[
  {
    "path": "AUTHORS",
    "content": "# This file lists authors for copyright purposes.  This file is distinct from\n# the CONTRIBUTORS files.  See the latter for an explanation.\n#\n# Names should be added to this file as:\n#     Name or Organization <email address>\n#\n# The email address is not required for organizations.\n#\n# Please keep the list sorted.\n\nDan Kortschak <dan.kortschak@adelaide.edu.au>\nJan Mercl <0xjnml@gmail.com>\nMaxim Kupriianov <max@kc.vc>\nPeter Waller <p@pwaller.net>\nSteffen Butzer <steffen(dot)butzer@outlook.com>\nYasuhiro Matsumoto <mattn.jp@gmail.com>\n"
  },
  {
    "path": "CONTRIBUTORS",
    "content": "# This file lists people who contributed code to this repository.  The AUTHORS\n# file lists the copyright holders; this file lists people.\n#\n# Names should be added to this file like so:\n#     Name <email address>\n#\n# Please keep the list sorted.\n\nDan Kortschak <dan.kortschak@adelaide.edu.au>\nJan Mercl <0xjnml@gmail.com>\nMaxim Kupriianov <max@kc.vc>\nPeter Waller <p@pwaller.net>\nSteffen Butzer <steffen(dot)butzer@outlook.com>\nZvi Effron <zeffron@cs.hmc.edu>\nYasuhiro Matsumoto <mattn.jp@gmail.com>\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014 The CC Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n   * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n   * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n   * Neither the names of the authors nor the names of the\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "Makefile",
    "content": "# Copyright 2016 The CC Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style\n# license that can be found in the LICENSE file.\n\n.PHONY:\tall clean cover cpu edit editor internalError later mem nuke todo\n\ngrep=--include=*.go --include=*.l --include=*.y\n\nall: editor\n\trm -f log-*.c log-*.h\n\tgo vet || true\n\tgolint || true\n\tmake todo\n\tunused . || true\n\tmaligned\n\tunconvert -apply\n\nclean:\n\trm -f log-*.c log-*.h *~ cpu.test mem.test /tmp/cc-test-* log*.c\n\tgo clean\n\ncover:\n\tt=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t\n\ncpu:\n\tgo test -c -o cpu.test\n\t./cpu.test -noerr -test.cpuprofile cpu.out\n\tgo tool pprof --lines cpu.test cpu.out\n\nedit:\n\tgvim -p Makefile trigraphs.l scanner.l parser.yy all_test.go ast2.go cc.go cpp.go encoding.go etc.go lexer.go model.go\n\neditor: parser.go scanner.go trigraphs.go\n\trm -f log-*.c log-*.h\n\tgofmt -l -s -w *.go\n\trm -f log-*.c log-*.h\n\tgo test -i\n\tgo test 2>&1 | tee log\n\tgo install\n\ninternalError:\n\tegrep -ho '\"internal error.*\"' *.go | sort | cat -n\n\nlater:\n\t@grep -n $(grep) LATER * || true\n\t@grep -n $(grep) MAYBE * || true\n\nmem:\n\tgo test -c -o mem.test\n\t./mem.test -test.bench . -test.memprofile mem.out\n\tgo tool pprof --lines --web --alloc_space mem.test mem.out\n\nnuke: clean\n\tgo clean -i\n\nparser.go scanner.go trigraphs.go: parser.yy trigraphs.l scanner.l\n\trm -f log-*.c log-*.h\n\tgo test -i\n\tgo generate\n\ntodo:\n\t@grep -n $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true\n\t@grep -n $(grep) TODO * || true\n\t@grep -n $(grep) BUG * || true\n\t@grep -n $(grep) [^[:alpha:]]println * || true\n"
  },
  {
    "path": "README.md",
    "content": "`github.com/cznic/cc` has moved to [`modernc.org/cc`](https://godoc.org/modernc.org/cc) ([vcs](https://gitlab.com/cznic/cc)).\n\nPlease update your import paths to `modernc.org/cc`.\n\nThis repo is now archived.\n"
  },
  {
    "path": "all_test.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"go/scanner\"\n\t\"go/token\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"runtime/debug\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\t\"testing\"\n\t\"unicode\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\nfunc printStack() { debug.PrintStack() }\n\nfunc caller(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(2)\n\tfmt.Fprintf(os.Stderr, \"caller: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\t_, fn, fl, _ = runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"\\tcallee: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc dbg(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"dbg %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc TODO(...interface{}) string {\n\t_, fn, fl, _ := runtime.Caller(1)\n\treturn fmt.Sprintf(\"TODO: %s:%d:\\n\", path.Base(fn), fl)\n}\n\nfunc use(...interface{}) int { return 42 }\n\nvar _ = use(printStack, caller, dbg, TODO, (*ctype).str, yyDefault, yyErrCode, yyMaxDepth)\n\n// ============================================================================\n\nvar (\n\to1        = flag.String(\"1\", \"\", \"single file argument of TestPPParse1.\")\n\toDev      = flag.Bool(\"dev\", false, \"enable WIP tests\")\n\toFailFast = flag.Bool(\"ff\", false, \"crash on first reported error (in some tests.)\")\n\toRe       = flag.String(\"re\", \"\", \"regexp filter.\")\n\toTmp      = flag.Bool(\"tmp\", false, \"keep certain temp files.\")\n\toTrace    = flag.Bool(\"trc\", false, \"print testDev path\")\n\n\tincludes = []string{}\n\n\tpredefinedMacros = `\n#define __STDC_HOSTED__ 1\n#define __STDC_VERSION__ 199901L\n#define __STDC__ 1\n\n#define __MODEL64\n\nvoid __GO__(char *s, ...);\n`\n\tsysIncludes = []string{}\n\n\ttestTweaks = &tweaks{\n\t\tenableDefineOmitCommaBeforeDDD: true,\n\t\tenableDlrInIdentifiers:         true,\n\t\tenableEmptyDefine:              true,\n\t\tenableUndefExtraTokens:         true,\n\t}\n)\n\nfunc newTestReport() *xc.Report {\n\tr := xc.NewReport()\n\tr.ErrLimit = -1\n\tif *oFailFast {\n\t\tr.PanicOnError = true\n\t}\n\treturn r\n}\n\nfunc init() {\n\tisTesting = true\n\tlog.SetFlags(log.Llongfile)\n\tflag.BoolVar(&debugIncludes, \"dbgi\", false, \"debug include searches\")\n\tflag.BoolVar(&debugMacros, \"dbgm\", false, \"debug macros\")\n\tflag.BoolVar(&debugTypeStrings, \"xtypes\", false, \"add debug info to type strings\")\n\tflag.BoolVar(&isGenerating, \"generating\", false, \"go generate is executing (false).\")\n\tflag.IntVar(&yyDebug, \"yydebug\", 0, \"\")\n}\n\nfunc newTestModel() *Model {\n\treturn &Model{ // 64\n\t\tItems: map[Kind]ModelItem{\n\t\t\tPtr:               {8, 8, 8, nil},\n\t\t\tUintPtr:           {8, 8, 8, nil},\n\t\t\tVoid:              {0, 1, 1, nil},\n\t\t\tChar:              {1, 1, 1, nil},\n\t\t\tSChar:             {1, 1, 1, nil},\n\t\t\tUChar:             {1, 1, 1, nil},\n\t\t\tShort:             {2, 2, 2, nil},\n\t\t\tUShort:            {2, 2, 2, nil},\n\t\t\tInt:               {4, 4, 4, nil},\n\t\t\tUInt:              {4, 4, 4, nil},\n\t\t\tLong:              {8, 8, 8, nil},\n\t\t\tULong:             {8, 8, 8, nil},\n\t\t\tLongLong:          {8, 8, 8, nil},\n\t\t\tULongLong:         {8, 8, 8, nil},\n\t\t\tFloat:             {4, 4, 4, nil},\n\t\t\tDouble:            {8, 8, 8, nil},\n\t\t\tLongDouble:        {16, 16, 16, nil},\n\t\t\tBool:              {1, 1, 1, nil},\n\t\t\tFloatComplex:      {8, 8, 8, nil},\n\t\t\tDoubleComplex:     {16, 16, 16, nil},\n\t\t\tLongDoubleComplex: {16, 16, 16, nil},\n\t\t},\n\t}\n}\n\nfunc printError(w io.Writer, pref string, err error) {\n\tswitch x := err.(type) {\n\tcase scanner.ErrorList:\n\t\tfor i, v := range x {\n\t\t\tfmt.Fprintf(w, \"%s%v\\n\", pref, v)\n\t\t\tif i == 50 {\n\t\t\t\tfmt.Fprintln(w, \"too many errors\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tfmt.Fprintf(w, \"%s%v\\n\", pref, err)\n\t}\n}\n\nfunc errString(err error) string {\n\tvar b bytes.Buffer\n\tprintError(&b, \"\", err)\n\treturn b.String()\n}\n\nfunc testUCNTable(t *testing.T, tab []rune, fOk, fOther func(rune) bool, fcategory func(rune) bool, tag string) {\n\tm := map[rune]struct{}{}\n\tfor i := 0; i < len(tab); i += 2 {\n\t\tl, h := tab[i], tab[i+1]\n\t\tif h == 0 {\n\t\t\th = l\n\t\t}\n\t\tfor r := rune(l); r <= rune(h); r++ {\n\t\t\tm[r] = struct{}{}\n\t\t}\n\t}\n\tfor r := rune(0); r < 0xffff; r++ {\n\t\t_, ok := m[r]\n\t\tif g, e := fOk(r), ok; g != e {\n\t\t\tt.Errorf(\"%#04x %v %v\", r, g, e)\n\t\t}\n\n\t\tif ok {\n\t\t\tif g, e := fOther(r), false; g != e {\n\t\t\t\tt.Errorf(\"%#04x %v %v\", r, g, e)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestUCNDigitsTable(t *testing.T) {\n\ttab := []rune{\n\t\t0x0660, 0x0669, 0x06F0, 0x06F9, 0x0966, 0x096F, 0x09E6, 0x09EF, 0x0A66, 0x0A6F,\n\t\t0x0AE6, 0x0AEF, 0x0B66, 0x0B6F, 0x0BE7, 0x0BEF, 0x0C66, 0x0C6F, 0x0CE6, 0x0CEF,\n\t\t0x0D66, 0x0D6F, 0x0E50, 0x0E59, 0x0ED0, 0x0ED9, 0x0F20, 0x0F33,\n\t}\n\ttestUCNTable(t, tab, isUCNDigit, isUCNNonDigit, unicode.IsDigit, \"unicode.IsDigit\")\n}\n\nfunc TestUCNNonDigitsTable(t *testing.T) {\n\ttab := []rune{\n\t\t0x00AA, 0x0000, 0x00B5, 0x0000, 0x00B7, 0x0000, 0x00BA, 0x0000, 0x00C0, 0x00D6,\n\t\t0x00D8, 0x00F6, 0x00F8, 0x01F5, 0x01FA, 0x0217, 0x0250, 0x02A8, 0x02B0, 0x02B8,\n\t\t0x02BB, 0x0000, 0x02BD, 0x02C1, 0x02D0, 0x02D1, 0x02E0, 0x02E4, 0x037A, 0x0000,\n\t\t0x0386, 0x0000, 0x0388, 0x038A, 0x038C, 0x0000, 0x038E, 0x03A1, 0x03A3, 0x03CE,\n\t\t0x03D0, 0x03D6, 0x03DA, 0x0000, 0x03DC, 0x0000, 0x03DE, 0x0000, 0x03E0, 0x0000,\n\t\t0x03E2, 0x03F3, 0x0401, 0x040C, 0x040E, 0x044F, 0x0451, 0x045C, 0x045E, 0x0481,\n\t\t0x0490, 0x04C4, 0x04C7, 0x04C8, 0x04CB, 0x04CC, 0x04D0, 0x04EB, 0x04EE, 0x04F5,\n\t\t0x04F8, 0x04F9, 0x0531, 0x0556, 0x0559, 0x0000, 0x0561, 0x0587, 0x05B0, 0x05B9,\n\t\t0x05F0, 0x05F2, 0x0621, 0x063A, 0x0640, 0x0652, 0x0670, 0x06B7, 0x06BA, 0x06BE,\n\t\t0x06C0, 0x06CE, 0x06D0, 0x06DC, 0x06E5, 0x06E8, 0x06EA, 0x06ED, 0x0901, 0x0903,\n\t\t0x0905, 0x0939, 0x093D, 0x0000, 0x093E, 0x094D, 0x0950, 0x0952, 0x0958, 0x0963,\n\t\t0x0981, 0x0983, 0x0985, 0x098C, 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA, 0x09B0,\n\t\t0x09B2, 0x0000, 0x09B6, 0x09B9, 0x09BE, 0x09C4, 0x09C7, 0x09C8, 0x09CB, 0x09CD,\n\t\t0x09DC, 0x09DD, 0x09DF, 0x09E3, 0x09F0, 0x09F1, 0x0A02, 0x0000, 0x0A05, 0x0A0A,\n\t\t0x0A0F, 0x0A10, 0x0A13, 0x0A28, 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36,\n\t\t0x0A38, 0x0A39, 0x0A3E, 0x0A42, 0x0A47, 0x0A48, 0x0A4B, 0x0A4D, 0x0A59, 0x0A5C,\n\t\t0x0A5E, 0x0000, 0x0A74, 0x0000, 0x0A81, 0x0A83, 0x0A85, 0x0A8B, 0x0A8D, 0x0000,\n\t\t0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, 0x0AB5, 0x0AB9,\n\t\t0x0ABD, 0x0AC5, 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0AD0, 0x0000, 0x0AE0, 0x0000,\n\t\t0x0B01, 0x0B03, 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28, 0x0B2A, 0x0B30,\n\t\t0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B3D, 0x0000, 0x0B3E, 0x0B43, 0x0B47, 0x0B48,\n\t\t0x0B4B, 0x0B4D, 0x0B5C, 0x0B5D, 0x0B5F, 0x0B61, 0x0B82, 0x0B83, 0x0B85, 0x0B8A,\n\t\t0x0B8E, 0x0B90, 0x0B92, 0x0B95, 0x0B99, 0x0B9A, 0x0B9C, 0x0000, 0x0B9E, 0x0B9F,\n\t\t0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA, 0x0BAE, 0x0BB5, 0x0BB7, 0x0BB9, 0x0BBE, 0x0BC2,\n\t\t0x0BC6, 0x0BC8, 0x0BCA, 0x0BCD, 0x0C01, 0x0C03, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10,\n\t\t0x0C12, 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C3E, 0x0C44, 0x0C46, 0x0C48,\n\t\t0x0C4A, 0x0C4D, 0x0C60, 0x0C61, 0x0C82, 0x0C83, 0x0C85, 0x0C8C, 0x0C8E, 0x0C90,\n\t\t0x0C92, 0x0CA8, 0x0CAA, 0x0CB3, 0x0CB5, 0x0CB9, 0x0CBE, 0x0CC4, 0x0CC6, 0x0CC8,\n\t\t0x0CCA, 0x0CCD, 0x0CDE, 0x0000, 0x0CE0, 0x0CE1, 0x0D02, 0x0D03, 0x0D05, 0x0D0C,\n\t\t0x0D0E, 0x0D10, 0x0D12, 0x0D28, 0x0D2A, 0x0D39, 0x0D3E, 0x0D43, 0x0D46, 0x0D48,\n\t\t0x0D4A, 0x0D4D, 0x0D60, 0x0D61, 0x0E01, 0x0E3A,\n\n\t\t// In [0], Annex D, Thai [0x0E40, 0x0E5B] overlaps with digits\n\t\t// [0x0E50, 0x0E59]. Exclude them.\n\t\t0x0E40, 0x0E4F,\n\t\t0x0E5A, 0x0E5B,\n\n\t\t0x0E81, 0x0E82,\n\t\t0x0E84, 0x0000, 0x0E87, 0x0E88, 0x0E8A, 0x0000, 0x0E8D, 0x0000, 0x0E94, 0x0E97,\n\t\t0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EA5, 0x0000, 0x0EA7, 0x0000, 0x0EAA, 0x0EAB,\n\t\t0x0EAD, 0x0EAE, 0x0EB0, 0x0EB9, 0x0EBB, 0x0EBD, 0x0EC0, 0x0EC4, 0x0EC6, 0x0000,\n\t\t0x0EC8, 0x0ECD, 0x0EDC, 0x0EDD, 0x0F00, 0x0000, 0x0F18, 0x0F19, 0x0F35, 0x0000,\n\t\t0x0F37, 0x0000, 0x0F39, 0x0000, 0x0F3E, 0x0F47, 0x0F49, 0x0F69, 0x0F71, 0x0F84,\n\t\t0x0F86, 0x0F8B, 0x0F90, 0x0F95, 0x0F97, 0x0000, 0x0F99, 0x0FAD, 0x0FB1, 0x0FB7,\n\t\t0x0FB9, 0x0000, 0x10A0, 0x10C5, 0x10D0, 0x10F6, 0x1E00, 0x1E9B, 0x1EA0, 0x1EF9,\n\t\t0x1F00, 0x1F15, 0x1F18, 0x1F1D, 0x1F20, 0x1F45, 0x1F48, 0x1F4D, 0x1F50, 0x1F57,\n\t\t0x1F59, 0x0000, 0x1F5B, 0x0000, 0x1F5D, 0x0000, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4,\n\t\t0x1FB6, 0x1FBC, 0x1FBE, 0x0000, 0x1FC2, 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3,\n\t\t0x1FD6, 0x1FDB, 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC, 0x203F, 0x2040,\n\t\t0x207F, 0x0000, 0x2102, 0x0000, 0x2107, 0x0000, 0x210A, 0x2113, 0x2115, 0x0000,\n\t\t0x2118, 0x211D, 0x2124, 0x0000, 0x2126, 0x0000, 0x2128, 0x0000, 0x212A, 0x2131,\n\t\t0x2133, 0x2138, 0x2160, 0x2182, 0x3005, 0x3007, 0x3021, 0x3029, 0x3041, 0x3093,\n\t\t0x309B, 0x309C, 0x30A1, 0x30F6, 0x30FB, 0x30FC, 0x3105, 0x312C, 0x4E00, 0x9FA5,\n\t\t0xAC00, 0xD7A3,\n\t}\n\ttestUCNTable(t, tab, isUCNNonDigit, isUCNDigit, unicode.IsLetter, \"unicode.IsLetter\")\n}\n\nfunc charStr(c rune) string {\n\treturn yySymName(int(c))\n}\n\nfunc charsStr(chars []lex.Char, delta token.Pos) (a []string) {\n\tfor _, v := range chars {\n\t\ta = append(a, fmt.Sprintf(\"{%s %d}\", charStr(v.Rune), v.Pos()-delta))\n\t}\n\treturn a\n}\n\ntype x []struct {\n\tc   rune\n\tpos token.Pos\n}\n\ntype lexerTests []struct {\n\tsrc   string\n\tchars x\n}\n\nfunc testLexer(t *testing.T, newLexer func(i int, src string, report *xc.Report) (*lexer, error), tab lexerTests) {\nnextTest:\n\tfor ti, test := range tab {\n\t\t//dbg(\"==== %v\", ti)\n\t\treport := xc.NewReport()\n\t\tlx, err := newLexer(ti, test.src, report)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tdelta := token.Pos(lx.file.Base() - 1)\n\t\tvar chars []lex.Char\n\t\tvar c lex.Char\n\t\tfor i := 0; c.Rune != ccEOF && i < len(test.src)+2; i++ {\n\t\t\tc = lx.scanChar()\n\t\t\tchars = append(chars, c)\n\t\t}\n\t\tif c.Rune != ccEOF {\n\t\t\tt.Errorf(\"%d: scanner stall %v\", ti, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tif g, e := report.Errors(true), error(nil); g != e {\n\t\t\tt.Errorf(\"%d: lx.err %v %v %v\", ti, g, e, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tif g, e := len(chars), len(test.chars); g != e {\n\t\t\tt.Errorf(\"%d: len(chars) %v %v %v\", ti, g, e, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tfor i, c := range chars {\n\t\t\tc = chars[i]\n\t\t\te := test.chars[i]\n\t\t\tg := c.Rune\n\t\t\tif c.Rune == ccEOF {\n\t\t\t\tg = -1\n\t\t\t}\n\t\t\tif e := e.c; g != e {\n\t\t\t\tt.Errorf(\"%d: c[%d] %v %v %v\", ti, i, charStr(g), charStr(e), charsStr(chars, delta))\n\t\t\t\tcontinue nextTest\n\t\t\t}\n\n\t\t\tif g, e := c.Pos()-delta, e.pos; g != e {\n\t\t\t\tt.Errorf(\"%d: pos[%d] %v %v %v\", ti, i, g, e, charsStr(chars, delta))\n\t\t\t\tcontinue nextTest\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestLexer(t *testing.T) {\n\ttestLexer(\n\t\tt,\n\t\tfunc(i int, src string, report *xc.Report) (*lexer, error) {\n\t\t\treturn newLexer(fmt.Sprintf(\"TestLexer.%d\", i), len(src), strings.NewReader(src), report, testTweaks)\n\t\t},\n\t\tlexerTests{\n\t\t\t{\"\", x{{-1, 1}}},\n\t\t\t{\"%0\", x{{'%', 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"%:%:\", x{{PPPASTE, 1}, {-1, 5}}},\n\t\t\t{\"%>\", x{{'}', 1}, {-1, 3}}},\n\t\t\t{\"0\", x{{INTCONST, 1}, {-1, 2}}},\n\t\t\t{\"01\", x{{INTCONST, 1}, {-1, 3}}},\n\t\t\t{\"0??/1\\n\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {INTCONST, 5}, {'\\n', 6}, {-1, 7}}},\n\t\t\t{\"0??/1\\n2\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {INTCONST, 5}, {'\\n', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"0??/\\n\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"0??/\\n2\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"0\\\\1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"0\\\\1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"0\\\\\\n\", x{{INTCONST, 1}, {-1, 4}}},\n\t\t\t{\"0\\\\\\n2\", x{{INTCONST, 1}, {-1, 5}}},\n\t\t\t{\"0\\x00\", x{{INTCONST, 1}, {0, 2}, {-1, 3}}},\n\t\t\t{\"0\\x001\", x{{INTCONST, 1}, {0, 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\":>\", x{{']', 1}, {-1, 3}}},\n\t\t\t{\"<%\", x{{'{', 1}, {-1, 3}}},\n\t\t\t{\"<:\", x{{'[', 1}, {-1, 3}}},\n\t\t\t{\"??!\", x{{'?', 1}, {'?', 2}, {'!', 3}, {-1, 4}}},\n\t\t\t{\"??!0\", x{{'?', 1}, {'?', 2}, {'!', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"??!01\", x{{'?', 1}, {'?', 2}, {'!', 3}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"??!=\", x{{'?', 1}, {'?', 2}, {NEQ, 3}, {-1, 5}}},\n\t\t\t{\"??'\", x{{'?', 1}, {'?', 2}, {'\\'', 3}, {-1, 4}}},\n\t\t\t{\"??(\", x{{'?', 1}, {'?', 2}, {'(', 3}, {-1, 4}}},\n\t\t\t{\"??)\", x{{'?', 1}, {'?', 2}, {')', 3}, {-1, 4}}},\n\t\t\t{\"??-\", x{{'?', 1}, {'?', 2}, {'-', 3}, {-1, 4}}},\n\t\t\t{\"??/\", x{{'?', 1}, {'?', 2}, {'/', 3}, {-1, 4}}},\n\t\t\t{\"??/1\\n\", x{{'?', 1}, {'?', 2}, {'/', 3}, {INTCONST, 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"??/1\\n2\", x{{'?', 1}, {'?', 2}, {'/', 3}, {INTCONST, 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"??/\\n\", x{{'?', 1}, {'?', 2}, {'/', 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"??/\\n2\", x{{'?', 1}, {'?', 2}, {'/', 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"??<\", x{{'?', 1}, {'?', 2}, {'<', 3}, {-1, 4}}},\n\t\t\t{\"??=??=\", x{{'?', 1}, {'?', 2}, {'=', 3}, {'?', 4}, {'?', 5}, {'=', 6}, {-1, 7}}},\n\t\t\t{\"??>\", x{{'?', 1}, {'?', 2}, {'>', 3}, {-1, 4}}},\n\t\t\t{\"???!\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'!', 4}, {-1, 5}}},\n\t\t\t{\"???!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'!', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"???/\\n2\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"????!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'?', 4}, {'!', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"???x0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {-1, 6}}},\n\t\t\t{\"???x??!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {'?', 5}, {'?', 6}, {'!', 7}, {INTCONST, 8}, {-1, 9}}},\n\t\t\t{\"??x0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {-1, 5}}},\n\t\t\t{\"??x??!0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {'?', 4}, {'?', 5}, {'!', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"?x0\", x{{'?', 1}, {IDENTIFIER, 2}, {-1, 4}}},\n\t\t\t{\"?x??!0\", x{{'?', 1}, {IDENTIFIER, 2}, {'?', 3}, {'?', 4}, {'!', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"@\", x{{'@', 1}, {-1, 2}}},\n\t\t\t{\"@%\", x{{'@', 1}, {'%', 2}, {-1, 3}}},\n\t\t\t{\"@%0\", x{{'@', 1}, {'%', 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"@%:\", x{{'@', 1}, {'#', 2}, {-1, 4}}},\n\t\t\t{\"@%:0\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"@%:01\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"@??=\", x{{'@', 1}, {'?', 2}, {'?', 3}, {'=', 4}, {-1, 5}}},\n\t\t\t{\"\\\"(a\\\\\\nz\", x{{'\"', 1}, {'(', 2}, {IDENTIFIER, 3}, {-1, 7}}},\n\t\t\t{\"\\\\1\\n\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {-1, 4}}},\n\t\t\t{\"\\\\1\\n2\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\\\\\n\", x{{-1, 3}}},\n\t\t\t{\"\\\\\\n2\", x{{INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"\\\\\\r\\n\", x{{-1, 4}}},\n\t\t\t{\"\\\\\\r\\n2\", x{{INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\r\", x{{-1, 2}}},\n\t\t\t{\"\\r0\", x{{INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"\\r01\", x{{INTCONST, 2}, {-1, 4}}},\n\t\t\t{\"\\x00\", x{{0, 1}, {-1, 2}}},\n\t\t\t{\"\\x000\", x{{0, 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t},\n\t)\n}\n\nfunc TestLexer2(t *testing.T) {\n\ttestLexer(\n\t\tt,\n\t\tfunc(i int, src string, report *xc.Report) (*lexer, error) {\n\t\t\ttweaks := *testTweaks\n\t\t\ttweaks.enableTrigraphs = true\n\t\t\treturn newLexer(fmt.Sprintf(\"TestLexer.%d\", i), len(src), strings.NewReader(src), report, &tweaks)\n\t\t},\n\t\tlexerTests{\n\t\t\t{\"\", x{{-1, 1}}},\n\t\t\t{\"%0\", x{{'%', 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"%:%:\", x{{PPPASTE, 1}, {-1, 5}}},\n\t\t\t{\"%>\", x{{'}', 1}, {-1, 3}}},\n\t\t\t{\"0\", x{{INTCONST, 1}, {-1, 2}}},\n\t\t\t{\"01\", x{{INTCONST, 1}, {-1, 3}}},\n\t\t\t{\"0??/1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 5}, {'\\n', 6}, {-1, 7}}},\n\t\t\t{\"0??/1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 5}, {'\\n', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"0??/\\n\", x{{INTCONST, 1}, {-1, 6}}},\n\t\t\t{\"0??/\\n2\", x{{INTCONST, 1}, {-1, 7}}},\n\t\t\t{\"0\\\\1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"0\\\\1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"0\\\\\\n\", x{{INTCONST, 1}, {-1, 4}}},\n\t\t\t{\"0\\\\\\n2\", x{{INTCONST, 1}, {-1, 5}}},\n\t\t\t{\"0\\x00\", x{{INTCONST, 1}, {0, 2}, {-1, 3}}},\n\t\t\t{\"0\\x001\", x{{INTCONST, 1}, {0, 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\":>\", x{{']', 1}, {-1, 3}}},\n\t\t\t{\"<%\", x{{'{', 1}, {-1, 3}}},\n\t\t\t{\"<:\", x{{'[', 1}, {-1, 3}}},\n\t\t\t{\"??!\", x{{'|', 1}, {-1, 4}}},\n\t\t\t{\"??!0\", x{{'|', 1}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"??!01\", x{{'|', 1}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"??!=\", x{{ORASSIGN, 1}, {-1, 5}}},\n\t\t\t{\"??'\", x{{'^', 1}, {-1, 4}}},\n\t\t\t{\"??(\", x{{'[', 1}, {-1, 4}}},\n\t\t\t{\"??)\", x{{']', 1}, {-1, 4}}},\n\t\t\t{\"??-\", x{{'~', 1}, {-1, 4}}},\n\t\t\t{\"??/\", x{{'\\\\', 1}, {-1, 4}}},\n\t\t\t{\"??/1\\n\", x{{'\\\\', 1}, {INTCONST, 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"??/1\\n2\", x{{'\\\\', 1}, {INTCONST, 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"??/\\n\", x{{-1, 5}}},\n\t\t\t{\"??/\\n2\", x{{INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"??<\", x{{'{', 1}, {-1, 4}}},\n\t\t\t{\"??=??=\", x{{PPPASTE, 1}, {-1, 7}}},\n\t\t\t{\"??>\", x{{'}', 1}, {-1, 4}}},\n\t\t\t{\"???!\", x{{'?', 1}, {'|', 2}, {-1, 5}}},\n\t\t\t{\"???!0\", x{{'?', 1}, {'|', 2}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"???/\\n2\", x{{'?', 1}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"????!0\", x{{'?', 1}, {'?', 2}, {'|', 3}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"???x0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {-1, 6}}},\n\t\t\t{\"???x??!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {'|', 5}, {INTCONST, 8}, {-1, 9}}},\n\t\t\t{\"??x0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {-1, 5}}},\n\t\t\t{\"??x??!0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {'|', 4}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"?x0\", x{{'?', 1}, {IDENTIFIER, 2}, {-1, 4}}},\n\t\t\t{\"?x??!0\", x{{'?', 1}, {IDENTIFIER, 2}, {'|', 3}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"@\", x{{'@', 1}, {-1, 2}}},\n\t\t\t{\"@%\", x{{'@', 1}, {'%', 2}, {-1, 3}}},\n\t\t\t{\"@%0\", x{{'@', 1}, {'%', 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"@%:\", x{{'@', 1}, {'#', 2}, {-1, 4}}},\n\t\t\t{\"@%:0\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"@%:01\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"@??=\", x{{'@', 1}, {'#', 2}, {-1, 5}}},\n\t\t\t{\"\\\"(a\\\\\\nz\", x{{'\"', 1}, {'(', 2}, {IDENTIFIER, 3}, {-1, 7}}},\n\t\t\t{\"\\\\1\\n\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {-1, 4}}},\n\t\t\t{\"\\\\1\\n2\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\\\\\n\", x{{-1, 3}}},\n\t\t\t{\"\\\\\\n2\", x{{INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"\\\\\\r\\n\", x{{-1, 4}}},\n\t\t\t{\"\\\\\\r\\n2\", x{{INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\r\", x{{-1, 2}}},\n\t\t\t{\"\\r0\", x{{INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"\\r01\", x{{INTCONST, 2}, {-1, 4}}},\n\t\t\t{\"\\x00\", x{{0, 1}, {-1, 2}}},\n\t\t\t{\"\\x000\", x{{0, 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t},\n\t)\n}\n\nfunc testPreprocessor(t *testing.T, fname string) string {\n\tvar buf bytes.Buffer\n\t_, err := Parse(\n\t\t\"\",\n\t\t[]string{fname},\n\t\tnewTestModel(),\n\t\tpreprocessOnly(),\n\t\tCpp(func(toks []xc.Token) {\n\t\t\t//dbg(\"____ cpp toks\\n%s\", PrettyString(toks))\n\t\t\tfor _, v := range toks {\n\t\t\t\tbuf.WriteString(TokSrc(v))\n\t\t\t}\n\t\t\tbuf.WriteByte('\\n')\n\t\t}),\n\t\tEnableDefineOmitCommaBeforeDDD(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\treturn strings.TrimSpace(buf.String())\n}\n\nfunc TestStdExample6_10_3_3_4(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.3-4.h\"), `char p[] = \"x ## y\";`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nfunc TestStdExample6_10_3_5_3(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.5-3.h\"),\n\t\t`f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);\nf(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) &\nf(2 * (0,1))^m(0,1);\nint i[] = { 1, 23, 4, 5,  };\nchar c[2][6] = { \"hello\", \"\" };`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nfunc TestStdExample6_10_3_5_4(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.5-4.h\"),\n\t\t`printf(\"x1= %d, x2= %s\", x1, x2);\nfputs(\n\"strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0: @\\n\", s);\nvers2.h included from testdata/example-6.10.3.5-4.h\n\"hello\";\n\"hello, world\"`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nfunc TestStdExample6_10_3_5_5(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.5-5.h\"),\n\t\t`int j[] = { 123, 45, 67, 89,\n10, 11, 12,  };`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nfunc TestStdExample6_10_3_5_6(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.5-6.h\"),\n\t\t`ok`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nfunc TestStdExample6_10_3_5_7(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/example-6.10.3.5-7.h\"),\n\t\t`fprintf(stderr, \"Flag\");\nfprintf(stderr, \"X = %d\\n\", x);\nputs(\"The first, second, and third items.\");\n((x>y)?puts(\"x>y\"): printf(\"x is %d but y is %d\", x, y));`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\ntype cppCmpError struct {\n\terror\n}\n\nfunc testDev1(ppPredefine, cppPredefine, parsePredefine string, cppOpts []string, wd, src string, ppOpts, parseOpts []Opt) error {\n\tfp := filepath.Join(wd, src)\n\tif re := *oRe; re != \"\" {\n\t\tok, err := regexp.MatchString(re, fp)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tlogf, err := os.Create(\"log-\" + filepath.Base(src))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer logf.Close()\n\n\tlogw := bufio.NewWriter(logf)\n\n\tdefer logw.Flush()\n\n\tif *oTrace {\n\t\tfmt.Println(fp)\n\t\tfmt.Println(logf.Name())\n\t}\n\n\tvar got, exp []xc.Token\n\tvar lpos token.Position\n\n\tvar tw tweaks\n\t_, err = Parse(\n\t\tppPredefine,\n\t\t[]string{src},\n\t\tnewTestModel(),\n\t\tappend(\n\t\t\tppOpts,\n\t\t\tgetTweaks(&tw),\n\t\t\tpreprocessOnly(),\n\t\t\tCpp(func(toks []xc.Token) {\n\t\t\t\tif len(toks) != 0 {\n\t\t\t\t\tp := toks[0].Position()\n\t\t\t\t\tif p.Filename != lpos.Filename {\n\t\t\t\t\t\tfmt.Fprintf(logw, \"# %d %q\\n\", p.Line, p.Filename)\n\t\t\t\t\t}\n\t\t\t\t\tlpos = p\n\t\t\t\t}\n\t\t\t\tfor _, v := range toks {\n\t\t\t\t\tlogw.WriteString(TokSrc(toC(v, &tw)))\n\t\t\t\t\tif v.Rune != ' ' {\n\t\t\t\t\t\tgot = append(got, v)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlogw.WriteByte('\\n')\n\t\t\t}),\n\t\t\tdisableWarnings(),\n\t\t\tdisablePredefinedLineMacro(),\n\t\t)...,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tout, err := exec.Command(\"cpp\", append(cppOpts, src)...).CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%v: %v\", src, err)\n\t}\n\n\tf, err := ioutil.TempFile(\"\", \"cc-test-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif *oTrace {\n\t\tfmt.Println(f.Name())\n\t}\n\tdefer func() {\n\t\tif !*oTmp {\n\t\t\tos.Remove(f.Name())\n\t\t}\n\t\tf.Close()\n\t}()\n\n\tif _, err := f.Write(out); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := Parse(\n\t\tcppPredefine,\n\t\t[]string{f.Name()},\n\t\tnewTestModel(),\n\t\tpreprocessOnly(),\n\t\tCpp(func(toks []xc.Token) {\n\t\t\tfor _, tok := range toks {\n\t\t\t\tif tok.Rune != ' ' {\n\t\t\t\t\texp = append(exp, tok)\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t\tdisableWarnings(),\n\t); err != nil {\n\t\treturn err\n\t}\n\n\tfor i, g := range got {\n\t\tif i >= len(exp) {\n\t\t\tbreak\n\t\t}\n\n\t\tg = toC(g, &tw)\n\t\te := toC(exp[i], &tw)\n\t\tif g.Rune != e.Rune || g.Val != e.Val {\n\n\t\t\tif g.Rune == STRINGLITERAL && e.Rune == STRINGLITERAL && bytes.Contains(g.S(), []byte(fakeTime)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif g.Rune == IDENTIFIER && e.Rune == INTCONST && g.Val == idLine {\n\t\t\t\tn, err := strconv.ParseUint(string(e.S()), 10, mathutil.IntBits-1)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\td := g.Position().Line - int(n)\n\t\t\t\tif d < 0 {\n\t\t\t\t\td = -d\n\t\t\t\t}\n\t\t\t\tif d <= 3 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn cppCmpError{fmt.Errorf(\"%d\\ngot %s\\nexp %s\", i, PrettyString(g), PrettyString(e))}\n\t\t}\n\t}\n\n\tif g, e := len(got), len(exp); g != e {\n\t\treturn cppCmpError{fmt.Errorf(\"%v: got %d tokens, expected %d tokens (∆ %d)\", src, g, e, g-e)}\n\t}\n\n\tlogf2, err := os.Create(\"log2-\" + filepath.Base(src))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdefer logf2.Close()\n\n\tlogw2 := bufio.NewWriter(logf2)\n\n\tdefer logw2.Flush()\n\n\tif *oTrace {\n\t\tfmt.Println(logf2.Name())\n\t}\n\n\t_, err = Parse(\n\t\tparsePredefine,\n\t\t[]string{src},\n\t\tnewTestModel(),\n\t\tappend(\n\t\t\tparseOpts,\n\t\t\tdisableWarnings(),\n\t\t\tCpp(func(toks []xc.Token) {\n\t\t\t\tif len(toks) != 0 {\n\t\t\t\t\tp := toks[0].Position()\n\t\t\t\t\tif p.Filename != lpos.Filename {\n\t\t\t\t\t\tfmt.Fprintf(logw2, \"# %d %q\\n\", p.Line, p.Filename)\n\t\t\t\t\t}\n\t\t\t\t\tlpos = p\n\t\t\t\t}\n\t\t\t\tfor _, v := range toks {\n\t\t\t\t\tlogw2.WriteString(TokSrc(toC(v, &tw)))\n\t\t\t\t}\n\t\t\t\tlogw2.WriteByte('\\n')\n\t\t\t}),\n\t\t)...,\n\t)\n\treturn err\n}\n\nfunc testDev(t *testing.T, ppPredefine, cppPredefine, parsePredefine string, cppOpts, src []string, wd string, ppOpts, parseOpts []Opt) {\n\tif !dirExists(t, wd) {\n\t\tt.Logf(\"skipping: %v\", wd)\n\t\treturn\n\t}\n\n\tcwd, err := os.Getwd()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif err := os.Chdir(wd); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdefer os.Chdir(cwd)\n\n\tfor _, src := range src {\n\t\tfi, err := os.Stat(src)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif !fi.Mode().IsRegular() {\n\t\t\tt.Errorf(\"not a regular file: %s\", filepath.Join(wd, src))\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := testDev1(ppPredefine, cppPredefine, parsePredefine, cppOpts, wd, src, ppOpts, parseOpts); err != nil {\n\t\t\tt.Error(errString(err))\n\t\t}\n\t}\n}\n\nfunc dirExists(t *testing.T, dir string) bool {\n\tdir = filepath.FromSlash(dir)\n\tfi, err := os.Stat(dir)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false\n\t\t}\n\n\t\tt.Fatal(err)\n\t}\n\n\tif !fi.IsDir() {\n\t\tt.Fatal(dir, \"is not a directory\")\n\t}\n\n\treturn true\n}\n\nfunc TestPreprocessor(t *testing.T) {\n\tif err := testDev1(\"\", \"\", \"\", nil, \"\", \"testdata/arith-1.h\", nil, nil); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\nfunc TestDevSDL(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tEnableIncludeNext(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\ttestDev(\n\t\tt,\n\t\tpredefined,\n\t\tpredefined,\n\t\tpredefined+`\n#define __inline inline\n`,\n\t\tnil,\n\t\t[]string{\n\t\t\t\"SDL.h\",\n\t\t},\n\t\t\"testdata/dev/SDL-1.2.15/include/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevSqlite(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tEnableIncludeNext(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\ttestDev(\n\t\tt,\n\t\tpredefined,\n\t\tpredefined,\n\t\tpredefined+`\n#define __const const\n#define __inline inline\n#define __restrict restrict\n`,\n\t\tnil,\n\t\t[]string{\n\t\t\t\"shell.c\",\n\t\t\t\"sqlite3.c\",\n\t\t\t\"sqlite3.h\",\n\t\t\t\"sqlite3ext.h\",\n\t\t},\n\t\t\"testdata/dev/sqlite3\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevVim(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"proto\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tEnableDefineOmitCommaBeforeDDD(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"proto\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined + `\n#define _FORTIFY_SOURCE 1\n#define HAVE_CONFIG_H\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict restrict\n#define __typeof typeof\n`,\n\t\t[]string{\n\t\t\t\"-I.\",\n\t\t\t\"-Iproto\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-U_FORTIFY_SOURCE\",\n\t\t\t\"-D_FORTIFY_SOURCE=1\",\n\t\t},\n\t\t[]string{\n\t\t\t\"auto/pathdef.c\",\n\t\t\t\"blowfish.c\",\n\t\t\t\"buffer.c\",\n\t\t\t\"channel.c\",\n\t\t\t\"charset.c\",\n\t\t\t\"crypt.c\",\n\t\t\t\"crypt_zip.c\",\n\t\t\t\"diff.c\",\n\t\t\t\"digraph.c\",\n\t\t\t\"edit.c\",\n\t\t\t\"eval.c\",\n\t\t\t\"ex_cmds.c\",\n\t\t\t\"ex_cmds2.c\",\n\t\t\t\"ex_docmd.c\",\n\t\t\t\"ex_eval.c\",\n\t\t\t\"ex_getln.c\",\n\t\t\t\"fileio.c\",\n\t\t\t\"fold.c\",\n\t\t\t\"getchar.c\",\n\t\t\t\"hardcopy.c\",\n\t\t\t\"hashtab.c\",\n\t\t\t\"if_cscope.c\",\n\t\t\t\"if_xcmdsrv.c\",\n\t\t\t\"json.c\",\n\t\t\t\"main.c\",\n\t\t\t\"mark.c\",\n\t\t\t\"mbyte.c\",\n\t\t\t\"memfile.c\",\n\t\t\t\"memline.c\",\n\t\t\t\"menu.c\",\n\t\t\t\"message.c\",\n\t\t\t\"misc1.c\",\n\t\t\t\"misc2.c\",\n\t\t\t\"move.c\",\n\t\t\t\"netbeans.c\",\n\t\t\t\"normal.c\",\n\t\t\t\"ops.c\",\n\t\t\t\"option.c\",\n\t\t\t\"os_unix.c\",\n\t\t\t\"popupmnu.c\",\n\t\t\t\"quickfix.c\",\n\t\t\t\"regexp.c\",\n\t\t\t\"screen.c\",\n\t\t\t\"search.c\",\n\t\t\t\"sha256.c\",\n\t\t\t\"spell.c\",\n\t\t\t\"syntax.c\",\n\t\t\t\"tag.c\",\n\t\t\t\"term.c\",\n\t\t\t\"ui.c\",\n\t\t\t\"undo.c\",\n\t\t\t\"version.c\",\n\t\t\t\"window.c\",\n\t\t},\n\t\t\"testdata/dev/vim/vim/src\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevBash(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"include\",\n\t\t\t\"lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"include\",\n\t\t\t\"lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined + `\n#define PROGRAM \"bash\"\n#define CONF_HOSTTYPE \"x86_64\"\n#define CONF_OSTYPE \"linux-gnu\"\n#define CONF_MACHTYPE \"x86_64-unknown-linux-gnu\"\n#defien CONF_VENDOR \"unknown\"\n#define LOCALEDIR \"/usr/local/share/locale\"\n#define PACKAGE \"bash\"\n#define SHELL\n#define HAVE_CONFIG_H\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n#define __typeof typeof\n\t\t`,\n\t\t[]string{\n\t\t\t`-DPROGRAM=\"bash\"`,\n\t\t\t`-DCONF_HOSTTYPE=\"x86_64\"`,\n\t\t\t`-DCONF_OSTYPE=\"linux-gnu\"`,\n\t\t\t`-DCONF_MACHTYPE=\"x86_64-unknown-linux-gnu\"`,\n\t\t\t`-DCONF_VENDOR=\"unknown\"`,\n\t\t\t`-DLOCALEDIR=\"/usr/local/share/locale\"`,\n\t\t\t`-DPACKAGE=\"bash\"`,\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-Iinclude\",\n\t\t\t\"-Ilib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"alias.c\",\n\t\t\t\"array.c\",\n\t\t\t\"arrayfunc.c\",\n\t\t\t\"assoc.c\",\n\t\t\t\"bashhist.c\",\n\t\t\t\"bashline.c\",\n\t\t\t\"bracecomp.c\",\n\t\t\t\"braces.c\",\n\t\t\t\"copy_cmd.c\",\n\t\t\t\"dispose_cmd.c\",\n\t\t\t\"error.c\",\n\t\t\t\"eval.c\",\n\t\t\t\"expr.c\",\n\t\t\t\"findcmd.c\",\n\t\t\t\"flags.c\",\n\t\t\t\"general.c\",\n\t\t\t\"hashcmd.c\",\n\t\t\t\"hashlib.c\",\n\t\t\t\"input.c\",\n\t\t\t\"jobs.c\",\n\t\t\t\"list.c\",\n\t\t\t\"locale.c\",\n\t\t\t\"mailcheck.c\",\n\t\t\t\"make_cmd.c\",\n\t\t\t\"mksyntax.c\",\n\t\t\t\"pathexp.c\",\n\t\t\t\"pcomplete.c\",\n\t\t\t\"pcomplib.c\",\n\t\t\t\"print_cmd.c\",\n\t\t\t\"redir.c\",\n\t\t\t\"shell.c\",\n\t\t\t\"sig.c\",\n\t\t\t\"stringlib.c\",\n\t\t\t\"subst.c\",\n\t\t\t\"support/bashversion.c\",\n\t\t\t\"support/mksignames.c\",\n\t\t\t\"support/signames.c\",\n\t\t\t\"syntax.c\",\n\t\t\t\"test.c\",\n\t\t\t\"trap.c\",\n\t\t\t\"unwind_prot.c\",\n\t\t\t\"variables.c\",\n\t\t\t\"version.c\",\n\t\t\t\"version.c\",\n\t\t\t\"xmalloc.c\",\n\t\t\t\"y.tab.c\",\n\t\t\t//\"execute_cmd.c\", // Composite type K&R fn def style vs prototype decl lefts an undefined param.\n\t\t},\n\t\t\"testdata/dev/bash-4.3/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\tppOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"..\",\n\t\t\t\"../include\",\n\t\t\t\"../lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"..\",\n\t\t\t\"../include\",\n\t\t\t\"../lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp = predefined + `\n#define HAVE_CONFIG_H\n#define SHELL\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __restrict __restrict__\n#define __inline inline\n`,\n\t\t[]string{\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I..\",\n\t\t\t\"-I../include\",\n\t\t\t\"-I../lib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"builtins.c\",\n\t\t\t\"common.c\",\n\t\t\t\"evalfile.c\",\n\t\t\t\"evalstring.c\",\n\t\t\t\"mkbuiltins.c\",\n\t\t\t\"psize.c\",\n\t\t},\n\t\t\"testdata/dev/bash-4.3/builtins\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\tppOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../..\",\n\t\t\t\"../../include\",\n\t\t\t\"../../lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../..\",\n\t\t\t\"../../include\",\n\t\t\t\"../../lib\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp = predefined + `\n#define HAVE_CONFIG_H\n#define SHELL\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../..\",\n\t\t\t\"-I../../include\",\n\t\t\t\"-I../../lib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"glob.c\",\n\t\t\t\"gmisc.c\",\n\t\t\t\"smatch.c\",\n\t\t\t\"strmatch.c\",\n\t\t\t\"xmbsrtowcs.c\",\n\t\t},\n\t\t\"testdata/dev/bash-4.3/lib/glob\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../..\",\n\t\t\t\"-I../../include\",\n\t\t\t\"-I../../lib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"casemod.c\",\n\t\t\t\"clktck.c\",\n\t\t\t\"clock.c\",\n\t\t\t\"eaccess.c\",\n\t\t\t\"fmtullong.c\",\n\t\t\t\"fmtulong.c\",\n\t\t\t\"fmtumax.c\",\n\t\t\t\"fnxform.c\",\n\t\t\t\"fpurge.c\",\n\t\t\t\"getenv.c\",\n\t\t\t\"input_avail.c\",\n\t\t\t\"itos.c\",\n\t\t\t\"mailstat.c\",\n\t\t\t\"makepath.c\",\n\t\t\t\"mbscasecmp.c\",\n\t\t\t\"mbschr.c\",\n\t\t\t\"mbscmp.c\",\n\t\t\t\"netconn.c\",\n\t\t\t\"netopen.c\",\n\t\t\t\"oslib.c\",\n\t\t\t\"pathcanon.c\",\n\t\t\t\"pathphys.c\",\n\t\t\t\"setlinebuf.c\",\n\t\t\t\"shmatch.c\",\n\t\t\t\"shmbchar.c\",\n\t\t\t\"shquote.c\",\n\t\t\t\"shtty.c\",\n\t\t\t\"snprintf.c\",\n\t\t\t\"spell.c\",\n\t\t\t\"stringlist.c\",\n\t\t\t\"stringvec.c\",\n\t\t\t\"strnlen.c\",\n\t\t\t\"strtrans.c\",\n\t\t\t\"timeval.c\",\n\t\t\t\"tmpfile.c\",\n\t\t\t\"uconvert.c\",\n\t\t\t\"ufuncs.c\",\n\t\t\t\"unicode.c\",\n\t\t\t\"wcsdup.c\",\n\t\t\t\"wcsnwidth.c\",\n\t\t\t\"winsize.c\",\n\t\t\t\"zcatfd.c\",\n\t\t\t\"zgetline.c\",\n\t\t\t\"zmapfd.c\",\n\t\t\t\"zread.c\",\n\t\t\t\"zwrite.c\",\n\t\t},\n\t\t\"testdata/dev/bash-4.3/lib/sh\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../..\",\n\t\t\t\"-I../../include\",\n\t\t\t\"-I../../lib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"bind.c\",\n\t\t\t\"callback.c\",\n\t\t\t\"colors.c\",\n\t\t\t\"compat.c\",\n\t\t\t\"complete.c\",\n\t\t\t\"display.c\",\n\t\t\t\"funmap.c\",\n\t\t\t\"histexpand.c\",\n\t\t\t\"histfile.c\",\n\t\t\t\"history.c\",\n\t\t\t\"histsearch.c\",\n\t\t\t\"input.c\",\n\t\t\t\"isearch.c\",\n\t\t\t\"keymaps.c\",\n\t\t\t\"kill.c\",\n\t\t\t\"macro.c\",\n\t\t\t\"mbutil.c\",\n\t\t\t\"misc.c\",\n\t\t\t\"nls.c\",\n\t\t\t\"parens.c\",\n\t\t\t\"parse-colors.c\",\n\t\t\t\"readline.c\",\n\t\t\t\"rltty.c\",\n\t\t\t\"savestring.c\",\n\t\t\t\"search.c\",\n\t\t\t\"shell.c\",\n\t\t\t\"signals.c\",\n\t\t\t\"terminal.c\",\n\t\t\t\"text.c\",\n\t\t\t\"tilde.c\",\n\t\t\t\"undo.c\",\n\t\t\t\"util.c\",\n\t\t\t\"vi_mode.c\",\n\t\t\t\"xfree.c\",\n\t\t\t\"xmalloc.c\",\n\t\t},\n\t\t\"testdata/dev/bash-4.3/lib/readline\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\tp = predefined + `\n#define HAVE_CONFIG_H\n#define SHELL\n#define RCHECK\n#define botch programming_error\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DSHELL\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-DRCHECK\",\n\t\t\t\"-Dbotch=programming_error\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../..\",\n\t\t\t\"-I../../include\",\n\t\t\t\"-I../../lib\",\n\t\t},\n\t\t[]string{\n\t\t\t\"malloc.c\",\n\t\t\t\"trace.c\",\n\t\t\t\"stats.c\",\n\t\t\t\"table.c\",\n\t\t\t\"watch.c\",\n\t\t},\n\t\t\"testdata/dev/bash-4.3/lib/malloc\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevMake(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined + `\n#define LOCALEDIR \"/usr/local/share/locale\"\n#define LIBDIR \"/usr/local/lib\"\n#define INCLUDEDIR \"/usr/local/include\"\n#define HAVE_CONFIG_H\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n#define __typeof typeof\n`,\n\t\t[]string{\n\t\t\t\"-DLOCALEDIR=\\\"/usr/local/share/locale\\\"\",\n\t\t\t\"-DLIBDIR=\\\"/usr/local/lib\\\"\",\n\t\t\t\"-DINCLUDEDIR=\\\"/usr/local/include\\\"\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t},\n\t\t[]string{\n\t\t\t\"ar.c\",\n\t\t\t\"arscan.c\",\n\t\t\t\"commands.c\",\n\t\t\t\"default.c\",\n\t\t\t\"dir.c\",\n\t\t\t\"expand.c\",\n\t\t\t\"file.c\",\n\t\t\t\"function.c\",\n\t\t\t\"getopt.c\",\n\t\t\t\"getopt1.c\",\n\t\t\t\"guile.c\",\n\t\t\t\"hash.c\",\n\t\t\t\"implicit.c\",\n\t\t\t\"job.c\",\n\t\t\t\"load.c\",\n\t\t\t\"loadapi.c\",\n\t\t\t\"main.c\",\n\t\t\t\"misc.c\",\n\t\t\t\"output.c\",\n\t\t\t\"read.c\",\n\t\t\t\"remake.c\",\n\t\t\t\"remote-stub.c\",\n\t\t\t\"rule.c\",\n\t\t\t\"signame.c\",\n\t\t\t\"strcache.c\",\n\t\t\t\"variable.c\",\n\t\t\t\"version.c\",\n\t\t\t\"vpath.c\",\n\t\t},\n\t\t\"testdata/dev/make-4.1/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevBc(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"..\",\n\t\t\t\"./../h\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"..\",\n\t\t\t\"./../h\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined + `\n#define HAVE_CONFIG_H\n`\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I..\",\n\t\t\t\"-I./../h\",\n\t\t},\n\t\t[]string{\n\t\t\t\"getopt.c\",\n\t\t\t\"getopt1.c\",\n\t\t\t\"number.c\",\n\t\t\t\"vfprintf.c\",\n\t\t},\n\t\t\"testdata/dev/bc-1.06/lib/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I..\",\n\t\t\t\"-I./../h\",\n\t\t},\n\t\t[]string{\n\t\t\t\"main.c\",\n\t\t\t\"bc.c\",\n\t\t\t\"scan.c\",\n\t\t\t\"execute.c\",\n\t\t\t\"load.c\",\n\t\t\t\"storage.c\",\n\t\t\t\"util.c\",\n\t\t\t\"global.c\",\n\t\t},\n\t\t\"testdata/dev/bc-1.06/bc\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I..\",\n\t\t\t\"-I./../h\",\n\t\t},\n\t\t[]string{\n\t\t\t\"dc.c\",\n\t\t\t\"misc.c\",\n\t\t\t\"eval.c\",\n\t\t\t\"stack.c\",\n\t\t\t\"array.c\",\n\t\t\t\"numeric.c\",\n\t\t\t\"string.c\",\n\t\t},\n\t\t\"testdata/dev/bc-1.06/dc\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevEmacs(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../lib\",\n\t\t\t\"../src\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../lib\",\n\t\t\t\"../src\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined + `\n#define HAVE_CONFIG_H\n#define _GCC_MAX_ALIGN_T\n`\n\ttestDev(\n\t\tt,\n\t\tp+`\n#define _Noreturn __attribute__ ((__noreturn__))\n`,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __getopt_argv_const const\n#define __inline inline\n#define __restrict __restrict__\n`,\n\t\t[]string{\n\t\t\t\"-std=gnu99\",\n\t\t\t\"-DHAVE_CONFIG_H\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../lib\",\n\t\t\t\"-I../src\",\n\t\t},\n\t\t[]string{\n\t\t\t\"acl-errno-valid.c\",\n\t\t\t\"allocator.c\",\n\t\t\t\"binary-io.c\",\n\t\t\t\"c-ctype.c\",\n\t\t\t\"c-strcasecmp.c\",\n\t\t\t\"c-strncasecmp.c\",\n\t\t\t\"careadlinkat.c\",\n\t\t\t\"close-stream.c\",\n\t\t\t\"count-one-bits.c\",\n\t\t\t\"count-trailing-zeros.c\",\n\t\t\t\"dtoastr.c\",\n\t\t\t\"dtotimespec.c\",\n\t\t\t\"fcntl.c\",\n\t\t\t\"file-has-acl.c\",\n\t\t\t\"filemode.c\",\n\t\t\t\"getopt.c\",\n\t\t\t\"getopt1.c\",\n\t\t\t\"gettime.c\",\n\t\t\t\"md5.c\",\n\t\t\t\"openat-die.c\",\n\t\t\t\"pipe2.c\",\n\t\t\t\"pthread_sigmask.c\",\n\t\t\t\"qcopy-acl.c\",\n\t\t\t\"qset-acl.c\",\n\t\t\t\"save-cwd.c\",\n\t\t\t\"sha1.c\",\n\t\t\t\"sha256.c\",\n\t\t\t\"sha512.c\",\n\t\t\t\"sig2str.c\",\n\t\t\t\"stat-time.c\",\n\t\t\t\"strftime.c\",\n\t\t\t\"timespec-add.c\",\n\t\t\t\"timespec-sub.c\",\n\t\t\t\"timespec.c\",\n\t\t\t\"u64.c\",\n\t\t\t\"unistd.c\",\n\t\t\t\"utimens.c\",\n\t\t},\n\t\t\"testdata/dev/emacs-24.5/lib\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\tp = predefined + `\n #define CTAGS\n #define EMACS_NAME \"GNU Emacs\"\n #define HAVE_CONFIG_H\n #define HAVE_SHARED_GAME_DIR \"/usr/local/var/games/emacs\"\n #define VERSION \"24.5\"\n `\n\ttestDev(\n\t\tt,\n\t\tp+`\n#define _GCC_MAX_ALIGN_T\n#define _Noreturn __attribute__ ((__noreturn__))\n`,\n\t\tp,\n\t\tp+`\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n#define __typeof typeof\n`,\n\t\t[]string{\n\t\t\t\"-std=gnu99\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../lib\",\n\t\t\t\"-I../src\",\n\t\t\t\"-DEMACS_NAME=\\\"GNU Emacs\\\"\",\n\t\t\t\"-DCTAGS\",\n\t\t\t\"-DHAVE_SHARED_GAME_DIR=\\\"/usr/local/var/games/emacs\\\"\",\n\t\t\t\"-DVERSION=\\\"24.5\\\"\",\n\t\t},\n\t\t[]string{\n\t\t\t\"./../src/regex.c\",\n\t\t\t\"./ebrowse.c\",\n\t\t\t\"./emacsclient.c\",\n\t\t\t\"./etags.c\",\n\t\t\t\"./hexl.c\",\n\t\t\t\"./make-docfile.c\",\n\t\t\t\"./movemail.c\",\n\t\t\t\"./pop.c\",\n\t\t\t\"./profile.c\",\n\t\t\t\"./test-distrib.c\",\n\t\t\t\"./update-game-score.c\",\n\t\t},\n\t\t\"testdata/dev/emacs-24.5/lib-src/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n\n\tppOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../lib\",\n\t\t\t\"/usr/include/gtk-3.0\",\n\t\t\t\"/usr/include/pango-1.0\",\n\t\t\t\"/usr/include/gio-unix-2.0/\",\n\t\t\t\"/usr/include/atk-1.0\",\n\t\t\t\"/usr/include/cairo\",\n\t\t\t\"/usr/include/gdk-pixbuf-2.0\",\n\t\t\t\"/usr/include/freetype2\",\n\t\t\t\"/usr/include/glib-2.0\",\n\t\t\t\"/usr/lib/x86_64-linux-gnu/glib-2.0/include\",\n\t\t\t\"/usr/include/pixman-1\",\n\t\t\t\"/usr/include/libpng12\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tEnableDefineOmitCommaBeforeDDD(),\n\t\tEnableIncludeNext(),\n\t\tdevTest(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts = []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t\t\"../lib\",\n\t\t\t\"/usr/include/gtk-3.0\",\n\t\t\t\"/usr/include/pango-1.0\",\n\t\t\t\"/usr/include/gio-unix-2.0/\",\n\t\t\t\"/usr/include/atk-1.0\",\n\t\t\t\"/usr/include/cairo\",\n\t\t\t\"/usr/include/gdk-pixbuf-2.0\",\n\t\t\t\"/usr/include/freetype2\",\n\t\t\t\"/usr/include/glib-2.0\",\n\t\t\t\"/usr/lib/x86_64-linux-gnu/glib-2.0/include\",\n\t\t\t\"/usr/include/pixman-1\",\n\t\t\t\"/usr/include/libpng12\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp = predefined + `\n#define _GCC_MAX_ALIGN_T\n#define emacs\n`\n\n\ttestDev(\n\t\tt,\n\t\tp+`\n#define _Noreturn __attribute__ ((__noreturn__))\n`,\n\t\tp,\n\t\tp+`\n#define _Alignas(x)\n#define __const const\n#define __inline inline\n#define __restrict __restrict__\n#define __typeof typeof\n`,\n\t\t[]string{\n\t\t\t\"-std=gnu99\",\n\t\t\t\"-Demacs\",\n\t\t\t\"-I.\",\n\t\t\t\"-I../lib\",\n\t\t\t\"-I/usr/include/gtk-3.0\",\n\t\t\t\"-I/usr/include/pango-1.0\",\n\t\t\t\"-I/usr/include/gio-unix-2.0/\",\n\t\t\t\"-I/usr/include/atk-1.0\",\n\t\t\t\"-I/usr/include/cairo\",\n\t\t\t\"-I/usr/include/gdk-pixbuf-2.0\",\n\t\t\t\"-I/usr/include/freetype2\",\n\t\t\t\"-I/usr/include/glib-2.0\",\n\t\t\t\"-I/usr/lib/x86_64-linux-gnu/glib-2.0/include\",\n\t\t\t\"-I/usr/include/pixman-1\",\n\t\t\t\"-I/usr/include/libpng12\",\n\t\t},\n\t\t[]string{\n\t\t\t\"alloc.c\",\n\t\t\t\"atimer.c\",\n\t\t\t\"bidi.c\",\n\t\t\t\"buffer.c\",\n\t\t\t\"callint.c\",\n\t\t\t\"callproc.c\",\n\t\t\t\"casefiddle.c\",\n\t\t\t\"casetab.c\",\n\t\t\t\"category.c\",\n\t\t\t\"ccl.c\",\n\t\t\t\"character.c\",\n\t\t\t\"charset.c\",\n\t\t\t\"chartab.c\",\n\t\t\t\"cm.c\",\n\t\t\t\"cmds.c\",\n\t\t\t\"coding.c\",\n\t\t\t\"composite.c\",\n\t\t\t\"data.c\",\n\t\t\t\"decompress.c\",\n\t\t\t\"dired.c\",\n\t\t\t\"dispnew.c\",\n\t\t\t\"doc.c\",\n\t\t\t\"doprnt.c\",\n\t\t\t\"editfns.c\",\n\t\t\t\"emacs.c\",\n\t\t\t\"eval.c\",\n\t\t\t\"fileio.c\",\n\t\t\t\"filelock.c\",\n\t\t\t\"floatfns.c\",\n\t\t\t\"fns.c\",\n\t\t\t\"font.c\",\n\t\t\t\"fontset.c\",\n\t\t\t\"frame.c\",\n\t\t\t\"fringe.c\",\n\t\t\t\"ftfont.c\",\n\t\t\t\"gfilenotify.c\",\n\t\t\t\"gnutls.c\",\n\t\t\t\"gtkutil.c\",\n\t\t\t\"indent.c\",\n\t\t\t\"insdel.c\",\n\t\t\t\"intervals.c\",\n\t\t\t\"keyboard.c\",\n\t\t\t\"keymap.c\",\n\t\t\t\"lastfile.c\",\n\t\t\t\"lread.c\",\n\t\t\t\"macros.c\",\n\t\t\t\"marker.c\",\n\t\t\t\"menu.c\",\n\t\t\t\"minibuf.c\",\n\t\t\t\"print.c\",\n\t\t\t\"process.c\",\n\t\t\t\"profiler.c\",\n\t\t\t\"region-cache.c\",\n\t\t\t\"scroll.c\",\n\t\t\t\"search.c\",\n\t\t\t\"sound.c\",\n\t\t\t\"syntax.c\",\n\t\t\t\"sysdep.c\",\n\t\t\t\"term.c\",\n\t\t\t\"terminal.c\",\n\t\t\t\"terminfo.c\",\n\t\t\t\"textprop.c\",\n\t\t\t\"undo.c\",\n\t\t\t\"vm-limit.c\",\n\t\t\t\"window.c\",\n\t\t\t\"xdisp.c\",\n\t\t\t\"xfaces.c\",\n\t\t\t\"xfns.c\",\n\t\t\t\"xfont.c\",\n\t\t\t\"xgselect.c\",\n\t\t\t\"xmenu.c\",\n\t\t\t\"xml.c\",\n\t\t\t\"xrdb.c\",\n\t\t\t\"xselect.c\",\n\t\t\t\"xsmfns.c\",\n\t\t\t\"xterm.c\",\n\t\t\t/// \"bytecode.c\",      // [lo ... hi] = expr\n\t\t\t/// \"emacsgtkfixed.c\", // /usr/include/gtk-3.0/gtk/gtkversion.h:98:9: cannot redefine macro: argument names differ\n\t\t\t/// \"ftxfont.c\",       // ftxfont.c:145:7: undefined: ftfont_driver\n\t\t\t/// \"unexelf.c\",       // /usr/include/x86_64-linux-gnu/bits/link.h:97:3: unexpected identifier __int128_t, expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\n\t\t\t/// \"xftfont.c\",       // lisp.h:2041:13: unexpected typedefname, expected optional type qualifier list or pointer or one of ['(', ')', '*', ',', '[', const, identifier, restrict, volatile]\n\t\t\t/// \"xsettings.c\",     // xsettings.c:431:36: unexpected '{', expected expression list or type name or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\n\t\t\t///\"image.c\",         // /usr/include/gif_lib.h:269:44: unexpected typedefname, expected optional type qualifier list or pointer or one of ['(', ')', '*', ',', '[', const, identifier, restrict, volatile]\n\t\t},\n\t\t\"testdata/dev/emacs-24.5/src/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\nfunc TestDevM4(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tEnableIncludeNext(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths([]string{\n\t\t\t\".\",\n\t\t}),\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\tp := predefined\n\n\ttestDev(\n\t\tt,\n\t\tp,\n\t\tp,\n\t\tp+`\n#define __const\n#define __inline inline\n#define __restrict __restrict__\n#define __typeof typeof\n`,\n\t\t[]string{\n\t\t\t\"-I.\",\n\t\t},\n\t\t[]string{\n\t\t\t\"asnprintf.c\",\n\t\t\t\"asprintf.c\",\n\t\t\t\"basename-lgpl.c\",\n\t\t\t\"basename.c\",\n\t\t\t\"binary-io.c\",\n\t\t\t\"c-ctype.c\",\n\t\t\t\"c-strcasecmp.c\",\n\t\t\t\"c-strncasecmp.c\",\n\t\t\t\"clean-temp.c\",\n\t\t\t\"cloexec.c\",\n\t\t\t\"close-stream.c\",\n\t\t\t\"closein.c\",\n\t\t\t\"closeout.c\",\n\t\t\t\"dirname-lgpl.c\",\n\t\t\t\"dirname.c\",\n\t\t\t\"dup-safer-flag.c\",\n\t\t\t\"dup-safer.c\",\n\t\t\t\"exitfail.c\",\n\t\t\t\"fatal-signal.c\",\n\t\t\t\"fclose.c\",\n\t\t\t\"fcntl.c\",\n\t\t\t\"fd-hook.c\",\n\t\t\t\"fd-safer-flag.c\",\n\t\t\t\"fd-safer.c\",\n\t\t\t\"fflush.c\",\n\t\t\t\"filenamecat-lgpl.c\",\n\t\t\t\"filenamecat.c\",\n\t\t\t\"fopen-safer.c\",\n\t\t\t\"fpurge.c\",\n\t\t\t\"freadahead.c\",\n\t\t\t\"freading.c\",\n\t\t\t\"fseek.c\",\n\t\t\t\"fseeko.c\",\n\t\t\t\"gl_avltree_oset.c\",\n\t\t\t\"gl_linkedhash_list.c\",\n\t\t\t\"gl_list.c\",\n\t\t\t\"gl_oset.c\",\n\t\t\t\"gl_xlist.c\",\n\t\t\t\"gl_xoset.c\",\n\t\t\t\"glthread/lock.c\",\n\t\t\t\"glthread/threadlib.c\",\n\t\t\t\"glthread/tls.c\",\n\t\t\t\"localcharset.c\",\n\t\t\t\"malloca.c\",\n\t\t\t\"math.c\",\n\t\t\t\"memchr2.c\",\n\t\t\t\"mkstemp-safer.c\",\n\t\t\t\"pipe-safer.c\",\n\t\t\t\"pipe2-safer.c\",\n\t\t\t\"pipe2.c\",\n\t\t\t\"printf-args.c\",\n\t\t\t\"printf-frexp.c\",\n\t\t\t\"printf-parse.c\",\n\t\t\t\"progname.c\",\n\t\t\t\"quotearg.c\",\n\t\t\t\"sig-handler.c\",\n\t\t\t\"stripslash.c\",\n\t\t\t\"tempname.c\",\n\t\t\t\"tmpdir.c\",\n\t\t\t\"unistd.c\",\n\t\t\t\"vasprintf.c\",\n\t\t\t\"verror.c\",\n\t\t\t\"version-etc-fsf.c\",\n\t\t\t\"version-etc.c\",\n\t\t\t\"wait-process.c\",\n\t\t\t\"wctype-h.c\",\n\t\t\t\"xalloc-die.c\",\n\t\t\t\"xasprintf.c\",\n\t\t\t\"xmalloc.c\",\n\t\t\t\"xmalloca.c\",\n\t\t\t\"xprintf.c\",\n\t\t\t\"xsize.c\",\n\t\t\t\"xstrndup.c\",\n\t\t\t\"xvasprintf.c\",\n\t\t\t/// \"c-stack.c\", c-stack.c:119:3: unexpected '{', expected expression list or type name or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\n\t\t\t/// \"execute.c\", spawn.h:457:9: cannot redefine macro using a replacement list of different length\n\t\t\t/// \"isnanl.c\", float+.h:145:32: array size must be positive: -1\n\t\t\t/// \"printf-frexpl.c\", printf-frexp.c:72:3: unexpected '{', expected expression list or type name or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\n\t\t\t/// \"spawn-pipe.c\", spawn.h:457:9: cannot redefine macro using a replacement list of different length\n\t\t\t/// \"vasnprintf.c\", vasnprintf.c:3624:25: unexpected '{', expected expression list or type name or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\n\t\t},\n\t\t\"testdata/dev/m4-1.4.17/lib/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevStbVorbis(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tEnableIncludeNext(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\ttestDev(\n\t\tt,\n\t\tpredefined,\n\t\tpredefined,\n\t\tpredefined+`\n#define __inline inline\n#define __const const\n#define __restrict restrict\n`,\n\t\tnil,\n\t\t[]string{\n\t\t\t\"stb_vorbis.c\",\n\t\t},\n\t\t\"testdata/dev/stb\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestDevGMP(t *testing.T) {\n\tpredefined, includePaths, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Logf(\"skipping: %v\", err)\n\t\treturn\n\t}\n\n\tppOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tEnableIncludeNext(),\n\t}\n\tif *oFailFast {\n\t\tppOpts = append(ppOpts, CrashOnError())\n\t}\n\tparseOpts := []Opt{\n\t\tIncludePaths(includePaths),\n\t\tSysIncludePaths(sysIncludePaths),\n\t\tdevTest(),\n\t\tgccEmu(),\n\t}\n\tif *oFailFast {\n\t\tparseOpts = append(parseOpts, CrashOnError())\n\t}\n\n\ttestDev(\n\t\tt,\n\t\tpredefined,\n\t\tpredefined,\n\t\tpredefined,\n\t\tnil,\n\t\t[]string{\n\t\t\t\"gmp.h\",\n\t\t},\n\t\t\"testdata/dev/gmp-6.1.0/\",\n\t\tppOpts,\n\t\tparseOpts,\n\t)\n}\n\nfunc TestPPParse1(t *testing.T) {\n\tpath := *o1\n\tif path == \"\" {\n\t\treturn\n\t}\n\n\ttestReport := newTestReport()\n\ttestReport.ClearErrors()\n\t_, err := ppParse(path, testReport, testTweaks)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif err := testReport.Errors(true); err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n}\n\nfunc TestFinalInjection(t *testing.T) {\n\tconst src = \"int f() {}\"\n\n\tif strings.HasSuffix(src, \"\\n\") {\n\t\tt.Fatal(\"internal error\")\n\t}\n\n\tast, err := ppParseString(\"test.c\", src, xc.NewReport(), &tweaks{})\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tt.Log(PrettyString(ast))\n}\n\nfunc TestRedecl(t *testing.T) {\n\ttestParse(t, []string{\"testdata/redecl.c\"}, \"\")\n}\n\nfunc TestParse1(t *testing.T) {\n\tpath := *o1\n\tif path == \"\" {\n\t\treturn\n\t}\n\n\ttestParse(t, []string{path}, \"\")\n}\n\nfunc testParse(t *testing.T, paths []string, ignoreError string, opts ...Opt) *TranslationUnit {\n\tlast := paths[len(paths)-1]\n\tln := filepath.Base(last)\n\tf, err := os.Create(\"log-\" + ln)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdefer f.Close()\n\n\tb := bufio.NewWriter(f)\n\tdefer b.Flush()\n\n\tb.WriteString(\"// +build ignore\\n\\n\")\n\tvar a []string\n\tcrash := nopOpt()\n\tif *oFailFast {\n\t\tcrash = CrashOnError()\n\t}\n\topts = append(\n\t\topts,\n\t\tIncludePaths(includes),\n\t\tSysIncludePaths(sysIncludes),\n\t\tCpp(func(toks []xc.Token) {\n\t\t\ta = a[:0]\n\t\t\tfor _, v := range toks {\n\t\t\t\ta = append(a, TokSrc(v))\n\t\t\t}\n\t\t\tfmt.Fprintf(b, \"%s\\n\", strings.Join(a, \" \"))\n\t\t}),\n\t\tcrash,\n\t\tErrLimit(-1),\n\t)\n\tast, err := Parse(\n\t\tpredefinedMacros,\n\t\tpaths,\n\t\tnewTestModel(),\n\t\topts...,\n\t)\n\tif err != nil {\n\t\tif s := strings.TrimSpace(errString(err)); s != ignoreError {\n\t\t\tt.Fatal(errString(err))\n\t\t}\n\t}\n\n\tt.Log(paths)\n\treturn ast\n}\n\nfunc ddsStr(dds []*DirectDeclarator) string {\n\tbuf := bytes.NewBufferString(\"|\")\n\tfor i, dd := range dds {\n\t\tif i == 0 {\n\t\t\tfmt.Fprintf(buf, \"(@%p)\", &dds[0])\n\t\t}\n\t\tswitch dd.Case {\n\t\tcase 0: // IDENTIFIER\n\t\t\tfmt.Fprintf(buf, \"IDENTIFIER(%s: %s)\", dd.Token.Position(), dd.Token.S())\n\t\tcase 1: // '(' Declarator ')'\n\t\t\tbuf.WriteString(\"(\")\n\t\t\tbuf.WriteString(strings.Repeat(\"*\", dd.Declarator.stars()))\n\t\t\tfmt.Fprintf(buf, \"Declarator.%v)\", dds[i-1].Case)\n\t\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tfmt.Fprintf(buf, \"DirectDeclarator[TypeQualifierListOpt ExpressionOpt.%v]\", dd.elements)\n\t\tcase 3: // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t\tfmt.Fprintf(buf, \"DirectDeclarator[static TypeQualifierListOpt Expression.%v]\", dd.elements)\n\t\tcase 4: // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t\tfmt.Fprintf(buf, \"DirectDeclarator[TypeQualifierList static Expression.%v]\", dd.elements)\n\t\tcase 5: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t\tfmt.Fprintf(buf, \"DirectDeclarator[TypeQualifierListOpt*.%v]\", dd.elements)\n\t\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\tbuf.WriteString(\"DirectDeclarator(ParameterTypeList)\")\n\t\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\tbuf.WriteString(\"DirectDeclarator(IdentifierListOpt)\")\n\t\t}\n\t\tbuf.WriteString(\"|\")\n\t}\n\treturn buf.String()\n}\n\nfunc (n *ctype) str() string {\n\treturn fmt.Sprintf(\"R%v S%v %v\", n.resultStars, n.stars, ddsStr(n.dds))\n}\n\nfunc (n *ctype) str0() string {\n\treturn fmt.Sprintf(\"R%v S%v %v\", n.resultStars, n.stars, ddsStr(n.dds0))\n}\n\nfunc TestIssue3(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue3.h\"}, newTestModel()); err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n}\n\nfunc TestIssue8(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue8.h\"}, newTestModel()); err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n}\n\nfunc TestIssue4(t *testing.T) {\n\t_, err := Parse(\"\", []string{\"testdata/issue4.c\"}, newTestModel())\n\tif err == nil {\n\t\tt.Fatal(\"unexpected sucess\")\n\t}\n\n\tl, ok := err.(scanner.ErrorList)\n\tif !ok {\n\t\tt.Fatalf(\"unexpected error type %T\", err)\n\t}\n\n\tif g, e := l.Len(), 2; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := l[0].Error(), \"testdata/issue4.c:5:13: redeclaration of foo as different kind of symbol, previous declaration at testdata/issue4.c:4:5\"; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := l[1].Error(), \"testdata/issue4.c:9:15: redeclaration of foo2 as different kind of symbol, previous declaration at testdata/issue4.c:8:7\"; g != e {\n\t\tt.Fatal(g, e)\n\t}\n}\n\nfunc unpackType(typ Type) Type {\n\tfor {\n\t\tswitch typ.Kind() {\n\t\tcase Ptr, Array:\n\t\t\ttyp = typ.Element()\n\t\tdefault:\n\t\t\treturn typ\n\t\t}\n\t}\n}\n\nfunc TestIssue9(t *testing.T) {\n\tconst exp = `original:  typedef short[64] Array\nunpacked:  typedef short Short\noriginal: JBLOCK short(*)[64] Ptr\nunpacked: JBLOCK short Short\noriginal: JBLOCKROW short(**)[64] Ptr\nunpacked: JBLOCKROW short Short\noriginal: JBLOCKARRAY short(***)[64] Ptr\nunpacked: JBLOCKARRAY short Short\noriginal:  short[64] Array\nunpacked:  short Short\noriginal:  short[64] Array\nunpacked:  short Short\noriginal: JBLOCK short[64] Array\nunpacked: JBLOCK short Short\noriginal: JBLOCK short[64] Array\nunpacked: JBLOCK short Short\noriginal:  short(*)[64] Ptr\nunpacked:  short Short\noriginal:  short(*)[64] Ptr\nunpacked:  short Short\noriginal:  short(*)[64] Ptr\nunpacked:  short Short\noriginal: JBLOCKROW short(*)[64] Ptr\nunpacked: JBLOCKROW short Short\noriginal: JBLOCKROW short(*)[64] Ptr\nunpacked: JBLOCKROW short Short\noriginal:  short(**)[64] Ptr\nunpacked:  short Short\noriginal:  short(**)[64] Ptr\nunpacked:  short Short\noriginal:  short(**)[64] Ptr\nunpacked:  short Short\noriginal: JBLOCKARRAY short(**)[64] Ptr\nunpacked: JBLOCKARRAY short Short\noriginal: JBLOCKARRAY short(**)[64] Ptr\nunpacked: JBLOCKARRAY short Short\noriginal:  short(***)[64] Ptr\nunpacked:  short Short\noriginal:  short(***)[64] Ptr\nunpacked:  short Short\noriginal:  short(***)[64] Ptr\nunpacked:  short Short\noriginal: JBLOCKIMAGE short(***)[64] Ptr\nunpacked: JBLOCKIMAGE short Short\noriginal: JBLOCKIMAGE short(***)[64] Ptr\nunpacked: JBLOCKIMAGE short Short\n`\n\n\ttu, err := Parse(\"\", []string{\"testdata/issue9.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tvar buf bytes.Buffer\n\tfor tu != nil {\n\t\tdeclr := tu.ExternalDeclaration.Declaration.InitDeclaratorListOpt.InitDeclaratorList.InitDeclarator.Declarator\n\t\tname := string(xc.Dict.S(declr.RawSpecifier().TypedefName()))\n\t\tfmt.Fprintln(&buf, \"original:\", name, declr.Type, declr.Type.Kind())\n\t\tunpacked := unpackType(declr.Type)\n\t\tfmt.Fprintln(&buf, \"unpacked:\", name, unpacked, unpacked.Kind())\n\t\ttu = tu.TranslationUnit\n\t}\n\tif g, e := buf.String(), exp; g != e {\n\t\tt.Fatalf(\"got:\\n%s\\nexp:\\n%s\", g, e)\n\t}\n}\n\nfunc TestEnumConstToks(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/enum.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tsc := tu.Declarations\n\tfoo := sc.Lookup(NSIdentifiers, xc.Dict.SID(\"foo\"))\n\tif foo.Node == nil {\n\t\tt.Fatal(\"internal error\")\n\t}\n\n\tswitch x := foo.Node.(type) {\n\tcase *DirectDeclarator:\n\t\ttyp := x.TopDeclarator().Type\n\t\tif g, e := typ.Kind(), Enum; g != e {\n\t\t\tt.Fatal(g, e)\n\t\t}\n\n\t\tl := typ.EnumeratorList()\n\t\tif g, e := PrettyString(\n\t\t\tl),\n\t\t\t`[]cc.EnumConstant{ // len 2\n· 0: cc.EnumConstant{\n· · DefTok: testdata/enum.c:4:2: IDENTIFIER \"c\",\n· · Value: 18,\n· · Tokens: []xc.Token{ // len 3\n· · · 0: testdata/enum.c:4:6: INTCONST \"42\",\n· · · 1: testdata/enum.c:4:9: '-',\n· · · 2: testdata/enum.c:4:11: INTCONST \"24\",\n· · },\n· },\n· 1: cc.EnumConstant{\n· · DefTok: testdata/enum.c:5:2: IDENTIFIER \"d\",\n· · Value: 592,\n· · Tokens: []xc.Token{ // len 3\n· · · 0: testdata/enum.c:5:6: INTCONST \"314\",\n· · · 1: testdata/enum.c:5:10: '+',\n· · · 2: testdata/enum.c:5:12: INTCONST \"278\",\n· · },\n· },\n}`; g != e {\n\t\t\tt.Fatalf(\"got\\n%s\\nexp\\n%s\", g, e)\n\t\t}\n\t\tvar a []string\n\t\tfor _, e := range l {\n\t\t\tvar b []string\n\t\t\tfor _, t := range e.Tokens {\n\t\t\t\tb = append(b, TokSrc(t))\n\t\t\t}\n\t\t\ta = append(a, strings.Join(b, \" \"))\n\t\t}\n\t\tif g, e := strings.Join(a, \"\\n\"), \"42 - 24\\n314 + 278\"; g != e {\n\t\t\tt.Fatalf(\"got\\n%s\\nexp\\n%s\", g, e)\n\t\t}\n\tdefault:\n\t\tt.Fatalf(\"%T\", x)\n\t}\n}\n\nfunc TestPaste(t *testing.T) {\n\ttestParse(t, []string{\"testdata/paste.c\"}, \"\")\n}\n\nfunc TestPaste2(t *testing.T) {\n\ttestParse(t, []string{\"testdata/paste2.c\"}, \"\")\n}\n\nfunc TestFunc(t *testing.T) {\n\ttestParse(t, []string{\"testdata/func.c\"}, \"\")\n}\n\nfunc TestEmptyMacroArg(t *testing.T) {\n\ttestParse(t, []string{\"testdata/empty.c\"}, \"\")\n}\n\nfunc TestFuncFuncParams(t *testing.T) {\n\ttestParse(t, []string{\"testdata/funcfunc.c\"}, \"\")\n}\n\nfunc TestAnonStructField(t *testing.T) {\n\ttestParse(\n\t\tt,\n\t\t[]string{\"testdata/anon.c\"},\n\t\t\"testdata/anon.c:4:7: only unnamed structs and unions are allowed\",\n\t\tEnableAnonymousStructFields(),\n\t)\n}\n\nfunc tokStr(toks []xc.Token) string {\n\tvar b []byte\n\tfor _, v := range toks {\n\t\tswitch v.Rune {\n\t\tcase sentinel:\n\t\t\tb = append(b, []byte(\"@:\")...)\n\t\tcase IDENTIFIER_NONREPL:\n\t\t\tb = append(b, []byte(\"-:\")...)\n\t\t}\n\t\tb = append(b, xc.Dict.S(tokVal(v))...)\n\t}\n\treturn string(b)\n}\n\nfunc tokStr2(toks [][]xc.Token) string {\n\tvar a []string\n\tfor _, v := range toks {\n\t\ta = append(a, tokStr(v))\n\t}\n\treturn strings.Join(a, \", \")\n}\n\nfunc TestIssue50(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue50.h\"}, newTestModel()); err == nil {\n\t\tt.Fatal(\"unexpected success\")\n\t}\n}\n\n// https://github.com/cznic/cc/issues/57\nfunc TestIssue57(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/issue57.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tbool_func := tu.Declarations.Identifiers[dict.SID(\"bool_func\")].Node.(*DirectDeclarator).TopDeclarator()\n\ttyp := bool_func.Type\n\tif g, e := typ.String(), \"int(*)()\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\ttyp = typ.Element() // deref function pointer\n\tif g, e := typ.Result().String(), \"int\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\t// bool_t -> ok!\n\tif g, e := typ.Result().RawDeclarator().RawSpecifier().TypedefName(), dict.SID(\"bool_t\"); g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tfunc1 := tu.Declarations.Identifiers[dict.SID(\"func1\")].Node.(*DirectDeclarator).TopDeclarator()\n\ttyp = func1.Type\n\tif g, e := typ.String(), \"int(*)()\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\ttyp = typ.Element() // deref function pointer\n\tif g, e := typ.String(), \"int()\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\tif g, e := typ.Result().String(), \"int\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\t// try to get bool_t the way we got it above\n\tif g, e := typ.Result().RawDeclarator().RawSpecifier().TypedefName(), dict.SID(\"bool_t\"); g != e {\n\t\tt.Fatal(string(xc.Dict.S(g)), string(xc.Dict.S(e))) // bool_func, how to get bool_t?\n\t}\n}\n\n// https://github.com/cznic/cc/issues/62\nfunc TestIssue62(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/issue62.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tfor ; tu != nil; tu = tu.TranslationUnit {\n\t\td := tu.ExternalDeclaration.Declaration.Declarator()\n\t\tvar e Linkage\n\t\ttag := string(xc.Dict.S(d.Type.Tag()))\n\t\tt.Logf(\"%s: %s\", position(d.Pos()), tag)\n\t\tswitch {\n\t\tcase strings.HasPrefix(tag, \"global\"):\n\t\t\te = External\n\t\tcase strings.HasPrefix(tag, \"local\"):\n\t\t\te = Internal\n\t\t}\n\t\tif g := d.Linkage; g != e {\n\t\t\tt.Fatalf(\"%v %v\", g, e)\n\t\t}\n\t}\n}\n\n// https://github.com/cznic/cc/issues/64\nfunc TestIssue64(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue64.c\"}, newTestModel()); err == nil {\n\t\tt.Fatal(\"expected error\")\n\t} else {\n\t\tt.Log(errString(err))\n\t}\n}\n\n// https://github.com/cznic/cc/issues/65\nfunc TestIssue65(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/issue65.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tfoo, ok := tu.Declarations.Identifiers[xc.Dict.SID(\"foo\")]\n\tif !ok {\n\t\tt.Fatal(\"undefined: foo\")\n\t}\n\n\tft := foo.Node.(*DirectDeclarator).TopDeclarator().Type\n\tm, _ := ft.Members()\n\ttab := map[string]int{\n\t\t\"i\": -1,\n\t\t\"j\": 0,\n\t\t\"k\": 1,\n\t\t\"l\": 3,\n\t\t\"m\": -1,\n\t}\n\tfor _, v := range m {\n\t\tofs, ok := tab[string(xc.Dict.S(v.Name))]\n\t\tif !ok {\n\t\t\tt.Fatal(PrettyString(v))\n\t\t}\n\n\t\tif ofs < 0 {\n\t\t\tif v.Bits != 0 {\n\t\t\t\tt.Fatal(PrettyString(v))\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif v.Bits == 0 {\n\t\t\tt.Fatal(PrettyString(v))\n\t\t}\n\n\t\tif g, e := v.BitOffsetOf, ofs; g != e {\n\t\t\tt.Log(PrettyString(v))\n\t\t\tt.Fatal(g, e)\n\t\t}\n\t}\n}\n\n// https://github.com/cznic/cc/issues/66\nfunc TestIssue66(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/issue66.c\"}, newTestModel())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\te := tu.ExternalDeclaration.Declaration.InitDeclaratorListOpt.InitDeclaratorList.InitDeclarator.Initializer.Expression\n\tif e.Value == nil {\n\t\tt.Fatal(\"expected constant expression\")\n\t}\n\n\tswitch g := e.Value.(type) {\n\tcase uintptr:\n\t\tif e := uintptr(13); g != e {\n\t\t\tt.Fatal(g, e)\n\t\t}\n\tdefault:\n\t\tt.Fatalf(\"%T(%#v)\", g, g)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/67\nfunc TestIssue67(t *testing.T) {\n\ttu, err := Parse(\"\", []string{\"testdata/issue67.c\"}, newTestModel(), KeepComments())\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tvar a []string\n\tfor k, v := range tu.Comments {\n\t\ta = append(a, fmt.Sprintf(\"%s: %q\", xc.FileSet.Position(k), xc.Dict.S(v)))\n\t}\n\tsort.Strings(a)\n\tif g, e := strings.Join(a, \"\\n\"), `testdata/issue67.c:14:1: \"/* abc11 */\\n/* def12\\n */\"\ntestdata/issue67.c:19:1: \"/* abc16\\n */\\n/* def18 */\"\ntestdata/issue67.c:23:1: \"/* abc21 */\\n// def22\"\ntestdata/issue67.c:27:1: \"// def25\\n/* abc26 */\"\ntestdata/issue67.c:2:1: \"// bar1\"\ntestdata/issue67.c:32:1: \"// def31\"\ntestdata/issue67.c:5:1: \"/*\\nbaz3\\n*/\"\ntestdata/issue67.c:9:1: \"// abc7\\n// def8\"`; g != e {\n\t\tt.Fatalf(\"got\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/68\nfunc TestIssue68(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue68.h\"}, newTestModel()); err == nil {\n\t\tt.Fatal(\"expected error\")\n\t}\n\n\tif _, err := Parse(\"\", []string{\"testdata/issue68.h\"}, newTestModel(), EnableEmptyDeclarations()); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/69\nfunc TestIssue69(t *testing.T) {\n\tif _, err := Parse(\"\", []string{\"testdata/issue69.h\"}, newTestModel()); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/72\nfunc TestIssue72(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue72.h\"}, newTestModel(),\n\t\tEnableWideEnumValues(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/74\nfunc TestIssue74EnableWideBitFieldTypes(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue74.h\"}, newTestModel(),\n\t\tEnableWideBitFieldTypes(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/77\nfunc TestIssue77(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue77.c\"}, newTestModel(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/78\nfunc TestIssue78(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue78.c\"}, newTestModel(),\n\t); err == nil {\n\t\tt.Fatal(\"expected error\")\n\t}\n\n\ttu, err := Parse(\n\t\t\"\", []string{\"testdata/issue78.c\"}, newTestModel(), EnableOmitFuncRetType(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tb := tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"f\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\ttyp := b.Node.(*DirectDeclarator).TopDeclarator().Type\n\tif typ == nil {\n\t\tt.Fatal(\"missing type\")\n\t}\n\n\tif typ = typ.Result(); typ == nil {\n\t\tt.Fatal(\"missing result type\")\n\t}\n\n\tif g, e := typ.String(), \"int\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/80\nfunc TestIssue80(t *testing.T) {\n\ttu, err := Parse(\n\t\t\"\", []string{\"testdata/issue80.c\"}, newTestModel(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\tb := tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"s\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\ttyp := b.Node.(*DirectDeclarator).TopDeclarator().Type\n\tif typ == nil {\n\t\tt.Fatal(\"missing type\")\n\t}\n\n\tif g, e := typ.Kind(), Array; g != e {\n\t\tt.Errorf(\"Kind: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.Elements(), 7; g != e {\n\t\tt.Errorf(\"Elements: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.SizeOf(), 7; g != e {\n\t\tt.Fatalf(\"Sizeof: %v %v\", g, e)\n\t}\n\n\tb = tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"t\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\ttyp = b.Node.(*DirectDeclarator).TopDeclarator().Type\n\tif typ == nil {\n\t\tt.Fatal(\"missing type\")\n\t}\n\n\tif g, e := typ.Kind(), Ptr; g != e {\n\t\tt.Errorf(\"Kind: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.Elements(), -1; g != e {\n\t\tt.Errorf(\"Elements: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.SizeOf(), 8; g != e {\n\t\tt.Fatalf(\"Sizeof: %v %v\", g, e)\n\t}\n\n\tb = tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"u\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\ttyp = b.Node.(*DirectDeclarator).TopDeclarator().Type\n\tif typ == nil {\n\t\tt.Fatal(\"missing type\")\n\t}\n\n\tif g, e := typ.Kind(), Array; g != e {\n\t\tt.Errorf(\"Kind: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.Elements(), 11; g != e {\n\t\tt.Errorf(\"Elements: %v %v\", g, e)\n\t}\n\n\tif g, e := typ.SizeOf(), 11; g != e {\n\t\tt.Fatalf(\"Sizeof: %v %v\", g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/81\nfunc TestIssue81(t *testing.T) {\n\ttu, err := Parse(\n\t\t\"\", []string{\"testdata/issue81.c\"}, newTestModel(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t_ = tu\n\tfor l := tu; l != nil; l = l.TranslationUnit {\n\t\td := l.ExternalDeclaration.Declaration\n\t\tfor l := d.InitDeclaratorListOpt.InitDeclaratorList; l != nil; l = l.InitDeclaratorList {\n\t\t\tx := l.InitDeclarator.Initializer.Expression\n\t\t\ts := xc.Dict.S(int(x.Value.(StringLitID)))\n\t\t\tif g, e := len(s), 3; g != e {\n\t\t\t\tt.Fatalf(\"%v |% x| \\n%v %v\", position(x.Pos()), s, g, e)\n\t\t\t}\n\n\t\t\tif g, e := s, []byte{0, 255, 0}; !bytes.Equal(g, e) {\n\t\t\t\tt.Fatalf(\"%v |% x| |% x|\", position(x.Pos()), g, e)\n\t\t\t}\n\t\t}\n\t}\n}\n\n// https://github.com/cznic/cc/issues/82\nfunc TestIssue82(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/issue82.c\"),\n\t\t`d(2)\nd(2, 3)`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/84\nfunc TestIssue84(t *testing.T) {\n\tif g, e := testPreprocessor(t, \"testdata/issue84.c\"),\n\t\t`c(1, 2, 3);\nc(1, 2);\nc(1, );`; g != e {\n\t\tt.Fatalf(\"\\ngot\\n%s\\nexp\\n%s\", g, e)\n\t}\n}\n\nvar vectorAttr = regexp.MustCompile(`__attribute__ *\\(\\((__)?vector_size(__)? *\\(`)\n\nfunc testDir(t *testing.T, dir string) {\n\n\tvar re *regexp.Regexp\n\tif s := *oRe; s != \"\" {\n\t\tre = regexp.MustCompile(s)\n\t}\n\n\tdir = filepath.FromSlash(dir)\n\tt.Log(dir)\n\tm, err := filepath.Glob(filepath.Join(dir, \"*.c\"))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tsort.Strings(m)\n\tpredefined, _, sysIncludePaths, err := HostConfig()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tblacklist := []string{\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011217-2.c\", // (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020320-1.c\", // static T *p = x;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37056.c\",    // ? ({void *__s = (u.buf + off); __s;}) : ...\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-1.c\",  // __complex__ int c;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-2.c\",  // __complex__ int ci;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-3.c\",  // __complex__ int ci;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54559.c\",    // return x + y * (T) (__extension__ 1.0iF);\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c\",  // #include: typedef int V __attribute__((vector_size (N * sizeof (int))));\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c\",  // #include: typedef int V __attribute__((vector_size (N * sizeof (int))));\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr67143.c\",    // __sync_add_and_fetch(&a, 536870912);\n\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041124-1.c\",    // struct s { _Complex unsigned short x; };\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041201-1.c\",    // typedef struct { _Complex char a; _Complex char b; } Scc2;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071211-1.c\",    // __asm__ volatile (\"\" : : : \"memory\");\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19449.c\",       // int z = __builtin_choose_expr (!__builtin_constant_p (y), 3, 4);\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38151.c\",       // _Complex int b;\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39228.c\",       // if (testl (1.18973149535723176502e+4932L) < 1)\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56982.c\",       // __asm__ volatile (\"\" : : : \"memory\");\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71626-2.c\",     // #include: typedef __INTPTR_TYPE__ V __attribute__((__vector_size__(sizeof (__INTPTR_TYPE__))));\n\t\t\"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pushpop_macro.c\", // #pragma push_macro(\"_\")\n\t}\n\n\tconst attempt2prototypes = `\nvoid exit();\nvoid abort();\n`\n\n\tvar pass, gccFail int\n\tdefer func() {\n\t\tt.Logf(\"pass %v, gccFail %v (sum %v), total test cases %v\", pass, gccFail, pass+gccFail, len(m))\n\t}()\nouter:\n\tfor i, v := range m {\n\t\tif re != nil && !re.MatchString(v) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, w := range blacklist {\n\t\t\tif strings.HasSuffix(filepath.ToSlash(v), w) {\n\t\t\t\tcontinue outer\n\t\t\t}\n\t\t}\n\n\t\tb, err := ioutil.ReadFile(v)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tif vectorAttr.Match(b) {\n\t\t\tcontinue\n\t\t}\n\n\t\tattempt := 1\n\tretry:\n\t\tfunc() {\n\t\t\tdefer func() {\n\t\t\t\tif e := recover(); e != nil {\n\t\t\t\t\terr = fmt.Errorf(\"PANIC\\n%s\\n%v\", debug.Stack(), e)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\ts := predefined\n\t\t\tif attempt == 2 {\n\t\t\t\ts += attempt2prototypes\n\t\t\t}\n\t\t\terr = testDev1(\n\t\t\t\ts,\n\t\t\t\ts,\n\t\t\t\ts,\n\t\t\t\t[]string{},\n\t\t\t\t\"\",\n\t\t\t\tv,\n\t\t\t\t[]Opt{\n\t\t\t\t\tErrLimit(-1),\n\t\t\t\t\tSysIncludePaths(sysIncludePaths),\n\t\t\t\t\tEnableIncludeNext(),\n\t\t\t\t\tEnableDefineOmitCommaBeforeDDD(),\n\t\t\t\t},\n\t\t\t\t[]Opt{\n\t\t\t\t\tErrLimit(-1),\n\t\t\t\t\tSysIncludePaths(sysIncludePaths),\n\t\t\t\t\tEnableIncludeNext(),\n\t\t\t\t\tEnableWideBitFieldTypes(),\n\t\t\t\t\tEnableEmptyDeclarations(),\n\t\t\t\t\tgccEmu(),\n\t\t\t\t},\n\t\t\t)\n\t\t}()\n\n\t\tif err != nil {\n\t\t\t//dbg(\"%T(%v)\", err, err)\n\t\t\tswitch err.(type) {\n\t\t\tcase cppCmpError:\n\t\t\t\t// fail w/o retry.\n\t\t\tdefault:\n\t\t\t\tif attempt == 1 { // retry with {abort,exit} prototype.\n\t\t\t\t\tattempt++\n\t\t\t\t\tgoto retry\n\t\t\t\t}\n\n\t\t\t\ts := errString(err)\n\t\t\t\tif !strings.Contains(s, \"PANIC\") && !strings.Contains(s, \"TODO\") && !strings.Contains(s, \"undefined: __builtin_\") {\n\t\t\t\t\tif out, err := exec.Command(\"gcc\", \"-o\", os.DevNull, \"-c\", \"-std=c99\", \"--pedantic\", \"-fmax-errors=10\", v).CombinedOutput(); len(out) != 0 || err != nil {\n\t\t\t\t\t\t// Auto blacklist if gcc fails to compile as well.\n\t\t\t\t\t\tif n := 4000; len(out) > n {\n\t\t\t\t\t\t\tout = out[:n]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tt.Logf(\"%s\\n==== gcc reports\\n%s\\n%v\", s, out, err)\n\t\t\t\t\t\tgccFail++\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tt.Errorf(\"%v\\n%v/%v, %v ok(+%v=%v)\\nFAIL\\n%s (%T)\", v, i+1, len(m), pass, gccFail, pass+gccFail, errString(err), err)\n\t\t\treturn\n\t\t}\n\n\t\tpass++\n\t\tif re != nil {\n\t\t\tt.Logf(\"%v: %v ok\", v, pass)\n\t\t}\n\t}\n}\n\nfunc TestTCCTests(t *testing.T) {\n\tif !*oDev {\n\t\tt.Log(\"enable with -dev\")\n\t\treturn\n\t}\n\n\ttestDir(t, \"testdata/tcc-0.9.26/tests/tests2/\")\n}\n\nfunc TestGCCTests(t *testing.T) {\n\tif !*oDev {\n\t\tt.Log(\"enable with -dev\")\n\t\treturn\n\t}\n\n\ttestDir(t, \"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/\")\n\ttestDir(t, \"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/\")\n\ttestDir(t, \"testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/\")\n}\n\n// https://github.com/cznic/cc/issues/85\nfunc TestIssue85(t *testing.T) {\n\ttu, err := Parse(\n\t\t\"\", []string{\"testdata/issue85.c\"}, newTestModel(), EnableOmitFuncRetType(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tb := tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"i\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\td := b.Node.(*DirectDeclarator).TopDeclarator()\n\tif g, e := d.Linkage, External; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := d.Type.Specifier().IsExtern(), false; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tb = tu.Declarations.Lookup(NSIdentifiers, xc.Dict.SID(\"j\"))\n\tif b.Node == nil {\n\t\tt.Fatal(\"lookup fail\")\n\t}\n\n\td = b.Node.(*DirectDeclarator).TopDeclarator()\n\tif g, e := d.Linkage, External; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := d.Type.Specifier().IsExtern(), true; g != e {\n\t\tt.Fatal(g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/86\nfunc TestIssue86(t *testing.T) {\n\t_, err := Parse(\n\t\t\"\", []string{\"testdata/issue86.c\"}, newTestModel(), EnableOmitFuncRetType(),\n\t)\n\tif err == nil {\n\t\tt.Fatal(\"missed error\")\n\t}\n\n\tif g, e := err.Error(), \"testdata/issue86.c:2:12: 'j' initialized and declared 'extern'\"; g != e {\n\t\tt.Fatalf(\"%q %q\", g, e)\n\t}\n\n\tt.Log(err)\n}\n\nfunc TestArray(t *testing.T) {\n\tast, err := Parse(\n\t\t\"\", []string{\"testdata/array.c\"}, newTestModel(), EnableOmitFuncRetType(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\texpr := ast.TranslationUnit.ExternalDeclaration.FunctionDefinition.FunctionBody.\n\t\tCompoundStatement.BlockItemListOpt.BlockItemList.BlockItemList.BlockItem.\n\t\tStatement.ExpressionStatement.ExpressionListOpt.ExpressionList.Expression\n\n\tif g, e := expr.Type.Kind(), Ptr; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tdd := expr.IdentResolutionScope().Lookup(NSIdentifiers, dict.SID(\"a\")).Node.(*DirectDeclarator)\n\tif g, e := dd.TopDeclarator().Type.Kind(), Array; g != e {\n\t\tt.Fatal(g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/87\nfunc TestIssue87(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue87.c\"}, newTestModel(),\n\t); err == nil {\n\t\tt.Fatal(\"missed error\")\n\t}\n\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue87.c\"}, newTestModel(), AllowCompatibleTypedefRedefinitions(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/88\nfunc TestIssue88(t *testing.T) {\n\tast, err := Parse(\n\t\t\"\", []string{\"testdata/issue88.c\"}, newTestModel(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\texp := ast.TranslationUnit.ExternalDeclaration.FunctionDefinition.FunctionBody.\n\t\tCompoundStatement.BlockItemListOpt.BlockItemList.BlockItemList.BlockItem.\n\t\tStatement.ExpressionStatement.ExpressionListOpt.ExpressionList.Expression\n\n\tif g := exp.BinOpType; g != nil {\n\t\tt.Fatalf(\"unexpected non-nil BinOpType %s\", g)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/89\nfunc TestIssue89(t *testing.T) {\n\tast, err := Parse(\n\t\t\"\", []string{\"testdata/issue89.c\"}, newTestModel(), EnableImplicitFuncDef(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\texp := ast.TranslationUnit.ExternalDeclaration.FunctionDefinition.FunctionBody.\n\t\tCompoundStatement.BlockItemListOpt.BlockItemList.BlockItemList.BlockItemList.BlockItem.\n\t\tStatement.ExpressionStatement.ExpressionListOpt.ExpressionList.Expression.\n\t\tArgumentExpressionListOpt.ArgumentExpressionList.Expression\n\n\tif g := exp.Type; g == nil {\n\t\tt.Errorf(\"'a.f': missing expression type\")\n\t}\n\tif g := exp.Expression.Type; g == nil {\n\t\tt.Errorf(\"'a': missing expression type\")\n\t}\n}\n\n// https://github.com/cznic/cc/issues/90\nfunc TestIssue90(t *testing.T) {\n\tast, err := Parse(\n\t\t\"\", []string{\"testdata/issue90.c\"}, newTestModel(), EnableImplicitFuncDef(),\n\t)\n\tif err != nil {\n\t\tt.Fatal(errString(err))\n\t}\n\n\texpr := ast.TranslationUnit.ExternalDeclaration.FunctionDefinition.FunctionBody.\n\t\tCompoundStatement.BlockItemListOpt.BlockItemList.BlockItemList.BlockItem.\n\t\tStatement.ExpressionStatement.ExpressionListOpt.ExpressionList.Expression\n\n\tif g, e := expr.Type.Kind(), UInt; g != e {\n\t\tt.Errorf(\"expr: %v %v\", g, e)\n\t}\n\tif g, e := expr.Expression.Type.Kind(), UInt; g != e {\n\t\tt.Errorf(\"expr.Expression: %v %v\", g, e)\n\t}\n\tif g, e := expr.Expression2.Type.Kind(), UInt; g != e {\n\t\tt.Errorf(\"expr.Expression2: %v %v\", g, e)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/92\nfunc TestIssue92(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue92.c\"}, newTestModel(),\n\t); err == nil {\n\t\tt.Fatal(\"missed error\")\n\t}\n\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue92.c\"}, newTestModel(), AllowCompatibleTypedefRedefinitions(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\n// https://github.com/cznic/cc/issues/93\nfunc TestIssue93(t *testing.T) {\n\tif _, err := Parse(\n\t\t\"\", []string{\"testdata/issue93.c\"}, newTestModel(),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n"
  },
  {
    "path": "ast.go",
    "content": "// Code generated by yy. DO NOT EDIT.\n\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"go/token\"\n\n\t\"github.com/cznic/xc\"\n)\n\n// AbstractDeclarator represents data reduced by productions:\n//\n//\tAbstractDeclarator:\n//\t        Pointer\n//\t|       PointerOpt DirectAbstractDeclarator  // Case 1\ntype AbstractDeclarator struct {\n\tdeclarator               *Declarator\n\tCase                     int\n\tDirectAbstractDeclarator *DirectAbstractDeclarator\n\tPointer                  *Pointer\n\tPointerOpt               *PointerOpt\n}\n\nfunc (n *AbstractDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AbstractDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AbstractDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Pointer.Pos()\n\tcase 1:\n\t\tif p := n.PointerOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.DirectAbstractDeclarator.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// AbstractDeclaratorOpt represents data reduced by productions:\n//\n//\tAbstractDeclaratorOpt:\n//\t        /* empty */\n//\t|       AbstractDeclarator  // Case 1\ntype AbstractDeclaratorOpt struct {\n\tAbstractDeclarator *AbstractDeclarator\n}\n\nfunc (n *AbstractDeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AbstractDeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AbstractDeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.AbstractDeclarator.Pos()\n}\n\n// ArgumentExpressionList represents data reduced by productions:\n//\n//\tArgumentExpressionList:\n//\t        Expression\n//\t|       ArgumentExpressionList ',' Expression  // Case 1\ntype ArgumentExpressionList struct {\n\tArgumentExpressionList *ArgumentExpressionList\n\tCase                   int\n\tExpression             *Expression\n\tToken                  xc.Token\n}\n\nfunc (n *ArgumentExpressionList) reverse() *ArgumentExpressionList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ArgumentExpressionList\n\tfor nb != nil {\n\t\tnc := nb.ArgumentExpressionList\n\t\tnb.ArgumentExpressionList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ArgumentExpressionList = nil\n\treturn na\n}\n\nfunc (n *ArgumentExpressionList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ArgumentExpressionList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ArgumentExpressionList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.ArgumentExpressionList.Pos()\n\tcase 0:\n\t\treturn n.Expression.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ArgumentExpressionListOpt represents data reduced by productions:\n//\n//\tArgumentExpressionListOpt:\n//\t        /* empty */\n//\t|       ArgumentExpressionList  // Case 1\ntype ArgumentExpressionListOpt struct {\n\tArgumentExpressionList *ArgumentExpressionList\n}\n\nfunc (n *ArgumentExpressionListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ArgumentExpressionListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ArgumentExpressionListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ArgumentExpressionList.Pos()\n}\n\n// AssemblerInstructions represents data reduced by productions:\n//\n//\tAssemblerInstructions:\n//\t        STRINGLITERAL\n//\t|       AssemblerInstructions STRINGLITERAL  // Case 1\ntype AssemblerInstructions struct {\n\tAssemblerInstructions *AssemblerInstructions\n\tCase                  int\n\tToken                 xc.Token\n}\n\nfunc (n *AssemblerInstructions) reverse() *AssemblerInstructions {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.AssemblerInstructions\n\tfor nb != nil {\n\t\tnc := nb.AssemblerInstructions\n\t\tnb.AssemblerInstructions = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.AssemblerInstructions = nil\n\treturn na\n}\n\nfunc (n *AssemblerInstructions) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *AssemblerInstructions) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AssemblerInstructions) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.AssemblerInstructions.Pos()\n\tcase 0:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// AssemblerOperand represents data reduced by production:\n//\n//\tAssemblerOperand:\n//\t        AssemblerSymbolicNameOpt STRINGLITERAL '(' Expression ')'\ntype AssemblerOperand struct {\n\tAssemblerSymbolicNameOpt *AssemblerSymbolicNameOpt\n\tExpression               *Expression\n\tToken                    xc.Token\n\tToken2                   xc.Token\n\tToken3                   xc.Token\n}\n\nfunc (n *AssemblerOperand) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AssemblerOperand) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AssemblerOperand) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tif p := n.AssemblerSymbolicNameOpt.Pos(); p != 0 {\n\t\treturn p\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// AssemblerOperands represents data reduced by productions:\n//\n//\tAssemblerOperands:\n//\t        AssemblerOperand\n//\t|       AssemblerOperands ',' AssemblerOperand  // Case 1\ntype AssemblerOperands struct {\n\tAssemblerOperand  *AssemblerOperand\n\tAssemblerOperands *AssemblerOperands\n\tCase              int\n\tToken             xc.Token\n}\n\nfunc (n *AssemblerOperands) reverse() *AssemblerOperands {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.AssemblerOperands\n\tfor nb != nil {\n\t\tnc := nb.AssemblerOperands\n\t\tnb.AssemblerOperands = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.AssemblerOperands = nil\n\treturn na\n}\n\nfunc (n *AssemblerOperands) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *AssemblerOperands) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AssemblerOperands) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.AssemblerOperand.Pos()\n\tcase 1:\n\t\treturn n.AssemblerOperands.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// AssemblerStatement represents data reduced by productions:\n//\n//\tAssemblerStatement:\n//\t        BasicAssemblerStatement\n//\t|       \"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ')'                                             // Case 1\n//\t|       \"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ')'                       // Case 2\n//\t|       \"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ':' Clobbers ')'          // Case 3\n//\t|       \"asm\" VolatileOpt \"goto\" '(' AssemblerInstructions ':' ':' AssemblerOperands ':' Clobbers ':' IdentifierList ')'  // Case 4\n//\t|       \"asm\" VolatileOpt '(' AssemblerInstructions ':' ')'                                                               // Case 5\n//\t|       \"asm\" VolatileOpt '(' AssemblerInstructions ':' ':' AssemblerOperands ')'                                         // Case 6\ntype AssemblerStatement struct {\n\tAssemblerInstructions   *AssemblerInstructions\n\tAssemblerOperands       *AssemblerOperands\n\tAssemblerOperands2      *AssemblerOperands\n\tBasicAssemblerStatement *BasicAssemblerStatement\n\tCase                    int\n\tClobbers                *Clobbers\n\tIdentifierList          *IdentifierList\n\tToken                   xc.Token\n\tToken2                  xc.Token\n\tToken3                  xc.Token\n\tToken4                  xc.Token\n\tToken5                  xc.Token\n\tToken6                  xc.Token\n\tToken7                  xc.Token\n\tToken8                  xc.Token\n\tVolatileOpt             *VolatileOpt\n}\n\nfunc (n *AssemblerStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AssemblerStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AssemblerStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.BasicAssemblerStatement.Pos()\n\tcase 1, 2, 3, 4, 5, 6:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// AssemblerSymbolicNameOpt represents data reduced by productions:\n//\n//\tAssemblerSymbolicNameOpt:\n//\t        /* empty */\n//\t|       '[' IDENTIFIER ']'  // Case 1\ntype AssemblerSymbolicNameOpt struct {\n\tToken  xc.Token\n\tToken2 xc.Token\n\tToken3 xc.Token\n}\n\nfunc (n *AssemblerSymbolicNameOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AssemblerSymbolicNameOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AssemblerSymbolicNameOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// BasicAssemblerStatement represents data reduced by production:\n//\n//\tBasicAssemblerStatement:\n//\t        \"asm\" VolatileOpt '(' AssemblerInstructions ')'\ntype BasicAssemblerStatement struct {\n\tAssemblerInstructions *AssemblerInstructions\n\tToken                 xc.Token\n\tToken2                xc.Token\n\tToken3                xc.Token\n\tVolatileOpt           *VolatileOpt\n}\n\nfunc (n *BasicAssemblerStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *BasicAssemblerStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BasicAssemblerStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// BlockItem represents data reduced by productions:\n//\n//\tBlockItem:\n//\t        Declaration\n//\t|       Statement    // Case 1\ntype BlockItem struct {\n\tCase        int\n\tDeclaration *Declaration\n\tStatement   *Statement\n}\n\nfunc (n *BlockItem) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItem) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItem) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declaration.Pos()\n\tcase 1:\n\t\treturn n.Statement.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// BlockItemList represents data reduced by productions:\n//\n//\tBlockItemList:\n//\t        BlockItem\n//\t|       BlockItemList BlockItem  // Case 1\ntype BlockItemList struct {\n\tBlockItem     *BlockItem\n\tBlockItemList *BlockItemList\n\tCase          int\n}\n\nfunc (n *BlockItemList) reverse() *BlockItemList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.BlockItemList\n\tfor nb != nil {\n\t\tnc := nb.BlockItemList\n\t\tnb.BlockItemList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.BlockItemList = nil\n\treturn na\n}\n\nfunc (n *BlockItemList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItemList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItemList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.BlockItem.Pos()\n\tcase 1:\n\t\treturn n.BlockItemList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// BlockItemListOpt represents data reduced by productions:\n//\n//\tBlockItemListOpt:\n//\t        /* empty */\n//\t|       BlockItemList  // Case 1\ntype BlockItemListOpt struct {\n\tBlockItemList *BlockItemList\n}\n\nfunc (n *BlockItemListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItemListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItemListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.BlockItemList.Pos()\n}\n\n// Clobbers represents data reduced by productions:\n//\n//\tClobbers:\n//\t        STRINGLITERAL\n//\t|       Clobbers ',' STRINGLITERAL  // Case 1\ntype Clobbers struct {\n\tCase     int\n\tClobbers *Clobbers\n\tToken    xc.Token\n\tToken2   xc.Token\n}\n\nfunc (n *Clobbers) reverse() *Clobbers {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.Clobbers\n\tfor nb != nil {\n\t\tnc := nb.Clobbers\n\t\tnb.Clobbers = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.Clobbers = nil\n\treturn na\n}\n\nfunc (n *Clobbers) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *Clobbers) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Clobbers) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.Clobbers.Pos()\n\tcase 0:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// CommaOpt represents data reduced by productions:\n//\n//\tCommaOpt:\n//\t        /* empty */\n//\t|       ','          // Case 1\ntype CommaOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *CommaOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *CommaOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *CommaOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// CompoundStatement represents data reduced by production:\n//\n//\tCompoundStatement:\n//\t        '{' BlockItemListOpt '}'\ntype CompoundStatement struct {\n\tscope            *Bindings // Scope of the CompoundStatement.\n\tBlockItemListOpt *BlockItemListOpt\n\tToken            xc.Token\n\tToken2           xc.Token\n}\n\nfunc (n *CompoundStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *CompoundStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *CompoundStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ConstantExpression represents data reduced by production:\n//\n//\tConstantExpression:\n//\t        Expression\ntype ConstantExpression struct {\n\tType       Type        // Type of expression.\n\tValue      interface{} // Non nil for certain constant expressions.\n\ttoks       []xc.Token  //\n\tExpression *Expression\n}\n\nfunc (n *ConstantExpression) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ConstantExpression) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ConstantExpression) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Expression.Pos()\n}\n\n// ControlLine represents data reduced by productions:\n//\n//\tControlLine:\n//\t        PPDEFINE IDENTIFIER ReplacementList\n//\t|       PPDEFINE IDENTIFIER_LPAREN \"...\" ')' ReplacementList                     // Case 1\n//\t|       PPDEFINE IDENTIFIER_LPAREN IdentifierList ',' \"...\" ')' ReplacementList  // Case 2\n//\t|       PPDEFINE IDENTIFIER_LPAREN IdentifierListOpt ')' ReplacementList         // Case 3\n//\t|       PPERROR PPTokenListOpt                                                   // Case 4\n//\t|       PPHASH_NL                                                                // Case 5\n//\t|       PPINCLUDE PPTokenList '\\n'                                               // Case 6\n//\t|       PPLINE PPTokenList '\\n'                                                  // Case 7\n//\t|       PPPRAGMA PPTokenListOpt                                                  // Case 8\n//\t|       PPUNDEF IDENTIFIER '\\n'                                                  // Case 9\n//\t|       PPDEFINE IDENTIFIER_LPAREN IdentifierList \"...\" ')' ReplacementList      // Case 10\n//\t|       PPDEFINE '\\n'                                                            // Case 11\n//\t|       PPUNDEF IDENTIFIER PPTokenList '\\n'                                      // Case 12\n//\t|       PPINCLUDE_NEXT PPTokenList '\\n'                                          // Case 13\ntype ControlLine struct {\n\tCase              int\n\tIdentifierList    *IdentifierList\n\tIdentifierListOpt *IdentifierListOpt\n\tPPTokenList       PPTokenList\n\tPPTokenListOpt    PPTokenList\n\tReplacementList   PPTokenList\n\tToken             xc.Token\n\tToken2            xc.Token\n\tToken3            xc.Token\n\tToken4            xc.Token\n\tToken5            xc.Token\n}\n\nfunc (n *ControlLine) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ControlLine) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ControlLine) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// Declaration represents data reduced by productions:\n//\n//\tDeclaration:\n//\t        DeclarationSpecifiers InitDeclaratorListOpt ';'\n//\t|       StaticAssertDeclaration                          // Case 1\ntype Declaration struct {\n\tdeclarator              *Declarator // Synthetic declarator when InitDeclaratorListOpt is nil.\n\tCase                    int\n\tDeclarationSpecifiers   *DeclarationSpecifiers\n\tInitDeclaratorListOpt   *InitDeclaratorListOpt\n\tStaticAssertDeclaration *StaticAssertDeclaration\n\tToken                   xc.Token\n}\n\nfunc (n *Declaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Declaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Declaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.DeclarationSpecifiers.Pos()\n\tcase 1:\n\t\treturn n.StaticAssertDeclaration.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DeclarationList represents data reduced by productions:\n//\n//\tDeclarationList:\n//\t        Declaration\n//\t|       DeclarationList Declaration  // Case 1\ntype DeclarationList struct {\n\tCase            int\n\tDeclaration     *Declaration\n\tDeclarationList *DeclarationList\n}\n\nfunc (n *DeclarationList) reverse() *DeclarationList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.DeclarationList\n\tfor nb != nil {\n\t\tnc := nb.DeclarationList\n\t\tnb.DeclarationList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.DeclarationList = nil\n\treturn na\n}\n\nfunc (n *DeclarationList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declaration.Pos()\n\tcase 1:\n\t\treturn n.DeclarationList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DeclarationListOpt represents data reduced by productions:\n//\n//\tDeclarationListOpt:\n//\t        /* empty */\n//\t|       DeclarationList  // Case 1\ntype DeclarationListOpt struct {\n\tparamsScope     *Bindings\n\tDeclarationList *DeclarationList\n}\n\nfunc (n *DeclarationListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationList.Pos()\n}\n\n// DeclarationSpecifiers represents data reduced by productions:\n//\n//\tDeclarationSpecifiers:\n//\t        StorageClassSpecifier DeclarationSpecifiersOpt\n//\t|       TypeSpecifier DeclarationSpecifiersOpt          // Case 1\n//\t|       TypeQualifier DeclarationSpecifiersOpt          // Case 2\n//\t|       FunctionSpecifier DeclarationSpecifiersOpt      // Case 3\ntype DeclarationSpecifiers struct {\n\tattr                     int // tsInline, tsTypedefName, ...\n\ttypeSpecifier            int // Encoded combination of tsVoid, tsInt, ...\n\tCase                     int\n\tDeclarationSpecifiersOpt *DeclarationSpecifiersOpt\n\tFunctionSpecifier        *FunctionSpecifier\n\tStorageClassSpecifier    *StorageClassSpecifier\n\tTypeQualifier            *TypeQualifier\n\tTypeSpecifier            *TypeSpecifier\n}\n\nfunc (n *DeclarationSpecifiers) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationSpecifiers) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationSpecifiers) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 3:\n\t\treturn n.FunctionSpecifier.Pos()\n\tcase 0:\n\t\treturn n.StorageClassSpecifier.Pos()\n\tcase 2:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 1:\n\t\treturn n.TypeSpecifier.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DeclarationSpecifiersOpt represents data reduced by productions:\n//\n//\tDeclarationSpecifiersOpt:\n//\t        /* empty */\n//\t|       DeclarationSpecifiers  // Case 1\ntype DeclarationSpecifiersOpt struct {\n\tattr                  int // tsInline, tsTypedefName, ...\n\ttypeSpecifier         int // Encoded combination of tsVoid, tsInt, ...\n\tDeclarationSpecifiers *DeclarationSpecifiers\n}\n\nfunc (n *DeclarationSpecifiersOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationSpecifiersOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationSpecifiersOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationSpecifiers.Pos()\n}\n\n// Declarator represents data reduced by production:\n//\n//\tDeclarator:\n//\t        PointerOpt DirectDeclarator\ntype Declarator struct {\n\tLinkage          Linkage\n\tType             Type\n\tbitFieldType     Type\n\tbitFieldGroup    int\n\tbitOffset        int\n\tbits             int\n\toffsetOf         int\n\tpadding          int\n\tspecifier        Specifier\n\tDirectDeclarator *DirectDeclarator\n\tPointerOpt       *PointerOpt\n}\n\nfunc (n *Declarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Declarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Declarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tif p := n.PointerOpt.Pos(); p != 0 {\n\t\treturn p\n\t}\n\n\treturn n.DirectDeclarator.Pos()\n}\n\n// DeclaratorOpt represents data reduced by productions:\n//\n//\tDeclaratorOpt:\n//\t        /* empty */\n//\t|       Declarator   // Case 1\ntype DeclaratorOpt struct {\n\tDeclarator *Declarator\n}\n\nfunc (n *DeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Declarator.Pos()\n}\n\n// Designation represents data reduced by production:\n//\n//\tDesignation:\n//\t        DesignatorList '='\ntype Designation struct {\n\tDesignatorList *DesignatorList\n\tToken          xc.Token\n}\n\nfunc (n *Designation) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Designation) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Designation) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DesignatorList.Pos()\n}\n\n// DesignationOpt represents data reduced by productions:\n//\n//\tDesignationOpt:\n//\t        /* empty */\n//\t|       Designation  // Case 1\ntype DesignationOpt struct {\n\tDesignation *Designation\n}\n\nfunc (n *DesignationOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DesignationOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DesignationOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Designation.Pos()\n}\n\n// Designator represents data reduced by productions:\n//\n//\tDesignator:\n//\t        '[' ConstantExpression ']'\n//\t|       '.' IDENTIFIER              // Case 1\ntype Designator struct {\n\tCase               int\n\tConstantExpression *ConstantExpression\n\tToken              xc.Token\n\tToken2             xc.Token\n}\n\nfunc (n *Designator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Designator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Designator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// DesignatorList represents data reduced by productions:\n//\n//\tDesignatorList:\n//\t        Designator\n//\t|       DesignatorList Designator  // Case 1\ntype DesignatorList struct {\n\tCase           int\n\tDesignator     *Designator\n\tDesignatorList *DesignatorList\n}\n\nfunc (n *DesignatorList) reverse() *DesignatorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.DesignatorList\n\tfor nb != nil {\n\t\tnc := nb.DesignatorList\n\t\tnb.DesignatorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.DesignatorList = nil\n\treturn na\n}\n\nfunc (n *DesignatorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *DesignatorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DesignatorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Designator.Pos()\n\tcase 1:\n\t\treturn n.DesignatorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DirectAbstractDeclarator represents data reduced by productions:\n//\n//\tDirectAbstractDeclarator:\n//\t        '(' AbstractDeclarator ')'\n//\t|       DirectAbstractDeclaratorOpt '[' ExpressionOpt ']'                             // Case 1\n//\t|       DirectAbstractDeclaratorOpt '[' TypeQualifierList ExpressionOpt ']'           // Case 2\n//\t|       DirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expression ']'  // Case 3\n//\t|       DirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expression ']'     // Case 4\n//\t|       DirectAbstractDeclaratorOpt '[' '*' ']'                                       // Case 5\n//\t|       '(' ParameterTypeListOpt ')'                                                  // Case 6\n//\t|       DirectAbstractDeclarator '(' ParameterTypeListOpt ')'                         // Case 7\ntype DirectAbstractDeclarator struct {\n\tdirectDeclarator            *DirectDeclarator\n\tparamsScope                 *Bindings\n\tAbstractDeclarator          *AbstractDeclarator\n\tCase                        int\n\tDirectAbstractDeclarator    *DirectAbstractDeclarator\n\tDirectAbstractDeclaratorOpt *DirectAbstractDeclaratorOpt\n\tExpression                  *Expression\n\tExpressionOpt               *ExpressionOpt\n\tParameterTypeListOpt        *ParameterTypeListOpt\n\tToken                       xc.Token\n\tToken2                      xc.Token\n\tToken3                      xc.Token\n\tTypeQualifierList           *TypeQualifierList\n\tTypeQualifierListOpt        *TypeQualifierListOpt\n}\n\nfunc (n *DirectAbstractDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectAbstractDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectAbstractDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 7:\n\t\treturn n.DirectAbstractDeclarator.Pos()\n\tcase 1, 2, 3, 4, 5:\n\t\tif p := n.DirectAbstractDeclaratorOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tcase 0, 6:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DirectAbstractDeclaratorOpt represents data reduced by productions:\n//\n//\tDirectAbstractDeclaratorOpt:\n//\t        /* empty */\n//\t|       DirectAbstractDeclarator  // Case 1\ntype DirectAbstractDeclaratorOpt struct {\n\tDirectAbstractDeclarator *DirectAbstractDeclarator\n}\n\nfunc (n *DirectAbstractDeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectAbstractDeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectAbstractDeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DirectAbstractDeclarator.Pos()\n}\n\n// DirectDeclarator represents data reduced by productions:\n//\n//\tDirectDeclarator:\n//\t        IDENTIFIER\n//\t|       '(' Declarator ')'                                                 // Case 1\n//\t|       DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'        // Case 2\n//\t|       DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'  // Case 3\n//\t|       DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'     // Case 4\n//\t|       DirectDeclarator '[' TypeQualifierListOpt '*' ']'                  // Case 5\n//\t|       DirectDeclarator '(' ParameterTypeList ')'                         // Case 6\n//\t|       DirectDeclarator '(' IdentifierListOpt ')'                         // Case 7\ntype DirectDeclarator struct {\n\tEnumVal              interface{} // Non nil if DD declares an enumeration constant.\n\tdeclarator           *Declarator\n\telements             int\n\tidScope              *Bindings // Of case 0: IDENTIFIER.\n\tparamsScope          *Bindings\n\tparent               *DirectDeclarator\n\tprev                 *Binding // Existing declaration in same scope, if any.\n\tspecifier            Specifier\n\tvisible              *Binding // Existing declaration of same ident visible in same scope, if any and this DD has storage class extrn.\n\tCase                 int\n\tDeclarator           *Declarator\n\tDirectDeclarator     *DirectDeclarator\n\tExpression           *Expression\n\tExpressionOpt        *ExpressionOpt\n\tIdentifierListOpt    *IdentifierListOpt\n\tParameterTypeList    *ParameterTypeList\n\tToken                xc.Token\n\tToken2               xc.Token\n\tToken3               xc.Token\n\tTypeQualifierList    *TypeQualifierList\n\tTypeQualifierListOpt *TypeQualifierListOpt\n}\n\nfunc (n *DirectDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 2, 3, 4, 5, 6, 7:\n\t\treturn n.DirectDeclarator.Pos()\n\tcase 0, 1:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ElifGroup represents data reduced by production:\n//\n//\tElifGroup:\n//\t        PPELIF PPTokenList '\\n' GroupListOpt\ntype ElifGroup struct {\n\tGroupListOpt *GroupListOpt\n\tPPTokenList  PPTokenList\n\tToken        xc.Token\n\tToken2       xc.Token\n}\n\nfunc (n *ElifGroup) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ElifGroup) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ElifGroup) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ElifGroupList represents data reduced by productions:\n//\n//\tElifGroupList:\n//\t        ElifGroup\n//\t|       ElifGroupList ElifGroup  // Case 1\ntype ElifGroupList struct {\n\tCase          int\n\tElifGroup     *ElifGroup\n\tElifGroupList *ElifGroupList\n}\n\nfunc (n *ElifGroupList) reverse() *ElifGroupList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ElifGroupList\n\tfor nb != nil {\n\t\tnc := nb.ElifGroupList\n\t\tnb.ElifGroupList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ElifGroupList = nil\n\treturn na\n}\n\nfunc (n *ElifGroupList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ElifGroupList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ElifGroupList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.ElifGroup.Pos()\n\tcase 1:\n\t\treturn n.ElifGroupList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ElifGroupListOpt represents data reduced by productions:\n//\n//\tElifGroupListOpt:\n//\t        /* empty */\n//\t|       ElifGroupList  // Case 1\ntype ElifGroupListOpt struct {\n\tElifGroupList *ElifGroupList\n}\n\nfunc (n *ElifGroupListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ElifGroupListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ElifGroupListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ElifGroupList.Pos()\n}\n\n// ElseGroup represents data reduced by production:\n//\n//\tElseGroup:\n//\t        PPELSE '\\n' GroupListOpt\ntype ElseGroup struct {\n\tGroupListOpt *GroupListOpt\n\tToken        xc.Token\n\tToken2       xc.Token\n}\n\nfunc (n *ElseGroup) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ElseGroup) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ElseGroup) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ElseGroupOpt represents data reduced by productions:\n//\n//\tElseGroupOpt:\n//\t        /* empty */\n//\t|       ElseGroup    // Case 1\ntype ElseGroupOpt struct {\n\tElseGroup *ElseGroup\n}\n\nfunc (n *ElseGroupOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ElseGroupOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ElseGroupOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ElseGroup.Pos()\n}\n\n// EndifLine represents data reduced by production:\n//\n//\tEndifLine:\n//\t        PPENDIF\ntype EndifLine struct {\n\tToken xc.Token\n}\n\nfunc (n *EndifLine) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *EndifLine) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EndifLine) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// EnumSpecifier represents data reduced by productions:\n//\n//\tEnumSpecifier:\n//\t        \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n//\t|       \"enum\" IDENTIFIER                                     // Case 1\ntype EnumSpecifier struct {\n\tunsigned       bool\n\tCase           int\n\tCommaOpt       *CommaOpt\n\tEnumeratorList *EnumeratorList\n\tIdentifierOpt  *IdentifierOpt\n\tToken          xc.Token\n\tToken2         xc.Token\n\tToken3         xc.Token\n}\n\nfunc (n *EnumSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *EnumSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// EnumerationConstant represents data reduced by production:\n//\n//\tEnumerationConstant:\n//\t        IDENTIFIER\ntype EnumerationConstant struct {\n\tToken xc.Token\n}\n\nfunc (n *EnumerationConstant) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *EnumerationConstant) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumerationConstant) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// Enumerator represents data reduced by productions:\n//\n//\tEnumerator:\n//\t        EnumerationConstant\n//\t|       EnumerationConstant '=' ConstantExpression  // Case 1\ntype Enumerator struct {\n\tValue               interface{} // Enumerator's value.\n\tCase                int\n\tConstantExpression  *ConstantExpression\n\tEnumerationConstant *EnumerationConstant\n\tToken               xc.Token\n}\n\nfunc (n *Enumerator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Enumerator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Enumerator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.EnumerationConstant.Pos()\n}\n\n// EnumeratorList represents data reduced by productions:\n//\n//\tEnumeratorList:\n//\t        Enumerator\n//\t|       EnumeratorList ',' Enumerator  // Case 1\ntype EnumeratorList struct {\n\tCase           int\n\tEnumerator     *Enumerator\n\tEnumeratorList *EnumeratorList\n\tToken          xc.Token\n}\n\nfunc (n *EnumeratorList) reverse() *EnumeratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.EnumeratorList\n\tfor nb != nil {\n\t\tnc := nb.EnumeratorList\n\t\tnb.EnumeratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.EnumeratorList = nil\n\treturn na\n}\n\nfunc (n *EnumeratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *EnumeratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumeratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Enumerator.Pos()\n\tcase 1:\n\t\treturn n.EnumeratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// Expression represents data reduced by productions:\n//\n//\tExpression:\n//\t        IDENTIFIER\n//\t|       CHARCONST                                          // Case 1\n//\t|       FLOATCONST                                         // Case 2\n//\t|       INTCONST                                           // Case 3\n//\t|       LONGCHARCONST                                      // Case 4\n//\t|       LONGSTRINGLITERAL                                  // Case 5\n//\t|       STRINGLITERAL                                      // Case 6\n//\t|       '(' ExpressionList ')'                             // Case 7\n//\t|       Expression '[' ExpressionList ']'                  // Case 8\n//\t|       Expression '(' ArgumentExpressionListOpt ')'       // Case 9\n//\t|       Expression '.' IDENTIFIER                          // Case 10\n//\t|       Expression \"->\" IDENTIFIER                         // Case 11\n//\t|       Expression \"++\"                                    // Case 12\n//\t|       Expression \"--\"                                    // Case 13\n//\t|       '(' TypeName ')' '{' InitializerList CommaOpt '}'  // Case 14\n//\t|       \"++\" Expression                                    // Case 15\n//\t|       \"--\" Expression                                    // Case 16\n//\t|       '&' Expression                                     // Case 17\n//\t|       '*' Expression                                     // Case 18\n//\t|       '+' Expression                                     // Case 19\n//\t|       '-' Expression                                     // Case 20\n//\t|       '~' Expression                                     // Case 21\n//\t|       '!' Expression                                     // Case 22\n//\t|       \"sizeof\" Expression                                // Case 23\n//\t|       \"sizeof\" '(' TypeName ')'                          // Case 24\n//\t|       '(' TypeName ')' Expression                        // Case 25\n//\t|       Expression '*' Expression                          // Case 26\n//\t|       Expression '/' Expression                          // Case 27\n//\t|       Expression '%' Expression                          // Case 28\n//\t|       Expression '+' Expression                          // Case 29\n//\t|       Expression '-' Expression                          // Case 30\n//\t|       Expression \"<<\" Expression                         // Case 31\n//\t|       Expression \">>\" Expression                         // Case 32\n//\t|       Expression '<' Expression                          // Case 33\n//\t|       Expression '>' Expression                          // Case 34\n//\t|       Expression \"<=\" Expression                         // Case 35\n//\t|       Expression \">=\" Expression                         // Case 36\n//\t|       Expression \"==\" Expression                         // Case 37\n//\t|       Expression \"!=\" Expression                         // Case 38\n//\t|       Expression '&' Expression                          // Case 39\n//\t|       Expression '^' Expression                          // Case 40\n//\t|       Expression '|' Expression                          // Case 41\n//\t|       Expression \"&&\" Expression                         // Case 42\n//\t|       Expression \"||\" Expression                         // Case 43\n//\t|       Expression '?' ExpressionList ':' Expression       // Case 44\n//\t|       Expression '=' Expression                          // Case 45\n//\t|       Expression \"*=\" Expression                         // Case 46\n//\t|       Expression \"/=\" Expression                         // Case 47\n//\t|       Expression \"%=\" Expression                         // Case 48\n//\t|       Expression \"+=\" Expression                         // Case 49\n//\t|       Expression \"-=\" Expression                         // Case 50\n//\t|       Expression \"<<=\" Expression                        // Case 51\n//\t|       Expression \">>=\" Expression                        // Case 52\n//\t|       Expression \"&=\" Expression                         // Case 53\n//\t|       Expression \"^=\" Expression                         // Case 54\n//\t|       Expression \"|=\" Expression                         // Case 55\n//\t|       \"_Alignof\" '(' TypeName ')'                        // Case 56\n//\t|       '(' CompoundStatement ')'                          // Case 57\n//\t|       \"&&\" IDENTIFIER                                    // Case 58\n//\t|       Expression '?' ':' Expression                      // Case 59\ntype Expression struct {\n\tBinOpType                 Type        // The type operands of binary expression are coerced into, if different from Type.\n\tType                      Type        // Type of expression.\n\tValue                     interface{} // Non nil for certain constant expressions.\n\tscope                     *Bindings   // Case 0: IDENTIFIER resolution scope.\n\tArgumentExpressionListOpt *ArgumentExpressionListOpt\n\tCase                      int\n\tCommaOpt                  *CommaOpt\n\tCompoundStatement         *CompoundStatement\n\tExpression                *Expression\n\tExpression2               *Expression\n\tExpressionList            *ExpressionList\n\tInitializerList           *InitializerList\n\tToken                     xc.Token\n\tToken2                    xc.Token\n\tToken3                    xc.Token\n\tToken4                    xc.Token\n\tTypeName                  *TypeName\n}\n\nfunc (n *Expression) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Expression) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Expression) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 8, 9, 10, 11, 12, 13, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 59:\n\t\treturn n.Expression.Pos()\n\tcase 0, 1, 2, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 56, 57, 58:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExpressionList represents data reduced by productions:\n//\n//\tExpressionList:\n//\t        Expression\n//\t|       ExpressionList ',' Expression  // Case 1\ntype ExpressionList struct {\n\tType           Type        // Type of expression.\n\tValue          interface{} // Non nil for certain constant expressions.\n\tCase           int\n\tExpression     *Expression\n\tExpressionList *ExpressionList\n\tToken          xc.Token\n}\n\nfunc (n *ExpressionList) reverse() *ExpressionList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ExpressionList\n\tfor nb != nil {\n\t\tnc := nb.ExpressionList\n\t\tnb.ExpressionList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ExpressionList = nil\n\treturn na\n}\n\nfunc (n *ExpressionList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ExpressionList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExpressionList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Expression.Pos()\n\tcase 1:\n\t\treturn n.ExpressionList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExpressionListOpt represents data reduced by productions:\n//\n//\tExpressionListOpt:\n//\t        /* empty */\n//\t|       ExpressionList  // Case 1\ntype ExpressionListOpt struct {\n\tExpressionList *ExpressionList\n}\n\nfunc (n *ExpressionListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExpressionListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExpressionListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ExpressionList.Pos()\n}\n\n// ExpressionOpt represents data reduced by productions:\n//\n//\tExpressionOpt:\n//\t        /* empty */\n//\t|       Expression   // Case 1\ntype ExpressionOpt struct {\n\tExpression *Expression\n}\n\nfunc (n *ExpressionOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExpressionOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExpressionOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Expression.Pos()\n}\n\n// ExpressionStatement represents data reduced by production:\n//\n//\tExpressionStatement:\n//\t        ExpressionListOpt ';'\ntype ExpressionStatement struct {\n\tExpressionListOpt *ExpressionListOpt\n\tToken             xc.Token\n}\n\nfunc (n *ExpressionStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExpressionStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExpressionStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tif p := n.ExpressionListOpt.Pos(); p != 0 {\n\t\treturn p\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ExternalDeclaration represents data reduced by productions:\n//\n//\tExternalDeclaration:\n//\t        FunctionDefinition\n//\t|       Declaration                  // Case 1\n//\t|       BasicAssemblerStatement ';'  // Case 2\n//\t|       ';'                          // Case 3\ntype ExternalDeclaration struct {\n\tBasicAssemblerStatement *BasicAssemblerStatement\n\tCase                    int\n\tDeclaration             *Declaration\n\tFunctionDefinition      *FunctionDefinition\n\tToken                   xc.Token\n}\n\nfunc (n *ExternalDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExternalDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExternalDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 2:\n\t\treturn n.BasicAssemblerStatement.Pos()\n\tcase 1:\n\t\treturn n.Declaration.Pos()\n\tcase 0:\n\t\treturn n.FunctionDefinition.Pos()\n\tcase 3:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// FunctionBody represents data reduced by productions:\n//\n//\tFunctionBody:\n//\t        CompoundStatement\n//\t|       AssemblerStatement ';'  // Case 1\ntype FunctionBody struct {\n\tscope              *Bindings // Scope of the FunctionBody.\n\tAssemblerStatement *AssemblerStatement\n\tCase               int\n\tCompoundStatement  *CompoundStatement\n\tToken              xc.Token\n}\n\nfunc (n *FunctionBody) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionBody) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionBody) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.AssemblerStatement.Pos()\n\tcase 0:\n\t\treturn n.CompoundStatement.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// FunctionDefinition represents data reduced by productions:\n//\n//\tFunctionDefinition:\n//\t        DeclarationSpecifiers Declarator DeclarationListOpt FunctionBody\n//\t|       Declarator DeclarationListOpt FunctionBody                        // Case 1\ntype FunctionDefinition struct {\n\tCase                  int\n\tDeclarationListOpt    *DeclarationListOpt\n\tDeclarationSpecifiers *DeclarationSpecifiers\n\tDeclarator            *Declarator\n\tFunctionBody          *FunctionBody\n}\n\nfunc (n *FunctionDefinition) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionDefinition) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionDefinition) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.DeclarationSpecifiers.Pos()\n\tcase 1:\n\t\treturn n.Declarator.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// FunctionSpecifier represents data reduced by productions:\n//\n//\tFunctionSpecifier:\n//\t        \"inline\"\n//\t|       \"_Noreturn\"  // Case 1\ntype FunctionSpecifier struct {\n\tattr  int // tsInline, tsTypedefName, ...\n\tCase  int\n\tToken xc.Token\n}\n\nfunc (n *FunctionSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// GroupList represents data reduced by productions:\n//\n//\tGroupList:\n//\t        GroupPart\n//\t|       GroupList GroupPart  // Case 1\ntype GroupList struct {\n\tCase      int\n\tGroupList *GroupList\n\tGroupPart Node\n}\n\nfunc (n *GroupList) reverse() *GroupList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.GroupList\n\tfor nb != nil {\n\t\tnc := nb.GroupList\n\t\tnb.GroupList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.GroupList = nil\n\treturn na\n}\n\nfunc (n *GroupList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *GroupList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *GroupList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.GroupList.Pos()\n\tcase 0:\n\t\treturn n.GroupPart.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// GroupListOpt represents data reduced by productions:\n//\n//\tGroupListOpt:\n//\t        /* empty */\n//\t|       GroupList    // Case 1\ntype GroupListOpt struct {\n\tGroupList *GroupList\n}\n\nfunc (n *GroupListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *GroupListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *GroupListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.GroupList.Pos()\n}\n\n// IdentifierList represents data reduced by productions:\n//\n//\tIdentifierList:\n//\t        IDENTIFIER\n//\t|       IdentifierList ',' IDENTIFIER  // Case 1\ntype IdentifierList struct {\n\tCase           int\n\tIdentifierList *IdentifierList\n\tToken          xc.Token\n\tToken2         xc.Token\n}\n\nfunc (n *IdentifierList) reverse() *IdentifierList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.IdentifierList\n\tfor nb != nil {\n\t\tnc := nb.IdentifierList\n\t\tnb.IdentifierList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.IdentifierList = nil\n\treturn na\n}\n\nfunc (n *IdentifierList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.IdentifierList.Pos()\n\tcase 0:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// IdentifierListOpt represents data reduced by productions:\n//\n//\tIdentifierListOpt:\n//\t        /* empty */\n//\t|       IdentifierList  // Case 1\ntype IdentifierListOpt struct {\n\tparams         []Parameter\n\tIdentifierList *IdentifierList\n}\n\nfunc (n *IdentifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.IdentifierList.Pos()\n}\n\n// IdentifierOpt represents data reduced by productions:\n//\n//\tIdentifierOpt:\n//\t        /* empty */\n//\t|       IDENTIFIER   // Case 1\ntype IdentifierOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *IdentifierOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// IfGroup represents data reduced by productions:\n//\n//\tIfGroup:\n//\t        PPIF PPTokenList '\\n' GroupListOpt\n//\t|       PPIFDEF IDENTIFIER '\\n' GroupListOpt   // Case 1\n//\t|       PPIFNDEF IDENTIFIER '\\n' GroupListOpt  // Case 2\ntype IfGroup struct {\n\tCase         int\n\tGroupListOpt *GroupListOpt\n\tPPTokenList  PPTokenList\n\tToken        xc.Token\n\tToken2       xc.Token\n\tToken3       xc.Token\n}\n\nfunc (n *IfGroup) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IfGroup) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IfGroup) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// IfSection represents data reduced by production:\n//\n//\tIfSection:\n//\t        IfGroup ElifGroupListOpt ElseGroupOpt EndifLine\ntype IfSection struct {\n\tElifGroupListOpt *ElifGroupListOpt\n\tElseGroupOpt     *ElseGroupOpt\n\tEndifLine        *EndifLine\n\tIfGroup          *IfGroup\n}\n\nfunc (n *IfSection) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IfSection) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IfSection) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.IfGroup.Pos()\n}\n\n// InitDeclarator represents data reduced by productions:\n//\n//\tInitDeclarator:\n//\t        Declarator\n//\t|       Declarator '=' Initializer  // Case 1\ntype InitDeclarator struct {\n\tCase        int\n\tDeclarator  *Declarator\n\tInitializer *Initializer\n\tToken       xc.Token\n}\n\nfunc (n *InitDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Declarator.Pos()\n}\n\n// InitDeclaratorList represents data reduced by productions:\n//\n//\tInitDeclaratorList:\n//\t        InitDeclarator\n//\t|       InitDeclaratorList ',' InitDeclarator  // Case 1\ntype InitDeclaratorList struct {\n\tCase               int\n\tInitDeclarator     *InitDeclarator\n\tInitDeclaratorList *InitDeclaratorList\n\tToken              xc.Token\n}\n\nfunc (n *InitDeclaratorList) reverse() *InitDeclaratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.InitDeclaratorList\n\tfor nb != nil {\n\t\tnc := nb.InitDeclaratorList\n\t\tnb.InitDeclaratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.InitDeclaratorList = nil\n\treturn na\n}\n\nfunc (n *InitDeclaratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclaratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclaratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.InitDeclarator.Pos()\n\tcase 1:\n\t\treturn n.InitDeclaratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// InitDeclaratorListOpt represents data reduced by productions:\n//\n//\tInitDeclaratorListOpt:\n//\t        /* empty */\n//\t|       InitDeclaratorList  // Case 1\ntype InitDeclaratorListOpt struct {\n\tInitDeclaratorList *InitDeclaratorList\n}\n\nfunc (n *InitDeclaratorListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclaratorListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclaratorListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.InitDeclaratorList.Pos()\n}\n\n// Initializer represents data reduced by productions:\n//\n//\tInitializer:\n//\t        Expression\n//\t|       '{' InitializerList CommaOpt '}'  // Case 1\n//\t|       IDENTIFIER ':' Initializer        // Case 2\ntype Initializer struct {\n\tCase            int\n\tCommaOpt        *CommaOpt\n\tExpression      *Expression\n\tInitializer     *Initializer\n\tInitializerList *InitializerList\n\tToken           xc.Token\n\tToken2          xc.Token\n}\n\nfunc (n *Initializer) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Initializer) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Initializer) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Expression.Pos()\n\tcase 1, 2:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// InitializerList represents data reduced by productions:\n//\n//\tInitializerList:\n//\t        DesignationOpt Initializer\n//\t|       InitializerList ',' DesignationOpt Initializer  // Case 1\n//\t|       /* empty */                                     // Case 2\ntype InitializerList struct {\n\tCase            int\n\tDesignationOpt  *DesignationOpt\n\tInitializer     *Initializer\n\tInitializerList *InitializerList\n\tToken           xc.Token\n}\n\nfunc (n *InitializerList) reverse() *InitializerList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.InitializerList\n\tfor nb != nil {\n\t\tnc := nb.InitializerList\n\t\tnb.InitializerList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.InitializerList = nil\n\treturn na\n}\n\nfunc (n *InitializerList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *InitializerList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitializerList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 2:\n\t\treturn 0\n\tcase 0:\n\t\tif p := n.DesignationOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Initializer.Pos()\n\tcase 1:\n\t\tif p := n.InitializerList.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// IterationStatement represents data reduced by productions:\n//\n//\tIterationStatement:\n//\t        \"while\" '(' ExpressionList ')' Statement\n//\t|       \"do\" Statement \"while\" '(' ExpressionList ')' ';'                                      // Case 1\n//\t|       \"for\" '(' ExpressionListOpt ';' ExpressionListOpt ';' ExpressionListOpt ')' Statement  // Case 2\n//\t|       \"for\" '(' Declaration ExpressionListOpt ';' ExpressionListOpt ')' Statement            // Case 3\ntype IterationStatement struct {\n\tCase               int\n\tDeclaration        *Declaration\n\tExpressionList     *ExpressionList\n\tExpressionListOpt  *ExpressionListOpt\n\tExpressionListOpt2 *ExpressionListOpt\n\tExpressionListOpt3 *ExpressionListOpt\n\tStatement          *Statement\n\tToken              xc.Token\n\tToken2             xc.Token\n\tToken3             xc.Token\n\tToken4             xc.Token\n\tToken5             xc.Token\n}\n\nfunc (n *IterationStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IterationStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IterationStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// JumpStatement represents data reduced by productions:\n//\n//\tJumpStatement:\n//\t        \"goto\" IDENTIFIER ';'\n//\t|       \"continue\" ';'                  // Case 1\n//\t|       \"break\" ';'                     // Case 2\n//\t|       \"return\" ExpressionListOpt ';'  // Case 3\n//\t|       \"goto\" Expression ';'           // Case 4\ntype JumpStatement struct {\n\tCase              int\n\tExpression        *Expression\n\tExpressionListOpt *ExpressionListOpt\n\tToken             xc.Token\n\tToken2            xc.Token\n\tToken3            xc.Token\n}\n\nfunc (n *JumpStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *JumpStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *JumpStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// LabeledStatement represents data reduced by productions:\n//\n//\tLabeledStatement:\n//\t        IDENTIFIER ':' Statement\n//\t|       \"case\" ConstantExpression ':' Statement  // Case 1\n//\t|       \"default\" ':' Statement                  // Case 2\ntype LabeledStatement struct {\n\tCase               int\n\tConstantExpression *ConstantExpression\n\tStatement          *Statement\n\tToken              xc.Token\n\tToken2             xc.Token\n}\n\nfunc (n *LabeledStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *LabeledStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *LabeledStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ParameterDeclaration represents data reduced by productions:\n//\n//\tParameterDeclaration:\n//\t        DeclarationSpecifiers Declarator\n//\t|       DeclarationSpecifiers AbstractDeclaratorOpt  // Case 1\ntype ParameterDeclaration struct {\n\tdeclarator            *Declarator\n\tAbstractDeclaratorOpt *AbstractDeclaratorOpt\n\tCase                  int\n\tDeclarationSpecifiers *DeclarationSpecifiers\n\tDeclarator            *Declarator\n}\n\nfunc (n *ParameterDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationSpecifiers.Pos()\n}\n\n// ParameterList represents data reduced by productions:\n//\n//\tParameterList:\n//\t        ParameterDeclaration\n//\t|       ParameterList ',' ParameterDeclaration  // Case 1\ntype ParameterList struct {\n\tCase                 int\n\tParameterDeclaration *ParameterDeclaration\n\tParameterList        *ParameterList\n\tToken                xc.Token\n}\n\nfunc (n *ParameterList) reverse() *ParameterList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ParameterList\n\tfor nb != nil {\n\t\tnc := nb.ParameterList\n\t\tnb.ParameterList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ParameterList = nil\n\treturn na\n}\n\nfunc (n *ParameterList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.ParameterDeclaration.Pos()\n\tcase 1:\n\t\treturn n.ParameterList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ParameterTypeList represents data reduced by productions:\n//\n//\tParameterTypeList:\n//\t        ParameterList\n//\t|       ParameterList ',' \"...\"  // Case 1\ntype ParameterTypeList struct {\n\tparams        []Parameter\n\tCase          int\n\tParameterList *ParameterList\n\tToken         xc.Token\n\tToken2        xc.Token\n}\n\nfunc (n *ParameterTypeList) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterTypeList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterTypeList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ParameterList.Pos()\n}\n\n// ParameterTypeListOpt represents data reduced by productions:\n//\n//\tParameterTypeListOpt:\n//\t        /* empty */\n//\t|       ParameterTypeList  // Case 1\ntype ParameterTypeListOpt struct {\n\tParameterTypeList *ParameterTypeList\n}\n\nfunc (n *ParameterTypeListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterTypeListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterTypeListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ParameterTypeList.Pos()\n}\n\n// Pointer represents data reduced by productions:\n//\n//\tPointer:\n//\t        '*' TypeQualifierListOpt\n//\t|       '*' TypeQualifierListOpt Pointer  // Case 1\ntype Pointer struct {\n\tCase                 int\n\tPointer              *Pointer\n\tToken                xc.Token\n\tTypeQualifierListOpt *TypeQualifierListOpt\n}\n\nfunc (n *Pointer) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Pointer) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Pointer) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// PointerOpt represents data reduced by productions:\n//\n//\tPointerOpt:\n//\t        /* empty */\n//\t|       Pointer      // Case 1\ntype PointerOpt struct {\n\tPointer *Pointer\n}\n\nfunc (n *PointerOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *PointerOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *PointerOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Pointer.Pos()\n}\n\n// PreprocessingFile represents data reduced by production:\n//\n//\tPreprocessingFile:\n//\t        GroupList\ntype PreprocessingFile struct {\n\tpath      string\n\tGroupList *GroupList\n}\n\nfunc (n *PreprocessingFile) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *PreprocessingFile) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *PreprocessingFile) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.GroupList.Pos()\n}\n\n// SelectionStatement represents data reduced by productions:\n//\n//\tSelectionStatement:\n//\t        \"if\" '(' ExpressionList ')' Statement\n//\t|       \"if\" '(' ExpressionList ')' Statement \"else\" Statement  // Case 1\n//\t|       \"switch\" '(' ExpressionList ')' Statement               // Case 2\ntype SelectionStatement struct {\n\tCase           int\n\tExpressionList *ExpressionList\n\tStatement      *Statement\n\tStatement2     *Statement\n\tToken          xc.Token\n\tToken2         xc.Token\n\tToken3         xc.Token\n\tToken4         xc.Token\n}\n\nfunc (n *SelectionStatement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SelectionStatement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SelectionStatement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// SpecifierQualifierList represents data reduced by productions:\n//\n//\tSpecifierQualifierList:\n//\t        TypeSpecifier SpecifierQualifierListOpt\n//\t|       TypeQualifier SpecifierQualifierListOpt  // Case 1\ntype SpecifierQualifierList struct {\n\tattr                      int // tsInline, tsTypedefName, ...\n\ttypeSpecifier             int // Encoded combination of tsVoid, tsInt, ...\n\tCase                      int\n\tSpecifierQualifierListOpt *SpecifierQualifierListOpt\n\tTypeQualifier             *TypeQualifier\n\tTypeSpecifier             *TypeSpecifier\n}\n\nfunc (n *SpecifierQualifierList) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SpecifierQualifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SpecifierQualifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 0:\n\t\treturn n.TypeSpecifier.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// SpecifierQualifierListOpt represents data reduced by productions:\n//\n//\tSpecifierQualifierListOpt:\n//\t        /* empty */\n//\t|       SpecifierQualifierList  // Case 1\ntype SpecifierQualifierListOpt struct {\n\tattr                   int // tsInline, tsTypedefName, ...\n\ttypeSpecifier          int // Encoded combination of tsVoid, tsInt, ...\n\tSpecifierQualifierList *SpecifierQualifierList\n}\n\nfunc (n *SpecifierQualifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SpecifierQualifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SpecifierQualifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.SpecifierQualifierList.Pos()\n}\n\n// Statement represents data reduced by productions:\n//\n//\tStatement:\n//\t        LabeledStatement\n//\t|       CompoundStatement    // Case 1\n//\t|       ExpressionStatement  // Case 2\n//\t|       SelectionStatement   // Case 3\n//\t|       IterationStatement   // Case 4\n//\t|       JumpStatement        // Case 5\n//\t|       AssemblerStatement   // Case 6\ntype Statement struct {\n\tAssemblerStatement  *AssemblerStatement\n\tCase                int\n\tCompoundStatement   *CompoundStatement\n\tExpressionStatement *ExpressionStatement\n\tIterationStatement  *IterationStatement\n\tJumpStatement       *JumpStatement\n\tLabeledStatement    *LabeledStatement\n\tSelectionStatement  *SelectionStatement\n}\n\nfunc (n *Statement) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Statement) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Statement) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 6:\n\t\treturn n.AssemblerStatement.Pos()\n\tcase 1:\n\t\treturn n.CompoundStatement.Pos()\n\tcase 2:\n\t\treturn n.ExpressionStatement.Pos()\n\tcase 4:\n\t\treturn n.IterationStatement.Pos()\n\tcase 5:\n\t\treturn n.JumpStatement.Pos()\n\tcase 0:\n\t\treturn n.LabeledStatement.Pos()\n\tcase 3:\n\t\treturn n.SelectionStatement.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StaticAssertDeclaration represents data reduced by production:\n//\n//\tStaticAssertDeclaration:\n//\t        \"_Static_assert\" '(' ConstantExpression ',' STRINGLITERAL ')' ';'\ntype StaticAssertDeclaration struct {\n\tConstantExpression *ConstantExpression\n\tToken              xc.Token\n\tToken2             xc.Token\n\tToken3             xc.Token\n\tToken4             xc.Token\n\tToken5             xc.Token\n\tToken6             xc.Token\n}\n\nfunc (n *StaticAssertDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StaticAssertDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StaticAssertDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// StorageClassSpecifier represents data reduced by productions:\n//\n//\tStorageClassSpecifier:\n//\t        \"typedef\"\n//\t|       \"extern\"    // Case 1\n//\t|       \"static\"    // Case 2\n//\t|       \"auto\"      // Case 3\n//\t|       \"register\"  // Case 4\ntype StorageClassSpecifier struct {\n\tattr  int\n\tCase  int\n\tToken xc.Token\n}\n\nfunc (n *StorageClassSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StorageClassSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StorageClassSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// StructDeclaration represents data reduced by productions:\n//\n//\tStructDeclaration:\n//\t        SpecifierQualifierList StructDeclaratorList ';'\n//\t|       SpecifierQualifierList ';'                       // Case 1\n//\t|       StaticAssertDeclaration                          // Case 2\ntype StructDeclaration struct {\n\tCase                    int\n\tSpecifierQualifierList  *SpecifierQualifierList\n\tStaticAssertDeclaration *StaticAssertDeclaration\n\tStructDeclaratorList    *StructDeclaratorList\n\tToken                   xc.Token\n}\n\nfunc (n *StructDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0, 1:\n\t\treturn n.SpecifierQualifierList.Pos()\n\tcase 2:\n\t\treturn n.StaticAssertDeclaration.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructDeclarationList represents data reduced by productions:\n//\n//\tStructDeclarationList:\n//\t        StructDeclaration\n//\t|       StructDeclarationList StructDeclaration  // Case 1\ntype StructDeclarationList struct {\n\tCase                  int\n\tStructDeclaration     *StructDeclaration\n\tStructDeclarationList *StructDeclarationList\n}\n\nfunc (n *StructDeclarationList) reverse() *StructDeclarationList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.StructDeclarationList\n\tfor nb != nil {\n\t\tnc := nb.StructDeclarationList\n\t\tnb.StructDeclarationList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.StructDeclarationList = nil\n\treturn na\n}\n\nfunc (n *StructDeclarationList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclarationList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclarationList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.StructDeclaration.Pos()\n\tcase 1:\n\t\treturn n.StructDeclarationList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructDeclarator represents data reduced by productions:\n//\n//\tStructDeclarator:\n//\t        Declarator\n//\t|       DeclaratorOpt ':' ConstantExpression  // Case 1\ntype StructDeclarator struct {\n\tCase               int\n\tConstantExpression *ConstantExpression\n\tDeclarator         *Declarator\n\tDeclaratorOpt      *DeclaratorOpt\n\tToken              xc.Token\n}\n\nfunc (n *StructDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declarator.Pos()\n\tcase 1:\n\t\tif p := n.DeclaratorOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructDeclaratorList represents data reduced by productions:\n//\n//\tStructDeclaratorList:\n//\t        StructDeclarator\n//\t|       StructDeclaratorList ',' StructDeclarator  // Case 1\ntype StructDeclaratorList struct {\n\tCase                 int\n\tStructDeclarator     *StructDeclarator\n\tStructDeclaratorList *StructDeclaratorList\n\tToken                xc.Token\n}\n\nfunc (n *StructDeclaratorList) reverse() *StructDeclaratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.StructDeclaratorList\n\tfor nb != nil {\n\t\tnc := nb.StructDeclaratorList\n\t\tnb.StructDeclaratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.StructDeclaratorList = nil\n\treturn na\n}\n\nfunc (n *StructDeclaratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclaratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclaratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.StructDeclarator.Pos()\n\tcase 1:\n\t\treturn n.StructDeclaratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructOrUnion represents data reduced by productions:\n//\n//\tStructOrUnion:\n//\t        \"struct\"\n//\t|       \"union\"   // Case 1\ntype StructOrUnion struct {\n\tCase  int\n\tToken xc.Token\n}\n\nfunc (n *StructOrUnion) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructOrUnion) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructOrUnion) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// StructOrUnionSpecifier represents data reduced by productions:\n//\n//\tStructOrUnionSpecifier:\n//\t        StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n//\t|       StructOrUnion IDENTIFIER                                   // Case 1\n//\t|       StructOrUnion IdentifierOpt '{' '}'                        // Case 2\ntype StructOrUnionSpecifier struct {\n\talignOf               int\n\tdeclarator            *Declarator // Synthetic declarator when tagged struct/union defined inline.\n\tscope                 *Bindings\n\tsizeOf                int\n\tCase                  int\n\tIdentifierOpt         *IdentifierOpt\n\tStructDeclarationList *StructDeclarationList\n\tStructOrUnion         *StructOrUnion\n\tToken                 xc.Token\n\tToken2                xc.Token\n}\n\nfunc (n *StructOrUnionSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructOrUnionSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructOrUnionSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.StructOrUnion.Pos()\n}\n\n// TranslationUnit represents data reduced by productions:\n//\n//\tTranslationUnit:\n//\t        ExternalDeclaration\n//\t|       TranslationUnit ExternalDeclaration  // Case 1\ntype TranslationUnit struct {\n\tComments            map[token.Pos]int // Position -> comment ID. Enable using the KeepComments option.\n\tDeclarations        *Bindings\n\tMacros              map[int]*Macro // Ident ID -> preprocessor macro defined by ident.\n\tModel               *Model         // Model used to parse the TranslationUnit.\n\tCase                int\n\tExternalDeclaration *ExternalDeclaration\n\tTranslationUnit     *TranslationUnit\n}\n\nfunc (n *TranslationUnit) reverse() *TranslationUnit {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.TranslationUnit\n\tfor nb != nil {\n\t\tnc := nb.TranslationUnit\n\t\tnb.TranslationUnit = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.TranslationUnit = nil\n\treturn na\n}\n\nfunc (n *TranslationUnit) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *TranslationUnit) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TranslationUnit) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.ExternalDeclaration.Pos()\n\tcase 1:\n\t\treturn n.TranslationUnit.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// TypeName represents data reduced by production:\n//\n//\tTypeName:\n//\t        SpecifierQualifierList AbstractDeclaratorOpt\ntype TypeName struct {\n\tType                   Type\n\tdeclarator             *Declarator\n\tscope                  *Bindings\n\tAbstractDeclaratorOpt  *AbstractDeclaratorOpt\n\tSpecifierQualifierList *SpecifierQualifierList\n}\n\nfunc (n *TypeName) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeName) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeName) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.SpecifierQualifierList.Pos()\n}\n\n// TypeQualifier represents data reduced by productions:\n//\n//\tTypeQualifier:\n//\t        \"const\"\n//\t|       \"restrict\"  // Case 1\n//\t|       \"volatile\"  // Case 2\ntype TypeQualifier struct {\n\tattr  int // tsInline, tsTypedefName, ...\n\tCase  int\n\tToken xc.Token\n}\n\nfunc (n *TypeQualifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// TypeQualifierList represents data reduced by productions:\n//\n//\tTypeQualifierList:\n//\t        TypeQualifier\n//\t|       TypeQualifierList TypeQualifier  // Case 1\ntype TypeQualifierList struct {\n\tattr              int // tsInline, tsTypedefName, ...\n\tCase              int\n\tTypeQualifier     *TypeQualifier\n\tTypeQualifierList *TypeQualifierList\n}\n\nfunc (n *TypeQualifierList) reverse() *TypeQualifierList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.TypeQualifierList\n\tfor nb != nil {\n\t\tnc := nb.TypeQualifierList\n\t\tnb.TypeQualifierList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.TypeQualifierList = nil\n\treturn na\n}\n\nfunc (n *TypeQualifierList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 1:\n\t\treturn n.TypeQualifierList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// TypeQualifierListOpt represents data reduced by productions:\n//\n//\tTypeQualifierListOpt:\n//\t        /* empty */\n//\t|       TypeQualifierList  // Case 1\ntype TypeQualifierListOpt struct {\n\tTypeQualifierList *TypeQualifierList\n}\n\nfunc (n *TypeQualifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.TypeQualifierList.Pos()\n}\n\n// TypeSpecifier represents data reduced by productions:\n//\n//\tTypeSpecifier:\n//\t        \"void\"\n//\t|       \"char\"                       // Case 1\n//\t|       \"short\"                      // Case 2\n//\t|       \"int\"                        // Case 3\n//\t|       \"long\"                       // Case 4\n//\t|       \"float\"                      // Case 5\n//\t|       \"double\"                     // Case 6\n//\t|       \"signed\"                     // Case 7\n//\t|       \"unsigned\"                   // Case 8\n//\t|       \"_Bool\"                      // Case 9\n//\t|       \"_Complex\"                   // Case 10\n//\t|       StructOrUnionSpecifier       // Case 11\n//\t|       EnumSpecifier                // Case 12\n//\t|       TYPEDEFNAME                  // Case 13\n//\t|       \"typeof\" '(' Expression ')'  // Case 14\n//\t|       \"typeof\" '(' TypeName ')'    // Case 15\ntype TypeSpecifier struct {\n\tscope                  *Bindings // If case TYPEDEFNAME.\n\ttypeSpecifier          int       // Encoded combination of tsVoid, tsInt, ...\n\tType                   Type      // Type of typeof.\n\tCase                   int\n\tEnumSpecifier          *EnumSpecifier\n\tExpression             *Expression\n\tStructOrUnionSpecifier *StructOrUnionSpecifier\n\tToken                  xc.Token\n\tToken2                 xc.Token\n\tToken3                 xc.Token\n\tTypeName               *TypeName\n}\n\nfunc (n *TypeSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 12:\n\t\treturn n.EnumSpecifier.Pos()\n\tcase 11:\n\t\treturn n.StructOrUnionSpecifier.Pos()\n\tcase 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// VolatileOpt represents data reduced by productions:\n//\n//\tVolatileOpt:\n//\t        /* empty */\n//\t|       \"volatile\"   // Case 1\ntype VolatileOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *VolatileOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *VolatileOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *VolatileOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n"
  },
  {
    "path": "ast2.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\t\"go/token\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\ntype operand interface {\n\teval(*lexer) (value interface{}, typ Type)\n\tNode\n}\n\n// Node represents an AST node.\ntype Node interface {\n\tPos() token.Pos\n}\n\n// ---------------------------------------------------------- CompoundStatement\n\n// Scope returns n's scope.\nfunc (n *CompoundStatement) Scope() *Bindings { return n.scope }\n\n// ---------------------------------------------------------------- Declaration\n\n// Declarator returns a synthetic Declarator when n.InitDeclaratorListOpt is\n// nil.\nfunc (n *Declaration) Declarator() *Declarator { return n.declarator }\n\n// ------------------------------------------------------ DeclarationSpecifiers\n\n// IsInline implements specifier.\nfunc (n *DeclarationSpecifiers) IsInline() bool {\n\treturn n.attr&saInline != 0\n}\n\n// IsTypedef implements specifier.\nfunc (n *DeclarationSpecifiers) IsTypedef() bool {\n\treturn n.attr&saTypedef != 0\n}\n\n// IsExtern implements specifier.\nfunc (n *DeclarationSpecifiers) IsExtern() bool {\n\treturn n.attr&saExtern != 0\n}\n\n// IsStatic implements specifier.\nfunc (n *DeclarationSpecifiers) IsStatic() bool {\n\treturn n.attr&saStatic != 0\n}\n\n// IsAuto implements specifier.\nfunc (n *DeclarationSpecifiers) IsAuto() bool {\n\treturn n.attr&saAuto != 0\n}\n\n// IsRegister implements specifier.\nfunc (n *DeclarationSpecifiers) IsRegister() bool {\n\treturn n.attr&saRegister != 0\n}\n\n// IsConst returns whether n includes the 'const' type qualifier.\nfunc (n *DeclarationSpecifiers) IsConst() bool {\n\treturn n.attr&saConst != 0\n}\n\n// IsRestrict implements specifier.\nfunc (n *DeclarationSpecifiers) IsRestrict() bool {\n\treturn n.attr&saRestrict != 0\n}\n\n// IsVolatile implements specifier.\nfunc (n *DeclarationSpecifiers) IsVolatile() bool {\n\treturn n.attr&saVolatile != 0\n}\n\n// kind implements specifier.\nfunc (n *DeclarationSpecifiers) kind() Kind { return tsValid[n.typeSpecifiers()] }\n\n// typeSpecifiers implements specifier.\nfunc (n *DeclarationSpecifiers) typeSpecifiers() int {\n\treturn n.typeSpecifier\n}\n\n// firstTypeSpecifier implements specifier.\nfunc (n *DeclarationSpecifiers) firstTypeSpecifier() *TypeSpecifier {\n\tfor n.Case != 1 { // TypeSpecifier DeclarationSpecifiersOpt\n\t\to := n.DeclarationSpecifiersOpt\n\t\tif o == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tn = o.DeclarationSpecifiers\n\t}\n\treturn n.TypeSpecifier\n}\n\n// attrs implements specifier.\nfunc (n *DeclarationSpecifiers) attrs() int { return n.attr }\n\n// member implements specifier.\nfunc (n *DeclarationSpecifiers) member(nm int) (*Member, error) {\n\treturn n.firstTypeSpecifier().member(nm)\n}\n\n// str implements specifier.\nfunc (n *DeclarationSpecifiers) str() string {\n\treturn specifierString(n)\n}\n\n// TypedefName implements Specifier.\nfunc (n *DeclarationSpecifiers) TypedefName() int {\n\tif n.kind() == TypedefName {\n\t\treturn n.firstTypeSpecifier().Token.Val\n\t}\n\treturn 0\n}\n\n// ----------------------------------------------------------------- Declarator\n\n// Identifier returns the ID of the name declared by n and the scope the name\n// is declared in.\nfunc (n *Declarator) Identifier() (int, *Bindings) {\n\tdd := n.DirectDeclarator.bottom()\n\tif dd != nil {\n\t\treturn dd.Token.Val, dd.DeclarationScope()\n\t}\n\n\treturn 0, nil\n}\n\n// RawSpecifier returns the raw Specifier associated with n before expanding\n// typedefs. The effective Specifier is accessible via the Type field of n.\nfunc (n *Declarator) RawSpecifier() Specifier { return n.specifier }\n\nfunc (n *Declarator) clone() *Declarator {\n\tm := *n\n\treturn &m\n}\n\nfunc (n *Declarator) stars() int { return n.PointerOpt.stars() }\n\nfunc (n *Declarator) isCompatible(m *Declarator) (r bool) {\n\treturn n == m || n.Type.(*ctype).isCompatible(m.Type.(*ctype))\n}\n\nfunc (n *Declarator) unsigednEnum(lx *lexer, s Specifier) bool {\n\tswitch x := s.(type) {\n\tcase *DeclarationSpecifiers:\n\t\to := x.DeclarationSpecifiersOpt\n\t\tif o == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tswitch ds := o.DeclarationSpecifiers; ds.Case {\n\t\tcase 1: // TypeSpecifier DeclarationSpecifiersOpt          // Case 1\n\t\t\tswitch ts := ds.TypeSpecifier; ts.Case {\n\t\t\tcase 12: // EnumSpecifier                // Case 12\n\t\t\t\treturn ts.EnumSpecifier.isUnsigned(lx)\n\t\t\t}\n\t\t}\n\tcase *SpecifierQualifierList:\n\t\tts := x.TypeSpecifier\n\t\tif ts == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tswitch ts.Case {\n\t\tcase 12: // EnumSpecifier                // Case 12\n\t\t\treturn ts.EnumSpecifier.isUnsigned(lx)\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (n *Declarator) setFull(lx *lexer) Type {\n\td := n\n\tvar dds0, dds []*DirectDeclarator\n\tfor dd := d.DirectDeclarator; dd != nil; dd = dd.directDeclarator() {\n\t\tdds = append(dds, dd)\n\t}\n\tfor i, j := 0, len(dds)-1; i < j; i, j = i+1, j-1 { // reverse\n\t\tdds[i], dds[j] = dds[j], dds[i]\n\t}\n\n\tresultAttr := 0\n\tmask := 0\n\tif d.specifier != nil {\n\t\tif d.specifier.IsTypedef() {\n\t\t\tdds0 = append([]*DirectDeclarator(nil), dds...)\n\t\t}\n\t\tif d.specifier.typeSpecifiers() == 0 && lx.tweaks.enableImplicitIntType {\n\t\t\tswitch x := d.specifier.(type) {\n\t\t\tcase *DeclarationSpecifiers:\n\t\t\t\tx.typeSpecifier = tsEncode(tsInt)\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%s: TODO %T\", position(n.Pos()), x))\n\t\t\t}\n\t\t}\n\t}\nloop0:\n\tfor d.specifier != nil {\n\t\tswitch d.specifier.kind() {\n\t\tcase TypedefName:\n\t\t\tresultAttr |= d.specifier.attrs()\n\t\t\tts := d.specifier.firstTypeSpecifier()\n\t\t\tdd := ts.scope.Lookup(NSIdentifiers, ts.Token.Val).Node.(*DirectDeclarator) // eg. typedef T dd, (*dd), dd(int), ...\n\t\t\tif dd.Case != 0 {                                                           // IDENTIFIER\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\n\t\t\tnd := dd.top().declarator\n\t\t\tmask = saTypedef // nd.specifier.IsTypedef() == true\n\t\t\tdds2 := nd.Type.(*ctype).dds0\n\t\t\td2 := d.clone()\n\t\t\td2.specifier = nil\n\t\t\tdd2 := &DirectDeclarator{\n\t\t\t\tCase:       1, //  '(' Declarator ')'\n\t\t\t\tDeclarator: d2,\n\t\t\t}\n\t\t\tdds = append(dds, dd2)\n\t\t\tdds = append(dds, dds2[1:]...)\n\t\t\td = nd\n\t\tcase typeof:\n\t\t\tresultAttr |= d.specifier.attrs()\n\t\t\tts := d.specifier.firstTypeSpecifier()\n\t\t\tnd := ts.Type.Declarator()\n\t\t\tdds2 := ts.Type.(*ctype).dds0\n\t\t\td2 := d.clone()\n\t\t\td2.specifier = nil\n\t\t\tdd2 := &DirectDeclarator{\n\t\t\t\tCase:       1, //  '(' Declarator ')'\n\t\t\t\tDeclarator: d2,\n\t\t\t}\n\t\t\tdds = append(dds, dd2)\n\t\t\tdds = append(dds, dds2...)\n\t\t\td = nd\n\t\tdefault:\n\t\t\tbreak loop0\n\t\t}\n\t}\n\n\t// Inner ((...)) -> (...)\n\tfor {\n\t\tchanged := false\n\t\tw := 0\n\t\tfor r := 0; r < len(dds); {\n\t\t\tdd := dds[r]\n\t\t\tif r == len(dds)-1 || dd.Case != 1 { // '(' Declarator ')'\n\t\t\t\tdds[w] = dd\n\t\t\t\tw++\n\t\t\t\tr++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdd2 := dds[r+1]\n\t\t\tif dd2.Case != 1 {\n\t\t\t\tdds[w] = dd\n\t\t\t\tw++\n\t\t\t\tr++\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\td := dd.Declarator\n\t\t\td2 := dd2.Declarator\n\t\t\tswitch s, s2 := d.stars(), d2.stars(); {\n\t\t\tcase s == 0 && s2 == 0:\n\t\t\t\tdds[w] = dd\n\t\t\t\tw++\n\t\t\t\tr += 2\n\t\t\t\tchanged = true\n\t\t\tcase s == 0 && s2 != 0:\n\t\t\t\tdds[w] = dd2\n\t\t\t\tw++\n\t\t\t\tr += 2\n\t\t\t\tchanged = true\n\t\t\tcase s != 0 && s2 == 0:\n\t\t\t\tdds[w] = dd\n\t\t\t\tw++\n\t\t\t\tr += 2\n\t\t\t\tchanged = true\n\t\t\tcase s != 0 && s2 != 0:\n\t\t\t\td2 := d2.clone()\n\t\t\t\tvar p *Pointer\n\t\t\t\tfor i := 0; i < s+s2; i++ {\n\t\t\t\t\tp = &Pointer{Pointer: p}\n\t\t\t\t}\n\t\t\t\td2.PointerOpt = &PointerOpt{Pointer: p}\n\t\t\t\tdd2 := dd2.clone()\n\t\t\t\tdd2.Declarator = d2\n\t\t\t\tdds[w] = dd2\n\t\t\t\tw++\n\t\t\t\tr += 2\n\t\t\t\tchanged = true\n\t\t\t}\n\n\t\t}\n\t\tdds = dds[:w]\n\t\tif !changed {\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Outer (...) -> ...\n\tfor {\n\t\ti := len(dds) - 1\n\t\tif dd := dds[i]; dd.Case == 1 /* '(' Declarator ')' */ && dd.Declarator.stars() == 0 {\n\t\t\tdds = dds[:i:i]\n\t\t\tcontinue\n\t\t}\n\n\t\tbreak\n\t}\n\tresultStars := 0\n\ti := len(dds) - 1\n\tif dd := dds[i]; dd.Case == 1 /* '(' Declarator ')' */ {\n\t\tresultStars = dd.Declarator.stars()\n\t\tdds = dds[:i:i]\n\t}\n\n\tstars := 0\n\tresultStars += d.stars()\n\tswitch {\n\tcase len(dds) == 1:\n\t\tif dds[0].Case != 0 { // IDENTIFIER\n\t\t\tpanic(\"internal error\")\n\t\t}\n\n\t\tstars, resultStars = resultStars, 0\n\tdefault:\n\tagain:\n\t\ti := 1\n\tloop:\n\t\tfor {\n\t\t\tswitch dd := dds[i]; dd.Case {\n\t\t\tcase 1: // '(' Declarator ')'\n\t\t\t\tif dds[i-1].Case == 0 { // IDENTIFIER\n\t\t\t\t\tstars = dd.Declarator.stars()\n\t\t\t\t\tif stars == 0 {\n\t\t\t\t\t\tcopy(dds[i:], dds[i+1:])\n\t\t\t\t\t\tdds = dds[:len(dds)-1 : len(dds)-1]\n\t\t\t\t\t\tgoto again\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t//dbg(\"\", resultStars, stars, d.specifier.str(), ddsStr(dds))\n\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t}\n\t\t\t\ti++\n\t\t\tcase\n\t\t\t\t2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\t\t6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\tbreak loop\n\t\t\tdefault:\n\t\t\t\t//dbg(\"\", position(n.Pos()), resultStars, stars, d.specifier.str(), ddsStr(dds))\n\t\t\t\tpanic(dd.Case)\n\t\t\t}\n\t\t}\n\t}\n\n\tresultSpecifier := d.specifier\n\tresultAttr |= resultSpecifier.attrs()\n\tresultAttr &^= mask\n\tt := &ctype{\n\t\tdds0:            dds0,\n\t\tdds:             dds,\n\t\tmodel:           lx.model,\n\t\tresultAttr:      resultAttr,\n\t\tresultSpecifier: resultSpecifier,\n\t\tresultStars:     resultStars,\n\t\tstars:           stars,\n\t}\n\t//fmt.Printf(\"%s: 343\\n%s\", position(d.Pos()), PrettyString(resultSpecifier))\n\tif lx.tweaks.enableUnsignedEnums && n.unsigednEnum(lx, resultSpecifier) {\n\t\tt.resultSpecifier = &spec{resultAttr, tsEncode(tsUnsigned)}\n\t}\n\tn.Type = t\n\t//dbg(\"@@@@ %v: %s\", position(n.Pos()), t.dds[0].Token.S())\n\t//dbg(\"setFull %v: %v, %v %v\", t, t.Kind(), t.resultStars, t.stars)\n\t//dbg(\"\", t.str())\n\t//dbg(\"----> %v\", t)\n\n\tif lx.scope == nil {\n\t\treturn t\n\t}\n\n\t// Determine linkage\n\n\tdd := dds[0]\n\tscs := resultAttr & (saTypedef | saExtern | saStatic | saAuto | saRegister)\n\tsk := lx.scope.kind\n\tvar prev, prevVisible *Declarator\n\tvar prevVisibleBinding *Binding\n\tid := dd.Token.Val\n\tif p := lx.scope.Parent; p != nil {\n\t\tb := p.Lookup(NSIdentifiers, id)\n\t\tif dd, ok := b.Node.(*DirectDeclarator); ok {\n\t\t\tprevVisible = dd.TopDeclarator()\n\t\t\tprevVisibleBinding = &b\n\t\t}\n\t}\n\tif b := dd.prev; b != nil {\n\t\tprev = b.Node.(*DirectDeclarator).TopDeclarator()\n\t}\n\n\tswitch {\n\tcase\n\t\t// [0]6.2.2, 6: The following identifiers have no linkage: an\n\t\t// identifier declared to be anything other than an object or a\n\t\t// function; an identifier declared to be a function parameter;\n\t\t// a block scope identifier for an object declared without the\n\t\t// storage-class specifier extern.\n\t\tresultAttr&saTypedef != 0,\n\t\tsk == ScopeParams,\n\t\t(sk == ScopeBlock || sk == ScopeMembers) && resultAttr&saExtern == 0:\n\n\t\tn.Linkage = None\n\tcase\n\t\t// [0]6.2.2, 3: If the declaration of a file scope identifier\n\t\t// for an object or a function contains the storage-class\n\t\t// specifier static, the identifier has internal linkage.\n\t\tsk == ScopeFile && resultAttr&saStatic != 0:\n\n\t\tn.Linkage = Internal\n\tcase\n\t\t// [0]6.2.2, 4: For an identifier declared with the\n\t\t// storage-class specifier extern in a scope in which a prior\n\t\t// declaration of that identifier is visible, if the prior\n\t\t// declaration specifies internal or external linkage, the\n\t\t// linkage of the identifier at the later declaration is the\n\t\t// same as the linkage specified at the prior declaration.\n\n\t\tresultAttr&saExtern != 0 &&\n\t\t\t(prev != nil && (prev.Linkage == Internal || prev.Linkage == External) ||\n\t\t\t\tprevVisible != nil && (prevVisible.Linkage == Internal || prevVisible.Linkage == External)):\n\t\tswitch {\n\t\tcase prev != nil && (prev.Linkage == Internal || prev.Linkage == External):\n\t\t\tn.Linkage = prev.Linkage\n\t\tdefault:\n\t\t\tn.Linkage = prevVisible.Linkage\n\t\t\tdd.visible = prevVisibleBinding\n\t\t}\n\tcase\n\t\t// [0]6.2.2, 4: If no prior declaration is visible, or if the\n\t\t// prior declaration specifies no linkage, then the identifier\n\t\t// has external linkage.\n\t\tresultAttr&saExtern != 0 && (prev == nil || prev.Linkage == None):\n\n\t\tn.Linkage = External\n\tcase\n\t\t// [0]6.2.2, 5: If the declaration of an identifier for a\n\t\t// function has no storage-class specifier, its linkage is\n\t\t// determined exactly as if it were declared with the\n\t\t// storage-class specifier extern.\n\t\tt.Kind() == Function && scs == 0,\n\t\t// [0]6.2.2, 5: If the declaration of an identifier for an\n\t\t// object has file scope and no storage-class specifier, its\n\t\t// linkage is external.\n\t\tt.Kind() != Function && sk == ScopeFile && scs == 0:\n\n\t\tn.Linkage = External\n\t}\n\n\tif isGenerating || id == 0 {\n\t\t//dbg(\"setFull done (A)(%p): %s: %s\\n%v\", lx.scope, position(n.Pos()), n, resultSpecifier)\n\t\treturn t\n\t}\n\n\tif prev != nil && prev.specifier.IsTypedef() != n.specifier.IsTypedef() {\n\t\tlx.report.Err(n.Pos(),\n\t\t\t\"redeclaration of %s as different kind of symbol, previous declaration at %v\",\n\t\t\txc.Dict.S(id), position(prev.Pos()))\n\t\treturn t\n\t}\n\n\tswitch n.Linkage {\n\tcase External:\n\t\t// [0]6.2.2, 2: In the set of translation units and libraries\n\t\t// that constitutes an entire program, each declaration of a\n\t\t// particular identifier with external linkage denotes the same\n\t\t// object or function.\n\t\tif prev, ok := lx.externs[id]; ok && !n.isCompatible(prev) {\n\t\t\tt, isA := compositeType(prev.Type, n.Type)\n\t\t\tif t == nil {\n\t\t\t\tlx.report.Err(n.Pos(),\n\t\t\t\t\t\"conflicting types for %s '%s' with external linkage, previous declaration at %s '%s'\",\n\t\t\t\t\txc.Dict.S(id), n.Type, position(prev.Pos()), prev.Type)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif !isA {\n\t\t\t\tdd.prev.Node = n.DirectDeclarator.bottom()\n\t\t\t}\n\t\t}\n\n\t\tlx.externs[id] = n\n\tcase Internal:\n\t\t// [0]6.2.2, 2: Within one translation unit, each declaration\n\t\t// of an identifier with internal linkage denotes the same\n\t\t// object or function.\n\t\tif prev != nil && !n.isCompatible(prev) {\n\t\t\tt, isA := compositeType(prev.Type, n.Type)\n\t\t\tif t == nil {\n\t\t\t\tlx.report.Err(n.Pos(),\n\t\t\t\t\t\"conflicting types for %s '%s' with internal linkage, previous declaration at %s '%s'\",\n\t\t\t\t\txc.Dict.S(id), n.Type, position(prev.Pos()), prev.Type)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif !isA {\n\t\t\t\tdd.prev.Node = n.DirectDeclarator.bottom()\n\t\t\t}\n\t\t}\n\tcase None:\n\t\t// [0]6.2.2, 2: Each declaration of an identifier with no\n\t\t// linkage denotes a unique entity.\n\t\tif prev != nil {\n\t\t\tif lx.tweaks.allowCompatibleTypedefRedefinitions &&\n\t\t\t\tn.RawSpecifier().IsTypedef() && prev.RawSpecifier().IsTypedef() &&\n\t\t\t\tstrings.TrimPrefix(n.Type.String(), \"typedef \") == strings.TrimPrefix(prev.Type.String(), \"typedef \") {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlx.report.Err(n.Pos(),\n\t\t\t\t\"redeclaration of %s '%s' with no linkage, previous declaration at %v '%s'\",\n\t\t\t\txc.Dict.S(id), n.Type, position(prev.Pos()), prev.Type)\n\t\t}\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n\n\t//dbg(\"setFull done: %s: %s\", position(n.Pos()), n)\n\treturn t\n}\n\n// ----------------------------------------------------------- DeclaratorOpt\nfunc (n *DeclaratorOpt) isCompatible(m *DeclaratorOpt) bool {\n\treturn n == m || (n != nil && m != nil && n.Declarator.isCompatible(m.Declarator))\n}\n\n// ----------------------------------------------------------- DirectDeclarator\n\n// DeclarationScope returns the scope a name declared by n is in. If n does not\n// declare a name or n declares a name of a built in type, DeclarationScope\n// returns nil.\nfunc (n *DirectDeclarator) DeclarationScope() *Bindings {\n\treturn n.idScope\n}\n\n// TopDeclarator returns the top level Declarator associated with n.\nfunc (n *DirectDeclarator) TopDeclarator() *Declarator {\n\treturn n.top().declarator\n}\n\nfunc (n *DirectDeclarator) top() *DirectDeclarator {\n\tfor n.parent != nil {\n\t\tn = n.parent\n\t}\n\treturn n\n}\n\nfunc (n *DirectDeclarator) bottom() *DirectDeclarator {\n\tfor n.Case != 0 { // IDENTIFIER\n\t\tn = n.directDeclarator()\n\t}\n\treturn n\n}\n\nfunc (n *DirectDeclarator) clone() *DirectDeclarator {\n\tm := *n\n\treturn &m\n}\n\nfunc (n *DirectDeclarator) isCompatible(m *DirectDeclarator) (r bool) {\n\tif n == m {\n\t\treturn true\n\t}\n\n\tif n.Case > m.Case {\n\t\tn, m = m, n\n\t}\n\n\tif n.Case != m.Case {\n\t\tif n.Case == 6 && m.Case == 7 {\n\t\t\tvar b []Parameter\n\t\t\tif o := m.IdentifierListOpt; o != nil {\n\t\t\t\tb = o.params\n\t\t\t}\n\t\t\treturn isCompatibleParameters(\n\t\t\t\tn.ParameterTypeList.params,\n\t\t\t\tb,\n\t\t\t\tn.ParameterTypeList.Case == 1, // ParameterList ',' \"...\"\n\t\t\t\tfalse,\n\t\t\t)\n\t\t}\n\t}\n\n\tswitch n.Case {\n\tcase 0: // IDENTIFIER\n\t\treturn true\n\tcase 1: // '(' Declarator ')'\n\t\treturn true // Declarator checked before\n\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t// [0]6.7.5.3 6: For two array types to be compatible, both\n\t\t// shall have compatible element types, and if both size\n\t\t// specifiers are present, and are integer constant\n\t\t// expressions, then both size specifiers shall have the same\n\t\t// constant value. If the two array types are used in a context\n\t\t// which requires them to be compatible, it is undefined\n\t\t// behavior if the two size specifiers evaluate to unequal\n\t\t// values.\n\t\tvar nv, mv interface{}\n\t\tif o := n.ExpressionOpt; o != nil {\n\t\t\tnv = o.Expression.Value\n\t\t}\n\t\tif o := m.ExpressionOpt; o != nil {\n\t\t\tmv = o.Expression.Value\n\t\t}\n\t\tif nv != nil && mv != nil && nv != mv {\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'\n\t\treturn isCompatibleParameters(\n\t\t\tn.ParameterTypeList.params,\n\t\t\tm.ParameterTypeList.params,\n\t\t\tn.ParameterTypeList.Case == 1, // ParameterList ',' \"...\"\n\t\t\tm.ParameterTypeList.Case == 1, // ParameterList ',' \"...\"\n\t\t)\n\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\tvar a, b []Parameter\n\t\tif o := n.IdentifierListOpt; o != nil {\n\t\t\ta = o.params\n\t\t}\n\t\tif o := m.IdentifierListOpt; o != nil {\n\t\t\tb = o.params\n\t\t}\n\n\t\treturn isCompatibleParameters(a, b, false, false)\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *DirectDeclarator) directDeclarator() *DirectDeclarator {\n\tswitch n.Case {\n\tcase 0: // IDENTIFIER\n\t\treturn nil\n\tcase 1: // '(' Declarator ')'\n\t\treturn n.Declarator.DirectDeclarator\n\tcase\n\t\t2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t3, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t5, // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\treturn n.DirectDeclarator\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *DirectDeclarator) isArray() bool {\n\tswitch n.Case {\n\tcase\n\t\t0, // IDENTIFIER\n\t\t1, // '(' Declarator ')'                                                 // Case 1\n\t\t6, // DirectDeclarator '(' ParameterTypeList ')'                         // Case 6\n\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'                         // Case 7\n\t\treturn false\n\tcase\n\t\t2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'        // Case 2\n\t\t3, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'  // Case 3\n\t\t4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'     // Case 4\n\t\t5: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'                  // Case 5\n\t\treturn true\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *DirectDeclarator) isVLA() *Expression {\n\tswitch dd := n.DirectDeclarator; dd.Case {\n\tcase 0: // IDENTIFIER\n\t\treturn nil\n\tcase 1: // '(' Declarator ')'                                                 // Case 1\n\t\t//dbg(\"\", n.TopDeclarator().Type, n.TopDeclarator().Type.Element(), n.TopDeclarator().Type.Element().Elements())\n\t\td := n.TopDeclarator()\n\t\tif d.Type.Kind() == Ptr && d.Type.Element().Elements() >= 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tpanic(\"TODO\")\n\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'        // Case 2\n\t\to := n.ExpressionOpt\n\t\tif o == nil || o.Expression.Value != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn o.Expression\n\tcase 3: // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'  // Case 3\n\t\tpanic(\"TODO\")\n\tcase 4: // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'     // Case 4\n\t\tpanic(\"TODO\")\n\tcase 5: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'                  // Case 5\n\t\tpanic(\"TODO\")\n\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'                         // Case 6\n\t\treturn nil\n\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'                         // Case 7\n\t\tpanic(\"TODO\")\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// -------------------------------------------------------------  EnumSpecifier\n\nfunc (n *EnumSpecifier) isUnsigned(lx *lexer) bool {\n\tswitch n.Case {\n\tcase 0: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\treturn n.unsigned\n\tcase 1: // \"enum\" IDENTIFIER                                     // Case 1\n\t\tswitch b := lx.scope.Lookup(NSTags, n.Token2.Val); x := b.Node.(type) {\n\t\tcase *EnumSpecifier:\n\t\t\tswitch n := x; n.Case {\n\t\t\tcase 0: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\t\t\treturn n.unsigned\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\n// ----------------------------------------------------------------- Expression\n\nfunc (n *Expression) cond(lx *lexer, op operand) {\n\tm := lx.model\n\tlv, _ := n.Expression.eval(lx)\n\tif lv == nil {\n\t\t_, at := op.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\tif eqTypes(at, bt) {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tif IsArithmeticType(at) && IsArithmeticType(bt) {\n\t\t\tn.Type = m.BinOpType(at, bt)\n\t\t\treturn\n\t\t}\n\n\t\tak := at.Kind()\n\t\tbk := bt.Kind()\n\n\t\tif ak == Function && bk == Ptr {\n\t\t\tif e := bt.Element(); e.Kind() == Function && eqTypes(at, e) {\n\t\t\t\tn.Type = bt\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif bk == Function && ak == Ptr {\n\t\t\tif e := at.Element(); e.Kind() == Function && eqTypes(bt, e) {\n\t\t\t\tn.Type = at\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (ak == Enum || ak == Bool) && IsIntType(bt) {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tif (bk == Enum || bk == Bool) && IsIntType(at) {\n\t\t\tn.Type = bt\n\t\t\treturn\n\t\t}\n\n\t\tif ak == Struct && bk == Struct ||\n\t\t\tak == Union && bk == Union {\n\t\t\tif at.CanAssignTo(bt) {\n\t\t\t\tn.Type = at\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif ak == Void && bk == Void {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tif ak == Array && bk == Array {\n\t\t\tif at.(*ctype).isCompatible(bt.(*ctype)) {\n\t\t\t\tn.Type = at\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tat = at.(*ctype).arrayDecay()\n\t\t\tak = at.Kind()\n\t\t\tbt = bt.(*ctype).arrayDecay()\n\t\t\tbk = bt.Kind()\n\t\t}\n\n\t\tif ak == Array && bk == Ptr && at.CanAssignTo(bt) {\n\t\t\tn.Type = bt\n\t\t\treturn\n\t\t}\n\n\t\tif ak == Ptr && bk == Array && bt.CanAssignTo(at) {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tif ak == Ptr && bk == Ptr {\n\t\t\tif at.CanAssignTo(bt) {\n\t\t\t\tn.Type = at\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tif (ak == Ptr || ak == Array || ak == Function) && IsIntType(bt) {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tif (bk == Ptr || bk == Array || bk == Function) && IsIntType(at) {\n\t\t\tn.Type = bt\n\t\t\treturn\n\t\t}\n\n\t\tif ak == Ptr && at.Element().Kind() == Void && bk == Ptr {\n\t\t\tn.Type = bt\n\t\t\treturn\n\t\t}\n\n\t\tif bk == Ptr && bt.Element().Kind() == Void && ak == Ptr {\n\t\t\tn.Type = at\n\t\t\treturn\n\t\t}\n\n\t\tlx.report.ErrTok(n.Token2, \"'%s'/'%s' mismatch in conditional expression\", at, bt)\n\t\treturn\n\t}\n\n\tif isNonZero(lv) {\n\t\tn.Value, n.Type = op.eval(lx)\n\t\treturn\n\t}\n\n\tn.Value, n.Type = n.Expression2.eval(lx)\n}\n\nfunc (n *Expression) eval(lx *lexer) (interface{}, Type) {\n\tm := lx.model\n\tif n.Type != nil {\n\t\treturn n.Value, n.Type\n\t}\n\n\tn.Type = undefined\nouter:\n\tswitch n.Case {\n\tcase 0: // IDENTIFIER\n\t\tb := n.scope.Lookup(NSIdentifiers, n.Token.Val)\n\t\tif b.Node == nil {\n\t\t\tlx.report.ErrTok(n.Token, \"undefined: %s\", n.Token.S())\n\t\t\tbreak\n\t\t}\n\n\t\tdd := b.Node.(*DirectDeclarator)\n\t\tt := dd.top().declarator.Type\n\t\tif (t.Kind() == Ptr || t.Kind() == Array) && n.Type.Elements() == -1 {\n\t\t\tfound := false\n\t\t\tdd := dd\n\t\tmore:\n\t\t\tfor dd.prev != nil {\n\t\t\t\tdd = dd.prev.Node.(*DirectDeclarator)\n\t\t\t\tif t2 := dd.TopDeclarator().Type; t2.Elements() >= 0 {\n\t\t\t\t\tt = t2\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !found && dd.visible != nil {\n\t\t\t\tdd = dd.visible.Node.(*DirectDeclarator)\n\t\t\t\tif t2 := dd.TopDeclarator().Type; t2.Elements() >= 0 {\n\t\t\t\t\tt = t2\n\t\t\t\t} else {\n\t\t\t\t\tgoto more\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tn.Type = t\n\t\tif v := dd.EnumVal; v != nil {\n\t\t\tn.Value = v\n\t\t}\n\tcase 1: // CHARCONST\n\t\tn.Value, n.Type = m.charConst(lx, n.Token)\n\tcase 2: // FLOATCONST\n\t\tn.Value, n.Type = m.floatConst(lx, n.Token)\n\tcase 3: // INTCONST\n\t\tn.Value, n.Type = m.intConst(lx, n.Token)\n\tcase 4: // LONGCHARCONST\n\t\tn.Value, n.Type = m.charConst(lx, n.Token)\n\tcase 5: // LONGSTRINGLITERAL\n\t\tn.Value, n.Type = m.strConst(lx, n.Token)\n\tcase 6: // STRINGLITERAL\n\t\tn.Value, n.Type = m.strConst(lx, n.Token)\n\tcase 7: //  '(' ExpressionList ')'\n\t\tn.Value, n.Type = n.ExpressionList.eval(lx)\n\tcase 8: // Expression '[' ExpressionList ']'\n\t\t_, t := n.Expression.eval(lx)\n\t\t_, t2 := n.ExpressionList.eval(lx)\n\t\tswitch t.Kind() {\n\t\tcase Ptr, Array:\n\t\t\tn.Type = t.Element()\n\t\t\tif !IsIntType(t2) && t2.Kind() != Bool {\n\t\t\t\tlx.report.Err(n.ExpressionList.Pos(), \"array subscript is not an integer or bool (have '%s')\", t2)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif p, x := n.Expression.Value, n.ExpressionList.Value; p != nil && x != nil {\n\t\t\t\tsz := uintptr(n.Type.SizeOf())\n\t\t\t\tswitch pv := p.(type) {\n\t\t\t\tcase uintptr:\n\t\t\t\t\tswitch xv := x.(type) {\n\t\t\t\t\tcase int32:\n\t\t\t\t\t\tpv += sz * uintptr(xv)\n\t\t\t\t\tcase uint32:\n\t\t\t\t\t\tpv += sz * uintptr(xv)\n\t\t\t\t\tcase int64:\n\t\t\t\t\t\tpv += sz * uintptr(xv)\n\t\t\t\t\tcase uint64:\n\t\t\t\t\t\tpv += sz * uintptr(xv)\n\t\t\t\t\tcase uintptr:\n\t\t\t\t\t\tpv += sz * xv\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t}\n\t\t\t\t\tn.Value = pv\n\t\t\t\tcase StringLitID, LongStringLitID:\n\t\t\t\t\t// ok, but not a constant expression.\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak outer\n\t\t}\n\n\t\tif !IsIntType(t) && t.Kind() != Bool || t2.Kind() != Ptr && t2.Kind() != Array {\n\t\t\tlx.report.ErrTok(n.Token, \"invalid index expression types (%s[%t])\", t, n.ExpressionList.Type)\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = t2.Element()\n\t\tif p, x := n.ExpressionList.Value, n.Expression.Value; p != nil && x != nil {\n\t\t\tpanic(fmt.Errorf(\"%s: TODO\", position(n.Pos())))\n\t\t}\n\tcase 9: // Expression '(' ArgumentExpressionListOpt ')'\n\t\tif n.Expression.Case == 0 { // IDENTIFIER\n\t\t\tif lx.tweaks.enableBuiltinConstantP && n.Expression.Token.Val == idBuiltinConstantP {\n\t\t\t\to := n.ArgumentExpressionListOpt\n\t\t\t\tif o == nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"missing argument of __builtin_constant_p\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\targs := o.ArgumentExpressionList\n\t\t\t\tif args.ArgumentExpressionList != nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"too many arguments of __builtin_constant_p\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tn.Case = 3 // INTCONST\n\t\t\t\tn.Type = lx.model.IntType\n\t\t\t\tswitch v, _ := args.Expression.eval(lx); {\n\t\t\t\tcase v != nil:\n\t\t\t\t\tn.Value = int32(1)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = int32(0)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif lx.tweaks.enableBuiltinClassifyType && n.Expression.Token.Val == idBuiltinClasifyType {\n\t\t\t\to := n.ArgumentExpressionListOpt\n\t\t\t\tif o == nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"missing argument of __builtin_classify_type\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\targs := o.ArgumentExpressionList\n\t\t\t\tif args.ArgumentExpressionList != nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"too many arguments of __builtin_classify_type\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tn.Case = 3 // INTCONST\n\t\t\t\tn.Type = lx.model.IntType\n\t\t\t\tv := noTypeClass\n\t\t\t\tif _, t := args.Expression.eval(lx); t != nil {\n\t\t\t\t\tv = classifyType[t.Kind()]\n\t\t\t\t}\n\t\t\t\tn.Value = int32(v)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif n.Expression.Token.Val == idBuiltinTypesCompatible {\n\t\t\t\t// using #define __builtin_types_compatible_p(type1, type2) __builtin_types_compatible__((type1){}, (type2){})\n\t\t\t\to := n.ArgumentExpressionListOpt\n\t\t\t\tif o == nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"missing arguments of __builtin_types_compatible_p\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\targs := o.ArgumentExpressionList\n\t\t\t\targ1 := args.Expression\n\t\t\t\tif arg1.Case != 14 { // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\t\t\t\tlx.report.Err(arg1.Pos(), \"invalid argument of __builtin_types_compatible__\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\targs = args.ArgumentExpressionList\n\t\t\t\tif args == nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"missing argument of __builtin_types_compatible_p\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\targ2 := args.Expression\n\t\t\t\tif arg2.Case != 14 { // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\t\t\t\tlx.report.Err(arg1.Pos(), \"invalid argument of __builtin_types_compatible__\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif args.ArgumentExpressionList != nil {\n\t\t\t\t\tlx.report.Err(n.Expression.Pos(), \"too many arguments of __builtin_types_compatible_p\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tt := arg1.Type\n\t\t\t\tu := arg2.Type\n\t\t\t\tvar v int32\n\t\t\t\tif !isEnum(arg1.TypeName, arg2.TypeName) && t.(*ctype).isCompatible(u.(*ctype)) {\n\t\t\t\t\tv = 1\n\t\t\t\t\tif t.Kind() == Ptr && u.Kind() == Ptr && t.Specifier().IsConst() != u.Specifier().IsConst() {\n\t\t\t\t\t\tv = 0\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tn.Type = lx.model.IntType\n\t\t\t\tn.Value = v\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tb := n.Expression.scope.Lookup(NSIdentifiers, n.Expression.Token.Val)\n\t\t\tif b.Node == nil && lx.tweaks.enableImplicitFuncDef {\n\t\t\t\tn.Type = lx.model.IntType\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t_, t := n.Expression.eval(lx)\n\t\tif t.Kind() == Ptr {\n\t\t\tt = t.Element()\n\t\t}\n\t\tif t.Kind() != Function {\n\t\t\tlx.report.Err(n.Expression.Pos(), \"called object is not a function or function pointer (have '%s')\", t)\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = t.Result()\n\t\tparams, isVariadic := t.Parameters()\n\t\tif params == nil {\n\t\t\tbreak // [0], 6.5.2.2/8\n\t\t}\n\n\t\tvar args []*Expression\n\t\tvar types []Type\n\t\tif o := n.ArgumentExpressionListOpt; o != nil {\n\t\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\t\tex := l.Expression\n\t\t\t\targs = append(args, ex)\n\t\t\t\t_, t := ex.eval(lx)\n\t\t\t\ttypes = append(types, t)\n\t\t\t}\n\t\t}\n\n\t\tif g, e := len(args), len(params); g < e {\n\t\t\tlx.report.ErrTok(n.Token, \"too few arguments to function (have %v, want %v)\", g, e)\n\t\t\tbreak\n\t\t}\n\n\t\tif !isVariadic {\n\t\t\tif len(args) > len(params) && len(params) != 0 /* composite type */ {\n\t\t\t\tlx.report.Err(n.ArgumentExpressionListOpt.Pos(), \"too many arguments to function\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tfor i, param := range params {\n\t\t\tpt := param.Type\n\t\t\tif pt.Kind() == Array {\n\t\t\t\tpt = pt.(*ctype).arrayDecay()\n\t\t\t}\n\t\t\ttyp := types[i]\n\t\t\tif pt.Kind() == Function && typ.Kind() == Ptr && typ.Element().Kind() == Function {\n\t\t\t\ttyp = typ.Element()\n\t\t\t}\n\t\t\tif !typ.CanAssignTo(pt) {\n\t\t\t\tlx.report.Err(args[i].Pos(), \"expected '%s' but argument is of type '%s'\", pt, typ)\n\t\t\t}\n\t\t}\n\tcase 10: // Expression '.' IDENTIFIER\n\t\t_, t := n.Expression.eval(lx)\n\t\tmb, err := t.Member(n.Token2.Val)\n\t\tif err == nil {\n\t\t\tn.Type = mb.Type\n\t\t} else {\n\t\t\t// support AnonymousStructs() by doing some emulating... (todo check if enabled)\n\t\t\toffset, ty, err2 := memberOffsetRecursive(t, n.Token2.Val)\n\t\t\tif err2 == nil {\n\t\t\t\t// This is kindof a simple workaround... should work good enough though\n\t\t\t\t// and might be the easiest implementation possible\n\t\t\t\t// transform a.b into (*(ty*)((char*)(&a))+offset))\n\t\t\t\tptr := &Expression{\n\t\t\t\t\tCase:       17, // &Expression\n\t\t\t\t\tToken:      xc.Token{lex.Char{Rune: '&'}, 0},\n\t\t\t\t\tExpression: n.Expression,\n\t\t\t\t}\n\t\t\t\t// sneak in a char pointer so that the offset is correct\n\t\t\t\tcharTy := lx.model.CharType.Pointer()\n\t\t\t\tcharTyDeclarator := &Declarator{Type: charTy}\n\t\t\t\tptr = &Expression{\n\t\t\t\t\tCase:       25,\n\t\t\t\t\tToken:      xc.Token{lex.Char{Rune: '('}, 0},\n\t\t\t\t\tTypeName:   &TypeName{Type: charTy, declarator: charTyDeclarator},\n\t\t\t\t\tToken2:     xc.Token{lex.Char{Rune: ')'}, 0},\n\t\t\t\t\tExpression: ptr,\n\t\t\t\t}\n\t\t\t\tsid := dict.SID(strconv.Itoa(offset))\n\t\t\t\toffset := &Expression{\n\t\t\t\t\tCase:  3, // INTCONST\n\t\t\t\t\tToken: xc.Token{lex.Char{Rune: INTCONST}, sid},\n\t\t\t\t}\n\t\t\t\tfieldPtr := &Expression{\n\t\t\t\t\tCase:        29, // +\n\t\t\t\t\tExpression:  ptr,\n\t\t\t\t\tToken:       xc.Token{lex.Char{Rune: '+'}, 0},\n\t\t\t\t\tExpression2: offset,\n\t\t\t\t}\n\t\t\t\tptrTy := (*ty).Pointer()\n\t\t\t\tdeclarator := &Declarator{Type: ptrTy}\n\t\t\t\tcast := &Expression{\n\t\t\t\t\tCase:       25, // cast to ty *\n\t\t\t\t\tToken:      xc.Token{lex.Char{Rune: '('}, 0},\n\t\t\t\t\tTypeName:   &TypeName{Type: ptrTy, declarator: declarator},\n\t\t\t\t\tToken2:     xc.Token{lex.Char{Rune: ')'}, 0},\n\t\t\t\t\tExpression: fieldPtr,\n\t\t\t\t}\n\t\t\t\t*n = Expression{\n\t\t\t\t\tCase:       18, // * (dereference)\n\t\t\t\t\tToken:      xc.Token{lex.Char{Rune: '*'}, 0},\n\t\t\t\t\tExpression: cast,\n\t\t\t\t}\n\t\t\t\tn.Value, n.Type = n.eval(lx)\n\t\t\t} else {\n\t\t\t\tlx.report.Err(n.Token2.Pos(), \"%v (OR %v)\", err, err2)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tcase 11: // Expression \"->\" IDENTIFIER\n\t\tv, t := n.Expression.eval(lx)\n\t\tif t.Kind() != Ptr && t.Kind() != Array {\n\t\t\tlx.report.ErrTok(n.Token2, \"invalid type argument of -> (have '%v')\", t)\n\t\t\tbreak\n\t\t}\n\n\t\tt = t.Element()\n\t\tmb, err := t.Member(n.Token2.Val)\n\t\tif err != nil {\n\t\t\tlx.report.Err(n.Token2.Pos(), \"%v\", err)\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = mb.Type\n\t\tswitch x := v.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase uintptr:\n\t\t\tn.Value = x + uintptr(mb.OffsetOf)\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\tcase 12: // Expression \"++\"\n\t\tn.Value, n.Type = n.Expression.eval(lx)\n\tcase 13: // Expression \"--\"\n\t\tn.Value, n.Type = n.Expression.eval(lx)\n\tcase 14: // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\tn.Type = n.TypeName.Type\n\t\tn.InitializerList.typeCheck(&n.Type, n.Type, false, lx)\n\tcase 15: // \"++\" Expression\n\t\tn.Value, n.Type = n.Expression.eval(lx)\n\tcase 16: // \"--\" Expression\n\t\tn.Value, n.Type = n.Expression.eval(lx)\n\tcase 17: // '&' Expression\n\t\tvar t Type\n\t\tn.Value, t = n.Expression.eval(lx)\n\t\tn.Type = t.Pointer()\n\tcase 18: // '*' Expression\n\t\t_, t := n.Expression.eval(lx)\n\t\tif t.Kind() == Function {\n\t\t\tn.Type = t\n\t\t\tbreak\n\t\t}\n\n\t\tif k := t.Kind(); k != Ptr && k != Array {\n\t\t\tlx.report.ErrTok(n.Token, \"invalid argument type of unary * (have '%v')\", t)\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = t.Element()\n\tcase 19: // '+' Expression\n\t\tv, t := n.Expression.eval(lx)\n\t\tn.Type = lx.model.promote(t)\n\t\tif v == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tn.Value = lx.model.MustConvert(v, n.Type)\n\tcase 20: // '-' Expression\n\t\tv, t := n.Expression.eval(lx)\n\t\tn.Type = lx.model.promote(t)\n\t\tif v == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tv = lx.model.MustConvert(v, n.Type)\n\t\tswitch x := v.(type) {\n\t\tcase int16:\n\t\t\tn.Value = -x\n\t\tcase uint16:\n\t\t\tn.Value = -x\n\t\tcase int32:\n\t\t\tn.Value = -x\n\t\tcase uint32:\n\t\t\tn.Value = -x\n\t\tcase uint64:\n\t\t\tn.Value = -x\n\t\tcase int64:\n\t\t\tn.Value = -x\n\t\tcase float32:\n\t\t\tn.Value = -x\n\t\tcase float64:\n\t\t\tn.Value = -x\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 21: // '~' Expression\n\t\tv, t := n.Expression.eval(lx)\n\t\tn.Type = lx.model.promote(t)\n\t\tif v == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tv = lx.model.MustConvert(v, n.Type)\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tn.Value = ^x\n\t\tcase uint32:\n\t\t\tn.Value = ^x\n\t\tcase int64:\n\t\t\tn.Value = ^x\n\t\tcase uint64:\n\t\t\tn.Value = ^x\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 22: // '!' Expression\n\t\tv, _ := n.Expression.eval(lx)\n\t\tn.Type = m.IntType\n\t\tif v == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tn.Value = m.cBool(isZero(v))\n\tcase 23: // \"sizeof\" Expression\n\t\tn.Type = m.getSizeType(lx)\n\t\tswitch v, t := n.Expression.eval(lx); x := v.(type) {\n\t\tcase StringLitID:\n\t\t\tn.Value = m.MustConvert(int32(len(dict.S(int(x)))+1), n.Type)\n\t\tdefault:\n\t\t\tn.Value = m.MustConvert(uint64(t.SizeOf()), n.Type)\n\t\t}\n\tcase 24: // \"sizeof\" '(' TypeName ')'\n\t\tn.Type = m.getSizeType(lx)\n\t\tn.Value = m.MustConvert(uint64(n.TypeName.declarator.Type.SizeOf()), n.Type)\n\tcase 25: // '(' TypeName ')' Expression\n\t\tv, _ := n.Expression.eval(lx)\n\t\tn.Type = n.TypeName.declarator.Type\n\t\tn.Value = v\n\t\tif v != nil && n.Type.Kind() != Struct && n.Type.Kind() != Union && !isStrLitID(v) {\n\t\t\tn.Value = m.MustConvert(v, n.Type)\n\t\t}\n\tcase 26: // Expression '*' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x * b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x * b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x * b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x * b.(uint64)\n\t\tcase float32:\n\t\t\tn.Value = x * b.(float32)\n\t\tcase float64:\n\t\t\tn.Value = x * b.(float64)\n\t\tcase complex64:\n\t\t\tn.Value = x * b.(complex64)\n\t\tcase complex128:\n\t\t\tn.Value = x * b.(complex128)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 27: // Expression '/' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tif b != nil && isZero(b) && IsIntType(n.Type) {\n\t\t\tlx.report.Err(n.Expression2.Pos(), \"division by zero\")\n\t\t\tbreak\n\t\t}\n\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x / b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x / b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x / b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x / b.(uint64)\n\t\tcase float32:\n\t\t\tn.Value = x / b.(float32)\n\t\tcase float64:\n\t\t\tn.Value = x / b.(float64)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 28: // Expression '%' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tif b != nil && isZero(b) && IsIntType(n.Type) {\n\t\t\tlx.report.Err(n.Expression2.Pos(), \"division by zero\")\n\t\t\tbreak\n\t\t}\n\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x % b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x % b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x % b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x % b.(uint64)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 29: // Expression '+' Expression\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\tif at.Kind() == Array {\n\t\t\tat = at.Element().Pointer()\n\t\t}\n\t\tif bt.Kind() == Array {\n\t\t\tbt = bt.Element().Pointer()\n\t\t}\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif IsIntType(bt) || bt.Kind() == Bool {\n\t\t\t\tn.Type = at\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' + '%s')\", at, bt)\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tn.BinOpType = n.Type\n\t\t\tswitch x := a.(type) {\n\t\t\tcase nil:\n\t\t\t\t// nop\n\t\t\tcase int32:\n\t\t\t\tn.Value = x + b.(int32)\n\t\t\tcase uint32:\n\t\t\t\tn.Value = x + b.(uint32)\n\t\t\tcase int64:\n\t\t\t\tn.Value = x + b.(int64)\n\t\t\tcase uint64:\n\t\t\t\tn.Value = x + b.(uint64)\n\t\t\tcase float32:\n\t\t\t\tn.Value = x + b.(float32)\n\t\t\tcase float64:\n\t\t\t\tn.Value = x + b.(float64)\n\t\t\tcase complex64:\n\t\t\t\tn.Value = x + b.(complex64)\n\t\t\tcase complex128:\n\t\t\t\tn.Value = x + b.(complex128)\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t\t}\n\t\t}\n\tcase 30: // Expression '-' Expression\n\t\tav, at := n.Expression.eval(lx)\n\t\tbv, bt := n.Expression2.eval(lx)\n\t\tif at.Kind() == Array {\n\t\t\tat = at.Element().Pointer()\n\t\t}\n\t\tif bt.Kind() == Array {\n\t\t\tbt = bt.Element().Pointer()\n\t\t}\n\t\tif at.Kind() == Ptr && bt.Kind() == Ptr {\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tn.Type = undefined\n\t\t\t\tlx.report.Err(n.Expression2.Pos(), \"incompatible types ('%s' - '%s')\", at, bt)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn.Type = m.getPtrDiffType(lx)\n\t\t\tif av != nil && bv != nil {\n\t\t\t\tn.Value = lx.model.MustConvert((av.(uintptr)-bv.(uintptr))/uintptr(n.Type.SizeOf()), n.Type)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tif at.Kind() == Ptr && IsIntType(bt) {\n\t\t\tn.Type = at\n\t\t\tbreak\n\t\t}\n\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x - b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x - b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x - b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x - b.(uint64)\n\t\tcase float32:\n\t\t\tn.Value = x - b.(float32)\n\t\tcase float64:\n\t\t\tn.Value = x - b.(float64)\n\t\tcase complex64:\n\t\t\tn.Value = x - b.(complex64)\n\t\tcase complex128:\n\t\t\tn.Value = x - b.(complex128)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 31: // Expression \"<<\" Expression\n\t\tav, at := n.Expression.eval(lx)\n\t\tbv, bt := n.Expression2.eval(lx)\n\t\tn.Type = lx.model.promote(at)\n\t\tif av == nil || bv == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tav = lx.model.MustConvert(av, n.Type)\n\t\tbv = lx.model.MustConvert(bv, lx.model.promote(bt))\n\t\tswitch x := av.(type) {\n\t\tcase int8:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint8:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int16:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint16:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint16:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x >> uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x << uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 32: // Expression \">>\" Expression\n\t\tav, at := n.Expression.eval(lx)\n\t\tbv, bt := n.Expression2.eval(lx)\n\t\tn.Type = lx.model.promote(at)\n\t\tif av == nil || bv == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tav = lx.model.MustConvert(av, n.Type)\n\t\tbv = lx.model.MustConvert(bv, lx.model.promote(bt))\n\t\tswitch x := av.(type) {\n\t\tcase int8:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint8:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int16:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint16:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch y := bv.(type) {\n\t\t\tcase int32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint32:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tcase y < 0:\n\t\t\t\t\tn.Value = x << uint(-y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tcase uint64:\n\t\t\t\tswitch {\n\t\t\t\tcase y > 0:\n\t\t\t\t\tn.Value = x >> uint(y)\n\t\t\t\tdefault:\n\t\t\t\t\tn.Value = x\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", y))\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 33: // Expression '<' Expression\n\t\tn.Type = m.IntType\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\ta0, b0 := at, bt\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif bt.Kind() == Array {\n\t\t\t\tbt = bt.Element().Pointer()\n\t\t\t}\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' < '%s')\", a0, b0)\n\t\t\t}\n\t\t\tbreak\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tn.Type = m.IntType\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tswitch x := a.(type) {\n\t\t\tcase nil:\n\t\t\t\t// nop\n\t\t\tcase int32:\n\t\t\t\tn.Value = m.cBool(x < b.(int32))\n\t\t\tcase uint32:\n\t\t\t\tn.Value = m.cBool(x < b.(uint32))\n\t\t\tcase int64:\n\t\t\t\tn.Value = m.cBool(x < b.(int64))\n\t\t\tcase uint64:\n\t\t\t\tn.Value = m.cBool(x < b.(uint64))\n\t\t\tcase float32:\n\t\t\t\tn.Value = m.cBool(x < b.(float32))\n\t\t\tcase float64:\n\t\t\t\tn.Value = m.cBool(x < b.(float64))\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t\t}\n\t\t}\n\tcase 34: // Expression '>' Expression\n\t\tn.Type = m.IntType\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\ta0, b0 := at, bt\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif bt.Kind() == Array {\n\t\t\t\tbt = bt.Element().Pointer()\n\t\t\t}\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' > '%s')\", a0, b0)\n\t\t\t}\n\t\t\tbreak\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tn.Type = m.IntType\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tswitch x := a.(type) {\n\t\t\tcase nil:\n\t\t\t\t// nop\n\t\t\tcase int32:\n\t\t\t\tn.Value = m.cBool(x > b.(int32))\n\t\t\tcase int64:\n\t\t\t\tn.Value = m.cBool(x > b.(int64))\n\t\t\tcase uint32:\n\t\t\t\tn.Value = m.cBool(x > b.(uint32))\n\t\t\tcase uint64:\n\t\t\t\tn.Value = m.cBool(x > b.(uint64))\n\t\t\tcase float32:\n\t\t\t\tn.Value = m.cBool(x > b.(float32))\n\t\t\tcase float64:\n\t\t\t\tn.Value = m.cBool(x > b.(float64))\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t\t}\n\t\t}\n\tcase 35: // Expression \"<=\" Expression\n\t\tn.Type = m.IntType\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\ta0, b0 := at, bt\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' <= '%s')\", a0, b0)\n\t\t\t}\n\t\t\tbreak\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tn.Type = m.IntType\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tswitch x := a.(type) {\n\t\t\tcase nil:\n\t\t\t\t// nop\n\t\t\tcase int32:\n\t\t\t\tn.Value = m.cBool(x <= b.(int32))\n\t\t\tcase uint32:\n\t\t\t\tn.Value = m.cBool(x <= b.(uint32))\n\t\t\tcase int64:\n\t\t\t\tn.Value = m.cBool(x <= b.(int64))\n\t\t\tcase uint64:\n\t\t\t\tn.Value = m.cBool(x <= b.(uint64))\n\t\t\tcase float32:\n\t\t\t\tn.Value = m.cBool(x <= b.(float32))\n\t\t\tcase float64:\n\t\t\t\tn.Value = m.cBool(x <= b.(float64))\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t\t}\n\t\t}\n\tcase 36: // Expression \">=\" Expression\n\t\tn.Type = m.IntType\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\ta0, b0 := at, bt\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif bt.Kind() == Array {\n\t\t\t\tbt = bt.Element().Pointer()\n\t\t\t}\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' >= '%s')\", a0, b0)\n\t\t\t}\n\t\t\tbreak\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tswitch x := a.(type) {\n\t\t\tcase nil:\n\t\t\t\t// nop\n\t\t\tcase int32:\n\t\t\t\tn.Value = m.cBool(x >= b.(int32))\n\t\t\tcase uint32:\n\t\t\t\tn.Value = m.cBool(x >= b.(uint32))\n\t\t\tcase int64:\n\t\t\t\tn.Value = m.cBool(x >= b.(int64))\n\t\t\tcase uint64:\n\t\t\t\tn.Value = m.cBool(x >= b.(uint64))\n\t\t\tcase float32:\n\t\t\t\tn.Value = m.cBool(x >= b.(float32))\n\t\t\tcase float64:\n\t\t\t\tn.Value = m.cBool(x >= b.(float64))\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t\t}\n\t\t}\n\tcase 37: // Expression \"==\" Expression\n\t\tn.Type = m.IntType\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\ta0, b0 := at, bt\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif IsIntType(bt) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif bt.Kind() == Array {\n\t\t\t\tbt = bt.(*ctype).arrayDecay()\n\t\t\t}\n\t\t\tif bt.Kind() == Function && at.Element().Kind() == Function {\n\t\t\t\tbt = bt.Pointer()\n\t\t\t}\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' == '%s')\", a0, b0)\n\t\t\t}\n\t\t\tbreak\n\t\tcase at.Kind() == Function && bt.Kind() == Function:\n\t\t\t// nop\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tif a == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn.Value = m.cBool(a == b)\n\t\t}\n\tcase 38: // Expression \"!=\" Expression\n\t\tn.Type = m.IntType\n\t\tav, at := n.Expression.eval(lx)\n\t\tbv, bt := n.Expression2.eval(lx)\n\t\tif at.Kind() > bt.Kind() {\n\t\t\tat, bt = bt, at\n\t\t}\n\touter38:\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif av != nil && bv != nil {\n\t\t\t\tx := av.(uintptr)\n\t\t\t\tswitch y := bv.(type) {\n\t\t\t\tcase int32:\n\t\t\t\t\tn.Value = m.cBool(x != uintptr(y))\n\t\t\t\t\tbreak outer38\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"TODO %s: %T %T\", position(n.Pos()), av, bv))\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif IsIntType(bt) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif bt.Kind() == Function && at.Element().Kind() == Function {\n\t\t\t\tbt = bt.Pointer()\n\t\t\t}\n\t\t\tif bt.Kind() == Array {\n\t\t\t\tbt = bt.(*ctype).arrayDecay()\n\t\t\t}\n\t\t\tif !at.CanAssignTo(bt) {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types ('%s' != '%s')\", at, bt)\n\t\t\t}\n\t\t\tbreak\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tvar a, b interface{}\n\t\t\ta, b, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2)\n\t\t\tif a == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn.Value = m.cBool(a != b)\n\t\t}\n\tcase 39: // Expression '&' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x & b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x & b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x & b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x & b.(uint64)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 40: // Expression '^' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x ^ b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x ^ b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x ^ b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x ^ b.(uint64)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t\t}\n\tcase 41: // Expression '|' Expression\n\t\tvar a, b interface{}\n\t\ta, b, n.Type = m.binOp(lx, n.Expression, n.Expression2)\n\t\tn.BinOpType = n.Type\n\t\tswitch x := a.(type) {\n\t\tcase nil:\n\t\t\t// nop\n\t\tcase int32:\n\t\t\tn.Value = x | b.(int32)\n\t\tcase uint32:\n\t\t\tn.Value = x | b.(uint32)\n\t\tcase int64:\n\t\t\tn.Value = x | b.(int64)\n\t\tcase uint64:\n\t\t\tn.Value = x | b.(uint64)\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"internal error: %T\", x))\n\t\t}\n\tcase 42: // Expression \"&&\" Expression\n\t\tn.Type = m.IntType\n\t\ta, _ := n.Expression.eval(lx)\n\t\tif a != nil && isZero(a) {\n\t\t\tn.Value = m.cBool(false)\n\t\t\tbreak\n\t\t}\n\n\t\tb, _ := n.Expression2.eval(lx)\n\t\tif a != nil && b != nil {\n\t\t\tif isZero(b) {\n\t\t\t\tn.Value = m.cBool(false)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn.Value = m.cBool(true)\n\t\t\tbreak\n\t\t}\n\tcase 43: // Expression \"||\" Expression\n\t\tn.Type = m.IntType\n\t\tav, _ := n.Expression.eval(lx)\n\t\tif av != nil && isNonZero(av) {\n\t\t\tn.Value = m.cBool(true)\n\t\t\tbreak\n\t\t}\n\n\t\tbv, _ := n.Expression2.eval(lx)\n\t\tif av != nil && bv != nil {\n\t\t\tn.Value = m.cBool(isNonZero(bv))\n\t\t\tbreak\n\t\t}\n\tcase 44: // Expression '?' ExpressionList ':' Expression\n\t\tn.cond(lx, n.ExpressionList)\n\t\tbreak\n\tcase 45: // Expression '=' Expression\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\tif bt.Kind() == Function {\n\t\t\tbt = bt.Pointer()\n\t\t}\n\t\tif !bt.CanAssignTo(at) {\n\t\t\tlx.report.Err(n.Expression2.Pos(), \"assignment from incompatible type ('%s' = '%s')\", at, bt)\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = at\n\t\tif at.Kind() == Array && bt.Kind() == Ptr {\n\t\t\tn.Type = bt\n\t\t}\n\tcase 46: // Expression \"*=\" Expression\n\t\t_, n.Type = n.Expression.eval(lx)\n\t\tif _, _, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2); n.BinOpType.Kind() == Undefined {\n\t\t\tlx.report.ErrTok(n.Token, \"incompatible types\") //TODO have ...\n\t\t}\n\tcase\n\t\t47, // Expression \"/=\" Expression\n\t\t48: // Expression \"%=\" Expression\n\t\tm.checkArithmeticType(lx, n.Expression, n.Expression2)\n\t\tn.Type = n.Expression.Type\n\t\tif v := n.Expression2.Value; v != nil && isZero(v) && IsIntType(n.Type) {\n\t\t\tlx.report.Err(n.Expression2.Pos(), \"division by zero\")\n\t\t\tbreak\n\t\t}\n\n\t\tif _, _, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2); n.BinOpType.Kind() == Undefined {\n\t\t\tlx.report.ErrTok(n.Token, \"incompatible types\") //TODO have ...\n\t\t}\n\tcase\n\t\t49, // Expression \"+=\" Expression\n\t\t50: // Expression \"-=\" Expression\n\t\t_, at := n.Expression.eval(lx)\n\t\t_, bt := n.Expression2.eval(lx)\n\t\tn.Type = at\n\t\tswitch {\n\t\tcase at.Kind() == Ptr:\n\t\t\tif IsIntType(bt) || bt.Kind() == Bool {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlx.report.ErrTok(n.Token, \"incompatible types\") //TODO have ...\n\t\tcase IsArithmeticType(at):\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tif _, _, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2); n.BinOpType.Kind() == Undefined {\n\t\t\t\tlx.report.ErrTok(n.Token, \"incompatible types\") //TODO have ...\n\t\t\t}\n\t\t}\n\tcase\n\t\t51, // Expression \"<<=\" Expression\n\t\t52: // Expression \">>=\" Expression\n\t\tm.checkIntegerOrBoolType(lx, n.Expression, n.Expression2)\n\t\tn.Type = n.Expression.Type\n\tcase\n\t\t53, // Expression \"&=\" Expression\n\t\t54, // Expression \"^=\" Expression\n\t\t55: // Expression \"|=\" Expression\n\t\tm.checkIntegerOrBoolType(lx, n.Expression, n.Expression2)\n\t\tif _, _, n.BinOpType = m.binOp(lx, n.Expression, n.Expression2); n.BinOpType.Kind() == Undefined {\n\t\t\tlx.report.ErrTok(n.Token, \"incompatible types\") //TODO have ...\n\t\t}\n\t\tn.Type = n.BinOpType\n\tcase 56: // \"_Alignof\" '(' TypeName ')'\n\t\tn.Type = lx.model.getSizeType(lx)\n\t\tt := n.TypeName.Type\n\t\tel := true\n\tagain:\n\t\tswitch t.Kind() {\n\t\tcase Undefined, Function:\n\t\t\tt = nil\n\t\tcase Struct, Union:\n\t\t\tif _, isIncomplete := t.Members(); isIncomplete {\n\t\t\t\tt = nil\n\t\t\t\tbreak\n\t\t\t}\n\t\tcase Array:\n\t\t\tif el {\n\t\t\t\tel = false\n\t\t\t\tt = t.Element()\n\t\t\t\tgoto again\n\t\t\t}\n\t\t}\n\t\tif t == nil {\n\t\t\tlx.report.Err(n.TypeName.Pos(), \"invalid argument of _Alignof\")\n\t\t\tn.Value = lx.model.MustConvert(1, n.Type)\n\t\t\tbreak\n\t\t}\n\n\t\tal := t.AlignOf()\n\t\tif al < 0 {\n\t\t\tlx.report.Err(n.TypeName.Pos(), \"invalid argument of _Alignof\")\n\t\t\tal = 1\n\t\t}\n\t\tn.Value = lx.model.MustConvert(int32(al), n.Type)\n\tcase 57: // '(' CompoundStatement ')'                          // Case 57\n\t\tif !lx.tweaks.enableParenCompoundStmt {\n\t\t\tlx.report.Err(n.Pos(), \"non-standard parenthesized compound statement as expression not enabled\")\n\t\t\tbreak\n\t\t}\n\n\t\tn.Type = lx.model.VoidType\n\t\to := n.CompoundStatement.BlockItemListOpt\n\t\tif o == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tvar last *BlockItem\n\t\tfor l := o.BlockItemList; l != nil; l = l.BlockItemList {\n\t\t\tif l.BlockItemList == nil {\n\t\t\t\tlast = l.BlockItem\n\t\t\t}\n\t\t}\n\n\t\tif last == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tswitch last.Case {\n\t\tcase 0: // Declaration\n\t\t\t// nop\n\t\tcase 1: // Statement    // Case 1\n\t\t\tif es := last.Statement.ExpressionStatement; es != nil {\n\t\t\t\to := es.ExpressionListOpt\n\t\t\t\tif o != nil {\n\t\t\t\t\tel := o.ExpressionList\n\t\t\t\t\tn.Type, n.Value = el.Type, el.Value\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\tcase 58: // \"&&\" IDENTIFIER                                    // Case 58\n\t\tn.Type = lx.model.VoidType.Pointer()\n\t\tn.Value = ComputedGotoID(n.Token2.Val)\n\tcase 59: // Expression '?' ':' Expression                      // Case 59\n\t\tn.cond(lx, n.Expression)\n\tdefault:\n\t\t//dbg(\"\", PrettyString(n))\n\t\tpanic(fmt.Errorf(\"%s: internal error: Expression.Case: %v\", position(n.Pos()), n.Case))\n\t}\n\t//ct := n.Type.(*ctype)\n\t//s := \"\"\n\t//if n.Value != nil {\n\t//\ts = fmt.Sprintf(\"value: %T(%#v)\", n.Value, n.Value)\n\t//}\n\t//dbg(\"tc %v %v %v %v %v: %v %v\", position(n.Pos()), n.Case, ct.resultStars, ct.stars, ct, ct.Kind(), s)\n\treturn n.Value, n.Type\n}\n\n// IdentResolutionScope returns the scope an identifier is resolved in. If n is\n// not an identifier (n.Case == 0), IdentResolutionScope returns nil.\nfunc (n *Expression) IdentResolutionScope() *Bindings {\n\tif n.Case == 0 { // IDENTIFIER\n\t\treturn n.scope\n\t}\n\n\treturn nil\n}\n\n// ------------------------------------------------------------- ExpressionList\n\nfunc (n *ExpressionList) eval(lx *lexer) (interface{}, Type) {\n\tif n.Type != nil {\n\t\treturn n.Value, n.Type\n\t}\n\n\tn0 := n\n\tfor ; n != nil; n = n.ExpressionList {\n\t\tn.Value, n.Type = n.Expression.eval(lx)\n\t\tn0.Value, n0.Type = n.Value, n.Type\n\t}\n\treturn n0.Value, n0.Type\n}\n\n// Len returns the number of items in n.\nfunc (n *ExpressionList) Len() (r int) {\n\tfor ; n != nil; n = n.ExpressionList {\n\t\tr++\n\t}\n\treturn r\n}\n\n// --------------------------------------------------------- FunctionDefinition\n\nfunc (*FunctionDefinition) post(lx *lexer, d *Declarator, dlo *DeclarationListOpt) {\n\tlx.scope.mergeScope = nil\n\tdone := false\n\tfor dd := d.DirectDeclarator.bottom(); !done && dd != nil; dd = dd.parent {\n\t\tswitch dd.Case {\n\t\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\tdone = true\n\t\t\tlx.scope.mergeScope = dd.paramsScope\n\t\t\tif dlo != nil {\n\t\t\t\tlx.report.Err(dlo.Pos(), \"declaration list not allowed in a function definition with parameter type list\")\n\t\t\t}\n\t\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\tdone = true\n\t\t\tilo := dd.IdentifierListOpt\n\t\t\tif ilo != nil && dlo == nil {\n\t\t\t\tif !lx.tweaks.enableOmitFuncArgTypes {\n\t\t\t\t\tlx.report.Err(ilo.Pos(), \"missing parameter declaration list\")\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tlx.pushScope(ScopeParams)\n\t\t\t\tfor l := ilo.IdentifierList; l != nil; l = l.IdentifierList {\n\t\t\t\t\ttok := l.Token\n\t\t\t\t\tif l.Case == 1 {\n\t\t\t\t\t\ttok = l.Token2\n\t\t\t\t\t}\n\t\t\t\t\td := lx.model.makeDeclarator(0, tsInt)\n\t\t\t\t\td.Type = lx.model.IntType\n\t\t\t\t\tlx.scope.declareIdentifier(tok, d.DirectDeclarator, lx.report)\n\t\t\t\t\tilo.params = append(ilo.params, Parameter{d, tok.Val, d.Type})\n\t\t\t\t}\n\t\t\t\tlx.scope.mergeScope, _ = lx.popScope(dd.Token2)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif ilo == nil {\n\t\t\t\tif dlo != nil {\n\t\t\t\t\tlx.report.Err(dlo.Pos(), \"unexpected parameter declaration list\")\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// ilo != nil && dlo != nil\n\t\t\tlx.scope.mergeScope = dlo.paramsScope\n\t\t\tilo.post(lx, dlo)\n\t\t}\n\t}\n\td.setFull(lx)\n\tif !done {\n\t\tlx.report.Err(d.Pos(), \"declarator is not a function (have '%s': %v)\", d.Type, d.Type.Kind())\n\t}\n\tlx.fnDeclarator = d\n}\n\n// ---------------------------------------------------------- IdentifierListOpt\n\nfunc (n *IdentifierListOpt) post(lx *lexer, dlo *DeclarationListOpt) {\n\ttype r struct {\n\t\tpos token.Pos\n\t\ti   int\n\t}\n\tvar a []xc.Token\n\tilm := map[int]r{}\n\ti := 0\n\tfor il := n.IdentifierList; il != nil; il, i = il.IdentifierList, i+1 {\n\t\tt := il.Token\n\t\tif il.Case == 1 {\n\t\t\tt = il.Token2\n\t\t}\n\t\tnm := t.Val\n\t\tif r, ok := ilm[nm]; ok {\n\t\t\tlx.report.ErrTok(t, \"duplicate parameter name declaration, previous at %s\", r.pos)\n\t\t\tcontinue\n\t\t}\n\n\t\tv := r{t.Pos(), i}\n\t\tilm[nm] = v\n\t\ta = append(a, t)\n\t}\n\tparams := make([]Parameter, len(ilm))\n\tif dlo != nil {\n\t\tfor dl := dlo.DeclarationList; dl != nil; dl = dl.DeclarationList {\n\t\t\tdecl := dl.Declaration\n\t\t\to := decl.InitDeclaratorListOpt\n\t\t\tif o == nil {\n\t\t\t\tlx.report.Err(decl.Pos(), \"invalid parameter declaration\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor l := o.InitDeclaratorList; l != nil; l = l.InitDeclaratorList {\n\t\t\t\tid := l.InitDeclarator\n\t\t\t\tif id.Case == 1 { // Declarator '=' Initializer\n\t\t\t\t\tlx.report.Err(id.Pos(), \"invalid parameter declarator\")\n\t\t\t\t}\n\n\t\t\t\td := id.Declarator\n\t\t\t\tnm, _ := d.Identifier()\n\t\t\t\tr, ok := ilm[nm]\n\t\t\t\tif !ok {\n\t\t\t\t\tlx.report.Err(d.Pos(), \"parameter name not declared\")\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tparams[r.i] = Parameter{d, nm, d.Type}\n\t\t\t}\n\t\t}\n\t}\n\tfor i, v := range params {\n\t\tif v.Declarator == nil {\n\t\t\ttok := a[i]\n\t\t\td := lx.model.makeDeclarator(0, tsInt)\n\t\t\td.Type = lx.model.IntType\n\t\t\tdlo.paramsScope.declareIdentifier(tok, d.DirectDeclarator, lx.report)\n\t\t\tparams[i] = Parameter{d, tok.Val, d.Type}\n\t\t}\n\t}\n\tn.params = params\n\tfixParams(n.params)\n}\n\n// ---------------------------------------------------------------- Initializer\n\nfunc (n *Initializer) typeCheck(pt *Type, dt Type, static bool, lx *lexer) {\n\tstatic = static && !lx.tweaks.enableNonConstStaticInitExpressions\n\tif dt == nil {\n\t\treturn\n\t}\n\n\tk := dt.Kind()\n\td := dt.Declarator()\n\tdd := d.DirectDeclarator\n\tif dd.isArray() && dd.isVLA() != nil {\n\t\tlx.report.Err(n.Pos(), \"variable length array cannot have initializers\")\n\t\treturn\n\t}\n\n\tswitch n.Case {\n\tcase 0: // Expression\n\t\tx := n.Expression\n\t\txt := n.Expression.Type\n\t\tswitch v := x.Value.(type) {\n\t\tcase StringLitID:\n\t\t\tswitch k {\n\t\t\tcase Array, Ptr:\n\t\t\t\tswitch dt.Element().Kind() {\n\t\t\t\tcase Char, SChar, UChar:\n\t\t\t\t\tif pt != nil && dd.isArray() && dt.Elements() < 0 {\n\t\t\t\t\t\t*pt = dt.(*ctype).setElements(len(xc.Dict.S(int(v))) + 1)\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tif !xt.CanAssignTo(dt) {\n\t\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif !xt.CanAssignTo(dt) {\n\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\tcase LongStringLitID:\n\t\t\tswitch k {\n\t\t\tcase Array, Ptr:\n\t\t\t\tswitch dt.Element().Kind() {\n\t\t\t\tcase Short, UShort, Int, UInt, Long, ULong:\n\t\t\t\t\tif pt != nil && dd.isArray() && dt.Elements() < 0 {\n\t\t\t\t\t\t*pt = dt.(*ctype).setElements(len([]rune(string(xc.Dict.S(int(v))))) + 1)\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tif !xt.CanAssignTo(dt) {\n\t\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif !xt.CanAssignTo(dt) {\n\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\tcase nil:\n\t\t\tif static {\n\t\t\t\tswitch x.Case {\n\t\t\t\tcase 0: // IDENTIFIER\n\t\t\t\t\tif xt.Kind() == Array && xt.CanAssignTo(dt) {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tif xt.Kind() == Function && xt.Pointer().CanAssignTo(dt) {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\tcase 17: // '&' Expression                                     // Case 17\n\t\t\t\t\tif !xt.CanAssignTo(dt) {\n\t\t\t\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tlx.report.Err(x.Pos(), \"expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals.\")\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\n\t\tif !xt.CanAssignTo(dt) {\n\t\t\t//dbg(\"\", dt, xt)\n\t\t\tif dt.Kind() == Struct || dt.Kind() == Union {\n\t\t\t\tif ma, _ := dt.Members(); len(ma) == 1 {\n\t\t\t\t\t//dbg(\"\")\n\t\t\t\t\tn.typeCheck(nil, ma[0].Type, static, lx)\n\t\t\t\t\t//dbg(\"\")\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif dt.Kind() == Array {\n\t\t\t\tn.typeCheck(nil, dt.Element(), static, lx)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlx.report.Err(x.Pos(), \"cannot initialize type '%v' using expression of type '%v'\", dt, xt)\n\t\t\treturn\n\t\t}\n\tcase 1: // '{' InitializerList CommaOpt '}'  // Case 1\n\t\tn.InitializerList.typeCheck(pt, dt, static, lx)\n\tcase 2: // IDENTIFIER ':' Initializer        // Case 2\n\t\tp := *pt\n\t\tif p.Kind() != Struct && dt.Kind() != Union {\n\t\t\tlx.report.Err(n.Pos(), \"invalid designator for type %v\", dt)\n\t\t\tbreak\n\t\t}\n\n\t\tm, err := p.Member(n.Token.Val)\n\t\tif err != nil {\n\t\t\tlx.report.Err(n.Pos(), \"type %v has no member %s: %v\", p, dict.S(n.Token.Val), err)\n\t\t\tbreak\n\t\t}\n\n\t\tn.InitializerList.typeCheck(&p, m.Type, static, lx)\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ------------------------------------------------------------ InitializerList\n\n// Len returns the number of items in n.\nfunc (n *InitializerList) Len() (r int) {\n\tfor ; n != nil; n = n.InitializerList {\n\t\tr++\n\t}\n\treturn r\n}\n\nfunc (n *InitializerList) typeCheck(pt *Type, dt Type, static bool, lx *lexer) {\n\tif n == nil || dt == nil {\n\t\treturn\n\t}\n\n\td := dt.Declarator()\n\tdd := d.DirectDeclarator\n\tswitch dt.Kind() {\n\tcase Struct, Union:\n\t\tma, incomplete := dt.Members()\n\t\tif incomplete {\n\t\t\tlx.report.Err(n.Pos(), \"cannot initialize incomplete type\")\n\t\t\treturn\n\t\t}\n\n\t\tif len(ma) == 1 {\n\t\t\t//dbg(\"%s: %v -> %v\", position(n.Pos()), dt, ma[0].Type)\n\t\t\tn.InitializerList.typeCheck(nil, ma[0].Type, static, lx)\n\t\t\treturn\n\t\t}\n\n\t\ti := 0\n\t\tvar stack []int\n\t\tfor l := n; l != nil; l = l.InitializerList {\n\t\t\tvar m Member\n\t\t\tswitch o := l.DesignationOpt; {\n\t\t\tcase o != nil:\n\t\t\t\tma := ma\n\t\t\t\tj := 0\n\t\t\t\tfor l := o.Designation.DesignatorList; l != nil; l = l.DesignatorList {\n\t\t\t\t\tswitch d := l.Designator; d.Case {\n\t\t\t\t\tcase 0: // '[' ConstantExpression ']'\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\tcase 1: // '.' IDENTIFIER              // Case 1\n\t\t\t\t\t\tif j != 0 {\n\t\t\t\t\t\t\tma, _ = m.Type.Members()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfound := false\n\t\t\t\t\t\tfor k, v := range ma {\n\t\t\t\t\t\t\tif d.Token2.Val == v.Name {\n\t\t\t\t\t\t\t\tfound = true\n\t\t\t\t\t\t\t\tm = v\n\t\t\t\t\t\t\t\tif j == 0 {\n\t\t\t\t\t\t\t\t\ti = k\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif !found {\n\t\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tj++\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif i >= len(ma) {\n\t\t\t\t\t//dbg(\"\", i, len(ma))\n\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t}\n\n\t\t\t\tswitch l := len(stack); {\n\t\t\t\tcase l != 0:\n\t\t\t\t\tstack[l-1]--\n\t\t\t\t\tif stack[l-1] != 0 {\n\t\t\t\t\t\ti--\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tstack = stack[:l-1]\n\t\t\t\t\ti++\n\t\t\t\t\tfallthrough\n\t\t\t\tdefault:\n\t\t\t\t\tm = ma[i]\n\t\t\t\t\tif mt := m.Type; mt.Kind() == Array && mt.Elements() >= 0 {\n\t\t\t\t\t\tstack = append(stack, mt.Elements())\n\t\t\t\t\t\ti--\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tp := dt\n\t\t\tl.Initializer.typeCheck(&p, m.Type, static, lx)\n\t\t\ti++\n\t\t}\n\tcase Array, Ptr:\n\t\telems := dt.Elements()\n\t\telem := dt.Element()\n\t\telem0 := elem\n\t\tfor elem0.Kind() == Array {\n\t\t\tn := elem0.Elements()\n\t\t\tif n >= 0 {\n\t\t\t\tif elems < 0 {\n\t\t\t\t\telems = 1\n\t\t\t\t}\n\t\t\t\telems *= n\n\t\t\t}\n\t\t\telem0 = elem0.Element()\n\t\t}\n\t\ti := 0\n\t\tfor l := n; l != nil; l = l.InitializerList {\n\t\t\tif o := l.DesignationOpt; o != nil {\n\t\t\t\telem := elem\n\t\t\t\tj := 0\n\t\t\t\tm := lx.model\n\t\t\t\tfor l := o.Designation.DesignatorList; l != nil; l = l.DesignatorList {\n\t\t\t\t\tswitch d := l.Designator; d.Case {\n\t\t\t\t\tcase 0: // '[' ConstantExpression ']'\n\t\t\t\t\t\tif !IsIntType(d.ConstantExpression.Type) {\n\t\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tswitch {\n\t\t\t\t\t\tcase j == 0:\n\t\t\t\t\t\t\ti = int(m.MustConvert(d.ConstantExpression.Value, m.IntType).(int32))\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\telem = elem.Element()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tj++\n\t\t\t\t\tcase 1: // '.' IDENTIFIER              // Case 1\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif elems >= 0 && i >= elems {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tswitch in := l.Initializer; in.Case {\n\t\t\tcase 0: // Expression\n\t\t\t\tin.typeCheck(nil, elem0, static, lx)\n\t\t\t\ti++\n\t\t\tcase 1: // '{' InitializerList CommaOpt '}'  // Case 1\n\t\t\t\tif !elem.Declarator().DirectDeclarator.isArray() {\n\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t}\n\n\t\t\t\tin.InitializerList.typeCheck(nil, elem, static, lx)\n\t\t\t\ti++\n\t\t\tdefault:\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\t\t}\n\t\tif pt != nil && dd.isArray() && elems < 0 {\n\t\t\t//dbg(\"\", position(n.Pos()), elem, elems)\n\t\t\t*pt = dt.(*ctype).setElements(i)\n\t\t}\n\tdefault:\n\t\ti := 0\n\t\tfor l := n; l != nil; l = l.InitializerList {\n\t\t\tif i != 0 {\n\t\t\t\t//dbg(\"%s: %v\", position(n.Pos()), dt)\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tl.Initializer.typeCheck(nil, dt, static, lx)\n\t\t\ti++\n\t\t}\n\t}\n}\n\n// ---------------------------------------------------------- ParameterTypeList\n\nfunc (n *ParameterTypeList) post() {\n\tfor l := n.ParameterList; l != nil; l = l.ParameterList {\n\t\td := l.ParameterDeclaration.declarator\n\t\tnm, _ := d.Identifier()\n\t\tt := d.Type\n\t\tn.params = append(n.params, Parameter{\n\t\t\tDeclarator: d,\n\t\t\tName:       nm,\n\t\t\tType:       t,\n\t\t})\n\t}\n\tif len(n.params) == 1 && n.params[0].Type.Kind() == Void {\n\t\tn.params = make([]Parameter, 0) // Must be non nil.\n\t}\n\tfixParams(n.params)\n}\n\n// -------------------------------------------------------------------- Pointer\n\nfunc (n *Pointer) stars() (r int) {\n\tfor ; n != nil; n = n.Pointer {\n\t\tr++\n\t}\n\treturn r\n}\n\n// ----------------------------------------------------------------- PointerOpt\n\nfunc (n *PointerOpt) stars() int {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Pointer.stars()\n}\n\n// ----------------------------------------------------- SpecifierQualifierList\n\nfunc (n *SpecifierQualifierList) isCompatible(m *SpecifierQualifierList) bool {\n\tif n.typeSpecifier != m.typeSpecifier {\n\t\treturn false\n\t}\n\n\tswitch n.TypeSpecifier.Case {\n\tcase 11: // StructOrUnionSpecifier       // Case 11\n\t\treturn true //TODO nil deref panic: return m.TypeQualifier.Case == 11 && n.TypeSpecifier.StructOrUnionSpecifier.isCompatible(m.TypeSpecifier.StructOrUnionSpecifier)\n\tdefault:\n\t\treturn true\n\t}\n}\n\n// IsInline implements specifier.\nfunc (n *SpecifierQualifierList) IsInline() bool {\n\treturn n.attr&saInline != 0\n}\n\n// IsTypedef implements specifier.\nfunc (n *SpecifierQualifierList) IsTypedef() bool {\n\treturn n.attr&saTypedef != 0\n}\n\n// IsExtern implements specifier.\nfunc (n *SpecifierQualifierList) IsExtern() bool {\n\treturn n.attr&saExtern != 0\n}\n\n// IsStatic implements specifier.\nfunc (n *SpecifierQualifierList) IsStatic() bool {\n\treturn n.attr&saStatic != 0\n}\n\n// IsAuto implements specifier.\nfunc (n *SpecifierQualifierList) IsAuto() bool {\n\treturn n.attr&saAuto != 0\n}\n\n// IsRegister implements specifier.\nfunc (n *SpecifierQualifierList) IsRegister() bool {\n\treturn n.attr&saRegister != 0\n}\n\n// IsConst returns whether n includes the 'const' type qualifier.\nfunc (n *SpecifierQualifierList) IsConst() bool {\n\treturn n.attr&saConst != 0\n}\n\n// IsRestrict implements specifier.\nfunc (n *SpecifierQualifierList) IsRestrict() bool {\n\treturn n.attr&saRestrict != 0\n}\n\n// IsVolatile implements specifier.\nfunc (n *SpecifierQualifierList) IsVolatile() bool {\n\treturn n.attr&saVolatile != 0\n}\n\n// kind implements specifier.\nfunc (n *SpecifierQualifierList) kind() Kind { return tsValid[n.typeSpecifiers()] }\n\n// typeSpecifiers implements specifier.\nfunc (n *SpecifierQualifierList) typeSpecifiers() int {\n\treturn n.typeSpecifier\n}\n\n// firstTypeSpecifier implements specifier.\nfunc (n *SpecifierQualifierList) firstTypeSpecifier() *TypeSpecifier {\n\tfor n.Case != 0 { // TypeSpecifier SpecifierQualifierListOpt\n\t\to := n.SpecifierQualifierListOpt\n\t\tif o == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tn = o.SpecifierQualifierList\n\t}\n\treturn n.TypeSpecifier\n}\n\n// attrs implements specifier.\nfunc (n *SpecifierQualifierList) attrs() int { return n.attr }\n\n// member implements specifier.\nfunc (n *SpecifierQualifierList) member(nm int) (*Member, error) {\n\treturn n.firstTypeSpecifier().member(nm)\n}\n\n// str implements specifier.\nfunc (n *SpecifierQualifierList) str() string {\n\treturn specifierString(n)\n}\n\n// TypedefName implements Specifier.\nfunc (n *SpecifierQualifierList) TypedefName() int {\n\tif n.kind() == TypedefName {\n\t\treturn n.firstTypeSpecifier().Token.Val\n\t}\n\treturn 0\n}\n\n// ----------------------------------------------------------- StructDeclarator\n\nfunc (n *StructDeclarator) post(lx *lexer) {\n\tsc := lx.scope\n\tswitch n.Case {\n\tcase 0: // Declarator\n\t\tif sc.bitOffset != 0 {\n\t\t\tfinishBitField(n, lx)\n\t\t}\n\n\t\tt := n.Declarator.Type\n\t\tsz := t.sizeOf(lx)\n\t\tal := t.structAlignOf(lx)\n\t\tswitch {\n\t\tcase sc.isUnion:\n\t\t\t// Track union size.\n\t\t\tsc.maxSize = mathutil.Max(sc.maxSize, sz)\n\t\tdefault:\n\t\t\toff := sc.offset\n\t\t\tsc.offset = align(sc.offset, al) // Bump offset if necessary.\n\t\t\tif pd := sc.prevStructDeclarator; pd != nil {\n\t\t\t\tpd.padding = sc.offset - off\n\t\t\t}\n\t\t\tn.Declarator.offsetOf = sc.offset\n\t\t\tsc.offset += sz // Allocate sz.\n\t\t}\n\t\tsc.maxAlign = mathutil.Max(sc.maxAlign, al)\n\t\tsc.prevStructDeclarator = n.Declarator\n\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\tt := lx.model.IntType\n\t\tif o := n.DeclaratorOpt; o != nil {\n\t\t\tt = o.Declarator.Type\n\t\t}\n\n\t\tvar w int\n\t\tswitch x := n.ConstantExpression.Value.(type) {\n\t\tcase int32:\n\t\t\tw = int(x)\n\t\tcase int64:\n\t\t\tw = int(x)\n\t\t\tif m := t.sizeOf(lx) * 8; x > int64(m) {\n\t\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"width of bit field exceeds its type\")\n\t\t\t\tw = m\n\t\t\t}\n\t\tcase uint64:\n\t\t\tw = int(x)\n\t\t\tm := t.sizeOf(lx) * 8\n\t\t\tif x > uint64(m) {\n\t\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"width of bit field exceeds its type\")\n\t\t\t\tw = m\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif x > uint64(lx.model.Items[Int].Size*8) {\n\t\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"width of bit field exceeds int bits\")\n\t\t\t\tw = m\n\t\t\t\tbreak\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\t\tif m := t.sizeOf(lx) * 8; w > m {\n\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"width of bit field exceeds its type\")\n\t\t\tw = m\n\t\t}\n\t\tmaxLLBits := lx.model.LongLongType.sizeOf(lx) * 8\n\t\tmaxBits := lx.model.LongType.sizeOf(lx) * 8\n\t\tif sum := sc.bitOffset + w; sum > maxBits {\n\t\t\tif sum > maxLLBits || w <= maxBits {\n\t\t\t\tfinishBitField(n, lx)\n\t\t\t}\n\t\t}\n\t\tif o := n.DeclaratorOpt; o != nil {\n\t\t\td := o.Declarator\n\t\t\td.offsetOf = sc.offset\n\t\t\td.bitOffset = sc.bitOffset\n\t\t\td.bitFieldGroup = sc.bitFieldGroup\n\t\t\tsc.prevStructDeclarator = o.Declarator\n\t\t\tt = d.Type\n\t\t\tswitch t.Kind() {\n\t\t\tcase Char, SChar, UChar, Int, UInt, Long, ULong, Short, UShort, Enum, Bool:\n\t\t\t\t// ok\n\t\t\tcase LongLong, ULongLong:\n\t\t\t\tif lx.tweaks.enableWideBitFieldTypes {\n\t\t\t\t\t// Non-standard, but enabled.\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"bit field has invalid type (have %s)\", t)\n\t\t\t\tt = lx.model.IntType\n\t\t\tdefault:\n\t\t\t\tlx.report.Err(n.ConstantExpression.Pos(), \"bit field has invalid type (have %s)\", t)\n\t\t\t\tt = lx.model.IntType\n\t\t\t}\n\t\t}\n\t\tsc.bitOffset += w\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *StructDeclarator) isCompatible(m *StructDeclarator) bool {\n\tif n.Case != m.Case {\n\t\treturn false\n\t}\n\n\tswitch n.Case {\n\tcase 0: // Declarator\n\t\treturn n.Declarator.isCompatible(m.Declarator)\n\tcase 1: //  DeclaratorOpt ':' ConstantExpression  // Case 1\n\t\tty1 := n.ConstantExpression.Expression.Type.(*ctype)\n\t\tty2 := m.ConstantExpression.Expression.Type.(*ctype)\n\t\treturn n.DeclaratorOpt.isCompatible(m.DeclaratorOpt) && ty1.isCompatible(ty2)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%s: internal error\", position(n.Pos())))\n\t}\n}\n\n// -------------------------------------------------------------- StructDeclaratorList\n\nfunc (n *StructDeclaratorList) isCompatible(m *StructDeclaratorList) bool {\n\tfor ; n != nil; n = n.StructDeclaratorList {\n\t\tif m == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tsda := n.StructDeclarator\n\t\tsdb := m.StructDeclarator\n\t\tif !sda.isCompatible(sdb) {\n\t\t\treturn false\n\t\t}\n\t\tm = m.StructDeclaratorList\n\t}\n\tif m != nil {\n\t\treturn false\n\t}\n\treturn true\n}\n\n// -------------------------------------------------------------- StructOrUnion\n\nfunc (n *StructOrUnion) typeSpecifiers() int {\n\tswitch n.Token.Rune {\n\tcase STRUCT:\n\t\treturn tsStructSpecifier\n\tcase UNION:\n\t\treturn tsUnionSpecifier\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\nfunc (n *StructOrUnion) isCompatible(m *StructOrUnion) (r bool) {\n\treturn n == m || n.Case == m.Case\n}\n\nfunc (n *StructOrUnion) str() string {\n\tswitch n.Token.Rune {\n\tcase STRUCT:\n\t\treturn \"struct\"\n\tcase UNION:\n\t\treturn \"union\"\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ----------------------------------------------------- StructOrUnionSpecifier\n\n// Declarator returns a synthetic Declarator when a tagged struc/union type is\n// defined inline a declaration.\nfunc (n *StructOrUnionSpecifier) Declarator() *Declarator { return n.declarator }\n\nfunc (n *StructOrUnionSpecifier) typeSpecifiers() int { return n.StructOrUnion.typeSpecifiers() }\n\nfunc (n *StructOrUnionSpecifier) isCompatible(m *StructOrUnionSpecifier) (r bool) {\n\tif n == m {\n\t\treturn true\n\t}\n\n\tif !n.StructOrUnion.isCompatible(m.StructOrUnion) {\n\t\treturn false\n\t}\n\n\tif n.Case > m.Case {\n\t\tn, m = m, n\n\t}\n\tswitch n.Case {\n\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\tswitch m.Case {\n\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\tb := m.StructDeclarationList\n\t\t\tfor a := n.StructDeclarationList; a != nil; a = a.StructDeclarationList {\n\t\t\t\tif b == nil {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tsda := a.StructDeclaration\n\t\t\t\tsdb := b.StructDeclaration\n\t\t\t\tif sda.Case != sdb.Case {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tswitch sda.Case {\n\t\t\t\tcase 0: // SpecifierQualifierList StructDeclaratorList ';'\n\t\t\t\t\tif !sda.StructDeclaratorList.isCompatible(sdb.StructDeclaratorList) {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\tcase 1: // SpecifierQualifierList ';'                       // Case 1\n\t\t\t\t\tswitch sdb.Case {\n\t\t\t\t\tcase 1: // SpecifierQualifierList ';'                       // Case 1\n\t\t\t\t\t\tif !sda.SpecifierQualifierList.isCompatible(sdb.SpecifierQualifierList) {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\tcase 2: // StaticAssertDeclaration                          // Case 2\n\t\t\t\t\tpanic(fmt.Errorf(\"%s: TODO\", position(n.Pos())))\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%s: internal error\", position(n.Pos())))\n\t\t\t\t}\n\n\t\t\t\tb = b.StructDeclarationList\n\t\t\t}\n\n\t\t\treturn b == nil\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\tif o := n.IdentifierOpt; o != nil {\n\t\t\t\treturn o.Token.Val == m.Token.Val\n\t\t\t}\n\n\t\t\tpanic(\"TODO\")\n\t\tdefault:\n\t\t\tpanic(m.Case)\n\t\t}\n\tcase 1: // StructOrUnion IDENTIFIER\n\t\tswitch m.Case {\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\treturn n.Token.Val == m.Token.Val\n\t\tdefault:\n\t\t\tpanic(m.Case)\n\t\t}\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *StructOrUnionSpecifier) member(nm int) (*Member, error) {\n\tswitch n.Case {\n\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\tb, s := n.scope.Lookup2(NSIdentifiers, nm)\n\t\tif s != n.scope {\n\t\t\tvar t []byte\n\t\t\tif o := n.IdentifierOpt; o != nil {\n\t\t\t\tt = o.Token.S()\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"%s %s has no member named %s\", n.StructOrUnion.str(), t, xc.Dict.S(nm))\n\t\t}\n\n\t\td := b.Node.(*DirectDeclarator).top().declarator\n\t\treturn &Member{\n\t\t\tBits:       d.bits,\n\t\t\tDeclarator: d,\n\t\t\tName:       nm,\n\t\t\tOffsetOf:   d.offsetOf,\n\t\t\tType:       d.Type,\n\t\t}, nil\n\tcase 1: // StructOrUnion IDENTIFIER\n\t\tb := n.scope.Lookup(NSTags, n.Token.Val)\n\t\tn2, def := b.Node.(*StructOrUnionSpecifier)\n\t\tif !def {\n\t\t\treturn nil, fmt.Errorf(\"invalid use of undefined type '%s %s'\", n.StructOrUnion.str(), n.Token.S())\n\t\t}\n\n\t\treturn n2.member(nm)\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\n// -------------------------------------------------------------- TypeSpecifier\n\nfunc (n *TypeSpecifier) member(nm int) (*Member, error) {\n\tswitch n.Case {\n\tcase 11: // StructOrUnionSpecifier\n\t\treturn n.StructOrUnionSpecifier.member(nm)\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n"
  },
  {
    "path": "ast_test.go",
    "content": "// Code generated by yy. DO NOT EDIT.\n\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"fmt\"\n)\n\nfunc ExampleAbstractDeclarator() {\n\tfmt.Println(exampleAST(185, \"\\U00100001 ( _Bool * )\"))\n\t// Output:\n\t// &cc.AbstractDeclarator{\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: example185.c:1:10: '*',\n\t// · },\n\t// }\n}\n\nfunc ExampleAbstractDeclarator_case1() {\n\tfmt.Println(exampleAST(186, \"\\U00100001 ( _Bool ( ) )\"))\n\t// Output:\n\t// &cc.AbstractDeclarator{\n\t// · Case: 1,\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 6,\n\t// · · Token: example186.c:1:10: '(',\n\t// · · Token2: example186.c:1:12: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleAbstractDeclaratorOpt() {\n\tfmt.Println(exampleAST(187, \"\\U00100001 ( _Bool )\") == (*AbstractDeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleAbstractDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(188, \"\\U00100001 ( _Bool * )\"))\n\t// Output:\n\t// &cc.AbstractDeclaratorOpt{\n\t// · AbstractDeclarator: &cc.AbstractDeclarator{\n\t// · · Pointer: &cc.Pointer{\n\t// · · · Token: example188.c:1:10: '*',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExpressionList() {\n\tfmt.Println(exampleAST(8, \"\\U00100001 'a' ( 'b' )\"))\n\t// Output:\n\t// &cc.ArgumentExpressionList{\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example8.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExpressionList_case1() {\n\tfmt.Println(exampleAST(9, \"\\U00100001 'a' ( 'b' , 'c' )\"))\n\t// Output:\n\t// &cc.ArgumentExpressionList{\n\t// · ArgumentExpressionList: &cc.ArgumentExpressionList{\n\t// · · Case: 1,\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example9.c:1:14: CHARCONST \"'c'\",\n\t// · · },\n\t// · · Token: example9.c:1:12: ',',\n\t// · },\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example9.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExpressionListOpt() {\n\tfmt.Println(exampleAST(10, \"\\U00100001 'a' ( )\") == (*ArgumentExpressionListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleArgumentExpressionListOpt_case1() {\n\tfmt.Println(exampleAST(11, \"\\U00100001 'a' ( 'b' )\"))\n\t// Output:\n\t// &cc.ArgumentExpressionListOpt{\n\t// · ArgumentExpressionList: &cc.ArgumentExpressionList{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example11.c:1:8: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleAssemblerInstructions() {\n\tfmt.Println(exampleAST(265, \"\\U00100002 asm ( \\\"a\\\" )\"))\n\t// Output:\n\t// &cc.AssemblerInstructions{\n\t// · Token: example265.c:1:8: STRINGLITERAL \"\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleAssemblerInstructions_case1() {\n\tfmt.Println(exampleAST(266, \"\\U00100002 asm ( \\\"a\\\" \\\"b\\\" )\"))\n\t// Output:\n\t// &cc.AssemblerInstructions{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Case: 1,\n\t// · · Token: example266.c:1:12: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · Token: example266.c:1:8: STRINGLITERAL \"\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleAssemblerOperand() {\n\tfmt.Println(exampleAST(270, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) )\"))\n\t// Output:\n\t// &cc.AssemblerOperand{\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example270.c:1:22: CHARCONST \"'d'\",\n\t// · },\n\t// · Token: example270.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · Token2: example270.c:1:20: '(',\n\t// · Token3: example270.c:1:26: ')',\n\t// }\n}\n\nfunc ExampleAssemblerOperands() {\n\tfmt.Println(exampleAST(271, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) )\"))\n\t// Output:\n\t// &cc.AssemblerOperands{\n\t// · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example271.c:1:22: CHARCONST \"'d'\",\n\t// · · },\n\t// · · Token: example271.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · Token2: example271.c:1:20: '(',\n\t// · · Token3: example271.c:1:26: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleAssemblerOperands_case1() {\n\tfmt.Println(exampleAST(272, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) , \\\"e\\\" ( 'f' ) )\"))\n\t// Output:\n\t// &cc.AssemblerOperands{\n\t// · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example272.c:1:22: CHARCONST \"'d'\",\n\t// · · },\n\t// · · Token: example272.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · Token2: example272.c:1:20: '(',\n\t// · · Token3: example272.c:1:26: ')',\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example272.c:1:36: CHARCONST \"'f'\",\n\t// · · · },\n\t// · · · Token: example272.c:1:30: STRINGLITERAL \"\\\"e\\\"\",\n\t// · · · Token2: example272.c:1:34: '(',\n\t// · · · Token3: example272.c:1:40: ')',\n\t// · · },\n\t// · · Case: 1,\n\t// · · Token: example272.c:1:28: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleAssemblerStatement() {\n\tfmt.Println(exampleAST(277, \"\\U00100002 a asm ( \\\"b\\\" ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · BasicAssemblerStatement: &cc.BasicAssemblerStatement{\n\t// · · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · · Token: example277.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · · },\n\t// · · Token: example277.c:1:4: ASM \"asm\",\n\t// · · Token2: example277.c:1:8: '(',\n\t// · · Token3: example277.c:1:14: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case1() {\n\tfmt.Println(exampleAST(278, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example278.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example278.c:1:22: CHARCONST \"'d'\",\n\t// · · · },\n\t// · · · Token: example278.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · · Token2: example278.c:1:20: '(',\n\t// · · · Token3: example278.c:1:26: ')',\n\t// · · },\n\t// · },\n\t// · Case: 1,\n\t// · Token: example278.c:1:4: ASM \"asm\",\n\t// · Token2: example278.c:1:8: '(',\n\t// · Token3: example278.c:1:14: ':',\n\t// · Token4: example278.c:1:28: ')',\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case2() {\n\tfmt.Println(exampleAST(279, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) : \\\"e\\\" ( 'f' ) ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example279.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example279.c:1:22: CHARCONST \"'d'\",\n\t// · · · },\n\t// · · · Token: example279.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · · Token2: example279.c:1:20: '(',\n\t// · · · Token3: example279.c:1:26: ')',\n\t// · · },\n\t// · },\n\t// · AssemblerOperands2: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example279.c:1:36: CHARCONST \"'f'\",\n\t// · · · },\n\t// · · · Token: example279.c:1:30: STRINGLITERAL \"\\\"e\\\"\",\n\t// · · · Token2: example279.c:1:34: '(',\n\t// · · · Token3: example279.c:1:40: ')',\n\t// · · },\n\t// · },\n\t// · Case: 2,\n\t// · Token: example279.c:1:4: ASM \"asm\",\n\t// · Token2: example279.c:1:8: '(',\n\t// · Token3: example279.c:1:14: ':',\n\t// · Token4: example279.c:1:28: ':',\n\t// · Token5: example279.c:1:42: ')',\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case3() {\n\tfmt.Println(exampleAST(280, \"\\U00100002 a asm ( \\\"b\\\" : \\\"c\\\" ( 'd' ) : \\\"e\\\" ( 'f' ) : \\\"g\\\" ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example280.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example280.c:1:22: CHARCONST \"'d'\",\n\t// · · · },\n\t// · · · Token: example280.c:1:16: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · · Token2: example280.c:1:20: '(',\n\t// · · · Token3: example280.c:1:26: ')',\n\t// · · },\n\t// · },\n\t// · AssemblerOperands2: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example280.c:1:36: CHARCONST \"'f'\",\n\t// · · · },\n\t// · · · Token: example280.c:1:30: STRINGLITERAL \"\\\"e\\\"\",\n\t// · · · Token2: example280.c:1:34: '(',\n\t// · · · Token3: example280.c:1:40: ')',\n\t// · · },\n\t// · },\n\t// · Case: 3,\n\t// · Clobbers: &cc.Clobbers{\n\t// · · Token: example280.c:1:44: STRINGLITERAL \"\\\"g\\\"\",\n\t// · },\n\t// · Token: example280.c:1:4: ASM \"asm\",\n\t// · Token2: example280.c:1:8: '(',\n\t// · Token3: example280.c:1:14: ':',\n\t// · Token4: example280.c:1:28: ':',\n\t// · Token5: example280.c:1:42: ':',\n\t// · Token6: example280.c:1:48: ')',\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case4() {\n\tfmt.Println(exampleAST(281, \"\\U00100002 a asm goto ( \\\"b\\\" : : \\\"c\\\" ( 'd' ) : \\\"e\\\" : f ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example281.c:1:15: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example281.c:1:29: CHARCONST \"'d'\",\n\t// · · · },\n\t// · · · Token: example281.c:1:23: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · · Token2: example281.c:1:27: '(',\n\t// · · · Token3: example281.c:1:33: ')',\n\t// · · },\n\t// · },\n\t// · Case: 4,\n\t// · Clobbers: &cc.Clobbers{\n\t// · · Token: example281.c:1:37: STRINGLITERAL \"\\\"e\\\"\",\n\t// · },\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Token: example281.c:1:43: IDENTIFIER \"f\",\n\t// · },\n\t// · Token: example281.c:1:4: ASM \"asm\",\n\t// · Token2: example281.c:1:8: GOTO \"goto\",\n\t// · Token3: example281.c:1:13: '(',\n\t// · Token4: example281.c:1:19: ':',\n\t// · Token5: example281.c:1:21: ':',\n\t// · Token6: example281.c:1:35: ':',\n\t// · Token7: example281.c:1:41: ':',\n\t// · Token8: example281.c:1:45: ')',\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case5() {\n\tfmt.Println(exampleAST(282, \"\\U00100002 a asm ( \\\"b\\\" : ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example282.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · Case: 5,\n\t// · Token: example282.c:1:4: ASM \"asm\",\n\t// · Token2: example282.c:1:8: '(',\n\t// · Token3: example282.c:1:14: ':',\n\t// · Token4: example282.c:1:16: ')',\n\t// }\n}\n\nfunc ExampleAssemblerStatement_case6() {\n\tfmt.Println(exampleAST(283, \"\\U00100002 a asm ( \\\"b\\\" : : \\\"c\\\" ( 'd' ) ) !\"))\n\t// Output:\n\t// &cc.AssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example283.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · },\n\t// · AssemblerOperands: &cc.AssemblerOperands{\n\t// · · AssemblerOperand: &cc.AssemblerOperand{\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Case: 1,\n\t// · · · · Token: example283.c:1:24: CHARCONST \"'d'\",\n\t// · · · },\n\t// · · · Token: example283.c:1:18: STRINGLITERAL \"\\\"c\\\"\",\n\t// · · · Token2: example283.c:1:22: '(',\n\t// · · · Token3: example283.c:1:28: ')',\n\t// · · },\n\t// · },\n\t// · Case: 6,\n\t// · Token: example283.c:1:4: ASM \"asm\",\n\t// · Token2: example283.c:1:8: '(',\n\t// · Token3: example283.c:1:14: ':',\n\t// · Token4: example283.c:1:16: ':',\n\t// · Token5: example283.c:1:30: ')',\n\t// }\n}\n\nfunc ExampleAssemblerSymbolicNameOpt() {\n\tfmt.Println(exampleAST(273, \"\\U00100002 a asm goto ( \\\"b\\\" : : \\\"c\\\"\") == (*AssemblerSymbolicNameOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleAssemblerSymbolicNameOpt_case1() {\n\tfmt.Println(exampleAST(274, \"\\U00100002 a asm ( \\\"b\\\" : [ c ] \\\"d\\\"\"))\n\t// Output:\n\t// &cc.AssemblerSymbolicNameOpt{\n\t// · Token: example274.c:1:16: '[',\n\t// · Token2: example274.c:1:18: IDENTIFIER \"c\",\n\t// · Token3: example274.c:1:20: ']',\n\t// }\n}\n\nfunc ExampleBasicAssemblerStatement() {\n\tfmt.Println(exampleAST(267, \"\\U00100002 asm ( \\\"a\\\" ) !\"))\n\t// Output:\n\t// &cc.BasicAssemblerStatement{\n\t// · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · Token: example267.c:1:8: STRINGLITERAL \"\\\"a\\\"\",\n\t// · },\n\t// · Token: example267.c:1:2: ASM \"asm\",\n\t// · Token2: example267.c:1:6: '(',\n\t// · Token3: example267.c:1:12: ')',\n\t// }\n}\n\nfunc ExampleBlockItem() {\n\tfmt.Println(exampleAST(230, \"\\U00100001 ( { auto ; !\"))\n\t// Output:\n\t// &cc.BlockItem{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example230.c:1:6: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example230.c:1:11: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItem_case1() {\n\tfmt.Println(exampleAST(231, \"\\U00100001 ( { ; !\"))\n\t// Output:\n\t// &cc.BlockItem{\n\t// · Case: 1,\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example231.c:1:6: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemList() {\n\tfmt.Println(exampleAST(226, \"\\U00100001 ( { ; !\"))\n\t// Output:\n\t// &cc.BlockItemList{\n\t// · BlockItem: &cc.BlockItem{\n\t// · · Case: 1,\n\t// · · Statement: &cc.Statement{\n\t// · · · Case: 2,\n\t// · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · Token: example226.c:1:6: ';',\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemList_case1() {\n\tfmt.Println(exampleAST(227, \"\\U00100001 ( { ; ; !\"))\n\t// Output:\n\t// &cc.BlockItemList{\n\t// · BlockItem: &cc.BlockItem{\n\t// · · Case: 1,\n\t// · · Statement: &cc.Statement{\n\t// · · · Case: 2,\n\t// · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · Token: example227.c:1:6: ';',\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · BlockItemList: &cc.BlockItemList{\n\t// · · BlockItem: &cc.BlockItem{\n\t// · · · Case: 1,\n\t// · · · Statement: &cc.Statement{\n\t// · · · · Case: 2,\n\t// · · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · · Token: example227.c:1:8: ';',\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Case: 1,\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemListOpt() {\n\tfmt.Println(exampleAST(228, \"\\U00100001 ( { }\") == (*BlockItemListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleBlockItemListOpt_case1() {\n\tfmt.Println(exampleAST(229, \"\\U00100001 ( { ; }\"))\n\t// Output:\n\t// &cc.BlockItemListOpt{\n\t// · BlockItemList: &cc.BlockItemList{\n\t// · · BlockItem: &cc.BlockItem{\n\t// · · · Case: 1,\n\t// · · · Statement: &cc.Statement{\n\t// · · · · Case: 2,\n\t// · · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · · Token: example229.c:1:6: ';',\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleClobbers() {\n\tfmt.Println(exampleAST(275, \"\\U00100002 a asm goto ( \\\"b\\\" : : \\\"c\\\" ( 'd' ) : \\\"e\\\" )\"))\n\t// Output:\n\t// &cc.Clobbers{\n\t// · Token: example275.c:1:37: STRINGLITERAL \"\\\"e\\\"\",\n\t// }\n}\n\nfunc ExampleClobbers_case1() {\n\tfmt.Println(exampleAST(276, \"\\U00100002 a asm goto ( \\\"b\\\" : : \\\"c\\\" ( 'd' ) : \\\"e\\\" , \\\"f\\\" )\"))\n\t// Output:\n\t// &cc.Clobbers{\n\t// · Clobbers: &cc.Clobbers{\n\t// · · Case: 1,\n\t// · · Token: example276.c:1:41: ',',\n\t// · · Token2: example276.c:1:43: STRINGLITERAL \"\\\"f\\\"\",\n\t// · },\n\t// · Token: example276.c:1:37: STRINGLITERAL \"\\\"e\\\"\",\n\t// }\n}\n\nfunc ExampleCommaOpt() {\n\tfmt.Println(exampleAST(135, \"\\U00100002 auto a = { }\") == (*CommaOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleCommaOpt_case1() {\n\tfmt.Println(exampleAST(136, \"\\U00100002 auto a = { , }\"))\n\t// Output:\n\t// &cc.CommaOpt{\n\t// · Token: example136.c:1:13: ',',\n\t// }\n}\n\nfunc ExampleCompoundStatement() {\n\tfmt.Println(exampleAST(225, \"\\U00100001 ( { }\"))\n\t// Output:\n\t// &cc.CompoundStatement{\n\t// · Token: example225.c:1:4: '{',\n\t// · Token2: example225.c:1:6: '}',\n\t// }\n}\n\nfunc ExampleConstantExpression() {\n\tfmt.Println(exampleAST(79, \"\\U00100001 'a'\"))\n\t// Output:\n\t// &cc.ConstantExpression{\n\t// · Type: int,\n\t// · Value: 97,\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Case: 1,\n\t// · · Token: example79.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleControlLine() {\n\tfmt.Println(exampleAST(307, \"\\U00100000 \\n#define a \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · ReplacementList: []xc.Token{ // len 1\n\t// · · 0: example307.c:2:10: ' ',\n\t// · },\n\t// · Token: example307.c:2:2: PPDEFINE,\n\t// · Token2: example307.c:2:9: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleControlLine_case01() {\n\tfmt.Println(exampleAST(308, \"\\U00100000 \\n#define a( ... ) \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 1,\n\t// · ReplacementList: []xc.Token{ // len 1\n\t// · · 0: example308.c:2:17: ' ',\n\t// · },\n\t// · Token: example308.c:2:2: PPDEFINE,\n\t// · Token2: example308.c:2:9: IDENTIFIER_LPAREN \"a(\",\n\t// · Token3: example308.c:2:12: DDD,\n\t// · Token4: example308.c:2:16: ')',\n\t// }\n}\n\nfunc ExampleControlLine_case02() {\n\tfmt.Println(exampleAST(309, \"\\U00100000 \\n#define a( b , ... ) \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 2,\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Token: example309.c:2:12: IDENTIFIER \"b\",\n\t// · },\n\t// · ReplacementList: []xc.Token{ // len 1\n\t// · · 0: example309.c:2:21: ' ',\n\t// · },\n\t// · Token: example309.c:2:2: PPDEFINE,\n\t// · Token2: example309.c:2:9: IDENTIFIER_LPAREN \"a(\",\n\t// · Token3: example309.c:2:14: ',',\n\t// · Token4: example309.c:2:16: DDD,\n\t// · Token5: example309.c:2:20: ')',\n\t// }\n}\n\nfunc ExampleControlLine_case03() {\n\tfmt.Println(exampleAST(310, \"\\U00100000 \\n#define a( ) \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 3,\n\t// · ReplacementList: []xc.Token{ // len 1\n\t// · · 0: example310.c:2:13: ' ',\n\t// · },\n\t// · Token: example310.c:2:2: PPDEFINE,\n\t// · Token2: example310.c:2:9: IDENTIFIER_LPAREN \"a(\",\n\t// · Token3: example310.c:2:12: ')',\n\t// }\n}\n\nfunc ExampleControlLine_case04() {\n\tfmt.Println(exampleAST(311, \"\\U00100000 \\n#error \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 4,\n\t// · PPTokenListOpt: []xc.Token{ // len 1\n\t// · · 0: example311.c:2:7: ' ',\n\t// · },\n\t// · Token: example311.c:2:2: PPERROR,\n\t// }\n}\n\nfunc ExampleControlLine_case05() {\n\tfmt.Println(exampleAST(312, \"\\U00100000 \\n#\"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 5,\n\t// · Token: example312.c:2:2: PPHASH_NL,\n\t// }\n}\n\nfunc ExampleControlLine_case06() {\n\tfmt.Println(exampleAST(313, \"\\U00100000 \\n#include other_a \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 6,\n\t// · PPTokenList: []xc.Token{ // len 3\n\t// · · 0: example313.c:2:9: ' ',\n\t// · · 1: example313.c:2:10: IDENTIFIER \"other_a\",\n\t// · · 2: example313.c:2:17: ' ',\n\t// · },\n\t// · Token: example313.c:2:2: PPINCLUDE,\n\t// · Token2: example313.c:2:18: '\\n',\n\t// }\n}\n\nfunc ExampleControlLine_case07() {\n\tfmt.Println(exampleAST(314, \"\\U00100000 \\n#line other_a \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 7,\n\t// · PPTokenList: []xc.Token{ // len 3\n\t// · · 0: example314.c:2:6: ' ',\n\t// · · 1: example314.c:2:7: IDENTIFIER \"other_a\",\n\t// · · 2: example314.c:2:14: ' ',\n\t// · },\n\t// · Token: example314.c:2:2: PPLINE,\n\t// · Token2: example314.c:2:15: '\\n',\n\t// }\n}\n\nfunc ExampleControlLine_case08() {\n\tfmt.Println(exampleAST(315, \"\\U00100000 \\n#pragma \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 8,\n\t// · PPTokenListOpt: []xc.Token{ // len 1\n\t// · · 0: example315.c:2:8: ' ',\n\t// · },\n\t// · Token: example315.c:2:2: PPPRAGMA,\n\t// }\n}\n\nfunc ExampleControlLine_case09() {\n\tfmt.Println(exampleAST(316, \"\\U00100000 \\n#undef foo\"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 9,\n\t// · Token: example316.c:2:2: PPUNDEF,\n\t// · Token2: example316.c:2:8: IDENTIFIER \"foo\",\n\t// · Token3: example316.c:2:11: '\\n',\n\t// }\n}\n\nfunc ExampleControlLine_case10() {\n\tfmt.Println(exampleAST(317, \"\\U00100000 \\n#define a( b ... ) \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 10,\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Token: example317.c:2:12: IDENTIFIER \"b\",\n\t// · },\n\t// · ReplacementList: []xc.Token{ // len 1\n\t// · · 0: example317.c:2:19: ' ',\n\t// · },\n\t// · Token: example317.c:2:2: PPDEFINE,\n\t// · Token2: example317.c:2:9: IDENTIFIER_LPAREN \"a(\",\n\t// · Token3: example317.c:2:14: DDD,\n\t// · Token4: example317.c:2:18: ')',\n\t// }\n}\n\nfunc ExampleControlLine_case11() {\n\tfmt.Println(exampleAST(318, \"\\U00100000 \\n#define \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 11,\n\t// · Token: example318.c:2:2: PPDEFINE,\n\t// · Token2: example318.c:2:9: '\\n',\n\t// }\n}\n\nfunc ExampleControlLine_case12() {\n\tfmt.Println(exampleAST(319, \"\\U00100000 \\n#undef foo(bar)\"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 12,\n\t// · PPTokenList: []xc.Token{ // len 3\n\t// · · 0: example319.c:2:11: '(',\n\t// · · 1: example319.c:2:12: IDENTIFIER \"bar\",\n\t// · · 2: example319.c:2:15: ')',\n\t// · },\n\t// · Token: example319.c:2:2: PPUNDEF,\n\t// · Token2: example319.c:2:8: IDENTIFIER \"foo\",\n\t// · Token3: example319.c:2:16: '\\n',\n\t// }\n}\n\nfunc ExampleControlLine_case13() {\n\tfmt.Println(exampleAST(320, \"\\U00100000 \\n#include_next other_a \"))\n\t// Output:\n\t// &cc.ControlLine{\n\t// · Case: 13,\n\t// · PPTokenList: []xc.Token{ // len 3\n\t// · · 0: example320.c:2:14: ' ',\n\t// · · 1: example320.c:2:15: IDENTIFIER \"other_a\",\n\t// · · 2: example320.c:2:22: ' ',\n\t// · },\n\t// · Token: example320.c:2:2: PPINCLUDE_NEXT,\n\t// · Token2: example320.c:2:23: '\\n',\n\t// }\n}\n\nfunc ExampleDeclaration() {\n\tfmt.Println(exampleAST(80, \"\\U00100002 auto ;\"))\n\t// Output:\n\t// &cc.Declaration{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Case: 3,\n\t// · · · Token: example80.c:1:2: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Token: example80.c:1:7: ';',\n\t// }\n}\n\nfunc ExampleDeclaration_case1() {\n\tfmt.Println(exampleAST(81, \"\\U00100002 _Static_assert ( 'a' , \\\"b\\\" ) ;\"))\n\t// Output:\n\t// &cc.Declaration{\n\t// · Case: 1,\n\t// · StaticAssertDeclaration: &cc.StaticAssertDeclaration{\n\t// · · ConstantExpression: &cc.ConstantExpression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Type: int,\n\t// · · · · Value: 97,\n\t// · · · · Case: 1,\n\t// · · · · Token: example81.c:1:19: CHARCONST \"'a'\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example81.c:1:2: STATIC_ASSERT \"_Static_assert\",\n\t// · · Token2: example81.c:1:17: '(',\n\t// · · Token3: example81.c:1:23: ',',\n\t// · · Token4: example81.c:1:25: STRINGLITERAL \"\\\"b\\\"\",\n\t// · · Token5: example81.c:1:29: ')',\n\t// · · Token6: example81.c:1:31: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationList() {\n\tfmt.Println(exampleAST(260, \"\\U00100002 a auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationList{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example260.c:1:4: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example260.c:1:9: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationList_case1() {\n\tfmt.Println(exampleAST(261, \"\\U00100002 a auto ; auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationList{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example261.c:1:4: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example261.c:1:9: ';',\n\t// · },\n\t// · DeclarationList: &cc.DeclarationList{\n\t// · · Case: 1,\n\t// · · Declaration: &cc.Declaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example261.c:1:11: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: example261.c:1:16: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationListOpt() {\n\tfmt.Println(exampleAST(262, \"\\U00100002 a {\") == (*DeclarationListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclarationListOpt_case1() {\n\tfmt.Println(exampleAST(264, \"\\U00100002 a auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationListOpt{\n\t// · DeclarationList: &cc.DeclarationList{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example264.c:1:4: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: example264.c:1:9: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers() {\n\tfmt.Println(exampleAST(82, \"\\U00100002 auto (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · Case: 3,\n\t// · · Token: example82.c:1:2: AUTO \"auto\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_case1() {\n\tfmt.Println(exampleAST(83, \"\\U00100002 _Bool (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 1,\n\t// · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · Case: 9,\n\t// · · Token: example83.c:1:2: BOOL \"_Bool\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_case2() {\n\tfmt.Println(exampleAST(84, \"\\U00100002 const (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 2,\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: example84.c:1:2: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_case3() {\n\tfmt.Println(exampleAST(85, \"\\U00100002 inline (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 3,\n\t// · FunctionSpecifier: &cc.FunctionSpecifier{\n\t// · · Token: example85.c:1:2: INLINE \"inline\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiersOpt() {\n\tfmt.Println(exampleAST(86, \"\\U00100002 auto (\") == (*DeclarationSpecifiersOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclarationSpecifiersOpt_case1() {\n\tfmt.Println(exampleAST(87, \"\\U00100002 auto auto (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiersOpt{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Case: 3,\n\t// · · · Token: example87.c:1:7: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarator() {\n\tfmt.Println(exampleAST(149, \"\\U00100002 a )\"))\n\t// Output:\n\t// &cc.Declarator{\n\t// · Linkage: None,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example149.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclaratorOpt() {\n\tfmt.Println(exampleAST(150, \"\\U00100002 struct { _Bool :\") == (*DeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(151, \"\\U00100002 struct { _Bool a :\"))\n\t// Output:\n\t// &cc.DeclaratorOpt{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example151.c:1:17: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDesignation() {\n\tfmt.Println(exampleAST(207, \"\\U00100002 auto a = { . b = !\"))\n\t// Output:\n\t// &cc.Designation{\n\t// · DesignatorList: &cc.DesignatorList{\n\t// · · Designator: &cc.Designator{\n\t// · · · Case: 1,\n\t// · · · Token: example207.c:1:13: '.',\n\t// · · · Token2: example207.c:1:15: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// · Token: example207.c:1:17: '=',\n\t// }\n}\n\nfunc ExampleDesignationOpt() {\n\tfmt.Println(exampleAST(208, \"\\U00100002 auto a = { !\") == (*DesignationOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDesignationOpt_case1() {\n\tfmt.Println(exampleAST(209, \"\\U00100002 auto a = { . b = !\"))\n\t// Output:\n\t// &cc.DesignationOpt{\n\t// · Designation: &cc.Designation{\n\t// · · DesignatorList: &cc.DesignatorList{\n\t// · · · Designator: &cc.Designator{\n\t// · · · · Case: 1,\n\t// · · · · Token: example209.c:1:13: '.',\n\t// · · · · Token2: example209.c:1:15: IDENTIFIER \"b\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example209.c:1:17: '=',\n\t// · },\n\t// }\n}\n\nfunc ExampleDesignator() {\n\tfmt.Println(exampleAST(212, \"\\U00100002 auto a = { [ 'b' ] .\"))\n\t// Output:\n\t// &cc.Designator{\n\t// · ConstantExpression: &cc.ConstantExpression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 98,\n\t// · · · Case: 1,\n\t// · · · Token: example212.c:1:15: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: example212.c:1:13: '[',\n\t// · Token2: example212.c:1:19: ']',\n\t// }\n}\n\nfunc ExampleDesignator_case1() {\n\tfmt.Println(exampleAST(213, \"\\U00100002 auto a = { . b .\"))\n\t// Output:\n\t// &cc.Designator{\n\t// · Case: 1,\n\t// · Token: example213.c:1:13: '.',\n\t// · Token2: example213.c:1:15: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleDesignatorList() {\n\tfmt.Println(exampleAST(210, \"\\U00100002 auto a = { . b .\"))\n\t// Output:\n\t// &cc.DesignatorList{\n\t// · Designator: &cc.Designator{\n\t// · · Case: 1,\n\t// · · Token: example210.c:1:13: '.',\n\t// · · Token2: example210.c:1:15: IDENTIFIER \"b\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDesignatorList_case1() {\n\tfmt.Println(exampleAST(211, \"\\U00100002 auto a = { . b . c .\"))\n\t// Output:\n\t// &cc.DesignatorList{\n\t// · Designator: &cc.Designator{\n\t// · · Case: 1,\n\t// · · Token: example211.c:1:13: '.',\n\t// · · Token2: example211.c:1:15: IDENTIFIER \"b\",\n\t// · },\n\t// · DesignatorList: &cc.DesignatorList{\n\t// · · Case: 1,\n\t// · · Designator: &cc.Designator{\n\t// · · · Case: 1,\n\t// · · · Token: example211.c:1:17: '.',\n\t// · · · Token2: example211.c:1:19: IDENTIFIER \"c\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator() {\n\tfmt.Println(exampleAST(189, \"\\U00100001 ( _Bool ( * ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · AbstractDeclarator: &cc.AbstractDeclarator{\n\t// · · Pointer: &cc.Pointer{\n\t// · · · Token: example189.c:1:12: '*',\n\t// · · },\n\t// · },\n\t// · Token: example189.c:1:10: '(',\n\t// · Token2: example189.c:1:14: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case1() {\n\tfmt.Println(exampleAST(190, \"\\U00100001 ( _Bool [ ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 1,\n\t// · Token: example190.c:1:10: '[',\n\t// · Token2: example190.c:1:12: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case2() {\n\tfmt.Println(exampleAST(191, \"\\U00100001 ( _Bool [ const ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 2,\n\t// · Token: example191.c:1:10: '[',\n\t// · Token2: example191.c:1:18: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: example191.c:1:12: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case3() {\n\tfmt.Println(exampleAST(192, \"\\U00100001 ( _Bool [ static 'a' ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 3,\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Case: 1,\n\t// · · Token: example192.c:1:19: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example192.c:1:10: '[',\n\t// · Token2: example192.c:1:12: STATIC \"static\",\n\t// · Token3: example192.c:1:23: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case4() {\n\tfmt.Println(exampleAST(193, \"\\U00100001 ( _Bool [ const static 'a' ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 4,\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Case: 1,\n\t// · · Token: example193.c:1:25: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example193.c:1:10: '[',\n\t// · Token2: example193.c:1:18: STATIC \"static\",\n\t// · Token3: example193.c:1:29: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: example193.c:1:12: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case5() {\n\tfmt.Println(exampleAST(194, \"\\U00100001 ( _Bool [ * ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 5,\n\t// · Token: example194.c:1:10: '[',\n\t// · Token2: example194.c:1:12: '*',\n\t// · Token3: example194.c:1:14: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case6() {\n\tfmt.Println(exampleAST(196, \"\\U00100001 ( _Bool ( ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 6,\n\t// · Token: example196.c:1:10: '(',\n\t// · Token2: example196.c:1:12: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_case7() {\n\tfmt.Println(exampleAST(198, \"\\U00100001 ( _Bool ( ) ( ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 7,\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 6,\n\t// · · Token: example198.c:1:10: '(',\n\t// · · Token2: example198.c:1:12: ')',\n\t// · },\n\t// · Token: example198.c:1:14: '(',\n\t// · Token2: example198.c:1:16: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclaratorOpt() {\n\tfmt.Println(exampleAST(199, \"\\U00100001 ( _Bool [\") == (*DirectAbstractDeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDirectAbstractDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(200, \"\\U00100001 ( _Bool ( ) [\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclaratorOpt{\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 6,\n\t// · · Token: example200.c:1:10: '(',\n\t// · · Token2: example200.c:1:12: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectDeclarator() {\n\tfmt.Println(exampleAST(152, \"\\U00100002 a (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Token: example152.c:1:2: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case1() {\n\tfmt.Println(exampleAST(153, \"\\U00100002 ( a ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 1,\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example153.c:1:4: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · Token: example153.c:1:2: '(',\n\t// · Token2: example153.c:1:6: ')',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case2() {\n\tfmt.Println(exampleAST(154, \"\\U00100002 a [ ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 2,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example154.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: example154.c:1:4: '[',\n\t// · Token2: example154.c:1:6: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case3() {\n\tfmt.Println(exampleAST(155, \"\\U00100002 a [ static 'b' ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 3,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example155.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Case: 1,\n\t// · · Token: example155.c:1:13: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example155.c:1:4: '[',\n\t// · Token2: example155.c:1:6: STATIC \"static\",\n\t// · Token3: example155.c:1:17: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case4() {\n\tfmt.Println(exampleAST(156, \"\\U00100002 a [ const static 'b' ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 4,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example156.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Case: 1,\n\t// · · Token: example156.c:1:19: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example156.c:1:4: '[',\n\t// · Token2: example156.c:1:12: STATIC \"static\",\n\t// · Token3: example156.c:1:23: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: example156.c:1:6: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case5() {\n\tfmt.Println(exampleAST(157, \"\\U00100002 a [ * ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 5,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example157.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: example157.c:1:4: '[',\n\t// · Token2: example157.c:1:6: '*',\n\t// · Token3: example157.c:1:8: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case6() {\n\tfmt.Println(exampleAST(159, \"\\U00100002 a ( auto ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 6,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example159.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · ParameterTypeList: &cc.ParameterTypeList{\n\t// · · ParameterList: &cc.ParameterList{\n\t// · · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · · Case: 1,\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Case: 3,\n\t// · · · · · · Token: example159.c:1:6: AUTO \"auto\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: example159.c:1:4: '(',\n\t// · Token2: example159.c:1:11: ')',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_case7() {\n\tfmt.Println(exampleAST(160, \"\\U00100002 a ( ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: 7,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Token: example160.c:1:2: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: example160.c:1:4: '(',\n\t// · Token2: example160.c:1:6: ')',\n\t// }\n}\n\nfunc ExampleElifGroup() {\n\tfmt.Println(exampleAST(302, \"\\U00100000 \\n#if other_a  \\n#elif other_b  \\n#elif\"))\n\t// Output:\n\t// &cc.ElifGroup{\n\t// · PPTokenList: []xc.Token{ // len 4\n\t// · · 0: example302.c:3:6: ' ',\n\t// · · 1: example302.c:3:7: IDENTIFIER \"other_b\",\n\t// · · 2: example302.c:3:14: ' ',\n\t// · · 3: example302.c:3:16: ' ',\n\t// · },\n\t// · Token: example302.c:3:2: PPELIF,\n\t// · Token2: example302.c:3:16: '\\n',\n\t// }\n}\n\nfunc ExampleElifGroupList() {\n\tfmt.Println(exampleAST(298, \"\\U00100000 \\n#if other_a  \\n#elif other_b  \\n#elif\"))\n\t// Output:\n\t// &cc.ElifGroupList{\n\t// · ElifGroup: &cc.ElifGroup{\n\t// · · PPTokenList: []xc.Token{ // len 4\n\t// · · · 0: example298.c:3:6: ' ',\n\t// · · · 1: example298.c:3:7: IDENTIFIER \"other_b\",\n\t// · · · 2: example298.c:3:14: ' ',\n\t// · · · 3: example298.c:3:16: ' ',\n\t// · · },\n\t// · · Token: example298.c:3:2: PPELIF,\n\t// · · Token2: example298.c:3:16: '\\n',\n\t// · },\n\t// }\n}\n\nfunc ExampleElifGroupList_case1() {\n\tfmt.Println(exampleAST(299, \"\\U00100000 \\n#if other_a  \\n#elif other_b  \\n#elif other_c  \\n#elif\"))\n\t// Output:\n\t// &cc.ElifGroupList{\n\t// · ElifGroup: &cc.ElifGroup{\n\t// · · PPTokenList: []xc.Token{ // len 4\n\t// · · · 0: example299.c:3:6: ' ',\n\t// · · · 1: example299.c:3:7: IDENTIFIER \"other_b\",\n\t// · · · 2: example299.c:3:14: ' ',\n\t// · · · 3: example299.c:3:16: ' ',\n\t// · · },\n\t// · · Token: example299.c:3:2: PPELIF,\n\t// · · Token2: example299.c:3:16: '\\n',\n\t// · },\n\t// · ElifGroupList: &cc.ElifGroupList{\n\t// · · Case: 1,\n\t// · · ElifGroup: &cc.ElifGroup{\n\t// · · · PPTokenList: []xc.Token{ // len 4\n\t// · · · · 0: example299.c:4:6: ' ',\n\t// · · · · 1: example299.c:4:7: IDENTIFIER \"other_c\",\n\t// · · · · 2: example299.c:4:14: ' ',\n\t// · · · · 3: example299.c:4:16: ' ',\n\t// · · · },\n\t// · · · Token: example299.c:4:2: PPELIF,\n\t// · · · Token2: example299.c:4:16: '\\n',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleElifGroupListOpt() {\n\tfmt.Println(exampleAST(300, \"\\U00100000 \\n#if other_a  \\n#else\") == (*ElifGroupListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleElifGroupListOpt_case1() {\n\tfmt.Println(exampleAST(301, \"\\U00100000 \\n#if other_a  \\n#elif other_b  \\n#else\"))\n\t// Output:\n\t// &cc.ElifGroupListOpt{\n\t// · ElifGroupList: &cc.ElifGroupList{\n\t// · · ElifGroup: &cc.ElifGroup{\n\t// · · · PPTokenList: []xc.Token{ // len 4\n\t// · · · · 0: example301.c:3:6: ' ',\n\t// · · · · 1: example301.c:3:7: IDENTIFIER \"other_b\",\n\t// · · · · 2: example301.c:3:14: ' ',\n\t// · · · · 3: example301.c:3:16: ' ',\n\t// · · · },\n\t// · · · Token: example301.c:3:2: PPELIF,\n\t// · · · Token2: example301.c:3:16: '\\n',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleElseGroup() {\n\tfmt.Println(exampleAST(303, \"\\U00100000 \\n#if other_a  \\n#else  \\n#endif\"))\n\t// Output:\n\t// &cc.ElseGroup{\n\t// · Token: example303.c:3:2: PPELSE,\n\t// · Token2: example303.c:3:8: '\\n',\n\t// }\n}\n\nfunc ExampleElseGroupOpt() {\n\tfmt.Println(exampleAST(304, \"\\U00100000 \\n#if other_a  \\n#endif\") == (*ElseGroupOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleElseGroupOpt_case1() {\n\tfmt.Println(exampleAST(305, \"\\U00100000 \\n#if other_a  \\n#else  \\n#endif\"))\n\t// Output:\n\t// &cc.ElseGroupOpt{\n\t// · ElseGroup: &cc.ElseGroup{\n\t// · · Token: example305.c:3:2: PPELSE,\n\t// · · Token2: example305.c:3:8: '\\n',\n\t// · },\n\t// }\n}\n\nfunc ExampleEndifLine() {\n\tfmt.Println(exampleAST(306, \"\\U00100000 \\n#if other_a  \\n#endif\"))\n\t// Output:\n\t// &cc.EndifLine{\n\t// · Token: example306.c:3:2: PPENDIF,\n\t// }\n}\n\nfunc ExampleEnumSpecifier() {\n\tfmt.Println(exampleAST(138, \"\\U00100002 enum { a } (\"))\n\t// Output:\n\t// &cc.EnumSpecifier{\n\t// · EnumeratorList: &cc.EnumeratorList{\n\t// · · Enumerator: &cc.Enumerator{\n\t// · · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · · Token: example138.c:1:9: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: example138.c:1:2: ENUM \"enum\",\n\t// · Token2: example138.c:1:7: '{',\n\t// · Token3: example138.c:1:11: '}',\n\t// }\n}\n\nfunc ExampleEnumSpecifier_case1() {\n\tfmt.Println(exampleAST(139, \"\\U00100002 enum a (\"))\n\t// Output:\n\t// &cc.EnumSpecifier{\n\t// · Case: 1,\n\t// · Token: example139.c:1:2: ENUM \"enum\",\n\t// · Token2: example139.c:1:7: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleEnumerationConstant() {\n\tfmt.Println(exampleAST(7, \"\\U00100002 enum { a ,\"))\n\t// Output:\n\t// &cc.EnumerationConstant{\n\t// · Token: example7.c:1:9: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleEnumerator() {\n\tfmt.Println(exampleAST(142, \"\\U00100002 enum { a ,\"))\n\t// Output:\n\t// &cc.Enumerator{\n\t// · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · Token: example142.c:1:9: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleEnumerator_case1() {\n\tfmt.Println(exampleAST(143, \"\\U00100002 enum { a = 'b' ,\"))\n\t// Output:\n\t// &cc.Enumerator{\n\t// · Value: 98,\n\t// · Case: 1,\n\t// · ConstantExpression: &cc.ConstantExpression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 98,\n\t// · · · Case: 1,\n\t// · · · Token: example143.c:1:13: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · Token: example143.c:1:9: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: example143.c:1:11: '=',\n\t// }\n}\n\nfunc ExampleEnumeratorList() {\n\tfmt.Println(exampleAST(140, \"\\U00100002 enum { a ,\"))\n\t// Output:\n\t// &cc.EnumeratorList{\n\t// · Enumerator: &cc.Enumerator{\n\t// · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · Token: example140.c:1:9: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleEnumeratorList_case1() {\n\tfmt.Println(exampleAST(141, \"\\U00100002 enum { a , b ,\"))\n\t// Output:\n\t// &cc.EnumeratorList{\n\t// · Enumerator: &cc.Enumerator{\n\t// · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · Token: example141.c:1:9: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · EnumeratorList: &cc.EnumeratorList{\n\t// · · Case: 1,\n\t// · · Enumerator: &cc.Enumerator{\n\t// · · · Value: 1,\n\t// · · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · · Token: example141.c:1:13: IDENTIFIER \"b\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example141.c:1:11: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleExpression() {\n\tfmt.Println(exampleAST(12, \"\\U00100001 a\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Token: example12.c:1:2: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleExpression_case01() {\n\tfmt.Println(exampleAST(13, \"\\U00100001 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 1,\n\t// · Token: example13.c:1:2: CHARCONST \"'a'\",\n\t// }\n}\n\nfunc ExampleExpression_case02() {\n\tfmt.Println(exampleAST(14, \"\\U00100001 1.97\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 2,\n\t// · Token: example14.c:1:2: FLOATCONST \"1.97\",\n\t// }\n}\n\nfunc ExampleExpression_case03() {\n\tfmt.Println(exampleAST(15, \"\\U00100001 97\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 3,\n\t// · Token: example15.c:1:2: INTCONST \"97\",\n\t// }\n}\n\nfunc ExampleExpression_case04() {\n\tfmt.Println(exampleAST(16, \"\\U00100001 L'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 4,\n\t// · Token: example16.c:1:2: LONGCHARCONST \"L'a'\",\n\t// }\n}\n\nfunc ExampleExpression_case05() {\n\tfmt.Println(exampleAST(17, \"\\U00100001 L\\\"a\\\"\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 5,\n\t// · Token: example17.c:1:2: LONGSTRINGLITERAL \"L\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleExpression_case06() {\n\tfmt.Println(exampleAST(18, \"\\U00100001 \\\"a\\\"\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 6,\n\t// · Token: example18.c:1:2: STRINGLITERAL \"\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleExpression_case07() {\n\tfmt.Println(exampleAST(19, \"\\U00100001 ( 'a' )\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 7,\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example19.c:1:4: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: example19.c:1:2: '(',\n\t// · Token2: example19.c:1:8: ')',\n\t// }\n}\n\nfunc ExampleExpression_case08() {\n\tfmt.Println(exampleAST(20, \"\\U00100001 'a' [ 'b' ]\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 8,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example20.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example20.c:1:8: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: example20.c:1:6: '[',\n\t// · Token2: example20.c:1:12: ']',\n\t// }\n}\n\nfunc ExampleExpression_case09() {\n\tfmt.Println(exampleAST(21, \"\\U00100001 'a' ( )\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 9,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example21.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example21.c:1:6: '(',\n\t// · Token2: example21.c:1:8: ')',\n\t// }\n}\n\nfunc ExampleExpression_case10() {\n\tfmt.Println(exampleAST(22, \"\\U00100001 'a' . b\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 10,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example22.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example22.c:1:6: '.',\n\t// · Token2: example22.c:1:8: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleExpression_case11() {\n\tfmt.Println(exampleAST(23, \"\\U00100001 'a' -> b\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 11,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example23.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example23.c:1:6: ARROW,\n\t// · Token2: example23.c:1:9: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleExpression_case12() {\n\tfmt.Println(exampleAST(24, \"\\U00100001 'a' ++\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 12,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example24.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example24.c:1:6: INC,\n\t// }\n}\n\nfunc ExampleExpression_case13() {\n\tfmt.Println(exampleAST(25, \"\\U00100001 'a' --\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 13,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example25.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example25.c:1:6: DEC,\n\t// }\n}\n\nfunc ExampleExpression_case14() {\n\tfmt.Println(exampleAST(26, \"\\U00100001 ( _Bool ) { }\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 14,\n\t// · Token: example26.c:1:2: '(',\n\t// · Token2: example26.c:1:10: ')',\n\t// · Token3: example26.c:1:12: '{',\n\t// · Token4: example26.c:1:14: '}',\n\t// · TypeName: &cc.TypeName{\n\t// · · Type: bool,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example26.c:1:4: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpression_case15() {\n\tfmt.Println(exampleAST(27, \"\\U00100001 ++ 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 15,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example27.c:1:5: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example27.c:1:2: INC,\n\t// }\n}\n\nfunc ExampleExpression_case16() {\n\tfmt.Println(exampleAST(28, \"\\U00100001 -- 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 16,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example28.c:1:5: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example28.c:1:2: DEC,\n\t// }\n}\n\nfunc ExampleExpression_case17() {\n\tfmt.Println(exampleAST(29, \"\\U00100001 & 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 17,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example29.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example29.c:1:2: '&',\n\t// }\n}\n\nfunc ExampleExpression_case18() {\n\tfmt.Println(exampleAST(30, \"\\U00100001 * 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 18,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example30.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example30.c:1:2: '*',\n\t// }\n}\n\nfunc ExampleExpression_case19() {\n\tfmt.Println(exampleAST(31, \"\\U00100001 + 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 19,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example31.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example31.c:1:2: '+',\n\t// }\n}\n\nfunc ExampleExpression_case20() {\n\tfmt.Println(exampleAST(32, \"\\U00100001 - 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 20,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example32.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example32.c:1:2: '-',\n\t// }\n}\n\nfunc ExampleExpression_case21() {\n\tfmt.Println(exampleAST(33, \"\\U00100001 ~ 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 21,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example33.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example33.c:1:2: '~',\n\t// }\n}\n\nfunc ExampleExpression_case22() {\n\tfmt.Println(exampleAST(34, \"\\U00100001 ! 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 22,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example34.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example34.c:1:2: '!',\n\t// }\n}\n\nfunc ExampleExpression_case23() {\n\tfmt.Println(exampleAST(35, \"\\U00100001 sizeof 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 23,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example35.c:1:9: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example35.c:1:2: SIZEOF \"sizeof\",\n\t// }\n}\n\nfunc ExampleExpression_case24() {\n\tfmt.Println(exampleAST(36, \"\\U00100001 sizeof ( _Bool )\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 24,\n\t// · Token: example36.c:1:2: SIZEOF \"sizeof\",\n\t// · Token2: example36.c:1:9: '(',\n\t// · Token3: example36.c:1:17: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · Type: bool,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example36.c:1:11: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpression_case25() {\n\tfmt.Println(exampleAST(37, \"\\U00100001 ( _Bool ) 'a'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 25,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example37.c:1:12: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example37.c:1:2: '(',\n\t// · Token2: example37.c:1:10: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · Type: bool,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example37.c:1:4: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpression_case26() {\n\tfmt.Println(exampleAST(38, \"\\U00100001 'a' * 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 26,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example38.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example38.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example38.c:1:6: '*',\n\t// }\n}\n\nfunc ExampleExpression_case27() {\n\tfmt.Println(exampleAST(39, \"\\U00100001 'a' / 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 27,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example39.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example39.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example39.c:1:6: '/',\n\t// }\n}\n\nfunc ExampleExpression_case28() {\n\tfmt.Println(exampleAST(40, \"\\U00100001 'a' % 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 28,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example40.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example40.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example40.c:1:6: '%',\n\t// }\n}\n\nfunc ExampleExpression_case29() {\n\tfmt.Println(exampleAST(41, \"\\U00100001 'a' + 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 29,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example41.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example41.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example41.c:1:6: '+',\n\t// }\n}\n\nfunc ExampleExpression_case30() {\n\tfmt.Println(exampleAST(42, \"\\U00100001 'a' - 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 30,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example42.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example42.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example42.c:1:6: '-',\n\t// }\n}\n\nfunc ExampleExpression_case31() {\n\tfmt.Println(exampleAST(43, \"\\U00100001 'a' << 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 31,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example43.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example43.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example43.c:1:6: LSH,\n\t// }\n}\n\nfunc ExampleExpression_case32() {\n\tfmt.Println(exampleAST(44, \"\\U00100001 'a' >> 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 32,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example44.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example44.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example44.c:1:6: RSH,\n\t// }\n}\n\nfunc ExampleExpression_case33() {\n\tfmt.Println(exampleAST(45, \"\\U00100001 'a' < 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 33,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example45.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example45.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example45.c:1:6: '<',\n\t// }\n}\n\nfunc ExampleExpression_case34() {\n\tfmt.Println(exampleAST(46, \"\\U00100001 'a' > 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 34,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example46.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example46.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example46.c:1:6: '>',\n\t// }\n}\n\nfunc ExampleExpression_case35() {\n\tfmt.Println(exampleAST(47, \"\\U00100001 'a' <= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 35,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example47.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example47.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example47.c:1:6: LEQ,\n\t// }\n}\n\nfunc ExampleExpression_case36() {\n\tfmt.Println(exampleAST(48, \"\\U00100001 'a' >= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 36,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example48.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example48.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example48.c:1:6: GEQ,\n\t// }\n}\n\nfunc ExampleExpression_case37() {\n\tfmt.Println(exampleAST(49, \"\\U00100001 'a' == 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 37,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example49.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example49.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example49.c:1:6: EQ,\n\t// }\n}\n\nfunc ExampleExpression_case38() {\n\tfmt.Println(exampleAST(50, \"\\U00100001 'a' != 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 38,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example50.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example50.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example50.c:1:6: NEQ,\n\t// }\n}\n\nfunc ExampleExpression_case39() {\n\tfmt.Println(exampleAST(51, \"\\U00100001 'a' & 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 39,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example51.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example51.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example51.c:1:6: '&',\n\t// }\n}\n\nfunc ExampleExpression_case40() {\n\tfmt.Println(exampleAST(52, \"\\U00100001 'a' ^ 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 40,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example52.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example52.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example52.c:1:6: '^',\n\t// }\n}\n\nfunc ExampleExpression_case41() {\n\tfmt.Println(exampleAST(53, \"\\U00100001 'a' | 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 41,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example53.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example53.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example53.c:1:6: '|',\n\t// }\n}\n\nfunc ExampleExpression_case42() {\n\tfmt.Println(exampleAST(54, \"\\U00100001 'a' && 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 42,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example54.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example54.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example54.c:1:6: ANDAND,\n\t// }\n}\n\nfunc ExampleExpression_case43() {\n\tfmt.Println(exampleAST(55, \"\\U00100001 'a' || 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 43,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example55.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example55.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example55.c:1:6: OROR,\n\t// }\n}\n\nfunc ExampleExpression_case44() {\n\tfmt.Println(exampleAST(56, \"\\U00100001 'a' ? 'b' : 'c'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 44,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example56.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example56.c:1:14: CHARCONST \"'c'\",\n\t// · },\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example56.c:1:8: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: example56.c:1:6: '?',\n\t// · Token2: example56.c:1:12: ':',\n\t// }\n}\n\nfunc ExampleExpression_case45() {\n\tfmt.Println(exampleAST(57, \"\\U00100001 'a' = 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 45,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example57.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example57.c:1:8: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example57.c:1:6: '=',\n\t// }\n}\n\nfunc ExampleExpression_case46() {\n\tfmt.Println(exampleAST(58, \"\\U00100001 'a' *= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 46,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example58.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example58.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example58.c:1:6: MULASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case47() {\n\tfmt.Println(exampleAST(59, \"\\U00100001 'a' /= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 47,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example59.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example59.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example59.c:1:6: DIVASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case48() {\n\tfmt.Println(exampleAST(60, \"\\U00100001 'a' %= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 48,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example60.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example60.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example60.c:1:6: MODASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case49() {\n\tfmt.Println(exampleAST(61, \"\\U00100001 'a' += 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 49,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example61.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example61.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example61.c:1:6: ADDASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case50() {\n\tfmt.Println(exampleAST(62, \"\\U00100001 'a' -= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 50,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example62.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example62.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example62.c:1:6: SUBASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case51() {\n\tfmt.Println(exampleAST(63, \"\\U00100001 'a' <<= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 51,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example63.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example63.c:1:10: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example63.c:1:6: LSHASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case52() {\n\tfmt.Println(exampleAST(64, \"\\U00100001 'a' >>= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 52,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example64.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example64.c:1:10: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example64.c:1:6: RSHASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case53() {\n\tfmt.Println(exampleAST(65, \"\\U00100001 'a' &= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 53,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example65.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example65.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example65.c:1:6: ANDASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case54() {\n\tfmt.Println(exampleAST(66, \"\\U00100001 'a' ^= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 54,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example66.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example66.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example66.c:1:6: XORASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case55() {\n\tfmt.Println(exampleAST(67, \"\\U00100001 'a' |= 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 55,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example67.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example67.c:1:9: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example67.c:1:6: ORASSIGN,\n\t// }\n}\n\nfunc ExampleExpression_case56() {\n\tfmt.Println(exampleAST(68, \"\\U00100001 _Alignof ( _Bool )\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 56,\n\t// · Token: example68.c:1:2: ALIGNOF \"_Alignof\",\n\t// · Token2: example68.c:1:11: '(',\n\t// · Token3: example68.c:1:19: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · Type: bool,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example68.c:1:13: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpression_case57() {\n\tfmt.Println(exampleAST(69, \"\\U00100001 ( { } )\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 57,\n\t// · CompoundStatement: &cc.CompoundStatement{\n\t// · · Token: example69.c:1:4: '{',\n\t// · · Token2: example69.c:1:6: '}',\n\t// · },\n\t// · Token: example69.c:1:2: '(',\n\t// · Token2: example69.c:1:8: ')',\n\t// }\n}\n\nfunc ExampleExpression_case58() {\n\tfmt.Println(exampleAST(70, \"\\U00100001 && a\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 58,\n\t// · Token: example70.c:1:2: ANDAND,\n\t// · Token2: example70.c:1:5: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleExpression_case59() {\n\tfmt.Println(exampleAST(71, \"\\U00100001 'a' ? : 'b'\"))\n\t// Output:\n\t// &cc.Expression{\n\t// · Case: 59,\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example71.c:1:2: CHARCONST \"'a'\",\n\t// · },\n\t// · Expression2: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example71.c:1:10: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: example71.c:1:6: '?',\n\t// · Token2: example71.c:1:8: ':',\n\t// }\n}\n\nfunc ExampleExpressionList() {\n\tfmt.Println(exampleAST(74, \"\\U00100001 ( 'a' )\"))\n\t// Output:\n\t// &cc.ExpressionList{\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example74.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleExpressionList_case1() {\n\tfmt.Println(exampleAST(75, \"\\U00100001 ( 'a' , 'b' )\"))\n\t// Output:\n\t// &cc.ExpressionList{\n\t// · Expression: &cc.Expression{\n\t// · · Case: 1,\n\t// · · Token: example75.c:1:4: CHARCONST \"'a'\",\n\t// · },\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Case: 1,\n\t// · · Expression: &cc.Expression{\n\t// · · · Case: 1,\n\t// · · · Token: example75.c:1:10: CHARCONST \"'b'\",\n\t// · · },\n\t// · · Token: example75.c:1:8: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleExpressionListOpt() {\n\tfmt.Println(exampleAST(76, \"\\U00100001 ( { ;\") == (*ExpressionListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleExpressionListOpt_case1() {\n\tfmt.Println(exampleAST(77, \"\\U00100001 ( { 'a' )\"))\n\t// Output:\n\t// &cc.ExpressionListOpt{\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example77.c:1:6: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpressionOpt() {\n\tfmt.Println(exampleAST(72, \"\\U00100001 ( _Bool [ ]\") == (*ExpressionOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleExpressionOpt_case1() {\n\tfmt.Println(exampleAST(73, \"\\U00100002 a [ 'b' ]\"))\n\t// Output:\n\t// &cc.ExpressionOpt{\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Case: 1,\n\t// · · Token: example73.c:1:6: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleExpressionStatement() {\n\tfmt.Println(exampleAST(232, \"\\U00100001 ( { ; !\"))\n\t// Output:\n\t// &cc.ExpressionStatement{\n\t// · Token: example232.c:1:6: ';',\n\t// }\n}\n\nfunc ExampleExternalDeclaration() {\n\tfmt.Println(exampleAST(247, \"\\U00100002 a { }\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · FunctionDefinition: &cc.FunctionDefinition{\n\t// · · Case: 1,\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: External,\n\t// · · · Type: int,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Token: example247.c:1:2: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · · FunctionBody: &cc.FunctionBody{\n\t// · · · CompoundStatement: &cc.CompoundStatement{\n\t// · · · · Token: example247.c:1:4: '{',\n\t// · · · · Token2: example247.c:1:6: '}',\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExternalDeclaration_case1() {\n\tfmt.Println(exampleAST(248, \"\\U00100002 auto ;\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · Case: 1,\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example248.c:1:2: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example248.c:1:7: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleExternalDeclaration_case2() {\n\tfmt.Println(exampleAST(249, \"\\U00100002 asm ( \\\"a\\\" ) ;\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · BasicAssemblerStatement: &cc.BasicAssemblerStatement{\n\t// · · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · · Token: example249.c:1:8: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · },\n\t// · · Token: example249.c:1:2: ASM \"asm\",\n\t// · · Token2: example249.c:1:6: '(',\n\t// · · Token3: example249.c:1:12: ')',\n\t// · },\n\t// · Case: 2,\n\t// · Token: example249.c:1:14: ';',\n\t// }\n}\n\nfunc ExampleExternalDeclaration_case3() {\n\tfmt.Println(exampleAST(250, \"\\U00100002 ;\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · Case: 3,\n\t// · Token: example250.c:1:2: ';',\n\t// }\n}\n\nfunc ExampleFunctionBody() {\n\tfmt.Println(exampleAST(257, \"\\U00100002 a { }\"))\n\t// Output:\n\t// &cc.FunctionBody{\n\t// · CompoundStatement: &cc.CompoundStatement{\n\t// · · Token: example257.c:1:4: '{',\n\t// · · Token2: example257.c:1:6: '}',\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionBody_case1() {\n\tfmt.Println(exampleAST(259, \"\\U00100002 a asm ( \\\"b\\\" ) ;\"))\n\t// Output:\n\t// &cc.FunctionBody{\n\t// · AssemblerStatement: &cc.AssemblerStatement{\n\t// · · BasicAssemblerStatement: &cc.BasicAssemblerStatement{\n\t// · · · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · · · Token: example259.c:1:10: STRINGLITERAL \"\\\"b\\\"\",\n\t// · · · },\n\t// · · · Token: example259.c:1:4: ASM \"asm\",\n\t// · · · Token2: example259.c:1:8: '(',\n\t// · · · Token3: example259.c:1:14: ')',\n\t// · · },\n\t// · },\n\t// · Case: 1,\n\t// · Token: example259.c:1:16: ';',\n\t// }\n}\n\nfunc ExampleFunctionDefinition() {\n\tfmt.Println(exampleAST(252, \"\\U00100002 auto a { }\"))\n\t// Output:\n\t// &cc.FunctionDefinition{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Case: 3,\n\t// · · · Token: example252.c:1:2: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · Type: auto int,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example252.c:1:7: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · FunctionBody: &cc.FunctionBody{\n\t// · · CompoundStatement: &cc.CompoundStatement{\n\t// · · · Token: example252.c:1:9: '{',\n\t// · · · Token2: example252.c:1:11: '}',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionDefinition_case1() {\n\tfmt.Println(exampleAST(255, \"\\U00100002 a { }\"))\n\t// Output:\n\t// &cc.FunctionDefinition{\n\t// · Case: 1,\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: External,\n\t// · · Type: int,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example255.c:1:2: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · FunctionBody: &cc.FunctionBody{\n\t// · · CompoundStatement: &cc.CompoundStatement{\n\t// · · · Token: example255.c:1:4: '{',\n\t// · · · Token2: example255.c:1:6: '}',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionSpecifier() {\n\tfmt.Println(exampleAST(147, \"\\U00100002 inline (\"))\n\t// Output:\n\t// &cc.FunctionSpecifier{\n\t// · Token: example147.c:1:2: INLINE \"inline\",\n\t// }\n}\n\nfunc ExampleFunctionSpecifier_case1() {\n\tfmt.Println(exampleAST(148, \"\\U00100002 _Noreturn (\"))\n\t// Output:\n\t// &cc.FunctionSpecifier{\n\t// · Case: 1,\n\t// · Token: example148.c:1:2: NORETURN \"_Noreturn\",\n\t// }\n}\n\nfunc ExampleGroupList() {\n\tfmt.Println(exampleAST(286, \"\\U00100000 \"))\n\t// Output:\n\t// &cc.GroupList{\n\t// }\n}\n\nfunc ExampleGroupList_case1() {\n\tfmt.Println(exampleAST(287, \"\\U00100000int\\nf() {}\"))\n\t// Output:\n\t// &cc.GroupList{\n\t// · GroupList: &cc.GroupList{\n\t// · · Case: 1,\n\t// · · GroupPart: []xc.Token{ // len 6\n\t// · · · 0: example287.c:2:1: IDENTIFIER \"f\",\n\t// · · · 1: example287.c:2:2: '(',\n\t// · · · 2: example287.c:2:3: ')',\n\t// · · · 3: example287.c:2:4: ' ',\n\t// · · · 4: example287.c:2:5: '{',\n\t// · · · 5: example287.c:2:6: '}',\n\t// · · },\n\t// · },\n\t// · GroupPart: []xc.Token{ // len 2\n\t// · · 0: example287.c:1:1: IDENTIFIER \"int\",\n\t// · · 1: example287.c:1:4: ' ',\n\t// · },\n\t// }\n}\n\nfunc ExampleGroupListOpt() {\n\tfmt.Println(exampleAST(288, \"\\U00100000 \\n#ifndef a  \\n#elif\") == (*GroupListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleGroupListOpt_case1() {\n\tfmt.Println(exampleAST(289, \"\\U00100000 \\n#ifndef a\\nb\\n#elif\"))\n\t// Output:\n\t// &cc.GroupListOpt{\n\t// · GroupList: &cc.GroupList{\n\t// · · GroupPart: []xc.Token{ // len 2\n\t// · · · 0: example289.c:3:1: IDENTIFIER \"b\",\n\t// · · · 1: example289.c:3:2: ' ',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleIdentifierList() {\n\tfmt.Println(exampleAST(177, \"\\U00100002 a ( b )\"))\n\t// Output:\n\t// &cc.IdentifierList{\n\t// · Token: example177.c:1:6: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleIdentifierList_case1() {\n\tfmt.Println(exampleAST(178, \"\\U00100002 a ( b , c )\"))\n\t// Output:\n\t// &cc.IdentifierList{\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Case: 1,\n\t// · · Token: example178.c:1:8: ',',\n\t// · · Token2: example178.c:1:10: IDENTIFIER \"c\",\n\t// · },\n\t// · Token: example178.c:1:6: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleIdentifierListOpt() {\n\tfmt.Println(exampleAST(179, \"\\U00100002 a ( )\") == (*IdentifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleIdentifierListOpt_case1() {\n\tfmt.Println(exampleAST(180, \"\\U00100002 a ( b )\"))\n\t// Output:\n\t// &cc.IdentifierListOpt{\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Token: example180.c:1:6: IDENTIFIER \"b\",\n\t// · },\n\t// }\n}\n\nfunc ExampleIdentifierOpt() {\n\tfmt.Println(exampleAST(181, \"\\U00100002 struct {\") == (*IdentifierOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleIdentifierOpt_case1() {\n\tfmt.Println(exampleAST(182, \"\\U00100002 enum a {\"))\n\t// Output:\n\t// &cc.IdentifierOpt{\n\t// · Token: example182.c:1:7: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleIfGroup() {\n\tfmt.Println(exampleAST(295, \"\\U00100000 \\n#if other_a  \\n#elif\"))\n\t// Output:\n\t// &cc.IfGroup{\n\t// · PPTokenList: []xc.Token{ // len 4\n\t// · · 0: example295.c:2:4: ' ',\n\t// · · 1: example295.c:2:5: IDENTIFIER \"other_a\",\n\t// · · 2: example295.c:2:12: ' ',\n\t// · · 3: example295.c:2:14: ' ',\n\t// · },\n\t// · Token: example295.c:2:2: PPIF,\n\t// · Token2: example295.c:2:14: '\\n',\n\t// }\n}\n\nfunc ExampleIfGroup_case1() {\n\tfmt.Println(exampleAST(296, \"\\U00100000 \\n#ifdef a  \\n#elif\"))\n\t// Output:\n\t// &cc.IfGroup{\n\t// · Case: 1,\n\t// · Token: example296.c:2:2: PPIFDEF,\n\t// · Token2: example296.c:2:8: IDENTIFIER \"a\",\n\t// · Token3: example296.c:2:11: '\\n',\n\t// }\n}\n\nfunc ExampleIfGroup_case2() {\n\tfmt.Println(exampleAST(297, \"\\U00100000 \\n#ifndef a  \\n#elif\"))\n\t// Output:\n\t// &cc.IfGroup{\n\t// · Case: 2,\n\t// · Token: example297.c:2:2: PPIFNDEF,\n\t// · Token2: example297.c:2:9: IDENTIFIER \"a\",\n\t// · Token3: example297.c:2:12: '\\n',\n\t// }\n}\n\nfunc ExampleIfSection() {\n\tfmt.Println(exampleAST(294, \"\\U00100000 \\n#if other_a  \\n#endif\"))\n\t// Output:\n\t// &cc.IfSection{\n\t// · EndifLine: &cc.EndifLine{\n\t// · · Token: example294.c:3:2: PPENDIF,\n\t// · },\n\t// · IfGroup: &cc.IfGroup{\n\t// · · PPTokenList: []xc.Token{ // len 4\n\t// · · · 0: example294.c:2:4: ' ',\n\t// · · · 1: example294.c:2:5: IDENTIFIER \"other_a\",\n\t// · · · 2: example294.c:2:12: ' ',\n\t// · · · 3: example294.c:2:14: ' ',\n\t// · · },\n\t// · · Token: example294.c:2:2: PPIF,\n\t// · · Token2: example294.c:2:14: '\\n',\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclarator() {\n\tfmt.Println(exampleAST(92, \"\\U00100002 a auto b ,\"))\n\t// Output:\n\t// &cc.InitDeclarator{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · Type: auto undefined,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example92.c:1:9: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclarator_case1() {\n\tfmt.Println(exampleAST(94, \"\\U00100002 auto a = 'b' ,\"))\n\t// Output:\n\t// &cc.InitDeclarator{\n\t// · Case: 1,\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · Type: auto undefined,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example94.c:1:7: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · Initializer: &cc.Initializer{\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 98,\n\t// · · · Case: 1,\n\t// · · · Token: example94.c:1:11: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: example94.c:1:9: '=',\n\t// }\n}\n\nfunc ExampleInitDeclaratorList() {\n\tfmt.Println(exampleAST(88, \"\\U00100002 auto a ,\"))\n\t// Output:\n\t// &cc.InitDeclaratorList{\n\t// · InitDeclarator: &cc.InitDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: None,\n\t// · · · Type: auto undefined,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Token: example88.c:1:7: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclaratorList_case1() {\n\tfmt.Println(exampleAST(89, \"\\U00100002 auto a , b ,\"))\n\t// Output:\n\t// &cc.InitDeclaratorList{\n\t// · InitDeclarator: &cc.InitDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: None,\n\t// · · · Type: auto undefined,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Token: example89.c:1:7: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · Case: 1,\n\t// · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: None,\n\t// · · · · Type: auto undefined,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Token: example89.c:1:11: IDENTIFIER \"b\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: example89.c:1:9: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclaratorListOpt() {\n\tfmt.Println(exampleAST(90, \"\\U00100002 auto ;\") == (*InitDeclaratorListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleInitDeclaratorListOpt_case1() {\n\tfmt.Println(exampleAST(91, \"\\U00100002 auto a ;\"))\n\t// Output:\n\t// &cc.InitDeclaratorListOpt{\n\t// · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: None,\n\t// · · · · Type: auto undefined,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Token: example91.c:1:7: IDENTIFIER \"a\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializer() {\n\tfmt.Println(exampleAST(201, \"\\U00100002 auto a = 'b' ,\"))\n\t// Output:\n\t// &cc.Initializer{\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 98,\n\t// · · Case: 1,\n\t// · · Token: example201.c:1:11: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializer_case1() {\n\tfmt.Println(exampleAST(202, \"\\U00100002 auto a = { } ,\"))\n\t// Output:\n\t// &cc.Initializer{\n\t// · Case: 1,\n\t// · Token: example202.c:1:11: '{',\n\t// · Token2: example202.c:1:13: '}',\n\t// }\n}\n\nfunc ExampleInitializer_case2() {\n\tfmt.Println(exampleAST(203, \"\\U00100002 auto a = b : 'c' ,\"))\n\t// Output:\n\t// &cc.Initializer{\n\t// · Case: 2,\n\t// · Initializer: &cc.Initializer{\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 99,\n\t// · · · Case: 1,\n\t// · · · Token: example203.c:1:15: CHARCONST \"'c'\",\n\t// · · },\n\t// · },\n\t// · Token: example203.c:1:11: IDENTIFIER \"b\",\n\t// · Token2: example203.c:1:13: ':',\n\t// }\n}\n\nfunc ExampleInitializerList() {\n\tfmt.Println(exampleAST(204, \"\\U00100002 auto a = { 'b' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Initializer: &cc.Initializer{\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 98,\n\t// · · · Case: 1,\n\t// · · · Token: example204.c:1:13: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializerList_case1() {\n\tfmt.Println(exampleAST(205, \"\\U00100002 auto a = { , 'b' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Case: 1,\n\t// · Initializer: &cc.Initializer{\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 98,\n\t// · · · Case: 1,\n\t// · · · Token: example205.c:1:15: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: example205.c:1:13: ',',\n\t// }\n}\n\nfunc ExampleInitializerList_case2() {\n\tfmt.Println(exampleAST(206, \"\\U00100002 auto a = { ,\") == (*InitializerList)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleIterationStatement() {\n\tfmt.Println(exampleAST(236, \"\\U00100001 ( { while ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.IterationStatement{\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example236.c:1:14: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example236.c:1:20: ';',\n\t// · · },\n\t// · },\n\t// · Token: example236.c:1:6: WHILE \"while\",\n\t// · Token2: example236.c:1:12: '(',\n\t// · Token3: example236.c:1:18: ')',\n\t// }\n}\n\nfunc ExampleIterationStatement_case1() {\n\tfmt.Println(exampleAST(237, \"\\U00100001 ( { do ; while ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.IterationStatement{\n\t// · Case: 1,\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example237.c:1:19: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example237.c:1:9: ';',\n\t// · · },\n\t// · },\n\t// · Token: example237.c:1:6: DO \"do\",\n\t// · Token2: example237.c:1:11: WHILE \"while\",\n\t// · Token3: example237.c:1:17: '(',\n\t// · Token4: example237.c:1:23: ')',\n\t// · Token5: example237.c:1:25: ';',\n\t// }\n}\n\nfunc ExampleIterationStatement_case2() {\n\tfmt.Println(exampleAST(238, \"\\U00100001 ( { for ( ; ; ) ; !\"))\n\t// Output:\n\t// &cc.IterationStatement{\n\t// · Case: 2,\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example238.c:1:18: ';',\n\t// · · },\n\t// · },\n\t// · Token: example238.c:1:6: FOR \"for\",\n\t// · Token2: example238.c:1:10: '(',\n\t// · Token3: example238.c:1:12: ';',\n\t// · Token4: example238.c:1:14: ';',\n\t// · Token5: example238.c:1:16: ')',\n\t// }\n}\n\nfunc ExampleIterationStatement_case3() {\n\tfmt.Println(exampleAST(239, \"\\U00100001 ( { for ( auto ; ; ) ; !\"))\n\t// Output:\n\t// &cc.IterationStatement{\n\t// · Case: 3,\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example239.c:1:12: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example239.c:1:17: ';',\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example239.c:1:23: ';',\n\t// · · },\n\t// · },\n\t// · Token: example239.c:1:6: FOR \"for\",\n\t// · Token2: example239.c:1:10: '(',\n\t// · Token3: example239.c:1:19: ';',\n\t// · Token4: example239.c:1:21: ')',\n\t// }\n}\n\nfunc ExampleJumpStatement() {\n\tfmt.Println(exampleAST(240, \"\\U00100001 ( { goto a ; !\"))\n\t// Output:\n\t// &cc.JumpStatement{\n\t// · Token: example240.c:1:6: GOTO \"goto\",\n\t// · Token2: example240.c:1:11: IDENTIFIER \"a\",\n\t// · Token3: example240.c:1:13: ';',\n\t// }\n}\n\nfunc ExampleJumpStatement_case1() {\n\tfmt.Println(exampleAST(241, \"\\U00100001 ( { continue ; !\"))\n\t// Output:\n\t// &cc.JumpStatement{\n\t// · Case: 1,\n\t// · Token: example241.c:1:6: CONTINUE \"continue\",\n\t// · Token2: example241.c:1:15: ';',\n\t// }\n}\n\nfunc ExampleJumpStatement_case2() {\n\tfmt.Println(exampleAST(242, \"\\U00100001 ( { break ; !\"))\n\t// Output:\n\t// &cc.JumpStatement{\n\t// · Case: 2,\n\t// · Token: example242.c:1:6: BREAK \"break\",\n\t// · Token2: example242.c:1:12: ';',\n\t// }\n}\n\nfunc ExampleJumpStatement_case3() {\n\tfmt.Println(exampleAST(243, \"\\U00100001 ( { return ; !\"))\n\t// Output:\n\t// &cc.JumpStatement{\n\t// · Case: 3,\n\t// · Token: example243.c:1:6: RETURN \"return\",\n\t// · Token2: example243.c:1:13: ';',\n\t// }\n}\n\nfunc ExampleJumpStatement_case4() {\n\tfmt.Println(exampleAST(244, \"\\U00100001 ( { goto 'a' ; !\"))\n\t// Output:\n\t// &cc.JumpStatement{\n\t// · Case: 4,\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Case: 1,\n\t// · · Token: example244.c:1:11: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example244.c:1:6: GOTO \"goto\",\n\t// · Token2: example244.c:1:15: ';',\n\t// }\n}\n\nfunc ExampleLabeledStatement() {\n\tfmt.Println(exampleAST(221, \"\\U00100001 ( { a : ; !\"))\n\t// Output:\n\t// &cc.LabeledStatement{\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example221.c:1:10: ';',\n\t// · · },\n\t// · },\n\t// · Token: example221.c:1:6: IDENTIFIER \"a\",\n\t// · Token2: example221.c:1:8: ':',\n\t// }\n}\n\nfunc ExampleLabeledStatement_case1() {\n\tfmt.Println(exampleAST(222, \"\\U00100001 ( { case 'a' : ; !\"))\n\t// Output:\n\t// &cc.LabeledStatement{\n\t// · Case: 1,\n\t// · ConstantExpression: &cc.ConstantExpression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example222.c:1:11: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example222.c:1:17: ';',\n\t// · · },\n\t// · },\n\t// · Token: example222.c:1:6: CASE \"case\",\n\t// · Token2: example222.c:1:15: ':',\n\t// }\n}\n\nfunc ExampleLabeledStatement_case2() {\n\tfmt.Println(exampleAST(223, \"\\U00100001 ( { default : ; !\"))\n\t// Output:\n\t// &cc.LabeledStatement{\n\t// · Case: 2,\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example223.c:1:16: ';',\n\t// · · },\n\t// · },\n\t// · Token: example223.c:1:6: DEFAULT \"default\",\n\t// · Token2: example223.c:1:14: ':',\n\t// }\n}\n\nfunc ExampleParameterDeclaration() {\n\tfmt.Println(exampleAST(175, \"\\U00100002 a ( auto b )\"))\n\t// Output:\n\t// &cc.ParameterDeclaration{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Case: 3,\n\t// · · · Token: example175.c:1:6: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · Type: auto undefined,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example175.c:1:11: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterDeclaration_case1() {\n\tfmt.Println(exampleAST(176, \"\\U00100002 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterDeclaration{\n\t// · Case: 1,\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Case: 3,\n\t// · · · Token: example176.c:1:6: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterList() {\n\tfmt.Println(exampleAST(173, \"\\U00100002 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterList{\n\t// · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · Case: 1,\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example173.c:1:6: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterList_case1() {\n\tfmt.Println(exampleAST(174, \"\\U00100002 a ( auto , auto )\"))\n\t// Output:\n\t// &cc.ParameterList{\n\t// · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · Case: 1,\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: example174.c:1:6: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · ParameterList: &cc.ParameterList{\n\t// · · Case: 1,\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · Case: 1,\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example174.c:1:13: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: example174.c:1:11: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterTypeList() {\n\tfmt.Println(exampleAST(169, \"\\U00100002 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterTypeList{\n\t// · ParameterList: &cc.ParameterList{\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · Case: 1,\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example169.c:1:6: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterTypeList_case1() {\n\tfmt.Println(exampleAST(170, \"\\U00100002 a ( auto , ... )\"))\n\t// Output:\n\t// &cc.ParameterTypeList{\n\t// · Case: 1,\n\t// · ParameterList: &cc.ParameterList{\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · Case: 1,\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example170.c:1:6: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: example170.c:1:11: ',',\n\t// · Token2: example170.c:1:13: DDD,\n\t// }\n}\n\nfunc ExampleParameterTypeListOpt() {\n\tfmt.Println(exampleAST(171, \"\\U00100001 ( _Bool ( )\") == (*ParameterTypeListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleParameterTypeListOpt_case1() {\n\tfmt.Println(exampleAST(172, \"\\U00100001 ( _Bool ( auto )\"))\n\t// Output:\n\t// &cc.ParameterTypeListOpt{\n\t// · ParameterTypeList: &cc.ParameterTypeList{\n\t// · · ParameterList: &cc.ParameterList{\n\t// · · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · · Case: 1,\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Case: 3,\n\t// · · · · · · Token: example172.c:1:12: AUTO \"auto\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExamplePointer() {\n\tfmt.Println(exampleAST(161, \"\\U00100002 * (\"))\n\t// Output:\n\t// &cc.Pointer{\n\t// · Token: example161.c:1:2: '*',\n\t// }\n}\n\nfunc ExamplePointer_case1() {\n\tfmt.Println(exampleAST(162, \"\\U00100002 * * (\"))\n\t// Output:\n\t// &cc.Pointer{\n\t// · Case: 1,\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: example162.c:1:4: '*',\n\t// · },\n\t// · Token: example162.c:1:2: '*',\n\t// }\n}\n\nfunc ExamplePointerOpt() {\n\tfmt.Println(exampleAST(163, \"\\U00100002 auto (\") == (*PointerOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExamplePointerOpt_case1() {\n\tfmt.Println(exampleAST(164, \"\\U00100001 ( _Bool * (\"))\n\t// Output:\n\t// &cc.PointerOpt{\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: example164.c:1:10: '*',\n\t// · },\n\t// }\n}\n\nfunc ExamplePreprocessingFile() {\n\tfmt.Println(exampleAST(285, \"\\U00100000 \"))\n\t// Output:\n\t// &cc.PreprocessingFile{\n\t// · GroupList: &cc.GroupList{\n\t// · },\n\t// }\n}\n\nfunc ExampleSelectionStatement() {\n\tfmt.Println(exampleAST(233, \"\\U00100001 ( { if ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.SelectionStatement{\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example233.c:1:11: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example233.c:1:17: ';',\n\t// · · },\n\t// · },\n\t// · Token: example233.c:1:6: IF \"if\",\n\t// · Token2: example233.c:1:9: '(',\n\t// · Token3: example233.c:1:15: ')',\n\t// }\n}\n\nfunc ExampleSelectionStatement_case1() {\n\tfmt.Println(exampleAST(234, \"\\U00100001 ( { if ( 'a' ) ; else ; !\"))\n\t// Output:\n\t// &cc.SelectionStatement{\n\t// · Case: 1,\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example234.c:1:11: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example234.c:1:17: ';',\n\t// · · },\n\t// · },\n\t// · Statement2: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example234.c:1:24: ';',\n\t// · · },\n\t// · },\n\t// · Token: example234.c:1:6: IF \"if\",\n\t// · Token2: example234.c:1:9: '(',\n\t// · Token3: example234.c:1:15: ')',\n\t// · Token4: example234.c:1:19: ELSE \"else\",\n\t// }\n}\n\nfunc ExampleSelectionStatement_case2() {\n\tfmt.Println(exampleAST(235, \"\\U00100001 ( { switch ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.SelectionStatement{\n\t// · Case: 2,\n\t// · ExpressionList: &cc.ExpressionList{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example235.c:1:15: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Statement: &cc.Statement{\n\t// · · Case: 2,\n\t// · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · Token: example235.c:1:21: ';',\n\t// · · },\n\t// · },\n\t// · Token: example235.c:1:6: SWITCH \"switch\",\n\t// · Token2: example235.c:1:13: '(',\n\t// · Token3: example235.c:1:19: ')',\n\t// }\n}\n\nfunc ExampleSpecifierQualifierList() {\n\tfmt.Println(exampleAST(127, \"\\U00100001 ( _Bool (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierList{\n\t// · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · Case: 9,\n\t// · · Token: example127.c:1:4: BOOL \"_Bool\",\n\t// · },\n\t// }\n}\n\nfunc ExampleSpecifierQualifierList_case1() {\n\tfmt.Println(exampleAST(128, \"\\U00100001 ( const (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierList{\n\t// · Case: 1,\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: example128.c:1:4: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleSpecifierQualifierListOpt() {\n\tfmt.Println(exampleAST(129, \"\\U00100001 ( _Bool (\") == (*SpecifierQualifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleSpecifierQualifierListOpt_case1() {\n\tfmt.Println(exampleAST(130, \"\\U00100001 ( _Bool _Bool (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierListOpt{\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Case: 9,\n\t// · · · Token: example130.c:1:10: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement() {\n\tfmt.Println(exampleAST(214, \"\\U00100001 ( { default : ; !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · LabeledStatement: &cc.LabeledStatement{\n\t// · · Case: 2,\n\t// · · Statement: &cc.Statement{\n\t// · · · Case: 2,\n\t// · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · Token: example214.c:1:16: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: example214.c:1:6: DEFAULT \"default\",\n\t// · · Token2: example214.c:1:14: ':',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case1() {\n\tfmt.Println(exampleAST(215, \"\\U00100001 ( { { } !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · Case: 1,\n\t// · CompoundStatement: &cc.CompoundStatement{\n\t// · · Token: example215.c:1:6: '{',\n\t// · · Token2: example215.c:1:8: '}',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case2() {\n\tfmt.Println(exampleAST(216, \"\\U00100001 ( { ; !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · Case: 2,\n\t// · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · Token: example216.c:1:6: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case3() {\n\tfmt.Println(exampleAST(217, \"\\U00100001 ( { if ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · Case: 3,\n\t// · SelectionStatement: &cc.SelectionStatement{\n\t// · · ExpressionList: &cc.ExpressionList{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Type: int,\n\t// · · · · Value: 97,\n\t// · · · · Case: 1,\n\t// · · · · Token: example217.c:1:11: CHARCONST \"'a'\",\n\t// · · · },\n\t// · · },\n\t// · · Statement: &cc.Statement{\n\t// · · · Case: 2,\n\t// · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · Token: example217.c:1:17: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: example217.c:1:6: IF \"if\",\n\t// · · Token2: example217.c:1:9: '(',\n\t// · · Token3: example217.c:1:15: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case4() {\n\tfmt.Println(exampleAST(218, \"\\U00100001 ( { while ( 'a' ) ; !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · Case: 4,\n\t// · IterationStatement: &cc.IterationStatement{\n\t// · · ExpressionList: &cc.ExpressionList{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Type: int,\n\t// · · · · Value: 97,\n\t// · · · · Case: 1,\n\t// · · · · Token: example218.c:1:14: CHARCONST \"'a'\",\n\t// · · · },\n\t// · · },\n\t// · · Statement: &cc.Statement{\n\t// · · · Case: 2,\n\t// · · · ExpressionStatement: &cc.ExpressionStatement{\n\t// · · · · Token: example218.c:1:20: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: example218.c:1:6: WHILE \"while\",\n\t// · · Token2: example218.c:1:12: '(',\n\t// · · Token3: example218.c:1:18: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case5() {\n\tfmt.Println(exampleAST(219, \"\\U00100001 ( { break ; !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · Case: 5,\n\t// · JumpStatement: &cc.JumpStatement{\n\t// · · Case: 2,\n\t// · · Token: example219.c:1:6: BREAK \"break\",\n\t// · · Token2: example219.c:1:12: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStatement_case6() {\n\tfmt.Println(exampleAST(220, \"\\U00100001 ( { asm ( \\\"a\\\" ) !\"))\n\t// Output:\n\t// &cc.Statement{\n\t// · AssemblerStatement: &cc.AssemblerStatement{\n\t// · · BasicAssemblerStatement: &cc.BasicAssemblerStatement{\n\t// · · · AssemblerInstructions: &cc.AssemblerInstructions{\n\t// · · · · Token: example220.c:1:12: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · },\n\t// · · · Token: example220.c:1:6: ASM \"asm\",\n\t// · · · Token2: example220.c:1:10: '(',\n\t// · · · Token3: example220.c:1:16: ')',\n\t// · · },\n\t// · },\n\t// · Case: 6,\n\t// }\n}\n\nfunc ExampleStaticAssertDeclaration() {\n\tfmt.Println(exampleAST(284, \"\\U00100002 _Static_assert ( 'a' , \\\"b\\\" ) ;\"))\n\t// Output:\n\t// &cc.StaticAssertDeclaration{\n\t// · ConstantExpression: &cc.ConstantExpression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example284.c:1:19: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: example284.c:1:2: STATIC_ASSERT \"_Static_assert\",\n\t// · Token2: example284.c:1:17: '(',\n\t// · Token3: example284.c:1:23: ',',\n\t// · Token4: example284.c:1:25: STRINGLITERAL \"\\\"b\\\"\",\n\t// · Token5: example284.c:1:29: ')',\n\t// · Token6: example284.c:1:31: ';',\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier() {\n\tfmt.Println(exampleAST(95, \"\\U00100002 typedef (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Token: example95.c:1:2: TYPEDEF \"typedef\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_case1() {\n\tfmt.Println(exampleAST(96, \"\\U00100002 extern (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 1,\n\t// · Token: example96.c:1:2: EXTERN \"extern\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_case2() {\n\tfmt.Println(exampleAST(97, \"\\U00100002 static (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 2,\n\t// · Token: example97.c:1:2: STATIC \"static\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_case3() {\n\tfmt.Println(exampleAST(98, \"\\U00100002 auto (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 3,\n\t// · Token: example98.c:1:2: AUTO \"auto\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_case4() {\n\tfmt.Println(exampleAST(99, \"\\U00100002 register (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 4,\n\t// · Token: example99.c:1:2: REGISTER \"register\",\n\t// }\n}\n\nfunc ExampleStructDeclaration() {\n\tfmt.Println(exampleAST(124, \"\\U00100002 struct { _Bool a ; }\"))\n\t// Output:\n\t// &cc.StructDeclaration{\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Case: 9,\n\t// · · · Token: example124.c:1:11: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// · StructDeclaratorList: &cc.StructDeclaratorList{\n\t// · · StructDeclarator: &cc.StructDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: None,\n\t// · · · · Type: bool,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Token: example124.c:1:17: IDENTIFIER \"a\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: example124.c:1:19: ';',\n\t// }\n}\n\nfunc ExampleStructDeclaration_case1() {\n\tfmt.Println(exampleAST(125, \"\\U00100002 struct { _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclaration{\n\t// · Case: 1,\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Case: 9,\n\t// · · · Token: example125.c:1:11: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// · Token: example125.c:1:17: ';',\n\t// }\n}\n\nfunc ExampleStructDeclaration_case2() {\n\tfmt.Println(exampleAST(126, \"\\U00100002 struct { _Static_assert ( 'a' , \\\"b\\\" ) ; }\"))\n\t// Output:\n\t// &cc.StructDeclaration{\n\t// · Case: 2,\n\t// · StaticAssertDeclaration: &cc.StaticAssertDeclaration{\n\t// · · ConstantExpression: &cc.ConstantExpression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Expression: &cc.Expression{\n\t// · · · · Type: int,\n\t// · · · · Value: 97,\n\t// · · · · Case: 1,\n\t// · · · · Token: example126.c:1:28: CHARCONST \"'a'\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example126.c:1:11: STATIC_ASSERT \"_Static_assert\",\n\t// · · Token2: example126.c:1:26: '(',\n\t// · · Token3: example126.c:1:32: ',',\n\t// · · Token4: example126.c:1:34: STRINGLITERAL \"\\\"b\\\"\",\n\t// · · Token5: example126.c:1:38: ')',\n\t// · · Token6: example126.c:1:40: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarationList() {\n\tfmt.Println(exampleAST(122, \"\\U00100002 struct { _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclarationList{\n\t// · StructDeclaration: &cc.StructDeclaration{\n\t// · · Case: 1,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example122.c:1:11: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example122.c:1:17: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarationList_case1() {\n\tfmt.Println(exampleAST(123, \"\\U00100002 struct { _Bool ; _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclarationList{\n\t// · StructDeclaration: &cc.StructDeclaration{\n\t// · · Case: 1,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example123.c:1:11: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · · Token: example123.c:1:17: ';',\n\t// · },\n\t// · StructDeclarationList: &cc.StructDeclarationList{\n\t// · · Case: 1,\n\t// · · StructDeclaration: &cc.StructDeclaration{\n\t// · · · Case: 1,\n\t// · · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · Case: 9,\n\t// · · · · · Token: example123.c:1:19: BOOL \"_Bool\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: example123.c:1:25: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarator() {\n\tfmt.Println(exampleAST(133, \"\\U00100002 struct { _Bool a ,\"))\n\t// Output:\n\t// &cc.StructDeclarator{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: None,\n\t// · · Type: bool,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Token: example133.c:1:17: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarator_case1() {\n\tfmt.Println(exampleAST(134, \"\\U00100002 struct { _Bool : 'a' ,\"))\n\t// Output:\n\t// &cc.StructDeclarator{\n\t// · Case: 1,\n\t// · ConstantExpression: &cc.ConstantExpression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Expression: &cc.Expression{\n\t// · · · Type: int,\n\t// · · · Value: 97,\n\t// · · · Case: 1,\n\t// · · · Token: example134.c:1:19: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: example134.c:1:17: ':',\n\t// }\n}\n\nfunc ExampleStructDeclaratorList() {\n\tfmt.Println(exampleAST(131, \"\\U00100002 struct { _Bool a ,\"))\n\t// Output:\n\t// &cc.StructDeclaratorList{\n\t// · StructDeclarator: &cc.StructDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: None,\n\t// · · · Type: bool,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Token: example131.c:1:17: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclaratorList_case1() {\n\tfmt.Println(exampleAST(132, \"\\U00100002 struct { _Bool a , b ,\"))\n\t// Output:\n\t// &cc.StructDeclaratorList{\n\t// · StructDeclarator: &cc.StructDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: None,\n\t// · · · Type: bool,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Token: example132.c:1:17: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · StructDeclaratorList: &cc.StructDeclaratorList{\n\t// · · Case: 1,\n\t// · · StructDeclarator: &cc.StructDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: None,\n\t// · · · · Type: bool,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Token: example132.c:1:21: IDENTIFIER \"b\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: example132.c:1:19: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleStructOrUnion() {\n\tfmt.Println(exampleAST(120, \"\\U00100002 struct {\"))\n\t// Output:\n\t// &cc.StructOrUnion{\n\t// · Token: example120.c:1:2: STRUCT \"struct\",\n\t// }\n}\n\nfunc ExampleStructOrUnion_case1() {\n\tfmt.Println(exampleAST(121, \"\\U00100002 union {\"))\n\t// Output:\n\t// &cc.StructOrUnion{\n\t// · Case: 1,\n\t// · Token: example121.c:1:2: UNION \"union\",\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier() {\n\tfmt.Println(exampleAST(117, \"\\U00100002 struct { int i; } (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · StructDeclarationList: &cc.StructDeclarationList{\n\t// · · StructDeclaration: &cc.StructDeclaration{\n\t// · · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: example117.c:1:11: INT \"int\",\n\t// · · · · },\n\t// · · · },\n\t// · · · StructDeclaratorList: &cc.StructDeclaratorList{\n\t// · · · · StructDeclarator: &cc.StructDeclarator{\n\t// · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · Linkage: None,\n\t// · · · · · · Type: int,\n\t// · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · Token: example117.c:1:15: IDENTIFIER \"i\",\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: example117.c:1:16: ';',\n\t// · · },\n\t// · },\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: example117.c:1:2: STRUCT \"struct\",\n\t// · },\n\t// · Token: example117.c:1:9: '{',\n\t// · Token2: example117.c:1:18: '}',\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier_case1() {\n\tfmt.Println(exampleAST(118, \"\\U00100002 struct a (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · Case: 1,\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: example118.c:1:2: STRUCT \"struct\",\n\t// · },\n\t// · Token: example118.c:1:9: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier_case2() {\n\tfmt.Println(exampleAST(119, \"\\U00100002 struct { } (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · Case: 2,\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: example119.c:1:2: STRUCT \"struct\",\n\t// · },\n\t// · Token: example119.c:1:9: '{',\n\t// · Token2: example119.c:1:11: '}',\n\t// }\n}\n\nfunc ExampleTranslationUnit() {\n\tfmt.Println(exampleAST(245, \"\\U00100002 ;\"))\n\t// Output:\n\t// &cc.TranslationUnit{\n\t// · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · Case: 3,\n\t// · · Token: example245.c:1:2: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleTranslationUnit_case1() {\n\tfmt.Println(exampleAST(246, \"\\U00100002 ; ;\"))\n\t// Output:\n\t// &cc.TranslationUnit{\n\t// · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · Case: 3,\n\t// · · Token: example246.c:1:2: ';',\n\t// · },\n\t// · TranslationUnit: &cc.TranslationUnit{\n\t// · · Case: 1,\n\t// · · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · · Case: 3,\n\t// · · · Token: example246.c:1:4: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeName() {\n\tfmt.Println(exampleAST(184, \"\\U00100001 ( _Bool )\"))\n\t// Output:\n\t// &cc.TypeName{\n\t// · Type: bool,\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Case: 9,\n\t// · · · Token: example184.c:1:4: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifier() {\n\tfmt.Println(exampleAST(144, \"\\U00100002 const !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Token: example144.c:1:2: CONST \"const\",\n\t// }\n}\n\nfunc ExampleTypeQualifier_case1() {\n\tfmt.Println(exampleAST(145, \"\\U00100002 restrict !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Case: 1,\n\t// · Token: example145.c:1:2: RESTRICT \"restrict\",\n\t// }\n}\n\nfunc ExampleTypeQualifier_case2() {\n\tfmt.Println(exampleAST(146, \"\\U00100002 volatile !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Case: 2,\n\t// · Token: example146.c:1:2: VOLATILE \"volatile\",\n\t// }\n}\n\nfunc ExampleTypeQualifierList() {\n\tfmt.Println(exampleAST(165, \"\\U00100002 * const !\"))\n\t// Output:\n\t// &cc.TypeQualifierList{\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: example165.c:1:4: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifierList_case1() {\n\tfmt.Println(exampleAST(166, \"\\U00100002 * const const !\"))\n\t// Output:\n\t// &cc.TypeQualifierList{\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: example166.c:1:4: CONST \"const\",\n\t// · },\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · Case: 1,\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: example166.c:1:10: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifierListOpt() {\n\tfmt.Println(exampleAST(167, \"\\U00100002 * (\") == (*TypeQualifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleTypeQualifierListOpt_case1() {\n\tfmt.Println(exampleAST(168, \"\\U00100002 * const !\"))\n\t// Output:\n\t// &cc.TypeQualifierListOpt{\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: example168.c:1:4: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier() {\n\tfmt.Println(exampleAST(100, \"\\U00100002 void (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Token: example100.c:1:2: VOID \"void\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case01() {\n\tfmt.Println(exampleAST(101, \"\\U00100002 char (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 1,\n\t// · Token: example101.c:1:2: CHAR \"char\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case02() {\n\tfmt.Println(exampleAST(102, \"\\U00100002 short (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 2,\n\t// · Token: example102.c:1:2: SHORT \"short\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case03() {\n\tfmt.Println(exampleAST(103, \"\\U00100002 int (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 3,\n\t// · Token: example103.c:1:2: INT \"int\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case04() {\n\tfmt.Println(exampleAST(104, \"\\U00100002 long (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 4,\n\t// · Token: example104.c:1:2: LONG \"long\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case05() {\n\tfmt.Println(exampleAST(105, \"\\U00100002 float (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 5,\n\t// · Token: example105.c:1:2: FLOAT \"float\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case06() {\n\tfmt.Println(exampleAST(106, \"\\U00100002 double (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 6,\n\t// · Token: example106.c:1:2: DOUBLE \"double\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case07() {\n\tfmt.Println(exampleAST(107, \"\\U00100002 signed (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 7,\n\t// · Token: example107.c:1:2: SIGNED \"signed\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case08() {\n\tfmt.Println(exampleAST(108, \"\\U00100002 unsigned (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 8,\n\t// · Token: example108.c:1:2: UNSIGNED \"unsigned\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case09() {\n\tfmt.Println(exampleAST(109, \"\\U00100002 _Bool (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 9,\n\t// · Token: example109.c:1:2: BOOL \"_Bool\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case10() {\n\tfmt.Println(exampleAST(110, \"\\U00100002 _Complex (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 10,\n\t// · Token: example110.c:1:2: COMPLEX \"_Complex\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case11() {\n\tfmt.Println(exampleAST(111, \"\\U00100002 struct a (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 11,\n\t// · StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{\n\t// · · Case: 1,\n\t// · · StructOrUnion: &cc.StructOrUnion{\n\t// · · · Token: example111.c:1:2: STRUCT \"struct\",\n\t// · · },\n\t// · · Token: example111.c:1:9: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case12() {\n\tfmt.Println(exampleAST(112, \"\\U00100002 enum a (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 12,\n\t// · EnumSpecifier: &cc.EnumSpecifier{\n\t// · · Case: 1,\n\t// · · Token: example112.c:1:2: ENUM \"enum\",\n\t// · · Token2: example112.c:1:7: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case13() {\n\tfmt.Println(exampleAST(113, \"\\U00100002 typedef int i; i j;\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 13,\n\t// · Token: example113.c:1:17: TYPEDEFNAME \"i\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case14() {\n\tfmt.Println(exampleAST(114, \"\\U00100002 typeof ( 'a' ) (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Type: int,\n\t// · Case: 14,\n\t// · Expression: &cc.Expression{\n\t// · · Type: int,\n\t// · · Value: 97,\n\t// · · Case: 1,\n\t// · · Token: example114.c:1:11: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: example114.c:1:2: TYPEOF \"typeof\",\n\t// · Token2: example114.c:1:9: '(',\n\t// · Token3: example114.c:1:15: ')',\n\t// }\n}\n\nfunc ExampleTypeSpecifier_case15() {\n\tfmt.Println(exampleAST(115, \"\\U00100002 typeof ( _Bool ) (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Type: bool,\n\t// · Case: 15,\n\t// · Token: example115.c:1:2: TYPEOF \"typeof\",\n\t// · Token2: example115.c:1:9: '(',\n\t// · Token3: example115.c:1:17: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · Type: bool,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Case: 9,\n\t// · · · · Token: example115.c:1:11: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleVolatileOpt() {\n\tfmt.Println(exampleAST(268, \"\\U00100002 asm (\") == (*VolatileOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleVolatileOpt_case1() {\n\tfmt.Println(exampleAST(269, \"\\U00100002 asm volatile (\"))\n\t// Output:\n\t// &cc.VolatileOpt{\n\t// · Token: example269.c:1:6: VOLATILE \"volatile\",\n\t// }\n}\n"
  },
  {
    "path": "cc.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n//go:generate go run generate.go\n//go:generate golex -o trigraphs.go trigraphs.l\n//go:generate golex -o scanner.go scanner.l\n//go:generate stringer -type Kind\n//go:generate stringer -type Linkage\n//go:generate stringer -type Namespace\n//go:generate stringer -type Scope\n//go:generate go run generate.go -2\n\n// Package cc is a C99 compiler front end.\n//\n// Changelog\n//\n// 2018-07-01 This package is no longer maintained. Please see the v2 version at\n//\n//\thttps://github.com/cznic/cc/v2\n//\n// Links\n//\n// Referenced from elsewhere:\n//\n//  [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n//  [1]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1406.pdf\n//  [2]: https://github.com/rsc/c2go/blob/fc8cbfad5a47373828c81c7a56cccab8b221d310/cc/cc.y\n//  [3]: https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html\npackage cc\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"os\"\n\t\"os/exec\"\n\t\"runtime\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nconst (\n\tfakeTime = \"__TESTING_TIME__\"\n\n\tgccPredefine = `\n#define __PRETTY_FUNCTION__ __func__\n#define __asm asm\n#define __attribute(x)\n#define __attribute__(x)\n#define __builtin___memcpy_chk(x, y, z, t) __BUILTIN___MEMCPY_CHK()\n#define __builtin___memset_chk(x, y, z, ...) __BUILTIN___MEMSET_CHK()\n#define __builtin_alloca(x) __BUILTIN_ALLOCA()\n#define __builtin_classify_type(x) __BUILTIN_CLASSIFY_TYPE()\n#define __builtin_constant_p(exp) __BUILTIN_CONSTANT_P()\n#define __builtin_isgreater(x, y) __BUILTIN_ISGREATER()\n#define __builtin_isless(x, y) __BUILTIN_ISLESS()\n#define __builtin_isunordered(x, y) __BUILTIN_ISUNORDERED()\n#define __builtin_longjmp(x, y) __BUILTIN_LONGJMP()\n#define __builtin_malloc(x) __BUILTIN_MALLOC()\n#define __builtin_memmove(x, y, z) __BUILTIN_MEMMOVE()\n#define __builtin_mempcpy(x, y, z) __BUILTIN_MEMPCPY()\n#define __builtin_mul_overflow(a, b, c) __BUILTIN_MUL_OVERFLOW()\n#define __builtin_offsetof(type, member) ((%[1]v)(&((type *)0)->member))\n#define __builtin_signbit(x) __BUILTIN_SIGNBIT()\n#define __builtin_va_arg(ap, type) ( *( type* )ap )\n#define __builtin_va_end(x)\n#define __builtin_va_list void*\n#define __builtin_va_start(x, y)\n#define __complex _Complex\n#define __complex__ _Complex\n#define __const\n#define __extension__\n#define __imag__\n#define __inline inline\n#define __real(x) __REAL()\n#define __real__\n#define __restrict\n#define __sync_fetch_and_add(x, y, ...) __SYNC_FETCH_AND_ADD()\n#define __sync_val_compare_and_swap(x, y, z, ...) __SYNC_VAL_COMPARE_AND_SWAP()\n#define __typeof typeof\n#define __volatile volatile\n%[1]v __builtin_object_size (void*, int);\n%[1]v __builtin_strlen(char*);\n%[1]v __builtin_strspn(char*, char*);\n_Bool __BUILTIN_MUL_OVERFLOW();\nchar* __builtin___stpcpy_chk(char*, char*, %[1]v);\nchar* __builtin_stpcpy(char*, char*);\nchar* __builtin_strchr(char*, int);\nchar* __builtin_strcpy(char*, char*);\nchar* __builtin_strdup(char*);\nchar* __builtin_strncpy(char*, char*, %[1]v);\ndouble _Complex __builtin_cpow(double _Complex, _Complex double);\ndouble __REAL();\ndouble __builtin_copysign(double, double);\ndouble __builtin_copysignl(long double, long double);\ndouble __builtin_inff();\ndouble __builtin_modf(double, double*);\ndouble __builtin_modfl(long double, long double*);\ndouble __builtin_nanf(char *);\nfloat _Complex __builtin_conjf(float _Complex);\nfloat __builtin_ceilf(float);\nfloat __builtin_copysignf(float, float);\nfloat __builtin_modff(float, float*);\nint __BUILTIN_CLASSIFY_TYPE();\nint __BUILTIN_CONSTANT_P();\nint __BUILTIN_ISGREATER();\nint __BUILTIN_ISLESS();\nint __BUILTIN_ISUNORDERED();\nint __BUILTIN_SIGNBIT();\nint __builtin___snprintf_chk (char*, %[1]v, int, %[1]v, char*, ...);\nint __builtin___sprintf_chk (char*, int, %[1]v, char*, ...);\nint __builtin___vsnprintf_chk (char*, %[1]v, int, %[1]v, char*, void*);\nint __builtin___vsprintf_chk (char*, int, %[1]v, char*, void*);\nint __builtin_abs(int);\nint __builtin_clrsb(int);\nint __builtin_clrsbl(long);\nint __builtin_clrsbll(long long);\nint __builtin_clz(unsigned int);\nint __builtin_clzl(unsigned long);\nint __builtin_clzll(unsigned long long);\nint __builtin_constant_p (exp);\nint __builtin_ctz(unsigned int x);\nint __builtin_ctzl(unsigned long);\nint __builtin_ctzll(unsigned long long);\nint __builtin_ffs(int);\nint __builtin_ffsl(long);\nint __builtin_ffsll(long long);\nint __builtin_isinf(double);\nint __builtin_isinff(float);\nint __builtin_isinfl(long double);\nint __builtin_memcmp(void*, void*, %[1]v);\nint __builtin_parity (unsigned);\nint __builtin_parityl(unsigned long);\nint __builtin_parityll (unsigned long long);\nint __builtin_popcount (unsigned int x);\nint __builtin_popcountl (unsigned long);\nint __builtin_popcountll (unsigned long long);\nint __builtin_printf(char*, ...);\nint __builtin_puts(char*);\nint __builtin_setjmp(void*);\nint __builtin_strcmp(char*, char*);\nint __builtin_strncmp(char*, char*, %[1]v);\nlong __builtin_expect(long, long);\nlong long strlen (char*);\nunsigned __builtin_bswap32 (unsigned x);\nunsigned long long __builtin_bswap64 (unsigned long long x);\nunsigned short __builtin_bswap16 (unsigned short x);\nvoid __BUILTIN_LONGJMP();\nvoid __SYNC_FETCH_AND_ADD();\nvoid __SYNC_VAL_COMPARE_AND_SWAP();\nvoid __builtin_abort(void);\nvoid __builtin_bcopy(void*, void*, %[1]v);\nvoid __builtin_bzero(void*, %[1]v);\nvoid __builtin_prefetch (void*, ...);\nvoid __builtin_stack_restore(void*);\nvoid __builtin_trap (void);\nvoid __builtin_unreachable (void);\nvoid __builtin_unwind_init();\nvoid __builtin_va_arg_pack ();\nvoid __builtin_va_copy(void*, void*);\nvoid* __BUILTIN_ALLOCA();\nvoid* __BUILTIN_MALLOC();\nvoid* __BUILTIN_MEMMOVE();\nvoid* __BUILTIN_MEMPCPY();\nvoid* __BUILTIN___MEMCPY_CHK();\nvoid* __BUILTIN___MEMSET_CHK();\nvoid* __builtin_alloca(int);\nvoid* __builtin_apply (void (*)(), void*, %[1]v);\nvoid* __builtin_apply_args();\nvoid* __builtin_extract_return_addr(void *);\nvoid* __builtin_frame_address(unsigned int);\nvoid* __builtin_memcpy(void*, void*, long long);\nvoid* __builtin_memset(void*, int, long long);\nvoid* __builtin_return_address (unsigned int);\nvoid* __builtin_stack_save();\nvoid* memcpy(void*, void*, long long);\nvoid* memset(void*, int, long long);\n`\n)\n\n// ImportPath returns the import path of this package or an error, if any.\nfunc ImportPath() (string, error) { return strutil.ImportPath() }\n\n// HostConfig executes HostCppConfig with the cpp argument set to \"cpp\". For\n// more info please see the documentation of HostCppConfig.\nfunc HostConfig(opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error) {\n\treturn HostCppConfig(\"cpp\", opts...)\n}\n\n// HostCppConfig returns the system C preprocessor configuration, or an error,\n// if any.  The configuration is obtained by running the cpp command. For the\n// predefined macros list the '-dM' options is added. For the include paths\n// lists, the option '-v' is added and the output is parsed to extract the\n// \"...\" include and <...> include paths. To add any other options to cpp, list\n// them in opts.\n//\n// The function relies on a POSIX compatible C preprocessor installed.\n// Execution of HostConfig is not free, so caching the results is recommended\n// whenever possible.\nfunc HostCppConfig(cpp string, opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error) {\n\targs := append(append([]string{\"-dM\"}, opts...), os.DevNull)\n\t// cross-compile e.g. win64 -> win32\n\tif runtime.GOARCH == \"386\" {\n\t\targs = append(args, \"-m32\")\n\t}\n\tpre, err := exec.Command(cpp, args...).Output()\n\tif err != nil {\n\t\treturn \"\", nil, nil, err\n\t}\n\n\targs = append(append([]string{\"-v\"}, opts...), os.DevNull)\n\tout, err := exec.Command(cpp, args...).CombinedOutput()\n\tif err != nil {\n\t\treturn \"\", nil, nil, err\n\t}\n\n\tsep := \"\\n\"\n\tif runtime.GOOS == \"windows\" {\n\t\tsep = \"\\r\\n\"\n\t}\n\n\ta := strings.Split(string(out), sep)\n\tfor i := 0; i < len(a); {\n\t\tswitch a[i] {\n\t\tcase \"#include \\\"...\\\" search starts here:\":\n\t\tloop:\n\t\t\tfor i = i + 1; i < len(a); {\n\t\t\t\tswitch v := a[i]; {\n\t\t\t\tcase strings.HasPrefix(v, \"#\") || v == \"End of search list.\":\n\t\t\t\t\tbreak loop\n\t\t\t\tdefault:\n\t\t\t\t\tincludePaths = append(includePaths, strings.TrimSpace(v))\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"#include <...> search starts here:\":\n\t\t\tfor i = i + 1; i < len(a); {\n\t\t\t\tswitch v := a[i]; {\n\t\t\t\tcase strings.HasPrefix(v, \"#\") || v == \"End of search list.\":\n\t\t\t\t\treturn string(pre), includePaths, sysIncludePaths, nil\n\t\t\t\tdefault:\n\t\t\t\t\tsysIncludePaths = append(sysIncludePaths, strings.TrimSpace(v))\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\ti++\n\t\t}\n\t}\n\treturn \"\", nil, nil, fmt.Errorf(\"failed parsing %s -v output\", cpp)\n}\n\ntype tweaks struct {\n\tallowCompatibleTypedefRedefinitions bool              // typedef int foo; typedef int foo;\n\tcomments                            map[token.Pos]int //\n\tdevTest                             bool              //\n\tdisablePredefinedLineMacro          bool              // __LINE__ will not expand.\n\tenableAlignof                       bool              //\n\tenableAlternateKeywords             bool              // __asm__ etc.\n\tenableAnonymousStructFields         bool              //\n\tenableAsm                           bool              //\n\tenableBuiltinClassifyType           bool              // __builtin_classify_type(expr)\n\tenableBuiltinConstantP              bool              // __builtin_constant_p(expr)\n\tenableComputedGotos                 bool              // var = &&label; goto *var;\n\tenableDefineOmitCommaBeforeDDD      bool              // #define foo(a, b...)\n\tenableDlrInIdentifiers              bool              // foo$bar\n\tenableEmptyDeclarations             bool              // ; // C++11\n\tenableEmptyDefine                   bool              // #define\n\tenableEmptyStructs                  bool              // struct foo {};\n\tenableImaginarySuffix               bool              // 4.2i\n\tenableImplicitFuncDef               bool              // int f() { return g(); } int g() { return 42; }\n\tenableImplicitIntType               bool              // eg. 'static i;' is the same as 'static int i;'.\n\tenableIncludeNext                   bool              //\n\tenableLegacyDesignators             bool              // { a: 42 }\n\tenableNonConstStaticInitExpressions bool              // static int *p = &i;\n\tenableNoreturn                      bool              //\n\tenableOmitConditionalOperand        bool              // x ? : y == x ? x : y\n\tenableOmitFuncArgTypes              bool              // f(a) becomes the same as int f(int a).\n\tenableOmitFuncRetType               bool              // f() becomes the same as int f().\n\tenableParenCompoundStmt             bool              // ({...}), see [3]\n\tenableStaticAssert                  bool              // _Static_assert\n\tenableTrigraphs                     bool              // ??=define foo(bar)\n\tenableTypeof                        bool              //\n\tenableUndefExtraTokens              bool              // #undef foo(bar)\n\tenableUnsignedEnums                 bool              // If no enum member is negative, enum type will be unsigned.\n\tenableWarnings                      bool              // #warning\n\tenableWideBitFieldTypes             bool              // long long v : 2;\n\tenableWideEnumValues                bool              // enum { v = X } for X wider than 32bits\n\tgccEmu                              bool              //\n\tmode99c                             bool              //\n\tpreprocessOnly                      bool              //\n}\n\nfunc (t *tweaks) doGccEmu() *tweaks {\n\tt.allowCompatibleTypedefRedefinitions = true\n\tt.enableAlignof = true\n\tt.enableAlternateKeywords = true\n\tt.enableAnonymousStructFields = true\n\tt.enableAsm = true\n\tt.enableDefineOmitCommaBeforeDDD = true\n\tt.enableDlrInIdentifiers = true\n\tt.enableEmptyDefine = true\n\tt.enableEmptyStructs = true\n\tt.enableIncludeNext = true\n\tt.enableNonConstStaticInitExpressions = true\n\tt.enableNoreturn = true\n\tt.enableOmitFuncRetType = true\n\tt.enableStaticAssert = true\n\tt.enableTypeof = true\n\tt.enableUndefExtraTokens = true\n\tt.enableWarnings = false\n\treturn t\n}\n\nfunc exampleAST(rule int, src string) interface{} {\n\treport := xc.NewReport()\n\treport.IgnoreErrors = true\n\tr := bytes.NewBufferString(src)\n\tr0, _, _ := r.ReadRune()\n\tlx, err := newLexer(\n\t\tfmt.Sprintf(\"example%v.c\", rule),\n\t\tlen(src)+1, // Plus final injected NL\n\t\tr,\n\t\treport,\n\t\t(&tweaks{gccEmu: true}).doGccEmu(),\n\t)\n\tlx.Unget(lex.NewChar(token.Pos(lx.File.Base()), r0))\n\tlx.model = &Model{ // 64 bit\n\t\tItems: map[Kind]ModelItem{\n\t\t\tPtr:               {8, 8, 8, nil},\n\t\t\tVoid:              {0, 1, 1, nil},\n\t\t\tChar:              {1, 1, 1, nil},\n\t\t\tSChar:             {1, 1, 1, nil},\n\t\t\tUChar:             {1, 1, 1, nil},\n\t\t\tShort:             {2, 2, 2, nil},\n\t\t\tUShort:            {2, 2, 2, nil},\n\t\t\tInt:               {4, 4, 4, nil},\n\t\t\tUInt:              {4, 4, 4, nil},\n\t\t\tLong:              {8, 8, 8, nil},\n\t\t\tULong:             {8, 8, 8, nil},\n\t\t\tLongLong:          {8, 8, 8, nil},\n\t\t\tULongLong:         {8, 8, 8, nil},\n\t\t\tFloat:             {4, 4, 4, nil},\n\t\t\tDouble:            {8, 8, 8, nil},\n\t\t\tLongDouble:        {8, 8, 8, nil},\n\t\t\tBool:              {1, 1, 1, nil},\n\t\t\tFloatComplex:      {8, 8, 8, nil},\n\t\t\tDoubleComplex:     {16, 16, 16, nil},\n\t\t\tLongDoubleComplex: {16, 16, 16, nil},\n\t\t},\n\t\ttweaks: &tweaks{},\n\t}\n\n\tlx.model.initialize(lx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tlx.exampleRule = rule\n\tyyParse(lx)\n\treturn lx.example\n}\n\nfunc ppParseString(fn, src string, report *xc.Report, tweaks *tweaks) (*PreprocessingFile, error) {\n\tsz := len(src)\n\tlx, err := newLexer(fn, sz+1, bytes.NewBufferString(src), report, tweaks)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlx.Unget(lex.NewChar(token.Pos(lx.File.Base()), PREPROCESSING_FILE))\n\tyyParse(lx)\n\treturn lx.preprocessingFile, nil\n}\n\nfunc ppParse(fn string, report *xc.Report, tweaks *tweaks) (*PreprocessingFile, error) {\n\to := xc.Files.Once(fn, func() interface{} {\n\t\tf, err := os.Open(fn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tdefer f.Close()\n\n\t\tfi, err := os.Stat(fn)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tsz := fi.Size()\n\t\tif sz > mathutil.MaxInt-1 {\n\t\t\treturn fmt.Errorf(\"%s: file size too big: %v\", fn, sz)\n\t\t}\n\n\t\tlx, err := newLexer(fn, int(sz)+1, bufio.NewReader(f), report, tweaks)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlx.Unget(lex.NewChar(token.Pos(lx.File.Base()), PREPROCESSING_FILE))\n\t\tif yyParse(lx) != 0 {\n\t\t\treturn report.Errors(true)\n\t\t}\n\n\t\treturn lx.preprocessingFile\n\t})\n\tswitch r := o.Value(); x := r.(type) {\n\tcase error:\n\t\treturn nil, x\n\tcase *PreprocessingFile:\n\t\treturn x, nil\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// Opt is a configuration/setup function that can be passed to the Parser\n// function.\ntype Opt func(*lexer)\n\n// KeepComments makes the parser keep comments.\nfunc KeepComments() Opt {\n\treturn func(l *lexer) { l.tweaks.comments = map[token.Pos]int{} }\n}\n\n// EnableBuiltinClassifyType makes the parser handle specially\n//\n//\t__builtin_constant_p(expr)\n//\n// See https://gcc.gnu.org/onlinedocs/gccint/Varargs.html\nfunc EnableBuiltinClassifyType() Opt {\n\treturn func(l *lexer) { l.tweaks.enableBuiltinClassifyType = true }\n}\n\n// Mode99c turns on support for the 99c compiler.\nfunc Mode99c() Opt {\n\treturn func(l *lexer) { l.tweaks.mode99c = true }\n}\n\n// EnableBuiltinConstantP makes the parser handle specially\n//\n//\t__builtin_constant_p(expr)\n//\n// See https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html\nfunc EnableBuiltinConstantP() Opt {\n\treturn func(l *lexer) { l.tweaks.enableBuiltinConstantP = true }\n}\n\n// EnableImplicitIntType makes the parser accept non standard omitting type\n// specifier. For example\n//\n//\tstatic i;\n//\n// becomes the same as\n//\n//\tstatic int i;\n//\nfunc EnableImplicitIntType() Opt {\n\treturn func(l *lexer) { l.tweaks.enableImplicitIntType = true }\n}\n\n// EnableOmitConditionalOperand makes the parser accept non standard\n//\n//\tx ? : y\n//\n// See https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Conditionals.html#Conditionals\nfunc EnableOmitConditionalOperand() Opt {\n\treturn func(l *lexer) { l.tweaks.enableOmitConditionalOperand = true }\n}\n\n// EnableComputedGotos makes the parser accept non standard\n//\n//\tvariable = &&label;\n//\tgoto *variable;\n//\n// See https://gcc.gnu.org/onlinedocs/gcc-3.3/gcc/Labels-as-Values.html\nfunc EnableComputedGotos() Opt {\n\treturn func(l *lexer) { l.tweaks.enableComputedGotos = true }\n}\n\n// EnableUnsignedEnums makes the parser handle choose unsigned int as the type\n// of an enumeration with no negative members.\nfunc EnableUnsignedEnums() Opt {\n\treturn func(l *lexer) { l.tweaks.enableUnsignedEnums = true }\n}\n\n// EnableLegacyDesignators makes the parser accept legacy designators\n//\n//\t{ a: 42 } // Obsolete since GCC 2.5, standard is { .a=42 }\n//\n// See https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html\nfunc EnableLegacyDesignators() Opt {\n\treturn func(l *lexer) { l.tweaks.enableLegacyDesignators = true }\n}\n\n// AllowCompatibleTypedefRedefinitions makes the parser accept compatible\n// typedef redefinitions.\n//\n//\ttypedef int foo;\n//\ttypedef int foo; // ok with this option.\n//\ttypedef long int foo; // never ok.\n//\nfunc AllowCompatibleTypedefRedefinitions() Opt {\n\treturn func(l *lexer) { l.tweaks.allowCompatibleTypedefRedefinitions = true }\n}\n\n// EnableParenthesizedCompoundStatemen makes the parser accept non standard\n//\n//\t({ ... })\n//\n// as an expression. See [3].\nfunc EnableParenthesizedCompoundStatemen() Opt {\n\treturn func(l *lexer) { l.tweaks.enableParenCompoundStmt = true }\n}\n\n// EnableImaginarySuffix makes the parser accept non standard\n//\n//\t4.2i, 5.6j etc\n//\n// See https://gcc.gnu.org/onlinedocs/gcc/Complex.html\nfunc EnableImaginarySuffix() Opt {\n\treturn func(l *lexer) { l.tweaks.enableImaginarySuffix = true }\n}\n\n// EnableNonConstStaticInitExpressions makes the parser accept non standard\n//\n//\tstatic int i = f();\n//\n// [0], 6.7.8/4: All the expressions in an initializer for an object that has\n// static storage duration shall be constant expressions or string literals.\nfunc EnableNonConstStaticInitExpressions() Opt {\n\treturn func(l *lexer) { l.tweaks.enableNonConstStaticInitExpressions = true }\n}\n\n// EnableAnonymousStructFields makes the parser accept non standard\n//\n//\tstruct {\n//\t\tint i;\n//\t\tstruct {\n//\t\t\tint j;\n//\t\t};\n//\t\tint k;\n//\t};\nfunc EnableAnonymousStructFields() Opt {\n\treturn func(l *lexer) { l.tweaks.enableAnonymousStructFields = true }\n}\n\n// EnableOmitFuncRetType makes the parser accept non standard\n//\n//\tf() // Same as int f().\nfunc EnableOmitFuncRetType() Opt {\n\treturn func(l *lexer) { l.tweaks.enableOmitFuncRetType = true }\n}\n\n// EnableOmitFuncArgTypes makes the parser accept non standard\n//\n//\tf(a) // Same as int f(int a).\nfunc EnableOmitFuncArgTypes() Opt {\n\treturn func(l *lexer) { l.tweaks.enableOmitFuncArgTypes = true }\n}\n\n// EnableEmptyDeclarations makes the parser accept non standard\n//\n//\t; // C++11 empty declaration\nfunc EnableEmptyDeclarations() Opt {\n\treturn func(l *lexer) { l.tweaks.enableEmptyDeclarations = true }\n}\n\n// EnableIncludeNext makes the parser accept non standard\n//\n//\t#include_next \"foo.h\"\nfunc EnableIncludeNext() Opt {\n\treturn func(l *lexer) { l.tweaks.enableIncludeNext = true }\n}\n\n// EnableDefineOmitCommaBeforeDDD makes the parser accept non standard\n//\n//\t#define foo(a, b...) // Note the missing comma after identifier list.\nfunc EnableDefineOmitCommaBeforeDDD() Opt {\n\treturn func(l *lexer) { l.tweaks.enableDefineOmitCommaBeforeDDD = true }\n}\n\n// EnableAlternateKeywords makes the parser accept, for example, non standard\n//\n//\t__asm__\n//\n// as an equvalent of keyowrd asm (which first hast be permitted by EnableAsm).\nfunc EnableAlternateKeywords() Opt {\n\treturn func(l *lexer) { l.tweaks.enableAlternateKeywords = true }\n}\n\n// EnableDlrInIdentifiers makes the parser accept non standard\n//\n//\tint foo$bar\nfunc EnableDlrInIdentifiers() Opt {\n\treturn func(l *lexer) { l.tweaks.enableDlrInIdentifiers = true }\n}\n\n// EnableEmptyDefine makes the parser accept non standard\n//\n//\t#define\nfunc EnableEmptyDefine() Opt {\n\treturn func(l *lexer) { l.tweaks.enableEmptyDefine = true }\n}\n\n// EnableImplicitFuncDef makes the parser accept non standard\n//\n//\tint f() {\n//\t\treturn g(); // g is undefined, but assumed to be returning int.\n//\t}\nfunc EnableImplicitFuncDef() Opt {\n\treturn func(l *lexer) { l.tweaks.enableImplicitFuncDef = true }\n}\n\n// EnableEmptyStructs makes the parser accept non standard\n//\n//\tstruct foo {};\nfunc EnableEmptyStructs() Opt {\n\treturn func(l *lexer) { l.tweaks.enableEmptyStructs = true }\n}\n\n// EnableUndefExtraTokens makes the parser accept non standard\n//\n//\t#undef foo(bar)\nfunc EnableUndefExtraTokens() Opt {\n\treturn func(l *lexer) { l.tweaks.enableUndefExtraTokens = true }\n}\n\n// EnableWideEnumValues makes the parser accept non standard\n//\n//\tenum { v = X }; for X wider than 32 bits.\nfunc EnableWideEnumValues() Opt {\n\treturn func(l *lexer) { l.tweaks.enableWideEnumValues = true }\n}\n\n// EnableWideBitFieldTypes makes the parser accept non standard bitfield\n// types (i.e, long long and unsigned long long).\n//\n//\tunsigned long long bits : 2;\nfunc EnableWideBitFieldTypes() Opt {\n\treturn func(l *lexer) { l.tweaks.enableWideBitFieldTypes = true }\n}\n\n// SysIncludePaths option configures where to search for system include files\n// (eg. <name.h>). Multiple SysIncludePaths options may be used, the resulting\n// search path list is produced by appending the option arguments in order of\n// appearance.\nfunc SysIncludePaths(paths []string) Opt {\n\treturn func(l *lexer) {\n\t\tvar err error\n\t\tif l.sysIncludePaths, err = dedupAbsPaths(append(l.sysIncludePaths, fromSlashes(paths)...)); err != nil {\n\t\t\tl.report.Err(0, \"synIncludepaths option: %v\", err)\n\t\t}\n\t\tl.sysIncludePaths = l.sysIncludePaths[:len(l.sysIncludePaths):len(l.sysIncludePaths)]\n\t}\n}\n\n// IncludePaths option configures where to search for include files (eg.\n// \"name.h\").  Multiple IncludePaths options may be used, the resulting search\n// path list is produced by appending the option arguments in order of\n// appearance.\nfunc IncludePaths(paths []string) Opt {\n\treturn func(l *lexer) {\n\t\tvar err error\n\t\tif l.includePaths, err = dedupAbsPaths(append(l.includePaths, fromSlashes(paths)...)); err != nil {\n\t\t\tl.report.Err(0, \"includepaths option: %v\", err)\n\t\t}\n\t\tl.includePaths = l.includePaths[:len(l.includePaths):len(l.includePaths)]\n\t}\n}\n\n// YyDebug sets the parser debug level.\nfunc YyDebug(n int) Opt {\n\treturn func(*lexer) { yyDebug = n }\n}\n\n// Cpp registers a preprocessor hook function which is called for every line,\n// or group of lines the preprocessor produces before it is consumed by the\n// parser. The token slice must not be modified by the hook.\nfunc Cpp(f func([]xc.Token)) Opt {\n\treturn func(lx *lexer) { lx.cpp = f }\n}\n\n// ErrLimit limits the number of calls to the error reporting methods.  After\n// the limit is reached, all errors are reported using log.Print and then\n// log.Fatal() is called with a message about too many errors.  To disable\n// error limit, set ErrLimit to value less or equal zero.  Default value is 10.\nfunc ErrLimit(n int) Opt {\n\treturn func(lx *lexer) { lx.report.ErrLimit = n }\n}\n\n// Trigraphs enables processing of trigraphs.\nfunc Trigraphs() Opt { return func(lx *lexer) { lx.tweaks.enableTrigraphs = true } }\n\n// EnableAsm enables recognizing the reserved word asm.\nfunc EnableAsm() Opt { return func(lx *lexer) { lx.tweaks.enableAsm = true } }\n\n// EnableNoreturn enables recognizing the reserved word _Noreturn.\nfunc EnableNoreturn() Opt { return func(lx *lexer) { lx.tweaks.enableNoreturn = true } }\n\n// EnableTypeOf enables recognizing the reserved word typeof.\nfunc EnableTypeOf() Opt { return func(lx *lexer) { lx.tweaks.enableTypeof = true } }\n\n// EnableAlignOf enables recognizing the reserved word _Alignof.\nfunc EnableAlignOf() Opt { return func(lx *lexer) { lx.tweaks.enableAlignof = true } }\n\n// EnableStaticAssert enables recognizing the reserved word _Static_assert.\nfunc EnableStaticAssert() Opt { return func(lx *lexer) { lx.tweaks.enableStaticAssert = true } }\n\n// CrashOnError is an debugging option.\nfunc CrashOnError() Opt { return func(lx *lexer) { lx.report.PanicOnError = true } }\n\nfunc disableWarnings() Opt      { return func(lx *lexer) { lx.tweaks.enableWarnings = false } }\nfunc gccEmu() Opt               { return func(lx *lexer) { lx.tweaks.gccEmu = true } }\nfunc getTweaks(dst *tweaks) Opt { return func(lx *lexer) { *dst = *lx.tweaks } }\nfunc nopOpt() Opt               { return func(*lexer) {} }\nfunc preprocessOnly() Opt       { return func(lx *lexer) { lx.tweaks.preprocessOnly = true } }\n\nfunc devTest() Opt {\n\treturn func(lx *lexer) { lx.tweaks.devTest = true }\n}\n\nfunc disablePredefinedLineMacro() Opt {\n\treturn func(lx *lexer) { lx.tweaks.disablePredefinedLineMacro = true }\n}\n\n// Parse defines any macros in predefine. Then Parse preprocesses and parses\n// the translation unit consisting of files in paths. The m communicates the\n// scalar types model and opts allow to amend parser behavior. m cannot be\n// reused and passed to Parse again.\nfunc Parse(predefine string, paths []string, m *Model, opts ...Opt) (*TranslationUnit, error) {\n\tif m == nil {\n\t\treturn nil, fmt.Errorf(\"invalid nil model passed\")\n\t}\n\n\tif m.initialized {\n\t\treturn nil, fmt.Errorf(\"invalid reused model passed\")\n\t}\n\n\tfromSlashes(paths)\n\treport := xc.NewReport()\n\tlx0 := &lexer{tweaks: &tweaks{enableWarnings: true}, report: report}\n\tfor _, opt := range opts {\n\t\topt(lx0)\n\t}\n\tm.tweaks = lx0.tweaks\n\tif err := report.Errors(true); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif lx0.tweaks.devTest {\n\t\tpredefine += fmt.Sprintf(`\n#define __DATE__ %q\n#define __TIME__ %q\n`, xc.Dict.S(idTDate), fakeTime)\n\t}\n\n\tif t := lx0.tweaks; t.gccEmu {\n\t\tt.doGccEmu()\n\t}\n\n\tm.initialize(lx0)\n\tif err := m.sanityCheck(); err != nil {\n\t\treport.Err(0, \"%s\", err.Error())\n\t\treturn nil, report.Errors(true)\n\t}\n\n\tif lx0.tweaks.gccEmu {\n\t\tdts := debugTypeStrings\n\t\tdebugTypeStrings = false\n\t\tpredefine += fmt.Sprintf(gccPredefine, m.getSizeType(lx0))\n\t\tdebugTypeStrings = dts\n\t}\n\ttweaks := lx0.tweaks\n\tpredefined, err := ppParseString(\"<predefine>\", predefine, report, tweaks)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tch := make(chan []xc.Token, 1000)\n\tmacros := newMacros()\n\tstop := make(chan int, 1)\n\tgo func() {\n\t\tdefer close(ch)\n\n\t\tnewPP(ch, lx0.includePaths, lx0.sysIncludePaths, macros, false, m, report, tweaks).preprocessingFile(predefined)\n\t\tfor _, path := range paths {\n\t\t\tselect {\n\t\t\tcase <-stop:\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t}\n\t\t\tpf, err := ppParse(path, report, tweaks)\n\t\t\tif err != nil {\n\t\t\t\treport.Err(0, err.Error())\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tnewPP(ch, lx0.includePaths, lx0.sysIncludePaths, macros, true, m, report, tweaks).preprocessingFile(pf)\n\t\t}\n\t}()\n\n\tif err := report.Errors(true); err != nil { // Do not parse if preprocessing already failed.\n\t\tgo func() {\n\t\t\tfor range ch { // Drain.\n\t\t\t}\n\t\t}()\n\t\tstop <- 1\n\t\treturn nil, err\n\t}\n\n\tlx := newSimpleLexer(lx0.cpp, report, tweaks)\n\tlx.ch = ch\n\tlx.state = lsTranslationUnit0\n\tlx.model = m\n\tif lx.tweaks.preprocessOnly {\n\t\tvar lval yySymType\n\t\tfor lval.Token.Rune != lex.RuneEOF {\n\t\t\tlx.Lex(&lval)\n\t\t}\n\t\treturn nil, report.Errors(true)\n\t}\n\n\tyyParse(lx)\n\tstop <- 1\n\tfor range ch { // Drain.\n\t}\n\tif tu := lx.translationUnit; tu != nil {\n\t\ttu.Macros = macros.macros()\n\t\ttu.Model = m\n\t\ttu.Comments = lx0.tweaks.comments\n\t\tif c := tu.Comments; c != nil {\n\t\t\tfor _, v := range tu.Declarations.Identifiers {\n\t\t\t\tswitch x := v.Node.(type) {\n\t\t\t\tcase *DirectDeclarator:\n\t\t\t\t\tpos0 := x.Declarator.Pos()\n\t\t\t\t\tif !pos0.IsValid() {\n\t\t\t\t\t\tpos0 = x.Pos()\n\t\t\t\t\t}\n\t\t\t\t\tif !pos0.IsValid() {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tif comment(lx0.tweaks, x, x.Declarator) != 0 {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tfor p := x.prev; p != nil; {\n\t\t\t\t\t\ty := p.Node.(*DirectDeclarator)\n\t\t\t\t\t\tif n := comment(lx0.tweaks, y, y.Declarator); n != 0 {\n\t\t\t\t\t\t\tpos := y.DirectDeclarator.Pos()\n\t\t\t\t\t\t\tif !pos.IsValid() {\n\t\t\t\t\t\t\t\tpos = y.Pos()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tc[pos0] = n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tp2 := p.Node.(*DirectDeclarator).prev\n\t\t\t\t\t\tif p2 == p {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp = p2\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn lx.translationUnit, report.Errors(true)\n}\n"
  },
  {
    "path": "cpp.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\t_ tokenReader = (*tokenBuf)(nil)\n\t_ tokenReader = (*tokenPipe)(nil)\n)\n\nconst (\n\tmaxIncludeLevel = 100\n\tsentinel        = -1\n)\n\nvar (\n\tprotectedMacros = map[int]bool{\n\t\tidDate:             true,\n\t\tidDefined:          true,\n\t\tidFile:             true,\n\t\tidLine:             true,\n\t\tidSTDC:             true,\n\t\tidSTDCHosted:       true,\n\t\tidSTDCMBMightNeqWc: true,\n\t\tidSTDCVersion:      true,\n\t\tidTime:             true,\n\t\tidVAARGS:           true,\n\t}\n)\n\n// Macro represents a C preprocessor macro.\ntype Macro struct {\n\tArgs      []int       // Numeric IDs of argument identifiers.\n\tDefTok    xc.Token    // Macro name definition token.\n\tIsFnLike  bool        // Whether the macro is function like.\n\tType      Type        // Non nil if macro expands to a constant expression.\n\tValue     interface{} // Non nil if macro expands to a constant expression.\n\tellipsis  bool        // Macro definition uses the idList, ... notation.\n\tellipsis2 bool        // Macro definition uses the idList... notation.\n\tnonRepl   []bool      // Non replaceable, due to # or ##, arguments of a fn-like macro.\n\trepl      PPTokenList //\n}\n\n// ReplacementToks returns the tokens that replace m.\nfunc (m *Macro) ReplacementToks() (r []xc.Token) { return decodeTokens(m.repl, nil, false) }\n\nfunc (m *Macro) findArg(nm int) int {\n\tfor i, v := range m.Args {\n\t\tif v == nm {\n\t\t\treturn i\n\t\t}\n\t}\n\n\tif m.ellipsis && nm == idVAARGS {\n\t\treturn len(m.Args)\n\t}\n\n\treturn -1\n}\n\ntype macros struct {\n\tm     map[int]*Macro\n\tpp    *pp\n\tstack map[int][]*Macro\n}\n\nfunc newMacros() *macros {\n\treturn &macros{\n\t\tm:     map[int]*Macro{},\n\t\tstack: map[int][]*Macro{},\n\t}\n}\n\nfunc (m *macros) macros() map[int]*Macro {\n\tp := m.pp\n\tdefer func(ie bool) {\n\t\tp.report.IgnoreErrors = ie\n\t}(p.report.IgnoreErrors)\n\n\tp.report.IgnoreErrors = true\n\tr := map[int]*Macro{}\n\tfor id, macro := range m.m {\n\t\tr[id] = macro\n\n\t\tif macro.IsFnLike {\n\t\t\tcontinue\n\t\t}\n\n\t\trl := macro.repl\n\t\tif rl == 0 {\n\t\t\tmacro.Value = true // #define foo -> foo: true.\n\t\t\tmacro.Type = p.model.BoolType\n\t\t\tcontinue\n\t\t}\n\n\t\tmacro.Value, macro.Type = p.lx.parsePPConstExpr0(rl, p)\n\t}\n\treturn r\n}\n\ntype tokenReader interface {\n\teof(more bool) bool\n\tpeek() xc.Token\n\tread() xc.Token\n\tunget([]xc.Token)\n}\n\ntype tokenBuf struct {\n\ttoks []xc.Token\n}\n\n// Implements tokenReader.\nfunc (t *tokenBuf) eof(bool) bool { return len(t.toks) == 0 }\n\n// Implements tokenReader.\nfunc (t *tokenBuf) peek() xc.Token { return t.toks[0] }\n\n// Implements tokenReader.\nfunc (t *tokenBuf) read() xc.Token { r := t.peek(); t.toks = t.toks[1:]; return r }\n\n// Implements tokenReader.\nfunc (t *tokenBuf) unget(toks []xc.Token) { t.toks = append(toks[:len(toks):len(toks)], t.toks...) }\n\ntype tokenPipe struct {\n\tack     chan struct{}\n\tackMore bool\n\tclosed  bool\n\tin      []xc.Token\n\tlast    xc.Token\n\tout     []xc.Token\n\tr       chan []xc.Token\n\tw       chan []xc.Token\n}\n\n// Implements tokenReader.\nfunc (t *tokenPipe) eof(more bool) bool {\nagain:\n\tif len(t.in) != 0 {\n\t\treturn false\n\t}\n\n\tif t.closed {\n\t\treturn true\n\t}\n\n\tt.flush(false)\n\tif !more {\n\t\treturn true\n\t}\n\n\tif t.ackMore {\n\t\tt.ack <- struct{}{}\n\t}\n\tvar ok bool\n\tif t.in, ok = <-t.r; !ok {\n\t\tt.closed = true\n\t\treturn true\n\t}\n\n\tif len(t.in) != 0 && t.last.Rune == ' ' && t.in[0].Rune == ' ' {\n\t\tt.in = t.in[1:]\n\t\tgoto again\n\t}\n\n\tif n := len(t.in); n > 1 && t.in[n-1].Rune == ' ' && t.in[n-2].Rune == ' ' {\n\t\tt.in = t.in[:n-1]\n\t\tgoto again\n\t}\n\n\treturn false\n}\n\n// Implements tokenReader.\nfunc (t *tokenPipe) peek() xc.Token { return t.in[0] }\n\n// Implements tokenReader.\nfunc (t *tokenPipe) read() xc.Token {\n\tr := t.peek()\n\tt.in = t.in[1:]\n\tt.last = r\n\treturn r\n}\n\n// Implements tokenReader.\nfunc (t *tokenPipe) unget(toks []xc.Token) {\n\tt.in = append(toks[:len(toks):len(toks)], t.in...)\n}\n\nfunc (t *tokenPipe) flush(final bool) {\n\tt.out = trimSpace(t.out, false)\n\tif n := len(t.out); !final && n != 0 {\n\t\tif tok := t.out[n-1]; tok.Rune == STRINGLITERAL || tok.Rune == LONGSTRINGLITERAL {\n\t\t\t// Accumulate lines b/c of possible string concatenation of preprocessing phase 6.\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Preproc phase 6. Adjacent string literal tokens are concatenated.\n\tw := 0\n\tfor r := 0; r < len(t.out); r++ {\n\t\tv := t.out[r]\n\t\tswitch v.Rune {\n\t\tcase IDENTIFIER_NONREPL:\n\t\t\tv.Rune = IDENTIFIER\n\t\t\tt.out[w] = v\n\t\t\tw++\n\t\tcase STRINGLITERAL, LONGSTRINGLITERAL:\n\t\t\tto := r\n\t\tloop:\n\t\t\tfor to < len(t.out)-1 {\n\t\t\t\tswitch t.out[to+1].Rune {\n\t\t\t\tcase STRINGLITERAL, LONGSTRINGLITERAL, ' ':\n\t\t\t\t\tto++\n\t\t\t\tdefault:\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor t.out[to].Rune == ' ' {\n\t\t\t\tto--\n\t\t\t}\n\t\t\tif to == r {\n\t\t\t\tt.out[w] = v\n\t\t\t\tw++\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tvar buf bytes.Buffer\n\t\t\ts := v.S()\n\t\t\ts = s[:len(s)-1] // Remove trailing \"\n\t\t\tbuf.Write(s)\n\t\t\tfor i := r + 1; i <= to; i++ {\n\t\t\t\tif t.out[i].Rune == ' ' {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\ts = dict.S(t.out[i].Val)\n\t\t\t\ts = s[1 : len(s)-1] // Remove leading and trailing \"\n\t\t\t\tbuf.Write(s)\n\t\t\t}\n\t\t\tr = to\n\t\t\tbuf.WriteByte('\"')\n\t\t\tv.Val = dict.ID(buf.Bytes())\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tt.out[w] = v\n\t\t\tw++\n\t\t}\n\t}\n\tt.out = t.out[:w]\n\tif w == 0 {\n\t\treturn\n\t}\n\n\tt.w <- t.out\n\tt.out = nil\n}\n\ntype pp struct {\n\tack                chan struct{}      // Must be unbuffered.\n\texpandingMacros    map[int]int        //\n\tin                 chan []xc.Token    // Must be unbuffered.\n\tincludeLevel       int                //\n\tincludedSearchPath string             //\n\tincludes           []string           //\n\tlx                 *lexer             //\n\tmacros             *macros            //\n\tmodel              *Model             //\n\tppf                *PreprocessingFile //\n\tprotectMacros      bool               //\n\treport             *xc.Report         //\n\tsysIncludes        []string           //\n\ttweaks             *tweaks            //\n}\n\nfunc newPP(ch chan []xc.Token, includes, sysIncludes []string, macros *macros, protectMacros bool, model *Model, report *xc.Report, tweaks *tweaks) *pp {\n\tvar err error\n\tif includes, err = dedupAbsPaths(append(includes[:len(includes):len(includes)], sysIncludes...)); err != nil {\n\t\treport.Err(0, \"%s\", err)\n\t\treturn nil\n\t}\n\tpp := &pp{\n\t\tack:             make(chan struct{}),\n\t\texpandingMacros: map[int]int{},\n\t\tin:              make(chan []xc.Token),\n\t\tincludes:        includes,\n\t\tlx:              newSimpleLexer(nil, report, tweaks),\n\t\tmacros:          macros,\n\t\tmodel:           model,\n\t\tprotectMacros:   protectMacros,\n\t\treport:          report,\n\t\tsysIncludes:     sysIncludes,\n\t\ttweaks:          tweaks,\n\t}\n\tmacros.pp = pp\n\tpp.lx.model = model\n\tmodel.initialize(pp.lx)\n\tgo pp.pp2(ch)\n\treturn pp\n}\n\nfunc (p *pp) pp2(ch chan []xc.Token) {\n\tpipe := &tokenPipe{ack: p.ack, r: p.in, w: ch}\n\tfor !pipe.eof(true) {\n\t\tpipe.ackMore = true\n\t\tp.expand(pipe, false, func(toks []xc.Token) { pipe.out = append(pipe.out, toks...) })\n\t\tpipe.ackMore = false\n\t\tp.ack <- struct{}{}\n\t}\n\tpipe.flush(true)\n\tp.ack <- struct{}{}\n}\n\nfunc (p *pp) checkCompatibleReplacementTokenList(tok xc.Token, oldList, newList PPTokenList) {\n\tex := trimSpace(decodeTokens(oldList, nil, true), false)\n\ttoks := trimSpace(decodeTokens(newList, nil, true), false)\n\n\tif g, e := len(toks), len(ex); g != e && len(ex) > 0 {\n\t\tp.report.ErrTok(tok, \"cannot redefine macro using a replacement list of different length\")\n\t\treturn\n\t}\n\n\tif len(toks) == 0 || len(ex) == 0 {\n\t\treturn\n\t}\n\n\tif g, e := whitespace(toks), whitespace(ex); !bytes.Equal(g, e) {\n\t\tp.report.ErrTok(tok, \"cannot redefine macro, whitespace differs\")\n\t}\n\n\tfor i, g := range toks {\n\t\tif e := ex[i]; g.Rune != e.Rune || g.Val != e.Val {\n\t\t\tp.report.ErrTok(tok, \"cannot redefine macro using a different replacement list\")\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc (p *pp) defineMacro(tok xc.Token, repl PPTokenList) {\n\tnm := tok.Val\n\tif protectedMacros[nm] && p.protectMacros {\n\t\tp.report.ErrTok(tok, \"cannot define protected macro\")\n\t\treturn\n\t}\n\n\tm := p.macros.m[nm]\n\tif m == nil {\n\t\tif debugMacros {\n\t\t\ttoks := trimSpace(decodeTokens(repl, nil, true), false)\n\t\t\tvar a [][]byte\n\t\t\tfor _, v := range toks {\n\t\t\t\ta = append(a, xc.Dict.S(tokVal(v)))\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, \"%s: #define %s %s\\n\", tok.Position(), tok.S(), bytes.Join(a, nil))\n\t\t}\n\t\tp.macros.m[nm] = &Macro{DefTok: tok, repl: repl}\n\t\treturn\n\t}\n\n\tif m.IsFnLike {\n\t\tp.report.ErrTok(tok, \"cannot redefine a function-like macro using an object-like macro\")\n\t\treturn\n\t}\n\n\tp.checkCompatibleReplacementTokenList(tok, m.repl, repl)\n}\n\nfunc (p *pp) defineFnMacro(tok xc.Token, il *IdentifierList, repl PPTokenList, ellipsis, ellipsis2 bool) {\n\tnm0 := tok.S()\n\tnm := dict.ID(nm0[:len(nm0)-1])\n\tif protectedMacros[nm] && p.protectMacros {\n\t\tp.report.ErrTok(tok, \"cannot define protected macro %s\", xc.Dict.S(nm))\n\t\treturn\n\t}\n\n\tvar args []int\n\tfor ; il != nil; il = il.IdentifierList {\n\t\ttok := il.Token2\n\t\tif !tok.IsValid() {\n\t\t\ttok = il.Token\n\t\t}\n\t\targs = append(args, tok.Val)\n\t}\n\tm := p.macros.m[nm]\n\tdefTok := tok\n\tdefTok.Rune = IDENTIFIER\n\tdefTok.Val = nm\n\tif m == nil {\n\t\treplToks := decodeTokens(repl, nil, false)\n\t\tif debugMacros {\n\t\t\ttoks := trimSpace(replToks, false)\n\t\t\tvar p [][]byte\n\t\t\tfor _, v := range args {\n\t\t\t\tp = append(p, xc.Dict.S(v))\n\t\t\t}\n\t\t\tvar a [][]byte\n\t\t\tfor _, v := range toks {\n\t\t\t\ta = append(a, xc.Dict.S(tokVal(v)))\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, \"%s: #define %s%s) %s\\n\", tok.Position(), tok.S(), bytes.Join(p, []byte(\", \")), bytes.Join(a, nil))\n\t\t}\n\t\tnonRepl := make([]bool, len(args))\n\t\tmp := map[int]struct{}{}\n\t\tfor i, v := range replToks {\n\t\t\tswitch v.Rune {\n\t\t\tcase PPPASTE:\n\t\t\t\tif i > 0 {\n\t\t\t\t\tif tok := replToks[i-1]; tok.Rune == IDENTIFIER {\n\t\t\t\t\t\tmp[tok.Val] = struct{}{}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfallthrough\n\t\t\tcase '#':\n\t\t\t\tif i < len(replToks)-1 {\n\t\t\t\t\tif tok := replToks[i+1]; tok.Rune == IDENTIFIER {\n\t\t\t\t\t\tmp[tok.Val] = struct{}{}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tm := &Macro{Args: args, DefTok: defTok, IsFnLike: true, repl: repl, ellipsis: ellipsis, ellipsis2: ellipsis2}\n\t\tfor nm := range mp {\n\t\t\tif i := m.findArg(nm); i >= 0 && i < len(nonRepl) {\n\t\t\t\tnonRepl[i] = true\n\t\t\t}\n\t\t}\n\t\tm.nonRepl = nonRepl\n\t\tp.macros.m[nm] = m\n\t\treturn\n\t}\n\n\tif !m.IsFnLike {\n\t\tp.report.ErrTok(tok, \"cannot redefine an object-like macro %s using a function-like macro\", xc.Dict.S(nm))\n\t\treturn\n\t}\n\n\tif g, e := len(args), len(m.Args); g != e {\n\t\tp.report.ErrTok(tok, \"cannot redefine macro %s: number of arguments differ\", xc.Dict.S(nm))\n\t\treturn\n\t}\n\n\tfor i, g := range args {\n\t\tif e := m.Args[i]; g != e {\n\t\t\tp.report.ErrTok(tok, \"cannot redefine macro %s: argument names differ\", xc.Dict.S(nm))\n\t\t\treturn\n\t\t}\n\t}\n\n\tp.checkCompatibleReplacementTokenList(tok, m.repl, repl)\n}\n\nfunc (p *pp) expand(r tokenReader, handleDefined bool, w func([]xc.Token)) {\n\tfor !r.eof(false) {\n\t\ttok := r.read()\n\t\tswitch tok.Rune {\n\t\tcase sentinel:\n\t\t\tp.expandingMacros[tok.Val]--\n\t\tcase IDENTIFIER:\n\t\t\tif tok.Val == idFile {\n\t\t\t\ttok.Rune = STRINGLITERAL\n\t\t\t\ttok.Val = dict.SID(fmt.Sprintf(\"%q\", tok.Position().Filename))\n\t\t\t\tw([]xc.Token{tok})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif tok.Val == idLine && !p.tweaks.disablePredefinedLineMacro {\n\t\t\t\ttok.Rune = INTCONST\n\t\t\t\ttok.Val = dict.SID(strconv.Itoa(position(tok.Pos()).Line))\n\t\t\t\tw([]xc.Token{tok})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif handleDefined && tok.Val == idDefined {\n\t\t\t\tp.expandDefined(tok, r, w)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tm := p.macros.m[tok.Val]\n\t\t\tif m == nil {\n\t\t\t\tw([]xc.Token{tok})\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tp.expandMacro(tok, r, m, handleDefined, w)\n\t\tdefault:\n\t\t\tw([]xc.Token{tok})\n\t\t}\n\t}\n}\n\nfunc (p *pp) expandDefined(tok xc.Token, r tokenReader, w func([]xc.Token)) {\nagain:\n\tif r.eof(false) {\n\t\tp.report.ErrTok(tok, \"'defined' with no argument\")\n\t\treturn\n\t}\n\n\tswitch tok = r.read(); tok.Rune {\n\tcase ' ':\n\t\tgoto again\n\tcase '(': // defined (IDENTIFIER)\n\tagain2:\n\t\tif r.eof(false) {\n\t\t\tp.report.ErrTok(tok, \"'defined' with no argument\")\n\t\t\treturn\n\t\t}\n\n\t\ttok = r.read()\n\t\tswitch tok.Rune {\n\t\tcase IDENTIFIER:\n\t\t\tv := tok\n\t\t\tv.Rune = INTCONST\n\t\t\tif p.macros.m[tok.Val] != nil {\n\t\t\t\tv.Val = id1\n\t\t\t} else {\n\t\t\t\tv.Val = id0\n\t\t\t}\n\n\t\tagain3:\n\t\t\tif r.eof(false) {\n\t\t\t\tp.report.ErrTok(tok, \"must be followed by ')'\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ttok = r.read()\n\t\t\tif tok.Rune == ' ' {\n\t\t\t\tgoto again3\n\t\t\t}\n\n\t\t\tif tok.Rune != ')' {\n\t\t\t\tp.report.ErrTok(tok, \"expected ')'\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tw([]xc.Token{v})\n\t\tcase ' ':\n\t\t\tgoto again2\n\t\tdefault:\n\t\t\tp.report.ErrTok(tok, \"expected identifier\")\n\t\t\treturn\n\t\t}\n\tcase IDENTIFIER:\n\t\tv := tok\n\t\tv.Rune = INTCONST\n\t\tif p.macros.m[tok.Val] != nil {\n\t\t\tv.Val = id1\n\t\t} else {\n\t\t\tv.Val = id0\n\t\t}\n\n\t\tw([]xc.Token{v})\n\tdefault:\n\t\tpanic(PrettyString(tok))\n\t}\n}\n\nfunc (p *pp) expandMacro(tok xc.Token, r tokenReader, m *Macro, handleDefined bool, w func([]xc.Token)) {\n\tnm := tok.Val\n\tif m.IsFnLike {\n\t\tp.expandFnMacro(tok, r, m, handleDefined, w)\n\t\treturn\n\t}\n\n\trepl := trimSpace(normalizeToks(decodeTokens(m.repl, nil, true)), false)\n\trepl = pasteToks(repl)\n\tpos := tok.Pos()\n\tfor i, v := range repl {\n\t\trepl[i].Char = lex.NewChar(pos, v.Rune)\n\t}\n\ttok.Rune = sentinel\n\tp.expandingMacros[nm]++\n\ty := append(p.sanitize(p.expandLineNo(p.pragmas(repl))), tok)\n\tr.unget(y)\n}\n\nfunc trimSpace(toks []xc.Token, removeTrailingComma bool) []xc.Token {\n\tif len(toks) == 0 {\n\t\treturn nil\n\t}\n\n\tif removeTrailingComma {\n\t\tif tok := toks[len(toks)-1]; tok.Rune == ',' {\n\t\t\ttoks = toks[:len(toks)-1]\n\t\t}\n\t}\n\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\ttoks = toks[1:]\n\t}\n\tfor len(toks) != 0 && toks[len(toks)-1].Rune == ' ' {\n\t\ttoks = toks[:len(toks)-1]\n\t}\n\treturn toks\n}\n\nfunc (p *pp) pragmas(toks []xc.Token) []xc.Token {\n\tvar r []xc.Token\n\tfor len(toks) != 0 {\n\t\tswitch tok := toks[0]; {\n\t\tcase tok.Rune == IDENTIFIER && tok.Val == idPragma:\n\t\t\ttoks = toks[1:]\n\t\t\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\t\t\ttoks = toks[1:]\n\t\t\t}\n\t\t\tif len(toks) == 0 {\n\t\t\t\tp.report.ErrTok(tok, \"malformed _Pragma unary operator expression.\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\tif toks[0].Rune != '(' {\n\t\t\t\tp.report.ErrTok(toks[0], \"expected '('\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\ttoks = toks[1:]\n\t\t\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\t\t\ttoks = toks[1:]\n\t\t\t}\n\t\t\tif len(toks) == 0 {\n\t\t\t\tp.report.ErrTok(tok, \"malformed _Pragma unary operator expression.\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\tif toks[0].Rune != STRINGLITERAL && toks[0].Rune != LONGSTRINGLITERAL {\n\t\t\t\tp.report.ErrTok(toks[0], \"expected string literal or long string literal\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\ttoks = toks[1:]\n\t\t\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\t\t\ttoks = toks[1:]\n\t\t\t}\n\t\t\tif len(toks) == 0 {\n\t\t\t\tp.report.ErrTok(tok, \"malformed _Pragma unary operator expression.\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\tif toks[0].Rune != ')' {\n\t\t\t\tp.report.ErrTok(toks[0], \"expected ')'\")\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\ttoks = toks[1:]\n\t\tdefault:\n\t\t\tr = append(r, tok)\n\t\t\ttoks = toks[1:]\n\t\t}\n\t}\n\treturn r\n}\n\nfunc (p *pp) sanitize(toks []xc.Token) []xc.Token {\n\tw := 0\n\tfor _, v := range toks {\n\t\tswitch v.Rune {\n\t\tcase 0:\n\t\t\t// nop\n\t\tcase IDENTIFIER:\n\t\t\tif p.expandingMacros[v.Val] != 0 {\n\t\t\t\tv.Rune = IDENTIFIER_NONREPL\n\t\t\t}\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\ttoks[w] = v\n\t\t\tw++\n\t\t}\n\t}\n\treturn toks[:w]\n}\n\nfunc pasteToks(toks []xc.Token) []xc.Token {\n\tfor i := 0; i < len(toks); {\n\t\tswitch tok := toks[i]; tok.Rune {\n\t\tcase PPPASTE:\n\t\t\tvar b []byte\n\t\t\tvar r rune\n\t\t\tvar v int\n\t\t\tif i > 0 {\n\t\t\t\ti--\n\t\t\t\tt := toks[i]\n\t\t\t\tr = t.Rune\n\t\t\t\tif r == IDENTIFIER_NONREPL {\n\t\t\t\t\t// testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981001-3.c\n\t\t\t\t\tr = IDENTIFIER\n\t\t\t\t}\n\t\t\t\tv = t.Val\n\t\t\t\tb = append(b, xc.Dict.S(tokVal(t))...)\n\t\t\t\ttoks = append(toks[:i], toks[i+1:]...) // Remove left arg.\n\t\t\t}\n\t\t\tif i < len(toks)-1 {\n\t\t\t\ti++\n\t\t\t\tt := toks[i]\n\t\t\t\tswitch {\n\t\t\t\tcase r == 0:\n\t\t\t\t\tr = t.Rune\n\t\t\t\tcase r == IDENTIFIER && v == idL:\n\t\t\t\t\tswitch t.Rune {\n\t\t\t\t\tcase CHARCONST:\n\t\t\t\t\t\tr = LONGCHARCONST\n\t\t\t\t\tcase STRINGLITERAL:\n\t\t\t\t\t\tr = LONGSTRINGLITERAL\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tb = append(b, xc.Dict.S(tokVal(t))...)\n\t\t\t\ttoks = append(toks[:i], toks[i+1:]...) // Remove right arg.\n\t\t\t\ti--\n\t\t\t}\n\t\t\ttok.Rune = r\n\t\t\ttok.Val = xc.Dict.ID(b)\n\t\t\tif tok.Rune < 0x80 && tok.Val > 0x80 {\n\t\t\t\ttok.Rune = PPOTHER\n\t\t\t}\n\t\t\ttoks[i] = tok\n\t\tdefault:\n\t\t\ti++\n\t\t}\n\t}\n\treturn toks\n}\n\nfunc (p *pp) expandLineNo(toks []xc.Token) []xc.Token {\n\tfor i, v := range toks {\n\t\tif v.Rune == IDENTIFIER && v.Val == idLine && !p.tweaks.disablePredefinedLineMacro {\n\t\t\tv.Rune = INTCONST\n\t\t\tv.Val = dict.SID(strconv.Itoa(position(v.Pos()).Line))\n\t\t\ttoks[i] = v\n\t\t}\n\t}\n\treturn toks\n}\n\nfunc normalizeToks(toks []xc.Token) []xc.Token {\n\tif len(toks) == 0 {\n\t\treturn toks\n\t}\n\n\tfor i := 0; i < len(toks); {\n\t\tswitch toks[i].Rune {\n\t\tcase PPPASTE:\n\t\t\tif i > 0 && toks[i-1].Rune == ' ' {\n\t\t\t\ti--\n\t\t\t\ttoks = append(toks[:i], toks[i+1:]...)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfallthrough\n\t\tcase '#':\n\t\t\tif i < len(toks)-1 && toks[i+1].Rune == ' ' {\n\t\t\t\tj := i + 1\n\t\t\t\ttoks = append(toks[:j], toks[j+1:]...)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\ti++\n\t\t}\n\t}\n\treturn toks\n}\n\nfunc (p *pp) expandFnMacro(tok xc.Token, r tokenReader, m *Macro, handleDefined bool, w func([]xc.Token)) {\n\tnm := tok.Val\n\tvar sentinels []xc.Token\nagain:\n\tif r.eof(true) {\n\t\tr.unget(sentinels)\n\t\tw([]xc.Token{tok})\n\t\treturn\n\t}\n\n\tswitch c := r.peek().Rune; {\n\tcase c == ' ':\n\t\tr.read()\n\t\tgoto again\n\tcase c == sentinel:\n\t\ts := r.read()\n\t\tsentinels = append([]xc.Token{s}, sentinels...)\n\t\tgoto again\n\tcase c != '(': // != name()\n\t\tr.unget(sentinels)\n\t\tw([]xc.Token{tok})\n\t\treturn\n\t}\n\n\targs := p.parseMacroArgs(r)\n\tif g, e := len(args), len(m.Args); g != e {\n\t\tswitch {\n\t\tcase g == 1 && e == 0 && len(args[0]) == 0:\n\t\t\t// Spacial case: Handling of empty args to macros with\n\t\t\t// one parameter makes it non distinguishable of\n\t\t\t// passing no argument to a macro with no parameters.\n\n\t\t\t// ok, nop.\n\t\tcase m.ellipsis:\n\t\t\tif g < e {\n\t\t\t\tp.report.ErrTok(tok, \"not enough macro arguments, expected at least %v\", e+1)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor i := e + 1; i < len(args); i++ {\n\t\t\t\targs[e] = append(args[e], args[i]...)\n\t\t\t}\n\t\t\targs = args[:e+1]\n\t\tcase m.ellipsis2:\n\t\t\tif g < e {\n\t\t\t\tp.report.ErrTok(tok, \"not enough macro arguments, expected at least %v\", e)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor i := e; i < len(args); i++ {\n\t\t\t\targs[e-1] = append(args[e-1], args[i]...)\n\t\t\t}\n\t\t\targs = args[:e]\n\t\tdefault:\n\t\t\tp.report.ErrTok(tok, \"macro argument count mismatch: got %v, expected %v\", g, e)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfor i, arg := range args {\n\t\targs[i] = trimSpace(arg, true)\n\t}\n\tfor i, arg := range args {\n\t\targs[i] = nil\n\t\ttoks := p.expandLineNo(arg)\n\t\tif i < len(m.nonRepl) && m.nonRepl[i] {\n\t\t\tif len(toks) != 0 {\n\t\t\t\targs[i] = toks\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tp.expand(&tokenBuf{toks}, handleDefined, func(toks []xc.Token) { args[i] = append(args[i], toks...) })\n\t}\n\trepl := trimSpace(normalizeToks(decodeTokens(m.repl, nil, true)), false)\n\tfor i, v := range repl {\n\t\trepl[i].Char = lex.NewChar(tok.Pos(), v.Rune)\n\t}\n\tvar r0 []xc.Token\nnext:\n\tfor i, tok := range repl {\n\t\tswitch tok.Rune {\n\t\tcase IDENTIFIER:\n\t\t\tif ia := m.findArg(tok.Val); ia >= 0 {\n\t\t\t\tif i > 0 && repl[i-1].Rune == '#' {\n\t\t\t\t\tr0 = append(r0[:len(r0)-1], stringify(args[ia]))\n\t\t\t\t\tcontinue next\n\t\t\t\t}\n\n\t\t\t\tvar arg []xc.Token\n\t\t\t\tif ia < len(args) {\n\t\t\t\t\targ = args[ia]\n\t\t\t\t}\n\t\t\t\tif len(arg) == 0 {\n\t\t\t\t\targ = []xc.Token{{}}\n\t\t\t\t}\n\t\t\t\tr0 = append(r0, arg...)\n\n\t\t\t\tcontinue next\n\t\t\t}\n\n\t\t\tr0 = append(r0, tok)\n\t\tdefault:\n\t\t\tr0 = append(r0, tok)\n\t\t}\n\t}\n\n\ttok.Rune = sentinel\n\tsentinels = append([]xc.Token{tok}, sentinels...)\n\tp.expandingMacros[nm]++\n\ty := append(p.sanitize(p.pragmas(p.expandLineNo(pasteToks(r0)))), sentinels...)\n\tr.unget(y)\n}\n\nfunc stringify(toks []xc.Token) xc.Token {\n\ttoks = trimSpace(toks, false)\n\tif len(toks) == 0 || (toks[0] == xc.Token{}) {\n\t\treturn xc.Token{Char: lex.NewChar(0, STRINGLITERAL), Val: idEmptyString}\n\t}\n\n\ts := []byte{'\"'}\n\tfor _, tok := range toks {\n\t\tswitch tok.Rune {\n\t\tcase CHARCONST, STRINGLITERAL, LONGSTRINGLITERAL, LONGCHARCONST:\n\t\t\tfor _, c := range tok.S() {\n\t\t\t\tswitch c {\n\t\t\t\tcase '\"', '\\\\':\n\t\t\t\t\ts = append(s, '\\\\', c)\n\t\t\t\tdefault:\n\t\t\t\t\ts = append(s, c)\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\ts = append(s, xc.Dict.S(tokVal(tok))...)\n\t\t}\n\t}\n\ts = append(s, '\"')\n\tr := xc.Token{Char: lex.NewChar(toks[0].Pos(), STRINGLITERAL), Val: dict.ID(s)}\n\treturn r\n}\n\nfunc whitespace(toks []xc.Token) []byte {\n\tif len(toks) < 2 {\n\t\treturn nil\n\t}\n\n\tr := make([]byte, 0, len(toks)-1)\n\tltok := toks[0]\n\tfor _, tok := range toks[1:] {\n\t\tif ltok.Rune == ' ' {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch {\n\t\tcase tok.Rune == ' ':\n\t\t\tr = append(r, 1)\n\t\tdefault:\n\t\t\tr = append(r, 0)\n\t\t}\n\t\tltok = tok\n\t}\n\treturn r\n}\n\nfunc (p *pp) parseMacroArgs(r tokenReader) (args [][]xc.Token) {\n\tif r.eof(true) {\n\t\tpanic(\"internal error\")\n\t}\n\n\ttok := r.read()\n\tif tok.Rune != '(' {\n\t\tp.report.ErrTok(tok, \"expected '('\")\n\t\treturn nil\n\t}\n\n\tfor !r.eof(true) {\n\t\targ, more := p.parseMacroArg(r)\n\t\targs = append(args, arg)\n\t\tif more {\n\t\t\tcontinue\n\t\t}\n\n\t\tif r.eof(true) || r.peek().Rune == ')' {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif r.eof(true) {\n\t\tp.report.ErrTok(tok, \"missing final ')'\")\n\t\treturn nil\n\t}\n\n\ttok = r.read()\n\tif tok.Rune != ')' {\n\t\tp.report.ErrTok(tok, \"expected ')'\")\n\t}\n\n\treturn args\n}\n\nfunc (p *pp) parseMacroArg(r tokenReader) (arg []xc.Token, more bool) {\n\tn := 0\n\ttok := r.peek()\n\tfor {\n\t\tif r.eof(true) {\n\t\t\tp.report.ErrTok(tok, \"unexpected end of line after token\")\n\t\t\treturn arg, false\n\t\t}\n\n\t\ttok = r.peek()\n\t\tswitch tok.Rune {\n\t\tcase '(':\n\t\t\targ = append(arg, r.read())\n\t\t\tn++\n\t\tcase ')':\n\t\t\tif n == 0 {\n\t\t\t\treturn arg, false\n\t\t\t}\n\n\t\t\targ = append(arg, r.read())\n\t\t\tn--\n\t\tcase ',':\n\t\t\tif n == 0 {\n\t\t\t\targ = append(arg, r.read())\n\t\t\t\treturn arg, true\n\t\t\t}\n\n\t\t\targ = append(arg, r.read())\n\t\tdefault:\n\t\t\targ = append(arg, r.read())\n\t\t}\n\t}\n}\n\nfunc (p *pp) preprocessingFile(n *PreprocessingFile) {\n\tppf := p.ppf\n\tp.ppf = n\n\tp.groupList(n.GroupList)\n\tp.ppf = ppf\n\tif p.includeLevel == 0 {\n\t\tclose(p.in)\n\t\t<-p.ack\n\t}\n}\n\nfunc (p *pp) groupList(n *GroupList) {\n\tfor ; n != nil; n = n.GroupList {\n\t\tswitch gp := n.GroupPart.(type) {\n\t\tcase nil: // PPNONDIRECTIVE PPTokenList\n\t\t\t// nop\n\t\tcase *ControlLine:\n\t\t\tp.controlLine(gp)\n\t\tcase *IfSection:\n\t\t\tp.ifSection(gp)\n\t\tcase PPTokenList: // TextLine\n\t\t\tif gp == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttoks := decodeTokens(gp, nil, true)\n\t\t\tfor _, v := range toks {\n\t\t\t\tif v.Rune != ' ' {\n\t\t\t\t\tp.in <- toks\n\t\t\t\t\t<-p.ack\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\tcase xc.Token:\n\t\t\tif p.tweaks.enableWarnings {\n\t\t\t\tfmt.Printf(\"[INFO] %s at %s\\n\", gp.S(), xc.FileSet.Position(gp.Pos()).String())\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\t}\n}\n\nfunc (p *pp) ifSection(n *IfSection) {\n\tif p.ifGroup(n.IfGroup) || p.elifGroupListOpt(n.ElifGroupListOpt) {\n\t\treturn\n\t}\n\n\tp.elseGroupOpt(n.ElseGroupOpt)\n}\n\nfunc (p *pp) ifGroup(n *IfGroup) bool {\n\tswitch n.Case {\n\tcase 0: // PPIF PPTokenList GroupListOpt\n\t\tif !p.lx.parsePPConstExpr(n.PPTokenList, p) {\n\t\t\treturn false\n\t\t}\n\tcase 1: // PPIFDEF IDENTIFIER '\\n' GroupListOpt\n\t\tif m := p.macros.m[n.Token2.Val]; m == nil {\n\t\t\treturn false\n\t\t}\n\tcase 2: // PPIFNDEF IDENTIFIER '\\n' GroupListOpt\n\t\tif m := p.macros.m[n.Token2.Val]; m != nil {\n\t\t\treturn false\n\t\t}\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n\tp.groupListOpt(n.GroupListOpt)\n\treturn true\n}\n\nfunc (p *pp) elifGroupListOpt(n *ElifGroupListOpt) bool {\n\tif n == nil {\n\t\treturn false\n\t}\n\n\treturn p.elifGroupList(n.ElifGroupList)\n}\n\nfunc (p *pp) elifGroupList(n *ElifGroupList) bool {\n\tfor ; n != nil; n = n.ElifGroupList {\n\t\tif p.elifGroup(n.ElifGroup) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\nfunc (p *pp) elifGroup(n *ElifGroup) bool {\n\tif !p.lx.parsePPConstExpr(n.PPTokenList, p) {\n\t\treturn false\n\t}\n\n\tp.groupListOpt(n.GroupListOpt)\n\treturn true\n}\n\nfunc (p *pp) elseGroupOpt(n *ElseGroupOpt) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tp.groupListOpt(n.ElseGroup.GroupListOpt)\n}\n\nfunc (p *pp) groupListOpt(n *GroupListOpt) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tp.groupList(n.GroupList)\n}\n\nfunc (p *pp) fixInclude(toks []xc.Token) []xc.Token {\nagain:\n\tif len(toks) == 0 {\n\t\treturn nil\n\t}\n\n\tswitch toks[0].Rune {\n\tcase ' ':\n\t\ttoks = toks[1:]\n\t\tgoto again\n\tcase STRINGLITERAL, PPHEADER_NAME:\n\t\treturn toks\n\tcase '<':\n\t\tfor i := 1; i < len(toks); i++ {\n\t\t\tif toks[i].Rune == '>' {\n\t\t\t\tr := stringify(toks[1:i])\n\t\t\t\treturn []xc.Token{r}\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\tdefault:\n\t\treturn nil\n\t}\n}\n\nfunc (p *pp) pragma1(a []xc.Token) (t xc.Token, _ bool) {\n\tif len(a) != 3 || a[0].Rune != '(' || a[1].Rune != STRINGLITERAL || a[2].Rune != ')' {\n\t\treturn t, false\n\t}\n\n\treturn a[1], true\n}\n\nfunc (p *pp) pragma(a []xc.Token) {\n\tif len(a) == 0 {\n\t\treturn\n\t}\n\n\tswitch t := a[0]; t.Val {\n\tcase idPushMacro:\n\t\tt, ok := p.pragma1(a[1:])\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\n\t\ts := dict.S(t.Val)\n\t\tnm := dict.ID(s[1 : len(s)-1])\n\t\tm := p.macros.m[nm]\n\t\tif m == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tp.macros.stack[nm] = append(p.macros.stack[nm], m)\n\tcase idPopMacro:\n\t\tt, ok := p.pragma1(a[1:])\n\t\tif !ok {\n\t\t\tbreak\n\t\t}\n\n\t\ts := dict.S(t.Val)\n\t\tnm := dict.ID(s[1 : len(s)-1])\n\t\tstack := p.macros.stack[nm]\n\t\tif len(stack) == 0 {\n\t\t\tbreak\n\t\t}\n\n\t\tm := stack[0]\n\t\tp.macros.stack[nm] = stack[1:]\n\t\tp.macros.m[nm] = m\n\t}\n}\n\nfunc (p *pp) controlLine(n *ControlLine) {\nout:\n\tswitch n.Case {\n\tcase 0: // PPDEFINE IDENTIFIER ReplacementList\n\t\tp.defineMacro(n.Token2, n.ReplacementList)\n\tcase 1: // PPDEFINE IDENTIFIER_LPAREN \"...\" ')' ReplacementList\n\t\tp.defineFnMacro(n.Token2, nil, n.ReplacementList, true, false)\n\tcase 2: // PPDEFINE IDENTIFIER_LPAREN IdentifierList ',' \"...\" ')' ReplacementList\n\t\tp.defineFnMacro(n.Token2, n.IdentifierList, n.ReplacementList, true, false)\n\tcase 3: // PPDEFINE IDENTIFIER_LPAREN IdentifierListOpt ')' ReplacementList\n\t\tvar l *IdentifierList\n\t\tif o := n.IdentifierListOpt; o != nil {\n\t\t\tl = o.IdentifierList\n\t\t}\n\t\tp.defineFnMacro(n.Token2, l, n.ReplacementList, false, false)\n\tcase 5: // PPHASH_NL\n\t\t// nop\n\tcase 4: // PPERROR PPTokenListOpt\n\t\tvar sep string\n\t\ttoks := decodeTokens(n.PPTokenListOpt, nil, true)\n\t\ts := stringify(toks)\n\t\tif s.Val != 0 {\n\t\t\tsep = \": \"\n\t\t}\n\t\tp.report.ErrTok(n.Token, \"error%s%s\", sep, s.S())\n\tcase 6: // PPINCLUDE PPTokenList\n\t\ttoks := decodeTokens(n.PPTokenList, nil, false)\n\t\tvar exp []xc.Token\n\t\tp.expand(&tokenBuf{toks}, false, func(toks []xc.Token) { exp = append(exp, toks...) })\n\t\ttoks = p.fixInclude(exp)\n\t\tif len(toks) == 0 {\n\t\t\tp.report.ErrTok(n.Token, \"invalid #include argument\")\n\t\t\tbreak\n\t\t}\n\n\t\tif p.includeLevel == maxIncludeLevel {\n\t\t\tp.report.ErrTok(toks[0], \"too many include nesting levels\")\n\t\t\tbreak\n\t\t}\n\n\t\tcurrentFileDir := filepath.Dir(p.ppf.path)\n\t\targ := string(toks[0].S())\n\t\tvar dirs []string\n\t\tswitch {\n\t\tcase strings.HasPrefix(arg, \"<\"):\n\t\t\tswitch {\n\t\t\tcase p.tweaks.mode99c:\n\t\t\t\tdirs = append([]string(nil), p.sysIncludes...)\n\t\t\tdefault:\n\t\t\t\tdirs = append(p.includes, p.sysIncludes...)\n\t\t\t}\n\t\tcase strings.HasPrefix(arg, \"\\\"\"):\n\t\t\tswitch {\n\t\t\tcase p.tweaks.mode99c:\n\t\t\t\tdirs = append([]string(nil), p.includes...)\n\t\t\tdefault:\n\t\t\t\tdirs = p.includes\n\t\t\t\tdirs = append([]string{filepath.Dir(p.ppf.path)}, dirs...)\n\t\t\t}\n\t\tdefault:\n\t\t\tp.report.ErrTok(n.Token, \"invalid #include argument\")\n\t\t\tbreak out\n\t\t}\n\n\t\t// Include origin.\n\t\targ = arg[1 : len(arg)-1]\n\t\tfor i, dir := range dirs {\n\t\t\tif p.tweaks.mode99c && dir == \"@\" {\n\t\t\t\tdir = currentFileDir\n\t\t\t\tdirs[i] = dir\n\t\t\t}\n\t\t\tpth := arg\n\t\t\tif !filepath.IsAbs(pth) {\n\t\t\t\tpth = filepath.Join(dir, arg)\n\t\t\t}\n\t\t\tif _, err := os.Stat(pth); err != nil {\n\t\t\t\tif !os.IsNotExist(err) {\n\t\t\t\t\tp.report.ErrTok(toks[0], err.Error())\n\t\t\t\t}\n\t\t\t\tif debugIncludes {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"include file %q not found\\n\", pth)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tppf, err := ppParse(pth, p.report, p.tweaks)\n\t\t\tif err != nil {\n\t\t\t\tp.report.ErrTok(toks[0], err.Error())\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tp.includeLevel++\n\t\t\tsave := p.includedSearchPath\n\t\t\tp.includedSearchPath = dir\n\t\t\tp.preprocessingFile(ppf)\n\t\t\tp.includedSearchPath = save\n\t\t\tp.includeLevel--\n\t\t\treturn\n\t\t}\n\n\t\tp.report.ErrTok(toks[0], \"include file not found: %s. Search paths:\\n\\t%s\", arg, strings.Join(clean(dirs), \"\\n\\t\"))\n\tcase 7: // PPLINE PPTokenList '\\n'\n\t\ttoks := decodeTokens(n.PPTokenList, nil, false)\n\t\t// lineno, fname\n\t\tif len(toks) < 2 || toks[0].Rune != INTCONST || toks[1].Rune != STRINGLITERAL {\n\t\t\tbreak\n\t\t}\n\n\t\tln, err := strconv.ParseUint(string(toks[0].S()), 10, mathutil.IntBits-1)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\n\t\tfn := string(toks[1].S())\n\t\tfn = fn[1 : len(fn)-1] // Unquote.\n\t\tnl := n.Token2\n\t\ttf := xc.FileSet.File(nl.Pos())\n\t\ttf.AddLineInfo(tf.Offset(nl.Pos()+1), fn, int(ln))\n\tcase 8: // PPPRAGMA PPTokenListOpt\n\t\tp.pragma(decodeTokens(n.PPTokenListOpt, nil, false))\n\tcase\n\t\t9,  // PPUNDEF IDENTIFIER '\\n'\n\t\t12: // PPUNDEF IDENTIFIER PPTokenList '\\n'\n\t\tnm := n.Token2.Val\n\t\tif protectedMacros[nm] && p.protectMacros {\n\t\t\tp.report.ErrTok(n.Token2, \"cannot undefine protected macro\")\n\t\t\treturn\n\t\t}\n\n\t\tif debugMacros {\n\t\t\tfmt.Fprintf(os.Stderr, \"#undef %s\\n\", xc.Dict.S(nm))\n\t\t}\n\t\tdelete(p.macros.m, nm)\n\tcase 10: // PPDEFINE IDENTIFIER_LPAREN IdentifierList \"...\" ')' ReplacementList\n\t\tp.defineFnMacro(n.Token2, n.IdentifierList, n.ReplacementList, false, true)\n\tcase 13: // PPINCLUDE_NEXT PPTokenList '\\n'\n\t\ttoks := decodeTokens(n.PPTokenList, nil, false)\n\t\tvar exp []xc.Token\n\t\tp.expand(&tokenBuf{toks}, false, func(toks []xc.Token) { exp = append(exp, toks...) })\n\t\ttoks = p.fixInclude(exp)\n\t\tif len(toks) == 0 {\n\t\t\tp.report.ErrTok(n.Token, \"invalid #include_next argument\")\n\t\t\tbreak\n\t\t}\n\n\t\tif p.includeLevel == maxIncludeLevel {\n\t\t\tp.report.ErrTok(toks[0], \"too many include nesting levels\")\n\t\t\tbreak\n\t\t}\n\n\t\targ := string(toks[0].S())\n\t\targ = arg[1 : len(arg)-1]\n\t\torigin := p.includedSearchPath\n\t\tvar dirs []string\n\t\tfound := false\n\t\tfor i, dir := range p.includes {\n\t\t\tif dir == origin {\n\t\t\t\tdirs = p.includes[i+1:]\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tfor i, dir := range p.sysIncludes {\n\t\t\t\tif dir == origin {\n\t\t\t\t\tdirs = p.sysIncludes[i+1:]\n\t\t\t\t\tfound = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor _, dir := range dirs {\n\t\t\tpth := filepath.Join(dir, arg)\n\t\t\tif _, err := os.Stat(pth); err != nil {\n\t\t\t\tif !os.IsNotExist(err) {\n\t\t\t\t\tp.report.ErrTok(toks[0], err.Error())\n\t\t\t\t}\n\t\t\t\tif debugIncludes {\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"include file %q not found\\n\", pth)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tppf, err := ppParse(pth, p.report, p.tweaks)\n\t\t\tif err != nil {\n\t\t\t\tp.report.ErrTok(toks[0], err.Error())\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tp.includeLevel++\n\t\t\tsave := p.includedSearchPath\n\t\t\tp.includedSearchPath = dir\n\t\t\tp.preprocessingFile(ppf)\n\t\t\tp.includedSearchPath = save\n\t\t\tp.includeLevel--\n\t\t\treturn\n\t\t}\n\n\t\tp.report.ErrTok(toks[0], \"include file not found: %s\", arg)\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n"
  },
  {
    "path": "encoding.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"encoding/binary\"\n\t\"go/token\"\n\t\"sort\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\nconst (\n\tintBits  = mathutil.IntBits\n\tbitShift = intBits>>6 + 5\n\tbitMask  = intBits - 1\n\n\tscINITIAL = 0 // Start condition (shared value).\n)\n\nconst (\n\t// Character class is an 8 bit encoding of an Unicode rune for the\n\t// golex generated FSM.\n\t//\n\t// Every ASCII rune is its own class.  DO NOT change any of the\n\t// existing values. Adding new classes is OK.\n\tccEOF         = iota + 0x80\n\t_             // ccError\n\tccOther       // Any other rune.\n\tccUCNDigit    // [0], Annex D, Universal character names for identifiers - digits.\n\tccUCNNonDigit // [0], Annex D, Universal character names for identifiers - non digits.\n)\n\nconst (\n\ttsVoid            = iota //  0: \"void\"\n\ttsChar                   //  1: \"char\"\n\ttsShort                  //  2: \"short\"\n\ttsInt                    //  3: \"int\"\n\ttsLong                   //  4: \"long\"\n\ttsFloat                  //  5: \"float\"\n\ttsDouble                 //  6: \"double\"\n\ttsSigned                 //  7: \"signed\"\n\ttsUnsigned               //  8: \"unsigned\"\n\ttsBool                   //  9: \"_Bool\"\n\ttsComplex                // 10: \"_Complex\"\n\ttsStructSpecifier        // 11: StructOrUnionSpecifier: struct\n\ttsUnionSpecifier         // 12: StructOrUnionSpecifier: union\n\ttsEnumSpecifier          // 13: EnumSpecifier\n\ttsTypedefName            // 14: TYPEDEFNAME\n\ttsTypeof                 // 15: \"typeof\"\n\ttsUintptr                // 16: Pseudo type\n)\n\nconst (\n\ttsBits = 5 // Values [0, 16]\n\ttsMask = 1<<tsBits - 1\n)\n\n// specifier attributes.\nconst (\n\tsaInline = 1 << iota\n\tsaTypedef\n\tsaExtern\n\tsaStatic\n\tsaAuto\n\tsaRegister\n\tsaConst\n\tsaRestrict\n\tsaVolatile\n\tsaNoreturn\n)\n\nfunc attrString(attr int) string {\n\tif attr == 0 {\n\t\treturn \"\"\n\t}\n\n\ta := []string{}\n\tif attr&saAuto != 0 {\n\t\ta = append(a, \"auto\")\n\t}\n\tif attr&saConst != 0 {\n\t\ta = append(a, \"const\")\n\t}\n\tif attr&saExtern != 0 {\n\t\ta = append(a, \"extern\")\n\t}\n\tif attr&saInline != 0 {\n\t\ta = append(a, \"inline\")\n\t}\n\tif attr&saRegister != 0 {\n\t\ta = append(a, \"register\")\n\t}\n\tif attr&saRestrict != 0 {\n\t\ta = append(a, \"restrict\")\n\t}\n\tif attr&saStatic != 0 {\n\t\ta = append(a, \"static\")\n\t}\n\tif attr&saTypedef != 0 {\n\t\ta = append(a, \"typedef\")\n\t}\n\tif attr&saVolatile != 0 {\n\t\ta = append(a, \"volatile\")\n\t}\n\tif attr&saNoreturn != 0 {\n\t\ta = append(a, \"_Noreturn\")\n\t}\n\treturn strings.Join(a, \" \")\n}\n\n// PPTokenList represents a sequence of tokens.\ntype PPTokenList int\n\nfunc (p PPTokenList) Pos() token.Pos {\n\tif p == 0 {\n\t\treturn 0\n\t}\n\n\treturn decodeTokens(p, nil, false)[0].Pos()\n}\n\n// Linkage is a C linkage kind ([0], 6.2.2, p. 30)\ntype Linkage int\n\n// Values of type Linkage.\nconst (\n\tNone Linkage = iota\n\tInternal\n\tExternal\n)\n\n// Values from GCC's typeclass.h\nconst (\n\tnoTypeClass = iota - 1\n\tvoidTypeClass\n\tintegerTypeClass\n\tcharTypeClass\n\tenumeralTypeClass\n\tbooleanTypeClass\n\tpointerTypeClass\n\treferenceTypeClass\n\toffsetTypeClass\n\trealTypeClass\n\tcomplexTypeClass\n\tfunctionTypeClass\n\tmethodTypeClass\n\trecordTypeClass\n\tunionTypeClass\n\tarrayTypeClass\n\tstringTypeClass\n\tlangTypeClass\n)\n\nvar classifyType = map[Kind]int{\n\tUndefined:         noTypeClass,\n\tVoid:              voidTypeClass,\n\tPtr:               pointerTypeClass,\n\tUintPtr:           noTypeClass,\n\tChar:              charTypeClass,\n\tSChar:             charTypeClass,\n\tUChar:             charTypeClass,\n\tShort:             integerTypeClass,\n\tUShort:            integerTypeClass,\n\tInt:               integerTypeClass,\n\tUInt:              integerTypeClass,\n\tLong:              integerTypeClass,\n\tULong:             integerTypeClass,\n\tLongLong:          integerTypeClass,\n\tULongLong:         integerTypeClass,\n\tFloat:             realTypeClass,\n\tDouble:            realTypeClass,\n\tLongDouble:        realTypeClass,\n\tBool:              booleanTypeClass,\n\tFloatComplex:      complexTypeClass,\n\tDoubleComplex:     complexTypeClass,\n\tLongDoubleComplex: complexTypeClass,\n\tStruct:            recordTypeClass,\n\tUnion:             unionTypeClass,\n\tEnum:              enumeralTypeClass,\n\tTypedefName:       noTypeClass,\n\tFunction:          functionTypeClass,\n\tArray:             arrayTypeClass,\n\ttypeof:            noTypeClass,\n}\n\n// Kind is a type category. Kind formally implements Type the only method\n// returning a non nil value is Kind.\ntype Kind int\n\n// Values of type Kind.\nconst (\n\tUndefined Kind = iota\n\tVoid\n\tPtr\n\tUintPtr // Type used for pointer arithmetic.\n\tChar\n\tSChar\n\tUChar\n\tShort\n\tUShort\n\tInt\n\tUInt\n\tLong\n\tULong\n\tLongLong\n\tULongLong\n\tFloat\n\tDouble\n\tLongDouble\n\tBool\n\tFloatComplex\n\tDoubleComplex\n\tLongDoubleComplex\n\tStruct\n\tUnion\n\tEnum\n\tTypedefName\n\tFunction\n\tArray\n\ttypeof\n\n\tkindMax\n)\n\nfunc (k Kind) CString() string {\n\tswitch k {\n\tcase Undefined:\n\t\treturn \"undefined\"\n\tcase Void:\n\t\treturn \"void\"\n\tcase Ptr:\n\t\treturn \"pointer\"\n\tcase Char:\n\t\treturn \"char\"\n\tcase SChar:\n\t\treturn \"signed char\"\n\tcase UChar:\n\t\treturn \"unsigned char\"\n\tcase Short:\n\t\treturn \"short\"\n\tcase UShort:\n\t\treturn \"unsigned short\"\n\tcase Int:\n\t\treturn \"int\"\n\tcase UInt:\n\t\treturn \"unsigned\"\n\tcase Long:\n\t\treturn \"long\"\n\tcase ULong:\n\t\treturn \"unsigned long\"\n\tcase LongLong:\n\t\treturn \"long long\"\n\tcase ULongLong:\n\t\treturn \"unsigned long long\"\n\tcase Float:\n\t\treturn \"float\"\n\tcase Double:\n\t\treturn \"double\"\n\tcase LongDouble:\n\t\treturn \"long double\"\n\tcase Bool:\n\t\treturn \"bool\"\n\tcase FloatComplex:\n\t\treturn \"float complex\"\n\tcase DoubleComplex:\n\t\treturn \"double complex\"\n\tcase LongDoubleComplex:\n\t\treturn \"long double complex\"\n\tcase Struct:\n\t\treturn \"struct\"\n\tcase Union:\n\t\treturn \"union\"\n\tcase Enum:\n\t\treturn \"enum\"\n\tcase TypedefName:\n\t\treturn \"typedefname\"\n\tcase Function:\n\t\treturn \"function\"\n\tcase Array:\n\t\treturn \"array\"\n\tcase UintPtr:\n\t\treturn \"uintptr\"\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// Scope is a bindings category.\ntype Scope int\n\n// Values of type Scope\nconst (\n\tScopeFile Scope = iota\n\tScopeBlock\n\tScopeMembers\n\tScopeParams\n)\n\n// Namespace is a binding category.\ntype Namespace int\n\n// Values of type Namespace.\nconst (\n\tNSIdentifiers Namespace = iota\n\tNSTags\n)\n\nvar (\n\tcwords = map[int]rune{\n\t\tdict.SID(\"auto\"):     AUTO,\n\t\tdict.SID(\"_Bool\"):    BOOL,\n\t\tdict.SID(\"break\"):    BREAK,\n\t\tdict.SID(\"case\"):     CASE,\n\t\tdict.SID(\"char\"):     CHAR,\n\t\tdict.SID(\"_Complex\"): COMPLEX,\n\t\tdict.SID(\"const\"):    CONST,\n\t\tdict.SID(\"continue\"): CONTINUE,\n\t\tdict.SID(\"default\"):  DEFAULT,\n\t\tdict.SID(\"do\"):       DO,\n\t\tdict.SID(\"double\"):   DOUBLE,\n\t\tdict.SID(\"else\"):     ELSE,\n\t\tdict.SID(\"enum\"):     ENUM,\n\t\tdict.SID(\"extern\"):   EXTERN,\n\t\tdict.SID(\"float\"):    FLOAT,\n\t\tdict.SID(\"for\"):      FOR,\n\t\tdict.SID(\"goto\"):     GOTO,\n\t\tdict.SID(\"if\"):       IF,\n\t\tdict.SID(\"inline\"):   INLINE,\n\t\tdict.SID(\"int\"):      INT,\n\t\tdict.SID(\"long\"):     LONG,\n\t\tdict.SID(\"register\"): REGISTER,\n\t\tdict.SID(\"restrict\"): RESTRICT,\n\t\tdict.SID(\"return\"):   RETURN,\n\t\tdict.SID(\"short\"):    SHORT,\n\t\tdict.SID(\"signed\"):   SIGNED,\n\t\tdict.SID(\"sizeof\"):   SIZEOF,\n\t\tdict.SID(\"static\"):   STATIC,\n\t\tdict.SID(\"struct\"):   STRUCT,\n\t\tdict.SID(\"switch\"):   SWITCH,\n\t\tdict.SID(\"typedef\"):  TYPEDEF,\n\t\tdict.SID(\"union\"):    UNION,\n\t\tdict.SID(\"unsigned\"): UNSIGNED,\n\t\tdict.SID(\"void\"):     VOID,\n\t\tdict.SID(\"volatile\"): VOLATILE,\n\t\tdict.SID(\"while\"):    WHILE,\n\t}\n\n\ttokConstVals = map[rune]int{\n\t\tADDASSIGN:     dict.SID(\"+=\"),\n\t\tALIGNOF:       dict.SID(\"_Alignof\"),\n\t\tANDAND:        dict.SID(\"&&\"),\n\t\tANDASSIGN:     dict.SID(\"&=\"),\n\t\tARROW:         dict.SID(\"->\"),\n\t\tASM:           dict.SID(\"asm\"),\n\t\tAUTO:          dict.SID(\"auto\"),\n\t\tBOOL:          dict.SID(\"_Bool\"),\n\t\tBREAK:         dict.SID(\"break\"),\n\t\tCASE:          dict.SID(\"case\"),\n\t\tCHAR:          dict.SID(\"char\"),\n\t\tCOMPLEX:       dict.SID(\"_Complex\"),\n\t\tCONST:         dict.SID(\"const\"),\n\t\tCONTINUE:      dict.SID(\"continue\"),\n\t\tDDD:           dict.SID(\"...\"),\n\t\tDEC:           dict.SID(\"--\"),\n\t\tDEFAULT:       dict.SID(\"default\"),\n\t\tDIVASSIGN:     dict.SID(\"/=\"),\n\t\tDO:            dict.SID(\"do\"),\n\t\tDOUBLE:        dict.SID(\"double\"),\n\t\tELSE:          dict.SID(\"else\"),\n\t\tENUM:          dict.SID(\"enum\"),\n\t\tEQ:            dict.SID(\"==\"),\n\t\tEXTERN:        dict.SID(\"extern\"),\n\t\tFLOAT:         dict.SID(\"float\"),\n\t\tFOR:           dict.SID(\"for\"),\n\t\tGEQ:           dict.SID(\">=\"),\n\t\tGOTO:          dict.SID(\"goto\"),\n\t\tIF:            dict.SID(\"if\"),\n\t\tINC:           dict.SID(\"++\"),\n\t\tINLINE:        dict.SID(\"inline\"),\n\t\tINT:           dict.SID(\"int\"),\n\t\tLEQ:           dict.SID(\"<=\"),\n\t\tLONG:          dict.SID(\"long\"),\n\t\tLSH:           dict.SID(\"<<\"),\n\t\tLSHASSIGN:     dict.SID(\"<<=\"),\n\t\tMODASSIGN:     dict.SID(\"%=\"),\n\t\tMULASSIGN:     dict.SID(\"*=\"),\n\t\tNEQ:           dict.SID(\"!=\"),\n\t\tORASSIGN:      dict.SID(\"|=\"),\n\t\tOROR:          dict.SID(\"||\"),\n\t\tPPPASTE:       dict.SID(\"##\"),\n\t\tREGISTER:      dict.SID(\"register\"),\n\t\tRESTRICT:      dict.SID(\"restrict\"),\n\t\tRETURN:        dict.SID(\"return\"),\n\t\tRSH:           dict.SID(\">>\"),\n\t\tRSHASSIGN:     dict.SID(\">>=\"),\n\t\tSHORT:         dict.SID(\"short\"),\n\t\tSIGNED:        dict.SID(\"signed\"),\n\t\tSIZEOF:        dict.SID(\"sizeof\"),\n\t\tSTATIC:        dict.SID(\"static\"),\n\t\tSTATIC_ASSERT: dict.SID(\"_Static_assert\"),\n\t\tSTRUCT:        dict.SID(\"struct\"),\n\t\tSUBASSIGN:     dict.SID(\"-=\"),\n\t\tSWITCH:        dict.SID(\"switch\"),\n\t\tTYPEDEF:       dict.SID(\"typedef\"),\n\t\tTYPEOF:        dict.SID(\"typeof\"),\n\t\tUNION:         dict.SID(\"union\"),\n\t\tUNSIGNED:      dict.SID(\"unsigned\"),\n\t\tVOID:          dict.SID(\"void\"),\n\t\tVOLATILE:      dict.SID(\"volatile\"),\n\t\tWHILE:         dict.SID(\"while\"),\n\t\tXORASSIGN:     dict.SID(\"^=\"),\n\t}\n\n\tid0                      = dict.SID(\"0\")\n\tid1                      = dict.SID(\"1\")\n\tidAlignof                = dict.SID(\"_Alignof\")\n\tidAlignofAlt             = dict.SID(\"__alignof__\")\n\tidAsm                    = dict.SID(\"asm\")\n\tidAsmAlt                 = dict.SID(\"__asm__\")\n\tidBuiltinClasifyType     = dict.SID(\"__builtin_classify_type\")\n\tidBuiltinConstantP       = dict.SID(\"__builtin_constant_p\")\n\tidBuiltinTypesCompatible = dict.SID(\"__builtin_types_compatible__\") // Implements __builtin_types_compatible_p\n\tidChar                   = dict.SID(\"char\")\n\tidConst                  = dict.SID(\"const\")\n\tidDate                   = dict.SID(\"__DATE__\")\n\tidDefined                = dict.SID(\"defined\")\n\tidEmptyString            = dict.SID(`\"\"`)\n\tidFile                   = dict.SID(\"__FILE__\")\n\tidID                     = dict.SID(\"ID\")\n\tidInlineAlt              = dict.SID(\"__inline__\")\n\tidL                      = dict.SID(\"L\")\n\tidLine                   = dict.SID(\"__LINE__\")\n\tidMagicFunc              = dict.SID(\"__func__\")\n\tidNoreturn               = dict.SID(\"_Noreturn\")\n\tidPopMacro               = dict.SID(\"pop_macro\")\n\tidPragma                 = dict.SID(\"_Pragma\")\n\tidPushMacro              = dict.SID(\"push_macro\")\n\tidRestrictAlt            = dict.SID(\"__restrict__\")\n\tidSTDC                   = dict.SID(\"__STDC__\")\n\tidSTDCHosted             = dict.SID(\"__STDC_HOSTED__\")\n\tidSTDCMBMightNeqWc       = dict.SID(\"__STDC_MB_MIGHT_NEQ_WC__\")\n\tidSTDCVersion            = dict.SID(\"__STDC_VERSION__\")\n\tidSignedAlt              = dict.SID(\"__signed__\")\n\tidSpace                  = dict.SID(\" \")\n\tidStatic                 = dict.SID(\"static\")\n\tidStaticAssert           = dict.SID(\"_Static_assert\")\n\tidTDate                  = dict.SID(tuTime.Format(\"Jan _2 2006\")) // The date of translation of the preprocessing translation unit.\n\tidTTime                  = dict.SID(tuTime.Format(\"15:04:05\"))    // The time of translation of the preprocessing translation unit.\n\tidTime                   = dict.SID(\"__TIME__\")\n\tidTypeof                 = dict.SID(\"typeof\")\n\tidTypeofAlt              = dict.SID(\"__typeof__\")\n\tidVAARGS                 = dict.SID(\"__VA_ARGS__\")\n\tidVolatileAlt            = dict.SID(\"__volatile__\")\n\ttuTime                   = time.Now()\n\n\ttokHasVal = map[rune]bool{\n\t\tCHARCONST:         true,\n\t\tFLOATCONST:        true,\n\t\tIDENTIFIER:        true,\n\t\tIDENTIFIER_LPAREN: true,\n\t\tINTCONST:          true,\n\t\tLONGCHARCONST:     true,\n\t\tLONGSTRINGLITERAL: true,\n\t\tPPHEADER_NAME:     true,\n\t\tPPNUMBER:          true,\n\t\tPPOTHER:           true,\n\t\tSTRINGLITERAL:     true,\n\t\tTYPEDEFNAME:       true,\n\t}\n\n\t// Valid combinations of TypeSpecifier.Case ([0], 6.7.2, 2)\n\ttsValid = map[int]Kind{\n\t\ttsEncode(tsBool):                            Bool,              // _Bool\n\t\ttsEncode(tsChar):                            Char,              // char\n\t\ttsEncode(tsComplex):                         DoubleComplex,     // _Complex\n\t\ttsEncode(tsDouble):                          Double,            // double\n\t\ttsEncode(tsDouble, tsComplex):               DoubleComplex,     // double _Complex\n\t\ttsEncode(tsEnumSpecifier):                   Enum,              // enum specifier\n\t\ttsEncode(tsFloat):                           Float,             // float\n\t\ttsEncode(tsFloat, tsComplex):                FloatComplex,      // float _Complex\n\t\ttsEncode(tsInt):                             Int,               // int\n\t\ttsEncode(tsLong):                            Long,              // long\n\t\ttsEncode(tsLong, tsDouble):                  LongDouble,        // long double\n\t\ttsEncode(tsLong, tsDouble, tsComplex):       LongDoubleComplex, // long double _Complex\n\t\ttsEncode(tsLong, tsInt):                     Long,              // long int\n\t\ttsEncode(tsLong, tsLong):                    LongLong,          // long long\n\t\ttsEncode(tsLong, tsLong, tsInt):             LongLong,          // long long int\n\t\ttsEncode(tsShort):                           Short,             // short\n\t\ttsEncode(tsShort, tsInt):                    Short,             // short int\n\t\ttsEncode(tsSigned):                          Int,               // signed\n\t\ttsEncode(tsSigned, tsChar):                  Char,              // signed char\n\t\ttsEncode(tsSigned, tsInt):                   Int,               // signed int\n\t\ttsEncode(tsSigned, tsLong):                  Long,              // signed long\n\t\ttsEncode(tsSigned, tsLong, tsInt):           Long,              // signed long int\n\t\ttsEncode(tsSigned, tsLong, tsLong):          LongLong,          // signed long long\n\t\ttsEncode(tsSigned, tsLong, tsLong, tsInt):   LongLong,          // signed long long int\n\t\ttsEncode(tsSigned, tsShort):                 Short,             // signed short\n\t\ttsEncode(tsSigned, tsShort, tsInt):          Short,             // signed short int\n\t\ttsEncode(tsStructSpecifier):                 Struct,            // struct\n\t\ttsEncode(tsTypedefName):                     TypedefName,       // typedef name\n\t\ttsEncode(tsTypeof):                          typeof,            // typeof name\n\t\ttsEncode(tsUintptr):                         UintPtr,           // Pseudo type.\n\t\ttsEncode(tsUnionSpecifier):                  Union,             // union\n\t\ttsEncode(tsUnsigned):                        UInt,              // unsigned\n\t\ttsEncode(tsUnsigned, tsChar):                UChar,             // unsigned char\n\t\ttsEncode(tsUnsigned, tsInt):                 UInt,              // unsigned int\n\t\ttsEncode(tsUnsigned, tsLong):                ULong,             // unsigned long\n\t\ttsEncode(tsUnsigned, tsLong, tsInt):         ULong,             // unsigned long int\n\t\ttsEncode(tsUnsigned, tsLong, tsLong):        ULongLong,         // unsigned long long\n\t\ttsEncode(tsUnsigned, tsLong, tsLong, tsInt): ULongLong,         // unsigned long long int\n\t\ttsEncode(tsUnsigned, tsShort):               UShort,            // unsigned short\n\t\ttsEncode(tsUnsigned, tsShort, tsInt):        UShort,            // unsigned short int\n\t\ttsEncode(tsVoid):                            Void,              // void\n\t}\n)\n\nfunc isUCNDigit(r rune) bool {\n\treturn int(r) < len(ucnDigits)<<bitShift && ucnDigits[uint(r)>>bitShift]&(1<<uint(r&bitMask)) != 0\n}\n\nfunc isUCNNonDigit(r rune) bool {\n\treturn int(r) < len(ucnNonDigits)<<bitShift && ucnNonDigits[uint(r)>>bitShift]&(1<<uint(r&bitMask)) != 0\n}\n\nfunc rune2class(r rune) (c int) {\n\tswitch {\n\tcase r == lex.RuneEOF:\n\t\treturn ccEOF\n\tcase r < 128:\n\t\treturn int(r)\n\tcase isUCNDigit(r):\n\t\treturn ccUCNDigit\n\tcase isUCNNonDigit(r):\n\t\treturn ccUCNNonDigit\n\tdefault:\n\t\treturn ccOther\n\t}\n}\n\nfunc toC(t xc.Token, tw *tweaks) xc.Token {\n\tif t.Rune != IDENTIFIER {\n\t\treturn t\n\t}\n\n\tif x, ok := cwords[t.Val]; ok {\n\t\tt.Rune = x\n\t}\n\n\tif tw.enableStaticAssert && t.Val == idStaticAssert {\n\t\tt.Rune = STATIC_ASSERT\n\t\treturn t\n\t}\n\n\tif tw.enableAlignof && (t.Val == idAlignof || t.Val == idAlignofAlt) {\n\t\tt.Rune = ALIGNOF\n\t\treturn t\n\t}\n\n\tif tw.enableNoreturn {\n\t\tif t.Val == idNoreturn {\n\t\t\tt.Rune = NORETURN\n\t\t\treturn t\n\t\t}\n\n\t}\n\n\tif tw.enableTypeof && (t.Val == idTypeof || t.Val == idTypeofAlt) {\n\t\tt.Rune = TYPEOF\n\t\treturn t\n\t}\n\n\tif tw.enableAsm {\n\t\tif t.Val == idAsm {\n\t\t\tt.Rune = ASM\n\t\t\treturn t\n\t\t}\n\n\t\tif tw.enableAlternateKeywords && t.Val == idAsmAlt {\n\t\t\tt.Rune = ASM\n\t\t\treturn t\n\t\t}\n\t}\n\n\tif tw.enableAlternateKeywords {\n\t\tif t.Val == idInlineAlt {\n\t\t\tt.Rune = INLINE\n\t\t\treturn t\n\t\t}\n\n\t\tif t.Val == idVolatileAlt {\n\t\t\tt.Rune = VOLATILE\n\t\t\treturn t\n\t\t}\n\n\t\tif t.Val == idSignedAlt {\n\t\t\tt.Rune = SIGNED\n\t\t\treturn t\n\t\t}\n\n\t\tif t.Val == idRestrictAlt {\n\t\t\tt.Rune = RESTRICT\n\t\t\treturn t\n\t\t}\n\t}\n\n\treturn t\n}\n\nfunc tsEncode(a ...int) (r int) {\n\tsort.Ints(a)\n\tfor _, v := range a {\n\t\tr = r<<tsBits | v\n\t}\n\treturn r<<1 | 1 // Bit 0 set: value is valid.\n}\n\nfunc tsDecode(n int) (r []int) {\n\tif n == 0 {\n\t\treturn nil\n\t}\n\n\tn >>= 1 // Remove value is valid bit.\n\tfor n != 0 {\n\t\tr = append(r, n&tsMask)\n\t\tn >>= tsBits\n\t}\n\treturn r\n}\n\nfunc (l *lexer) encodeToken(tok xc.Token) {\n\tn := binary.PutUvarint(l.encBuf1[:], uint64(tok.Rune))\n\tpos := tok.Pos()\n\tn += binary.PutUvarint(l.encBuf1[n:], uint64(pos-l.encPos))\n\tl.encPos = pos\n\tif tokHasVal[tok.Rune] {\n\t\tn += binary.PutUvarint(l.encBuf1[n:], uint64(tok.Val))\n\t}\n\tl.encBuf = append(l.encBuf, l.encBuf1[:n]...)\n}\n\nfunc decodeToken(p *[]byte, pos *token.Pos) xc.Token {\n\tb := *p\n\tr, n := binary.Uvarint(b)\n\tb = b[n:]\n\td, n := binary.Uvarint(b)\n\tb = b[n:]\n\tnp := *pos + token.Pos(d)\n\t*pos = np\n\tc := lex.NewChar(np, rune(r))\n\tvar v uint64\n\tif tokHasVal[c.Rune] {\n\t\tv, n = binary.Uvarint(b)\n\t\tb = b[n:]\n\t}\n\t*p = b\n\treturn xc.Token{Char: c, Val: int(v)}\n}\n\nfunc decodeTokens(id PPTokenList, r []xc.Token, withSpaces bool) []xc.Token {\n\tb := dict.S(int(id))\n\tvar pos token.Pos\n\tr = r[:0]\n\tfor len(b) != 0 {\n\t\ttok := decodeToken(&b, &pos)\n\t\tif tok.Rune == ' ' && !withSpaces {\n\t\t\tcontinue\n\t\t}\n\n\t\tr = append(r, tok)\n\t}\n\treturn r\n}\n\nfunc tokVal(t xc.Token) int {\n\tr := t.Rune\n\tif r == 0 {\n\t\treturn 0\n\t}\n\n\tif v := t.Val; v != 0 {\n\t\treturn v\n\t}\n\n\tif r != 0 && r < 0x80 {\n\t\treturn int(r) + 1\n\t}\n\n\tif i, ok := tokConstVals[r]; ok {\n\t\treturn i\n\t}\n\n\tpanic(\"internal error\")\n}\n\n// TokSrc returns t in its source form.\nfunc TokSrc(t xc.Token) string {\n\tif x, ok := tokConstVals[t.Rune]; ok {\n\t\treturn string(dict.S(x))\n\t}\n\n\tif tokHasVal[t.Rune] {\n\t\treturn string(t.S())\n\t}\n\n\treturn string(t.Rune)\n}\n\n// universal-character-name\t\\\\u{hex-quad}|\\\\U{hex-quad}{hex-quad}\nfunc decodeUCN(runes []rune) (rune, int) {\n\tif runes[0] != '\\\\' {\n\t\tpanic(\"internal error\")\n\t}\n\n\trunes = runes[1:]\n\tswitch runes[0] {\n\tcase 'u':\n\t\treturn rune(decodeHexQuad(runes[1:])), 6\n\tcase 'U':\n\t\treturn rune(decodeHexQuad(runes[1:])<<16 | decodeHexQuad(runes[5:])), 10\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// hex-quad\t{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}\nfunc decodeHexQuad(runes []rune) int {\n\tn := 0\n\tfor _, r := range runes[:4] {\n\t\tn = n<<4 | decodeHex(r)\n\t}\n\treturn n\n}\n\nfunc decodeHex(r rune) int {\n\tswitch {\n\tcase r >= '0' && r <= '9':\n\t\treturn int(r) - '0'\n\tdefault:\n\t\tx := int(r) &^ 0x20\n\t\treturn x - 'A' + 10\n\t}\n}\n\n// escape-sequence\t\t{simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}\n// simple-sequence\t\t\\\\['\\x22?\\\\abfnrtv]\n// octal-escape-sequence\t\\\\{octal-digit}{octal-digit}?{octal-digit}?\n// hexadecimal-escape-sequence\t\\\\x{hexadecimal-digit}+\nfunc decodeEscapeSequence(runes []rune) (rune, int) {\n\tif runes[0] != '\\\\' {\n\t\tpanic(\"internal error\")\n\t}\n\n\tr := runes[1]\n\tswitch r {\n\tcase '\\'', '\"', '?', '\\\\':\n\t\treturn r, 2\n\tcase 'a':\n\t\treturn 7, 2\n\tcase 'b':\n\t\treturn 8, 2\n\tcase 'f':\n\t\treturn 12, 2\n\tcase 'n':\n\t\treturn 10, 2\n\tcase 'r':\n\t\treturn 13, 2\n\tcase 't':\n\t\treturn 9, 2\n\tcase 'v':\n\t\treturn 11, 2\n\tcase 'x':\n\t\tv, n := 0, 2\n\tloop2:\n\t\tfor _, r := range runes[2:] {\n\t\t\tswitch {\n\t\t\tcase r >= '0' && r <= '9', r >= 'a' && r <= 'f', r >= 'A' && r <= 'F':\n\t\t\t\tv = v<<4 | decodeHex(r)\n\t\t\t\tn++\n\t\t\tdefault:\n\t\t\t\tbreak loop2\n\t\t\t}\n\t\t}\n\t\treturn -rune(v & 0xff), n\n\tcase 'u', 'U':\n\t\treturn decodeUCN(runes)\n\t}\n\n\tif r < '0' || r > '7' {\n\t\tpanic(\"internal error\")\n\t}\n\n\tv, n := 0, 1\nloop:\n\tfor _, r := range runes[1:] {\n\t\tswitch {\n\t\tcase r >= '0' && r <= '7':\n\t\t\tv = v<<3 | (int(r) - '0')\n\t\t\tn++\n\t\tdefault:\n\t\t\tbreak loop\n\t\t}\n\t}\n\treturn -rune(v), n\n}\n"
  },
  {
    "path": "etc.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\t_ Specifier = (*DeclarationSpecifiers)(nil)\n\t_ Specifier = (*SpecifierQualifierList)(nil)\n\t_ Specifier = (*spec)(nil)\n\n\t_ Type = (*ctype)(nil)\n)\n\nvar (\n\tnoTypedefNameAfter = map[rune]bool{\n\t\t'*':         true,\n\t\t'.':         true,\n\t\tARROW:       true,\n\t\tBOOL:        true,\n\t\tCHAR:        true,\n\t\tCOMPLEX:     true,\n\t\tDOUBLE:      true,\n\t\tENUM:        true,\n\t\tFLOAT:       true,\n\t\tGOTO:        true,\n\t\tINT:         true,\n\t\tLONG:        true,\n\t\tSHORT:       true,\n\t\tSIGNED:      true,\n\t\tSTRUCT:      true,\n\t\tTYPEDEFNAME: true,\n\t\tUNION:       true,\n\t\tUNSIGNED:    true,\n\t\tVOID:        true,\n\t}\n\n\tundefined        = &ctype{}\n\tdebugTypeStrings bool\n)\n\n// EnumConstant represents the name/value pair defined by an Enumerator.\ntype EnumConstant struct {\n\tDefTok xc.Token    // Enumeration constant name definition token.\n\tValue  interface{} // Value represented by name. Type of Value is C int.\n\tTokens []xc.Token  // The tokens the constant expression consists of.\n}\n\n// Specifier describes a combination of {Function,StorageClass,Type}Specifiers\n// and TypeQualifiers.\ntype Specifier interface {\n\tIsAuto() bool                       // StorageClassSpecifier \"auto\" present.\n\tIsConst() bool                      // TypeQualifier \"const\" present.\n\tIsExtern() bool                     // StorageClassSpecifier \"extern\" present.\n\tIsInline() bool                     // FunctionSpecifier \"inline\" present.\n\tIsRegister() bool                   // StorageClassSpecifier \"register\" present.\n\tIsRestrict() bool                   // TypeQualifier \"restrict\" present.\n\tIsStatic() bool                     // StorageClassSpecifier \"static\" present.\n\tIsTypedef() bool                    // StorageClassSpecifier \"typedef\" present.\n\tIsVolatile() bool                   // TypeQualifier \"volatile\" present.\n\tTypedefName() int                   // TypedefName returns the typedef name ID used, if any, zero otherwise.\n\tattrs() int                         // Encoded attributes.\n\tfirstTypeSpecifier() *TypeSpecifier //\n\tkind() Kind                         //\n\tmember(int) (*Member, error)        //\n\tstr() string                        //\n\ttypeSpecifiers() int                // Encoded TypeSpecifier combination.\n}\n\n// Type decribes properties of a C type.\ntype Type interface {\n\t// AlignOf returns the alignment in bytes of a value of this type when\n\t// allocated in memory not as a struct field. Incomplete struct types\n\t// have no alignment and the value returned will be < 0.\n\tAlignOf() int\n\n\t// Bits returns the bit width of the type's value. For non integral\n\t// types the returned value will < 0.\n\tBits() int\n\n\t// SetBits returns a type instance with the value Bits() will return\n\t// equal to n. SetBits panics for n < 0.\n\tSetBits(n int) Type\n\n\t// CanAssignTo returns whether this type can be assigned to dst.\n\tCanAssignTo(dst Type) bool\n\n\t// Declarator returns the full Declarator which defined an entity of\n\t// this type. The returned declarator is possibly artificial.\n\tDeclarator() *Declarator\n\n\t// RawDeclarator returns the typedef declarator associated with a type\n\t// if this type is a typedef name. Otherwise the normal declarator is\n\t// returned.\n\tRawDeclarator() *Declarator\n\n\t// Element returns the type this Ptr type points to or the element type\n\t// of an Array type.\n\tElement() Type\n\n\t// Elements returns the number of elements an Array type has. The\n\t// returned value is < 0 if this type is not an Array or if the array\n\t// is not of a constant size.\n\tElements() int\n\n\t// EnumeratorList returns the enumeration constants defined by an Enum\n\t// type, if any.\n\tEnumeratorList() []EnumConstant\n\n\t// Kind returns one of Ptr, Void, Int, ...\n\tKind() Kind\n\n\t// Member returns the type of a member of this Struct or Union type,\n\t// having numeric name identifier nm.\n\tMember(nm int) (*Member, error)\n\n\t// Members returns the members of a Struct or Union type in declaration\n\t// order. Returned members are valid iff non nil.\n\t//\n\t// Note: Non nil members of length 0 means the struct/union has no\n\t// members or the type is incomplete, which is indicated by the\n\t// isIncomplete return value.\n\t//\n\t// Note 2: C99 standard does not allow empty structs/unions, but GCC\n\t// supports that as an extension.\n\tMembers() (members []Member, isIncomplete bool)\n\n\t// Parameters returns the parameters of a Function type in declaration\n\t// order. Result is valid iff params is not nil.\n\t//\n\t// Note: len(params) == 0 is fine and just means the function has no\n\t// parameters.\n\tParameters() (params []Parameter, isVariadic bool)\n\n\t// Pointer returns a type that points to this type.\n\tPointer() Type\n\n\t// Result returns the result type of a Function type.\n\tResult() Type\n\n\t// Sizeof returns the number of bytes needed to store a value of this\n\t// type. Incomplete struct types have no size and the value returned\n\t// will be < 0.\n\tSizeOf() int\n\n\t// Specifier returns the Specifier of this type.\n\tSpecifier() Specifier\n\n\t// String returns a C-like type specifier of this type.\n\tString() string\n\n\t// StructAlignOf returns the alignment in bytes of a value of this type\n\t// when allocated in memory as a struct field. Incomplete struct types\n\t// have no alignment and the value returned will be < 0.\n\tStructAlignOf() int\n\n\t// Tag returns the ID of a tag of a Struct, Union or Enum type, if any.\n\t// Otherwise the returned value is zero.\n\tTag() int\n\n\tsizeOf(*lexer) int\n\tstructAlignOf(*lexer) int\n}\n\n// Member describes a member of a struct or union.\n//\n// BitFieldGroup represents the ordinal number of the packed bit fields:\n//\n//\tstruct foo {\n//\t\tint i;\n//\t\tint j:1;\t// BitFieldGroup: 0\n//\t\tint k:2;\t// BitFieldGroup: 0\n//\t\tdouble l;\n//\t\tint m:1;\t// BitFieldGroup: 1\n//\t\tint n:2;\t// BitFieldGroup: 1\n//\t}\ntype Member struct {\n\tBitFieldType  Type\n\tBitFieldGroup int         // Ordinal number of the packed bits field.\n\tBitOffsetOf   int         // Bit field starting bit.\n\tBits          int         // Size in bits for bit fields, 0 otherwise.\n\tDeclarator    *Declarator // Possibly nil for bit fields.\n\tName          int\n\tOffsetOf      int\n\tPadding       int // Number of unused bytes added to the end of the field to force proper alignment requirements.\n\tType          Type\n}\n\n// Parameter describes a function argument.\ntype Parameter struct {\n\tDeclarator *Declarator\n\tName       int\n\tType       Type\n}\n\n// PrettyString pretty prints things produced by this package.\nfunc PrettyString(v interface{}) string {\n\treturn strutil.PrettyString(v, \"\", \"\", printHooks)\n}\n\nfunc position(pos token.Pos) token.Position { return fset.Position(pos) }\n\n// Binding records the declaration Node of a declared name.\n//\n// In the NSIdentifiers namespace the dynamic type of Node for declared names\n// is always *DirectDeclarator.  The *Declarator associated with the direct\n// declarator is available via (*DirectDeclarator).TopDeclarator().\n//\n//\tint* p;\n//\n// In the NSTags namespace the dynamic type of Node is xc.Token when a tag is\n// declared:\n//\n//\tstruct foo;\n//\tenum bar;\n//\n// When a tag is defined, the dynamic type of Node is *EnumSpecifier or\n// *StructOrUnionSpecifier:\n//\n//\tstruct foo { int i; };\n//\tenum bar { a = 1 };\n//\ntype Binding struct {\n\tNode Node\n\tenum bool\n}\n\n// Bindings record names declared in a scope.\ntype Bindings struct {\n\tIdentifiers map[int]Binding // NSIdentifiers name space bindings.\n\tTags        map[int]Binding // NSTags name space bindings.\n\tkind        Scope           // ScopeFile, ...\n\tParent      *Bindings       // Parent scope or nil for ScopeFile.\n\n\t// Scoped helpers.\n\n\tmergeScope *Bindings // Fn params.\n\tspecifier  Specifier // To store in full declarators.\n\n\t// Struct/union field handling.\n\tbitFieldGroup        int         // Group ordinal number.\n\tbitFieldTypes        []Type      //\n\tbitOffset            int         //\n\tisUnion              bool        //\n\tmaxAlign             int         //\n\tmaxSize              int         //\n\toffset               int         //\n\tprevStructDeclarator *Declarator //\n}\n\nfunc newBindings(parent *Bindings, kind Scope) *Bindings {\n\treturn &Bindings{\n\t\tkind:   kind,\n\t\tParent: parent,\n\t}\n}\n\n// Scope retuns the kind of b.\nfunc (b *Bindings) Scope() Scope { return b.kind }\n\nfunc (b *Bindings) merge(c *Bindings) {\n\tif b.kind != ScopeBlock || len(b.Identifiers) != 0 || c.kind != ScopeParams {\n\t\tpanic(\"internal error\")\n\t}\n\n\tb.boot(NSIdentifiers)\n\tfor k, v := range c.Identifiers {\n\t\tb.Identifiers[k] = v\n\t}\n}\n\nfunc (b *Bindings) boot(ns Namespace) map[int]Binding {\n\tvar m *map[int]Binding\n\tswitch ns {\n\tcase NSIdentifiers:\n\t\tm = &b.Identifiers\n\tcase NSTags:\n\t\tm = &b.Tags\n\tdefault:\n\t\tpanic(fmt.Errorf(\"internal error %v\", ns))\n\t}\n\n\tmp := *m\n\tif mp == nil {\n\t\tmp = make(map[int]Binding)\n\t\t*m = mp\n\t}\n\treturn mp\n}\n\nfunc (b *Bindings) root() *Bindings {\n\tfor b.Parent != nil {\n\t\tb = b.Parent\n\t}\n\treturn b\n}\n\n// Lookup returns the Binding of id in ns or any of its parents. If id is\n// undeclared, the returned Binding has its Node field set to nil.\nfunc (b *Bindings) Lookup(ns Namespace, id int) Binding {\n\tr, _ := b.Lookup2(ns, id)\n\treturn r\n}\n\n// Lookup2 is like Lookup but addionally it returns also the scope in which id\n// was found.\nfunc (b *Bindings) Lookup2(ns Namespace, id int) (Binding, *Bindings) {\n\tif ns == NSTags {\n\t\tb = b.root()\n\t}\n\tfor b != nil {\n\t\tm := b.boot(ns)\n\t\tif x, ok := m[id]; ok {\n\t\t\treturn x, b\n\t\t}\n\n\t\tb = b.Parent\n\t}\n\n\treturn Binding{}, nil\n}\n\nfunc (b *Bindings) declareIdentifier(tok xc.Token, d *DirectDeclarator, report *xc.Report) {\n\tm := b.boot(NSIdentifiers)\n\tvar p *Binding\n\tif ex, ok := m[tok.Val]; ok {\n\t\tp = &ex\n\t}\n\n\td.prev = p\n\tm[tok.Val] = Binding{d, false}\n}\n\nfunc (b *Bindings) declareEnumTag(tok xc.Token, report *xc.Report) {\n\tb = b.root()\n\tm := b.boot(NSTags)\n\tif ex, ok := m[tok.Val]; ok {\n\t\tif !ex.enum {\n\t\t\treport.ErrTok(tok, \"struct tag redeclared as enum tag, previous declaration/definition: %s\", position(ex.Node.Pos()))\n\t\t}\n\t\treturn\n\t}\n\n\tm[tok.Val] = Binding{tok, true}\n}\n\nfunc (b *Bindings) defineEnumTag(tok xc.Token, n Node, report *xc.Report) {\n\tb = b.root()\n\tm := b.boot(NSTags)\n\tif ex, ok := m[tok.Val]; ok {\n\t\tif !ex.enum {\n\t\t\treport.ErrTok(tok, \"struct tag redefined as enum tag, previous declaration/definition: %s\", position(ex.Node.Pos()))\n\t\t\treturn\n\t\t}\n\n\t\tif _, ok := ex.Node.(xc.Token); !ok {\n\t\t\treport.ErrTok(tok, \"enum tag redefined, previous definition: %s\", position(ex.Node.Pos()))\n\t\t\treturn\n\t\t}\n\t}\n\n\tm[tok.Val] = Binding{n, true}\n}\n\nfunc (b *Bindings) defineEnumConst(lx *lexer, tok xc.Token, v interface{}) *Declarator {\n\tb = b.root()\n\td := lx.model.makeDeclarator(0, tsInt)\n\tdd := d.DirectDeclarator\n\tdd.Token = tok\n\tdd.EnumVal = v\n\td.setFull(lx)\n\tb.declareIdentifier(tok, dd, lx.report)\n\tswitch x := v.(type) {\n\tcase int16:\n\t\tlx.iota = int64(x) + 1\n\tcase int32:\n\t\tlx.iota = int64(x) + 1\n\tcase int64:\n\t\tlx.iota = x + 1\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n\treturn d\n}\n\nfunc (b *Bindings) declareStructTag(tok xc.Token, report *xc.Report) {\n\tb = b.root()\n\tm := b.boot(NSTags)\n\tif ex, ok := m[tok.Val]; ok {\n\t\tif ex.enum {\n\t\t\treport.ErrTok(tok, \"enum tag redeclared as struct tag, previous declaration/definition: %s\", position(ex.Node.Pos()))\n\t\t}\n\t\treturn\n\t}\n\n\tm[tok.Val] = Binding{tok, false}\n}\n\nfunc (b *Bindings) defineStructTag(tok xc.Token, n Node, report *xc.Report) {\n\tb = b.root()\n\tm := b.boot(NSTags)\n\tif ex, ok := m[tok.Val]; ok {\n\t\tif ex.enum {\n\t\t\treport.ErrTok(tok, \"enum tag redefined as struct tag, previous declaration/definition: %s\", position(ex.Node.Pos()))\n\t\t\treturn\n\t\t}\n\n\t\tif _, ok := ex.Node.(xc.Token); !ok {\n\t\t\tif !n.(*StructOrUnionSpecifier).isCompatible(ex.Node.(*StructOrUnionSpecifier)) {\n\t\t\t\treport.ErrTok(tok, \"incompatible struct tag redefinition, previous definition at %s\", position(ex.Node.Pos()))\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\n\tm[tok.Val] = Binding{n, false}\n}\n\nfunc (b *Bindings) isTypedefName(id int) bool {\n\tx := b.Lookup(NSIdentifiers, id)\n\tif dd, ok := x.Node.(*DirectDeclarator); ok {\n\t\treturn dd.specifier.IsTypedef()\n\t}\n\n\treturn false\n}\n\nfunc (b *Bindings) lexerHack(tok, prev xc.Token) xc.Token { // https://en.wikipedia.org/wiki/The_lexer_hack\n\tif noTypedefNameAfter[prev.Rune] {\n\t\treturn tok\n\t}\n\n\tif tok.Rune == IDENTIFIER && b.isTypedefName(tok.Val) {\n\t\ttok.Char = lex.NewChar(tok.Pos(), TYPEDEFNAME)\n\t}\n\treturn tok\n}\n\nfunc errPos(a ...token.Pos) token.Pos {\n\tfor _, v := range a {\n\t\tif v.IsValid() {\n\t\t\treturn v\n\t\t}\n\t}\n\n\treturn token.Pos(0)\n}\n\nfunc isZero(v interface{}) bool { return !isNonZero(v) }\n\nfunc isNonZero(v interface{}) bool {\n\tswitch x := v.(type) {\n\tcase int32:\n\t\treturn x != 0\n\tcase int:\n\t\treturn x != 0\n\tcase uint32:\n\t\treturn x != 0\n\tcase int64:\n\t\treturn x != 0\n\tcase uint64:\n\t\treturn x != 0\n\tcase float32:\n\t\treturn x != 0\n\tcase float64:\n\t\treturn x != 0\n\tcase StringLitID, LongStringLitID:\n\t\treturn true\n\tdefault:\n\t\tpanic(fmt.Errorf(\"internal error: %T\", x))\n\t}\n}\n\nfunc fromSlashes(a []string) []string {\n\tfor i, v := range a {\n\t\ta[i] = filepath.FromSlash(v)\n\t}\n\treturn a\n}\n\ntype ctype struct {\n\tbits            int\n\tdds             []*DirectDeclarator // Expanded.\n\tdds0            []*DirectDeclarator // Unexpanded, only for typedefs\n\tmodel           *Model\n\tresultAttr      int\n\tresultSpecifier Specifier\n\tresultStars     int\n\tstars           int\n}\n\nfunc (n *ctype) SetBits(b int) Type {\n\tif b < 0 {\n\t\tpanic(\"internal error\")\n\t}\n\n\tif b == n.bits {\n\t\treturn n\n\t}\n\n\to := *n\n\to.bits = b\n\treturn &o\n}\n\nfunc (n *ctype) Bits() int {\n\tif n.bits > 0 {\n\t\treturn n.bits\n\t}\n\n\tif !IsIntType(n) {\n\t\treturn -1\n\t}\n\n\tn.bits = n.model.Items[n.Kind()].Size * 8\n\treturn n.bits\n}\n\nfunc (n *ctype) arrayDecay() *ctype {\n\treturn n.setElements(-1)\n}\n\nfunc (n *ctype) setElements(elems int) *ctype {\n\tm := *n\n\tm.dds = append([]*DirectDeclarator(nil), n.dds...)\n\tfor i, dd := range m.dds {\n\t\tswitch dd.Case {\n\t\tcase 0: // IDENTIFIER\n\t\t\t// nop\n\t\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tdd := dd.clone()\n\t\t\tdd.elements = elems\n\t\t\tm.dds[i] = dd\n\t\t\treturn &m\n\t\tdefault:\n\t\t\t//dbg(\"\", position(dd.Pos()), n.str(), elems)\n\t\t\tpanic(dd.Case)\n\t\t}\n\t}\n\treturn n\n}\n\nfunc (n *ctype) eq(m *ctype) (r bool) {\n\tconst ignore = saInline | saTypedef | saExtern | saStatic | saAuto | saRegister | saConst | saRestrict | saVolatile | saNoreturn\n\n\tif n == m {\n\t\treturn true\n\t}\n\n\tif len(n.dds) != len(m.dds) || n.resultAttr&^ignore != m.resultAttr&^ignore ||\n\t\tn.resultStars != m.resultStars || n.stars != m.stars {\n\t\treturn false\n\t}\n\n\tfor i, n := range n.dds {\n\t\tif !n.isCompatible(m.dds[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn n.resultSpecifier.str() == m.resultSpecifier.str()\n}\n\nfunc (n *ctype) isCompatible(m *ctype) (r bool) {\n\tconst ignore = saInline | saTypedef | saExtern | saStatic | saAuto | saRegister | saConst | saRestrict | saVolatile | saNoreturn\n\n\tif n == m {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Array {\n\t\tn = n.arrayDecay()\n\t}\n\n\tif m.Kind() == Array {\n\t\tm = m.arrayDecay()\n\t}\n\n\tif len(n.dds) != len(m.dds) || n.resultAttr&^ignore != m.resultAttr&^ignore ||\n\t\tn.resultStars != m.resultStars || n.stars != m.stars {\n\t\treturn false\n\t}\n\n\tif n.Kind() == Function && m.Kind() == Function {\n\t\ta, va := n.Parameters()\n\t\tb, vb := m.Parameters()\n\t\treturn isCompatibleParameters(a, b, va, vb)\n\t}\n\n\tfor i, n := range n.dds {\n\t\tif !n.isCompatible(m.dds[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tns := n.resultSpecifier\n\tms := m.resultSpecifier\n\tif ns == ms {\n\t\treturn true\n\t}\n\n\tif n.Kind() != m.Kind() {\n\t\treturn false\n\t}\n\n\tswitch ns.kind() {\n\tcase Array:\n\t\tpanic(\"internal error\")\n\tcase Struct, Union:\n\t\treturn n.structOrUnionSpecifier().isCompatible(m.structOrUnionSpecifier())\n\tcase Enum:\n\t\t/*TODO\n\t\t6.2.7 Compatible type and composite type\n\n\t\t1 Two types have compatible type if their types are the same.\n\t\tAdditional rules for determining whether two types are\n\t\tcompatible are described in 6.7.2 for type specifiers, in 6.7.3\n\t\tfor type qualifiers, and in 6.7.5 for declarators.46) Moreover,\n\t\ttwo structure, union, or enumerated types declared in separate\n\t\ttranslation units are compatible if their tags and members\n\t\tsatisfy the following requirements: If one is declared with a\n\t\ttag, the other shall be declared with the same tag. If both are\n\t\tcomplete types, then the following additional requirements\n\t\tapply: there shall be a one-to-one correspondence between their\n\t\tmembers such that each pair of corresponding members are\n\t\tdeclared with compatible types, and such that if one member of\n\t\ta corresponding pair is declared with a name, the other member\n\t\tis declared with the same name. For two structures,\n\t\tcorresponding members shall be declared in the same order. For\n\t\ttwo structures or unions, corresponding bit-fields shall have\n\t\tthe same widths. For two enumerations, corresponding members\n\t\tshall have the same values.\n\n\t\t*/\n\t\treturn ms.kind() == Enum\n\tcase TypedefName:\n\t\tpanic(\"internal error\")\n\tdefault:\n\t\treturn true\n\t}\n}\n\nfunc (n *ctype) index(d int) int { return len(n.dds) - 1 + d }\n\nfunc (n *ctype) top(d int) *DirectDeclarator {\n\treturn n.dds[n.index(d)]\n}\n\n// AlignOf implements Type.\nfunc (n *ctype) AlignOf() int {\n\tif n == undefined {\n\t\treturn 1\n\t}\n\n\tif n.Kind() == Array {\n\t\treturn n.Element().AlignOf()\n\t}\n\n\tswitch k := n.Kind(); k {\n\tcase\n\t\tVoid,\n\t\tPtr,\n\t\tChar,\n\t\tSChar,\n\t\tUChar,\n\t\tShort,\n\t\tUShort,\n\t\tInt,\n\t\tUInt,\n\t\tLong,\n\t\tULong,\n\t\tLongLong,\n\t\tULongLong,\n\t\tFloat,\n\t\tDouble,\n\t\tLongDouble,\n\t\tBool,\n\t\tFloatComplex,\n\t\tDoubleComplex,\n\t\tLongDoubleComplex:\n\t\treturn n.model.Items[k].Align\n\tcase Enum:\n\t\treturn n.model.Items[Int].Align\n\tcase Struct, Union:\n\t\tswitch sus := n.structOrUnionSpecifier(); sus.Case {\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\treturn -1 // Incomplete type\n\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\treturn sus.alignOf\n\t\tdefault:\n\t\t\tpanic(sus.Case)\n\t\t}\n\tdefault:\n\t\tpanic(k.String())\n\t}\n}\n\nfunc (n *ctype) unionCanAssignTo(dst Type) bool {\n\tm, isIncomplete := n.Members()\n\tif isIncomplete {\n\t\treturn false\n\t}\n\n\tfor _, v := range m {\n\t\tif v.Type.CanAssignTo(dst) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// CanAssignTo implements Type.\nfunc (n *ctype) CanAssignTo(dst Type) bool {\n\tif n == undefined || dst.Kind() == Undefined {\n\t\treturn false\n\t}\n\n\tif n.Kind() == Bool && IsIntType(dst) {\n\t\treturn true\n\t}\n\n\tif dst.Kind() == Bool && IsIntType(n) {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Union && n.unionCanAssignTo(dst) {\n\t\treturn true\n\t}\n\n\tif dst.Kind() == Union && dst.(*ctype).unionCanAssignTo(n) {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Function {\n\t\tn = n.Pointer().(*ctype)\n\t}\n\n\tif dst.Kind() == Function {\n\t\tdst = dst.Pointer().(*ctype)\n\t}\n\n\tif n.Kind() == Array && dst.Kind() == Ptr {\n\t\tn = n.arrayDecay()\n\t}\n\n\tif dst.Kind() == Array && n.Kind() == Ptr {\n\t\tdst = dst.(*ctype).arrayDecay()\n\t}\n\n\tif IsArithmeticType(n) && IsArithmeticType(dst) {\n\t\treturn true\n\t}\n\n\tif IsIntType(n) && dst.Kind() == Enum {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Enum && IsIntType(dst) {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Ptr && dst.Kind() == Ptr && dst.Element().Kind() == Void {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Ptr && n.Element().Kind() == Void && dst.Kind() == Ptr {\n\t\treturn true\n\t}\n\n\tif n.isCompatible(dst.(*ctype)) {\n\t\treturn true\n\t}\n\n\tif n.Kind() == Ptr && dst.Kind() == Ptr {\n\t\tt := Type(n)\n\t\tu := dst\n\t\tfor t.Kind() == Ptr && u.Kind() == Ptr {\n\t\t\tt = t.Element()\n\t\t\tu = u.Element()\n\t\t}\n\t\tif t.Kind() == Array && unsigned(t.Element().Kind()) == unsigned(u.Kind()) {\n\t\t\treturn true\n\t\t}\n\n\t\tif t.Kind() == Ptr || u.Kind() == Ptr {\n\t\t\treturn false\n\t\t}\n\n\t\tif IsIntType(t) && IsIntType(u) && unsigned(t.Kind()) == unsigned(u.Kind()) {\n\t\t\treturn true\n\t\t}\n\n\t\tif t.Kind() == Function && u.Kind() == Function {\n\t\t\ta, _ := t.Parameters()\n\t\t\tb, _ := u.Parameters()\n\t\t\tif (len(a) == 0) != (len(b) == 0) {\n\t\t\t\ta := t.Result()\n\t\t\t\tb := u.Result()\n\t\t\t\treturn a.Kind() == Void && b.Kind() == Void || t.Result().CanAssignTo(u.Result())\n\t\t\t}\n\t\t}\n\n\t\treturn t.(*ctype).isCompatible(u.(*ctype))\n\t}\n\n\tif n.Kind() == Function && dst.Kind() == Ptr && dst.Element().Kind() == Function {\n\t\treturn n.isCompatible(dst.Element().(*ctype))\n\t}\n\n\tif dst.Kind() == Ptr {\n\t\tif IsIntType(n) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n\n// RawDeclarator implements Type.\nfunc (n *ctype) RawDeclarator() *Declarator {\n\tif len(n.dds0) == 0 {\n\t\treturn n.dds[0].TopDeclarator()\n\t}\n\n\treturn n.dds0[0].TopDeclarator()\n}\n\n// Declarator implements Type.\nfunc (n *ctype) Declarator() *Declarator {\n\tif len(n.dds) == 0 {\n\t\tpanic(\"internal error\")\n\t}\n\n\treturn n.dds[0].TopDeclarator()\n}\n\n// Element implements Type.\nfunc (n *ctype) Element() Type {\n\tif n == undefined {\n\t\treturn n\n\t}\n\n\tif n.Kind() != Ptr && n.Kind() != Array {\n\t\treturn undefined\n\t}\n\n\tif len(n.dds) == 1 {\n\t\tm := *n\n\t\tm.stars--\n\t\treturn &m\n\t}\n\n\tswitch dd := n.dds[1]; dd.Case {\n\tcase 1: // '(' Declarator ')'\n\t\tif n.stars == 1 {\n\t\t\tm := *n\n\t\t\tm.dds = append([]*DirectDeclarator{n.dds[0]}, n.dds[2:]...)\n\t\t\tm.dds0 = n.dds0\n\t\t\tswitch len(m.dds0) {\n\t\t\tcase 0:\n\t\t\t\t// nop\n\t\t\tcase 1:\n\t\t\t\tnm := m.Declarator().RawSpecifier().TypedefName()\n\t\t\t\ttypedef := m.Declarator().DirectDeclarator.idScope.Lookup(NSIdentifiers, nm)\n\t\t\t\tif typedef.Node == nil {\n\t\t\t\t\tbreak // undefined\n\t\t\t\t}\n\n\t\t\t\tm.dds0 = typedef.Node.(*DirectDeclarator).TopDeclarator().Type.(*ctype).dds0\n\t\t\t\tif len(m.dds0) < 3 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tfallthrough\n\t\t\tdefault:\n\t\t\t\tm.dds0 = append([]*DirectDeclarator{m.dds0[0]}, m.dds0[2:]...)\n\t\t\t}\n\t\t\tm.stars--\n\t\t\treturn &m\n\t\t}\n\n\t\tm := *n\n\t\tm.stars--\n\t\treturn &m\n\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\tm := *n\n\t\tm.dds = append([]*DirectDeclarator{n.dds[0]}, n.dds[2:]...)\n\t\tswitch {\n\t\tcase len(m.dds) == 1:\n\t\t\tm.stars += m.resultStars\n\t\t\tm.resultStars = 0\n\t\tdefault:\n\t\t\tif dd := m.dds[1]; dd.Case == 1 { // '(' Declarator ')'\n\t\t\t\tm.stars = dd.Declarator.stars()\n\t\t\t\tif dd.Declarator.stars() == 0 {\n\t\t\t\t\tm.dds = append([]*DirectDeclarator{m.dds[0]}, m.dds[2:]...)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn &m\n\tdefault:\n\t\t//dbg(\"\", position(n.dds[0].Pos()), n, n.Kind())\n\t\t//dbg(\"\", n.str())\n\t\tpanic(dd.Case)\n\t}\n}\n\n// Kind implements Type.\nfunc (n *ctype) Kind() Kind {\n\tif n == undefined {\n\t\treturn Undefined\n\t}\n\n\tif n.stars > 0 {\n\t\treturn Ptr\n\t}\n\n\tif len(n.dds) == 1 {\n\t\treturn n.resultSpecifier.kind()\n\t}\n\n\ti := 1\n\tfor {\n\t\tswitch dd := n.dds[i]; dd.Case {\n\t\t//TODO case 1: // '(' Declarator ')'\n\t\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tif dd.elements < 0 {\n\t\t\t\treturn Ptr\n\t\t\t}\n\n\t\t\treturn Array\n\t\tcase\n\t\t\t6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\treturn Function\n\t\tdefault:\n\t\t\t//dbg(\"\", position(n.Declarator().Pos()))\n\t\t\t//dbg(\"\", n)\n\t\t\t//dbg(\"\", n.str())\n\t\t\tpanic(dd.Case)\n\t\t}\n\t}\n}\n\n// Member implements Type.\nfunc (n *ctype) Member(nm int) (*Member, error) {\n\tif n == undefined {\n\t\treturn nil, fmt.Errorf(\"not a struct/union (have '%s')\", n)\n\t}\n\n\tif n.Kind() == Array {\n\t\tpanic(\"TODO\")\n\t}\n\n\tif k := n.Kind(); k != Struct && k != Union {\n\t\treturn nil, fmt.Errorf(\"request for member %s in something not a structure or union (have '%s')\", xc.Dict.S(nm), n)\n\t}\n\n\ta, _ := n.Members()\n\tfor i := range a {\n\t\tif a[i].Name == nm {\n\t\t\treturn &a[i], nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"%s has no member named %s\", Type(n), xc.Dict.S(nm))\n}\n\n// Returns nil if type kind != Enum\nfunc (n *ctype) enumSpecifier() *EnumSpecifier {\n\treturn n.resultSpecifier.firstTypeSpecifier().EnumSpecifier\n}\n\nfunc (n *ctype) structOrUnionSpecifier() *StructOrUnionSpecifier {\n\tif k := n.Kind(); k != Struct && k != Union {\n\t\treturn nil\n\t}\n\n\tts := n.resultSpecifier.firstTypeSpecifier()\n\tif ts.Case != 11 { // StructOrUnionSpecifier\n\t\tpanic(\"internal error\")\n\t}\n\n\tswitch sus := ts.StructOrUnionSpecifier; sus.Case {\n\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\treturn sus\n\tcase 1: // StructOrUnion IDENTIFIER\n\t\tb := sus.scope.Lookup(NSTags, sus.Token.Val)\n\t\tswitch x := b.Node.(type) {\n\t\tcase nil:\n\t\t\treturn sus\n\t\tcase *StructOrUnionSpecifier:\n\t\t\treturn x\n\t\tcase xc.Token:\n\t\t\treturn sus\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\tcase 2: // StructOrUnion IdentifierOpt '{' '}'                        // Case 2\n\t\treturn sus\n\tdefault:\n\t\tpanic(sus.Case)\n\t}\n}\n\nfunc (n *ctype) members(p *[]Member, l *StructDeclarationList) {\n\tr := *p\n\tdefer func() { *p = r }()\n\n\tfor ; l != nil; l = l.StructDeclarationList {\n\t\tswitch sdn := l.StructDeclaration; sdn.Case {\n\t\tcase 0: // SpecifierQualifierList StructDeclaratorList ';'\n\t\t\tfor l := sdn.StructDeclaratorList; l != nil; l = l.StructDeclaratorList {\n\t\t\t\tvar d *Declarator\n\t\t\t\tvar bits int\n\t\t\t\tswitch sd := l.StructDeclarator; sd.Case {\n\t\t\t\tcase 0: // Declarator\n\t\t\t\t\td = sd.Declarator\n\t\t\t\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\t\t\t\tif o := sd.DeclaratorOpt; o != nil {\n\t\t\t\t\t\td = o.Declarator\n\t\t\t\t\t}\n\t\t\t\t\tswitch x := sd.ConstantExpression.Value.(type) {\n\t\t\t\t\tcase int32:\n\t\t\t\t\t\tbits = int(x)\n\t\t\t\t\tcase int64:\n\t\t\t\t\t\tif x <= int64(n.model.Items[Int].Size*8) {\n\t\t\t\t\t\t\tbits = int(x)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\tcase uint64:\n\t\t\t\t\t\tif x <= uint64(n.model.Items[Int].Size*8) {\n\t\t\t\t\t\t\tbits = int(x)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(sd.Case)\n\t\t\t\t}\n\t\t\t\tvar id, off, pad, bitoff, group int\n\t\t\t\tt := n.model.IntType\n\t\t\t\tvar bt Type\n\t\t\t\tif d != nil {\n\t\t\t\t\tid, _ = d.Identifier()\n\t\t\t\t\tt = d.Type\n\t\t\t\t\toff = d.offsetOf\n\t\t\t\t\tpad = d.padding\n\t\t\t\t\tbitoff = d.bitOffset\n\t\t\t\t\tbt = d.bitFieldType\n\t\t\t\t\tgroup = d.bitFieldGroup\n\t\t\t\t}\n\t\t\t\tr = append(r, Member{\n\t\t\t\t\tBitFieldGroup: group,\n\t\t\t\t\tBitFieldType:  bt,\n\t\t\t\t\tBitOffsetOf:   bitoff,\n\t\t\t\t\tBits:          bits,\n\t\t\t\t\tDeclarator:    d,\n\t\t\t\t\tName:          id,\n\t\t\t\t\tOffsetOf:      off,\n\t\t\t\t\tPadding:       pad,\n\t\t\t\t\tType:          t,\n\t\t\t\t})\n\t\t\t}\n\t\tcase 1: // SpecifierQualifierList ';'                       // Case 1\n\t\t\td := sdn.SpecifierQualifierList.TypeSpecifier.StructOrUnionSpecifier.declarator\n\t\t\tt := d.Type\n\t\t\tr = append(r, Member{\n\t\t\t\tDeclarator: d,\n\t\t\t\tOffsetOf:   d.offsetOf,\n\t\t\t\tPadding:    d.padding,\n\t\t\t\tType:       t,\n\t\t\t})\n\t\tcase 2: // StaticAssertDeclaration                          // Case 2\n\t\t\t//nop\n\t\tdefault:\n\t\t\tpanic(\"internal error\")\n\t\t}\n\t}\n}\n\n// Members implements Type.\nfunc (n *ctype) Members() (r []Member, isIncomplete bool) {\n\tif k := n.Kind(); k != Struct && k != Union {\n\t\treturn nil, false\n\t}\n\n\tswitch sus := n.structOrUnionSpecifier(); sus.Case {\n\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\tn.members(&r, sus.StructDeclarationList)\n\t\treturn r, false\n\tcase 1: // StructOrUnion IDENTIFIER\n\t\treturn []Member{}, true\n\tcase 2: // StructOrUnion IdentifierOpt '{' '}'                        // Case 2\n\t\treturn []Member{}, false\n\tdefault:\n\t\tpanic(sus.Case)\n\t}\n}\n\n// Parameters implements Type.\nfunc (n *ctype) Parameters() ([]Parameter, bool) {\n\tif n == undefined || n.Kind() != Function {\n\t\treturn nil, false\n\t}\n\n\tswitch dd := n.dds[1]; dd.Case {\n\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'\n\t\tl := dd.ParameterTypeList\n\t\treturn l.params, l.Case == 1 // ParameterList ',' \"...\"\n\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\to := dd.IdentifierListOpt\n\t\tif o == nil {\n\t\t\treturn make([]Parameter, 0), false\n\t\t}\n\n\t\treturn o.params, false\n\tdefault:\n\t\t//dbg(\"\", dd.Case)\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// Pointer implements Type.\nfunc (n *ctype) Pointer() Type {\n\tif n == undefined {\n\t\treturn n\n\t}\n\n\tif len(n.dds) == 1 {\n\t\tm := *n\n\t\tm.stars++\n\t\treturn &m\n\t}\n\n\tswitch dd := n.dds[1]; dd.Case {\n\tcase\n\t\t2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'        // Case 2\n\t\t3, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'  // Case 3\n\t\t4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'     // Case 4\n\t\t5, // DirectDeclarator '[' TypeQualifierListOpt '*' ']'                  // Case 5\n\t\t6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\tdd := &DirectDeclarator{\n\t\t\tCase: 1, // '(' Declarator ')'\n\t\t\tDeclarator: &Declarator{\n\t\t\t\tDirectDeclarator: &DirectDeclarator{},\n\t\t\t\tPointerOpt: &PointerOpt{\n\t\t\t\t\tPointer: &Pointer{},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t\tm := *n\n\t\tm.dds = append(append([]*DirectDeclarator{n.dds[0]}, dd), n.dds[1:]...)\n\t\tm.stars++\n\t\treturn &m\n\tdefault:\n\t\tm := *n\n\t\tm.stars++\n\t\treturn &m\n\t}\n}\n\n// Result implements Type.\nfunc (n *ctype) Result() Type {\n\tif n == undefined {\n\t\treturn n\n\t}\n\n\tif n.Kind() != Function {\n\t\t//dbg(\"\", n, n.Kind())\n\t\t//dbg(\"\", n.str())\n\t\tpanic(\"TODO\")\n\t}\n\n\ti := 1\n\tfor {\n\t\tswitch dd := n.dds[i]; dd.Case {\n\t\tcase\n\t\t\t6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\tif i == len(n.dds)-1 { // Outermost function.\n\t\t\t\tif i == 1 {\n\t\t\t\t\tm := *n\n\t\t\t\t\tm.dds = m.dds[:1:1]\n\t\t\t\t\tm.stars += m.resultStars\n\t\t\t\t\tm.resultStars = 0\n\t\t\t\t\treturn &m\n\t\t\t\t}\n\n\t\t\t\t//dbg(\"\", n)\n\t\t\t\t//dbg(\"\", n.str())\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tm := *n\n\t\t\tm.dds = append([]*DirectDeclarator{n.dds[0]}, n.dds[i+1:]...)\n\t\t\tif dd := m.dds[1]; dd.Case == 1 { // '(' Declarator ')'\n\t\t\t\tm.stars = dd.Declarator.stars()\n\t\t\t}\n\t\t\treturn &m\n\t\tdefault:\n\t\t\t//dbg(\"\", position(n.dds[0].Pos()), n)\n\t\t\t//dbg(\"\", n.str())\n\t\t\tpanic(dd.Case)\n\t\t}\n\n\t}\n}\n\n// Elements implements Type.\nfunc (n *ctype) Elements() int {\n\tdone := false\nloop:\n\tfor _, dd := range n.dds {\n\tmore:\n\t\tswitch dd.Case {\n\t\tcase 0: // IDENTIFIER\n\t\tcase 1: // '(' Declarator ')'\n\t\t\tdd = dd.Declarator.DirectDeclarator\n\t\t\tdone = true\n\t\t\tgoto more\n\t\tcase\n\t\t\t2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\t3, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t\t4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t\t5: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t\treturn dd.elements\n\t\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'                         // Case 6\n\t\t\tbreak loop\n\t\tdefault:\n\t\t\t//dbg(\"\", position(n.dds[0].Pos()), n)\n\t\t\t//dbg(\"\", n.str())\n\t\t\tpanic(dd.Case)\n\t\t}\n\t\tif done {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn -1\n}\n\n// EnumeratorList implements Type\nfunc (n *ctype) EnumeratorList() (r []EnumConstant) {\n\tif n.Kind() != Enum {\n\t\treturn nil\n\t}\n\n\tswitch es := n.enumSpecifier(); es.Case {\n\tcase 0: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\tfor l := es.EnumeratorList; l != nil; l = l.EnumeratorList {\n\t\t\te := l.Enumerator\n\t\t\tif e.ConstantExpression != nil {\n\t\t\t\tr = append(r, EnumConstant{\n\t\t\t\t\tDefTok: e.EnumerationConstant.Token,\n\t\t\t\t\tValue:  e.Value,\n\t\t\t\t\tTokens: e.ConstantExpression.toks})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tr = append(r, EnumConstant{\n\t\t\t\tDefTok: e.EnumerationConstant.Token,\n\t\t\t\tValue:  e.Value,\n\t\t\t})\n\t\t}\n\t\treturn r\n\tcase 1: // \"enum\" IDENTIFIER\n\t\treturn nil\n\tdefault:\n\t\tpanic(es.Case)\n\t}\n}\n\n// SizeOf implements Type.\nfunc (n *ctype) SizeOf() int {\n\tif n == undefined {\n\t\treturn 1\n\t}\n\n\tif n.Kind() == Array {\n\t\tswitch nelem := n.Elements(); {\n\t\tcase nelem < 0:\n\t\t\treturn n.model.Items[Ptr].Size\n\t\tdefault:\n\t\t\treturn nelem * n.Element().SizeOf()\n\t\t}\n\t}\n\n\tswitch k := n.Kind(); k {\n\tcase\n\t\tVoid,\n\t\tPtr,\n\t\tChar,\n\t\tSChar,\n\t\tUChar,\n\t\tShort,\n\t\tUShort,\n\t\tInt,\n\t\tUInt,\n\t\tLong,\n\t\tULong,\n\t\tLongLong,\n\t\tULongLong,\n\t\tFloat,\n\t\tDouble,\n\t\tLongDouble,\n\t\tBool,\n\t\tFloatComplex,\n\t\tDoubleComplex,\n\t\tLongDoubleComplex:\n\t\treturn n.model.Items[k].Size\n\tcase Enum:\n\t\treturn n.model.Items[Int].Size\n\tcase Struct, Union:\n\t\tswitch sus := n.structOrUnionSpecifier(); sus.Case {\n\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\treturn sus.sizeOf\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\treturn -1 // Incomplete type\n\t\tcase 2: // StructOrUnion IdentifierOpt '{' '}'                        // Case 2\n\t\t\treturn 0\n\t\tdefault:\n\t\t\tpanic(sus.Case)\n\t\t}\n\tcase Function:\n\t\treturn n.model.Items[Ptr].Size\n\tdefault:\n\t\treturn -1\n\t}\n}\n\nfunc (n *ctype) sizeOf(lx *lexer) int {\n\tr := n.SizeOf()\n\tif r < 0 {\n\t\tlx.report.Err(n.Declarator().Pos(), \"cannot determine size of %v\", n)\n\t\tr = 1\n\t}\n\treturn r\n}\n\n// Specifier implements Type.\nfunc (n *ctype) Specifier() Specifier { return &spec{n.resultAttr, n.resultSpecifier.typeSpecifiers()} }\n\n// String implements Type.\nfunc (n *ctype) String() string {\n\tif n == undefined {\n\t\treturn \"<undefined>\"\n\t}\n\n\tvar buf bytes.Buffer\n\ts := attrString(n.resultAttr)\n\tbuf.WriteString(s)\n\tif s != \"\" {\n\t\tbuf.WriteString(\" \")\n\t}\n\ts = specifierString(n.resultSpecifier)\n\tbuf.WriteString(s)\n\tbuf.WriteString(strings.Repeat(\"*\", n.resultStars))\n\n\tparams := func(p []Parameter) {\n\t\tfor i, v := range p {\n\t\t\tfmt.Fprintf(&buf, \"%s\", v.Type)\n\t\t\tif i != len(p)-1 {\n\t\t\t\tbuf.WriteByte(',')\n\t\t\t}\n\t\t}\n\t}\n\n\tvar f func(int)\n\tstarsWritten := false\n\tf = func(x int) {\n\t\tswitch dd := n.top(x); dd.Case {\n\t\tcase 0: // IDENTIFIER\n\t\t\tif debugTypeStrings {\n\t\t\t\tid := dd.Token.Val\n\t\t\t\tif id == 0 {\n\t\t\t\t\tid = idID\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(&buf, \"<%s>\", xc.Dict.S(id))\n\t\t\t}\n\t\t\tif !starsWritten {\n\t\t\t\tbuf.WriteString(strings.Repeat(\"*\", n.stars))\n\t\t\t}\n\t\tcase 1: // '(' Declarator ')'\n\t\t\tbuf.WriteString(\"(\")\n\t\t\ts := 0\n\t\t\tswitch dd2 := n.top(x - 1); dd2.Case {\n\t\t\tcase 0: // IDENTIFIER\n\t\t\t\ts = n.stars\n\t\t\t\tstarsWritten = true\n\t\t\tdefault:\n\t\t\t\ts = dd.Declarator.stars()\n\t\t\t}\n\t\t\tbuf.WriteString(strings.Repeat(\"*\", s))\n\t\t\tf(x - 1)\n\t\t\tbuf.WriteString(\")\")\n\t\tcase 2: // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tf(x - 1)\n\t\t\tbuf.WriteString(\"[\")\n\t\t\tsep := \"\"\n\t\t\tif o := dd.TypeQualifierListOpt; o != nil {\n\t\t\t\tbuf.WriteString(attrString(o.TypeQualifierList.attr))\n\t\t\t\tsep = \" \"\n\t\t\t}\n\t\t\tif e := dd.elements; e > 0 {\n\t\t\t\tbuf.WriteString(sep)\n\t\t\t\tfmt.Fprint(&buf, e)\n\t\t\t}\n\t\t\tbuf.WriteString(\"]\")\n\t\tcase 6: // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\tf(x - 1)\n\t\t\tbuf.WriteString(\"(\")\n\t\t\tparams(dd.ParameterTypeList.params)\n\t\t\tbuf.WriteString(\")\")\n\t\tcase 7: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\tf(x - 1)\n\t\t\tbuf.WriteString(\"(\")\n\t\t\tif o := dd.IdentifierListOpt; o != nil {\n\t\t\t\tparams(o.params)\n\t\t\t}\n\t\t\tbuf.WriteString(\")\")\n\t\tdefault:\n\t\t\tpanic(dd.Case)\n\t\t}\n\t}\n\tf(0)\n\treturn buf.String()\n}\n\n// StructAlignOf implements Type.\nfunc (n *ctype) StructAlignOf() int {\n\tif n == undefined {\n\t\treturn 1\n\t}\n\n\tif n.Kind() == Array {\n\t\treturn n.Element().StructAlignOf()\n\t}\n\n\tswitch k := n.Kind(); k {\n\tcase\n\t\tVoid,\n\t\tPtr,\n\t\tChar,\n\t\tSChar,\n\t\tUChar,\n\t\tShort,\n\t\tUShort,\n\t\tInt,\n\t\tUInt,\n\t\tLong,\n\t\tULong,\n\t\tLongLong,\n\t\tULongLong,\n\t\tFloat,\n\t\tDouble,\n\t\tLongDouble,\n\t\tBool,\n\t\tFloatComplex,\n\t\tDoubleComplex,\n\t\tLongDoubleComplex:\n\t\treturn n.model.Items[k].StructAlign\n\tcase Enum:\n\t\treturn n.model.Items[Int].StructAlign\n\tcase Struct, Union:\n\t\tswitch sus := n.structOrUnionSpecifier(); sus.Case {\n\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\treturn sus.alignOf\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\treturn -1 // Incomplete type\n\t\tcase 2: // StructOrUnion IdentifierOpt '{' '}'                        // Case 2\n\t\t\treturn 1\n\t\tdefault:\n\t\t\tpanic(sus.Case)\n\t\t}\n\tdefault:\n\t\treturn -1\n\t}\n}\n\nfunc (n *ctype) structAlignOf(lx *lexer) int {\n\tr := n.StructAlignOf()\n\tif r < 0 {\n\t\tlx.report.Err(n.Declarator().Pos(), \"cannot determine struct align of %v\", n)\n\t\tr = 1\n\t}\n\treturn r\n}\n\n// Tag implements Type.\nfunc (n *ctype) Tag() int {\n\tswitch k := n.Kind(); k {\n\tcase Struct, Union:\n\t\tswitch sus := n.structOrUnionSpecifier(); sus.Case {\n\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\tif o := sus.IdentifierOpt; o != nil {\n\t\t\t\treturn o.Token.Val\n\t\t\t}\n\n\t\t\treturn 0\n\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\treturn sus.Token.Val\n\t\tdefault:\n\t\t\tpanic(sus.Case)\n\t\t}\n\tcase Enum:\n\t\tes := n.enumSpecifier()\n\t\tif es == nil {\n\t\t\treturn 0\n\t\t}\n\n\t\tswitch es.Case {\n\t\tcase 0: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\t\tif o := es.IdentifierOpt; o != nil {\n\t\t\t\treturn o.Token.Val\n\t\t\t}\n\n\t\t\treturn 0\n\t\tcase 1: // \"enum\" IDENTIFIER\n\t\t\treturn es.Token2.Val\n\t\tdefault:\n\t\t\tpanic(es.Case)\n\t\t}\n\tdefault:\n\t\treturn 0\n\t}\n}\n\ntype spec struct {\n\tattr int\n\tts   int\n}\n\nfunc (s *spec) IsAuto() bool                       { return s.attr&saAuto != 0 }\nfunc (s *spec) IsConst() bool                      { return s.attr&saConst != 0 }\nfunc (s *spec) IsExtern() bool                     { return s.attr&saExtern != 0 }\nfunc (s *spec) IsInline() bool                     { return s.attr&saInline != 0 }\nfunc (s *spec) IsRegister() bool                   { return s.attr&saRegister != 0 }\nfunc (s *spec) IsRestrict() bool                   { return s.attr&saRestrict != 0 }\nfunc (s *spec) IsStatic() bool                     { return s.attr&saStatic != 0 }\nfunc (s *spec) IsTypedef() bool                    { return s.attr&saTypedef != 0 }\nfunc (s *spec) IsVolatile() bool                   { return s.attr&saVolatile != 0 }\nfunc (s *spec) TypedefName() int                   { return 0 }\nfunc (s *spec) attrs() int                         { return s.attr }\nfunc (s *spec) firstTypeSpecifier() *TypeSpecifier { panic(\"TODO\") }\nfunc (s *spec) kind() Kind                         { return tsValid[s.ts] }\nfunc (s *spec) member(int) (*Member, error)        { panic(\"TODO\") }\nfunc (s *spec) str() string                        { return specifierString(s) }\nfunc (s *spec) typeSpecifiers() int                { return s.ts }\n\nfunc specifierString(sp Specifier) string {\n\tif sp == nil {\n\t\treturn \"\"\n\t}\n\n\tvar buf bytes.Buffer\n\tswitch k := sp.kind(); k {\n\tcase Enum:\n\t\tswitch ts := sp.firstTypeSpecifier(); ts.Case {\n\t\tcase 12: // EnumSpecifier\n\t\t\tes := ts.EnumSpecifier\n\t\t\tswitch es.Case {\n\t\t\tcase 0: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\t\t\tbuf.WriteString(\"enum\")\n\t\t\t\tif o := es.IdentifierOpt; o != nil {\n\t\t\t\t\tbuf.WriteString(\" \" + string(xc.Dict.S(o.Token.Val)))\n\t\t\t\t}\n\t\t\t\tbuf.WriteString(\" { ... }\")\n\t\t\tcase 1: // \"enum\" IDENTIFIER\n\t\t\t\tfmt.Fprintf(&buf, \"enum %s\", xc.Dict.S(es.Token2.Val))\n\t\t\tdefault:\n\t\t\t\tpanic(es.Case)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(ts.Case)\n\t\t}\n\tcase Function:\n\t\tpanic(\"TODO Function\")\n\tcase Struct, Union:\n\t\tswitch ts := sp.firstTypeSpecifier(); ts.Case {\n\t\tcase 11: // StructOrUnionSpecifier\n\t\t\tsus := ts.StructOrUnionSpecifier\n\t\t\tbuf.WriteString(sus.StructOrUnion.str())\n\t\t\tswitch sus.Case {\n\t\t\tcase 0: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\tif o := sus.IdentifierOpt; o != nil {\n\t\t\t\t\tbuf.WriteString(\" \")\n\t\t\t\t\tbuf.Write(o.Token.S())\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tbuf.WriteString(\"{\")\n\t\t\t\touterFirst := true\n\t\t\t\tfor l := sus.StructDeclarationList; l != nil; l = l.StructDeclarationList {\n\t\t\t\t\tif !outerFirst {\n\t\t\t\t\t\tbuf.WriteString(\"; \")\n\t\t\t\t\t}\n\t\t\t\t\touterFirst = false\n\t\t\t\t\tfirst := true\n\t\t\t\t\tfor l := l.StructDeclaration.StructDeclaratorList; l != nil; l = l.StructDeclaratorList {\n\t\t\t\t\t\tif !first {\n\t\t\t\t\t\t\tbuf.WriteString(\", \")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfirst = false\n\t\t\t\t\t\tswitch sd := l.StructDeclarator; sd.Case {\n\t\t\t\t\t\tcase 0: // Declarator\n\t\t\t\t\t\t\tbuf.WriteString(sd.Declarator.Type.String())\n\t\t\t\t\t\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\t\t\t\t\t\tif o := sd.DeclaratorOpt; o != nil {\n\t\t\t\t\t\t\t\tbuf.WriteString(o.Declarator.Type.String())\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbuf.WriteByte(':')\n\t\t\t\t\t\t\tfmt.Fprintf(&buf, \"%v\", sd.ConstantExpression.Value)\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tfmt.Fprintf(&buf, \"specifierString_TODO%v\", sd.Case)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbuf.WriteString(\";}\")\n\t\t\tcase 1: // StructOrUnion IDENTIFIER\n\t\t\t\tbuf.WriteString(\" \")\n\t\t\t\tbuf.Write(sus.Token.S())\n\t\t\tcase 2: // StructOrUnion IdentifierOpt '{' '}'                        // Case 2\n\t\t\t\tif o := sus.IdentifierOpt; o != nil {\n\t\t\t\t\tbuf.WriteString(\" \")\n\t\t\t\t\tbuf.Write(o.Token.S())\n\t\t\t\t}\n\t\t\t\tbuf.WriteString(\"{}\")\n\t\t\tdefault:\n\t\t\t\tpanic(sus.Case)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(ts.Case)\n\t\t}\n\tdefault:\n\t\tbuf.WriteString(k.CString())\n\t}\n\treturn buf.String()\n}\n\nfunc align(off, algn int) int {\n\tr := off % algn\n\tif r != 0 {\n\t\toff += algn - r\n\t}\n\treturn off\n}\n\nfunc finishBitField(n Node, lx *lexer) {\n\tsc := lx.scope\n\tmaxLLBits := lx.model.LongLongType.SizeOf() * 8\n\tbits := sc.bitOffset\n\tif bits > maxLLBits || bits == 0 {\n\t\tpanic(fmt.Errorf(\"%s: internal error %v\", position(n.Pos()), bits)) //TODO split group.\n\t}\n\n\tvar bytes, al int\n\tfor _, k := range []Kind{Char, Short, Int, Long, LongLong} {\n\t\tbytes = lx.model.Items[k].Size\n\t\tal = lx.model.Items[k].StructAlign\n\t\tif bytes*8 >= bits {\n\t\t\tvar t Type\n\t\t\tswitch k {\n\t\t\tcase Char:\n\t\t\t\tt = lx.model.CharType\n\t\t\tcase Short:\n\t\t\t\tt = lx.model.ShortType\n\t\t\tcase Int:\n\t\t\t\tt = lx.model.IntType\n\t\t\tcase Long:\n\t\t\t\tt = lx.model.LongType\n\t\t\tcase LongLong:\n\t\t\t\tt = lx.model.LongLongType\n\t\t\tdefault:\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\t\t\tsc.bitFieldTypes = append(sc.bitFieldTypes, t)\n\t\t\tbreak\n\t\t}\n\t}\n\tswitch {\n\tcase sc.isUnion:\n\t\toff := 0\n\t\tsc.offset = align(sc.offset, al)\n\t\tif pd := sc.prevStructDeclarator; pd != nil {\n\t\t\tpd.padding = sc.offset - off\n\t\t\tpd.offsetOf = sc.offset\n\t\t}\n\t\tsc.bitOffset = 0\n\t\tsc.bitFieldGroup++\n\tdefault:\n\t\toff := sc.offset\n\t\tsc.offset = align(sc.offset, al)\n\t\tif pd := sc.prevStructDeclarator; pd != nil {\n\t\t\tpd.padding = sc.offset - off\n\t\t\tpd.offsetOf = sc.offset\n\t\t}\n\t\tsc.offset += bytes\n\t\tsc.bitOffset = 0\n\t\tsc.bitFieldGroup++\n\t}\n\tsc.maxAlign = mathutil.Max(sc.maxAlign, al)\n}\n\n// IsArithmeticType reports wheter t.Kind() is one of UintPtr, Char, SChar,\n// UChar, Short, UShort, Int, UInt, Long, ULong, LongLong, ULongLong, Float,\n// Double, LongDouble, FloatComplex, DoubleComplex, LongDoubleComplex, Bool or\n// Enum.\nfunc IsArithmeticType(t Type) bool {\n\tswitch t.Kind() {\n\tcase\n\t\tUintPtr,\n\t\tChar,\n\t\tSChar,\n\t\tUChar,\n\t\tShort,\n\t\tUShort,\n\t\tInt,\n\t\tUInt,\n\t\tLong,\n\t\tULong,\n\t\tLongLong,\n\t\tULongLong,\n\t\tFloat,\n\t\tDouble,\n\t\tLongDouble,\n\t\tFloatComplex,\n\t\tDoubleComplex,\n\t\tLongDoubleComplex,\n\t\tBool,\n\t\tEnum:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// IsIntType reports t.Kind() is one of Char, SChar, UChar, Short, UShort, Int,\n// UInt, Long, ULong, LongLong, ULongLong, Bool or Enum.\nfunc IsIntType(t Type) bool {\n\tswitch t.Kind() {\n\tcase\n\t\tChar,\n\t\tSChar,\n\t\tUChar,\n\t\tShort,\n\t\tUShort,\n\t\tInt,\n\t\tUInt,\n\t\tLong,\n\t\tULong,\n\t\tLongLong,\n\t\tULongLong,\n\t\t// [0], 6.2.5/6: The type _Bool and the unsigned integer types\n\t\t// that correspond to the standard signed integer types are the\n\t\t// standard unsigned integer types.\n\t\tBool,\n\t\tEnum:\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc elements(v interface{}, t Type) (int, error) {\n\tif !IsIntType(t) {\n\t\treturn -1, fmt.Errorf(\"expression shall have integer type\")\n\t}\n\n\tif v == nil {\n\t\treturn -1, nil\n\t}\n\n\tr, err := toInt(v)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\n\tif r < 0 {\n\t\treturn -1, fmt.Errorf(\"array size must be positive: %v\", v)\n\t}\n\n\treturn r, nil\n}\n\nfunc toInt(v interface{}) (int, error) {\n\tswitch x := v.(type) {\n\tcase int8:\n\t\treturn int(x), nil\n\tcase byte:\n\t\treturn int(x), nil\n\tcase int16:\n\t\treturn int(x), nil\n\tcase uint16:\n\t\treturn int(x), nil\n\tcase int32:\n\t\treturn int(x), nil\n\tcase uint32:\n\t\treturn int(x), nil\n\tcase int64:\n\t\tif x < mathutil.MinInt || x > mathutil.MaxInt {\n\t\t\treturn 0, fmt.Errorf(\"value out of bounds: %v\", x)\n\t\t}\n\n\t\treturn int(x), nil\n\tcase uint64:\n\t\tif x > mathutil.MaxInt {\n\t\t\treturn 0, fmt.Errorf(\"value out of bounds: %v\", x)\n\t\t}\n\n\t\treturn int(x), nil\n\tcase int:\n\t\treturn x, nil\n\tdefault:\n\t\treturn -1, fmt.Errorf(\"not a constant integer expression: %v\", x)\n\t}\n}\n\nfunc dedupAbsPaths(a []string) (r []string, _ error) {\n\tm := map[string]struct{}{}\n\tfor _, v := range a {\n\t\tav, err := filepath.Abs(v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif _, ok := m[av]; ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tr = append(r, v)\n\t\tm[v] = struct{}{}\n\t}\n\treturn r, nil\n}\n\nfunc isCompatibleParameters(a, b []Parameter, va, vb bool) bool {\n\tif len(a) != len(b) || va != vb {\n\t\treturn false\n\t}\n\n\tfor i, v := range a {\n\t\tif !v.Type.CanAssignTo(b[i].Type) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n// [0], 6.2.7-3\n//\n// A composite type can be constructed from two types that are compatible; it\n// is a type that is compatible with both of the two types and satisfies the\n// following conditions:\n//\n// — If one type is an array of known constant size, the composite type is an\n// array of that size; otherwise, if one type is a variable length array, the\n// composite type is that type.\n//\n// — If only one type is a function type with a parameter type list (a function\n// prototype), the composite type is a function prototype with the parameter\n// type list.\n//\n// — If both types are function types with parameter type lists, the type of\n// each parameter in the composite parameter type list is the composite type of\n// the corresponding parameters.\n//\n// These rules apply recursively to the types from which the two types are\n// derived.\nfunc compositeType(a, b Type) (c Type, isA bool) {\n\tt, u := a, b\n\tfor t.Kind() == Ptr && u.Kind() == Ptr {\n\t\tt = t.Element()\n\t\tu = u.Element()\n\t}\n\n\tif t.Kind() == Function && u.Kind() == Function {\n\t\tif !t.Result().CanAssignTo(u.Result()) {\n\t\t\treturn nil, false\n\t\t}\n\n\t\tp, va := t.Parameters()\n\t\tq, vb := u.Parameters()\n\t\tif va != vb {\n\t\t\treturn nil, false\n\t\t}\n\n\t\tif len(p) == 0 && len(q) != 0 {\n\t\t\treturn b, false\n\t\t}\n\n\t\tif len(p) != 0 && len(q) == 0 {\n\t\t\treturn a, true\n\t\t}\n\n\t\tif len(p) != len(q) {\n\t\t\treturn nil, false\n\t\t}\n\n\t\tfor i, v := range p {\n\t\t\tw := q[i]\n\t\t\tif v.Type != undefined && w.Type == undefined || v.Type.CanAssignTo(w.Type) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treturn nil, false\n\t\t}\n\n\t\treturn a, true\n\t}\n\n\treturn nil, false\n}\n\nfunc eqTypes(a, b Type) bool { return a.(*ctype).eq(b.(*ctype)) }\n\nfunc isStrLitID(v interface{}) bool {\n\tswitch v.(type) {\n\tcase StringLitID, LongStringLitID:\n\t\treturn true\n\t}\n\n\treturn false\n}\n\nfunc nElem(t Type) int {\n\tp := -1\n\tfor {\n\t\tn := t.Elements()\n\t\tif n < 0 {\n\t\t\treturn p\n\t\t}\n\n\t\tif p < 0 {\n\t\t\tp = 1\n\t\t}\n\t\tp *= n\n\t\tt = t.Element()\n\t}\n}\n\nfunc unsigned(k Kind) Kind {\n\tswitch k {\n\tcase Char, SChar:\n\t\treturn UChar\n\tcase Short:\n\t\treturn UShort\n\tcase Int:\n\t\treturn UInt\n\tcase Long:\n\t\treturn ULong\n\tcase LongLong:\n\t\treturn ULongLong\n\tdefault:\n\t\treturn k\n\t}\n}\n\nfunc isEnum(tn ...*TypeName) bool {\n\tfor _, tn := range tn {\n\t\tt := tn.Type\n\t\tif t.Kind() == Enum {\n\t\t\treturn true\n\t\t}\n\n\t\tts := tn.SpecifierQualifierList.TypeSpecifier\n\t\tif ts == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch ts.Case {\n\t\tcase 15: // \"typeof\" '(' TypeName ')'    // Case 15\n\t\t\tnm := ts.TypeName.SpecifierQualifierList.TypedefName()\n\t\t\tif nm == 0 {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tn := ts.TypeName.scope.Lookup(NSIdentifiers, nm)\n\t\t\tswitch x := n.Node.(type) {\n\t\t\tcase *DirectDeclarator:\n\t\t\t\tif x.specifier.kind() == Enum {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}\n\nfunc memberOffsetRecursive(t Type, name int) (offset int, ty *Type, err error) {\n\tmembers, incomplete := t.Members()\n\tif incomplete {\n\t\treturn 0, nil, fmt.Errorf(\"memberOffsetRecursive: incomplete\")\n\t}\n\tmatches := 0\n\tfor _, member := range members {\n\t\tif member.Name == name {\n\t\t\tmatches++\n\t\t\toffset = member.OffsetOf\n\t\t\tty = &member.Type\n\t\t}\n\t\tif member.Name == 0 {\n\t\t\tmoffset, mty, err := memberOffsetRecursive(member.Type, name)\n\t\t\tif err == nil {\n\t\t\t\tmatches++\n\t\t\t\toffset += member.OffsetOf + moffset\n\t\t\t\tty = mty\n\t\t\t}\n\t\t}\n\t}\n\tif matches > 1 {\n\t\treturn 0, nil, fmt.Errorf(\"memberOffsetRecursive: ambigous member %s\", string(dict.S(name)))\n\t}\n\tif matches == 0 {\n\t\treturn 0, nil, fmt.Errorf(\"memberOffsetRecursive: non-existent member %s\", string(dict.S(name)))\n\t}\n\treturn offset, ty, err\n}\n\nfunc comment(tw *tweaks, p ...Node) int {\n\tfor _, v := range p {\n\t\tv := v.Pos()\n\t\tif n := tw.comments[v]; n != 0 {\n\t\t\treturn n\n\t\t}\n\n\t\tv -= token.Pos(xc.FileSet.Position(v).Column - 1)\n\t\tif n := tw.comments[v]; n != 0 {\n\t\t\treturn n\n\t\t}\n\t}\n\treturn 0\n\n}\n\nfunc fixParams(in []Parameter) {\n\tfor i, v := range in {\n\t\tif t := v.Type; t.Kind() == Function {\n\t\t\tin[i].Type = t.Pointer()\n\t\t}\n\t}\n}\n\nfunc clean(paths []string) (r []string) {\n\tfor _, v := range paths {\n\t\ta, err := filepath.Abs(v)\n\t\tif err != nil {\n\t\t\ta = v\n\t\t}\n\t\tr = append(r, a)\n\t}\n\treturn r\n}\n"
  },
  {
    "path": "generate.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build ignore\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"flag\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n)\n\nfunc yy() (nm string, err error) {\n\ty, err := os.Create(\"parser.y\")\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ty.Close()\n\n\tnm = y.Name()\n\tcmd := exec.Command(\n\t\t\"yy\",\n\t\t\"-astImport\", \"\\\"go/token\\\"\\n\\n\\\"github.com/cznic/xc\\\"\",\n\t\t\"-kind\", \"Case\",\n\t\t\"-o\", nm,\n\t\t\"-prettyString\", \"PrettyString\",\n\t\t\"parser.yy\",\n\t)\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\tos.Remove(nm)\n\t\tlog.Printf(\"%s\", out)\n\n\t\treturn \"\", err\n\t}\n\n\treturn nm, nil\n}\n\nfunc goyacc(y string) (err error) {\n\tt, err := ioutil.TempFile(\"\", \"go-generate-xegen-\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer func() {\n\t\tt.Close()\n\t\tif e := os.Remove(t.Name()); e != nil && err == nil {\n\t\t\terr = e\n\t\t}\n\t}()\n\n\tcmd := exec.Command(\"goyacc\", \"-o\", os.DevNull, \"-xegen\", t.Name(), \"-ex\", y)\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\tlog.Printf(\"%s\\n\", out)\n\t\treturn err\n\t}\n\n\txerrors, err := ioutil.ReadFile(\"xerrors\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := t.Seek(0, 2); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := t.Write(xerrors); err != nil {\n\t\treturn err\n\t}\n\n\tcmd = exec.Command(\"goyacc\", \"-cr\", \"-xe\", t.Name(), \"-o\", \"parser.go\", \"-dlvalf\", \"%v\", \"-dlval\", \"PrettyString(lval.Token)\", y)\n\tif out, err := cmd.CombinedOutput(); err != nil {\n\t\tlog.Printf(\"%s\", out)\n\t\treturn err\n\t} else {\n\t\tlog.Printf(\"%s\", out)\n\t}\n\n\treturn nil\n}\n\nfunc main() {\n\tif err := main0(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc main0() (err error) {\n\tlog.SetFlags(log.Lshortfile)\n\tp2 := flag.Bool(\"2\", false, \"\")\n\tflag.Parse()\n\tif *p2 {\n\t\treturn main2()\n\t}\n\n\tos.Remove(\"ast.go\")\n\tos.Remove(\"ast_test.go\")\n\ty, err := yy()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn goyacc(y)\n}\n\nfunc main2() (err error) {\n\tgoCmd := exec.Command(\"go\", \"test\", \"-generating\", \"-run\", \"^Example\")\n\tout, err := goCmd.CombinedOutput() // Errors are expected and wanted here.\n\tfeCmd := exec.Command(\"fe\")\n\tfeCmd.Stdin = bytes.NewBuffer(out)\n\tif out, err = feCmd.CombinedOutput(); err != nil {\n\t\tlog.Printf(\"%s\", out)\n\t\treturn err\n\t}\n\n\tmatches, err := filepath.Glob(\"*_test.go\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd := exec.Command(\"pcregrep\", append([]string{\"-nM\", `failed|panic|\\/\\/ <nil>|// false|// -1|Output:\\n}`}, matches...)...)\n\tif out, _ = cmd.CombinedOutput(); len(out) != 0 { // Error != nil when no matches\n\t\tlog.Printf(\"%s\", out)\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "global.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nconst (\n\tcommentNotClosed = \"comment not closed\"\n)\n\nvar (\n\tdebugIncludes bool\n\tdebugMacros   bool\n\tdict          = xc.Dict\n\tfset          = xc.FileSet\n\tisGenerating  bool // go generate hook.\n\tisTesting     bool // Test hook.\n\tprintHooks    = strutil.PrettyPrintHooks{}\n)\n\nfunc init() {\n\tfor k, v := range xc.PrintHooks {\n\t\tprintHooks[k] = v\n\t}\n\tlcRT := reflect.TypeOf(lex.Char{})\n\tlcH := func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tc := v.(lex.Char)\n\t\tr := c.Rune\n\t\ts := yySymName(int(r))\n\t\tif x := s[0]; x >= '0' && x <= '9' {\n\t\t\ts = strconv.QuoteRune(r)\n\t\t}\n\t\tf.Format(\"%s%v: %s\"+suffix, prefix, fset.Position(c.Pos()), s)\n\t}\n\n\tprintHooks[lcRT] = lcH\n\tprintHooks[reflect.TypeOf(xc.Token{})] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tt := v.(xc.Token)\n\t\tif (t == xc.Token{}) {\n\t\t\treturn\n\t\t}\n\n\t\tlcH(f, t.Char, prefix, \"\")\n\t\tif s := t.S(); len(s) != 0 {\n\t\t\tf.Format(\" %q\", s)\n\t\t}\n\t\tf.Format(suffix)\n\t}\n\n\tprintHooks[reflect.TypeOf(PPTokenList(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tx := v.(PPTokenList)\n\t\tif x == 0 {\n\t\t\treturn\n\t\t}\n\n\t\ta := strings.Split(prefix+PrettyString(decodeTokens(x, nil, true))+\",\", \"\\n\")\n\t\tfor _, v := range a {\n\t\t\tf.Format(\"%s\\n\", v)\n\t\t}\n\n\t}\n\n\tprintHooks[reflect.TypeOf((*ctype)(nil))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tf.Format(prefix)\n\t\tf.Format(\"%v\", v.(Type).String())\n\t\tf.Format(suffix)\n\t}\n\n\tprintHooks[reflect.TypeOf(Kind(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tf.Format(prefix)\n\t\tf.Format(\"%v\", v.(Kind))\n\t\tf.Format(suffix)\n\t}\n\n\tprintHooks[reflect.TypeOf(Linkage(0))] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tf.Format(prefix)\n\t\tf.Format(\"%v\", v.(Linkage))\n\t\tf.Format(suffix)\n\t}\n}\n"
  },
  {
    "path": "kind_string.go",
    "content": "// Code generated by \"stringer -type Kind\"; DO NOT EDIT.\n\npackage cc\n\nimport \"fmt\"\n\nconst _Kind_name = \"UndefinedVoidPtrUintPtrCharSCharUCharShortUShortIntUIntLongULongLongLongULongLongFloatDoubleLongDoubleBoolFloatComplexDoubleComplexLongDoubleComplexStructUnionEnumTypedefNameFunctionArraytypeofkindMax\"\n\nvar _Kind_index = [...]uint8{0, 9, 13, 16, 23, 27, 32, 37, 42, 48, 51, 55, 59, 64, 72, 81, 86, 92, 102, 106, 118, 131, 148, 154, 159, 163, 174, 182, 187, 193, 200}\n\nfunc (i Kind) String() string {\n\tif i < 0 || i >= Kind(len(_Kind_index)-1) {\n\t\treturn fmt.Sprintf(\"Kind(%d)\", i)\n\t}\n\treturn _Kind_name[_Kind_index[i]:_Kind_index[i+1]]\n}\n"
  },
  {
    "path": "lexer.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"io\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/xc\"\n)\n\n// Lexer state\nconst (\n\tlsZero             = iota\n\tlsBOL              // Preprocessor: Beginning of line.\n\tlsDefine           // Preprocessor: Seen ^#define.\n\tlsSeekRParen       // Preprocessor: Seen ^#define identifier(\n\tlsTokens           // Preprocessor: Convert anything to PPOTHER until EOL.\n\tlsUndef            // Preprocessor: Seen ^#undef.\n\tlsConstExpr0       // Preprocessor: Parsing constant expression.\n\tlsConstExpr        // Preprocessor: Parsing constant expression.\n\tlsTranslationUnit0 //\n\tlsTranslationUnit  //\n)\n\ntype trigraphsReader struct {\n\t*lex.Lexer           //\n\tpos0       token.Pos //\n\tsc         int       // Start condition.\n}\n\nfunc (t *trigraphsReader) ReadRune() (rune, int, error) { return lex.RuneEOF, 0, io.EOF }\n\nfunc (t *trigraphsReader) ReadChar() (c lex.Char, size int, err error) {\n\tr := rune(t.scan())\n\tpos0 := t.pos0\n\tpos := t.Lookahead().Pos()\n\tt.pos0 = pos\n\tc = lex.NewChar(t.First.Pos(), r)\n\treturn c, int(pos - pos0), nil\n}\n\ntype byteReader struct {\n\tio.Reader\n\tb [1]byte\n}\n\nfunc (b *byteReader) ReadRune() (r rune, size int, err error) {\n\tif _, err = b.Read(b.b[:]); err != nil {\n\t\treturn -1, 0, err\n\t}\n\n\treturn rune(b.b[0]), 1, nil\n}\n\ntype lexer struct {\n\t*lex.Lexer                             //\n\tch                 chan []xc.Token     //\n\tcommentPos0        token.Pos           //\n\tconstExprToks      []xc.Token          //\n\tconstantExpression *ConstantExpression //\n\tcpp                func([]xc.Token)    //\n\tencBuf             []byte              // PPTokens\n\tencBuf1            [30]byte            // Rune, position, optional value ID.\n\tencPos             token.Pos           // For delta pos encoding\n\teof                lex.Char            //\n\texample            interface{}         //\n\texampleRule        int                 //\n\texterns            map[int]*Declarator //\n\tfile               *token.File         //\n\tfinalNLInjected    bool                //\n\tfnDeclarator       *Declarator         //\n\tincludePaths       []string            //\n\tinjectFunc         []xc.Token          // [0], 6.4.2.2.\n\tiota               int64               //\n\tisPreprocessing    bool                //\n\tlast               xc.Token            //\n\tmodel              *Model              //\n\tpreprocessingFile  *PreprocessingFile  //\n\treport             *xc.Report          //\n\tsc                 int                 // Start condition.\n\tscope              *Bindings           //\n\tscs                int                 // Start condition stack.\n\tstate              int                 // Lexer state.\n\tsysIncludePaths    []string            //\n\tt                  *trigraphsReader    //\n\ttextLine           []xc.Token          //\n\ttoC                bool                // Whether to translate preprocessor identifiers to reserved C words.\n\ttokLast            xc.Token            //\n\ttokPrev            xc.Token            //\n\ttoks               []xc.Token          // Parsing preprocessor constant expression.\n\ttranslationUnit    *TranslationUnit    //\n\ttweaks             *tweaks             //\n\n\tfsm struct {\n\t\tcomment int\n\t\tpos     token.Pos\n\t\tstate   int\n\t}\n}\n\nfunc newLexer(nm string, sz int, r io.RuneReader, report *xc.Report, tweaks *tweaks, opts ...lex.Option) (*lexer, error) {\n\tfile := fset.AddFile(nm, -1, sz)\n\tt := &trigraphsReader{}\n\tlx, err := lex.New(\n\t\tfile,\n\t\t&byteReader{Reader: r.(io.Reader)},\n\t\tlex.ErrorFunc(func(pos token.Pos, msg string) {\n\t\t\treport.Err(pos, msg)\n\t\t}),\n\t\tlex.RuneClass(func(r rune) int { return int(r) }),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tt.Lexer = lx\n\tt.pos0 = lx.Lookahead().Pos()\n\tif tweaks.enableTrigraphs {\n\t\tt.sc = scTRIGRAPHS\n\t}\n\tr = t\n\n\tscope := newBindings(nil, ScopeFile)\n\tlexer := &lexer{\n\t\texterns: map[int]*Declarator{},\n\t\tfile:    file,\n\t\treport:  report,\n\t\tscope:   scope,\n\t\tscs:     -1, // Stack empty\n\t\tt:       t,\n\t\ttweaks:  tweaks,\n\t}\n\tif lexer.Lexer, err = lex.New(\n\t\tfile,\n\t\tr,\n\t\tappend(opts, lex.RuneClass(rune2class))...,\n\t); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn lexer, nil\n}\n\nfunc newSimpleLexer(cpp func([]xc.Token), report *xc.Report, tweaks *tweaks) *lexer {\n\treturn &lexer{\n\t\tcpp:     cpp,\n\t\texterns: map[int]*Declarator{},\n\t\treport:  report,\n\t\tscope:   newBindings(nil, ScopeFile),\n\t\ttweaks:  tweaks,\n\t}\n}\n\nfunc (l *lexer) push(sc int) {\n\tif l.scs >= 0 { // Stack overflow.\n\t\tif l.sc != scDIRECTIVE || sc != scCOMMENT {\n\t\t\tpanic(\"internal error\")\n\t\t}\n\n\t\t// /*-style comment in a line starting with #\n\t\tl.pop()\n\t}\n\n\tl.scs = l.sc\n\tl.sc = sc\n}\n\nfunc (l *lexer) pop() {\n\tif l.scs < 0 { // Stack underflow\n\t\tpanic(\"internal error\")\n\t}\n\tl.sc = l.scs\n\tl.scs = -1 // Stack empty.\n}\n\nfunc (l *lexer) pushScope(kind Scope) (old *Bindings) {\n\told = l.scope\n\tl.scope = newBindings(old, kind)\n\tl.scope.maxAlign = 1\n\treturn old\n}\n\nfunc (l *lexer) popScope(tok xc.Token) (old, new *Bindings) {\n\treturn l.popScopePos(tok.Pos())\n}\n\nfunc (l *lexer) popScopePos(pos token.Pos) (old, new *Bindings) {\n\told = l.scope\n\tnew = l.scope.Parent\n\tif new == nil {\n\t\tl.report.Err(pos, \"cannot pop scope\")\n\t\treturn nil, old\n\t}\n\n\tl.scope = new\n\treturn old, new\n}\n\nconst (\n\tfsmZero = iota\n\tfsmHasComment\n)\n\nvar genCommentLeader = []byte(\"/*\")\n\nfunc (l *lexer) comment(general bool) {\n\tif l.tweaks.comments != nil {\n\t\tb := l.TokenBytes(nil)\n\t\tpos := l.First.Pos()\n\t\tif general {\n\t\t\tpos = l.commentPos0\n\t\t\tb = append(genCommentLeader, b...)\n\t\t}\n\t\tif l.Lookahead().Rune == '\\n' {\n\t\t\tb = append(b, '\\n')\n\t\t}\n\n\t\tswitch fsm := &l.fsm; fsm.state {\n\t\tcase fsmHasComment:\n\t\t\tif pos == fsm.pos+token.Pos(len(dict.S(l.fsm.comment))) {\n\t\t\t\tfsm.comment = dict.ID(append(dict.S(fsm.comment), b...))\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfallthrough\n\t\tcase fsmZero:\n\t\t\tfsm.state = fsmHasComment\n\t\t\tfsm.comment = dict.ID(b)\n\t\t\tfsm.pos = pos\n\t\t}\n\t}\n}\n\nfunc (l *lexer) scanChar() (c lex.Char) {\nagain:\n\tr := rune(l.scan())\n\tswitch r {\n\tcase ' ':\n\t\tif l.state != lsTokens || l.tokLast.Rune == ' ' {\n\t\t\tgoto again\n\t\t}\n\tcase '\\n':\n\t\tif l.state == lsTokens {\n\t\t\tl.encodeToken(xc.Token{Char: lex.NewChar(l.First.Pos(), ' '), Val: idSpace})\n\t\t}\n\t\tl.state = lsBOL\n\t\tl.sc = scINITIAL\n\t\tl.scs = -1 // Stack empty\n\tcase PREPROCESSING_FILE:\n\t\tl.state = lsBOL\n\t\tl.isPreprocessing = true\n\tcase CONSTANT_EXPRESSION, TRANSLATION_UNIT: //TODO- CONSTANT_EXPRESSION, then must add some manual yy:examples.\n\t\tl.toC = true\n\t}\n\n\tfp := l.First.Pos()\n\tif l.fsm.state == fsmHasComment {\n\t\tswitch {\n\t\tcase r == '\\n' && fp == l.fsm.pos+token.Pos(len(dict.S(l.fsm.comment)))-1:\n\t\t\t// keep going\n\t\tcase r != '\\n' && fp == l.fsm.pos+token.Pos(len(dict.S(l.fsm.comment))):\n\t\t\tl.tweaks.comments[fp] = dict.ID(bytes.TrimSpace(dict.S(l.fsm.comment)))\n\t\t\tl.fsm.state = fsmZero\n\t\tdefault:\n\t\t\tl.fsm.state = fsmZero\n\t\t}\n\t}\n\n\treturn lex.NewChar(l.First.Pos(), r)\n}\n\nfunc (l *lexer) scanToken() (tok xc.Token) {\n\tswitch l.state {\n\tcase lsConstExpr0:\n\t\ttok = xc.Token{Char: lex.NewChar(0, CONSTANT_EXPRESSION)}\n\t\tl.state = lsConstExpr\n\tcase lsConstExpr:\n\t\tif len(l.toks) == 0 {\n\t\t\ttok = xc.Token{Char: lex.NewChar(l.tokLast.Pos(), lex.RuneEOF)}\n\t\t\tbreak\n\t\t}\n\n\t\ttok = l.toks[0]\n\t\tl.toks = l.toks[1:]\n\tcase lsTranslationUnit0:\n\t\ttok = xc.Token{Char: lex.NewChar(0, TRANSLATION_UNIT)}\n\t\tl.state = lsTranslationUnit\n\t\tl.toC = true\n\tcase lsTranslationUnit:\n\tagain:\n\t\tfor len(l.textLine) == 0 {\n\t\t\tvar ok bool\n\t\t\tif l.textLine, ok = <-l.ch; !ok {\n\t\t\t\treturn xc.Token{Char: lex.NewChar(l.tokLast.Pos(), lex.RuneEOF)}\n\t\t\t}\n\n\t\t\tif l.cpp != nil {\n\t\t\t\tl.cpp(l.textLine)\n\t\t\t}\n\t\t}\n\t\ttok = l.textLine[0]\n\t\tl.textLine = l.textLine[1:]\n\t\tif tok.Rune == ' ' {\n\t\t\tgoto again\n\t\t}\n\n\t\ttok = l.scope.lexerHack(tok, l.tokLast)\n\tdefault:\n\t\tc := l.scanChar()\n\t\tif c.Rune == ccEOF {\n\t\t\tc = lex.NewChar(c.Pos(), lex.RuneEOF)\n\t\t\tif l.isPreprocessing && l.last.Rune != '\\n' && !l.finalNLInjected {\n\t\t\t\tl.finalNLInjected = true\n\t\t\t\tl.eof = c\n\t\t\t\tc.Rune = '\\n'\n\t\t\t\tl.state = lsBOL\n\t\t\t\treturn xc.Token{Char: c}\n\t\t\t}\n\n\t\t\treturn xc.Token{Char: c}\n\t\t}\n\n\t\tval := 0\n\t\tif tokHasVal[c.Rune] {\n\t\t\tb := l.TokenBytes(nil)\n\t\t\tval = dict.ID(b)\n\t\t\t//TODO handle ID UCNs\n\t\t\t//TODO- chars := l.Token()\n\t\t\t//TODO- switch c.Rune {\n\t\t\t//TODO- case IDENTIFIER, IDENTIFIER_LPAREN:\n\t\t\t//TODO- \tb := l.TokenBytes(func(buf *bytes.Buffer) {\n\t\t\t//TODO- \t\tfor i := 0; i < len(chars); {\n\t\t\t//TODO- \t\t\tswitch c := chars[i]; {\n\t\t\t//TODO- \t\t\tcase c.Rune == '$' && !l.tweaks.enableDlrInIdentifiers:\n\t\t\t//TODO- \t\t\t\tl.report.Err(c.Pos(), \"identifier character set extension '$' not enabled\")\n\t\t\t//TODO- \t\t\t\ti++\n\t\t\t//TODO- \t\t\tcase c.Rune == '\\\\':\n\t\t\t//TODO- \t\t\t\tr, n := decodeUCN(chars[i:])\n\t\t\t//TODO- \t\t\t\tbuf.WriteRune(r)\n\t\t\t//TODO- \t\t\t\ti += n\n\t\t\t//TODO- \t\t\tcase c.Rune < 0x80: // ASCII\n\t\t\t//TODO- \t\t\t\tbuf.WriteByte(byte(c.Rune))\n\t\t\t//TODO- \t\t\t\ti++\n\t\t\t//TODO- \t\t\tdefault:\n\t\t\t//TODO- \t\t\t\tpanic(\"internal error\")\n\t\t\t//TODO- \t\t\t}\n\t\t\t//TODO- \t\t}\n\t\t\t//TODO- \t})\n\t\t\t//TODO- \tval = dict.ID(b)\n\t\t\t//TODO- default:\n\t\t\t//TODO- \tpanic(\"internal error: \" + yySymName(int(c.Rune)))\n\t\t\t//TODO- }\n\t\t}\n\t\ttok = xc.Token{Char: c, Val: val}\n\t\tif !l.isPreprocessing {\n\t\t\ttok = l.scope.lexerHack(tok, l.tokLast)\n\t\t}\n\t}\n\tif l.toC {\n\t\ttok = toC(tok, l.tweaks)\n\t}\n\tl.tokPrev = l.tokLast\n\tl.tokLast = tok\n\treturn tok\n}\n\n// Lex implements yyLexer\nfunc (l *lexer) Lex(lval *yySymType) int {\n\tvar tok xc.Token\n\tif x := l.injectFunc; l.exampleRule == 0 && len(x) != 0 {\n\t\ttok = x[0]\n\t\tl.injectFunc = x[1:]\n\t} else {\n\t\ttok = l.scanToken()\n\t}\n\t//dbg(\"Lex %s\", PrettyString(tok))\n\tif l.constExprToks != nil {\n\t\tl.constExprToks = append(l.constExprToks, tok)\n\t}\n\tl.last = tok\n\tif tok.Rune == lex.RuneEOF {\n\t\tlval.Token = tok\n\t\treturn 0\n\t}\n\n\tswitch l.state {\n\tcase lsBOL:\n\t\tswitch tok.Rune {\n\t\tcase PREPROCESSING_FILE, '\\n':\n\t\t\t// nop\n\t\tcase '#':\n\t\t\tl.push(scDIRECTIVE)\n\t\t\ttok = l.scanToken()\n\t\t\tswitch tok.Rune {\n\t\t\tcase '\\n':\n\t\t\t\ttok.Char = lex.NewChar(tok.Pos(), PPHASH_NL)\n\t\t\tcase PPDEFINE:\n\t\t\t\tl.push(scDEFINE)\n\t\t\t\tl.state = lsDefine\n\t\t\tcase PPELIF, PPENDIF, PPERROR, PPIF, PPLINE, PPPRAGMA:\n\t\t\t\tl.sc = scINITIAL\n\t\t\t\tl.state = lsTokens\n\t\t\tcase PPELSE, PPIFDEF, PPIFNDEF:\n\t\t\t\tl.state = lsZero\n\t\t\tcase PPUNDEF:\n\t\t\t\tl.state = lsUndef\n\t\t\tcase PPINCLUDE:\n\t\t\t\tl.sc = scHEADER\n\t\t\t\tl.state = lsTokens\n\t\t\tcase PPINCLUDE_NEXT:\n\t\t\t\tif l.tweaks.enableIncludeNext {\n\t\t\t\t\tl.sc = scHEADER\n\t\t\t\t\tl.state = lsTokens\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tl.state = lsTokens\n\t\t\t\ttok.Char = lex.NewChar(tok.Pos(), PPNONDIRECTIVE)\n\t\t\t\ttok.Val = xc.Dict.SID(\"include_next\")\n\t\t\tdefault:\n\t\t\t\tl.state = lsTokens\n\t\t\t\ttok.Char = lex.NewChar(tok.Pos(), PPNONDIRECTIVE)\n\t\t\t\tl.pop()\n\t\t\t}\n\t\tdefault:\n\t\t\tl.encodeToken(tok)\n\t\t\ttok.Char = lex.NewChar(tok.Pos(), PPOTHER)\n\t\t\tl.state = lsTokens\n\t\t}\n\tcase lsDefine:\n\t\tl.pop()\n\t\tswitch tok.Rune {\n\t\tcase IDENTIFIER:\n\t\t\tl.state = lsTokens\n\t\tcase IDENTIFIER_LPAREN:\n\t\t\tl.state = lsSeekRParen\n\t\tdefault:\n\t\t\tl.state = lsZero\n\t\t}\n\tcase lsSeekRParen:\n\t\tif tok.Rune == ')' {\n\t\t\tl.state = lsTokens\n\t\t}\n\tcase lsTokens:\n\t\tl.encodeToken(tok)\n\t\ttok.Char = lex.NewChar(tok.Pos(), PPOTHER)\n\tcase lsUndef:\n\t\tl.state = lsTokens\n\t}\n\n\tlval.Token = tok\n\treturn int(tok.Char.Rune)\n}\n\n// Error Implements yyLexer.\nfunc (l *lexer) Error(msg string) {\n\tmsg = strings.Replace(msg, \"$end\", \"EOF\", -1)\n\tt := l.last\n\tparts := strings.Split(msg, \", expected \")\n\tif len(parts) == 2 && strings.HasPrefix(parts[0], \"unexpected \") && tokHasVal[t.Rune] {\n\t\tmsg = fmt.Sprintf(\"%s %s, expected %s\", parts[0], t.S(), parts[1])\n\t}\n\tl.report.ErrTok(t, \"%s\", msg)\n}\n\n// Reduced implements yyLexerEx\nfunc (l *lexer) Reduced(rule, state int, lval *yySymType) (stop bool) {\n\tif n := l.exampleRule; n >= 0 && rule != n {\n\t\treturn false\n\t}\n\n\tswitch x := lval.node.(type) {\n\tcase interface {\n\t\tfragment() interface{}\n\t}:\n\t\tl.example = x.fragment()\n\tdefault:\n\t\tl.example = x\n\t}\n\treturn true\n}\n\nfunc (l *lexer) parsePPConstExpr0(list PPTokenList, p *pp) (interface{}, Type) {\n\tl.toks = l.toks[:0]\n\tp.expand(&tokenBuf{decodeTokens(list, nil, true)}, true, func(toks []xc.Token) {\n\t\tl.toks = append(l.toks, toks...)\n\t})\n\tw := 0\n\tfor _, tok := range l.toks {\n\t\tswitch tok.Rune {\n\t\tcase ' ':\n\t\t\t// nop\n\t\tcase IDENTIFIER:\n\t\t\tif p.macros.m[tok.Val] != nil {\n\t\t\t\tl.report.ErrTok(tok, \"expected constant expression\")\n\t\t\t\treturn nil, nil\n\t\t\t}\n\n\t\t\ttok.Rune = INTCONST\n\t\t\ttok.Val = id0\n\t\t\tfallthrough\n\t\tdefault:\n\t\t\tl.toks[w] = tok\n\t\t\tw++\n\t\t}\n\t}\n\tl.toks = l.toks[:w]\n\tl.state = lsConstExpr0\n\tif yyParse(l) == 0 {\n\t\te := l.constantExpression\n\t\treturn e.Value, e.Type\n\t}\n\n\treturn nil, nil\n}\n\nfunc (l *lexer) parsePPConstExpr(list PPTokenList, p *pp) bool {\n\tif v, _ := l.parsePPConstExpr0(list, p); v != nil {\n\t\treturn isNonZero(v)\n\t}\n\n\treturn false\n}\n"
  },
  {
    "path": "linkage_string.go",
    "content": "// Code generated by \"stringer -type Linkage\"; DO NOT EDIT.\n\npackage cc\n\nimport \"fmt\"\n\nconst _Linkage_name = \"NoneInternalExternal\"\n\nvar _Linkage_index = [...]uint8{0, 4, 12, 20}\n\nfunc (i Linkage) String() string {\n\tif i < 0 || i >= Linkage(len(_Linkage_index)-1) {\n\t\treturn fmt.Sprintf(\"Linkage(%d)\", i)\n\t}\n\treturn _Linkage_name[_Linkage_index[i]:_Linkage_index[i+1]]\n}\n"
  },
  {
    "path": "model.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"math\"\n\t\"math/big\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\ntype (\n\t// StringLitID is the type of an Expression.Value representing the numeric\n\t// ID of a string literal.\n\tStringLitID int\n\n\t// LongStringLitID is the type of an Expression.Value representing the\n\t// numeric ID of a long string literal.\n\tLongStringLitID int\n\n\t// StringLitID is the type of an Expression.Value representing the numeric\n\t// ID of a label name used in &&label.\n\tComputedGotoID int\n)\n\nvar (\n\tmaxConvF32I32 = math.Nextafter32(math.MaxInt32, 0) // https://github.com/golang/go/issues/19405\n\tmaxConvF32U32 = math.Nextafter32(math.MaxUint32, 0)\n)\n\n// ModelItem is a single item of a model.\n//\n// Note about StructAlign: To provide GCC ABI compatibility set, for example,\n// Align of Double to 8 and StructAlign of Double to 4.\ntype ModelItem struct {\n\tSize        int         // Size of the entity in bytes.\n\tAlign       int         // Alignment of the entity when it's not a struct field.\n\tStructAlign int         // Alignment of the entity when it's a struct field.\n\tMore        interface{} // Optional user data.\n}\n\n// Model describes size and align requirements of predeclared types.\ntype Model struct {\n\tItems map[Kind]ModelItem\n\n\tBoolType              Type\n\tCharType              Type\n\tDoubleComplexType     Type\n\tDoubleType            Type\n\tFloatComplexType      Type\n\tFloatType             Type\n\tIntType               Type\n\tLongDoubleComplexType Type\n\tLongDoubleType        Type\n\tLongLongType          Type\n\tLongType              Type\n\tShortType             Type\n\tUCharType             Type\n\tUIntType              Type\n\tULongLongType         Type\n\tULongType             Type\n\tUShortType            Type\n\tUintPtrType           Type\n\tVoidType              Type\n\tlongStrType           Type\n\tptrDiffType           Type\n\tsizeType              Type\n\tstrType               Type\n\n\tinitialized bool\n\ttweaks      *tweaks\n\tintConvRank [kindMax]int\n\tSigned      [kindMax]bool // Signed[Kind] reports whether Kind is a signed integer type.\n\tpromoteTo   [kindMax]Kind\n}\n\nfunc (m *Model) initialize(lx *lexer) {\n\tm.BoolType = m.makeType(lx, 0, tsBool)\n\tm.CharType = m.makeType(lx, 0, tsChar)\n\tm.DoubleComplexType = m.makeType(lx, 0, tsComplex, tsDouble)\n\tm.DoubleType = m.makeType(lx, 0, tsDouble)\n\tm.FloatComplexType = m.makeType(lx, 0, tsComplex, tsFloat)\n\tm.FloatType = m.makeType(lx, 0, tsFloat)\n\tm.IntType = m.makeType(lx, 0, tsInt)\n\tm.LongDoubleComplexType = m.makeType(lx, 0, tsComplex, tsDouble, tsLong)\n\tm.LongDoubleType = m.makeType(lx, 0, tsLong, tsDouble)\n\tm.LongLongType = m.makeType(lx, 0, tsLong, tsLong)\n\tm.LongType = m.makeType(lx, 0, tsLong)\n\tm.ShortType = m.makeType(lx, 0, tsShort)\n\tm.UCharType = m.makeType(lx, 0, tsUnsigned, tsChar)\n\tm.UIntType = m.makeType(lx, 0, tsUnsigned)\n\tm.ULongLongType = m.makeType(lx, 0, tsUnsigned, tsLong, tsLong)\n\tm.ULongType = m.makeType(lx, 0, tsUnsigned, tsLong)\n\tm.UShortType = m.makeType(lx, 0, tsUnsigned, tsShort)\n\tm.UintPtrType = m.makeType(lx, 0, tsUintptr) // Pseudo type.\n\tm.VoidType = m.makeType(lx, 0, tsVoid)\n\tm.strType = m.makeType(lx, 0, tsChar).Pointer()\n\n\t// [0], 6.3.1.1.\n\tm.intConvRank = [kindMax]int{\n\t\tBool:      1,\n\t\tChar:      2,\n\t\tSChar:     2,\n\t\tUChar:     2,\n\t\tShort:     3,\n\t\tUShort:    3,\n\t\tInt:       4,\n\t\tUInt:      4,\n\t\tLong:      5,\n\t\tULong:     5,\n\t\tLongLong:  6,\n\t\tULongLong: 6,\n\t\tUintPtr:   7,\n\t}\n\tm.Signed = [kindMax]bool{\n\t\tChar:     true,\n\t\tSChar:    true,\n\t\tShort:    true,\n\t\tInt:      true,\n\t\tLong:     true,\n\t\tLongLong: true,\n\t}\n\tm.promoteTo = [kindMax]Kind{}\n\tfor i := range m.promoteTo {\n\t\tm.promoteTo[i] = Kind(i)\n\t}\n\tswitch {\n\tcase m.tweaks.enableWideEnumValues:\n\t\tm.intConvRank[Enum] = m.intConvRank[LongLong]\n\tdefault:\n\t\tm.intConvRank[Enum] = m.intConvRank[Int]\n\t}\n\tfor k := Kind(0); k < kindMax; k++ {\n\t\tr := m.intConvRank[k]\n\t\tif r == 0 || r > m.intConvRank[Int] {\n\t\t\tcontinue\n\t\t}\n\n\t\t// k is an integer type whose conversion rank is less than or\n\t\t// equal to the rank of int and unsigned int.\n\t\tswitch {\n\t\tcase m.Items[k].Size < m.Items[Int].Size || m.Signed[k]:\n\t\t\t// If an int can represent all values of the original\n\t\t\t// type, the value is converted to an int;\n\t\t\tm.promoteTo[k] = Int\n\t\tdefault:\n\t\t\t// otherwise, it is converted to an unsigned int.\n\t\t\tm.promoteTo[k] = UInt\n\t\t}\n\t}\n\n\tm.initialized = true\n}\n\nfunc (m *Model) typ(k Kind) Type {\n\tswitch k {\n\tcase Undefined:\n\t\treturn undefined\n\tcase Bool:\n\t\treturn m.BoolType\n\tcase Char:\n\t\treturn m.CharType\n\tcase Double:\n\t\treturn m.DoubleType\n\tcase Float:\n\t\treturn m.FloatType\n\tcase Int:\n\t\treturn m.IntType\n\tcase LongDouble:\n\t\treturn m.LongDoubleType\n\tcase LongLong:\n\t\treturn m.LongLongType\n\tcase Long:\n\t\treturn m.LongType\n\tcase Short:\n\t\treturn m.ShortType\n\tcase UChar:\n\t\treturn m.UCharType\n\tcase UInt:\n\t\treturn m.UIntType\n\tcase ULongLong:\n\t\treturn m.ULongLongType\n\tcase ULong:\n\t\treturn m.ULongType\n\tcase UShort:\n\t\treturn m.UShortType\n\tcase UintPtr:\n\t\treturn m.UintPtrType\n\tcase FloatComplex:\n\t\treturn m.FloatComplexType\n\tcase DoubleComplex:\n\t\treturn m.DoubleComplexType\n\tcase LongDoubleComplex:\n\t\treturn m.LongDoubleComplexType\n\tdefault:\n\t\tpanic(k)\n\t}\n}\n\nfunc (m *Model) enumValueToInt(v interface{}) (interface{}, bool) {\n\tintSize := m.Items[Int].Size\n\tif m.tweaks.enableWideEnumValues {\n\t\tintSize = m.Items[LongLong].Size\n\t}\n\tswitch x := v.(type) {\n\tcase byte, int8, int16, uint16, int32:\n\t\treturn m.MustConvert(x, m.IntType), true\n\tcase uint32:\n\t\tswitch intSize {\n\t\tcase 4:\n\t\t\treturn m.MustConvert(x, m.IntType), x <= math.MaxUint32\n\t\tcase 8:\n\t\t\treturn m.MustConvert(x, m.IntType), true\n\t\tdefault:\n\t\t\tpanic(intSize)\n\t\t}\n\tcase int64:\n\t\tswitch intSize {\n\t\tcase 4:\n\t\t\treturn m.MustConvert(x, m.IntType), x <= math.MaxUint32\n\t\tcase 8:\n\t\t\treturn m.MustConvert(x, m.IntType), true\n\t\tdefault:\n\t\t\tpanic(intSize)\n\t\t}\n\tcase uint64:\n\t\tswitch intSize {\n\t\tcase 4:\n\t\t\treturn m.MustConvert(x, m.IntType), x <= math.MaxUint32\n\t\tcase 8:\n\t\t\treturn m.MustConvert(x, m.IntType), x <= math.MaxUint64\n\t\tdefault:\n\t\t\tpanic(intSize)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// sanityCheck reports model errors, if any.\nfunc (m *Model) sanityCheck() error {\n\tif len(m.Items) == 0 {\n\t\treturn fmt.Errorf(\"model has no items\")\n\t}\n\n\ttab := map[Kind]struct {\n\t\tminSize, maxSize   int\n\t\tminAlign, maxAlign int\n\t}{\n\t\tPtr:               {4, 8, 4, 8},\n\t\tUintPtr:           {4, 8, 4, 8},\n\t\tVoid:              {0, 0, 1, 1},\n\t\tChar:              {1, 1, 1, 1},\n\t\tSChar:             {1, 1, 1, 1},\n\t\tUChar:             {1, 1, 1, 1},\n\t\tShort:             {2, 2, 2, 2},\n\t\tUShort:            {2, 2, 2, 2},\n\t\tInt:               {4, 4, 4, 4},\n\t\tUInt:              {4, 4, 4, 4},\n\t\tLong:              {4, 8, 4, 8},\n\t\tULong:             {4, 8, 4, 8},\n\t\tLongLong:          {8, 8, 8, 8},\n\t\tULongLong:         {8, 8, 8, 8},\n\t\tFloat:             {4, 4, 4, 4},\n\t\tDouble:            {8, 8, 8, 8},\n\t\tLongDouble:        {8, 16, 8, 16},\n\t\tBool:              {1, 1, 1, 1},\n\t\tFloatComplex:      {8, 8, 8, 8},\n\t\tDoubleComplex:     {16, 16, 8, 16},\n\t\tLongDoubleComplex: {16, 32, 8, 16},\n\t}\n\ta := []int{}\n\trequired := map[Kind]bool{}\n\tseen := map[Kind]bool{}\n\tfor k := range tab {\n\t\trequired[k] = true\n\t\ta = append(a, int(k))\n\t}\n\tsort.Ints(a)\n\tfor k, v := range m.Items {\n\t\tif seen[k] {\n\t\t\treturn fmt.Errorf(\"model has duplicate item: %s\", k)\n\t\t}\n\n\t\tseen[k] = true\n\t\tif !required[k] {\n\t\t\treturn fmt.Errorf(\"model has invalid type: %s: %#v\", k, v)\n\t\t}\n\n\t\tfor typ, t := range tab {\n\t\t\tif typ == k {\n\t\t\t\tif v.Size < t.minSize {\n\t\t\t\t\treturn fmt.Errorf(\"size %d too small: %s\", v.Size, k)\n\t\t\t\t}\n\n\t\t\t\tif v.Size > t.maxSize {\n\t\t\t\t\treturn fmt.Errorf(\"size %d too big: %s\", v.Size, k)\n\t\t\t\t}\n\n\t\t\t\tif v.Size != 0 && mathutil.PopCount(v.Size) != 1 {\n\t\t\t\t\treturn fmt.Errorf(\"size %d is not a power of two: %s\", v.Size, k)\n\t\t\t\t}\n\n\t\t\t\tif v.Align < t.minAlign {\n\t\t\t\t\treturn fmt.Errorf(\"align %d too small: %s\", v.Align, k)\n\t\t\t\t}\n\n\t\t\t\tif v.Align > t.maxAlign {\n\t\t\t\t\treturn fmt.Errorf(\"align %d too big: %s\", v.Align, k)\n\t\t\t\t}\n\n\t\t\t\tif v.Align < v.Size && v.Align < t.minAlign {\n\t\t\t\t\treturn fmt.Errorf(\"align is smaller than size: %s\", k)\n\t\t\t\t}\n\n\t\t\t\tif v.StructAlign < 1 {\n\t\t\t\t\treturn fmt.Errorf(\"struct align %d too small: %s\", v.StructAlign, k)\n\t\t\t\t}\n\n\t\t\t\tif v.StructAlign > t.maxAlign {\n\t\t\t\t\treturn fmt.Errorf(\"struct align %d too big: %s\", v.Align, k)\n\t\t\t\t}\n\n\t\t\t\tif mathutil.PopCount(v.Align) != 1 {\n\t\t\t\t\treturn fmt.Errorf(\"align %d is not a power of two: %s\", v.Align, k)\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tw := m.Items[Ptr].Size\n\tif m.Items[Short].Size < w &&\n\t\tm.Items[Int].Size < w &&\n\t\tm.Items[Long].Size < w &&\n\t\tm.Items[LongLong].Size < w {\n\t\treturn fmt.Errorf(\"model has no integer type suitable for pointer difference and sizeof\")\n\t}\n\n\tfor _, typ := range a {\n\t\tif !seen[Kind(typ)] {\n\t\t\treturn fmt.Errorf(\"model has no item for type %s\", Kind(typ))\n\t\t}\n\t}\n\n\tif g, e := w, m.Items[UintPtr].Size; g != e {\n\t\treturn fmt.Errorf(\"model uintptr has different sizes than ptr has\")\n\t}\n\treturn nil\n}\n\n// MustConvert returns v converted to the type of typ. If the conversion is\n// impossible, the method panics.\n//\n// Conversion an integer type to any pointer type yields an uintptr.\nfunc (m *Model) MustConvert(v interface{}, typ Type) interface{} {\n\tif typ.Kind() == Enum {\n\t\ttyp = m.IntType\n\t}\n\tmi, ok := m.Items[typ.Kind()]\n\tif !ok && typ.Kind() != Function {\n\t\tpanic(fmt.Errorf(\"internal error: no model item for %s, %s\", typ, typ.Kind()))\n\t}\n\n\tw := mi.Size\n\tswitch typ.Kind() {\n\tcase Short:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 2:\n\t\t\t\treturn int16(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 2:\n\t\t\t\treturn int16(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase UShort:\n\t\tswitch x := v.(type) {\n\t\tcase uint16:\n\t\t\tswitch w {\n\t\t\tcase 2:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 2:\n\t\t\t\treturn uint16(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 2:\n\t\t\t\treturn uint16(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Int:\n\t\tswitch x := v.(type) {\n\t\tcase int8:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase byte:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int16:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint16:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\tswitch {\n\t\t\t\tcase x > maxConvF32I32:\n\t\t\t\t\treturn int32(math.MaxInt32)\n\t\t\t\tdefault:\n\t\t\t\t\treturn int32(x)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase UInt:\n\t\tswitch x := v.(type) {\n\t\tcase uint8:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int16:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint16:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uintptr:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\tswitch {\n\t\t\t\tcase x > maxConvF32U32:\n\t\t\t\t\treturn uint32(math.MaxUint32)\n\t\t\t\tdefault:\n\t\t\t\t\treturn uint32(x)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Long:\n\t\tswitch x := v.(type) {\n\t\tcase int16:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn x\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uintptr:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn int32(x)\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase LongLong:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn int64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase ULong:\n\t\tswitch x := v.(type) {\n\t\tcase uint8:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn x\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uintptr:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uint32(x)\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase ULongLong:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uintptr:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn uint64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Float:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn float32(x)\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn float32(x)\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn float32(x)\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn float32(x)\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn x\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn float32(x)\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Double:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Ptr, Function:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\treturn uintptr(x)\n\t\tcase uint32:\n\t\t\treturn uintptr(x)\n\t\tcase int64:\n\t\t\treturn uintptr(x)\n\t\tcase uint64:\n\t\t\treturn uintptr(x)\n\t\tcase uintptr:\n\t\t\treturn x\n\t\tcase StringLitID:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Void:\n\t\treturn nil\n\tcase Char, SChar:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 1:\n\t\t\t\treturn int8(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 1:\n\t\t\t\treturn int8(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase UChar:\n\t\tswitch x := v.(type) {\n\t\tcase uint8:\n\t\t\tswitch w {\n\t\t\tcase 1:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 1:\n\t\t\t\treturn byte(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 1:\n\t\t\t\treturn byte(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase UintPtr:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 4, 8:\n\t\t\t\treturn uintptr(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 4:\n\t\t\t\treturn uintptr(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn uintptr(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase LongDouble:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint32:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase int64:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase uint64:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn float64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 8, 16:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase Bool:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tif x != 0 {\n\t\t\t\treturn int32(1)\n\t\t\t}\n\n\t\t\treturn int32(0)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase FloatComplex:\n\t\tswitch x := v.(type) {\n\t\tcase float32:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn complex(x, 0)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn complex(float32(x), 0)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase complex64:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase complex128:\n\t\t\tswitch w {\n\t\t\tcase 8:\n\t\t\t\treturn complex64(x)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase DoubleComplex:\n\t\tswitch x := v.(type) {\n\t\tcase int32:\n\t\t\tswitch w {\n\t\t\tcase 16:\n\t\t\t\treturn complex(float64(x), 0)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 16:\n\t\t\t\treturn complex(x, 0)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase complex128:\n\t\t\tswitch w {\n\t\t\tcase 16:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tcase LongDoubleComplex:\n\t\tswitch x := v.(type) {\n\t\tcase float64:\n\t\t\tswitch w {\n\t\t\tcase 16:\n\t\t\t\treturn complex(x, 0)\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tcase complex128:\n\t\t\tswitch w {\n\t\t\tcase 16:\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(w)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"internal error %T\", x))\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"internal error %s, %s\", typ, typ.Kind()))\n\t}\n}\n\nfunc (m *Model) value2(v interface{}, typ Type) (interface{}, Type) {\n\treturn m.MustConvert(v, typ), typ\n}\n\nfunc (m *Model) charConst(lx *lexer, t xc.Token) (interface{}, Type) {\n\tswitch t.Rune {\n\tcase CHARCONST:\n\t\ts := string(t.S())\n\t\ttyp := m.IntType\n\t\tvar r rune\n\t\ts = s[1 : len(s)-1] // Remove outer 's.\n\t\tif len(s) == 1 {\n\t\t\treturn rune(s[0]), m.IntType\n\t\t}\n\n\t\trunes := []rune(s)\n\t\tswitch runes[0] {\n\t\tcase '\\\\':\n\t\t\tr, _ = decodeEscapeSequence(runes)\n\t\t\tif r < 0 {\n\t\t\t\tr = -r\n\t\t\t}\n\t\tdefault:\n\t\t\tr = runes[0]\n\t\t}\n\t\treturn r, typ\n\tcase LONGCHARCONST:\n\t\ts := t.S()\n\t\ttyp := m.LongType\n\t\tvar buf bytes.Buffer\n\t\ts = s[2 : len(s)-1]\n\t\trunes := []rune(string(s))\n\t\tfor i := 0; i < len(runes); {\n\t\t\tswitch r := runes[i]; {\n\t\t\tcase r == '\\\\':\n\t\t\t\tr, n := decodeEscapeSequence(runes[i:])\n\t\t\t\tswitch {\n\t\t\t\tcase r < 0:\n\t\t\t\t\tbuf.WriteByte(byte(-r))\n\t\t\t\tdefault:\n\t\t\t\t\tbuf.WriteRune(r)\n\t\t\t\t}\n\t\t\t\ti += n\n\t\t\tdefault:\n\t\t\t\tbuf.WriteByte(byte(r))\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\ts = buf.Bytes()\n\t\trunes = []rune(string(s))\n\t\tif len(runes) != 1 {\n\t\t\tlx.report.Err(t.Pos(), \"invalid character literal %s\", t.S())\n\t\t\treturn 0, typ\n\t\t}\n\n\t\treturn runes[0], typ\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\nfunc (m *Model) getSizeType(lx *lexer) Type {\n\tif t := m.sizeType; t != nil {\n\t\treturn t\n\t}\n\n\tb := lx.scope.Lookup(NSIdentifiers, xc.Dict.SID(\"size_t\"))\n\tif b.Node == nil {\n\t\tw := m.Items[Ptr].Size\n\t\tswitch {\n\t\tcase m.Items[Short].Size >= w:\n\t\t\treturn m.ShortType\n\t\tcase m.Items[Int].Size >= w:\n\t\t\treturn m.IntType\n\t\tcase m.Items[Long].Size >= w:\n\t\t\treturn m.LongType\n\t\tdefault:\n\t\t\treturn m.LongLongType\n\t\t}\n\t}\n\n\td := b.Node.(*DirectDeclarator)\n\tif !d.TopDeclarator().RawSpecifier().IsTypedef() {\n\t\tlx.report.Err(d.Pos(), \"size_t is not a typedef name\")\n\t\tm.sizeType = undefined\n\t\treturn undefined\n\t}\n\n\tm.sizeType = b.Node.(*DirectDeclarator).top().declarator.Type\n\treturn m.sizeType\n}\n\nfunc (m *Model) getPtrDiffType(lx *lexer) Type {\n\tif t := m.ptrDiffType; t != nil {\n\t\treturn t\n\t}\n\n\tb := lx.scope.Lookup(NSIdentifiers, xc.Dict.SID(\"ptrdiff_t\"))\n\tif b.Node == nil {\n\t\tw := m.Items[Ptr].Size\n\t\tswitch {\n\t\tcase m.Items[Short].Size >= w:\n\t\t\treturn m.ShortType\n\t\tcase m.Items[Int].Size >= w:\n\t\t\treturn m.IntType\n\t\tcase m.Items[Long].Size >= w:\n\t\t\treturn m.LongType\n\t\tdefault:\n\t\t\treturn m.LongLongType\n\t\t}\n\t}\n\n\td := b.Node.(*DirectDeclarator)\n\tif !d.TopDeclarator().RawSpecifier().IsTypedef() {\n\t\tlx.report.Err(d.Pos(), \"ptrdiff_t is not a typedef name\")\n\t\tm.ptrDiffType = undefined\n\t\treturn undefined\n\t}\n\n\tm.ptrDiffType = b.Node.(*DirectDeclarator).top().declarator.Type\n\treturn m.ptrDiffType\n}\n\nfunc (m *Model) getLongStrType(lx *lexer, tok xc.Token) Type {\n\tif t := m.longStrType; t != nil {\n\t\treturn t\n\t}\n\n\tb := lx.scope.Lookup(NSIdentifiers, xc.Dict.SID(\"wchar_t\"))\n\tif b.Node == nil {\n\t\tm.longStrType = m.IntType.Pointer()\n\t\treturn m.longStrType\n\t}\n\n\td := b.Node.(*DirectDeclarator)\n\tif !d.TopDeclarator().RawSpecifier().IsTypedef() {\n\t\tlx.report.Err(d.Pos(), \"wchar_t is not a typedef name\")\n\t\tm.longStrType = undefined\n\t\treturn m.longStrType\n\t}\n\n\tm.longStrType = b.Node.(*DirectDeclarator).top().declarator.Type.Pointer()\n\treturn m.longStrType\n}\n\nfunc (m *Model) strConst(lx *lexer, t xc.Token) (interface{}, Type) {\n\ts := t.S()\n\ttyp := m.strType\n\tvar buf bytes.Buffer\n\tswitch t.Rune {\n\tcase LONGSTRINGLITERAL:\n\t\ttyp = m.getLongStrType(lx, t)\n\t\ts = s[1:] // Remove leading 'L'.\n\t\tfallthrough\n\tcase STRINGLITERAL:\n\t\ts = s[1 : len(s)-1] // Remove outer \"s.\n\t\trunes := []rune(string(s))\n\t\tfor i := 0; i < len(runes); {\n\t\t\tswitch r := runes[i]; {\n\t\t\tcase r == '\\\\':\n\t\t\t\tr, n := decodeEscapeSequence(runes[i:])\n\t\t\t\tswitch {\n\t\t\t\tcase r < 0:\n\t\t\t\t\tbuf.WriteByte(byte(-r))\n\t\t\t\tdefault:\n\t\t\t\t\tbuf.WriteRune(r)\n\t\t\t\t}\n\t\t\t\ti += n\n\t\t\tdefault:\n\t\t\t\tbuf.WriteByte(byte(r))\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n\ts = buf.Bytes()\n\tswitch t.Rune {\n\tcase LONGSTRINGLITERAL:\n\t\treturn LongStringLitID(xc.Dict.ID(s)), typ\n\tcase STRINGLITERAL:\n\t\treturn StringLitID(xc.Dict.ID(s)), typ\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\nfunc (m *Model) floatConst(lx *lexer, t xc.Token) (interface{}, Type) {\n\tconst (\n\t\tf = 1 << iota\n\t\tj\n\t\tl\n\t)\n\tk := 0\n\ts := t.S()\n\ti := len(s) - 1\nmore:\n\tswitch c := s[i]; c {\n\tcase 'i', 'j':\n\t\tk |= j\n\t\ti--\n\t\tgoto more\n\tcase 'l', 'L':\n\t\tk |= l\n\t\ti--\n\t\tgoto more\n\tcase 'f', 'F':\n\t\tk |= f\n\t\ti--\n\t\tgoto more\n\t}\n\tif k&j != 0 && !lx.tweaks.enableImaginarySuffix {\n\t\tlx.report.Err(t.Pos(), \"imaginary suffixes not enabled\")\n\t\tk &^= j\n\t}\n\tss := string(s[:i+1])\n\tvar v float64\n\tvar err error\n\tswitch {\n\tcase strings.Contains(ss, \"p\"):\n\t\tvar bf *big.Float\n\t\tbf, _, err = big.ParseFloat(ss, 0, 53, big.ToNearestEven)\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\tlx.report.Err(t.Pos(), \"invalid floating point constant %s\", ss)\n\t\t\tv = 0\n\t\tdefault:\n\t\t\tv, _ = bf.Float64()\n\t\t}\n\tdefault:\n\t\tv, err = strconv.ParseFloat(ss, 64)\n\t}\n\tif err != nil {\n\t\tlx.report.Err(t.Pos(), \"invalid floating point constant %s\", ss)\n\t\tv = 0\n\t}\n\tswitch k {\n\tcase 0:\n\t\treturn m.value2(v, m.DoubleType)\n\tcase l:\n\t\treturn m.value2(v, m.LongDoubleType)\n\tcase j:\n\t\treturn m.value2(complex(0, v), m.DoubleComplexType)\n\tcase j | l:\n\t\treturn m.value2(complex(0, v), m.LongDoubleComplexType)\n\tcase f:\n\t\treturn m.value2(v, m.FloatType)\n\tcase f | j:\n\t\treturn m.value2(complex(0, v), m.FloatComplexType)\n\tdefault:\n\t\tlx.report.Err(t.Pos(), \"invalid literal %s\", t.S())\n\t\treturn 0.0, m.DoubleType\n\t}\n}\n\nfunc (m *Model) intConst(lx *lexer, t xc.Token) (interface{}, Type) {\n\tconst (\n\t\tl = 1 << iota\n\t\tll\n\t\tu\n\t)\n\tk := 0\n\ts := t.S()\n\ti := len(s) - 1\nmore:\n\tswitch c := s[i]; c {\n\tcase 'u', 'U':\n\t\tk |= u\n\t\ti--\n\t\tgoto more\n\tcase 'l', 'L':\n\t\tif i > 0 && (s[i-1] == 'l' || s[i-1] == 'L') {\n\t\t\tk |= ll\n\t\t\ti -= 2\n\t\t\tgoto more\n\t\t}\n\n\t\tk |= l\n\t\ti--\n\t\tgoto more\n\t}\n\tn, err := strconv.ParseUint(string(s[:i+1]), 0, 64)\n\tif err != nil {\n\t\tlx.report.Err(t.Pos(), \"invalid integer constant: %s\", s)\n\t}\n\n\tswitch k {\n\tcase 0:\n\t\tswitch b := mathutil.BitLenUint64(n); {\n\t\tcase b < 32:\n\t\t\treturn m.value2(n, m.IntType)\n\t\tcase b < 33:\n\t\t\treturn m.value2(n, m.UIntType)\n\t\tcase b < 64:\n\t\t\tif m.Items[Long].Size == 8 {\n\t\t\t\treturn m.value2(n, m.LongType)\n\t\t\t}\n\n\t\t\treturn m.value2(n, m.LongLongType)\n\t\tdefault:\n\t\t\tif m.Items[ULong].Size == 8 {\n\t\t\t\treturn m.value2(n, m.ULongType)\n\t\t\t}\n\n\t\t\treturn m.value2(n, m.ULongLongType)\n\t\t}\n\tcase l:\n\t\treturn m.value2(n, m.LongType)\n\tcase ll:\n\t\treturn m.value2(n, m.LongLongType)\n\tcase u:\n\t\treturn m.value2(n, m.UIntType)\n\tcase u | l:\n\t\treturn m.value2(n, m.ULongType)\n\tcase u | ll:\n\t\treturn m.value2(n, m.ULongLongType)\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\nfunc (m *Model) cBool(v bool) interface{} {\n\tif v {\n\t\treturn m.MustConvert(int32(1), m.IntType)\n\n\t}\n\treturn m.MustConvert(int32(0), m.IntType)\n}\n\nfunc (m *Model) binOp(lx *lexer, a, b operand) (interface{}, interface{}, Type) {\n\tav, at := a.eval(lx)\n\tbv, bt := b.eval(lx)\n\tt := at\n\tif IsArithmeticType(at) && IsArithmeticType(bt) {\n\t\tt = m.BinOpType(at, bt)\n\t}\n\tif av == nil || bv == nil || t.Kind() == Undefined {\n\t\treturn nil, nil, t\n\t}\n\n\treturn m.MustConvert(av, t), m.MustConvert(bv, t), t\n}\n\n// BinOpType returns the evaluation type of a binop b, ie. the type operands\n// are converted to before performing the operation. Operands must be\n// arithmetic types.\n//\n// See [0], 6.3.1.8 - Usual arithmetic conversions.\nfunc (m *Model) BinOpType(a, b Type) Type {\n\tak := a.Kind()\n\tbk := b.Kind()\n\n\tif ak == LongDoubleComplex || bk == LongDoubleComplex {\n\t\treturn m.LongDoubleComplexType\n\t}\n\n\tif ak == DoubleComplex || bk == DoubleComplex {\n\t\treturn m.DoubleComplexType\n\t}\n\n\tif ak == FloatComplex || bk == FloatComplex {\n\t\treturn m.FloatComplexType\n\t}\n\n\t// First, if the corresponding real type of either operand is long\n\t// double, the other operand is converted, without change of type\n\t// domain, to a type whose corresponding real type is long double.\n\tif ak == LongDouble || bk == LongDouble {\n\t\treturn m.LongDoubleType\n\t}\n\n\t// Otherwise, if the corresponding real type of either operand is\n\t// double, the other operand is converted, without change of type\n\t// domain, to a type whose corresponding real type is double.\n\tif ak == Double || bk == Double {\n\t\treturn m.DoubleType\n\t}\n\n\t// Otherwise, if the corresponding real type of either operand is float, the other\n\t// operand is converted, without change of type domain, to a type whose\n\t// corresponding real type is float.\n\tif ak == Float || bk == Float {\n\t\treturn m.FloatType\n\t}\n\n\t// Otherwise, the integer promotions are performed on both operands.\n\tak = m.promoteTo[ak]\n\tbk = m.promoteTo[bk]\n\n\t// Then the following rules are applied to the promoted operands:\n\tar := m.intConvRank[ak]\n\tbr := m.intConvRank[bk]\n\n\t// If both operands have the same type, then no further conversion is\n\t// needed.\n\tif ak == bk {\n\t\treturn m.typ(ak)\n\t}\n\n\t// Otherwise, if both operands have signed integer types or both have\n\t// unsigned integer types, the operand with the type of lesser integer\n\t// conversion rank is converted to the type of the operand with greater\n\t// rank.\n\tif m.Signed[ak] == m.Signed[bk] {\n\t\tswitch {\n\t\tcase ar < br:\n\t\t\treturn m.typ(bk)\n\t\tdefault:\n\t\t\treturn m.typ(ak)\n\t\t}\n\t}\n\n\t// Make a the unsigned type and b the signed type.\n\tif m.Signed[ak] {\n\t\ta, b = b, a\n\t\tak, bk = bk, ak\n\t\tar, br = br, ar\n\t}\n\n\t// Otherwise, if the operand that has unsigned integer type has rank\n\t// greater or equal to the rank of the type of the other operand, then\n\t// the operand with signed integer type is converted to the type of the\n\t// operand with unsigned integer type.\n\tif ar >= br {\n\t\treturn m.typ(ak)\n\t}\n\n\t// Otherwise, if the type of the operand with signed integer type can\n\t// represent all of the values of the type of the operand with unsigned\n\t// integer type, then the operand with unsigned integer type is\n\t// converted to the type of the operand with signed integer type.\n\tas := m.Items[ak].Size\n\tbs := m.Items[bk].Size\n\tif bs > as {\n\t\treturn m.typ(bk)\n\t}\n\n\t// Otherwise, both operands are converted to the unsigned integer type\n\t// corresponding to the type of the operand with signed integer type.\n\treturn m.typ(unsigned(bk))\n}\n\nfunc (m *Model) promote(t Type) Type {\n\tif !IsIntType(t) {\n\t\treturn t\n\t}\n\n\treturn m.BinOpType(t, t)\n}\n\nfunc (m *Model) makeType(lx *lexer, attr int, ts ...int) Type {\n\td := m.makeDeclarator(attr, ts...)\n\treturn d.setFull(lx)\n}\n\nfunc (m *Model) makeDeclarator(attr int, ts ...int) *Declarator {\n\ts := &spec{attr, tsEncode(ts...)}\n\td := &Declarator{specifier: s}\n\tdd := &DirectDeclarator{declarator: d, specifier: s}\n\td.DirectDeclarator = dd\n\treturn d\n}\n\nfunc (m *Model) checkArithmeticType(lx *lexer, a ...operand) (r bool) {\n\tr = true\n\tfor _, v := range a {\n\t\t_, t := v.eval(lx)\n\t\tif !IsArithmeticType(t) {\n\t\t\tlx.report.Err(v.Pos(), \"not an arithmetic type (have '%s')\", t)\n\t\t\tr = false\n\t\t}\n\t}\n\treturn r\n}\n\nfunc (m *Model) checkIntegerOrBoolType(lx *lexer, a ...operand) (r bool) {\n\tr = true\n\tfor _, v := range a {\n\t\t_, t := v.eval(lx)\n\t\tif !IsIntType(t) && !(t.Kind() == Bool) {\n\t\t\tlx.report.Err(v.Pos(), \"not an integer or bool type (have '%s')\", t)\n\t\t\tr = false\n\t\t}\n\t}\n\treturn r\n}\n"
  },
  {
    "path": "namespace_string.go",
    "content": "// Code generated by \"stringer -type Namespace\"; DO NOT EDIT.\n\npackage cc\n\nimport \"fmt\"\n\nconst _Namespace_name = \"NSIdentifiersNSTags\"\n\nvar _Namespace_index = [...]uint8{0, 13, 19}\n\nfunc (i Namespace) String() string {\n\tif i < 0 || i >= Namespace(len(_Namespace_index)-1) {\n\t\treturn fmt.Sprintf(\"Namespace(%d)\", i)\n\t}\n\treturn _Namespace_name[_Namespace_index[i]:_Namespace_index[i+1]]\n}\n"
  },
  {
    "path": "parser.go",
    "content": "// Code generated by goyacc - DO NOT EDIT.\n\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.10. Substantial portions of expression AST size\n// optimizations are from [2], license of which follows.\n\n// ----------------------------------------------------------------------------\n\n// Copyright 2013 The Go Authors.  All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// This grammar is derived from the C grammar in the 'ansitize'\n// program, which carried this notice:\n//\n// Copyright (c) 2006 Russ Cox,\n// \tMassachusetts Institute of Technology\n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall\n// be included in all copies or substantial portions of the\n// Software.\n//\n// The software is provided \"as is\", without warranty of any\n// kind, express or implied, including but not limited to the\n// warranties of merchantability, fitness for a particular\n// purpose and noninfringement.  In no event shall the authors\n// or copyright holders be liable for any claim, damages or\n// other liability, whether in an action of contract, tort or\n// otherwise, arising from, out of or in connection with the\n// software or the use or other dealings in the software.\n\npackage cc\n\nimport __yyfmt__ \"fmt\"\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/xc\"\n)\n\ntype yySymType struct {\n\tyys       int\n\tToken     xc.Token\n\tgroupPart Node\n\tnode      Node\n\ttoks      PPTokenList\n}\n\ntype yyXError struct {\n\tstate, xsym int\n}\n\nconst (\n\tyyDefault           = 57460\n\tyyEofCode           = 57344\n\tADDASSIGN           = 57346\n\tALIGNOF             = 57347\n\tANDAND              = 57348\n\tANDASSIGN           = 57349\n\tARROW               = 57350\n\tASM                 = 57351\n\tAUTO                = 57352\n\tBOOL                = 57353\n\tBREAK               = 57354\n\tCASE                = 57355\n\tCAST                = 57356\n\tCHAR                = 57357\n\tCHARCONST           = 57358\n\tCOMPLEX             = 57359\n\tCONST               = 57360\n\tCONSTANT_EXPRESSION = 1048577\n\tCONTINUE            = 57361\n\tDDD                 = 57362\n\tDEC                 = 57363\n\tDEFAULT             = 57364\n\tDIVASSIGN           = 57365\n\tDO                  = 57366\n\tDOUBLE              = 57367\n\tELSE                = 57368\n\tENUM                = 57369\n\tEQ                  = 57370\n\tEXTERN              = 57371\n\tFLOAT               = 57372\n\tFLOATCONST          = 57373\n\tFOR                 = 57374\n\tGEQ                 = 57375\n\tGOTO                = 57376\n\tIDENTIFIER          = 57377\n\tIDENTIFIER_LPAREN   = 57378\n\tIDENTIFIER_NONREPL  = 57379\n\tIF                  = 57380\n\tINC                 = 57381\n\tINLINE              = 57382\n\tINT                 = 57383\n\tINTCONST            = 57384\n\tLEQ                 = 57385\n\tLONG                = 57386\n\tLONGCHARCONST       = 57387\n\tLONGSTRINGLITERAL   = 57388\n\tLSH                 = 57389\n\tLSHASSIGN           = 57390\n\tMODASSIGN           = 57391\n\tMULASSIGN           = 57392\n\tNEQ                 = 57393\n\tNOELSE              = 57394\n\tNORETURN            = 57395\n\tNOSEMI              = 57396\n\tORASSIGN            = 57397\n\tOROR                = 57398\n\tPPDEFINE            = 57399\n\tPPELIF              = 57400\n\tPPELSE              = 57401\n\tPPENDIF             = 57402\n\tPPERROR             = 57403\n\tPPHASH_NL           = 57404\n\tPPHEADER_NAME       = 57405\n\tPPIF                = 57406\n\tPPIFDEF             = 57407\n\tPPIFNDEF            = 57408\n\tPPINCLUDE           = 57409\n\tPPINCLUDE_NEXT      = 57410\n\tPPLINE              = 57411\n\tPPNONDIRECTIVE      = 57412\n\tPPNUMBER            = 57413\n\tPPOTHER             = 57414\n\tPPPASTE             = 57415\n\tPPPRAGMA            = 57416\n\tPPUNDEF             = 57417\n\tPREPROCESSING_FILE  = 1048576\n\tREGISTER            = 57418\n\tRESTRICT            = 57419\n\tRETURN              = 57420\n\tRSH                 = 57421\n\tRSHASSIGN           = 57422\n\tSHORT               = 57423\n\tSIGNED              = 57424\n\tSIZEOF              = 57425\n\tSTATIC              = 57426\n\tSTATIC_ASSERT       = 57427\n\tSTRINGLITERAL       = 57428\n\tSTRUCT              = 57429\n\tSUBASSIGN           = 57430\n\tSWITCH              = 57431\n\tTRANSLATION_UNIT    = 1048578\n\tTYPEDEF             = 57432\n\tTYPEDEFNAME         = 57433\n\tTYPEOF              = 57434\n\tUNARY               = 57435\n\tUNION               = 57436\n\tUNSIGNED            = 57437\n\tVOID                = 57438\n\tVOLATILE            = 57439\n\tWHILE               = 57440\n\tXORASSIGN           = 57441\n\tyyErrCode           = 57345\n\n\tyyMaxDepth = 200\n\tyyTabOfs   = -328\n)\n\nvar (\n\tyyXLAT = map[int]int{\n\t\t40:      0,   // '(' (333x)\n\t\t42:      1,   // '*' (294x)\n\t\t57377:   2,   // IDENTIFIER (241x)\n\t\t38:      3,   // '&' (226x)\n\t\t43:      4,   // '+' (226x)\n\t\t45:      5,   // '-' (226x)\n\t\t57348:   6,   // ANDAND (226x)\n\t\t57363:   7,   // DEC (226x)\n\t\t57381:   8,   // INC (226x)\n\t\t59:      9,   // ';' (220x)\n\t\t41:      10,  // ')' (203x)\n\t\t44:      11,  // ',' (191x)\n\t\t57428:   12,  // STRINGLITERAL (169x)\n\t\t91:      13,  // '[' (167x)\n\t\t33:      14,  // '!' (150x)\n\t\t126:     15,  // '~' (150x)\n\t\t57347:   16,  // ALIGNOF (150x)\n\t\t57358:   17,  // CHARCONST (150x)\n\t\t57373:   18,  // FLOATCONST (150x)\n\t\t57384:   19,  // INTCONST (150x)\n\t\t57387:   20,  // LONGCHARCONST (150x)\n\t\t57388:   21,  // LONGSTRINGLITERAL (150x)\n\t\t57425:   22,  // SIZEOF (150x)\n\t\t57439:   23,  // VOLATILE (141x)\n\t\t57360:   24,  // CONST (139x)\n\t\t57419:   25,  // RESTRICT (139x)\n\t\t125:     26,  // '}' (132x)\n\t\t57353:   27,  // BOOL (129x)\n\t\t57357:   28,  // CHAR (129x)\n\t\t57359:   29,  // COMPLEX (129x)\n\t\t57367:   30,  // DOUBLE (129x)\n\t\t57369:   31,  // ENUM (129x)\n\t\t57372:   32,  // FLOAT (129x)\n\t\t57383:   33,  // INT (129x)\n\t\t57386:   34,  // LONG (129x)\n\t\t57423:   35,  // SHORT (129x)\n\t\t57424:   36,  // SIGNED (129x)\n\t\t57429:   37,  // STRUCT (129x)\n\t\t57433:   38,  // TYPEDEFNAME (129x)\n\t\t57434:   39,  // TYPEOF (129x)\n\t\t57436:   40,  // UNION (129x)\n\t\t57437:   41,  // UNSIGNED (129x)\n\t\t57438:   42,  // VOID (129x)\n\t\t58:      43,  // ':' (126x)\n\t\t57426:   44,  // STATIC (120x)\n\t\t57352:   45,  // AUTO (114x)\n\t\t57371:   46,  // EXTERN (114x)\n\t\t57382:   47,  // INLINE (114x)\n\t\t57395:   48,  // NORETURN (114x)\n\t\t57418:   49,  // REGISTER (114x)\n\t\t57432:   50,  // TYPEDEF (114x)\n\t\t57344:   51,  // $end (106x)\n\t\t61:      52,  // '=' (96x)\n\t\t123:     53,  // '{' (93x)\n\t\t57503:   54,  // Expression (88x)\n\t\t93:      55,  // ']' (86x)\n\t\t46:      56,  // '.' (85x)\n\t\t57351:   57,  // ASM (84x)\n\t\t57427:   58,  // STATIC_ASSERT (79x)\n\t\t37:      59,  // '%' (77x)\n\t\t47:      60,  // '/' (77x)\n\t\t60:      61,  // '<' (77x)\n\t\t62:      62,  // '>' (77x)\n\t\t63:      63,  // '?' (77x)\n\t\t94:      64,  // '^' (77x)\n\t\t124:     65,  // '|' (77x)\n\t\t57346:   66,  // ADDASSIGN (77x)\n\t\t57349:   67,  // ANDASSIGN (77x)\n\t\t57350:   68,  // ARROW (77x)\n\t\t57365:   69,  // DIVASSIGN (77x)\n\t\t57370:   70,  // EQ (77x)\n\t\t57375:   71,  // GEQ (77x)\n\t\t57385:   72,  // LEQ (77x)\n\t\t57389:   73,  // LSH (77x)\n\t\t57390:   74,  // LSHASSIGN (77x)\n\t\t57391:   75,  // MODASSIGN (77x)\n\t\t57392:   76,  // MULASSIGN (77x)\n\t\t57393:   77,  // NEQ (77x)\n\t\t57397:   78,  // ORASSIGN (77x)\n\t\t57398:   79,  // OROR (77x)\n\t\t57421:   80,  // RSH (77x)\n\t\t57422:   81,  // RSHASSIGN (77x)\n\t\t57430:   82,  // SUBASSIGN (77x)\n\t\t57441:   83,  // XORASSIGN (77x)\n\t\t10:      84,  // '\\n' (58x)\n\t\t57376:   85,  // GOTO (55x)\n\t\t57440:   86,  // WHILE (53x)\n\t\t57354:   87,  // BREAK (52x)\n\t\t57355:   88,  // CASE (52x)\n\t\t57361:   89,  // CONTINUE (52x)\n\t\t57364:   90,  // DEFAULT (52x)\n\t\t57366:   91,  // DO (52x)\n\t\t57374:   92,  // FOR (52x)\n\t\t57380:   93,  // IF (52x)\n\t\t57414:   94,  // PPOTHER (52x)\n\t\t57420:   95,  // RETURN (52x)\n\t\t57431:   96,  // SWITCH (52x)\n\t\t57402:   97,  // PPENDIF (44x)\n\t\t57401:   98,  // PPELSE (40x)\n\t\t57400:   99,  // PPELIF (39x)\n\t\t57399:   100, // PPDEFINE (35x)\n\t\t57403:   101, // PPERROR (35x)\n\t\t57404:   102, // PPHASH_NL (35x)\n\t\t57406:   103, // PPIF (35x)\n\t\t57407:   104, // PPIFDEF (35x)\n\t\t57408:   105, // PPIFNDEF (35x)\n\t\t57409:   106, // PPINCLUDE (35x)\n\t\t57410:   107, // PPINCLUDE_NEXT (35x)\n\t\t57411:   108, // PPLINE (35x)\n\t\t57412:   109, // PPNONDIRECTIVE (35x)\n\t\t57416:   110, // PPPRAGMA (35x)\n\t\t57417:   111, // PPUNDEF (35x)\n\t\t57368:   112, // ELSE (32x)\n\t\t57555:   113, // TypeQualifier (28x)\n\t\t57504:   114, // ExpressionList (26x)\n\t\t57528:   115, // PPTokenList (22x)\n\t\t57530:   116, // PPTokens (22x)\n\t\t57499:   117, // EnumSpecifier (20x)\n\t\t57550:   118, // StructOrUnion (20x)\n\t\t57551:   119, // StructOrUnionSpecifier (20x)\n\t\t57558:   120, // TypeSpecifier (20x)\n\t\t57505:   121, // ExpressionListOpt (18x)\n\t\t57470:   122, // BasicAssemblerStatement (15x)\n\t\t57476:   123, // CompoundStatement (15x)\n\t\t57482:   124, // DeclarationSpecifiers (15x)\n\t\t57511:   125, // FunctionSpecifier (15x)\n\t\t57529:   126, // PPTokenListOpt (15x)\n\t\t57545:   127, // StorageClassSpecifier (15x)\n\t\t57468:   128, // AssemblerStatement (13x)\n\t\t57507:   129, // ExpressionStatement (12x)\n\t\t57525:   130, // IterationStatement (12x)\n\t\t57526:   131, // JumpStatement (12x)\n\t\t57527:   132, // LabeledStatement (12x)\n\t\t57535:   133, // Pointer (12x)\n\t\t57539:   134, // SelectionStatement (12x)\n\t\t57543:   135, // Statement (12x)\n\t\t57536:   136, // PointerOpt (11x)\n\t\t57484:   137, // Declarator (9x)\n\t\t57544:   138, // StaticAssertDeclaration (9x)\n\t\t57478:   139, // ControlLine (8x)\n\t\t57514:   140, // GroupPart (8x)\n\t\t57518:   141, // IfGroup (8x)\n\t\t57519:   142, // IfSection (8x)\n\t\t57552:   143, // TextLine (8x)\n\t\t57479:   144, // Declaration (7x)\n\t\t57454:   145, // $@4 (6x)\n\t\t57477:   146, // ConstantExpression (6x)\n\t\t57362:   147, // DDD (6x)\n\t\t57512:   148, // GroupList (6x)\n\t\t57466:   149, // AssemblerOperand (5x)\n\t\t57469:   150, // AssemblerSymbolicNameOpt (5x)\n\t\t57513:   151, // GroupListOpt (5x)\n\t\t57538:   152, // ReplacementList (5x)\n\t\t57540:   153, // SpecifierQualifierList (5x)\n\t\t57556:   154, // TypeQualifierList (5x)\n\t\t57459:   155, // $@9 (4x)\n\t\t57461:   156, // AbstractDeclarator (4x)\n\t\t57467:   157, // AssemblerOperands (4x)\n\t\t57483:   158, // DeclarationSpecifiersOpt (4x)\n\t\t57488:   159, // Designator (4x)\n\t\t57523:   160, // Initializer (4x)\n\t\t57531:   161, // ParameterDeclaration (4x)\n\t\t57554:   162, // TypeName (4x)\n\t\t57557:   163, // TypeQualifierListOpt (4x)\n\t\t57465:   164, // AssemblerInstructions (3x)\n\t\t57475:   165, // CommaOpt (3x)\n\t\t57486:   166, // Designation (3x)\n\t\t57487:   167, // DesignationOpt (3x)\n\t\t57489:   168, // DesignatorList (3x)\n\t\t57506:   169, // ExpressionOpt (3x)\n\t\t57515:   170, // IdentifierList (3x)\n\t\t57520:   171, // InitDeclarator (3x)\n\t\t57532:   172, // ParameterList (3x)\n\t\t57533:   173, // ParameterTypeList (3x)\n\t\t57443:   174, // $@10 (2x)\n\t\t57447:   175, // $@14 (2x)\n\t\t57449:   176, // $@16 (2x)\n\t\t57450:   177, // $@17 (2x)\n\t\t57451:   178, // $@18 (2x)\n\t\t57455:   179, // $@5 (2x)\n\t\t57462:   180, // AbstractDeclaratorOpt (2x)\n\t\t57471:   181, // BlockItem (2x)\n\t\t57474:   182, // Clobbers (2x)\n\t\t57481:   183, // DeclarationListOpt (2x)\n\t\t57485:   184, // DeclaratorOpt (2x)\n\t\t57490:   185, // DirectAbstractDeclarator (2x)\n\t\t57491:   186, // DirectAbstractDeclaratorOpt (2x)\n\t\t57492:   187, // DirectDeclarator (2x)\n\t\t57493:   188, // ElifGroup (2x)\n\t\t57500:   189, // EnumerationConstant (2x)\n\t\t57501:   190, // Enumerator (2x)\n\t\t57508:   191, // ExternalDeclaration (2x)\n\t\t57509:   192, // FunctionBody (2x)\n\t\t57510:   193, // FunctionDefinition (2x)\n\t\t57516:   194, // IdentifierListOpt (2x)\n\t\t57517:   195, // IdentifierOpt (2x)\n\t\t57521:   196, // InitDeclaratorList (2x)\n\t\t57522:   197, // InitDeclaratorListOpt (2x)\n\t\t57524:   198, // InitializerList (2x)\n\t\t57534:   199, // ParameterTypeListOpt (2x)\n\t\t57541:   200, // SpecifierQualifierListOpt (2x)\n\t\t57546:   201, // StructDeclaration (2x)\n\t\t57548:   202, // StructDeclarator (2x)\n\t\t57559:   203, // VolatileOpt (2x)\n\t\t57442:   204, // $@1 (1x)\n\t\t57444:   205, // $@11 (1x)\n\t\t57445:   206, // $@12 (1x)\n\t\t57446:   207, // $@13 (1x)\n\t\t57448:   208, // $@15 (1x)\n\t\t57452:   209, // $@2 (1x)\n\t\t57453:   210, // $@3 (1x)\n\t\t57456:   211, // $@6 (1x)\n\t\t57457:   212, // $@7 (1x)\n\t\t57458:   213, // $@8 (1x)\n\t\t57463:   214, // ArgumentExpressionList (1x)\n\t\t57464:   215, // ArgumentExpressionListOpt (1x)\n\t\t57472:   216, // BlockItemList (1x)\n\t\t57473:   217, // BlockItemListOpt (1x)\n\t\t1048577: 218, // CONSTANT_EXPRESSION (1x)\n\t\t57480:   219, // DeclarationList (1x)\n\t\t57494:   220, // ElifGroupList (1x)\n\t\t57495:   221, // ElifGroupListOpt (1x)\n\t\t57496:   222, // ElseGroup (1x)\n\t\t57497:   223, // ElseGroupOpt (1x)\n\t\t57498:   224, // EndifLine (1x)\n\t\t57502:   225, // EnumeratorList (1x)\n\t\t57378:   226, // IDENTIFIER_LPAREN (1x)\n\t\t1048576: 227, // PREPROCESSING_FILE (1x)\n\t\t57537:   228, // PreprocessingFile (1x)\n\t\t57542:   229, // Start (1x)\n\t\t57547:   230, // StructDeclarationList (1x)\n\t\t57549:   231, // StructDeclaratorList (1x)\n\t\t1048578: 232, // TRANSLATION_UNIT (1x)\n\t\t57553:   233, // TranslationUnit (1x)\n\t\t57460:   234, // $default (0x)\n\t\t57356:   235, // CAST (0x)\n\t\t57345:   236, // error (0x)\n\t\t57379:   237, // IDENTIFIER_NONREPL (0x)\n\t\t57394:   238, // NOELSE (0x)\n\t\t57396:   239, // NOSEMI (0x)\n\t\t57405:   240, // PPHEADER_NAME (0x)\n\t\t57413:   241, // PPNUMBER (0x)\n\t\t57415:   242, // PPPASTE (0x)\n\t\t57435:   243, // UNARY (0x)\n\t}\n\n\tyySymNames = []string{\n\t\t\"'('\",\n\t\t\"'*'\",\n\t\t\"IDENTIFIER\",\n\t\t\"'&'\",\n\t\t\"'+'\",\n\t\t\"'-'\",\n\t\t\"ANDAND\",\n\t\t\"DEC\",\n\t\t\"INC\",\n\t\t\"';'\",\n\t\t\"')'\",\n\t\t\"','\",\n\t\t\"STRINGLITERAL\",\n\t\t\"'['\",\n\t\t\"'!'\",\n\t\t\"'~'\",\n\t\t\"ALIGNOF\",\n\t\t\"CHARCONST\",\n\t\t\"FLOATCONST\",\n\t\t\"INTCONST\",\n\t\t\"LONGCHARCONST\",\n\t\t\"LONGSTRINGLITERAL\",\n\t\t\"SIZEOF\",\n\t\t\"VOLATILE\",\n\t\t\"CONST\",\n\t\t\"RESTRICT\",\n\t\t\"'}'\",\n\t\t\"BOOL\",\n\t\t\"CHAR\",\n\t\t\"COMPLEX\",\n\t\t\"DOUBLE\",\n\t\t\"ENUM\",\n\t\t\"FLOAT\",\n\t\t\"INT\",\n\t\t\"LONG\",\n\t\t\"SHORT\",\n\t\t\"SIGNED\",\n\t\t\"STRUCT\",\n\t\t\"TYPEDEFNAME\",\n\t\t\"TYPEOF\",\n\t\t\"UNION\",\n\t\t\"UNSIGNED\",\n\t\t\"VOID\",\n\t\t\"':'\",\n\t\t\"STATIC\",\n\t\t\"AUTO\",\n\t\t\"EXTERN\",\n\t\t\"INLINE\",\n\t\t\"NORETURN\",\n\t\t\"REGISTER\",\n\t\t\"TYPEDEF\",\n\t\t\"$end\",\n\t\t\"'='\",\n\t\t\"'{'\",\n\t\t\"Expression\",\n\t\t\"']'\",\n\t\t\"'.'\",\n\t\t\"ASM\",\n\t\t\"STATIC_ASSERT\",\n\t\t\"'%'\",\n\t\t\"'/'\",\n\t\t\"'<'\",\n\t\t\"'>'\",\n\t\t\"'?'\",\n\t\t\"'^'\",\n\t\t\"'|'\",\n\t\t\"ADDASSIGN\",\n\t\t\"ANDASSIGN\",\n\t\t\"ARROW\",\n\t\t\"DIVASSIGN\",\n\t\t\"EQ\",\n\t\t\"GEQ\",\n\t\t\"LEQ\",\n\t\t\"LSH\",\n\t\t\"LSHASSIGN\",\n\t\t\"MODASSIGN\",\n\t\t\"MULASSIGN\",\n\t\t\"NEQ\",\n\t\t\"ORASSIGN\",\n\t\t\"OROR\",\n\t\t\"RSH\",\n\t\t\"RSHASSIGN\",\n\t\t\"SUBASSIGN\",\n\t\t\"XORASSIGN\",\n\t\t\"'\\\\n'\",\n\t\t\"GOTO\",\n\t\t\"WHILE\",\n\t\t\"BREAK\",\n\t\t\"CASE\",\n\t\t\"CONTINUE\",\n\t\t\"DEFAULT\",\n\t\t\"DO\",\n\t\t\"FOR\",\n\t\t\"IF\",\n\t\t\"PPOTHER\",\n\t\t\"RETURN\",\n\t\t\"SWITCH\",\n\t\t\"PPENDIF\",\n\t\t\"PPELSE\",\n\t\t\"PPELIF\",\n\t\t\"PPDEFINE\",\n\t\t\"PPERROR\",\n\t\t\"PPHASH_NL\",\n\t\t\"PPIF\",\n\t\t\"PPIFDEF\",\n\t\t\"PPIFNDEF\",\n\t\t\"PPINCLUDE\",\n\t\t\"PPINCLUDE_NEXT\",\n\t\t\"PPLINE\",\n\t\t\"PPNONDIRECTIVE\",\n\t\t\"PPPRAGMA\",\n\t\t\"PPUNDEF\",\n\t\t\"ELSE\",\n\t\t\"TypeQualifier\",\n\t\t\"ExpressionList\",\n\t\t\"PPTokenList\",\n\t\t\"PPTokens\",\n\t\t\"EnumSpecifier\",\n\t\t\"StructOrUnion\",\n\t\t\"StructOrUnionSpecifier\",\n\t\t\"TypeSpecifier\",\n\t\t\"ExpressionListOpt\",\n\t\t\"BasicAssemblerStatement\",\n\t\t\"CompoundStatement\",\n\t\t\"DeclarationSpecifiers\",\n\t\t\"FunctionSpecifier\",\n\t\t\"PPTokenListOpt\",\n\t\t\"StorageClassSpecifier\",\n\t\t\"AssemblerStatement\",\n\t\t\"ExpressionStatement\",\n\t\t\"IterationStatement\",\n\t\t\"JumpStatement\",\n\t\t\"LabeledStatement\",\n\t\t\"Pointer\",\n\t\t\"SelectionStatement\",\n\t\t\"Statement\",\n\t\t\"PointerOpt\",\n\t\t\"Declarator\",\n\t\t\"StaticAssertDeclaration\",\n\t\t\"ControlLine\",\n\t\t\"GroupPart\",\n\t\t\"IfGroup\",\n\t\t\"IfSection\",\n\t\t\"TextLine\",\n\t\t\"Declaration\",\n\t\t\"$@4\",\n\t\t\"ConstantExpression\",\n\t\t\"DDD\",\n\t\t\"GroupList\",\n\t\t\"AssemblerOperand\",\n\t\t\"AssemblerSymbolicNameOpt\",\n\t\t\"GroupListOpt\",\n\t\t\"ReplacementList\",\n\t\t\"SpecifierQualifierList\",\n\t\t\"TypeQualifierList\",\n\t\t\"$@9\",\n\t\t\"AbstractDeclarator\",\n\t\t\"AssemblerOperands\",\n\t\t\"DeclarationSpecifiersOpt\",\n\t\t\"Designator\",\n\t\t\"Initializer\",\n\t\t\"ParameterDeclaration\",\n\t\t\"TypeName\",\n\t\t\"TypeQualifierListOpt\",\n\t\t\"AssemblerInstructions\",\n\t\t\"CommaOpt\",\n\t\t\"Designation\",\n\t\t\"DesignationOpt\",\n\t\t\"DesignatorList\",\n\t\t\"ExpressionOpt\",\n\t\t\"IdentifierList\",\n\t\t\"InitDeclarator\",\n\t\t\"ParameterList\",\n\t\t\"ParameterTypeList\",\n\t\t\"$@10\",\n\t\t\"$@14\",\n\t\t\"$@16\",\n\t\t\"$@17\",\n\t\t\"$@18\",\n\t\t\"$@5\",\n\t\t\"AbstractDeclaratorOpt\",\n\t\t\"BlockItem\",\n\t\t\"Clobbers\",\n\t\t\"DeclarationListOpt\",\n\t\t\"DeclaratorOpt\",\n\t\t\"DirectAbstractDeclarator\",\n\t\t\"DirectAbstractDeclaratorOpt\",\n\t\t\"DirectDeclarator\",\n\t\t\"ElifGroup\",\n\t\t\"EnumerationConstant\",\n\t\t\"Enumerator\",\n\t\t\"ExternalDeclaration\",\n\t\t\"FunctionBody\",\n\t\t\"FunctionDefinition\",\n\t\t\"IdentifierListOpt\",\n\t\t\"IdentifierOpt\",\n\t\t\"InitDeclaratorList\",\n\t\t\"InitDeclaratorListOpt\",\n\t\t\"InitializerList\",\n\t\t\"ParameterTypeListOpt\",\n\t\t\"SpecifierQualifierListOpt\",\n\t\t\"StructDeclaration\",\n\t\t\"StructDeclarator\",\n\t\t\"VolatileOpt\",\n\t\t\"$@1\",\n\t\t\"$@11\",\n\t\t\"$@12\",\n\t\t\"$@13\",\n\t\t\"$@15\",\n\t\t\"$@2\",\n\t\t\"$@3\",\n\t\t\"$@6\",\n\t\t\"$@7\",\n\t\t\"$@8\",\n\t\t\"ArgumentExpressionList\",\n\t\t\"ArgumentExpressionListOpt\",\n\t\t\"BlockItemList\",\n\t\t\"BlockItemListOpt\",\n\t\t\"CONSTANT_EXPRESSION\",\n\t\t\"DeclarationList\",\n\t\t\"ElifGroupList\",\n\t\t\"ElifGroupListOpt\",\n\t\t\"ElseGroup\",\n\t\t\"ElseGroupOpt\",\n\t\t\"EndifLine\",\n\t\t\"EnumeratorList\",\n\t\t\"IDENTIFIER_LPAREN\",\n\t\t\"PREPROCESSING_FILE\",\n\t\t\"PreprocessingFile\",\n\t\t\"Start\",\n\t\t\"StructDeclarationList\",\n\t\t\"StructDeclaratorList\",\n\t\t\"TRANSLATION_UNIT\",\n\t\t\"TranslationUnit\",\n\t\t\"$default\",\n\t\t\"CAST\",\n\t\t\"error\",\n\t\t\"IDENTIFIER_NONREPL\",\n\t\t\"NOELSE\",\n\t\t\"NOSEMI\",\n\t\t\"PPHEADER_NAME\",\n\t\t\"PPNUMBER\",\n\t\t\"PPPASTE\",\n\t\t\"UNARY\",\n\t}\n\n\tyyTokenLiteralStrings = map[int]string{\n\t\t57377:   \"identifier\",\n\t\t57348:   \"&&\",\n\t\t57363:   \"--\",\n\t\t57381:   \"++\",\n\t\t57428:   \"string literal\",\n\t\t57347:   \"_Alignof\",\n\t\t57358:   \"character constant\",\n\t\t57373:   \"floating-point constant\",\n\t\t57384:   \"integer constant\",\n\t\t57387:   \"long character constant\",\n\t\t57388:   \"long string constant\",\n\t\t57425:   \"sizeof\",\n\t\t57439:   \"volatile\",\n\t\t57360:   \"const\",\n\t\t57419:   \"restrict\",\n\t\t57353:   \"_Bool\",\n\t\t57357:   \"char\",\n\t\t57359:   \"_Complex\",\n\t\t57367:   \"double\",\n\t\t57369:   \"enum\",\n\t\t57372:   \"float\",\n\t\t57383:   \"int\",\n\t\t57386:   \"long\",\n\t\t57423:   \"short\",\n\t\t57424:   \"signed\",\n\t\t57429:   \"struct\",\n\t\t57433:   \"typedefname\",\n\t\t57434:   \"typeof\",\n\t\t57436:   \"union\",\n\t\t57437:   \"unsigned\",\n\t\t57438:   \"void\",\n\t\t57426:   \"static\",\n\t\t57352:   \"auto\",\n\t\t57371:   \"extern\",\n\t\t57382:   \"inline\",\n\t\t57395:   \"_Noreturn\",\n\t\t57418:   \"register\",\n\t\t57432:   \"typedef\",\n\t\t57351:   \"asm\",\n\t\t57427:   \"_Static_assert\",\n\t\t57346:   \"+=\",\n\t\t57349:   \"&=\",\n\t\t57350:   \"->\",\n\t\t57365:   \"/=\",\n\t\t57370:   \"==\",\n\t\t57375:   \">=\",\n\t\t57385:   \"<=\",\n\t\t57389:   \"<<\",\n\t\t57390:   \"<<=\",\n\t\t57391:   \"%=\",\n\t\t57392:   \"*=\",\n\t\t57393:   \"!=\",\n\t\t57397:   \"|=\",\n\t\t57398:   \"||\",\n\t\t57421:   \">>\",\n\t\t57422:   \">>=\",\n\t\t57430:   \"-=\",\n\t\t57441:   \"^=\",\n\t\t57376:   \"goto\",\n\t\t57440:   \"while\",\n\t\t57354:   \"break\",\n\t\t57355:   \"case\",\n\t\t57361:   \"continue\",\n\t\t57364:   \"default\",\n\t\t57366:   \"do\",\n\t\t57374:   \"for\",\n\t\t57380:   \"if\",\n\t\t57414:   \"ppother\",\n\t\t57420:   \"return\",\n\t\t57431:   \"switch\",\n\t\t57402:   \"#endif\",\n\t\t57401:   \"#else\",\n\t\t57400:   \"#elif\",\n\t\t57399:   \"#define\",\n\t\t57403:   \"#error\",\n\t\t57404:   \"#\",\n\t\t57406:   \"#if\",\n\t\t57407:   \"#ifdef\",\n\t\t57408:   \"#ifndef\",\n\t\t57409:   \"#include\",\n\t\t57410:   \"#include_next\",\n\t\t57411:   \"#line\",\n\t\t57412:   \"#foo\",\n\t\t57416:   \"#pragma\",\n\t\t57417:   \"#undef\",\n\t\t57368:   \"else\",\n\t\t57362:   \"...\",\n\t\t1048577: \"constant expression prefix\",\n\t\t57378:   \"identifier immediatelly followed by '('\",\n\t\t1048576: \"preprocessing file prefix\",\n\t\t1048578: \"translation unit prefix\",\n\t\t57379:   \"non replaceable identifier\",\n\t\t57405:   \"header name\",\n\t\t57413:   \"preprocessing number\",\n\t\t57415:   \"##\",\n\t}\n\n\tyyReductions = map[int]struct{ xsym, components int }{\n\t\t0:   {0, 1},\n\t\t1:   {204, 0},\n\t\t2:   {229, 3},\n\t\t3:   {209, 0},\n\t\t4:   {229, 3},\n\t\t5:   {210, 0},\n\t\t6:   {229, 3},\n\t\t7:   {189, 1},\n\t\t8:   {214, 1},\n\t\t9:   {214, 3},\n\t\t10:  {215, 0},\n\t\t11:  {215, 1},\n\t\t12:  {54, 1},\n\t\t13:  {54, 1},\n\t\t14:  {54, 1},\n\t\t15:  {54, 1},\n\t\t16:  {54, 1},\n\t\t17:  {54, 1},\n\t\t18:  {54, 1},\n\t\t19:  {54, 3},\n\t\t20:  {54, 4},\n\t\t21:  {54, 4},\n\t\t22:  {54, 3},\n\t\t23:  {54, 3},\n\t\t24:  {54, 2},\n\t\t25:  {54, 2},\n\t\t26:  {54, 7},\n\t\t27:  {54, 2},\n\t\t28:  {54, 2},\n\t\t29:  {54, 2},\n\t\t30:  {54, 2},\n\t\t31:  {54, 2},\n\t\t32:  {54, 2},\n\t\t33:  {54, 2},\n\t\t34:  {54, 2},\n\t\t35:  {54, 2},\n\t\t36:  {54, 4},\n\t\t37:  {54, 4},\n\t\t38:  {54, 3},\n\t\t39:  {54, 3},\n\t\t40:  {54, 3},\n\t\t41:  {54, 3},\n\t\t42:  {54, 3},\n\t\t43:  {54, 3},\n\t\t44:  {54, 3},\n\t\t45:  {54, 3},\n\t\t46:  {54, 3},\n\t\t47:  {54, 3},\n\t\t48:  {54, 3},\n\t\t49:  {54, 3},\n\t\t50:  {54, 3},\n\t\t51:  {54, 3},\n\t\t52:  {54, 3},\n\t\t53:  {54, 3},\n\t\t54:  {54, 3},\n\t\t55:  {54, 3},\n\t\t56:  {54, 5},\n\t\t57:  {54, 3},\n\t\t58:  {54, 3},\n\t\t59:  {54, 3},\n\t\t60:  {54, 3},\n\t\t61:  {54, 3},\n\t\t62:  {54, 3},\n\t\t63:  {54, 3},\n\t\t64:  {54, 3},\n\t\t65:  {54, 3},\n\t\t66:  {54, 3},\n\t\t67:  {54, 3},\n\t\t68:  {54, 4},\n\t\t69:  {54, 3},\n\t\t70:  {54, 2},\n\t\t71:  {54, 4},\n\t\t72:  {169, 0},\n\t\t73:  {169, 1},\n\t\t74:  {114, 1},\n\t\t75:  {114, 3},\n\t\t76:  {121, 0},\n\t\t77:  {121, 1},\n\t\t78:  {145, 0},\n\t\t79:  {146, 2},\n\t\t80:  {144, 3},\n\t\t81:  {144, 1},\n\t\t82:  {124, 2},\n\t\t83:  {124, 2},\n\t\t84:  {124, 2},\n\t\t85:  {124, 2},\n\t\t86:  {158, 0},\n\t\t87:  {158, 1},\n\t\t88:  {196, 1},\n\t\t89:  {196, 3},\n\t\t90:  {197, 0},\n\t\t91:  {197, 1},\n\t\t92:  {171, 1},\n\t\t93:  {179, 0},\n\t\t94:  {171, 4},\n\t\t95:  {127, 1},\n\t\t96:  {127, 1},\n\t\t97:  {127, 1},\n\t\t98:  {127, 1},\n\t\t99:  {127, 1},\n\t\t100: {120, 1},\n\t\t101: {120, 1},\n\t\t102: {120, 1},\n\t\t103: {120, 1},\n\t\t104: {120, 1},\n\t\t105: {120, 1},\n\t\t106: {120, 1},\n\t\t107: {120, 1},\n\t\t108: {120, 1},\n\t\t109: {120, 1},\n\t\t110: {120, 1},\n\t\t111: {120, 1},\n\t\t112: {120, 1},\n\t\t113: {120, 1},\n\t\t114: {120, 4},\n\t\t115: {120, 4},\n\t\t116: {211, 0},\n\t\t117: {119, 6},\n\t\t118: {119, 2},\n\t\t119: {119, 4},\n\t\t120: {118, 1},\n\t\t121: {118, 1},\n\t\t122: {230, 1},\n\t\t123: {230, 2},\n\t\t124: {201, 3},\n\t\t125: {201, 2},\n\t\t126: {201, 1},\n\t\t127: {153, 2},\n\t\t128: {153, 2},\n\t\t129: {200, 0},\n\t\t130: {200, 1},\n\t\t131: {231, 1},\n\t\t132: {231, 3},\n\t\t133: {202, 1},\n\t\t134: {202, 3},\n\t\t135: {165, 0},\n\t\t136: {165, 1},\n\t\t137: {212, 0},\n\t\t138: {117, 7},\n\t\t139: {117, 2},\n\t\t140: {225, 1},\n\t\t141: {225, 3},\n\t\t142: {190, 1},\n\t\t143: {190, 3},\n\t\t144: {113, 1},\n\t\t145: {113, 1},\n\t\t146: {113, 1},\n\t\t147: {125, 1},\n\t\t148: {125, 1},\n\t\t149: {137, 2},\n\t\t150: {184, 0},\n\t\t151: {184, 1},\n\t\t152: {187, 1},\n\t\t153: {187, 3},\n\t\t154: {187, 5},\n\t\t155: {187, 6},\n\t\t156: {187, 6},\n\t\t157: {187, 5},\n\t\t158: {213, 0},\n\t\t159: {187, 5},\n\t\t160: {187, 4},\n\t\t161: {133, 2},\n\t\t162: {133, 3},\n\t\t163: {136, 0},\n\t\t164: {136, 1},\n\t\t165: {154, 1},\n\t\t166: {154, 2},\n\t\t167: {163, 0},\n\t\t168: {163, 1},\n\t\t169: {173, 1},\n\t\t170: {173, 3},\n\t\t171: {199, 0},\n\t\t172: {199, 1},\n\t\t173: {172, 1},\n\t\t174: {172, 3},\n\t\t175: {161, 2},\n\t\t176: {161, 2},\n\t\t177: {170, 1},\n\t\t178: {170, 3},\n\t\t179: {194, 0},\n\t\t180: {194, 1},\n\t\t181: {195, 0},\n\t\t182: {195, 1},\n\t\t183: {155, 0},\n\t\t184: {162, 3},\n\t\t185: {156, 1},\n\t\t186: {156, 2},\n\t\t187: {180, 0},\n\t\t188: {180, 1},\n\t\t189: {185, 3},\n\t\t190: {185, 4},\n\t\t191: {185, 5},\n\t\t192: {185, 6},\n\t\t193: {185, 6},\n\t\t194: {185, 4},\n\t\t195: {174, 0},\n\t\t196: {185, 4},\n\t\t197: {205, 0},\n\t\t198: {185, 5},\n\t\t199: {186, 0},\n\t\t200: {186, 1},\n\t\t201: {160, 1},\n\t\t202: {160, 4},\n\t\t203: {160, 3},\n\t\t204: {198, 2},\n\t\t205: {198, 4},\n\t\t206: {198, 0},\n\t\t207: {166, 2},\n\t\t208: {167, 0},\n\t\t209: {167, 1},\n\t\t210: {168, 1},\n\t\t211: {168, 2},\n\t\t212: {159, 3},\n\t\t213: {159, 2},\n\t\t214: {135, 1},\n\t\t215: {135, 1},\n\t\t216: {135, 1},\n\t\t217: {135, 1},\n\t\t218: {135, 1},\n\t\t219: {135, 1},\n\t\t220: {135, 1},\n\t\t221: {132, 3},\n\t\t222: {132, 4},\n\t\t223: {132, 3},\n\t\t224: {206, 0},\n\t\t225: {123, 4},\n\t\t226: {216, 1},\n\t\t227: {216, 2},\n\t\t228: {217, 0},\n\t\t229: {217, 1},\n\t\t230: {181, 1},\n\t\t231: {181, 1},\n\t\t232: {129, 2},\n\t\t233: {134, 5},\n\t\t234: {134, 7},\n\t\t235: {134, 5},\n\t\t236: {130, 5},\n\t\t237: {130, 7},\n\t\t238: {130, 9},\n\t\t239: {130, 8},\n\t\t240: {131, 3},\n\t\t241: {131, 2},\n\t\t242: {131, 2},\n\t\t243: {131, 3},\n\t\t244: {131, 3},\n\t\t245: {233, 1},\n\t\t246: {233, 2},\n\t\t247: {191, 1},\n\t\t248: {191, 1},\n\t\t249: {191, 2},\n\t\t250: {191, 1},\n\t\t251: {207, 0},\n\t\t252: {193, 5},\n\t\t253: {175, 0},\n\t\t254: {208, 0},\n\t\t255: {193, 5},\n\t\t256: {176, 0},\n\t\t257: {192, 2},\n\t\t258: {177, 0},\n\t\t259: {192, 3},\n\t\t260: {219, 1},\n\t\t261: {219, 2},\n\t\t262: {183, 0},\n\t\t263: {178, 0},\n\t\t264: {183, 2},\n\t\t265: {164, 1},\n\t\t266: {164, 2},\n\t\t267: {122, 5},\n\t\t268: {203, 0},\n\t\t269: {203, 1},\n\t\t270: {149, 5},\n\t\t271: {157, 1},\n\t\t272: {157, 3},\n\t\t273: {150, 0},\n\t\t274: {150, 3},\n\t\t275: {182, 1},\n\t\t276: {182, 3},\n\t\t277: {128, 1},\n\t\t278: {128, 7},\n\t\t279: {128, 9},\n\t\t280: {128, 11},\n\t\t281: {128, 13},\n\t\t282: {128, 6},\n\t\t283: {128, 8},\n\t\t284: {138, 7},\n\t\t285: {228, 1},\n\t\t286: {148, 1},\n\t\t287: {148, 2},\n\t\t288: {151, 0},\n\t\t289: {151, 1},\n\t\t290: {140, 1},\n\t\t291: {140, 1},\n\t\t292: {140, 3},\n\t\t293: {140, 1},\n\t\t294: {142, 4},\n\t\t295: {141, 4},\n\t\t296: {141, 4},\n\t\t297: {141, 4},\n\t\t298: {220, 1},\n\t\t299: {220, 2},\n\t\t300: {221, 0},\n\t\t301: {221, 1},\n\t\t302: {188, 4},\n\t\t303: {222, 3},\n\t\t304: {223, 0},\n\t\t305: {223, 1},\n\t\t306: {224, 1},\n\t\t307: {139, 3},\n\t\t308: {139, 5},\n\t\t309: {139, 7},\n\t\t310: {139, 5},\n\t\t311: {139, 2},\n\t\t312: {139, 1},\n\t\t313: {139, 3},\n\t\t314: {139, 3},\n\t\t315: {139, 2},\n\t\t316: {139, 3},\n\t\t317: {139, 6},\n\t\t318: {139, 2},\n\t\t319: {139, 4},\n\t\t320: {139, 3},\n\t\t321: {143, 1},\n\t\t322: {152, 1},\n\t\t323: {115, 1},\n\t\t324: {126, 1},\n\t\t325: {126, 2},\n\t\t326: {116, 1},\n\t\t327: {116, 2},\n\t}\n\n\tyyXErrors = map[yyXError]string{\n\t\t{0, 51}:   \"invalid empty input\",\n\t\t{583, -1}: \"expected #endif\",\n\t\t{585, -1}: \"expected #endif\",\n\t\t{1, -1}:   \"expected $end\",\n\t\t{503, -1}: \"expected $end\",\n\t\t{505, -1}: \"expected $end\",\n\t\t{32, -1}:  \"expected '('\",\n\t\t{49, -1}:  \"expected '('\",\n\t\t{75, -1}:  \"expected '('\",\n\t\t{274, -1}: \"expected '('\",\n\t\t{275, -1}: \"expected '('\",\n\t\t{276, -1}: \"expected '('\",\n\t\t{278, -1}: \"expected '('\",\n\t\t{288, -1}: \"expected '('\",\n\t\t{311, -1}: \"expected '('\",\n\t\t{353, -1}: \"expected '('\",\n\t\t{435, -1}: \"expected '('\",\n\t\t{54, -1}:  \"expected ')'\",\n\t\t{79, -1}:  \"expected ')'\",\n\t\t{86, -1}:  \"expected ')'\",\n\t\t{180, -1}: \"expected ')'\",\n\t\t{195, -1}: \"expected ')'\",\n\t\t{198, -1}: \"expected ')'\",\n\t\t{201, -1}: \"expected ')'\",\n\t\t{209, -1}: \"expected ')'\",\n\t\t{214, -1}: \"expected ')'\",\n\t\t{220, -1}: \"expected ')'\",\n\t\t{236, -1}: \"expected ')'\",\n\t\t{241, -1}: \"expected ')'\",\n\t\t{252, -1}: \"expected ')'\",\n\t\t{253, -1}: \"expected ')'\",\n\t\t{343, -1}: \"expected ')'\",\n\t\t{349, -1}: \"expected ')'\",\n\t\t{433, -1}: \"expected ')'\",\n\t\t{489, -1}: \"expected ')'\",\n\t\t{547, -1}: \"expected ')'\",\n\t\t{548, -1}: \"expected ')'\",\n\t\t{555, -1}: \"expected ')'\",\n\t\t{558, -1}: \"expected ')'\",\n\t\t{52, -1}:  \"expected ','\",\n\t\t{267, -1}: \"expected ':'\",\n\t\t{293, -1}: \"expected ':'\",\n\t\t{377, -1}: \"expected ':'\",\n\t\t{479, -1}: \"expected ':'\",\n\t\t{45, -1}:  \"expected ';'\",\n\t\t{55, -1}:  \"expected ';'\",\n\t\t{273, -1}: \"expected ';'\",\n\t\t{280, -1}: \"expected ';'\",\n\t\t{281, -1}: \"expected ';'\",\n\t\t{330, -1}: \"expected ';'\",\n\t\t{339, -1}: \"expected ';'\",\n\t\t{341, -1}: \"expected ';'\",\n\t\t{347, -1}: \"expected ';'\",\n\t\t{356, -1}: \"expected ';'\",\n\t\t{380, -1}: \"expected ';'\",\n\t\t{448, -1}: \"expected ';'\",\n\t\t{387, -1}: \"expected '='\",\n\t\t{91, -1}:  \"expected '['\",\n\t\t{527, -1}: \"expected '\\\\n'\",\n\t\t{531, -1}: \"expected '\\\\n'\",\n\t\t{535, -1}: \"expected '\\\\n'\",\n\t\t{538, -1}: \"expected '\\\\n'\",\n\t\t{540, -1}: \"expected '\\\\n'\",\n\t\t{562, -1}: \"expected '\\\\n'\",\n\t\t{567, -1}: \"expected '\\\\n'\",\n\t\t{570, -1}: \"expected '\\\\n'\",\n\t\t{577, -1}: \"expected '\\\\n'\",\n\t\t{582, -1}: \"expected '\\\\n'\",\n\t\t{588, -1}: \"expected '\\\\n'\",\n\t\t{97, -1}:  \"expected ']'\",\n\t\t{188, -1}: \"expected ']'\",\n\t\t{232, -1}: \"expected ']'\",\n\t\t{299, -1}: \"expected ']'\",\n\t\t{401, -1}: \"expected ']'\",\n\t\t{452, -1}: \"expected '{'\",\n\t\t{454, -1}: \"expected '{'\",\n\t\t{466, -1}: \"expected '{'\",\n\t\t{268, -1}: \"expected '}'\",\n\t\t{407, -1}: \"expected '}'\",\n\t\t{423, -1}: \"expected '}'\",\n\t\t{463, -1}: \"expected '}'\",\n\t\t{0, -1}:   \"expected Start or one of [constant expression prefix, preprocessing file prefix, translation unit prefix]\",\n\t\t{208, -1}: \"expected abstract declarator or declarator or optional parameter type list or one of ['(', ')', '*', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{90, -1}:  \"expected abstract declarator or optional parameter type list or one of ['(', ')', '*', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{287, -1}: \"expected assembler instructions or string literal\",\n\t\t{289, -1}: \"expected assembler instructions or string literal\",\n\t\t{436, -1}: \"expected assembler instructions or string literal\",\n\t\t{301, -1}: \"expected assembler operand or one of ['[', string literal]\",\n\t\t{317, -1}: \"expected assembler operands or one of [')', ':', '[', string literal]\",\n\t\t{294, -1}: \"expected assembler operands or one of ['[', string literal]\",\n\t\t{320, -1}: \"expected assembler operands or one of ['[', string literal]\",\n\t\t{324, -1}: \"expected assembler operands or one of ['[', string literal]\",\n\t\t{447, -1}: \"expected assembler statement or asm\",\n\t\t{270, -1}: \"expected block item or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{302, -1}: \"expected clobbers or string literal\",\n\t\t{327, -1}: \"expected clobbers or string literal\",\n\t\t{446, -1}: \"expected compound statement or '{'\",\n\t\t{64, -1}:  \"expected compound statement or expression list or type name or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{249, -1}: \"expected compound statement or expression list or type name or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{3, -1}:   \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{50, -1}:  \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{266, -1}: \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{398, -1}: \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{460, -1}: \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{480, -1}: \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{502, -1}: \"expected constant expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{440, -1}: \"expected declaration list or one of [_Bool, _Complex, _Noreturn, _Static_assert, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{442, -1}: \"expected declaration or one of ['{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{338, -1}: \"expected declaration or optional expression list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{47, -1}:  \"expected declarator or one of ['(', '*', identifier]\",\n\t\t{386, -1}: \"expected declarator or one of ['(', '*', identifier]\",\n\t\t{200, -1}: \"expected declarator or optional abstract declarator or one of ['(', ')', '*', ',', '[', identifier]\",\n\t\t{7, -1}:   \"expected declarator or optional init declarator list or one of ['(', '*', ';', identifier]\",\n\t\t{395, -1}: \"expected designator or one of ['.', '=', '[']\",\n\t\t{203, -1}: \"expected direct abstract declarator or direct declarator or one of ['(', '[', identifier]\",\n\t\t{87, -1}:  \"expected direct abstract declarator or one of ['(', '[']\",\n\t\t{384, -1}: \"expected direct declarator or one of ['(', identifier]\",\n\t\t{575, -1}: \"expected elif group or one of [#elif, #else, #endif]\",\n\t\t{581, -1}: \"expected endif line or #endif\",\n\t\t{512, -1}: \"expected endif line or optional elif group list or optional else group or one of [#elif, #else, #endif]\",\n\t\t{573, -1}: \"expected endif line or optional else group or one of [#else, #endif]\",\n\t\t{455, -1}: \"expected enumerator list or identifier\",\n\t\t{462, -1}: \"expected enumerator or one of ['}', identifier]\",\n\t\t{126, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', ':', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{102, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{354, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{358, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{362, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{366, -1}: \"expected expression list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{419, -1}: \"expected expression or one of [!=, $end, %=, &&, &=, '!', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '{', '|', '}', '~', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal, |=, ||]\",\n\t\t{94, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{231, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{434, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{51, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{66, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{67, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{68, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{69, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{70, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{71, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{72, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{73, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{74, -1}:  \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{100, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{108, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{109, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{110, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{111, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{112, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{113, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{114, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{115, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{116, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{117, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{118, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{119, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{120, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{121, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{122, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{123, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{124, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{125, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{127, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{128, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{129, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{130, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{131, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{132, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{133, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{134, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{135, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{136, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{137, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{152, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{154, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{155, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{182, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{189, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{225, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{228, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{279, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{312, -1}: \"expected expression or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{98, -1}:  \"expected expression or optional type qualifier list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{223, -1}: \"expected expression or optional type qualifier list or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{487, -1}: \"expected expression or type name or one of [&&, '!', '&', '(', '*', '+', '-', '~', ++, --, _Alignof, _Bool, _Complex, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{6, -1}:   \"expected external declaration or one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{439, -1}: \"expected function body or one of ['{', asm]\",\n\t\t{444, -1}: \"expected function body or one of ['{', asm]\",\n\t\t{498, -1}: \"expected function body or one of ['{', asm]\",\n\t\t{499, -1}: \"expected function body or one of ['{', asm]\",\n\t\t{497, -1}: \"expected function body or optional declaration list or one of [',', ';', '=', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{438, -1}: \"expected function body or optional declaration list or one of ['{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{564, -1}: \"expected group part or one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{506, -1}: \"expected group part or one of [#, #define, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{76, -1}:  \"expected identifier\",\n\t\t{104, -1}: \"expected identifier\",\n\t\t{105, -1}: \"expected identifier\",\n\t\t{217, -1}: \"expected identifier\",\n\t\t{298, -1}: \"expected identifier\",\n\t\t{399, -1}: \"expected identifier\",\n\t\t{514, -1}: \"expected identifier\",\n\t\t{515, -1}: \"expected identifier\",\n\t\t{522, -1}: \"expected identifier\",\n\t\t{306, -1}: \"expected identifier list or identifier\",\n\t\t{544, -1}: \"expected identifier list or optional identifier list or one of [')', ..., identifier]\",\n\t\t{413, -1}: \"expected init declarator or one of ['(', '*', identifier]\",\n\t\t{392, -1}: \"expected initializer list or optional comma or one of [&&, '!', '&', '(', '*', '+', ',', '-', '.', '[', '{', '}', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{421, -1}: \"expected initializer list or optional comma or one of [&&, '!', '&', '(', '*', '+', ',', '-', '.', '[', '{', '}', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{388, -1}: \"expected initializer or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{394, -1}: \"expected initializer or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{409, -1}: \"expected initializer or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{411, -1}: \"expected initializer or one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{406, -1}: \"expected initializer or optional designation or one of [&&, '!', '&', '(', '*', '+', '-', '.', '[', '{', '}', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{57, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{58, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{59, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{60, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{61, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{62, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{63, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{77, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{106, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{107, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{139, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{140, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{141, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{142, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{143, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{144, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{145, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{146, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{147, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{148, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{149, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{153, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{157, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{158, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{159, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{160, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{161, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{162, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{163, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{164, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{165, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{166, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{167, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{168, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{169, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{170, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{171, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{172, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{173, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{174, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{175, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{176, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{177, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{181, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{185, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{193, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{248, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{250, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{418, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{420, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{424, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{425, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{426, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{427, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{428, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{429, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{430, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{431, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{432, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{65, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{150, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{156, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{178, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{183, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{313, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{488, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{389, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{256, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{390, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ';', '<', '=', '>', '?', '[', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{334, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', ';', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{335, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', ';', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{93, -1}:  \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{101, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{190, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{226, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{229, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{507, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{508, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{509, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{511, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{518, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{524, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{526, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{529, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{532, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{534, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{536, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{537, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{539, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{541, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{542, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{545, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{550, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{551, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{553, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{557, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{560, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{561, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{566, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{586, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{587, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{589, -1}: \"expected one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, $end, '\\\\n', ppother]\",\n\t\t{565, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{569, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{572, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{574, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{579, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{580, -1}: \"expected one of [#elif, #else, #endif]\",\n\t\t{374, -1}: \"expected one of [$end, &&, '!', '&', '(', ')', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{8, -1}:   \"expected one of [$end, &&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{56, -1}:  \"expected one of [$end, &&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{415, -1}: \"expected one of [$end, &&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{42, -1}:  \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{43, -1}:  \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{44, -1}:  \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{46, -1}:  \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{445, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{449, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{450, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{451, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{500, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{501, -1}: \"expected one of [$end, '(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{37, -1}:  \"expected one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{38, -1}:  \"expected one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{39, -1}:  \"expected one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{95, -1}:  \"expected one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', '[', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{186, -1}: \"expected one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', '[', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{259, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{260, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{261, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{262, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{263, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{264, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{265, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{284, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{308, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{316, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{319, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{322, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{323, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{326, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{329, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{331, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{332, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{333, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{336, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{337, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{345, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{351, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{357, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{361, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{365, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{369, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{371, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{372, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{376, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{379, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{417, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{269, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{271, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{272, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{373, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{396, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{403, -1}: \"expected one of [&&, '!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{453, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', '{', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{467, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', '{', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{18, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{19, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{20, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{21, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{22, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{23, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{24, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{25, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{26, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{27, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{28, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{29, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{30, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{31, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{464, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{470, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{485, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{490, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{491, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{13, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{14, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{15, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{16, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{17, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{40, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{41, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{492, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{493, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{494, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{495, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{496, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{245, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{246, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{247, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{206, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{207, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{210, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{219, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{221, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{227, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{230, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{233, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{234, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{85, -1}:  \"expected one of ['(', ')', ',', '[', identifier]\",\n\t\t{244, -1}: \"expected one of ['(', ')', ',', '[', identifier]\",\n\t\t{89, -1}:  \"expected one of ['(', ')', ',', '[']\",\n\t\t{138, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{187, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{191, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{192, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{194, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{202, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{238, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{242, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{285, -1}: \"expected one of ['(', goto]\",\n\t\t{286, -1}: \"expected one of ['(', goto]\",\n\t\t{385, -1}: \"expected one of ['(', identifier]\",\n\t\t{296, -1}: \"expected one of [')', ',', ':']\",\n\t\t{303, -1}: \"expected one of [')', ',', ':']\",\n\t\t{309, -1}: \"expected one of [')', ',', ':']\",\n\t\t{310, -1}: \"expected one of [')', ',', ':']\",\n\t\t{314, -1}: \"expected one of [')', ',', ':']\",\n\t\t{318, -1}: \"expected one of [')', ',', ':']\",\n\t\t{325, -1}: \"expected one of [')', ',', ':']\",\n\t\t{257, -1}: \"expected one of [')', ',', ';']\",\n\t\t{215, -1}: \"expected one of [')', ',', ...]\",\n\t\t{218, -1}: \"expected one of [')', ',', ...]\",\n\t\t{546, -1}: \"expected one of [')', ',', ...]\",\n\t\t{88, -1}:  \"expected one of [')', ',']\",\n\t\t{179, -1}: \"expected one of [')', ',']\",\n\t\t{197, -1}: \"expected one of [')', ',']\",\n\t\t{199, -1}: \"expected one of [')', ',']\",\n\t\t{204, -1}: \"expected one of [')', ',']\",\n\t\t{205, -1}: \"expected one of [')', ',']\",\n\t\t{216, -1}: \"expected one of [')', ',']\",\n\t\t{237, -1}: \"expected one of [')', ',']\",\n\t\t{251, -1}: \"expected one of [')', ',']\",\n\t\t{307, -1}: \"expected one of [')', ',']\",\n\t\t{321, -1}: \"expected one of [')', ',']\",\n\t\t{328, -1}: \"expected one of [')', ',']\",\n\t\t{355, -1}: \"expected one of [')', ',']\",\n\t\t{359, -1}: \"expected one of [')', ',']\",\n\t\t{363, -1}: \"expected one of [')', ',']\",\n\t\t{367, -1}: \"expected one of [')', ',']\",\n\t\t{290, -1}: \"expected one of [')', ':', string literal]\",\n\t\t{292, -1}: \"expected one of [')', ':', string literal]\",\n\t\t{315, -1}: \"expected one of [')', ':', string literal]\",\n\t\t{437, -1}: \"expected one of [')', string literal]\",\n\t\t{478, -1}: \"expected one of [',', ':', ';']\",\n\t\t{151, -1}: \"expected one of [',', ':']\",\n\t\t{297, -1}: \"expected one of [',', ':']\",\n\t\t{304, -1}: \"expected one of [',', ':']\",\n\t\t{383, -1}: \"expected one of [',', ';', '=']\",\n\t\t{408, -1}: \"expected one of [',', ';', '}']\",\n\t\t{412, -1}: \"expected one of [',', ';', '}']\",\n\t\t{381, -1}: \"expected one of [',', ';']\",\n\t\t{382, -1}: \"expected one of [',', ';']\",\n\t\t{391, -1}: \"expected one of [',', ';']\",\n\t\t{414, -1}: \"expected one of [',', ';']\",\n\t\t{475, -1}: \"expected one of [',', ';']\",\n\t\t{477, -1}: \"expected one of [',', ';']\",\n\t\t{481, -1}: \"expected one of [',', ';']\",\n\t\t{484, -1}: \"expected one of [',', ';']\",\n\t\t{456, -1}: \"expected one of [',', '=', '}']\",\n\t\t{459, -1}: \"expected one of [',', '=', '}']\",\n\t\t{184, -1}: \"expected one of [',', ']']\",\n\t\t{405, -1}: \"expected one of [',', '}']\",\n\t\t{410, -1}: \"expected one of [',', '}']\",\n\t\t{458, -1}: \"expected one of [',', '}']\",\n\t\t{461, -1}: \"expected one of [',', '}']\",\n\t\t{465, -1}: \"expected one of [',', '}']\",\n\t\t{397, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{400, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{402, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{404, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{291, -1}: \"expected one of [':', string literal]\",\n\t\t{516, -1}: \"expected one of ['\\\\n', identifier, identifier immediatelly followed by '(']\",\n\t\t{525, -1}: \"expected one of ['\\\\n', ppother]\",\n\t\t{528, -1}: \"expected one of ['\\\\n', ppother]\",\n\t\t{530, -1}: \"expected one of ['\\\\n', ppother]\",\n\t\t{441, -1}: \"expected one of ['{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{443, -1}: \"expected one of ['{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{34, -1}:  \"expected one of ['{', identifier]\",\n\t\t{35, -1}:  \"expected one of ['{', identifier]\",\n\t\t{472, -1}: \"expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{474, -1}: \"expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{476, -1}: \"expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{482, -1}: \"expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{486, -1}: \"expected one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{554, -1}: \"expected one of [..., identifier]\",\n\t\t{83, -1}:  \"expected optional abstract declarator or one of ['(', ')', '*', '[']\",\n\t\t{103, -1}: \"expected optional argument expression list or one of [&&, '!', '&', '(', ')', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{254, -1}: \"expected optional block item list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{255, -1}: \"expected optional block item list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Alignof, _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedefname, typeof, union, unsigned, void, volatile, while]\",\n\t\t{393, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{422, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{457, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{9, -1}:   \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{10, -1}:  \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{11, -1}:  \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{12, -1}:  \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{342, -1}: \"expected optional expression list or one of [&&, '!', '&', '(', ')', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{348, -1}: \"expected optional expression list or one of [&&, '!', '&', '(', ')', '*', '+', '-', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{282, -1}: \"expected optional expression list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{340, -1}: \"expected optional expression list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{346, -1}: \"expected optional expression list or one of [&&, '!', '&', '(', '*', '+', '-', ';', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{222, -1}: \"expected optional expression or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{211, -1}: \"expected optional expression or optional type qualifier list or type qualifier list or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{92, -1}:  \"expected optional expression or type qualifier list or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{96, -1}:  \"expected optional expression or type qualifier or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{563, -1}: \"expected optional group list or one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{568, -1}: \"expected optional group list or one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{571, -1}: \"expected optional group list or one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{578, -1}: \"expected optional group list or one of [#, #define, #elif, #else, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{584, -1}: \"expected optional group list or one of [#, #define, #endif, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{212, -1}: \"expected optional identifier list or parameter type list or one of [')', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{33, -1}:  \"expected optional identifier or one of ['{', identifier]\",\n\t\t{36, -1}:  \"expected optional identifier or one of ['{', identifier]\",\n\t\t{258, -1}: \"expected optional init declarator list or one of ['(', '*', ';', identifier]\",\n\t\t{196, -1}: \"expected optional parameter type list or one of [')', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{239, -1}: \"expected optional parameter type list or one of [')', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{240, -1}: \"expected optional parameter type list or one of [')', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{81, -1}:  \"expected optional specifier qualifier list or one of ['(', ')', '*', ':', ';', '[', _Bool, _Complex, char, const, double, enum, float, identifier, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{82, -1}:  \"expected optional specifier qualifier list or one of ['(', ')', '*', ':', ';', '[', _Bool, _Complex, char, const, double, enum, float, identifier, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{517, -1}: \"expected optional token list or one of ['\\\\n', ppother]\",\n\t\t{521, -1}: \"expected optional token list or one of ['\\\\n', ppother]\",\n\t\t{84, -1}:  \"expected optional type qualifier list or pointer or one of ['(', ')', '*', ',', '[', const, identifier, restrict, volatile]\",\n\t\t{283, -1}: \"expected optional volatile or one of ['(', goto, volatile]\",\n\t\t{48, -1}:  \"expected optional volatile or one of ['(', volatile]\",\n\t\t{235, -1}: \"expected parameter declaration or one of [..., _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{213, -1}: \"expected parameter type list or one of [_Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{243, -1}: \"expected pointer or one of ['(', ')', '*', ',', '[', identifier]\",\n\t\t{2, -1}:   \"expected preprocessing file or one of [#, #define, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{504, -1}: \"expected preprocessing file or one of [#, #define, #error, #foo, #if, #ifdef, #ifndef, #include, #include_next, #line, #pragma, #undef, '\\\\n', ppother]\",\n\t\t{543, -1}: \"expected replacement list or one of ['\\\\n', ppother]\",\n\t\t{549, -1}: \"expected replacement list or one of ['\\\\n', ppother]\",\n\t\t{552, -1}: \"expected replacement list or one of ['\\\\n', ppother]\",\n\t\t{556, -1}: \"expected replacement list or one of ['\\\\n', ppother]\",\n\t\t{559, -1}: \"expected replacement list or one of ['\\\\n', ppother]\",\n\t\t{80, -1}:  \"expected specifier qualifier list or one of [_Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{277, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{344, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{350, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{360, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{364, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{368, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{370, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{375, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{378, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{416, -1}: \"expected statement or one of [&&, '!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, _Alignof, asm, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, while]\",\n\t\t{53, -1}:  \"expected string literal\",\n\t\t{295, -1}: \"expected string literal\",\n\t\t{300, -1}: \"expected string literal\",\n\t\t{305, -1}: \"expected string literal\",\n\t\t{468, -1}: \"expected struct declaration list or one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{469, -1}: \"expected struct declaration list or one of [_Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{471, -1}: \"expected struct declaration or one of ['}', _Bool, _Complex, _Static_assert, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{473, -1}: \"expected struct declarator list or one of ['(', '*', ':', ';', identifier]\",\n\t\t{483, -1}: \"expected struct declarator or one of ['(', '*', ':', identifier]\",\n\t\t{533, -1}: \"expected token list or one of ['\\\\n', ppother]\",\n\t\t{510, -1}: \"expected token list or ppother\",\n\t\t{513, -1}: \"expected token list or ppother\",\n\t\t{519, -1}: \"expected token list or ppother\",\n\t\t{520, -1}: \"expected token list or ppother\",\n\t\t{523, -1}: \"expected token list or ppother\",\n\t\t{576, -1}: \"expected token list or ppother\",\n\t\t{4, -1}:   \"expected translation unit or one of ['(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{5, -1}:   \"expected translation unit or one of ['(', '*', ';', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{78, -1}:  \"expected type name or one of [_Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedefname, typeof, union, unsigned, void, volatile]\",\n\t\t{99, -1}:  \"expected type qualifier or one of [&&, '!', '&', '(', ')', '*', '+', ',', '-', '[', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{224, -1}: \"expected type qualifier or one of [&&, '!', '&', '(', '*', '+', '-', ']', '~', ++, --, _Alignof, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{352, -1}: \"expected while\",\n\t\t{3, 51}:   \"unexpected EOF\",\n\t\t{2, 51}:   \"unexpected EOF\",\n\t\t{4, 51}:   \"unexpected EOF\",\n\t}\n\n\tyyParseTab = [590][]uint16{\n\t\t// 0\n\t\t{218: 331, 227: 330, 229: 329, 232: 332},\n\t\t{51: 328},\n\t\t{84: 327, 94: 327, 100: 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 327, 204: 832},\n\t\t{325, 325, 325, 325, 325, 325, 325, 325, 325, 12: 325, 14: 325, 325, 325, 325, 325, 325, 325, 325, 325, 209: 830},\n\t\t{323, 323, 323, 9: 323, 23: 323, 323, 323, 27: 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 323, 44: 323, 323, 323, 323, 323, 323, 323, 57: 323, 323, 210: 333},\n\t\t// 5\n\t\t{75, 75, 75, 9: 374, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 57: 376, 377, 113: 339, 117: 358, 361, 357, 338, 122: 373, 124: 335, 340, 127: 337, 138: 336, 144: 372, 175: 375, 191: 370, 193: 371, 233: 334},\n\t\t{75, 75, 75, 9: 374, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 322, 57: 376, 377, 113: 339, 117: 358, 361, 357, 338, 122: 373, 124: 335, 340, 127: 337, 138: 336, 144: 372, 175: 375, 191: 829, 193: 371},\n\t\t{165, 412, 165, 9: 238, 133: 713, 136: 712, 825, 171: 709, 196: 710, 708},\n\t\t{247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 12: 247, 14: 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 44: 247, 247, 247, 247, 247, 247, 247, 247, 53: 247, 57: 247, 247, 85: 247, 247, 247, 247, 247, 247, 247, 247, 247, 95: 247, 247},\n\t\t{242, 242, 242, 9: 242, 242, 242, 13: 242, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 821, 340, 127: 337, 158: 824},\n\t\t// 10\n\t\t{242, 242, 242, 9: 242, 242, 242, 13: 242, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 821, 340, 127: 337, 158: 823},\n\t\t{242, 242, 242, 9: 242, 242, 242, 13: 242, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 821, 340, 127: 337, 158: 822},\n\t\t{242, 242, 242, 9: 242, 242, 242, 13: 242, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 821, 340, 127: 337, 158: 820},\n\t\t{233, 233, 233, 9: 233, 233, 233, 13: 233, 23: 233, 233, 233, 27: 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 44: 233, 233, 233, 233, 233, 233, 233},\n\t\t{232, 232, 232, 9: 232, 232, 232, 13: 232, 23: 232, 232, 232, 27: 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 44: 232, 232, 232, 232, 232, 232, 232},\n\t\t// 15\n\t\t{231, 231, 231, 9: 231, 231, 231, 13: 231, 23: 231, 231, 231, 27: 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 44: 231, 231, 231, 231, 231, 231, 231},\n\t\t{230, 230, 230, 9: 230, 230, 230, 13: 230, 23: 230, 230, 230, 27: 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 44: 230, 230, 230, 230, 230, 230, 230},\n\t\t{229, 229, 229, 9: 229, 229, 229, 13: 229, 23: 229, 229, 229, 27: 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 44: 229, 229, 229, 229, 229, 229, 229},\n\t\t{228, 228, 228, 9: 228, 228, 228, 13: 228, 23: 228, 228, 228, 27: 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228},\n\t\t{227, 227, 227, 9: 227, 227, 227, 13: 227, 23: 227, 227, 227, 27: 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227},\n\t\t// 20\n\t\t{226, 226, 226, 9: 226, 226, 226, 13: 226, 23: 226, 226, 226, 27: 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226},\n\t\t{225, 225, 225, 9: 225, 225, 225, 13: 225, 23: 225, 225, 225, 27: 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225},\n\t\t{224, 224, 224, 9: 224, 224, 224, 13: 224, 23: 224, 224, 224, 27: 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224},\n\t\t{223, 223, 223, 9: 223, 223, 223, 13: 223, 23: 223, 223, 223, 27: 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223},\n\t\t{222, 222, 222, 9: 222, 222, 222, 13: 222, 23: 222, 222, 222, 27: 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222, 222},\n\t\t// 25\n\t\t{221, 221, 221, 9: 221, 221, 221, 13: 221, 23: 221, 221, 221, 27: 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221},\n\t\t{220, 220, 220, 9: 220, 220, 220, 13: 220, 23: 220, 220, 220, 27: 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220},\n\t\t{219, 219, 219, 9: 219, 219, 219, 13: 219, 23: 219, 219, 219, 27: 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219, 219},\n\t\t{218, 218, 218, 9: 218, 218, 218, 13: 218, 23: 218, 218, 218, 27: 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218},\n\t\t{217, 217, 217, 9: 217, 217, 217, 13: 217, 23: 217, 217, 217, 27: 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217},\n\t\t// 30\n\t\t{216, 216, 216, 9: 216, 216, 216, 13: 216, 23: 216, 216, 216, 27: 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, 216},\n\t\t{215, 215, 215, 9: 215, 215, 215, 13: 215, 23: 215, 215, 215, 27: 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215},\n\t\t{815},\n\t\t{2: 795, 53: 147, 195: 794},\n\t\t{2: 208, 53: 208},\n\t\t// 35\n\t\t{2: 207, 53: 207},\n\t\t{2: 781, 53: 147, 195: 780},\n\t\t{184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 27: 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 55: 184},\n\t\t{183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 27: 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 55: 183},\n\t\t{182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 27: 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 55: 182},\n\t\t// 40\n\t\t{181, 181, 181, 9: 181, 181, 181, 13: 181, 23: 181, 181, 181, 27: 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 44: 181, 181, 181, 181, 181, 181, 181},\n\t\t{180, 180, 180, 9: 180, 180, 180, 13: 180, 23: 180, 180, 180, 27: 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 44: 180, 180, 180, 180, 180, 180, 180},\n\t\t{83, 83, 83, 9: 83, 23: 83, 83, 83, 27: 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 44: 83, 83, 83, 83, 83, 83, 83, 83, 57: 83, 83},\n\t\t{81, 81, 81, 9: 81, 23: 81, 81, 81, 27: 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 44: 81, 81, 81, 81, 81, 81, 81, 81, 57: 81, 81},\n\t\t{80, 80, 80, 9: 80, 23: 80, 80, 80, 27: 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 44: 80, 80, 80, 80, 80, 80, 80, 80, 57: 80, 80},\n\t\t// 45\n\t\t{9: 779},\n\t\t{78, 78, 78, 9: 78, 23: 78, 78, 78, 27: 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 44: 78, 78, 78, 78, 78, 78, 78, 78, 57: 78, 78},\n\t\t{165, 412, 165, 133: 713, 136: 712, 766},\n\t\t{60, 23: 614, 203: 763},\n\t\t{378},\n\t\t// 50\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 380},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 393},\n\t\t{11: 381},\n\t\t{12: 382},\n\t\t{10: 383},\n\t\t// 55\n\t\t{9: 384},\n\t\t{44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 12: 44, 14: 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44: 44, 44, 44, 44, 44, 44, 44, 44, 53: 44, 57: 44, 44, 85: 44, 44, 44, 44, 44, 44, 44, 44, 44, 95: 44, 44},\n\t\t{316, 316, 3: 316, 316, 316, 316, 316, 316, 316, 316, 316, 13: 316, 26: 316, 43: 316, 51: 316, 316, 55: 316, 316, 59: 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316},\n\t\t{315, 315, 3: 315, 315, 315, 315, 315, 315, 315, 315, 315, 13: 315, 26: 315, 43: 315, 51: 315, 315, 55: 315, 315, 59: 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, 315},\n\t\t{314, 314, 3: 314, 314, 314, 314, 314, 314, 314, 314, 314, 13: 314, 26: 314, 43: 314, 51: 314, 314, 55: 314, 314, 59: 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, 314},\n\t\t// 60\n\t\t{313, 313, 3: 313, 313, 313, 313, 313, 313, 313, 313, 313, 13: 313, 26: 313, 43: 313, 51: 313, 313, 55: 313, 313, 59: 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, 313},\n\t\t{312, 312, 3: 312, 312, 312, 312, 312, 312, 312, 312, 312, 13: 312, 26: 312, 43: 312, 51: 312, 312, 55: 312, 312, 59: 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, 312},\n\t\t{311, 311, 3: 311, 311, 311, 311, 311, 311, 311, 311, 311, 13: 311, 26: 311, 43: 311, 51: 311, 311, 55: 311, 311, 59: 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311, 311},\n\t\t{310, 310, 3: 310, 310, 310, 310, 310, 310, 310, 310, 310, 13: 310, 26: 310, 43: 310, 51: 310, 310, 55: 310, 310, 59: 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, 310},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 145, 145, 145, 27: 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 53: 582, 478, 114: 579, 123: 581, 155: 408, 162: 761},\n\t\t// 65\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 249, 11: 249, 13: 430, 26: 249, 43: 249, 51: 249, 455, 55: 249, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 760},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 759},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 758},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 521},\n\t\t// 70\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 757},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 756},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 755},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 754},\n\t\t{577, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 578},\n\t\t// 75\n\t\t{406},\n\t\t{2: 405},\n\t\t{258, 258, 3: 258, 258, 258, 258, 258, 258, 258, 258, 258, 13: 258, 26: 258, 43: 258, 51: 258, 258, 55: 258, 258, 59: 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, 258},\n\t\t{23: 145, 145, 145, 27: 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 155: 408, 162: 407},\n\t\t{10: 576},\n\t\t// 80\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 113: 410, 117: 358, 361, 357, 409, 153: 411},\n\t\t{199, 199, 199, 9: 199, 199, 13: 199, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 199, 113: 410, 117: 358, 361, 357, 409, 153: 574, 200: 575},\n\t\t{199, 199, 199, 9: 199, 199, 13: 199, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 199, 113: 410, 117: 358, 361, 357, 409, 153: 574, 200: 573},\n\t\t{165, 412, 10: 141, 13: 165, 133: 413, 136: 415, 156: 416, 180: 414},\n\t\t{161, 161, 161, 10: 161, 161, 13: 161, 23: 367, 365, 366, 113: 423, 154: 427, 163: 571},\n\t\t// 85\n\t\t{164, 2: 164, 10: 143, 143, 13: 164},\n\t\t{10: 144},\n\t\t{418, 13: 129, 185: 417, 419},\n\t\t{10: 140, 140},\n\t\t{567, 10: 142, 142, 13: 128},\n\t\t// 90\n\t\t{165, 412, 10: 133, 13: 165, 23: 133, 133, 133, 27: 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 44: 133, 133, 133, 133, 133, 133, 133, 133: 413, 136: 415, 156: 523, 174: 524},\n\t\t{13: 420},\n\t\t{392, 422, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 367, 365, 366, 44: 426, 54: 421, 256, 113: 423, 154: 424, 169: 425},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 13: 430, 52: 455, 55: 255, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 521, 522},\n\t\t// 95\n\t\t{163, 163, 163, 163, 163, 163, 163, 163, 163, 10: 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 44: 163, 55: 163},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 367, 365, 366, 44: 517, 54: 421, 256, 113: 514, 169: 516},\n\t\t{55: 515},\n\t\t{161, 161, 161, 161, 161, 161, 161, 161, 161, 12: 161, 14: 161, 161, 161, 161, 161, 161, 161, 161, 161, 367, 365, 366, 113: 423, 154: 427, 163: 428},\n\t\t{160, 160, 160, 160, 160, 160, 160, 160, 160, 10: 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 367, 365, 366, 113: 514},\n\t\t// 100\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 429},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 13: 430, 52: 455, 55: 466, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 512},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 10: 318, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 506, 214: 507, 508},\n\t\t{2: 505},\n\t\t// 105\n\t\t{2: 504},\n\t\t{304, 304, 3: 304, 304, 304, 304, 304, 304, 304, 304, 304, 13: 304, 26: 304, 43: 304, 51: 304, 304, 55: 304, 304, 59: 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, 304},\n\t\t{303, 303, 3: 303, 303, 303, 303, 303, 303, 303, 303, 303, 13: 303, 26: 303, 43: 303, 51: 303, 303, 55: 303, 303, 59: 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303, 303},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 503},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 502},\n\t\t// 110\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 501},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 500},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 499},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 498},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 497},\n\t\t// 115\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 496},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 495},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 494},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 493},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 492},\n\t\t// 120\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 491},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 490},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 489},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 488},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 487},\n\t\t// 125\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 486},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 43: 480, 54: 478, 114: 479},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 477},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 476},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 475},\n\t\t// 130\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 474},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 473},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 472},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 471},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 470},\n\t\t// 135\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 469},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 468},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 467},\n\t\t{136, 10: 136, 136, 13: 136},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 261, 261, 261, 13: 430, 26: 261, 43: 261, 51: 261, 455, 55: 261, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t// 140\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 262, 262, 262, 13: 430, 26: 262, 43: 262, 51: 262, 455, 55: 262, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 263, 263, 263, 13: 430, 26: 263, 43: 263, 51: 263, 455, 55: 263, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 264, 264, 264, 13: 430, 26: 264, 43: 264, 51: 264, 455, 55: 264, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 265, 265, 265, 13: 430, 26: 265, 43: 265, 51: 265, 455, 55: 265, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 266, 266, 266, 13: 430, 26: 266, 43: 266, 51: 266, 455, 55: 266, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t// 145\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 267, 267, 267, 13: 430, 26: 267, 43: 267, 51: 267, 455, 55: 267, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 268, 268, 268, 13: 430, 26: 268, 43: 268, 51: 268, 455, 55: 268, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 269, 269, 269, 13: 430, 26: 269, 43: 269, 51: 269, 455, 55: 269, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 270, 270, 270, 13: 430, 26: 270, 43: 270, 51: 270, 455, 55: 270, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 271, 271, 271, 13: 430, 26: 271, 43: 271, 51: 271, 455, 55: 271, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t// 150\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 254, 254, 254, 13: 430, 43: 254, 52: 455, 55: 254, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{11: 483, 43: 482},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 481},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 257, 257, 257, 13: 430, 26: 257, 43: 257, 51: 257, 257, 55: 257, 432, 59: 438, 437, 443, 444, 454, 450, 451, 257, 257, 433, 257, 447, 446, 445, 441, 257, 257, 257, 448, 257, 453, 442, 257, 257, 257},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 485},\n\t\t// 155\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 484},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 253, 253, 253, 13: 430, 43: 253, 52: 455, 55: 253, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 272, 272, 272, 13: 430, 26: 272, 43: 272, 51: 272, 272, 55: 272, 432, 59: 438, 437, 443, 444, 454, 450, 451, 272, 272, 433, 272, 447, 446, 445, 441, 272, 272, 272, 448, 272, 453, 442, 272, 272, 272},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 273, 273, 273, 13: 430, 26: 273, 43: 273, 51: 273, 273, 55: 273, 432, 59: 438, 437, 443, 444, 273, 450, 451, 273, 273, 433, 273, 447, 446, 445, 441, 273, 273, 273, 448, 273, 273, 442, 273, 273, 273},\n\t\t{431, 436, 3: 449, 439, 440, 274, 435, 434, 274, 274, 274, 13: 430, 26: 274, 43: 274, 51: 274, 274, 55: 274, 432, 59: 438, 437, 443, 444, 274, 450, 451, 274, 274, 433, 274, 447, 446, 445, 441, 274, 274, 274, 448, 274, 274, 442, 274, 274, 274},\n\t\t// 160\n\t\t{431, 436, 3: 449, 439, 440, 275, 435, 434, 275, 275, 275, 13: 430, 26: 275, 43: 275, 51: 275, 275, 55: 275, 432, 59: 438, 437, 443, 444, 275, 450, 275, 275, 275, 433, 275, 447, 446, 445, 441, 275, 275, 275, 448, 275, 275, 442, 275, 275, 275},\n\t\t{431, 436, 3: 449, 439, 440, 276, 435, 434, 276, 276, 276, 13: 430, 26: 276, 43: 276, 51: 276, 276, 55: 276, 432, 59: 438, 437, 443, 444, 276, 276, 276, 276, 276, 433, 276, 447, 446, 445, 441, 276, 276, 276, 448, 276, 276, 442, 276, 276, 276},\n\t\t{431, 436, 3: 277, 439, 440, 277, 435, 434, 277, 277, 277, 13: 430, 26: 277, 43: 277, 51: 277, 277, 55: 277, 432, 59: 438, 437, 443, 444, 277, 277, 277, 277, 277, 433, 277, 447, 446, 445, 441, 277, 277, 277, 448, 277, 277, 442, 277, 277, 277},\n\t\t{431, 436, 3: 278, 439, 440, 278, 435, 434, 278, 278, 278, 13: 430, 26: 278, 43: 278, 51: 278, 278, 55: 278, 432, 59: 438, 437, 443, 444, 278, 278, 278, 278, 278, 433, 278, 278, 446, 445, 441, 278, 278, 278, 278, 278, 278, 442, 278, 278, 278},\n\t\t{431, 436, 3: 279, 439, 440, 279, 435, 434, 279, 279, 279, 13: 430, 26: 279, 43: 279, 51: 279, 279, 55: 279, 432, 59: 438, 437, 443, 444, 279, 279, 279, 279, 279, 433, 279, 279, 446, 445, 441, 279, 279, 279, 279, 279, 279, 442, 279, 279, 279},\n\t\t// 165\n\t\t{431, 436, 3: 280, 439, 440, 280, 435, 434, 280, 280, 280, 13: 430, 26: 280, 43: 280, 51: 280, 280, 55: 280, 432, 59: 438, 437, 280, 280, 280, 280, 280, 280, 280, 433, 280, 280, 280, 280, 441, 280, 280, 280, 280, 280, 280, 442, 280, 280, 280},\n\t\t{431, 436, 3: 281, 439, 440, 281, 435, 434, 281, 281, 281, 13: 430, 26: 281, 43: 281, 51: 281, 281, 55: 281, 432, 59: 438, 437, 281, 281, 281, 281, 281, 281, 281, 433, 281, 281, 281, 281, 441, 281, 281, 281, 281, 281, 281, 442, 281, 281, 281},\n\t\t{431, 436, 3: 282, 439, 440, 282, 435, 434, 282, 282, 282, 13: 430, 26: 282, 43: 282, 51: 282, 282, 55: 282, 432, 59: 438, 437, 282, 282, 282, 282, 282, 282, 282, 433, 282, 282, 282, 282, 441, 282, 282, 282, 282, 282, 282, 442, 282, 282, 282},\n\t\t{431, 436, 3: 283, 439, 440, 283, 435, 434, 283, 283, 283, 13: 430, 26: 283, 43: 283, 51: 283, 283, 55: 283, 432, 59: 438, 437, 283, 283, 283, 283, 283, 283, 283, 433, 283, 283, 283, 283, 441, 283, 283, 283, 283, 283, 283, 442, 283, 283, 283},\n\t\t{431, 436, 3: 284, 439, 440, 284, 435, 434, 284, 284, 284, 13: 430, 26: 284, 43: 284, 51: 284, 284, 55: 284, 432, 59: 438, 437, 284, 284, 284, 284, 284, 284, 284, 433, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284},\n\t\t// 170\n\t\t{431, 436, 3: 285, 439, 440, 285, 435, 434, 285, 285, 285, 13: 430, 26: 285, 43: 285, 51: 285, 285, 55: 285, 432, 59: 438, 437, 285, 285, 285, 285, 285, 285, 285, 433, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285},\n\t\t{431, 436, 3: 286, 286, 286, 286, 435, 434, 286, 286, 286, 13: 430, 26: 286, 43: 286, 51: 286, 286, 55: 286, 432, 59: 438, 437, 286, 286, 286, 286, 286, 286, 286, 433, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286},\n\t\t{431, 436, 3: 287, 287, 287, 287, 435, 434, 287, 287, 287, 13: 430, 26: 287, 43: 287, 51: 287, 287, 55: 287, 432, 59: 438, 437, 287, 287, 287, 287, 287, 287, 287, 433, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287},\n\t\t{431, 288, 3: 288, 288, 288, 288, 435, 434, 288, 288, 288, 13: 430, 26: 288, 43: 288, 51: 288, 288, 55: 288, 432, 59: 288, 288, 288, 288, 288, 288, 288, 288, 288, 433, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288},\n\t\t{431, 289, 3: 289, 289, 289, 289, 435, 434, 289, 289, 289, 13: 430, 26: 289, 43: 289, 51: 289, 289, 55: 289, 432, 59: 289, 289, 289, 289, 289, 289, 289, 289, 289, 433, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289},\n\t\t// 175\n\t\t{431, 290, 3: 290, 290, 290, 290, 435, 434, 290, 290, 290, 13: 430, 26: 290, 43: 290, 51: 290, 290, 55: 290, 432, 59: 290, 290, 290, 290, 290, 290, 290, 290, 290, 433, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290},\n\t\t{305, 305, 3: 305, 305, 305, 305, 305, 305, 305, 305, 305, 13: 305, 26: 305, 43: 305, 51: 305, 305, 55: 305, 305, 59: 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305},\n\t\t{306, 306, 3: 306, 306, 306, 306, 306, 306, 306, 306, 306, 13: 306, 26: 306, 43: 306, 51: 306, 306, 55: 306, 306, 59: 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306, 306},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 10: 320, 320, 13: 430, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{10: 317, 510},\n\t\t// 180\n\t\t{10: 509},\n\t\t{307, 307, 3: 307, 307, 307, 307, 307, 307, 307, 307, 307, 13: 307, 26: 307, 43: 307, 51: 307, 307, 55: 307, 307, 59: 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, 307},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 511},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 10: 319, 319, 13: 430, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{11: 483, 55: 513},\n\t\t// 185\n\t\t{308, 308, 3: 308, 308, 308, 308, 308, 308, 308, 308, 308, 13: 308, 26: 308, 43: 308, 51: 308, 308, 55: 308, 308, 59: 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308, 308},\n\t\t{162, 162, 162, 162, 162, 162, 162, 162, 162, 10: 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 44: 162, 55: 162},\n\t\t{138, 10: 138, 138, 13: 138},\n\t\t{55: 520},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 518},\n\t\t// 190\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 13: 430, 52: 455, 55: 519, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{135, 10: 135, 135, 13: 135},\n\t\t{137, 10: 137, 137, 13: 137},\n\t\t{431, 298, 3: 298, 298, 298, 298, 435, 434, 298, 298, 298, 13: 430, 26: 298, 43: 298, 51: 298, 298, 55: 298, 432, 59: 298, 298, 298, 298, 298, 298, 298, 298, 298, 433, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, 298},\n\t\t{134, 10: 134, 134, 13: 134},\n\t\t// 195\n\t\t{10: 566},\n\t\t{10: 157, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 528, 340, 127: 337, 161: 527, 172: 525, 526, 199: 529},\n\t\t{10: 159, 563},\n\t\t{10: 156},\n\t\t{10: 155, 155},\n\t\t// 200\n\t\t{165, 412, 165, 10: 141, 141, 13: 165, 133: 413, 136: 531, 532, 156: 416, 180: 533},\n\t\t{10: 530},\n\t\t{132, 10: 132, 132, 13: 132},\n\t\t{536, 2: 535, 13: 129, 185: 417, 419, 534},\n\t\t{10: 153, 153},\n\t\t// 205\n\t\t{10: 152, 152},\n\t\t{540, 9: 179, 179, 179, 13: 539, 23: 179, 179, 179, 27: 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 179, 52: 179, 179, 57: 179, 179},\n\t\t{176, 9: 176, 176, 176, 13: 176, 23: 176, 176, 176, 27: 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 176, 52: 176, 176, 57: 176, 176},\n\t\t{165, 412, 165, 10: 133, 13: 165, 23: 133, 133, 133, 27: 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 44: 133, 133, 133, 133, 133, 133, 133, 133: 413, 136: 531, 537, 156: 523, 174: 524},\n\t\t{10: 538},\n\t\t// 210\n\t\t{175, 9: 175, 175, 175, 13: 175, 23: 175, 175, 175, 27: 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 52: 175, 175, 57: 175, 175},\n\t\t{161, 161, 161, 161, 161, 161, 161, 161, 161, 12: 161, 14: 161, 161, 161, 161, 161, 161, 161, 161, 161, 367, 365, 366, 44: 551, 55: 161, 113: 423, 154: 552, 163: 550},\n\t\t{2: 543, 10: 149, 23: 170, 170, 170, 27: 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, 44: 170, 170, 170, 170, 170, 170, 170, 170: 544, 194: 542, 213: 541},\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 528, 340, 127: 337, 161: 527, 172: 525, 548},\n\t\t{10: 547},\n\t\t// 215\n\t\t{10: 151, 151, 147: 151},\n\t\t{10: 148, 545},\n\t\t{2: 546},\n\t\t{10: 150, 150, 147: 150},\n\t\t{168, 9: 168, 168, 168, 13: 168, 23: 168, 168, 168, 27: 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 168, 52: 168, 168, 57: 168, 168},\n\t\t// 220\n\t\t{10: 549},\n\t\t{169, 9: 169, 169, 169, 13: 169, 23: 169, 169, 169, 27: 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 52: 169, 169, 57: 169, 169},\n\t\t{392, 559, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 421, 256, 169: 560},\n\t\t{161, 161, 161, 161, 161, 161, 161, 161, 161, 12: 161, 14: 161, 161, 161, 161, 161, 161, 161, 161, 161, 367, 365, 366, 113: 423, 154: 427, 163: 556},\n\t\t{160, 160, 160, 160, 160, 160, 160, 160, 160, 12: 160, 14: 160, 160, 160, 160, 160, 160, 160, 160, 160, 367, 365, 366, 44: 553, 55: 160, 113: 514},\n\t\t// 225\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 554},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 13: 430, 52: 455, 55: 555, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{172, 9: 172, 172, 172, 13: 172, 23: 172, 172, 172, 27: 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 52: 172, 172, 57: 172, 172},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 557},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 13: 430, 52: 455, 55: 558, 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t// 230\n\t\t{173, 9: 173, 173, 173, 13: 173, 23: 173, 173, 173, 27: 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 52: 173, 173, 57: 173, 173},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 521, 562},\n\t\t{55: 561},\n\t\t{174, 9: 174, 174, 174, 13: 174, 23: 174, 174, 174, 27: 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 174, 52: 174, 174, 57: 174, 174},\n\t\t{171, 9: 171, 171, 171, 13: 171, 23: 171, 171, 171, 27: 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 52: 171, 171, 57: 171, 171},\n\t\t// 235\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 528, 340, 127: 337, 147: 564, 161: 565},\n\t\t{10: 158},\n\t\t{10: 154, 154},\n\t\t{139, 10: 139, 139, 13: 139},\n\t\t{10: 131, 23: 131, 131, 131, 27: 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 44: 131, 131, 131, 131, 131, 131, 131, 205: 568},\n\t\t// 240\n\t\t{10: 157, 23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 113: 339, 117: 358, 361, 357, 338, 124: 528, 340, 127: 337, 161: 527, 172: 525, 526, 199: 569},\n\t\t{10: 570},\n\t\t{130, 10: 130, 130, 13: 130},\n\t\t{167, 412, 167, 10: 167, 167, 13: 167, 133: 572},\n\t\t{166, 2: 166, 10: 166, 166, 13: 166},\n\t\t// 245\n\t\t{200, 200, 200, 9: 200, 200, 13: 200, 43: 200},\n\t\t{198, 198, 198, 9: 198, 198, 13: 198, 43: 198},\n\t\t{201, 201, 201, 9: 201, 201, 13: 201, 43: 201},\n\t\t{260, 260, 3: 260, 260, 260, 260, 260, 260, 260, 260, 260, 13: 260, 26: 260, 43: 260, 51: 260, 260, 55: 260, 260, 59: 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260, 260},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 145, 145, 145, 27: 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 53: 582, 478, 114: 579, 123: 581, 155: 408, 162: 580},\n\t\t// 250\n\t\t{431, 293, 3: 293, 293, 293, 293, 435, 434, 293, 293, 293, 13: 430, 26: 293, 43: 293, 51: 293, 293, 55: 293, 432, 59: 293, 293, 293, 293, 293, 293, 293, 293, 293, 433, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293, 293},\n\t\t{10: 753, 483},\n\t\t{10: 747},\n\t\t{10: 746},\n\t\t{104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 12: 104, 14: 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 44: 104, 104, 104, 104, 104, 104, 104, 53: 104, 57: 104, 104, 85: 104, 104, 104, 104, 104, 104, 104, 104, 104, 95: 104, 104, 206: 583},\n\t\t// 255\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 367, 365, 366, 100, 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 53: 582, 478, 57: 611, 377, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 113: 339, 585, 117: 358, 361, 357, 338, 601, 612, 588, 586, 340, 127: 337, 593, 589, 591, 592, 587, 134: 590, 600, 138: 336, 144: 599, 181: 597, 216: 598, 596},\n\t\t{316, 316, 3: 316, 316, 316, 316, 316, 316, 316, 11: 316, 13: 316, 43: 744, 52: 316, 56: 316, 59: 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316},\n\t\t{9: 251, 251, 483},\n\t\t{165, 412, 165, 9: 238, 133: 713, 136: 712, 711, 171: 709, 196: 710, 708},\n\t\t{114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 12: 114, 14: 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 44: 114, 114, 114, 114, 114, 114, 114, 53: 114, 57: 114, 114, 85: 114, 114, 114, 114, 114, 114, 114, 114, 114, 95: 114, 114, 112: 114},\n\t\t// 260\n\t\t{113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 12: 113, 14: 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, 44: 113, 113, 113, 113, 113, 113, 113, 53: 113, 57: 113, 113, 85: 113, 113, 113, 113, 113, 113, 113, 113, 113, 95: 113, 113, 112: 113},\n\t\t{112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 12: 112, 14: 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 44: 112, 112, 112, 112, 112, 112, 112, 53: 112, 57: 112, 112, 85: 112, 112, 112, 112, 112, 112, 112, 112, 112, 95: 112, 112, 112: 112},\n\t\t{111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 12: 111, 14: 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 44: 111, 111, 111, 111, 111, 111, 111, 53: 111, 57: 111, 111, 85: 111, 111, 111, 111, 111, 111, 111, 111, 111, 95: 111, 111, 112: 111},\n\t\t{110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 12: 110, 14: 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 44: 110, 110, 110, 110, 110, 110, 110, 53: 110, 57: 110, 110, 85: 110, 110, 110, 110, 110, 110, 110, 110, 110, 95: 110, 110, 112: 110},\n\t\t{109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 12: 109, 14: 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 44: 109, 109, 109, 109, 109, 109, 109, 53: 109, 57: 109, 109, 85: 109, 109, 109, 109, 109, 109, 109, 109, 109, 95: 109, 109, 112: 109},\n\t\t// 265\n\t\t{108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 12: 108, 14: 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 44: 108, 108, 108, 108, 108, 108, 108, 53: 108, 57: 108, 108, 85: 108, 108, 108, 108, 108, 108, 108, 108, 108, 95: 108, 108, 112: 108},\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 705},\n\t\t{43: 703},\n\t\t{26: 702},\n\t\t{102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 12: 102, 14: 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 44: 102, 102, 102, 102, 102, 102, 102, 53: 102, 57: 102, 102, 85: 102, 102, 102, 102, 102, 102, 102, 102, 102, 95: 102, 102},\n\t\t// 270\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 367, 365, 366, 99, 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 53: 582, 478, 57: 611, 377, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 113: 339, 585, 117: 358, 361, 357, 338, 601, 612, 588, 586, 340, 127: 337, 593, 589, 591, 592, 587, 134: 590, 600, 138: 336, 144: 599, 181: 701},\n\t\t{98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 12: 98, 14: 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 44: 98, 98, 98, 98, 98, 98, 98, 53: 98, 57: 98, 98, 85: 98, 98, 98, 98, 98, 98, 98, 98, 98, 95: 98, 98},\n\t\t{97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 12: 97, 14: 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 44: 97, 97, 97, 97, 97, 97, 97, 53: 97, 57: 97, 97, 85: 97, 97, 97, 97, 97, 97, 97, 97, 97, 95: 97, 97},\n\t\t{9: 700},\n\t\t{694},\n\t\t// 275\n\t\t{690},\n\t\t{686},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 680},\n\t\t{666},\n\t\t{392, 397, 662, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 663},\n\t\t// 280\n\t\t{9: 661},\n\t\t{9: 660},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 585, 121: 658},\n\t\t{60, 23: 614, 85: 60, 203: 613},\n\t\t{51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 12: 51, 14: 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 44: 51, 51, 51, 51, 51, 51, 51, 53: 51, 57: 51, 51, 85: 51, 51, 51, 51, 51, 51, 51, 51, 51, 95: 51, 51, 112: 51},\n\t\t// 285\n\t\t{615, 85: 616},\n\t\t{59, 85: 59},\n\t\t{12: 618, 164: 643},\n\t\t{617},\n\t\t{12: 618, 164: 619},\n\t\t// 290\n\t\t{10: 63, 12: 63, 43: 63},\n\t\t{12: 620, 43: 621},\n\t\t{10: 62, 12: 62, 43: 62},\n\t\t{43: 622},\n\t\t{12: 55, 626, 149: 624, 623, 157: 625},\n\t\t// 295\n\t\t{12: 639},\n\t\t{10: 57, 57, 43: 57},\n\t\t{11: 629, 43: 630},\n\t\t{2: 627},\n\t\t{55: 628},\n\t\t// 300\n\t\t{12: 54},\n\t\t{12: 55, 626, 149: 638, 623},\n\t\t{12: 631, 182: 632},\n\t\t{10: 53, 53, 43: 53},\n\t\t{11: 633, 43: 634},\n\t\t// 305\n\t\t{12: 637},\n\t\t{2: 543, 170: 635},\n\t\t{10: 636, 545},\n\t\t{47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 12: 47, 14: 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 44: 47, 47, 47, 47, 47, 47, 47, 53: 47, 57: 47, 47, 85: 47, 47, 47, 47, 47, 47, 47, 47, 47, 95: 47, 47, 112: 47},\n\t\t{10: 52, 52, 43: 52},\n\t\t// 310\n\t\t{10: 56, 56, 43: 56},\n\t\t{640},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 641},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 10: 642, 13: 430, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{10: 58, 58, 43: 58},\n\t\t// 315\n\t\t{10: 644, 12: 620, 43: 645},\n\t\t{61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 12: 61, 14: 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 44: 61, 61, 61, 61, 61, 61, 61, 53: 61, 57: 61, 61, 85: 61, 61, 61, 61, 61, 61, 61, 61, 61, 95: 61, 61, 112: 61},\n\t\t{10: 647, 12: 55, 626, 43: 648, 149: 624, 623, 157: 646},\n\t\t{10: 651, 629, 43: 652},\n\t\t{46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 12: 46, 14: 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 44: 46, 46, 46, 46, 46, 46, 46, 53: 46, 57: 46, 46, 85: 46, 46, 46, 46, 46, 46, 46, 46, 46, 95: 46, 46, 112: 46},\n\t\t// 320\n\t\t{12: 55, 626, 149: 624, 623, 157: 649},\n\t\t{10: 650, 629},\n\t\t{45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 12: 45, 14: 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44: 45, 45, 45, 45, 45, 45, 45, 53: 45, 57: 45, 45, 85: 45, 45, 45, 45, 45, 45, 45, 45, 45, 95: 45, 45, 112: 45},\n\t\t{50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 12: 50, 14: 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 44: 50, 50, 50, 50, 50, 50, 50, 53: 50, 57: 50, 50, 85: 50, 50, 50, 50, 50, 50, 50, 50, 50, 95: 50, 50, 112: 50},\n\t\t{12: 55, 626, 149: 624, 623, 157: 653},\n\t\t// 325\n\t\t{10: 654, 629, 43: 655},\n\t\t{49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 12: 49, 14: 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 44: 49, 49, 49, 49, 49, 49, 49, 53: 49, 57: 49, 49, 85: 49, 49, 49, 49, 49, 49, 49, 49, 49, 95: 49, 49, 112: 49},\n\t\t{12: 631, 182: 656},\n\t\t{10: 657, 633},\n\t\t{48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 12: 48, 14: 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 44: 48, 48, 48, 48, 48, 48, 48, 53: 48, 57: 48, 48, 85: 48, 48, 48, 48, 48, 48, 48, 48, 48, 95: 48, 48, 112: 48},\n\t\t// 330\n\t\t{9: 659},\n\t\t{85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 12: 85, 14: 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 44: 85, 85, 85, 85, 85, 85, 85, 53: 85, 57: 85, 85, 85: 85, 85, 85, 85, 85, 85, 85, 85, 85, 95: 85, 85, 112: 85},\n\t\t{86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 12: 86, 14: 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 44: 86, 86, 86, 86, 86, 86, 86, 53: 86, 57: 86, 86, 85: 86, 86, 86, 86, 86, 86, 86, 86, 86, 95: 86, 86, 112: 86},\n\t\t{87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 12: 87, 14: 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 44: 87, 87, 87, 87, 87, 87, 87, 53: 87, 57: 87, 87, 85: 87, 87, 87, 87, 87, 87, 87, 87, 87, 95: 87, 87, 112: 87},\n\t\t{316, 316, 3: 316, 316, 316, 316, 316, 316, 665, 13: 316, 52: 316, 56: 316, 59: 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316},\n\t\t// 335\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 664, 13: 430, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 12: 84, 14: 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 44: 84, 84, 84, 84, 84, 84, 84, 53: 84, 57: 84, 84, 85: 84, 84, 84, 84, 84, 84, 84, 84, 84, 95: 84, 84, 112: 84},\n\t\t{88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 12: 88, 14: 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 44: 88, 88, 88, 88, 88, 88, 88, 53: 88, 57: 88, 88, 85: 88, 88, 88, 88, 88, 88, 88, 88, 88, 95: 88, 88, 112: 88},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 54: 478, 58: 377, 113: 339, 585, 117: 358, 361, 357, 338, 667, 124: 586, 340, 127: 337, 138: 336, 144: 668},\n\t\t{9: 674},\n\t\t// 340\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 585, 121: 669},\n\t\t{9: 670},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 10: 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 585, 121: 671},\n\t\t{10: 672},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 673},\n\t\t// 345\n\t\t{89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 12: 89, 14: 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 44: 89, 89, 89, 89, 89, 89, 89, 53: 89, 57: 89, 89, 85: 89, 89, 89, 89, 89, 89, 89, 89, 89, 95: 89, 89, 112: 89},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 585, 121: 675},\n\t\t{9: 676},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 10: 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 585, 121: 677},\n\t\t{10: 678},\n\t\t// 350\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 679},\n\t\t{90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 12: 90, 14: 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 44: 90, 90, 90, 90, 90, 90, 90, 53: 90, 57: 90, 90, 85: 90, 90, 90, 90, 90, 90, 90, 90, 90, 95: 90, 90, 112: 90},\n\t\t{86: 681},\n\t\t{682},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 683},\n\t\t// 355\n\t\t{10: 684, 483},\n\t\t{9: 685},\n\t\t{91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 12: 91, 14: 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 44: 91, 91, 91, 91, 91, 91, 91, 53: 91, 57: 91, 91, 85: 91, 91, 91, 91, 91, 91, 91, 91, 91, 95: 91, 91, 112: 91},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 687},\n\t\t{10: 688, 483},\n\t\t// 360\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 689},\n\t\t{92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 12: 92, 14: 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 44: 92, 92, 92, 92, 92, 92, 92, 53: 92, 57: 92, 92, 85: 92, 92, 92, 92, 92, 92, 92, 92, 92, 95: 92, 92, 112: 92},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 691},\n\t\t{10: 692, 483},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 693},\n\t\t// 365\n\t\t{93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 12: 93, 14: 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 44: 93, 93, 93, 93, 93, 93, 93, 53: 93, 57: 93, 93, 85: 93, 93, 93, 93, 93, 93, 93, 93, 93, 95: 93, 93, 112: 93},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 54: 478, 114: 695},\n\t\t{10: 696, 483},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 697},\n\t\t{95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 12: 95, 14: 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 44: 95, 95, 95, 95, 95, 95, 95, 53: 95, 57: 95, 95, 85: 95, 95, 95, 95, 95, 95, 95, 95, 95, 95: 95, 95, 112: 698},\n\t\t// 370\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 699},\n\t\t{94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 12: 94, 14: 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 44: 94, 94, 94, 94, 94, 94, 94, 53: 94, 57: 94, 94, 85: 94, 94, 94, 94, 94, 94, 94, 94, 94, 95: 94, 94, 112: 94},\n\t\t{96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 12: 96, 14: 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 44: 96, 96, 96, 96, 96, 96, 96, 53: 96, 57: 96, 96, 85: 96, 96, 96, 96, 96, 96, 96, 96, 96, 95: 96, 96, 112: 96},\n\t\t{101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 12: 101, 14: 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 44: 101, 101, 101, 101, 101, 101, 101, 53: 101, 57: 101, 101, 85: 101, 101, 101, 101, 101, 101, 101, 101, 101, 95: 101, 101},\n\t\t{103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 12: 103, 14: 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 44: 103, 103, 103, 103, 103, 103, 103, 103, 53: 103, 57: 103, 103, 85: 103, 103, 103, 103, 103, 103, 103, 103, 103, 95: 103, 103, 112: 103},\n\t\t// 375\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 704},\n\t\t{105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 12: 105, 14: 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 44: 105, 105, 105, 105, 105, 105, 105, 53: 105, 57: 105, 105, 85: 105, 105, 105, 105, 105, 105, 105, 105, 105, 95: 105, 105, 112: 105},\n\t\t{43: 706},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 707},\n\t\t{106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 12: 106, 14: 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 44: 106, 106, 106, 106, 106, 106, 106, 53: 106, 57: 106, 106, 85: 106, 106, 106, 106, 106, 106, 106, 106, 106, 95: 106, 106, 112: 106},\n\t\t// 380\n\t\t{9: 743},\n\t\t{9: 240, 11: 240},\n\t\t{9: 237, 11: 741},\n\t\t{9: 236, 11: 236, 52: 235, 179: 715},\n\t\t{714, 2: 535, 187: 534},\n\t\t// 385\n\t\t{164, 2: 164},\n\t\t{165, 412, 165, 133: 713, 136: 712, 537},\n\t\t{52: 716},\n\t\t{392, 397, 717, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 720, 718, 160: 719},\n\t\t{316, 316, 3: 316, 316, 316, 316, 316, 316, 316, 11: 316, 13: 316, 26: 316, 43: 739, 52: 316, 56: 316, 59: 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316},\n\t\t// 390\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 127, 11: 127, 13: 430, 26: 127, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{9: 234, 11: 234},\n\t\t{120, 120, 120, 120, 120, 120, 120, 120, 120, 11: 122, 120, 726, 120, 120, 120, 120, 120, 120, 120, 120, 120, 26: 122, 53: 120, 56: 727, 159: 725, 166: 724, 722, 723, 198: 721},\n\t\t{11: 734, 26: 193, 165: 735},\n\t\t{392, 397, 717, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 720, 718, 160: 733},\n\t\t// 395\n\t\t{13: 726, 52: 731, 56: 727, 159: 732},\n\t\t{119, 119, 119, 119, 119, 119, 119, 119, 119, 12: 119, 14: 119, 119, 119, 119, 119, 119, 119, 119, 119, 53: 119},\n\t\t{13: 118, 52: 118, 56: 118},\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 729},\n\t\t{2: 728},\n\t\t// 400\n\t\t{13: 115, 52: 115, 56: 115},\n\t\t{55: 730},\n\t\t{13: 116, 52: 116, 56: 116},\n\t\t{121, 121, 121, 121, 121, 121, 121, 121, 121, 12: 121, 14: 121, 121, 121, 121, 121, 121, 121, 121, 121, 53: 121},\n\t\t{13: 117, 52: 117, 56: 117},\n\t\t// 405\n\t\t{11: 124, 26: 124},\n\t\t{120, 120, 120, 120, 120, 120, 120, 120, 120, 12: 120, 726, 120, 120, 120, 120, 120, 120, 120, 120, 120, 26: 192, 53: 120, 56: 727, 159: 725, 166: 724, 737, 723},\n\t\t{26: 736},\n\t\t{9: 126, 11: 126, 26: 126},\n\t\t{392, 397, 717, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 720, 718, 160: 738},\n\t\t// 410\n\t\t{11: 123, 26: 123},\n\t\t{392, 397, 717, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 720, 718, 160: 740},\n\t\t{9: 125, 11: 125, 26: 125},\n\t\t{165, 412, 165, 133: 713, 136: 712, 711, 171: 742},\n\t\t{9: 239, 11: 239},\n\t\t// 415\n\t\t{248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 12: 248, 14: 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 44: 248, 248, 248, 248, 248, 248, 248, 248, 53: 248, 57: 248, 248, 85: 248, 248, 248, 248, 248, 248, 248, 248, 248, 95: 248, 248},\n\t\t{392, 397, 584, 396, 398, 399, 404, 395, 394, 252, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 582, 478, 57: 611, 85: 607, 604, 609, 594, 608, 595, 605, 606, 602, 95: 610, 603, 114: 585, 121: 601, 612, 588, 128: 593, 589, 591, 592, 587, 134: 590, 745},\n\t\t{107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 12: 107, 14: 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 44: 107, 107, 107, 107, 107, 107, 107, 53: 107, 57: 107, 107, 85: 107, 107, 107, 107, 107, 107, 107, 107, 107, 95: 107, 107, 112: 107},\n\t\t{259, 259, 3: 259, 259, 259, 259, 259, 259, 259, 259, 259, 13: 259, 26: 259, 43: 259, 51: 259, 259, 55: 259, 259, 59: 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, 259},\n\t\t{392, 292, 385, 292, 292, 292, 292, 395, 394, 292, 292, 292, 391, 292, 401, 400, 403, 386, 387, 388, 389, 390, 402, 26: 292, 43: 292, 51: 292, 292, 749, 748, 292, 292, 59: 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292},\n\t\t// 420\n\t\t{431, 291, 3: 291, 291, 291, 291, 435, 434, 291, 291, 291, 13: 430, 26: 291, 43: 291, 51: 291, 291, 55: 291, 432, 59: 291, 291, 291, 291, 291, 291, 291, 291, 291, 433, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, 291},\n\t\t{120, 120, 120, 120, 120, 120, 120, 120, 120, 11: 122, 120, 726, 120, 120, 120, 120, 120, 120, 120, 120, 120, 26: 122, 53: 120, 56: 727, 159: 725, 166: 724, 722, 723, 198: 750},\n\t\t{11: 734, 26: 193, 165: 751},\n\t\t{26: 752},\n\t\t{302, 302, 3: 302, 302, 302, 302, 302, 302, 302, 302, 302, 13: 302, 26: 302, 43: 302, 51: 302, 302, 55: 302, 302, 59: 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302, 302},\n\t\t// 425\n\t\t{309, 309, 3: 309, 309, 309, 309, 309, 309, 309, 309, 309, 13: 309, 26: 309, 43: 309, 51: 309, 309, 55: 309, 309, 59: 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, 309},\n\t\t{431, 294, 3: 294, 294, 294, 294, 435, 434, 294, 294, 294, 13: 430, 26: 294, 43: 294, 51: 294, 294, 55: 294, 432, 59: 294, 294, 294, 294, 294, 294, 294, 294, 294, 433, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294},\n\t\t{431, 295, 3: 295, 295, 295, 295, 435, 434, 295, 295, 295, 13: 430, 26: 295, 43: 295, 51: 295, 295, 55: 295, 432, 59: 295, 295, 295, 295, 295, 295, 295, 295, 295, 433, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295},\n\t\t{431, 296, 3: 296, 296, 296, 296, 435, 434, 296, 296, 296, 13: 430, 26: 296, 43: 296, 51: 296, 296, 55: 296, 432, 59: 296, 296, 296, 296, 296, 296, 296, 296, 296, 433, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296},\n\t\t{431, 297, 3: 297, 297, 297, 297, 435, 434, 297, 297, 297, 13: 430, 26: 297, 43: 297, 51: 297, 297, 55: 297, 432, 59: 297, 297, 297, 297, 297, 297, 297, 297, 297, 433, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297},\n\t\t// 430\n\t\t{431, 299, 3: 299, 299, 299, 299, 435, 434, 299, 299, 299, 13: 430, 26: 299, 43: 299, 51: 299, 299, 55: 299, 432, 59: 299, 299, 299, 299, 299, 299, 299, 299, 299, 433, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299},\n\t\t{431, 300, 3: 300, 300, 300, 300, 435, 434, 300, 300, 300, 13: 430, 26: 300, 43: 300, 51: 300, 300, 55: 300, 432, 59: 300, 300, 300, 300, 300, 300, 300, 300, 300, 433, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300},\n\t\t{431, 301, 3: 301, 301, 301, 301, 435, 434, 301, 301, 301, 13: 430, 26: 301, 43: 301, 51: 301, 301, 55: 301, 432, 59: 301, 301, 301, 301, 301, 301, 301, 301, 301, 433, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301},\n\t\t{10: 762},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 53: 749, 748},\n\t\t// 435\n\t\t{764},\n\t\t{12: 618, 164: 765},\n\t\t{10: 644, 12: 620},\n\t\t{23: 65, 65, 65, 27: 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 44: 65, 65, 65, 65, 65, 65, 65, 53: 66, 57: 66, 65, 178: 768, 183: 767},\n\t\t{53: 74, 57: 74, 208: 772},\n\t\t// 440\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 58: 377, 113: 339, 117: 358, 361, 357, 338, 124: 586, 340, 127: 337, 138: 336, 144: 769, 219: 770},\n\t\t{23: 68, 68, 68, 27: 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 44: 68, 68, 68, 68, 68, 68, 68, 53: 68, 57: 68, 68},\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 44: 343, 344, 342, 368, 369, 345, 341, 53: 64, 57: 64, 377, 113: 339, 117: 358, 361, 357, 338, 124: 586, 340, 127: 337, 138: 336, 144: 771},\n\t\t{23: 67, 67, 67, 27: 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 44: 67, 67, 67, 67, 67, 67, 67, 53: 67, 57: 67, 67},\n\t\t{53: 72, 57: 70, 176: 774, 775, 192: 773},\n\t\t// 445\n\t\t{73, 73, 73, 9: 73, 23: 73, 73, 73, 27: 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 44: 73, 73, 73, 73, 73, 73, 73, 73, 57: 73, 73},\n\t\t{53: 582, 123: 778},\n\t\t{57: 611, 122: 612, 128: 776},\n\t\t{9: 777},\n\t\t{69, 69, 69, 9: 69, 23: 69, 69, 69, 27: 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 44: 69, 69, 69, 69, 69, 69, 69, 69, 57: 69, 69},\n\t\t// 450\n\t\t{71, 71, 71, 9: 71, 23: 71, 71, 71, 27: 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 44: 71, 71, 71, 71, 71, 71, 71, 71, 57: 71, 71},\n\t\t{79, 79, 79, 9: 79, 23: 79, 79, 79, 27: 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 44: 79, 79, 79, 79, 79, 79, 79, 79, 57: 79, 79},\n\t\t{53: 191, 212: 782},\n\t\t{189, 189, 189, 9: 189, 189, 189, 13: 189, 23: 189, 189, 189, 27: 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 53: 146},\n\t\t{53: 783},\n\t\t// 455\n\t\t{2: 784, 189: 787, 786, 225: 785},\n\t\t{11: 321, 26: 321, 52: 321},\n\t\t{11: 790, 26: 193, 165: 791},\n\t\t{11: 188, 26: 188},\n\t\t{11: 186, 26: 186, 52: 788},\n\t\t// 460\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 789},\n\t\t{11: 185, 26: 185},\n\t\t{2: 784, 26: 192, 189: 787, 793},\n\t\t{26: 792},\n\t\t{190, 190, 190, 9: 190, 190, 190, 13: 190, 23: 190, 190, 190, 27: 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190},\n\t\t// 465\n\t\t{11: 187, 26: 187},\n\t\t{53: 796},\n\t\t{210, 210, 210, 9: 210, 210, 210, 13: 210, 23: 210, 210, 210, 27: 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, 53: 146},\n\t\t{23: 212, 212, 212, 798, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 58: 212, 211: 797},\n\t\t{23: 367, 365, 366, 27: 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 58: 377, 113: 410, 117: 358, 361, 357, 409, 138: 802, 153: 801, 201: 800, 230: 799},\n\t\t// 470\n\t\t{209, 209, 209, 9: 209, 209, 209, 13: 209, 23: 209, 209, 209, 27: 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209},\n\t\t{23: 367, 365, 366, 813, 355, 347, 356, 352, 364, 351, 349, 350, 348, 353, 362, 359, 360, 363, 354, 346, 58: 377, 113: 410, 117: 358, 361, 357, 409, 138: 802, 153: 801, 201: 814},\n\t\t{23: 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 58: 206},\n\t\t{165, 412, 165, 9: 804, 43: 178, 133: 713, 136: 712, 806, 184: 807, 202: 805, 231: 803},\n\t\t{23: 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, 58: 202},\n\t\t// 475\n\t\t{9: 810, 11: 811},\n\t\t{23: 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 58: 203},\n\t\t{9: 197, 11: 197},\n\t\t{9: 195, 11: 195, 43: 177},\n\t\t{43: 808},\n\t\t// 480\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 809},\n\t\t{9: 194, 11: 194},\n\t\t{23: 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 58: 204},\n\t\t{165, 412, 165, 43: 178, 133: 713, 136: 712, 806, 184: 807, 202: 812},\n\t\t{9: 196, 11: 196},\n\t\t// 485\n\t\t{211, 211, 211, 9: 211, 211, 211, 13: 211, 23: 211, 211, 211, 27: 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211},\n\t\t{23: 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 58: 205},\n\t\t{392, 397, 385, 396, 398, 399, 404, 395, 394, 12: 391, 14: 401, 400, 403, 386, 387, 388, 389, 390, 402, 145, 145, 145, 27: 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 54: 816, 155: 408, 162: 817},\n\t\t{431, 436, 3: 449, 439, 440, 452, 435, 434, 10: 819, 13: 430, 52: 455, 56: 432, 59: 438, 437, 443, 444, 454, 450, 451, 459, 463, 433, 457, 447, 446, 445, 441, 461, 458, 456, 448, 465, 453, 442, 462, 460, 464},\n\t\t{10: 818},\n\t\t// 490\n\t\t{213, 213, 213, 9: 213, 213, 213, 13: 213, 23: 213, 213, 213, 27: 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213},\n\t\t{214, 214, 214, 9: 214, 214, 214, 13: 214, 23: 214, 214, 214, 27: 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214},\n\t\t{243, 243, 243, 9: 243, 243, 243, 13: 243},\n\t\t{241, 241, 241, 9: 241, 241, 241, 13: 241},\n\t\t{244, 244, 244, 9: 244, 244, 244, 13: 244},\n\t\t// 495\n\t\t{245, 245, 245, 9: 245, 245, 245, 13: 245},\n\t\t{246, 246, 246, 9: 246, 246, 246, 13: 246},\n\t\t{9: 236, 11: 236, 23: 65, 65, 65, 27: 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 44: 65, 65, 65, 65, 65, 65, 65, 52: 235, 66, 57: 66, 65, 178: 768, 715, 183: 826},\n\t\t{53: 77, 57: 77, 207: 827},\n\t\t{53: 72, 57: 70, 176: 774, 775, 192: 828},\n\t\t// 500\n\t\t{76, 76, 76, 9: 76, 23: 76, 76, 76, 27: 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 44: 76, 76, 76, 76, 76, 76, 76, 76, 57: 76, 76},\n\t\t{82, 82, 82, 9: 82, 23: 82, 82, 82, 27: 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 44: 82, 82, 82, 82, 82, 82, 82, 82, 57: 82, 82},\n\t\t{250, 250, 250, 250, 250, 250, 250, 250, 250, 12: 250, 14: 250, 250, 250, 250, 250, 250, 250, 250, 250, 145: 379, 831},\n\t\t{51: 324},\n\t\t{84: 854, 94: 856, 100: 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 834, 228: 833},\n\t\t// 505\n\t\t{51: 326},\n\t\t{51: 43, 84: 854, 94: 856, 100: 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 894, 840, 837, 839},\n\t\t{51: 42, 84: 42, 94: 42, 97: 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42},\n\t\t{51: 38, 84: 38, 94: 38, 97: 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38},\n\t\t{51: 37, 84: 37, 94: 37, 97: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37},\n\t\t// 510\n\t\t{94: 856, 115: 916, 853},\n\t\t{51: 35, 84: 35, 94: 35, 97: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35},\n\t\t{97: 28, 28, 904, 188: 902, 220: 903, 901},\n\t\t{94: 856, 115: 898, 853},\n\t\t{2: 895},\n\t\t// 515\n\t\t{2: 890},\n\t\t{2: 871, 84: 873, 226: 872},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 870},\n\t\t{51: 16, 84: 16, 94: 16, 97: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},\n\t\t{94: 856, 115: 868, 853},\n\t\t// 520\n\t\t{94: 856, 115: 866, 853},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 865},\n\t\t{2: 861},\n\t\t{94: 856, 115: 859, 853},\n\t\t{51: 7, 84: 7, 94: 7, 97: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7},\n\t\t// 525\n\t\t{84: 5, 94: 858},\n\t\t{51: 4, 84: 4, 94: 4, 97: 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},\n\t\t{84: 857},\n\t\t{84: 2, 94: 2},\n\t\t{51: 3, 84: 3, 94: 3, 97: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},\n\t\t// 530\n\t\t{84: 1, 94: 1},\n\t\t{84: 860},\n\t\t{51: 8, 84: 8, 94: 8, 97: 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},\n\t\t{84: 862, 94: 856, 115: 863, 853},\n\t\t{51: 12, 84: 12, 94: 12, 97: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},\n\t\t// 535\n\t\t{84: 864},\n\t\t{51: 9, 84: 9, 94: 9, 97: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9},\n\t\t{51: 13, 84: 13, 94: 13, 97: 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13},\n\t\t{84: 867},\n\t\t{51: 14, 84: 14, 94: 14, 97: 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14},\n\t\t// 540\n\t\t{84: 869},\n\t\t{51: 15, 84: 15, 94: 15, 97: 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15},\n\t\t{51: 17, 84: 17, 94: 17, 97: 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 879, 152: 889},\n\t\t{2: 543, 10: 149, 147: 875, 170: 874, 194: 876},\n\t\t// 545\n\t\t{51: 10, 84: 10, 94: 10, 97: 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},\n\t\t{10: 148, 882, 147: 883},\n\t\t{10: 880},\n\t\t{10: 877},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 879, 152: 878},\n\t\t// 550\n\t\t{51: 18, 84: 18, 94: 18, 97: 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18},\n\t\t{51: 6, 84: 6, 94: 6, 97: 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 879, 152: 881},\n\t\t{51: 20, 84: 20, 94: 20, 97: 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20},\n\t\t{2: 546, 147: 886},\n\t\t// 555\n\t\t{10: 884},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 879, 152: 885},\n\t\t{51: 11, 84: 11, 94: 11, 97: 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11},\n\t\t{10: 887},\n\t\t{84: 854, 94: 856, 115: 855, 853, 126: 879, 152: 888},\n\t\t// 560\n\t\t{51: 19, 84: 19, 94: 19, 97: 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19},\n\t\t{51: 21, 84: 21, 94: 21, 97: 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21},\n\t\t{84: 891},\n\t\t{84: 854, 94: 856, 97: 40, 40, 40, 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 892, 151: 893},\n\t\t{84: 854, 94: 856, 97: 39, 39, 39, 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 894, 840, 837, 839},\n\t\t// 565\n\t\t{97: 31, 31, 31},\n\t\t{51: 41, 84: 41, 94: 41, 97: 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41},\n\t\t{84: 896},\n\t\t{84: 854, 94: 856, 97: 40, 40, 40, 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 892, 151: 897},\n\t\t{97: 32, 32, 32},\n\t\t// 570\n\t\t{84: 899},\n\t\t{84: 854, 94: 856, 97: 40, 40, 40, 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 892, 151: 900},\n\t\t{97: 33, 33, 33},\n\t\t{97: 24, 910, 222: 911, 909},\n\t\t{97: 30, 30, 30},\n\t\t// 575\n\t\t{97: 27, 27, 904, 188: 908},\n\t\t{94: 856, 115: 905, 853},\n\t\t{84: 906},\n\t\t{84: 854, 94: 856, 97: 40, 40, 40, 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 892, 151: 907},\n\t\t{97: 26, 26, 26},\n\t\t// 580\n\t\t{97: 29, 29, 29},\n\t\t{97: 915, 224: 914},\n\t\t{84: 912},\n\t\t{97: 23},\n\t\t{84: 854, 94: 856, 97: 40, 100: 844, 845, 846, 841, 842, 843, 847, 851, 848, 838, 849, 850, 115: 855, 853, 126: 852, 139: 836, 835, 840, 837, 839, 148: 892, 151: 913},\n\t\t// 585\n\t\t{97: 25},\n\t\t{51: 34, 84: 34, 94: 34, 97: 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34},\n\t\t{51: 22, 84: 22, 94: 22, 97: 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22},\n\t\t{84: 917},\n\t\t{51: 36, 84: 36, 94: 36, 97: 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36},\n\t}\n)\n\nvar yyDebug = 0\n\ntype yyLexer interface {\n\tLex(lval *yySymType) int\n\tError(s string)\n}\n\ntype yyLexerEx interface {\n\tyyLexer\n\tReduced(rule, state int, lval *yySymType) bool\n}\n\nfunc yySymName(c int) (s string) {\n\tx, ok := yyXLAT[c]\n\tif ok {\n\t\treturn yySymNames[x]\n\t}\n\n\tif c < 0x7f {\n\t\treturn __yyfmt__.Sprintf(\"'%c'\", c)\n\t}\n\n\treturn __yyfmt__.Sprintf(\"%d\", c)\n}\n\nfunc yylex1(yylex yyLexer, lval *yySymType) (n int) {\n\tn = yylex.Lex(lval)\n\tif n <= 0 {\n\t\tn = yyEofCode\n\t}\n\tif yyDebug >= 3 {\n\t\t__yyfmt__.Printf(\"\\nlex %s(%#x %d), PrettyString(lval.Token): %v\\n\", yySymName(n), n, n, PrettyString(lval.Token))\n\t}\n\treturn n\n}\n\nfunc yyParse(yylex yyLexer) int {\n\tconst yyError = 236\n\n\tyyEx, _ := yylex.(yyLexerEx)\n\tvar yyn int\n\tvar yylval yySymType\n\tvar yyVAL yySymType\n\tyyS := make([]yySymType, 200)\n\n\tNerrs := 0   /* number of errors */\n\tErrflag := 0 /* error recovery flag */\n\tyyerrok := func() {\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Printf(\"yyerrok()\\n\")\n\t\t}\n\t\tErrflag = 0\n\t}\n\t_ = yyerrok\n\tyystate := 0\n\tyychar := -1\n\tvar yyxchar int\n\tvar yyshift int\n\tyyp := -1\n\tgoto yystack\n\nret0:\n\treturn 0\n\nret1:\n\treturn 1\n\nyystack:\n\t/* put a state and value onto the stack */\n\tyyp++\n\tif yyp >= len(yyS) {\n\t\tnyys := make([]yySymType, len(yyS)*2)\n\t\tcopy(nyys, yyS)\n\t\tyyS = nyys\n\t}\n\tyyS[yyp] = yyVAL\n\tyyS[yyp].yys = yystate\n\nyynewstate:\n\tif yychar < 0 {\n\t\tyylval.yys = yystate\n\t\tyychar = yylex1(yylex, &yylval)\n\t\tvar ok bool\n\t\tif yyxchar, ok = yyXLAT[yychar]; !ok {\n\t\t\tyyxchar = len(yySymNames) // > tab width\n\t\t}\n\t}\n\tif yyDebug >= 4 {\n\t\tvar a []int\n\t\tfor _, v := range yyS[:yyp+1] {\n\t\t\ta = append(a, v.yys)\n\t\t}\n\t\t__yyfmt__.Printf(\"state stack %v\\n\", a)\n\t}\n\trow := yyParseTab[yystate]\n\tyyn = 0\n\tif yyxchar < len(row) {\n\t\tif yyn = int(row[yyxchar]); yyn != 0 {\n\t\t\tyyn += yyTabOfs\n\t\t}\n\t}\n\tswitch {\n\tcase yyn > 0: // shift\n\t\tyychar = -1\n\t\tyyVAL = yylval\n\t\tyystate = yyn\n\t\tyyshift = yyn\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Printf(\"shift, and goto state %d\\n\", yystate)\n\t\t}\n\t\tif Errflag > 0 {\n\t\t\tErrflag--\n\t\t}\n\t\tgoto yystack\n\tcase yyn < 0: // reduce\n\tcase yystate == 1: // accept\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Println(\"accept\")\n\t\t}\n\t\tgoto ret0\n\t}\n\n\tif yyn == 0 {\n\t\t/* error ... attempt to resume parsing */\n\t\tswitch Errflag {\n\t\tcase 0: /* brand new error */\n\t\t\tif yyDebug >= 1 {\n\t\t\t\t__yyfmt__.Printf(\"no action for %s in state %d\\n\", yySymName(yychar), yystate)\n\t\t\t}\n\t\t\tmsg, ok := yyXErrors[yyXError{yystate, yyxchar}]\n\t\t\tif !ok {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yystate, -1}]\n\t\t\t}\n\t\t\tif !ok && yyshift != 0 {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yyshift, yyxchar}]\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yyshift, -1}]\n\t\t\t}\n\t\t\tif yychar > 0 {\n\t\t\t\tls := yyTokenLiteralStrings[yychar]\n\t\t\t\tif ls == \"\" {\n\t\t\t\t\tls = yySymName(yychar)\n\t\t\t\t}\n\t\t\t\tif ls != \"\" {\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase msg == \"\":\n\t\t\t\t\t\tmsg = __yyfmt__.Sprintf(\"unexpected %s\", ls)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tmsg = __yyfmt__.Sprintf(\"unexpected %s, %s\", ls, msg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif msg == \"\" {\n\t\t\t\tmsg = \"syntax error\"\n\t\t\t}\n\t\t\tyylex.Error(msg)\n\t\t\tNerrs++\n\t\t\tfallthrough\n\n\t\tcase 1, 2: /* incompletely recovered error ... try again */\n\t\t\tErrflag = 3\n\n\t\t\t/* find a state where \"error\" is a legal shift action */\n\t\t\tfor yyp >= 0 {\n\t\t\t\trow := yyParseTab[yyS[yyp].yys]\n\t\t\t\tif yyError < len(row) {\n\t\t\t\t\tyyn = int(row[yyError]) + yyTabOfs\n\t\t\t\t\tif yyn > 0 { // hit\n\t\t\t\t\t\tif yyDebug >= 2 {\n\t\t\t\t\t\t\t__yyfmt__.Printf(\"error recovery found error shift in state %d\\n\", yyS[yyp].yys)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyystate = yyn /* simulate a shift of \"error\" */\n\t\t\t\t\t\tgoto yystack\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* the current p has no shift on \"error\", pop stack */\n\t\t\t\tif yyDebug >= 2 {\n\t\t\t\t\t__yyfmt__.Printf(\"error recovery pops state %d\\n\", yyS[yyp].yys)\n\t\t\t\t}\n\t\t\t\tyyp--\n\t\t\t}\n\t\t\t/* there is no state on the stack with an error shift ... abort */\n\t\t\tif yyDebug >= 2 {\n\t\t\t\t__yyfmt__.Printf(\"error recovery failed\\n\")\n\t\t\t}\n\t\t\tgoto ret1\n\n\t\tcase 3: /* no shift yet; clobber input char */\n\t\t\tif yyDebug >= 2 {\n\t\t\t\t__yyfmt__.Printf(\"error recovery discards %s\\n\", yySymName(yychar))\n\t\t\t}\n\t\t\tif yychar == yyEofCode {\n\t\t\t\tgoto ret1\n\t\t\t}\n\n\t\t\tyychar = -1\n\t\t\tgoto yynewstate /* try again in the same state */\n\t\t}\n\t}\n\n\tr := -yyn\n\tx0 := yyReductions[r]\n\tx, n := x0.xsym, x0.components\n\tyypt := yyp\n\t_ = yypt // guard against \"declared and not used\"\n\n\tyyp -= n\n\tif yyp+1 >= len(yyS) {\n\t\tnyys := make([]yySymType, len(yyS)*2)\n\t\tcopy(nyys, yyS)\n\t\tyyS = nyys\n\t}\n\tyyVAL = yyS[yyp+1]\n\n\t/* consult goto table to find next state */\n\texState := yystate\n\tyystate = int(yyParseTab[yyS[yyp].yys][x]) + yyTabOfs\n\t/* reduction by production r */\n\tif yyDebug >= 2 {\n\t\t__yyfmt__.Printf(\"reduce using rule %v (%s), and goto state %d\\n\", r, yySymNames[x], yystate)\n\t}\n\n\tswitch r {\n\tcase 1:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.preprocessingFile = nil\n\t\t}\n\tcase 2:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.preprocessingFile = yyS[yypt-0].node.(*PreprocessingFile)\n\t\t}\n\tcase 3:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.constantExpression = nil\n\t\t}\n\tcase 4:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.constantExpression = yyS[yypt-0].node.(*ConstantExpression)\n\t\t}\n\tcase 5:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.translationUnit = nil\n\t\t}\n\tcase 6:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif lx.report.Errors(false) == nil && lx.scope.kind != ScopeFile {\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\n\t\t\tlx.translationUnit = yyS[yypt-0].node.(*TranslationUnit).reverse()\n\t\t\tlx.translationUnit.Declarations = lx.scope\n\t\t}\n\tcase 7:\n\t\t{\n\t\t\tyyVAL.node = &EnumerationConstant{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 8:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExpressionList{\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 9:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExpressionList{\n\t\t\t\tCase: 1,\n\t\t\t\tArgumentExpressionList: yyS[yypt-2].node.(*ArgumentExpressionList),\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 10:\n\t\t{\n\t\t\tyyVAL.node = (*ArgumentExpressionListOpt)(nil)\n\t\t}\n\tcase 11:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExpressionListOpt{\n\t\t\t\tArgumentExpressionList: yyS[yypt-0].node.(*ArgumentExpressionList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 12:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expression{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 13:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 14:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  2,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 15:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  3,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 16:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  4,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 17:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  5,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 18:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:  6,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 19:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:           7,\n\t\t\t\tToken:          yyS[yypt-2].Token,\n\t\t\t\tExpressionList: yyS[yypt-1].node.(*ExpressionList).reverse(),\n\t\t\t\tToken2:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 20:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:           8,\n\t\t\t\tExpression:     yyS[yypt-3].node.(*Expression),\n\t\t\t\tToken:          yyS[yypt-2].Token,\n\t\t\t\tExpressionList: yyS[yypt-1].node.(*ExpressionList).reverse(),\n\t\t\t\tToken2:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 21:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expression{\n\t\t\t\tCase:       9,\n\t\t\t\tExpression: yyS[yypt-3].node.(*Expression),\n\t\t\t\tToken:      yyS[yypt-2].Token,\n\t\t\t\tArgumentExpressionListOpt: yyS[yypt-1].node.(*ArgumentExpressionListOpt),\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\to := lhs.ArgumentExpressionListOpt\n\t\t\tif o == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif lhs.Expression.Case == 0 { // IDENTIFIER\n\t\t\t\tif lx.tweaks.enableBuiltinConstantP && lhs.Expression.Token.Val == idBuiltinConstantP {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tb := lhs.Expression.scope.Lookup(NSIdentifiers, lhs.Expression.Token.Val)\n\t\t\t\tif b.Node == nil && lx.tweaks.enableImplicitFuncDef {\n\t\t\t\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\t\t\t\tl.Expression.eval(lx)\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlhs.Expression.eval(lx)\n\t\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\t\tl.Expression.eval(lx)\n\t\t\t}\n\t\t}\n\tcase 22:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       10,\n\t\t\t\tExpression: yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tToken2:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 23:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       11,\n\t\t\t\tExpression: yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tToken2:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 24:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       12,\n\t\t\t\tExpression: yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 25:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       13,\n\t\t\t\tExpression: yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 26:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:            14,\n\t\t\t\tToken:           yyS[yypt-6].Token,\n\t\t\t\tTypeName:        yyS[yypt-5].node.(*TypeName),\n\t\t\t\tToken2:          yyS[yypt-4].Token,\n\t\t\t\tToken3:          yyS[yypt-3].Token,\n\t\t\t\tInitializerList: yyS[yypt-2].node.(*InitializerList).reverse(),\n\t\t\t\tCommaOpt:        yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken4:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 27:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       15,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 28:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       16,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 29:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       17,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 30:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       18,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 31:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       19,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 32:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       20,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 33:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       21,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 34:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       22,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 35:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       23,\n\t\t\t\tToken:      yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 36:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:     24,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 37:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:       25,\n\t\t\t\tToken:      yyS[yypt-3].Token,\n\t\t\t\tTypeName:   yyS[yypt-2].node.(*TypeName),\n\t\t\t\tToken2:     yyS[yypt-1].Token,\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 38:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        26,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 39:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        27,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 40:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        28,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 41:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        29,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 42:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        30,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 43:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        31,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 44:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        32,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 45:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        33,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 46:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        34,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 47:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        35,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 48:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        36,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 49:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        37,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 50:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        38,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 51:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        39,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 52:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        40,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 53:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        41,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 54:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        42,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 55:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        43,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 56:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:           44,\n\t\t\t\tExpression:     yyS[yypt-4].node.(*Expression),\n\t\t\t\tToken:          yyS[yypt-3].Token,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList).reverse(),\n\t\t\t\tToken2:         yyS[yypt-1].Token,\n\t\t\t\tExpression2:    yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 57:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        45,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 58:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        46,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 59:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        47,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 60:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        48,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 61:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        49,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 62:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        50,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 63:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        51,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 64:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        52,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 65:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        53,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 66:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        54,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 67:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:        55,\n\t\t\t\tExpression:  yyS[yypt-2].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 68:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:     56,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 69:\n\t\t{\n\t\t\tyyVAL.node = &Expression{\n\t\t\t\tCase:              57,\n\t\t\t\tToken:             yyS[yypt-2].Token,\n\t\t\t\tCompoundStatement: yyS[yypt-1].node.(*CompoundStatement),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 70:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expression{\n\t\t\t\tCase:   58,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t\t}\n\t\t}\n\tcase 71:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expression{\n\t\t\t\tCase:        59,\n\t\t\t\tExpression:  yyS[yypt-3].node.(*Expression),\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tToken2:      yyS[yypt-1].Token,\n\t\t\t\tExpression2: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableOmitConditionalOperand {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"omitting conditional operand not enabled\")\n\t\t\t}\n\t\t}\n\tcase 72:\n\t\t{\n\t\t\tyyVAL.node = (*ExpressionOpt)(nil)\n\t\t}\n\tcase 73:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ExpressionOpt{\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Expression.eval(lx)\n\t\t}\n\tcase 74:\n\t\t{\n\t\t\tyyVAL.node = &ExpressionList{\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 75:\n\t\t{\n\t\t\tyyVAL.node = &ExpressionList{\n\t\t\t\tCase:           1,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList),\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tExpression:     yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t}\n\tcase 76:\n\t\t{\n\t\t\tyyVAL.node = (*ExpressionListOpt)(nil)\n\t\t}\n\tcase 77:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ExpressionListOpt{\n\t\t\t\tExpressionList: yyS[yypt-0].node.(*ExpressionList).reverse(),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 78:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.constExprToks = []xc.Token{lx.last}\n\t\t}\n\tcase 79:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ConstantExpression{\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Value, lhs.Type = lhs.Expression.eval(lx)\n\t\t\tif lhs.Value == nil {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"not a constant expression\")\n\t\t\t}\n\t\t\tl := lx.constExprToks\n\t\t\tlhs.toks = l[:len(l)-1]\n\t\t\tlx.constExprToks = nil\n\t\t}\n\tcase 80:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Declaration{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-2].node.(*DeclarationSpecifiers),\n\t\t\t\tInitDeclaratorListOpt: yyS[yypt-1].node.(*InitDeclaratorListOpt),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tts0 := lhs.DeclarationSpecifiers.typeSpecifiers()\n\t\t\tif ts0 == 0 && lx.tweaks.enableImplicitIntType {\n\t\t\t\tlhs.DeclarationSpecifiers.typeSpecifier = tsEncode(tsInt)\n\t\t\t}\n\t\t\tts := tsDecode(lhs.DeclarationSpecifiers.typeSpecifiers())\n\t\t\tok := false\n\t\t\tfor _, v := range ts {\n\t\t\t\tif v == tsStructSpecifier || v == tsUnionSpecifier {\n\t\t\t\t\tok = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\ts := lhs.DeclarationSpecifiers\n\t\t\t\td := &Declarator{specifier: s}\n\t\t\t\tdd := &DirectDeclarator{\n\t\t\t\t\tToken:      xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\t\tdeclarator: d,\n\t\t\t\t\tidScope:    lx.scope,\n\t\t\t\t\tspecifier:  s,\n\t\t\t\t}\n\t\t\t\td.DirectDeclarator = dd\n\t\t\t\td.setFull(lx)\n\t\t\t\tfor l := lhs.DeclarationSpecifiers; l != nil; {\n\t\t\t\t\tts := l.TypeSpecifier\n\t\t\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tif o := l.DeclarationSpecifiersOpt; o != nil {\n\t\t\t\t\t\tl = o.DeclarationSpecifiers\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\to := lhs.InitDeclaratorListOpt\n\t\t\tif o != nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ts := lhs.DeclarationSpecifiers\n\t\t\td := &Declarator{specifier: s}\n\t\t\tdd := &DirectDeclarator{\n\t\t\t\tToken:      xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\tdeclarator: d,\n\t\t\t\tidScope:    lx.scope,\n\t\t\t\tspecifier:  s,\n\t\t\t}\n\t\t\td.DirectDeclarator = dd\n\t\t\td.setFull(lx)\n\t\t\tlhs.declarator = d\n\t\t}\n\tcase 81:\n\t\t{\n\t\t\tyyVAL.node = &Declaration{\n\t\t\t\tCase: 1,\n\t\t\t\tStaticAssertDeclaration: yyS[yypt-0].node.(*StaticAssertDeclaration),\n\t\t\t}\n\t\t}\n\tcase 82:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DeclarationSpecifiers{\n\t\t\t\tStorageClassSpecifier:    yyS[yypt-1].node.(*StorageClassSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.StorageClassSpecifier\n\t\t\tb := lhs.DeclarationSpecifiersOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.attr = a.attr\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif a.attr&b.attr != 0 {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = a.attr | b.attr\n\t\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\t\tif lhs.StorageClassSpecifier.Case != 0 /* \"typedef\" */ && lhs.IsTypedef() {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t\t}\n\t\t}\n\tcase 83:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DeclarationSpecifiers{\n\t\t\t\tCase:                     1,\n\t\t\t\tTypeSpecifier:            yyS[yypt-1].node.(*TypeSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.TypeSpecifier\n\t\t\tb := lhs.DeclarationSpecifiersOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = b.attr\n\t\t\ttsb := tsDecode(b.typeSpecifier)\n\t\t\tif len(tsb) == 1 && tsb[0] == tsTypedefName && lx.tweaks.allowCompatibleTypedefRedefinitions {\n\t\t\t\ttsb[0] = 0\n\t\t\t}\n\t\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsb...)...)\n\t\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\t\tts = tsEncode(tsInt)\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t\t}\n\t\t\tlhs.typeSpecifier = ts\n\t\t}\n\tcase 84:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DeclarationSpecifiers{\n\t\t\t\tCase:                     2,\n\t\t\t\tTypeQualifier:            yyS[yypt-1].node.(*TypeQualifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.TypeQualifier\n\t\t\tb := lhs.DeclarationSpecifiersOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.attr = a.attr\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif a.attr&b.attr != 0 {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = a.attr | b.attr\n\t\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\t\tif lhs.IsTypedef() {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\t}\n\t\t}\n\tcase 85:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DeclarationSpecifiers{\n\t\t\t\tCase:                     3,\n\t\t\t\tFunctionSpecifier:        yyS[yypt-1].node.(*FunctionSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.FunctionSpecifier\n\t\t\tb := lhs.DeclarationSpecifiersOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.attr = a.attr\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif a.attr&b.attr != 0 {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = a.attr | b.attr\n\t\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\t\tif lhs.IsTypedef() {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t\t}\n\t\t}\n\tcase 86:\n\t\t{\n\t\t\tyyVAL.node = (*DeclarationSpecifiersOpt)(nil)\n\t\t}\n\tcase 87:\n\t\t{\n\t\t\tlhs := &DeclarationSpecifiersOpt{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-0].node.(*DeclarationSpecifiers),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = lhs.DeclarationSpecifiers.attr\n\t\t\tlhs.typeSpecifier = lhs.DeclarationSpecifiers.typeSpecifier\n\t\t}\n\tcase 88:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorList{\n\t\t\t\tInitDeclarator: yyS[yypt-0].node.(*InitDeclarator),\n\t\t\t}\n\t\t}\n\tcase 89:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorList{\n\t\t\t\tCase:               1,\n\t\t\t\tInitDeclaratorList: yyS[yypt-2].node.(*InitDeclaratorList),\n\t\t\t\tToken:              yyS[yypt-1].Token,\n\t\t\t\tInitDeclarator:     yyS[yypt-0].node.(*InitDeclarator),\n\t\t\t}\n\t\t}\n\tcase 90:\n\t\t{\n\t\t\tyyVAL.node = (*InitDeclaratorListOpt)(nil)\n\t\t}\n\tcase 91:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorListOpt{\n\t\t\t\tInitDeclaratorList: yyS[yypt-0].node.(*InitDeclaratorList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 92:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &InitDeclarator{\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.setFull(lx)\n\t\t}\n\tcase 93:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\td := yyS[yypt-0].node.(*Declarator)\n\t\t\td.setFull(lx)\n\t\t}\n\tcase 94:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &InitDeclarator{\n\t\t\t\tCase:        1,\n\t\t\t\tDeclarator:  yyS[yypt-3].node.(*Declarator),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tInitializer: yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\td := lhs.Declarator\n\t\t\tlhs.Initializer.typeCheck(&d.Type, d.Type, lhs.Declarator.specifier.IsStatic(), lx)\n\t\t\tif d.Type.Specifier().IsExtern() {\n\t\t\t\tid, _ := d.Identifier()\n\t\t\t\tlx.report.Err(d.Pos(), \"'%s' initialized and declared 'extern'\", dict.S(id))\n\t\t\t}\n\t\t}\n\tcase 95:\n\t\t{\n\t\t\tlhs := &StorageClassSpecifier{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saTypedef\n\t\t}\n\tcase 96:\n\t\t{\n\t\t\tlhs := &StorageClassSpecifier{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saExtern\n\t\t}\n\tcase 97:\n\t\t{\n\t\t\tlhs := &StorageClassSpecifier{\n\t\t\t\tCase:  2,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saStatic\n\t\t}\n\tcase 98:\n\t\t{\n\t\t\tlhs := &StorageClassSpecifier{\n\t\t\t\tCase:  3,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saAuto\n\t\t}\n\tcase 99:\n\t\t{\n\t\t\tlhs := &StorageClassSpecifier{\n\t\t\t\tCase:  4,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saRegister\n\t\t}\n\tcase 100:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsVoid)\n\t\t}\n\tcase 101:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsChar)\n\t\t}\n\tcase 102:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  2,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsShort)\n\t\t}\n\tcase 103:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  3,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsInt)\n\t\t}\n\tcase 104:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  4,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsLong)\n\t\t}\n\tcase 105:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  5,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsFloat)\n\t\t}\n\tcase 106:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  6,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsDouble)\n\t\t}\n\tcase 107:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  7,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsSigned)\n\t\t}\n\tcase 108:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  8,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsUnsigned)\n\t\t}\n\tcase 109:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  9,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsBool)\n\t\t}\n\tcase 110:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  10,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsComplex)\n\t\t}\n\tcase 111:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase: 11,\n\t\t\t\tStructOrUnionSpecifier: yyS[yypt-0].node.(*StructOrUnionSpecifier),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(lhs.StructOrUnionSpecifier.typeSpecifiers())\n\t\t}\n\tcase 112:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:          12,\n\t\t\t\tEnumSpecifier: yyS[yypt-0].node.(*EnumSpecifier),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsEnumSpecifier)\n\t\t}\n\tcase 113:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  13,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsTypedefName)\n\t\t\t_, lhs.scope = lx.scope.Lookup2(NSIdentifiers, lhs.Token.Val)\n\t\t}\n\tcase 114:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:       14,\n\t\t\t\tToken:      yyS[yypt-3].Token,\n\t\t\t\tToken2:     yyS[yypt-2].Token,\n\t\t\t\tExpression: yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\t\t_, lhs.Type = lhs.Expression.eval(lx)\n\t\t}\n\tcase 115:\n\t\t{\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:     15,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\t\tlhs.Type = undefined\n\t\t\tif t := lhs.TypeName.Type; t != nil {\n\t\t\t\tlhs.Type = t\n\t\t\t}\n\t\t}\n\tcase 116:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif o := yyS[yypt-1].node.(*IdentifierOpt); o != nil {\n\t\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t\t}\n\t\t\tlx.pushScope(ScopeMembers)\n\t\t\tlx.scope.isUnion = yyS[yypt-2].node.(*StructOrUnion).Case == 1 // \"union\"\n\t\t\tlx.scope.prevStructDeclarator = nil\n\t\t}\n\tcase 117:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructOrUnionSpecifier{\n\t\t\t\tStructOrUnion: yyS[yypt-5].node.(*StructOrUnion),\n\t\t\t\tIdentifierOpt: yyS[yypt-4].node.(*IdentifierOpt),\n\t\t\t\tToken:         yyS[yypt-3].Token,\n\t\t\t\tStructDeclarationList: yyS[yypt-1].node.(*StructDeclarationList).reverse(),\n\t\t\t\tToken2:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tsc := lx.scope\n\t\t\tlhs.scope = sc\n\t\t\tif sc.bitOffset != 0 {\n\t\t\t\tfinishBitField(lhs, lx)\n\t\t\t}\n\n\t\t\ti := 0\n\t\t\tvar bt Type\n\t\t\tvar d *Declarator\n\t\t\tfor l := lhs.StructDeclarationList; l != nil; l = l.StructDeclarationList {\n\t\t\t\tfor l := l.StructDeclaration.StructDeclaratorList; l != nil; l = l.StructDeclaratorList {\n\t\t\t\t\tswitch sd := l.StructDeclarator; sd.Case {\n\t\t\t\t\tcase 0: // Declarator\n\t\t\t\t\t\td = sd.Declarator\n\t\t\t\t\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\t\t\t\t\tif o := sd.DeclaratorOpt; o != nil {\n\t\t\t\t\t\t\tx := o.Declarator\n\t\t\t\t\t\t\tif x.bitOffset == 0 {\n\t\t\t\t\t\t\t\td = x\n\t\t\t\t\t\t\t\tbt = lx.scope.bitFieldTypes[i]\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tx.bitFieldType = bt\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlx.scope.bitFieldTypes = nil\n\n\t\t\tlhs.alignOf = sc.maxAlign\n\t\t\tswitch {\n\t\t\tcase sc.isUnion:\n\t\t\t\tlhs.sizeOf = align(sc.maxSize, sc.maxAlign)\n\t\t\tdefault:\n\t\t\t\toff := sc.offset\n\t\t\t\tlhs.sizeOf = align(sc.offset, sc.maxAlign)\n\t\t\t\tif d != nil {\n\t\t\t\t\td.padding = lhs.sizeOf - off\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlx.popScope(lhs.Token2)\n\t\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t\t}\n\t\t}\n\tcase 118:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructOrUnionSpecifier{\n\t\t\t\tCase:          1,\n\t\t\t\tStructOrUnion: yyS[yypt-1].node.(*StructOrUnion),\n\t\t\t\tToken:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.declareStructTag(lhs.Token, lx.report)\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 119:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructOrUnionSpecifier{\n\t\t\t\tCase:          2,\n\t\t\t\tStructOrUnion: yyS[yypt-3].node.(*StructOrUnion),\n\t\t\t\tIdentifierOpt: yyS[yypt-2].node.(*IdentifierOpt),\n\t\t\t\tToken:         yyS[yypt-1].Token,\n\t\t\t\tToken2:        yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableEmptyStructs {\n\t\t\t\tlx.report.Err(lhs.Token.Pos(), \"empty structs/unions not allowed\")\n\t\t\t}\n\t\t\tif o := yyS[yypt-2].node.(*IdentifierOpt); o != nil {\n\t\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t\t}\n\t\t\tlx.scope.isUnion = yyS[yypt-3].node.(*StructOrUnion).Case == 1 // \"union\"\n\t\t\tlx.scope.prevStructDeclarator = nil\n\t\t\tlhs.alignOf = 1\n\t\t\tlhs.sizeOf = 0\n\t\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t\t}\n\t\t}\n\tcase 120:\n\t\t{\n\t\t\tyyVAL.node = &StructOrUnion{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 121:\n\t\t{\n\t\t\tyyVAL.node = &StructOrUnion{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 122:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarationList{\n\t\t\t\tStructDeclaration: yyS[yypt-0].node.(*StructDeclaration),\n\t\t\t}\n\t\t}\n\tcase 123:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarationList{\n\t\t\t\tCase: 1,\n\t\t\t\tStructDeclarationList: yyS[yypt-1].node.(*StructDeclarationList),\n\t\t\t\tStructDeclaration:     yyS[yypt-0].node.(*StructDeclaration),\n\t\t\t}\n\t\t}\n\tcase 124:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructDeclaration{\n\t\t\t\tSpecifierQualifierList: yyS[yypt-2].node.(*SpecifierQualifierList),\n\t\t\t\tStructDeclaratorList:   yyS[yypt-1].node.(*StructDeclaratorList).reverse(),\n\t\t\t\tToken:                  yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\ts := lhs.SpecifierQualifierList\n\t\t\tif k := s.kind(); k != Struct && k != Union {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\td := &Declarator{specifier: s}\n\t\t\tdd := &DirectDeclarator{\n\t\t\t\tToken:      xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\tdeclarator: d,\n\t\t\t\tidScope:    lx.scope,\n\t\t\t\tspecifier:  s,\n\t\t\t}\n\t\t\td.DirectDeclarator = dd\n\t\t\td.setFull(lx)\n\t\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\t\tts := l.TypeSpecifier\n\t\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tcase 125:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructDeclaration{\n\t\t\t\tCase: 1,\n\t\t\t\tSpecifierQualifierList: yyS[yypt-1].node.(*SpecifierQualifierList),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\ts := lhs.SpecifierQualifierList\n\t\t\tif !lx.tweaks.enableAnonymousStructFields {\n\t\t\t\tlx.report.Err(lhs.Token.Pos(), \"unnamed fields not allowed\")\n\t\t\t} else if k := s.kind(); k != Struct && k != Union {\n\t\t\t\tlx.report.Err(lhs.Token.Pos(), \"only unnamed structs and unions are allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\td := &Declarator{specifier: s}\n\t\t\tdd := &DirectDeclarator{\n\t\t\t\tToken:      xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\tdeclarator: d,\n\t\t\t\tidScope:    lx.scope,\n\t\t\t\tspecifier:  s,\n\t\t\t}\n\t\t\td.DirectDeclarator = dd\n\t\t\td.setFull(lx)\n\n\t\t\t// we have no struct declarators to parse, so we have to create the case of one implicit declarator\n\t\t\t// because else the size of anonymous members is not included in the struct size!\n\t\t\tdummy := &StructDeclarator{Declarator: d}\n\t\t\tdummy.post(lx)\n\n\t\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\t\tts := l.TypeSpecifier\n\t\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tcase 126:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaration{\n\t\t\t\tCase: 2,\n\t\t\t\tStaticAssertDeclaration: yyS[yypt-0].node.(*StaticAssertDeclaration),\n\t\t\t}\n\t\t}\n\tcase 127:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &SpecifierQualifierList{\n\t\t\t\tTypeSpecifier:             yyS[yypt-1].node.(*TypeSpecifier),\n\t\t\t\tSpecifierQualifierListOpt: yyS[yypt-0].node.(*SpecifierQualifierListOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.TypeSpecifier\n\t\t\tb := lhs.SpecifierQualifierListOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = b.attr\n\t\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsDecode(b.typeSpecifier)...)...)\n\t\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.typeSpecifier = ts\n\t\t}\n\tcase 128:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &SpecifierQualifierList{\n\t\t\t\tCase:                      1,\n\t\t\t\tTypeQualifier:             yyS[yypt-1].node.(*TypeQualifier),\n\t\t\t\tSpecifierQualifierListOpt: yyS[yypt-0].node.(*SpecifierQualifierListOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.specifier = lhs\n\t\t\ta := lhs.TypeQualifier\n\t\t\tb := lhs.SpecifierQualifierListOpt\n\t\t\tif b == nil {\n\t\t\t\tlhs.attr = a.attr\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif a.attr&b.attr != 0 {\n\t\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = a.attr | b.attr\n\t\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\t}\n\tcase 129:\n\t\t{\n\t\t\tyyVAL.node = (*SpecifierQualifierListOpt)(nil)\n\t\t}\n\tcase 130:\n\t\t{\n\t\t\tlhs := &SpecifierQualifierListOpt{\n\t\t\t\tSpecifierQualifierList: yyS[yypt-0].node.(*SpecifierQualifierList),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = lhs.SpecifierQualifierList.attr\n\t\t\tlhs.typeSpecifier = lhs.SpecifierQualifierList.typeSpecifier\n\t\t}\n\tcase 131:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaratorList{\n\t\t\t\tStructDeclarator: yyS[yypt-0].node.(*StructDeclarator),\n\t\t\t}\n\t\t}\n\tcase 132:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaratorList{\n\t\t\t\tCase:                 1,\n\t\t\t\tStructDeclaratorList: yyS[yypt-2].node.(*StructDeclaratorList),\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tStructDeclarator:     yyS[yypt-0].node.(*StructDeclarator),\n\t\t\t}\n\t\t}\n\tcase 133:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructDeclarator{\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.setFull(lx)\n\t\t\tlhs.post(lx)\n\t\t}\n\tcase 134:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructDeclarator{\n\t\t\t\tCase:               1,\n\t\t\t\tDeclaratorOpt:      yyS[yypt-2].node.(*DeclaratorOpt),\n\t\t\t\tToken:              yyS[yypt-1].Token,\n\t\t\t\tConstantExpression: yyS[yypt-0].node.(*ConstantExpression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tm := lx.model\n\t\t\te := lhs.ConstantExpression\n\t\t\tif e.Value == nil {\n\t\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t\t}\n\t\t\tif !IsIntType(e.Type) {\n\t\t\t\tlx.report.Err(e.Pos(), \"bit field width not an integer (have '%s')\", e.Type)\n\t\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t\t}\n\t\t\tif o := lhs.DeclaratorOpt; o != nil {\n\t\t\t\to.Declarator.setFull(lx)\n\t\t\t}\n\t\t\tlhs.post(lx)\n\t\t}\n\tcase 135:\n\t\t{\n\t\t\tyyVAL.node = (*CommaOpt)(nil)\n\t\t}\n\tcase 136:\n\t\t{\n\t\t\tyyVAL.node = &CommaOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 137:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif o := yyS[yypt-0].node.(*IdentifierOpt); o != nil {\n\t\t\t\tlx.scope.declareEnumTag(o.Token, lx.report)\n\t\t\t}\n\t\t\tlx.iota = 0\n\t\t}\n\tcase 138:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &EnumSpecifier{\n\t\t\t\tToken:          yyS[yypt-6].Token,\n\t\t\t\tIdentifierOpt:  yyS[yypt-5].node.(*IdentifierOpt),\n\t\t\t\tToken2:         yyS[yypt-3].Token,\n\t\t\t\tEnumeratorList: yyS[yypt-2].node.(*EnumeratorList).reverse(),\n\t\t\t\tCommaOpt:       yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken3:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\t\tlx.scope.defineEnumTag(o.Token, lhs, lx.report)\n\t\t\t}\n\t\t\tif !lx.tweaks.enableUnsignedEnums {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.unsigned = true\n\t\tloop:\n\t\t\tfor l := lhs.EnumeratorList; l != nil; l = l.EnumeratorList {\n\t\t\t\tswitch e := l.Enumerator; x := e.Value.(type) {\n\t\t\t\tcase int32:\n\t\t\t\t\tif x < 0 {\n\t\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\t\tbreak loop\n\t\t\t\t\t}\n\t\t\t\tcase int64:\n\t\t\t\t\tif x < 0 {\n\t\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\t\tbreak loop\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%s: TODO Enumerator.Value type %T\", position(e.Pos()), x))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tcase 139:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &EnumSpecifier{\n\t\t\t\tCase:   1,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.declareEnumTag(lhs.Token2, lx.report)\n\t\t}\n\tcase 140:\n\t\t{\n\t\t\tyyVAL.node = &EnumeratorList{\n\t\t\t\tEnumerator: yyS[yypt-0].node.(*Enumerator),\n\t\t\t}\n\t\t}\n\tcase 141:\n\t\t{\n\t\t\tyyVAL.node = &EnumeratorList{\n\t\t\t\tCase:           1,\n\t\t\t\tEnumeratorList: yyS[yypt-2].node.(*EnumeratorList),\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tEnumerator:     yyS[yypt-0].node.(*Enumerator),\n\t\t\t}\n\t\t}\n\tcase 142:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Enumerator{\n\t\t\t\tEnumerationConstant: yyS[yypt-0].node.(*EnumerationConstant),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tm := lx.model\n\t\t\tv := m.MustConvert(lx.iota, m.IntType)\n\t\t\tlhs.Value = v\n\t\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t\t}\n\tcase 143:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Enumerator{\n\t\t\t\tCase:                1,\n\t\t\t\tEnumerationConstant: yyS[yypt-2].node.(*EnumerationConstant),\n\t\t\t\tToken:               yyS[yypt-1].Token,\n\t\t\t\tConstantExpression:  yyS[yypt-0].node.(*ConstantExpression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tm := lx.model\n\t\t\te := lhs.ConstantExpression\n\t\t\tvar v interface{}\n\t\t\t// [0], 6.7.2.2\n\t\t\t// The expression that defines the value of an enumeration\n\t\t\t// constant shall be an integer constant expression that has a\n\t\t\t// value representable as an int.\n\t\t\tswitch {\n\t\t\tcase !IsIntType(e.Type):\n\t\t\t\tlx.report.Err(e.Pos(), \"not an integer constant expression (have '%s')\", e.Type)\n\t\t\t\tv = m.MustConvert(int32(0), m.IntType)\n\t\t\tdefault:\n\t\t\t\tvar ok bool\n\t\t\t\tif v, ok = m.enumValueToInt(e.Value); !ok {\n\t\t\t\t\tlx.report.Err(e.Pos(), \"overflow in enumeration value: %v\", e.Value)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlhs.Value = v\n\t\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t\t}\n\tcase 144:\n\t\t{\n\t\t\tlhs := &TypeQualifier{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saConst\n\t\t}\n\tcase 145:\n\t\t{\n\t\t\tlhs := &TypeQualifier{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saRestrict\n\t\t}\n\tcase 146:\n\t\t{\n\t\t\tlhs := &TypeQualifier{\n\t\t\t\tCase:  2,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saVolatile\n\t\t}\n\tcase 147:\n\t\t{\n\t\t\tlhs := &FunctionSpecifier{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saInline\n\t\t}\n\tcase 148:\n\t\t{\n\t\t\tlhs := &FunctionSpecifier{\n\t\t\t\tCase:  1,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = saNoreturn\n\t\t}\n\tcase 149:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Declarator{\n\t\t\t\tPointerOpt:       yyS[yypt-1].node.(*PointerOpt),\n\t\t\t\tDirectDeclarator: yyS[yypt-0].node.(*DirectDeclarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.specifier = lx.scope.specifier\n\t\t\tlhs.DirectDeclarator.declarator = lhs\n\t\t}\n\tcase 150:\n\t\t{\n\t\t\tyyVAL.node = (*DeclaratorOpt)(nil)\n\t\t}\n\tcase 151:\n\t\t{\n\t\t\tyyVAL.node = &DeclaratorOpt{\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t}\n\tcase 152:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.specifier = lx.scope.specifier\n\t\t\tlx.scope.declareIdentifier(lhs.Token, lhs, lx.report)\n\t\t\tlhs.idScope = lx.scope\n\t\t}\n\tcase 153:\n\t\t{\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:       1,\n\t\t\t\tToken:      yyS[yypt-2].Token,\n\t\t\t\tDeclarator: yyS[yypt-1].node.(*Declarator),\n\t\t\t\tToken2:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.specifier = nil\n\t\t\tlhs.Declarator.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 154:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:                 2,\n\t\t\t\tDirectDeclarator:     yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExpressionOpt:        yyS[yypt-1].node.(*ExpressionOpt),\n\t\t\t\tToken2:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.elements = -1\n\t\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\t\tvar err error\n\t\t\t\tif lhs.elements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 155:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:                 3,\n\t\t\t\tDirectDeclarator:     yyS[yypt-5].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-4].Token,\n\t\t\t\tToken2:               yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExpression:           yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tvar err error\n\t\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 156:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:              4,\n\t\t\t\tDirectDeclarator:  yyS[yypt-5].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-4].Token,\n\t\t\t\tTypeQualifierList: yyS[yypt-3].node.(*TypeQualifierList).reverse(),\n\t\t\t\tToken2:            yyS[yypt-2].Token,\n\t\t\t\tExpression:        yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tvar err error\n\t\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 157:\n\t\t{\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:                 5,\n\t\t\t\tDirectDeclarator:     yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tToken2:               yyS[yypt-1].Token,\n\t\t\t\tToken3:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t\tlhs.elements = -1\n\t\t}\n\tcase 158:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.pushScope(ScopeParams)\n\t\t}\n\tcase 159:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:              6,\n\t\t\t\tDirectDeclarator:  yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-3].Token,\n\t\t\t\tParameterTypeList: yyS[yypt-1].node.(*ParameterTypeList),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 160:\n\t\t{\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:              7,\n\t\t\t\tDirectDeclarator:  yyS[yypt-3].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-2].Token,\n\t\t\t\tIdentifierListOpt: yyS[yypt-1].node.(*IdentifierListOpt),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.DirectDeclarator.parent = lhs\n\t\t}\n\tcase 161:\n\t\t{\n\t\t\tyyVAL.node = &Pointer{\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-0].node.(*TypeQualifierListOpt),\n\t\t\t}\n\t\t}\n\tcase 162:\n\t\t{\n\t\t\tyyVAL.node = &Pointer{\n\t\t\t\tCase:                 1,\n\t\t\t\tToken:                yyS[yypt-2].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-1].node.(*TypeQualifierListOpt),\n\t\t\t\tPointer:              yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t}\n\tcase 163:\n\t\t{\n\t\t\tyyVAL.node = (*PointerOpt)(nil)\n\t\t}\n\tcase 164:\n\t\t{\n\t\t\tyyVAL.node = &PointerOpt{\n\t\t\t\tPointer: yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t}\n\tcase 165:\n\t\t{\n\t\t\tlhs := &TypeQualifierList{\n\t\t\t\tTypeQualifier: yyS[yypt-0].node.(*TypeQualifier),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.attr = lhs.TypeQualifier.attr\n\t\t}\n\tcase 166:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &TypeQualifierList{\n\t\t\t\tCase:              1,\n\t\t\t\tTypeQualifierList: yyS[yypt-1].node.(*TypeQualifierList),\n\t\t\t\tTypeQualifier:     yyS[yypt-0].node.(*TypeQualifier),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\ta := lhs.TypeQualifierList\n\t\t\tb := lhs.TypeQualifier\n\t\t\tif a.attr&b.attr != 0 {\n\t\t\t\tlx.report.Err(b.Pos(), \"invalid type qualifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlhs.attr = a.attr | b.attr\n\t\t}\n\tcase 167:\n\t\t{\n\t\t\tyyVAL.node = (*TypeQualifierListOpt)(nil)\n\t\t}\n\tcase 168:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifierListOpt{\n\t\t\t\tTypeQualifierList: yyS[yypt-0].node.(*TypeQualifierList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 169:\n\t\t{\n\t\t\tlhs := &ParameterTypeList{\n\t\t\t\tParameterList: yyS[yypt-0].node.(*ParameterList).reverse(),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.post()\n\t\t}\n\tcase 170:\n\t\t{\n\t\t\tlhs := &ParameterTypeList{\n\t\t\t\tCase:          1,\n\t\t\t\tParameterList: yyS[yypt-2].node.(*ParameterList).reverse(),\n\t\t\t\tToken:         yyS[yypt-1].Token,\n\t\t\t\tToken2:        yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.post()\n\t\t}\n\tcase 171:\n\t\t{\n\t\t\tyyVAL.node = (*ParameterTypeListOpt)(nil)\n\t\t}\n\tcase 172:\n\t\t{\n\t\t\tyyVAL.node = &ParameterTypeListOpt{\n\t\t\t\tParameterTypeList: yyS[yypt-0].node.(*ParameterTypeList),\n\t\t\t}\n\t\t}\n\tcase 173:\n\t\t{\n\t\t\tyyVAL.node = &ParameterList{\n\t\t\t\tParameterDeclaration: yyS[yypt-0].node.(*ParameterDeclaration),\n\t\t\t}\n\t\t}\n\tcase 174:\n\t\t{\n\t\t\tyyVAL.node = &ParameterList{\n\t\t\t\tCase:                 1,\n\t\t\t\tParameterList:        yyS[yypt-2].node.(*ParameterList),\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tParameterDeclaration: yyS[yypt-0].node.(*ParameterDeclaration),\n\t\t\t}\n\t\t}\n\tcase 175:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ParameterDeclaration{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-1].node.(*DeclarationSpecifiers),\n\t\t\t\tDeclarator:            yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.setFull(lx)\n\t\t\tlhs.declarator = lhs.Declarator\n\t\t}\n\tcase 176:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ParameterDeclaration{\n\t\t\t\tCase: 1,\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-1].node.(*DeclarationSpecifiers),\n\t\t\t\tAbstractDeclaratorOpt: yyS[yypt-0].node.(*AbstractDeclaratorOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t\t\tlhs.declarator.setFull(lx)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\td := &Declarator{\n\t\t\t\tspecifier: lx.scope.specifier,\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t},\n\t\t\t}\n\t\t\td.DirectDeclarator.declarator = d\n\t\t\tlhs.declarator = d\n\t\t\td.setFull(lx)\n\t\t}\n\tcase 177:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierList{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 178:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierList{\n\t\t\t\tCase:           1,\n\t\t\t\tIdentifierList: yyS[yypt-2].node.(*IdentifierList),\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tToken2:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 179:\n\t\t{\n\t\t\tyyVAL.node = (*IdentifierListOpt)(nil)\n\t\t}\n\tcase 180:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierListOpt{\n\t\t\t\tIdentifierList: yyS[yypt-0].node.(*IdentifierList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 181:\n\t\t{\n\t\t\tyyVAL.node = (*IdentifierOpt)(nil)\n\t\t}\n\tcase 182:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 183:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.pushScope(ScopeBlock)\n\t\t}\n\tcase 184:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &TypeName{\n\t\t\t\tSpecifierQualifierList: yyS[yypt-1].node.(*SpecifierQualifierList),\n\t\t\t\tAbstractDeclaratorOpt:  yyS[yypt-0].node.(*AbstractDeclaratorOpt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t\t} else {\n\t\t\t\td := &Declarator{\n\t\t\t\t\tspecifier: lhs.SpecifierQualifierList,\n\t\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\t\tCase:    0, // IDENTIFIER\n\t\t\t\t\t\tidScope: lx.scope,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t\td.DirectDeclarator.declarator = d\n\t\t\t\tlhs.declarator = d\n\t\t\t}\n\t\t\tlhs.Type = lhs.declarator.setFull(lx)\n\t\t\tlhs.scope = lx.scope\n\t\t\tlx.popScope(xc.Token{})\n\t\t}\n\tcase 185:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &AbstractDeclarator{\n\t\t\t\tPointer: yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\td := &Declarator{\n\t\t\t\tspecifier: lx.scope.specifier,\n\t\t\t\tPointerOpt: &PointerOpt{\n\t\t\t\t\tPointer: lhs.Pointer,\n\t\t\t\t},\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase:    0, // IDENTIFIER\n\t\t\t\t\tidScope: lx.scope,\n\t\t\t\t},\n\t\t\t}\n\t\t\td.DirectDeclarator.declarator = d\n\t\t\tlhs.declarator = d\n\t\t}\n\tcase 186:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &AbstractDeclarator{\n\t\t\t\tCase:                     1,\n\t\t\t\tPointerOpt:               yyS[yypt-1].node.(*PointerOpt),\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-0].node.(*DirectAbstractDeclarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\td := &Declarator{\n\t\t\t\tspecifier:        lx.scope.specifier,\n\t\t\t\tPointerOpt:       lhs.PointerOpt,\n\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t}\n\t\t\td.DirectDeclarator.declarator = d\n\t\t\tlhs.declarator = d\n\t\t}\n\tcase 187:\n\t\t{\n\t\t\tyyVAL.node = (*AbstractDeclaratorOpt)(nil)\n\t\t}\n\tcase 188:\n\t\t{\n\t\t\tyyVAL.node = &AbstractDeclaratorOpt{\n\t\t\t\tAbstractDeclarator: yyS[yypt-0].node.(*AbstractDeclarator),\n\t\t\t}\n\t\t}\n\tcase 189:\n\t\t{\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tToken:              yyS[yypt-2].Token,\n\t\t\t\tAbstractDeclarator: yyS[yypt-1].node.(*AbstractDeclarator),\n\t\t\t\tToken2:             yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.AbstractDeclarator.declarator.specifier = nil\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:       1, // '(' Declarator ')'\n\t\t\t\tDeclarator: lhs.AbstractDeclarator.declarator,\n\t\t\t}\n\t\t\tlhs.AbstractDeclarator.declarator.DirectDeclarator.parent = lhs.directDeclarator\n\t\t}\n\tcase 190:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 1,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-3].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:         yyS[yypt-2].Token,\n\t\t\t\tExpressionOpt: yyS[yypt-1].node.(*ExpressionOpt),\n\t\t\t\tToken2:        yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tnElements := -1\n\t\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\t\tvar err error\n\t\t\t\tif nElements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar dd *DirectDeclarator\n\t\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\t\tcase o == nil:\n\t\t\t\tdd = &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t\t}\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:             2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\t\tDirectDeclarator: dd,\n\t\t\t\tExpressionOpt:    lhs.ExpressionOpt,\n\t\t\t\telements:         nElements,\n\t\t\t}\n\t\t\tdd.parent = lhs.directDeclarator\n\t\t}\n\tcase 191:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 2,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-4].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:             yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierList: yyS[yypt-2].node.(*TypeQualifierList).reverse(),\n\t\t\t\tExpressionOpt:     yyS[yypt-1].node.(*ExpressionOpt),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\t\to.Expression.eval(lx)\n\t\t\t}\n\t\t\tvar dd *DirectDeclarator\n\t\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\t\tcase o == nil:\n\t\t\t\tdd = &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t\t}\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:                 2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\t\tDirectDeclarator:     dd,\n\t\t\t\tTypeQualifierListOpt: &TypeQualifierListOpt{lhs.TypeQualifierList},\n\t\t\t\tExpressionOpt:        lhs.ExpressionOpt,\n\t\t\t}\n\t\t\tdd.parent = lhs.directDeclarator\n\t\t}\n\tcase 192:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 3,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-5].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                yyS[yypt-4].Token,\n\t\t\t\tToken2:               yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExpression:           yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Expression.eval(lx)\n\t\t\tvar dd *DirectDeclarator\n\t\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\t\tcase o == nil:\n\t\t\t\tdd = &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t\t}\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:                 2, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t\t\tDirectDeclarator:     dd,\n\t\t\t\tTypeQualifierListOpt: lhs.TypeQualifierListOpt,\n\t\t\t\tExpression:           lhs.Expression,\n\t\t\t}\n\t\t\tdd.parent = lhs.directDeclarator\n\t\t}\n\tcase 193:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 4,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-5].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:             yyS[yypt-4].Token,\n\t\t\t\tTypeQualifierList: yyS[yypt-3].node.(*TypeQualifierList).reverse(),\n\t\t\t\tToken2:            yyS[yypt-2].Token,\n\t\t\t\tExpression:        yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Expression.eval(lx)\n\t\t\tvar dd *DirectDeclarator\n\t\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\t\tcase o == nil:\n\t\t\t\tdd = &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t\t}\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:              4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t\t\tDirectDeclarator:  dd,\n\t\t\t\tTypeQualifierList: lhs.TypeQualifierList,\n\t\t\t\tExpression:        lhs.Expression,\n\t\t\t}\n\t\t\tdd.parent = lhs.directDeclarator\n\t\t}\n\tcase 194:\n\t\t{\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 5,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-3].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tvar dd *DirectDeclarator\n\t\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\t\tcase o == nil:\n\t\t\t\tdd = &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t\t}\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase:             5, // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t\t\tDirectDeclarator: dd,\n\t\t\t}\n\t\t\tdd.parent = lhs.directDeclarator\n\t\t}\n\tcase 195:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.pushScope(ScopeParams)\n\t\t}\n\tcase 196:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase:                 6,\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tParameterTypeListOpt: yyS[yypt-1].node.(*ParameterTypeListOpt),\n\t\t\t\tToken2:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\t\tcase o != nil:\n\t\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\t\tCase: 6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t\t},\n\t\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\t\tCase: 7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t}\n\t\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t\t}\n\tcase 197:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.pushScope(ScopeParams)\n\t\t}\n\tcase 198:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectAbstractDeclarator{\n\t\t\t\tCase: 7,\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-4].node.(*DirectAbstractDeclarator),\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tParameterTypeListOpt: yyS[yypt-1].node.(*ParameterTypeListOpt),\n\t\t\t\tToken2:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\t\tcase o != nil:\n\t\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\t\tCase:              6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\t\tDirectDeclarator:  lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\t\tCase:             7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t\t}\n\t\t\t}\n\t\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t\t}\n\tcase 199:\n\t\t{\n\t\t\tyyVAL.node = (*DirectAbstractDeclaratorOpt)(nil)\n\t\t}\n\tcase 200:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclaratorOpt{\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-0].node.(*DirectAbstractDeclarator),\n\t\t\t}\n\t\t}\n\tcase 201:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Initializer{\n\t\t\t\tExpression: yyS[yypt-0].node.(*Expression),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Expression.eval(lx)\n\t\t}\n\tcase 202:\n\t\t{\n\t\t\tyyVAL.node = &Initializer{\n\t\t\t\tCase:            1,\n\t\t\t\tToken:           yyS[yypt-3].Token,\n\t\t\t\tInitializerList: yyS[yypt-2].node.(*InitializerList).reverse(),\n\t\t\t\tCommaOpt:        yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken2:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 203:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Initializer{\n\t\t\t\tCase:        2,\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tToken2:      yyS[yypt-1].Token,\n\t\t\t\tInitializer: yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableLegacyDesignators {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"legacy designators not enabled\")\n\t\t\t}\n\t\t}\n\tcase 204:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tDesignationOpt: yyS[yypt-1].node.(*DesignationOpt),\n\t\t\t\tInitializer:    yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 205:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tCase:            1,\n\t\t\t\tInitializerList: yyS[yypt-3].node.(*InitializerList),\n\t\t\t\tToken:           yyS[yypt-2].Token,\n\t\t\t\tDesignationOpt:  yyS[yypt-1].node.(*DesignationOpt),\n\t\t\t\tInitializer:     yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 206:\n\t\t{\n\t\t\tyyVAL.node = (*InitializerList)(nil)\n\t\t}\n\tcase 207:\n\t\t{\n\t\t\tyyVAL.node = &Designation{\n\t\t\t\tDesignatorList: yyS[yypt-1].node.(*DesignatorList).reverse(),\n\t\t\t\tToken:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 208:\n\t\t{\n\t\t\tyyVAL.node = (*DesignationOpt)(nil)\n\t\t}\n\tcase 209:\n\t\t{\n\t\t\tyyVAL.node = &DesignationOpt{\n\t\t\t\tDesignation: yyS[yypt-0].node.(*Designation),\n\t\t\t}\n\t\t}\n\tcase 210:\n\t\t{\n\t\t\tyyVAL.node = &DesignatorList{\n\t\t\t\tDesignator: yyS[yypt-0].node.(*Designator),\n\t\t\t}\n\t\t}\n\tcase 211:\n\t\t{\n\t\t\tyyVAL.node = &DesignatorList{\n\t\t\t\tCase:           1,\n\t\t\t\tDesignatorList: yyS[yypt-1].node.(*DesignatorList),\n\t\t\t\tDesignator:     yyS[yypt-0].node.(*Designator),\n\t\t\t}\n\t\t}\n\tcase 212:\n\t\t{\n\t\t\tyyVAL.node = &Designator{\n\t\t\t\tToken:              yyS[yypt-2].Token,\n\t\t\t\tConstantExpression: yyS[yypt-1].node.(*ConstantExpression),\n\t\t\t\tToken2:             yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 213:\n\t\t{\n\t\t\tyyVAL.node = &Designator{\n\t\t\t\tCase:   1,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 214:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tLabeledStatement: yyS[yypt-0].node.(*LabeledStatement),\n\t\t\t}\n\t\t}\n\tcase 215:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:              1,\n\t\t\t\tCompoundStatement: yyS[yypt-0].node.(*CompoundStatement),\n\t\t\t}\n\t\t}\n\tcase 216:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:                2,\n\t\t\t\tExpressionStatement: yyS[yypt-0].node.(*ExpressionStatement),\n\t\t\t}\n\t\t}\n\tcase 217:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:               3,\n\t\t\t\tSelectionStatement: yyS[yypt-0].node.(*SelectionStatement),\n\t\t\t}\n\t\t}\n\tcase 218:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:               4,\n\t\t\t\tIterationStatement: yyS[yypt-0].node.(*IterationStatement),\n\t\t\t}\n\t\t}\n\tcase 219:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:          5,\n\t\t\t\tJumpStatement: yyS[yypt-0].node.(*JumpStatement),\n\t\t\t}\n\t\t}\n\tcase 220:\n\t\t{\n\t\t\tyyVAL.node = &Statement{\n\t\t\t\tCase:               6,\n\t\t\t\tAssemblerStatement: yyS[yypt-0].node.(*AssemblerStatement),\n\t\t\t}\n\t\t}\n\tcase 221:\n\t\t{\n\t\t\tyyVAL.node = &LabeledStatement{\n\t\t\t\tToken:     yyS[yypt-2].Token,\n\t\t\t\tToken2:    yyS[yypt-1].Token,\n\t\t\t\tStatement: yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 222:\n\t\t{\n\t\t\tyyVAL.node = &LabeledStatement{\n\t\t\t\tCase:               1,\n\t\t\t\tToken:              yyS[yypt-3].Token,\n\t\t\t\tConstantExpression: yyS[yypt-2].node.(*ConstantExpression),\n\t\t\t\tToken2:             yyS[yypt-1].Token,\n\t\t\t\tStatement:          yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 223:\n\t\t{\n\t\t\tyyVAL.node = &LabeledStatement{\n\t\t\t\tCase:      2,\n\t\t\t\tToken:     yyS[yypt-2].Token,\n\t\t\t\tToken2:    yyS[yypt-1].Token,\n\t\t\t\tStatement: yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 224:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tm := lx.scope.mergeScope\n\t\t\tlx.pushScope(ScopeBlock)\n\t\t\tif m != nil {\n\t\t\t\tlx.scope.merge(m)\n\t\t\t}\n\t\t\tlx.scope.mergeScope = nil\n\t\t}\n\tcase 225:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &CompoundStatement{\n\t\t\t\tToken:            yyS[yypt-3].Token,\n\t\t\t\tBlockItemListOpt: yyS[yypt-1].node.(*BlockItemListOpt),\n\t\t\t\tToken2:           yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t\tlx.popScope(lhs.Token2)\n\t\t}\n\tcase 226:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemList{\n\t\t\t\tBlockItem: yyS[yypt-0].node.(*BlockItem),\n\t\t\t}\n\t\t}\n\tcase 227:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemList{\n\t\t\t\tCase:          1,\n\t\t\t\tBlockItemList: yyS[yypt-1].node.(*BlockItemList),\n\t\t\t\tBlockItem:     yyS[yypt-0].node.(*BlockItem),\n\t\t\t}\n\t\t}\n\tcase 228:\n\t\t{\n\t\t\tyyVAL.node = (*BlockItemListOpt)(nil)\n\t\t}\n\tcase 229:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemListOpt{\n\t\t\t\tBlockItemList: yyS[yypt-0].node.(*BlockItemList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 230:\n\t\t{\n\t\t\tyyVAL.node = &BlockItem{\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 231:\n\t\t{\n\t\t\tyyVAL.node = &BlockItem{\n\t\t\t\tCase:      1,\n\t\t\t\tStatement: yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 232:\n\t\t{\n\t\t\tyyVAL.node = &ExpressionStatement{\n\t\t\t\tExpressionListOpt: yyS[yypt-1].node.(*ExpressionListOpt),\n\t\t\t\tToken:             yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 233:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &SelectionStatement{\n\t\t\t\tToken:          yyS[yypt-4].Token,\n\t\t\t\tToken2:         yyS[yypt-3].Token,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList).reverse(),\n\t\t\t\tToken3:         yyS[yypt-1].Token,\n\t\t\t\tStatement:      yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 234:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &SelectionStatement{\n\t\t\t\tCase:           1,\n\t\t\t\tToken:          yyS[yypt-6].Token,\n\t\t\t\tToken2:         yyS[yypt-5].Token,\n\t\t\t\tExpressionList: yyS[yypt-4].node.(*ExpressionList).reverse(),\n\t\t\t\tToken3:         yyS[yypt-3].Token,\n\t\t\t\tStatement:      yyS[yypt-2].node.(*Statement),\n\t\t\t\tToken4:         yyS[yypt-1].Token,\n\t\t\t\tStatement2:     yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 235:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &SelectionStatement{\n\t\t\t\tCase:           2,\n\t\t\t\tToken:          yyS[yypt-4].Token,\n\t\t\t\tToken2:         yyS[yypt-3].Token,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList).reverse(),\n\t\t\t\tToken3:         yyS[yypt-1].Token,\n\t\t\t\tStatement:      yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 236:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &IterationStatement{\n\t\t\t\tToken:          yyS[yypt-4].Token,\n\t\t\t\tToken2:         yyS[yypt-3].Token,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList).reverse(),\n\t\t\t\tToken3:         yyS[yypt-1].Token,\n\t\t\t\tStatement:      yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 237:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &IterationStatement{\n\t\t\t\tCase:           1,\n\t\t\t\tToken:          yyS[yypt-6].Token,\n\t\t\t\tStatement:      yyS[yypt-5].node.(*Statement),\n\t\t\t\tToken2:         yyS[yypt-4].Token,\n\t\t\t\tToken3:         yyS[yypt-3].Token,\n\t\t\t\tExpressionList: yyS[yypt-2].node.(*ExpressionList).reverse(),\n\t\t\t\tToken4:         yyS[yypt-1].Token,\n\t\t\t\tToken5:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.ExpressionList.eval(lx)\n\t\t}\n\tcase 238:\n\t\t{\n\t\t\tyyVAL.node = &IterationStatement{\n\t\t\t\tCase:               2,\n\t\t\t\tToken:              yyS[yypt-8].Token,\n\t\t\t\tToken2:             yyS[yypt-7].Token,\n\t\t\t\tExpressionListOpt:  yyS[yypt-6].node.(*ExpressionListOpt),\n\t\t\t\tToken3:             yyS[yypt-5].Token,\n\t\t\t\tExpressionListOpt2: yyS[yypt-4].node.(*ExpressionListOpt),\n\t\t\t\tToken4:             yyS[yypt-3].Token,\n\t\t\t\tExpressionListOpt3: yyS[yypt-2].node.(*ExpressionListOpt),\n\t\t\t\tToken5:             yyS[yypt-1].Token,\n\t\t\t\tStatement:          yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 239:\n\t\t{\n\t\t\tyyVAL.node = &IterationStatement{\n\t\t\t\tCase:               3,\n\t\t\t\tToken:              yyS[yypt-7].Token,\n\t\t\t\tToken2:             yyS[yypt-6].Token,\n\t\t\t\tDeclaration:        yyS[yypt-5].node.(*Declaration),\n\t\t\t\tExpressionListOpt:  yyS[yypt-4].node.(*ExpressionListOpt),\n\t\t\t\tToken3:             yyS[yypt-3].Token,\n\t\t\t\tExpressionListOpt2: yyS[yypt-2].node.(*ExpressionListOpt),\n\t\t\t\tToken4:             yyS[yypt-1].Token,\n\t\t\t\tStatement:          yyS[yypt-0].node.(*Statement),\n\t\t\t}\n\t\t}\n\tcase 240:\n\t\t{\n\t\t\tyyVAL.node = &JumpStatement{\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 241:\n\t\t{\n\t\t\tyyVAL.node = &JumpStatement{\n\t\t\t\tCase:   1,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 242:\n\t\t{\n\t\t\tyyVAL.node = &JumpStatement{\n\t\t\t\tCase:   2,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 243:\n\t\t{\n\t\t\tyyVAL.node = &JumpStatement{\n\t\t\t\tCase:              3,\n\t\t\t\tToken:             yyS[yypt-2].Token,\n\t\t\t\tExpressionListOpt: yyS[yypt-1].node.(*ExpressionListOpt),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 244:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &JumpStatement{\n\t\t\t\tCase:       4,\n\t\t\t\tToken:      yyS[yypt-2].Token,\n\t\t\t\tExpression: yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken2:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\t_, t := lhs.Expression.eval(lx)\n\t\t\tif t == nil {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfor t != nil && t.Kind() == Ptr {\n\t\t\t\tt = t.Element()\n\t\t\t}\n\n\t\t\tif t == nil || t.Kind() != Void {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"invalid computed goto argument type, have '%s'\", t)\n\t\t\t}\n\n\t\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t\t}\n\t\t}\n\tcase 245:\n\t\t{\n\t\t\tyyVAL.node = &TranslationUnit{\n\t\t\t\tExternalDeclaration: yyS[yypt-0].node.(*ExternalDeclaration),\n\t\t\t}\n\t\t}\n\tcase 246:\n\t\t{\n\t\t\tyyVAL.node = &TranslationUnit{\n\t\t\t\tCase:                1,\n\t\t\t\tTranslationUnit:     yyS[yypt-1].node.(*TranslationUnit),\n\t\t\t\tExternalDeclaration: yyS[yypt-0].node.(*ExternalDeclaration),\n\t\t\t}\n\t\t}\n\tcase 247:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclaration{\n\t\t\t\tFunctionDefinition: yyS[yypt-0].node.(*FunctionDefinition),\n\t\t\t}\n\t\t}\n\tcase 248:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclaration{\n\t\t\t\tCase:        1,\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 249:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclaration{\n\t\t\t\tCase: 2,\n\t\t\t\tBasicAssemblerStatement: yyS[yypt-1].node.(*BasicAssemblerStatement),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 250:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ExternalDeclaration{\n\t\t\t\tCase:  3,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableEmptyDeclarations {\n\t\t\t\tlx.report.Err(lhs.Pos(), \"C++11 empty declarations are illegal in C99.\")\n\t\t\t}\n\t\t}\n\tcase 251:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif ds := yyS[yypt-2].node.(*DeclarationSpecifiers); ds.typeSpecifier == 0 {\n\t\t\t\tds.typeSpecifier = tsEncode(tsInt)\n\t\t\t\tyyS[yypt-1].node.(*Declarator).Type = lx.model.IntType\n\t\t\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\t\t\tlx.report.Err(yyS[yypt-1].node.Pos(), \"missing function return type\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar fd *FunctionDefinition\n\t\t\tfd.post(lx, yyS[yypt-1].node.(*Declarator), yyS[yypt-0].node.(*DeclarationListOpt))\n\t\t}\n\tcase 252:\n\t\t{\n\t\t\tyyVAL.node = &FunctionDefinition{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-4].node.(*DeclarationSpecifiers),\n\t\t\t\tDeclarator:            yyS[yypt-3].node.(*Declarator),\n\t\t\t\tDeclarationListOpt:    yyS[yypt-2].node.(*DeclarationListOpt),\n\t\t\t\tFunctionBody:          yyS[yypt-0].node.(*FunctionBody),\n\t\t\t}\n\t\t}\n\tcase 253:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.scope.specifier = &DeclarationSpecifiers{typeSpecifier: tsEncode(tsInt)}\n\t\t}\n\tcase 254:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\t\tlx.report.Err(yyS[yypt-1].node.Pos(), \"missing function return type\")\n\t\t\t}\n\t\t\tvar fd *FunctionDefinition\n\t\t\tfd.post(lx, yyS[yypt-1].node.(*Declarator), yyS[yypt-0].node.(*DeclarationListOpt))\n\t\t}\n\tcase 255:\n\t\t{\n\t\t\tyyVAL.node = &FunctionDefinition{\n\t\t\t\tCase:               1,\n\t\t\t\tDeclarator:         yyS[yypt-3].node.(*Declarator),\n\t\t\t\tDeclarationListOpt: yyS[yypt-2].node.(*DeclarationListOpt),\n\t\t\t\tFunctionBody:       yyS[yypt-0].node.(*FunctionBody),\n\t\t\t}\n\t\t}\n\tcase 256:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\t// Handle __func__, [0], 6.4.2.2.\n\t\t\tid, _ := lx.fnDeclarator.Identifier()\n\t\t\tlx.injectFunc = []xc.Token{\n\t\t\t\t{lex.Char{Rune: STATIC}, idStatic},\n\t\t\t\t{lex.Char{Rune: CONST}, idConst},\n\t\t\t\t{lex.Char{Rune: CHAR}, idChar},\n\t\t\t\t{lex.Char{Rune: IDENTIFIER}, idMagicFunc},\n\t\t\t\t{lex.Char{Rune: '['}, 0},\n\t\t\t\t{lex.Char{Rune: ']'}, 0},\n\t\t\t\t{lex.Char{Rune: '='}, 0},\n\t\t\t\t{lex.Char{Rune: STRINGLITERAL}, xc.Dict.SID(fmt.Sprintf(\"%q\", xc.Dict.S(id)))},\n\t\t\t\t{lex.Char{Rune: ';'}, 0},\n\t\t\t}\n\t\t}\n\tcase 257:\n\t\t{\n\t\t\tlhs := &FunctionBody{\n\t\t\t\tCompoundStatement: yyS[yypt-0].node.(*CompoundStatement),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lhs.CompoundStatement.scope\n\t\t}\n\tcase 258:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tm := lx.scope.mergeScope\n\t\t\tlx.pushScope(ScopeBlock)\n\t\t\tif m != nil {\n\t\t\t\tlx.scope.merge(m)\n\t\t\t}\n\t\t\tlx.scope.mergeScope = nil\n\t\t}\n\tcase 259:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &FunctionBody{\n\t\t\t\tCase:               1,\n\t\t\t\tAssemblerStatement: yyS[yypt-1].node.(*AssemblerStatement),\n\t\t\t\tToken:              yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t\tlx.popScope(lx.tokPrev)\n\t\t}\n\tcase 260:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationList{\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 261:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationList{\n\t\t\t\tCase:            1,\n\t\t\t\tDeclarationList: yyS[yypt-1].node.(*DeclarationList),\n\t\t\t\tDeclaration:     yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 262:\n\t\t{\n\t\t\tyyVAL.node = (*DeclarationListOpt)(nil)\n\t\t}\n\tcase 263:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.pushScope(ScopeParams)\n\t\t}\n\tcase 264:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DeclarationListOpt{\n\t\t\t\tDeclarationList: yyS[yypt-0].node.(*DeclarationList).reverse(),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramsScope, _ = lx.popScopePos(lhs.Pos())\n\t\t}\n\tcase 265:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerInstructions{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 266:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerInstructions{\n\t\t\t\tCase: 1,\n\t\t\t\tAssemblerInstructions: yyS[yypt-1].node.(*AssemblerInstructions),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 267:\n\t\t{\n\t\t\tyyVAL.node = &BasicAssemblerStatement{\n\t\t\t\tToken:                 yyS[yypt-4].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-3].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-2].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-1].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 268:\n\t\t{\n\t\t\tyyVAL.node = (*VolatileOpt)(nil)\n\t\t}\n\tcase 269:\n\t\t{\n\t\t\tyyVAL.node = &VolatileOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 270:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerOperand{\n\t\t\t\tAssemblerSymbolicNameOpt: yyS[yypt-4].node.(*AssemblerSymbolicNameOpt),\n\t\t\t\tToken:      yyS[yypt-3].Token,\n\t\t\t\tToken2:     yyS[yypt-2].Token,\n\t\t\t\tExpression: yyS[yypt-1].node.(*Expression),\n\t\t\t\tToken3:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 271:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerOperands{\n\t\t\t\tAssemblerOperand: yyS[yypt-0].node.(*AssemblerOperand),\n\t\t\t}\n\t\t}\n\tcase 272:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerOperands{\n\t\t\t\tCase:              1,\n\t\t\t\tAssemblerOperands: yyS[yypt-2].node.(*AssemblerOperands),\n\t\t\t\tToken:             yyS[yypt-1].Token,\n\t\t\t\tAssemblerOperand:  yyS[yypt-0].node.(*AssemblerOperand),\n\t\t\t}\n\t\t}\n\tcase 273:\n\t\t{\n\t\t\tyyVAL.node = (*AssemblerSymbolicNameOpt)(nil)\n\t\t}\n\tcase 274:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerSymbolicNameOpt{\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 275:\n\t\t{\n\t\t\tyyVAL.node = &Clobbers{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 276:\n\t\t{\n\t\t\tyyVAL.node = &Clobbers{\n\t\t\t\tCase:     1,\n\t\t\t\tClobbers: yyS[yypt-2].node.(*Clobbers),\n\t\t\t\tToken:    yyS[yypt-1].Token,\n\t\t\t\tToken2:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 277:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tBasicAssemblerStatement: yyS[yypt-0].node.(*BasicAssemblerStatement),\n\t\t\t}\n\t\t}\n\tcase 278:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  1,\n\t\t\t\tToken:                 yyS[yypt-6].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-5].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-4].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-3].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-2].Token,\n\t\t\t\tAssemblerOperands:     yyS[yypt-1].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken4:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 279:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  2,\n\t\t\t\tToken:                 yyS[yypt-8].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-7].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-6].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-5].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-4].Token,\n\t\t\t\tAssemblerOperands:     yyS[yypt-3].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken4:                yyS[yypt-2].Token,\n\t\t\t\tAssemblerOperands2:    yyS[yypt-1].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken5:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 280:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  3,\n\t\t\t\tToken:                 yyS[yypt-10].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-9].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-8].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-7].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-6].Token,\n\t\t\t\tAssemblerOperands:     yyS[yypt-5].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken4:                yyS[yypt-4].Token,\n\t\t\t\tAssemblerOperands2:    yyS[yypt-3].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken5:                yyS[yypt-2].Token,\n\t\t\t\tClobbers:              yyS[yypt-1].node.(*Clobbers).reverse(),\n\t\t\t\tToken6:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 281:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  4,\n\t\t\t\tToken:                 yyS[yypt-12].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-11].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-10].Token,\n\t\t\t\tToken3:                yyS[yypt-9].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-8].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken4:                yyS[yypt-7].Token,\n\t\t\t\tToken5:                yyS[yypt-6].Token,\n\t\t\t\tAssemblerOperands:     yyS[yypt-5].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken6:                yyS[yypt-4].Token,\n\t\t\t\tClobbers:              yyS[yypt-3].node.(*Clobbers).reverse(),\n\t\t\t\tToken7:                yyS[yypt-2].Token,\n\t\t\t\tIdentifierList:        yyS[yypt-1].node.(*IdentifierList).reverse(),\n\t\t\t\tToken8:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 282:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  5,\n\t\t\t\tToken:                 yyS[yypt-5].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-4].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-3].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-2].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-1].Token,\n\t\t\t\tToken4:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 283:\n\t\t{\n\t\t\tyyVAL.node = &AssemblerStatement{\n\t\t\t\tCase:                  6,\n\t\t\t\tToken:                 yyS[yypt-7].Token,\n\t\t\t\tVolatileOpt:           yyS[yypt-6].node.(*VolatileOpt),\n\t\t\t\tToken2:                yyS[yypt-5].Token,\n\t\t\t\tAssemblerInstructions: yyS[yypt-4].node.(*AssemblerInstructions).reverse(),\n\t\t\t\tToken3:                yyS[yypt-3].Token,\n\t\t\t\tToken4:                yyS[yypt-2].Token,\n\t\t\t\tAssemblerOperands:     yyS[yypt-1].node.(*AssemblerOperands).reverse(),\n\t\t\t\tToken5:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 284:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StaticAssertDeclaration{\n\t\t\t\tToken:              yyS[yypt-6].Token,\n\t\t\t\tToken2:             yyS[yypt-5].Token,\n\t\t\t\tConstantExpression: yyS[yypt-4].node.(*ConstantExpression),\n\t\t\t\tToken3:             yyS[yypt-3].Token,\n\t\t\t\tToken4:             yyS[yypt-2].Token,\n\t\t\t\tToken5:             yyS[yypt-1].Token,\n\t\t\t\tToken6:             yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tce := lhs.ConstantExpression\n\t\t\tif ce.Type == nil || ce.Type.Kind() == Undefined || ce.Value == nil || !IsIntType(ce.Type) {\n\t\t\t\tlx.report.Err(ce.Pos(), \"invalid static assert expression (have '%v')\", ce.Type)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif !isNonZero(ce.Value) {\n\t\t\t\tlx.report.ErrTok(lhs.Token, \"%s\", lhs.Token4.S())\n\t\t\t}\n\t\t}\n\tcase 285:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &PreprocessingFile{\n\t\t\t\tGroupList: yyS[yypt-0].node.(*GroupList).reverse(),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.path = lx.file.Name()\n\t\t}\n\tcase 286:\n\t\t{\n\t\t\tyyVAL.node = &GroupList{\n\t\t\t\tGroupPart: yyS[yypt-0].groupPart,\n\t\t\t}\n\t\t}\n\tcase 287:\n\t\t{\n\t\t\tyyVAL.node = &GroupList{\n\t\t\t\tCase:      1,\n\t\t\t\tGroupList: yyS[yypt-1].node.(*GroupList),\n\t\t\t\tGroupPart: yyS[yypt-0].groupPart,\n\t\t\t}\n\t\t}\n\tcase 288:\n\t\t{\n\t\t\tyyVAL.node = (*GroupListOpt)(nil)\n\t\t}\n\tcase 289:\n\t\t{\n\t\t\tyyVAL.node = &GroupListOpt{\n\t\t\t\tGroupList: yyS[yypt-0].node.(*GroupList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 290:\n\t\t{\n\t\t\tyyVAL.groupPart = yyS[yypt-0].node.(Node)\n\t\t}\n\tcase 291:\n\t\t{\n\t\t\tyyVAL.groupPart = yyS[yypt-0].node.(Node)\n\t\t}\n\tcase 292:\n\t\t{\n\t\t\tyyVAL.groupPart = yyS[yypt-2].Token\n\t\t}\n\tcase 293:\n\t\t{\n\t\t\tyyVAL.groupPart = yyS[yypt-0].toks\n\t\t}\n\tcase 294:\n\t\t{\n\t\t\tyyVAL.node = &IfSection{\n\t\t\t\tIfGroup:          yyS[yypt-3].node.(*IfGroup),\n\t\t\t\tElifGroupListOpt: yyS[yypt-2].node.(*ElifGroupListOpt),\n\t\t\t\tElseGroupOpt:     yyS[yypt-1].node.(*ElseGroupOpt),\n\t\t\t\tEndifLine:        yyS[yypt-0].node.(*EndifLine),\n\t\t\t}\n\t\t}\n\tcase 295:\n\t\t{\n\t\t\tyyVAL.node = &IfGroup{\n\t\t\t\tToken:        yyS[yypt-3].Token,\n\t\t\t\tPPTokenList:  yyS[yypt-2].toks,\n\t\t\t\tToken2:       yyS[yypt-1].Token,\n\t\t\t\tGroupListOpt: yyS[yypt-0].node.(*GroupListOpt),\n\t\t\t}\n\t\t}\n\tcase 296:\n\t\t{\n\t\t\tyyVAL.node = &IfGroup{\n\t\t\t\tCase:         1,\n\t\t\t\tToken:        yyS[yypt-3].Token,\n\t\t\t\tToken2:       yyS[yypt-2].Token,\n\t\t\t\tToken3:       yyS[yypt-1].Token,\n\t\t\t\tGroupListOpt: yyS[yypt-0].node.(*GroupListOpt),\n\t\t\t}\n\t\t}\n\tcase 297:\n\t\t{\n\t\t\tyyVAL.node = &IfGroup{\n\t\t\t\tCase:         2,\n\t\t\t\tToken:        yyS[yypt-3].Token,\n\t\t\t\tToken2:       yyS[yypt-2].Token,\n\t\t\t\tToken3:       yyS[yypt-1].Token,\n\t\t\t\tGroupListOpt: yyS[yypt-0].node.(*GroupListOpt),\n\t\t\t}\n\t\t}\n\tcase 298:\n\t\t{\n\t\t\tyyVAL.node = &ElifGroupList{\n\t\t\t\tElifGroup: yyS[yypt-0].node.(*ElifGroup),\n\t\t\t}\n\t\t}\n\tcase 299:\n\t\t{\n\t\t\tyyVAL.node = &ElifGroupList{\n\t\t\t\tCase:          1,\n\t\t\t\tElifGroupList: yyS[yypt-1].node.(*ElifGroupList),\n\t\t\t\tElifGroup:     yyS[yypt-0].node.(*ElifGroup),\n\t\t\t}\n\t\t}\n\tcase 300:\n\t\t{\n\t\t\tyyVAL.node = (*ElifGroupListOpt)(nil)\n\t\t}\n\tcase 301:\n\t\t{\n\t\t\tyyVAL.node = &ElifGroupListOpt{\n\t\t\t\tElifGroupList: yyS[yypt-0].node.(*ElifGroupList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 302:\n\t\t{\n\t\t\tyyVAL.node = &ElifGroup{\n\t\t\t\tToken:        yyS[yypt-3].Token,\n\t\t\t\tPPTokenList:  yyS[yypt-2].toks,\n\t\t\t\tToken2:       yyS[yypt-1].Token,\n\t\t\t\tGroupListOpt: yyS[yypt-0].node.(*GroupListOpt),\n\t\t\t}\n\t\t}\n\tcase 303:\n\t\t{\n\t\t\tyyVAL.node = &ElseGroup{\n\t\t\t\tToken:        yyS[yypt-2].Token,\n\t\t\t\tToken2:       yyS[yypt-1].Token,\n\t\t\t\tGroupListOpt: yyS[yypt-0].node.(*GroupListOpt),\n\t\t\t}\n\t\t}\n\tcase 304:\n\t\t{\n\t\t\tyyVAL.node = (*ElseGroupOpt)(nil)\n\t\t}\n\tcase 305:\n\t\t{\n\t\t\tyyVAL.node = &ElseGroupOpt{\n\t\t\t\tElseGroup: yyS[yypt-0].node.(*ElseGroup),\n\t\t\t}\n\t\t}\n\tcase 306:\n\t\t{\n\t\t\tyyVAL.node = &EndifLine{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 307:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tToken:           yyS[yypt-2].Token,\n\t\t\t\tToken2:          yyS[yypt-1].Token,\n\t\t\t\tReplacementList: yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 308:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:            1,\n\t\t\t\tToken:           yyS[yypt-4].Token,\n\t\t\t\tToken2:          yyS[yypt-3].Token,\n\t\t\t\tToken3:          yyS[yypt-2].Token,\n\t\t\t\tToken4:          yyS[yypt-1].Token,\n\t\t\t\tReplacementList: yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 309:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:            2,\n\t\t\t\tToken:           yyS[yypt-6].Token,\n\t\t\t\tToken2:          yyS[yypt-5].Token,\n\t\t\t\tIdentifierList:  yyS[yypt-4].node.(*IdentifierList).reverse(),\n\t\t\t\tToken3:          yyS[yypt-3].Token,\n\t\t\t\tToken4:          yyS[yypt-2].Token,\n\t\t\t\tToken5:          yyS[yypt-1].Token,\n\t\t\t\tReplacementList: yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 310:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:              3,\n\t\t\t\tToken:             yyS[yypt-4].Token,\n\t\t\t\tToken2:            yyS[yypt-3].Token,\n\t\t\t\tIdentifierListOpt: yyS[yypt-2].node.(*IdentifierListOpt),\n\t\t\t\tToken3:            yyS[yypt-1].Token,\n\t\t\t\tReplacementList:   yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 311:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:           4,\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tPPTokenListOpt: yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 312:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:  5,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 313:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:        6,\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tPPTokenList: yyS[yypt-1].toks,\n\t\t\t\tToken2:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 314:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:        7,\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tPPTokenList: yyS[yypt-1].toks,\n\t\t\t\tToken2:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 315:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:           8,\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tPPTokenListOpt: yyS[yypt-0].toks,\n\t\t\t}\n\t\t}\n\tcase 316:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:   9,\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 317:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ControlLine{\n\t\t\t\tCase:            10,\n\t\t\t\tToken:           yyS[yypt-5].Token,\n\t\t\t\tToken2:          yyS[yypt-4].Token,\n\t\t\t\tIdentifierList:  yyS[yypt-3].node.(*IdentifierList).reverse(),\n\t\t\t\tToken3:          yyS[yypt-2].Token,\n\t\t\t\tToken4:          yyS[yypt-1].Token,\n\t\t\t\tReplacementList: yyS[yypt-0].toks,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableDefineOmitCommaBeforeDDD {\n\t\t\t\tlx.report.ErrTok(lhs.Token4, \"missing comma before \\\"...\\\"\")\n\t\t\t}\n\t\t}\n\tcase 318:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ControlLine{\n\t\t\t\tCase:   11,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tif !lx.tweaks.enableEmptyDefine {\n\t\t\t\tlx.report.ErrTok(lhs.Token2, \"expected identifier\")\n\t\t\t}\n\t\t}\n\tcase 319:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &ControlLine{\n\t\t\t\tCase:        12,\n\t\t\t\tToken:       yyS[yypt-3].Token,\n\t\t\t\tToken2:      yyS[yypt-2].Token,\n\t\t\t\tPPTokenList: yyS[yypt-1].toks,\n\t\t\t\tToken3:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\ttoks := decodeTokens(lhs.PPTokenList, nil, false)\n\t\t\tif len(toks) == 0 {\n\t\t\t\tlhs.Case = 9 // PPUNDEF IDENTIFIER '\\n'\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlx.report.ErrTok(toks[0], \"extra tokens after #undef argument\")\n\t\t}\n\tcase 320:\n\t\t{\n\t\t\tyyVAL.node = &ControlLine{\n\t\t\t\tCase:        13,\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tPPTokenList: yyS[yypt-1].toks,\n\t\t\t\tToken2:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 323:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.toks = PPTokenList(dict.ID(lx.encBuf))\n\t\t\tlx.encBuf = lx.encBuf[:0]\n\t\t\tlx.encPos = 0\n\t\t}\n\tcase 324:\n\t\t{\n\t\t\tyyVAL.toks = 0\n\t\t}\n\n\t}\n\n\tif yyEx != nil && yyEx.Reduced(r, exState, &yyVAL) {\n\t\treturn -1\n\t}\n\tgoto yystack /* stack new state and value */\n}\n"
  },
  {
    "path": "parser.y",
    "content": "// Code generated by yy. DO NOT EDIT.\n\n%{\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.10. Substantial portions of expression AST size\n// optimizations are from [2], license of which follows.\n\n// ----------------------------------------------------------------------------\n\n// Copyright 2013 The Go Authors.  All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// This grammar is derived from the C grammar in the 'ansitize'\n// program, which carried this notice:\n// \n// Copyright (c) 2006 Russ Cox, \n// \tMassachusetts Institute of Technology\n// \n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall\n// be included in all copies or substantial portions of the\n// Software.\n// \n// The software is provided \"as is\", without warranty of any\n// kind, express or implied, including but not limited to the\n// warranties of merchantability, fitness for a particular\n// purpose and noninfringement.  In no event shall the authors\n// or copyright holders be liable for any claim, damages or\n// other liability, whether in an action of contract, tort or\n// otherwise, arising from, out of or in connection with the\n// software or the use or other dealings in the software.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cznic/xc\"\n\t\"github.com/cznic/golex/lex\"\n)\n%}\n\n%union {\n\tToken     xc.Token\n\tgroupPart Node\n\tnode      Node\n\ttoks      PPTokenList\n}\n\n%token\t<Token>\n\t'!'\n\t'%'\n\t'&'\n\t'('\n\t')'\n\t'*'\n\t'+'\n\t','\n\t'-'\n\t'.'\n\t'/'\n\t':'\n\t';'\n\t'<'\n\t'='\n\t'>'\n\t'?'\n\t'['\n\t'\\n'\n\t']'\n\t'^'\n\t'{'\n\t'|'\n\t'}'\n\t'~'\n\tADDASSIGN                    \"+=\"\n\tALIGNOF                      \"_Alignof\"\n\tANDAND                       \"&&\"\n\tANDASSIGN                    \"&=\"\n\tARROW                        \"->\"\n\tASM                          \"asm\"\n\tAUTO                         \"auto\"\n\tBOOL                         \"_Bool\"\n\tBREAK                        \"break\"\n\tCASE                         \"case\"\n\tCAST\n\tCHAR                         \"char\"\n\tCHARCONST                    \"character constant\"\n\tCOMPLEX                      \"_Complex\"\n\tCONST                        \"const\"\n\tCONSTANT_EXPRESSION 1048577  \"constant expression prefix\"\n\tCONTINUE                     \"continue\"\n\tDDD                          \"...\"\n\tDEC                          \"--\"\n\tDEFAULT                      \"default\"\n\tDIVASSIGN                    \"/=\"\n\tDO                           \"do\"\n\tDOUBLE                       \"double\"\n\tELSE                         \"else\"\n\tENUM                         \"enum\"\n\tEQ                           \"==\"\n\tEXTERN                       \"extern\"\n\tFLOAT                        \"float\"\n\tFLOATCONST                   \"floating-point constant\"\n\tFOR                          \"for\"\n\tGEQ                          \">=\"\n\tGOTO                         \"goto\"\n\tIDENTIFIER                   \"identifier\"\n\tIDENTIFIER_LPAREN            \"identifier immediatelly followed by '('\"\n\tIDENTIFIER_NONREPL           \"non replaceable identifier\"\n\tIF                           \"if\"\n\tINC                          \"++\"\n\tINLINE                       \"inline\"\n\tINT                          \"int\"\n\tINTCONST                     \"integer constant\"\n\tLEQ                          \"<=\"\n\tLONG                         \"long\"\n\tLONGCHARCONST                \"long character constant\"\n\tLONGSTRINGLITERAL            \"long string constant\"\n\tLSH                          \"<<\"\n\tLSHASSIGN                    \"<<=\"\n\tMODASSIGN                    \"%=\"\n\tMULASSIGN                    \"*=\"\n\tNEQ                          \"!=\"\n\tNOELSE\n\tNORETURN                     \"_Noreturn\"\n\tNOSEMI\n\tORASSIGN                     \"|=\"\n\tOROR                         \"||\"\n\tPPDEFINE                     \"#define\"\n\tPPELIF                       \"#elif\"\n\tPPELSE                       \"#else\"\n\tPPENDIF                      \"#endif\"\n\tPPERROR                      \"#error\"\n\tPPHASH_NL                    \"#\"\n\tPPHEADER_NAME                \"header name\"\n\tPPIF                         \"#if\"\n\tPPIFDEF                      \"#ifdef\"\n\tPPIFNDEF                     \"#ifndef\"\n\tPPINCLUDE                    \"#include\"\n\tPPINCLUDE_NEXT               \"#include_next\"\n\tPPLINE                       \"#line\"\n\tPPNONDIRECTIVE               \"#foo\"\n\tPPNUMBER                     \"preprocessing number\"\n\tPPOTHER                      \"ppother\"\n\tPPPASTE                      \"##\"\n\tPPPRAGMA                     \"#pragma\"\n\tPPUNDEF                      \"#undef\"\n\tPREPROCESSING_FILE 1048576   \"preprocessing file prefix\"\n\tREGISTER                     \"register\"\n\tRESTRICT                     \"restrict\"\n\tRETURN                       \"return\"\n\tRSH                          \">>\"\n\tRSHASSIGN                    \">>=\"\n\tSHORT                        \"short\"\n\tSIGNED                       \"signed\"\n\tSIZEOF                       \"sizeof\"\n\tSTATIC                       \"static\"\n\tSTATIC_ASSERT                \"_Static_assert\"\n\tSTRINGLITERAL                \"string literal\"\n\tSTRUCT                       \"struct\"\n\tSUBASSIGN                    \"-=\"\n\tSWITCH                       \"switch\"\n\tTRANSLATION_UNIT 1048578     \"translation unit prefix\"\n\tTYPEDEF                      \"typedef\"\n\tTYPEDEFNAME                  \"typedefname\"\n\tTYPEOF                       \"typeof\"\n\tUNARY\n\tUNION                        \"union\"\n\tUNSIGNED                     \"unsigned\"\n\tVOID                         \"void\"\n\tVOLATILE                     \"volatile\"\n\tWHILE                        \"while\"\n\tXORASSIGN                    \"^=\"\n\n%type\t<groupPart>\n\tGroupPart                    \"group part\"\n\n%type\t<node>\n\tAbstractDeclarator           \"abstract declarator\"\n\tAbstractDeclaratorOpt        \"optional abstract declarator\"\n\tArgumentExpressionList       \"argument expression list\"\n\tArgumentExpressionListOpt    \"optional argument expression list\"\n\tAssemblerInstructions        \"assembler instructions\"\n\tAssemblerOperand             \"assembler operand\"\n\tAssemblerOperands            \"assembler operands\"\n\tAssemblerStatement           \"assembler statement\"\n\tAssemblerSymbolicNameOpt     \"optional assembler symbolic name\"\n\tBasicAssemblerStatement      \"basic assembler statement\"\n\tBlockItem                    \"block item\"\n\tBlockItemList                \"block item list\"\n\tBlockItemListOpt             \"optional block item list\"\n\tClobbers                     \"clobbers\"\n\tCommaOpt                     \"optional comma\"\n\tCompoundStatement            \"compound statement\"\n\tConstantExpression           \"constant expression\"\n\tControlLine                  \"control line\"\n\tDeclaration                  \"declaration\"\n\tDeclarationList              \"declaration list\"\n\tDeclarationListOpt           \"optional declaration list\"\n\tDeclarationSpecifiers        \"declaration specifiers\"\n\tDeclarationSpecifiersOpt     \"optional declaration specifiers\"\n\tDeclarator                   \"declarator\"\n\tDeclaratorOpt                \"optional declarator\"\n\tDesignation                  \"designation\"\n\tDesignationOpt               \"optional designation\"\n\tDesignator                   \"designator\"\n\tDesignatorList               \"designator list\"\n\tDirectAbstractDeclarator     \"direct abstract declarator\"\n\tDirectAbstractDeclaratorOpt  \"optional direct abstract declarator\"\n\tDirectDeclarator             \"direct declarator\"\n\tElifGroup                    \"elif group\"\n\tElifGroupList                \"elif group list\"\n\tElifGroupListOpt             \"optional elif group list\"\n\tElseGroup                    \"else group\"\n\tElseGroupOpt                 \"optional else group\"\n\tEndifLine                    \"endif line\"\n\tEnumSpecifier                \"enum specifier\"\n\tEnumerationConstant          \"enumearation constant\"\n\tEnumerator                   \"enumerator\"\n\tEnumeratorList               \"enumerator list\"\n\tExpression                   \"expression\"\n\tExpressionList               \"expression list\"\n\tExpressionListOpt            \"optional expression list\"\n\tExpressionOpt                \"optional expression\"\n\tExpressionStatement          \"expression statement\"\n\tExternalDeclaration          \"external declaration\"\n\tFunctionBody                 \"function body\"\n\tFunctionDefinition           \"function definition\"\n\tFunctionSpecifier            \"function specifier\"\n\tGroupList                    \"group list\"\n\tGroupListOpt                 \"optional group list\"\n\tIdentifierList               \"identifier list\"\n\tIdentifierListOpt            \"optional identifier list\"\n\tIdentifierOpt                \"optional identifier\"\n\tIfGroup                      \"if group\"\n\tIfSection                    \"if section\"\n\tInitDeclarator               \"init declarator\"\n\tInitDeclaratorList           \"init declarator list\"\n\tInitDeclaratorListOpt        \"optional init declarator list\"\n\tInitializer                  \"initializer\"\n\tInitializerList              \"initializer list\"\n\tIterationStatement           \"iteration statement\"\n\tJumpStatement                \"jump statement\"\n\tLabeledStatement             \"labeled statement\"\n\tPPTokens\n\tParameterDeclaration         \"parameter declaration\"\n\tParameterList                \"parameter list\"\n\tParameterTypeList            \"parameter type list\"\n\tParameterTypeListOpt         \"optional parameter type list\"\n\tPointer                      \"pointer\"\n\tPointerOpt                   \"optional pointer\"\n\tPreprocessingFile            \"preprocessing file\"\n\tSelectionStatement           \"selection statement\"\n\tSpecifierQualifierList       \"specifier qualifier list\"\n\tSpecifierQualifierListOpt    \"optional specifier qualifier list\"\n\tStart\n\tStatement                    \"statement\"\n\tStaticAssertDeclaration      \"static assert declaration\"\n\tStorageClassSpecifier        \"storage class specifier\"\n\tStructDeclaration            \"struct declaration\"\n\tStructDeclarationList        \"struct declaration list\"\n\tStructDeclarator             \"struct declarator\"\n\tStructDeclaratorList         \"struct declarator list\"\n\tStructOrUnion                \"struct-or-union\"\n\tStructOrUnionSpecifier       \"struct-or-union specifier\"\n\tTranslationUnit              \"translation unit\"\n\tTypeName                     \"type name\"\n\tTypeQualifier                \"type qualifier\"\n\tTypeQualifierList            \"type qualifier list\"\n\tTypeQualifierListOpt         \"optional type qualifier list\"\n\tTypeSpecifier                \"type specifier\"\n\tVolatileOpt                  \"optional volatile\"\n\n%type\t<toks>\n\tPPTokenList                  \"token list\"\n\tPPTokenListOpt               \"optional token list\"\n\tReplacementList              \"replacement list\"\n\tTextLine                     \"text line\"\n\n%precedence\tNOSEMI\n%precedence\t';'\n%precedence\tNOELSE\n%precedence\tELSE\n%right\t'=' ADDASSIGN ANDASSIGN DIVASSIGN LSHASSIGN MODASSIGN MULASSIGN ORASSIGN RSHASSIGN SUBASSIGN XORASSIGN\n%right\t':' '?'\n%left\tOROR\n%left\tANDAND\n%left\t'|'\n%left\t'^'\n%left\t'&'\n%left\tEQ NEQ\n%left\t'<' '>' GEQ LEQ\n%left\tLSH RSH\n%left\t'+' '-'\n%left\t'%' '*' '/'\n%precedence\tCAST\n%left\t'!' '~' SIZEOF UNARY\n%right\t'(' '.' '[' ARROW DEC INC\n\n%start Start\n\n%%\n\nStart:\n\tPREPROCESSING_FILE\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.preprocessingFile = nil\n\t}\n\tPreprocessingFile\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.preprocessingFile = $3.(*PreprocessingFile)\n\t}\n|\tCONSTANT_EXPRESSION\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.constantExpression = nil\n\t}\n\tConstantExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.constantExpression = $3.(*ConstantExpression)\n\t}\n|\tTRANSLATION_UNIT\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.translationUnit = nil\n\t}\n\tTranslationUnit\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tif lx.report.Errors(false) == nil && lx.scope.kind != ScopeFile {\n\t\t\tpanic(\"internal error\")\n\t\t}\n\n\t\tlx.translationUnit = $3.(*TranslationUnit).reverse()\n\t\tlx.translationUnit.Declarations = lx.scope\n\t}\n\nEnumerationConstant:\n\tIDENTIFIER\n\t{\n\t\t$$ = &EnumerationConstant{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nArgumentExpressionList:\n\tExpression\n\t{\n\t\t$$ = &ArgumentExpressionList{\n\t\t\tExpression:  $1.(*Expression),\n\t\t}\n\t}\n|\tArgumentExpressionList ',' Expression\n\t{\n\t\t$$ = &ArgumentExpressionList{\n\t\t\tCase:                    1,\n\t\t\tArgumentExpressionList:  $1.(*ArgumentExpressionList),\n\t\t\tToken:                   $2,\n\t\t\tExpression:              $3.(*Expression),\n\t\t}\n\t}\n\nArgumentExpressionListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ArgumentExpressionListOpt)(nil)\n\t\t}\n|\tArgumentExpressionList\n\t{\n\t\t$$ = &ArgumentExpressionListOpt{\n\t\t\tArgumentExpressionList:  $1.(*ArgumentExpressionList).reverse(),\n\t\t}\n\t}\n\nExpression:\n\tIDENTIFIER %prec NOSEMI\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Expression{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.scope = lx.scope\n\t}\n|\tCHARCONST\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tFLOATCONST\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   2,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tINTCONST\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   3,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tLONGCHARCONST\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   4,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tLONGSTRINGLITERAL\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   5,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tSTRINGLITERAL\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:   6,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\t'(' ExpressionList ')'\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:            7,\n\t\t\tToken:           $1,\n\t\t\tExpressionList:  $2.(*ExpressionList).reverse(),\n\t\t\tToken2:          $3,\n\t\t}\n\t}\n|\tExpression '[' ExpressionList ']'\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:            8,\n\t\t\tExpression:      $1.(*Expression),\n\t\t\tToken:           $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken2:          $4,\n\t\t}\n\t}\n|\tExpression '(' ArgumentExpressionListOpt ')'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Expression{\n\t\t\tCase:                       9,\n\t\t\tExpression:                 $1.(*Expression),\n\t\t\tToken:                      $2,\n\t\t\tArgumentExpressionListOpt:  $3.(*ArgumentExpressionListOpt),\n\t\t\tToken2:                     $4,\n\t\t}\n\t\t$$ = lhs\n\t\to := lhs.ArgumentExpressionListOpt\n\t\tif o == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif lhs.Expression.Case == 0 { // IDENTIFIER\n\t\t\tif lx.tweaks.enableBuiltinConstantP &&lhs.Expression.Token.Val == idBuiltinConstantP {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tb := lhs.Expression.scope.Lookup(NSIdentifiers, lhs.Expression.Token.Val)\n\t\t\tif b.Node == nil && lx.tweaks.enableImplicitFuncDef {\n\t\t\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\t\t\tl.Expression.eval(lx)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tlhs.Expression.eval(lx)\n\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\tl.Expression.eval(lx)\n\t\t}\n\t}\n|\tExpression '.' IDENTIFIER\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        10,\n\t\t\tExpression:  $1.(*Expression),\n\t\t\tToken:       $2,\n\t\t\tToken2:      $3,\n\t\t}\n\t}\n|\tExpression \"->\" IDENTIFIER\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        11,\n\t\t\tExpression:  $1.(*Expression),\n\t\t\tToken:       $2,\n\t\t\tToken2:      $3,\n\t\t}\n\t}\n|\tExpression \"++\"\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        12,\n\t\t\tExpression:  $1.(*Expression),\n\t\t\tToken:       $2,\n\t\t}\n\t}\n|\tExpression \"--\"\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        13,\n\t\t\tExpression:  $1.(*Expression),\n\t\t\tToken:       $2,\n\t\t}\n\t}\n|\t'(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:             14,\n\t\t\tToken:            $1,\n\t\t\tTypeName:         $2.(*TypeName),\n\t\t\tToken2:           $3,\n\t\t\tToken3:           $4,\n\t\t\tInitializerList:  $5.(*InitializerList).reverse(),\n\t\t\tCommaOpt:         $6.(*CommaOpt),\n\t\t\tToken4:           $7,\n\t\t}\n\t}\n|\t\"++\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        15,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t\"--\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        16,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'&' Expression %prec UNARY\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        17,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'*' Expression %prec UNARY\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        18,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'+' Expression %prec UNARY\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        19,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'-' Expression %prec UNARY\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        20,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'~' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        21,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t'!' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        22,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t\"sizeof\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        23,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t}\n|\t\"sizeof\" '(' TypeName ')' %prec SIZEOF\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:      24,\n\t\t\tToken:     $1,\n\t\t\tToken2:    $2,\n\t\t\tTypeName:  $3.(*TypeName),\n\t\t\tToken3:    $4,\n\t\t}\n\t}\n|\t'(' TypeName ')' Expression %prec CAST\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:        25,\n\t\t\tToken:       $1,\n\t\t\tTypeName:    $2.(*TypeName),\n\t\t\tToken2:      $3,\n\t\t\tExpression:  $4.(*Expression),\n\t\t}\n\t}\n|\tExpression '*' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         26,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '/' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         27,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '%' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         28,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '+' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         29,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '-' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         30,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"<<\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         31,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \">>\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         32,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '<' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         33,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '>' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         34,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"<=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         35,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \">=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         36,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"==\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         37,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"!=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         38,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '&' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         39,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '^' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         40,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '|' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         41,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"&&\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         42,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"||\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         43,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression '?' ExpressionList ':' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:            44,\n\t\t\tExpression:      $1.(*Expression),\n\t\t\tToken:           $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken2:          $4,\n\t\t\tExpression2:     $5.(*Expression),\n\t\t}\n\t}\n|\tExpression '=' Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         45,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"*=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         46,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"/=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         47,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"%=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         48,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"+=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         49,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"-=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         50,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"<<=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         51,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \">>=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         52,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"&=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         53,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"^=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         54,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\tExpression \"|=\" Expression\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:         55,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tExpression2:  $3.(*Expression),\n\t\t}\n\t}\n|\t\"_Alignof\" '(' TypeName ')'\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:      56,\n\t\t\tToken:     $1,\n\t\t\tToken2:    $2,\n\t\t\tTypeName:  $3.(*TypeName),\n\t\t\tToken3:    $4,\n\t\t}\n\t}\n|\t'(' CompoundStatement ')'\n\t{\n\t\t$$ = &Expression{\n\t\t\tCase:               57,\n\t\t\tToken:              $1,\n\t\t\tCompoundStatement:  $2.(*CompoundStatement),\n\t\t\tToken2:             $3,\n\t\t}\n\t}\n|\t\"&&\" IDENTIFIER\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Expression{\n\t\t\tCase:    58,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t}\n\t}\n|\tExpression '?' ':' Expression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Expression{\n\t\t\tCase:         59,\n\t\t\tExpression:   $1.(*Expression),\n\t\t\tToken:        $2,\n\t\t\tToken2:       $3,\n\t\t\tExpression2:  $4.(*Expression),\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableOmitConditionalOperand {\n\t\t\tlx.report.Err(lhs.Pos(), \"omitting conditional operand not enabled\")\n\t\t}\n\t}\n\nExpressionOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ExpressionOpt)(nil)\n\t\t}\n|\tExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ExpressionOpt{\n\t\t\tExpression:  $1.(*Expression),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Expression.eval(lx)\n\t}\n\nExpressionList:\n\tExpression\n\t{\n\t\t$$ = &ExpressionList{\n\t\t\tExpression:  $1.(*Expression),\n\t\t}\n\t}\n|\tExpressionList ',' Expression\n\t{\n\t\t$$ = &ExpressionList{\n\t\t\tCase:            1,\n\t\t\tExpressionList:  $1.(*ExpressionList),\n\t\t\tToken:           $2,\n\t\t\tExpression:      $3.(*Expression),\n\t\t}\n\t}\n\nExpressionListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ExpressionListOpt)(nil)\n\t\t}\n|\tExpressionList\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ExpressionListOpt{\n\t\t\tExpressionList:  $1.(*ExpressionList).reverse(),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n\nConstantExpression:\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.constExprToks = []xc.Token{lx.last}\n\t}\n\tExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ConstantExpression{\n\t\t\tExpression:  $2.(*Expression),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Value, lhs.Type = lhs.Expression.eval(lx)\n\t\tif lhs.Value == nil {\n\t\t\tlx.report.Err(lhs.Pos(), \"not a constant expression\")\n\t\t}\n\t\tl := lx.constExprToks\n\t\tlhs.toks = l[:len(l)-1]\n\t\tlx.constExprToks = nil\n\t}\n\nDeclaration:\n\tDeclarationSpecifiers InitDeclaratorListOpt ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Declaration{\n\t\t\tDeclarationSpecifiers:  $1.(*DeclarationSpecifiers),\n\t\t\tInitDeclaratorListOpt:  $2.(*InitDeclaratorListOpt),\n\t\t\tToken:                  $3,\n\t\t}\n\t\t$$ = lhs\n\t\tts0 := lhs.DeclarationSpecifiers.typeSpecifiers()\n\t\tif ts0 == 0 && lx.tweaks.enableImplicitIntType {\n\t\t\tlhs.DeclarationSpecifiers.typeSpecifier = tsEncode(tsInt)\n\t\t}\n\t\tts := tsDecode(lhs.DeclarationSpecifiers.typeSpecifiers())\n\t\tok := false\n\t\tfor _, v := range ts {\n\t\t\tif v == tsStructSpecifier || v == tsUnionSpecifier {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\ts := lhs.DeclarationSpecifiers\n\t\t\td := &Declarator{specifier: s}\n\t\t\tdd := &DirectDeclarator{\n\t\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\tdeclarator: d,\n\t\t\t\tidScope: lx.scope,\n\t\t\t\tspecifier: s,\n\t\t\t}\n\t\t\td.DirectDeclarator = dd\n\t\t\td.setFull(lx)\n\t\t\tfor l := lhs.DeclarationSpecifiers; l != nil; {\n\t\t\t\tts := l.TypeSpecifier\n\t\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif o := l.DeclarationSpecifiersOpt; o != nil {\n\t\t\t\t\tl = o.DeclarationSpecifiers\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\to := lhs.InitDeclaratorListOpt\n\t\tif o != nil {\n\t\t\tbreak\n\t\t}\n\n\t\ts := lhs.DeclarationSpecifiers\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\t\tlhs.declarator = d\n\t}\n|\tStaticAssertDeclaration\n\t{\n\t\t$$ = &Declaration{\n\t\t\tCase:                     1,\n\t\t\tStaticAssertDeclaration:  $1.(*StaticAssertDeclaration),\n\t\t}\n\t}\n\nDeclarationSpecifiers:\n\tStorageClassSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DeclarationSpecifiers{\n\t\t\tStorageClassSpecifier:     $1.(*StorageClassSpecifier),\n\t\t\tDeclarationSpecifiersOpt:  $2.(*DeclarationSpecifiersOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.StorageClassSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.StorageClassSpecifier.Case != 0 /* \"typedef\" */ && lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t}\n\t}\n|\tTypeSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DeclarationSpecifiers{\n\t\t\tCase:                      1,\n\t\t\tTypeSpecifier:             $1.(*TypeSpecifier),\n\t\t\tDeclarationSpecifiersOpt:  $2.(*DeclarationSpecifiersOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = b.attr\n\t\ttsb := tsDecode(b.typeSpecifier)\n\t\tif len(tsb) == 1 && tsb[0] == tsTypedefName && lx.tweaks.allowCompatibleTypedefRedefinitions {\n\t\t\ttsb[0] = 0\n\t\t}\n\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsb...)...)\n\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\tts = tsEncode(tsInt)\n\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t}\n\t\tlhs.typeSpecifier = ts\n\t}\n|\tTypeQualifier DeclarationSpecifiersOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DeclarationSpecifiers{\n\t\t\tCase:                      2,\n\t\t\tTypeQualifier:             $1.(*TypeQualifier),\n\t\t\tDeclarationSpecifiersOpt:  $2.(*DeclarationSpecifiersOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeQualifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t}\n\t}\n|\tFunctionSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DeclarationSpecifiers{\n\t\t\tCase:                      3,\n\t\t\tFunctionSpecifier:         $1.(*FunctionSpecifier),\n\t\t\tDeclarationSpecifiersOpt:  $2.(*DeclarationSpecifiersOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.FunctionSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t}\n\t}\n\nDeclarationSpecifiersOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*DeclarationSpecifiersOpt)(nil)\n\t\t}\n|\tDeclarationSpecifiers\n\t{\n\t\tlhs := &DeclarationSpecifiersOpt{\n\t\t\tDeclarationSpecifiers:  $1.(*DeclarationSpecifiers),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = lhs.DeclarationSpecifiers.attr\n\t\tlhs.typeSpecifier = lhs.DeclarationSpecifiers.typeSpecifier\n\t}\n\nInitDeclaratorList:\n\tInitDeclarator\n\t{\n\t\t$$ = &InitDeclaratorList{\n\t\t\tInitDeclarator:  $1.(*InitDeclarator),\n\t\t}\n\t}\n|\tInitDeclaratorList ',' InitDeclarator\n\t{\n\t\t$$ = &InitDeclaratorList{\n\t\t\tCase:                1,\n\t\t\tInitDeclaratorList:  $1.(*InitDeclaratorList),\n\t\t\tToken:               $2,\n\t\t\tInitDeclarator:      $3.(*InitDeclarator),\n\t\t}\n\t}\n\nInitDeclaratorListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*InitDeclaratorListOpt)(nil)\n\t\t}\n|\tInitDeclaratorList\n\t{\n\t\t$$ = &InitDeclaratorListOpt{\n\t\t\tInitDeclaratorList:  $1.(*InitDeclaratorList).reverse(),\n\t\t}\n\t}\n\nInitDeclarator:\n\tDeclarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &InitDeclarator{\n\t\t\tDeclarator:  $1.(*Declarator),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Declarator.setFull(lx)\n\t}\n|\tDeclarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\td := $1.(*Declarator)\n\t\td.setFull(lx)\n\t}\n\t'=' Initializer\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &InitDeclarator{\n\t\t\tCase:         1,\n\t\t\tDeclarator:   $1.(*Declarator),\n\t\t\tToken:        $3,\n\t\t\tInitializer:  $4.(*Initializer),\n\t\t}\n\t\t$$ = lhs\n\t\td := lhs.Declarator\n\t\tlhs.Initializer.typeCheck(&d.Type, d.Type, lhs.Declarator.specifier.IsStatic(), lx)\n\t\tif d.Type.Specifier().IsExtern() {\n\t\t\tid, _ := d.Identifier()\n\t\t\tlx.report.Err(d.Pos(), \"'%s' initialized and declared 'extern'\", dict.S(id))\n\t\t}\n\t}\n\nStorageClassSpecifier:\n\t\"typedef\"\n\t{\n\t\tlhs := &StorageClassSpecifier{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saTypedef\n\t}\n|\t\"extern\"\n\t{\n\t\tlhs := &StorageClassSpecifier{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saExtern\n\t}\n|\t\"static\"\n\t{\n\t\tlhs := &StorageClassSpecifier{\n\t\t\tCase:   2,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saStatic\n\t}\n|\t\"auto\"\n\t{\n\t\tlhs := &StorageClassSpecifier{\n\t\t\tCase:   3,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saAuto\n\t}\n|\t\"register\"\n\t{\n\t\tlhs := &StorageClassSpecifier{\n\t\t\tCase:   4,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saRegister\n\t}\n\nTypeSpecifier:\n\t\"void\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsVoid)\n\t}\n|\t\"char\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsChar)\n\t}\n|\t\"short\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   2,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsShort)\n\t}\n|\t\"int\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   3,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsInt)\n\t}\n|\t\"long\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   4,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsLong)\n\t}\n|\t\"float\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   5,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsFloat)\n\t}\n|\t\"double\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   6,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsDouble)\n\t}\n|\t\"signed\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   7,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsSigned)\n\t}\n|\t\"unsigned\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   8,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsUnsigned)\n\t}\n|\t\"_Bool\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   9,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsBool)\n\t}\n|\t\"_Complex\"\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   10,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsComplex)\n\t}\n|\tStructOrUnionSpecifier\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:                    11,\n\t\t\tStructOrUnionSpecifier:  $1.(*StructOrUnionSpecifier),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(lhs.StructOrUnionSpecifier.typeSpecifiers())\n\t}\n|\tEnumSpecifier\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:           12,\n\t\t\tEnumSpecifier:  $1.(*EnumSpecifier),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsEnumSpecifier)\n\t}\n|\tTYPEDEFNAME\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:   13,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsTypedefName)\n\t\t_, lhs.scope = lx.scope.Lookup2(NSIdentifiers, lhs.Token.Val)\n\t}\n|\t\"typeof\" '(' Expression ')'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:        14,\n\t\t\tToken:       $1,\n\t\t\tToken2:      $2,\n\t\t\tExpression:  $3.(*Expression),\n\t\t\tToken3:      $4,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\t_, lhs.Type = lhs.Expression.eval(lx)\n\t}\n|\t\"typeof\" '(' TypeName ')'\n\t{\n\t\tlhs := &TypeSpecifier{\n\t\t\tCase:      15,\n\t\t\tToken:     $1,\n\t\t\tToken2:    $2,\n\t\t\tTypeName:  $3.(*TypeName),\n\t\t\tToken3:    $4,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\tlhs.Type = undefined\n\t\tif t := lhs.TypeName.Type; t != nil {\n\t\t\tlhs.Type = t\n\t\t}\n\t}\n\nStructOrUnionSpecifier:\n\tStructOrUnion IdentifierOpt '{'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t}\n\t\tlx.pushScope(ScopeMembers)\n\t\tlx.scope.isUnion = $1.(*StructOrUnion).Case == 1 // \"union\"\n\t\tlx.scope.prevStructDeclarator = nil\n\t}\n\tStructDeclarationList '}'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructOrUnionSpecifier{\n\t\t\tStructOrUnion:          $1.(*StructOrUnion),\n\t\t\tIdentifierOpt:          $2.(*IdentifierOpt),\n\t\t\tToken:                  $3,\n\t\t\tStructDeclarationList:  $5.(*StructDeclarationList).reverse(),\n\t\t\tToken2:                 $6,\n\t\t}\n\t\t$$ = lhs\n\t\tsc := lx.scope\n\t\tlhs.scope = sc\n\t\tif sc.bitOffset != 0 {\n\t\t\tfinishBitField(lhs, lx)\n\t\t}\n\n\t\ti := 0\n\t\tvar bt Type\n\t\tvar d *Declarator\n\t\tfor l := lhs.StructDeclarationList; l != nil; l = l.StructDeclarationList {\n\t\t\tfor l := l.StructDeclaration.StructDeclaratorList; l != nil; l = l.StructDeclaratorList {\n\t\t\t\tswitch sd := l.StructDeclarator; sd.Case {\n\t\t\t\tcase 0: // Declarator\n\t\t\t\t\td = sd.Declarator\n\t\t\t\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\t\t\t\tif o := sd.DeclaratorOpt; o != nil {\n\t\t\t\t\t\tx := o.Declarator\n\t\t\t\t\t\tif x.bitOffset == 0  {\n\t\t\t\t\t\t\td = x\n\t\t\t\t\t\t\tbt = lx.scope.bitFieldTypes[i]\n\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx.bitFieldType = bt\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlx.scope.bitFieldTypes = nil\n\n\t\tlhs.alignOf = sc.maxAlign\n\t\tswitch {\n\t\tcase sc.isUnion:\n\t\t\tlhs.sizeOf = align(sc.maxSize, sc.maxAlign)\n\t\tdefault:\n\t\t\toff := sc.offset\n\t\t\tlhs.sizeOf = align(sc.offset, sc.maxAlign)\n\t\t\tif d != nil {\n\t\t\t\td.padding = lhs.sizeOf-off\n\t\t\t}\n\t\t}\n\n\t\tlx.popScope(lhs.Token2)\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t}\n\t}\n|\tStructOrUnion IDENTIFIER\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructOrUnionSpecifier{\n\t\t\tCase:           1,\n\t\t\tStructOrUnion:  $1.(*StructOrUnion),\n\t\t\tToken:          $2,\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.declareStructTag(lhs.Token, lx.report)\n\t\tlhs.scope = lx.scope\n\t}\n|\tStructOrUnion IdentifierOpt '{' '}'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructOrUnionSpecifier{\n\t\t\tCase:           2,\n\t\t\tStructOrUnion:  $1.(*StructOrUnion),\n\t\t\tIdentifierOpt:  $2.(*IdentifierOpt),\n\t\t\tToken:          $3,\n\t\t\tToken2:         $4,\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableEmptyStructs {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"empty structs/unions not allowed\")\n\t\t}\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t}\n\t\tlx.scope.isUnion = $1.(*StructOrUnion).Case == 1 // \"union\"\n\t\tlx.scope.prevStructDeclarator = nil\n\t\tlhs.alignOf = 1\n\t\tlhs.sizeOf = 0\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t}\n\t}\n\nStructOrUnion:\n\t\"struct\"\n\t{\n\t\t$$ = &StructOrUnion{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\t\"union\"\n\t{\n\t\t$$ = &StructOrUnion{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nStructDeclarationList:\n\tStructDeclaration\n\t{\n\t\t$$ = &StructDeclarationList{\n\t\t\tStructDeclaration:  $1.(*StructDeclaration),\n\t\t}\n\t}\n|\tStructDeclarationList StructDeclaration\n\t{\n\t\t$$ = &StructDeclarationList{\n\t\t\tCase:                   1,\n\t\t\tStructDeclarationList:  $1.(*StructDeclarationList),\n\t\t\tStructDeclaration:      $2.(*StructDeclaration),\n\t\t}\n\t}\n\nStructDeclaration:\n\tSpecifierQualifierList StructDeclaratorList ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructDeclaration{\n\t\t\tSpecifierQualifierList:  $1.(*SpecifierQualifierList),\n\t\t\tStructDeclaratorList:    $2.(*StructDeclaratorList).reverse(),\n\t\t\tToken:                   $3,\n\t\t}\n\t\t$$ = lhs\n\t\ts := lhs.SpecifierQualifierList\n\t\tif k := s.kind(); k != Struct && k != Union {\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\tts := l.TypeSpecifier\n\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\t}\n|\tSpecifierQualifierList ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructDeclaration{\n\t\t\tCase:                    1,\n\t\t\tSpecifierQualifierList:  $1.(*SpecifierQualifierList),\n\t\t\tToken:                   $2,\n\t\t}\n\t\t$$ = lhs\n\t\ts := lhs.SpecifierQualifierList\n\t\tif !lx.tweaks.enableAnonymousStructFields {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"unnamed fields not allowed\")\n\t\t} else if k := s.kind(); k != Struct && k != Union {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"only unnamed structs and unions are allowed\")\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\n\t\t// we have no struct declarators to parse, so we have to create the case of one implicit declarator\n\t\t// because else the size of anonymous members is not included in the struct size!\n\t\tdummy := &StructDeclarator{Declarator: d}\n\t\tdummy.post(lx)\n\n\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\tts := l.TypeSpecifier\n\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\t}\n|\tStaticAssertDeclaration\n\t{\n\t\t$$ = &StructDeclaration{\n\t\t\tCase:                     2,\n\t\t\tStaticAssertDeclaration:  $1.(*StaticAssertDeclaration),\n\t\t}\n\t}\n\nSpecifierQualifierList:\n\tTypeSpecifier SpecifierQualifierListOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &SpecifierQualifierList{\n\t\t\tTypeSpecifier:              $1.(*TypeSpecifier),\n\t\t\tSpecifierQualifierListOpt:  $2.(*SpecifierQualifierListOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeSpecifier\n\t\tb := lhs.SpecifierQualifierListOpt\n\t\tif b == nil {\n\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = b.attr\n\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsDecode(b.typeSpecifier)...)...)\n\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.typeSpecifier = ts\n\t}\n|\tTypeQualifier SpecifierQualifierListOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &SpecifierQualifierList{\n\t\t\tCase:                       1,\n\t\t\tTypeQualifier:              $1.(*TypeQualifier),\n\t\t\tSpecifierQualifierListOpt:  $2.(*SpecifierQualifierListOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeQualifier\n\t\tb := lhs.SpecifierQualifierListOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t}\n\nSpecifierQualifierListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*SpecifierQualifierListOpt)(nil)\n\t\t}\n|\tSpecifierQualifierList\n\t{\n\t\tlhs := &SpecifierQualifierListOpt{\n\t\t\tSpecifierQualifierList:  $1.(*SpecifierQualifierList),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = lhs.SpecifierQualifierList.attr\n\t\tlhs.typeSpecifier = lhs.SpecifierQualifierList.typeSpecifier\n\t}\n\nStructDeclaratorList:\n\tStructDeclarator\n\t{\n\t\t$$ = &StructDeclaratorList{\n\t\t\tStructDeclarator:  $1.(*StructDeclarator),\n\t\t}\n\t}\n|\tStructDeclaratorList ',' StructDeclarator\n\t{\n\t\t$$ = &StructDeclaratorList{\n\t\t\tCase:                  1,\n\t\t\tStructDeclaratorList:  $1.(*StructDeclaratorList),\n\t\t\tToken:                 $2,\n\t\t\tStructDeclarator:      $3.(*StructDeclarator),\n\t\t}\n\t}\n\nStructDeclarator:\n\tDeclarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructDeclarator{\n\t\t\tDeclarator:  $1.(*Declarator),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Declarator.setFull(lx)\n\t\tlhs.post(lx)\n\t}\n|\tDeclaratorOpt ':' ConstantExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StructDeclarator{\n\t\t\tCase:                1,\n\t\t\tDeclaratorOpt:       $1.(*DeclaratorOpt),\n\t\t\tToken:               $2,\n\t\t\tConstantExpression:  $3.(*ConstantExpression),\n\t\t}\n\t\t$$ = lhs\n\t\tm := lx.model\n\t\te := lhs.ConstantExpression\n\t\tif e.Value == nil {\n\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t}\n\t\tif !IsIntType(e.Type) {\n\t\t\tlx.report.Err(e.Pos(), \"bit field width not an integer (have '%s')\", e.Type)\n\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t}\n\t\tif o := lhs.DeclaratorOpt; o != nil {\n\t\t\to.Declarator.setFull(lx)\n\t\t}\n\t\tlhs.post(lx)\n\t}\n\nCommaOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*CommaOpt)(nil)\n\t\t}\n|\t','\n\t{\n\t\t$$ = &CommaOpt{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nEnumSpecifier:\n\t\"enum\" IdentifierOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareEnumTag(o.Token, lx.report)\n\t\t}\n\t\tlx.iota = 0\n\t}\n\t'{' EnumeratorList CommaOpt '}'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &EnumSpecifier{\n\t\t\tToken:           $1,\n\t\t\tIdentifierOpt:   $2.(*IdentifierOpt),\n\t\t\tToken2:          $4,\n\t\t\tEnumeratorList:  $5.(*EnumeratorList).reverse(),\n\t\t\tCommaOpt:        $6.(*CommaOpt),\n\t\t\tToken3:          $7,\n\t\t}\n\t\t$$ = lhs\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineEnumTag(o.Token, lhs, lx.report)\n\t\t}\n\t\tif !lx.tweaks.enableUnsignedEnums {\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.unsigned = true\n\tloop:\n\t\tfor l := lhs.EnumeratorList; l != nil; l = l.EnumeratorList {\n\t\t\tswitch e := l.Enumerator; x := e.Value.(type) {\n\t\t\tcase int32:\n\t\t\t\tif x < 0 {\n\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tif x < 0 {\n\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%s: TODO Enumerator.Value type %T\", position(e.Pos()), x))\n\t\t\t}\n\t\t}\n\t}\n|\t\"enum\" IDENTIFIER\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &EnumSpecifier{\n\t\t\tCase:    1,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t\t$$ = lhs\n\t\tlx.scope.declareEnumTag(lhs.Token2, lx.report)\n\t}\n\nEnumeratorList:\n\tEnumerator\n\t{\n\t\t$$ = &EnumeratorList{\n\t\t\tEnumerator:  $1.(*Enumerator),\n\t\t}\n\t}\n|\tEnumeratorList ',' Enumerator\n\t{\n\t\t$$ = &EnumeratorList{\n\t\t\tCase:            1,\n\t\t\tEnumeratorList:  $1.(*EnumeratorList),\n\t\t\tToken:           $2,\n\t\t\tEnumerator:      $3.(*Enumerator),\n\t\t}\n\t}\n\nEnumerator:\n\tEnumerationConstant\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Enumerator{\n\t\t\tEnumerationConstant:  $1.(*EnumerationConstant),\n\t\t}\n\t\t$$ = lhs\n\t\tm := lx.model\n\t\tv := m.MustConvert(lx.iota, m.IntType)\n\t\tlhs.Value = v\n\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t}\n|\tEnumerationConstant '=' ConstantExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Enumerator{\n\t\t\tCase:                 1,\n\t\t\tEnumerationConstant:  $1.(*EnumerationConstant),\n\t\t\tToken:                $2,\n\t\t\tConstantExpression:   $3.(*ConstantExpression),\n\t\t}\n\t\t$$ = lhs\n\t\tm := lx.model\n\t\te := lhs.ConstantExpression\n\t\tvar v interface{}\n\t\t// [0], 6.7.2.2\n\t\t// The expression that defines the value of an enumeration\n\t\t// constant shall be an integer constant expression that has a\n\t\t// value representable as an int.\n\t\tswitch {\n\t\tcase !IsIntType(e.Type):\n\t\t\tlx.report.Err(e.Pos(), \"not an integer constant expression (have '%s')\", e.Type)\n\t\t\tv = m.MustConvert(int32(0), m.IntType)\n\t\tdefault:\n\t\t\tvar ok bool\n\t\t\tif v, ok = m.enumValueToInt(e.Value); !ok {\n\t\t\t\tlx.report.Err(e.Pos(), \"overflow in enumeration value: %v\", e.Value)\n\t\t\t}\n\t\t}\n\n\t\tlhs.Value = v\n\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t}\n\nTypeQualifier:\n\t\"const\"\n\t{\n\t\tlhs := &TypeQualifier{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saConst\n\t}\n|\t\"restrict\"\n\t{\n\t\tlhs := &TypeQualifier{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saRestrict\n\t}\n|\t\"volatile\"\n\t{\n\t\tlhs := &TypeQualifier{\n\t\t\tCase:   2,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saVolatile\n\t}\n\nFunctionSpecifier:\n\t\"inline\"\n\t{\n\t\tlhs := &FunctionSpecifier{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saInline\n\t}\n|\t\"_Noreturn\"\n\t{\n\t\tlhs := &FunctionSpecifier{\n\t\t\tCase:   1,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = saNoreturn\n\t}\n\nDeclarator:\n\tPointerOpt DirectDeclarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Declarator{\n\t\t\tPointerOpt:        $1.(*PointerOpt),\n\t\t\tDirectDeclarator:  $2.(*DirectDeclarator),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.specifier = lx.scope.specifier\n\t\tlhs.DirectDeclarator.declarator = lhs\n\t}\n\nDeclaratorOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*DeclaratorOpt)(nil)\n\t\t}\n|\tDeclarator\n\t{\n\t\t$$ = &DeclaratorOpt{\n\t\t\tDeclarator:  $1.(*Declarator),\n\t\t}\n\t}\n\nDirectDeclarator:\n\tIDENTIFIER\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectDeclarator{\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.specifier = lx.scope.specifier\n\t\tlx.scope.declareIdentifier(lhs.Token, lhs, lx.report)\n\t\tlhs.idScope = lx.scope\n\t}\n|\t'(' Declarator ')'\n\t{\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:        1,\n\t\t\tToken:       $1,\n\t\t\tDeclarator:  $2.(*Declarator),\n\t\t\tToken2:      $3,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Declarator.specifier = nil\n\t\tlhs.Declarator.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:                  2,\n\t\t\tDirectDeclarator:      $1.(*DirectDeclarator),\n\t\t\tToken:                 $2,\n\t\t\tTypeQualifierListOpt:  $3.(*TypeQualifierListOpt),\n\t\t\tExpressionOpt:         $4.(*ExpressionOpt),\n\t\t\tToken2:                $5,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.elements = -1\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\tvar err error\n\t\t\tif lhs.elements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:                  3,\n\t\t\tDirectDeclarator:      $1.(*DirectDeclarator),\n\t\t\tToken:                 $2,\n\t\t\tToken2:                $3,\n\t\t\tTypeQualifierListOpt:  $4.(*TypeQualifierListOpt),\n\t\t\tExpression:            $5.(*Expression),\n\t\t\tToken3:                $6,\n\t\t}\n\t\t$$ = lhs\n\t\tvar err error\n\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:               4,\n\t\t\tDirectDeclarator:   $1.(*DirectDeclarator),\n\t\t\tToken:              $2,\n\t\t\tTypeQualifierList:  $3.(*TypeQualifierList).reverse(),\n\t\t\tToken2:             $4,\n\t\t\tExpression:         $5.(*Expression),\n\t\t\tToken3:             $6,\n\t\t}\n\t\t$$ = lhs\n\t\tvar err error\n\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t{\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:                  5,\n\t\t\tDirectDeclarator:      $1.(*DirectDeclarator),\n\t\t\tToken:                 $2,\n\t\t\tTypeQualifierListOpt:  $3.(*TypeQualifierListOpt),\n\t\t\tToken2:                $4,\n\t\t\tToken3:                $5,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.DirectDeclarator.parent = lhs\n\t\tlhs.elements = -1\n\t}\n|\tDirectDeclarator '('\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeList ')'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:               6,\n\t\t\tDirectDeclarator:   $1.(*DirectDeclarator),\n\t\t\tToken:              $2,\n\t\t\tParameterTypeList:  $4.(*ParameterTypeList),\n\t\t\tToken2:             $5,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '(' IdentifierListOpt ')'\n\t{\n\t\tlhs := &DirectDeclarator{\n\t\t\tCase:               7,\n\t\t\tDirectDeclarator:   $1.(*DirectDeclarator),\n\t\t\tToken:              $2,\n\t\t\tIdentifierListOpt:  $3.(*IdentifierListOpt),\n\t\t\tToken2:             $4,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n\nPointer:\n\t'*' TypeQualifierListOpt\n\t{\n\t\t$$ = &Pointer{\n\t\t\tToken:                 $1,\n\t\t\tTypeQualifierListOpt:  $2.(*TypeQualifierListOpt),\n\t\t}\n\t}\n|\t'*' TypeQualifierListOpt Pointer\n\t{\n\t\t$$ = &Pointer{\n\t\t\tCase:                  1,\n\t\t\tToken:                 $1,\n\t\t\tTypeQualifierListOpt:  $2.(*TypeQualifierListOpt),\n\t\t\tPointer:               $3.(*Pointer),\n\t\t}\n\t}\n\nPointerOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*PointerOpt)(nil)\n\t\t}\n|\tPointer\n\t{\n\t\t$$ = &PointerOpt{\n\t\t\tPointer:  $1.(*Pointer),\n\t\t}\n\t}\n\nTypeQualifierList:\n\tTypeQualifier\n\t{\n\t\tlhs := &TypeQualifierList{\n\t\t\tTypeQualifier:  $1.(*TypeQualifier),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.attr = lhs.TypeQualifier.attr\n\t}\n|\tTypeQualifierList TypeQualifier\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &TypeQualifierList{\n\t\t\tCase:               1,\n\t\t\tTypeQualifierList:  $1.(*TypeQualifierList),\n\t\t\tTypeQualifier:      $2.(*TypeQualifier),\n\t\t}\n\t\t$$ = lhs\n\t\ta := lhs.TypeQualifierList\n\t\tb := lhs.TypeQualifier\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(b.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t}\n\nTypeQualifierListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*TypeQualifierListOpt)(nil)\n\t\t}\n|\tTypeQualifierList\n\t{\n\t\t$$ = &TypeQualifierListOpt{\n\t\t\tTypeQualifierList:  $1.(*TypeQualifierList).reverse(),\n\t\t}\n\t}\n\nParameterTypeList:\n\tParameterList\n\t{\n\t\tlhs := &ParameterTypeList{\n\t\t\tParameterList:  $1.(*ParameterList).reverse(),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.post()\n\t}\n|\tParameterList ',' \"...\"\n\t{\n\t\tlhs := &ParameterTypeList{\n\t\t\tCase:           1,\n\t\t\tParameterList:  $1.(*ParameterList).reverse(),\n\t\t\tToken:          $2,\n\t\t\tToken2:         $3,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.post()\n\t}\n\nParameterTypeListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ParameterTypeListOpt)(nil)\n\t\t}\n|\tParameterTypeList\n\t{\n\t\t$$ = &ParameterTypeListOpt{\n\t\t\tParameterTypeList:  $1.(*ParameterTypeList),\n\t\t}\n\t}\n\nParameterList:\n\tParameterDeclaration\n\t{\n\t\t$$ = &ParameterList{\n\t\t\tParameterDeclaration:  $1.(*ParameterDeclaration),\n\t\t}\n\t}\n|\tParameterList ',' ParameterDeclaration\n\t{\n\t\t$$ = &ParameterList{\n\t\t\tCase:                  1,\n\t\t\tParameterList:         $1.(*ParameterList),\n\t\t\tToken:                 $2,\n\t\t\tParameterDeclaration:  $3.(*ParameterDeclaration),\n\t\t}\n\t}\n\nParameterDeclaration:\n\tDeclarationSpecifiers Declarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ParameterDeclaration{\n\t\t\tDeclarationSpecifiers:  $1.(*DeclarationSpecifiers),\n\t\t\tDeclarator:             $2.(*Declarator),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Declarator.setFull(lx)\n\t\tlhs.declarator = lhs.Declarator\n\t}\n|\tDeclarationSpecifiers AbstractDeclaratorOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ParameterDeclaration{\n\t\t\tCase:                   1,\n\t\t\tDeclarationSpecifiers:  $1.(*DeclarationSpecifiers),\n\t\t\tAbstractDeclaratorOpt:  $2.(*AbstractDeclaratorOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t\tlhs.declarator.setFull(lx)\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t},\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t\td.setFull(lx)\n\t}\n\nIdentifierList:\n\tIDENTIFIER\n\t{\n\t\t$$ = &IdentifierList{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tIdentifierList ',' IDENTIFIER\n\t{\n\t\t$$ = &IdentifierList{\n\t\t\tCase:            1,\n\t\t\tIdentifierList:  $1.(*IdentifierList),\n\t\t\tToken:           $2,\n\t\t\tToken2:          $3,\n\t\t}\n\t}\n\nIdentifierListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*IdentifierListOpt)(nil)\n\t\t}\n|\tIdentifierList\n\t{\n\t\t$$ = &IdentifierListOpt{\n\t\t\tIdentifierList:  $1.(*IdentifierList).reverse(),\n\t\t}\n\t}\n\nIdentifierOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*IdentifierOpt)(nil)\n\t\t}\n|\tIDENTIFIER\n\t{\n\t\t$$ = &IdentifierOpt{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nTypeName:\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.pushScope(ScopeBlock)\n\t}\n\tSpecifierQualifierList AbstractDeclaratorOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &TypeName{\n\t\t\tSpecifierQualifierList:  $2.(*SpecifierQualifierList),\n\t\t\tAbstractDeclaratorOpt:   $3.(*AbstractDeclaratorOpt),\n\t\t}\n\t\t$$ = lhs\n\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t} else {\n\t\t\td := &Declarator{\n\t\t\t\tspecifier: lhs.SpecifierQualifierList,\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t\tidScope: lx.scope,\n\t\t\t\t},\n\t\t\t}\n\t\t\td.DirectDeclarator.declarator = d\n\t\t\tlhs.declarator = d\n\t\t}\n\t\tlhs.Type = lhs.declarator.setFull(lx)\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(xc.Token{})\n\t}\n\nAbstractDeclarator:\n\tPointer\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &AbstractDeclarator{\n\t\t\tPointer:  $1.(*Pointer),\n\t\t}\n\t\t$$ = lhs\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tPointerOpt: &PointerOpt {\n\t\t\t\tPointer: lhs.Pointer,\n\t\t\t},\n\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\tidScope: lx.scope,\n\t\t\t},\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t}\n|\tPointerOpt DirectAbstractDeclarator\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &AbstractDeclarator{\n\t\t\tCase:                      1,\n\t\t\tPointerOpt:                $1.(*PointerOpt),\n\t\t\tDirectAbstractDeclarator:  $2.(*DirectAbstractDeclarator),\n\t\t}\n\t\t$$ = lhs\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tPointerOpt: lhs.PointerOpt,\n\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t}\n\nAbstractDeclaratorOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*AbstractDeclaratorOpt)(nil)\n\t\t}\n|\tAbstractDeclarator\n\t{\n\t\t$$ = &AbstractDeclaratorOpt{\n\t\t\tAbstractDeclarator:  $1.(*AbstractDeclarator),\n\t\t}\n\t}\n\nDirectAbstractDeclarator:\n\t'(' AbstractDeclarator ')'\n\t{\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tToken:               $1,\n\t\t\tAbstractDeclarator:  $2.(*AbstractDeclarator),\n\t\t\tToken2:              $3,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.AbstractDeclarator.declarator.specifier = nil\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 1, // '(' Declarator ')'\n\t\t\tDeclarator: lhs.AbstractDeclarator.declarator,\n\t\t}\n\t\tlhs.AbstractDeclarator.declarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' ExpressionOpt ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                         1,\n\t\t\tDirectAbstractDeclaratorOpt:  $1.(*DirectAbstractDeclaratorOpt),\n\t\t\tToken:                        $2,\n\t\t\tExpressionOpt:                $3.(*ExpressionOpt),\n\t\t\tToken2:                       $4,\n\t\t}\n\t\t$$ = lhs\n\t\tnElements := -1\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\tvar err error\n\t\t\tif nElements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t}\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tExpressionOpt: lhs.ExpressionOpt,\n\t\t\telements: nElements,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' TypeQualifierList ExpressionOpt ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                         2,\n\t\t\tDirectAbstractDeclaratorOpt:  $1.(*DirectAbstractDeclaratorOpt),\n\t\t\tToken:                        $2,\n\t\t\tTypeQualifierList:            $3.(*TypeQualifierList).reverse(),\n\t\t\tExpressionOpt:                $4.(*ExpressionOpt),\n\t\t\tToken2:                       $5,\n\t\t}\n\t\t$$ = lhs\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\to.Expression.eval(lx)\n\t\t}\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierListOpt: &TypeQualifierListOpt{ lhs.TypeQualifierList },\n\t\t\tExpressionOpt: lhs.ExpressionOpt,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expression ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                         3,\n\t\t\tDirectAbstractDeclaratorOpt:  $1.(*DirectAbstractDeclaratorOpt),\n\t\t\tToken:                        $2,\n\t\t\tToken2:                       $3,\n\t\t\tTypeQualifierListOpt:         $4.(*TypeQualifierListOpt),\n\t\t\tExpression:                   $5.(*Expression),\n\t\t\tToken3:                       $6,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Expression.eval(lx)\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierListOpt: lhs.TypeQualifierListOpt,\n\t\t\tExpression: lhs.Expression,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expression ']'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                         4,\n\t\t\tDirectAbstractDeclaratorOpt:  $1.(*DirectAbstractDeclaratorOpt),\n\t\t\tToken:                        $2,\n\t\t\tTypeQualifierList:            $3.(*TypeQualifierList).reverse(),\n\t\t\tToken2:                       $4,\n\t\t\tExpression:                   $5.(*Expression),\n\t\t\tToken3:                       $6,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Expression.eval(lx)\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierList: lhs.TypeQualifierList,\n\t\t\tExpression: lhs.Expression,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' '*' ']'\n\t{\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                         5,\n\t\t\tDirectAbstractDeclaratorOpt:  $1.(*DirectAbstractDeclaratorOpt),\n\t\t\tToken:                        $2,\n\t\t\tToken2:                       $3,\n\t\t\tToken3:                       $4,\n\t\t}\n\t\t$$ = lhs\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 5, // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t\tDirectDeclarator: dd,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\t'('\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeListOpt ')'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                  6,\n\t\t\tToken:                 $1,\n\t\t\tParameterTypeListOpt:  $3.(*ParameterTypeListOpt),\n\t\t\tToken2:                $4,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\tcase o != nil:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t},\n\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t}\n\t\tdefault:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclarator '('\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeListOpt ')'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DirectAbstractDeclarator{\n\t\t\tCase:                      7,\n\t\t\tDirectAbstractDeclarator:  $1.(*DirectAbstractDeclarator),\n\t\t\tToken:                     $2,\n\t\t\tParameterTypeListOpt:      $4.(*ParameterTypeListOpt),\n\t\t\tToken2:                    $5,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\tcase o != nil:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t}\n\t\tdefault:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t}\n\t\t}\n\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n\nDirectAbstractDeclaratorOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*DirectAbstractDeclaratorOpt)(nil)\n\t\t}\n|\tDirectAbstractDeclarator\n\t{\n\t\t$$ = &DirectAbstractDeclaratorOpt{\n\t\t\tDirectAbstractDeclarator:  $1.(*DirectAbstractDeclarator),\n\t\t}\n\t}\n\nInitializer:\n\tExpression\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Initializer{\n\t\t\tExpression:  $1.(*Expression),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.Expression.eval(lx)\n\t}\n|\t'{' InitializerList CommaOpt '}'\n\t{\n\t\t$$ = &Initializer{\n\t\t\tCase:             1,\n\t\t\tToken:            $1,\n\t\t\tInitializerList:  $2.(*InitializerList).reverse(),\n\t\t\tCommaOpt:         $3.(*CommaOpt),\n\t\t\tToken2:           $4,\n\t\t}\n\t}\n|\tIDENTIFIER ':' Initializer\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &Initializer{\n\t\t\tCase:         2,\n\t\t\tToken:        $1,\n\t\t\tToken2:       $2,\n\t\t\tInitializer:  $3.(*Initializer),\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableLegacyDesignators {\n\t\t\tlx.report.Err(lhs.Pos(), \"legacy designators not enabled\")\n\t\t}\n\t}\n\nInitializerList:\n\tDesignationOpt Initializer\n\t{\n\t\t$$ = &InitializerList{\n\t\t\tDesignationOpt:  $1.(*DesignationOpt),\n\t\t\tInitializer:     $2.(*Initializer),\n\t\t}\n\t}\n|\tInitializerList ',' DesignationOpt Initializer\n\t{\n\t\t$$ = &InitializerList{\n\t\t\tCase:             1,\n\t\t\tInitializerList:  $1.(*InitializerList),\n\t\t\tToken:            $2,\n\t\t\tDesignationOpt:   $3.(*DesignationOpt),\n\t\t\tInitializer:      $4.(*Initializer),\n\t\t}\n\t}\n|\t/* empty */\n\t{\n\t\t$$ = (*InitializerList)(nil)\n\t\t}\n\nDesignation:\n\tDesignatorList '='\n\t{\n\t\t$$ = &Designation{\n\t\t\tDesignatorList:  $1.(*DesignatorList).reverse(),\n\t\t\tToken:           $2,\n\t\t}\n\t}\n\nDesignationOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*DesignationOpt)(nil)\n\t\t}\n|\tDesignation\n\t{\n\t\t$$ = &DesignationOpt{\n\t\t\tDesignation:  $1.(*Designation),\n\t\t}\n\t}\n\nDesignatorList:\n\tDesignator\n\t{\n\t\t$$ = &DesignatorList{\n\t\t\tDesignator:  $1.(*Designator),\n\t\t}\n\t}\n|\tDesignatorList Designator\n\t{\n\t\t$$ = &DesignatorList{\n\t\t\tCase:            1,\n\t\t\tDesignatorList:  $1.(*DesignatorList),\n\t\t\tDesignator:      $2.(*Designator),\n\t\t}\n\t}\n\nDesignator:\n\t'[' ConstantExpression ']'\n\t{\n\t\t$$ = &Designator{\n\t\t\tToken:               $1,\n\t\t\tConstantExpression:  $2.(*ConstantExpression),\n\t\t\tToken2:              $3,\n\t\t}\n\t}\n|\t'.' IDENTIFIER\n\t{\n\t\t$$ = &Designator{\n\t\t\tCase:    1,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t}\n\nStatement:\n\tLabeledStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tLabeledStatement:  $1.(*LabeledStatement),\n\t\t}\n\t}\n|\tCompoundStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:               1,\n\t\t\tCompoundStatement:  $1.(*CompoundStatement),\n\t\t}\n\t}\n|\tExpressionStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:                 2,\n\t\t\tExpressionStatement:  $1.(*ExpressionStatement),\n\t\t}\n\t}\n|\tSelectionStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:                3,\n\t\t\tSelectionStatement:  $1.(*SelectionStatement),\n\t\t}\n\t}\n|\tIterationStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:                4,\n\t\t\tIterationStatement:  $1.(*IterationStatement),\n\t\t}\n\t}\n|\tJumpStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:           5,\n\t\t\tJumpStatement:  $1.(*JumpStatement),\n\t\t}\n\t}\n|\tAssemblerStatement\n\t{\n\t\t$$ = &Statement{\n\t\t\tCase:                6,\n\t\t\tAssemblerStatement:  $1.(*AssemblerStatement),\n\t\t}\n\t}\n\nLabeledStatement:\n\tIDENTIFIER ':' Statement\n\t{\n\t\t$$ = &LabeledStatement{\n\t\t\tToken:      $1,\n\t\t\tToken2:     $2,\n\t\t\tStatement:  $3.(*Statement),\n\t\t}\n\t}\n|\t\"case\" ConstantExpression ':' Statement\n\t{\n\t\t$$ = &LabeledStatement{\n\t\t\tCase:                1,\n\t\t\tToken:               $1,\n\t\t\tConstantExpression:  $2.(*ConstantExpression),\n\t\t\tToken2:              $3,\n\t\t\tStatement:           $4.(*Statement),\n\t\t}\n\t}\n|\t\"default\" ':' Statement\n\t{\n\t\t$$ = &LabeledStatement{\n\t\t\tCase:       2,\n\t\t\tToken:      $1,\n\t\t\tToken2:     $2,\n\t\t\tStatement:  $3.(*Statement),\n\t\t}\n\t}\n\nCompoundStatement:\n\t'{'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tm := lx.scope.mergeScope\n\t\tlx.pushScope(ScopeBlock)\n\t\tif m != nil {\n\t\t\tlx.scope.merge(m)\n\t\t}\n\t\tlx.scope.mergeScope = nil\n\t}\n\tBlockItemListOpt '}'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &CompoundStatement{\n\t\t\tToken:             $1,\n\t\t\tBlockItemListOpt:  $3.(*BlockItemListOpt),\n\t\t\tToken2:            $4,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(lhs.Token2)\n\t}\n\nBlockItemList:\n\tBlockItem\n\t{\n\t\t$$ = &BlockItemList{\n\t\t\tBlockItem:  $1.(*BlockItem),\n\t\t}\n\t}\n|\tBlockItemList BlockItem\n\t{\n\t\t$$ = &BlockItemList{\n\t\t\tCase:           1,\n\t\t\tBlockItemList:  $1.(*BlockItemList),\n\t\t\tBlockItem:      $2.(*BlockItem),\n\t\t}\n\t}\n\nBlockItemListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*BlockItemListOpt)(nil)\n\t\t}\n|\tBlockItemList\n\t{\n\t\t$$ = &BlockItemListOpt{\n\t\t\tBlockItemList:  $1.(*BlockItemList).reverse(),\n\t\t}\n\t}\n\nBlockItem:\n\tDeclaration\n\t{\n\t\t$$ = &BlockItem{\n\t\t\tDeclaration:  $1.(*Declaration),\n\t\t}\n\t}\n|\tStatement\n\t{\n\t\t$$ = &BlockItem{\n\t\t\tCase:       1,\n\t\t\tStatement:  $1.(*Statement),\n\t\t}\n\t}\n\nExpressionStatement:\n\tExpressionListOpt ';'\n\t{\n\t\t$$ = &ExpressionStatement{\n\t\t\tExpressionListOpt:  $1.(*ExpressionListOpt),\n\t\t\tToken:              $2,\n\t\t}\n\t}\n\nSelectionStatement:\n\t\"if\" '(' ExpressionList ')' Statement %prec NOELSE\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &SelectionStatement{\n\t\t\tToken:           $1,\n\t\t\tToken2:          $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken3:          $4,\n\t\t\tStatement:       $5.(*Statement),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"if\" '(' ExpressionList ')' Statement \"else\" Statement\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &SelectionStatement{\n\t\t\tCase:            1,\n\t\t\tToken:           $1,\n\t\t\tToken2:          $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken3:          $4,\n\t\t\tStatement:       $5.(*Statement),\n\t\t\tToken4:          $6,\n\t\t\tStatement2:      $7.(*Statement),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"switch\" '(' ExpressionList ')' Statement\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &SelectionStatement{\n\t\t\tCase:            2,\n\t\t\tToken:           $1,\n\t\t\tToken2:          $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken3:          $4,\n\t\t\tStatement:       $5.(*Statement),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n\nIterationStatement:\n\t\"while\" '(' ExpressionList ')' Statement\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &IterationStatement{\n\t\t\tToken:           $1,\n\t\t\tToken2:          $2,\n\t\t\tExpressionList:  $3.(*ExpressionList).reverse(),\n\t\t\tToken3:          $4,\n\t\t\tStatement:       $5.(*Statement),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"do\" Statement \"while\" '(' ExpressionList ')' ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &IterationStatement{\n\t\t\tCase:            1,\n\t\t\tToken:           $1,\n\t\t\tStatement:       $2.(*Statement),\n\t\t\tToken2:          $3,\n\t\t\tToken3:          $4,\n\t\t\tExpressionList:  $5.(*ExpressionList).reverse(),\n\t\t\tToken4:          $6,\n\t\t\tToken5:          $7,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"for\" '(' ExpressionListOpt ';' ExpressionListOpt ';' ExpressionListOpt ')' Statement\n\t{\n\t\t$$ = &IterationStatement{\n\t\t\tCase:                2,\n\t\t\tToken:               $1,\n\t\t\tToken2:              $2,\n\t\t\tExpressionListOpt:   $3.(*ExpressionListOpt),\n\t\t\tToken3:              $4,\n\t\t\tExpressionListOpt2:  $5.(*ExpressionListOpt),\n\t\t\tToken4:              $6,\n\t\t\tExpressionListOpt3:  $7.(*ExpressionListOpt),\n\t\t\tToken5:              $8,\n\t\t\tStatement:           $9.(*Statement),\n\t\t}\n\t}\n|\t\"for\" '(' Declaration ExpressionListOpt ';' ExpressionListOpt ')' Statement\n\t{\n\t\t$$ = &IterationStatement{\n\t\t\tCase:                3,\n\t\t\tToken:               $1,\n\t\t\tToken2:              $2,\n\t\t\tDeclaration:         $3.(*Declaration),\n\t\t\tExpressionListOpt:   $4.(*ExpressionListOpt),\n\t\t\tToken3:              $5,\n\t\t\tExpressionListOpt2:  $6.(*ExpressionListOpt),\n\t\t\tToken4:              $7,\n\t\t\tStatement:           $8.(*Statement),\n\t\t}\n\t}\n\nJumpStatement:\n\t\"goto\" IDENTIFIER ';'\n\t{\n\t\t$$ = &JumpStatement{\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t\tToken3:  $3,\n\t\t}\n\t}\n|\t\"continue\" ';'\n\t{\n\t\t$$ = &JumpStatement{\n\t\t\tCase:    1,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t}\n|\t\"break\" ';'\n\t{\n\t\t$$ = &JumpStatement{\n\t\t\tCase:    2,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t}\n|\t\"return\" ExpressionListOpt ';'\n\t{\n\t\t$$ = &JumpStatement{\n\t\t\tCase:               3,\n\t\t\tToken:              $1,\n\t\t\tExpressionListOpt:  $2.(*ExpressionListOpt),\n\t\t\tToken2:             $3,\n\t\t}\n\t}\n|\t\"goto\" Expression ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &JumpStatement{\n\t\t\tCase:        4,\n\t\t\tToken:       $1,\n\t\t\tExpression:  $2.(*Expression),\n\t\t\tToken2:      $3,\n\t\t}\n\t\t$$ = lhs\n\t\t_, t := lhs.Expression.eval(lx)\n\t\tif t == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tfor t != nil && t.Kind() == Ptr {\n\t\t\tt = t.Element()\n\t\t}\n\n\t\tif t == nil || t.Kind() != Void {\n\t\t\tlx.report.Err(lhs.Pos(), \"invalid computed goto argument type, have '%s'\", t)\n\t\t}\n\n\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t}\n\t}\n\nTranslationUnit:\n\tExternalDeclaration\n\t{\n\t\t$$ = &TranslationUnit{\n\t\t\tExternalDeclaration:  $1.(*ExternalDeclaration),\n\t\t}\n\t}\n|\tTranslationUnit ExternalDeclaration\n\t{\n\t\t$$ = &TranslationUnit{\n\t\t\tCase:                 1,\n\t\t\tTranslationUnit:      $1.(*TranslationUnit),\n\t\t\tExternalDeclaration:  $2.(*ExternalDeclaration),\n\t\t}\n\t}\n\nExternalDeclaration:\n\tFunctionDefinition\n\t{\n\t\t$$ = &ExternalDeclaration{\n\t\t\tFunctionDefinition:  $1.(*FunctionDefinition),\n\t\t}\n\t}\n|\tDeclaration\n\t{\n\t\t$$ = &ExternalDeclaration{\n\t\t\tCase:         1,\n\t\t\tDeclaration:  $1.(*Declaration),\n\t\t}\n\t}\n|\tBasicAssemblerStatement ';'\n\t{\n\t\t$$ = &ExternalDeclaration{\n\t\t\tCase:                     2,\n\t\t\tBasicAssemblerStatement:  $1.(*BasicAssemblerStatement),\n\t\t\tToken:                    $2,\n\t\t}\n\t}\n|\t';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ExternalDeclaration{\n\t\t\tCase:   3,\n\t\t\tToken:  $1,\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableEmptyDeclarations {\n\t\t\tlx.report.Err(lhs.Pos(), \"C++11 empty declarations are illegal in C99.\")\n\t\t}\n\t}\n\nFunctionDefinition:\n\tDeclarationSpecifiers Declarator DeclarationListOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tif ds := $1.(*DeclarationSpecifiers); ds.typeSpecifier == 0 {\n\t\t\tds.typeSpecifier = tsEncode(tsInt)\n\t\t\t$2.(*Declarator).Type = lx.model.IntType\n\t\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\t\tlx.report.Err($2.Pos(), \"missing function return type\")\n\t\t\t}\n\t\t}\n\t\tvar fd *FunctionDefinition\n\t\tfd.post(lx, $2.(*Declarator), $3.(*DeclarationListOpt))\n\t}\n\tFunctionBody\n\t{\n\t\t$$ = &FunctionDefinition{\n\t\t\tDeclarationSpecifiers:  $1.(*DeclarationSpecifiers),\n\t\t\tDeclarator:             $2.(*Declarator),\n\t\t\tDeclarationListOpt:     $3.(*DeclarationListOpt),\n\t\t\tFunctionBody:           $5.(*FunctionBody),\n\t\t}\n\t}\n|\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.scope.specifier = &DeclarationSpecifiers{typeSpecifier: tsEncode(tsInt)}\n\t}\n\tDeclarator DeclarationListOpt\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\tlx.report.Err($2.Pos(), \"missing function return type\")\n\t\t}\n\t\tvar fd *FunctionDefinition\n\t\tfd.post(lx, $2.(*Declarator), $3.(*DeclarationListOpt))\n\t}\n\tFunctionBody\n\t{\n\t\t$$ = &FunctionDefinition{\n\t\t\tCase:                1,\n\t\t\tDeclarator:          $2.(*Declarator),\n\t\t\tDeclarationListOpt:  $3.(*DeclarationListOpt),\n\t\t\tFunctionBody:        $5.(*FunctionBody),\n\t\t}\n\t}\n\nFunctionBody:\n\t{\n\t\tlx := yylex.(*lexer)\n\t\t// Handle __func__, [0], 6.4.2.2.\n\t\tid, _ := lx.fnDeclarator.Identifier()\n\t\tlx.injectFunc = []xc.Token{\n\t\t\t{lex.Char{Rune: STATIC}, idStatic},\n\t\t\t{lex.Char{Rune: CONST}, idConst},\n\t\t\t{lex.Char{Rune: CHAR}, idChar},\n\t\t\t{lex.Char{Rune: IDENTIFIER}, idMagicFunc},\n\t\t\t{lex.Char{Rune: '['}, 0},\n\t\t\t{lex.Char{Rune: ']'}, 0},\n\t\t\t{lex.Char{Rune: '='}, 0},\n\t\t\t{lex.Char{Rune: STRINGLITERAL}, xc.Dict.SID(fmt.Sprintf(\"%q\", xc.Dict.S(id)))},\n\t\t\t{lex.Char{Rune: ';'}, 0},\n\t\t}\n\t}\n\tCompoundStatement\n\t{\n\t\tlhs := &FunctionBody{\n\t\t\tCompoundStatement:  $2.(*CompoundStatement),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.scope = lhs.CompoundStatement.scope\n\t}\n|\t{\n\t\tlx := yylex.(*lexer)\n\t\tm := lx.scope.mergeScope\n\t\tlx.pushScope(ScopeBlock)\n\t\tif m != nil {\n\t\t\tlx.scope.merge(m)\n\t\t}\n\t\tlx.scope.mergeScope = nil\n\t}\n\tAssemblerStatement ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &FunctionBody{\n\t\t\tCase:                1,\n\t\t\tAssemblerStatement:  $2.(*AssemblerStatement),\n\t\t\tToken:               $3,\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(lx.tokPrev)\n\t}\n\nDeclarationList:\n\tDeclaration\n\t{\n\t\t$$ = &DeclarationList{\n\t\t\tDeclaration:  $1.(*Declaration),\n\t\t}\n\t}\n|\tDeclarationList Declaration\n\t{\n\t\t$$ = &DeclarationList{\n\t\t\tCase:             1,\n\t\t\tDeclarationList:  $1.(*DeclarationList),\n\t\t\tDeclaration:      $2.(*Declaration),\n\t\t}\n\t}\n\nDeclarationListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*DeclarationListOpt)(nil)\n\t\t}\n|\t{\n\t\tlx := yylex.(*lexer)\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tDeclarationList\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &DeclarationListOpt{\n\t\t\tDeclarationList:  $2.(*DeclarationList).reverse(),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.paramsScope, _ = lx.popScopePos(lhs.Pos())\n\t}\n\nAssemblerInstructions:\n\tSTRINGLITERAL\n\t{\n\t\t$$ = &AssemblerInstructions{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tAssemblerInstructions STRINGLITERAL\n\t{\n\t\t$$ = &AssemblerInstructions{\n\t\t\tCase:                   1,\n\t\t\tAssemblerInstructions:  $1.(*AssemblerInstructions),\n\t\t\tToken:                  $2,\n\t\t}\n\t}\n\nBasicAssemblerStatement:\n\t\"asm\" VolatileOpt '(' AssemblerInstructions ')'\n\t{\n\t\t$$ = &BasicAssemblerStatement{\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t}\n\t}\n\nVolatileOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*VolatileOpt)(nil)\n\t\t}\n|\t\"volatile\"\n\t{\n\t\t$$ = &VolatileOpt{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nAssemblerOperand:\n\tAssemblerSymbolicNameOpt STRINGLITERAL '(' Expression ')'\n\t{\n\t\t$$ = &AssemblerOperand{\n\t\t\tAssemblerSymbolicNameOpt:  $1.(*AssemblerSymbolicNameOpt),\n\t\t\tToken:                     $2,\n\t\t\tToken2:                    $3,\n\t\t\tExpression:                $4.(*Expression),\n\t\t\tToken3:                    $5,\n\t\t}\n\t}\n\nAssemblerOperands:\n\tAssemblerOperand\n\t{\n\t\t$$ = &AssemblerOperands{\n\t\t\tAssemblerOperand:  $1.(*AssemblerOperand),\n\t\t}\n\t}\n|\tAssemblerOperands ',' AssemblerOperand\n\t{\n\t\t$$ = &AssemblerOperands{\n\t\t\tCase:               1,\n\t\t\tAssemblerOperands:  $1.(*AssemblerOperands),\n\t\t\tToken:              $2,\n\t\t\tAssemblerOperand:   $3.(*AssemblerOperand),\n\t\t}\n\t}\n\nAssemblerSymbolicNameOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*AssemblerSymbolicNameOpt)(nil)\n\t\t}\n|\t'[' IDENTIFIER ']'\n\t{\n\t\t$$ = &AssemblerSymbolicNameOpt{\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t\tToken3:  $3,\n\t\t}\n\t}\n\nClobbers:\n\tSTRINGLITERAL\n\t{\n\t\t$$ = &Clobbers{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tClobbers ',' STRINGLITERAL\n\t{\n\t\t$$ = &Clobbers{\n\t\t\tCase:      1,\n\t\t\tClobbers:  $1.(*Clobbers),\n\t\t\tToken:     $2,\n\t\t\tToken2:    $3,\n\t\t}\n\t}\n\nAssemblerStatement:\n\tBasicAssemblerStatement\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tBasicAssemblerStatement:  $1.(*BasicAssemblerStatement),\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   1,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t\tAssemblerOperands:      $6.(*AssemblerOperands).reverse(),\n\t\t\tToken4:                 $7,\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   2,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t\tAssemblerOperands:      $6.(*AssemblerOperands).reverse(),\n\t\t\tToken4:                 $7,\n\t\t\tAssemblerOperands2:     $8.(*AssemblerOperands).reverse(),\n\t\t\tToken5:                 $9,\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ':' Clobbers ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   3,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t\tAssemblerOperands:      $6.(*AssemblerOperands).reverse(),\n\t\t\tToken4:                 $7,\n\t\t\tAssemblerOperands2:     $8.(*AssemblerOperands).reverse(),\n\t\t\tToken5:                 $9,\n\t\t\tClobbers:               $10.(*Clobbers).reverse(),\n\t\t\tToken6:                 $11,\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt \"goto\" '(' AssemblerInstructions ':' ':' AssemblerOperands ':' Clobbers ':' IdentifierList ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   4,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tToken3:                 $4,\n\t\t\tAssemblerInstructions:  $5.(*AssemblerInstructions).reverse(),\n\t\t\tToken4:                 $6,\n\t\t\tToken5:                 $7,\n\t\t\tAssemblerOperands:      $8.(*AssemblerOperands).reverse(),\n\t\t\tToken6:                 $9,\n\t\t\tClobbers:               $10.(*Clobbers).reverse(),\n\t\t\tToken7:                 $11,\n\t\t\tIdentifierList:         $12.(*IdentifierList).reverse(),\n\t\t\tToken8:                 $13,\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   5,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t\tToken4:                 $6,\n\t\t}\n\t}\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' ':' AssemblerOperands ')'\n\t{\n\t\t$$ = &AssemblerStatement{\n\t\t\tCase:                   6,\n\t\t\tToken:                  $1,\n\t\t\tVolatileOpt:            $2.(*VolatileOpt),\n\t\t\tToken2:                 $3,\n\t\t\tAssemblerInstructions:  $4.(*AssemblerInstructions).reverse(),\n\t\t\tToken3:                 $5,\n\t\t\tToken4:                 $6,\n\t\t\tAssemblerOperands:      $7.(*AssemblerOperands).reverse(),\n\t\t\tToken5:                 $8,\n\t\t}\n\t}\n\nStaticAssertDeclaration:\n\t\"_Static_assert\" '(' ConstantExpression ',' STRINGLITERAL ')' ';'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &StaticAssertDeclaration{\n\t\t\tToken:               $1,\n\t\t\tToken2:              $2,\n\t\t\tConstantExpression:  $3.(*ConstantExpression),\n\t\t\tToken3:              $4,\n\t\t\tToken4:              $5,\n\t\t\tToken5:              $6,\n\t\t\tToken6:              $7,\n\t\t}\n\t\t$$ = lhs\n\t\tce := lhs.ConstantExpression\n\t\tif ce.Type == nil || ce.Type.Kind() == Undefined || ce.Value == nil || !IsIntType(ce.Type) {\n\t\t\tlx.report.Err(ce.Pos(), \"invalid static assert expression (have '%v')\", ce.Type)\n\t\t\tbreak\n\t\t}\n\n\t\tif !isNonZero(ce.Value) {\n\t\t\tlx.report.ErrTok(lhs.Token, \"%s\", lhs.Token4.S())\n\t\t}\n\t}\n\nPreprocessingFile:\n\tGroupList\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &PreprocessingFile{\n\t\t\tGroupList:  $1.(*GroupList).reverse(),\n\t\t}\n\t\t$$ = lhs\n\t\tlhs.path = lx.file.Name()\n\t}\n\nGroupList:\n\tGroupPart\n\t{\n\t\t$$ = &GroupList{\n\t\t\tGroupPart:  $1,\n\t\t}\n\t}\n|\tGroupList GroupPart\n\t{\n\t\t$$ = &GroupList{\n\t\t\tCase:       1,\n\t\t\tGroupList:  $1.(*GroupList),\n\t\t\tGroupPart:  $2,\n\t\t}\n\t}\n\nGroupListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*GroupListOpt)(nil)\n\t\t}\n|\tGroupList\n\t{\n\t\t$$ = &GroupListOpt{\n\t\t\tGroupList:  $1.(*GroupList).reverse(),\n\t\t}\n\t}\n\nGroupPart:\n\tControlLine\n\t{\n\t\t$$ = $1.(Node)\n\t}\n|\tIfSection\n\t{\n\t\t$$ = $1.(Node)\n\t}\n|\tPPNONDIRECTIVE PPTokenList '\\n'\n\t{\n\t\t$$ = $1\n\t}\n|\tTextLine\n\t{\n\t\t$$ = $1\n\t}\n\nIfSection:\n\tIfGroup ElifGroupListOpt ElseGroupOpt EndifLine\n\t{\n\t\t$$ = &IfSection{\n\t\t\tIfGroup:           $1.(*IfGroup),\n\t\t\tElifGroupListOpt:  $2.(*ElifGroupListOpt),\n\t\t\tElseGroupOpt:      $3.(*ElseGroupOpt),\n\t\t\tEndifLine:         $4.(*EndifLine),\n\t\t}\n\t}\n\nIfGroup:\n\tPPIF PPTokenList '\\n' GroupListOpt\n\t{\n\t\t$$ = &IfGroup{\n\t\t\tToken:         $1,\n\t\t\tPPTokenList:   $2,\n\t\t\tToken2:        $3,\n\t\t\tGroupListOpt:  $4.(*GroupListOpt),\n\t\t}\n\t}\n|\tPPIFDEF IDENTIFIER '\\n' GroupListOpt\n\t{\n\t\t$$ = &IfGroup{\n\t\t\tCase:          1,\n\t\t\tToken:         $1,\n\t\t\tToken2:        $2,\n\t\t\tToken3:        $3,\n\t\t\tGroupListOpt:  $4.(*GroupListOpt),\n\t\t}\n\t}\n|\tPPIFNDEF IDENTIFIER '\\n' GroupListOpt\n\t{\n\t\t$$ = &IfGroup{\n\t\t\tCase:          2,\n\t\t\tToken:         $1,\n\t\t\tToken2:        $2,\n\t\t\tToken3:        $3,\n\t\t\tGroupListOpt:  $4.(*GroupListOpt),\n\t\t}\n\t}\n\nElifGroupList:\n\tElifGroup\n\t{\n\t\t$$ = &ElifGroupList{\n\t\t\tElifGroup:  $1.(*ElifGroup),\n\t\t}\n\t}\n|\tElifGroupList ElifGroup\n\t{\n\t\t$$ = &ElifGroupList{\n\t\t\tCase:           1,\n\t\t\tElifGroupList:  $1.(*ElifGroupList),\n\t\t\tElifGroup:      $2.(*ElifGroup),\n\t\t}\n\t}\n\nElifGroupListOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ElifGroupListOpt)(nil)\n\t\t}\n|\tElifGroupList\n\t{\n\t\t$$ = &ElifGroupListOpt{\n\t\t\tElifGroupList:  $1.(*ElifGroupList).reverse(),\n\t\t}\n\t}\n\nElifGroup:\n\tPPELIF PPTokenList '\\n' GroupListOpt\n\t{\n\t\t$$ = &ElifGroup{\n\t\t\tToken:         $1,\n\t\t\tPPTokenList:   $2,\n\t\t\tToken2:        $3,\n\t\t\tGroupListOpt:  $4.(*GroupListOpt),\n\t\t}\n\t}\n\nElseGroup:\n\tPPELSE '\\n' GroupListOpt\n\t{\n\t\t$$ = &ElseGroup{\n\t\t\tToken:         $1,\n\t\t\tToken2:        $2,\n\t\t\tGroupListOpt:  $3.(*GroupListOpt),\n\t\t}\n\t}\n\nElseGroupOpt:\n\t/* empty */\n\t{\n\t\t$$ = (*ElseGroupOpt)(nil)\n\t\t}\n|\tElseGroup\n\t{\n\t\t$$ = &ElseGroupOpt{\n\t\t\tElseGroup:  $1.(*ElseGroup),\n\t\t}\n\t}\n\nEndifLine:\n\tPPENDIF\n\t{\n\t\t$$ = &EndifLine{\n\t\t\tToken:  $1,\n\t\t}\n\t}\n\nControlLine:\n\tPPDEFINE IDENTIFIER ReplacementList\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tToken:            $1,\n\t\t\tToken2:           $2,\n\t\t\tReplacementList:  $3,\n\t\t}\n\t}\n|\tPPDEFINE IDENTIFIER_LPAREN \"...\" ')' ReplacementList\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:             1,\n\t\t\tToken:            $1,\n\t\t\tToken2:           $2,\n\t\t\tToken3:           $3,\n\t\t\tToken4:           $4,\n\t\t\tReplacementList:  $5,\n\t\t}\n\t}\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierList ',' \"...\" ')' ReplacementList\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:             2,\n\t\t\tToken:            $1,\n\t\t\tToken2:           $2,\n\t\t\tIdentifierList:   $3.(*IdentifierList).reverse(),\n\t\t\tToken3:           $4,\n\t\t\tToken4:           $5,\n\t\t\tToken5:           $6,\n\t\t\tReplacementList:  $7,\n\t\t}\n\t}\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierListOpt ')' ReplacementList\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:               3,\n\t\t\tToken:              $1,\n\t\t\tToken2:             $2,\n\t\t\tIdentifierListOpt:  $3.(*IdentifierListOpt),\n\t\t\tToken3:             $4,\n\t\t\tReplacementList:    $5,\n\t\t}\n\t}\n|\tPPERROR PPTokenListOpt\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:            4,\n\t\t\tToken:           $1,\n\t\t\tPPTokenListOpt:  $2,\n\t\t}\n\t}\n|\tPPHASH_NL\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:   5,\n\t\t\tToken:  $1,\n\t\t}\n\t}\n|\tPPINCLUDE PPTokenList '\\n'\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:         6,\n\t\t\tToken:        $1,\n\t\t\tPPTokenList:  $2,\n\t\t\tToken2:       $3,\n\t\t}\n\t}\n|\tPPLINE PPTokenList '\\n'\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:         7,\n\t\t\tToken:        $1,\n\t\t\tPPTokenList:  $2,\n\t\t\tToken2:       $3,\n\t\t}\n\t}\n|\tPPPRAGMA PPTokenListOpt\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:            8,\n\t\t\tToken:           $1,\n\t\t\tPPTokenListOpt:  $2,\n\t\t}\n\t}\n|\tPPUNDEF IDENTIFIER '\\n'\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:    9,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t\tToken3:  $3,\n\t\t}\n\t}\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierList \"...\" ')' ReplacementList\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ControlLine{\n\t\t\tCase:             10,\n\t\t\tToken:            $1,\n\t\t\tToken2:           $2,\n\t\t\tIdentifierList:   $3.(*IdentifierList).reverse(),\n\t\t\tToken3:           $4,\n\t\t\tToken4:           $5,\n\t\t\tReplacementList:  $6,\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableDefineOmitCommaBeforeDDD {\n\t\t\tlx.report.ErrTok(lhs.Token4, \"missing comma before \\\"...\\\"\")\n\t\t}\n\t}\n|\tPPDEFINE '\\n'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ControlLine{\n\t\t\tCase:    11,\n\t\t\tToken:   $1,\n\t\t\tToken2:  $2,\n\t\t}\n\t\t$$ = lhs\n\t\tif !lx.tweaks.enableEmptyDefine {\n\t\t\tlx.report.ErrTok(lhs.Token2, \"expected identifier\")\n\t\t}\n\t}\n|\tPPUNDEF IDENTIFIER PPTokenList '\\n'\n\t{\n\t\tlx := yylex.(*lexer)\n\t\tlhs := &ControlLine{\n\t\t\tCase:         12,\n\t\t\tToken:        $1,\n\t\t\tToken2:       $2,\n\t\t\tPPTokenList:  $3,\n\t\t\tToken3:       $4,\n\t\t}\n\t\t$$ = lhs\n\t\ttoks := decodeTokens(lhs.PPTokenList, nil, false)\n\t\tif len(toks) == 0 {\n\t\t\tlhs.Case = 9 // PPUNDEF IDENTIFIER '\\n' \n\t\t\tbreak\n\t\t}\n\n\t\tlx.report.ErrTok(toks[0], \"extra tokens after #undef argument\")\n\t}\n|\tPPINCLUDE_NEXT PPTokenList '\\n'\n\t{\n\t\t$$ = &ControlLine{\n\t\t\tCase:         13,\n\t\t\tToken:        $1,\n\t\t\tPPTokenList:  $2,\n\t\t\tToken2:       $3,\n\t\t}\n\t}\n\nTextLine:\n\tPPTokenListOpt\n\t{\n\t}\n\nReplacementList:\n\tPPTokenListOpt\n\t{\n\t}\n\nPPTokenList:\n\tPPTokens\n\t{\n\t\tlx := yylex.(*lexer)\n\t\t$$ = PPTokenList(dict.ID(lx.encBuf))\n\t\tlx.encBuf = lx.encBuf[:0]\n\t\tlx.encPos = 0\n\t}\n\nPPTokenListOpt:\n\t'\\n'\n\t{\n\t\t$$ = 0\n\t}\n|\tPPTokenList '\\n'\n\t{\n\t}\n\nPPTokens:\n\tPPOTHER\n\t{\n\t}\n|\tPPTokens PPOTHER\n\t{\n\t}\n"
  },
  {
    "path": "parser.yy",
    "content": "%{\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.10. Substantial portions of expression AST size\n// optimizations are from [2], license of which follows.\n\n// ----------------------------------------------------------------------------\n\n// Copyright 2013 The Go Authors.  All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// This grammar is derived from the C grammar in the 'ansitize'\n// program, which carried this notice:\n// \n// Copyright (c) 2006 Russ Cox, \n// \tMassachusetts Institute of Technology\n// \n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall\n// be included in all copies or substantial portions of the\n// Software.\n// \n// The software is provided \"as is\", without warranty of any\n// kind, express or implied, including but not limited to the\n// warranties of merchantability, fitness for a particular\n// purpose and noninfringement.  In no event shall the authors\n// or copyright holders be liable for any claim, damages or\n// other liability, whether in an action of contract, tort or\n// otherwise, arising from, out of or in connection with the\n// software or the use or other dealings in the software.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cznic/xc\"\n\t\"github.com/cznic/golex/lex\"\n)\n%}\n\n%union {\n\tToken\t\t\txc.Token\n\tgroupPart\t\tNode\n\tnode\t\t\tNode\n\ttoks\t\t\tPPTokenList\n}\n\n%token\n\t/*yy:token \"'%c'\"            */ CHARCONST\t\t\"character constant\"\n\t/*yy:token \"1.%d\"            */ FLOATCONST\t\t\"floating-point constant\"\n\t/*yy:token \"%c\"              */ IDENTIFIER\t\t\"identifier\"\n\t/*yy:token \"%c\"              */ IDENTIFIER_NONREPL\t\"non replaceable identifier\"\n\t/*yy:token \"%c(\"             */ IDENTIFIER_LPAREN\t\"identifier immediatelly followed by '('\"\n\t/*yy:token \"%d\"              */ INTCONST\t\t\"integer constant\"\n\t/*yy:token \"L'%c'\"           */ LONGCHARCONST\t\t\"long character constant\"\n\t/*yy:token \"L\\\"%c\\\"\"         */ LONGSTRINGLITERAL\t\"long string constant\"\n\t/*yy:token \"<%c.h>\"          */ PPHEADER_NAME\t\t\"header name\"\n\t/*yy:token \"%d\"              */ PPNUMBER\t\t\"preprocessing number\"\n\t/*yy:token \"\\\"%c\\\"\"          */ STRINGLITERAL\t\t\"string literal\"\n\n\t/*yy:token \"\\U00100000\"      */\tPREPROCESSING_FILE\t1048576\t\"preprocessing file prefix\"\t// 0x100000 = 1048576\n\t/*yy:token \"\\U00100001\"      */\tCONSTANT_EXPRESSION\t1048577\t\"constant expression prefix\"\n\t/*yy:token \"\\U00100002\"      */\tTRANSLATION_UNIT\t1048578\t\"translation unit prefix\"\n\n\t/*yy:token \"\\n#define\"       */\tPPDEFINE\t\t\"#define\"\n\t/*yy:token \"\\n#elif\"         */\tPPELIF\t\t\t\"#elif\"\n\t/*yy:token \"\\n#else\"         */\tPPELSE\t\t\t\"#else\"\n\t/*yy:token \"\\n#endif\"        */\tPPENDIF\t\t\t\"#endif\"\n\t/*yy:token \"\\n#error\"        */\tPPERROR\t\t\t\"#error\"\n\t/*yy:token \"\\n#\"             */\tPPHASH_NL\t\t\"#\"\n\t/*yy:token \"\\n#if\"           */\tPPIF\t\t\t\"#if\"\n\t/*yy:token \"\\n#ifdef\"        */\tPPIFDEF\t\t\t\"#ifdef\"\n\t/*yy:token \"\\n#ifndef\"       */\tPPIFNDEF\t\t\"#ifndef\"\n\t/*yy:token \"\\n#include\"      */\tPPINCLUDE\t\t\"#include\"\n\t/*yy:token \"\\n#include_next\" */\tPPINCLUDE_NEXT\t\t\"#include_next\"\n\t/*yy:token \"\\n#line\"         */\tPPLINE\t\t\t\"#line\"\n\t/*yy:token \"\\n#foo\"          */\tPPNONDIRECTIVE\t\t\"#foo\"\n\t/*yy:token \"other_%c\"        */ PPOTHER\t\t\t\"ppother\"\n\t/*yy:token \"\\n##\"            */\tPPPASTE\t\t\t\"##\"\n\t/*yy:token \"\\n#pragma\"       */\tPPPRAGMA\t\t\"#pragma\"\n\t/*yy:token \"\\n#undef\"        */\tPPUNDEF\t\t\t\"#undef\"\n\n\tADDASSIGN\t\t\t\"+=\"\n\tALIGNOF\t\t\t\t\"_Alignof\"\n\tANDAND\t\t\t\t\"&&\"\n\tANDASSIGN\t\t\t\"&=\"\n\tARROW\t\t\t\t\"->\"\n\tASM\t\t\t\t\"asm\"\n\tAUTO\t\t\t\t\"auto\"\n\tBOOL\t\t\t\t\"_Bool\"\n\tBREAK\t\t\t\t\"break\"\n\tCASE\t\t\t\t\"case\"\n\tCHAR\t\t\t\t\"char\"\n\tCOMPLEX\t\t\t\t\"_Complex\"\n\tCONST\t\t\t\t\"const\"\n\tCONTINUE\t\t\t\"continue\"\n\tDDD\t\t\t\t\"...\"\n\tDEC\t\t\t\t\"--\"\n\tDEFAULT\t\t\t\t\"default\"\n\tDIVASSIGN\t\t\t\"/=\"\n\tDO\t\t\t\t\"do\"\n\tDOUBLE\t\t\t\t\"double\"\n\tELSE\t\t\t\t\"else\"\n\tENUM\t\t\t\t\"enum\"\n\tEQ\t\t\t\t\"==\"\n\tEXTERN\t\t\t\t\"extern\"\n\tFLOAT\t\t\t\t\"float\"\n\tFOR\t\t\t\t\"for\"\n\tGEQ\t\t\t\t\">=\"\n\tGOTO\t\t\t\t\"goto\"\n\tIF\t\t\t\t\"if\"\n\tINC\t\t\t\t\"++\"\n\tINLINE\t\t\t\t\"inline\"\n\tINT\t\t\t\t\"int\"\n\tLEQ\t\t\t\t\"<=\"\n\tLONG\t\t\t\t\"long\"\n\tLSH\t\t\t\t\"<<\"\n\tLSHASSIGN\t\t\t\"<<=\"\n\tMODASSIGN\t\t\t\"%=\"\n\tMULASSIGN\t\t\t\"*=\"\n\tNEQ\t\t\t\t\"!=\"\n\tNORETURN\t\t\t\"_Noreturn\"\n\tORASSIGN\t\t\t\"|=\"\n\tOROR\t\t\t\t\"||\"\n\tREGISTER\t\t\t\"register\"\n\tRESTRICT\t\t\t\"restrict\"\n\tRETURN\t\t\t\t\"return\"\n\tRSH\t\t\t\t\">>\"\n\tRSHASSIGN\t\t\t\">>=\"\n\tSHORT\t\t\t\t\"short\"\n\tSIGNED\t\t\t\t\"signed\"\n\tSIZEOF\t\t\t\t\"sizeof\"\n\tSTATIC\t\t\t\t\"static\"\n\tSTATIC_ASSERT\t\t\t\"_Static_assert\"\n\tSTRUCT\t\t\t\t\"struct\"\n\tSUBASSIGN\t\t\t\"-=\"\n\tSWITCH\t\t\t\t\"switch\"\n\tTYPEDEF\t\t\t\t\"typedef\"\n\tTYPEDEFNAME\t\t\t\"typedefname\"\n\tTYPEOF\t\t\t\t\"typeof\"\n\tUNION\t\t\t\t\"union\"\n\tUNSIGNED\t\t\t\"unsigned\"\n\tVOID\t\t\t\t\"void\"\n\tVOLATILE\t\t\t\"volatile\"\n\tWHILE\t\t\t\t\"while\"\n\tXORASSIGN\t\t\t\"^=\"\n\n%type\t<toks>\n\tPPTokenList\t\t\t\"token list\"\n\tPPTokenListOpt\t\t\t\"optional token list\"\n\tReplacementList\t\t\t\"replacement list\"\n\tTextLine\t\t\t\"text line\"\n\n%type\t<groupPart>\n\tGroupPart\t\t\t\"group part\"\n\n%type\t<node>\n\tAbstractDeclarator\t\t\"abstract declarator\"\n\tAbstractDeclaratorOpt\t\t\"optional abstract declarator\"\n\tArgumentExpressionList\t\t\"argument expression list\"\n\tArgumentExpressionListOpt\t\"optional argument expression list\"\n\tAssemblerInstructions\t\t\"assembler instructions\"\n\tAssemblerOperand\t\t\"assembler operand\"\n\tAssemblerOperands\t\t\"assembler operands\"\n\tAssemblerStatement\t\t\"assembler statement\"\n\tAssemblerSymbolicNameOpt\t\"optional assembler symbolic name\"\n\tBasicAssemblerStatement\t\t\"basic assembler statement\"\n\tBlockItem\t\t\t\"block item\"\n\tBlockItemList\t\t\t\"block item list\"\n\tBlockItemListOpt\t\t\"optional block item list\"\n\tClobbers\t\t\t\"clobbers\"\n\tCommaOpt\t\t\t\"optional comma\"\n\tCompoundStatement\t\t\"compound statement\"\n\tConstantExpression\t\t\"constant expression\"\n\tControlLine\t\t\t\"control line\"\n\tDeclaration\t\t\t\"declaration\"\n\tDeclarationList\t\t\t\"declaration list\"\n\tDeclarationListOpt\t\t\"optional declaration list\"\n\tDeclarationSpecifiers\t\t\"declaration specifiers\"\n\tDeclarationSpecifiersOpt\t\"optional declaration specifiers\"\n\tDeclarator\t\t\t\"declarator\"\n\tDeclaratorOpt\t\t\t\"optional declarator\"\n\tDesignation\t\t\t\"designation\"\n\tDesignationOpt\t\t\t\"optional designation\"\n\tDesignator\t\t\t\"designator\"\n\tDesignatorList\t\t\t\"designator list\"\n\tDirectAbstractDeclarator\t\"direct abstract declarator\"\n\tDirectAbstractDeclaratorOpt\t\"optional direct abstract declarator\"\n\tDirectDeclarator\t\t\"direct declarator\"\n\tElifGroup\t\t\t\"elif group\"\n\tElifGroupList\t\t\t\"elif group list\"\n\tElifGroupListOpt\t\t\"optional elif group list\"\n\tElseGroup\t\t\t\"else group\"\n\tElseGroupOpt\t\t\t\"optional else group\"\n\tEndifLine\t\t\t\"endif line\"\n\tEnumSpecifier\t\t\t\"enum specifier\"\n\tEnumerationConstant\t\t\"enumearation constant\"\n\tEnumerator\t\t\t\"enumerator\"\n\tEnumeratorList\t\t\t\"enumerator list\"\n\tExpression\t\t\t\"expression\"\n\tExpressionList\t\t\t\"expression list\"\n\tExpressionListOpt\t\t\"optional expression list\"\n\tExpressionOpt\t\t\t\"optional expression\"\n\tExpressionStatement\t\t\"expression statement\"\n\tExternalDeclaration\t\t\"external declaration\"\n\tFunctionDefinition\t\t\"function definition\"\n\tFunctionBody\t\t\t\"function body\"\n\tFunctionSpecifier\t\t\"function specifier\"\n\tGroupList\t\t\t\"group list\"\n\tGroupListOpt\t\t\t\"optional group list\"\n\tIdentifierList\t\t\t\"identifier list\"\n\tIdentifierListOpt\t\t\"optional identifier list\"\n\tIdentifierOpt\t\t\t\"optional identifier\"\n\tIfGroup\t\t\t\t\"if group\"\n\tIfSection\t\t\t\"if section\"\n\tInitDeclarator\t\t\t\"init declarator\"\n\tInitDeclaratorList\t\t\"init declarator list\"\n\tInitDeclaratorListOpt\t\t\"optional init declarator list\"\n\tInitializer\t\t\t\"initializer\"\n\tInitializerList\t\t\t\"initializer list\"\n\tIterationStatement\t\t\"iteration statement\"\n\tJumpStatement\t\t\t\"jump statement\"\n\tLabeledStatement\t\t\"labeled statement\"\n\tParameterDeclaration\t\t\"parameter declaration\"\n\tParameterList\t\t\t\"parameter list\"\n\tParameterTypeList\t\t\"parameter type list\"\n\tParameterTypeListOpt\t\t\"optional parameter type list\"\n\tPointer\t\t\t\t\"pointer\"\n\tPointerOpt\t\t\t\"optional pointer\"\n\tPreprocessingFile\t\t\"preprocessing file\"\n\tSelectionStatement\t\t\"selection statement\"\n\tSpecifierQualifierList\t\t\"specifier qualifier list\"\n\tSpecifierQualifierListOpt\t\"optional specifier qualifier list\"\n\tStatement\t\t\t\"statement\"\n\tStaticAssertDeclaration\t\t\"static assert declaration\"\n\tStorageClassSpecifier\t\t\"storage class specifier\"\n\tStructDeclaration\t\t\"struct declaration\"\n\tStructDeclarationList\t\t\"struct declaration list\"\n\tStructDeclarator\t\t\"struct declarator\"\n\tStructDeclaratorList\t\t\"struct declarator list\"\n\tStructOrUnion\t\t\t\"struct-or-union\"\n\tStructOrUnionSpecifier\t\t\"struct-or-union specifier\"\n\tTranslationUnit\t\t\t\"translation unit\"\n\tTypeName\t\t\t\"type name\"\n\tTypeQualifier\t\t\t\"type qualifier\"\n\tTypeQualifierList\t\t\"type qualifier list\"\n\tTypeQualifierListOpt\t\t\"optional type qualifier list\"\n\tTypeSpecifier\t\t\t\"type specifier\"\n\tVolatileOpt\t\t\t\"optional volatile\"\n\n\n%precedence\tNOSEMI\n%precedence\t';'\n\n%precedence\tNOELSE\n%precedence\tELSE\n\n%right\t\t'=' ADDASSIGN ANDASSIGN DIVASSIGN LSHASSIGN MODASSIGN MULASSIGN\n\t\tORASSIGN RSHASSIGN SUBASSIGN XORASSIGN\n\t\t\n%right\t\t':' '?'\n%left\t\tOROR\n%left\t\tANDAND\n%left\t\t'|'\n%left\t\t'^'\n%left\t\t'&'\n%left\t\tEQ NEQ\n%left\t\t'<' '>' GEQ LEQ\n%left\t\tLSH RSH\n%left\t\t'+' '-' \n%left\t\t'%' '*' '/'\n%precedence\tCAST\n%left\t\t'!' '~' SIZEOF UNARY\n%right\t\t'(' '.' '[' ARROW DEC INC\n\n%%\n\n//yy:ignore\nStart:\n\tPREPROCESSING_FILE\n\t{\n\t\tlx.preprocessingFile = nil\n\t}\n\tPreprocessingFile\n\t{\n\t\tlx.preprocessingFile = $3.(*PreprocessingFile)\n\t}\n|\tCONSTANT_EXPRESSION\n\t{\n\t\tlx.constantExpression = nil\n\t}\n\tConstantExpression\n\t{\n\t\tlx.constantExpression = $3.(*ConstantExpression)\n\t}\n|\tTRANSLATION_UNIT\n\t{\n\t\tlx.translationUnit = nil\n\t}\n\tTranslationUnit\n\t{\n\t\tif lx.report.Errors(false) == nil && lx.scope.kind != ScopeFile {\n\t\t\tpanic(\"internal error\")\n\t\t}\n\n\t\tlx.translationUnit = $3.(*TranslationUnit).reverse()\n\t\tlx.translationUnit.Declarations = lx.scope\n\t}\n\n// [0](6.4.4.3)\nEnumerationConstant:\n\tIDENTIFIER\n\n// [0](6.5.2)\nArgumentExpressionList:\n\tExpression\n|\tArgumentExpressionList ',' Expression\n\nArgumentExpressionListOpt:\n\t/* empty */ {}\n|\tArgumentExpressionList\n\n// [0](6.5.16)\n//yy:field\tBinOpType\tType\t\t// The type operands of binary expression are coerced into, if different from Type.\n//yy:field\tType\t\tType\t\t// Type of expression.\n//yy:field\tValue\t\tinterface{}\t// Non nil for certain constant expressions.\n//yy:field\tscope\t\t*Bindings\t// Case 0: IDENTIFIER resolution scope.\nExpression:\n\tIDENTIFIER %prec NOSEMI\n\t{\n\t\tlhs.scope = lx.scope\n\t}\n|\tCHARCONST\n|\tFLOATCONST\n|\tINTCONST\n|\tLONGCHARCONST\n|\tLONGSTRINGLITERAL\n|\tSTRINGLITERAL\n|\t'(' ExpressionList ')'\n|\tExpression '[' ExpressionList ']'\n|\tExpression '(' ArgumentExpressionListOpt ')'\n\t{\n\t\to := lhs.ArgumentExpressionListOpt\n\t\tif o == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tif lhs.Expression.Case == 0 { // IDENTIFIER\n\t\t\tif lx.tweaks.enableBuiltinConstantP &&lhs.Expression.Token.Val == idBuiltinConstantP {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tb := lhs.Expression.scope.Lookup(NSIdentifiers, lhs.Expression.Token.Val)\n\t\t\tif b.Node == nil && lx.tweaks.enableImplicitFuncDef {\n\t\t\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\t\t\tl.Expression.eval(lx)\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tlhs.Expression.eval(lx)\n\t\tfor l := o.ArgumentExpressionList; l != nil; l = l.ArgumentExpressionList {\n\t\t\tl.Expression.eval(lx)\n\t\t}\n\t}\n|\tExpression '.' IDENTIFIER\n|\tExpression \"->\" IDENTIFIER\n|\tExpression \"++\"\n|\tExpression \"--\"\n|\t'(' TypeName ')' '{' InitializerList CommaOpt '}'\n|\t\"++\" Expression\n|\t\"--\" Expression\n|\t'&' Expression %prec UNARY\n|\t'*' Expression %prec UNARY\n|\t'+' Expression %prec UNARY\n|\t'-' Expression %prec UNARY\n|\t'~' Expression\n|\t'!' Expression\n|\t\"sizeof\" Expression\n|\t\"sizeof\" '(' TypeName ')' %prec SIZEOF\n|\t'(' TypeName ')' Expression %prec CAST\n|\tExpression '*' Expression\n|\tExpression '/' Expression\n|\tExpression '%' Expression\n|\tExpression '+' Expression\n|\tExpression '-' Expression\n|\tExpression \"<<\" Expression\n|\tExpression \">>\" Expression\n|\tExpression '<' Expression\n|\tExpression '>' Expression\n|\tExpression \"<=\" Expression\n|\tExpression \">=\" Expression\n|\tExpression \"==\" Expression\n|\tExpression \"!=\" Expression\n|\tExpression '&' Expression\n|\tExpression '^' Expression\n|\tExpression '|' Expression\n|\tExpression \"&&\" Expression\n|\tExpression \"||\" Expression\n|\tExpression '?' ExpressionList ':' Expression\n|\tExpression '=' Expression\n|\tExpression \"*=\" Expression\n|\tExpression \"/=\" Expression\n|\tExpression \"%=\" Expression\n|\tExpression \"+=\" Expression\n|\tExpression \"-=\" Expression\n|\tExpression \"<<=\" Expression\n|\tExpression \">>=\" Expression\n|\tExpression \"&=\" Expression\n|\tExpression \"^=\" Expression\n|\tExpression \"|=\" Expression\n|\t\"_Alignof\" '(' TypeName ')'\n|\t'(' CompoundStatement ')'\n|\t\"&&\" IDENTIFIER\n\t{\n\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t}\n\t}\n|\tExpression '?' ':' Expression\n\t{\n\t\tif !lx.tweaks.enableOmitConditionalOperand {\n\t\t\tlx.report.Err(lhs.Pos(), \"omitting conditional operand not enabled\")\n\t\t}\n\t}\n\n\nExpressionOpt:\n\t/* empty */ {}\n|\tExpression\n\t{\n\t\tlhs.Expression.eval(lx)\n\t}\n\n// [0](6.5.17)\n//yy:field\tType\tType\t\t// Type of expression.\n//yy:field\tValue\tinterface{}\t// Non nil for certain constant expressions.\n//yy:list\nExpressionList:\n\tExpression\n|\tExpressionList ',' Expression\n\nExpressionListOpt:\n\t/* empty */ {}\n|\tExpressionList\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n\n// [0](6.6)\n//yy:field\tType\tType\t\t// Type of expression.\n//yy:field\tValue\tinterface{}\t// Non nil for certain constant expressions.\n//yy:field\ttoks\t[]xc.Token\t//\nConstantExpression:\n\t{\n\t\tlx.constExprToks = []xc.Token{lx.last}\n\t}\n\tExpression\n\t{\n\t\tlhs.Value, lhs.Type = lhs.Expression.eval(lx)\n\t\tif lhs.Value == nil {\n\t\t\tlx.report.Err(lhs.Pos(), \"not a constant expression\")\n\t\t}\n\t\tl := lx.constExprToks\n\t\tlhs.toks = l[:len(l)-1]\n\t\tlx.constExprToks = nil\n\t}\n\n// [0](6.7)\n//yy:field\tdeclarator\t*Declarator\t// Synthetic declarator when InitDeclaratorListOpt is nil.\nDeclaration:\n\tDeclarationSpecifiers InitDeclaratorListOpt ';'\n\t{\n\t\tts0 := lhs.DeclarationSpecifiers.typeSpecifiers()\n\t\tif ts0 == 0 && lx.tweaks.enableImplicitIntType {\n\t\t\tlhs.DeclarationSpecifiers.typeSpecifier = tsEncode(tsInt)\n\t\t}\n\t\tts := tsDecode(lhs.DeclarationSpecifiers.typeSpecifiers())\n\t\tok := false\n\t\tfor _, v := range ts {\n\t\t\tif v == tsStructSpecifier || v == tsUnionSpecifier {\n\t\t\t\tok = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif ok {\n\t\t\ts := lhs.DeclarationSpecifiers\n\t\t\td := &Declarator{specifier: s}\n\t\t\tdd := &DirectDeclarator{\n\t\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\t\tdeclarator: d,\n\t\t\t\tidScope: lx.scope,\n\t\t\t\tspecifier: s,\n\t\t\t}\n\t\t\td.DirectDeclarator = dd\n\t\t\td.setFull(lx)\n\t\t\tfor l := lhs.DeclarationSpecifiers; l != nil; {\n\t\t\t\tts := l.TypeSpecifier\n\t\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif o := l.DeclarationSpecifiersOpt; o != nil {\n\t\t\t\t\tl = o.DeclarationSpecifiers\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\to := lhs.InitDeclaratorListOpt\n\t\tif o != nil {\n\t\t\tbreak\n\t\t}\n\n\t\ts := lhs.DeclarationSpecifiers\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\t\tlhs.declarator = d\n\t}\n|\tStaticAssertDeclaration\n\n// [0](6.7)\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\n//yy:field\ttypeSpecifier\tint\t// Encoded combination of tsVoid, tsInt, ...\nDeclarationSpecifiers:\n\tStorageClassSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.StorageClassSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.StorageClassSpecifier.Case != 0 /* \"typedef\" */ && lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid storage class specifier\")\n\t\t}\n\t}\n|\tTypeSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = b.attr\n\t\ttsb := tsDecode(b.typeSpecifier)\n\t\tif len(tsb) == 1 && tsb[0] == tsTypedefName && lx.tweaks.allowCompatibleTypedefRedefinitions {\n\t\t\ttsb[0] = 0\n\t\t}\n\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsb...)...)\n\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\tts = tsEncode(tsInt)\n\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t}\n\t\tlhs.typeSpecifier = ts\n\t}\n|\tTypeQualifier DeclarationSpecifiersOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeQualifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t}\n\t}\n|\tFunctionSpecifier DeclarationSpecifiersOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.FunctionSpecifier\n\t\tb := lhs.DeclarationSpecifiersOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t\tif lhs.IsTypedef() {\n\t\t\tlx.report.Err(a.Pos(), \"invalid function specifier\")\n\t\t}\n\t}\n\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\n//yy:field\ttypeSpecifier\tint\t// Encoded combination of tsVoid, tsInt, ...\nDeclarationSpecifiersOpt:\n\t/* empty */ {}\n|\tDeclarationSpecifiers\n\t{\n\t\tlhs.attr = lhs.DeclarationSpecifiers.attr\n\t\tlhs.typeSpecifier = lhs.DeclarationSpecifiers.typeSpecifier\n\t}\n\n// [0](6.7)\nInitDeclaratorList:\n\tInitDeclarator\n|\tInitDeclaratorList ',' InitDeclarator\n\nInitDeclaratorListOpt:\n\t/* empty */ {}\n|\tInitDeclaratorList\n\n// [0](6.7)\nInitDeclarator:\n\tDeclarator\n\t{\n\t\tlhs.Declarator.setFull(lx)\n\t}\n|\tDeclarator\n\t{\n\t\td := $1.(*Declarator)\n\t\td.setFull(lx)\n\t}\n\t'=' Initializer\n\t{\n\t\td := lhs.Declarator\n\t\tlhs.Initializer.typeCheck(&d.Type, d.Type, lhs.Declarator.specifier.IsStatic(), lx)\n\t\tif d.Type.Specifier().IsExtern() {\n\t\t\tid, _ := d.Identifier()\n\t\t\tlx.report.Err(d.Pos(), \"'%s' initialized and declared 'extern'\", dict.S(id))\n\t\t}\n\t}\n\n// [0](6.7.1)\n//yy:field\tattr\tint\nStorageClassSpecifier:\n\t\"typedef\"\n\t{\n\t\tlhs.attr = saTypedef\n\t}\n|\t\"extern\"\n\t{\n\t\tlhs.attr = saExtern\n\t}\n|\t\"static\"\n\t{\n\t\tlhs.attr = saStatic\n\t}\n|\t\"auto\"\n\t{\n\t\tlhs.attr = saAuto\n\t}\n|\t\"register\"\n\t{\n\t\tlhs.attr = saRegister\n\t}\n\n// [0](6.7.2)\n//yy:field\tscope\t\t*Bindings\t// If case TYPEDEFNAME.\n//yy:field\ttypeSpecifier\tint\t\t// Encoded combination of tsVoid, tsInt, ...\n//yy:field\tType\t\tType\t\t// Type of typeof.\nTypeSpecifier:\n\t\"void\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsVoid)\n\t}\n|\t\"char\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsChar)\n\t}\n|\t\"short\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsShort)\n\t}\n|\t\"int\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsInt)\n\t}\n|\t\"long\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsLong)\n\t}\n|\t\"float\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsFloat)\n\t}\n|\t\"double\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsDouble)\n\t}\n|\t\"signed\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsSigned)\n\t}\n|\t\"unsigned\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsUnsigned)\n\t}\n|\t\"_Bool\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsBool)\n\t}\n|\t\"_Complex\"\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsComplex)\n\t}\n|\tStructOrUnionSpecifier\n\t{\n\t\tlhs.typeSpecifier = tsEncode(lhs.StructOrUnionSpecifier.typeSpecifiers())\n\t}\n|\tEnumSpecifier\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsEnumSpecifier)\n\t}\n/*yy:example \"\\U00100002 typedef int i; i j;\" */\n|\tTYPEDEFNAME\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsTypedefName)\n\t\t_, lhs.scope = lx.scope.Lookup2(NSIdentifiers, lhs.Token.Val)\n\t}\n|\t\"typeof\" '(' Expression ')'\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\t_, lhs.Type = lhs.Expression.eval(lx)\n\t}\n|\t\"typeof\" '(' TypeName ')'\n\t{\n\t\tlhs.typeSpecifier = tsEncode(tsTypeof)\n\t\tlhs.Type = undefined\n\t\tif t := lhs.TypeName.Type; t != nil {\n\t\t\tlhs.Type = t\n\t\t}\n\t}\n\n// [0](6.7.2.1)\n//yy:example\t\"\\U00100002 struct { int i; } (\"\n//yy:field\talignOf\tint\n//yy:field\tdeclarator\t*Declarator\t// Synthetic declarator when tagged struct/union defined inline.\n//yy:field\tscope\t\t*Bindings\n//yy:field\tsizeOf\t\tint\nStructOrUnionSpecifier:\n\tStructOrUnion IdentifierOpt\n\t'{'\n\t{\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t}\n\t\tlx.pushScope(ScopeMembers)\n\t\tlx.scope.isUnion = $1.(*StructOrUnion).Case == 1 // \"union\"\n\t\tlx.scope.prevStructDeclarator = nil\n\t}\n\tStructDeclarationList '}'\n\t{\n\t\tsc := lx.scope\n\t\tlhs.scope = sc\n\t\tif sc.bitOffset != 0 {\n\t\t\tfinishBitField(lhs, lx)\n\t\t}\n\n\t\ti := 0\n\t\tvar bt Type\n\t\tvar d *Declarator\n\t\tfor l := lhs.StructDeclarationList; l != nil; l = l.StructDeclarationList {\n\t\t\tfor l := l.StructDeclaration.StructDeclaratorList; l != nil; l = l.StructDeclaratorList {\n\t\t\t\tswitch sd := l.StructDeclarator; sd.Case {\n\t\t\t\tcase 0: // Declarator\n\t\t\t\t\td = sd.Declarator\n\t\t\t\tcase 1: // DeclaratorOpt ':' ConstantExpression\n\t\t\t\t\tif o := sd.DeclaratorOpt; o != nil {\n\t\t\t\t\t\tx := o.Declarator\n\t\t\t\t\t\tif x.bitOffset == 0  {\n\t\t\t\t\t\t\td = x\n\t\t\t\t\t\t\tbt = lx.scope.bitFieldTypes[i]\n\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t}\n\t\t\t\t\t\tx.bitFieldType = bt\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlx.scope.bitFieldTypes = nil\n\n\t\tlhs.alignOf = sc.maxAlign\n\t\tswitch {\n\t\tcase sc.isUnion:\n\t\t\tlhs.sizeOf = align(sc.maxSize, sc.maxAlign)\n\t\tdefault:\n\t\t\toff := sc.offset\n\t\t\tlhs.sizeOf = align(sc.offset, sc.maxAlign)\n\t\t\tif d != nil {\n\t\t\t\td.padding = lhs.sizeOf-off\n\t\t\t}\n\t\t}\n\n\t\tlx.popScope(lhs.Token2)\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t}\n\t}\n|\tStructOrUnion IDENTIFIER\n\t{\n\t\tlx.scope.declareStructTag(lhs.Token, lx.report)\n\t\tlhs.scope = lx.scope\n\t}\n|\tStructOrUnion IdentifierOpt '{' '}'\n\t{\n\t\tif !lx.tweaks.enableEmptyStructs {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"empty structs/unions not allowed\")\n\t\t}\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareStructTag(o.Token, lx.report)\n\t\t}\n\t\tlx.scope.isUnion = $1.(*StructOrUnion).Case == 1 // \"union\"\n\t\tlx.scope.prevStructDeclarator = nil\n\t\tlhs.alignOf = 1\n\t\tlhs.sizeOf = 0\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineStructTag(o.Token, lhs, lx.report)\n\t\t}\n\t}\n\n// [0](6.7.2.1)\nStructOrUnion:\n\t\"struct\"\n|\t\"union\"\n\n// [0](6.7.2.1)\nStructDeclarationList:\n\tStructDeclaration\n|\tStructDeclarationList StructDeclaration\n\n// [0](6.7.2.1)\nStructDeclaration:\n\tSpecifierQualifierList StructDeclaratorList ';'\n\t{\n\t\ts := lhs.SpecifierQualifierList\n\t\tif k := s.kind(); k != Struct && k != Union {\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\tts := l.TypeSpecifier\n\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\t}\n|\tSpecifierQualifierList ';'\n\t{\n\t\ts := lhs.SpecifierQualifierList\n\t\tif !lx.tweaks.enableAnonymousStructFields {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"unnamed fields not allowed\")\n\t\t} else if k := s.kind(); k != Struct && k != Union {\n\t\t\tlx.report.Err(lhs.Token.Pos(), \"only unnamed structs and unions are allowed\")\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{specifier: s}\n\t\tdd := &DirectDeclarator{\n\t\t\tToken: xc.Token{Char: lex.NewChar(lhs.Pos(), 0)},\n\t\t\tdeclarator: d,\n\t\t\tidScope: lx.scope,\n\t\t\tspecifier: s,\n\t\t}\n\t\td.DirectDeclarator = dd\n\t\td.setFull(lx)\n\n\t\t// we have no struct declarators to parse, so we have to create the case of one implicit declarator\n\t\t// because else the size of anonymous members is not included in the struct size!\n\t\tdummy := &StructDeclarator{Declarator: d}\n\t\tdummy.post(lx)\n\n\t\tfor l := lhs.SpecifierQualifierList; l != nil; {\n\t\t\tts := l.TypeSpecifier\n\t\t\tif ts != nil && ts.Case == 11 && ts.StructOrUnionSpecifier.Case == 0 { // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\t\t\tts.StructOrUnionSpecifier.declarator = d\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif o := l.SpecifierQualifierListOpt; o != nil {\n\t\t\t\tl = o.SpecifierQualifierList\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tbreak\n\t\t}\n\t}\n|\tStaticAssertDeclaration\n\n// [0](6.7.2.1)\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\n//yy:field\ttypeSpecifier\tint\t// Encoded combination of tsVoid, tsInt, ...\nSpecifierQualifierList:\n\tTypeSpecifier SpecifierQualifierListOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeSpecifier\n\t\tb := lhs.SpecifierQualifierListOpt\n\t\tif b == nil {\n\t\t\tlhs.typeSpecifier = a.typeSpecifier\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = b.attr\n\t\tts := tsEncode(append(tsDecode(a.typeSpecifier), tsDecode(b.typeSpecifier)...)...)\n\t\tif _, ok := tsValid[ts]; !ok {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type specifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.typeSpecifier = ts\n\t}\n|\tTypeQualifier SpecifierQualifierListOpt\n\t{\n\t\tlx.scope.specifier = lhs\n\t\ta := lhs.TypeQualifier\n\t\tb := lhs.SpecifierQualifierListOpt\n\t\tif b == nil {\n\t\t\tlhs.attr = a.attr\n\t\t\tbreak\n\t\t}\n\t\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(a.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t\tlhs.typeSpecifier = b.typeSpecifier\n\t}\n\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\n//yy:field\ttypeSpecifier\tint\t// Encoded combination of tsVoid, tsInt, ...\nSpecifierQualifierListOpt:\n\t/* empty */ {}\n|\tSpecifierQualifierList\n\t{\n\t\tlhs.attr = lhs.SpecifierQualifierList.attr\n\t\tlhs.typeSpecifier = lhs.SpecifierQualifierList.typeSpecifier\n\t}\n\n// [0](6.7.2.1)\nStructDeclaratorList:\n\tStructDeclarator\n|\tStructDeclaratorList ',' StructDeclarator\n\n// [0](6.7.2.1)\nStructDeclarator:\n\tDeclarator\n\t{\n\t\tlhs.Declarator.setFull(lx)\n\t\tlhs.post(lx)\n\t}\n|\tDeclaratorOpt ':' ConstantExpression\n\t{\n\t\tm := lx.model\n\t\te := lhs.ConstantExpression\n\t\tif e.Value == nil {\n\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t}\n\t\tif !IsIntType(e.Type) {\n\t\t\tlx.report.Err(e.Pos(), \"bit field width not an integer (have '%s')\", e.Type)\n\t\t\te.Value, e.Type = m.value2(1, m.IntType)\n\t\t}\n\t\tif o := lhs.DeclaratorOpt; o != nil {\n\t\t\to.Declarator.setFull(lx)\n\t\t}\n\t\tlhs.post(lx)\n\t}\n\nCommaOpt:\n\t/* empty */ {}\n|\t','\n\n// [0](6.7.2.2)\n//yy:field\tunsigned\tbool\nEnumSpecifier:\n\t\"enum\" IdentifierOpt\n\t{\n\t\tif o := $2.(*IdentifierOpt); o != nil {\n\t\t\tlx.scope.declareEnumTag(o.Token, lx.report)\n\t\t}\n\t\tlx.iota = 0\n\t}\n\t'{' EnumeratorList  CommaOpt '}'\n\t{\n\t\tif o := lhs.IdentifierOpt; o != nil {\n\t\t\tlx.scope.defineEnumTag(o.Token, lhs, lx.report)\n\t\t}\n\t\tif !lx.tweaks.enableUnsignedEnums {\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.unsigned = true\n\tloop:\n\t\tfor l := lhs.EnumeratorList; l != nil; l = l.EnumeratorList {\n\t\t\tswitch e := l.Enumerator; x := e.Value.(type) {\n\t\t\tcase int32:\n\t\t\t\tif x < 0 {\n\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\tcase int64:\n\t\t\t\tif x < 0 {\n\t\t\t\t\tlhs.unsigned = false\n\t\t\t\t\tbreak loop\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%s: TODO Enumerator.Value type %T\", position(e.Pos()), x))\n\t\t\t}\n\t\t}\n\t}\n|\t\"enum\" IDENTIFIER\n\t{\n\t\tlx.scope.declareEnumTag(lhs.Token2, lx.report)\n\t}\n\n// [0](6.7.2.2)\nEnumeratorList:\n\tEnumerator\n|\tEnumeratorList ',' Enumerator\n\n// [0](6.7.2.2)\n//yy:field\tValue\t\tinterface{}\t// Enumerator's value.\nEnumerator:\n\tEnumerationConstant\n\t{\n\t\tm := lx.model\n\t\tv := m.MustConvert(lx.iota, m.IntType)\n\t\tlhs.Value = v\n\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t}\n|\tEnumerationConstant '=' ConstantExpression\n\t{\n\t\tm := lx.model\n\t\te := lhs.ConstantExpression\n\t\tvar v interface{}\n\t\t// [0], 6.7.2.2\n\t\t// The expression that defines the value of an enumeration\n\t\t// constant shall be an integer constant expression that has a\n\t\t// value representable as an int.\n\t\tswitch {\n\t\tcase !IsIntType(e.Type):\n\t\t\tlx.report.Err(e.Pos(), \"not an integer constant expression (have '%s')\", e.Type)\n\t\t\tv = m.MustConvert(int32(0), m.IntType)\n\t\tdefault:\n\t\t\tvar ok bool\n\t\t\tif v, ok = m.enumValueToInt(e.Value); !ok {\n\t\t\t\tlx.report.Err(e.Pos(), \"overflow in enumeration value: %v\", e.Value)\n\t\t\t}\n\t\t}\n\n\t\tlhs.Value = v\n\t\tlx.scope.defineEnumConst(lx, lhs.EnumerationConstant.Token, v)\n\t}\n\n// [0](6.7.3)\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\nTypeQualifier:\n\t\"const\"\n\t{\n\t\tlhs.attr = saConst\n\t}\n|\t\"restrict\"\n\t{\n\t\tlhs.attr = saRestrict\n\t}\n|\t\"volatile\"\n\t{\n\t\tlhs.attr = saVolatile\n\t}\n\n// [0](6.7.4)\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\nFunctionSpecifier:\n\t\"inline\"\n\t{\n\t\tlhs.attr = saInline\n\t}\n|\t\"_Noreturn\"\n\t{\n\t\tlhs.attr = saNoreturn\n\t}\n\n// [0](6.7.5)\n//yy:field\tLinkage\t\tLinkage\n//yy:field\tType\t\tType\n//yy:field\tbitFieldType\tType\n//yy:field\tbitFieldGroup\tint\n//yy:field\tbitOffset\tint\n//yy:field\tbits\t\tint\n//yy:field\toffsetOf\tint\n//yy:field\tpadding\t\tint\n//yy:field\tspecifier\tSpecifier\nDeclarator:\n\tPointerOpt DirectDeclarator\n\t{\n\t\tlhs.specifier = lx.scope.specifier\n\t\tlhs.DirectDeclarator.declarator = lhs\n\t}\n\nDeclaratorOpt:\n\t/* empty */ {}\n|\tDeclarator\n\n// [0](6.7.5)\n//yy:field\tEnumVal\t\tinterface{}\t// Non nil if DD declares an enumeration constant.\n//yy:field\tdeclarator\t*Declarator\n//yy:field\telements\tint\n//yy:field\tidScope\t\t*Bindings\t// Of case 0: IDENTIFIER.\n//yy:field\tparamsScope\t*Bindings\n//yy:field\tparent\t\t*DirectDeclarator\n//yy:field\tprev\t\t*Binding\t// Existing declaration in same scope, if any.\n//yy:field\tspecifier\tSpecifier\n//yy:field\tvisible\t\t*Binding\t// Existing declaration of same ident visible in same scope, if any and this DD has storage class extrn.\nDirectDeclarator:\n\tIDENTIFIER\n\t{\n\t\tlhs.specifier = lx.scope.specifier\n\t\tlx.scope.declareIdentifier(lhs.Token, lhs, lx.report)\n\t\tlhs.idScope = lx.scope\n\t}\n|\t'(' Declarator ')'\n\t{\n\t\tlhs.Declarator.specifier = nil\n\t\tlhs.Declarator.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t{\n\t\tlhs.elements = -1\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\tvar err error\n\t\t\tif lhs.elements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t{\n\t\tvar err error\n\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t{\n\t\tvar err error\n\t\tif lhs.elements, err = elements(lhs.Expression.eval(lx)); err != nil {\n\t\t\tlx.report.Err(lhs.Expression.Pos(), \"%s\", err)\n\t\t}\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t{\n\t\tlhs.DirectDeclarator.parent = lhs\n\t\tlhs.elements = -1\n\t}\n|\tDirectDeclarator '('\n\t{\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeList ')'\n\t{\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n|\tDirectDeclarator '(' IdentifierListOpt ')'\n\t{\n\t\tlhs.DirectDeclarator.parent = lhs\n\t}\n\n// [0](6.7.5)\nPointer:\n\t'*' TypeQualifierListOpt\n|\t'*' TypeQualifierListOpt Pointer\n\nPointerOpt:\n\t/* empty */ {}\n|\tPointer\n\n// [0](6.7.5)\n//yy:field\tattr\t\tint\t// tsInline, tsTypedefName, ...\nTypeQualifierList:\n\tTypeQualifier\n\t{\n\t\tlhs.attr = lhs.TypeQualifier.attr\n\t}\n|\tTypeQualifierList TypeQualifier\n\t{\n\t\ta := lhs.TypeQualifierList\n\t\tb := lhs.TypeQualifier\n\t\tif a.attr&b.attr != 0 {\n\t\t\tlx.report.Err(b.Pos(), \"invalid type qualifier\")\n\t\t\tbreak\n\t\t}\n\n\t\tlhs.attr = a.attr|b.attr\n\t}\n\nTypeQualifierListOpt:\n\t/* empty */ {}\n|\tTypeQualifierList\n\n// [0](6.7.5)\n//yy:field\tparams\t[]Parameter\nParameterTypeList:\n\tParameterList\n\t{\n\t\tlhs.post()\n\t}\n|\tParameterList ',' \"...\"\n\t{\n\t\tlhs.post()\n\t}\n\nParameterTypeListOpt:\n\t/* empty */ {}\n|\tParameterTypeList\n\n// [0](6.7.5)\nParameterList:\n\tParameterDeclaration\n|\tParameterList ',' ParameterDeclaration\n\n// [0](6.7.5)\n//yy:field\tdeclarator\t*Declarator\n/*TODO\nA declaration of a parameter as ‘‘function returning type’’ shall be adjusted\nto ‘‘pointer to function returning type’’, as in 6.3.2.1.\n*/\nParameterDeclaration:\n\tDeclarationSpecifiers Declarator\n\t{\n\t\tlhs.Declarator.setFull(lx)\n\t\tlhs.declarator = lhs.Declarator\n\t}\n|\tDeclarationSpecifiers AbstractDeclaratorOpt\n\t{\n\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t\tlhs.declarator.setFull(lx)\n\t\t\tbreak\n\t\t}\n\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t},\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t\td.setFull(lx)\n\t}\n\n// [0](6.7.5)\nIdentifierList:\n\tIDENTIFIER\n|\tIdentifierList ',' IDENTIFIER\n\n//yy:field\tparams\t[]Parameter\nIdentifierListOpt:\n\t/* empty */ {}\n|\tIdentifierList\n\nIdentifierOpt:\n\t/* empty */ {}\n|\tIDENTIFIER\n\n// [0](6.7.6)\n//yy:field\tType\t\tType\n//yy:field\tdeclarator\t*Declarator\n//yy:field\tscope\t\t*Bindings\nTypeName:\n\t{\n\t\tlx.pushScope(ScopeBlock)\n\t}\n\tSpecifierQualifierList AbstractDeclaratorOpt\n\t{\n\t\tif o := lhs.AbstractDeclaratorOpt; o != nil {\n\t\t\tlhs.declarator = o.AbstractDeclarator.declarator\n\t\t} else {\n\t\t\td := &Declarator{\n\t\t\t\tspecifier: lhs.SpecifierQualifierList,\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t\tidScope: lx.scope,\n\t\t\t\t},\n\t\t\t}\n\t\t\td.DirectDeclarator.declarator = d\n\t\t\tlhs.declarator = d\n\t\t}\n\t\tlhs.Type = lhs.declarator.setFull(lx)\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(xc.Token{})\n\t}\n\n// [0](6.7.6)\n//yy:field\tdeclarator\t*Declarator\nAbstractDeclarator:\n\tPointer\n\t{\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tPointerOpt: &PointerOpt {\n\t\t\t\tPointer: lhs.Pointer,\n\t\t\t},\n\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\tidScope: lx.scope,\n\t\t\t},\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t}\n|\tPointerOpt DirectAbstractDeclarator\n\t{\n\t\td := &Declarator{\n\t\t\tspecifier: lx.scope.specifier,\n\t\t\tPointerOpt: lhs.PointerOpt,\n\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t}\n\t\td.DirectDeclarator.declarator = d\n\t\tlhs.declarator = d\n\t}\n\nAbstractDeclaratorOpt:\n\t/* empty */ {}\n|\tAbstractDeclarator\n\n// [0](6.7.6)\n//yy:field\tdirectDeclarator\t*DirectDeclarator\n//yy:field\tparamsScope\t\t*Bindings\nDirectAbstractDeclarator:\n\t'(' AbstractDeclarator ')'\n\t{\n\t\tlhs.AbstractDeclarator.declarator.specifier = nil\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 1, // '(' Declarator ')'\n\t\t\tDeclarator: lhs.AbstractDeclarator.declarator,\n\t\t}\n\t\tlhs.AbstractDeclarator.declarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' ExpressionOpt ']'\n\t{\n\t\tnElements := -1\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\tvar err error\n\t\t\tif nElements, err = elements(o.Expression.eval(lx)); err != nil {\n\t\t\t\tlx.report.Err(o.Expression.Pos(), \"%s\", err)\n\t\t\t}\n\t\t}\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tExpressionOpt: lhs.ExpressionOpt,\n\t\t\telements: nElements,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' TypeQualifierList ExpressionOpt ']'\n\t{\n\t\tif o := lhs.ExpressionOpt; o != nil {\n\t\t\to.Expression.eval(lx)\n\t\t}\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' TypeQualifierListOpt ExpressionOpt ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierListOpt: &TypeQualifierListOpt{ lhs.TypeQualifierList },\n\t\t\tExpressionOpt: lhs.ExpressionOpt,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expression ']'\n\t{\n\t\tlhs.Expression.eval(lx)\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 2, // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expression ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierListOpt: lhs.TypeQualifierListOpt,\n\t\t\tExpression: lhs.Expression,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expression ']'\n\t{\n\t\tlhs.Expression.eval(lx)\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 4, // DirectDeclarator '[' TypeQualifierList \"static\" Expression ']'\n\t\t\tDirectDeclarator: dd,\n\t\t\tTypeQualifierList: lhs.TypeQualifierList,\n\t\t\tExpression: lhs.Expression,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclaratorOpt '[' '*' ']'\n\t{\n\t\tvar dd *DirectDeclarator\n\t\tswitch o := lhs.DirectAbstractDeclaratorOpt; {\n\t\tcase o == nil:\n\t\t\tdd = &DirectDeclarator{\n\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t}\n\t\tdefault:\n\t\t\tdd = o.DirectAbstractDeclarator.directDeclarator\n\t\t}\n\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\tCase: 5, // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\t\tDirectDeclarator: dd,\n\t\t}\n\t\tdd.parent = lhs.directDeclarator\n\t}\n|\t'('\n\t{\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeListOpt ')'\n\t{\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\tcase o != nil:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t},\n\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t}\n\t\tdefault:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\t\tCase: 0, // IDENTIFIER\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n|\tDirectAbstractDeclarator '('\n\t{\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tParameterTypeListOpt ')'\n\t{\n\t\tlhs.paramsScope, _ = lx.popScope(lhs.Token2)\n\t\tswitch o := lhs.ParameterTypeListOpt; {\n\t\tcase o != nil:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 6, // DirectDeclarator '(' ParameterTypeList ')'\n\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t\tParameterTypeList: o.ParameterTypeList,\n\t\t\t}\n\t\tdefault:\n\t\t\tlhs.directDeclarator = &DirectDeclarator{\n\t\t\t\tCase: 7, // DirectDeclarator '(' IdentifierListOpt ')'\n\t\t\t\tDirectDeclarator: lhs.DirectAbstractDeclarator.directDeclarator,\n\t\t\t}\n\t\t}\n\t\tlhs.directDeclarator.DirectDeclarator.parent = lhs.directDeclarator\n\t}\n\nDirectAbstractDeclaratorOpt:\n\t/* empty */ {}\n|\tDirectAbstractDeclarator\n\n// [0](6.7.8)\nInitializer:\n\tExpression\n\t{\n\t\tlhs.Expression.eval(lx)\n\t}\n|\t'{' InitializerList CommaOpt '}'\n|\tIDENTIFIER ':' Initializer\n\t{\n\t\tif !lx.tweaks.enableLegacyDesignators {\n\t\t\tlx.report.Err(lhs.Pos(), \"legacy designators not enabled\")\n\t\t}\n\t}\n\n// [0](6.7.8)\nInitializerList:\n\tDesignationOpt Initializer\n|\tInitializerList ',' DesignationOpt Initializer\n|\t/* empty */ {}\n\n// [0](6.7.8)\nDesignation:\n\tDesignatorList '='\n\nDesignationOpt:\n\t/* empty */ {}\n|\tDesignation\n\n// [0](6.7.8)\nDesignatorList:\n\tDesignator\n|\tDesignatorList Designator\n\n// [0](6.7.8)\nDesignator:\n\t'[' ConstantExpression ']'\n|\t'.' IDENTIFIER\n\n// [0](6.8)\nStatement:\n\tLabeledStatement\n|\tCompoundStatement\n|\tExpressionStatement\n|\tSelectionStatement\n|\tIterationStatement\n|\tJumpStatement\n|\tAssemblerStatement\n\n// [0](6.8.1)\nLabeledStatement:\n\tIDENTIFIER ':' Statement\n|\t\"case\" ConstantExpression ':' Statement\n|\t\"default\" ':' Statement\n\n// [0](6.8.2)\n//yy:field\tscope\t*Bindings\t// Scope of the CompoundStatement.\nCompoundStatement:\n\t'{'\n\t{\n\t\tm := lx.scope.mergeScope\n\t\tlx.pushScope(ScopeBlock)\n\t\tif m != nil {\n\t\t\tlx.scope.merge(m)\n\t\t}\n\t\tlx.scope.mergeScope = nil\n\t}\n\tBlockItemListOpt '}'\n\t{\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(lhs.Token2)\n\t}\n\n// [0](6.8.2)\nBlockItemList:\n\tBlockItem\n|\tBlockItemList BlockItem\n\nBlockItemListOpt:\n\t/* empty */ {}\n|\tBlockItemList\n\n// [0](6.8.2)\nBlockItem:\n\tDeclaration\n|\tStatement\n\n// [0](6.8.3)\nExpressionStatement:\n\tExpressionListOpt ';'\n\n// [0](6.8.4)\nSelectionStatement:\n\t\"if\" '(' ExpressionList ')' Statement %prec NOELSE\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"if\" '(' ExpressionList ')' Statement \"else\" Statement\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"switch\" '(' ExpressionList ')' Statement\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n\n// [0](6.8.5)\nIterationStatement:\n\t\"while\" '(' ExpressionList ')' Statement\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"do\" Statement \"while\" '(' ExpressionList ')' ';'\n\t{\n\t\tlhs.ExpressionList.eval(lx)\n\t}\n|\t\"for\" '(' ExpressionListOpt ';' ExpressionListOpt ';' ExpressionListOpt ')' Statement\n|\t\"for\" '(' Declaration ExpressionListOpt ';' ExpressionListOpt ')' Statement\n\n// [0](6.8.6)\nJumpStatement:\n\t\"goto\" IDENTIFIER ';'\n|\t\"continue\" ';'\n|\t\"break\" ';'\n|\t\"return\" ExpressionListOpt ';'\n|\t\"goto\" Expression ';'\n\t{\n\t\t_, t := lhs.Expression.eval(lx)\n\t\tif t == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tfor t != nil && t.Kind() == Ptr {\n\t\t\tt = t.Element()\n\t\t}\n\n\t\tif t == nil || t.Kind() != Void {\n\t\t\tlx.report.Err(lhs.Pos(), \"invalid computed goto argument type, have '%s'\", t)\n\t\t}\n\n\t\tif !lx.tweaks.enableComputedGotos {\n\t\t\tlx.report.Err(lhs.Pos(), \"computed gotos not enabled\")\n\t\t}\n\t}\n\n// [0](6.9)\n//yy:field\tComments\tmap[token.Pos]int\t// Position -> comment ID. Enable using the KeepComments option.\n//yy:field\tDeclarations\t*Bindings\n//yy:field\tMacros\t\tmap[int]*Macro\t\t// Ident ID -> preprocessor macro defined by ident.\n//yy:field\tModel\t\t*Model\t\t\t// Model used to parse the TranslationUnit.\n//yy:list\nTranslationUnit:\n\tExternalDeclaration\n|\tTranslationUnit ExternalDeclaration\n\n// [0](6.9)\nExternalDeclaration:\n\tFunctionDefinition\n|\tDeclaration\n|\tBasicAssemblerStatement ';'\n|\t';'\n\t{\n\t\tif !lx.tweaks.enableEmptyDeclarations {\n\t\t\tlx.report.Err(lhs.Pos(), \"C++11 empty declarations are illegal in C99.\")\n\t\t}\n\t}\n\n// [0](6.9.1)\nFunctionDefinition:\n\tDeclarationSpecifiers Declarator DeclarationListOpt\n\t{\n\t\tif ds := $1.(*DeclarationSpecifiers); ds.typeSpecifier == 0 {\n\t\t\tds.typeSpecifier = tsEncode(tsInt)\n\t\t\t$2.(*Declarator).Type = lx.model.IntType\n\t\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\t\tlx.report.Err($2.Pos(), \"missing function return type\")\n\t\t\t}\n\t\t}\n\t\tvar fd *FunctionDefinition\n\t\tfd.post(lx, $2.(*Declarator), $3.(*DeclarationListOpt))\n\t}\n\tFunctionBody\n|\t{\n\t\tlx.scope.specifier = &DeclarationSpecifiers{typeSpecifier: tsEncode(tsInt)}\n\t}\n\tDeclarator DeclarationListOpt\n\t{\n\t\tif !lx.tweaks.enableOmitFuncRetType {\n\t\t\tlx.report.Err($2.Pos(), \"missing function return type\")\n\t\t}\n\t\tvar fd *FunctionDefinition\n\t\tfd.post(lx, $2.(*Declarator), $3.(*DeclarationListOpt))\n\t}\n\tFunctionBody\n\n//yy:field\tscope\t*Bindings\t// Scope of the FunctionBody.\nFunctionBody:\n\t{\n\t\t// Handle __func__, [0], 6.4.2.2.\n\t\tid, _ := lx.fnDeclarator.Identifier()\n\t\tlx.injectFunc = []xc.Token{\n\t\t\t{lex.Char{Rune: STATIC}, idStatic},\n\t\t\t{lex.Char{Rune: CONST}, idConst},\n\t\t\t{lex.Char{Rune: CHAR}, idChar},\n\t\t\t{lex.Char{Rune: IDENTIFIER}, idMagicFunc},\n\t\t\t{lex.Char{Rune: '['}, 0},\n\t\t\t{lex.Char{Rune: ']'}, 0},\n\t\t\t{lex.Char{Rune: '='}, 0},\n\t\t\t{lex.Char{Rune: STRINGLITERAL}, xc.Dict.SID(fmt.Sprintf(\"%q\", xc.Dict.S(id)))},\n\t\t\t{lex.Char{Rune: ';'}, 0},\n\t\t}\n\t}\n\tCompoundStatement\n\t{\n\t\tlhs.scope = lhs.CompoundStatement.scope\n\t}\n|\t\n\t{\n\t\tm := lx.scope.mergeScope\n\t\tlx.pushScope(ScopeBlock)\n\t\tif m != nil {\n\t\t\tlx.scope.merge(m)\n\t\t}\n\t\tlx.scope.mergeScope = nil\n\t}\n\tAssemblerStatement ';'\n\t{\n\t\tlhs.scope = lx.scope\n\t\tlx.popScope(lx.tokPrev)\n\t}\n\n// [0](6.9.1)\nDeclarationList:\n\tDeclaration\n|\tDeclarationList Declaration\n\n//yy:field\tparamsScope\t*Bindings\nDeclarationListOpt:\n\t/* empty */ {}\n|\t{\n\t\tlx.pushScope(ScopeParams)\n\t}\n\tDeclarationList\n\t{\n\t\tlhs.paramsScope, _ = lx.popScopePos(lhs.Pos())\n\t}\n\n//yy:list\nAssemblerInstructions:\n\tSTRINGLITERAL\n|\tAssemblerInstructions STRINGLITERAL\n\nBasicAssemblerStatement:\n\t\"asm\" VolatileOpt '(' AssemblerInstructions ')'\n\nVolatileOpt:\n\t/* empty */ {}\n|\t\"volatile\"\n\nAssemblerOperand:\n\tAssemblerSymbolicNameOpt STRINGLITERAL '(' Expression ')'\n\n//yy:list\nAssemblerOperands:\n\tAssemblerOperand\n|\tAssemblerOperands ',' AssemblerOperand\n\nAssemblerSymbolicNameOpt:\n\t/* empty */ {}\n|\t'[' IDENTIFIER ']'\n\n//yy:list\nClobbers:\n\tSTRINGLITERAL\n|\tClobbers ',' STRINGLITERAL\n\nAssemblerStatement:\n\tBasicAssemblerStatement\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ')'\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ')'\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' AssemblerOperands ':' AssemblerOperands ':' Clobbers ')'\n|\t\"asm\" VolatileOpt \"goto\" '(' AssemblerInstructions ':' ':' AssemblerOperands ':' Clobbers ':' IdentifierList ')'\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' ')' // https://github.com/cznic/cc/issues/59\n|\t\"asm\" VolatileOpt '(' AssemblerInstructions ':' ':' AssemblerOperands ')'\n\nStaticAssertDeclaration:\n\t\"_Static_assert\" '(' ConstantExpression ',' STRINGLITERAL ')' ';'\n\t{\n\t\tce := lhs.ConstantExpression\n\t\tif ce.Type == nil || ce.Type.Kind() == Undefined || ce.Value == nil || !IsIntType(ce.Type) {\n\t\t\tlx.report.Err(ce.Pos(), \"invalid static assert expression (have '%v')\", ce.Type)\n\t\t\tbreak\n\t\t}\n\n\t\tif !isNonZero(ce.Value) {\n\t\t\tlx.report.ErrTok(lhs.Token, \"%s\", lhs.Token4.S())\n\t\t}\n\t}\n\n// ========================================================= PREPROCESSING_FILE\n\n// [0](6.10)\n//yy:field\tpath\tstring\nPreprocessingFile:\n\tGroupList // No more GroupListOpt due to final '\\n' injection.\n\t{\n\t\tlhs.path = lx.file.Name()\n\t}\n\n// [0](6.10)\nGroupList:\n\tGroupPart\n//yy:example \"\\U00100000int\\nf() {}\"\n|\tGroupList GroupPart\n\nGroupListOpt:\n\t/* empty */ {}\n//yy:example \"\\U00100000 \\n#ifndef a\\nb\\n#elif\"\n|\tGroupList\n\n// [0](6.10)\n//yy:ignore\nGroupPart:\n\tControlLine\n\t{\n\t\t$$ = $1.(Node)\n\t}\n|\tIfSection\n\t{\n\t\t$$ = $1.(Node)\n\t}\n|\tPPNONDIRECTIVE PPTokenList '\\n'\n\t{\n\t\t$$ = $1\n\t}\n|\tTextLine\n\t{\n\t\t$$ = $1\n\t}\n\n//(6.10)\nIfSection:\n\tIfGroup ElifGroupListOpt ElseGroupOpt EndifLine\n\n//(6.10)\nIfGroup:\n\tPPIF PPTokenList '\\n' GroupListOpt\n|\tPPIFDEF IDENTIFIER '\\n' GroupListOpt\n|\tPPIFNDEF IDENTIFIER '\\n' GroupListOpt\n\n// [0](6.10)\nElifGroupList:\n\tElifGroup\n|\tElifGroupList ElifGroup\n\nElifGroupListOpt:\n\t/* empty */ {}\n|\tElifGroupList\n\n// [0](6.10)\nElifGroup:\n\tPPELIF PPTokenList '\\n' GroupListOpt\n\n// [0](6.10)\nElseGroup:\n\tPPELSE '\\n' GroupListOpt\n\nElseGroupOpt:\n\t/* empty */ {}\n|\tElseGroup\n\n// [0](6.10)\nEndifLine:\n\tPPENDIF /* PPTokenListOpt */ //TODO Option enabling the non std PPTokenListOpt part.\n\n// [0](6.10)\nControlLine:\n\tPPDEFINE IDENTIFIER ReplacementList\n|\tPPDEFINE IDENTIFIER_LPAREN \"...\" ')' ReplacementList\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierList ',' \"...\" ')' ReplacementList\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierListOpt ')' ReplacementList\n|\tPPERROR PPTokenListOpt\n|\tPPHASH_NL\n|\tPPINCLUDE PPTokenList '\\n'\n|\tPPLINE PPTokenList '\\n'\n|\tPPPRAGMA PPTokenListOpt\n//yy:example\t\"\\U00100000 \\n#undef foo\"\n|\tPPUNDEF IDENTIFIER '\\n'\n\n\t// Non standard stuff.\n\n|\tPPDEFINE IDENTIFIER_LPAREN IdentifierList \"...\" ')' ReplacementList\n\t{\n\t\tif !lx.tweaks.enableDefineOmitCommaBeforeDDD {\n\t\t\tlx.report.ErrTok(lhs.Token4, \"missing comma before \\\"...\\\"\")\n\t\t}\n\t}\n|\tPPDEFINE '\\n'\n\t{\n\t\tif !lx.tweaks.enableEmptyDefine {\n\t\t\tlx.report.ErrTok(lhs.Token2, \"expected identifier\")\n\t\t}\n\t}\n//yy:example\t\"\\U00100000 \\n#undef foo(bar)\"\n|\tPPUNDEF IDENTIFIER PPTokenList '\\n'\n\t{\n\t\ttoks := decodeTokens(lhs.PPTokenList, nil, false)\n\t\tif len(toks) == 0 {\n\t\t\tlhs.Case = 9 // PPUNDEF IDENTIFIER '\\n' \n\t\t\tbreak\n\t\t}\n\n\t\tlx.report.ErrTok(toks[0], \"extra tokens after #undef argument\")\n\t}\n|\tPPINCLUDE_NEXT PPTokenList '\\n'\n\n// [0](6.10)\n//yy:ignore\nTextLine:\n\tPPTokenListOpt\n\n// [0](6.10)\n//yy:ignore\nReplacementList:\n\tPPTokenListOpt\n\n// [0](6.10)\n//yy:ignore\nPPTokenList:\n\tPPTokens\n\t{\n\t\t$$ = PPTokenList(dict.ID(lx.encBuf))\n\t\tlx.encBuf = lx.encBuf[:0]\n\t\tlx.encPos = 0\n\t}\n\n//yy:ignore\nPPTokenListOpt:\n\t'\\n'\n\t{\n\t\t$$ = 0\n\t}\n|\tPPTokenList '\\n'\n\n//yy:ignore\nPPTokens:\n\tPPOTHER\n|\tPPTokens PPOTHER\n"
  },
  {
    "path": "scanner.go",
    "content": "// Code generated by golex. DO NOT EDIT.\n\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cznic/golex/lex\"\n)\n\nconst (\n\t_           = iota\n\tscCOMMENT   // [`/*`, `*/`]\n\tscDEFINE    // [^#define, next token]\n\tscDIRECTIVE // [^#, next token]\n\tscHEADER    // [`#include`, next token]\n)\n\nfunc (l *lexer) scan() (r int) {\n\tc := l.Enter()\n\nyystate0:\n\tyyrule := -1\n\t_ = yyrule\n\tc = l.Rule0()\n\n\tswitch yyt := l.sc; yyt {\n\tdefault:\n\t\tpanic(fmt.Errorf(`invalid start condition %d`, yyt))\n\tcase 0: // start condition: INITIAL\n\t\tgoto yystart1\n\tcase 1: // start condition: COMMENT\n\t\tgoto yystart147\n\tcase 2: // start condition: DEFINE\n\t\tgoto yystart152\n\tcase 3: // start condition: DIRECTIVE\n\t\tgoto yystart165\n\tcase 4: // start condition: HEADER\n\t\tgoto yystart221\n\t}\n\n\tgoto yystate0 // silence unused label error\n\tgoto yyAction // silence unused label error\nyyAction:\n\tswitch yyrule {\n\tcase 1:\n\t\tgoto yyrule1\n\tcase 2:\n\t\tgoto yyrule2\n\tcase 3:\n\t\tgoto yyrule3\n\tcase 4:\n\t\tgoto yyrule4\n\tcase 5:\n\t\tgoto yyrule5\n\tcase 6:\n\t\tgoto yyrule6\n\tcase 7:\n\t\tgoto yyrule7\n\tcase 8:\n\t\tgoto yyrule8\n\tcase 9:\n\t\tgoto yyrule9\n\tcase 10:\n\t\tgoto yyrule10\n\tcase 11:\n\t\tgoto yyrule11\n\tcase 12:\n\t\tgoto yyrule12\n\tcase 13:\n\t\tgoto yyrule13\n\tcase 14:\n\t\tgoto yyrule14\n\tcase 15:\n\t\tgoto yyrule15\n\tcase 16:\n\t\tgoto yyrule16\n\tcase 17:\n\t\tgoto yyrule17\n\tcase 18:\n\t\tgoto yyrule18\n\tcase 19:\n\t\tgoto yyrule19\n\tcase 20:\n\t\tgoto yyrule20\n\tcase 21:\n\t\tgoto yyrule21\n\tcase 22:\n\t\tgoto yyrule22\n\tcase 23:\n\t\tgoto yyrule23\n\tcase 24:\n\t\tgoto yyrule24\n\tcase 25:\n\t\tgoto yyrule25\n\tcase 26:\n\t\tgoto yyrule26\n\tcase 27:\n\t\tgoto yyrule27\n\tcase 28:\n\t\tgoto yyrule28\n\tcase 29:\n\t\tgoto yyrule29\n\tcase 30:\n\t\tgoto yyrule30\n\tcase 31:\n\t\tgoto yyrule31\n\tcase 32:\n\t\tgoto yyrule32\n\tcase 33:\n\t\tgoto yyrule33\n\tcase 34:\n\t\tgoto yyrule34\n\tcase 35:\n\t\tgoto yyrule35\n\tcase 36:\n\t\tgoto yyrule36\n\tcase 37:\n\t\tgoto yyrule37\n\tcase 38:\n\t\tgoto yyrule38\n\tcase 39:\n\t\tgoto yyrule39\n\tcase 40:\n\t\tgoto yyrule40\n\tcase 41:\n\t\tgoto yyrule41\n\tcase 42:\n\t\tgoto yyrule42\n\tcase 43:\n\t\tgoto yyrule43\n\tcase 44:\n\t\tgoto yyrule44\n\tcase 45:\n\t\tgoto yyrule45\n\tcase 46:\n\t\tgoto yyrule46\n\tcase 47:\n\t\tgoto yyrule47\n\tcase 48:\n\t\tgoto yyrule48\n\tcase 49:\n\t\tgoto yyrule49\n\tcase 50:\n\t\tgoto yyrule50\n\tcase 51:\n\t\tgoto yyrule51\n\tcase 52:\n\t\tgoto yyrule52\n\tcase 53:\n\t\tgoto yyrule53\n\tcase 54:\n\t\tgoto yyrule54\n\tcase 55:\n\t\tgoto yyrule55\n\tcase 56:\n\t\tgoto yyrule56\n\tcase 57:\n\t\tgoto yyrule57\n\tcase 58:\n\t\tgoto yyrule58\n\tcase 59:\n\t\tgoto yyrule59\n\tcase 60:\n\t\tgoto yyrule60\n\t}\n\tgoto yystate1 // silence unused label error\nyystate1:\n\tc = l.Next()\nyystart1:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate3\n\tcase c == '\"':\n\t\tgoto yystate5\n\tcase c == '#':\n\t\tgoto yystate16\n\tcase c == '%':\n\t\tgoto yystate20\n\tcase c == '&':\n\t\tgoto yystate27\n\tcase c == '*':\n\t\tgoto yystate42\n\tcase c == '+':\n\t\tgoto yystate44\n\tcase c == '-':\n\t\tgoto yystate47\n\tcase c == '.':\n\t\tgoto yystate51\n\tcase c == '/':\n\t\tgoto yystate72\n\tcase c == '0':\n\t\tgoto yystate76\n\tcase c == ':':\n\t\tgoto yystate93\n\tcase c == '<':\n\t\tgoto yystate95\n\tcase c == '=':\n\t\tgoto yystate101\n\tcase c == '>':\n\t\tgoto yystate103\n\tcase c == 'L':\n\t\tgoto yystate117\n\tcase c == '\\'':\n\t\tgoto yystate30\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\tcase c == '\\u0080':\n\t\tgoto yystate146\n\tcase c == '^':\n\t\tgoto yystate141\n\tcase c == '|':\n\t\tgoto yystate143\n\tcase c >= '1' && c <= '9':\n\t\tgoto yystate92\n\tcase c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate107\n\t}\n\nyystate2:\n\tc = l.Next()\n\tyyrule = 1\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule1\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\t}\n\nyystate3:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate4\n\t}\n\nyystate4:\n\tc = l.Next()\n\tyyrule = 7\n\tl.Mark()\n\tgoto yyrule7\n\nyystate5:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate7\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate5\n\t}\n\nyystate6:\n\tc = l.Next()\n\tyyrule = 60\n\tl.Mark()\n\tgoto yyrule60\n\nyystate7:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate5\n\tcase c == 'U':\n\t\tgoto yystate8\n\tcase c == 'u':\n\t\tgoto yystate12\n\tcase c == 'x':\n\t\tgoto yystate15\n\t}\n\nyystate8:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate9\n\t}\n\nyystate9:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate10\n\t}\n\nyystate10:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate11\n\t}\n\nyystate11:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate12\n\t}\n\nyystate12:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate13\n\t}\n\nyystate13:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate14\n\t}\n\nyystate14:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate15\n\t}\n\nyystate15:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate5\n\t}\n\nyystate16:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '#':\n\t\tgoto yystate17\n\tcase c == '%':\n\t\tgoto yystate18\n\t}\n\nyystate17:\n\tc = l.Next()\n\tyyrule = 34\n\tl.Mark()\n\tgoto yyrule34\n\nyystate18:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate19\n\t}\n\nyystate19:\n\tc = l.Next()\n\tyyrule = 35\n\tl.Mark()\n\tgoto yyrule35\n\nyystate20:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate21\n\tcase c == '=':\n\t\tgoto yystate25\n\tcase c == '>':\n\t\tgoto yystate26\n\t}\n\nyystate21:\n\tc = l.Next()\n\tyyrule = 8\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule8\n\tcase c == '#':\n\t\tgoto yystate22\n\tcase c == '%':\n\t\tgoto yystate23\n\t}\n\nyystate22:\n\tc = l.Next()\n\tyyrule = 36\n\tl.Mark()\n\tgoto yyrule36\n\nyystate23:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate24\n\t}\n\nyystate24:\n\tc = l.Next()\n\tyyrule = 37\n\tl.Mark()\n\tgoto yyrule37\n\nyystate25:\n\tc = l.Next()\n\tyyrule = 9\n\tl.Mark()\n\tgoto yyrule9\n\nyystate26:\n\tc = l.Next()\n\tyyrule = 10\n\tl.Mark()\n\tgoto yyrule10\n\nyystate27:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '&':\n\t\tgoto yystate28\n\tcase c == '=':\n\t\tgoto yystate29\n\t}\n\nyystate28:\n\tc = l.Next()\n\tyyrule = 11\n\tl.Mark()\n\tgoto yyrule11\n\nyystate29:\n\tc = l.Next()\n\tyyrule = 12\n\tl.Mark()\n\tgoto yyrule12\n\nyystate30:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate33\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate31\n\t}\n\nyystate31:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\'':\n\t\tgoto yystate32\n\tcase c == '\\\\':\n\t\tgoto yystate33\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate31\n\t}\n\nyystate32:\n\tc = l.Next()\n\tyyrule = 54\n\tl.Mark()\n\tgoto yyrule54\n\nyystate33:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate31\n\tcase c == 'U':\n\t\tgoto yystate34\n\tcase c == 'u':\n\t\tgoto yystate38\n\tcase c == 'x':\n\t\tgoto yystate41\n\t}\n\nyystate34:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate35\n\t}\n\nyystate35:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate36\n\t}\n\nyystate36:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate37\n\t}\n\nyystate37:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate38\n\t}\n\nyystate38:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate39\n\t}\n\nyystate39:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate40\n\t}\n\nyystate40:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate41\n\t}\n\nyystate41:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate31\n\t}\n\nyystate42:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate43\n\t}\n\nyystate43:\n\tc = l.Next()\n\tyyrule = 13\n\tl.Mark()\n\tgoto yyrule13\n\nyystate44:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '+':\n\t\tgoto yystate45\n\tcase c == '=':\n\t\tgoto yystate46\n\t}\n\nyystate45:\n\tc = l.Next()\n\tyyrule = 14\n\tl.Mark()\n\tgoto yyrule14\n\nyystate46:\n\tc = l.Next()\n\tyyrule = 15\n\tl.Mark()\n\tgoto yyrule15\n\nyystate47:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '-':\n\t\tgoto yystate48\n\tcase c == '=':\n\t\tgoto yystate49\n\tcase c == '>':\n\t\tgoto yystate50\n\t}\n\nyystate48:\n\tc = l.Next()\n\tyyrule = 16\n\tl.Mark()\n\tgoto yyrule16\n\nyystate49:\n\tc = l.Next()\n\tyyrule = 17\n\tl.Mark()\n\tgoto yyrule17\n\nyystate50:\n\tc = l.Next()\n\tyyrule = 18\n\tl.Mark()\n\tgoto yyrule18\n\nyystate51:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '.':\n\t\tgoto yystate52\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate54\n\t}\n\nyystate52:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '.':\n\t\tgoto yystate53\n\t}\n\nyystate53:\n\tc = l.Next()\n\tyyrule = 19\n\tl.Mark()\n\tgoto yyrule19\n\nyystate54:\n\tc = l.Next()\n\tyyrule = 58\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule58\n\tcase c == '.' || c >= 'A' && c <= 'D' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c == 'g' || c == 'h' || c == 'j' || c == 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate66\n\tcase c == 'F' || c == 'L' || c == 'f' || c == 'l':\n\t\tgoto yystate69\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'i':\n\t\tgoto yystate71\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate54\n\t}\n\nyystate55:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate56:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '+' || c == '-' || c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate57:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == 'U':\n\t\tgoto yystate58\n\tcase c == 'u':\n\t\tgoto yystate62\n\t}\n\nyystate58:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate59\n\t}\n\nyystate59:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate60\n\t}\n\nyystate60:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate61\n\t}\n\nyystate61:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate62\n\t}\n\nyystate62:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate63\n\t}\n\nyystate63:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate64\n\t}\n\nyystate64:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate65\n\t}\n\nyystate65:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate55\n\t}\n\nyystate66:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '+' || c == '-':\n\t\tgoto yystate67\n\tcase c == '.' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate68\n\t}\n\nyystate67:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate68\n\t}\n\nyystate68:\n\tc = l.Next()\n\tyyrule = 58\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule58\n\tcase c == '.' || c >= 'A' && c <= 'D' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c == 'g' || c == 'h' || c == 'j' || c == 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'F' || c == 'L' || c == 'f' || c == 'l':\n\t\tgoto yystate69\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'i':\n\t\tgoto yystate71\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate68\n\t}\n\nyystate69:\n\tc = l.Next()\n\tyyrule = 58\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule58\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'h' || c >= 'j' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'i':\n\t\tgoto yystate70\n\t}\n\nyystate70:\n\tc = l.Next()\n\tyyrule = 58\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule58\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate71:\n\tc = l.Next()\n\tyyrule = 58\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule58\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'g' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'F' || c == 'L' || c == 'f' || c == 'l':\n\t\tgoto yystate70\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate72:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate73\n\tcase c == '/':\n\t\tgoto yystate74\n\tcase c == '=':\n\t\tgoto yystate75\n\t}\n\nyystate73:\n\tc = l.Next()\n\tyyrule = 3\n\tl.Mark()\n\tgoto yyrule3\n\nyystate74:\n\tc = l.Next()\n\tyyrule = 2\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule2\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate74\n\t}\n\nyystate75:\n\tc = l.Next()\n\tyyrule = 20\n\tl.Mark()\n\tgoto yyrule20\n\nyystate76:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.':\n\t\tgoto yystate54\n\tcase c == '8' || c == '9':\n\t\tgoto yystate78\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate66\n\tcase c == 'L':\n\t\tgoto yystate79\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate82\n\tcase c == 'X' || c == 'x':\n\t\tgoto yystate86\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate85\n\tcase c >= '0' && c <= '7':\n\t\tgoto yystate77\n\tcase c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c == 'V' || c == 'W' || c == 'Y' || c == 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c == 'v' || c == 'w' || c == 'y' || c == 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate77:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.':\n\t\tgoto yystate54\n\tcase c == '8' || c == '9':\n\t\tgoto yystate78\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate66\n\tcase c == 'L':\n\t\tgoto yystate79\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate82\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate85\n\tcase c >= '0' && c <= '7':\n\t\tgoto yystate77\n\tcase c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate78:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.':\n\t\tgoto yystate54\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate66\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate78\n\tcase c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate79:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'L':\n\t\tgoto yystate80\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate81\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate80:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate81\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate81:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate82:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'L':\n\t\tgoto yystate83\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate84\n\t}\n\nyystate83:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'L':\n\t\tgoto yystate81\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\t}\n\nyystate84:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate81\n\t}\n\nyystate85:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate81\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate80\n\t}\n\nyystate86:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.':\n\t\tgoto yystate87\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate91\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate90\n\tcase c >= 'G' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate87:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.' || c >= 'G' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate89\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate88\n\t}\n\nyystate88:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '.' || c >= 'G' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate89\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate66\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate88\n\t}\n\nyystate89:\n\tc = l.Next()\n\tyyrule = 59\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule59\n\tcase c == '+' || c == '-' || c == '.' || c >= 'G' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate89\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate66\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate88\n\t}\n\nyystate90:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.':\n\t\tgoto yystate88\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate91\n\tcase c == 'L':\n\t\tgoto yystate79\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate66\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate82\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate85\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate90\n\tcase c >= 'G' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate91:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '+' || c == '-' || c >= 'G' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'g' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\tcase c == '.':\n\t\tgoto yystate88\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate91\n\tcase c == 'L':\n\t\tgoto yystate79\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate66\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate82\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate85\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c == 'F' || c >= 'a' && c <= 'd' || c == 'f':\n\t\tgoto yystate90\n\t}\n\nyystate92:\n\tc = l.Next()\n\tyyrule = 57\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule57\n\tcase c == '.':\n\t\tgoto yystate54\n\tcase c == 'E' || c == 'e':\n\t\tgoto yystate66\n\tcase c == 'L':\n\t\tgoto yystate79\n\tcase c == 'P' || c == 'p':\n\t\tgoto yystate56\n\tcase c == 'U' || c == 'u':\n\t\tgoto yystate82\n\tcase c == '\\\\':\n\t\tgoto yystate57\n\tcase c == 'l':\n\t\tgoto yystate85\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate92\n\tcase c >= 'A' && c <= 'D' || c >= 'F' && c <= 'K' || c >= 'M' && c <= 'O' || c >= 'Q' && c <= 'T' || c >= 'V' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate55\n\t}\n\nyystate93:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '>':\n\t\tgoto yystate94\n\t}\n\nyystate94:\n\tc = l.Next()\n\tyyrule = 21\n\tl.Mark()\n\tgoto yyrule21\n\nyystate95:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '%':\n\t\tgoto yystate96\n\tcase c == ':':\n\t\tgoto yystate97\n\tcase c == '<':\n\t\tgoto yystate98\n\tcase c == '=':\n\t\tgoto yystate100\n\t}\n\nyystate96:\n\tc = l.Next()\n\tyyrule = 22\n\tl.Mark()\n\tgoto yyrule22\n\nyystate97:\n\tc = l.Next()\n\tyyrule = 23\n\tl.Mark()\n\tgoto yyrule23\n\nyystate98:\n\tc = l.Next()\n\tyyrule = 24\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule24\n\tcase c == '=':\n\t\tgoto yystate99\n\t}\n\nyystate99:\n\tc = l.Next()\n\tyyrule = 25\n\tl.Mark()\n\tgoto yyrule25\n\nyystate100:\n\tc = l.Next()\n\tyyrule = 26\n\tl.Mark()\n\tgoto yyrule26\n\nyystate101:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate102\n\t}\n\nyystate102:\n\tc = l.Next()\n\tyyrule = 27\n\tl.Mark()\n\tgoto yyrule27\n\nyystate103:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate104\n\tcase c == '>':\n\t\tgoto yystate105\n\t}\n\nyystate104:\n\tc = l.Next()\n\tyyrule = 28\n\tl.Mark()\n\tgoto yyrule28\n\nyystate105:\n\tc = l.Next()\n\tyyrule = 29\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule29\n\tcase c == '=':\n\t\tgoto yystate106\n\t}\n\nyystate106:\n\tc = l.Next()\n\tyyrule = 30\n\tl.Mark()\n\tgoto yyrule30\n\nyystate107:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate108:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == 'U':\n\t\tgoto yystate109\n\tcase c == 'u':\n\t\tgoto yystate113\n\t}\n\nyystate109:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate110\n\t}\n\nyystate110:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate111\n\t}\n\nyystate111:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate112\n\t}\n\nyystate112:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate113\n\t}\n\nyystate113:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate114\n\t}\n\nyystate114:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate115\n\t}\n\nyystate115:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate116\n\t}\n\nyystate116:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate107\n\t}\n\nyystate117:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '\"':\n\t\tgoto yystate118\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\'':\n\t\tgoto yystate129\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate118:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate119\n\tcase c == '\\\\':\n\t\tgoto yystate120\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate118\n\t}\n\nyystate119:\n\tc = l.Next()\n\tyyrule = 53\n\tl.Mark()\n\tgoto yyrule53\n\nyystate120:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate118\n\tcase c == 'U':\n\t\tgoto yystate121\n\tcase c == 'u':\n\t\tgoto yystate125\n\tcase c == 'x':\n\t\tgoto yystate128\n\t}\n\nyystate121:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate122\n\t}\n\nyystate122:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate123\n\t}\n\nyystate123:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate124\n\t}\n\nyystate124:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate125\n\t}\n\nyystate125:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate126\n\t}\n\nyystate126:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate127\n\t}\n\nyystate127:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate128\n\t}\n\nyystate128:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate118\n\t}\n\nyystate129:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate132\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate130\n\t}\n\nyystate130:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\'':\n\t\tgoto yystate131\n\tcase c == '\\\\':\n\t\tgoto yystate132\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate130\n\t}\n\nyystate131:\n\tc = l.Next()\n\tyyrule = 52\n\tl.Mark()\n\tgoto yyrule52\n\nyystate132:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate130\n\tcase c == 'U':\n\t\tgoto yystate133\n\tcase c == 'u':\n\t\tgoto yystate137\n\tcase c == 'x':\n\t\tgoto yystate140\n\t}\n\nyystate133:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate134\n\t}\n\nyystate134:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate135\n\t}\n\nyystate135:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate136\n\t}\n\nyystate136:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate137\n\t}\n\nyystate137:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate138\n\t}\n\nyystate138:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate139\n\t}\n\nyystate139:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate140\n\t}\n\nyystate140:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate130\n\t}\n\nyystate141:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate142\n\t}\n\nyystate142:\n\tc = l.Next()\n\tyyrule = 31\n\tl.Mark()\n\tgoto yyrule31\n\nyystate143:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate144\n\tcase c == '|':\n\t\tgoto yystate145\n\t}\n\nyystate144:\n\tc = l.Next()\n\tyyrule = 32\n\tl.Mark()\n\tgoto yyrule32\n\nyystate145:\n\tc = l.Next()\n\tyyrule = 33\n\tl.Mark()\n\tgoto yyrule33\n\nyystate146:\n\tc = l.Next()\n\tyyrule = 6\n\tl.Mark()\n\tgoto yyrule6\n\n\tgoto yystate147 // silence unused label error\nyystate147:\n\tc = l.Next()\nyystart147:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate149\n\tcase c == '\\u0080':\n\t\tgoto yystate151\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate148\n\t}\n\nyystate148:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate149\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate148\n\t}\n\nyystate149:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate149\n\tcase c == '/':\n\t\tgoto yystate150\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '.' || c >= '0' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate148\n\t}\n\nyystate150:\n\tc = l.Next()\n\tyyrule = 4\n\tl.Mark()\n\tgoto yyrule4\n\nyystate151:\n\tc = l.Next()\n\tyyrule = 5\n\tl.Mark()\n\tgoto yyrule5\n\n\tgoto yystate152 // silence unused label error\nyystate152:\n\tc = l.Next()\nyystart152:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate3\n\tcase c == '\"':\n\t\tgoto yystate5\n\tcase c == '#':\n\t\tgoto yystate16\n\tcase c == '%':\n\t\tgoto yystate20\n\tcase c == '&':\n\t\tgoto yystate27\n\tcase c == '*':\n\t\tgoto yystate42\n\tcase c == '+':\n\t\tgoto yystate44\n\tcase c == '-':\n\t\tgoto yystate47\n\tcase c == '.':\n\t\tgoto yystate51\n\tcase c == '/':\n\t\tgoto yystate72\n\tcase c == '0':\n\t\tgoto yystate76\n\tcase c == ':':\n\t\tgoto yystate93\n\tcase c == '<':\n\t\tgoto yystate95\n\tcase c == '=':\n\t\tgoto yystate101\n\tcase c == '>':\n\t\tgoto yystate103\n\tcase c == 'L':\n\t\tgoto yystate164\n\tcase c == '\\'':\n\t\tgoto yystate30\n\tcase c == '\\\\':\n\t\tgoto yystate155\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\tcase c == '\\u0080':\n\t\tgoto yystate146\n\tcase c == '^':\n\t\tgoto yystate141\n\tcase c == '|':\n\t\tgoto yystate143\n\tcase c >= '1' && c <= '9':\n\t\tgoto yystate92\n\tcase c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate153\n\t}\n\nyystate153:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate153\n\tcase c == '(':\n\t\tgoto yystate154\n\tcase c == '\\\\':\n\t\tgoto yystate155\n\t}\n\nyystate154:\n\tc = l.Next()\n\tyyrule = 56\n\tl.Mark()\n\tgoto yyrule56\n\nyystate155:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == 'U':\n\t\tgoto yystate156\n\tcase c == 'u':\n\t\tgoto yystate160\n\t}\n\nyystate156:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate157\n\t}\n\nyystate157:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate158\n\t}\n\nyystate158:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate159\n\t}\n\nyystate159:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate160\n\t}\n\nyystate160:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate161\n\t}\n\nyystate161:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate162\n\t}\n\nyystate162:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate163\n\t}\n\nyystate163:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate153\n\t}\n\nyystate164:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '\"':\n\t\tgoto yystate118\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate153\n\tcase c == '(':\n\t\tgoto yystate154\n\tcase c == '\\'':\n\t\tgoto yystate129\n\tcase c == '\\\\':\n\t\tgoto yystate155\n\t}\n\n\tgoto yystate165 // silence unused label error\nyystate165:\n\tc = l.Next()\nyystart165:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate3\n\tcase c == '\"':\n\t\tgoto yystate5\n\tcase c == '#':\n\t\tgoto yystate16\n\tcase c == '%':\n\t\tgoto yystate20\n\tcase c == '&':\n\t\tgoto yystate27\n\tcase c == '*':\n\t\tgoto yystate42\n\tcase c == '+':\n\t\tgoto yystate44\n\tcase c == '-':\n\t\tgoto yystate47\n\tcase c == '.':\n\t\tgoto yystate51\n\tcase c == '/':\n\t\tgoto yystate72\n\tcase c == '0':\n\t\tgoto yystate76\n\tcase c == ':':\n\t\tgoto yystate93\n\tcase c == '<':\n\t\tgoto yystate95\n\tcase c == '=':\n\t\tgoto yystate101\n\tcase c == '>':\n\t\tgoto yystate103\n\tcase c == 'L':\n\t\tgoto yystate117\n\tcase c == '\\'':\n\t\tgoto yystate30\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\tcase c == '\\u0080':\n\t\tgoto yystate146\n\tcase c == '^':\n\t\tgoto yystate141\n\tcase c == 'd':\n\t\tgoto yystate166\n\tcase c == 'e':\n\t\tgoto yystate172\n\tcase c == 'i':\n\t\tgoto yystate186\n\tcase c == 'l':\n\t\tgoto yystate206\n\tcase c == 'p':\n\t\tgoto yystate210\n\tcase c == 'u':\n\t\tgoto yystate216\n\tcase c == '|':\n\t\tgoto yystate143\n\tcase c >= '1' && c <= '9':\n\t\tgoto yystate92\n\tcase c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'f' && c <= 'h' || c == 'j' || c == 'k' || c >= 'm' && c <= 'o' || c >= 'q' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate107\n\t}\n\nyystate166:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate167\n\t}\n\nyystate167:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate168\n\t}\n\nyystate168:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'i':\n\t\tgoto yystate169\n\t}\n\nyystate169:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'n':\n\t\tgoto yystate170\n\t}\n\nyystate170:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate171\n\t}\n\nyystate171:\n\tc = l.Next()\n\tyyrule = 38\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule38\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate172:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c == 'm' || c >= 'o' && c <= 'q' || c >= 's' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'l':\n\t\tgoto yystate173\n\tcase c == 'n':\n\t\tgoto yystate178\n\tcase c == 'r':\n\t\tgoto yystate182\n\t}\n\nyystate173:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'r' || c >= 't' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'i':\n\t\tgoto yystate174\n\tcase c == 's':\n\t\tgoto yystate176\n\t}\n\nyystate174:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate175\n\t}\n\nyystate175:\n\tc = l.Next()\n\tyyrule = 39\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule39\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate176:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate177\n\t}\n\nyystate177:\n\tc = l.Next()\n\tyyrule = 40\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule40\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate178:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'd':\n\t\tgoto yystate179\n\t}\n\nyystate179:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'i':\n\t\tgoto yystate180\n\t}\n\nyystate180:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate181\n\t}\n\nyystate181:\n\tc = l.Next()\n\tyyrule = 41\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule41\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate182:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'r':\n\t\tgoto yystate183\n\t}\n\nyystate183:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'n' || c >= 'p' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'o':\n\t\tgoto yystate184\n\t}\n\nyystate184:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'r':\n\t\tgoto yystate185\n\t}\n\nyystate185:\n\tc = l.Next()\n\tyyrule = 42\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule42\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate186:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate187\n\tcase c == 'n':\n\t\tgoto yystate195\n\t}\n\nyystate187:\n\tc = l.Next()\n\tyyrule = 43\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule43\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'd':\n\t\tgoto yystate188\n\tcase c == 'n':\n\t\tgoto yystate191\n\t}\n\nyystate188:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate189\n\t}\n\nyystate189:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate190\n\t}\n\nyystate190:\n\tc = l.Next()\n\tyyrule = 44\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule44\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate191:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'd':\n\t\tgoto yystate192\n\t}\n\nyystate192:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate193\n\t}\n\nyystate193:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate194\n\t}\n\nyystate194:\n\tc = l.Next()\n\tyyrule = 45\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule45\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate195:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c == 'a' || c == 'b' || c >= 'd' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'c':\n\t\tgoto yystate196\n\t}\n\nyystate196:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'k' || c >= 'm' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'l':\n\t\tgoto yystate197\n\t}\n\nyystate197:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 't' || c >= 'v' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'u':\n\t\tgoto yystate198\n\t}\n\nyystate198:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'd':\n\t\tgoto yystate199\n\t}\n\nyystate199:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate200\n\t}\n\nyystate200:\n\tc = l.Next()\n\tyyrule = 46\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule46\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == '_':\n\t\tgoto yystate201\n\t}\n\nyystate201:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'n':\n\t\tgoto yystate202\n\t}\n\nyystate202:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate203\n\t}\n\nyystate203:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'w' || c == 'y' || c == 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'x':\n\t\tgoto yystate204\n\t}\n\nyystate204:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 's' || c >= 'u' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 't':\n\t\tgoto yystate205\n\t}\n\nyystate205:\n\tc = l.Next()\n\tyyrule = 47\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule47\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate206:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'h' || c >= 'j' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'i':\n\t\tgoto yystate207\n\t}\n\nyystate207:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'n':\n\t\tgoto yystate208\n\t}\n\nyystate208:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate209\n\t}\n\nyystate209:\n\tc = l.Next()\n\tyyrule = 48\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule48\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate210:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'q' || c >= 's' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'r':\n\t\tgoto yystate211\n\t}\n\nyystate211:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'a':\n\t\tgoto yystate212\n\t}\n\nyystate212:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'f' || c >= 'h' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'g':\n\t\tgoto yystate213\n\t}\n\nyystate213:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'l' || c >= 'n' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'm':\n\t\tgoto yystate214\n\t}\n\nyystate214:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'b' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'a':\n\t\tgoto yystate215\n\t}\n\nyystate215:\n\tc = l.Next()\n\tyyrule = 49\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule49\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\nyystate216:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'm' || c >= 'o' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'n':\n\t\tgoto yystate217\n\t}\n\nyystate217:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'c' || c >= 'e' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'd':\n\t\tgoto yystate218\n\t}\n\nyystate218:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'e':\n\t\tgoto yystate219\n\t}\n\nyystate219:\n\tc = l.Next()\n\tyyrule = 55\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule55\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'e' || c >= 'g' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == 'f':\n\t\tgoto yystate220\n\t}\n\nyystate220:\n\tc = l.Next()\n\tyyrule = 50\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule50\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\t}\n\n\tgoto yystate221 // silence unused label error\nyystate221:\n\tc = l.Next()\nyystart221:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate3\n\tcase c == '\"':\n\t\tgoto yystate222\n\tcase c == '#':\n\t\tgoto yystate16\n\tcase c == '%':\n\t\tgoto yystate20\n\tcase c == '&':\n\t\tgoto yystate27\n\tcase c == '*':\n\t\tgoto yystate42\n\tcase c == '+':\n\t\tgoto yystate44\n\tcase c == '-':\n\t\tgoto yystate47\n\tcase c == '.':\n\t\tgoto yystate51\n\tcase c == '/':\n\t\tgoto yystate72\n\tcase c == '0':\n\t\tgoto yystate76\n\tcase c == ':':\n\t\tgoto yystate93\n\tcase c == '<':\n\t\tgoto yystate237\n\tcase c == '=':\n\t\tgoto yystate101\n\tcase c == '>':\n\t\tgoto yystate103\n\tcase c == 'L':\n\t\tgoto yystate117\n\tcase c == '\\'':\n\t\tgoto yystate30\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\tcase c == '\\u0080':\n\t\tgoto yystate146\n\tcase c == '^':\n\t\tgoto yystate141\n\tcase c == '|':\n\t\tgoto yystate143\n\tcase c >= '1' && c <= '9':\n\t\tgoto yystate92\n\tcase c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate107\n\t}\n\nyystate222:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate225\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate223\n\t}\n\nyystate223:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate224\n\tcase c == '\\\\':\n\t\tgoto yystate225\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate223\n\t}\n\nyystate224:\n\tc = l.Next()\n\tyyrule = 51\n\tl.Mark()\n\tgoto yyrule51\n\nyystate225:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate228\n\tcase c == 'U':\n\t\tgoto yystate229\n\tcase c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate223\n\tcase c == 'u':\n\t\tgoto yystate233\n\tcase c == 'x':\n\t\tgoto yystate236\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '&' || c >= '(' && c <= '/' || c >= '8' && c <= '>' || c >= '@' && c <= 'T' || c >= 'V' && c <= '[' || c >= ']' && c <= '`' || c >= 'c' && c <= 'e' || c >= 'g' && c <= 'm' || c >= 'o' && c <= 'q' || c == 's' || c == 'w' || c >= 'y' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate226:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate227:\n\tc = l.Next()\n\tyyrule = 51\n\tl.Mark()\n\tgoto yyrule51\n\nyystate228:\n\tc = l.Next()\n\tyyrule = 51\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule51\n\tcase c == '\"':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate7\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate5\n\t}\n\nyystate229:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate230\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate230:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate231\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate231:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate232\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate232:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate233\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate233:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate234\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate234:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate235\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate235:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate236\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate236:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate227\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate223\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '/' || c >= ':' && c <= '@' || c >= 'G' && c <= '`' || c >= 'g' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate226\n\t}\n\nyystate237:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '%':\n\t\tgoto yystate239\n\tcase c == ':':\n\t\tgoto yystate240\n\tcase c == '<':\n\t\tgoto yystate241\n\tcase c == '=':\n\t\tgoto yystate243\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '$' || c >= '&' && c <= '9' || c == ';' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate238:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '=' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate239:\n\tc = l.Next()\n\tyyrule = 22\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule22\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '=' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate240:\n\tc = l.Next()\n\tyyrule = 23\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule23\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '=' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate241:\n\tc = l.Next()\n\tyyrule = 24\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule24\n\tcase c == '=':\n\t\tgoto yystate242\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '<' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate242:\n\tc = l.Next()\n\tyyrule = 25\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule25\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '=' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyystate243:\n\tc = l.Next()\n\tyyrule = 26\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule26\n\tcase c == '>':\n\t\tgoto yystate227\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '=' || c >= '?' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate238\n\t}\n\nyyrule1: // [ \\t\\f\\v]+\n\t{\n\t\treturn ' '\n\t}\nyyrule2: // \"//\"[^\\x80\\n]*\n\t{\n\t\tl.comment(false)\n\t\treturn ' '\n\t}\nyyrule3: // \"/*\"\n\t{\n\t\tl.commentPos0 = l.First.Pos()\n\t\tl.push(scCOMMENT)\n\t\tgoto yystate0\n\t}\nyyrule4: // {comment-close}\n\t{\n\t\tl.pop()\n\t\tl.First = lex.NewChar(l.commentPos0, l.First.Rune)\n\t\tl.comment(true)\n\t\treturn ' '\n\t}\nyyrule5: // {eof}\n\t{\n\t\tl.report.Err(l.commentPos0, commentNotClosed)\n\t\tl.pop()\n\t\treturn rune2class(lex.RuneEOF)\n\t}\nyyrule6: // {eof}\n\t{\n\t\treturn rune2class(lex.RuneEOF)\n\t}\nyyrule7: // \"!=\"\n\t{\n\t\treturn NEQ\n\t}\nyyrule8: // \"%:\"\n\t{\n\t\treturn '#'\n\t}\nyyrule9: // \"%=\"\n\t{\n\t\treturn MODASSIGN\n\t}\nyyrule10: // \"%>\"\n\t{\n\t\treturn '}'\n\t}\nyyrule11: // \"&&\"\n\t{\n\t\treturn ANDAND\n\t}\nyyrule12: // \"&=\"\n\t{\n\t\treturn ANDASSIGN\n\t}\nyyrule13: // \"*=\"\n\t{\n\t\treturn MULASSIGN\n\t}\nyyrule14: // \"++\"\n\t{\n\t\treturn INC\n\t}\nyyrule15: // \"+=\"\n\t{\n\t\treturn ADDASSIGN\n\t}\nyyrule16: // \"--\"\n\t{\n\t\treturn DEC\n\t}\nyyrule17: // \"-=\"\n\t{\n\t\treturn SUBASSIGN\n\t}\nyyrule18: // \"->\"\n\t{\n\t\treturn ARROW\n\t}\nyyrule19: // \"...\"\n\t{\n\t\treturn DDD\n\t}\nyyrule20: // \"/=\"\n\t{\n\t\treturn DIVASSIGN\n\t}\nyyrule21: // \":>\"\n\t{\n\t\treturn ']'\n\t}\nyyrule22: // \"<%\"\n\t{\n\t\treturn '{'\n\t}\nyyrule23: // \"<:\"\n\t{\n\t\treturn '['\n\t}\nyyrule24: // \"<<\"\n\t{\n\t\treturn LSH\n\t}\nyyrule25: // \"<<=\"\n\t{\n\t\treturn LSHASSIGN\n\t}\nyyrule26: // \"<=\"\n\t{\n\t\treturn LEQ\n\t}\nyyrule27: // \"==\"\n\t{\n\t\treturn EQ\n\t}\nyyrule28: // \">=\"\n\t{\n\t\treturn GEQ\n\t}\nyyrule29: // \">>\"\n\t{\n\t\treturn RSH\n\t}\nyyrule30: // \">>=\"\n\t{\n\t\treturn RSHASSIGN\n\t}\nyyrule31: // \"^=\"\n\t{\n\t\treturn XORASSIGN\n\t}\nyyrule32: // \"|=\"\n\t{\n\t\treturn ORASSIGN\n\t}\nyyrule33: // \"||\"\n\t{\n\t\treturn OROR\n\t}\nyyrule34: // \"##\"\nyyrule35: // \"#%:\"\nyyrule36: // \"%:#\"\nyyrule37: // \"%:%:\"\n\t{\n\t\treturn PPPASTE\n\t}\nyyrule38: // \"define\"\n\t{\n\t\tl.pop()\n\t\treturn PPDEFINE\n\t\tgoto yystate0\n\t}\nyyrule39: // \"elif\"\n\t{\n\t\tl.pop()\n\t\treturn PPELIF\n\t\tgoto yystate0\n\t}\nyyrule40: // \"else\"\n\t{\n\t\tl.pop()\n\t\treturn PPELSE\n\t\tgoto yystate0\n\t}\nyyrule41: // \"endif\"\n\t{\n\t\tl.pop()\n\t\treturn PPENDIF\n\t\tgoto yystate0\n\t}\nyyrule42: // \"error\"\n\t{\n\t\tl.pop()\n\t\treturn PPERROR\n\t\tgoto yystate0\n\t}\nyyrule43: // \"if\"\n\t{\n\t\tl.pop()\n\t\treturn PPIF\n\t\tgoto yystate0\n\t}\nyyrule44: // \"ifdef\"\n\t{\n\t\tl.pop()\n\t\treturn PPIFDEF\n\t\tgoto yystate0\n\t}\nyyrule45: // \"ifndef\"\n\t{\n\t\tl.pop()\n\t\treturn PPIFNDEF\n\t\tgoto yystate0\n\t}\nyyrule46: // \"include\"\n\t{\n\t\tl.pop()\n\t\treturn PPINCLUDE\n\t\tgoto yystate0\n\t}\nyyrule47: // \"include_next\"\n\t{\n\t\tl.pop()\n\t\treturn PPINCLUDE_NEXT\n\t\tgoto yystate0\n\t}\nyyrule48: // \"line\"\n\t{\n\t\tl.pop()\n\t\treturn PPLINE\n\t\tgoto yystate0\n\t}\nyyrule49: // \"pragma\"\n\t{\n\t\tl.pop()\n\t\treturn PPPRAGMA\n\t\tgoto yystate0\n\t}\nyyrule50: // \"undef\"\n\t{\n\t\tl.pop()\n\t\treturn PPUNDEF\n\t\tgoto yystate0\n\t}\nyyrule51: // {header-name}\n\t{\n\t\tl.sc = scINITIAL\n\t\treturn PPHEADER_NAME\n\t}\nyyrule52: // L{character-constant}\n\t{\n\t\treturn LONGCHARCONST\n\t}\nyyrule53: // L{string-literal}\n\t{\n\t\treturn LONGSTRINGLITERAL\n\t}\nyyrule54: // {character-constant}\n\t{\n\t\treturn CHARCONST\n\t}\nyyrule55: // {identifier}\n\t{\n\t\treturn IDENTIFIER\n\t}\nyyrule56: // {identifier}\"(\"\n\t{\n\t\treturn IDENTIFIER_LPAREN\n\t}\nyyrule57: // {integer-constant}\n\t{\n\t\treturn INTCONST\n\t}\nyyrule58: // {floating-constant}\n\t{\n\t\treturn FLOATCONST\n\t}\nyyrule59: // {pp-number}\n\t{\n\t\treturn PPNUMBER\n\t}\nyyrule60: // {string-literal}\n\t{\n\t\treturn STRINGLITERAL\n\t}\n\tpanic(\"unreachable\")\n\n\tgoto yyabort // silence unused label error\n\nyyabort: // no lexem recognized\n\tif c, ok := l.Abort(); ok {\n\t\treturn c\n\t}\n\n\tgoto yyAction\n}\n"
  },
  {
    "path": "scanner.l",
    "content": "%{\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n%}\n\n%yyc c\n%yyn c = l.Next()\n%yym l.Mark()\n%yyt l.sc\n\n%x COMMENT\n%s DEFINE DIRECTIVE HEADER\n\n%{\npackage cc\n\nimport (\n        \"fmt\"\n\n        \"github.com/cznic/golex/lex\"\n)\n\nconst (\n        _ = iota\n        scCOMMENT       // [`/*`, `*/`]\n        scDEFINE        // [^#define, next token]\n        scDIRECTIVE     // [^#, next token]\n        scHEADER        // [`#include`, next token]\n)\n\nfunc (l *lexer) scan() (r int) {\n        c := l.Enter()\n%}\n\nbinary-exponent-part            [pP]{sign}?{digit-sequence}\nc-char                          [^'\\n\\x80\\\\]|{escape-sequence}\nc-char-sequence                 {c-char}+\ncharacter-constant              '{c-char-sequence}'\ncomment-close                   ([^*\\x80]|\\*+[^*/\\x80])*\\*+\\/\ndecimal-constant                {nonzero-digit}{digit}*\ndecimal-floating-constant       ({fractional-constant}{exponent-part}?|{digit-sequence}{exponent-part}){floating-suffix}?\ndigit                           [0-9]\ndigit-sequence                  {digit}+\neof                             \\x80\nescape-sequence                 {simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}\nexponent-part                   [eE]{sign}?{digit-sequence}\nfloating-constant               {decimal-floating-constant}|{hexadecimal-floating-constant}\nfloating-suffix                 i?[flFL]?|[flFL]?i?\nfractional-constant             {digit-sequence}?\\.{digit-sequence}|{digit-sequence}\\.\nh-char                          [^>\\n\\x80]\nh-char-sequence                 {h-char}+\nheader-name                     <{h-char-sequence}>|\\x22{q-char-sequence}\\x22\nhex-quad                        {hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}\nhexadecimal-constant            {hexadecimal-prefix}{hexadecimal-digit}+\nhexadecimal-digit               [0-9a-fA-F]\nhexadecimal-digit-sequence      {hexadecimal-digit}+\nhexadecimal-escape-sequence     \\\\x{hexadecimal-digit}+\nhexadecimal-floating-constant   {hexadecimal-prefix}({hexadecimal-fractional-constant}|{hexadecimal-digit-sequence}){binary-exponent-part}{floating-suffix}?\nhexadecimal-fractional-constant {hexadecimal-digit-sequence}?\\.{hexadecimal-digit-sequence}|{hexadecimal-digit-sequence}\\.\nhexadecimal-prefix              0[xX]\nidentifier                      {identifier-nondigit}({identifier-nondigit}|{digit}|{ucn-digit}|\"$\")*\nidentifier-nondigit             {nondigit}|{universal-character-name}|{ucn-nondigit}\ninteger-constant                ({decimal-constant}|{octal-constant}|{hexadecimal-constant}){integer-suffix}?\ninteger-suffix                  {unsigned-suffix}({long-suffix}?|{long-long-suffix})|{long-suffix}{unsigned-suffix}?|{long-long-suffix}{unsigned-suffix}?\nlong-long-suffix                ll|LL\nlong-suffix                     [lL]\nnondigit                        [_a-zA-Z]\nnonzero-digit                   [1-9]\noctal-constant                  0{octal-digit}*\noctal-digit                     [0-7]\noctal-escape-sequence           \\\\{octal-digit}{octal-digit}?{octal-digit}?\npp-number                       ({digit}|\\.{digit})({digit}|{identifier-nondigit}|[eEpP]{sign}|\\.)*\nq-char                          [^\\n\\x22\\x80]\nq-char-sequence                 {q-char}+\ns-char                          [^\\x22\\n\\x80\\\\]|{escape-sequence}\ns-char-sequence                 {s-char}+\nsign                            [-+]\nsimple-sequence                 \\\\['\\x22?\\\\abfnrtv]\nstring-literal                  \\x22{s-char-sequence}?\\x22\nucn-digit                       \\x83\nucn-nondigit                    \\x84\nuniversal-character-name        \\\\u{hex-quad}|\\\\U{hex-quad}{hex-quad}\nunsigned-suffix                 [uU]\n\n%%\n                                c = l.Rule0()\n\n[ \\t\\f\\v]+\t\t\treturn ' '\n\n\"//\"[^\\x80\\n]*\t\t\tl.comment(false)\n\t\t\t\treturn ' '\n\n\"/*\"\t\t\t\tl.commentPos0 = l.First.Pos()\n                                l.push(scCOMMENT)\n\n<COMMENT>{comment-close}        l.pop()\n\t\t\t\tl.First = lex.NewChar(l.commentPos0, l.First.Rune)\n\t\t\t\tl.comment(true)\n\t\t\t\treturn ' '\n\n<COMMENT>{eof}                  l.report.Err(l.commentPos0, commentNotClosed)\n                                l.pop()\n                                return rune2class(lex.RuneEOF)\n\n<*>{eof}                        return rune2class(lex.RuneEOF)\n\n\"!=\"                            return NEQ\n\"%:\"                            return '#'\n\"%=\"                            return MODASSIGN\n\"%>\"                            return '}'\n\"&&\"                            return ANDAND\n\"&=\"                            return ANDASSIGN\n\"*=\"                            return MULASSIGN\n\"++\"                            return INC\n\"+=\"                            return ADDASSIGN\n\"--\"                            return DEC\n\"-=\"                            return SUBASSIGN\n\"->\"                            return ARROW\n\"...\"                           return DDD\n\"/=\"                            return DIVASSIGN\n\":>\"                            return ']'\n\"<%\"                            return '{'\n\"<:\"                            return '['\n\"<<\"                            return LSH\n\"<<=\"                           return LSHASSIGN\n\"<=\"                            return LEQ\n\"==\"                            return EQ\n\">=\"                            return GEQ\n\">>\"                            return RSH\n\">>=\"                           return RSHASSIGN\n\"^=\"                            return XORASSIGN\n\"|=\"                            return ORASSIGN\n\"||\"                            return OROR\n\n\"##\"                            |\n\"#%:\"                           |\n\"%:#\"                           |\n\"%:%:\"                          return PPPASTE\n\n\n<DIRECTIVE>\"define\"             l.pop(); return PPDEFINE\n<DIRECTIVE>\"elif\"               l.pop(); return PPELIF\n<DIRECTIVE>\"else\"               l.pop(); return PPELSE\n<DIRECTIVE>\"endif\"              l.pop(); return PPENDIF\n<DIRECTIVE>\"error\"              l.pop(); return PPERROR\n<DIRECTIVE>\"if\"                 l.pop(); return PPIF\n<DIRECTIVE>\"ifdef\"              l.pop(); return PPIFDEF\n<DIRECTIVE>\"ifndef\"             l.pop(); return PPIFNDEF\n<DIRECTIVE>\"include\"            l.pop(); return PPINCLUDE\n<DIRECTIVE>\"include_next\"       l.pop(); return PPINCLUDE_NEXT\n<DIRECTIVE>\"line\"               l.pop(); return PPLINE\n<DIRECTIVE>\"pragma\"             l.pop(); return PPPRAGMA\n<DIRECTIVE>\"undef\"              l.pop(); return PPUNDEF\n\n<HEADER>{header-name}           l.sc = scINITIAL\n                                return PPHEADER_NAME\n\nL{character-constant}           return LONGCHARCONST\nL{string-literal}               return LONGSTRINGLITERAL\n{character-constant}            return CHARCONST\n{identifier}                    return IDENTIFIER\n<DEFINE>{identifier}\"(\"         return IDENTIFIER_LPAREN\n{integer-constant}              return INTCONST\n{floating-constant}             return FLOATCONST\n{pp-number}                     return PPNUMBER\n{string-literal}                return STRINGLITERAL\n\n%%\n        if c, ok := l.Abort(); ok {\n                return c\n        }\n        \n        goto yyAction\n}\n"
  },
  {
    "path": "scope_string.go",
    "content": "// Code generated by \"stringer -type Scope\"; DO NOT EDIT.\n\npackage cc\n\nimport \"fmt\"\n\nconst _Scope_name = \"ScopeFileScopeBlockScopeMembersScopeParams\"\n\nvar _Scope_index = [...]uint8{0, 9, 19, 31, 42}\n\nfunc (i Scope) String() string {\n\tif i < 0 || i >= Scope(len(_Scope_index)-1) {\n\t\treturn fmt.Sprintf(\"Scope(%d)\", i)\n\t}\n\treturn _Scope_name[_Scope_index[i]:_Scope_index[i+1]]\n}\n"
  },
  {
    "path": "testdata/anon.c",
    "content": "// Invalid anonymous field should raise an error but not panic.\n\nstruct {\n\t_Bool;\n};\n"
  },
  {
    "path": "testdata/arith-1.c",
    "content": "/* Preprocessor arithmetic semantic tests.  */\n\n/* Copyright (C) 2002 Free Software Foundation, Inc.  */\n/* Source: Neil Booth, 25 May 2002.  */\n\n/* The file tests all aspects of preprocessor arithmetic that are\n   independent of target precision.  */\n\n/* { dg-do preprocess } */\n/* { dg-options \"\" } */\n\n/* Test || operator and its short circuiting.  */\n#if 0 || 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 5 || 0\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0 || 1\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 || 4\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 || (8 / 0) /* { dg-bogus \"division by zero\" }  */\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 || (1 << 256) /* { dg-bogus \"overflow\" }  */\n#endif\n\n/* Test && operator and its short circuiting.  */\n#if (0 && 0) || (0 && 1) || (1 && 0)\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 && 2\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0 && (8 / 0)/* { dg-bogus \"division by zero\" }  */\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0 && (1 << 256) /* { dg-bogus \"overflow\" }  */\n#endif\n\n/* Test == and != operators, and their signedness.  */\n#if 1 == 0 || 0 == 1 || 20 != 0x014 || 142 != 0216\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (1 == 1) - 2 > 0 || (1U != 1U) - 2 > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test ? : operator, its short circuiting, and its signedness.  */\n#if (1 ? 3: 5) != 3 || (0 ? 3: 5) != 5\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 ? 0: 1 / 0 /* { dg-bogus \"division by zero\" }  */\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0 ? 1 / 0: 0 /* { dg-bogus \"division by zero\" }  */\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0 ? (1 << 256): 0 /* { dg-bogus \"overflow\" }  */\n#endif\n\n#if 1 ? 0: (1 << 256) /* { dg-bogus \"overflow\" }  */\n#endif\n\n/* Test unary + and its signedness.  */\n\n#if 23 != +23 || 23 != + +23\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (+1 - 2) > 0 || (+1U - 2) < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test unary - and its signedness.  */\n\n#if -1 + 1 != 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if -1 >= 0 || -1U <= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test unary ! and its signedness.  */\n#if !5 != 0 || !1 != 0 || !0 != 1\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if !5 - 1 > 0 || !5U - 1 > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test unary ~ and its signedness.  */\n#if ~0 != -1 || ~~5 != 5 || ~-2 != 1\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if ~5 > 0 || ~5U < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test comparison operators and their signedness.  */\n#if 1 >= 1 && 2 >= 1 && -1 >= -1 && -1 >= -2 && 1 >= -1 && 1 >= -2 \\\n    && !(-2 >= -1) && !(2 >= 3) && -1U >= 2 && !(-1 >= 1)\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if ((1 > 0) - 2) > 0 || ((1U > 0) - 2) > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if !(1 > 1) && 2 > 1 && !(-1 > -1) && -1 > -2 && 1 > -1 && 1 > -2 \\\n    && !(-2 > -1) && !(2 > 3) && -1U > 2 && !(-1 > 1)\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if ((1 >= 0) - 2) > 0 || ((1U >= 0) - 2) > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 1 <= 1 && !(2 <= 1) && -1 <= -1 && !(-1 <= -2) && !(1 <= -1) && !(1 <= -2) \\\n    && -2 <= -1 && 2 <= 3 && !(-1U <= 2) && -1 <= 1\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if ((1 <= 0) - 2) > 0 || ((1U <= 0) - 2) > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if !(1 < 1) && !(2 < 1) && !(-1 < -1) && !(-1 < -2) && !(1 < -1) && !(1 < -2) \\\n    && -2 < -1 && 2 < 3 && !(-1U < 2) && -1 < 1\n#else\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if ((1 < 0) - 2) > 0 || ((1U < 0) - 2) > 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test bitwise operators and their signedness.  */\n#if (3 & 7) != 3 || (-1 & 34) != 34\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 & 7) - 20 > 0 || (3 & 7U) - 20 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 | 5) != 7 || (-1 | 34) != -1\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 | 7) - 20 > 0 || (3 | 7U) - 20 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (7 ^ 5) != 2 || (-1 ^ 34) != ~34\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 ^ 7) - 20 > 0 || (3 ^ 7U) - 20 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test shifts and their signedness.  */\n#if 3 << 2 != 12 || 3 << -2 != 0 || -1 << 1 != -2\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 5 >> 1 != 2 || 5 >> -2 != 20 || -5 >> 1 != -3\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (5 >> 2) - 2 >= 0 || (5U >> 2) - 2 <= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (5 << 1) - 20 >= 0 || (5U << 1) - 20 <= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 0\n/* Test min / max and their signedness.  */\n#if (3 >? 2) != 3 || (-3 >? -2) != -2\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 <? 2) != 2 || (-3 <? -2) != -3\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 >? 2) - 4 >= 0 || (3 >? 2U) - 4 <= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (3 <? 2) - 4 >= 0 || (3 <? 2U) - 4 <= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n#endif\n\n/* Test *, / and % and their signedness.  */\n#if 3 * 2 != 6 || 3 * -2 != -6 || -2 * 3 != -6 || -2 * -3 != 6\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 3 * 2 - 7 >= 0 || 3 * 2U - 7 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 5 / 2 != 2 || -325 / 50 != -6 || 53 / -4 != -13 || -55 / -12 != 4\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 3 / 2 - 7 >= 0 || 3 / 2U - 7 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 5 % 2 != 1 || -325 % 50 != -25 || 53 % -4 != 1 || -55 % -12 != -7\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if 3 % 2 - 7 >= 0 || 3U % 2 - 7 < 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n/* Test , and its signedness.  */\n#if (1, 2) != 2 || (2, 1) != 1\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n\n#if (1, 2) - 3 >= 0 || (1, 2U) - 3 <= 0 || (1U, 2) - 3 >= 0\n# error\t\t/* { dg-bogus \"error\" }  */\n#endif\n"
  },
  {
    "path": "testdata/arith-1.h",
    "content": "#include \"arith-1.c\"\nint i;\n"
  },
  {
    "path": "testdata/array.c",
    "content": "char a[];\n\nvoid f() {\n\ta;\n}\n\nchar a[] = \"foo\";\n"
  },
  {
    "path": "testdata/empty.c",
    "content": "#define m(x) #x\n#define n(x, y) #x\n#define o(x, y) #y\n#define p(x, y, z) #y\n\nchar s[] = m();\nchar t[] = n(, 42);\nchar u[] = o(42,);\nchar v[] = p(42,,314);\n"
  },
  {
    "path": "testdata/enum.c",
    "content": "#define K 278\n\nenum {\n\tc = 42 - 24,\n\td = 314 + K,\n} foo;\n\n"
  },
  {
    "path": "testdata/example-6.10.3.3-4.h",
    "content": "#define hash_hash # ## #\n#define mkstr(a) # a\n#define in_between(a) mkstr(a)\n#define join(c, d) in_between(c hash_hash d)\nchar p[] = join(x, y);\t// equivalent to\n\t\t\t// char p[] = \"x ## y\";\n"
  },
  {
    "path": "testdata/example-6.10.3.5-3.h",
    "content": "#define x\t3\n#define f(a)\tf(x * (a))\n#undef\tx\n#define x\t2\n#define g\tf\n#define z\tz[0]\n#define\th\tg(~\n#define\tm(a)\ta(w)\n#define w\t0,1\n#define\tt(a)\ta\n#define p()\tint\n#define\tq(x)\tx\n#define\tr(x,y)\tx ## y\n#define\tstr(x)\t# x\n\nf(y+1) + f(f(z)) % t(t(g)(0) + t)(1);\ng(x+(3,4)-w) | h 5) & m\n\t(f)^m(m);\np() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\nchar c[2][6] = { str(hello), str() };\n"
  },
  {
    "path": "testdata/example-6.10.3.5-4.h",
    "content": "#define str(s)\t\t# s\n#define xstr(s)\t\tstr(s)\n#define debug(s, t)\tprintf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n\t\t\t\tx ## s, x ## t)\n#define INCFILE(n)\tvers ## n\n#define glue(a, b)\ta ## b\n#define xglue(a, b)\tglue(a, b)\n#define HIGHLOW\t\t\"hello\"\n#define LOW\t\tLOW \", world\"\n\ndebug(1, 2);\nfputs(str(strncmp(\"abc\\0d\", \"abc\", '\\4') // this goes away\n\t== 0) str(: @\\n), s);\n#include xstr(INCFILE(2).h)\nglue(HIGH, LOW);\nxglue(HIGH, LOW)\n"
  },
  {
    "path": "testdata/example-6.10.3.5-5.h",
    "content": "#define t(x,y,z) x ## y ## z\nint j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n\tt(10,,), t(,11,), t(,,12), t(,,) };\n"
  },
  {
    "path": "testdata/example-6.10.3.5-6.h",
    "content": "#define OBJ_LIKE\t(1-1)\n#define OBJ_LIKE\t/* white space */ (1-1) /* other */\n#define FUNC_LIKE(a)\t( a )\n#define FUNC_LIKE( a )\t( /* note the white space */ a /* other stuff on this line */ )\n#define FUNC_LIKE( a )\t( /* note the white space */ \\\n\t\t\ta /* other stuff on this line\n\t\t\t*/ )\nok\n"
  },
  {
    "path": "testdata/example-6.10.3.5-7.h",
    "content": "#define debug(...)\t\tfprintf(stderr, __VA_ARGS__)\n#define showlist(...)\t\tputs(#__VA_ARGS__)\n#define report(test, ...) \t((test)?puts(#test):\\\n\t\t\t\tprintf(__VA_ARGS__))\n\ndebug(\"Flag\");\ndebug(\"X = %d\\n\", x);\nshowlist(The first, second, and third items.);\nreport(x>y, \"x is %d but y is %d\", x, y);\n"
  },
  {
    "path": "testdata/func.c",
    "content": "void f(char *) {\n\tf(__func__);\n}\n"
  },
  {
    "path": "testdata/funcfunc.c",
    "content": "// Declare f as function (char) returning pointer to function (int) returning long.\n//\n// http://cdecl.ridiculousfish.com/?q=long+%28*f%28char%29%29+%28int%29%3B\n//\nlong (*f(char c))(int i) { char d = c; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/COPYING",
    "content": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Library General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\f\n\t\t    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\f\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\f\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\f\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n\t    How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year  name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Library General\nPublic License instead of this License.\n"
  },
  {
    "path": "testdata/gcc-6.3.0/COPYING.LIB",
    "content": "\n                  GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n\t51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations\nbelow.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\f\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it\nbecomes a de-facto standard.  To achieve this, non-free programs must\nbe allowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\f\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control\ncompilation and installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\f\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\f\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at least\n    three years, to give the same user the materials specified in\n    Subsection 6a, above, for a charge no more than the cost of\n    performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\f\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\f\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply, and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License\nmay add an explicit geographical distribution limitation excluding those\ncountries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\f\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\f\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms\nof the ordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.\nIt is safest to attach them to the start of each source file to most\neffectively convey the exclusion of warranty; and each file should\nhave at least the \"copyright\" line and a pointer to where the full\nnotice is found.\n\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or\nyour school, if any, to sign a \"copyright disclaimer\" for the library,\nif necessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James\n  Random Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/COPYING.RUNTIME",
    "content": "GCC RUNTIME LIBRARY EXCEPTION\n\nVersion 3.1, 31 March 2009\n\nCopyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>\n\nEveryone is permitted to copy and distribute verbatim copies of this\nlicense document, but changing it is not allowed.\n\nThis GCC Runtime Library Exception (\"Exception\") is an additional\npermission under section 7 of the GNU General Public License, version\n3 (\"GPLv3\"). It applies to a given file (the \"Runtime Library\") that\nbears a notice placed by the copyright holder of the file stating that\nthe file is governed by GPLv3 along with this Exception.\n\nWhen you use GCC to compile a program, GCC may combine portions of\ncertain GCC header files and runtime libraries with the compiled\nprogram. The purpose of this Exception is to allow compilation of\nnon-GPL (including proprietary) programs to use, in this way, the\nheader files and runtime libraries covered by this Exception.\n\n0. Definitions.\n\nA file is an \"Independent Module\" if it either requires the Runtime\nLibrary for execution after a Compilation Process, or makes use of an\ninterface provided by the Runtime Library, but is not otherwise based\non the Runtime Library.\n\n\"GCC\" means a version of the GNU Compiler Collection, with or without\nmodifications, governed by version 3 (or a specified later version) of\nthe GNU General Public License (GPL) with the option of using any\nsubsequent versions published by the FSF.\n\n\"GPL-compatible Software\" is software whose conditions of propagation,\nmodification and use would permit combination with GCC in accord with\nthe license of GCC.\n\n\"Target Code\" refers to output from any compiler for a real or virtual\ntarget processor architecture, in executable form or suitable for\ninput to an assembler, loader, linker and/or execution\nphase. Notwithstanding that, Target Code does not include data in any\nformat that is used as a compiler intermediate representation, or used\nfor producing a compiler intermediate representation.\n\nThe \"Compilation Process\" transforms code entirely represented in\nnon-intermediate languages designed for human-written code, and/or in\nJava Virtual Machine byte code, into Target Code. Thus, for example,\nuse of source code generators and preprocessors need not be considered\npart of the Compilation Process, since the Compilation Process can be\nunderstood as starting with the output of the generators or\npreprocessors.\n\nA Compilation Process is \"Eligible\" if it is done using GCC, alone or\nwith other GPL-compatible software, or if it is done without using any\nwork based on GCC. For example, using non-GPL-compatible Software to\noptimize any GCC intermediate representations would not qualify as an\nEligible Compilation Process.\n\n1. Grant of Additional Permission.\n\nYou have permission to propagate a work of Target Code formed by\ncombining the Runtime Library with Independent Modules, even if such\npropagation would otherwise violate the terms of GPLv3, provided that\nall Target Code was generated by Eligible Compilation Processes. You\nmay then convey such a combination under terms of your choice,\nconsistent with the licensing of the Independent Modules.\n\n2. No Weakening of GCC Copyleft.\n\nThe availability of this Exception does not imply any general\npresumption that third-party software is unaffected by the copyleft\nrequirements of the license of GCC.\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/COPYING3",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "testdata/gcc-6.3.0/COPYING3.LIB",
    "content": "\t\t   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions. \n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version. \n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "testdata/gcc-6.3.0/README",
    "content": "This directory contains the GNU Compiler Collection (GCC).\n\nThe GNU Compiler Collection is free software.  See the files whose\nnames start with COPYING for copying permission.  The manuals, and\nsome of the runtime libraries, are under different terms; see the\nindividual source files for details.\n\nThe directory INSTALL contains copies of the installation information\nas HTML and plain text.  The source of this information is\ngcc/doc/install.texi.  The installation information includes details\nof what is included in the GCC sources and what files GCC installs.\n\nSee the file gcc/doc/gcc.texi (together with other files that it\nincludes) for usage and porting information.  An online readable\nversion of the manual is in the files gcc/doc/gcc.info*.\n\nSee http://gcc.gnu.org/bugs/ for how to report bugs usefully.\n\nCopyright years on GCC source files may be listed using range\nnotation, e.g., 1987-2012, indicating that every year in the range,\ninclusive, is a copyrightable year that could otherwise be listed\nindividually.\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/strct-layout.c",
    "content": "typedef struct\n{\n  char a;\n  int b;\n  char c;\n  short d;\n  double e;\n  char f;\n} T;\n\n#if COMPILER != 1\nf (T *x)\n{\n  x[0].a = 'a';\n  x[0].b = 47114711;\n  x[0].c = 'c';\n  x[0].d = 1234;\n  x[0].e = 3.141592897932;\n  x[0].f = '*';\n\n  x[1].a = 'A';\n  x[1].b = 71417141;\n  x[1].c = 'C';\n  x[1].d = 4321;\n  x[1].e = 2.718281828459;\n  x[1].f = '?';\n}\n#endif\n\n#if COMPILER != 2\ng (T *x)\n{\n  if (x[0].a != 'a')\n    abort ();\n  if (x[0].b != 47114711)\n    abort ();\n  if (x[0].c != 'c')\n    abort ();\n  if (x[0].d != 1234)\n    abort ();\n  if (x[0].e != 3.141592897932)\n    abort ();\n  if (x[0].f != '*')\n    abort ();\n\n  if (x[1].a != 'A')\n    abort ();\n  if (x[1].b != 71417141)\n    abort ();\n  if (x[1].c != 'C')\n    abort ();\n  if (x[1].d != 4321)\n    abort ();\n  if (x[1].e != 2.718281828459)\n    abort ();\n  if (x[1].f != '?')\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  T x[2];\n  f (x);\n  g (x);\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-align.c",
    "content": "typedef union\n{\n  struct {int a; int b;} s;\n  double d;\n} T;\n\nint h (T *);\nT g (T);\n\n#if COMPILER != 1\nh (T *x)\n{\n  if (x->s.a != 0 || x->s.b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nT\ng (T x)\n{\n  if (x.s.a != 13 || x.s.b != 47)\n    abort ();\n  x.s.a = 0;\n  x.s.b = 1;\n  h (&x);\n  return x;\n}\n#endif\n\n#if COMPILER != 1\nf ()\n{\n  T x;\n  x.s.a = 13;\n  x.s.b = 47;\n  g (x);\n  if (x.s.a != 13 || x.s.b != 47)\n    abort ();\n  x = g (x);\n  if (x.s.a != 0 || x.s.b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  f ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-big.c",
    "content": "typedef struct {int a, b, c, d, e;} T;\n\nint h (T *);\nT g (T);\n\n#if COMPILER != 1\nh (T *x)\n{\n  if (x->a != 0 || x->b != 1 || x->c != 2 || x->d != 3 || x->e != 4)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nT\ng (T x)\n{\n  if (x.a != 13 || x.b != 47 || x.c != 123456 || x.d != -4711 || x.e != -2)\n    abort ();\n  x.a = 0;\n  x.b = 1;\n  x.c = 2;\n  x.d = 3;\n  x.e = 4;\n  h (&x);\n  return x;\n}\n#endif\n\n#if COMPILER != 1\nf ()\n{\n  T x;\n  x.a = 13;\n  x.b = 47;\n  x.c = 123456;\n  x.d = -4711;\n  x.e = -2;\n  g (x);\n  if (x.a != 13 || x.b != 47 || x.c != 123456 || x.d != -4711 || x.e != -2)\n    abort ();\n  x = g (x);\n  if (x.a != 0 || x.b != 1 || x.c != 2 || x.d != 3 || x.e != 4)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  f ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-i.c",
    "content": "typedef struct {int a;} T;\n\nint h (T *);\nT g (T);\n\n#if COMPILER != 1\nh (T *x)\n{\n  if (x->a != 47114711)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nT\ng (T x)\n{\n  if (x.a != 13)\n    abort ();\n  x.a = 47114711;\n  h (&x);\n  return x;\n}\n#endif\n\n#if COMPILER != 1\nf ()\n{\n  T x;\n  x.a = 13;\n  g (x);\n  if (x.a != 13)\n    abort ();\n  x = g (x);\n  if (x.a != 47114711)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  f ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-ic.c",
    "content": "typedef struct {int a; char b;} T;\n\nint h (T *);\nT g (T);\n\n#if COMPILER != 1\nh (T *x)\n{\n  if (x->a != 0 || x->b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nT\ng (T x)\n{\n  if (x.a != 13 || x.b != 47)\n    abort ();\n  x.a = 0;\n  x.b = 1;\n  h (&x);\n  return x;\n}\n#endif\n\n#if COMPILER != 1\nf ()\n{\n  T x;\n  x.a = 13;\n  x.b = 47;\n  g (x);\n  if (x.a != 13 || x.b != 47)\n    abort ();\n  x = g (x);\n  if (x.a != 0 || x.b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  f ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-ii.c",
    "content": "typedef struct {int a, b;} T;\n\nint h (T *);\nT g (T);\n\n#if COMPILER != 1\nh (T *x)\n{\n  if (x->a != 0 || x->b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nT\ng (T x)\n{\n  if (x.a != 13 || x.b != 47)\n    abort ();\n  x.a = 0;\n  x.b = 1;\n  h (&x);\n  return x;\n}\n#endif\n\n#if COMPILER != 1\nf ()\n{\n  T x;\n  x.a = 13;\n  x.b = 47;\n  g (x);\n  if (x.a != 13 || x.b != 47)\n    abort ();\n  x = g (x);\n  if (x.a != 0 || x.b != 1)\n    abort ();\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  f ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compat/struct-ret-1.c",
    "content": "typedef struct { int re; int im; } T;\n\nT f (int, int);\n\n#if COMPILER != 1\nT\nf (int arg1, int arg2)\n{\n  T x;\n  x.re = arg1;\n  x.im = arg2;\n  return x;\n}\n#endif\n\n#if COMPILER != 2\nmain ()\n{\n  T result;\n  result = f (3, 4);\n  if (result.re != 3 || result.im != 4)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000105-1.c",
    "content": "main(int na, char* argv[])\n{\n\tint wflg = 0, tflg = 0;\n\tint dflg = 0;\n\texit(0);\n\twhile(1)\n\t{\n\t\tswitch(argv[1][0])\n\t\t{\n\t\t\thelp:\n\t\t\t\texit(0);\n\t\t\tcase 'w':\n\t\t\tcase 'W':\n\t\t\t\twflg = 1;\n\t\t\t\tbreak;\n\t\t\tcase 't':\n\t\t\tcase 'T':\n\t\t\t\ttflg = 1;\n\t\t\t\tbreak;\n\t\t\tcase 'd':\n\t\t\t\tdflg = 1;\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000105-2.c",
    "content": "foo ()\n{\n  long long int i = (int) \"\";\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000120-1.c",
    "content": "extern char letters[26+1];\nchar letter;\nint letter_number;\nchar letters[] = \"AbCdefghiJklmNopQrStuVwXyZ\";\n\nstatic void\npad_home1 ()\n{\n  letter = letters[letter_number =\n\t\t   letters[letter_number + 1] ? letter_number +\n\t\t   1 : 0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000120-2.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern __inline__ int\nodd(int i)\n{\n  return i & 0x1;\n}\n\nint\nfoo(int i, int j)\n{\n  return odd(i + j);\n}\n\nint\nodd(int i)\n{\n  return i & 0x1;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000127-1.c",
    "content": "double bar(void), c;\nint foo(void) {\n\tdouble a, b;\n\tint i = bar() + bar();\n\ta = i; i += 1; a += 0.1; i = c + i;\n\treturn i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000211-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef unsigned char Bufbyte;\ntypedef int Bytecount;\ntypedef int Charcount;\ntypedef struct lstream Lstream;\ntypedef int  Lisp_Object;\nextern Lisp_Object Qnil;\nextern inline  int\nTRUE_LIST_P (Lisp_Object object)\n{\n  return ((  object  ) == (  Qnil ))  ;\n}\nstruct Lisp_String\n{\n  Bytecount _size;\n  Bufbyte *_data;\n};\ntypedef enum lstream_buffering\n{\n  LSTREAM_LINE_BUFFERED,\n} Lstream_buffering;\nstruct lstream\n{\n  Lstream_buffering buffering;  \n  unsigned char *out_buffer;  \n  size_t out_buffer_size;  \n  size_t out_buffer_ind;  \n  size_t byte_count;\n  long flags;   \n  char data[1];\n};\ntypedef struct printf_spec printf_spec;\nstruct printf_spec\n{\n};\ntypedef union printf_arg printf_arg;\nunion printf_arg\n{\n};\ntypedef struct\n{\n   int cur;\n} printf_spec_dynarr;\ntypedef struct\n{\n} printf_arg_dynarr;\nstatic void\ndoprnt_1 (Lisp_Object stream, const  Bufbyte *string, Bytecount len,\n\t  Charcount minlen, Charcount maxlen, int minus_flag, int zero_flag)\n{\n  Charcount cclen;\n  Bufbyte pad;\n  Lstream *lstr = ((  struct lstream  *) ((void *)((((    stream    ) & ((1UL << ((4   * 8 )  - 4 ) ) - 1UL) ) ) | 0x40000000 )) )  ;\n  cclen = (  len ) ;\n  if (zero_flag)\n    pad = '0';\n  pad = ' ';\n#if 0\n  if (minlen > cclen && !minus_flag)\n#endif\n    {\n      int to_add = minlen - cclen;\n      while (to_add > 0)\n\t{\n\t  (( lstr )->out_buffer_ind >= ( lstr )->out_buffer_size ?\tLstream_fputc ( lstr ,   pad ) :\t(( lstr )->out_buffer[( lstr )->out_buffer_ind++] =\t(unsigned char) (  pad ),\t( lstr )->byte_count++,\t( lstr )->buffering == LSTREAM_LINE_BUFFERED &&\t( lstr )->out_buffer[( lstr )->out_buffer_ind - 1] == '\\n' ?\tLstream_flush_out ( lstr ) : 0)) ;\n\t  to_add--;\n\t}\n    }\n  if (maxlen >= 0)\n    len = (  ((( maxlen ) <= (  cclen )) ? ( maxlen ) : (  cclen ))  ) ;\n  Lstream_write (lstr, string, len);\n  if (minlen > cclen && minus_flag)\n    {\n      int to_add = minlen - cclen;\n      while (to_add > 0)\n\t{\n\t  (( lstr )->out_buffer_ind >= ( lstr )->out_buffer_size ?\tLstream_fputc ( lstr ,   pad ) :\t(( lstr )->out_buffer[( lstr )->out_buffer_ind++] =\t(unsigned char) (  pad ),\t( lstr )->byte_count++,\t( lstr )->buffering == LSTREAM_LINE_BUFFERED &&\t( lstr )->out_buffer[( lstr )->out_buffer_ind - 1] == '\\n' ?\tLstream_flush_out ( lstr ) : 0)) ;\n\t  to_add--;\n\t}\n    }\n}\nstatic Bytecount\nemacs_doprnt_1 (Lisp_Object stream, const  Bufbyte *format_nonreloc,\n\t\tLisp_Object format_reloc, Bytecount format_length,\n\t\tint nargs,\n\t\tconst  Lisp_Object *largs)\n{\n  int i;\n  printf_spec_dynarr *specs = 0;\n  format_nonreloc = (( ((  struct Lisp_String  *) ((void *)((((     format_reloc     ) & ((1UL << ((4   * 8 )  - 4 ) ) - 1UL) ) ) | 0x40000000 )) )   )->_data + 0)  ;\n  format_length = (( ((  struct Lisp_String  *) ((void *)((((     format_reloc     ) & ((1UL << ((4   * 8 )  - 4 ) ) - 1UL) ) ) | 0x40000000 )) )   )->_size)  ;\n  specs = parse_doprnt_spec (format_nonreloc, format_length);\n  for (i = 0; i < (( specs )->cur) ; i++)\n    {\n      char ch;\n      doprnt_1 (stream, (Bufbyte *) &ch, 1, 0, -1, 0, 0);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000211-3.c",
    "content": "void f_clos(int x)\n\n{        \n        switch(x) {\n                default:\n                mumble:;\n        }\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000224-1.c",
    "content": "enum Lisp_Type\n{\n  Lisp_Int                     \n  ,Lisp_Record                 \n  ,Lisp_Cons                   \n  ,Lisp_String                 \n  ,Lisp_Vector                 \n  ,Lisp_Symbol\n  ,Lisp_Char                     \n};\ntypedef\nunion Lisp_Object\n  {\n    struct\n      {\n        enum Lisp_Type type: 3L ;\n        unsigned long  markbit: 1;\n        unsigned long  val: 32;\n      } gu;\n    long  i;\n  }\nLisp_Object;\nextern int initialized;\nvoid\ninit_device_faces (int *d)\n{\n  if (initialized)\n    {\n      Lisp_Object tdevice;\n      do {\n          tdevice = (union Lisp_Object)\n                        { gu:\n                          { markbit: 0,\n                            type: Lisp_Record,\n                            val: ((unsigned long )d)\n                          }\n                        };\n      } while (0);\n      call_critical_lisp_code (tdevice);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000314-1.c",
    "content": "struct {\n   char a[5];\n} *p;\n\nint main ()\n{\n   int i = -1;\n   \n   if(p->a[-i])\n     return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000314-2.c",
    "content": "extern void malloc(__SIZE_TYPE__ size); \n\ntoto()\n{\n    malloc(100);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000319-1.c",
    "content": "struct foo\n{\n  long x;\n  char y;\n  long boom[0];\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000326-1.c",
    "content": "long sys_reboot(int magic1, int magic2, int cmd, void * arg)\n{\n  switch (cmd) {\n  case 0x89ABCDEF:\n    return 1;\n\n  case 0x00000000:\n    return 2;\n\n  case 0xCDEF0123:\n    return 3;\n\n  case 0x4321FEDC:\n    return 4;\n\n  case 0xA1B2C3D4:\n    return 5;\n\n  default:\n    return 0;\n  };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000326-2.c",
    "content": "#ifndef NO_LABEL_VALUES\nextern int printk(const char *fmt, ...);\n\nvoid foo (int x, int y)\n{\n  __label__ here;\n  here:\n  printk (\"\", &&here);\n}\n\n#else\nint x;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000329-1.c",
    "content": "int giop_tx_big_endian;\n\ninline\nvoid\ngiop_encode_ulong (unsigned long i, char *buf)\n{\n  if (giop_tx_big_endian)\n    {\n      *(unsigned long *) buf = i;\n    }\n  else\n    {\n      *buf++ = i & 0xff;\n      *buf++ = (i >> 8) & 0xff;\n      *buf++ = (i >> 16) & 0xff;\n      *buf = (i >> 24) & 0xff;\n    }\n}\n\n\n\nstatic\ndouble\ntime_giop_encode (unsigned long l)\n{\n  int c;\n  char buf[4];\n\n  for (c = 0; c < (512 * 1024 * 1024); ++c)\n    {\n      giop_encode_ulong (l, buf);\n    }\n}\n\nint\nmain (int ac, char *av[])\n{\n  giop_tx_big_endian = 1;\n  time_giop_encode (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000403-1.c",
    "content": "struct utsname {\n\tchar\tsysname[32 ];\t \n\tchar\tversion[32 ];\t \n};\nint\nuname(name)\n\tstruct utsname *name;\n{\n\tint mib[2], rval;\n\tlong len;\n\tchar *p;\n\tint oerrno;\n\tif (sysctl(mib, 2, &name->sysname, &len, 0 , 0) == -1)\n\t  ;\n\tfor (p = name->version; len--; ++p) {\n\t\t\t\t*p = ' ';\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000403-2.c",
    "content": "void   \nfoo ()\n{\n long long tmp;\n (( tmp ) = (long long)(  tmp ) >> (  32 )) ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000405-1.c",
    "content": "// Copyright (C) 2000 Free Software Foundation\n\n// by Alexandre Oliva <oliva@lsd.ic.unicamp.br>\n// simplified from libio/floatconv.c\n\nstatic const double bar[] = { 0 };\nint j;\n\ndouble\nfoo ()\n{\n  return bar[j];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000405-2.c",
    "content": "extern void foo (int);\n\nvoid bar (unsigned long l)\n{\n  foo(l == 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000405-3.c",
    "content": "struct foo {\n  void *entry[40];\n} __attribute__ ((aligned(32)));\n\nint foo (struct foo *ptr, int idx, void *pointer)\n{\n  ptr->entry[idx] = pointer;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000412-1.c",
    "content": "typedef struct {\n        short   a;\n        short   b;\n} s1;\n\nextern void g(unsigned char *b);\n\nvoid f(void)\n{\n        s1        a;\n\tunsigned char *b;\n\n        a.a = 0;\n\tb = (unsigned char *)&a;\t\n        g(b);           \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000412-2.c",
    "content": "char list[250][64];\n\nint f(int idx) { return (strlen(list[idx])); }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000420-1.c",
    "content": "struct z_candidate { struct z_candidate *next;int viable;};\nint pedantic;\n\nstatic struct z_candidate *\nsplice_viable (cands)\n     struct z_candidate *cands;\n{\n  struct z_candidate **p = &cands;\n\n  for (; *p; )\n    {\n      if (pedantic ? (*p)->viable == 1 : (*p)->viable)\n        p = &((*p)->next);\n      else\n        *p = (*p)->next;\n    }\n\n  return cands;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000420-2.c",
    "content": "struct x { int a, b, c; };\n\nextern struct x a ();\nextern void b (struct x);\n\nvoid\nfoo ()\n{\n  a ();\n  b (a ());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000427-1.c",
    "content": "int lwidth;                                                                   \nint lheight;                                                                  \nvoid ConvertFor3dDriver (int requirePO2, int maxAspect)       \n{                                                     \n  int oldw = lwidth, oldh = lheight;                      \n\n  lheight = FindNearestPowerOf2 (lheight);            \n  while (lwidth/lheight > maxAspect) lheight += lheight;              \n}                                                                         \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000502-1.c",
    "content": "static int minimum(int a, int b)\n{\n\tif(a < b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\nstatic int a, b;\nstatic inline int foo(void)\n{\n\ta = minimum (a, b);\n\treturn 0;\n}\nstatic int bar(void)\n{\n\treturn foo();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000504-1.c",
    "content": "struct foo {\n\tint a;\n\tint b;\n};\n\nint func(struct foo *foo, int a)\n{\n\tif (foo->b == 0) {\n\t\tint ret = foo->a = a;\n\t\tif (a >= 0)\n\t\t\tfoo->a = a;\n\t\treturn (ret);\n \t}\n\treturn (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000511-1.c",
    "content": "typedef struct {\n  char y;\n  char x[32];\n} X;\n\nint z (void)\n{\n  X xxx;\n  xxx.x[0] =\n  xxx.x[31] = '0';\n  xxx.y = 0xf;\n  return f (xxx, xxx);\n}\n\nint main (void)\n{\n  int val;\n\n  val = z ();\n  if (val != 0x60)\n    abort ();\n  exit (0);\n}\n\nint f(X x, X y)\n{\n  if (x.y != y.y)\n    return 'F';\n\n  return x.x[0] + y.x[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000517-1.c",
    "content": "void test2 (int*, int, int, int);\n\nvoid test ()\n{\n  int l;\n\n  test2 (0, 0, 0, 0);\n  test2 (&l, 0, 0, 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000518-1.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nvoid callit1(void*);\n\nextern __inline__ void test()\n{\n\t__label__ l1;\n\n\tcallit1(&&l1);\n\nl1:;\n\n}\n\n\nvoid dotest()\n{\n\ttest();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000523-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* Contributed by Alexandre Oliva <aoliva@cygnus.com> */\n\nenum { foo = sizeof(void *) };\nint i = sizeof(void *);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000605-1.c",
    "content": "/* Copyright (C) 2000 Free Software Foundation */\n\n/* make sure we don't get confused by various flavors of void */\n\n/* Origin:  Jakub Jelinek  <jakub@redhat.com>\n *          Joel Sherrill <joel.sherrill@OARcorp.com>\n */\n\ntypedef void foo;\nfoo bar(void);\nvoid baz(void)\n{\n  bar();\n}\n\nvoid volatile f();\n\nint x()\n{\n  f();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000606-1.c",
    "content": "typedef struct _foo foo;\nextern foo bar;\nstruct _foo {\n  int a;\n};\n\nvoid baz(void)\n{\n  bar.a = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000609-1.c",
    "content": "int main ()\n{\n  char temp[1024] = \"tempfile\";\n  return temp[0] != 't';\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000629-1.c",
    "content": "struct a\n{\n  struct a * x;\n};\n\nvoid\nfoo (struct a * b)\n{\n  int i;\n\n  for (i = 0; i < 1000; i++)\n    {\n      b->x = b;\n      b++;\n    }\n}\n\nvoid\nbar (struct a * b)\n{\n  int i;\n\n  for (i = 0; i < 1000; i++)\n    {\n      b->x = b;\n      b--;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000701-1.c",
    "content": "void\ndr106_1(void *pv, int i)\n{\n\t*pv;\n\ti ? *pv : *pv;\n\t*pv, *pv;\n}\n\nvoid\ndr106_2(const void *pcv, volatile void *pvv, int i)\n{\n\t*pcv;\n\ti ? *pcv : *pcv;\n\t*pcv, *pcv;\n\n\t*pvv;\n\ti ? *pvv : *pvv;\n\t*pvv, *pvv;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000717-1.c",
    "content": "short\ninner_product (short *a, short *b)\n{\n  int i;\n  short sum = 0;\n\n  for (i = 9; i >= 0; i--)\n    sum += (*a++) * (*b++);\n\n  return sum;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000718.c",
    "content": "extern double foo(double, double);\nextern void bar(float*, int*);\n\nvoid\nbaz(int* arg)\n{\n    float tmp = (float)foo(2.0,1.0);\n    unsigned i;\n    short junk[64];\n\n    for (i=0; i<10; i++, arg++) {\n        bar(&tmp, arg);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000728-1.c",
    "content": "struct clock {\n  long sec; long usec;\n};\n        \nint foo(void)\n{\n  struct clock clock_old = {0, 0};\n\n  for (;;) {\n    long foo;\n\n    if (foo == clock_old.sec && 0 == clock_old.usec);\n  }\n  return 0;\n}\n                                        \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000802-1.c",
    "content": "struct foo {\n  char a[3];\n  char b;\n  char c;\n};\n\nstruct foo bs;\nint x;\nchar y[3];\n\nvoid bar(void)\n{\n    memcpy(bs.a, y, 3);\n    bs.a[1] = ((x ? &bs.b : &bs.c) - (char *)&bs) - 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000803-1.c",
    "content": "static int      gl_cnt = 0;\nstatic char     gl_buf[1024];\n\nvoid\ngl_yank()\n{\n  int  i;\n\n  for (i=gl_cnt; i >= 0; i--)\n    gl_buf[i+10] = gl_buf[i];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000804-1.c",
    "content": "/* This does not work on h8300 due to the use of an asm\n   statement to force a 'long long' (64-bits) to go in a register.  */\n/* { dg-do assemble } */\n/* { dg-skip-if \"\" { { i?86-*-* x86_64-*-* } && { ia32 && { ! nonpic } } } { \"*\" } { \"\" } } */\n/* { dg-skip-if \"No 64-bit registers\" { m32c-*-* } { \"*\" } { \"\" } } */\n/* { dg-skip-if \"Not enough 64-bit registers\" { pdp11-*-* } { \"-O0\" } { \"\" } } */\n/* { dg-xfail-if \"\" { h8300-*-* } { \"*\" } { \"\" } } */\n\n/* Copyright (C) 2000, 2003 Free Software Foundation */\n__complex__ long long f ()\n{\n  int i[99];\n  __complex__ long long v;\n\n  v += f ();\n  asm(\"\": \"+r\" (v) : \"r\" (0), \"r\" (1));\n  v = 2;\n  return v;\n  g (&v);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000818-1.c",
    "content": "void\nfoo (long double x)\n{\n  struct {long double t;} y = {x};\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000825-1.c",
    "content": "typedef signed int      s32;\ntypedef signed long     s64;\ntypedef unsigned int    u32;\ntypedef unsigned long   u64;\n\nextern __inline__ u32 foobar(int logmask)\n{\n        u32 ret = ~(1 << logmask);      // fails\n        // s32 ret = ~(1 << logmask);   // ok\n        // u64 ret = ~(1 << logmask);   // ok\n        // s64 ret = ~(1 << logmask);   // ok\n        return ret;\n}\n\n// This procedure compiles fine...\nu32 good(u32 var)\n{\n        var = foobar(0);\n        return var;\n}\n\n// This procedure does not compile...\n// Same as above, but formal parameter is a pointer\n// Both good() and fails() compile ok if we choose\n// a different type for \"ret\" in foobar().\nu32 fails(u32 *var)\n{\n        *var = foobar(0);\n        return *var;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000827-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* Contributed by Alexandre Oliva <aoliva@redhat.com> */\n\nint\nfoo () \n{\n  while (1)\n    {\n      int a;\n      char b;\n      /* gcse should not merge these asm statements, since their\n\t output operands have different modes.  */\n      __asm__(\"\":\"=r\" (a)); __asm__(\"\":\"=r\" (b));\n      if (b)\n\treturn a;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000922-1.c",
    "content": "extern void doit(int);\nvoid \nquick_doit(int x)\n{\n#ifdef __OPTIMIZE__\n  if (__builtin_constant_p (x)\n      && x != 0)\n    asm volatile (\"%0\" : : \"i#*X\"(x));\n  else\n#endif\n    doit(x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20000923-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nconst int a = 3;\nconst int b = 50;\n\nvoid foo (void)\n{\n  long int x[a][b];\n  asm (\"\" : : \"r\" (x) : \"memory\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001018-1.c",
    "content": "void\nfoo (void)\n{\n  extern char i[10];\n\n  {\n    extern char i[];\n    char x[sizeof (i) == 10 ? 1 : -1];\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001024-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* Contributed by Nathan Sidwell <nathan@codesourcery.com> */\n\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memset(void *, int, size_t);\n\nstruct Baz;\n\nvoid quux(struct Baz *context)\n{\n  memset(context, 0, 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001109-1.c",
    "content": "typedef struct _foo foo;\nextern foo bar;\nstruct _foo {\n  int a;\n};\n\nint tst[__alignof__ (bar) >= __alignof__ (int) ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001109-2.c",
    "content": "extern struct foo bar;\nstruct foo {\n  int a;\n};\n\nint tst[__alignof__ (bar) >= __alignof__ (int) ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001116-1.c",
    "content": "int x[60];\nchar *y = ((char*)&(x[2*8 + 2]) - 8);\nint z = (&\"Foobar\"[1] - &\"Foobar\"[0]);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001121-1.c",
    "content": "extern int bar(int);\n\nint foo(int x)\n{\n  return 1 + bar(\n\t({\n\t\tint y;\n\t\tswitch (x)\n\t\t{\n\t\tcase 0: y = 1; break;\n\t\tcase 1: y = 2; break;\n\t\tcase 2: y = 3; break;\n\t\tcase 3: y = 4; break;\n\t\tcase 4: y = 5; break;\n\t\tcase 5: y = 6; break;\n\t\tdefault: y = 7; break;\n\t\t}\n\t\ty;\n\t})\n     );\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001123-1.c",
    "content": "\ntypedef __builtin_va_list __gnuc_va_list;\ntypedef __gnuc_va_list va_list;\n\nstruct X { int y; };\n\nvoid func(va_list va)\n{\n  char* a = __builtin_va_arg(va, char**)[0];\n  int b = __builtin_va_arg(va, struct X*)->y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001123-2.c",
    "content": "/* Copyright 2000 Free Software Foundation\n\n   by Alexandre Oliva  <aoliva@redhat.com>\n\n   Based on zlib/gzio.c.\n\n   This used to generate duplicate labels when compiled with\n   sh-elf-gcc -O2 -m3 -fPIC.\n\n   Bug reported by NIIBE Yutaka <gniibe@m17n.org>.  */\n\nvoid foo (void);\n\nvoid\nbar ()\n{\n    unsigned len;\n\n    for (len = 0; len < 2; len++)\n\tfoo ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001205-1.c",
    "content": "/* { dg-do assemble } */\n\nstatic inline unsigned long rdfpcr(void)\n{\n        unsigned long tmp, ret;\n        __asm__ (\"\" : \"=r\"(tmp), \"=r\"(ret));\n        return ret;\n}\n\nstatic inline unsigned long\nswcr_update_status(unsigned long swcr, unsigned long fpcr)\n{\n\tswcr &= ~0x7e0000ul;\n        swcr |= (fpcr >> 3) & 0x7e0000ul;\n        return swcr;\n}\n\nunsigned long osf_getsysinfo(unsigned long flags)\n{\n        unsigned long w;\n\tw = swcr_update_status(flags, rdfpcr());\n\treturn w;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001212-1.c",
    "content": "typedef struct\n{\n  long double l;\n} ld;\n\nld a (ld x, ld y)\n{\n  ld b;\n  b.l = x.l + y.l;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001221-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nstatic void\nfoo ()\n{\n  long maplength;\n  int type;\n  {\n    const long nibbles = 8;\n    char buf1[nibbles + 1];\n    char buf2[nibbles + 1];\n    char buf3[nibbles + 1];\n    buf1[nibbles] = '\\0';\n    buf2[nibbles] = '\\0';\n    buf3[nibbles] = '\\0';\n    ((nibbles) <= 16\n     ? (({\n       void *__s = (buf1);\n       union\n\t {\n\t   unsigned int __ui;\n\t   unsigned short int __usi;\n\t   unsigned char __uc;\n\t }\n       *__u = __s;\n       unsigned char __c = (unsigned char)('0');\n       switch ((unsigned int) (nibbles))\n\t {\n\t  case 16:\n\t   __u->__ui = __c * 0x01010101;\n\t   __u = __extension__ ((void *) __u + 4);\n\t  case 12:\n\t   __u->__ui = __c * 0x01010101;\n\t   __u = __extension__ ((void *) __u + 4);\n\t  case 0:\n\t   break;\n\t }\n       __s;\n     }))\n     : 0);\n    ((nibbles) <= 16\n     ? (({\n       void *__s = (buf2);\n       union\n\t {\n\t   unsigned int __ui;\n\t   unsigned short int __usi;\n\t   unsigned char __uc;\n\t }\n       *__u = __s;\n       unsigned char __c = (unsigned char)('0');\n       switch ((unsigned int) (nibbles))\n\t {\n\t  case 16:\n\t   __u->__ui = __c * 0x01010101;\n\t   __u = __extension__ ((void *) __u + 4);\n\t  case 12:\n\t   __u->__ui = __c * 0x01010101;\n\t   __u = __extension__ ((void *) __u + 4);\n\t  case 8:\n\t   __u->__ui = __c * 0x01010101; \n\t   __u = __extension__ ((void *) __u + 4);\n\t  case 4:\n\t   __u->__ui = __c * 0x01010101;\n\t  case 0:\n\t   break;\n\t }\n       __s;\n     }))\n     : 0);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001222-1.c",
    "content": "/* Testcase for PR c/1501. */\ndouble __complex__\nf (void)\n{\n  return ~(1.0 + 2.0i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20001226-1.c",
    "content": "/* { dg-do assemble } */\n/* { dg-skip-if \"too much code for avr\" { \"avr-*-*\" } { \"*\" } { \"\" } } */\n/* { dg-skip-if \"too much code for pdp11\" { \"pdp11-*-*\" } { \"*\" } { \"\" } } */\n/* { dg-xfail-if \"jump beyond 128K not supported\" { xtensa*-*-* } { \"-O0\" } { \"\" } } */\n/* { dg-xfail-if \"PR36698\" { spu-*-* } { \"-O0\" } { \"\" } } */\n/* { dg-skip-if \"\" { m32c-*-* } { \"*\" } { \"\" } } */\n/* { dg-timeout-factor 4.0 } */\n\n/* This testcase exposed two branch shortening bugs on powerpc.  */\n\n#define C(a,b) \\\n  if (a > b)  goto gt; \\\n  if (a < b)  goto lt;\n\n#define C4(x,b) C((x)[0], b) C((x)[1],b) C((x)[2],b) C((x)[3],b)\n#define C16(x,y) C4(x, (y)[0]) C4(x, (y)[1]) C4(x, (y)[2]) C4(x, (y)[3])\n\n#define C64(x,y) C16(x,y) C16(x+4,y) C16(x+8,y) C16(x+12,y)\n#define C256(x,y) C64(x,y) C64(x,y+4) C64(x,y+8) C64(x,y+12)\n\n#define C1024(x,y) C256(x,y) C256(x+16,y) C256(x+32,y) C256(x+48,y)\n#define C4096(x,y) C1024(x,y) C1024(x,y+16) C1024(x,y+32) C1024(x,y+48)\n\nunsigned foo(int x[64], int y[64])\n{\n  C4096(x,y);\n  \n  return 0x01234567;\n gt:\n  return 0x12345678;\n lt:\n  return 0xF0123456;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/200031109-1.c",
    "content": "/* For a short time on the tree-ssa branch this would warn that\n   value was not initialized as it was optimizing !(value = (m?1:2))\n   to 0 and not setting value before.  */\n\nint t(int m)\n{\n  int value;\n  if (!(value = (m?1:2)))\n    value = 0;\n  return value;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010102-1.c",
    "content": "/* This testcase derives from gnu obstack.c/obstack.h and failed with\n   -O3 -funroll-all-loops, or -O1 -frename-registers -funroll-loops on\n   sparc-sun-solaris2.7.\n\n   Copyright (C) 2001  Free Software Foundation.  */\n\n# define PTR_INT_TYPE __PTRDIFF_TYPE__\n\nstruct _obstack_chunk\n{\n  char  *limit;\n  struct _obstack_chunk *prev;\n  char\tcontents[4];\n};\n\nstruct obstack\n{\n  long\tchunk_size;\n  struct _obstack_chunk *chunk;\n  char\t*object_base;\n  char\t*next_free;\n  char\t*chunk_limit;\n  PTR_INT_TYPE temp;\n  int   alignment_mask;\n  struct _obstack_chunk *(*chunkfun) (void *, long);\n  void (*freefun) (void *, struct _obstack_chunk *);\n  void *extra_arg;\n  unsigned use_extra_arg:1;\n  unsigned maybe_empty_object:1;\n  unsigned alloc_failed:1;\n};\n\nextern void _obstack_newchunk (struct obstack *, int);\n\nstruct fooalign {char x; double d;};\n#define DEFAULT_ALIGNMENT  \\\n  ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))\nunion fooround {long x; double d;};\n#define DEFAULT_ROUNDING (sizeof (union fooround))\n\n#ifndef COPYING_UNIT\n#define COPYING_UNIT int\n#endif\n\n#define CALL_CHUNKFUN(h, size) \\\n  (((h) -> use_extra_arg) \\\n   ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \\\n   : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))\n\n#define CALL_FREEFUN(h, old_chunk) \\\n  do { \\\n    if ((h) -> use_extra_arg) \\\n      (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \\\n    else \\\n      (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \\\n  } while (0)\n\nvoid\n_obstack_newchunk (h, length)\n     struct obstack *h;\n     int length;\n{\n  register struct _obstack_chunk *old_chunk = h->chunk;\n  register struct _obstack_chunk *new_chunk;\n  register long\tnew_size;\n  register long obj_size = h->next_free - h->object_base;\n  register long i;\n  long already;\n\n  new_size = (obj_size + length) + (obj_size >> 3) + 100;\n  if (new_size < h->chunk_size)\n    new_size = h->chunk_size;\n\n  new_chunk = CALL_CHUNKFUN (h, new_size);\n  h->chunk = new_chunk;\n  new_chunk->prev = old_chunk;\n  new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;\n\n  if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)\n    {\n      for (i = obj_size / sizeof (COPYING_UNIT) - 1;\n\t   i >= 0; i--)\n\t((COPYING_UNIT *)new_chunk->contents)[i]\n\t  = ((COPYING_UNIT *)h->object_base)[i];\n      already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);\n    }\n  else\n    already = 0;\n  for (i = already; i < obj_size; i++)\n    new_chunk->contents[i] = h->object_base[i];\n\n  if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)\n    {\n      new_chunk->prev = old_chunk->prev;\n      CALL_FREEFUN (h, old_chunk);\n    }\n\n  h->object_base = new_chunk->contents;\n  h->next_free = h->object_base + obj_size;\n  h->maybe_empty_object = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010107-1.c",
    "content": "unsigned long x[4];\n\nvoid foo(void)\n{\n  ((void (*)())(x+2))();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010112-1.c",
    "content": "/* Test that putting an initialized variable in a register works. */\n\n#ifdef __i386__\n#define REGISTER asm (\"eax\")\n#elif defined (__arm__)\n#define REGISTER asm (\"r0\")\n#else\n/* Put examples for other architectures here. */\n#define REGISTER\n#endif\n\nvoid f() {\n  register int i REGISTER = 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010113-1.c",
    "content": "/* Origin: PR c/364 from and@genesyslab.com, very much reduced to a\n   testcase by Joseph Myers <jsm28@cam.ac.uk>.\n\n   The initializer of z is a valid address constant, and GCC 2.95.2\n   accepts it as such.  CVS GCC as of 2001-01-13 rejects it, but accepts\n   it if y is changed to x in the initializer.  */\n\nstruct {\n  struct {\n    int x;\n    int y;\n  } p;\n} v;\n\nint *z = &((&(v.p))->y);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010114-1.c",
    "content": "/* Origin: PR c/166 from Joerg Czeranski <jc@joerch.org>.  */\n/* In the declaration of proc, x cannot be parsed as a typedef name,\n   so it must be parsed as a parameter name.  */\ntypedef int x;\nvoid proc(int (*x)(void)) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010114-2.c",
    "content": "/* Origin: <URL:http://gcc.gnu.org/ml/gcc-patches/2000-12/msg01384.html>\n   from Fred Fish <fnf@geekgadgets.org>.  See also PR c/1625.  */\n\n#include <stdbool.h>\n\nstruct { int x; bool y; } foo = { 0, false };\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010117-1.c",
    "content": "unsigned char u, v, w;\n\nvoid baz (void)\n{\n  if ((u - v - w) & 0x80)\n    v = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010117-2.c",
    "content": "unsigned char a, b;\n\nvoid baz (void)\n{\n  if (b & 0x08)\n    {\n      int g = 0;\n      int c = (b & 0x01);\n      int d = a - g - c;\n      int e = (a & 0x0f) - (g & 0x0f);\n      int f = (a & 0xf0) - (g & 0xf0);\n      int h = (a & 0x0f) - (g & 0x0f);\n\n      if ((a ^ g) & (a ^ d) & 0x80) b |= 0x40;\n      if ((d & 0xff00) == 0) b |= 0x01;\n      if (!((a - h - c) & 0xff)) b |= 0x02;\n      if ((a - g - c) & 0x80) b |= 0x80;\n      a = (e & 0x0f) | (f & 0xf0);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010118-1.c",
    "content": "static unsigned int bar(void *h, unsigned int n)\n{\n  static int i;\n  return i++;\n}\n\nstatic void baz(unsigned int *x)\n{\n  (*x)++;\n}\n\nlong\nfoo(void *h, unsigned int l)\n{\n  unsigned int n;\n  long m;\n  n = bar(h, 0);\n  n = bar(h, n);\n  m = ({ baz(&n); 21; });\n  return m;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010124-1.c",
    "content": "/* Origin: testcase from Joseph Myers <jsm28@cam.ac.uk>, problem pointed\n   out in a post to comp.std.c\n   <980283801.3063.0.nnrp-07.c2deb1c2@news.demon.co.uk>\n   by Dibyendu Majumdar <dibyendu@mazumdar.demon.co.uk>.\n   Compound literals should be parsed as postfix expressions, rather than\n   as cast expressions.  In particular, they are valid operands of sizeof.  */\n\nstruct s { int a; int b; };\nchar x[((sizeof (struct s){ 1, 2 }) == sizeof (struct s)) ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010202-1.c",
    "content": "int foo (int n, char m[1][n]);\n\nint foo (int n, char m[1][n])\n{\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010209-1.c",
    "content": "short int a;\n\nint main (void)\n{\n  a = 65535.0;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010226-1.c",
    "content": "/* { dg-require-effective-target trampolines } */\n\nvoid f1 (void *);\nvoid f3 (void *, void (*)(void *));\nvoid f2 (void *);\n\nint foo (void *a, int b)\n{\n  if (!b)\n    {\n      f1 (a);\n      return 1;\n    }\n  if (b)\n    {\n      void bar (void *c)\n      {\n\tif (c == a)\n\t  f2 (c);\n      }\n      f3 (a, bar);\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010227-1.c",
    "content": "void foo (void)\n{\n  double a = 0.0;\n  double b = a;\n  if (&b != &a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010313-1.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n/* After the open parenthesis before the __attribute__, we used to shift\n   the __attribute__ (expecting a parenthesised abstract declarator)\n   instead of reducing to the start of a parameter list.  */\nvoid bar (int (__attribute__((__mode__(__SI__))) int foo));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010320-1.c",
    "content": "typedef struct sec { \nconst char *name;\nint id;\nint index;\nstruct sec *next;\nunsigned int flags;\nunsigned int user_set_vma : 1;\nunsigned int reloc_done : 1;\nunsigned int linker_mark : 1;\nunsigned int gc_mark : 1;\nunsigned int segment_mark : 1;\nunsigned long long vma; } asection;\n \nstatic void pe_print_pdata (asection *section)\n{\n  unsigned long long i;\n  unsigned long long start = 0, stop = 0;\n  int onaline = (3*8) ;\n\n  for (i = start; i < stop; i += onaline)\n    {\n      if (i + (3*8)  > stop)\n\tbreak;\n\n      f (((unsigned long) (((   i + section->vma  ) >> 32) & 0xffffffff)) , ((unsigned long) (((   i + section->vma  ) & 0xffffffff))) ) ;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010326-1.c",
    "content": "float d;\nint e, f;\n\nvoid foo (void)\n{\n  struct { float u, v; } a = {0.0, 0.0};\n  float b;\n  int c;\n\n  c = e;\n  if (c == 0)\n    c = f;\n  b = d;\n  if (a.v < b)\n    a.v = b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010327-1.c",
    "content": "/* { dg-do compile { target { ptr32plus && { ! llp64 } } } } */\n\n/* This testcase tests whether GCC can produce static initialized data\n   that references addresses of size 'unsigned long', even if that's not\n   the same as __SIZE_TYPE__.  (See 20011114-1.c for the same test of\n   size __SIZE_TYPE__.)  \n\n   Some rare environments might not have the required relocs to support\n   this; they should have this test disabled in the .x file.  */\n\nextern void _text;\nstatic unsigned long x = (unsigned long) &_text - 0x10000000L - 1;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010328-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef unsigned int __u_int;\ntypedef unsigned long __u_long;\n\n__extension__ typedef unsigned long long int __u_quad_t;\n__extension__ typedef long long int __quad_t;\n\ntypedef struct\n  {\n    int __val[2];\n  } __fsid_t;\n\ntypedef long int __blksize_t;\ntypedef long int __blkcnt_t;\ntypedef __quad_t __blkcnt64_t;\ntypedef __u_long __fsblkcnt_t;\ntypedef __u_quad_t __fsblkcnt64_t;\ntypedef __u_long __fsfilcnt_t;\ntypedef __u_quad_t __fsfilcnt64_t;\ntypedef __u_quad_t __ino64_t;\n\nextern void *memcpy (void *__restrict __dest,\n                     __const void *__restrict __src, size_t __n) ;\n\nstruct statfs\n  {\n    int f_type;\n    int f_bsize;\n\n    __fsblkcnt_t f_blocks;\n    __fsblkcnt_t f_bfree;\n    __fsblkcnt_t f_bavail;\n    __fsfilcnt_t f_files;\n    __fsfilcnt_t f_ffree;\n\n    __fsid_t f_fsid;\n    int f_namelen;\n    int f_spare[6];\n  };\n\n\nstruct statfs64\n  {\n    int f_type;\n    int f_bsize;\n    __fsblkcnt64_t f_blocks;\n    __fsblkcnt64_t f_bfree;\n    __fsblkcnt64_t f_bavail;\n    __fsfilcnt64_t f_files;\n    __fsfilcnt64_t f_ffree;\n    __fsid_t f_fsid;\n    int f_namelen;\n    int f_spare[6];\n  };\n\nextern int __statfs (__const char *__file, struct statfs *__buf);\nextern int __statfs64 (__const char *__file, struct statfs64 *__buf);\n\n\nint\n__statfs64 (const char *file, struct statfs64 *buf)\n{\n  struct statfs buf32;\n\n  if (__statfs (file, &buf32) < 0)\n    return -1;\n\n  buf->f_type = buf32.f_type;\n  buf->f_bsize = buf32.f_bsize;\n  buf->f_blocks = buf32.f_blocks;\n  buf->f_bfree = buf32.f_bfree;\n  buf->f_bavail = buf32.f_bavail;\n  buf->f_files = buf32.f_files;\n  buf->f_ffree = buf32.f_ffree;\n  buf->f_fsid = buf32.f_fsid;\n  buf->f_namelen = buf32.f_namelen;\n  memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010329-1.c",
    "content": "union u {\n  unsigned char a;\n  double b;\n};\n\nint a;\n\nunion u foo (void)\n{\n  union u b;\n\n  if (a)\n    b.a = 1;\n  else\n    b.a = 0;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010404-1.c",
    "content": "/* This testcase caused a floating point exception in the compiler when\n   compiled with -O2. The crash occurs when trying to simplify division\n   and modulo operations.  */\n\n#include <limits.h>\n\nextern void bar (int);\n\nvoid foo ()\n{\n  int a = INT_MIN;\n  int b = -1;\n  bar (a / b);\n  bar (a % b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010408-1.c",
    "content": "extern struct win *windows, *wtab[];\nstruct win\n{\n  struct win *w_next;\n};\n\nstruct auser;\n\nstruct comm\n{\n  char *name;\n  int flags;\n};\n\nextern struct comm comms[];\n\nextern int WindowByNoN (char *);\nextern int FindCommnr (char *);\nextern int AclSetPermCmd (struct auser *, char *, struct comm *);\nextern int AclSetPermWin (struct auser *, struct auser *, char *, struct win *);\n\n\nint\n  AclSetPerm(uu, u, mode, s)\n    struct auser *uu, *u;\nchar *mode, *s;\n{\n  struct win *w;\n  int i;\n  char *p, ch;\n\n  do \n    {\n    }\n  while (0);\n\n  while (*s)\n    {\n      switch (*s)\n\t{  \n\tcase '*':\n\t  return AclSetPerm(uu, u, mode, \"#?\");\n\tcase '#':\n\t  if (uu)\n\t    AclSetPermWin(uu, u, mode, (struct win *)1);\n\t  else\n\t    for (w = windows; w; w = w->w_next)\n\t      AclSetPermWin((struct auser *)0, u, mode, w);\n\t  s++;\n\t  break;\n\tcase '?':\n\t  if (uu)\n\t    AclSetPermWin(uu, u, mode, (struct win *)0);\n\t  else\n\t    for (i = 0; i <= 174; i++)\n\t      AclSetPermCmd(u, mode, &comms[i]);\n\t  s++;\n\t  break;\n\tdefault:\n\t  for (p = s; *p && *p != ' ' && *p != '\\t' && *p != ','; p++)\n\t    ;\n\t  if ((ch = *p))\n\t    *p++ = '\\0';\n\t  if ((i = FindCommnr(s)) != -1)\n\t    AclSetPermCmd(u, mode, &comms[i]);\n\t  else if (((i = WindowByNoN(s)) >= 0) && wtab[i])\n\t    AclSetPermWin((struct auser *)0, u, mode, wtab[i]);\n\t  else\n\t    return -1;\n\t  if (ch)\n\t    p[-1] = ch;\n\t  s = p;\n\t}\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010421-1.c",
    "content": "int j;\n\nvoid residual ()\n{\n  long double s;\n  for (j = 3; j < 9; j++)\n    s -= 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010423-1.c",
    "content": "/* Origin: PR c/2618 from Cesar Eduardo Barros <cesarb@nitnet.com.br>,\n   adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n\n   Boolean conversions were causing infinite recursion between convert\n   and fold in certain cases.  */\n\n#include <stdbool.h>\n\nbool x;\nunsigned char y;\n\nvoid\nfn (void)\n{\n  x = y & 0x1 ? 1 : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010426-1.c",
    "content": "struct { char *m; long n; } a[20];\nint b = 20, c;\nvoid bar(void) __attribute__((__noreturn__));\n\nint\nfoo(int x)\n{\n  int i;\n\n  for (i = 0; i < x; i++)\n    {\n      a[0].m = \"a\"; a[0].n = 10; c=1;\n      a[c].m = \"b\"; a[c].n = 32; c++;\n      if (c >= b) bar ();\n      a[c].m = \"c\"; a[c].n = 80; c++;\n      if (c >= b) bar ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010503-1.c",
    "content": "void f1 (double);\nvoid f2 (int);\n\nvoid\nfoo (int type, double xx)\n{\n  if (type)\n    f1 (xx);\n  else\n    f2 (type);\n}\n\nvoid\nbar (int type)\n{\n  foo (type, 1.0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010510-1.c",
    "content": "typedef char *ident;\n#ident \"This is ident\"\nident i;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010518-1.c",
    "content": "/* This was cut down from reload1.c in May 2001, was observed to cause\n   a bootstrap failure for powerpc-apple-darwin1.3.\n\n   Copyright (C) 2001  Free Software Foundation.  */\n\nenum insn_code\n{\n  CODE_FOR_extendqidi2 = 3,\n  CODE_FOR_nothing = 870\n};\n\nstruct rtx_def;\n\nenum machine_mode\n{\n  VOIDmode,\n  MAX_MACHINE_MODE\n};\n\ntypedef unsigned long long HARD_REG_ELT_TYPE;\ntypedef HARD_REG_ELT_TYPE HARD_REG_SET[((77 + (8 * 8) - 1) / (8 * 8))];\n\nenum rtx_code\n{\n  UNKNOWN,\n  NIL,\n  REG,\n  LAST_AND_UNUSED_RTX_CODE = 256\n};\n\ntypedef struct\n{\n  unsigned min_align:8;\n  unsigned base_after_vec:1;\n  unsigned min_after_vec:1;\n  unsigned max_after_vec:1;\n  unsigned min_after_base:1;\n  unsigned max_after_base:1;\n  unsigned offset_unsigned:1;\n  unsigned:2;\n  unsigned scale:8;\n}\naddr_diff_vec_flags;\ntypedef union rtunion_def\n{\n  long long rtwint;\n  int rtint;\n  unsigned int rtuint;\n  const char *rtstr;\n  struct rtx_def *rtx;\n  struct rtvec_def *rtvec;\n  enum machine_mode rttype;\n  addr_diff_vec_flags rt_addr_diff_vec_flags;\n  struct cselib_val_struct *rt_cselib;\n  struct bitmap_head_def *rtbit;\n  union tree_node *rttree;\n  struct basic_block_def *bb;\n}\nrtunion;\ntypedef struct rtx_def\n{\n  enum rtx_code code:16;\n  enum machine_mode mode:8;\n  unsigned int jump:1;\n  unsigned int call:1;\n  unsigned int unchanging:1;\n  unsigned int volatil:1;\n  unsigned int in_struct:1;\n  unsigned int used:1;\n  unsigned integrated:1;\n  unsigned frame_related:1;\n  rtunion fld[1];\n}\n *rtx;\n\nenum reload_type\n{\n  RELOAD_FOR_INPUT, RELOAD_FOR_OUTPUT, RELOAD_FOR_INSN,\n  RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_INPADDR_ADDRESS,\n  RELOAD_FOR_OUTPUT_ADDRESS, RELOAD_FOR_OUTADDR_ADDRESS,\n  RELOAD_FOR_OPERAND_ADDRESS, RELOAD_FOR_OPADDR_ADDR,\n  RELOAD_OTHER, RELOAD_FOR_OTHER_ADDRESS\n};\n\nstruct reload\n{\n  rtx in;\n  rtx out;\n  //  enum reg_class class;\n  enum machine_mode inmode;\n  enum machine_mode outmode;\n  enum machine_mode mode;\n  unsigned int nregs;\n  int inc;\n  rtx in_reg;\n  rtx out_reg;\n  int regno;\n  rtx reg_rtx;\n  int opnum;\n  int secondary_in_reload;\n  int secondary_out_reload;\n  enum insn_code secondary_in_icode;\n  enum insn_code secondary_out_icode;\n  enum reload_type when_needed;\n  unsigned int optional:1;\n  unsigned int nocombine:1;\n  unsigned int secondary_p:1;\n  unsigned int nongroup:1;\n};\n\nstruct insn_chain\n{\n  rtx insn;\n};\n\nextern int n_reloads;\nstatic short reload_order[(2 * 10 * (2 + 1))];\nint reload_spill_index[(2 * 10 * (2 + 1))];\nextern struct reload rld[(2 * 10 * (2 + 1))];\nstatic rtx *reg_last_reload_reg;\nstatic HARD_REG_SET reg_reloaded_valid;\nstatic HARD_REG_SET reg_reloaded_dead;\nstatic HARD_REG_SET reg_reloaded_died;\nstatic HARD_REG_SET reg_is_output_reload;\nextern const unsigned int mode_size[];\nextern int target_flags;\n\nstatic void\nemit_reload_insns (chain)\n     struct insn_chain *chain;\n{\n  rtx insn = chain->insn;\n  register int j;\n  rtx following_insn = (((insn)->fld[2]).rtx);\n  rtx before_insn = (((insn)->fld[1]).rtx);\n\n  for (j = 0; j < n_reloads; j++)\n    {\n      register int r = reload_order[j];\n      register int i = reload_spill_index[r];\n\n\t{\n\t  rtx out = (((enum rtx_code) (rld[r].out)->code) == REG ? rld[r].out : rld[r].out_reg);\n\t  register int nregno = (((out)->fld[0]).rtuint);\n\n\t  if (nregno >= 77)\n\t    {\n\t      rtx src_reg, store_insn = (rtx) 0;\n\n\t      reg_last_reload_reg[nregno] = 0;\n\t      if (src_reg && ((enum rtx_code) (src_reg)->code) == REG && (((src_reg)->fld[0]).rtuint) < 77)\n\t\t{\n\t\t  int src_regno = (((src_reg)->fld[0]).rtuint);\n\t\t  int nr =\n\t\t    (((src_regno) >= 32\n\t\t      && (src_regno) <=\n\t\t      63) ? (((mode_size[(int) (rld[r].mode)]) + 8 -\n\t\t\t      1) / 8) : (((mode_size[(int) (rld[r].mode)]) +\n\t\t\t\t\t  (!(target_flags & 0x00000020) ? 4 :\n\t\t\t\t\t   8) - 1) / (!(target_flags & 0x00000020) ? 4 : 8)));\n\t\t  rtx note = 0;\n\n\t\t  while (nr-- > 0)\n\t\t    {\n\t\t      ((reg_reloaded_dead)\n\t\t       [(src_regno + nr) / ((unsigned) (8 * 8))] &=\n\t\t       ~(((HARD_REG_ELT_TYPE) (1)) << ((src_regno + nr) % ((unsigned) (8 * 8)))));\n\t\t      ((reg_reloaded_valid)\n\t\t       [(src_regno + nr) / ((unsigned) (8 * 8))] |=\n\t\t       ((HARD_REG_ELT_TYPE) (1)) << ((src_regno + nr) % ((unsigned) (8 * 8))));\n\t\t      ((reg_is_output_reload)\n\t\t       [(src_regno + nr) / ((unsigned) (8 * 8))] |=\n\t\t       ((HARD_REG_ELT_TYPE) (1)) << ((src_regno + nr) % ((unsigned) (8 * 8))));\n\t\t      if (note)\n\t\t\t((reg_reloaded_died)\n\t\t\t [(src_regno) / ((unsigned) (8 * 8))] |=\n\t\t\t ((HARD_REG_ELT_TYPE) (1)) << ((src_regno) % ((unsigned) (8 * 8))));\n\t\t      else\n\t\t\t((reg_reloaded_died)\n\t\t\t [(src_regno) / ((unsigned) (8 * 8))] &=\n\t\t\t ~(((HARD_REG_ELT_TYPE) (1)) << ((src_regno) % ((unsigned) (8 * 8)))));\n\t\t    }\n\t\t  reg_last_reload_reg[nregno] = src_reg;\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      int num_regs =\n\t\t(((nregno) >= 32\n\t\t  && (nregno) <=\n\t\t  63)\n\t\t ? (((mode_size\n\t\t      [(int) (((enum machine_mode) (rld[r].out)->mode))]) +\n\t\t     8 -\n\t\t     1) /\n\t\t    8)\n\t\t : (((mode_size\n\t\t      [(int) (((enum machine_mode) (rld[r].out)->mode))]) +\n\t\t     (!(target_flags & 0x00000020) ? 4 : 8) - 1) / (!(target_flags & 0x00000020) ? 4 : 8)));\n\t      while (num_regs-- > 0)\n\t\treg_last_reload_reg[nregno + num_regs] = 0;\n\t    }\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010518-2.c",
    "content": "/* { dg-do compile } */\n\n/* Large static storage.  */\n\n#include <limits.h>\n\nstatic volatile char chars_1[INT_MAX / 2];\nstatic volatile char chars_2[1];\n\nint\nfoo (void)\n{\n  chars_1[10] = 'y';\n  chars_2[0] = 'x';\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010525-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nstatic int kind_varread(char *str)\n{\n  if (0 == memcmp(\"%_#\",               str, 3))  return 2;\n  /* NOTREACHED */\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010605-1.c",
    "content": "int\nmain (int argc, char **argv)\n{\n  int size = 10;\n\n  typedef struct {\n    char val[size];\n  } block;\n  block retframe_block()\n    {\n      return *(block*)0;\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010605-2.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n/* As an extension, GCC allows a struct or union to be cast to its own\n   type, but failed to allow this when a typedef was involved.\n   Reported as PR c/2735 by <cowan@ccil.org>.  */\nunion u { int i; };\ntypedef union u uu;\nunion u a;\nuu b;\n\nvoid\nfoo (void)\n{\n  a = (union u) b;\n  a = (uu) b;\n  b = (union u) a;\n  b = (uu) a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010605-3.c",
    "content": "struct A { unsigned long buf[100]; };\nint foo(unsigned int *x)\n{\n  unsigned int a;\n\n  if (!x)\n    return -22;\n\n#ifdef __ia64__\n  if (({\n    register long b asm (\"r8\") = 0;\n    register long c asm (\"r9\") = 0;\n    asm (\"\" : \"=r\"(c), \"=r\"(b) : \"m\"(*(struct A *)x), \"1\"(b));\n    a = (unsigned int) c;\n    b; }))\n    return -14;\n#endif\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010610-1.c",
    "content": "/* Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu>\n\n   Boolean types were not accepted as array sizes nor as switch\n   quantities.  */\n\n#include <stdbool.h>\n\nint\nmain(void)\n{\n  bool arr[(bool)1];\n  \n  switch (arr[0])\n    {\n    default:;\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010611-1.c",
    "content": "/* Origin: PR c/3116 from Andreas Jaeger <aj@suse.de>.  */\n/* When determining type compatibility of function types, we must remove\n   qualifiers from argument types.  We used to fail to do this properly\n   in store_parm_decls when comparing prototype and non-prototype\n   declarations.  */\nstruct _IO_FILE {\n  int _flags;\n};\n\ntypedef struct _IO_FILE __FILE;\ntypedef struct _IO_FILE _IO_FILE;\ntypedef long int wchar_t;\n\nextern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,\n                        __FILE *__restrict __stream);\n\nwchar_t *\nfgetws (buf, n, fp)\n     wchar_t *buf;\n     int n;\n     _IO_FILE *fp;\n{\n  return (wchar_t *)0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010701-1.c",
    "content": "/* Test that postfix attributes only apply to a single declared object.\n   (decl_attributes used to chain them onto the end of the prefix attributes,\n   which caused them to apply to other declarations as well.)  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\nvoid __attribute__((__noreturn__)) foo (const char *, ...) __attribute__((__format__(__printf__, 1, 2))), bar (void);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010706-1.c",
    "content": "\nfoo(unsigned int x)\n{\n  return (x << 1) | (x >> 31);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010711-1.c",
    "content": "typedef unsigned long long value;\n\nvoid foo (value *v) {}\n\nvoid test ()\n{\n  value v;\n  foo (&v);\n  if (v-- > 0)\n    foo (&v);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010711-2.c",
    "content": "typedef unsigned long long value;\n\nvoid foo (value *v) {}\n\nvoid test ()\n{\n  value v;\n  foo (&v);\n  if (v-- == 1)\n    foo (&v);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010714-1.c",
    "content": "/* Test that prefix attributes after a comma only apply to a single\n   declared object or function.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n\n__attribute__((noreturn)) void d0 (void), __attribute__((format(printf, 1, 2))) d1 (const char *, ...), d2 (void);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010824-1.c",
    "content": "void f(int n)\n{\nbugcauser:\n  if (n != 0)\n    f(n-1);\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010903-1.c",
    "content": "struct A {\n  long a;\n};\n\nstatic inline void foo(struct A *x)\n{\n  __asm__ __volatile__(\"\" : \"+m\"(x->a) : \"r\"(x) : \"memory\", \"cc\");\n}\n\nstatic inline void bar(struct A *x)\n{\n  foo(x);\n}\n\nstruct B { char buf[640]; struct A a; };\nstruct B b[32];\n\nint baz(void)\n{\n  int i;\n  struct B *j;\n  for (i = 1; i < 32; i++)\n    {\n      j = &b[i];\n      bar(&j->a);\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010903-2.c",
    "content": "extern int __dummy (void *__preg, const char *__string);\nextern int rpmatch (const char *response);\n\nint\nrpmatch (const char *response)\n{\n  auto inline int try (void *re);\n\n  inline int try (void *re)\n    {\n      return __dummy (re, response);\n    }\n  static void *yesre;\n  return (try (&yesre));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20010911-1.c",
    "content": "/* Test for segfault handling an empty attribute.  */\n/* Origin: PR c/4294 from <tori@ringstrom.mine.nu>.  */\n\nvoid __attribute__(()) foo();\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011010-1.c",
    "content": "extern int used (void);\n\n\nint foo () \n{\n  int i;\n  for (; used (); ({while (1) if (used ()) return 0;}))\n    i++;\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011023-1.c",
    "content": "/* Test whether tree inlining works with prototyped nested functions.  */\n\nextern void foo (char *x);\nvoid bar (void);\nvoid bar (void)\n{\n  auto void baz (void);\n  void baz (void)\n    {\n      char tmp[2];\n      foo (tmp);\n    }\n  baz ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011029-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nvoid foo (void *) __attribute__ ((noreturn));\n\nvoid\nbar (void *x)\n{\n  if (__builtin_setjmp (x))\n    return;\n  foo (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011106-1.c",
    "content": "/* Test that functions passed to the comma operator are correctly converted\n   to pointers.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n\nvoid foo (void);\nvoid (*fp) (void);\nchar x[sizeof (1, foo) == sizeof (fp) ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011106-2.c",
    "content": "/* Test the type of a component of a conditional expression between\n   two structures is correct.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n\nstruct s { char c; } a, b;\nint c;\nchar x[sizeof ((c ? a : b).c) == 1 ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011109-1.c",
    "content": "typedef struct { short x[4]; } S;\ntypedef struct { unsigned int a, b, c; S *d; } T;\n\nS *(*foo) (T *, int, int, int, int);\nunsigned short *(*bar)(const T *);\nunsigned short baz(T *,const int);\n\nT *die (void)\n{\n  typedef struct { unsigned int a, b, e; double f, g; } U;\n\n  char h[8], i[2053], j[2053];\n  double k, l, m;\n  U n;\n  T *o;\n  unsigned short p;\n  int q, r;\n  long s;\n  unsigned short *t;\n  S *u;\n  unsigned char *v, *w;\n  unsigned int x;\n\n  o = 0;\n  for (x = 0; x < n.e; x++)\n    {\n      l = 1.0;\n      if (n.g - n.f <= 1.0)\n\tl = ((1 << o->c) - 1) / (n.g - n.f);\n      v = w;\n      for (r = o->b - 1; r >= 0; r--)\n\t{\n\t  u = foo (o, 0, r, o->a, 1);\n\t  if (!u)\n\t    break;\n\t  t = bar (o);\n\t  for (q = 0; q < (int) o->a; q++)\n\t    {\n\t      h[0] = *v;\n\t      s = *v++;\n\t      k = (double) s;\n\t      m = l*k;\n\t      p = m < 0 ? 0 : m > (1 << o->c) - 1 ? (1 << o->c) - 1 : m + 0.5;\n\t      p = baz (o,p);\n\t      t[q] = p;\n\t      *u++ = o->d[p];\n\t    }\n\t}\n    }\n  return o;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011114-1.c",
    "content": "extern void _text;\nstatic __SIZE_TYPE__ x = (__SIZE_TYPE__) &_text - 0x10000000L - 1;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011114-2.c",
    "content": "typedef struct { int c, d, e, f, g; } D;\n\nvoid bar (unsigned long, unsigned long);\nvoid foo (D *y)\n{\n  int x = 0;\n\n  if (y->f == 0)\n    x |= 0x1;\n  if (y->g == 0)\n    x |= 0x2;\n  bar ((x << 16) | (y->c & 0xffff), (y->d << 16) | (y->e & 0xffff));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011114-3.c",
    "content": "typedef struct { int s, t; } C;\nC x;\nint foo (void);\nvoid bar (int);\n\nint baz (void)\n{\n  int a = 0, c, d = 0;\n  C *b = &x;\n\n  while ((c = foo ()))\n    switch(c)\n      {\n      case 23:\n\tbar (1);\n\tbreak;\n      default:\n\tbreak;\n      }\n\n  if (a == 0 || (a & 1))\n    {\n      if (b->s)\n\t{\n\t  if (a)\n\t    bar (1);\n\t  else\n\t    a = 16;\n\t}\n      else if (b->t)\n\t{\n\t  if (a)\n\t    bar (1);\n\t  else\n\t    a = 32;\n\t}\n    }\n\n  if (d && (a & ~127))\n    bar (2);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011114-4.c",
    "content": "static inline int foo (long x)\n{\n  register int a = 0;\n  register unsigned b;\n\n  do\n    {\n      b = (x & 0x7f);\n      x = (x >> 7) | ~(-1L >> 7);\n      a += 1;\n    }\n  while ((x != 0 || (b & 0x40) != 0) && (x != -1 || (b & 0x40) == 0));\n  return a;\n}\n\nstatic inline int bar (unsigned long x)\n{\n  register int a = 0;\n  register unsigned b;\n\n  do\n    {\n      b = (x & 0x7f);\n      x >>= 7;\n      a++;\n    }\n  while (x != 0);\n  return a;\n}\n\nint\nbaz (unsigned long x, int y)\n{\n  if (y)\n    return foo ((long) x);\n  else\n    return bar (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011119-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n/* { dg-require-weak \"\" } */\n/* { dg-require-alias \"\" } */\n#define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n#define ASMNAME2(prefix, cname) STRING (prefix) cname\n#define STRING(x)    #x\n\nextern inline int foo (void) { return 23; }\nint xxx(void) __asm__(ASMNAME (\"xxx\"));\nint xxx(void) { return 23; }\nextern int foo (void) __attribute__ ((weak, alias (\"xxx\")));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011119-2.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n/* { dg-require-weak \"\" } */\n/* { dg-require-alias \"\" } */\n#define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n#define ASMNAME2(prefix, cname) STRING (prefix) cname\n#define STRING(x)    #x\n\nextern inline int foo (void) { return 23; }\nint bar (void) { return foo (); }\nextern int foo (void) __attribute__ ((weak, alias (\"xxx\")));\nint baz (void) { return foo (); }\nint xxx(void) __asm__(ASMNAME (\"xxx\"));\nint xxx(void) { return 23; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011130-1.c",
    "content": "struct S { int i; };\nextern struct S x[];\nchar *bar (const struct S *);\nvoid foo (void)\n{\n  bar (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011130-2.c",
    "content": "/* This testcase caused infinite loop in life info computation\n   after if conversion on IA-64.  Conditional register dead for\n   pseudo holding sign-extended k was improperly computed,\n   resulting in this pseudo being live at start of bb if it was\n   dead at the end and vice versa; as it was a bb which had edge\n   to itself, this resulted in alternative propagating this basic\n   block forever.  */\n\ntypedef struct {\n  unsigned char a;\n  unsigned char b;\n} S0;\n\ntypedef struct {\n  S0 *c;\n  int d;\n  unsigned int e;\n  unsigned char *f[3];\n  void *g;\n} S1;\n\nint bar (int, void *);\n\nint foo (S1 *x, float y)\n{\n  S0 *h;\n  int i, j, k, l, m;\n  float n, o, p;\n  unsigned char *q, *r[3];\n\n  h = x->c;\n  m = h->a;\n  l = h->b;\n  n = y;\n  o = 0.0;\n  if (x->d == 8)\n    for (j = 0; j < x->e; j++)\n      for (k = 0; k < 3; k++)\n\t{\n\t  n = y;\n\t  o = 0.0;\n\t  if (m)\n\t    q = x->f[k] + x->e - 1 - j;\n\t  else\n\t    q = x->f[k] + j;\n\t  p = (*q - o) * y / (n - o);\n\t  p = 0.0 > p ? 0.0 : p;\n\t  p = y < p ? y : p;\n\t  if (l)\n\t    p = r[k][(int) p];\n\t  bar (p, x->g);\n\t}\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011205-1.c",
    "content": "/* Failure to mark_addressable all operands before evaluation means we\n   don't set up the proper temporaries, which leaves us with an asm that\n   doesn't match its contraints.  */\n\nlong foo()\n{\n  long x;\n  asm(\"\" : \"=r\"(x) : \"m\"(x));\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011217-1.c",
    "content": "/* Test that the initializer of a compound literal is properly walked\n   when tree inlining.  */\n/* Origin: PR c/5105 from <aj@suse.de>.  */\n\ntypedef struct { long p; } pt;\n\ninline pt f (pt _p)\n{\n  long p = _p.p;\n\n  return (pt) { (p) };\n}\n\nstatic int mmap_mem (void)\n{\n  pt p;\n  p = f (p);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011217-2.c",
    "content": "/* Test that the initializer of a compound literal is properly walked\n   when tree inlining.  */\n/* Origin: glibc (as reported in PR c/5105) from <aj@suse.de>.  */\n\ninline int\nfinite (double __x)\n{\n  return (__extension__\n\t  (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]\n\t     | 0x800fffffu) + 1) >> 31));\n}\n\nint\nmain (void)\n{\n  double x = 1.0;\n  \n  return finite (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011218-1.c",
    "content": "/* This testcase failed on Alpha at -O2 because $27 hard register\n   for the indirect call was exposed too early and reload couldn't\n   allocate it for multiplication and division.  */\n\nstruct S {\n  int a, b;\n  void (*f) (long, int);\n};\n\nvoid foo (struct S *x)\n{\n  long c = x->a * 50;\n  c /= (long) x->b;\n  c *= (long) x->b;\n  x->f (c, 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011219-1.c",
    "content": "/* This testcase failed on IA-64 at -O2 during scheduling.  */\n\nvoid * baz (unsigned long);\nstatic inline double **\nbar (long w, long x, long y, long z)\n{\n  long i, a = x - w + 1, b = z - y + 1;\n  double **m = (double **) baz (sizeof (double *) * (a + 1));\n\n  m += 1;\n  m -= w;\n  m[w] = (double *) baz (sizeof (double) * (a * b + 1));\n  m[w] += 1;\n  m[w] -= y;\n  for (i = w + 1; i <= x; i++)\n    m[i] = m[i - 1] + b;\n  return m;\n}\n\nvoid\nfoo (double w[], int x, double y[], double z[])\n{\n  int i;\n  double **a;\n\n  a = bar (1, 50, 1, 50);\n  for (i = 1; i <= x; i++)\n    a[1][i] = - w[x - i] / w[x];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011219-2.c",
    "content": "/* This testcase failed on Alpha at -O2 when simplifying conditional\n   expressions.  */\n\nstruct S {\n  unsigned long a;\n  double b, c;\n};\n\nextern double bar (double, double);\n\nint\nfoo (unsigned long x, unsigned int y, struct S *z)\n{\n  unsigned int a = z->a;\n  int b = y / z->a > 1 ? y / z->a : 1;\n\n  a = y / b < z->a ? y / b : z->a;\n  z->c = z->b * bar ((double) a, (double) x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011229-1.c",
    "content": "/* ICE: call insn does not satisfy its constraints, MMIX port.\n   Origin: ghostscript-6.52, reduction from hp@bitrange.com.  */\nstruct s0\n{\n  void (*init_color)(void *, void *);\n};\nstruct s1\n{\n  void (*map_cmyk)(short, void *, void **, void *);\n  void (*map_rgb_alpha)(short, void *, void **, void *);\n};\nstruct s5\n{\n  long fill1; int fill2;\n  long fill3; unsigned int fill4, fill5;\n};\nstruct s2\n{\n  struct s5 x, y;\n};\nstruct s3\n{\n  long dev_color;\n  unsigned int key;\n};\nstruct s4\n{\n  unsigned char spp;\n  int alpha;\n  struct mc_\n  {\n    unsigned int values[14];\n    unsigned int mask, test;\n    int exact;\n  } mask_color;\n  void **pis;\n  struct s0 *pcs;\n  struct dd_\n  {\n    struct s2 row[2];\n    struct s2 pixel0;\n  } dda;\n  struct s3 clues[256];\n};\nextern struct s1 *get_cmap_procs (void **, void *);\nint image_render_color (struct s4 *, unsigned char *, int, void *);\nint\nimage_render_color (struct s4 *penum, unsigned char *buffer,\n\t\t    int data_x, void *dev) \n{\n  struct s3 *clues = penum->clues;\n  void **pis = penum->pis;\n  struct s2 pnext;\n  struct s0 *pcs = penum->pcs;\n  struct s1 *cmap_procs = get_cmap_procs(pis, dev);\n  void (*map_4)(short, void *, void **, void *) =\n    (penum->alpha ? cmap_procs->map_rgb_alpha : cmap_procs->map_cmyk);\n  unsigned int mask = penum->mask_color.mask;\n  unsigned int test = penum->mask_color.test;\n  struct s3 *pic_next = &clues[1];\n  int spp = penum->spp;\n  unsigned char *psrc = buffer + data_x * spp;\n  unsigned char v[6];\n\n  pnext = penum->dda.pixel0;\n  __builtin_memset (&v, 0, sizeof(v));\n  (*(pcs)->init_color) (0, 0);\n\n  if (spp == 4)\n    {\n      v[0] = psrc[0];\n      v[1] = psrc[1];\n      if ((buffer[0] & mask) == test && penum->mask_color.exact)\n\tpic_next->dev_color = 0;\n      (*map_4)(v[0], &pic_next->dev_color, pis, dev);\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20011229-2.c",
    "content": "/* Test whether jump threading doesn't ICE if redirecting the jump to exit\n   block.  */\n\nextern int bar ();\nextern void baz ();\n\nvoid foo ()\n{\n  int x;\n\n  do\n    {\n      if ((x = bar ()) == 1)\n\tbaz ();\n    }\n  while (x == 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020103-1.c",
    "content": "/* This testcase failed on Alpha at -O2 when simplifying conditional\n   expressions.  */\n\nint foo (void);\n\nstruct A\n{\n  int a, b, c, d;\n};\n\nvoid bar (struct A *x)\n{\n  int e, f;\n\n  e = foo ();\n  e = e / x->b;\n  if (e < 1)\n    e = 1;\n  f = (x->a + x->c) / e;\n  if (f < x->d)\n    x->d -= (1 << 16) / 8;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020106-1.c",
    "content": "/* Origin: PR c/5279 from <wilco@equator.com>.  */     \n\t\nint\nfoo ()\n{\n  extern long long Y;\n  return (0 > Y++);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020109-1.c",
    "content": "/* This testcase ICEd when 2 different successors of a basic block\n   were successfully threaded and try_forward_edges was not expecting\n   that.  */\n\ntypedef struct A\n{\n  struct A *s, *t;\n  unsigned int u;\n} A;\n\nvoid bar (A *);\n\nvoid\nfoo (A *x, A *y, A *z)\n{\n  while (y\n\t && (((y && y->t && y->t->u) ? y : z)->t\n\t     == ((x && x->t && x->t->u) ? x : z)->t))\n    y = y->s;\n\n  if (y)\n    bar (y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020109-2.c",
    "content": "typedef union\n{\n  unsigned char member3;\n  signed short member4;\n  unsigned int member5;\n}\nUNI02;\n\nstruct srt_dat_t\n{\n  UNI02 un2;\n  unsigned long member1;\n  signed short member2;\n};\n\nstruct srt_dat_t exsrt1;\nvoid\nextern_test (struct srt_dat_t arg1)\n{\n  arg1.un2.member3++;\n  arg1.member1++;\n  arg1.member2++;\n}\n\nint\nmain (void)\n{\n  extern_test (exsrt1);\n  return (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020110.c",
    "content": "/* Copyright 2002 Free Software Foundation */\n\n/* Make sure the nested extern declaration doesn't conflict with the\n   non-extern one in the enclosing scope.  */\n\nvoid foo() {\n  static long bar;\n\n  {\n    extern int bar;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020116-1.c",
    "content": "void noret (void) __attribute__ ((noreturn));\nint foo (int, char **);\nchar *a, *b;\nint d;\n\nint\nmain (int argc, char **argv)\n{\n  register int c;\n\n  d = 1;\n  while ((c = foo (argc, argv)) != -1)\n    switch (c) {\n    case 's':\n    case 'c':\n    case 'f':\n      a = b;\n      break;\n    case 'v':\n      d = 1;\n      break;\n    case 'V':\n      d = 0;\n      break;\n    }\n  noret ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020120-1.c",
    "content": "/* This ICEed on IA-32 with -O2 -mcpu=i386, because reload was trying\n   to reload into %sil register.  */\n\nstruct A\n{\n  void *a;\n  unsigned int b, c, d;\n};\n\nstruct B\n{\n  struct A *e;\n};\n\nvoid bar (struct A *);\nvoid baz (struct A *);\n\nstatic inline unsigned int\ninl (unsigned int v, unsigned char w, unsigned char x, unsigned char y,\n     unsigned char z)\n{\n  switch (v)\n    {\n    case 2:\n      return ((w & 0xf8) << 8) | ((x & 0xfc) << 3) | ((y & 0xf8) >> 3);\n    case 4:\n      return (z << 24) | (w << 16) | (x << 8) | y;\n    default:\n      return 0;\n    }\n}\n\nvoid foo (struct B *x, int y, const float *z)\n{\n  struct A *a = x->e;\n\n  if (y)\n    {\n      if (x->e->a)\n       bar (x->e);\n    }\n  else\n    {\n      unsigned char c[4];\n      unsigned int b;\n\n      c[0] = z[0]; c[1] = z[1]; c[2] = z[2]; c[3] = z[3];\n      b = inl (a->b, c[0], c[1], c[2], c[3] );\n      if (a->a)\n       bar (a);\n      else\n       baz (a);\n      a->c = b;\n   }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020121-1.c",
    "content": "/* This testcase resulted in a 'unrecognizeable insn' on powerpc-linux-gnu\n   because of a missing trunc_int_for_mode in simplify_and_const_int.  */\n\nstruct display {\n  struct disphist *hstent;\n  int pid;\n  int status;\n};\n\nstruct disphist {\n  struct disphist *next;\n  char *name;\n  int startTries;\n  unsigned rLogin:2,\n    sd_how:2,\n    sd_when:2,\n    lock:1,\n    goodExit:1;\n  char *nuser, *npass, **nargs;\n};\n\nvoid\nStartDisplay (struct display *d)\n{\n  d->pid = 0;\n  d->status = 0;\n  d->hstent->lock = d->hstent->rLogin = d->hstent->goodExit =\n    d->hstent->sd_how = d->hstent->sd_when = 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020129-1.c",
    "content": "/* Test call to static variable.  */\n\ntypedef struct\n{\n  long long a[10];\n} A;\n  \nvoid bar (A *);\n  \ntypedef int (*B)(int);\n  \nvoid foo (void)\n{\n  static A a;\n  bar (&a);\n  (*(B)&a) (1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020206-1.c",
    "content": "/* Origin: PR optimization/5429 from Philipp Thomas <pthomas@suse.de>.  */\n/* This testcase caused ICE on IA-32 -O2 -march=i686 due to rtl sharing\n   problem in noce_process_if_block.  Fixed by\n   http://gcc.gnu.org/ml/gcc-patches/2002-01/msg02146.html.  */\n\ntypedef struct {\n  unsigned char a;\n} A;\n\nunsigned int foo (A *x)\n{\n  unsigned char b[2] = { 0, 0 };\n  unsigned char c = 0;\n\n  c = (x->a) ? b[1] : b[0];\n\n  return (unsigned int) c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020210-1.c",
    "content": "/* PR c/5615 */\nvoid f(int a, struct {int b[a];} c) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020303-1.c",
    "content": "/* With -fzero-initialized-in-bss, we made I a common symbol instead\n   of a symbol in the .bss section.  Not only does that break semantics,\n   but a common symbol can't be weak.  */\n\nint i __attribute__((weak)) = 0;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020304-1.c",
    "content": "/* In 3.0, this test case (extracted from Bigloo) crashes the compiler in\n   bb-reorder.c.  This is a regression from 2.95, already fixed in 3.1.\n\n   Original bug report is c/5830 by Manuel Serrano <Manuel.Serrano@inria.fr>.\n */\n\ntypedef union scmobj {\n  struct pair {\n    union scmobj *car;\n    union scmobj *cdr;\n  } pair_t;\n  struct vector {\n    long header;\n    int length;\n    union scmobj *obj0;\n  } vector_t;\n} *obj_t;\n\nextern obj_t create_vector (int);\nextern obj_t make_pair (obj_t, obj_t);\nextern long bgl_list_length (obj_t);\nextern int BGl_equalzf3zf3zz__r4_equivalence_6_2z00 (obj_t, obj_t);\nextern obj_t BGl_evcompilezd2lambdazd2zz__evcompilez00 (obj_t\n\t\t\t\t\t\t\tBgL_formalsz00_39,\n\t\t\t\t\t\t\tobj_t BgL_bodyz00_40,\n\t\t\t\t\t\t\tobj_t BgL_wherez00_41,\n\t\t\t\t\t\t\tobj_t\n\t\t\t\t\t\t\tBgL_namedzf3zf3_42,\n\t\t\t\t\t\t\tobj_t BgL_locz00_43);\n\nobj_t\nBGl_evcompilezd2lambdazd2zz__evcompilez00 (obj_t BgL_formalsz00_39,\n\t\t\t\t\t   obj_t BgL_bodyz00_40,\n\t\t\t\t\t   obj_t BgL_wherez00_41,\n\t\t\t\t\t   obj_t BgL_namedzf3zf3_42,\n\t\t\t\t\t   obj_t BgL_locz00_43)\n{\n  if (BGl_equalzf3zf3zz__r4_equivalence_6_2z00\n      (BgL_formalsz00_39,\n       ((obj_t) (obj_t) ((long) (((long) (0) << 2) | 2))))) {\n  BgL_tagzd21966zd2_943:\n    if ((BgL_namedzf3zf3_42 !=\n\t ((obj_t) (obj_t) ((long) (((long) (1) << 2) | 2))))) {\n      obj_t BgL_v1042z00_998;\n      {\n\tint BgL_auxz00_4066;\n\tBgL_auxz00_4066 = (int) (((long) 3));\n\tBgL_v1042z00_998 = create_vector (BgL_auxz00_4066);\n      }\n      {\n\tobj_t BgL_arg1586z00_1000;\n\tBgL_arg1586z00_1000 = make_pair (BgL_wherez00_41, BgL_bodyz00_40);\n\t{\n\t  int BgL_auxz00_4070;\n\t  BgL_auxz00_4070 = (int) (((long) 2));\n\t  ((&(((obj_t) (BgL_v1042z00_998))->vector_t.obj0))[BgL_auxz00_4070] =\n\t   BgL_arg1586z00_1000,\n\t   ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n      }\n      {\n\tint BgL_auxz00_4073;\n\tBgL_auxz00_4073 = (int) (((long) 1));\n\t((&(((obj_t) (BgL_v1042z00_998))->vector_t.obj0))[BgL_auxz00_4073] =\n\t BgL_locz00_43, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n      }\n      {\n\tobj_t BgL_auxz00_4078;\n\tint BgL_auxz00_4076;\n\t{\n\t  long BgL_auxz00_4079;\n\t  {\n\t    long BgL_auxz00_4080;\n\t    BgL_auxz00_4080 = bgl_list_length (BgL_formalsz00_39);\n\t    BgL_auxz00_4079 = (BgL_auxz00_4080 + ((long) 37));\n\t  }\n\t  BgL_auxz00_4078 =\n\t    (obj_t) ((long) (((long) (BgL_auxz00_4079) << 2) | 1));\n\t}\n\tBgL_auxz00_4076 = (int) (((long) 0));\n\t((&(((obj_t) (BgL_v1042z00_998))->vector_t.obj0))[BgL_auxz00_4076] =\n\t BgL_auxz00_4078, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n      }\n      return BgL_v1042z00_998;\n    } else {\n      obj_t BgL_v1043z00_1005;\n      {\n\tint BgL_auxz00_4085;\n\tBgL_auxz00_4085 = (int) (((long) 3));\n\tBgL_v1043z00_1005 = create_vector (BgL_auxz00_4085);\n      }\n      {\n\tint BgL_auxz00_4088;\n\tBgL_auxz00_4088 = (int) (((long) 2));\n\t((&(((obj_t) (BgL_v1043z00_1005))->vector_t.obj0))[BgL_auxz00_4088] =\n\t BgL_bodyz00_40, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n      }\n      {\n\tint BgL_auxz00_4091;\n\tBgL_auxz00_4091 = (int) (((long) 1));\n\t((&(((obj_t) (BgL_v1043z00_1005))->vector_t.obj0))[BgL_auxz00_4091] =\n\t BgL_locz00_43, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n      }\n      {\n\tobj_t BgL_auxz00_4096;\n\tint BgL_auxz00_4094;\n\t{\n\t  long BgL_auxz00_4097;\n\t  {\n\t    long BgL_auxz00_4098;\n\t    BgL_auxz00_4098 = bgl_list_length (BgL_formalsz00_39);\n\t    BgL_auxz00_4097 = (BgL_auxz00_4098 + ((long) 42));\n\t  }\n\t  BgL_auxz00_4096 =\n\t    (obj_t) ((long) (((long) (BgL_auxz00_4097) << 2) | 1));\n\t}\n\tBgL_auxz00_4094 = (int) (((long) 0));\n\t((&(((obj_t) (BgL_v1043z00_1005))->vector_t.obj0))[BgL_auxz00_4094] =\n\t BgL_auxz00_4096, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n      }\n      return BgL_v1043z00_1005;\n    }\n  } else {\n    if (((((long) BgL_formalsz00_39) & ((1 << 2) - 1)) == 3)) {\n      if (BGl_equalzf3zf3zz__r4_equivalence_6_2z00\n\t  (((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).cdr),\n\t   ((obj_t) (obj_t) ((long) (((long) (0) << 2) | 2))))) {\n\tgoto BgL_tagzd21966zd2_943;\n      } else {\n\tobj_t BgL_cdrzd21979zd2_953;\n\tBgL_cdrzd21979zd2_953 =\n\t  ((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).cdr);\n\tif (((((long) BgL_cdrzd21979zd2_953) & ((1 << 2) - 1)) == 3)) {\n\t  if (BGl_equalzf3zf3zz__r4_equivalence_6_2z00\n\t      (((((obj_t) ((long) BgL_cdrzd21979zd2_953 - 3))->pair_t).cdr),\n\t       ((obj_t) (obj_t) ((long) (((long) (0) << 2) | 2))))) {\n\t    goto BgL_tagzd21966zd2_943;\n\t  } else {\n\t    obj_t BgL_cdrzd21986zd2_956;\n\t    BgL_cdrzd21986zd2_956 =\n\t      ((((obj_t) ((long) BgL_cdrzd21979zd2_953 - 3))->pair_t).cdr);\n\t    if (((((long) BgL_cdrzd21986zd2_956) & ((1 << 2) - 1)) == 3)) {\n\t      if (BGl_equalzf3zf3zz__r4_equivalence_6_2z00\n\t\t  (((((obj_t) ((long) BgL_cdrzd21986zd2_956 - 3))->pair_t).\n\t\t    cdr),\n\t\t   ((obj_t) (obj_t) ((long) (((long) (0) << 2) | 2))))) {\n\t\tgoto BgL_tagzd21966zd2_943;\n\t      } else {\n\t\tobj_t BgL_cdrzd21994zd2_959;\n\t\t{\n\t\t  obj_t BgL_auxz00_4120;\n\t\t  BgL_auxz00_4120 =\n\t\t    ((((obj_t) ((long) BgL_cdrzd21979zd2_953 - 3))->pair_t).\n\t\t     cdr);\n\t\t  BgL_cdrzd21994zd2_959 =\n\t\t    ((((obj_t) ((long) BgL_auxz00_4120 - 3))->pair_t).cdr);\n\t\t}\n\t\tif (((((long) BgL_cdrzd21994zd2_959) & ((1 << 2) - 1)) == 3)) {\n\t\t  if (BGl_equalzf3zf3zz__r4_equivalence_6_2z00\n\t\t      (((((obj_t) ((long) BgL_cdrzd21994zd2_959 - 3))->\n\t\t\t pair_t).cdr),\n\t\t       ((obj_t) (obj_t) ((long) (((long) (0) << 2) | 2))))) {\n\t\t    goto BgL_tagzd21966zd2_943;\n\t\t  } else {\n\t\t    int BgL_testz00_4128;\n\t\t    {\n\t\t      obj_t BgL_auxz00_4129;\n\t\t      BgL_auxz00_4129 =\n\t\t\t((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).\n\t\t\t car);\n\t\t      BgL_testz00_4128 =\n\t\t\t((((long) BgL_auxz00_4129) & ((1 << 2) - 1)) == 3);\n\t\t    }\n\t\t    if (BgL_testz00_4128) {\n\t\t    BgL_tagzd21971zd2_948:\n\t\t      if ((BgL_namedzf3zf3_42 !=\n\t\t\t   ((obj_t) (obj_t)\n\t\t\t    ((long) (((long) (1) << 2) | 2))))) {\n\t\t\tobj_t BgL_v1052z00_1026;\n\t\t\t{\n\t\t\t  int BgL_auxz00_4134;\n\t\t\t  BgL_auxz00_4134 = (int) (((long) 3));\n\t\t\t  BgL_v1052z00_1026 = create_vector (BgL_auxz00_4134);\n\t\t\t}\n\t\t\t{\n\t\t\t  obj_t BgL_arg1606z00_1028;\n\t\t\t  {\n\t\t\t    obj_t BgL_v1053z00_1029;\n\t\t\t    {\n\t\t\t      int BgL_auxz00_4137;\n\t\t\t      BgL_auxz00_4137 = (int) (((long) 3));\n\t\t\t      BgL_v1053z00_1029 =\n\t\t\t\tcreate_vector (BgL_auxz00_4137);\n\t\t\t    }\n\t\t\t    {\n\t\t\t      int BgL_auxz00_4140;\n\t\t\t      BgL_auxz00_4140 = (int) (((long) 2));\n\t\t\t      ((&\n\t\t\t\t(((obj_t) (BgL_v1053z00_1029))->vector_t.\n\t\t\t\t obj0))[BgL_auxz00_4140] =\n\t\t\t       BgL_formalsz00_39,\n\t\t\t       ((obj_t) (obj_t)\n\t\t\t\t((long) (((long) (3) << 2) | 2))));\n\t\t\t    }\n\t\t\t    {\n\t\t\t      int BgL_auxz00_4143;\n\t\t\t      BgL_auxz00_4143 = (int) (((long) 1));\n\t\t\t      ((&\n\t\t\t\t(((obj_t) (BgL_v1053z00_1029))->vector_t.\n\t\t\t\t obj0))[BgL_auxz00_4143] =\n\t\t\t       BgL_bodyz00_40,\n\t\t\t       ((obj_t) (obj_t)\n\t\t\t\t((long) (((long) (3) << 2) | 2))));\n\t\t\t    }\n\t\t\t    {\n\t\t\t      int BgL_auxz00_4146;\n\t\t\t      BgL_auxz00_4146 = (int) (((long) 0));\n\t\t\t      ((&\n\t\t\t\t(((obj_t) (BgL_v1053z00_1029))->vector_t.\n\t\t\t\t obj0))[BgL_auxz00_4146] =\n\t\t\t       BgL_wherez00_41,\n\t\t\t       ((obj_t) (obj_t)\n\t\t\t\t((long) (((long) (3) << 2) | 2))));\n\t\t\t    }\n\t\t\t    BgL_arg1606z00_1028 = BgL_v1053z00_1029;\n\t\t\t  }\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4149;\n\t\t\t    BgL_auxz00_4149 = (int) (((long) 2));\n\t\t\t    ((&(((obj_t) (BgL_v1052z00_1026))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4149] =\n\t\t\t     BgL_arg1606z00_1028,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t}\n\t\t\t{\n\t\t\t  int BgL_auxz00_4152;\n\t\t\t  BgL_auxz00_4152 = (int) (((long) 1));\n\t\t\t  ((&(((obj_t) (BgL_v1052z00_1026))->vector_t.obj0))\n\t\t\t   [BgL_auxz00_4152] =\n\t\t\t   BgL_locz00_43,\n\t\t\t   ((obj_t) (obj_t)\n\t\t\t    ((long) (((long) (3) << 2) | 2))));\n\t\t\t}\n\t\t\t{\n\t\t\t  obj_t BgL_auxz00_4157;\n\t\t\t  int BgL_auxz00_4155;\n\t\t\t  BgL_auxz00_4157 =\n\t\t\t    (obj_t) ((long)\n\t\t\t\t     (((long) (((long) 55)) << 2) | 1));\n\t\t\t  BgL_auxz00_4155 = (int) (((long) 0));\n\t\t\t  ((&(((obj_t) (BgL_v1052z00_1026))->vector_t.obj0))\n\t\t\t   [BgL_auxz00_4155] =\n\t\t\t   BgL_auxz00_4157,\n\t\t\t   ((obj_t) (obj_t)\n\t\t\t    ((long) (((long) (3) << 2) | 2))));\n\t\t\t}\n\t\t\treturn BgL_v1052z00_1026;\n\t\t      } else {\n\t\t\tobj_t BgL_v1054z00_1030;\n\t\t\t{\n\t\t\t  int BgL_auxz00_4160;\n\t\t\t  BgL_auxz00_4160 = (int) (((long) 3));\n\t\t\t  BgL_v1054z00_1030 = create_vector (BgL_auxz00_4160);\n\t\t\t}\n\t\t\t{\n\t\t\t  obj_t BgL_arg1608z00_1032;\n\t\t\t  BgL_arg1608z00_1032 =\n\t\t\t    make_pair (BgL_bodyz00_40, BgL_formalsz00_39);\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4164;\n\t\t\t    BgL_auxz00_4164 = (int) (((long) 2));\n\t\t\t    ((&(((obj_t) (BgL_v1054z00_1030))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4164] =\n\t\t\t     BgL_arg1608z00_1032,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t}\n\t\t\t{\n\t\t\t  int BgL_auxz00_4167;\n\t\t\t  BgL_auxz00_4167 = (int) (((long) 1));\n\t\t\t  ((&(((obj_t) (BgL_v1054z00_1030))->vector_t.obj0))\n\t\t\t   [BgL_auxz00_4167] =\n\t\t\t   BgL_locz00_43,\n\t\t\t   ((obj_t) (obj_t)\n\t\t\t    ((long) (((long) (3) << 2) | 2))));\n\t\t\t}\n\t\t\t{\n\t\t\t  obj_t BgL_auxz00_4172;\n\t\t\t  int BgL_auxz00_4170;\n\t\t\t  BgL_auxz00_4172 =\n\t\t\t    (obj_t) ((long)\n\t\t\t\t     (((long) (((long) 56)) << 2) | 1));\n\t\t\t  BgL_auxz00_4170 = (int) (((long) 0));\n\t\t\t  ((&(((obj_t) (BgL_v1054z00_1030))->vector_t.obj0))\n\t\t\t   [BgL_auxz00_4170] =\n\t\t\t   BgL_auxz00_4172,\n\t\t\t   ((obj_t) (obj_t)\n\t\t\t    ((long) (((long) (3) << 2) | 2))));\n\t\t\t}\n\t\t\treturn BgL_v1054z00_1030;\n\t\t      }\n\t\t    } else {\n\t\t      int BgL_testz00_4175;\n\t\t      {\n\t\t\tobj_t BgL_auxz00_4176;\n\t\t\t{\n\t\t\t  obj_t BgL_auxz00_4177;\n\t\t\t  BgL_auxz00_4177 =\n\t\t\t    ((((obj_t) ((long) BgL_formalsz00_39 - 3))->\n\t\t\t      pair_t).cdr);\n\t\t\t  BgL_auxz00_4176 =\n\t\t\t    ((((obj_t) ((long) BgL_auxz00_4177 - 3))->pair_t).\n\t\t\t     car);\n\t\t\t}\n\t\t\tBgL_testz00_4175 =\n\t\t\t  ((((long) BgL_auxz00_4176) & ((1 << 2) - 1)) == 3);\n\t\t      }\n\t\t      if (BgL_testz00_4175) {\n\t\t\tgoto BgL_tagzd21971zd2_948;\n\t\t      } else {\n\t\t\tint BgL_testz00_4181;\n\t\t\t{\n\t\t\t  obj_t BgL_auxz00_4182;\n\t\t\t  {\n\t\t\t    obj_t BgL_auxz00_4183;\n\t\t\t    {\n\t\t\t      obj_t BgL_auxz00_4184;\n\t\t\t      BgL_auxz00_4184 =\n\t\t\t\t((((obj_t) ((long) BgL_formalsz00_39 - 3))->\n\t\t\t\t  pair_t).cdr);\n\t\t\t      BgL_auxz00_4183 =\n\t\t\t\t((((obj_t) ((long) BgL_auxz00_4184 - 3))->\n\t\t\t\t  pair_t).cdr);\n\t\t\t    }\n\t\t\t    BgL_auxz00_4182 =\n\t\t\t      ((((obj_t) ((long) BgL_auxz00_4183 - 3))->\n\t\t\t\tpair_t).car);\n\t\t\t  }\n\t\t\t  BgL_testz00_4181 =\n\t\t\t    ((((long) BgL_auxz00_4182) & ((1 << 2) - 1)) ==\n\t\t\t     3);\n\t\t\t}\n\t\t\tif (BgL_testz00_4181) {\n\t\t\t  goto BgL_tagzd21971zd2_948;\n\t\t\t} else {\n\t\t\t  goto BgL_tagzd21971zd2_948;\n\t\t\t}\n\t\t      }\n\t\t    }\n\t\t  }\n\t\t} else {\n\t\t  int BgL_testz00_4189;\n\t\t  {\n\t\t    obj_t BgL_auxz00_4190;\n\t\t    BgL_auxz00_4190 =\n\t\t      ((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).\n\t\t       car);\n\t\t    BgL_testz00_4189 =\n\t\t      ((((long) BgL_auxz00_4190) & ((1 << 2) - 1)) == 3);\n\t\t  }\n\t\t  if (BgL_testz00_4189) {\n\t\t    goto BgL_tagzd21971zd2_948;\n\t\t  } else {\n\t\t    int BgL_testz00_4193;\n\t\t    {\n\t\t      obj_t BgL_auxz00_4194;\n\t\t      {\n\t\t\tobj_t BgL_auxz00_4195;\n\t\t\tBgL_auxz00_4195 =\n\t\t\t  ((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).\n\t\t\t   cdr);\n\t\t\tBgL_auxz00_4194 =\n\t\t\t  ((((obj_t) ((long) BgL_auxz00_4195 - 3))->pair_t).\n\t\t\t   car);\n\t\t      }\n\t\t      BgL_testz00_4193 =\n\t\t\t((((long) BgL_auxz00_4194) & ((1 << 2) - 1)) == 3);\n\t\t    }\n\t\t    if (BgL_testz00_4193) {\n\t\t      goto BgL_tagzd21971zd2_948;\n\t\t    } else {\n\t\t      int BgL_testz00_4199;\n\t\t      {\n\t\t\tobj_t BgL_auxz00_4200;\n\t\t\t{\n\t\t\t  obj_t BgL_auxz00_4201;\n\t\t\t  {\n\t\t\t    obj_t BgL_auxz00_4202;\n\t\t\t    BgL_auxz00_4202 =\n\t\t\t      ((((obj_t) ((long) BgL_formalsz00_39 - 3))->\n\t\t\t\tpair_t).cdr);\n\t\t\t    BgL_auxz00_4201 =\n\t\t\t      ((((obj_t) ((long) BgL_auxz00_4202 - 3))->\n\t\t\t\tpair_t).cdr);\n\t\t\t  }\n\t\t\t  BgL_auxz00_4200 =\n\t\t\t    ((((obj_t) ((long) BgL_auxz00_4201 - 3))->pair_t).\n\t\t\t     car);\n\t\t\t}\n\t\t\tBgL_testz00_4199 =\n\t\t\t  ((((long) BgL_auxz00_4200) & ((1 << 2) - 1)) == 3);\n\t\t      }\n\t\t      if (BgL_testz00_4199) {\n\t\t\tgoto BgL_tagzd21971zd2_948;\n\t\t      } else {\n\t\t\tif ((BgL_namedzf3zf3_42 !=\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (1) << 2) | 2))))) {\n\t\t\t  obj_t BgL_v1050z00_1022;\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4209;\n\t\t\t    BgL_auxz00_4209 = (int) (((long) 3));\n\t\t\t    BgL_v1050z00_1022 =\n\t\t\t      create_vector (BgL_auxz00_4209);\n\t\t\t  }\n\t\t\t  {\n\t\t\t    obj_t BgL_arg1604z00_1024;\n\t\t\t    BgL_arg1604z00_1024 =\n\t\t\t      make_pair (BgL_wherez00_41, BgL_bodyz00_40);\n\t\t\t    {\n\t\t\t      int BgL_auxz00_4213;\n\t\t\t      BgL_auxz00_4213 = (int) (((long) 2));\n\t\t\t      ((&\n\t\t\t\t(((obj_t) (BgL_v1050z00_1022))->vector_t.\n\t\t\t\t obj0))[BgL_auxz00_4213] =\n\t\t\t       BgL_arg1604z00_1024,\n\t\t\t       ((obj_t) (obj_t)\n\t\t\t\t((long) (((long) (3) << 2) | 2))));\n\t\t\t    }\n\t\t\t  }\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4216;\n\t\t\t    BgL_auxz00_4216 = (int) (((long) 1));\n\t\t\t    ((&(((obj_t) (BgL_v1050z00_1022))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4216] =\n\t\t\t     BgL_locz00_43,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t  {\n\t\t\t    obj_t BgL_auxz00_4221;\n\t\t\t    int BgL_auxz00_4219;\n\t\t\t    BgL_auxz00_4221 =\n\t\t\t      (obj_t) ((long)\n\t\t\t\t       (((long) (((long) 50)) << 2) | 1));\n\t\t\t    BgL_auxz00_4219 = (int) (((long) 0));\n\t\t\t    ((&(((obj_t) (BgL_v1050z00_1022))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4219] =\n\t\t\t     BgL_auxz00_4221,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t  return BgL_v1050z00_1022;\n\t\t\t} else {\n\t\t\t  obj_t BgL_v1051z00_1025;\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4224;\n\t\t\t    BgL_auxz00_4224 = (int) (((long) 3));\n\t\t\t    BgL_v1051z00_1025 =\n\t\t\t      create_vector (BgL_auxz00_4224);\n\t\t\t  }\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4227;\n\t\t\t    BgL_auxz00_4227 = (int) (((long) 2));\n\t\t\t    ((&(((obj_t) (BgL_v1051z00_1025))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4227] =\n\t\t\t     BgL_bodyz00_40,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t  {\n\t\t\t    int BgL_auxz00_4230;\n\t\t\t    BgL_auxz00_4230 = (int) (((long) 1));\n\t\t\t    ((&(((obj_t) (BgL_v1051z00_1025))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4230] =\n\t\t\t     BgL_locz00_43,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t  {\n\t\t\t    obj_t BgL_auxz00_4235;\n\t\t\t    int BgL_auxz00_4233;\n\t\t\t    BgL_auxz00_4235 =\n\t\t\t      (obj_t) ((long)\n\t\t\t\t       (((long) (((long) 54)) << 2) | 1));\n\t\t\t    BgL_auxz00_4233 = (int) (((long) 0));\n\t\t\t    ((&(((obj_t) (BgL_v1051z00_1025))->vector_t.obj0))\n\t\t\t     [BgL_auxz00_4233] =\n\t\t\t     BgL_auxz00_4235,\n\t\t\t     ((obj_t) (obj_t)\n\t\t\t      ((long) (((long) (3) << 2) | 2))));\n\t\t\t  }\n\t\t\t  return BgL_v1051z00_1025;\n\t\t\t}\n\t\t      }\n\t\t    }\n\t\t  }\n\t\t}\n\t      }\n\t    } else {\n\t      int BgL_testz00_4238;\n\t      {\n\t\tobj_t BgL_auxz00_4239;\n\t\tBgL_auxz00_4239 =\n\t\t  ((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).car);\n\t\tBgL_testz00_4238 =\n\t\t  ((((long) BgL_auxz00_4239) & ((1 << 2) - 1)) == 3);\n\t      }\n\t      if (BgL_testz00_4238) {\n\t\tgoto BgL_tagzd21971zd2_948;\n\t      } else {\n\t\tint BgL_testz00_4242;\n\t\t{\n\t\t  obj_t BgL_auxz00_4243;\n\t\t  BgL_auxz00_4243 =\n\t\t    ((((obj_t) ((long) BgL_cdrzd21979zd2_953 - 3))->pair_t).\n\t\t     car);\n\t\t  BgL_testz00_4242 =\n\t\t    ((((long) BgL_auxz00_4243) & ((1 << 2) - 1)) == 3);\n\t\t}\n\t\tif (BgL_testz00_4242) {\n\t\t  goto BgL_tagzd21971zd2_948;\n\t\t} else {\n\t\t  if ((BgL_namedzf3zf3_42 !=\n\t\t       ((obj_t) (obj_t) ((long) (((long) (1) << 2) | 2))))) {\n\t\t    obj_t BgL_v1048z00_1018;\n\t\t    {\n\t\t      int BgL_auxz00_4248;\n\t\t      BgL_auxz00_4248 = (int) (((long) 3));\n\t\t      BgL_v1048z00_1018 = create_vector (BgL_auxz00_4248);\n\t\t    }\n\t\t    {\n\t\t      obj_t BgL_arg1602z00_1020;\n\t\t      BgL_arg1602z00_1020 =\n\t\t\tmake_pair (BgL_wherez00_41, BgL_bodyz00_40);\n\t\t      {\n\t\t\tint BgL_auxz00_4252;\n\t\t\tBgL_auxz00_4252 = (int) (((long) 2));\n\t\t\t((&(((obj_t) (BgL_v1048z00_1018))->vector_t.obj0))\n\t\t\t [BgL_auxz00_4252] =\n\t\t\t BgL_arg1602z00_1020,\n\t\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t      }\n\t\t    }\n\t\t    {\n\t\t      int BgL_auxz00_4255;\n\t\t      BgL_auxz00_4255 = (int) (((long) 1));\n\t\t      ((&(((obj_t) (BgL_v1048z00_1018))->vector_t.obj0))\n\t\t       [BgL_auxz00_4255] =\n\t\t       BgL_locz00_43,\n\t\t       ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t    }\n\t\t    {\n\t\t      obj_t BgL_auxz00_4260;\n\t\t      int BgL_auxz00_4258;\n\t\t      BgL_auxz00_4260 =\n\t\t\t(obj_t) ((long) (((long) (((long) 49)) << 2) | 1));\n\t\t      BgL_auxz00_4258 = (int) (((long) 0));\n\t\t      ((&(((obj_t) (BgL_v1048z00_1018))->vector_t.obj0))\n\t\t       [BgL_auxz00_4258] =\n\t\t       BgL_auxz00_4260,\n\t\t       ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t    }\n\t\t    return BgL_v1048z00_1018;\n\t\t  } else {\n\t\t    obj_t BgL_v1049z00_1021;\n\t\t    {\n\t\t      int BgL_auxz00_4263;\n\t\t      BgL_auxz00_4263 = (int) (((long) 3));\n\t\t      BgL_v1049z00_1021 = create_vector (BgL_auxz00_4263);\n\t\t    }\n\t\t    {\n\t\t      int BgL_auxz00_4266;\n\t\t      BgL_auxz00_4266 = (int) (((long) 2));\n\t\t      ((&(((obj_t) (BgL_v1049z00_1021))->vector_t.obj0))\n\t\t       [BgL_auxz00_4266] =\n\t\t       BgL_bodyz00_40,\n\t\t       ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t    }\n\t\t    {\n\t\t      int BgL_auxz00_4269;\n\t\t      BgL_auxz00_4269 = (int) (((long) 1));\n\t\t      ((&(((obj_t) (BgL_v1049z00_1021))->vector_t.obj0))\n\t\t       [BgL_auxz00_4269] =\n\t\t       BgL_locz00_43,\n\t\t       ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t    }\n\t\t    {\n\t\t      obj_t BgL_auxz00_4274;\n\t\t      int BgL_auxz00_4272;\n\t\t      BgL_auxz00_4274 =\n\t\t\t(obj_t) ((long) (((long) (((long) 53)) << 2) | 1));\n\t\t      BgL_auxz00_4272 = (int) (((long) 0));\n\t\t      ((&(((obj_t) (BgL_v1049z00_1021))->vector_t.obj0))\n\t\t       [BgL_auxz00_4272] =\n\t\t       BgL_auxz00_4274,\n\t\t       ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t    }\n\t\t    return BgL_v1049z00_1021;\n\t\t  }\n\t\t}\n\t      }\n\t    }\n\t  }\n\t} else {\n\t  int BgL_testz00_4277;\n\t  {\n\t    obj_t BgL_auxz00_4278;\n\t    BgL_auxz00_4278 =\n\t      ((((obj_t) ((long) BgL_formalsz00_39 - 3))->pair_t).car);\n\t    BgL_testz00_4277 =\n\t      ((((long) BgL_auxz00_4278) & ((1 << 2) - 1)) == 3);\n\t  }\n\t  if (BgL_testz00_4277) {\n\t    goto BgL_tagzd21971zd2_948;\n\t  } else {\n\t    if ((BgL_namedzf3zf3_42 !=\n\t\t ((obj_t) (obj_t) ((long) (((long) (1) << 2) | 2))))) {\n\t      obj_t BgL_v1046z00_1014;\n\t      {\n\t\tint BgL_auxz00_4283;\n\t\tBgL_auxz00_4283 = (int) (((long) 3));\n\t\tBgL_v1046z00_1014 = create_vector (BgL_auxz00_4283);\n\t      }\n\t      {\n\t\tobj_t BgL_arg1600z00_1016;\n\t\tBgL_arg1600z00_1016 =\n\t\t  make_pair (BgL_wherez00_41, BgL_bodyz00_40);\n\t\t{\n\t\t  int BgL_auxz00_4287;\n\t\t  BgL_auxz00_4287 = (int) (((long) 2));\n\t\t  ((&(((obj_t) (BgL_v1046z00_1014))->vector_t.obj0))\n\t\t   [BgL_auxz00_4287] =\n\t\t   BgL_arg1600z00_1016,\n\t\t   ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t\t}\n\t      }\n\t      {\n\t\tint BgL_auxz00_4290;\n\t\tBgL_auxz00_4290 = (int) (((long) 1));\n\t\t((&(((obj_t) (BgL_v1046z00_1014))->vector_t.obj0))\n\t\t [BgL_auxz00_4290] =\n\t\t BgL_locz00_43,\n\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t      }\n\t      {\n\t\tobj_t BgL_auxz00_4295;\n\t\tint BgL_auxz00_4293;\n\t\tBgL_auxz00_4295 =\n\t\t  (obj_t) ((long) (((long) (((long) 48)) << 2) | 1));\n\t\tBgL_auxz00_4293 = (int) (((long) 0));\n\t\t((&(((obj_t) (BgL_v1046z00_1014))->vector_t.obj0))\n\t\t [BgL_auxz00_4293] =\n\t\t BgL_auxz00_4295,\n\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t      }\n\t      return BgL_v1046z00_1014;\n\t    } else {\n\t      obj_t BgL_v1047z00_1017;\n\t      {\n\t\tint BgL_auxz00_4298;\n\t\tBgL_auxz00_4298 = (int) (((long) 3));\n\t\tBgL_v1047z00_1017 = create_vector (BgL_auxz00_4298);\n\t      }\n\t      {\n\t\tint BgL_auxz00_4301;\n\t\tBgL_auxz00_4301 = (int) (((long) 2));\n\t\t((&(((obj_t) (BgL_v1047z00_1017))->vector_t.obj0))\n\t\t [BgL_auxz00_4301] =\n\t\t BgL_bodyz00_40,\n\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t      }\n\t      {\n\t\tint BgL_auxz00_4304;\n\t\tBgL_auxz00_4304 = (int) (((long) 1));\n\t\t((&(((obj_t) (BgL_v1047z00_1017))->vector_t.obj0))\n\t\t [BgL_auxz00_4304] =\n\t\t BgL_locz00_43,\n\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t      }\n\t      {\n\t\tobj_t BgL_auxz00_4309;\n\t\tint BgL_auxz00_4307;\n\t\tBgL_auxz00_4309 =\n\t\t  (obj_t) ((long) (((long) (((long) 52)) << 2) | 1));\n\t\tBgL_auxz00_4307 = (int) (((long) 0));\n\t\t((&(((obj_t) (BgL_v1047z00_1017))->vector_t.obj0))\n\t\t [BgL_auxz00_4307] =\n\t\t BgL_auxz00_4309,\n\t\t ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t      }\n\t      return BgL_v1047z00_1017;\n\t    }\n\t  }\n\t}\n      }\n    } else {\n      if ((BgL_namedzf3zf3_42 !=\n\t   ((obj_t) (obj_t) ((long) (((long) (1) << 2) | 2))))) {\n\tobj_t BgL_v1044z00_1010;\n\t{\n\t  int BgL_auxz00_4314;\n\t  BgL_auxz00_4314 = (int) (((long) 3));\n\t  BgL_v1044z00_1010 = create_vector (BgL_auxz00_4314);\n\t}\n\t{\n\t  obj_t BgL_arg1598z00_1012;\n\t  BgL_arg1598z00_1012 = make_pair (BgL_wherez00_41, BgL_bodyz00_40);\n\t  {\n\t    int BgL_auxz00_4318;\n\t    BgL_auxz00_4318 = (int) (((long) 2));\n\t    ((&(((obj_t) (BgL_v1044z00_1010))->vector_t.obj0))\n\t     [BgL_auxz00_4318] =\n\t     BgL_arg1598z00_1012,\n\t     ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t  }\n\t}\n\t{\n\t  int BgL_auxz00_4321;\n\t  BgL_auxz00_4321 = (int) (((long) 1));\n\t  ((&(((obj_t) (BgL_v1044z00_1010))->vector_t.obj0))[BgL_auxz00_4321]\n\t   =\n\t   BgL_locz00_43, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n\t{\n\t  obj_t BgL_auxz00_4326;\n\t  int BgL_auxz00_4324;\n\t  BgL_auxz00_4326 =\n\t    (obj_t) ((long) (((long) (((long) 47)) << 2) | 1));\n\t  BgL_auxz00_4324 = (int) (((long) 0));\n\t  ((&(((obj_t) (BgL_v1044z00_1010))->vector_t.obj0))[BgL_auxz00_4324]\n\t   =\n\t   BgL_auxz00_4326,\n\t   ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n\treturn BgL_v1044z00_1010;\n      } else {\n\tobj_t BgL_v1045z00_1013;\n\t{\n\t  int BgL_auxz00_4329;\n\t  BgL_auxz00_4329 = (int) (((long) 3));\n\t  BgL_v1045z00_1013 = create_vector (BgL_auxz00_4329);\n\t}\n\t{\n\t  int BgL_auxz00_4332;\n\t  BgL_auxz00_4332 = (int) (((long) 2));\n\t  ((&(((obj_t) (BgL_v1045z00_1013))->vector_t.obj0))[BgL_auxz00_4332]\n\t   =\n\t   BgL_bodyz00_40,\n\t   ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n\t{\n\t  int BgL_auxz00_4335;\n\t  BgL_auxz00_4335 = (int) (((long) 1));\n\t  ((&(((obj_t) (BgL_v1045z00_1013))->vector_t.obj0))[BgL_auxz00_4335]\n\t   =\n\t   BgL_locz00_43, ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n\t{\n\t  obj_t BgL_auxz00_4340;\n\t  int BgL_auxz00_4338;\n\t  BgL_auxz00_4340 =\n\t    (obj_t) ((long) (((long) (((long) 51)) << 2) | 1));\n\t  BgL_auxz00_4338 = (int) (((long) 0));\n\t  ((&(((obj_t) (BgL_v1045z00_1013))->vector_t.obj0))[BgL_auxz00_4338]\n\t   =\n\t   BgL_auxz00_4340,\n\t   ((obj_t) (obj_t) ((long) (((long) (3) << 2) | 2))));\n\t}\n\treturn BgL_v1045z00_1013;\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020304-2.c",
    "content": "/* This testcase ICEd because a SUBREG of MEM/v was never\n   simplified.  */\nvolatile unsigned long long *a;\n\nunsigned char\nfoo (void)\n{\n  unsigned char b = (*a != 0);\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020309-1.c",
    "content": "int\nsub1 (char *p, int i)\n{\n  char j = p[i];\n\n  {\n    void\n    sub2 ()\n      {\n\ti = 2;\n\tp = p + 2;\n      }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020309-2.c",
    "content": "/* This testcase ICEd on IA-32 at -O2, because loop was calling convert_modes\n   between a MODE_FLOAT and MODE_INT class modes.  */\n\ntypedef union\n{\n  double d;\n  long long ll;\n} A;\n\nvoid\nfoo (A x, A **y, A z)\n{\n  for (; *y; y++)\n    if (x.ll == 262 && (*y)->d == z.d)\n      break;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020312-1.c",
    "content": "/* { dg-do assemble } */\n/* { dg-skip-if \"\" { pdp11-*-* } { \"-O0\" } { \"\" } } */\n\n/* PR optimization/5892 */\ntypedef struct { unsigned long a; unsigned int b, c; } A;\ntypedef struct { unsigned long a; A *b; int c; } B;\n\nstatic inline unsigned int\nbar (unsigned int x)\n{\n  unsigned long r;\n  asm (\"\" : \"=r\" (r) : \"0\" (x));\n  return r >> 31;\n}\n\nint foo (B *x)\n{\n  A *y;\n  y = x->b;\n  y->b = bar (x->c);\n  y->c = ({ unsigned int z = 1; (z << 24) | (z >> 24); });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020314-1.c",
    "content": "typedef struct tux_req_struct tux_req_t;\nstruct tux_req_struct\n{\n        struct socket *sock;\n        char usermode;\n        char *userbuf;\n        unsigned int userlen;\n        char error;\n        void *private;\n};\nvoid user_send_buffer (tux_req_t *req, int cachemiss)\n{\n        int ret;\nrepeat:\n        switch (ret) {\n                case -11:\n                        if (add_output_space_event(req, req->sock)) {\n                                del_tux_atom(req);\n                                goto repeat;\n                        }\n                        do { } while (0);\n                        break;\n                default:\n                        add_req_to_workqueue(req);\n        }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020315-1.c",
    "content": "/* PR bootstrap/4128 */\n\nextern int bar (char *, char *, int, int);\nextern long baz (char *, char *, int, int);\n\nint sgt (char *a, char *b, int c, int d)\n{\n  return bar (a, b, c, d) > 0;\n}\n\nlong dgt (char *a, char *b, int c, int d)\n{\n  return baz (a, b, c, d) > 0;\n}\n\nint sne (char *a, char *b, int c, int d)\n{\n  return bar (a, b, c, d) != 0;\n}\n\nlong dne (char *a, char *b, int c, int d)\n{\n  return baz (a, b, c, d) != 0;\n}\n\nint seq (char *a, char *b, int c, int d)\n{\n  return bar (a, b, c, d) == 0;\n}\n\nlong deq (char *a, char *b, int c, int d)\n{\n  return baz (a, b, c, d) == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020318-1.c",
    "content": "/* PR c/5656\n   This testcase ICEd on IA-32 at -O3, due to tree inliner not converting\n   parameter assignment when using K&R syntax.  */\n\nvoid foo (c)\n     char c;\n{\n  (void) &c;\n}\n\nint bar (void);\n\nvoid baz (void)\n{\n  foo (bar ());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020319-1.c",
    "content": "/* This testcase ICEd in combine.c:do_SUBST() self-test for sign-extended\nCONST_INT because expr.c:expand_expr() was not sign-extending array index\ninto constant strings.  */\n\ntypedef unsigned char uch;\nextern uch outbuf[];\nextern unsigned outcnt;\n\nextern void flush_outbuf (void);\n\nint zip(void)\n{\n  outcnt = 0;\n\n    {outbuf[outcnt++]=(uch)(\"\\037\\213\"[0]); if (outcnt==16384) flush_outbuf();};\n    {outbuf[outcnt++]=(uch)(\"\\037\\213\"[1]); if (outcnt==16384) flush_outbuf();};\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020320-1.c",
    "content": "/* PR bootstrap/4192\n   This testcase caused infinite loop in flow (several places),\n   because flow assumes gen_jump generates simple_jump_p.  */\n\ntypedef void (*T) (void);\nextern T x[];\n\nvoid\nfoo (void)\n{\n  static T *p = x;\n  static _Bool a;\n  T f;\n\n  if (__builtin_expect (a, 0))\n    return;\n\n  while ((f = *p))\n    {\n      p++;\n      f ();\n    }\n  a = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020323-1.c",
    "content": "/* This testcase caused ICE on powerpc at -O3, because regrename did\n   not handle match_dup of match_operator if the RTLs were not shared.  */\n\nstruct A\n{\n  unsigned char *a0, *a1;\n  int a2;\n};\n\nvoid bar (struct A *);\n\nunsigned int\nfoo (int x)\n{\n  struct A a;\n  unsigned int b;\n\n  if (x < -128 || x > 255 || x == -1)\n    return 26;\n\n  a.a0 = (unsigned char *) &b;\n  a.a1 = a.a0 + sizeof (unsigned int);\n  a.a2 = 0;\n  bar (&a);\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020330-1.c",
    "content": "/* PR 5446 */\n/* This testcase is similar to gcc.c-torture/compile/20011219-1.c except\n   with parts of it omitted, causing an ICE with -O3 on IA-64.  */\n\nvoid * baz (unsigned long);\nstatic inline double **\nbar (long w, long x, long y, long z)\n{\n  long i, a = x - w + 1, b = z - y + 1;\n  double **m = (double **) baz (sizeof (double *) * (a + 1));\n\n  m += 1;\n  m -= w;\n  m[w] = (double *) baz (sizeof (double) * (a * b + 1));\n  for (i = w + 1; i <= x; i++)\n    m[i] = m[i - 1] + b;\n  return m;\n}\n\nvoid\nfoo (double w[], int x, double y[], double z[])\n{\n  int i;\n  double **a;\n\n  a = bar (1, 50, 1, 50);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020409-1.c",
    "content": "/* PR c/5078 */\n\n#include <limits.h>\n\nint f(int i)\n{\n  i -= 2 * (INT_MAX + 1);\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020415-1.c",
    "content": "/* Check that floating point casts of integer operations don't ICE.  */\n/* The first of these routines caused problems for a patch, that wasn't\n   otherwise caught by a full bootstrap, the regression test suite or\n   SPEC CPU2000.  */\n\ndouble\nandop (unsigned int x)\n{\n  return x & 1;\n}\n\ndouble\norop (unsigned int x)\n{\n  return x | 1;\n}\n\ndouble\nnotop (unsigned int x)\n{\n  return ~x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020418-1.c",
    "content": "/* PR c/6358\n   This testcase ICEd on IA-32 in foo, because current_function_return_rtx\n   was assigned a hard register only after expand_null_return was called,\n   thus return pseudo was clobbered twice and the hard register not at\n   all.  */\n\nvoid baz (void);\n                       \ndouble foo (void)\n{\n  baz ();\n  return;\n}\n\ndouble bar (void)\n{\n  baz ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020530-1.c",
    "content": "/* PR optimization/6822 */\n\nextern unsigned char foo1 (void);\nextern unsigned short foo2 (void);\n\nint bar1 (void)\n{\n  unsigned char q = foo1 ();\n  return (q < 0x80) ? 64 : 0;\n}\n\nint bar2 (void)\n{\n  unsigned short h = foo2 ();\n  return (h < 0x8000) ? 64 : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020604-1.c",
    "content": "/* { dg-do assemble } */\n/* { dg-require-effective-target ptr32plus } */\n/* { dg-xfail-if \"The array too big\" { \"h8300-*-*\" } { \"-mno-h\" \"-mn\" } { \"\" } } */\n\n/* PR c/6957\n   This testcase ICEd at -O2 on IA-32, because\n   (insn 141 139 142 (set (subreg:SF (reg:QI 72) 0)\n\t   (plus:SF (reg:SF 73)\n\t       (reg:SF 76))) 525 {*fop_sf_comm_nosse} (insn_list 134 (nil))\n       (expr_list:REG_DEAD (reg:SF 73) (nil)))\n   couldn't be reloaded. */\n\nvoid\nfoo (unsigned int n, int x, int y, unsigned char *z)\n{\n  int a, b;\n  float c[2048][4];\n\n  switch (x)\n    {\n    case 0x1906:\n      a = b = -1;\n      break;\n    case 0x190A:\n      a = b = -1;\n      break;\n    case 0x8049:\n      a = b = -1;\n      break;\n    case 0x1907:\n      a = 1;\n      b = 2;\n      break;\n    default:\n      return;\n    }\n\n  if (a >= 0)\n    {\n      unsigned char *d = z;\n      unsigned int i;\n      for (i = 0; i < n; i++)\n\t{\n\t  do\n\t    {\n\t      union\n\t      {\n\t\tfloat r;\n\t\tunsigned int i;\n\t      }\n\t      e;\n\t      e.r = c[i][1];\n\t      d[a] =\n\t\t((e.i >= 0x3f7f0000) ? ((int) e.i <\n\t\t\t\t\t    0) ? (unsigned char) 0\n\t\t : (unsigned char) 255 : (e.r =\n\t\t\t\t\t  e.r * (255.0F / 256.0F) +\n\t\t\t\t\t  32768.0F, (unsigned char) e.i));\n\t    }\n\t  while (0);\n\t  d += y;\n\t}\n    }\n\n  if (b >= 0)\n    {\n      unsigned char *d = z;\n      unsigned int i;\n      for (i = 0; i < n; i++)\n\t{\n\t  do\n\t    {\n\t      union\n\t      {\n\t\tfloat r;\n\t\tunsigned int i;\n\t      }\n\t      e;\n\t      e.r = c[i][2];\n\t      d[b] =\n\t\t((e.i >= 0x3f7f0000) ? ((int) e.i <\n\t\t\t\t\t    0) ? (unsigned char) 0\n\t\t : (unsigned char) 255 : (e.r =\n\t\t\t\t\t  e.r * (255.0F / 256.0F) +\n\t\t\t\t\t  32768.0F, (unsigned char) e.i));\n\t    }\n\t  while (0);\n\t  d += y;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020605-1.c",
    "content": "/* This testcase caused on IA-32 -O2 endless loop in\n   merge_blocks when trying to merge a basic block\n   with itself.  */\n\nvoid f (void)\n{\n  char *c;\n  do\n    {\n      if (c)\n\tbreak;\n    }\n  while (1);\n  if (!c)\n    while (1)\n      f ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020701-1.c",
    "content": "/* PR target/7177\n   Problem with cris-axis-elf: ICE in global.\n   Origin: hp@axis.com.  */\n\ntypedef __SIZE_TYPE__ size_t;\nvoid f1 (void *);\nchar *f2 (const char *);\nint atoi (const char *);\nchar *strchr (const char *, int);\nint strcmp (const char *, const char *);\nsize_t strlen (const char *);\ntypedef enum { A, B, C } t1;\nextern const char _v[];\n\nstatic t1\nf (const char* p1, const char* p2, char p3)\n{\n  char *v1;\n  char *v2;\n  char *a;\n  char *v3;\n  char *v4;\n  char *v5;\n  char *e;\n  char *v6;\n  t1 r = C;\n\n  v1 = f2 (p2);\n  v4 = f2 (p1);\n\n  a = v2 = v1;\n  e = v5 = v4;\n  memcpy (&e, &e, sizeof (e));\n\n  v3 = strchr (v2, ',');\n  v6 = strchr (v5, ',');\n\n  while ((_v + 1)[(unsigned) *a] & 4)\n    a++;\n  while ((_v + 1)[(unsigned) *e] & 4)\n    e++;\n\n  if (a == v3 && e == v6)\n    {\n      if (p3)\n        r = atoi (v5) < atoi (v2) ? B : A;\n      else\n        r = atoi (v5) > atoi (v2) ? B : A;\n      v2 = ++a;\n      v5 = ++e;\n      v3 = strchr (v2, ',');\n      v6 = strchr (v5, ',');\n\n      while ((_v + 1)[(unsigned) *a] & 4)\n        a++;\n      while ((_v + 1)[(unsigned) *e] & 4)\n        e++;\n\n      if (a == v3 && e == v6)\n        {\n          if (r == B)\n            r = B;\n          else if (p3)\n            r = atoi (v5) < atoi (v2) ? B : A;\n          else\n            r = atoi (v5) > atoi (v2) ? B : A;\n        }\n      else\n        r = C;\n    }\n\n  f1 (v1);\n  f1 (v4);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020706-1.c",
    "content": "// Contributed by Alexandre Oliva <aoliva@redhat.com>\n// From Red Hat case 106165.\n\ntypedef struct s1\n{\n  unsigned short v1;\n  unsigned char *v2;\n} S1;\n\nextern void bar(const struct s1 *const hdb);\nextern unsigned char* foo ();\n\nunsigned int sn;\nS1 *hdb;\nS1 *pb;\nunsigned short len;\n\nunsigned int crashIt()\n{\n  unsigned char *p;\n  unsigned int nsn;\n  unsigned short cnt;\n\n  if (sn != 0) return 1;\n\n  if ((len < 12) || ((p = (((pb->v1) >= 8) ? pb->v2 : foo() )) == 0))\n    return 1;\n\n  nsn = (\n\t (((*(unsigned int*)p) & 0x000000ff) << 24) |\n\t (((*(unsigned int*)p) & 0x0000ff00) << 8)  |\n\t (((*(unsigned int*)p) & 0x00ff0000) >> 8)  |\n\t (((*(unsigned int*)p) & 0xff000000) >> 24)  );\n  p += 4;\n\n  cnt = (unsigned short) ((\n\t\t\t   (((*(unsigned int*)p) & 0x000000ff) << 24) |\n\t\t\t   (((*(unsigned int*)p) & 0x0000ff00) << 8)  |\n\t\t\t   (((*(unsigned int*)p) & 0x00ff0000) >> 8)  |\n\t\t\t   (((*(unsigned int*)p) & 0xff000000) >> 24)  ) &\n\t\t\t  0xffff);\n\n  if ((len != 12 + (cnt * 56)) || (nsn == 0))\n    {\n      bar(hdb);\n      return 1;\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020706-2.c",
    "content": "// Contributed by Alexandre Oliva <aoliva@redhat.com>\n// From Red Hat case 106165.\n\ntypedef unsigned short (FUNC_P) (void *, unsigned char *, unsigned short);\n\nvoid crashIt(int id, FUNC_P *func, unsigned char *funcparm)\n{\n  unsigned char buff[5], reverse[4];\n  unsigned char *bp = buff;\n  unsigned char *rp = reverse;\n  unsigned short int count = 0;\n  unsigned short cnt;\n  while (id > 0)\n    {\n      *rp++ = (unsigned char) (id & 0x7F);\n      id >>= 7;\n      count++;\n    }\n  cnt = count + 1;\n  while ((count--) > 1)\n    {\n      *bp++ = (unsigned char)(*(--rp) | 0x80);\n    }\n  *bp++ = *(--rp);\n  (void)(*func)(funcparm, buff, cnt);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020709-1.c",
    "content": "extern double atof (__const char *__nptr) __attribute__ ((__pure__));\n\nvoid bar (char *s)\n{\n  union {double val; unsigned int a, b;} u;\n  u.val = atof (s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020710-1.c",
    "content": "/* Red Hat bugzilla #68395\n   PR middle-end/7245\n   This testcase ICEd on IA-32 because shift & compare patterns\n   predicates allowed any immediate, but constraints allowed only\n   numbers from 1 to 31.  */\n\nvoid foo (int *x, unsigned int y)\n{\n  int a = y >> -13;\n  if (a)\n    *x = a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020715-1.c",
    "content": "/* PR optimization/7153 */\n/* Verify that GCC doesn't promote a register when its\n   lifetime is not limited to one basic block. */\n\nvoid f(char);\nvoid g(void);\n\nvoid scale(void)\n{\n  int width;\n  char bytes;\n  char *src;\n\n  if (width)\n  {\n    bytes = *src;\n    g();\n    width *= bytes;\n  }\n\n  f(bytes);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020807-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nint x;\n\nstatic int\n__attribute__ ((noinline))\nfoo (void)\n{\n  return 0;\n}\n\nstatic void\n__attribute__ ((noinline))\nbar (void)\n{\n}\n\nstatic inline void\nbaz (void)\n{\n  char arr[x];\n\nlab:\n  if (foo () == -1)\n    {\n      bar ();\n      goto lab;\n    }\n}\n\nvoid\ntest (void)\n{\n  baz ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020910-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint a;\n#else\nunsigned int  x0  = 0;\n\ntypedef struct {\n  unsigned int  field1 : 20;\n  unsigned int  field2 : 12;\n} XX;\n\nstatic XX yy;\n\nstatic void foo (void)\n{\n  yy.field1 = (unsigned int ) (&x0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020926-1.c",
    "content": "/* PR c/7160 */\n/* Verify that the register-to-stack converter properly handles\n   branches without return value containing function calls.  */\n   \nextern int gi;\n\nextern int foo1(int, int);\nextern void foo2(int, int);\nextern float foo3(int);\n\nfloat bar(int i1, int i2)\n{\n  int i3;\n    \n  if (i2) {\n    i3 = foo1(i1, gi);\n    foo2(i1, i3);\n  }\n  else\n    return foo3(i2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020927-1.c",
    "content": "/* PR optimization/7520 */\n/* ICE at -O3 on x86 due to register life problems caused by\n   the return-without-value in bar.  */\n\nint\nfoo ()\n{\n  int i;\n  long long int j;\n\n  while (1)\n    {\n      if (j & 1)\n\t++i;\n      j >>= 1;\n      if (j)\n\treturn i;\n    }\n}\n\nint\nbar ()\n{\n  if (foo ())\n    return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20020930-1.c",
    "content": "/* PR c/8002 */\n\nfloat expm1f(float x) {\n     union {\n         float value;\n         unsigned word;\n     } sf_u;\n     sf_u.word = (unsigned) x * 2;\n     return x + sf_u.value;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021001-1.c",
    "content": "int foo (double x, double y)\n{\n  return !__builtin_isunordered (x, y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021007-1.c",
    "content": "/* PR c/7411 */\n/* Verify that GCC simplifies the null addition to i before\n   virtual register substitution tries it and winds up with\n   a memory to memory move.  */\n                        \nvoid foo ()     \n{\n   int i = 0,j;\n \n   i+=j=0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021008-1.c",
    "content": "/* Origin: PR target/7434 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> */\n\nint main(void)\n{\n  static const int align_g[] = { 1, 2, 4, 8, 16 };\n  char * buf;\n  int i = 0;\n  volatile long double val = 0;\n  val = *((long double *)(buf + align_g[i]));\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021015-1.c",
    "content": "/* PR target/7370.  */\n\nint g (int *x, int *y);\n\nvoid f ()\n{\n  int x, y;\n  char a[4000];\n\n  g (&x, &y);\n  x = x/y + x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021015-2.c",
    "content": "/* PR target/8232.  */\n/* { dg-require-effective-target untyped_assembly } */\n\nint f (char *p, char *q, int i)\n{\n  return bcmp (p, q, i);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021103-1.c",
    "content": "/* PR middle-end/8408 */\n/* Verify that the recognizer explicitly\n   handles ADDRESSOF operands. */\n\nvoid foo(void)\n{\n  double d1 = 3.14159, d2;\n  if (&d2 == &d1)\n     ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021108-1.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nint\nmain()\n{\nl1:\n  return &&l1-&&l2;\nl2:;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021110.c",
    "content": "/* PR c/8439 */\n/* Verify that GCC properly handles null increments. */\n\nstruct empty {\n};\n\nvoid foo(struct empty *p)\n{\n   p++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021119-1.c",
    "content": "/* PR c/8588 */\n/* Contributed by Volker Reichelt. */\n\n/* Verify that GCC converts integer constants\n   in shift operations. */\n   \nvoid foo()\n{\n  unsigned int i, j;\n  j = (i >> 0xf0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021120-1.c",
    "content": "/* PR c/8518 */\n/* Contributed by Volker Reichelt. */\n\n/* Verify that GCC doesn't get confused by the\n   redefinition of an extern inline function. */\n\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern int inline foo () { return 0; }\nextern int inline bar () { return 0; }\nstatic int inline bar () { return foo(); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021120-2.c",
    "content": "/* PR c/8518 */\n/* Contributed by Volker Reichelt. */\n\n/* Verify that GCC doesn't get confused by the\n   redefinition of an extern inline function. */\n\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern int inline foo () { return 0; }\nextern int inline bar () { return 0; }\nstatic int bar () { return foo(); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021124-1.c",
    "content": "/* PR optimization/8275 */\n/* Contributed by Volker Reichelt. */\n\nunsigned int foo (unsigned int u)\n{\n  return (u >> 32) & 0xffff;\n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021204-1.c",
    "content": "/* PR c/7622 */\n\n/* Verify that GCC can handle the mix of\n   extern inline and nested functions. */\n\nextern inline int t()\n{\n  int q() { return 0; }\n\n  return q();\n}\n\nint foo()\n{\n  return t();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021205-1.c",
    "content": "typedef struct x x;\nextern void *baz(char *);\nstruct x { char * (*bar) (int); };\nstatic x **foo() { return ((x**)baz(0)); }\nint xyzzy()\n{\n    baz((*foo())->bar(0));\n    return 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021212-1.c",
    "content": "/* PR optimization/8334 */\n/* Verify that GCC produces valid operands\n   after simplifying an addition. */\n\nvoid foo(int m, int n, double *f)\n{\n  int i, j, k = 1;\n\n  for (j = 0; j < n; j++) {\n    for (i = k; i < m; i++) {\n      f[i] = (double) (i * j);\n      f[i + j] = (double) ((i + 1) * j);\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20021230-1.c",
    "content": "/* SH has special handling for combined and/shift sequences.  Make\n   sure that it behaves properly when one input is in the MACL register.  */\nint r, t;\n\nstatic void initRGB()\n{\n  t = ((r*255/3) & 0xff) << 16;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030109-1.c",
    "content": "void foo ()\n{\n  int x1, x2, x3;\n\n  bar (&x2 - &x1, &x3 - &x2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030110-1.c",
    "content": "extern char bpp;\n\nvoid foo()\n{\n  if (bpp == 32)\n    {\n      if (2 < 8)\n\t{\n\t  do\n\t    {\n\t      while (inb(0x9ae8) & (0x0100 >> (2 +1)));\n\t    }\n\t  while(0);\n\t}\n      else\n\t{\n\t  do\n\t    {\n\t      while (inb(0x9ae8) & (0x0100 >> (2)));\n\t    }\n\t  while(0);\n\t}\n    }\n  else\n    do\n      { \n\twhile (inb(0x9ae8) & (0x0100 >> (1)));\n      }\n    while(0);\n  if (8 < 8)\n    {\n      do\n\t{\n\t  while (inb(0x9ae8) & (0x0100 >> (8 +1)));\n\t}\n      while(0);\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030125-1.c",
    "content": " int count;\n\n int func(int *valp) {\n   int val, locked = 0;\n\n   while ((val = *valp) != 0) {\n     if (count) {\n       if (count)\n         locked = 1;\n       else\n         locked = 1;\n\n     if (!locked)\n       continue;\n     }\n\n     if (!count)\n       count--;\n\n     break;\n   }\n\n   return val;\n }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030206-1.c",
    "content": "/* PR c/9530 */\n/* Contributed by Volker Reichelt. */\n\n/* Verify that the call to 'foo' is not turned\n   into a sibling call.  */\n\nvoid foo(float d);\n\nfloat bar(float d);\n\nfloat baz(float d)\n{\n  foo(bar(d));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030216-1.c",
    "content": "/* PR c/8086  */\n\n#define P(x) \\\n        ((((((((((((((((((((((((((((((((        \\\n         (x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)                 \\\n         *(x)+a)\n\nint\npolynomial(int a)\n{\n  return P(3);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030219-1.c",
    "content": "int global_one;\n\nvoid clobber_register()\n{\n  *(volatile unsigned char *)(0xE0000000 * global_one) = 0x00;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030220-1.c",
    "content": "/* PR optimization/9768 */\n/* Originator: Randolph Chung <tausq@debian.org> */\n\ninline int fixfloor (long x)\n{\n  if (x >= 0)\n    return (x >> 16);\n  else\n    return ~((~x) >> 16);\n}\n\ninline int fixtoi (long x)\n{\n  return fixfloor(x) + ((x & 0x8000) >> 15);\n}\n\nint foo(long x, long y)\n{\n  return fixtoi(x*y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030224-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nvoid zzz (char *s1, char *s2, int len, int *q)\n{\n  int z = 5;\n  unsigned int i,  b;\n  struct { char a[z]; } x;\n          \n  for (i = 0; i < len; i++)\n    s1[i] = s2[i];\n\n  b = z & 0x3;\n\n  len += (b == 0 ? 0 : 1) + z;\n    \n  *q = len;\n\n  foo (x, x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030305-1.c",
    "content": "/* PR c/9799 */\n/* Verify that GCC doesn't crash on excess elements\n   in initializer for a flexible array member.  */\n\ntypedef struct {\n    int aaa;\n} s1_t;\n\ntypedef struct {\n    int bbb;\n    s1_t s1_array[];\n} s2_t;\n\nstatic s2_t s2_array[]= {\n    { 1, 4 },\t/* { dg-error \"(initialization of flexible array member|near)\" } */\n    { 2, 5 },\t/* { dg-error \"(initialization of flexible array member|near)\" } */\n    { 3, 6 }\t/* { dg-error \"(initialization of flexible array member|near)\" } */\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030310-1.c",
    "content": "static inline void\nfoo (char accept)\n{\n  char s;\n  while (s == accept) ;\n}\n\nstatic void\nbar (void)\n{\n  char ch;\n  foo (ch);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030314-1.c",
    "content": "/* PR optimization/8396 */\n/* Originator: <papadopo@shfj.cea.fr> */\n\n/* Verify that the tree inliner doesn't mess up the types\n   when passing the value of read-only constant arguments.  */\n\nstatic inline bar(const short int xs, const short int xe)\n{\n  if (xe && (xs < xe))\n    ;\n}\n  \nvoid f()\n{\n  short int xe;\n\n  bar(0, xe);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030319-1.c",
    "content": "/* PR 10073 */\ntypedef struct\n{\n  unsigned short digits[4];\n} INT_64;\n\nINT_64 int_64_com (INT_64 a)\n{\n  a.digits[0] ^= 0xFFFF;\n  a.digits[1] ^= 0xFFFF;\n  a.digits[2] ^= 0xFFFF;\n  a.digits[3] ^= 0xFFFF;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030320-1.c",
    "content": "/* Failed on powerpc64-linux with a segfault due to ifcvt generating\n   conditional returns without updating dominance info.\n   Extracted from glibc's dl-load.c.  */\n\ntypedef __SIZE_TYPE__ size_t;\n\nstatic size_t\nis_dst (const char *start, const char *name, const char *str,\n        int is_path, int secure)\n{\n  size_t len;\n  _Bool is_curly = 0;\n\n  if (name[0] == '{')\n    {\n      is_curly = 1;\n      ++name;\n    }\n\n  len = 0;\n  while (name[len] == str[len] && name[len] != '\\0')\n    ++len;\n\n  if (is_curly)\n    {\n      if (name[len] != '}')\n        return 0;\n\n\n      --name;\n\n      len += 2;\n    }\n  else if (name[len] != '\\0' && name[len] != '/'\n           && (!is_path || name[len] != ':'))\n    return 0;\n\n  if (__builtin_expect (secure, 0)\n      && ((name[len] != '\\0' && (!is_path || name[len] != ':'))\n          || (name != start + 1 && (!is_path || name[-2] != ':'))))\n    return 0;\n\n  return len;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030323-1.c",
    "content": "/* PR c/10178.  The following code would ICE because we didn't check for\n   overflow when computing the range of the switch-statment, and therefore\n   decided it could be implemented using bit-tests.  */\n\nint\nbanana(long citron)\n{\n  switch (citron) {\n    case 0x80000000:\n    case 0x40000:\n    case 0x40001:\n      return 1;\n      break;\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030330-1.c",
    "content": "/* PR c/10083 */\n/* This will result in a very small constant for umul_highpart, which\n   uncovered a bug in the Alpha machine description.  */\n\nunsigned long f(unsigned long x) {\n    return x % 0x3fffffffffffffff;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030331-1.c",
    "content": "/* From PR/9301.  Fixed by ebotcazou's patch for PR/9493.  */\n\nvoid bar (void);\n\nvoid foo (int a, int b, int c, int d, int e)\n{\n  if (a)\n    bar();\n  if (b && c)\n    ;\n  if (d && e)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030405-1.c",
    "content": "/* When compiled with -pedantic, this program will cause an ICE when the\n   constant propagator tries to set the value of *str to UNDEFINED.\n   \n   This happens because *str is erroneously considered as a store alias.\n   The aliasing code is then making *str an alias leader for its alias set\n   and when the PHI node at the end of the while() is visited the first\n   time, CCP will try to assign it a value of UNDEFINED, but the default\n   value for *str is a constant.  */\ntypedef\t__SIZE_TYPE__ size_t;\nsize_t strlength (const char * const);\nchar foo();\n\nstatic const char * const str = \"mingo\";\n\nbar()\n{\n  size_t c;\n  char *x;\n\n  c = strlength (str);\n  while (c < 10)\n    {\n      if (c > 5)\n\t*x = foo ();\n      if (*x < 'a')\n\tbreak;\n    }\n\n  return *x == '3';\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030410-1.c",
    "content": "/* PR 10201 */\n\nextern struct _zend_compiler_globals compiler_globals;\ntypedef struct _zend_executor_globals zend_executor_globals;\nextern zend_executor_globals executor_globals;\n\ntypedef struct _zend_ptr_stack {\n        int top;\n        void **top_element;\n} zend_ptr_stack;\nstruct _zend_compiler_globals {\n};\nstruct _zend_executor_globals {\n        int *uninitialized_zval_ptr;\n        zend_ptr_stack argument_stack;\n};\n\nstatic inline void safe_free_zval_ptr(int *p)\n{\n        if (p!=(executor_globals.uninitialized_zval_ptr)) {\n        }\n}\nzend_executor_globals executor_globals;\nstatic inline void zend_ptr_stack_clear_multiple(void)\n{\n        executor_globals.argument_stack.top -= 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030415-1.c",
    "content": "float g(float f)\n{\n  return fabs(f);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030416-1.c",
    "content": "void foo(int x)\n{\n  if (x > 3)\n    {;}\n  else\n    bar();\n  x = 9;\n}\n\nmain()\n{\n  int j;\n\n  foo(j);\n  return j;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030418-1.c",
    "content": "/* PR optimization/7675 */\n/* Contributed by Volker Reichelt */\n\n/* Verify that we don't put automatic variables\n   in registers too early.  */\n\nextern int dummy (int *);\n\nvoid foo(int i)\n{\n  int j=i;\n\n  void bar() { int x=j, y=i; }\n\n  dummy(&i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030503-1.c",
    "content": "void foo ()\n{\n  if (1)\n    goto foo;\n  else\n    for (;;)\n      {\n      foo:\n\tbar ();\n\treturn;\n      }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030518-1.c",
    "content": "/* Test case from PR middle-end/10472  */\n\nextern void f (char *);\n\nvoid foo (char *s)\n{\n  f (__builtin_stpcpy (s, \"hi\"));\n}\n\nvoid bar (char *s)\n{\n  f (__builtin_mempcpy (s, \"hi\", 3));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030530-1.c",
    "content": "union tree_node;\ntypedef union tree_node *tree;\nstruct tree_common\n{\n  tree type;\n  unsigned lang_flag_0 : 1;\n};\nunion tree_node\n{\n  struct tree_common common;\n};\nstatic void\njava_check_regular_methods (tree class_decl)\n{\n  int saw_constructor = class_decl->common.type->common.lang_flag_0;\n  tree class = class_decl->common.type;\n  for (;;)\n    {\n      if (class)\n        if (class_decl->common.type)\n          bar (class);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030530-3.c",
    "content": "struct tree_decl\n{\n  unsigned in_system_header_flag:1;\n};\nunion tree_node\n{\n  struct tree_decl decl;\n};\ntypedef union tree_node *tree;\nstatic int\nredeclaration_error_message (olddecl)\n     tree olddecl;\n{\n  if (({olddecl;})->decl.in_system_header_flag)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030604-1.c",
    "content": "/* PR optimization/10876 */\n/* Contributed by Christian Ehrhardt */\n\n/* Verify that the SPARC port doesn't emit\n   (minus) (reg) (const_int) insns.  */\n\nvoid f(void)\n{\n  unsigned int butterfly, block, offset;\n  double *Z;\n\n  for (block = 0; block < 512; block += 512) {\n    double T1re, T2re;\n    offset = butterfly + block;\n    T1re += T2re;\n    T2re = Z[offset] + T1re;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030605-1.c",
    "content": "/* Test for proper preparation of the comparison operands for \n   generation of a conditional trap.  Produced unrecognizable\n   rtl on Sparc.  */\n\nstruct blah { char *b_data; };\n\nvoid set_bh_page(struct blah *bh, unsigned long offset)\n{\n        if ((1UL << 12 ) <= offset)\n                __builtin_trap() ;\n        bh->b_data = (char *)offset;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030612-1.c",
    "content": "static inline void\nfoo (long long const v0, long long const v1)\n{\n  bar (v0 == v1);\n}\n\nvoid\ntest (void)\n{\n  foo (0, 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030624-1.c",
    "content": "/* Derived from PR optimization/11311 */\n\ndouble pow(double, double);\n\ndouble foo(double x) { return pow(x,261); }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030703-1.c",
    "content": "/* Extracted from PR target/10700.  */\n/* The following code used to cause an ICE on 64-bit targets.  */\n\nint SAD_Block(int *);\nvoid MBMotionEstimation(int *act_block, int block)\n{\n    SAD_Block(act_block + (  (8 * (block == 1 || block == 3))\n                          + (8 * (block == 2 || block == 3))));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030704-1.c",
    "content": "/* PR c/11428.  */\n\n/* fold_single_bit_test() failed to return a tree of the type that the\n   outer expression was looking for.  Specifically, it returned a tree\n   whose type corresponded to QImode for !p->m, but the desired result\n   type was int, which corresponded to SImode.  emit_move_insn() later\n   tried to copy a reg:QI to reg:SI, causing an ICE.  */\n\nstruct s {\n  int m : 1;\n};\n\nint\nfoo (struct s *p)\n{\n  return !p->m;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030707-1.c",
    "content": "/* PR c/11449.  */\n\n/* sign_bit_p() in fold-const.c failed to notice that (int) 0x80000000\n   was the sign bit of m.  As a result, fold_single_bit_test()\n   returned ((unsigned int) m >> 31), and that was eventually passed\n   to invert_truthvalue(), which did not know how to handle\n   RROTATE_EXPR, causing an ICE.  */\n\nint\nfoo (int m)\n{\n  return !(m & ((int) 0x80000000));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030708-1.c",
    "content": "/* PR 10795.  */\n\n/* ix86_expand_carry_flag_compare() in i386.c swapped the comparison\n   operands without checking that the compare instruction, cmpl, would\n   accept the swapped operands.  */\n\nextern const char a[];\n\nint\nfoo (const char *p)\n{\n  return (p > a) ? 0 : 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030716-1.c",
    "content": "void baz(int i);\n\nvoid foo(int i, int A[i+1])\n{\n    int j=A[i];\n    void bar() { baz(A[i]); }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030725-1.c",
    "content": "/* This testcase caused ICE on any 64-bit arch at -O2/-O3 due to\n   fold/extract_muldiv/convert destroying its argument.  */\nint x, *y, z, *p;\n\nvoid\nfoo (void)\n{\n  p = y + (8 * (x == 1 || x == 3) + z);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030804-1.c",
    "content": "/* Extracted from PR middle-end/11771.  */\n/* The following testcase used to ICE without -ffast-math from unbounded\n   recursion in fold.  This was due to the logic in negate_expr_p not\n   matching that in negate_expr.  */\n\ndouble f(double x) {\n    return -(1 - x) + (x ? -(1 - x) : 0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030821-1.c",
    "content": "/* PR target/11805.  */\n\n/* Consider the following sequence.\n\n     (set (cc0)\n\t  (and:HI (reg:HI 0)\n\t\t  (const_int 1)))\n\n     (set (pc)\n\t  (if_then_else (le (cc0)\n\t\t\t    (const_int 0))\n\t\t\t(label_ref 17)\n\t\t\t(pc)))\n\n   On h8300, the first insn does not set the overflow flag, but the\n   second requires the overflow flag.  As a result, when the final\n   wants to output the jump insn, it cannot find a test insn that\n   gives appropriate condition flags.  */\n\nunsigned char\nfoo (unsigned char a)\n{\n  return (a & 1) > 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030823-1.c",
    "content": "struct A\n{\n  int a;\n};\n\nint foo (struct A *a)\n{\n  static int c = 30;\n  int x;\n\n  a->a = c;\n  /* Dominator optimizations will replace the use of 'a->a' with 'c', but\n     they won't copy the virtual operands for 'c' from its originating\n     statement.  This exposes symbol 'c' without a correct SSA version\n     number.  */\n  x = a->a;\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030902-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef unsigned long int reg_syntax_t;\nstruct re_pattern_buffer\n{\n  unsigned char *buffer;\n};\ntypedef enum\n{\n  jump,\n  jump_n,\n} re_opcode_t;\nstatic int\nfoo (bufp)\n     struct re_pattern_buffer *bufp;\n{\n  int mcnt;\n  unsigned char *p = bufp->buffer;\n  switch (((re_opcode_t) * p++))\n    {\n    unconditional_jump:\n      ;\n      /* This test case caused an ICE because the statement insertion\n\t routines were failing to update basic block boundaries.  */\n    case jump:\n      do\n        {\n          (mcnt) = *(p) & 0377;\n        }\n      while (0);\n      (p) += 2;\n      p += mcnt;\n    case jump_n:\n      (mcnt) = *(p + 2) & 0377;\n      if (mcnt)\n        goto unconditional_jump;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030903-1.c",
    "content": "/* Derived from PR optimization/11700.  */\n/* The compiler used to ICE during reload for m68k targets.  */\n\nvoid check_complex (__complex__ double, __complex__ double,\n                    __complex__ double, __complex__ int);\nvoid check_float (double, double, double, int);\nextern double _Complex conj (double _Complex);\nextern double carg (double _Complex __z);\n\nstatic double minus_zero;\n\nvoid\nconj_test (void)\n{\n  check_complex (conj (({ __complex__ double __retval;\n\t\t\t  __real__ __retval = (0.0);\n\t\t\t  __imag__ __retval = (0.0);\n\t\t\t  __retval; })),\n\t\t ({ __complex__ double __retval;\n\t\t    __real__ __retval = (0.0);\n\t\t    __imag__ __retval = (minus_zero);\n\t\t    __retval; }), 0, 0);\n}\n\nvoid\ncarg_test (void)\n{\n  check_float (carg (({ __complex__ double __retval;\n\t\t\t__real__ __retval = (2.0);\n\t\t\t__imag__ __retval = (0);\n\t\t\t__retval; })), 0, 0, 0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030904-1.c",
    "content": "struct A\n{\n  long a1;\n  double *a2;\n};\n\nstruct B\n{\n  void *b1;\n  double b2, b3;\n  struct\n  {\n    int d1;\n    double d2;\n  } b4;\n};\n\nstruct C\n{\n  struct A *c1;\n  void *c2;\n};\n\nlong fn1 (struct A *, double);\nvoid fn2 (void *, const char *);\ndouble fn3 (double);\ndouble fn4 (double);\nint fn5 (void *, double, double);\n\nint\nfoo (struct B *x)\n{\n  struct C *e = x->b1;\n  struct A *f = e->c1;\n  long g, h, i;\n  double *j, k;\n  g = fn1 (f, 0.5 * (x->b2 + x->b3)), h = g + 1, i = f->a1;\n  j = f->a2, k = x->b4.d2;\n  fn2 (x, \"something\");\n  if (g <= 0)\n    {\n      double l = j[2] - j[1];\n      if (l > 0.0 && l <= 0.02)\n        k = (x->b4.d1 == 1\n             ? ((1.0 / l) < 25 ? 25 : (1.0 / l))\n             : fn3 ((1.0 / l) < 25 ? 25 : (1.0 / l)));\n    }\n  else\n    {\n      double m = j[h] - j[g], n = 0.0, l = 0.0;\n      if (g > 1)\n        n = j[g] - j[g - 1];\n      if (h < i)\n        l = j[h + 1] - j[h];\n      if (n > 0.02)\n        n = 0;\n      if (m > 0.02)\n        m = 0;\n      if (l > 0.02)\n        l = 0;\n      if (m < n)\n        {\n          double o = m;\n          m = n;\n          n = o;\n        }\n      if (l < n)\n        {\n          double o = l;\n          l = n;\n          n = o;\n        }\n      if (l < m)\n        {\n          double o = l;\n          l = m;\n          m = o;\n        }\n      if (n != 0.0)\n        k = (x->b4.d1 == 1\n             ? ((1 / m) < 25 ? 25 : (1 / m))\n             : fn3 ((1 / m) < 25 ? 25 : (1 / m)));\n      else if (m != 0.0)\n        k = (x->b4.d1 == 1\n             ? ((2 / (m + l)) < 25 ? 25 : (2 / (m + l)))\n             : fn3 ((2 / (m + l)) < 25 ? 25 : (2 / (m + l))));\n      else if (l != 0.0)\n        k = (x->b4.d1 == 1\n             ? ((1 / l) < 25 ? 25 : (1 / l))\n             : fn3 ((1 / l) < 25 ? 25 : (1 / l)));\n    }\n  fn5 (e->c2, 0.5 * (x->b2 + x->b3), (x->b4.d1 == 1 ? k : fn4 (k)));\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030907-1.c",
    "content": "/* PR 11665 \n   Orgin: jwhite@cse.unl.edu\n   The problem was in initializer_constant_valid_p,\n   \"for a CONSTRUCTOR, only the last element\n   of the CONSTRUCTOR was being checked\" \n   (from the email of the patch which fixed this).  \n   This used to ICE because GCC thought gdt_table was a \n   constant value when it is not.  */\n\nint x;\nstruct gdt\n{\nunsigned a,b,c,d,e,f;\n};\nvoid f()\n{\nstruct gdt gdt_table[2]=\n{\n    {\n\t\t0,\n\t\t( (((unsigned)(&x))<<(24))&(-1<<(8)) ),\n    },\n};\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030910-1.c",
    "content": "/* The gimplifier was getting confused when taking the real or\n   imaginary component of a complex rvalue.  */\n\nvoid test()\n{\n  __complex double dc;\n  double d;\n\n  d = __real (dc * dc);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030917-1.c",
    "content": "typedef struct string STR;\ntypedef struct atbl ARRAY;\nstruct string {\n    unsigned char str_pok;\n};\nstruct atbl {\n    int ary_fill;\n};\nblah(size,strp)\nregister int size;\nregister STR **strp;\n{\n    register ARRAY *ar;\n    ar->ary_fill = size - 1;\n    while (size--)\n     (*strp)->str_pok &= ~128;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20030921-1.c",
    "content": "/* PR 12281  The darwin back-end was causing the function \n   f is not being emitted. TREE_SYMBOL_REFERENCED was being set\n   instead of calling mark_referenced.  */\n\n\nstatic void f(void);\nvoid g(void (*x) (void)){x();}\nstatic inline void f(void){}\nvoid h(){g(f);}\nint main(){h();return 0;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031002-1.c",
    "content": "/* PR/12292\n   http://gcc.gnu.org/ml/gcc-patches/2003-10/msg00143.html  */\n\nchar flags;\n\nint bug12292(int t)\n{\n\tflags &= ~(1 << (t + 4));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031010-1.c",
    "content": "/* This crashed the ARM backend with -mcpu=iwmmxt -O because an insn\n   required a split which was not available for the iwmmxt.  */\ninline int *f1(int* a, int* b) { if (*b < *a) return b; return a; }\nint f2(char *d, char *e, int f) { int g = e - d; return *f1(&f, &g); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031011-1.c",
    "content": "/* PR optimization/12544 */\n/* Origin: Tony Hosking <hosking@cs.purdue.edu> */\n\n/* Verify that non-local structures passed by invisible\n   reference are correctly put in the stack.  */\n\ntypedef struct {\n  int a;\n  int f;\n} A;\n\nA *b;\n\nvoid x (A a) {\n  void y () {\n    a.a = 0;\n  }\n\n  b = &a;\n  y();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031011-2.c",
    "content": "/* PR optimization/12260.  */\n\nextern int f(void);\nextern int g(int);\n\nstatic char buf[512];\nvoid h(int l) {\n    while (l) {\n        char *op = buf;\n        if (f() == 0)\n            break;\n        if (g(op - buf + 1))\n            break;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031023-1.c",
    "content": "/* Declaration of the frame size doesn't work on ptx.  */\n/* { dg-require-effective-target untyped_assembly } */\n#ifndef ASIZE\n# define ASIZE 0x10000000000UL\n#endif\n\n#include <limits.h>\n\n#if LONG_MAX < 8 * ASIZE\n# undef ASIZE\n# define ASIZE 4096\n#endif\n\nextern void abort (void);\n\nint __attribute__((noinline))\nfoo (const char *s)\n{\n  if (!s)\n    return 1;\n  if (s[0] != 'a')\n    abort ();\n  s += ASIZE - 1;\n  if (s[0] != 'b')\n    abort ();\n  return 0;\n}\n\nint (*fn) (const char *) = foo;\n\nint __attribute__((noinline))\nbar (void)\n{\n  char s[ASIZE];\n  s[0] = 'a';\n  s[ASIZE - 1] = 'b';\n  foo (s);\n  foo (s);\n  return 0;\n}\n\nint __attribute__((noinline))\nbaz (long i)\n{\n  if (i)\n    return fn (0);\n  else\n    {\n      char s[ASIZE];\n      s[0] = 'a';\n      s[ASIZE - 1] = 'b';\n      foo (s);\n      foo (s);\n      return fn (0);\n    }\n}\n\nint\nmain (void)\n{\n  if (bar ())\n    abort ();\n  if (baz (0) != 1)\n    abort ();\n  if (baz (1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031023-2.c",
    "content": "/* Declaration of the frame size doesn't work on ptx.  */\n/* { dg-require-effective-target untyped_assembly } */\n#define ASIZE 0x1000000000UL\n#include \"20031023-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031023-3.c",
    "content": "/* Declaration of the frame size doesn't work on ptx.  */\n/* { dg-require-effective-target untyped_assembly } */\n#define ASIZE 0x100000000UL\n#include \"20031023-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031023-4.c",
    "content": "#define ASIZE 0x80000000UL\n#include \"20031023-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031031-1.c",
    "content": "/* PR/11640 */\n\nint\ninternal_insn_latency (int insn_code, int insn2_code)\n{\n  switch (insn_code)\n    {\n    case 256:\n      switch (insn2_code)\n\t{\n\tcase 267:\n\t  return 8;\n\tcase 266:\n\t  return 8;\n\tcase 265:\n\t  return 8;\n\tcase 264:\n\t  return 8;\n\tcase 263:\n\t  return 8;\n\t}\n      break;\n    case 273:\n      switch (insn2_code)\n\t{\n\tcase 267:\n\t  return 5;\n\tcase 266:\n\t  return 5;\n\tcase 277:\n\t  return 3;\n\t}\n      break;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031031-2.c",
    "content": "/* PR/10239 */\n\nenum node_type\n{\n  INITIAL = 0, FREE,\n  PRECOLORED,\n  SIMPLIFY, SIMPLIFY_SPILL, SIMPLIFY_FAT, FREEZE, SPILL,\n  SELECT,\n  SPILLED, COALESCED, COLORED,\n  LAST_NODE_TYPE\n};\n\ninline void\nput_web (enum node_type type)\n{\n  switch (type)\n    {\n    case INITIAL:\n    case FREE:\n    case FREEZE:\n    case SPILL:\n      foo ();\n      break;\n    case PRECOLORED:\n      bar ();\n      break;\n    default:\n      baz ();\n    }\n}\n\nvoid\nreset_lists ()\n{\n  put_web (INITIAL);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031102-1.c",
    "content": "/* PR optimization/10817.\n   Check that the following code doesn't cause any problems\n   for GCC's if-conversion passes.  */\n\nint foo(int t)\n{\n  int result = 0;\n  if (t != 0)\n    result = t;\n  return result;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031112-1.c",
    "content": "extern __inline int __finite (double __value) { return 0; }\nextern __typeof (__finite) __finite __asm__ (\"\" \"__GI___finite\");\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031113-1.c",
    "content": "/* On Darwin, the stub for simple_cst_equal was not being emitted at all \n   causing the as to die and not create an object file.  */\n\nint\nattribute_list_contained ()\n{\n  return (simple_cst_equal ());\n}\nint\nsimple_cst_list_equal ()\n{\n  return (simple_cst_equal ());\n}\n\n\nint __attribute__((noinline))\nsimple_cst_equal ()\n{\n  return simple_cst_list_equal ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031124-1.c",
    "content": "/* PR 13143 */\n\nint f (void *ptr)\n{\n    extern char const stop[];\n    return ptr >= (void *) &stop;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031125-1.c",
    "content": "short *_offsetTable;\n/* This tests to make sure PRE splits the entry block ->block 0 edge\n   when there are multiple block 0 predecessors.\n   This is done so that we don't end up with an insertion on the \n   entry block -> block 0 edge which would require a split at insertion\n   time.  \n   PR 13163.  */\nvoid proc4WithoutFDFE(char *dst, const char *src, int next_offs, int bw,\n\t\tint bh, int pitch)\n{\n\tdo {\n\t\tint i = bw;\n\t\tint code = *src++;\n\t\tint x, l;\n\t\tint length = *src++ + 1;\n\n\t\tfor (l = 0; l < length; l++) {\n\t\t\tint x;\n\n\t\t\tfor (x = 0; x < 4; x++) ;\n\t\t\tif (i == 0)\n\t\t\t\tdst += pitch * 3;\n\t\t}\n\t\tchar *dst2 = dst + _offsetTable[code] + next_offs;\n\n\t\tfor (x = 0; x < 4; x++) {\n\t\t\tint j = 0;\n\t\t\t(dst + pitch * x)[j] = (dst2 + pitch * x)[j];\n\t\t}\n\t\tdst += pitch * 3;\n\t} while (--bh);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031125-2.c",
    "content": "struct BlobSpan {\n\tint right;\n};\n/* This test makes sure we don't accidentally cause a bad insertion to occur\n   by choosing the wrong variable name so that we end up with a use not\n   dominated by a def. */\nvoid render_blob_line(struct BlobSpan blobdata) {\n\tint buf[4 * 8];\n\tint *data = buf;\n\tint i, n = 0;\n\tif (blobdata.right)\n\t\tn++;\n\tif (n)\n\t\tfor (; i < 2 * n;)\n\t\t\tdata[i] = 0;\n\tn *= 2;\n\tfor (; n;) ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031203-1.c",
    "content": "void make_file_symbol_completion_list (char *);\n/* This tests to make sure PRE doesn't choose the wrong name when\n   inserting phi nodes.  Otherwise, we get uses that aren't dominated\n   by defs.  \n   PR 13177.  */\nvoid location_completer (char *text)\n{\n\tchar *p, *symbol_start = text;\n\tfor (p = text; *p != '\\0'; ++p) {\n\t\tif (*p == '\\\\' && p[1] == '\\'')\n\t\t\tp++;\n\t\telse if (*p == ':')\n\t\t\tsymbol_start = p + 1;\n\t\telse \n\t\t\tsymbol_start = p + 1;\n\t\tmake_file_symbol_completion_list(symbol_start);\n\t}\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031203-2.c",
    "content": "/* Don't ICE on stupid user tricks.  */\n\nint foo(int bar)\n{\n  return (&bar)[-1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031203-3.c",
    "content": "/* Don't ICE on user silliness.  GCC 3.4 and before accepts this without\n   comment; 3.5 warns.  Perhaps eventually we'll declare this an error.  */\n\nvoid bar (void)\n{\n        ({});\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031208-1.c",
    "content": "extern int foo(int, ...);\nint bar(void) {\n  long double l = 1.2345E6;\n  foo(0, l);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031220-1.c",
    "content": "/* PR optimization/13031  */\n/* The following code used to ICE on alphaev67-*-* at -O2 with an\n   unrecognizable instruction, caused by local register allocation\n   substituting a register for a constant in a conditional branch.  */\n\nvoid emit(int, int);\nint f(void);\nstatic int signals[5];\n\nstatic inline void select(int sel, void *klass)\n{\n  emit(klass ? 0 : f(), signals[sel ? 0 : 1]);\n}\n\nvoid all(void *gil, void *l, void *icon)\n{\n  while (l)\n    if (icon)\n      select(0, gil);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031220-2.c",
    "content": "/*  PR target/12749\n  Orgin: Matt Thomas <matt@3am-software.com>\n  This used to cause GCC to write out an instruction for i386 when using a L64 host\n  which gas could not handle because GCC would write a full 64bit hex string out. */\n\n\nfloat fabsf (float);\ntypedef int __int32_t;\ntypedef unsigned int __uint32_t;\ntypedef union\n{\n  float value;\n  __uint32_t word;\n} ieee_float_shape_type;\nextern float __ieee754_expf (float);\nextern float __ieee754_sinhf (float);\nstatic const float one = 1.0, shuge = 1.0e37;\nfloat\n__ieee754_sinhf(float x)\n{\n        float t,w,h;\n        __int32_t ix,jx;\n        do { ieee_float_shape_type gf_u; gf_u.value = (x); (jx) = gf_u.word; } while (0);\n        ix = jx&0x7fffffff;\n        if(ix>=0x7f800000) return x+x;\n        h = 0.5;\n        if (jx<0) h = -h;\n        if (ix < 0x41b00000) {\n            if (ix<0x31800000)\n                if(shuge+x>one) return x;\n            t = expm1f(fabsf(x));\n            if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));\n            return h*(t+t/(t+one));\n        }\n        if (ix < 0x42b17180) return h*__ieee754_expf(fabsf(x));\n        if (ix<=0x42b2d4fc) {\n            w = __ieee754_expf((float)0.5*fabsf(x));\n            t = h*w;\n            return t*w;\n        }\n        return x*shuge;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031227-1.c",
    "content": "/* PR opt/13159 -- test unswitching a loop multiple times.  */\n\nvoid\nfoo (void)\n{\n  long j, k, p, g;\n\n  while (p)\n    {\n      while (k < 0 && j < 0)\n\t;\n      if (g)\n\t;\n      else if (g)\n\t;      \n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20031231-1.c",
    "content": "extern int f1 (int, void *);\nextern int *f2 (void) __attribute__ ((__const__));\nextern int f3 (int, void *);\n\nint\ntest (int x, char *y, int z)\n{\n  int b = 0;\n\n  if (x < 1024)\n    {\n      y[0] = '\\0';\n\n      do\n\t{\n\t  switch (f1 (x, y + b))\n\t    {\n\t    case -1:\n\t      if (b == 0)\n\t\treturn -1;\n\t      else\n\t\treturn b;\n\n\t    default:\n\t      b++;\n\t    }\n\t}\n      while (y[b - 1] != '\\0' && y[b - 1] != '\\n' && b < z);\n    }\n  else\n    {\n      do\n\t{\n\t  switch (f3 (x, y + b))\n\t    {\n\t    case -1:\n\t      if ((*f2 ()) == 4)\n\t\tcontinue;\n\t      if (b == 0)\n\t\treturn -1;\n\t      else\n\t\treturn b;\n\n\t    default:\n\t      b++;\n\t    }\n\t}\n      while (y[b - 1] != '\\0' && y[b - 1] != '\\n' && b < z);\n    }\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040101-1.c",
    "content": "/* { dg-skip-if \"not enough registers\" { pdp11-*-* } { \"-O[12s]\" } { \"\" } } */\n\ntypedef unsigned short uint16_t;\ntypedef unsigned int uint32_t;\n\n#define CF (1<<0)\n#define PF (1<<2)\n#define AF (1<<4)\n#define ZF (1<<6)\n#define SF (1<<7)\n#define OF (1<<11)\n\n#define EFLAGS_BITS (CF|PF|AF|ZF|SF|OF)\n\nvoid test16(uint16_t x, uint32_t eflags)\n{\n        uint16_t bsr_result;\n        uint32_t bsr_eflags;\n        uint16_t bsf_result;\n        uint32_t bsf_eflags;\n\n        __asm volatile(\"\"\n                : \"=&r\" (bsr_result), \"=&r\" (bsr_eflags)\n                : \"r\" (x), \"i\" (~EFLAGS_BITS), \"r\" (eflags));\n        __asm volatile(\"\"\n                : \"=&r\" (bsf_result), \"=&r\" (bsf_eflags)\n                : \"r\" (x), \"i\" (~EFLAGS_BITS), \"r\" (eflags));\n        printf(\"%08x %04x bsrw %02x %08x bsfw %02x %08x\\n\",\n                x, eflags, bsr_result, bsr_eflags, bsf_result, bsf_eflags);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040109-1.c",
    "content": "/* PR target/13380.\n   On m32r, the condition code register, (reg:SI 17), was replaced with\n   a pseudo reg, which would cause an unrecognized insn.  */\n\nvoid\nfoo (unsigned int a, unsigned int b)\n{\n  if (a > b)\n    {\n      while (a)\n\t{\n\t  switch (b)\n\t    {\n\t    default:\n\t      a = 0;\n\t    case 2:\n\t      a = 0;\n\t    case 1:\n\t      a = 0;\n\t    case 0:\n\t      ;\n\t    }\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040121-1.c",
    "content": "/* PR target/12898\n   0x8000 needs multiple instructions to be emitted on Alpha; the\n   fluff around it causes it to be emitted in a no_new_pseudos\n   context, which triggered a problem in alpha.c.  */\n\nvoid f (const char *, ...);\nint g (void);\nvoid *p (void);\n\nint isymBase, ilineBase, sym_hdr, want_line, proc_desc;\nchar *lines;\n\nvoid print_file_desc (int *fdp)\n{\n  char *str_base = p ();\n  int symi, pdi = g ();\n\n  for (symi = 0; isymBase;)\n    {\n      int proc_ptr = proc_desc + pdi;\n      f(\"1\", isymBase, proc_ptr + *fdp, str_base);\n      if (want_line && *fdp)\n\t{\n\t  int delta;\n\t  long cur_line = proc_ptr;\n\t  char *line_ptr = lines + proc_ptr;\n\t  char *line_end = p ();\n\n\t  f(\"2\", sym_hdr);\n\t  while (line_ptr < line_end)\n\t    {\n\t      delta = *line_ptr;\n\t      if (delta)\n\t\tline_ptr++;\n\t      else\n\t\tdelta = line_ptr[1] ^ 0x8000;\n\t      f(\"3\", cur_line, delta);\n\t    }\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040124-1.c",
    "content": "int\nf1 (int a, int b)\n{\n  int i, j, k;\n\n  switch (b)\n    {\n    case (-9):\n      j = 4;\n      break;\n    case (-10):\n      j = 10;\n      break;\n    case (-8):\n      j = 15;\n      break;\n    }\n\n  i = f2 (f3 (b == (-9) ? k : a), j);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040130-1.c",
    "content": "/* PR target/11475 */\n/* Origin: <heinrich.brand@fujitsu-siemens.com> */\n\n/* This used to fail on SPARC because of a broken pattern.  */\n\n#pragma pack(2)\n\nstruct\n{\n  unsigned char G936:7;\n  unsigned short G937:6;\n  unsigned int :4;\n  unsigned short :14;\n  unsigned int G938:8;\n#if __INT_MAX__ >= 2147483647L\n  unsigned int :30;\n#endif\n  unsigned short :16;\n#if __INT_MAX__ >= 2147483647L\n  unsigned int :18;\n#endif\n  unsigned short G939:9;\n} G928b;\n\nvoid TestG928(void)\n{\n  G928b.G936 |= G928b.G939;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040202-1.c",
    "content": "/* PR target/13789 */\n/* Failed on SPARC due to a bug in store_expr.  */\n\nvoid *foo (void *c)\n{\n  void *a = __builtin_extract_return_addr (c);\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040209-1.c",
    "content": "/* The following code used to ICE in fold_convert.  */\n\nfloat ceilf(float);\n\nint foo(float x)\n{\n  return (double)ceilf(x);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040214-1.c",
    "content": "void foo(void)\n{\n  char c;\n\n  for (c = -75; c <= 75; c++)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040214-2.c",
    "content": "/* http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01307.html */\n\ntypedef struct xdef xdef;\nstruct xdef\n{\n  char xtyp;\n  xdef *next;\n  int y;\n};\n\nextern void b ();\nextern void *foo (void *bar);\nextern void *foo2 (void *bar1, void *bar2);\nextern void *qwe;\n\nstatic void\nc (xdef * xp)\n{\n  b (xp);\n}\nstatic void\na (xdef ** xpp)\n{\n  xdef *xp;\n  xp = *xpp;\n\n  foo (xp);\n  xp = foo2 (xp, qwe);\n  b (xp->next);\n  foo (xp);\n  if (xp->y)\n  {\n    foo (xp);\n    if (xp)\n    {\n      xdef *p = foo2 (xp, qwe);\n      foo2 (xp, p);\n      xp = foo (p);\n    }\n    else\n    {\n      foo2 (foo(*xpp), *xpp);\n    }\n  }\n  *xpp = foo2 (xpp, qwe);\n}\n\nvoid\nb (xdef ** xpp)\n{\n  xdef *xp = *xpp;\n  if (!xp)\n    return;\n  if (xp->xtyp == 0)\n    a (xpp);\n  c (xp);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040216-1.c",
    "content": "int foo (int a, int b, int c, int d)\n{\n  return ~a & ~b & ~c & ~d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040219-1.c",
    "content": "double foo() { return __builtin_isgreater(0.,0.); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040220-1.c",
    "content": "/* PR 14194 */\n\nint irqs;\n\nstatic inline __attribute__((always_inline))\nint kstat_irqs (void) {\n  int i, sum = 0;\n  for (i = 0; i < 1; i++)\n    if (__builtin_expect(i, 0))\n      sum += irqs;\n  return sum;\n}\n\nint show_interrupts (void) {\n  return kstat_irqs ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040303-1.c",
    "content": "typedef struct input {\n        struct input *next;\n} input_t;\nstatic input_t *inputs = (input_t *)((void *)0);\nvoid\nRemoveInput(unsigned long id)\n{\n input_t *ip;\n input_t *prev;\n while (1)\n  if (ip == (input_t *)id)\n   break;\n if (ip == (input_t *)((void *)0))\n  return;\n  prev->next = ip->next;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040303-2.c",
    "content": "void abort(void);\nint x, y;\nvoid init_xy(void);\nvoid\ntest4(void)\n{\n  init_xy();\n  _Bool iftemp0;\n  int x1 = x;\n  _Bool iftemp1;\n  x1++;\n  if (x1 != 3)\n    {\n      iftemp1 = 1;\n      goto endfirstif;\n    }\n  iftemp1 = 0;\n  endfirstif:\n  iftemp0 = iftemp1;\n  if (iftemp0)\n    abort();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040304-1.c",
    "content": "void\ncpplib_macroExpand (char * pfile)\n{\n  int nargs;\n  int rest_args;\n  int token = -1;\n  rest_args = 0;\n  do\n    {\n      if (rest_args != 0)\n          continue;\n      if (nargs == 0)\n        {\n          rest_args = 1;\n          token = macarg (pfile, rest_args);\n        }\n    }\n  while (token == 20);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040309-1.c",
    "content": "static const char default_tupleseps[] = \", \\t\";\n\n\nfubar (tupleseps)\n     const char *tupleseps;\n{\n  char *kp, *sp;\n  const char *septmp;\n  const char *tseplist;\n  tseplist = (tupleseps) ? tupleseps : default_tupleseps;\n  while (kp)\n    {\n      if (*tseplist)\n        septmp = tseplist;\n      bar (*septmp);\n      if (*tseplist)\n        if (*kp)\n          ;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040310-1.c",
    "content": "void I_wacom ()\n{\n  char buffer[50], *p;\n  int RequestData (char *cmd)\n  {\n    p = buffer;\n    foo (buffer);\n  }\n  RequestData (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040317-1.c",
    "content": "int String2Array(int len, char strarr[][len])\n{\n  strarr[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040317-2.c",
    "content": "typedef struct _ScaleRec *ScaleWidget;\ntypedef struct\n{\n  short *x;\n  unsigned short *width;\n} Table;\ntypedef struct\n{\n  Table table;\n} ScalePart;\ntypedef struct _ScaleRec\n{\n  ScalePart scale;\n} ScaleRec;\nstatic int\nFindPixel (ScaleWidget sw, short x, short y,\n       short * img_x, short * img_y, unsigned long * img_pixel)\n{\n  if (sw->scale.table.x[(int) *img_x] + \n      (short) sw->scale.table.width[(int) *img_x] < x)\n    {\n      ++*img_x;\n      return FindPixel (sw, x, y, img_x, img_y, img_pixel);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040317-3.c",
    "content": "I_wacom ()\n{\n  char buffer[50], *p;\n  int RequestData (char *cmd)\n  {\n    p = buffer;\n    foo (buffer);\n  }\n  RequestData (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040323-1.c",
    "content": "/* PR middle-end/14694 */\n/* { dg-require-alias \"\" } */\n\nunsigned int _rtld_global = 1;\nextern unsigned int _rtld_local __attribute__ ((alias (\"_rtld_global\")));\n\nunsigned int\n_dl_start (void *arg)\n{\n  unsigned int elf_machine_rel () { return _rtld_local; }\n  return elf_machine_rel ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040401-1.c",
    "content": "int __atomic_readv_replacement(unsigned char iov_len, int count, int i) {\n    unsigned char bytes = 0;\n    if ((unsigned char)((char)127 - bytes) < iov_len)\n      return 22;\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040415-1.c",
    "content": "int isdigit (int);\nint f (const char *type)\n{\n  return isdigit ((unsigned char) *type++);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040415-2.c",
    "content": "int isascii (int);\n\nint f1 (const char *type)\n{\n  return isascii ((unsigned char) *type++);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040419-1.c",
    "content": "/* This used to ICE because PHI-OPT would produce non-gimple code. */\n\nint f(double d0, double d1) { return d0 > 0 == d1 > 0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040602-1.c",
    "content": "/* Test type qualifiers.  These should as equal types.  */\nextern volatile unsigned long foo;\ntypedef unsigned long ulong;\nextern volatile ulong foo;\nvolatile ulong foo;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040610-1.c",
    "content": "int foo (float x)\n{\n        float i = __builtin_inff ();\n        return x != i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040611-1.c",
    "content": "/* This would cause PRE load motion to generate invalid code and ICE */\nvoid foo (char *name)\n{\n  if (*name)\n    name ++;\n  while (name[0]);\n  asm (\"\" : \"=r\" (name));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040614-1.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nvoid f(int r1, int *fp) \n{     \n  void *hlbl_tbl[] = { &&label1 }; \n  goto *hlbl_tbl[r1]; \n  *fp = 0; \n label0: \n  fp += 8; \n label1: \n  *fp = 0; \n  if (r1)  \n    goto label2; \n  if (r1) \n    goto label0; \n label2: \n  ; \n}\n\nint x;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040621-1.c",
    "content": "/* This test would cause partial redundancies too complex for PRE\n   to insert using a single temporary due to them not being GIMPLE\n   expressions.  */\nint ssbgst (int c, int k)\n{\n  int a, i, j;\n\n  a = 0;\n  i = 1;\n  j = k;\n  while (j)\n    {\n      a += (j + i) * (k + i + c) + (j + i + c);\n      j = j - 1;\n    }\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040624-1.c",
    "content": "struct s { float f[1]; };\nstruct s foo();\nfloat bar() { return foo().f[0]; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040705-1.c",
    "content": "extern char foo[], bar[];\nvoid f (void) { memcpy (foo, bar, 7); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040708-1.c",
    "content": "/* PR rtl-optimization/16199 */\n/* Origin: Olaf Klein <oklein@smallo.ruhr.de> */\n\ntypedef enum {\n    APR_LOCK_FCNTL,\n    APR_LOCK_FLOCK,\n    APR_LOCK_SYSVSEM,\n    APR_LOCK_PROC_PTHREAD,\n    APR_LOCK_POSIXSEM,\n    APR_LOCK_DEFAULT\n} apr_lockmech_e;\n\nstruct apr_proc_mutex_unix_lock_methods_t {\n    unsigned int flags;\n    const char *name;\n};\n\ntypedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;\n\nextern const apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_sysv_methods;\n\nstruct apr_proc_mutex_t {\n    const apr_proc_mutex_unix_lock_methods_t *inter_meth;\n    int curr_locked;\n    char *fname;\n};\n\ntypedef struct apr_proc_mutex_t apr_proc_mutex_t;\n\nextern const apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_proc_pthread_methods;\n\nextern const apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_fcntl_methods;\n\nstatic int proc_mutex_choose_method(apr_proc_mutex_t *new_mutex, apr_lockmech_e mech)\n{\n    switch (mech) {\n    case APR_LOCK_FCNTL:\n        new_mutex->inter_meth = &apr_proc_mutex_unix_fcntl_methods;\n        break;\n    case APR_LOCK_FLOCK:\n        return ((20000 + 50000) + 23);\n        break;\n    case APR_LOCK_SYSVSEM:\n        new_mutex->inter_meth = &apr_proc_mutex_unix_sysv_methods;\n        break;\n    case APR_LOCK_POSIXSEM:\n        return ((20000 + 50000) + 23);\n        break;\n    case APR_LOCK_PROC_PTHREAD:\n        new_mutex->inter_meth = &apr_proc_mutex_unix_proc_pthread_methods;\n        break;\n    case APR_LOCK_DEFAULT:\n        new_mutex->inter_meth = &apr_proc_mutex_unix_proc_pthread_methods;\n        break;\n    default:\n        return ((20000 + 50000) + 23);\n    }\n    return 0;\n}\n\nconst char* apr_proc_mutex_defname(void)\n{\n    apr_proc_mutex_t mutex;\n\n    if (proc_mutex_choose_method(&mutex, APR_LOCK_DEFAULT) != 0) {\n        return \"unknown\";\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040709-1.c",
    "content": "/* PR target/16364 */\nunion foo {\n  long double ld;\n} bar;\n\ndouble\nsub (union foo baz)\n{\n  return baz.ld / 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040726-1.c",
    "content": "/* PR rtl-optimization/16643 */\nvoid foo (int a, int b, int c, int d, int e, int *f)\n{\n  if (a == 0)\n    if (b == 0)\n      if (c == 0)\n\tif (d == 0)\n\t  {\n\t    *f = e;\n\t    return;\n\t  }\n  *f = e;\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040726-2.c",
    "content": "/* { dg-do compile } */\n/* From a failure after the global ccp pass.  */\ntypedef struct\n{\n  char n[129];\n} A;\n\nconst A C = {\n  0,\n  0\n};\n\nextern const A *const B;\n\nvoid bar(const char *);\n\nvoid foo ()\n{\n  bar (B->n);\n}\n\nconst A *const B = &C;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040727-1.c",
    "content": "/* Extracted from boehm-gc/os_dep.c on Darwin.  It caused an ICE when\n   trying to merge alias information from two pointers that had\n   different type memory tags.  */\ntypedef int thread_state_flavor_t;\ntypedef int exception_behavior_t;\ntypedef unsigned int exception_mask_t;\ntypedef unsigned int exception_handler_t;\ntypedef unsigned int mach_msg_type_number_t;\nstatic struct {\n   mach_msg_type_number_t count;\n   exception_mask_t masks[16];\n   exception_handler_t ports[16];\n   thread_state_flavor_t flavors[16];\n} GC_old_exc_ports;\n\ntypedef exception_handler_t *exception_handler_array_t;\ntypedef thread_state_flavor_t *exception_flavor_array_t;\n\n\nint task_get_exception_ports\n(\n  mach_msg_type_number_t *masksCnt,\n  exception_handler_array_t old_handlers,\n  exception_flavor_array_t old_flavors\n);\n\nvoid GC_dirty_init()\n{\n   task_get_exception_ports(GC_old_exc_ports.masks,\n                           GC_old_exc_ports.ports,\n                           GC_old_exc_ports.flavors);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040730-1.c",
    "content": "/*  PR tree-opt/16827\n    This used to ICE in tree-ssa-loop-im.c */\n\nextern unsigned short dev_roles[];\nvoid super_1_sync(int *rdev2)\n{\n int i;\n int max_dev = 0;\n\n for (i =0;i<20;i++)\n  if (rdev2[i] > max_dev)\n   max_dev = rdev2[i];\n\n for (i=0; i<max_dev;i++)\n  dev_roles[max_dev] = 0xfffe;\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040817-1.c",
    "content": "/* PR 17051: SRA failed to rename the VOPS properly.  */\n\nstruct A\n{\n    char c, d;\n};\n\nvoid foo(struct A *p)\n{\n    struct A a = *p;\n\n    if (p->c)\n        bar1(a);\n    else\n    {\n        if (p) bar2(a,a.c);\n        bar3(a.c);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040824-1.c",
    "content": "/* This caused an out-of-range address on the MIPS port.  */\nvoid foo (char *x) { __builtin_prefetch (x + 0x8000); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040901-1.c",
    "content": "typedef enum {a, b} __attribute__((__mode__(__QI__))) x;\nx foo;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040907-1.c",
    "content": "void ProdWord_bla ( gtL, gtRes, lnL )\n    int *gtL, *gtRes;\n    int lnL;\n{\n    while ( 1 < lnL )\n    {\n        *gtRes++ = *gtL++;\n        --lnL;\n    }\n    if ( 0 < lnL )\n        if ( gtL[0] == gtL[1] )\n            *gtRes++ = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040908-1.c",
    "content": "/* PR 17186 */\n\ndouble foo()\n{\n    int i;\n    double d;\n\n    if (i)\n        bar();\n    else\n        if (d) return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040909-1.c",
    "content": "static __inline__ int\none_utf8_to_utf16 () { }\n\nstatic __inline__ unsigned char\nconversion_loop (int (*const one_conversion)())\n{\nreturn one_conversion ();\n}\nstatic unsigned char\nconvert_utf8_utf16 ()\n{\n  return conversion_loop (one_utf8_to_utf16);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040914-1.c",
    "content": "extern int clobber_k (int *); \nextern int barrier (void); \nint t, u; \n\nint\nprocess_second_stream(void) \n{ \n  int k; \n  int i = 0, j = 0, result; \n \n  clobber_k (&k); \n \n  while(t)\n    ;\n \n  while(!j) \n    {\n      while(!j) \n\t{ \n\t  barrier (); \n\t  if (t == 0) \n\t    break; \n\t  else if(t == 1) \n\t    t = 2; \n\t  else \n\t    {\n\t      if(t < 0) \n\t\tj=1; \n\t      if(u < 0) \n\t\tk = i++; \n\t    }\n\t} \n \n      if(!j && u) \n\tj=1; \n    } \n \n  return 0; \n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20040916-1.c",
    "content": "/* PR tree-optimization/17512\n\n   We used to try to fold \"(char) (X ^ Y)\", where '^' is\n   TRUTH_XOR_EXPR into ((char) X ^ (char) Y), creating TRUTH_XOR_EXPR\n   with its operands being of type char, which is invalid.  */\n\nchar\nfoo (int p)\n{\n  int q = p;\n  return (p != 0) == (p == q);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041005-1.c",
    "content": "/* This wrongly caused duplicate definitions of x in the assembler\n   output.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\nstatic int x = 1;\nvoid f (void) { extern int x; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041007-1.c",
    "content": "/* PR rtl-optimization/17027 */\n/* Origin: dbk <sfc@village.uunet.be> */\n/* Testcase by Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de> */\n\nint bar(void);\nvoid baz (void)  __attribute__ ((noreturn)); /* noreturn is required */\n\nvoid foo (void) \n{\n  while (bar ()) {\n    switch (1) {\n      default:\n      baz ();\n    }\n  }\n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041018-1.c",
    "content": "void\nfoo (int y, int z, unsigned char **t, int **c, int *b)\n{\n  int i, j, k;\n  unsigned char a[2];\n\n  a[0] = 0;\n  a[1] = 0;\n  for (j = 0; j < z; j++)\n    for (i = 0; i < y; i++, a[0] += 3)\n      for (k = 0; k < 3; k++)\n\tc[0][k] += 3 * b[k];\n  for (i = 0; i < 3; i++)\n    if (t[0][i] + c[0][i] / a[0] <= 0)\n      t[0][i] = 0;\n    else\n      t[0][i] = t[0][i] + c[0][i] / a[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041026-1.c",
    "content": "int\nfoo (double x, long double y)\n{\n  return __builtin_isgreater (x, y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041119-1.c",
    "content": "/* PR rtl-optimization/17825 */\n#ifdef __i386__\nregister unsigned int reg __asm (\"esi\");\n#elif defined __x86_64__\nregister unsigned int reg __asm (\"r14\");\n#else\nunsigned int reg;\n#endif\n\nstruct S\n{\n  unsigned int h[8];\n} *b;\nunsigned int c;\nvoid foo (int);\n\nvoid\nbar (void)\n{\n  unsigned int j, k, l, m;\n\n  j = (reg & 0xffff) | ((b->h[2] & 0xffff) << 16);\n  k = c & 0xffff;\n  if (k == 0)\n    foo (0);\n  l = (j / k) & 0xffff;\n  m = (j % k) & 0xffff;\n  reg = (reg & 0xffff0000) | l;\n  b->h[2] = (b->h[2] & 0xffff0000) | m;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20041211-1.c",
    "content": "/* PR tree-optimization/16951 */\n\nvoid dummy_use(const char *p);\n\n__inline void f(const char *const p) {\n  const char q;\n  dummy_use(p);\n  f(&q);\n}\n\nvoid crash() {\n  f(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050105-1.c",
    "content": "void bar (struct S *);\nvoid foo (void *x)\n{\n  bar ((struct S *) x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050113-1.c",
    "content": "/* PR c/17297 */\n\ntypedef float V2SF __attribute__ ((vector_size (8)));\n\nint test0 (V2SF, V2SF);\n\nint\nmain (void)\n{\n  V2SF a = (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f};\n  V2SF b = (V2SF) {567.345, 1984.0};\n  int i;\n\n  i = test0 (a, b);\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050119-1.c",
    "content": "void write_char(char);\nint len(char*);\nvoid f(char *a)\n{\n  int col = 0;\n  int i;\n  void wchar(char c)\n  {\n    if (c == '\\t')\n     {\n      do {\n       wchar(' ');\n      } while ((col%8)!=0);\n     }\n    else\n     {\n       write_char (c);\n       col++;\n     }\n  }\n  for(i =0;i<len(a);i++)\n  {\n   wchar(*a);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050122-1.c",
    "content": "/* From PR 19484.  */\nextern void foo (void) __attribute__((noreturn));\nint n;\n\nvoid\ng (void)\n{\n  void (*f) (void) = foo;\n  if (n)\n    f ();\n  n = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050122-2.c",
    "content": "/* Related to PR 19484.  */\n/* { dg-require-effective-target trampolines } */\n\nextern void foo (void) __attribute__((noreturn));\nint n;\n\nvoid\ng (void)\n{\n  __label__ lab;\n  void h (void) { if (n == 2) goto lab; }\n  void (*f1) (void) = foo;\n  void (*f2) (void) = h;\n\n  f2 ();\n  if (n)\n    f1 ();\n  n = 1;\n lab:\n  n++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050202-1.c",
    "content": "/* From PR 19578.  */\nextern void foo (void) __attribute__((noreturn));\n\nvoid\ng (void)\n{\n  void (*f) (void) = foo;\n  f ();\n  f ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050206-1.c",
    "content": "unsigned short foo (void)\n{\n  unsigned short u[1] = { 1 };\n  u[0] = 0;\n  u[1] = 1;\n  u[2] = 2;\n  return u[0] + u[1] + u[2];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050210-1.c",
    "content": "/* PR middle-end/19858 */\n\ntypedef __SIZE_TYPE__ size_t;\nunion U { int c; } foo;\nint bar (void)\n{\n  return !(((size_t) &foo & 3) == 0 && !((size_t) &foo & 1));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050215-1.c",
    "content": "/* PR tree-optimization/18947 */\n/* { dg-options \"-fgnu89-inline\" } */\nextern __inline void f1 (void) { }\nextern __inline void f2 (void) { f1 (); }\nvoid f2 (void) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050215-2.c",
    "content": "/* PR tree-optimization/18947 */\n/* { dg-options \"-fgnu89-inline\" } */\nint v;\nextern __inline void f1 (void) { v++; }\nvoid f4 (void) { f1 (); }\nextern __inline void f2 (void) { f1 (); }\nvoid f3 (void) { f2 (); }\nvoid f2 (void) { f1 (); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050215-3.c",
    "content": "/* PR tree-optimization/18947 */\n/* { dg-options \"-fgnu89-inline\" } */\nint v;\nextern __inline void f0 (void) { v++; }\nextern __inline void f1 (void) { f0 (); }\nvoid f4 (void) { f1 (); }\nextern __inline void f2 (void) { f1 (); }\nvoid f3 (void) { f2 (); }\nvoid f2 (void) { f1 (); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050217-1.c",
    "content": "/* PR c++/20023 */\n\nvoid f (void);\ntypedef __SIZE_TYPE__ size_t;\nvoid g (void *a)\n{\n  size_t b = (size_t) a;\n  switch (b)\n  {\n    case 1:\n    f ();\n    break;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050303-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target size32plus } */\n\nvoid crc()\n{\n    int  toread;\n    long long nleft;\n    unsigned char buf[(128 * 1024)];\n\n    nleft = 0;\n    while (toread = (nleft < (2147483647 * 2U + 1U)) ? nleft: (2147483647 * 2U + 1U) )\n\t;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050328-1.c",
    "content": "void fn1 (void *);\nvoid fn2 (void *);\nvoid foo (void);\nvoid bar (void);\n\nextern inline void *\nbaz (void)\n{\n  return 0;\n}\n\nvoid\nfoo (void)\n{\n  fn1 (baz ());\n  fn2 (baz ());\n}\n\nvoid\nbar (void)\n{\n  fn1 (baz ());\n  fn2 (baz);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050423-1.c",
    "content": "/* PR tree-optimization/20742 */\n\nint\nfoo (int x, int y)\n{\n  register int a = y + 57;\n  register int b = y + 31;\n\n  while (x-- > 0)\n    {\n #define TEN(x) x x x x x x x x x x\n      TEN (TEN (a += b; b -= a;))\n      TEN (TEN (a += b; b -= a;))\n    }\n  return a + b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050510-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nvoid bar (int k)\n{\n  void *label = (k) ? &&x : &&y;\n  if (k)\n    goto *label;\n\nx:\n  if (k)\n    dont_remove ();\ny:\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050516-1.c",
    "content": "/* PR tree-optimization/21610 */\n\nstruct S { char s; };\nstruct T { struct S t; };\n\nstruct S *const p = &((struct T * const) (0x4000))->t;\n\nvoid\nfoo (void)\n{\n  p->s = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050520-1.c",
    "content": "struct s { int x[4]; };\nstruct s gs;\n\nvoid\nbar (void)\n{\n  struct s *s;\n  int i;\n\n  s = &gs;\n  for (i = 0; i < 4; i++)\n    ((char*) (&s->x[i]))[0] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050622-1.c",
    "content": "#if __SCHAR_MAX__ == 127 && __INT_MAX__ >= 2147483647\nstruct S { char buf[72*1024*1024]; };\n#else\nstruct S { char buf[64]; };\n#endif\n\nextern void bar (struct S);\n\nstruct S s;\n\nint\nfoo (void)\n{\n  bar (s);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050721-1.c",
    "content": "/* Test for PR target/20191.  */\n\nstruct S1;\n\nstruct S1 {\n  struct S1 *next;\n  float x;\n};\n\nstruct S2 {\n  float y;\n};\n\nextern int func_ex1 (float);\n\nextern int f;\nextern float n;\nextern struct S1 *bp1;\nextern struct S2 *bp2;\n\ninline float\nfunc1 (int f, struct S2 *p2)\n{\n  float a;\n\n  if (f)\n    a = n >= p2->y ? n : p2->y;\n  else\n    a = n;\n  return a;\n}\n\ninline float\nfunc2 (struct S1 *p1, struct S2 *p2)\n{\n  float a, b;\n\n  if(n <= 1.0)\n    b = func1 (f, p2);\n  else\n    {\n       a = n <= p1->x ? 0.0 : p1->x;\n       b = a >= p2->y ? a : p2->y;\n    }\n  return(b);\n}\n\nvoid\nfunc3 (struct S1 *p)\n{\n  float a = 0.0;\n\n  if (f)\n    a = func2 (bp1, bp2);\n  if (func_ex1 (a))\n    bp1 = p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050801-1.c",
    "content": "__inline void libc_name_p (void)\n{\n  enum { A = 1 };\n}\nvoid nothrow_libfn_p (void)\n{\n  libc_name_p ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20050801-2.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n__inline int f(int i)\n{\n  struct {\n    int t[i];\n  } t;\n  return sizeof(t.t[i--]);\n}\n\nint g(int i)\n{\n  return f(i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20051207-1.c",
    "content": "/* PR target/25268 */\n\nlong long\nfoo (long long x, int y)\n{\n  return x << ((y + 1) & 63);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20051216-1.c",
    "content": "/* PR rtl-optimization/25432 */\n\nvoid *malloc (__SIZE_TYPE__);\nvoid *realloc (void *, __SIZE_TYPE__);\n\nstruct A { double x, y; };\nstruct B { double x0, y0, x1, y1; };\nstruct C { int n_points; int dir; struct B bbox; struct A *points; };\nstruct D { int n_segs; struct C segs[1]; };\n\nvoid foo (int, int, int *, int, int *, struct A **, int *, int *,\n\t  struct D *, int *, struct D **, int *, int **);\nint baz (struct A, struct A, struct A, struct A);\n\nstatic void\nbar (struct D *svp, int *n_points_max,\n     struct A p, int *seg_map, int *active_segs, int i)\n{\n  int asi, n_points;\n  struct C *seg;\n\n  asi = seg_map[active_segs[i]];\n  seg = &svp->segs[asi];\n  n_points = seg->n_points;\n  seg->points = ((struct A *)\n\t\trealloc (seg->points, (n_points_max[asi] <<= 1) * sizeof (struct A)));\n  seg->points[n_points] = p;\n  seg->bbox.y1 = p.y;\n  seg->n_points++;\n}\n\nstruct D *\ntest (struct D *vp)\n{\n  int *active_segs, n_active_segs, *cursor, seg_idx;\n  double y, share_x;\n  int tmp1, tmp2, asi, i, j, *n_ips, *n_ips_max, n_segs_max;\n  struct A **ips, p_curs, *pts;\n  struct D *new_vp;\n  int *n_points_max, *seg_map, first_share;\n\n  n_segs_max = 16;\n  new_vp = (struct D *) malloc (sizeof (struct D) +\n\t\t\t\t(n_segs_max - 1) * sizeof (struct C));\n  new_vp->n_segs = 0;\n\n  if (vp->n_segs == 0)\n    return new_vp;\n\n  active_segs = ((int *) malloc ((vp->n_segs) * sizeof (int)));\n  cursor = ((int *) malloc ((vp->n_segs) * sizeof (int)));\n\n  seg_map = ((int *) malloc ((vp->n_segs) * sizeof (int)));\n  n_ips = ((int *) malloc ((vp->n_segs) * sizeof (int)));\n  n_ips_max = ((int *) malloc ((vp->n_segs) * sizeof (int)));\n  ips = ((struct A * *) malloc ((vp->n_segs) * sizeof (struct A *)));\n\n  n_points_max = ((int *) malloc ((n_segs_max) * sizeof (int)));\n\n  n_active_segs = 0;\n  seg_idx = 0;\n  y = vp->segs[0].points[0].y;\n  while (seg_idx < vp->n_segs || n_active_segs > 0)\n    {\n      for (i = 0; i < n_active_segs; i++)\n\t{\n\t  asi = active_segs[i];\n\t  if (vp->segs[asi].n_points - 1 == cursor[asi] &&\n\t      vp->segs[asi].points[cursor[asi]].y == y)\n\t    i--;\n\t}\n\n      while (seg_idx < vp->n_segs && y == vp->segs[seg_idx].points[0].y)\n\t{\n\t  cursor[seg_idx] = 0;\n\t  n_ips[seg_idx] = 1;\n\t  n_ips_max[seg_idx] = 2;\n\t  ips[seg_idx] =\n\t    ((struct A *) malloc ((n_ips_max[seg_idx]) * sizeof (struct A)));\n\t  ips[seg_idx][0] = vp->segs[seg_idx].points[0];\n\t  pts = ((struct A *) malloc ((16) * sizeof (struct A)));\n\t  pts[0] = vp->segs[seg_idx].points[0];\n\t  tmp1 = seg_idx;\n\t  for (j = i; j < n_active_segs; j++)\n\t    {\n\t      tmp2 = active_segs[j];\n\t      active_segs[j] = tmp1;\n\t      tmp1 = tmp2;\n\t    }\n\t  active_segs[n_active_segs] = tmp1;\n\t  n_active_segs++;\n\t  seg_idx++;\n\t}\n      first_share = -1;\n      share_x = 0;\n\n      for (i = 0; i < n_active_segs; i++)\n\t{\n\t  asi = active_segs[i];\n\t  p_curs = ips[asi][1];\n\t  if (p_curs.y == y)\n\t    {\n\t      bar (new_vp, n_points_max,\n\t\t   p_curs, seg_map, active_segs, i);\n\n\t      n_ips[asi]--;\n\t      for (j = 0; j < n_ips[asi]; j++)\n\t\tips[asi][j] = ips[asi][j + 1];\n\n\t      if (first_share < 0 || p_curs.x != share_x)\n\t\t{\n\t\t  foo (first_share, i,\n\t\t       active_segs, n_active_segs,\n\t\t       cursor, ips, n_ips, n_ips_max, vp, seg_map,\n\t\t       &new_vp, &n_segs_max, &n_points_max);\n\t\t  first_share = i;\n\t\t  share_x = p_curs.x;\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      foo (first_share, i,\n\t\t   active_segs, n_active_segs,\n\t\t   cursor, ips, n_ips, n_ips_max, vp, seg_map,\n\t\t   &new_vp, &n_segs_max, &n_points_max);\n\t      first_share = -1;\n\t    }\n\t}\n    }\n  return new_vp;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20051228-1.c",
    "content": "/* PR target/25554 */\n/* Bitwise shift with negative shift count has undefined behavior,\n   but we shouldn't ICE on it.  */\n\nvoid\nfoo (long x)\n{\n  if (((x >> -2) & 1) != 0)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060109-1.c",
    "content": "/* This test exposed a bug in combine where it was improperly changing\n   the mode of a register.  The bug appeared to be latent until web\n   was moved after combine.  This is the reduced test that fails \n   by crashing in reload.  */\n\n\ntypedef struct cpp_reader cpp_reader;\ntypedef struct cpp_string cpp_string;\nstruct cpp_string\n{\n  unsigned int len;\n  const unsigned char *text;\n};\nstruct cpp_callbacks\n{\n  void (*ident) (cpp_reader *, unsigned int, const cpp_string *);\n};\nstatic void cb_ident (cpp_reader *, unsigned int, const cpp_string *);\ninit_c_lex (void)\n{\n  struct cpp_callbacks *cb;\n  cb->ident = cb_ident;\n}\ncb_ident (cpp_reader * pfile __attribute__ ((__unused__)), unsigned int\nline\n          __attribute__ ((__unused__)), const cpp_string * str\n          __attribute__ ((__unused__)))\n{\n  {\n    cpp_string cstr = {\n    };\n    if (cpp_interpret_string (pfile, str, 1, &cstr, 0))\n      {\n      }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060202-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef const struct objc_selector\n{\n  void *sel_id;\n}\n *SEL;\ntypedef struct objc_object\n{\n}\n *id;\ntypedef struct objc_class *Class;\nstruct objc_class\n{\n  struct sarray *dtable;\n};\ntypedef size_t sidx;\nstruct soffset\n{\n  unsigned int boffset:(sizeof (size_t) * 8) / 2;\n  unsigned int eoffset:(sizeof (size_t) * 8) / 2;\n};\nunion sofftype\n{\n  struct soffset off;\n  sidx idx;\n};\nstruct sarray\n{\n  size_t capacity;\n};\nstatic __inline__ unsigned int\nsoffset_decode (sidx indx)\n{\n  union sofftype x;\n  x.idx = indx;\n  return x.off.eoffset + (x.off.boffset * (1 << 5));\n}\nstatic __inline__ void *\nsarray_get_safe (struct sarray *array, sidx indx)\n{\n  if (soffset_decode (indx) < array->capacity)\n    return (void *)sarray_get (array, indx);\n}\nvoid *\nget_imp (Class class, SEL sel)\n{\n  void *res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);\n  if (res == 0)\n    {\n\t{\n\t  res = get_imp (class, sel);\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060208-1.c",
    "content": "/* PR middle-end/26092 */\n/* { dg-skip-if \"can't take address of malloc\" { nvptx-*-* } { \"*\" } { \"\" } } */\ntypedef __SIZE_TYPE__ size_t;\nextern void *malloc (size_t);\n\nvoid *(*const foo) (size_t) = malloc;\n\nvoid *test (void)\n{\n  return (*foo) (3);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060215-1.c",
    "content": "/* PR middle-end/26300 */\n\nstruct S\n{\n  char c;\n  struct S *d;\n  struct S *e;\n};\nextern struct S *u, *v;\nextern void fn1 (struct S *) __attribute__ ((noreturn));\nvoid fn2 (struct S *);\n\nstatic inline struct S *\nfn3 (struct S *x)\n{\n  if (x->c != 6)\n    fn1 (0);\n  return (struct S *) x;\n}\n\nstatic inline int\nfn4 (struct S *x)\n{\n  if (x != u)\n    return 3;\n  fn2 (x);\n  return 0;\n}\n\nint\ntest (struct S *x)\n{\n  struct S *r;\n  int m = 0;\n\n  for (r = x; r != v; r = (fn3 (r)->d))\n    if (r->c != 6)\n      fn1 (x);\n    else\n      m |= 1 << (fn4 (fn3 (r)->e) - 1);\n  return m;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060217-1.c",
    "content": "/* PR middle-end/26334 */\n\nstruct U\n{\n  unsigned int u[256];\n};\n\nstruct S\n{\n  int u, v, w, x;\n  int s[255];\n};\n\nint\nfoo (struct U *x, struct S *y)\n{\n  register int i;\n  for (i = 0; i < 255; i++)\n    {\n      unsigned int v;\n      __asm__ (\"\" : \"=r\" (v) : \"0\" (x->u[i + 1]) : \"cc\");\n      y->s[i] = v;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060309-1.c",
    "content": "/* Test to make sure that indirect jumps compile.  */\nextern void bar(void);\nvoid foo() { bar(); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060419-1.c",
    "content": "/* This failed because if conversion didn't handle insv patterns properly.  */\n\nunion y\n{\n  int a;\n  unsigned short b;\n};\n\nextern void bar (unsigned short u, union y v);\n\nvoid\nfoo (int check)\n{\n  union y x;\n\n  if (check != 0)\n    x.b = 1;\n  else\n    x.b = 2;\n  bar (x.b, x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060421-1.c",
    "content": "/* This test used to ICE on ARM with -mcpu=iwmmxt.  */\nvoid\nfoo (void)\n{\n  long long int a;\n  unsigned long b[249]; /* >= 249 causes failure */\n  register unsigned int c;\n  b[c] = (a & (1ULL << c)) ? 1 : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060609-1.c",
    "content": "/* This test used to ICE on IA64.  */\nint __strspn_c2 (__const char *__s, int __accept1, int __accept2)\n{\n  register long unsigned int __result = 0;\n  while (__s[__result] == __accept1 || __s[__result] == __accept2)\n  return __result;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060625-1.c",
    "content": "/* PR middle-end/28151 */\n/* Testcase by Steven Bosscher <stevenb.gcc@gmail.com> */\n\n_Complex float b;\n\nvoid foo (void)\n{\n  _Complex float a = __FLT_MAX__;\n  b = __FLT_MAX__ + a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060823-1.c",
    "content": "/* PR middle-end/28683 */\n\nextern void foo (int *);\n\nstruct A\n{\n  int f;\n};\n\nstruct A *\ntest (struct A *r)\n{\n  int *f = &r->f;\n  static int i = 0;\n  if (!i && !((void *) f == (void *) r))\n    foo (&i);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060826-1.c",
    "content": "typedef _Complex double S;\nS bar (void);\nvoid quux (S, S);\nvoid foo (void)\n{\n quux (bar(), bar());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20060904-1.c",
    "content": "/* PR rtl-optimization/27616 */\n/* Reported by Lee Ji Hwan <moonz@kaist.ac.kr> */\n/* Testcase by Andrew Pinski <pinskia@gcc.gnu.org> */\n\nstruct chunk_s\n{\n  unsigned int size;\n  int offset_next;\n};\n\ntypedef struct chunk_s chunk_t;\n\nvoid foo(chunk_t *first)\n{\n  chunk_t *cur;\n  char *first0;\n\n  do {\n    first0 = (char *) first;\n    cur = (chunk_t *) (first0 + first->offset_next);\n    if ((chunk_t *) (first0 + cur->offset_next) != first)\n      return ;\n\n    first->offset_next = 0;\n\n  } while (cur->size != 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20061005-1.c",
    "content": "/* PR target/28924 */\n\nchar c;\n\nvoid\ntestc (void)\n{\n  (void) __sync_fetch_and_add (&c, -1);\n}\n\nshort s;\n\nvoid\ntests (void)\n{\n  (void) __sync_fetch_and_add (&s, -1);\n}\n\nvoid\ntestc2 (void)\n{\n  (void) __sync_val_compare_and_swap (&c, -1, -3);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20061214-1.c",
    "content": "typedef unsigned long long ull;\null bar (void);\nvoid foo (ull *x)\n{\n  ull y = bar ();\n  *x += y >> 32;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070121.c",
    "content": "/* PR rtl-optimization/29329 */\n/* Origin: Debian GCC Maintainers <debian-gcc@lists.debian.org> */\n/* Testcase by: Andrew Pinski <pinskia@gmail.com> */\n\nstruct node234_Tag\n{\n  int t1;\n  int kids[4];\n  void *elems[3];\n};\n\nvoid *add234_internal(struct node234_Tag *n, int ei)\n{\n  int j;\n  for (j = ei; j < 2 && n->elems[j+1];)\n    j++;\n  n->kids[j+1] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070129.c",
    "content": "/* This testcase would cause a hang in PTA solving due to a complex copy\n   constraint and marking the wrong variable as changed.  */\n\ntypedef struct RExC_state_t\n{\n char *end;\n char *parse;\n} RExC_state_t;\n\nstruct regnode_string\n{\n unsigned char str_len;\n char string[1];\n};\n\nstatic void *regatom (RExC_state_t * pRExC_state, int *flagp);\n\nstatic void *\nregpiece (RExC_state_t * pRExC_state, int *flagp)\n{\n return regatom (0, 0);\n}\n\nstatic void *\nregbranch (RExC_state_t * pRExC_state, int *flagp, int first)\n{\n return regpiece (0, 0);\n}\n\nstatic void *\nreg (RExC_state_t * pRExC_state, int paren, int *flagp)\n{\n return regbranch (0, 0, 1);\n}\n\nvoid *\nPerl_pregcomp (char *exp, char *xend, void *pm)\n{\n return reg (0, 0, 0);\n}\n\nstatic void *\nregatom (RExC_state_t * pRExC_state, int *flagp)\n{\n register void *ret = 0;\n int flags;\n\ntryagain:\n switch (*(pRExC_state->parse))\n   {\n   case '(':\n     ret = reg (pRExC_state, 1, &flags);\n     if (flags & 0x8)\n       {\n         goto tryagain;\n       }\n     break;\n   default:\n {\n       register unsigned long len;\n       register unsigned ender;\n       register char *p;\n       char *oldp, *s;\n       unsigned long numlen;\n       unsigned long foldlen;\n       unsigned char tmpbuf[6 + 1], *foldbuf;\n\n     defchar:\n       s = (((struct regnode_string *) ret)->string);\n       for (len = 0, p = (pRExC_state->parse) - 1;\n            len < 127 && p < (pRExC_state->end); len++)\n         {\n           if (((*p) == '*' || (*p) == '+' || (*p) == '?'\n                || ((*p) == '{' && regcurly (p))))\n             {\n               unsigned long unilen;\n               for (foldbuf = tmpbuf; foldlen; foldlen -= numlen)\n                 {\n                   reguni (pRExC_state, ender, s, &unilen);\n                   s += unilen;\n                 }\n               break;\n             }\n           unsigned long unilen;\n\n           reguni (pRExC_state, ender, s, &unilen);\n           s += unilen;\n         }\n\n     };\n     break;\n   }\n return (ret);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070419-1.c",
    "content": "/* PR tree-optimization/31632 */\n\nstruct S\n{\n  long int l;\n  void *m;\n};\n\nint\nfoo (struct S *x)\n{\n  unsigned long a;\n  a = x->l;\n  if (a <= ((void *) 0))\n    x->m = 0;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070501-1.c",
    "content": " typedef signed int signed16 __attribute__ ((__mode__ (__HI__)));\n typedef unsigned int unsigned16 __attribute__ ((__mode__ (__HI__)));\n typedef signed16 HI;\n typedef unsigned16 UHI;\nunsigned short f(int y)\n{\n  HI tmp_b4;\n  tmp_b4 = y;\n  UHI opval;\n  if (tmp_b4 == -32768)\n    opval = 32767;\n  else\n   opval = -tmp_b4;\n return opval;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070520-1.c",
    "content": "typedef unsigned char uint8_t;\nextern uint8_t ff_cropTbl[256 + 2 * 1024];\n\nvoid ff_pred8x8_plane_c(uint8_t *src, int stride){\n  int j, k;\n  int a;\n  uint8_t *cm = ff_cropTbl + 1024;\n  const uint8_t * const src0 = src+3-stride;\n  const uint8_t *src1 = src+4*stride-1;\n  const uint8_t *src2 = src1-2*stride;\n  int H = src0[1] - src0[-1];\n  int V = src1[0] - src2[ 0];\n  for(k=2; k<=4; ++k) {\n    src1 += stride; src2 -= stride;\n    H += k*(src0[k] - src0[-k]);\n    V += k*(src1[0] - src2[ 0]);\n  }\n  H = ( 17*H+16 ) >> 5;\n  V = ( 17*V+16 ) >> 5;\n\n  a = 16*(src1[0] + src2[8]+1) - 3*(V+H);\n  for(j=8; j>0; --j) {\n    int b = a;\n    a += V;\n    src[0] = cm[ (b ) >> 5 ];\n    src[1] = cm[ (b+ H) >> 5 ];\n    src[2] = cm[ (b+2*H) >> 5 ];\n    src[3] = cm[ (b+3*H) >> 5 ];\n    src[4] = cm[ (b+4*H) >> 5 ];\n    src[5] = cm[ (b+5*H) >> 5 ];\n    src[6] = cm[ (b+6*H) >> 5 ];\n    src[7] = cm[ (b+7*H) >> 5 ];\n    src += stride;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070522-1.c",
    "content": "/* { dg-options \"-Wno-psabi\" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */\n\n/* This was PR 31606, we were trying to use TImode to expand the\n   struct copy in SRA but TImode is not support on ia32. */\n\nstruct Collision {\n   int edge;\n   int triangle;\n  float _M_instance[3] __attribute__((__aligned__));\n};\nvoid  get_collisions(struct Collision a) {\n  struct Collision b = a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070529-1.c",
    "content": "/* ICE in chrec_fold_plus_poly_poly. */\n\ntypedef unsigned short __u16;\ntypedef unsigned int u32;\ntypedef __u16 __be16;\nstruct hfs_extent {\n __be16 count;\n};\nint hfs_free_fork( int type)\n{\n u32 total_blocks, blocks, start;\n struct hfs_extent *extent;\n int res, i;\n for (i = 0; i < 3; extent++, i++)\n  blocks += __fswab16((( __u16)(__be16)(extent[i].count)));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070529-2.c",
    "content": "void xfs_dir2_grow_inode(void)\n{\n int map;\n int *mapp;\n int nmap;\n mapp = &map;\n if (nmap == 0 )\n  mapp = ((void *)0);\n if (mapp != &map)\n  kmem_free(mapp);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070531-1.c",
    "content": "/* MIN_EXPR/MAX_EXPR caused an ICE in VRP. */\nint *f(int *a, int *b)\n{\n *a = 1;\n *b = 2;\n int *c = a < b ? a : b;\n if (c)\n   return c;\n else\n   return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070531-2.c",
    "content": "int f(void)\n{\n  int *a = 0;\n  for(a = 0; a < (int*)32767;a++)\n   ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070603-1.c",
    "content": "\nint f(_Complex double *a, unsigned int n)\n{\n  unsigned int i;\n  for(i = 0; i< n; i++)\n    {\n      a[i] = __real__ a[i+1] + __real__ a[i];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070603-2.c",
    "content": "typedef _Complex double ar[];\nint f(ar *a, unsigned int n)\n{\n  unsigned int i;\n  for(i = 0; i< n; i++)\n    {\n      (*a)[i*4] = __real__ (*a)[(i+1)*4] + __real__ (*a)[i*4];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070605-1.c",
    "content": "quantize_fs_dither (unsigned width, short *errorptr, int dir)\n{\n  short bpreverr;\n  unsigned col;\n  for (col = width; col > 0; col--) \n    errorptr += dir;\n  errorptr[0] = (short) bpreverr;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070827-1.c",
    "content": "/* PR rtl-optimization/33148 */\n\nint\nfoo (unsigned int *p, int *q, unsigned int w, unsigned int b)\n{\n  unsigned int i;\n  int mask;\n\n  if (q[0] < q[1])\n    mask = 0xff;\n  else\n    mask = 0;\n\n  for (i = 0; 8 * i < w; i++)\n    {\n      b ^= mask;\n      *p++ = b;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070905-1.c",
    "content": "/* PR tree-optimization/32772 */\n\nstruct S\n{\n  unsigned long bits[1];\n};\n\nvoid f1 (int, unsigned long *);\nint f2 (void);\nint f3 (int, unsigned long *);\nint f4 (int, unsigned long *);\n\nstatic inline __attribute__ ((always_inline))\nvoid baz (int x, volatile struct S *y)\n{\n  f1 (x, y->bits);\n}\n\nstatic int\nbar (int x, struct S *y)\n{\n  int n;\n  if (__builtin_constant_p (x) ? f3 (x, y->bits) : f4 (x, y->bits))\n    baz (x, y);\n  for (n = f2 (); n < 8; n = f2 ())\n    f3 (n, y->bits);\n}\n\nvoid\nfoo (int x, int y)\n{\n  struct S m;\n  while ((y = bar (x, &m)) >= 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070906-1.c",
    "content": "struct Bar {\n  int i[8];\n};\nstruct Bar foo(struct Bar **p)\n{\n  return foo((struct Bar**)*p);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070915-1.c",
    "content": "/* PR middle-end/33423 */\n\nstatic struct\n{\n  char buf[15];\n} u2;\n\nvoid\ntest6 (void)\n{\n  int len;\n  char *p;\n\n  for (len = 0; len < 2; len++)\n    {\n      p = __builtin___memset_chk (u2.buf, '\\0', len, 15);\n      if (p != u2.buf)\n\treturn;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20070919-1.c",
    "content": "typedef short int int16_t;\ntypedef unsigned char uint8_t;\ntypedef struct {\n\tint16_t LARc[8];\n\tint16_t Nc[4];\n\tint16_t bc[4];\n\tint16_t Mc[4];\n\tint16_t xmaxc[4];\n\tint16_t xMc[4][13];\n} gsm0610_frame_t;\nint gsm0610_unpack_voip(gsm0610_frame_t * s, const uint8_t c[33])\n{\n\tint i;\n\tfor (i = 0; i < 4; i++) {\n\t\ts->Nc[i] = (*c >> 1) & 0x7F;\n\t\ts->bc[i] = (*c++ & 0x1) << 1;\n\t\ts->bc[i] |= (*c >> 7) & 0x1;\n\t\ts->Mc[i] = (*c >> 5) & 0x3;\n\t\ts->xmaxc[i] = (*c++ & 0x1F) << 1;\n\t\ts->xmaxc[i] |= (*c >> 7) & 0x1;\n\t\ts->xMc[i][0] = (*c >> 4) & 0x7;\n\t\ts->xMc[i][1] = (*c >> 1) & 0x7;\n\t\ts->xMc[i][2] = (*c++ & 0x1) << 2;\n\t\ts->xMc[i][2] |= (*c >> 6) & 0x3;\n\t\ts->xMc[i][3] = (*c >> 3) & 0x7;\n\t\ts->xMc[i][4] = *c++ & 0x7;\n\t\ts->xMc[i][10] |= (*c >> 6) & 0x3;\n\t\ts->xMc[i][11] = (*c >> 3) & 0x7;\n\t\ts->xMc[i][12] = *c++ & 0x7;\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071027-1.c",
    "content": "/* PR tree-optimization/33856 */\n/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\ntypedef struct z_key\n{\n  int key;\n  int mask;\n} z_key;\ntypedef struct picture_size\n{\n  z_key key;\n} picture_size;\n\nvoid picture_size_new (picture_size *ps)\n{\n  z_key key;\n  ps->key = key;\n}\n\nvoid picture_sizes_load_default (picture_size *ps)\n{\n  int i;\n  for (i = 0; i < 5; ++i)\n    picture_size_new (ps);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071102-1.c",
    "content": "/* PR rtl-optimization/28062 */\n/* Original testcase by Martin Michlmayr <tbm@cyrius.com> */\n/* C testcase by Andrew Pinski <pinskia@gcc.gnu.org> */\n\nstruct _NSPoint\n{\n  float x;\n  float y;\n};\n\ntypedef struct _NSPoint NSPoint;\n\nstatic inline NSPoint\nNSMakePoint (float x, float y)\n{\n  NSPoint point;\n  point.x = x;\n  point.y = y;\n  return point;\n}\n\nstatic inline NSPoint\nRelativePoint (NSPoint point, NSPoint refPoint)\n{\n  return NSMakePoint (refPoint.x + point.x, refPoint.y + point.y);\n}\n\nNSPoint g(NSPoint refPoint)\n{\n  float pointA, pointB;\n  return RelativePoint (NSMakePoint (0, pointA), refPoint);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071105-1.c",
    "content": "/* PR tree-optimization/33993 */\n/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\nvoid\ninit_full (char *array, int ny)\n{\n  int j;\n  char acc = 128;\n  for (j = 0; j < ny; j++)\n    *array++ = acc++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071107-1.c",
    "content": "/* PR rtl-optimization/33737 */\n/* Testcase by Richard Guenther <rguenth@gcc.gnu.org> */\n\nenum { PROP_0, PROP_DOUBLE_CLICK_TIME, PROP_DOUBLE_CLICK_DISTANCE, PROP_CURSOR_BLINK, PROP_CURSOR_BLINK_TIME, PROP_CURSOR_BLINK_TIMEOUT, PROP_SPLIT_CURSOR, PROP_THEME_NAME, PROP_ICON_THEME_NAME, PROP_FALLBACK_ICON_THEME, PROP_KEY_THEME_NAME, PROP_MENU_BAR_ACCEL, PROP_DND_DRAG_THRESHOLD, PROP_FONT_NAME, PROP_ICON_SIZES, PROP_MODULES, PROP_XFT_ANTIALIAS, PROP_XFT_HINTING, PROP_XFT_HINTSTYLE, PROP_XFT_RGBA, PROP_XFT_DPI, PROP_CURSOR_THEME_NAME, PROP_CURSOR_THEME_SIZE, PROP_ALTERNATIVE_BUTTON_ORDER, PROP_ALTERNATIVE_SORT_ARROWS, PROP_SHOW_INPUT_METHOD_MENU, PROP_SHOW_UNICODE_MENU, PROP_TIMEOUT_INITIAL, PROP_TIMEOUT_REPEAT, PROP_TIMEOUT_EXPAND, PROP_COLOR_SCHEME, PROP_ENABLE_ANIMATIONS, PROP_TOUCHSCREEN_MODE, PROP_TOOLTIP_TIMEOUT, PROP_TOOLTIP_BROWSE_TIMEOUT, PROP_TOOLTIP_BROWSE_MODE_TIMEOUT, PROP_KEYNAV_CURSOR_ONLY, PROP_KEYNAV_WRAP_AROUND, PROP_ERROR_BELL, PROP_COLOR_HASH, PROP_FILE_CHOOSER_BACKEND, PROP_PRINT_BACKENDS, PROP_PRINT_PREVIEW_COMMAND, PROP_ENABLE_MNEMONICS, PROP_ENABLE_ACCELS, PROP_RECENT_FILES_LIMIT };\nvoid g_assert_warning (void) __attribute__((__noreturn__));\nvoid gtk_settings_class_init (void)\n{\n    unsigned int result;\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_DOUBLE_CLICK_TIME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_DOUBLE_CLICK_DISTANCE) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_CURSOR_BLINK) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_CURSOR_BLINK_TIME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_CURSOR_BLINK_TIMEOUT) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_SPLIT_CURSOR) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_THEME_NAME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ICON_THEME_NAME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_FALLBACK_ICON_THEME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_KEY_THEME_NAME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_MENU_BAR_ACCEL) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_DND_DRAG_THRESHOLD) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_FONT_NAME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ICON_SIZES) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_MODULES) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_XFT_ANTIALIAS) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_XFT_HINTING) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_XFT_HINTSTYLE) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_XFT_RGBA) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_XFT_DPI) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_CURSOR_THEME_NAME) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_CURSOR_THEME_SIZE) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ALTERNATIVE_BUTTON_ORDER) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ALTERNATIVE_SORT_ARROWS) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_SHOW_INPUT_METHOD_MENU) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_SHOW_UNICODE_MENU) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_TOOLTIP_BROWSE_TIMEOUT) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_TOOLTIP_BROWSE_MODE_TIMEOUT) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_KEYNAV_CURSOR_ONLY) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_KEYNAV_WRAP_AROUND) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ERROR_BELL) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_FILE_CHOOSER_BACKEND) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_PRINT_PREVIEW_COMMAND) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ENABLE_MNEMONICS) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n    result = settings_install_property_parser();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_ENABLE_ACCELS) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n     if (__builtin_expect (__extension__ ({\n       int _g_boolean_var_;\n       if (result == PROP_RECENT_FILES_LIMIT) _g_boolean_var_ = 1;\n       else _g_boolean_var_ = 0;\n       _g_boolean_var_;\n   }), 1)) {\n     }\n     else g_assert_warning();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071108-1.c",
    "content": "/* PR tree-optimization/33680 */\n/* { dg-require-effective-target alloca } */\n\nint\nf (int dim, int *b, int *c)\n{\n  int newcentroid[3][dim];\n  int *a = newcentroid[2];\n  int i, dist = 0;\n  __builtin_memcpy (newcentroid, c, sizeof (newcentroid));\n  for (i = 0; i < dim; i++)\n    dist += (a[i] - b[i]) * (a[i] - b[i]);\n  return dist;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071114-1.c",
    "content": "/* PR tree-optimization/34046 */\n/* Origin: dcb <dcb314@hotmail.com> */\n\ntypedef unsigned char bool8;\ntypedef unsigned char uint8_t;\ntypedef unsigned short int uint16_t;\ntypedef unsigned int uint32_t;\ntypedef uint8_t uint8;\ntypedef uint16_t uint16;\ntypedef uint32_t uint32;\n\nstruct SIAPU\n{\n    uint8 *PC;\n    uint8 *RAM;\n    uint8 Bit;\n    uint32 Address;\n    uint8 *WaitAddress1;\n    uint8 *WaitAddress2;\n    uint8 _Carry;\n};\n\nstruct SAPU\n{\n    bool8 ShowROM;\n    uint8 OutPorts [4];\n    uint8 ExtraRAM [64];\n    uint16 TimerTarget [3];\n};\n\nstruct SAPU APU;\nstruct SIAPU IAPU;\n\nvoid S9xSetAPUControl (uint8 byte);\nvoid S9xSetAPUDSP (uint8 byte);\nuint8 S9xGetAPUDSP ();\n\nuint8 S9xAPUGetByte (uint32 Address)\n{\n  Address &= 0xffff;\n\n  if (Address <= 0xff && Address >= 0xf0)\n    {\n      if (Address >= 0xf4 && Address <= 0xf7)\n\t{\n\t  IAPU.WaitAddress2 = IAPU.WaitAddress1;\n\t  IAPU.WaitAddress1 = IAPU.PC;\n\t  return (IAPU.RAM [Address]);\n\t}\n      else if (Address == 0xf3)\n\treturn (S9xGetAPUDSP ());\n\n      if (Address >= 0xfd)\n\t{\n\t  IAPU.WaitAddress2 = IAPU.WaitAddress1;\n\t  IAPU.WaitAddress1 = IAPU.PC;\n\t  uint8 t = IAPU.RAM [Address];\n\t  IAPU.RAM [Address] = 0;\n\t  return (t);\n\t}\n\n      return (IAPU.RAM [Address]);\n    }\n else\n   return (IAPU.RAM [Address]);\n}\n\nvoid S9xAPUSetByte (uint8 byte, uint32 Address)\n{\n  Address &= 0xffff;\n\n  if (Address <= 0xff && Address >= 0xf0)\n    {\n      if (Address == 0xf3)\n\tS9xSetAPUDSP (byte);\n      else if (Address >= 0xf4 && Address <= 0xf7)\n\tAPU.OutPorts [Address - 0xf4] = byte;\n      else if (Address == 0xf1)\n\tS9xSetAPUControl (byte);\n      else if (Address < 0xfd)\n\t{\n\t  IAPU.RAM [Address] = byte;\n\t  if (Address >= 0xfa)\n\t    {\n\t      if (byte == 0)\n\t\tAPU.TimerTarget [Address - 0xfa] = 0x100;\n\t      else\n\t\tAPU.TimerTarget [Address - 0xfa] = byte;\n\t    }\n\t}\n    }\n  else\n    {\n      if (Address < 0xffc0)\n\tIAPU.RAM [Address] = byte;\n      else\n\t{\n\t  APU.ExtraRAM [Address - 0xffc0] = byte;\n\t  if (!APU.ShowROM)\n\t    IAPU.RAM [Address] = byte;\n\t}\n    }\n}\n\nvoid ApuCA ()\n{\n  IAPU.Address = *(uint16 *) (IAPU.PC + 1);\n  IAPU.Bit = (uint8)(IAPU.Address >> 13);\n  if ((IAPU._Carry))\n    S9xAPUSetByte (S9xAPUGetByte (IAPU.Address) | (1 << IAPU.Bit), IAPU.Address);\n  else\n    S9xAPUSetByte (S9xAPUGetByte (IAPU.Address) & ~(1 << IAPU.Bit), IAPU.Address);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071117-1.c",
    "content": "/* PR middle-end/34134 */\n/* { dg-require-effective-target alloca } */\n\nextern void bar (void *, int);\n\nint foo (int i)\n{\n  char *p = __builtin_stack_save ();\n  void *q = __builtin_alloca (i);\n  bar (q, i);\n  __builtin_stack_restore (p);\n  bar (\"\", 0);\n  return 6;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071118-1.c",
    "content": "/* PR rtl-optimization/34132 */\n/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\nstatic char *m = \"%s%u.msg\";\nextern void bar (int, const char *);\nvoid foo (short x, int y, int z)\n{\n  if (x == 0)\n    {\n      bar (y, m);\n      z = 1;\n    }\n  else if (x == 1)\n    z = 0;\n  bar (y, m);\n  bar (z, \"%d\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071128-1.c",
    "content": "/* PR tree-optimization/34140 */\n/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\nstruct S\n{\n  unsigned int s;\n};\nstruct T\n{\n  struct S t[2];\n  unsigned int u : 1;\n};\n\nvoid\nfoo (int x, int y, int z)\n{\n  int i;\n  struct T t;\n\n  t.u = t.u;\n  for (i = 0; i < x; i++)\n    if (z != 1)\n      t.t[i].s = y || t.u;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071203-1.c",
    "content": "/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\nstruct User { char username[10]; };\n\nvoid\nauth_set_username (struct User *user)\n{\n  char *d;\n  char ch;\n  d = user->username + (user->username[0] == '~');\n  while ((ch = *d++) != '\\0') /* do nothing */ ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071207-1.c",
    "content": "/* PR tree-optimization/34371 */\n/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\nvoid centerln (int width, int ch, char *s)\n{\n  unsigned int sidebar;\n  int i;\n  char linet1[1000];\n  char linet2[100];\n  sidebar = (width - __builtin_strlen (s)) / 2;\n  for (i = 0; i < sidebar; i++)\n    linet2[i] = ch;\n  __builtin_strcpy (linet1, linet2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20071214-1.c",
    "content": "typedef __builtin_va_list va_list;\nvoid gftp_config_parse_args (int numargs, char **first, ...)\n{\n  char **dest = first;\n  va_list argp;\n  __builtin_va_start (argp, first);\n  while (numargs-- > 0)\n    {\n      *dest = __builtin_malloc (1);\n      dest = __builtin_va_arg(argp, char **);\n      *dest = ((void *)0);\n    }\n  __builtin_va_end(argp);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080114-1.c",
    "content": "/* PR rtl-optimization/31944 */\n/* Origin: Aurelien Jarno <aurelien@aurel32.net> */\n\nint type;\n\nvoid stuck(int res)\n{\n  if (type == 1) {\n    if (res == 0) asm volatile(\"\");\n  }\n  else if (type == 0) {\n    if (res == 0) asm volatile(\"\" : : \"i\" (0));\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080124-1.c",
    "content": "/* PR middle-end/34934 */\n\n#include <stdarg.h>\n\ntypedef struct\n{\n  int e[1024];\n  int f;\n} S;\n\nvoid foo (long *, va_list);\n\nvoid\nbar (long *x, S *y, int z, ...)\n{\n  int i, j;\n  va_list ap;\n  va_start (ap, z);\n  for (j = y->e[i = 1]; i <= y->f; j = y->e[++i])\n    {\n      switch (z)\n\t{\n\tcase 1:\n\t  if (!(*x & 0x00000020))\n\t    continue;\n\tcase 3:\n\t  if (!(*x & 0x00000080))\n\t    continue;\n\tcase 9:\n\t  if (!(*x & 0x04000000))\n\t    continue;\n\tcase 4:\n\t  if (!(*x & 0x00000200))\n\t    continue;\n\tcase 8:\n\t  if (!(*x & 0x00100000))\n\t    continue;\n\tcase 6:\n\t  if (!(*x & 0x00000100))\n\t    continue;\n\tcase 7:\n\t  if (!(*x & 0x00040000))\n\t    continue;\n\tcase 10:\n\t  if (!(*x & 0x00000020)\n\t      && ((*x & 0x00008000) || (*x & 0x08000000)))\n\t    continue;\n\t}\n      foo (x, ap);\n    }\n  va_end (ap);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080419-1.c",
    "content": "extern void *f();\nvoid dmi_scan_machine(void) {\n  char *p = f(), *q;\n  for (q = p; q < p + 10; q++)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080613-1.c",
    "content": "/* PR middle-end/36520 */\n/* Testcase by Richard Guenther <rguenth@gcc.gnu.org> */\n\ntypedef __SIZE_TYPE__ size_t;\ntypedef unsigned short int sa_family_t;\nstruct cmsghdr   {\n    size_t cmsg_len;\n    __extension__ unsigned char __cmsg_data [];\n};\ntypedef unsigned int uint32_t;\nstruct in6_addr   {\n    union       {\n        uint32_t u6_addr32[4];\n    } in6_u;\n};\nstruct sockaddr_in   {\n    sa_family_t sin_family;\n};\nstruct in6_pktinfo   {\n    struct in6_addr ipi6_addr;\n};\ntypedef union {\n    struct sockaddr_in sin;\n} sockaddr_any;\nstatic sockaddr_any src_addr;\n\ninline struct cmsghdr * cmsg_put(struct cmsghdr *cm, int type, void *data, size_t len)\n{\n    memcpy(((cm)->__cmsg_data), data, len);\n}\n\nint hop_sendmsg(int fd) {\n    struct cmsghdr *cm;\n    if (src_addr.sin.sin_family) {\n        if (src_addr.sin.sin_family == 2) {\n            struct in6_pktinfo info;\n            cm = cmsg_put(cm, 50, &info, sizeof(info));\n        }\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080625-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\nstruct peakbufStruct {\n    unsigned int lnum [5000];\n    int lscan [5000][4000];\n    double lmz [5000][4000];\n    double lint [5000][4000];\n    int PeaksInBuf;\n    unsigned char freelists [350000];\n    unsigned char freelistl [5000];\n    unsigned int LastFreeL;\n} peakbuf;\nvoid foo(int);\nvoid findmzROI(int i, int *p_scan)\n{\n    foo(peakbuf.PeaksInBuf);\n    __builtin_memmove(p_scan, peakbuf.lscan[i], peakbuf.lnum[i]*sizeof(int));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080628-1.c",
    "content": "void f (long double, long double);\n\nstruct s {\n  char c;\n  struct s *p;\n} *p;\n\nvoid\ng (void)\n{\n  long double ld;\n  p->p->c = 1;\n  ld = p->p->c;\n  f (ld, 1.0L);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080704-1.c",
    "content": "/* This code used to crash fold_convert due to PRE\n   wanting to fold_convert from a REAL_TYPE to an INTEGER_TYPE.  */\ntypedef unsigned int uint32_t;\nunion double_union\n{\n  double d;\n  uint32_t i[2];\n};\nstruct _Jv_reent\n{\n  int _errno;\n};\n_Jv_strtod_r (struct _Jv_reent *ptr, char **se)\n{\n  int bb2, sign;\n  double aadj, aadj1, adj;\n  unsigned long y, z;\n  union double_union rv, *bs = ((void *) 0), *delta = ((void *) 0);\n  {\n  ovfl:ptr->_errno = 34;\n    {\n      (((uint32_t) 0xfffffL) | ((uint32_t) 0x100000L) * (1024 + 1023 - 1));\n    }\n    if ((aadj = _Jv_ratio (delta, bs)) <= 2.)\n      {\n\t{\n\t  if (aadj < 2. / 2)\n\t    aadj = 1. / 2;\n\t  aadj1 = -aadj;\n\t}\n      }\n    {\n      (rv.i[1]) -= 53 * ((uint32_t) 0x100000L);\n      adj = aadj1 * _Jv_ulp (rv.d);\n      rv.d += adj;\n      if (((rv.i[1]) & ((uint32_t) 0x7ff00000L)) >=\n\t  ((uint32_t) 0x100000L) * (1024 + 1023 - 53))\n\t{\n\t  goto ovfl;\n\t}\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080721-1.c",
    "content": "/* { dg-skip-if \"can't read function data\" { nvptx-*-* } { \"*\" } { \"\" } } */\nvoid foo(void);\nvoid bar(void);\n\nint test(int b)\n{\n  void *p, **q;\n  if (b)\n    p = (void *)foo;\n  else\n    p = (void *)bar;\n  q = (void **)p;\n  if (*q == (void *)0)\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080806-1.c",
    "content": "/* This used to ICE on s390x due to a reload bug.  */\n\n#if defined(STACK_SIZE) && (STACK_SIZE < 65536)\n  #define BYTES 64\n#else\n  #define BYTES 65400\n#endif\n\nint gl2;\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memcpy (void *dest, const void *src, size_t n);\n\nvoid\nf1 ()\n{\n  int i2;\n  unsigned char bf[BYTES];\n\n  for (i2 = 0; i2 < 3; i2++)\n    {\n      unsigned char *p2 = bf;\n      unsigned char *p3 = ((void *) 0);\n      unsigned short ctf2;\n\n      p2 += sizeof (short);\n\n      for (ctf2 = 0; ctf2 < 3; ctf2++)\n\t{\n\t  if (ctf2 == 1)\n\t    {\n\t      unsigned short of = p2 - bf - 6;\n\t      unsigned short *ofp = (unsigned short *) &of;\n\t      memcpy (p3, ofp, sizeof (short));\n\t    }\n\n\t  if (gl2 == 1)\n\t    p2 += 3;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080812-1.c",
    "content": "/* PR middle-end/37014 */\n\nvoid bar (signed char *);\n\nvoid\nfoo (int x, int y)\n{\n  int i;\n  signed char a[123], b[123], c;\n  for (i = 0; i < 123; i++)\n    {\n      int e = y - x;\n      int d = e < 0 ? -e : e;\n      c = d < 75;\n      a[y] = c;\n      b[y] = c;\n      y--;\n    }\n  bar (b);\n  bar (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080820-1.c",
    "content": "extern unsigned long volatile jiffies;\nvoid do_timer(void)\n{\n  (*(unsigned long *)&jiffies)++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080903-1.c",
    "content": "struct bar { unsigned short length; };\n\nint\ndummy(void)\n{\n  char c[4096];\n  struct bar *a;\n  struct bar *b;\n\n  a->length = ((char *) b - c);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080910-1.c",
    "content": "/* This used to crash IRA with -O3 -fPIC.\n  See PR 37333.  */\nstruct yy_buffer_state  {\n  int yy_is_interactive;\n};\nstatic struct yy_buffer_state * * yy_buffer_stack = 0;\nstatic int yy_n_chars;\nint orafce_sql_yyleng;\nunsigned char *yy_c_buf_p = 0;\nextern char *orafce_sql_yytext;\nstatic const int yy_ec[256] = { };\nshort yy_accept[155], yy_base[193] = { }, yy_def[193] = { };\nshort yy_chk[738] = { };\nunsigned char *yy_last_accepting_cpos;\nint orafce_sql_yylex (int a)\n{\n  register int yy_current_state;\n  unsigned char *yy_cp, *yy_bp;\n  register int yy_act;\n  while ( 1 )   {\n    do {\n      char yy_c = yy_ec[*yy_cp];\n      if ( yy_accept[yy_current_state] )\n\tyy_last_accepting_cpos = yy_cp;\n      while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )\n\tyy_current_state = yy_def[yy_current_state];\n    } while ( yy_current_state != 154 );\nyy_find_action:\n    yy_act = yy_accept[yy_current_state];\n    *yy_cp = '\\0';\n    switch ( yy_act )  {\n      case 2:\n\t*yy_cp = 1;\n\treturn 265;\n      case 24: \n      case 25:\n\taddlit(orafce_sql_yytext, orafce_sql_yyleng);\n      case 26:\n\taddlit(orafce_sql_yytext, orafce_sql_yyleng);\n      case 53:\n\tyy_fatal_error( \"flex scanner jammed\" );\n\tbreak;\n      case 54:\n\tyy_cp = ++(yy_c_buf_p);\n\tunsigned long n = 0;\n\tif ( yy_buffer_stack[0]->yy_is_interactive )\n\t  for ( ; _IO_getc () != (-1) ;   ++n )\n\t    yy_n_chars = n;\n\tif (a == 0)\n\t{\n\t  yy_current_state = yy_get_previous_state( );\n\t  goto yy_find_action;\n\t}\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080922-1.c",
    "content": "typedef struct rtx_def *rtx;\ntypedef struct rtvec_def *rtvec;\nenum rtx_code { PARALLEL, SET };\nunion rtunion_def {\n    rtx rt_rtx;\n    rtvec rt_rtvec;\n};\ntypedef union rtunion_def rtunion;\nstruct rtx_def {\n    rtunion fld;\n};\nstruct rtvec_def {\n    int num_elem;\n};\nextern rtx operand;\n\nrtx peephole2_insns (rtx x0, enum rtx_code code)\n{\n  switch (code)\n    {\n      case SET:\n\t  operand = (((x0)->fld).rt_rtx);\n\t  return operand;\n      case PARALLEL:\n\t  if ((((((x0)->fld).rt_rtvec))->num_elem) == 2)\n\t    return 0;\n\t  break;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20080929-1.c",
    "content": "struct option {\n  const char *name;\n  int has_arg;\n  int *flag;\n  int val;\n};\nenum {\n  UBI_DYNAMIC_VOLUME = 3,  UBI_STATIC_VOLUME = 4, };\ntypedef void * libubi_t;\nstruct ubi_dev_info {\n  int leb_size;\n};\nstruct args {\n  int vol_id;\n  int vol_type;\n  long long bytes;\n  int lebs;\n  int alignment;\n  const char *node;\n  int maxavs;\n  int devn;\n};\nstatic struct args args = {\n  .vol_type = UBI_DYNAMIC_VOLUME,  .bytes = -1,  .lebs = -1,  .alignment = 1,  .vol_id = (-1),  .devn = -1, };\nextern libubi_t libubi_open (int);\nextern int ubi_get_dev_info (libubi_t, const char *, struct ubi_dev_info *);\nint main(int argc, char * const argv[]) {\n  int err;\n  libubi_t libubi;\n  struct ubi_dev_info dev_info;\n  libubi = libubi_open(1);\n  if (!libubi)\n    return 0;\n  err = ubi_get_dev_info(libubi, args.node, &dev_info);\n  if (args.maxavs) {\n    args.bytes = dev_info.leb_size;\n  }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081101-1.c",
    "content": "int foo (int i, int b)\n{\n  int mask;\n  int result;\n  if (b)\n    mask = -1;\n  else\n    mask = 0;\n  result = i + 1;\n  result = result & mask;\n  return result;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081108-1.c",
    "content": "/* Test function call with function designator involving VLA\n   side-effects does not lead to an ICE.  */\n\nvoid f (void);\nvoid g (void);\n\nvoid\nh (int a, void *b)\n{\n  ((void *)(int (*)[++a])b ? f : g) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081108-2.c",
    "content": "/* Test boolean conversion as part of returning unsigned value does\n   not lead to an ICE.  */\n\n_Bool f(unsigned a) { return a & 1; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081108-3.c",
    "content": "/* Test boolean conversion of an overflowing integer return value does\n   not lead to an ICE.  */\n\n_Bool f(void) { return __INT_MAX__ + 1; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081119-1.c",
    "content": "unsigned long long\nf (__builtin_va_list  ap)\n{\n  return __builtin_va_arg (ap, unsigned long long);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20081203-1.c",
    "content": "/* PR rtl-optimization/38281 */\n/* Reporter: John Regehr <regehr@cs.utah.edu> */\n/* Testcase by Jakub Jelinek <jakub@redhat.com> */\n\ninline unsigned short\nfoo (unsigned short x, unsigned short y)\n{\n  if (y == 0)\n    return x;\n  return x / y;\n}\n\nunsigned short a, b, c;\n\nextern int baz (int, int);\n\nvoid\nbar (void)\n{\n  int d = 0x3D75D162;\n  a = foo (b > d, baz (0, 1));\n  for (c = 0; c; c = 1)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090107-1.c",
    "content": "/* Verify that we don't ICE by forming invalid addresses for unaligned\n   doubleword loads (originally for PPC64).  */\n\nstruct a\n{\n unsigned int x;\n unsigned short y;\n} __attribute__((packed));\n\nstruct b {\n struct a rep;\n unsigned long long seq;\n} __attribute__((packed));\n\nstruct c {\n int x;\n struct a a[5460];\n struct b b;\n};\n\nextern void use_ull(unsigned long long);\nextern void f(struct c *i) {\n  use_ull(i->b.seq);\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090114-1.c",
    "content": "typedef struct {\n    int MbInterlace;\n    int channel_type;\n} InputParameters;\ntypedef struct {\n    int type;\n    int NumberofCodedPFrame;\n    int NumberofGOP;\n    int NumberofPPicture;\n    int FieldControl;\n    int Frame_Total_Number_MB;\n    int NumberofCodedMacroBlocks;\n    int BasicUnit;\n} ImageParameters;\nextern InputParameters *input;\nextern ImageParameters *img;\nlong T;\nvoid rc_init_pict(int fieldpic)\n{\n  if(input->MbInterlace)\n    T = img->Frame_Total_Number_MB;\n  img->NumberofCodedMacroBlocks=0;\n  if(input->channel_type==1\n     && img->NumberofCodedPFrame==58)\n    T = 4;\n  if(fieldpic)\n    {\n      switch (img->type)\n\t{\n\t  case 0:\n\t   if(img->NumberofCodedPFrame>0\n\t      && img->FieldControl==1)\n\t     T = 3;\n\t   if(img->NumberofPPicture==1)\n\t     T = 2;\n\t}\n      if(img->type==0\n\t && img->NumberofCodedPFrame>0)\n\tT = 0;\n    }\n  if(img->type==0\n     && img->FieldControl==1)\n    T = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090209-1.c",
    "content": "/* PR middle-end/38981 */\n/* Reporter: Kamaraju Kusumanchi <kamaraju@gmail.com> */\n\nstruct d_info\n{\n  int **subs;\n};\n\nstatic int *\nd_substitution (struct d_info *di, int prefix)\n{\n  char c;\n\n\tc='_';\n\n  if (c == '_')\n    {\n      unsigned int id;\n\n      if (c != '_')\n\t{\n\t  do\n\t    {\n\t      unsigned int new_id;\n\n\t      if (new_id < id)\n\t\treturn 0;\n\t      id = new_id;\n\t    }\n\t  while (c != '_');\n\t}\n\n\n\n      return di->subs[id];\n    }\n  else\n    {\n      int verbose;\n      int code;\n      int simple_len;\n\n\tcode=0;\n\tsimple_len=0;\n\tverbose=0;\n      if (! code && prefix)\n\t{\n\t  char peek;\n\t\tpeek='A';\n\n\t  if (peek == 'C' || peek == 'D')\n\t    verbose = 1;\n\t}\n\n\t      if (verbose)\n\t\t{\n\t\t  code = simple_len;\n\t\t}\n\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090303-1.c",
    "content": "/* The array offset became 0x1ffffffffffffffe via a conversion from\n   signed to unsigned HOST_WIDE_INT, causing an ICE compiling for\n   Thumb.  */\n\nint r (unsigned short *);\nvoid s (unsigned short *, unsigned short *);\n\nint\nf (int x)\n{\n  unsigned short a[1], c[1];\n\n  if (r (a))\n    return x;\n\n  if (c[-1])\n    s (a, c);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090303-2.c",
    "content": "/* The array offset became 0x1ffffffffffffffe via a conversion from\n   signed to unsigned HOST_WIDE_INT, causing an ICE compiling for\n   Thumb.  */\n\nint r (unsigned short *);\nvoid s (unsigned short *, unsigned short *);\n\nint\nf (int x)\n{\n  unsigned short a[1], c[1];\n\n  if (r (a))\n    return x;\n\n  if (c[0x7fffffff])\n    s (a, c);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090328-1.c",
    "content": "union loc {  unsigned reg; signed offset; };\nvoid __frame_state_for (volatile char *state_in, int x)\n{\n  /* We should move all the loads out of this loop. Right now, we only\n     move one.  It takes two insertions because we insert a cast.  */\n    union loc fs;\n    int reg;\n    for (;;)     {\n        switch (x)  {\n\t    case 0:\n\t\t*state_in = fs.reg;\n\t    case 1:\n\t\t*state_in = fs.offset;\n\t}\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090331-1.c",
    "content": "struct re_pattern_buffer {\n    unsigned char *buffer;\n    unsigned long int allocated;\n};\nvoid byte_regex_compile (struct re_pattern_buffer *bufp,\n\t\t\t unsigned char *begalt, unsigned char *b)\n{\n  unsigned char *pfrom;\n  unsigned char *pto;\n\n  while ((unsigned long) (b - bufp->buffer + 3) > bufp->allocated)\n    {\n      unsigned char *old_buffer = bufp->buffer;\n      bufp->allocated <<= 1;\n      if (old_buffer != bufp->buffer)\n\t{\n\t  int incr = bufp->buffer - old_buffer;\n\t  b += incr;\n\t}\n    }\n  pfrom = b;\n  pto = b + 3;\n  while (pfrom != begalt)\n    *--pto = *--pfrom;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090401-1.c",
    "content": "/* PR rtl-optimization/39588 */\n/* Testcase by Olivier ROUSSEL <olivier.roussel@cril.univ-artois.fr> */\n\n#define lit_from_int(in) ((in<0)?(((-in)<<1)|1):(in<<1))\n\nvoid init_clause(int *literals, int size, int *lits)\n{\n  int i;\n  for(i=0; i < size; i++)\n    lits[i] = lit_from_int(literals[i]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090518-1.c",
    "content": "float\nfoo(int i)\n{\n  int j = i == 42;\n  return *(float *)&j;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090519-1.c",
    "content": "typedef struct { int licensed;  } __pmPDUInfo;\nvoid __pmDecodeXtendError (int *);\nvoid do_handshake(void)\n{\n  __pmPDUInfo *pduinfo;\n  int challenge;\n  __pmDecodeXtendError(&challenge);\n  pduinfo = (__pmPDUInfo *)&challenge;\n  *pduinfo = *pduinfo;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090721-1.c",
    "content": "/* { dg-options \"-fno-tree-sra\" } */\nunion u {double d;long long ll;};\nint f(double x, int n){union u v;v.d=x;if(n>=0){v.ll<<=63;}else{v.ll-=1<<-n;v.ll>>=-n;}return v.ll;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090907-1.c",
    "content": "struct platform_device;\ntypedef unsigned long __kernel_size_t;\ntypedef unsigned short __u16;\ntypedef unsigned int __u32;\ntypedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef __kernel_size_t size_t;\ntypedef __u32 uint32_t;\nstatic inline __attribute__ ((always_inline))\nuint32_t __attribute__ ((pure)) bfin_dspid (void)\n{\n    return ( {\n\t    uint32_t __v; __v;}\n    );\n}\nstruct list_head {\n    struct list_head *next, *prev;\n};\nstruct page {\n    union {\n    };\n    struct list_head lru;\n};\nstruct device_driver {\n    const char *name;\n    struct module *owner;\n};\nstruct fb_info {\n    struct device *dev;\n};\nstruct platform_driver {\n    int (*probe) (struct platform_device *);\n    int (*remove) (struct platform_device *);\n    struct device_driver driver;\n};\nstruct firmware {\n    size_t size;\n    const u8 *data;\n};\nstruct metronomefb_par {\n    struct fb_info *info;\n};\nstruct waveform_hdr {\n    u8 trc;\n};\nstatic u8 calc_cksum (int start, int end, u8 * mem)\n{\n    u8 tmp = 0;\n    int i;\n    for (i = start; i < end; i++)\n\ttmp += mem[i];\n    return tmp;\n}\nextern struct waveform_hdr *wfm_hdr;\nextern int wmta;\n\nstatic int\nload_waveform (u8 * mem, size_t size, int m, int t, struct metronomefb_par *par)\n{\n    int tta;\n    int trn = 0;\n    int i;\n    u8 cksum;\n    int cksum_idx;\n    struct device *dev = par->info->dev;\n    for (i = 0; i <= sizeof (*wfm_hdr) + wfm_hdr->trc; i++) {\n\tif (mem[i] > t) {\n\t    trn = i - sizeof (*wfm_hdr) - 1;\n\t}\n    }\n    tta = * (mem + wmta + m * 4) & 0x00FFFFFF;\n    cksum_idx = tta + trn * 4 + 3;\n    cksum = calc_cksum (cksum_idx - 3, cksum_idx, mem);\n    if (cksum != mem[cksum_idx]) {\n\tabort();\n    }\n}\nextern struct firmware *fw_entry;\nextern struct metronomefb_par *par;\n\nint metronomefb_probe (struct platform_device *dev)\n{\n\treturn load_waveform ((u8 *) fw_entry->data, fw_entry->size, 3, 31, par);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20090917-1.c",
    "content": "typedef int *loop_p;\ntypedef struct VEC_loop_p_base\n{\n  unsigned num;\n  loop_p vec[1];\n}\nVEC_loop_p_base;\n\n__inline__ int\nVEC_loop_p_base_iterate (const VEC_loop_p_base * vec_, unsigned ix_,\n\t\t\t loop_p * ptr)\n{\n  if (vec_ && ix_ < vec_->num)\n    {\n      *ptr = vec_->vec[ix_];\n      return 1;\n    }\n  else\n    {\n      return 0;\n    }\n}\n\ntypedef struct VEC_loop_p_heap\n{\n  VEC_loop_p_base base;\n}\nVEC_loop_p_heap;\n\n\nstatic __inline__ int\nam_vector_index_for_loop (VEC_loop_p_heap * loop_nest, int loop_num)\n{\n  int i;\n  loop_p l;\n\n  for (i = 0;\n       VEC_loop_p_base_iterate ((loop_nest) ? &(loop_nest)->base : 0, i,\n\t\t\t\t&(l)); i++)\n    if (l == loop_num)\n      return i;\n\n  __builtin_unreachable ();\n}\n\nunsigned char\nbuild_access_matrix (unsigned max)\n{\n  unsigned i;\n  for (i = 0; i < max; i++)\n    {\n      if (am_vector_index_for_loop (foo (), 0))\n\treturn 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20091215-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\nvoid bar ();\n\nvoid\nfoo (void *x, short y)\n{\n  bar (x, y + 1);\n}\n\nvoid\nbar (x, y)\n  void *x;\n  char *y;\n{\n  baz (y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20100609-1.c",
    "content": "extern unsigned long int strtoul (__const char *__restrict __nptr,       char **__restrict __endptr, int __base);\nint find_reloads (int i, char *p)\n{\n  int c;\n  while ((c = *p++))\n    return strtoul (p - 1, &p, 10); \n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20100907.c",
    "content": "struct a {int a,b;};\nconst static struct a a[1]={{1,2}};\nstruct a b,c;\nt()\n{\n  int idx = 0;\n  b=a[idx];\n  c=a[idx];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20100915-1.c",
    "content": "/* PR rtl-optimization/45593 */\n/* Testcase by Arnaud Lacombe <lacombar@gmail.com> */\n\ntypedef unsigned int __u32;\ntypedef __u32 __be32;\nstatic inline __attribute__((always_inline)) int __attribute__((__cold__)) printk(const char *s, ...) { return 0; }\ntypedef struct journal_s journal_t;\ntypedef struct journal_header_s\n{\n __be32 h_magic;\n __be32 h_blocktype;\n __be32 h_sequence;\n} journal_header_t;\ntypedef struct journal_superblock_s\n{\n journal_header_t s_header;\n __be32 s_blocksize;\n __be32 s_maxlen;\n} journal_superblock_t;\nstruct journal_s\n{\n struct buffer_head *j_sb_buffer;\n journal_superblock_t *j_superblock;\n int j_format_version;\n int j_blocksize;\n unsigned int j_maxlen;\n};\nstatic void journal_fail_superblock (journal_t *journal)\n{\n journal->j_sb_buffer = ((void *)0);\n}\nstatic int journal_get_superblock(journal_t *journal)\n{\n struct buffer_head *bh;\n journal_superblock_t *sb;\n int err = -100;\n bh = journal->j_sb_buffer;\n if (!buffer_uptodate(bh)) {\n  if (!buffer_uptodate(bh)) {\n   printk (\"JBD: IO error reading journal superblock\\n\");\n   goto out;\n  }\n }\n err = -101;\n if (sb->s_header.h_magic != (( __be32)(__u32)(0)) ||\n     sb->s_blocksize != (( __be32)(__u32)(journal->j_blocksize))) {\n  printk(\"JBD: no valid journal superblock found\\n\");\n  goto out;\n }\n switch((( __u32)(__be32)(sb->s_header.h_blocktype))) {\n case 0:\n case 1:\n  break;\n default:\n  goto out;\n }\n if ((( __u32)(__be32)(sb->s_maxlen)) < journal->j_maxlen)\n  journal->j_maxlen = (( __u32)(__be32)(sb->s_maxlen));\n else if ((( __u32)(__be32)(sb->s_maxlen)) > journal->j_maxlen) {\n  printk (\"JBD: journal file too short\\n\");\n  goto out;\n }\n return 0;\nout:\n journal_fail_superblock(journal);\n return err;\n}\nstatic int load_superblock(journal_t *journal)\n{\n journal_get_superblock(journal);\n return 0;\n}\nint jbd2_journal_update_format (journal_t *journal)\n{\n journal_get_superblock(journal);\n return 0;\n}\nint jbd2_journal_wipe(journal_t *journal, int write)\n{\n load_superblock(journal);\n return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20101216-1.c",
    "content": "typedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\ntypedef union\n{\n  double value;\n  struct\n  {\n    __uint32_t msw;\n    __uint32_t lsw;\n  } parts;\n} ieee_double_shape_type;\ntwo52= 4.50359962737049600000e+15,\nw6 = -1.63092934096575273989e-03;\ndouble sin_pi(double x)\n{\n double y,z;\n __int32_t n,ix;\nieee_double_shape_type gh_u;\n gh_u.value = (x); \n(ix) = gh_u.parts.msw;\n                if(ix<0x43300000)\n z = y+two52;\n ieee_double_shape_type gl_u;\n gl_u.value = (z);\n (n) = gl_u.parts.lsw;\n  n &= 1;\n switch (n)\n {\n     case 0:\n__kernel_sin();\n     }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20101217-1.c",
    "content": "/* Testcase provided by HUAWEI.  */\n#include <stdio.h>\nint main()\n{\n        int cur_k;\n        int cur_j=0;\n        int cur_i=28;\n        unsigned char temp_data[8];\n        unsigned int Data_Size=20;\n\n        for (cur_k=0;cur_j<7;cur_j++,cur_i++) {\n                if (cur_j%2==0) {\n                        temp_data[cur_k++]=0;\n                }\n                if (cur_k==7) {\n                        for (;cur_k>0;cur_k--) {\n                                if (cur_k>2) {\n                                        if ((temp_data[7-cur_k]=='n' || temp_data[7-cur_k]=='N' ) && (temp_data[7-cur_k+1]=='a' || temp_data[7-cur_k+1]=='A' )) {\n                                                break;\n                                        }\n                                }\n                                if (cur_k==1) {\n                                        if (temp_data[7-cur_k]=='n' || temp_data[7-cur_k]=='N' ) {\n                                                break;\n                                        }\n                                }\n                        }\n                        if (cur_k==7) {\n                        } else {\n                                if (cur_k>0)\n                                        printf(\"dfjk\");\n                        }\n                }\n        }\nreturn 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110126-1.c",
    "content": "/* PR rtl-optimization/44469 */\n/* Testcase by Siarhei Siamashka <siarhei.siamashka@gmail.com> */\n\nint a (int *t, const char *p)\n{\n  if (*t == 0)\n    {\n    }\n  else if (*t == 1)\n    {\n      p = (const char *)t;\n    }\n  else\n    __builtin_unreachable();\n  if (p[0])\n    return 0;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110131-1.c",
    "content": "/* PR rtl-optimization/44031 */\n/* Testcase by John Regehr <regehr@cs.utah.edu> */\n\ntypedef unsigned char uint8_t;\ntypedef unsigned int uint32_t;\ntypedef unsigned long int uint64_t;\n\nstatic uint32_t\nsafe_add_func_uint32_t_u_u (uint32_t ui1, uint32_t ui2)\n{\n  return ui1 + ui2;\n}\n\nstatic uint64_t\nsafe_div_func_uint64_t_u_u (uint64_t ui1, uint32_t ui2)\n{\n  return ui2 ? : (ui1 / ui2);\n}\n\nuint8_t g_55;\nuint8_t *g_73 = &g_55;\nuint8_t **g_332 = &g_73;\n\nint func_38(uint8_t *,int);\nint func_8(int);\n\nint int321 (void)\n{\n  uint8_t l_26[4];\n  uint8_t *l_238 = &l_26[2];\n  uint8_t l_400;\n  l_400 &=\n    func_38 (&l_26[3],\n         safe_add_func_uint32_t_u_u (safe_div_func_uint64_t_u_u\n                     (1, **g_332),\n                     *l_238) >= *l_238 < func_8 (0)), 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110401-1.c",
    "content": "void asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len)\n{\n    int k;\n    unsigned char temp[4];\n    if (len < 128) {\n\tif (ans != ((void *) 0))\n\t    ans[0] = (unsigned char) len;\n\t*ans_len = 1;\n    } else {\n\tk = 0;\n\twhile (len) {\n\t    temp[k++] = len & 0xFF;\n\t    len = len >> 8;\n\t}\n\t*ans_len = k + 1;\n\tif (ans != ((void *) 0)) {\n\t    ans[0] = ((unsigned char) k & 0x7F) + 128;\n\t    while (k--)\n\t\tans[*ans_len - 1 - k] = temp[k];\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110902.c",
    "content": "static inline __attribute__((always_inline)) int f (unsigned int n, unsigned int size)\n{\n return (__builtin_constant_p (size != 0 && n > ~0 / size)\n         ? !!(size != 0 && n > ~0 / size)\n         : ({ static unsigned int count[2] = { 0, 0 };\n              int r = !!(size != 0 && n > ~0 / size);\n              count[r]++;\n              r; }));\n}\n\nint g (unsigned int size)\n{\n return f (size / 4096, 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110906-1.c",
    "content": "/* PR middle-end/50266 */\n/* Testcase by <bero@arklinux.org> */\n\nstruct a {\n unsigned int a;\n unsigned int b;\n};\n\nstruct a *const p = (struct a *)0x4A004100;\n\nvoid foo(void)\n{\n unsigned int i = 0;\n unsigned int *const x[] = {\n  &p->a,\n  &p->b,\n  0\n };\n\n (*(volatile unsigned int *)((x[i]))\n   = (unsigned int)((unsigned int)((*(volatile unsigned int *)(x[i])))));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20110913-1.c",
    "content": "struct ieee754_double {\n  double d;\n};\nextern const float __exp_deltatable[178];\nfloat __ieee754_expf (float x)\n{\n  static const float himark = 88.72283935546875;\n  static const float lomark = -103.972084045410;\n  if (__builtin_isless(x, himark) && __builtin_isgreater(x, lomark))\n    {\n      int tval;\n      double x22, t, result, dx;\n      float delta;\n      struct ieee754_double ex2_u;\n      dx -= t;\n      tval = (int) (t * 512.0);\n      if (t >= 0)\n\tdelta = - __exp_deltatable[tval];\n      else\n\tdelta = __exp_deltatable[-tval];\n      x22 = (0.5000000496709180453 * dx + 1.0000001192102037084) * dx + delta;\n      result = x22 * ex2_u.d + ex2_u.d;\n      return (float) result;\n    }\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20111209-1.c",
    "content": "/* { dg-do compile { target s390x-*-* *-*-*vms* } } */\n\ntypedef char* char_ptr32 __attribute__ ((mode(SI)));\n\nchar_ptr32 getenv (const char *name);\nunsigned long strlen (const char *str);\n\nvoid\n__gnat_getenv (char *name, int *len, char **value)\n{\n  *value = getenv (name);\n  *len = strlen (*value);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120524-1.c",
    "content": "  char CJPAT_Packet[1508] = {};\nvoid build_packet(int port, char *packet) {\n            memcpy(packet, CJPAT_Packet, sizeof(CJPAT_Packet)); \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120727-1.c",
    "content": "/* { dg-options \"-mfpmath=387\" { target { i?86-*-* x86_64-*-* } } } */\n\nunion {\n  char *p;\n  float f;\n} u;\n\nvoid\nf (void)\n{\n  u.p = \"\";\n  u.f += 1.1f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120727-2.c",
    "content": "/* { dg-options \"-mfpmath=387\" { target { i?86-*-* x86_64-*-* } } } */\n\nunion {\n  char *p;\n  double d;\n} u;\n\nvoid\nf (void)\n{\n  u.p = \"\";\n  u.d += 1.1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120822-1.c",
    "content": "int a;\nint c;\nint b;\nvoid shr_long(int d, unsigned char s)\n{\n long long dvd, div, mod;\n dvd = b;\n mod = dvd % s;\n if (((c >> ((mod & 0xff) % 32)) & 1) == 0)\n  a = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120830-1.c",
    "content": "int keyring_search(void);\nint keydb_search2 (int *hdfound, int *hdcurrent, int *a)\n{\n    int rc = -1;\n    while (rc == -1) {\n        if (*a == 1)\n            rc = keyring_search ();\n        if (rc == -1)\n            *hdcurrent++;\n\tif (!rc)\n            *hdfound = *hdcurrent;\n    }\n    return rc;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120830-2.c",
    "content": "ubidi_writeReordered_49( int *dest, const unsigned char *dirProps) \n{\n    if (!(1&(1UL<<*dirProps)))\n      *dest=1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120913-1.c",
    "content": "struct list_head {\n  struct list_head *next, *prev;\n};\nstruct dm_exception {\n  struct list_head hash_list;\n  unsigned long long old_chunk;\n  unsigned long long new_chunk;\n};\nstruct dm_exception *dm_lookup_exception(struct list_head *table, unsigned long long chunk) {\n  struct list_head *slot;\n  struct dm_exception *e;\n  slot = &table[0];\n  e = (struct dm_exception *)slot->next;\n  for (; &e->hash_list != (slot);)\n    if (chunk <= (e->new_chunk>>56))\n      return e;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120917-1.c",
    "content": "typedef long long curl_off_t;\nint tool_seek_cb(void *userdata, curl_off_t offset, int whence)\n{\n  if(offset > 0x7FFFFFFFLL - 0x1LL) \n{\n    curl_off_t left = offset;\n    while(left) \n{\n      long step = (left > 0x7FFFFFFFLL - 0x1LL) ? 2147483647L - 1L : (long)left;\n      left -= step;\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20120927-1.c",
    "content": "void ff(int);\nint isc_fsaccess_set(unsigned int access) {\n unsigned int mode;\n unsigned int bits;\n mode = 0;\n bits = 0x00000021;\n if ((access & bits) != 0) \n  {\n   mode |= 0400;\n   access &= ~bits;\n  }\n access &= ~bits; \n bits <<= (10);\n if ((access & bits) != 0)\n   access &= ~bits; \n bits = 0x00000012;\n if ((access & bits) != 0)\n {\n   mode |= 0200; \n   access &= ~bits; \n }\n mode |= (0200 >> 3);\n access &= ~bits; \n bits <<= (10);\n if ((access & bits) != 0)\n   mode |= ((0200 >> 3) >> 3);\n bits = 0x00000044;\n if ((access & bits) != 0)\n { \n    mode |= 0100;\n    access &= ~bits;\n }\n if ((access & bits) != 0)\n {\n   mode |= (0100 >> 3);\n   access &= ~bits; \n }; \n bits <<= (10);\n if ((access & bits) != 0)\n   mode |= ((0100 >> 3) >> 3);\n ff(mode) ;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20121010-1.c",
    "content": "int _IO_getc(int*);\nread_long(int *fp)\n{\n  unsigned char b0, b1, b2, b3;\n  b0 = _IO_getc (fp);\n  b1 = _IO_getc (fp);\n  b2 = _IO_getc (fp);\n  b3 = _IO_getc (fp);\n  return ((int)(((((b3 << 8) | b2) << 8) | b1) << 8) | b0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20121027-1.c",
    "content": "extern int nc;\nvoid f(void)\n{\n    unsigned char resp[1024];\n    int c;\n    int bl = 0;\n    unsigned long long *dwords = (unsigned long long *)(resp + 5);\n    for (c=0; c<nc; c++)\n    {\n        ff(dwords[bl/64]);\n        bl++;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20121107-1.c",
    "content": "/* PR middle-end/55219 */\n/* Testcase by Markus Trippelsdorf <markus@trippelsdorf.de> */\n\nint x, c, d, e, f, g, h, i;\ndouble j;\nconst int k;\nconst enum { B } a;\nvoid\nfn1 (void)\n{\n  h = (g ? c : g ? f : g ? e : g ? i : g ? f : g ? e : g ? d : x)\n      + (a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a\n         ? j : a ? : 0 ? : a ? : a ? : a ? : a ? : a ? : a ? k : a ? : x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20121220-1.c",
    "content": "typedef unsigned char uint8_t;\ntypedef unsigned int uint32_t;\nstatic __attribute__ (( always_inline )) __inline__\nvoid rop_8_notsrc_or_dst(uint8_t *dst, uint8_t src)\n{\n  *dst = (~(src)) | (*dst);\n}\nvoid cirrus_colorexpand_notsrc_or_dst_8 (uint8_t * dst, int bits)\n{\n  uint8_t src;\n  uint32_t colors[2];\n  src = colors[bits];\n  rop_8_notsrc_or_dst(dst, src);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20140110-1.c",
    "content": "typedef long unsigned int size_t;\nstruct RangeMapRange {\n  unsigned fromMin;\n  unsigned fromMax;\n  unsigned toMin;\n};\nvoid reserve1(void);\nvoid f(struct RangeMapRange *q1, size_t t)\n{\n  const struct RangeMapRange *q2 = q1 + t;\n  size_t n = q2 - q1;\n  if (n > 0)\n    reserve1();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20140213.c",
    "content": "static unsigned short\nfoo (unsigned char *x, int y)\n{\n  unsigned short r = 0;\n  int i;\n  for (i = 0; i < y; i++)\n    r += x[i];\n  return r;\n}\n\nint baz (int, unsigned short);\n\nvoid\nbar (unsigned char *x, unsigned char *y)\n{\n  int i;\n  unsigned short key = foo (x, 0x10000);\n  baz (0, 0);\n  for (i = 0; i < 0x80000; i++)\n    y[i] = x[baz (i, key)];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20140528-1.c",
    "content": "unsigned f(unsigned flags, unsigned capabilities)\n{\n  unsigned gfp_mask;\n  unsigned gfp_notmask = 0;\n  gfp_mask = flags & ((1 << 25) - 1);\n  if (!(capabilities & 0x00000001))\n    gfp_mask |= 0x1000000u;\n  return (gfp_mask & ~gfp_notmask);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20140723-1.c",
    "content": "double f(double a, double b, int c, int d)\n{\n  return (c>10&&d>20)?a:b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20140816-1.c",
    "content": "/* This used to ICE with the ccmp patches on aarch64. */\nint f(char);\nint init_emit_regs (int mode) {\n  f(mode == 4 || mode == 13);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20150108.c",
    "content": "long long a[10];\nlong long b, c, d, k, m, n, o, p, q, r, s, t, u, v, w;\nint e, f, g, h, i, j, l, x;\n\nint fn1 () {\n  for (; x; x++)\n    if (x & 1)\n      s = h | g;\n    else\n      s = f | e;\n  l = ~0;\n  m = 1 | k;\n  n = i;\n  o = j;\n  p = f | e;\n  q = h | g;\n  w = d | c | a[1];\n  t = c;\n  v = b | c;\n  u = v;\n  r = b | a[4];\n  return e;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20150327.c",
    "content": "int a;\nint (*b)(), (*c)();\nint fn1(int p1) {\n  if (a)\n    return 0;\n  if (p1) {\n    c();\n    b();\n  }\n}\nvoid fn2() { fn1(0); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20151204.c",
    "content": "/* { dg-skip-if \"Array too big\" { \"avr-*-*\" } } */\n\ntypedef __SIZE_TYPE__ size_t;\n\nint strcmp (const char*, const char*);\nvoid *memchr (const void *, int, size_t);\nchar* strncpy (char *, const char *, size_t);\n\nint\nmain (int argc, char** argv)\n{\n  char target[32753] = \"A\";\n  char buffer[32753];\n  char *x;\n  x = buffer;\n\n  if (strcmp (target, \"A\")\n      || memchr (target, 'A', 0) != ((void *) 0))\n    if (strncpy (x, \"\", 4) != x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20160205-1.c",
    "content": "int a[32];\nint fn1(int d) {\n  int c = 1;\n  for (int b = 0; b < 32; b++)\n    if (a[b])\n      c = 0;\n  return c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/20161124-1.c",
    "content": "/* PR middle-end/78429 */\n/* Testcase by Chengnian Sun <chengniansun@gmail.com> */\n\nint a[6];\nchar b;\nunsigned c;\nshort d;\nvolatile int e;\n\nint foo (void)\n{\n  int f;\n  for (; c <= 2; c++) {\n    d = 3;\n    for (; d >= 0; d--) {\n      int g = b;\n      f = a[d] || b;\n    }\n    f || e;\n  }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/386.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nfoo (a, p)\n     int *p;\n{\n  p[0] = a;\n  a = (short) a;\n  return a;\n}\n\nmain ()\n{\n  int i;\n  foobar (i, &i);\n}\n\n\nfoobar (a, b)\n{\n  int c;\n\n  c = a % b;\n  a = a / b;\n  return a + b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/86.c",
    "content": "m32 (a)\n     int *a;\n{\n  a[1] = a[0];\n}\n\nm16 (a)\n     short *a;\n{\n  a[1] = a[0];\n}\n\n\nm8 (a)\n     char *a;\n{\n  a[1] = a[0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/900116-1.c",
    "content": "struct st {char a, b, c, d; }\n\nzloop (struct st *s, int *p, int *q)\n{\n  int i;\n  struct st ss;\n\n  for (i = 0;  i < 100;  i++)\n    {\n      ss = s[i];\n      p[i] = ss.c;\n      q[i] = ss.b;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/900216-1.c",
    "content": "foo (p, a, b)\n     unsigned short *p;\n{\n  unsigned int x;\n\n  x = p[0];\n\n  return (x == 134U);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/900313-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nmain ()\n{\n  char *a;\n  foo (alloca (10000));\n  foo (alloca (100000));\n  foo (alloca ((int) &main));\n}\n\nmany_par (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)\n{\n  char *x;\n  int aa, ba, ca, da, ea, fa, ga, ha, ia, ja, ka, la, ma, na, oa, pa;\n\n  aa = bar ();\n  ba = bar ();\n  ca = bar ();\n  da = bar ();\n  ea = bar ();\n  fa = bar ();\n  ga = bar ();\n  ha = bar ();\n  ia = bar ();\n  ja = bar ();\n  ka = bar ();\n  la = bar ();\n  ma = bar ();\n  na = bar ();\n  oa = bar ();\n  pa = bar ();\n  foobar (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ba, ca,\n\t  da, ea, fa, ga, ha, ia, ja, ka, la, ma, na, oa, pa);\n\n}\n\nfoobar (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ba, ca,\n\tda, ea, fa, ga, ha, ia, ja, ka, la, ma, na, oa, pa)\n{\n  int ab, bb, cb, db, eb, fb, gb, hb, ib, jb, kb, lb, mb, nb, ob, pb;\n  int qb, rb, sb, tb, ub, vb, xb, yb;\n\n  ab = bar ();\n  bb = bar ();\n  cb = bar ();\n  db = bar ();\n  eb = bar ();\n  fb = bar ();\n  gb = bar ();\n  hb = bar ();\n  ib = bar ();\n  jb = bar ();\n  kb = bar ();\n  lb = bar ();\n  mb = bar ();\n  nb = bar ();\n  ob = bar ();\n  pb = bar ();\n  qb = bar ();\n  rb = bar ();\n  sb = bar ();\n  tb = bar ();\n  ub = bar ();\n  vb = bar ();\n  xb = bar ();\n  yb = bar ();\n\n  boofar (a);\n  boofar (b);\n  boofar (c);\n  boofar (d);\n  boofar (e);\n  boofar (f);\n  boofar (g);\n  boofar (h);\n  boofar (i);\n  boofar (j);\n  boofar (k);\n  boofar (l);\n  boofar (m);\n  boofar (n);\n  boofar (o);\n  boofar (p);\n  boofar (aa);\n  boofar (ba);\n  boofar (ca);\n  boofar (da);\n  boofar (ea);\n  boofar (fa);\n  boofar (ga);\n  boofar (ha);\n  boofar (ia);\n  boofar (ja);\n  boofar (ka);\n  boofar (la);\n  boofar (ma);\n  boofar (na);\n  boofar (oa);\n  boofar (pa);\n\n  boofar (ab);\n  boofar (bb);\n  boofar (cb);\n  boofar (db);\n  boofar (eb);\n  boofar (fb);\n  boofar (gb);\n  boofar (hb);\n  boofar (ib);\n  boofar (jb);\n  boofar (kb);\n  boofar (lb);\n  boofar (mb);\n  boofar (nb);\n  boofar (ob);\n  boofar (pb);\n\n  boofar (a);\n  boofar (b);\n  boofar (c);\n  boofar (d);\n  boofar (e);\n  boofar (f);\n  boofar (g);\n  boofar (h);\n  boofar (i);\n  boofar (j);\n  boofar (k);\n  boofar (l);\n  boofar (m);\n  boofar (n);\n  boofar (o);\n  boofar (p);\n  boofar (aa);\n  boofar (ba);\n  boofar (ca);\n  boofar (da);\n  boofar (ea);\n  boofar (fa);\n  boofar (ga);\n  boofar (ha);\n  boofar (ia);\n  boofar (ja);\n  boofar (ka);\n  boofar (la);\n  boofar (ma);\n  boofar (na);\n  boofar (oa);\n  boofar (pa);\n\n  boofar (ab);\n  boofar (bb);\n  boofar (cb);\n  boofar (db);\n  boofar (eb);\n  boofar (fb);\n  boofar (gb);\n  boofar (hb);\n  boofar (ib);\n  boofar (jb);\n  boofar (kb);\n  boofar (lb);\n  boofar (mb);\n  boofar (nb);\n  boofar (ob);\n  boofar (pb);\n\n}\n\ntest_exit_ignore_stack ()\n{\n  foobar (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n\t  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/900407-1.c",
    "content": "foo (a, b, p)\n     int *p;\n{\n  int c;\n  p[1] = a + 0x1000;\n  c = b + 0xffff0000;\n  if ((b + 0xffff0000) == 0)\n    c++;\n  p[2] = c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/900516-1.c",
    "content": "f(c){return!(c?2.0:1.0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920301-1.c",
    "content": "#ifndef NO_LABEL_VALUES\nf(){static void*t[]={&&x};x:;}\n#endif\ng(){static unsigned p[5];}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920409-1.c",
    "content": "x(){int y;y>0.0?y:y-1;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920409-2.c",
    "content": "double x(){int x1,x2;double v;\nif(((long)(x1-x2))<1)return -1.0;v=t(v);v=y(1,v>0.0?(int)v:((int)v-1));}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920410-1.c",
    "content": "int alloc_float(f)\n float f;\n{  union\n    {\n      float f;\n      int i;\n    }\n  u;\n  u.f=f;\n  return u.i&~1;\n}\n\nfloat c_float(int obj)\n{  union\n    {\n      float f;\n      int i;\n    } u;\n\n  u.i=obj;\n  return u.f;\n}\n\nmain()\n{ int x=alloc_float(1.2);\n  int y=alloc_float(5.7);\n  int z=alloc_float(c_float(x)*c_float(y));\n\n  printf(\"%g\\n\",(double)c_float(z));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920410-2.c",
    "content": "joe()\n{\n  int j;\n\n  while( 1 )\n    {\n      for( j = 0; j < 4; j++ )\n\t;\n      for( j = 0; j < 4; j++ )\n\t;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920411-2.c",
    "content": "x(){int n;double x;n=x<1?n:n+1;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920413-1.c",
    "content": "union u {double d;long long ll;};\nf(double x, int n){union u v;v.d=x;if(n>=0){v.ll<<=63;}else{v.ll+=1<<-n;v.ll>>=-n;}return v.ll;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920415-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nextern void abort (void);\nextern void exit (int);\n\nf ()\n{\n  __label__ l;\n  void *x()\n    {\n      return &&l;\n    }\n  goto *x ();\n  abort ();\n  return;\n l:\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-1.c",
    "content": "x(){char*q;return(long)q>>8&0xff;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-2.c",
    "content": "double sin(double x);\ndouble cos(double x);\ndouble tan(double x);\ndouble asin(double x);\ndouble acos(double x);\ndouble atan(double x);\ndouble atan2(double y, double x);\ndouble sinh(double x);\ndouble cosh(double x);\ndouble tanh(double x);\ndouble exp(double x);\ndouble expm1(double x);\ndouble log(double x);\ndouble log10(double x);\ndouble log1p(double x);\ndouble pow(double x, double y);\ndouble sqrt(double x);\ndouble cbrt(double x);\ndouble ceil(double x);\ndouble floor(double x);\ndouble fabs(double x);\ndouble frexp(double value, int *eptr);\ndouble ldexp(double value, int exp);\ndouble modf(double value, double *iptr);\ndouble erf(double x);\ndouble erfc(double x);\ndouble atof(const char *nptr);\ndouble hypot(double x, double y);\ndouble lgamma(double x);\ndouble j0(double x);\ndouble j1(double x);\ndouble jn(int n, double x);\ndouble y0(double x);\ndouble y1(double x);\ndouble yn(int n, double x);\nextern struct _iobuf {\n int _cnt;\n char *_ptr;\n char *_base;\n int _bufsiz;\n short _flag;\n char _file;\n} _iob[];\ntypedef __SIZE_TYPE__ size_t;\ntypedef char *va_list;\nstruct _iobuf *fopen(const char *filename, const char *type);\nstruct _iobuf *freopen(const char *filename, const char *type, struct _iobuf *stream);\nstruct _iobuf *fdopen(int fildes, const char *type);\nstruct _iobuf *popen(const char *command, const char *type);\nint pclose(struct _iobuf *stream);\nint fflush(struct _iobuf *stream);\nint fclose(struct _iobuf *stream);\nint remove(const char *path);\nint rename(const char *from, const char *to);\nstruct _iobuf *tmpfile(void);\nchar *tmpnam(char *s);\nint setvbuf(struct _iobuf *iop, char *buf, int type, size_t size);\nint setbuf(struct _iobuf *stream, char *buf);\nint setbuffer(struct _iobuf *stream, char *buf, size_t size);\nint setlinebuf(struct _iobuf *stream);\nint fprintf(struct _iobuf *stream, const char *format, ...);\nint printf(const char *format, ...);\nchar *sprintf(char *s, const char *format, ...);\nint vfprintf(struct _iobuf *stream, const char *format, va_list arg);\nint vprintf(const char *format, va_list arg);\nint vsprintf(char *s, const char *format, va_list arg);\nint fscanf(struct _iobuf *stream, const char *format, ...);\nint scanf(const char *format, ...);\nint sscanf(char *s, const char *format, ...);\nint fgetc(struct _iobuf *stream);\nint getw(struct _iobuf *stream);\nchar *fgets(char *s, int n, struct _iobuf *stream);\nchar *gets(char *s);\nint fputc(int c, struct _iobuf *stream);\nint putw(int w, struct _iobuf *stream);\nint fputs(const char *s, struct _iobuf *stream);\nint puts(const char *s);\nint ungetc(int c, struct _iobuf *stream);\nint fread(void *ptr, size_t size, size_t count, struct _iobuf *iop);\nint fwrite(const void *ptr, size_t size, size_t count, struct _iobuf *iop);\nint fseek(struct _iobuf *stream, long offset, int ptrname);\nlong ftell(struct _iobuf *stream);\nvoid rewind(struct _iobuf *stream);\nint fgetpos(struct _iobuf *stream, long *pos);\nint fsetpos(struct _iobuf *stream, const long *pos);\nvoid perror(const char *s);\ntypedef unsigned char byte;\ntypedef unsigned char uchar;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\ntypedef unsigned char u_char;\ntypedef unsigned short u_short;\ntypedef unsigned int u_int;\ntypedef unsigned long u_long;\ntypedef unsigned short ushort_;\ntypedef struct _physadr { int r[1]; } *physadr;\ntypedef struct label_t {\n int val[11];\n} label_t;\ntypedef struct _quad { long val[2]; } quad;\ntypedef long daddr_t;\ntypedef char * caddr_t;\ntypedef u_long ino_t;\ntypedef long swblk_t;\ntypedef long time_t;\ntypedef short dev_t;\ntypedef long off_t;\ntypedef u_short uid_t;\ntypedef u_short gid_t;\ntypedef signed char prio_t;\ntypedef long fd_mask;\ntypedef struct fd_set {\n fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];\n} fd_set;\ntypedef struct qhdr {\n struct qhdr *link, *rlink;\n} *queue_t;\ntypedef char *ptr_ord_t;\ntypedef double floatp;\ntypedef char *(*proc_alloc_t)(unsigned num_elements, unsigned element_size, const char *client_name );\ntypedef void (*proc_free_t)(char *data, unsigned num_elements, unsigned element_size, const char *client_name );\nextern struct _iobuf *gs_out;\ntypedef struct gs_point_s {\n double x, y;\n} gs_point;\ntypedef struct gs_int_point_s {\n int x, y;\n} gs_int_point;\ntypedef struct gs_rect_s {\n gs_point p, q;\n} gs_rect;\ntypedef struct gs_int_rect_s {\n gs_int_point p, q;\n} gs_int_rect;\ntypedef struct gs_state_s gs_state;\ntypedef struct {\n proc_alloc_t alloc;\n proc_free_t free;\n} gs_memory_procs;\nchar *gs_malloc(uint, uint, const char * );\nvoid gs_free(char *, uint, uint, const char * );\nextern char gs_debug[128];\nextern int gs_log_error(int, const char *, int );\ntypedef long fixed;\ntypedef struct gs_fixed_point_s {\n fixed x, y;\n} gs_fixed_point;\ntypedef struct gs_fixed_rect_s {\n gs_fixed_point p, q;\n} gs_fixed_rect;\ntypedef struct gs_matrix_s {\n long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;\n} gs_matrix;\nvoid gs_make_identity(gs_matrix * );\nint gs_make_translation(floatp, floatp, gs_matrix * ),\n gs_make_scaling(floatp, floatp, gs_matrix * ),\n gs_make_rotation(floatp, gs_matrix * );\nint gs_matrix_multiply(const gs_matrix *, const gs_matrix *, gs_matrix * ),\n gs_matrix_invert(const gs_matrix *, gs_matrix * ),\n gs_matrix_rotate(const gs_matrix *, floatp, gs_matrix * );\nint gs_point_transform(floatp, floatp, const gs_matrix *, gs_point * ),\n gs_point_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),\n gs_distance_transform(floatp, floatp, const gs_matrix *, gs_point * ),\n gs_distance_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),\n gs_bbox_transform_inverse(gs_rect *, gs_matrix *, gs_rect * );\ntypedef struct gs_matrix_fixed_s {\n long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;\n fixed tx_fixed, ty_fixed;\n} gs_matrix_fixed;\nextern void gs_update_matrix_fixed(gs_matrix_fixed * );\nint gs_point_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * ),\n gs_distance_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * );\ntypedef struct {\n long xx, xy, yx, yy;\n int skewed;\n int shift;\n int max_bits;\n fixed round;\n} fixed_coeff;\n\ntypedef enum {\n gs_cap_butt = 0,\n gs_cap_round = 1,\n gs_cap_square = 2\n} gs_line_cap;\ntypedef enum {\n gs_join_miter = 0,\n gs_join_round = 1,\n gs_join_bevel = 2\n} gs_line_join;\ngs_state *gs_state_alloc(proc_alloc_t, proc_free_t );\nint gs_state_free(gs_state * );\nint gs_gsave(gs_state * ),\n gs_grestore(gs_state * ),\n gs_grestoreall(gs_state * );\ngs_state *gs_gstate(gs_state * );\nint gs_currentgstate(gs_state * , const gs_state * ),\n gs_setgstate(gs_state * , const gs_state * );\ngs_state *gs_state_swap_saved(gs_state *, gs_state * );\nvoid gs_state_swap(gs_state *, gs_state * );\nint gs_initgraphics(gs_state * );\ntypedef struct gx_device_s gx_device;\nint gs_flushpage(gs_state * );\nint gs_copypage(gs_state * );\nint gs_output_page(gs_state *, int, int );\nint gs_copyscanlines(gx_device *, int, byte *, uint, int *, uint * );\ngx_device * gs_getdevice(int );\nint gs_copydevice(gx_device **, gx_device *, proc_alloc_t );\nint gs_makeimagedevice(gx_device **, gs_matrix *, uint, uint, byte *, int, proc_alloc_t );\nvoid gs_nulldevice(gs_state * );\nint gs_setdevice(gs_state *, gx_device * );\ngx_device * gs_currentdevice(gs_state * );\nconst char * gs_devicename(gx_device * );\nvoid gs_deviceinitialmatrix(gx_device *, gs_matrix * );\nint gs_closedevice(gx_device * );\nint gs_setlinewidth(gs_state *, floatp );\nfloat gs_currentlinewidth(const gs_state * );\nint gs_setlinecap(gs_state *, gs_line_cap );\ngs_line_cap gs_currentlinecap(const gs_state * );\nint gs_setlinejoin(gs_state *, gs_line_join );\ngs_line_join gs_currentlinejoin(const gs_state * );\nint gs_setmiterlimit(gs_state *, floatp );\nfloat gs_currentmiterlimit(const gs_state * );\nint gs_setdash(gs_state *, const float *, uint, floatp );\nuint gs_currentdash_length(const gs_state * );\nint gs_currentdash_pattern(const gs_state *, float * );\nfloat gs_currentdash_offset(const gs_state * );\nint gs_setflat(gs_state *, floatp );\nfloat gs_currentflat(const gs_state * );\nint gs_setstrokeadjust(gs_state *, int );\nint gs_currentstrokeadjust(const gs_state * );\ntypedef enum {\n gs_color_space_DeviceGray = 0,\n gs_color_space_DeviceRGB,\n gs_color_space_DeviceCMYK\n} gs_color_space;\ntypedef struct gs_color_s gs_color;\nextern const uint gs_color_sizeof;\nint gs_setgray(gs_state *, floatp );\nfloat gs_currentgray(gs_state * );\nint gs_sethsbcolor(gs_state *, floatp, floatp, floatp ),\n gs_currenthsbcolor(gs_state *, float [3] ),\n gs_setrgbcolor(gs_state *, floatp, floatp, floatp ),\n gs_currentrgbcolor(gs_state *, float [3] );\nint gs_currentcolorspace(gs_state *, gs_color_space * );\ntypedef float (*gs_transfer_proc)(gs_state *, floatp );\nint gs_settransfer(gs_state *, gs_transfer_proc ),\n gs_settransfer_remap(gs_state *, gs_transfer_proc, int );\ngs_transfer_proc gs_currenttransfer(gs_state * );\nint gs_setcolortransfer(gs_state *, gs_transfer_proc ,\n gs_transfer_proc , gs_transfer_proc ,\n gs_transfer_proc ),\n gs_setcolortransfer_remap(gs_state *, gs_transfer_proc ,\n gs_transfer_proc , gs_transfer_proc ,\n gs_transfer_proc , int );\nvoid gs_currentcolortransfer(gs_state *, gs_transfer_proc [4] );\nint gs_setscreen(gs_state *, floatp, floatp, float (*)(floatp, floatp ) );\nint gs_currentscreen(gs_state *, float *, float *, float (**)(floatp, floatp ) );\nint gs_sethalftonephase(gs_state *, int, int );\nint gs_currenthalftonephase(gs_state *, gs_int_point * );\ntypedef struct gs_screen_enum_s gs_screen_enum;\nextern const uint gs_screen_enum_sizeof;\nint gs_screen_init(gs_screen_enum *, gs_state *, floatp, floatp );\nint gs_screen_currentpoint(gs_screen_enum *, gs_point * );\nint gs_screen_next(gs_screen_enum *, floatp );\nstruct gs_state_s {\n gs_state *saved;\n gs_memory_procs memory_procs;\n gs_matrix_fixed ctm;\n gs_matrix ctm_inverse;\n int inverse_valid;\n struct gx_path_s *path;\n struct gx_clip_path_s *clip_path;\n int clip_rule;\n struct line_params_s *line_params;\n struct halftone_params_s *halftone;\n float (*ht_proc)(floatp, floatp );\n gs_int_point ht_phase;\n gs_int_point phase_mod;\n struct gs_color_s *color;\n struct gx_device_color_s *dev_color;\n struct gx_transfer_s *transfer;\n struct gs_font_s *font;\n gs_matrix char_tm;\n int char_tm_valid;\n byte in_cachedevice;\n byte in_charpath;\n\n\n\n\n int level;\n float flatness;\n int stroke_adjust;\n struct device_s *device;\n int device_is_shared;\n\n};\ntypedef unsigned long gx_bitmap_id;\ntypedef struct gx_bitmap_s {\n byte *data;\n int raster;\n gs_int_point size;\n gx_bitmap_id id;\n ushort rep_width, rep_height;\n} gx_bitmap;\ntypedef unsigned long gx_color_index;\ntypedef unsigned short gx_color_value;\ntypedef struct gx_device_color_info_s {\n int num_components;\n\n int depth;\n gx_color_value max_gray;\n gx_color_value max_rgb;\n\n gx_color_value dither_gray;\n gx_color_value dither_rgb;\n\n} gx_device_color_info;\ntypedef struct gx_device_procs_s gx_device_procs;\nstruct gx_device_s {\n int params_size; gx_device_procs *procs; const char *dname; int width; int height; float x_pixels_per_inch; float y_pixels_per_inch; float l_margin, b_margin, r_margin, t_margin; gx_device_color_info color_info; int is_open;\n};\ntypedef struct gs_prop_item_s gs_prop_item;\nstruct gx_device_procs_s {\n int (*open_device)(gx_device *dev );\n void (*get_initial_matrix)(gx_device *dev, gs_matrix *pmat );\n int (*sync_output)(gx_device *dev );\n int (*output_page)(gx_device *dev, int num_copies, int flush );\n int (*close_device)(gx_device *dev );\n gx_color_index (*map_rgb_color)(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );\n int (*map_color_rgb)(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );\n int (*fill_rectangle)(gx_device *dev, int x, int y, int width, int height, gx_color_index color );\n int (*tile_rectangle)(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );\n int (*copy_mono)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1 );\n int (*copy_color)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );\n int (*draw_line)(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );\n int (*get_bits)(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );\n int (*get_props)(gx_device *dev, gs_prop_item *plist );\n\n int (*put_props)(gx_device *dev, gs_prop_item *plist, int count );\n\n};\nextern unsigned int gx_device_bytes_per_scan_line(gx_device *dev, int pad_to_word );\nint gx_default_open_device(gx_device *dev );\nvoid gx_default_get_initial_matrix(gx_device *dev, gs_matrix *pmat );\nint gx_default_sync_output(gx_device *dev );\nint gx_default_output_page(gx_device *dev, int num_copies, int flush );\nint gx_default_close_device(gx_device *dev );\ngx_color_index gx_default_map_rgb_color(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );\nint gx_default_map_color_rgb(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );\nint gx_default_tile_rectangle(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );\nint gx_default_copy_color(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );\nint gx_default_draw_line(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );\nint gx_default_get_bits(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );\nint gx_default_get_props(gx_device *dev, gs_prop_item *plist );\nint gx_default_put_props(gx_device *dev, gs_prop_item *plist, int count );\ntypedef struct device_s {\n gx_device *info;\n int is_band_device;\n gx_color_index white, black;\n} device;\nint gs_initmatrix(gs_state * ),\n gs_defaultmatrix(const gs_state *, gs_matrix * ),\n gs_currentmatrix(const gs_state *, gs_matrix * ),\n gs_setmatrix(gs_state *, const gs_matrix * ),\n gs_translate(gs_state *, floatp, floatp ),\n gs_scale(gs_state *, floatp, floatp ),\n gs_rotate(gs_state *, floatp ),\n gs_concat(gs_state *, const gs_matrix * );\nint gs_transform(gs_state *, floatp, floatp, gs_point * ),\n gs_dtransform(gs_state *, floatp, floatp, gs_point * ),\n gs_itransform(gs_state *, floatp, floatp, gs_point * ),\n gs_idtransform(gs_state *, floatp, floatp, gs_point * );\nstatic int\nctm_set_inverse(gs_state *pgs)\n{ int code = gs_matrix_invert(&*(gs_matrix *)&(pgs)->ctm , &pgs->ctm_inverse);\n 0;\n if ( code < 0 ) return code;\n pgs->inverse_valid = 1;\n return 0;\n}\nvoid\ngs_update_matrix_fixed(gs_matrix_fixed *pmat)\n{ (*pmat). tx = ((float)(((*pmat). tx_fixed = ((fixed)(((*pmat). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (*pmat). ty = ((float)(((*pmat). ty_fixed = ((fixed)(((*pmat). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) )));\n}\nint\ngs_initmatrix(gs_state *pgs)\n{ gx_device *dev = pgs->device->info;\n (*dev->procs->get_initial_matrix)(dev, &*(gs_matrix *)&(pgs)->ctm );\n (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return 0;\n}\nint\ngs_defaultmatrix(const gs_state *pgs, gs_matrix *pmat)\n{ gx_device *dev = pgs->device->info;\n (*dev->procs->get_initial_matrix)(dev, pmat);\n return 0;\n}\nint\ngs_currentmatrix(const gs_state *pgs, gs_matrix *pmat)\n{ *pmat = *(gs_matrix *)&(pgs)->ctm;\n return 0;\n}\nint\ngs_setmatrix(gs_state *pgs, const gs_matrix *pmat)\n{ *(gs_matrix *)&(pgs)->ctm = *pmat;\n (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return 0;\n}\nint\ngs_translate(gs_state *pgs, floatp dx, floatp dy)\n{ gs_point pt;\n int code;\n if ( (code = gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , &pt)) < 0 )\n return code;\n pgs->ctm.tx += pt.x;\n pgs->ctm.ty += pt.y;\n (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return 0;\n}\nint\ngs_scale(gs_state *pgs, floatp sx, floatp sy)\n{ pgs->ctm.xx *= sx;\n pgs->ctm.xy *= sx;\n pgs->ctm.yx *= sy;\n pgs->ctm.yy *= sy;\n pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return 0;\n}\nint\ngs_rotate(gs_state *pgs, floatp ang)\n{ int code = gs_matrix_rotate(&*(gs_matrix *)&(pgs)->ctm , ang, &*(gs_matrix *)&(pgs)->ctm );\n pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return code;\n}\nint\ngs_concat(gs_state *pgs, const gs_matrix *pmat)\n{ int code = gs_matrix_multiply(pmat, &*(gs_matrix *)&(pgs)->ctm , &*(gs_matrix *)&(pgs)->ctm );\n (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;\n return code;\n}\nint\ngs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)\n{ return gs_point_transform(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);\n}\nint\ngs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)\n{ return gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , pt);\n}\nint\ngs_itransform(gs_state *pgs, floatp x, floatp y, gs_point *pt)\n{\n\n if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )\n { return gs_point_transform_inverse(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);\n }\n else\n { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };\n return gs_point_transform(x, y, &pgs->ctm_inverse, pt);\n }\n}\nint\ngs_idtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)\n{\n\n if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )\n { return gs_distance_transform_inverse(dx, dy,\n &*(gs_matrix *)&(pgs)->ctm , pt);\n }\n else\n { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };\n return gs_distance_transform(dx, dy, &pgs->ctm_inverse, pt);\n }\n}\nint\ngs_translate_to_fixed(register gs_state *pgs, fixed px, fixed py)\n{ pgs->ctm.tx = ((float)((pgs->ctm.tx_fixed = px)*(1.0/(1<<12 ) )));\n pgs->ctm.ty = ((float)((pgs->ctm.ty_fixed = py)*(1.0/(1<<12 ) )));\n pgs->inverse_valid = 0;\n pgs->char_tm_valid = 1;\n return 0;\n}\nint\ngx_matrix_to_fixed_coeff(const gs_matrix *pmat, register fixed_coeff *pfc,\n int max_bits)\n{ gs_matrix ctm;\n int scale = -10000;\n int expt, shift;\n ctm = *pmat;\n pfc->skewed = 0;\n if ( !((*(long *)(&(ctm.xx)) << 1) == 0) )\n { (void)frexp(ctm.xx, &scale);\n }\n if ( !((*(long *)(&(ctm.xy)) << 1) == 0) )\n { (void)frexp(ctm.xy, &expt);\n if ( expt > scale ) scale = expt;\n pfc->skewed = 1;\n }\n if ( !((*(long *)(&(ctm.yx)) << 1) == 0) )\n { (void)frexp(ctm.yx, &expt);\n if ( expt > scale ) scale = expt;\n pfc->skewed = 1;\n }\n if ( !((*(long *)(&(ctm.yy)) << 1) == 0) )\n { (void)frexp(ctm.yy, &expt);\n if ( expt > scale ) scale = expt;\n }\n scale = sizeof(long) * 8 - 1 - max_bits - scale;\n shift = scale - 12;\n if ( shift > 0 )\n { pfc->shift = shift;\n pfc->round = (fixed)1 << (shift - 1);\n }\n else\n { pfc->shift = 0;\n pfc->round = 0;\n scale -= shift;\n }\n pfc->xx = (((*(long *)(&(ctm.xx)) << 1) == 0) ? 0 : (long)ldexp(ctm.xx, scale));\n pfc->yy = (((*(long *)(&(ctm.yy)) << 1) == 0) ? 0 : (long)ldexp(ctm.yy, scale));\n if ( pfc->skewed )\n { pfc->xy = (((*(long *)(&(ctm.xy)) << 1) == 0) ? 0 : (long)ldexp(ctm.xy, scale));\n pfc->yx = (((*(long *)(&(ctm.yx)) << 1) == 0) ? 0 : (long)ldexp(ctm.yx, scale));\n }\n else\n pfc->xy = pfc->yx = 0;\n pfc->max_bits = max_bits;\n return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-3.c",
    "content": "/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nx(a){static void*j[]={&&l1,&&l2};goto*j[a];l1:return 0;l2:return 1;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-4.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nx(a){struct{int p[a],i;}l;l.i;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-5.c",
    "content": "typedef struct{unsigned b0:1;}*t;x(a,b)t a,b;{b->b0=a->b0;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-6.c",
    "content": "typedef struct x\n{\n  struct x *type;\n  struct x *chain;\n  struct x *value;\n} *tree;\n\nint\nfunc (new, old)\n     register tree new, old;\n{\n  if (old->type == 0 || new->type == 0)\n    {\n      register tree t = old->type;\n      if (t == 0)\n\tt = new->type;\n      for (; t; t = t->chain )\n\tif (t->value)\n\t  return 1;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920428-7.c",
    "content": "x(float*x){int a[4],i=0,j;for(j=0;j<2;j++){f(a[i++]);f(a[i++]);}}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-1.c",
    "content": "#ifndef NO_LABEL_VALUES\na(){int**b[]={&&c};c:;}\n#else\nint x;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-10.c",
    "content": "x(y){return 8193*y;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-11.c",
    "content": "typedef struct{int s;}S;foo(){int i=(int)&(S){(void*)((int)&(S){1})};}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-12.c",
    "content": "/* { dg-do assemble } */\n\nx(x){            return 3 + x;}\na(x){int y[994]; return 3 + x;}\nb(x){int y[999]; return 2*(x + 3);}\nA(x){int y[9999];return 2*(x + 3);}\nB(x){int y[9949];return 3 + x;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-13.c",
    "content": "typedef struct{int i;}t;inline y(t u){}x(){t u;y(u);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-15.c",
    "content": "x(a)double a;{int i;return i>a?i:i+1;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-16.c",
    "content": "f(n){struct z{int a,b[n],c[n];};}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-17.c",
    "content": "x(){static const char x[]=\"x\";char y[2];y[0]=x[1];}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-18.c",
    "content": "union u{int i;float f;};\nx(p)int p;{union u x;for(x.i=0;x.i<p;x.i++)if(x.f>(float)3.0)break;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-19.c",
    "content": "long long x=0;y(){x=0;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-2.c",
    "content": "extern short distdata[64][64], taxidata[64][64];\nextern short PieceList[2][64];\n\nint\nScoreKBNK (short int winner, short int king1, short int king2)\n{\n  register short s;\n\n  s = taxidata[king1][king2] + distdata[PieceList[winner][1]][king2];\n  return s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-20.c",
    "content": "int*f(x)int*x;{if(x[4]){int h[1];if(setjmp(h))return x;}}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-21.c",
    "content": "typedef unsigned short t;\nstruct foo{t d;};\nint bar(d)t d;{struct foo u;u.d=d;return(int)(&u);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-22.c",
    "content": "x(){int y[]={};}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-23.c",
    "content": "typedef unsigned char qi;\ntypedef unsigned short hi;\ntypedef unsigned long si;\ntypedef unsigned long long di;\nsubi(a){return 100-a;}\nadd(a,b){return a+b;}\nmul(a){return 85*a;}\nmemshift(p)unsigned*p;{unsigned x;for(;;){x=*p++>>16;if(x)return x;}}\nldw(xp)si*xp;{return xp[4];}\nldws_m(xp)si*xp;{si x;do{x=xp[3];xp+=3;}while(x);}\npostinc_si(p)si*p;{si x;for(;;){x=*p++;if(x)return x;}}\npreinc_si(p)si*p;{si x;for(;;){x=*++p;if(x)return x;}}\npostinc_di(p)di*p;{di x;for(;;){x=*p++;if(x)return x;}}\npreinc_di(p)di*p;{di x;for(;;){x=*++p;if(x)return x;}}\ninc_overlap(p,a)di*p;{do{p=*(di**)p;p=(di*)((int)p+4);}while(*p);}\ndi move_di(p,p2)di*p,*p2;{di x=p;p2=((di*)x)[1];return p2[1];}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-3.c",
    "content": "struct{long long x:24,y:40;}v;\nx(){v.y=0;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-4.c",
    "content": "/* { dg-do assemble } */\n/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\n\nfoo ()\n{\n  int r0[8186 ];\n  int r1[2 ];\n  int r2[2 ];\n  int bitm0[2 ];\n  int bitm1[2 ];\n  int bitm2[2 ];\n\n  int i,j,k,m,n,m_max;\n  int f;\n  double fm,ft;\n\n  while (1) {\n\n    if (m%4 == 2)\n      ++m;\n\n    if (m_max != 0 && m > m_max)\n      break;\n\n    fm=m;\n\n    r0[k=1]=0;\n    bitm0[0] = 0;\n\n      while ( n%f == 0 ) {\n\twhile ( (ft != 0) && (ft < fm )) {\n\t  bitm1[i] = 0;\n\t  r1[i]=0;\n          }\n\n\twhile ( r0[i] != 0 && r1[i] != 0 ) {\n\t  if ( r0[i] < r1[i] ) {\n\t    bitm2[k] = bitm0[i];\n\t    r2[k++]=0;\n\t  }\n\t  else if ( r0[i] > r1[j] ) {\n\t    bitm2[k] = bitm1[j];\n\t    r2[k++]=r1[j++];\n\t  }\n\t  else {\n\t    bitm1[k] = bitm0[i];\n\t    r2[k++]=r0[i++];\n\t  }\n\t}\n      }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-6.c",
    "content": "x(y,z)float*y;{*y=z;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-7.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nx(){if(&&e-&&b<0)x();b:goto*&&b;e:;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-8.c",
    "content": "x(int*p){int x=p;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920501-9.c",
    "content": "short x(a)unsigned a;{a=32987799;return a;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920502-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nextern void*t[];x(i){goto*t[i];}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920502-2.c",
    "content": "x(c){1LL<<c;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920520-1.c",
    "content": "/* { dg-do compile } */\n/* { dg-skip-if \"\" { pdp11-*-* } { \"*\" } { \"\" } } */\n\nf(){asm(\"%0\"::\"r\"(1.5F));}g(){asm(\"%0\"::\"r\"(1.5));}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920521-1.c",
    "content": "/* { dg-do compile } */\n\nf(){asm(\"f\":::\"cc\");}g(x,y){asm(\"g\"::\"%r\"(x), \"r\"(y));}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920529-1.c",
    "content": "void\nf (a, b, m, n)\n     unsigned short *a, *b;\n     int m, n;\n{\n  unsigned long acc;\n  int qn;\n  int j;\n\n  abort ();\n\n  acc = a[m - 1];\n  a += 0;\n  for (j = qn - 1; j >= 0; j = j - 1)\n    {\n      acc = (acc << 16) | a[j];\n      acc = acc % *b;\n    }\n\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920608-1.c",
    "content": "foo (p)\n     int *p;\n{\n  int x;\n  int a;\n\n  a = p[0];\n  x = a + 5;\n  a = -1;\n  p[0] = x - 5;\n  return a;\n}\n\nbar (p)\n{\n  short x;\n  int a;\n\n  x = ((short *) p)[1];\n#if INHIBIT_COMBINE\n  ((short *) p)[0] = x;\n#endif\n\n  return (x < 45);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920611-2.c",
    "content": "typedef unsigned char uchar;\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\nstatic unsigned long S[1][1]={0x00820200};\n\nstatic int body(out0,out1,ks,Eswap0,Eswap1)\nulong *out0,*out1;\nint *ks;\nulong Eswap0,Eswap1;\n{\n  register unsigned long l,r,t,u,v;\n  register unsigned long *s;\n  register int i,j;\n  register unsigned long E0,E1;\n\n  l=0;\n  r=0;\n\n  s=(ulong *)ks;\n  E0=Eswap0;\n  E1=Eswap1;\n\n  for (i=0; i<(16 *2); i+=4)\n    {\n      v=(r^(r>>16));\n      u=(v&E0);\n      v=(v&E1);\n      u=(u^(u<<16))^r^s[  i  ];\n      t=(v^(v<<16))^r^s[  i+1];\n      t=(t>>4)|(t<<28);\n      l^=S[1][(t)&0x3f]| S[3][(t>> 8)&0x3f]| S[5][(t>>16)&0x3f]| S[7][(t>>24)&0x3f]| S[0][(u)&0x3f]| S[2][(u>> 8)&0x3f]| S[4][(u>>16)&0x3f]| S[6][(u>>24)&0x3f];\n      v=(l^(l>>16));\n      u=(v&E0);\n      v=(v&E1);\n      u=(u^(u<<16))^l^s[  i+2  ];\n      t=(v^(v<<16))^l^s[  i+2+1];\n      t=(t>>4)|(t<<28);\n      r^=\tS[1][(t    )&0x3f];\n    }\n  t=l;\n  l=r;\n  r=t;\n\n  t=r;\n  r=(l>>1)|(l<<31);\n  l=(t>>1)|(t<<31);\n\n  *out0=l;\n  *out1=r;\n  return(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920615-1.c",
    "content": "f()\n{\n  int x[20] = {[0] = 5, [10] = 12};\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920617-1.c",
    "content": "f(){double*xp,y;*xp++=sqrt(y);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920617-2.c",
    "content": "f(a,b,c,d)float a[],d;int b[],c;{}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920623-1.c",
    "content": "int f(int c){return f(c--);}\ng(){}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920624-1.c",
    "content": "int B[],Q[];\nf(){int s;for(s=0;s<=1;s++)switch(s){case 2:case 3:++B[s];case 4:case 5:++Q[s];}}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920625-1.c",
    "content": "typedef unsigned long int unsigned_word;\ntypedef signed long int signed_word;\ntypedef unsigned_word word;\n\ntypedef enum { ADD, ADD_CI, ADD_CO, ADD_CIO, SUB, SUB_CI, SUB_CO,\nSUB_CIO, ADC_CI, ADC_CO, ADC_CIO, AND, IOR, XOR, ANDC, IORC, EQV,\nNAND, NOR, AND_RC, IOR_RC, XOR_RC, ANDC_RC, IORC_RC, EQV_RC, NAND_RC,\nNOR_RC, AND_CC, IOR_CC, XOR_CC, ANDC_CC, IORC_CC, EQV_CC, NAND_CC,\nNOR_CC, LSHIFTR, ASHIFTR, SHIFTL, LSHIFTR_CO, ASHIFTR_CO, SHIFTL_CO,\nROTATEL, ROTATEL_CO, ROTATEXL_CIO, ASHIFTR_CON, EXTS1, EXTS2, EXTU1,\nEXTU2, CLZ, CTZ, FF1, FF0, ABSVAL, NABSVAL, CMP, CPEQ, CPGE, CPGEU,\nCPGT, CPGTU, CPLE, CPLEU, CPLT, CPLTU, CPNEQ, CMPPAR, DOZ, COPY,\nEXCHANGE, COMCY, } opcode_t;\n\ntypedef struct\n{\n  opcode_t opcode:8;\n  unsigned int s1:8;\n  unsigned int s2:8;\n  unsigned int d:8;\n} insn_t;\n\nenum prune_flags\n{\n  NO_PRUNE = 0,\n  CY_0 = 1,\n  CY_1 = 2,\n  CY_JUST_SET = 4,\n};\n\nint flag_use_carry = 1;\n\ninline\nrecurse(opcode_t opcode,\n int d,\n int s1,\n int s2,\n word v,\n int cost,\n insn_t *sequence,\n int n_insns,\n word *values,\n int n_values,\n const word goal_value,\n int allowed_cost,\n int cy,\n int prune_flags)\n{\n  insn_t insn;\n\n  allowed_cost -= cost;\n\n  if (allowed_cost > 0)\n    {\n      word old_d;\n\n      old_d = values[d];\n      values[d] = v;\n\n      insn.opcode = opcode;\n      insn.s1 = s1;\n      insn.s2 = s2;\n      insn.d = d;\n      sequence[n_insns] = insn;\n\n      synth(sequence, n_insns + 1, values, n_values,\n     goal_value, allowed_cost, cy, prune_flags);\n\n      values[d] = old_d;\n    }\n  else if (goal_value == v)\n    {\n      insn.opcode = opcode;\n      insn.s1 = s1;\n      insn.s2 = s2;\n      insn.d = d;\n      sequence[n_insns] = insn;\n      test_sequence(sequence, n_insns + 1);\n    }\n}\n\nsynth(insn_t *sequence,\n      int n_insns,\n      word *values,\n      int n_values,\n      word goal_value,\n      int allowed_cost,\n      int ci,\n      int prune_hint)\n{\n  int s1, s2;\n  word v, r1, r2;\n  int co;\n  int last_dest;\n\n  if (n_insns > 0)\n    last_dest = sequence[n_insns - 1].d;\n  else\n    last_dest = -1;\n  if (ci >= 0 && flag_use_carry)\n    {\n      for (s1 = n_values - 1; s1 >= 0; s1--)\n {\n   r1 = values[s1];\n   for (s2 = s1 - 1; s2 >= 0; s2--)\n     {\n       r2 = values[s2];\n\n       if (allowed_cost <= 1 && (prune_hint & CY_JUST_SET) == 0)\n  {\n    if (last_dest >= 0 && s1 != last_dest && s2 != last_dest)\n      continue;\n  }\n       do { word __d = ( r1) + ( r2) + (( ci)); ( co) = ( ci) ? __d <= ( r1) : __d < ( r1); (v) = __d; } while (0);\n       recurse(ADD_CIO, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n       do { word __d = ( r1) + ( r2) + (( ci)); ( co) = ( ci); (v) = __d; } while (0);\n       recurse(ADD_CI, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n       do { word __d = ( r1) - ( r2) - (( ci)); ( co) = ( ci) ? __d >= ( r1) : __d > ( r1); (v) = __d; } while (0);\n       recurse(SUB_CIO, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n       do { word __d = ( r2) - ( r1) - (( ci)); ( co) = ( ci) ? __d >= ( r2) : __d > ( r2); (v) = __d; } while (0);\n       recurse(SUB_CIO, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n       do { word __d = ( r1) - ( r2) - (( ci)); ( co) = ( ci); (v) = __d; } while (0);\n       recurse(SUB_CI, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n       do { word __d = ( r2) - ( r1) - (( ci)); ( co) = ( ci); (v) = __d; } while (0);\n       recurse(SUB_CI, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n     }\n }\n    }\n  for (s1 = n_values - 1; s1 >= 0; s1--)\n    {\n      r1 = values[s1];\n      for (s2 = s1 - 1; s2 >= 0; s2--)\n {\n   r2 = values[s2];\n\n   if (allowed_cost <= 1)\n     {\n       if (last_dest >= 0 && s1 != last_dest && s2 != last_dest)\n  continue;\n     }\n\n   do { word __d = ( r1) + ( r2); ( co) = __d < ( r1); (v) = __d; } while (0);\n   recurse(ADD_CO, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n   ((v) = ( r1) + ( r2), ( co) = ( ci));\n   recurse(ADD, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   do { word __d = ( r1) - ( r2); ( co) = __d > ( r1); (v) = __d; } while (0);\n   recurse(SUB_CO, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n   do { word __d = ( r2) - ( r1); ( co) = __d > ( r2); (v) = __d; } while (0);\n   recurse(SUB_CO, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n   ((v) = ( r1) - ( r2), ( co) = ( ci));\n   recurse(SUB, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n   ((v) = ( r2) - ( r1), ( co) = ( ci));\n   recurse(SUB, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   ((v) = ( r1) & ( r2), ( co) = ( ci));\n   recurse(AND, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   ((v) = ( r1) | ( r2), ( co) = ( ci));\n   recurse(IOR, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   ((v) = ( r1) ^ ( r2), ( co) = ( ci));\n   recurse(XOR, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   ((v) = ( r1) & ~( r2), ( co) = ( ci));\n   recurse(ANDC, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n   ((v) = ( r2) & ~( r1), ( co) = ( ci));\n   recurse(ANDC, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n   ((v) = ( r1) | ~( r2), ( co) = ( ci));\n   recurse(IORC, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n   ((v) = ( r2) | ~( r1), ( co) = ( ci));\n   recurse(IORC, n_values,  s2,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n   ((v) = ( r1) ^ ~( r2), ( co) = ( ci));\n   recurse(EQV, n_values,  s1,  s2, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n }\n    }\n  if (ci >= 0 && flag_use_carry)\n    {\n      for (s1 = n_values - 1; s1 >= 0; s1--)\n {\n   r1 = values[s1];\n\n   if (allowed_cost <= 1 && (prune_hint & CY_JUST_SET) == 0)\n     {\n\n       if (last_dest >= 0 && s1 != last_dest)\n  continue;\n     }\n\n   do { word __d = ( r1) + ( r1) + (( ci)); ( co) = ( ci) ? __d <= ( r1) : __d < ( r1); (v) = __d; } while (0);\n   recurse(ADD_CIO, n_values,  s1,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n   do { word __d = ( r1) + ( r1) + (( ci)); ( co) = ( ci); (v) = __d; } while (0);\n   recurse(ADD_CI, n_values,  s1,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n   do { word __d = ( r1) + ( -1 ) + (( ci)); ( co) = ( ci) ? __d <= ( r1) : __d < ( r1); (v) = __d; } while (0);\n   recurse(ADD_CIO, n_values,  s1,  (0x20 + -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n   do { word __d = ( r1) + ( 0 ) + (( ci)); ( co) = ( ci) ? __d <= ( r1) : __d < ( r1); (v) = __d; } while (0);\n   recurse(ADD_CIO, n_values,  s1,  (0x20 + 0) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n   do { word __d = ( 0 ) - ( r1) - (( ci)); ( co) = ( ci) ? __d >= ( 0 ) : __d > ( 0 ); (v) = __d; } while (0);\n   recurse(SUB_CIO, n_values,  (0x20 + 0) ,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n }\n    }\n  for (s1 = n_values - 1; s1 >= 0; s1--)\n    {\n      r1 = values[s1];\n\n      if (allowed_cost <= 1)\n {\n   if (last_dest >= 0 && s1 != last_dest)\n     continue;\n }\n      do { word __d = ( r1) + ( r1); ( co) = __d < ( r1); (v) = __d; } while (0);\n      recurse(ADD_CO, n_values,  s1,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n\n      ((v) = ( r1) & ( 1 ), ( co) = ( ci));\n      recurse(AND, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n      ((v) = ( r1) ^ ( 1 ), ( co) = ( ci));\n      recurse(XOR, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n      ((v) = ( -1 ) - ( r1), ( co) = ( ci));\n      recurse(SUB, n_values,  (0x20 + -1) ,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      do { word __d = ( r1) + ( 1 ); ( co) = __d < ( r1); (v) = __d; } while (0);\n      recurse(ADD_CO, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n      ((v) = ( r1) + ( 1 ), ( co) = ( ci));\n      recurse(ADD, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      do { word __d = ( r1) + ( -1 ); ( co) = __d < ( r1); (v) = __d; } while (0);\n      recurse(ADD_CO, n_values,  s1,  (0x20 + -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n      do { word __d = ( r1) - ( 1 ); ( co) = __d > ( r1); (v) = __d; } while (0);\n      recurse(SUB_CO, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n      do { word __d = ( 0 ) - ( r1); ( co) = __d > ( 0 ); (v) = __d; } while (0);\n      recurse(SUB_CO, n_values,  (0x20 + 0) ,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET);\n      ((v) = ( 0 ) - ( r1), ( co) = ( ci));\n      recurse(SUB, n_values,  (0x20 + 0) ,  s1, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      ((v) = ((unsigned_word) ( r1) >> (( 1 ) & (32  - 1)) ), ( co) = ( ci));\n      recurse(LSHIFTR, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      ((v) = ((signed_word) ( r1) >> (( 1 ) & (32  - 1)) ), ( co) = ( ci));\n      recurse(ASHIFTR, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      ((v) = ((signed_word) ( r1) << (( 1 ) & (32  - 1)) ), ( co) = ( ci));\n      recurse(SHIFTL, n_values,  s1,  (0x20 + 1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      ((v) = ((unsigned_word) ( r1) >> (( 32 -1 ) & (32  - 1)) ), ( co) = ( ci));\n      recurse(LSHIFTR, n_values,  s1,  (0x20 + 32 -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      ((v) = ((signed_word) ( r1) >> (( 32 -1 ) & (32  - 1)) ), ( co) = ( ci));\n      recurse(ASHIFTR, n_values,  s1,  (0x20 + 32 -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n    }\n  if (ci >= 0 && flag_use_carry\n      && (allowed_cost <= 1 ? ((prune_hint & CY_JUST_SET) != 0) : 1))\n    {\n      do { word __d = ( 0 ) + ( 0 ) + (( ci)); ( co) = ( ci) ? __d <= ( 0 ) : __d < ( 0 ); (v) = __d; } while (0);\n      recurse(ADD_CIO, n_values,  (0x20 + 0) ,  (0x20 + 0) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET | CY_0);\n      do { word __d = ( 0 ) - ( 0 ) - (( ci)); ( co) = ( ci) ? __d >= ( 0 ) : __d > ( 0 ); (v) = __d; } while (0);\n      recurse(SUB_CIO, n_values,  (0x20 + 0) ,  (0x20 + 0) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n      do { word __d = ( 0 ) - ( -1 ) - (( ci)); ( co) = ( ci) ? __d >= ( 0 ) : __d > ( 0 ); (v) = __d; } while (0);\n      recurse(SUB_CIO, n_values,  (0x20 + 0) ,  (0x20 + -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  CY_JUST_SET | CY_1);\n      do { word __d = ( 0 ) + ( -1 ) + (( ci)); ( co) = ( ci) ? __d <= ( 0 ) : __d < ( 0 ); (v) = __d; } while (0);\n      recurse(ADD_CIO, n_values,  (0x20 + 0) ,  (0x20 + -1) , v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n    }\n\n  if (allowed_cost > 1)\n    {\n      ((v) = ( 0x80000000 ), ( co) = ( ci));\n      recurse(COPY, n_values,  (0x20 - 2) ,  0, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n      ((v) = ( -1 ), ( co) = ( ci));\n      recurse(COPY, n_values,  (0x20 + -1) ,  0, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n\n      ((v) = ( 1 ), ( co) = ( ci));\n      recurse(COPY, n_values,  (0x20 + 1) ,  0, v, 1, sequence, n_insns, values, n_values + 1, goal_value, allowed_cost, co,  prune_hint & ~CY_JUST_SET);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920625-2.c",
    "content": "typedef\tchar *\tcaddr_t;\ntypedef unsigned Cursor;\ntypedef char *String;\ntypedef struct _WidgetRec *Widget;\ntypedef char\t\tBoolean;\ntypedef unsigned int\tCardinal;\ntypedef struct _XedwListReturnStruct {\n  String   string;\n  int      xedwList_index;\n  struct _XedwListReturnStruct *next;\n} XedwListReturnStruct;\nstatic XedwListReturnStruct *return_list;\nstatic String   srcdir, dstdir;\nchar *strcpy();\n  extern void setCursor(Cursor);\n  extern void query_dialog(String, Boolean);\n  extern Boolean directoryManagerNewDirectory(String);\ntrashQueryResult(Widget w, Boolean delete, caddr_t call_data)\n{\n  int  execute(String, String, String, Boolean);\n  extern void destroy_button_dialog(void);\n  extern void changestate(Boolean);\n\n  extern Cursor busy, left_ptr;\n  extern String cwd;\n      \textern void freeReturnStruct(void);\n  String rmstring;\n  int status;\n  XedwListReturnStruct *tmp;\n  setCursor(busy);\n  destroy_button_dialog();\n  if (delete == 1) {\n    rmstring = ((\"rm -fr\") != ((void *)0) ? (strcpy((char*)XtMalloc((unsigned)strlen(\"rm -fr\") + 1), \"rm -fr\")) : ((void *)0));\n    tmp = return_list;\n    while (tmp != ((void *)0)) {\n      rmstring = (String) XtRealloc (rmstring, sizeof(char) *\n\t\t\t\t     (strlen(rmstring) +\n\t\t\t\t      strlen(tmp->string) + 5));\n      sprintf(rmstring, \"%s '%s'\", rmstring, tmp->string);\n      tmp = tmp->next;\n    }\n    if ((status = execute(((void *)0), \"rm\", rmstring, 1)) != 0) {\n      XBell(XtDisplay(w), 100);\n      query_dialog(\"Can't remove file\", 0);\n    }\n    XtFree(rmstring);\n\n    directoryManagerNewDirectory(cwd);\n  } else {\n    changestate(1);\n  }\n  setCursor(left_ptr);\n  freeReturnStruct();\n}\n\ncopyQueryResult(Widget w, Boolean copy, caddr_t call_data)\n{\n  extern void destroy_button_dialog();\n  extern void changestate(Boolean);\n  extern Cursor busy, left_ptr;\n  extern void freeReturnStruct(void);\n  int execute(String, String, String, Boolean);\n  extern String cwd;\n  String copystring;\n  int status;\n  Cardinal srclen, dstlen;\n  XedwListReturnStruct *tmp;\n  destroy_button_dialog();\n  setCursor(busy);\n  if (copy == 1) {\n    srclen = strlen(srcdir);\n    dstlen = strlen(dstdir);\n    copystring = ((\"cp -r\") != ((void *)0) ? (strcpy((char*)XtMalloc((unsigned)strlen(\"cp -r\") + 1), \"cp -r\")) : ((void *)0));\n    tmp = return_list;\n    while (tmp != ((void *)0)) {\n      copystring = (String) XtRealloc (copystring, sizeof(char) *\n\t\t\t\t       (strlen(copystring) +\n\t\t\t\t\tstrlen(tmp->string) +\n\t\t\t\t\tsrclen + 6));\n      sprintf(copystring, \"%s '%s/%s'\", copystring, srcdir, tmp->string);\n      tmp = tmp->next;\n    }\n    copystring = (String) XtRealloc (copystring, sizeof(char) *\n\t\t\t\t     (strlen(copystring) +\n\t\t\t\t      dstlen + 5));\n    sprintf(copystring, \"%s '%s'\", copystring, dstdir);\n    if ((status = execute(((void *)0), \"cp\", copystring, 1)) != 0) {\n      XBell(XtDisplay(w), 100);\n      query_dialog(\"Can't copy file!\", 0);\n    }\n    XtFree(copystring);\n\n    directoryManagerNewDirectory(cwd);\n  } else {\n    changestate(1);\n  }\n  XtFree(srcdir);\n  XtFree(dstdir);\n  setCursor(left_ptr);\n  freeReturnStruct();\n}\n\nvoid freeReturnStruct(){}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920626-1.c",
    "content": "f(x)unsigned x;{return x>>-5;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920701-1.c",
    "content": "f(char*c){extern char a[],b[];return a+(b-c);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920702-1.c",
    "content": "int somevar;\nvoid\nyylex ()\n{\n  register int result = 0;\n  int num_bits = -1;\n\n  if (((result >> -1) & 1))\n    somevar = 99;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920706-1.c",
    "content": "f(){float i[2],o[1];g(o);return*o;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920710-2.c",
    "content": "union u\n{\n  struct {unsigned h, l;} i;\n  double d;\n};\n\nfoo (union u x)\n{\n  while (x.i.h++)\n    {\n      while (x.i.l-- > 0)\n\t;\n      while (x.d++ > 0)\n\t;\n    }\n}\n\nunion n\n{\n  long long unsigned i;\n  double d;\n};\n\nbar (union n x)\n{\n  int i;\n  for (i = 0; i < 100; i++)\n    {\n      while (--x.i > 0)\n\t;\n      while (++x.d > 0)\n\t;\n    }\n  return x.i;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920711-1.c",
    "content": "f(a){a=(1,1)/2;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920721-1.c",
    "content": "typedef struct{short ttype;float s;}T;\nshort t[8][8];\n\nT f(T t2,T t1)\n{\n  T x;\n  if (t1.ttype == 1)\n    x.ttype = t[t2.ttype][t1.ttype],\n    x.s = 1;\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920723-1.c",
    "content": "\n#if defined(STACK_SIZE) && STACK_SIZE < 65536\n# define GITT_SIZE 75\n#endif\n\n#ifndef GITT_SIZE\n# define GITT_SIZE 150\n#endif\n\ntypedef struct {\n  double x, y;\n} vector_t;\ndouble sqrt();\nf(int count,vector_t*pos,double r,double *rho)\n{\n  int i, j, miny, maxy, hy;\n  float help, d;\n  int gitt[GITT_SIZE][GITT_SIZE];\n  int *data = (int *)malloc(count*sizeof(int));\n  for (i = 0; i < count; i++)\n    rho[i] = 0;\n  for (i = 1; i < count; i++)\n    for (hy = miny; hy<= maxy; hy++)\n      while(j >=0) {\n\td = pos[i].y - pos[j].y;\n\tif ( d <= r) {\n\t  d = sqrt(d);\n\t  rho[i] += help;\n\t}\n      }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920729-1.c",
    "content": "extern volatile int i;\nf(){int j;for(;;)j = i;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920806-1.c",
    "content": "f(){short x=32000;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920808-1.c",
    "content": "f(i){for(i=1;i<=2;({;}),i++){({;}),g();}}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920809-1.c",
    "content": "f(x,y){memcpy (&x,&y,8192);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920817-1.c",
    "content": "int v;static inline f(){return 0;}g(){return f();}void h(){return v++;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920820-1.c",
    "content": "long long f(double y){return y;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920821-1.c",
    "content": "/* empty */\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920821-2.c",
    "content": "typedef struct{int p[25];}t1;\nstruct{t1 x,y;}y;\nt1 x[1];\nf(){y.x=*x;y.y=*x;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920825-1.c",
    "content": "#pragma pack(1)\nstruct{unsigned short f1:5;unsigned short f2:6;}x;\nf(){x.f2=1;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920825-2.c",
    "content": "f(double*a,int m){int j;for(j=0;j<m;j++)a[j]=1;}\ng(double*a){int j;for(j=0;j<4;j++)a[j]=1;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920826-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nf(int*x){goto*(char)*x;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920828-1.c",
    "content": "char a[]={4,5};f(n){return a[n<2?n:0];}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920829-1.c",
    "content": "f(double x){double y;y=x/0.5;if(y<0.1)y=1.0;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920831-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nf(x){goto*(char)x;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920902-1.c",
    "content": "void f(int);\nvoid f(x)unsigned char x;{}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920909-1.c",
    "content": "long long f(long long a,long long b){return a<<b;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920917-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\ninline f(x){switch(x){case 6:case 4:case 3:case 1:;}return x;}\ng(){f(sizeof(\"xxxxxx\"));}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-1.c",
    "content": "struct{int c;}v;\nstatic long i=((char*)&(v.c)-(char*)&v);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-2.c",
    "content": "typedef struct{struct{char*d;int b;}*i;}*t;\ndouble f();\ng(p)t p;\n{\n  short x,y,delta,s,w,h,fx,fy,tx,ty;\n  int q1,q2,q3,q4;\n  h=f((ty-fy)/2.0+0.5);\n  s=(((int)((short)(tx-fx))<(int)((short)(ty-fy)))?((short)(tx-fx)):((short)(ty-fy)))%2;\n  delta=(((int)(w)<(int)(h))?(w):(h))-s;\n  for(x=0;x<=delta;x++)\n    for(y=1-s;y<=delta;y++){\n      q1=((int)((*(p->i->d+(fx+w+x)/8+(fy+h+y)*p->i->b)&(1<<((fx+w+x)%8)))?1:0));\n      q2=((int)((*(p->i->d+(fx+w+y)/8+(fy+h-s-x)*p->i->b)&(1<<((fx+w+y)%8)))?1:0));\n      q3=((int)((*(p->i->d+(fx+w-s-x)/8+(fy+h-s-y)*p->i->b)&(1<<((fx+w-s-x)%8)))?1:0));\n      q4=((int)((*(p->i->d+(fx+w-s-y)/8+(fy+h+x)*p->i->b)&(1<<((fx+w-s-y)%8)))?1:0));\n      if(q4!=q1)\n\tff(p,fx+w-s-y,fy+h+x);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-3.c",
    "content": "f (int phaseone)\n{\n  typedef struct\n    {\n      unsigned char *p;\n    }\n  FILE;\n  FILE b[2];\n  static unsigned char xchr[2];\n  int j;\n  int for_end;\n  if (phaseone)\n    {\n      if (j <= for_end)\n\tdo\n\t  *(b[1].p) = xchr[j];\n\twhile (j++ < 10);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-4.c",
    "content": "typedef unsigned char\tunsigned8;\ntypedef unsigned short int\tunsigned16;\ntypedef unsigned long int\tunsigned32;\ntypedef char\tsigned8;\ntypedef short int\tsigned16;\ntypedef long int\tsigned32;\ntypedef unsigned32 boolean32;\ntypedef unsigned long int\terror_status_t;\ntypedef struct {\n\tunsigned32 time_low;\n\tunsigned16 time_mid;\n\tunsigned16 time_hi_and_version;\n\tunsigned8 clock_seq_hi_and_reserved;\n\tunsigned8 clock_seq_low;\n\tunsigned char\tnode[6];\n} uuid_t;\n\ntypedef unsigned32 bitset;\ntypedef signed32 sec_timeval_sec_t;\ntypedef struct {\n\tsigned32 sec;\n\tsigned32 usec;\n} sec_timeval_t;\ntypedef signed32 sec_timeval_period_t;\ntypedef signed32 sec_rgy_acct_key_t;\n\ntypedef struct {\n\tuuid_t source;\n\tsigned32 handle;\n\tboolean32 valid;\n} sec_rgy_cursor_t;\ntypedef unsigned char\tsec_rgy_pname_t[257];\ntypedef unsigned char\tsec_rgy_name_t[1025];\n\ntypedef signed32 sec_rgy_override_t;\ntypedef signed32 sec_rgy_mode_resolve_t;\ntypedef unsigned char\tsec_rgy_unix_gecos_t[292];\ntypedef unsigned char\tsec_rgy_unix_login_name_t[1025];\ntypedef unsigned char\tsec_rgy_member_t[1025];\ntypedef unsigned char\tsec_rgy_unix_passwd_buf_t[16];\ntypedef struct sec_rgy_sid_t {\n\tuuid_t person;\n\tuuid_t group;\n\tuuid_t org;\n} sec_rgy_sid_t;\ntypedef struct {\n\tsigned32 person;\n\tsigned32 group;\n\tsigned32 org;\n} sec_rgy_unix_sid_t;\ntypedef struct {\n\tsec_rgy_unix_login_name_t name;\n\tsec_rgy_unix_passwd_buf_t passwd;\n\tsigned32 uid;\n\tsigned32 gid;\n\tsigned32 oid;\n\tsec_rgy_unix_gecos_t gecos;\n\tsec_rgy_pname_t homedir;\n\tsec_rgy_pname_t shell;\n} sec_rgy_unix_passwd_t;\ntypedef unsigned char\tsec_rgy_member_buf_t[10250];\ntypedef struct {\n\tsec_rgy_name_t name;\n\tsigned32 gid;\n\tsec_rgy_member_buf_t members;\n} sec_rgy_unix_group_t;\n\ntypedef struct {\n\tuuid_t site_id;\n\tsec_timeval_sec_t person_dtm;\n\tsec_timeval_sec_t group_dtm;\n\tsec_timeval_sec_t org_dtm;\n} rs_cache_data_t;\n\ntypedef enum {\n\trs_unix_query_name,\n\trs_unix_query_unix_num,\n\trs_unix_query_none\n} rs_unix_query_t;\n\ntypedef struct {\n\trs_unix_query_t query;\n\tunion {\n\t\tstruct {\n\t\t\tlong int\tname_len;\n\t\t\tsec_rgy_name_t name;\n\t\t} name;\n\t\tlong int\tunix_num;\n\t} tagged_union;\n} rs_unix_query_key_t;\n\nstatic unsigned long int IDL_offset_vec[] =\n{\n    0,\n    sizeof(sec_rgy_unix_group_t),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_unix_group_t *) 0)->name - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_unix_group_t *) 0)->gid - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_unix_group_t *) 0)->members - (unsigned char *) 0),\n    sizeof(rs_cache_data_t),\n    (unsigned long int) ((unsigned char *) &((rs_cache_data_t *) 0)->site_id.time_low - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((rs_cache_data_t *) 0)->site_id.time_mid - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((rs_cache_data_t *) 0)->site_id.time_hi_and_version - (unsigned char *) 0),\n    sizeof(sec_rgy_unix_passwd_t),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_cursor_t *) 0)->source.clock_seq_hi_and_reserved - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_cursor_t *) 0)->source.clock_seq_low - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_cursor_t *) 0)->source.node - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_cursor_t *) 0)->handle - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((sec_rgy_cursor_t *) 0)->valid - (unsigned char *) 0),\n    sizeof(struct {long int name_len; sec_rgy_name_t name;}),\n    (unsigned long int) ((unsigned char *) &((struct {long int name_len; sec_rgy_name_t name;} *)0)->name_len\n\t\t\t - (unsigned char *) 0),\n    (unsigned long int) ((unsigned char *) &((struct {long int name_len; sec_rgy_name_t name;} *)0)->name - (unsigned char *) 0),\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-5.c",
    "content": "/* REPRODUCED:CC1:SIGNAL MACHINE:m68k OPTIONS:-fpcc-struct-return */\nstruct b{};\nf(struct b(*f)())\n{\nstruct b d=f();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/920928-6.c",
    "content": "struct{int c;}v;\nstatic short i=((char*)&(v.c)-(char*)&v);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921004-1.c",
    "content": "/* REPRODUCED:CC1:SIGNAL MACHINE:i386 OPTIONS: */\nlong long f()\n{\nlong long*g,*s;\nreturn*g+*s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921011-1.c",
    "content": "/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\n\nvoid\nfun (nb)\n     int nb;\n{\n  int th, h, em, nlwm, nlwS, nlw, sy;\n\n  while (nb--)\n    while (h--)\n      {\n\tnlw = nlwm;\n\twhile (nlw)\n\t  {\n\t    if (nlwS == 1)\n\t      {\n\t      }\n\t    else\n\t      if (nlwS == 1)\n\t\t{\n\t\t}\n\t    nlwS--; nlw--;\n\t  }\n\tif (em)\n\t  nlwS--;\n\tif (++sy == th)\n\t  sy = 0;\n      }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921011-2.c",
    "content": "extern int foobar1 ();\n\ntypedef struct\n  {\n    unsigned long colormap;\n    unsigned long red_max;\n    unsigned long red_mult;\n    unsigned long green_max;\n    unsigned long green_mult;\n    unsigned long blue_max;\n    unsigned long blue_mult;\n    unsigned long base_pixel;\n    unsigned long visualid;\n    unsigned long killid;\n  }\nfrotz;\n\nint\nfoobar (stdcmap, count)\n     frotz **stdcmap;\n     int *count;\n{\n  register int i;\n  frotz *data = ((void *) 0);\n\n  unsigned long nitems;\n  int ncmaps;\n  int old_style = 0;\n  unsigned long def_visual = 0L;\n  frotz *cmaps;\n\n\n  if ( foobar1 (&data) != 0)\n    return 0;\n  if (nitems < 10)\n    {\n      ncmaps = 1;\n      if (nitems < 9)\n\t{\n\t}\n    }\n  else\n    ncmaps = (nitems / 10);\n\n  {\n    register frotz *map;\n    register frotz *prop;\n\n    for (i = ncmaps, map = cmaps, prop = data; i > 0; i--, map++, prop++)\n      {\n\tmap->colormap = prop->colormap;\n\tmap->red_max = prop->red_max;\n\tmap->red_mult = prop->red_mult;\n\tmap->green_max = prop->green_max;\n\tmap->green_mult = prop->green_mult;\n\tmap->blue_max = prop->blue_max;\n\tmap->blue_mult = prop->blue_mult;\n\tmap->base_pixel = prop->base_pixel;\n\tmap->visualid = (def_visual ? def_visual : prop->visualid);\n\tmap->killid = (old_style ? 0L : prop->killid);\n      }\n  }\n  *stdcmap = cmaps;\n  *count = ncmaps;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921012-1.c",
    "content": "f()\n{\ng(({int x;0;}));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921012-2.c",
    "content": "struct foo {\nint a,b,c;\n};\nf(struct foo*a,struct foo*b)\n{\n*a=*b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921013-1.c",
    "content": "f(int x,short y)\n{\nlong z=y<0?x>0?x:0:y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921019-1.c",
    "content": "struct\n{\nint n:1,c:1;\n}p;\n\nf()\n{\np.c=p.n=0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921021-1.c",
    "content": "void g();\n\nf()\n{\nint x=1;\nwhile(x)\n{\nx=h();\nif(x)\ng();\n}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921024-1.c",
    "content": "long long f(s,r)\n{\n  return *(long long*)(s+r);\n}\n\ng(s,r)\n{\n  *(long long*)(s+r)=0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921026-1.c",
    "content": "f(unsigned short*a)\n{\na[0]=65535;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921103-1.c",
    "content": "struct {\n  unsigned int f1, f2;\n} s;\n\nf()\n{\n unsigned x, y;\n x = y = 0;\n while (y % 4)\n   y++;\n g(&s.f2, s.f1 + x, 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921109-1.c",
    "content": "typedef struct { double x, y; } p;\ntypedef struct { int s; float r; } t;\nt *e, i;\nint i1;\n\nf(t *op)\n{\nint i2 = e->r;\np pt;\nint c = g();\nt p;\n\nif (c)\n{\ni = *e;\ne -= 3;\nreturn 8;\n}\nif (op > e)\nreturn 1;\nop->r = pt.x;\nop->r = pt.y;\np = *e;\n++e;\ne->r = i1, e->s = i1;\n*++e = p;\nreturn 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921111-1.c",
    "content": "int ps;\nstruct vp {\n  int wa;\n};\ntypedef struct vp *vpt;\ntypedef struct vc {\n  int o;\n  vpt py[8];\n} *vct;\nstruct n {\n  int a;\n};\nstruct nh {\n  int x;\n};\ntypedef struct np *npt;\nstruct np {\n  vct d;\n  int di;\n};\nstruct nh xhp;\nstruct n np[3];\n\nf(dp)\n     npt dp;\n{\n  vpt *py;\n  int a, l, o = 0;\n  a = dp->d->o;\n  if (dp->di < 0)\n    l = ps;\n\n  if ((int)o & 3)\n    g();\n\n  xhp.x = a;\n  py = &dp->d->py[dp->di];\n  if (o + l > ps)\n    np[2].a = (int)(py[1])->wa;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921116-2.c",
    "content": "typedef struct {\n long l[5];\n} t;\n\nf(size)\n{\n t event;\n g(&(event.l[2 + size]), (3 - size) * 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921118-1.c",
    "content": "inline f(i)\n{\n  h((long long) i * 2);\n}\ng()\n{\n  f(9);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921126-1.c",
    "content": "f()\n{\n  long long a0, a1, a0s, val;\n  int width;\n  float d;\n  if (d)\n    ;\n  if (a0s & (1LL << width))\n    ;\n  return a0 / a1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921202-1.c",
    "content": "f ()\n{\n  long dx[2055];\n  long dy[2055];\n  long s1[2055];\n  int x, y;\n  int i;\n  long s;\n\n  for (;;)\n    {\n      s = 2055;\n      g (s1, s);\n      for (i = 0; i < 1; i++);\n      dy[s] = 0x12345;\n      for (i = 0; i < 1; i++);\n      if (x != y || h (dx, dy, s) || dx[s] != 0x12345)\n\t{\n\t  j (y);k (dy);\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921202-2.c",
    "content": "f(x, c)\n{\n  for (;;)\n    {\n      if (x << c) break;\n      x++;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921203-1.c",
    "content": "char dispstr[];\nf()\n{\n  strcpy(dispstr,\"xxxxxxxxxxx\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921203-2.c",
    "content": "typedef struct\n{\n  char x;\n} s1;\n\ns1 f (int arg0,...)\n{\n  int args;\n  s1 back;\n  va_start (args, arg0);\n  va_end (args);\n  return back;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921206-1.c",
    "content": "double sqrt(double),fabs(double),sin(double);\nint sxs;\nint sys;\nf()\n{\n  int l;\n  int sm = -52, sx = 52;\n  char *smap;\n  for (l = 0; l < 9; l++)\n    {\n      double g;\n      int cx, cy, gx, gy, x, y;\n      gx = 2 > g / 3 ? 2 : g / 3;\n      gy = 2 > g / 3 ? 2 : g / 3;\n      for (y = 0 > cy - gy ? 0 : cy - gy; y <= (sys - 1 < cy + gy ? sys : cy + gy); y++)\n\t{\n\t  int sx = 0 > cx - gx ? 0 : cx - gx;\n\t  short *ax = (short *) (y * sxs + sx);\n\n\t  for (x = sx; x <= (sxs - 1 < cx + gx ? sxs - 1 : cx + gx); x++)\n\t    {\n\t      double c=2.25, z=sqrt(fabs(1-c)), cz=(c>1?0.0:-10)>z?c>1?0:1:z;\n\t    }\n\t}\n    }\n  for (l = sm; l <= sx; l++)\n    smap[l] = l > 0 ? 1 + foo(sin(.1 * l / sx)) : 1 - foo(sin(.1 * l / sm));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/921227-1.c",
    "content": "#define k(a) #a\nchar *s = k(k(1,2));\nchar *t = k(#) k(#undef k) k(x);\n\nf(){}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930109-1.c",
    "content": "f(x)\n     unsigned x;\n{\n  static short c;\n  return x>>c;\n}\ng(x)\n     unsigned x;\n{\n  static char c;\n  return x>>c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930109-2.c",
    "content": "f(r)\n{\n  int i;\n  for (i = 0; i < 2; i++)\n    {\n      r+= (4 >> i*2);\n      r+= (2 >> i*2);\n      r+= (1 >> i*2);\n    }\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930111-1.c",
    "content": "/* 2.3.3 crashes on 386 with -traditional */\nf(a)\n     char *a;\n{\n  int d = strcmp(a,\"-\");\n\n  while (vfork() < 0)\n    ;\n  return d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930117-1.c",
    "content": "f(x)\n{\n  (*(void (*)())&x)();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930118-1.c",
    "content": "f()\n{\n__label__ l;\nl:p();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930120-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nunion {\n  short I[2];\n  long int L;\n  char C[4];\n} itolws;\nchar *errflg;\nlong int dot;\nshort dotinc;\nlong int expvf;\n\nchar *\nf(fcount,ifp,itype,ptype)\n     short fcount;\n     char *ifp;\n{\n  unsigned w;\n  long int savdot, wx;\n  char *fp;\n  char c, modifier, longpr;\n  union {\n    double dval;\n    struct {\n      int i1;\n      int i2;\n    } ival;\n  } dw;\n  union {\n    float fval;\n    int ival;\n  } fw;\n  int gotdot = 0;\n  while (fcount > 0) {\n    fp = ifp;\n    c = *fp;\n    longpr = ((c >= 'A') & (c <= 'Z') | (c == 'f') | (c == '4') | (c == 'p') | (c == 'i'));\n    if ((itype == 0) || (*fp == 'a')) {\n      wx = dot;\n      w = dot;\n    } else {\n      gotdot = 1;\n      wx = get((int)dot, itype);\n      if (!longpr) {\n\tw = (itolws.L=(wx), itolws.I[((dot)&3)>>1]);\n      }\n    }\n    if (c == 'F') {\n      dw.ival.i1 = wx;\n      if (itype == 0) {\n\tdw.ival.i2 = expvf;\n      }\n    }\n\n    modifier = *fp++;\n    switch(modifier) {\n    case ' ' :\n    case '\\t' :\n      break;\n    case 't':\n    case 'T':\n      printf(\"%T\",fcount);\n      return(fp);\n    case 'r':\n    case 'R':\n      printf(\"%M\",fcount);\n      return(fp);\n    case 'k':\n      printf(\"%k\",w);\n      break;\n    case 'K':\n      printf(\"%K\",wx);\n      break;\n    case 'a':\n      psymoff(dot,ptype,\":%16t\");\n      dotinc = 0;\n      break;\n    case 'p':\n      psymoff(0,ptype,\"%16t\");\n      break;\n    case 'u':\n      printf(\"%-8u\",w);\n      break;\n    case 'U':\n      printf(\"%-16U\",wx); break;\n    case 'c':\n    case 'C':\n      if (modifier == 'C') {\n\tprintesc((int)(itolws.L=(wx), itolws.C[(dot)&3]));\n      } else {\n\tprintc((char)(itolws.L=(wx), itolws.C[(dot)&3]));\n      }\n      dotinc = 1;\n      break;\n    case 'b':\n      printf(\"%-8x\", (itolws.L=(wx), itolws.C[(dot)&3]));\n      dotinc = 1;\n      break;\n    case 'B':\n      printf(\"%-8o\", (itolws.L=(wx), itolws.C[(dot)&3]));\n      dotinc = 1;\n      break;\n    case 's':\n    case 'S':\n      savdot = dot;\n      dotinc = 1;\n      while ((c = (itolws.L=(wx), itolws.C[(dot)&3])) && (errflg == 0)) {\n\tdot = inkdot(1);\n\tif (modifier == 'S') {\n\t  printesc(c);\n\t} else {\n\t  printc(c);\n\t}\n\tendline();\n\tif (!(dot & 3))\n\t  wx = get((int)dot, itype);\n      }\n      dotinc = dot - savdot + 1;\n      dot = savdot;\n      break;\n    case 'i':\n      if (gotdot) {\n\twx = get((int)(dot & ~3), itype);\n      }\n      iDasm((int)(wx), (unsigned int)0, (unsigned int)(dot&~3));\n      printc('\\n');\n      break;\n    case 'f':\n      fw.ival = wx;\n      printf(\"%-16.9f\", fw.fval);\n      dotinc = 4;\n      break;\n    case 'F':\n      printf(\"%-32.18F\", dw.dval);\n      dotinc = 8;\n      break;\n    }\n  }\n  return(fp);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930126-1.c",
    "content": "typedef unsigned T;\ntypedef char Tchar;\nT mt (long, char *);\nT ms (long, char *);\nT mv (long, T, char);\nT cons (T, T);\nT decl (T * (*) (T *), char *);\n\nT*L92(T*),*L15(T*),*L14(T*),*L13(T*),*L12(T*),*L11(T*),*L10(T*),*L9(T*),*L8(T*),*L7(T*),*L6(T*),*L5(T*),*L4(T*),*L3(T*),*L2(T*),*L1(T*);\n\nstatic T *\nLdata (T * my_pc)\n{\nint cc = (((* ((T *) (my_pc))) >> 16) & 0xFF);\nT B92, B91, B90, B15, B14, B13, B12, B11, B10, B9, B8, B7, B6, B5, B4, B3, B2, B1, tO7, tO6, tO5, tO4, tO3, tO2, tO1, tO0;\nT object = mv (168, 0, ((Tchar) 1));\nT * cb = (T *) (((T) (object & 0x3FF)) | 0x400);\ntO0 = mv (92, 0, ((Tchar) 1));\nB92 = decl (L92, \"\");\nB15 = decl (L15, \"\");\nB14 = decl (L14, \"\");\nB13 = decl (L13, \"\");\nB12 = decl (L12, \"\");\nB11 = decl (L11, \"\");\nB10 = decl (L10, \"\");\nB9 = decl (L9, \"\");\nB8 = decl (L8, \"\");\nB7 = decl (L7, \"\");\nB6 = decl (L6, \"\");\nB5 = decl (L5, \"\");\nB4 = decl (L4, \"\");\nB3 = decl (L3, \"\");\nB2 = decl (L2, \"\");\nB1 = decl (L1, \"\");\ncb[19] = ((((cc) & 0xFF) << 16) | (9 & 0xFF));\ncb[21] = ((((cc) & 0xFF) << 16) | ((10) & 0xFF));\ncb[23] = ((((cc) & 0xFF) << 16) | (11 & 0xFF));\ncb[25] = ((((cc) & 0xFF) << 16) | (12 & 0xFF));\ncb[27] = ((((cc) & 0xFF) << 16) | (13 & 0xFF));\ncb[29] = ((((cc) & 0xFF) << 16) | (14 & 0xFF));\ncb[31] = ((((cc) & 0xFF) << 16) | (15 & 0xFF));\ncb[35] = ((((cc) & 0xFF) << 16) | (17 & 0xFF));\ncb[36] = ((0x1A) << 26) | (((0x39) << 26) | 1) & 0x3FF;\ncb[39] = ms (24, ((char *) \"\"));\ncb[41] = ((0x1A) << 26) | (((0x39) << 26) | 1) & 0x3FF;\ncb[44] = 3;\ncb[46] = 2;\ncb[48] = 3;\ncb[50] = 6;\ncb[52] = 4;\ncb[146] = tO0;\n((T *) (((tO0 & 0x3FF)) | 0x400))[92] = B1;\n((T *) (((tO0 & 0x3FF)) | 0x400))[91] = B2;\n((T *) (((tO0 & 0x3FF)) | 0x400))[2] = B90;\n((T *) (((tO0 & 0x3FF)) | 0x400))[2] = B91;\n((T *) (((tO0 & 0x3FF)) | 0x400))[1] = B92;\ncb[58] = 0x2800 | (T) ((T *) ((B6 & 0x3FF) | 0x400) + 3);\ncb[57] = 0x2800 | (T) ((T *) ((B7 & 0x3FF) | 0x400) + 3) & ~0xC00;\ncb[56] = 0x2800 | (T) ((T *) ((B8 & 0x3FF) | 0x400) + 3) & ~0xC00;\ncb[55] = 0x2800 | (T) ((T *) ((B9 & 0x3FF) | 0x400) + 3) & ~0xC00;\ntO7 = mv (8, 0, ((Tchar) 1));\ntO4 = ms (9, ((char *) \"\"));\ntO3 = mv (58, 0, ((Tchar) 1));\ntO6 = ms (4, ((char *) \"\"));\ntO2 = mv (4, 0, ((Tchar) 1));\ntO5 = ms (4, ((char *) \"\"));\ntO1 = mv (28, 0, ((Tchar) 1));\ncb[165] = tO1;\ncb[163] = cons (((ms (10, ((char *) \"\")))), (cons (tO5, 0)));\ncb[162] = cons (1, (cons (2, 0)));\ncb[150] = cons (1, (cons (2, (cons (3, (cons (4, (cons (5, (cons (6, 0)))))))))));\ncb[148] = tO7;\nreturn cb;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930210-1.c",
    "content": "f()\n{\n  char  c1, c2;\n  char *p1, *p2;\n\n  do {\n    c1 = c2 = *p1++;\n    while (c1--)\n      *p2++ = *p1++;\n  } while (c2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930217-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint a;\n#else\ndouble g ();\ntypedef union {\n  struct {\n    unsigned s:1, e:8, f:23;\n  } u;\n  float f;\n} s;\n\nf(x, n)\n     float x;\n{\n  ((s *)&x)->u.e -= n;\n  x = g((double)x, -n);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930222-1.c",
    "content": "typedef struct\n  {\n    long i;\n    double f;\n  } T;\n\nf (T *n1, T *n2)\n{\n  if (g (n2))\n    return n1->i - n2->i;\n  else\n    {\n      double f = n1->f - n2->i;\n      return f == 0.0 ? 0 : (f > 0.0 ? 1 : -1);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930325-1.c",
    "content": "typedef unsigned uint;\n\ninline\ng (uint *s, uint *d, uint c)\n{\n  while (c != 0)\n    {\n      *--d = *--s;\n      c--;\n    }\n}\n\nf (uint *p1, uint c, uint *p2)\n{\n  while (c > 0 && *p1 == 0)\n    {\n      p1++;\n      c--;\n    }\n  if (c == 0)\n    return 1;\n  g (p2, p1, c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930326-1.c",
    "content": "struct\n{\n  char a, b, f[3];\n} s;\n\nlong i = s.f-&s.b;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930411-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\nint heap;\n\ng(){}\n\nf(int i1, int i2)\n{\n  i1 = *(int*)(i1 + 4);\n  if (i1 == 0)\n    goto L4;\n  else\n    goto L9;\n L3:\n  i2 = heap - 8;\n  *(int*)i2 = 3;\n  *(int*)(i2 + 4) = i1;\n  heap -= 8;\n  return i2;\n L4:\n  i1 = g(i2);\n  goto L5;\n L5:\n  i1 = *(int*)(i1 + 4);\n  if (i1 == 0)\n    goto L7;\n  else\n    goto L8;\n L7:\n  i1 = 0;\n  goto L3;\n L8:\n  i1 = 1;\n  goto L3;\n L9:\n  i1 = 1;\n  goto L3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930421-1.c",
    "content": "double q(double);\n\nf (int **x, int *r, int *s, int a, int b, int c, int d)\n{\n  int i, j, k, m, e, f, g, z[1024], y[2];\n\n  e = g = 0;\n  for (i = 0; i < a; i++)\n    for (j = 0; j < b; j++)\n      if (x[i][j])\n\tfor (k = 0; k < c; k++)\n\t  {\n\t    f = q(1.5) + q(2.5);\n\t    if (g < y[f])\n\t      g = e;\n\t  }\n  for (m = 0; m < 1; m++)\n    z[0] = m*2*d/3.0 - d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930427-2.c",
    "content": "struct s {\n  int f;\n};\n\nf (w, v0, v1, v2, v3)\n     struct s *w;\n{\n g (v0 ? 1 : w->f, v1 ? v3 : v2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930503-1.c",
    "content": "f (const char *s, char *d, unsigned l)\n{\n  if (0)\n    while (1);\n  else\n    while (--l >= 0)\n      *d++ = *s++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930503-2.c",
    "content": "f()\n{\n  struct { char x; } r;\n  g(r);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930506-1.c",
    "content": "long long\nf (a)\n     double a;\n{\n  double b;\n  unsigned long long v;\n\n  b = a / 2.0;\n  v = (unsigned) b;\n  a -= (double) v;\n  return v;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930506-2.c",
    "content": "#ifndef NO_TRAMPOLINES\nint f1()\n{\n  { int ___() { foo(1); } bar(___); }\n  return( { int ___() { foo(2); } bar(___);} );\n}\n\nint f2(int j)\n{\n  { int ___() { foo(j); } bar(___); }\n  return( { int ___() { foo(j); } bar(___);} );\n}\n#else\nint x;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930510-1.c",
    "content": "typedef long time_t;\nstatic __const int mon_lengths[2][12] = {\n  31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,\n  31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31\n};\nstatic time_t\nf (janfirst, year, rulep, offset)\n     __const time_t janfirst;\n     __const int year;\n     register __const struct rule * __const rulep;\n     __const long offset;\n{\n  register int leapyear;\n  register time_t value;\n  register int i;\n\n  value += mon_lengths[leapyear][i] * ((long) (60 * 60) * 24);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930513-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint a;\n#else\nstruct s {\n  int f1 : 26;\n  int f2 : 8;\n};\n\nf (struct s *x)\n{\n  return x->f2++ == 0;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930513-2.c",
    "content": "double g ();\n\nf (x)\n     double x;\n{\n  x = .85;\n  while (g () < x)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930513-3.c",
    "content": "test ()\n{\n  short *p, q[3];\n  int x;\n\n  p = q;\n  for (x = 0; x < 3; x++)\n    *p++ = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930523-1.c",
    "content": "int v;\n\nf ()\n{\n  unsigned long *a1, *a2;\n  int vertex2;\n  int c, x1, x2, dx1, dx2, dy1, dy2, e1, e2, s2;\n  unsigned long m, b;\n  int n;\n  unsigned long r;\n  int aba;\n\n  do\n    {\n      if (dx2 >= dy2)\n\tdx2 = dx2 % dy2;\n\n      if (dx2 >= dy2)\n\t{\n\t  s2 = - (dx2 / dy2);\n\t  dx2 = dx2 % dy2;\n\t}\n    }\n  while (vertex2 / 65536);\n\n  for (;;)\n    {\n      c = x2;\n      a2 = a1;\n      if (v)\n\ta2 = 0;\n\n      if (c + n)\n\t{\n\t  m = b << (c * 8);\n\t  *a2 = (*a2 & ~m) | (r & m);\n\t  n += c;\n\n\t  while (--n)\n\t    {\n\t      {\n\t      }\n\t    }\n\t}\n\n      a1 = 0;\n      x1 += 0;\n      if (e1 += dx1)\n\te1 -= dy1;\n      x2 += s2;\n      if (e2 += dx2)\n\te2 -= dy2;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930525-1.c",
    "content": "typedef struct foo foo_t;\nfoo_t x;\nstruct foo {\n  int i;\n};\n\nfoo_t x = { 10 };\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930527-1.c",
    "content": "enum {e0, e1};\n\nint x[] =\n{\n  [e0] = 0\n};\n\nf ()\n{\n  switch (1)\n    {\n    case e0:\n    case e1:\n      break;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930529-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\nstruct r\n{\n  int d1, d2;\n};\n\nstruct km\n{\n  int d;\n};\n\nstruct f1\n{\n  char *fn;\n  char *fd;\n  char *fs;\n  char *ic;\n  void (*ff) ();\n};\n\nint g ();\n\nint y;\nstruct r *bs;\nint bv;\n\nvoid b ();\nchar *w ();\n\nstruct km **q;\nchar **mns;\nint nm;\nstruct f1 **z;\n\nf (char *km, char *h)\n{\n  struct f1 *t;\n  int map = midn(km, strlen(km));\n  int V;\n  int c;\n  struct r r;\n  struct f1 *cm;\n\n  if (!g(&V, &cm, h, strlen(h)))\n    {\n      c = (cm - z[V]);\n      goto L;\n    }\n\n  for (c = 0; c < nm; c++)\n    if (!strcmp (h, mns[c]))\n      {\n\tV = -1;\n\tgoto L;\n      }\n\n  for (c = 0; c < y; c++)\n    {\n      if (!memcmp (&bs[c], &r, 8))\n\tgoto L;\n    }\n\n  h = w (&r);\n  if (!bv)\n    {\n      bs = g (8);\n      t = (struct f1 *)g (20);\n    }\n  else\n    {\n      bs = g (bs, y * 8);\n      z[bv] = cr (z[bv], (1 + y) * 20);\n      t = &z[bv][y - 1];\n    }\n  bs[y - 1] = r;\n  t->fs[0] = sp (y - 1);\n  t->fs[1] = 0;\n  t->ic = 0;\n  t->fd = 0;\n  t->fn = cs (h);\n  t->ff = b;\n L:\n  g (q[map], V, c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930530-1.c",
    "content": "f ()\n{\n  struct { char a, b; } x;\n  g (x, x, x, x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930602-1.c",
    "content": "typedef struct {\n int f[8];\n} T;\n\nf (w, l, r)\n     T *w;\n     unsigned short l, r;\n{\n  int i;\n\n  for (i = l; i < r; i++)\n    g (w->f[i]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930603-1.c",
    "content": "union u { union u *a; double d; };\nunion u *s, g();\n\nf()\n{\n  union u x = g();\n\n  s[0] = *x.a;\n  s[1] = g();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930607-1.c",
    "content": "typedef void f ();\ntypedef f *pf;\nlong long i;\n\ng ()\n{\n  long long p = i;\n  ((pf) (long) p) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930611-1.c",
    "content": "float\nf (float a1)\n{\n  union { float f; int l; } fl1;\n  fl1.f = a1;\n  return fl1.l ? 1.0 : a1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930618-1.c",
    "content": "f (s)\n{\n  int r;\n\n  r = (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s)) | (!g(s));\n\n return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930621-1.c",
    "content": "#if defined(STACK_SIZE) && (STACK_SIZE < 65536)\n# define BYTEMEM_SIZE 10000L\n#endif\n\n#ifndef BYTEMEM_SIZE\n# define BYTEMEM_SIZE 45000L\n#endif\n\nint bytestart[5000 + 1];\nunsigned char modtext[400 + 1];\nunsigned char bytemem[2][BYTEMEM_SIZE + 1];\n\nlong\nmodlookup (int l)\n{\n  signed char c;\n  long j;\n  long k;\n  signed char w;\n  long p;\n  while (p != 0)\n    {\n      while ((k < bytestart[p + 2]) && (j <= l) && (modtext[j] == bytemem[w][k]))\n\t{\n\t  k = k + 1;\n\t  j = j + 1;\n\t}\n      if (k == bytestart[p + 2])\n\tif (j > l)\n\t  c = 1;\n\telse c = 4;\n      else if (j > l)\n\tc = 3;\n      else if (modtext[j] < bytemem[w][k])\n\tc = 0;\n      else c = 2;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930623-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\ng (a, b) {}\n\nf (xx)\n     void* xx;\n{\n  __builtin_apply ((void*)g, xx, 200);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930702-1.c",
    "content": "f ()\n{\n  {({});}\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930926-1.c",
    "content": "int f () { return 0; }\n\nvoid\ntest ()\n{\n    int j = { f() };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/930927-1.c",
    "content": "#include <stddef.h>\n\nwchar_t s[5] = L\"abcd\";\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931003-1.c",
    "content": "f (n, a)\n     int n;\n     double a[];\n{\n   double b[51];\n   int i, j;\n\n   i = 0;\n\n   for (j = n - 1; j > 0; j--)\n     b[i++] = 0;\n\n   if (b[0] > b[i - 1])\n     a[i] = b[i - 1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931004-1.c",
    "content": "#define A \"This is a long test that tests the structure initialization\"\n#define B A,A\n#define C B,B,B,B\n#define D C,C,C,C\nint main()\n{\n  char *subs[]={ D, D, D, D, D, D, D, D, D, D, D, D, D, D, D};\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931013-1.c",
    "content": "g ();\n\nf ()\n{\n  long ldata[2];\n  int seed;\n\n  seed = (ldata[0]) + (ldata[1] << 16);\n  g (seed);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931013-2.c",
    "content": "f (unsigned short Z[48])\n{\n  int j;\n  unsigned short t1, t2, t3, T[48];\n  unsigned short *p = T + 48;\n\n  for (j = 1; j < 8; j++)\n    {\n      t1 = *Z++;\n      *--p = *Z++;\n      *--p = t1;\n      t1 = inv(*Z++);\n      t2 = -*Z++;\n      t3 = -*Z++;\n      *--p = inv(*Z++);\n      *--p = t2;\n      *--p = t3;\n      *--p = t1;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931013-3.c",
    "content": "struct s\n{\n  int f;\n};\n\nstruct s\nf ()\n{\n  int addr;\n  return *(struct s *) &addr;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931018-1.c",
    "content": "typedef struct\n{\n  int a, b;\n} T;\n\nf (T *bs)\n{\n  long long x;\n  x = ({\n    union { T s; long long l; } u;\n    u.s = *bs;\n    u.l;\n  });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931031-1.c",
    "content": "struct s\n{\n  int pad:1, no:1;\n};\n\nf (struct s *b, int c)\n{\n  char d = b->no && c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931102-1.c",
    "content": "char *e ();\n\n#define SET \\\n  if (d > *b++) d |= a; \\\n  if (b) b = e(b);\n\nxxx()\n{\n  int a, d;\n  char *b, *c;\n\n  while (1) {\n    while (1) {\n      while (1) {\n\tif (a) {\n\t  switch (a) {\n\t  case 1:\n\t    while (1) {\n\t      SET\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t    }\n\t  case 2:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  case 3:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  case 4:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  }\n\t}\n\telse {\n\t  switch (a) {\n\t  case 2:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  case 3:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  case 4:\n\t    while (1) {\n\t      if (d) {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t      else {\n\t\tdo {\n\t\t  SET\n\t\t} while (1);\n\t      }\n\t    }\n\t  }\n\t}\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931102-2.c",
    "content": "typedef struct {\n  int a;\n} VCR;\n\ntypedef struct {\n  VCR vcr[8];\n} VCRC;\n\ntypedef struct {\n  char vcr;\n} OWN;\n\nOWN Own[16];\n\nf (x, own)\n  VCRC *x;\n  OWN *own;\n{\n  x[own->vcr / 8].vcr[own->vcr % 8].a--;\n  x[own->vcr / 8].vcr[own->vcr % 8].a = x[own->vcr / 8].vcr[own->vcr % 8].a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/931203-1.c",
    "content": "v (a, i)\n     unsigned  *a, i;\n{\n  a++[i] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/940611-1.c",
    "content": "f ()\n{\n  do\nL:;\n  while (0);\n  do\n    ;\n  while (0);\n  goto L;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/940712-1.c",
    "content": "f ()\n{\n  return (*(volatile unsigned int *)8000) / 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/940718-1.c",
    "content": "extern double log (double) __attribute__ ((const));\n\nf (double x)\n{\n  for (;;)\n    exp(log(x));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941014-1.c",
    "content": "f (to)\n     char *to;\n{\n  unsigned int wch;\n  register length;\n  unsigned char tmp;\n  unsigned int mult = 10;\n\n  tmp = (wch>>(unsigned int)(length * mult));\n  *to++ = (unsigned char)tmp;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941014-2.c",
    "content": "void\nf (n, ppt, xrot)\n{\n  int tileWidth;\n  int nlwSrc;\n  int srcx;\n  int v3, v4;\n  register unsigned long ca1, cx1, ca2, cx2;\n  unsigned long *pSrcLine;\n  register unsigned long *pDst;\n  register unsigned long *pSrc;\n  register unsigned long b, tmp;\n  unsigned long tileEndMask;\n  int v1, v2;\n  int tileEndPart;\n  int needFirst;\n  tileEndPart = 0;\n  v1 = tileEndPart << 5;\n  v2 = 32 - v1;\n  while (n--)\n    {\n      if ((srcx = (ppt - xrot) % tileWidth) < 0)\n\tif (needFirst)\n\t  if (nlwSrc == 1)\n\t    {\n\t      tmp = b;\n\t      if (tileEndPart)\n\t\tb = (*pSrc & tileEndMask) | (*pSrcLine >> v1);\n\t    }\n      if (tileEndPart)\n\tb = (tmp << v1) | (b >> v2);\n      if (v4 != 32)\n\t*pDst = (*pDst & ((tmp << v3) | (b >> v4) & ca1 ^ cx1)\n\t\t ^ (((tmp << v3) | (b >> v4)) & ca2 ^ cx2));\n      *pDst = *pDst & tmp;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941014-3.c",
    "content": "typedef unsigned char byte;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\ntypedef ulong gs_char;\ntypedef struct gs_show_enum_s gs_show_enum;\ntypedef struct gs_font_s gs_font;\ntypedef struct gx_font_stack_item_s {\n  gs_font *font;\n} gx_font_stack_item;\ntypedef struct gx_font_stack_s {\n  gx_font_stack_item items[1 + 5 ];\n} gx_font_stack;\nstruct gs_show_enum_s {\n  gx_font_stack fstack;\n};\ntypedef enum {\n  ft_composite = 0,\n} font_type;\nstruct gs_font_s {\n  font_type FontType;\n};\ntypedef enum {\n  fmap_escape = 3,\n  fmap_shift = 8\n  } fmap_type;\ntypedef struct gs_type0_data_s {\n  fmap_type FMapType;\n} gs_type0_data;\ngs_type0_next_char(register gs_show_enum *penum)\n{\n  const byte *p;\n  int fdepth;\n  gs_font *pfont;\n  gs_type0_data *pdata;\n  uint fidx;\n  gs_char chr;\n  for (; pfont->FontType == ft_composite; )\n    {\n      fmap_type fmt;\n      switch ( fmt )\n\t{\n\t  do {} while (0);\n\trdown:\n\t  continue;\n\tcase fmap_shift:\n\t  p++;\n\t  do {} while (0);\n\t  goto rdown;\n\t}\n      break;\n    }\n up:\n  while ( fdepth > 0 )\n    {\n      switch ( pdata->FMapType )\n\t{\n\tdefault:\n\t  continue;\n\tcase fmap_escape:\n\t  fidx = *++p;\n\t  do {} while (0);\n\t  if ( fidx == chr && fdepth > 1 )\n\t    goto up;\n\tdown:\n\t  fdepth--;\n\t  do {} while (0);\n\t}\n      break;\n    }\n  while ( (pfont = penum->fstack.items[fdepth].font)->FontType == ft_composite )\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941014-4.c",
    "content": "#ifndef NO_LABEL_VALUES\nf (int *re)\n{\n  int *loops = 0, *loope = 0;\n  unsigned dat0 = 0;\n  static void *debug = &&firstdebug;\n\n firstdebug:\n  g (loops, loope);\n\n  if (dat0 & 1)\n    re[(dat0 >> 2) & 3] = 0;\n}\n#else\nint x;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941019-1.c",
    "content": "__complex__ long double sub (__complex__ long double cld) { return cld; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941111-1.c",
    "content": "main ()\n{\n  struct S { int i; char c; } obj1, obj2;\n\n  foo ();\n  if (obj1.c != obj2.c)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/941113-1.c",
    "content": "typedef void foo (void);\n\nf (x)\n{\n  if (x)\n    {\n      const foo* v;\n      (*v)();\n    }\n  else\n    g (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950122-1.c",
    "content": "int\nfoo (int i, unsigned short j)\n{\n  return j *= i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950124-1.c",
    "content": "f ()\n{\n  if (g ())\n    h ();\n  else\n    {\n      do\n\t{\n\t  return 0;\n\t  break;\n\t}\n      while (1);\n    }\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950221-1.c",
    "content": "short v = -1;\n\ntypedef struct\n{\n  short network;\n} atype;\n\nvoid f ()\n{\n  static atype config;\n  atype *cp;\n  short net;\n  cp = &config;\n  cp->network = (v == -1) ? 100 : v;\n  net = cp->network;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950329-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nf ()\n{\n  int i;\n  for (i = 1;; i = 0)\n    {\n      if (h ())\n\t{\n\t  if (i)\n\t    g ();\n\t  g (h ());\n\t  g (h ());\n\t}\n      else\n\t{\n\t  g ();\n\t  break;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950512-1.c",
    "content": "typedef unsigned short uint16;\nf (unsigned char *w)\n{\n  w[2] = (uint16) ((((g (0) % 10000 + 42) & 0xFF) << 8) | (((g (0) % 10000 + 42) >> 8) & 0xFF)) & 0xFF,\n  w[3] = (uint16) ((((g (0) % 10000 + 42) & 0xFF) << 8) | (((g (0) % 10000 + 42) >> 8) & 0xFF)) >> 8;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950530-1.c",
    "content": "f (int *s, int *t)\n{\n  return (t - s) / 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950607-1.c",
    "content": "typedef struct {\n  int component_id;\n  int component_index;\n  int h_samp_factor;\n  int v_samp_factor;\n} jpeg_component_info;\nstruct jpeg_common_struct {\n  struct jpeg_error_mgr * err;\n};\ntypedef struct jpeg_common_struct * j_common_ptr;\ntypedef struct jpeg_compress_struct * j_compress_ptr;\nstruct jpeg_compress_struct {\n  struct jpeg_error_mgr * err;\n  int num_components;\n  jpeg_component_info * comp_info;\n  int max_h_samp_factor;\n  int max_v_samp_factor;\n};\nstruct jpeg_error_mgr {\n  int msg_code;\n};\n\nvoid\njinit_downsampler (j_compress_ptr cinfo)\n{\n  int ci;\n  jpeg_component_info * compptr;\n\n  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;\n       ci++, compptr++) {\n    if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&\n\tcompptr->v_samp_factor == cinfo->max_v_samp_factor) {\n    } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&\n\t       (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {\n    } else\n      cinfo->err->msg_code = 0;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950610-1.c",
    "content": "f (int n, int a[2][n]) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950612-1.c",
    "content": "typedef enum\n{\n  LODI,\n  STO,\n  ADDI,\n  ADD,\n  SUBI,\n  SUB,\n  MULI,\n  MUL,\n  DIVI,\n  DIV,\n  INC,\n  DEC\n} INSN;\n\nf (pc)\n     short *pc;\n{\n  long long stack[16], *sp = &stack[16], acc = 0;\n\n  for (;;)\n    {\n      switch ((INSN)*pc++)\n\t{\n\tcase LODI:\n\t  *--sp = acc;\n\t  acc = ((long long)*pc++) << 32;\n\t  break;\n\tcase STO:\n\t  return (acc >> 32) + (((((unsigned long long) acc) & 0xffffffff)  & (1 << 31)) != 0);\n\t  break;\n\tcase ADDI:\n\t  acc += ((long long)*pc++) << 32;\n\t  break;\n\tcase ADD:\n\t  acc = *sp++ + acc;\n\t  break;\n\tcase SUBI:\n\t  acc -= ((long long)*pc++) << 32;\n\t  break;\n\tcase SUB:\n\t  acc = *sp++ - acc;\n\t  break;\n\tcase MULI:\n\t  acc *= *pc++;\n\t  break;\n\tcase MUL:\n\t  {\n\t    long long aux;\n\t    unsigned char minus;\n\n\t    minus = 0;\n\t    aux = *sp++;\n\t    if (aux < 0)\n\t      {\n\t\tminus = ~minus;\n\t\taux = -aux;\n\t      }\n\t    if (acc < 0)\n\t      {\n\t\tminus = ~minus;\n\t\tacc = -acc;\n\t      }\n\t    acc = ((((((unsigned long long) acc) & 0xffffffff)  * (((unsigned long long) aux) & 0xffffffff)) >> 32)\n\t\t   + ((((unsigned long long) acc) >> 32)  * (((unsigned long long) aux) & 0xffffffff)  + (((unsigned long long) acc) & 0xffffffff)  + (((unsigned long long) aux) >> 32))\n\t\t   + (((((unsigned long long) acc) >> 32)  * (((unsigned long long) aux) >> 32)) << 32));\n\t    if (minus)\n\t      acc = -acc;\n\t  }\n\t  break;\n\tcase DIVI:\n\t  {\n\t    short aux;\n\n\t    aux = *pc++;\n\t    acc = (acc + aux / 2) / aux;\n\t  }\n\t  break;\n\tcase DIV:\n\t  {\n\t    long long aux;\n\t    unsigned char minus;\n\n\t    minus = 0;\n\t    aux = *sp++;\n\t    if (aux < 0)\n\t      {\n\t\tminus = ~minus;\n\t\taux = -aux;\n\t      }\n\t    if (acc < 0)\n\t      {\n\t\tminus = ~minus;\n\t\tacc = -acc;\n\t      }\n\n\t    if (((unsigned long long)acc)  == 0)\n\t      acc = (unsigned long long)-1 / 2;\n\t    else if ((((unsigned long long) ((unsigned long long)acc)) & 0xffffffff)  == 0)\n\t      acc = ((unsigned long long)aux)  / (((unsigned long long) ((unsigned long long)acc)) >> 32);\n\t    else if ((((unsigned long long) ((unsigned long long)acc)) >> 32)  == 0)\n\t      acc = ((((unsigned long long)aux)  / ((unsigned long long)acc)) << 32)\n\t\t+ ((((unsigned long long)aux)  % ((unsigned long long)acc)) << 32) / ((unsigned long long)acc);\n\t    else\n\t      {\n\t\tunsigned char shift;\n\t\tunsigned long hi;\n\n\t\tshift = 32;\n\t\thi = (((unsigned long long) ((unsigned long long)acc)) >> 32);\n\t\tdo {\n\t\t  if (hi & ((unsigned long)1 << (shift - 1)))\n\t\t    break;\n\t\t} while (--shift != 0);\n\t\tprintf(\"shift = %d\\n\", shift);\n\t\tacc = ((((unsigned long long)aux)  / ((unsigned long long)acc)) << 32)\n\t\t  + (((((unsigned long long)aux)  % ((unsigned long long)acc)) << (32 - shift)) + ((((unsigned long long)acc)  >> shift) / 2)) / (((unsigned long long)acc)  >> shift);\n\t      }\n\n\t    if (minus)\n\t      acc = -acc;\n\t  }\n\t  break;\n\tcase INC:\n\t  acc += 1;\n\t  break;\n\tcase DEC:\n\t  acc -= 1;\n\t  break;\n\t}\n      printf(\"%08lx.%08lx\\n\", (long)(((unsigned long long) acc) >> 32) , (long)(((unsigned long long) acc) & 0xffffffff));\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950613-1.c",
    "content": "/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nf ()\n{\n  long *sp;\n  long *pc;\n\n  static void *dummy[] =\n    {\n      &&L1,\n      &&L2,\n    };\n\n L1:\n  {\n    float val;\n    val = *(float *) sp;\n    val = -val;\n    *(float *) sp = val;\n    goto *pc++;\n  }\n\n L2:\n  {\n    float from;\n    *(long long *) sp = from;\n    goto *pc++;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950618-1.c",
    "content": "static __inline__ int f () { return g (); }\nint g () { return f (); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950719-1.c",
    "content": "typedef struct\n{\n  int Header;\n  char data[4092];\n} t_node;\n\nf (unsigned short rid, unsigned short record_length)\n{\n  t_node tnode;\n  g (rid, tnode.data + rid * record_length);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950729-1.c",
    "content": "static const char * const lcset = \"0123456789abcdef\";\nstatic const char * const ucset = \"0123456789ABCDEF\";\n\nchar *\nf (char *buffer, long long value, char type)\n{\n  int base, i;\n\n  i = 128  - 1;\n  buffer[i--] = '\\0';\n\n  switch (type)\n    {\n    case 'u':\n    case 'o':\n    case 'x':\n    case 'X':\n      if (type == 'u')\n\tbase = 10;\n      else if (type == 'o')\n\tbase = 8;\n      else\n\tbase = 16;\n\n      while (i >= 0)\n\t{\n\t  if (type == 'X')\n\t    buffer[i--] = ucset[((unsigned long long) value) % base];\n\t  else\n\t    buffer[i--] = lcset[((unsigned long long) value) % base];\n\n\t  if ((value = ((unsigned long long) value) / base) == 0)\n\t    break;\n\t}\n      break;\n    }\n\n  return &buffer[++i];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950816-1.c",
    "content": "f ()\n{\n  unsigned char b[2];\n  float f;\n  b[0] = (unsigned char) f / 256;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950816-2.c",
    "content": "f ()\n{\n  int i;\n  float a,b,c;\n  unsigned char val[2];\n  i = func (&c);\n  val[0] = c < a ? a : c >= 1.0 ? b : c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950816-3.c",
    "content": "f ()\n{\n  int i;\n  short\tx, z;\n  for (i = 0; i <= 1; i++)\n    x = i;\n  return x + z;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950910-1.c",
    "content": "f (char *p)\n{\n  char c;\n\n  c = *++p;\n  if (c != ' ')\n    return 0;\n  for (;;)\n    {\n      c = *p;\n      if (g (c))\n\tp++;\n      else\n\t{\n\t  if (c == ' ')\n\t    break;\n\t  else\n\t    return 0;\n\t}\n    }\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950919-1.c",
    "content": "#define empty\n#if empty#cpu(m68k)\n#endif\n\nf (){}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950921-1.c",
    "content": "f ()\n{\n  union\n    {\n      signed char c;\n      double d;\n    } u;\n\n  u.c = 1;\n  u.c = 1;\n  return u.c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/950922-1.c",
    "content": "struct sw {\n  const void *x;\n  int r;\n};\nstruct sq {\n  struct sw *q_w;\n  int t;\n  int z;\n};\n\nint\nf (int ch, char *fp, char *ap)\n{\n  register int n;\n  register char *cp;\n  register struct sw *p;\n  register int f;\n  int prec;\n  double _double;\n  int expt;\n  int ndig;\n  char expstr[7];\n  unsigned long long _uquad;\n  struct sq q;\n  struct sw w[8];\n  static char zeroes[16];\n\n  for (;;) {\n    switch (ch) {\n    case 'd':\n      _double = (double) (ap += 8, *((double *) (ap - 8)));\n      break;\n    case 'o':\n      goto nosign;\n    case 'u':\n      _uquad = (f & 0x020 ? (ap += 8, *((long long *) (ap - 8))) : f & 0x010 ? (ap += 4, *((long *) (ap - 4))) : f & 0x040 ? (long)(short)(ap += 4, *((int *) (ap - 4))) : (long)(ap += 4, *((int *) (ap - 4))));\n      goto nosign;\n    case 'x':\n      _uquad = (f & 0x020 ? (ap += 8, *((long long *) (ap - 8))) : f & 0x010 ? (ap += 4, *((long *) (ap - 4))) : f & 0x040 ? (long)(unsigned short)(ap += 4, *((int *) (ap - 4))) : (long)(ap += 4, *((int *) (ap - 4))));\n    nosign:\n      if (_uquad != 0 || prec != 0);\n      break;\n    default:;\n    }\n    if ((f & 0x100) == 0) {\n    } else {\n      if (ch >= 'f') {\n\tif (_double == 0) {\n\t  if (expt < ndig || (f & 0x001) != 0) {\n\t    { if ((n = (ndig - 1)) > 0) { while (n > 16) {{ p->x = (zeroes); p->r = 16; q.z += 16; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} n -= 16; }{ p->x = (zeroes); p->r = n; q.z += n; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}}}\n\t  }\n\t} else if (expt <= 0) {\n\t  { p->x = (\"0\"); p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t  { p->x = 0; p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t  { if ((n = (-expt)) > 0) { while (n > 16) {{ p->x = (zeroes); p->r = 16; q.z += 16; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} n -= 16; }{ p->x = (zeroes); p->r = n; q.z += n; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }} }}\n\t  { p->x = cp; p->r = ndig; q.z += ndig; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t} else {\n\t  { p->x = cp; p->r = expt; q.z += expt; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t  cp += expt;\n\t  { p->x = (\".\"); p->r = 1; q.z += 1; p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t  { p->x = cp; p->r = (ndig-expt); q.z += (ndig-expt); p++; if (++q.t >= 8) { if (g(fp, &q)) goto error; p = w; }}\n\t}\n      }\n    }\n  }\n\n error:;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951004-1.c",
    "content": "typedef struct\n{\n  short v, h;\n} S;\n\nS a;\n\nf (S pnt)\n{\n  S mpnt, mtp;\n\n  (&pnt)->v -= 1;\n  mpnt = pnt;\n  mtp = a;\n  if (mtp.v != mpnt.v)\n    {\n      S tpnt;\n\n      tpnt = mtp;\n      mtp = mpnt;\n      mpnt = tpnt;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951106-1.c",
    "content": "f (double a, double b)\n{\n  g (a, 0, b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951116-1.c",
    "content": "f ()\n{\n  long long i;\n  int j;\n  long long k = i = j;\n\n  int inner () {return j + i;}\n  return k;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951128-1.c",
    "content": "char a[];\nf (const int i)\n{\n  a[i] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951220-1.c",
    "content": "f (char *x)\n{\n  return (*x & 2) || (*x & 3);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/951222-1.c",
    "content": "extern long long foo ();\n\nlong long\nsub1 ()\n{\n  char junk[10000];\n  register long long a, b, c;\n\n  b = foo ();\n\n  setjmp ();\n  a = foo ();\n  c = a - b;\n  return c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960106-1.c",
    "content": "f (a)\n{\n  return (a & 1) && !(a & 2 & 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960130-1.c",
    "content": "int a[1];\n\nint\nmain()\n{\n  extern int a[];\n  return *a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960201-1.c",
    "content": "union foo\n{\n  char a;\n  int x[2];\n} __attribute__ ((transparent_union));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960218-1.c",
    "content": "#define X(x) x\nint main() { return X(0/* *//* */); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960220-1.c",
    "content": "f ()\n{\n  unsigned long long int a = 0, b;\n  while (b > a)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960221-1.c",
    "content": "struct s1 { int f1; };\n\nstruct s2 {\n  struct s1 a;\n  int f2;\n};\n\nfoo (struct s2 *ptr)\n{\n  *ptr = (struct s2) {{}, 0};\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960319-1.c",
    "content": "static void\nf()\n{\n  long long a[2];\n  int i;\n  if (g())\n    if (h())\n      ;\n  *a |= (long long)i << 65 ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960514-1.c",
    "content": "struct s {\n  unsigned long long t[5];\n};\n\nvoid\nf (struct s *d, unsigned long long *l)\n{\n  int i;\n\n  for (i = 0; i < 5; i++)\n    d->t[i] += l[i];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960704-1.c",
    "content": "struct A {\n  double d;\n};\n\nstruct A f ();\n\nmain ()\n{\n  struct A a = f();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/960829-1.c",
    "content": "f ()\n{\n  g (0, 0.0, 0.0, 0.0, 0.0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961004-1.c",
    "content": "void\nf1 (o1, o2, o3, i, j, k)\n     long long *o1, *o2, *o3;\n     int i, j, k;\n{\n  while (--i)\n    o1[i] = o2[j >>= 1] + o3[k >>= 1];\n}\n\nvoid\nf2 (o1, o2, o3, i, j, k)\n     long long *o1, *o2, *o3;\n     int i, j, k;\n{\n  while (--i)\n    o1[i] = o2[j >>= 1] - o3[k >>= 1];\n}\n\nvoid\nf3 (o1, o2, o3, i, j, k)\n     long long *o1, *o3;\n     unsigned *o2;\n     int i, j, k;\n{\n  while (--i)\n    o1[i] = o2[j >>= 1] + o3[k >>= 1];\n}\n\nvoid\nf4 (o1, o2, o3, i, j, k)\n     long long *o1, *o2;\n     unsigned *o3;\n     int i, j, k;\n{\n  while (--i)\n    o1[i] = o2[j >>= 1] - o3[k >>= 1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961010-1.c",
    "content": "double f (double x) { return x == 0 ? x : 0.0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961019-1.c",
    "content": "char _hex_value[256];\n\nvoid\nhex_init ()\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    _hex_value[i] = 99;\n  for (i = 0; i < 10; i++)\n    _hex_value['0' + i] = i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961031-1.c",
    "content": "struct s {\n  double d;\n} sd;\n\nstruct s g () __attribute__ ((const));\n\nstruct s\ng ()\n{\n  return sd;\n}\n\nf ()\n{\n  g ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961126-1.c",
    "content": "int *p;\n\nmain()\n{\n  int i = sub ();\n\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n  i = -i;\n  if (*p != i)\n    goto quit;\n\n  i = -i;\nquit:\n  sub2 (i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/961203-1.c",
    "content": "/* The structure is too large for the xstormy16 - won't fit in 16\n   bits.  */\n/* { dg-do assemble } */\n\n#if __INT_MAX__ >= 2147483647L\nstruct s {\n  char a[0x32100000];\n  int x:30, y:30;\n};\n\nint\nmain ()\n{\n  struct s* p;\n\n  p = (struct s*) 0;\n  if (p->x == p->y)\n    exit (1);\n}\n#else\nint g;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/970206-1.c",
    "content": "struct Rect\n{\n  int iA;\n  int iB;\n  int iC;\n  int iD;\n};\n\nvoid\nf (int * const this, struct Rect arect)\n{\n  g (*this, arect);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/970214-1.c",
    "content": "#include <stddef.h>\n#define L       264\nwchar_t c = L'X';\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980329-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nstruct re_pattern_buffer\n  {\n    unsigned char *buffer;\n    unsigned long int used;\n  };\nstruct re_registers\n  {\n    int *start;\n  };\n\nstatic const char **regstart, **regend;\nstatic const char **old_regend;\n\nstatic int\nre_match_2_internal (struct re_pattern_buffer *bufp,\n\t\t     struct re_registers *regs)\n{\n  unsigned char *p = bufp->buffer;\n  unsigned char *pend = p + bufp->used;\n\n  for (;;)\n    {\n      int highest_active_reg = 1;\n      if (bufp)\n\t{\n\t  int i;\n\t  for (i = 1;; i++)\n\t    regs->start[i] = 0;\n\t}\n\n      switch ((unsigned int) *p++)\n\t{\n\tcase 1:\n\t  {\n\t    unsigned char r = *p;\n\t    if (r)\n\t      highest_active_reg = r;\n\t  }\n\t  if (p + 2 == pend)\n\t    {\n\t      char is_a_jump_n = 0;\n\t      int mcnt = 0;\n\t      unsigned char *p1;\n\n\t      p1 = p + 2;\n\t      switch (*p1++)\n\t\t{\n\t\tcase 2:\n\t\t  is_a_jump_n = 1;\n\t\tcase 1:\n\t\t  do { do { mcnt = *p1; } while (0); p1 += 2; } while (0);\n\t\t  if (is_a_jump_n)\n\t\t    p1 = 0;\n\t\t}\n\n\t      if (mcnt && *p1 == 0)\n\t\t{\n\t\t  unsigned r;\n\t\t  for (r = 0; r < (unsigned) *p + (unsigned) *(p + 1); r++)\n\t\t    {\n\t\t      if (regend[0] >= regstart[r])\n\t\t\tregend[r] = old_regend[r];\n\t\t    }\n\t\t  do { while (0 < highest_active_reg + 1) { } } while (0);\n\t\t}\n\t    }\n\t}\n    }\n\n  return -1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980408-1.c",
    "content": "typedef struct _RunlengthPacket\n{\n  unsigned short\n    red,\n    green,\n    blue,\n    length;\n  unsigned short\n    index;\n} RunlengthPacket;\ntypedef struct _Image\n{\n  int\n    status,\n    temporary;\n  char\n    filename[1664 ];\n  long int\n    filesize;\n  int\n    pipe;\n  char\n    magick[1664 ],\n    *comments,\n    *label,\n    *text;\n  unsigned int\n    matte;\n  unsigned int\n    columns,\n    rows,\n    depth;\n  unsigned int\n    scene,\n    number_scenes;\n  char\n    *montage,\n    *directory;\n  unsigned int\n    colors;\n  double\n    gamma;\n  float\n    x_resolution,\n    y_resolution;\n  unsigned int\n    mean_error_per_pixel;\n  double\n    normalized_mean_error,\n    normalized_maximum_error;\n  unsigned long\n    total_colors;\n  char\n    *signature;\n  unsigned int\n    packets,\n    runlength,\n    packet_size;\n  unsigned char\n    *packed_pixels;\n  long int\n    magick_time;\n  char\n    magick_filename[1664 ];\n  unsigned int\n    magick_columns,\n    magick_rows;\n  char\n    *geometry,\n    *page;\n  unsigned int\n    dispose,\n    delay,\n    iterations;\n  unsigned int\n    orphan;\n  struct _Image\n    *previous,\n    *list,\n    *next;\n} Image;\n  Image *MinifyImage(Image *image)\n{\n  Image\n    *minified_image;\n  register RunlengthPacket\n    *q,\n    *s,\n    *s0,\n    *s1,\n    *s2,\n    *s3;\n  register unsigned int\n    x;\n  unsigned int\n    blue,\n    green,\n    red;\n  unsigned long\n    total_matte,\n    total_blue,\n    total_green,\n    total_red;\n  unsigned short\n    index;\n    for (x=0; x < (image->columns-1); x+=2)\n    {\n      total_red=0;\n      total_green=0;\n      total_blue=0;\n      total_matte=0;\n      s=s0;\n      total_red+=( 3 )*(s->red); total_green+=( 3 )*(s->green); total_blue+=( 3 )*(s->blue); total_matte+=( 3 )*(s->index); s++; ; total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;  total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;  total_red+=( 3 )*(s->red); total_green+=( 3 )*(s->green); total_blue+=( 3 )*(s->blue); total_matte+=( 3 )*(s->index); s++; ;\n      s=s1;\n      total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ; total_red+=( 15 )*(s->red); total_green+=( 15 )*(s->green); total_blue+=( 15 )*(s->blue); total_matte+=( 15 )*(s->index); s++; ; total_red+=( 15 )*(s->red); total_green+=( 15 )*(s->green); total_blue+=( 15 )*(s->blue); total_matte+=( 15 )*(s->index); s++; ; total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;\n      s=s2;\n      total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ; total_red+=( 15 )*(s->red); total_green+=( 15 )*(s->green); total_blue+=( 15 )*(s->blue); total_matte+=( 15 )*(s->index); s++; ; total_red+=( 15 )*(s->red); total_green+=( 15 )*(s->green); total_blue+=( 15 )*(s->blue); total_matte+=( 15 )*(s->index); s++; ; total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;\n      s=s3;\n      total_red+=( 3 )*(s->red); total_green+=( 3 )*(s->green); total_blue+=( 3 )*(s->blue); total_matte+=( 3 )*(s->index); s++; ; total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;  total_red+=( 7 )*(s->red); total_green+=( 7 )*(s->green); total_blue+=( 7 )*(s->blue); total_matte+=( 7 )*(s->index); s++; ;  total_red+=( 3 )*(s->red); total_green+=( 3 )*(s->green); total_blue+=( 3 )*(s->blue); total_matte+=( 3 )*(s->index); s++; ;\n      red=(unsigned short) ((total_red+63) >> 7);\n      green=(unsigned short) ((total_green+63) >> 7);\n      blue=(unsigned short) ((total_blue+63) >> 7);\n      index=(unsigned short) ((total_matte+63) >> 7);\n      if ((red == q->red) && (green == q->green) && (blue == q->blue) &&\n          (index == q->index) && ((int) q->length < 65535L ))\n        q->length++;\n    }\n  return(minified_image);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980504-1.c",
    "content": "typedef struct _geom_elem {\n  double        coeffs[6];\n} pGeomDefRec, *pGeomDefPtr;\ntypedef struct _mpgeombanddef {\n\tint\tyOut;\t\t \n\tint\tin_width;\t \n} mpGeometryBandRec, *mpGeometryBandPtr;\ntypedef void *pointer;\ntypedef unsigned char  CARD8;\ntypedef CARD8 BytePixel;\nvoid  BiGL_B  (OUTP,srcimg,width,sline,pedpvt,pvtband)\tpointer OUTP;\npointer *srcimg;\nregister int width;\nint sline;\npGeomDefPtr pedpvt; mpGeometryBandPtr pvtband;\n{\n  register float s, t, st;\n  register int \tisrcline,isrcpix;\n  register int \tsrcwidth = pvtband->in_width - 1;\n  register   BytePixel  val;\n  register   BytePixel  *ptrIn, *ptrJn;\n  register double a  = pedpvt->coeffs[0];\n  register double c  = pedpvt->coeffs[2];\n  register double srcpix  = a * ((double)(0.0000))  +\tpedpvt->coeffs[1] * (pvtband->yOut + ((double)(0.0000)) ) +\tpedpvt->coeffs[4];\n  register double srcline = c * ((double)(0.0000))  +\tpedpvt->coeffs[3] * (pvtband->yOut + ((double)(0.0000)) ) +\tpedpvt->coeffs[5];\n  if ( (isrcpix >= 0) && (isrcpix < srcwidth) )\n    val =\tptrIn[isrcpix]   * ((float)1. - s - t + st) + ptrIn[isrcpix+1] * (s - st) +\tptrJn[isrcpix]   * (t - st) +\tptrJn[isrcpix+1] * (st) +   (float)0.5 ;\n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980506-1.c",
    "content": "/* The arrays are too large for the xstormy16 - won't fit in 16 bits. */\n/* { dg-do assemble } */\n/* { dg-require-effective-target size32plus } */\n/* { dg-skip-if \"Array too big\" { \"avr-*-*\" } { \"*\" } { \"\" } } */ \n/* { dg-xfail-if \"The array too big\" { h8300-*-* } { \"-mno-h\" \"-mn\" } { \"\" } } */\n\nunsigned char\tTIFFFax2DMode[20][256];\nunsigned char\tTIFFFax2DNextState[20][256];\nunsigned char\tTIFFFaxUncompAction[20][256];\nunsigned char\tTIFFFaxUncompNextState[20][256];\nunsigned char\tTIFFFax1DAction[230][256];\nunsigned char\tTIFFFax1DNextState[230][256];\n\ntypedef struct tableentry {\n    unsigned short length;\n    unsigned short code;\n    short       runlen;\n} tableentry;\n\nextern tableentry TIFFFaxWhiteCodes[];\nextern tableentry TIFFFaxBlackCodes[];\n\nstatic short sp_data, sp_bit;\n\nstatic unsigned char\nfetchByte (inbuf)\n\nunsigned char **inbuf;\n\n{\n    unsigned char byte = **inbuf;\n    (*inbuf)++;\n    return (byte);\n}\n\nstatic int\ndecode_white_run (inbuf)\n\nunsigned char **inbuf;\n\n{\n    short state = sp_bit;\n    short action;\n    int runlen = 0;\n\n    for (;;)\n    {\n\tif (sp_bit == 0)\n\t{\n\tnextbyte:\n\t    sp_data = fetchByte (inbuf);\n\t}\n\n\taction = TIFFFax1DAction[state][sp_data];\n\tstate = TIFFFax1DNextState[state][sp_data];\n\tif (action == 0 )\n\t    goto nextbyte;\n\tif (action == 1 )\n\t    return (-1 );\n\tif (action == 210 )\n\t    return (-3 );\n\tsp_bit = state;\n\taction = (TIFFFaxWhiteCodes[ action - 2  ].runlen) ;\n\trunlen += action;\n\tif (action < 64)\n\t    return (runlen);\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980506-2.c",
    "content": "/*\n * inspired by glibc-2.0.6/sysdeps/libm-ieee754/s_nextafterf.c\n *\n * gcc -O2 -S -DOP=+ gives faddp %st(1),%st\n * gcc -O2 -S -DOP=* gives fmulp %st(1),%st\n * gcc -O2 -S -DOP=- gives fsubrp %st(1),%st\n * gcc -O2 -S -DOP=/ gives fdivrp %st(1),%st\n */\n\n#ifndef OP\n#define OP *\n#endif\n\ntypedef int int32_t __attribute__ ((__mode__ (  __SI__ ))) ;\ntypedef unsigned int u_int32_t __attribute__ ((__mode__ (  __SI__ ))) ;\n\ntypedef union\n{\n  float value;\n  u_int32_t word;\n} ieee_float_shape_type;\n\nfloat __nextafterf(float x, float y)\n{\n int32_t hx,hy,ix,iy;\n\n {\n  ieee_float_shape_type gf_u;\n  gf_u.value = x;\n  hx = gf_u.word;\n }\n {\n  ieee_float_shape_type gf_u;\n  gf_u.value = y;\n  hy = gf_u.word;\n }\n ix = hx&0x7fffffff;\n iy = hy&0x7fffffff;\n\n if ( ix > 0x7f800000 || iy > 0x7f800000 )\n    return x+y;\n if (x == y) return x;\n if (ix == 0)\n   {\n    {\n     ieee_float_shape_type sf_u;\n     sf_u.word = (hy&0x80000000) | 1;\n     x = sf_u.value;\n    }\n    y = x*x;\n    if (y == x) return y; else return x;\n   }\n if (hx >= 0)\n   {\n    if (hx > hy)\n       hx -= 1;\n    else\n       hx += 1;\n   }\n else\n   {\n    if (hy >= 0 || hx > hy)\n       hx -= 1;\n    else\n       hx += 1;\n   }\n hy = hx & 0x7f800000;\n if (hy >= 0x7f800000)\n    return x+x;\n if (hy < 0x00800000)\n   {\n    y = x OP x;\n    if (y != x)\n      {\n       ieee_float_shape_type sf_u;\n       sf_u.word = hx;\n       y = sf_u.value;\n       return y;\n      }\n   }\n {\n  ieee_float_shape_type sf_u;\n  sf_u.word = hx;\n  x = sf_u.value;\n }\n return x;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980511-1.c",
    "content": "typedef unsigned int\t__kernel_dev_t;\ntypedef __kernel_dev_t\t\tdev_t;\nstruct ustat {\n};\ntypedef unsigned int kdev_t;\nstatic inline kdev_t to_kdev_t(int dev)\n{\n\tint major, minor;\n\tmajor = (dev >> 8);\n\tminor = (dev & 0xff);\n\treturn ((( major ) << 22 ) | (  minor )) ;\n}\nstruct super_block {\n};\nstruct super_block * get_super (kdev_t dev);\nint sys_ustat(dev_t dev, struct ustat * ubuf)\n{\n        struct super_block *s;\n        s = get_super(to_kdev_t(dev));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980701-1.c",
    "content": "\nshort\nfunc(void)\n{\n\tunsigned char x, y;\n\n\treturn  y | x << 8;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980706-1.c",
    "content": "void g(long long);\n\nlong long f(long long v1, long long v2, long long v3, long long v4)\n{\n  g(v1);\n  g(v2);\n  g(v3);\n  g(v4);\n  return v1 && v2;\n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980726-1.c",
    "content": "static __inline__ unsigned char BCD(unsigned char binval)\n{\n  if (binval > 99) return 0x99;\n  return (((binval/10) << 4) | (binval%10));\n}\n\nvoid int1a(unsigned char i)\n{\n    (*((unsigned char *)1)) = BCD(i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980729-1.c",
    "content": "static int\nregex_compile ()\n{\n  int  c, c1;\n  char str[6  + 1];\n  c1 = 0;\n  for (;;)\n    {\n      do { } while (0) ;\n      if (c1 == 6 )\n        break;\n      str[c1++] = c;\n    }\n}  \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980816-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef void *XtPointer;\n\ntypedef struct _WidgetRec *Widget;\ntypedef struct _WidgetClassRec *WidgetClass;\n\nextern WidgetClass commandWidgetClass;\n\ntypedef void (*XtCallbackProc)(\n    Widget \t\t ,\n    XtPointer \t\t ,\t \n    XtPointer \t\t \t \n);\n\nextern const  char XtStrings[];\n\n\ntypedef struct\t\t\t\t\t\t \n{\n\tchar\t\t\t*Name,\t\t\t \n\t\t\t\t*Label;\t\t\t \n\tXtCallbackProc\t\tCallback;\t\t \n\tXtPointer\t\tClientData;\t\t \n\tWidget\t\t\tW;\t\t\t\t \n} DialogButtonType, *DialogButtonTypePtr;\n\n \nWidget AddButtons(Widget Parent, Widget Top,\n\tDialogButtonTypePtr Buttons, size_t Count)\n{\n\tint\t\ti;\n\n\tfor (i = 0; i < Count; i++)\n\t{\n\t\tif (!Buttons[i].Label)\n\t\t\tcontinue;\n\t\tButtons[i].W  = XtVaCreateManagedWidget(Buttons[i].Name,\n\t\t\tcommandWidgetClass,\n\t\t\tParent,\n\t\t\t((char*)&XtStrings[429]) , Buttons[i].Label,\n\t\t\t\"fromHoriz\" , i ? Buttons[i-1].W : ((void *)0) ,\n\t\t\t\"fromVert\" , Top,\n\t\t\t\"resizable\" , 1 ,\n\t\t\t((void *)0) );\n\n\t\tXtAddCallback(((char*)&XtStrings[136]),\n\t\t\t\t Buttons[i].Callback, Buttons[i].ClientData);\n\t}\n\treturn(Buttons[Count-1].W);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980821-1.c",
    "content": "typedef int __int32_t;\nint __kernel_rem_pio2(int prec)\n{\n\t__int32_t i, jz;\n\tdouble fw, fq[20];\n\tswitch(prec) {\n\t    case 2:\n\t\tfw = 0.0;\n\t    case 3:\t \n\t\tfor (i=jz;i>0;i--) {\n\t\t    fw      = fq[i-1] +fq[i]; \n\t\t    fq[i-1] = fw;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/980825-1.c",
    "content": "typedef enum { FALSE, TRUE } boolean;\nenum _errorTypes { FATAL = 1, WARNING = 2, PERROR = 4 };\ntypedef struct _optionValues {\n    struct _include {\t\t \n\tboolean\tclassNames;\t \n\tboolean\tdefines;\t \n\tboolean\tenumerators;\t \n    } include;\n} optionValues;\nextern optionValues\tOption;\nstatic void applyTagInclusionList( list )\n    const char *const list;\n{\n    boolean mode = TRUE;\t \n    const char *p;\n    for (p = list  ;  *p != '\\0'  ;  ++p)\n\tswitch (*p)\n\t{\n\t    case '=':\t \n\t\tclearTagList();\n\t\tmode = TRUE;\n\t\tbreak;\n\t    case '+':\tmode = TRUE;\tbreak;\t \n\t    case '-':\tmode = FALSE;\tbreak;\t \n\t    case 'c':\tOption.include.classNames\t= mode;\t\tbreak;\n\t    case 'd':\tOption.include.defines\t\t= mode;\t\tbreak;\n\t    case 'e':\tOption.include.enumerators\t= mode;\t\tbreak;\n\t    default: error(FATAL, \"-i: Invalid tag option '%c'\", *p);\tbreak;\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981001-1.c",
    "content": "unsigned short code = 0x0000;\nunsigned short  low = 0x4000;\nunsigned short high = 0xb000;\n\nint main (void)\n{\n  if (\n         (high & 0x8000) != (low & 0x8000)\n      && ( low & 0x4000) == 0x4000\n      && (high & 0x4000) == 0\n      )\n    {\n      code ^= 0x4000;\n      low  |= 0x4000;\n    }\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981001-2.c",
    "content": "/* { dg-require-weak \"\" } */\n/* { dg-require-alias \"\" } */\n#define weak_alias(func, aliasname) \\\n\textern __typeof (func) aliasname __attribute__ ((weak, alias (#func)));\n\n#define add3(d, m, c) ((d) + (m) + (c))\n\nint\n__add3(int d, int m, int c)\n{\n  return d + m + c;\n}\n\nweak_alias (__add3, add3)\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981001-3.c",
    "content": "#define P(a, b) P1(a,b)\n#define P1(a,b) a##b\n\n#define FLT_MIN_EXP (-125)\n#define DBL_MIN_EXP (-1021)\n\n#define MIN_EXP P(FLT,_MIN_EXP)\n\n#define FLT FLT\nint f1 = MIN_EXP;\n\n#undef FLT\n#define FLT DBL\nint f2 = MIN_EXP;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981001-4.c",
    "content": "#define P(a,b) P1(a,b)\n#define P1(a,b) a##b\n\n#define ONCE(x, y) (x ?: (x = y()))\n#define PREFIX\n\nextern int P(PREFIX, init) (void);\n\nint\nfun(void)\n{\n  static int memo;\n  return ONCE(memo, P(PREFIX, init));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981006-1.c",
    "content": "/* Test that tablejump insns are correctly handled.  If the compiler\n   loses track of the jump targets, it will report that x and y can be\n   used uninitialized.\n\n   This is broken in egcs 1998/10/06 for mips in pic mode.  */\n/* { dg-do assemble } */\n/* For MIPS at least, pic is needed to trigger the problem. */\n/* { dg-options \"-w -Wuninitialized -Werror -fpic\" } */\n/* { dg-options \"-w -Wuninitialized -Werror\" { target { { rs6000-*-aix* powerpc*-*-aix* arm*-*-* fr30-*-* sh-*-hms h8300*-*-* cris-*-elf* mmix-*-* } || { ! fpic } } } } */\n/* { dg-require-effective-target label_values } */\n\nint foo (int a, int b)\n{\n  __label__ z;\n  int x; /* { dg-bogus \"warning: `.' might be used uninitialized in this function\" } */\n  int y; /* { dg-bogus \"warning: `.' might be used uninitialized in this function\" } */\n  static void *p;\n\n  switch (a) {\n  case 2:\n    x = 4;\n    break;\n  case 4:\n    x = 6;\n    break;\n  case 8: case 10: case 13: case 11: case 17: case 19:\n    x = 7;\n    break;\n  default:\n    x = -1;\n    break;\n  }\n  switch (b) {\n  case 2:\n    y = 4;\n    break;\n  case 4:\n    y = 6;\n    break;\n  case 8: case 10: case 13: case 11: case 17: case 19:\n    y = 7;\n    break;\n  default:\n    y = -1;\n    break;\n  }\n z:\n  p = &&z;\n  return x * y;\n}\nint main (int argc, char *argv[])\n{\n  return 1 == foo (argc, argc + 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981007-1.c",
    "content": "extern double fabs (double);\nextern double sqrt (double);\n\ntypedef struct complexm {\n  double re,im;\n} complex;\n\nstatic complex\nsetCom (double r, double i)\n{\n  complex ct;\n  ct.re=fabs(r)<1E-300?0.0:r;\n  ct.im=fabs(i)<1E-300?0.0:i;\n  return ct;\n}\n\nstatic complex\ncsqrt_crash (double x)\n{\n  return (x>=0) ? setCom(sqrt(x),0) : setCom(0,sqrt(-x));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981107-1.c",
    "content": "unsigned long seed(void)\n{\n    unsigned long u;\n\n    call();\n\n    u = 26107 * (unsigned long)&u;\n    return u;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/981223-1.c",
    "content": "/* The problem on IA-64 is that the assembler emits\n\n   Warning: Additional NOP may be necessary to workaround Itanium\n   processor A/B step errata  */\n\n/* { dg-prune-output \"Assembler messages\" } */\n/* { dg-prune-output \"Additional NOP may be necessary\" } */\n\n\n__complex__ float\nfunc (__complex__ float x)\n{\n    if (__real__ x == 0.0)\n\treturn 1.0;\n    else\n\treturn 0.0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990107-1.c",
    "content": "static int\njava_double_finite (d)\n     double  d;\n{\n  long long  *ip = (long long  *) &d;\n  return (*ip & 0x7ff0000000000000LL ) != 0x7ff0000000000000LL ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990117-1.c",
    "content": "static void\n__bb_init_prg ()\n{\n  const char *p;\n\n      {\n\tunsigned long l;\n\n\t(__extension__ (__builtin_constant_p (p) && __builtin_constant_p (l)\n\t\t\t? 5 : 2));\n      }\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990203-1.c",
    "content": "int\nf (f)\n     float f;\n{\n  long long  *ip = (long long  *) &f;\n  return (*ip & 0x7ff0000000000000LL ) != 0x7ff0000000000000LL ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990517-1.c",
    "content": "/* Extracted from the sdm module in perl.  */\ntypedef struct {\n\tchar *dptr;\n\tint dsize;\n} datum;\nextern long sdbm_hash  (char *, int)  ;\nextern void  sdbm__putpair   (char *, datum, datum)  ;\nvoid\nsdbm__splpage (char *pag, char *New, long int sbit)\n{\n\tdatum key;\n\tdatum val;\n\tregister int n;\n\tregister int off = 1024 ;\n\tchar cur[1024 ];\n\tregister short *ino = (short *) cur;\n\t(void) memcpy(cur, pag, 1024 );\n\t(void) ({ void *__s = ( pag ); __builtin_memset ( __s , '\\0',     1024   ) ; __s; });\n\t(void) ({ void *__s = ( New ); __builtin_memset ( __s , '\\0',     1024   ) ; __s; });\n\tn = ino[0];\n\tfor (ino++; n > 0; ino += 2) {\n\t\tkey.dptr = cur + ino[0]; \n\t\tkey.dsize = off - ino[0];\n\t\tval.dptr = cur + ino[1];\n\t\tval.dsize = ino[0] - ino[1];\n\t\t(void) sdbm__putpair ((sdbm_hash(( key ).dptr, ( key ).dsize)  & sbit) ? New : pag, key, val);\n\t\toff = ino[1];\n\t\tn -= 2;\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990519-1.c",
    "content": "  typedef int   gboolean;\n\n  typedef struct{\n    gboolean names : 1;\n    gboolean types : 1;\n  } ParamOptions;\n\n  int p_param(ParamOptions* o){\n    return o->types && o->names;\n  }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990523-1.c",
    "content": "extern float  decwin[512+32];\n\nint synth_1to1(float  *bandPtr,int channel,unsigned char *out,int *pnt)\n{\n  static const int step = 2;\n  short *samples = (short *) (out+*pnt);\n\n  float  *b0;\n  int clip = 0; \n  int bo1;\n\n  {\n    register int j;\n    float  *window = decwin + 16 - bo1;\n    for (j=15;j;j--,b0-=0x20,window-=0x10,samples+=step)\n    {\n      float  sum;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n      sum -= *(--window) * *b0++;\n\n      if( ( sum ) > 32767.0) *( samples ) = 0x7fff; ( clip )++;  ;\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990527-1.c",
    "content": "typedef struct {\n    int dummy;\n    int width, height;           \n} XWindowAttributes;\n\ntypedef struct {\n    short x, y;\n} XPoint;\n    \nextern unsigned int ya_random (void);\nextern int XDrawPoints(XPoint*, int);\n\nstatic int iterations, offset;\nstatic int  xsym, ysym;\n\nstatic void\nhurm (void)\n{\n  XWindowAttributes xgwa;\n  int xlim, ylim, x, y, i;\n  XPoint points [4];\n\n\n  for (i = 0; i < iterations; i++)\n    {\n      int j = 0;\n      j++;\n      if (xsym)\n        {\n          points [j].x = xlim - x;\n          j++;\n        }\n      points [j].x = x;\n      j++;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990617-1.c",
    "content": "/* { dg-do assemble } */\n/* { dg-require-effective-target ptr32plus } */\n\nint main()\n{\n    do {\n        long l;\n        long *p = &l;\n        \n        *p = 0x0000000070000000L;\n        p += 2;\n        {\n            unsigned int *addr = (unsigned int *)0x70000000;\n            printf(\"%d, %d\\n\", addr[1], addr[0]);\n        }\n        \n    } while (1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990625-1.c",
    "content": "#define __USE_STRING_INLINES\n#include <string.h>\n\nvoid test()\n{\n        char *p, *a;\n        const char *s;\n\n        while ( (s = a) )\n          p = strcpy(strcpy(p,\"/\"), s);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990625-2.c",
    "content": "void\nbroken030599(int *n)\n{\n  int i, x;\n  for (i = 0; i < 32; i++) {\n    x=0;\n    x++;\n    if (i & 4)\n      x++;\n    x++;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990801-1.c",
    "content": "extern int getch();\nextern int class();\n\nint\ntoken()\n{\n    int state = 1;\n\n    while (1) {\n\tint c=0;\n\tc = getch();\n\tswitch (state) {\n\tcase 1: break;\n\tcase 4: break;\n\tcase 5: break;\n\tcase 6: \n            {\n\t        switch (class(c)) {\n\t        default: break;\n\t        }\n\t    } break;\n\tcase 7:\tbreak;\n\t}\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990801-2.c",
    "content": "void f()\n{\n    extern char* p;\n    int ch;\n    while (!(ch = 0)) {\n        if ((ch == 0) || (ch == 2)) {\n            break;\n        }\n        *p = 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990829-1.c",
    "content": "struct x\n{\n  int a:16;\n  int b:16;\n  int c;\n};\n\nbar()\n{\n  struct x y;\n  y.b = 1 < y.a;\n  foo(&y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990913-1.c",
    "content": " \nint f()\n{\n  unsigned char hrs, min;\n\n  min = ((min / 10) << 4) + min % 10;\n  hrs = ((hrs / 10) << 4) + hrs % 10;\n\n  return hrs + min;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/990928-1.c",
    "content": "/* Make sure that debug information can be generated\n   for inline functions containing incomplete type\n   declarations.  */\ninline int foo (void)\n{\n   struct imcomplete1 * ptr1;\n   union incomplete2 * ptr2;\n   enum incomplete3 * ptr3;\n   return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991008-1.c",
    "content": "typedef struct {\n    int x;\n} FILE;\nextern void fputs (const char *, FILE *);\n\nint mView;\nvoid foo (FILE * out, int aIndent)\n{\n    if (0 != mView) {\n\taIndent++;\n\taIndent--;\n\t{\n\t    int __t = aIndent;\n\t    while (--__t >= 0)\n\t\tfputs (\"  \", out);\n\t}\n\n    } {\n\tint __t = aIndent;\n\twhile (--__t >= 0)\n\t    fputs (\"  \", out);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991026-1.c",
    "content": "void something_f(float);\n\nint foo(void)\n{\n  union\n  {\n    float f;\n    double d;\n  } u, *pu = &u;\n\n  u.f = 1.0;\n  something_f(u.f);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991026-2.c",
    "content": "typedef int __pid_t;\t\t\t \nextern __pid_t fork  (void)    ;\nextern int printf  (__const char *__restrict __format, ...)    ;\nextern char *strerror  (int __errnum)    ;\nextern int errno;\nextern int *__errno_location  (void)     __attribute__ ((__const__));\nextern void _exit  (int __status)   __attribute__ ((__noreturn__));\nextern void exit  (int __status)     __attribute__ ((__noreturn__));\nextern int close  (int __fd)    ;\nextern int dup  (int __fd)    ;\nextern int open  (__const char *__file, int __oflag, ...)    ;\n\n\nchar\tmyname[]=\"foo\";\n\ndetach()\n{\n\tswitch(fork()) {\n\t    case -1:\n\t\tprintf(\"%s: Error: fork - %s\\n\",myname, strerror((*__errno_location ()) ));\n\t\texit(255);\n\t    case 0:\n\t\t \n\t\tclose(0);\n\t\tclose(1);\n\t\tclose(2);\n\t\tdup(dup(open(\"/dev/null\", 02 )));\n\t\treturn;\n\t    default:\n\t\t \n\t\t_exit(0);\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991127-1.c",
    "content": "\nextern void foo (int *);\n\nstatic void bar (char *buf)\n{\n    int a;\n    foo (&a);\n    while (a > 0) {\n\t*buf++ = '0';\n\ta--;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991202-1.c",
    "content": "extern float A[], B[];\nextern float MAXNUMF;\nfloat chbevlf(float, float *, int);\nfloat expf(float), i1f(float), logf(float), sqrtf(float);\n\nfloat k1f(float xx)\n{\n  float x, y;\n\n  x = xx;\n  if( x <= 2.0 )\n    {\n      y = x * x - 2.0;\n      y =  logf( 0.5f * x ) * i1f(x)  +  chbevlf( y, A, 7 ) / x;\n      return( y );\n    }\n  return(  expf(-x) * chbevlf( (float)(8.0/x - 2.0), B, 10 ) / sqrtf(x) );\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991208-1.c",
    "content": "void fn (char *ptr)\n{\n  void *p = ptr - 8 - 4;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991213-1.c",
    "content": "typedef __complex__ double double_complex;\n\n\n\nvoid\np (const double_complex *t, int n)\n{\n  int i;\n  double s = ({ typeof ( t[n/2] ) arg = ( t[n/2] ); (__imag__ arg); }) ;\n  for (i = 1; i < n/2; i++)\n    s += 2* ({ typeof ( t[i] ) arg = ( t[i] ); (__imag__ arg); }) ;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991213-2.c",
    "content": "typedef long\t\t__kernel_time_t;\ntypedef __kernel_time_t\t\ttime_t;\ntime2(\n    void (* const  (funcp)(time_t)),\n    const long offset, int * const okayp)\n{\n\tregister int\t\t\tbits;\n\ttime_t\t\t\t\tt;\n\tfor (bits = 0, t = 1; t > 0; ++bits, t <<= 1)\n\t\t;\n\tt = (t < 0) ? 0 : ((time_t) 1 << bits);\n\tfor ( ; ; ) {\n\t\t(*funcp)((time_t)&t);\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991213-3.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nint jump () { goto * (int (*) ()) 0xbabebec0; }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991214-1.c",
    "content": "void foo(double bar[], double *zp, int n)\n{\n   int i, j;\n\n   i = 0;\n   for(j = 0; j < n; j++)\n   {\n      i += j+1;\n      bar[i] *= (1.0 + *zp);\n   }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991214-2.c",
    "content": "#if defined(STACK_SIZE) && (STACK_SIZE < 65536)\n# define HISTO_SIZE 9\n#else\n# define HISTO_SIZE 36\n#endif\n\nextern int N;\nextern int nrows;\nextern int or_num_angles;\n\ntypedef struct\n{\n  double value;\n  int count;\n}Histo;\n\nHisto add_histo[10][2][HISTO_SIZE][HISTO_SIZE];\n\nvoid cmd_connection_statistics( )\n{\n  int i,j,k,m;\n\n  for(i=0; i<nrows; i++){\n      for(j=0; j< 2; j++)\n\tfor(k=0; k< or_num_angles; k++)\n\t;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991229-1.c",
    "content": "static int parse (int, int);\nstatic int parseStmt (int, int);\n\nejEval()\n{\n\tint\t\tstate;\n\tstate = parse(8  , 0x1 );\n}\nstatic int parse(int state, int flags)\n{\n\tswitch (state) {\n\tcase 8 :\n\tcase 18 :\n\tcase 6 :\n\tcase 2 :\n\t\tstate = parseStmt(state, flags);\n\t\tbreak;\n\t}\n}\nstatic int parseStmt(int state, int flags)\n{\n  parse (2, flags);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991229-2.c",
    "content": "void foo ();\n\nvoid update (double* r)\n{\n  foo ();\n    {\n      register double  y1;\n      y1 = r[ 4] - r[11];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/991229-3.c",
    "content": "int m[8],b[8];\n\nint main(){\n\tint i;\n\n\tfor(;;){\n\t\tm[0] = rand();\n\t\tif(m[0] == 0){\n\t\t\tfor(i=0;i<8;i++){\n\t\t\t\tm[i] = b[i];\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG1.c",
    "content": "struct _XtTextSource {\n\t/* ... */\n    \tvoid (* SetSelection)();\n\t/* ... */\n    };\n\ntypedef struct _XtTextSource *XtTextSource;\n\ntypedef struct _TextPart {\n    \tXtTextSource source;\n\t/* ... */\n} TextPart;\n\ntypedef struct _TextRec {\n\t/* ... */\n\tTextPart    text;\n} TextRec;\n\ntypedef struct _TextRec      *TextWidget;\n\n\nvoid XtTextUnsetSelection(w)\n    TextWidget          w;\t\t   /* original is: Widget w; */\n{\n    register TextWidget ctx = (TextWidget) w;\n    void (*nullProc)() = 0;\n\n/*\n * the following line causes the error, when optimizing:\n */\n\n    if (ctx->text.source->SetSelection != nullProc) {\n\n\tfoo();\n\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG11.c",
    "content": "#define DD 2410065408\n\nunsigned\nfoo (d)\n     double d;\n{\n  return d;\n}\n\n#if foobar\n\nmain ()\n{\n#if bar\n  unsigned u = DD;\n  double d = (double) u;\n#else\n  double d = (double) DD;\n#endif\n  printf (\"%u = %u = %lf\\n\", foo ((double) DD), foo (d), d);\n}\n#else\n\nmain ()\n{\n  printf (\"%lf\\n\", (double) ((unsigned) DD));\n  foo ((double) DD);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG12.c",
    "content": "long long\nmain ()\n{\n  return 1.1e10;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG13.c",
    "content": "struct tree_common\n{\n  int uid;\n  unsigned int code : 8;\n  unsigned int code2 : 8;\n  unsigned external_attr : 1;\n  unsigned public_attr : 1;\n\n};\n\nstatic int\nduplicate_decls (x)\n     register struct tree_common *x;\n{\n  if (x->external_attr)\n    if (x->code)\n      if (x->code2)\n\tx->public_attr = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG16.c",
    "content": "setgetlen (a)\n     int *a;\n{\n  while (*a++ & 0x80000000)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG17.c",
    "content": "double d;\n\nmain()\n{\n  int i;\n\n  i = (int) d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG18.c",
    "content": "main()\n{\n  if ((signed int) 1 < (signed int) -2147483648)\n    printf(\"true\\n\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG2.c",
    "content": "BUG2 (p) int *p;\n{\n  int a = 0;\n  if (*p == a)\n    return 0;\n  else\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG21.c",
    "content": "typedef struct {\n\tint knock_on_wood;\t\t/* leave it out and it works. */\n\tint f1;\n} FOO;\n\ntypedef struct {\n\tFOO *b1;\n} BAR;\n\nNase ()\n{\n\tint i, j;\n\tFOO *foop;\n\tBAR *barp;\n\n\tfor (i = 0; i < 2; i++) {\n\t\tfoop = &barp->b1[i];\n\t\tfor (j = 0; j < foop->f1; j++) {\n\t\t\t/* dummy() */;\t\t/* put it in and it works. */\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG22.c",
    "content": "\nvoid\nRotate (float angle)\n{\n    float mag = (angle < 0) ? -angle : angle;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG23.c",
    "content": "main()\n{\n  static char static_char_array[1];\n  static char *static_char_pointer;\n  static char static_char;\n  char  char_array[1];\n  char *char_pointer;\n  char  character;\n\n  char *cp, c;\n\n  c = cp - static_char_array;   /* error */\n  c = cp - static_char_pointer;\n  c = cp - &static_char;        /* error */\n  c = cp - char_array;\n  c = cp - char_pointer;\n  c = cp - &character;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG24.c",
    "content": "struct ack {\n    char a, b, c;\n};\n\nmain()\n{\n   struct ack bad;\n\n   foo(bad);\n}\n\nfoo(c)\n   struct ack c;\n{\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG25.c",
    "content": "\nfoo (a)\n{\n  __builtin_ffs (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG3.c",
    "content": "BUG2 (p) char *p;\n{\n  int a = 0;\n  if (*p == a)\n    return 0;\n  else\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG4.c",
    "content": "int foo()\n{\n\tchar c;\n\n \treturn (c ^ 30  ) > (c ^ 40 );\n/*\n  these also get the signal :\n \treturn (c ^ 30  ) == (c ^ 40 );\n \treturn ((int)c ^ 30  ) > (c ^ 40 );\n  also fails if c is \"extern char\"\n\n  these are ok :\n \treturn (c + 30  ) > (c ^ 40 );\n \treturn (c ^ 30  ) > (c + 40 );\n \treturn (c ^ 30  ) + (c ^ 40 );\n \treturn ('a' ^ 30  ) > (c ^ 40 );\n \treturn (c ^ 40 );\n \treturn (c ^ 30  ) > (c ^ 40 );\n*/\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG5.c",
    "content": "enum bar\n{\n  one,\n  two\n};\n\nenum bar foo;\n\nvoid bar()\n{\n  switch (foo)\n  {\n    case one:\n    case two:\n      printf (\"one to two\\n\");\n    break;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/BUG6.c",
    "content": "main()\n{\n  unsigned long L;\n  double D;\n  D = L = -3;\n  printf(\"L=%lu, D=%g\\n\", L, D);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/DFcmp.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#define type double\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)((int)&glob0))\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)((int)&glob1))\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/HIcmp.c",
    "content": "#define type short\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/HIset.c",
    "content": "#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)(int)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)(int)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nint glob0, glob1;\n\n#define type short\n\nreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = reg1;  }\n\nreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = indreg1;  }\n\nreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = imm1;  }\n\nreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = limm1;  }\n\nreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adr1;  }\n\nreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrreg1;  }\n\nreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrx1;  }\n\nreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = regx1;  }\n\nindreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = reg1;  }\n\nindreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = indreg1;  }\n\nindreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = imm1;  }\n\nindreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = limm1;  }\n\nindreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adr1;  }\n\nindreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrreg1;  }\n\nindreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrx1;  }\n\nindreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = regx1;  }\n\nadr0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = reg1;  }\n\nadr0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = indreg1;  }\n\nadr0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = imm1;  }\n\nadr0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = limm1;  }\n\nadr0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adr1;  }\n\nadr0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrreg1;  }\n\nadr0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrx1;  }\n\nadr0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = regx1;  }\n\nadrreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = reg1;  }\n\nadrreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = indreg1;  }\n\nadrreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = imm1;  }\n\nadrreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = limm1;  }\n\nadrreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adr1;  }\n\nadrreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrreg1;  }\n\nadrreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrx1;  }\n\nadrreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = regx1;  }\n\nadrx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = reg1;  }\n\nadrx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = indreg1;  }\n\nadrx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = imm1;  }\n\nadrx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = limm1;  }\n\nadrx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adr1;  }\n\nadrx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrreg1;  }\n\nadrx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrx1;  }\n\nadrx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = regx1;  }\n\nregx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = reg1;  }\n\nregx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = indreg1;  }\n\nregx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = imm1;  }\n\nregx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = limm1;  }\n\nregx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adr1;  }\n\nregx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrreg1;  }\n\nregx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrx1;  }\n\nregx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = regx1;  }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/PYRBUG.c",
    "content": "typedef struct\n{\n  int v;\n  int h;\n} Point;\n\ntypedef struct\n{\n  int top, left, bottom, right;\n} Rect;\n\nint\nx_PtInRect (Point pt, Rect *r)\n{\n  return  pt.v >= r->top  && pt.v < r->bottom\n    && pt.h >= r->left && pt.h < r->right;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/QIcmp.c",
    "content": "#define type signed char\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)11111111)\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/QIset.c",
    "content": "#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)(int)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)11111111)\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)(int)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nint glob0, glob1;\n\n#define type char\n\nreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = reg1;  }\n\nreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = indreg1;  }\n\nreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = imm1;  }\n\nreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = limm1;  }\n\nreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adr1;  }\n\nreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrreg1;  }\n\nreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrx1;  }\n\nreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = regx1;  }\n\nindreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = reg1;  }\n\nindreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = indreg1;  }\n\nindreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = imm1;  }\n\nindreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = limm1;  }\n\nindreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adr1;  }\n\nindreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrreg1;  }\n\nindreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrx1;  }\n\nindreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = regx1;  }\n\nadr0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = reg1;  }\n\nadr0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = indreg1;  }\n\nadr0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = imm1;  }\n\nadr0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = limm1;  }\n\nadr0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adr1;  }\n\nadr0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrreg1;  }\n\nadr0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrx1;  }\n\nadr0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = regx1;  }\n\nadrreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = reg1;  }\n\nadrreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = indreg1;  }\n\nadrreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = imm1;  }\n\nadrreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = limm1;  }\n\nadrreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adr1;  }\n\nadrreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrreg1;  }\n\nadrreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrx1;  }\n\nadrreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = regx1;  }\n\nadrx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = reg1;  }\n\nadrx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = indreg1;  }\n\nadrx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = imm1;  }\n\nadrx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = limm1;  }\n\nadrx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adr1;  }\n\nadrx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrreg1;  }\n\nadrx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrx1;  }\n\nadrx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = regx1;  }\n\nregx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = reg1;  }\n\nregx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = indreg1;  }\n\nregx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = imm1;  }\n\nregx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = limm1;  }\n\nregx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adr1;  }\n\nregx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrreg1;  }\n\nregx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrx1;  }\n\nregx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = regx1;  }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/SFset.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)(int)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)(int)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nint glob0, glob1;\n\n#define type float\n\nreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = reg1;  }\n\nreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = indreg1;  }\n\nreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = imm1;  }\n\nreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = limm1;  }\n\nreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adr1;  }\n\nreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrreg1;  }\n\nreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrx1;  }\n\nreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = regx1;  }\n\nindreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = reg1;  }\n\nindreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = indreg1;  }\n\nindreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = imm1;  }\n\nindreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = limm1;  }\n\nindreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adr1;  }\n\nindreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrreg1;  }\n\nindreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrx1;  }\n\nindreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = regx1;  }\n\nadr0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = reg1;  }\n\nadr0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = indreg1;  }\n\nadr0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = imm1;  }\n\nadr0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = limm1;  }\n\nadr0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adr1;  }\n\nadr0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrreg1;  }\n\nadr0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrx1;  }\n\nadr0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = regx1;  }\n\nadrreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = reg1;  }\n\nadrreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = indreg1;  }\n\nadrreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = imm1;  }\n\nadrreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = limm1;  }\n\nadrreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adr1;  }\n\nadrreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrreg1;  }\n\nadrreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrx1;  }\n\nadrreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = regx1;  }\n\nadrx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = reg1;  }\n\nadrx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = indreg1;  }\n\nadrx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = imm1;  }\n\nadrx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = limm1;  }\n\nadrx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adr1;  }\n\nadrx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrreg1;  }\n\nadrx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrx1;  }\n\nadrx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = regx1;  }\n\nregx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = reg1;  }\n\nregx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = indreg1;  }\n\nregx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = imm1;  }\n\nregx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = limm1;  }\n\nregx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adr1;  }\n\nregx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrreg1;  }\n\nregx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrx1;  }\n\nregx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = regx1;  }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/SIcmp.c",
    "content": "#define type int\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/SIset.c",
    "content": "#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)(int)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)(int)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nint glob0, glob1;\n\n#define type int\n\nreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = reg1;  }\n\nreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = indreg1;  }\n\nreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = imm1;  }\n\nreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = limm1;  }\n\nreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adr1;  }\n\nreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrreg1;  }\n\nreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = adrx1;  }\n\nreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{reg0 = regx1;  }\n\nindreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = reg1;  }\n\nindreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = indreg1;  }\n\nindreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = imm1;  }\n\nindreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = limm1;  }\n\nindreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adr1;  }\n\nindreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrreg1;  }\n\nindreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = adrx1;  }\n\nindreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{indreg0 = regx1;  }\n\nadr0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = reg1;  }\n\nadr0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = indreg1;  }\n\nadr0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = imm1;  }\n\nadr0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = limm1;  }\n\nadr0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adr1;  }\n\nadr0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrreg1;  }\n\nadr0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = adrx1;  }\n\nadr0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adr0 = regx1;  }\n\nadrreg0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = reg1;  }\n\nadrreg0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = indreg1;  }\n\nadrreg0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = imm1;  }\n\nadrreg0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = limm1;  }\n\nadrreg0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adr1;  }\n\nadrreg0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrreg1;  }\n\nadrreg0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = adrx1;  }\n\nadrreg0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrreg0 = regx1;  }\n\nadrx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = reg1;  }\n\nadrx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = indreg1;  }\n\nadrx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = imm1;  }\n\nadrx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = limm1;  }\n\nadrx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adr1;  }\n\nadrx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrreg1;  }\n\nadrx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = adrx1;  }\n\nadrx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{adrx0 = regx1;  }\n\nregx0reg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = reg1;  }\n\nregx0indreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = indreg1;  }\n\nregx0imm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = imm1;  }\n\nregx0limm1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = limm1;  }\n\nregx0adr1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adr1;  }\n\nregx0adrreg1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrreg1;  }\n\nregx0adrx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = adrx1;  }\n\nregx0regx1_set (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{regx0 = regx1;  }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/UHIcmp.c",
    "content": "#define type unsigned short\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/UQIcmp.c",
    "content": "#define type unsigned char\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)11111111)\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/USIcmp.c",
    "content": "#define type unsigned int\n\ntype glob0, glob1;\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)(11111111 & ~(__alignof__ (type) - 1)))\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= reg1) return 1; else return 0;}\n\nreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= indreg1) return 1; else return 0;}\n\nreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= imm1) return 1; else return 0;}\n\nreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= limm1) return 1; else return 0;}\n\nreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adr1) return 1; else return 0;}\n\nreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrreg1) return 1; else return 0;}\n\nreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= adrx1) return 1; else return 0;}\n\nreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (reg0 <= regx1) return 1; else return 0;}\n\nindreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= reg1) return 1; else return 0;}\n\nindreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= indreg1) return 1; else return 0;}\n\nindreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= imm1) return 1; else return 0;}\n\nindreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= limm1) return 1; else return 0;}\n\nindreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adr1) return 1; else return 0;}\n\nindreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrreg1) return 1; else return 0;}\n\nindreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= adrx1) return 1; else return 0;}\n\nindreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (indreg0 <= regx1) return 1; else return 0;}\n\nimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= reg1) return 1; else return 0;}\n\nimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= indreg1) return 1; else return 0;}\n\nimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= imm1) return 1; else return 0;}\n\nimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= limm1) return 1; else return 0;}\n\nimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adr1) return 1; else return 0;}\n\nimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrreg1) return 1; else return 0;}\n\nimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= adrx1) return 1; else return 0;}\n\nimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (imm0 <= regx1) return 1; else return 0;}\n\nlimm0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= reg1) return 1; else return 0;}\n\nlimm0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= indreg1) return 1; else return 0;}\n\nlimm0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= imm1) return 1; else return 0;}\n\nlimm0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= limm1) return 1; else return 0;}\n\nlimm0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adr1) return 1; else return 0;}\n\nlimm0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrreg1) return 1; else return 0;}\n\nlimm0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= adrx1) return 1; else return 0;}\n\nlimm0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (limm0 <= regx1) return 1; else return 0;}\n\nadr0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= reg1) return 1; else return 0;}\n\nadr0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= indreg1) return 1; else return 0;}\n\nadr0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= imm1) return 1; else return 0;}\n\nadr0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= limm1) return 1; else return 0;}\n\nadr0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adr1) return 1; else return 0;}\n\nadr0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrreg1) return 1; else return 0;}\n\nadr0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= adrx1) return 1; else return 0;}\n\nadr0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adr0 <= regx1) return 1; else return 0;}\n\nadrreg0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= reg1) return 1; else return 0;}\n\nadrreg0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= indreg1) return 1; else return 0;}\n\nadrreg0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= imm1) return 1; else return 0;}\n\nadrreg0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= limm1) return 1; else return 0;}\n\nadrreg0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adr1) return 1; else return 0;}\n\nadrreg0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrreg1) return 1; else return 0;}\n\nadrreg0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= adrx1) return 1; else return 0;}\n\nadrreg0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrreg0 <= regx1) return 1; else return 0;}\n\nadrx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= reg1) return 1; else return 0;}\n\nadrx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= indreg1) return 1; else return 0;}\n\nadrx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= imm1) return 1; else return 0;}\n\nadrx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= limm1) return 1; else return 0;}\n\nadrx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adr1) return 1; else return 0;}\n\nadrx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrreg1) return 1; else return 0;}\n\nadrx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= adrx1) return 1; else return 0;}\n\nadrx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (adrx0 <= regx1) return 1; else return 0;}\n\nregx0reg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= reg1) return 1; else return 0;}\n\nregx0indreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= indreg1) return 1; else return 0;}\n\nregx0imm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= imm1) return 1; else return 0;}\n\nregx0limm1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= limm1) return 1; else return 0;}\n\nregx0adr1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adr1) return 1; else return 0;}\n\nregx0adrreg1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrreg1) return 1; else return 0;}\n\nregx0adrx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= adrx1) return 1; else return 0;}\n\nregx0regx1 (r0, r1, x0, x1, p0, p1)\ntype r0, r1;  type *p0, *p1;\n{if (regx0 <= regx1) return 1; else return 0;}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/a.c",
    "content": "foo (a)\n{\n  return a & 65535;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/a1.c",
    "content": "int\nfoo (a, p)\n     int *p;\n{\n  p[0] = 85 * a;\n  p[1] = -86 * a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/a3.c",
    "content": "foo (a)\n{\n  int i;\n\n  for (i = 1;  i < a; i++)\n    ;\n  {\n    int b = (int) &foo;\n\n    return (a & b) == 0;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/aa.c",
    "content": "#define w 20\n#define c 1\n\nfoo (a)\n     unsigned a;\n{\n  return ((a & ((1 << w) - 1)) << c) > 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/aaa.c",
    "content": "foo (a, b)\n{\n  int t;\n  while (b < 0)\n    {\n      t = a;\n      a = b;\n      b = t;\n    }\n  return a + b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/abs.c",
    "content": "foo (a)\n{\n  return __builtin_abs (a);\n}\n\nmain ()\n{\n  printf (\"%d %d\\n\", foo (0x80000000), foo (12));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ac.c",
    "content": "barfoo (a)\n{\n  return (a << 16) & ~0xffff;\n}\n\nfoobar (a)\n{\n  return ((unsigned short) a) << 15;}\n\nfoo (a)\n{\n  return (a & 0x121) << 31;\n}\n\nbar (a)\n{\n  return (a & ~0xffff) << 16;\n}\n\nmain ()\n{\n  int a;\n\n  for (a = 1;  a; a += a)\n    {\n      printf (\"%d\", (foo (a)));\n    }\n  puts (\"\");\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/acc.c",
    "content": "foo (a)\n{\n  int b = a + 1;\n  int c = (short) a;\n  if (b)\n    return b;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/acc1.c",
    "content": "/* { dg-options \"-ffast-math\" } */\n\n/* Fast maths allows tail recursion to be turned into iteration.  */\n\ndouble\nfoo (int n, double f)\n{\n  if (n == 0)\n    return f;\n  else\n    return f + foo (n - 1, f);\n}\n\ndouble\nbar (int n, double f)\n{\n  if (n == 0)\n    return f;\n  else\n    return f * bar (n - 1, f);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/add.c",
    "content": "foo (a, b, p)\n     int *p;\n{\n  return 34 + *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/add386.c",
    "content": "main (a)\n{\n  return a + 128;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/addcc.c",
    "content": "foo (p, a, b)\n     int *p;\n     int a;\n     int b;\n{\n\n  a += p[0];\n  b += p[1];\n  if (a == 0)\n    return b;\n  return a;\n}\n\n\nbar (a)\n{\n  return -a > 0 ? 1 : 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andm.c",
    "content": "foo (p)\n     int *p;\n{\n  return (*p & 255) == 0;\n}\n\nbar (a)\n{\n  return (a & 0xfff00000) == 0;\n}\n\nmain ()\n{\n  printf (\"%d%d\\n\", bar (-1), bar(0));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andmem.c",
    "content": "void p1 (p) int *p;\n{ *p &= ~0xff;\n}\nvoid p2 (p) int *p;\n{ *p &= ~0xff00;\n}\nvoid p3 (p) int *p;\n{ *p &= ~0xffff0000;\n}\nvoid p4 (p) int *p;\n{ *p &= ~0xffff;\n}\n\nmain ()\n{\n  int a;\n\n  a = 0x12345678;  p1 (&a);  printf (\"%x\\n\", a);\n  a = 0x12345678;  p2 (&a);  printf (\"%x\\n\", a);\n  a = 0x12345678;  p3 (&a);  printf (\"%x\\n\", a);\n  a = 0x12345678;  p4 (&a);  printf (\"%x\\n\", a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andn.c",
    "content": "foo (a)\n{\n  int b = 0x1fff;\n  return a & ~b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andok.c",
    "content": "foo (a, b, p)\n     int *p;\n{\n  p[1] = a & 0xfff0000;\n  p[2] = b & 0xfff0000;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andsi.c",
    "content": "foo ()\n{\n  return (int)&foo;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/andsparc.c",
    "content": "foo (int *p)\n{\n  int a, b;\n\n  a = 123456;\n  a += p[0];\n  b = p[0];\n  if (a == 0)\n    return b;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/aos.c",
    "content": "foo (p)\n     int *p;\n{\n  if ((int) p > 0)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/arr.c",
    "content": "foo (a, b, c)\n{\n  bar (a, b);\n  {\n    int arr[10];\n    arr[c] = b;\n    bar (arr[0], arr[1]);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/as.c",
    "content": "\n#define S 31\n#define A 17\n\nfoo (a)\n     unsigned a;\n{\n  return (a >> S) & ((1 << A) - 1);\n}\n\nmain ()\n{\n  printf (\"%d%d\\n\", foo (-1), foo (0));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ase.c",
    "content": "ase (p)\n     short *p;\n{\n  int a;\n  a = p[1];\n  p[2] = a;\n  if ((short) a)\n    p[a]++;\n  return (a == 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/asmgoto-1.c",
    "content": "void fn (void);\n\nvoid\nfoo (void *x, unsigned long y)\n{\n  asm goto (\"\": : : : lab);\nlab:\n  fn ();\n}\n\nstatic void\nbar (unsigned long x)\n{\n  foo (0, x);\n}\n\nstatic void\nbaz (unsigned long x)\n{\n  if (x > 8192)\n    bar (x);\n  else\n    ({ __here: (unsigned long) &&__here; });\n}\n\nvoid\ntest (void)\n{\n  baz (16384);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/b.c",
    "content": "main ()\n{\n  *(short *) 25 = 123;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/b1.c",
    "content": "foo (long long x)\n{\n  if (x--)\n    return 255;\n  return 0;\n}\n\nmain ()\n{\n  printf (\"%d\\n\", foo (0));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/b2.c",
    "content": "\nstruct s\n{\n  unsigned a : 8;\n  unsigned b : 8;\n  unsigned c : 8;\n  unsigned d : 8;\n};\n\n/*\nstruct\n{\n  unsigned a : 8;\n  unsigned b : 16;\n  unsigned c : 8;\n};\n*/\n\nstruct s\nfoo (struct s s, int i)\n{\n  s.b = i;\n  return s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/b3.c",
    "content": "struct tree_common\n{\n  unsigned int code : 9;\n  unsigned int code2 : 7;\n};\n\nstatic int\nduplicate_decls (x)\n     register struct tree_common x;\n{\n  return x.code2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/b88.c",
    "content": "foo (double d)\n{\n  d = -d;\n  if (d < 0.0)\n    return 1;\n  return 2;\n}\n\nmain ()\n{\n  foo (0.0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bad.c",
    "content": "typedef union longlong\n{\n  struct {unsigned short h0, h1, h2, h3;} h;\n  struct {signed long low, high;} si;\n  struct {unsigned long low, high;} ui;\n  signed long long sll;\n  unsigned long long ull;\n} long_long;\n\n\nlong long\n__negdi2 (u)\n     long long u;\n{\n  long_long uu;\n\n  uu.sll = u;\n\n  uu.si.low = -uu.si.low;\n  if (uu.si.low == 0)\n    uu.si.high = -uu.si.high;\n  else\n    uu.si.high = ~uu.si.high;\n\n  return uu.sll;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/band.c",
    "content": "foo (a)\n{\n  return (a & (1 << 31)) != 0;\n}\n\nmain ()\n{\n  if (foo (0))\n    puts (\"foo\");\n  else\n    puts (\"bar\");\n  if (foo (~0))\n    puts (\"foo\");\n  else\n    puts (\"bar\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bb0.c",
    "content": "foo (a)\n{\n  return (a & 0xfff000) != 0;\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bb1.c",
    "content": "foo (a)\n{\n  int b = 32;\n  if (b & a)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bbb.c",
    "content": "struct looksets\n    {\n        int lset[10];\n    };\n\nstruct looksets lkst[];\n\nflset( p )\nstruct looksets *p;\n{\n    p-- > lkst;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bc.c",
    "content": "foo (a, b)\n{\n  return a % (1 << b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bcopy-1.c",
    "content": "/* PR middle-end/31095, expand_builtin_memmove_args forgot to take into\n   account that tree folding of builtins can add an extra NOP_EXPR.   */\n\nstruct timeval\n{\n  int tv_sec;\n  int tv_usec;\n};\nvoid\ncapture_next_packet (void)\n{\n  struct timeval past, now, then;\n  __builtin_bcopy (&then, &past, sizeof (then));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bcopy.c",
    "content": "void\nbcopy1 (s, d, c)\n     long long *s;\n     long long *d;\n     int c;\n{\n  int i;\n  c = c / 8;\n  for (i = 0;  i < c;  i++)\n    d[i] = s[i];\n}\n\nvoid\nbcopy2 (s, d, c)\n     long *s;\n     long *d;\n     int c;\n{\n  int i;\n  c = c / 4;\n  for (i = 0;  i < c;  i++)\n    d[i] = s[i];\n}\n\n\nvoid\nbcopy3 (s, d, c)\n     char *s;\n     char *d;\n     int c;\n{\n  long long z0, z1;\n  int r = d - s;\n\n  int i;\n\n  c /= 16;\n\n  z0 = *((long long *) s);\n  s += 8;\n  z1 = *((long long *) s);\n  s += 8;\n  for (i = 0; i < c; i++)\n    {\n      *(long long *)(s + r) = z0;\n      z0 = *((long long *) s);\n      s += 8;\n      *(long long *)(s + r) = z1;\n      z1 = *((long long *) s);\n      s += 8;\n    }\n}\n\n#if defined(STACK_SIZE) && STACK_SIZE < 16384\n#define BYTES STACK_SIZE\n#else\n#define BYTES 16384\n#endif\n\nmain ()\n{\n  long long s[BYTES / 8];\n  long long d[BYTES / 8];\n  int i;\n\n  for (i = 1; i < 67108864 / BYTES; i++)\n    bcopy (s, d, BYTES);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bf.c",
    "content": "typedef unsigned long uint32;\ntypedef signed long sint32;\n\nuint32\next (sint32 src, unsigned o5, unsigned w5)\n{\n  return (w5 == 0) ? src >> o5 : (src << (( - o5 - w5) & 31)) >> (32 - w5);\n}\n\nuint32\nextu (uint32 src, unsigned o5, unsigned w5)\n{\n  return (w5 == 0) ? src >> o5 : (src << (( - o5 - w5) & 31)) >> (32 - w5);\n}\n\nuint32\nmak (uint32 src, unsigned o5, unsigned w5)\n{\n  return (w5 == 0) ? src << o5 : (src << (32 - w5)) >> (( - o5 - w5) & 31);\n}\n\nuint32\nrot (uint32 src, unsigned o5)\n{\n  return (src >> o5) | (src << (( - o5) & 31));\n}\n\nmain (int argc, char **argv)\n{\n  printf (\"%x\\n\", clr (0xffffffff, atoi (argv[2]), atoi (argv[1])));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bfins.c",
    "content": "struct foo\n{\n  unsigned j : 16;\n  unsigned i : 16;\n};\n\nstruct foo\nfoo (a, b)\n     struct foo a;\n     int b;\n{\n  a.j = 123;\n  a.i = b;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bfx.c",
    "content": "foo (x, c)\n{\n  return x << -c;\n}\n\nmain ()\n{\n  printf (\"%x\\n\", foo (0xf05, -4));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bge.c",
    "content": "foo (a)\n     double a;\n{\n  if (a >= 0)\n    return 1;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bit.c",
    "content": "bar (a)\n{\n  return (a == 0);\n}\n\nfoo (a)\n     int a;\n{\n  if ((a & (1 << 26)) >= 0)\n    return 1;\n  else\n    return 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bitf.c",
    "content": "#define int unsigned\n\nstruct foo\n{\n  int aa : 1;\n  int a : 9;\n  int c : 16;\n  int d : 6;\n};\n\n\nint\nfoo (a, b)\n     struct foo a;\n{\n  return a.d == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bitw.c",
    "content": "foo (a)\n     unsigned a;\n{\n  unsigned b = 0;\n\n  if ((a & 12345678) > b)\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/blk.c",
    "content": "struct\n{\n  double a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t;\n} foo, bar;\n\nfoobar ()\n{\n  foo = bar;\n  xxx (&foo, &bar);\n}\n\nmain ()\n{\n  bar.g = 1.0;\n  foo.g = 2.0;\n  foobar ();\n  printf (\"%lf\\n\", foo.g);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bt.c",
    "content": "main ()\n{\n  int i;\n\n  for (i = 1000000; --i;)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bt386.c",
    "content": "foo (a, b)\n{\n  return (a & (1 << b)) != 0;\n}\n\nbar (a, b)\n{\n  a ^= (1 << b);\n  return a != 0;\n}\n\nmain ()\n{\n  int i;\n  for (i = 0; i < 32; i++)\n    printf (\"%d \", foo (0x8000000f, i));\n  puts (\"\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bug.c",
    "content": "foo (a, b)\n{\n  return a - 65536;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bugc.c",
    "content": "\nint\nreg0indreg1 (r0, p1)\n     short  r0;  short *p1;\n{\n  return (r0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/builtin_constant_p.c",
    "content": "int main (int argc, char *argv[])\n{\n  static int a[] = { __builtin_constant_p (argc) ? 1 : 0 };\n  return a[0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/builtin_unreachable-1.c",
    "content": "void bar (const char *);\nvoid foo (void)\n{\n  bar (\"foo\");\n  __builtin_unreachable ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/buns.c",
    "content": "foo (a)\n{\n  int bar = 0;\n\n  return (unsigned) (a - 1) <= (unsigned) bar;\n}\n\nmain ()\n{\n  if (foo (-1))\n    puts (\"The largest possible unsigned <= 0 on this machine...\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/bx.c",
    "content": "unsigned\ngood (unsigned src, unsigned o5, unsigned w5)\n{\n  return src & ~((w5 == 0) ? (~0 << o5) : (1 << o5));\n}\n\nunsigned\nbad (unsigned src, unsigned o5, unsigned w5)\n{\n  return src & ((w5 == 0) ? ~(~0 << o5) : ~(1 << o5));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/c.c",
    "content": "foo (a, b)\n     long long a, b;\n{\n  if (a & ~b)\n    return 1;\n  else\n    return 0;\n}\n\nbar (a, b)\n     long long a, b;\n{\n  if (a & ~b & ((long long) 87612378))\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/c1.c",
    "content": "unsigned\nrec (a, b)\n     unsigned a;\n     unsigned b;\n{\n  return a * rec (a - 1, b + 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/c2.c",
    "content": "foo (a)\n{\n  bar (a);\n  bar (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/call.c",
    "content": "/* { dg-skip-if \"requires untyped assembly\" { ! untyped_assembly } { \"-O0\" } { \"\" } } */\n\nint foo () {}\n\nmain (a, b)\n{\n  foo (foo (a, b), foo (b, a));\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/call386.c",
    "content": "void foo () {}\n\nint main ()\n{\n  int i;\n  for (i = 100000; i >= 0; i--)\n    {\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n      foo ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/callind.c",
    "content": "bar (foo, a)\n     int (**foo) ();\n{\n\n  (foo)[1] = bar;\n\n  foo[a] (1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/calls-void.c",
    "content": "/* { dg-require-effective-target ptr32plus } */\n/* { dg-require-effective-target untyped_assembly } */\n\ntypedef void  (*T)(void);\nf1 ()\n{\n  ((T) 0)();\n}\nf2 ()\n{\n  ((T) 1000)();\n}\nf3 ()\n{\n  ((T) 10000000)();\n}\nf4 (r)\n{\n  ((T) r)();\n}\nf5 ()\n{\n  int (*r)() = f3;\n  ((T) r)();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/calls.c",
    "content": "/* { dg-require-effective-target ptr32plus } */\n/* { dg-require-effective-target untyped_assembly } */\n\ntypedef void  *(*T)(void);\nf1 ()\n{\n  ((T) 0)();\n}\nf2 ()\n{\n  ((T) 1000)();\n}\nf3 ()\n{\n  ((T) 10000000)();\n}\nf4 (r)\n{\n  ((T) r)();\n}\nf5 ()\n{\n  int (*r)() = f3;\n  ((T) r)();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cc.c",
    "content": "cc8 (a, b)\n{\n  if (a < 0)\n    goto L1;\n    if (a == 0)\n      goto L2;\n L1:b++;\n L2:b++;\n  return b;\n}\n\ncc7 (a)\n     long long a;\n{\n  if (a < 0)\n    return 1;\n  else\n    return 0;\n}\n\ncc6 (float a, double p)\n{\n  p = a;\n  if (p < 0)\n    return p;\n  else\n    return p + 1;\n}\n\ncc5 (p, a)\n     char *p;\n     char a;\n{\n  p[2] = a;\n  if (a)\n    return 0;\n  else\n    return 1;\n}\n\n\ncc4 (a, b, p)\n     int a, b;\n     int *p;\n{\n  a = (int short)b;\n  *p = a;\n  if ((int) a < 0)\n    return 0;\n  else\n    return 1;\n}\n\n\ncc1 (a, b)\n{\n  int x = 0;\n\n  if ((int) a < (int) b)\n    {\n      if ((unsigned) a < (unsigned) b)\n\tx++;\n      x++;\n    }\n\n  return x;\n}\n\ncc2 (a, b)\n{\n  int x = 0;\n\n  if ((int) a <= (int) b)\n    {\n      if ((int) a < (int) b)\n\tx++;\n      x++;\n    }\n\n  return x;\n}\n\ncc3 (a, b)\n{\n  int x = 0;\n\n  a += b;\n  if ((unsigned) a > 0)\n    {\n      if (a == 0)\n\tx++;\n      x++;\n    }\n\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/charmtst.c",
    "content": "c_move_tst (char b)\n{\n  char a;\n\n  a = b;\n  b = 'b';\n  foo (a);\n  foo (b);\n  foo (a);\n  bar (a, b);\n  b = a;\n  if (b == 0)\n    a++;\n  return a + b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmb.c",
    "content": "foo (p1, p2)\n     short p1, *p2;\n{\n  int a;\n  return (int) p1 + (int) *p2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmp.c",
    "content": "struct fooalign {char x; double d;};\nunion fooround {long x; double d;};\n\nint\nfoo ()\n{\n  int extra = 4;\n  if (extra < sizeof (union fooround))\n    extra = sizeof (union fooround);\n  return extra;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmpdi-1.c",
    "content": "f (long long d)\n{\n  int i = 0;\n  if (d == 1)\n    i = 1;\n  return i;\n}\n\ng (long long d)\n{\n  int i = 0;\n  if (d <= 0)\n    i = 1;\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmphi.c",
    "content": "foo (short *p, short a)\n{\n  return a < *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmpsi386.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nfoo (a, p)\n     register int a;\n     int *p;\n{\n\n  for (a = 10000000; a >= *p; a--)\n    ;\n}\n\nmain ()\n{\n  int a;\n  foo (a, a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cmul.c",
    "content": "foo (a)\n{\n  return a * 84;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cn1.c",
    "content": "int\nfoo ()\n{\n  return 7561;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/comb.c",
    "content": "foo (a, b)\n{\n  int c = a & b;\n  if ((a & b) == 0)\n    return 0;\n  return c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/combine-hang.c",
    "content": "typedef union\n{\n  double value;\n  struct\n  {\n    unsigned long msw;\n    unsigned long lsw;\n  } parts;\n} ieee_double_shape_type;\n\ndouble f (int iy)\n{\n  double z, t;\n  ieee_double_shape_type u, v;\n\n  if (iy == 1)\n    return 0;\n\n  u.parts.msw = iy;\n  u.parts.lsw = 0;\n  z = u.value;\n  v.parts.msw = iy;\n  v.parts.lsw = 0;\n  t = v.value;\n  return 1.0+z+t+t;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/compile.exp",
    "content": "# Expect driver script for GCC Regression Tests\n# Copyright (C) 1993-2016 Free Software Foundation, Inc.\n#\n# This file is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n\n# These tests come from Torbjorn Granlund's (tege@cygnus.com)\n# C torture test suite, and other contributors.\n\n# Load support procs.\nload_lib gcc-dg.exp\n\n# Initialize `dg'.\ndg-init\n\n# Main loop.\nset saved-dg-do-what-default ${dg-do-what-default}\nset dg-do-what-default \"assemble\"\ngcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\\[cS\\]]] \"\" \"-w\"\nset dg-do-what-default ${saved-dg-do-what-default}\n\n# All done.\ndg-finish\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-1.c",
    "content": "extern void u (int, int);\nextern void v (float, float);\n\nvoid f (__complex__ int x)\n{\n  u (0, x);\n}\n\nvoid g (__complex__ float x)\n{\n  v (0, x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-2.c",
    "content": "/* PR 22103 */\n\n_Complex float f(void);\nvoid *a;\n\n_Complex float g(void)\n{\n  _Complex float x = f();\n  __imag__ x = 1.0;\n  if (__imag__ x != 1.0)\n    {\n      a = &x;\n    }\n  return x;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-3.c",
    "content": "/* PR 22116 */\n\nvoid g(_Complex float);\n_Complex float f(int data, _Complex float x, _Complex float y)\n{\n  _Complex float i, t;\n  if (data) \n  {\n    i = x +  __imag__ y;\n    g(i);\n  }\n  else\n    i = 5;\n  t = x + __imag__ y;\n  g(t);\n  return t * i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-4.c",
    "content": "/* This used to ICE because gimplify_modify_expr_complex_part was not\n   updated for the GIMPLE_MODIFY_EXPR changes in that calling\n   tree_to_gimple_tuple was needed.  */\n\nvoid f(void)\n{\n  double _Complex Res;\n  __real__ Res = __imag__ Res = 0.0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-5.c",
    "content": "int foo(__complex__ int z0, __complex__ int z1)\n{\n  return z0 != 0 || z1 != 0;\n}\n\nint foo1(__complex__ int z0, __complex__ int z1)\n{\n  return z0 == 0 && z1 == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/complex-6.c",
    "content": "/* PR tree-opt/35737 */\n/* { dg-require-effective-target indirect_jumps } */\n\nlong buf[10];\n\nint foo()\n{\n  __complex__ int i = 0;\n\n  if (__builtin_setjmp(buf))\n  {\n    i = 1;\n    bar();\n  }\n\n  return i == 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/compound-literal-1.c",
    "content": "/* ICE incrementing compound literal: bug 28418 from Volker Reichelt\n   <reichelt@gcc.gnu.org>.  */\n\nstruct A { int i; };\n\nvoid foo()\n{\n    ((struct A) { 0 }).i += 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/compound-literal-2.c",
    "content": "/* PR C/30265, invalid gimple was produced because we did not mark\n   the compound literal's decl early enough.  */\n\nint f(float *);\nint g(float x)\n{\n  return f(&(float){x}) + f(&x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/compound-literal-3.c",
    "content": "/* PR C/30265, invalid gimple was produced because we did not mark\n   the compound literal's decl early enough.  */\n\nint f(_Complex float *);\nint g(_Complex float x)\n{\n  return f(&(_Complex float){x+1}) + f(&x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/consec.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nint glob;\n\nconseq (a, b, c, d)\n     int *a, *b;\n{\n  a[2] = d;\n  a[1] = c;\n  sequence (a, b, c, d);\n  sequence (d, c, b, a);\n  b[0] = 0;\n  b[1] = 123;\n  a[0] = 321;\n  a[1] = 0;\n  sequence (111, 0, 0, 222, 0, 333);\n  ((int *)glob)[2] = c;\n  ((int *)glob)[3] = d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/const-high-part.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target size32plus } */\n\nchar *buf;\nint buflen;\n\ninline int\nsub (int length)\n{\n  if (length <= buflen)\n    buf[length] = '\\0';\n  return 0;\n}\n\nint\nsub2 (void)\n{\n  return sub (0x7fffffff);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/const.c",
    "content": "main (a)\n{\n  return a + (~0 - 240);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/conv.c",
    "content": "double\nu2d (unsigned int u)\n{\n  return u;\n}\n\ndouble\ni2d (signed int i)\n{\n  return i;\n}\n\nunsigned int\nd2u (double d)\n{\n  return d;\n}\n\nsigned int\nd2i (double d)\n{\n  return d;\n}\n\nmain ()\n{\n  printf (\"%lf, %lf, %lf\\n\", u2d (~0), u2d (1 << 31), u2d (1));\n  printf (\"%lf, %lf, %lf\\n\", i2d (~0), i2d (1 << 31), i2d (1));\n\n  printf (\"%u, %u, %u\\n\", d2u (u2d (~0)), d2u (u2d (1 << 31)), d2u (u2d (1)));\n  printf (\"%d, %d, %d\\n\", d2i (i2d (~0)), d2i (i2d (1 << 31)), d2i (i2d (1)));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/conv_tst.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\n#define ID_1 2400000000.0\n#define ID_2 1.7\n#define ID_3 -1.7\n\nunsigned ui;\nint si;\n\nconv_i1 ()\n{\n/*\n  ui = (unsigned) ID_1;\n  si = (int) ID_1;\n*/\n}\n\nconv_i2 ()\n{\n  ui = (unsigned) ID_2;\n  si = (int) ID_2;\n}\n\nconv_i3 ()\n{\n/*  ui = (unsigned) ID_3;*/\n  si = (int) ID_3;\n}\n\nconv_1 (d)\n     double d;\n{\n  ui = (unsigned) d;\n/*\n  si = (int) d;\n*/\n}\n\ndouble\nfoo (u)\n     unsigned u;\n{\n  return u;\n}\n\nmain ()\n{\n  printf (\"%lf\\n\", foo (2400000000));\n\n  conv_i1 ();\n  printf (\"%lf, %u, %d\\n\", ID_1, ui, si);\n\n  conv_i2 ();\n  printf (\"%lf, %u, %d\\n\", ID_2, ui, si);\n\n  conv_i3 ();\n  printf (\"%lf, %u, %d\\n\", ID_3, ui, si);\n\n  conv_1 (ID_1);\n  printf (\"%lf, %u, %d\\n\", ID_1, ui, si);\n\n  conv_1 (ID_2);\n  printf (\"%lf, %u, %d\\n\", ID_2, ui, si);\n\n  conv_1 (ID_3);\n  printf (\"%lf, %u, %d\\n\", ID_3, ui, si);\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cp.c",
    "content": "struct _obstack_chunk\n{\n  char  *limit;\n  struct _obstack_chunk *prev;\n  char\tcontents[4];\n};\n\nstruct obstack\n{\n  long\tchunk_size;\n  struct _obstack_chunk* chunk;\n  char\t*object_base;\n  char\t*next_free;\n  char\t*chunk_limit;\n  int\ttemp;\n  int   alignment_mask;\n  struct _obstack_chunk *(*chunkfun) ();\n  void (*freefun) ();\n};\n\nstruct fooalign {char x; double d;};\nunion fooround {long x; double d;};\n\nvoid\n_obstack_begin (h, size, alignment, chunkfun, freefun)\n     struct obstack *h;\n     int size;\n     int alignment;\n     void *  (*chunkfun) ();\n     void (*freefun) ();\n{\n  register struct _obstack_chunk* chunk;\n\n  if (alignment == 0)\n    alignment = ((char *)&((struct fooalign *) 0)->d - (char *)0);\n  if (size == 0)\n    {\n      int extra = 4;\n      if (extra < (sizeof (union fooround)))\n\textra = (sizeof (union fooround));\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cpp-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   by Alexandre Oliva  <oliva@lsd.ic.unicamp.br>  */\n\n#define foo/**/1\n#if foo != 1\n# error \"foo not properly defined\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cpp-2.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   by Alexandre Oliva  <oliva@lsd.ic.unicamp.br>  */\n\n#pragma /* the token after #pragma is optional. */\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/csebug.c",
    "content": "\nint\nreg0indreg1 (r0, p1)\n     short  r0;  short *p1;\n{\n  return (r0 + *p1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/cvt.c",
    "content": "foo (p)\n     unsigned char *p;\n{\n  unsigned char a = 0;\n\n  if (*p > 0)\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/d.c",
    "content": "long long unsigned\nstr2llu (str)\n     char *str;\n{\n  long long unsigned acc;\n  long long b = 10;\n  char d;\n  acc =  *str++ - '0';\n  for (;;)\n    {\n      d = *str++;\n      if (d == '\\0')\n\tbreak;\n      d -= '0';\n      acc = acc * 10 + d;\n    }\n\n  return acc;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dbl_parm.c",
    "content": "foo (a, b, c)\n     double a;\n     int b;\n     double c;\n{\n  if (b)\n    return a + c;\n  else\n    return a - c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dblbug.c",
    "content": "union real_extract\n{\n  double  d;\n  int i[sizeof (double ) / sizeof (int)];\n};\n\ntypedef struct\n{\n  int zzzz;\n} *rtx;\n\nrtx\nimmed_real_const_1 (d)\n     double  d;\n{\n  union real_extract u;\n  register rtx r;\n\n  u.d = d;\n  foo (&(r->zzzz), &u);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ddd.c",
    "content": "int foo;\nint bar;\n\nmain ()\n{\n  return foo + bar;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dead.c",
    "content": "foo (a)\n{\n  ++a;\n  return a == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/debugvlafunction-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nextern void dynreplace_trampoline(void);\nextern void dynreplace_trampoline_endlabel(void);\nint dynreplace_add_trampoline(void)\n{\n  unsigned long trampoline_code[(((unsigned long)\n(&(dynreplace_trampoline_endlabel))\n-(unsigned long) (&dynreplace_trampoline)))\n];\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/delay.c",
    "content": "foo (a, b)\n{\n  if (a == 1)\n    goto foo1;\n  if (a == 2)\n    goto foo2;\n foo1:\n  return 2;\n foo2:\n  return 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/di.c",
    "content": "long long\nfoo (a, b)\n     long long a, b;\n{\n  return a * b;\n}\n\nmain ()\n{\n  int a = foo ((long long) 2, (long long) 3);\n  printf (\"%d\\n\", a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dic.c",
    "content": "unsigned long long\nmain ()\n{\n  return (unsigned long long) 7816234 << 671111;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dilayout.c",
    "content": "struct ii\n{\n  int a;\n  int b;\n};\n\nstruct foo\n{\n  int a;\n  struct ii ab;\n  int b;\n};\n\nstruct ii\nfoo (int *p, struct foo a)\n{\n  p[0] = a.a;\n  p[1] = a.ab.a;\n  p[2] = a.ab.b;\n  p[3] = a.b;\n  return a.ab;\n}\n\nstr (struct ii ab, struct ii *p)\n{\n  *p = ab;\n}\n\nll (long long ab, long long *p)\n{\n  *p = ab;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dimove.c",
    "content": "foo (long long *p)\n{\n  p[0] = p[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dimul.c",
    "content": "long long\nfoo (a, b)\n     long long a, b;\n{\n  return a * b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/div.c",
    "content": "foo (a, b)\n{\n  return a / b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/divdf.c",
    "content": "double\nfoo (float a, float b)\n{\n  return (double)a / (double)b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dll.c",
    "content": "/* { dg-require-dll \"\" } */\n\n__declspec (dllimport) int foo;\nextern int (* import) (void) __attribute__((dllimport));\nint func2 (void) __attribute__((dllexport));\n\n__declspec(dllexport) int \nfunc1 (int a)\n{\n  return a + foo;\n}\n\nstatic int\ninternal (void)\n{\n  return 77;\n}\n\nint\nfunc2 (void)\n{\n  return import ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dm.c",
    "content": "struct dm\n{\n  unsigned q;\n  unsigned r;\n};\n\nstruct dm\ndm (a, b)\n     unsigned a, b;\n{\n  struct dm qr;\n\n  qr.q = a / b;\n  qr.r = a % b;\n  return qr;\n}\n\nmain ()\n{\n  struct dm qr;\n\n  qr = dm (100, 30);\n  printf (\"%u, %u\\n\", qr.q, qr.r);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/dshift.c",
    "content": "foo (b, c)\n     unsigned b, c;\n{\n  return (b << 12) | (c >> 20);\n}\n\nmain ()\n{\n  printf (\"0x%x\\n\", foo (0x11223344, 0xaabbccdd));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/e.c",
    "content": "foo (short a, int *p, short *s)\n{\n  int i;\n  for (i = 10;  i >= 0; i--)\n    {\n      a = (short) bar ();\n      p[i] = a;\n      s[i] = a;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ex.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n\nfoo (a, b)\n{\n  if ((a & (1 << b)) == 0)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  printf (\"%d\\n\", foo ());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ext.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct foo\n{\n  unsigned b31 : 1;\n  unsigned b30 : 1;\n  unsigned b29 : 1;\n  unsigned b28 : 1;\n  unsigned rest : 28;\n};\nfoo(a)\n     struct foo a;\n{\n  return a.b30;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/f1.c",
    "content": "double\nfoo ()\n{\n  return 1.2587624368724;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/f2.c",
    "content": "foo (double *p)\n{\n  p[0] = p[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/fdmul.c",
    "content": "double\nfoo (float a, float b) { return (double) a * (double) b; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/fix-trunc-mem-1.c",
    "content": "/* PR target/14201  */\n/* Excercise float -> integer in memory patterns.  */\n/* { dg-add-options ieee } */\n\nvoid f1 (float v,  int *p)\t\t\t{ *p = v; }\nvoid f2 (float v,  unsigned int*p)\t\t{ *p = v; }\nvoid f3 (float v,  long long *p)\t\t{ *p = v; }\nvoid f4 (float v,  unsigned long long *p)\t{ *p = v; }\nvoid f5 (double v, int *p)\t\t\t{ *p = v; }\nvoid f6 (double v, unsigned int *p)\t\t{ *p = v; }\nvoid f7 (double v, long long *p)\t\t{ *p = v; }\nvoid f8 (double v, unsigned long long *p)\t{ *p = v; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/flo.c",
    "content": "foo (a)\n     double a;\n{\n  double b = 0.0;\n\n  return (a == 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/float.c",
    "content": "double\nfoo (a, b, c)\n     double a, b, c;\n{\n  return a * b + c * a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/flt_const.c",
    "content": "double\nfoo ()\n{\n  return 3.141592653589793238462643;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/fnul.c",
    "content": "main ()\n{\n  int i;\n  int f;\n\n  for (i = 0;; i--)\n    {\n      f = 0;\n\n      if ((i & (i - 1)) == 0)\n\t{\n\t  printf (\"d\");\n\t  f = 1;\n\t}\n      if ((i & -i) == i)\n\t{\n\t  printf (\"t\");\n\t  f = 1;\n\t}\n      if (f)\n\tprintf (\"%d\\n\", i);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/foo.c",
    "content": "int *\nmain (s1, s2)\n     int *s1; int *s2;\n{\n  while ((*s1++ = *s2++) != '\\0')\n    ;\n  return s1 - 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/forgetcc.c",
    "content": "foo (hp, p, a)\n     short *hp;\n     int *p;\n     int a;\n{\n  hp[10] = a;\n  p[0] = 10;\n  if (hp[10] > 0)\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/fq.c",
    "content": "expand_to_ascii (int *i, int *o)\n{\n  unsigned x, y, out;\n  unsigned x1;\n\n  /* Big endian code.  */\n\n  x = *i++;\n\n  y = x >> (32 - 13);\n  out = (y / 91);\n  out = (out << 8) | (y % 91);\n\n  x <<= 13;\n  y = x >> (32 - 13);\n  out = (out << 8) | (y / 91);\n  out = (out << 8) | (y % 91);\n\n  *o++ = out + 0x20202020;\n\n  /* 6 bits left in x.  */\n\n  x1 = *i++;\n  x = (x << 26) | (x1 >> 6);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/funcptr-1.c",
    "content": "extern int (*gp)(const char*);\n\nint\ng (const char* d)\n{\n  printf (\"g\");\n  return 0;\n}\n\nf ()\n{\n  int errcnt=0;\n\n  if (gp != g)\n    {\n      printf (\"f\");\n      errcnt++;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/g.c",
    "content": "foo (a, b)\n     long long a, b;\n\n{\n  if (a == b)\n    return 0;\n  else\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/gen_tst.c",
    "content": "/* Compiler Test Generator Program.\n   Copyright (C) 1989 FSF.  */\n\n\n#define E0 ((type *)10000000)\n#define reg0 r0\n#define indreg0 (*p0)\n#define imm0 22\n#define limm0 ((type)(int)&glob0)\n#define adr0 (*E0)\n#define adrreg0 (p0[10000000])\n#define adrx0 (E0[x0])\n#define regx0 (p0[x0])\n\n#define E1 ((type *)11111111)\n#define reg1 r1\n#define indreg1 (*p1)\n#define imm1 33\n#define limm1 ((type)(int)&glob1)\n#define adr1 (*E1)\n#define adrreg1 (p1[1111111/4])\n#define adrx1 (E1[x1])\n#define regx1 (p1[x1])\n\nint glob0, glob1;\n\n#define type double\n\nchar *a0[] = {\"reg0\", \"indreg0\", \"imm0\", \"limm0\",\n\t\t\"adr0\", \"adrreg0\", \"adrx0\", \"regx0\"};\nchar *a1[] = {\"reg1\", \"indreg1\", \"imm1\", \"limm1\",\n\t\t\"adr1\", \"adrreg1\", \"adrx1\", \"regx1\"};\n\nmain_compare ()\n{\n  int i0, i1;\n\n  for (i0 = 0;  i0 < 8;  i0++)\n    {\n      for (i1 = 0;  i1 < 8;  i1++)\n\t{\n\t  printf (\"%s%s_cmp (r0, r1, x0, x1, p0, p1)\\n\", a0[i0], a1[i1]);\n\t  printf (\"type r0, r1;  type *p0, *p1;\\n\");\n\t  printf (\"{if (%s <= %s) return 1; else return 0;}\\n\\n\",\n\t\t  a0[i0], a1[i1], a0[i0]);\n\t}\n    }\n}\n\nmain_assign ()\n{\n  int i0, i1;\n\n  for (i0 = 0;  i0 < 8;  i0++)\n    {\n      if (i0 < 2 || i0 > 3)\n      for (i1 = 0;  i1 < 8;  i1++)\n\t{\n\t  printf (\"%s%s_set (r0, r1, x0, x1, p0, p1)\\n\", a0[i0], a1[i1]);\n\t  printf (\"type r0, r1;  type *p0, *p1;\\n\");\n\t  printf (\"{%s = %s;  }\\n\\n\",\n\t\t  a0[i0], a1[i1]);\n\t}\n    }\n}\n\nmain () {main_assign ();}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/glob.c",
    "content": "typedef int tt;\n\ntt a1;\ntt a2;\ntt a3;\n\nfoo ()\n{\n  a1++;\n  a2++;\n  a1++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/goto-1.c",
    "content": "f ()\n{\n  do\n    {\n      if (0)\n\t{\n        L1:;\n\t}\n      else\n\tgoto L2;\n    L2:;\n    }\n  while (0);\n\n  goto L1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/gronk.c",
    "content": "test_opt (a, b)\n     unsigned a, b;\n{\n  a = a / b;\n  if (a == 0)\n    a++;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/hi.c",
    "content": "foo (a, b)\n     short a, b;\n{\n  return a < b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/hibug.c",
    "content": "struct foo\n{\n  short  d;\n  int a;\n};\n\nint\nbar (d, u)\n     short d;\n  struct foo u;\n{\n\n  u.d = d;\n  return (int) (&u);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/i++.c",
    "content": "int main ()\n{\n  int i = 2;\n\n  i = i++;\n  printf (\"%d\\n\",i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/i.c",
    "content": "ase (p)\n     short *p;\n{\n  int a;\n\n  a = *p;\n  *p = a + 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ic.c",
    "content": "foo (int *ip, int a)\n{\n  a++;\n  if (a < ip[a])\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/icfmatch.c",
    "content": "typedef char __attribute__ ((vector_size (4))) v4qi;\nvoid retv (int a,int b,int c,int d, v4qi *ret)\n{\n  v4qi v = { a, b , c, d };\n  *ret = v;\n}\nvoid retv2 (int a,int b,int c,int d, v4qi *ret)\n{\n  v4qi v = { a, b , c, d };\n  *ret = v;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/icmp.c",
    "content": "foo (a, b)\n{\n  b++;\n  if (a <= b)\n    if ((int) a < (int) b)\n      b--;\n    else\n      b++;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ifreg.c",
    "content": "union foo\n{\n  float f;\n  int i;\n};\n\nfoo (int a, float c)\n{\n  union foo b;\n  b.i = a;\n  return b.f + c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/iftrap-1.c",
    "content": "/* Verify that ifcvt doesn't crash under a number of interesting conditions. */\n\nvoid f1(int p)\n{\n  if (p)\n    __builtin_trap();\n}\n\nvoid f2(int p)\n{\n  if (p)\n    __builtin_trap();\n  else\n    bar();\n}\n\nvoid f3(int p)\n{\n  if (p)\n    bar();\n  else\n    __builtin_trap();\n}\n\nvoid f4(int p, int q)\n{\n  if (p)\n    {\n      bar();\n      if (q)\n\tbar();\n    }\n  else\n    __builtin_trap();\n}\n\nvoid f5(int p)\n{\n  if (p)\n    __builtin_trap();\n  else\n    abort();\n}\n\nvoid f6(int p)\n{\n  if (p)\n    abort();\n  else\n    __builtin_trap();\n}\n\nvoid f7(int p)\n{\n  if (p)\n    __builtin_trap();\n  else\n    __builtin_trap();\n}\n\nvoid f8(int p)\n{\n  if (p)\n    __builtin_trap();\n  else\n    {\n      bar();\n      __builtin_trap();\n    }\n}\n\nvoid f9(int p)\n{\n  if (p)\n    {\n      bar();\n      __builtin_trap();\n    }\n  else\n    __builtin_trap();\n}\n\nvoid f10(int p)\n{\n  if (p)\n    __builtin_trap();\n  while (1)\n    bar();\n}\n\nvoid f11(int p)\n{\n  if (p)\n    __builtin_trap();\n  else\n    bar();\n  while (1)\n    baz();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/iftrap-2.c",
    "content": "void foo(int p, int q)\n{\n  if (p)\n    {\n      if (q)\n        __builtin_trap ();\n    }\n  else\n    bar();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/iftrap-3.c",
    "content": "/* Check that the conditional_trap pattern handles floating-point\n   comparisons correctly.  */\nvoid f1 (float x, float y) { if (x == y) __builtin_trap (); }\nvoid f2 (double x, double y) { if (x == y) __builtin_trap (); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/imm.c",
    "content": "int\nimm ()\n\n{\n  return 11234;\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/init-1.c",
    "content": "typedef struct\n{\n  char *key;\n  char *value;\n} T1;\n\ntypedef struct\n{\n  long type;\n  char *value;\n} T3;\n\nT1 a[] =\n{\n  {\n    \"\",\n    ((char *)&((T3) {1, (char *) 1}))\n  }\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/init-2.c",
    "content": "struct\n{\n  int e1, e2;\n} v = { e2: 0 };\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/init-3.c",
    "content": "struct empty { };\nstruct something {\n\tint spacer;\n\tstruct empty foo;\n\tint bar;\n};\n\nstruct something X = {\n\tfoo: { },\n\tbar: 1,\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/inline-1.c",
    "content": "typedef __builtin_va_list va_list;\n\nextern void foo (va_list);\n\nstatic void\nbuild_message_string (const char *msg, ...)\n{\n  va_list ap;\n\n  __builtin_va_start (ap, msg);\n  foo (ap);\n  __builtin_va_end (ap);\n}\n\nvoid\nfile_name_as_prefix (f)\n     const char *f;\n{\n  build_message_string (\"%s: \", f);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/isinf.c",
    "content": "int\nisinf ()\n{\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/jmp.c",
    "content": "foo (a)\n{\n  if (a)\n    goto a1;\n  goto a2;\n a1: goto a3;\n a2: goto a4;\n a3: goto a5;\n a4: goto a6;\n a5: goto a7;\n a6: goto a8;\n a7: goto a9;\n a8: goto a10;\n a9: goto a11;\n a10: goto a12;\n a11: goto a13;\n a12:;\n a13:;\n  return -a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/jumptab.c",
    "content": "jumptab (a)\n{\n  int b;\n  switch (a)\n    {\n    case 0:\n      b = 6;break;\n    case 1:\n      b = 5;break;\n    case 2:\n      b = 4;break;\n    case 3:\n      b = 3;break;\n    case 4:\n      b = 2;break;\n    case 5:\n      b = 1;break;\n    }\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/l.c",
    "content": "main (a)\n{\n  return - 256 + a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/labels-1.c",
    "content": "#ifndef NO_LABEL_VALUES\nf ()\n{\n  void *x = &&L2;\n  if (&&L3 - &&L1 > 1)\n    abort();\n L1: return 1;\n L2: abort ();\n L3:;\n}\n#else\nint x;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/labels-2.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nstruct bp { void *v, *b, *e; };\nf ()\n{\n  struct bp x = { &&L2 };\n  if (&&L3 - &&L1 > 1)\n    abort ();\nL1:return 1;\nL2:abort ();\nL3:;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/labels-3.c",
    "content": "/* Verify that we can narrow the storage associated with label diffs.  */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nint foo (int a)\n{\n  static const short ar[] = { &&l1 - &&l1, &&l2 - &&l1 };\n  void *p = &&l1 + ar[a];\n  goto *p;\n l1:\n  return 1;\n l2:\n  return 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/layout.c",
    "content": "struct foo\n{\n  char a;\n};\n\nfoo ()\n{\n  struct foo bar[3];\n  bar[0].a = '0';\n  bar[1].a = '1';\n  bar[2].a = '2';\n  foof (bar);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/lbug.c",
    "content": "long long x = 0;\nmain()\n{\n  if (x--)\n    return 255;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/libcall-1.c",
    "content": "/* Failed on ARM because rtx_varies_p didn't like the REG_EQUAL notes\n   generated for libcalls.\n   http://gcc.gnu.org/ml/gcc-patches/2004-02/msg01518.html */\nstatic const char digs[] = \"0123456789ABCDEF\";\nint __attribute__((pure)) bar();\n\nint foo (int i)\n{\n  int len;\n  if (i)\n    return 0;\n  len = bar();\n  return digs[len];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-blockid.c",
    "content": "#define LIM1(x) x##0; x##1; x##2; x##3; x##4; x##5; x##6; x##7; x##8; x##9;\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nvoid q9_func(void)\n{\n#if __INT_MAX__ >= 100000\n  LIM5(char t)\n#else\n  LIM4(char t)\n#endif\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-caselabels.c",
    "content": "#define LIM1(x) x##0: x##1: x##2: x##3: x##4: x##5: x##6: x##7: x##8: x##9: \n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nvoid q19_func (long i)\n{\n  switch (i) {\n    LIM5 (case 1)\n      break;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-declparen.c",
    "content": "#define PTR1 (* (* (* (* (* (* (* (* (* (*\n#define PTR2 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1\n#define PTR3 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2\n#define PTR4 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3\n#define PTR5 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4\n#define PTR6 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5\n\n#define RBR1 ) ) ) ) ) ) ) ) ) )\n#define RBR2 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1\n#define RBR3 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2\n#define RBR4 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3\n#define RBR5 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4\n#define RBR6 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5\n\nint PTR4 q4_var RBR4 = 0;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-enumconst.c",
    "content": "#define LIM1(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9,\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nenum q21_enum\n{\n#if __INT_MAX__ >= 100000\n  LIM5 (e)\n#else\n  LIM4 (e)\n#endif\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-exprparen.c",
    "content": "#define LBR1 ( ( ( ( ( ( ( ( ( (\n#define LBR2 LBR1 LBR1 LBR1 LBR1 LBR1 LBR1 LBR1 LBR1 LBR1 LBR1\n#define LBR3 LBR2 LBR2 LBR2 LBR2 LBR2 LBR2 LBR2 LBR2 LBR2 LBR2\n#define LBR4 LBR3 LBR3 LBR3 LBR3 LBR3 LBR3 LBR3 LBR3 LBR3 LBR3\n#define LBR5 LBR4 LBR4 LBR4 LBR4 LBR4 LBR4 LBR4 LBR4 LBR4 LBR4\n#define LBR6 LBR5 LBR5 LBR5 LBR5 LBR5 LBR5 LBR5 LBR5 LBR5 LBR5\n\n#define RBR1 ) ) ) ) ) ) ) ) ) )\n#define RBR2 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1\n#define RBR3 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2\n#define RBR4 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3\n#define RBR5 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4\n#define RBR6 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5 RBR5\n\nint q5_var = LBR4 0 RBR4;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-externalid.c",
    "content": "#define LIM1(x) x##0; x##1; x##2; x##3; x##4; x##5; x##6; x##7; x##8; x##9;\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nLIM5(char t)\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-externdecl.c",
    "content": "/* { dg-skip-if \"ptxas runs out of memory\" { nvptx-*-* } { \"*\" } { \"\" } } */\n\n/* { dg-require-effective-target int32plus } */\n/* Inspired by the test case for PR middle-end/52640.  */\n\ntypedef struct\n{\n    char *value;\n} REFERENCE;\n\n/* Add a few \"extern int Xxxxxx ();\" declarations.  */\n#undef DEF\n#undef LIM1\n#undef LIM2\n#undef LIM3\n#undef LIM4\n#undef LIM5\n#undef LIM6\n#define DEF(x) \textern int x ()\n#define LIM1(x) DEF(x##0); DEF(x##1); DEF(x##2); DEF(x##3); DEF(x##4); \\\n\t\tDEF(x##5); DEF(x##6); DEF(x##7); DEF(x##8); DEF(x##9);\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\nLIM5 (X);\n\n/* Add references to them, or GCC will simply ignore the extern decls.  */\n#undef DEF\n#undef LIM1\n#undef LIM2\n#undef LIM3\n#undef LIM4\n#undef LIM5\n#undef LIM6\n#define DEF(x)\t(char *) x\n#define LIM1(x) DEF(x##0), DEF(x##1), DEF(x##2), DEF(x##3), DEF(x##4), \\\n\t\tDEF(x##5), DEF(x##6), DEF(x##7), DEF(x##8), DEF(x##9),\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\nREFERENCE references[] = {\n  LIM5 (X)\n  0\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-fnargs.c",
    "content": "/* { dg-timeout-factor 4.0 } */\n/* { dg-require-effective-target run_expensive_tests } */\n\n#define PAR1 int, int, int, int, int, int, int, int, int, int\n#define PAR2 PAR1, PAR1, PAR1, PAR1, PAR1, PAR1, PAR1, PAR1, PAR1, PAR1\n#define PAR3 PAR2, PAR2, PAR2, PAR2, PAR2, PAR2, PAR2, PAR2, PAR2, PAR2\n#define PAR4 PAR3, PAR3, PAR3, PAR3, PAR3, PAR3, PAR3, PAR3, PAR3, PAR3\n#define PAR5 PAR4, PAR4, PAR4, PAR4, PAR4, PAR4, PAR4, PAR4, PAR4, PAR4\n#define PAR6 PAR5, PAR5, PAR5, PAR5, PAR5, PAR5, PAR5, PAR5, PAR5, PAR5\n\nextern void func (PAR4);\n\n#define ARG1 0,1,2,3,4,5,6,7,8,9\n#define ARG2 ARG1, ARG1, ARG1, ARG1, ARG1, ARG1, ARG1, ARG1, ARG1, ARG1\n#define ARG3 ARG2, ARG2, ARG2, ARG2, ARG2, ARG2, ARG2, ARG2, ARG2, ARG2\n#define ARG4 ARG3, ARG3, ARG3, ARG3, ARG3, ARG3, ARG3, ARG3, ARG3, ARG3\n#define ARG5 ARG4, ARG4, ARG4, ARG4, ARG4, ARG4, ARG4, ARG4, ARG4, ARG4\n#define ARG5HALF ARG5, ARG5, ARG5, ARG5, ARG5\n\nvoid caller(void)\n{\n  func (ARG4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c",
    "content": "/* { dg-skip-if \"too complex for avr\" { avr-*-* } { \"*\" } { \"\" } } */\n/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"*\" } { \"\" } } */\n/* { dg-timeout-factor 4.0 } */\n#define LIM1(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9,\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nvoid func1 (LIM5(int p) int t)\n{\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-idexternal.c",
    "content": "#define LIM1 0123456789\n#define LIM2 LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1\n#define LIM3 LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2\n#define LIM4 LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3\n#define LIM5 LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4\n#define LIM6 LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5\n\n#define V(x) v##LIM5##x\n\nint V(a);\nint V(b);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-idinternal.c",
    "content": "#define LIM1 0123456789\n#define LIM2 LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1##LIM1\n#define LIM3 LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2##LIM2\n#define LIM4 LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3##LIM3\n#define LIM5 LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4##LIM4\n#define LIM6 LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5##LIM5\n\n#define V(x) v##LIM6##x\n\nstatic int V(a);\nstatic int V(b);\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-pointer.c",
    "content": "#define PTR1 * * * * * * * * * *\n#define PTR2 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1 PTR1\n#define PTR3 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2 PTR2\n#define PTR4 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3 PTR3\n#define PTR5 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4 PTR4\n#define PTR6 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5 PTR5\n\nint PTR4 q3_var = 0;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-stringlit.c",
    "content": "/* { dg-skip-if \"Array too big\" { avr-*-* m32c-*-* pdp11-*-* msp430-*-* } { \"*\" } { \"\" } } */ \n\n#define STR2 \"012345678901234567890123456789012345678901234567890123456789\\\n0123456789012345678901234567890123456789\"\n#define STR3 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2\n#define STR4 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3\n#define STR5 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4\n#define STR6 STR5 STR5 STR5 STR5 STR5 STR5 STR5 STR5 STR5 STR5\n#define STR7 STR6 STR6 STR6 STR6 STR6 STR6 STR6 STR6 STR6 STR6\n#define STR8 STR7 STR7 STR7 STR7 STR7 STR7 STR7 STR7 STR7 STR7\n\nchar vlv[] = STR6;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-structmem.c",
    "content": "#define LIM1(x) x##0; x##1; x##2; x##3; x##4; x##5; x##6; x##7; x##8; x##9;\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\nstruct q20_struct\n{\n  LIM4 (char m)\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/limits-structnest.c",
    "content": "#define LIM1(x) x##0 {x##1 {x##2 {x##3 {x##4 {x##5 {x##6 {x##7 {x##8 {x##9 {\n#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \\\n\t\tLIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)\n#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \\\n\t\tLIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)\n#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \\\n\t\tLIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)\n#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \\\n\t\tLIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)\n#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \\\n\t\tLIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)\n#define LIM7(x) LIM6(x##0) LIM6(x##1) LIM6(x##2) LIM6(x##3) LIM6(x##4) \\\n\t\tLIM6(x##5) LIM6(x##6) LIM6(x##7) LIM6(x##8) LIM6(x##9)\n\n#define RBR1 } x; } x; } x; } x; } x; } x; } x; } x; } x; } x;\n#define RBR2 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1 RBR1\n#define RBR3 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2 RBR2\n#define RBR4 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3 RBR3\n#define RBR5 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4 RBR4\n\nLIM4(struct s)\n  int x;\nRBR4   \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ll1.c",
    "content": "long long\nfoo (long long a)\n{\n  return a + ((long long) 10230101 << 32) + 7561;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/llbug.c",
    "content": "union foo\n{\n  long long  d;\n};\n\nint\nbar (long long d)\n{\n  union foo u;\n\n  u.d = d;\n  return (int) &u;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/lll.c",
    "content": "\nbyte_match_count2 (buf, n, xm, m1, m2, m3, m4)\n     unsigned *buf;\n     unsigned n;\n     unsigned xm;\n     unsigned m1, m2, m3, m4;\n{\n  unsigned w, cnt = 0;\n  unsigned *bp;\n\n  n /= 4;\n\n  bp = buf;\n  while (bp < buf + n)\n    {\n      w = *bp++;\n      w ^= xm;\n      cnt += ((m1 & w) == 0);\n      cnt += ((m2 & w) == 0);\n      cnt += ((m3 & w) == 0);\n      cnt += ((m4 & w) == 0);\n\n      w = *bp++;\n      w ^= xm;\n      cnt += ((m1 & w) == 0);\n      cnt += ((m2 & w) == 0);\n      cnt += ((m3 & w) == 0);\n      cnt += ((m4 & w) == 0);\n\n      w = *bp++;\n      w ^= xm;\n      cnt += ((m1 & w) == 0);\n      cnt += ((m2 & w) == 0);\n      cnt += ((m3 & w) == 0);\n      cnt += ((m4 & w) == 0);\n\n      w = *bp++;\n      w ^= xm;\n      cnt += ((m1 & w) == 0);\n      cnt += ((m2 & w) == 0);\n      cnt += ((m3 & w) == 0);\n      cnt += ((m4 & w) == 0);\n    }\n  return cnt;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/load8.c",
    "content": "foo ()\n{\n  return *(short *) 126;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/loadhicc.c",
    "content": "typedef int xtype;\n\nfoo (p, pc)\n     xtype *p;\n     char *pc;\n{\n  xtype a;\n  unsigned b = 0;\n\n  a = *p;\n  p[1] = a;\n  if ((unsigned) p[1] > 0)\n    return 1;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/loop-1.c",
    "content": "foo (a)\n{\n  while ((a -= 1) != -1)\n    bar (270000);\n  putchar ('\\n');\n}\n\nmain ()\n{\n  foo (5);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/loop386.c",
    "content": "foo (a)\n{\n  do\n    {\n      puts (\"a\");\n      a -= 1;\n    }\n  while (a != 0);\n}\n\nmain ()\n{\n  int p[100];\n  printf (\"%d\\n\", foo (3));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/lop.c",
    "content": "lop (a)\n{\n  do\n    a--;\n  while (a >= -1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/m1.c",
    "content": "foo (p)\n     int *p;\n{\n  *p = 1234;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/m2.c",
    "content": "void\nstore16 (p, a)\n     short *p;\n     short a;\n{\n  *p = a;\n}\n\nsigned int\nsign_extend16 (p)\n     signed short *p;\n{\n  return *p;\n}\n\nunsigned int\nzero_extend16 (p)\n     unsigned short *p;\n{\n  return *p;\n}\n\nvoid\nstore8 (p, a)\n     char *p;\n     char a;\n{\n  *p = a;\n}\n\nsigned int\nsign_extend8 (p)\n     signed char *p;\n{\n  return *p;\n}\n\nunsigned int\nzero_extend8 (p)\n     unsigned char *p;\n{\n  return *p;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/m5.c",
    "content": "foo (a)\n{\n  return a * 5 + 12;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/m68.c",
    "content": "foo (a)\n{\n  return a | 12345;\n}\n\nbar (a)\n{\n  return a & (0xffff0000 | 12345);\n}\n\nfoobar (a)\n{\n  return a - 128;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/m68k-byte-addr.c",
    "content": "/* This testcase triggered an attempt to reload a byte value into an\n   address register.  */\nextern volatile unsigned char x[];\n\n#define DECLARE(I) orig##I, inc##I\n#define READ(I) orig##I = x[I]\n#define INC(I) inc##I = orig##I + 1\n#define WRITE1(I) x[I] = orig##I\n#define WRITE2(I) x[I] = inc##I\n\n#define REPEAT(X) X(0), X(1), X(2), X(3), X(4), X(5), X(6), X(7), X(8)\n\nvoid foo (void)\n{\n  unsigned char REPEAT (DECLARE);\n  REPEAT (READ);\n  REPEAT (INC);\n  REPEAT (WRITE1);\n  REPEAT (WRITE2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mangle-1.c",
    "content": "\n#if __nvptx__\n/* Doesn't like . in labels.  */\n#define SEP \"$\"\n#else\n#define SEP \".\"\n#endif\n\nint foo(void)\n{\n  static int x asm (\"x\") = 3;\n  return x++;\n}\n\nint X2 asm (\"x\" SEP \"0\") = 4;\nint X3 asm (\"_x\" SEP \"0\") = 5;\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mbyte.c",
    "content": "foo1 (p)\n     char *p;\n{\n  p[0] = p[1];\n  return p[0];\n}\n\nfoo2 (p, x)\n     char *p;\n{\n  p[0] = x;\n  return p[0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mchar.c",
    "content": "int\nfoo (char *a, char *b)\n{\n  int x;\n  *a = *b;\n  x = *b;\n  if ((char) x)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mcmp.c",
    "content": "foo (ip, a, x)\n     int a;\n     int *ip;\n     int x;\n{\n  if (a >= 1)\n    x++;\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mdouble.c",
    "content": "double\nfoo (double a)\n{\n\n  return 1.123486712;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/memcpy-1.c",
    "content": "static const char OggFLAC__MAPPING_VERSION_MAJOR = 1;\nvoid f(void)\n{\n  char synthetic_first_packet_body[10];\n  char *b = &synthetic_first_packet_body[4];\n  __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u));\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/memcpy-2.c",
    "content": "static const char OggFLAC__MAPPING_VERSION_MAJOR = 1;\nvoid f(void)\n{\n  char synthetic_first_packet_body[10];\n  char *b = synthetic_first_packet_body;\n  b+=4u;\n  __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u));\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/memtst.c",
    "content": "#ifdef STACK_SIZE\n#define SIZE STACK_SIZE / 8\n#else\n#define SIZE 65536\n#endif\n\nmemtst (int *p, int a)\n{\n  do\n    {\n      if (p[a] == 1)\n\tbreak;\n    }\n  while (--a);\n}\n\nmain ()\n{\n  int a[SIZE];\n  int i;\n  bzero (a, SIZE * 4);\n  for (i = 0;  i < 100;  i++)\n    {\n      memtst (a, SIZE);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mipscop-1.c",
    "content": "/* { dg-do compile { target mips*-*-* } } */\n\nregister unsigned int cp0count asm (\"$c0r1\");\n\nint __attribute__ ((nomips16))\nmain (int argc, char *argv[])\n{\n  unsigned int d;\n\n  d = cp0count + 3;\n  printf (\"%d\\n\", d);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mipscop-2.c",
    "content": "/* { dg-do compile { target mips*-*-* } } */\n\nregister unsigned int c3r1 asm (\"$c3r1\");\n\nextern unsigned int b, c;\n\nvoid __attribute__ ((nomips16))\nfoo ()\n{\n  unsigned int a, d;\n\n  c3r1 = a;\n  b = c3r1;\n\n  c3r1 = c;\n  d = c3r1;\n  printf (\"%d\\n\", d);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mipscop-3.c",
    "content": "/* { dg-do compile { target mips*-*-* } } */\n\nregister unsigned int c3r1 asm (\"$c3r1\"), c3r2 asm (\"$c3r2\");\n\nextern unsigned int b, c;\n\nvoid __attribute__ ((nomips16))\nfoo ()\n{\n  unsigned int a, d;\n\n  c3r1 = a;\n  b = c3r1;\n\n  c3r2 = c;\n  d = c3r1;\n  printf (\"%d\\n\", d);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mipscop-4.c",
    "content": "/* { dg-do compile { target mips*-*-* } } */\n\nregister unsigned long c3r1 asm (\"$c3r1\"), c3r2 asm (\"$c3r2\");\n\nextern unsigned long b, c;\n\nvoid __attribute__ ((nomips16))\nfoo ()\n{\n  unsigned long a, d;\n\n  c3r1 = a;\n  b = c3r1;\n\n  c3r2 = c;\n  d = c3r1;\n  printf (\"%d\\n\", d);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/miscomp.c",
    "content": "unsigned char foo(unsigned long);\nmain()\n{\n    unsigned char AChar;\n    unsigned long ALong = 0x12345678;\n\n    AChar = foo(ALong);\n\n    printf(\"AChar = %x\\n\",(int)AChar);\n}\nunsigned char\nfoo( unsigned long TheLong)\n{\n     return( (unsigned char) (TheLong & 0xff) );\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mm.c",
    "content": "foo (a, b)\n{\n  return a * 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mod.c",
    "content": "foo (a, b)\n{\n  return a % b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/modcc.c",
    "content": "foo (a, b)\n{\n  return (a % b) == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/move.c",
    "content": "typedef char type;\n\ntype\nfoo (b)\n{\n  type a;\n  for (a = 10; a < b; a++)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/move_qhi.c",
    "content": "move (a, b)\n     char a, b;\n{\n  char s;\n  s = a;\n  if (s)\n    gurka (s);\n  foo (b, a);\n  a = bar ();\n  b = bar ();\n  gra (s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mregtst.c",
    "content": "foo (a, p)\n     int *p;\n{\n  int old, new, i;\n\n  old = 0;\n  for (i = 1; i < 100; i++)\n    {\n      new = p[i];\n      if (new < old)\n\ta++;\n      old = new;\n      if (old == 0)\n\treturn 0;\n    }\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/msp.c",
    "content": "#ifdef STACK_SIZE\n# define A_SIZE (STACK_SIZE/sizeof(int))\n#else\n# define A_SIZE 16384\n#endif\nfoo ()\n{\n  int a[A_SIZE];\n  bar (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mtst.c",
    "content": "foo (int *p, int c)\n{\n  int a, b;\n  a = p[0];\n  b = p[1];\n  c = p[2];\n  if (b == 0)\n    goto foo1;\n  if (b < 0)\n    goto foo2;;\n\n  return a + b + c;\n foo1:\n  return 1;\n foo2:\n  return 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mu.c",
    "content": "foo (a, b)\n{\n  return a * b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mul.c",
    "content": "void\nmulqi (char *p, char a, char b)\n{\n  p[0] = a/b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mword.c",
    "content": "int\nfoo (a, b)\nint *a,  *b;\n{\n  int x, y;\n  x++;\n  *a = *b;\n  y = *b;\n\n  if ((int) x)\n    return 1;\n  else\n    return y;\n}\n\nfoo1 (p)\n     int *p;\n{\n  p[0] = p[1];\n  return p[0];\n}\n\nfoo2 (p, x)\n     int *p;\n{\n  p[0] = x;\n  return p[0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/mword1.c",
    "content": "int\nfoo (a, b)\nint *a,  *b;\n{\n  int x;\n  *a = (*b + 1);\n  x = *b;\n  if ((int) x)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/n.c",
    "content": "char_autoincr (b1, c)\n    short *b1;\n    short c;\n{\n  *b1 = c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/n1.c",
    "content": "foo (a, p)\n     long long a;\n     int *p;\n{\n  int b = (int)-a;\n  if (b > 32)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/nand.c",
    "content": "nadn (a, b)\n{\n  return (~a) | (~b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/neg.c",
    "content": "foo (a) {return -a;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/nested-1.c",
    "content": "/* { dg-require-effective-target trampolines } */\n\ntypedef __SIZE_TYPE__ size_t;\nextern int printf (const char *, ...);\nextern void *memset (void *, int, size_t);\n\nint bar (int (*)(), int, void *);\n\nint\nmain(int argc, char **argv)\n{\n  struct s { int a; char b[argc]; };\n  int nested (struct s x) { return x.a + sizeof(x); }\n  struct s t;\n  memset (&t, 0, sizeof(t));\n  t.a = 123;\n  printf(\"%d\\n\", bar (nested, argc, &t));\n  return 0;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/nested-2.c",
    "content": "/* PR 21105 */\n\nvoid\nCheckFile ()\n{\n  char tagname[10];\n  char *a = tagname;\n\n  int validate ()\n  {\n    return (a == tagname + 4);\n  }\n\n  if (a == tagname)\n    validate ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/o.c",
    "content": "foo (a, p)\n     char a;\n     int *p;\n{\n  int b = a;\n  *p = b;\n  a = (char) a;\n  if (a)\n    return b;\n  else\n    return b + 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/omit.c",
    "content": "omit (a, b)\n    char a;\n    char *b;\n{\n  char x;\n  int i;\n  x = *b;\n  b[1] = x;\n  foo ((int)x);\n  return x + 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/opout.c",
    "content": "x ()\n{}\n\ny ()\n{}\n\nz (a, b)\n{\n  return (int) &a + (int) &b + (int) x + (int) z;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/opt.c",
    "content": "int\nfoo (a)\n{\n  return (a == 2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/or.c",
    "content": "foo (a)\n{\n  return a | 0xffff0101;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/or386.c",
    "content": "typedef int xtype;\n\nxtype\nfoo (a)\n     xtype a;\n{\n  return a | 0x7f;\n}\n\nmain ()\n{\n  printf (\"%08x\\n\", foo (-1));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/p.c",
    "content": "foo (a, b, p)\n     short *p;\n{\n  p[0] = a;\n  p[1] = b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/packed-1.c",
    "content": "struct s\n{\n  int e;\n} x;\n\nstruct rbuf\n{\n  struct s *p __attribute__ ((packed));\n} *b;\n\nf ()\n{\n  b->p = &x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/parms.c",
    "content": "/* { dg-require-effective-target alloca } */\n#define alloca __builtin_alloca\n\nx (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, x, y)\n{\n  foo (alloca (8));\n  return a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+x+y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pass.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nint\nfoo (a, b, c)\n{\n  return a + b + c;\n}\n\nint\nbar ()\n{\n  int q, w, e, r, t, y;\n\n  return foo ((int) & q, q, w, e, q, (int) &w);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pc44485.c",
    "content": "static int\nfoo (int si1, int si2)\n{\n  return si1 > 0 && si2 > 0 && si1 > -si2 || si1 < 0 && si2 < 0\n    && si1 < -si2 ? : si1 + si2;\n}\n\nstruct S0\n{\n  unsigned short f1;\n};\nint g_4;\nstruct S0 g_54 = {\n  3428\n};\n\nint\nfunc_21 (int * p_22, int * const int32p_24, unsigned p_25,\n         const int * p_26);\n\nvoid int324 (unsigned p_15, int * p_16, int * p_17, int * p_18)\n{\n  if (foo (g_4, func_21 (p_18, &g_4, 0, 0)))\n    {\n      for (g_54.f1; g_54.f1; g_54.f1 += 1)\n        {\n        }\n    }\n}\n\nint\nfunc_21 (int * p_22, int * const int32p_24, unsigned p_25,\n         const int * p_26)\n{\n  for (0; 1; p_25 += 1)\n  lbl_29:if (p_25)\n      goto lbl_28;\nlbl_28:for (p_25 = 0; p_25 < 9; p_25 += 1)\n    if (p_25)\n      goto lbl_29;\n  unsigned short l_53;\n  for (0; l_53; l_53 = foo)\n    {\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pmt.c",
    "content": "long long\nfoo (a, b)\n     long long a, b;\n{\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/poor.c",
    "content": "typedef struct\n{\n\tchar\tc[510];\n} s510;\n\ntypedef struct\n{\n\tchar\tc[511];\n} s511;\n\ns510\tG510, s1;\ns511\tG511;\nint\tI, J;\ndouble\tD;\n\nvoid main(void);\nvoid f0(double D, ...);\ns510 f1(double D, ...);\nvoid f2a(s510 S);\nvoid f2b(s511 S);\n\n\nvoid main(void)\n{\n\n\tf0(D, I, J);\n\n\ts1 = f1(D, I, D);\n\n\tf2a(G510);\n\n\tf2b(G511);\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pp.c",
    "content": "foo (a, b, c, d, e, i0, f, i1)\n     double a, b, c, d, e, f;\n     int i0, i1;\n{}\n\nmain ()\n{\n  foo (1.0, 2.0, 3.0, 4.0, 5.0, 1, 6.0, 2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr12517.c",
    "content": "/*  PR tree-optimization/12517  */\n\nint f(void);\nvoid g(int);\nvoid h(int a, int b, int c)\n{\n    int i = f();\n\n    if (b && (i & 4))\n\tg(i & 8 ? 0 : 1);\n    if (a) {\n\tdo {\n\t    if (i & 8)\n\t\tg(0);\n\t    if (i & 4)\n\t\tg(i ? 0 : 1);\n\t} while (--c);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr12578.c",
    "content": "/*  PR tree-optimization/12517  */\n\nvoid trivial_regexp_p(int *s, int len)\n{\n    while (--len) {\n\tswitch (*s++) {\n\t    case '\\\\':\n\t\tswitch (*s++) {\n\t\t    case '|':\n\t\t\t;\n\t\t}\n\t}\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr12899.c",
    "content": "/*  PR tree-optimization/12899  */\n\nvoid\nbb_getopt_ulflags (char *s)\n{\n  for (;;)\n    if (s[1])\n      do\n\ts++;\n      while (*s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr13066-1.c",
    "content": "void *g, *c;\nint a, b;\n\nint f()\n{\n  if ((0 == a) != (b || g == c))\n    return 1;\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr13889.c",
    "content": "/* PR target/13889 */\nstruct { long long a; } *p;\nvoid initNetFlowFunct(void) {\n  unsigned int b = (unsigned int)-1;\n  p->a = b;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr14692.c",
    "content": "/* PR rtl-optimization/14692  */\n\nvoid assert_failed (void);           \nvoid eidecpos_1 (unsigned char *pos, long n)\n{\n  int i;\n  for (i = 0; i < n; i++)\n    {\n      const unsigned char *dc_ptr1 = pos;\n      pos--;\n      if (dc_ptr1 - pos == 1)\n\tassert_failed ();\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr14730.c",
    "content": "/* PR middle-end/14730 */\n\nint t (char i)\n{\n  switch (i)\n    {\n    case 1:\n    case 7:\n    case 10:\n    case 14:\n    case 9:\n    case 256:\n      return 0;\n    }\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr15245.c",
    "content": "/*  Testcase from <marcus@jet.franken.de>\n    PR optimization/15245\n    This used to ICE as convert was used\n    in tree-ssa-phiopt which created non gimple\n    code.   */\n\nchar *f(char *x, int flag)\n{\n    char *ret = (char*)0;\n\n\n    if( x > (char*)1 ) {\n      if(x)\n        return (char*)0;\n    } else {\n      if( flag & 1 )\n        ret = (char*)1;\n      flag |= 2;\n    }\n    return ret;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr16461.c",
    "content": "/* PR tree-optimization/16461  */\n\nint DVDinput_read(int);\nint DVDReadBlocksPath(int offset, int block_count) {\n    int ret = 0, ret2 = 0;\n    for (;;) {\n\tif (offset)\n\t    ret = DVDinput_read(block_count);\n\telse \n\t    ret2 = DVDinput_read(block_count);\n\tbreak;\n    }\n    return ret + ret2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr16566-1.c",
    "content": "/* ICE with flexible arrays in non-lvalue structures.  Bug 16566\n   (comment #3).  */\n\nstruct S;\n\nstruct C {\n    int i;\n    struct S *tab[];\n};\n\nstruct S { struct C c; };\n\nvoid foo (struct S *x) {\n  foo(((void)1, x->c).tab[0]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr16566-2.c",
    "content": "/* ICE with flexible arrays in non-lvalue structures.  Bug 16566\n   (comment #5).  */\n/* { dg-options \"-Wno-psabi\" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } */\n\nstruct A\n{\n    int i;\n    int x[];\n};\n\nint foo(struct A a)\n{ \n    return (a,a).x[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr16566-3.c",
    "content": "/* ICE with flexible arrays in non-lvalue structures.  Bug 16566\n   (testcase from duplicate bug 16575).  */\n\nstruct S;\nstruct C {\n    int i;\n    struct S *tab[];\n};\nstruct S { struct C c; };\nvoid foo (struct S *x) {\n  ((void)1, x->c).tab[0] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr16808.c",
    "content": "/* We used to ICE as we did not mark a Vop for rename as\n   we changed a function call to a normal modify statement\n   while folding exp(0.0); */\n\ndouble exp(double);\nvoid f0(void);\nvoid f(double);\ntypedef struct Parser {\n    int x;\n    char *s;\n} Parser;\nstatic double pop(Parser *p) {\n    if (p->s[0] <= 0) {\n\tf0();\n\treturn 0;\n    }\n    --p->x;\n    return 0;\n}\nstatic void evalFactor(Parser *p) {\n    while (p->x)\n\tf(exp(pop(p)));\n}\nstatic void evalTerm(Parser *p) {\n    while (p->s[0])\n\tevalFactor(p);\n}\nstatic void evalExpression(Parser *p) {\n    evalTerm(p);\n    while (p->s[0])\n\tevalTerm(p);\n}\nvoid evalPrimary(Parser *p) {\n    if (p->s)\n\treturn;\n    evalExpression(p);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17119.c",
    "content": "void\n_mesa_DrawPixels (int width, int height, unsigned format,\n\t\t  unsigned type, const void * pixels)\n{\n  switch (format)\n    {\n    case 0x1900:\n      func1 ();\n      break;\n    case 0x1907:\n    case 0x80E0:\n    case 0x1908:\n    case 0x80E1:\n    case 0x8000:\n      func2 ();\n      break;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17273.c",
    "content": "struct A { int i; };\nstruct B { struct A a; };\n\nvoid f(struct A*, struct A*);\n#define bool _Bool\n\nvoid bar(bool b)\n{\n  struct B * D1601;\n  struct A D1576;\n  struct A * D1593;\n  struct B * D1592;\n  struct B D1575;\n\n  D1575 = (struct B){};\n\n  if (b) D1592 = &D1575; else D1592 = &D1575;\n\n  D1593 = &D1592->a; // <-- we are prograting &D1575 into here.\n  D1576 = (struct A){};\n  f (D1593, &D1576);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17397.c",
    "content": "/* ICE due to invalid GIMPLE created during strlen simplification.  */\n/* { dg-require-effective-target alloca } */\n\nextern unsigned long strlen (__const char *__s);\nextern void bar ();\nextern int cols;\n\nvoid foo (void)\n{\n  char s[cols + 2];\n  if (strlen (s) > 0)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17407.c",
    "content": "typedef struct libxml_xpathCallback { \n  void *ns_uri; \n} libxml_xpathCallback; \n \ntypedef libxml_xpathCallback libxml_xpathCallbackArray[]; \n \nlibxml_xpathCallbackArray *libxml_xpathCallbacks; \n\nvoid foo1(void);\n \nvoid \nfoo (void) \n{ \n  if ((*libxml_xpathCallbacks)[3].ns_uri != ((void *)0)) foo1(); \n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17408.c",
    "content": "/* PRs 17408 and 17409, with different options. */\nextern int t;\nextern int t = 0;\nvoid f(){t =0;}\nvoid g(){h(&t);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17529.c",
    "content": "\nstatic inline void \nbar (const int * const x) \n{ \n  __asm__ __volatile__ (\"\"::\"m\" (*x)); \n} \n \nstatic const int y[1]; \n \nvoid \nfoo (void) \n{ \n  bar (y); \n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17558.c",
    "content": "struct xobject {\n       char type;\n};\nextern struct xobject *t1_Xform ( struct xobject *obj);\nstruct xobject *\nt1_Xform(struct xobject *obj)\n{\n  register struct font *F = (struct font *) obj;\n  return((struct xobject*)F);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17656.c",
    "content": "int sprintf (char *s, const char *format, ...);\n\nint foo(int i, int j)\n{\n   char *buf, *str;\n\n   if (i)\n     str = \"\";\n   else if (j)\n     str = \"\";\n   else\n     return 1;\n\n   /* We were propagating &\"\"[0] here and not calling fold_stmt with a\n      proper statement pointer.  */\n   sprintf(buf, str);\n   return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17906.c",
    "content": "struct usc_bigstack_t {};\n\nvoid\nusc_recressive_func(int cnt, int max, struct usc_bigstack_t bstack)\n{\n  usc_recressive_func(cnt+1, max, bstack);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr17913.c",
    "content": "/* Test for computed jump into cond_expr: bug 17913.  */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nvoid f (void) \n{ \n  void *p = &&a;\n  1 ? 1 : ({ a : 1; }); \n  goto *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr18291.c",
    "content": "int baz(int k2)\n{\n  int i, j, *p, k = 1, k1 = 0;\n  if (k2)\n    p = &j;\n  else\n    p = &i;\n  if (k1)\n    *p = 0 , p = &k;\n  *p = 1;\n  return k;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr18299-1.c",
    "content": "/* We used to ICE in gimple-lower because we\n   would produce __t (VAR_DECL) as a statement in the\n   instruction stream which is not valid. */\n\nstatic inline int f(int i)\n{\n  const int __t = (__t);\n}\nint g(void)\n{\n  return f(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr18712.c",
    "content": "void *eintr_source (void *arg)\n{\n  int ts = 0;\n  \n  if (arg)\n    foo ();\n  \n  while (1)\n    {\n      if (arg)\n\tfoo ();\n      \n      foo1 (&ts);\n    }\n  \n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr18903.c",
    "content": "/* We were ICEing in bsi_after_labels because \n   we had a BB which did not have a lablel.\n   PR middle-end/18903 */\n\n#ifndef NO_LABEL_VALUES\nvoid g (int s, int f)\n{\n  &&ff;\n  s = f;\n  ff:\n  goto end;\n  f = s;\n  end:;\n}\n#else\nint g;\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr19080.c",
    "content": "typedef union { int ioport; volatile char *maddr; } bus_space_handle_t;\nstruct scb { unsigned short *hscb; };\nstruct ahd_softc\n{\n  int tags[2];\n  bus_space_handle_t bshs[2];\n  int dst_mode;\n  int src_mode;\n  int flags;\n};\nvoid outb(int, int);\n\nint foo_inb(struct ahd_softc*);\nint foo_int_int (int, int);\nint ahd_inb(struct ahd_softc*);\nint ahd_scb_active_in_fifo (void);\n\nvoid ahd_flush_qoutfifo (struct ahd_softc *ahd, struct scb *scb)\n{\n  int src, dst, *a = &src, *b = &dst; *a = 1, *b = 1;\n  int bb, p;\n\n  if (ahd->src_mode == 1)\n    { int src, dst, *a = &src, *b = &dst; *a = 1, *b = 1;}\n  foo_int_int (ahd->src_mode, ahd->dst_mode);\n  p = 1;\n  if (ahd->src_mode == 2 && ahd->dst_mode == p)\n    {\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n    }\n  ahd->src_mode = 1;\n  ahd->dst_mode = 2;\n  while ((ahd_inb (ahd) & 0x01) != 0)\n  {\n    p = 1;\n    if (ahd->src_mode == 2 && ahd->dst_mode == p)\n      {\n        if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n          outb (1, ahd->bshs[0].ioport );\n        if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n          outb (1, ahd->bshs[0].ioport );\n      }\n    ahd->src_mode = 1;\n    ahd->dst_mode = 2;\n    if (ahd_scb_active_in_fifo () == 0)\n      continue;\n    p = 1;\n    if (ahd->src_mode == 2 && ahd->dst_mode == p)\n      {\n        if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n          outb (1, ahd->bshs[0].ioport );\n        if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n          outb (1, ahd->bshs[0].ioport );\n      }\n    ahd->src_mode = 1;\n    ahd->dst_mode = 2;\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if ((ahd->flags & 1) != 0)\n      foo_inb (ahd);\n    if ((ahd->flags & 1) != 0)\n      foo_inb (ahd);\n    if ((ahd->flags & 1) != 0)\n      foo_inb (ahd);\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if ((ahd->flags & 1) != 0)\n      foo_inb (ahd);\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    bb = (*(scb->hscb));\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    bb = (*(scb->hscb));\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n    if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n      outb (1, ahd->bshs[0].ioport );\n  }\n  if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n    outb (1, ahd->bshs[0].ioport );\n  if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n    outb (1, ahd->bshs[0].ioport );\n  p = 1;\n  if (ahd->src_mode == 2 && ahd->dst_mode == p)\n    {\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n    }\n  ahd->src_mode = 1;\n  ahd->dst_mode = 2;\n  if (ahd->src_mode == 2 && ahd->dst_mode == dst)\n    {\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n      if (ahd->tags[0] == 1) *(ahd->bshs[0].maddr);\n        outb (1, ahd->bshs[0].ioport );\n    }\n  ahd->src_mode = 1;\n  ahd->dst_mode = 2;\n  ahd->flags |= 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr19121.c",
    "content": "typedef struct interpreter {\n  char Itokenbuf[256];\n} PerlInterpreter;\nstatic inline void S_missingterm(char *s)\n{\n  char tmpbuf[3] = \"\";\n  char q;\n  if (!s)\n    s = tmpbuf;\n  q = strchr(s,'\"') ? '\\'' : '\"';\n}\nvoid S_scan_heredoc(PerlInterpreter *my_perl, char *s, int i)\n{\n  char term;\n  term = *my_perl->Itokenbuf;\n  if (i)\n  {\n    *s = term;\n    S_missingterm(my_perl->Itokenbuf);\n  }\n  else\n    S_missingterm(my_perl->Itokenbuf);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr19357.c",
    "content": "/* This generated an ICE for an ia64-linux target.  */\nstruct f {\n  float f[8];\n};\n\nlong double ftest(struct f arg1, long double arg2) {\n  return arg2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr19736.c",
    "content": "/* We used to ICE because we had forgot to update the immediate_uses\n   information after foldding the last strcpy in Reduce PHI.\n   This was PR tree-opt/19763. */\n\nextern char *strcpy (char *, const char *);\nvoid sdbout_one_type (char *p)\n{\n  int i, t = 1;\n  char *q;\n  for (i = 0; i < 2; i++)\n    {\n      strcpy (p, \"1\");\n      p += sizeof (\"1\");\n    }\n  if (t)\n    q = \"2\";\n  else\n    q = \"3\";\n  strcpy (p, q);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr19853.c",
    "content": "struct test { int *x; } global_test;\nint global_int;\n\nint flag;\n\nvoid test (char *dummy)\n{\n  static const struct test const_test = { &global_int };\n  struct test local_test;\n\n  int i;\n  for (i = 0; i < 1; i++)\n    *dummy = 0;\n  if (flag)\n    __builtin_memset (dummy, 0, 16);\n\n  local_test = const_test;\n  global_test = local_test;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr20203.c",
    "content": "void *memset (void *, int, unsigned long);\n\ntypedef struct bfd_section\n{\n  unsigned long size;\n  unsigned char *contents;\n} asection;\n\nint\n_bfd_mips_elf_finish_dynamic_sections (asection *s)\n{\n  long long dummy_offset;\n  dummy_offset = s->size - 16;\n  memset (s->contents + dummy_offset, 0, 16);\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr20412.c",
    "content": "int\nfoo(void)\n{\n  int      a,b,g;\n  int      i,len;\n  int      stop;\n                                                                     \n  len = 10;\n  stop = 0;\n  for (i=0; i<len; i++)\n  {\n    a = bar1() ? 0 : 1;\n    b = bar2() ? 0 : 1;\n    g = bar3() ? 0 : 1;\n                                                                     \n    if (stop = ((a+b) % 2 != g)) break;\n  }\n \n  return stop;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr20539-1.c",
    "content": "char l7_en;\nlong long l6_data_Z_0th;\nint t;\nvoid f()\n{\n  if (((char )(l6_data_Z_0th>>1 & 1U)) & ((l6_data_Z_0th & 1U)\n     | !(((char )(l6_data_Z_0th>>35 & 15U))==14U)))\n    t = 0ULL;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr20583.c",
    "content": "/* PR target/20583\n   On m68k-none-elf, CSE used to generate\n\n     (set (reg:HI ...)\n          (const:HI (truncate:HI (minus:SI (label_ref ...)\n                                           (label_ref ...)))))\n\n   which output functions do not know how to handle.  Make sure that\n   such a constant will be rejected.  */\n\nvoid bar (unsigned int);\n\nvoid\nfoo (void)\n{\n  char buf[1] = { 3 };\n  const char *p = buf;\n  const char **q = &p;\n  unsigned int ch;\n  switch (**q)\n    {\n    case 1:  ch = 5; break;\n    case 2:  ch = 4; break;\n    case 3:  ch = 3; break;\n    case 4:  ch = 2; break;\n    case 5:  ch = 1; break;\n    default: ch = 0; break;\n    }\n  bar (ch);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr20928.c",
    "content": "extern struct bar_t bar;\nvoid *a;\nvoid\nfoo (void)\n{\n  void **p = a;\n  do {\n    *p++ = ((unsigned char *) &bar + ((unsigned long int) 1L << 31));\n  } while (p);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21021.c",
    "content": "/* PR tree-optimization/21021\n\n   The front end produces a comparison of mismatched types, namely an\n   integer and a pointer, causing VRP to compute TYPE_MAX_VALUE for a\n   pointer, which we cannot.  */\n\nextern void *bar (void);\n\nint\nfoo (unsigned int *p, unsigned int *q)\n{\n  const void *r = bar ();\n\n  if (r >= (const void *) *p\n      && r < (const void *) *q)\n    return 1;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21030.c",
    "content": "/* PR tree-optimization/21030\n   VRP used to create invalid ranges where VR->MIN is greater than\n   VR->MAX.  */\n\nvoid\nfoo (int unit)\n{\n  int i;\n\n  for (i = 0; unit; i++, unit--)\n    {\n      if (i >= 0)\n\t{\n\t  int j = i;\n\t  while (j)\n\t    j--;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21293.c",
    "content": "/* Testcase from Dale Johannesen <dalej@gcc.gnu.org>. */\nstruct {\ndouble x[1];\n} g;\nvoid k( double *, double*);\nvoid h(int Tmp8)\n{\n  int i;\n  for(i = 1;i <= Tmp8;i++)\n    k(&g.x[ + -1],&g.x[ Tmp8 + -1]);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21356.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nint a;\nvoid* p;\n\nvoid foo (void)\n{\n  switch (a)\n  {\n    a0: case 0:   p = &&a1;\n    a1: case 1:   p = &&a2;\n    a2: default:  p = &&a1;\n  }\n  goto *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21380.c",
    "content": "void bar (void);\n                                                                                \nvoid\nfoo (int *diff)\n{\n  double deltay = 0.0;\n  int Stangent = 0;\n  int mindiff;\n  int Sflipped = 0;\n  int i;\n  int Sturn, Snofit;\n                                                                                \n  Sturn = 1;\n  if (Sturn)\n    Stangent = 1;\n  if (Sturn)\n    {\n      Sflipped = 0;\n      Snofit = 1;\n      while (Snofit)\n        {\n          Snofit = 0;\n          mindiff = 0;\n          for (i = 0; i < 4; i++)\n            mindiff = diff[i];\n          while (!Snofit && (mindiff < 0.0))\n            {\n              deltay = (Stangent ? deltay : 0.0);\n              if (deltay < 0.0)\n                Snofit = 1;\n              for (i = 0; i < 4; i++)\n                {\n                }\n            }\n          if (Snofit)\n            if (Sflipped)\n              break;\n        }\n      if (Snofit)\n        bar ();\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21532.c",
    "content": "\n\nint\nbar (unsigned char key)\n{\n  unsigned char buf[sizeof (unsigned long)+2];\n  unsigned char b;\n  unsigned char *buf_ = buf + 1;\n\n  for (b = 8; b != 0; b--)\n    buf_[b] = key >> b;\n\n  return foo (b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21562.c",
    "content": "/* { dg-options \"-fno-inline\" } */\nstruct foo { int a, b, c; };\nvoid abort(void);\nvoid exit(int);\n\nvoid\nbrother (int a, int b, int c)\n{\n  if (a)\n    abort ();\n}\n\nvoid\nsister (struct foo f, int b, int c)\n{\n  brother ((f.b == b), b, c);\n}\n\nint\nmain ()\n{\n  struct foo f = { 7, 8, 9 };\n  sister (f, 1, 2);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21638.c",
    "content": "typedef struct hashhdr {\n int bitmaps[32];\n} HASHHDR;\n\nstatic void\nswap_header_copy(HASHHDR *srcp, HASHHDR *destp)\n{\n  int i;\n  for (i = 0; i < 32; i++)\n    ((char *)&(destp->bitmaps[i]))[0] = ((char *)&(srcp->bitmaps[i]))[1];\n}\n\nint\nflush_meta(HASHHDR *whdrp1)\n{\n HASHHDR *whdrp;\n HASHHDR whdr;\n whdrp = &whdr;\n swap_header_copy(whdrp1, whdrp);\n return (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21728.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nint main (void)\n{\n  __label__ l1;\n  void __attribute__((used)) q(void)\n  {\n    goto l1;\n  }\n\n  l1:;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21761.c",
    "content": "void f1()\n{\n  long bit=0, exponent;\n  exponent = -exponent;\n  for (bit = 1; exponent; bit <<= 1)\n      if (exponent & bit)\n              exponent ^= bit;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21839.c",
    "content": " typedef struct { } spinlock_t;\ntypedef struct {\n unsigned sequence;\n spinlock_t lock;\n} seqlock_t;\nvoid ext3_new_inode(seqlock_t *rsv_seqlock)\n{\n *rsv_seqlock = (seqlock_t) { 0, (spinlock_t) { } };\n\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr21840.c",
    "content": "void fn_show_state(void);\ntypedef void (*fn_handler_fn)(void);\nstatic fn_handler_fn fn_handler[1];\n\nvoid k_spec(unsigned char value)\n{\n  void *func = fn_handler[value];\n  if (func == fn_show_state )\n    return;\n  fn_handler[value]();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22013-1.c",
    "content": "typedef unsigned short W;\ntypedef const W *P;\n\nextern void g(P);\n\nvoid\nf ()\n{\n  const P s = (const W []){ 'R' };\n  g (s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22269.c",
    "content": "/* We used to ICE in tree-ssa-reassoc because we did look at the correct operand to\n   see if it was a SSA_NAME.  */\nint printf(const char*, ...);\nint main(int argv, char*argc) {\n\n    int d1;\n    int d2;\n    int s1, s2;\n    int b;\n    ((d1)&=(int)0x0000ffffL, (d1)|=((int)(short)(0x344))<<16);\n    ((d1)&=(int)0xffff0000UL, (d1)|=(int)(unsigned short)(0x4567));\n    ((d2)&=(int)0x0000ffffL, (d2)|=((int)(short)(0))<<16);\n    ((d2)&=(int)0xffff0000UL, (d2)|=(int)(unsigned short)(0x3b9a));\n    printf(\" dividend >>: %ld\\n\", d1);\n    printf(\" divisor  >>: %ld\\n\", d2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22379.c",
    "content": "void __add_entropy_words(void);\nvoid __wake_up(void);\nvoid SHATransform(void);\nstatic inline __attribute__((always_inline)) void add_entropy_words(void){}\nvoid extract_entropy(void);\nstatic inline __attribute__((always_inline)) void xfer_secondary_pool(void)\n{\nextract_entropy();\nadd_entropy_words();\n}\nvoid extract_entropy(void)\n{\nxfer_secondary_pool();\n__wake_up();\n}\nvoid init_std_data(void)\n{\nadd_entropy_words();\n}\nvoid rand_initialize(void)\n{\ninit_std_data();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22398.c",
    "content": "#if ULONG_MAX != 4294967295u && ULONG_MAX != 18446744073709551615ull\nint main(void) { exit (0); }\n#else\n#if ULONG_MAX != 18446744073709551615ull\n#define NUM 0xf0000000\n#else\n#define NUM 0xf000000000000000\n#endif\n\n\nint func1(void *rw)\n{\n  return (rw && (((unsigned long) rw) >= NUM) );\n}\n\nvoid func2(void *rw)\n{\n  while(rw && (((unsigned long) rw) >= NUM) ) {}\n}\n\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22422.c",
    "content": "/* We should not crash trying to figure out the points-to sets for the below.  We used to because we\n   ended up adding pointers to the points-to set of the ANYTHING variable.  */\nstruct D\n{\n  int n;\n  int c [8];\n};\n\nstruct A\n{\n  int i;\n  char *p;\n};\n\nstruct B\n{\n  struct A *a;\n  struct D *d;\n};\n\nint dtInsert1 (struct B *b)\n{\n  struct A a = { 0, 0 };\n  struct D *d;\n  b->a = &a;\n  d = b->d;\n  &d->c [d->n];\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22531.c",
    "content": "typedef struct dw_cfi_oprnd_struct {\n      unsigned long reg;\n} dw_cfa_location;\nvoid def_cfa_1 (void) {\n      dw_cfa_location loc;\n        loc.reg = loc.reg;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr22589-1.c",
    "content": "int bar (char *foo)\n{\n  return (long long) ((int) foo + 0) < 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23233-1.c",
    "content": "void foo (volatile long long *x)\n{\n  while (*x)\n    {\n      *x = 0;\n      *((volatile char *) 0) = 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23237.c",
    "content": "/* Don't assemble, as this section syntax may not be valid on all platforms\n   (e.g., Darwin).  */\n/* { dg-do compile } */\n\n/* { dg-require-effective-target named_sections } */\n\nstatic __attribute__ ((__section__ (\".init.data\"))) char *message;\nstatic __attribute__ ((__section__ (\".init.data\"))) int (*actions[])(void) = {};\nvoid unpack_to_rootfs(void)\n{\n  while (!message)\n  {\n    if(!actions[0])\n      return;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23435.c",
    "content": "/* PR target/23435.\n\n   On m68k-none-elf, this used to cause an unrecognized insn because\n   zero_extendsidi2 accepted operands that are both memory even though\n   such a pattern did not exist.  */\n\nvoid\nfoo (unsigned long *a, unsigned long long *p)\n{\n  *p = *a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23445.c",
    "content": " struct buffer_head {\n   char *b_data;\n };\n   void asfs_deletebnode( struct buffer_head *bhsec)  {\n     if (bhsec == 0)   {\n     void *bnc2 = (void *) bhsec->b_data;\n     if (bnc2)       return;\n     if (bhsec)       __brelse(bhsec);\n   }\n }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23476.c",
    "content": "int h(int);\nint t;\nstatic inline int f(const int i)\n{\n  int tt = i;\n  _Bool a = i < t;\n  if (a)\n    return h(t);\n  return 9;\n}\nint g(void)\n{\n  return f(0x7FFFFFFF);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23929.c",
    "content": "/* PR tree-optimization/23929 */\n\nextern void bar (char *);\n\nvoid\nfoo (int n, char *z)\n{\n  char b[2048];\n  int x, y;\n\n  bar (b);\n  for (y = 0; y < 60; y++)\n    if (n == 600)\n      for (x = 0; x < 320;)\n\t{\n\t  *z++ = b[x];\n\t  x += 1;\n\t  *z++ = b[x];\n\t  x += 1;\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23944.c",
    "content": "float f(float src[][4])\n{\n return *(src[3]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23946.c",
    "content": "\nextern int foo (void);\n\nint\navi_parse_comments (int fd, char *buf, int space_left)\n{\n  int len = 0, readlen = 0, k;\n  char *data, *c, *d;\n\n  if (fd <= 0 || !buf || space_left <= 0)\n    return -1;\n\n  memset (buf, 0, space_left);\n\n  readlen = foo ();\n  if (!(data = malloc (readlen * sizeof (char) + 1)))\n    return -1;\n\n  c = data;\n  space_left--;\n\n  while (len < space_left)\n    {\n      if (!c || *c == '\\0')\n\tbreak;\n      else if (*c == 'I')\n\t{\n\t  d = c + 4;\n\n\t  k = 0;\n\t  while (d[k] != '\\r' && d[k] != '\\n' && d[k] != '\\0')\n\t    ++k;\n\t  if (k >= space_left)\n\t    return len;\n\n\n\t  memcpy (buf + len, c, 4);\n\t  len += 4;\n\n\n\t  long2str (buf + len, k + 1);\n\t  len += 4;\n\n\n\t  memcpy (buf + len, d, k);\n\n\t  *(buf + len + k + 1) = '\\0';\n\n\n\t  if ((k + 1) & 1)\n\t    {\n\t      k++;\n\t      *(buf + len + k + 1) = '\\0';\n\t    }\n\t  len += k + 1;\n\n\n\t  while (*c != '\\n' && *c != '\\0')\n\t    ++c;\n\t  if (*c != '\\0')\n\t    ++c;\n\t  else\n\t    break;\n\n\t}\n    }\n  free (data);\n\n  return len;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr23960.c",
    "content": "/* PR tree-optimization/23960\n   fold-const.c used to construct a comparison node with one pointer\n   operand and one non-pointer operand.  */\n\nvoid abort (void) __attribute__ ((noreturn));\n\nvoid\nfoo (char *d, unsigned long int n)\n{ \n  if (d + n > d)\n    abort ();\n} \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr24227.c",
    "content": "int Fdisplay_buffer   (int buffer)\n{\n  if (((struct buffer *) ((unsigned int) buffer)) ==\n      (0,(struct buffer *) ((unsigned int) ((buffer) & 1))))\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr24883.c",
    "content": "typedef struct _rec_stl rec_stl;\nstruct _rec_stl {\n   unsigned char **strs;\n};\norec_str_list(int count) {\n   rec_stl *stl;\n   int i, j;\n   int li, lj;\n   unsigned char ci, cj;\n   for (i = 0; i < count; i++) {\n      for (j = i + 1; j < count; j++) {\n         cj = lj > 2 ? stl->strs[j][0] : (long)stl->strs[j] & 0xff;\n         if ((count >= 16 && cj < ci) || (cj == ci && lj > li)) {\n            stl->strs[j] = stl->strs[i];\n            ci ^= cj;\n            cj ^= ci;\n            ci ^= cj;\n         }\n      }\n   }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr24930.c",
    "content": "/* PR 24930 */\nextern int foo(int u) __attribute__((noinline));\nint foo(int u) {return 0;}\nint\nmain(int argc, char** argv)\n{\n  const char *buf = argv[1];\n  \n  unsigned int data = (((unsigned int) buf[0]) << 8) + (unsigned int) buf[1];\n  if (data & 0x8000) {\n    data &= 0x7fff ;\n    data ^= 0x7fff ;\n    data += 1 ;\n    data *= -1 ;\n  }\n  return foo((int)data);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25224.c",
    "content": "/* { dg-options \"-funswitch-loops\" } */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nstatic float rgam;\nextern void *jmp(void *);\n\nvoid drotmg(float d1) {\nvoid *labels[] = { &&L170, &&L180, 0 };\n\n  for(;;) {\n    goto *jmp(labels);\n    if (d1 <= rgam)\n      goto L170;\n\nL170:\n    if (d1 <= rgam)\n      goto L170;\n  }\n\nL180:\n  goto L170;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25310.c",
    "content": "\n/* Prevent spurious test failures on 16-bit targets.  */\n#if __INT_MAX__ >= 2147483647L\n\nextern int f (char *, int);\n\nvoid test (void)\n{\n  char buffer[65536];\n  char *bufptr;\n  char *bufend;\n  int bytes;\n\n  bufptr = buffer;\n  bufend = buffer + sizeof(buffer) - 1;\n\n  while ((bytes = f (bufptr, bufend - bufptr)) > 0)\n    bufptr += bytes;\n}\n\n#endif\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25311.c",
    "content": "\nstruct w\n{\n  int top;\n  int left;\n  int height;\n  int width;\n  struct w *next;\n  struct w *parent;\n  struct w *child;\n};\n\nextern struct w *Qnil;\n\nvoid\nset_size (struct w *w, int new_size, int nodelete, int set_height)\n{\n  int old_size = set_height? w->height : w->width;\n\n  if (nodelete || w->parent == Qnil)\n    {\n      int last_pos, last_old_pos, pos, old_pos, first;\n      int div_val = old_size << 1;\n      struct w *c;\n\n      last_pos = first = set_height? w->top : w->left;\n      last_old_pos = 0;\n\n      for (c = w->child; c != Qnil; c = c->next)\n\t{\n\t  if (set_height)\n\t    old_pos = last_old_pos + c->height;\n\t  else\n\t    old_pos = last_old_pos + c->width;\n\n\t  pos = (((old_pos * new_size) << 1) + old_size) / div_val;\n\t  set_size (c, pos + first - last_pos, 1, set_height);\n\t  last_pos = pos + first;\n\t  last_old_pos = old_pos;\n\t}\n\n      if (!nodelete)\n\tfor (c = w->child; c != Qnil; c = c->next)\n\t  use (c);\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25483.c",
    "content": "/* { dg-options \"-fmove-loop-invariants\" } */\n\nstatic int mdct_win[8];\nint x;\n\nint\ndecode_init (double d)\n{\n  int j;\n  for (j = 4; j; j--)\n    {\n      d *= 0.5;\n      mdct_win[j] = (d * 3);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25513.c",
    "content": "int f(void)\n{\n  static _Complex double t;\n  int i, j;\n  for(i = 0;i<2;i++)\n    for(j = 0;j<2;j++)\n      t = .5 * 1.0;\n  return t;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25514.c",
    "content": "struct node {\n  struct node *next;\n  int value;\n};\n\nstruct node *current_node, global_list;\n\nvoid\nbar (void)\n{\n  struct node *node, *next;\n\n  node = current_node;\n  next = node->next;\n  if (node != &global_list)\n    current_node = next;\n  else\n    {\n      node = global_list.next;\n      global_list.value = node->value;\n      global_list.next = node->next;\n    }\n  foo (node);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25860.c",
    "content": "/* We used to ICE because PRE would try to PRE the load of *Note from the\n   loop. */\n\nstruct g\n{\n  int i;\n};\nstruct f\n{\n  struct g i;\n};\nint GSM_RingNoteGetFullDuration(struct g)__attribute__((const));\nvoid savewav(struct f *gg)\n{\n  struct g *Note;\n  long i = 0,j,length=0;\n  Note = &gg->i;\n  for (j=0;j<GSM_RingNoteGetFullDuration(*Note);j++)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr25861.c",
    "content": "int f(void *a)\n{\n  return !(&a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26213.c",
    "content": "void\nxnanosleep (_Bool overflow)\n{\n  struct { int tv_nsec; } ts_sleep;\n  if (0 <= ts_sleep.tv_nsec)\n    overflow |= 1;\n\n  for (;;)\n    {\n      if (overflow)\n        ts_sleep.tv_nsec = 0;\n      if (foo (ts_sleep))\n        break;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26255.c",
    "content": "typedef short int16_t;\n\nint round_sample(int *sum);\n\n#define MULS(ra, rb) ((ra) * (rb))\n\n#define SUM8(sum, op, w, p) \\\n{ \\\n  sum op MULS((w)[0 * 64], p[0 * 64]); \\\n  sum op MULS((w)[1 * 64], p[1 * 64]); \\\n  sum op MULS((w)[2 * 64], p[2 * 64]); \\\n  sum op MULS((w)[3 * 64], p[3 * 64]); \\\n  sum op MULS((w)[4 * 64], p[4 * 64]); \\\n  sum op MULS((w)[5 * 64], p[5 * 64]); \\\n  sum op MULS((w)[6 * 64], p[6 * 64]); \\\n  sum op MULS((w)[7 * 64], p[7 * 64]); \\\n}\n\nvoid foo(int *dither_state, int *samples)\n{\n  int16_t *synth_buf;\n  const int16_t *w, *p;\n  int sum;\n\n  sum = *dither_state;\n  p = synth_buf + 16;\n  SUM8(sum, +=, w, p);\n  p = synth_buf + 48;\n  SUM8(sum, -=, w + 32, p);\n  *samples = round_sample(&sum);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26425.c",
    "content": "struct keyring_list {\n struct key *keys[0];\n};\nvoid keyring_destroy(struct keyring_list *keyring, unsigned short a)\n{\n int loop;\n  for (loop = a - 1; loop >= 0; loop--)\n   key_put(keyring->keys[loop]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26622.c",
    "content": "/* PR middle-end/26622\n   fold_ternary used to create a tree with mismatching types, causing\n   (const_int 128) to appear in QImode rtx.  */\n\nunsigned char g;\n\nunsigned long long\nfoo (void)\n{\n  return ((long long) ((g & 0x80) != 0)) << 7;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26626.c",
    "content": "typedef union {\n    int d;\n} U;\n\nint rv;\nvoid breakme()\n{\n    U *rv0;\n    U *pretmp = (U*)&rv;\n    rv0 = pretmp;\n    rv0->d = 42;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26725.c",
    "content": "struct { unsigned int num; } *numptr;\nvoid notice (int);\nvoid doit (unsigned int *);\n\nvoid\nrewrite_finalize_block (int x)\n{\n  unsigned int *tmp;\n  while (tmp = (numptr ? &numptr->num : 0), (tmp ? *tmp : 0) > 0)\n    {\n      tmp = (numptr ? &numptr->num : 0);\n      (void) (*tmp ? 0 : notice (x));\n      doit (tmp);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26781-1.c",
    "content": "void zconfdump(void)\n{\n  char *p, *p2;\n  for (p2 = p; p2; )\n    {\n      char __a0, __a1, __a2;\n      __a0 = ((__const char *) (\"\\\"\\\\\"))[0];\n      if (__a0)\n        return;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26781-2.c",
    "content": "void zconfdump(__SIZE_TYPE__ i)\n{\n  for (;;)\n    {\n      char __a0;\n      __a0 = (\"\\\"\\\\\")[i];\n      if (__a0)\n        return;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26833.c",
    "content": "void yasm_lc3b__parse_insn( int num_info, int *num_operands\n , int *operands, int op)\n{\n  int found = 0;\n  int i;\n  for (; num_info>0 && !found; num_info--)\n   {\n    int mismatch = 0;\n     for(i = 0;op && (i<*num_operands)&& !mismatch; i++)\n     {\n       if (!(int)(operands[i] & 0x1))\n         mismatch = 1;\n       if (mismatch)\n         break;\n     }\n    if (!mismatch)\n      found = 1;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr26840.c",
    "content": "extern int f1 (void **);\nextern void f2 (void *);\n\nstruct s\n{\n  unsigned char field1;\n  int field2;\n};\n\nstatic inline struct s *\nget_globals (void)\n{\n  struct s * r;\n  void * rr;\n\n  if (f1 (&rr))\n    return 0;\n  r = rr;\n  if (! r)\n    {\n      extern struct s t;\n      r = &t;\n    }\n  r->field1 = 1;\n  return r;\n}\n\nvoid\natexit_common (const void *dso)\n{\n  struct s *g = get_globals ();\n\n  if (! g)\n    return;\n  if (g->field1)\n    {\n      g->field2 = 0;\n      f2 (g);\n    }\n  else\n    f2 (g);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27087.c",
    "content": "extern int ptbl[4];\nextern int ctbl[4];\n\nvoid doViews(void) {\n    int  *c = ctbl, *p = ptbl;\n    while (1)\n  {\n        p++;\n        c++;\n        if (*p)\n        {\n            if (c == p)\n            {\n                if (*c)\n                    return;\n            }\n            else\n              return;\n        }\n    }\n\n    g();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27282.c",
    "content": "/* This test used to ICE on PowerPC at -O due to combine GEN_INT bug.  */\ntypedef struct _ColRowInfo ColRowInfo;\ntypedef struct { }\nGnmSheetRange;\nstruct _ColRowInfo\n{\n  float size_pts;\n  unsigned margin_a:3;\n  unsigned margin_b:3;\n  unsigned visible:1;\n};\ncolrow_equal (ColRowInfo const *a, ColRowInfo const *b)\n{\n  return a->size_pts == b->size_pts && a->margin_a == b->margin_a\n    && a->visible == b->visible;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27341-1.c",
    "content": "extern double R_NaReal;\nvoid z_atan2 (double _Complex * r, double _Complex * ccs)\n{\n    if (*ccs == 0)\n        __imag__ *r = R_NaReal;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27341-2.c",
    "content": "void zgemm_ (const int*, const double*);\nextern void matmul_c8 (_Complex double * dest)\n{\n  const int  ldc = 0;\n  const double zero = 0;\n  zgemm_ ( &zero, &ldc);\n  dest[1] += 1 ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27373.c",
    "content": "typedef struct atype\n{\n    float bg[1], cg[1];\n    _Bool ant;\n}atype;\n\n\nvoid cp_assert(_Bool*, float*, int*, _Bool*);\n\nvoid f(atype **rng_stream, int *error, float u)\n{\n    _Bool t = *rng_stream != 0;\n    float routinep;\n    _Bool failure;\n    cp_assert ( &t, &routinep, error, &failure);\n    if (failure == 0)\n    {\n        typedef float ty[1];\n        ty *tt = &((*rng_stream)->bg);\n        int i = 1;\n\n        do \n        {\n            (*tt)[i - 1] = u;\n            i ++;\n        }while (i > 1);\n        {\n            ty *tt = &(*rng_stream)->cg;\n            int i = 1;\n\n            do \n            {\n                (*tt)[i - 1] = u;\n                i ++;\n            }while (i > 1);\n        }\n    }    \n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27528.c",
    "content": "/* Check that constant constraints like \"i\", \"n\" and \"s\" can be used in\n   cases where the operand is an initializer constant.  */\n/* { dg-require-effective-target nonpic } */\n\nint x[2] = { 1, 2 };\n\n#ifdef __OPTIMIZE__\nstatic inline void __attribute__((__always_inline__))\ninsn1 (int x)\n{\n  asm volatile (\"\" :: \"n\" (x), \"i\" (x));\n}\n\nstatic inline void __attribute__((__always_inline__))\ninsn2 (const void *x)\n{\n  asm volatile (\"\" :: \"s\" (x), \"i\" (x));\n}\n#endif\n\nvoid\nfoo (void)\n{\n#ifdef __OPTIMIZE__\n  insn1 (2);\n  insn1 (2);\n  insn1 (400);\n  insn1 (__LINE__);\n  insn2 (x);\n  insn2 (x);\n  insn2 (&x[1]);\n  insn2 (\"string\");\n#endif\n  asm volatile (\"\" :: \"s\" (x), \"i\" (x));\n  /* At the time of writing, &x[1] is decomposed before reaching expand\n     when compiling with -O0.  */\n  asm volatile (\"\" :: \"s\" (\"string\"), \"i\" (\"string\"));\n  asm volatile (\"\" :: \"s\" (__FILE__), \"i\" (__FILE__));\n  asm volatile (\"\" :: \"s\" (__FUNCTION__), \"i\" (__FUNCTION__));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27571.c",
    "content": "/* PR target/27571\n   alpha_does_function_need_gp did not properly skip jump table insns  */\n\nint r3isseparator(int);\nvoid r3isdigit(int);\nvoid r3decimalvalue(int);\n\nvoid r7todouble(int *storage, int *count) {\n    int i = 0;\n    int state = 0;\n    int cc = 0;\n    while (i > *count) {\n\tcc = *storage;\n\tswitch (state) {\n\tcase 0:\n\t    if (r3isseparator(cc))\n\t\tstate = 1;\n\tcase 1:\n\t    r3isdigit(cc);\n\tcase 2:\n\tcase 5:\n\tcase 6:\n\t    r3decimalvalue(cc);\n\t}\n\ti++;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27863.c",
    "content": "/* This test used to ICE on IA64.  */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nlong stack[100];\nint main(int argc,char**argv,char **envp)\n{\n  long *esp=stack;\n  static void* jarray[]={ &&KeyCtrlKV };\n *++esp=(long)&&_loc0;\n goto SetTermStruc;\n _loc0:;\n *++esp=(long)&&_loc1;\n _loc1:;\n*++esp=(long)&&_loc35;\n _loc35:;\ngoto *(*esp--);\n*++esp=(long)&&_loc36;\n _loc36:;\n*++esp=(long)&&_loc37;\n _loc37:;\nKeyCtrlKV:\n*++esp=(long)&&_loc66;\n_loc66:;\n*++esp=(long)&&_loc106;\n _loc106:;\n*++esp=(long)&&_loc119;\n _loc119:;\nSetTermStruc:\n goto *(*esp--);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27889.c",
    "content": "/* { dg-require-effective-target trampolines } */\n\nvoid h(void (*)(void));\n_Complex int g (void)\n{\n  _Complex int x;\n  void f(void)\n  {\n     x = x + x;\n  }\n  h(f);\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr27907.c",
    "content": "typedef double fann_type;\ntypedef struct { } _G_fpos64_t;\nstruct fann_neuron\n{\n    fann_type value;\n}\n__attribute__ ((packed));\nstruct fann_layer\n{\n    struct fann_neuron *last_neuron;\n};\nstruct fann\n{\n    struct fann_layer *first_layer;\n};\nfann_run (struct fann *ann, fann_type * input)\n{\n  struct fann_layer *layer_it, *layer_it2, *last_layer;\n  for (layer_it = ann->first_layer + 1; layer_it != last_layer; layer_it++)\n    {\n      ((layer_it - 1)->last_neuron - 1)->value = 1;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28489.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\ntypedef int c_int;\nunion c_insn\n{\n  void (*op) ();\n  c_int *mem;\n  c_int imm;\n};\nstatic union c_insn c_stack[((0x100 + 4) * 4)];\nstatic struct c_ident *c_funcs;\nstatic void (*c_op_bz) ();\nstatic void c_direct (union c_insn *addr);\nc_compile (int (*ext_getchar) (), void (*ext_rewind) (),\n\t   struct c_ident *externs)\n{\n  c_direct (((void *) 0));\n}\nstatic void\nc_direct (union c_insn *addr)\n{\n  union c_insn *pc = addr;\n  union c_insn *sp = c_stack;\n  c_int imm = 0;\n  static void *ops[] = {\n    &&op_index, &&op_assign, &&op_add_a, &&op_sub_a, &&op_mul_a, &&op_div_a,\n      &&op_mod_a, &&op_or_a, &&op_xor_a, &&op_and_a, &&op_shl_a, &&op_shr_a,\n  };\n    {\n      c_op_bz = &&op_bz;\n    }\n  goto *(pc++)->op;\nop_bz:if (imm)\n    {\n    }\nop_push_imm_imm:(sp - 2)->imm = imm;\n  goto *(pc - 1)->op;\nop_index:imm = *((sp - 3)->mem += imm);\nop_assign:*(sp - 3)->mem = imm;\nop_add_a:imm = *(sp - 3)->mem += imm;\nop_sub_a:imm = *(sp - 3)->mem -= imm;\nop_mul_a:imm = *(sp - 3)->mem *= imm;\nop_div_a:imm = *(sp - 3)->mem /= imm;\nop_mod_a:imm = *(sp - 3)->mem %= imm;\nop_or_a:imm = *(sp - 3)->mem |= imm;\nop_xor_a:imm = *(sp - 3)->mem ^= imm;\nop_and_a:imm = *(sp - 3)->mem &= imm;\nop_shl_a:imm = *(sp - 3)->mem <<= imm;\nop_shr_a:imm = *(sp - 3)->mem >>= imm;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28675.c",
    "content": "struct fb_cmap {\n unsigned int start;\n unsigned int len;\n unsigned short *red;\n unsigned short *green;\n unsigned short *blue;\n unsigned short *transp;\n};\n\ntypedef struct {\n    int r;\n    int g;\n    int b;\n    int a;\n} rgba_t;\n\nstatic unsigned int cmap_len;\n\nextern unsigned int red_len, green_len, blue_len, alpha_len;\nextern struct fb_cmap fb_cmap;\nextern rgba_t *clut;\nextern int fb_set_cmap(void);\n\nvoid directcolor_update_cmap(void)\n{\n    unsigned int i;\n\n    for (i = 0; i < cmap_len; i++) {\n      if (i < red_len)\n\tfb_cmap.red[i] = clut[i].r;\n      if (i < green_len)\n\tfb_cmap.green[i] = clut[i].g;\n      if (i < blue_len)\n\tfb_cmap.blue[i] = clut[i].b;\n      if (fb_cmap.transp && i < alpha_len)\n\tfb_cmap.transp[i] = clut[i].a;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28776-1.c",
    "content": "typedef struct dw_fde_struct\n{\n  int decl;\n} *dw_fde_ref;\ndw_fde_ref fde_table;\nunsigned fde_table_in_use;\nvoid output_call_frame_info (void)\n{\n  unsigned int i;\n  dw_fde_ref fde;\n  for (i = 0; i < fde_table_in_use; i++)\n    {\n      fde = &fde_table[i];\n      tree_contains_struct_check_failed (fde_table[i].decl);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28776-2.c",
    "content": "typedef struct RangeCoder\n{\n    unsigned char one_state[256];\n} RangeCoder;\nstatic inline void put_rac(RangeCoder *c, unsigned char* const state)\n{\n  *state= c->one_state[*state];\n}\ntypedef struct PlaneContext{\n    unsigned (*state)[32];\n} PlaneContext;\nstatic inline void put_symbol(RangeCoder *c, unsigned char *state)\n{\n    int i;\n    const int e;\n    put_rac(c, state);\n    for(i=e-1; i>=0; i--)\n      put_rac(c, state+22+i);\n}\nint encode_line(void)\n{\n    PlaneContext * const p;\n    RangeCoder * const c;\n    int a;\n    put_symbol(c, p->state[a]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28865.c",
    "content": "struct var_len\n{\n  int field1;\n  const char field2[];\n};\n\n/* Note - strictly speaking this array declaration is illegal\n   since each element has a variable length.  We used to allow\n   this because it was used in existing code.\n   Since PR64417 we reject this code.  */\nstatic const struct var_len var_array[] = \n{\n  { 1, \"Long exposure noise reduction\" }, /* { dg-error \"initialization of flexible array member\" } */\n  { 2, \"Shutter/AE lock buttons\" }, /* { dg-error \"initialization of flexible array member\" } */\n  { 3, \"Mirror lockup\" } /* { dg-error \"initialization of flexible array member\" } */\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr28905.c",
    "content": "/* We used to ICE here because after VRP we ended up with\n   non-compatible ranges in a value-range equivalences set.  */\nvoid code_comment (int size)\n{\n  int i;\n  for (i = 0; i < size; i++)\n    if (i)\n      if (i < 0)\n        if (i < 0)\n          return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr29128.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\ntypedef unsigned long Eterm;\nprocess_main (void)\n{\n  register Eterm x0;\n  register Eterm *reg = ((void *) 0);\n  register Eterm *I = ((void *) 0);\n  static void *opcodes[] = {\n      &&lb_allocate_heap_zero_III,\n      &&lb_allocate_init_tIy, &&lb_allocate_zero_tt\n  };\nlb_allocate_heap_III:{\n    Eterm *next;\n    goto *(next);\n  }\nlb_allocate_heap_zero_III:{\n  }\nlb_allocate_init_tIy:{\n  }\nlb_allocate_zero_tt:{\n    Eterm *next;\n    {\n      Eterm *tmp_ptr = ((Eterm *) (((x0)) - 0x1));\n      (*(Eterm *) (((unsigned char *) reg) + (I[(0) + 1]))) = ((tmp_ptr)[0]);\n      x0 = ((tmp_ptr)[1]);\n    }\n    goto *(next);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr29201.c",
    "content": "/* { dg-do assemble { target ia64-*-* } } */\ntypedef int gint;\ntypedef gint gboolean;\ntypedef unsigned int guint;\ntypedef struct _MetaRectangle MetaRectangle;\nstruct _MetaRectangle\n{\n  int x;\n  int y;\n};\ntypedef struct _MetaDisplay MetaDisplay;\ntypedef struct _MetaFrame MetaFrame;\ntypedef struct _MetaWindow MetaWindow;\ntypedef struct\n{\n  int win_gravity;\n}\nXSizeHints;\ntypedef enum\n{\n  META_DEBUG_FOCUS = 1 << 0, META_DEBUG_WORKAREA = 1 << 1, META_DEBUG_STACK =\n    1 << 6, META_DEBUG_WINDOW_OPS = 1 << 7, META_DEBUG_GEOMETRY =\n    1 << 20, META_DEBUG_EDGE_RESISTANCE = 1 << 21\n}\nMetaStackLayer;\nstruct _MetaWindow\n{\n  MetaDisplay *display;\n  MetaFrame *frame;\n  guint user_has_move_resized:1;\n  MetaRectangle user_rect;\n  XSizeHints size_hints;\n};\nvoid meta_window_get_position (MetaWindow * window, int *x, int *y);\ntypedef struct _MetaFrameGeometry MetaFrameGeometry;\nstruct _MetaFrameGeometry\n{\n};\nstruct _MetaFrame\n{\n  MetaWindow *window;\n  MetaRectangle rect;\n  int child_x;\n  int child_y;\n};\ntypedef enum\n{\n  META_IS_CONFIGURE_REQUEST = 1 << 0, META_DO_GRAVITY_ADJUST =\n    1 << 3, META_IS_RESIZE_ACTION = 1 << 4\n}\nMetaMoveResizeFlags;\nadjust_for_gravity (MetaWindow * window, MetaFrameGeometry * fgeom,\n\t\t    gboolean coords_assume_border, int gravity,\n\t\t    MetaRectangle * rect)\n{\n  int ref_x, ref_y;\n  int child_x, child_y;\n  int frame_width, frame_height;\n  switch (gravity)\n    {\n    case 1:\n      ref_x = rect->x;\n    }\n  switch (gravity)\n    {\n    case 1:\n      rect->y = ref_y + child_y;\n    case 2:\n      rect->x = ref_x - frame_width / 2 + child_x;\n      break;\n    case 3:\n    case 5:\n    case 6:\n      rect->x = ref_x - frame_width + child_x;\n    }\n}\nmeta_window_move_resize_internal (MetaWindow * window,\n\t\t\t\t  MetaMoveResizeFlags flags,\n\t\t\t\t  int resize_gravity, int root_x_nw,\n\t\t\t\t  int root_y_nw, int w, int h)\n{\n  unsigned int mask;\n  MetaFrameGeometry fgeom;\n  gboolean need_resize_client = (0);\n  gboolean is_configure_request;\n  MetaRectangle new_rect;\n  MetaRectangle old_rect;\n  {\n    adjust_for_gravity (window, window->frame ? &fgeom : ((void *) 0),\n\t\t\tis_configure_request, window->size_hints.win_gravity,\n\t\t\t&new_rect);\n  }\n  meta_window_constrain (window, window->frame ? &fgeom : ((void *) 0), flags,\n\t\t\t resize_gravity, &old_rect, &new_rect);\n  if (mask != 0)\n    {\n      {\n\tmeta_topic_real (META_DEBUG_GEOMETRY,\n\t\t\t need_resize_client ? \"true\" : \"false\");\n      }\n    }\n  {\n    window->user_has_move_resized = (!(0));\n    meta_window_get_position (window, &window->user_rect.x,\n\t\t\t      &window->user_rect.y);\n  }\n}\nvoid\nmeta_window_get_position (MetaWindow * window, int *x, int *y)\n{\n  if (window->frame)\n    {\n      *x = window->frame->rect.x + window->frame->child_x;\n      *y = window->frame->rect.y + window->frame->child_y;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr29241.c",
    "content": "static inline __attribute__((always_inline)) void ip_finish_output2(){}\nvoid ip_fragment(void (*)(void));\nstatic inline __attribute__((always_inline)) void ip_finish_output()\n{\n ip_fragment(ip_finish_output2);\n ip_finish_output2();\n}\nvoid ip_mc_output()\n{\n ip_finish_output();\n}\nvoid ip_output()\n{\n ip_finish_output();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr29250.c",
    "content": "/* We used to ICE because EXPAND_SUM was being used for all recursive calls\n   to expand_expr.  */\nstruct TSparseEntry\n{\n  int feat_index;\n  double entry;\n};\n\nstruct TSparse\n{\n  int vec_index;\n  int num_feat_entries;\n  struct TSparseEntry *features;\n};\n\nvoid\nget_full_feature_matrix (struct TSparse* sparse_feature_matrix, int num_vec)\n{\n  double *fm;\n  int v, f;\n\n  for (v=0; v < num_vec; v++)\n  {\n    for (f=0; f < sparse_feature_matrix[v].num_feat_entries; f++)\n    {\n      long long offs = sparse_feature_matrix[v].vec_index\n\t+ sparse_feature_matrix[v].features[f].feat_index;\n      fm[offs] = sparse_feature_matrix[v].features[f].entry;\n    }\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr29945.c",
    "content": "/* This test used to ICE on the SPU target. */\nextern const char *__ctype_ptr;\n\nparse_real (unsigned char c)\n{\n  if ((__ctype_ptr[c]&04) && c != '.')\n   unget_char ( c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30132.c",
    "content": "double testit(double _Complex* t)\n{\n  return *t==0.0?0.0:-*t;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30311.c",
    "content": "/* ICE in subreg_get_info: bug 30311.  */\n/* { dg-do compile { target i?86-*-* x86_64-*-* } } */\ninline double bar(double x)\n{\n  long double d;\n  __asm__ (\"\" : \"=t\" (d) : \"0\" (x));\n  return d;\n}\n\ndouble foo(double x)\n{\n  if (x)\n    return bar(x);\n  else\n    return bar(x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30338.c",
    "content": "/* We used to do folding with mismatched types which caused us to\n   infinitely loop in comparison foldings.  */\n\nextern char *grub_scratch_mem;\nint testload_func (char *arg, int flags)\n{\n  int i;\n  for (i = 0; i < 0x10ac0; i++)\n    if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem)))\n        != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem))))\n      return 0;\n  return 1;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30433.c",
    "content": "int f = (_Complex float)(0.5) == 0.5;\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30564-1.c",
    "content": "static int spready[] = {0, 1, 2, 3};\nvoid explosion_map (int y)\n{\n  int i;\n  for (i = 0; i < 4; i++)\n    if (y * spready[i] < 0)\n      break;\n}\nvoid explosion (void)\n{\n  int i;\n  explosion_map (0);\n  for (i = 0; i < 2; i++)\n    continue;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30564-2.c",
    "content": "\nstatic int RawOrEnc = 0;\nstatic inline void addpair(int fp, int un)\n{\n  if (RawOrEnc == 0 && fp != un)\n    RawOrEnc = 1;\n}\nint f(int un0, char *a, unsigned int __s2_len)\n{\n  addpair(un0, un0);\n  __s2_len < 4 ? __builtin_strcmp (a, \"-\") : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr30984.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\nint fs_exec(int ino)\n{\n void *src = 0;\n if (ino)\n   src = (void*)0xe000;\n goto *src;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31034.c",
    "content": "static inline int\nmod (int a, int n)\n{\n  return a >= n ? a % n : a;\n}\nvoid dpara(int);\nvoid opticurve (int m)\n{\n  int i;\n  for (i = 0; i < m; i++)\n    {\n        dpara(mod (i - 1, m));\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31345-1.c",
    "content": "/* PR tree-optimization/31345\n   This caused a crash in VRP when dealing with overflow infinities.  */\n\nvoid\ndpsnaffle (const char *kbuf)\n{\n  int hash, thash, head[2], off;\n    {\n      int _DP_i;\n      (hash) = 19780211;\n        {\n          (hash) = (hash) + (kbuf)[_DP_i];\n        }\n      (hash) = ((hash) * 43321879) & 0x7FFFFFFF;\n    }\n  while (off != 0)\n    {\n      if (hash > thash) {}\n      else if (hash < thash)\n        {\n          off = head[2];\n        }\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31541.c",
    "content": "typedef unsigned char Uchar;\nstruct scsi_mode_header {\n unsigned char sense_data_len : 8;\n};\nint f(void)\n{\n struct scsi_mode_header md;\nreturn *(Uchar*)&md;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31703.c",
    "content": "typedef unsigned long long HARD_REG_ELT_TYPE;\nstatic HARD_REG_ELT_TYPE reload_reg_used_in_output_addr[30];\nint reload_reg_reaches_end_p (unsigned int regno, int opnum)\n{\n    int i;\n    for (i = opnum + 1; i < opnum; i++)\n        if (reload_reg_used_in_output_addr[i]\n            & ((HARD_REG_ELT_TYPE)1 << regno))\n            return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31710.c",
    "content": "typedef short SHORT;\nstruct v { SHORT i; };\nvoid f(struct v *pin, struct v *pout) {\n        if (pin->i == (-0x7fff)-1)\n            pout->i = -pin->i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31797.c",
    "content": "struct GTeth_desc\n{\n  unsigned ed_cmdsts;\n};\nstruct GTeth_softc\n{\n  struct GTeth_desc txq_desc[32];\n  unsigned int txq_fi;\n  unsigned int txq_nactive;\n};\n\nvoid\nGTeth_txq_free (struct GTeth_softc *sc)\n{\n  struct GTeth_desc *txd = &sc->txq_desc[0];\n  txd->ed_cmdsts &= ~(1U << (31));\n}\nvoid\nGTeth_txq_done (struct GTeth_softc *sc)\n{\n  while (sc->txq_nactive > 0)\n    {\n      volatile struct GTeth_desc *txd = &sc->txq_desc[sc->txq_fi];\n      if (txd->ed_cmdsts)\n\t{\n\t  if (sc->txq_nactive == 1)\n\t    return;\n\t}\n      GTeth_txq_free (sc);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr31953.c",
    "content": "struct WView\n{\n  int hexedit_mode:1;\n};\ntoggle_hexedit_mode (struct WView *view)\n{\n  if (view->hexedit_mode)\n    {\n    }\n  else\n    {\n      view->hexedit_mode = !view->hexedit_mode;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32139.c",
    "content": "/* PR tree-optimization/32139 */\nint foo (void);\nint bar (void) __attribute__ ((const));\n\nint\ntest (int x)\n{\n  int a = (x == 10000 ? foo : bar) ();\n  int b = (x == 10000 ? foo : bar) ();\n  return a + b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32169.c",
    "content": "void f(char);\nstatic inline\nvoid * __memset_generic(char c)\n{\n  f(c);\n}\nint prepare_startup_playback_urb(\n     int b,\n     int c\n)\n{\n  char d;\n  if (b)\n    __memset_generic(c == ( 1) ? 0x80 : 0);\n  else\n    __memset_generic (c == ( 1) ? 0x80 : 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32349.c",
    "content": "/* { dg-options \"-fmodulo-sched\" } */\n\n\nextern long *x1, *x2, *x3;\n\nint\nfoo ()\n{\n  /* Switching the following two lines prevents the ICE.  */\n  long *p1, *p2;\n  long m, n, i;\n\n  p1 = x1;\n  p2 = x2;\n  n = 0;\n  for (i = *x3; 0 < i; i--)\n    {\n      m = (*p1++) ^ (*p2++);\n      m = (m & 0x55555555) + ((m >> 1) & 0x55555555);\n      m = (m & 0x33333333) + ((m >> 2) & 0x33333333);\n      m = (m + (m >> 4)) & 0x0f0f0f0f;\n      m = (m + (m >> 8));\n      n += m;\n    }\n  return n;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32355.c",
    "content": "typedef struct\n{\n}\n__sigset_t;\ntypedef struct\n{\n    char coredump;\n}\nEMode;\nextern EMode Mode;\nstruct sigaction\n{\n  __sigset_t sa_mask;\n  int sa_flags;\n};\ndoSignalsSetup (void)\n{\n  static const int signals[] = {\n    1, 2 , 3, 4, 6, 8, 11, 13, 14, 15, 10, 12, 17, 7\n  };\n  unsigned int i, sig;\n  struct sigaction sa;\n  for (i = 0; i < sizeof (signals) / sizeof (int); i++)\n    {\n      sig = signals[i];\n      if (Mode.coredump && (sig == 4 || sig == 8))\n        continue;\n      sa.sa_flags = (sig == 17);\n      sigemptyset (&sa.sa_mask);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32372.c",
    "content": "typedef struct AVCodecContext\n{\n  int flags;\n  void *priv_data;\n  char codec_name[32];\n}\nAVCodecContext;\ntypedef struct ScanTable\n{\n  int obmc;\n  int umvplus;\n  int h263_aic;\n}\nMpegEncContext;\nMPV_encode_init (AVCodecContext *avctx)\n{\n  MpegEncContext *s = avctx->priv_data;\n  s->umvplus = (avctx->flags & 0x02000000) ? 1 : 0;\n  s->h263_aic = (avctx->flags & 0x01000000) ? 1 : 0;\n  s->h263_aic = s->obmc || s->umvplus;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32399.c",
    "content": "void f(unsigned char *src, unsigned char *dst, int num, unsigned char *pos, unsigned char *diffuse, int hasdiffuse, unsigned char *specular, int hasspecular) {\n    int i;\n\n    for(i=num;i--;) {\n\tfloat *p = (float *) ((__SIZE_TYPE__) dst + (__SIZE_TYPE__) pos);\n        if(hasdiffuse) {\n            unsigned int *dstColor = (unsigned int *) (dst + i + (__SIZE_TYPE__) diffuse);\n            *dstColor = * (unsigned int *) ( ((__SIZE_TYPE__) src + (__SIZE_TYPE__) diffuse) + i);\n        }\n        if(hasspecular) {\n            unsigned int *dstColor = (unsigned int *) (dst + i + (__SIZE_TYPE__) specular);\n            *dstColor = * (unsigned int *) ( ((__SIZE_TYPE__) src + (__SIZE_TYPE__) specular) + i);\n        }\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32453.c",
    "content": "void ucs2reverse_internal_loop_single (long *irreversible, int foo)\n{\n    unsigned char bytebuf[2];\n    const unsigned char *inptr = bytebuf;\n    if (irreversible == (void *)0)\n\t;\n    else \n\tinptr += 2;\n    if (inptr != bytebuf)\n\t((inptr - bytebuf > foo) ? (void) (0) : __assert_fail ());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32482.c",
    "content": "typedef struct { unsigned long bits[((((1 << 0))+32 -1)/32)]; } nodemask_t;\nstatic inline __attribute__((always_inline))\nint bitmap_empty(const unsigned long *src, int nbits)\n{\n  return ! (*src & ( ((nbits) % 32) ? (1UL<<((nbits) % 32))-1 : ~0UL ));\n}\nstatic inline __attribute__((always_inline))\nint __nodes_empty(const nodemask_t *srcp, int nbits)\n{\n return bitmap_empty(srcp->bits, nbits);\n}\nextern nodemask_t node_online_map;\nvoid drain_array(void);\nvoid drain_cpu_caches(void)\n{\n int node;\n if (!__nodes_empty(&(node_online_map), (1 << 0)))\n     for (((node)) = 0; ((node)) < 1; ((node))++)\n     {\n     }\n if (!__nodes_empty(&(node_online_map), (1 << 0)))\n     drain_array();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32571.c",
    "content": "\nstruct list_head {\n struct list_head *next, *prev;\n};\nstruct ib_fmr {\n int *device;\n struct list_head list;\n};\nstatic inline\nstruct mthca_fmr *to_mfmr(struct ib_fmr *ibmr)\n{\n const struct ib_fmr *__mptr = (ibmr);\n return (struct mthca_fmr *)( (char *)__mptr );\n}\nvoid mthca_unmap_fmr(struct list_head *fmr_list)\n{\n struct ib_fmr *fmr;\n if (mthca_is_memfree())\n {\n for (fmr =\n ({ const struct list_head *__mptr = ((fmr_list)->next); (struct ib_fmr *)(\n(char *)__mptr - 8 );});\n &fmr->list != (fmr_list);\n fmr = ({ const struct list_head *__mptr = (fmr->list.next); (struct ib_fmr\n*)( (char *)__mptr - 8);})\n )\n  mthca_arbel_fmr_unmap(to_mfmr(fmr));\n }\n else\n for (fmr =\n ({ const struct list_head *__mptr = ((fmr_list)->next); (struct ib_fmr *)(\n(char *)__mptr - 8);});\n  &fmr->list != (fmr_list);\n  fmr = ({ const struct list_head *__mptr = (fmr->list.next); (struct ib_fmr\n*)( (char *)__mptr - 8);})\n  )\n  mthca_tavor_fmr_unmap(to_mfmr(fmr));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32584.c",
    "content": "typedef __SIZE_TYPE__ size_t;\n/* Kludge */\n#define unsigned\ntypedef __SIZE_TYPE__ __ssize_t;\n#undef unsigned\ntypedef struct\n{\n} __mbstate_t;\ntypedef struct\n{\n} _G_fpos64_t;\nenum\n{\n  __GCONV_INTERNAL_ERROR\n};\ntypedef int (*__gconv_trans_fct) (struct __gconv_step *,\n      size_t *);\ntypedef int (*__gconv_trans_context_fct) (void *, __const unsigned char *,\n       unsigned char *, unsigned char *);\nstruct __gconv_trans_data\n{\n};\nstruct _IO_marker {\n};\ntypedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,\n     size_t __n);\ntypedef struct blockbox {\n} *BBOXPTR, BBOX ;\ntypedef struct netbox {\n} *NBOXPTR, NBOX ;\ntypedef struct termbox {\n    struct termbox *nextterm ;\n} *TEBOXPTR, TEBOX ;\ntypedef struct tilebox {\n    TEBOXPTR termsptr ;\n}\n*TIBOXPTR ,\nTIBOX ;\ntypedef struct cellbox {\n    TIBOXPTR tileptr ;\n}\n*CBOXPTR ,\nCBOX ;\ntypedef struct dimbox {\n}\nDBOX ;\ntypedef struct rowbox {\n} ROWBOX ;\ntypedef struct binbox {\n}\nCHANGRDBOX ;\nextern int numcells ;\nextern int numterms ;\nsortpin()\n{\nint j , n , cell ;\nCBOXPTR ptr ;\nTIBOXPTR tile ;\nTEBOXPTR term , *xpptr ;\nfor( cell = 1 ; cell <= numcells + numterms ; cell++ ) {\n    if( ( tile = ptr->tileptr ) == (TIBOXPTR) ((void *)0) ) {\n    }\n    n = 0 ;\n    for( term = tile->termsptr ; term != (TEBOXPTR) ((void *)0) ;\n      term = term->nextterm ) {\n xpptr[ ++n ] = term ;\n    }\n    xpptr[ n + 1 ] = (TEBOXPTR) ((void *)0) ;\n    ptr->tileptr->termsptr = xpptr[ 1 ] ;\n    for( j = 1 ; j <= n ; j++ ) {\n    }\n}\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32606.c",
    "content": "int inb(int);\nvoid is870(unsigned int wkport, unsigned char j)\n{\n unsigned int tmport;\n unsigned char i;\n for (i = 0; i < 16; i++)\n {\n  tmport = wkport + 0x18;\n  tmport += 0x07;\n  while ((inb(tmport) & 0x80) == 0)\n  {\n   if ((inb(tmport) & 0x01) != 0)\n   {\n    tmport -= 0x06;\n    tmport += 0x06;\n   }\n  }\n  tmport = wkport + 0x14;\n  tmport += 0x04;\n  tmport += 0x07;\nwidep_in1:\n  if ((j & 0x01) != 0)\n  {\n   tmport -= 0x06;\n   tmport += 0x06;\n   goto widep_in1;\n  }\n  while ((inb(tmport) & 0x80) == 0) {}\n }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32780.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nextern void dont_optimize_away(size_t);\n\nvoid crashGcc(char*a)\n{\n        size_t b=(size_t)a - ((size_t)a & 1);\n        size_t c=(size_t)a - (b & (size_t)a);\n        dont_optimize_away(b+c);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32796.c",
    "content": "\n\n__SIZE_TYPE__ f (void *ptr)\n{\n  return ((__SIZE_TYPE__)(ptr)-1) | 1ULL;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32919.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nvoid _IO_vfprintf_internal ( char *f )\n{\n  static const void *const step0_jumps[] = { &&do_form_unknown, &&do_flag_plus, &&do_form_float };\n  const void * ptr = step0_jumps[0];\n  do {\n    char spec;\n    spec = (*++f);\n    goto *ptr;\ndo_flag_plus:\n     read_int (&f);\ndo_number:\n    _itoa_word (spec);\ndo_form_float:\n    if (ptr != ((void *)0))\n    {\n      spec = 'x';\n      goto do_number;\n    }\n    if (spec != 'S')\n      __strnlen ();\n    return;\n    do_form_unknown:;\n  }\n  while (*f != '\\0');\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32920.c",
    "content": "int a;\nvoid\nfoo(void)\n{\n  char buf[10];\n  a = a < sizeof(buf) ? a : sizeof (buf);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr32988.c",
    "content": "enum zone_type {\n  ZONE_DMA,\n  ZONE_NORMAL,\n  ZONE_MOVABLE,\n  MAX_NR_ZONES\n};\nstatic unsigned long arch_zone_lowest_possible_pfn[MAX_NR_ZONES];\nstatic unsigned long arch_zone_highest_possible_pfn[MAX_NR_ZONES];\nvoid free_area_init_nodes(unsigned long *max_zone_pfn)\n{\n  enum zone_type i;\n  for (i = 1; i < MAX_NR_ZONES; i++)\n  {\n    if (i == ZONE_MOVABLE)\n      continue;\n    unsigned long _x = max_zone_pfn[i];\n    unsigned long _y = arch_zone_lowest_possible_pfn[i];\n    arch_zone_highest_possible_pfn[i] = _x > _y ? _x : _y;\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33122.c",
    "content": "struct dis386 {\n  const char *x;\n};\n\nstatic const struct dis386 float_reg[][2] = {\n  { { \"fadd\" }, { \"fadd\" } },\n};\n\nvoid foo(int i, int j)\n{\n  const struct dis386 *dp;\n\n  dp = &float_reg[i - 1][j];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33133.c",
    "content": "static char newshuffle[256 + 16] = {\n  0x0f, 0x08, 0x05, 0x07, 0x0c, 0x02, 0x0e, 0x09, 0x00, 0x01, 0x06, 0x0d,\n    0x03, 0x04, 0x0b, 0x0a, 0x02, 0x0c, 0x0e, 0x06, 0x0f, 0x00, 0x01, 0x08,\n    0x0d, 0x03, 0x0a, 0x04, 0x09, 0x0b, 0x05, 0x07, 0x05, 0x02, 0x09, 0x0f,\n    0x0c, 0x04, 0x0d, 0x00, 0x0e, 0x0a, 0x06, 0x08, 0x0b, 0x01, 0x03, 0x07,\n    0x0f, 0x0d, 0x02, 0x06, 0x07, 0x08, 0x05, 0x09, 0x00, 0x04, 0x0c, 0x03,\n    0x01, 0x0a, 0x0b, 0x0e, 0x05, 0x0e, 0x02, 0x0b, 0x0d, 0x0a, 0x07, 0x00,\n    0x08, 0x06, 0x04, 0x01, 0x0f, 0x0c, 0x03, 0x09, 0x08, 0x02, 0x0f, 0x0a,\n    0x05, 0x09, 0x06, 0x0c, 0x00, 0x0b, 0x01, 0x0d, 0x07, 0x03, 0x04, 0x0e,\n    0x0e, 0x08, 0x00, 0x09, 0x04, 0x0b, 0x02, 0x07, 0x0c, 0x03, 0x0a, 0x05,\n    0x0d, 0x01, 0x06, 0x0f, 0x01, 0x04, 0x08, 0x0a, 0x0d, 0x0b, 0x07, 0x0e,\n    0x05, 0x0f, 0x03, 0x09, 0x00, 0x02, 0x06, 0x0c, 0x05, 0x03, 0x0c, 0x08,\n    0x0b, 0x02, 0x0e, 0x0a, 0x04, 0x01, 0x0d, 0x00, 0x06, 0x07, 0x0f, 0x09,\n    0x06, 0x00, 0x0b, 0x0e, 0x0d, 0x04, 0x0c, 0x0f, 0x07, 0x02, 0x08, 0x0a,\n    0x01, 0x05, 0x03, 0x09, 0x0b, 0x05, 0x0a, 0x0e, 0x0f, 0x01, 0x0c, 0x00,\n    0x06, 0x04, 0x02, 0x09, 0x03, 0x0d, 0x07, 0x08, 0x07, 0x02, 0x0a, 0x00,\n    0x0e, 0x08, 0x0f, 0x04, 0x0c, 0x0b, 0x09, 0x01, 0x05, 0x0d, 0x03, 0x06,\n    0x07, 0x04, 0x0f, 0x09, 0x05, 0x01, 0x0c, 0x0b, 0x00, 0x03, 0x08, 0x0e,\n    0x02, 0x0a, 0x06, 0x0d, 0x09, 0x04, 0x08, 0x00, 0x0a, 0x03, 0x01, 0x0c,\n    0x05, 0x0f, 0x07, 0x02, 0x0b, 0x0e, 0x06, 0x0d, 0x09, 0x05, 0x04, 0x07,\n    0x0e, 0x08, 0x03, 0x01, 0x0d, 0x0b, 0x0c, 0x02, 0x00, 0x0f, 0x06, 0x0a,\n    0x09, 0x0a, 0x0b, 0x0d, 0x05, 0x03, 0x0f, 0x00, 0x01, 0x0c, 0x08, 0x07,\n    0x06, 0x04, 0x0e, 0x02, 0x03, 0x0e, 0x0f, 0x02, 0x0d, 0x0c, 0x04, 0x05,\n    0x09, 0x06, 0x00, 0x01, 0x0b, 0x07, 0x0a, 0x08,\n};\nvoid newpassencrypt (char *, char *, char *);\nvoid\nnewpassencrypt (char *old, char *new, char *out)\n{\n  char *p, *bx;\n  char copy[8];\n  int i, di, ax;\n  char cl, dl, ch;\n  for (i = 0; i < 16; i++)\n    {\n      for (bx = old + 7; bx > old; bx--)\n        {\n          *bx = ((bx[-1] >> 4) & 0x0f) | ((*bx) << 4);\n        }\n      for (di = 0; di < 16; di++)\n        {\n          if (newshuffle[di + 0x100] & 1)\n            ch = ((copy[newshuffle[di + 0x100] / 2] >> 4) & 0x0f);\n          else\n            ch = copy[newshuffle[di + 0x100] / 2] & 0x0f;\n          out[di / 2] |= ((di & 1) ? ch << 4 : ch);\n        }\n      memcpy (copy, out, 8);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33146.c",
    "content": "typedef struct\n{\n  int end;\n  int term;\n}\njpc_enc_pass_t;\nvoid foo(int numpasses, jpc_enc_pass_t *p)\n{\n  jpc_enc_pass_t *pass;\n  jpc_enc_pass_t *termpass;\n  for (pass = p; pass != termpass; ++pass)\n    if (!pass->term)\n    {\n      termpass = pass;\n      while (termpass - pass < numpasses && !termpass->term)\n        ++termpass;\n      pass->end = termpass->end;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33166.c",
    "content": "static void ConvertAddr (char *saddr, void **addr)\n{\n  *addr = (void *) &saddr;\n}\nvoid DefineSelf (char *addr)\n{\n  ConvertAddr (addr, (void **) &addr);\n  if (addr[0] == 127 && addr[3] == 1)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33173.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef struct\n{\n}\n_G_fpos_t;\nextern int printf (__const char *__restrict __format, ...);\nextern size_t strlen (__const char *__s) __attribute__ ((__nothrow__))\n  __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\ntypedef struct rend_service_descriptor_t\n{\n  int patchlevel;\n  char status_tag[32];\n}\ntor_version_t;\ntest_dir_format (void)\n{\n  tor_version_t ver1;\n  {\n    long v2 = (long) (ver1.patchlevel);\n  }\n  {\n    const char *v1 = (\"\"), *v2 = (ver1.status_tag);\n    if (!__extension__ (\n\t\t\t {\n\t\t\t size_t __s1_len, __s2_len;\n\t\t\t (__builtin_constant_p (v1)\n\t\t\t  && (__s1_len = strlen (v1), __s2_len =\n\t\t\t      (!((size_t) (const void *) ((v1) + 1) -\n\t\t\t\t (size_t) (const void *) (v1) == 1)\n\t\t\t       || __s1_len >= 4)\n\t\t\t      &&\n\t\t\t      (!((size_t) (const void *) ((v2) + 1) -\n\t\t\t\t (size_t) (const void *) (v2) == 1)\n\t\t\t       || __s2_len >= 4)) ? __builtin_strcmp (v1,\n\t\t\t\t\t\t\t\t      v2)\n\t\t\t  : (__builtin_constant_p (v1)\n\t\t\t     && ((size_t) (const void *) ((v1) + 1) -\n\t\t\t\t __s1_len < 4) ? (__builtin_constant_p (v2)\n\t\t\t\t\t\t  &&\n\t\t\t\t\t\t  ((size_t) (const void *)\n\t\t\t\t\t\t   (size_t) (const void\n\t\t\t\t\t\t\t     *) (v2) ==\n\t\t\t\t\t\t   1) ? __builtin_strcmp (v1,\n\t\t\t\t\t\t\t\t\t  v2)\n\t\t\t\t\t\t  : (__extension__ (\n\t\t\t\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\t\t __const\n\t\t\t\t\t\t\t\t\t\t\t char\n\t\t\t\t\t\t\t\t\t\t\t *__s2\n\t\t\t\t\t\t\t\t\t\t\t =\n\t\t\t\t\t\t\t\t\t\t\t (__const\n\t\t\t\t\t\t\t\t\t\t\t  char\n\t\t\t\t\t\t\t\t\t\t\t  *)\n\t\t\t\t\t\t\t\t\t\t\t (v2);\n\t\t\t\t\t\t\t\t\t\t\t register\n\t\t\t\t\t\t\t\t\t\t\t __result\n\t\t\t\t\t\t\t\t\t\t\t =\n\t\t\t\t\t\t\t\t\t\t\t (((__const unsigned char *) (__const char *) (v1))[0] - __s2[0]); if (__s1_len > 0 && __result == 0)\n\t\t\t\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t __result;}\n    ))):\t\t\t\t\t     \n\t\t\t     (__builtin_constant_p (v2)\n\t\t\t      && ((size_t) (const void *) ((v2) + 1) -\n\t\t\t\t  __s2_len < 4) ? (__builtin_constant_p (v1)\n\t\t\t\t\t\t   && ((size_t) (const void *)\n\t\t\t\t\t\t       1) ?\n\t\t\t\t\t\t   __builtin_strcmp (v1,\n\t\t\t\t\t\t\t\t     v2)\n\t\t\t\t\t\t   : (__extension__ (\n\t\t\t\t\t\t\t\t\t      {\n\t\t\t\t\t\t\t\t\t      __const\n\t\t\t\t\t\t\t\t\t      char\n\t\t\t\t\t\t\t\t\t      *__s1\n\t\t\t\t\t\t\t\t\t      =\n\t\t\t\t\t\t\t\t\t      (__const\n\t\t\t\t\t\t\t\t\t       char\n\t\t\t\t\t\t\t\t\t       *)\n\t\t\t\t\t\t\t\t\t      (__const\n\t\t\t\t\t\t\t\t\t       *)\n\t\t\t\t\t\t\t\t\t      (v1);\n\t\t\t\t\t\t\t\t\t      register\n\t\t\t\t\t\t\t\t\t      __result\n\t\t\t\t\t\t\t\t\t      =\n\t\t\t\t\t\t\t\t\t      ((__const unsigned char *) (__const char *) (v2))[0]; if (__s2_len > 0 && __result == 0)\n\t\t\t\t\t\t\t\t\t      {\n\t\t\t\t\t\t\t\t\t      if\n\t\t\t\t\t\t\t\t\t      (__s2_len\n\t\t\t\t\t\t\t\t\t       ==\n\t\t\t\t\t\t\t\t\t       0)\n\t\t\t\t\t\t\t\t\t      {\n\t\t\t\t\t\t\t\t\t      }\n\t\t\t\t\t\t\t\t\t      }\n\t\t\t\t\t\t\t\t\t      __result;}\n  ))):\t\t\t\t\t\t      __builtin_strcmp (v1,\n\t\t\t\t\t\t\t\t\tv2))));}\n\t))\n      {\n\tprintf (\".\");\n      }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33382.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef struct {\n    int disable;\n    char *searchconfig[];\n} config_t;\ntypedef struct {\n    void *lng;\n} arglist_t;\nconfig_t config = {\n    .searchconfig = {\n\t\t     ((void *) 0)}\n};\n\narglist_t arglist[] = {\n    {\n     &config.searchconfig[0]}\n};\nconst int arglistsize = ((int) (sizeof(arglist) / sizeof(arglist_t)));\nvoid show_configuration(char *arg)\n{\n    int i;\n\n    if (!__extension__( {\n\t\t       size_t\n\t\t       __s1_len,\n\t\t       __s2_len; (__builtin_constant_p(arglist[i].lng)\n\t\t\t\t  && (__s1_len = (!((size_t)\n\t\t\t\t\t\t    (const void *)\n\t\t\t\t\t\t    1)\n\t\t\t\t\t\t  || __s2_len >= 4))\n\t\t\t\t  ? : (__builtin_constant_p(arglist[i].lng)\n\t\t\t\t       && ((size_t)\n\t\t\t\t\t   (const void *)\n\t\t\t\t\t   4)\n\t\t\t\t       ? (__builtin_constant_p(arg)\n\t\t\t\t\t  && ((size_t) (const void *) 1) ?\n\t\t\t\t\t  : (__extension__( {\n\t\t\t\t\t\t\t   __const * __s2 =\n\t\t\t\t\t\t\t   (__const *)\n\t\t\t\t\t\t\t   (arg);\n\t\t\t\t\t\t\t   register\n\t\t\t\t\t\t\t   __result =\n\t\t\t\t\t\t\t   (((__const\n\t\t\t\t\t\t\t      *) (arglist\n\t\t\t\t\t\t\t\t  [i].\n\t\t\t\t\t\t\t\t  lng))[0]\n\t\t\t\t\t\t\t    - __s2[0]);\n\t\t\t\t\t\t\t   if (__s1_len ==\n\t\t\t\t\t\t\t       0) {\n\t\t\t\t\t\t\t   if (__s1_len ==\n\t\t\t\t\t\t\t       0) {\n\t\t\t\t\t\t\t   __result =\n\t\t\t\t\t\t\t   (((__const\n\t\t\t\t\t\t\t      unsigned char\n\t\t\t\t\t\t\t      *) (__const\n\t\t\t\t\t\t\t\t  char\n\t\t\t\t\t\t\t\t  *)\n\t\t\t\t\t\t\t     (arglist[i].\n\t\t\t\t\t\t\t      lng))[3] -\n\t\t\t\t\t\t\t    __s2[3]);}\n\t\t\t\t\t\t\t   }\n\t\t\t\t\t\t\t   __result;}\n      ))):\n\t\t\t\t       (__builtin_constant_p(arg)\n\t\t\t\t\t?\n\t\t\t\t\t(__builtin_constant_p\n\t\t\t\t\t (arglist[i].lng)\n\t\t\t\t\t ? : (__extension__( {\n\t\t\t\t\t\t\t    char\n\t\t\t\t\t\t\t    __result\n\t\t\t\t\t\t\t    =\n\t\t\t\t\t\t\t    ((__const\n\t\t\t\t\t\t\t      unsigned *)\n\t\t\t\t\t\t\t     (arg))[0];\n\t\t\t\t\t\t\t    if\n\t\t\t\t\t\t\t    (__s2_len\n\t\t\t\t\t\t\t     > 0\n\t\t\t\t\t\t\t     && __result ==\n\t\t\t\t\t\t\t     0) {\n\t\t\t\t\t\t\t    if (__s2_len >\n\t\t\t\t\t\t\t\t1\n\t\t\t\t\t\t\t\t&& __result\n\t\t\t\t\t\t\t\t== 0) {\n\t\t\t\t\t\t\t    }\n\t\t\t\t\t\t\t    }\n\t\t\t\t\t\t\t    __result;}\n      ))):\n\n\n\n\t\t\t\t\t__builtin_strcmp(arglist[i].lng,\n\t\t\t\t\t\t\t arg))));}\n\t))\n\treturn;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33614.c",
    "content": "typedef float V2SF __attribute__ ((vector_size (8)));\n\nV2SF\nfoo (int x, V2SF a)\n{\n  while (x--)\n    a += (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f};\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33617.c",
    "content": "/* { dg-options \"-w -Wno-psabi\" { target { i?86-*-* x86_64-*-* } } } */\n\ntypedef float V8SF __attribute__ ((vector_size (32)));\nvoid bar (V8SF);\nvoid\nfoo (float x)\n{\n  bar ((V8SF) { x, x, x, x, x, x, x, x });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33641.c",
    "content": "/* This failed with type checking enabled.  */\n\ntypedef enum { one, two } exp;\nextern exp pe;\nextern char pt[256];\nvoid psd (void (*f) (void *), void *p);\nstatic void rle (void *e) { }\nvoid\nfoo (void)\n{\n  psd ((void (*)(void *)) (rle), (void *) (pt + pe));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr33855.c",
    "content": "/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n/* Used to segfault due to cselim not marking the complex temp var\n   as GIMPLE reg.  */\n\ntypedef struct {\n  int nsant, nvqd;\n  _Complex long double *vqd;\n} vsorc_t;\nvsorc_t vsorc;\n\nvoid foo(int next_job, int ain_num, int iped, long t) {\n  long double zpnorm;\n\n  while (!next_job)\n    if (ain_num)\n    {\n      if (iped == 1)\n        zpnorm = 0.0;\n      int indx = vsorc.nvqd-1;\n      vsorc.vqd[indx] = t*1.0fj;\n      if (cabsl(vsorc.vqd[indx]) < 1.e-20)\n        vsorc.vqd[indx] = 0.0fj;\n      zpnorm = t;\n      if (zpnorm > 0.0)\n        iped = vsorc.nsant;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34029-1.c",
    "content": "static const char s[] = \"ab.cd.efghijk\";\n\nint\nfoo (const char *x)\n{\n  const char *a;\n  int b = 0;\n\n  a = __builtin_strchr (s, '.');\n  if (a == 0)\n    b = 1;\n  else if ((a = __builtin_strchr (a + 1, '.')) == 0)\n    b = 1;\n  else if (__builtin_strncmp (s, x, a - s))\n    b = 1;\n  else if (__builtin_strncmp (a + 1, x + (a - s + 1), 4) < 0)\n    b = 1;\n\n  if (b)\n    return 4;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34029-2.c",
    "content": "static const char s[] = \"ab.cd.efghijk\";\nstatic const char t[] = \"abcde\";\n\nlong\nfoo (const char *x)\n{\n  const char *a;\n  long b = 0;\n\n  a = __builtin_strchr (s, '.');\n  return ((long) a) + (1 - (long) t);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34030.c",
    "content": "int myvar;\n\nint foo(int mynum)\n{\n  if ((((void *)0) == (myvar & ((1U<<0) << mynum))) && (mynum > 0))\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34091.c",
    "content": "typedef unsigned int GLenum;\ntypedef unsigned char GLboolean;\ntypedef int GLint;\ntypedef unsigned short GLushort;\ntypedef unsigned int GLuint;\ntypedef float GLfloat;\ntypedef GLushort GLchan;\nstruct gl_texture_image;\ntypedef struct __GLcontextRec GLcontext;\ntypedef void (*FetchTexelFuncC) (const struct gl_texture_image * texImage,\n\t\t\t\t GLint col, GLint row, GLint img,\n\t\t\t\t GLchan * texelOut);\nstruct gl_texture_format\n{\n};\nstruct gl_texture_image\n{\n  GLenum _BaseFormat;\n  GLboolean _IsPowerOfTwo;\n  FetchTexelFuncC FetchTexelc;\n};\nstruct gl_texture_object\n{\n  GLenum Target;\n  GLenum WrapS;\n  GLenum MinFilter;\n  GLenum MagFilter;\n  GLint BaseLevel;\n  GLint _MaxLevel;\n  struct gl_texture_image *Image[6][12];\n};\nenum _format\n{\n    MESA_FORMAT_RGBA_DXT3, MESA_FORMAT_RGBA_DXT5, MESA_FORMAT_RGBA,\n    MESA_FORMAT_RGB, MESA_FORMAT_ALPHA, MESA_FORMAT_LUMINANCE,\n};\ntypedef void (*texture_sample_func) (GLcontext * ctx,\n\t\t\t\t     const struct gl_texture_object * tObj,\n\t\t\t\t     GLuint n, const GLfloat texcoords[][4],\n\t\t\t\t     const GLfloat lambda[],\n\t\t\t\t     GLchan rgba[][4]);\nlerp_2d (GLfloat a, GLfloat b, GLfloat v00, GLfloat v10, GLfloat v01,\n\t GLfloat v11)\n{\n  const GLfloat temp0 = ((v00) + (a) * ((v10) - (v00)));\n  const GLfloat temp1 = ((v01) + (a) * ((v11) - (v01)));\n  return ((temp0) + (b) * ((temp1) - (temp0)));\n}\nstatic __inline__ void\nlerp_rgba (GLchan result[4], GLfloat t, const GLchan a[4], const GLchan b[4])\n{\n  result[0] = (GLchan) (((a[0]) + (t) * ((b[0]) - (a[0]))) + 0.5);\n  result[1] = (GLchan) (((a[1]) + (t) * ((b[1]) - (a[1]))) + 0.5);\n  result[2] = (GLchan) (((a[2]) + (t) * ((b[2]) - (a[2]))) + 0.5);\n}\nstatic __inline__ void\nlerp_rgba_2d (GLchan result[4], GLfloat a, GLfloat b, const GLchan t00[4],\n\t      const GLchan t10[4], const GLchan t01[4], const GLchan t11[4])\n{\n  result[0] = (GLchan) (lerp_2d (a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5);\n  result[1] = (GLchan) (lerp_2d (a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5);\n  result[2] = (GLchan) (lerp_2d (a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5);\n}\nstatic __inline__ void\nsample_2d_linear_repeat (GLcontext * ctx,\n\t\t\t const struct gl_texture_object *tObj,\n\t\t\t const struct gl_texture_image *img,\n\t\t\t const GLfloat texcoord[4], GLchan rgba[])\n{\n  GLint i0, j0, i1, j1;\n  GLfloat a, b;\n  GLchan t00[4], t10[4], t01[4], t11[4];\n  {\n  };\n  img->FetchTexelc (img, i1, j1, 0, t11);\n  lerp_rgba_2d (rgba, a, b, t00, t10, t01, t11);\n}\nsample_2d_nearest_mipmap_linear (GLcontext * ctx,\n\t\t\t\t const struct gl_texture_object *tObj,\n\t\t\t\t GLuint n, const GLfloat texcoord[][4],\n\t\t\t\t const GLfloat lambda[], GLchan rgba[][4])\n{\n  GLuint i;\n  GLint level = linear_mipmap_level (tObj, lambda[i]);\n  sample_2d_nearest (ctx, tObj, tObj->Image[0][tObj->_MaxLevel], texcoord[i], rgba[i]);\n  GLchan t0[4], t1[4];\n  sample_2d_nearest (ctx, tObj, tObj->Image[0][level], texcoord[i], t0);\n  sample_2d_nearest (ctx, tObj, tObj->Image[0][level + 1], texcoord[i], t1);\n}\nstatic void\nsample_2d_linear_mipmap_linear_repeat (GLcontext * ctx,\n\t\t\t\t       const struct gl_texture_object *tObj,\n\t\t\t\t       GLuint n, const GLfloat texcoord[][4],\n\t\t\t\t       const GLfloat lambda[],\n\t\t\t\t       GLchan rgba[][4])\n{\n  GLuint i;\n  for (i = 0; i < n; i++)\n    {\n      GLint level = linear_mipmap_level (tObj, lambda[i]);\n      if (level >= tObj->_MaxLevel)\n\t{\n\t  GLchan t0[4], t1[4];\n\t  const GLfloat f = ((lambda[i]) - ifloor (lambda[i]));\n\t  sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level],\n\t\t\t\t   texcoord[i], t0);\n\t  sample_2d_linear_repeat (ctx, tObj, tObj->Image[0][level + 1],\n\t\t\t\t   texcoord[i], t1);\n\t  lerp_rgba (rgba[i], f, t0, t1);\n\t}\n    }\n}\nstatic void\nsample_lambda_2d (GLcontext * ctx, const struct gl_texture_object *tObj,\n\t\t  GLuint n, const GLfloat texcoords[][4],\n\t\t  const GLfloat lambda[], GLchan rgba[][4])\n{\n  const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];\n  GLuint minStart, minEnd;\n  GLuint magStart, magEnd;\n  const GLboolean repeatNoBorderPOT = (tObj->WrapS == 0x2901)\n    && (tImg->_BaseFormat != 0x1900) && tImg->_IsPowerOfTwo;\n  compute_min_mag_ranges (tObj, n, lambda, &minStart, &minEnd, &magStart,\n\t\t\t  &magEnd);\n  if (minStart < minEnd)\n    {\n      const GLuint m = minEnd - minStart;\n      switch (tObj->MinFilter)\n\t{\n\tcase 0x2600:\n\t  if (repeatNoBorderPOT)\n\t    {\n\t\tcase MESA_FORMAT_RGB:\n\t\t  opt_sample_rgb_2d (ctx, tObj, m, texcoords + minStart,\n\t\t\t\t     ((void *) 0), rgba + minStart);\n\t\tcase MESA_FORMAT_RGBA:\n\t\t  opt_sample_rgba_2d (ctx, tObj, m, texcoords + minStart,\n\t\t\t\t      ((void *) 0), rgba + minStart);\n\t    }\n\t    {\n\t      sample_nearest_2d (ctx, tObj, m, texcoords + minStart,\n\t\t\t\t ((void *) 0), rgba + minStart);\n\t    }\n\t  break;\n\t  sample_2d_nearest_mipmap_linear (ctx, tObj, m, texcoords + minStart,\n\t\t\t\t\t   lambda + minStart,\n\t\t\t\t\t   rgba + minStart);\n\tcase 0x2703:\n\t  if (repeatNoBorderPOT)\n\t    sample_2d_linear_mipmap_linear_repeat (ctx, tObj, m,\n\t\t\t\t\t\t   texcoords + minStart,\n\t\t\t\t\t\t   lambda + minStart,\n\t\t\t\t\t\t   rgba + minStart);\n\t}\n      switch (tObj->MagFilter)\n\t{\n\t\tcase MESA_FORMAT_RGB:\n\t\t  opt_sample_rgb_2d (ctx, tObj, m, texcoords + magStart,\n\t\t\t\t     ((void *) 0), rgba + magStart);\n\t\t  opt_sample_rgba_2d (ctx, tObj, m, texcoords + magStart,\n\t\t\t\t      ((void *) 0), rgba + magStart);\n                  sample_nearest_2d (ctx, tObj, m, texcoords + magStart,\n                                     ((void *) 0), rgba + magStart);\n\t}\n    }\n}\ntexture_sample_func\n_swrast_choose_texture_sample_func (const struct gl_texture_object *t)\n{\n      switch (t->Target)\n\t{\n\tcase 0x0DE0:\n\t      return &sample_lambda_2d;\n\t}\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34093.c",
    "content": "struct X { int i; int j; };\n#define FOO struct X\n#define FOO10(x) FOO x ## 0; FOO x ## 1; FOO x ## 2; FOO x ## 3; FOO x ## 4; FOO x ## 5; FOO x ## 6; FOO x ## 7; FOO x ## 8; FOO x ## 9;\n#define FOO100(x) FOO10(x ## 0) FOO10(x ## 1) FOO10(x ## 2) FOO10(x ## 3) FOO10(x ## 4) FOO10(x ## 5) FOO10(x ## 6) FOO10(x ## 7) FOO10(x ## 8) FOO10(x ## 9)\n  FOO100(x0)\n  FOO100(x1)\n  FOO100(x2)\n  FOO100(x3)\n  FOO100(x4)\n  FOO100(x5)\n  FOO100(x6)\n  FOO100(x7)\n  FOO100(x8)\n  FOO100(x9)\n\n#define COO(n,f) case n: p = &f; break;\n#define COO10(n,f) COO(n ## 0, f ## 0) COO(n ## 1, f ## 1) COO(n ## 2, f ## 2) COO(n ## 3, f ## 3) COO(n ## 4, f ## 4) COO(n ## 5, f ## 5) COO(n ## 6, f ## 6) COO(n ## 7, f ## 7) COO(n ## 8, f ## 8) COO(n ## 9, f ## 9)\n#define COO100(n,f) COO10(n ## 0, f ## 0) COO10(n ## 1, f ## 1) COO10(n ## 2, f ## 2) COO10(n ## 3, f ## 3) COO10(n ## 4, f ## 4) COO10(n ## 5, f ## 5) COO10(n ## 6, f ## 6) COO10(n ## 7, f ## 7) COO10(n ## 8, f ## 8) COO10(n ## 9, f ## 9)\n\nint foo(int i)\n{\n  struct X *p = 0;\n  x000.i = 0;\n  x599.j = 0;\n  switch (i)\n    {\n  COO100(1, x0)\n  COO100(2, x1)\n  COO100(3, x2)\n  COO100(4, x3)\n  COO100(5, x4)\n  COO100(6, x5)\n  COO100(7, x6)\n  COO100(8, x7)\n  COO100(9, x8)\n  COO100(10, x9)\n    }\n  return p->j;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34113.c",
    "content": "struct sockaddr_in { int sin_addr; };\nstatic void ConvertAddr (struct sockaddr_in *saddr, void **addr)\n{\n  *addr = (void *) &saddr->sin_addr;\n}\nunsigned char EnableLocalHost (struct sockaddr_in *ifa_addr)\n{\n  unsigned char * addr;\n  ConvertAddr(ifa_addr, (void **)&addr);\n  return addr[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34127.c",
    "content": "static void \nwhichtable(char **pfmt)\n{\n  --*pfmt;\n}\nvoid prepare_s(const char *fmt)\n{\n  whichtable((char **)&fmt);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34138.c",
    "content": "extern void free (void *__ptr);\nstruct shparam\n{\n  char **p;\n  int foo;\n};\nstatic struct shparam shellparam;\ninline void freeparam (volatile struct shparam *param, char **ap)\n{\n  free ((void *) (*ap));\n  free ((void *) (param->p));\n}\nvoid dotcmd (char **p)\n{\n  freeparam (&shellparam, p);\n}\nvoid evaltree (void)\n{\n  void (*evalfn) (char **);\n  evalfn = dotcmd;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34334.c",
    "content": "/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"*\" } { \"-O0\" } } */\n__extension__ typedef __SIZE_TYPE__ size_t;\n__extension__ typedef long long int __quad_t;\n__extension__ typedef unsigned int __mode_t;\n__extension__ typedef __quad_t __off64_t;\ntypedef __mode_t mode_t;\ntypedef __off64_t off_t;\nstruct timeval   {};\ntypedef struct   {} fd_set;\ntypedef union {} __pthread_slist_t;\ntypedef union {\n    struct __pthread_mutex_s   { __extension__ union { };   } __data;\n};\nextern int stat64 (__const char *__restrict __file,      struct stat64 *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int fstatat64 (int __fd, __const char *__restrict __file,         struct stat64 *__restrict __buf, int __flag)      __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (2, 3)));\nenum __socket_type { SOCK_STREAM = 1, };\nenum { SI_ASYNCNL = -60, };\nenum { CLD_EXITED = 1, };\ntypedef struct sigaltstack   { } stack_t;\nenum __rlimit_resource { __RLIMIT_SIGPENDING = 11, };\nstruct rlimit   { };\nenum __priority_which { PRIO_PROCESS = 0, };\ntypedef union   { } __WAIT_STATUS __attribute__ ((__transparent_union__));\nunion wait   {\n    struct       {       } __wait_stopped;\n};\ntypedef enum {  P_ALL, } idtype_t;\nstruct utsname   { };\nenum   { IPPROTO_IP = 0,   };\nenum   { IPPORT_ECHO = 7,   };\nstruct in_addr   { };\nstruct in6_addr   {\n    union       {       } in6_u;\n};\ntypedef long int wchar_t;\ntypedef unsigned char guint8;\ntypedef signed int gint32;\ntypedef unsigned int guint32;\ntypedef signed int gssize;\ntypedef unsigned int gsize;\nstruct _GStaticMutex {\n    union {   } static_mutex;\n};\nunion _GSystemThread { };\ntypedef int GPid;\ntypedef char gchar;\ntypedef int gint;\ntypedef gint gboolean;\ntypedef unsigned short gushort;\ntypedef unsigned long gulong;\ntypedef unsigned int guint;\ntypedef void* gpointer;\ntypedef const void *gconstpointer;\ntypedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);\ntypedef void (*GFunc) (gpointer data,   gpointer user_data);\ntypedef void (*GHFunc) (gpointer key,   gpointer user_data);\nstruct _GTimeVal { };\ntypedef struct _GByteArray GByteArray;\nguint8* g_byte_array_free (GByteArray *array,      guint index_);\ntypedef guint32 GQuark;\ntypedef struct _GError GError;\nGError* g_error_new (GQuark domain,   const gchar *message);\ngboolean g_error_matches (const GError *error,   gint code);\ntypedef __builtin_va_list __gnuc_va_list;\ntypedef __gnuc_va_list va_list;\ntypedef enum { G_USER_DIRECTORY_DESKTOP, } GUserDirectory;\ntypedef enum { G_THREAD_PRIORITY_URGENT } GThreadPriority;\nstruct _GThread { };\ntypedef struct _GCond GCond;\nstruct _GThreadFunctions {\n    void (*cond_wait) (GCond *cond,  GError **error);\n    gboolean (*thread_equal) (gpointer thread1,        gpointer thread2);\n};\ntypedef struct _GAsyncQueue GAsyncQueue;\nvoid g_async_queue_sort (GAsyncQueue *queue,           guint *save);\nstruct tm { };\ntypedef struct __locale_struct { } *__locale_t;\nextern int getaddrinfo (__const char *__restrict __name, struct addrinfo **__restrict __pai);\ntypedef struct _IO_FILE FILE;\n__strsep_1c (char **__s, char __reject) { }\n__strsep_2c (char **__s, char __reject1, char __reject2) { }\ntypedef struct stack_st  { } STACK;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct EDIPartyName_st {\n    union { } d;\n} GENERAL_NAME;\ntypedef struct DIST_POINT_NAME_st {\n    union { } name;\n} DIST_POINT_NAME;\ntypedef struct SXNET_st { } NOTICEREF;\ntypedef struct GENERAL_SUBTREE_st { } X509_PURPOSE;\nint X509V3_add_value(const char *name, const char *value, STACK **extlist);\nint X509_PURPOSE_add(int id, int trust, int flags, char *name, char *sname, void *arg);\nextern char *dcgettext (__const char *__domainname, __const char *__msgid, int __category) __attribute__ ((__nothrow__)) __attribute__ ((__format_arg__ (2)));\nenum { __LC_CTYPE = 0, };\nstruct lconv { };\ntypedef enum gftp_logging_level_tag { gftp_logging_send, } gftp_logging_level;\nstruct gftp_file_tag {\n    char *file,        *destfile;\n    unsigned int selected : 1,\n                is_fd : 1;\n    gint32 ipv4_network_address, ipv4_netmask;\n} gftp_proxy_hosts;\ntypedef enum { gftp_option_type_text = 0, } gftp_option_type_enum;\ntypedef struct gftp_config_list_vars_tag { } gftp_config_list_vars;\ntypedef struct gftp_config_vars_tag { } gftp_config_vars;\ntypedef struct gftp_option_type_tag {\n    int (*read_function) (char *str, gftp_config_vars * cv, int line);\n    int (*write_function) (gftp_config_vars * cv, char *buf, size_t buflen, int to_config_file);\n} gftp_option_type_var;\ntypedef struct gftp_request_tag gftp_request;\ntypedef void (*gftp_logging_func) ( gftp_logging_level level, const char *string, ... );\ntypedef struct gftp_transfer_tag {\n    gftp_request * fromreq, * toreq;\n    unsigned int cancel : 1,\n                skip_file : 1;\n    long numfiles,  resumed_bytes;\n} gftp_transfer;\ntypedef struct gftp_log_tag {\n    unsigned int shown : 1,\n\tuse_threads : 1;\n} supported_gftp_protocols;\nvoid\ngftp_config_parse_args (char *str, int numargs, int lineno, char **first, ...)\n{\n    char *curpos, *endpos, *pos, **dest, tempchar;\n    va_list argp;\n    dest = first;\n    while (numargs > 0)\n    {\n        if (numargs > 1)\n\t{  \n\t    dest = __builtin_va_arg(argp,char **); \n\t    *dest = ((void *)0);\n\t} \n\tnumargs--; \n\t**dest = '\\0'; \n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34448.c",
    "content": "typedef struct chunk_t chunk_t;\nstruct chunk_t\n{\n  unsigned char *ptr;\n  long unsigned int len;\n};\nextern chunk_t asn1_wrap (chunk_t c, ...);\ntypedef struct linked_list_t linked_list_t;\nchunk_t ietfAttr_list_encode (linked_list_t * list);\nextern linked_list_t *groups;\nstatic unsigned char ASN1_group_oid_str[] = {\n    0x06\n};\nstatic const chunk_t ASN1_group_oid = {\n  ASN1_group_oid_str, sizeof (ASN1_group_oid_str)\n};\nstatic chunk_t\nbuild_attribute_type (const chunk_t type, chunk_t content)\n{\n  return type;\n}\nstatic chunk_t\nbuild_attributes (void)\n{\n  return asn1_wrap (build_attribute_type (ASN1_group_oid,\n\t\t\t\t\t  ietfAttr_list_encode (groups)));\n}\nvoid build_attr_cert (void)\n{\n  asn1_wrap (build_attributes ());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34458.c",
    "content": "/* Testcase by Martin Michlmayr <tbm@cyrius.com> */\n\ntypedef struct\n{\n  int data[1024];\n}\nLint;\nLint lint_operate (Lint a, long long ammount)\n{\n  int index;\n  Lint ret;\n  for (index = 0; index < 24; index++)\n    ret.data[index] =\n      a.data[index + ammount / 32 + 1] << a.data[index + ammount / 32];\n  return ret;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34648.c",
    "content": "/* PR tree-optimization/34648 */\n\n/* { dg-options \"-fexceptions\" } */\n\nextern const unsigned short int **bar (void) __attribute__ ((const));\nconst char *a;\nint b;\nchar c;\n\nchar\nfoo (int *x)\n{\n  char r;\n\n  c = '\\0';\n  if (!b)\n    {\n      while (((*bar ())[a[*x]] & 0x2000) != 0)\n        (*x)++;\n      if (a[++(*x)] == '-')\n        {\n          (*x)++;\n          if (a[*x] && !((*bar ())[a[*x]] & 0x2000))\n            return '?';\n        }\n      if (!a[*x] || ((*bar ())[a[*x]] & 0x2000))\n        {\n          while (((*bar ())[a[*x]] & 0x2000))\n            ++(*x);\n          return '\\0';\n        }\n    }\n\n  r = a[*x];\n  b = a[*x] && !((*bar ())[a[*x]] & 0x2000);\n  return r;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34688.c",
    "content": "typedef __SIZE_TYPE__ size_t;\n         typedef struct {\n        }\n         HashTable;\n         typedef struct _zval_struct zval;\n         typedef struct _zend_guard {\n         HashTable *ht;\n        }\n         zvalue_value;\n         struct _zval_struct {\n         zvalue_value value;\n        }\n         php_output_globals;\n         typedef struct _php_stream php_stream;\n         typedef struct _php_stream_filter php_stream_filter;\n         typedef struct _php_stream_bucket_brigade php_stream_bucket_brigade;\n         typedef enum {\n         PSFS_ERR_FATAL,  PSFS_FEED_ME,  PSFS_PASS_ON, }\n         php_stream_filter_status_t;\n         typedef struct _php_stream_filter_ops {\n         php_stream_filter_status_t (*filter)(    php_stream *stream,    php_stream_filter *thisfilter,    php_stream_bucket_brigade *buckets_in,    php_stream_bucket_brigade *buckets_out,    size_t *bytes_consumed,    int flags    );\n         void (*dtor)(php_stream_filter *thisfilter );\n         const char *label;\n        }\n         php_stream_filter_ops;\n         struct _php_stream_filter {\n        };\n         typedef struct _php_stream_filter_factory {\n         php_stream_filter *(*create_filter)(const char *filtername, zval *filterparams, int persistent );\n        }\n         php_stream_filter_factory;\n         typedef enum _php_conv_err_t {\n         PHP_CONV_ERR_SUCCESS = 0,  PHP_CONV_ERR_UNKNOWN,  PHP_CONV_ERR_TOO_BIG,  PHP_CONV_ERR_INVALID_SEQ,  PHP_CONV_ERR_UNEXPECTED_EOS,  PHP_CONV_ERR_EXISTS,  PHP_CONV_ERR_MORE,  PHP_CONV_ERR_ALLOC,  PHP_CONV_ERR_NOT_FOUND }\n         php_conv_err_t;\n         typedef struct _php_conv php_conv;\n         typedef php_conv_err_t (*php_conv_convert_func)(php_conv *, const char **, size_t *, char **, size_t *);\n         struct _php_conv {\n         php_conv_convert_func convert_op;\n        }\n         php_conv_base64_decode;\n         typedef struct _php_conv_qprint_decode {\n         php_conv _super;\n         const char *lbchars;\n        }\n         php_conv_qprint_decode;\n         static php_conv_err_t php_conv_qprint_decode_convert(php_conv_qprint_decode *inst, const char **in_pp, size_t *in_left_p, char **out_pp, size_t *out_left_p) {\n         size_t icnt, ocnt;\n         unsigned char *ps, *pd;\n         unsigned int scan_stat;\n         unsigned int lb_ptr, lb_cnt;\n         for (;\n       ;\n       ) {\n         switch (scan_stat) {\n         case 0: {\n         if (*ps == '=') {\n         scan_stat = 1;\n        }\n     else {\n         if (ocnt < 1) {\n         goto out;\n        }\n         *(pd++) = *ps;\n         ocnt--;\n        }\n        }\n      break;\n         case 1: {\n         if (*ps == ' ' || *ps == '\\t') {\n        }\n     else if (!inst->lbchars && lb_cnt == 0 && *ps == '\\r') {\n         lb_cnt++;\n         scan_stat = 5;\n         break;\n        }\n     else if (!inst->lbchars && lb_cnt == 0 && *ps == '\\n') {\n         scan_stat = 0;\n         break;\n        }\n        }\n         case 2: {\n         if (icnt <= 0) {\n         goto out;\n        }\n        }\n         case 3: {\n        }\n         case 4: {\n         ps++, icnt--;\n        }\n        }\n        }\n        out:  *in_pp = (const char *)ps;\n        }\n         static php_conv_err_t php_conv_qprint_decode_ctor(php_conv_qprint_decode *inst, const char *lbchars, size_t lbchars_len, int lbchars_dup, int persistent) {\n         inst->_super.convert_op = (php_conv_convert_func) php_conv_qprint_decode_convert;\n        }\n         typedef struct _php_convert_filter {\n         php_conv *cd;\n        }\n         php_convert_filter;\n         static php_conv *php_conv_open(int conv_mode, const HashTable *options, int persistent) {\n         php_conv *retval = ((void *)0);\n         switch (conv_mode) {\n         case 4: {\n         char *lbchars = ((void *)0);\n         size_t lbchars_len;\n         if (lbchars != ((void *)0)) {\n         if (php_conv_qprint_decode_ctor((php_conv_qprint_decode *)retval, lbchars, lbchars_len, 1, persistent)) {\n        }\n        }\n        }\n        }\n        }\n         static int php_convert_filter_ctor(php_convert_filter *inst,  int conv_mode, HashTable *conv_opts,  const char *filtername, int persistent) {\n         if ((inst->cd = php_conv_open(conv_mode, conv_opts, persistent)) == ((void *)0)) {\n        }\n        }\n         static php_stream_filter_status_t strfilter_convert_filter(  php_stream *stream,  php_stream_filter *thisfilter,  php_stream_bucket_brigade *buckets_in,  php_stream_bucket_brigade *buckets_out,  size_t *bytes_consumed,  int flags  ) {\n        }\n         static void strfilter_convert_dtor(php_stream_filter *thisfilter ) {\n        }\n         static php_stream_filter_ops strfilter_convert_ops = {\n         strfilter_convert_filter,  strfilter_convert_dtor,  \"convert.*\" };\n         static php_stream_filter *strfilter_convert_create(const char *filtername, zval *filterparams, int persistent ) {\n         php_convert_filter *inst;\n         int conv_mode = 0;\n         if (php_convert_filter_ctor(inst, conv_mode,   (filterparams != ((void *)0) ? (*filterparams).value.ht : ((void *)0)),   filtername, persistent) != 0) {\n        }\n        }\n         static php_stream_filter_factory strfilter_convert_factory = {\n         strfilter_convert_create };\n         static const struct {\n         php_stream_filter_ops *ops;\n         php_stream_filter_factory *factory;\n        }\n         standard_filters[] = {\n         {\n       &strfilter_convert_ops, &strfilter_convert_factory }\n        };\n         int zm_startup_standard_filters(int type, int module_number ) {\n         int i;\n         for (i = 0;\n        standard_filters[i].ops;\n        i++) {\n        }\n        }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34808.c",
    "content": "/* PR 34808 */\n/* { dg-do compile }\n/* { dg-options \"-fno-tree-dominator-opts\" } */\n\nextern int flags;\n\nstruct r { int code; int val;};\n\nvoid bar (void);\nvoid baz (void);\n\nint\nfoo (struct r *home)\n{\n  int n = 0;\n  int regno = -1;\n\n  if (home->code == 0)\n    regno = home->val;\n\n  if (home->code == 1)\n      bar ();\n  else if (regno >= 0)\n    n = (regno == 16\n\t ? 16\n\t : (regno - (unsigned long long) (flags != 0 ? 63 : 15)\n\t    ? regno - 128\n\t    : -1));\n\n  baz ();\n  return n;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34856.c",
    "content": "/* { dg-options \"-msse\" { target { i?86-*-* x86_64-*-* } } } */\n#undef __vector\n#define __vector __attribute__((vector_size(16) ))\ntypedef __vector signed char qword;\ntypedef __vector unsigned int VU32;\nextern short g[192 +16];\nvoid f(qword);\nvoid f1 (unsigned ctr)\n{\n  VU32 pin;\n  pin = (VU32){(__SIZE_TYPE__)&g[16]};\n  do {\n   f((qword)pin);\n   ctr--;\n  }\nwhile(ctr);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34885.c",
    "content": "typedef union {\n  __const struct sockaddr *__restrict __sockaddr__;\n} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));\nextern int _pure_socketcall (const struct sockaddr *);\nextern int sendto (__CONST_SOCKADDR_ARG __addr);\nint send(void)\n{\n  return sendto((void *)0);\n}\nint sendto(const struct sockaddr *to)\n{\n   return _pure_socketcall(to);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34966.c",
    "content": "extern double sin (double), cos (double);\n\n__inline double\natan (double __x)\n{\n  register double __result;\n#if defined(__i386__) || defined(__x86_64__)\n  __asm __volatile__ (\"\" : \"=t\" (__result) : \"0\" (__x));\n#else\n  __result = __x;\n#endif\n  return __result;\n}\n\ndouble\nf(double x)\n{\n  double t = atan (x);\n  return cos (t) + sin (t);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr34993.c",
    "content": "/* PR c/34993 */\n\n/* { dg-do compile } */\n\ntypedef int x[] __attribute((may_alias));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35006.c",
    "content": "/* { dg-require-effective-target alloca } */\ntypedef unsigned long grub_uint64_t;\ntypedef grub_uint64_t grub_size_t;\ngrub_cmdline_get (unsigned max_len, int echo_char)\n{\n  unsigned xpos, ypos, ystart;\n  grub_size_t lpos, llen;\n  char buf[max_len];\n  void cl_print (int pos, int c)\n  {\n      char *p;\n      for (p = buf + pos; *p; p++)\n      {\n        if (xpos++ > 78)\n          grub_putchar ('\\n');\n        grub_putchar (*p);\n      }\n }\n void cl_delete (unsigned len)\n {\n   cl_set_pos ();\n   cl_print (lpos, ' ');\n   grub_memmove ();\n   cl_print (lpos, echo_char);\n   cl_set_pos ();\n }\n cl_delete (llen);\n grub_size_t n = lpos;\n cl_delete (n);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35043.c",
    "content": "typedef __SIZE_TYPE__ size_t;\ntypedef struct   {\n      long double dat[2];\n} gsl_complex_long_double;\ntypedef struct {\n    size_t size;\n    size_t stride;\n    long double *data;\n} gsl_vector_complex_long_double;\nvoid gsl_vector_complex_long_double_set_zero (gsl_vector_complex_long_double * v) \n{\n    long double * const data = v->data;\n    const size_t n = v->size;\n    const size_t stride = v->stride;\n    const gsl_complex_long_double zero = { { 0.0L,0.0L} } ;\n    size_t i;\n    for (i = 0; i < n; i++)     \n        *(gsl_complex_long_double *) (data + 2 * i * stride) = zero;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35171.c",
    "content": "int f(int a, int b, short c, int d, short e)\r\n{\r\n  int i;\r\n  for (i = 1; i <= 2 ; i++) {\r\n    c -= 4;\r\n    a = c;\r\n    d = d + (b?b:e);\r\n  }\r\n  return a + d;\r\n}\r\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35318.c",
    "content": "/* { dg-skip-if \"\" { pdp11-*-* } { \"*\" } { \"\" } } */\n/* PR target/35318 */\n\nvoid\nfoo ()\n{\n  double x = 4, y;\n  __asm__ volatile (\"\" : \"=r,r\" (x), \"=r,r\" (y) : \"%0,0\" (x), \"m,r\" (8));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35431.c",
    "content": "void bar();\n\nvoid foo(int i)\n{\n  __complex__ int k = 0;\n\n  if (i)\n    k = 1;\n\n  for (i = 0; i < 1; ++i)\n    ;\n\n  if (k)\n    bar();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35432.c",
    "content": "/* PR middle-end/35432 */\n\nstruct A\n{\n  char c[0];\n};\n\nvoid foo(struct A a)\n{\n  (a = a).c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35468.c",
    "content": "/* PR tree-optimization/35468 */\n/* { dg-do compile } */\n\nvoid\nfoo (void)\n{\n  *(char *) \"c\" = 'x';\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35492.c",
    "content": "void prepare_to_wait (void *, void *, int);\nvoid finish_wait (void *, void *);\nextern signed long schedule_timeout (signed long);\nstruct sock\n{\n  unsigned char skc_state;\n  void *sk_sleep;\n  int sk_err;\n};\n\nvoid\nsk_stream_wait_connect (struct sock *sk, long *timeo_p)\n{\n  int done;\n  int wait;\n  do\n    {\n      if ((1 << sk->skc_state) & ~12)\n        return;\n      prepare_to_wait (sk->sk_sleep, &wait, 1);\n      *(timeo_p) = schedule_timeout (0);\n      done = !sk->sk_err;\n      finish_wait (sk->sk_sleep, &wait);\n    }\n  while (!done);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35595.c",
    "content": "/* { dg-require-effective-target int32plus } */\ntypedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\ntypedef union\n{\n  float value;\n  __uint32_t word;\n}\nieee_float_shape_type;\nstatic const float two23 = 8.3886080000e+06;\nstatic const float pi = 3.1415927410e+00;\nstatic const float zero = 0.0000000000e+00;\nstatic float\nsin_pif (float x)\n{\n  float y = 0;\n  float z = 0;\n  __int32_t n = 0;\n  __int32_t ix = 0;\n  do\n    {\n      ieee_float_shape_type gf_u = { 0 };\n      (ix) = gf_u.word;\n    }\n  while (0);\n  if (z == y)\n    {\n      if (ix < 0x4b800000)\n\t{\n\t  if (ix < 0x4b000000)\n\t    z = y + two23;\n\t  do\n\t    {\n\t      ieee_float_shape_type gf_u;\n\t      gf_u.value = (z);\n\t      (n) = gf_u.word;\n\t    }\n\t  while (0);\n\t}\n    }\n  if (n == 0)\n    y = __kernel_sinf (pi * y, zero, 0);\n}\n\nfloat\n__ieee754_lgammaf_r (float x, int *signgamp)\n{\n  float t = 0;\n  __int32_t hx = 0;\n  do\n    {\n      ieee_float_shape_type gf_u = { 0 };\n      (hx) = gf_u.word;\n    }\n  while (0);\n  if (hx < 0)\n    t = sin_pif (x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35607.c",
    "content": "extern void (*__fini_array_start []) (void);\nextern void (*__fini_array_end []) (void);\nvoid\n__libc_csu_fini (void)\n{\n  __SIZE_TYPE__ i = __fini_array_end - __fini_array_start;\n  while (i-- > 0)\n    (*__fini_array_start [i]) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35760.c",
    "content": "/* PR target/35760 */\n\nvoid\nfoo (void)\n{\n  __complex__ float i = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr35869.c",
    "content": "struct texture_stage_op\n{\n    unsigned int carg1, carg2, carg0;\n    unsigned int aarg1, aarg2, aarg0;\n    unsigned int dst;\n};\n\nstatic const char *debug_register(unsigned int reg) {\n    switch(reg) {\n        case 0x8921: return \"GL_REG_0_ATI\";\n        case 0x8923: return \"GL_REG_2_ATI\";\n        case 0x0: return \"GL_ZERO\";\n        case 0x1: return \"GL_ONE\";\n        default: return \"Unknown register\\n\";\n    }\n}\n\nstatic unsigned int find_tmpreg(struct texture_stage_op op[8]) {\n    int i;\n    int tex_used[8];\n\n    for(i = 0; i < 8; i++) {\n        if(op[i].carg1 == 0x00000002 ) {\n            tex_used[i] = 1;\n        }\n    }\n\n    for(i = 1; i < 6; i++) {\n        if(!tex_used[i]) {\n                return 0x8921 + i;\n        }\n    }\n    return 0;\n}\n\nextern f(const char*);\n\nvoid g() {\n    struct texture_stage_op op[8];\n    unsigned int tmparg = find_tmpreg(op);\n    unsigned int dstreg;\n\n    if(tmparg == 0x0) return;\n    dstreg = tmparg;\n    f(debug_register(dstreg));\n    return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36125.c",
    "content": "/* PR middle-end/36125 */\n\nextern void bar (long double *);\n\nint\nfoo (long double x)\n{\n  bar (&x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36141.c",
    "content": "extern void ffi_closure_unix (void);\nffi_prep_closure_loc (void)\n{\n  struct ia64_fd\n  {\n    unsigned long long code_pointer;\n    unsigned long long gp;\n  };\n  struct ffi_ia64_trampoline_struct\n  {\n    unsigned long long code_pointer;\n  };\n  struct ffi_ia64_trampoline_struct *tramp;\n  struct ia64_fd *fd;\n  fd = (struct ia64_fd *)(void *)ffi_closure_unix;\n  tramp->code_pointer = fd->code_pointer;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36154.c",
    "content": "struct eth_test_pkt {\n  unsigned short len;\n  unsigned short ctr;\n  unsigned char packet[];\n} __attribute__ ((packed));\nstruct eth_test_pkt pkt_unaligned = { .packet = { 0xFC } };\nint cmd_unaligned(const void *p)\n{\n  return memcmp(p, pkt_unaligned.packet, 1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36172.c",
    "content": "int f(float * );\n__SIZE_TYPE__ FcCharSetFreeze (int *fcs, int b)\n{\n  int i;\n  int a = 0;\n  for (i = 0; i < *fcs; i++)\n  {\n    float *leaf = (float *)fcs;\n    int hash = f (leaf);\n    if (hash)\n      a = b;\n    if (!a)\n      return;\n  }\n  return (__SIZE_TYPE__) fcs;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36238.c",
    "content": "typedef signed char int8_t;\ntypedef int int32_t;\ntypedef unsigned short int uint16_t;\ntypedef unsigned int uint32_t;\nint32_t g_19 = 0x67F5AEE0L;\nuint16_t g_169 = 0x89E3L;\nconst volatile uint32_t g_258 = 0x63AFEBCAL;\nint32_t func_11;\nint32_t func_29;\nint32_t\nfunc_5 (int32_t p_6, int32_t p_8, uint16_t p_10)\n{\n  if (lshift_s_s (func_11, p_8))\n    {\n      int8_t l_18 = 0x6FL;\n      if (l_18)\n        for (p_6 = -14;; g_19 += 6)\n          {\n            int32_t l_283 = -1L;\n            if (((0x45L / 1L) > 0x07414511L * 1L / 1L > func_29) / 1L)\n              for (p_8 = 6;; p_8 -= 5)\n                l_283 = 0xC90541F7L;\n          }\n    }\n  else\n    g_169 = g_258;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36245.c",
    "content": "extern char buf1[10];\nextern char buf2[10];\nextern void b(int i, int j, int w);\n\nvoid a() {\n    int i,j;\n    char *p;\n    int w;\n\n    p = buf1;\n    for(j = 0;j < 10; j++) {\n        for(i = 0;i < 10; i++) {\n            w = *p;\n            if(w != 1) {\n                w = buf2[p - buf1];\n                b(i*2+1, j, w);\n            }\n            p++;\n        }\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36666.c",
    "content": "struct Foo {\n    int *p;\n    struct X {\n\tint a,b,c,d,e,*f;\n    } x;\n} *init, *init2;\n\nstruct X __attribute__((const)) foo(struct X);\nstruct Foo __attribute__((const)) foo2(struct Foo);\n\nvoid bar1 (void)\n{\n  init->x = foo (init2->x);\n}\nvoid bar2 (void)\n{\n  init->x = foo (init->x);\n}\nvoid bar3 (void)\n{\n  *init = foo2 (*init2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36817.c",
    "content": "void xxx()\n{\n  unsigned i;\n  unsigned *p=0;\n  for(i=0; i<4; ++i)\n    *p++=0;\n  for(i=0; i<4; ++i)\n    *p++=0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr36988.c",
    "content": "typedef struct {\n    unsigned char mbxCommand;\n} MAILBOX_t;\nvoid lpfc_sli_brdrestart(void)\n{\n  volatile unsigned int word0;\n  MAILBOX_t *mb;\n  mb = (MAILBOX_t *) &word0;\n  mb->mbxCommand = 0x1A;\n  __writel((*(unsigned int *) mb));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37026.c",
    "content": "struct a {\n    long a1;\n    long a2;\n};\nstruct b {\n    struct a b1;\n    struct a b2;\n};\nvoid bar (struct b *c)\n{\n  c->b1 = c->b2 = ((struct a) { foo(), 0 });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37056.c",
    "content": "/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-O2\" \"-Os\" } { \"\" } } */\nextern void abort (void);\n\nstatic union {\n    char buf[12 * sizeof (long long)];\n} u;\n\nint main ()\n{\n  int off, len, i;\n  char *p, *q;\n\n  for (off = 0; off < (sizeof (long long)); off++)\n    for (len = 1; len < (10 * sizeof (long long)); len++)\n      {\n\tfor (i = 0; i < (12 * sizeof (long long)); i++)\n\t  u.buf[i] = 'a';\n\tp = (__extension__ (__builtin_constant_p ('\\0') && ('\\0') == '\\0'\n\t\t\t    ? ({void *__s = (u.buf + off); __s;})\n\t\t\t    : __builtin_memset (u.buf + off, '\\0', len)));\n\tif (p != u.buf + off)\n\t  abort ();\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n      }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37078.c",
    "content": "int foo (int b)\n{\n  if (b == (int)0x80000000)\n    return __builtin_abs (b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37207.c",
    "content": "void\nfunc_18 ( int t )\n{\n  unsigned l_889;\n  int l_895 = 1;\n  for (0; 1; ++l_889)\n    {\n      int t1 = 0;\n      if (func_81 (1))\n        {\n          int rhs = l_895;\n          if (rhs == 0)\n            rhs = 1;\n          if (1 & (t % rhs))\n            t1 = 1;\n        }\n      func_98 (t1);\n      l_895 = 0;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37258.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\ntypedef signed char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\n__extension__ typedef long long int int64_t;\ntypedef unsigned short int uint16_t;\ntypedef unsigned int uint32_t;\nstatic inline unsigned int\nlshift_u_s (unsigned int left, int right)\n{\n  if ((right) || (right >= sizeof (unsigned int) * 8)\n      || (left > (4294967295U >> right)))\n    return left;\n}\nstatic inline unsigned long int\ndiv_rhs (long int rhs)\n{\n  if (rhs == 0)\n    return 1;\n  return rhs;\n}\n\nuint32_t g_230;\nint8_t g_294;\nuint16_t g_316;\nuint32_t g_334;\nint32_t g_375;\nint64_t g_380;\nint32_t func_99 (int16_t p_100, int32_t p_101, int32_t p_102, int32_t p_103,\n                 int64_t p_105, int32_t p_106, int32_t p_107, int16_t p_108,\n                 int16_t p_109);\nint32_t\nfunc_77 (int64_t p_79)\n{\n  int16_t l_397;\n  if (mod_rhs (p_79))\n    p_79 = 1;\n  else\n    for (p_79 = 0; 0; p_79 += 1)\n      {\n      }\n  if (lshift_s_s (1, func_112 (2L, (lshift_u_s (g_334, p_79)))))\n    {\n      int8_t l_384;\n      int64_t l_414;\n      if (lshift_u_s (g_375, 1))\n        {\n          func_23 (func_99 (1, 1, 1, 1, g_230, p_79, 1, g_334, 1), 1);\n          for (p_79 = 0; 0; ++p_79)\n            {\n            }\n        }\n      if (div_rhs (func_82 (1, 1, g_380, 1, l_397, 1, 1)))\n        func_99 ((func_82\n                  (1, g_334, g_294, func_112 (1, (p_79 & 1)), g_316, 1, 1)),\n                 1, (0xFBA25CA382A8CA74LL), l_384, l_414, 0L, 1, 1, 1);\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37285.c",
    "content": "_bfd_xcoff_canonicalize_dynamic_reloc (unsigned long long l_symndx)\n{\n  if (l_symndx < 3)\n    {\n      switch (l_symndx)\n      {\n        case 0:\n        case 1:\n         break;\n        case 2:\n         _bfd_abort (\"HI\");\n    }\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37305.c",
    "content": "typedef int int32_t;\ntypedef unsigned int uint32_t;\nstatic inline int\nsafe_add_s_s (int si1, int si2)\n{\n  if ((si1 > 0) && (si2 > 0) && (si1 > (si2)) || (si1 < 0) && (si2 < 0)\n      && (si1 < ((-__INT_MAX__ - 1) - si2)))\n    return si1;\n}\n\nuint32_t g_8;\nuint32_t\nfunc_24 (int32_t p_25)\n{\n  uint32_t l_30 = -1L;\n  if ((safe_mod_u_u (1, 1)) | (safe_add_s_s (g_8, l_30)))\n    return 1;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37327.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\ntypedef signed char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\ntypedef unsigned short int uint16_t;\ntypedef unsigned int uint32_t;\nstatic inline uint32_t\nsafe_add_int8_t_s_s (int8_t si1, int16_t si2)\n{\n  if ((si1) && (si2) && (si1 > (1 - si2)) || (si1) && (si2 < 0)\n      && (si1 < (-128 - si2)))\n    return si1;\n  return si1 + si2;\n}\n\nuint32_t g_2;\nuint32_t g_113;\nuint32_t g_145;\nint32_t\nfunc_17 (int32_t p_18, uint32_t p_19, uint32_t p_21)\n{\n  uint32_t l_23 = -1L;\n  return l_23;\n}\n\nuint32_t\nfunc_26 (uint16_t p_27)\n{\n  uint32_t l_424;\n  if (func_93 (func_59 (safe_add_int8_t_s_s (p_27, 1))),\n      func_124 (l_424, -7L, 1, g_145, 1, (safe_add_int8_t_s_s (1, 1)), 1), 1,\n      1, 1)\n    func_117 (1, 1,\n              (safe_add_uint64_t_u_u\n               (1, (safe_add_int8_t_s_s (1, 0xCDF4BE7A1B7E4629LL)))), 1);\n  uint32_t l_210;\n  if (func_17\n      ((safe_add_int8_t_s_s (g_2, (0x6C79A83AL | func_17 (1, 1, 1)))),\n       0x4C9FL, 1))\n    {\n      uint32_t l_212;\n      if (safe_mul_int32_t_s_s\n          ((1, 1, l_212, (1, (safe_add_int8_t_s_s (l_210, 1)), 1, 1)), 1))\n        if (func_59 (1, (safe_add_int8_t_s_s (g_113, 1))))\n          {\n          }\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37341.c",
    "content": "/* PR rtl-optimization/37341 */\n\nshort int a;\nint b;\n\nstatic inline int\nf1 (int x, int y)\n{\n  if (x < 0 || y < 0 || y >= sizeof (int) * 8 || x > (1 >> y))\n    return x;\n}\n\nstatic inline unsigned int\nf2 (int x, int y)\n{\n  if (y <= 0 && x && y < __INT_MAX__ / x)\n    return x;\n  return x * y;\n}\n\nint\nf3 (void)\n{\n  return (signed char) 0xb6;\n}\n\nunsigned int\nf4 (unsigned int x)\n{\n  while (1)\n    {\n      if ((f2 (f3 (), (f1 (a, b)))) < x)\n\treturn 1;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37380.c",
    "content": "typedef struct basic_block_def *basic_block;\ntypedef struct gimple_seq_node_d *gimple_seq_node;\ntypedef struct gimple_seq_d *gimple_seq;\ntypedef struct\n{\n  gimple_seq_node ptr;\n  gimple_seq seq;\n  basic_block bb;\n} gimple_stmt_iterator;\ntypedef void *gimple;\nextern void exit(int);\nstruct gimple_seq_node_d\n{\n  gimple stmt;\n  struct gimple_seq_node_d *next;\n};\nstruct gimple_seq_d\n{\n};\nstatic __inline__ gimple_stmt_iterator\ngsi_start (gimple_seq seq)\n{\n  gimple_stmt_iterator i;\n  i.seq = seq;\n  return i;\n}\nstatic __inline__ unsigned char\ngsi_end_p (gimple_stmt_iterator i)\n{\n  return i.ptr == ((void *)0);\n}\nstatic __inline__ void\ngsi_next (gimple_stmt_iterator *i)\n{\n  i->ptr = i->ptr->next;\n}\nstatic __inline__ gimple\ngsi_stmt (gimple_stmt_iterator i)\n{\n  return i.ptr->stmt;\n}\nvoid\nc_warn_unused_result (gimple_seq seq)\n{\n  gimple_stmt_iterator i;\n  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))\n    {\n      gimple g = gsi_stmt (i);\n      if (!g) exit(0);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37381.c",
    "content": "extern unsigned int __invalid_size_argument_for_IOC;\ntypedef unsigned int __u32;\nstruct video_window\n{\n  __u32 x, y;\n  __u32 width, height;\n};\ntypedef unsigned long XID;\ntypedef XID Window;\ntypedef struct _XExtData\n{\n  Window root;\n}\nScreen;\ntypedef struct\n{\n  int border_width;\n}\nXWindowAttributes;\ntypedef struct _XDisplay Display;\ntypedef struct\n{\n  int default_screen;\n  Screen *screens;\n}\n *_XPrivDisplay;\ntypedef struct\n{\n  int x, y;\n}\nXSizeHints;\ntypedef struct\n{\n  unsigned short hdisplay;\n  unsigned short vdisplay;\n}\nXF86VidModeModeInfo;\nDisplay *display;\nint tfd;\nint ccapt;\nint tml;\nint fswidth = 0;\nint fsheight = 0;\nWindow fmwin;\nXF86VidModeModeInfo **modelines, *fullscreenmode = ((void *) 0);\nstruct video_window vswin;\nDoFullScreen (void)\n{\n  int i;\n  int rx, ry;\n  Window junkwin;\n  XSizeHints fmsizehints;\n  XWindowAttributes fmwinattr;\n  if (ioctl\n      (tfd,\n       (((1U) << (((0 + 8) + 8) + 14)) | ((('v')) << (0 + 8)) | (((8)) << 0) |\n\t(((((sizeof (int) == sizeof (int[1])\n\t     && sizeof (int) <\n\t     (1 << 14)) ? sizeof (int) : __invalid_size_argument_for_IOC))) <<\n\t ((0 + 8) + 8))), &ccapt) < 0)\n    {\n      perror (\"ioctl VIDIOCCAPTURE\");\n    }\n  if (!XTranslateCoordinates\n      (display, fmwin,\n       ((&((_XPrivDisplay) display)->\n\t screens[(((_XPrivDisplay) display)->default_screen)])->root),\n       -fmwinattr.border_width, -fmwinattr.border_width, &rx, &ry, &junkwin))\n    {\n    }\n  vswin.width = fswidth;\n  vswin.height = fsheight;\n  vswin.x = fmsizehints.x + rx;\n  vswin.y = fmsizehints.y + ry;\n  if (ioctl\n      (tfd,\n       (((1U) << (((0 + 8) + 8) + 14)) | ((('v')) << (0 + 8)) | (((8)) << 0) |\n\t(((((sizeof (int) == sizeof (int[1])\n\t     && sizeof (int) <\n\t     (1 << 14)) ? sizeof (int) : __invalid_size_argument_for_IOC))) <<\n\t ((0 + 8) + 8))), &ccapt) < 0)\n    {\n      XF86VidModeGetAllModeLines (display, XDefaultScreen (display), &tml,\n\t\t\t\t  &modelines);\n\t{\n\t  if ((modelines[i]->hdisplay == fswidth)\n\t      && (modelines[i]->vdisplay == fsheight))\n\t    {\n\t      fullscreenmode = modelines[i];\n\t    }\n\t}\n\t{\n\t  XF86VidModeSetViewPort (display, XDefaultScreen (display), vswin.x,\n\t\t\t\t  vswin.y);\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37382.c",
    "content": "/* PR target/37382 */\n\nvoid baz (char *);\nint c;\n\nvoid\nbar (void)\n{\n  char a[2];\n  int *ip = &c;\n  char *p = a, *q = (char *) &ip;\n  const char *r = q + 2;\n  for (; q != r; p++, q++)\n    *p = *q;\n  baz (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37387.c",
    "content": "typedef long int Int;\nvoid FuncMakeConsequencesPres (long *objDefs1)\n{\n  long a = (long)objDefs1;\n  int c = a & 0x01;\n  int b = 0;\n  if (!  ( 13 <= ( c ? 0 : (((int) objDefs1 & 0x02) ? 0 : *objDefs1  ))\n           && b <= 0))\n    ErrorQuit ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37395.c",
    "content": "/* PR target/37395 */\n\nint\nf (int j)\n{\n  int i;\n  asm volatile (\"\" : \"=r\"(i));\n  if (i >= 0)\n    j = 0;\n  return j;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37418-1.c",
    "content": "typedef void ft(int);\nvoid f(int args)__attribute__((noreturn));\nvoid f2(ft *p __attribute__((noreturn)))\n{\n  p = f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37418-2.c",
    "content": "typedef void ft(int);\nvolatile ft f;\nvoid f2(ft *p __attribute__((noreturn)))\n{\n  p = f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37418-3.c",
    "content": "typedef void ft(int);\nvoid f(int args)__attribute__((const));\nvoid f2(ft *p __attribute__((const)))\n{\n  p = f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37418-4.c",
    "content": "typedef void ft(int);\nconst ft f;\nvoid f2(ft *p __attribute__((const)))\n{\n  p = f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37432.c",
    "content": "static void print_wkb_byte(unsigned char val) {\n    print_wkb_bytes((unsigned char *)&val, 1, 1);\n}\nvoid InsertMultiPoint(int b) {\n    char a = 1;\n    if (b) a = 0;\n    print_wkb_byte(a);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c",
    "content": "void regex_subst(void)\n{\n  const void *subst = \"\";\n  (*(void (*)(int))subst) (0);\n}\n\nvoid foobar (void)\n{\n  int x;\n  (*(void (*)(void))&x) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37433.c",
    "content": "int regex_subst(void)\n{\n  const void *subst = \"\";\n  return (*(int (*)(int))subst) (0);\n}\n\nint foobar (void)\n{\n  int x;\n  return (*(int (*)(void))&x) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37483.c",
    "content": "/* PR target/37483 */\n\nunsigned long long\nfoo (unsigned count, int i)\n{\n  unsigned long long value;\n  if (i == 0)\n    value = (value & 0xFFFFFFFF) >> count;\n  return value;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37617.c",
    "content": "typedef union\n{\n  char *string;\n  double dval;\n  float fval;\n} yystype;\nchar *f(void)\n{\n  yystype tok;\n  tok.dval = 0;\n  return (tok.string);\n}\nchar *f1(void)\n{\n  yystype tok;\n  tok.fval = 0;\n  return (tok.string);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37662.c",
    "content": "/* PR tree-optimization/37662 */\n\nextern int baz (void);\n\nstatic int\nfoo (void)\n{\n  return 1;\n}\n\nint\nbar (void)\n{\n  return foo () >= 1 ^ (baz () || 0) || 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37664.c",
    "content": "/* PR tree-optimization/37664 */\n\nint v;\n\nint\nfoo ()\n{\n  int a = 0x8899A862;\n  int b = 0x8E * a;\n  int c = (b % b);\n  if (v > (4294967295U >> c))\n    return v;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37669-2.c",
    "content": "/* PR middle-end/37669 */\n\n#define FMT10 \"%d%d%d%d%d%d%d%d%d%d\"\n#define FMT100 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10\n#define FMT1000 FMT100 FMT100 FMT100 FMT100 FMT100 \\\n\t\tFMT100 FMT100 FMT100 FMT100 FMT100\n#define ARG10 , i, i, i, i, i, i, i, i, i, i\n#define ARG100 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10\n#define ARG1000 ARG100 ARG100 ARG100 ARG100 ARG100 \\\n\t\tARG100 ARG100 ARG100 ARG100 ARG100\nvoid foo (char *s, int i, int j)\n{\n  __builtin___snprintf_chk (s, i, 1, j, FMT1000 ARG1000);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37669.c",
    "content": "/* This testcase used to fail because a miscompiled execute_fold_all_builtins. */\n/* { dg-options \"-fgnu89-inline\" } */\n\ntypedef __SIZE_TYPE__ size_t;\nextern __inline __attribute__ ((__always_inline__)) int __attribute__\n((__nothrow__)) snprintf (char *__restrict __s, size_t __n, __const char\n*__restrict __fmt, ...)  {\n  return __builtin___snprintf_chk (__s, __n, 2 - 1,       \n__builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());\n}\nint n1, n2, n3, n4, f5, f6;\nchar * BackgroundGetUniqueString(void)\n{\n  char s[256];\n  const char *chmap =\n\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_\";\n  snprintf(s, sizeof(s),\n\"%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\",\n           chmap[(n1 >> 0) & 0x3f], chmap[(n1 >> 6) & 0x3f],\n           chmap[(n1 >> 12) & 0x3f], chmap[(n1 >> 18) & 0x3f],\n           chmap[(n1 >> 24) & 0x3f], chmap[(n1 >> 28) & 0x3f],\n           chmap[(n2 >> 0) & 0x3f], chmap[(n2 >> 6) & 0x3f],\n           chmap[(n2 >> 12) & 0x3f], chmap[(n2 >> 18) & 0x3f],\n           chmap[(n2 >> 24) & 0x3f], chmap[(n2 >> 28) & 0x3f],\n           chmap[(n3 >> 0) & 0x3f], chmap[(n3 >> 6) & 0x3f],\n           chmap[(n3 >> 12) & 0x3f], chmap[(n3 >> 18) & 0x3f],\n           chmap[(n3 >> 24) & 0x3f], chmap[(n3 >> 28) & 0x3f],\n           chmap[(n4 >> 0) & 0x3f], chmap[(n4 >> 6) & 0x3f],\n           chmap[(n4 >> 12) & 0x3f], chmap[(n4 >> 18) & 0x3f],\n           chmap[(n4 >> 24) & 0x3f], chmap[(n4 >> 28) & 0x3f],\n           chmap[(f5 >> 12) & 0x3f], chmap[(f5 >> 18) & 0x3f],\n           chmap[(f5 >> 24) & 0x3f], chmap[(f5 >> 28) & 0x3f],\n           chmap[(f6 >> 0) & 0x3f], chmap[(f6 >> 6) & 0x3f]\n           );\n  return __builtin_strdup(s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37713.c",
    "content": "void add_opush(void)\n{\n    unsigned char formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xff };\n    void *dtds[sizeof(formats)];\n    unsigned int i;\n    unsigned char dtd = 0x08;\n    for (i = 0; i < sizeof(formats); i++)\n\tdtds[i] = &dtd;\n    sdp_seq_alloc(dtds);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37742-3.c",
    "content": "void matmul_i4 (int * __restrict dest_y,\n\t\tconst int * __restrict abase,\n\t\tconst int * __restrict bbase_y,\n\t\tint count, int xcount, int ycount, int aystride)\n{               \n  int x, y, n;\n  const int * __restrict abase_n;\n  int bbase_yn;\n  for (y = 0; y < ycount; y++)\n    for (n = 0; n < count; n++) {\n\tabase_n = abase + n*aystride;\n\tbbase_yn = bbase_y[n];\n\tfor (x = 0; x < xcount; x++)\n\t  dest_y[x] += abase_n[x] * bbase_yn; \n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37742.c",
    "content": "void foo(int* __restrict__ p, int* q, int* p1, int *q1)\n{\n  int i;\n\n  p = p1;\n  q = q1;\n\n  for (i = 0; i < 4; ++i)\n    *++q = *++p + 1;\n}\n\nvoid bar(int* p, int* __restrict__ q, int* p1, int *q1)\n{\n  int i;\n\n  p = p1;\n  q = q1;\n\n  for (i = 0; i < 4; ++i)\n    *++q = *++p + 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37878.c",
    "content": "/* PR target/37878 */\n\ndouble y, z;\nvoid foo (long x)\n{\n  y = *(double *) ((long *) (x - 1) + 1);\n  z = *(double *) ((long *) (x - 1) + 1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37913.c",
    "content": "/* PR middle-end/37913 */\n\nvoid foo (void) __attribute__ ((noreturn));\n\nstatic int __attribute__ ((noreturn))\nbar (void)\n{\n  foo ();\n}\n\nvoid\nbaz (void)\n{\n  int i = bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37955.c",
    "content": "typedef struct\n{\n  enum { NotConnected = 0 } conn_state;\n  unsigned int conn_hndl;\n} AEP_CONNECTION_ENTRY;\n\nstatic AEP_CONNECTION_ENTRY aep_app_conn_table[256];\n\nvoid aep_mod_exp (void)\n{\n  int count;\n\n  for (count = 0; count < 256; count++)\n    {\n      aep_app_conn_table[count].conn_state = NotConnected;\n      aep_app_conn_table[count].conn_hndl = 0;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37976.c",
    "content": "void percent_x(int ch, char *p, char* ok_chars)\n{\n  char *cp = ch == 'a' ? p : \"\";\n  for (;*(cp += __builtin_strspn (cp, ok_chars));)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr37991.c",
    "content": "typedef int Int32;\nvoid use_it(int);\nvoid FindAndReadSignature(int processedSize)\n{\n  int numPrevBytes = 1;\n  for (;;)\n    {\n      int numBytesInBuffer = numPrevBytes + processedSize;\n      Int32 numTests = numBytesInBuffer - 1;\n      use_it (numTests);\n      numPrevBytes = numBytesInBuffer - numTests;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38123.c",
    "content": "/* PR target/38123 */\n\n#include <stdarg.h>\n\nstruct S { int i; double d; };\n\nstruct S\ntest (char *x, va_list ap)\n{\n  struct S s;\n  s = va_arg (ap, struct S);\n  return s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38343-2.c",
    "content": "/* PR middle-end/38343 */\n\nstatic struct S\n{\n  char f[6];\n} s[] = { {\"01000\"} };\n\nchar *\nfoo (void)\n{\n  return __builtin_stpcpy (s[0].f, \"S0022\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38343.c",
    "content": "/* PR middle-end/38343 */\n\nstatic struct A\n{\n  char f[6];\n} a[] = { {\"01000\"} };\n\nvoid\nfoo (void)\n{\n  __builtin_stpcpy (a[0].f, \"S0022\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38359.c",
    "content": "unsigned _ov_64_seek_lap (_Bool x1, _Bool x2, _Bool x3)\n{\n  unsigned ltmp_3978_7__PHI_TEMPORARY;\n  signed ltmp_4011_7;\n\n  if (!x1 || !x2)\n    while (1) ;\n\n  if (x3)\n    ltmp_3978_7__PHI_TEMPORARY = 0xffffff7e;\n  else\n    ltmp_3978_7__PHI_TEMPORARY = 1;\n\n  ltmp_4011_7 = -1;\n  return ltmp_4011_7 >> ltmp_3978_7__PHI_TEMPORARY;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38360.c",
    "content": "/* PR middle-end/38360 */\n/* { dg-require-effective-target untyped_assembly } */\n\nint\nmain ()\n{\n  fputs (\"\");\n  fputs_unlocked (\"\");\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38428.c",
    "content": "/* PR middle-end/38428 */\n\nstruct S\n{\n  volatile struct\n  {\n    unsigned int t : 1;\n  } s;\n};\n\nint\nfoo (struct S *x)\n{\n  int ret;\n  if (x->s.t)\n    ret = 0;\n  else\n    ret = 10;\n  return ret;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38505.c",
    "content": "/* PR middle-end/38505 */\n/* { dg-do compile } */\n\nstruct S\n{\n  unsigned short a[50];\n  unsigned short b[20];\n};\nextern void bar (struct S *);\nextern void baz (unsigned short *);\nextern unsigned short d[];\n\nvoid\nfoo (void)\n{\n  struct S s;\n  unsigned short g[50];\n\n  baz (g);\n  __builtin_memcpy (&s, g, sizeof (g));\n  __builtin_memcpy (s.b, d, sizeof (s.b));\n  bar (&s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38554.c",
    "content": "typedef unsigned long sample;\nstruct pam\n{\n  sample maxval;\n};\ntypedef sample *tuple;\nenum function\n  {\n    FN_MULTIPLY, FN_DIVIDE, FN_ADD, FN_SUBTRACT, FN_MIN, FN_MAX, FN_AND, FN_OR,\n    FN_XOR, FN_NOT, FN_SHIFTLEFT, FN_SHIFTRIGHT\n  };\nstruct cmdlineInfo\n{\n  enum function function;\n  union\n  {\n    float divisor;\n    unsigned int shiftCount;\n  }\n    u;\n};\napplyFunction (struct cmdlineInfo const cmdline, struct pam const inpam,\n               struct pam const outpam, tuple * const inputRow,\n               tuple * const outputRow)\n{\n  float const oneOverDivisor = 1 / cmdline.u.divisor;\n  int col;\n  {\n    int plane;\n    {\n      sample const inSample = inputRow[col][plane];\n      sample outSample;\n      switch (cmdline.function)\n        {\n        case FN_DIVIDE:\n          outSample = ((unsigned int) ((inSample * oneOverDivisor) + 0.5));\n          break;\n        case FN_SHIFTLEFT:\n          outSample = (inSample << cmdline.u.shiftCount) & outpam.maxval;\n        }\n      outputRow[col][plane] =\n        ((outpam.maxval) < (outSample) ? (outpam.maxval) : (outSample));\n    }\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38564.c",
    "content": "struct S\n{\n  struct S *n, *p;\n} *s;\n\nvoid bar (void *);\n\nint\nfoo (int x)\n{\n  struct S p = { &p, &p };\n  int i;\n  for (i = 0; i < x; i++)\n    bar (s);\n  return p.n == &p;\n}\n\nint dialog_calendar(int state)\n{\n  int *obj = (state == 1 ? &state : 0);\n  return (obj == &state);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38590-1.c",
    "content": "\nint func_75 (int p_76) \n{\n  return (1 / (int) -(unsigned int)p_76);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38590-2.c",
    "content": "\nint func_75 (int p_76) \n{\n  return (1 / (int) -(unsigned int)p_76) ? 1 : p_76;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38621.c",
    "content": "/* PR target/38621  */\nstruct s\n{\n  char a[512];\n  int b;\n  int c;\n};\n\nlong long\nfoo (struct s *p, int m, int r)\n{\n  if (r == m)\n    p->b = 3;\n  p->c = 1;\n  return m;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38661-1.c",
    "content": "/* We used to ICE because we would wrap INT_MAX\n   into INT_MIN while doing the switch converison. */\n\nconst char *func(int val) {\n switch (val) {\n   case - __INT_MAX__ -1 : return \"foo\";\n   default: return \"\";\n }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38661.c",
    "content": "/* We used to ICE because we would wrap INT_MAX\n   into INT_MIN while doing the switch converison. */\n\nconst char *func(int val) {\n switch (val) {\n   case __INT_MAX__: return \"foo\";\n   default: return \"\";\n }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38752.c",
    "content": "typedef struct\n{\n  int             baddr;\n} mstruct_t;\n\nstatic struct\n{\n  unsigned int    mapnum;\n  mstruct_t       unused;\n} mtab;\n\nstatic mstruct_t *mactab = &mtab.unused;\n\nint\nmain(void)\n{\n  int i;\n  int addr;\n\n  for (i=1; i <= mtab.mapnum; i++)\n    if (addr < mactab[i].baddr)\n      break;\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38771.c",
    "content": "/* PR middle-end/38771 */\n\nunsigned long long\nfoo (long long x)\n{\n  return -(unsigned long long) (x ? : x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38789.c",
    "content": "/* PR tree-optimization/38789 */\n/* { dg-do compile } */\n\nvoid\nbaz (int v)\n{\n  unsigned a = (v == 1) ? 1 : 2;\n\n  if (__builtin_constant_p (a))\n    asm volatile (\"# constant %0\" :: \"i\" (a));\n  else\n    asm volatile (\"# register %0\" :: \"r\" (a));\n\n  a = 6;\n  if (__builtin_constant_p (a))\n    asm volatile (\"# constant %0\" :: \"i\" (a));\n  else\n    asm volatile (\"# register %0\" :: \"r\" (a));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38807.c",
    "content": "/* PR tree-optimization/38807 */\n\nint\nbaz (short x)\n{\n  return x;\n}\n\nint a, b;\n\nint\nbar (int x)\n{\n  if (baz (a ^ x ^ a))\n    return b;\n  return 0;\n}\n\nint\nfoo (void)\n{\n  return bar (a == 0 || 1 == 1 - a) ? 1 : bar (1 && a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38857.c",
    "content": "static const int vs_total_ac_bits = 2680;\ntypedef struct EncBlockInfo {\n      short mb[64];\n      unsigned char next[64];\n} EncBlockInfo;\ninline void dv_guess_qnos(EncBlockInfo* blks, int* qnos) {\n      int size[5];\n      int j, k, a, prev;\n      EncBlockInfo* b;\n      for(a=2; a==2 || vs_total_ac_bits < size[0]; a+=a){\n\t for (j=0; j<6*5; j++, b++) {\n\t     for (k= b->next[prev]; k<64; k= b->next[k]) {\n\t\t if(b->mb[k] < a && b->mb[k] > -a){\n\t\t     b->next[prev] = b->next[k];\n\t\t }\n\t\t else{\n\t\t     prev = k;\n\t\t }\n\t     }\n\t }\n     }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr38926.c",
    "content": "static inline int foo (unsigned _si1)\n{\n  if (_si1 != 0)\n    if (_si1 > 2147483647)\n      return 1;\n  return 0;\n}\n\nstatic inline unsigned bar (unsigned _left, int _right)\n{\n  return (unsigned) _right >= 8 ? 1 : _left >> _right;\n}\n\nunsigned g_2;\nunsigned g_67;\nvolatile unsigned g_162;\n\nstatic inline int func_62 (unsigned p_63)\n{\n  p_63 = g_2 & g_67;\n  if (g_2)\n    ;\n  else if (p_63)\n    return 1;\n  g_67 = bar (p_63, g_2);\n  return 0;\n}\n\nunsigned baz (void)\n{\n  if (g_2)\n    for (; g_2 <= -16; g_2 = foo (g_2))\n      {\n        for (; g_162; g_162)\n          func_62 (func_62 (0));\n        if (g_67)\n          break;\n      }\n  return g_2;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39041.c",
    "content": "int test_bit(int nr, void *addr)\n{\n  int *a = (int *)addr;\n  int mask;\n  a += nr;\n  mask = 1 << nr;\n  return mask & *a;\n}\nstruct {\n    struct {\n\tint disabled;\n    } *data[1];\n} trace;\nstruct {\n    unsigned bits[1];\n} cpumask;\nvoid inc(int *);\nvoid dec(int *);\nint foo(void)\n{\n  int cpu;\n  for (cpu = 0; cpu < 1; cpu++) {\n      if (test_bit(cpu, cpumask.bits))\n\tinc(&trace.data[cpu]->disabled);\n      if (!test_bit(cpu, cpumask.bits))\n\tdec(&trace.data[cpu]->disabled);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39202.c",
    "content": "typedef struct\n{\n  union\n    {\n      int * aaa;\n    } u;\n} t_a;\n\ntypedef struct\n{\n  unsigned bbb : 1;\n} t_b;\n\ntypedef struct\n{\n  int ccc;\n  t_a ddd;\n  t_b eee;\n  int fff;\n} t_c;\n\ntypedef struct t_d\n{\n  t_c f1;\n  t_c f2;\n} t_d;\n\nvoid foo (void)\n{\n  t_d ggg;\n  ggg.f1 = ggg.f2;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39360.c",
    "content": "/* PR middle-end/39360 */\n\nstatic int a[] = { 1 };\n\nstatic inline void\nbar (int **x)\n{\n  static int *c[2] = { 0, a };\n  *x = c[1];\n}\n\nint\nfoo (int **x)\n{\n  bar (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39394.c",
    "content": "/* PR tree-optimization/39394 */\n\nchar *p;\nint x;\n\nstatic inline void\nf1 (int n)\n{\n  asm volatile (\"\" : \"=m\" (*(struct { char x[n]; } *) p));\n}\n\nstatic inline void\nf2 (void)\n{\n  x ? f1 (1) : f1 (2);\n}\n\nstatic inline void\nf3 (void)\n{\n  f2 ();\n}\n\nvoid\nf4 (void)\n{\n  f3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39423-1.c",
    "content": "/* PR target/39423 */\n/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-O2\" } { \"\" } } */\n\nint\nfoo (const char *name, int nmlen, char *flags)\n{\n  const char *nonspc;\n  int len, n, lfn;\n  int needlfn[2], dotspc[2];\n  unsigned char locale[2];\n  for (nonspc = &name[nmlen - 1]; nonspc >= name && *nonspc == ' '; ++n)\n    {\n      if (!nmlen)\n\t{\n\t  needlfn[name >= nonspc] = !0, dotspc[n != 0] =\n\t    locale[0], --n, name += len, nmlen -= len;\n\t}\n    }\n  if (!lfn && ((dotspc[0] == ' ' && !(len & 0x0010)) || dotspc[0] == '.'))\n    return 22;\n  if (!(needlfn[0] || needlfn[1]))\n    *flags |= 0x02;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39423-2.c",
    "content": "/* PR target/39423 */\n\ntypedef unsigned short uint16_t;\n\ntypedef struct\n{\n  short x, y;\n} P;\n\ntypedef struct\n{\n  uint16_t w, h;\n} D;\n\ntypedef struct\n{\n  P p;\n  D s;\n} A;\n\ntypedef struct\n{\n  uint16_t f;\n} W;\n\ntypedef struct\n{\n  void* w;\n  D s;\n} T;\n\nextern void* foo00 (void*, void*);\n\nvoid foo01 (W* w)\n{\n  void* it;\n  uint16_t c, i;\n  T* cl;\n  T* rs;\n  T* t;\n  uint16_t rh = 0;\n  uint16_t v = !(w->f & 0x8000);\n  A a = { };\n\n  for (c = 0, it = foo00 (w, 0); it; it = foo00 (w, it), c++);\n\n  for (it = foo00 (w, 0), i = 0; i <= c; it = foo00 (w, it), i++, cl++)\n    {\n      if (i)\n \tfor (t = rs; t < cl; t++)\n\t  *((uint16_t*)&t->s + ((!v) ? 1 : 0)) = rh;\n\n      rh = (rh > ((*((uint16_t*)&a.s + ((!v) ? 1 : 0)))))\n\t   ? rh\n\t   : ((*((uint16_t*)&a.s + ((!v) ? 1 : 0)))); \n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39614-1.c",
    "content": "typedef struct page {\n unsigned long flags;\n} mem_map_t;\nstatic inline void set_page_zone(struct page *page, unsigned long zone_num)\n{\n page->flags &= ~(~0UL << (64 - 8));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39614-2.c",
    "content": "int i;\nvoid\nf (void)\n{\n  i = (1 / 0) / 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39614-3.c",
    "content": "int i;\nvoid\nf (void)\n{\n  i = (1 ? 1 / 0 : 1 / 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39614-4.c",
    "content": "int i;\nvoid\nf (void)\n{\n  i = (1 / 0 ? 1 : 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39614-5.c",
    "content": "/* { dg-do compile } */\n/* { dg-options \"-w -std=c99\" } */\nint i;\nvoid\nf (void)\n{\n  i = (1 / 0, 1 / 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39636.c",
    "content": "typedef float real;\ntypedef real rvec[3];\nvoid calc_dx2dx(real *, real *);\nvoid phi_sr(int nj,rvec x[],int k)\n{\n  int i,j;\n  for(i=0; (i<nj-1); i++)\n    for(j=i+1; (j<nj); j++)\n      if (k)\n\tcalc_dx2dx(x[i],x[j]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39648.c",
    "content": "void\nyysyntax_error (char *yyp)\n{\n        char const *yyf;\n        char yyformat[5];\n\n        yyf = yyformat;\n        while ((*yyp = *yyf) != '\\0') {\n                if (yyf[1] == 's')\n                        yyf += 2;\n        }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39673-1.c",
    "content": "unsigned long f1();\nint f2();\n\nint store_aff_word(int x) {\n  return (int) (x ? f1() : f2());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39673-2.c",
    "content": "unsigned long long f1();\nint f2();\n\nint store_aff_word(int x) {\n  return (int) (x ? f1() : f2());\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39779.c",
    "content": "int test (char v1)\n{\n  v1 >>= 0xdebecced;\n  return v1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39824.c",
    "content": "static const double internalEndianMagic = 7.949928895127363e-275;\nstatic const unsigned char ieee_754_mantissa_mask[] = { 0x00, 0x0F, 0xFF, 0xFF,\n    0xFF, 0xFF, 0xFF, 0xFF };\nstatic inline int \ntrio_isnan (double number)\n{\n  int has_mantissa = 0;\n  unsigned int i;\n  unsigned char current;\n  for (i = 0; i < (unsigned int)sizeof(double); i++)\n    {\n      current = ((unsigned char *)&number)[(((unsigned char\n\t\t\t\t\t      *)&internalEndianMagic)[7-(i)])];\n      has_mantissa |= (current & ieee_754_mantissa_mask[i]);\n    }\n  return has_mantissa;\n}\nvoid\nxmlXPathEqualNodeSetFloat(int nodeNr, double v)\n{\n  int i;\n  for (i=0; i<nodeNr; i++)\n    if (!trio_isnan(v))\n      break;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39834.c",
    "content": "/* { dg-options \"-Winline\" } */\nvoid quit_mined ();\nvoid bottom_line ();\ntypedef enum { False, True } FLAG;\ninline void\nnextfile (FLAG exitiflast)\n{\n  if (exitiflast)     \n    quit_mined ();\n  else \n    bottom_line ();\n  nextfile (True);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39845.c",
    "content": "\n/* { dg-options \"-fno-short-enums\" {target short_enums} } */\ntypedef union tree_node *tree;\nenum tree_code { EXCESS_PRECISION_EXPR };\nenum built_in_function { BUILT_IN_ACOS, BUILT_IN_FPCLASSIFY, BUILT_IN_ISFINITE };\nstruct tree_base {\n    __extension__ enum tree_code code : 16;\n    unsigned side_effects_flag : 1;\n};\nstruct tree_exp {\n    tree     operands[1];\n};\nstruct tree_function_decl {\n    __extension__ enum built_in_function function_code : 11;\n    unsigned static_ctor_flag : 1;\n};\nunion tree_node {\n    struct tree_base base;\n    struct tree_function_decl function_decl;\n    struct tree_exp exp;\n};\nstatic tree\nconvert_arguments (tree fundecl)\n{\n  tree val = (void *)0;\n  unsigned int parmnum;\n  unsigned char type_generic_remove_excess_precision = 0;\n  switch (((fundecl)->function_decl.function_code))\n    {\n      case BUILT_IN_ISFINITE:\n      case BUILT_IN_FPCLASSIFY:\n\t  type_generic_remove_excess_precision = 1;\n    }\n  for (parmnum = 0;; ++parmnum)\n    if (((enum tree_code) (val)->base.code) == EXCESS_PRECISION_EXPR\n\t&& !type_generic_remove_excess_precision)\n      val = ((val)->exp.operands[0]);\n  return val;\n}\ntree\nbuild_function_call_vec (tree function)\n{\n  return convert_arguments (function);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39886.c",
    "content": "/* PR middle-end/39886 */\n\nint foo (int);\n\nvolatile unsigned char g;\n\nvoid bar (int p)\n{\n  char l = 0xE1;\n  func ((foo ((p & g) <= l), 1));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39928-1.c",
    "content": "/* { dg-options \"-msse\" { target { i?86-*-* x86_64-*-* } } } */\ntypedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));\nextern __m128 _mm_sub_ps (__m128 __A, __m128 __B);\nextern __m128 _mm_mul_ps (__m128 __A, __m128 __B);\n__m128\nvq_nbest(const __m128 *codebook, __m128 d, __m128 in)\n{\n  return _mm_sub_ps(d, _mm_mul_ps(in, *codebook++));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39928-2.c",
    "content": "typedef _Complex float __m128;\nextern __m128 _mm_sub_ps (__m128 __A, __m128 __B);\nextern __m128 _mm_mul_ps (__m128 __A, __m128 __B);\n__m128\nvq_nbest(const __m128 *codebook, __m128 d, __m128 in)\n{\n  return _mm_sub_ps(d, _mm_mul_ps(in, *codebook++));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39937.c",
    "content": "int foo (__const char *__restrict __s);\nstatic void \nread_anisou(char line[])\n{\n  foo (line+1);\n}\nvoid\nread_pdbfile(void)\n{\n  char line[4096];\n  read_anisou (line);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39941.c",
    "content": "typedef void (*entry_func) (void) __attribute__ ((noreturn));\nextern entry_func entry_addr;\nstatic void bsd_boot_entry (void)\n{\n  stop ();\n}   \nvoid bsd_boot (void)\n{\n  entry_addr = (entry_func) bsd_boot_entry;\n  (*entry_addr) ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39943.c",
    "content": "void gl_fog_index_pixels(float f, unsigned int n, unsigned int index[])\n{ \n  unsigned int i;\n  for (i=0; i<n; i++) \n    index[i] = (unsigned int) ((float) index[i] + (1.0F-f));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39983.c",
    "content": "typedef struct {\n    int *p;\n} *A;\n\nextern const int a[1];\nextern const int b[1];\n\nvoid foo()\n{\n  A x;\n  A y;\n  static const int * const c[] = { b };\n\n  x->p = (int*)c[0];\n  y->p = (int*)a;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr39999.c",
    "content": "void foo(void *);\nvoid\nMMAPGCD (int *A1, int *A2)\n{\n  int *t;\n\n  do\n    {\n      t = A1;\n      A1 = A2;\n      A2 = t;\n    }\n  while (A2[-1]);\n\n  foo (A1-1);\n  foo (A2-1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40023.c",
    "content": "typedef __builtin_va_list va_list;\ntypedef struct {\n    va_list ap;\n} ScanfState;\nvoid\nGetInt(ScanfState *state, long llval)\n{\n  *__builtin_va_arg(state->ap,long *) = llval;\n  __builtin_va_end(state->ap);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40026.c",
    "content": "typedef struct {\n    unsigned long bits;\n} S;\nstruct T {\n    S span;\n    int flags;\n};\n\nstruct T f(int x)\n{\n  return (struct T) {\n      .span = (S) { 0UL },\n      .flags = (x ? 256 : 0),\n  };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40035.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nvoid *memmove (void *dest, const void *src, size_t count);\nsize_t strlen (const char *s);\n\nint\nfoo (char *param, char *val)\n{\n  if (val)\n    {\n      if (val == param + strlen (param) + 1)\n        val[-1] = '=';\n      else if (val == param + strlen (param) + 2)\n        {\n          val[-2] = '=';\n          memmove (val - 1, val, strlen (val) + 1);\n          val--;\n        }\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40080.c",
    "content": "extern void *ff(void*,int);\n\nstruct lpgl { struct lpgl *next; };\nstruct lpgd { struct lpgl *first; };\n\ntypedef int (*xfn)( );\nstatic void xDP_IF_EnumGroupsInGroup ( void *a, int b, xfn fn)\n{\n  struct lpgd *lpGData;\n  struct lpgl *lpGList;\n\n  if( ( lpGData = ff( a, b ) ) == ((void *)0) )\n    return;\n\n  if( lpGData->first  == ((void *)0) )\n    return;\n  lpGList = lpGData->first;\n\n  for( ;; ) {\n    if( !(*fn)( ) )\n      return;\n    if( lpGList->next == ((void *)0) )\n      break;\n    lpGList = lpGList->next;\n  }\n  return;\n}\n\n\nstatic int \nxcbDeletePlayerFromAllGroups() {\n  xDP_IF_EnumGroupsInGroup(0, 0, 0);\n  return 1;\n}\n\nvoid xDP_IF_EnumGroups( xfn fn) {\n  xDP_IF_EnumGroupsInGroup( 0, 0, fn);\n}\n\nstatic void xDP_IF_DestroyPlayer () {\n  xDP_IF_EnumGroups( xcbDeletePlayerFromAllGroups);\n}\n\nvoid* foo=xDP_IF_DestroyPlayer;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40204.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* PR middle-end/40204 */\n\nstruct S\n{\n  unsigned int a : 4;\n  unsigned int b : 28;\n} s;\nchar c;\n\nvoid\nf (void)\n{\n  s.a = (c >> 4) & ~(1 << 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40233.c",
    "content": "typedef int aligned __attribute__((aligned(64)));\nstruct Frame {\n  aligned i;\n};\n\nvoid foo(struct Frame *p)\n{\n  aligned *q = &p->i;\n  *q = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40252.c",
    "content": "typedef unsigned int uint32_t;\nstatic void IP(uint32_t v[2])\n{\n    v[0] = ((v[0] << 1) | ((v[0] >> 31) & 1L)) & 0xffffffffL;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40291.c",
    "content": "/* PR middle-end/40291 */\n\nint\nfoo (void *x, char *y, unsigned long long z)\n{\n  return memcmp (x, y, z);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40321.c",
    "content": "struct X { int flag; int pos; };\nint foo(struct X *a, struct X *b)\n{\n  while (1)\n    {\n      if (a->flag)\n\tbreak;\n      ({ struct X *tmp = a; a = b; b = tmp; });\n    }\n\n  return a->pos + b->pos;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40351.c",
    "content": "/* PR tree-optimizations/40351 */\n\nstruct IO_APIC_route_entry {\n    unsigned int vector : 8;\n    unsigned int delivery_mode : 1;\n    unsigned int mask : 1;\n    unsigned int __reserved_2 : 15;\n    unsigned int __reserved_3 : 8;\n} __attribute__ ((packed));\nunion entry_union {\n    struct {\n        unsigned int w1, w2;\n    };\n    struct IO_APIC_route_entry entry;\n};\nunsigned int io_apic_read(void);\nstruct IO_APIC_route_entry ioapic_read_entry(void)\n{\n  union entry_union eu;\n  eu.w1 = io_apic_read();\n  return eu.entry;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40432.c",
    "content": "/* Test that SRA produces valid gimple when handling both type punning by means\n   of VCE and creating an access to a union.  */\n\nunion U {\n  struct something *sth;\n  void *nothing;\n};\n\nvoid\nfoo (union U *target, void *p)\n{\n  union U u;\n\n  u.nothing = p;\n  *target = u;\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40556.c",
    "content": "struct A {};\n\nstruct A foo()\n{\n  return foo();\n}\n\nvoid bar()\n{\n  foo();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40570.c",
    "content": "extern void anything(int);\n\nstatic int foo(int i);\n\nstatic int bar(int i) { foo(i); }\n\nextern int j;\n\nstatic int foo(int i)\n{\n  if (j)\n    anything(j);\n  return bar(i);\n}\n\nint baz()\n{\n  foo(0);\n  if (baz())\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40582.c",
    "content": "struct A\n{\n  void* q;\n  short i;\n};\n\nunion U\n{\n  char* p;\n  struct A a;\n};\n\nstruct A foo(union U u)\n{\n  struct A a = { 0, 0 };\n  a = u.a;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40640.c",
    "content": "void decode_opic_address(int *);\nvoid sim_io_printf_filtered2 (int, unsigned);\nvoid\nhw_opic_io_read_buffer(int index)\n{\n  unsigned reg = 0;\n  decode_opic_address(&index);\n  switch (index)\n    {\n      case 0:\n\t  reg = 1;\n    }\n  sim_io_printf_filtered2 (index, reg);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40676.c",
    "content": "extern int f1();\nextern int f2(void*);\nextern void* f3(int);\nint xmsih;\ntypedef unsigned short XWCHAR;\n\ninline unsigned int xstrlenW( const XWCHAR *str )\n{\n    const XWCHAR *s = str;\n    while (*s) s++;\n    return s - str;\n}\n\n\nstatic int msi_dialog_register_class( void )\n{\n    int cls;\n\n    if( !f2( &cls ) )\n        return 0;\n    if( !f2( &cls ) )\n        return 0;\n    xmsih = f1();\n    if( !xmsih )\n        return 0;\n    return 1;\n}\n\nvoid *xmsi_dialog_create(const XWCHAR* szDialogName)\n{\n    msi_dialog_register_class();\n    return f3(xstrlenW(szDialogName));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40692.c",
    "content": "/* PR middle-end/40692 */\n\n#define M1(x) (((x) & 0x00000002) ? 0x2 : ((x) & 0x1))\n#define M2(x) (((x) & 0x0000000c) ? M1 ((x) >> 2) << 2 : M1 (x))\n#define M3(x) (((x) & 0x000000f0) ? M2 ((x) >> 4) << 4 : M2 (x))\n#define M4(x) (((x) & 0x0000ff00) ? M3 ((x) >> 8) << 8 : M3 (x))\n#define M5(x) (((x) & 0xffff0000) ? M4 ((x) >> 16) << 16 : M4 (x))\n\nstruct A { char e; char f; };\n\nlong\nfoo (void)\n{\n  return M5 (4096UL - (long) &((struct A *) 0)->f);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40753.c",
    "content": "typedef struct {\n    unsigned nargs;\n} ffi_cif;\ntypedef struct {\n    char tramp[24];\n    ffi_cif *cif;\n} ffi_closure;\nextern void *memcpy (void *, const void *, __SIZE_TYPE__);\nextern void ffi_closure_LINUX64 (void);\n\nint\nffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif)\n{\n  void **tramp = (void **) &closure->tramp[0];\n\n  memcpy (tramp, (char *) ffi_closure_LINUX64, 16);\n  closure->cif = cif;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40797.c",
    "content": "typedef struct str { short x, y;} S;\n\nstatic short\nbar (short ch, short sl, short sr, short tl, short tr)\n{\n  return 0;\n}\n\nvoid\nfoo (short ch, S *pi, short nc, S *po)\n{\n  short clo, chi, lo, hi;\n\n  po->x = bar (ch, clo, chi, pi[lo].x, pi[hi].x);\n  po->y = bar (ch, clo, chi, pi[lo].y, pi[hi].y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr40964.c",
    "content": "struct alloc2 {\n    int bla;\n    char * __restrict data;\n    char * __restrict data2;\n};\nstruct alloc2 b;\nvoid * f (void)\n{\n  return b.data;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41006-1.c",
    "content": "typedef int (*FARPROC)();\n\ntypedef int (*LPFN_ACCEPTEX)(void*);\nstatic LPFN_ACCEPTEX acceptex_fn;\n\nint xWSAIoctl(void*);\nstatic void get_fn(FARPROC* fn)\n{\n    FARPROC func;\n    if (!xWSAIoctl( &func))\n        *fn = func;\n}\n\nvoid get_fn_pointers()\n{\n    get_fn((FARPROC*)&acceptex_fn);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41006-2.c",
    "content": "typedef int *FARPROC;\nstatic int * __restrict__ acceptex_fn;\n\nint xWSAIoctl(void*);\nstatic void get_fn(FARPROC* fn)\n{\n  FARPROC func;\n  if (!xWSAIoctl( &func))\n    *fn = func;\n}\n\nvoid get_fn_pointers()\n{\n  get_fn((FARPROC*)&acceptex_fn);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41016.c",
    "content": "typedef struct _IO_FILE FILE;\nvoid\nCompareRNAStructures (FILE * ofp, int start, int L, char *ss_true, char *ss)\n{\n  int i;\n  float agree = 0.;\n  float pairs = 0.;\n  float pairs_true = 0.;\n  for (i = 0; i < L; i++)\n    {\n      pairs_true += 1.;\n      agree += 1.;\n    }\n  if (((int) pairs % 2 != 0) || ((int) pairs_true % 2 != 0)\n      || ((int) agree % 2 != 0))\n    Die (\"Error in CompareRNAStrutures(); odd number of paired nucleotides\\n\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41101.c",
    "content": "int func(int);\n\nvoid\nbug(int* x, int* y, unsigned long int N)\n{\n  unsigned long int i;\n  int* t;\n\n  while (1)\n    {\n      for (i=1; i<=N; i++)\n\t{\n\t  y[i] = func(x[i] - x[1]);\n\t  if (y[i])\n\t    return;\n\t}\n      t=x; x=y; y=t;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41163.c",
    "content": "struct option {\n    void *value;\n};\nvoid parse_options (struct option *);\nvoid cmd_grep(void)\n{\n  struct option options[] = { { &options } };\n  parse_options(options);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41181.c",
    "content": "/* { dg-require-effective-target ptr32plus } */\n/* { dg-skip-if \"The array is too big\" { \"avr-*-*\" \"pdp11-*-*\" } { \"*\" } { \"\" } } */ \nchar paths[1024];\nstatic void x264_slicetype_path(char (*best_paths)[250], int n, int length)\n{\n    __builtin_memcpy (best_paths[n], paths, length);\n}\nvoid x264_slicetype_analyse(int n, int length)\n{\n    char best_paths[250][250];\n    x264_slicetype_path (best_paths, n, length);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41182-1.c",
    "content": "typedef long unsigned int size_t;\nint _lae_process_opts(char *pr, char *pe)\n{ \n  return (strlen (\"on\") < ((size_t) ((pe-&pr[2])>(strlen(\"on\"))                \n                                     ? (pe-&pr[2]) : (strlen(\"on\")))));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41282.c",
    "content": "struct S\n{\n  unsigned int iu;\n};\n\nunion U\n{\n  struct S s;\n  signed int is;\n};\n\nextern signed int bar ();\n\nstruct S foo (void)\n{\n  union U u;\n\n  u.is = bar ();\n  return u.s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41469.c",
    "content": "/* { dg-options \"-fexceptions\" } */\n/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n\nvoid\naf (void *a)\n{\n}\nvoid\nbf (void)\n{\n  int i = 1;\n  char v[i];\n  af (v);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41634.c",
    "content": "extern int _xgetw();\nextern int foo(char*);\n\nvoid test_readmode( int ascii_mode )\n{\n  static const char outbuffer[]\n    = \"0,1,2,3,4,5,6,7,8,9\\r\\n\\r\\nA,B,C,D,E\\r\\nX,Y,Z\";\n  char buffer[2*512 +256];\n  int i, j, ao;\n  unsigned int fp;\n\n  foo(buffer);\n\n  for (i=0, j=0; i<6; i++) {\n      if (ao==0 || outbuffer[fp-3+i] != '\\r')\n\tbuffer[j++] = outbuffer[fp-3+i];\n  }\n  _xgetw();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41646.c",
    "content": "/* PR rtl-optimization/41646 */\n\nstruct A { unsigned long a; };\nstruct B { unsigned short b, c, d; };\nstruct B bar (unsigned long);\n\nchar *\nfoo (char *a, struct A *x)\n{\n  struct B b = bar (x->a);\n  unsigned char c;\n  unsigned short d;\n  a[3] = ((unsigned char) (b.b % 10) + 48);\n  d = b.b / 10;\n  a[2] = ((unsigned char) (d % 10) + 48);\n  d = d / 10;\n  a[1] = ((unsigned char) (d % 10) + 48);\n  a[0] = ((unsigned char) ((d / 10) % 10) + 48);\n  a[4] = 46;\n  c = (unsigned char) b.c;\n  a[6] = (c % 10 + 48);\n  a[5] = ((c / 10) % 10 + 48);\n  a[7] = 46;\n  c = b.d;\n  a[9] = (c % 10 + 48);\n  a[8] = ((c / 10) % 10 + 48);\n  return a + 10;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41661.c",
    "content": "/* PR tree-optimization/41661 */\n/* { dg-do compile } */\n/* { dg-options \"-fno-early-inlining\" } */\n\nint g;\n\nvoid foo (int x)\n{\n  g = x;\n}\n\nvoid bar (double d)\n{\n  foo (d == 1);\n}\n\nvoid baz (int a)\n{\n  bar (1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41679.c",
    "content": "/* { dg-options \"-g\" } */\n\nextern int a;\nextern char b;\nextern int foo (void);\n\nvoid\ntest (void)\n{\n  int c;\n  b = foo () ? '~' : '\\0';\n  while ((c = foo ()))\n    if (c == '7')\n      a = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41728.c",
    "content": "int a[8];\nint s244(void)\n{\n  int lrc, j;\n  lrc = 0;\n  for (j=0; j<7; j++)\n    if(a[j] != a[j+1])\n      lrc = 1;\n  if (lrc != 0)\n    return 0;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr41987.c",
    "content": "/* PR tree-optimization/41987 */\n\n#define TESTIT(TYPE) do { \\\n  _Complex TYPE ylm; \\\n  TYPE nbond; \\\n  ylm = 0; \\\n  nbond = 0; \\\n  ylm = ylm / nbond; \\\n} while (0)\n\nvoid qparm_colvar(void)\n{\n  TESTIT (float);\n  TESTIT (double);\n  TESTIT (long double);\n\n  TESTIT (char);\n  TESTIT (short);\n  TESTIT (int);\n  TESTIT (long);\n  TESTIT (long long);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42025-1.c",
    "content": "typedef void* Ptr;\n\nstruct A\n{\n  int i;\n  union\n  {\n    Ptr p;\n    char *q;\n  } u;\n};\n\nstatic void foo(struct A *p, char *q)\n{\n  if (p->i)\n    p->u.p = 0;\n  else\n    p->u.q = q;\n}\n\nvoid bar(struct A *p, char *q)\n{\n  foo(p, q);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42025-2.c",
    "content": "typedef struct\n{\n  void *p;\n} Ptr;\n\nstruct A\n{\n  int i;\n  union\n  {\n    Ptr p;\n    char *q;\n  } u;\n};\n\nextern Ptr get_stuff (void);\nextern void use_stuff (char *);\n\nstatic void foo(struct A p, char *q)\n{\n  if (p.i)\n    p.u.p = get_stuff ();\n  else\n    p.u.q = q;\n\n  use_stuff (p.u.q);\n}\n\nvoid bar(struct A *p, char *q)\n{\n  foo(*p, q);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42049.c",
    "content": "/* PR middle-end/42049 */\n\nextern char *strcpy (char *s1, const char *s2);\nstruct S { char s[4]; };\n\nint\nfoo (int x, char **y)\n{\n  char const *a;\n  char const *b;\n  struct S s[9];\n  long i;\n  if (x > 1)\n    a = y[1];\n  else\n    a = \"abc\";\n  if (x > 2)\n    b = y[2];\n  else\n    b = \"def\";\n  strcpy (s[0].s, a);\n  strcpy (s[1].s, b);\n  for (i = 2; i < x - 2 && i < 8; i++)\n    strcpy (s[i].s, y[i + 1]);\n  s[i].s[0] = '\\0';\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42164.c",
    "content": "typedef struct\n{\n  unsigned long long pte;\n} pte_t;\npte_t mk_swap_pte (unsigned long offset)\n{\n  pte_t pte;\n  pte.pte = (offset << 40);\n  return pte;\n}\nint pte_file (pte_t pte)\n{\n  return pte.pte & (1 << 4);\n}\ntypedef struct\n{\n  unsigned long val;\n} swp_entry_t;\npte_t swp_entry_to_pte (swp_entry_t entry)\n{\n  swp_entry_t arch_entry;\n  arch_entry = (swp_entry_t){mk_swap_pte (swp_offset (entry)).pte};\n  __BUG_ON ((unsigned long) pte_file ((pte_t) {arch_entry.val}));\n  return (pte_t) {arch_entry.val};\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-1.c",
    "content": "union U\n{\n  double d;\n  __complex__ int c;\n};\n\ndouble gd;\nextern double bar (union U);\n\ndouble foo (int b, double d, int c1, int c2)\n{\n  union U u;\n  double r;\n\n  if (b)\n    {\n      u.d = d;\n      r = u.d;\n    }\n  else\n    {\n      __real__ u.c = c1;\n      __imag__ u.c = c2;\n      r = bar (u);\n    }\n\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-2.c",
    "content": "union U\n{\n  __complex__ int ci;\n  __complex__ float cf;\n};\n\nfloat gd;\nextern float bar (union U);\n\nfloat foo (int b, double f1, double f2, int c1, int c2)\n{\n  union U u;\n  double r;\n\n  if (b)\n    {\n      __real__ u.cf = f1;\n      __imag__ u.cf = f2;\n    }\n  else\n    {\n      __real__ u.ci = c1;\n      __imag__ u.ci = c2;\n    }\n\n  r = bar (u);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42196-3.c",
    "content": "union U\n{\n  __complex__ int ci;\n  __complex__ float cf;\n};\n\nfloat gd;\nextern float bar (float, float);\n\nfloat foo (int b, union U u)\n{\n  float f1, f2, r;\n\n  if (b)\n    {\n      f1 = __real__ u.cf;\n      f1 = __imag__ u.cf;\n    }\n  else\n    {\n      f1 = __real__ u.ci;\n      f1 = __imag__ u.ci;\n    }\n\n  r = bar (f1, f2);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42234.c",
    "content": "/* { dg-options \"-g\" } */\n\nvoid\nfoo (int x)\n{\n  struct S { int s; } d = { 1 };\n  unsigned int e = 1;\n  if (x)\n    e = x && d.s;\n  else\n    for (e = 0; e <= 3; e--)\n      ;\n  e++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42237.c",
    "content": "struct A\n{\n  int p;\n};\n\nstruct B\n{\n  struct A n;\n  struct A m;\n  int x;\n  int y;\n  int z;\n};\n\nextern int g1, g2;\n\nstatic void __attribute__((noinline)) foo (struct B *b)\n{\n  int t;\n\n  t = b->n.p;\n  g1 = t;\n  b->n.p = t+1;\n  g2 = b->m.p;\n\n  b->m = b->n;\n}\n\nvoid bar (struct B *b)\n{\n  foo (b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42299.c",
    "content": "/* { dg-options \"-g\" } */\n\nvoid bar (void);\n\nstatic int\nfoo (int x, int y)\n{\n  if (y)\n    goto lab;\n  if (x)\n    y = 0;\n  if (y)\n    goto lab;\n  y = 0;\nlab:\n  return y;\n}\n\nvoid\nbaz (int x, int y)\n{\n  y = foo (x, y);\n  if (y != 0)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42347.c",
    "content": "/* PR bootstrap/42347 */\n\nlong\nfoo (long x, long y)\n{\n  x = x & y;\n  switch (y)\n    {\n    case 63L: x >>= 0; break;\n    case 4032L: x >>= 6; break;\n    case 258048L: x >>= 12; break;\n    case 16515072L: x >>= 18; break;\n    default: __builtin_unreachable ();\n    }\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42398.c",
    "content": "int ptrace_setregs(void)\n{\n  union { unsigned int l; int t; } __gu_tmp;\n  __asm__ __volatile__(\"\" : \"=r\" (__gu_tmp.l));\n  return __gu_tmp.t;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42559.c",
    "content": "/* { dg-require-effective-target label_values } */\n\nvoid jumpfunc(int copy, void *p)\n{\n  void *l = &&jumplabel;\n  if (copy)\n    __builtin___memcpy_chk (p, l, 128, __builtin_object_size (p, 0));\njumplabel:\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42632.c",
    "content": "static inline __attribute__((always_inline)) int\n__pskb_trim(void)\n{\n  return ___pskb_trim();\n}\nstatic inline __attribute__((always_inline))\nint pskb_trim(void)\n{\n  return __pskb_trim();\n}\nint ___pskb_trim(void)\n{\n  pskb_trim();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42703.c",
    "content": "__extension__ typedef unsigned long long int uint64_t;\ntypedef uint64_t ScmUInt64;\nvoid swapb64(ScmUInt64 *loc) \n{\n    union {\n        ScmUInt64 l;\n        unsigned char c[4];\n    } dd;\n    unsigned char t;\n    dd.l = *loc;\n    (t = dd.c[3], dd.c[3] = dd.c[4], dd.c[4] = t);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42705.c",
    "content": "typedef int GLint;\ntypedef unsigned char GLubyte;\ntypedef unsigned int uint32_t;\nstruct radeon_bo {\n    void *ptr;\n    uint32_t flags;\n};\nstruct radeon_renderbuffer {\n    struct radeon_bo *bo;\n    unsigned int cpp;\n    int has_surface;\n};\nstatic inline\nGLint r600_1d_tile_helper(const struct radeon_renderbuffer * rrb,\n\t\t\t  GLint x, GLint y, GLint is_depth, GLint is_stencil)\n{\n  GLint element_bytes = rrb->cpp;\n  GLint num_samples = 1;\n  GLint tile_width = 8;\n  GLint tile_height = 8;\n  GLint tile_thickness = 1;\n  GLint tile_bytes;\n  GLint tiles_per_row;\n  GLint slice_offset;\n  GLint tile_row_index;\n  GLint tile_column_index;\n  GLint tile_offset;\n  GLint pixel_number = 0;\n  GLint element_offset;\n  GLint offset = 0;\n  tile_bytes = tile_width * tile_height * tile_thickness\n      * element_bytes * num_samples;\n  tile_column_index = x / tile_width;\n  tile_offset = ((tile_row_index * tiles_per_row)\n\t\t + tile_column_index) * tile_bytes;\n  if (is_depth) {\n  }\n  else {\n      GLint sample_offset;\n      switch (element_bytes) {\n\t  case 1:       pixel_number |= ((x >> 0) & 1) << 0;\n      }\n      element_offset = sample_offset + (pixel_number * element_bytes);\n  }\n  offset = slice_offset + tile_offset + element_offset;\n  return offset;\n}\nGLubyte *r600_ptr_color(const struct radeon_renderbuffer * rrb,\n\t\t\tGLint x, GLint y)\n{\n  GLubyte *ptr = rrb->bo->ptr;\n  uint32_t mask = 1 | 2;\n  GLint offset;\n  if (rrb->has_surface || !(rrb->bo->flags & mask)) {\n      offset = r600_1d_tile_helper(rrb, x, y, 0, 0);\n  }\n  return &ptr[offset];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42708-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nvoid *malloc(size_t);\ntypedef union YYSTYPE {\n    char *id;\n}  YYSTYPE;\nextern YYSTYPE yylval;\nvoid yylex (int b)\n{\n  yylval = (YYSTYPE) (b ? 0 : (char *) malloc (4));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42716.c",
    "content": "static short foo (long long si1, short si2)\n{\n  return si1 > 0 && si2 > 0 || si1 < 0\n      && si2 < 0 && si1 < 1 - si2 ? : si1 + si2;\n}\n\nint g_13;\nunsigned g_17;\n\nint safe (int, int);\n\nvoid bar (short p_51, short * p_52)\n{\n  int *const l_55 = &g_13;\n  if (safe (*p_52, g_13 != foo (*p_52 & *l_55 == g_13 && g_17 >= 1, 0)))\n    {\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42717.c",
    "content": "/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"-O0\" } { \"\" } } */\nstatic signed char\nfoo (signed char si1, unsigned char si2)\n{\n  return (si1 ^ si2) & (-si2 ^ si2) ? : si1 - si2;\n}\n\nstruct S0\n{\n};\n\nunsigned char g_21;\n\nstruct S0 g_34;\n\nvoid\nbar (unsigned char p_20)\n{\n  unsigned char *l_22 = &g_21;\n  unsigned char l_23 = 0;\n  struct S0 *l = &g_34;\n  goto lbl_42;\n  for (; l_23; l_23 = foo (l_23, 1))\n    {\n      for (p_20 = 0; 0; p_20 = foo (p_20, 1))\n\tlbl_42:;\n      (l == &g_34) ? 0 : \"\";\nlbl_85:*l_22 = p_20;\n    }\n  goto lbl_85;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42730.c",
    "content": "union bzz\n{\n  unsigned *pa;\n  void *pv;\n};\n\nvoid foo (void)\n{\n  union bzz u;\n  void **x;\n  void *y = 0;\n  x = &u.pv;\n  *x = y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42749.c",
    "content": "struct pdf_object { int val; };\nint pdf_count_size_object (struct pdf_object * p_obj)\n{\n    return pdf_count_size_object(p_obj) + 2 * sizeof(struct pdf_object);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42927.c",
    "content": "typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));\ntypedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));\ntypedef enum { READ_SHARED = 0, WRITE_EXCLUSIVE = 1,\n    READ_EXCLUSIVE = 2, EXCLUSIVE_ACCESS = 3 } scsires_access_mode;\nstruct scsires_extent_elem {\n    scsires_access_mode mode;\n    unsigned relative_address;\n    u_int32_t first_block;\n    u_int32_t length;\n};\ntypedef struct scsires_extent_elem scsires_extent_elem_t;\nstruct scsires_extent {\n    u_int8_t num_elements;\n    scsires_extent_elem_t *elements;\n};\ntypedef struct scsires_extent scsires_extent_t;\nunsigned char buf[512];\nvoid scsires_issue_reservation(scsires_extent_t * new_extent)\n{\n  int i;\n  for (i = 0; i < new_extent->num_elements; i++)\n    {\n      buf[(i * 8)] = new_extent->elements[i].mode;\n      buf[(i * 8) + 1] = ((new_extent->elements[i].length >> 16) & 0xff); \n      buf[(i * 8) + 2] = ((new_extent->elements[i].length >> 8) & 0xff);\n      buf[(i * 8) + 3] = (new_extent->elements[i].length & 0xff);\n      buf[(i * 8) + 4] = ((new_extent->elements[i].first_block >> 24) & 0xff); \n      buf[(i * 8) + 5] = ((new_extent->elements[i].first_block >> 16) & 0xff);\n      buf[(i * 8) + 6] = ((new_extent->elements[i].first_block >> 8) & 0xff);\n      buf[(i * 8) + 7] = (new_extent->elements[i].first_block & 0xff);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42956.c",
    "content": "/* { dg-require-effective-target alloca } */\ntypedef const int cint;\ntypedef struct {\n} Bounds;\nint ndim_, ncomp_, selectedcomp_, nregions_;\nvoid *voidregion_;\ntypedef struct {\n    double diff, err, spread;\n} Errors;\ntypedef const Errors cErrors;\nvoid Split(int iregion, int depth, int xregion)\n{\n  typedef struct {\n      double avg, err, spread, chisq;\n      double xmin[ndim_], xmax[ndim_];\n  } Result;\n  typedef struct region {\n      Result result[ncomp_];\n  } Region;\n  Errors errors[ncomp_];\n  int comp, ireg, xreg;\n  for( ireg = iregion, xreg = xregion; ireg < nregions_; ireg = xreg++ )\n    {\n      Result *result = ((Region *)voidregion_)[ireg].result;\n      for( comp = 0; comp < ncomp_; ++comp )\n\t{\n\t  Result *r = &result[comp];\n\t  cErrors *e = &errors[comp];\n\t  double c = e->diff;\n\t  if( r->err > 0 ) r->err = r->err*e->err + c;\n\t}\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr42998.c",
    "content": "void foo(void *);\nvoid bar(void *);\nvoid ndisc_fill_addr_option(unsigned char *opt, int data_len,\n\t\t\t    unsigned short addr_type) \n{\n  int pad;\n  if (addr_type == 32)\n    pad = 2;\n  else\n    pad = 0;\n  __builtin_memset(opt + 2, 0, pad);\n  opt += pad;\n  __builtin_constant_p(data_len) ? foo (opt+2) : bar (opt+2);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43066.c",
    "content": "struct S {\n  struct { } empty[1];\n  int i;\n};\n\nint foo(int i, ...)\n{\n  struct S s;\n  __builtin_va_list va;\n  __builtin_va_start(va, i);\n  s = __builtin_va_arg(va, struct S);\n  __builtin_va_end(va);\n  return s.i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43164.c",
    "content": "struct S0\n{\n  unsigned char f0;\n  int:0;\n};\n\nstruct S1\n{\n  struct S0 f0;\n};\n\nstruct S1 func_34 (void)\n{\n  struct S1 l_221 = { { 1 } };\n  return l_221;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43186.c",
    "content": "int n;\n\nvoid foo (int i)\n{\n  int a, b;\n\n  if (!i)\n    for (a = 1; a < 4; a++)\n      if (a)\n\tfor (b = 1; b < 3; b++)\n\t  foo (b);\n\n  n++;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43188.c",
    "content": "int *__attribute__((__aligned__(16))) *p;\n\nint main (void)\n{\n  return **p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43191.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\nstruct S0\n{\n};\n\nstruct S1\n{\n  unsigned f0:27;\n  const unsigned:0;\n};\n\nstruct S2\n{\n  unsigned f2:1;\n};\n\nunsigned char g_4[1][8][3][1][1][1];\nunsigned char *g_17;\nunsigned char **g_16[1][10][7];\n\nstruct S2 g_35 = {\n  0\n};\n\nstruct S2 *g_34 = &g_35;\n\nstruct S1 func_86 (unsigned char p_87, struct S2 **p_89)\n{\n  struct S1 l_92[6][8][1][1] = {\n    16143586\n  }\n  ;\n  return l_92[0][0][0][0];\n}\n\nvoid func_28 (struct S1 p_30, const struct S1 p_32)\n{\n}\n\nvoid func_70 (unsigned char p_72)\n{\n  unsigned char *const *l_93 = &g_17;\n  struct S2 **l_94;\n  unsigned char *const *l_97 = &g_17;\n  func_28 (func_86 (p_72, 0),\n           func_86 (p_72, &g_34));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43255.c",
    "content": "int safe (int);\n\nstatic unsigned foo (unsigned ui1, unsigned ui2)\n{\n  return ui1 + ui2;\n}\n\nint g_22;\nint *volatile g_23 = &g_22;\nint **g_282[8][10][1];\nint *g_330 = &g_22;\nvolatile unsigned g_348;\nint g_397;\n\nvoid int32func (const unsigned char p_10)\n{\n  if (foo\n      (~\n       (p_10 |\n\t(*g_282[(unsigned long) g_397 % 8][(unsigned) g_22 % 10][g_348 % 1]) ==\n\t(*g_282[(unsigned long) g_397 % 8][(unsigned) g_22 % 10][g_348 % 1])),\n       1))\n    {\n    }\n  else if (*g_330 >=\n\t   safe (*g_23 ^\n\t\t (**g_282[(unsigned long) g_397 % 8][(unsigned) g_22 % 10]\n\t\t  [g_348 % 1])) & **g_282[8][10][1], 1)\n    {\n    }\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43288.c",
    "content": "static int a __attribute__ ((common));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43367.c",
    "content": "unsigned char g_17;\n\nconst unsigned char func_39 (unsigned char p_40, unsigned char * p_41)\n{\n  return 0;\n}\n\nvoid int327 (const unsigned char p_48, unsigned char p_49)\n{\n  unsigned l_52;\n  unsigned char l_58[2];\n  int i, j;\n  if (func_39 (l_52, &p_49), p_48) {\n      unsigned char *l_60;\n      unsigned char *l = &l_58[1];\n      for (j; j; j++) {\nlbl_59:\n\t  break;\n      }\n      for (l = 0; 1; l += 1) {\n\t  for (p_49 = 1; p_49; p_49 += 0) {\n\t      unsigned char **l_61[1][6];\n\t      for (j = 0; j < 1; j++)\n\t\tl_61[i][j] = &l_60;\n\t      goto lbl_59;\n\t  }\n      }\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43415.c",
    "content": "int main()                                                                      \n{                                                                               \n  unsigned long long table[256];                                          \n  unsigned int i;\n  for (i=0; i<256; ++i) {\n      unsigned long long j;\n      unsigned char x=i;\n      for (j=0; j<5; ++j) {\n\t  x += x<<1;\n\t  x ^= x>>1;\n      }\n      for (j=0; j<5; ++j) {\n\t  x += x<<1;\n\t  x ^= x>>1;\n      }\n      for (j=0; j<5; ++j) {\n\t  x += x<<1;\n\t  x ^= x>>1;\n      }\n      for (j=0; j<5; ++j) {\n\t  x += x<<1;\n\t  x ^= x>>1;\n      }\n      for (j=0; j<5; ++j) {\n\t  x += x<<1;\n\t  x ^= x>>1;\n      }\n      table[i] ^= (((unsigned long long)x)<<16);\n  }\n  for (i=0; i<256; ++i) {\n      if ((table[i]&0xff)==i)\n\treturn 1;\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43417.c",
    "content": "int pid_count = 0;\n\nunsigned int getopt (int, const char**, const char*);\nunsigned long long atoll (const char*);\nint fork (void);\nvoid kill (int, int);\n\nint\nmain (int argc, const char *argv[])\n{\n  unsigned int c;\n  unsigned long long maxbytes = 0;\n  extern const char *optarg;\n  int i;\n  int pid_cntr;\n  int pid;\n  int pid_list[1000];\n  while ((c = getopt (argc, argv, \"c:b:p:wvh\")) != (-1))\n    {\n      switch ((char) c)\n\t{\n\tcase 'b':\n\t  maxbytes = atoll (optarg);\n\t}\n    }\n  pid = fork ();\n  while ((pid != 0) && (maxbytes > 1024 * 1024 * 1024))\n    {\n      maxbytes = maxbytes - (1024 * 1024 * 1024);\n      pid = fork ();\n      if (pid != 0)\n\tpid_cntr++;\n      pid_list[i] = pid;\n    }\n  while ((pid_count < pid_cntr))\n    {\n    }\n  kill (pid_list[i], 9);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43614.c",
    "content": "volatile int g_2[7];\n\nvoid foo (unsigned);\n\nint main (void)\n{\n  int i_459 = 0;\n  int t2818;\n  int t2819;\n  volatile char *t2820;\n  int t2821;\n  volatile char *t2822;\n  int *t2823;\n  unsigned t2824;\nLL655:\n  t2822 = (volatile char *)g_2;\n  t2821 = i_459;\n  t2820 = t2822 + t2821;\n  t2823 = (int *)t2820;\n  t2824 = *t2823;\n  foo (t2824);\n  t2818 = i_459;\n  t2819 = t2818 + 1;\n  i_459 = t2819;\n  goto LL655;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43635.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nextern void d (void);\n\nvoid (*foo (void)) (float)\n{\n  void (*(*x) (void)) (float) = d;\n  return (*x) ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43636.c",
    "content": "/* PR target/43636 */\n\nextern char a[], *b[];\n\nchar *\nfoo (char *x, int y)\n{\n  x = __builtin_stpcpy (x, b[a[y]]);\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43661.c",
    "content": "int\nfunc (int x)\n{\n  return 0 ? (unsigned short) (0 ? : 1 * (signed char) (x ^ x) >= 0) : 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43679.c",
    "content": "unsigned g_5;\nint g_7;\nint g_23[2];\nint *g_29 = &g_23[0];\nint **g_59;\nunsigned long g_186;\n\nint foo (int, int);\nint bar (int);\n\nvoid func_37 (long p_38)\n{\n  int *l_39 = &g_7;\n  *l_39 = (*l_39\n             ||\n             (foo\n              (((*g_29 != *l_39, ((bar (g_59 != &l_39), 0), 0))),\n               0)));\n  foo (*l_39, 0);\n  int **l_256 = &l_39;\n  {\n    for (0; g_186; 0)\n      {\n        *l_256 = *l_256;\n        if (g_5)\n          goto lbl_270;\n        *l_39 &= 0;\n      }\n  }\nlbl_270:\n  ;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43791.c",
    "content": "int owner();\nint clear();\n\nstatic void fixup() {\n   clear();\n}\n\ninline __attribute__ ((always_inline))\nvoid slowtrylock(void) {\n     if (owner())\n         fixup();\n}\n\nvoid fasttrylock(void (*slowfn)()) {\n     slowfn();\n}\n\nvoid trylock(void) {\n     fasttrylock(slowtrylock);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr43845.c",
    "content": "typedef int __attribute__ ((const)) (*x264_pixel_cmp_t)(void);\n\ntypedef struct {\n    x264_pixel_cmp_t ssd;\n} x264_pixel_function_t;\n\nint x264_pixel_ssd_wxh (x264_pixel_function_t *pf, int i_width) {\n    int i_ssd = 0, x;\n    for (x = 0; x < i_width; x++)\n      i_ssd += pf->ssd();\n    return i_ssd;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44030.c",
    "content": "typedef int int32_t;\ntypedef unsigned int uint32_t;\nstatic uint32_t\nsafe_sub_func_uint32_t_u_u (uint32_t ui1, uint32_t ui2)\n{\n  return ui1 - ui2;\n}\n\nint32_t l_105[7];\n\nint32_t g_4;\nint32_t *g_54 = &g_4;\nint32_t *\nfunc (int32_t p_73, int32_t * p_74, int32_t p_75, int32_t * *p_76,\n      int32_t * *p_77)\n{\nlbl_110:for (g_4 = 0; g_4; g_4 = 1)\n    {\n    }\n  for (p_75 = -28; p_75; p_75 = safe_sub_func_uint32_t_u_u (p_75, 1))\n    {\n      if (g_4)\n        goto lbl_110;\n      *g_54 = 0;\n    }\n  return &l_105[5];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44038.c",
    "content": "struct Ustr {\n    char data[1]; \n};\nint ustr_xi__embed_val_get(char *);\ninline static int ustr_len(struct Ustr *s1)\n{\n  return ustr_xi__embed_val_get(s1->data);\n}\nstatic struct Ustr *s1 = ((struct Ustr *) \"\");\nint tst(char *cstr)\n{\n  return ustr_len(s1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44043.c",
    "content": "typedef unsigned char __u8;\ntypedef unsigned short __u16;\ntypedef unsigned int __u32;\ntypedef unsigned long __kernel_size_t;\ntypedef __kernel_size_t size_t;\ntypedef __u8 uint8_t;\ntypedef __u16 __be16;\ntypedef __u32 __be32;\nstruct msghdr {\n    struct iovec * msg_iov;\n    unsigned msg_flags;\n};\nenum { IPPROTO_ICMP = 1 };\nstruct sk_buff { };\nstatic inline __attribute__((always_inline)) struct dst_entry *\nskb_dst(const struct sk_buff *skb)\n{\n};\nenum nf_inet_hooks { NF_INET_LOCAL_OUT };\nstruct net_device {\n    unsigned mtu;\n};\nstatic inline __attribute__((always_inline)) int\nNF_HOOK_THRESH(uint8_t pf, unsigned int hook, struct sk_buff *skb,\n\t       struct net_device *in, struct net_device *out,\n\t       int (*okfn)(struct sk_buff *), int thresh)\n{\n  int ret = nf_hook_thresh(pf, hook, skb, in, out, okfn, thresh);\n  if (ret == 1)\n    ret = okfn(skb);\n  return ret;\n}\nstatic inline __attribute__((always_inline)) int\nNF_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,\n\tstruct net_device *in, struct net_device *out,\n\tint (*okfn)(struct sk_buff *))\n{\n  return NF_HOOK_THRESH(pf, hook, skb, in, out, okfn, (-((int)(~0U>>1)) - 1));\n}\nstruct dst_entry {\n    struct net_device *dev;\n    int (*output)(struct sk_buff*);\n};\nstatic inline __attribute__((always_inline)) int dst_output(struct sk_buff *skb) {\n    return skb_dst(skb)->output(skb);\n};\nstruct iphdr {\n    __u8 protocol;\n};\nstruct inet_sock {\n    __be16 inet_dport;\n    __u8 recverr: 1,     hdrincl: 1;\n    struct { } cork;\n};\nstruct icmphdr {\n    __u8 type;\n};\nstruct rtable {\n    union { struct dst_entry dst; } u;\n    __be32 rt_dst;\n};\nstruct sock;\nstruct inet_sock *inet_sk (struct sock *);\nstruct net *sock_net (struct sock *);\nvoid *skb_transport_header (struct sk_buff *);\nstatic int raw_send_hdrinc(struct sock *sk, void *from, size_t length,\n\t\t\t   struct rtable *rt,    unsigned int flags)\n{\n  struct inet_sock *inet = inet_sk(sk);\n  struct net *net = sock_net(sk);\n  struct iphdr *iph;\n  struct sk_buff *skb;\n  if (length > rt->u.dst.dev->mtu) \n    ip_local_error(sk, 90, rt->rt_dst, inet->inet_dport, rt->u.dst.dev->mtu);\n  if (flags&0x10)\n    goto out;\n  if (iph->protocol == IPPROTO_ICMP)\n    icmp_out_count(net, ((struct icmphdr *)skb_transport_header(skb))->type);\n  NF_HOOK(2, NF_INET_LOCAL_OUT, skb, ((void *)0), rt->u.dst.dev,\n\t  dst_output);\nout:\n  while (0);\n}\nint raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n{\n  raw_send_hdrinc(sk, msg->msg_iov, len, (void *)0, msg->msg_flags);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44063.c",
    "content": "typedef signed char int8_t;\ntypedef short int16_t;\ntypedef unsigned char uint8_t;\ntypedef unsigned int uint32_t;\n\nunion unaligned_32 {uint32_t l;} __attribute__((packed)) __attribute__((may_alias));\nstatic inline uint32_t NEG_USR32(uint32_t a, int8_t s){return a << (32 - s);}\ntypedef struct GetBitContext { const uint8_t *buffer, *buffer_end; int index;}GetBitContext;\ntypedef struct VLC {int16_t (*table)[2];} VLC;\nstatic __attribute__((always_inline)) inline int get_vlc2(GetBitContext *s, int16_t (*table)[2], int bits, int max_depth) {\n    unsigned int re_index= (s)->index;\n    int re_cache= 0;\n    {\n        int n, nb_bits;\n        unsigned int index;\n        index= NEG_USR32(re_cache, bits);\n        n = table[index][1];\n        if(max_depth > 1 && n < 0){\n            re_cache= bswap_32((((const union unaligned_32 *) (((const uint8_t *)(s)->buffer)+(re_index>>3)))->l)) << (re_index&0x07);\n        }\n    }\n}\ntypedef struct HYuvContext{GetBitContext gb; int decorrelate; int bitstream_bpp; uint8_t *temp[3]; VLC vlc[6];} HYuvContext;\nstatic __attribute__((always_inline)) inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){\n    int i;\n        int code = get_vlc2(&s->gb, s->vlc[3].table, 11, 1);\n        if(code != -1){\n            s->temp[0][4*i+0] = get_vlc2(&s->gb, s->vlc[0].table, 11, 3);\n            s->temp[0][4*i+1] = get_vlc2(&s->gb, s->vlc[1].table, 11, 3);\n            s->temp[0][4*i+2] = get_vlc2(&s->gb, s->vlc[2].table, 11, 3);\n        }\n}\nvoid decode_bgr_bitstream(HYuvContext *s, int count){\n    if(s->decorrelate){\n        if(s->bitstream_bpp==24) decode_bgr_1(s, count, 1, 0);\n        else             decode_bgr_1(s, count, 1, 1);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44119.c",
    "content": "typedef signed char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\ntypedef unsigned int uint32_t;\nstatic int8_t\nsafe_mul_func_int16_t_s_s (int16_t si1, int8_t si2)\n{\n  return si1 && si2 && si1 > +si2 || si1 && si2 && si2 < +si1 || si1 && si2\n    && si1 < +si2 || si1 && si2 && si1 && si2 < +si1 ? : si1 * si2;\n}\n\nstruct S0\n{\n};\nint32_t g_72[7][4][1];\nint32_t *g_184 = &g_72[1][2][0];\nint32_t **g_224 = &g_184;\nstruct S0 g_244 = {\n};\n\nint8_t *\nfunc_96 (int8_t p_97, uint32_t p_98, uint32_t p_99)\n{\n  struct S0 *l_243 = &g_244;\n  int i;\n  for (i = 0; i < 1; p_98 = 1)\n    {\n      int32_t *l_202[3];\n      int i;\n      for (i = 0; i < 1; i++)\n        l_202[i] = &g_72[2][2][0];\n      if (safe_mul_func_int16_t_s_s (0xCAF0, **g_224))\n        {\n          if (p_98 && &l_243)\n            {\n            }\n          else\n            *g_224 = l_202[0];\n          for (0;; 1)\n            {\n            }\n        }\n    }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44197.c",
    "content": "/* { dg-require-alias \"\" } */\n/* { dg-require-visibility \"\" } */\n\n#ifndef __USER_LABEL_PREFIX__\n#define PREFIX \"\"\n#else\n#define xstr(s) str(s)\n#define str(s)  #s\n#define PREFIX  xstr(__USER_LABEL_PREFIX__)\n#endif\n\ntypedef unsigned short int __uint16_t;\nenum\n{\n  _ISupper = (1 << (0)), _ISlower = (1 << (1)), _ISalpha =\n    (1 << (2)), _ISdigit = (1 << (3)), _ISxdigit = (1 << (4)), _ISspace =\n    (1 << (5)), _ISprint = (1 << (6)), _ISgraph = (1 << (7)), _ISblank =\n    (1 << (8)), _IScntrl = (1 << (9)), _ISpunct = (1 << (10)), _ISalnum =\n    (1 << (11))\n};\ntypedef __uint16_t __ctype_mask_t;\nextern const __ctype_mask_t *__C_ctype_b;\nextern\n__typeof (__C_ctype_b)\n   __C_ctype_b __asm__ (PREFIX \"__GI___C_ctype_b\")\n  __attribute__ ((visibility (\"hidden\")));\n     static const __ctype_mask_t __C_ctype_b_data[] = {\n     };\n\nconst __ctype_mask_t *__C_ctype_b = __C_ctype_b_data + 128;\nextern\n__typeof (__C_ctype_b)\n     __EI___C_ctype_b __attribute__ ((alias (\"\" \"__GI___C_ctype_b\")));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44246.c",
    "content": "int main(int argc, char *argv[])\n{\n  strcat(argv[0], \"X\");\n  return strlen(argv[0]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44686.c",
    "content": "/* { dg-require-profiling \"-fprofile-generate\" } */\n/* { dg-options \"-fipa-pta -fprofile-generate\" } */\nvoid *\nmemcpy (void *a, const void *b, __SIZE_TYPE__ len)\n{\n  if (a == b)\n    __builtin_abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44687.c",
    "content": "typedef int int32_t;\ntypedef unsigned char uint8_t;\nstruct S0\n{\n  uint8_t f0;\n};\nstruct S0 *g_18[7][5][1][1] = {\n};\n\nstruct S0 **g_17 = &g_18[0][3][0][0];\nint32_t g_86;\nstruct S0 func_72 (uint8_t p_73, struct S0 p_74);\n\nvoid\nint326 (struct S0 **p_67, int32_t p_68, int32_t * *const p_69,\n\tstruct S0 *p_70)\n{\n  struct S0 l_95 = {\n    -1L\n  };\n  func_72 (1L, func_72 (0, l_95));\n}\n\nstruct S0\nfunc_72 (uint8_t p_73, struct S0 p_74)\n{\n  int32_t *l_85 = &g_86;\n  if (*l_85)\n  lbl_94:*l_85 ^= 0;\n  if (g_86)\n    goto lbl_94;\n  return **g_17;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44707.c",
    "content": "/* { dg-do compile { target powerpc-ibm-aix* } } */\n\nextern struct { int a, b, c, d; } v;\nextern int w;\n\nvoid\nfoo (void)\n{\n  int e1 = v.a;\n  int e2 = w;\n  int e3 = v.b;\n  int e4 = v.c;\n  int e5 = v.d;\n  __asm__ volatile (\"\" : : \"nro\" (e1), \"nro\" (e2), \"nro\" (e3), \"nro\" (e4), \"nro\" (e5));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44784.c",
    "content": "typedef struct rtx_def *rtx;\nenum rtx_code { SUBREG };\ntypedef union rtunion_def {\n    long rtint;\n    unsigned long rtuint;\n    rtx rtx;\n} rtunion;\nstruct rtx_def {\n    enum rtx_code code: 8;\n    rtunion fld[1];\n};\ntypedef struct simple_bitmap_def {\n    unsigned long long elms[1];\n} *sbitmap;\nstruct df_link {\n    struct df_link *next;\n    rtx reg;\n};\ntypedef enum { UNDEFINED,   CONSTANT,   VARYING } latticevalue;\ntypedef struct {\n    latticevalue lattice_val;\n} value;\nstatic value *values;\nstatic sbitmap ssa_edges;\nvoid defs_to_varying (struct df_link *start)\n{\n  struct df_link *currdef;\n  for (currdef = start;\n       currdef;\n       currdef = currdef->next)\n    {\n      rtx reg = currdef->reg;\n      if (values[(reg->code == SUBREG\n\t\t  ? reg->fld[0].rtx\n\t\t  : reg)->fld[0].rtuint].lattice_val != VARYING)\n\tssa_edges->elms [(reg->code == SUBREG\n\t\t\t  ? reg->fld[0].rtx\n\t\t\t  : reg)->fld[0].rtuint / 64]\n\t    |= ((unsigned long long) 1\n\t\t<< (reg->code == SUBREG\n\t\t    ? reg->fld[0].rtx\n\t\t    : reg)->fld[0].rtuint % 64);\n      values[(reg->code == SUBREG\n\t      ? reg->fld[0].rtx\n\t      : reg)->fld[0].rtuint].lattice_val = VARYING;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44788.c",
    "content": "void joint_decode(float* mlt_buffer1, int t) {\n    int i;\n    float decode_buffer[1060];\n    foo(decode_buffer);\n    for (i=0; i<10 ; i++) {\n        mlt_buffer1[i] = i * decode_buffer[t];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44831.c",
    "content": "typedef unsigned char UCHAR, *PUCHAR;\ntypedef void *HANDLE;\ntypedef struct _NCB {\n    UCHAR ncb_reserve[10];\n} NCB, *PNCB;\nstruct NBCmdQueue {\n    PNCB head;\n};\nPNCB *NBCmdQueueFindNBC(struct NBCmdQueue *queue, PNCB ncb)\n{\n  PNCB *ret = &queue->head;\n  while (ret && *ret != ncb)\n    ret = (PNCB *)((*ret)->ncb_reserve + sizeof(HANDLE));\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44891.c",
    "content": "struct S\n{\n  float f;\n  long l;\n};\n\nextern int gi;\nextern float gf;\n\nlong foo (long p)\n{\n  struct S s;\n  float *pf;\n\n  s.l = p;\n\n  pf = &s.f;\n\n  pf++;\n  pf--;\n\n  gf = *pf + 3.3;\n  gi = *((int *)pf) + 2;\n\n  return s.l + 6;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44937.c",
    "content": "int g_19;\nint *g_42;\nint **volatile g = &g_42;\nint g_67[5][9][2][1] = {\n};\n\nint\nfunc_4 (int p_5, unsigned char p_6, unsigned char p_7)\n{\n  unsigned char l_8[1];\n  if (p_6)\n    goto lbl_13;\n  for (p_6 = 0; p_6; p_6 = (p_6, 0))\n    if (0)\n      {\n      }\n    else\n      lbl_13:for (p_6 = 0; p_6 < 1; p_6 += 1)\n\t  l_8[p_6] = 0;\n  return 0;\n}\n\nint *\nfunc_45 (unsigned long p_46, unsigned char p_47)\n{\n  int *l_56 = &g_19;\n  (void *)&l_56 != (void *)&g | !1 == func_4 (0, g_67[2][6][1][0], 0) ^ func_4 (1, 0, 0);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44941.c",
    "content": "struct S { };\n\nextern void bar(struct S);\n\nvoid foo (int i)\n{\n  bar (*(struct S *)&i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44946.c",
    "content": "struct A\n{\n  int i;\n  long l;\n};\n\nstruct B\n{\n  int i;\n};\n\nstruct C\n{\n  int i;\n  struct B b;\n};\n\nstruct B foo (struct A a)\n{\n  struct C *c = (struct C *) &a;\n  return c->b;\n}\nvoid bar (struct A a, struct B b)\n{\n  struct C *c = (struct C *) &a;\n  c->b = b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr44988.c",
    "content": "struct S\n{\n  int i;\n};\n\nextern void bar (struct S);\n\nvoid\nfoo (void)\n{\n  int i = 0;\n  bar (*(struct S *) &i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45047.c",
    "content": "/* PR tree-optimization/45047 */\n\nvoid\nfoo (const unsigned short *w, char *x, int y, int z)\n{\n  int i;\n  for (i = 0; i < y; i++)\n    x[i] = w[i] == z;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45059.c",
    "content": "/* PR tree-optimization/45059 */\n\ntypedef unsigned int T;\nextern void foo (signed char *, int);\n\nstatic signed char a;\nstatic T b[1] = { -1 };\nstatic unsigned char c;\n\nstatic inline short int\nbar (short v)\n{\n  c |= a < b[0];\n  return 0;\n}\n\nint\nmain ()\n{\n  signed char *e = &a;\n  foo (e, bar (bar (c)));\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45109.c",
    "content": "struct o_fsm_t;\nstruct o_fsm_event_t;\n\ntypedef void (*fn_t) (struct o_fsm_t *,\n\t\t      struct o_fsm_event_t const *);\n\nstruct o_fsm_state_t {\n    fn_t dispatch;\n};\n\nstruct o_fsm_t {\n    fn_t dispatch;\n};\n\nextern struct o_fsm_state_t o_fsm_tran(struct o_fsm_t *fsm,\n\t\t\t\t       struct o_fsm_state_t next_state);\nstatic void plist_parser_state_start(struct o_fsm_t *fsm,\n\t\t\t\t     struct o_fsm_event_t const *fsm_event);\n\nstruct o_fsm_state_t o_fsm_state(fn_t dispatch_fcn)\n{\n  return *(struct o_fsm_state_t *)&dispatch_fcn;\n}\n\ntypedef struct _o_plist_parser_t {\n    struct o_fsm_t fsm;\n} o_plist_parser_t;\n\nstatic void plist_parser_state_start(struct o_fsm_t *fsm,\n\t\t\t\t     struct o_fsm_event_t const *fsm_event)\n{\n}\n\nvoid o_plist_deserialize_xml(int fin)\n{\n  o_plist_parser_t parser;\n  o_fsm_tran(&parser.fsm, o_fsm_state(plist_parser_state_start));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45182.c",
    "content": "typedef struct TypHeader {\n  struct TypHeader ** ptr;\n} *TypHandle;\nvoid PlainRange (TypHandle hdList, long lenList, long low, long inc)\n{\n  long i;\n  for (i = 1; i <= lenList; i++ )\n    (((TypHandle*)((hdList)->ptr))[i] = (((TypHandle) (((long)(low + (i-1) *\ninc) << 2) + 1))));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45412.c",
    "content": "extern void baz (int, int, int);\n\nint j;\n\nint\nbar (void)\n{\n  int n = 0, *np = &n;\n  if (j)\n    baz (0, 0, 0);\n  if (j)\n    baz (0, 0, 0);\n  return n;\n}\n\nvoid\nfoo (void)\n{\n  bar ();\n  bar ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45535.c",
    "content": "typedef struct {\n    unsigned long pmd0;\n    unsigned long pmd1;\n} pmd_t;\ntypedef unsigned int pgd_t;\nstruct mm_struct {\n    pgd_t * pgd;\n};\nextern inline int pmd_bad(pmd_t pmd)\n{\n}\nextern inline void pmd_clear(pmd_t * pmdp)\n{\n  ((*pmdp).pmd0) = 0x20 | 0x00;\n  ((*pmdp).pmd1) = 0x20 | 0x00;\n}\nstatic inline void free_one_pmd(pmd_t * dir)\n{\n  if (pmd_bad(*dir)) {\n      pmd_clear(dir);\n  }\n}\nstatic inline void free_one_pgd(pgd_t * dir)\n{\n  int j;\n  pmd_t * pmd;\n  pmd = ((pmd_t *) ((unsigned long) (void *)(__pgd_val(dir) & (~((1UL << 12)-1)))) + (((0) >> 21) & (512 - 1)));\n  for (j = 0; j < 512 ; j++) {\n      free_one_pmd(pmd+j);\n  }\n}\nvoid clear_page_tables(struct mm_struct *mm, unsigned long first, int nr)\n{\n  pgd_t * page_dir = mm->pgd;\n  do {\n      free_one_pgd(page_dir);\n  } while (--nr);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45728.c",
    "content": "/* PR rtl-optimization/45728 */\n\nunion U\n{\n  int *m;\n  double d;\n};\n\nint i;\nunion U u;\n\nint\nfoo (void)\n{\n  union U v = { &i };\n  return u.d == v.d;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45771.c",
    "content": "static const int data[2048];\n\nvoid foo (void *ptr)\n{\n  __builtin_memcmp (data, ptr, 1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45876.c",
    "content": "/* PR middle-end/45876 */\n\nunsigned\nfoo (unsigned x)\n{\n  short i = 0;\n  i = ((short) (((((unsigned) i) >> 1) & 16383) + x)) & 16383;\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45919.c",
    "content": "/* PR tree-optimization/45919 */\n\nconst struct S { int a; int b[]; } s = { 0, { 0 }};\n\nint\nfoo (void)\n{\n  return s.b[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr45969-1.c",
    "content": "/* { dg-options \"-std=c89\" } */\nvoid crash() {\n    double l[4];\n    if((l[0]+l[2]) && (l[1]+l[3])){\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46002.c",
    "content": "/* { dg-options \"-fira-algorithm=priority\" } */\nchar **\nfoo (char **p, char *cmp, unsigned i)\n{\n  for (; *p; p++)\n    if (__builtin_strncmp (*p, cmp, i))\n      if (i == __builtin_strlen (*p))\n\tbreak;\n  return p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46034.c",
    "content": "/* PR rtl-optimization/46034 */\n\nvoid bar (int);\n\nvoid\nfoo (int x, int y)\n{\n  int i;\n  for (i = 0; i < x; i++)\n    {\n      y = __builtin_abs (y);\n      bar (y / 2);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46107.c",
    "content": "/* PR tree-optimization/46107 */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nint foo (void) __attribute__ ((noreturn));\n\nvoid\nbar (int x, int *y, int z)\n{\n  static void *j[] = { &&l1, &&l2 };\nl1:\n  if (*y)\n    goto *j[z];\n  foo ();\nl2:\n  *y ^= (x & 1) ? -1 : 0;\n  goto *j[x];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46248.c",
    "content": "/* PR rtl-optimization/46248 */\n\nstruct S\n{\n  int s;\n};\n\nvoid\nfoo (unsigned char *x, int y, struct S *z)\n{\n  const int l1 = y;\n  const int l2 = y + l1;\n  const int l3 = y + l2;\n  const int l4 = y + l3;\n  const int l5 = y + l4;\n  const int l6 = y + l5;\n  const int l7 = y + l6;\n  int i;\n  for (i = 0; i < 8; i++)\n    {\n      int a = x[l3] - x[l4];\n      int b = x[l4] - x[l5];\n      int c = x[l5] - x[l6];\n      int d = (b >= 0 ? b : -b) - (((a >= 0 ? a : -a) + (c >= 0 ? c : -c)) >> 1);\n      if (d < z->s * 2)\n\t{\n\t  int v = d * (-b > 0 ? 1 : -1);\n\t  x[l2] += v >> 3;\n\t  x[l7] -= v >> 3;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46360.c",
    "content": "/* PR middle-end/46360 */\n\n__attribute__((gnu_inline, always_inline)) extern inline char *\nstrncpy (char *dest, const char *src, __SIZE_TYPE__ len)\n{\n  return __builtin_strncpy (dest, src, len);\n}\n\nvoid\nfoo (char *s)\n{\n  strncpy (s, \"\", 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46388.c",
    "content": "/* PR middle-end/46388 */\n\nstruct S;\nstruct T\n{\n  struct S *t;\n};\nextern struct S s, u;\n\nvoid\nfoo (void)\n{\n  ((struct T *) &u)->t = &s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46461.c",
    "content": "/* PR tree-optimization/46461 */\n\nvoid\nfoo (char *c)\n{\n  c[7] = 0xff;\n  __builtin_memset (c + 8, 0xff, 8);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46534.c",
    "content": "/* { dg-skip-if \"too big\" { avr-*-* nvptx-*-* pdp11-*-* } { \"*\" } { \"\" } } */\n/* PR middle-end/46534 */\n\nextern int printf (const char *, ...);\n\n#define S1 \"                    \"\n#define S2 S1 S1 S1 S1 S1 S1 S1 S1 S1 S1\n#define S3 S2 S2 S2 S2 S2 S2 S2 S2 S2 S2\n#define S4 S3 S3 S3 S3 S3 S3 S3 S3 S3 S3\n#define S5 S4 S4 S4 S4 S4 S4 S4 S4 S4 S4\n#define S6 S5 S5 S5 S5 S5 S5 S5 S5 S5 S5\n#define S7 S6 S6 S6 S6 S6 S6 S6 S6 S6 S6\n\nvoid\nfoo (void)\n{\n  printf (S7 \"\\n\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46547-1.c",
    "content": "void foo (void) {\n  _Bool d;\n  long double _Complex *s;\n\n  d = *s++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46637.c",
    "content": "/* PR middle-end/46637 */\n\nstruct S { int s[5]; } *p;\n\nvoid\nfoo (long x)\n{\n  long a = x == 1 ? 4L : 1L;\n  asm (\"\" : \"+m\" (p->s[a]));\n  p->s[0]++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46832.c",
    "content": "double pow(double x, double y);\nvoid foo( double x ) {\n   int j = (int) ((pow(x, 2)) < 0.0 ? (pow(x, 2))-0.5 : (pow(x, 2))+0.5);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46856.c",
    "content": "struct data {\n    int prio;\n    signed char status;\n};\n\nstruct base {\n    unsigned _num;\n    struct data vec[10];\n};\n\nstatic struct data *ix(struct base *base, unsigned i)\n{\n    return &base->vec[i];\n}\n\nstruct heap {\n    struct base base;\n};\n\nstruct heap *heap;\n\nvoid increase_insn_priority (int *fld, int amount)\n{\n    if (ix(heap ? &heap->base : 0, *fld)->status > 0)\n\tix(heap ? &heap->base : 0, *fld)->prio += amount;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46866.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\ntypedef struct T T;\nstruct T {\n    void (*destroy)(void *);\n};\nvoid destroy(union { void *this; } __attribute__((transparent_union)));\nstatic const typeof(destroy) *_destroy  = (const typeof(destroy)*)destroy;\nvoid destroy(void *this);\nstatic T *create_empty(void)\n{\n  T *this = malloc(sizeof(*this));\n  *this = (typeof(*this)){ _destroy };\n  return this;\n}\nvoid openssl_crl_load(void)\n{\n  T *this = create_empty();\n  destroy(this);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46883.c",
    "content": "void bar (unsigned char *q, unsigned short *data16s, int len)\n{\n  int i;\n\n  for (i = 0; i < len; i++)\n    {\n      q[2 * i] =\n        (((data16s[i] & 0xFF) << 8) | ((data16s[i] >> 8) & 0xFF)) & 0xFF;\n      q[2 * i + 1] =\n        ((unsigned short)\n         (((data16s[i] & 0xFF) << 8) | ((data16s[i] >> 8) & 0xFF))) >> 8;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr46934.c",
    "content": "int caller (unsigned int reg_type)\n{\n  switch (reg_type)\n    {\n    case 0x80000000:\n      return (int)foo();\n\n    case 0x80000003:\n      return (int) bar();\n\n    case 0x80000001:\n      return (int) baz();\n\n    case 0x80000004:\n      return (int) fooz();\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47140.c",
    "content": "/* PR tree-optimization/47140 */\n\nstatic inline int\nfoo (int x, short y)\n{\n  return y == 0 ? x : x + y;\n}\n\nstatic inline unsigned short\nbar (unsigned short x, unsigned char y)\n{\n  return x - y;\n}\n\nint w;\n\nint baz (void);\n\nint\ntest (void)\n{\n  int i;\n  for (i = 0; i < 50; i++)\n    w += foo ((unsigned char) (1 + baz ()) >= bar (0, 1), 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47141.c",
    "content": "int\nfoo (__UINTPTR_TYPE__ x)\n{\n  int a = 6;\n  int *b = &a;\n  if (x)\n    for (a = 0; a; a++)\n      ;\n  return a;\n}\n\nvoid\nbar (void)\n{\n  foo ((__UINTPTR_TYPE__) foo);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47150.c",
    "content": "/* PR c/47150 */\n\nfloat _Complex foo (float, float);\n\nvoid\nbar ()\n{\n  float w = 2;\n  float _Complex b;\n  b = 0.5 * (foo (0, w) + foo (1, w) / w);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47157.c",
    "content": "/* PR rtl-optimization/47157 */\n\nstruct S { unsigned a; unsigned b; } c = { 1, 0 };\nunsigned long int e;\nvoid bar (int);\nint baz (void);\n\nstatic int\nfoo (int x, short y)\n{\n  return ((x ^ y) & ((x ^ (x ^ y) & ~__INT_MAX__) - y ^ y)) < 0 ? x : x - y;\n}\n\nvoid\ntest (void)\n{\n  bar (foo (baz () != (c.a | c.b), -1L));\n  for (e = 0; e; e = 1)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47265.c",
    "content": "/* PR tree-optimization/47265 */\n\nstruct S\n{\n  char a[3];\n  char b[3];\n};\n\nvoid\nbar (char *dst, const char *src, unsigned n)\n{\n  while (n--)\n    *dst++ = *src ? *src++ : ' ';\n}\n\nvoid\nfoo (struct S *s)\n{\n  bar (s->a, s->b, 3);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47364-1.c",
    "content": "static unsigned char foo[256];\n\narc4_init(void)\n{\n  int n;\n\n  for (n = 0; n < 256; n++)\n    foo[n] = n;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47364-2.c",
    "content": "extern __SIZE_TYPE__ strlen (const char *);\nvoid foo (char *, const char *);\nint bar (const char *prefix)\n{\n    char buff[256];\n    foo (buff, prefix);\n    return strlen(buff);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47427.c",
    "content": "/* PR tree-optimization/47427 */\n\nchar *g, *h;\n\nint\nbar (unsigned char x, const int y)\n{\nlab:\n  for (; h; g = h)\n    for (g = 0; h; h++)\n      {\n\tint a = 1;\n\tif (h)\n\t  {\n\t    if (a)\n\t      goto lab;\n\t    return y;\n\t  }\n      }\n  return x;\n}\n\nvoid\nfoo (void)\n{\n  if (bar (0, 1))\n    bar (1, 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47428.c",
    "content": "/* PR tree-optimization/47428 */\n/* { dg-require-effective-target untyped_assembly } */\n\nstruct S\n{\n  int s;\n} a;\nint b;\n\nvoid bar (struct S);\n\nint\nbaz (int x __attribute__((unused)), int y)\n{\n  int i;\n  for (i = 0; i < 1; i = 1)\n    for (y = 0; y < 1; y = 1);\n  return y;\n}\n\nvoid\nfoo (void)\n{\n  fn (0);\n}\n\nint\nfn (const int x, int y __attribute__((unused)))\n{\n  if (baz (baz (0, x), 0))\n    return 0;\n  else\n    bar (a);\n  return 0;\n}\n\nvoid\nbar (struct S x)\n{\n  for (;;)\n    for (; x.s;)\n      b = 0 ? : baz (0, 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr47967.c",
    "content": "/* PR tree-optimization/47967 */\n/* { dg-require-effective-target untyped_assembly } */\n\nextern void abort (void);\nstatic void bar ();\n\nvoid\nfoo ()\n{\n  bar (1);\n}\n\nstatic void\nbar (double i)\n{\n  if (i)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48136.c",
    "content": "/* PR middle-end/48136 */\n\nint\nfoo (int x, int y)\n{\n  return (x ^ 5U) == (y ^ 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48161.c",
    "content": "/* PR bootstrap/48161 */\n\nstruct T { int u; };\nstruct G { int l; int t; int r; };\nstruct V { struct G v[10]; };\nstruct { struct V b; } *h;\nvoid bar (void);\n\nstruct G *\nbaz (struct V *x, unsigned y)\n{\n  return &x->v[y];\n}\n\nint\nfoo (struct T *x, struct T *y)\n{\n  if ((baz (&h->b, y->u)->t ? baz (&h->b, y->u)->t : 0)\n      - baz (h ? &h->b : 0, x->u)->r\n      - (baz (h ? &h->b : 0, x->u)->t > 0 ? 5 : 0))\n    return 1;\n  bar ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48305.c",
    "content": "/* PR c/48305 */\n\nint\nfoo (int x)\n{\n  return (x ^ 1) == (x ^ 1U);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48335-1.c",
    "content": "/* PR middle-end/48335 */\n\nstruct S { float d; };\n\nvoid bar (struct S);\n\nvoid\nf0 (int x)\n{\n  struct S s = {.d = 0.0f };\n  ((char *) &s.d)[0] = x;\n  s.d *= 7.0;\n  bar (s);\n}\n\nvoid\nf1 (int x)\n{\n  struct S s = {.d = 0.0f };\n  ((char *) &s.d)[1] = x;\n  s.d *= 7.0;\n  bar (s);\n}\n\nvoid\nf2 (int x)\n{\n  struct S s = {.d = 0.0f };\n  ((char *) &s.d)[2] = x;\n  s.d *= 7.0;\n  bar (s);\n}\n\nvoid\nf3 (int x)\n{\n  struct S s = {.d = 0.0f };\n  ((char *) &s.d)[3] = x;\n  s.d *= 7.0;\n  bar (s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48381.c",
    "content": "/* PR rtl-optimization/48381 */\n\nstruct S { int s; } t;\n\nint baz (void);\nvoid fn (int, unsigned, int, unsigned, char);\n\nstatic char\nfoo (signed x, unsigned y)\n{\n  return x < 0 || y >= 32 ? 1 : x >> y;\n}\n\nlong long\nbar (long long x, long y)\n{\n  return y < 0 ? 1LL : x - y;\n}\n\nvoid\ntest (int x, unsigned y, unsigned z, char w)\n{\n  unsigned v[2];\n  fn (w || baz (), y, t.s, y, foo (bar (z, w) <= v[0], x));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48517.c",
    "content": "/* PR c/48517 */\n/* { dg-do compile } */\n/* { dg-options \"-std=gnu89\" } */\n\nvoid bar (const unsigned short *);\n\nvoid\nfoo (void)\n{\n  static const unsigned short array[] = (const unsigned short []) { 0x0D2B };\n  const unsigned short *ptr = array;\n  bar (ptr);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48596.c",
    "content": "/* PR target/48596  */\nenum { nrrdCenterUnknown, nrrdCenterNode, nrrdCenterCell, nrrdCenterLast };\ntypedef struct { int size; int center; }  NrrdAxis;\ntypedef struct { int dim; NrrdAxis axis[10]; } Nrrd;\ntypedef struct { } NrrdKernel;\ntypedef struct { const NrrdKernel *kernel[10]; int samples[10]; } Info;\n\nvoid\nfoo (Nrrd *nout, Nrrd *nin, const NrrdKernel *kernel, const double *parm,\n     const int *samples, const double *scalings)\n{\n  Info *info;\n  int d, p, np, center;\n  for (d=0; d<nin->dim; d++)\n    {\n      info->kernel[d] = kernel;\n      if (samples)\n\tinfo->samples[d] = samples[d];\n      else\n\t{\n\t  center = _nrrdCenter(nin->axis[d].center);\n\t  if (nrrdCenterCell == center)\n\t    info->samples[d] = nin->axis[d].size*scalings[d];\n\t  else\n\t    info->samples[d] = (nin->axis[d].size - 1)*scalings[d] + 1;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48641.c",
    "content": "/* { dg-options \"-O -fno-tree-ccp -fno-tree-copy-prop\" } */\n#define CSF __builtin_copysignf\n#define CSD __builtin_copysign\n#define CSL __builtin_copysignl\n#define MODFF __builtin_modff\n#define MODFD __builtin_modf\n#define MODFL __builtin_modfl\n\nextern void link_error (void);\n\nvoid\nfoo (void)\n{\n  float iptrf;\n  double iptr;\n  long double iptrl;\n  long long iptrll;\n  if ((CSF (1.0F, MODFF (0x1p10F + 0.5f, &iptrf)) != CSF (1.0F, 0.5f))\n      || (CSF (1.0F, iptrf) != 0x1p10f))\n    link_error ();\n  if (MODFD (0x1p10F + 0.5, &iptr) != 0.5\n      || (CSD (1.0, MODFD (0x1p10F + 0.5, &iptr)) != CSD (1.0, 0.5))\n      || (CSD (1.0, iptr) != CSD (1.0, 0x1p10)))\n    link_error ();\n  if (MODFL (0x1p10F + 0.5l, &iptrl) != 0.5l\n      || (CSL (1.0L, MODFL (0x1p10F + 0.5l, &iptrl)) != CSL (1.0L, 0.5l))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0x1p10l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (0x1p10F + 0x1p-10f, &iptrf)))\n       != CSF (1.0F, 0x1p-10f))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 0x1p10f)))\n    link_error ();\n  if (MODFD (0x1p10F + 0x1p-10, &iptr) != 0x1p-10\n      || (CSD (1.0, (MODFD (0x1p10F + 0x1p-10, &iptr)))\n\t  != CSD (1.0, 0x1p-10)) || (CSD (1.0, iptr) != CSD (1.0, 0x1p10)))\n    link_error ();\n  if (MODFL (0x1p10F + 0x1p-10l, &iptrl) != 0x1p-10l\n      || (CSL (1.0L, (MODFL (0x1p10F + 0x1p-10l, &iptrl)))\n\t  != CSL (1.0L, 0x1p-10l))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0x1p10l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (12345678L / 17.0f, &iptrf)))\n       != CSF (1.0F, (-726216L + 12345678L / 17.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 726216.0f)))\n    link_error ();\n  if (MODFD (12345678L / 17.0, &iptr) != -726216L + 12345678L / 17.0\n      || (CSD (1.0, (MODFD (12345678L / 17.0, &iptr)))\n\t  != CSD (1.0, (-726216L + 12345678L / 17.0)))\n      || (CSD (1.0, iptr) != CSD (1.0, 726216.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (12345678L / 17.0l, &iptrl)))\n       != CSL (1.0L, (-726216L + 12345678L / 17.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 726216.0l)))\n    link_error ();\n  if (MODFF (555.555f, &iptrf) != -555 + 555.555f\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 555.0f)))\n    link_error ();\n  if (MODFD (555.555, &iptr) != -555 + 555.555\n      || (CSD (1.0, (MODFD (555.555, &iptr))) != CSD (1.0, (-555 + 555.555)))\n      || (CSD (1.0, iptr) != CSD (1.0, 555.0)))\n    link_error ();\n  if (MODFL (555.555l, &iptrl) != -555 + 555.555l\n      || (CSL (1.0L, (MODFL (555.555l, &iptrl)))\n\t  != CSL (1.0L, (-555 + 555.555l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 555.0l)))\n    link_error ();\n  if (MODFF (5000 / 11.0f, &iptrf) != -454 + 5000 / 11.0f\n      || (CSF (1.0F, (MODFF (5000 / 11.0f, &iptrf)))\n\t  != CSF (1.0F, (-454 + 5000 / 11.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 454.0f)))\n    link_error ();\n  if (MODFD (5000 / 11.0, &iptr) != -454 + 5000 / 11.0\n      || (CSD (1.0, (MODFD (5000 / 11.0, &iptr)))\n\t  != CSD (1.0, (-454 + 5000 / 11.0)))\n      || (CSD (1.0, iptr) != CSD (1.0, 454.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (5000 / 11.0l, &iptrl)))\n       != CSL (1.0L, (-454 + 5000 / 11.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 454.0l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (1000 / 7.0f, &iptrf)))\n       != CSF (1.0F, (-142 + 1000 / 7.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 142.0f)))\n    link_error ();\n  if ((CSD (1.0, (MODFD (1000 / 7.0, &iptr)))\n       != CSD (1.0, (-142 + 1000 / 7.0)))\n      || (CSD (1.0, iptr) != CSD (1.0, 142.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (1000 / 7.0l, &iptrl)))\n       != CSL (1.0L, (-142 + 1000 / 7.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 142.0l)))\n    link_error ();\n  if (MODFF (123 / 7.0f, &iptrf) != -17 + 123 / 7.0f\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 17.0f)))\n    link_error ();\n  if (MODFD (123 / 7.0, &iptr) != -17 + 123 / 7.0\n      || (CSD (1.0, iptr) != CSD (1.0, 17.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (123 / 7.0l, &iptrl)))\n       != CSL (1.0L, (-17 + 123 / 7.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 17.0l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (117 / 7.0f, &iptrf)))\n       != CSF (1.0F, (-16 + 117 / 7.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 16.0f)))\n    link_error ();\n  if ((CSD (1.0, (MODFD (117 / 7.0, &iptr))) != CSD (1.0, (-16 + 117 / 7.0)))\n      || (CSD (1.0, iptr) != CSD (1.0, 16.0)))\n    link_error ();\n  if (MODFL (117 / 7.0l, &iptrl) != -16 + 117 / 7.0l\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 16.0l)))\n    link_error ();\n  if (MODFF (5.5f, &iptrf) != 0.5f || (CSF (1.0F, iptrf) != CSF (1.0F, 5.0f)))\n    link_error ();\n  if (MODFD (5.5, &iptr) != 0.5 || (CSD (1.0, iptr) != CSD (1.0, 5.0)))\n    link_error ();\n  if (MODFL (5.5l, &iptrl) != 0.5l || (CSL (1.0L, iptrl) != CSL (1.0L, 5.0l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (1.5f, &iptrf))) != CSF (1.0F, 0.5f))\n      || (CSF (1.0F, iptrf) != 1.0f))\n    link_error ();\n  if ((CSD (1.0, (MODFD (1.5, &iptr))) != CSD (1.0, 0.5))\n      || (CSD (1.0, iptr) != 1.0))\n    link_error ();\n  if (MODFL (1.5l, &iptrl) != iptrl != 1.0l || (CSL (1.0L, iptrl) != 1.0l))\n    link_error ();\n  if (MODFF (4 / 3.0f, &iptrf) != -1 + 4 / 3.0f\n      || (CSF (1.0F, (MODFF (4 / 3.0f, &iptrf)))\n\t  != CSF (1.0F, (-1 + 4 / 3.0f))) || (CSF (1.0F, iptrf) != (1.0F)))\n    link_error ();\n  if (MODFD (4 / 3.0, &iptr) != -1 + 4 / 3.0 || (CSD (1.0, iptr) != 1.0))\n    link_error ();\n  if (MODFL (4 / 3.0l, &iptrl) != iptrl != 1.0l\n      || (CSL (1.0L, iptrl) != 1.0l))\n    link_error ();\n  if ((((MODFF (1.0f, &iptrf)))) || (CSF (1.0F, iptrf) != 1.0f))\n    link_error ();\n  if ((((MODFD (1.0, &iptr))) != 0.0) || (CSD (1.0, iptr) != 1.0))\n    link_error ();\n  if ((((MODFL (1.0l, &iptrl))) != 0.0l) || (CSL (1.0L, iptrl) != 1.0l))\n    link_error ();\n  if (MODFF (0.5f, &iptrf) != 0.5f || (CSF (1.0F, iptrf) != CSF (1.0F, 0.0f)))\n    link_error ();\n  if (MODFD (0.5, &iptr) != 0.5 || (CSD (1.0, iptr) != CSD (1.0, 0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (0.5l, &iptrl))) != CSL (1.0L, 0.5l))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0.0l)))\n    link_error ();\n  if (MODFF (4 / 9.0f, &iptrf) != 4 / 9.0f\n      != (CSF (1.0F, (MODFF (4 / 9.0f, &iptrf))) != CSF (1.0F, (4 / 9.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 0.0f)))\n    link_error ();\n  if (MODFD (4 / 9.0, &iptr) != 4 / 9.0\n      || (CSD (1.0, iptr) != CSD (1.0, 0.0)))\n    link_error ();\n  if (MODFL (4 / 9.0l, &iptrl) != 4 / 9.0l\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0.0l)))\n    link_error ();\n  if (MODFF (1 / 3.0f, &iptrf) != 1 / 3.0f\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 0.0f)))\n    link_error ();\n  if (MODFD (1 / 3.0, &iptr) != 1 / 3.0\n      || (CSD (1.0, iptr) != CSD (1.0, 0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (1 / 3.0l, &iptrl))) != CSL (1.0L, (1 / 3.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0.0l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (1 / 9.0f, &iptrf))) != CSF (1.0F, (1 / 9.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, 0.0f)))\n    link_error ();\n  if (MODFD (1 / 9.0, &iptr) != 1 / 9.0\n      || (CSD (1.0, iptr) != CSD (1.0, 0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (1 / 9.0l, &iptrl))) != CSL (1.0L, (1 / 9.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0.0l)))\n    link_error ();\n  if ((((MODFF (0.0f, &iptrf)))) || (CSF (1.0F, iptrf) != CSF (1.0F, 0.0f)))\n    link_error ();\n  if ((((MODFD (0.0, &iptr)))) || (CSD (1.0, iptr) != CSD (1.0, 0.0)))\n    link_error ();\n  if ((((MODFL (0.0l, &iptrl))) != 0.0l)\n      || (CSL (1.0L, iptrl) != CSL (1.0L, 0.0l)))\n    link_error ();\n  if ((((MODFF (-0.0f, &iptrf)))) || (CSF (1.0F, iptrf) != CSF (1.0F, -0.0f)))\n    link_error ();\n  if ((((MODFD (-0.0, &iptr)))) || (CSD (1.0, iptr) != CSD (1.0, -0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (-0.0l, &iptrl))) != CSL (1.0L, -0.0l))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, -0.0l)))\n    link_error ();\n  if (MODFF (-1 / 9.0f, &iptrf) != -1 / 9.0f\n      || (CSF (1.0F, (MODFF (-1 / 9.0f, &iptrf))) != CSF (1.0F, (-1 / 9.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, -0.0f)))\n    link_error ();\n  if (MODFD (-1 / 9.0, &iptr) != -1 / 9.0\n      || (CSD (1.0, iptr) != CSD (1.0, -0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (-1 / 9.0l, &iptrl))) != CSL (1.0L, (-1 / 9.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, -0.0l)))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (-1 / 3.0f, &iptrf))) != CSF (1.0F, (-1 / 3.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, -0.0f)))\n    link_error ();\n  if (MODFD (-1 / 3.0, &iptr) != -1 / 3.0\n      || (CSD (1.0, iptr) != CSD (1.0, -0.0)))\n    link_error ();\n  if ((CSL (1.0L, (MODFL (-1 / 3.0l, &iptrl))) != CSL (1.0L, (-1 / 3.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, -0.0l)))\n    link_error ();\n  if (MODFF (-4 / 9.0f, &iptrf) != -4 / 9.0f\n      || (CSF (1.0F, (MODFF (-4 / 9.0f, &iptrf))) != CSF (1.0F, (-4 / 9.0f)))\n      || (CSF (1.0F, iptrf) != CSF (1.0F, -0.0f)))\n    link_error ();\n  if (MODFD (-4 / 9.0, &iptr) != -4 / 9.0\n      || (CSD (1.0, iptr) != CSD (1.0, -0.0)))\n    link_error ();\n  if (MODFL (-4 / 9.0l, &iptrl) != -4 / 9.0l\n      || (CSL (1.0L, (MODFL (-4 / 9.0l, &iptrl))) != CSL (1.0L, (-4 / 9.0l)))\n      || (CSL (1.0L, iptrl) != CSL (1.0L, -0.0l)))\n    link_error ();\n  if (MODFF (-0.5f, &iptrf) != -0.5f\n      || (CSF (1.0F, iptrf) != CSF (1.0F, -0.0f)))\n    link_error ();\n  if (MODFD (-0.5, &iptr) != -0.5\n      != (CSD (1.0, (MODFD (-0.5, &iptr))) != CSD (1.0, -0.5))\n      || (CSD (1.0, iptr) != CSD (1.0, -0.0)))\n    (MODFL (-0.5l, (long double *) &iptrll));\n  if ((((MODFF (-1.0f, &iptrf)))) || (CSF (1.0F, iptrf) != -1.0f))\n    link_error ();\n  if ((((MODFD (-1.0, &iptr))) != -0.0) || (CSD (1.0, iptr) != -1.0))\n    link_error ();\n  if ((((MODFL (-1.0l, &iptrl)))) || (CSL (1.0L, iptrl) != -1.0l))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (-4 / 3.0f, &iptrf))) != CSF (1.0F, (1 - 4 / 3.0f)))\n      || (CSF (1.0F, iptrf) != -1.0f))\n    link_error ();\n  if (MODFD (-4 / 3.0, &iptr) != 1 - 4 / 3.0 || (CSD (1.0, iptr) != -1.0))\n    link_error ();\n  if (MODFL (-4 / 3.0l, &iptrl) != 1 - 4 / 3.0l\n      || (CSL (1.0L, (MODFL (-4 / 3.0l, &iptrl)))\n\t  != CSL (1.0L, (1 - 4 / 3.0l))) || (CSL (1.0L, iptrl) != -1.0l))\n    link_error ();\n  if ((CSF (1.0F, (MODFF (-1.5f, &iptrf))) != CSF (1.0F, -0.5f))\n      || (CSF (1.0F, iptrf) != -1.0f))\n    link_error ();\n  if ((CSD (1.0, (MODFD (-1.5, &iptr))) != CSD (1.0, -0.5))\n      || (CSD (1.0, iptr) != -1.0))\n    link_error ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48734.c",
    "content": "/* PR tree-optimization/48734 */\n\nunsigned int\nfoo (int x, unsigned int y, unsigned int z)\n{\n  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;\n  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;\n  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;\n  z &= (x == -__INT_MAX__ - 1 ? x : -x) > y;\n  return z;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48742.c",
    "content": "/* PR c/48742 */\n\nvoid baz (int);\n\nint\nfoo (void)\n{\n  return 1 / 0 > 0;\n}\n\nvoid\nbar (void)\n{\n  baz (1 <= 2 % (3 >> 1 > 5 / 6 == 3));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48767.c",
    "content": "/* PR target/48767 */\n\nvoid\nfoo (__builtin_va_list ap)\n{\n  __builtin_va_arg (ap, void); /* { dg-error \"second argument to .va_arg. is of incomplete type .void.\" } */\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr48929.c",
    "content": "/*{ dg-options \"-findirect-inlining\" }*/\nvoid bar ();\n\nstatic void\nf4 (double di, double d, double *dd)\n{\n  if (d == 0 && di == 0)\n    *dd = 0;\n  bar ();\n}\n\nstatic inline void\nf3 (int i, double d)\n{\n  double di = i;\n  double dd;\n  f4 (di, d, &dd);\n}\n\nstatic inline void\nf2 (int i, double d)\n{\n  if (d < 0)\n    f3 (i, d);\n}\n\nvoid\nf1 ()\n{\n  f2 (0, 1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49029.c",
    "content": "/* PR middle-end/49029 */\n/* { dg-require-effective-target int32plus } */\nstruct S { volatile unsigned f : 11; signed g : 30; } __attribute__((packed));\nstruct T { volatile struct S h; } __attribute__((packed)) a;\nvoid foo (int);\n\nvoid\nbar ()\n{\n  foo (a.h.g);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49049.c",
    "content": "/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-Os\" } { \"\" } } */\n\n__extension__ typedef unsigned long long int uint64_t;\n\nstatic int\nsub (int a, int b)\n{\n  return a - b;\n}\n\nstatic uint64_t\nadd (uint64_t a, uint64_t b)\n{\n  return a + b;\n}\n\nint *ptr;\n\nint\nfoo (uint64_t arg1, int *arg2)\n{\n  int j;\n  for (; j < 1; j++)\n    {\n      *arg2 |= sub ( sub (sub (j || 1 ^ 0x1, 1), arg1 < 0x1 <=\n\t\t\t\t\t\t   sub (1, *ptr & j)),\n\t\t     (sub ( j != 1 || sub (j && j, 1) >= 0,\n\t\t       add (!j > arg1, 0x35DLL))));\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49145.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nstatic int\nfunc1 (int a, int b)\n{\n  return b ? a : a / b;\n}\n\nstatic unsigned char\nfunc2 (unsigned char a, int b)\n{\n  return b ? a : b;\n}\n\nint i;\n\nvoid\nfunc3 (const int arg)\n{\n  for (i = 0; i != 10; i = foo ())\n    {\n      if (!arg)\n\t{\n\t  int j;\n\t  for (j = 0; j < 5; j += 1)\n\t    {\n\t      int *ptr;\n\t      *ptr = func2 (func1 (arg, *ptr), foo (arg));\n\t    }\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49163.c",
    "content": "/* PR target/49163 */\n/* { dg-require-effective-target int32plus } */\nstruct S1\n{\n unsigned f0:18;\n int f1;\n} __attribute__ ((packed));\n\nstruct S2\n{\n  volatile long long f0;\n  int f1;\n};\n\nstruct S1 s1;\nstruct S2 s2;\nconst struct S2 s2array[2][1] = { };\n\nstruct S2 **sptr;\n\nextern int bar (char a, long long b, int * c, long long d, long long e);\nextern int baz (void);\n\nint i;\nint *ptr;\n\nvoid\nfoo (int *arg)\n{\n  for (i = 0; i < 1; i = baz())\n    {\n      *arg = *(int *)sptr;\n      *ptr = bar (*arg, s2.f1, ptr,\n\t\t  bar (s2array[1][0].f0, *arg, ptr, s1.f1, *ptr), *arg);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49206.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nstruct S1\n{\n  short f0;\n};\nextern volatile struct S1 g_5;\nextern int g_120, i;\nextern short g_339;\n\nint\nfunc_72 (int x, int y, struct S1 z)\n{\n  for (z.f0 = -3; z.f0 > 16; z.f0 += 1)\n    foo ();\n  return g_120;\n}\n\nint\nmain ()\n{\n  while (g_339 % 0x200003)\n    continue;\n  if (i)\n    func_72 (0, 0, g_5);\n  foo (&g_339);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49220.c",
    "content": "int array[2];\n\nstatic int\nfunc1 (int b)\n{\n  return b;\n}\n\nstatic int\nfunc2 (int a, int b)\n{\n  return b == 0 ? a : b;\n}\n\nint\nfunc3 (int a)\n{\n}\n\nint *\nfunc4 (int *arg)\n{\n  *arg = func1 ((func2 (func3 (array[0]), *arg)) | array[0]);\n  return &array[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49238.c",
    "content": "/* PR target/49238 */\nextern int bar (void);\n\nvoid\nfoo (unsigned long long a, int b)\n{\n  int i;\n\n  if (b)\n    for (a = -12; a >= 10; a = bar ())\n      break;\n  else\n    return;\n\n  for (i = 0; i < 10; i += 10)\n    if ((i == bar ()) | (bar () >= a))\n      bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49474.c",
    "content": "typedef struct gfc_formal_arglist\n{\n  int next;\n}\ngfc_actual_arglist;\nupdate_arglist_pass (gfc_actual_arglist* lst, int po, unsigned argpos,\n       const char *name)\n{\n  ((void)(__builtin_expect(!(argpos > 0), 0) ? __builtin_unreachable(), 0 : 0));\n  if (argpos == 1)\n      return 0;\n  if (lst)\n    lst->next = update_arglist_pass (lst->next, po, argpos - 1, name);\n  else\n    lst = update_arglist_pass (((void *)0), po, argpos - 1, name);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49710.c",
    "content": "int a, b, c, d;\n\nstatic void\nfoo (int *x)\n{\n  c = 0;\n  while (1)\n    {\n      if (*x)\nbreak;\n      while (b)\nfor (; c; c = 0);\n      for (d = 18; d != 18; d++)\nif (c)\n  {\n    foo (x);\n    return;\n  }\n    }\n}\n\nstatic void\nbar ()\n{\n  foo (0);\n  foo (0);\n  for (;;)\n    ;\n}\n\nbaz ()\n{\n  for (; a;)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr49735.c",
    "content": "/* { dg-require-alias \"\" } */\nvoid bar (void);\nstatic void foo (void) { bar (); }\nvoid bar (void) __attribute__((alias(\"foo\")));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr50009.c",
    "content": "/* PR target/50009 */\n\nstruct S {\n  short a;\n  short b[];\n} __attribute__((packed));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr50380.c",
    "content": "__attribute__ ((__noreturn__)) extern void fail (void);\n\nchar x;\n\n/* This used to get stuck in an infinite loop in find_comparison_args\n   when compiling this function for MIPS at -O2.  */\n\nvoid foo (const unsigned char y)\n{\n   ((void) (__builtin_expect((!! y == y), 1) ? 0 : (fail (), 0)));\n   x = ! y;\n}\n\n/* This used to similarly get stuck when compiling for PowerPC at -O2.  */\n\nint foo2 (int arg)\n{\n  if (arg != !arg)\n    fail ();\n  if (arg)\n    fail ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr50565-1.c",
    "content": "struct s { char p[2]; };\nstatic struct s v;\nconst int o0 = (int) ((void *) &v.p[0] - (void *) &v) + 0U;\nconst int o1 = (int) ((void *) &v.p[0] - (void *) &v) + 1U;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr50565-2.c",
    "content": "struct s { char p[2]; };\nstatic struct s v;\nconst int o0 = (int) ((void *) &v.p[0] - (void *) &v) + 0;\nconst int o1 = (int) ((void *) &v.p[0] - (void *) &v) + 1;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr50650.c",
    "content": "/* PR tree-optimization/50650 */\n\nunsigned int\nfoo (unsigned int x, unsigned int y)\n{\n  int i;\n  for (i = 8; i--; x <<= 1)\n    y ^= (x ^ y) & 0x80 ? 79U : 0U;\n  return y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51069.c",
    "content": "\nint a, b, c, d, e, f, bar (void);\n\nvoid\nfoo (int x)\n{\n  for (;;)\n    {\n      if (!x)\n        {\n          for (d = 6; d >= 0; d--)\n            {\n              while (!b)\n                ;\n              if (e)\n                return foo (x);\n              if (f)\n                {\n                  a = 0;\n                  continue;\n                }\n              for (; c; c--)\n                ;\n            }\n        }\n      if (bar ())\n        break;\n      e = 0;\n      if (x)\n        for (;;)\n          ;\n    }\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51077.c",
    "content": "/* PR middle-end/51077 */\n\nstruct S { unsigned char s, t[256]; };\n\nvoid\nfoo (const struct S *x, struct S *y, int z)\n{\n  int i;\n  for (i = 0; i < 8; i++)\n    {\n      const struct S *a = &x[i];\n      __builtin___memcpy_chk (y->t, a->t, z, __builtin_object_size (y->t, 0));\n      y = (struct S *) &y->t[z];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51246.c",
    "content": "/* PR tree-optimization/51246 */\n\nint a, *b;\n\nvoid\ntest (void)\n{\n  while (1)\n    {\n      int c;\n      a = c;\n      b = &c;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51247.c",
    "content": "/* PR tree-optimization/51247 */\n\nstruct S { int s : 1; };\nint a;\n\nvoid\nfoo (int x, int y)\n{\n  struct S s;\n  s.s = !!y;\n  while (1)\n    {\n      unsigned l = 94967295;\n      a = x || (s.s &= l);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51354.c",
    "content": "/* PR target/51354 */\n/* { dg-require-effective-target alloca } */\n\nextern void abort (void);\n\ntypedef int __attribute__ ((aligned (32))) ai;\n\nvoid foo (int *x, ai * y);\n\nint\nbar (int x)\n{\n  if (x == 12346)\n    return 24;\n  ai i;\n  foo (__builtin_alloca (x), &i);\n  return 128;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51495.c",
    "content": "/* PR rtl-optimization/51495 */\n/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\nvoid bar (void);\n\nint\nfoo (int i)\n{\n  static const void *const table[] = { &&begin, &&end };\n  goto *(table[i]);\nbegin:\n  bar ();\nend:\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51694.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nvoid\nfoo (x, fn)\n  void (*fn) ();\n{\n  int a = baz ((void *) 0, x);\n  (*fn) (x, 0);\n}\n\nvoid\nbar (void)\n{\n  void *x = 0;\n  foo (x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51761.c",
    "content": "/* PR middle-end/51761 */\n\nstruct S { unsigned int len; };\nstruct S foo (struct S);\n\nstruct S\nbar (struct S x)\n{\n  return ({ struct S a = x; foo (a); });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51767.c",
    "content": "/* PR rtl-optimization/51767 */\n\nextern void fn1 (void), fn2 (void);\n\nstatic inline __attribute__((always_inline)) int\nfoo (int *x, long y)\n{\n  asm goto (\"\" : : \"r\" (x), \"r\" (y) : \"memory\" : lab);\n  return 0;\nlab:\n  return 1;\n}\n\nvoid\nbar (int *x)\n{\n  if (foo (x, 23))\n    fn1 ();\n  else\n    fn2 ();\n\n  foo (x, 2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr51856.c",
    "content": "struct B { int b1; long long b2, b3; int b4; };\nstruct C { char c1[40], c2, c3[96]; long long c4[5], c5; char c6[596]; };\nvoid fn1 (long long), fn2 (char *, int), fn4 (void);\nint r, fn3 (int, const char *, int, char *, int, int);\n\nvoid\nfoo (int t, int u, int v, int w, int x, int y, struct B *z)\n{\n  char c[512], d[512], e;\n  struct C g;\n  long long f, h[255];\n  struct B j;\n  __builtin_bzero (&j, sizeof j);\n  if (y > w)\n    fn4 ();\n  __builtin_bzero (&g, sizeof g);\n  g.c5 = h[0];\n  fn1 (z ? z->b3 : f);\n  g.c2 = y;\n  fn2 (d, 256);\n  if (fn3 (r, \"\", e, c, 0, 16))\n    fn4 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52073.c",
    "content": "/* PR tree-optimization/52073 */\n\nint a, b, c, d, e, f;\n\nvoid\nfoo (int x)\n{\n  e = 1;\n  for (;;)\n    {\n      int g = c;\n      if (x)\n\t{\n\t  if (e)\n\t    continue;\n\t  while (a)\n\t    --f;\n\t}\n      else\n\tfor (b = 5; b; b--)\n\t  {\n\t    d = g;\n\t    g = 0 == d;\n\t  }\n      if (!g)\n\tx = 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52074.c",
    "content": "/* PR middle-end/52074 */\n\nstruct S { const char *d, *e; } __attribute__((packed));\n\nvoid\nfoo (const char **p, struct S *q)\n{\n  *p = \"abcdef\";\n  q->d = \"ghijk\";\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52092.c",
    "content": "/* PR rtl-optimization/52092 */\n\nint a, b, c, d, e, f, g;\n\nvoid\nfoo (void)\n{\n  for (;;)\n    {\n      int *h = 0;\n      int i = 3;\n      int **j = &h;\n      if (e)\n\t{\n\t  c = d || a;\n\t  g = c ? a : b;\n\t  if ((char) (i * g))\n\t    {\n\t      h = &f;\n\t      *h = 0;\n\t    }\n\t  **j = 0;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52113.c",
    "content": "/* PR rtl-optimization/52113 */\n\nunsigned long v1;\nunsigned char v2;\n\nvoid\nfoo (void)\n{\n  if (v1 > (v2 * 1000L))\n    v1 = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52115.c",
    "content": "struct S\n{\n  float f;\n  long l;\n};\n\nextern int gi;\nextern float gf;\n\nlong foo (long p)\n{\n  struct S s;\n  float *pf;\n\n  s.l = p;\n\n  pf = &s.f;\n\n  pf++;\n  pf--;\n\n  gf = *pf + 3.3;\n  gi = *((short *)pf) + 2;\n\n  return s.l + 6;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52175.c",
    "content": "void bad (void);\nchar *foo (char *src, char **last)\n{\n  char *dst;\n  int ch;\n  dst = src = (src ? src : *last);\n\n  if (*src == 0)\n    return 0;\n\n  while (src[0])\n    {\n      if (!src[1])\n\t{\n\t  bad ();\n\t  break;\n\t}\n      *dst = *src;\n      dst += 1;\n      src += 2;\n    }\n  *last = src;\n  *dst = 0;\n  return *last;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52255.c",
    "content": "/* PR tree-optimization/52255 */\n\nint a, b, c[10], d[10] = { 0, 0 };\n\nvoid\nfoo (void)\n{\n  for (a = 1; a <= 4; a += 1)\n    d[a] = d[1];\n  for (; b; ++b)\n    c[0] |= 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52306.c",
    "content": "/* PR middle-end/52306 */\n\nstruct xmlNs {\n    const unsigned char *prefix;\n};\n\nstruct xmlNode {\n    const unsigned char *name;\n    struct xmlNs *ns;\n    struct xmlNs *nsDef;\n};\n\nstruct xsltTemplate {\n    const unsigned char *name;\n    int inheritedNsNr;\n    void *inheritedNs;\n};\n\nstruct xsltTemplate *xsltNewTemplate(void);\nvoid xsltGetQNameURI(unsigned char**);\nlong xmlMalloc(unsigned long);\nvoid xsltGenericDebug(void);\nint xmlStrEqual(const unsigned char*, const unsigned char*);\n\nstatic void xsltGetInheritedNsList(\n    struct xsltTemplate *template,\n    struct xmlNode *node)\n{\n    struct xmlNs *cur;\n    struct xmlNs **ret;\n    int nbns = 0;\n    int maxns = 10;\n    int i;\n\n    if (template == 0\n\t|| template->inheritedNsNr != 0\n\t|| template->inheritedNs != 0)\n\treturn;\n\n    while (node != 0) {\n\tcur = node->nsDef;\n\tret = (struct xmlNs**) xmlMalloc((maxns + 1) * sizeof(struct xmlNs*));\n\tfor (i = 0; i < nbns; i++)\n\t    if (cur->prefix == ret[i]->prefix\n\t\t|| xmlStrEqual(cur->prefix, 0))\n\t\tbreak;\n\n\tif (i >= nbns) {\n\t    if (nbns >= maxns)\n\t\treturn;\n\t    ret[nbns++] = cur;\n\t}\n    }\n}\n\nstatic void\nxsltParseStylesheetTemplate(struct xmlNode *template)\n{\n    struct xsltTemplate *ret;\n    unsigned char *prop;\n\n    ret = xsltNewTemplate();\n    if (ret == 0)\n\treturn;\n    xsltGetInheritedNsList(ret, template);\n    xsltGenericDebug();\n    xsltGetQNameURI(&prop);\n    xmlStrEqual(0, ret->name);\n}\n\nvoid xsltParseStylesheetTop(struct xmlNode *cur)\n{\n    xmlStrEqual(0, 0);\n\n    while (cur != 0) {\n\tif (xmlStrEqual(cur->name, 0))\n\t    ;\n\telse if (xmlStrEqual(cur->name, 0))\n\t    ;\n\telse if (xmlStrEqual(cur->name, 0))\n\t    xsltParseStylesheetTemplate(cur);\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52375.c",
    "content": "/* PR target/52375 */\n\nstruct C { int c, d; };\n\nunsigned\nfoo (struct C *p)\n{\n  unsigned int b = 0, i;\n  for (i = 0; i < 64; i++)\n    b |= 0x80000000U >> p[i].c;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52437.c",
    "content": "/* PR target/52437 */\n\nint f, g, i, j;\n\nvoid\nfn1 ()\n{\n  for (;;)\n    {\n      fn2 ();\n      j = 1;\n      for (i = 0; i <= 3; i++)\n\t{\n\t  for (g = 1; g >= 0; g--)\n\t    f = 0, j &= 11;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52533.c",
    "content": "/* PR tree-optimization/52533 */\n\nint\nfoo (unsigned char x)\n{\n  if (x <= 9)\n    return '0' + x;\n  else if (x <= 15)\n    return 'a' + (x - 10);\n  else\n    return 0;\n}\n\nvoid\nbar (unsigned char x, unsigned char *y)\n{\n  y[0] = foo ((unsigned char) (x >> 4));\n  y[1] = foo ((unsigned char) (x & 0x0f));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52555.c",
    "content": "/* { dg-options \"-ffast-math\" } */\n\nfloat farg;\nunsigned val;\n\nvoid __attribute__((optimize(\"O\")))\ntest()\n{\n  val = __builtin_ceilf(farg);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52714.c",
    "content": "/* { dg-require-effective-target alloca } */\n\nint __re_compile_fastmap(unsigned char *p)\n{\n    unsigned char **stack;\n    unsigned size;\n    unsigned avail;\n\n    stack = __builtin_alloca(5 * sizeof(unsigned char*));\n    if (stack == 0)\n\treturn -2;\n    size = 5;\n    avail = 0;\n\n    for (;;) {\n\tswitch (*p++) {\n\tcase 0:\n\t    if (avail == size)\n\t\treturn -2;\n\t    stack[avail++] = p;\n\t}\n    }\n\n    return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52750.c",
    "content": "/* PR middle-end/52750 */\n\ntypedef signed char V __attribute__((vector_size (32)));\n\nvoid\nfoo (V *x)\n{\n  V m = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n\t  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};\n  *x = __builtin_shuffle (*x, m);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52773.c",
    "content": "/* pr52773.c */\n\nstruct s {\n    short x;\n    short _pad[2];\n};\n\nstatic short mat_a_x;\n\nvoid transform(const struct s *src, struct s *dst, int n)\n{\n    int i;\n\n    for (i = 0; i < n; ++i)\n\tdst[i].x = (src[i].x * mat_a_x) >> 6;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c",
    "content": "/* PR tree-optimizations/52891 */\n\nstruct S\n{\n  int a;\n  struct T { unsigned c : 10; } b;\n} s;\n\nvoid\nbar (short x, short y, int **p)\n{\n  if ((x && y) + **p)\n    while (1);\n}\n\nvoid\nfoo (int **p)\n{\n  bar (s.a, s.b.c, p);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c",
    "content": "/* PR tree-optimizations/52891 */\n\n#if __SIZEOF_INT__ > 2\nstruct __attribute__((packed)) S { unsigned s : 22; };\n#else\nstruct __attribute__((packed)) S { unsigned s : 12; };\n#endif\nstruct __attribute__((packed)) T { struct S t; } c;\nint a, b, d;\n\nvoid\nfoo (void)\n{\n  if (1 ? (!c.t.s & (d < 0)) < a : 0)\n    b = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr52979-1.c",
    "content": "/* PR middle-end/52979 */\n\nstruct S\n{\n  unsigned int a : 16, b : 16, c : 16, d : 16, e : 14;\n  unsigned int f : 4, g : 14, h : 8;\n  char i;\n  int j;\n};\n\nvoid\nfoo (struct S *s)\n{\n  s->f = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53058.c",
    "content": "/* PR tree-optimization/53058 */\n\nint a, b, c;\n\nvoid\nfoo ()\n{\n  c = b >> 16;\n  if (c > 32767)\n    c = 0;\n  a = b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53163.c",
    "content": "/* PR tree-optimization/53163 */\n\nstruct S { int s; } b, f;\nint a, c;\n\nvoid\nfoo (void)\n{\n  int d, e;\n  for (d = 4; d < 19; ++d)\n    for (e = 2; e >= 0; e--)\n      {\n\ta = 0;\n\ta = 1;\n      }\n}\n\nvoid\nbar (void)\n{\n  int g, h, i;\n  for (i = 1; i >= 0; i--)\n    {\n      b = f;\n      for (g = 0; g <= 1; g++)\n\t{\n\t  if (c)\n\t    break;\n\t  for (h = 0; h <= 1; h++)\n\t    foo ();\n\t  foo ();\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53187.c",
    "content": "/* PR target/53187 */\n\nvoid bar (int);\n\nvoid\nfoo (int x, double y, double z)\n{\n  _Bool t = z >= y;\n  if (!t || x)\n    bar (t ? 1 : 16);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53226.c",
    "content": "/* PR tree-optimization/53226 */\n\nvoid\nfoo (unsigned long *x, char y, char z)\n{\n  int i;\n  for (i = y; i < z; ++i)\n    {\n      unsigned long a = ((unsigned char) i) & 63UL;\n      unsigned long b = 1ULL << a;\n      *x |= b;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53409.c",
    "content": "/* PR tree-optimization/53409 */\n\nint a, c, d, e, f;\nint b[0];\n\nint\nmain ()\n{\n  if (f)\n    e = 0;\n  int g = d;\n  for (c = 0; c <= 1; c++)\n    {\n      for (a = 0; a <= 1; a = (char) a + 1)\n\tb[c] = g;\n      a = 0;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53410-1.c",
    "content": "/* PR tree-optimization/53410 */\n\nint *a, b, c, d;\n\nvoid\nfoo (void)\n{\n  for (; d <= 0; d++)\n    b &= ((a || d) ^ c) == 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53410-2.c",
    "content": "/* PR tree-optimization/53410 */\n\ntypedef int V __attribute__((vector_size (4 * sizeof (int))));\ntypedef unsigned int W __attribute__((vector_size (4 * sizeof (int))));\n\nvoid\nf1 (V *p)\n{\n  *p = (*p & ((V) { 1, 1, 1, 1 })) ^ ((V) { 1, 1, 1, 1});\n}\n\nvoid\nf2 (V *p)\n{\n  *p = (*p ^ ((V) { 1, 1, 1, 1 })) & ((V) { 1, 1, 1, 1});\n}\n\nvoid\nf3 (V *p)\n{\n  *p = (~*p) & ((V) { 1, 1, 1, 1 });\n}\n\nvoid\nf4 (V *p, V *q)\n{\n  *p = (*p ^ *q) == *q;\n}\n\nvoid\nf5 (V *p, V *q)\n{\n  *p = (*p ^ *q) == *p;\n}\n\nvoid\nf6 (V *p, V *q, V *r)\n{\n  *p = (*p & *r) == (*q & *r);\n}\n\nvoid\nf7 (V *p, V *q, V *r)\n{\n  *p = (*p & *r) == (*r & *q);\n}\n\nvoid\nf8 (V *p, V *q, V *r)\n{\n  *p = (*r & *p) == (*q & *r);\n}\n\nvoid\nf9 (V *p, V *q, V *r)\n{\n  *p = (*r & *p) == (*r & *q);\n}\n\nvoid\nf10 (W *p, W *q)\n{\n  *p = *p < (((const W) { 1U, 1U, 1U, 1U }) << *q);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53411.c",
    "content": "/* PR middle-end/53411 */\n/* { dg-require-effective-target untyped_assembly } */\n\nint a, b, c, d, e, f, g, h;\nvoid fn1 (void);\nint fn2 (void);\n\nint\nfn3 (x)\n     int x;\n{\n  return a ? 0 : x;\n}\n\nvoid\nfn4 (char x)\n{\n  int i, j, k;\n  for (; e; e++)\n    if (fn2 ())\n      {\n\tf = 1;\n\tk = 0;\n\tfor (; k <= 1; k++)\n\t  {\n\t    j = ~x;\n\t    i = f * j;\n\t    h = (fn3 (i | 0 <= c ^ 9L) != b | d) & 8;\n\t    g = x | 1;\n\t    fn1 ();\n\t  }\n      }\n  c = x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53418-1.c",
    "content": "void\nf (void)\n{\n  int i = (0 ? 1 : 0U / 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53418-2.c",
    "content": "void\nf (void)\n{\n  int i = (1 ? 0U / 0 : 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53495.c",
    "content": "/* PR rtl-optimization/53495 */\n\nint a, b, c, d, e, g;\nstatic char\nfn1 (char p1, int p2)\n{\n  return p1 || p2 < 0 || p2 >= 1 || 1 >> p2 ? p1 : 0;\n}\n\nstatic long long fn2 (int *, int);\nstatic int fn3 ();\nvoid\nfn4 ()\n{\n  fn3 ();\n  fn2 (&a, d);\n}\n\nlong long\nfn2 (int *p1, int p2)\n{\n  int f = -1L;\n  for (; c <= 1; c++)\n    {\n      *p1 = 0;\n      *p1 = fn1 (c, p2 ^ f);\n    }\n  a = 0;\n  e = p2;\n  return 0;\n}\n\nint\nfn3 ()\n{\n  b = 3;\n  for (; b; b--)\n    c++;\n  g = 0 >= c;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53519.c",
    "content": "/* PR rtl-optimization/53519 */\n\nint a, b, c, d, e;\n\nshort int\nfoo (short int x)\n{\n  return a == 0 ? x : 0;\n}\n\nshort int\nbar (int x, int y)\n{\n  return x + y;\n}\n\nvoid\nbaz (void)\n{\n  if (!e)\n    {\n      int f = foo (65535 ^ b);\n      if (bar (!6L <= ~f, ~e) == c)\n\td = 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53748.c",
    "content": "/* PR tree-optimization/53748 */\n\ntypedef unsigned int V __attribute__ ((__vector_size__ (sizeof (int) * 4)));\n\nvoid\nfoo (int x, V *y)\n{\n  *y = x ? ((V) { ~0U, ~0U, ~0U, ~0U }) : ((V) { 0, 0, 0, 0 });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr53886.c",
    "content": "/* PR target/53886  */\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct bignum_st BIGNUM;\ntypedef struct ec_group_st EC_GROUP;\ntypedef struct ec_key_st EC_KEY;\n\nstruct ec_key_st\n{\n  EC_GROUP *group;\n  BIGNUM *priv_key;\n  unsigned int enc_flag;\n}\nX9_62_PENTANOMIAL;\ntypedef struct ec_privatekey_st\n{\n  ASN1_BIT_STRING *publicKey;\n}\nEC_PRIVATEKEY;\n\nextern EC_PRIVATEKEY* EC_PRIVATEKEY_new (void);\nextern void EC_PRIVATEKEY_free (EC_PRIVATEKEY*);\nextern unsigned char* CRYPTO_realloc (char*,int,const char*,int);\n\nint\ni2d_ECPrivateKey (EC_KEY * a, unsigned char **out)\n{\n  int ret = 0, ok = 0;\n  unsigned char *buffer = 0;\n  unsigned buf_len = 0, tmp_len;\n  EC_PRIVATEKEY *priv_key = 0;\n  if (a == 0 || a->group == 0 || a->priv_key == 0)\n    {\n      ERR_put_error (16, (192), ((3 | 64)),\n\t\t     \"\",\n\t\t     1234);\n      goto err;\n    }\n  if ((priv_key = EC_PRIVATEKEY_new ()) == 0)\n    {\n      ERR_put_error (16, (192), ((1 | 64)),\n\t\t     \"\",\n\t\t     1241);\n      goto err;\n    }\n  if (!(a->enc_flag & 0x002))\n    {\n      if (priv_key->publicKey == 0)\n\t{\n\t  goto err;\n\t}\n      if (tmp_len > buf_len)\n\t{\n\t  unsigned char *tmp_buffer =\n\t    CRYPTO_realloc ((char *) buffer, (int) tmp_len, \"\", 1293);\n\t  buffer = tmp_buffer;\n\t}\n    }\n  if ((ret = i2d_EC_PRIVATEKEY (priv_key, out)) == 0)\n    {\n    }\n  ok = 1;\nerr:\n  if (buffer)\n    CRYPTO_free (buffer);\n  if (priv_key)\n    EC_PRIVATEKEY_free (priv_key);\n  return (ok ? ret : 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-1.c",
    "content": "void\nf (void)\n{\n  0 || 0 / 0 ? : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-2.c",
    "content": "void\nf (void)\n{\n  0 / 0 || 0 ? : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-3.c",
    "content": "void\nf (void)\n{\n  1 && 0 / 0 ? : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-4.c",
    "content": "void\nf (void)\n{\n  0 / 0 && 1 ? : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-5.c",
    "content": "void\nf (void)\n{\n  !(0 / 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54103-6.c",
    "content": "void\nf (void)\n{\n  0 || 65536*65536 ? : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54321.c",
    "content": "/* PR tree-optimization/54321 */\nstruct S { char s[0]; } *a;\n\nvoid\nfoo (void)\n{\n  char *b = a->s;\n  int c = 0;\n  b[0] = 0;\n  while (++c < 9)\n    b[c] = 255;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54428.c",
    "content": "/* PR c/54428 */\n\ntypedef double _Complex C;\n\nC\nfoo (C x, C y, double z, C w)\n{\n  return y - z * __builtin_cpow (x, 75) * w;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54552-1.c",
    "content": "void\nf (void)\n{\n  unsigned n = 10;\n\n  typedef double T[n];\n  (double (*)[n])((unsigned char (*)[sizeof (T)]){ 0 });\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54559.c",
    "content": "/* PR c/54559 */\n\ntypedef double _Complex T;\n\nT\nfoo (double x, double y)\n{\n  return x + y * (T) (__extension__ 1.0iF);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54713-1.c",
    "content": "/* PR tree-optimization/54713 */\n\n#ifndef N\n#define N 8\n#define ONE 1, 1, 1, 1, 1, 1, 1, 1\n#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U\n#endif\n\ntypedef int V __attribute__((vector_size (N * sizeof (int))));\ntypedef unsigned int W __attribute__((vector_size (N * sizeof (int))));\n\nvoid\nf1 (V *p)\n{\n  *p = (*p & ((V) { ONE })) ^ ((V) { ONE});\n}\n\nvoid\nf2 (V *p)\n{\n  *p = (*p ^ ((V) { ONE })) & ((V) { ONE});\n}\n\nvoid\nf3 (V *p)\n{\n  *p = (~*p) & ((V) { ONE });\n}\n\nvoid\nf4 (V *p, V *q)\n{\n  *p = (*p ^ *q) == *q;\n}\n\nvoid\nf5 (V *p, V *q)\n{\n  *p = (*p ^ *q) == *p;\n}\n\nvoid\nf6 (V *p, V *q, V *r)\n{\n  *p = (*p & *r) == (*q & *r);\n}\n\nvoid\nf7 (V *p, V *q, V *r)\n{\n  *p = (*p & *r) == (*r & *q);\n}\n\nvoid\nf8 (V *p, V *q, V *r)\n{\n  *p = (*r & *p) == (*q & *r);\n}\n\nvoid\nf9 (V *p, V *q, V *r)\n{\n  *p = (*r & *p) == (*r & *q);\n}\n\nvoid\nf10 (W *p, W *q)\n{\n  *p = *p < (((const W) { ONEU }) << *q);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54713-2.c",
    "content": "/* PR tree-optimization/54713 */\n\n#define N 16\n#define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U\n\n#include \"pr54713-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54713-3.c",
    "content": "/* PR tree-optimization/54713 */\n\n#define N 32\n#define ONE 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \\\n\t    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1    \n#define ONEU 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, \\\n\t     1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U, 1U\n\n#include \"pr54713-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr54925.c",
    "content": "/* PR target/54925  */\nextern int bar;\nextern void foo (int *);\nstatic unsigned char *\nnr_memcpy (unsigned char *, unsigned char *, unsigned short);\n\nvoid \nbaz (char *buf, unsigned short len)\n{\n  unsigned char data[10];\n  if (len == 0)\n    return;\n  nr_memcpy (data, (unsigned char *) buf, len);\n  foo (&bar);\n}\n\nstatic unsigned char *\nnr_memcpy (unsigned char * to, unsigned char * from, unsigned short len)\n{\n  unsigned char *p = to;\n  while (len > 0)\n    {\n      len--;\n      *to++ = *from++;\n    }\n  return p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55273.c",
    "content": "extern int debug_threads;\nextern void sigsuspend (void);\nvoid my_waitpid (int flags, int wnohang)\n{\n  while (1)\n    {\n      if (flags & 0x80000000)\n        {\n          if (wnohang)\n            break;\n          if (debug_threads)\n            __builtin_puts (\"blocking\\n\");\n          sigsuspend ();\n        }\n      flags ^= 0x80000000;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55350.c",
    "content": "void\nfoo (__INTPTR_TYPE__ x, __INTPTR_TYPE__ y)\n{\n  int i;\n  void **a = (void *)  (8UL * (x / 8UL));\n  for (i = 0; i < x; i++)\n    a[i] = (void *) y;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55569.c",
    "content": "/* { dg-options \"-ftree-vectorize\" } */\nint *bar (void);\n\nvoid\nfoo (void)\n{\n  long x;\n  int *y = bar ();\n    for (x = -1 / sizeof (int); x; --x, ++y)\n       *y = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55832.c",
    "content": "/* PR tree-optimization/55832 */\n\nint g, b;\n\nvoid\nfoo (void)\n{\n  union U { int i; unsigned short s; } a = { 0 };\n  unsigned char c;\n  unsigned short d = 0, *p = &a.s;\n\n  if (g)\n    a.i--;\n\n  if (b && a.i < (d = 1))\n    return;\n\n  for (; a.i < 15; a.i++)\n    b |= d <= c;\n\n  if (!*p)\n    g = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55851.c",
    "content": "/* PR middle-end/55851 */\n/* { dg-require-effective-target alloca } */\n\nenum { A = 1UL, B = -1UL } var = A;\nvoid foo (char *);\n\nvoid\ntest (void)\n{\n  char vla[1][var];\n  vla[0][0] = 1;\n  foo (&vla[0][0]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55920.c",
    "content": "/* PR tree-optimization/55920 */\n\nstruct A { unsigned a; } __attribute__((packed));\nstruct B { int b; unsigned char c[16]; };\nvoid bar (struct A);\n\nvoid\nfoo (struct B *x)\n{\n  struct A a;\n  if (x->b)\n    __builtin_memcpy (&a, x->c, sizeof a);\n  else\n    a.a = 0;\n  bar (a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55921.c",
    "content": "/* PR tree-optimization/55921 */\n\ntypedef union\n{\n  _Complex float cf;\n  long long ll;\n} ucf;\n\nvoid\nfoo (ucf *in, ucf *out, _Complex float r)\n{\n  int i;\n  ucf ucf1;\n  _Complex float cf;\n\n  ucf1.ll = in[i].ll;\n  __asm (\"\" : \"=r\" (cf) : \"r\" (ucf1.ll));\n  cf *= r;\n  __asm (\"\" : \"=r\" (ucf1.ll) : \"r\" (cf));\n  out[i].ll = ucf1.ll;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr55955.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* PR tree-optimization/55955 */\n\nint b;\n\nvoid\nfoo (int x)\n{\n  int a;\n  for (a = x; a < 2; a++)\n    for (b = 0; b < 2; b++)\n      *(unsigned short *) 0x100000UL %= 46;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56405.c",
    "content": "/* PR inline-asm/56405 */\n\nvoid\nfoo (void)\n{\n  asm volatile (\"\" : \"+m\" (*(volatile unsigned short *) 0x1001UL));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56448.c",
    "content": "/* PR tree-optimization/56448 */\n\nvolatile int a[1];\nint b;\n\nvoid\nfoo ()\n{\n  for (;;)\n    {\n      int *c[3][6] = { 0, 0, 0, &b, 0, 0, 0, 0, &b, 0, 0, 0, 0, 0, 0, 0, &b, (int *) &a[0] };\n      b = *c[2][5];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56484.c",
    "content": "/* PR rtl-optimization/56484 */\n\nunsigned char b[4096];\nint bar (void);\n\nint\nfoo (void)\n{\n  int a = 0;\n  while (bar ())\n    {\n      int c = bar ();\n      a = a < 0 ? a : c;\n      __builtin_memset (b, 0, sizeof b);\n    }\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56539.c",
    "content": "/* PR tree-optimization/56539 */\n\nshort\nfoo (const char *x, unsigned y)\n{\n  return y > 1 ? (x[y - 1] - '0') + 10 * foo (x, y - 1) : (*x - '0');\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56571.c",
    "content": "/* { dg-options \"-funroll-loops -ftracer\" } */\nint a, b;\n\nint f(void)\n{\n    (a % b) && f();\n    a = (0 || a | (a ? : 1));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56745.c",
    "content": "/* PR rtl-optimization/56745 */\n\nunsigned char a[6];\n\nvoid\nfoo ()\n{\n  int i;\n  for (i = 5; i >= 0; i++)\n    {\n      if (++a[i] != 0)\n\tbreak;\n      ++a[i];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr56984.c",
    "content": "/* PR tree-optimization/56984 */\n\nint\nfoo (int x)\n{\n  if ((x >> 31) < -1)\n    x++;\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr57108.c",
    "content": "/* PR target/57108  */\n\nvoid __assert_func (void) __attribute__ ((__noreturn__));\n\nvoid\nATATransfer (int num, int buffer)\n{\n  int wordCount;\n\n  while (num > 0)\n    {\n      wordCount = num * 512 / sizeof (int);\n\n      ((0 == (buffer & 63)) ? (void)0 : __assert_func () );\n      ((0 == (wordCount & 31)) ? (void)0 : __assert_func ());\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr57331.c",
    "content": "/* PR tree-optimization/57331 */\n\nint\nfoo (int x)\n{\n  void *p = x ? (void *) 1 : (void *) 0;\n  __INTPTR_TYPE__ b = (__INTPTR_TYPE__) p;\n  if (b)\n    return 0;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr57441.c",
    "content": "/* PR tree-optimization/57441 */\n\nint a, c, d, *e;\nunsigned char b;\n\nchar\nbaz (char p1)\n{\n    return p1 * a;\n}\n\nvoid func_65 ();\nfunc_1 ()\n{\n    func_65 ();\n    func_65 ();\n}\n\nvoid\nfunc_65 ()\n{\n    d = baz (b--);\n    if (*e)\n        b--;\n    c = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr57698.c",
    "content": "typedef int (*IsAcceptableThis) (const int );\ninline int\nfn1 (IsAcceptableThis p1)\n{\n    p1 (0);\n    return 0;\n}\n\n__attribute__ ((always_inline))\ninline int fn2 (const int a)\n{\n    return 0;\n}\n\nvoid\nfn3 ()\n{\n    fn1 (fn2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58088.c",
    "content": "int\nbar (int i)\n{\n  return 1 | ((i * 2) & 254);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58164.c",
    "content": "/* PR tree-optimization/58164 */\n/* { dg-require-effective-target indirect_jumps } */\n\nint\nfoo (void)\n{\n  int x = 0;\n  goto *&x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58332.c",
    "content": "static inline int foo (int x) { return x + 1; }\n__attribute__ ((__optimize__ (0))) int bar (void) { return foo (100); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58340.c",
    "content": "int a, b, c, d;\n\nint foo (int x, int y)\n{\n  return y == 0 ? x : 1 % y;\n}\n\nint main ()\n{\n  c = 0 || a;\n\n  for (;;)\n    b = foo (d, c) && 1;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58343.c",
    "content": "int a;\n\nint main ()\n{\n  int b = a; \n\n  for (a = 1; a > 0; a--)\n    ;\n\n lbl:\n  if (b && a)\n    goto lbl; \n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58344.c",
    "content": "/* PR middle-end/58344 */\n/* { dg-do compile } */\n\nstruct U {};\nstatic struct U a[1];\nextern void bar (struct U);\n\nvoid\nfoo (void)\n{\n  bar (a[0]);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58775.c",
    "content": "/* PR tree-optimization/58775 */\n\nvoid bar (void);\n\nvoid\nfoo (char *x)\n{\n  char a;\n  _Bool b, c, d, e, f, g, h, i, j, k, l, m;\n\n  a = *x;\n  b = a == 100;\n  c = a == 105;\n  d = b | c;\n  e = a != 111;\n  f = !d;\n  g = e & f;\n  h = a != 117;\n  i = g & h;\n  j = a != 120;\n  k = i & j;\n  l = a != 88;\n  m = k & l;\n  if (m == 0)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58946.c",
    "content": "/* PR tree-optimization/58946 */\n\nint\nfoo (unsigned int c)\n{\n  unsigned int d, e, f;\n  if ((int) c < 0)\n    d = 0;\n  else\n    d = c;\n  if (d == 0)\n    e = __INT_MAX__ + 1U;\n  else\n    e = d;\n  if ((int) e < 0)\n    f = 0;\n  else\n    f = e;\n  return f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58970-1.c",
    "content": "/* PR middle-end/58970 */\n\nstruct T { int b : 1; };\nstruct S { struct T t[1]; };\n\nvoid\nfoo (int x, struct S *s)\n{\n  if (x == -1)\n    s->t[x].b = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58970-2.c",
    "content": "/* PR middle-end/58970 */\n\nstruct T { char a : 8; char b : 1; };\nstruct S { char x; struct T t[1]; };\n\nvoid\nfoo (int x, struct S *s)\n{\n  if (x == -1)\n    s->t[x].b = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58978.c",
    "content": "/* PR tree-optimization/58978 */\n\nint\nfoo (int x)\n{\n  switch (x)\n    {\n    case 0:\n    case 1:\n    case 9:\n      break;\n    default:\n      __builtin_unreachable ();\n    }\n  return x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr58997.c",
    "content": "/* PR rtl-optimization/58997 */\n\nint a, b, c, e;\nshort d;\nchar h;\n\nvoid\nfoo ()\n{\n  while (b)\n    {\n      d = a ? c : 1 % a;\n      c = d;\n      h = d;\n      if (!h)\n\twhile (e)\n\t  ;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59102.c",
    "content": "\nint a, b, c, f;\n\nstruct S\n{\n  int f0;\n} d, *e;\n\nstruct S\nfoo ()\n{\n  b = c = b || a == 0 || f % 11;\n  return d;\n}\n\nint\nmain ()\n{\n  foo ();\n  if (b);\n  else\n    {\n      struct S **g = &e;\n      *g = 0;\n      *e = foo ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59119.c",
    "content": "extern void *memmove (void *, const void *, __SIZE_TYPE__);\nextern void *memset (void *, int, __SIZE_TYPE__);\n\ntypedef struct {\n    long n_prefix;\n    long n_spadding;\n} NumberFieldWidths;\n\nvoid\nfill_number(char *buf, const NumberFieldWidths *spec)\n{\n    if (spec->n_prefix) {\n        memmove(buf,\n                (char *) 0,\n                spec->n_prefix * sizeof(char));\n        buf += spec->n_prefix;\n    }\n    if (spec->n_spadding) {\n        memset(buf, 0, spec->n_spadding);\n        buf += spec->n_spadding;\n    }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59134.c",
    "content": "/* { dg-do compile } */\n\nextern void* malloc(__SIZE_TYPE__) __attribute__((malloc));\n\ntypedef struct {\n  char pad;\n  int arr[0];\n} __attribute__((packed)) str;\n\nstr *\nfoo (void)\n{\n  str *s = malloc (sizeof (str) + sizeof (int));\n  s->arr[0] = 0x12345678;\n  return s;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59322.c",
    "content": "\nint a, b, d;\nshort c;\n\nint\nfoo ()\n{\n  for (b = 0; b; b = a)\n    for (c = 18; c < 10; c++)\n      {\n\td = c;\n\tif (d)\n\t  return 0;\n      }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59362.c",
    "content": "/* PR tree-optimization/59362 */\n\nchar *\nfoo (char *r, int s)\n{\n  r = __builtin___stpcpy_chk (r, \"abc\", __builtin_object_size (r, 1));\n  if (s)\n    r = __builtin___stpcpy_chk (r, \"d\", __builtin_object_size (r, 1));\n  return r;\n}\n\nchar *a;\nlong int b;\n\nvoid\nbar (void)\n{\n  b = __builtin_object_size (0, 0);\n  a = __builtin___stpcpy_chk (0, \"\", b);\n  b = __builtin_object_size (a, 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59386.c",
    "content": "/* PR tree-optimization/59386 */\n\nstruct S { int s; };\nstruct T { int t; struct S u; } c;\nint b;\n\nstruct S\nfoo ()\n{\n  struct T d;\n  if (b)\n    while (c.t)\n      ;\n  else\n    return d.u;\n}\n\nstruct S\nbar ()\n{\n  struct T a;\n  a.u = foo ();\n  return a.u;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59417.c",
    "content": "/* PR tree-optimization/59417 */\n/* { dg-skip-if \"ptxas times out\" { nvptx-*-* } { \"-O1\" \"-O2\" \"-Os\" } { \"\" } } */\n\nint a, b, d;\nshort c;\n\nvoid\nf (void)\n{\n  if (b)\n    {\n      int *e;\n\n      if (d)\n\t{\n\t  for (; b; a++)\n\t  lbl1:\n\t    d = 0;\n\n\t  for (; d <= 1; d++)\n\t    {\n\t      int **q = &e;\n\t      for (**q = 0; **q <= 0; **q++)\n\t\td = 0;\n\t    }\n\t}\n    }\n\n  else\n    {\n      int t;\n      for (c = 0; c < 77; c++)\n\tfor (c = 0; c < 46; c++);\n      for (; t <= 0; t++)\n      lbl2:\n\t;\n      goto lbl1;\n    }\n  goto lbl2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59569-1.c",
    "content": "/* PR middle-end/59569 */\nextern char c;\n\nvoid\nfoo (int i, char **j)\n{\n  while (i)\n    j[--i] = &c;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59569-2.c",
    "content": "/* PR middle-end/59569 */\nvoid foo (int *a, int b)\n{\n  for (; b; b--)\n    a[b] = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59743.c",
    "content": "/* PR middle-end/59743 */\n\ntypedef union {\n  long all;\n  struct {\n    int low;\n    int high;\n  } s;\n} udwords;\nint a, b, c, d;\nvoid __udivmoddi4() {\n  udwords r;\n  d = __builtin_clz(0);\n  r.s.low = 0;\n  for (; d; --d) {\n    r.s.high = r.s.high << 1 | r.s.low >> a;\n    r.s.low = r.s.low << b >> 1;\n    int s = -r.all;\n    c = s;\n    r.all--;\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59803.c",
    "content": "/* PR target/59803 */\n\nextern void baz (void) __attribute__ ((__noreturn__));\nstruct A { int g, h; };\nextern struct A a;\nstruct B { unsigned char i, j, k, l, m; };\nint c, d, e;\nstatic int f;\n\nvoid\nfoo (void)\n{\n  f = 1;\n}\n\nvoid\nbar (struct B *x)\n{\n  x->i = e;\n  x->k = c;\n  x->l = d;\n  x->j = a.h;\n  x->m = f;\n  if (x->i != e) baz ();\n  if (x->k != c) baz ();\n  if (x->j != a.h) baz ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr59919.c",
    "content": "typedef int jmp_buf[10];\nstruct S\n{\n  int i;\n  jmp_buf buf;\n};\n\nvoid setjmp (jmp_buf);\nvoid foo (int *);\n__attribute__ ((__noreturn__, __nonnull__)) void bar (struct S *);\n\nvoid\nbaz (struct S *p)\n{\n  bar (p);\n  setjmp (p->buf);\n  foo (&p->i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60071.c",
    "content": "int\nfoo (int cls, int sign)\n{\n  if (__builtin_expect (cls == 4, 0))\n    return (sign\n            ? (-((int) ((~(unsigned)0) >> 1)))-1\n            : ((int) ((~(unsigned)0) >> 1)));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60268.c",
    "content": "/* { dg-options \"-flive-range-shrinkage\" } */\nvoid f()\n{\n  int i = 0;\n  void *p = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60502.c",
    "content": "/* PR tree-optimization/60502 */\n\ntypedef signed char v16i8 __attribute__ ((vector_size (16)));\ntypedef unsigned char v16u8 __attribute__ ((vector_size (16)));\n\nvoid\nfoo (v16i8 *x)\n{\n  v16i8 m1 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };\n  *x |= *x ^ m1;\n}\n\nvoid\nbar (v16u8 *x)\n{\n  v16u8 m1 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };\n  *x |= *x ^ m1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60556.c",
    "content": "/* PR middle-end/60556 */\n\nint g (int);\n\nunsigned long long f (void)\n{\n return (unsigned long long)(long)&g;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60655-1.c",
    "content": "/* { dg-options \"-fdata-sections\" { target { { ! { { hppa*-*-hpux* } && { ! lp64 } } } && { ! nvptx-*-* } } } } */\n\ntypedef unsigned char unit;\ntypedef unit *unitptr;\nextern short global_precision;\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *dest, const void *src, size_t n);\n\nshort mp_compare(const unit* r1, const unit* r2)\n{\n  register short precision;\n  precision = global_precision;\n  (r1) = ((r1)+(precision)-1);\n  (r2) = ((r2)+(precision)-1);\n  do\n    { if (*r1 < *r2)\n\treturn(-1);\n      if (*((r1)--) > *((r2)--))\n\treturn(1);\n    } while (--precision);\n}\n\nstatic unit modulus[((1280+(2*8))/8)];\nstatic unit d_data[((1280+(2*8))/8)*2];\n\nint upton_modmult (unitptr prod, unitptr multiplicand, unitptr multiplier)\n{\n unitptr d = d_data;\n while (mp_compare(d,modulus) > 0)\n   memcpy((void*)(prod), (const void*)(d), (global_precision));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr60655-2.c",
    "content": "\ntypedef unsigned char unit;\ntypedef unit *unitptr;\nextern short global_precision;\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *dest, const void *src, size_t n);\n\nshort mp_compare(const unit* r1, const unit* r2)\n{\n  register short precision;\n  precision = global_precision;\n  (r1) = ((r1)+(precision)-1);\n  (r2) = ((r2)+(precision)-1);\n  do\n    { if (*r1 < *r2)\n\treturn(-1);\n      if (*((r1)--) > *((r2)--))\n\treturn(1);\n    } while (--precision);\n}\n\nstatic unit modulus[((1280+(2*8))/8)];\nstatic unit d_data[((1280+(2*8))/8)*2];\n\nint upton_modmult (unitptr prod, unitptr multiplicand, unitptr multiplier)\n{\n unitptr d = d_data;\n while (mp_compare(d,modulus) > 0)\n   memcpy((void*)(prod), (const void*)(d), (global_precision));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr61042.c",
    "content": "/* PR tree-optimization/61042 */\n\nint a, b, c[1], d, f;\n\nvoid\nfoo ()\n{\n  for (; b; b++)\n    c[0] = c[f] && (d = a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr61222-1.c",
    "content": "int a, b, d, e;\nchar c;\n\nvoid\nfoo ()\n{\n  for (; a; a++)\n    {\n      d = ((b == 0) ^ (129 + a));\n      c = d * 9;\n      e = c < 1;\n      if (e)\n\tfor (;;)\n\t  ;\n    }\n}\n\nint\nmain ()\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr61222-2.c",
    "content": "int a, b, d;\nint main (void)\n{\n  int c = a && 1;\n  d = 1 << (((c | (b - 842)) << 1) + 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr61684.c",
    "content": "/* PR tree-optimization/61684 */\n/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"*\" } { \"-O0\" \"-O1\" \"-Os\" } } */\n\nint a, c;\nstatic int *b = 0;\nshort d;\nstatic short **e = 0;\n\nvoid\nfoo ()\n{\n  for (; c < 1; c++)\n    ;\n  *e = &d;\n  a = d && (c && 1) & *b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr61848.c",
    "content": "/* { dg-do compile } */\n/* { dg-require-effective-target named_sections } */\n/* { dg-final { scan-assembler \"mysection\" } } */\nextern char foo;\nchar foo __attribute__ ((__section__(\".mysection\")));\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr62312.c",
    "content": "/* PR target/62312  */\n\ntypedef struct { unsigned int arg[100]; } *FunctionCallInfo;\ntypedef struct { int day; int month; } Interval;\nvoid* palloc (unsigned int);\nint bar (void);\nvoid baz (void);\n\nvoid\ninterval_pl (FunctionCallInfo fcinfo)\n{\n  Interval *span1 = ((Interval *) ((char *) ((fcinfo->arg[0]))));\n  Interval *span2 = ((Interval *) ((char *) ((fcinfo->arg[1]))));\n  Interval *result = (Interval *) palloc (sizeof (Interval));\n\n  if ((((span1->month) < 0) == ((span2->month) < 0))\n      && !(((result->month) < 0) == ((span1->month) < 0)))\n    do {\n      if (bar ())\n\tbaz ();\n    } while(0);\n  result->day = span1->day + span2->day;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr63282.c",
    "content": "/* PR inline-asm/63282 */\n\nvoid bar (void);\n\nvoid\nfoo (void)\n{\n  asm volatile goto (\"\" : : : : a, b);\na:\n  bar ();\nb:\n  return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr63761.c",
    "content": "int a, b;\nshort c;\n\nvoid fn1 ();\n\nvoid\nfn2 (unsigned short p1)\n{\n  int d;\n\n  c = p1 >> 8 | p1 << 8;\n  d = b;\n  if (d)\n    fn1 ();\n  a = d >> 8 & 0x00FF\n    | d << 8 & 0xFF00;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr64067.c",
    "content": "/* PR middle-end/64067 */\n\nstruct S { int s; };\nint *const v[1] = { &((struct S) { .s = 42 }).s };\n\nint *\nfoo (void)\n{\n  return v[0];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr64269.c",
    "content": "/* PR tree-optimization/64269 */\n\nvoid\nfoo (char *p)\n{\n  __SIZE_TYPE__ s = ~(__SIZE_TYPE__)0;\n  *p = 0;\n  __builtin_memset (p + 1, 0, s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr64494.c",
    "content": "/* PR tree-optimization/64494 */\n\nint a, b;\nunsigned char c;\n\nint\nmain ()\n{\n  int d;\n  a = 0;\n  for (d = 0; d < 2; d++)\n    {\n      a &= (b >= 1);\n      c = (204 > (((unsigned char) ~0) >> a)) ? 0 : 204 << a;\n      b = 0;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65014.c",
    "content": "/* PR tree-optimization/65014 */\n/* { dg-do compile { target int32plus } } */\n\nextern int x;\n\nunsigned\nfoo (unsigned int y)\n{\n  return (y << ((__INTPTR_TYPE__) &x)) | (y >> (32 - ((__INTPTR_TYPE__) &x)));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65153.c",
    "content": "/* { dg-additional-options \"-fPIC\" { target fpic } }  */\n\ntypedef unsigned long word32;\ntypedef unsigned char byte;\ntypedef struct cast256_instance { word32 l_key[96];} cast256_key;\nword32 cast256_sbox[4][256] = {};\nvoid\nkey (cast256_key *key, const word32 *in_key, const int key_len)\n{\n  word32 i, j, t, u, cm, cr, lk[8], tm[8], tr[8];\n  for (i = 0; i < 96; i += 8)\n    {\n      for (j = 0; j < 8; ++j)\n\t{\n\t  tm[j] = cm;\n\t  cm += 0x6ed9eba1;\n\t  tr[j] = cr;\n\t  cr += 17;\n\t}\n      t = (((tm[0] + lk[7]) << ((word32)(tr[0] & 31)))\n\t   | ((tm[0] + lk[7]) >> (32 - (word32)(tr[0] & 31))));\n      u = cast256_sbox[0][((byte)((t) >> (8 * 3)))];\n      u ^= cast256_sbox[1][((byte)((t) >> (8 * 2)))];\n      lk[7] ^= u;\n      for (j = 0; j < 8; ++j)\n\t{\n\t  cm += 0x6ed9eba1;\n\t  tr[j] = cr;\n\t  cr += 17;\n\t}\n      t = (((tm[0] + lk[7]) << ((word32)(tr[0] & 31)))\n\t   | ((tm[0] + lk[7]) >> (32 - (word32)(tr[0] & 31))));\n      u = cast256_sbox[0][((byte)((t) >> (8 * 3)))];\n      u ^= cast256_sbox[1][((byte)((t) >> (8 * 2)))];\n      u -= cast256_sbox[2][((byte)((t) >> (8 * 1)))];\n      lk[2] ^= u;\n      lk[7] ^= u;\n      key->l_key[i + 1] = lk[2];\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65163.c",
    "content": "/* PR target/65163  */\n\ntypedef unsigned int uint32_t;\ntypedef unsigned short uint16_t;\nunion unaligned_32 { uint32_t l; } __attribute__((packed));\nunion unaligned_16 { uint16_t l; } __attribute__((packed));\n\nint\ntest_00 (unsigned char* buf, int bits_per_component)\n{\n  (((union unaligned_32*)(buf))->l) =\n    __builtin_bswap32 (bits_per_component == 10 ? 1 : 0);\n  return 0;\n}\n\nint\ntest_01 (unsigned char* buf, int bits_per_component)\n{\n  (((union unaligned_16*)(buf))->l) =\n    __builtin_bswap16 (bits_per_component == 10 ? 1 : 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65241.c",
    "content": "enum E { A, B, C, D };\nvoid fn4 (void);\n\nint\nfn1 (enum E p1)\n{\n  static int w[D];\n  if (w[p1])\n    switch (p1)\n      case C:\n      w[p1] = 0;\n}\n\nvoid\nfn2 (p1)\n{\n  fn1 (p1);\n}\n\nvoid\nfn3 (enum E p1)\n{\n  fn2 (p1);\n  fn4 ();\n  fn2 (p1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65540.c",
    "content": "long double func1 (long double x)\n{\n  if (x > 0.0)\n    return x;\n  else if (x < 0.0)\n    return -x;\n  else\n    return x;\n}\n\nlong double func2 (long double x)\n{\n  if (x > 0.0)\n    return x;\n  else if (x < 0.0)\n    return -x;\n  else\n    return x;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65593.c",
    "content": "/* PR target/65593 */\n/* { dg-additional-options \"-fpie\" { target pie } } */\n\n#include \"pr20928.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65595.c",
    "content": "extern void *memcpy(void *, const void *, unsigned long);\nstruct in6_addr {\n  struct {\n    int u6_addr32[4];\n  };\n};\nstruct foo {\n  struct in6_addr daddr;\n  struct in6_addr saddr;\n} a;\nextern void ip6_route_output(struct foo, int);\nint b;\nstatic void find_route_ipv6(struct in6_addr *p1) {\n  if (p1)\n    memcpy(0, p1, sizeof(struct in6_addr));\n  ip6_route_output(a, b);\n}\nvoid cxgbi_ep_connect() { find_route_ipv6(0); }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65680.c",
    "content": "/* PR middle-end/65680 */\n/* { dg-do compile { target lp64 } } */\n\nstruct S\n{\n  int f : 1;\n} a[100000000000000001][3];\n\nvoid\nfoo (void)\n{\n  struct S b = { 0 };\n  a[100000000000000000][0] = b;\n}\n\nvoid\nbar (void)\n{\n  a[100000000000000000][0].f = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65735.c",
    "content": "/* PR tree-optimization/65735 */\n\nint foo (void);\n\nvoid\nbar (int a, int b, int c)\n{\n  while (!a)\n    {\n      c = foo ();\n      if (c == 7)\n\tc = b;\n      switch (c)\n\t{\n\tcase 1:\n\t  a = b++;\n\t  if (b)\n\t    b = 1;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65803.c",
    "content": "/* { dg-options \"-fno-strict-overflow\" } */\ntypedef unsigned char __uint8_t;\ntypedef __uint8_t uint8_t;\ntypedef uint8_t u8_t;\ntypedef struct ip_addr ip_addr_t;\nchar *\nipaddr_ntoa_r (const ip_addr_t * addr, char *buf, int buflen)\n{\n  char inv[3];\n  char *rp;\n  u8_t *ap;\n  u8_t n;\n  u8_t i;\n  int len = 0;\n  for (n = 0; n < 4; n++)\n    {\n      while (*ap);\n      while (i--)\n\t{\n\t  if (len++ >= buflen)\n\t    return ((void *) 0);\n\t  *rp++ = inv[i];\n\t} ap++;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65873.c",
    "content": "typedef __SIZE_TYPE__ size_t;\n\nextern inline __attribute__ ((__always_inline__, __gnu_inline__, __artificial__, __nothrow__, __leaf__)) void *\nmemcpy (void *__restrict __dest, const void *__restrict __src, size_t __len)\n{\n  return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));\n}\n\n__attribute__((optimize (\"Ofast\"))) void\nbar (void *d, void *s, size_t l)\n{\n  memcpy (d, s, l);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr65875.c",
    "content": "/* PR tree-optimization/65875 */\n\nint a, b, c, d, e, f, g;\n\nvoid\nfoo (void)\n{\n  long h = 0, i;\n  if (g < 0)\n    i = -g;\n  for (; b;)\n    for (; c;)\n      if (e)\n\th = 1;\n  for (; f;)\n    if (a)\n      break;\n  if (h > i)\n    while (h > i)\n      {\n\td = 0;\n\th--;\n      }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr66168.c",
    "content": "int a, b;\n\nvoid\nfn1 ()\n{\n  for (;;)\n    {\n      for (b = 0; b < 3; b++)\n\t{\n\t  char e[2];\n\t  char f = e[1];\n\t  a ^= f ? 1 / f : 0;\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr67106.c",
    "content": "/* { dg-options \"-g -fpack-struct\" } */\ntypedef struct S S;\n\nstruct S\n{\n  struct\n  {\n    S *s;\n  };\n  int a;\n};\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr67143.c",
    "content": "long a, c;\nint b;\nint d;\nvoid ut_dbg_assertion_failed() __attribute__((noreturn));\nlong dict_index_is_spatial(int *);\nvoid btr_block_get_func(char *);\nlong btr_page_get_level_low(unsigned char *);\nvoid btr_validate_level(long p1) {\n  unsigned char *e;\n  while (p1 != btr_page_get_level_low(e)) {\n    if (__builtin_expect(b, 0))\n      ut_dbg_assertion_failed();\n    if (dict_index_is_spatial(&d))\n      while (c != 5535) {\n        __sync_add_and_fetch(&a, 536870912);\n        btr_block_get_func(\"\");\n      }\n  }\n  for (long i; i; ++i)\n    btr_validate_level(-i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr67506.c",
    "content": "extern struct _IO_FILE *stderr;\ntypedef long integer;\ntypedef unsigned char byte;\nshort nl;\nbyte * tfmfilearray;\ninteger charbase, ligkernbase;\nunsigned char charsonline;\nshort c;\nunsigned short r;\nstruct {\n  short cc;\n  integer rr;\n} labeltable[259];\nshort sortptr;\nunsigned char activity[(32510) + 1];\ninteger ai, acti;\nextern void _IO_putc (char, struct _IO_FILE *);\n\nvoid\nmainbody (void)\n{\n  register integer for_end;\n  if (c <= for_end)\n    do {\n      if (((tfmfilearray + 1001)[4 * (charbase + c) + 2] % 4) == 1)\n\t{\n\t  if ( r < nl )\n\t    ;\n\t  else\n\t    {\n\t      while (labeltable[sortptr ].rr > r)\n\t\tlabeltable[sortptr + 1 ]= labeltable[sortptr];\n\t    }\n\t}\n    } while (c++ < for_end);\n\n  if (ai <= for_end)\n    do {\n      if (activity[ai]== 2)\n\t{\n\t  r = (tfmfilearray + 1001)[4 * (ligkernbase + (ai))];\n\t  if (r < 128)\n\t    {\n\t      r = r + ai + 1 ;\n\t      if (r >= nl)\n\t\t{\n\t\t  if (charsonline > 0)\n\t\t    _IO_putc ('\\n', stderr);\n\t\t}\n\t    }\n\t}\n    } while (ai++ < for_end);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr67816.c",
    "content": "int a, c, d, e;\nint b[10];\nvoid fn1() {\n  int i, f = 0;\n  for (;;) {\n    i = 0;\n    for (; i < a; i++)\n      if (c) {\n        if (b[i])\n          f = 1;\n      } else if (b[i])\n        f = 0;\n    if (f)\n      d++;\n    while (e)\n      ;\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr68013.c",
    "content": "int a, b, c, d, e, f;\n\nvoid\nfn1 ()\n{\n  for (; e;)\n    {\n      e = f;\n      for (; b;)\n\t{\n\t  b = a;\n\t  f = a || d ? 0 : c;\n\t}\n      d = 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69102.c",
    "content": "/* { dg-options \"-Og -fPIC -fschedule-insns2 -fselective-scheduling2 -fno-tree-fre --param=max-sched-extend-regions-iters=10\" } */\nvoid bar (unsigned int);\n\nvoid\nfoo (void)\n{\n  char buf[1] = { 3 };\n  const char *p = buf;\n  const char **q = &p;\n  unsigned int ch;\n  switch (**q)\n    {\n    case 1:  ch = 5; break;\n    case 2:  ch = 4; break;\n    case 3:  ch = 3; break;\n    case 4:  ch = 2; break;\n    case 5:  ch = 1; break;\n    default: ch = 0; break;\n    }\n  bar (ch);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69161.c",
    "content": "/* PR target/69161.  */\n\nchar a;\nint b, c, d, e;\n\nvoid\nfoo (void)\n{\n  int f;\n  for (f = 0; f <= 4; f++)\n    {\n      for (d = 0; d < 20; d++)\n\t{\n\t  __INTPTR_TYPE__ g = (__INTPTR_TYPE__) & c;\n\t  b &= (0 != g) > e;\n\t}\n      e &= a;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69209.c",
    "content": "/* PR tree-optimization/69209 */\n\nint a, c, *d, e;\n\nvoid foo (void) __attribute__ ((__noreturn__));\n\nint\nbar (void)\n{\n  int f;\n  if (a)\n    {\n      if (e)\n\tfoo ();\n      foo ();\n    }\n  if (d != &f)\n    foo ();\n  if (!c)\n    foo ();\n  return f;\n}\n\nvoid\nbaz ()\n{\n  bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69214.c",
    "content": "/* PR tree-optimization/69214 */\n\nextern void bar (void);\nextern int __setjmp (char *);\n\nvoid\nfoo (char *p)\n{\n  int d = 0;\n  bar ();\n  if (__setjmp (p))\n    return;\n  long a = d;\n  d = 8;\n  if (!a)\n    bar ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69740-1.c",
    "content": "char a;\nshort b;\nvoid fn1() {\n  if (b)\n    ;\n  else {\n    int c[1] = {0};\n  l1:;\n  }\n  if (a)\n    goto l1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69740-2.c",
    "content": "inline int foo(int *p1, int p2) {\n  int z = *p1;\n  while (z > p2)\n    p2 = 2;\n  return z;\n}\nint main() {\n  int i;\n  for (;;) {\n    int j, k;\n    i = foo(&k, 7);\n    if (k)\n      j = i;\n    else\n      k = j;\n    if (2 != j)\n      __builtin_abort();\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69989-2.c",
    "content": "int a, b, d;\nshort c[] = {4073709551611, 1, 4, 4};\n\nvoid fn1() {\n  if (a)\n    goto LABEL_vhvhP;\n  for (;;) {\n    for (; b; b++)\n      d = c[b + 3] | c[b];\n  LABEL_vhvhP:\n    if (d)\n      break;\n  }\n}\n\nint main() { return 0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr69999.c",
    "content": "int uh;\n\nvoid\nha(void)\n{\n  while (uh) {\n    for (uh = 0; uh < 1; ++uh) {\n      uh = 0;\n      if (uh != 0)\n ts:\n        uh %= uh;\n    }\n    ++uh;\n  }\n  goto ts;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70061.c",
    "content": "typedef int v8si __attribute__ ((vector_size (32)));\n\nint\nfoo(v8si c, v8si d)\n{\nl0:\n  if (c[2])\n    d ^= c;\n  return d[3];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70190.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\n\nint\nfn1 ()\n{\n  static char a[] = \"foo\";\n  static void *b[] = { &&l1, &&l2 };\n  goto *(b[1]);\n l1: goto *(a[0]);\n l2: return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70199.c",
    "content": "static volatile int v = 0;\nstatic\nvoid benchmark(long runs) {\n  void* labels[] = {\n    &&l0, &&l1, &&l2\n  };\n  for(unsigned int mask = 0x1F; mask > 0; mask >>= 1) {\n    unsigned lfsr = 0xACE1u;\n    long n = 10000000;\n    while(n > 0) {\n      l2: v;\n      l1: v;\n      goto *labels[lfsr & mask];\n      l0: n--;\n    }\n  }\n}\nint f(void) {\n  benchmark(10000000);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70240.c",
    "content": "typedef short v16hi __attribute__ ((vector_size (32)));\ntypedef int v8si __attribute__ ((vector_size (32)));\ntypedef long long v4di __attribute__ ((vector_size (32)));\n\nint\nfoo(int u16_0, int u32_0, int u64_0, int u16_1, int u32_1, int u64_1, v16hi v32u16_0, v8si v32u32_0, v4di v32u64_0, v16hi v32u16_1, v8si v32u32_1, v4di v32u64_1)\n{\n  do {\n    v32u16_1 += (v16hi){ v32u32_1[7], ~v32u32_1[3], 0, v32u64_0[0]};\n    u32_0 = (u32_0 << 31) | (u32_0 >> ~v32u32_0[1]);\n    u64_0 += 1;\n    v32u64_0[2] <<= v32u64_0[2] & 63;\n    u16_1 = (u16_1 >> (v32u16_0[11] & 15)) | (u16_1 << (-v32u16_0[11] & 15));\n    v32u16_0 -= ~v32u16_1;\n    v32u32_1[5] += u32_1;\n    if (v32u32_1[3] >= 0) {\n      u64_1 -= ~v32u64_1[1];\n      v32u16_1 += (v16hi){ -u64_1, ~u32_0, ~u16_1, v32u32_1[1], 0, ~v32u16_1[2], ~v32u64_1[2], ~v32u32_0[7]};\n    }\n    v32u64_1 += (v4di){0, 0, ~v32u32_0[5]};\n    v32u32_1 *= (v8si){0, ~v32u32_1[6]};\n    v32u64_0[3] &= 0x1234;\n    v32u64_0 += (v4di){v32u32_1[6]};\n  } while (u16_0 < 0x1234);\n  return u64_0 + u16_1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70263-1.c",
    "content": "int a[91];\nint b, c;\nvoid fn1() {\n  int n, m;\n  do {\n    a[c--];\n    a[--c] = m;\n    a[--m] = b;\n  } while (n);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70355.c",
    "content": "/* { dg-require-effective-target int128 } */\n/* { dg-additional-options \"-g\" } */\n\ntypedef unsigned __int128 v2ti __attribute__ ((vector_size (32)));\n\nunsigned\nfoo (unsigned i, v2ti v)\n{\n  do {\n    i--;\n    v %= ~v;\n  } while (i);\n  return v[0] + v[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70633.c",
    "content": "/* PR middle-end/70633 */\n\ntypedef long V __attribute__((vector_size (4 * sizeof (long))));\n\nvoid foo (V *);\n\nvoid\nbar (void)\n{ \n  V b = { (long) bar, 0, 0, 0 };\n  foo (&b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr70916.c",
    "content": "/* PR tree-optimization/70916 */\n\nint a, b, c, d, i, k;\nint static *e = &b, *j;\nint **f;\nint static ***g = &f;\nint *h;\nvoid\nfn1 ()\n{\n  for (;;)\n    {\n      int l[1] = { };\n      int m = (__UINTPTR_TYPE__) l;\n      for (; d; d--)\n\t{\n\t  int ****n;\n\t  int *****o = &n;\n\t  i = a & 7 ? : a;\n\t  *e = (((*o = &g) != (int ****) g) < h[c], 0) || k;\n\t  if (*e)\n\t    {\n\t      **n = &j;\n\t      *e = (__UINTPTR_TYPE__) h;\n\t    }\n\t}\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr71693.c",
    "content": "/* PR middle-end/71693 */\n\nunsigned short v;\n\nvoid\nfoo (int x)\n{\n  v = ((((unsigned short) (0x0001 | (x & 0x0070) | 0x0100) & 0x00ffU) << 8)\n       | (((unsigned short) (0x0001 | (x & 0x0070) | 0x0100) >> 8) & 0x00ffU));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr71916.c",
    "content": "/* PR rtl-optimization/71916 */\n\nint a, b, c, d, f, g;\nshort h;\n\nshort\nfoo (short p1)\n{\n  return a >= 2 || p1 > 7 >> a ? p1 : p1 << a;\n}\n\nvoid\nbar (void)\n{\n  for (;;)\n    {\n      int i, j[3];\n      h = b >= 2 ? d : d >> b;\n      if (foo (f > h ^ c))\n\t{\n\t  d = 0;\n\t  while (f <= 2)\n\t    {\n\t      char k[2];\n\t      for (;;)\n\t\tk[i++] = 7;\n\t    }\n\t}\n      else\n\tfor (;;)\n\t  g = j[2];\n      if (g)\n\tfor (;;)\n\t  ;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pr72802.c",
    "content": "static a[];\nstatic b, h, m, n, o, p, q, t, u, v, t5, t6, t16, t17, t18, t25;\nc;\nstatic volatile d;\nstatic volatile e;\nstatic volatile f;\nstatic volatile g;\nj;\nstatic volatile k;\nstatic volatile l;\nstatic volatile r;\nconst volatile s;\nstatic volatile w;\nstatic volatile x;\nconst volatile y;\nstatic volatile z;\nstatic volatile t1;\nstatic volatile t2;\nconst t3;\nt4;\nconst volatile t8;\nconst volatile t9;\nconst volatile t10;\nstatic volatile t11;\nstatic volatile t12;\nstatic volatile t13;\nstatic volatile t14;\nconst volatile t15;\nstatic volatile t19;\nstatic volatile t20;\nconst volatile t21;\nstatic volatile t22;\nstatic volatile t23;\nconst volatile t24;\n*t29;\nfn1() { b = 5; }\nfn2(long);\n#pragma pack(1)\nstruct S0 {\n  short f3;\n  float f4;\n  signed f5\n};\nconst struct S0 t7[] = {};\nstatic fn3() {\n  int t26[] = {};\n  int t27[10] = {};\n  --t25;\n  if (fn4()) {\n    t5++;\n    fn5();\n    int t28[] = {t26, t27};\n    return;\n  }\n}\nfn6() {\n  int i, t30 = 0;\n  if (fn6 == 2)\n    t30 = 1;\n  {\n    int t31, i = 0;\n    for (; i < 256; i++) {\n      t31 = i;\n      if (i & 1)\n        t31 = 0;\n      a[i] = t31;\n    }\n    i = 0;\n    for (; i < 3; i++)\n      t29[i] = t6;\n    fn7();\n    fn3();\n    t4 = c = j = 0;\n  }\n  fn2(h);\n  if (t30)\n    printf(b);\n  g;\n  fn2(g);\n  printf(b);\n  f;\n  fn2(f);\n  if (t30)\n    printf(b);\n  e;\n  fn2(e);\n  printf(b);\n  fn8();\n  d;\n  fn2(d);\n  if (t30)\n    printf(b);\n  l;\n  fn2(l);\n  printf(b);\n  k;\n  fn2(k);\n  if (t30)\n    printf(b);\n  printf(b);\n  for (; i; i++) {\n    y;\n    fn2(y);\n    printf(b);\n    x;\n    fn2(x);\n    if (t30)\n      printf(b);\n    w;\n    fn2(w);\n    printf(b);\n    fn2(v);\n    printf(b);\n    fn2(u);\n    if (t30)\n      printf(b);\n    fn2(t);\n    printf(b);\n    s;\n    fn2(s);\n    if (t30)\n      printf(b);\n    r;\n    fn2(r);\n    printf(b);\n    fn2(q);\n    if (t30)\n      printf(b);\n    fn2(p);\n    printf(\"\", b);\n    fn2(o);\n    printf(b);\n    fn2(n);\n    if (t30)\n      printf(b);\n    fn2(m);\n    printf(b);\n  }\n  fn2(z);\n  if (t30)\n    printf(b);\n  printf(\"\", t3);\n  t2;\n  fn2(t2);\n  printf(b);\n  t1;\n  fn2(t1);\n  if (t30)\n    printf(b);\n  for (; i < 6; i++) {\n    t10;\n    fn2(t10);\n    printf(b);\n    t9;\n    fn2(t9);\n    if (t30)\n      printf(b);\n    t8;\n    fn2(t8);\n    printf(b);\n    fn2(t7[i].f3);\n    if (t30)\n      printf(b);\n    fn2(t7[i].f4);\n    printf(b);\n    fn2(t7[i].f5);\n    if (t30)\n      printf(b);\n    t15;\n    fn2(t15);\n    printf(b);\n    t14;\n    fn2(t14);\n    if (t30)\n      printf(b);\n    t13;\n    fn2(t13);\n    printf(b);\n    t12;\n    fn2(t12);\n    if (t30)\n      printf(b);\n    t11;\n    fn2(t11);\n    printf(b);\n    t21;\n    fn2(t21);\n    if (t30)\n      printf(b);\n    t20;\n    fn2(t20);\n    fn2(t19);\n    if (t30)\n      printf(b);\n    fn2(t18);\n    printf(b);\n    fn2(t17);\n    printf(b);\n    fn2(t16);\n    printf(b);\n  }\n  t24;\n  t24;\n  if (t30)\n    printf(b);\n  printf(t23);\n  t22;\n  t22;\n  if (t30)\n    printf(b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pret-arg.c",
    "content": "foo (a, b, c, d, e, f, g, h, i, j, xx)\n     double xx;\n{\n  return xx + 1.2345;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pta-1.c",
    "content": "typedef struct JSObject JSObject;\ntypedef struct JSObjectMap *(*JSNewObjectMapOp) (JSObject *obj);\ntypedef JSObject *(*JSGetMethodOp) (JSObject *obj);\nstruct JSObjectOps {\n    JSNewObjectMapOp newObjectMap;\n};\nstruct JSXMLObjectOps {\n    struct JSObjectOps base;\n    JSGetMethodOp getMethod;\n};\nstruct JSObjectMap {\n    struct JSObjectOps *ops;\n};\nstruct JSObject {\n    struct JSObjectMap *map;\n};\n\nstruct JSXMLObjectOps js_XMLObjectOps;\n\n\n/* We need to create SFT's for the entire structure when this address is taken, \n   not just the part in the component reference itself.  */\nJSObject *JS_GetMethod(JSObject *obj)\n{\n    if (obj->map->ops == &js_XMLObjectOps.base) {\n        struct JSXMLObjectOps *ops;\n        ops = (struct JSXMLObjectOps *) obj->map->ops;\n        obj = ops->getMethod(obj);\n    }\n    return obj;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ptr-conv-1.c",
    "content": "/* The intermediate conversion to __PTRDIFF_TYPE__ could be lost,\n   resulting in an \"invalid types in nop conversion\" ICE.  */\nlong long a;\nvoid\nf (void)\n{\n  int c = 1;\n  volatile int *p = &c;\n  a = (long long) (__PTRDIFF_TYPE__) p;\n  *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pyr.c",
    "content": "foo (char *a)\n{\n  char b;\n  int c;\n  b = *a;\n  c = b;\n  if (c < 0)\n    return 1;\n  a[1] = b;\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/pyr2.c",
    "content": "foo (a)\n{\n  return ((int *)0)[a];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/q.c",
    "content": "\nunsigned\nreg0indreg1 (r0, p1)\n     unsigned short  r0;  unsigned short p1;\n{\n  return (r0 + p1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/r.c",
    "content": "r (a, b)\n{\n  if (a < b)\n    return 1;\n  else\n    return 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/r1.c",
    "content": "void assert (a) {if (a != 1) abort ();}\n\nint h1 (int *p) {return *p & 255;}\n\nvoid p1 () {int a = 0x01020304; assert (h1 (&a) == 0x04);}\n\n\nint h2 (a) {return a > 0;}\n\np2 () {assert (h2 (1));}\n\nh3 (int *p)\n{\n  *p |= 255;\n}\n\np3 ()\n{\n  int *p;\n  h3 (p);\n}\n\nmain ()\n{\n  p1 ();\n  p2 ();\n  p3 ();\n  puts (\"Compiler test passed.\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/rel.c",
    "content": "foo (int *c, int b)\n{\n  int a;\n\n  a = *c + b;\n  c[1] = a;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/rmsc.c",
    "content": "\ncc1 (x, y)\n     int x, y;\n{\n  int z;\n  z = x - y;\n  if (x >= y)\n    return z + 1;\n  else\n    return z + 0;\n}\n\ncc2 (x, y)\n     int x, y;\n{\n  int z;\n\n  z = x - y;\n  if (z >= 0)\n    return z + 1;\n  else\n    return z + 0;\n}\n\ncc3 (x, y)\n     unsigned x, y;\n{\n  unsigned z;\n  z = x - y;\n  if (x >= y)\n    return z + 1;\n  else\n    return z + 0;\n}\n\ncc4 (x, y)\n     unsigned x, y;\n{\n  unsigned z;\n\n  z = x - y;\n  if (z >= 0)\n    return z + 1;\n  else\n    return z + 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/round.c",
    "content": "foo (a)\n     double a;\n{\n  printf (\"%d\\n\", (int) a);\n}\n\nmain ()\n{\n  foo (1.6);\n  foo (1.4);\n  foo (-1.4);\n  foo (-1.6);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/run.c",
    "content": "main ()\n{\n  typedef short int xtype;\n\n  xtype i;\n  xtype ii;\n\n  for (i = 0; i < 100; i++)\n    for (ii = 65535; --ii;)\n      ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/s.c",
    "content": "struct foo\n{\n  int a, b, c, d;\n  double doubl;\n} s1, s2;\n\nstruct foo\nstructret (s1, i1, i2, s2)\n     struct foo s1, s2;\n     int i1, i2;\n{\n  if (i1 != i2)\n    {\n      if (i1 < i2)\n\treturn s1;\n      else\n\treturn s2;\n    }\n  s2.a = 11;\n  s2.b = 22;\n  s2.c = s1.c;\n  s2.d = s1.d;\n  return s2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sar.c",
    "content": "struct foo\n{\n  char a;\n} foo[100];\n\nmain ()\n{\n  foo[1].a = '1';\n  foo[2].a = '2';\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sc.c",
    "content": "foo (a, b)\n     int a, b;\n{\n  return (a < 0) | (a <= 0) | (a == 0) | (a != 0) | (a >= 0) | (a > 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/scal.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nint g1, g2;\n\nvoid\nwrite_at (addr, off, val)\n     int *addr;\n     int off;\n     int val;\n{\n  g2 = 1;\n  addr[off] = val;\n  g2++;\n}\n\nmain ()\n{\n  g2 = 12;\n  write_at (&g1, &g2 - &g1, 12345);\n  printf (\"%d\\n\", g2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/scc.c",
    "content": "foo (a, b)\n{\n  if (a < 0)\n    goto ret1;\n  if (a == 0)\n    return 2;\n  return 3;\n ret1:\n  return 1;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/scond.c",
    "content": "scond (a, b, c, d)\n{\n  return (a > b) & (c < d);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/section.c",
    "content": "/* { dg-do compile } */\n\n/* { dg-require-effective-target named_sections } */\nextern int __attribute__ ((__section__(\".init.text\"))) elv_register(void)\n{\n return 0;\n}\nextern typeof(elv_register) elv_register;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/selfrec.c",
    "content": "int\nfoo (a)\n{\n  return foo (a - 1) * a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/seq.c",
    "content": "foo (a)\n{\n  return a < 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/set386.c",
    "content": "foo (a, p)\n     int *p;\n{\n  *p = a > 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/set88.c",
    "content": "foo (a)\n{\n  return -1 << a;\n}\n\nbar (a, b)\n{\n  return b | (-1 << a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sh.c",
    "content": "foo (a, b)\n{\n  return a << b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/shand.c",
    "content": "int\nfoo (x, c)\n     int x;\n{\n  return x >> 24 & 0xff;\n}\n\nbar (x)\n{\n  return (int)(x & 0xfffff) << 13;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/shft.c",
    "content": "foo (a)\n     int a;\n{\n  int b = 8;\n\n  if ((a << b) >= 0)\n    return 1;\n  return a;\n}\n\nmain ()\n{\n  if (foo (0x00ffffff) == 1)\n    puts (\"y\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/shift.c",
    "content": "foo (a)\n{\n  if (a >= 0)\n    return (unsigned) a << 10;\n  else\n    return (int) a << 10;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/shloop.c",
    "content": "main ()\n{\n  int volatile p;\n  int i;\n  for (i = 10000000; i > 0; i--)\n    p = i >> 10;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/shm.c",
    "content": "foo (int *p)\n{\n  int a = *p;\n  return a >> 24;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/signext.c",
    "content": "void longprint (x)\n     long long x;\n{\n  printf (\" %d, %d\\n\", (unsigned) ((unsigned long long) x >> 32),\n\t  (unsigned) x);\n}\n\nvoid\nk_min (p, qa, d)\n     int d;\n{\n  int s = 1;\n  long long x;\n\n  if (s >= d)\n    s -= d;\n\n  x = ((long long)((8 * s) % 3) + qa) % d;\n  longprint (x);\n}\n\nint\nmain ()\n{\n  k_min (100003, -600017, 3);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/signext2.c",
    "content": "long long\nfoo (a)\n     int a;\n{\n  return a;\n}\n\nmain ()\n{\n  printf (\"%d\\n\", (int) (foo (-1) >> 32));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sim.c",
    "content": "main ()\n{\n  int i;\n\n  for (i = 1;  i < 10000; i++)\n    ;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-1.c",
    "content": "typedef int v2si __attribute__ ((vector_size (8)));\ntypedef unsigned di __attribute__ ((mode(DI)));\nvoid foo(unsigned long);\nvoid bar() {\n    v2si x = { 1, 2 };\n    foo((di) x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-2.c",
    "content": "typedef float floatvect2 __attribute__((vector_size (8)));\n\ntypedef union\n{\n    floatvect2 vector;\n    float f[2];\n}resfloatvect2;\n\nvoid tempf(float *x, float *y)\n{\n        floatvect2 temp={x[0],x[1]};\n        floatvect2 temp1={y[0],y[1]};\n        resfloatvect2 temp2;\n        temp2.vector=temp+temp1;\n        x[0]=temp2.f[0];\n        x[1]=temp2.f[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-3.c",
    "content": "#include <float.h>\n\n/* If double is not wider than float, we probably don't have DFmode,\n   or at least it's not as wide as double.  */\n#if DBL_MANT_DIG > FLT_MANT_DIG\ntypedef double floatvect2 __attribute__((vector_size (16)));\n\ntypedef union\n{\n    floatvect2 vector;\n    double f[2];\n}resfloatvect2;\n\nvoid tempf(double *x, double *y)\n{\n        floatvect2 temp={x[0],x[1]};\n        floatvect2 temp1={y[0],y[1]};\n        resfloatvect2 temp2;\n        temp2.vector=temp+temp1;\n        x[0]=temp2.f[0];\n        x[1]=temp2.f[1];\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-4.c",
    "content": "typedef float floatvect2 __attribute__((vector_size (16)));\n\ntypedef union\n{\n    floatvect2 vector;\n    float f[2];\n}resfloatvect2;\n\nvoid tempf(floatvect2 *x, floatvect2 *y)\n{\n        floatvect2 temp= *x;\n        floatvect2 temp1=*y;\n        resfloatvect2 temp2;\n        *x=temp+temp1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-5.c",
    "content": "#define vector64 __attribute__((vector_size(8)))\n\nmain(){\n\n vector64 int  c;\nvector64 int a = {1, -1};\nvector64 int b = {2, -2};\nc = -a + b*b*(-1LL);\n/* c is now {5, 3} */\n\n printf(\"result is %llx\\n\", (long long)c); \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simd-6.c",
    "content": "/* { dg-options \"-std=gnu89\" } */\n\ntypedef int __attribute__((vector_size (8))) vec;\n\nvec a[] = {(vec) {1, 2}, {3, 4}};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/simple.c",
    "content": "foo (a)\n{\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sizeof-macros-1.c",
    "content": "/* This checks the gcc builtin macros defined to the byte\n   sizes of C standard types.  */\n\nint a[sizeof(int) == __SIZEOF_INT__ ? 1 : -1];\nint b[sizeof(long) == __SIZEOF_LONG__ ? 1 : -1];\nint c[sizeof(long long) == __SIZEOF_LONG_LONG__ ? 1 : -1];\nint d[sizeof(short) == __SIZEOF_SHORT__ ? 1 : -1];\nint e[sizeof(void *) == __SIZEOF_POINTER__ ? 1 : -1];\nint f[sizeof(float) == __SIZEOF_FLOAT__ ? 1 : -1];\nint g[sizeof(double) == __SIZEOF_DOUBLE__ ? 1 : -1];\nint h[sizeof(long double) == __SIZEOF_LONG_DOUBLE__ ? 1 : -1];\nint i[sizeof(__SIZE_TYPE__) == __SIZEOF_SIZE_T__ ? 1 : -1];\nint j[sizeof(__WCHAR_TYPE__) == __SIZEOF_WCHAR_T__ ? 1 : -1];\nint k[sizeof(__WINT_TYPE__) == __SIZEOF_WINT_T__ ? 1 : -1];\nint l[sizeof(__PTRDIFF_TYPE__) == __SIZEOF_PTRDIFF_T__ ? 1 : -1];\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sne.c",
    "content": "foo (double a)\n{\n  return (a != 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sound.c",
    "content": "\nmain ()\n{\n  char audio[8192];\n  int i;\n\n  for (i = 0;  i < 4095;  i += 1)\n    audio[i] = i / 8,\n    audio[8191 - i] = i / 8;\n\n  for (;;)\n    write (1, audio, 8192);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sparcbug.c",
    "content": "foo (a)\n{\n  int b = a;\n  return b + 8762345;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/speed.c",
    "content": "main ()\n{\n  int i;\n\n  for (i = 5000000; i >=0; i--)\n    {\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sra-1.c",
    "content": "/* Let gimple verifier check what SRA does to unions and single-field\n   strucutres . */\n\nstruct sim_struct\n{\n  int x;\n};\n\nextern struct sim_struct get_x(void);\n\nstruct sim_struct foo (void)\n{\n  struct sim_struct simple;\n\n  simple = get_x ();\n  if (simple.x % 2)\n    simple.x = 39;\n  else\n    simple.x -=8;\n\n  return simple;\n}\n\nstruct sim_cmplx\n{\n  _Complex double c;\n};\n\nextern struct sim_cmplx get_sc (void);\n\n_Complex double foo_c (void)\n{\n  struct sim_cmplx simple;\n\n  simple = get_sc ();\n  if (__real__ simple.c > 200.3)\n    __imag__ simple.c -= 2.4;\n\n  return simple.c;\n}\n\n\nunion sim_union\n{\n  int i;\n  float d;\n};\n\nextern union sim_union get_y (void);\n\nunion sim_union bar (void)\n{\n  union sim_union simple;\n\n  simple = get_y ();\n  if (simple.d > 8.2)\n    simple.i = 300;\n\n  return simple;\n}\n\nextern int get_int (void);\n\nint bar_i (void)\n{\n  union sim_union simple;\n\n  simple = get_y ();\n  if (simple.d > 8.2)\n    simple.i = get_int ();\n\n  return simple.i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ssa-pre-1.c",
    "content": "void washQtoM3(double m[9], double q[4]);\ndouble sqrt(double);\nint f(int samp)\n{\n      double clp[2], xyz[3], q[4], len;\n      double mRF[9];\n      int xi;\n      for (xi=0; xi<samp; xi++)\n\t    {\n\t\t    q[0] = 1.0;\n\t\t    q[1] = ( ((double)(1)-(-1))*((double)((float)xi)-(-0.5)) / ((double)(samp-0.5)-(-0.5)) + (-1));\n\t\t    q[2] = ( ((double)(1)-(-1))*((double)((float)0)-(-0.5)) / ((double)(samp-0.5)-(-0.5)) + (-1));\n\t\t    q[3] = ( ((double)(1)-(-1))*((double)((float)0)-(-0.5)) / ((double)(samp-0.5)-(-0.5)) + (-1));\n\t\t    len = (sqrt((((q))[0]*((q))[0] + ((q))[1]*((q))[1] + ((q))[2]*((q))[2] + ((q))[3]*((q))[3])));\n\t\t  ((q)[0] = (q)[0]*1.0/len, (q)[1] = (q)[1]*1.0/len, (q)[2] = (q)[2]*1.0/len, (q)[3] = (q)[3]*1.0/len);\n\t\t washQtoM3(mRF, q);\n\t\t      }\n      return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/statement-expression-1.c",
    "content": "/* PR middle-end/30253, We would ICE with statement expressions\n   in a conditional expression because we forgot to update the wrapper\n   function for the gimple modify statement.  */\n\n#define f(x) ({ unsigned tmp=x; tmp; })\n\nunsigned foo(unsigned x) {\n  return __builtin_constant_p(x) ? 0 : f(x);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/stor.c",
    "content": "#define C 1\n\nfoo (p)\n     int *p;\n{\n  p[0] = C;\n  p[1] = C;\n  p[2] = C;\n  p[3] = C;\n  p[4] = C;\n  p[5] = C;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/store0.c",
    "content": "foo (int *p)\n{\n  p[10] = 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/storecc.c",
    "content": "foo (char *p, int a)\n{\n  *p = a;\n  if ((char) a)\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/str.c",
    "content": "typedef struct\n{\n  char a;\n  char b;\n} foo;\n\nbar ()\n{\n  foo foobar[100];\n  foobar[1].a = 'a';\n  foobar[2].a = 'b';\n  barfoo (foobar);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/strcpy-1.c",
    "content": "\n\ntypedef struct\n{\n  char str[20];\n}STACK;\nSTACK stack[15];\nint level;\nrezero ()\n{\n  level = 0;\n  __builtin_strcpy (stack[level].str, \"\");\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/strcpy-2.c",
    "content": "char wrkstr_un[270];\nextern void\nLoadUserAlph (char *s)\n{\n  s = &wrkstr_un[0];\n  __builtin_strcpy (s, \"\");\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/stru.c",
    "content": "struct foo\n{\n  int a, b, c;\n};\n\nfoo (struct foo *a)\n{\n  a[0] = a[1];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/struct-non-lval-1.c",
    "content": "/* Bug c/17855.  */\nstruct foo {char x, y, z[2];};\nstruct foo f();\nvoid bar(int baz)\n{\n  f().z[baz] = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/struct-non-lval-2.c",
    "content": "/* Bug c/17855, using conditional expression for non-lvalue.  */\nstruct foo {char x, y, z[2];};\nstruct foo p, q; int r;\nvoid bar(int baz)\n{\n  (r ? p : q).z[baz] = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/struct-non-lval-3.c",
    "content": "/* Bug c/17855, using assignment for non-lvalue.  */\nstruct foo {char x, y, z[2];};\nstruct foo p, q;\nvoid bar(int baz)\n{\n  (p = q).z[baz] = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/structret.c",
    "content": "struct foo\n{\n  int a, b, c, d;\n  double doubl;\n} s1, s2;\n\n#ifndef ONLY2\n\nstruct foo\nstructret (s1, i1, i2, s2)\n     struct foo s1, s2;\n     int i1, i2;\n{\n  if (i1 != i2)\n    {\n      if (i1 < i2)\n\treturn s1;\n      else\n\treturn s2;\n    }\n  s2.a = 11;\n  s2.b = 22;\n  s2.c = s1.c;\n  s2.d = s1.d;\n  return s2;\n}\n\n#endif\n\n#ifndef ONLY1\n\nstruct foo\nmani (a, b)\n{\n  return structret (s1, a, b, s2);\n}\n\ninit ()\n{\n  s1.a = 1;\n  s1.b = 2;\n  s1.c = 3;\n  s1.d = 4;\n  s1.doubl = 3.1415;\n  s2.a = -1;\n  s2.b = -2;\n  s2.c = -3;\n  s2.d = -4;\n  s2.doubl = 2.71818;\n}\n\nmain ()\n{\n  struct foo s;\n\n  init ();\n  s = mani (1, 1);\n  printf (\"%d, %d, %d, %d : %f\\n\", s.a, s.b, s.c, s.d, s.doubl);\n\n  init ();\n  s = mani (2, 1);\n  printf (\"%d, %d, %d, %d : %f\\n\", s.a, s.b, s.c, s.d, s.doubl);\n\n  init ();\n  s = mani (1, 2);\n  printf (\"%d, %d, %d, %d : %f\\n\", s.a, s.b, s.c, s.d, s.doubl);\n}\n\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/structs.c",
    "content": "/* Copyright 1996, 1999, 2007 Free Software Foundation, Inc.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n \n   You should have received a copy of the GNU General Public License\n   along with GCC; see the file COPYING3.  If not see\n   <http://www.gnu.org/licenses/>.\n\n   Please email any bugs, comments, and/or additions to this file to:\n   bug-gdb@prep.ai.mit.edu  */\n\nstruct struct1 { char a;};\nstruct struct2 { char a, b;};\nstruct struct3 { char a, b, c; };\nstruct struct4 { char a, b, c, d; };\nstruct struct5 { char a, b, c, d, e; };\nstruct struct6 { char a, b, c, d, e, f; };\nstruct struct7 { char a, b, c, d, e, f, g; };\nstruct struct8 { char a, b, c, d, e, f, g, h; };\nstruct struct9 { char a, b, c, d, e, f, g, h, i; };\nstruct struct10 { char a, b, c, d, e, f, g, h, i, j; };\nstruct struct11 { char a, b, c, d, e, f, g, h, i, j, k; };\nstruct struct12 { char a, b, c, d, e, f, g, h, i, j, k, l; };\nstruct struct16 { char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; };\n\nstruct struct1 foo1 = {'1'},  L1;\nstruct struct2 foo2 = { 'a', 'b'},  L2;\nstruct struct3 foo3 = { 'A', 'B', 'C'},  L3;\nstruct struct4 foo4 = {'1', '2', '3', '4'},  L4;\nstruct struct5 foo5 = {'a', 'b', 'c', 'd', 'e'},  L5;\nstruct struct6 foo6 = {'A', 'B', 'C', 'D', 'E', 'F'},  L6;\nstruct struct7 foo7 = {'1', '2', '3', '4', '5', '6', '7'},  L7;\nstruct struct8 foo8 = {'1', '2', '3', '4', '5', '6', '7', '8'},  L8;\nstruct struct9 foo9 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'},  L9;\nstruct struct10 foo10 = {\n  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'},  L10;\nstruct struct11 foo11 = {\n  '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, L11;\nstruct struct12 foo12 = {\n  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'}, L12;\nstruct struct16 foo16 = {\n  'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}, L16;\n\nstruct struct1  fun1()\n{\n  return foo1;  \n}\nstruct struct2  fun2()\n{\n  return foo2;\n}\nstruct struct3  fun3()\n{\n  return foo3;\n}\nstruct struct4  fun4()\n{\n  return foo4;\n}\nstruct struct5  fun5()\n{\n  return foo5;\n}\nstruct struct6  fun6()\n{\n  return foo6;\n}\nstruct struct7  fun7()\n{\n  return foo7;\n}\nstruct struct8  fun8()\n{\n  return foo8;\n}\nstruct struct9  fun9()\n{\n  return foo9;\n}\nstruct struct10 fun10()\n{\n  return foo10; \n}\nstruct struct11 fun11()\n{\n  return foo11; \n}\nstruct struct12 fun12()\n{\n  return foo12; \n}\nstruct struct16 fun16()\n{\n  return foo16; \n}\n\n#ifdef PROTOTYPES\nvoid Fun1(struct struct1 foo1)\n#else\nvoid Fun1(foo1)\n     struct struct1 foo1;\n#endif\n{\n  L1 = foo1;\n}\n#ifdef PROTOTYPES\nvoid Fun2(struct struct2 foo2)\n#else\nvoid Fun2(foo2)\n     struct struct2 foo2;\n#endif\n{\n  L2 = foo2;\n}\n#ifdef PROTOTYPES\nvoid Fun3(struct struct3 foo3)\n#else\nvoid Fun3(foo3)\n     struct struct3 foo3;\n#endif\n{\n  L3 = foo3;\n}\n#ifdef PROTOTYPES\nvoid Fun4(struct struct4 foo4)\n#else\nvoid Fun4(foo4)\n     struct struct4 foo4;\n#endif\n{\n  L4 = foo4;\n}\n#ifdef PROTOTYPES\nvoid Fun5(struct struct5 foo5)\n#else\nvoid Fun5(foo5)\n     struct struct5 foo5;\n#endif\n{\n  L5 = foo5;\n}\n#ifdef PROTOTYPES\nvoid Fun6(struct struct6 foo6)\n#else\nvoid Fun6(foo6)\n     struct struct6 foo6;\n#endif\n{\n  L6 = foo6;\n}\n#ifdef PROTOTYPES\nvoid Fun7(struct struct7 foo7)\n#else\nvoid Fun7(foo7)\n     struct struct7 foo7;\n#endif\n{\n  L7 = foo7;\n}\n#ifdef PROTOTYPES\nvoid Fun8(struct struct8 foo8)\n#else\nvoid Fun8(foo8)\n     struct struct8 foo8;\n#endif\n{\n  L8 = foo8;\n}\n#ifdef PROTOTYPES\nvoid Fun9(struct struct9 foo9)\n#else\nvoid Fun9(foo9)\n     struct struct9 foo9;\n#endif\n{\n  L9 = foo9;\n}\n#ifdef PROTOTYPES\nvoid Fun10(struct struct10 foo10)\n#else\nvoid Fun10(foo10)\n     struct struct10 foo10;\n#endif\n{\n  L10 = foo10; \n}\n#ifdef PROTOTYPES\nvoid Fun11(struct struct11 foo11)\n#else\nvoid Fun11(foo11)\n     struct struct11 foo11;\n#endif\n{\n  L11 = foo11; \n}\n#ifdef PROTOTYPES\nvoid Fun12(struct struct12 foo12)\n#else\nvoid Fun12(foo12)\n     struct struct12 foo12;\n#endif\n{\n  L12 = foo12; \n}\n#ifdef PROTOTYPES\nvoid Fun16(struct struct16 foo16)\n#else\nvoid Fun16(foo16)\n     struct struct16 foo16;\n#endif\n{\n  L16 = foo16; \n}\n\nint main()\n{\n#ifdef usestubs\n  set_debug_traps();\n  breakpoint();\n#endif\n\n  /* TEST C FUNCTIONS */\n  L1  = fun1();\t\n  L2  = fun2();\t\n  L3  = fun3();\t\n  L4  = fun4();\t\n  L5  = fun5();\t\n  L6  = fun6();\t\n  L7  = fun7();\t\n  L8  = fun8();\t\n  L9  = fun9();\t\n  L10 = fun10();\n  L11 = fun11();\n  L12 = fun12();\n  L16 = fun16();\n\n  foo1.a = foo2.a = foo3.a = foo4.a = foo5.a = foo6.a = foo7.a = foo8.a =\n    foo9.a = foo10.a = foo11.a = foo12.a = foo16.a = '$';\n\n  Fun1(foo1);\t\n  Fun2(foo2);\t\n  Fun3(foo3);\t\n  Fun4(foo4);\t\n  Fun5(foo5);\t\n  Fun6(foo6);\t\n  Fun7(foo7);\t\n  Fun8(foo8);\t\n  Fun9(foo9);\t\n  Fun10(foo10);\n  Fun11(foo11);\n  Fun12(foo12);\n  Fun16(foo16);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/stuct.c",
    "content": "#ifdef STACK_SIZE\n#define SIZE STACK_SIZE / 8\n#else\n#define SIZE 10000000\n#endif\n\nstruct foo\n{\n  int a, b, c;\n  int arr[SIZE];\n};\n\nstruct foo s, ss;\n\nmain ()\n{\n\n  s.b = 2;\n  s.c = 3;\n  ss.b = 2;\n  ss.c = 3;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sub32.c",
    "content": "foo (a)\n{\n  return a + 32;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/subcc.c",
    "content": "int foo (a, c)\n{\n  int b;\n\n  if (a + c >= 0)\t\t\t/* b < 0 ==== a < 10? */\n    return a | 0x80000000;\n  return 0;\n}\n\nvoid bar (a)\n     int a;\n{\n  if (foo (a, 10) & 0x80000000)\n    printf (\"y\");\n  else\n    printf (\"n\");\n}\n\nint main ()\n{\n  bar (0);\n  bar (1);\n  bar (-1);\n  bar (10);\n  bar (-10);\n  bar (11);\n  bar (-11);\n  bar (0x7fffffff);\n  bar (-0x7fffffff);\n\n  puts (\"\");\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/subcse.c",
    "content": "foo (a, b, p)\n     int *p;\n{\n  p[0] = 1230 - a;\n  p[1] = 1230 - b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/switch-1.c",
    "content": "/* PR middle-end/26557.  */\nconst int struct_test[1] = {1};\nvoid g();\nvoid f() {\n  switch(struct_test[0]) {\n    case 1: g();\n  }\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sym.c",
    "content": "foo ()\n{\n  return (int) &foo;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/symconst.c",
    "content": "foo ()\n{\n  return (int)foo;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sync-1.c",
    "content": "/* { dg-message \"note: '__sync_fetch_and_nand' changed semantics in GCC 4.4\" \"fetch_and_nand\" { target *-*-* } 0 } */\n/* { dg-message \"note: '__sync_nand_and_fetch' changed semantics in GCC 4.4\" \"nand_and_fetch\" { target *-*-* } 0 } */\n/* { dg-options \"-ffat-lto-objects\" } */\n\n/* Validate that each of the __sync builtins compiles.  This won't \n   necessarily link, since the target might not support the builtin,\n   so this may result in external library calls.  */\n\nsigned char sc;\nunsigned char uc;\nsigned short ss;\nunsigned short us;\nsigned int si;\nunsigned int ui;\nsigned long sl;\nunsigned long ul;\nsigned long long sll;\nunsigned long long ull;\nvoid *vp;\nint *ip;\nstruct S { struct S *next; int x; } *sp;\n\nvoid test_op_ignore (void)\n{\n  (void) __sync_fetch_and_add (&sc, 1);\n  (void) __sync_fetch_and_add (&uc, 1);\n  (void) __sync_fetch_and_add (&ss, 1);\n  (void) __sync_fetch_and_add (&us, 1);\n  (void) __sync_fetch_and_add (&si, 1);\n  (void) __sync_fetch_and_add (&ui, 1);\n  (void) __sync_fetch_and_add (&sl, 1);\n  (void) __sync_fetch_and_add (&ul, 1);\n  (void) __sync_fetch_and_add (&sll, 1);\n  (void) __sync_fetch_and_add (&ull, 1);\n\n  (void) __sync_fetch_and_sub (&sc, 1);\n  (void) __sync_fetch_and_sub (&uc, 1);\n  (void) __sync_fetch_and_sub (&ss, 1);\n  (void) __sync_fetch_and_sub (&us, 1);\n  (void) __sync_fetch_and_sub (&si, 1);\n  (void) __sync_fetch_and_sub (&ui, 1);\n  (void) __sync_fetch_and_sub (&sl, 1);\n  (void) __sync_fetch_and_sub (&ul, 1);\n  (void) __sync_fetch_and_sub (&sll, 1);\n  (void) __sync_fetch_and_sub (&ull, 1);\n\n  (void) __sync_fetch_and_or (&sc, 1);\n  (void) __sync_fetch_and_or (&uc, 1);\n  (void) __sync_fetch_and_or (&ss, 1);\n  (void) __sync_fetch_and_or (&us, 1);\n  (void) __sync_fetch_and_or (&si, 1);\n  (void) __sync_fetch_and_or (&ui, 1);\n  (void) __sync_fetch_and_or (&sl, 1);\n  (void) __sync_fetch_and_or (&ul, 1);\n  (void) __sync_fetch_and_or (&sll, 1);\n  (void) __sync_fetch_and_or (&ull, 1);\n\n  (void) __sync_fetch_and_xor (&sc, 1);\n  (void) __sync_fetch_and_xor (&uc, 1);\n  (void) __sync_fetch_and_xor (&ss, 1);\n  (void) __sync_fetch_and_xor (&us, 1);\n  (void) __sync_fetch_and_xor (&si, 1);\n  (void) __sync_fetch_and_xor (&ui, 1);\n  (void) __sync_fetch_and_xor (&sl, 1);\n  (void) __sync_fetch_and_xor (&ul, 1);\n  (void) __sync_fetch_and_xor (&sll, 1);\n  (void) __sync_fetch_and_xor (&ull, 1);\n\n  (void) __sync_fetch_and_and (&sc, 1);\n  (void) __sync_fetch_and_and (&uc, 1);\n  (void) __sync_fetch_and_and (&ss, 1);\n  (void) __sync_fetch_and_and (&us, 1);\n  (void) __sync_fetch_and_and (&si, 1);\n  (void) __sync_fetch_and_and (&ui, 1);\n  (void) __sync_fetch_and_and (&sl, 1);\n  (void) __sync_fetch_and_and (&ul, 1);\n  (void) __sync_fetch_and_and (&sll, 1);\n  (void) __sync_fetch_and_and (&ull, 1);\n\n  (void) __sync_fetch_and_nand (&sc, 1);\n  (void) __sync_fetch_and_nand (&uc, 1);\n  (void) __sync_fetch_and_nand (&ss, 1);\n  (void) __sync_fetch_and_nand (&us, 1);\n  (void) __sync_fetch_and_nand (&si, 1);\n  (void) __sync_fetch_and_nand (&ui, 1);\n  (void) __sync_fetch_and_nand (&sl, 1);\n  (void) __sync_fetch_and_nand (&ul, 1);\n  (void) __sync_fetch_and_nand (&sll, 1);\n  (void) __sync_fetch_and_nand (&ull, 1);\n}\n\nvoid test_fetch_and_op (void)\n{\n  sc = __sync_fetch_and_add (&sc, 11);\n  uc = __sync_fetch_and_add (&uc, 11);\n  ss = __sync_fetch_and_add (&ss, 11);\n  us = __sync_fetch_and_add (&us, 11);\n  si = __sync_fetch_and_add (&si, 11);\n  ui = __sync_fetch_and_add (&ui, 11);\n  sl = __sync_fetch_and_add (&sl, 11);\n  ul = __sync_fetch_and_add (&ul, 11);\n  sll = __sync_fetch_and_add (&sll, 11);\n  ull = __sync_fetch_and_add (&ull, 11);\n\n  sc = __sync_fetch_and_sub (&sc, 11);\n  uc = __sync_fetch_and_sub (&uc, 11);\n  ss = __sync_fetch_and_sub (&ss, 11);\n  us = __sync_fetch_and_sub (&us, 11);\n  si = __sync_fetch_and_sub (&si, 11);\n  ui = __sync_fetch_and_sub (&ui, 11);\n  sl = __sync_fetch_and_sub (&sl, 11);\n  ul = __sync_fetch_and_sub (&ul, 11);\n  sll = __sync_fetch_and_sub (&sll, 11);\n  ull = __sync_fetch_and_sub (&ull, 11);\n\n  sc = __sync_fetch_and_or (&sc, 11);\n  uc = __sync_fetch_and_or (&uc, 11);\n  ss = __sync_fetch_and_or (&ss, 11);\n  us = __sync_fetch_and_or (&us, 11);\n  si = __sync_fetch_and_or (&si, 11);\n  ui = __sync_fetch_and_or (&ui, 11);\n  sl = __sync_fetch_and_or (&sl, 11);\n  ul = __sync_fetch_and_or (&ul, 11);\n  sll = __sync_fetch_and_or (&sll, 11);\n  ull = __sync_fetch_and_or (&ull, 11);\n\n  sc = __sync_fetch_and_xor (&sc, 11);\n  uc = __sync_fetch_and_xor (&uc, 11);\n  ss = __sync_fetch_and_xor (&ss, 11);\n  us = __sync_fetch_and_xor (&us, 11);\n  si = __sync_fetch_and_xor (&si, 11);\n  ui = __sync_fetch_and_xor (&ui, 11);\n  sl = __sync_fetch_and_xor (&sl, 11);\n  ul = __sync_fetch_and_xor (&ul, 11);\n  sll = __sync_fetch_and_xor (&sll, 11);\n  ull = __sync_fetch_and_xor (&ull, 11);\n\n  sc = __sync_fetch_and_and (&sc, 11);\n  uc = __sync_fetch_and_and (&uc, 11);\n  ss = __sync_fetch_and_and (&ss, 11);\n  us = __sync_fetch_and_and (&us, 11);\n  si = __sync_fetch_and_and (&si, 11);\n  ui = __sync_fetch_and_and (&ui, 11);\n  sl = __sync_fetch_and_and (&sl, 11);\n  ul = __sync_fetch_and_and (&ul, 11);\n  sll = __sync_fetch_and_and (&sll, 11);\n  ull = __sync_fetch_and_and (&ull, 11);\n\n  sc = __sync_fetch_and_nand (&sc, 11);\n  uc = __sync_fetch_and_nand (&uc, 11);\n  ss = __sync_fetch_and_nand (&ss, 11);\n  us = __sync_fetch_and_nand (&us, 11);\n  si = __sync_fetch_and_nand (&si, 11);\n  ui = __sync_fetch_and_nand (&ui, 11);\n  sl = __sync_fetch_and_nand (&sl, 11);\n  ul = __sync_fetch_and_nand (&ul, 11);\n  sll = __sync_fetch_and_nand (&sll, 11);\n  ull = __sync_fetch_and_nand (&ull, 11);\n}\n\nvoid test_op_and_fetch (void)\n{\n  sc = __sync_add_and_fetch (&sc, uc);\n  uc = __sync_add_and_fetch (&uc, uc);\n  ss = __sync_add_and_fetch (&ss, uc);\n  us = __sync_add_and_fetch (&us, uc);\n  si = __sync_add_and_fetch (&si, uc);\n  ui = __sync_add_and_fetch (&ui, uc);\n  sl = __sync_add_and_fetch (&sl, uc);\n  ul = __sync_add_and_fetch (&ul, uc);\n  sll = __sync_add_and_fetch (&sll, uc);\n  ull = __sync_add_and_fetch (&ull, uc);\n\n  sc = __sync_sub_and_fetch (&sc, uc);\n  uc = __sync_sub_and_fetch (&uc, uc);\n  ss = __sync_sub_and_fetch (&ss, uc);\n  us = __sync_sub_and_fetch (&us, uc);\n  si = __sync_sub_and_fetch (&si, uc);\n  ui = __sync_sub_and_fetch (&ui, uc);\n  sl = __sync_sub_and_fetch (&sl, uc);\n  ul = __sync_sub_and_fetch (&ul, uc);\n  sll = __sync_sub_and_fetch (&sll, uc);\n  ull = __sync_sub_and_fetch (&ull, uc);\n\n  sc = __sync_or_and_fetch (&sc, uc);\n  uc = __sync_or_and_fetch (&uc, uc);\n  ss = __sync_or_and_fetch (&ss, uc);\n  us = __sync_or_and_fetch (&us, uc);\n  si = __sync_or_and_fetch (&si, uc);\n  ui = __sync_or_and_fetch (&ui, uc);\n  sl = __sync_or_and_fetch (&sl, uc);\n  ul = __sync_or_and_fetch (&ul, uc);\n  sll = __sync_or_and_fetch (&sll, uc);\n  ull = __sync_or_and_fetch (&ull, uc);\n\n  sc = __sync_xor_and_fetch (&sc, uc);\n  uc = __sync_xor_and_fetch (&uc, uc);\n  ss = __sync_xor_and_fetch (&ss, uc);\n  us = __sync_xor_and_fetch (&us, uc);\n  si = __sync_xor_and_fetch (&si, uc);\n  ui = __sync_xor_and_fetch (&ui, uc);\n  sl = __sync_xor_and_fetch (&sl, uc);\n  ul = __sync_xor_and_fetch (&ul, uc);\n  sll = __sync_xor_and_fetch (&sll, uc);\n  ull = __sync_xor_and_fetch (&ull, uc);\n\n  sc = __sync_and_and_fetch (&sc, uc);\n  uc = __sync_and_and_fetch (&uc, uc);\n  ss = __sync_and_and_fetch (&ss, uc);\n  us = __sync_and_and_fetch (&us, uc);\n  si = __sync_and_and_fetch (&si, uc);\n  ui = __sync_and_and_fetch (&ui, uc);\n  sl = __sync_and_and_fetch (&sl, uc);\n  ul = __sync_and_and_fetch (&ul, uc);\n  sll = __sync_and_and_fetch (&sll, uc);\n  ull = __sync_and_and_fetch (&ull, uc);\n\n  sc = __sync_nand_and_fetch (&sc, uc);\n  uc = __sync_nand_and_fetch (&uc, uc);\n  ss = __sync_nand_and_fetch (&ss, uc);\n  us = __sync_nand_and_fetch (&us, uc);\n  si = __sync_nand_and_fetch (&si, uc);\n  ui = __sync_nand_and_fetch (&ui, uc);\n  sl = __sync_nand_and_fetch (&sl, uc);\n  ul = __sync_nand_and_fetch (&ul, uc);\n  sll = __sync_nand_and_fetch (&sll, uc);\n  ull = __sync_nand_and_fetch (&ull, uc);\n}\n\nvoid test_compare_and_swap (void)\n{\n  sc = __sync_val_compare_and_swap (&sc, uc, sc);\n  uc = __sync_val_compare_and_swap (&uc, uc, sc);\n  ss = __sync_val_compare_and_swap (&ss, uc, sc);\n  us = __sync_val_compare_and_swap (&us, uc, sc);\n  si = __sync_val_compare_and_swap (&si, uc, sc);\n  ui = __sync_val_compare_and_swap (&ui, uc, sc);\n  sl = __sync_val_compare_and_swap (&sl, uc, sc);\n  ul = __sync_val_compare_and_swap (&ul, uc, sc);\n  sll = __sync_val_compare_and_swap (&sll, uc, sc);\n  ull = __sync_val_compare_and_swap (&ull, uc, sc);\n\n  ui = __sync_bool_compare_and_swap (&sc, uc, sc);\n  ui = __sync_bool_compare_and_swap (&uc, uc, sc);\n  ui = __sync_bool_compare_and_swap (&ss, uc, sc);\n  ui = __sync_bool_compare_and_swap (&us, uc, sc);\n  ui = __sync_bool_compare_and_swap (&si, uc, sc);\n  ui = __sync_bool_compare_and_swap (&ui, uc, sc);\n  ui = __sync_bool_compare_and_swap (&sl, uc, sc);\n  ui = __sync_bool_compare_and_swap (&ul, uc, sc);\n  ui = __sync_bool_compare_and_swap (&sll, uc, sc);\n  ui = __sync_bool_compare_and_swap (&ull, uc, sc);\n}\n\nvoid test_lock (void)\n{\n  sc = __sync_lock_test_and_set (&sc, 1);\n  uc = __sync_lock_test_and_set (&uc, 1);\n  ss = __sync_lock_test_and_set (&ss, 1);\n  us = __sync_lock_test_and_set (&us, 1);\n  si = __sync_lock_test_and_set (&si, 1);\n  ui = __sync_lock_test_and_set (&ui, 1);\n  sl = __sync_lock_test_and_set (&sl, 1);\n  ul = __sync_lock_test_and_set (&ul, 1);\n  sll = __sync_lock_test_and_set (&sll, 1);\n  ull = __sync_lock_test_and_set (&ull, 1);\n\n  __sync_synchronize ();\n\n  __sync_lock_release (&sc);\n  __sync_lock_release (&uc);\n  __sync_lock_release (&ss);\n  __sync_lock_release (&us);\n  __sync_lock_release (&si);\n  __sync_lock_release (&ui);\n  __sync_lock_release (&sl);\n  __sync_lock_release (&ul);\n  __sync_lock_release (&sll);\n  __sync_lock_release (&ull);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sync-2.c",
    "content": "/* { dg-message \"note: '__sync_fetch_and_nand' changed semantics in GCC 4.4\" \"\" { target *-*-* } 0 } */\n/* { dg-options \"-ffat-lto-objects\" } */\n\n/* Validate that each of the __sync builtins compiles.  This won't \n   necessarily link, since the target might not support the builtin,\n   so this may result in external library calls.  */\n\nsigned char sc;\nunsigned char uc;\nsigned short ss;\nunsigned short us;\nsigned int si;\nunsigned int ui;\nsigned long sl;\nunsigned long ul;\nsigned long long sll;\nunsigned long long ull;\n\nvoid test_op_ignore (void)\n{\n  (void) __sync_fetch_and_add (&sc, -1);\n  (void) __sync_fetch_and_add (&uc, -1);\n  (void) __sync_fetch_and_add (&ss, -1);\n  (void) __sync_fetch_and_add (&us, -1);\n  (void) __sync_fetch_and_add (&si, -1);\n  (void) __sync_fetch_and_add (&ui, -1);\n  (void) __sync_fetch_and_add (&sl, -1);\n  (void) __sync_fetch_and_add (&ul, -1);\n  (void) __sync_fetch_and_add (&sll, -1);\n  (void) __sync_fetch_and_add (&ull, -1);\n\n  (void) __sync_fetch_and_sub (&sc, -1);\n  (void) __sync_fetch_and_sub (&uc, -1);\n  (void) __sync_fetch_and_sub (&ss, -1);\n  (void) __sync_fetch_and_sub (&us, -1);\n  (void) __sync_fetch_and_sub (&si, -1);\n  (void) __sync_fetch_and_sub (&ui, -1);\n  (void) __sync_fetch_and_sub (&sl, -1);\n  (void) __sync_fetch_and_sub (&ul, -1);\n  (void) __sync_fetch_and_sub (&sll, -1);\n  (void) __sync_fetch_and_sub (&ull, -1);\n\n  (void) __sync_fetch_and_or (&sc, -1);\n  (void) __sync_fetch_and_or (&uc, -1);\n  (void) __sync_fetch_and_or (&ss, -1);\n  (void) __sync_fetch_and_or (&us, -1);\n  (void) __sync_fetch_and_or (&si, -1);\n  (void) __sync_fetch_and_or (&ui, -1);\n  (void) __sync_fetch_and_or (&sl, -1);\n  (void) __sync_fetch_and_or (&ul, -1);\n  (void) __sync_fetch_and_or (&sll, -1);\n  (void) __sync_fetch_and_or (&ull, -1);\n\n  (void) __sync_fetch_and_xor (&sc, -1);\n  (void) __sync_fetch_and_xor (&uc, -1);\n  (void) __sync_fetch_and_xor (&ss, -1);\n  (void) __sync_fetch_and_xor (&us, -1);\n  (void) __sync_fetch_and_xor (&si, -1);\n  (void) __sync_fetch_and_xor (&ui, -1);\n  (void) __sync_fetch_and_xor (&sl, -1);\n  (void) __sync_fetch_and_xor (&ul, -1);\n  (void) __sync_fetch_and_xor (&sll, -1);\n  (void) __sync_fetch_and_xor (&ull, -1);\n\n  (void) __sync_fetch_and_and (&sc, -1);\n  (void) __sync_fetch_and_and (&uc, -1);\n  (void) __sync_fetch_and_and (&ss, -1);\n  (void) __sync_fetch_and_and (&us, -1);\n  (void) __sync_fetch_and_and (&si, -1);\n  (void) __sync_fetch_and_and (&ui, -1);\n  (void) __sync_fetch_and_and (&sl, -1);\n  (void) __sync_fetch_and_and (&ul, -1);\n  (void) __sync_fetch_and_and (&sll, -1);\n  (void) __sync_fetch_and_and (&ull, -1);\n\n  (void) __sync_fetch_and_nand (&sc, -1);\n  (void) __sync_fetch_and_nand (&uc, -1);\n  (void) __sync_fetch_and_nand (&ss, -1);\n  (void) __sync_fetch_and_nand (&us, -1);\n  (void) __sync_fetch_and_nand (&si, -1);\n  (void) __sync_fetch_and_nand (&ui, -1);\n  (void) __sync_fetch_and_nand (&sl, -1);\n  (void) __sync_fetch_and_nand (&ul, -1);\n  (void) __sync_fetch_and_nand (&sll, -1);\n  (void) __sync_fetch_and_nand (&ull, -1);\n}\n\nvoid test_fetch_and_op (void)\n{\n  sc = __sync_fetch_and_add (&sc, -11);\n  uc = __sync_fetch_and_add (&uc, -11);\n  ss = __sync_fetch_and_add (&ss, -11);\n  us = __sync_fetch_and_add (&us, -11);\n  si = __sync_fetch_and_add (&si, -11);\n  ui = __sync_fetch_and_add (&ui, -11);\n  sl = __sync_fetch_and_add (&sl, -11);\n  ul = __sync_fetch_and_add (&ul, -11);\n  sll = __sync_fetch_and_add (&sll, -11);\n  ull = __sync_fetch_and_add (&ull, -11);\n\n  sc = __sync_fetch_and_sub (&sc, -11);\n  uc = __sync_fetch_and_sub (&uc, -11);\n  ss = __sync_fetch_and_sub (&ss, -11);\n  us = __sync_fetch_and_sub (&us, -11);\n  si = __sync_fetch_and_sub (&si, -11);\n  ui = __sync_fetch_and_sub (&ui, -11);\n  sl = __sync_fetch_and_sub (&sl, -11);\n  ul = __sync_fetch_and_sub (&ul, -11);\n  sll = __sync_fetch_and_sub (&sll, -11);\n  ull = __sync_fetch_and_sub (&ull, -11);\n\n  sc = __sync_fetch_and_or (&sc, -11);\n  uc = __sync_fetch_and_or (&uc, -11);\n  ss = __sync_fetch_and_or (&ss, -11);\n  us = __sync_fetch_and_or (&us, -11);\n  si = __sync_fetch_and_or (&si, -11);\n  ui = __sync_fetch_and_or (&ui, -11);\n  sl = __sync_fetch_and_or (&sl, -11);\n  ul = __sync_fetch_and_or (&ul, -11);\n  sll = __sync_fetch_and_or (&sll, -11);\n  ull = __sync_fetch_and_or (&ull, -11);\n\n  sc = __sync_fetch_and_xor (&sc, -11);\n  uc = __sync_fetch_and_xor (&uc, -11);\n  ss = __sync_fetch_and_xor (&ss, -11);\n  us = __sync_fetch_and_xor (&us, -11);\n  si = __sync_fetch_and_xor (&si, -11);\n  ui = __sync_fetch_and_xor (&ui, -11);\n  sl = __sync_fetch_and_xor (&sl, -11);\n  ul = __sync_fetch_and_xor (&ul, -11);\n  sll = __sync_fetch_and_xor (&sll, -11);\n  ull = __sync_fetch_and_xor (&ull, -11);\n\n  sc = __sync_fetch_and_and (&sc, -11);\n  uc = __sync_fetch_and_and (&uc, -11);\n  ss = __sync_fetch_and_and (&ss, -11);\n  us = __sync_fetch_and_and (&us, -11);\n  si = __sync_fetch_and_and (&si, -11);\n  ui = __sync_fetch_and_and (&ui, -11);\n  sl = __sync_fetch_and_and (&sl, -11);\n  ul = __sync_fetch_and_and (&ul, -11);\n  sll = __sync_fetch_and_and (&sll, -11);\n  ull = __sync_fetch_and_and (&ull, -11);\n\n  sc = __sync_fetch_and_nand (&sc, -11);\n  uc = __sync_fetch_and_nand (&uc, -11);\n  ss = __sync_fetch_and_nand (&ss, -11);\n  us = __sync_fetch_and_nand (&us, -11);\n  si = __sync_fetch_and_nand (&si, -11);\n  ui = __sync_fetch_and_nand (&ui, -11);\n  sl = __sync_fetch_and_nand (&sl, -11);\n  ul = __sync_fetch_and_nand (&ul, -11);\n  sll = __sync_fetch_and_nand (&sll, -11);\n  ull = __sync_fetch_and_nand (&ull, -11);\n}\n\nvoid test_lock (void)\n{\n  sc = __sync_lock_test_and_set (&sc, -1);\n  uc = __sync_lock_test_and_set (&uc, -1);\n  ss = __sync_lock_test_and_set (&ss, -1);\n  us = __sync_lock_test_and_set (&us, -1);\n  si = __sync_lock_test_and_set (&si, -1);\n  ui = __sync_lock_test_and_set (&ui, -1);\n  sl = __sync_lock_test_and_set (&sl, -1);\n  ul = __sync_lock_test_and_set (&ul, -1);\n  sll = __sync_lock_test_and_set (&sll, -1);\n  ull = __sync_lock_test_and_set (&ull, -1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/sync-3.c",
    "content": "/* { dg-message \"note: '__sync_fetch_and_nand' changed semantics in GCC 4.4\" \"\" { target *-*-* } 0 } */\n/* { dg-options \"-ffat-lto-objects\" } */\n\n/* Validate that each of the __sync builtins compiles.  This won't \n   necessarily link, since the target might not support the builtin,\n   so this may result in external library calls.  */\n\nvoid test_op_ignore (void)\n{\nsigned char sc[2];\nunsigned char uc[2];\nsigned short ss[2];\nunsigned short us[2];\nsigned int si[2];\nunsigned int ui[2];\nsigned long sl[2];\nunsigned long ul[2];\nsigned long long sll[2];\nunsigned long long ull[2];\n  (void) __sync_fetch_and_add (&sc[1], -1);\n  (void) __sync_fetch_and_add (&uc[1], -1);\n  (void) __sync_fetch_and_add (&ss[1], -1);\n  (void) __sync_fetch_and_add (&us[1], -1);\n  (void) __sync_fetch_and_add (&si[1], -1);\n  (void) __sync_fetch_and_add (&ui[1], -1);\n  (void) __sync_fetch_and_add (&sl[1], -1);\n  (void) __sync_fetch_and_add (&ul[1], -1);\n  (void) __sync_fetch_and_add (&sll[1], -1);\n  (void) __sync_fetch_and_add (&ull[1], -1);\n\n  (void) __sync_fetch_and_sub (&sc[1], -1);\n  (void) __sync_fetch_and_sub (&uc[1], -1);\n  (void) __sync_fetch_and_sub (&ss[1], -1);\n  (void) __sync_fetch_and_sub (&us[1], -1);\n  (void) __sync_fetch_and_sub (&si[1], -1);\n  (void) __sync_fetch_and_sub (&ui[1], -1);\n  (void) __sync_fetch_and_sub (&sl[1], -1);\n  (void) __sync_fetch_and_sub (&ul[1], -1);\n  (void) __sync_fetch_and_sub (&sll[1], -1);\n  (void) __sync_fetch_and_sub (&ull[1], -1);\n\n  (void) __sync_fetch_and_or (&sc[1], -1);\n  (void) __sync_fetch_and_or (&uc[1], -1);\n  (void) __sync_fetch_and_or (&ss[1], -1);\n  (void) __sync_fetch_and_or (&us[1], -1);\n  (void) __sync_fetch_and_or (&si[1], -1);\n  (void) __sync_fetch_and_or (&ui[1], -1);\n  (void) __sync_fetch_and_or (&sl[1], -1);\n  (void) __sync_fetch_and_or (&ul[1], -1);\n  (void) __sync_fetch_and_or (&sll[1], -1);\n  (void) __sync_fetch_and_or (&ull[1], -1);\n\n  (void) __sync_fetch_and_xor (&sc[1], -1);\n  (void) __sync_fetch_and_xor (&uc[1], -1);\n  (void) __sync_fetch_and_xor (&ss[1], -1);\n  (void) __sync_fetch_and_xor (&us[1], -1);\n  (void) __sync_fetch_and_xor (&si[1], -1);\n  (void) __sync_fetch_and_xor (&ui[1], -1);\n  (void) __sync_fetch_and_xor (&sl[1], -1);\n  (void) __sync_fetch_and_xor (&ul[1], -1);\n  (void) __sync_fetch_and_xor (&sll[1], -1);\n  (void) __sync_fetch_and_xor (&ull[1], -1);\n\n  (void) __sync_fetch_and_and (&sc[1], -1);\n  (void) __sync_fetch_and_and (&uc[1], -1);\n  (void) __sync_fetch_and_and (&ss[1], -1);\n  (void) __sync_fetch_and_and (&us[1], -1);\n  (void) __sync_fetch_and_and (&si[1], -1);\n  (void) __sync_fetch_and_and (&ui[1], -1);\n  (void) __sync_fetch_and_and (&sl[1], -1);\n  (void) __sync_fetch_and_and (&ul[1], -1);\n  (void) __sync_fetch_and_and (&sll[1], -1);\n  (void) __sync_fetch_and_and (&ull[1], -1);\n\n  (void) __sync_fetch_and_nand (&sc[1], -1);\n  (void) __sync_fetch_and_nand (&uc[1], -1);\n  (void) __sync_fetch_and_nand (&ss[1], -1);\n  (void) __sync_fetch_and_nand (&us[1], -1);\n  (void) __sync_fetch_and_nand (&si[1], -1);\n  (void) __sync_fetch_and_nand (&ui[1], -1);\n  (void) __sync_fetch_and_nand (&sl[1], -1);\n  (void) __sync_fetch_and_nand (&ul[1], -1);\n  (void) __sync_fetch_and_nand (&sll[1], -1);\n  (void) __sync_fetch_and_nand (&ull[1], -1);\n}\n\nvoid test_fetch_and_op (void)\n{\nsigned char sc[2];\nunsigned char uc[2];\nsigned short ss[2];\nunsigned short us[2];\nsigned int si[2];\nunsigned int ui[2];\nsigned long sl[2];\nunsigned long ul[2];\nsigned long long sll[2];\nunsigned long long ull[2];\n  sc[1] = __sync_fetch_and_add (&sc[1], -11);\n  uc[1] = __sync_fetch_and_add (&uc[1], -11);\n  ss[1] = __sync_fetch_and_add (&ss[1], -11);\n  us[1] = __sync_fetch_and_add (&us[1], -11);\n  si[1] = __sync_fetch_and_add (&si[1], -11);\n  ui[1] = __sync_fetch_and_add (&ui[1], -11);\n  sl[1] = __sync_fetch_and_add (&sl[1], -11);\n  ul[1] = __sync_fetch_and_add (&ul[1], -11);\n  sll[1] = __sync_fetch_and_add (&sll[1], -11);\n  ull[1] = __sync_fetch_and_add (&ull[1], -11);\n\n  sc[1] = __sync_fetch_and_sub (&sc[1], -11);\n  uc[1] = __sync_fetch_and_sub (&uc[1], -11);\n  ss[1] = __sync_fetch_and_sub (&ss[1], -11);\n  us[1] = __sync_fetch_and_sub (&us[1], -11);\n  si[1] = __sync_fetch_and_sub (&si[1], -11);\n  ui[1] = __sync_fetch_and_sub (&ui[1], -11);\n  sl[1] = __sync_fetch_and_sub (&sl[1], -11);\n  ul[1] = __sync_fetch_and_sub (&ul[1], -11);\n  sll[1] = __sync_fetch_and_sub (&sll[1], -11);\n  ull[1] = __sync_fetch_and_sub (&ull[1], -11);\n\n  sc[1] = __sync_fetch_and_or (&sc[1], -11);\n  uc[1] = __sync_fetch_and_or (&uc[1], -11);\n  ss[1] = __sync_fetch_and_or (&ss[1], -11);\n  us[1] = __sync_fetch_and_or (&us[1], -11);\n  si[1] = __sync_fetch_and_or (&si[1], -11);\n  ui[1] = __sync_fetch_and_or (&ui[1], -11);\n  sl[1] = __sync_fetch_and_or (&sl[1], -11);\n  ul[1] = __sync_fetch_and_or (&ul[1], -11);\n  sll[1] = __sync_fetch_and_or (&sll[1], -11);\n  ull[1] = __sync_fetch_and_or (&ull[1], -11);\n\n  sc[1] = __sync_fetch_and_xor (&sc[1], -11);\n  uc[1] = __sync_fetch_and_xor (&uc[1], -11);\n  ss[1] = __sync_fetch_and_xor (&ss[1], -11);\n  us[1] = __sync_fetch_and_xor (&us[1], -11);\n  si[1] = __sync_fetch_and_xor (&si[1], -11);\n  ui[1] = __sync_fetch_and_xor (&ui[1], -11);\n  sl[1] = __sync_fetch_and_xor (&sl[1], -11);\n  ul[1] = __sync_fetch_and_xor (&ul[1], -11);\n  sll[1] = __sync_fetch_and_xor (&sll[1], -11);\n  ull[1] = __sync_fetch_and_xor (&ull[1], -11);\n\n  sc[1] = __sync_fetch_and_and (&sc[1], -11);\n  uc[1] = __sync_fetch_and_and (&uc[1], -11);\n  ss[1] = __sync_fetch_and_and (&ss[1], -11);\n  us[1] = __sync_fetch_and_and (&us[1], -11);\n  si[1] = __sync_fetch_and_and (&si[1], -11);\n  ui[1] = __sync_fetch_and_and (&ui[1], -11);\n  sl[1] = __sync_fetch_and_and (&sl[1], -11);\n  ul[1] = __sync_fetch_and_and (&ul[1], -11);\n  sll[1] = __sync_fetch_and_and (&sll[1], -11);\n  ull[1] = __sync_fetch_and_and (&ull[1], -11);\n\n  sc[1] = __sync_fetch_and_nand (&sc[1], -11);\n  uc[1] = __sync_fetch_and_nand (&uc[1], -11);\n  ss[1] = __sync_fetch_and_nand (&ss[1], -11);\n  us[1] = __sync_fetch_and_nand (&us[1], -11);\n  si[1] = __sync_fetch_and_nand (&si[1], -11);\n  ui[1] = __sync_fetch_and_nand (&ui[1], -11);\n  sl[1] = __sync_fetch_and_nand (&sl[1], -11);\n  ul[1] = __sync_fetch_and_nand (&ul[1], -11);\n  sll[1] = __sync_fetch_and_nand (&sll[1], -11);\n  ull[1] = __sync_fetch_and_nand (&ull[1], -11);\n}\n\nvoid test_lock (void)\n{\nsigned char sc[2];\nunsigned char uc[2];\nsigned short ss[2];\nunsigned short us[2];\nsigned int si[2];\nunsigned int ui[2];\nsigned long sl[2];\nunsigned long ul[2];\nsigned long long sll[2];\nunsigned long long ull[2];\n  sc[1] = __sync_lock_test_and_set (&sc[1], -1);\n  uc[1] = __sync_lock_test_and_set (&uc[1], -1);\n  ss[1] = __sync_lock_test_and_set (&ss[1], -1);\n  us[1] = __sync_lock_test_and_set (&us[1], -1);\n  si[1] = __sync_lock_test_and_set (&si[1], -1);\n  ui[1] = __sync_lock_test_and_set (&ui[1], -1);\n  sl[1] = __sync_lock_test_and_set (&sl[1], -1);\n  ul[1] = __sync_lock_test_and_set (&ul[1], -1);\n  sll[1] = __sync_lock_test_and_set (&sll[1], -1);\n  ull[1] = __sync_lock_test_and_set (&ull[1], -1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/t.c",
    "content": "#define B 95\n\nfoo (a, b, p)\n     unsigned a, b;\n     int *p;\n{\n  p[1] = a % B;\n  p[0] = a / B;\n}\n\nbar (a, b, p)\n     unsigned a, b;\n     int *p;\n{\n  p[0] = a / B;\n  p[1] = a % B;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/test-flow.c",
    "content": "foo (a, b, c, d)\n{\n  if (a < 0)\n    {\n      b = c;\n    }\n  else\n    {\n      b = d;\n    }\n  return b + 75;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/test-loop.c",
    "content": "main ()\n{\n  int i;\n  for (i = 100;  i >= -1; i--)\n    foo ();\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/test.c",
    "content": "foo (a)\n{\n  if (a & 38)\n    return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/time.c",
    "content": "main ()\n{\n  int i;\n  for (i = 3000000; --i;)\n    {\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/tmp.c",
    "content": "foo (a, b)\n{\n  return (a - b) == 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/trivial.c",
    "content": "foo () {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/trunc.c",
    "content": "main ()\n{\n  printf (\"%x, %x\\n\", (unsigned char) main, main);\n}\n\nfoo (p)\n     char *p;\n{\n  p[0] = (char)foo;\n  p[1] = (char)foo;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/trunctfdf.c",
    "content": "/* Sparc w/128-bit long double bombed on this because even though\n   the trunctfdf libcall passed the long double by reference, the\n   libcall was still marked as LCT_CONST instead of LCT_PURE.  */\n\ndouble *copy(long double *first, long double *last, double *result)\n{\n\tint n;\n\tfor (n = last - first; n > 0; --n) {\n\t\t*result = *first;\n\t\t++first;\n\t\t++result;\n\t}\n\treturn result;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/u.c",
    "content": "foo (a, b) { return a % b; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/udconvert.c",
    "content": "double\nunsigned_to_double1 (u)\n     unsigned u;\n{\n  double d;\n  d = (int) u;\t\t\t/* convert as from a *signed* integer */\n  return ((int) u < 0)\n    ? d + 4294967296.0\n      : d;\n}\n\n/* Alternatively */\n\ndouble\nunsigned_to_double2 (u)\n     unsigned u;\n{\n  double d;\n  u -= 2147483648;\t\t/* complement sign bit */\n  d = (int) u;\t\t\t/* convert as from a *signed* integer */\n  return d + 2147483648.0;\n}\n\nunsigned\ndouble_to_unsigned (d)\n     double d;\n{\n  d += 2147483648.0;\n  return ((int) d) - 2147483648;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/udivmod4.c",
    "content": "long long\nxlrandom ()\n{\n  long long x;\n  unsigned a;\n  int bits = 64;\n  unsigned b;\n\n  do\n    {\n      a = random ();\n      b = (a & 15) + 1;\n      x <<= b;\t\t\t\t/* shift up 1-16 steps */\n      a = (a >> 18) & 1;\n      if (a)\n\tx |= (unsigned) (1 << b) - 1;\n      bits -= b;\n    }\n  while (bits >= 0);\n  return x;\n}\n\n\nunsigned long long __udivmoddi4();\n\nmain ()\n{\n  int i;\n  unsigned long long n, d, q, r, rr;\n\n  for (i = 0; ;i++)\n    {\n      n = xlrandom ();\n      d = xlrandom ();\n      if (d == 0)\n\tcontinue;\n\n      q = __udivmoddi4 (n, d, &r);\n\n      if (i % 1000000 == 0)\n\tprintf (\"Testing udivmoddi4: %d iterations made\\n\", i);\n\n      rr = n - q * d;\n      if (rr != r || r >= d)\n\t{\n\t  printf (\"Testing udivmoddi4: failure after %d iterations\\n\", i);\n\t  printf (\"n=%lX%08lX\\n\", (unsigned) (n >> 32), (unsigned) n);\n\t  printf (\"d=%lX%08lX\\n\", (unsigned) (d >> 32), (unsigned) d);\n\t  printf (\"q=%lX%08lX\\n\", (unsigned) (q >> 32), (unsigned) q);\n\t  printf (\"r=%lX%08lX\\n\", (unsigned) (r >> 32), (unsigned) r);\n\t  printf (\"rr=%lX%08lX\\n\", (unsigned) (rr >> 32), (unsigned) rr);\n\t  abort ();\n\t}\n    }\n\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/unalign-1.c",
    "content": "typedef struct __attribute__ ((__packed__))\n{\n    char valueField[2];\n} ptp_tlv_t;\ntypedef struct __attribute__ ((__packed__))\n{\n    char stepsRemoved;\n    ptp_tlv_t tlv[1];\n} ptp_message_announce_t;\nint ptplib_send_announce(int sequenceId, int i)\n{\n    ptp_message_announce_t tx_packet;\n    ((long long *)tx_packet.tlv[0].valueField)[sequenceId] = i;\n    f(&tx_packet);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/uns.c",
    "content": "foo (a)\n{\n  if ((unsigned) a < 234)\n    return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/uns_tst.c",
    "content": "a (c)\n     unsigned char c;\n{\n  unsigned u = c;\n  if ((int)u < 0)\n    return 1;\n  else\n    return 0;\n}\n\nb (x, y)\n     unsigned x, y;\n{\n  x /= y;\n  if ((int)x < 0)\n    return 1;\n  else\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/uuarg.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nfoo (a, b, c, d, e, f, g, h, i)\n{\n  return foo () + i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/v.c",
    "content": "main (int *p)\n{\n  int a;\n\n  a = 0;\n  p[1] = a;\n  a = 0;\n  p[2] = a;\n  a = 123456;\n  p[3] = a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-1.c",
    "content": "/* { dg-options \"-msse\" { target { i?86-*-* x86_64-*-* } } } */\n#define vector __attribute__((vector_size(16) ))\nstruct ss\n{\n vector float mVec;\n};\nfloat getCapsule(vector int t)\n{\n vector float t1 = (vector float)t;\n struct ss y = {t1};\n return *((float*)&y.mVec);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-2.c",
    "content": "/* { dg-options \"-msse\" { target { i?86-*-* x86_64-*-* } } } */\n#define vector __attribute__((vector_size(16) ))\nstruct ss\n{\n vector float mVec;\n};\nvector float getCapsule(vector int t)\n{\n vector float t1 = (vector float)t;\n struct ss y = {t1};\n *((float*)&y.mVec) = 1.0;\n return y.mVec;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-3.c",
    "content": "#define vector __attribute__((vector_size(16) ))\nvector float g(void)\n{\n  float t = 1.0f;\n  return (vector float){0.0, 0.0, t, 0.0};\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-4.c",
    "content": "/* { dg-do compile } */\n/* { dg-options \"-mavx\" { target { i?86-*-* x86_64-*-* } } } */\n\n/* Make sure that vector of size 8 of signed char works. This used to crash with AVX on x86\n   as we would produce try to extract the chars inside the vector mode using the vector mode of V8SI\n   which was wrong. */\n__attribute__ ((vector_size (8))) signed char v4, v5, v6;\nvoid\ntwo (void)\n{\n v4 = v5 + v6;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-5.c",
    "content": "typedef int v2si __attribute__((__vector_size__(8)));\n\nv2si\nf (int x)\n{\n  return (v2si) { x, (__INTPTR_TYPE__) \"\" };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-6.c",
    "content": "typedef int v2si __attribute__((__vector_size__(8)));\n\nv2si\nf (int x)\n{\n  return (v2si) { (__INTPTR_TYPE__) \"\", x };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vector-align-1.c",
    "content": "/* Check to make sure the alignment on vectors is not being lost. */\n\n/* If some target has a Max alignment less than 128, please create\n   a #ifdef around the alignment and add your alignment.  */\n#define alignment 128\n\nchar x __attribute__((aligned(alignment),vector_size(2)));\n\n\nint f[__alignof__(x) == alignment?1:-1];\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vla-const-1.c",
    "content": "/* Test TREE_CONSTANT VLA size: bug 27893.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n/* { dg-require-effective-target alloca } */\nint a;\nvoid g(void *);\nvoid f(void) { int b[(__SIZE_TYPE__)&a]; g(b); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/vla-const-2.c",
    "content": "/* Test TREE_CONSTANT VLA size: bug 27893.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n/* { dg-require-effective-target alloca } */\nvoid g(void *);\nvoid f(void) { int b[1/0]; g(b); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/volatile-1.c",
    "content": "/* The problem here was that the statements that\n   loaded from exception.reason where not being\n   marked as having volatile behavior which\n   caused load PRE on the tree level to go\n   into an infinite loop. */\n\nstruct gdb_exception\n{\n  int reason;\n};\nint catch_exceptions_with_msg (int *gdberrmsg)\n{\n  volatile struct gdb_exception exception;\n  exceptions_state_mc_init (&(exception));\n  if (exception.reason != 0)\n    foo ();\n  return exception.reason;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/w.c",
    "content": "int foo (unsigned short a, unsigned short b) { return a + b; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/widechar-1.c",
    "content": "char *s = L\"a\" \"b\";\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/ww.c",
    "content": "foo (p)\n     short *p;\n{\n  static int *foo;\n  *p = 1234;\n  *foo = 1234;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/x.c",
    "content": "f(m){int i,s=0;for(i=0;i<m;i++)s+=i;return s;}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xb.c",
    "content": "foo (a, b)\n{\n  unsigned x = 1;\n\n  a += b;\n  a += x;\n  if (a <= 0)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  printf (\"%d\\n\", foo (1, ~0));\n  printf (\"%d\\n\", foo (0, ~0));\n  printf (\"%d\\n\", foo (-1, ~0));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xbg.c",
    "content": "typedef short type;\n\nshort\nfoo (type *sp, int a)\n{\n  type t;\n  int i;\n\n  t = sp[a];\n  i = (int)(type)sp[a];\n  if (i)\n    return 0;\n  return t;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xc.c",
    "content": "foo (a, p)\n     int *p;\n{\n  int b;\n\n  a++;\n  b = *p;\n  if (a)\n    return 1;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xcsebug.c",
    "content": "int g1;\nint g2;\n\nfoo ()\n{\n  int i = 1;\n  int x;\n\n  x = g1;\n  (*(&g1 + i - 1)) = x + 1;\n  x = g1;\n  (*(&g1 + i - 1)) = x + 1;\n  g1++;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xdi.c",
    "content": "foo (long long *p, int a, int b)\n{\n  *(p + a + b) = 876243243874343LL;\n}\n\nbar (p, pp)\n     long long *p, *pp;\n{\n  long long a;\n  *p++ = a;\n  fee (*p);\n    *p++ = *pp--;\n    *p++ = *pp--;\n  return (int) p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xfoo.c",
    "content": "foo (a)\n{\n  return (a & ~0xfff) == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xi.c",
    "content": "foo (a)\n{\n  int r = 0;\n  if (a)\n    r = 1;\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xlop.c",
    "content": "foo (a)\n{\n  int b;\n  do\n    {\n      b = bar ();\n      a = b - 10;\n    }\n  while (a > 10);\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xmtst.c",
    "content": "p1 (int b, int *p, int a)\n{\n  p[0] = p[1];\n  return p[0];\n}\np2 (int b, int *p, int a)\n{\n  p[0] = p[1];\n  return p[0] == 0;\n}\np3 (int b, int *p, int a)\n{\n  p[0] = p[1];\n  a = p[0];\n  if (a)\n    return 0;\n  return a;\n}\np4 (int b, int *p, int a)\n{\n  a = p[1];\n  p[0] = p[1];\n  if (a)\n    return 0;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xneg.c",
    "content": "foo (a)\n     double a;\n{\n  return -a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xopt.c",
    "content": "proc1 (a)\n     unsigned a;\n{\n  return (a >> 20) & 0x010fffff;\n}\n\nproc2 (a)\n     unsigned a;\n{\n  return (a << 17) & 0xfffff001;\n}\n\nproc3 (a)\n     unsigned a;\n{\n  return (a & 0xff00000a) >> 25;\n}\n\nproc4 (a)\n     unsigned a;\n{\n  return (a & 0x100000ff) << 25;\n}\n\nproc5 (a)\n     unsigned a;\n{\n  return (unsigned char) (a >> 24);\n}\n\nproc6 (a)\n     unsigned a;\n{\n  return ((unsigned char) a) << 30;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xor.c",
    "content": "foo (a, b)\n{\n  return ~(a ^ ~123);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xorn.c",
    "content": "int\nxorn (a, b)\n     int a, b;\n{\n  return a ^ ~b;\n}\n\nint\nnot (a)\n     int a;\n{\n  return ~a;\n}\n\nint\nxor (a, b)\n     int a, b;\n{\n  return a ^ b;\n}\n\nmain ()\n{\n  int i, j;\n\n  for (i = 0;  i <= 1;  i++)\n    for (j = 0;  j <= 1;  j++)\n      printf (\"%d op %d = %d = %d?\\n\", i, j,\n\t      1 & xor (i, not (j)),\n\t      1 & xorn (i, j));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xp.c",
    "content": "foo (a)\n{\n  return a & 255;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xpp.c",
    "content": "foo (a)\n{\n  a++;\n  if (a < 10)\n    return 1;\n  return a;\n}\n\nmain ()\n{\n  printf (\"%d\\n\", foo ((1 << 31) - 1));\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xs.c",
    "content": "foo (a, b)\n{\n  for (b = 0; b < 10; b++)\n    ;\n  for (a = 0; a < 10; a++)\n    ;\n  a = b << 1;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xsh.c",
    "content": "foo (a, b)\n{\n  a = b + b;\n  if (a)\n    return a;\n  return b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xz.c",
    "content": "foo (int *p)\n{\n  *p = (unsigned short) *p;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/xzz.c",
    "content": "foo (a, b)\n{\n  return a >> (char) b;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/zero-strct-1.c",
    "content": "typedef struct { } empty_t;\n\nf ()\n{\n  empty_t i;\n  bar (i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c",
    "content": "struct { } foo = { };\nvoid * bar(void) { return &foo; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/zero-strct-3.c",
    "content": "typedef struct {} spinlock_t;\nstruct sk_buff_head {\n  int i;\n  spinlock_t lock;\n};\nstruct sk_buff_head audit_skb_queue;\nvoid audit_init(void)\n{\n  struct sk_buff_head *list = &audit_skb_queue;\n  spinlock_t a = {};\n  audit_skb_queue.lock = a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/zero-strct-4.c",
    "content": "typedef struct {} raw_spinlock_t;\ntypedef struct {\n  raw_spinlock_t raw_lock;\n} spinlock_t;\nstruct sk_buff_head {\n  int i;\n  spinlock_t lock;\n};\nstruct sk_buff_head audit_skb_queue;\nvoid audit_init(void)\n{\n  struct sk_buff_head *list = &audit_skb_queue;\n  audit_skb_queue.lock = (spinlock_t) { .raw_lock = { } };\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/compile/zero-strct-5.c",
    "content": "/* Check that the inliner does not crash for this testcase.\n   gimple_expr can change the expr to NULL meaning that we\n   should not add any statement. */\nstruct f {};\nstruct g1 {struct f l;};\n\nstatic inline void g(struct f a, int i){}\n\nvoid h(void)\n{\n  struct g1 t;\n  g(t.l , 1);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000112-1.c",
    "content": "#include <string.h>\n\nstatic int\nspecial_format (fmt)\n     const char *fmt;\n{\n  return (strchr (fmt, '*') != 0\n          || strchr (fmt, 'V') != 0\n          || strchr (fmt, 'S') != 0\n          || strchr (fmt, 'n') != 0);\n}\n\nmain()\n{\n  if (special_format (\"ee\"))\n    abort ();\n  if (!special_format (\"*e\"))\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000113-1.c",
    "content": "struct x { \n  unsigned x1:1;\n  unsigned x2:2;\n  unsigned x3:3;\n};\n   \nfoobar (int x, int y, int z)\n{\n  struct x a = {x, y, z};\n  struct x b = {x, y, z};\n  struct x *c = &b;\n\n  c->x3 += (a.x2 - a.x1) * c->x2;\n  if (a.x1 != 1 || c->x3 != 5)\n    abort ();\n  exit (0);\n}\n\nmain()\n{\n  foobar (1, 2, 3);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000121-1.c",
    "content": "void big(long long u) { }\n\nvoid doit(unsigned int a,unsigned int b,char *id)\n{\n  big(*id);\n  big(a);\n  big(b);\n}\n\nint main(void)\n{\n  doit(1,1,\"\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000205-1.c",
    "content": "static int f (int a)\n{\n  if (a == 0)\n    return 0;\n  do\n    if (a & 128)\n      return 1;\n  while (f (0));\n  return 0;\n}\n\nint main(void)\n{\n  if (f (~128))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000217-1.c",
    "content": "unsigned short int showbug(unsigned short int *a, unsigned short int *b)\n{\n        *a += *b -8;\n        return (*a >= 8);\n}\n\nint main()\n{\n        unsigned short int x = 0;\n        unsigned short int y = 10;\n\n        if (showbug(&x, &y) != 0)\n\t  abort ();\n\n\texit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000223-1.c",
    "content": "/* Copyright (C) 2000 Free Software Foundation, Inc.\n   Contributed by Nathan Sidwell 23 Feb 2000 <nathan@codesourcery.com> */\n\n/* __alignof__ should never return a non-power of 2\n   eg, sizeof(long double) might be 12, but that means it must be alignable\n   on a 4 byte boundary. */\n\nvoid check (char const *type, int align)\n{\n  if ((align & -align) != align)\n    {\n      abort ();\n    }\n}\n\n#define QUOTE_(s) #s\n#define QUOTE(s) QUOTE_(s)\n\n#define check(t) check(QUOTE(t), __alignof__(t))\n\n// This struct should have an alignment of the lcm of all the types. If one of\n// the base alignments is not a power of two, then A cannot be power of two\n// aligned.\nstruct A\n{\n  char c;\n  signed short ss;\n  unsigned short us;\n  signed int si;\n  unsigned int ui;\n  signed long sl;\n  unsigned long ul;\n  signed long long sll;\n  unsigned long long ull;\n  float f;\n  double d;\n  long double ld;\n  void *dp;\n  void (*fp)();\n};\n\nint main ()\n{\n  check (void);\n  check (char);\n  check (signed short);\n  check (unsigned short);\n  check (signed int);\n  check (unsigned int);\n  check (signed long);\n  check (unsigned long);\n  check (signed long long);\n  check (unsigned long long);\n  check (float);\n  check (double);\n  check (long double);\n  check (void *);\n  check (void (*)());\n  check (struct A);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000224-1.c",
    "content": "int loop_1 = 100;\nint loop_2 = 7;\nint flag = 0;\n\nint test (void)\n{\n    int i;\n    int counter  = 0;\n\n    while (loop_1 > counter) {\n        if (flag & 1) {\n            for (i = 0; i < loop_2; i++) {\n                counter++;\n            }\n        }\n        flag++;\n    }\n    return 1;\n}\n\nint main()\n{\n    if (test () != 1)\n      abort ();\n    \n    exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000225-1.c",
    "content": "int main ()\n{\n    int nResult;\n    int b=0;\n    int i = -1;\n\n    do\n    {\n     if (b!=0) {\n       abort ();\n       nResult=1;\n     } else {\n      nResult=0;\n     }\n     i++;\n     b=(i+2)*4;\n    } while (i < 0);\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000227-1.c",
    "content": "static const unsigned char f[] = \"\\0\\377\";\nstatic const unsigned char g[] = \"\\0\";\n\nint main(void)\n{\n  if (sizeof f != 3 || sizeof g != 3)\n    abort ();\n  if (f[0] != g[0])\n    abort ();\n  if (f[1] != g[1])\n    abort ();\n  if (f[2] != g[2])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000313-1.c",
    "content": "unsigned int buggy (unsigned int *param)\n{\n  unsigned int accu, zero = 0, borrow;\n  accu    = - *param;\n  borrow  = - (accu > zero);\n  *param += accu;\n  return borrow;\n}\n\nint main (void)\n{\n  unsigned int param  = 1;\n  unsigned int borrow = buggy (&param);\n\n  if (param != 0)\n    abort ();\n  if (borrow + 1 != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000314-1.c",
    "content": "int main ()\n{\n  long winds = 0;\n\n  while (winds != 0)\n    {\n      if (*(char *) winds)\n\tbreak;\n    }\n\n  if (winds == 0 || winds != 0 || *(char *) winds)\n    exit (0);\n\n  abort ();\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000314-2.c",
    "content": "typedef unsigned long long uint64;\nconst uint64 bigconst = 1ULL << 34;\n\nint a = 1;\n\nstatic\nuint64 getmask(void)\n{\n    if (a)\n      return bigconst;\n    else\n      return 0;\n}\n\nmain()\n{\n    uint64 f = getmask();\n    if (sizeof (long long) == 8\n\t&& f != bigconst) abort ();\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000314-3.c",
    "content": "extern void abort (void);\n\nstatic char arg0[] = \"arg0\";\nstatic char arg1[] = \"arg1\";\n\nstatic void attr_rtx\t\t(char *, char *);\nstatic char *attr_string        (char *);\nstatic void attr_eq\t\t(char *, char *);\n\nstatic void \nattr_rtx (char *varg0, char *varg1)\n{\n  if (varg0 != arg0)\n    abort ();\n\n  if (varg1 != arg1)\n    abort ();\n\n  return;\n}\n\nstatic void \nattr_eq (name, value)\n     char *name, *value;\n{\n  return attr_rtx (attr_string (name),\n\t\t   attr_string (value));\n}\n\nstatic char *\nattr_string (str)\n     char *str;\n{\n  return str;\n}\n\nint main()\n{\n  attr_eq (arg0, arg1);\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000402-1.c",
    "content": "#include <limits.h>\n\n#if ULONG_LONG_MAX != 18446744073709551615ull && ULONG_MAX != 18446744073709551615ull\nint main(void) { exit (0); }\n#else\n#if ULONG_MAX != 18446744073709551615ull\ntypedef unsigned long long ull;\n#else\ntypedef unsigned long ull;\n#endif\n\n#include <stdio.h>\n\nvoid checkit(int);\n\nmain () {\n    const ull a = 0x1400000000ULL;\n    const ull b = 0x80000000ULL;\n    const ull c = a/b;\n    const ull d = 0x1400000000ULL / 0x80000000ULL;\n\n    checkit ((int) c);\n    checkit ((int) d);\n\n    exit(0);\n}\n\nvoid checkit (int a)\n{\n  if (a != 40)\n    abort();\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000403-1.c",
    "content": "extern unsigned long aa[], bb[];\n\nint seqgt (unsigned long a, unsigned short win, unsigned long b);\n\nint seqgt2 (unsigned long a, unsigned short win, unsigned long b);\n\nmain()\n{\n  if (! seqgt (*aa, 0x1000, *bb) || ! seqgt2 (*aa, 0x1000, *bb))\n    abort ();\n\n  exit (0);\n}\n\nint\nseqgt (unsigned long a, unsigned short win, unsigned long b)\n{\n  return (long) ((a + win) - b) > 0;\n}\n\nint\nseqgt2 (unsigned long a, unsigned short win, unsigned long b)\n{\n  long l = ((a + win) - b);\n  return l > 0;\n}\n\nunsigned long aa[] = { (1UL << (sizeof (long) * 8 - 1)) - 0xfff };\nunsigned long bb[] = { (1UL << (sizeof (long) * 8 - 1)) - 0xfff };\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-1.c",
    "content": "short int i = -1;\nconst char * const wordlist[207];\n\nconst char * const *\nfoo(void)\n{\n  register const char * const *wordptr = &wordlist[207u + i];\n  return wordptr;\n}\n\nint\nmain()\n{\n  if (foo() != &wordlist[206])\n    abort ();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-2.c",
    "content": "int f(int a,int *y)\n{\n  int x = a;\n\n  if (a==0)\n    return *y;\n\n  return f(a-1,&x);\n}\n\nint main(int argc,char **argv)\n{\n  if (f (100, (int *) 0) != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-3.c",
    "content": "typedef struct {\n  char y;\n  char x[32];\n} X;\n\nint z (void)\n{\n  X xxx;\n  xxx.x[0] =\n  xxx.x[31] = '0';\n  xxx.y = 0xf;\n  return f (xxx, xxx);\n}\n\nint main (void)\n{\n  int val;\n\n  val = z ();\n  if (val != 0x60)\n    abort ();\n  exit (0);\n}\n\nint f(X x, X y)\n{\n  if (x.y != y.y)\n    return 'F';\n\n  return x.x[0] + y.x[0];\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-4.c",
    "content": "  void f(int i, int j, int radius, int width, int N)\n  {\n    const int diff   = i-radius;\n    const int lowk   = (diff>0 ? diff : 0 );\n    int k;\n  \n    for(k=lowk; k<= 2; k++){\n      int idx = ((k-i+radius)*width-j+radius);\n      if (idx < 0)\n\tabort ();\n    }\n  \n    for(k=lowk; k<= 2; k++);\n  }\n  \n  \n  int main(int argc, char **argv)\n  {\n    int exc_rad=2;\n    int N=8;\n    int i;\n    for(i=1; i<4; i++)\n      f(i,1,exc_rad,2*exc_rad + 1, N);\n    exit (0);\n  } \n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-5.c",
    "content": "int main( void ) {\n    struct {\n\tint node;\n\tint type;\n    } lastglob[1] = { { 0   , 1  } };\n\n    if (lastglob[0].node != 0 || lastglob[0].type != 1)\n      abort ();\n    exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000412-6.c",
    "content": "unsigned bug (unsigned short value, unsigned short *buffer,\n              unsigned short *bufend);\n\nunsigned short buf[] = {1, 4, 16, 64, 256};\nint main()\n{\n  if (bug (512, buf, buf + 3) != 491)\n    abort ();\n\n  exit (0);\n}\n\nunsigned\nbug (unsigned short value, unsigned short *buffer, unsigned short *bufend)\n{\n  unsigned short *tmp;\n\n  for (tmp = buffer; tmp < bufend; tmp++)\n    value -= *tmp;\n\n  return value;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000419-1.c",
    "content": "struct foo { int a, b, c; };\n\nvoid\nbrother (int a, int b, int c)\n{\n  if (a)\n    abort ();\n}\n\nvoid\nsister (struct foo f, int b, int c)\n{\n  brother ((f.b == b), b, c);\n}\n\nint\nmain ()\n{\n  struct foo f = { 7, 8, 9 };\n  sister (f, 1, 2);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000422-1.c",
    "content": "int ops[13] =\n{\n  11, 12, 46, 3, 2, 2, 3, 2, 1, 3, 2, 1, 2\n};\n\nint correct[13] = \n{\n  46, 12, 11, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1\n};\n\nint num = 13;\n\nint main()\n{\n  int i;\n\n  for (i = 0; i < num; i++)\n    {\n      int j;\n\n      for (j = num - 1; j > i; j--)\n        {\n          if (ops[j-1] < ops[j])\n            {\n              int op = ops[j];\n              ops[j] = ops[j-1];\n              ops[j-1] = op;\n            }\n        }\n    }\n\n\n  for (i = 0; i < num; i++)\n    if (ops[i] != correct[i])\n      abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000503-1.c",
    "content": "unsigned long\nsub (int a)\n{\n  return ((0 > a - 2) ? 0 : a - 2) * sizeof (long);\n}\n\nmain ()\n{\n  if (sub (0) != 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000511-1.c",
    "content": "void f (int value, int expect)\n{\n  if (value != expect)\n    abort ();\n}\n\nint main()\n{\n  int a = 7, b = 6, c = 4, d = 7, e = 2;\n\t\n  f (a||b%c,   1);\n  f (a?b%c:0,  2);\n  f (a=b%c,    2);\n  f (a*=b%c,   4);\n  f (a/=b%c,   2);\n  f (a%=b%c,   0);\n  f (a+=b%c,   2);\n  f (d||c&&e,  1);\n  f (d?c&&e:0, 1);\n  f (d=c&&e,   1);\n  f (d*=c&&e,  1);\n  f (d%=c&&e,  0);\n  f (d+=c&&e,  1);\n  f (d-=c&&e,  0);\n  f (d||c||e,  1);\n  f (d?c||e:0, 0);\n  f (d=c||e,   1);\n  f (d*=c||e,  1);\n  f (d%=c||e,  0);\n  f (d+=c||e,  1);\n  f (d-=c||e,  0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000519-1.c",
    "content": "#include <stdarg.h>\n\nint\nbar (int a, va_list ap)\n{\n  int b;\n\n  do\n    b = va_arg (ap, int);\n  while (b > 10);\n\n  return a + b;\n}\n\nint\nfoo (int a, ...)\n{\n  va_list ap;\n\n  va_start (ap, a);\n  return bar (a, ap);\n}\n\nint\nmain ()\n{\n  if (foo (1, 2, 3) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000519-2.c",
    "content": "long x = -1L;\n\nint main()\n{\n  long b = (x != -1L);\n\n  if (b)\n    abort();\n\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000523-1.c",
    "content": "int\nmain (void)\n{\n  long long   x;\n  int         n;\n\n  if (sizeof (long long) < 8)\n    exit (0);\n  \n  n = 9;\n  x = (((long long) n) << 55) / 0xff; \n\n  if (x == 0)\n    abort ();\n\n  x = (((long long) 9) << 55) / 0xff;\n\n  if (x == 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000528-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* Contributed by Alexandre Oliva <aoliva@cygnus.com> */\n\nunsigned long l = (unsigned long)-2;\nunsigned short s;\n\nint main () {\n  long t = l;\n  s = t;\n  if (s != (unsigned short)-2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000603-1.c",
    "content": "/* It is not clear whether this test is conforming.  See DR#236\n   http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_236.htm.  However,\n   there seems to be consensus that the presence of a union to aggregate\n   struct s1 and struct s2 should make it conforming.  */\nstruct s1 { double d; };\nstruct s2 { double d; };\nunion u { struct s1 x; struct s2 y; };\n\ndouble f(struct s1 *a, struct s2 *b)\n{\n  a->d = 1.0;\n  return b->d + 1.0;\n}\n\nint main()\n{\n  union u a;\n  a.x.d = 0.0;\n  if (f (&a.x, &a.y) != 2.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000605-1.c",
    "content": "typedef struct _RenderInfo RenderInfo;\nstruct _RenderInfo\n{\n    int y;\n    float scaley;\n    int src_y;\n};\n\nstatic void bar(void) { }\n\nstatic int\nrender_image_rgb_a (RenderInfo * info)\n{\n  int y, ye;\n  float error;\n  float step;\n\n  y = info->y;\n  ye = 256;\n\n  step = 1.0 / info->scaley;\n\n  error = y * step;\n  error -= ((int) error) - step;\n\n  for (; y < ye; y++) {\n      if (error >= 1.0) {\n\t  info->src_y += (int) error;\n\t  error -= (int) error;\n\t  bar();\n      }\n      error += step;\n  }\n  return info->src_y;\n}\n\nint main (void)\n{\n    RenderInfo info;\n\n    info.y = 0;\n    info.src_y = 0;\n    info.scaley = 1.0;\n\n    if (render_image_rgb_a(&info) != 256)\n       abort ();\n    exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000605-2.c",
    "content": "struct F { int i; };\n\nvoid f1(struct F *x, struct F *y)\n{\n  int timeout = 0;\n  for (; ((const struct F*)x)->i < y->i ; x->i++)\n    if (++timeout > 5)\n      abort ();\n}\n\nmain()\n{\n  struct F x, y;\n  x.i = 0;\n  y.i = 1;\n  f1 (&x, &y);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000605-3.c",
    "content": "struct F { int x; int y; };\n\nint main()\n{\n  int timeout = 0;\n  int x = 0;\n  while (1)\n    {\n      const struct F i = { x++, };\n      if (i.x > 0)\n\tbreak;\n      if (++timeout > 5)\n\tgoto die;\n    }\n  return 0;\n die:\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000622-1.c",
    "content": "long foo(long a, long b, long c)\n{\n  if (a != 12 || b != 1 || c != 11)\n    abort();\n  return 0;\n}\nlong bar (long a, long b)\n{\n  return b;\n}\nvoid baz (long a, long b, void *c)\n{\n  long d;\n  d = (long)c;\n  foo(d, bar (a, 1), b);\n}\nint main()\n{\n  baz (10, 11, (void *)12);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000703-1.c",
    "content": "void abort(void);\nvoid exit(int);\nstruct baz \n{\n  char a[17];\n  char b[3];\n  unsigned int c;\n  unsigned int d;\n};\n\nvoid foo(struct baz *p, unsigned int c, unsigned int d)\n{\n  __builtin_memcpy (p->b, \"abc\", 3);\n  p->c = c;\n  p->d = d;\n}\n\nvoid bar(struct baz *p, unsigned int c, unsigned int d)\n{\n  ({ void *s = (p);\n     __builtin_memset (s, '\\0', sizeof (struct baz));\n     s; });\n  __builtin_memcpy (p->a, \"01234567890123456\", 17);\n  __builtin_memcpy (p->b, \"abc\", 3);\n  p->c = c;\n  p->d = d;\n}\n\nint main()\n{\n  struct baz p;\n  foo(&p, 71, 18);\n  if (p.c != 71 || p.d != 18)\n    abort();\n  bar(&p, 59, 26);\n  if (p.c != 59 || p.d != 26)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000706-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c, d, e;\n};\n\nvoid bar(struct baz *x, int f, int g, int h, int i, int j)\n{\n  if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||\n      f != 6 || g != 7 || h != 8 || i != 9 || j != 10)\n    abort();\n}\n\nvoid foo(struct baz x, char **y)\n{\n  bar(&x,6,7,8,9,10);\n}\n\nint main()\n{\n  struct baz x;\n\n  x.a = 1;\n  x.b = 2;\n  x.c = 3;\n  x.d = 4;\n  x.e = 5;\n  foo(x,(char **)0);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000706-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c, d, e;\n};\n\nvoid bar(struct baz *x, int f, int g, int h, int i, int j)\n{\n  if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||\n      f != 6 || g != 7 || h != 8 || i != 9 || j != 10)\n    abort();\n}\n\nvoid foo(char *z, struct baz x, char *y)\n{\n  bar(&x,6,7,8,9,10);\n}\n\nint main()\n{\n  struct baz x;\n\n  x.a = 1;\n  x.b = 2;\n  x.c = 3;\n  x.d = 4;\n  x.e = 5;\n  foo((char *)0,x,(char *)0);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000706-3.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nint c;\n\nvoid baz(int *p)\n{\n  c = *p;\n}\n\nvoid bar(int b)\n{\n  if (c != 1 || b != 2)\n    abort();\n}\n\nvoid foo(int a, int b)\n{\n  baz(&a);\n  bar(b);\n}\n\nint main()\n{\n  foo(1, 2);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000706-4.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nint *c;\n\nvoid bar(int b)\n{\n  if (*c != 1 || b != 2)\n    abort();\n}\n\nvoid foo(int a, int b)\n{\n  c = &a;\n  bar(b);\n}\n\nint main()\n{\n  foo(1, 2);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000706-5.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz { int a, b, c; };\n\nstruct baz *c;\n\nvoid bar(int b)\n{\n  if (c->a != 1 || c->b != 2 || c->c != 3 || b != 4)\n    abort();\n}\n\nvoid foo(struct baz a, int b)\n{\n  c = &a;\n  bar(b);\n}\n\nint main()\n{\n  struct baz a;\n  a.a = 1;\n  a.b = 2;\n  a.c = 3;\n  foo(a, 4);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000707-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c;\n};\n\nvoid\nfoo (int a, int b, int c)\n{\n  if (a != 4)\n    abort ();\n}\n\nvoid\nbar (struct baz x, int b, int c)\n{\n  foo (x.b, b, c);\n}\n\nint\nmain ()\n{\n  struct baz x = { 3, 4, 5 };\n  bar (x, 1, 2);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000715-1.c",
    "content": "void abort(void);\nvoid exit(int);\n\nvoid\ntest1(void)\n{\n  int x = 3, y = 2;\n\n  if ((x < y ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest2(void)\n{\n  int x = 3, y = 2, z;\n\n  z = (x < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest3(void)\n{\n  int x = 3, y = 2;\n  int xx = 3, yy = 2;\n\n  if ((xx < yy ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nint x, y;\n\nstatic void\ninit_xy(void)\n{\n  x = 3;\n  y = 2;\n}\n\nvoid\ntest4(void)\n{\n  init_xy();\n  if ((x < y ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest5(void)\n{\n  int z;\n\n  init_xy();\n  z = (x < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest6(void)\n{\n  int xx = 3, yy = 2;\n  int z;\n\n  init_xy();\n  z = (xx < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nint\nmain(){\n  test1 ();\n  test2 ();\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000715-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nunsigned int foo(unsigned int a)\n{\n  return ((unsigned char)(a + 1)) * 4;\n}\n\nint main(void)\n{\n  if (foo((unsigned char)~0))\n    abort ();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000717-1.c",
    "content": "typedef struct trio { int a, b, c; } trio;\n\nint\nbar (int i, trio t)\n{\n  if (t.a == t.b || t.a == t.c)\n    abort ();\n}\n\nint\nfoo (trio t, int i)\n{\n  return bar (i, t);\n}\n\nmain ()\n{\n  trio t = { 1, 2, 3 };\n\n  foo (t, 4);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000717-2.c",
    "content": "static void\ncompare (long long foo)\n{\n  if (foo < 4294967297LL)\n    abort();\n}\nint main(void)\n{\n  compare (8589934591LL);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000717-3.c",
    "content": "int c = -1;\n\nfoo (p)\n     int *p;\n{\n  int x;\n  int a;\n\n  a = p[0];\n  x = a + 5;\n  a = c;\n  p[0] = x - 15;\n  return a;\n}\n\nint main()\n{\n   int b = 1;\n   int a = foo(&b);\n\n   if (a != -1 || b != (1 + 5 - 15))\n     abort ();\n\n   exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000717-4.c",
    "content": "/* Extracted from gas.  Incorrectly generated non-pic code at -O0 for\n   IA-64, which produces linker errors on some operating systems.  */\n\nstruct\n{\n  int offset;\n  struct slot\n  {\n    int field[6];\n  }\n  slot[4];\n} s;\n\nint\nx ()\n{\n  int toggle = 0;\n  int r = s.slot[0].field[!toggle];\n  return r;\n}\n\nint\nmain ()\n{\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000717-5.c",
    "content": "typedef struct trio { int a, b, c; } trio;\n\nint\nbar (int i, int j, int k, trio t)\n{\n  if (t.a != 1 || t.b != 2 || t.c != 3 ||\n      i != 4 || j != 5 || k != 6)\n    abort ();\n}\n\nint\nfoo (trio t, int i, int j, int k)\n{\n  return bar (i, j, k, t);\n}\n\nmain ()\n{\n  trio t = { 1, 2, 3 };\n\n  foo (t, 4, 5, 6);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000722-1.c",
    "content": "struct s { char *p; int t; };\n\nextern void bar (void);\nextern void foo (struct s *);\n\nint main(void)\n{\n  bar ();\n  bar ();\n  exit (0);\n}\n\nvoid \nbar (void)\n{\n  foo (& (struct s) { \"hi\", 1 });\n}\n\nvoid foo (struct s *p)\n{\n  if (p->t != 1)\n    abort();\n  p->t = 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000726-1.c",
    "content": "void adjust_xy (short *, short *);\n\nstruct adjust_template\n{\n  short kx_x;\n  short kx_y;\n  short kx;\n  short kz;\n};\n\nstatic struct adjust_template adjust = {0, 0, 1, 1};\n\nmain ()\n{\n  short x = 1, y = 1;\n\n  adjust_xy (&x, &y);\n\n  if (x != 1)\n    abort ();\n\n  exit (0);\n}\n\nvoid\nadjust_xy (x, y)\n     short  *x;\n     short  *y;\n{\n  *x = adjust.kx_x * *x + adjust.kx_y * *y + adjust.kx;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000731-1.c",
    "content": "double\nfoo (void)\n{\n  return 0.0;\n}\n\nvoid\ndo_sibcall (void)\n{\n  (void) foo ();\n}\n\nint\nmain (void)\n{\n   double x;\n\n   for (x = 0; x < 20; x++)\n      do_sibcall ();\n   if (!(x >= 10))\n      abort ();\n   exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000731-2.c",
    "content": "int\nmain()\n{\n    int i = 1;\n    int j = 0;\n\n    while (i != 1024 || j <= 0) {\n        i *= 2;\n        ++ j;\n    }\n\n    if (j != 10)\n      abort ();\n\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000801-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nvoid\nfoo (char *bp, unsigned n)\n{\n  register char c;\n  register char *ep = bp + n;\n  register char *sp;\n\n  while (bp < ep)\n    {\n      sp = bp + 3;\n      c = *sp;\n      *sp = *bp;\n      *bp++ = c;\n      sp = bp + 1;\n      c = *sp;\n      *sp = *bp;\n      *bp++ = c;\n      bp += 2;\n    }\n}\n\nint main(void)\n{\n  int one = 1;\n\n  if (sizeof(int) != 4 * sizeof(char))\n    exit(0);\n\n  foo((char *)&one, sizeof(one));\n  foo((char *)&one, sizeof(one));\n\n  if (one != 1)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000801-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\nint bar(void);\nint baz(void);\n\nstruct foo {\n  struct foo *next;\n};\n\nstruct foo *test(struct foo *node)\n{\n  while (node) {\n    if (bar() && !baz())\n      break;\n    node = node->next;\n  }\n  return node;\n}\n\nint bar (void)\n{\n  return 0;\n}\n\nint baz (void)\n{\n  return 0;\n}\n\nint main(void)\n{\n  struct foo a, b, *c;\n\n  a.next = &b;\n  b.next = (struct foo *)0;\n  c = test(&a);\n  if (c)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000801-3.c",
    "content": "/* Origin: PR c/92 from Simon Marlow <t-simonm@microsoft.com>, adapted\n   to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n\ntypedef struct { } empty;\n\ntypedef struct {\n  int i;\n  empty e;\n  int i2;\n} st;\n\nst s = { .i = 0, .i2 = 1 };\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (s.i2 == 1)\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000801-4.c",
    "content": "/* Origin: PR c/128 from Martin Sebor <sebor@roguewave.com>, adapted\n   as a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n/* Character arrays initialized by a string literal must have\n   uninitialized elements zeroed.  This isn't clear in the 1990\n   standard, but was fixed in TC2 and C99; see DRs #060, #092.\n*/\nextern void abort (void);\n\nint\nfoo (void)\n{\n  char s[2] = \"\";\n  return 0 == s[1];\n}\n\nchar *t;\n\nint\nmain (void)\n{\n  {\n    char s[] = \"x\";\n    t = s;\n  }\n  if (foo ())\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000808-1.c",
    "content": "typedef struct {\n  long int p_x, p_y;\n} Point;\n\nvoid\nbar ()\n{\n}\n\nvoid\nf (p0, p1, p2, p3, p4, p5)\n     Point p0, p1, p2, p3, p4, p5;\n{\n  if (p0.p_x != 0 || p0.p_y != 1\n      || p1.p_x != -1 || p1.p_y != 0\n      || p2.p_x != 1 || p2.p_y != -1\n      || p3.p_x != -1 || p3.p_y != 1\n      || p4.p_x != 0 || p4.p_y != -1\n      || p5.p_x != 1 || p5.p_y != 0)\n    abort ();\n}\n\nvoid\nfoo ()\n{\n  Point p0, p1, p2, p3, p4, p5;\n\n  bar();\n  \n  p0.p_x = 0;\n  p0.p_y = 1;\n\n  p1.p_x = -1;\n  p1.p_y = 0;\n\n  p2.p_x = 1;\n  p2.p_y = -1;\n\n  p3.p_x = -1;\n  p3.p_y = 1;\n\n  p4.p_x = 0;\n  p4.p_y = -1;\n\n  p5.p_x = 1;\n  p5.p_y = 0;\n\n  f (p0, p1, p2, p3, p4, p5);\n}\n\nint\nmain()\n{\n  foo();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000815-1.c",
    "content": "struct table_elt\n{\n  void *exp;\n  struct table_elt *next_same_hash;\n  struct table_elt *prev_same_hash;\n  struct table_elt *next_same_value;\n  struct table_elt *prev_same_value;\n  struct table_elt *first_same_value;\n  struct table_elt *related_value;\n  int cost;\n  int mode;\n  char in_memory;\n  char in_struct;\n  char is_const;\n  char flag;\n};\n\nstruct write_data\n{\n  int sp : 1;\t\t\t \n  int var : 1;\t\t\t \n  int nonscalar : 1;\t\t \n  int all : 1;\t\t\t \n};\n\nint cse_rtx_addr_varies_p(void *);\nvoid remove_from_table(struct table_elt *, int);\nstatic struct table_elt *table[32];\n\nvoid\ninvalidate_memory (writes)\n     struct write_data *writes;\n{\n  register int i;\n  register struct table_elt *p, *next;\n  int all = writes->all;\n  int nonscalar = writes->nonscalar;\n\n  for (i = 0; i < 31; i++)\n    for (p = table[i]; p; p = next)\n      {\n\tnext = p->next_same_hash;\n\tif (p->in_memory\n\t    && (all\n\t\t|| (nonscalar && p->in_struct)\n\t\t|| cse_rtx_addr_varies_p (p->exp)))\n\t  remove_from_table (p, i);\n      }\n}\n\nint cse_rtx_addr_varies_p(void *x) { return 0; }\nvoid remove_from_table(struct table_elt *x, int y) { abort (); }\n\nint\nmain()\n{\n  struct write_data writes;\n  struct table_elt elt;\n\n  __builtin_memset(&elt, 0, sizeof(elt));\n  elt.in_memory = 1;\n  table[0] = &elt;\n\n  __builtin_memset(&writes, 0, sizeof(writes));\n  writes.var = 1;\n  writes.nonscalar = 1;\n\n  invalidate_memory(&writes);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000818-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   by Manfred Hollstein <manfredh@redhat.com>  */\n\nvoid *temporary_obstack;\n\nstatic int input (void);\nstatic int ISALNUM (int ch);\nstatic void obstack_1grow (void **ptr, int ch);\n\nint yylex (void);\nint main (void);\n\nint main (void)\n{\n  int ch = yylex ();\n\n  exit (0);\n}\n\nint yylex (void)\n{\n  int ch;\n\n#ifndef WORK_AROUND\n  for (;;)\n    {\n      ch = input ();\n      if (ISALNUM (ch))\n        obstack_1grow (&temporary_obstack, ch);\n      else if (ch != '_')\n        break;\n    }\n#else\n  do\n    {\n      ch = input ();\n      if (ISALNUM (ch))\n        obstack_1grow (&temporary_obstack, ch);\n    } while (ch == '_');\n#endif\n\n  return ch;\n}\n\nstatic int input (void)\n{\n  return 0;\n}\n\nstatic int ISALNUM (int ch)\n{\n  return ((ch >= 'A' && ch <= 'Z')\n\t  || (ch >= 'a' && ch <= 'z')\n\t  || (ch >= '0' && ch <= '0'));\n}\n\nstatic void obstack_1grow (void **ptr, int ch)\n{\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000819-1.c",
    "content": "int a[2] = { 2, 0 };\n\nvoid foo(int *sp, int cnt)\n{\n  int *p, *top;\n\n  top = sp; sp -= cnt;\n\n  for(p = sp; p <= top; p++)\n    if (*p < 2) exit(0);\n}\n\nint main()\n{\n  foo(a + 1, 1);\n  abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000822-1.c",
    "content": "#ifndef NO_TRAMPOLINES\nint f0(int (*fn)(int *), int *p)\n{\n  return (*fn) (p);\n}\n\nint f1(void)\n{\n  int i = 0;\n\n  int f2(int *p)\n  {\n    i = 1;\n    return *p + 1;\n  }\n\n  return f0(f2, &i);\n}\n#endif\n\nint main()\n{\n#ifndef NO_TRAMPOLINES\n  if (f1() != 2)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000910-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* by Alexandre Oliva <aoliva@redhat.com> */\n\n#include <stdlib.h>\n\nvoid bar (int);\nvoid foo (int *);\n\nint main () {\n  static int a[] = { 0, 1, 2 };\n  int *i = &a[sizeof(a)/sizeof(*a)];\n  \n  while (i-- > a)\n    foo (i);\n\n  exit (0);\n}\n\nvoid baz (int, int);\n\nvoid bar (int i) { baz (i, i); }\nvoid foo (int *i) { bar (*i); }\n\nvoid baz (int i, int j) {\n  if (i != j)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000910-2.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* by Alexandre Oliva <aoliva@redhat.com> */\n\n#include <stdlib.h>\n#include <string.h>\n\nchar *list[] = { \"*\", \"e\" };\n\nstatic int bar (const char *fmt) {\n  return (strchr (fmt, '*') != 0);\n}\n\nstatic void foo () {\n  int i;\n  for (i = 0; i < sizeof (list) / sizeof (*list); i++) {\n    const char *fmt = list[i];\n    if (bar (fmt))\n      continue;\n    if (i == 0)\n      abort ();\n    else\n      exit (0);\n  }\n}\n\nint main () {\n  foo ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000914-1.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\n\nenum tree_code {\nERROR_MARK,\nIDENTIFIER_NODE,\nOP_IDENTIFIER,\nTREE_LIST,\nTREE_VEC,\nBLOCK,\nVOID_TYPE,\nINTEGER_TYPE,\nREAL_TYPE,\nCOMPLEX_TYPE,\nVECTOR_TYPE,\nENUMERAL_TYPE,\nBOOLEAN_TYPE,\nCHAR_TYPE,\nPOINTER_TYPE,\nOFFSET_TYPE,\nREFERENCE_TYPE,\nMETHOD_TYPE,\nFILE_TYPE,\nARRAY_TYPE,\nSET_TYPE,\nRECORD_TYPE,\nUNION_TYPE,\nQUAL_UNION_TYPE,\nFUNCTION_TYPE,\nLANG_TYPE,\nINTEGER_CST,\nREAL_CST,\nCOMPLEX_CST,\nSTRING_CST,\nFUNCTION_DECL,\nLABEL_DECL,\nCONST_DECL,\nTYPE_DECL,\nVAR_DECL,\nPARM_DECL,\nRESULT_DECL,\nFIELD_DECL,\nNAMESPACE_DECL,\nCOMPONENT_REF,\nBIT_FIELD_REF,\nINDIRECT_REF,\nBUFFER_REF,\nARRAY_REF,\nCONSTRUCTOR,\nCOMPOUND_EXPR,\nMODIFY_EXPR,\nINIT_EXPR,\nTARGET_EXPR,\nCOND_EXPR,\nBIND_EXPR,\nCALL_EXPR,\nMETHOD_CALL_EXPR,\nWITH_CLEANUP_EXPR,\nCLEANUP_POINT_EXPR,\nPLACEHOLDER_EXPR,\nWITH_RECORD_EXPR,\nPLUS_EXPR,\nMINUS_EXPR,\nMULT_EXPR,\nTRUNC_DIV_EXPR,\nCEIL_DIV_EXPR,\nFLOOR_DIV_EXPR,\nROUND_DIV_EXPR,\nTRUNC_MOD_EXPR,\nCEIL_MOD_EXPR,\nFLOOR_MOD_EXPR,\nROUND_MOD_EXPR,\nRDIV_EXPR,\nEXACT_DIV_EXPR,\nFIX_TRUNC_EXPR,\nFIX_CEIL_EXPR,\nFIX_FLOOR_EXPR,\nFIX_ROUND_EXPR,\nFLOAT_EXPR,\nEXPON_EXPR,\nNEGATE_EXPR,\nMIN_EXPR,\nMAX_EXPR,\nABS_EXPR,\nFFS_EXPR,\nLSHIFT_EXPR,\nRSHIFT_EXPR,\nLROTATE_EXPR,\nRROTATE_EXPR,\nBIT_IOR_EXPR,\nBIT_XOR_EXPR,\nBIT_AND_EXPR,\nBIT_ANDTC_EXPR,\nBIT_NOT_EXPR,\nTRUTH_ANDIF_EXPR,\nTRUTH_ORIF_EXPR,\nTRUTH_AND_EXPR,\nTRUTH_OR_EXPR,\nTRUTH_XOR_EXPR,\nTRUTH_NOT_EXPR,\nLT_EXPR,\nLE_EXPR,\nGT_EXPR,\nGE_EXPR,\nEQ_EXPR,\nNE_EXPR,\nUNORDERED_EXPR,\nORDERED_EXPR,\nUNLT_EXPR,\nUNLE_EXPR,\nUNGT_EXPR,\nUNGE_EXPR,\nUNEQ_EXPR,\nIN_EXPR,\nSET_LE_EXPR,\nCARD_EXPR,\nRANGE_EXPR,\nCONVERT_EXPR,\nNOP_EXPR,\nNON_LVALUE_EXPR,\nSAVE_EXPR,\nUNSAVE_EXPR,\nRTL_EXPR,\nADDR_EXPR,\nREFERENCE_EXPR,\nENTRY_VALUE_EXPR,\nCOMPLEX_EXPR,\nCONJ_EXPR,\nREALPART_EXPR,\nIMAGPART_EXPR,\nPREDECREMENT_EXPR,\nPREINCREMENT_EXPR,\nPOSTDECREMENT_EXPR,\nPOSTINCREMENT_EXPR,\nVA_ARG_EXPR,\nTRY_CATCH_EXPR,\nTRY_FINALLY_EXPR,\nGOTO_SUBROUTINE_EXPR,\nPOPDHC_EXPR,\nPOPDCC_EXPR,\nLABEL_EXPR,\nGOTO_EXPR,\nRETURN_EXPR,\nEXIT_EXPR,\nLOOP_EXPR,\nLABELED_BLOCK_EXPR,\nEXIT_BLOCK_EXPR,\nEXPR_WITH_FILE_LOCATION,\nSWITCH_EXPR,\n  LAST_AND_UNUSED_TREE_CODE\n};\ntypedef union tree_node *tree;\nstruct tree_common\n{\n  union tree_node *chain;\n  union tree_node *type;\n  enum tree_code code : 8;\n  unsigned side_effects_flag : 1;\n  unsigned constant_flag : 1;\n  unsigned permanent_flag : 1;\n  unsigned addressable_flag : 1;\n  unsigned volatile_flag : 1;\n  unsigned readonly_flag : 1;\n  unsigned unsigned_flag : 1;\n  unsigned asm_written_flag: 1;\n  unsigned used_flag : 1;\n  unsigned nothrow_flag : 1;\n  unsigned static_flag : 1;\n  unsigned public_flag : 1;\n  unsigned private_flag : 1;\n  unsigned protected_flag : 1;\n  unsigned bounded_flag : 1;\n  unsigned lang_flag_0 : 1;\n  unsigned lang_flag_1 : 1;\n  unsigned lang_flag_2 : 1;\n  unsigned lang_flag_3 : 1;\n  unsigned lang_flag_4 : 1;\n  unsigned lang_flag_5 : 1;\n  unsigned lang_flag_6 : 1;\n};\nunion tree_node\n{\n  struct tree_common common;\n };\nenum c_tree_code {\n  C_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE,\nSRCLOC,\nSIZEOF_EXPR,\nARROW_EXPR,\nALIGNOF_EXPR,\nEXPR_STMT,\nCOMPOUND_STMT,\nDECL_STMT,\nIF_STMT,\nFOR_STMT,\nWHILE_STMT,\nDO_STMT,\nRETURN_STMT,\nBREAK_STMT,\nCONTINUE_STMT,\nSWITCH_STMT,\nGOTO_STMT,\nLABEL_STMT,\nASM_STMT,\nSCOPE_STMT,\nCASE_LABEL,\nSTMT_EXPR,\n  LAST_C_TREE_CODE\n};\nenum cplus_tree_code {\n  CP_DUMMY_TREE_CODE = LAST_C_TREE_CODE,\nOFFSET_REF,\nPTRMEM_CST,\nNEW_EXPR,\nVEC_NEW_EXPR,\nDELETE_EXPR,\nVEC_DELETE_EXPR,\nSCOPE_REF,\nMEMBER_REF,\nTYPE_EXPR,\nAGGR_INIT_EXPR,\nTHROW_EXPR,\nEMPTY_CLASS_EXPR,\nTEMPLATE_DECL,\nTEMPLATE_PARM_INDEX,\nTEMPLATE_TYPE_PARM,\nTEMPLATE_TEMPLATE_PARM,\nBOUND_TEMPLATE_TEMPLATE_PARM,\nTYPENAME_TYPE,\nTYPEOF_TYPE,\nUSING_DECL,\nDEFAULT_ARG,\nTEMPLATE_ID_EXPR,\nCPLUS_BINDING,\nOVERLOAD,\nWRAPPER,\nLOOKUP_EXPR,\nFUNCTION_NAME,\nMODOP_EXPR,\nCAST_EXPR,\nREINTERPRET_CAST_EXPR,\nCONST_CAST_EXPR,\nSTATIC_CAST_EXPR,\nDYNAMIC_CAST_EXPR,\nDOTSTAR_EXPR,\nTYPEID_EXPR,\nPSEUDO_DTOR_EXPR,\nSUBOBJECT,\nCTOR_STMT,\nCLEANUP_STMT,\nSTART_CATCH_STMT,\nCTOR_INITIALIZER,\nRETURN_INIT,\nTRY_BLOCK,\nHANDLER,\nTAG_DEFN,\nIDENTITY_CONV,\nLVALUE_CONV,\nQUAL_CONV,\nSTD_CONV,\nPTR_CONV,\nPMEM_CONV,\nBASE_CONV,\nREF_BIND,\nUSER_CONV,\nAMBIG_CONV,\nRVALUE_CONV,\n  LAST_CPLUS_TREE_CODE\n};\n\nblah(){}\n\nconvert_like_real (convs)\n     tree convs;\n{\n  switch (((enum tree_code) (convs)->common.code))\n    {\n    case AMBIG_CONV:\n      return blah();\n    default:\n      break;\n    };\n   abort ();\n}\n\nmain()\n{\n  tree convs = (void *)malloc (sizeof (struct tree_common));;\n\n  convs->common.code = AMBIG_CONV;\n  convert_like_real (convs);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20000917-1.c",
    "content": "/* This bug exists in gcc-2.95, egcs-1.1.2, gcc-2.7.2 and probably\n   every other version as well.  */\n\ntypedef struct int3 { int a, b, c; } int3;\n\nint3\none (void)\n{\n  return (int3) { 1, 1, 1 };\n}\n\nint3\nzero (void)\n{\n  return (int3) { 0, 0, 0 };\n}\n\nint\nmain (void)\n{\n  int3 a;\n\n  /* gcc allocates a temporary for the inner expression statement\n     to store the return value of `one'.\n\n     gcc frees the temporaries for the inner expression statement.\n\n     gcc realloates the same temporary slot to store the return\n     value of `zero'.\n\n     gcc expands the call to zero ahead of the expansion of the\n     statement expressions.  The temporary gets the value of `zero'.\n\n     gcc expands statement expressions and the stale temporary is\n     clobbered with the value of `one'.  The bad value is copied from\n     the temporary into *&a.  */\n\n  *({ ({ one (); &a; }); }) = zero ();\n  if (a.a && a.b && a.c)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001009-1.c",
    "content": "int a,b;\nmain()\n{\n  int c=-2;\n  int d=0xfe;\n  int e=a&1;\n  int f=b&2;\n  if ((char)(c|(e&f)) == (char)d)\n    return 0;\n  else\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001009-2.c",
    "content": "int b=1;\nint foo()\n{\n  int a;\n  int c;\n  a=0xff;\n  for (;b;b--)\n  {\n    c=1;\n    asm(\"\"::\"r\"(c));\n    c=(signed char)a;\n  }\n  if (c!=-1)\n    abort();\n  return c;\n}\nint main()\n{\n  foo();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001011-1.c",
    "content": "extern void abort(void);\nextern int strcmp(const char *, const char *);\n\nint foo(const char *a)\n{\n    return strcmp(a, \"main\");\n}\n\nint main(void)\n{\n    if(foo(__FUNCTION__))\n        abort();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001013-1.c",
    "content": "struct x {\n\tint a, b;\n} z = { -4028, 4096 };\n\nint foo(struct x *p, int y)\n{\n  if ((y & 0xff) != y || -p->b >= p->a)\n    return 1;\n  return 0;\n}\n\nmain()\n{\n  if (foo (&z, 10))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001017-1.c",
    "content": " \nvoid bug (double *Cref, char transb, int m, int n, int k,\n\t  double a, double *A, int fdA, double *B, int fdB,\n\t  double b, double *C, int fdC)\n{\n  if (C != Cref) abort ();\n}\n \nint main (void)\n{\n  double A[1], B[1], C[1];\n   \n  bug (C, 'B', 1, 2, 3, 4.0, A, 5, B, 6, 7.0, C, 8);\n   \n  return 0;\n}\n                                                                                                                                       \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001017-2.c",
    "content": "void\nfn_4parms (unsigned char a, long *b, long *c, unsigned int *d)\n{\n  if (*b != 1 || *c != 2 || *d != 3)\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned char a = 0;\n  unsigned long b = 1, c = 2;\n  unsigned int d = 3;\n\n  fn_4parms (a, &b, &c, &d);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001024-1.c",
    "content": "struct a;\n\nextern int baz (struct a *__restrict x);\n\nstruct a {\n  long v;\n  long w;\n};\n\nstruct b {\n  struct a c;\n  struct a d;\n};\n\nint bar (int x, const struct b *__restrict y, struct b *__restrict z)\n{\n  if (y->c.v || y->c.w != 250000 || y->d.v || y->d.w != 250000)\n    abort();\n}\n\nvoid foo(void)\n{\n  struct b x;\n  x.c.v = 0;\n  x.c.w = 250000;\n  x.d = x.c;\n  bar(0, &x, ((void *)0));\n}\n\nint main()\n{\n  foo();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001026-1.c",
    "content": "extern void abort (void);\n\ntypedef struct {\n  long r[(19 + sizeof (long))/(sizeof (long))];\n} realvaluetype;\n\ntypedef void *tree;\n\nstatic realvaluetype\nreal_value_from_int_cst (tree x, tree y)\n{\n  realvaluetype r;\n  int i;\n  for (i = 0; i < sizeof(r.r)/sizeof(long); ++i)\n    r.r[i] = -1;\n  return r;\n}\n\nstruct brfic_args\n{\n  tree type;\n  tree i;\n  realvaluetype d;\n};\n\nstatic void\nbuild_real_from_int_cst_1 (data)\n     void * data;\n{\n  struct brfic_args *args = (struct brfic_args *) data;\n  args->d = real_value_from_int_cst (args->type, args->i);\n}\n\nint main()\n{\n  struct brfic_args args;\n\n  __builtin_memset (&args, 0, sizeof(args));\n  build_real_from_int_cst_1 (&args);\n\n  if (args.d.r[0] == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001027-1.c",
    "content": "int x,*p=&x;\n\nint main()\n{\n  int i=0;\n  x=1;\n  p[i]=2;\n  if (x != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001031-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid t1 (int x)\n{\n  if (x != 4100)\n    abort ();\n}\n\nint t2 (void)\n{\n  int i;\n  t1 ((i = 4096) + 4);\n  return i;\n}\n\nvoid t3 (long long x)\n{\n  if (x != 0x80000fffULL)\n    abort ();\n}\n\nlong long t4 (void)\n{\n  long long i;\n  t3 ((i = 4096) + 0x7fffffffULL);\n  return i;\n}\n\nmain ()\n{\n  if (t2 () != 4096)\n    abort ();\n  if (t4 () != 4096)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001101.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nextern void abort(void);\n\t\t\t \ntypedef struct\n{\n  unsigned int unchanging : 1;\n} struc, *rtx;\n\nrtx dummy ( int *a, rtx *b)\n{\n  *a = 1;\n  *b = (rtx)7;\n  return (rtx)1;\n}\n\nvoid bogus (insn, thread, delay_list)\n     rtx insn;\n     rtx thread;\n     rtx delay_list;\n{\n  rtx new_thread;\n  int must_annul;\n\n  delay_list = dummy ( &must_annul, &new_thread);\n  if (delay_list == 0 &&  new_thread )\n    {\n      thread = new_thread;\n    }\n  if (delay_list && must_annul)\n    insn->unchanging = 1;\n  if (new_thread != thread )\n    abort();\n}\n\nint main()\n{\n  struc baz;\n  bogus (&baz, (rtx)7, 0);\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001108-1.c",
    "content": "long long\nsigned_poly (long long sum, long x)\n{\n  sum += (long long) (long) sum * (long long) x;\n  return sum;\n}\n\nunsigned long long\nunsigned_poly (unsigned long long sum, unsigned long x)\n{\n  sum += (unsigned long long) (unsigned long) sum * (unsigned long long) x;\n  return sum;\n}\n\nint\nmain (void)\n{\n  if (signed_poly (2LL, -3) != -4LL)\n    abort ();\n  \n  if (unsigned_poly (2ULL, 3) != 8ULL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001111-1.c",
    "content": "\nstatic int next_buffer = 0;\nvoid bar (void);\n\nstatic int t = 1, u = 0;\n\nlong\nfoo (unsigned int offset)\n{\n  unsigned i, buffer;\n  int x;\n  char *data;\n\n  i = u;\n  if (i)\n    return i * 0xce2f;\n\n  buffer = next_buffer;\n  data = buffer * 0xce2f;\n  for (i = 0; i < 2; i++)\n    bar ();\n  buffer = next_buffer;\n  return buffer * 0xce2f + offset;\n\n}\n\nvoid\nbar (void)\n{\n}\n\nint\nmain ()\n{\n  if (foo (3) != 3)\n    abort ();\n  next_buffer = 1;\n  if (foo (2) != 0xce2f + 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001112-1.c",
    "content": "int main ()\n{\n  long long i = 1;\n\n  i = i * 2 + 1;\n  \n  if (i != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001121-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\ndouble d;\n\n__inline__ double foo (void)\n{\n  return d;\n}\n\n__inline__ int bar (void)\n{\n  foo();\n  return 0;\n}\n\nint main (void)\n{\n  if (bar ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001124-1.c",
    "content": "\nstruct inode {\n\tlong long\t\ti_size;\n\tstruct super_block\t*i_sb;\n};\n\nstruct file {\n\tlong long\t\tf_pos;\n};\n\nstruct super_block {\n\tint\t\t\ts_blocksize;\n\tunsigned char\t\ts_blocksize_bits;\n\tint\t\t\ts_hs;\n};\n\nstatic char *\nisofs_bread(unsigned int block)\n{\n\tif (block)\n\t  abort ();\n\texit(0);\n}\n\nstatic int\ndo_isofs_readdir(struct inode *inode, struct file *filp)\n{\n\tint bufsize = inode->i_sb->s_blocksize;\n\tunsigned char bufbits = inode->i_sb->s_blocksize_bits;\n\tunsigned int block, offset;\n\tchar *bh = 0;\n\tint hs;\n\n \tif (filp->f_pos >= inode->i_size)\n\t\treturn 0;\n \n\toffset = filp->f_pos & (bufsize - 1);\n\tblock = filp->f_pos >> bufbits;\n\ths = inode->i_sb->s_hs;\n\n\twhile (filp->f_pos < inode->i_size) {\n\t\tif (!bh)\n\t\t\tbh = isofs_bread(block);\n\n\t\ths += block << bufbits;\n\n\t\tif (hs == 0)\n\t\t\tfilp->f_pos++;\n\n\t\tif (offset >= bufsize)\n\t\t\toffset &= bufsize - 1;\n\n\t\tif (*bh)\n\t\t\tfilp->f_pos++;\n\n\t\tfilp->f_pos++;\n\t}\n\treturn 0;\n}\n\nstruct super_block s;\nstruct inode i;\nstruct file f;\n\nint\nmain(int argc, char **argv)\n{\n\ts.s_blocksize = 512;\n\ts.s_blocksize_bits = 9;\n\ti.i_size = 2048;\n\ti.i_sb = &s;\n\tf.f_pos = 0;\n\n\tdo_isofs_readdir(&i,&f);\n\tabort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001130-1.c",
    "content": "static inline int bar(void) { return 1; }\nstatic int mem[3];\n\nstatic int foo(int x)\n{\n  if (x != 0)\n    return x;\n\n  mem[x++] = foo(bar());\n\n  if (x != 1)\n    abort();\n\n  return 0;\n}\n\nint main()\n{\n  foo(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001130-2.c",
    "content": "static int which_alternative = 3;\n\nstatic const char *i960_output_ldconst (void);\n\nstatic const char *\noutput_25 (void)\n{\n  switch (which_alternative)\n    {\n    case 0:\n      return \"mov\t%1,%0\";\n    case 1:\n      return i960_output_ldconst ();\n    case 2:\n      return \"ld\t%1,%0\";\n    case 3:\n      return \"st\t%1,%0\";      \n    }\n}\n\nstatic const char *i960_output_ldconst (void)\n{\n  return \"foo\";\n}\nint main(void)\n{\n  const char *s = output_25 () ;\n  if (s[0] != 's')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001203-1.c",
    "content": "/* Origin: PR c/410 from Jan Echternach\n   <jan.echternach@informatik.uni-rostock.de>,\n   adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n\nextern void exit (int);\n\nstatic void\nfoo (void)\n{\n  struct {\n    long a;\n    char b[1];\n  } x = { 2, { 0 } };\n}\n\nint\nmain (void)\n{\n  int tmp;\n  foo ();\n  tmp = 1;\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001203-2.c",
    "content": "struct obstack\n{\n  long chunk_size;\n  struct _obstack_chunk *chunk;\n  char *object_base;\n  char *next_free;\n  char *chunk_limit;\n  int alignment_mask;\n  unsigned maybe_empty_object;\n};\n\nstruct objfile\n  {\n    struct objfile *next;\n    struct obstack type_obstack;\n  };\n\nstruct type\n  {\n    unsigned length;\n    struct objfile *objfile;\n    short nfields;\n    struct field\n      {\n        union field_location\n          {\n            int bitpos;\n            unsigned long physaddr;\n            char *physname;\n          }\n        loc;\n        int bitsize;\n        struct type *type;\n        char *name;\n      }\n     *fields;\n  };\n\nstruct type *alloc_type (void);\nvoid * xmalloc (unsigned int z);\nvoid _obstack_newchunk (struct obstack *o, int i);\nvoid get_discrete_bounds (long long *lowp, long long *highp);\n\nextern void *memset(void *, int, __SIZE_TYPE__);\n\nstruct type *\ncreate_array_type (struct type *result_type, struct type *element_type)\n{\n  long long low_bound, high_bound;\n  if (result_type == ((void *)0))\n    {\n      result_type = alloc_type ();\n    }\n  get_discrete_bounds (&low_bound, &high_bound);\n  (result_type)->length =\n    (element_type)->length * (high_bound - low_bound + 1);\n  (result_type)->nfields = 1;\n  (result_type)->fields =\n    (struct field *) ((result_type)->objfile != ((void *)0) \n\t\t      ? (\n\t\t      {\n\t\t\tstruct obstack *__h = \n\t\t\t  (&(result_type)->objfile -> type_obstack);\n\t\t\t{\n\t\t\t  struct obstack *__o = (__h);\n\t\t\t  int __len = ((sizeof (struct field)));\n\t\t\t  if (__o->chunk_limit - __o->next_free < __len)\n\t\t\t    _obstack_newchunk (__o, __len); \n\t\t\t  __o->next_free += __len; (void) 0;\n\t\t\t};\n\t\t\t({\n\t\t\t  struct obstack *__o1 = (__h); \n\t\t\t  void *value; \n\t\t\t  value = (void *) __o1->object_base;\n\t\t\t  if (__o1->next_free == value)\n\t\t\t    __o1->maybe_empty_object = 1;\n\t\t\t  __o1->next_free = (((((__o1->next_free) - (char *) 0)\n\t\t\t\t\t       +__o1->alignment_mask) \n\t\t\t\t\t      & ~ (__o1->alignment_mask)) \n\t\t\t\t\t     + (char *) 0);\n\t\t\t  if (__o1->next_free - (char *)__o1->chunk \n\t\t\t      > __o1->chunk_limit - (char *)__o1->chunk)\n\t\t\t    __o1->next_free = __o1->chunk_limit;\n\t\t\t  __o1->object_base = __o1->next_free; \n\t\t\t  value;\n\t\t\t});\n\t\t      }) : xmalloc (sizeof (struct field)));\n  return (result_type);\n}\n\nstruct type *\nalloc_type (void)\n{\n  abort ();\n}\nvoid * xmalloc (unsigned int z)\n{\n  return 0;\n}\nvoid _obstack_newchunk (struct obstack *o, int i)\n{\n  abort ();\n}\nvoid\nget_discrete_bounds (long long *lowp, long long *highp)\n{\n  *lowp = 0;\n  *highp = 2;\n}\n\nint main(void)\n{\n  struct type element_type;\n  struct type result_type;\n  \n  memset (&element_type, 0, sizeof (struct type));\n  memset (&result_type, 0, sizeof (struct type));\n  element_type.length = 4;\n  create_array_type (&result_type, &element_type);\n  if (result_type.length != 12)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001221-1.c",
    "content": "int main ()\n{\n  unsigned long long a;\n  if (! (a = 0xfedcba9876543210ULL))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001228-1.c",
    "content": "int foo1(void)\n{\n  union {\n    char a[sizeof (unsigned)];\n    unsigned b;\n  } u;\n  \n  u.b = 0x01;\n  return u.a[0];\n}\n\nint foo2(void)\n{\n  volatile union {\n    char a[sizeof (unsigned)];\n    unsigned b;\n  } u;\n  \n  u.b = 0x01;\n  return u.a[0];\n}\n\nint main(void)\n{\n  if (foo1() != foo2())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20001229-1.c",
    "content": "/* This testcase originally provoked an unaligned access fault on Alpha.\n\n   Since Digital Unix and Linux (and probably others) by default fix\n   these up in the kernel, the failure was not visible unless one \n   is sitting at the console examining logs.\n\n   So: If we know how, ask the kernel to deliver SIGBUS instead so\n   that the test case visibly fails.  */\n   \n#if defined(__alpha__) && defined(__linux__)\n#include <asm/sysinfo.h>\n#include <asm/unistd.h>\n\nstatic inline int\nsetsysinfo(unsigned long op, void *buffer, unsigned long size,\n           int *start, void *arg, unsigned long flag)\n{\n  syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);\n}\n\nstatic void __attribute__((constructor))\ntrap_unaligned(void)\n{\n  unsigned int buf[2];\n  buf[0] = SSIN_UACPROC;\n  buf[1] = UAC_SIGBUS | UAC_NOPRINT;\n  setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);\n}\n#endif /* alpha */\n\nvoid foo(char *a, char *b) { }\n\nvoid showinfo()\n{\n    char uname[33] = \"\", tty[38] = \"/dev/\";\n    foo(uname, tty);\n}\n\nint main()\n{\n  showinfo ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010106-1.c",
    "content": "/* Copyright 2001 Free Software Foundation\n   Contributed by Alexandre Oliva <aoliva@redhat.com> */\n\nint f(int i) {\n  switch (i)\n  {\n    case -2:\n      return 33;\n    case -1:\n      return 0;\n    case 0:\n      return 7;\n    case 1:\n      return 4;\n    case 2:\n      return 3;\n    case 3:\n      return 15;\n    case 4:\n     return 9;\n    default:\n      abort ();\n  }\n}\n\nint main() {\n  if (f(-1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010114-1.c",
    "content": "/* Origin: PR c/1540 from Mattias Lampe <lampe@tu-harburg.de>,\n   adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n   GCC 2.95.2 fails, CVS GCC of 2001-01-13 passes.  */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  int array1[1] = { 1 };\n  int array2[2][1]= { { 1 }, { 0 } };\n  if (array1[0] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010116-1.c",
    "content": "/* Distilled from optimization/863.  */\n\nextern void abort (void);\nextern void exit (int);\nextern void ok (int);\n\ntypedef struct\n{\n  int x, y, z;\n} Data;\n\nvoid find (Data *first, Data *last)\n{\n  int i;\n  for (i = (last - first) >> 2; i > 0; --i)\n    ok(i);\n  abort ();\n}\n\nvoid ok(int i)\n{\n  if (i != 1)\n    abort ();\n  exit (0);\n}\n\nint\nmain ()\n{\n  Data DataList[4];\n  find (DataList + 0, DataList + 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010118-1.c",
    "content": "typedef struct {\n  int a, b, c, d, e, f;\n} A;\n\nvoid foo (A *v, int w, int x, int *y, int *z)\n{\n}\n\nvoid\nbar (A *v, int x, int y, int w, int h)\n{\n  if (v->a != x || v->b != y) {\n    int oldw = w;\n    int oldh = h;\n    int e = v->e;\n    int f = v->f;\n    int dx, dy;\n    foo(v, 0, 0, &w, &h);\n    dx = (oldw - w) * (double) e/2.0;\n    dy = (oldh - h) * (double) f/2.0;\n    x += dx;\n    y += dy;\n    v->a = x;\n    v->b = y;\n    v->c = w;\n    v->d = h;\n  }\n}\n\nint main ()\n{\n  A w = { 100, 110, 20, 30, -1, -1 };\n  bar (&w,400,420,50,70);\n  if (w.d != 70)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010119-1.c",
    "content": "#ifdef __OPTIMIZE__\nextern void undef (void);\n\nvoid bar (unsigned x) { }\nvoid baz (unsigned x) { }\n\nextern inline void foo (int a, int b)\n{\n  int c = 0;\n  while (c++ < b)\n    (__builtin_constant_p (a) ? ((a) > 20000 ? undef () : bar (a)) : baz (a));\n}\n#else\nvoid foo (int a, int b)\n{\n}\n#endif\n\nint main (void)\n{\n  foo(10, 100);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010122-1.c",
    "content": "/* { dg-skip-if \"requires frame pointers\" { *-*-* } \"-fomit-frame-pointer\" \"\" } */\n/* { dg-require-effective-target return_address } */\n\nextern void exit (int);\nextern void abort (void);\nextern void *alloca (__SIZE_TYPE__);\nchar *dummy (void);\n\n#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))\n\nvoid *save_ret1[6];\nvoid *test4a (char *);\nvoid *test5a (char *);\nvoid *test6a (char *);\n\nvoid NOINLINE *test1 (void)\n{\n  void * temp;\n  temp = __builtin_return_address (0);\n  return temp;\n}\n\nvoid NOINLINE *test2 (void)\n{\n  void * temp;\n  dummy ();\n  temp = __builtin_return_address (0);\n  return temp;\n}\n\nvoid NOINLINE *test3 (void)\n{\n  void * temp;\n  temp = __builtin_return_address (0);\n  dummy ();\n  return temp;\n}\n\nvoid NOINLINE *test4 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test4a (save);\n}\n\nvoid *NOINLINE test4a (char * p)\n{\n  void * temp;\n  temp = __builtin_return_address (1);\n  return temp;\n}\n\nvoid NOINLINE *test5 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test5a (save);\n}\n\nvoid NOINLINE *test5a (char * p)\n{\n  void * temp;\n  dummy ();\n  temp = __builtin_return_address (1);\n  return temp;\n}\n\nvoid NOINLINE *test6 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test6a (save);\n}\n\nvoid NOINLINE *test6a (char * p)\n{\n  void * temp;\n  temp = __builtin_return_address (1);\n  dummy ();\n  return temp;\n}\n\nvoid *(*func1[6])(void) = { test1, test2, test3, test4, test5, test6 };\n\nchar * NOINLINE call_func1 (int i)\n{\n  save_ret1[i] = func1[i] ();\n}\n\nstatic void *ret_addr;\nvoid *save_ret2[6];\nvoid test10a (char *);\nvoid test11a (char *);\nvoid test12a (char *);\n\nvoid NOINLINE test7 (void)\n{\n  ret_addr = __builtin_return_address (0);\n  return;\n}\n\nvoid NOINLINE test8 (void)\n{\n  dummy ();\n  ret_addr = __builtin_return_address (0);\n  return;\n}\n\nvoid NOINLINE test9 (void)\n{\n  ret_addr = __builtin_return_address (0);\n  dummy ();\n  return;\n}\n\nvoid NOINLINE test10 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test10a (save);\n}\n\nvoid NOINLINE test10a (char * p)\n{\n  ret_addr = __builtin_return_address (1);\n  return;\n}\n\nvoid NOINLINE test11 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test11a (save);\n}\n\nvoid NOINLINE test11a (char * p)\n{\n  dummy ();\n  ret_addr = __builtin_return_address (1);\n  return;\n}\n\nvoid NOINLINE test12 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test12a (save);\n}\n\nvoid NOINLINE test12a (char * p)\n{\n  ret_addr = __builtin_return_address (1);\n  dummy ();\n  return;\n}\n\nchar * dummy (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return save;\n}\n\nvoid (*func2[6])(void) = { test7, test8, test9, test10, test11, test12 };\n\nvoid NOINLINE call_func2 (int i)\n{\n  func2[i] ();\n  save_ret2[i] = ret_addr;\n}\n\nint main (void)\n{\n  int i;\n\n  for (i = 0; i < 6; i++) {\n    call_func1(i);\n  }\n\n  if (save_ret1[0] != save_ret1[1]\n      || save_ret1[1] != save_ret1[2])\n    abort ();\n  if (save_ret1[3] != save_ret1[4]\n      || save_ret1[4] != save_ret1[5])\n    abort ();\n  if (save_ret1[3] && save_ret1[0] != save_ret1[3])\n    abort ();\n\n\n  for (i = 0; i < 6; i++) {\n    call_func2(i);\n  }\n\n  if (save_ret2[0] != save_ret2[1]\n      || save_ret2[1] != save_ret2[2])\n    abort ();\n  if (save_ret2[3] != save_ret2[4]\n      || save_ret2[4] != save_ret2[5])\n    abort ();\n  if (save_ret2[3] && save_ret2[0] != save_ret2[3])\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010123-1.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nstruct s\n{\n    int value;\n    char *string;\n};\n\nint main (void)\n{\n  int i;\n  for (i = 0; i < 4; i++)\n    {\n      struct s *t = & (struct s) { 3, \"hey there\" };\n      if (t->value != 3)\n\tabort();\n      t->value = 4;\n      if (t->value != 4)\n\tabort();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010129-1.c",
    "content": "/* { dg-options \"-mtune=i686\" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */\n\nextern void abort (void);\nextern void exit (int);\n\nlong baz1 (void *a)\n{\n  static long l;\n  return l++;\n}\n\nint baz2 (const char *a)\n{\n  return 0;\n}\n\nint baz3 (int i)\n{\n  if (!i)\n    abort ();\n  return 1;\n}\n\nvoid **bar;\n\nint foo (void *a, long b, int c)\n{\n  int d = 0, e, f = 0, i;\n  char g[256];\n  void **h;\n\n  g[0] = '\\n';\n  g[1] = 0;\n\n  while (baz1 (a) < b) {\n    if (g[0] != ' ' && g[0] != '\\t') {\n      f = 1;\n      e = 0;\n      if (!d && baz2 (g) == 0) {\n\tif ((c & 0x10) == 0)\n\t  continue;\n\te = d = 1;\n      }\n      if (!((c & 0x10) && (c & 0x4000) && e) && (c & 2))\n\tcontinue;\n      if ((c & 0x2000) && baz2 (g) == 0)\n\tcontinue;\n      if ((c & 0x1408) && baz2 (g) == 0)\n\tcontinue;\n      if ((c & 0x200) && baz2 (g) == 0)\n\tcontinue;\n      if (c & 0x80) {\n\tfor (h = bar, i = 0; h; h = (void **)*h, i++)\n\t  if (baz3 (i))\n\t    break;\n      }\n      f = 0;\n    }\n  }\n  return 0;\n}\n\nint main ()\n{\n  void *n = 0;\n  bar = &n;\n  foo (&n, 1, 0xc811);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010206-1.c",
    "content": "int foo (void)\n{\n  int i;\n#line 1 \"20010206-1.c\"\n  if (0) i = 1; else i\n#line 1 \"20010206-1.c\"\n    = 26;\n  return i;\n}\n\nint main ()\n{\n  if (foo () != 26)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010209-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nint b;\nint foo (void)\n{\n  int x[b];\n  int bar (int t[b])\n  {\n    int i;\n    for (i = 0; i < b; i++)\n      t[i] = i + (i > 0 ? t[i-1] : 0);\n    return t[b-1];\n  }\n  return bar (x);\n}\n\nint main ()\n{\n  b = 6;\n  if (foo () != 15)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010221-1.c",
    "content": "\nint n = 2;\n\nmain ()\n{\n  int i, x = 45;\n\n  for (i = 0; i < n; i++)\n    {\n      if (i != 0)\n\tx = ( i > 0 ) ? i : 0;\n    }\n\n  if (x != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010222-1.c",
    "content": "int a[2] = { 18, 6 };\n\nint main ()\n{\n  int b = (-3 * a[0] -3 * a[1]) / 12;\n  if (b != -6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010224-1.c",
    "content": "extern void abort (void);\n\ntypedef signed short int16_t;\ntypedef unsigned short uint16_t;\n\nint16_t logadd (int16_t *a, int16_t *b);\nvoid ba_compute_psd (int16_t start);\n\nint16_t masktab[6] = { 1, 2, 3, 4, 5};\nint16_t psd[6] = { 50, 40, 30, 20, 10};\nint16_t bndpsd[6] = { 1, 2, 3, 4, 5};\n\nvoid ba_compute_psd (int16_t start)\n{\n  int i,j,k;\n  int16_t lastbin = 4;\n\n  j = start; \n  k = masktab[start]; \n\n  bndpsd[k] = psd[j]; \n  j++; \n\n  for (i = j; i < lastbin; i++) { \n    bndpsd[k] = logadd(&bndpsd[k], &psd[j]);\n    j++; \n  } \n}\n\nint16_t logadd (int16_t *a, int16_t *b)\n{\n  return *a + *b;\n}\n\nint main (void)\n{\n  int i;\n\n  ba_compute_psd (0);\n\n  if (bndpsd[1] != 140) abort ();\n  return 0;\n}\n  \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010325-1.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.\n\n   This tests for inconsistency in whether wide STRING_CSTs use the host\n   or the target endianness.  */\n\nextern void exit (int);\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (L\"a\" \"b\"[1] != L'b')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010329-1.c",
    "content": "#include <limits.h>\n\nint main (void)\n{\n  void *x = ((void *)((unsigned int)INT_MAX + 2));\n  void *y = ((void *)((unsigned long)LONG_MAX + 2));\n  if (x >= ((void *)((unsigned int)INT_MAX + 1))\n      && x <= ((void *)((unsigned int)INT_MAX + 6))\n      && y >= ((void *)((unsigned long)LONG_MAX + 1))\n      && y <= ((void *)((unsigned long)LONG_MAX + 6)))\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010403-1.c",
    "content": "void b (int *);\nvoid c (int, int);\nvoid d (int);\n\nint e;\n\nvoid a (int x, int y)\n{\n  int f = x ? e : 0;\n  int z = y;\n\n  b (&y);\n  c (z, y);\n  d (f);\n}\n\nvoid b (int *y)\n{\n  (*y)++;\n}\n\nvoid c (int x, int y)\n{\n  if (x == y)\n    abort ();\n}\n\nvoid d (int x)\n{\n}\n\nint main (void)\n{\n  a (0, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010409-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *s);\n\ntypedef struct A {\n  int a, b;\n} A;\n\ntypedef struct B {\n  struct A **a;\n  int b;\n} B;\n\nA *a;\nint b = 1, c;\nB d[1];\n\nvoid foo (A *x, const char *y, int z)\n{\n  c = y[4] + z * 25;\n}\n\nA *bar (const char *v, int w, int x, const char *y, int z)\n{\n  if (w)\n    abort ();\n  exit (0);\n}\n\nvoid test (const char *x, int *y)\n{\n  foo (d->a[d->b], \"test\", 200);\n  d->a[d->b] = bar (x, b ? 0 : 65536, strlen (x), \"test\", 201);\n  d->a[d->b]->a++;\n  if (y)\n    d->a[d->b]->b = *y;\n}\n\nint main ()\n{\n  d->b = 0;\n  d->a = &a;\n  test (\"\", 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010422-1.c",
    "content": "unsigned int foo(unsigned int x)\n{\n  if (x < 5)\n    x = 4;\n  else\n    x = 8;\n  return x;\n}\n\nint main(void)\n{\n  if (foo (8) != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010518-1.c",
    "content": "/* Leaf functions with many arguments.  */\n\nint\nadd (int a,\n    int b,\n    int c,\n    int d,\n    int e,\n    int f,\n    int g,\n    int h,\n    int i,\n    int j,\n    int k,\n    int l,\n    int m)\n{\n  return a+b+c+d+e+f+g+h+i+j+k+l+m;\n}\n\nint\nmain(void)\n{\n  if (add (1,2,3,4,5,6,7,8,9,10,11,12,13) != 91)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010518-2.c",
    "content": "/* Mis-aligned packed structures.  */\n\ntypedef struct\n{\n  char b0;\n  char b1;\n  char b2;\n  char b3;\n  char b4;\n  char b5;\n} __attribute__ ((packed)) b_struct;\n\n\ntypedef struct\n{\n  short a;\n  long b;\n  short c;\n  short d;\n  b_struct e;\n} __attribute__ ((packed)) a_struct;\n\n\nint\nmain(void)\n{\n  volatile a_struct *a;\n  volatile a_struct b;\n\n  a = &b;\n  *a = (a_struct){1,2,3,4};\n  a->e.b4 = 'c';\n\n  if (a->a != 1 || a->b != 2 || a->c != 3 || a->d != 4 || a->e.b4 != 'c')\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010520-1.c",
    "content": "static unsigned int expr_hash_table_size = 1;\n\nint\nmain ()\n{\n  int del = 1;\n  unsigned int i = 0;\n\n  if (i < expr_hash_table_size && del)\n    exit (0);\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010604-1.c",
    "content": "#include <stdbool.h>\n\nint f (int a, int b, int c, _Bool d, _Bool e, _Bool f, char g)\n{\n  if (g != 1 || d != true || e != true || f != true) abort ();\n  return a + b + c;\n}\n\nint main (void)\n{\n  if (f (1, 2, -3, true, true, true, '\\001'))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010605-1.c",
    "content": "int main ()\n{\n  int v = 42;\n\n  inline int fff (int x)\n    {\n      return x*10;\n    }\n\n  return (fff (v) != 420);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010605-2.c",
    "content": "void foo (), bar (), baz ();\nint main ()\n{\n  __complex__ double x;\n  __complex__ float y;\n  __complex__ long double z;\n  __real__ x = 1.0;\n  __imag__ x = 2.0;\n  foo (x);\n  __real__ y = 3.0f;\n  __imag__ y = 4.0f;\n  bar (y);\n  __real__ z = 5.0L;\n  __imag__ z = 6.0L;\n  baz (z);\n  exit (0);\n}\n\nvoid foo (__complex__ double x)\n{\n  if (__real__ x != 1.0 || __imag__ x != 2.0)\n    abort ();\n}\n\nvoid bar (__complex__ float x)\n{\n  if (__real__ x != 3.0f || __imag__ x != 4.0f)\n    abort ();\n}\n\nvoid baz (__complex__ long double x)\n{\n  if (__real__ x != 5.0L || __imag__ x != 6.0L)\n    abort ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010711-1.c",
    "content": "void foo (int *a) {}\n\nint main ()\n{\n  int a;\n  if (&a == 0)\n    abort ();\n  else\n    {\n      foo (&a);\n      exit (0);\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010717-1.c",
    "content": "extern void abort (void);\n\nint\nmain ()\n{\n  int i, j;\n  unsigned long u, r1, r2;\n\n  i = -16;\n  j = 1;\n  u = i + j;\n\n  /* no sign extension upon shift */\n  r1 = u >> 1;\n  /* sign extension upon shift, but there shouldn't be */\n  r2 = ((unsigned long) (i + j)) >> 1;\n\n  if (r1 != r2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010723-1.c",
    "content": "int\ntest ()\n{\n  int biv,giv;\n  for (biv = 0, giv = 0; giv != 8; biv++)\n      giv = biv*8;\n  return giv;\n}\n\n\nmain()\n{\n  if (test () != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010904-1.c",
    "content": "typedef struct x { int a; int b; } __attribute__((aligned(32))) X;\ntypedef struct y { X x[32]; int c; } Y;\n\nY y[2];\n\nint main(void)\n{\n  if (((char *)&y[1] - (char *)&y[0]) & 31)\n    abort ();\n  exit (0);\n}                \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010904-2.c",
    "content": "typedef struct x { int a; int b; } __attribute__((aligned(32))) X;\ntypedef struct y { X x; X y[31]; int c; } Y;\n\nY y[2];\n\nint main(void)\n{\n  if (((char *)&y[1] - (char *)&y[0]) & 31)\n    abort ();\n  exit (0);\n}                \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010910-1.c",
    "content": "/* Test case contributed by Ingo Rohloff <rohloff@in.tum.de>.\n   Code distilled from Linux kernel.  */\n\n/* Compile this program with a gcc-2.95.2 using\n   \"gcc -O2\" and run it. The result will be that\n   rx_ring[1].next == 0   (it should be == 14)\n   and\n   ep.skbuff[4] == 5      (it should be 0)\n*/\n\nextern void abort(void);\n\nstruct epic_rx_desc \n{\n  unsigned int next;\n};\n\nstruct epic_private \n{\n  struct epic_rx_desc *rx_ring;\n  unsigned int rx_skbuff[5];\n};\n\nstatic void epic_init_ring(struct epic_private *ep)\n{\n  int i;\n\n  for (i = 0; i < 5; i++) \n  {\n    ep->rx_ring[i].next = 10 + (i+1)*2;\n    ep->rx_skbuff[i] = 0;\n  }\n  ep->rx_ring[i-1].next = 10;\n}\n\nstatic int check_rx_ring[5] = { 12,14,16,18,10 };\n\nint main(void)\n{\n  struct epic_private ep;\n  struct epic_rx_desc rx_ring[5];\n  int i;\n\n  for (i=0;i<5;i++)\n  {\n    rx_ring[i].next=0;\n    ep.rx_skbuff[i]=5;\n  }\n  \n  ep.rx_ring=rx_ring;\n  epic_init_ring(&ep);\n  \n  for (i=0;i<5;i++)\n  {\n    if ( rx_ring[i].next != check_rx_ring[i] ) abort();\n    if ( ep.rx_skbuff[i] != 0 ) abort();\n  }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010915-1.c",
    "content": "/* Bug in reorg.c, deleting the \"++\" in the last loop in main.\n   Origin: <hp@axis.com>.  */\n\nextern void f (void);\nextern int x (int, char **);\nextern int r (const char *);\nextern char *s (char *, char **);\nextern char *m (char *);\nchar *u;\nchar *h;\nint check = 0;\nint o = 0;\n\nint main (int argc, char **argv)\n{\n  char *args[] = {\"a\", \"b\", \"c\", \"d\", \"e\"};\n  if (x (5, args) != 0 || check != 2 || o != 5)\n    abort ();\n  exit (0);\n}\n\nint x (int argc, char **argv)\n{\n  int opt = 0;\n  char *g = 0;\n  char *p = 0;\n\n  if (argc > o && argc > 2 && argv[o])\n    {\n      g = s (argv[o], &p);\n      if (g)\n\t{\n\t  *g++ = '\\0';\n\t  h = s (g, &p);\n\t  if (g == p)\n\t    h = m (g);\n\t}\n      u = s (argv[o], &p);\n      if (argv[o] == p)\n\tu = m (argv[o]);\n    }\n  else\n    abort ();\n\n  while (++o < argc)\n    if (r (argv[o]) == 0)\n      return 1;\n\n  return 0;\n}\n\nchar *m (char *x) { abort (); }\nchar *s (char *v, char **pp)\n{\n  if (strcmp (v, \"a\") != 0 || check++ > 1)\n    abort ();\n  *pp = v+1;\n  return 0;\n}\n\nint r (const char *f)\n{\n  static char c[2] = \"b\";\n  static int cnt = 0;\n\n  if (*f != *c || f[1] != c[1] || cnt > 3)\n    abort ();\n  c[0]++;\n  cnt++;\n  return 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010924-1.c",
    "content": "/* Verify that flexible arrays can be initialized from STRING_CST\n   constructors. */\n\n/* Baselines.  */\nstruct {\n  char a1c;\n  char *a1p;\n} a1 = {\n  '4',\n  \"62\"\n};\n\nstruct {\n  char a2c;\n  char a2p[2];\n} a2 = {\n  'v',\n  \"cq\"\n};\n\n/* The tests.  */\nstruct {\n  char a3c;\n  char a3p[];\n} a3 = {\n  'o',\n  \"wx\"\n};\n\nstruct {\n  char a4c;\n  char a4p[];\n} a4 = {\n  '9',\n  { 'e', 'b' }\n};\n\nmain()\n{\n  if (a1.a1c != '4')\n    abort();\n  if (a1.a1p[0] != '6')\n    abort();\n  if (a1.a1p[1] != '2')\n    abort();\n  if (a1.a1p[2] != '\\0')\n    abort();\n\n  if (a2.a2c != 'v')\n    abort();\n  if (a2.a2p[0] != 'c')\n    abort();\n  if (a2.a2p[1] != 'q')\n    abort();\n\n  if (a3.a3c != 'o')\n    abort();\n  if (a3.a3p[0] != 'w')\n    abort();\n  if (a3.a3p[1] != 'x')\n    abort();\n\n  if (a4.a4c != '9')\n    abort();\n  if (a4.a4p[0] != 'e')\n    abort();\n  if (a4.a4p[1] != 'b')\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20010925-1.c",
    "content": "extern void exit(int);\nextern void abort (void);\n\nextern void * memcpy (void *, const void *, __SIZE_TYPE__);\nint foo (void *, void *, unsigned int c);\n\nint src[10];\nint dst[10];\n\nint main()\n{\n   if (foo (dst, src, 10) != 0)\n     abort();\n   exit(0);\n}\n\nint foo (void *a, void *b, unsigned int c)\n{\n  if (c == 0)\n    return 1;\n\n  memcpy (a, b, c);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011008-3.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\ntypedef unsigned int u_int32_t;\ntypedef unsigned char u_int8_t;\ntypedef int int32_t;\n\ntypedef enum {\n        TXNLIST_DELETE,\n        TXNLIST_LSN,\n        TXNLIST_TXNID,\n        TXNLIST_PGNO\n} db_txnlist_type;\n\nstruct __db_lsn; typedef struct __db_lsn DB_LSN;\nstruct __db_lsn {\n        u_int32_t file;\n        u_int32_t offset;\n};\nstruct __db_txnlist; typedef struct __db_txnlist DB_TXNLIST;\n\nstruct __db_txnlist {\n        db_txnlist_type type;\n        struct { struct __db_txnlist *le_next; struct __db_txnlist **le_prev; } links;\n        union {\n                struct {\n                        u_int32_t txnid;\n                        int32_t generation;\n                        int32_t aborted;\n                } t;\n                struct {\n\n\n                        u_int32_t flags;\n                        int32_t fileid;\n                        u_int32_t count;\n                        char *fname;\n                } d;\n                struct {\n                        int32_t ntxns;\n                        int32_t maxn;\n                        DB_LSN *lsn_array;\n                } l;\n                struct {\n                        int32_t nentries;\n                        int32_t maxentry;\n                        char *fname;\n                        int32_t fileid;\n                        void *pgno_array;\n                        u_int8_t uid[20];\n                } p;\n        } u;\n};\n\nint log_compare (const DB_LSN *a, const DB_LSN *b)\n{\n  return 1;\n}\n\n\nint\n__db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags)\n{\n   int i;\n \n   for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++)\n     {\n\tint __j;\n\tDB_LSN __tmp;\n\tval++; \n\tfor (__j = 0; __j < elp->u.l.ntxns - 1; __j++)\n\t  if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0)\n\t  {\n\t     __tmp = elp->u.l.lsn_array[__j];\n\t     elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1];\n\t     elp->u.l.lsn_array[__j + 1] = __tmp;\n\t  }\n     }\n\n   *lsnp = elp->u.l.lsn_array[0];\n   return val;\n}\n\n#if defined (STACK_SIZE) && STACK_SIZE < 12350\n#define VLEN (STACK_SIZE/10)\n#else\n#define VLEN 1235\n#endif\n\nint main (void)\n{\n  DB_TXNLIST el;\n  DB_LSN lsn, lsn_a[VLEN];\n  \n  el.u.l.ntxns = VLEN-1;\n  el.u.l.lsn_array = lsn_a;\n  \n  if (__db_txnlist_lsnadd (0, &el, &lsn, 0) != 1)\n    abort ();\n  \n  if (__db_txnlist_lsnadd (0, &el, &lsn, 1) != VLEN-1)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011019-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nstruct { int a; int b[5]; } x;\nint *y;\n\nint foo (void)\n{\n  return y - x.b;\n}\n\nint main (void)\n{\n  y = x.b;\n  if (foo ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011024-1.c",
    "content": "/* Test whether store motion recognizes pure functions as potentially reading\n   any memory.  */\n\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *dest, const void *src, size_t n);\nextern size_t strlen (const char *s);\nextern int strcmp (const char *s1, const char *s2) __attribute__((pure));\n\nchar buf[50];\n\nstatic void foo (void)\n{\n  if (memcpy (buf, \"abc\", 4) != buf) abort ();\n  if (strcmp (buf, \"abc\")) abort ();\n  memcpy (buf, \"abcdefgh\", strlen (\"abcdefgh\") + 1);\n}\n\nint main (void)\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011109-1.c",
    "content": "void fail1(void)\n{\n  abort ();\n}\nvoid fail2(void)\n{\n  abort ();\n}\nvoid fail3(void)\n{\n  abort ();\n}\nvoid fail4(void)\n{\n  abort ();\n}\n\n\nvoid foo(long x)\n{\n  switch (x)\n    {\n    case -6: \n      fail1 (); break;\n    case 0: \n      fail2 (); break;\n    case 1: case 2: \n      break;\n    case 3: case 4: case 5: \n      fail3 ();\n      break;\n    default:\n      fail4 ();\n      break;\n    }\n  switch (x)\n    {\n      \n    case -3: \n      fail1 (); break;\n    case 0: case 4: \n      fail2 (); break;\n    case 1: case 3: \n      break;\n    case 2: case 8: \n      abort ();\n      break;\n    default:\n      fail4 ();\n      break;\n    }\n}\n\nint main(void)\n{\n  foo (1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011109-2.c",
    "content": "int main(void)\n{\n  char *c1 = \"foo\";\n  char *c2 = \"foo\";\n  int i;\n  for (i = 0; i < 3; i++)\n    if (c1[i] != c2[i])\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011113-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *__restrict, const void *__restrict, size_t);\nextern void abort (void);\nextern void exit (int);\n\ntypedef struct t\n{\n  unsigned a : 16;\n  unsigned b : 8;\n  unsigned c : 8;\n  long d[4];\n} *T;\n\ntypedef struct {\n  long r[3];\n} U;\n\nT bar (U, unsigned int);\n\nT foo (T x)\n{\n  U d, u;\n\n  memcpy (&u, &x->d[1], sizeof u);\n  d = u;\n  return bar (d, x->b);\n}\n\nT baz (T x)\n{\n  U d, u;\n\n  d.r[0] = 0x123456789;\n  d.r[1] = 0xfedcba987;\n  d.r[2] = 0xabcdef123;\n  memcpy (&u, &x->d[1], sizeof u);\n  d = u;\n  return bar (d, x->b);\n}\n\nT bar (U d, unsigned int m)\n{\n  if (d.r[0] != 21 || d.r[1] != 22 || d.r[2] != 23)\n    abort ();\n  return 0;\n}\n\nstruct t t = { 26, 0, 0, { 0, 21, 22, 23 }};\n\nint main (void)\n{\n  baz (&t);\n  foo (&t);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011114-1.c",
    "content": "char foo(char bar[])\n{\n  return bar[1];\n}\nextern char foo(char *);\nint main(void)\n{\n  if (foo(\"xy\") != 'y')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011115-1.c",
    "content": "extern void exit (int);\n\nstatic inline int\nfoo (void)\n{\n#ifdef __OPTIMIZE__\n  extern int undefined_reference;\n  return undefined_reference;\n#else\n  return 0;\n#endif\n}\n\nstatic inline int\nbar (void)\n{\n  if (foo == foo)\n    return 1;\n  else\n    return foo ();\n}\n\nint main (void)\n{\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011121-1.c",
    "content": "struct s\n{\n  int i[18];\n  char f;\n  char b[2];\n};\n\nstruct s s1;\n\nint\nmain()\n{\n  struct s s2;\n  s2.b[0] = 100;\n  __builtin_memcpy(&s2, &s1, ((unsigned int) &((struct s *)0)->b));\n  if (s2.b[0] != 100)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011126-1.c",
    "content": "/* Produced a overflow in ifcvt.c, causing S to contain 0xffffffff7fffffff.  */\n\nint a = 1;\n\nint main ()\n{\n  long long s;\n\n  s = a;\n  if (s < 0)\n    s = -2147483648LL;\n  else\n    s = 2147483647LL;\n\n  if (s < 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011126-2.c",
    "content": "/* Problem originally visible on ia64.\n\n   There is a partial redundancy of \"in + 1\" that makes GCSE want to\n   transform the final while loop to \n\n     p = in + 1;\n     tmp = p;\n     ...\n     goto start;\n   top:\n     tmp = tmp + 1;\n   start:\n     in = tmp;\n     if (in < p) goto top;\n\n   We miscalculate the number of loop iterations as (p - tmp) = 0\n   instead of (p - in) = 1, which results in overflow in the doloop\n   optimization.  */\n\nstatic const char *\ntest (const char *in, char *out)\n{\n  while (1)\n    {\n      if (*in == 'a')\n\t{\n\t  const char *p = in + 1;\n\t  while (*p == 'x')\n\t    ++p;\n\t  if (*p == 'b')\n\t    return p;\n\t  while (in < p)\n\t    *out++ = *in++;\n\t}\n    }\n}\n\nint main ()\n{\n  char out[4];\n  test (\"aab\", out);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011128-1.c",
    "content": "main()\n{\n  char blah[33] = \"01234567890123456789\";\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011217-1.c",
    "content": "int\nmain()\n{\n  double x = 1.0;\n  double y = 2.0;\n\n  if ((y > x--) != 1)\n    abort ();\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011219-1.c",
    "content": "/* This testcase failed on IA-32 at -O and above, because combine attached\n   a REG_LABEL note to jump instruction already using JUMP_LABEL.  */\n\nextern void abort (void);\nextern void exit (int);\n\nenum X { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q };\n\nvoid\nbar (const char *x, int y, const char *z)\n{\n}\n\nlong\nfoo (enum X x, const void *y)\n{\n  long a;\n\n  switch (x)\n    {\n    case K:\n      a = *(long *)y;\n      break;\n    case L:\n      a = *(long *)y;\n      break;\n    case M:\n      a = *(long *)y;\n      break;\n    case N:\n      a = *(long *)y;\n      break;\n    case O:\n      a = *(long *)y;\n      break;\n    default:\n      bar (\"foo\", 1, \"bar\");\n    }\n  return a;\n}\n\nint\nmain ()\n{\n  long i = 24;\n  if (foo (N, &i) != 24)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20011223-1.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n/* Case labels in a switch statement are converted to the promoted\n   type of the controlling expression, not an unpromoted version.\n   Reported as PR c/2454 by\n   Andreas Krakowczyk <Andreas.Krakowczyk@fujitsu-siemens.com>.  */\n\nextern void exit (int);\nextern void abort (void);\n\nstatic int i;\n\nint\nmain (void)\n{\n  i = -1;\n  switch ((signed char) i) {\n  case 255:\n    abort ();\n  default:\n    exit (0);\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020103-1.c",
    "content": "/* On h8300 port, the following used to be broken with -mh or -ms.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long\nfoo (unsigned long a)\n{\n  return a ^ 0x0000ffff;\n}\n\nunsigned long\nbar (unsigned long a)\n{\n  return a ^ 0xffff0000;\n}\n\nint\nmain ()\n{\n  if (foo (0) != 0x0000ffff)\n    abort ();\n\n  if (bar (0) != 0xffff0000)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020107-1.c",
    "content": "/* This testcase failed because - 1 - buf was simplified into ~buf and when\n   later expanding it back into - buf + -1, -1 got lost.  */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nstatic void\nbar (int x)\n{\n  if (!x)\n    abort ();\n}\n\nchar buf[10];\n\ninline char *\nfoo (char *tmp)\n{\n  asm (\"\" : \"=r\" (tmp) : \"0\" (tmp));\n  return tmp + 2;\n}\n\nint\nmain (void)\n{\n  bar ((foo (buf) - 1 - buf) == 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020108-1.c",
    "content": "/* This file tests shifts in various integral modes.  */\n\n#include <limits.h>\n\n#define CAT(A, B) A ## B\n\n#define REPEAT_8\t\\\nREPEAT_FN ( 0)\t\t\\\nREPEAT_FN ( 1)\t\t\\\nREPEAT_FN ( 2)\t\t\\\nREPEAT_FN ( 3)\t\t\\\nREPEAT_FN ( 4)\t\t\\\nREPEAT_FN ( 5)\t\t\\\nREPEAT_FN ( 6)\t\t\\\nREPEAT_FN ( 7)\n\n#define REPEAT_16\t\\\nREPEAT_8\t\t\\\nREPEAT_FN ( 8)\t\t\\\nREPEAT_FN ( 9)\t\t\\\nREPEAT_FN (10)\t\t\\\nREPEAT_FN (11)\t\t\\\nREPEAT_FN (12)\t\t\\\nREPEAT_FN (13)\t\t\\\nREPEAT_FN (14)\t\t\\\nREPEAT_FN (15)\n\n#define REPEAT_32\t\\\nREPEAT_16\t\t\\\nREPEAT_FN (16)\t\t\\\nREPEAT_FN (17)\t\t\\\nREPEAT_FN (18)\t\t\\\nREPEAT_FN (19)\t\t\\\nREPEAT_FN (20)\t\t\\\nREPEAT_FN (21)\t\t\\\nREPEAT_FN (22)\t\t\\\nREPEAT_FN (23)\t\t\\\nREPEAT_FN (24)\t\t\\\nREPEAT_FN (25)\t\t\\\nREPEAT_FN (26)\t\t\\\nREPEAT_FN (27)\t\t\\\nREPEAT_FN (28)\t\t\\\nREPEAT_FN (29)\t\t\\\nREPEAT_FN (30)\t\t\\\nREPEAT_FN (31)\n\n/* Define 8-bit shifts.  */\n#if CHAR_BIT == 8\ntypedef unsigned int u8 __attribute__((mode(QI)));\ntypedef signed int s8 __attribute__((mode(QI)));\n\n#define REPEAT_FN(COUNT) \\\nu8 CAT (ashift_qi_, COUNT) (u8 n) { return n << COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu8 CAT (lshiftrt_qi_, COUNT) (u8 n) { return n >> COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns8 CAT (ashiftrt_qi_, COUNT) (s8 n) { return n >> COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 */\n\n/* Define 16-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16\n#if CHAR_BIT == 8\ntypedef unsigned int u16 __attribute__((mode(HI)));\ntypedef signed int s16 __attribute__((mode(HI)));\n#elif CHAR_BIT == 16\ntypedef unsigned int u16 __attribute__((mode(QI)));\ntypedef signed int s16 __attribute__((mode(QI)));\n#endif\n\n#define REPEAT_FN(COUNT) \\\nu16 CAT (ashift_hi_, COUNT) (u16 n) { return n << COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu16 CAT (lshiftrt_hi_, COUNT) (u16 n) { return n >> COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns16 CAT (ashiftrt_hi_, COUNT) (s16 n) { return n >> COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */\n\n/* Define 32-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32\n#if CHAR_BIT == 8\ntypedef unsigned int u32 __attribute__((mode(SI)));\ntypedef signed int s32 __attribute__((mode(SI)));\n#elif CHAR_BIT == 16\ntypedef unsigned int u32 __attribute__((mode(HI)));\ntypedef signed int s32 __attribute__((mode(HI)));\n#elif CHAR_BIT == 32\ntypedef unsigned int u32 __attribute__((mode(QI)));\ntypedef signed int s32 __attribute__((mode(QI)));\n#endif\n\n#define REPEAT_FN(COUNT) \\\nu32 CAT (ashift_si_, COUNT) (u32 n) { return n << COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu32 CAT (lshiftrt_si_, COUNT) (u32 n) { return n >> COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns32 CAT (ashiftrt_si_, COUNT) (s32 n) { return n >> COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain ()\n{\n  /* Test 8-bit shifts.  */\n#if CHAR_BIT == 8\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashift_qi_, COUNT) (0xff) != (u8) ((u8)0xff << COUNT)) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (lshiftrt_qi_, COUNT) (0xff) != (u8) ((u8)0xff >> COUNT)) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_qi_, COUNT) (-1) != -1) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_qi_, COUNT) (0) != 0) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 */\n\n  /* Test 16-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16\n# define REPEAT_FN(COUNT)\t\t\t\\\n  if (CAT (ashift_hi_, COUNT) (0xffff)\t\t\\\n      != (u16) ((u16) 0xffff << COUNT)) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT)\t\t\t\\\n  if (CAT (lshiftrt_hi_, COUNT) (0xffff)\t\\\n      != (u16) ((u16) 0xffff >> COUNT)) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_hi_, COUNT) (-1) != -1) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_hi_, COUNT) (0) != 0) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */\n\n  /* Test 32-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32\n# define REPEAT_FN(COUNT)\t\t\t\t\\\n  if (CAT (ashift_si_, COUNT) (0xffffffff)\t\t\\\n      != (u32) ((u32) 0xffffffff << COUNT)) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT)\t\t\t\t\\\n  if (CAT (lshiftrt_si_, COUNT) (0xffffffff)\t\t\\\n      != (u32) ((u32) 0xffffffff >> COUNT)) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_si_, COUNT) (-1) != -1) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_si_, COUNT) (0) != 0) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020118-1.c",
    "content": "/* This tests an insn length of sign extension on h8300 port.  */\n\nextern void exit (int);\n\nvolatile signed char *q;\nvolatile signed int n;\n\nvoid\nfoo (void)\n{\n  signed char *p;\n\n  for (;;)\n    {\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n    }\n}\n\nint\nmain ()\n{\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020127-1.c",
    "content": "/* This used to fail on h8300.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long\nfoo (unsigned long n)\n{\n  return (~n >> 3) & 1;\n}\n\nint\nmain ()\n{\n  if (foo (1 << 3) != 0)\n    abort ();\n\n  if (foo (0) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020129-1.c",
    "content": "/* This testcase failed at -O2 on IA-64, because scheduling did not take\n   into account conditional execution when using cselib for alias\n   analysis.  */\n\nstruct D { int d1; struct D *d2; };\nstruct C { struct D c1; long c2, c3, c4, c5, c6; };\nstruct A { struct A *a1; struct C *a2; };\nstruct B { struct C b1; struct A *b2; };\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (struct B *x, struct B *y)\n{\n  if (x->b2 == 0)\n    {\n      struct A *a;\n\n      x->b2 = a = y->b2;\n      y->b2 = 0;\n      for (; a; a = a->a1)\n\ta->a2 = &x->b1;\n    }\n\n  if (y->b2 != 0)\n    abort ();\n\n  if (x->b1.c3 == -1)\n    {\n      x->b1.c3 = y->b1.c3;\n      x->b1.c4 = y->b1.c4;\n      y->b1.c3 = -1;\n      y->b1.c4 = 0;\n    }\n\n  if (y->b1.c3 != -1)\n    abort ();\n}\n\nstruct B x, y;\n\nint main ()\n{\n  y.b1.c1.d1 = 6;\n  y.b1.c3 = 145;\n  y.b1.c4 = 2448;\n  x.b1.c3 = -1;\n  foo (&x, &y);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020201-1.c",
    "content": "/* Test whether division by constant works properly.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned char cx = 7;\nunsigned short sx = 14;\nunsigned int ix = 21;\nunsigned long lx = 28;\nunsigned long long Lx = 35;\n\nint\nmain ()\n{\n  unsigned char cy;\n  unsigned short sy;\n  unsigned int iy;\n  unsigned long ly;\n  unsigned long long Ly;\n  \n  cy = cx / 6; if (cy != 1) abort ();\n  cy = cx % 6; if (cy != 1) abort ();\n\n  sy = sx / 6; if (sy != 2) abort ();\n  sy = sx % 6; if (sy != 2) abort ();\n\n  iy = ix / 6; if (iy != 3) abort ();\n  iy = ix % 6; if (iy != 3) abort ();\n\n  ly = lx / 6; if (ly != 4) abort ();\n  ly = lx % 6; if (ly != 4) abort ();\n\n  Ly = Lx / 6; if (Ly != 5) abort ();\n  Ly = Lx % 6; if (Ly != 5) abort ();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020206-1.c",
    "content": "struct A {\n  unsigned int a, b, c;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nstruct A bar (void)\n{\n  return (struct A) { 176, 52, 31 };\n}\n\nvoid baz (struct A *a)\n{\n  if (a->a != 176 || a->b != 52 || a->c != 31)\n    abort ();\n}\n\nint main ()\n{\n  struct A d;\n\n  d = ({ ({ bar (); }); });\n  baz (&d);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020206-2.c",
    "content": "/* Origin: PR c/5420 from David Mosberger <davidm@hpl.hp.com>.\n   This testcase was miscompiled when tail call optimizing, because a\n   compound literal initialization was emitted only in the tail call insn\n   chain, not in the normal call insn chain.  */\n\ntypedef struct { unsigned short a; } A;\n\nextern void abort (void);\nextern void exit (int);\n\nvoid foo (unsigned int x)\n{\n  if (x != 0x800 && x != 0x810)\n    abort ();\n}\n\nint\nmain (int argc, char **argv)\n{\n  int i;\n  for (i = 0; i < 2; ++i)\n    foo (((A) { ((!(i >> 4) ? 8 : 64 + (i >> 4)) << 8) + (i << 4) } ).a);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020213-1.c",
    "content": "/* PR c/5681\n   This testcase failed on IA-32 at -O0, because safe_from_p\n   incorrectly assumed it is safe to first write into a.a2 b-1\n   and then read the original value from it.  */\n\nint bar (float);\n\nstruct A {\n  float a1;\n  int a2;\n} a;\n\nint b;\n\nvoid foo (void)\n{\n  a.a2 = bar (a.a1);\n  a.a2 = a.a2 < b - 1 ? a.a2 : b - 1;\n  if (a.a2 >= b - 1)\n    abort ();\n}\n\nint bar (float x)\n{\n  return 2241;\n}\n\nint main()\n{\n  a.a1 = 1.0f;\n  b = 3384;\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020215-1.c",
    "content": "/* Test failed on an architecture that:\n\n   - had 16-bit registers,\n   - passed 64-bit structures in registers,\n   - only allowed SImode values in even numbered registers.\n\n   Before reload, s.i2 in foo() was represented as:\n\n\t(subreg:SI (reg:DI 0) 2)\n\n   find_dummy_reload would return (reg:SI 1) for the subreg reload,\n   despite that not being a valid register.  */\n\nstruct s\n{\n  short i1;\n  long i2;\n  short i3;\n};\n\nstruct s foo (struct s s)\n{\n  s.i2++;\n  return s;\n}\n\nint main ()\n{\n  struct s s = foo ((struct s) { 1000, 2000L, 3000 });\n  if (s.i1 != 1000 || s.i2 != 2001L || s.i3 != 3000)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020216-1.c",
    "content": "/* PR c/3444\n   This used to fail because bitwise xor was improperly computed in char type\n   and sign extended to int type.  */\n\nextern void abort ();\nextern void exit (int);\n\nsigned char c = (signed char) 0xffffffff;\n\nint foo (void)\n{\n  return (unsigned short) c ^ (signed char) 0x99999999;\n}\n\nint main (void)\n{\n  if ((unsigned char) -1 != 0xff\n      || sizeof (short) != 2\n      || sizeof (int) != 4)\n    exit (0);\n  if (foo () != (int) 0xffff0066)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020219-1.c",
    "content": "/* PR c/4308\n   This testcase failed because 0x8000000000000000 >> 0\n   was incorrectly folded into 0xffffffff00000000.  */\n\nextern void abort (void);\nextern void exit (int);\n\nlong long foo (void)\n{\n  long long C = 1ULL << 63, X;\n  int Y = 32;\n  X = C >> (Y & 31);\n  return X;\n}\n\nint main (void)\n{\n  if (foo () != 1ULL << 63)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020225-1.c",
    "content": "/* This testcase failed at -O2 on powerpc64 due to andsi3 writing\n   nonzero bits to the high 32 bits of a 64 bit register.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long foo (unsigned long base, unsigned int val)\n{\n  return base + (val & 0x80000001);\n}\n\nint main (void)\n{\n  if (foo (0L, 0x0ffffff0) != 0L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020225-2.c",
    "content": "static int \ntest(int x)\n{\n  union \n    {\n      int i;\n      double d;\n  } a;\n  a.d = 0;\n  a.i = 1;\n  return x >> a.i;\n}\n\nint main(void)\n{\n  if (test (5) != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020226-1.c",
    "content": "/* This tests the rotate patterns that some machines support.  */\n\n#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((unsigned char)0x1234U)\n#define SHORT_VALUE ((unsigned short)0x1234U)\n#define INT_VALUE 0x1234U\n#define LONG_VALUE 0x12345678LU\n#define LL_VALUE 0x12345678abcdef0LLU\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nunsigned char uc = CHAR_VALUE;\nunsigned short us = SHORT_VALUE;\nunsigned int ui = INT_VALUE;\nunsigned long ul = LONG_VALUE;\nunsigned long long ull = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020227-1.c",
    "content": "/* This testcase failed on mmix-knuth-mmixware.  Problem was with storing\n   to an unaligned mem:SC, gcc tried doing it by parts from a (concat:SC\n   (reg:SF 293) (reg:SF 294)).  */\n\ntypedef __complex__ float cf;\nstruct x { char c; cf f; } __attribute__ ((__packed__));\nextern void f2 (struct x*);\nextern void f1 (void);\nint\nmain (void)\n{\n  f1 ();\n  exit (0);\n}\n\nvoid\nf1 (void)\n{\n  struct x s;\n  s.f = 1;\n  s.c = 42;\n  f2 (&s);\n}\n\nvoid\nf2 (struct x *y)\n{\n  if (y->f != 1 || y->c != 42)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020307-1.c",
    "content": "#define MASK(N) ((1UL << (N)) - 1)\n#define BITS(N) ((1UL << ((N) - 1)) + 2)\n\n#define FUNC(N) void f##N(long j) { if ((j & MASK(N)) >= BITS(N)) abort();}\n\nFUNC(3)\nFUNC(4)\nFUNC(5)\nFUNC(6)\nFUNC(7)\nFUNC(8)\nFUNC(9)\nFUNC(10)\nFUNC(11)\nFUNC(12)\nFUNC(13)\nFUNC(14)\nFUNC(15)\nFUNC(16)\nFUNC(17)\nFUNC(18)\nFUNC(19)\nFUNC(20)\nFUNC(21)\nFUNC(22)\nFUNC(23)\nFUNC(24)\nFUNC(25)\nFUNC(26)\nFUNC(27)\nFUNC(28)\nFUNC(29)\nFUNC(30)\nFUNC(31)\n\nint main ()\n{\n  f3(0);\n  f4(0);\n  f5(0);\n  f6(0);\n  f7(0);\n  f8(0);\n  f9(0);\n  f10(0);\n  f11(0);\n  f12(0);\n  f13(0);\n  f14(0);\n  f15(0);\n  f16(0);\n  f17(0);\n  f18(0);\n  f19(0);\n  f20(0);\n  f21(0);\n  f22(0);\n  f23(0);\n  f24(0);\n  f25(0);\n  f26(0);\n  f27(0);\n  f28(0);\n  f29(0);\n  f30(0);\n  f31(0);\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020314-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nvoid f(void * a, double y)\n{\n}\n\ndouble g (double a, double b, double c, double d)\n{\n  double x, y, z;\n  void *p;\n\n  x = a + b;\n  y = c * d;\n\n  p = alloca (16);\n\n  f(p, y);\n  z = x * y * a;\n\n  return z + b;\n}\n\nmain ()\n{\n  double a, b, c, d;\n  a = 1.0;\n  b = 0.0;\n  c = 10.0;\n  d = 0.0;\n\n  if (g (a, b, c, d) != 0.0)\n    abort ();\n\n  if (a != 1.0 || b != 0.0 || c != 10.0 || d != 0.0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020320-1.c",
    "content": "/* PR c/5354 */\n/* Verify that GCC preserves relevant stack slots.  */\n\nextern void abort(void);\nextern void exit(int);\n\nstruct large { int x, y[9]; };\n\nint main()\n{\n  int fixed;\n\n  fixed = ({ int temp1 = 2; temp1; }) - ({ int temp2 = 1; temp2; });\n  if (fixed != 1)\n    abort();\n\n  fixed = ({ struct large temp3; temp3.x = 2; temp3; }).x\n\t  - ({ struct large temp4; temp4.x = 1; temp4; }).x;\n  if (fixed != 1)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020321-1.c",
    "content": "/* PR 3177 */\n/* Produced a SIGILL on ia64 with sibcall from F to G.  We hadn't\n   widened the register window to allow for the fourth outgoing\n   argument as an \"in\" register.  */\n\nfloat g (void *a, void *b, int e, int c, float d)\n{\n  return d;\n}\n\nfloat f (void *a, void *b, int c, float d)\n{\n  return g (a, b, 0, c, d);\n}\n\nint main ()\n{\n  f (0, 0, 1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020328-1.c",
    "content": "int b = 0;\n\nfunc () { }\n\nvoid\ntestit(int x)\n{\n  if (x != 20)\n    abort ();\n}\n\nint\nmain()\n\n{\n  int a = 0;\n\n  if (b)\n    func();\n\n  /* simplify_and_const_int would incorrectly omit the mask in\n     the line below.  */\n  testit ((a + 23) & 0xfffffffc);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020402-1.c",
    "content": "/* derived from PR c/2100 */\n\nextern void abort ();\nextern void exit (int);\n\n#define SMALL_N  2\n#define NUM_ELEM 4\n\nint main(void)\n{\n  int listElem[NUM_ELEM]={30,2,10,5};\n  int listSmall[SMALL_N];\n  int i, j;\n  int posGreatest=-1, greatest=-1;\n\n  for (i=0; i<SMALL_N; i++) { \n    listSmall[i] = listElem[i];\n    if (listElem[i] > greatest) {\n      posGreatest = i;\n      greatest = listElem[i];\n    }\n  }\n  \n  for (i=SMALL_N; i<NUM_ELEM; i++) { \n    if (listElem[i] < greatest) {\n      listSmall[posGreatest] = listElem[i];\n      posGreatest = 0;\n      greatest = listSmall[0];\n      for (j=1; j<SMALL_N; j++) \n\tif (listSmall[j] > greatest) {\n\t  posGreatest = j;\n\t  greatest = listSmall[j];\n\t}\n    }\n  }\n\n  if (listSmall[0] != 5 || listSmall[1] != 2)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020402-2.c",
    "content": "/* PR 3967\n\n   local-alloc screwed up consideration of high+lo_sum and created\n   reg_equivs that it shouldn't have, resulting in lo_sum with\n   uninitialized data, resulting in segv.  The test has to remain\n   relatively large, since register spilling is required to twig\n   the bug.  */\n\nunsigned long *Local1;\nunsigned long *Local2;\nunsigned long *Local3;\nunsigned long *RDbf1;\nunsigned long *RDbf2;\nunsigned long *RDbf3;\nunsigned long *IntVc1;\nunsigned long *IntVc2;\nunsigned long *IntCode3;\nunsigned long *IntCode4;\nunsigned long *IntCode5;\nunsigned long *IntCode6;\nunsigned long *Lom1;\nunsigned long *Lom2;\nunsigned long *Lom3;\nunsigned long *Lom4;\nunsigned long *Lom5;\nunsigned long *Lom6;\nunsigned long *Lom7;\nunsigned long *Lom8;\nunsigned long *Lom9;\nunsigned long *Lom10;\nunsigned long *RDbf11;\nunsigned long *RDbf12;\n\ntypedef struct\n  {\n    long a1;\n    unsigned long n1;\n    unsigned long local1;\n    unsigned long local2;\n    unsigned long local3;\n    unsigned long rdbf1;\n    unsigned long rdbf2;\n    unsigned long milli;\n    unsigned long frames1;\n    unsigned long frames2;\n    unsigned long nonShared;\n    long newPrivate;\n    long freeLimit;\n    unsigned long cache1;\n    unsigned long cache2;\n    unsigned long cache3;\n    unsigned long cache4;\n    unsigned long cache5;\n    unsigned long time6;\n    unsigned long frames7;\n    unsigned long page8;\n    unsigned long ot9;\n    unsigned long data10;\n    unsigned long bm11;\n    unsigned long misc12;\n  }\nShrPcCommonStatSType;\n\n\ntypedef struct\n  {\n    unsigned long sharedAttached;\n    unsigned long totalAttached;\n    long avgPercentShared;\n    unsigned long numberOfFreeFrames;\n    unsigned long localDirtyPageCount;\n    unsigned long globalDirtyPageCount;\n    long wakeupInterval;\n    unsigned long numActiveProcesses;\n    unsigned long numRecentActiveProcesses;\n    unsigned long gemDirtyPageKinds[10];\n    unsigned long stoneDirtyPageKinds[10];\n    unsigned long gemsInCacheCount;\n    long targetFreeFrameCount;\n  }\nShrPcMonStatSType;\n\ntypedef struct\n  {\n    unsigned long c1;\n    unsigned long c2;\n    unsigned long c3;\n    unsigned long c4;\n    unsigned long c5;\n    unsigned long c6;\n    unsigned long c7;\n    unsigned long c8;\n    unsigned long c9;\n    unsigned long c10;\n    unsigned long c11;\n    unsigned long c12;\n    unsigned long a1;\n    unsigned long a2;\n    unsigned long a3;\n    unsigned long a4;\n    unsigned long a5;\n    unsigned long a6;\n    unsigned long a7;\n    unsigned long a8;\n    unsigned long a9;\n    unsigned long a10;\n    unsigned long a11;\n    unsigned long a12;\n    unsigned long a13;\n    unsigned long a14;\n    unsigned long a15;\n    unsigned long a16;\n    unsigned long a17;\n    unsigned long a18;\n    unsigned long a19;\n    unsigned long sessionStats[40];\n  }\nShrPcGemStatSType;\n\nunion ShrPcStatUnion\n  {\n    ShrPcMonStatSType monitor;\n    ShrPcGemStatSType gem;\n  };\n\ntypedef struct\n  {\n    int processId;\n    int sessionId;\n    ShrPcCommonStatSType cmn;\n    union ShrPcStatUnion u;\n  } ShrPcStatsSType;\n\ntypedef struct\n  {\n    unsigned long *p1;\n    unsigned long *p2;\n    unsigned long *p3;\n    unsigned long *p4;\n    unsigned long *p5;\n    unsigned long *p6;\n    unsigned long *p7;\n    unsigned long *p8;\n    unsigned long *p9;\n    unsigned long *p10;\n    unsigned long *p11;\n  }\nWorkEntrySType;\n\nWorkEntrySType Workspace;\n\nstatic void \nsetStatPointers (ShrPcStatsSType * statsPtr, long sessionId)\n{\n  statsPtr->sessionId = sessionId;\n  statsPtr->cmn.a1 = 0;\n  statsPtr->cmn.n1 = 5;\n\n  Local1 = &statsPtr->cmn.local1;\n  Local2 = &statsPtr->cmn.local2;\n  Local3 = &statsPtr->cmn.local3;\n  RDbf1 = &statsPtr->cmn.rdbf1;\n  RDbf2 = &statsPtr->cmn.rdbf2;\n  RDbf3 = &statsPtr->cmn.milli;\n  *RDbf3 = 1;\n\n  IntVc1 = &statsPtr->u.gem.a1;\n  IntVc2 = &statsPtr->u.gem.a2;\n  IntCode3 = &statsPtr->u.gem.a3;\n  IntCode4 = &statsPtr->u.gem.a4;\n  IntCode5 = &statsPtr->u.gem.a5;\n  IntCode6 = &statsPtr->u.gem.a6;\n\n  {\n    WorkEntrySType *workSpPtr;\n    workSpPtr = &Workspace;\n    workSpPtr->p1 = &statsPtr->u.gem.a7;\n    workSpPtr->p2 = &statsPtr->u.gem.a8;\n    workSpPtr->p3 = &statsPtr->u.gem.a9;\n    workSpPtr->p4 = &statsPtr->u.gem.a10;\n    workSpPtr->p5 = &statsPtr->u.gem.a11;\n    workSpPtr->p6 = &statsPtr->u.gem.a12;\n    workSpPtr->p7 = &statsPtr->u.gem.a13;\n    workSpPtr->p8 = &statsPtr->u.gem.a14;\n    workSpPtr->p9 = &statsPtr->u.gem.a15;\n    workSpPtr->p10 = &statsPtr->u.gem.a16;\n    workSpPtr->p11 = &statsPtr->u.gem.a17;\n  }\n  Lom1 = &statsPtr->u.gem.c1;\n  Lom2 = &statsPtr->u.gem.c2;\n  Lom3 = &statsPtr->u.gem.c3;\n  Lom4 = &statsPtr->u.gem.c4;\n  Lom5 = &statsPtr->u.gem.c5;\n  Lom6 = &statsPtr->u.gem.c6;\n  Lom7 = &statsPtr->u.gem.c7;\n  Lom8 = &statsPtr->u.gem.c8;\n  Lom9 = &statsPtr->u.gem.c9;\n  Lom10 = &statsPtr->u.gem.c10;\n  RDbf11 = &statsPtr->u.gem.c11;\n  RDbf12 = &statsPtr->u.gem.c12;\n}\n\ntypedef struct\n{\n  ShrPcStatsSType stats;\n} ShrPcPteSType;\n\nShrPcPteSType MyPte;\n\nstatic void \ninitPte (void *shrpcPtr, long sessionId)\n{\n  ShrPcPteSType *ptePtr;\n\n  ptePtr = &MyPte;\n  setStatPointers (&ptePtr->stats, sessionId);\n}\n\nvoid \nInitCache (int sessionId)\n{\n  initPte (0, sessionId);\n}\n\nint \nmain (int argc, char *argv[])\n{\n  InitCache (5);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020402-3.c",
    "content": "/* extracted from gdb sources */\n\ntypedef unsigned long long CORE_ADDR;\n\nstruct blockvector;\n\nstruct symtab {\n  struct blockvector *blockvector;\n};\n\nstruct sec {\n  void *unused;\n};\n\nstruct symbol {\n  int len;\n  char *name;\n};\n\nstruct block {\n\tCORE_ADDR startaddr, endaddr;\n\tstruct symbol *function;\n\tstruct block *superblock;\n\tunsigned char gcc_compile_flag;\n\tint nsyms;\n\tstruct symbol syms[1];\n};\n\nstruct blockvector {\n\tint nblocks;\n\tstruct block *block[2];\n};\n\nstruct blockvector *blockvector_for_pc_sect(register CORE_ADDR pc,\n\t\t\t\t\t    struct symtab *symtab)\n{\n  register struct block *b;\n  register int bot, top, half;\n  struct blockvector *bl;\n\n  bl = symtab->blockvector;\n  b = bl->block[0];\n\n  bot = 0;\n  top = bl->nblocks;\n\n  while (top - bot > 1)\n    {\n      half = (top - bot + 1) >> 1;\n      b = bl->block[bot + half];\n      if (b->startaddr <= pc)\n\tbot += half;\n      else\n\ttop = bot + half;\n    }\n\n  while (bot >= 0)\n    {\n      b = bl->block[bot];\n      if (b->endaddr > pc)\n\t{\n\t  return bl;\n\t}\n      bot--;\n    }\n  return 0;\n}\n\nint main(void)\n{\n  struct block a = { 0, 0x10000, 0, 0, 1, 20 };\n  struct block b = { 0x10000, 0x20000, 0, 0, 1, 20 };\n  struct blockvector bv = { 2, { &a, &b } };\n  struct symtab s = { &bv };\n\n  struct blockvector *ret;\n\n  ret = blockvector_for_pc_sect(0x500, &s);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020404-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-skip-if \"pointers can be truncated\" { m32c-*-* } \"*\" \"\" } */\n/* Extracted from GDB sources. */\n\ntypedef long long bfd_signed_vma;\ntypedef bfd_signed_vma file_ptr;\n\ntypedef enum bfd_boolean {false, true} boolean;\n\ntypedef unsigned long long bfd_size_type;\n\ntypedef unsigned int flagword;\n\ntypedef unsigned long long CORE_ADDR;\ntypedef unsigned long long bfd_vma;\n\nstruct bfd_struct {\n\tint x;\n};\n\nstruct asection_struct {\n  unsigned int user_set_vma : 1;\n  bfd_vma vma;\n  bfd_vma lma;\n  unsigned int alignment_power;\n  unsigned int entsize;\n};\n\ntypedef struct bfd_struct bfd;\ntypedef struct asection_struct asection;\n\nstatic bfd *\nbfd_openw_with_cleanup (char *filename, const char *target, char *mode);\n\nstatic asection *\nbfd_make_section_anyway (bfd *abfd, const char *name);\n\nstatic boolean\nbfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val);\n\nstatic boolean\nbfd_set_section_flags (bfd *abfd, asection *sec, flagword flags);\n\nstatic boolean\nbfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count);\n\nstatic void\ndump_bfd_file (char *filename, char *mode,\n               char *target, CORE_ADDR vaddr,\n               char *buf, int len)\n{\n  bfd *obfd;\n  asection *osection;\n\n  obfd = bfd_openw_with_cleanup (filename, target, mode);\n  osection = bfd_make_section_anyway (obfd, \".newsec\");\n  bfd_set_section_size (obfd, osection, len);\n  (((osection)->vma = (osection)->lma= (vaddr)), ((osection)->user_set_vma = (boolean)true), true);\n  (((osection)->alignment_power = (0)),true);\n  bfd_set_section_flags (obfd, osection, 0x203);\n  osection->entsize = 0;\n  bfd_set_section_contents (obfd, osection, buf, 0, len);\n}\n\nstatic bfd *\nbfd_openw_with_cleanup (char *filename, const char *target, char *mode)\n{\n\tstatic bfd foo_bfd = { 0 };\n\treturn &foo_bfd;\n}\n\nstatic asection *\nbfd_make_section_anyway (bfd *abfd, const char *name)\n{\n\tstatic asection foo_section = { false, 0x0, 0x0, 0 };\n\n\treturn &foo_section;\n}\n\nstatic boolean\nbfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val)\n{\n\treturn true;\n}\n\nstatic boolean\nbfd_set_section_flags (bfd *abfd, asection *sec, flagword flags)\n{\n}\n\nstatic boolean\nbfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count)\n{\n\tif (count != (bfd_size_type)0x1eadbeef)\n\t\tabort();\n}\n\nstatic char hello[] = \"hello\";\n\nint main(void)\n{\n\tdump_bfd_file(0, 0, 0, (CORE_ADDR)0xdeadbeef, hello, (int)0x1eadbeef);\n\texit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020406-1.c",
    "content": "// Origin: abbott@dima.unige.it\n// PR c/5120\n\nextern void * malloc (__SIZE_TYPE__);\nextern void * calloc (__SIZE_TYPE__, __SIZE_TYPE__);\n\ntypedef unsigned int FFelem;\n\nFFelem FFmul(const FFelem x, const FFelem y)\n{\n  return x;\n}\n\n\nstruct DUPFFstruct\n{\n  int maxdeg;\n  int deg;\n  FFelem *coeffs;\n};\n\ntypedef struct DUPFFstruct *DUPFF;\n\n\nint DUPFFdeg(const DUPFF f)\n{\n  return f->deg;\n}\n\n\nDUPFF DUPFFnew(const int maxdeg)\n{\n  DUPFF ans = (DUPFF)malloc(sizeof(struct DUPFFstruct));\n  ans->coeffs = 0;\n  if (maxdeg >= 0) ans->coeffs = (FFelem*)calloc(maxdeg+1,sizeof(FFelem));\n  ans->maxdeg = maxdeg;\n  ans->deg = -1;\n  return ans;\n}\n\nvoid DUPFFfree(DUPFF x)\n{\n}\n\nvoid DUPFFswap(DUPFF x, DUPFF y)\n{\n}\n\n\nDUPFF DUPFFcopy(const DUPFF x)\n{\n  return x;\n}\n\n\nvoid DUPFFshift_add(DUPFF f, const DUPFF g, int deg, const FFelem coeff)\n{\n}\n\n\nDUPFF DUPFFexgcd(DUPFF *fcofac, DUPFF *gcofac, const DUPFF f, const DUPFF g)\n{\n  DUPFF u, v, uf, ug, vf, vg;\n  FFelem q, lcu, lcvrecip, p;\n  int df, dg, du, dv;\n\n  printf(\"DUPFFexgcd called on degrees %d and %d\\n\", DUPFFdeg(f), DUPFFdeg(g));\n  if (DUPFFdeg(f) < DUPFFdeg(g)) return DUPFFexgcd(gcofac, fcofac, g, f);  /*** BUG IN THIS LINE ***/\n  if (DUPFFdeg(f) != 2 || DUPFFdeg(g) != 1) abort();\n  if (f->coeffs[0] == 0) return f;\n  /****** NEVER REACH HERE IN THE EXAMPLE ******/\n  p = 2;\n\n  df = DUPFFdeg(f);  if (df < 0) df = 0; /* both inputs are zero */\n  dg = DUPFFdeg(g);  if (dg < 0) dg = 0; /* one input is zero */\n  u = DUPFFcopy(f);\n  v = DUPFFcopy(g);\n\n  uf = DUPFFnew(dg); uf->coeffs[0] = 1; uf->deg = 0;\n  ug = DUPFFnew(df);\n  vf = DUPFFnew(dg);\n  vg = DUPFFnew(df); vg->coeffs[0] = 1; vg->deg = 0;\n\n  while (DUPFFdeg(v) > 0)\n  {\n    dv = DUPFFdeg(v);\n    lcvrecip = FFmul(1, v->coeffs[dv]);\n    while (DUPFFdeg(u) >= dv)\n    {\n      du = DUPFFdeg(u);\n      lcu = u->coeffs[du];\n      q = FFmul(lcu, lcvrecip);\n      DUPFFshift_add(u, v, du-dv, p-q);\n      DUPFFshift_add(uf, vf, du-dv, p-q);\n      DUPFFshift_add(ug, vg, du-dv, p-q);\n    }\n    DUPFFswap(u, v);\n    DUPFFswap(uf, vf);\n    DUPFFswap(ug, vg);\n  }\n  if (DUPFFdeg(v) == 0)\n  {\n    DUPFFswap(u, v);\n    DUPFFswap(uf, vf);\n    DUPFFswap(ug, vg);\n  }\n  DUPFFfree(vf);\n  DUPFFfree(vg);\n  DUPFFfree(v);\n  *fcofac = uf;\n  *gcofac = ug;\n  return u;\n}\n\n\n\nint main()\n{\n  DUPFF f, g, cf, cg, h;\n  f = DUPFFnew(1); f->coeffs[1] = 1; f->deg = 1;\n  g = DUPFFnew(2); g->coeffs[2] = 1; g->deg = 2;\n\n  printf(\"calling DUPFFexgcd on degrees %d and %d\\n\", DUPFFdeg(f), DUPFFdeg(g)) ;\n  h = DUPFFexgcd(&cf, &cg, f, g);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020411-1.c",
    "content": "/* PR optimization/6177\n   This testcase ICEd because expr.c did not expect to see a CONCAT\n   as array rtl.  */\n\nextern void abort (void);\nextern void exit (int);\n\n__complex__ float foo (void)\n{\n  __complex__ float f[1];\n  __real__ f[0] = 1.0;\n  __imag__ f[0] = 1.0;\n  f[0] = __builtin_conjf (f[0]);\n  return f[0];\n}\n\nint main (void)\n{\n  __complex__ double d[1];\n  d[0] = foo ();\n  if (__real__ d[0] != 1.0\n      || __imag__ d[0] != -1.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020412-1.c",
    "content": "/* PR c/3711\n   This testcase ICEd on IA-32 at -O0 and was miscompiled otherwise,\n   because std_expand_builtin_va_arg didn't handle variable size types.  */\n/* { dg-require-effective-target alloca } */\n\n#include <stdarg.h>\n\nextern void abort (void);\nextern void exit (int);\n\nvoid bar (int c)\n{\n  static int d = '0';\n\n  if (c != d++)\n    abort ();\n  if (c < '0' || c > '9')\n    abort ();\n}\n\nvoid foo (int size, ...)\n{\n  struct\n  {\n    char x[size];\n  } d;\n  va_list ap;\n  int i;\n\n  va_start (ap, size);\n  d = va_arg (ap, typeof (d));\n  for (i = 0; i < size; i++)\n    bar (d.x[i]);\n  d = va_arg (ap, typeof (d));\n  for (i = 0; i < size; i++)\n    bar (d.x[i]);\n  va_end (ap);\n}\n\nint main (void)\n{\n  int z = 5;\n  struct { char a[z]; } x, y;\n          \n  x.a[0] = '0';\n  x.a[1] = '1';\n  x.a[2] = '2';\n  x.a[3] = '3';\n  x.a[4] = '4';\n  y.a[0] = '5';\n  y.a[1] = '6';\n  y.a[2] = '7';\n  y.a[3] = '8';\n  y.a[4] = '9';\n  foo (z, x, y);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020413-1.c",
    "content": "void test(long double val, int *eval)\n{\n  long double tmp = 1.0l;\n  int i = 0;\n\n  if (val < 0.0l)\n    val = -val;\n\n  if (val >= tmp)\n    while (tmp < val)\n      {\n\ttmp *= 2.0l;\n\tif (i++ >= 10)\n\t  abort ();\n      }\n  else if (val != 0.0l)\n    while (val < tmp)\n      {\n\ttmp /= 2.0l;\n\tif (i++ >= 10)\n\t  abort ();\n      }\n\n  *eval = i;\n}\n\nint main(void)\n{\n  int eval;\n\n  test(3.0, &eval);\n  test(3.5, &eval);\n  test(4.0, &eval);\n  test(5.0, &eval);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020418-1.c",
    "content": "/* ifcvt accidentally deletes a referenced label while generating\n   conditional traps on machines having such patterns */\n\nstruct foo { int a; };\n\nvoid gcc_crash(struct foo *p)\n{\n\tif (__builtin_expect(p->a < 52, 0))\n\t\t__builtin_trap();\n top:\n\tp->a++;\n\tif (p->a >= 62)\n\t\tgoto top;\n}\n\nint main(void)\n{\n\tstruct foo x;\n\n\tx.a = 53;\n\tgcc_crash(&x);\n\n\texit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020423-1.c",
    "content": "/* PR c/5430 */\n/* Verify that the multiplicative folding code is not fooled\n   by the mix between signed variables and unsigned constants. */\n\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  int my_int = 924;\n  unsigned int result;\n\n  result = ((my_int*2 + 4) - 8U) / 2;\n  if (result != 922U)\n    abort();\n         \n  result = ((my_int*2 - 4U) + 2) / 2;\n  if (result != 923U)\n    abort();\n\n  result = (((my_int + 2) * 2) - 8U - 4) / 2;\n  if (result != 920U)\n    abort();\n  result = (((my_int + 2) * 2) - (8U + 4)) / 2;\n  if (result != 920U)\n    abort();\n\n  result = ((my_int*4 + 2U) - 4U) / 2;\n  if (result != 1847U)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020503-1.c",
    "content": "/* PR 6534 */\n/* GCSE unified the two i<0 tests, but if-conversion to ui=abs(i) \n   insertted the code at the wrong place corrupting the i<0 test.  */\n\nvoid abort (void);\nstatic char *\ninttostr (long i, char buf[128])\n{\n  unsigned long ui = i;\n  char *p = buf + 127;\n  *p = '\\0';\n  if (i < 0)\n    ui = -ui;\n  do\n    *--p = '0' + ui % 10;\n  while ((ui /= 10) != 0);\n  if (i < 0)\n    *--p = '-';\n  return p;\n}\n\nint\nmain ()\n{\n  char buf[128], *p;\n\n  p = inttostr (-1, buf);\n  if (*p != '-')\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020506-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test that (A & C1) op C2 optimizations behave correctly where C1 is\n   a constant power of 2, op is == or !=, and C2 is C1 or zero.\n\n   Written by Roger Sayle, 5th May 2002.  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid test1 (signed char c, int set);\nvoid test2 (unsigned char c, int set);\nvoid test3 (short s, int set);\nvoid test4 (unsigned short s, int set);\nvoid test5 (int i, int set);\nvoid test6 (unsigned int i, int set);\nvoid test7 (long long l, int set);\nvoid test8 (unsigned long long l, int set);\n\n#ifndef LONG_LONG_MAX\n#define LONG_LONG_MAX __LONG_LONG_MAX__\n#endif\n#ifndef LONG_LONG_MIN\n#define LONG_LONG_MIN (-LONG_LONG_MAX-1LL)\n#endif\n#ifndef ULONG_LONG_MAX\n#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)\n#endif\n\n\nvoid\ntest1 (signed char c, int set)\n{\n  if ((c & (SCHAR_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) == (SCHAR_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != (SCHAR_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest2 (unsigned char c, int set)\n{\n  if ((c & (SCHAR_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) == (SCHAR_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != (SCHAR_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest3 (short s, int set)\n{\n  if ((s & (SHRT_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) == (SHRT_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != (SHRT_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest4 (unsigned short s, int set)\n{\n  if ((s & (SHRT_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) == (SHRT_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != (SHRT_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest5 (int i, int set)\n{\n  if ((i & (INT_MAX+1U)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((i & (INT_MAX+1U)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) == (INT_MAX+1U))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) != (INT_MAX+1U))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest6 (unsigned int i, int set)\n{\n  if ((i & (INT_MAX+1U)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((i & (INT_MAX+1U)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) == (INT_MAX+1U))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) != (INT_MAX+1U))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest7 (long long l, int set)\n{\n  if ((l & (LONG_LONG_MAX+1ULL)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) == (LONG_LONG_MAX+1ULL))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != (LONG_LONG_MAX+1ULL))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest8 (unsigned long long l, int set)\n{\n  if ((l & (LONG_LONG_MAX+1ULL)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) == (LONG_LONG_MAX+1ULL))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != (LONG_LONG_MAX+1ULL))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nint\nmain ()\n{\n  test1 (0, 0);\n  test1 (SCHAR_MAX, 0);\n  test1 (SCHAR_MIN, 1);\n  test1 (UCHAR_MAX, 1);\n\n  test2 (0, 0);\n  test2 (SCHAR_MAX, 0);\n  test2 (SCHAR_MIN, 1);\n  test2 (UCHAR_MAX, 1);\n\n  test3 (0, 0);\n  test3 (SHRT_MAX, 0);\n  test3 (SHRT_MIN, 1);\n  test3 (USHRT_MAX, 1);\n\n  test4 (0, 0);\n  test4 (SHRT_MAX, 0);\n  test4 (SHRT_MIN, 1);\n  test4 (USHRT_MAX, 1);\n\n  test5 (0, 0);\n  test5 (INT_MAX, 0);\n  test5 (INT_MIN, 1);\n  test5 (UINT_MAX, 1);\n\n  test6 (0, 0);\n  test6 (INT_MAX, 0);\n  test6 (INT_MIN, 1);\n  test6 (UINT_MAX, 1);\n\n  test7 (0, 0);\n  test7 (LONG_LONG_MAX, 0);\n  test7 (LONG_LONG_MIN, 1);\n  test7 (ULONG_LONG_MAX, 1);\n\n  test8 (0, 0);\n  test8 (LONG_LONG_MAX, 0);\n  test8 (LONG_LONG_MIN, 1);\n  test8 (ULONG_LONG_MAX, 1);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020508-1.c",
    "content": "/* This tests the rotate patterns that some machines support.  */\n\n#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((unsigned char)0xf234U)\n#define SHORT_VALUE ((unsigned short)0xf234U)\n#define INT_VALUE 0xf234U\n#define LONG_VALUE 0xf2345678LU\n#define LL_VALUE 0xf2345678abcdef0LLU\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nunsigned char uc = CHAR_VALUE;\nunsigned short us = SHORT_VALUE;\nunsigned int ui = INT_VALUE;\nunsigned long ul = LONG_VALUE;\nunsigned long long ull = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020508-2.c",
    "content": "#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0x1234)\n#define SHORT_VALUE ((short)0x1234)\n#define INT_VALUE ((int)0x1234)\n#define LONG_VALUE ((long)0x12345678L)\n#define LL_VALUE ((long long)0x12345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020508-3.c",
    "content": "#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0xf234)\n#define SHORT_VALUE ((short)0xf234)\n#define INT_VALUE ((int)0xf234)\n#define LONG_VALUE ((long)0xf2345678L)\n#define LL_VALUE ((long long)0xf2345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020510-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test that optimizing ((c>=1) && (c<=127)) into (signed char)c < 0\n   doesn't cause any problems for the compiler and behaves correctly.\n\n   Written by Roger Sayle, 8th May 2002.  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid\ntestc (unsigned char c, int ok)\n{\n  if ((c>=1) && (c<=SCHAR_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntests (unsigned short s, int ok)\n{\n  if ((s>=1) && (s<=SHRT_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntesti (unsigned int i, int ok)\n{\n  if ((i>=1) && (i<=INT_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntestl (unsigned long l, int ok)\n{\n  if ((l>=1) && (l<=LONG_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint\nmain ()\n{\n  testc (0, 0);\n  testc (1, 1);\n  testc (SCHAR_MAX, 1);\n  testc (SCHAR_MAX+1, 0);\n  testc (UCHAR_MAX, 0);\n\n  tests (0, 0);\n  tests (1, 1);\n  tests (SHRT_MAX, 1);\n  tests (SHRT_MAX+1, 0);\n  tests (USHRT_MAX, 0);\n\n  testi (0, 0);\n  testi (1, 1);\n  testi (INT_MAX, 1);\n  testi (INT_MAX+1U, 0);\n  testi (UINT_MAX, 0);\n\n  testl (0, 0);\n  testl (1, 1);\n  testl (LONG_MAX, 1);\n  testl (LONG_MAX+1UL, 0);\n  testl (ULONG_MAX, 0);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020529-1.c",
    "content": "/* PR target/6838 from cato@df.lth.se.\n   cris-elf got an ICE with -O2: the insn matching\n      (insn 49 48 52 (parallel[ \n\t\t  (set (mem/s:HI (plus:SI (reg/v/f:SI 0 r0 [24])\n\t\t\t      (const_int 8 [0x8])) [5 <variable>.c+0 S2 A8])\n\t\t      (reg:HI 2 r2 [27]))\n\t\t  (set (reg/f:SI 2 r2 [31])\n\t\t      (plus:SI (reg/v/f:SI 0 r0 [24])\n\t\t\t  (const_int 8 [0x8])))\n\t      ] ) 24 {*mov_sidehi_mem} (nil)\n\t  (nil))\n   forced a splitter through the output pattern \"#\", but there was no\n   matching splitter.  */\n\nstruct xx\n {\n   int a;\n   struct xx *b;\n   short c;\n };\n\nint f1 (struct xx *);\nvoid f2 (void);\n\nint\nfoo (struct xx *p, int b, int c, int d)\n{\n  int a;\n\n  for (;;)\n    {\n      a = f1(p);\n      if (a)\n\treturn (0);\n      if (b)\n\tcontinue;\n      p->c = d;\n      if (p->a)\n\tf2 ();\n      if (c)\n\tf2 ();\n      d = p->c;\n      switch (a)\n\t{\n\tcase 1:\n\t  if (p->b)\n\t    f2 ();\n\t  if (c)\n\t    f2 ();\n\tdefault:\n\t  break;\n\t}\n    }\n  return d;\n}\n\nint main (void)\n{\n  struct xx s = {0, &s, 23};\n  if (foo (&s, 0, 0, 0) != 0 || s.a != 0 || s.b != &s || s.c != 0)\n    abort ();\n  exit (0);\n}\n\nint\nf1 (struct xx *p)\n{\n  static int beenhere = 0;\n  if (beenhere++ > 1)\n    abort ();\n  return beenhere > 1;\n}\n\nvoid\nf2 (void)\n{\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020611-1.c",
    "content": "/* PR target/6997.  Missing (set_attr \"cc\" \"none\") in sleu pattern in\n   cris.md.  Testcase from hp@axis.com.  */\n\nint p;\nint k;\nunsigned int n;\n\nvoid x ()\n{\n  unsigned int h;\n\n  h = n <= 30;\n  if (h)\n    p = 1;\n  else\n    p = 0;\n\n  if (h)\n    k = 1;\n  else\n    k = 0;\n}\n\nunsigned int n = 30;\n\nmain ()\n{\n  x ();\n  if (p != 1 || k != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020614-1.c",
    "content": "/* PR c/6677 */\n/* Verify that GCC doesn't perform illegal simplifications\n   when folding constants.  */\n\n#include <limits.h>\n\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  int i;\n  signed char j;\n  unsigned char k;\n\n  i = SCHAR_MAX;\n\n  j = ((signed char) (i << 1)) / 2;\n\n  if (j != -1)\n    abort();\n\n  j = ((signed char) (i * 2)) / 2;\n\n  if (j != -1)\n    abort();\n\n  i = UCHAR_MAX;\n\n  k = ((unsigned char) (i << 1)) / 2;\n\n  if (k != UCHAR_MAX/2)\n    abort();\n\n  k = ((unsigned char) (i * 2)) / 2;\n\n  if (k != UCHAR_MAX/2)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020615-1.c",
    "content": "/* PR target/7042.  When reorg.c changed branches into return insns, it\n   completely forgot about any current_function_epilogue_delay_list and\n   dropped those insns.  Uncovered on cris-axis-elf, where an insn in an\n   epilogue delay-slot set the return-value register with the testcase\n   below.  Derived from ghostscript-6.52 (GPL) by hp@axis.com.  */\n\ntypedef struct font_hints_s {\n  int axes_swapped;\n  int x_inverted, y_inverted;\n} font_hints;\ntypedef struct gs_fixed_point_s {\n  long x, y;\n} gs_fixed_point;\n\nint\nline_hints(const font_hints *fh, const gs_fixed_point *p0,\n\t   const gs_fixed_point *p1)\n{\n  long dx = p1->x - p0->x;\n  long dy = p1->y - p0->y;\n  long adx, ady;\n  int xi = fh->x_inverted, yi = fh->y_inverted;\n  int hints;\n  if (xi)\n    dx = -dx;\n  if (yi)\n    dy = -dy;\n  if (fh->axes_swapped) {\n    long t = dx;\n    int ti = xi;\n    dx = dy, xi = yi;\n    dy = t, yi = ti;\n  }\n  adx = dx < 0 ? -dx : dx;\n  ady = dy < 0 ? -dy : dy;\n  if (dy != 0 && (adx <= ady >> 4)) {\n    hints = dy > 0 ? 2 : 1;\n    if (xi)\n      hints ^= 3;\n  } else if (dx != 0 && (ady <= adx >> 4)) {\n    hints = dx < 0 ? 8 : 4;\n    if (yi)\n      hints ^= 12;\n  } else\n    hints = 0;\n  return hints;\n}\nint main ()\n{\n  static font_hints fh[] = {{0, 1, 0}, {0, 0, 1}, {0, 0, 0}};\n  static gs_fixed_point gsf[]\n    = {{0x30000, 0x13958}, {0x30000, 0x18189},\n       {0x13958, 0x30000}, {0x18189, 0x30000}};\n  if (line_hints (fh, gsf, gsf + 1) != 1\n      || line_hints (fh + 1, gsf + 2, gsf + 3) != 8\n      || line_hints (fh + 2, gsf + 2, gsf + 3) != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020619-1.c",
    "content": "#if (__SIZEOF_INT__ == 4)\ntypedef int int32;\n#elif (__SIZEOF_LONG__ == 4)\ntypedef long int32;\n#else\n#error Add target support for int32\n#endif\nstatic int32 ref(void)\n{\n  union {\n    char c[5];\n    int32 i;\n  } u;\n\n  __builtin_memset (&u, 0, sizeof(u));\n  u.c[0] = 1;\n  u.c[1] = 2;\n  u.c[2] = 3;\n  u.c[3] = 4;\n\n  return u.i;\n}\n\nint main()\n{\n  int32 b = ref();\n  if (b != 0x01020304\n      && b != 0x04030201)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020716-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint sub1 (int val)\n{\n  return val;\n}\n\nint testcond (int val)\n{\n  int flag1;\n\n    {\n      int t1 = val;\n        {\n          int t2 = t1;\n            {\n              flag1 = sub1 (t2) ==0;\n              goto lab1;\n            };\n        }\n      lab1: ;\n    }\n\n  if (flag1 != 0)\n    return 0x4d0000;\n  else\n    return 0;\n}\n\nint main (void)\n{\n  if (testcond (1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020720-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Ensure that fabs(x) < 0.0 optimization is working.\n\n   Written by Roger Sayle, 20th July 2002.  */\n\nextern void abort (void);\nextern double fabs (double);\nextern void link_error (void);\n\nvoid\nfoo (double x)\n{\n  double p, q;\n\n  p = fabs (x);\n  q = 0.0;\n  if (p < q)\n    link_error ();\n}\n\nint\nmain()\n{\n  foo (1.0);\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_error ()\n{\n  abort ();\n}\n#endif\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020805-1.c",
    "content": "/* This testcase was miscompiled on IA-32, because fold-const\n   assumed associate_trees is always done on PLUS_EXPR.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid check (unsigned int m)\n{\n  if (m != (unsigned int) -1)\n    abort ();\n}\n\nunsigned int n = 1;\n\nint main (void)\n{\n  unsigned int m;\n  m = (1 | (2 - n)) | (-n);\n  check (m);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020810-1.c",
    "content": "/* PR target/7559\n   This testcase was miscompiled on x86-64, because classify_argument\n   wrongly computed the offset of nested structure fields.  */\n\nextern void abort (void);\n\nstruct A\n{\n  long x;\n};\n\nstruct R\n{\n  struct A a, b;\n};\n\nstruct R R = { 100, 200 };\n\nvoid f (struct R r)\n{\n  if (r.a.x != R.a.x || r.b.x != R.b.x)\n    abort ();\n}\n\nstruct R g (void)\n{\n  return R;\n}\n\nint main (void)\n{\n  struct R r;\n  f(R);\n  r = g();\n  if (r.a.x != R.a.x || r.b.x != R.b.x)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020819-1.c",
    "content": "foo ()\n{\n  return 0;\n}\n\nmain()\n{\n  int i, j, k, ccp_bad = 0;\n\n  for (i = 0; i < 10; i++)\n    {\n      for (j = 0; j < 10; j++)\n\tif (foo ())\n\t  ccp_bad = 1;\n    \n      k = ccp_bad != 0;\n      if (k)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020904-1.c",
    "content": "/* PR c/7102 */\n\n/* Verify that GCC zero-extends integer constants\n   in unsigned binary operations. */\n\ntypedef unsigned char u8;\n\nu8 fun(u8 y)\n{\n  u8 x=((u8)255)/y;\n  return x;\n}\n\nint main(void)\n{\n  if (fun((u8)2) != 127)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020911-1.c",
    "content": "extern void abort (void);\nunsigned short c = 0x8000;\nint main()\n{\n  if ((c-0x8000) < 0 || (c-0x8000) > 0x7fff)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020916-1.c",
    "content": "/* Distilled from try_pre_increment in flow.c.  If-conversion inserted\n   new instructions at the wrong place on ppc.  */\n\nint foo(int a)\n{\n  int x;\n  x = 0;\n  if (a > 0) x = 1;\n  if (a < 0) x = 1;\n  return x;\n}\n\nint main()\n{\n  if (foo(1) != 1)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20020920-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nstruct B\n{\n  int x;\n  int y;\n};\n\nstruct A\n{\n  int z;\n  struct B b;\n};\n\nstruct A\nf ()\n{\n  struct B b = { 0, 1 };\n  struct A a = { 2, b };\n  return a;\n}\n\nint\nmain (void)\n{\n  struct A a = f ();\n  if (a.z != 2 || a.b.x != 0 || a.b.y != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021010-1.c",
    "content": "#include <limits.h>\n\nint\nsub ()\n{\n  int dummy = 0, a = 16;\n\n  if (a / INT_MAX / 16 == 0)\n    return 0;\n  else\n    return a / INT_MAX / 16;\n}\n\nint\nmain ()\n{\n  if (sub () != 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021010-2.c",
    "content": "/* cse.c failure on x86 target.\n   Contributed by Stuart Hastings 10 Oct 2002 <stuart@apple.com> */\n#include <stdlib.h>\n\ntypedef signed short SInt16;\n\ntypedef struct {\n    SInt16 minx;\n    SInt16 maxx;\n    SInt16 miny;\n    SInt16 maxy;\n} IOGBounds;\n\nint expectedwidth = 50;\n\nunsigned int *global_vramPtr = (unsigned int *)0xa000;\n\nIOGBounds global_bounds = { 100, 150, 100, 150 };\nIOGBounds global_saveRect = { 75, 175, 75, 175 };\n\nmain()\n{\n  unsigned int *vramPtr;\n  int width;\n  IOGBounds saveRect = global_saveRect;\n  IOGBounds bounds = global_bounds;\n\n  if (saveRect.minx < bounds.minx) saveRect.minx = bounds.minx;\n  if (saveRect.maxx > bounds.maxx) saveRect.maxx = bounds.maxx;\n\n  vramPtr = global_vramPtr + (saveRect.miny - bounds.miny) ;\n  width = saveRect.maxx - saveRect.minx;\n\n  if (width != expectedwidth)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021011-1.c",
    "content": "/* PR opt/8165.  */\n\nextern void abort (void);\n\nchar buf[64];\n\nint\nmain (void)\n{\n  int i;\n\n  __builtin_strcpy (buf, \"mystring\");\n  if (__builtin_strcmp (buf, \"mystring\") != 0)\n    abort ();\n\n  for (i = 0; i < 16; ++i)\n    {\n      __builtin_strcpy (buf + i, \"mystring\");\n      if (__builtin_strcmp (buf + i, \"mystring\") != 0)\n\tabort ();\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021015-1.c",
    "content": "/* PR opt/7409.  */\n\nextern void abort (void);\n\nchar g_list[] = { '1' };\n\nvoid g (void *p, char *list, int length, char **elementPtr, char **nextPtr)\n{\n  if (*nextPtr != g_list)\n    abort ();\n\n  **nextPtr = 0;\n}\n\nint main (void)\n{\n  char *list = g_list;\n  char *element;\n  int i, length = 100;\n\n  for (i = 0; *list != 0; i++) \n    {\n      char *prevList = list;\n      g (0, list, length, &element, &list);\n      length -= (list - prevList);\n    }\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021024-1.c",
    "content": "/* Origin: PR target/6981 from Mattias Engdegaard <mattias@virtutech.se>.  */\n/* { dg-require-effective-target int32plus } */\n\nvoid exit (int);\nvoid abort (void);\n\nunsigned long long *cp, m;\n\nvoid foo (void)\n{\n}\n\nvoid bar (unsigned rop, unsigned long long *r)\n{\n  unsigned rs1, rs2, rd;\n\ntop:\n  rs2 = (rop >> 23) & 0x1ff;\n  rs1 = (rop >> 9) & 0x1ff;\n  rd = rop & 0x1ff;\n\n  *cp = 1;\n  m = r[rs1] + r[rs2];\n  *cp = 2;\n  foo();\n  if (!rd)\n    goto top;\n  r[rd] = 1;\n}\n\nint main(void)\n{\n  static unsigned long long r[64];\n  unsigned long long cr;\n  cp = &cr;\n\n  r[4] = 47;\n  r[8] = 11;\n  bar((8 << 23) | (4 << 9) | 15, r);\n\n  if (m != 47 + 11)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021111-1.c",
    "content": "/* Origin: PR c/8467 */\n\nextern void abort (void);\nextern void exit (int);\n\nint aim_callhandler(int sess, int conn, unsigned short family, unsigned short type);\n\nint aim_callhandler(int sess, int conn, unsigned short family, unsigned short type)\n{\n  static int i = 0;\n\n  if (!conn)\n    return 0;\n\n  if (type == 0xffff)\n    {\n      return 0;\n    }\n\n  if (i >= 1)\n    abort ();\n\n  i++;\n  return aim_callhandler(sess, conn, family, (unsigned short) 0xffff);\n}\n\nint main (void)\n{\n  aim_callhandler (0, 1, 0, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021113-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n\n/* This program tests a data flow bug that would cause constant propagation\n   to propagate constants through function calls.  */\n\nfoo (int *p)\n{\n  *p = 10;\n}\n\nmain()\n{\n  int *ptr = alloca (sizeof (int));\n  *ptr = 5;\n  foo (ptr);\n  if (*ptr == 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021118-1.c",
    "content": "struct s { int f[4]; };\n\nint foo (struct s s, int x1, int x2, int x3, int x4, int x5, int x6, int x7)\n{\n  return s.f[3] + x7;\n}\n\nint main ()\n{\n  struct s s = { 1, 2, 3, 4 };\n\n  if (foo (s, 100, 200, 300, 400, 500, 600, 700) != 704)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021118-2.c",
    "content": "/* Originally added to test SH constant pool layout.  t1() failed for\n   non-PIC and t2() failed for PIC.  */\n\nint t1 (float *f, int i,\n\tvoid (*f1) (double),\n\tvoid (*f2) (float, float))\n{\n  f1 (3.0);\n  f[i] = f[i + 1];\n  f2 (2.5f, 3.5f);\n}\n\nint t2 (float *f, int i,\n\tvoid (*f1) (double),\n\tvoid (*f2) (float, float),\n\tvoid (*f3) (float))\n{\n  f3 (6.0f);\n  f1 (3.0);\n  f[i] = f[i + 1];\n  f2 (2.5f, 3.5f);\n}\n\nvoid f1 (double d)\n{\n  if (d != 3.0)\n    abort ();\n}\n\nvoid f2 (float f1, float f2)\n{\n  if (f1 != 2.5f || f2 != 3.5f)\n    abort ();\n}\n\nvoid f3 (float f)\n{\n  if (f != 6.0f)\n    abort ();\n}\n\nint main ()\n{\n  float f[3] = { 2.0f, 3.0f, 4.0f };\n  t1 (f, 0, f1, f2);\n  t2 (f, 1, f1, f2, f3);\n  if (f[0] != 3.0f && f[1] != 4.0f)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021118-3.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint\nfoo (int x)\n{\n  if (x == -2 || -x - 100 >= 0)\n    abort ();\n  return 0;\n}\n           \nint\nmain ()\n{\n  foo (-3);\n  foo (-99);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021119-1.c",
    "content": "/* PR 8639.  */\n\nextern void abort(void);\n\nint foo (int i)\n{\n  int r;\n  r = (80 - 4 * i) / 20;\n  return r;\n}\n    \nint main ()\n{\n  if (foo (1) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021120-1.c",
    "content": "/* Macros to emit \"L Nxx R\" for each octal number xx between 000 and 037.  */\n#define OP1(L, N, R, I, J) L N##I##J R\n#define OP2(L, N, R, I) \\\n    OP1(L, N, R, 0, I), OP1(L, N, R, 1, I), \\\n    OP1(L, N, R, 2, I), OP1(L, N, R, 3, I)\n#define OP(L, N, R) \\\n    OP2(L, N, R, 0), OP2(L, N, R, 1), OP2(L, N, R, 2), OP2(L, N, R, 3), \\\n    OP2(L, N, R, 4), OP2(L, N, R, 5), OP2(L, N, R, 6), OP2(L, N, R, 7)\n\n/* Declare 32 unique variables with prefix N.  */\n#define DECLARE(N) OP (, N,)\n\n/* Copy 32 variables with prefix N from the array at ADDR.\n   Leave ADDR pointing to the end of the array.  */\n#define COPYIN(N, ADDR) OP (, N, = *(ADDR++))\n\n/* Likewise, but copy the other way.  */\n#define COPYOUT(N, ADDR) OP (*(ADDR++) =, N,)\n\n/* Add the contents of the array at ADDR to 32 variables with prefix N.\n   Leave ADDR pointing to the end of the array.  */\n#define ADD(N, ADDR) OP (, N, += *(ADDR++))\n\nvolatile double gd[32];\nvolatile float gf[32];\n\nvoid foo (int n)\n{\n  double DECLARE(d);\n  float DECLARE(f);\n  volatile double *pd;\n  volatile float *pf;\n  int i;\n\n  pd = gd; COPYIN (d, pd);\n  for (i = 0; i < n; i++)\n    {\n      pf = gf; COPYIN (f, pf);\n      pd = gd; ADD (d, pd);\n      pd = gd; ADD (d, pd);\n      pd = gd; ADD (d, pd);\n      pf = gf; COPYOUT (f, pf);\n    }\n  pd = gd; COPYOUT (d, pd);\n}\n\nint main ()\n{\n  int i;\n\n  for (i = 0; i < 32; i++)\n    gd[i] = i, gf[i] = i;\n  foo (1);\n  for (i = 0; i < 32; i++)\n    if (gd[i] != i * 4 || gf[i] != i)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021120-2.c",
    "content": "int g1, g2;\n\nvoid foo (int x)\n{\n  int y;\n\n  if (x)\n    y = 793;\n  else\n    y = 793;\n  g1 = 7930 / y;\n  g2 = 7930 / x;\n}\n\nint main ()\n{\n  foo (793);\n  if (g1 != 10 || g2 != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021120-3.c",
    "content": "/* Test whether a partly call-clobbered register will be moved over a call.\n   Although the original test case didn't use any GNUisms, it proved\n   difficult to reduce without the named register extension.  */\n#if __SH64__ == 32\n#define LOC asm (\"r10\")\n#else\n#define LOC\n#endif\n\nunsigned int foo (char *c, unsigned int x, unsigned int y)\n{\n  register unsigned int z LOC;\n\n  sprintf (c, \"%d\", x / y);\n  z = x + 1;\n  return z / (y + 1);\n}\n\nint main ()\n{\n  char c[16];\n\n  if (foo (c, ~1U, 4) != (~0U / 5))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021127-1.c",
    "content": "/* { dg-options \"-std=c99\" } */\n\nlong long a = -1;\nlong long llabs (long long);\nvoid abort (void);\nint\nmain()\n{\n  if (llabs (a) != 1)\n    abort ();\n  return 0;\n}\nlong long llabs (long long b)\n{\n\tabort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021204-1.c",
    "content": "/* This test was miscompiled when using sibling call optimization,\n   because X ? Y : Y - 1 optimization changed X into !X in place\n   and haven't reverted it if do_store_flag was successful, so\n   when expanding the expression the second time it was\n   !X ? Y : Y - 1.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid foo (int x)\n{\n  if (x != 1)\n    abort ();\n}\n\nint z;\n\nint main (int argc, char **argv)\n{\n  char *a = \"test\";\n  char *b = a + 2;\n\n  foo (z > 0 ? b - a : b - a - 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20021219-1.c",
    "content": "/* PR optimization/8988 */\n/* Contributed by Kevin Easton */\n\nvoid foo(char *p1, char **p2)\n{}\n \nint main(void)\n{\n  char str[] = \"foo { xx }\";\n  char *ptr = str + 5;\n\n  foo(ptr, &ptr);\n\n  while (*ptr && (*ptr == 13 || *ptr == 32))\n    ptr++;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030105-1.c",
    "content": "int __attribute__ ((noinline))\nfoo ()\n{\n  const int a[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };\n  int i, sum;\n\n  sum = 0;\n  for (i = 0; i < sizeof (a) / sizeof (*a); i++)\n    sum += a[i];\n\n  return sum;\n}\n\nint\nmain ()\n{\n  if (foo () != 28)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030109-1.c",
    "content": "/* PR c/8032 */\n/* Verify that an empty initializer inside a partial\n   parent initializer doesn't confuse GCC.  */\n\nstruct X\n{\n  int a;\n  int b;\n  int z[];\n};\n\nstruct X x = { .b = 40, .z = {} };\n\nint main ()\n{\n  if (x.b != 40)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030117-1.c",
    "content": "int foo (int, int, int);\nint bar (int, int, int);\n\nint main (void)\n{\n  if (foo (5, 10, 21) != 12)\n    abort ();\n\n  if (bar (9, 12, 15) != 150)\n    abort ();\n\n  exit (0);\n}\n\nint foo (int x, int y, int z)\n{\n  return (x + y + z) / 3;\n}\n\nint bar (int x, int y, int z)\n{\n  return foo (x * x, y * y, z * z);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030120-1.c",
    "content": "/* On H8/300 port, NOTICE_UPDATE_CC had a bug that causes the final\n   pass to remove test insns that should be kept.  */\n\nunsigned short\ntest1 (unsigned short w)\n{\n  if ((w & 0xff00) == 0)\n    {\n      if (w == 0)\n\tw = 2;\n    }\n  return w;\n}\n\nunsigned long\ntest2 (unsigned long w)\n{\n  if ((w & 0xffff0000) == 0)\n    {\n      if (w == 0)\n\tw = 2;\n    }\n  return w;\n}\n\nint\ntest3 (unsigned short a)\n{\n  if (a & 1)\n    return 1;\n  else if (a)\n    return 1;\n  else\n    return 0;\n}\n\nint\nmain ()\n{\n  if (test1 (1) != 1)\n    abort ();\n\n  if (test2 (1) != 1)\n    abort ();\n\n  if (test3 (2) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030120-2.c",
    "content": "/* PR 8848 */\n\nextern void abort ();\n\nint foo(int status)\n{\n  int s = 0;\n  if (status == 1) s=1;\n  if (status == 3) s=3;\n  if (status == 4) s=4;\n  return s;\n}\n\nint main()\n{\n  if (foo (3) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030125-1.c",
    "content": "/* Verify whether math functions are simplified.  */\n/* { dg-require-effective-target c99_runtime } */\n/* { dg-require-weak } */\ndouble sin(double);\ndouble floor(double);\nfloat \nt(float a)\n{\n\treturn sin(a);\n}\nfloat \nq(float a)\n{\n\treturn floor(a);\n}\ndouble\nq1(float a)\n{\n\treturn floor(a);\n}\nmain()\n{\n#ifdef __OPTIMIZE__\n\tif (t(0)!=0)\n\t\tabort ();\n\tif (q(0)!=0)\n\t\tabort ();\n\tif (q1(0)!=0)\n\t\tabort ();\n#endif\n\treturn 0;\n}\n__attribute__ ((weak))\ndouble\nfloor(double a)\n{\n\tabort ();\n}\n__attribute__ ((weak))\nfloat\nfloorf(float a)\n{\n\treturn a;\n}\n__attribute__ ((weak))\ndouble\nsin(double a)\n{\n\treturn a;\n}\n__attribute__ ((weak))\nfloat\nsinf(float a)\n{\n\tabort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030128-1.c",
    "content": "unsigned char x = 50;\nvolatile short y = -5;\n\nint main ()\n{\n  x /= y;\n  if (x != (unsigned char) -10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030203-1.c",
    "content": "void f(int);\nint do_layer3(int single)\n{\n  int stereo1;\n\n  if(single >= 0) /* stream is stereo, but force to mono */\n    stereo1 = 1;\n  else\n    stereo1 = 2;\n  f(single);\n\n  return stereo1;\n}\n\nextern void abort ();\nint main()\n{\n  if (do_layer3(-1) != 2)\n    abort ();\n  return 0;\n}\n\nvoid f(int i) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030209-1.c",
    "content": "#ifdef STACK_SIZE\n#if STACK_SIZE < 8*100*100\n#define SKIP\n#endif\n#endif\n\n#ifndef SKIP\ndouble x[100][100];\nint main ()\n{\n  int i;\n\n  i = 99;\n  x[i][0] = 42;\n  if (x[99][0] != 42)\n    abort ();\n  exit (0);\n}\n#else\nint\nmain ()\n{\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030216-1.c",
    "content": "/* This test requires constant propagation of loads and stores to be\n   enabled.  This is only guaranteed at -O2 and higher.  Do not run\n   at -O1.  */\n/* { dg-skip-if \"requires higher optimization\" { *-*-* } \"-O1\" \"\" } */\n\nvoid link_error (void);\nconst double one=1.0;\nmain ()\n{\n#ifdef __OPTIMIZE__\n  if ((int) one != 1)\n    link_error ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030218-1.c",
    "content": "/*  On H8, the predicate general_operand_src(op,mode) used to ignore\n    mode when op is a (mem (post_inc ...)).  As a result, the pattern\n    for extendhisi2 was recognized as extendqisi2.  */\n\nextern void abort ();\nextern void exit (int);\n\nshort *q;\n\nlong\nfoo (short *p)\n{\n  long b = *p;\n  q = p + 1;\n  return b;\n}\n\nint\nmain ()\n{\n  short a = 0xff00;\n  if (foo (&a) != (long) (short) 0xff00)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030221-1.c",
    "content": "/* PR optimization/8613 */\n/* Contributed by Glen Nakamura */\n\nextern void abort (void);\n \nint main (void)\n{\n  char buf[16] = \"1234567890\";\n  char *p = buf;\n\n  *p++ = (char) __builtin_strlen (buf);\n\n  if ((buf[0] != 10) || (p - buf != 1))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030222-1.c",
    "content": "/* Verify that we get the low part of the long long as an int.  We\n   used to get it wrong on big-endian machines, if register allocation\n   succeeded at all.  We use volatile to make sure the long long is\n   actually truncated to int, in case a single register is wide enough\n   for a long long.  */\n/* { dg-skip-if \"asm would require extra shift-left-4-byte\" { spu-*-* } \"*\" \"\" } */\n#include <limits.h>\n\nvoid\nll_to_int (long long x, volatile int *p)\n{\n  int i;\n  asm (\"\" : \"=r\" (i) : \"0\" (x));\n  *p = i;\n}\n\nint val = INT_MIN + 1;\n\nint main() {\n  volatile int i;\n\n  ll_to_int ((long long)val, &i);\n  if (i != val)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030224-2.c",
    "content": "/* Make sure that we don't free any temp stack slots associated with\n   initializing marker before we're finished with them.  */\n\nextern void abort();\n\ntypedef struct { short v16; } __attribute__((packed)) jint16_t;\n\nstruct node {\n  jint16_t magic;\n  jint16_t nodetype;\n  int totlen;\n} __attribute__((packed));\n\nstruct node node, *node_p = &node;\n\nint main()\n{\n  struct node marker = {\n    .magic = (jint16_t) {0x1985},\n    .nodetype = (jint16_t) {0x2003},\n    .totlen = node_p->totlen\n  };\n  if (marker.magic.v16 != 0x1985)\n    abort();\n  if (marker.nodetype.v16 != 0x2003)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030307-1.c",
    "content": "/* PR optimization/8726 */\n/* Originator: Paul Eggert <eggert@twinsun.com> */\n\n/* Verify that GCC doesn't miscompile tail calls on Sparc. */\n\nextern void abort(void);\n\nint fcntl_lock(int fd, int op, long long offset, long long count, int type);\n\nint vfswrap_lock(char *fsp, int fd, int op, long long offset, long long count, int type)\n{\n  return fcntl_lock(fd, op, offset, count, type);\n}\n\nint fcntl_lock(int fd, int op, long long offset, long long count, int type)\n{\n  return type;\n}\n\nint main(void)\n{\n  if (vfswrap_lock (0, 1, 2, 3, 4, 5) != 5)\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030313-1.c",
    "content": "struct A\n{\n  unsigned long p, q, r, s;\n} x = { 13, 14, 15, 16 };\n\nextern void abort (void);\nextern void exit (int);\n\nstatic inline struct A *\nbar (void)\n{\n  struct A *r;\n\n  switch (8)\n    {\n    case 2:\n      abort ();\n      break;\n    case 8:\n      r = &x;\n      break;\n    default:\n      abort ();\n      break;\n    }\n  return r;\n}\n\nvoid\nfoo (unsigned long *x, int y)\n{\n  if (y != 12)\n    abort ();\n  if (x[0] != 1 || x[1] != 11)\n    abort ();\n  if (x[2] != 2 || x[3] != 12)\n    abort ();\n  if (x[4] != 3 || x[5] != 13)\n    abort ();\n  if (x[6] != 4 || x[7] != 14)\n    abort ();\n  if (x[8] != 5 || x[9] != 15)\n    abort ();\n  if (x[10] != 6 || x[11] != 16)\n    abort ();\n}\n\nint\nmain (void)\n{\n  unsigned long a[40];\n  int b = 0;\n\n  a[b++] = 1;\n  a[b++] = 11;\n  a[b++] = 2;\n  a[b++] = 12;\n  a[b++] = 3;\n  a[b++] = bar()->p;\n  a[b++] = 4;\n  a[b++] = bar()->q;\n  a[b++] = 5;\n  a[b++] = bar()->r;\n  a[b++] = 6;\n  a[b++] = bar()->s;\n  foo (a, b);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030316-1.c",
    "content": "/* PR target/9164 */\n/* The comparison operand was sign extended erraneously.  */\n\nint\nmain (void)\n{\n    long j = 0x40000000;\n    if ((unsigned int) (0x40000000 + j) < 0L)\n \tabort ();\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030323-1.c",
    "content": "/* PR opt/10116 */\n/* { dg-require-effective-target return_address } */\n/* Removed tablejump while label still in use; this is really a link test.  */\n\nvoid *NSReturnAddress(int offset)\n{\n\tswitch (offset) {\n\tcase 0:  return __builtin_return_address(0 + 1);\n\tcase 1:  return __builtin_return_address(1 + 1);\n\tcase 2:  return __builtin_return_address(2 + 1);\n\tcase 3:  return __builtin_return_address(3 + 1);\n\tcase 4:  return __builtin_return_address(4 + 1);\n\tcase 5:  return __builtin_return_address(5 + 1);\n\tcase 6:  return __builtin_return_address(6 + 1);\n\tcase 7:  return __builtin_return_address(7 + 1);\n\tcase 8:  return __builtin_return_address(8 + 1);\n\tcase 9:  return __builtin_return_address(9 + 1);\n\tcase 10: return __builtin_return_address(10 + 1);\n\tcase 11: return __builtin_return_address(11 + 1);\n\tcase 12: return __builtin_return_address(12 + 1);\n\tcase 13: return __builtin_return_address(13 + 1);\n\tcase 14: return __builtin_return_address(14 + 1);\n\tcase 15: return __builtin_return_address(15 + 1);\n\tcase 16: return __builtin_return_address(16 + 1);\n\tcase 17: return __builtin_return_address(17 + 1);\n\tcase 18: return __builtin_return_address(18 + 1);\n\tcase 19: return __builtin_return_address(19 + 1);\n\tcase 20: return __builtin_return_address(20 + 1);\n\tcase 21: return __builtin_return_address(21 + 1);\n\tcase 22: return __builtin_return_address(22 + 1);\n\tcase 23: return __builtin_return_address(23 + 1);\n\tcase 24: return __builtin_return_address(24 + 1);\n\tcase 25: return __builtin_return_address(25 + 1);\n\tcase 26: return __builtin_return_address(26 + 1);\n\tcase 27: return __builtin_return_address(27 + 1);\n\tcase 28: return __builtin_return_address(28 + 1);\n\tcase 29: return __builtin_return_address(29 + 1);\n\tcase 30: return __builtin_return_address(30 + 1);\n\tcase 31: return __builtin_return_address(31 + 1);\n\tcase 32: return __builtin_return_address(32 + 1);\n\tcase 33: return __builtin_return_address(33 + 1);\n\tcase 34: return __builtin_return_address(34 + 1);\n\tcase 35: return __builtin_return_address(35 + 1);\n\tcase 36: return __builtin_return_address(36 + 1);\n\tcase 37: return __builtin_return_address(37 + 1);\n\tcase 38: return __builtin_return_address(38 + 1);\n\tcase 39: return __builtin_return_address(39 + 1);\n\tcase 40: return __builtin_return_address(40 + 1);\n\tcase 41: return __builtin_return_address(41 + 1);\n\tcase 42: return __builtin_return_address(42 + 1);\n\tcase 43: return __builtin_return_address(43 + 1);\n\tcase 44: return __builtin_return_address(44 + 1);\n\tcase 45: return __builtin_return_address(45 + 1);\n\tcase 46: return __builtin_return_address(46 + 1);\n\tcase 47: return __builtin_return_address(47 + 1);\n\tcase 48: return __builtin_return_address(48 + 1);\n\tcase 49: return __builtin_return_address(49 + 1);\n\tcase 50: return __builtin_return_address(50 + 1);\n\tcase 51: return __builtin_return_address(51 + 1);\n\tcase 52: return __builtin_return_address(52 + 1);\n\tcase 53: return __builtin_return_address(53 + 1);\n\tcase 54: return __builtin_return_address(54 + 1);\n\tcase 55: return __builtin_return_address(55 + 1);\n\tcase 56: return __builtin_return_address(56 + 1);\n\tcase 57: return __builtin_return_address(57 + 1);\n\tcase 58: return __builtin_return_address(58 + 1);\n\tcase 59: return __builtin_return_address(59 + 1);\n\tcase 60: return __builtin_return_address(60 + 1);\n\tcase 61: return __builtin_return_address(61 + 1);\n\tcase 62: return __builtin_return_address(62 + 1);\n\tcase 63: return __builtin_return_address(63 + 1);\n\tcase 64: return __builtin_return_address(64 + 1);\n\tcase 65: return __builtin_return_address(65 + 1);\n\tcase 66: return __builtin_return_address(66 + 1);\n\tcase 67: return __builtin_return_address(67 + 1);\n\tcase 68: return __builtin_return_address(68 + 1);\n\tcase 69: return __builtin_return_address(69 + 1);\n\tcase 70: return __builtin_return_address(70 + 1);\n\tcase 71: return __builtin_return_address(71 + 1);\n\tcase 72: return __builtin_return_address(72 + 1);\n\tcase 73: return __builtin_return_address(73 + 1);\n\tcase 74: return __builtin_return_address(74 + 1);\n\tcase 75: return __builtin_return_address(75 + 1);\n\tcase 76: return __builtin_return_address(76 + 1);\n\tcase 77: return __builtin_return_address(77 + 1);\n\tcase 78: return __builtin_return_address(78 + 1);\n\tcase 79: return __builtin_return_address(79 + 1);\n\tcase 80: return __builtin_return_address(80 + 1);\n\tcase 81: return __builtin_return_address(81 + 1);\n\tcase 82: return __builtin_return_address(82 + 1);\n\tcase 83: return __builtin_return_address(83 + 1);\n\tcase 84: return __builtin_return_address(84 + 1);\n\tcase 85: return __builtin_return_address(85 + 1);\n\tcase 86: return __builtin_return_address(86 + 1);\n\tcase 87: return __builtin_return_address(87 + 1);\n\tcase 88: return __builtin_return_address(88 + 1);\n\tcase 89: return __builtin_return_address(89 + 1);\n\tcase 90: return __builtin_return_address(90 + 1);\n\tcase 91: return __builtin_return_address(91 + 1);\n\tcase 92: return __builtin_return_address(92 + 1);\n\tcase 93: return __builtin_return_address(93 + 1);\n\tcase 94: return __builtin_return_address(94 + 1);\n\tcase 95: return __builtin_return_address(95 + 1);\n\tcase 96: return __builtin_return_address(96 + 1);\n\tcase 97: return __builtin_return_address(97 + 1);\n\tcase 98: return __builtin_return_address(98 + 1);\n\tcase 99: return __builtin_return_address(99 + 1);\n\t}\n\treturn 0;\n}\n\nint main()\n{\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030330-1.c",
    "content": "/* PR opt/10011 */\n/* This is link test for builtin_constant_p simplification + DCE.  */\n\nextern void link_error(void);\nstatic void usb_hub_port_wait_reset(unsigned int delay)\n{\n        int delay_time;\n        for (delay_time = 0; delay_time < 500; delay_time += delay) {\n                if (__builtin_constant_p(delay))\n                        link_error();\n        }\n}\n\nint main() { return 0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030401-1.c",
    "content": "/* Testcase for PR fortran/9974.  This was a miscompilation of the g77\n   front-end caused by the jump bypassing optimizations not handling\n   instructions inserted on CFG edges.  */\n\nextern void abort ();\n\nint bar ()\n{\n  return 1;\n}\n\nvoid foo (int x)\n{\n  unsigned char error = 0;\n\n  if (! (error = ((x == 0) || bar ())))\n    bar ();\n  if (! error)\n    abort ();\n}\n\nint main()\n{\n  foo (1);\n  return 0;\n}\n  \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030403-1.c",
    "content": "/* The non-destructive folder was always emitting >= when folding\n   comparisons to signed_max+1.  */\n\n#include <limits.h>\n\nint\nmain ()\n{\n  unsigned long count = 8;\n\n  if (count > INT_MAX)\n    abort ();\n\n  return (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030404-1.c",
    "content": "/* This exposed a bug in tree-ssa-ccp.c.  Since 'j' and 'i' are never\n   defined, CCP was not traversing the edges out of the if(), which caused\n   the PHI node for 'k' at the top of the while to only be visited once.\n   This ended up causing CCP to think that 'k' was the constant '1'.  */\nmain()\n{\n  int i, j, k;\n\n  k = 0;\n  while (k < 10)\n    {\n      k++;\n      if (j > i)\n\tj = 5;\n      else\n\tj =3;\n    }\n\n  if (k != 10)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030408-1.c",
    "content": "/* PR optimization/8634 */\n/* Contributed by Glen Nakamura <glen at imodulo dot com> */\n\nextern void abort (void);\n\nstruct foo {\n  char a, b, c, d, e, f, g, h, i, j;\n};\n\nint test1 ()\n{\n  const char X[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };\n  char buffer[8];\n  __builtin_memcpy (buffer, X, 8);\n  if (buffer[0] != 'A' || buffer[1] != 'B'\n      || buffer[2] != 'C' || buffer[3] != 'D'\n      || buffer[4] != 'E' || buffer[5] != 'F'\n      || buffer[6] != 'G' || buffer[7] != 'H')\n    abort ();\n  return 0;\n}\n\nint test2 ()\n{\n  const char X[10] = { 'A', 'B', 'C', 'D', 'E' };\n  char buffer[10];\n  __builtin_memcpy (buffer, X, 10);\n  if (buffer[0] != 'A' || buffer[1] != 'B'\n      || buffer[2] != 'C' || buffer[3] != 'D'\n      || buffer[4] != 'E' || buffer[5] != '\\0'\n      || buffer[6] != '\\0' || buffer[7] != '\\0'\n      || buffer[8] != '\\0' || buffer[9] != '\\0')\n    abort ();\n  return 0;\n}\n\nint test3 ()\n{\n  const struct foo X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };\n  char buffer[10];\n  __builtin_memcpy (buffer, &X, 10);\n  if (buffer[0] != 'A' || buffer[1] != '\\0'\n      || buffer[2] != 'C' || buffer[3] != '\\0'\n      || buffer[4] != 'E' || buffer[5] != '\\0'\n      || buffer[6] != 'G' || buffer[7] != '\\0'\n      || buffer[8] != 'I' || buffer[9] != '\\0')\n    abort ();\n  return 0;\n}\n\nint test4 ()\n{\n  const struct foo X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };\n  char buffer[10];\n  __builtin_memcpy (buffer, &X, 10);\n  if (buffer[0] != '\\0' || buffer[1] != 'B'\n      || buffer[2] != '\\0' || buffer[3] != 'D'\n      || buffer[4] != '\\0' || buffer[5] != 'F'\n      || buffer[6] != '\\0' || buffer[7] != 'H'\n      || buffer[8] != '\\0' || buffer[9] != 'J')\n    abort ();\n  return 0;\n}\n\nint main ()\n{\n  test1 (); test2 (); test3 (); test4 ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030501-1.c",
    "content": "int\nmain (int argc, char **argv)\n{\n  int size = 10;\n\n  {\n    int retframe_block()\n      {\n        return size + 5;\n      }\n\n  if (retframe_block() != 15)\n      abort ();\n  exit (0);\n\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030606-1.c",
    "content": "\nint * foo (int *x, int b)\n{\n\n  *(x++) = 55;\n  if (b)\n    *(x++) = b;\n\n  return x;\n}\n\nmain()\n{\n  int a[5];\n\n  memset (a, 1, sizeof (a));\n\n  if (foo(a, 0) - a != 1 || a[0] != 55 || a[1] != a[4])\n    abort();\n\n  memset (a, 1, sizeof (a));\n\n  if (foo(a, 2) - a != 2 || a[0] != 55 || a[1] != 2)\n    abort();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030613-1.c",
    "content": "/* PR optimization/10955 */\n/* Originator: <heinrich.brand@fujitsu-siemens.com> */\n\n/* This used to fail on SPARC32 at -O3 because the loop unroller\n   wrongly thought it could eliminate a pseudo in a loop, while\n   the pseudo was used outside the loop.  */\n\nextern void abort(void);\n\n#define COMPLEX struct CS\n\nCOMPLEX {\n  long x;\n  long y;\n};\n\n\nstatic COMPLEX CCID (COMPLEX x)\n{\n  COMPLEX a;\n\n  a.x = x.x;\n  a.y = x.y;\n\n  return a;\n}\n\n\nstatic COMPLEX CPOW (COMPLEX x, int y)\n{\n  COMPLEX a;\n  a = x;\n\n  while (--y > 0)\n    a=CCID(a);\n\n  return a;\n}\n\n\nstatic int c5p (COMPLEX x)\n{\n  COMPLEX a,b;\n  a = CPOW (x, 2);\n  b = CCID( CPOW(a,2) );\n    \n  return (b.x == b.y); \n}\n\n\nint main (void)\n{\n  COMPLEX  x;  \n\n  x.x = -7;\n  x.y = -7;\n\n  if (!c5p(x))\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030626-1.c",
    "content": "char buf[10];\n\nextern void abort (void);\nextern int sprintf (char*, const char*, ...);\n\nint main()\n{\n  int l = sprintf (buf, \"foo\\0bar\");\n  if (l != 3)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030626-2.c",
    "content": "char buf[40];\n\nextern int sprintf (char*, const char*, ...);\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  int l = sprintf (buf, \"%s\", i++ ? \"string\" : \"other string\");\n  if (l != sizeof (\"other string\") - 1 || i != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030714-1.c",
    "content": "/* derived from PR optimization/11440  */\n\nextern void abort (void);\nextern void exit (int);\n\ntypedef _Bool bool;\nconst bool false = 0;\nconst bool true = 1;\n\nenum EPosition \n{\n  STATIC, RELATIVE, ABSOLUTE, FIXED\n};\ntypedef enum EPosition EPosition;\n\nenum EFloat \n{\n  FNONE = 0, FLEFT, FRIGHT\n};\ntypedef enum EFloat EFloat;\n\nstruct RenderBox\n{\n  int unused[6];\n  short m_verticalPosition;\n  \n  bool m_layouted : 1;\n  bool m_unused : 1;\n  bool m_minMaxKnown : 1;\n  bool m_floating : 1;\n  \n  bool m_positioned : 1;\n  bool m_overhangingContents : 1;\n  bool m_relPositioned : 1;\n  bool m_paintSpecial : 1;\n  \n  bool m_isAnonymous : 1;\n  bool m_recalcMinMax : 1;\n  bool m_isText : 1;\n  bool m_inline : 1;\n  \n  bool m_replaced : 1;\n  bool m_mouseInside : 1;\n  bool m_hasFirstLine : 1;\n  bool m_isSelectionBorder : 1;\n  \n  bool (*isTableCell) (struct RenderBox *this);\n};\n\ntypedef struct RenderBox RenderBox;\n\nstruct RenderStyle\n{\n  struct NonInheritedFlags \n    {\n      union \n\t{\n\t  struct \n\t    {\n\t      unsigned int _display : 4;\n\t      unsigned int _bg_repeat : 2;\n\t      bool _bg_attachment : 1;\n\t      unsigned int _overflow : 4 ;\n\t      unsigned int _vertical_align : 4;\n\t      unsigned int _clear : 2;\n\t      EPosition _position : 2;\n\t      EFloat _floating : 2;\n\t      unsigned int _table_layout : 1;\n\t      bool _flowAroundFloats :1;\n\n\t      unsigned int _styleType : 3;\n\t      bool _hasHover : 1;\n\t      bool _hasActive : 1;\n\t      bool _clipSpecified : 1;\n\t      unsigned int _unicodeBidi : 2;\n\t      int _unused : 1;\n\t    } f;\n\t  int _niflags;\n\t};\n    } noninherited_flags;\n};\n\ntypedef struct RenderStyle RenderStyle;\n\nextern void RenderObject_setStyle(RenderBox *this, RenderStyle *_style);\nextern void removeFromSpecialObjects(RenderBox *this);\n\n\n\nvoid RenderBox_setStyle(RenderBox *thisin, RenderStyle *_style)\n{\n  RenderBox *this = thisin;\n  bool oldpos, tmp;\n  EPosition tmppo;\n  \n  tmp = this->m_positioned;\n\n  oldpos = tmp;\n\n  RenderObject_setStyle(this, _style);\n  \n  tmppo = _style->noninherited_flags.f._position;\n\n  switch(tmppo)\n    {\n    case ABSOLUTE:\n    case FIXED:\n\t{\n\t  bool ltrue = true;\n\t  this->m_positioned = ltrue;\n\t  break;\n\t}\n\n    default:\n\t{\n\t  EFloat tmpf;\n\t  EPosition tmpp;\n\t  if (oldpos)\n\t    {\n\t      bool ltrue = true;\n\t      this->m_positioned = ltrue;\n\t      removeFromSpecialObjects(this);\n\t    }\n\t    {\n\t      bool lfalse = false;\n\t      this->m_positioned = lfalse;\n\t    }\n\n\t  tmpf = _style->noninherited_flags.f._floating;\n\n\t  if(!this->isTableCell (this) && !(tmpf == FNONE)) \n\t    {\n\t      bool ltrue = true;\n\t      this->m_floating = ltrue;\n\t    }\n\t  else \n\t    {\n\t      tmpp = _style->noninherited_flags.f._position;\n\t      if (tmpp == RELATIVE)\n\t\t{\n\t\t  bool ltrue = true;\n\t\t  this->m_relPositioned = ltrue;\n\t\t}\n\t    }\n\t}\n    }\n}\n\n\n\n\nRenderBox g_this;\nRenderStyle g__style;\n\nvoid RenderObject_setStyle(RenderBox *this, RenderStyle *_style)\n{\n  (void) this;\n  (void) _style;\n}\n\nvoid removeFromSpecialObjects(RenderBox *this)\n{\n  (void) this;\n}\n\nbool RenderBox_isTableCell (RenderBox *this)\n{\n  (void) this;\n  return false;\n}\n\nint main (void)\n{\n\n  g_this.m_relPositioned = false;\n  g_this.m_positioned = false;\n  g_this.m_floating = false;\n  g_this.isTableCell = RenderBox_isTableCell;\n\n  g__style.noninherited_flags.f._position = FIXED;\n  g__style.noninherited_flags.f._floating = FNONE;\n\n  RenderBox_setStyle (&g_this, &g__style);\n  \n  if (g_this.m_positioned != true)\n    abort ();\n  if (g_this.m_relPositioned != false)\n    abort ();\n  if (g_this.m_floating != false)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030715-1.c",
    "content": "/* PR optimization/11320 */\n/* Origin: Andreas Schwab <schwab@suse.de> */\n\n/* Verify that the scheduler correctly computes the dependencies\n   in the presence of conditional instructions.  */\n\nint strcmp (const char *, const char *);\nint ap_standalone;\n\nconst char *ap_check_cmd_context (void *a, int b)\n{\n  return 0;\n}\n\nconst char *server_type (void *a, void *b, char *arg)\n{\n  const char *err = ap_check_cmd_context (a, 0x01|0x02|0x04|0x08|0x10);\n  if (err)\n    return err;\n\n  if (!strcmp (arg, \"inetd\"))\n    ap_standalone = 0;\n  else if (!strcmp (arg, \"standalone\"))\n      ap_standalone = 1;\n  else\n    return \"ServerType must be either 'inetd' or 'standalone'\";\n\n  return 0;\n}\n\nint main ()\n{\n  server_type (0, 0, \"standalone\");\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030717-1.c",
    "content": "/* PR target/11087\n   This testcase was miscompiled on ppc64, because basic_induction_var called\n   convert_modes, yet did not expect it to emit any new instructions.\n   Those were emitted at the end of the function and destroyed during life\n   analysis, while the program used uninitialized pseudos created by\n   convert_modes.  */\n\nstruct A\n{\n  unsigned short a1;\n  unsigned long a2;\n};\n\nstruct B\n{\n  int b1, b2, b3, b4, b5;\n};\n\nstruct C\n{\n  struct B c1[1];\n  int c2, c3;\n};\n\nstatic\nint foo (int x)\n{\n  return  x < 0 ? -x : x;\n}\n\nint bar (struct C *x, struct A *y)\n{\n  int a = x->c3;\n  const int b = y->a1 >> 9;\n  const unsigned long c = y->a2;\n  int d = a;\n  unsigned long e, f;\n\n  f = foo (c - x->c1[d].b4);\n  do\n    {\n      if (d <= 0)\n\td = x->c2;\n      d--;\n\n      e = foo (c-x->c1[d].b4);\n      if (e < f)\n\ta = d;\n    }\n  while (d != x->c3);\n  x->c1[a].b4 = c + b;\n  return a;\n}\n\nint\nmain ()\n{\n  struct A a;\n  struct C b;\n  int c;\n\n  a.a1 = 512;\n  a.a2 = 4242;\n  __builtin_memset (&b, 0, sizeof (b));\n  b.c1[0].b3 = 424242;\n  b.c2 = 1;\n  c = bar (&b, &a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030718-1.c",
    "content": "/* PR c/10320\n   The function temp was not being emitted in a prerelease of 3.4 20030406. \n   Contributed by pinskia@physics.uc.edu */\n\nstatic inline void temp();\nint main()\n{\n        temp();\n        return 0;\n}\nstatic void temp(){}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030811-1.c",
    "content": "/* Origin: PR target/11535 from H. J. Lu <hjl@lucon.org> */\n/* { dg-require-effective-target return_address } */\n\nvoid vararg (int i, ...)\n{\n  (void) i;\n}\n\nint i0[0], i1;\n\nvoid test1 (void)\n{\n  int a = (int) (long long) __builtin_return_address (0);\n  vararg (0, a);\n}\n\nvoid test2 (void)\n{\n  i0[0] = (int) (long long) __builtin_return_address (0);\n}\n\nvoid test3 (void)\n{\n  i1 = (int) (long long) __builtin_return_address (0);\n}\n\nvoid test4 (void)\n{\n  volatile long long a = (long long) __builtin_return_address (0);\n  i0[0] = (int) a;\n}\n\nint main (void)\n{\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030821-1.c",
    "content": "extern void abort (void);\n\nint\nfoo (int x)\n{\n  if ((int) (x & 0x80ffffff) != (int) (0x8000fffe))\n    abort ();\n\n  return 0;\n}\n\nint\nmain ()\n{\n  return foo (0x8000fffe);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030828-1.c",
    "content": "const int *p;\n\nint bar (void)\n{\n  return *p + 1;\n}\n\nmain ()\n{\n  /* Variable 'i' is never used but it's aliased to a global pointer.  The\n     alias analyzer was not considering that 'i' may be used in the call to\n     bar().  */\n  const int i = 5;\n  p = &i;\n  if (bar() != 6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030828-2.c",
    "content": "struct rtx_def\n{\n  int code;\n};\n\nmain()\n{\n  int tmp[2];\n  struct rtx_def *r, s;\n  int *p, *q;\n\n  /* The alias analyzer was creating the same memory tag for r, p and q\n     because 'struct rtx_def *' is type-compatible with 'int *'.  However,\n     the alias set of 'int[2]' is not the same as 'int *', so variable\n     'tmp' was deemed not aliased with anything.  */\n  r = &s;\n  r->code = 39;\n\n  /* If 'r' wasn't declared, then q and tmp would have had the same memory\n     tag.  */\n  p = tmp;\n  q = p + 1;\n  *q = 0;\n  tmp[1] = 39;\n  if (*q != 39)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030903-1.c",
    "content": "/* Test that we don't let stmt.c think that the enumeration's values are\n   the entire set of possibilities.  Such an assumption is false for C,\n   but true for other languages.  */\n\nenum X { X1 = 1, X2, X3, X4 };\nstatic volatile enum X test = 0;\nstatic void y(int);\n\nint main()\n{\n  switch (test)\n    {\n    case X1: y(1); break;\n    case X2: y(2); break;\n    case X3: y(3); break;\n    case X4: y(4); break;\n    }\n  return 0;\n}\n\nstatic void y(int x) { abort (); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030909-1.c",
    "content": "void abort ();\nvoid exit (int);\n\nvoid test(int x, int y)\n{\n  if (x == y)\n    abort ();\n}\n\nvoid foo(int x, int y)\n{\n  if (x == y)\n    goto a;\n  else\n    {\na:;\n      if (x == y)\n\tgoto b;\n      else\n\t{\nb:;\n\t  if (x != y)\n\t    test (x, y);\n\t}\n    }\n}\n\nint main(void)\n{\n  foo (0, 0);\n\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030910-1.c",
    "content": "/* The gimplifier was inserting unwanted temporaries for REALPART_EXPR\n   nodes.  These need to be treated like a COMPONENT_REF so their address can\n   be taken.  */\n\nint main()\n{\n  __complex double dc;\n  double *dp = &(__real dc);\n  *dp = 3.14;\n  if ((__real dc) != 3.14) abort();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030913-1.c",
    "content": "/* Assignments via pointers pointing to global variables were being killed\n   by SSA-DCE.  Test contributed by Paul Brook <paul@nowt.org>  */\n\nint glob; \n \nvoid \nfn2(int ** q) \n{ \n  *q = &glob; \n} \n \nvoid test() \n{ \n  int *p; \n \n  fn2(&p); \n \n  *p=42; \n} \n \nint main() \n{ \n  test(); \n  if (glob != 42) abort(); \n  exit (0); \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030914-1.c",
    "content": "/* On IRIX 6, PB is passed partially in registers and partially on the\n   stack, with an odd number of words in the register part.  Check that\n   the long double stack argument (PC) is still accessed properly.  */\n\nstruct s { int val[16]; };\n\nlong double f (int pa, struct s pb, long double pc)\n{\n  int i;\n\n  for (i = 0; i < 16; i++)\n    pc += pb.val[i];\n  return pc;\n}\n\nint main ()\n{\n  struct s x;\n  int i;\n\n  for (i = 0; i < 16; i++)\n    x.val[i] = i + 1;\n  if (f (1, x, 10000.0L) != 10136.0L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030914-2.c",
    "content": "/* On IRIX 6, PA is passed partially in registers and partially on the\n   stack.  We therefore have two potential uses of pretend_args_size:\n   one for the partial argument and one for the varargs save area.\n   Make sure that these uses don't conflict.  */\n\nstruct s { int i[18]; };\n\nint f (struct s pa, int pb, ...)\n{\n  return pb;\n}\n\nstruct s gs;\n\nint main ()\n{\n  if (f (gs, 0x1234) != 0x1234)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030916-1.c",
    "content": "/* \"i\" overflows in f().  Check that x[i] is not treated as a giv.  */\n#include <limits.h>\n\n#if CHAR_BIT == 8\n\nvoid f (unsigned int *x)\n{\n  unsigned char i;\n  int j;\n\n  i = 0x10;\n  for (j = 0; j < 0x10; j++)\n    {\n      i += 0xe8;\n      x[i] = 0;\n      i -= 0xe7;\n    }\n}\n\nint main ()\n{\n  unsigned int x[256];\n  int i;\n\n  for (i = 0; i < 256; i++)\n    x[i] = 1;\n  f (x);\n  for (i = 0; i < 256; i++)\n    if (x[i] != (i >= 0x08 && i < 0xf8))\n      abort ();\n  exit (0);\n}\n#else\nint main () { exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030920-1.c",
    "content": "extern void abort (void);\n\nint main()\n{\n  int hicount = 0;\n  unsigned char *c;\n  char *str = \"\\x7f\\xff\";\n  for (c = (unsigned char *)str; *c ; c++) {\n    if (!(((unsigned int)(*c)) < 0x80)) hicount++;\n  }\n  if (hicount != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20030928-1.c",
    "content": "#include <limits.h>\n\n#if INT_MAX <= 32767\nint main () { exit (0); }\n#else\nvoid get_addrs (const char**x, int *y)\n{\n  x[0] = \"a1111\" + (y[0] - 0x10000) * 2;\n  x[1] = \"a1112\" + (y[1] - 0x20000) * 2;\n  x[2] = \"a1113\" + (y[2] - 0x30000) * 2;\n  x[3] = \"a1114\" + (y[3] - 0x40000) * 2;\n  x[4] = \"a1115\" + (y[4] - 0x50000) * 2;\n  x[5] = \"a1116\" + (y[5] - 0x60000) * 2;\n  x[6] = \"a1117\" + (y[6] - 0x70000) * 2;\n  x[7] = \"a1118\" + (y[7] - 0x80000) * 2;\n}\n\nint main ()\n{\n  const char *x[8];\n  int y[8];\n  int i;\n\n  for (i = 0; i < 8; i++)\n    y[i] = 0x10000 * (i + 1);\n  get_addrs (x, y);\n  for (i = 0; i < 8; i++)\n    if (*x[i] != 'a')\n      abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031003-1.c",
    "content": "/* PR optimization/9325  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nint f1()\n{\n  return (int)2147483648.0f;\n}\n\nint f2()\n{\n  return (int)(float)(2147483647);\n}\n\nint main()\n{\n#if INT_MAX == 2147483647\n  if (f1() != 2147483647)\n    abort ();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2() != 0x7fffff80)\n    abort ();\n#else\n  if (f2() != 2147483647)\n    abort ();\n#endif\n#endif\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031010-1.c",
    "content": "/* A reminder to process ops in generate_expr_as_of_bb exactly once.  */\n\nlong __attribute__((noinline))\nfoo (long ct, long cf, _Bool p1, _Bool p2, _Bool p3)\n{\n  long diff;\n\n  diff = ct - cf;\n\n  if (p1)\n    {\n      if (p2)\n\t{\n\t  if (p3)\n\t    {\n\t      long tmp = ct;\n\t      ct = cf;\n\t      cf = tmp;\n\t    }\n\t  diff = ct - cf;\n\t}\n\n      return diff;\n    }\n\n  abort ();\n}\n\nint main ()\n{\n  if (foo(2, 3, 1, 1, 1) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031011-1.c",
    "content": "/* Check that MAX_EXPR and MIN_EXPR are working properly.  */\n\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n\nextern void abort (void);\n\nint main()\n{\n  int ll_bitsize, ll_bitpos;\n  int rl_bitsize, rl_bitpos;\n  int end_bit;\n\n  ll_bitpos = 32;  ll_bitsize = 32;\n  rl_bitpos = 0;   rl_bitsize = 32;\n\n  end_bit = MAX (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);\n  if (end_bit != 64)\n    abort ();\n  end_bit = MAX (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);\n  if (end_bit != 64)\n    abort ();\n  end_bit = MIN (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);\n  if (end_bit != 32)\n    abort ();\n  end_bit = MIN (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);\n  if (end_bit != 32)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031012-1.c",
    "content": "/* PR optimization/8750\n   Used to fail under Cygwin with \n   -O2 -fomit-frame-pointer        \n   Testcase by David B. Trout     */\n\n#if defined(STACK_SIZE) && STACK_SIZE < 16000\n#define ARRAY_SIZE (STACK_SIZE / 2)\n#define STRLEN\t   (ARRAY_SIZE - 9)\n#else\n#define ARRAY_SIZE 15000\n#define STRLEN     13371\n#endif\n\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern void abort (void);\n\nstatic void foo ()\n{\n    char a[ARRAY_SIZE];\n\n    a[0]=0;\n    memset( &a[0], 0xCD, STRLEN );\n    a[STRLEN]=0;\n    if (strlen(a) != STRLEN)\n      abort ();\n}\n\nint main ( int argc, char* argv[] )\n{\n    foo();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031020-1.c",
    "content": "/* PR target/12654\n   The Alpha backend tried to do a >= 1024 as (a - 1024) >= 0, which fails\n   for very large negative values.  */\n/* Origin: tg@swox.com  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid __attribute__((noinline))\nfoo (long x)\n{\n  if (x >= 1024)\n    abort ();\n}\n\nint\nmain ()\n{\n  foo (LONG_MIN);\n  foo (LONG_MIN + 10000);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031201-1.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n   PR target/13256\n   STRICT_LOW_PART was handled incorrectly in delay slots.\n   Origin: Hans-Peter Nilsson.  */\n\ntypedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s1;\ntypedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s2;\ntypedef struct { s1 i12; s2 i16; } io;\nstatic int test_length = 2;\nstatic io *i;\nstatic int m = 1;\nstatic int d = 1;\nstatic unsigned long test_t0;\nstatic unsigned long test_t1;\nvoid test(void) __attribute__ ((__noinline__));\nextern int f1 (void *port) __attribute__ ((__noinline__));\nextern void f0 (void) __attribute__ ((__noinline__));\nint\nf1 (void *port)\n{\n  int fail_count = 0;\n  unsigned long tlen;\n  s1 x0 = {0};\n  s2 x1 = {0};\n\n  i = port;\n  x0.e0 = x1.e0 = 32;\n  i->i12 = x0;\n  i->i16 = x1;\n  do f0(); while (test_t1);\n  x0.e0 = x1.e0 = 8;\n  i->i12 = x0;\n  i->i16 = x1;\n  test ();\n  if (m)\n    {\n      unsigned long e = 1000000000 / 460800 * test_length;\n      tlen = test_t1 - test_t0;\n      if (((tlen-e) & 0x7FFFFFFF) > 1000)\n\tf0();\n    }\n  if (d)\n    {\n      unsigned long e = 1000000000 / 460800 * test_length;\n      tlen = test_t1 - test_t0;\n      if (((tlen - e) & 0x7FFFFFFF) > 1000)\n\tf0();\n    }\n  return fail_count != 0 ? 1 : 0;\n}\n\nint\nmain ()\n{\n  io io0;\n  f1 (&io0);\n  abort ();\n}\n\nvoid\ntest (void)\n{\n  io *iop = i;\n  if (iop->i12.e0 != 8 || iop->i16.e0 != 8)\n    abort ();\n  exit (0);\n}\n\nvoid\nf0 (void)\n{\n  static int washere = 0;\n  io *iop = i;\n  if (washere++ || iop->i12.e0 != 32 || iop->i16.e0 != 32)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031204-1.c",
    "content": "/* PR optimization/13260 */\n\n#include <string.h>\n\ntypedef unsigned long u32;\n\nu32 in_aton(const char* x)\n{\n  return 0x0a0b0c0d;\n}\n\nu32 root_nfs_parse_addr(char *name)\n{\n u32 addr;\n int octets = 0;\n char *cp, *cq;\n\n cp = cq = name;\n while (octets < 4) {\n  while (*cp >= '0' && *cp <= '9')\n   cp++;\n  if (cp == cq || cp - cq > 3)\n   break;\n  if (*cp == '.' || octets == 3)\n   octets++;\n  if (octets < 4)\n   cp++;\n  cq = cp;\n }\n\n if (octets == 4 && (*cp == ':' || *cp == '\\0')) {\n  if (*cp == ':')\n   *cp++ = '\\0';\n  addr = in_aton(name);\n  strcpy(name, cp);\n } else\n  addr = (-1);\n\n return addr;\n}\n\nint\nmain()\n{\n  static char addr[] = \"10.11.12.13:/hello\";\n  u32 result = root_nfs_parse_addr(addr);\n  if (result != 0x0a0b0c0d) { abort(); }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031211-1.c",
    "content": "struct a { unsigned int bitfield : 1; };\n\nunsigned int x;\n\nmain()\n{\n  struct a a = {0};\n  x = 0xbeef;\n  a.bitfield |= x;\n  if (a.bitfield != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031211-2.c",
    "content": "struct a\n{\n  unsigned int bitfield : 3;\n};\n\nint main()\n{\n  struct a a;\n\n  a.bitfield = 131;\n  foo (a.bitfield);\n  exit (0);\n}\n\nfoo(unsigned int z)\n{\n  if (z != 3)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031214-1.c",
    "content": "/* PR optimization/10312 */\n/* Originator: Peter van Hoof <p dot van-hoof at qub dot ac dot uk> */\n\n/* Verify that the strength reduction pass doesn't find\n   illegitimate givs.  */\n\nstruct\n{\n  double a;\n  int n[2];\n} g = { 0., { 1, 2}};\n\nint k = 0;\n\nvoid\nb (int *j)\n{\n}\n\nint\nmain ()\n{\n  int j;\n\n  for (j = 0; j < 2; j++)\n    k = (k > g.n[j]) ? k : g.n[j];\n\n  k++;\n  b (&j);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031215-1.c",
    "content": "/* PR middle-end/13400 */\n/* The following test used to fail at run-time with a write to read-only\n   memory, caused by if-conversion converting a conditional write into an\n   unconditional write.  */\n\ntypedef struct {int c, l; char ch[3];} pstr;\nconst pstr ao = {2, 2, \"OK\"};\nconst pstr * const a = &ao;\n\nvoid test1(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = 0;\n    }\n}\n\nvoid test2(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = -1;\n    }\n}\n\nvoid test3(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = 1;\n    }\n}\n\nint main(void)\n{\n    test1();\n    test2();\n    test3();\n    return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20031216-1.c",
    "content": "/* PR optimization/13313 */\n/* Origin: Mike Lerwill <mike@ml-solutions.co.uk> */\n\nextern void abort(void);\n\nvoid DisplayNumber (unsigned long v)\n{\n  if (v != 0x9aL)\n    abort();\n}\n\nunsigned long ReadNumber (void)\n{\n  return 0x009a0000L;\n}\n\nint main (void)\n{\n  unsigned long tmp;\n  tmp = (ReadNumber() & 0x00ff0000L) >> 16;\n  DisplayNumber (tmp);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040208-1.c",
    "content": "int main ()\n{\n  long double x;\n\n  x = 0x1.0p-500L;\n  x *= 0x1.0p-522L;\n  if (x != 0x1.0p-1022L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040218-1.c",
    "content": "/* PR target/14209.  Bug in cris.md, shrinking access size of\n   postincrement.\n   Origin: <hp@axis.com>.  */\n\nlong int xb (long int *y) __attribute__ ((__noinline__));\nlong int xw (long int *y) __attribute__ ((__noinline__));\nshort int yb (short int *y) __attribute__ ((__noinline__));\n\nlong int xb (long int *y)\n{\n  long int xx = *y & 255;\n  return xx + y[1];\n}\n\nlong int xw (long int *y)\n{\n  long int xx = *y & 65535;\n  return xx + y[1];\n}\n\nshort int yb (short int *y)\n{\n  short int xx = *y & 255;\n  return xx + y[1];\n}\n\nint main (void)\n{\n  long int y[] = {-1, 16000};\n  short int yw[] = {-1, 16000};\n\n  if (xb (y) != 16255\n      || xw (y) != 81535\n      || yb (yw) != 16255)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040223-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n#include <string.h>\n#include <stdio.h>\n\nvoid\na(void *x,int y)\n{\n  if (y != 1234)\n    abort ();\n}\n\nint\nmain()\n{\n  a(strcpy(alloca(100),\"abc\"),1234);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040302-1.c",
    "content": "/* { dg-require-effective-target label_values } */\nint code[]={0,0,0,0,1};\n\nvoid foo(int x) {\n  volatile int b;\n  b = 0xffffffff;\n}\n\nvoid bar(int *pc) {\n  static const void *l[] = {&&lab0, &&end};\n\n  foo(0);\n  goto *l[*pc];\n lab0:\n  foo(0);\n  pc++;\n  goto *l[*pc];\n end:\n  return;\n}\n\nint main() {\n  bar(code);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040307-1.c",
    "content": "int main()\n{\n  int b = 0;\n\n  struct {\n    unsigned int bit0:1;\n    unsigned int bit1:1;\n    unsigned int bit2:1;\n    unsigned int bit3:1;\n    unsigned int bit4:1;\n    unsigned int bit5:1;\n    unsigned int bit6:1;\n    unsigned int bit7:1;\n  } sdata = {0x01};\n\n  while ( sdata.bit0-- > 0 ) {\n    b++ ;\n    if ( b > 100 ) break;\n  }\n\n  if (b != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040308-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n/* This used to fail on SPARC with an unaligned memory access.  */\n\nvoid foo(int n)\n{\n  struct S {\n    int i[n];\n    unsigned int b:1;\n    int i2;\n  } __attribute__ ((packed)) __attribute__ ((aligned (4)));\n\n  struct S s;\n\n  s.i2 = 0;\n}\n\nint main(void)\n{\n  foo(4);\n  \n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040309-1.c",
    "content": "extern void abort ();\n\nint foo(unsigned short x)\n{\n  unsigned short y;\n  y = x > 32767 ? x - 32768 : 0;\n  return y;\n}\n\nint main()\n{\n  if (foo (0) != 0)\n    abort ();\n  if (foo (32767) != 0)\n    abort ();\n  if (foo (32768) != 0)\n    abort ();\n  if (foo (32769) != 1)\n    abort ();\n  if (foo (65535) != 32767)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040311-1.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Check that constant folding and RTL simplification of -(x >> y) doesn't\n   break anything and produces the expected results.\n\n   Written by Roger Sayle, 11th March 2004.  */\n\nextern void abort (void);\n\n#define INT_BITS  (sizeof(int)*8)\n\nint test1(int x)\n{\n  return -(x >> (INT_BITS-1));\n}\n\nint test2(unsigned int x)\n{\n  return -((int)(x >> (INT_BITS-1)));\n}\n\nint test3(int x)\n{\n  int y;\n  y = INT_BITS-1;\n  return -(x >> y);\n}\n\nint test4(unsigned int x)\n{\n  int y;\n  y = INT_BITS-1;\n  return -((int)(x >> y));\n}\n\nint main()\n{\n  if (test1(0) != 0)\n    abort ();\n  if (test1(1) != 0)\n    abort ();\n  if (test1(-1) != 1)\n    abort ();\n\n  if (test2(0) != 0)\n    abort ();\n  if (test2(1) != 0)\n    abort ();\n  if (test2((unsigned int)-1) != -1)\n    abort ();\n\n  if (test3(0) != 0)\n    abort ();\n  if (test3(1) != 0)\n    abort ();\n  if (test3(-1) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(1) != 0)\n    abort ();\n  if (test4((unsigned int)-1) != -1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040313-1.c",
    "content": "/* PR middle-end/14470 */\n/* Origin: Lodewijk Voge <lvoge@cs.vu.nl> */\n\nextern void abort(void);\n\nint main()\n{\n  int t[1025] = { 1024 }, d;\n\n  d = 0;\n  d = t[d]++;\n  if (t[0] != 1025)\n    abort();\n  if (d != 1024)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040319-1.c",
    "content": "int\nblah (int zzz)\n{\n  int foo;\n  if (zzz >= 0)\n    return 1;\n  foo = (zzz >= 0 ? (zzz) : -(zzz));\n  return foo;\n}\n\nmain()\n{\n  if (blah (-1) != 1)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040331-1.c",
    "content": "/* PR c++/14755 */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n#if __INT_MAX__ >= 2147483647\n  struct { int count: 31; } s = { 0 };\n  while (s.count--)\n    abort ();\n#elif __INT_MAX__ >= 32767\n  struct { int count: 15; } s = { 0 };\n  while (s.count--)\n    abort ();\n#else\n  /* Don't bother because __INT_MAX__ is too small.  */\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040409-1.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return x ^ INT_MIN;\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return x ^ (unsigned int)INT_MIN;\n}\n\nint test2(int x)\n{\n  return x + INT_MIN;\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return x + (unsigned int)INT_MIN;\n}\n\nint test3(int x)\n{\n  return x - INT_MIN;\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return x - (unsigned int)INT_MIN;\n}\n\nint test4(int x)\n{\n  int y = INT_MIN;\n  return x ^ y;\n}\n\nunsigned int test4u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x ^ y;\n}\n\nint test5(int x)\n{\n  int y = INT_MIN;\n  return x + y;\n}\n\nunsigned int test5u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x + y;\n}\n\nint test6(int x)\n{\n  int y = INT_MIN;\n  return x - y;\n}\n\nunsigned int test6u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x - y;\n}\n\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x80000000);\n  test(0x80000000,0x00000000);\n  test(0x12345678,0x92345678);\n  test(0x92345678,0x12345678);\n  test(0x7fffffff,0xffffffff);\n  test(0xffffffff,0x7fffffff);\n\n  testu(0x00000000,0x80000000);\n  testu(0x80000000,0x00000000);\n  testu(0x12345678,0x92345678);\n  testu(0x92345678,0x12345678);\n  testu(0x7fffffff,0xffffffff);\n  testu(0xffffffff,0x7fffffff);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x8000);\n  test(0x8000,0x0000);\n  test(0x1234,0x9234);\n  test(0x9234,0x1234);\n  test(0x7fff,0xffff);\n  test(0xffff,0x7fff);\n\n  testu(0x0000,0x8000);\n  testu(0x8000,0x0000);\n  testu(0x1234,0x9234);\n  testu(0x9234,0x1234);\n  testu(0x7fff,0xffff);\n  testu(0xffff,0x7fff);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040409-2.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return (x ^ INT_MIN) ^ 0x1234;\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return (x ^ (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test2(int x)\n{\n  return (x ^ 0x1234) ^ INT_MIN;\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return (x ^ 0x1234) ^ (unsigned int)INT_MIN;\n}\n\nint test3(int x)\n{\n  return (x + INT_MIN) ^ 0x1234;\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return (x + (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test4(int x)\n{\n  return (x ^ 0x1234) + INT_MIN;\n}\n\nunsigned int test4u(unsigned int x)\n{\n  return (x ^ 0x1234) + (unsigned int)INT_MIN;\n}\n\nint test5(int x)\n{\n  return (x - INT_MIN) ^ 0x1234;\n}\n\nunsigned int test5u(unsigned int x)\n{\n  return (x - (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test6(int x)\n{\n  return (x ^ 0x1234) - INT_MIN;\n}\n\nunsigned int test6u(unsigned int x)\n{\n  return (x ^ 0x1234) - (unsigned int)INT_MIN;\n}\n\nint test7(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x ^ y) ^ z;\n}\n\nunsigned int test7u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x ^ y) ^ z;\n}\n\nint test8(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) ^ z;\n}\n\nunsigned int test8u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) ^ z;\n}\n\nint test9(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x + y) ^ z;\n}\n\nunsigned int test9u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x + y) ^ z;\n}\n\nint test10(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) + z;\n}\n\nunsigned int test10u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) + z;\n}\n\nint test11(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x - y) ^ z;\n}\n\nunsigned int test11u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x - y) ^ z;\n}\n\nint test12(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) - z;\n}\n\nunsigned int test12u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) - z;\n}\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n  if (test7(a) != b)\n    abort();\n  if (test8(a) != b)\n    abort();\n  if (test9(a) != b)\n    abort();\n  if (test10(a) != b)\n    abort();\n  if (test11(a) != b)\n    abort();\n  if (test12(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n  if (test7u(a) != b)\n    abort();\n  if (test8u(a) != b)\n    abort();\n  if (test9u(a) != b)\n    abort();\n  if (test10u(a) != b)\n    abort();\n  if (test11u(a) != b)\n    abort();\n  if (test12u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x80001234);\n  test(0x00001234,0x80000000);\n  test(0x80000000,0x00001234);\n  test(0x80001234,0x00000000);\n  test(0x7fffffff,0xffffedcb);\n  test(0xffffffff,0x7fffedcb);\n\n  testu(0x00000000,0x80001234);\n  testu(0x00001234,0x80000000);\n  testu(0x80000000,0x00001234);\n  testu(0x80001234,0x00000000);\n  testu(0x7fffffff,0xffffedcb);\n  testu(0xffffffff,0x7fffedcb);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x9234);\n  test(0x1234,0x8000);\n  test(0x8000,0x1234);\n  test(0x9234,0x0000);\n  test(0x7fff,0xedcb);\n  test(0xffff,0x6dcb);\n\n  testu(0x0000,0x9234);\n  testu(0x8000,0x1234);\n  testu(0x1234,0x8000);\n  testu(0x9234,0x0000);\n  testu(0x7fff,0xedcb);\n  testu(0xffff,0x6dcb);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040409-3.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return ~(x ^ INT_MIN);\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return ~(x ^ (unsigned int)INT_MIN);\n}\n\nint test2(int x)\n{\n  return ~(x + INT_MIN);\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return ~(x + (unsigned int)INT_MIN);\n}\n\nint test3(int x)\n{\n  return ~(x - INT_MIN);\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return ~(x - (unsigned int)INT_MIN);\n}\n\nint test4(int x)\n{\n  int y = INT_MIN;\n  return ~(x ^ y);\n}\n\nunsigned int test4u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x ^ y);\n}\n\nint test5(int x)\n{\n  int y = INT_MIN;\n  return ~(x + y);\n}\n\nunsigned int test5u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x + y);\n}\n\nint test6(int x)\n{\n  int y = INT_MIN;\n  return ~(x - y);\n}\n\nunsigned int test6u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x - y);\n}\n\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x7fffffff);\n  test(0x80000000,0xffffffff);\n  test(0x12345678,0x6dcba987);\n  test(0x92345678,0xedcba987);\n  test(0x7fffffff,0x00000000);\n  test(0xffffffff,0x80000000);\n\n  testu(0x00000000,0x7fffffff);\n  testu(0x80000000,0xffffffff);\n  testu(0x12345678,0x6dcba987);\n  testu(0x92345678,0xedcba987);\n  testu(0x7fffffff,0x00000000);\n  testu(0xffffffff,0x80000000);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x7fff);\n  test(0x8000,0xffff);\n  test(0x1234,0x6dcb);\n  test(0x9234,0xedcb);\n  test(0x7fff,0x0000);\n  test(0xffff,0x8000);\n\n  testu(0x0000,0x7fff);\n  testu(0x8000,0xffff);\n  testu(0x1234,0x6dcb);\n  testu(0x9234,0xedcb);\n  testu(0x7fff,0x0000);\n  testu(0xffff,0x8000);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040411-1.c",
    "content": "int\nsub1 (int i, int j)\n{\n  typedef int c[i+2];\n  int x[10], y[10];\n\n  if (j == 2)\n    {\n      memcpy (x, y, 10 * sizeof (int));\n      return sizeof (c);\n    }\n  else\n    return sizeof (c) * 3;\n}\n\nint\nmain ()\n{\n  if (sub1 (20, 3) != 66 * sizeof (int))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040423-1.c",
    "content": "int\nsub1 (int i, int j)\n{\n  typedef struct\n  {\n   int  c[i+2];\n  }c;\n  int x[10], y[10];\n\n  if (j == 2)\n    {\n      memcpy (x, y, 10 * sizeof (int));\n      return sizeof (c);\n    }\n  else\n    return sizeof (c) * 3;\n}\n\nint\nmain ()\n{\n  typedef struct\n  {\n   int  c[22];\n  }c;\n  if (sub1 (20, 3) != sizeof (c)*3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040520-1.c",
    "content": "/* PR 15454 */\n\nvoid abort ();\nint main () {\n        int foo;\n        int bar (void)\n        {\n                int baz = 0;\n                if (foo!=45)\n                        baz = foo;\n                return baz;\n        }\n        foo = 1;\n        if (!bar ())\n                abort ();\n        return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040625-1.c",
    "content": "/* From PR target/16176 */\nstruct __attribute__ ((packed)) s { struct s *next; };\n\nstruct s * __attribute__ ((noinline))\nmaybe_next (struct s *s, int t)\n{\n  if (t)\n    s = s->next;\n  return s;\n}\n\nint main ()\n{\n  struct s s1, s2;\n\n  s1.next = &s2;\n  if (maybe_next (&s1, 1) != &s2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040629-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Test arithmetics on bitfields.  */\n#ifndef T\n\nextern void abort (void);\nextern void exit (int);\n\n#ifndef FIELDS1\n#define FIELDS1\n#endif\n#ifndef FIELDS2\n#define FIELDS2\n#endif\n\nstruct { FIELDS1 unsigned int i : 6, j : 11, k : 15; FIELDS2 } b;\nstruct { FIELDS1 unsigned int i : 5, j : 1, k : 26; FIELDS2 } c;\nstruct { FIELDS1 unsigned int i : 16, j : 8, k : 8; FIELDS2 } d;\n\nunsigned int ret1 (void) { return b.i; }\nunsigned int ret2 (void) { return b.j; }\nunsigned int ret3 (void) { return b.k; }\nunsigned int ret4 (void) { return c.i; }\nunsigned int ret5 (void) { return c.j; }\nunsigned int ret6 (void) { return c.k; }\nunsigned int ret7 (void) { return d.i; }\nunsigned int ret8 (void) { return d.j; }\nunsigned int ret9 (void) { return d.k; }\n\n#define T(n, pre, post, op) \t\t\t\t\t\\\nvoid fn1_##n (unsigned int x) { pre b.i post; }\t\t\t\\\nvoid fn2_##n (unsigned int x) { pre b.j post; }\t\t\t\\\nvoid fn3_##n (unsigned int x) { pre b.k post; }\t\t\t\\\nvoid fn4_##n (unsigned int x) { pre c.i post; }\t\t\t\\\nvoid fn5_##n (unsigned int x) { pre c.j post; }\t\t\t\\\nvoid fn6_##n (unsigned int x) { pre c.k post; }\t\t\t\\\nvoid fn7_##n (unsigned int x) { pre d.i post; }\t\t\t\\\nvoid fn8_##n (unsigned int x) { pre d.j post; }\t\t\t\\\nvoid fn9_##n (unsigned int x) { pre d.k post; }\n\n#include \"20040629-1.c\"\n#undef T\n\n#define FAIL(n, i) abort ()\n\nint\nmain (void)\n{\n#define T(n, pre, post, op)\t\t\t\t\t\\\n  b.i = 51;\t\t\t\t\t\t\t\\\n  b.j = 636;\t\t\t\t\t\t\t\\\n  b.k = 31278;\t\t\t\t\t\t\t\\\n  c.i = 21;\t\t\t\t\t\t\t\\\n  c.j = 1;\t\t\t\t\t\t\t\\\n  c.k = 33554432;\t\t\t\t\t\t\\\n  d.i = 26812;\t\t\t\t\t\t\t\\\n  d.j = 156;\t\t\t\t\t\t\t\\\n  d.k = 187;\t\t\t\t\t\t\t\\\n  fn1_##n (3);\t\t\t\t\t\t\t\\\n  if (ret1 () != (op (51, 3) & ((1 << 6) - 1)))\t\t\t\\\n    FAIL (n, 1);\t\t\t\t\t\t\\\n  b.i = 51;\t\t\t\t\t\t\t\\\n  fn2_##n (251);\t\t\t\t\t\t\\\n  if (ret2 () != (op (636, 251) & ((1 << 11) - 1)))\t\t\\\n    FAIL (n, 2);\t\t\t\t\t\t\\\n  b.j = 636;\t\t\t\t\t\t\t\\\n  fn3_##n (13279);\t\t\t\t\t\t\\\n  if (ret3 () != (op (31278, 13279) & ((1 << 15) - 1)))\t\t\\\n    FAIL (n, 3);\t\t\t\t\t\t\\\n  b.j = 31278;\t\t\t\t\t\t\t\\\n  fn4_##n (24);\t\t\t\t\t\t\t\\\n  if (ret4 () != (op (21, 24) & ((1 << 5) - 1)))\t\t\\\n    FAIL (n, 4);\t\t\t\t\t\t\\\n  c.i = 21;\t\t\t\t\t\t\t\\\n  fn5_##n (1);\t\t\t\t\t\t\t\\\n  if (ret5 () != (op (1, 1) & ((1 << 1) - 1)))\t\t\t\\\n    FAIL (n, 5);\t\t\t\t\t\t\\\n  c.j = 1;\t\t\t\t\t\t\t\\\n  fn6_##n (264151);\t\t\t\t\t\t\\\n  if (ret6 () != (op (33554432, 264151) & ((1 << 26) - 1)))\t\\\n    FAIL (n, 6);\t\t\t\t\t\t\\\n  c.k = 33554432;\t\t\t\t\t\t\\\n  fn7_##n (713);\t\t\t\t\t\t\\\n  if (ret7 () != (op (26812, 713) & ((1 << 16) - 1)))\t\t\\\n    FAIL (n, 7);\t\t\t\t\t\t\\\n  d.i = 26812;\t\t\t\t\t\t\t\\\n  fn8_##n (17);\t\t\t\t\t\t\t\\\n  if (ret8 () != (op (156, 17) & ((1 << 8) - 1)))\t\t\\\n    FAIL (n, 8);\t\t\t\t\t\t\\\n  d.j = 156;\t\t\t\t\t\t\t\\\n  fn9_##n (199);\t\t\t\t\t\t\\\n  if (ret9 () != (op (187, 199) & ((1 << 8) - 1)))\t\t\\\n    FAIL (n, 9);\t\t\t\t\t\t\\\n  d.k = 187;\n\n#include \"20040629-1.c\"\n#undef T\n  return 0;\n}\n\n#else\n\n#ifndef opadd\n#define opadd(x, y) (x + y)\n#define opsub(x, y) (x - y)\n#define opinc(x, y) (x + 1)\n#define opdec(x, y) (x - 1)\n#define opand(x, y) (x & y)\n#define opior(x, y) (x | y)\n#define opxor(x, y) (x ^ y)\n#define opdiv(x, y) (x / y)\n#define oprem(x, y) (x % y)\n#define opadd3(x, y) (x + 3)\n#define opsub7(x, y) (x - 7)\n#define opand21(x, y) (x & 21)\n#define opior19(x, y) (x | 19)\n#define opxor37(x, y) (x ^ 37)\n#define opdiv17(x, y) (x / 17)\n#define oprem19(x, y) (x % 19)\n#endif\n\nT(1, , += x, opadd)\nT(2, ++, , opinc)\nT(3, , ++, opinc)\nT(4, , -= x, opsub)\nT(5, --, , opdec)\nT(6, , --, opdec)\nT(7, , &= x, opand)\nT(8, , |= x, opior)\nT(9, , ^= x, opxor)\nT(a, , /= x, opdiv)\nT(b, , %= x, oprem)\nT(c, , += 3, opadd3)\nT(d, , -= 7, opsub7)\nT(e, , &= 21, opand21)\nT(f, , |= 19, opior19)\nT(g, , ^= 37, opxor37)\nT(h, , /= 17, opdiv17)\nT(i, , %= 19, oprem19)\n\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040703-1.c",
    "content": "/* PR 16341 */\n/* { dg-require-effective-target int32plus } */\n\n#define PART_PRECISION (sizeof (cpp_num_part) * 8)\n\ntypedef unsigned int cpp_num_part;\ntypedef struct cpp_num cpp_num;\nstruct cpp_num\n{\n   cpp_num_part high;\n   cpp_num_part low;\n   int unsignedp;  /* True if value should be treated as unsigned.  */\n   int overflow;   /* True if the most recent calculation overflowed.  */\n};\n\nstatic  int\nnum_positive (cpp_num num, unsigned int precision)\n{\n   if (precision > PART_PRECISION)\n     {\n       precision -= PART_PRECISION;\n       return (num.high & (cpp_num_part) 1 << (precision - 1)) == 0;\n     }\n\n   return (num.low & (cpp_num_part) 1 << (precision - 1)) == 0;\n}\n\nstatic cpp_num\nnum_trim (cpp_num num, unsigned int precision)\n{\n   if (precision > PART_PRECISION)\n     {\n       precision -= PART_PRECISION;\n       if (precision < PART_PRECISION)\n         num.high &= ((cpp_num_part) 1 << precision) - 1;\n     }\n   else\n     {\n       if (precision < PART_PRECISION)\n         num.low &= ((cpp_num_part) 1 << precision) - 1;\n       num.high = 0;\n     }\n\n   return num;\n}\n\n/* Shift NUM, of width PRECISION, right by N bits.  */\nstatic cpp_num\nnum_rshift (cpp_num num, unsigned int precision, unsigned int n)\n{\n   cpp_num_part sign_mask;\n   int x = num_positive (num, precision);\n\n   if (num.unsignedp || x)\n     sign_mask = 0;\n   else\n     sign_mask = ~(cpp_num_part) 0;\n\n   if (n >= precision)\n     num.high = num.low = sign_mask;\n   else\n     {\n       /* Sign-extend.  */\n       if (precision < PART_PRECISION)\n         num.high = sign_mask, num.low |= sign_mask << precision;\n       else if (precision < 2 * PART_PRECISION)\n         num.high |= sign_mask << (precision - PART_PRECISION);\n\n       if (n >= PART_PRECISION)\n         {\n           n -= PART_PRECISION;\n           num.low = num.high;\n           num.high = sign_mask;\n         }\n\n       if (n)\n         {\n           num.low = (num.low >> n) | (num.high << (PART_PRECISION - n));\n           num.high = (num.high >> n) | (sign_mask << (PART_PRECISION - n));\n         }\n     }\n\n   num = num_trim (num, precision);\n   num.overflow = 0;\n   return num;\n}\n                              #define num_zerop(num) ((num.low | num.high) == 0)\n#define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high)\n\ncpp_num\nnum_lshift (cpp_num num, unsigned int precision, unsigned int n)\n{\n   if (n >= precision)\n     {\n       num.overflow = !num.unsignedp && !num_zerop (num);\n       num.high = num.low = 0;\n     }\n   else\n     {\n       cpp_num orig;\n       unsigned int m = n;\n\n       orig = num;\n       if (m >= PART_PRECISION)\n         {\n           m -= PART_PRECISION;\n           num.high = num.low;\n           num.low = 0;\n         }\n       if (m)\n         {\n           num.high = (num.high << m) | (num.low >> (PART_PRECISION - m));\n           num.low <<= m;\n         }\n       num = num_trim (num, precision);\n\n       if (num.unsignedp)\n         num.overflow = 0;\n       else\n         {\n           cpp_num maybe_orig = num_rshift (num, precision, n);\n           num.overflow = !num_eq (orig, maybe_orig);\n         }\n     }\n\n   return num;\n}\n\nunsigned int precision = 64;\nunsigned int n = 16;\n\ncpp_num num = { 0, 3, 0, 0 };\n\nint main()\n{\n   cpp_num res = num_lshift (num, 64, n);\n\n   if (res.low != 0x30000)\n     abort ();\n\n   if (res.high != 0)\n     abort ();\n\n   if (res.overflow != 0)\n     abort ();\n\n   exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040704-1.c",
    "content": "/* PR 16348: Make sure that condition-first false loops DTRT.  */\n\nextern void abort ();\n\nint main()\n{\n  for (; 0 ;)\n    {\n      abort ();\n    label:\n      return 0;\n    }\n  goto label;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040705-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#define FIELDS1 long long l;\n#include \"20040629-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040705-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#define FIELDS2 long long l;\n#include \"20040629-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040706-1.c",
    "content": "int main ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    continue;\n  if (i < 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040707-1.c",
    "content": "struct s { char c1, c2; };\nvoid foo (struct s s)\n{\n  static struct s s1;\n  s1 = s;\n}\nint main ()\n{\n  static struct s s2;\n  foo (s2);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040709-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Test arithmetics on bitfields.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned int\nmyrnd (void)\n{\n  static unsigned int s = 1388815473;\n  s *= 1103515245;\n  s += 12345;\n  return (s / 65536) % 2048;\n}\n\n#define T(S)\t\t\t\t\t\\\nstruct S s##S;\t\t\t\t\t\\\nstruct S retme##S (struct S x)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return x;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn1##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y = retme##S (y);\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn2##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y.k %= 15;\t\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int retit##S (void)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return s##S.k;\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn3##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  s##S.k += x;\t\t\t\t\t\\\n  return retit##S ();\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid test##S (void)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n  unsigned int mask, v, a, r;\t\t\t\\\n  struct S x;\t\t\t\t\t\\\n  char *p = (char *) &s##S;\t\t\t\\\n  for (i = 0; i < sizeof (s##S); ++i)\t\t\\\n    *p++ = myrnd ();\t\t\t\t\\\n  if (__builtin_classify_type (s##S.l) == 8)\t\\\n    s##S.l = 5.25;\t\t\t\t\\\n  s##S.k = -1;\t\t\t\t\t\\\n  mask = s##S.k;\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn1##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn2##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((((v + a) & mask) % 15) & mask) != r)\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn3##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || s##S.k != r || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n}\n\nstruct A { unsigned int i : 6, l : 1, j : 10, k : 15; }; T(A)\nstruct B { unsigned int i : 6, j : 11, k : 15; unsigned int l; }; T(B)\nstruct C { unsigned int l; unsigned int i : 6, j : 11, k : 15; }; T(C)\nstruct D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)\nstruct E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)\nstruct F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)\nstruct G { unsigned int i : 12, j : 13, k : 7; unsigned long long l; }; T(G)\nstruct H { unsigned int i : 12, j : 11, k : 9; unsigned long long l; }; T(H)\nstruct I { unsigned short i : 1, j : 6, k : 9; unsigned long long l; }; T(I)\nstruct J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)\nstruct K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)\nstruct L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)\nstruct M { unsigned int l; unsigned int k : 6, j : 11, i : 15; }; T(M)\nstruct N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)\nstruct O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)\nstruct P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)\nstruct Q { unsigned int k : 12, j : 13, i : 7; unsigned long long l; }; T(Q)\nstruct R { unsigned int k : 12, j : 11, i : 9; unsigned long long l; }; T(R)\nstruct S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)\nstruct T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)\nstruct U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)\nstruct V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)\nstruct W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)\nstruct X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)\nstruct Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)\nstruct Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)\n\nint\nmain (void)\n{\n  testA ();\n  testB ();\n  testC ();\n  testD ();\n  testE ();\n  testF ();\n  testG ();\n  testH ();\n  testI ();\n  testJ ();\n  testK ();\n  testL ();\n  testM ();\n  testN ();\n  testO ();\n  testP ();\n  testQ ();\n  testR ();\n  testS ();\n  testT ();\n  testU ();\n  testV ();\n  testW ();\n  testX ();\n  testY ();\n  testZ ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040709-2.c",
    "content": "/* Test arithmetics on bitfields.  */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned int\nmyrnd (void)\n{\n  static unsigned int s = 1388815473;\n  s *= 1103515245;\n  s += 12345;\n  return (s / 65536) % 2048;\n}\n\n#define T(S)\t\t\t\t\t\\\nstruct S s##S;\t\t\t\t\t\\\nstruct S retme##S (struct S x)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return x;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn1##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y = retme##S (y);\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn2##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y.k %= 15;\t\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int retit##S (void)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return s##S.k;\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn3##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  s##S.k += x;\t\t\t\t\t\\\n  return retit##S ();\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid test##S (void)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n  unsigned int mask, v, a, r;\t\t\t\\\n  struct S x;\t\t\t\t\t\\\n  char *p = (char *) &s##S;\t\t\t\\\n  for (i = 0; i < sizeof (s##S); ++i)\t\t\\\n    *p++ = myrnd ();\t\t\t\t\\\n  if (__builtin_classify_type (s##S.l) == 8)\t\\\n    s##S.l = 5.25;\t\t\t\t\\\n  s##S.k = -1;\t\t\t\t\t\\\n  mask = s##S.k;\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn1##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn2##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((((v + a) & mask) % 15) & mask) != r)\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn3##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || s##S.k != r || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n}\n\n#define pck __attribute__((packed))\nstruct pck A { unsigned short i : 1, l : 1, j : 3, k : 11; }; T(A)\nstruct pck B { unsigned short i : 4, j : 1, k : 11; unsigned int l; }; T(B)\nstruct pck C { unsigned int l; unsigned short i : 4, j : 1, k : 11; }; T(C)\nstruct pck D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)\nstruct pck E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)\nstruct pck F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)\nstruct pck G { unsigned short i : 1, j : 1, k : 6; unsigned long long l; }; T(G)\nstruct pck H { unsigned short i : 6, j : 2, k : 8; unsigned long long l; }; T(H)\nstruct pck I { unsigned short i : 1, j : 6, k : 1; unsigned long long l; }; T(I)\nstruct pck J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)\nstruct pck K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)\nstruct pck L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)\nstruct pck M { unsigned int l; unsigned short k : 6, j : 11, i : 15; }; T(M)\nstruct pck N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)\nstruct pck O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)\nstruct pck P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)\nstruct pck Q { unsigned short k : 12, j : 1, i : 3; unsigned long long l; }; T(Q)\nstruct pck R { unsigned short k : 2, j : 11, i : 3; unsigned long long l; }; T(R)\nstruct pck S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)\nstruct pck T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)\nstruct pck U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)\nstruct pck V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)\nstruct pck W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)\nstruct pck X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)\nstruct pck Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)\nstruct pck Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)\n\nint\nmain (void)\n{\n  testA ();\n  testB ();\n  testC ();\n  testD ();\n  testE ();\n  testF ();\n  testG ();\n  testH ();\n  testI ();\n  testJ ();\n  testK ();\n  testL ();\n  testM ();\n  testN ();\n  testO ();\n  testP ();\n  testQ ();\n  testR ();\n  testS ();\n  testT ();\n  testU ();\n  testV ();\n  testW ();\n  testX ();\n  testY ();\n  testZ ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040805-1.c",
    "content": "#if __INT_MAX__ < 32768 || (defined(STACK_SIZE) && STACK_SIZE < 0x12000)\nint main () { exit (0); }\n#else\nint a[2] = { 2, 3 };\n\nstatic int __attribute__((noinline))\nbar (int x, void *b)\n{\n  a[0]++;\n  return x;\n}\n\nstatic int __attribute__((noinline))\nfoo (int x)\n{\n  char buf[0x10000];\n  int y = a[0];\n  a[1] = y;\n  x = bar (x, buf);\n  y = bar (y, buf);\n  return x + y;\n}\n\nint\nmain ()\n{\n  if (foo (100) != 102)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040811-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target alloca } */\n\n/* Ensure that we deallocate X when branching back before its\n   declaration.  */\n\nvoid *volatile p;\n                                                                                \nint\nmain (void)\n{\n  int n = 0;\n lab:;\n  int x[n % 1000 + 1];\n  x[0] = 1;\n  x[n % 1000] = 2;\n  p = x;\n  n++;\n  if (n < 1000000)\n    goto lab;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040820-1.c",
    "content": "/* PR rtl-optimization/17099 */\n\nextern void exit (int);\nextern void abort (void);\n\nvoid\ncheck (int a)\n{\n  if (a != 1)\n    abort ();\n}\n\nvoid\ntest (int a, int b)\n{\n  check ((a ? 1 : 0) | (b ? 2 : 0));\n}\n\nint\nmain (void)\n{\n  test (1, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040823-1.c",
    "content": "/* Ensure that we create VUSE operands also for noreturn functions.  */\n\n#include <stdlib.h>\n#include <string.h>\n\nint *pwarn;\n\nvoid bla (void) __attribute__ ((noreturn));\n\nvoid bla (void)\n{\n  if (!*pwarn)\n    abort ();\n    \n  exit (0);\n}\n\nint main (void)\n{\n  int warn;\n\n  memset (&warn, 0, sizeof (warn));\n\n  pwarn = &warn;\n\n  warn = 1;\n\n  bla ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040831-1.c",
    "content": "/* This testcase was being miscompiled, because operand_equal_p\n   returned that (unsigned long) d and (long) d are equal.  */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  double d = -12.0;\n  long l = (d > 10000) ? (unsigned long) d : (long) d;\n  if (l != -12)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20040917-1.c",
    "content": "/* submitted by kenneth zadeck */\n\nstatic int test_var;\n\n/* the idea here is that not only is inlinable, inlinable but since it\n   is static, the cgraph node will not be marked as output.  The\n   current version of the code ignores these cgraph nodes.  */\n\nvoid not_inlinable()  __attribute__((noinline));\n\nstatic void  \ninlinable ()\n{\n  test_var = -10;\n}\n\nvoid \nnot_inlinable ()\n{\n  inlinable();\n}\n\nmain ()\n{\n  test_var = 10;\n  /* Variable test_var should be considered call-clobbered by the call\n     to not_inlinable().  */\n  not_inlinable ();\n  if (test_var == 10)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041011-1.c",
    "content": "typedef unsigned long long ull;\nvolatile int gvol[32];\null gull;\n\n#define MULTI(X) \\\n\tX( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), X(10), \\\n\tX(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), X(20), \\\n\tX(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29), X(30)\n\n#define DECLARE(INDEX) x##INDEX\n#define COPYIN(INDEX) x##INDEX = gvol[INDEX]\n#define COPYOUT(INDEX) gvol[INDEX] = x##INDEX\n\n#define BUILD_TEST(NAME, N)\t\t\\\n  ull __attribute__((noinline))\t\t\\\n  NAME (int n, ull x)\t\t\t\\\n  {\t\t\t\t\t\\\n    while (n--)\t\t\t\t\\\n      {\t\t\t\t\t\\\n\tint MULTI (DECLARE);\t\t\\\n\tMULTI (COPYIN);\t\t\t\\\n\tMULTI (COPYOUT);\t\t\\\n\tx += N;\t\t\t\t\\\n      }\t\t\t\t\t\\\n    return x;\t\t\t\t\\\n  }\n\n#define RUN_TEST(NAME, N)\t\t\\\n  if (NAME (3, ~0ULL) != N * 3 - 1)\t\\\n    abort ();\t\t\t\t\\\n  if (NAME (3, 0xffffffffULL)\t\t\\\n      != N * 3 + 0xffffffffULL)\t\t\\\n    abort ();\n\n#define DO_TESTS(DO_TEST)\t\\\n  DO_TEST (t1, -2048)\t\t\\\n  DO_TEST (t2, -513)\t\t\\\n  DO_TEST (t3, -512)\t\t\\\n  DO_TEST (t4, -511)\t\t\\\n  DO_TEST (t5, -1)\t\t\\\n  DO_TEST (t6, 1)\t\t\\\n  DO_TEST (t7, 511)\t\t\\\n  DO_TEST (t8, 512)\t\t\\\n  DO_TEST (t9, 513)\t\t\\\n  DO_TEST (t10, gull)\t\t\\\n  DO_TEST (t11, -gull)\n\nDO_TESTS (BUILD_TEST)\n\null neg (ull x) { return -x; }\n\nint\nmain ()\n{\n  gull = 100;\n  DO_TESTS (RUN_TEST)\n  if (neg (gull) != -100ULL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041019-1.c",
    "content": "test_store_ccp (int i)\n{\n  int *p, a, b, c;\n\n  if (i < 5)\n    p = &a;\n  else if (i > 8)\n    p = &b;\n  else\n    p = &c;\n\n  *p = 10;\n  b = 3;\n\n  /* STORE-CCP was wrongfully propagating 10 into *p.  */\n  return *p + 2;\n}\n\n\ntest_store_copy_prop (int i)\n{\n  int *p, a, b, c;\n\n  if (i < 5)\n    p = &a;\n  else if (i > 8)\n    p = &b;\n  else\n    p = &c;\n\n  *p = i;\n  b = i + 1;\n\n  /* STORE-COPY-PROP was wrongfully propagating i into *p.  */\n  return *p;\n}\n\n\nmain()\n{\n  int x;\n  \n  x = test_store_ccp (10);\n  if (x == 12)\n    abort ();\n  \n  x = test_store_copy_prop (9);\n  if (x == 9)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041112-1.c",
    "content": "/* This was failing on Alpha because the comparison (p != -1) was rewritten\n   as (p+1 != 0) and p+1 isn't allowed to wrap for pointers.  */\n\nextern void abort(void);\n\ntypedef __SIZE_TYPE__ size_t;\n\nint global;\n\nstatic void *foo(int p)\n{\n  if (p == 0)\n   {\n      global++;\n      return &global;\n   }\n\n  return (void *)(size_t)-1;\n}\n\nint bar(void)\n{\n  void *p;\n\n  p = foo(global);\n  if (p != (void *)(size_t)-1)\n    return 1;\n\n  global++;\n  return 0;\n}\n\nint main(void)\n{\n  global = 1;\n  if (bar () != 0)\n    abort();\n  \n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041113-1.c",
    "content": "#include <stdarg.h>\n\nvoid test (int x, ...)\n{\n    va_list ap;\n    int i;\n    va_start (ap, x);\n    if (va_arg (ap, int) != 1)\n\tabort ();\n    if (va_arg (ap, int) != 2)\n\tabort ();\n    if (va_arg (ap, int) != 3)\n\tabort ();\n    if (va_arg (ap, int) != 4)\n\tabort ();\n}\n\ndouble a = 40.0;\n\nint main(int argc, char *argv[])\n{\n    test(0, 1, 2, 3, (int)(a / 10.0));\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041114-1.c",
    "content": "/* Verify that\n   \n   var <= 0 || ((long unsigned) (unsigned) (var - 1) < MAX_UNSIGNED_INT)\n\n   gets folded to 1.  */\n\n#include <limits.h>\n\nvoid abort (void);\nvoid link_failure (void);\n\nvolatile int v;\n\nvoid \nfoo (int var)\n{\n  if (!(var <= 0\n        || ((long unsigned) (unsigned) (var - 1) < UINT_MAX)))\n    link_failure ();\n}\n\nint\nmain (int argc, char **argv)\n{\n  foo (v);\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_failure (void)\n{\n  abort ();\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041124-1.c",
    "content": "struct s { _Complex unsigned short x; };\nstruct s gs = { 100 + 200i };\nstruct s __attribute__((noinline)) foo (void) { return gs; }\n\nint main ()\n{\n  if (foo ().x != gs.x)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041126-1.c",
    "content": "extern int abs (int);\nextern void abort (void);\n\nvoid\ncheck (int *p)\n{\n  int i;\n  for (i = 0; i < 5; ++i)\n    if (p[i])\n      abort ();\n  for (; i < 10; ++i)\n    if (p[i] != i + 1)\n      abort ();\n}\n\nint\nmain (void)\n{\n  int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n  int i;\n\n  for (i = -5; i < 0; i++)\n    a[abs (i - 10) - 11] = 0;\n  check (a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041201-1.c",
    "content": "/* PR rtl-opt/15289 */\n\ntypedef struct { _Complex char a; _Complex char b; } Scc2;\n\nScc2 s = { 1+2i, 3+4i };\n\nint checkScc2 (Scc2 s)\n{\n  return s.a != 1+2i || s.b != 3+4i;\n}\n\nint main (void)\n{\n  return checkScc2 (s);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041210-1.c",
    "content": "/* The FR-V port used to fail this test because the andcc patterns\n   wrongly claimed to set the C and V flags.  */\n#include <limits.h>\n\nint x[4] = { INT_MIN / 2, INT_MAX, 2, 4 };\n\nint\nmain ()\n{\n  if (x[0] < x[1])\n    if ((x[2] & x[3]) < 0)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041212-1.c",
    "content": "/* A function pointer compared with a void pointer should not be canonicalized.\n   See PR middle-end/17564.  */\nvoid *f (void) __attribute__ ((__noinline__));\nvoid *\nf (void)\n{\n  return f;\n}\nint\nmain (void)\n{\n  if (f () != f)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041213-2.c",
    "content": "/* PR tree-optimization/18694\n\n   The dominator optimization didn't take the PHI evaluation order\n   into account when threading an edge.  */\n\nextern void abort (void) __attribute__((noreturn));\nextern void exit (int) __attribute__((noreturn));\n\nvoid __attribute__((noinline))\nfoo (int i)\n{\n  int next_n = 1;\n  int j = 0;\n\n  for (; i != 0; i--)\n    {\n      int n;\n\n      for (n = next_n; j < n; j++)\n\tnext_n++;\n\n      if (j != n)\n\tabort ();\n    }\n}\n\nint\nmain (void)\n{\n  foo (2);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041214-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\ntypedef long unsigned int size_t;\nextern void abort (void);\nextern char *strcpy (char *, const char *);\nextern int strcmp (const char *, const char *);\ntypedef __builtin_va_list va_list;\nstatic const char null[] = \"(null)\";\nint g (char *s, const char *format, va_list ap)\n{\n  const char *f;\n  const char *string;\n  char spec;\n  static const void *step0_jumps[] = {\n    &&do_precision,\n    &&do_form_integer,\n    &&do_form_string,\n  };\n  f = format;\n  if (*f == '\\0')\n    goto all_done;\n  do\n    {\n      spec = (*++f);\n      goto *(step0_jumps[2]);\n      \n    /* begin switch table. */\n    do_precision:\n      ++f;\n      __builtin_va_arg (ap, int);\n      spec = *f;\n      goto *(step0_jumps[2]);\n      \n      do_form_integer:\n\t__builtin_va_arg (ap, unsigned long int);\n\tgoto end;\n\t\n      do_form_string:\n\tstring = __builtin_va_arg (ap, const char *);\n\tstrcpy (s, string);\n      \n      /* End of switch table. */\n      end:\n      ++f;\n    }\n  while (*f != '\\0');\n\nall_done:\n  return 0;\n}\n\nvoid\nf (char *s, const char *f, ...)\n{\n  va_list ap;\n  __builtin_va_start (ap, f);\n  g (s, f, ap);\n  __builtin_va_end (ap);\n}\n\nint\nmain (void)\n{\n  char buf[10];\n  f (buf, \"%s\", \"asdf\", 0);\n  if (strcmp (buf, \"asdf\"))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041218-1.c",
    "content": "/* PR rtl-optimization/16968 */\n/* Testcase by Jakub Jelinek  <jakub@redhat.com> */\n\nstruct T\n{\n  unsigned int b, c, *d;\n  unsigned char e;\n};\nstruct S\n{\n  unsigned int a;\n  struct T f;\n};\nstruct U\n{\n  struct S g, h;\n};\nstruct V\n{\n  unsigned int i;\n  struct U j;\n};\n\nextern void exit (int);\nextern void abort (void);\n\nvoid *\ndummy1 (void *x)\n{\n  return \"\";\n}\n\nvoid *\ndummy2 (void *x, void *y)\n{\n  exit (0);\n}\n\nstruct V *\nbaz (unsigned int x)\n{\n  static struct V v;\n  __builtin_memset (&v, 0x55, sizeof (v));\n  return &v;\n}\n\nint\ncheck (void *x, struct S *y)\n{\n  if (y->a || y->f.b || y->f.c || y->f.d || y->f.e)\n    abort ();\n  return 1;\n}\n\nstatic struct V *\nbar (unsigned int x, void *y)\n{\n  const struct T t = { 0, 0, (void *) 0, 0 };\n  struct V *u;\n  void *v;\n  v = dummy1 (y);\n  if (!v)\n    return (void *) 0;\n\n  u = baz (sizeof (struct V));\n  u->i = x;\n  u->j.g.a = 0;\n  u->j.g.f = t;\n  u->j.h.a = 0;\n  u->j.h.f = t;\n\n  if (!check (v, &u->j.g) || !check (v, &u->j.h))\n    return (void *) 0;\n  return u;\n}\n\nint\nfoo (unsigned int *x, unsigned int y, void **z)\n{\n  void *v;\n  unsigned int i, j;\n\n  *z = v = (void *) 0;\n\n  for (i = 0; i < y; i++)\n    {\n      struct V *c;\n\n      j = *x;\n\n      switch (j)\n\t{\n\tcase 1:\n\t  c = bar (j, x);\n\t  break;\n\tdefault:\n\t  c = 0;\n\t  break;\n\t}\n      if (c)\n\tv = dummy2 (v, c);\n      else\n        return 1;\n    }\n\n  *z = v;\n  return 0;\n}\n\nint\nmain (void)\n{\n  unsigned int one = 1;\n  void *p;\n  foo (&one, 1, &p);\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20041218-2.c",
    "content": "extern void abort (void);\n\nint test(int n)\n{\n  struct s { char b[n]; } __attribute__((packed));\n  n++;\n  return sizeof(struct s);\n}\n\nint main()\n{\n  if (test(123) != 123)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050104-1.c",
    "content": "/* PR tree-optimization/19060 */\n\nvoid abort (void);\n\nstatic\nlong long min ()\n{\n  return -__LONG_LONG_MAX__ - 1;\n}\n\nvoid\nfoo (long long j)\n{\n  if (j > 10 || j < min ())\n    abort ();\n}\n\nint\nmain (void)\n{\n  foo (10);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050106-1.c",
    "content": "/* PR tree-optimization/19283 */\n\nvoid abort (void);\n\nstatic inline unsigned short\nfoo (unsigned int *p)\n{\n  return *p;\n};\n\nunsigned int u;\n\nint\nmain ()\n{\n  if ((foo (&u) & 0x8000) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050107-1.c",
    "content": "typedef enum { C = 1, D = 2 } B;\nextern void abort (void);\n\nstruct S\n{\n  B __attribute__ ((mode (byte))) a;\n  B __attribute__ ((mode (byte))) b;\n};\n\nvoid\nfoo (struct S *x)\n{\n  if (x->a != C || x->b != D)\n    abort ();\n}\n\nint\nmain (void)\n{\n  struct S s;\n  s.a = C;\n  s.b = D;\n  foo (&s);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050111-1.c",
    "content": "/* PR middle-end/19084, rtl-optimization/19348 */\n\nunsigned int\nfoo (unsigned long long x)\n{\n  unsigned int u;\n\n  if (x == 0)\n    return 0;\n  u = (unsigned int) (x >> 32);\n  return u;\n}\n\nunsigned long long\nbar (unsigned short x)\n{\n  return (unsigned long long) x << 32;\n}\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (sizeof (long long) != 8)\n    return 0;\n\n  if (foo (0) != 0)\n    abort ();\n  if (foo (0xffffffffULL) != 0)\n    abort ();\n  if (foo (0x25ff00ff00ULL) != 0x25)\n    abort ();\n  if (bar (0) != 0)\n    abort ();\n  if (bar (0x25) != 0x2500000000ULL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050119-1.c",
    "content": "/* PR c/19342 */\ntypedef enum { A, B, C, D } E;\n\nstruct S {\n  E __attribute__ ((mode (__byte__))) a;\n  E __attribute__ ((mode (__byte__))) b;\n  E __attribute__ ((mode (__byte__))) c;\n  E __attribute__ ((mode (__byte__))) d;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (struct S *s)\n{\n  if (s->a != s->b)\n    abort ();\n  if (s->c != C)\n    abort ();\n}\n\nint\nmain (void)\n{\n  struct S s[2];\n  s[0].a = B;\n  s[0].b = B;\n  s[0].c = C;\n  s[0].d = D;\n  s[1].a = D;\n  s[1].b = C;\n  s[1].c = B;\n  s[1].d = A;\n  foo (s);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050119-2.c",
    "content": "/* PR middle-end/19874 */\ntypedef enum { A, B, C, D } E;\n\nstruct S {\n  E __attribute__ ((mode (__byte__))) a;\n  E __attribute__ ((mode (__byte__))) b;\n  E __attribute__ ((mode (__byte__))) c;\n  E __attribute__ ((mode (__byte__))) d;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nE\nfoo (struct S *s)\n{\n  if (s->a != s->b)\n    abort ();\n  if (s->c != C)\n    abort ();\n  return s->d;\n}\n\nint\nmain (void)\n{\n  struct S s[2];\n  s[0].a = B;\n  s[0].b = B;\n  s[0].c = C;\n  s[0].d = D;\n  s[1].a = D;\n  s[1].b = C;\n  s[1].c = B;\n  s[1].d = A;\n  if (foo (s) != D)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050121-1.c",
    "content": "/* PR middle-end/19551 */\n\nextern void abort ();\n\n#define T(type, name) \\\n__attribute__((pure)) _Complex type\t\t\\\nfoo_##name (int x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  _Complex type r;\t\t\t\t\\\n  __real r = x + 1;\t\t\t\t\\\n  __imag r = x - 1;\t\t\t\t\\\n  return r;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\\\nbar_##name (type *x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  *x = __real foo_##name (5);\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\\\nbaz_##name (type *x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  *x = __imag foo_##name (5);\t\t\t\\\n}\n\ntypedef long double ldouble_t;\ntypedef long long llong;\n\nT (float, float)\nT (double, double)\nT (long double, ldouble_t)\nT (char, char)\nT (short, short)\nT (int, int)\nT (long, long)\nT (long long, llong)\n#undef T\n\nint\nmain (void)\n{\n#define T(type, name) \\\n  {\t\t\t\t\t\t\\\n    type var = 0;\t\t\t\t\\\n    bar_##name (&var);\t\t\t\t\\\n    if (var != 6)\t\t\t\t\\\n      abort ();\t\t\t\t\t\\\n    var = 0;\t\t\t\t\t\\\n    baz_##name (&var);\t\t\t\t\\\n    if (var != 4)\t\t\t\t\\\n      abort ();\t\t\t\t\t\\\n  }\n  T (float, float)\n  T (double, double)\n  T (long double, ldouble_t)\n  T (char, char)\n  T (short, short)\n  T (int, int)\n  T (long, long)\n  T (long long, llong)\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050124-1.c",
    "content": "/* PR rtl-optimization/19579 */\n\nextern void abort (void);\n\nint\nfoo (int i, int j)\n{\n  int k = i + 1;\n\n  if (j)\n    {\n      if (k > 0)\n\tk++;\n      else if (k < 0)\n\tk--;\n    }\n\n  return k;\n}\n\nint\nmain (void)\n{\n  if (foo (-2, 0) != -1)\n    abort ();\n  if (foo (-1, 0) != 0)\n    abort ();\n  if (foo (0, 0) != 1)\n    abort ();\n  if (foo (1, 0) != 2)\n    abort ();\n  if (foo (-2, 1) != -2)\n    abort ();\n  if (foo (-1, 1) != 0)\n    abort ();\n  if (foo (0, 1) != 2)\n    abort ();\n  if (foo (1, 1) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050125-1.c",
    "content": "/* Verify that the CALL sideeffect isn't optimized away.  */\n/* Contributed by Greg Parker  25 Jan 2005  <gparker@apple.com> */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nstruct parse {\n  char *next;\n  char *end;\n  int error;\n};\n\nint seterr(struct parse *p, int err)\n{\n  p->error = err;\n  return 0;\n}\n\nvoid bracket_empty(struct parse *p)\n{\n  if (((p->next < p->end) && (*p->next++) == ']')  ||  seterr(p, 7)) { }\n}\n\nint main(int argc __attribute__((unused)), char **argv __attribute__((unused)))\n{\n  struct parse p;\n  p.next = p.end = (char *)0x12345;\n\n  p.error = 0;\n  bracket_empty(&p);\n  if (p.error != 7)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050131-1.c",
    "content": "/* Verify that we do not lose side effects on a MOD expression.  */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nint\nfoo (int a)\n{\n  int x = 0 % a++;\n  return a;\n}\n\nmain()\n{\n  if (foo (9) != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050203-1.c",
    "content": "/* Reduced testcase extracted from Samba source code.  */\n\n#include <stdlib.h>\n\nstatic void __attribute__((__noinline__))\n     foo (unsigned char *p) {\n  *p = 0x81;\n}\n\nstatic void __attribute__((__noinline__))\n     bar (int x) {\n  asm (\"\");\n}\n\nint main() {\n  unsigned char b;\n\n  foo(&b);\n  if (b & 0x80)\n    {\n      bar (b & 0x7f);\n      exit (0);\n    }\n  else\n    {\n      bar (b & 1);\n      abort ();\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050215-1.c",
    "content": "/* PR middle-end/19857 */\n\ntypedef struct { char c[8]; } V\n#ifdef __ELF__\n  __attribute__ ((aligned (8)))\n#endif\n  ;\ntypedef __SIZE_TYPE__ size_t;\nV v;\nvoid abort (void);\n\nint\nmain (void)\n{\n  V *w = &v;\n  if (((size_t) ((float *) ((size_t) w & ~(size_t) 3)) % 8) != 0\n      || ((size_t) w & 1))\n    {\n#ifndef __ELF__\n      if (((size_t) &v & 7) == 0)\n#endif\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050218-1.c",
    "content": "/* PR tree-optimization/19828 */\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *s);\nextern int strncmp (const char *s1, const char *s2, size_t n);\nextern void abort (void);\n\nconst char *a[16] = { \"a\", \"bc\", \"de\", \"fgh\" };\n\nint\nfoo (char *x, const char *y, size_t n)\n{\n  size_t i, j = 0;\n  for (i = 0; i < n; i++)\n    {\n      if (strncmp (x + j, a[i], strlen (a[i])) != 0)\n        return 2;\n      j += strlen (a[i]);\n      if (y)\n        j += strlen (y);\n    }\n  return 0;\n}\n\nint\nmain (void)\n{\n  if (foo (\"abcde\", (const char *) 0, 3) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050224-1.c",
    "content": "/* Origin: Mikael Pettersson <mikpe@csd.uu.se> and the Linux kernel.  */\n\nextern void abort (void);\nunsigned long a = 0xc0000000, b = 0xd0000000;\nunsigned long c = 0xc01bb958, d = 0xc0264000;\nunsigned long e = 0xc0288000, f = 0xc02d4378;\n\nvoid\nfoo (int x, int y, int z)\n{\n  if (x != 245 || y != 36 || z != 444)\n    abort ();\n}\n\nint\nmain (void)\n{\n  unsigned long g;\n  int h = 0, i = 0, j = 0;\n\n  if (sizeof (unsigned long) < 4)\n    return 0;\n\n  for (g = a; g < b; g += 0x1000)\n    if (g < c)\n      h++;\n    else if (g >= d && g < e)\n      j++;\n    else if (g < f)\n      i++;\n  foo (i, j, h);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050316-1.c",
    "content": "/* PR rtl-optimization/16104 */\n/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-Wno-psabi\" } */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nint\ntest1 (void)\n{\n  return (long long) (V2SI) 0LL;\n}\n\nint\ntest2 (V2SI x)\n{\n  return (long long) x;\n}\n\nV2SI\ntest3 (void)\n{\n  return (V2SI) (long long) (int) (V2HI) 0;\n}\n\nV2SI\ntest4 (V2HI x)\n{\n  return (V2SI) (long long) (int) x;\n}\n\nV2SI\ntest5 (V2USI x)\n{\n  return (V2SI) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  if (test1 () != 0)\n    abort ();\n\n  V2SI x = { 2, 2 };\n  if (test2 (x) != 2)\n    abort ();\n\n  union { V2SI x; int y[2]; V2USI z; long long l; } u;\n  u.x = test3 ();\n  if (u.y[0] != 0 || u.y[1] != 0)\n    abort ();\n\n  V2HI y = { 4, 4 };\n  union { V2SI x; long long y; } v;\n  v.x = test4 (y);\n  if (v.y != 0x40004)\n    abort ();\n\n  V2USI z = { 6, 6 };\n  u.x = test5 (z);\n  if (u.y[0] != 6 || u.y[1] != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050316-2.c",
    "content": "/* This testcase generates MMX instructions together with x87 instructions.\n   Currently, there is no \"emms\" generated to switch between register sets,\n   so the testcase fails for targets where MMX insns are enabled.  */\n/* { dg-options \"-mno-mmx -Wno-psabi\" { target { x86_64-*-* i?86-*-* } } } */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef float V2SF __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nlong long\ntest1 (V2SF x)\n{\n  return (long long) (V2SI) x;\n}\n\nlong long\ntest2 (V2SF x)\n{\n  return (long long) x;\n}\n\nlong long\ntest3 (V2SI x)\n{\n  return (long long) (V2SF) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  V2SF x = { 2.0, 2.0 };\n  union { long long l; float f[2]; int i[2]; } u;\n  u.l = test1 (x);\n  if (u.f[0] != 2.0 || u.f[1] != 2.0)\n    abort ();\n\n  V2SF y = { 6.0, 6.0 };\n  u.l = test2 (y);\n  if (u.f[0] != 6.0 || u.f[1] != 6.0)\n    abort ();\n\n  V2SI z = { 4, 4 };\n  u.l = test3 (z);\n  if (u.i[0] != 4 || u.i[1] != 4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050316-3.c",
    "content": "/* { dg-options \"-Wno-psabi\" } */\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nV2USI\ntest1 (V2SI x)\n{\n  return (V2USI) (V2SI) (long long) x;\n}\n\nlong long\ntest2 (V2SI x)\n{\n  return (long long) (V2USI) (V2SI) (long long) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  union { V2SI x; int y[2]; V2USI z; long long l; } u;\n  V2SI a = { -3, -3 };\n  u.z = test1 (a);\n  if (u.y[0] != -3 || u.y[1] != -3)\n    abort ();\n\n  u.l = test2 (a);\n  if (u.y[0] != -3 || u.y[1] != -3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050410-1.c",
    "content": "int s = 200;\nint __attribute__((noinline))\nfoo (void)\n{\n  return (signed char) (s - 100) - 5;\n}\nint\nmain (void)\n{\n  if (foo () != 95)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050502-1.c",
    "content": "/* PR rtl-optimization/21330 */\n\nextern void abort (void);\nextern int strcmp (const char *, const char *);\n\nint\n__attribute__((noinline))\nbar (const char **x)\n{\n  return *(*x)++;\n}\n\nint\n__attribute__((noinline))\nbaz (int c)\n{\n  return c != '@';\n}\n\nvoid\n__attribute__((noinline))\nfoo (const char **w, char *x, _Bool y, _Bool z)\n{\n  char c = bar (w);\n  int i = 0;\n\n  while (1)\n    {\n      x[i++] = c;\n      c = bar (w);\n      if (y && c == '\\'')\n        break;\n      if (z && c == '\\\"')\n        break;\n      if (!y && !z && !baz (c))\n        break;\n    }\n   x[i] = 0;\n}\n\nint\nmain (void)\n{\n  char buf[64];\n  const char *p;\n  p = \"abcde'fgh\";\n  foo (&p, buf, 1, 0);\n  if (strcmp (p, \"fgh\") != 0 || strcmp (buf, \"abcde\") != 0)\n    abort ();\n  p = \"ABCDEFG\\\"HI\";\n  foo (&p, buf, 0, 1);\n  if (strcmp (p, \"HI\") != 0 || strcmp (buf, \"ABCDEFG\") != 0)\n    abort ();\n  p = \"abcd\\\"e'fgh\";\n  foo (&p, buf, 1, 1);\n  if (strcmp (p, \"e'fgh\") != 0 || strcmp (buf, \"abcd\") != 0)\n    abort ();\n  p = \"ABCDEF'G\\\"HI\";\n  foo (&p, buf, 1, 1);\n  if (strcmp (p, \"G\\\"HI\") != 0 || strcmp (buf, \"ABCDEF\") != 0)\n    abort ();\n  p = \"abcdef@gh\";\n  foo (&p, buf, 0, 0);\n  if (strcmp (p, \"gh\") != 0 || strcmp (buf, \"abcdef\") != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050502-2.c",
    "content": "/* PR target/21297 */\ntypedef __SIZE_TYPE__ size_t;\nextern int memcmp (const char *, const char *, size_t);\nextern void abort ();\n\nvoid\nfoo (char *x)\n{\n  int i;\n  for (i = 0; i < 2; i++);\n  x[i + i] = '\\0';\n}\n\nvoid\nbar (char *x)\n{\n  int i;\n  for (i = 0; i < 2; i++);\n  x[i + i + i + i] = '\\0';\n}\n\nint\nmain (void)\n{\n  char x[] = \"IJKLMNOPQR\";\n  foo (x);\n  if (memcmp (x, \"IJKL\\0NOPQR\", sizeof x) != 0)\n    abort ();\n  x[4] = 'M';\n  bar (x);\n  if (memcmp (x, \"IJKLMNOP\\0R\", sizeof x) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050604-1.c",
    "content": "/* PR regression/21897 */\n/* This testcase generates MMX instructions together with x87 instructions.\n   Currently, there is no \"emms\" generated to switch between register sets,\n   so the testcase fails for targets where MMX insns are enabled.  */\n/* { dg-options \"-mno-mmx\" { target { x86_64-*-* i?86-*-* } } } */\n\nextern void abort (void);\n\ntypedef short v4hi __attribute__ ((vector_size (8)));\ntypedef float v4sf __attribute__ ((vector_size (16)));\n\nunion\n{\n  v4hi v;\n  short s[4];\n} u;\n\nunion\n{\n  v4sf v;\n  float f[4];\n} v;\n\nvoid\nfoo (void)\n{\n  unsigned int i;\n  for (i = 0; i < 2; i++)\n    u.v += (v4hi) { 12, 14 };\n  for (i = 0; i < 2; i++)\n    v.v += (v4sf) { 18.0, 20.0, 22 };\n}\n\nint\nmain (void)\n{\n  foo ();\n  if (u.s[0] != 24 || u.s[1] != 28 || u.s[2] || u.s[3])\n    abort ();\n  if (v.f[0] != 36.0 || v.f[1] != 40.0 || v.f[2] != 44.0 || v.f[3] != 0.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050607-1.c",
    "content": "/* PR middle-end/21850 */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\n\nint\nmain (void)\n{\n#if (__INT_MAX__ == 2147483647) \\\n    && (__LONG_LONG_MAX__ == 9223372036854775807LL)\n  if (((int)(long long)(V2SI){ 2, 2 }) != 2)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050613-1.c",
    "content": "/* PR tree-optimization/22043 */\n\nextern void abort (void);\n\nstruct A { int i; int j; int k; int l; };\nstruct B { struct A a; int r[1]; };\nstruct C { struct A a; int r[0]; };\nstruct D { struct A a; int r[]; };\n\nvoid\nfoo (struct A *x)\n{\n  if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0)\n    abort ();\n}\n\nint\nmain ()\n{\n  struct B b = { .a.j = 5 };\n  struct C c = { .a.j = 5 };\n  struct D d = { .a.j = 5 };\n  foo (&b.a);\n  foo (&c.a);\n  foo (&d.a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050713-1.c",
    "content": "/* Test that sibling call is not used if there is an argument overlap.  */\n\nextern void abort (void);\n\nstruct S\n{\n  int a, b, c;\n};\n\nint\nfoo2 (struct S x, struct S y)\n{\n  if (x.a != 3 || x.b != 4 || x.c != 5)\n    abort ();\n  if (y.a != 6 || y.b != 7 || y.c != 8)\n    abort ();\n  return 0;\n}\n\nint\nfoo3 (struct S x, struct S y, struct S z)\n{\n  foo2 (x, y);\n  if (z.a != 9 || z.b != 10 || z.c != 11)\n    abort ();\n  return 0;\n}\n\nint\nbar2 (struct S x, struct S y)\n{\n  return foo2 (y, x);\n}\n\nint\nbar3 (struct S x, struct S y, struct S z)\n{\n  return foo3 (y, x, z);\n}\n\nint\nbaz3 (struct S x, struct S y, struct S z)\n{\n  return foo3 (y, z, x);\n}\n\nint\nmain (void)\n{\n  struct S a = { 3, 4, 5 }, b = { 6, 7, 8 }, c = { 9, 10, 11 };\n\n  bar2 (b, a);\n  bar3 (b, a, c);\n  baz3 (c, a, b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050826-1.c",
    "content": "/* PR rtl-optimization/23561 */\n\nstruct A\n{\n  char a1[1];\n  char a2[5];\n  char a3[1];\n  char a4[2048 - 7];\n} a;\n\ntypedef __SIZE_TYPE__ size_t;\nextern void *memset (void *, int, size_t);\nextern void *memcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern void abort (void);\n\nvoid\nbar (struct A *x)\n{\n  size_t i;\n  if (memcmp (x, \"\\1HELLO\\1\", sizeof \"\\1HELLO\\1\"))\n    abort ();\n  for (i = 0; i < sizeof (x->a4); i++)\n    if (x->a4[i])\n      abort ();\n}\n\nint\nfoo (void)\n{\n  memset (&a, 0, sizeof (a));\n  a.a1[0] = 1;\n  memcpy (a.a2, \"HELLO\", sizeof \"HELLO\");\n  a.a3[0] = 1;\n  bar (&a);\n  return 0;\n}\n\nint\nmain (void)\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050826-2.c",
    "content": "/* PR rtl-optimization/23560 */\n\nstruct rtattr\n{\n  unsigned short rta_len;\n  unsigned short rta_type;\n};\n\n__attribute__ ((noinline))\nint inet_check_attr (void *r, struct rtattr **rta)\n{\n  int i;\n\n  for (i = 1; i <= 14; i++)\n    {\n      struct rtattr *attr = rta[i - 1];\n      if (attr)\n\t{\n\t  if (attr->rta_len - sizeof (struct rtattr) < 4)\n\t    return -22;\n\t  if (i != 9 && i != 8)\n\t    rta[i - 1] = attr + 1;\n\t}\n    }\n  return 0;\n}\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  struct rtattr rt[2];\n  struct rtattr *rta[14];\n  int i;\n\n  rt[0].rta_len = sizeof (struct rtattr) + 8;\n  rt[0].rta_type = 0;\n  rt[1] = rt[0];\n  for (i = 0; i < 14; i++)\n    rta[i] = &rt[0];\n  if (inet_check_attr (0, rta) != 0)\n    abort ();\n  for (i = 0; i < 14; i++)\n    if (rta[i] != &rt[i != 7 && i != 8])\n      abort ();\n  for (i = 0; i < 14; i++)\n    rta[i] = &rt[0];\n  rta[1] = 0;\n  rt[1].rta_len -= 8;\n  rta[5] = &rt[1];\n  if (inet_check_attr (0, rta) != -22)\n    abort ();\n  for (i = 0; i < 14; i++)\n    if (i == 1 && rta[i] != 0)\n      abort ();\n    else if (i != 1 && i <= 5 && rta[i] != &rt[1])\n      abort ();\n    else if (i > 5 && rta[i] != &rt[0])\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20050929-1.c",
    "content": "/* PR middle-end/24109 */\n\nextern void abort (void);\n\nstruct A { int i; int j; };\nstruct B { struct A *a; struct A *b; };\nstruct C { struct B *c; struct A *d; };\nstruct C e = { &(struct B) { &(struct A) { 1, 2 }, &(struct A) { 3, 4 } }, &(struct A) { 5, 6 } };\n\nint\nmain (void)\n{\n  if (e.c->a->i != 1 || e.c->a->j != 2)\n    abort ();\n  if (e.c->b->i != 3 || e.c->b->j != 4)\n    abort ();\n  if (e.d->i != 5 || e.d->j != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051012-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nextern void abort (void);\n\nstruct type \n{\n  int *a;\n  \n  int b:16;\n  unsigned int p:9;\n} t;\n\nunsigned int \nfoo ()\n{\n  return t.p;\n}\n\nint \nmain (void)\n{\n  t.p = 8;\n  if (foo (t) != 8)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051021-1.c",
    "content": "/* Verify that TRUTH_AND_EXPR is not wrongly changed to TRUTH_ANDIF_EXPR.  */\n\nextern void abort (void);\n\nint count = 0;\n\nint foo1(void)\n{\n  count++;\n  return 0;\n}\n\nint foo2(void)\n{\n  count++;\n  return 0;\n}\n\nint main(void)\n{\n  if ((foo1() == 1) & (foo2() == 1))\n    abort ();\n\n  if (count != 2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051104-1.c",
    "content": "/* PR rtl-optimization/23567 */\n\nstruct\n{\n  int len;\n  char *name;\n} s;\n\nint\nmain (void)\n{\n  s.len = 0;\n  s.name = \"\";\n  if (s.name [s.len] != 0)\n    s.name [s.len] = 0;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051110-1.c",
    "content": "void add_unwind_adjustsp (long);\nvoid abort (void);\n\nunsigned char bytes[5];\n\nvoid\nadd_unwind_adjustsp (long offset)\n{\n  int n;\n  unsigned long o;\n\n  o = (long) ((offset - 0x204) >> 2);\n\n  n = 0;\n  while (o)\n    {\n      bytes[n] = o & 0x7f;\n      o >>= 7;\n      if (o)\n\tbytes[n] |= 0x80;\n      n++;\n    }\n}\n\nint main(void)\n{\n  add_unwind_adjustsp (4132);\n  if (bytes[0] != 0x88 || bytes[1] != 0x07)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051110-2.c",
    "content": "void add_unwind_adjustsp (long);\nvoid abort (void);\n\nunsigned char bytes[5];\n\nint flag;\n\nvoid\nadd_unwind_adjustsp (long offset)\n{\n  int n;\n  unsigned long o;\n\n  o = (long) ((offset - 0x204) >> 2);\n\n  n = 0;\n  do\n    {\na:\n      bytes[n] = o & 0x7f;\n      o >>= 7;\n      if (o)\n        {\n\t  bytes[n] |= 0x80;\n\t  if (flag)\n\t    goto a;\n\t}\n      n++;\n    }\n  while (o);\n}\n\nint main(void)\n{\n  add_unwind_adjustsp (4132);\n  if (bytes[0] != 0x88 || bytes[1] != 0x07)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051113-1.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\nextern void *memset(void *, int, __SIZE_TYPE__);\ntypedef struct\n{\n  short a;  \n  unsigned short b;\n  unsigned short c;\n  unsigned long long Count;\n  long long Count2;\n} __attribute__((packed)) Struct1;\n\ntypedef struct\n{\n  short a;\n  unsigned short b;\n  unsigned short c;\n  unsigned long long d;\n  long long e;\n  long long f;\n} __attribute__((packed)) Struct2;\n\ntypedef union\n{\n  Struct1 a;\n  Struct2 b;\n} Union;\n\ntypedef struct\n{\n  int Count;\n  Union List[0];\n} __attribute__((packed)) Struct3;\n\nunsigned long long Sum (Struct3 *instrs) __attribute__((noinline));\nunsigned long long Sum (Struct3 *instrs)\n{\n    unsigned long long  count = 0;\n    int     i;\n    \n    for (i = 0; i < instrs->Count; i++) {\n        count += instrs->List[i].a.Count;\n    }\n    return count;\n}\nlong long Sum2 (Struct3 *instrs) __attribute__((noinline));\nlong long Sum2 (Struct3 *instrs)\n{\n    long long  count = 0;\n    int     i;\n    \n    for (i = 0; i < instrs->Count; i++) {\n        count += instrs->List[i].a.Count2;\n    }\n    return count;\n}\nmain() {\n  Struct3 *p = malloc (sizeof (int) + 3 * sizeof(Union));\n  memset(p, 0, sizeof(int) + 3*sizeof(Union));\n  p->Count = 3;\n  p->List[0].a.Count = 555;\n  p->List[1].a.Count = 999;\n  p->List[2].a.Count = 0x101010101ULL;\n  p->List[0].a.Count2 = 555;\n  p->List[1].a.Count2 = 999;\n  p->List[2].a.Count2 = 0x101010101LL;\n  if (Sum(p) != 555 + 999 + 0x101010101ULL)\n    abort();\n  if (Sum2(p) != 555 + 999 + 0x101010101LL)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20051215-1.c",
    "content": "/* PR rtl-optimization/24899 */\n\nextern void abort (void);\n\n__attribute__ ((noinline)) int\nfoo (int x, int y, int *z)\n{\n  int a, b, c, d;\n\n  a = b = 0;\n  for (d = 0; d < y; d++)\n    {\n      if (z)\n\tb = d * *z;\n      for (c = 0; c < x; c++)\n\ta += b;\n    }\n\n  return a;\n}\n\nint\nmain (void)\n{\n  if (foo (3, 2, 0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060102-1.c",
    "content": "extern void abort ();\n\nint f(int x)\n{\n  return (x >> (sizeof (x) * __CHAR_BIT__ - 1)) ? -1 : 1;\n}\n\nvolatile int one = 1;\nint main (void)\n{\n  /* Test that the function above returns different values for\n     different signs.  */\n  if (f(one) == f(-one))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060110-1.c",
    "content": "extern void abort (void);\n\nlong long \nf (long long a) \n{ \n  return (a << 32) >> 32; \n} \nlong long a = 0x1234567876543210LL;\nlong long b = (0x1234567876543210LL << 32) >> 32;\nint\nmain ()\n{\n  if (f (a) != b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060110-2.c",
    "content": "extern void abort (void);\n\nlong long \nf (long long a, long long b) \n{ \n  return ((a + b) << 32) >> 32; \n} \n\nlong long a = 0x1234567876543210LL;\nlong long b = 0x2345678765432101LL;\nlong long c = ((0x1234567876543210LL + 0x2345678765432101LL) << 32) >> 32;\n\nint\nmain ()\n{\n  if (f (a, b) != c)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060127-1.c",
    "content": "void abort ();\n\nvoid\nf (long long a)\n{\n  if ((a & 0xffffffffLL) != 0)\n    abort ();\n}\n\nlong long a = 0x1234567800000000LL;\n\nint\nmain ()\n{\n  f (a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060412-1.c",
    "content": "extern void abort (void);\n\nstruct S\n{\n  long o;\n};\n\nstruct T\n{\n  long o;\n  struct S m[82];\n};\n\nstruct T t;\n\nint\nmain ()\n{\n  struct S *p, *q;\n\n  p = (struct S *) &t;\n  p = &((struct T *) p)->m[0];\n  q = p + 82;\n  while (--q > p)\n    q->o = -1;\n  q->o = 0;\n\n  if (q > p)\n    abort ();\n  if (q - p > 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060420-1.c",
    "content": "extern void abort (void);\n\ntypedef float v4flt __attribute__ ((vector_size (16)));\n\nvoid __attribute__ ((noinline)) foo (float *dst, float **src, int a, int n)\n{\n  int i, j;\n  int z = sizeof (v4flt) / sizeof (float);\n  unsigned m = sizeof (v4flt) - 1;\n\n  for (j = 0; j < n && (((unsigned long) dst + j) & m); ++j)\n    {\n      float t = src[0][j];\n      for (i = 1; i < a; ++i)\n\tt += src[i][j];\n      dst[j] = t;\n    }\n\n  for (; j < (n - (4 * z - 1)); j += 4 * z)\n    {\n      v4flt t0 = *(v4flt *) (src[0] + j + 0 * z);\n      v4flt t1 = *(v4flt *) (src[0] + j + 1 * z);\n      v4flt t2 = *(v4flt *) (src[0] + j + 2 * z);\n      v4flt t3 = *(v4flt *) (src[0] + j + 3 * z);\n      for (i = 1; i < a; ++i)\n\t{\n\t  t0 += *(v4flt *) (src[i] + j + 0 * z);\n\t  t1 += *(v4flt *) (src[i] + j + 1 * z);\n\t  t2 += *(v4flt *) (src[i] + j + 2 * z);\n\t  t3 += *(v4flt *) (src[i] + j + 3 * z);\n\t}\n      *(v4flt *) (dst + j + 0 * z) = t0;\n      *(v4flt *) (dst + j + 1 * z) = t1;\n      *(v4flt *) (dst + j + 2 * z) = t2;\n      *(v4flt *) (dst + j + 3 * z) = t3;\n    }\n  for (; j < n; ++j)\n    {\n      float t = src[0][j];\n      for (i = 1; i < a; ++i)\n\tt += src[i][j];\n      dst[j] = t;\n    }\n}\n\nfloat buffer[64];\n\nint\nmain (void)\n{\n  int i;\n  float *dst, *src[2];\n  char *cptr;\n\n  cptr = (char *)buffer;\n  cptr += (-(long int) buffer & (16 * sizeof (float) - 1));\n  dst = (float *)cptr;\n  src[0] = dst + 16;\n  src[1] = dst + 32;\n  for (i = 0; i < 16; ++i)\n    {\n      src[0][i] = (float) i + 11 * (float) i;\n      src[1][i] = (float) i + 12 * (float) i;\n    }\n  foo (dst, src, 2, 16);\n  for (i = 0; i < 16; ++i)\n    {\n      float e = (float) i + 11 * (float) i + (float) i + 12 * (float) i;\n      if (dst[i] != e)\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060905-1.c",
    "content": "/* PR rtl-optimization/28386 */\n/* Origin: Volker Reichelt <reichelt@gcc.gnu.org> */\n\nextern void abort(void);\n\nvolatile char s[256][3];\n\nchar g;\n\nstatic void dummy(char a)\n{\n  g = a;\n}\n\nstatic int foo(void)\n{\n  int i, j=0;\n\n  for (i = 0; i < 256; i++)\n    if (i >= 128 && i < 256)\n      {\n\tdummy (s[i - 128][0]);\n\t++j;\n      }\n\n  return j;\n}\n\nint main(void)\n{\n  if (foo () != 128)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060910-1.c",
    "content": "/* PR rtl-optimization/28636 */\n/* Origin: Andreas Schwab <schwab@suse.de> */\n\nextern void abort(void);\n\nstruct input_ty\n{\n  unsigned char *buffer_position;\n  unsigned char *buffer_end;\n};\n\nint input_getc_complicated (struct input_ty *x) { return 0; }\n\nint check_header (struct input_ty *deeper)\n{\n  unsigned len;\n  for (len = 0; len < 6; len++)\n    if (((deeper)->buffer_position < (deeper)->buffer_end\n         ? *((deeper)->buffer_position)++\n         : input_getc_complicated((deeper))) < 0)\n      return 0;\n  return 1;\n}\n\nstruct input_ty s;\nunsigned char b[6];\n\nint main (void)\n{\n  s.buffer_position = b;\n  s.buffer_end = b + sizeof b;\n  if (!check_header(&s))\n    abort();\n  if (s.buffer_position != s.buffer_end)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060929-1.c",
    "content": "/* PR c/29154 */\n\nextern void abort (void);\n\nvoid\nfoo (int **p, int *q)\n{\n  *(*p++)++ = *q++;\n}\n\nvoid\nbar (int **p, int *q)\n{\n  **p = *q++;\n  *(*p++)++;\n}\n\nvoid\nbaz (int **p, int *q)\n{\n  **p = *q++;\n  (*p++)++;\n}\n\nint\nmain (void)\n{\n  int i = 42, j = 0;\n  int *p = &i;\n  foo (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  i = 43;\n  p = &i;\n  bar (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  i = 44;\n  p = &i;\n  baz (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060930-1.c",
    "content": "/* PR rtl-optimization/28096 */\n/* Origin: Jan Stein <jan@gatespacetelematics.com> */\n\nextern void abort (void);\n\nint bar (int, int) __attribute__((noinline));\nint bar (int a, int b)\n{\n  if (b != 1)\n    abort ();\n}\n\nvoid foo(int, int) __attribute__((noinline));\nvoid foo (int e, int n)\n{\n  int i, bb2, bb5;\n\n  if (e > 0)\n    e = -e;\n\n  for (i = 0; i < n; i++)\n    {\n      if (e >= 0)\n\t{\n\t  bb2 = 0;\n\t  bb5 = 0;\n\t}\n      else\n\t{\n\t  bb5 = -e;\n\t  bb2 = bb5;\n\t}\n\n      bar (bb5, bb2);\n    }\n}\n\nint main(void)\n{\n  foo (1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20060930-2.c",
    "content": "/* PR middle-end/29272 */\n\nextern void abort (void);\n\nstruct S { struct S *s; } s;\nstruct T { struct T *t; } t;\n\nstatic inline void\nfoo (void *s)\n{\n  struct T *p = s;\n  __builtin_memcpy (&p->t, &t.t, sizeof (t.t));\n}\n\nvoid *\n__attribute__((noinline))\nbar (void *p, struct S *q)\n{\n  q->s = &s;\n  foo (p);\n  return q->s;\n}\n\nint\nmain (void)\n{\n  t.t = &t;\n  if (bar (&s, &s) != (void *) &t)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20061031-1.c",
    "content": "/* PR rtl-optimization/29631 */\n/* Origin: Falk Hueffner <falk@debian.org> */\n\nconst signed char nunmap[] = { 17, -1, 1 };\n\n__attribute__((noinline))\nvoid ff(int i) {\n    asm volatile(\"\");\n}\n\n__attribute__((noinline))\nvoid f(short delta)\n{\n    short p0 = 2, s;\n    for (s = 0; s < 2; s++)\n    {\n        p0 += delta;\n        ff(s);\n        if (nunmap[p0] == 17)\n            asm volatile(\"\");\n    }\n}\n\nint main(void)\n{\n    f(-1);\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20061101-1.c",
    "content": "/* PR rtl-optimization/28970 */\n/* Origin: Peter Bergner <bergner@vnet.ibm.com> */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nint tar (int i)\n{\n  if (i != 36863)\n    abort ();\n\n  return -1;\n}\n\nvoid bug(int q, int bcount)\n{\n  int j = 0;\n  int outgo = 0;\n\n  while(j != -1)\n    {\n      outgo++;\n      if (outgo > q-1)\n        outgo = q-1;\n      j = tar (outgo*bcount);\n    }\n}\n\nint main(void)\n{\n  bug(5, 36863);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20061101-2.c",
    "content": "/* PR rtl-optimization/28970 */\n/* Origin: Peter Bergner <bergner@vnet.ibm.com> */\n\nextern void abort (void);\n\nint tar (long i)\n{\n  if (i != 36863)\n    abort ();\n\n  return -1;\n}\n\nvoid bug(int q, long bcount)\n{\n  int j = 0;\n  int outgo = 0;\n\n  while(j != -1)\n    {\n      outgo++;\n      if (outgo > q-1)\n        outgo = q-1;\n      j = tar (outgo*bcount);\n    }\n}\n\nint main(void)\n{\n  bug(5, 36863);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20061220-1.c",
    "content": "/* PR middle-end/30262 */\n/* { dg-skip-if \"asm statements do not work as expected\" { rl78-*-* } \"*\" \"\" } */\nextern void abort (void);\n\nint\nfoo (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    x = 254;\n  }\n\n  nested ();\n  asm volatile (\"\" :: \"r\" (x));\n  asm volatile (\"\" :: \"m\" (x));\n  asm volatile (\"\" :: \"mr\" (x));\n  asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n  asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n  return x;\n}\n\nint\nbar (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    asm volatile (\"\" :: \"r\" (x));\n    asm volatile (\"\" :: \"m\" (x));\n    asm volatile (\"\" :: \"mr\" (x));\n    x += 4;\n    asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n    asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n  }\n\n  nested ();\n  return x;\n}\n\nint\nbaz (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    void nested2 (void)\n    {\n      asm volatile (\"\" :: \"r\" (x));\n      asm volatile (\"\" :: \"m\" (x));\n      asm volatile (\"\" :: \"mr\" (x));\n      x += 4;\n      asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n      asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n    }\n    nested2 ();\n    nested2 ();\n  }\n\n  nested ();\n  return x;\n}\n\nint\nmain (void)\n{\n  if (foo () != 254 || bar () != 4 || baz () != 8)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070201-1.c",
    "content": "/* PR middle-end/30473 */\n\nextern int sprintf (char *, const char *, ...);\nextern void abort (void);\n\nchar *\nfoo (char *buf, char *p)\n{\n  sprintf (buf, \"abcde\", p++);\n  return p;\n}\n\nint\nmain (void)\n{\n  char buf[6];\n  if (foo (buf, &buf[2]) != &buf[3])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070212-1.c",
    "content": "struct f\n{\n  int i;\n};\n\nint g(int i, int c, struct f *ff, int *p)\n{\n  int *t;\n  if (c)\n   t = &i;\n  else\n   t = &ff->i;\n  *p = 0;\n  return *t;\n}\n\nextern void abort(void);\n\nint main()\n{\n  struct f f;\n  f.i = 1;\n  if (g(5, 0, &f, &f.i) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070212-2.c",
    "content": "int f(int k, int i1, int j1)\n{\n  int *f1;\n  if(k)\n   f1 = &i1;\n  else\n   f1 = &j1;\n  i1 = 0;\n  return *f1;\n}\n\nextern void abort (void);\n\nint main()\n{\n  if (f(1, 1, 2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070212-3.c",
    "content": "struct foo { int i; int j; };\n\nint bar (struct foo *k, int k2, int f, int f2)\n{\n  int *p, *q;\n  int res;\n  if (f)\n    p = &k->i;\n  else\n    p = &k->j;\n  res = *p;\n  k->i = 1;\n  if (f2)\n    q = p;\n  else\n    q = &k2;\n  return res + *q;\n}\n\nextern void abort (void);\n\nint main()\n{\n  struct foo k;\n  k.i = 0;\n  k.j = 1;\n  if (bar (&k, 1, 1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070424-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid do_exit (void) { exit (0); }\nvoid do_abort (void) { abort (); }\n\nvoid foo (int x, int a)\n{\n  if (x < a)\n    goto doit;\n  do_exit ();\n  if (x != a)\n    goto doit;\n\n  /* else */\n  do_abort ();\n  return;\n\ndoit:\n  do_abort ();\n}\n\nint main()\n{\n  foo (1, 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070517-1.c",
    "content": "/* PR rtl-optimization/31691 */\n/* Origin: Chi-Hua Chen <stephaniechc-gccbug@yahoo.com> */\n\nextern void abort (void);\n\nstatic int get_kind(int) __attribute__ ((noinline));\n\nstatic int get_kind(int v)\n{\n  volatile int k = v;\n  return k;\n}\n\nstatic int some_call(void) __attribute__ ((noinline));\n\nstatic int some_call(void)\n{\n  return 0;\n}\n\nstatic void example (int arg)\n{\n  int tmp, kind = get_kind (arg);\n\n  if (kind == 9 || kind == 10 || kind == 5)\n    {\n      if (some_call() == 0)\n        {\n          if (kind == 9 || kind == 10)\n            tmp = arg;\n          else\n            abort();\n        }\n    }\n} \n\nint main(void)\n{\n  example(10);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070614-1.c",
    "content": "extern void abort (void);\n\n_Complex v = 3.0 + 1.0iF;\n\nvoid\nfoo (_Complex z, int *x)\n{\n  if (z != v)\n    abort ();\n}\n\n_Complex bar (_Complex z) __attribute__ ((pure));\n_Complex\nbar (_Complex z)\n{\n  return v;\n}\n\nint\nbaz (void)\n{\n  int a, i;\n  for (i = 0; i < 6; i++)\n    foo (bar (1.0iF * i), &a);\n  return 0;\n}\n\nint\nmain ()\n{\n  baz ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070623-1.c",
    "content": "#include <limits.h>\n\nint __attribute__((noinline)) nge(int a, int b) {return -(a >= b);}\nint __attribute__((noinline)) ngt(int a, int b) {return -(a > b);}\nint __attribute__((noinline)) nle(int a, int b) {return -(a <= b);}\nint __attribute__((noinline)) nlt(int a, int b) {return -(a < b);}\nint __attribute__((noinline)) neq(int a, int b) {return -(a == b);}\nint __attribute__((noinline)) nne(int a, int b) {return -(a != b);}\nint __attribute__((noinline)) ngeu(unsigned a, unsigned b) {return -(a >= b);}\nint __attribute__((noinline)) ngtu(unsigned a, unsigned b) {return -(a > b);}\nint __attribute__((noinline)) nleu(unsigned a, unsigned b) {return -(a <= b);}\nint __attribute__((noinline)) nltu(unsigned a, unsigned b) {return -(a < b);}\n\n\nint main()\n{\n  if (nge(INT_MIN, INT_MAX) !=  0) abort();\n  if (nge(INT_MAX, INT_MIN) != -1) abort();\n  if (ngt(INT_MIN, INT_MAX) !=  0) abort();\n  if (ngt(INT_MAX, INT_MIN) != -1) abort();\n  if (nle(INT_MIN, INT_MAX) != -1) abort();\n  if (nle(INT_MAX, INT_MIN) !=  0) abort();\n  if (nlt(INT_MIN, INT_MAX) != -1) abort();\n  if (nlt(INT_MAX, INT_MIN) !=  0) abort();\n\n  if (neq(INT_MIN, INT_MAX) !=  0) abort();\n  if (neq(INT_MAX, INT_MIN) !=  0) abort();\n  if (nne(INT_MIN, INT_MAX) != -1) abort();\n  if (nne(INT_MAX, INT_MIN) != -1) abort();\n\n  if (ngeu(0, ~0U) !=  0) abort();\n  if (ngeu(~0U, 0) != -1) abort();\n  if (ngtu(0, ~0U) !=  0) abort();\n  if (ngtu(~0U, 0) != -1) abort();\n  if (nleu(0, ~0U) != -1) abort();\n  if (nleu(~0U, 0) !=  0) abort();\n  if (nltu(0, ~0U) != -1) abort();\n  if (nltu(~0U, 0) !=  0) abort();\n  \n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070724-1.c",
    "content": "void abort (void);\n\nstatic unsigned char magic[] = \"\\235\";\nstatic unsigned char value = '\\235';\n\nint main()\n{\n  if (value != magic[0])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070824-1.c",
    "content": "/* PR tree-optimization/33136 */\n/* { dg-require-effective-target alloca } */\n\nextern void abort (void);\n\nstruct S\n{\n  struct S *a;\n  int b;\n};\n\nint\nmain (void)\n{\n  struct S *s = (struct S *) 0, **p, *n;\n  for (p = &s; *p; p = &(*p)->a);\n  n = (struct S *) __builtin_alloca (sizeof (*n));\n  n->a = *p;\n  n->b = 1;\n  *p = n;\n\n  if (!s)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20070919-1.c",
    "content": "/* PR c/33238 */\n/* { dg-require-effective-target alloca } */\n\ntypedef __SIZE_TYPE__ size_t;\nint memcmp (const void *, const void *, size_t);\nvoid abort (void);\n\nvoid\n__attribute__((noinline))\nbar (void *x, void *y)\n{\n  struct S { char w[8]; } *p = x, *q = y;\n  if (memcmp (p->w, \"zyxwvut\", 8) != 0)\n    abort ();\n  if (memcmp (q[0].w, \"abcdefg\", 8) != 0)\n    abort ();\n  if (memcmp (q[1].w, \"ABCDEFG\", 8) != 0)\n    abort ();\n  if (memcmp (q[2].w, \"zyxwvut\", 8) != 0)\n    abort ();\n  if (memcmp (q[3].w, \"zyxwvut\", 8) != 0)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\nfoo (void *x, int y)\n{\n  struct S { char w[y]; } *p = x, a;\n  int i;\n  a = ({ struct S b; b = p[2]; p[3] = b; });\n  bar (&a, x);\n}\n\nint\nmain (void)\n{\n  struct S { char w[8]; } p[4]\n    = { \"abcdefg\", \"ABCDEFG\", \"zyxwvut\", \"ZYXWVUT\" };\n  foo (p, 8);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071011-1.c",
    "content": "extern void abort(void);\nvoid foo(int *p)\n{\n  int x;\n  int y;\n  x = *p;\n  *p = 0;\n  y = *p;\n  if (x != y)\n    return;\n  abort ();\n}\n\nint main()\n{\n  int a = 1;\n  foo(&a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071018-1.c",
    "content": "extern void abort(void);\n\nstruct foo {\n  int rank;\n  char *name;\n};\n\nstruct mem {\n  struct foo *x[4];\n};\n\nvoid __attribute__((noinline)) bar(struct foo **f)\n{\n  *f = __builtin_malloc(sizeof(struct foo));\n}\nstruct foo * __attribute__((noinline, noclone)) foo(int rank)\n{\n  void *x = __builtin_malloc(sizeof(struct mem));\n  struct mem *as = x;\n  struct foo **upper = &as->x[rank * 8 - 5];\n  *upper = 0;\n  bar(upper);\n  return *upper;\n}\n\nint main()\n{\n  if (foo(1) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071029-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\ntypedef union\n{\n  struct\n  {\n    int f1, f2, f3, f4, f5, f6, f7, f8;\n    long int f9, f10;\n    int f11;\n  } f;\n  char s[56];\n  long int a;\n} T;\n\n__attribute__((noinline))\nvoid\ntest (T *t)\n{\n  static int i = 11;\n  if (t->f.f1 != i++)\n    abort ();\n  if (t->f.f2 || t->f.f3 || t->f.f4 || t->f.f5 || t->f.f6\n      || t->f.f7 || t->f.f8 || t->f.f9 || t->f.f10 || t->f.f11)\n    abort ();\n  if (i == 20)\n    exit (0);\n}\n\n__attribute__((noinline))\nvoid\nfoo (int i)\n{\n  T t;\nagain:\n  t = (T) { { ++i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };\n  test (&t);\n  goto again;\n}\n\nint\nmain (void)\n{\n  T *t1, *t2;\n  int cnt = 0;\n  t1 = (T *) 0;\nloop:\n  t2 = t1;\n  t1 = & (T) { .f.f9 = cnt++ };\n  if (cnt < 3)\n    goto loop;\n  if (t1 != t2 || t1->f.f9 != 2)\n    abort ();\n  foo (10);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071030-1.c",
    "content": "/* PR target/11044 */\n/* Originator: Tim McGrath <misty-@charter.net> */\n/* Testcase contributed by Eric Botcazou <ebotcazou@libertysurf.fr> */\n\n/* Testcase copied from gcc.target/i386/loop-3.c */\n\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern void abort (void);\n\ntypedef struct\n{\n        unsigned char colormod;\n} entity_state_t;\n\ntypedef struct\n{\n        int num_entities;\n        entity_state_t *entities;\n} packet_entities_t;\n\ntypedef struct\n{\n        double senttime;\n        float ping_time;\n        packet_entities_t entities;\n} client_frame_t;\n\ntypedef enum\n{\n        cs_free,\n        cs_server,\n        cs_zombie,\n        cs_connected,\n        cs_spawned\n} sv_client_state_t;\n\ntypedef struct client_s\n{\n        sv_client_state_t state;\n        int ping;\n        client_frame_t frames[64];\n} client_t;\n\nint CalcPing (client_t *cl)\n{\n        float ping;\n        int count, i;\n        register client_frame_t *frame;\n\n        if (cl->state == cs_server)\n                return cl->ping;\n        ping = 0;\n        count = 0;\n        for (frame = cl->frames, i = 0; i < 64; i++, frame++) {\n                if (frame->ping_time > 0) {\n                        ping += frame->ping_time;\n                        count++;\n                }\n        }\n        if (!count)\n                return 9999;\n        ping /= count;\n\n        return ping * 1000;\n}\n\nint main(void)\n{\n   client_t cl;\n\n   memset(&cl, 0, sizeof(cl));\n\n   cl.frames[0].ping_time = 1.0f;\n\n   if (CalcPing(&cl) != 1000)\n     abort();\n\n   return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071108-1.c",
    "content": "/* PR tree-optimization/32575 */\n\nextern void abort (void);\n\nstruct S\n{\n  void *s1, *s2;\n  unsigned char s3, s4, s5;\n};\n\n__attribute__ ((noinline))\nvoid *\nfoo (void)\n{\n  static struct S s;\n  return &s;\n}\n\n__attribute__ ((noinline))\nvoid *\nbar ()\n{\n  return (void *) 0;\n}\n\n__attribute__ ((noinline))\nstruct S *\ntest (void *a, void *b)\n{\n  struct S *p, q;\n  p = foo ();\n  if (p == 0)\n    {\n      p = &q;\n      __builtin_memset (p, 0, sizeof (*p));\n    }\n  p->s1 = a;\n  p->s2 = b;\n  if (p == &q)\n    p = 0;\n  return p;\n}\n\nint\nmain (void)\n{\n  int a;\n  int b;\n  struct S *z = test ((void *) &a, (void *) &b);\n  if (z == 0 || z->s1 != (void *) &a || z->s2 != (void *) &b || z->s3 || z->s4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071120-1.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline,noreturn))\nvec_assert_fail (void)\n{\n    abort ();\n}\n\nstruct ggc_root_tab {\n    void *base;\n};\n\ntypedef struct deferred_access_check {} VEC_deferred_access_check_gc;\n\ntypedef struct deferred_access {\n    VEC_deferred_access_check_gc* deferred_access_checks;\n    int deferring_access_checks_kind;\n} deferred_access;\n\ntypedef struct VEC_deferred_access_base {\n    unsigned num;\n    deferred_access vec[1];\n} VEC_deferred_access_base;\n\nstatic __inline__ deferred_access *\nVEC_deferred_access_base_last (VEC_deferred_access_base *vec_)\n{\n    (void)((vec_ && vec_->num) ? 0 : (vec_assert_fail (), 0));\n    return &vec_->vec[vec_->num - 1];\n}\n\nstatic __inline__  void\nVEC_deferred_access_base_pop (VEC_deferred_access_base *vec_)\n{\n    (void)((vec_->num) ? 0 : (vec_assert_fail (), 0));\n    --vec_->num;\n}\n\nvoid __attribute__((noinline))\nperform_access_checks (VEC_deferred_access_check_gc* p)\n{\n    abort ();\n}\n\ntypedef struct VEC_deferred_access_gc {\n    VEC_deferred_access_base base;\n} VEC_deferred_access_gc;\n\nstatic VEC_deferred_access_gc *deferred_access_stack;\nstatic unsigned deferred_access_no_check;\n\nconst struct ggc_root_tab gt_pch_rs_gt_cp_semantics_h[] = {\n    {\n\t&deferred_access_no_check\n    }\n};\n\nvoid __attribute__((noinline)) pop_to_parent_deferring_access_checks (void)\n{\n    if (deferred_access_no_check)\n\tdeferred_access_no_check--;\n    else\n    {\n        VEC_deferred_access_check_gc *checks;\n        deferred_access *ptr;\n\tchecks = (VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0))->deferred_access_checks;\n        VEC_deferred_access_base_pop(deferred_access_stack ? &deferred_access_stack->base : 0);\n        ptr = VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0);\n        if (ptr->deferring_access_checks_kind == 0)\n\t    perform_access_checks (checks);\n    }\n}\n\nint main()\n{\n    deferred_access_stack = __builtin_malloc (sizeof(VEC_deferred_access_gc) + sizeof(deferred_access) * 8);\n    deferred_access_stack->base.num = 2;\n    deferred_access_stack->base.vec[0].deferring_access_checks_kind = 1;\n    pop_to_parent_deferring_access_checks ();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071202-1.c",
    "content": "extern void abort (void);\nstruct T { int t; int r[8]; };\nstruct S { int a; int b; int c[6]; struct T d; };\n\n__attribute__((noinline)) void\nfoo (struct S *s)\n{\n  *s = (struct S) { s->b, s->a, { 0, 0, 0, 0, 0, 0 }, s->d };\n}\n\nint\nmain (void)\n{\n  struct S s = { 6, 12, { 1, 2, 3, 4, 5, 6 },\n\t\t { 7, { 8, 9, 10, 11, 12, 13, 14, 15 } } };\n  foo (&s);\n  if (s.a != 12 || s.b != 6\n      || s.c[0] || s.c[1] || s.c[2] || s.c[3] || s.c[4] || s.c[5])\n    abort ();\n  if (s.d.t != 7 || s.d.r[0] != 8 || s.d.r[1] != 9 || s.d.r[2] != 10\n      || s.d.r[3] != 11 || s.d.r[4] != 12 || s.d.r[5] != 13\n      || s.d.r[6] != 14 || s.d.r[7] != 15)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071205-1.c",
    "content": "/* PR middle-end/34337 */\n\nextern void abort (void);\n\nint\nfoo (int x)\n{\n  return ((x << 8) & 65535) | 255;\n}\n\nint\nmain (void)\n{\n  if (foo (0x32) != 0x32ff || foo (0x174) != 0x74ff)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071210-1.c",
    "content": "/* PR rtl-optimization/34302 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nstruct S\n{\n  int n1, n2, n3, n4;\n};\n\n__attribute__((noinline)) struct S\nfoo (int x, int y, int z)\n{\n  if (x != 10 || y != 9 || z != 8)\n    abort ();\n  struct S s = { 1, 2, 3, 4 };\n  return s;\n}\n\n__attribute__((noinline)) void **\nbar (void **u, int *v)\n{\n  void **w = u;\n  int *s = v, x, y, z;\n  void **p, **q;\n  static void *l[] = { &&lab1, &&lab1, &&lab2, &&lab3, &&lab4 };\n\n  if (!u)\n    return l;\n\n  q = *w++;\n  goto *q;\nlab2:\n  p = q;\n  q = *w++;\n  x = s[2];\n  y = s[1];\n  z = s[0];\n  s -= 1;\n  struct S r = foo (x, y, z);\n  s[3] = r.n1;\n  s[2] = r.n2;\n  s[1] = r.n3;\n  s[0] = r.n4;\n  goto *q;\nlab3:\n  p = q;\n  q = *w++;\n  s += 1;\n  s[0] = 23;\nlab1:\n  goto *q;\nlab4:\n  return 0;\n}\n\nint\nmain (void)\n{\n  void **u = bar ((void **) 0, (int *) 0);\n  void *t[] = { u[2], u[4] };\n  int s[] = { 7, 8, 9, 10, 11, 12 };\n  if (bar (t, &s[1]) != (void **) 0\n      || s[0] != 4 || s[1] != 3 || s[2] != 2 || s[3] != 1\n      || s[4] != 11 || s[5] != 12)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071211-1.c",
    "content": "extern void abort() __attribute__ ((noreturn));\n\nstruct s\n{\n  unsigned long long f1 : 40;\n#if(__SIZEOF_INT__ >= 4)\n  unsigned int f2 : 24;\n#else\n  unsigned long int f2 : 24;\n#endif\n} sv;\n\nint main()\n{\n  int f2;\n  sv.f2 = (1 << 24) - 1;\n  __asm__ volatile (\"\" : : : \"memory\");\n  ++sv.f2;\n  f2 = sv.f2;\n  if (f2 != 0)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071213-1.c",
    "content": "/* PR target/34281 */\n\n#include <stdarg.h>\n\nextern void abort (void);\n\nvoid\nh (int x, va_list ap)\n{\n  switch (x)\n    {\n    case 1:\n      if (va_arg (ap, int) != 3 || va_arg (ap, int) != 4)\n\tabort ();\n      return;\n    case 5:\n      if (va_arg (ap, int) != 9 || va_arg (ap, int) != 10)\n\tabort ();\n      return;\n    default:\n      abort ();\n    }\n}\n\nvoid\nf1 (int i, long long int j, ...)\n{\n  va_list ap;\n  va_start (ap, j);\n  h (i, ap);\n  if (i != 1 || j != 2)\n    abort ();\n  va_end (ap);\n}\n\nvoid\nf2 (int i, int j, int k, long long int l, ...)\n{\n  va_list ap;\n  va_start (ap, l);\n  h (i, ap);\n  if (i != 5 || j != 6 || k != 7 || l != 8)\n    abort ();\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  f1 (1, 2, 3, 4);\n  f2 (5, 6, 7, 8, 9, 10);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071216-1.c",
    "content": "/* PR rtl-optimization/34490 */\n\nextern void abort (void);\n\nstatic int x;\n\nint\n__attribute__((noinline))\nbar (void)\n{\n  return x;\n}\n\nint\nfoo (void)\n{\n  long int b = bar ();\n  if ((unsigned long) b < -4095L)\n    return b;\n  if (-b != 38)\n    b = -2;\n  return b + 1;\n}\n\nint\nmain (void)\n{\n  x = 26;\n  if (foo () != 26)\n    abort ();\n  x = -39;\n  if (foo () != -1)\n    abort ();\n  x = -38;\n  if (foo () != -37)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071219-1.c",
    "content": "/* PR c++/34459 */\n\nextern void abort (void);\nextern void *memset (void *s, int c, __SIZE_TYPE__ n);\n\nstruct S\n{\n  char s[25];\n};\n\nstruct S *p;\n\nvoid __attribute__((noinline,noclone))\nfoo (struct S *x, int set)\n{\n  int i;\n  for (i = 0; i < sizeof (x->s); ++i)\n    if (x->s[i] != 0)\n      abort ();\n    else if (set)\n      x->s[i] = set;\n  p = x;\n}\n\nvoid __attribute__((noinline,noclone))\ntest1 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  b = a;\n  b = b;\n  foo (&b, 0);\n}\n\nvoid __attribute__((noinline,noclone))\ntest2 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  b = a;\n  b = *p;\n  foo (&b, 0);\n}\n\nvoid __attribute__((noinline,noclone))\ntest3 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  *p = a;\n  *p = b;\n  foo (&b, 0);\n}\n\nint\nmain (void)\n{\n  test1 ();\n  test2 ();\n  test3 ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071220-1.c",
    "content": "/* PR tree-optimization/29484 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nvoid *__attribute__((noinline))\nbaz (void **lab)\n{\n  asm volatile (\"\" : \"+r\" (lab));\n  return *lab;\n}\n\nstatic inline\nint bar (void)\n{\n  static void *b[] = { &&addr };\n  void *p = baz (b);\n  goto *p;\naddr:\n  return 17;\n}\n\nint __attribute__((noinline))\nf1 (void)\n{\n  return bar ();\n}\n\nint __attribute__((noinline))\nf2 (void)\n{\n  return bar ();\n}\n\nint\nmain (void)\n{\n  if (f1 () != 17 || f1 () != 17 || f2 () != 17 || f2 () != 17)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20071220-2.c",
    "content": "/* PR tree-optimization/29484 */\n/* { dg-require-effective-target label_values } */\n\nextern void abort (void);\n\nvoid *__attribute__((noinline))\nbaz (void **lab)\n{\n  asm volatile (\"\" : \"+r\" (lab));\n  return *lab;\n}\n\nstatic inline\nint bar (void)\n{\n  static void *b[] = { &&addr };\n  baz (b);\naddr:\n  return 17;\n}\n\nint __attribute__((noinline))\nf1 (void)\n{\n  return bar ();\n}\n\nint __attribute__((noinline))\nf2 (void)\n{\n  return bar ();\n}\n\nint\nmain (void)\n{\n  if (f1 () != 17 || f1 () != 17 || f2 () != 17 || f2 () != 17)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080117-1.c",
    "content": "typedef struct gs_imager_state_s {\n  struct {\n    int half_width;\n    int cap;\n    float miter_limit;\n  } line_params;\n} gs_imager_state;\nstatic const gs_imager_state gstate_initial = { { 1 } };\nvoid gstate_path_memory(gs_imager_state *pgs) {\n  *pgs = gstate_initial;\n}\nint gs_state_update_overprint(void)\n{\n  return gstate_initial.line_params.half_width;\n}\n\nextern void abort (void);\nint main()\n{\n  if (gs_state_update_overprint() != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080122-1.c",
    "content": "/* PR rtl-optimization/34628 */\n/* Origin: Martin Michlmayr <tbm@cyrius.com> */\n\ntypedef unsigned short u16;\ntypedef unsigned char u8;\n\nstatic void\ndo_segfault(u8 in_buf[], const u8 out_buf[], const int len)\n{\n  int i;\n\n  for (i = 0; i < len; i++) {\n    asm(\"\");\n\n    in_buf[2*i] = (   out_buf[2*i] | out_buf[(2*i)+1]<<8  ) & 0xFF;\n\n    asm(\"\");\n\n    in_buf[(2*i)+1] =  ( out_buf[2*i] | out_buf[(2*i)+1]<<8 ) >> 8;\n\n    asm(\"\");\n  }\n}\n\nint main(int argc, char *argv[])\n{\n  u8 outbuf[32] = \"buffer     \";\n  u8 inbuf[32] = \"\\f\";\n\n  asm(\"\");\n  do_segfault(inbuf, outbuf, 12);\n  asm(\"\");\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080222-1.c",
    "content": "extern void abort (void);\n\nstruct container\n{\n  unsigned char data[1];\n};\n\nunsigned char space[6] = {1, 2, 3, 4, 5, 6};\n\nint\nfoo (struct container *p)\n{\n  return p->data[4];\n}\n\nint\nmain ()\n{\n  if (foo ((struct container *) space) != 5)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080408-1.c",
    "content": "extern void abort (void);\nint main ()\n{\n  short ssi = 126;\n  unsigned short usi = 65280;\n  int fail = !(ssi < usi);\n  if (fail)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080424-1.c",
    "content": "/* PR tree-optimization/36008 */\n\nextern void abort (void);\n\nint g[48][3][3];\n\nvoid __attribute__ ((noinline))\nbar (int x[3][3], int y[3][3])\n{\n  static int i;\n  if (x != g[i + 8] || y != g[i++])\n    abort ();\n}\n\nstatic inline void __attribute__ ((always_inline))\nfoo (int x[][3][3])\n{\n  int i;\n  for (i = 0; i < 8; i++)\n    {\n      int k = i + 8;\n      bar (x[k], x[k - 8]);\n    }\n}\n\nint\nmain ()\n{\n  foo (g);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080502-1.c",
    "content": "/* PR target/36090 */\n\nextern void abort (void);\n\nlong double __attribute__ ((noinline)) foo (long double x)\n{\n  return __builtin_signbit (x) ? 3.1415926535897932384626433832795029L : 0.0;\n}\n\nint\nmain (void)\n{\n  if (foo (-1.0L) != 3.1415926535897932384626433832795029L)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080506-1.c",
    "content": "/* PR middle-end/36137 */\nextern void abort (void);\n\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n\nint\nmain ()\n{\n  unsigned int u;\n  int i = -1;\n\n  u = MAX ((unsigned int) MAX (i, 0), 1);\n  if (u != 1)\n    abort ();\n\n  u = MIN ((unsigned int) MAX (i, 0), (unsigned int) i);\n  if (u != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080506-2.c",
    "content": "/* PR middle-end/36013 */\n\nextern void abort (void);\n\nvoid __attribute__((noinline))\nfoo (int **__restrict p, int **__restrict q)\n{\n  *p[0] = 1;\n  *q[0] = 2;\n  if (*p[0] != 2)\n    abort ();\n}\n\nint\nmain (void)\n{\n  int a;\n  int *p1 = &a, *p2 = &a;\n  foo (&p1, &p2);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080519-1.c",
    "content": "extern void abort (void);\n\ntypedef unsigned long HARD_REG_SET[2];\nHARD_REG_SET reg_class_contents[2];\n\nstruct du_chain\n{\n  struct du_chain *next_use;\n  int cl;\n};\n\nvoid __attribute__((noinline))\nmerge_overlapping_regs (HARD_REG_SET *p)\n{\n  if ((*p)[0] != -1 || (*p)[1] != -1)\n    abort ();\n}\n\nvoid __attribute__((noinline))\nregrename_optimize (struct du_chain *this)\n{\n  HARD_REG_SET this_unavailable;\n  unsigned long *scan_fp_;\n  int n_uses;\n  struct du_chain *last;\n\n  this_unavailable[0] = 0;\n  this_unavailable[1] = 0;\n\n  n_uses = 0;\n  for (last = this; last->next_use; last = last->next_use)\n    {\n      scan_fp_ = reg_class_contents[last->cl];\n      n_uses++;\n      this_unavailable[0] |= ~ scan_fp_[0];\n      this_unavailable[1] |= ~ scan_fp_[1];\n    }\n  if (n_uses < 1)\n    return;\n\n  scan_fp_ = reg_class_contents[last->cl];\n  this_unavailable[0] |= ~ scan_fp_[0];\n  this_unavailable[1] |= ~ scan_fp_[1];\n\n  merge_overlapping_regs (&this_unavailable);\n}\n\nint main()\n{\n  struct du_chain du1 = { 0, 0 };\n  struct du_chain du0 = { &du1, 1 };\n  reg_class_contents[0][0] = -1;\n  reg_class_contents[0][1] = -1;\n  reg_class_contents[1][0] = 0;\n  reg_class_contents[1][1] = 0;\n  regrename_optimize (&du0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080522-1.c",
    "content": "/* This testcase is to make sure we have i in referenced vars and that we\n   properly compute aliasing for the loads and stores.  */\n\nextern void abort (void);\n\nstatic int i;\nstatic int *p = &i;\n\nint __attribute__((noinline))\nfoo(int *q)\n{\n  *p = 1;\n  *q = 2;\n  return *p;\n}\n\nint __attribute__((noinline))\nbar(int *q)\n{\n  *q = 2;\n  *p = 1;\n  return *q;\n}\n\nint main()\n{\n  int j = 0;\n\n  if (foo(&i) != 2)\n    abort ();\n  if (bar(&i) != 1)\n    abort ();\n  if (foo(&j) != 1)\n    abort ();\n  if (j != 2)\n    abort ();\n  if (bar(&j) != 2)\n    abort ();\n  if (j != 2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080529-1.c",
    "content": "/* PR target/36362 */\n\nextern void abort (void);\n\nint\ntest (float c)\n{\n  return !!c * 7LL == 0;\n}\n\nint\nmain (void)\n{\n  if (test (1.0f) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080604-1.c",
    "content": "struct barstruct { char const* some_string; } x;\nextern void abort (void);\nvoid __attribute__((noinline))\nfoo(void)\n{\n  if (!x.some_string)\n    abort ();\n}\nvoid baz(int b)\n{\n  struct barstruct bar;\n  struct barstruct* barptr;\n  if (b)\n    barptr = &bar;\n  else\n    {\n      barptr = &x + 1;\n      barptr = barptr - 1;\n    }\n  barptr->some_string = \"Everything OK\";\n  foo();\n  barptr->some_string = \"Everything OK\";\n}\nint main()\n{\n  x.some_string = (void *)0;\n  baz(0);\n  if (!x.some_string)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080719-1.c",
    "content": "typedef unsigned int u32;\n\nstatic const u32 deadfish = 0xdeadf155;\n\nstatic const u32 cfb_tab8_be[] = {\n    0x00000000,0x000000ff,0x0000ff00,0x0000ffff,\n    0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,\n    0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,\n    0xffff0000,0xffff00ff,0xffffff00,0xffffffff\n};\n\nstatic const u32 cfb_tab8_le[] = {\n    0x00000000,0xff000000,0x00ff0000,0xffff0000,\n    0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,\n    0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,\n    0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff\n};\n\nstatic const u32 cfb_tab16_be[] = {\n    0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff\n};\n\nstatic const u32 cfb_tab16_le[] = {\n    0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff\n};\n\nstatic const u32 cfb_tab32[] = {\n 0x00000000, 0xffffffff\n};\n\n\n\n\n\n\nconst u32 *xxx(int bpp)\n{\n const u32 *tab;\n\nif (0) return &deadfish;\n\n switch (bpp) {\n case 8:\n  tab = cfb_tab8_be;\n  break;\n case 16:\n  tab = cfb_tab16_be;\n  break;\n case 32:\n default:\n  tab = cfb_tab32;\n  break;\n }\n\n return tab;\n}\n\nint main(void)\n{\n  const u32 *a = xxx(8);\n  int b = a[0];\n  if (b != cfb_tab8_be[0])\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20080813-1.c",
    "content": "/* PR middle-end/37103 */\n\nextern void abort (void);\n\nvoid\nfoo (unsigned short x)\n{\n  signed char y = -1;\n  if (x == y)\n    abort ();\n}\n\nvoid\nbar (unsigned short x)\n{\n  unsigned char y = -1;\n  if (x == y)\n    abort ();\n}\n\nint\nmain (void)\n{\n  if (sizeof (int) == sizeof (short))\n    return 0;\n  foo (-1);\n  if (sizeof (short) > 1)\n    bar (-1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20081103-1.c",
    "content": "struct S { char c; char arr[4]; float f; };\n\nchar A[4] = { '1', '2', '3', '4' };\n\nvoid foo (struct S s)\n{\n  if (__builtin_memcmp (s.arr, A, 4))\n    __builtin_abort ();\n}\n\nint main (void)\n{\n  struct S s;\n  __builtin_memcpy (s.arr, A, 4);\n  foo (s);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20081112-1.c",
    "content": "#include <limits.h>\n\nextern void abort (void);\n\nstatic __attribute__((noinline)) void foo (int a)\n{\n  int b = (a - 1) + INT_MIN;\n\n  if (b != INT_MIN)\n    abort ();\n}\n\nint main (void)\n{\n  foo (1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20081117-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort (void);\n\nstruct s\n{\n  unsigned long long a:16;\n  unsigned long long b:32;\n  unsigned long long c:16;\n};\n\n__attribute__ ((noinline)) unsigned\nf (struct s s, unsigned i)\n{\n  return s.b == i;\n}\n\nstruct s s = { 1, 0x87654321u, 2};\n\nint\nmain ()\n{\n  if (!f (s, 0x87654321u))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20081218-1.c",
    "content": "struct A { int i, j; char pad[512]; } a;\n\nint __attribute__((noinline))\nfoo (void)\n{\n  __builtin_memset (&a, 0x26, sizeof a);\n  return a.i;\n}\n\nvoid __attribute__((noinline))\nbar (void)\n{\n  __builtin_memset (&a, 0x36, sizeof a);\n  a.i = 0x36363636;\n  a.j = 0x36373636;\n}\n\nint\nmain (void)\n{\n  int i;\n  if (sizeof (int) != 4 || __CHAR_BIT__ != 8)\n    return 0;\n\n  if (foo () != 0x26262626)\n    __builtin_abort ();\n  for (i = 0; i < sizeof a; i++)\n    if (((char *)&a)[i] != 0x26)\n      __builtin_abort ();\n\n  bar ();\n  if (a.j != 0x36373636)\n    __builtin_abort ();\n  a.j = 0x36363636;\n  for (i = 0; i < sizeof a; i++)\n    if (((char *)&a)[i] != 0x36)\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090113-1.c",
    "content": "typedef struct descriptor_dimension\n{\n  int stride;\n  int lbound;\n  int ubound;\n} descriptor_dimension;\ntypedef struct {\n    int *data;\n    int dtype;\n    descriptor_dimension dim[7];\n} gfc_array_i4;\n\nvoid\nmsum_i4 (gfc_array_i4 * const retarray,\n\t gfc_array_i4 * const array,\n\t const int * const pdim)\n{\n  int count[7];\n  int extent[7];\n  int * dest;\n  const int * base;\n  int dim;\n  int n;\n  int len;\n\n  dim = (*pdim) - 1;\n  len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;\n\n  for (n = 0; n < dim; n++)\n    {\n      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;\n      count[n] = 0;\n    }\n\n  dest = retarray->data;\n  base = array->data;\n\n  do\n    {\n      int result = 0;\n\n      for (n = 0; n < len; n++, base++)\n\tresult += *base;\n      *dest = result;\n\n      count[0]++;\n      dest += 1;\n    }\n  while (count[0] != extent[0]);\n}\n\nint main()\n{\n  int rdata[3];\n  int adata[9];\n  gfc_array_i4 retarray = { rdata, 265, { { 1, 1, 3 } } };\n  gfc_array_i4 array = { adata, 266, { { 1, 1, 3 }, { 3, 1, 3 } } };\n  int dim = 2;\n  msum_i4 (&retarray, &array, &dim);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090113-2.c",
    "content": "struct obstack {};\nstruct bitmap_head_def;\ntypedef struct bitmap_head_def *bitmap;\ntypedef const struct bitmap_head_def *const_bitmap;\ntypedef unsigned long BITMAP_WORD;\ntypedef struct bitmap_obstack\n{\n  struct bitmap_element_def *elements;\n  struct bitmap_head_def *heads;\n  struct obstack obstack;\n} bitmap_obstack;\ntypedef struct bitmap_element_def\n{\n  struct bitmap_element_def *next;\n  struct bitmap_element_def *prev;\n  unsigned int indx;\n  BITMAP_WORD bits[((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u))];\n} bitmap_element;\n\nstruct bitmap_descriptor;\n\ntypedef struct bitmap_head_def {\n    bitmap_element *first;\n    bitmap_element *current;\n    unsigned int indx;\n    bitmap_obstack *obstack;\n} bitmap_head;\n\nbitmap_element bitmap_zero_bits;\n\ntypedef struct\n{\n  bitmap_element *elt1;\n  bitmap_element *elt2;\n  unsigned word_no;\n  BITMAP_WORD bits;\n} bitmap_iterator;\n\nstatic void __attribute__((noinline))\nbmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,\n\t\t   unsigned start_bit, unsigned *bit_no)\n{\n  bi->elt1 = map->first;\n  bi->elt2 = ((void *)0);\n\n  while (1)\n    {\n      if (!bi->elt1)\n\t{\n\t  bi->elt1 = &bitmap_zero_bits;\n\t  break;\n\t}\n\n      if (bi->elt1->indx >= start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))\n\tbreak;\n      bi->elt1 = bi->elt1->next;\n    }\n\n  if (bi->elt1->indx != start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))\n    start_bit = bi->elt1->indx * (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u));\n\n  bi->word_no = start_bit / (8 * 8 * 1u) % ((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u));\n  bi->bits = bi->elt1->bits[bi->word_no];\n  bi->bits >>= start_bit % (8 * 8 * 1u);\n\n  start_bit += !bi->bits;\n\n  *bit_no = start_bit;\n}\n\nstatic void __attribute__((noinline))\nbmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)\n{\n  bi->bits >>= 1;\n  *bit_no += 1;\n}\n\nstatic unsigned char __attribute__((noinline))\nbmp_iter_set_tail (bitmap_iterator *bi, unsigned *bit_no)\n{\n  while (!(bi->bits & 1))\n    {\n      bi->bits >>= 1;\n      *bit_no += 1;\n    }\n  return 1;\n}\n\nstatic __inline__ unsigned char\nbmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)\n{\n  unsigned bno = *bit_no;\n  BITMAP_WORD bits = bi->bits;\n  bitmap_element *elt1;\n\n  if (bits)\n    {\n      while (!(bits & 1))\n\t{\n\t  bits >>= 1;\n\t  bno += 1;\n\t}\n      *bit_no = bno;\n      return 1;\n    }\n\n  *bit_no = ((bno + 64 - 1) / 64 * 64);\n  bi->word_no++;\n\n  elt1 = bi->elt1;\n  while (1)\n    {\n      while (bi->word_no != 2)\n\t{\n\t  bi->bits = elt1->bits[bi->word_no];\n\t  if (bi->bits)\n\t    {\n\t      bi->elt1 = elt1;\n\t      return bmp_iter_set_tail (bi, bit_no);\n\t    }\n\t  *bit_no += 64;\n\t  bi->word_no++;\n\t}\n\n      elt1 = elt1->next;\n      if (!elt1)\n\t{\n\t  bi->elt1 = elt1;\n\t  return 0;\n\t}\n      *bit_no = elt1->indx * (2 * 64);\n      bi->word_no = 0;\n    }\n}\n\nextern void abort (void);\n\nstatic void __attribute__((noinline)) catchme(int i)\n{\n  if (i != 0 && i != 64)\n    abort ();\n}\nstatic void __attribute__((noinline)) foobar (bitmap_head *chain)\n{\n  bitmap_iterator rsi;\n  unsigned int regno;\n  for (bmp_iter_set_init (&(rsi), (chain), (0), &(regno));\n       bmp_iter_set (&(rsi), &(regno));\n       bmp_iter_next (&(rsi), &(regno)))\n    catchme(regno);\n}\n\nint main()\n{\n  bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };\n  bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };\n  foobar (&live_throughout);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090113-3.c",
    "content": "struct obstack {};\nstruct bitmap_head_def;\ntypedef struct bitmap_head_def *bitmap;\ntypedef const struct bitmap_head_def *const_bitmap;\ntypedef unsigned long BITMAP_WORD;\n\ntypedef struct bitmap_obstack\n{\n  struct bitmap_element_def *elements;\n  struct bitmap_head_def *heads;\n  struct obstack obstack;\n} bitmap_obstack;\ntypedef struct bitmap_element_def\n{\n  struct bitmap_element_def *next;\n  struct bitmap_element_def *prev;\n  unsigned int indx;\n  BITMAP_WORD bits[(2)];\n} bitmap_element;\n\nstruct bitmap_descriptor;\n\ntypedef struct bitmap_head_def {\n    bitmap_element *first;\n    bitmap_element *current;\n    unsigned int indx;\n    bitmap_obstack *obstack;\n} bitmap_head;\n\nbitmap_element bitmap_zero_bits;\n\ntypedef struct\n{\n  bitmap_element *elt1;\n  bitmap_element *elt2;\n  unsigned word_no;\n  BITMAP_WORD bits;\n} bitmap_iterator;\n\nstatic __attribute__((noinline)) void\nbmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,\n\t\t   unsigned start_bit, unsigned *bit_no)\n{\n  bi->elt1 = map->first;\n  bi->elt2 = ((void *)0);\n\n  while (1)\n    {\n      if (!bi->elt1)\n\t{\n\t  bi->elt1 = &bitmap_zero_bits;\n\t  break;\n\t}\n\n      if (bi->elt1->indx >= start_bit / (128u))\n\tbreak;\n      bi->elt1 = bi->elt1->next;\n    }\n\n  if (bi->elt1->indx != start_bit / (128u))\n    start_bit = bi->elt1->indx * (128u);\n\n  bi->word_no = start_bit / 64u % (2);\n  bi->bits = bi->elt1->bits[bi->word_no];\n  bi->bits >>= start_bit % 64u;\n\n  start_bit += !bi->bits;\n\n  *bit_no = start_bit;\n}\n\nstatic __inline__ __attribute__((always_inline)) void\nbmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)\n{\n  bi->bits >>= 1;\n  *bit_no += 1;\n}\n\nstatic __inline__ __attribute__((always_inline)) unsigned char\nbmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)\n{\n  if (bi->bits)\n    {\n      while (!(bi->bits & 1))\n\t{\n\t  bi->bits >>= 1;\n\t  *bit_no += 1;\n\t}\n      return 1;\n    }\n\n  *bit_no = ((*bit_no + 64u - 1) / 64u * 64u);\n  bi->word_no++;\n\n  while (1)\n    {\n      while (bi->word_no != (2))\n\t{\n\t  bi->bits = bi->elt1->bits[bi->word_no];\n\t  if (bi->bits)\n\t    {\n\t      while (!(bi->bits & 1))\n\t\t{\n\t\t  bi->bits >>= 1;\n\t\t  *bit_no += 1;\n\t\t}\n\t      return 1;\n\t    }\n\t  *bit_no += 64u;\n\t  bi->word_no++;\n\t}\n\n      bi->elt1 = bi->elt1->next;\n      if (!bi->elt1)\n\treturn 0;\n      *bit_no = bi->elt1->indx * (128u);\n      bi->word_no = 0;\n    }\n}\n\nstatic void __attribute__((noinline))\nfoobar (bitmap_head *live_throughout)\n{\n  bitmap_iterator rsi;\n  unsigned int regno;\n  for (bmp_iter_set_init (&(rsi), (live_throughout), (0), &(regno));\n       bmp_iter_set (&(rsi), &(regno));\n       bmp_iter_next (&(rsi), &(regno)))\n    ;\n}\nint main()\n{\n  bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };\n  bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };\n  foobar (&live_throughout);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090207-1.c",
    "content": "int foo(int i)\n{\n  int a[32];\n  a[1] = 3;\n  a[0] = 1;\n  a[i] = 2;\n  return a[0];\n}\nextern void abort (void);\nint main()\n{\n  if (foo (0) != 2\n      || foo (1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090219-1.c",
    "content": "/* On ARM, BAR used to get a bogus number in E due to stack\n   misalignment.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (void)\n{\n  int f = 0;\n\n  void bar (int a, int b, int c, int d, int e)\n    {\n      if (e != 0)\n\t{\n\t  f = 1;\n\t  abort ();\n\t}\n    }\n\n  bar (0, 0, 0, 0, 0);\n}\n\nint\nmain (void)\n{\n  foo ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090527-1.c",
    "content": "typedef enum { POSITION_ASIS, POSITION_UNSPECIFIED } unit_position;\n\ntypedef enum { STATUS_UNKNOWN, STATUS_UNSPECIFIED } unit_status;\n\ntypedef struct\n{\n  unit_position position;\n  unit_status status;\n} unit_flags;\n\nextern void abort (void);\n\nvoid\nnew_unit (unit_flags * flags)\n{\n  if (flags->status == STATUS_UNSPECIFIED)\n    flags->status = STATUS_UNKNOWN;\n\n  if (flags->position == POSITION_UNSPECIFIED)\n    flags->position = POSITION_ASIS;\n\n  switch (flags->status)\n    {\n    case STATUS_UNKNOWN:\n      break;\n\n    default:\n      abort ();\n    }\n}\n\nint main()\n{\n  unit_flags f;\n  f.status = STATUS_UNSPECIFIED;\n  new_unit (&f);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090623-1.c",
    "content": "int * __restrict__ x;\n\nint foo (int y)\n{\n  *x = y;\n  return *x;\n}\n\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  x = &i;\n  if (foo(1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090711-1.c",
    "content": "/* Used to be miscompiled at -O0 due to incorrect choice of sign extension\n   vs. zero extension.  __attribute__ ((noinline)) added to try to make it\n   fail at higher optimization levels too.  */\n\nextern void abort (void);\n\nlong long __attribute__ ((noinline))\ndiv (long long val)\n{\n  return val / 32768;\n}\n\nint main (void)\n{\n  long long d1 = -990000000;\n  long long d2 = div(d1);\n  if (d2 != -30212)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20090814-1.c",
    "content": "int __attribute__((noinline))\nbar (int *a)\n{\n  return *a;\n}\nint i;\nint __attribute__((noinline))\nfoo (int (*a)[2])\n{\n  return bar (&(*a)[i]);\n}\n\nextern void abort (void);\nint a[2];\nint main()\n{\n  a[0] = -1;\n  a[1] = 42;\n  i = 1;\n  if (foo (&a) != 42)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20091229-1.c",
    "content": "long long foo(long long v) { return v / -0x080000000LL; }\nint main(int argc, char **argv) { if (foo(0x080000000LL) != -1) abort(); exit (0); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100209-1.c",
    "content": "int bar(int foo)\n{\n  return (int)(((unsigned long long)(long long)foo) / 8);\n}\nextern void abort (void);\nint main()\n{\n  if (sizeof (long long) > sizeof (int)\n      && bar(-1) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100316-1.c",
    "content": "struct Foo {\n  int i;\n  unsigned precision : 10;\n  unsigned blah : 3;\n} f;\n\nint __attribute__((noinline,noclone))\nfoo (struct Foo *p)\n{\n  struct Foo *q = p;\n  return (*q).precision;\n}\n\nextern void abort (void);\n\nint main()\n{\n  f.i = -1;\n  f.precision = 0;\n  f.blah = -1;\n  if (foo (&f) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100416-1.c",
    "content": "void abort(void);\n\nint\nmovegt(int x, int y, long long a)\n{\n  int i;\n  int ret = 0;\n  for (i = 0; i < y; i++)\n    {\n      if (a >= (long long) 0xf000000000000000LL)\n\tret = x;\n      else\n\tret = y;\n    }\n  return ret;\n}\n\nstruct test\n{\n  long long val;\n  int ret;\n} tests[] = {\n  { 0xf000000000000000LL, -1 },\n  { 0xefffffffffffffffLL, 1 },\n  { 0xf000000000000001LL, -1 },\n  { 0x0000000000000000LL, -1 },\n  { 0x8000000000000000LL, 1 },\n};\n\nint\nmain()\n{\n  int i;\n  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)\n    {\n      if (movegt (-1, 1, tests[i].val) != tests[i].ret)\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100430-1.c",
    "content": "/* This used to generate unaligned accesses at -O2 because of IVOPTS.  */\n\nstruct packed_struct\n{\n  struct packed_struct1\n  {\n    unsigned char cc11;\n    unsigned char cc12;\n  } __attribute__ ((packed)) pst1;\n  struct packed_struct2\n  {\n    unsigned char cc21;\n    unsigned char cc22;\n    unsigned short ss[104];\n    unsigned char cc23[13];\n  } __attribute__ ((packed)) pst2[4];\n} __attribute__ ((packed));\n\ntypedef struct\n{\n  int ii;\n  struct packed_struct buf;\n} info_t;\n\nstatic unsigned short g;\n\nstatic void __attribute__((noinline))\ndummy (unsigned short s)\n{\n  g = s;\n}\n\nstatic int\nfoo (info_t *info)\n{\n  int i, j;\n\n  for (i = 0; i < info->buf.pst1.cc11; i++)\n    for (j = 0; j < info->buf.pst2[i].cc22; j++)\n      dummy (info->buf.pst2[i].ss[j]);\n\n  return 0;\n}\n\nint main(void)\n{\n  info_t info;\n  info.buf.pst1.cc11 = 2;\n  info.buf.pst2[0].cc22 = info.buf.pst2[1].cc22 = 8;\n  return foo (&info);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100708-1.c",
    "content": "/* PR middle-end/44843 */\n/* Verify that we don't use the alignment of struct S for inner accesses.  */\n\nstruct S\n{\n  double for_alignment;\n  struct { int x, y, z; } a[16];\n};\n\nvoid f(struct S *s) __attribute__((noinline));\n\nvoid f(struct S *s)\n{\n  unsigned int i;\n\n  for (i = 0; i < 16; ++i)\n    {\n      s->a[i].x = 0;\n      s->a[i].y = 0;\n      s->a[i].z = 0;\n    }\n}\n\nint main (void)\n{\n  struct S s;\n  f (&s);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100805-1.c",
    "content": "unsigned int foo (unsigned int a, unsigned int b)\n{\n  unsigned i;\n  a = a & 1;\n  for (i = 0; i < b; ++i)\n    a = a << 1 | a >> (sizeof (unsigned int) * 8 - 1);\n  return a;\n}\nextern void abort (void);\nint main()\n{\n  if (foo (1, sizeof (unsigned int) * 8 + 1) != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20100827-1.c",
    "content": "extern void abort (void);\nint __attribute__((noinline,noclone))\nfoo (char *p)\n{\n  int h = 0;\n  do\n    {\n      if (*p == '\\0')\n\tbreak;\n      ++h;\n      if (p == 0)\n\tabort ();\n      ++p;\n    }\n  while (1);\n  return h;\n}\nint main()\n{\n  if (foo(\"a\") != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20101011-1.c",
    "content": "/* { dg-options \"-fnon-call-exceptions\" } */\n/* With -fnon-call-exceptions 0 / 0 should not be eliminated.  */\n\n#ifdef SIGNAL_SUPPRESS\n# define DO_TEST 0\n#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)\n  /* On PPC division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__SPU__)\n  /* On SPU division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__sh__)\n  /* On SH division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__v850__)\n  /* On V850 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__MSP430__)\n  /* On MSP430 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__RL78__)\n  /* On RL78 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__RX__)\n  /* On RX division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__aarch64__)\n  /* On AArch64 integer division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__TMS320C6X__)\n  /* On TI C6X division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__VISIUM__)\n  /* On Visium division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__mips__) && !defined(__linux__)\n  /* MIPS divisions do trap by default, but libgloss targets do not\n     intercept the trap and raise a SIGFPE.  The same is probably\n     true of other bare-metal environments, so restrict the test to\n     systems that use the Linux kernel.  */\n# define DO_TEST 0\n#elif defined (__mips16) && defined(__linux__)\n  /* Not all Linux kernels deal correctly the breakpoints generated by\n     MIPS16 divisions by zero.  They show up as a SIGTRAP instead.  */\n# define DO_TEST 0\n#elif defined (__MICROBLAZE__)\n/* We cannot rely on division by zero generating a trap. */\n# define DO_TEST 0\n#elif defined (__epiphany__)\n  /* Epiphany does not have hardware division, and the software implementation\n     has truly undefined behavior for division by 0.  */\n# define DO_TEST 0\n#elif defined (__m68k__) && !defined(__linux__)\n  /* Attempting to trap division-by-zero in this way isn't likely to work on \n     bare-metal m68k systems.  */\n# define DO_TEST 0\n#elif defined (__CRIS__)\n  /* No SIGFPE for CRIS integer division.  */\n# define DO_TEST 0\n#elif defined (__MMIX__)\n/* By default we emit a sequence with DIVU, which \"never signals an\n   exceptional condition, even when dividing by zero\".  */\n# define DO_TEST 0\n#elif defined (__arc__)\n  /* No SIGFPE for ARC integer division.  */\n# define DO_TEST 0\n#elif defined (__arm__) && defined (__ARM_EABI__)\n# ifdef __ARM_ARCH_EXT_IDIV__\n  /* Hardware division instructions may not trap, and handle trapping\n     differently anyway.  Skip the test if we have those instructions.  */\n#  define DO_TEST 0\n# else\n#  include <signal.h>\n  /* ARM division-by-zero behavior is to call a helper function, which\n     can do several different things, depending on requirements.  Emulate\n     the behavior of other targets here by raising SIGFPE.  */\nint __attribute__((used))\n__aeabi_idiv0 (int return_value)\n{\n  raise (SIGFPE);\n  return return_value;\n}\n#  define DO_TEST 1\n# endif\n#elif defined (__nios2__)\n  /* Nios II requires both hardware support and user configuration to\n     raise an exception on divide by zero.  */\n# define DO_TEST 0\n#elif defined (__nvptx__)\n/* There isn't even a signal function.  */\n# define DO_TEST 0\n#else\n# define DO_TEST 1\n#endif\n\nextern void abort (void);\nextern void exit (int);\n\n#if DO_TEST\n\n#include <signal.h>\n\nvoid\nsigfpe (int signum __attribute__ ((unused)))\n{\n  exit (0);\n}\n\n#endif\n\n/* When optimizing, the compiler is smart enough to constant fold the\n   static unset variables i and j to produce 0 / 0, but it can't\n   eliminate the assignment to the global k.  */\nstatic int i;\nstatic int j;\nint k __attribute__ ((used));\n\nint\nmain ()\n{\n#if DO_TEST\n  signal (SIGFPE, sigfpe);\n  k = i / j;\n  abort ();\n#else\n  exit (0);\n#endif\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20101013-1.c",
    "content": "/* PR rtl-optimization/45912 */\n\nextern void abort (void);\n\nstatic void* __attribute__((noinline,noclone))\nget_addr_base_and_unit_offset (void *base, long long *i)\n{\n  *i = 0;\n  return base;\n}\n\nstatic void* __attribute__((noinline,noclone))\nbuild_int_cst (void *base, long long offset)\n{\n  if (offset != 4)\n    abort ();\n\n  return base;\n}\n\nstatic void* __attribute__((noinline,noclone))\nbuild_ref_for_offset (void *base, long long offset)\n{\n  long long base_offset;\n  base = get_addr_base_and_unit_offset (base, &base_offset);\n  return build_int_cst (base, base_offset + offset / 8);\n}\n\nint\nmain (void)\n{\n  void *ret = build_ref_for_offset ((void *)0, 32);\n  if (ret != (void *)0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20101025-1.c",
    "content": "static int g_7;\nstatic int *volatile g_6 = &g_7;\nint g_3;\n\nstatic int f1 (int *p_58)\n{\n    return *p_58;\n}\n\nvoid f2 (int i) __attribute__ ((noinline));\nvoid f2 (int i)\n{\n  g_3 = i;\n}\n\nint f3 (void) __attribute__ ((noinline));\nint f3 (void)\n{\n    *g_6 = 1;\n    f2 (f1 (&g_7));\n    return 0;\n}\n\nint main ()\n{\n  f3 ();\n  if (g_3 != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20110418-1.c",
    "content": "typedef unsigned long long uint64_t;\nvoid f(uint64_t *a, uint64_t aa) __attribute__((noinline));\nvoid f(uint64_t *a, uint64_t aa)\n{\n  uint64_t new_value = aa;\n  uint64_t old_value = *a;\n  int bit_size = 32;\n    uint64_t mask = (uint64_t)(unsigned)(-1);\n    uint64_t tmp = old_value & mask;\n    new_value &= mask;\n    /* On overflow we need to add 1 in the upper bits */\n    if (tmp > new_value)\n        new_value += 1ull<<bit_size;\n    /* Add in the upper bits from the old value */\n    new_value += old_value & ~mask;\n    *a = new_value;\n}\nint main(void)\n{\n  uint64_t value, new_value, old_value;\n  value = 0x100000001;\n  old_value = value;\n  new_value = (value+1)&(uint64_t)(unsigned)(-1);\n  f(&value, new_value);\n  if (value != old_value+1)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20111208-1.c",
    "content": "/* PR tree-optimization/51315 */\n/* Reported by Jurij Smakov <jurij@wooyd.org> */\n\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memcpy (void *__restrict __dest,\n       __const void *__restrict __src, size_t __n)\n     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));\n\nextern size_t strlen (__const char *__s)\n     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\n\ntypedef __INT16_TYPE__ int16_t;\ntypedef __INT32_TYPE__ int32_t;\n\nextern void abort (void);\n\nint a;\n\nstatic void __attribute__ ((noinline,noclone))\ndo_something (int item)\n{\n  a = item;\n}\n\nint\npack_unpack (char *s, char *p)\n{\n  char *send, *pend;\n  char type;\n  int integer_size;\n\n  send = s + strlen (s);\n  pend = p + strlen (p);\n\n  while (p < pend)\n    {\n      type = *p++;\n\n      switch (type)\n {\n case 's':\n   integer_size = 2;\n   goto unpack_integer;\n\n case 'l':\n   integer_size = 4;\n   goto unpack_integer;\n\n unpack_integer:\n   switch (integer_size)\n     {\n     case 2:\n       {\n  union\n  {\n    int16_t i;\n    char a[sizeof (int16_t)];\n  }\n  v;\n  memcpy (v.a, s, sizeof (int16_t));\n  s += sizeof (int16_t);\n  do_something (v.i);\n       }\n       break;\n\n     case 4:\n       {\n  union\n  {\n    int32_t i;\n    char a[sizeof (int32_t)];\n  }\n  v;\n  memcpy (v.a, s, sizeof (int32_t));\n  s += sizeof (int32_t);\n  do_something (v.i);\n       }\n       break;\n     }\n   break;\n }\n    }\n  return (int) *s;\n}\n\nint\nmain (void)\n{\n  int n = pack_unpack (\"\\200\\001\\377\\376\\035\\300\", \"sl\");\n  if (n != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20111212-1.c",
    "content": "/* PR tree-optimization/50569 */\n/* Reported by Paul Koning <pkoning@gcc.gnu.org> */\n/* Reduced testcase by Mikael Pettersson <mikpe@it.uu.se> */\n\nstruct event {\n    struct {\n\tunsigned int sec;\n    } sent __attribute__((packed));\n};\n\nvoid __attribute__((noinline,noclone)) frob_entry(char *buf)\n{\n    struct event event;\n\n    __builtin_memcpy(&event, buf, sizeof(event));\n    if (event.sent.sec < 64) {\n\tevent.sent.sec = -1U;\n\t__builtin_memcpy(buf, &event, sizeof(event));\n    }\n}\n\nint main(void)\n{\n    union {\n\tchar buf[1 + sizeof(struct event)];\n\tint align;\n    } u;\n\n    __builtin_memset(&u, 0, sizeof u);\n\n    frob_entry(&u.buf[1]);\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20111227-1.c",
    "content": "/* PR rtl-optimization/51667 */\n/* Testcase by Uros Bizjak <ubizjak@gmail.com> */\n\nextern void abort (void);\n\nvoid __attribute__((noinline,noclone))\nbar (int a)\n{\n  if (a != -1)\n    abort ();\n}\n\nvoid __attribute__((noinline,noclone))\nfoo (short *a, int t)\n{\n  short r = *a;\n\n  if (t)\n    bar ((unsigned short) r);\n  else\n    bar ((signed short) r);\n}\n\nshort v = -1;\n\nint main(void)\n{\n  foo (&v, 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120105-1.c",
    "content": "struct __attribute__((packed)) S\n{\n  int a, b, c;\n};\n\nstatic int __attribute__ ((noinline,noclone))\nextract(const char *p)\n{\n  struct S s;\n  __builtin_memcpy (&s, p, sizeof(struct S));\n  return s.a;\n}\n\nvolatile int i;\n\nint main (void)\n{\n  char p[sizeof(struct S) + 1];\n\n  __builtin_memset (p, 0, sizeof(struct S) + 1);\n  i = extract (p + 1);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120111-1.c",
    "content": "#include <stdlib.h>\n#include <stdint.h>\n\nuint32_t f0a (uint64_t arg2) __attribute__((noinline));\n\nuint32_t\nf0a (uint64_t arg)\n{\n  return ~((unsigned) (arg > -3));\n}\n\nint main() {\n  uint32_t r1;\n  r1 = f0a (12094370573988097329ULL);\n  if (r1 != ~0U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120207-1.c",
    "content": "/* PR middle-end/51994 */\n/* Testcase by Uros Bizjak <ubizjak@gmail.com> */\n\nextern char *strcpy (char *, const char *);\nextern void abort (void);\n\nchar __attribute__((noinline))\ntest (int a)\n{\n  char buf[16];\n  char *output = buf;\n\n  strcpy (&buf[0], \"0123456789\");\n\n  output += a;\n  output -= 1;\n\n  return output[0];\n}\n\nint main ()\n{\n  if (test (2) != '1')\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120427-1.c",
    "content": "typedef struct sreal\n{\n  unsigned sig;\t\t/* Significant.  */\n  int exp;\t\t/* Exponent.  */\n} sreal;\n\nsreal_compare (sreal *a, sreal *b)\n{\n  if (a->exp > b->exp)\n    return 1;\n  if (a->exp < b->exp)\n    return -1;\n  if (a->sig > b->sig)\n    return 1;\n  return -(a->sig < b->sig);\n}\n\nsreal a[] = {\n   { 0, 0 },\n   { 1, 0 },\n   { 0, 1 },\n   { 1, 1 }\n};\n\nint main()\n{\n  int i, j;\n  for (i = 0; i <= 3; i++) {\n    for (j = 0; j < 3; j++) {\n      if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();\n      if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();\n      if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120427-2.c",
    "content": "typedef struct sreal\n{\n  unsigned sig;\t\t/* Significant.  */\n  int exp;\t\t/* Exponent.  */\n} sreal;\n\nsreal_compare (sreal *a, sreal *b)\n{\n  if (a->exp > b->exp)\n    return 1;\n  if (a->exp < b->exp)\n    return -1;\n  if (a->sig > b->sig)\n    return 1;\n  if (a->sig < b->sig)\n    return -1;\n  return 0;\n}\n\nsreal a[] = {\n   { 0, 0 },\n   { 1, 0 },\n   { 0, 1 },\n   { 1, 1 }\n};\n\nint main()\n{\n  int i, j;\n  for (i = 0; i <= 3; i++) {\n    for (j = 0; j < 3; j++) {\n      if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();\n      if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();\n      if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120615-1.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline,noclone))\n     test1(int i)\n{\n  if (i == 12)\n    return;\n  if (i != 17)\n    {\n      if (i == 15)\n\treturn;\n      abort ();\n    }\n}\n\nint main() { test1 (15); return 0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120808-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nvolatile int i;\nunsigned char *volatile cp;\nunsigned char d[32] = { 0 };\n\nint\nmain (void)\n{\n  unsigned char c[32] = { 0 };\n  unsigned char *p = d + i;\n  int j;\n  for (j = 0; j < 30; j++)\n    {\n      int x = 0xff;\n      int y = *++p;\n      switch (j)\n\t{\n\tcase 1: x ^= 2; break;\n\tcase 2: x ^= 4; break;\n\tcase 25: x ^= 1; break;\n\tdefault: break;\n\t}\n      c[j] = y | x;\n      cp = p;\n    }\n  if (c[0] != 0xff\n      || c[1] != 0xfd\n      || c[2] != 0xfb\n      || c[3] != 0xff\n      || c[4] != 0xff\n      || c[25] != 0xfe\n      || cp != d + 30)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120817-1.c",
    "content": "typedef unsigned long long u64;\nunsigned long foo = 0;\nu64 f() __attribute__((noinline));\n\nu64 f() {\n  return ((u64)40) + ((u64) 24) * (int)(foo - 1);\n}\n\nint main ()\n{\n  if (f () != 16)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20120919-1.c",
    "content": "/* PR rtl-optimization/54290 */\n/* Testcase by Eric Volk <eriksnga@gmail.com> */\n/* { dg-require-effective-target int32plus } */\n\ndouble vd[2] = {1., 0.};\nint vi[2] = {1234567890, 0};\ndouble *pd = vd;\nint *pi = vi;\n\nextern void abort(void);\n\nvoid init (int *n, int *dummy) __attribute__ ((noinline,noclone));\n\nvoid init (int *n, int *dummy)\n{\n  if(0 == n) dummy[0] = 0;\n}\n\nint main (void)\n{\n  int dummy[1532];\n  int i = -1, n = 1, s = 0;\n  init (&n, dummy);\n  while (i < n) {\n    if (i == 0) {\n      if (pd[i] > 0) {\n        if (pi[i] > 0) {\n          s += pi[i];\n        }\n      }\n      pd[i] = pi[i];\n    }\n    ++i;\n  }\n  if (s != 1234567890)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20121108-1.c",
    "content": "char temp[] = \"192.168.190.160\";\nunsigned result = (((((192u<<8)|168u)<<8)|190u)<<8)|160u;\n\nint strtoul1(const char *a, char **b, int c) __attribute__((noinline, noclone));\nint strtoul1(const char *a, char **b, int c)\n{\n  *b = a+3;\n  if (a == temp)\n    return 192;\n  else if (a == temp+4)\n    return 168;\n  else if (a == temp+8)\n    return 190;\n  else if (a == temp+12)\n    return 160;\n  __builtin_abort();\n}\n\nint string_to_ip(const char *s) __attribute__((noinline,noclone));\nint string_to_ip(const char *s)\n{\n        int addr;\n        char *e;\n        int i;\n\n        if (s == 0)\n                return(0);\n\n        for (addr=0, i=0; i<4; ++i) {\n                int val = s ? strtoul1(s, &e, 10) : 0;\n                addr <<= 8;\n                addr |= (val & 0xFF);\n                if (s) {\n                        s = (*e) ? e+1 : e;\n                }\n        }\n\n        return addr;\n}\n\nint main(void)\n{\n  int t = string_to_ip (temp);\n  printf (\"%x\\n\", t);\n  printf (\"%x\\n\", result);\n  if (t != result)\n    __builtin_abort ();\n  printf (\"WORKS.\\n\");\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20131127-1.c",
    "content": "/* PR middle-end/59138 */\n/* Testcase by John Regehr <regehr@cs.utah.edu> */\n\nextern void abort (void);\n\n#pragma pack(1)\n\nstruct S0 {\n  int f0;\n  int f1;\n  int f2;\n  short f3;\n};\n\nshort a = 1;\n\nstruct S0 b = { 1 }, c, d, e;\n\nstruct S0 fn1() { return c; }\n\nvoid fn2 (void)\n{\n  b = fn1 ();\n  a = 0;\n  d = e;\n}\n\nint main (void)\n{\n  fn2 ();\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140212-1.c",
    "content": "/* PR rtl-optimization/60116 */\n/* Reported by Zhendong Su <su@cs.ucdavis.edu> */\n\nextern void abort (void);\n\nint a, b, c, d = 1, e, f = 1, h, i, k;\nchar g, j;\n\nvoid\nfn1 (void)\n{\n  int l;\n  e = 0;\n  c = 0;\n  for (;;)\n    {\n      k = a && b;\n      j = k * 54;\n      g = j * 147;\n      l = ~g + (long long) e && 1;\n      if (d)\n\tc = l;\n      else\n\th = i = l * 9UL;\n      if (f)\n\treturn;\n    }\n}\n\nint\nmain (void)\n{\n  fn1 ();\n  if (c != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140212-2.c",
    "content": "/* This used to fail as we would convert f into just return (unsigned int)usVlanID\n   which is wrong. */\n\nint f(unsigned short usVlanID) __attribute__((noinline,noclone));\nint f(unsigned short usVlanID)\n{\n  unsigned int uiVlanID = 0xffffffff;\n  int i;\n  if ((unsigned short)0xffff != usVlanID)\n    uiVlanID = (unsigned int)usVlanID;\n  return uiVlanID;\n}\n\nint main(void)\n{\n  if (f(1) != 1)\n    __builtin_abort ();\n  if (f(0xffff) != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140326-1.c",
    "content": "int a;\n\nint\nmain (void)\n{\n  char e[2] = { 0, 0 }, f = 0;\n  if (a == 131072)\n    f = e[a];\n  return f;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140425-1.c",
    "content": "/* PR target/60941 */\n/* Reported by Martin Husemann <martin@netbsd.org> */\n\nextern void abort (void);\n\nstatic void __attribute__((noinline))\nset (unsigned long *l)\n{\n  *l = 31;\n}\n\nint main (void)\n{\n  unsigned long l;\n  int i;\n\n  set (&l);\n  i = (int) l;\n  l = (unsigned long)(2U << i);\n  if (l != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140622-1.c",
    "content": "unsigned p;\n\nlong __attribute__((noinline, noclone))\ntest (unsigned a)\n{\n  return (long)(p + a) - (long)p;\n}\n\nint\nmain ()\n{\n  p = (unsigned) -2;\n  if (test (0) != 0)\n    __builtin_abort ();\n  if (test (1) != 1)\n    __builtin_abort ();\n  if (test (2) != -(long)(unsigned)-2)\n    __builtin_abort ();\n  p = (unsigned) -1;\n  if (test (0) != 0)\n    __builtin_abort ();\n  if (test (1) != -(long)(unsigned)-1)\n    __builtin_abort ();\n  if (test (2) != -(long)(unsigned)-2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20140828-1.c",
    "content": "short *f(short *a, int b, int *d) __attribute__((noinline,noclone));\n\nshort *f(short *a, int b, int *d)\n{\n  short c = *a;\n  a++;\n  c = b << c;\n  *d = c;\n  return a;\n}\n\nint main(void)\n{\n  int d;\n  short a[2];\n  a[0] = 0;\n  if (f(a, 1, &d) != &a[1])\n    __builtin_abort ();\n  if (d != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20141022-1.c",
    "content": "#define ABORT() do { __builtin_printf(\"assert.\\n\");  __builtin_abort (); }while(0)\nint f(int a) __attribute__((noinline));\nint f(int a)\n{\n  int fem_key_src;\n  int D2930 = a & 4294967291;\n  fem_key_src = a == 6 ? 0 : 15;\n  fem_key_src = D2930 != 1 ? fem_key_src : 0;\n  return fem_key_src;\n}\n\nint main(void)\n{\n  if (f(0) != 15)\n    ABORT ();\n  if (f(1) != 0)\n    ABORT ();\n  if (f(6) != 0)\n    ABORT ();\n  if (f(5) != 0)\n    ABORT ();\n  if (f(15) != 15)\n    ABORT ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20141107-1.c",
    "content": "#define bool _Bool\n\nbool f(int a, bool c) __attribute__((noinline));\nbool f(int a, bool c)\n{\n  if (!a)\n    c = !c;\n  return c;\n}\n\nvoid checkf(int a, bool b)\n{\n  bool c = f(a, b);\n  char d;\n  __builtin_memcpy (&d, &c, 1);\n  if ( d != (a==0)^b)\n    __builtin_abort();\n}\n\nint main(void)\n{\n  checkf(0, 0);\n  checkf(0, 1);\n  checkf(1, 1);\n  checkf(1, 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20141125-1.c",
    "content": "int f(long long a) __attribute__((noinline,noclone));\nint f(long long a)\n{\n  if (a & 0x3ffffffffffffffull)\n    return 1;\n  return 1024;\n}\n\nint main(void)\n{\n  if(f(0x48375d8000000000ull) != 1)\n    __builtin_abort ();\n  if (f(0xfc00000000000000ull) != 1024)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/20150611-1.c",
    "content": "int a, c, d;\nshort b;\n\nint\nmain ()\n{\n  int e[1];\n  for (; b < 2; b++)\n    {\n      a = 0;\n      if (b == 28378)\n        a = e[b];\n      if (!(d || b))\n        for (; c;)\n          ;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/900409-1.c",
    "content": "long f1(long a){return a&0xff000000L;}\nlong f2 (long a){return a&~0xff000000L;}\nlong f3(long a){return a&0x000000ffL;}\nlong f4(long a){return a&~0x000000ffL;}\nlong f5(long a){return a&0x0000ffffL;}\nlong f6(long a){return a&~0x0000ffffL;}\n\nmain ()\n{\n  long a = 0x89ABCDEF;\n\n  if (f1(a)!=0x89000000L||\n      f2(a)!=0x00ABCDEFL||\n      f3(a)!=0x000000EFL||\n      f4(a)!=0x89ABCD00L||\n      f5(a)!=0x0000CDEFL||\n      f6(a)!=0x89AB0000L)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920202-1.c",
    "content": "static int rule_text_needs_stack_pop = 0;\nstatic int input_stack_pos = 1;\n\nf (void)\n{\n  rule_text_needs_stack_pop = 1;\n\n  if (input_stack_pos <= 0)\n    return 1;\n  else\n    return 0;\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920302-1.c",
    "content": "short optab[5];\nchar buf[10];\nexecute (ip)\n     register short *ip;\n{\n#ifndef NO_LABEL_VALUES\n  register void *base = &&x;\n  char *bp = buf;\n  static void *tab[] = {&&x, &&y, &&z};\n  if (ip == 0)\n    {\n      int i;\n      for (i = 0; i < 3; ++i)\n\toptab[i] = (short)(tab[i] - base);\n      return;\n    }\nx:  *bp++='x';\n    goto *(base + *ip++);\ny:  *bp++='y';\n    goto *(base + *ip++);\nz:  *bp++='z';\n    *bp=0;\n    return;\n#else\n    strcpy (buf, \"xyxyz\");\n#endif\n}\n\nshort p[5];\n\nmain ()\n{\n  execute ((short *) 0);\n  p[0] = optab[1];\n  p[1] = optab[0];\n  p[2] = optab[1];\n  p[3] = optab[2];\n  execute (&p);\n  if (strcmp (buf, \"xyxyz\"))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920409-1.c",
    "content": "x(){signed char c=-1;return c<0;}main(){if(x()!=1)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920410-1.c",
    "content": "#define STACK_REQUIREMENT (40000 * 4 + 256)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\nmain(){int d[40000];d[0]=0;exit(0);}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920411-1.c",
    "content": "long f (w)\n     char *w;\n{\n  long k, i, c = 0, x;\n  char *p = (char*) &x;\n  for (i = 0; i < 1; i++)\n    {\n      for (k = 0; k < sizeof (long); k++)\n\tp[k] = w[k];\n      c += x;\n    }\n  return c;\n}\n\nmain ()\n{\n  int i;\n  char a[sizeof (long)];\n\n  for (i = sizeof (long); --i >= 0;) a[i] = ' ';\n  if (f (a) != ~0UL / (unsigned char) ~0 * ' ')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920415-1.c",
    "content": "#ifndef NO_LABEL_VALUES\nmain(){__label__ l;void*x(){return&&l;}goto*x();abort();return;l:exit(0);}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920428-1.c",
    "content": "x(const char*s){char a[1];const char*ss=s;a[*s++]|=1;return(int)ss+1==(int)s;}\nmain(){if(x(\"\")!=1)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920428-2.c",
    "content": "#if !defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\ns(i){if(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return f(i);l1:;}return 1;}\nx(){return s(0)==1&&s(1)==0&&s(2)==1;}\nmain(){if(x()!=1)abort();exit(0);}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920429-1.c",
    "content": "typedef unsigned char t;int i,j;\nt*f(t*p){t c;c=*p++;i=((c&2)?1:0);j=(c&7)+1;return p;}\nmain(){t*p0=\"ab\",*p1;p1=f(p0);if(p0+1!=p1)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nint s[2];\nx(){if(!s[0]){s[1+s[1]]=s[1];return 1;}}\nmain(){s[0]=s[1]=0;if(x(0)!=1)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-2.c",
    "content": "unsigned long\ngcd_ll (unsigned long long x, unsigned long long y)\n{\n  for (;;)\n    {\n      if (y == 0)\n\treturn (unsigned long) x;\n      x = x % y;\n      if (x == 0)\n\treturn (unsigned long) y;\n      y = y % x;\n    }\n}\n\nunsigned long long\npowmod_ll (unsigned long long b, unsigned e, unsigned long long m)\n{\n  unsigned t;\n  unsigned long long pow;\n  int i;\n\n  if (e == 0)\n    return 1;\n\n  /* Find the most significant bit in E.  */\n  t = e;\n  for (i = 0; t != 0; i++)\n    t >>= 1;\n\n  /* The most sign bit in E is handled outside of the loop, by beginning\n     with B in POW, and decrementing I.  */\n  pow = b;\n  i -= 2;\n\n  for (; i >= 0; i--)\n    {\n      pow = pow * pow % m;\n      if ((1 << i) & e)\n\tpow = pow * b % m;\n    }\n\n  return pow;\n}\n\nunsigned long factab[10];\n\nvoid\nfacts (t, a_int, x0, p)\n     unsigned long long t;\n     int a_int;\n     int x0;\n     unsigned p;\n{\n  unsigned long *xp = factab;\n  unsigned long long x, y;\n  unsigned long q = 1;\n  unsigned long long a = a_int;\n  int i;\n  unsigned long d;\n  int j = 1;\n  unsigned long tmp;\n  int jj = 0;\n\n  x = x0;\n  y = x0;\n\n  for (i = 1; i < 10000; i++)\n    {\n      x = powmod_ll (x, p, t) + a;\n      y = powmod_ll (y, p, t) + a;\n      y = powmod_ll (y, p, t) + a;\n\n      if (x > y)\n\ttmp = x - y;\n      else\n\ttmp = y - x;\n      q = (unsigned long long) q * tmp % t;\n\n      if (i == j)\n\t{\n\t  jj += 1;\n\t  j += jj;\n\t  d = gcd_ll (q, t);\n\t  if (d != 1)\n\t    {\n\t      *xp++ = d;\n\t      t /= d;\n\t      if (t == 1)\n\t\t{\n\t\t  return;\n\t\t  *xp = 0;\n\t\t}\n\t    }\n\t}\n    }\n}\n\nmain ()\n{\n  unsigned long long t;\n  unsigned x0, a;\n  unsigned p;\n\n  p = 27;\n  t = (1ULL << p) - 1;\n\n  a = -1;\n  x0 = 3;\n\n  facts (t, a, x0, p);\n  if (factab[0] != 7 || factab[1] != 73 || factab[2] != 262657)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-3.c",
    "content": "int tab[9];\nexecute(oip, ip)\n     unsigned short *oip, *ip;\n{\n#ifndef NO_LABEL_VALUES\n  int x = 0;\n  int *xp = tab;\nbase:\n  x++;\n  if (x == 4)\n    {\n      *xp = 0;\n      return;\n    }\n  *xp++ = ip - oip;\n  goto *(&&base + *ip++);\n#else\n  tab[0] = 0;\n  tab[1] = 1;\n  tab[2] = 2;\n  tab[3] = 0;\n#endif\n}\n\nmain()\n{\n  unsigned short ip[10];\n  int i;\n  for (i = 0; i < 10; i++)\n    ip[i] = 0;\n  execute(ip, ip);\n  if (tab[0] != 0 || tab[1] != 1 || tab[2] != 2 || tab[3] != 0)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-4.c",
    "content": "#ifndef NO_LABEL_VALUES\nint\nx (int i)\n{\n  static const void *j[] = {&& x, && y, && z};\n  \n  goto *j[i];\n  \n x: return 2;\n y: return 3;\n z: return 5;\n}\n\nint\nmain (void)\n{\n  if (   x (0) != 2\n      || x (1) != 3\n      || x (2) != 5)\n    abort ();\n\n  exit (0);\n}\n#else\nint\nmain (void) { exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-5.c",
    "content": "#ifndef NO_LABEL_VALUES\nx (int i)\n{\n  void *j[] = {&&x, &&y, &&z};\n  goto *j[i];\n x:return 2;\n y:return 3;\n z:return 5;\n\n}\nmain ()\n{\n  if (x (0) != 2 || x (1) != 3 || x (2) != 5)\n    abort();\n  exit(0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-6.c",
    "content": "#include <stdio.h>\n\n/* Convert a decimal string to a long long unsigned.  No error check is\n   performed.  */\n\nlong long unsigned\nstr2llu (str)\n     char *str;\n{\n  long long unsigned acc;\n  int d;\n  acc =  *str++ - '0';\n  for (;;)\n    {\n      d = *str++;\n      if (d == '\\0')\n\tbreak;\n      d -= '0';\n      acc = acc * 10 + d;\n    }\n\n  return acc;\n}\n\n/* isqrt(t) - computes the square root of t. (tege 86-10-27) */\n\nlong unsigned\nsqrtllu (long long unsigned t)\n{\n  long long unsigned s;\n  long long unsigned b;\n\n  for (b = 0, s = t;  b++, (s >>= 1) != 0; )\n    ;\n\n  s = 1LL << (b >> 1);\n\n  if (b & 1)\n    s += s >> 1;\n\n  do\n    {\n      b = t / s;\n      s = (s + b) >> 1;\n    }\n  while (b < s);\n\n  return s;\n}\n\n\nint plist (p0, p1, tab)\n     long long unsigned p0, p1;\n     long long unsigned *tab;\n{\n  long long unsigned p;\n  long unsigned d;\n  long unsigned s;\n  long long unsigned *xp = tab;\n\n  for (p = p0;  p <= p1;  p += 2)\n    {\n      s = sqrtllu (p);\n\n      for (d = 3;  d <= s;  d += 2)\n\t{\n\t  long long unsigned q = p % d;\n\t  if (q == 0)\n\t    goto not_prime;\n\t}\n\n      *xp++ = p;\n    not_prime:;\n    }\n  *xp = 0;\n  return xp - tab;\n}\n\nmain (argc, argv)\n     int argc;\n     char *argv[];\n{\n  long long tab[10];\n  int nprimes;\n  nprimes = plist (str2llu (\"1234111111\"), str2llu (\"1234111127\"), tab);\n\n  if(tab[0]!=1234111117LL||tab[1]!=1234111121LL||tab[2]!=1234111127LL||tab[3]!=0)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-7.c",
    "content": "#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 1000\n#endif\n\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\nx(a)\n{\n  __label__ xlab;\n  void y(a)\n    {\n      if (a==0)\n\tgoto xlab;\n      y (a-1);\n    }\n  y (a);\n xlab:;\n  return a;\n}\n#endif\n\nmain ()\n{\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\n  if (x (DEPTH) != DEPTH)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-8.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\n\nchar buf[50];\nint\nva (int a, double b, int c, ...)\n{\n  va_list ap;\n  int d, e, f, g, h, i, j, k, l, m, n, o, p;\n  va_start (ap, c);\n\n  d = va_arg (ap, int);\n  e = va_arg (ap, int);\n  f = va_arg (ap, int);\n  g = va_arg (ap, int);\n  h = va_arg (ap, int);\n  i = va_arg (ap, int);\n  j = va_arg (ap, int);\n  k = va_arg (ap, int);\n  l = va_arg (ap, int);\n  m = va_arg (ap, int);\n  n = va_arg (ap, int);\n  o = va_arg (ap, int);\n  p = va_arg (ap, int);\n\n  sprintf (buf,\n\t   \"%d,%f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\",\n\t   a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);\n  va_end (ap);\n}\n\nmain()\n{\n  va (1, 1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  if (strcmp (\"1,1.000000,2,3,4,5,6,7,8,9,10,11,12,13,14,15\", buf))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920501-9.c",
    "content": "#include <stdio.h>\n\nlong long proc1(){return 1LL;}\nlong long proc2(){return 0x12345678LL;}\nlong long proc3(){return 0xaabbccdd12345678LL;}\nlong long proc4(){return -1LL;}\nlong long proc5(){return 0xaabbccddLL;}\n\nprint_longlong(x,buf)\n     long long x;\n     char *buf;\n{\n  unsigned long l;\n  l= (x >> 32) & 0xffffffff;\n  if (l != 0)\n    sprintf(buf,\"%lx%08.lx\",l,((unsigned long)x & 0xffffffff));\n  else\n    sprintf(buf,\"%lx\",((unsigned long)x & 0xffffffff));\n}\n\nmain(){char buf[100];\nprint_longlong(proc1(),buf);if(strcmp(\"1\",buf))abort();\nprint_longlong(proc2(),buf);if(strcmp(\"12345678\",buf))abort();\nprint_longlong(proc3(),buf);if(strcmp(\"aabbccdd12345678\",buf))abort();\nprint_longlong(proc4(),buf);if(strcmp(\"ffffffffffffffff\",buf))abort();\nprint_longlong(proc5(),buf);if(strcmp(\"aabbccdd\",buf))abort();\nexit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920506-1.c",
    "content": "int l[]={0,1};\nmain(){int*p=l;switch(*p++){case 0:exit(0);case 1:break;case 2:break;case 3:case 4:break;}abort();}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920520-1.c",
    "content": "foo(int *bar)\n{\n  *bar = 8;\n}\n\nbugger()\n{\n  int oldDepth, newDepth;\n\n  foo(&oldDepth);\n\n  switch (oldDepth)\n    {\n    case 8:\n    case 500:\n      newDepth = 8;\n      break;\n\n    case 5000:\n      newDepth = 500;\n      break;\n\n    default:\n      newDepth = 17;\n      break;\n    }\n\n  return newDepth - oldDepth;\n}\n\nmain()\n{\n  if (bugger() != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920603-1.c",
    "content": "f(got){if(got!=0xffff)abort();}\nmain(){signed char c=-1;unsigned u=(unsigned short)c;f(u);exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920604-1.c",
    "content": "long long\nmod (a, b)\n     long long a, b;\n{\n  return a % b;\n}\n\nint\nmain ()\n{\n  mod (1LL, 2LL);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920612-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint f(j)int j;{return++j>0;}\nint main(){if(f((~0U)>>1))abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920612-2.c",
    "content": "main ()\n{\n  int i = 0;\n  int a (int x)\n    {\n      while (x)\n\ti++, x--;\n      return x;\n    }\n#ifndef NO_TRAMPOLINES\n  if (a (2) != 0)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920618-1.c",
    "content": "main(){if(1.17549435e-38F<=1.1)exit(0);abort();}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920625-1.c",
    "content": "#include <stdarg.h>\n\ntypedef struct{double x,y;}point;\npoint pts[]={{1.0,2.0},{3.0,4.0},{5.0,6.0},{7.0,8.0}};\nstatic int va1(int nargs,...)\n{\n  va_list args;\n  int i;\n  point pi;\n  va_start(args,nargs);\n  for(i=0;i<nargs;i++){\n    pi=va_arg(args,point);\n    if(pts[i].x!=pi.x||pts[i].y!=pi.y)abort();\n  }\n  va_end(args);\n}\n\ntypedef struct{int x,y;}ipoint;\nipoint ipts[]={{1,2},{3,4},{5,6},{7,8}};\nstatic int va2(int nargs,...)\n{\n  va_list args;\n  int i;\n  ipoint pi;\n  va_start(args,nargs);\n  for(i=0;i<nargs;i++){\n    pi=va_arg(args,ipoint);\n    if(ipts[i].x!=pi.x||ipts[i].y!=pi.y)abort();\n  }\n  va_end(args);\n}\n\nmain()\n{\nva1(4,pts[0],pts[1],pts[2],pts[3]);\nva2(4,ipts[0],ipts[1],ipts[2],ipts[3]);\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920710-1.c",
    "content": "main()\n{\n  if ((double) 18446744073709551615ULL < 1.84467440737095e+19 ||\n      (double) 18446744073709551615ULL > 1.84467440737096e+19)\n    abort();\n\n  if (16777217L != (float)16777217e0)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920711-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint f(long a){return (--a > 0);}\nint main(){if(f(0x80000000L)==0)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920721-1.c",
    "content": "long f(short a,short b){return (long)a/b;}\nmain(){if(f(-32768,-1)!=32768L)abort();else exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920721-2.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nf(){}\nmain(){int n=2;double x[n];f();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920721-3.c",
    "content": "static inline fu (unsigned short data)\n{\n  return data;\n}\nru(i)\n{\n   if(fu(i++)!=5)abort();\n   if(fu(++i)!=7)abort();\n}\nstatic inline fs (signed short data)\n{\n  return data;\n}\nrs(i)\n{\n   if(fs(i++)!=5)abort();\n   if(fs(++i)!=7)abort();\n}\n\n\nmain()\n{\n  ru(5);\n  rs(5);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920721-4.c",
    "content": "#ifndef NO_LABEL_VALUES\nint try (int num) {\n  __label__ lab1, lab2, lab3, lab4, lab5, lab6, default_lab;\n\n  void *do_switch (int num) {\n    switch(num) {\n    case 1:\n      return &&lab1;\n    case 2:\n      return &&lab2;\n    case 3:\n      return &&lab3;\n    case 4:\n      return &&lab4;\n    case 5:\n      return &&lab5;\n    case 6:\n      return &&lab6;\n    default:\n      return &&default_lab;\n    }\n  }\n\n  goto *do_switch (num);\n\n lab1:\n  return 1;\n\n lab2:\n  return 2;\n\n lab3:\n  return 3;\n\n lab4:\n  return 4;\n\n lab5:\n  return 5;\n\n lab6:\n  return 6;\n\n default_lab:\n  return -1;\n}\n\nmain()\n{\n  int i;\n  for (i = 1; i <= 6; i++)\n    {\n      if (try (i) != i)\n\tabort();\n    }\n  exit(0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920726-1.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\n\nstruct spurious\n{\n    int anumber;\n};\n\nint first(char *buf, char *fmt, ...)\n{\n  int pos, number;\n  va_list args;\n  int dummy;\n  char *bp = buf;\n\n  va_start(args, fmt);\n  for (pos = 0; fmt[pos]; pos++)\n    if (fmt[pos] == 'i')\n      {\n\tnumber = va_arg(args, int);\n\tsprintf(bp, \"%d\", number);\n\tbp += strlen(bp);\n      }\n    else\n      *bp++ = fmt[pos];\n\n  va_end(args);\n  *bp = 0;\n  return dummy;\n}\n\nstruct spurious second(char *buf,char *fmt, ...)\n{\n  int pos, number;\n  va_list args;\n  struct spurious dummy;\n  char *bp = buf;\n\n  va_start(args, fmt);\n  for (pos = 0; fmt[pos]; pos++)\n    if (fmt[pos] == 'i')\n      {\n\tnumber = va_arg(args, int);\n\tsprintf(bp, \"%d\", number);\n\tbp += strlen(bp);\n      }\n    else\n      *bp++ = fmt[pos];\n\n  va_end(args);\n  *bp = 0;\n  return dummy;\n}\n\nmain()\n{\n  char buf1[100], buf2[100];\n  first(buf1, \"i i \", 5, 20);\n  second(buf2, \"i i \", 5, 20);\n  if (strcmp (\"5 20 \", buf1) || strcmp (\"5 20 \", buf2))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920728-1.c",
    "content": "typedef struct {int dims[0]; } *A;\n\nf(unsigned long obj)\n{\n  unsigned char y = obj >> 24;\n  y &= ~4;\n\n  if ((y==0)||(y!=251  ))\n    abort();\n\n  if(((int)obj&7)!=7)return;\n\n  REST_OF_CODE_JUST_HERE_TO_TRIGGER_THE_BUG:\n\n  {\n    unsigned char t = obj >> 24;\n    if (!(t==0)&&(t<=0x03))\n      return 0;\n    return ((A)(obj&0x00FFFFFFL))->dims[1];\n  }\n}\n\nlong g(){return 0xff000000L;}\nmain (){int x;f(g());exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920730-1.c",
    "content": "/* 920730-1.c */\n#include <limits.h>\nf1()\n{\n\tint b=INT_MIN;\n\treturn b>=INT_MIN;\n}\n\nf2()\n{\n\tint b=INT_MIN+1;\n\treturn b>= (unsigned)(INT_MAX+2);\n}\n\nf3()\n{\n\tint b=INT_MAX;\n\treturn b>=INT_MAX;\n}\n\nf4()\n{\n\tint b=-1;\n\treturn b>=UINT_MAX;\n}\n\nmain ()\n{\n\tif((f1()&f2()&f3()&f4())!=1)\n\t\tabort();\n\t\texit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920731-1.c",
    "content": "f(x){int i;for(i=0;i<8&&(x&1)==0;x>>=1,i++);return i;}\nmain(){if(f(4)!=2)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920810-1.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\ntypedef struct{void*super;int name;int size;}t;\nt*f(t*clas,int size)\n{\n  t*child=(t*)malloc(size);\n  memcpy(child,clas,clas->size);\n  child->super=clas;\n  child->name=0;\n  child->size=size;\n  return child;\n}\nmain()\n{\n  t foo,*bar;\n  memset(&foo,37,sizeof(t));\n  foo.size=sizeof(t);\n  bar=f(&foo,sizeof(t));\n  if(bar->super!=&foo||bar->name!=0||bar->size!=sizeof(t))abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920812-1.c",
    "content": "typedef int t;\nf(t y){switch(y){case 1:return 1;}return 0;}\nmain(){if(f((t)1)!=1)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920829-1.c",
    "content": "long long c=2863311530LL,c3=2863311530LL*3;\nmain(){if(c*3!=c3)abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920908-1.c",
    "content": "/* REPRODUCED:RUN:SIGNAL MACHINE:mips OPTIONS: */\n\n#include <stdarg.h>\n\ntypedef struct{int A;}T;\n\nT f(int x,...)\n{\nva_list ap;\nT X;\nva_start(ap,x);\nX=va_arg(ap,T);\nif(X.A!=10)abort();\nX=va_arg(ap,T);\nif(X.A!=20)abort();\nva_end(ap);\nreturn X;\n}\n\nmain()\n{\nT X,Y;\nint i;\nX.A=10;\nY.A=20;\nf(2,X,Y);\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920908-2.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\n/*\nCONF:m68k-sun-sunos4.1.1\nOPTIONS:-O\n*/\nstruct T\n{\nunsigned i:8;\nunsigned c:24;\n};\nf(struct T t)\n{\nstruct T s[1];\ns[0]=t;\nreturn(char)s->c;\n}\nmain()\n{\nstruct T t;\nt.i=0xff;\nt.c=0xffff11;\nif(f(t)!=0x11)abort();\nexit(0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920909-1.c",
    "content": "f(a){switch(a){case 0x402:return a+1;case 0x403:return a+2;case 0x404:return a+3;case 0x405:return a+4;case 0x406:return 1;case 0x407:return 4;}return 0;}\nmain(){if(f(1))abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920922-1.c",
    "content": "unsigned long*\nf(p)unsigned long*p;\n{\n  unsigned long a = (*p++) >> 24;\n  return p + a;\n}\n\nmain ()\n{\n  unsigned long x = 0x80000000UL;\n  if (f(&x) != &x + 0x81)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/920929-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n/* REPRODUCED:RUN:SIGNAL MACHINE:sparc OPTIONS: */\nf(int n)\n{\nint i;\ndouble v[n];\nfor(i=0;i<n;i++)\nv[i]=0;\n}\nmain()\n{\nf(100);\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921006-1.c",
    "content": "/* REPRODUCED:RUN:SIGNAL MACHINE:i386 OPTIONS:-O */\nmain()\n{\nif(strcmp(\"X\",\"\")<0)abort();\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921007-1.c",
    "content": "static int strcmp(){return-1;}\n#define strcmp __builtin_strcmp\nmain()\n{\nif(strcmp(\"X\",\"X\\376\")>=0)abort();\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921013-1.c",
    "content": "f(d,x,y,n)\nint*d;\nfloat*x,*y;\nint n;\n{\n  while(n--){*d++=*x++==*y++;}\n}\n\nmain()\n{\n  int r[4];\n  float a[]={5,1,3,5};\n  float b[]={2,4,3,0};\n  int i;\n  f(r,a,b,4);\n  for(i=0;i<4;i++)\n    if((a[i]==b[i])!=r[i])\n      abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921016-1.c",
    "content": "main()\n{\nint j=1081;\nstruct\n{\nsigned int m:11;\n}l;\nif((l.m=j)==j)abort();\nexit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921017-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nf(n)\n{\n  int a[n];\n  int g(i)\n    {\n      return a[i];\n    }\n  a[1]=4711;\n  return g(1);\n}\nmain()\n{\n#ifndef NO_TRAMPOLINES\n  if(f(2)!=4711)abort();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921019-1.c",
    "content": "void *foo[]={(void *)&(\"X\"[0])};\n\nmain ()\n{\n  if (((char*)foo[0])[0] != 'X')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921019-2.c",
    "content": "main()\n{\n  double x,y=0.5;\n  x=y/0.2;\n  if(x!=x)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921029-1.c",
    "content": "typedef unsigned long long ULL;\nULL back;\nULL hpart, lpart;\nULL\nbuild(long h, long l)\n{\n  hpart = h;\n  hpart <<= 32;\n  lpart = l;\n  lpart &= 0xFFFFFFFFLL;\n  back = hpart | lpart;\n  return back;\n}\n\nmain()\n{\n  if (build(0, 1) != 0x0000000000000001LL)\n    abort();\n  if (build(0, 0) != 0x0000000000000000LL)\n    abort();\n  if (build(0, 0xFFFFFFFF) != 0x00000000FFFFFFFFLL)\n    abort();\n  if (build(0, 0xFFFFFFFE) != 0x00000000FFFFFFFELL)\n    abort();\n  if (build(1, 1) != 0x0000000100000001LL)\n    abort();\n  if (build(1, 0) != 0x0000000100000000LL)\n    abort();\n  if (build(1, 0xFFFFFFFF) != 0x00000001FFFFFFFFLL)\n    abort();\n  if (build(1, 0xFFFFFFFE) != 0x00000001FFFFFFFELL)\n    abort();\n  if (build(0xFFFFFFFF, 1) != 0xFFFFFFFF00000001LL)\n    abort();\n  if (build(0xFFFFFFFF, 0) != 0xFFFFFFFF00000000LL)\n    abort();\n  if (build(0xFFFFFFFF, 0xFFFFFFFF) != 0xFFFFFFFFFFFFFFFFLL)\n    abort();\n  if (build(0xFFFFFFFF, 0xFFFFFFFE) != 0xFFFFFFFFFFFFFFFELL)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921104-1.c",
    "content": "main ()\n{\n  unsigned long val = 1;\n\n  if (val > (unsigned long) ~0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921110-1.c",
    "content": "extern int abort();\ntypedef int (*frob)();\nfrob f[] = {abort};\nmain()\n{\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921112-1.c",
    "content": "union u {\n  struct { int i1, i2; } t;\n  double d;\n} x[2], v;\n\nf (x, v)\n     union u *x, v;\n{\n  *++x = v;\n}\n\nmain()\n{\n  x[1].t.i1 = x[1].t.i2 = 0;\n  v.t.i1 = 1;\n  v.t.i2 = 2;\n  f (x, v);\n  if (x[1].t.i1 != 1 || x[1].t.i2 != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921113-1.c",
    "content": "#define STACK_REQUIREMENT (128 * 128 * 4 + 1024)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\n\ntypedef struct {\n  float wsx;\n} struct_list;\n\ntypedef struct_list *list_t;\n\ntypedef struct {\n  float x, y;\n} vector_t;\n\nw(float x, float y) {}\n\nf1(float x, float y)\n{\n  if (x != 0 || y != 0)\n    abort();\n}\nf2(float x, float y)\n{\n  if (x != 1 || y != 1)\n    abort();\n}\n\ngitter(int count, vector_t pos[], list_t list, int *nww, vector_t limit[2], float r)\n{\n  float d;\n  int gitt[128][128];\n\n  f1(limit[0].x, limit[0].y);\n  f2(limit[1].x, limit[1].y);\n\n  *nww = 0;\n\n  d = pos[0].x;\n  if (d <= 0.)\n    {\n      w(d, r);\n      if (d <= r * 0.5)\n\t{\n\t  w(d, r);\n\t  list[0].wsx = 1;\n\t}\n    }\n}\n\nvector_t pos[1] = {{0., 0.}};\nvector_t limit[2] = {{0.,0.},{1.,1.}};\n\nmain()\n{\n  int nww;\n  struct_list list;\n\n  gitter(1, pos, &list, &nww, limit, 1.);\n  exit(0);\n}\n\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921117-1.c",
    "content": "struct s {\n  char text[11];\n  int flag;\n} cell;\n\nint\ncheck (struct s p)\n{\n  if (p.flag != 99)\n    return 1;\n  return strcmp (p.text, \"0123456789\");\n}\n\nmain ()\n{\n  cell.flag = 99;\n  strcpy (cell.text, \"0123456789\");\n\n  if (check (cell))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921123-1.c",
    "content": "f(short *p)\n{\n  short x = *p;\n  return (--x < 0);\n}\n\nmain()\n{\n  short x = -10;\n  if (!f(&x))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921123-2.c",
    "content": "typedef struct\n{\n  unsigned short b0, b1, b2, b3;\n} four_quarters;\n\nfour_quarters x;\nint a, b;\n\nvoid f (four_quarters j)\n{\n  b = j.b2;\n  a = j.b3;\n}\n\nmain ()\n{\n  four_quarters x;\n  x.b0 = x.b1 = x.b2 = 0;\n  x.b3 = 38;\n  f(x);\n  if (a != 38)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921124-1.c",
    "content": "f(x, d1, d2, d3)\n   double d1, d2, d3;\n{\n   return x;\n}\n\ng(b,s,x,y,i,j)\n     char *b,*s;\n     double x,y;\n{\n  if (x != 1.0 || y != 2.0 || i != 3 || j != 4)\n    abort();\n}\n\nmain()\n{\n  g(\"\",\"\", 1.0, 2.0, f(3, 0.0, 0.0, 0.0), f(4, 0.0, 0.0, 0.0));\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921202-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n#ifndef STACK_SIZE\n#define\tVLEN\t2055\n#else\n#define VLEN ((STACK_SIZE/16) - 1)\n#endif\nmain ()\n{\n  long dx[VLEN+1];\n  long dy[VLEN+1];\n  long s1[VLEN];\n  int cyx, cyy;\n  int i;\n  long size;\n\n  for (;;)\n    {\n      size = VLEN;\n      mpn_random2 (s1, size);\n\n      for (i = 0; i < 1; i++)\n\t;\n\n      dy[size] = 0x12345678;\n\n      for (i = 0; i < 1; i++)\n\tcyy = mpn_mul_1 (dy, s1, size);\n\n      if (cyx != cyy || mpn_cmp (dx, dy, size + 1) != 0 || dx[size] != 0x12345678)\n\t{\n\t  foo (\"\", 8, cyy); mpn_print (dy, size);\n\t}\n      exxit();\n    }\n}\n\nfoo (){}\nmpn_mul_1(){}\nmpn_print (){}\nmpn_random2(){}\nmpn_cmp(){}\nexxit(){exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921202-2.c",
    "content": "int\nf(long long x)\n{\n  x >>= 8;\n  return x & 0xff;\n}\n\nmain()\n{\n  if (f(0x0123456789ABCDEFLL) != 0xCD)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921204-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\ntypedef struct {\n  unsigned b0:1, f1:17, b18:1, b19:1, b20:1, f2:11;\n} bf;\n\ntypedef union {\n  bf b;\n  unsigned w;\n} bu;\n\nbu\nf(bu i)\n{\n  bu o = i;\n\n  if (o.b.b0)\n    o.b.b18 = 1,\n    o.b.b20 = 1;\n  else\n    o.b.b18 = 0,\n    o.b.b20 = 0;\n\n  return o;\n}\n\nmain()\n{\n  bu a;\n  bu r;\n\n  a.w = 0x4000000;\n  a.b.b0 = 0;\n  r = f(a);\n  if (a.w != r.w)\n    abort();\n  exit(0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921207-1.c",
    "content": "f()\n{\n  unsigned b = 0;\n\n  if (b > ~0U)\n    b = ~0U;\n\n  return b;\n}\nmain()\n{\n  if (f()!=0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921208-1.c",
    "content": "double\nf(double x)\n{\n  return x*x;\n}\n\ndouble\nInt(double (*f)(double), double a)\n{\n  return (*f)(a);\n}\n\nmain()\n{\n  if (Int(&f,2.0) != 4.0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921208-2.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n#define STACK_REQUIREMENT (100000 * 4 + 1024)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\n\ng(){}\n\nf()\n{\n  int i;\n  float a[100000];\n\n  for (i = 0; i < 1; i++)\n    {\n      g(1.0, 1.0 + i / 2.0 * 3.0);\n      g(2.0, 1.0 + i / 2.0 * 3.0);\n    }\n}\n\nmain ()\n{\n  f();\n  exit(0);\n}\n\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921215-1.c",
    "content": "main()\n{\n#ifndef NO_TRAMPOLINES\n  void p(void ((*f) (void ())))\n    {\n      void r()\n\t{\n\t  foo ();\n\t}\n\n      f(r);\n    }\n\n  void q(void ((*f)()))\n    {\n      f();\n    }\n\n  p(q);\n#endif\n  exit(0);\n}\n\nfoo(){}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921218-1.c",
    "content": "f()\n{\n  return (unsigned char)(\"\\377\"[0]);\n}\n\nmain()\n{\n  if (f() != (unsigned char)(0377))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/921218-2.c",
    "content": "f()\n{\n  long l2;\n  unsigned short us;\n  unsigned long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nmain()\n{\n  if (f()!=(unsigned short)-1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930106-1.c",
    "content": "#if defined (STACK_SIZE)\n#define DUMMY_SIZE 9\n#else\n#define DUMMY_SIZE 399999\n#endif\n\ndouble g()\n{\n  return 1.0;\n}\n\nf()\n{\n  char dummy[DUMMY_SIZE];\n  double f1, f2, f3;\n  f1 = g();\n  f2 = g();\n  f3 = g();\n  return f1 + f2 + f3;\n}\n\nmain()\n{\n  if (f() != 3.0)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930111-1.c",
    "content": "main()\n{\n  if (wwrite((long long) 0) != 123)\n    abort();\n  exit(0);\n}\n\nint\nwwrite(long long i)\n{\n  switch(i)\n    {\n    case 3:\n    case 10:\n    case 23:\n    case 28:\n    case 47:\n      return 0;\n    default:\n      return 123;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930123-1.c",
    "content": "f(int *x)\n{\n  *x = 0;\n}\n\nmain()\n{\n  int s, c, x;\n  char a[] = \"c\";\n\n  f(&s);\n  a[c = 0] = s == 0 ? (x=1, 'a') : (x=2, 'b');\n  if (a[c] != 'a')\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930126-1.c",
    "content": "struct s {\n  unsigned long long a:8, b:32;\n};\n\nstruct s\nf(struct s x)\n{\n  x.b = 0xcdef1234;\n  return x;\n}\n\nmain()\n{\n  static struct s i;\n  i.a = 12;\n  i = f(i);\n  if (i.a != 12 || i.b != 0xcdef1234)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930208-1.c",
    "content": "typedef union {\n  long l;\n  struct { char b3, b2, b1, b0; } c;\n} T;\n\nf (T u)\n{\n  ++u.c.b0;\n  ++u.c.b3;\n  return (u.c.b1 != 2 || u.c.b2 != 2);\n}\n\nmain ()\n{\n  T u;\n  u.c.b1 = 2;\n  u.c.b2 = 2;\n  u.c.b0 = ~0;\n  u.c.b3 = ~0;\n  if (f (u))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930406-1.c",
    "content": "f()\n{\n  int x = 1;\n#if defined(STACK_SIZE)\n  char big[STACK_SIZE/2];\n#else\n  char big[0x1000];\n#endif\n\n  ({\n    __label__ mylabel;\n  mylabel:\n    x++;\n    if (x != 3)\n      goto mylabel;\n  });\n  exit(0);\n}\n\nmain()\n{\n  f();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930408-1.c",
    "content": "typedef enum foo E;\nenum foo { e0, e1 };\n\nstruct {\n  E eval;\n} s;\n\np()\n{\n  abort();\n}\n\nf()\n{\n  switch (s.eval)\n    {\n    case e0:\n      p();\n    }\n}\n\nmain()\n{\n  s.eval = e1;\n  f();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930429-1.c",
    "content": "char *\nf (char *p)\n{\n  short x = *p++ << 16;\n  return p;\n}\n\nmain ()\n{\n  char *p = \"\";\n  if (f (p) != p + 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930429-2.c",
    "content": "int\nf (b)\n{\n  return (b >> 1) > 0;\n}\n\nmain ()\n{\n  if (!f (9))\n    abort ();\n  if (f (-9))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930513-1.c",
    "content": "#include <stdio.h>\nchar buf[2];\n\nf (fp)\n     int (*fp)(char *, const char *, ...);\n{\n  (*fp)(buf, \"%.0f\", 5.0);\n}\n\nmain ()\n{\n  f (&sprintf);\n  if (buf[0] != '5' || buf[1] != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930513-2.c",
    "content": "sub3 (i)\n     const int *i;\n{\n}\n\neq (a, b)\n{\n  static int i = 0;\n  if (a != i)\n    abort ();\n  i++;\n}\n\nmain ()\n{\n  int i;\n\n  for (i = 0; i < 4; i++)\n    {\n      const int j = i;\n      int k;\n      sub3 (&j);\n      k = j;\n      eq (k, k);\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930518-1.c",
    "content": "int bar = 0;\n\nf (p)\n     int *p;\n{\n  int foo = 2;\n\n  while (foo > bar)\n    {\n      foo -=  bar;\n      *p++ = foo;\n      bar = 1;\n    }\n}\n\nmain ()\n{\n  int tab[2];\n  tab[0] = tab[1] = 0;\n  f (tab);\n  if (tab[0] != 2 || tab[1] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930526-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void exit (int);\n\ninline void\nf (int x)\n{\n  int *(p[25]);\n  int m[25*7];\n  int i;\n\n  for (i = 0; i < 25; i++)\n    p[i] = m + x*i;\n\n  p[1][0] = 0;\n}\n\nint\nmain ()\n{\n  f (7);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930527-1.c",
    "content": "f (unsigned char x)\n{\n  return (0x50 | (x >> 4)) ^ 0xff;\n}\n\nmain ()\n{\n  if (f (0) != 0xaf)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930529-1.c",
    "content": "/* { dg-options { \"-fwrapv\" } } */\n\nextern void abort (void);\nextern void exit (int);\n\nint dd (int x, int d) { return x / d; }\n\nint\nmain ()\n{\n  int i;\n  for (i = -3; i <= 3; i++)\n    {\n      if (dd (i, 1) != i / 1)\n\tabort ();\n      if (dd (i, 2) != i / 2)\n\tabort ();\n      if (dd (i, 3) != i / 3)\n\tabort ();\n      if (dd (i, 4) != i / 4)\n\tabort ();\n      if (dd (i, 5) != i / 5)\n\tabort ();\n      if (dd (i, 6) != i / 6)\n\tabort ();\n      if (dd (i, 7) != i / 7)\n\tabort ();\n      if (dd (i, 8) != i / 8)\n\tabort ();\n    }\n  for (i = ((unsigned) ~0 >> 1) - 3; i <= ((unsigned) ~0 >> 1) + 3; i++)\n    {\n      if (dd (i, 1) != i / 1)\n\tabort ();\n      if (dd (i, 2) != i / 2)\n\tabort ();\n      if (dd (i, 3) != i / 3)\n\tabort ();\n      if (dd (i, 4) != i / 4)\n\tabort ();\n      if (dd (i, 5) != i / 5)\n\tabort ();\n      if (dd (i, 6) != i / 6)\n\tabort ();\n      if (dd (i, 7) != i / 7)\n\tabort ();\n      if (dd (i, 8) != i / 8)\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930603-1.c",
    "content": "float fx (x)\n     float x;\n{\n  return 1.0 + 3.0 / (2.302585093 * x);\n}\n\nmain ()\n{\n  float fx (), inita (), initc (), a, b, c;\n  a = inita ();\n  c = initc ();\n  f ();\n  b = fx (c) + a;\n  f ();\n  if (a != 3.0 || b < 4.3257 || b > 4.3258 || c != 4.0)\n    abort ();\n  exit (0);\n}\n\nfloat inita () { return 3.0; }\nfloat initc () { return 4.0; }\nf () {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930603-2.c",
    "content": "int w[2][2];\n\nf ()\n{\n  int i, j;\n\n  for (i = 0; i < 2; i++)\n    for (j = 0; j < 2; j++)\n      if (i == j)\n\tw[i][j] = 1;\n}\n\nmain ()\n{\n  f ();\n  if (w[0][0] != 1 || w[1][1] != 1 || w[1][0] != 0 || w[0][1] != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930603-3.c",
    "content": "f (b, c)\n     unsigned char *b;\n     int c;\n{\n  unsigned long v = 0;\n  switch (c)\n    {\n    case 'd':\n      v = ((unsigned long)b[0] << 8) + b[1];\n      v >>= 9;\n      break;\n\n    case 'k':\n      v = b[3] >> 4;\n      break;\n\n    default:\n      abort ();\n    }\n\n  return v;\n}\nmain ()\n{\n  char buf[4];\n  buf[0] = 170; buf[1] = 5;\n  if (f (buf, 'd') != 85)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930608-1.c",
    "content": "double f (double a) {}\ndouble (* const a[]) (double) = {&f};\n\nmain ()\n{\n  double (*p) ();\n  p = &f;\n  if (p != a[0])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930614-1.c",
    "content": "f (double *ty)\n{\n  *ty = -1.0;\n}\n\nmain ()\n{\n  double foo[6];\n  double tx = 0.0, ty, d;\n\n  f (&ty);\n\n  if (ty < 0)\n    ty = -ty;\n  d = (tx > ty) ? tx : ty;\n  if (ty != d)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930614-2.c",
    "content": "main ()\n{\n  int i, j, k, l;\n  float x[8][2][8][2];\n\n  for (i = 0; i < 8; i++)\n    for (j = i; j < 8; j++)\n      for (k = 0; k < 2; k++)\n\tfor (l = 0; l < 2; l++)\n\t  {\n\t    if ((i == j) && (k == l))\n\t      x[i][k][j][l] = 0.8;\n\t    else\n\t      x[i][k][j][l] = 0.8;\n\t    if (x[i][k][j][l] < 0.0)\n\t      abort ();\n\t  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930621-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nf ()\n{\n  struct {\n    int x : 18;\n    int y : 14;\n  } foo;\n\n  foo.x = 10;\n  foo.y = 20;\n\n  return foo.y;\n}\n\nmain ()\n{\n  if (f () != 20)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930622-1.c",
    "content": "int a = 1, b;\n\ng () { return 0; }\nh (x) {}\n\nf ()\n{\n  if (g () == -1)\n    return 0;\n  a = g ();\n  if (b >= 1)\n    h (a);\n  return 0;\n}\n\nmain ()\n{\n  f ();\n  if (a != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930622-2.c",
    "content": "long double\nll_to_ld (long long n)\n{\n  return n;\n}\n\nlong long\nld_to_ll (long double n)\n{\n  return n;\n}\n\nmain ()\n{\n  long long n;\n\n  if (ll_to_ld (10LL) != 10.0)\n    abort ();\n\n  if (ld_to_ll (10.0) != 10)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930628-1.c",
    "content": "f (double x[2], double y[2])\n{\n  if (x == y)\n    abort ();\n}\n\nmain ()\n{\n  struct { int f[3]; double x[1][2]; } tp[4][2];\n  int i, j, ki, kj, mi, mj;\n  float bdm[4][2][4][2];\n\n  for (i = 0; i < 4; i++)\n    for (j = i; j < 4; j++)\n      for (ki = 0; ki < 2; ki++)\n\tfor (kj = 0; kj < 2; kj++)\n\t  if ((j == i) && (ki == kj))\n\t    bdm[i][ki][j][kj] = 1000.0;\n\t  else\n\t    {\n\t      for (mi = 0; mi < 1; mi++)\n\t\tfor (mj = 0; mj < 1; mj++)\n\t\t  f (tp[i][ki].x[mi], tp[j][kj].x[mj]);\n\t      bdm[i][ki][j][kj] = 1000.0;\n\t    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930630-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nmain ()\n{\n  struct\n    {\n      signed int bf0:17;\n      signed int bf1:7;\n    } bf;\n\n  bf.bf1 = 7;\n  f (bf.bf1);\n  exit (0);\n}\n\nf (x)\n     int x;\n{\n  if (x != 7)\n    abort ();\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930702-1.c",
    "content": "fp (double a, int b)\n{\n  if (a != 33 || b != 11)\n    abort ();\n}\n\nmain ()\n{\n  int (*f) (double, int) = fp;\n\n  fp (33, 11);\n  f (33, 11);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930713-1.c",
    "content": "typedef struct\n{\n  char x;\n} T;\n\nT\nf (s1)\n     T s1;\n{\n  T s1a;\n  s1a.x = 17;\n  return s1a;\n}\n\nmain ()\n{\n  T s1a, s1b;\n  s1a.x = 13;\n  s1b = f (s1a);\n  if (s1a.x != 13 || s1b.x != 17)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930718-1.c",
    "content": "typedef struct rtx_def\n{\n  int f1 :1;\n  int f2 :1;\n} *rtx;\n\nstatic rtx\nf (orig)\n     register rtx orig;\n{\n  if (orig->f1 || orig->f2)\n    return orig;\n  orig->f2 = 1;\n  return orig;\n}\n\nvoid\nf2 ()\n{\n  abort ();\n}\n\nmain ()\n{\n  struct rtx_def foo;\n  rtx bar;\n\n  foo.f1 = 1;\n  foo.f2 = 0;\n  bar = f (&foo);\n  if (bar != &foo || bar->f2 != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930719-1.c",
    "content": "int\nf (foo, bar, com)\n{\n  unsigned align;\n  if (foo)\n    return 0;\n  while (1)\n    {\n      switch (bar)\n\t{\n\tcase 1:\n\t  if (com != 0)\n \t    return align;\n\t  *(char *) 0 = 0;\n\t}\n    }\n}\n\nmain ()\n{\n  f (0, 1, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930725-1.c",
    "content": "int v;\n\nchar *\ng ()\n{\n  return \"\";\n}\n\nchar *\nf ()\n{\n  return (v == 0 ? g () : \"abc\");\n}\n\nmain ()\n{\n  v = 1;\n  if (!strcmp (f (), \"abc\"))\n    exit (0);\n  abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930818-1.c",
    "content": "static double one = 1.0;\n\nf()\n{\n  int colinear;\n  colinear = (one == 0.0);\n  if (colinear)\n    abort ();\n  return colinear;\n}\nmain()\n{\n  if (f()) abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930916-1.c",
    "content": "f (n)\n     unsigned n;\n{\n  if ((int) n >= 0)\n    abort ();\n}\n\nmain ()\n{\n  unsigned x = ~0;\n  f (x);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930921-1.c",
    "content": "f (x)\n     unsigned x;\n{\n  return (unsigned) (((unsigned long long) x * 0xAAAAAAAB) >> 32) >> 1;\n}\n\nmain ()\n{\n  unsigned i;\n\n  for (i = 0; i < 10000; i++)\n    if (f (i) != i / 3)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930929-1.c",
    "content": "sub1 (i)\n     int i;\n{\n  return i - (5 - i);\n}\n\nsub2 (i)\n     int i;\n{\n  return i + (5 + i);\n}\n\nsub3 (i)\n     int i;\n{\n  return i - (5 + i);\n}\n\nsub4 (i)\n     int i;\n{\n  return i + (5 - i);\n}\n\nmain()\n{\n  if (sub1 (20) != 35)\n    abort ();\n  if (sub2 (20) != 45)\n    abort ();\n  if (sub3 (20) != -5)\n    abort ();\n  if (sub4 (20) != 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930930-1.c",
    "content": "__extension__ typedef __PTRDIFF_TYPE__ ptr_t;\nptr_t *wm_TR;\nptr_t *wm_HB;\nptr_t *wm_SPB;\n\nptr_t mem[100];\n\nf (mr_TR, mr_SPB, mr_HB, reg1, reg2)\n     ptr_t *mr_TR;\n     ptr_t *mr_SPB;\n     ptr_t *mr_HB;\n     ptr_t *reg1;\n     ptr_t *reg2;\n{\n  ptr_t *x = mr_TR;\n\n  for (;;)\n    {\n      if (reg1 < reg2)\n\tgoto out;\n      if ((ptr_t *) *reg1 < mr_HB && (ptr_t *) *reg1 >= mr_SPB)\n\t*--mr_TR = *reg1;\n      reg1--;\n    }\n out:\n\n  if (x != mr_TR)\n    abort ();\n}\n\nmain ()\n{\n  mem[99] = (ptr_t) mem;\n  f (mem + 100, mem + 6, mem + 8, mem + 99, mem + 99);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/930930-2.c",
    "content": "int\ntest_endianness()\n{\n  union doubleword\n    {\n      double d;\n      unsigned long u[2];\n    } dw;\n  dw.d = 10;\n  return dw.u[0] != 0 ? 1 : 0;\n}\n\nint\ntest_endianness_vol()\n{\n  union doubleword\n    {\n      volatile double d;\n      volatile long u[2];\n    } dw;\n  dw.d = 10;\n  return dw.u[0] != 0 ? 1 : 0;\n}\n\nmain ()\n{\n  if (test_endianness () != test_endianness_vol ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931002-1.c",
    "content": "f (void (*func) ())\n{\n  func ();\n}\n\nmain ()\n{\n#ifndef NO_TRAMPOLINES\n  void t0 ()\n    {\n    }\n\n  void t1 ()\n    {\n      f (t0);\n    }\n\n  void t2 ()\n    {\n      t1 ();\n    }\n\n  t1 ();\n  t1 ();\n  t2 ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-1.c",
    "content": "struct tiny\n{\n  int c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-10.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-11.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n  char e;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n  if (x.e != 30)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n  if (y.e != 31)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n  if (z.e != 32)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-12.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-13.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n  if (x.e != 30)\n    abort();\n  if (x.f != 40)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n  if (y.e != 31)\n    abort();\n  if (y.f != 41)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n  if (z.e != 32)\n    abort();\n  if (z.f != 42)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-14.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n      if (x.f != i + 40)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-2.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  int c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-3.c",
    "content": "struct tiny\n{\n  short c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-4.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  short c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-5.c",
    "content": "struct tiny\n{\n  short c;\n  short d;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-6.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  short c;\n  short d;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-7.c",
    "content": "struct tiny\n{\n  char c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-8.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931004-9.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931005-1.c",
    "content": "typedef struct\n{\n  char x;\n} T;\n\nT\nf (s1)\n     T s1;\n{\n  T s1a;\n  s1a.x = s1.x;\n  return s1a;\n}\n\nmain ()\n{\n  T s1a, s1b;\n  s1a.x = 100;\n  s1b = f (s1a);\n  if (s1b.x != 100)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931009-1.c",
    "content": "main ()\n{\n  f ();\n  exit (0);\n}\n\nstatic\ng (out, size, lo, hi)\n     int *out, size, lo, hi;\n{\n  int j;\n\n  for (j = 0; j < size; j++)\n    out[j] = j * (hi - lo);\n}\n\n\nf ()\n{\n  int a[2];\n\n  g (a, 2, 0, 1);\n\n  if (a[0] != 0 || a[1] != 1)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931012-1.c",
    "content": "f (int b, int c)\n{\n  if (b != 0 && b != 1 && c != 0)\n    b = 0;\n  return b;\n}\n\nmain ()\n{\n  if (!f (1, 2))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931017-1.c",
    "content": "int v;\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n\nh1 ()\n{\n  return 0;\n}\n\nh2 (e)\n     int *e;\n{\n  if (e != &v)\n    abort ();\n  return 0;\n}\n\ng (c)\n     char *c;\n{\n  int i;\n  int b;\n\n  do\n    {\n      i = h1 ();\n      if (i == -1)\n\treturn 0;\n      else if (i == 1)\n\th1 ();\n    }\n  while (i == 1);\n\n  do\n    b = h2 (&v);\n  while (i == 5);\n\n  if (i != 2)\n    return b;\n  *c = 'a';\n\n  return 0;\n}\n\n\nf ()\n{\n  char c;\n  g (&c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931018-1.c",
    "content": "unsigned int a[0x1000];\nextern const unsigned long v;\n\nmain ()\n{\n  f (v);\n  f (v);\n  exit (0);\n}\n\nf (a)\n     unsigned long a;\n{\n  if (a != 0xdeadbeefL)\n    abort();\n}\n\nconst unsigned long v = 0xdeadbeefL;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931031-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct foo\n{\n  unsigned y:1;\n  unsigned x:32;\n};\n\nint\nf (x)\n     struct foo x;\n{\n  int t = x.x;\n  if (t < 0)\n    return 1;\n  return t+1;\n}\n\nmain ()\n{\n  struct foo x;\n  x.x = -1;\n  if (f (x) == 0)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931102-1.c",
    "content": "typedef union\n{\n  struct\n    {\n      char h, l;\n    } b;\n} T;\n\nf (x)\n     int x;\n{\n  int num = 0;\n  T reg;\n\n  reg.b.l = x;\n  while ((reg.b.l & 1) == 0)\n    {\n      num++;\n      reg.b.l >>= 1;\n    }\n  return num;\n}\n\nmain ()\n{\n  if (f (2) != 1)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931102-2.c",
    "content": "typedef union\n{\n  long align;\n  struct\n    {\n      short h, l;\n    } b;\n} T;\n\nf (x)\n     int x;\n{\n  int num = 0;\n  T reg;\n\n  reg.b.l = x;\n  while ((reg.b.l & 1) == 0)\n    {\n      num++;\n      reg.b.l >>= 1;\n    }\n  return num;\n}\n\nmain ()\n{\n  if (f (2) != 1)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931110-1.c",
    "content": "typedef struct\n{\n  short f:3, g:3, h:10;\n} small;\n\nstruct\n{\n  int i;\n  small s[10];\n} x;\n\nmain ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    x.s[i].f = 0;\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931110-2.c",
    "content": "main ()\n{\n  static int a[] = {3, 4};\n  register int *b;\n  int c;\n\n  b = a;\n  c = *b++ % 8;\n  if (c != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931208-1.c",
    "content": "f ()\n{\n  unsigned long x, y = 1;\n\n  x = ((y * 8192) - 216) / 16;\n  return x;\n}\n\nmain ()\n{\n  if (f () != 498)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/931228-1.c",
    "content": "f (x)\n{\n  x &= 010000;\n  x &= 007777;\n  x ^= 017777;\n  x &= 017770;\n  return x;\n}\n\nmain ()\n{\n  if (f (-1) != 017770)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/940115-1.c",
    "content": "f (cp, end)\n     char *cp;\n     char *end;\n{\n  return (cp < end);\n}\n\nmain ()\n{\n  if (! f ((char *) 0, (char *) 1))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/940122-1.c",
    "content": "char *a = 0;\nchar *b = 0;\n\ng (x)\n     int x;\n{\n  if ((!!a) != (!!b))\n    abort ();\n}\n\nf (x)\n     int x;\n{\n  g (x * x);\n}\n\nmain ()\n{\n  f (100);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941014-1.c",
    "content": "int f (int a, int b) { }\n\nmain ()\n{\n  unsigned long addr1;\n  unsigned long addr2;\n\n  addr1 = (unsigned long) &f;\n  addr1 += 5;\n  addr2 = 5 + (unsigned long) &f;\n\n  if (addr1 != addr2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941014-2.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n\ntypedef struct {\n  unsigned short a;\n  unsigned short b;\n} foo_t;\n\nvoid a1 (unsigned long offset) {}\n\nvolatile foo_t *\nf ()\n{\n  volatile foo_t *foo_p = (volatile foo_t *)malloc (sizeof (foo_t));\n\n  a1((unsigned long)foo_p-30);\n  if (foo_p->a & 0xf000)\n    printf(\"%d\\n\", foo_p->a);\n  foo_p->b = 0x0100;\n  a1 ((unsigned long)foo_p + 2);\n  a1 ((unsigned long)foo_p - 30);\n  return foo_p;\n}\n\nmain ()\n{\n  volatile foo_t *foo_p;\n\n  foo_p = f ();\n  if (foo_p->b != 0x0100)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941015-1.c",
    "content": "int\nfoo1 (value)\n     long long value;\n{\n  register const long long constant = 0xc000000080000000LL;\n\n  if (value < constant)\n    return 1;\n  else\n    return 2;\n}\n\nint\nfoo2 (value)\n     unsigned long long value;\n{\n  register const unsigned long long constant = 0xc000000080000000LL;\n\n  if (value < constant)\n    return 1;\n  else\n    return 2;\n}\n\nmain ()\n{\n  unsigned long long value = 0xc000000000000001LL;\n  int x, y;\n\n  x = foo1 (value);\n  y = foo2 (value);\n  if (x != y || x != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941021-1.c",
    "content": "double glob_dbl;\n\nf (pdbl, value)\n     double *pdbl;\n     double value;\n{\n  if (pdbl == 0)\n    pdbl = &glob_dbl;\n\n  *pdbl = value;\n}\n\nmain ()\n{\n  f ((void *) 0, 55.1);\n\n  if (glob_dbl != 55.1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941025-1.c",
    "content": "long f (x, y)\n     long x,y;\n{\n  return (x > 1) ? y : (y & 1);\n}\n\nmain ()\n{\n  if (f (2L, 0xdecadeL) != 0xdecadeL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941031-1.c",
    "content": "typedef long mpt;\n\nint\nf (mpt us, mpt vs)\n{\n  long aus;\n  long avs;\n\n  aus = us >= 0 ? us : -us;\n  avs = vs >= 0 ? vs : -vs;\n\n  if (aus < avs)\n    {\n      long t = aus;\n      aus = avs;\n      avs = aus;\n    }\n\n  return avs;\n}\n\nmain ()\n{\n  if (f ((mpt) 3, (mpt) 17) != 17)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941101-1.c",
    "content": "f ()\n{\n  int var = 7;\n\n  if ((var/7) == 1)\n    return var/7;\n  return 0;\n}\n\nmain ()\n{\n  if (f () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941110-1.c",
    "content": "f (const int x)\n{\n  int y = 0;\n  y = x ? y : -y;\n  {\n    const int *p = &x;\n  }\n  return y;\n}\n\nmain ()\n{\n  if (f (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/941202-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\ng (x, y)\n{\n  if (x != 3)\n    abort ();\n}\n\nstatic inline\nf (int i)\n{\n  int *tmp;\n\n  tmp = (int *) alloca (sizeof (i));\n  *tmp = i;\n  g (*tmp, 0);\n}\n\nmain ()\n{\n  f (3);\n  exit (0);\n};\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950221-1.c",
    "content": "struct parsefile\n{\n  long fd;\n  char *buf;\n};\nstruct parsefile basepf;\nstruct parsefile *parsefile = &basepf;\n#ifdef STACK_SIZE\nint filler[STACK_SIZE / (2*sizeof(int))];\n#else\nint filler[0x3000];\n#endif\nint el;\n\nchar *\ng1 (a, b)\n     int a;\n     int *b;\n{\n}\n\ng2 (a)\n     long a;\n{\n  if (a != 0xdeadbeefL)\n    abort ();\n  exit (0);\n}\n\nf ()\n{\n  register char *p, *q;\n  register int i;\n  register int something;\n\n  if (parsefile->fd == 0L && el)\n    {\n      const char *rl_cp;\n      int len;\n      rl_cp = g1 (el, &len);\n      strcpy (p, rl_cp);\n    }\n  else\n    {\n    alabel:\n      i = g2 (parsefile->fd);\n    }\n}\n\nmain ()\n{\n  el = 0;\n  parsefile->fd = 0xdeadbeefL;\n  f ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950322-1.c",
    "content": "f (unsigned char *a)\n{\n  int i, j;\n  int x, y;\n\n  j = a[1];\n  i = a[0] - j;\n  if (i < 0)\n    {\n      x = 1;\n      y = -i;\n    }\n  else\n    {\n      x = 0;\n      y =  i;\n    }\n  return x + y;\n}\n\n\nmain ()\n{\n  unsigned char a[2];\n  a[0] = 8;\n  a[1] = 9;\n  if (f (a) != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950426-1.c",
    "content": "\nstruct tag {\n  int m1;\n  char *m2[5];\n} s1, *p1;\n\nint i;\n\nmain()\n{\n  s1.m1 = -1;\n  p1 = &s1;\n\n  if ( func1( &p1->m1 ) == -1 )\n    foo (\"ok\");\n  else\n    abort ();\n\n  i = 3;\n  s1.m2[3]= \"123\";\n\n  if ( strlen( (p1->m2[i])++ ) == 3 )\n    foo (\"ok\");\n  else\n    abort ();\n\n  exit (0);\n}\n\nfunc1(int *p) { return(*p); }\n\nfoo (char *s) {}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950426-2.c",
    "content": "main()\n{\n  long int i = -2147483647L - 1L; /* 0x80000000 */\n  char ca = 1;\n\n  if (i >> ca != -1073741824L)\n    abort ();\n\n  if (i >> i / -2000000000L != -1073741824L)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950503-1.c",
    "content": "main ()\n{\n  int tmp;\n  unsigned long long utmp1, utmp2;\n\n  tmp = 16;\n\n  utmp1 = (~((unsigned long long) 0)) >> tmp;\n  utmp2 = (~((unsigned long long) 0)) >> 16;\n\n  if (utmp1 != utmp2)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950511-1.c",
    "content": "main ()\n{\n  unsigned long long xx;\n  unsigned long long *x = (unsigned long long *) &xx;\n\n  *x = -3;\n  *x = *x * *x;\n  if (*x != 9)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950512-1.c",
    "content": "unsigned\nf1 (x)\n{\n  return ((unsigned) (x != 0) - 3) / 2;\n}\n\nunsigned long long\nf2 (x)\n{\n  return ((unsigned long long) (x != 0) - 3) / 2;\n}\n\nmain ()\n{\n  if (f1 (1) != (~(unsigned) 0) >> 1)\n    abort ();\n  if (f1 (0) != ((~(unsigned) 0) >> 1) - 1)\n    abort ();\n  if (f2 (1) != (~(unsigned long long) 0) >> 1)\n    abort ();\n  if (f2 (0) != ((~(unsigned long long) 0) >> 1) - 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950605-1.c",
    "content": "f (c)\n    unsigned char c;\n{\n  if (c != 0xFF)\n    abort ();\n}\n\nmain ()\n{\n  f (-1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950607-1.c",
    "content": "main ()\n{\n  struct { long status; } h;\n\n  h.status = 0;\n  if (((h.status & 128) == 1) && ((h.status & 32) == 0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950607-2.c",
    "content": "typedef struct {\n  long int p_x, p_y;\n} Point;\n\nint\nf (Point basePt, Point pt1, Point pt2)\n{\n  long long vector;\n\n  vector =\n    (long long) (pt1.p_x - basePt.p_x) * (long long) (pt2.p_y - basePt.p_y) -\n      (long long) (pt1.p_y - basePt.p_y) * (long long) (pt2.p_x - basePt.p_x);\n\n  if (vector > (long long) 0)\n    return 0;\n  else if (vector < (long long) 0)\n    return 1;\n  else\n    return 2;\n}\n\nmain ()\n{\n  Point b, p1, p2;\n  int answer;\n\n  b.p_x = -23250;\n  b.p_y = 23250;\n\n  p1.p_x = 23250;\n  p1.p_y = -23250;\n\n  p2.p_x = -23250;\n  p2.p_y = -23250;\n\n  answer = f (b, p1, p2);\n\n  if (answer != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950612-1.c",
    "content": "unsigned int\nf1 (int diff)\n{\n  return ((unsigned int) (diff < 0 ? -diff : diff));\n}\n\nunsigned int\nf2 (unsigned int diff)\n{\n  return ((unsigned int) ((signed int) diff < 0 ? -diff : diff));\n}\n\nunsigned long long\nf3 (long long diff)\n{\n  return ((unsigned long long) (diff < 0 ? -diff : diff));\n}\n\nunsigned long long\nf4 (unsigned long long diff)\n{\n  return ((unsigned long long) ((signed long long) diff < 0 ? -diff : diff));\n}\n\nmain ()\n{\n  int i;\n  for (i = 0; i <= 10; i++)\n    {\n      if (f1 (i) != i)\n\tabort ();\n      if (f1 (-i) != i)\n\tabort ();\n      if (f2 (i) != i)\n\tabort ();\n      if (f2 (-i) != i)\n\tabort ();\n      if (f3 ((long long) i) != i)\n\tabort ();\n      if (f3 ((long long) -i) != i)\n\tabort ();\n      if (f4 ((long long) i) != i)\n\tabort ();\n      if (f4 ((long long) -i) != i)\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950621-1.c",
    "content": "struct s\n{\n  int a;\n  int b;\n  struct s *dummy;\n};\n\nf (struct s *sp)\n{\n  return sp && sp->a == -1 && sp->b == -1;\n}\n\nmain ()\n{\n  struct s x;\n  x.a = x.b = -1;\n  if (f (&x) == 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950628-1.c",
    "content": "typedef struct\n{\n  char hours, day, month;\n  short year;\n} T;\n\nT g (void)\n{\n  T now;\n\n  now.hours = 1;\n  now.day = 2;\n  now.month = 3;\n  now.year = 4;\n  return now;\n}\n\nT f (void)\n{\n  T virk;\n\n  virk = g ();\n  return virk;\n}\n\nmain ()\n{\n  if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950704-1.c",
    "content": "int errflag;\n\nlong long\nf (long long x, long long y)\n{\n  long long r;\n\n  errflag = 0;\n  r = x + y;\n  if (x >= 0)\n    {\n      if ((y < 0) || (r >= 0))\n\treturn r;\n    }\n  else\n    {\n      if ((y > 0) || (r < 0))\n\treturn r;\n    }\n  errflag = 1;\n  return 0;\n}\n\nmain ()\n{\n  f (0, 0);\n  if (errflag)\n    abort ();\n\n  f (1, -1);\n  if (errflag)\n    abort ();\n\n  f (-1, 1);\n  if (errflag)\n    abort ();\n\n  f (0x8000000000000000LL, 0x8000000000000000LL);\n  if (!errflag)\n    abort ();\n\n  f (0x8000000000000000LL, -1LL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 0x7fffffffffffffffLL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 1LL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 0x8000000000000000LL);\n  if (errflag)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950706-1.c",
    "content": "int\nf (int n)\n{\n  return (n > 0) - (n < 0);\n}\n\nmain ()\n{\n  if (f (-1) != -1)\n    abort ();\n  if (f (1) != 1)\n    abort ();\n  if (f (0) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950710-1.c",
    "content": "struct twelve\n{\n  int a;\n  int b;\n  int c;\n};\n\nstruct pair\n{\n  int first;\n  int second;\n};\n\nstruct pair\ng ()\n{\n  struct pair p;\n  return p;\n}\n\nstatic void\nf ()\n{\n  int i;\n  for (i = 0; i < 1; i++)\n    {\n      int j;\n      for (j = 0; j < 1; j++)\n\t{\n\t  if (0)\n\t    {\n\t      int k;\n\t      for (k = 0; k < 1; k++)\n\t\t{\n\t\t  struct pair e = g ();\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      struct twelve a, b;\n\t      if ((((char *) &b - (char *) &a) < 0\n\t\t   ? (-((char *) &b - (char *) &a))\n\t\t   : ((char *) &b - (char *) &a))  < sizeof (a))\n\t\tabort ();\n\t    }\n\t}\n    }\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950714-1.c",
    "content": "int array[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};\n\nmain ()\n{\n  int i, j;\n  int *p;\n\n  for (i = 0; i < 10; i++)\n    for (p = &array[0]; p != &array[9]; p++)\n      if (*p == i)\n\tgoto label;\n\n label:\n  if (i != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950809-1.c",
    "content": "struct S\n{\n  int *sp, fc, *sc, a[2];\n};\n\nf (struct S *x)\n{\n  int *t = x->sc;\n  int t1 = t[0];\n  int t2 = t[1];\n  int t3 = t[2];\n  int a0 = x->a[0];\n  int a1 = x->a[1];\n  t[2] = t1;\n  t[0] = a1;\n  x->a[1] = a0;\n  x->a[0] = t3;\n  x->fc = t2;\n  x->sp = t;\n}\n\nmain ()\n{\n  struct S s;\n  static int sc[3] = {2, 3, 4};\n  s.sc = sc;\n  s.a[0] = 10;\n  s.a[1] = 11;\n  f (&s);\n  if (s.sp[2] != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950906-1.c",
    "content": "g (int i)\n{\n}\n\nf (int i)\n{\n  g (0);\n  while ( ({ i--; }) )\n    g (0);\n}\n\nmain ()\n{\n  f (10);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950915-1.c",
    "content": "long int a = 100000;\nlong int b = 21475;\n\nlong\nf ()\n{\n  return ((long long) a * (long long) b) >> 16;\n}\n\nmain ()\n{\n  if (f () < 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/950929-1.c",
    "content": "int f (char *p) { }\n\nmain ()\n{\n  char c;\n  char c2;\n  int i = 0;\n  char *pc = &c;\n  char *pc2 = &c2;\n  int *pi = &i;\n\n  *pc2 = 1;\n  *pi = 1;\n  *pc2 &= *pi;\n  f (pc2);\n  *pc2 = 1;\n  *pc2 &= *pi;\n  if (*pc2 != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/951003-1.c",
    "content": "int f (i) { return 12; }\nint g () { return 0; }\n\nmain ()\n{\n  int i, s;\n\n  for (i = 0; i < 32; i++)\n    {\n      s = f (i);\n\n      if (i == g ())\n\ts = 42;\n      if (i == 0 || s == 12)\n\t;\n      else\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/951115-1.c",
    "content": "int var = 0;\n\ng ()\n{\n  var = 1;\n}\n\nf ()\n{\n  int f2 = 0;\n\n  if (f2 == 0)\n    ;\n\n  g ();\n}\n\nmain ()\n{\n  f ();\n  if (var != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/951204-1.c",
    "content": "f (char *x)\n{\n  *x = 'x';\n}\n\nmain ()\n{\n  int i;\n  char x = '\\0';\n\n  for (i = 0; i < 100; ++i)\n    {\n      f (&x);\n      if (*(const char *) &x != 'x')\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960116-1.c",
    "content": "static inline\np (int *p)\n{\n  return !((long) p & 1);\n}\n\nint\nf (int *q)\n{\n  if (p (q) && *q)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  if (f ((int*) 0xffffffff) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960117-1.c",
    "content": "static char id_space[2] [32 +1];\ntypedef short COUNT;\n\ntypedef char TEXT;\n\nunion T_VALS\n{\n  TEXT   *id __attribute__ ((aligned (2), packed)) ;\n};\ntypedef union T_VALS VALS;\n\nstruct T_VAL\n{\n  COUNT    pos __attribute__ ((aligned (2), packed)) ;\n  VALS    vals __attribute__ ((aligned (2), packed)) ;\n};\ntypedef struct T_VAL VAL;\n\nVAL curval = {0};\n\nstatic short idc = 0;\nstatic int cur_line;\nstatic int char_pos;\n\ntypedef unsigned short WORD;\n\nWORD\nget_id (char c)\n{\n  curval.vals.id[0] = c;\n}\n\nWORD\nget_tok ()\n{\n  char c = 'c';\n  curval.vals.id = id_space[idc];\n  curval.pos = (cur_line << 10) | char_pos;\n  return get_id (c);\n}\n\nmain ()\n{\n  get_tok ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960209-1.c",
    "content": "struct a_struct\n{\n  unsigned char a_character;\n};\n\nstruct a_struct an_array[5];\nstruct a_struct *a_ptr;\nint yabba = 1;\n\nint\nf (a, b)\n     unsigned char a;\n     unsigned long b;\n{\n  long i, j, p, q, r, s;\n\n  if (b != (unsigned long) 0)\n    {\n      if (yabba)\n\treturn -1;\n      s = 4000000 / b;\n      for (i = 0; i < 11; i++)\n\t{\n\t  for (j = 0; j < 256; j++)\n\t    {\n\t      if (((p - s < 0) ? -s : 0) < (( q - s < 0) ? -s : q))\n\t\tr = i;\n\t    }\n\t}\n    }\n\n  if (yabba)\n    return 0;\n  a_ptr = &an_array[a];\n  a_ptr->a_character = (unsigned char) r;\n}\n\nmain ()\n{\n  if (f (1, 0UL) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960215-1.c",
    "content": "long double C = 2;\nlong double U = 1;\nlong double Y2 = 3;\nlong double Y1 = 1;\nlong double X, Y, Z, T, R, S;\nmain ()\n{\n  X = (C + U) * Y2;\n  Y = C - U - U;\n  Z = C + U + U;\n  T = (C - U) * Y1;\n  X = X - (Z + U);\n  R = Y * Y1;\n  S = Z * Y2;\n  T = T - Y;\n  Y = (U - Y) + R;\n  Z = S - (Z + U + U);\n  R = (Y2 + U) * Y1;\n  Y1 = Y2 * Y1;\n  R = R - Y2;\n  Y1 = Y1 - 0.5L;\n  if (Z != 6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960218-1.c",
    "content": "int glob;\n\ng (x)\n{\n  glob = x;\n  return 0;\n}\n\nf (x)\n{\n  int a = ~x;\n  while (a)\n    a = g (a);\n}\n\nmain ()\n{\n  f (3);\n  if (glob != -4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960219-1.c",
    "content": "f (int i)\n{\n  if (((1 << i) & 1) == 0)\n    abort ();\n}\n\nmain ()\n{\n  f (0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960301-1.c",
    "content": "struct foo {\n  unsigned : 12;\n  unsigned field : 4;\n} foo;\nunsigned oldfoo;\n\nint\nbar (unsigned k)\n{\n  oldfoo = foo.field;\n  foo.field = k;\n  if (k)\n    return 1;\n  return 2;\n}\n\nmain ()\n{\n  if (bar (1U) != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960302-1.c",
    "content": "long a = 1;\n\nfoo ()\n{\n  switch (a % 2 % 2 % 2 % 2 % 2 % 2 % 2 % 2)\n    {\n    case 0:\n      return 0;\n    case 1:\n      return 1;\n    default:\n      return -1;\n    }\n}\n\nmain ()\n{\n  if (foo () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960311-1.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned char data)\n{\n  if (data & 0x80) a1();\n  data <<= 1;\n\n  if (data & 0x80) a1();\n  data <<= 1;\n\n  if (data & 0x80) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x80);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x40);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x20);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc0);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa0);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x60);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe0);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960311-2.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned short data)\n{\n  if (data & 0x8000) a1();\n  data <<= 1;\n\n  if (data & 0x8000) a1();\n  data <<= 1;\n\n  if (data & 0x8000) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x8000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x4000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x2000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x6000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe000);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960311-3.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned long data)\n{\n  if (data & 0x80000000) a1();\n  data <<= 1;\n\n  if (data & 0x80000000) a1();\n  data <<= 1;\n\n  if (data & 0x80000000) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x80000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x40000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x20000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc0000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa0000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x60000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe0000000);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960312-1.c",
    "content": "struct S\n{\n  int *sp, fc, *sc, a[2];\n};\n\nf (struct S *x)\n{\n  int *t = x->sc;\n  int t1 = t[0];\n  int t2 = t[1];\n  int t3 = t[2];\n  int a0 = x->a[0];\n  int a1 = x->a[1];\n  asm(\"\": :\"r\" (t2), \"r\" (t3));\n  t[2] = t1;\n  t[0] = a1;\n  x->a[1] = a0;\n  x->a[0] = t3;\n  x->fc = t2;\n  x->sp = t;\n}\n\nmain ()\n{\n  struct S s;\n  static int sc[3] = {2, 3, 4};\n  s.sc = sc;\n  s.a[0] = 10;\n  s.a[1] = 11;\n  f (&s);\n  if (s.sp[2] != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960317-1.c",
    "content": "int\nf (unsigned bitcount, int mant)\n{\n  int mask = -1 << bitcount;\n  {\n    if (! (mant & -mask))\n      goto ab;\n    if (mant & ~mask)\n      goto auf;\n  }\nab:\n  return 0;\nauf:\n  return 1;\n}\n\nmain ()\n{\n  if (f (0, -1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960321-1.c",
    "content": "char a[10] = \"deadbeef\";\n\nchar\nacc_a (long i)\n{\n  return a[i-2000000000L];\n}\n\nmain ()\n{\n  if (acc_a (2000000000L) != 'd')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960326-1.c",
    "content": "struct s\n{\n  int a;\n  int b;\n  short c;\n  int d[3];\n};\n\nstruct s s = { .b = 3, .d = {2,0,0} };\n\nmain ()\n{\n  if (s.b != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960327-1.c",
    "content": "#include <stdio.h>\ng ()\n{\n  return '\\n';\n}\n\nf ()\n{\n  char s[] = \"abcedfg012345\";\n  char *sp = s + 12;\n\n  switch (g ())\n    {\n      case '\\n':\n        break;\n    }\n\n  while (*--sp == '0')\n    ;\n  sprintf (sp + 1, \"X\");\n\n  if (s[12] != 'X')\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960402-1.c",
    "content": "f (signed long long int x)\n{\n  return x > 0xFFFFFFFFLL || x < -0x80000000LL;\n}\n\nmain ()\n{\n  if (f (0) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960405-1.c",
    "content": "#define X  5.9486574767861588254287966331400356538172e4931L\n\nlong double x = X + X;\nlong double y = 2.0L * X;\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  if (x != y)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960416-1.c",
    "content": "typedef unsigned long int st;\ntypedef unsigned long long dt;\ntypedef union\n{\n  dt d;\n  struct\n  {\n    st h, l;\n  }\n  s;\n} t_be;\n\ntypedef union\n{\n  dt d;\n  struct\n  {\n    st l, h;\n  }\n  s;\n} t_le;\n\n#define df(f, t) \\\nint \\\nf (t afh, t bfh) \\\n{ \\\n  t hh; \\\n  t hp, lp, dp, m; \\\n  st ad, bd; \\\n  int s; \\\n  s = 0; \\\n  ad = afh.s.h - afh.s.l; \\\n  bd = bfh.s.l - bfh.s.h; \\\n  if (bd > bfh.s.l) \\\n    { \\\n      bd = -bd; \\\n      s = ~s; \\\n    } \\\n  lp.d = (dt) afh.s.l * bfh.s.l; \\\n  hp.d = (dt) afh.s.h * bfh.s.h; \\\n  dp.d = (dt) ad *bd; \\\n  dp.d ^= s; \\\n  hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \\\n  m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \\\n  return hh.s.l + m.s.l; \\\n}\n\ndf(f_le, t_le)\ndf(f_be, t_be)\n\nmain ()\n{\n  t_be x;\n  x.s.h = 0x10000000U;\n  x.s.l = 0xe0000000U;\n  if (x.d == 0x10000000e0000000ULL\n      && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1)\n    abort ();\n  if (x.d == 0xe000000010000000ULL\n      && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960419-1.c",
    "content": "static int i;\n\nvoid\ncheck(x)\n     int x;\n{\n  if (!x)\n    abort();\n}\n\nmain()\n{\n  int *p = &i;\n\n  check(p != (void *)0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960419-2.c",
    "content": "#define SIZE 8\n\nmain()\n{\n  int a[SIZE] = {1};\n  int i;\n\n  for (i = 1; i < SIZE; i++)\n    if (a[i] != 0)\n      abort();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960512-1.c",
    "content": "__complex__\ndouble f ()\n{\n  int a[40];\n  __complex__ double c;\n\n  a[9] = 0;\n  c = a[9];\n  return c;\n}\n\nmain ()\n{\n  __complex__ double c;\n\n  if (c = f ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960513-1.c",
    "content": "long double\nf (d, i)\n     long double d;\n     int i;\n{\n  long double e;\n\n  d = -d;\n  e = d;\n  if (i == 1)\n    d *= 2;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  return d;\n}\n\nmain ()\n{\n  if (! (int) (f (2.0L, 1)))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960521-1.c",
    "content": "#include <stdlib.h>\n\nint *a, *b;\nint n;\n\n#ifdef STACK_SIZE\n#define BLOCK_SIZE (STACK_SIZE / (sizeof (*a) + sizeof (*b)))\n#else\n#define BLOCK_SIZE 32768\n#endif\nfoo ()\n{\n  int i;\n  for (i = 0; i < n; i++)\n    a[i] = -1;\n  for (i = 0; i < BLOCK_SIZE - 1; i++)\n    b[i] = -1;\n}\n\nmain ()\n{\n  n = BLOCK_SIZE;\n  a = malloc (n * sizeof(*a));\n  b = malloc (n * sizeof(*b));\n  *b++ = 0;\n  foo ();\n  if (b[-1])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960608-1.c",
    "content": "typedef struct\n{\n  unsigned char a  : 2;\n  unsigned char b  : 3;\n  unsigned char c  : 1;\n  unsigned char d  : 1;\n  unsigned char e  : 1;\n} a_struct;\n\nfoo (flags)\n     a_struct *flags;\n{\n  return (flags->c != 0\n\t  || flags->d != 1\n\t  || flags->e != 1\n\t  || flags->a != 2\n\t  || flags->b != 3);\n}\n\nmain ()\n{\n  a_struct flags;\n\n  flags.c  = 0;\n  flags.d  = 1;\n  flags.e  = 1;\n  flags.a  = 2;\n  flags.b  = 3;\n\n  if (foo (&flags) != 0)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960801-1.c",
    "content": "unsigned\nf ()\n{\n  long long l2;\n  unsigned short us;\n  unsigned long long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nunsigned long long\ng ()\n{\n  long long l2;\n  unsigned short us;\n  unsigned long long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nmain ()\n{\n  if (f () != (unsigned short) -1)\n    abort ();\n  if (g () != (unsigned short) -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960802-1.c",
    "content": "long val = 0x5e000000;\n\nlong\nf1 (void)\n{\n  return 0x132;\n}\n\nlong\nf2 (void)\n{\n  return 0x5e000000;\n}\n\nvoid\nf3 (long b)\n{\n  val = b;\n}\n\nvoid\nf4 ()\n{\n  long v = f1 ();\n  long o = f2 ();\n  v = (v & 0x00ffffff) | (o & 0xff000000);\n  f3 (v);\n}\n\nmain ()\n{\n  f4 ();\n  if (val != 0x5e000132)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960830-1.c",
    "content": "#ifdef __i386__\nf (rp)\n     unsigned int *rp;\n{\n  __asm__ (\"mull %3\" : \"=a\" (rp[0]), \"=d\" (rp[1]) : \"%0\" (7), \"rm\" (7));\n}\n\nmain ()\n{\n  unsigned int s[2];\n\n  f (s);\n  if (s[1] != 0 || s[0] != 49)\n    abort ();\n exit (0);\n}\n#else\nmain ()\n{\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/960909-1.c",
    "content": "int\nffs (x)\n     int x;\n{\n  int bit, mask;\n\n  if (x == 0)\n    return 0;\n\n  for (bit = 1, mask = 1; !(x & mask); bit++, mask <<= 1)\n    ;\n\n  return bit;\n}\n\nf (x)\n     int x;\n{\n  int y;\n  y = ffs (x) - 1;\n  if (y < 0) \n    abort ();\n}\n\nmain ()\n{\n  f (1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961004-1.c",
    "content": "int k = 0;\n\nmain()\n{\n  int i;\n  int j;\n\n  for (i = 0; i < 2; i++)\n    {\n      if (k)\n\t{\n\t  if (j != 2)\n\t    abort ();\n\t}\n      else\n\t{\n\t  j = 2;\n\t  k++;\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961017-1.c",
    "content": "main ()\n{\n  unsigned char z = 0;\n\n  do ;\n  while (--z > 0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961017-2.c",
    "content": "main ()\n{\n  int i = 0;\n\n\n  if (sizeof (unsigned long int) == 4)\n    {\n      unsigned long int z = 0;\n\n      do {\n\tz -= 0x00004000;\n\ti++;\n\tif (i > 0x00040000)\n\t  abort ();\n      } while (z > 0);\n      exit (0);\n    }\n  else if (sizeof (unsigned int) == 4)\n    {\n      unsigned int z = 0;\n\n      do {\n\tz -= 0x00004000;\n\ti++;\n\tif (i > 0x00040000)\n\t  abort ();\n      } while (z > 0);\n      exit (0);\n    }\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961026-1.c",
    "content": "int\ntest (arg)\n     int arg;\n{\n  if (arg > 0 || arg == 0)\n    return 0;\n  return -1;\n}\n\nmain ()\n{\n  if (test (0) != 0)\n    abort ();\n  if (test (-1) != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961112-1.c",
    "content": "f (x)\n{\n  if (x != 0 || x == 0)\n    return 0;\n  return 1;\n}\n\nmain ()\n{\n  if (f (3))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961122-1.c",
    "content": "long long acc;\n\naddhi (short a)\n{\n  acc += (long long) a << 32;\n}\n\nsubhi (short a)\n{\n  acc -= (long long) a << 32;\n}\n\nmain ()\n{\n  acc = 0xffff00000000ll;\n  addhi (1);\n  if (acc != 0x1000000000000ll)\n    abort ();\n  subhi (1);\n  if (acc != 0xffff00000000ll)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961122-2.c",
    "content": "int\nf (int a)\n{\n  return ((a >= 0 && a <= 10) && ! (a >= 0));\n}\n\nmain ()\n{\n  if (f (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961125-1.c",
    "content": "static char *\nbegfield (int tab, char *ptr, char *lim, int sword, int schar)\n{\n  if (tab)\n    {\n      while (ptr < lim && sword--)\n\t{\n\t  while (ptr < lim && *ptr != tab)\n\t    ++ptr;\n\t  if (ptr < lim)\n\t    ++ptr;\n\t}\n    }\n  else\n    {\n      while (1)\n\t;\n    }\n\n  if (ptr + schar <= lim)\n    ptr += schar;\n\n  return ptr;\n}\n\nmain ()\n{\n  char *s = \":ab\";\n  char *lim = s + 3;\n  if (begfield (':', s, lim, 1, 1) != s + 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961206-1.c",
    "content": "int\nsub1 (unsigned long long i)\n{\n  if (i < 0x80000000)\n    return 1;\n  else\n    return 0;\n}\n\nint\nsub2 (unsigned long long i)\n{\n  if (i <= 0x7FFFFFFF)\n    return 1;\n  else\n    return 0;\n}\n\nint\nsub3 (unsigned long long i)\n{\n  if (i >= 0x80000000)\n    return 0;\n  else\n    return 1;\n}\n\nint\nsub4 (unsigned long long i)\n{\n  if (i > 0x7FFFFFFF)\n    return 0;\n  else\n    return 1;\n}\n\nmain()\n{\n  if (sub1 (0x80000000ULL))\n    abort ();\n\n  if (sub2 (0x80000000ULL))\n    abort ();\n\n  if (sub3 (0x80000000ULL))\n    abort ();\n\n  if (sub4 (0x80000000ULL))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961213-1.c",
    "content": "int\ng (unsigned long long int *v, int n, unsigned int a[], int b)\n{\n  int cnt;\n  *v = 0;\n  for (cnt = 0; cnt < n; ++cnt)\n    *v = *v * b + a[cnt];\n  return n;\n}\n\nmain ()\n{\n  int res;\n  unsigned int ar[] = { 10, 11, 12, 13, 14 };\n  unsigned long long int v;\n\n  res = g (&v, sizeof(ar)/sizeof(ar[0]), ar, 16);\n  if (v != 0xabcdeUL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/961223-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void exit (int);\nextern void abort (void);\n\nstruct s {\n  double d;\n};\n\ninline struct s\nsub (struct s s)\n{\n  s.d += 1.0;\n  return s;\n}\n\nint\nmain ()\n{\n  struct s t = { 2.0 };\n  t = sub (t);\n  if (t.d != 3.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/970214-1.c",
    "content": "#define L 1\nmain ()\n{\n  exit (L'1' != L'1');\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/970214-2.c",
    "content": "#define m(L) (L'1' + (L))\nmain ()\n{\n  exit (m (0) != L'1');\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/970217-1.c",
    "content": "sub (int i, int array[i++])\n{\n  return i;\n}\n\nmain()\n{\n  int array[10];\n  exit (sub (10, array) != 11);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/970923-1.c",
    "content": "int\nts(a)\n     int a;\n{\n  if (a < 1000 && a > 2000)\n    return 1;\n  else\n    return 0;\n}\n\nint\ntu(a)\n     unsigned int a;\n{\n  if (a < 1000 && a > 2000)\n    return 1;\n  else\n    return 0;\n}\n\n\nmain()\n{\n  if (ts (0) || tu (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980205.c",
    "content": "#include <stdarg.h>\n\nvoid fdouble (double one, ...)\n{\n  double value;\n  va_list ap;\n\n  va_start (ap, one);\n  value = va_arg (ap, double);\n  va_end (ap);\n\n  if (one != 1.0 || value != 2.0)\n    abort ();\n}\n\nint main ()\n{\n  fdouble (1.0, 2.0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980223.c",
    "content": "typedef struct { char *addr; long type; } object;\n\nobject bar (object blah)\n{\n  abort();\n}\n\nobject foo (object x, object y)\n{\n  object z = *(object*)(x.addr);\n  if (z.type & 64)\n    {\n      y = *(object*)(z.addr+sizeof(object));\n      z = *(object*)(z.addr);\n      if (z.type & 64)\n        y = bar(y);\n    }\n  return y;\n}\n\nint nil;\nobject cons1[2] = { {(char *) &nil, 0}, {(char *) &nil, 0} };\nobject cons2[2] = { {(char *) &cons1, 64}, {(char *) &nil, 0} };\n\nmain()\n{\n  object x = {(char *) &cons2, 64};\n  object y = {(char *) &nil, 0};\n  object three = foo(x,y);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980424-1.c",
    "content": "int i, a[99];\n\nvoid f (int one)\n{\n  if (one != 1)\n    abort ();\n}\n\nvoid\ng ()\n{\n  f (a[i & 0x3f]);\n}\n\nint\nmain ()\n{\n  a[0] = 1;\n  i = 0x40;\n  g ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980505-1.c",
    "content": "static int f(int) __attribute__((const));\nint main()\n{\n   int f1, f2, x;\n   x = 1; f1 = f(x);\n   x = 2; f2 = f(x);\n   if (f1 != 1 || f2 != 2)\n     abort ();\n   exit (0);\n}\nstatic int f(int x) { return x; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980505-2.c",
    "content": "typedef unsigned short Uint16;\ntypedef unsigned int Uint;\n\nUint f ()\n{\n        Uint16 token;\n        Uint count;\n        static Uint16 values[1] = {0x9300};\n\n        token = values[0];\n        count = token >> 8;\n\n        return count;\n}\n\nint\nmain ()\n{\n  if (f () != 0x93)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980506-1.c",
    "content": "struct decision\n{\n  char enforce_mode;             \n  struct decision *next;         \n};\n\n\nstatic void\nclear_modes (p)\n     register struct decision *p;\n{\n  goto blah;\n\nfoo:\n  p->enforce_mode = 0;\nblah:\n  if (p)\n    goto foo;\n}\n\nmain()\n{\n  struct decision *p = 0;\n  clear_modes (p);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980506-2.c",
    "content": "static void *self(void *p){ return p; }\n\nint\nf()\n{\n  struct { int i; } s, *sp;\n  int *ip = &s.i;\n\n  s.i = 1;\n  sp = self(&s);\n  \n  *ip = 0;\n  return sp->i+1;\n}\n\nmain()\n{\n  if (f () != 1)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980506-3.c",
    "content": "unsigned char lookup_table [257];\n\nstatic int \nbuild_lookup (pattern)\n     unsigned char *pattern;\n{\n  int m;\n\n  m = strlen (pattern) - 1;\n  \n  memset (lookup_table, ++m, 257);\n  return m;\n}\n\nint main(argc, argv)\n     int argc;\n     char **argv;\n{\n  if (build_lookup (\"bind\") != 4)\n    abort ();\n  else\n    exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980526-1.c",
    "content": "/* { dg-skip-if \"requires indirect jumps\" { ! indirect_jumps } { \"-O0\" } { \"\" } } */\n/* { dg-skip-if \"requires label values\" { ! label_values } { \"-O0\" } { \"\" } } */\nint expect_do1 = 1, expect_do2 = 2;\n \nstatic int doit(int x){\n  __label__ lbl1;\n  __label__ lbl2;\n  static int jtab_init = 0;\n  static void *jtab[2];\n \n  if(!jtab_init) {\n    jtab[0] = &&lbl1;\n    jtab[1] = &&lbl2;\n    jtab_init = 1;\n  }\n  goto *jtab[x];\nlbl1:\n  return 1;\nlbl2:\n  return 2;\n}\n \nstatic void do1(void) {\n  if (doit(0) != expect_do1)\n    abort ();\n}\n \nstatic void do2(void){\n  if (doit(1) != expect_do2)\n    abort ();\n}\n \nint main(void){\n#ifndef NO_LABEL_VALUES\n  do1();\n  do2();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980526-2.c",
    "content": "typedef unsigned int dev_t;\ntypedef unsigned int kdev_t;\n\nstatic inline kdev_t to_kdev_t(int dev)\n{\n\tint major, minor;\n\t\n\tif (sizeof(kdev_t) == 16)\n\t\treturn (kdev_t)dev;\n\tmajor = (dev >> 8);\n\tminor = (dev & 0xff);\n\treturn ((( major ) << 22 ) | (  minor )) ;\n\n}\n\nvoid do_mknod(const char * filename, int mode, kdev_t dev)\n{\n\tif (dev==0x15800078)\n\t\texit(0);\n\telse\n\t\tabort();\n}\n\n\nchar * getname(const char * filename)\n{\n\tregister unsigned int a1,a2,a3,a4,a5,a6,a7,a8,a9;\n\ta1 = (unsigned int)(filename) *5 + 1;\n\ta2 = (unsigned int)(filename) *6 + 2;\n\ta3 = (unsigned int)(filename) *7 + 3;\n\ta4 = (unsigned int)(filename) *8 + 4;\n\ta5 = (unsigned int)(filename) *9 + 5;\n\ta6 = (unsigned int)(filename) *10 + 5;\n\ta7 = (unsigned int)(filename) *11 + 5;\n\ta8 = (unsigned int)(filename) *12 + 5;\n\ta9 = (unsigned int)(filename) *13 + 5;\n\treturn (char *)(a1*a2+a3*a4+a5*a6+a7*a8+a9);\n}\n\nint sys_mknod(const char * filename, int mode, dev_t dev)\n{\n\tint error;\n\tchar * tmp;\n\n\ttmp = getname(filename);\n\terror = ((long)( tmp )) ;\n\tdo_mknod(tmp,mode,to_kdev_t(dev));\n\treturn error;\n}\n\nint main(void)\n{\n\tif (sizeof (int) != 4)\n\t  exit (0);\n\n\treturn sys_mknod(\"test\",1,0x12345678);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980526-3.c",
    "content": "int compare(x, y)\nunsigned int x;\nunsigned int y;\n{\n   if (x==y)\n     return 0;\n   else\n     return 1;\n}\n \nmain()\n{\n unsigned int i, j, k, l;\n i = 5; j = 2; k=0; l=2;\n if (compare(5%(~(unsigned) 2), i%~j) \n     || compare(0, k%~l))\n    abort();\n else\n    exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980602-1.c",
    "content": "main()\n{\n  int i;\n  for (i = 1; i < 100; i++)\n    ;\n  if (i == 100) \n    exit (0);\n  abort ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980602-2.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct {\n    unsigned bit : 30;\n} t;\n\nint main()\n{\n    if (!(t.bit++))\n\texit (0);\n    else\n\tabort ();\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980604-1.c",
    "content": "int a = 1;\nint b = -1;\n\nint c = 1;\nint d = 0;\n\nmain ()\n{\n  double e;\n  double f;\n  double g;\n\n  f = c;\n  g = d;\n  e = (a < b) ? f : g;\n  if (e)\n    abort ();\n  exit(0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980605-1.c",
    "content": "#include <stdio.h>\n\n#ifndef STACK_SIZE\n#define STACK_SIZE 200000\n#endif\n\n__inline__ static int\ndummy (x)\n{\n  int y;\n  y = (long) (x * 4711.3);\n  return y;\n}\n\nint getval (void);\n\nint\nf2 (double x)\n{\n  unsigned short s;\n  int a, b, c, d, e, f, g, h, i, j;\n\n  a = getval ();\n  b = getval ();\n  c = getval ();\n  d = getval ();\n  e = getval ();\n  f = getval ();\n  g = getval ();\n  h = getval ();\n  i = getval ();\n  j = getval ();\n\n\n  s = x;\n\n  return a + b + c + d + e + f + g + h + i + j + s;\n}\n\nint x = 1;\n\nint\ngetval (void)\n{\n  return x++;\n}\n\nchar buf[10];\n\nvoid\nf ()\n{\n  char ar[STACK_SIZE/2];\n  int a, b, c, d, e, f, g, h, i, j, k;\n\n  a = getval ();\n  b = getval ();\n  c = getval ();\n  d = getval ();\n  e = getval ();\n  f = getval ();\n  g = getval ();\n  h = getval ();\n  i = getval ();\n  j = getval ();\n\n  k = f2 (17.0);\n\n  sprintf (buf, \"%d\\n\", a + b + c + d + e + f + g + h + i + j + k);\n  if (a + b + c + d + e + f + g + h + i + j + k != 227)\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980608-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\n#include <stdarg.h>\n\nextern void abort(void);\nextern void exit (int);\n\nvoid f1(int a,int b,int c,int d,int e, int f,int g,int h,int i,int j, int k,int\nl,int m,int n,int o)\n{\n    return;\n}\n\ninline void debug(const char *msg,...)\n{\n    va_list ap;\n    va_start( ap, msg );\n\n    f1(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);\n\n    if ( va_arg(ap,int) != 101)\n        abort();\n    if ( va_arg(ap,int) != 102)\n        abort();\n    if ( va_arg(ap,int) != 103)\n        abort();\n    if ( va_arg(ap,int) != 104)\n        abort();\n    if ( va_arg(ap,int) != 105)\n        abort();\n    if ( va_arg(ap,int) != 106)\n        abort();\n\n    va_end( ap );\n}\n\nint main(void)\n{\n  debug(\"%d %d %d  %d %d %d\\n\", 101, 102, 103, 104, 105, 106);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980612-1.c",
    "content": "struct fd\n{\n\tunsigned char a;\n\tunsigned char b;\n} f = { 5 };\n\nstruct fd *g() { return &f; }\nint h() { return -1; }\n\nint main()\n{\n\tstruct fd *f = g();\n\tf->b = h();\n\tif (((f->a & 0x7f) & ~0x10) <= 2)\n\t\tabort ();\n\texit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980617-1.c",
    "content": "void foo (unsigned int * p)\n{\n  if ((signed char)(*p & 0xFF) == 17 || (signed char)(*p & 0xFF) == 18)\n    return;\n  else\n    abort ();\n}\n\nint main ()\n{\n  int i = 0x30011;\n  foo(&i);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980618-1.c",
    "content": "void func(int, int);\n\nint main()\n{\n        int x = 7;\n        func(!x, !7);\n\texit (0);\n}\n\nvoid func(int x, int y)\n{\n        if (x == y)\n                return;\n        else\n                abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980701-1.c",
    "content": "ns_name_skip (unsigned char **x, unsigned char *y)\n{\n  *x = 0;\n  return 0;\n}\n\nunsigned char a[2];\n\nint dn_skipname(unsigned char *ptr, unsigned char *eom) {\n    unsigned char *saveptr = ptr;\n\n    if (ns_name_skip(&ptr, eom) == -1)\n\t        return (-1);\n    return (ptr - saveptr);\n}\n\nmain()\n{\n  if (dn_skipname (&a[0], &a[1]) == 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980707-1.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n\nchar **\nbuildargv (char *input)\n{\n  static char *arglist[256];\n  int numargs = 0;\n\n  while (1)\n    {\n      while (*input == ' ')\n\tinput++;\n      if (*input == 0)\n\tbreak;\n      arglist [numargs++] = input;\n      while (*input != ' ' && *input != 0)\n\tinput++;\n      if (*input == 0)\n\tbreak;\n      *(input++) = 0;\n    }\n  arglist [numargs] = NULL;\n  return arglist;\n}\n\n\nint main()\n{\n  char **args;\n  char input[256];\n  int i;\n\n  strcpy(input, \" a b\");\n  args = buildargv(input);\n\n  if (strcmp (args[0], \"a\"))\n    abort ();\n  if (strcmp (args[1], \"b\"))\n    abort ();\n  if (args[2] != NULL)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980709-1.c",
    "content": "/* { dg-xfail-if \"Can not call system libm.a with -msoft-float\" { powerpc-*-aix* rs6000-*-aix* } { \"-msoft-float\" } { \"\" } } */\n#include <math.h>\n\nmain()\n{\n  volatile double a;\n  double c;\n  a = 32.0;\n  c = pow(a, 1.0/3.0);\n  if (c + 0.1 > 3.174802\n      && c - 0.1 < 3.174802)\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980716-1.c",
    "content": "#include <stdarg.h>\n\nvoid\nstub(int num, ...)\n{\n    va_list ap;\n    char *end;\n    int i;\n\n    for (i = 0; i < 2; i++) {\n        va_start(ap, num);\n        while ( 1 ) {\n            end = va_arg(ap, char *);\n            if (!end) break;\n        }\n        va_end(ap);\n    }\n}\n\nint\nmain()\n{\n    stub(1, \"ab\", \"bc\", \"cx\", (char *)0);\n    exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/980929-1.c",
    "content": "void f(int i)\n{\n  if (i != 1000)\n    abort ();\n}\n\n\nint main()\n{\n  int n=1000;\n  int i;\n\n  f(n);\n  for(i=0; i<1; ++i) {\n    f(n);\n    n=666;\n    &n;\n  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/981001-1.c",
    "content": "#define NG   0x100L\n\nunsigned long flg = 0;\n\nlong sub (int n)\n{\n  int a, b ;\n\n  if (n >= 2)\n    {\n      if (n % 2 == 0)\n\t{\n\t  a = sub (n / 2);\n\t  \n\t  return (a + 2 * sub (n / 2 - 1)) * a;\n\t}\n      else\n\t{\n\t  a = sub (n / 2 + 1);\n\t  b = sub (n / 2);\n\t  \n\t  return a * a + b * b;\n\t}\n    }\n  else \n    return (long) n;\n}\n\nint main (void)\n{\n  if (sub (30) != 832040L)\n    flg |= NG;\n\n  if (flg)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/981019-1.c",
    "content": "/* { dg-skip-if \"ptxas seg faults\" { nvptx-*-* } { \"-O3*\" } { \"\" } } */\n\nextern int f2(void);\nextern int f3(void);\nextern void f1(void);\n\nvoid\nff(int fname, int part, int nparts)\n{\n  if (fname)  /* bb 0 */\n    {\n      if (nparts)  /* bb 1 */\n\tf1();  /* bb 2 */\n    }\n  else\n    fname = 2; /* bb 3  */\n\n  /* bb 4 is the branch to bb 10\n     (bb 10 is physically at the end of the loop) */\n  while (f3() /* bb 10 */)\n    {\n      if (nparts /* bb 5 */ && f2() /* bb 6 */)\n\t{\n\t  f1();  /* bb 7 ... */\n\t  nparts = part;\n\t  if (f3())  /* ... bb 7 */\n\t    f1();  /* bb 8 */\n\t  f1(); /* bb 9 */\n\t  break;\n\t}\n    }\n\n  if (nparts)  /* bb 11 */\n    f1(); /* bb 12 */\n  return; /* bb 13 */\n}\n\nint main(void)\n{\n  ff(0, 1, 0);\n  return 0;\n}\n\nint f3(void) { static int x = 0; x = !x; return x; }\nvoid f1(void) { abort(); }\nint f2(void) { abort(); }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/981130-1.c",
    "content": "/* { dg-xfail-if \"alias analysis conflicts with instruction scheduling\" { m32r-*-* } { \"-O2\" \"-O1\" \"-O0\" \"-Os\"} { \"\" } } */\nstruct s { int a; int b;};\nstruct s s1;\nstruct s s2 = { 1, 2, };\n\nvoid\ncheck (a, b)\n     int a;\n     int b;\n{\n  if (a == b)\n    exit (0);\n  else\n    abort ();\n}\n\nint\nmain ()\n{\n  int * p;\n  int x;\n  \n  s1.a = 9;\n  p    = & s1.a;\n  s1   = s2;\n  x    = * p;\n  \n  check (x, 1);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/981206-1.c",
    "content": "/* Verify unaligned address aliasing on Alpha EV[45].  */\n\nstatic unsigned short x, y;\n\nvoid foo()\n{\n  x = 0x345;\n  y = 0x567;\n}\n\nint main()\n{\n  foo ();\n  if (x != 0x345 || y != 0x567)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990106-1.c",
    "content": "foo(bufp)\nchar *bufp;\n{\n    int x = 80;\n    return (*bufp++ = x ? 'a' : 'b');\n}\n\nmain()\n{\n  char x;\n\n  if (foo (&x) != 'a')\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990106-2.c",
    "content": "unsigned calc_mp(unsigned mod)\n{\n      unsigned a,b,c;\n      c=-1;\n      a=c/mod;\n      b=0-a*mod;\n      if (b > mod) { a += 1; b-=mod; }\n      return b;\n}\n\nint main(int argc, char *argv[])\n{\n      unsigned x = 1234;\n      unsigned y = calc_mp(x);\n\n      if ((sizeof (y) == 4 && y != 680)\n\t  || (sizeof (y) == 2 && y != 134))\n\tabort ();\n      exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990117-1.c",
    "content": "int\nfoo (int x, int y, int i, int j)\n{\n  double tmp1 = ((double) x / y);\n  double tmp2 = ((double) i / j);\n\n  return tmp1 < tmp2;\n}\n\nmain ()\n{\n  if (foo (2, 24, 3, 4) == 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990127-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nmain()\n{\n    int a,b,c;\n    int *pa, *pb, *pc;\n    int **ppa, **ppb, **ppc;\n    int i,j,k,x,y,z;\n\n    a = 10;\n    b = 20;\n    c = 30;\n    pa = &a; pb = &b; pc = &c;\n    ppa = &pa; ppb = &pb; ppc = &pc;\n    x = 0; y = 0; z = 0;\n\n    for(i=0;i<10;i++){\n        if( pa == &a ) pa = &b;\n        else pa = &a;\n        while( (*pa)-- ){\n            x++;\n            if( (*pa) < 3 ) break;\n            else pa = &b;\n        }\n        x++;\n        pa = &b;\n    }\n\n    if ((*pa) != -5 || (*pb) != -5 || x != 43)\n      abort ();\n\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990127-2.c",
    "content": "/* { dg-options \"-mpc64\"  { target { i?86-*-* x86_64-*-* } } } */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfpEq (double x, double y)\n{\n  if (x != y)\n    abort ();\n}\n\nvoid\nfpTest (double x, double y)\n{\n  double result1 = (35.7 * 100.0) / 45.0;\n  double result2 = (x * 100.0) / y;\n  fpEq (result1, result2);\n}\n\nint\nmain ()\n{\n  fpTest (35.7, 45.0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990128-1.c",
    "content": "extern int printf (const char *,...);\n\nstruct s { struct s *n; } *p;\nstruct s ss;\n#define MAX     10\nstruct s sss[MAX];\nint count = 0;\n\nvoid sub( struct s *p, struct s **pp );\nint look( struct s *p, struct s **pp );\n\nmain()\n{\n    struct s *pp;\n    struct s *next;\n    int i;\n\n    p = &ss;\n    next = p;\n    for ( i = 0; i < MAX; i++ ) {\n        next->n = &sss[i];\n        next = next->n;\n    }\n    next->n = 0;\n\n    sub( p, &pp );\n    if (count != MAX+2)\n      abort ();\n\n    exit( 0 );\n}\n\nvoid sub( struct s *p, struct s **pp )\n{\n   for ( ; look( p, pp ); ) {\n        if ( p )\n            p = p->n;\n        else\n            break;\n   }\n}\n\nint look( struct s *p, struct s **pp )\n{\n    for ( ; p; p = p->n )\n        ;\n    *pp = p;\n    count++;\n    return( 1 );\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990130-1.c",
    "content": "int count = 0;\nint dummy;\n\nstatic int *\nbar(void)\n{\n  ++count;\n  return &dummy;\n}\n\nstatic void\nfoo(void)\n{\n  asm(\"\" : \"+r\"(*bar()));\n}\n\nmain()\n{\n  foo();\n  if (count != 1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990208-1.c",
    "content": "/* As a quality of implementation issue, we should not prevent inlining\n   of function explicitly marked inline just because a label therein had\n   its address taken.  */\n\n#ifndef NO_LABEL_VALUES\nstatic void *ptr1, *ptr2;\nstatic int i = 1;\n\nstatic __inline__ void doit(void **pptr, int cond)\n{\n  if (cond) {\n  here:\n    *pptr = &&here;\n  }\n}\n\n__attribute__ ((noinline))\nstatic void f(int cond)\n{\n  doit (&ptr1, cond);\n}\n\n__attribute__ ((noinline))\nstatic void g(int cond)\n{\n  doit (&ptr2, cond);\n}\n\n__attribute__ ((noinline))\nstatic void bar(void);\n\nint main()\n{\n  f (i);\n  bar();\n  g (i);\n\n#ifdef  __OPTIMIZE__\n  if (ptr1 == ptr2)\n    abort ();\n#endif\n\n  exit (0);\n}\n\nvoid bar(void) { }\n\n#else /* NO_LABEL_VALUES */\nint main() { exit(0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990211-1.c",
    "content": "/* Copyright (C) 1999 Free Software Foundation, Inc.\n  Contributed by Nathan Sidwell 20 Jan 1999 <nathan@acm.org> */\n\n/* check range combining boolean operations work */\n\nextern void abort();\n\n#define N 77\n\nvoid func(int i)\n{\n  /* fold-const does some clever things with range tests. Make sure\n     we get (some of) them right */\n  \n  /* these must fail, regardless of the value of i */\n  if ((i < 0) && (i >= 0))\n    abort();\n  if ((i > 0) && (i <= 0))\n    abort();\n  if ((i >= 0) && (i < 0))\n    abort();\n  if ((i <= 0) && (i > 0))\n    abort();\n\n  if ((i < N) && (i >= N))\n    abort();\n  if ((i > N) && (i <= N))\n    abort();\n  if ((i >= N) && (i < N))\n    abort();\n  if ((i <= N) && (i > N))\n    abort();\n    \n  /* these must pass, regardless of the value of i */\n  if (! ((i < 0) || (i >= 0)))\n    abort();\n  if (! ((i > 0) || (i <= 0)))\n    abort();\n  if (! ((i >= 0) || (i < 0)))\n    abort();\n  if (! ((i <= 0) || (i > 0)))\n    abort();\n\n  if (! ((i < N) || (i >= N)))\n    abort();\n  if (! ((i > N) || (i <= N)))\n    abort();\n  if (! ((i >= N) || (i < N)))\n    abort();\n  if (! ((i <= N) || (i > N)))\n    abort();\n  \n  return;\n}\n\nint main()\n{\n  func(0);\n  func(1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990222-1.c",
    "content": "char line[4] = { '1', '9', '9', '\\0' };\n\nint main()\n{\n  char *ptr = line + 3;\n\n  while ((*--ptr += 1) > '9') *ptr = '0';\n  if (line[0] != '2' || line[1] != '0' || line[2] != '0')\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990324-1.c",
    "content": "void f(long i)\n{\n  if ((signed char)i < 0 || (signed char)i == 0) \n    abort ();\n  else\n    exit (0);\n}\n\nmain()\n{\n  f(0xffffff01);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990326-1.c",
    "content": "struct a {\n\tchar a, b;\n\tshort c;\n};\n\nint\na1()\n{\n\tstatic struct a x = { 1, 2, ~1 }, y = { 65, 2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\na2()\n{\n\tstatic struct a x = { 1, 66, ~1 }, y = { 1, 2, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\na3()\n{\n\tstatic struct a x = { 9, 66, ~1 }, y = { 33, 18, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct b {\n\tint c;\n\tshort b, a;\n};\n\nint\nb1()\n{\n\tstatic struct b x = { ~1, 2, 1 }, y = { ~2, 2, 65 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nb2()\n{\n\tstatic struct b x = { ~1, 66, 1 }, y = { ~2, 2, 1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nb3()\n{\n\tstatic struct b x = { ~1, 66, 9 }, y = { ~2, 18, 33 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct c {\n\tunsigned int c:4, b:14, a:14;\n} __attribute__ ((aligned));\n\nint\nc1()\n{\n\tstatic struct c x = { ~1, 2, 1 }, y = { ~2, 2, 65 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nc2()\n{\n\tstatic struct c x = { ~1, 66, 1 }, y = { ~2, 2, 1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nc3()\n{\n\tstatic struct c x = { ~1, 66, 9 }, y = { ~2, 18, 33 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct d {\n\tunsigned int a:14, b:14, c:4;\n} __attribute__ ((aligned));\n\nint\nd1()\n{\n\tstatic struct d x = { 1, 2, ~1 }, y = { 65, 2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nd2()\n{\n\tstatic struct d x = { 1, 66, ~1 }, y = { 1, 2, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nd3()\n{\n\tstatic struct d x = { 9, 66, ~1 }, y = { 33, 18, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct e {\n\tint c:4, b:14, a:14;\n} __attribute__ ((aligned));\n\nint\ne1()\n{\n\tstatic struct e x = { ~1, -2, -65 }, y = { ~2, -2, -1 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\ne2()\n{\n\tstatic struct e x = { ~1, -2, -1 }, y = { ~2, -66, -1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\ne3()\n{\n\tstatic struct e x = { ~1, -18, -33 }, y = { ~2, -66, -9 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\ne4()\n{\n\tstatic struct e x = { -1, -1, 0 };\n\n\treturn x.a == 0 && x.b & 0x2000;\n}\n\nstruct f {\n\tint a:14, b:14, c:4;\n} __attribute__ ((aligned));\n\nint\nf1()\n{\n\tstatic struct f x = { -65, -2, ~1 }, y = { -1, -2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nf2()\n{\n\tstatic struct f x = { -1, -2, ~1 }, y = { -1, -66, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nf3()\n{\n\tstatic struct f x = { -33, -18, ~1 }, y = { -9, -66, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\nf4()\n{\n\tstatic struct f x = { 0, -1, -1 };\n\n\treturn x.a == 0 && x.b & 0x2000;\n}\n\nstruct gx {\n\tint c:4, b:14, a:14;\n} __attribute__ ((aligned));\nstruct gy {\n\tint b:14, a:14, c:4;\n} __attribute__ ((aligned));\n\nint\ng1()\n{\n\tstatic struct gx x = { ~1, -2, -65 };\n\tstatic struct gy y = { -2, -1, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\ng2()\n{\n\tstatic struct gx x = { ~1, -2, -1 };\n\tstatic struct gy y = { -66, -1, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\ng3()\n{\n\tstatic struct gx x = { ~1, -18, -33 };\n\tstatic struct gy y = { -66, -9, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\ng4()\n{\n\tstatic struct gx x = { ~1, 0x0020, 0x0010 };\n\tstatic struct gy y = { 0x0200, 0x0100, ~2 };\n\n\treturn ((x.a & 0x00f0) == (y.a & 0x0f00) &&\n\t\t(x.b & 0x00f0) == (y.b & 0x0f00));\n}\n\nint\ng5()\n{\n\tstatic struct gx x = { ~1, 0x0200, 0x0100 };\n\tstatic struct gy y = { 0x0020, 0x0010, ~2 };\n\n\treturn ((x.a & 0x0f00) == (y.a & 0x00f0) &&\n\t\t(x.b & 0x0f00) == (y.b & 0x00f0));\n}\n\nint\ng6()\n{\n\tstatic struct gx x = { ~1, 0xfe20, 0xfd10 };\n\tstatic struct gy y = { 0xc22f, 0xc11f, ~2 };\n\n\treturn ((x.a & 0x03ff) == (y.a & 0x3ff0) &&\n\t\t(x.b & 0x03ff) == (y.b & 0x3ff0));\n}\n\nint\ng7()\n{\n\tstatic struct gx x = { ~1, 0xc22f, 0xc11f };\n\tstatic struct gy y = { 0xfe20, 0xfd10, ~2 };\n\n\treturn ((x.a & 0x3ff0) == (y.a & 0x03ff) &&\n\t\t(x.b & 0x3ff0) == (y.b & 0x03ff));\n}\n\nstruct hx {\n\tint a:14, b:14, c:4;\n} __attribute__ ((aligned));\nstruct hy {\n\tint c:4, a:14, b:14;\n} __attribute__ ((aligned));\n\nint\nh1()\n{\n\tstatic struct hx x = { -65, -2, ~1 };\n\tstatic struct hy y = { ~2, -1, -2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nh2()\n{\n\tstatic struct hx x = { -1, -2, ~1 };\n\tstatic struct hy y = { ~2, -1, -66 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nh3()\n{\n\tstatic struct hx x = { -33, -18, ~1 };\n\tstatic struct hy y = { ~2, -9, -66 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\nh4()\n{\n\tstatic struct hx x = { 0x0010, 0x0020, ~1 };\n\tstatic struct hy y = { ~2, 0x0100, 0x0200 };\n\n\treturn ((x.a & 0x00f0) == (y.a & 0x0f00) &&\n\t\t(x.b & 0x00f0) == (y.b & 0x0f00));\n}\n\nint\nh5()\n{\n\tstatic struct hx x = { 0x0100, 0x0200, ~1 };\n\tstatic struct hy y = { ~2, 0x0010, 0x0020 };\n\n\treturn ((x.a & 0x0f00) == (y.a & 0x00f0) &&\n\t\t(x.b & 0x0f00) == (y.b & 0x00f0));\n}\n\nint\nh6()\n{\n\tstatic struct hx x = { 0xfd10, 0xfe20, ~1 };\n\tstatic struct hy y = { ~2, 0xc11f, 0xc22f };\n\n\treturn ((x.a & 0x03ff) == (y.a & 0x3ff0) &&\n\t\t(x.b & 0x03ff) == (y.b & 0x3ff0));\n}\n\nint\nh7()\n{\n\tstatic struct hx x = { 0xc11f, 0xc22f, ~1 };\n\tstatic struct hy y = { ~2, 0xfd10, 0xfe20 };\n\n\treturn ((x.a & 0x3ff0) == (y.a & 0x03ff) &&\n\t\t(x.b & 0x3ff0) == (y.b & 0x03ff));\n}\n\nint\nmain()\n{\n  if (!a1 ())\n    abort ();\n  if (!a2 ())\n    abort ();\n  if (!a3 ())\n    abort ();\n  if (!b1 ())\n    abort ();\n  if (!b2 ())\n    abort ();\n  if (!b3 ())\n    abort ();\n  if (!c1 ())\n    abort ();\n  if (!c2 ())\n    abort ();\n  if (!c3 ())\n    abort ();\n  if (!d1 ())\n    abort ();\n  if (!d2 ())\n    abort ();\n  if (!d3 ())\n    abort ();\n  if (!e1 ())\n    abort ();\n  if (!e2 ())\n    abort ();\n  if (!e3 ())\n    abort ();\n  if (!e4 ())\n    abort ();\n  if (!f1 ())\n    abort ();\n  if (!f2 ())\n    abort ();\n  if (!f3 ())\n    abort ();\n  if (!f4 ())\n    abort ();\n  if (!g1 ())\n    abort ();\n  if (!g2 ())\n    abort ();\n  if (!g3 ())\n    abort ();\n  if (g4 ())\n    abort ();\n  if (g5 ())\n    abort ();\n  if (!g6 ())\n    abort ();\n  if (!g7 ())\n    abort ();\n  if (!h1 ())\n    abort ();\n  if (!h2 ())\n    abort ();\n  if (!h3 ())\n    abort ();\n  if (h4 ())\n    abort ();\n  if (h5 ())\n    abort ();\n  if (!h6 ())\n    abort ();\n  if (!h7 ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990404-1.c",
    "content": "\nint x[10] = { 0,1,2,3,4,5,6,7,8,9};\n\nint\nmain()\n{\n  int niterations = 0, i;\n\n  for (;;) {\n    int i, mi, max;\n    max = 0;\n    for (i = 0; i < 10 ; i++) {\n      if (x[i] > max) {\n\tmax = x[i];\n\tmi = i;\n      }\n    }\n    if (max == 0)\n      break;\n    x[mi] = 0;\n    niterations++;\n    if (niterations > 10)\n      abort ();\n  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990413-2.c",
    "content": "/* This tests for a bug in regstack that was breaking glibc's math library. */\n/* { dg-skip-if \"\" { ! { i?86-*-* x86_64-*-* } } { \"*\" } { \"\" } } */\n\nextern void abort (void);\n\nstatic __inline double\nminus_zero (void)\n{\n  union { double __d; int __i[2]; } __x;\n  __x.__i[0] = 0x0;\n  __x.__i[1] = 0x80000000;\n  return __x.__d;\n}\n\nstatic __inline long double\n__atan2l (long double __y, long double __x)\n{\n  register long double __value;\n  __asm __volatile__ (\"fpatan\\n\\t\"\n\t\t      : \"=t\" (__value)\n\t\t      : \"0\" (__x), \"u\" (__y)\n\t\t      : \"st(1)\");\n  return __value;\n}\n\nstatic __inline long double\n__sqrtl (long double __x)\n{\n  register long double __result;\n  __asm __volatile__ (\"fsqrt\" : \"=t\" (__result) : \"0\" (__x));\n  return __result;\n}\n\nstatic __inline double\nasin (double __x)\n{\n  return __atan2l (__x, __sqrtl (1.0 - __x * __x));\n}\n\nint\nmain (void)\n{\n  double x;\n\n  x = minus_zero();\n  x = asin (x);\n\n  if (x != 0.0) /* actually -0.0, but 0.0 == -0.0 */\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990513-1.c",
    "content": "#include <string.h>\n\nvoid foo (int *BM_tab, int j)\n{\n  int *BM_tab_base;\n\n  BM_tab_base = BM_tab;\n  BM_tab += 0400;\n  while (BM_tab_base != BM_tab)\n    {\n      *--BM_tab = j;\n      *--BM_tab = j;\n      *--BM_tab = j;\n      *--BM_tab = j;\n    }\n}\n\nint main ()\n{\n  int BM_tab[0400];\n  memset (BM_tab, 0, sizeof (BM_tab));\n  foo (BM_tab, 6);\n  if (BM_tab[0] != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990524-1.c",
    "content": "char a[] = \"12345\";\nchar b[] = \"12345\";\n\nvoid loop (char * pz, char * pzDta)\n{\n    for (;;) {\n        switch (*(pz++) = *(pzDta++)) {\n        case 0:\n  \t    goto loopDone2;\n\n\tcase '\"':\n\tcase '\\\\':\n\t    pz[-1]  = '\\\\';\n            *(pz++) = pzDta[-1];\n\t}\n    } loopDone2:;\n\n  if (a - pz != b - pzDta)\n    abort ();\n}\n\nmain()\n{\n  loop (a, b);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990525-1.c",
    "content": "struct blah {\n    int m1, m2;\n};\n\nvoid die(struct blah arg)\n{\n    int i ;\n    struct blah buf[1];\n\n    for (i = 0; i < 1 ; buf[i++] = arg)\n        ;\n    if (buf[0].m1 != 1) {\n        abort ();\n    }\n}\n\nint main()\n{\n    struct blah s = { 1, 2 };\n\n    die(s);\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990525-2.c",
    "content": "typedef struct {\n    int v[4];\n} Test1;\n\nTest1 func2();\n\nint func1()\n{\n    Test1 test;\n    test = func2();\n\n    if (test.v[0] != 10)\n      abort ();\n    if (test.v[1] != 20)\n      abort ();\n    if (test.v[2] != 30)\n      abort ();\n    if (test.v[3] != 40)\n      abort ();\n}\n\nTest1 func2()\n{\n    Test1 tmp;\n    tmp.v[0] = 10;\n    tmp.v[1] = 20;\n    tmp.v[2] = 30;\n    tmp.v[3] = 40;\n    return tmp;\n}\n\n\nint main()\n{\n    func1();\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990527-1.c",
    "content": "int sum;\n\nvoid\ng (int i)\n{\n  sum += i;\n}\n\nvoid\nf(int j)\n{\n  int i;\n\n  for (i = 0; i < 9; i++)\n    {\n      j++;\n      g (j);\n      j = 9;\n    }\n}\n\nint\nmain ()\n{\n  f (0);\n  if (sum != 81)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990531-1.c",
    "content": "   unsigned long bad(int reg, unsigned long inWord)\n   {\n       union {\n           unsigned long word;\n           unsigned char byte[4];\n       } data;\n\n       data.word = inWord;\n       data.byte[reg] = 0;\n\n       return data.word;\n   }\n\nmain()\n{\n  /* XXX This test could be generalized.  */\n  if (sizeof (long) != 4)\n    exit (0);\n\n  if (bad (0, 0xdeadbeef) == 0xdeadbeef)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990604-1.c",
    "content": "int b;\nvoid f ()\n{\n  int i = 0;\n  if (b == 0)\n    do {\n      b = i;\n      i++;\n    } while (i < 10);\n}\n\nint main ()\n{\n  f ();\n  if (b != 9)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990628-1.c",
    "content": "#include <stdlib.h>\n\nstruct {\n    long sqlcode;\n} sqlca;\n\n\nstruct data_record {\n    int dummy;\n    int a[100];\n} *data_ptr, data_tmp;\n\n\nint\nnum_records()\n{\n    return 1;\n}\n\n\nvoid\nfetch()\n{\n    static int fetch_count;\n\n    memset(&data_tmp, 0x55, sizeof(data_tmp));\n    sqlca.sqlcode = (++fetch_count > 1 ? 100 : 0);\n}\n\n\nvoid\nload_data() {\n    struct data_record *p;\n    int num = num_records();\n\n    data_ptr = malloc(num * sizeof(struct data_record));\n    memset(data_ptr, 0xaa, num * sizeof(struct data_record));\n\n    fetch();\n    p = data_ptr;\n    while (sqlca.sqlcode == 0) {\n        *p++ = data_tmp;\n        fetch();\n    }\n}\n\n\nmain()\n{\n    load_data();\n    if (sizeof (int) == 2 && data_ptr[0].dummy != 0x5555)\n      abort ();\n    else if (sizeof (int) > 2 && data_ptr[0].dummy != 0x55555555)\n      abort ();\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990804-1.c",
    "content": "int gfbyte ( void ) \n{\n return 0;\n} \n\nint main( void ) \n{\n int i,j,k ;\n\n i = gfbyte();\n\n i = i + 1 ;\n\n if ( i == 0 ) \n     k = -0 ;\n else\n     k = i + 0 ;\n\n if (i != 1)\n   abort ();\n\n k = 1 ;\n if ( k <= i)\n     do \n\t j = gfbyte () ;\n     while ( k++ < i ) ;\n\n exit (0);\n} \n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990811-1.c",
    "content": "struct s {long a; int b;};\n\nint foo(int x, void *y)\n{\n  switch(x) {\n    case 0: return ((struct s*)y)->a;\n    case 1: return *(signed char*)y;\n    case 2: return *(short*)y;\n  }\n  abort();\n}\n\nint main ()\n{\n  struct s s;\n  short sh[10];\n  signed char c[10];\n  int i;\n\n  s.a = 1;\n  s.b = 2;\n  for (i = 0; i < 10; i++) {\n    sh[i] = i;\n    c[i] = i;\n  }\n\n  if (foo(0, &s) != 1) abort();\n  if (foo(1, c+3) != 3) abort();\n  if (foo(2, sh+3) != 3) abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990826-0.c",
    "content": "/*\nFrom: niles@fan745.gsfc.nasa.gov\nTo: fortran@gnu.org\nSubject: Re: Scary problems in g77 for RedHat 6.0. (glibc-2.1) \nDate: Sun, 06 Jun 1999 23:37:23 -0400\nX-UIDL: 9c1e40c572e3b306464f703461764cd5\n*/\n\n/* { dg-xfail-if \"Can not call system libm.a with -msoft-float\" { powerpc-*-aix* rs6000-*-aix* } { \"-msoft-float\" } { \"\" } } */\n\n#include <stdio.h>\n#include <math.h>\n\nint\nmain()\n{\n  if (floor (0.1) != 0.)\n    abort ();\n  return 0;\n}\n\n/*\nIt will result in 36028797018963968.000000 on Alpha RedHat Linux 6.0\nusing glibc-2.1 at least on my 21064.  This may result in g77 bug\nreports concerning the INT() function, just so you know.\n\n\tThanks,\t\n\tRick Niles.\n*/\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990827-1.c",
    "content": "unsigned test(unsigned one , unsigned  bit)\n{\n    unsigned val=  bit & 1;\n    unsigned zero= one >> 1;\n\n    val++;\n    return zero + ( val>> 1 );\n}\n\nint main()\n{\n  if (test (1,0) != 0)\n    abort ();\n  if (test (1,1) != 1)\n    abort ();\n  if (test (1,65535) != 1)\n    abort ();\n  exit (0);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990829-1.c",
    "content": "double test (const double le, const double ri)\n{\n\tdouble val = ( ri - le ) / ( ri * ( le + 1.0 ) );\n\treturn val;\n}\n\nint main ()\n{\n        double retval;\n\n\tretval = test(1.0,2.0);\n        if (retval < 0.24 || retval > 0.26)\n\t  abort ();\n\texit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/990923-1.c",
    "content": "#define mask  0xffff0000L\n#define value 0xabcd0000L\n\nlong\nfoo (long x)\n{\n  if ((x & mask) == value)\n    return x & 0xffffL;\n  return 1;\n}\n\nint \nmain (void)\n{\n  if (foo (value) != 0 || foo (0) != 1)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991014-1.c",
    "content": "\ntypedef __SIZE_TYPE__ Size_t;\n\n#if __SIZEOF_LONG__ < __SIZEOF_POINTER__\n#define bufsize ((1LL << (8 * sizeof(Size_t) - 2))-256)\n#else\n#define bufsize ((1L << (8 * sizeof(Size_t) - 2))-256)\n#endif\n\nstruct huge_struct\n{\n  short buf[bufsize];\n  int a;\n  int b;\n  int c;\n  int d;\n};\n\nunion huge_union\n{\n  int a;\n  char buf[bufsize];\n};\n\nSize_t union_size()\n{\n  return sizeof(union huge_union);\n}\n\nSize_t struct_size()\n{\n  return sizeof(struct huge_struct);\n}\n\nSize_t struct_a_offset()\n{\n  return (Size_t)(&((struct huge_struct *) 0)->a);\n}\n\nint main()\n{\n  /* Check the exact sizeof value. bufsize is aligned on 256b. */\n  if (union_size() != sizeof(char) * bufsize)\n    abort();\n\n  if (struct_size() != sizeof(short) * bufsize + 4*sizeof(int))\n    abort();\n\n  if (struct_a_offset() < sizeof(short) * bufsize)\n    abort();  \n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991016-1.c",
    "content": "/* Two of these types will, on current gcc targets, have the same\n   mode but have different alias sets.  DOIT tries to get gcse to\n   invalidly hoist one of the values out of the loop.  */\n\ntypedef int T0;\ntypedef long T1;\ntypedef long long T2;\n\nint\ndoit(int sel, int n, void *p)\n{\n  T0 * const p0 = p;\n  T1 * const p1 = p;\n  T2 * const p2 = p;\n\n  switch (sel)\n    {\n    case 0:\n      do \n\t*p0 += *p0;\n      while (--n);\n      return *p0 == 0;\n\n    case 1:\n      do \n\t*p1 += *p1;\n      while (--n);\n      return *p1 == 0;\n\n    case 2:\n      do \n\t*p2 += *p2;\n      while (--n);\n      return *p2 == 0;\n\n    default:\n      abort ();\n    }\n}\n\nint\nmain()\n{\n  T0 v0; T1 v1; T2 v2;\n\n  v0 = 1; doit(0, 5, &v0);\n  v1 = 1; doit(1, 5, &v1);\n  v2 = 1; doit(2, 5, &v2);\n\n  if (v0 != 32) abort ();\n  if (v1 != 32) abort ();\n  if (v2 != 32) abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991019-1.c",
    "content": "typedef struct {\n     double epsilon;\n} material_type;\n\nmaterial_type foo(double x)\n{\n     material_type m;\n\n     m.epsilon = 1.0 + x;\n     return m;\n}\n\nmain()\n{\n  int i;\n  material_type x;\n\n  /* We must iterate enough times to overflow the FP stack on the\n     x86.  */\n  for (i = 0; i < 10; i++)\n    {\n      x = foo (1.0);\n      if (x.epsilon != 1.0 + 1.0)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991023-1.c",
    "content": "\n\nint blah;\nfoo()\n{\n  int i;\n\n  for (i=0 ; i< 7 ; i++)\n    {\n      if (i == 7 - 1)\n\tblah = 0xfcc;\n      else\n\tblah = 0xfee;\n    }\n  return blah;\n}\n\n\nmain()\n{\n  if (foo () != 0xfcc)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991030-1.c",
    "content": "double x = 0x1.fp1;\nint main()\n{\n  if (x !=  3.875)\n    abort ();\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991112-1.c",
    "content": "/* This code was miscompiled at -O3 on x86.\n   Reported by Jim Meyering; distilled from bash.  */\n\nint rl_show_char (int c) { return 0; }\n\nint rl_character_len (int c, int pos)\n{\n  return isprint (c) ? 1 : 2;\n}\n\nint main(void)\n{\n  int (*x)(int, int) = rl_character_len;\n  if (x('a', 1) != 1)\n    abort();\n  if (x('\\002', 1) != 2)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991118-1.c",
    "content": "struct tmp\n{\n  long long int pad : 12;\n  long long int field : 52;\n};\n\nstruct tmp2\n{\n  long long int field : 52;\n  long long int pad : 12;\n};\n\nstruct tmp3\n{\n  long long int pad : 11;\n  long long int field : 53;\n};\n\nstruct tmp4\n{\n  long long int field : 53;\n  long long int pad : 11;\n};\n\nstruct tmp\nsub (struct tmp tmp)\n{\n  tmp.field ^= 0x0008765412345678LL;\n  return tmp;\n}\n\nstruct tmp2\nsub2 (struct tmp2 tmp2)\n{\n  tmp2.field ^= 0x0008765412345678LL;\n  return tmp2;\n}\n\nstruct tmp3\nsub3 (struct tmp3 tmp3)\n{\n  tmp3.field ^= 0x0018765412345678LL;\n  return tmp3;\n}\n\nstruct tmp4\nsub4 (struct tmp4 tmp4)\n{\n  tmp4.field ^= 0x0018765412345678LL;\n  return tmp4;\n}\n\nstruct tmp tmp = {0x123, 0x123456789ABCDLL};\nstruct tmp2 tmp2 = {0x123456789ABCDLL, 0x123};\nstruct tmp3 tmp3 = {0x123, 0x1FFFF00000000LL};\nstruct tmp4 tmp4 = {0x1FFFF00000000LL, 0x123};\n\nmain()\n{\n\n  if (sizeof (long long) != 8)\n    exit (0);\n\n  tmp = sub (tmp);\n  tmp2 = sub2 (tmp2);\n\n  if (tmp.pad != 0x123 || tmp.field != 0xFFF9551175BDFDB5LL)\n    abort ();\n  if (tmp2.pad != 0x123 || tmp2.field != 0xFFF9551175BDFDB5LL)\n    abort ();\n\n  tmp3 = sub3 (tmp3);\n  tmp4 = sub4 (tmp4);\n  if (tmp3.pad != 0x123 || tmp3.field != 0xFFF989AB12345678LL)\n    abort ();\n  if (tmp4.pad != 0x123 || tmp4.field != 0xFFF989AB12345678LL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991201-1.c",
    "content": "struct vc_data {\n\tunsigned long\tspace;\n\tunsigned char   vc_palette[16*3];        \n};\n\nstruct vc {\n\tstruct vc_data *d;\n};\n\nstruct vc_data a_con;\nstruct vc vc_cons[63] = { &a_con };\nint default_red[16];\nint default_grn[16];\nint default_blu[16];\n\nextern void bar(int);\n\nvoid reset_palette(int currcons)\n{\n\tint j, k;\n\tfor (j=k=0; j<16; j++) {\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_red[j];\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_grn[j];\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_blu[j];\n\t}\n\tbar(k);\n}\n\nvoid bar(int k)\n{\n\tif (k != 16*3)\n\t\tabort();\n}\n\nint main()\n{\n\treset_palette(0);\n\texit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991202-1.c",
    "content": "int x, y;\n\nint\nmain()\n{\n  x = 2;\n  y = x;\n  do\n    {\n      x = y;\n      y = 2 * y;\n    }\n  while ( ! ((y - x) >= 20));\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991202-2.c",
    "content": "\nint\nf1 ()\n{\n  unsigned long x, y = 1;\n\n  x = ((y * 8192) - 216) % 16;\n  return x;\n}\n\nint\nmain ()\n{\n  if (f1 () != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991202-3.c",
    "content": "\nunsigned int f (unsigned int a)\n{\n  return a * 65536 / 8;\n}\n\nunsigned int g (unsigned int a)\n{\n  return a * 65536;\n}\n\nunsigned int h (unsigned int a)\n{\n  return a / 8;\n}\n\nint main ()\n{\n  if (f (65536) != h (g (65536)))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991216-1.c",
    "content": "#define VALUE 0x123456789abcdefLL\n#define AFTER 0x55\n\nvoid\ntest1 (int a, long long value, int after)\n{\n  if (a != 1\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest2 (int a, int b, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest3 (int a, int b, int c, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest4 (int a, int b, int c, int d, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest5 (int a, int b, int c, int d, int e, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest6 (int a, int b, int c, int d, int e, int f, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest7 (int a, int b, int c, int d, int e, int f, int g, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || g != 7\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest8 (int a, int b, int c, int d, int e, int f, int g, int h, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || g != 7\n      || h != 8\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nint\nmain ()\n{\n  test1 (1, VALUE, AFTER);\n  test2 (1, 2, VALUE, AFTER);\n  test3 (1, 2, 3, VALUE, AFTER);\n  test4 (1, 2, 3, 4, VALUE, AFTER);\n  test5 (1, 2, 3, 4, 5, VALUE, AFTER);\n  test6 (1, 2, 3, 4, 5, 6, VALUE, AFTER);\n  test7 (1, 2, 3, 4, 5, 6, 7, VALUE, AFTER);\n  test8 (1, 2, 3, 4, 5, 6, 7, 8, VALUE, AFTER);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991216-2.c",
    "content": "#include <stdarg.h>\n\n#define VALUE 0x123456789abcdefLL\n#define AFTER 0x55\n\nvoid\ntest (int n, ...)\n{\n  va_list ap;\n  int i;\n\n  va_start (ap, n);\n  for (i = 2; i <= n; i++)\n    {\n      if (va_arg (ap, int) != i)\n\tabort ();\n    }\n\n  if (va_arg (ap, long long) != VALUE)\n    abort ();\n\n  if (va_arg (ap, int) != AFTER)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  test (1, VALUE, AFTER);\n  test (2, 2, VALUE, AFTER);\n  test (3, 2, 3, VALUE, AFTER);\n  test (4, 2, 3, 4, VALUE, AFTER);\n  test (5, 2, 3, 4, 5, VALUE, AFTER);\n  test (6, 2, 3, 4, 5, 6, VALUE, AFTER);\n  test (7, 2, 3, 4, 5, 6, 7, VALUE, AFTER);\n  test (8, 2, 3, 4, 5, 6, 7, 8, VALUE, AFTER);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991216-4.c",
    "content": "/* Test against a problem with loop reversal.  */\nstatic void bug(int size, int tries)\n{\n    int i;\n    int num = 0;\n    while (num < size)\n    {\n        for (i = 1; i < tries; i++) num++;\n    }\n}\n\nint main()\n{\n    bug(5, 10);\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991221-1.c",
    "content": "int main( void )\n{\n   unsigned long totalsize = 80;\n   unsigned long msize = 64;\n\n   if (sizeof(long) != 4)\n     exit(0);\n   \n   if ( totalsize > (2147483647L   * 2UL + 1)  \n        || (msize != 0 && ((msize - 1) > (2147483647L   * 2UL + 1) )))\n      abort();\n   exit( 0 );\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991227-1.c",
    "content": "char* doit(int flag)\n{\n  return 1 + (flag ? \"\\0wrong\\n\" : \"\\0right\\n\");\n}\nint main()\n{\n  char *result = doit(0);\n  if (*result == 'r' && result[1] == 'i')\n    exit(0);\n  abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/991228-1.c",
    "content": "__extension__ union { double d; int i[2]; } u = { d: -0.25 };\n\n/* This assumes the endianness of words in a long long is the same as\n   that for doubles, which doesn't hold for a few platforms, but we\n   can probably special case them here, as appropriate.  */\nlong long endianness_test = 1;\n#define MSW (*(int*)&endianness_test)\n\nint\nsignbit(double x)\n{\n  __extension__ union { double d; int i[2]; } u = { d: x };\n  return u.i[MSW] < 0;\n}\n    \nint main(void)\n{\n  if (2*sizeof(int) != sizeof(double) || u.i[MSW] >= 0)\n    exit(0);\n\n  if (!signbit(-0.25))\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/alias-1.c",
    "content": "int val;\n\nint *ptr = &val;\nfloat *ptr2 = &val;\n\n__attribute__((optimize (\"-fno-strict-aliasing\")))\ntypepun ()\n{\n  *ptr2=0;\n}\n\nmain()\n{\n  *ptr=1;\n  typepun ();\n  if (*ptr)\n    __builtin_abort ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/alias-2.c",
    "content": "/* { dg-require-alias \"\" } */\nint a[10]={};\nextern int b[10] __attribute__ ((alias(\"a\")));\nint off;\nmain()\n{\n  b[off]=1;\n  a[off]=2;\n  if (b[off]!=2)\n   __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/alias-3.c",
    "content": "/* { dg-require-alias \"\" } */\nstatic int a=0;\nextern int b __attribute__ ((alias(\"a\")));\n__attribute__ ((noinline))\nstatic inc()\n{\n  b++;\n}\nint\nmain()\n{\n  a=0;\n  inc ();\n  if (a!=1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/alias-4.c",
    "content": "/* { dg-require-alias \"\" } */\nint a = 1;\nextern int b __attribute__ ((alias (\"a\")));\nint c = 1;\nextern int d __attribute__ ((alias (\"c\")));\nmain (int argc)\n{\n  int *p;\n  int *q;\n  if (argc)\n    p = &a, q = &b;\n  else\n    p = &c, q = &d;\n  *p = 1;\n  *q = 2;\n  if (*p == 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/align-1.c",
    "content": "typedef int new_int __attribute__ ((aligned(16)));\nstruct S { int x; };\n \nint main()\n{\n  if (sizeof(struct S) != sizeof(int))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/align-2.c",
    "content": "/* Simple alignment checks;\n   looking for compiler/assembler alignment disagreements,\n   agreement between struct initialization and access.  */\nstruct a_short { char c; short s; } s_c_s = { 'a', 13 };\nstruct a_int { char c ; int i; } s_c_i = { 'b', 14 };\nstruct b_int { short s; int i; } s_s_i  = { 15, 16 };\nstruct a_float { char c; float f; } s_c_f = { 'c', 17.0 };\nstruct b_float { short s; float f; } s_s_f = { 18, 19.0 };\nstruct a_double { char c; double d; } s_c_d = { 'd', 20.0 };\nstruct b_double { short s; double d; } s_s_d = { 21, 22.0 };\nstruct c_double { int i; double d; } s_i_d = { 23, 24.0 };\nstruct d_double { float f; double d; } s_f_d = { 25.0, 26.0 };\nstruct a_ldouble { char c; long double ld; } s_c_ld = { 'e', 27.0 };\nstruct b_ldouble { short s; long double ld; } s_s_ld = { 28, 29.0 };\nstruct c_ldouble { int i; long double ld; } s_i_ld = { 30, 31.0 };\nstruct d_ldouble { float f; long double ld; } s_f_ld = { 32.0, 33.0 };\nstruct e_ldouble { double d; long double ld; } s_d_ld = { 34.0, 35.0 };\n\nint main ()\n{\n  if (s_c_s.c != 'a') abort ();\n  if (s_c_s.s != 13) abort ();\n  if (s_c_i.c != 'b') abort ();\n  if (s_c_i.i != 14) abort ();\n  if (s_s_i.s != 15) abort ();\n  if (s_s_i.i != 16) abort ();\n  if (s_c_f.c != 'c') abort ();\n  if (s_c_f.f != 17.0) abort ();\n  if (s_s_f.s != 18) abort ();\n  if (s_s_f.f != 19.0) abort ();\n  if (s_c_d.c != 'd') abort ();\n  if (s_c_d.d != 20.0) abort ();\n  if (s_s_d.s != 21) abort ();\n  if (s_s_d.d != 22.0) abort ();\n  if (s_i_d.i != 23) abort ();\n  if (s_i_d.d != 24.0) abort ();\n  if (s_f_d.f != 25.0) abort ();\n  if (s_f_d.d != 26.0) abort ();\n  if (s_c_ld.c != 'e') abort ();\n  if (s_c_ld.ld != 27.0) abort ();\n  if (s_s_ld.s != 28) abort ();\n  if (s_s_ld.ld != 29.0) abort ();\n  if (s_i_ld.i != 30) abort ();\n  if (s_i_ld.ld != 31.0) abort ();\n  if (s_f_ld.f != 32.0) abort ();\n  if (s_f_ld.ld != 33.0) abort ();\n  if (s_d_ld.d != 34.0) abort ();\n  if (s_d_ld.ld != 35.0) abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/align-3.c",
    "content": "void func(void) __attribute__((aligned(256)));\n\nvoid func(void) \n{\n}\n\nint main()\n{\n  if (__alignof__(func) != 256)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/align-nest.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n\nvoid foo(int n)\n{\n  typedef struct\n  {\n    int value;\n  } myint;\n  \n  struct S\n  {\n    int i[n];\n    unsigned int b:1;\n    myint mi;\n  } __attribute__ ((packed)) __attribute__ ((aligned (4)));\n\n  struct S s[2];\n  int k;\n  \n  for (k = 0; k < 2; k ++)\n    s[k].mi.value = 0;\n}\n\nint main ()\n{\n  foo (2);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/alloca-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n/* Verify that alloca storage is sufficiently aligned.  */\n/* ??? May fail if BIGGEST_ALIGNMENT > STACK_BOUNDARY.  Which, I guess\n   can only happen on !STRICT_ALIGNMENT targets.  */\n\ntypedef __SIZE_TYPE__ size_t;\n\nstruct dummy { int x __attribute__((aligned)); };\n#define BIGGEST_ALIGNMENT __alignof__(struct dummy)\n\n_Bool foo(void)\n{\n  char *p = __builtin_alloca(32);\n  return ((size_t)p & (BIGGEST_ALIGNMENT - 1)) == 0;\n}\n\nint main()\n{\n  if (!foo())\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/anon-1.c",
    "content": "/* Copyright (C) 2001 Free Software Foundation, Inc.  */\n\n/* Source: Neil Booth, 4 Nov 2001, derived from PR 2820 - field lookup in\n   nested anonymous entities was broken.  */\n\nstruct\n{\n  int x;\n  struct\n  {\n    int a;\n    union\n    {\n      int b;\n    };\n  };\n} foo;\n\nint\nmain(int argc, char *argv[])\n{\n  foo.b = 6;\n  foo.a = 5;\n\n  if (foo.b != 6)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/arith-1.c",
    "content": "unsigned\nsat_add (unsigned i)\n{\n  unsigned ret = i + 1;\n  if (ret < i)\n    ret = i;\n  return ret;\n}\n\nmain ()\n{\n  if (sat_add (~0U) != ~0U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/arith-rand-ll.c",
    "content": "long long\nsimple_rand ()\n{\n  static unsigned long long seed = 47114711;\n  unsigned long long this = seed * 1103515245 + 12345;\n  seed = this;\n  return this >> 8;\n}\n\nunsigned long long int\nrandom_bitstring ()\n{\n  unsigned long long int x;\n  int n_bits;\n  long long ran;\n  int tot_bits = 0;\n\n  x = 0;\n  for (;;)\n    {\n      ran = simple_rand ();\n      n_bits = (ran >> 1) % 16;\n      tot_bits += n_bits;\n\n      if (n_bits == 0)\n\treturn x;\n      else\n\t{\n\t  x <<= n_bits;\n\t  if (ran & 1)\n\t    x |= (1 << n_bits) - 1;\n\n\t  if (tot_bits > 8 * sizeof (long long) + 6)\n\t    return x;\n\t}\n    }\n}\n\n#define ABS(x) ((x) >= 0 ? (x) : -(x))\n\nmain ()\n{\n  long long int i;\n\n  for (i = 0; i < 10000; i++)\n    {\n      unsigned long long x, y;\n      x = random_bitstring ();\n      y = random_bitstring ();\n\n      if (sizeof (int) == sizeof (long long))\n\tgoto save_time;\n\n      { unsigned long long xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed long long xx = x, yy = y, r1, r2;\n\tif ((unsigned long long) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned long long) ABS (yy) || (signed long long) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    save_time:\n      { unsigned int xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed int xx = x, yy = y, r1, r2;\n\tif ((unsigned int) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) != xx || ((xx < 0) != (r2 < 0) && r2))\n\t  abort ();\n      }\n      { unsigned short xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed short xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned short) ABS (yy) || (signed short) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned char xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed char xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned char) ABS (yy) || (signed char) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/arith-rand.c",
    "content": "long\nsimple_rand ()\n{\n  static unsigned long seed = 47114711;\n  unsigned long this = seed * 1103515245 + 12345;\n  seed = this;\n  return this >> 8;\n}\n\nunsigned long int\nrandom_bitstring ()\n{\n  unsigned long int x;\n  int n_bits;\n  long ran;\n  int tot_bits = 0;\n\n  x = 0;\n  for (;;)\n    {\n      ran = simple_rand ();\n      n_bits = (ran >> 1) % 16;\n      tot_bits += n_bits;\n\n      if (n_bits == 0)\n\treturn x;\n      else\n\t{\n\t  x <<= n_bits;\n\t  if (ran & 1)\n\t    x |= (1 << n_bits) - 1;\n\n\t  if (tot_bits > 8 * sizeof (long) + 6)\n\t    return x;\n\t}\n    }\n}\n\n#define ABS(x) ((x) >= 0 ? (x) : -(x))\n\nmain ()\n{\n  long int i;\n\n  for (i = 0; i < 1000; i++)\n    {\n      unsigned long x, y;\n      x = random_bitstring ();\n      y = random_bitstring ();\n\n      if (sizeof (int) == sizeof (long))\n\tgoto save_time;\n\n      { unsigned long xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed long xx = x, yy = y, r1, r2;\n\tif ((unsigned long) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned long) ABS (yy) || (signed long) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    save_time:\n      { unsigned int xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed int xx = x, yy = y, r1, r2;\n\tif ((unsigned int) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned short xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed short xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned short) ABS (yy) || (signed short) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned char xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed char xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned char) ABS (yy) || (signed char) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ashldi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic unsigned long long const data[64] = {\n  0x123456789abcdefULL,\n  0x2468acf13579bdeULL,\n  0x48d159e26af37bcULL,\n  0x91a2b3c4d5e6f78ULL,\n  0x123456789abcdef0ULL,\n  0x2468acf13579bde0ULL,\n  0x48d159e26af37bc0ULL,\n  0x91a2b3c4d5e6f780ULL,\n  0x23456789abcdef00ULL,\n  0x468acf13579bde00ULL,\n  0x8d159e26af37bc00ULL,\n  0x1a2b3c4d5e6f7800ULL,\n  0x3456789abcdef000ULL,\n  0x68acf13579bde000ULL,\n  0xd159e26af37bc000ULL,\n  0xa2b3c4d5e6f78000ULL,\n  0x456789abcdef0000ULL,\n  0x8acf13579bde0000ULL,\n  0x159e26af37bc0000ULL,\n  0x2b3c4d5e6f780000ULL,\n  0x56789abcdef00000ULL,\n  0xacf13579bde00000ULL,\n  0x59e26af37bc00000ULL,\n  0xb3c4d5e6f7800000ULL,\n  0x6789abcdef000000ULL,\n  0xcf13579bde000000ULL,\n  0x9e26af37bc000000ULL,\n  0x3c4d5e6f78000000ULL,\n  0x789abcdef0000000ULL,\n  0xf13579bde0000000ULL,\n  0xe26af37bc0000000ULL,\n  0xc4d5e6f780000000ULL,\n  0x89abcdef00000000ULL,\n  0x13579bde00000000ULL,\n  0x26af37bc00000000ULL,\n  0x4d5e6f7800000000ULL,\n  0x9abcdef000000000ULL,\n  0x3579bde000000000ULL,\n  0x6af37bc000000000ULL,\n  0xd5e6f78000000000ULL,\n  0xabcdef0000000000ULL,\n  0x579bde0000000000ULL,\n  0xaf37bc0000000000ULL,\n  0x5e6f780000000000ULL,\n  0xbcdef00000000000ULL,\n  0x79bde00000000000ULL,\n  0xf37bc00000000000ULL,\n  0xe6f7800000000000ULL,\n  0xcdef000000000000ULL,\n  0x9bde000000000000ULL,\n  0x37bc000000000000ULL,\n  0x6f78000000000000ULL,\n  0xdef0000000000000ULL,\n  0xbde0000000000000ULL,\n  0x7bc0000000000000ULL,\n  0xf780000000000000ULL,\n  0xef00000000000000ULL,\n  0xde00000000000000ULL,\n  0xbc00000000000000ULL,\n  0x7800000000000000ULL,\n  0xf000000000000000ULL,\n  0xe000000000000000ULL,\n  0xc000000000000000ULL,\n  0x8000000000000000ULL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic unsigned long long const data[32] = {\n  0x1234567fULL,\n  0x2468acfeULL,\n  0x48d159fcULL,\n  0x91a2b3f8ULL,\n  0x234567f0ULL,\n  0x468acfe0ULL,\n  0x8d159fc0ULL,\n  0x1a2b3f80ULL,\n  0x34567f00ULL,\n  0x68acfe00ULL,\n  0xd159fc00ULL,\n  0xa2b3f800ULL,\n  0x4567f000ULL,\n  0x8acfe000ULL,\n  0x159fc000ULL,\n  0x2b3f8000ULL,\n  0x567f0000ULL,\n  0xacfe0000ULL,\n  0x59fc0000ULL,\n  0xb3f80000ULL,\n  0x67f00000ULL,\n  0xcfe00000ULL,\n  0x9fc00000ULL,\n  0x3f800000ULL,\n  0x7f000000ULL,\n  0xfe000000ULL,\n  0xfc000000ULL,\n  0xf8000000ULL,\n  0xf0000000ULL,\n  0xe0000000ULL,\n  0xc0000000ULL,\n  0x80000000ULL\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic unsigned long long\nvariable_shift(unsigned long long x, int i)\n{\n  return x << i;\n}\n\nstatic unsigned long long\nconstant_shift(unsigned long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x << 0; break;\n    case 1: x = x << 1; break;\n    case 2: x = x << 2; break;\n    case 3: x = x << 3; break;\n    case 4: x = x << 4; break;\n    case 5: x = x << 5; break;\n    case 6: x = x << 6; break;\n    case 7: x = x << 7; break;\n    case 8: x = x << 8; break;\n    case 9: x = x << 9; break;\n    case 10: x = x << 10; break;\n    case 11: x = x << 11; break;\n    case 12: x = x << 12; break;\n    case 13: x = x << 13; break;\n    case 14: x = x << 14; break;\n    case 15: x = x << 15; break;\n    case 16: x = x << 16; break;\n    case 17: x = x << 17; break;\n    case 18: x = x << 18; break;\n    case 19: x = x << 19; break;\n    case 20: x = x << 20; break;\n    case 21: x = x << 21; break;\n    case 22: x = x << 22; break;\n    case 23: x = x << 23; break;\n    case 24: x = x << 24; break;\n    case 25: x = x << 25; break;\n    case 26: x = x << 26; break;\n    case 27: x = x << 27; break;\n    case 28: x = x << 28; break;\n    case 29: x = x << 29; break;\n    case 30: x = x << 30; break;\n    case 31: x = x << 31; break;\n#if BITS > 32\n    case 32: x = x << 32; break;\n    case 33: x = x << 33; break;\n    case 34: x = x << 34; break;\n    case 35: x = x << 35; break;\n    case 36: x = x << 36; break;\n    case 37: x = x << 37; break;\n    case 38: x = x << 38; break;\n    case 39: x = x << 39; break;\n    case 40: x = x << 40; break;\n    case 41: x = x << 41; break;\n    case 42: x = x << 42; break;\n    case 43: x = x << 43; break;\n    case 44: x = x << 44; break;\n    case 45: x = x << 45; break;\n    case 46: x = x << 46; break;\n    case 47: x = x << 47; break;\n    case 48: x = x << 48; break;\n    case 49: x = x << 49; break;\n    case 50: x = x << 50; break;\n    case 51: x = x << 51; break;\n    case 52: x = x << 52; break;\n    case 53: x = x << 53; break;\n    case 54: x = x << 54; break;\n    case 55: x = x << 55; break;\n    case 56: x = x << 56; break;\n    case 57: x = x << 57; break;\n    case 58: x = x << 58; break;\n    case 59: x = x << 59; break;\n    case 60: x = x << 60; break;\n    case 61: x = x << 61; break;\n    case 62: x = x << 62; break;\n    case 63: x = x << 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = variable_shift (data[0], i);\n      if (y != data[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = constant_shift (data[0], i);\n      if (y != data[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ashrdi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic long long const zext[64] = {\n  0x7654321fedcba980LL,\n  0x3b2a190ff6e5d4c0LL,\n  0x1d950c87fb72ea60LL,\n  0xeca8643fdb97530LL,\n  0x7654321fedcba98LL,\n  0x3b2a190ff6e5d4cLL,\n  0x1d950c87fb72ea6LL,\n  0xeca8643fdb9753LL,\n  0x7654321fedcba9LL,\n  0x3b2a190ff6e5d4LL,\n  0x1d950c87fb72eaLL,\n  0xeca8643fdb975LL,\n  0x7654321fedcbaLL,\n  0x3b2a190ff6e5dLL,\n  0x1d950c87fb72eLL,\n  0xeca8643fdb97LL,\n  0x7654321fedcbLL,\n  0x3b2a190ff6e5LL,\n  0x1d950c87fb72LL,\n  0xeca8643fdb9LL,\n  0x7654321fedcLL,\n  0x3b2a190ff6eLL,\n  0x1d950c87fb7LL,\n  0xeca8643fdbLL,\n  0x7654321fedLL,\n  0x3b2a190ff6LL,\n  0x1d950c87fbLL,\n  0xeca8643fdLL,\n  0x7654321feLL,\n  0x3b2a190ffLL,\n  0x1d950c87fLL,\n  0xeca8643fLL,\n  0x7654321fLL,\n  0x3b2a190fLL,\n  0x1d950c87LL,\n  0xeca8643LL,\n  0x7654321LL,\n  0x3b2a190LL,\n  0x1d950c8LL,\n  0xeca864LL,\n  0x765432LL,\n  0x3b2a19LL,\n  0x1d950cLL,\n  0xeca86LL,\n  0x76543LL,\n  0x3b2a1LL,\n  0x1d950LL,\n  0xeca8LL,\n  0x7654LL,\n  0x3b2aLL,\n  0x1d95LL,\n  0xecaLL,\n  0x765LL,\n  0x3b2LL,\n  0x1d9LL,\n  0xecLL,\n  0x76LL,\n  0x3bLL,\n  0x1dLL,\n  0xeLL,\n  0x7LL,\n  0x3LL,\n  0x1LL,\n  0LL\n};\n\nstatic long long const sext[64] = {\n  0x8edcba9f76543210LL,\n  0xc76e5d4fbb2a1908LL,\n  0xe3b72ea7dd950c84LL,\n  0xf1db9753eeca8642LL,\n  0xf8edcba9f7654321LL,\n  0xfc76e5d4fbb2a190LL,\n  0xfe3b72ea7dd950c8LL,\n  0xff1db9753eeca864LL,\n  0xff8edcba9f765432LL,\n  0xffc76e5d4fbb2a19LL,\n  0xffe3b72ea7dd950cLL,\n  0xfff1db9753eeca86LL,\n  0xfff8edcba9f76543LL,\n  0xfffc76e5d4fbb2a1LL,\n  0xfffe3b72ea7dd950LL,\n  0xffff1db9753eeca8LL,\n  0xffff8edcba9f7654LL,\n  0xffffc76e5d4fbb2aLL,\n  0xffffe3b72ea7dd95LL,\n  0xfffff1db9753eecaLL,\n  0xfffff8edcba9f765LL,\n  0xfffffc76e5d4fbb2LL,\n  0xfffffe3b72ea7dd9LL,\n  0xffffff1db9753eecLL,\n  0xffffff8edcba9f76LL,\n  0xffffffc76e5d4fbbLL,\n  0xffffffe3b72ea7ddLL,\n  0xfffffff1db9753eeLL,\n  0xfffffff8edcba9f7LL,\n  0xfffffffc76e5d4fbLL,\n  0xfffffffe3b72ea7dLL,\n  0xffffffff1db9753eLL,\n  0xffffffff8edcba9fLL,\n  0xffffffffc76e5d4fLL,\n  0xffffffffe3b72ea7LL,\n  0xfffffffff1db9753LL,\n  0xfffffffff8edcba9LL,\n  0xfffffffffc76e5d4LL,\n  0xfffffffffe3b72eaLL,\n  0xffffffffff1db975LL,\n  0xffffffffff8edcbaLL,\n  0xffffffffffc76e5dLL,\n  0xffffffffffe3b72eLL,\n  0xfffffffffff1db97LL,\n  0xfffffffffff8edcbLL,\n  0xfffffffffffc76e5LL,\n  0xfffffffffffe3b72LL,\n  0xffffffffffff1db9LL,\n  0xffffffffffff8edcLL,\n  0xffffffffffffc76eLL,\n  0xffffffffffffe3b7LL,\n  0xfffffffffffff1dbLL,\n  0xfffffffffffff8edLL,\n  0xfffffffffffffc76LL,\n  0xfffffffffffffe3bLL,\n  0xffffffffffffff1dLL,\n  0xffffffffffffff8eLL,\n  0xffffffffffffffc7LL,\n  0xffffffffffffffe3LL,\n  0xfffffffffffffff1LL,\n  0xfffffffffffffff8LL,\n  0xfffffffffffffffcLL,\n  0xfffffffffffffffeLL,\n  0xffffffffffffffffLL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic long long const zext[32] = {\n  0x76543218LL,\n  0x3b2a190cLL,\n  0x1d950c86LL,\n  0xeca8643LL,\n  0x7654321LL,\n  0x3b2a190LL,\n  0x1d950c8LL,\n  0xeca864LL,\n  0x765432LL,\n  0x3b2a19LL,\n  0x1d950cLL,\n  0xeca86LL,\n  0x76543LL,\n  0x3b2a1LL,\n  0x1d950LL,\n  0xeca8LL,\n  0x7654LL,\n  0x3b2aLL,\n  0x1d95LL,\n  0xecaLL,\n  0x765LL,\n  0x3b2LL,\n  0x1d9LL,\n  0xecLL,\n  0x76LL,\n  0x3bLL,\n  0x1dLL,\n  0xeLL,\n  0x7LL,\n  0x3LL,\n  0x1LL,\n  0LL\n};\n\nstatic long long const sext[64] = {\n  0x87654321LL,\n  0xc3b2a190LL,\n  0xe1d950c8LL,\n  0xf0eca864LL,\n  0xf8765432LL,\n  0xfc3b2a19LL,\n  0xfe1d950cLL,\n  0xff0eca86LL,\n  0xff876543LL,\n  0xffc3b2a1LL,\n  0xffe1d950LL,\n  0xfff0eca8LL,\n  0xfff87654LL,\n  0xfffc3b2aLL,\n  0xfffe1d95LL,\n  0xffff0ecaLL,\n  0xffff8765LL,\n  0xffffc3b2LL,\n  0xffffe1d9LL,\n  0xfffff0ecLL,\n  0xfffff876LL,\n  0xfffffc3bLL,\n  0xfffffe1dLL,\n  0xffffff0eLL,\n  0xffffff87LL,\n  0xffffffc3LL,\n  0xffffffe1LL,\n  0xfffffff0LL,\n  0xfffffff8LL,\n  0xfffffffcLL,\n  0xfffffffeLL,\n  0xffffffffLL\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic long long\nvariable_shift(long long x, int i)\n{\n  return x >> i;\n}\n\nstatic long long\nconstant_shift(long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x >> 0; break;\n    case 1: x = x >> 1; break;\n    case 2: x = x >> 2; break;\n    case 3: x = x >> 3; break;\n    case 4: x = x >> 4; break;\n    case 5: x = x >> 5; break;\n    case 6: x = x >> 6; break;\n    case 7: x = x >> 7; break;\n    case 8: x = x >> 8; break;\n    case 9: x = x >> 9; break;\n    case 10: x = x >> 10; break;\n    case 11: x = x >> 11; break;\n    case 12: x = x >> 12; break;\n    case 13: x = x >> 13; break;\n    case 14: x = x >> 14; break;\n    case 15: x = x >> 15; break;\n    case 16: x = x >> 16; break;\n    case 17: x = x >> 17; break;\n    case 18: x = x >> 18; break;\n    case 19: x = x >> 19; break;\n    case 20: x = x >> 20; break;\n    case 21: x = x >> 21; break;\n    case 22: x = x >> 22; break;\n    case 23: x = x >> 23; break;\n    case 24: x = x >> 24; break;\n    case 25: x = x >> 25; break;\n    case 26: x = x >> 26; break;\n    case 27: x = x >> 27; break;\n    case 28: x = x >> 28; break;\n    case 29: x = x >> 29; break;\n    case 30: x = x >> 30; break;\n    case 31: x = x >> 31; break;\n#if BITS > 32\n    case 32: x = x >> 32; break;\n    case 33: x = x >> 33; break;\n    case 34: x = x >> 34; break;\n    case 35: x = x >> 35; break;\n    case 36: x = x >> 36; break;\n    case 37: x = x >> 37; break;\n    case 38: x = x >> 38; break;\n    case 39: x = x >> 39; break;\n    case 40: x = x >> 40; break;\n    case 41: x = x >> 41; break;\n    case 42: x = x >> 42; break;\n    case 43: x = x >> 43; break;\n    case 44: x = x >> 44; break;\n    case 45: x = x >> 45; break;\n    case 46: x = x >> 46; break;\n    case 47: x = x >> 47; break;\n    case 48: x = x >> 48; break;\n    case 49: x = x >> 49; break;\n    case 50: x = x >> 50; break;\n    case 51: x = x >> 51; break;\n    case 52: x = x >> 52; break;\n    case 53: x = x >> 53; break;\n    case 54: x = x >> 54; break;\n    case 55: x = x >> 55; break;\n    case 56: x = x >> 56; break;\n    case 57: x = x >> 57; break;\n    case 58: x = x >> 58; break;\n    case 59: x = x >> 59; break;\n    case 60: x = x >> 60; break;\n    case 61: x = x >> 61; break;\n    case 62: x = x >> 62; break;\n    case 63: x = x >> 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = variable_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = variable_shift (sext[0], i);\n      if (y != sext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = constant_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = constant_shift (sext[0], i);\n      if (y != sext[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bcp-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__ ((externally_visible)) int global;\nint func(void);\n\n/* These must fail.  */\nint bad0(void) { return __builtin_constant_p(global); }\nint bad1(void) { return __builtin_constant_p(global++); }\ninline int bad2(int x) { return __builtin_constant_p(x++); }\ninline int bad3(int x) { return __builtin_constant_p(x); }\ninline int bad4(const char *x) { return __builtin_constant_p(x); }\nint bad5(void) { return bad2(1); }\ninline int bad6(int x) { return __builtin_constant_p(x+1); }\nint bad7(void) { return __builtin_constant_p(func()); }\nint bad8(void) { char buf[10]; return __builtin_constant_p(buf); }\nint bad9(const char *x) { return __builtin_constant_p(x[123456]); }\nint bad10(void) { return __builtin_constant_p(&global); }\n\n/* These must pass, or we've broken gcc2 functionality.  */\nint good0(void) { return __builtin_constant_p(1); }\nint good1(void) { return __builtin_constant_p(\"hi\"); }\nint good2(void) { return __builtin_constant_p((1234 + 45) & ~7); }\n\n/* These are extensions to gcc2.  Failure indicates an optimization\n   regression.  */\nint opt0(void) { return bad3(1); }\nint opt1(void) { return bad6(1); }\nint opt2(void) { return __builtin_constant_p(\"hi\"[0]); }\n\n/* \n * Opt3 is known to fail.  It is one of the important cases that glibc\n * was interested in though, so keep this around as a reminder.\n *\n * The solution is to add bits to recover bytes from constant pool\n * elements given nothing but a constant pool label and an offset.\n * When we can do that, and we can simplify strlen after the fact,\n * then we can enable recognition of constant pool labels as constants.\n */\n\n/* int opt3(void) { return bad4(\"hi\"); } */\n\n\n/* Call through tables so -finline-functions can't screw with us.  */\nint (* volatile bad_t0[])(void) = {\n\tbad0, bad1, bad5, bad7, bad8, bad10\n};\n\nint (* volatile bad_t1[])(int x) = {\n\tbad2, bad3, bad6\n};\n\nint (* volatile bad_t2[])(const char *x) = {\n\tbad4, bad9\n};\n\nint (* volatile good_t0[])(void) = {\n\tgood0, good1, good2\n};\n\nint (* volatile opt_t0[])(void) = {\n\topt0, opt1, opt2 /* , opt3 */\n};\n\n#define N(arr) (sizeof(arr)/sizeof(*arr))\n\nint main()\n{\n  int i;\n\n  for (i = 0; i < N(bad_t0); ++i)\n    if ((*bad_t0[i])())\n      abort();\n\n  for (i = 0; i < N(bad_t1); ++i)\n    if ((*bad_t1[i])(1))\n      abort();\n\n  for (i = 0; i < N(bad_t2); ++i)\n    if ((*bad_t2[i])(\"hi\"))\n      abort();\n\n  for (i = 0; i < N(good_t0); ++i)\n    if (! (*good_t0[i])())\n      abort();\n\n#ifdef __OPTIMIZE__\n  for (i = 0; i < N(opt_t0); ++i)\n    if (! (*opt_t0[i])())\n      abort();\n#endif\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bf-layout-1.c",
    "content": "struct { long f8:8; long f24:24; } a;\nstruct { long f32:32; } b;\n\nmain ()\n{\n  if (sizeof (a) != sizeof (b))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bf-pack-1.c",
    "content": "struct foo\n{\n  unsigned half:16;\n  unsigned long whole:32 __attribute__ ((packed));\n};\n\nf (struct foo *q)\n{\n  if (q->half != 0x1234)\n    abort ();\n  if (q->whole != 0x56789abcL)\n    abort ();\n}\n\nmain ()\n{\n  struct foo bar;\n\n  bar.half = 0x1234;\n  bar.whole = 0x56789abcL;\n  f (&bar);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bf-sign-1.c",
    "content": "main ()\n{\n  struct  {\n    signed int s:3;\n    unsigned int u:3;\n    int i:3;\n  } x = {-1, -1, -1};\n\n  if (x.u != 7)\n    abort ();\n  if (x.s != - 1)\n    abort ();\n\n  if (x.i != -1 && x.i != 7)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c",
    "content": "/* \n This test checks promotion of bitfields.  Bitfields should be promoted\n very much like chars and shorts: \n\n Bitfields (signed or unsigned) should be promoted to signed int if their\n value will fit in a signed int, otherwise to an unsigned int if their \n value will fit in an unsigned int, otherwise we don't promote them (ANSI/ISO\n does not specify the behavior of bitfields larger than an unsigned int).\n\n We test the behavior by subtracting two from the promoted value: this will\n result in a negitive value for signed types, a positive value for unsigned\n types.  This test (of course) assumes that the compiler is correctly \n implementing signed and unsigned arithmetic.\n */\n\nstruct X {\n  unsigned int\t     u3:3;\n    signed long int  s31:31;\n    signed long int  s32:32;\n  unsigned long int  u31:31;\n  unsigned long int  u32:32;\n  unsigned long long ull3 :3;\n  unsigned long long ull35:35;\n  unsigned u15:15;\n};\n\nstruct X x;\n\nmain ()\n{\n  if ((x.u3 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.s31 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.s32 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.u15 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  /* Conditionalize check on whether integers are 4 bytes or larger, i.e.\n     larger than a 31 bit bitfield.  */\n  if (sizeof (int) >= 4)\n    {\n      if ((x.u31 - 2) >= 0)\t/* promoted value should be signed */\n\tabort ();\n    }\n  else\n    {\n      if ((x.u31 - 2) < 0)\t/* promoted value should be UNsigned */\n\tabort ();\n    }\n\n  if ((x.u32 - 2) < 0)\t\t/* promoted value should be UNsigned */\n    abort ();\n\n  if ((x.ull3 - 2) >= 0)\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.ull35 - 2) < 0)\t/* promoted value should be UNsigned */\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bf64-1.c",
    "content": "/* { dg-xfail-if \"ABI specifies bitfields cannot exceed 32 bits\" { mcore-*-* } \"*\" \"\" } */\nstruct tmp\n{\n  long long int pad : 12;\n  long long int field : 52;\n};\n\nstruct tmp2\n{\n  long long int field : 52;\n  long long int pad : 12;\n};\n\nstruct tmp\nsub (struct tmp tmp)\n{\n  tmp.field |= 0x0008765412345678LL;\n  return tmp;\n}\n\nstruct tmp2\nsub2 (struct tmp2 tmp2)\n{\n  tmp2.field |= 0x0008765412345678LL;\n  return tmp2;\n}\n\nmain()\n{\n  struct tmp tmp = {0x123, 0xFFF000FFF000FLL};\n  struct tmp2 tmp2 = {0xFFF000FFF000FLL, 0x123};\n\n  tmp = sub (tmp);\n  tmp2 = sub2 (tmp2);\n\n  if (tmp.pad != 0x123 || tmp.field != 0xFFFFFF541FFF567FLL)\n    abort ();\n  if (tmp2.pad != 0x123 || tmp2.field != 0xFFFFFF541FFF567FLL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-1.c",
    "content": "/* Copyright 2002 Free Software Foundation, Inc.\n\n   Tests correct signedness of operations on bitfields; in particular\n   that integer promotions are done correctly, including the case when\n   casts are present.\n\n   The C front end was eliding the cast of an unsigned bitfield to\n   unsigned as a no-op, when in fact it forces a conversion to a\n   full-width unsigned int. (At the time of writing, the C++ front end\n   has a different bug; it erroneously promotes the uncast unsigned\n   bitfield to an unsigned int).\n\n   Source: Neil Booth, 25 Jan 2002, based on PR 3325 (and 3326, which\n   is a different manifestation of the same bug).\n*/\n\nextern void abort ();\n\nint\nmain(int argc, char *argv[])\n{\n  struct x { signed int i : 7; unsigned int u : 7; } bit;\n\n  unsigned int u;\n  int i;\n  unsigned int unsigned_result = -13U % 61;\n  int signed_result = -13 % 61;\n\n  bit.u = 61, u = 61; \n  bit.i = -13, i = -13;\n\n  if (i % u != unsigned_result)\n    abort ();\n  if (i % (unsigned int) u != unsigned_result)\n    abort ();\n\n  /* Somewhat counter-intuitively, bit.u is promoted to an int, making\n     the operands and result an int.  */\n  if (i % bit.u != signed_result)\n    abort ();\n\n  if (bit.i % bit.u != signed_result)\n    abort ();\n\n  /* But with a cast to unsigned int, the unsigned int is promoted to\n     itself as a no-op, and the operands and result are unsigned.  */\n  if (i % (unsigned int) bit.u != unsigned_result)\n    abort ();\n\n  if (bit.i % (unsigned int) bit.u != unsigned_result)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-2.c",
    "content": "/* Test whether bit field boundaries aren't advanced if bit field type\n   has alignment large enough.  */\nextern void abort (void);\nextern void exit (int);\n\nstruct A {\n  unsigned short a : 5;\n  unsigned short b : 5;\n  unsigned short c : 6;\n};\n\nstruct B {\n  unsigned short a : 5;\n  unsigned short b : 3;\n  unsigned short c : 8;\n};\n\nint main ()\n{\n  /* If short is not at least 16 bits wide, don't test anything.  */\n  if ((unsigned short) 65521 != 65521)\n    exit (0);\n\n  if (sizeof (struct A) != sizeof (struct B))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-3.c",
    "content": "/* Test that operations on bit-fields yield results reduced to bit-field\n   type.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\nextern void exit (int);\nextern void abort (void);\n\nstruct s {\n  unsigned long long u33: 33;\n  unsigned long long u40: 40;\n  unsigned long long u41: 41;\n};\n\nstruct s a = { 0x100000, 0x100000, 0x100000 };\nstruct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL };\nstruct s c = { 0x1FFFFFFFFULL, 0, 0 };\n\nint \nmain (void)\n{\n  if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0\n      || a.u40 * a.u40 != 0)\n    abort ();\n  if (a.u33 * a.u41 != 0x10000000000ULL\n      || a.u40 * a.u41 != 0x10000000000ULL\n      || a.u41 * a.u33 != 0x10000000000ULL\n      || a.u41 * a.u40 != 0x10000000000ULL\n      || a.u41 * a.u41 != 0x10000000000ULL)\n    abort ();\n  if (b.u33 + b.u33 != 0)\n    abort ();\n  if (b.u33 + b.u40 != 0x200000000ULL\n      || b.u33 + b.u41 != 0x200000000ULL\n      || b.u40 + b.u33 != 0x200000000ULL\n      || b.u40 + b.u40 != 0x200000000ULL\n      || b.u40 + b.u41 != 0x200000000ULL\n      || b.u41 + b.u33 != 0x200000000ULL\n      || b.u41 + b.u40 != 0x200000000ULL\n      || b.u41 + b.u41 != 0x200000000ULL)\n    abort ();\n  if (a.u33 - b.u33 != 0x100100000ULL\n      || a.u33 - b.u40 != 0xFF00100000ULL\n      || a.u33 - b.u41 != 0x1FF00100000ULL\n      || a.u40 - b.u33 != 0xFF00100000ULL\n      || a.u40 - b.u40 != 0xFF00100000ULL\n      || a.u40 - b.u41 != 0x1FF00100000ULL\n      || a.u41 - b.u33 != 0x1FF00100000ULL\n      || a.u41 - b.u40 != 0x1FF00100000ULL\n      || a.u41 - b.u41 != 0x1FF00100000ULL)\n    abort ();\n  if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-4.c",
    "content": "/* When comparisons of bit-fields to unsigned constants got shortened,\n   the shortened signed constant was wrongly marked as overflowing,\n   leading to a later integer_zerop failure and misoptimization.\n\n   Related to bug tree-optimization/16437 but shows the problem on\n   32-bit systems.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nstruct s { int a:12, b:20; };\n\nstruct s x = { -123, -456 };\n\nint\nmain (void)\n{\n  if (x.a != -123U || x.b != -456U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-5.c",
    "content": "/* See http://gcc.gnu.org/ml/gcc/2009-06/msg00072.html.  */\n\nextern void abort (void);\n\nstruct s\n{\n  unsigned long long a:2;\n  unsigned long long b:40;\n  unsigned long long c:22;\n};\n\n__attribute__ ((noinline)) void\ng (unsigned long long a, unsigned long long b)\n{\n  asm (\"\");\n  if (a != b)\n    abort ();\n}\n\n__attribute__ ((noinline)) void\nf (struct s s, unsigned long long b)\n{\n  asm (\"\");\n  g (((unsigned long long) (s.b-8)) + 8, b);\n}\n\nint\nmain ()\n{\n  struct s s = {1, 10, 3};\n  struct s t = {1, 2, 3};\n  f (s, 10);\n  f (t, 0x10000000002);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-6.c",
    "content": "union U\n{\n  const int a;\n  unsigned b : 20;\n};\n\nstatic union U u = { 0x12345678 };\n\n/* Constant folding used to fail to account for endianness when folding a\n   union.  */\n\nint\nmain (void)\n{\n#ifdef __BYTE_ORDER__\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  return u.b - 0x45678;\n#else\n  return u.b - 0x12345;\n#endif\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c",
    "content": "union U\n{\n  const int a;\n  unsigned b : 24;\n};\n\nstatic union U u = { 0x12345678 };\n\n/* Constant folding used to fail to account for endianness when folding a\n   union.  */\n\nint\nmain (void)\n{\n#ifdef __BYTE_ORDER__\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  return u.b - 0x345678;\n#else\n  return u.b - 0x123456;\n#endif\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bswap-1.c",
    "content": "/* Test __builtin_bswap64 . */\n\nunsigned long long g(unsigned long long a) __attribute__((noinline));\nunsigned long long g(unsigned long long a)\n{\n  return __builtin_bswap64(a);\n}\n\n\nunsigned long long f(unsigned long long c)\n{\n  union {\n    unsigned long long a;\n    unsigned char b[8];\n  } a, b;\n  a.a = c;\n  b.b[0] = a.b[7];\n  b.b[1] = a.b[6];\n  b.b[2] = a.b[5];\n  b.b[3] = a.b[4];\n  b.b[4] = a.b[3];\n  b.b[5] = a.b[2];\n  b.b[6] = a.b[1];\n  b.b[7] = a.b[0];\n  return b.a;\n}\n\nint main(void)\n{\n  unsigned long long i;\n  /* The rest of the testcase assumes 8 byte long long. */\n  if (sizeof(i) != sizeof(char)*8)\n    return 0;\n  if (f(0x12) != g(0x12))\n    __builtin_abort();\n  if (f(0x1234) != g(0x1234))\n    __builtin_abort();\n  if (f(0x123456) != g(0x123456))\n    __builtin_abort();\n  if (f(0x12345678ull) != g(0x12345678ull))\n    __builtin_abort();\n  if (f(0x1234567890ull) != g(0x1234567890ull))\n    __builtin_abort();\n  if (f(0x123456789012ull) != g(0x123456789012ull))\n    __builtin_abort();\n  if (f(0x12345678901234ull) != g(0x12345678901234ull))\n    __builtin_abort();\n  if (f(0x1234567890123456ull) != g(0x1234567890123456ull))\n    __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/bswap-2.c",
    "content": "#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef __UINT32_TYPE__ unsigned;\n#endif\n\nstruct bitfield {\n  unsigned char f0:7;\n  unsigned char   :1;\n  unsigned char f1:7;\n  unsigned char   :1;\n  unsigned char f2:7;\n  unsigned char   :1;\n  unsigned char f3:7;\n};\n\nstruct ok {\n  unsigned char f0;\n  unsigned char f1;\n  unsigned char f2;\n  unsigned char f3;\n};\n\nunion bf_or_uint32 {\n  struct ok inval;\n  struct bitfield bfval;\n};\n\n__attribute__ ((noinline, noclone)) uint32_t\npartial_read_le32 (union bf_or_uint32 in)\n{\n  return in.bfval.f0 | (in.bfval.f1 << 8)\n\t | (in.bfval.f2 << 16) | (in.bfval.f3 << 24);\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\npartial_read_be32 (union bf_or_uint32 in)\n{\n  return in.bfval.f3 | (in.bfval.f2 << 8)\n\t | (in.bfval.f1 << 16) | (in.bfval.f0 << 24);\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_read_le32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  *y = 1;\n  c2 = x[2];\n  c3 = x[3];\n  return c0 | c1 << 8 | c2 << 16 | c3 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_read_be32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  *y = 1;\n  c2 = x[2];\n  c3 = x[3];\n  return c3 | c2 << 8 | c1 << 16 | c0 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nincorrect_read_le32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  c2 = x[2];\n  c3 = x[3];\n  *y = 1;\n  return c0 | c1 << 8 | c2 << 16 | c3 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nincorrect_read_be32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  c2 = x[2];\n  c3 = x[3];\n  *y = 1;\n  return c3 | c2 << 8 | c1 << 16 | c0 << 24;\n}\n\nint\nmain ()\n{\n  union bf_or_uint32 bfin;\n  uint32_t out;\n  char cin[] = { 0x83, 0x85, 0x87, 0x89 };\n\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };\n  out = partial_read_le32 (bfin);\n  /* Test what bswap would do if its check are not strict enough instead of\n     what is the expected result as there is too many possible results with\n     bitfields.  */\n  if (out == 0x89878583)\n    __builtin_abort ();\n  bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };\n  out = partial_read_be32 (bfin);\n  /* Test what bswap would do if its check are not strict enough instead of\n     what is the expected result as there is too many possible results with\n     bitfields.  */\n  if (out == 0x83858789)\n    __builtin_abort ();\n  out = fake_read_le32 (cin, &cin[2]);\n  if (out != 0x89018583)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = fake_read_be32 (cin, &cin[2]);\n  if (out != 0x83850189)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = incorrect_read_le32 (cin, &cin[2]);\n  if (out != 0x89878583)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = incorrect_read_be32 (cin, &cin[2]);\n  if (out != 0x83858789)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/built-in-setjmp.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target alloca } */\n\nextern int strcmp(const char *, const char *);\nextern char *strcpy(char *, const char *);\nextern void abort(void);\nextern void exit(int);\n\nvoid *buf[20];\n\nvoid __attribute__((noinline))\nsub2 (void)\n{\n  __builtin_longjmp (buf, 1);\n}\n\nint\nmain ()\n{\n  char *p = (char *) __builtin_alloca (20);\n\n  strcpy (p, \"test\");\n\n  if (__builtin_setjmp (buf))\n    {\n      if (strcmp (p, \"test\") != 0)\n\tabort ();\n\n      exit (0);\n    }\n\n  {\n    int *q = (int *) __builtin_alloca (p[2] * sizeof (int));\n    int i;\n    \n    for (i = 0; i < p[2]; i++)\n      q[i] = 0;\n\n    while (1)\n      sub2 ();\n  }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-bitops-1.c",
    "content": "#include <limits.h>\n#include <assert.h>\n\n#if __INT_MAX__ > 2147483647L\n# if __INT_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_INT 64\n# else\n#  define BITSIZEOF_INT 32\n# endif\n#else\n# if __INT_MAX__ >= 2147483647L\n#  define BITSIZEOF_INT 32\n# else\n#  define BITSIZEOF_INT 16\n# endif\n#endif\n\n#if __LONG_MAX__ > 2147483647L\n# if __LONG_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_LONG 64\n# else\n#  define BITSIZEOF_LONG 32\n# endif\n#else\n# define BITSIZEOF_LONG 32\n#endif\n\n#if __LONG_LONG_MAX__ > 2147483647L\n# if __LONG_LONG_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_LONG_LONG 64\n# else\n#  define BITSIZEOF_LONG_LONG 32\n# endif\n#else\n# define BITSIZEOF_LONG_LONG 32\n#endif\n\n#define MAKE_FUNS(suffix, type)\t\t\t\t\t\t\\\nint my_ffs##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    if (x == 0)\t\t\t\t\t\t\t\t\\\n\t return 0; \t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1  << i))\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i + 1;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_ctz##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1  << i))\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i;\t\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_clz##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1)))\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i;\t\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_clrsb##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1;\t\t\\\n    for (i = 1; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1)\t\t\\\n\t    != leading)\t\t\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i - 1;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_popcount##suffix(type x) {\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int count = 0;\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << i))\t\t\t\t\t\\\n\t    count++;\t\t\t\t\t\t\t\\\n    return count;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_parity##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int count = 0;\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << i))\t\t\t\t\t\\\n\t    count++;\t\t\t\t\t\t\t\\\n    return count & 1;\t\t\t\t\t\t\t\\\n}\n\nMAKE_FUNS (, unsigned);\nMAKE_FUNS (l, unsigned long);\nMAKE_FUNS (ll, unsigned long long);\n\nextern void abort (void);\nextern void exit (int);\n\n#define NUMS16\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x0000U,\t\t\t\t\t\\\n    0x0001U,\t\t\t\t\t\\\n    0x8000U,\t\t\t\t\t\\\n    0x0002U,\t\t\t\t\t\\\n    0x4000U,\t\t\t\t\t\\\n    0x0100U,\t\t\t\t\t\\\n    0x0080U,\t\t\t\t\t\\\n    0xa5a5U,\t\t\t\t\t\\\n    0x5a5aU,\t\t\t\t\t\\\n    0xcafeU,\t\t\t\t\t\\\n    0xffffU\t\t\t\t\t\\\n  }\n\n#define NUMS32\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x00000000UL,\t\t\t\t\\\n    0x00000001UL,\t\t\t\t\\\n    0x80000000UL,\t\t\t\t\\\n    0x00000002UL,\t\t\t\t\\\n    0x40000000UL,\t\t\t\t\\\n    0x00010000UL,\t\t\t\t\\\n    0x00008000UL,\t\t\t\t\\\n    0xa5a5a5a5UL,\t\t\t\t\\\n    0x5a5a5a5aUL,\t\t\t\t\\\n    0xcafe0000UL,\t\t\t\t\\\n    0x00cafe00UL,\t\t\t\t\\\n    0x0000cafeUL,\t\t\t\t\\\n    0xffffffffUL\t\t\t\t\\\n  }\n\n#define NUMS64\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x0000000000000000ULL,\t\t\t\\\n    0x0000000000000001ULL,\t\t\t\\\n    0x8000000000000000ULL,\t\t\t\\\n    0x0000000000000002ULL,\t\t\t\\\n    0x4000000000000000ULL,\t\t\t\\\n    0x0000000100000000ULL,\t\t\t\\\n    0x0000000080000000ULL,\t\t\t\\\n    0xa5a5a5a5a5a5a5a5ULL,\t\t\t\\\n    0x5a5a5a5a5a5a5a5aULL,\t\t\t\\\n    0xcafecafe00000000ULL,\t\t\t\\\n    0x0000cafecafe0000ULL,\t\t\t\\\n    0x00000000cafecafeULL,\t\t\t\\\n    0xffffffffffffffffULL\t\t\t\\\n  }\n\nunsigned int ints[] =\n#if BITSIZEOF_INT == 64\nNUMS64;\n#elif BITSIZEOF_INT == 32\nNUMS32;\n#else\nNUMS16;\n#endif\n\nunsigned long longs[] =\n#if BITSIZEOF_LONG == 64\nNUMS64;\n#else\nNUMS32;\n#endif\n\nunsigned long long longlongs[] =\n#if BITSIZEOF_LONG_LONG == 64\nNUMS64;\n#else\nNUMS32;\n#endif\n\n#define N(table) (sizeof (table) / sizeof (table[0]))\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < N(ints); i++)\n    {\n      if (__builtin_ffs (ints[i]) != my_ffs (ints[i]))\n\tabort ();\n      if (ints[i] != 0\n\t  && __builtin_clz (ints[i]) != my_clz (ints[i]))\n\tabort ();\n      if (ints[i] != 0\n\t  && __builtin_ctz (ints[i]) != my_ctz (ints[i]))\n\tabort ();\n      if (__builtin_clrsb (ints[i]) != my_clrsb (ints[i]))\n\tabort ();\n      if (__builtin_popcount (ints[i]) != my_popcount (ints[i]))\n\tabort ();\n      if (__builtin_parity (ints[i]) != my_parity (ints[i]))\n\tabort ();\n    }\n\n  for (i = 0; i < N(longs); i++)\n    {\n      if (__builtin_ffsl (longs[i]) != my_ffsl (longs[i]))\n\tabort ();\n      if (longs[i] != 0\n\t  && __builtin_clzl (longs[i]) != my_clzl (longs[i]))\n\tabort ();\n      if (longs[i] != 0\n\t  && __builtin_ctzl (longs[i]) != my_ctzl (longs[i]))\n\tabort ();\n      if (__builtin_clrsbl (longs[i]) != my_clrsbl (longs[i]))\n\tabort ();\n      if (__builtin_popcountl (longs[i]) != my_popcountl (longs[i]))\n\tabort ();\n      if (__builtin_parityl (longs[i]) != my_parityl (longs[i]))\n\tabort ();\n    }\n\n  for (i = 0; i < N(longlongs); i++)\n    {\n      if (__builtin_ffsll (longlongs[i]) != my_ffsll (longlongs[i]))\n\tabort ();\n      if (longlongs[i] != 0\n\t  && __builtin_clzll (longlongs[i]) != my_clzll (longlongs[i]))\n\tabort ();\n      if (longlongs[i] != 0\n\t  && __builtin_ctzll (longlongs[i]) != my_ctzll (longlongs[i]))\n\tabort ();\n      if (__builtin_clrsbll (longlongs[i]) != my_clrsbll (longlongs[i]))\n\tabort ();\n      if (__builtin_popcountll (longlongs[i]) != my_popcountll (longlongs[i]))\n\tabort ();\n      if (__builtin_parityll (longlongs[i]) != my_parityll (longlongs[i]))\n\tabort ();\n    }\n\n  /* Test constant folding.  */\n\n#define TEST(x, suffix)\t\t\t\t\t\t\t\\\n  if (__builtin_ffs##suffix (x) != my_ffs##suffix (x))\t\t\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (x != 0 && __builtin_clz##suffix (x) != my_clz##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (x != 0 && __builtin_ctz##suffix (x) != my_ctz##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x))\t\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_popcount##suffix (x) != my_popcount##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_parity##suffix (x) != my_parity##suffix (x))\t\t\\\n    abort ();\n\n#if BITSIZEOF_INT == 32\n  TEST(0x00000000UL,);\n  TEST(0x00000001UL,);\n  TEST(0x80000000UL,);\n  TEST(0x40000000UL,);\n  TEST(0x00010000UL,);\n  TEST(0x00008000UL,);\n  TEST(0xa5a5a5a5UL,);\n  TEST(0x5a5a5a5aUL,);\n  TEST(0xcafe0000UL,);\n  TEST(0x00cafe00UL,);\n  TEST(0x0000cafeUL,);\n  TEST(0xffffffffUL,);\n#endif\n\n#if BITSIZEOF_LONG_LONG == 64\n  TEST(0x0000000000000000ULL, ll);\n  TEST(0x0000000000000001ULL, ll);\n  TEST(0x8000000000000000ULL, ll);\n  TEST(0x0000000000000002ULL, ll);\n  TEST(0x4000000000000000ULL, ll);\n  TEST(0x0000000100000000ULL, ll);\n  TEST(0x0000000080000000ULL, ll);\n  TEST(0xa5a5a5a5a5a5a5a5ULL, ll);\n  TEST(0x5a5a5a5a5a5a5a5aULL, ll);\n  TEST(0xcafecafe00000000ULL, ll);\n  TEST(0x0000cafecafe0000ULL, ll);\n  TEST(0x00000000cafecafeULL, ll);\n  TEST(0xffffffffffffffffULL, ll);\n#endif\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-constant.c",
    "content": "/* PR optimization/8423.  */\n\n#define btest(x) __builtin_constant_p(x) ? \"1\" : \"0\"\n\n#ifdef __OPTIMIZE__\nvoid\nfoo (char *i)\n{\n  if (*i == '0')\n    abort ();\n}\n#else\nvoid\nfoo (char *i)\n{\n}\n#endif\n\nint\nmain (void)\n{\n  int size = sizeof (int);\n  foo (btest (size));\n  foo (btest (size));\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-1.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch using all valid combinations of rw and locality values.\n   These must be compile-time constants.  */\n\n#define NO_TEMPORAL_LOCALITY 0\n#define LOW_TEMPORAL_LOCALITY 1\n#define MODERATE_TEMPORAL_LOCALITY 1\n#define HIGH_TEMPORAL_LOCALITY 3\n\n#define WRITE_ACCESS 1\n#define READ_ACCESS 0\n\nenum locality { none, low, moderate, high };\nenum rw { read, write };\n\nint arr[10];\n\nvoid\ngood_const (const int *p)\n{\n  __builtin_prefetch (p, 0, 0);\n  __builtin_prefetch (p, 0, 1);\n  __builtin_prefetch (p, 0, 2);\n  __builtin_prefetch (p, READ_ACCESS, 3);\n  __builtin_prefetch (p, 1, NO_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, 1, LOW_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, 1, MODERATE_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, WRITE_ACCESS, HIGH_TEMPORAL_LOCALITY);\n}\n\nvoid\ngood_enum (const int *p)\n{\n    __builtin_prefetch (p, read, none);\n    __builtin_prefetch (p, read, low);\n    __builtin_prefetch (p, read, moderate);\n    __builtin_prefetch (p, read, high);\n    __builtin_prefetch (p, write, none);\n    __builtin_prefetch (p, write, low);\n    __builtin_prefetch (p, write, moderate);\n    __builtin_prefetch (p, write, high);\n}\n\nvoid\ngood_expr (const int *p)\n{\n  __builtin_prefetch (p, 1 - 1, 6 - (2 * 3));\n  __builtin_prefetch (p, 1 + 0, 1 + 2);\n}\n\nvoid\ngood_vararg (const int *p)\n{\n  __builtin_prefetch (p, 0, 3);\n  __builtin_prefetch (p, 0);\n  __builtin_prefetch (p, 1);\n  __builtin_prefetch (p);\n}\n\nint\nmain ()\n{\n  good_const (arr);\n  good_enum (arr);\n  good_expr (arr);\n  good_vararg (arr);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-2.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch data using a variety of storage classes and address\n   expressions.  */\n\nint glob_int_arr[100];\nint *glob_ptr_int = glob_int_arr;\nint glob_int = 4;\n\nstatic stat_int_arr[100];\nstatic int *stat_ptr_int = stat_int_arr;\nstatic int stat_int;\n\nstruct S {\n  int a;\n  short b, c;\n  char d[8];\n  struct S *next;\n};\n\nstruct S str;\nstruct S *ptr_str = &str;\n\n/* Prefetch global variables using the address of the variable.  */\n\nvoid\nsimple_global ()\n{\n  __builtin_prefetch (glob_int_arr, 0, 0);\n  __builtin_prefetch (glob_ptr_int, 0, 0);\n  __builtin_prefetch (&glob_int, 0, 0);\n}\n\n/* Prefetch file-level static variables using the address of the variable.  */\n\nvoid\nsimple_file ()\n{\n  __builtin_prefetch (stat_int_arr, 0, 0);\n  __builtin_prefetch (stat_ptr_int, 0, 0);\n  __builtin_prefetch (&stat_int, 0, 0);\n}\n\n/* Prefetch local static variables using the address of the variable.  */\n\nvoid\nsimple_static_local ()\n{\n  static int gx[100];\n  static int *hx = gx;\n  static int ix;\n  __builtin_prefetch (gx, 0, 0);\n  __builtin_prefetch (hx, 0, 0);\n  __builtin_prefetch (&ix, 0, 0);\n}\n\n/* Prefetch local stack variables using the address of the variable.  */\n\nvoid\nsimple_local ()\n{\n  int gx[100];\n  int *hx = gx;\n  int ix;\n  __builtin_prefetch (gx, 0, 0);\n  __builtin_prefetch (hx, 0, 0);\n  __builtin_prefetch (&ix, 0, 0);\n}\n\n/* Prefetch arguments using the address of the variable.  */\n\nvoid\nsimple_arg (int g[100], int *h, int i)\n{\n  __builtin_prefetch (g, 0, 0);\n  __builtin_prefetch (h, 0, 0);\n  __builtin_prefetch (&i, 0, 0);\n}\n\n/* Prefetch using address expressions involving global variables.  */\n\nvoid\nexpr_global (void)\n{\n  __builtin_prefetch (&str, 0, 0);\n  __builtin_prefetch (ptr_str, 0, 0);\n  __builtin_prefetch (&str.b, 0, 0);\n  __builtin_prefetch (&ptr_str->b, 0, 0);\n  __builtin_prefetch (&str.d, 0, 0);\n  __builtin_prefetch (&ptr_str->d, 0, 0);\n  __builtin_prefetch (str.next, 0, 0);\n  __builtin_prefetch (ptr_str->next, 0, 0);\n  __builtin_prefetch (str.next->d, 0, 0);\n  __builtin_prefetch (ptr_str->next->d, 0, 0);\n\n  __builtin_prefetch (&glob_int_arr, 0, 0);\n  __builtin_prefetch (glob_ptr_int, 0, 0);\n  __builtin_prefetch (&glob_int_arr[2], 0, 0);\n  __builtin_prefetch (&glob_ptr_int[3], 0, 0);\n  __builtin_prefetch (glob_int_arr+3, 0, 0);\n  __builtin_prefetch (glob_int_arr+glob_int, 0, 0);\n  __builtin_prefetch (glob_ptr_int+5, 0, 0);\n  __builtin_prefetch (glob_ptr_int+glob_int, 0, 0);\n}\n\n/* Prefetch using address expressions involving local variables.  */\n\nvoid\nexpr_local (void)\n{\n  int b[10];\n  int *pb = b;\n  struct S t;\n  struct S *pt = &t;\n  int j = 4;\n\n  __builtin_prefetch (&t, 0, 0);\n  __builtin_prefetch (pt, 0, 0);\n  __builtin_prefetch (&t.b, 0, 0);\n  __builtin_prefetch (&pt->b, 0, 0);\n  __builtin_prefetch (&t.d, 0, 0);\n  __builtin_prefetch (&pt->d, 0, 0);\n  __builtin_prefetch (t.next, 0, 0);\n  __builtin_prefetch (pt->next, 0, 0);\n  __builtin_prefetch (t.next->d, 0, 0);\n  __builtin_prefetch (pt->next->d, 0, 0);\n\n  __builtin_prefetch (&b, 0, 0);\n  __builtin_prefetch (pb, 0, 0);\n  __builtin_prefetch (&b[2], 0, 0);\n  __builtin_prefetch (&pb[3], 0, 0);\n  __builtin_prefetch (b+3, 0, 0);\n  __builtin_prefetch (b+j, 0, 0);\n  __builtin_prefetch (pb+5, 0, 0);\n  __builtin_prefetch (pb+j, 0, 0);\n}\n\nint\nmain ()\n{\n  simple_global ();\n  simple_file ();\n  simple_static_local ();\n  simple_local ();\n  simple_arg (glob_int_arr, glob_ptr_int, glob_int);\n\n  str.next = &str;\n  expr_global ();\n  expr_local ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-3.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch data using a variety of storage classes and address\n   expressions with volatile variables and pointers.  */\n\nint glob_int_arr[100];\nint glob_int = 4;\nvolatile int glob_vol_int_arr[100];\nint * volatile glob_vol_ptr_int = glob_int_arr;\nvolatile int *glob_ptr_vol_int = glob_vol_int_arr;\nvolatile int * volatile glob_vol_ptr_vol_int = glob_vol_int_arr;\nvolatile int glob_vol_int;\n\nstatic stat_int_arr[100];\nstatic volatile int stat_vol_int_arr[100];\nstatic int * volatile stat_vol_ptr_int = stat_int_arr;\nstatic volatile int *stat_ptr_vol_int = stat_vol_int_arr;\nstatic volatile int * volatile stat_vol_ptr_vol_int = stat_vol_int_arr;\nstatic volatile int stat_vol_int;\n\nstruct S {\n  int a;\n  short b, c;\n  char d[8];\n  struct S *next;\n};\n\nstruct S str;\nvolatile struct S vol_str;\nstruct S * volatile vol_ptr_str = &str;\nvolatile struct S *ptr_vol_str = &vol_str;\nvolatile struct S * volatile vol_ptr_vol_str = &vol_str;\n\n/* Prefetch volatile global variables using the address of the variable.  */\n\nvoid\nsimple_vol_global ()\n{\n  __builtin_prefetch (glob_vol_int_arr, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&glob_vol_int, 0, 0);\n}\n\n/* Prefetch volatile static variables using the address of the variable.  */\n\nvoid\nsimple_vol_file ()\n{\n  __builtin_prefetch (stat_vol_int_arr, 0, 0);\n  __builtin_prefetch (stat_vol_ptr_int, 0, 0);\n  __builtin_prefetch (stat_ptr_vol_int, 0, 0);\n  __builtin_prefetch (stat_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&stat_vol_int, 0, 0);\n}\n\n/* Prefetch using address expressions involving volatile global variables.  */\n\nvoid\nexpr_vol_global (void)\n{\n  __builtin_prefetch (&vol_str, 0, 0);\n  __builtin_prefetch (ptr_vol_str, 0, 0);\n  __builtin_prefetch (vol_ptr_str, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str, 0, 0);\n  __builtin_prefetch (&vol_str.b, 0, 0);\n  __builtin_prefetch (&ptr_vol_str->b, 0, 0);\n  __builtin_prefetch (&vol_ptr_str->b, 0, 0);\n  __builtin_prefetch (&vol_ptr_vol_str->b, 0, 0);\n  __builtin_prefetch (&vol_str.d, 0, 0);\n  __builtin_prefetch (&vol_ptr_str->d, 0, 0);\n  __builtin_prefetch (&ptr_vol_str->d, 0, 0);\n  __builtin_prefetch (&vol_ptr_vol_str->d, 0, 0);\n  __builtin_prefetch (vol_str.next, 0, 0);\n  __builtin_prefetch (vol_ptr_str->next, 0, 0);\n  __builtin_prefetch (ptr_vol_str->next, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str->next, 0, 0);\n  __builtin_prefetch (vol_str.next->d, 0, 0);\n  __builtin_prefetch (vol_ptr_str->next->d, 0, 0);\n  __builtin_prefetch (ptr_vol_str->next->d, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str->next->d, 0, 0);\n\n  __builtin_prefetch (&glob_vol_int_arr, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&glob_vol_int_arr[2], 0, 0);\n  __builtin_prefetch (&glob_vol_ptr_int[3], 0, 0);\n  __builtin_prefetch (&glob_ptr_vol_int[3], 0, 0);\n  __builtin_prefetch (&glob_vol_ptr_vol_int[3], 0, 0);\n  __builtin_prefetch (glob_vol_int_arr+3, 0, 0);\n  __builtin_prefetch (glob_vol_int_arr+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int+5, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int+5, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int+5, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int+glob_vol_int, 0, 0);\n}\n\nint\nmain ()\n{\n  simple_vol_global ();\n  simple_vol_file ();\n\n  str.next = &str;\n  vol_str.next = &str;\n  expr_vol_global ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-4.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Check that the expression containing the address to prefetch is\n   evaluated if it has side effects, even if the target does not support\n   data prefetch.  Check changes to pointers and to array indices that are\n   either global variables or arguments.  */\n\n#define ARRSIZE 100\n\nint arr[ARRSIZE];\nint *ptr = &arr[20]; \nint arrindex = 4;\n\n/* Check that assignment within a prefetch argument is evaluated.  */\n\nint\nassign_arg_ptr (int *p)\n{\n  int *q;\n  __builtin_prefetch ((q = p), 0, 0);\n  return q == p;\n}\n\nint\nassign_glob_ptr (void)\n{\n  int *q;\n  __builtin_prefetch ((q = ptr), 0, 0);\n  return q == ptr;\n}\n\nint\nassign_arg_idx (int *p, int i)\n{\n  int j;\n  __builtin_prefetch (&p[j = i], 0, 0);\n  return j == i;\n}\n\nint\nassign_glob_idx (void)\n{\n  int j;\n  __builtin_prefetch (&ptr[j = arrindex], 0, 0);\n  return j == arrindex;\n}\n\n/* Check that pre/post increment/decrement within a prefetch argument are\n   evaluated.  */\n\nint\npreinc_arg_ptr (int *p)\n{\n  int *q;\n  q = p + 1;\n  __builtin_prefetch (++p, 0, 0);\n  return p == q;\n}\n\nint\npreinc_glob_ptr (void)\n{\n  int *q;\n  q = ptr + 1;\n  __builtin_prefetch (++ptr, 0, 0);\n  return ptr == q;\n}\n\nint\npostinc_arg_ptr (int *p)\n{\n  int *q;\n  q = p + 1;\n  __builtin_prefetch (p++, 0, 0);\n  return p == q;\n}\n\nint\npostinc_glob_ptr (void)\n{\n  int *q;\n  q = ptr + 1;\n  __builtin_prefetch (ptr++, 0, 0);\n  return ptr == q;\n}\n\nint\npredec_arg_ptr (int *p)\n{\n  int *q;\n  q = p - 1;\n  __builtin_prefetch (--p, 0, 0);\n  return p == q;\n}\n\nint\npredec_glob_ptr (void)\n{\n  int *q;\n  q = ptr - 1;\n  __builtin_prefetch (--ptr, 0, 0);\n  return ptr == q;\n}\n\nint\npostdec_arg_ptr (int *p)\n{\n  int *q;\n  q = p - 1;\n  __builtin_prefetch (p--, 0, 0);\n  return p == q;\n}\n\nint\npostdec_glob_ptr (void)\n{\n  int *q;\n  q = ptr - 1;\n  __builtin_prefetch (ptr--, 0, 0);\n  return ptr == q;\n}\n\nint\npreinc_arg_idx (int *p, int i)\n{\n  int j = i + 1;\n  __builtin_prefetch (&p[++i], 0, 0);\n  return i == j;\n}\n\n\nint\npreinc_glob_idx (void)\n{\n  int j = arrindex + 1;\n  __builtin_prefetch (&ptr[++arrindex], 0, 0);\n  return arrindex == j;\n}\n\nint\npostinc_arg_idx (int *p, int i)\n{\n  int j = i + 1;\n  __builtin_prefetch (&p[i++], 0, 0);\n  return i == j;\n}\n\nint\npostinc_glob_idx (void)\n{\n  int j = arrindex + 1;\n  __builtin_prefetch (&ptr[arrindex++], 0, 0);\n  return arrindex == j;\n}\n\nint\npredec_arg_idx (int *p, int i)\n{\n  int j = i - 1;\n  __builtin_prefetch (&p[--i], 0, 0);\n  return i == j;\n}\n\nint\npredec_glob_idx (void)\n{\n  int j = arrindex - 1;\n  __builtin_prefetch (&ptr[--arrindex], 0, 0);\n  return arrindex == j;\n}\n\nint\npostdec_arg_idx (int *p, int i)\n{\n  int j = i - 1;\n  __builtin_prefetch (&p[i--], 0, 0);\n  return i == j;\n}\n\nint\npostdec_glob_idx (void)\n{\n  int j = arrindex - 1;\n  __builtin_prefetch (&ptr[arrindex--], 0, 0);\n  return arrindex == j;\n}\n\n/* Check that function calls within the first prefetch argument are\n   evaluated.  */\n\nint getptrcnt = 0;\n\nint *\ngetptr (int *p)\n{\n  getptrcnt++;\n  return p + 1;\n}\n\nint\nfunccall_arg_ptr (int *p)\n{\n  __builtin_prefetch (getptr (p), 0, 0);\n  return getptrcnt == 1;\n}\n\nint getintcnt = 0;\n\nint\ngetint (int i)\n{\n  getintcnt++;\n  return i + 1;\n}\n\nint\nfunccall_arg_idx (int *p, int i)\n{\n  __builtin_prefetch (&p[getint (i)], 0, 0);\n  return getintcnt == 1;\n}\n\nint\nmain ()\n{\n  if (!assign_arg_ptr (ptr))\n    abort ();\n  if (!assign_glob_ptr ())\n    abort ();\n  if (!assign_arg_idx (ptr, 4))\n    abort ();\n  if (!assign_glob_idx ())\n    abort ();\n  if (!preinc_arg_ptr (ptr))\n    abort ();\n  if (!preinc_glob_ptr ())\n    abort ();\n  if (!postinc_arg_ptr (ptr))\n    abort ();\n  if (!postinc_glob_ptr ())\n    abort ();\n  if (!predec_arg_ptr (ptr))\n    abort ();\n  if (!predec_glob_ptr ())\n    abort ();\n  if (!postdec_arg_ptr (ptr))\n    abort ();\n  if (!postdec_glob_ptr ())\n    abort ();\n  if (!preinc_arg_idx (ptr, 3))\n    abort ();\n  if (!preinc_glob_idx ())\n    abort ();\n  if (!postinc_arg_idx (ptr, 3))\n    abort ();\n  if (!postinc_glob_idx ())\n    abort ();\n  if (!predec_arg_idx (ptr, 3))\n    abort ();\n  if (!predec_glob_idx ())\n    abort ();\n  if (!postdec_arg_idx (ptr, 3))\n    abort ();\n  if (!postdec_glob_idx ())\n    abort ();\n  if (!funccall_arg_ptr (ptr))\n    abort ();\n  if (!funccall_arg_idx (ptr, 3))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-5.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Use addresses that are unlikely to be word-aligned.  Some targets\n   have alignment requirements for prefetch addresses, so make sure the\n   compiler takes care of that.  This fails if it aborts, anything else\n   is OK.  */\n\nstruct S {\n  short a;\n  short b;\n  char c[8];\n} s;\n\nchar arr[100];\nchar *ptr = arr;\nint idx = 3;\n\nvoid\narg_ptr (char *p)\n{\n  __builtin_prefetch (p, 0, 0);\n}\n\nvoid\narg_idx (char *p, int i)\n{\n  __builtin_prefetch (&p[i], 0, 0);\n}\n\nvoid\nglob_ptr (void)\n{\n  __builtin_prefetch (ptr, 0, 0);\n}\n\nvoid\nglob_idx (void)\n{\n  __builtin_prefetch (&ptr[idx], 0, 0);\n}\n\nint\nmain ()\n{\n  __builtin_prefetch (&s.b, 0, 0);\n  __builtin_prefetch (&s.c[1], 0, 0);\n\n  arg_ptr (&s.c[1]);\n  arg_ptr (ptr+3);\n  arg_idx (ptr, 3);\n  arg_idx (ptr+1, 2);\n  idx = 3;\n  glob_ptr ();\n  glob_idx ();\n  ptr++;\n  idx = 2;\n  glob_ptr ();\n  glob_idx ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-6.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Data prefetch should not fault if used with an invalid address.  */\n\n#include <limits.h>\n\n#define ARRSIZE 65\nint *bad_addr[ARRSIZE];\nint arr_used;\n\n/* Fill bad_addr with a range of values in the hopes that on any target\n   some will be invalid addresses.  */\nvoid\ninit_addrs (void)\n{\n  int i;\n  int bits_per_ptr = sizeof (void *) * 8;\n  for (i = 0; i < bits_per_ptr; i++)\n    bad_addr[i] = (void *)(1UL << i);\n  arr_used = bits_per_ptr + 1;  /* The last element used is zero.  */\n}\n\nvoid\nprefetch_for_read (void)\n{\n  int i;\n  for (i = 0; i < ARRSIZE; i++)\n    __builtin_prefetch (bad_addr[i], 0, 0);\n}\n\nvoid\nprefetch_for_write (void)\n{\n  int i;\n  for (i = 0; i < ARRSIZE; i++)\n    __builtin_prefetch (bad_addr[i], 1, 0);\n}\n\nint\nmain ()\n{\n  init_addrs ();\n  prefetch_for_read ();\n  prefetch_for_write ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c",
    "content": "int i;\ndouble d;\n\n/* Make sure we return a constant.  */\nfloat rootbeer[__builtin_types_compatible_p (int, typeof(i))];\n\ntypedef enum { hot, dog, poo, bear } dingos;\ntypedef enum { janette, laura, amanda } cranberry;\n\ntypedef float same1;\ntypedef float same2;\n\nint main (void);\n\nint main (void)\n{\n  /* Compatible types.  */\n  if (!(__builtin_types_compatible_p (int, const int)\n\t&& __builtin_types_compatible_p (typeof (hot), int)\n\t&& __builtin_types_compatible_p (typeof (hot), typeof (laura))\n\t&& __builtin_types_compatible_p (int[5], int[])\n\t&& __builtin_types_compatible_p (same1, same2)))\n    abort ();\n\n  /* Incompatible types.  */\n  if (__builtin_types_compatible_p (char *, int)\n      || __builtin_types_compatible_p (char *, const char *)\n      || __builtin_types_compatible_p (long double, double)\n      || __builtin_types_compatible_p (typeof (i), typeof (d))\n      || __builtin_types_compatible_p (typeof (dingos), typeof (cranberry))\n      || __builtin_types_compatible_p (char, int)\n      || __builtin_types_compatible_p (char *, char **))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/20010124-1-lib.c",
    "content": "/* Verify that structure return doesn't invoke memcpy on \n   overlapping objects.  */\n\nextern void abort (void);\nextern int inside_main;\ntypedef __SIZE_TYPE__ size_t;\n\nstruct S {\n  char stuff[1024];\n};\n\nunion U {\n  struct {\n    int space;\n    struct S s;\n  } a;\n  struct {\n    struct S s;\n    int space;\n  } b;\n};\n  \nstruct S f(struct S *p)\n{\n  return *p;\n}\n\nvoid g(union U *p)\n{\n}\n\nvoid *memcpy(void *a, const void *b, size_t len)\n{\n  if (inside_main)\n    {\n      if (a < b && a+len > b)\n        abort ();\n      if (b < a && b+len > a)\n        abort ();\n      return a;\n    }\n  else\n    {\n      char *dst = (char *) a;\n      const char *src = (const char *) b;\n      while (len--)\n        *dst++ = *src++;\n      return a;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/20010124-1.c",
    "content": "/* Verify that structure return doesn't invoke memcpy on \n   overlapping objects.  */\n\nextern void abort (void);\n\nstruct S {\n  char stuff[1024];\n};\n\nunion U {\n  struct {\n    int space;\n    struct S s;\n  } a;\n  struct {\n    struct S s;\n    int space;\n  } b;\n};\n\nstruct S f(struct S *);\nvoid g(union U *);\n\nvoid main_test(void)\n{\n  union U u;\n  u.b.s = f(&u.a.s);\n  u.a.s = f(&u.b.s);\n  g(&u);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/20010124-1.x",
    "content": "load_lib target-supports.exp\n\nif [istarget \"nvptx-*-*\"] {\n    # This test uses memcpy for block move in the same file as it\n    # defines it.  The two decls are not the same, by design, and we\n    # end up emitting a definition of memcpy, along with a .extern\n    # declaration. This confuses the ptx assembler.\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1-lib.c",
    "content": "extern void abort (void);\nextern int abs_called;\nextern int inside_main;\n\n/* The labs call should have been optimized, but the abs call\n   shouldn't have been.  */\n\nint\nabs (int x)\n{\n  if (inside_main)\n    abs_called = 1;\n  return (x < 0 ? -x : x);\n}\n\nlong\nlabs (long x)\n{\n  if (inside_main)\n    abort ();\n  return (x < 0 ? -x : x);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.c",
    "content": "/* Test for -fno-builtin-FUNCTION.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n/* GCC normally handles abs and labs as built-in functions even without\n   optimization.  So test that with -fno-builtin-abs, labs is so handled\n   but abs isn't.  */\n\nint abs_called = 0;\n\nextern int abs (int);\nextern long labs (long);\nextern void abort (void);\n\nvoid\nmain_test (void)\n{\n  if (labs (0) != 0)\n    abort ();\n  if (abs (0) != 0)\n    abort ();\n  if (!abs_called)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-1.x",
    "content": "set additional_flags -fno-builtin-abs\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2-lib.c",
    "content": "#include \"lib/abs.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-2.c",
    "content": "/* Test for builtin abs, labs, llabs, imaxabs.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk> */\n\n#include <limits.h>\ntypedef __INTMAX_TYPE__ intmax_t;\n#define INTMAX_MAX __INTMAX_MAX__\n\nextern int abs (int);\nextern long labs (long);\nextern long long llabs (long long);\nextern intmax_t imaxabs (intmax_t);\nextern void abort (void);\nextern void link_error (void);\n\nvoid\nmain_test (void)\n{\n  /* For each type, test both runtime and compile time (constant folding)\n     optimization.  */\n  volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX;\n  volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX;\n  volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;\n  volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__;\n  volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1;\n  volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX;\n  if (abs (i0) != 0)\n    abort ();\n  if (abs (0) != 0)\n    link_error ();\n  if (abs (i1) != 1)\n    abort ();\n  if (abs (1) != 1)\n    link_error ();\n  if (abs (im1) != 1)\n    abort ();\n  if (abs (-1) != 1)\n    link_error ();\n  if (abs (imin) != INT_MAX)\n    abort ();\n  if (abs (-INT_MAX) != INT_MAX)\n    link_error ();\n  if (abs (imax) != INT_MAX)\n    abort ();\n  if (abs (INT_MAX) != INT_MAX)\n    link_error ();\n  if (labs (l0) != 0L)\n    abort ();\n  if (labs (0L) != 0L)\n    link_error ();\n  if (labs (l1) != 1L)\n    abort ();\n  if (labs (1L) != 1L)\n    link_error ();\n  if (labs (lm1) != 1L)\n    abort ();\n  if (labs (-1L) != 1L)\n    link_error ();\n  if (labs (lmin) != LONG_MAX)\n    abort ();\n  if (labs (-LONG_MAX) != LONG_MAX)\n    link_error ();\n  if (labs (lmax) != LONG_MAX)\n    abort ();\n  if (labs (LONG_MAX) != LONG_MAX)\n    link_error ();\n  if (llabs (ll0) != 0LL)\n    abort ();\n  if (llabs (0LL) != 0LL)\n    link_error ();\n  if (llabs (ll1) != 1LL)\n    abort ();\n  if (llabs (1LL) != 1LL)\n    link_error ();\n  if (llabs (llm1) != 1LL)\n    abort ();\n  if (llabs (-1LL) != 1LL)\n    link_error ();\n  if (llabs (llmin) != __LONG_LONG_MAX__)\n    abort ();\n  if (llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__)\n    link_error ();\n  if (llabs (llmax) != __LONG_LONG_MAX__)\n    abort ();\n  if (llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__)\n    link_error ();\n  if (imaxabs (imax0) != 0)\n    abort ();\n  if (imaxabs (0) != 0)\n    link_error ();\n  if (imaxabs (imax1) != 1)\n    abort ();\n  if (imaxabs (1) != 1)\n    link_error ();\n  if (imaxabs (imaxm1) != 1)\n    abort ();\n  if (imaxabs (-1) != 1)\n    link_error ();\n  if (imaxabs (imaxmin) != INTMAX_MAX)\n    abort ();\n  if (imaxabs (-INTMAX_MAX) != INTMAX_MAX)\n    link_error ();\n  if (imaxabs (imaxmax) != INTMAX_MAX)\n    abort ();\n  if (imaxabs (INTMAX_MAX) != INTMAX_MAX)\n    link_error ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3-lib.c",
    "content": "#include \"lib/abs.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/abs-3.c",
    "content": "/* Test for builtin abs, labs, llabs, imaxabs.  Test for __builtin versions. */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk> */\n\n#include <limits.h>\ntypedef __INTMAX_TYPE__ intmax_t;\n#define INTMAX_MAX __INTMAX_MAX__\n\nextern void abort (void);\nextern void link_error (void);\n\nvoid\nmain_test (void)\n{\n  /* For each type, test both runtime and compile time (constant folding)\n     optimization.  */\n  volatile int i0 = 0, i1 = 1, im1 = -1, imin = -INT_MAX, imax = INT_MAX;\n  volatile long l0 = 0L, l1 = 1L, lm1 = -1L, lmin = -LONG_MAX, lmax = LONG_MAX;\n  volatile long long ll0 = 0LL, ll1 = 1LL, llm1 = -1LL;\n  volatile long long llmin = -__LONG_LONG_MAX__, llmax = __LONG_LONG_MAX__;\n  volatile intmax_t imax0 = 0, imax1 = 1, imaxm1 = -1;\n  volatile intmax_t imaxmin = -INTMAX_MAX, imaxmax = INTMAX_MAX;\n  if (__builtin_abs (i0) != 0)\n    abort ();\n  if (__builtin_abs (0) != 0)\n    link_error ();\n  if (__builtin_abs (i1) != 1)\n    abort ();\n  if (__builtin_abs (1) != 1)\n    link_error ();\n  if (__builtin_abs (im1) != 1)\n    abort ();\n  if (__builtin_abs (-1) != 1)\n    link_error ();\n  if (__builtin_abs (imin) != INT_MAX)\n    abort ();\n  if (__builtin_abs (-INT_MAX) != INT_MAX)\n    link_error ();\n  if (__builtin_abs (imax) != INT_MAX)\n    abort ();\n  if (__builtin_abs (INT_MAX) != INT_MAX)\n    link_error ();\n  if (__builtin_labs (l0) != 0L)\n    abort ();\n  if (__builtin_labs (0L) != 0L)\n    link_error ();\n  if (__builtin_labs (l1) != 1L)\n    abort ();\n  if (__builtin_labs (1L) != 1L)\n    link_error ();\n  if (__builtin_labs (lm1) != 1L)\n    abort ();\n  if (__builtin_labs (-1L) != 1L)\n    link_error ();\n  if (__builtin_labs (lmin) != LONG_MAX)\n    abort ();\n  if (__builtin_labs (-LONG_MAX) != LONG_MAX)\n    link_error ();\n  if (__builtin_labs (lmax) != LONG_MAX)\n    abort ();\n  if (__builtin_labs (LONG_MAX) != LONG_MAX)\n    link_error ();\n  if (__builtin_llabs (ll0) != 0LL)\n    abort ();\n  if (__builtin_llabs (0LL) != 0LL)\n    link_error ();\n  if (__builtin_llabs (ll1) != 1LL)\n    abort ();\n  if (__builtin_llabs (1LL) != 1LL)\n    link_error ();\n  if (__builtin_llabs (llm1) != 1LL)\n    abort ();\n  if (__builtin_llabs (-1LL) != 1LL)\n    link_error ();\n  if (__builtin_llabs (llmin) != __LONG_LONG_MAX__)\n    abort ();\n  if (__builtin_llabs (-__LONG_LONG_MAX__) != __LONG_LONG_MAX__)\n    link_error ();\n  if (__builtin_llabs (llmax) != __LONG_LONG_MAX__)\n    abort ();\n  if (__builtin_llabs (__LONG_LONG_MAX__) != __LONG_LONG_MAX__)\n    link_error ();\n  if (__builtin_imaxabs (imax0) != 0)\n    abort ();\n  if (__builtin_imaxabs (0) != 0)\n    link_error ();\n  if (__builtin_imaxabs (imax1) != 1)\n    abort ();\n  if (__builtin_imaxabs (1) != 1)\n    link_error ();\n  if (__builtin_imaxabs (imaxm1) != 1)\n    abort ();\n  if (__builtin_imaxabs (-1) != 1)\n    link_error ();\n  if (__builtin_imaxabs (imaxmin) != INTMAX_MAX)\n    abort ();\n  if (__builtin_imaxabs (-INTMAX_MAX) != INTMAX_MAX)\n    link_error ();\n  if (__builtin_imaxabs (imaxmax) != INTMAX_MAX)\n    abort ();\n  if (__builtin_imaxabs (INTMAX_MAX) != INTMAX_MAX)\n    link_error ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/builtins.exp",
    "content": "# Copyright (C) 2003-2016 Free Software Foundation, Inc.\n#\n# This file is part of GCC.\n#\n# GCC is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3, or (at your option)\n# any later version.\n#\n# GCC is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n\n# This harness is for testing builtin support.  Each test has two files:\n#\n#    - foo.c defines the main testing function, main_test().\n#    - foo-lib.c implements the library functions that foo.c is testing.\n#\n# The functions in foo-lib.c will often want to abort on certain inputs.\n# They can use the global variable inside_main to see whether they are\n# being called from the test program or part of the common runtime.\n#\n# In many cases, the library functions will behave as normal at -O0\n# and abort when optimisation is enabled.  Such implementations should\n# go into the lib/ directory so that they can be included by any test\n# that needs them.  They shouldn't call any external functions in case\n# those functions were overridden too.\n\nload_lib torture-options.exp\nload_lib c-torture.exp\n\ntorture-init\nset-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS\n\nset additional_flags \"-fno-tree-loop-distribute-patterns -fno-tracer\"\nif [istarget \"powerpc-*-darwin*\"] {\n   lappend additional_flags \"-Wl,-multiply_defined,suppress\"\n}\nif { [istarget *-*-eabi*]\n     || [istarget *-*-elf]\n     || [istarget *-*-mingw*]\n     || [istarget *-*-rtems*] } {\n   lappend additional_flags \"-Wl,--allow-multiple-definition\"\n}\n\nforeach src [lsort [find $srcdir/$subdir *.c]] {\n    if {![string match *-lib.c $src] && [runtest_file_p $runtests $src]} {\n\tc-torture-execute [list $src \\\n\t\t\t        [file root $src]-lib.c \\\n\t\t\t        $srcdir/$subdir/lib/main.c] \\\n\t\t\t\t$additional_flags\n    }\n}\n\ntorture-finish\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/chk.h",
    "content": "#ifndef os\n# define os(ptr) __builtin_object_size (ptr, 0)\n#endif\n\n/* This is one of the alternatives for object size checking.\n   If dst has side-effects, size checking will never be done.  */\n#undef memcpy\n#define memcpy(dst, src, len) \\\n  __builtin___memcpy_chk (dst, src, len, os (dst))\n#undef mempcpy\n#define mempcpy(dst, src, len) \\\n  __builtin___mempcpy_chk (dst, src, len, os (dst))\n#undef memmove\n#define memmove(dst, src, len) \\\n  __builtin___memmove_chk (dst, src, len, os (dst))\n#undef memset\n#define memset(dst, val, len) \\\n  __builtin___memset_chk (dst, val, len, os (dst))\n#undef strcpy\n#define strcpy(dst, src) \\\n  __builtin___strcpy_chk (dst, src, os (dst))\n#undef stpcpy\n#define stpcpy(dst, src) \\\n  __builtin___stpcpy_chk (dst, src, os (dst))\n#undef strcat\n#define strcat(dst, src) \\\n  __builtin___strcat_chk (dst, src, os (dst))\n#undef strncpy\n#define strncpy(dst, src, len) \\\n  __builtin___strncpy_chk (dst, src, len, os (dst))\n#undef stpncpy\n#define stpncpy(dst, src, len) \\\n  __builtin___stpncpy_chk (dst, src, len, os (dst))\n#undef strncat\n#define strncat(dst, src, len) \\\n  __builtin___strncat_chk (dst, src, len, os (dst))\n#undef sprintf\n#define sprintf(dst, ...) \\\n  __builtin___sprintf_chk (dst, 0, os (dst), __VA_ARGS__)\n#undef vsprintf\n#define vsprintf(dst, fmt, ap) \\\n  __builtin___vsprintf_chk (dst, 0, os (dst), fmt, ap)\n#undef snprintf\n#define snprintf(dst, len, ...) \\\n  __builtin___snprintf_chk (dst, len, 0, os (dst), __VA_ARGS__)\n#undef vsnprintf\n#define vsnprintf(dst, len, fmt, ap) \\\n  __builtin___vsnprintf_chk (dst, len, 0, os (dst), fmt, ap)\n\n/* Now \"redefine\" even builtins for the purpose of testing.  */\n#undef __builtin_memcpy\n#define __builtin_memcpy(dst, src, len) memcpy (dst, src, len)\n#undef __builtin_mempcpy\n#define __builtin_mempcpy(dst, src, len) mempcpy (dst, src, len)\n#undef __builtin_memmove\n#define __builtin_memmove(dst, src, len) memmove (dst, src, len)\n#undef __builtin_memset\n#define __builtin_memset(dst, val, len) memset (dst, val, len)\n#undef __builtin_strcpy\n#define __builtin_strcpy(dst, src) strcpy (dst, src)\n#undef __builtin_stpcpy\n#define __builtin_stpcpy(dst, src) stpcpy (dst, src)\n#undef __builtin_strcat\n#define __builtin_strcat(dst, src) strcat (dst, src)\n#undef __builtin_strncpy\n#define __builtin_strncpy(dst, src, len) strncpy (dst, src, len)\n#undef __builtin_strncat\n#define __builtin_strncat(dst, src, len) strncat (dst, src, len)\n#undef __builtin_sprintf\n#define __builtin_sprintf(dst, ...) sprintf (dst, __VA_ARGS__)\n#undef __builtin_vsprintf\n#define __builtin_vsprintf(dst, fmt, ap) vsprintf (dst, fmt, ap)\n#undef __builtin_snprintf\n#define __builtin_snprintf(dst, len, ...) snprintf (dst, len, __VA_ARGS__)\n#undef __builtin_vsnprintf\n#define __builtin_vsnprintf(dst, len, fmt, ap) vsnprintf (dst, len, fmt, ap)\n\nextern void *chk_fail_buf[];\nextern volatile int chk_fail_allowed, chk_calls;\nextern volatile int memcpy_disallowed, mempcpy_disallowed, memmove_disallowed;\nextern volatile int memset_disallowed, strcpy_disallowed, stpcpy_disallowed;\nextern volatile int strncpy_disallowed, stpncpy_disallowed, strcat_disallowed;\nextern volatile int strncat_disallowed, sprintf_disallowed, vsprintf_disallowed;\nextern volatile int snprintf_disallowed, vsnprintf_disallowed;\n\n/* A storage class that ensures that declarations bind locally.  We want\n   to test non-static declarations where we know it is safe to do so.  */\n#if __PIC__ && !__PIE__\n#define LOCAL static\n#else\n#define LOCAL\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1-lib.c",
    "content": "extern int inside_main;\nextern void abort (void);\n#ifdef __OPTIMIZE__\n#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0)\n#else\n#define ABORT_INSIDE_MAIN do { } while (0)\n#endif\n\nstatic float _Complex\nconjf (float _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return ~z;\n}\n\nstatic double _Complex\nconj (double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return ~z;\n}\n\nstatic long double _Complex\nconjl (long double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return ~z;\n}\n\nstatic float\ncrealf (float _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __real__ z;\n}\n\nstatic double\ncreal (double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __real__ z;\n}\n\nstatic long double\ncreall (long double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __real__ z;\n}\n\nstatic float\ncimagf (float _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __imag__ z;\n}\n\nstatic double\ncimag (double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __imag__ z;\n}\n\nstatic long double\ncimagl (long double _Complex z)\n{\n  ABORT_INSIDE_MAIN;\n  return __imag__ z;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/complex-1.c",
    "content": "/* Test for builtin conj, creal, cimag.  */\n/* Origin: Joseph Myers <jsm28@cam.ac.uk> */\n\nextern float _Complex conjf (float _Complex);\nextern double _Complex conj (double _Complex);\nextern long double _Complex conjl (long double _Complex);\n\nextern float crealf (float _Complex);\nextern double creal (double _Complex);\nextern long double creall (long double _Complex);\n\nextern float cimagf (float _Complex);\nextern double cimag (double _Complex);\nextern long double cimagl (long double _Complex);\n\nextern void abort (void);\nextern void link_error (void);\n\nvoid\nmain_test (void)\n{\n  /* For each type, test both runtime and compile time (constant folding)\n     optimization.  */\n  volatile float _Complex fc = 1.0F + 2.0iF;\n  volatile double _Complex dc = 1.0 + 2.0i;\n  volatile long double _Complex ldc = 1.0L + 2.0iL;\n  /* Test floats.  */\n  if (conjf (fc) != 1.0F - 2.0iF)\n    abort ();\n  if (__builtin_conjf (fc) != 1.0F - 2.0iF)\n    abort ();\n  if (conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)\n    link_error ();\n  if (__builtin_conjf (1.0F + 2.0iF) != 1.0F - 2.0iF)\n    link_error ();\n  if (crealf (fc) != 1.0F)\n    abort ();\n  if (__builtin_crealf (fc) != 1.0F)\n    abort ();\n  if (crealf (1.0F + 2.0iF) != 1.0F)\n    link_error ();\n  if (__builtin_crealf (1.0F + 2.0iF) != 1.0F)\n    link_error ();\n  if (cimagf (fc) != 2.0F)\n    abort ();\n  if (__builtin_cimagf (fc) != 2.0F)\n    abort ();\n  if (cimagf (1.0F + 2.0iF) != 2.0F)\n    link_error ();\n  if (__builtin_cimagf (1.0F + 2.0iF) != 2.0F)\n    link_error ();\n  /* Test doubles.  */\n  if (conj (dc) != 1.0 - 2.0i)\n    abort ();\n  if (__builtin_conj (dc) != 1.0 - 2.0i)\n    abort ();\n  if (conj (1.0 + 2.0i) != 1.0 - 2.0i)\n    link_error ();\n  if (__builtin_conj (1.0 + 2.0i) != 1.0 - 2.0i)\n    link_error ();\n  if (creal (dc) != 1.0)\n    abort ();\n  if (__builtin_creal (dc) != 1.0)\n    abort ();\n  if (creal (1.0 + 2.0i) != 1.0)\n    link_error ();\n  if (__builtin_creal (1.0 + 2.0i) != 1.0)\n    link_error ();\n  if (cimag (dc) != 2.0)\n    abort ();\n  if (__builtin_cimag (dc) != 2.0)\n    abort ();\n  if (cimag (1.0 + 2.0i) != 2.0)\n    link_error ();\n  if (__builtin_cimag (1.0 + 2.0i) != 2.0)\n    link_error ();\n  /* Test long doubles.  */\n  if (conjl (ldc) != 1.0L - 2.0iL)\n    abort ();\n  if (__builtin_conjl (ldc) != 1.0L - 2.0iL)\n    abort ();\n  if (conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)\n    link_error ();\n  if (__builtin_conjl (1.0L + 2.0iL) != 1.0L - 2.0iL)\n    link_error ();\n  if (creall (ldc) != 1.0L)\n    abort ();\n  if (__builtin_creall (ldc) != 1.0L)\n    abort ();\n  if (creall (1.0L + 2.0iL) != 1.0L)\n    link_error ();\n  if (__builtin_creall (1.0L + 2.0iL) != 1.0L)\n    link_error ();\n  if (cimagl (ldc) != 2.0L)\n    abort ();\n  if (__builtin_cimagl (ldc) != 2.0L)\n    abort ();\n  if (cimagl (1.0L + 2.0iL) != 2.0L)\n    link_error ();\n  if (__builtin_cimagl (1.0L + 2.0iL) != 2.0L)\n    link_error ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf-lib.c",
    "content": "#include \"lib/fprintf.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf.c",
    "content": "/* Copyright (C) 2001  Free Software Foundation.\n\n   Ensure all expected transformations of builtin fprintf occur and\n   that we honor side effects in the arguments.\n\n   Written by Kaveh R. Ghazi, 1/7/2001.  */\n\n#include <stdio.h>\nextern int fprintf_unlocked (FILE *, const char *, ...);\nextern void abort(void);\n\nvoid\nmain_test (void)\n{\n  FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;\n  const char *const s1 = \"hello world\";\n  const char *const s2[] = { s1, 0 }, *const*s3;\n  \n  fprintf (*s_ptr, \"\");\n  fprintf (*s_ptr, \"%s\", \"\");\n  fprintf (*s_ptr, \"%s\", \"hello\");\n  fprintf (*s_ptr, \"%s\", \"\\n\");\n  fprintf (*s_ptr, \"%s\", *s2);\n  s3 = s2;\n  fprintf (*s_ptr, \"%s\", *s3++);\n  if (s3 != s2+1 || *s3 != 0)\n    abort();\n  s3 = s2;\n  fprintf (*s_ptr++, \"%s\", *s3++);\n  if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n  \n  s_ptr = s_array;\n  fprintf (*s_ptr, \"%c\", '\\n');\n  fprintf (*s_ptr, \"%c\", **s2);\n  s3 = s2;\n  fprintf (*s_ptr, \"%c\", **s3++);\n  if (s3 != s2+1 || *s3 != 0)\n    abort();\n  s3 = s2;\n  fprintf (*s_ptr++, \"%c\", **s3++);\n  if (s3 != s2+1 || *s3 != 0 || s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n  \n  s_ptr = s_array;\n  fprintf (*s_ptr++, \"hello world\");\n  if (s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n  s_ptr = s_array;\n  fprintf (*s_ptr, \"\\n\");\n    \n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  __builtin_fprintf (*s_ptr, \"%s\", \"hello world\\n\");\n  /* Check the unlocked style, these evaluate to nothing to avoid\n     problems on systems without the unlocked functions.  */\n  fprintf_unlocked (*s_ptr, \"\");\n  __builtin_fprintf_unlocked (*s_ptr, \"\");\n  fprintf_unlocked (*s_ptr, \"%s\", \"\");\n  __builtin_fprintf_unlocked (*s_ptr, \"%s\", \"\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fprintf.x",
    "content": "load_lib target-supports.exp\n\nif { [check_effective_target_freestanding] } {\n        return 1; \n}\n\nreturn 0;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fputs-lib.c",
    "content": "#include <stdio.h>\n#include <stddef.h>\nextern void abort (void);\nextern int inside_main;\nextern size_t strlen(const char *);\nint\nfputs(const char *string, FILE *stream)\n{\n  size_t n = strlen(string);\n  size_t r;\n#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__\n  if (inside_main)\n    abort();\n#endif\n  r = fwrite (string, 1, n, stream);\n  return n > r ? EOF : 0;\n}\n\n/* Locking stdio doesn't matter for the purposes of this test.  */\nint\nfputs_unlocked(const char *string, FILE *stream)\n{\n  return fputs (string, stream);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.c",
    "content": "/* Copyright (C) 2000, 2001  Free Software Foundation.\n\n   Ensure all expected transformations of builtin fputs occur and that\n   we honor side effects in the stream argument.\n\n   Written by Kaveh R. Ghazi, 10/30/2000.  */\n\n#include <stdio.h>\nextern void abort(void);\n\nint i;\n\nvoid\nmain_test(void)\n{\n  FILE *s_array[] = {stdout, NULL}, **s_ptr = s_array;\n  const char *const s1 = \"hello world\";\n  \n  fputs (\"\", *s_ptr);\n  fputs (\"\\n\", *s_ptr);\n  fputs (\"bye\", *s_ptr);\n  fputs (s1, *s_ptr);\n  fputs (s1+5, *s_ptr);\n  fputs (s1+10, *s_ptr);\n  fputs (s1+11, *s_ptr);\n  \n  /* Check side-effects when transforming fputs -> NOP.  */\n  fputs (\"\", *s_ptr++);\n  if (s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n\n  /* Check side-effects when transforming fputs -> fputc.  */\n  s_ptr = s_array;\n  fputs (\"\\n\", *s_ptr++);\n  if (s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n\n  /* Check side-effects when transforming fputs -> fwrite.  */\n  s_ptr = s_array;\n  fputs (\"hello\\n\", *s_ptr++);\n  if (s_ptr != s_array+1 || *s_ptr != 0)\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  s_ptr = s_array;\n  __builtin_fputs (\"\", *s_ptr);\n  /* These builtin stubs are called by __builtin_fputs, ensure their\n     prototypes are set correctly too.  */\n  __builtin_fputc ('\\n', *s_ptr);\n  __builtin_fwrite (\"hello\\n\", 1, 6, *s_ptr);\n  /* Check the unlocked style, these evaluate to nothing to avoid\n     problems on systems without the unlocked functions.  */\n  fputs_unlocked (\"\", *s_ptr);\n  __builtin_fputs_unlocked (\"\", *s_ptr);\n\n  /* Check side-effects in conditional expression.  */\n  s_ptr = s_array;\n  fputs (i++ ? \"f\" : \"x\", *s_ptr++);\n  if (s_ptr != s_array+1 || *s_ptr != 0 || i != 1)\n    abort();\n  fputs (--i ? \"\\n\" : \"\\n\", *--s_ptr);\n  if (s_ptr != s_array || i != 0)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/fputs.x",
    "content": "load_lib target-supports.exp\n\nif { [check_effective_target_freestanding] } {\n        return 1; \n}\n\nreturn 0;\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/abs.c",
    "content": "extern int inside_main;\nextern void abort (void);\n#ifdef __OPTIMIZE__\n#define ABORT_INSIDE_MAIN do { if (inside_main) abort (); } while (0)\n#else\n#define ABORT_INSIDE_MAIN do { } while (0)\n#endif\n\ntypedef __INTMAX_TYPE__ intmax_t;\n\n__attribute__ ((__noinline__))\nint\nabs (int x)\n{\n  ABORT_INSIDE_MAIN;\n  return x < 0 ? -x : x;\n}\n\n__attribute__ ((__noinline__))\nlong\nlabs (long x)\n{\n  ABORT_INSIDE_MAIN;\n  return x < 0 ? -x : x;\n}\n\n__attribute__ ((__noinline__))\nlong long\nllabs (long long x)\n{\n  ABORT_INSIDE_MAIN;\n  return x < 0 ? -x : x;\n}\n\n__attribute__ ((__noinline__))\nintmax_t\nimaxabs (intmax_t x)\n{\n  ABORT_INSIDE_MAIN;\n  return x < 0 ? -x : x;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/bfill.c",
    "content": "extern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid\nbfill (void *s, __SIZE_TYPE__ n, int ch)\n{\n  char *p;\n\n  for (p = s; n-- > 0; p++)\n    *p = ch;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/bzero.c",
    "content": "extern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid\nbzero (void *s, __SIZE_TYPE__ n)\n{\n  char *p;\n\n  for (p = s; n-- > 0; p++)\n    *p = 0;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/chk.c",
    "content": "#include <stdarg.h>\n#ifdef __unix__\n#include <sys/types.h>\n#endif\n\nextern void abort (void);\n\nextern int inside_main;\nvoid *chk_fail_buf[256] __attribute__((aligned (16)));\nvolatile int chk_fail_allowed, chk_calls;\nvolatile int memcpy_disallowed, mempcpy_disallowed, memmove_disallowed;\nvolatile int memset_disallowed, strcpy_disallowed, stpcpy_disallowed;\nvolatile int strncpy_disallowed, stpncpy_disallowed, strcat_disallowed;\nvolatile int strncat_disallowed, sprintf_disallowed, vsprintf_disallowed;\nvolatile int snprintf_disallowed, vsnprintf_disallowed;\nextern __SIZE_TYPE__ strlen (const char *);\nextern int vsprintf (char *, const char *, va_list);\n\nvoid __attribute__((noreturn))\n__chk_fail (void)\n{\n  if (chk_fail_allowed)\n    __builtin_longjmp (chk_fail_buf, 1);\n  abort ();\n}\n\nvoid *\nmemcpy (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  const char *srcp;\n  char *dstp;\n\n#ifdef __OPTIMIZE__\n  if (memcpy_disallowed && inside_main)\n    abort ();\n#endif\n\n  srcp = src;\n  dstp = dst;\n  while (n-- != 0)\n    *dstp++ = *srcp++;\n\n  return dst;\n}\n\nvoid *\n__memcpy_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into memcpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return memcpy (dst, src, n);\n}\n\nvoid *\nmempcpy (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  const char *srcp;\n  char *dstp;\n\n#ifdef __OPTIMIZE__\n  if (mempcpy_disallowed && inside_main)\n    abort ();\n#endif\n\n  srcp = src;\n  dstp = dst;\n  while (n-- != 0)\n    *dstp++ = *srcp++;\n\n  return dstp;\n}\n\nvoid *\n__mempcpy_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into mempcpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return mempcpy (dst, src, n);\n}\n\nvoid *\nmemmove (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  const char *srcp;\n  char *dstp;\n\n#ifdef __OPTIMIZE__\n  if (memmove_disallowed && inside_main)\n    abort ();\n#endif\n\n  srcp = src;\n  dstp = dst;\n  if (srcp < dstp)\n    while (n-- != 0)\n      dstp[n] = srcp[n];\n  else\n    while (n-- != 0)\n      *dstp++ = *srcp++;\n\n  return dst;\n}\n\nvoid *\n__memmove_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into memmove.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return memmove (dst, src, n);\n}\n\nvoid *\nmemset (void *dst, int c, __SIZE_TYPE__ n)\n{\n  while (n-- != 0)\n    n[(char *) dst] = c;\n\n  /* Single-byte memsets should be done inline when optimisation\n     is enabled.  Do this after the copy in case we're being called to\n     initialize bss.  */\n#ifdef __OPTIMIZE__\n  if (memset_disallowed && inside_main && n < 2)\n    abort ();\n#endif\n\n  return dst;\n}\n\nvoid *\n__memset_chk (void *dst, int c, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into memset.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return memset (dst, c, n);\n}\n\nchar *\nstrcpy (char *d, const char *s)\n{\n  char *r = d;\n#ifdef __OPTIMIZE__\n  if (strcpy_disallowed && inside_main)\n    abort ();\n#endif\n  while ((*d++ = *s++));\n  return r;\n}\n\nchar *\n__strcpy_chk (char *d, const char *s, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into strcpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (strlen (s) >= size)\n    __chk_fail ();\n  return strcpy (d, s);\n}\n\nchar *\nstpcpy (char *dst, const char *src)\n{\n#ifdef __OPTIMIZE__\n  if (stpcpy_disallowed && inside_main)\n    abort ();\n#endif\n\n  while (*src != 0)\n    *dst++ = *src++;\n\n  *dst = 0;\n  return dst;\n}\n\nchar *\n__stpcpy_chk (char *d, const char *s, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into stpcpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (strlen (s) >= size)\n    __chk_fail ();\n  return stpcpy (d, s);\n}\n\nchar *\nstpncpy (char *dst, const char *src, __SIZE_TYPE__ n)\n{\n#ifdef __OPTIMIZE__\n  if (stpncpy_disallowed && inside_main)\n    abort ();\n#endif\n\n  for (; *src && n; n--)\n    *dst++ = *src++;\n\n  char *ret = dst;\n\n  while (n--)\n    *dst++ = 0;\n\n  return ret;\n}\n\n\nchar *\n__stpncpy_chk (char *s1, const char *s2, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into stpncpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return stpncpy (s1, s2, n);\n}\n\nchar *\nstrncpy (char *s1, const char *s2, __SIZE_TYPE__ n)\n{\n  char *dest = s1;\n#ifdef __OPTIMIZE__\n  if (strncpy_disallowed && inside_main)\n    abort();\n#endif\n  for (; *s2 && n; n--)\n    *s1++ = *s2++;\n  while (n--)\n    *s1++ = 0;\n  return dest;\n}\n\nchar *\n__strncpy_chk (char *s1, const char *s2, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into strncpy.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (n > size)\n    __chk_fail ();\n  return strncpy (s1, s2, n);\n}\n\nchar *\nstrcat (char *dst, const char *src)\n{\n  char *p = dst;\n  \n#ifdef __OPTIMIZE__\n  if (strcat_disallowed && inside_main)\n    abort ();\n#endif\n\n  while (*p)\n    p++;\n  while ((*p++ = *src++))\n    ;\n  return dst;\n}\n\nchar *\n__strcat_chk (char *d, const char *s, __SIZE_TYPE__ size)\n{\n  /* If size is -1, GCC should always optimize the call into strcat.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  if (strlen (d) + strlen (s) >= size)\n    __chk_fail ();\n  return strcat (d, s);\n}\n\nchar *\nstrncat (char *s1, const char *s2, __SIZE_TYPE__ n)\n{\n  char *dest = s1;\n  char c;\n#ifdef __OPTIMIZE__\n  if (strncat_disallowed && inside_main)\n    abort();\n#endif\n  while (*s1) s1++;\n  c = '\\0';\n  while (n > 0)\n    {\n      c = *s2++;\n      *s1++ = c;\n      if (c == '\\0')\n\treturn dest;\n      n--;\n    }\n  if (c != '\\0')\n    *s1 = '\\0';\n  return dest;\n}\n\nchar *\n__strncat_chk (char *d, const char *s, __SIZE_TYPE__ n, __SIZE_TYPE__ size)\n{\n  __SIZE_TYPE__ len = strlen (d), n1 = n;\n  const char *s1 = s;\n\n  /* If size is -1, GCC should always optimize the call into strncat.  */\n  if (size == (__SIZE_TYPE__) -1)\n    abort ();\n  ++chk_calls;\n  while (len < size && n1 > 0)\n    {\n      if (*s1++ == '\\0')\n\tbreak;\n      ++len;\n      --n1;\n    }\n\n  if (len >= size)\n    __chk_fail ();\n  return strncat (d, s, n);\n}\n\n/* No chk test in GCC testsuite needs more bytes than this.\n   As we can't expect vsnprintf to be available on the target,\n   assume 4096 bytes is enough.  */\nstatic char chk_sprintf_buf[4096];\n\nint\n__sprintf_chk (char *str, int flag, __SIZE_TYPE__ size, const char *fmt, ...)\n{\n  int ret;\n  va_list ap;\n\n  /* If size is -1 and flag 0, GCC should always optimize the call into\n     sprintf.  */\n  if (size == (__SIZE_TYPE__) -1 && flag == 0)\n    abort ();\n  ++chk_calls;\n#ifdef __OPTIMIZE__\n  if (sprintf_disallowed && inside_main)\n    abort();\n#endif\n  va_start (ap, fmt);\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  va_end (ap);\n  if (ret >= 0)\n    {\n      if (ret >= size)\n\t__chk_fail ();\n      memcpy (str, chk_sprintf_buf, ret + 1);\n    }\n  return ret;\n}\n\nint\n__vsprintf_chk (char *str, int flag, __SIZE_TYPE__ size, const char *fmt,\n\t\tva_list ap)\n{\n  int ret;\n\n  /* If size is -1 and flag 0, GCC should always optimize the call into\n     vsprintf.  */\n  if (size == (__SIZE_TYPE__) -1 && flag == 0)\n    abort ();\n  ++chk_calls;\n#ifdef __OPTIMIZE__\n  if (vsprintf_disallowed && inside_main)\n    abort();\n#endif\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  if (ret >= 0)\n    {\n      if (ret >= size)\n\t__chk_fail ();\n      memcpy (str, chk_sprintf_buf, ret + 1);\n    }\n  return ret;\n}\n\nint\n__snprintf_chk (char *str, __SIZE_TYPE__ len, int flag, __SIZE_TYPE__ size,\n\t\tconst char *fmt, ...)\n{\n  int ret;\n  va_list ap;\n\n  /* If size is -1 and flag 0, GCC should always optimize the call into\n     snprintf.  */\n  if (size == (__SIZE_TYPE__) -1 && flag == 0)\n    abort ();\n  ++chk_calls;\n  if (size < len)\n    __chk_fail ();\n#ifdef __OPTIMIZE__\n  if (snprintf_disallowed && inside_main)\n    abort();\n#endif\n  va_start (ap, fmt);\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  va_end (ap);\n  if (ret >= 0)\n    {\n      if (ret < len)\n\tmemcpy (str, chk_sprintf_buf, ret + 1);\n      else\n\t{\n\t  memcpy (str, chk_sprintf_buf, len - 1);\n\t  str[len - 1] = '\\0';\n\t}\n    }\n  return ret;\n}\n\nint\n__vsnprintf_chk (char *str, __SIZE_TYPE__ len, int flag, __SIZE_TYPE__ size,\n\t\t const char *fmt, va_list ap)\n{\n  int ret;\n\n  /* If size is -1 and flag 0, GCC should always optimize the call into\n     vsnprintf.  */\n  if (size == (__SIZE_TYPE__) -1 && flag == 0)\n    abort ();\n  ++chk_calls;\n  if (size < len)\n    __chk_fail ();\n#ifdef __OPTIMIZE__\n  if (vsnprintf_disallowed && inside_main)\n    abort();\n#endif\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  if (ret >= 0)\n    {\n      if (ret < len)\n\tmemcpy (str, chk_sprintf_buf, ret + 1);\n      else\n\t{\n\t  memcpy (str, chk_sprintf_buf, len - 1);\n\t  str[len - 1] = '\\0';\n\t}\n    }\n  return ret;\n}\n\nint\nsnprintf (char *str, __SIZE_TYPE__ len, const char *fmt, ...)\n{\n  int ret;\n  va_list ap;\n\n#ifdef __OPTIMIZE__\n  if (snprintf_disallowed && inside_main)\n    abort();\n#endif\n  va_start (ap, fmt);\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  va_end (ap);\n  if (ret >= 0)\n    {\n      if (ret < len)\n\tmemcpy (str, chk_sprintf_buf, ret + 1);\n      else if (len)\n\t{\n\t  memcpy (str, chk_sprintf_buf, len - 1);\n\t  str[len - 1] = '\\0';\n\t}\n    }\n  return ret;\n}\n\n/* uClibc's vsprintf calls vsnprintf.  */\n#ifndef __UCLIBC__\nint\nvsnprintf (char *str, __SIZE_TYPE__ len, const char *fmt, va_list ap)\n{\n  int ret;\n\n#ifdef __OPTIMIZE__\n  if (vsnprintf_disallowed && inside_main)\n    abort();\n#endif\n  ret = vsprintf (chk_sprintf_buf, fmt, ap);\n  if (ret >= 0)\n    {\n      if (ret < len)\n\tmemcpy (str, chk_sprintf_buf, ret + 1);\n      else if (len)\n\t{\n\t  memcpy (str, chk_sprintf_buf, len - 1);\n\t  str[len - 1] = '\\0';\n\t}\n    }\n  return ret;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/fprintf.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\nextern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nint\nfprintf (FILE *fp, const char *string, ...)\n{\n  va_list ap;\n  int r;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  va_start (ap, string);\n  r = vfprintf (fp, string, ap);\n  va_end (ap);\n  return r;\n}\n\n/* Locking stdio doesn't matter for the purposes of this test.  */\n__attribute__ ((__noinline__))\nint\nfprintf_unlocked (FILE *fp, const char *string, ...)\n{\n  va_list ap;\n  int r;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  va_start (ap, string);\n  r = vfprintf (fp, string, ap);\n  va_end (ap);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c",
    "content": "extern void abort(void);\nextern void main_test (void);\nextern void abort (void);\nint inside_main;\n\nint\nmain ()\n{\n  inside_main = 1;\n  main_test ();\n  inside_main = 0;\n  return 0;\n}\n\n/* When optimizing, all the constant cases should have been\n   constant folded, so no calls to link_error should remain.\n   In any case, link_error should not be called.  */\n\n#ifndef __OPTIMIZE__\nvoid\nlink_error (void)\n{\n  abort ();\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/memchr.c",
    "content": "extern void abort(void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid *\nmemchr (const void *s, int c, __SIZE_TYPE__ n)\n{\n  const unsigned char uc = c;\n  const unsigned char *sp;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  sp = s;\n  for (; n != 0; ++sp, --n)\n    if (*sp == uc)\n      return (void *) sp;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/memcmp.c",
    "content": "extern void abort(void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nint\nmemcmp (const void *s1, const void *s2, __SIZE_TYPE__ len)\n{\n  const unsigned char *sp1, *sp2;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  sp1 = s1;\n  sp2 = s2;\n  while (len != 0 && *sp1 == *sp2)\n    sp1++, sp2++, len--;\n\n  if (len == 0)\n    return 0;\n  return *sp1 - *sp2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/memmove.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid *\nmemmove (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  char *dstp;\n  const char *srcp;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  srcp = src;\n  dstp = dst;\n  if (srcp < dstp)\n    while (n-- != 0)\n      dstp[n] = srcp[n];\n  else\n    while (n-- != 0)\n      *dstp++ = *srcp++;\n\n  return dst;\n}\n\nvoid\nbcopy (const void *src, void *dst, __SIZE_TYPE__ n)\n{\n  memmove (dst, src, n);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/mempcpy.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid *\nmempcpy (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  const char *srcp;\n  char *dstp;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  srcp = src;\n  dstp = dst;\n  while (n-- != 0)\n    *dstp++ = *srcp++;\n\n  return dstp;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/memset.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nvoid *\nmemset (void *dst, int c, __SIZE_TYPE__ n)\n{\n  while (n-- != 0)\n    n[(char *) dst] = c;\n\n  /* Single-byte memsets should be done inline when optimisation\n     is enabled.  Do this after the copy in case we're being called to\n     initialize bss.  */\n#ifdef __OPTIMIZE__\n  if (inside_main && n < 2)\n    abort ();\n#endif\n\n  return dst;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/printf.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\nextern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nint\nprintf (const char *string, ...)\n{\n  va_list ap;\n  int r;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  va_start (ap, string);\n  r = vprintf (string, ap);\n  va_end (ap);\n  return r;\n}\n\n\n/* Locking stdio doesn't matter for the purposes of this test.  */\n__attribute__ ((__noinline__))\nint\nprintf_unlocked (const char *string, ...)\n{\n  va_list ap;\n  int r;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  va_start (ap, string);\n  r = vprintf (string, ap);\n  va_end (ap);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/sprintf.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\nextern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nint\n(sprintf) (char *buf, const char *fmt, ...)\n{\n  va_list ap;\n  int r;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n  va_start (ap, fmt);\n  r = vsprintf (buf, fmt, ap);\n  va_end (ap);\n  return r;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/stpcpy.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstpcpy (char *dst, const char *src)\n{\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  while (*src != 0)\n    *dst++ = *src++;\n\n  *dst = 0;\n  return dst;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcat.c",
    "content": "extern int inside_main;\nextern void abort(void);\n\n__attribute__ ((__noinline__))\nchar *\nstrcat (char *dst, const char *src)\n{\n  char *p = dst;\n  \n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  while (*p)\n    p++;\n  while ((*p++ = *src++))\n    ;\n  return dst;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strchr.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstrchr (const char *s, int c)\n{\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  for (;;)\n    {\n      if (*s == c)\n\treturn (char *) s;\n      if (*s == 0)\n\treturn 0;\n      s++;\n    }\n}\n\n__attribute__ ((__noinline__))\nchar *\nindex (const char *s, int c)\n{\n  return strchr (s, c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcmp.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nint\nstrcmp (const char *s1, const char *s2)\n{\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  while (*s1 != 0 && *s1 == *s2)\n    s1++, s2++;\n\n  if (*s1 == 0 || *s2 == 0)\n    return (unsigned char) *s1 - (unsigned char) *s2;\n  return *s1 - *s2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcpy.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstrcpy (char *d, const char *s)\n{\n  char *r = d;\n#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__\n  if (inside_main)\n    abort ();\n#endif\n  while ((*d++ = *s++));\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strcspn.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\n__SIZE_TYPE__\nstrcspn (const char *s1, const char *s2)\n{\n  const char *p, *q;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n\n  for (p = s1; *p; p++)\n    for (q = s2; *q; q++)\n      if (*p == *q)\n\tgoto found;\n\n found:\n  return p - s1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strlen.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\n__SIZE_TYPE__\nstrlen (const char *s)\n{\n  __SIZE_TYPE__ i;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  i = 0;\n  while (s[i] != 0)\n    i++;\n\n  return i;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncat.c",
    "content": "extern void abort(void);\nextern int inside_main;\n\ntypedef __SIZE_TYPE__ size_t;\n\n__attribute__ ((__noinline__))\nchar *\nstrncat (char *s1, const char *s2, size_t n)\n{\n  char *dest = s1;\n  char c = '\\0';\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  while (*s1) s1++;\n  c = '\\0';\n  while (n > 0)\n    {\n      c = *s2++;\n      *s1++ = c;\n      if (c == '\\0')\n\treturn dest;\n      n--;\n    }\n  if (c != '\\0')\n    *s1 = '\\0';\n  return dest;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\ntypedef __SIZE_TYPE__ size_t;\n\n__attribute__ ((__noinline__))\nint\nstrncmp(const char *s1, const char *s2, size_t n)\n{\n  const unsigned char *u1 = (const unsigned char *)s1;\n  const unsigned char *u2 = (const unsigned char *)s2;\n  unsigned char c1, c2;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n\n  while (n > 0)\n    {\n      c1 = *u1++, c2 = *u2++;\n      if (c1 == '\\0' || c1 != c2)\n\treturn c1 - c2;\n      n--;\n    }\n  return c1 - c2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncpy.c",
    "content": "extern void abort(void);\nextern int inside_main;\n\ntypedef __SIZE_TYPE__ size_t;\n\n__attribute__ ((__noinline__))\nchar *\nstrncpy(char *s1, const char *s2, size_t n)\n{\n  char *dest = s1;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n  for (; *s2 && n; n--)\n    *s1++ = *s2++;\n  while (n--)\n    *s1++ = 0;\n  return dest;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strpbrk.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstrpbrk(const char *s1, const char *s2)\n{\n  const char *p;\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n  while (*s1)\n    {\n      for (p = s2; *p; p++)\n\tif (*s1 == *p)\n\t  return (char *)s1;\n      s1++;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strrchr.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstrrchr (const char *s, int c)\n{\n  __SIZE_TYPE__ i;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  i = 0;\n  while (s[i] != 0)\n    i++;\n\n  do\n    if (s[i] == c)\n      return (char *) s + i;\n  while (i-- != 0);\n\n  return 0;\n}\n\n__attribute__ ((__noinline__))\nchar *\nrindex (const char *s, int c)\n{\n  return strrchr (s, c);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strspn.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\n__SIZE_TYPE__\nstrcspn (const char *s1, const char *s2)\n{\n  const char *p, *q;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort();\n#endif\n\n  for (p = s1; *p; p++)\n    {\n      for (q = s2; *q; q++)\n\tif (*p == *q)\n\t  goto proceed;\n      break;\n\n    proceed:;\n    }\n  return p - s1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strstr.c",
    "content": "extern void abort (void);\nextern int inside_main;\n\n__attribute__ ((__noinline__))\nchar *\nstrstr(const char *s1, const char *s2)\n{\n  const char *p, *q;\n\n#ifdef __OPTIMIZE__\n  if (inside_main)\n    abort ();\n#endif\n\n  /* deliberately dumb algorithm */\n  for (; *s1; s1++)\n    {\n      p = s1, q = s2;\n      while (*q && *p)\n\t{\n\t  if (*q != *p)\n\t    break;\n\t  p++, q++;\n\t}\n      if (*q == 0)\n\treturn (char *)s1;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memchr-lib.c",
    "content": "#include \"lib/memchr.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memchr.c",
    "content": "/* Copyright (C) 2007  Free Software Foundation.\n\n   Ensure all expected transformations of builtin memchr occur\n   and perform correctly.\n\n   Written by Paolo Carlini, 10/5/2007.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memchr (const void *, int, size_t);\n\nvoid\nmain_test (void)\n{\n  const char* const foo1 = \"hello world\";\n\n  if (memchr (foo1, 'x', 11))\n    abort ();\n  if (memchr (foo1, 'o', 11) != foo1 + 4)\n    abort ();\n  if (memchr (foo1, 'w', 2))\n    abort ();\n  if (memchr (foo1 + 5, 'o', 6) != foo1 + 7)\n    abort ();\n  if (memchr (foo1, 'd', 11) != foo1 + 10)\n    abort ();\n  if (memchr (foo1, 'd', 10))\n    abort ();\n  if (memchr (foo1, '\\0', 11))\n    abort ();\n  if (memchr (foo1, '\\0', 12) != foo1 + 11)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_memchr (foo1, 'r', 11) != foo1 + 8)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memcmp-lib.c",
    "content": "#include \"lib/memcmp.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memcmp.c",
    "content": "/* Copyright (C) 2001  Free Software Foundation.\n\n   Ensure that short builtin memcmp are optimized and perform correctly.\n   On architectures with a cmpstrsi instruction, this test doesn't determine\n   which optimization is being performed, but it does check for correctness.\n\n   Written by Roger Sayle, 12/02/2001.\n   Additional tests by Roger Sayle after PR 3508, 12/26/2001.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern int memcmp (const void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern void link_error (void);\n\nvoid\nmain_test (void)\n{\n  char str[8];\n\n  strcpy (str, \"3141\");\n\n  if ( memcmp (str, str+2, 0) != 0 )\n    abort ();\n  if ( memcmp (str+1, str+3, 0) != 0 )\n    abort ();\n\n  if ( memcmp (str+1, str+3, 1) != 0 )\n    abort ();\n  if ( memcmp (str, str+2, 1) >= 0 )\n    abort ();\n  if ( memcmp (str+2, str, 1) <= 0 )\n    abort ();\n\n  if (memcmp (\"abcd\", \"efgh\", 4) >= 0)\n    link_error ();\n  if (memcmp (\"abcd\", \"abcd\", 4) != 0)\n    link_error ();\n  if (memcmp (\"efgh\", \"abcd\", 4) <= 0)\n    link_error ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memcpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memcpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __memcpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nvolatile char *s2 = \"defg\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile char *s3 = \"FGH\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  int i;\n\n#if defined __i386__ || defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  memcpy_disallowed = 1;\n#endif\n\n  /* All the memcpy calls in this routine except last have fixed length, so\n     object size checking should be done at compile time if optimizing.  */\n  chk_calls = 0;\n\n  if (memcpy (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n  if (memcpy (p + 16, \"VWX\" + 1, 2) != p + 16\n      || memcmp (p + 16, \"WX\\0\\0\", 5))\n    abort ();\n  if (memcpy (p + 1, \"\", 1) != p + 1 || memcmp (p, \"A\\0CDE\", 6))\n    abort ();\n  if (memcpy (p + 3, \"FGHI\", 4) != p + 3 || memcmp (p, \"A\\0CFGHI\", 8))\n    abort ();\n\n  i = 8;\n  memcpy (p + 20, \"qrstu\", 6);\n  memcpy (p + 25, \"QRSTU\", 6);\n  if (memcpy (p + 25 + 1, s1, 3) != p + 25 + 1\n      || memcmp (p + 25, \"Q123U\", 6))\n    abort ();\n\n  if (memcpy (memcpy (p, \"abcdEFG\", 4) + 4, \"efg\", 4) != p + 4\n      || memcmp (p, \"abcdefg\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_memcpy (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n\n  memcpy (p + 5, s3, 1);\n  if (memcmp (p, \"ABCDEFg\", 8))\n    abort ();\n\n  memcpy_disallowed = 0;\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n\n  memcpy (p + 6, s1 + 1, l1);\n  if (memcmp (p, \"ABCDEF2\", 8))\n    abort ();\n\n  /* The above memcpy copies into an object with known size, but\n     unknown length, so it should be a __memcpy_chk call.  */\n  if (chk_calls != 1)\n    abort ();\n}\n\nlong buf1[64];\nchar *buf2 = (char *) (buf1 + 32);\nlong buf5[20];\nchar buf7[20];\n\nvoid\n__attribute__((noinline))\ntest2_sub (long *buf3, char *buf4, char *buf6, int n)\n{\n  int i = 0;\n\n  /* All the memcpy/__builtin_memcpy/__builtin___memcpy_chk\n     calls in this routine are either fixed length, or have\n     side-effects in __builtin_object_size arguments, or\n     dst doesn't point into a known object.  */\n  chk_calls = 0;\n\n  /* These should probably be handled by store_by_pieces on most arches.  */\n  if (memcpy (buf1, \"ABCDEFGHI\", 9) != (char *) buf1\n      || memcmp (buf1, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (memcpy (buf1, \"abcdefghijklmnopq\", 17) != (char *) buf1\n      || memcmp (buf1, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memcpy (buf3, \"ABCDEF\", 6) != (char *) buf1\n      || memcmp (buf1, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memcpy (buf3, \"a\", 1) != (char *) buf1\n      || memcmp (buf1, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (memcpy ((char *) buf3 + 2, \"bcd\" + ++i, 2) != (char *) buf1 + 2\n      || memcmp (buf1, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 1)\n    abort ();\n\n  /* These should probably be handled by move_by_pieces on most arches.  */\n  if (memcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)\n      != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  if (memcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 14\n      || memcmp (buf1, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (memcpy (buf3, buf5, 8) != (char *) buf1\n      || memcmp (buf1, \"RSTUVWXYVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (memcpy (buf3, buf5, 17) != (char *) buf1\n      || memcmp (buf1, \"RSTUVWXYZ01234567\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf3, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or memcpy\n     call.  */\n\n  /* buf3 points to an unknown object, so __memcpy_chk should not be done.  */\n  if (memcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* This call has side-effects in dst, therefore no checking.  */\n  if (__builtin___memcpy_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,\n\t\t\t      n + 1, os ((char *) buf1 + ++i + 8))\n      != (char *) buf1 + 11\n      || memcmp (buf1, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (memcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 14\n      || memcmp (buf1, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  i = 1;\n\n  /* These might be handled by store_by_pieces.  */\n  if (memcpy (buf2, \"ABCDEFGHI\", 9) != buf2\n      || memcmp (buf2, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (memcpy (buf2, \"abcdefghijklmnopq\", 17) != buf2\n      || memcmp (buf2, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memcpy (buf4, \"ABCDEF\", 6) != buf2\n      || memcmp (buf2, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memcpy (buf4, \"a\", 1) != buf2\n      || memcmp (buf2, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (memcpy (buf4 + 2, \"bcd\" + i++, 2) != buf2 + 2\n      || memcmp (buf2, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  /* These might be handled by move_by_pieces.  */\n  if (memcpy (buf4 + 4, buf7, 6) != buf2 + 4\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___memcpy_chk (buf2 + i++ + 8, buf7 + 1, 1,\n\t\t\t      os (buf2 + i++ + 8))\n      != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (memcpy (buf4 + 14, buf6, 2) != buf2 + 14\n      || memcmp (buf2, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf4, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or memcpy\n     call.  */\n  if (memcpy (buf4 + 4, buf7, n + 6) != buf2 + 4\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___memcpy_chk (buf2 + i++ + 8, buf7 + 1, n + 1,\n\t\t\t      os (buf2 + i++ + 8))\n      != buf2 + 11\n      || memcmp (buf2, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 4)\n    abort ();\n\n  if (memcpy (buf4 + 14, buf6, n + 2) != buf2 + 14\n      || memcmp (buf2, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  long *x;\n  char *y;\n  int z;\n  __builtin_memcpy (buf5, \"RSTUVWXYZ0123456789\", 20);\n  __builtin_memcpy (buf7, \"RSTUVWXYZ0123456789\", 20);\n __asm (\"\" : \"=r\" (x) : \"0\" (buf1));\n __asm (\"\" : \"=r\" (y) : \"0\" (buf2));\n __asm (\"\" : \"=r\" (z) : \"0\" (0));\n  test2_sub (x, y, \"rstuvwxyz\", z);\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  size_t l;\n\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  memcpy (a.buf1 + 2, s3, l1);\n  memcpy (r, s3, l1 + 1);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memcpy (r, s2, l1 + 2);\n  memcpy (r + 2, s3, l1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  memcpy (r, s2, l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  memcpy (a.buf1 + 2, s3, 1);\n  memcpy (r, s3, 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memcpy (r, s2, 3);\n  r = buf3;\n  l = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = 1;\n    }\n  memcpy (r, s2, 1);\n  /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)\n     is 4, so this doesn't need runtime checking.  */\n  memcpy (&buf3[16], s2, l);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memcpy (&a.buf2[9], s2, l1 + 1);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memcpy (&a.buf2[7], s3, strlen (s3) + 1);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memcpy (&buf3[19], \"ab\", 2);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\n__attribute__((noinline))\ntest5 (void)\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\n\t  p = memcpy (u1.buf + off1, u2.buf + off2, len);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n}\n\n#define TESTSIZE 80\n\nchar srcb[TESTSIZE] __attribute__ ((aligned));\nchar dstb[TESTSIZE] __attribute__ ((aligned));\n\nvoid\n__attribute__((noinline))\ncheck (char *test, char *match, int n)\n{\n  if (memcmp (test, match, n))\n    abort ();\n}\n\n#define TN(n) \\\n{ memset (dstb, 0, n); memcpy (dstb, srcb, n); check (dstb, srcb, n); }\n#define T(n) \\\nTN (n) \\\nTN ((n) + 1) \\\nTN ((n) + 2) \\\nTN ((n) + 3)\n\nvoid\n__attribute__((noinline))\ntest6 (void)\n{\n  int i;\n\n  chk_calls = 0;\n\n  for (i = 0; i < sizeof (srcb); ++i)\n      srcb[i] = 'a' + i % 26;\n\n  T (0);\n  T (4);\n  T (8);\n  T (12);\n  T (16);\n  T (20);\n  T (24);\n  T (28);\n  T (32);\n  T (36);\n  T (40);\n  T (44);\n  T (48);\n  T (52);\n  T (56);\n  T (60);\n  T (64);\n  T (68);\n  T (72);\n  T (76);\n\n  /* All memcpy calls in this routine have constant arguments.  */\n  if (chk_calls)\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  test2 ();\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memcpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2-lib.c",
    "content": "#include \"lib/memmove.c\"\n#ifdef __vxworks\n/* The RTP C library uses bzero and bfill, both of which are defined\n   in the same file as bcopy.  */\n#include \"lib/bzero.c\"\n#include \"lib/bfill.c\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-2.c",
    "content": "/* Copyright (C) 2004  Free Software Foundation.\n\n   Check builtin memmove and bcopy optimization when length is 1.\n\n   Written by Jakub Jelinek, 9/14/2004.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memmove (void *, const void *, size_t);\nextern void bcopy (const void *, void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\nchar p[32] = \"abcdefg\";\nchar *q = p + 4;\n\nvoid\nmain_test (void)\n{\n  /* memmove with length 1 can be optimized into memcpy if it can be\n     expanded inline.  */\n  if (memmove (p + 2, p + 3, 1) != p + 2 || memcmp (p, \"abddefg\", 8))\n    abort ();\n  if (memmove (p + 1, p + 1, 1) != p + 1 || memcmp (p, \"abddefg\", 8))\n    abort ();\n  if (memmove (q, p + 4, 1) != p + 4 || memcmp (p, \"abddefg\", 8))\n    abort ();\n  bcopy (p + 5, p + 6, 1);\n  if (memcmp (p, \"abddeff\", 8))\n    abort ();\n  bcopy (p + 1, p + 1, 1);\n  if (memcmp (p, \"abddeff\", 8))\n    abort ();\n  bcopy (q, p + 4, 1);\n  if (memcmp (p, \"abddeff\", 8))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __memcpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern void *memmove (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\"; \nchar p[32] = \"\";\nvolatile char *s2 = \"defg\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile char *s3 = \"FGH\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  int i;\n\n#if defined __i386__ || defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  memmove_disallowed = 1;\n  memcpy_disallowed = 1;\n#endif\n\n  /* All the memmove calls in this routine except last have fixed length, so\n     object size checking should be done at compile time if optimizing.  */\n  chk_calls = 0;\n\n  if (memmove (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n  if (memmove (p + 16, \"VWX\" + 1, 2) != p + 16\n      || memcmp (p + 16, \"WX\\0\\0\", 5))\n    abort ();\n  if (memmove (p + 1, \"\", 1) != p + 1 || memcmp (p, \"A\\0CDE\", 6))\n    abort ();\n  if (memmove (p + 3, \"FGHI\", 4) != p + 3 || memcmp (p, \"A\\0CFGHI\", 8))\n    abort ();\n\n  i = 8;\n  memmove (p + 20, \"qrstu\", 6);\n  memmove (p + 25, \"QRSTU\", 6);\n  if (memmove (p + 25 + 1, s1, 3) != p + 25 + 1\n      || memcmp (p + 25, \"Q123U\", 6))\n    abort ();\n\n  if (memmove (memmove (p, \"abcdEFG\", 4) + 4, \"efg\", 4) != p + 4\n      || memcmp (p, \"abcdefg\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_memmove (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n\n  memmove (p + 5, s3, 1);\n  if (memcmp (p, \"ABCDEFg\", 8))\n    abort ();\n\n  memmove_disallowed = 0;\n  memcpy_disallowed = 0;\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n\n  memmove (p + 6, s1 + 1, l1);\n  if (memcmp (p, \"ABCDEF2\", 8))\n    abort ();\n\n  /* The above memmove copies into an object with known size, but\n     unknown length, so it should be a __memmove_chk call.  */\n  if (chk_calls != 1)\n    abort ();\n}\n\nlong buf1[64];\nchar *buf2 = (char *) (buf1 + 32);\nlong buf5[20];\nchar buf7[20];\n\nvoid\n__attribute__((noinline))\ntest2_sub (long *buf3, char *buf4, char *buf6, int n)\n{\n  int i = 0;\n\n  /* All the memmove/__builtin_memmove/__builtin___memmove_chk\n     calls in this routine are either fixed length, or have\n     side-effects in __builtin_object_size arguments, or\n     dst doesn't point into a known object.  */\n  chk_calls = 0;\n\n  /* These should probably be handled by store_by_pieces on most arches.  */\n  if (memmove (buf1, \"ABCDEFGHI\", 9) != (char *) buf1\n      || memcmp (buf1, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (memmove (buf1, \"abcdefghijklmnopq\", 17) != (char *) buf1\n      || memcmp (buf1, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memmove (buf3, \"ABCDEF\", 6) != (char *) buf1\n      || memcmp (buf1, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memmove (buf3, \"a\", 1) != (char *) buf1\n      || memcmp (buf1, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (memmove ((char *) buf3 + 2, \"bcd\" + ++i, 2) != (char *) buf1 + 2\n      || memcmp (buf1, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 1)\n    abort ();\n\n  /* These should probably be handled by move_by_pieces on most arches.  */\n  if (memmove ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memmove ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)\n      != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  if (memmove ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 14\n      || memcmp (buf1, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (memmove (buf3, buf5, 8) != (char *) buf1\n      || memcmp (buf1, \"RSTUVWXYVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (memmove (buf3, buf5, 17) != (char *) buf1\n      || memcmp (buf1, \"RSTUVWXYZ01234567\\0\", 19))\n    abort ();\n\n  __builtin_memmove (buf3, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or memmove\n     call.  */\n\n  /* buf3 points to an unknown object, so __memmove_chk should not be done.  */\n  if (memmove ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* This call has side-effects in dst, therefore no checking.  */\n  if (__builtin___memmove_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,\n\t\t\t       n + 1, os ((char *) buf1 + ++i + 8))\n      != (char *) buf1 + 11\n      || memcmp (buf1, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (memmove ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 14\n      || memcmp (buf1, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  i = 1;\n\n  /* These might be handled by store_by_pieces.  */\n  if (memmove (buf2, \"ABCDEFGHI\", 9) != buf2\n      || memcmp (buf2, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (memmove (buf2, \"abcdefghijklmnopq\", 17) != buf2\n      || memcmp (buf2, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memmove (buf4, \"ABCDEF\", 6) != buf2\n      || memcmp (buf2, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_memmove (buf4, \"a\", 1) != buf2\n      || memcmp (buf2, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (memmove (buf4 + 2, \"bcd\" + i++, 2) != buf2 + 2\n      || memcmp (buf2, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  /* These might be handled by move_by_pieces.  */\n  if (memmove (buf4 + 4, buf7, 6) != buf2 + 4\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___memmove_chk (buf2 + i++ + 8, buf7 + 1, 1,\n\t\t\t       os (buf2 + i++ + 8))\n      != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (memmove (buf4 + 14, buf6, 2) != buf2 + 14\n      || memcmp (buf2, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  __builtin_memmove (buf4, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or memmove\n     call.  */\n  if (memmove (buf4 + 4, buf7, n + 6) != buf2 + 4\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___memmove_chk (buf2 + i++ + 8, buf7 + 1, n + 1,\n\t\t\t       os (buf2 + i++ + 8))\n      != buf2 + 11\n      || memcmp (buf2, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 4)\n    abort ();\n\n  if (memmove (buf4 + 14, buf6, n + 2) != buf2 + 14\n      || memcmp (buf2, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  long *x;\n  char *y;\n  int z;\n  __builtin_memmove (buf5, \"RSTUVWXYZ0123456789\", 20);\n  __builtin_memmove (buf7, \"RSTUVWXYZ0123456789\", 20);\n __asm (\"\" : \"=r\" (x) : \"0\" (buf1));\n __asm (\"\" : \"=r\" (y) : \"0\" (buf2));\n __asm (\"\" : \"=r\" (z) : \"0\" (0));\n  test2_sub (x, y, \"rstuvwxyz\", z);\n}\n\nstatic const struct foo\n{\n  char *s;\n  double d;\n  long l;\n} foo[] =\n{\n  { \"hello world1\", 3.14159, 101L },\n  { \"hello world2\", 3.14159, 102L },\n  { \"hello world3\", 3.14159, 103L },\n  { \"hello world4\", 3.14159, 104L },\n  { \"hello world5\", 3.14159, 105L },\n  { \"hello world6\", 3.14159, 106L }\n};\n\nstatic const struct bar\n{\n  char *s;\n  const struct foo f[3];\n} bar[] =\n{\n  {\n    \"hello world10\",\n    {\n      { \"hello1\", 3.14159, 201L },\n      { \"hello2\", 3.14159, 202L },\n      { \"hello3\", 3.14159, 203L },\n    }\n  },\n  {\n    \"hello world11\",\n    {\n      { \"hello4\", 3.14159, 204L },\n      { \"hello5\", 3.14159, 205L },\n      { \"hello6\", 3.14159, 206L },\n    }\n  }\n};\n\nstatic const int baz[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };\n\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  const char *s;\n  struct foo f1[sizeof foo/sizeof*foo];\n  struct bar b1[sizeof bar/sizeof*bar];\n  int bz[sizeof baz/sizeof*baz];\n\n  /* All the memmove/__builtin_memmove calls in this routine have fixed\n     length.  */\n  chk_calls = 0;\n\n  /* All the *memmove calls below have src in read-only memory, so all\n     of them should be optimized into memcpy.  */\n  memmove_disallowed = 1;\n  if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))\n    abort ();\n  if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))\n    abort ();\n  memmove (bz, baz, sizeof (baz));\n  if (memcmp (bz, baz, sizeof (baz)))\n    abort ();\n\n  if (memmove (p, \"abcde\", 6) != p || memcmp (p, \"abcde\", 6))\n    abort ();\n  s = s1;\n  if (memmove (p + 2, ++s, 0) != p + 2 || memcmp (p, \"abcde\", 6) || s != s1 + 1)\n    abort ();\n  if (__builtin_memmove (p + 3, \"\", 1) != p + 3 || memcmp (p, \"abc\\0e\", 6))\n    abort ();\n  memmove (p + 2, \"fghijk\", 4);\n  if (memcmp (p, \"abfghi\", 7))\n    abort ();\n  s = s1 + 1;\n  memmove (p + 1, s++, 0);\n  if (memcmp (p, \"abfghi\", 7) || s != s1 + 2)\n    abort ();\n  __builtin_memmove (p + 4, \"ABCDE\", 1);\n  if (memcmp (p, \"abfgAi\", 7))\n    abort ();\n\n  /* memmove with length 1 can be optimized into memcpy if it can be\n     expanded inline.  */\n  if (memmove (p + 2, p + 3, 1) != p + 2)\n    abort ();\n  if (memcmp (p, \"abggAi\", 7))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  memmove_disallowed = 0;\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  size_t l;\n\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  memmove (a.buf1 + 2, s3, l1);\n  memmove (r, s3, l1 + 1);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memmove (r, s2, l1 + 2);\n  memmove (r + 2, s3, l1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  memmove (r, s2, l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  memmove (a.buf1 + 2, s3, 1);\n  memmove (r, s3, 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memmove (r, s2, 3);\n  r = buf3;\n  l = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = 1;\n    }\n  memmove (r, s2, 1);\n  /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)\n     is 4, so this doesn't need runtime checking.  */\n  memmove (&buf3[16], s2, l);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest5 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memmove (&a.buf2[9], s2, l1 + 1);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memmove (&a.buf2[7], s3, strlen (s3) + 1);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memmove (&buf3[19], \"ab\", 2);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\n__attribute__((noinline))\ntest6 (void)\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\n\t  p = memmove (u1.buf + off1, u2.buf + off2, len);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n}\n\n#define TESTSIZE 80\n\nchar srcb[TESTSIZE] __attribute__ ((aligned));\nchar dstb[TESTSIZE] __attribute__ ((aligned));\n\nvoid\n__attribute__((noinline))\ncheck (char *test, char *match, int n)\n{\n  if (memcmp (test, match, n))\n    abort ();\n}\n\n#define TN(n) \\\n{ memset (dstb, 0, n); memmove (dstb, srcb, n); check (dstb, srcb, n); }\n#define T(n) \\\nTN (n) \\\nTN ((n) + 1) \\\nTN ((n) + 2) \\\nTN ((n) + 3)\n\nvoid\n__attribute__((noinline))\ntest7 (void)\n{\n  int i;\n\n  chk_calls = 0;\n\n  for (i = 0; i < sizeof (srcb); ++i)\n      srcb[i] = 'a' + i % 26;\n\n  T (0);\n  T (4);\n  T (8);\n  T (12);\n  T (16);\n  T (20);\n  T (24);\n  T (28);\n  T (32);\n  T (36);\n  T (40);\n  T (44);\n  T (48);\n  T (52);\n  T (56);\n  T (60);\n  T (64);\n  T (68);\n  T (72);\n  T (76);\n\n  /* All memmove calls in this routine have constant arguments.  */\n  if (chk_calls)\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  test2 ();\n  __builtin_memset (p, '\\0', sizeof (p));\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n  test7 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test5 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove-lib.c",
    "content": "#include \"lib/memmove.c\"\n#ifdef __vxworks\n/* The RTP C library uses bzero and bfill, both of which are defined\n   in the same file as bcopy.  */\n#include \"lib/bzero.c\"\n#include \"lib/bfill.c\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memmove.c",
    "content": "/* Copyright (C) 2003, 2004  Free Software Foundation.\n\n   Ensure builtin memmove and bcopy perform correctly.\n\n   Written by Jakub Jelinek, 4/26/2003.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memmove (void *, const void *, size_t);\nextern void bcopy (const void *, void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\n\nstatic const struct foo\n{\n  char *s;\n  double d;\n  long l;\n} foo[] =\n{\n  { \"hello world1\", 3.14159, 101L },\n  { \"hello world2\", 3.14159, 102L },\n  { \"hello world3\", 3.14159, 103L },\n  { \"hello world4\", 3.14159, 104L },\n  { \"hello world5\", 3.14159, 105L },\n  { \"hello world6\", 3.14159, 106L }\n};\n\nstatic const struct bar\n{\n  char *s;\n  const struct foo f[3];\n} bar[] =\n{\n  {\n    \"hello world10\",\n    {\n      { \"hello1\", 3.14159, 201L },\n      { \"hello2\", 3.14159, 202L },\n      { \"hello3\", 3.14159, 203L },\n    }\n  },\n  {\n    \"hello world11\",\n    {\n      { \"hello4\", 3.14159, 204L },\n      { \"hello5\", 3.14159, 205L },\n      { \"hello6\", 3.14159, 206L },\n    }\n  }\n};\n\nstatic const int baz[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };\n\nvoid\nmain_test (void)\n{\n  const char *s;\n  struct foo f1[sizeof foo/sizeof*foo];\n  struct bar b1[sizeof bar/sizeof*bar];\n  int bz[sizeof baz/sizeof*baz];\n\n  if (memmove (f1, foo, sizeof (foo)) != f1 || memcmp (f1, foo, sizeof (foo)))\n    abort ();\n  if (memmove (b1, bar, sizeof (bar)) != b1 || memcmp (b1, bar, sizeof (bar)))\n    abort ();\n  bcopy (baz, bz, sizeof (baz));\n  if (memcmp (bz, baz, sizeof (baz)))\n    abort ();\n\n  if (memmove (p, \"abcde\", 6) != p || memcmp (p, \"abcde\", 6))\n    abort ();\n  s = s1;\n  if (memmove (p + 2, ++s, 0) != p + 2 || memcmp (p, \"abcde\", 6) || s != s1 + 1)\n    abort ();\n  if (__builtin_memmove (p + 3, \"\", 1) != p + 3 || memcmp (p, \"abc\\0e\", 6))\n    abort ();\n  bcopy (\"fghijk\", p + 2, 4);\n  if (memcmp (p, \"abfghi\", 7))\n    abort ();\n  s = s1 + 1;\n  bcopy (s++, p + 1, 0);\n  if (memcmp (p, \"abfghi\", 7) || s != s1 + 2)\n    abort ();\n  __builtin_bcopy (\"ABCDE\", p + 4, 1);\n  if (memcmp (p, \"abfgAi\", 7))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm-lib.c",
    "content": "extern void abort (void);\nextern int inside_main;\ntypedef __SIZE_TYPE__ size_t;\n\n#define TEST_ABORT if (inside_main) abort()\n\n/* LTO code is at the present to able to track that asm alias my_bcopy on builtin\n   actually refers to this function.  See PR47181. */\n__attribute__ ((used))\nvoid *\nmy_memcpy (void *d, const void *s, size_t n)\n{\n  char *dst = (char *) d;\n  const char *src = (const char *) s;\n  while (n--)\n    *dst++ = *src++;\n  return (char *) d;\n}\n\n/* LTO code is at the present to able to track that asm alias my_bcopy on builtin\n   actually refers to this function.  See PR47181. */\n__attribute__ ((used))\nvoid\nmy_bcopy (const void *s, void *d, size_t n)\n{\n  char *dst = (char *) d;\n  const char *src = (const char *) s;\n  if (src >= dst)\n    while (n--)\n      *dst++ = *src++;\n  else\n    {\n      dst += n;\n      src += n;\n      while (n--)\n        *--dst = *--src;\n    }\n}\n\n/* LTO code is at the present to able to track that asm alias my_bcopy on builtin\n   actually refers to this function.  See PR47181. */\n__attribute__ ((used))\nvoid *\nmy_memset (void *d, int c, size_t n)\n{\n  char *dst = (char *) d;\n  while (n--)\n    *dst++ = c;\n  return (char *) d;\n}\n\n/* LTO code is at the present to able to track that asm alias my_bcopy on builtin\n   actually refers to this function.  See PR47181. */\n__attribute__ ((used))\nvoid\nmy_bzero (void *d, size_t n)\n{\n  char *dst = (char *) d;\n  while (n--)\n    *dst++ = '\\0';\n}\n\nvoid *\nmemcpy (void *d, const void *s, size_t n)\n{\n  void *result = my_memcpy (d, s, n);\n  TEST_ABORT;\n  return result;\n}\n\nvoid\nbcopy (const void *s, void *d, size_t n)\n{\n  my_bcopy (s, d, n);\n  TEST_ABORT;\n}\n\nvoid *\nmemset (void *d, int c, size_t n)\n{\n  void *result = my_memset (d, c, n);\n  TEST_ABORT;\n  return result;\n}\n\nvoid\nbzero (void *d, size_t n)\n{\n  my_bzero (d, n);\n  TEST_ABORT;\n}\n\n#ifdef __vxworks\n/* The RTP C library uses bfill, which is defined in the same file as\n   bzero and bcopy.  */\n#include \"lib/bfill.c\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm.c",
    "content": "/* Copyright (C) 2003 Free Software Foundation.\n\n   Test memcpy and memset in presence of redirect.  */\n\n#define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n#define ASMNAME2(prefix, cname) STRING (prefix) cname\n#define STRING(x)    #x\n\ntypedef __SIZE_TYPE__ size_t;\nextern void abort (void);\nextern void *memcpy (void *, const void *, size_t)\n  __asm (ASMNAME (\"my_memcpy\"));\nextern void bcopy (const void *, void *, size_t)\n  __asm (ASMNAME (\"my_bcopy\"));\nextern void *memset (void *, int, size_t)\n  __asm (ASMNAME (\"my_memset\"));\nextern void bzero (void *, size_t)\n  __asm (ASMNAME (\"my_bzero\"));\nextern int memcmp (const void *, const void *, size_t);\n\nstruct A { char c[32]; } a = { \"foobar\" };\nchar x[64] = \"foobar\", y[64];\nint i = 39, j = 6, k = 4;\n\nextern int inside_main;\n\nvoid\nmain_test (void)\n{\n  struct A b = a;\n  struct A c = { { 'x' } };\n\n  inside_main = 1;\n  \n  if (memcmp (b.c, x, 32) || c.c[0] != 'x' || memcmp (c.c + 1, x + 32, 31))\n    abort ();\n  if (__builtin_memcpy (y, x, i) != y || memcmp (x, y, 64))\n    abort ();\n  if (memcpy (y + 6, x, j) != y + 6\n      || memcmp (x, y, 6) || memcmp (x, y + 6, 58))\n    abort ();\n  if (__builtin_memset (y + 2, 'X', k) != y + 2\n      || memcmp (y, \"foXXXXfoobar\", 13))\n    abort ();\n  bcopy (y + 1, y + 2, 6);\n  if (memcmp (y, \"fooXXXXfobar\", 13))\n    abort ();\n  __builtin_bzero (y + 4, 2);\n  if (memcmp (y, \"fooX\\0\\0Xfobar\", 13))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memops-asm.x",
    "content": "# Different translation units may have different user name overrides\n# and we do not preserve enough context to known which one we want.\n\nset torture_eval_before_compile {\n  if {[string match {*-flto*} \"$option\"]} {\n    continue\n  }\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2-lib.c",
    "content": "#include \"lib/mempcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-2.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Ensure that builtin mempcpy and stpcpy perform correctly.\n\n   Written by Jakub Jelinek, 21/05/2003.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern void *mempcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern int inside_main;\n\nlong buf1[64];\nchar *buf2 = (char *) (buf1 + 32);\nlong buf5[20];\nchar buf7[20];\n\nvoid\n__attribute__((noinline))\ntest (long *buf3, char *buf4, char *buf6, int n)\n{\n  int i = 0;\n\n  /* These should probably be handled by store_by_pieces on most arches.  */\n  if (mempcpy (buf1, \"ABCDEFGHI\", 9) != (char *) buf1 + 9\n      || memcmp (buf1, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (mempcpy (buf1, \"abcdefghijklmnopq\", 17) != (char *) buf1 + 17\n      || memcmp (buf1, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf3, \"ABCDEF\", 6) != (char *) buf1 + 6\n      || memcmp (buf1, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf3, \"a\", 1) != (char *) buf1 + 1\n      || memcmp (buf1, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 2, \"bcd\" + ++i, 2) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 1)\n    abort ();\n\n  /* These should probably be handled by move_by_pieces on most arches.  */\n  if (mempcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)\n      != (char *) buf1 + 11\n      || memcmp (buf1, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 16\n      || memcmp (buf1, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf3, buf5, 8) != (char *) buf1 + 8\n      || memcmp (buf1, \"RSTUVWXYVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf3, buf5, 17) != (char *) buf1 + 17\n      || memcmp (buf1, \"RSTUVWXYZ01234567\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf3, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or mempcpy\n     call.  */\n  if (mempcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, n + 1)\n      != (char *) buf1 + 12\n      || memcmp (buf1, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 16\n      || memcmp (buf1, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  i = 1;\n\n  /* These might be handled by store_by_pieces.  */\n  if (mempcpy (buf2, \"ABCDEFGHI\", 9) != buf2 + 9\n      || memcmp (buf2, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (mempcpy (buf2, \"abcdefghijklmnopq\", 17) != buf2 + 17\n      || memcmp (buf2, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf4, \"ABCDEF\", 6) != buf2 + 6\n      || memcmp (buf2, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf4, \"a\", 1) != buf2 + 1\n      || memcmp (buf2, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf4 + 2, \"bcd\" + i++, 2) != buf2 + 4\n      || memcmp (buf2, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  /* These might be handled by move_by_pieces.  */\n  if (mempcpy (buf4 + 4, buf7, 6) != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, 1)\n      != buf2 + 11\n      || memcmp (buf2, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (mempcpy (buf4 + 14, buf6, 2) != buf2 + 16\n      || memcmp (buf2, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf4, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or mempcpy\n     call.  */\n  if (mempcpy (buf4 + 4, buf7, n + 6) != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf2 + i++ + 8, buf7 + 1, n + 1)\n      != buf2 + 12\n      || memcmp (buf2, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 4)\n    abort ();\n\n  if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16\n      || memcmp (buf2, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n  /* All these tests are allowed to call mempcpy/stpcpy.  */\n  inside_main = 0;\n  __builtin_memcpy (buf5, \"RSTUVWXYZ0123456789\", 20);\n  __builtin_memcpy (buf7, \"RSTUVWXYZ0123456789\", 20);\n  test (buf1, buf2, \"rstuvwxyz\", 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __mempcpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern void *mempcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nvolatile char *s2 = \"defg\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile char *s3 = \"FGH\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile size_t l1 = 1; /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  int i;\n\n#if defined __i386__ || defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  mempcpy_disallowed = 1;\n#endif\n\n  /* All the mempcpy calls in this routine except last have fixed length, so\n     object size checking should be done at compile time if optimizing.  */\n  chk_calls = 0;\n\n  if (mempcpy (p, \"ABCDE\", 6) != p + 6 || memcmp (p, \"ABCDE\", 6))\n    abort ();\n  if (mempcpy (p + 16, \"VWX\" + 1, 2) != p + 16 + 2\n      || memcmp (p + 16, \"WX\\0\\0\", 5))\n    abort ();\n  if (mempcpy (p + 1, \"\", 1) != p + 1 + 1 || memcmp (p, \"A\\0CDE\", 6))\n    abort ();\n  if (mempcpy (p + 3, \"FGHI\", 4) != p + 3 + 4 || memcmp (p, \"A\\0CFGHI\", 8))\n    abort ();\n\n  i = 8;\n  memcpy (p + 20, \"qrstu\", 6);\n  memcpy (p + 25, \"QRSTU\", 6);\n  if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3)\n      || memcmp (p + 25, \"Q123U\", 6))\n    abort ();\n\n  if (mempcpy (mempcpy (p, \"abcdEFG\", 4), \"efg\", 4) != p + 8\n      || memcmp (p, \"abcdefg\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_mempcpy (p, \"ABCDE\", 6) != p + 6 || memcmp (p, \"ABCDE\", 6))\n    abort ();\n\n  /* If the result of mempcpy is ignored, gcc should use memcpy.\n     This should be optimized always, so disallow mempcpy calls.  */\n  mempcpy_disallowed = 1;\n  mempcpy (p + 5, s3, 1);\n  if (memcmp (p, \"ABCDEFg\", 8))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n\n  mempcpy (p + 6, s1 + 1, l1);\n  if (memcmp (p, \"ABCDEF2\", 8))\n    abort ();\n\n  /* The above mempcpy copies into an object with known size, but\n     unknown length and with result ignored, so it should be a\n     __memcpy_chk call.  */\n  if (chk_calls != 1)\n    abort ();\n\n  mempcpy_disallowed = 0;\n}\n\nlong buf1[64];\nchar *buf2 = (char *) (buf1 + 32);\nlong buf5[20];\nchar buf7[20];\n\nvoid\n__attribute__((noinline))\ntest2_sub (long *buf3, char *buf4, char *buf6, int n)\n{\n  int i = 0;\n\n  /* All the mempcpy/__builtin_mempcpy/__builtin___mempcpy_chk\n     calls in this routine are either fixed length, or have\n     side-effects in __builtin_object_size arguments, or\n     dst doesn't point into a known object.  */\n  chk_calls = 0;\n\n  /* These should probably be handled by store_by_pieces on most arches.  */\n  if (mempcpy (buf1, \"ABCDEFGHI\", 9) != (char *) buf1 + 9\n      || memcmp (buf1, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (mempcpy (buf1, \"abcdefghijklmnopq\", 17) != (char *) buf1 + 17\n      || memcmp (buf1, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf3, \"ABCDEF\", 6) != (char *) buf1 + 6\n      || memcmp (buf1, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf3, \"a\", 1) != (char *) buf1 + 1\n      || memcmp (buf1, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 2, \"bcd\" + ++i, 2) != (char *) buf1 + 4\n      || memcmp (buf1, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 1)\n    abort ();\n\n  /* These should probably be handled by move_by_pieces on most arches.  */\n  if (mempcpy ((char *) buf3 + 4, buf5, 6) != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy ((char *) buf1 + ++i + 8, (char *) buf5 + 1, 1)\n      != (char *) buf1 + 11\n      || memcmp (buf1, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 14, buf6, 2) != (char *) buf1 + 16\n      || memcmp (buf1, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf3, buf5, 8) != (char *) buf1 + 8\n      || memcmp (buf1, \"RSTUVWXYVWSlmnrsq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf3, buf5, 17) != (char *) buf1 + 17\n      || memcmp (buf1, \"RSTUVWXYZ01234567\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf3, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or mempcpy\n     call.  */\n\n  /* buf3 points to an unknown object, so __mempcpy_chk should not be done.  */\n  if (mempcpy ((char *) buf3 + 4, buf5, n + 6) != (char *) buf1 + 10\n      || memcmp (buf1, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* This call has side-effects in dst, therefore no checking.  */\n  if (__builtin___mempcpy_chk ((char *) buf1 + ++i + 8, (char *) buf5 + 1,\n\t\t\t       n + 1, os ((char *) buf1 + ++i + 8))\n      != (char *) buf1 + 12\n      || memcmp (buf1, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (mempcpy ((char *) buf3 + 14, buf6, n + 2) != (char *) buf1 + 16\n      || memcmp (buf1, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  i = 1;\n\n  /* These might be handled by store_by_pieces.  */\n  if (mempcpy (buf2, \"ABCDEFGHI\", 9) != buf2 + 9\n      || memcmp (buf2, \"ABCDEFGHI\\0\", 11))\n    abort ();\n\n  if (mempcpy (buf2, \"abcdefghijklmnopq\", 17) != buf2 + 17\n      || memcmp (buf2, \"abcdefghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf4, \"ABCDEF\", 6) != buf2 + 6\n      || memcmp (buf2, \"ABCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (__builtin_mempcpy (buf4, \"a\", 1) != buf2 + 1\n      || memcmp (buf2, \"aBCDEFghijklmnopq\\0\", 19))\n    abort ();\n\n  if (mempcpy (buf4 + 2, \"bcd\" + i++, 2) != buf2 + 4\n      || memcmp (buf2, \"aBcdEFghijklmnopq\\0\", 19)\n      || i != 2)\n    abort ();\n\n  /* These might be handled by move_by_pieces.  */\n  if (mempcpy (buf4 + 4, buf7, 6) != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___mempcpy_chk (buf2 + i++ + 8, buf7 + 1, 1,\n\t\t\t       os (buf2 + i++ + 8))\n      != buf2 + 11\n      || memcmp (buf2, \"aBcdRSTUVWSlmnopq\\0\", 19)\n      || i != 3)\n    abort ();\n\n  if (mempcpy (buf4 + 14, buf6, 2) != buf2 + 16\n      || memcmp (buf2, \"aBcdRSTUVWSlmnrsq\\0\", 19))\n    abort ();\n\n  __builtin_memcpy (buf4, \"aBcdEFghijklmnopq\\0\", 19);\n\n  /* These should be handled either by movmemendM or mempcpy\n     call.  */\n  if (mempcpy (buf4 + 4, buf7, n + 6) != buf2 + 10\n      || memcmp (buf2, \"aBcdRSTUVWklmnopq\\0\", 19))\n    abort ();\n\n  /* Side effect.  */\n  if (__builtin___mempcpy_chk (buf2 + i++ + 8, buf7 + 1,\n\t\t\t       n + 1, os (buf2 + i++ + 8))\n      != buf2 + 12\n      || memcmp (buf2, \"aBcdRSTUVWkSmnopq\\0\", 19)\n      || i != 4)\n    abort ();\n\n  if (mempcpy (buf4 + 14, buf6, n + 2) != buf2 + 16\n      || memcmp (buf2, \"aBcdRSTUVWkSmnrsq\\0\", 19))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  long *x;\n  char *y;\n  int z;\n  __builtin_memcpy (buf5, \"RSTUVWXYZ0123456789\", 20);\n  __builtin_memcpy (buf7, \"RSTUVWXYZ0123456789\", 20);\n __asm (\"\" : \"=r\" (x) : \"0\" (buf1));\n __asm (\"\" : \"=r\" (y) : \"0\" (buf2));\n __asm (\"\" : \"=r\" (z) : \"0\" (0));\n  test2_sub (x, y, \"rstuvwxyz\", z);\n}\n\nvolatile void *vx;\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  size_t l;\n\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  vx = mempcpy (a.buf1 + 2, s3, l1);\n  vx = mempcpy (r, s3, l1 + 1);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  vx = mempcpy (r, s2, l1 + 2);\n  vx = mempcpy (r + 2, s3, l1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  vx = mempcpy (r, s2, l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  vx = mempcpy (a.buf1 + 2, s3, 1);\n  vx = mempcpy (r, s3, 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  vx = mempcpy (r, s2, 3);\n  r = buf3;\n  l = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = 1;\n    }\n  vx = mempcpy (r, s2, 1);\n  /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)\n     is 4, so this doesn't need runtime checking.  */\n  vx = mempcpy (&buf3[16], s2, l);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = mempcpy (&a.buf2[9], s2, l1 + 1);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = mempcpy (&a.buf2[7], s3, strlen (s3) + 1);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = mempcpy (&buf3[19], \"ab\", 2);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\n__attribute__((noinline))\ntest5 (void)\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\n\t  p = mempcpy (u1.buf + off1, u2.buf + off2, len);\n\t  if (p != u1.buf + off1 + len)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n}\n\n#define TESTSIZE 80\n\nchar srcb[TESTSIZE] __attribute__ ((aligned));\nchar dstb[TESTSIZE] __attribute__ ((aligned));\n\nvoid\n__attribute__((noinline))\ncheck (char *test, char *match, int n)\n{\n  if (memcmp (test, match, n))\n    abort ();\n}\n\n#define TN(n) \\\n{ memset (dstb, 0, n); vx = mempcpy (dstb, srcb, n); check (dstb, srcb, n); }\n#define T(n) \\\nTN (n) \\\nTN ((n) + 1) \\\nTN ((n) + 2) \\\nTN ((n) + 3)\n\nvoid\n__attribute__((noinline))\ntest6 (void)\n{\n  int i;\n\n  chk_calls = 0;\n\n  for (i = 0; i < sizeof (srcb); ++i)\n      srcb[i] = 'a' + i % 26;\n\n  T (0);\n  T (4);\n  T (8);\n  T (12);\n  T (16);\n  T (20);\n  T (24);\n  T (28);\n  T (32);\n  T (36);\n  T (40);\n  T (44);\n  T (48);\n  T (52);\n  T (56);\n  T (60);\n  T (64);\n  T (68);\n  T (72);\n  T (76);\n\n  /* All mempcpy calls in this routine have constant arguments.  */\n  if (chk_calls)\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  test2 ();\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy-lib.c",
    "content": "#include \"lib/mempcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/mempcpy.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Ensure builtin mempcpy performs correctly.\n\n   Written by Kaveh Ghazi, 4/11/2003.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern void *mempcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern int inside_main;\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nsize_t l1 = 1;\n\nvoid\nmain_test (void)\n{\n  int i;\n\n#if !defined __i386__ && !defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  inside_main = 0;\n#endif\n\n  if (mempcpy (p, \"ABCDE\", 6) != p + 6 || memcmp (p, \"ABCDE\", 6))\n    abort ();\n  if (mempcpy (p + 16, \"VWX\" + 1, 2) != p + 16 + 2\n      || memcmp (p + 16, \"WX\\0\\0\", 5))\n    abort ();\n  if (mempcpy (p + 1, \"\", 1) != p + 1 + 1 || memcmp (p, \"A\\0CDE\", 6))\n    abort ();\n  if (mempcpy (p + 3, \"FGHI\", 4) != p + 3 + 4 || memcmp (p, \"A\\0CFGHI\", 8))\n    abort ();\n\n  i = 8;\n  memcpy (p + 20, \"qrstu\", 6);\n  memcpy (p + 25, \"QRSTU\", 6);\n  if (mempcpy (p + 25 + 1, s1, 3) != (p + 25 + 1 + 3)\n      || memcmp (p + 25, \"Q123U\", 6))\n    abort ();\n\n  if (mempcpy (mempcpy (p, \"abcdEFG\", 4), \"efg\", 4) != p + 8\n      || memcmp (p, \"abcdefg\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_mempcpy (p, \"ABCDE\", 6) != p + 6 || memcmp (p, \"ABCDE\", 6))\n    abort ();\n\n  /* If the result of mempcpy is ignored, gcc should use memcpy.\n     This should be optimized always, so set inside_main again.  */\n  inside_main = 1;\n  mempcpy (p + 5, s3, 1);\n  if (memcmp (p, \"ABCDEFg\", 8))\n    abort ();\n  mempcpy (p + 6, s1 + 1, l1);\n  if (memcmp (p, \"ABCDEF2\", 8))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memset-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memset-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __memset_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nchar buffer[32];\nint argc = 1;\nvolatile size_t l1 = 1;  /* prevent constant propagation to happen when whole program assumptions are made.  */\nvolatile char *s3 = \"FGH\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\nchar *s4;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  memset_disallowed = 1;\n  chk_calls = 0;\n  memset (buffer, argc, 0);\n  memset (buffer, argc, 1);\n  memset (buffer, argc, 2);\n  memset (buffer, argc, 3);\n  memset (buffer, argc, 4);\n  memset (buffer, argc, 5);\n  memset (buffer, argc, 6);\n  memset (buffer, argc, 7);\n  memset (buffer, argc, 8);\n  memset (buffer, argc, 9);\n  memset (buffer, argc, 10);\n  memset (buffer, argc, 11);\n  memset (buffer, argc, 12);\n  memset (buffer, argc, 13);\n  memset (buffer, argc, 14);\n  memset (buffer, argc, 15);\n  memset (buffer, argc, 16);\n  memset (buffer, argc, 17);\n  memset_disallowed = 0;\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  size_t l;\n\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  memset (a.buf1 + 2, 'a', l1);\n  memset (r, '\\0', l1 + 1);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, argc, l1 + 2);\n  memset (r + 2, 'Q', l1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  memset (r, '\\0', l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  memset (a.buf1 + 2, '\\0', 1);\n  memset (r, argc, 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, 'N', 3);\n  r = buf3;\n  l = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = 1;\n    }\n  memset (r, 'H', 1);\n  /* Here, l is known to be at most 4 and __builtin_object_size (&buf3[16], 0)\n     is 4, so this doesn't need runtime checking.  */\n  memset (&buf3[16], 'd', l);\n  /* Neither length nor destination known.  Doesn't need runtime checking.  */\n  memset (s4, 'a', l1);\n  memset (s4 + 2, '\\0', l1 + 2);\n  /* Destination unknown.  */\n  memset (s4 + 4, 'b', 2);\n  memset (s4 + 6, '\\0', 4);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memset (&a.buf2[9], '\\0', l1 + 1);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memset (&a.buf2[7], 'T', strlen (s3) + 1);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      memset (&buf3[19], 'b', 2);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#define MAX_COPY2 15\n#else\n#define MAX_COPY2 MAX_COPY\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n#define MAX_LENGTH2 (MAX_OFFSET + MAX_COPY2 + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  int off, len, i;\n  char *p, *q;\n\n  for (off = 0; off < MAX_OFFSET; off++)\n    for (len = 1; len < MAX_COPY; len++)\n      {\n\tfor (i = 0; i < MAX_LENGTH; i++)\n\t  u.buf[i] = 'a';\n\n\tp = memset (u.buf + off, '\\0', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != '\\0')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, A, len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'A')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, 'B', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'B')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n      }\n}\n\nstatic union {\n  char buf[MAX_LENGTH2];\n  long long align_int;\n  long double align_fp;\n} u2;\n\nvoid reset ()\n{\n  int i;\n\n  for (i = 0; i < MAX_LENGTH2; i++)\n    u2.buf[i] = 'a';\n}\n\nvoid check (int off, int len, int ch)\n{\n  char *q;\n  int i;\n\n  q = u2.buf;\n  for (i = 0; i < off; i++, q++)\n    if (*q != 'a')\n      abort ();\n\n  for (i = 0; i < len; i++, q++)\n    if (*q != ch)\n      abort ();\n\n  for (i = 0; i < MAX_EXTRA; i++, q++)\n    if (*q != 'a')\n      abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest5 (void)\n{\n  int off;\n  char *p;\n\n  /* len == 1 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 1);\n      if (p != u2.buf + off) abort ();\n      check (off, 1, '\\0');\n\n      p = memset (u2.buf + off, A, 1);\n      if (p != u2.buf + off) abort ();\n      check (off, 1, 'A');\n\n      p = memset (u2.buf + off, 'B', 1);\n      if (p != u2.buf + off) abort ();\n      check (off, 1, 'B');\n    }\n\n  /* len == 2 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 2);\n      if (p != u2.buf + off) abort ();\n      check (off, 2, '\\0');\n\n      p = memset (u2.buf + off, A, 2);\n      if (p != u2.buf + off) abort ();\n      check (off, 2, 'A');\n\n      p = memset (u2.buf + off, 'B', 2);\n      if (p != u2.buf + off) abort ();\n      check (off, 2, 'B');\n    }\n\n  /* len == 3 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 3);\n      if (p != u2.buf + off) abort ();\n      check (off, 3, '\\0');\n\n      p = memset (u2.buf + off, A, 3);\n      if (p != u2.buf + off) abort ();\n      check (off, 3, 'A');\n\n      p = memset (u2.buf + off, 'B', 3);\n      if (p != u2.buf + off) abort ();\n      check (off, 3, 'B');\n    }\n\n  /* len == 4 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 4);\n      if (p != u2.buf + off) abort ();\n      check (off, 4, '\\0');\n\n      p = memset (u2.buf + off, A, 4);\n      if (p != u2.buf + off) abort ();\n      check (off, 4, 'A');\n\n      p = memset (u2.buf + off, 'B', 4);\n      if (p != u2.buf + off) abort ();\n      check (off, 4, 'B');\n    }\n\n  /* len == 5 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 5);\n      if (p != u2.buf + off) abort ();\n      check (off, 5, '\\0');\n\n      p = memset (u2.buf + off, A, 5);\n      if (p != u2.buf + off) abort ();\n      check (off, 5, 'A');\n\n      p = memset (u2.buf + off, 'B', 5);\n      if (p != u2.buf + off) abort ();\n      check (off, 5, 'B');\n    }\n\n  /* len == 6 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 6);\n      if (p != u2.buf + off) abort ();\n      check (off, 6, '\\0');\n\n      p = memset (u2.buf + off, A, 6);\n      if (p != u2.buf + off) abort ();\n      check (off, 6, 'A');\n\n      p = memset (u2.buf + off, 'B', 6);\n      if (p != u2.buf + off) abort ();\n      check (off, 6, 'B');\n    }\n\n  /* len == 7 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 7);\n      if (p != u2.buf + off) abort ();\n      check (off, 7, '\\0');\n\n      p = memset (u2.buf + off, A, 7);\n      if (p != u2.buf + off) abort ();\n      check (off, 7, 'A');\n\n      p = memset (u2.buf + off, 'B', 7);\n      if (p != u2.buf + off) abort ();\n      check (off, 7, 'B');\n    }\n\n  /* len == 8 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 8);\n      if (p != u2.buf + off) abort ();\n      check (off, 8, '\\0');\n\n      p = memset (u2.buf + off, A, 8);\n      if (p != u2.buf + off) abort ();\n      check (off, 8, 'A');\n\n      p = memset (u2.buf + off, 'B', 8);\n      if (p != u2.buf + off) abort ();\n      check (off, 8, 'B');\n    }\n\n  /* len == 9 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 9);\n      if (p != u2.buf + off) abort ();\n      check (off, 9, '\\0');\n\n      p = memset (u2.buf + off, A, 9);\n      if (p != u2.buf + off) abort ();\n      check (off, 9, 'A');\n\n      p = memset (u2.buf + off, 'B', 9);\n      if (p != u2.buf + off) abort ();\n      check (off, 9, 'B');\n    }\n\n  /* len == 10 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 10);\n      if (p != u2.buf + off) abort ();\n      check (off, 10, '\\0');\n\n      p = memset (u2.buf + off, A, 10);\n      if (p != u2.buf + off) abort ();\n      check (off, 10, 'A');\n\n      p = memset (u2.buf + off, 'B', 10);\n      if (p != u2.buf + off) abort ();\n      check (off, 10, 'B');\n    }\n\n  /* len == 11 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 11);\n      if (p != u2.buf + off) abort ();\n      check (off, 11, '\\0');\n\n      p = memset (u2.buf + off, A, 11);\n      if (p != u2.buf + off) abort ();\n      check (off, 11, 'A');\n\n      p = memset (u2.buf + off, 'B', 11);\n      if (p != u2.buf + off) abort ();\n      check (off, 11, 'B');\n    }\n\n  /* len == 12 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 12);\n      if (p != u2.buf + off) abort ();\n      check (off, 12, '\\0');\n\n      p = memset (u2.buf + off, A, 12);\n      if (p != u2.buf + off) abort ();\n      check (off, 12, 'A');\n\n      p = memset (u2.buf + off, 'B', 12);\n      if (p != u2.buf + off) abort ();\n      check (off, 12, 'B');\n    }\n\n  /* len == 13 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 13);\n      if (p != u2.buf + off) abort ();\n      check (off, 13, '\\0');\n\n      p = memset (u2.buf + off, A, 13);\n      if (p != u2.buf + off) abort ();\n      check (off, 13, 'A');\n\n      p = memset (u2.buf + off, 'B', 13);\n      if (p != u2.buf + off) abort ();\n      check (off, 13, 'B');\n    }\n\n  /* len == 14 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 14);\n      if (p != u2.buf + off) abort ();\n      check (off, 14, '\\0');\n\n      p = memset (u2.buf + off, A, 14);\n      if (p != u2.buf + off) abort ();\n      check (off, 14, 'A');\n\n      p = memset (u2.buf + off, 'B', 14);\n      if (p != u2.buf + off) abort ();\n      check (off, 14, 'B');\n    }\n\n  /* len == 15 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u2.buf + off, '\\0', 15);\n      if (p != u2.buf + off) abort ();\n      check (off, 15, '\\0');\n\n      p = memset (u2.buf + off, A, 15);\n      if (p != u2.buf + off) abort ();\n      check (off, 15, 'A');\n\n      p = memset (u2.buf + off, 'B', 15);\n      if (p != u2.buf + off) abort ();\n      check (off, 15, 'B');\n    }\n}\n\nvoid\n__attribute__((noinline))\ntest6 (void)\n{\n  int len;\n  char *p;\n\n  /* off == 0 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf, '\\0', len);\n      if (p != u2.buf) abort ();\n      check (0, len, '\\0');\n\n      p = memset (u2.buf, A, len);\n      if (p != u2.buf) abort ();\n      check (0, len, 'A');\n\n      p = memset (u2.buf, 'B', len);\n      if (p != u2.buf) abort ();\n      check (0, len, 'B');\n    }\n\n  /* off == 1 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+1, '\\0', len);\n      if (p != u2.buf+1) abort ();\n      check (1, len, '\\0');\n\n      p = memset (u2.buf+1, A, len);\n      if (p != u2.buf+1) abort ();\n      check (1, len, 'A');\n\n      p = memset (u2.buf+1, 'B', len);\n      if (p != u2.buf+1) abort ();\n      check (1, len, 'B');\n    }\n\n  /* off == 2 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+2, '\\0', len);\n      if (p != u2.buf+2) abort ();\n      check (2, len, '\\0');\n\n      p = memset (u2.buf+2, A, len);\n      if (p != u2.buf+2) abort ();\n      check (2, len, 'A');\n\n      p = memset (u2.buf+2, 'B', len);\n      if (p != u2.buf+2) abort ();\n      check (2, len, 'B');\n    }\n\n  /* off == 3 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+3, '\\0', len);\n      if (p != u2.buf+3) abort ();\n      check (3, len, '\\0');\n\n      p = memset (u2.buf+3, A, len);\n      if (p != u2.buf+3) abort ();\n      check (3, len, 'A');\n\n      p = memset (u2.buf+3, 'B', len);\n      if (p != u2.buf+3) abort ();\n      check (3, len, 'B');\n    }\n\n  /* off == 4 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+4, '\\0', len);\n      if (p != u2.buf+4) abort ();\n      check (4, len, '\\0');\n\n      p = memset (u2.buf+4, A, len);\n      if (p != u2.buf+4) abort ();\n      check (4, len, 'A');\n\n      p = memset (u2.buf+4, 'B', len);\n      if (p != u2.buf+4) abort ();\n      check (4, len, 'B');\n    }\n\n  /* off == 5 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+5, '\\0', len);\n      if (p != u2.buf+5) abort ();\n      check (5, len, '\\0');\n\n      p = memset (u2.buf+5, A, len);\n      if (p != u2.buf+5) abort ();\n      check (5, len, 'A');\n\n      p = memset (u2.buf+5, 'B', len);\n      if (p != u2.buf+5) abort ();\n      check (5, len, 'B');\n    }\n\n  /* off == 6 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+6, '\\0', len);\n      if (p != u2.buf+6) abort ();\n      check (6, len, '\\0');\n\n      p = memset (u2.buf+6, A, len);\n      if (p != u2.buf+6) abort ();\n      check (6, len, 'A');\n\n      p = memset (u2.buf+6, 'B', len);\n      if (p != u2.buf+6) abort ();\n      check (6, len, 'B');\n    }\n\n  /* off == 7 */\n  for (len = 0; len < MAX_COPY2; len++)\n    {\n      reset ();\n\n      p = memset (u2.buf+7, '\\0', len);\n      if (p != u2.buf+7) abort ();\n      check (7, len, '\\0');\n\n      p = memset (u2.buf+7, A, len);\n      if (p != u2.buf+7) abort ();\n      check (7, len, 'A');\n\n      p = memset (u2.buf+7, 'B', len);\n      if (p != u2.buf+7) abort ();\n      check (7, len, 'B');\n    }\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = buffer;\n  test1 ();\n  test2 ();\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memset-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memset-lib.c",
    "content": "#include \"lib/memset.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/memset.c",
    "content": "/* Copyright (C) 2002, 2003  Free Software Foundation.\n\n   Ensure that builtin memset operations for constant length and\n   non-constant assigned value don't cause compiler problems.\n\n   Written by Roger Sayle, 21 April 2002.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memset (void *, int, size_t);\n\nchar buffer[32];\nint argc = 1;\n\nvoid\nmain_test (void)\n{\n  memset (buffer, argc, 0);\n  memset (buffer, argc, 1);\n  memset (buffer, argc, 2);\n  memset (buffer, argc, 3);\n  memset (buffer, argc, 4);\n  memset (buffer, argc, 5);\n  memset (buffer, argc, 6);\n  memset (buffer, argc, 7);\n  memset (buffer, argc, 8);\n  memset (buffer, argc, 9);\n  memset (buffer, argc, 10);\n  memset (buffer, argc, 11);\n  memset (buffer, argc, 12);\n  memset (buffer, argc, 13);\n  memset (buffer, argc, 14);\n  memset (buffer, argc, 15);\n  memset (buffer, argc, 16);\n  memset (buffer, argc, 17);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237-lib.c",
    "content": "extern void abort (void);\n\nvoid *\nmemcpy (void *dst, const void *src, __SIZE_TYPE__ n)\n{\n  const char *srcp;\n  char *dstp;\n\n  srcp = src;\n  dstp = dst;\n\n  if (dst < src)\n    {\n      if (dst + n > src)\n\tabort ();\n    }\n  else\n    {\n      if (src + n > dst)\n\tabort ();\n    }\n\n  while (n-- != 0)\n    *dstp++ = *srcp++;\n\n  return dst;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/pr22237.c",
    "content": "extern void abort (void);\nextern void exit (int);\nstruct s { unsigned char a[256]; };\nunion u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; };\nstatic union u v;\nstatic union u v0;\nstatic struct s *p = &v.d.b;\nstatic struct s *q = &v.e.b;\n\nstatic inline struct s rp (void) { return *p; }\nstatic inline struct s rq (void) { return *q; }\nstatic void pq (void) { *p = rq(); }\nstatic void qp (void) { *q = rp(); }\n\nstatic void\ninit (struct s *sp)\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    sp->a[i] = i;\n}\n\nstatic void\ncheck (struct s *sp)\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    if (sp->a[i] != i)\n      abort ();\n}\n\nvoid\nmain_test (void)\n{\n  v = v0;\n  init (p);\n  qp ();\n  check (q);\n  v = v0;\n  init (q);\n  pq ();\n  check (p);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk.c",
    "content": "/* PR middle-end/23484 */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern void *mempcpy (void *, const void *, size_t);\nextern void *memmove (void *, const void *, size_t);\nextern int snprintf (char *, size_t, const char *, ...);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nstatic char data[8] = \"ABCDEFG\";\n\nint l1;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  char buf[8];\n\n  /* All the checking calls in this routine have a maximum length, so\n     object size checking should be done at compile time if optimizing.  */\n  chk_calls = 0;\n\n  memset (buf, 'I', sizeof (buf));\n  if (memcpy (buf, data, l1 ? sizeof (buf) : 4) != buf\n      || memcmp (buf, \"ABCDIIII\", 8))\n    abort ();\n\n  memset (buf, 'J', sizeof (buf));\n  if (mempcpy (buf, data, l1 ? sizeof (buf) : 4) != buf + 4\n      || memcmp (buf, \"ABCDJJJJ\", 8))\n    abort ();\n\n  memset (buf, 'K', sizeof (buf));\n  if (memmove (buf, data, l1 ? sizeof (buf) : 4) != buf\n      || memcmp (buf, \"ABCDKKKK\", 8))\n    abort ();\n\n  memset (buf, 'L', sizeof (buf));\n#if(__SIZEOF_INT__ >= 4)  \n  if (snprintf (buf, l1 ? sizeof (buf) : 4, \"%d\", l1 + 65536) != 5\n      || memcmp (buf, \"655\\0LLLL\", 8))\n    abort ();\n#else\n  if (snprintf (buf, l1 ? sizeof (buf) : 4, \"%d\", l1 + 32700) != 5\n      || memcmp (buf, \"327\\0LLLL\", 8))\n    abort ();\n#endif\n\n  if (chk_calls)\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/pr23484-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/printf-lib.c",
    "content": "#include \"lib/printf.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/printf.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure all expected transformations of builtin printf occur and\n   that we honor side effects in the arguments.\n\n   Written by Kaveh R. Ghazi, 12/4/2000.  */\n\nextern int printf (const char *, ...);\nextern int printf_unlocked (const char *, ...);\nextern void abort(void);\n\nvoid\nmain_test (void)\n{\n  const char *const s1 = \"hello world\";\n  const char *const s2[] = { s1, 0 }, *const*s3;\n  \n  printf (\"%s\\n\", \"hello\");\n  printf (\"%s\\n\", *s2);\n  s3 = s2;\n  printf (\"%s\\n\", *s3++);\n  if (s3 != s2+1 || *s3 != 0)\n    abort();\n  \n  printf (\"%c\", '\\n');\n  printf (\"%c\", **s2);\n  s3 = s2;\n  printf (\"%c\", **s3++);\n  if (s3 != s2+1 || *s3 != 0)\n    abort();\n  \n  printf (\"\");\n  printf (\"%s\", \"\");\n  printf (\"\\n\");\n  printf (\"%s\", \"\\n\");\n  printf (\"hello world\\n\");\n  printf (\"%s\", \"hello world\\n\");\n  \n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  __builtin_printf (\"%s\\n\", \"hello\");\n  /* These builtin stubs are called by __builtin_printf, ensure their\n     prototypes are set correctly too.  */\n  __builtin_putchar ('\\n');\n  __builtin_puts (\"hello\");\n  /* Check the unlocked style, these evaluate to nothing to avoid\n     problems on systems without the unlocked functions.  */\n  printf_unlocked (\"\");\n  __builtin_printf_unlocked (\"\");\n  printf_unlocked (\"%s\", \"\");\n  __builtin_printf_unlocked (\"%s\", \"\");\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/snprintf-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/snprintf-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __snprintf_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\nextern int sprintf (char *, const char *, ...);\nextern int snprintf (char *, size_t, const char *, ...);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nstatic char buffer[32];\nchar * volatile ptr = \"barf\"; /* prevent constant propagation to happen when whole program assumptions are made.  */ \n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  chk_calls = 0;\n  /* snprintf_disallowed = 1; */\n\n  memset (buffer, 'A', 32);\n  snprintf (buffer, 4, \"foo\");\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (snprintf (buffer, 4, \"foo bar\") != 7)\n    abort ();\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  snprintf (buffer, 32, \"%s\", \"bar\");\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (snprintf (buffer, 21, \"%s\", \"bar\") != 3)\n    abort ();\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  snprintf_disallowed = 0;\n\n  memset (buffer, 'A', 32);\n  if (snprintf (buffer, 4, \"%d%d%d\", (int) l1, (int) l1 + 1, (int) l1 + 12)\n      != 4)\n    abort ();\n  if (memcmp (buffer, \"121\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (snprintf (buffer, 32, \"%d%d%d\", (int) l1, (int) l1 + 1, (int) l1 + 12)\n      != 4)\n    abort ();\n  if (memcmp (buffer, \"1213\", 5) || buffer[5] != 'A')\n    abort ();\n\n  if (chk_calls)\n    abort ();\n\n  memset (buffer, 'A', 32);\n  snprintf (buffer, strlen (ptr) + 1, \"%s\", ptr);\n  if (memcmp (buffer, \"barf\", 5) || buffer[5] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  snprintf (buffer, l1 + 31, \"%d - %c\", (int) l1 + 27, *ptr);\n  if (memcmp (buffer, \"28 - b\\0AAAAA\", 12))\n    abort ();\n\n  if (chk_calls != 2)\n    abort ();\n  chk_calls = 0;\n\n  memset (s4, 'A', 32);\n  snprintf (s4, l1 + 6, \"%d - %c\", (int) l1 - 17, ptr[1]);\n  if (memcmp (s4, \"-16 - \\0AAA\", 10))\n    abort ();\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  snprintf (a.buf1 + 2, l1, \"%s\", s3 + 3);\n  snprintf (r, l1 + 4, \"%s%c\", s3 + 3, s3[3]);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  snprintf (r, strlen (s2) - 2, \"%c %s\", s2[2], s2 + 4);\n  snprintf (r + 2, l1, s3 + 3);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  snprintf (r, l1, s2 + 4);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  /* snprintf_disallowed = 1; */\n  snprintf (a.buf1 + 2, 4, \"\");\n  snprintf (r, 1, \"a\");\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  snprintf (r, 3, \"%s\", s1 + 1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  snprintf (r, 1, \"%s\", \"\");\n  snprintf (r, 0, \"%s\", \"\");\n  snprintf_disallowed = 0;\n  /* Unknown destination and source, no checking.  */\n  snprintf (s4, l1 + 31, \"%s %d\", s3, 0);\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&a.buf2[9], l1 + 1, \"%c%s\", s2[3], s2 + 4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&a.buf2[7], l1 + 30, \"%s%c\", s3 + strlen (s3) - 2, *s3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&a.buf2[7], l1 + 3, \"%d\", (int) l1 + 9999);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&buf3[19], 2, \"a\");\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&buf3[17], 4, \"a\");\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      snprintf (&buf3[17], 4, \"%s\", \"abc\");\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/snprintf-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __sprintf_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\nextern int sprintf (char *, const char *, ...);\n\n#include \"chk.h\"\n\nLOCAL const char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nstatic char buffer[32];\nchar * volatile ptr = \"barf\"; /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  chk_calls = 0;\n  sprintf_disallowed = 1;\n\n  memset (buffer, 'A', 32);\n  sprintf (buffer, \"foo\");\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (sprintf (buffer, \"foo\") != 3)\n    abort ();\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  sprintf (buffer, \"%s\", \"bar\");\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (sprintf (buffer, \"%s\", \"bar\") != 3)\n    abort ();\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  sprintf_disallowed = 0;\n\n  memset (buffer, 'A', 32);\n  sprintf (buffer, \"%s\", ptr);\n  if (memcmp (buffer, \"barf\", 5) || buffer[5] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  sprintf (buffer, \"%d - %c\", (int) l1 + 27, *ptr);\n  if (memcmp (buffer, \"28 - b\\0AAAAA\", 12))\n    abort ();\n\n  if (chk_calls != 2)\n    abort ();\n  chk_calls = 0;\n\n  sprintf (s4, \"%d - %c\", (int) l1 - 17, ptr[1]);\n  if (memcmp (s4, \"-16 - a\", 8))\n    abort ();\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  chk_calls = 0;\n  sprintf (a.buf1 + 2, \"%s\", s3 + 3);\n  sprintf (r, \"%s%c\", s3 + 3, s3[3]);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  sprintf (r, \"%c %s\", s2[2], s2 + 4);\n  sprintf (r + 2, s3 + 3);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  sprintf (r, s2 + 4);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  sprintf_disallowed = 1;\n  sprintf (a.buf1 + 2, \"\");\n  sprintf (r, \"a\");\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  sprintf (r, \"%s\", s1 + 1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  sprintf (r, \"%s\", \"\");\n  sprintf_disallowed = 0;\n  /* Unknown destination and source, no checking.  */\n  sprintf (s4, \"%s %d\", s3, 0);\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      sprintf (&a.buf2[9], \"%c%s\", s2[3], s2 + 4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      sprintf (&a.buf2[7], \"%s%c\", s3 + strlen (s3) - 2, *s3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      sprintf (&a.buf2[7], \"%d\", (int) l1 + 9999);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      sprintf (&buf3[19], \"a\");\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      sprintf (&buf3[17], \"%s\", \"abc\");\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf-lib.c",
    "content": "#include \"lib/sprintf.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/sprintf.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test sprintf optimizations don't break anything and return the\n   correct results.\n\n   Written by Roger Sayle, June 22, 2003.  */\n\nstatic char buffer[32];\n\nextern void abort ();\ntypedef __SIZE_TYPE__ size_t;\nextern int sprintf(char*, const char*, ...);\nextern void *memset(void*, int, size_t);\nextern int memcmp(const void*, const void*, size_t);\n\nvoid test1()\n{\n  sprintf(buffer,\"foo\");\n}\n\nint test2()\n{\n  return sprintf(buffer,\"foo\");\n}\n\nvoid test3()\n{\n  sprintf(buffer,\"%s\",\"bar\");\n}\n\nint test4()\n{\n  return sprintf(buffer,\"%s\",\"bar\");\n}\n\nvoid test5(char *ptr)\n{\n  sprintf(buffer,\"%s\",ptr);\n}\n\n\nvoid\nmain_test (void)\n{\n  memset (buffer, 'A', 32);\n  test1 ();\n  if (memcmp(buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test2 () != 3)\n    abort ();\n  if (memcmp(buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test3 ();\n  if (memcmp(buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test4 () != 3)\n    abort ();\n  if (memcmp(buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test5 (\"barf\");\n  if (memcmp(buffer, \"barf\", 5) || buffer[5] != 'A')\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpcpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpcpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __stpcpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *stpcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nLOCAL const char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  int i = 8;\n\n#if defined __i386__ || defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  stpcpy_disallowed = 1;\n#endif\n  if (stpcpy (p, \"abcde\") != p + 5 || memcmp (p, \"abcde\", 6))\n    abort ();\n  if (stpcpy (p + 16, \"vwxyz\" + 1) != p + 16 + 4 || memcmp (p + 16, \"wxyz\", 5))\n    abort ();\n  if (stpcpy (p + 1, \"\") != p + 1 + 0 || memcmp (p, \"a\\0cde\", 6))\n    abort ();\n  if (stpcpy (p + 3, \"fghij\") != p + 3 + 5 || memcmp (p, \"a\\0cfghij\", 9))\n    abort ();\n\n  if (stpcpy ((i++, p + 20 + 1), \"23\") != (p + 20 + 1 + 2)\n      || i != 9 || memcmp (p + 19, \"z\\0\"\"23\\0\", 5))\n    abort ();\n\n  if (stpcpy (stpcpy (p, \"ABCD\"), \"EFG\") != p + 7 || memcmp (p, \"ABCDEFG\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_stpcpy (p, \"abcde\") != p + 5 || memcmp (p, \"abcde\", 6))\n    abort ();\n\n  /* If return value of stpcpy is ignored, it should be optimized into\n     strcpy call.  */\n  stpcpy_disallowed = 1;\n  stpcpy (p + 1, \"abcd\");\n  stpcpy_disallowed = 0;\n  if (memcmp (p, \"aabcd\", 6))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n\n  chk_calls = 0;\n  strcpy_disallowed = 1;\n  if (stpcpy (p, s2) != p + 4 || memcmp (p, \"defg\\0\", 6))\n    abort ();\n  strcpy_disallowed = 0;\n  stpcpy_disallowed = 1;\n  stpcpy (p + 2, s3);\n  stpcpy_disallowed = 0;\n  if (memcmp (p, \"deFGH\", 6))\n    abort ();\n  if (chk_calls != 2)\n    abort ();\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvolatile char *vx;\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\t  u2.buf[off2 + len] = '\\0';\n\n\t  p = stpcpy (u1.buf + off1, u2.buf + off2);\n\t  if (p != u1.buf + off1 + len)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  if (*q++ != '\\0')\n\t    abort ();\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  const char *l;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  chk_calls = 0;\n  vx = stpcpy (a.buf1 + 2, s3 + 3);\n  vx = stpcpy (r, s3 + 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  vx = stpcpy (r, s2 + 2);\n  vx = stpcpy (r + 2, s3 + 3);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  vx = stpcpy (r, s2 + 4);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  vx = stpcpy (a.buf1 + 2, \"\");\n  vx = stpcpy (r, \"a\");\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  vx = stpcpy (r, s1 + 1);\n  r = buf3;\n  l = \"abc\";\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = \"e\";\n      else if (i == l1)\n\tr = &a.buf2[7], l = \"gh\";\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = \"jkl\";\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = \"\";\n    }\n  vx = stpcpy (r, \"\");\n  /* Here, strlen (l) + 1 is known to be at most 4 and\n     __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need\n     runtime checking.  */\n  vx = stpcpy (&buf3[16], l);\n  /* Unknown destination and source, no checking.  */\n  vx = stpcpy (s4, s3);\n  stpcpy (s4 + 4, s3);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = stpcpy (&a.buf2[9], s2 + 3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = stpcpy (&a.buf2[7], s3 + strlen (s3) - 3);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      vx = stpcpy (&buf3[19], \"a\");\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  s4 = p;\n  test2 ();\n  test3 ();\n  test4 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpcpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpncpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpncpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005, 2011  Free Software Foundation.\n\n   Ensure builtin __stpncpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *stpncpy (char *, const char *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern int strcmp (const char *, const char *);\nextern int strncmp (const char *, const char *, size_t);\nextern void *memset (void *, int, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar * volatile s2 = \"defg\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\nchar * volatile s3 = \"FGH\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\nchar *s4;\nvolatile size_t l1 = 1;  /* prevent constant propagation to happen when whole program assumptions are made.  */\nint i;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  const char *const src = \"hello world\";\n  const char *src2;\n  char dst[64], *dst2;\n\n  chk_calls = 0;\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst, src, 4) != dst+4 || strncmp (dst, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst+16, src, 4) != dst+20 || strncmp (dst+16, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst+32, src+5, 4) != dst+36 || strncmp (dst+32, src+5, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  dst2 = dst;\n  if (stpncpy (++dst2, src+5, 4) != dst+5 || strncmp (dst2, src+5, 4)\n      || dst2 != dst+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst, src, 0) != dst || strcmp (dst, \"\"))\n    abort();\n  \n  memset (dst, 0, sizeof (dst));\n  dst2 = dst; src2 = src;\n  if (stpncpy (++dst2, ++src2, 0) != dst+1 || strcmp (dst2, \"\")\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  dst2 = dst; src2 = src;\n  if (stpncpy (++dst2+5, ++src2+5, 0) != dst+6 || strcmp (dst2+5, \"\")\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst, src, 12) != dst+11 || strcmp (dst, src))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  memset (dst, 0, sizeof (dst));\n  if (__builtin_stpncpy (dst, src, 4) != dst+4 || strncmp (dst, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (stpncpy (dst, i++ ? \"xfoo\" + 1 : \"bar\", 4) != dst+3\n      || strcmp (dst, \"bar\")\n      || i != 1)\n    abort ();\n\n  /* If return value of stpncpy is ignored, it should be optimized into\n     stpncpy call.  */\n  stpncpy_disallowed = 1;\n  stpncpy (dst + 1, src, 4);\n  stpncpy_disallowed = 0;\n  if (strncmp (dst + 1, src, 4))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  chk_calls = 0;\n\n  /* No runtime checking should be done here, both destination\n     and length are unknown.  */\n  size_t cpy_length = l1 < 4 ? l1 + 1 : 4;\n  if (stpncpy (s4, \"abcd\", l1 + 1) != s4 + cpy_length || strncmp (s4, \"abcd\", cpy_length))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  const char *l;\n  size_t l2;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  \n     The returned value is checked so that stpncpy calls\n     are not rewritten to strncpy calls. */\n  chk_calls = 0;\n  if (!stpncpy (a.buf1 + 2, s3 + 3, l1))\n    abort();\n  if (!stpncpy (r, s3 + 2, l1 + 2))\n    abort();\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  if (!stpncpy (r, s2 + 2, l1 + 2))\n    abort();\n  if (!stpncpy (r + 2, s3 + 3, l1))\n    abort();\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  if (!stpncpy (r, s2 + 4, l1))\n    abort();\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  if (!stpncpy (a.buf1 + 2, \"\", 3))\n    abort ();\n  if (!stpncpy (a.buf1 + 2, \"\", 0))\n    abort ();\n  if (!stpncpy (r, \"a\", 1))\n    abort ();\n  if (!stpncpy (r, \"a\", 3))\n    abort ();\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  if (!stpncpy (r, s1 + 1, 3))\n    abort ();\n  if (!stpncpy (r, s1 + 1, 2))\n    abort ();\n  r = buf3;\n  l = \"abc\";\n  l2 = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = \"e\", l2 = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = \"gh\", l2 = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = \"jkl\", l2 = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = \"\", l2 = 1;\n    }\n  if (!stpncpy (r, \"\", 1))\n    abort ();\n  /* Here, strlen (l) + 1 is known to be at most 4 and\n     __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need\n     runtime checking.  */\n  if (!stpncpy (&buf3[16], l, l2))\n    abort ();\n  if (!stpncpy (&buf3[15], \"abc\", l2))\n    abort ();\n  if (!stpncpy (&buf3[10], \"fghij\", l2))\n    abort ();\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      if (stpncpy (&a.buf2[9], s2 + 4, l1 + 1))\n        // returned value used to prevent stpncpy calls\n        // to be rewritten in strncpy calls\n        i++;\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      if (stpncpy (&a.buf2[7], s3, l1 + 4))\n        i++;\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      if (stpncpy (&buf3[19], \"abc\", 2))\n        i++;\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      if (stpncpy (&buf3[18], \"\", 3))\n        i++;\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  \n  s4 = p;\n  test2 ();\n  test3 ();\n  test4 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/stpncpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __strcat_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcat (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int strcmp (const char *, const char *);\nextern void *memset (void *, int, size_t);\n#define RESET_DST_WITH(FILLER) \\\n  do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nchar *s5;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  const char *const x1 = \"hello world\";\n  const char *const x2 = \"\";\n  char dst[64], *d2;\n\n  chk_calls = 0;\n  strcat_disallowed = 1;\n  /* Following strcat calls should be optimized out at compile time.  */  \n  RESET_DST_WITH (x1);\n  if (strcat (dst, \"\") != dst || strcmp (dst, x1))\n    abort ();\n  RESET_DST_WITH (x1);\n  if (strcat (dst, x2) != dst || strcmp (dst, x1))\n    abort ();\n  RESET_DST_WITH (x1); d2 = dst;\n  if (strcat (++d2, x2) != dst+1 || d2 != dst+1 || strcmp (dst, x1))\n    abort ();\n  RESET_DST_WITH (x1); d2 = dst;\n  if (strcat (++d2+5, x2) != dst+6 || d2 != dst+1 || strcmp (dst, x1))\n    abort ();\n  RESET_DST_WITH (x1); d2 = dst;\n  if (strcat (++d2+5, x1+11) != dst+6 || d2 != dst+1 || strcmp (dst, x1))\n    abort ();\n  if (chk_calls)\n    abort ();\n  strcat_disallowed = 0;\n\n  RESET_DST_WITH (x1);\n  if (strcat (dst, \" 1111\") != dst\n      || memcmp (dst, \"hello world 1111\\0XXX\", 20))\n    abort ();\n  \n  RESET_DST_WITH (x1);\n  if (strcat (dst+5, \" 2222\") != dst+5\n      || memcmp (dst, \"hello world 2222\\0XXX\", 20))\n    abort ();\n  \n  RESET_DST_WITH (x1); d2 = dst;\n  if (strcat (++d2+5, \" 3333\") != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world 3333\\0XXX\", 20))\n    abort ();\n  \n  RESET_DST_WITH (x1);\n  strcat (strcat (strcat (strcat (strcat (strcat (dst, \": this \"), \"\"),\n\t\t\t\t  \"is \"), \"a \"), \"test\"), \".\");\n  if (memcmp (dst, \"hello world: this is a test.\\0X\", 30))\n    abort ();\n\n  chk_calls = 0;\n  strcat_disallowed = 1;\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  RESET_DST_WITH (x1);\n  if (__builtin_strcat (dst, \"\") != dst || strcmp (dst, x1))\n    abort ();\n  if (chk_calls)\n    abort ();\n  strcat_disallowed = 0;\n}\n\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  memset (&a, '\\0', sizeof (a));\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  chk_calls = 0;\n  strcat (a.buf1 + 2, s3 + 3);\n  strcat (r, s3 + 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, '\\0', 3);\n  __asm __volatile (\"\" : : \"r\" (r) : \"memory\");\n  strcat (r, s2 + 2);\n  strcat (r + 2, s3 + 3);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  strcat (r, s2 + 4);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     but we don't know the length of dest string, so runtime checking\n     is needed too.  */\n  memset (&a, '\\0', sizeof (a));\n  chk_calls = 0;\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  strcat (a.buf1 + 2, \"a\");\n  strcat (r, \"\");\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, '\\0', 3);\n  __asm __volatile (\"\" : : \"r\" (r) : \"memory\");\n  strcat (r, s1 + 1);\n  if (chk_calls != 2)\n    abort ();\n  chk_calls = 0;\n  /* Unknown destination and source, no checking.  */\n  strcat (s4, s3);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  memset (&a, '\\0', sizeof (a));\n  memset (buf3, '\\0', sizeof (buf3));\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  s5 = buf3;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcat (&a.buf2[9], s2 + 3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcat (&a.buf2[7], s3 + strlen (s3) - 3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcat (&buf3[19], \"a\");\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  memset (p, '\\0', sizeof (p));\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcat-lib.c",
    "content": "#include \"lib/strcat.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcat.c",
    "content": "/* Copyright (C) 2000, 2003  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strcat occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/27/2000.  */\n\nextern int inside_main;\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern char *strcat (char *, const char *);\nextern char *strcpy (char *, const char *);\nextern void *memset (void *, int, size_t);\nextern int memcmp (const void *, const void *, size_t);\n#define RESET_DST_WITH(FILLER) \\\n  do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)\n\nvoid main_test (void)\n{\n  const char *const s1 = \"hello world\";\n  const char *const s2 = \"\";\n  char dst[64], *d2;\n  \n  RESET_DST_WITH (s1);\n  if (strcat (dst, \"\") != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1);\n  if (strcat (dst, s2) != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strcat (++d2, s2) != dst+1 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strcat (++d2+5, s2) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strcat (++d2+5, s1+11) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n\n#ifndef __OPTIMIZE_SIZE__\n# if !defined __i386__ && !defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  inside_main = 0;\n# endif\n\n  RESET_DST_WITH (s1);\n  if (strcat (dst, \" 1111\") != dst\n      || memcmp (dst, \"hello world 1111\\0XXX\", 20))\n    abort();\n  \n  RESET_DST_WITH (s1);\n  if (strcat (dst+5, \" 2222\") != dst+5\n      || memcmp (dst, \"hello world 2222\\0XXX\", 20))\n    abort();\n  \n  RESET_DST_WITH (s1); d2 = dst;\n  if (strcat (++d2+5, \" 3333\") != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world 3333\\0XXX\", 20))\n    abort();\n  \n  RESET_DST_WITH (s1);\n  strcat (strcat (strcat (strcat (strcat (strcat (dst, \": this \"), \"\"),\n\t\t\t\t  \"is \"), \"a \"), \"test\"), \".\");\n  if (memcmp (dst, \"hello world: this is a test.\\0X\", 30))\n    abort();\n\n  /* Set inside_main again.  */\n  inside_main = 1;\n#endif\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  RESET_DST_WITH (s1);\n  if (__builtin_strcat (dst, \"\") != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strchr-lib.c",
    "content": "#include \"lib/strchr.c\"\n#ifdef __vxworks\n/* The RTP C library uses bzero, bfill and bcopy, all of which are defined\n   in the same file as index.  */\n#include \"lib/bzero.c\"\n#include \"lib/bfill.c\"\n#include \"lib/memmove.c\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strchr.c",
    "content": "/* Copyright (C) 2000, 2003  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strchr and index\n   occur and perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.  */\n\nextern void abort (void);\nextern char *strchr (const char *, int);\nextern char *index (const char *, int);\n\nvoid\nmain_test (void)\n{\n  const char *const foo = \"hello world\";\n\n  if (strchr (foo, 'x'))\n    abort ();\n  if (strchr (foo, 'o') != foo + 4)\n    abort ();\n  if (strchr (foo + 5, 'o') != foo + 7)\n    abort ();\n  if (strchr (foo, '\\0')  != foo + 11)\n    abort ();\n  /* Test only one instance of index since the code path is the same\n     as that of strchr. */\n  if (index (\"hello\", 'z')  != 0)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strchr (foo, 'o')  != foo + 4)\n    abort ();\n  if (__builtin_index (foo, 'o')  != foo + 4)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp-lib.c",
    "content": "#include \"lib/strcmp.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcmp.c",
    "content": "/* Copyright (C) 2000, 2003, 2004  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strcmp\n   occur and perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.  */\n\nextern void abort (void);\nextern int strcmp (const char *, const char *);\n\nint x = 7;\nchar *bar = \"hi world\";\n\nvoid\nmain_test (void)\n{\n  const char *const foo = \"hello world\";\n\n  if (strcmp (foo, \"hello\") <= 0)\n    abort ();\n  if (strcmp (foo + 2, \"llo\") <= 0)\n    abort ();\n  if (strcmp (foo, foo) != 0)\n    abort ();\n  if (strcmp (foo, \"hello world \") >= 0)\n    abort ();\n  if (strcmp (foo + 10, \"dx\") >= 0)\n    abort ();\n  if (strcmp (10 + foo, \"dx\") >= 0)\n    abort ();\n  if (strcmp (bar, \"\") <= 0)\n    abort ();\n  if (strcmp (\"\", bar) >= 0)\n    abort ();\n  if (strcmp (bar+8, \"\") != 0)\n    abort ();\n  if (strcmp (\"\", bar+8) != 0)\n    abort ();\n  if (strcmp (bar+(--x), \"\") <= 0 || x != 6)\n    abort ();\n  if (strcmp (\"\", bar+(++x)) >= 0 || x != 7)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strcmp (foo, \"hello\") <= 0)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-2-lib.c",
    "content": "#include \"lib/strcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-2.c",
    "content": "/* Copyright (C) 2004  Free Software Foundation.\n\n   Ensure builtin strcpy is optimized into memcpy\n   even when there is more than one possible string literal\n   passed to it, but all string literals passed to it\n   have equal length.\n\n   Written by Jakub Jelinek, 9/15/2004.  */\n\nextern void abort (void);\nextern char *strcpy (char *, const char *);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\nchar buf[32], *p;\nint i;\n\nchar *\n__attribute__((noinline))\ntest (void)\n{\n  int j;\n  const char *q = \"abcdefg\";\n  for (j = 0; j < 3; ++j)\n    {\n      if (j == i)\n        q = \"bcdefgh\";\n      else if (j == i + 1)\n        q = \"cdefghi\";\n      else if (j == i + 2)\n        q = \"defghij\";\n    }\n  p = strcpy (buf, q);\n  return strcpy (buf + 16, q);\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE_SIZE__\n  /* For -Os, strcpy above is not replaced with\n     memcpy (buf, q, 8);, as that is larger.  */\n  if (test () != buf + 16 || p != buf)\n    abort ();\n#endif\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __strcpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\n\n#include \"chk.h\"\n\nLOCAL const char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  chk_calls = 0;\n#ifndef __OPTIMIZE_SIZE__\n  strcpy_disallowed = 1;\n#else\n  strcpy_disallowed = 0;\n#endif\n\n  if (strcpy (p, \"abcde\") != p || memcmp (p, \"abcde\", 6))\n    abort ();\n  if (strcpy (p + 16, \"vwxyz\" + 1) != p + 16 || memcmp (p + 16, \"wxyz\", 5))\n    abort ();\n  if (strcpy (p + 1, \"\") != p + 1 || memcmp (p, \"a\\0cde\", 6))\n    abort ();  \n  if (strcpy (p + 3, \"fghij\") != p + 3 || memcmp (p, \"a\\0cfghij\", 9))\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strcpy (p, \"abcde\") != p || memcmp (p, \"abcde\", 6))\n    abort ();\n\n  strcpy_disallowed = 0;\n  if (chk_calls)\n    abort ();\n}\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\t  u2.buf[off2 + len] = '\\0';\n\n\t  p = strcpy (u1.buf + off1, u2.buf + off2);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  if (*q++ != '\\0')\n\t    abort ();\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  const char *l;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  chk_calls = 0;\n  strcpy (a.buf1 + 2, s3 + 3);\n  strcpy (r, s3 + 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  strcpy (r, s2 + 2);\n  strcpy (r + 2, s3 + 3);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  strcpy (r, s2 + 4);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  strcpy (a.buf1 + 2, \"\");\n  strcpy (r, \"a\");\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  strcpy (r, s1 + 1);\n  r = buf3;\n  l = \"abc\";\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = \"e\";\n      else if (i == l1)\n\tr = &a.buf2[7], l = \"gh\";\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = \"jkl\";\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = \"\";\n    }\n  strcpy (r, \"\");\n  /* Here, strlen (l) + 1 is known to be at most 4 and\n     __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need\n     runtime checking.  */\n  strcpy (&buf3[16], l);\n  /* Unknown destination and source, no checking.  */\n  strcpy (s4, s3);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcpy (&a.buf2[9], s2 + 3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcpy (&a.buf2[7], s3 + strlen (s3) - 3);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strcpy (&buf3[19], \"a\");\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  test2 ();\n  s4 = p;\n  test3 ();\n  test4 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy-lib.c",
    "content": "#include \"lib/strcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure builtin memcpy and strcpy perform correctly.\n\n   Written by Jakub Jelinek, 11/24/2000.  */\n\nextern void abort (void);\nextern char *strcpy (char *, const char *);\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\n\nchar p[32] = \"\";\n\nvoid\nmain_test (void)\n{\n  if (strcpy (p, \"abcde\") != p || memcmp (p, \"abcde\", 6))\n    abort ();\n  if (strcpy (p + 16, \"vwxyz\" + 1) != p + 16 || memcmp (p + 16, \"wxyz\", 5))\n    abort ();\n  if (strcpy (p + 1, \"\") != p + 1 || memcmp (p, \"a\\0cde\", 6))\n    abort ();  \n  if (strcpy (p + 3, \"fghij\") != p + 3 || memcmp (p, \"a\\0cfghij\", 9))\n    abort ();\n  if (memcpy (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n  if (memcpy (p + 16, \"VWX\" + 1, 2) != p + 16 || memcmp (p + 16, \"WXyz\", 5))\n    abort ();\n  if (memcpy (p + 1, \"\", 1) != p + 1 || memcmp (p, \"A\\0CDE\", 6))\n    abort ();  \n  if (memcpy (p + 3, \"FGHI\", 4) != p + 3 || memcmp (p, \"A\\0CFGHIj\", 9))\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strcpy (p, \"abcde\") != p || memcmp (p, \"abcde\", 6))\n    abort ();\n  if (__builtin_memcpy (p, \"ABCDE\", 6) != p || memcmp (p, \"ABCDE\", 6))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn-lib.c",
    "content": "#include \"lib/strcspn.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strcspn.c",
    "content": "/* Copyright (C) 2000, 2004  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strcspn occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/27/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strcspn (const char *, const char *);\nextern char *strcpy (char *, const char *);\n\nvoid\nmain_test (void)\n{\n  const char *const s1 = \"hello world\";\n  char dst[64], *d2;\n  \n  if (strcspn (s1, \"hello\") != 0)\n    abort();\n  if (strcspn (s1, \"z\") != 11)\n    abort();\n  if (strcspn (s1+4, \"z\") != 7)\n    abort();\n  if (strcspn (s1, \"hello world\") != 0)\n    abort();\n  if (strcspn (s1, \"\") != 11)\n    abort();\n  strcpy (dst, s1);\n  if (strcspn (dst, \"\") != 11)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strcspn (++d2, \"\") != 10 || d2 != dst+1)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strcspn (++d2+5, \"\") != 5 || d2 != dst+1)\n    abort();\n  if (strcspn (\"\", s1) != 0)\n    abort();\n  strcpy (dst, s1);\n  if (strcspn (\"\", dst) != 0)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strcspn (\"\", ++d2) != 0 || d2 != dst+1)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strcspn (\"\", ++d2+5) != 0 || d2 != dst+1)\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strcspn (s1, \"z\") != 11)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2-lib.c",
    "content": "#include \"lib/strlen.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-2.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test strlen optimizations on conditional expressions.\n      \n   Written by Jakub Jelinek, June 23, 2003.  */\n\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void abort (void);\nextern int inside_main;\n\nsize_t g, h, i, j, k, l;\n\nsize_t\nfoo (void)\n{\n  if (l)\n    abort ();\n  return ++l;\n}\n\nvoid\nmain_test (void)\n{\n  if (strlen (i ? \"foo\" + 1 : j ? \"bar\" + 1 : \"baz\" + 1) != 2)\n    abort ();\n  if (strlen (g++ ? \"foo\" : \"bar\") != 3 || g != 1)\n    abort ();\n  if (strlen (h++ ? \"xfoo\" + 1 : \"bar\") != 3 || h != 1)\n    abort ();\n  if (strlen ((i++, \"baz\")) != 3 || i != 1)\n    abort ();\n  /* The following calls might not optimize strlen call away.  */\n  inside_main = 0;\n  if (strlen (j ? \"foo\" + k++ : \"bar\" + k++) != 3 || k != 1)\n    abort ();\n  if (strlen (foo () ? \"foo\" : \"bar\") != 3 || l != 1)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3-lib.c",
    "content": "#include \"lib/strlen.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-3.c",
    "content": "/* Copyright (C) 2004  Free Software Foundation.\n\n   Test strlen on const variables initialized to string literals.\n\n   Written by Jakub Jelinek, 9/14/2004.  */\n\nextern void abort (void);\nextern __SIZE_TYPE__ strlen (const char *);\nextern char *strcpy (char *, const char *);\nstatic const char bar[] = \"Hello, World!\";\nstatic const char baz[] = \"hello, world?\";\nstatic const char larger[20] = \"short string\";\nextern int inside_main;\n\nint l1 = 1;\nint x = 6;\n\nvoid\nmain_test(void)\n{\n#ifdef __OPTIMIZE__\n  const char *foo;\n  int i;\n#endif\n\n  if (strlen (bar) != 13)\n    abort ();\n\n  if (strlen (bar + 3) != 10)\n    abort ();\n\n  if (strlen (&bar[6]) != 7)\n    abort ();\n\n  if (strlen (bar + (x++ & 7)) != 7)\n    abort ();\n  if (x != 7)\n    abort ();\n\n#ifdef __OPTIMIZE__\n  foo = bar;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tfoo = \"HELLO, WORLD!\";\n      else if (i == l1)\n\tfoo = bar;\n      else if (i == l1 + 1)\n\tfoo = \"hello, world!\";\n      else\n\tfoo = baz;\n    }\n  if (strlen (foo) != 13)\n    abort ();\n#endif\n\n  if (strlen (larger) != 12)\n    abort ();\n  if (strlen (&larger[10]) != 2)\n    abort ();\n\n  inside_main = 0;\n  /* This will result in strlen call, because larger\n     array is bigger than its initializer.  */\n  if (strlen (larger + (x++ & 7)) != 5)\n    abort ();\n  if (x != 8)\n    abort ();\n  inside_main = 1;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen-lib.c",
    "content": "#include \"lib/strlen.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strlen.c",
    "content": "/* Copyright (C) 2000, 2001, 2003, 2004  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strlen\n   occur and perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.\n\n   Additional tests written by Roger Sayle, 11/02/2001:\n   Ensure all builtin strlen comparisons against zero are optimized\n   and perform correctly. The multiple calls to strcpy are to prevent\n   the potentially \"pure\" strlen calls from being removed by CSE.\n\n   Modified by Ben Elliston, 2006-10-25:\n   The multiple calls to strcpy that Roger mentions above are\n   problematic on systems where strcpy is implemented using strlen\n   (which this test overrides to call abort).  So, rather than use\n   strcpy, we perform the identical operations using array indexing\n   and char assignments.  */\n\nextern void abort (void);\nextern __SIZE_TYPE__ strlen (const char *);\nextern char *strcpy (char *, const char *);\n\nint x = 6;\n\nvoid\nmain_test(void)\n{\n  const char *const foo = \"hello world\";\n  char str[8];\n  char *ptr;\n\n  if (strlen (foo) != 11)\n    abort ();\n  if (strlen (foo + 4) != 7)\n    abort ();\n  if (strlen (foo + (x++ & 7)) != 5)\n    abort ();\n  if (x != 7)\n    abort ();\n\n  ptr = str;\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (ptr) == 0)\n    abort ();\n\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (ptr) < 1)\n    abort ();\n\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (ptr) <= 0)\n    abort ();\n\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (ptr+3) != 0)\n    abort ();\n\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (ptr+3) > 0)\n    abort ();\n\n  ptr[0] = 'n'; ptr[1] = 't'; ptr[2] = 's'; ptr[3] = '\\0';\n  if (strlen (str+3) >= 1)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strlen (foo) != 11)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __strncat_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcat (char *, const char *);\nextern char *strncat (char *, const char *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int strcmp (const char *, const char *);\nextern void *memset (void *, int, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nchar *s5;\nint x = 123;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  const char *const s1 = \"hello world\";\n  const char *const s2 = \"\";\n  const char *s3;\n  char dst[64], *d2;\n\n  /* Following strncat calls should be all optimized out.  */\n  chk_calls = 0;\n  strncat_disallowed = 1;\n  strcat_disallowed = 1;\n  strcpy (dst, s1);\n  if (strncat (dst, \"\", 100) != dst || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1);\n  if (strncat (dst, s2, 100) != dst || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (strncat (++d2, s2, 100) != dst+1 || d2 != dst+1 || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (strncat (++d2+5, s2, 100) != dst+6 || d2 != dst+1 || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (strncat (++d2+5, s1+11, 100) != dst+6 || d2 != dst+1 || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (strncat (++d2+5, s1, 0) != dst+6 || d2 != dst+1 || strcmp (dst, s1))\n    abort ();\n  strcpy (dst, s1); d2 = dst; s3 = s1;\n  if (strncat (++d2+5, ++s3, 0) != dst+6 || d2 != dst+1 || strcmp (dst, s1)\n      || s3 != s1 + 1)\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (strncat (++d2+5, \"\", ++x) != dst+6 || d2 != dst+1 || x != 124\n      || strcmp (dst, s1))\n    abort ();\n  if (chk_calls)\n    abort ();\n  strcat_disallowed = 0;\n\n  /* These __strncat_chk calls should be optimized into __strcat_chk,\n     as strlen (src) <= len.  */\n  strcpy (dst, s1);\n  if (strncat (dst, \"foo\", 3) != dst || strcmp (dst, \"hello worldfoo\"))\n    abort ();\n  strcpy (dst, s1);\n  if (strncat (dst, \"foo\", 100) != dst || strcmp (dst, \"hello worldfoo\"))\n    abort ();\n  strcpy (dst, s1);\n  if (strncat (dst, s1, 100) != dst || strcmp (dst, \"hello worldhello world\"))\n    abort ();\n  if (chk_calls != 3)\n    abort ();\n\n  chk_calls = 0;\n  /* The following calls have side-effects in dest, so are not checked.  */\n  strcpy (dst, s1); d2 = dst;\n  if (__builtin___strncat_chk (++d2, s1, 100, os (++d2)) != dst+1\n      || d2 != dst+1 || strcmp (dst, \"hello worldhello world\"))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (__builtin___strncat_chk (++d2+5, s1, 100, os (++d2+5)) != dst+6\n      || d2 != dst+1 || strcmp (dst, \"hello worldhello world\"))\n    abort ();\n  strcpy (dst, s1); d2 = dst;\n  if (__builtin___strncat_chk (++d2+5, s1+5, 100, os (++d2+5)) != dst+6\n      || d2 != dst+1 || strcmp (dst, \"hello world world\"))\n    abort ();\n  if (chk_calls)\n    abort ();\n\n  chk_calls = 0;\n  strcat_disallowed = 1;\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  strcpy (dst, s1);\n  if (__builtin_strncat (dst, \"\", 100) != dst || strcmp (dst, s1))\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  strncat_disallowed = 0;\n  strcat_disallowed = 0;\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n\n  /* The following calls should do runtime checking.  */\n  memset (&a, '\\0', sizeof (a));\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  chk_calls = 0;\n  strncat (a.buf1 + 2, s3 + 3, l1 - 1);\n  strncat (r, s3 + 2, l1);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, '\\0', 3);\n  __asm __volatile (\"\" : : \"r\" (r) : \"memory\");\n  strncat (r, s2 + 2, l1 + 1);\n  strncat (r + 2, s3 + 3, l1 - 1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  strncat (r, s2 + 4, l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known source length,\n     but we don't know the length of dest string, so runtime checking\n     is needed too.  */\n  memset (&a, '\\0', sizeof (a));\n  chk_calls = 0;\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  strncat (a.buf1 + 2, \"a\", 5);\n  strncat (r, \"def\", 0);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  memset (r, '\\0', 3);\n  __asm __volatile (\"\" : : \"r\" (r) : \"memory\");\n  strncat (r, s1 + 1, 2);\n  if (chk_calls != 2)\n    abort ();\n  chk_calls = 0;\n  strcat_disallowed = 1;\n  /* Unknown destination and source, no checking.  */\n  strncat (s4, s3, l1 + 1);\n  strcat_disallowed = 0;\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  memset (&a, '\\0', sizeof (a));\n  memset (buf3, '\\0', sizeof (buf3));\n  s5 = (char *) &a;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  s5 = buf3;\n  __asm __volatile (\"\" : : \"r\" (s5) : \"memory\");\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncat (&a.buf2[9], s2 + 3, 4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncat (&a.buf2[7], s3 + strlen (s3) - 3, 3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncat (&buf3[19], \"abcde\", 1);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  memset (p, '\\0', sizeof (p));\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncat-lib.c",
    "content": "#include \"lib/strncat.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncat.c",
    "content": "/* Copyright (C) 2000, 2003  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strncat occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/27/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern char *strncat (char *, const char *, size_t);\nextern char *strcpy (char *, const char *);\nextern void *memset (void *, int, size_t);\nextern int memcmp (const void *, const void *, size_t);\nint x = 123;\n\n/* Reset the destination buffer to a known state. */\n#define RESET_DST_WITH(FILLER) \\\n  do { memset (dst, 'X', sizeof (dst)); strcpy (dst, (FILLER)); } while (0)\n\nvoid\nmain_test (void)\n{\n  const char *const s1 = \"hello world\";\n  const char *const s2 = \"\";\n  char dst[64], *d2;\n  \n  RESET_DST_WITH (s1);\n  if (strncat (dst, \"\", 100) != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1);\n  if (strncat (dst, s2, 100) != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2, s2, 100) != dst+1 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, s2, 100) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, s1+11, 100) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, s1, 0) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, \"\", ++x) != dst+6 || d2 != dst+1 || x != 124\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n\n  RESET_DST_WITH (s1);\n  if (strncat (dst, \"foo\", 3) != dst || memcmp (dst, \"hello worldfoo\\0XXX\", 18))\n    abort();\n  RESET_DST_WITH (s1);\n  if (strncat (dst, \"foo\", 100) != dst || memcmp (dst, \"hello worldfoo\\0XXX\", 18))\n    abort();\n  RESET_DST_WITH (s1);\n  if (strncat (dst, s1, 100) != dst || memcmp (dst, \"hello worldhello world\\0XXX\", 26))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2, s1, 100) != dst+1 || d2 != dst+1\n      || memcmp (dst, \"hello worldhello world\\0XXX\", 26))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, s1, 100) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello worldhello world\\0XXX\", 26))\n    abort();\n  RESET_DST_WITH (s1); d2 = dst;\n  if (strncat (++d2+5, s1+5, 100) != dst+6 || d2 != dst+1\n      || memcmp (dst, \"hello world world\\0XXX\", 21))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  RESET_DST_WITH (s1);\n  if (__builtin_strncat (dst, \"\", 100) != dst\n      || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2-lib.c",
    "content": "#include \"lib/strncmp.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-2.c",
    "content": "/* Copyright (C) 2000, 2001, 2003, 2005  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strncmp occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/26/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern int strncmp (const char *, const char *, size_t);\n\nvoid\nmain_test (void)\n{\n#if !defined(__OPTIMIZE__) || ((defined(__sh__) || defined(__i386__) || defined (__x86_64__)) && !defined(__OPTIMIZE_SIZE__))\n  /* These tests work on platforms which support cmpstrsi.  We test it\n     at -O0 on all platforms to ensure the strncmp logic is correct.  */\n  const char *const s1 = \"hello world\";\n  const char *s2;\n  int n = 6, x;\n  \n  s2 = s1;\n  if (strncmp (++s2, \"ello\", 3) != 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"ello\", ++s2, 3) != 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"ello\", 4) != 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"ello\", ++s2, 4) != 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"ello\", 5) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"ello\", ++s2, 5) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"ello\", 6) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"ello\", ++s2, 6) >= 0 || s2 != s1+1)\n    abort();\n\n  s2 = s1;\n  if (strncmp (++s2, \"zllo\", 3) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"zllo\", ++s2, 3) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"zllo\", 4) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"zllo\", ++s2, 4) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"zllo\", 5) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"zllo\", ++s2, 5) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"zllo\", 6) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"zllo\", ++s2, 6) <= 0 || s2 != s1+1)\n    abort();\n\n  s2 = s1;\n  if (strncmp (++s2, \"allo\", 3) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"allo\", ++s2, 3) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"allo\", 4) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"allo\", ++s2, 4) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"allo\", 5) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"allo\", ++s2, 5) >= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"allo\", 6) <= 0 || s2 != s1+1)\n    abort();\n  s2 = s1;\n  if (strncmp (\"allo\", ++s2, 6) >= 0 || s2 != s1+1)\n    abort();\n\n  s2 = s1; n = 2; x = 1;\n  if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 2; x = 1;\n  if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (++s2, s1+(x&3), ++n) != 0 || s2 != s1+1 || n != 6)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (s1+(x&3), ++s2, ++n) != 0 || s2 != s1+1 || n != 6)\n    abort();\n\n  s2 = s1; n = 2;\n  if (strncmp (++s2, \"zllo\", ++n) >= 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 2; x = 1;\n  if (strncmp (\"zllo\", ++s2, ++n) <= 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (++s2, \"zllo\", ++n) >= 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (\"zllo\", ++s2, ++n) <= 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (++s2, \"zllo\", ++n) >= 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (\"zllo\", ++s2, ++n) <= 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (++s2, \"zllo\", ++n) >= 0 || s2 != s1+1 || n != 6)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (\"zllo\", ++s2, ++n) <= 0 || s2 != s1+1 || n != 6)\n    abort();\n\n  s2 = s1; n = 2;\n  if (strncmp (++s2, \"allo\", ++n) <= 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 2; x = 1;\n  if (strncmp (\"allo\", ++s2, ++n) >= 0 || s2 != s1+1 || n != 3)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (++s2, \"allo\", ++n) <= 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 3; x = 1;\n  if (strncmp (\"allo\", ++s2, ++n) >= 0 || s2 != s1+1 || n != 4)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (++s2, \"allo\", ++n) <= 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 4; x = 1;\n  if (strncmp (\"allo\", ++s2, ++n) >= 0 || s2 != s1+1 || n != 5)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (++s2, \"allo\", ++n) <= 0 || s2 != s1+1 || n != 6)\n    abort();\n  s2 = s1; n = 5; x = 1;\n  if (strncmp (\"allo\", ++s2, ++n) >= 0 || s2 != s1+1 || n != 6)\n    abort();\n\n#endif  \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp-lib.c",
    "content": "#include \"lib/strncmp.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncmp.c",
    "content": "/* Copyright (C) 2000, 2001, 2003  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strncmp occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/26/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern int strncmp (const char *, const char *, size_t);\n\nvoid\nmain_test (void)\n{\n  const char *const s1 = \"hello world\";\n  const char *s2, *s3;\n  \n  if (strncmp (s1, \"hello world\", 12) != 0)\n    abort();\n  if (strncmp (\"hello world\", s1, 12) != 0)\n    abort();\n  if (strncmp (\"hello\", \"hello\", 6) != 0)\n    abort();\n  if (strncmp (\"hello\", \"hello\", 2) != 0)\n    abort();\n  if (strncmp (\"hello\", \"hello\", 100) != 0)\n    abort();\n  if (strncmp (s1+10, \"d\", 100) != 0)\n    abort();\n  if (strncmp (10+s1, \"d\", 100) != 0)\n    abort();\n  if (strncmp (\"d\", s1+10, 1) != 0)\n    abort();\n  if (strncmp (\"d\", 10+s1, 1) != 0)\n    abort();\n  if (strncmp (\"hello\", \"aaaaa\", 100) <= 0)\n    abort();\n  if (strncmp (\"aaaaa\", \"hello\", 100) >= 0)\n    abort();\n  if (strncmp (\"hello\", \"aaaaa\", 1) <= 0)\n    abort();\n  if (strncmp (\"aaaaa\", \"hello\", 1) >= 0)\n    abort();\n\n  s2 = s1; s3 = s1+4;\n  if (strncmp (++s2, ++s3, 0) != 0 || s2 != s1+1 || s3 != s1+5)\n    abort();\n  s2 = s1;\n  if (strncmp (++s2, \"\", 1) <= 0 || s2 != s1+1)\n    abort();\n  if (strncmp (\"\", ++s2, 1) >= 0 || s2 != s1+2)\n    abort();\n  if (strncmp (++s2, \"\", 100) <= 0 || s2 != s1+3)\n    abort();\n  if (strncmp (\"\", ++s2, 100) >= 0 || s2 != s1+4)\n    abort();\n  if (strncmp (++s2+6, \"\", 100) != 0 || s2 != s1+5)\n    abort();\n  if (strncmp (\"\", ++s2+5, 100) != 0 || s2 != s1+6)\n    abort();\n  if (strncmp (\"ozz\", ++s2, 1) != 0 || s2 != s1+7)\n    abort();\n  if (strncmp (++s2, \"rzz\", 1) != 0 || s2 != s1+8)\n    abort();\n  s2 = s1; s3 = s1+4;\n  if (strncmp (++s2, ++s3+2, 1) >= 0 || s2 != s1+1 || s3 != s1+5)\n    abort();\n  \n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strncmp (\"hello\", \"a\", 100) <= 0)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __strncpy_chk performs correctly.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strncpy (char *, const char *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern int strcmp (const char *, const char *);\nextern int strncmp (const char *, const char *, size_t);\nextern void *memset (void *, int, size_t);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar * volatile s2 = \"defg\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\nchar * volatile s3 = \"FGH\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\nchar *s4;\nvolatile size_t l1 = 1;  /* prevent constant propagation to happen when whole program assumptions are made.  */\nint i;\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  const char *const src = \"hello world\";\n  const char *src2;\n  char dst[64], *dst2;\n\n  strncpy_disallowed = 1;\n  chk_calls = 0;\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst, src, 4) != dst || strncmp (dst, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst+16, src, 4) != dst+16 || strncmp (dst+16, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst+32, src+5, 4) != dst+32 || strncmp (dst+32, src+5, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  dst2 = dst;\n  if (strncpy (++dst2, src+5, 4) != dst+1 || strncmp (dst2, src+5, 4)\n      || dst2 != dst+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst, src, 0) != dst || strcmp (dst, \"\"))\n    abort();\n  \n  memset (dst, 0, sizeof (dst));\n  dst2 = dst; src2 = src;\n  if (strncpy (++dst2, ++src2, 0) != dst+1 || strcmp (dst2, \"\")\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  dst2 = dst; src2 = src;\n  if (strncpy (++dst2+5, ++src2+5, 0) != dst+6 || strcmp (dst2+5, \"\")\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst, src, 12) != dst || strcmp (dst, src))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  memset (dst, 0, sizeof (dst));\n  if (__builtin_strncpy (dst, src, 4) != dst || strncmp (dst, src, 4))\n    abort();\n\n  memset (dst, 0, sizeof (dst));\n  if (strncpy (dst, i++ ? \"xfoo\" + 1 : \"bar\", 4) != dst\n      || strcmp (dst, \"bar\")\n      || i != 1)\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  strncpy_disallowed = 0;\n}\n\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  chk_calls = 0;\n  /* No runtime checking should be done here, both destination\n     and length are unknown.  */\n  strncpy (s4, \"abcd\", l1 + 1);\n  if (chk_calls)\n    abort ();\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int i;\n  const char *l;\n  size_t l2;\n\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  chk_calls = 0;\n  strncpy (a.buf1 + 2, s3 + 3, l1);\n  strncpy (r, s3 + 2, l1 + 2);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  strncpy (r, s2 + 2, l1 + 2);\n  strncpy (r + 2, s3 + 3, l1);\n  r = buf3;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1];\n      else if (i == l1)\n\tr = &a.buf2[7];\n      else if (i == l1 + 1)\n\tr = &buf3[5];\n      else if (i == l1 + 2)\n\tr = &a.buf1[9];\n    }\n  strncpy (r, s2 + 4, l1);\n  if (chk_calls != 5)\n    abort ();\n\n  /* Following have known destination and known length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  strncpy (a.buf1 + 2, \"\", 3);\n  strncpy (a.buf1 + 2, \"\", 0);\n  strncpy (r, \"a\", 1);\n  strncpy (r, \"a\", 3);\n  r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n  strncpy (r, s1 + 1, 3);\n  strncpy (r, s1 + 1, 2);\n  r = buf3;\n  l = \"abc\";\n  l2 = 4;\n  for (i = 0; i < 4; ++i)\n    {\n      if (i == l1 - 1)\n\tr = &a.buf1[1], l = \"e\", l2 = 2;\n      else if (i == l1)\n\tr = &a.buf2[7], l = \"gh\", l2 = 3;\n      else if (i == l1 + 1)\n\tr = &buf3[5], l = \"jkl\", l2 = 4;\n      else if (i == l1 + 2)\n\tr = &a.buf1[9], l = \"\", l2 = 1;\n    }\n  strncpy (r, \"\", 1);\n  /* Here, strlen (l) + 1 is known to be at most 4 and\n     __builtin_object_size (&buf3[16], 0) is 4, so this doesn't need\n     runtime checking.  */\n  strncpy (&buf3[16], l, l2);\n  strncpy (&buf3[15], \"abc\", l2);\n  strncpy (&buf3[10], \"fghij\", l2);\n  if (chk_calls)\n    abort ();\n  chk_calls = 0;\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest4 (void)\n{\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncpy (&a.buf2[9], s2 + 4, l1 + 1);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncpy (&a.buf2[7], s3, l1 + 4);\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncpy (&buf3[19], \"abc\", 2);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      strncpy (&buf3[18], \"\", 3);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  test1 ();\n  s4 = p;\n  test2 ();\n  test3 ();\n  test4 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test4 struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy-lib.c",
    "content": "#include \"lib/strncpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strncpy.c",
    "content": "/* Copyright (C) 2000, 2005  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strncpy occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/25/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern char *strncpy (char *, const char *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\n\n/* Reset the destination buffer to a known state. */\n#define RESET_DST memset(dst, 'X', sizeof(dst))\n\nint i;\n\nvoid\nmain_test (void)\n{\n  const char *const src = \"hello world\";\n  const char *src2;\n  char dst[64], *dst2;\n  \n  RESET_DST;\n  if (strncpy (dst, src, 4) != dst || memcmp (dst, \"hellXXX\", 7))\n    abort();\n\n  RESET_DST;\n  if (strncpy (dst+16, src, 4) != dst+16 || memcmp (dst+16, \"hellXXX\", 7))\n    abort();\n\n  RESET_DST;\n  if (strncpy (dst+32, src+5, 4) != dst+32 || memcmp (dst+32, \" worXXX\", 7))\n    abort();\n\n  RESET_DST;\n  dst2 = dst;\n  if (strncpy (++dst2, src+5, 4) != dst+1 || memcmp (dst2, \" worXXX\", 7)\n      || dst2 != dst+1)\n    abort();\n\n  RESET_DST;\n  if (strncpy (dst, src, 0) != dst || memcmp (dst, \"XXX\", 3))\n    abort();\n  \n  RESET_DST;\n  dst2 = dst; src2 = src;\n  if (strncpy (++dst2, ++src2, 0) != dst+1 || memcmp (dst2, \"XXX\", 3)\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  RESET_DST;\n  dst2 = dst; src2 = src;\n  if (strncpy (++dst2+5, ++src2+5, 0) != dst+6 || memcmp (dst2+5, \"XXX\", 3)\n      || dst2 != dst+1 || src2 != src+1)\n    abort();\n\n  RESET_DST;\n  if (strncpy (dst, src, 12) != dst || memcmp (dst, \"hello world\\0XXX\", 15))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  RESET_DST;\n  if (__builtin_strncpy (dst, src, 4) != dst || memcmp (dst, \"hellXXX\", 7))\n    abort();\n\n  RESET_DST;\n  if (strncpy (dst, i++ ? \"xfoo\" + 1 : \"bar\", 4) != dst\n      || memcmp (dst, \"bar\\0XXX\", 7)\n      || i != 1)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk-lib.c",
    "content": "#include \"lib/strpbrk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpbrk.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strpbrk occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/6/2000.  */\n\nextern void abort(void);\nextern char *strpbrk (const char *, const char *);\nextern int strcmp (const char *, const char *);\n\nvoid fn (const char *foo, const char *const *bar)\n{\n  if (strcmp(strpbrk (\"hello world\", \"lrooo\"), \"llo world\") != 0)\n    abort();\n  if (strpbrk (foo, \"\") != 0)\n    abort();\n  if (strpbrk (foo + 4, \"\") != 0)\n    abort();\n  if (strpbrk (*bar--, \"\") != 0)\n    abort();\n  if (strpbrk (*bar, \"h\") != foo)\n    abort();\n  if (strpbrk (foo, \"h\") != foo)\n    abort();\n  if (strpbrk (foo, \"w\") != foo + 6)\n    abort();\n  if (strpbrk (foo + 6, \"o\") != foo + 7)\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strpbrk (foo + 6, \"o\") != foo + 7)\n    abort();\n}\n\nvoid\nmain_test (void)\n{\n  const char *const foo[] = { \"hello world\", \"bye bye world\" };\n  fn (foo[0], foo + 1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2-lib.c",
    "content": "#include \"lib/stpcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-2.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Ensure that builtin stpcpy performs correctly.\n\n   Written by Jakub Jelinek, 21/05/2003.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern int memcmp (const void *, const void *, size_t);\nextern char *stpcpy (char *, const char *);\nextern int inside_main;\n\nlong buf1[64];\nchar *buf2 = (char *) (buf1 + 32);\nlong buf5[20];\nchar buf7[20];\n\nvoid\n__attribute__((noinline))\ntest (long *buf3, char *buf4, char *buf6, int n)\n{\n  int i = 4;\n\n  if (stpcpy ((char *) buf3, \"abcdefghijklmnop\") != (char *) buf1 + 16\n      || memcmp (buf1, \"abcdefghijklmnop\", 17))\n    abort ();\n\n  if (__builtin_stpcpy ((char *) buf3, \"ABCDEFG\") != (char *) buf1 + 7\n      || memcmp (buf1, \"ABCDEFG\\0ijklmnop\", 17))\n    abort ();\n\n  if (stpcpy ((char *) buf3 + i++, \"x\") != (char *) buf1 + 5\n      || memcmp (buf1, \"ABCDx\\0G\\0ijklmnop\", 17))\n    abort ();\n}\n\nvoid\nmain_test (void)\n{\n  /* All these tests are allowed to call mempcpy/stpcpy.  */\n  inside_main = 0;\n  __builtin_memcpy (buf5, \"RSTUVWXYZ0123456789\", 20);\n  __builtin_memcpy (buf7, \"RSTUVWXYZ0123456789\", 20);\n  test (buf1, buf2, \"rstuvwxyz\", 0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy-lib.c",
    "content": "#include \"lib/stpcpy.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strpcpy.c",
    "content": "/* Copyright (C) 2003, 2004  Free Software Foundation.\n\n   Ensure builtin stpcpy performs correctly.\n\n   Written by Kaveh Ghazi, 4/11/2003.  */\n\ntypedef __SIZE_TYPE__ size_t;\n\nextern void abort (void);\nextern char *strcpy (char *, const char *);\nextern char *stpcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\n\nextern int inside_main;\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nsize_t l1 = 1;\n\nvoid\nmain_test (void)\n{\n  int i = 8;\n\n#if !defined __i386__ && !defined __x86_64__\n  /* The functions below might not be optimized into direct stores on all\n     arches.  It depends on how many instructions would be generated and\n     what limits the architecture chooses in STORE_BY_PIECES_P.  */\n  inside_main = 0;\n#endif\n  if (stpcpy (p, \"abcde\") != p + 5 || memcmp (p, \"abcde\", 6))\n    abort ();\n  if (stpcpy (p + 16, \"vwxyz\" + 1) != p + 16 + 4 || memcmp (p + 16, \"wxyz\", 5))\n    abort ();\n  if (stpcpy (p + 1, \"\") != p + 1 + 0 || memcmp (p, \"a\\0cde\", 6))\n    abort ();\n  if (stpcpy (p + 3, \"fghij\") != p + 3 + 5 || memcmp (p, \"a\\0cfghij\", 9))\n    abort ();\n\n  if (stpcpy ((i++, p + 20 + 1), \"23\") != (p + 20 + 1 + 2)\n      || i != 9 || memcmp (p + 19, \"z\\0\"\"23\\0\", 5))\n    abort ();\n\n  if (stpcpy (stpcpy (p, \"ABCD\"), \"EFG\") != p + 7 || memcmp (p, \"ABCDEFG\", 8))\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_stpcpy (p, \"abcde\") != p + 5 || memcmp (p, \"abcde\", 6))\n    abort ();\n\n    /* If the result of stpcpy is ignored, gcc should use strcpy.\n       This should be optimized always, so set inside_main again.  */\n  inside_main = 1;\n  stpcpy (p + 3, s3);\n  if (memcmp (p, \"abcFGH\", 6))\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr-lib.c",
    "content": "#include \"lib/strrchr.c\"\n#ifdef __vxworks\n/* The RTP C library uses bzero, bfill and bcopy, all of which are defined\n   in the same file as rindex.  */\n#include \"lib/bzero.c\"\n#include \"lib/bfill.c\"\n#include \"lib/memmove.c\"\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strrchr.c",
    "content": "/* Copyright (C) 2000, 2003, 2004  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strrchr and rindex\n   occur and perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.  */\n\nextern void abort (void);\nextern char *strrchr (const char *, int);\nextern char *rindex (const char *, int);\n\nchar *bar = \"hi world\";\nint x = 7;\n\nvoid\nmain_test (void)\n{\n  const char *const foo = \"hello world\";\n\n  if (strrchr (foo, 'x'))\n    abort ();\n  if (strrchr (foo, 'o') != foo + 7)\n    abort ();\n  if (strrchr (foo, 'e') != foo + 1)\n    abort ();\n  if (strrchr (foo + 3, 'e'))\n    abort ();\n  if (strrchr (foo, '\\0') != foo + 11)\n    abort ();\n  if (strrchr (bar, '\\0') != bar + 8)\n    abort ();\n  if (strrchr (bar + 4, '\\0') != bar + 8)\n    abort ();\n  if (strrchr (bar + (x++ & 3), '\\0') != bar + 8)\n    abort ();\n  if (x != 8)\n    abort ();\n  /* Test only one instance of rindex since the code path is the same\n     as that of strrchr. */\n  if (rindex (\"hello\", 'z') != 0)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strrchr (foo, 'o') != foo + 7)\n    abort ();\n  if (__builtin_rindex (foo, 'o') != foo + 7)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strspn-lib.c",
    "content": "#include \"lib/strspn.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strspn.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strspn occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/27/2000.  */\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strspn (const char *, const char *);\nextern char *strcpy (char *, const char *);\n\nvoid\nmain_test (void)\n{\n  const char *const s1 = \"hello world\";\n  char dst[64], *d2;\n  \n  if (strspn (s1, \"hello\") != 5)\n    abort();\n  if (strspn (s1+4, \"hello\") != 1)\n    abort();\n  if (strspn (s1, \"z\") != 0)\n    abort();\n  if (strspn (s1, \"hello world\") != 11)\n    abort();\n  if (strspn (s1, \"\") != 0)\n    abort();\n  strcpy (dst, s1);\n  if (strspn (dst, \"\") != 0)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strspn (++d2, \"\") != 0 || d2 != dst+1)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strspn (++d2+5, \"\") != 0 || d2 != dst+1)\n    abort();\n  if (strspn (\"\", s1) != 0)\n    abort();\n  strcpy (dst, s1);\n  if (strspn (\"\", dst) != 0)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strspn (\"\", ++d2) != 0 || d2 != dst+1)\n    abort();\n  strcpy (dst, s1); d2 = dst;\n  if (strspn (\"\", ++d2+5) != 0 || d2 != dst+1)\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strspn (s1, \"hello\") != 5)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm-lib.c",
    "content": "extern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern char *strchr(const char *, int);\nextern int strcmp(const char *, const char *);\nextern int strncmp(const char *, const char *, size_t);\nextern int inside_main;\nextern const char *p;\n\n__attribute__ ((used))\nchar *\nmy_strstr (const char *s1, const char *s2)\n{\n  const size_t len = strlen (s2);\n\n#ifdef __OPTIMIZE__\n  /* If optimizing, we should be called only in the strstr (foo + 2, p)\n     case.  All other cases should be optimized.  */\n  if (inside_main)\n    if (s2 != p || strcmp (s1, \"hello world\" + 2) != 0)\n      abort ();\n#endif\n  if (len == 0)\n    return (char *) s1;\n  for (s1 = strchr (s1, *s2); s1; s1 = strchr (s1 + 1, *s2))\n    if (strncmp (s1, s2, len) == 0)\n      return (char *) s1;\n  return (char *) 0;\n}\n\nchar *\nstrstr (const char *s1, const char *s2)\n{\n  if (inside_main)\n    abort ();\n\n  return my_strstr (s1, s2);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm.c",
    "content": "/* Copyright (C) 2000, 2003  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strstr occur and\n   perform correctly in presence of redirect.  */\n\n#define ASMNAME(cname)  ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n#define ASMNAME2(prefix, cname) STRING (prefix) cname\n#define STRING(x)    #x\n\ntypedef __SIZE_TYPE__ size_t;\nextern void abort (void);\nextern char *strstr (const char *, const char *)\n  __asm (ASMNAME (\"my_strstr\"));\n\nconst char *p = \"rld\", *q = \"hello world\";\n\nvoid\nmain_test (void)\n{\n  const char *const foo = \"hello world\";\n\n  if (strstr (foo, \"\") != foo)\n    abort ();\n  if (strstr (foo + 4, \"\") != foo + 4)\n    abort ();\n  if (strstr (foo, \"h\") != foo)\n    abort ();\n  if (strstr (foo, \"w\") != foo + 6)\n    abort ();\n  if (strstr (foo + 6, \"o\") != foo + 7)\n    abort ();\n  if (strstr (foo + 1, \"world\") != foo + 6)\n    abort ();\n  if (strstr (foo + 2, p) != foo + 8)\n    abort ();\n  if (strstr (q, \"\") != q)\n    abort ();\n  if (strstr (q + 1, \"o\") != q + 4)\n    abort ();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strstr (foo + 1, \"world\") != foo + 6)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-asm.x",
    "content": "# Different translation units may have different user name overrides\n# and we do not preserve enough context to known which one we want.\n\nset torture_eval_before_compile {\n  if {[string match {*-flto*} \"$option\"]} {\n    continue\n  }\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strstr-lib.c",
    "content": "#include \"lib/strstr.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/strstr.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure all expected transformations of builtin strstr occur and\n   perform correctly.\n\n   Written by Kaveh R. Ghazi, 11/6/2000.  */\n\nextern void abort(void);\nextern char *strstr (const char *, const char *);\n\nvoid\nmain_test (void)\n{\n  const char *const foo = \"hello world\";\n  \n  if (strstr (foo, \"\") != foo)\n    abort();\n  if (strstr (foo + 4, \"\") != foo + 4)\n    abort();\n  if (strstr (foo, \"h\") != foo)\n    abort();\n  if (strstr (foo, \"w\") != foo + 6)\n    abort();\n  if (strstr (foo + 6, \"o\") != foo + 7)\n    abort();\n  if (strstr (foo + 1, \"world\") != foo + 6)\n    abort();\n\n  /* Test at least one instance of the __builtin_ style.  We do this\n     to ensure that it works and that the prototype is correct.  */\n  if (__builtin_strstr (foo + 1, \"world\") != foo + 6)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsnprintf-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsnprintf-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __vsnprintf_chk performs correctly.  */\n\n#include <stdarg.h>\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\nextern int vsnprintf (char *, size_t, const char *, va_list);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nstatic char buffer[32];\nchar * volatile ptr = \"barf\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nint\n__attribute__((noinline))\ntest1_sub (int i, ...)\n{\n  int ret = 0;\n  va_list ap;\n  va_start (ap, i);\n  switch (i)\n    {\n    case 0:\n      vsnprintf (buffer, 4, \"foo\", ap);\n      break;\n    case 1:\n      ret = vsnprintf (buffer, 4, \"foo bar\", ap);\n      break;\n    case 2:\n      vsnprintf (buffer, 32, \"%s\", ap);\n      break;\n    case 3:\n      ret = vsnprintf (buffer, 21, \"%s\", ap);\n      break;\n    case 4:\n      ret = vsnprintf (buffer, 4, \"%d%d%d\", ap);\n      break;\n    case 5:\n      ret = vsnprintf (buffer, 32, \"%d%d%d\", ap);\n      break;\n    case 6:\n      ret = vsnprintf (buffer, strlen (ptr) + 1, \"%s\", ap);\n      break;\n    case 7:\n      vsnprintf (buffer, l1 + 31, \"%d - %c\", ap);\n      break;\n    case 8:\n      vsnprintf (s4, l1 + 6, \"%d - %c\", ap);\n      break;\n    }\n  va_end (ap);\n  return ret;\n}\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  chk_calls = 0;\n  /* vsnprintf_disallowed = 1; */\n\n  memset (buffer, 'A', 32);\n  test1_sub (0);\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (1) != 7)\n    abort ();\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  vsnprintf_disallowed = 0;\n\n  memset (buffer, 'A', 32);\n  test1_sub (2, \"bar\");\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (3, \"bar\") != 3)\n    abort ();\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (4, (int) l1, (int) l1 + 1, (int) l1 + 12) != 4)\n    abort ();\n  if (memcmp (buffer, \"121\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (5, (int) l1, (int) l1 + 1, (int) l1 + 12) != 4)\n    abort ();\n  if (memcmp (buffer, \"1213\", 5) || buffer[5] != 'A')\n    abort ();\n\n  if (chk_calls)\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test1_sub (6, ptr);\n  if (memcmp (buffer, \"barf\", 5) || buffer[5] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test1_sub (7, (int) l1 + 27, *ptr);\n  if (memcmp (buffer, \"28 - b\\0AAAAA\", 12))\n    abort ();\n\n  if (chk_calls != 2)\n    abort ();\n  chk_calls = 0;\n\n  memset (s4, 'A', 32);\n  test1_sub (8, (int) l1 - 17, ptr[1]);\n  if (memcmp (s4, \"-16 - \\0AAA\", 10))\n    abort ();\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2_sub (int i, ...)\n{\n  va_list ap;\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int j;\n\n  va_start (ap, i);\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  switch (i)\n    {\n    case 0:\n      vsnprintf (a.buf1 + 2, l1, \"%s\", ap);\n      break;\n    case 1:\n      vsnprintf (r, l1 + 4, \"%s%c\", ap);\n      break;\n    case 2:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsnprintf (r, strlen (s2) - 2, \"%c %s\", ap);\n      break;\n    case 3:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsnprintf (r + 2, l1, s3 + 3, ap);\n      break;\n    case 4:\n    case 7:\n      r = buf3;\n      for (j = 0; j < 4; ++j)\n\t{\n\t  if (j == l1 - 1)\n\t    r = &a.buf1[1];\n\t  else if (j == l1)\n\t    r = &a.buf2[7];\n\t  else if (j == l1 + 1)\n\t    r = &buf3[5];\n\t  else if (j == l1 + 2)\n\t    r = &a.buf1[9];\n\t}\n      if (i == 4)\n\tvsnprintf (r, l1, s2 + 4, ap);\n      else\n\tvsnprintf (r, 1, \"a\", ap);\n      break;\n    case 5:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsnprintf (r, l1 + 3, \"%s\", ap);\n      break;\n    case 6:\n      vsnprintf (a.buf1 + 2, 4, \"\", ap);\n      break;\n    case 8:\n      vsnprintf (s4, 3, \"%s %d\", ap);\n      break;\n    }\n  va_end (ap);\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  /* The following calls should do runtime checking\n     - length is not known, but destination is.  */\n  chk_calls = 0;\n  test2_sub (0, s3 + 3);\n  test2_sub (1, s3 + 3, s3[3]);\n  test2_sub (2, s2[2], s2 + 4);\n  test2_sub (3);\n  test2_sub (4);\n  test2_sub (5, s1 + 1);\n  if (chk_calls != 6)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  /* vsnprintf_disallowed = 1; */\n  test2_sub (6);\n  test2_sub (7);\n  vsnprintf_disallowed = 0;\n  /* Unknown destination and source, no checking.  */\n  test2_sub (8, s3, 0);\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest3_sub (int i, ...)\n{\n  va_list ap;\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  va_start (ap, i);\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  switch (i)\n    {\n    case 0:\n      vsnprintf (&a.buf2[9], l1 + 1, \"%c%s\", ap);\n      break;\n    case 1:\n      vsnprintf (&a.buf2[7], l1 + 30, \"%s%c\", ap);\n      break;\n    case 2:\n      vsnprintf (&a.buf2[7], l1 + 3, \"%d\", ap);\n      break;\n    case 3:\n      vsnprintf (&buf3[17], l1 + 3, \"%s\", ap);\n      break;\n    case 4:\n      vsnprintf (&buf3[19], 2, \"a\", ap);\n      break;\n    case 5:\n      vsnprintf (&buf3[16], 5, \"a\", ap);\n      break;\n    }\n  va_end (ap);\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (0, s2[3], s2 + 4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (1, s3 + strlen (s3) - 2, *s3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (2, (int) l1 + 9999);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (3, \"abc\");\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (5);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsnprintf-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3_sub struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsprintf-chk-lib.c",
    "content": "#include \"lib/chk.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsprintf-chk.c",
    "content": "/* Copyright (C) 2004, 2005  Free Software Foundation.\n\n   Ensure builtin __vsprintf_chk performs correctly.  */\n\n#include <stdarg.h>\n\nextern void abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen(const char *);\nextern void *memcpy (void *, const void *, size_t);\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memset (void *, int, size_t);\nextern int vsprintf (char *, const char *, va_list);\n\n#include \"chk.h\"\n\nconst char s1[] = \"123\";\nchar p[32] = \"\";\nchar *s2 = \"defg\";\nchar *s3 = \"FGH\";\nchar *s4;\nsize_t l1 = 1;\nstatic char buffer[32];\nchar * volatile ptr = \"barf\";  /* prevent constant propagation to happen when whole program assumptions are made.  */\n\nint\n__attribute__((noinline))\ntest1_sub (int i, ...)\n{\n  int ret = 0;\n  va_list ap;\n  va_start (ap, i);\n  switch (i)\n    {\n    case 0:\n      vsprintf (buffer, \"foo\", ap);\n      break;\n    case 1:\n      ret = vsprintf (buffer, \"foo\", ap);\n      break;\n    case 2:\n      vsprintf (buffer, \"%s\", ap);\n      break;\n    case 3:\n      ret = vsprintf (buffer, \"%s\", ap);\n      break;\n    case 4:\n      vsprintf (buffer, \"%d - %c\", ap);\n      break;\n    case 5:\n      vsprintf (s4, \"%d - %c\", ap);\n      break;\n    }\n  va_end (ap);\n  return ret;\n}\n\nvoid\n__attribute__((noinline))\ntest1 (void)\n{\n  chk_calls = 0;\n  vsprintf_disallowed = 1;\n\n  memset (buffer, 'A', 32);\n  test1_sub (0);\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (1) != 3)\n    abort ();\n  if (memcmp (buffer, \"foo\", 4) || buffer[4] != 'A')\n    abort ();\n\n  if (chk_calls)\n    abort ();\n  vsprintf_disallowed = 0;\n\n  memset (buffer, 'A', 32);\n  test1_sub (2, \"bar\");\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  if (test1_sub (3, \"bar\") != 3)\n    abort ();\n  if (memcmp (buffer, \"bar\", 4) || buffer[4] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test1_sub (2, ptr);\n  if (memcmp (buffer, \"barf\", 5) || buffer[5] != 'A')\n    abort ();\n\n  memset (buffer, 'A', 32);\n  test1_sub (4, (int) l1 + 27, *ptr);\n  if (memcmp (buffer, \"28 - b\\0AAAAA\", 12))\n    abort ();\n\n  if (chk_calls != 4)\n    abort ();\n  chk_calls = 0;\n\n  test1_sub (5, (int) l1 - 17, ptr[1]);\n  if (memcmp (s4, \"-16 - a\", 8))\n    abort ();\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest2_sub (int i, ...)\n{\n  va_list ap;\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char *r = l1 == 1 ? &a.buf1[5] : &a.buf2[4];\n  char buf3[20];\n  int j;\n\n  va_start (ap, i);\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  switch (i)\n    {\n    case 0:\n      vsprintf (a.buf1 + 2, \"%s\", ap);\n      break;\n    case 1:\n      vsprintf (r, \"%s%c\", ap);\n      break;\n    case 2:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsprintf (r, \"%c %s\", ap);\n      break;\n    case 3:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsprintf (r + 2, s3 + 3, ap);\n      break;\n    case 4:\n    case 7:\n      r = buf3;\n      for (j = 0; j < 4; ++j)\n\t{\n\t  if (j == l1 - 1)\n\t    r = &a.buf1[1];\n\t  else if (j == l1)\n\t    r = &a.buf2[7];\n\t  else if (j == l1 + 1)\n\t    r = &buf3[5];\n\t  else if (j == l1 + 2)\n\t    r = &a.buf1[9];\n\t}\n      if (i == 4)\n\tvsprintf (r, s2 + 4, ap);\n      else\n\tvsprintf (r, \"a\", ap);\n      break;\n    case 5:\n      r = l1 == 1 ? __builtin_alloca (4) : &a.buf2[7];\n      vsprintf (r, \"%s\", ap);\n      break;\n    case 6:\n      vsprintf (a.buf1 + 2, \"\", ap);\n      break;\n    case 8:\n      vsprintf (s4, \"%s %d\", ap);\n      break;\n    }\n  va_end (ap);\n}\n\n/* Test whether compile time checking is done where it should\n   and so is runtime object size checking.  */\nvoid\n__attribute__((noinline))\ntest2 (void)\n{\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  chk_calls = 0;\n  test2_sub (0, s3 + 3);\n  test2_sub (1, s3 + 3, s3[3]);\n  test2_sub (2, s2[2], s2 + 4);\n  test2_sub (3);\n  test2_sub (4);\n  test2_sub (5, s1 + 1);\n  if (chk_calls != 6)\n    abort ();\n\n  /* Following have known destination and known source length,\n     so if optimizing certainly shouldn't result in the checking\n     variants.  */\n  chk_calls = 0;\n  vsprintf_disallowed = 1;\n  test2_sub (6);\n  test2_sub (7);\n  vsprintf_disallowed = 0;\n  /* Unknown destination and source, no checking.  */\n  test2_sub (8, s3, 0);\n  if (chk_calls)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\ntest3_sub (int i, ...)\n{\n  va_list ap;\n  struct A { char buf1[10]; char buf2[10]; } a;\n  char buf3[20];\n\n  va_start (ap, i);\n  /* The following calls should do runtime checking\n     - source length is not known, but destination is.  */\n  switch (i)\n    {\n    case 0:\n      vsprintf (&a.buf2[9], \"%c%s\", ap);\n      break;\n    case 1:\n      vsprintf (&a.buf2[7], \"%s%c\", ap);\n      break;\n    case 2:\n      vsprintf (&a.buf2[7], \"%d\", ap);\n      break;\n    case 3:\n      vsprintf (&buf3[17], \"%s\", ap);\n      break;\n    case 4:\n      vsprintf (&buf3[19], \"a\", ap);\n      break;\n    }\n  va_end (ap);\n}\n\n/* Test whether runtime and/or compile time checking catches\n   buffer overflows.  */\nvoid\n__attribute__((noinline))\ntest3 (void)\n{\n  chk_fail_allowed = 1;\n  /* Runtime checks.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (0, s2[3], s2 + 4);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (1, s3 + strlen (s3) - 2, *s3);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (2, (int) l1 + 9999);\n      abort ();\n    }\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (3, \"abc\");\n      abort ();\n    }\n  /* This should be detectable at compile time already.  */\n  if (__builtin_setjmp (chk_fail_buf) == 0)\n    {\n      test3_sub (4);\n      abort ();\n    }\n  chk_fail_allowed = 0;\n}\n\nvoid\nmain_test (void)\n{\n#ifndef __OPTIMIZE__\n  /* Object size checking is only intended for -O[s123].  */\n  return;\n#endif\n  __asm (\"\" : \"=r\" (s2) : \"0\" (s2));\n  __asm (\"\" : \"=r\" (s3) : \"0\" (s3));\n  __asm (\"\" : \"=r\" (l1) : \"0\" (l1));\n  s4 = p;\n  test1 ();\n  test2 ();\n  test3 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/vsprintf-chk.x",
    "content": "load_lib target-supports.exp\n\nif { ! [check_effective_target_nonlocal_goto] } {\n    return 1\n}\n\nif [istarget \"epiphany-*-*\"] {\n    # This test assumes the absence of struct padding.\n    # to make this true for test3_sub struct A on epiphany would require\n    # __attribute__((packed)) .\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/call-trap-1.c",
    "content": "/* Undefined behavior from a call to a function cast to a different\n   type does not appear until after the function designator and\n   arguments have been evaluated.  PR 38483.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n/* { dg-require-effective-target untyped_assembly } */\n\nextern void exit (int);\nextern void abort (void);\n\nint\nfoo (void)\n{\n  exit (0);\n  return 0;\n}\n\nvoid\nbar (void)\n{\n}\n\nint\nmain (void)\n{\n  ((long (*)(int))bar) (foo ());\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cbrt.c",
    "content": "/*\n * ====================================================\n * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n *\n * Developed at SunPro, a Sun Microsystems, Inc. business.\n * Permission to use, copy, modify, and distribute this\n * software is freely granted, provided that this notice\n * is preserved.\n * ====================================================\n*/\n\n#ifndef __vax__\nstatic const unsigned long\n\tB1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */\n\tB2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */\n\nstatic const double\n\tC =  5.42857142857142815906e-01, /* 19/35     = 0x3FE15F15, 0xF15F15F1 */\n\tD = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */\n\tE =  1.41428571428571436819e+00, /* 99/70     = 0x3FF6A0EA, 0x0EA0EA0F */\n\tF =  1.60714285714285720630e+00, /* 45/28     = 0x3FF9B6DB, 0x6DB6DB6E */\n\tG =  3.57142857142857150787e-01; /* 5/14      = 0x3FD6DB6D, 0xB6DB6DB7 */\n\ndouble\ncbrtl (double x)\n{\n  long hx;\n  double r,s,w;\n  double lt;\n  unsigned sign;\n  typedef unsigned unsigned32 __attribute__((mode(SI)));\n  union {\n    double t;\n    unsigned32 pt[2];\n  } ut, ux;\n  int n0;\n\n  ut.t = 1.0;\n  n0 = (ut.pt[0] == 0);\n\n  ut.t = 0.0;\n  ux.t = x;\n\n  hx = ux.pt[n0];\t\t\t/* high word of x */\n  sign=hx&0x80000000;\t\t\t/* sign= sign(x) */\n  hx  ^=sign;\n  if(hx>=0x7ff00000) return(x+x);\t/* cbrt(NaN,INF) is itself */\n  if((hx| ux.pt[1-n0])==0)\n    return(ux.t);\t\t\t/* cbrt(0) is itself */\n\n  ux.pt[n0] = hx;\n  /* rough cbrt to 5 bits */\n  if(hx<0x00100000)\t\t\t/* subnormal number */\n    {ut.pt[n0]=0x43500000;\t\t/* set t= 2**54 */\n     ut.t*=x; ut.pt[n0]=ut.pt[n0]/3+B2;\n   }\n  else\n    ut.pt[n0]=hx/3+B1;\n\n  /* new cbrt to 23 bits, may be implemented in single precision */\n  r=ut.t*ut.t/ux.t;\n  s=C+r*ut.t;\n  ut.t*=G+F/(s+E+D/s);\n\n  /* chopped to 20 bits and make it larger than cbrt(x) */\n  ut.pt[1-n0]=0; ut.pt[n0]+=0x00000001;\n\n  /* one step newton iteration to 53 bits with error less than 0.667 ulps */\n  s=ut.t*ut.t;\t\t\t\t/* t*t is exact */\n  r=ux.t/s;\n  w=ut.t+ut.t;\n  r=(r-ut.t)/(w+r);\t\t\t/* r-s is exact */\n  ut.t=ut.t+ut.t*r;\n\n  /* restore the sign bit */\n  ut.pt[n0] |= sign;\n\n  lt = ut.t;\n  lt -= (lt - (x/(lt*lt))) * 0.333333333333333333333;\n  return lt;\n}\n\nmain ()\n{\n  if ((int) (cbrtl (27.0) + 0.5) != 3)\n    abort ();\n\n  exit (0);\n}\n#else\nmain () { exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c",
    "content": "#define F 140\n#define T 13\n\nfeq (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfltu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfgeu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgtu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfleu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nlong long args[] =\n{\n  0LL,\n  1LL,\n  -1LL,\n  0x7fffffffffffffffLL,\n  0x8000000000000000LL,\n  0x8000000000000001LL,\n  0x1A3F237394D36C58LL,\n  0x93850E92CAAC1B04LL\n};\n\nint correct_results[] =\n{\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T\n};\n\nmain ()\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      long long arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  long long arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fltu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgeu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgtu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fleu (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cmpsf-1.c",
    "content": "#include <limits.h>\n\n#define F 140\n#define T 13\n\nfeq (float x, float y)\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (float x, float y)\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (float x, float y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (float x, float y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (float x, float y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (float x, float y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfloat args[] =\n{\n  0.0F,\n  1.0F,\n  -1.0F, \n  __FLT_MAX__,\n  __FLT_MIN__,\n  0.0000000000001F,\n  123456789.0F,\n  -987654321.0F\n};\n\nint correct_results[] =\n{\n T, F, F, T, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n T, F, F, T, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n T, F, F, T, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n T, F, F, T, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n T, F, F, T, F, T,\n};\n\nint\nmain (void)\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      float arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  float arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cmpsi-1.c",
    "content": "f1 (unsigned int x, unsigned int y)\n{\n  if (x == 0)\n    dummy ();\n  x -= y;\n  /* 0xfffffff2 < 0x80000000? */\n  if (x < ~(~(unsigned int) 0 >> 1))\n    abort ();\n  return x;\n}\n\nf2 (unsigned long int x, unsigned long int y)\n{\n  if (x == 0)\n    dummy ();\n  x -= y;\n  /* 0xfffffff2 < 0x80000000? */\n  if (x < ~(~(unsigned long int) 0 >> 1))\n    abort ();\n  return x;\n}\n\n\ndummy () {}\n\nmain ()\n{\n  /*      0x7ffffff3\t\t\t0x80000001 */\n  f1 ((~(unsigned int) 0 >> 1) - 12, ~(~(unsigned int) 0 >> 1) + 1);\n  f2 ((~(unsigned long int) 0 >> 1) - 12, ~(~(unsigned long int) 0 >> 1) + 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cmpsi-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#define F 140\n#define T 13\n\nfeq (int x, int y)\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (int x, int y)\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (int x, int y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (int x, int y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (int x, int y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (int x, int y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfltu (unsigned int x, unsigned int y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfgeu (unsigned int x, unsigned int y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgtu (unsigned int x, unsigned int y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfleu (unsigned int x, unsigned int y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nunsigned int args[] =\n{\n  0L,\n  1L,\n  -1L,\n  0x7fffffffL,\n  0x80000000L,\n  0x80000001L,\n  0x1A3F2373L,\n  0x93850E92L\n};\n\nint correct_results[] =\n{\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T\n};\n\nint\nmain (void)\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      unsigned int arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  unsigned int arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fltu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgeu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgtu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fleu (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c",
    "content": "#include <stdlib.h>\n\n#if !defined(NO_LABEL_VALUES) && (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647\ntypedef unsigned int uint32;\ntypedef signed int sint32;\n\ntypedef uint32 reg_t;\n\ntypedef unsigned long int host_addr_t;\ntypedef uint32 target_addr_t;\ntypedef sint32 target_saddr_t;\n\ntypedef union\n{\n  struct\n    {\n      unsigned int\toffset:18;\n      unsigned int\tignore:4;\n      unsigned int\ts1:8;\n      int\t\t:2;\n      signed int\tsimm:14;\n      unsigned int\ts3:8;\n      unsigned int\ts2:8;\n      int\t\tpad2:2;\n    } f1;\n  long long ll;\n  double d;\n} insn_t;\n\ntypedef struct\n{\n  target_addr_t vaddr_tag;\n  unsigned long int rigged_paddr;\n} tlb_entry_t;\n\ntypedef struct\n{\n  insn_t *pc;\n  reg_t registers[256];\n  insn_t *program;\n  tlb_entry_t tlb_tab[0x100];\n} environment_t;\n\nenum operations\n{\n  LOAD32_RR,\n  METAOP_DONE\n};\n\nhost_addr_t\nf ()\n{\n  abort ();\n}\n\nreg_t\nsimulator_kernel (int what, environment_t *env)\n{\n  register insn_t *pc = env->pc;\n  register reg_t *regs = env->registers;\n  register insn_t insn;\n  register int s1;\n  register reg_t r2;\n  register void *base_addr = &&sim_base_addr;\n  register tlb_entry_t *tlb = env->tlb_tab;\n\n  if (what != 0)\n    {\n      int i;\n      static void *op_map[] =\n\t{\n\t  &&L_LOAD32_RR,\n\t  &&L_METAOP_DONE,\n\t};\n      insn_t *program = env->program;\n      for (i = 0; i < what; i++)\n\tprogram[i].f1.offset = op_map[program[i].f1.offset] - base_addr;\n    }\n\n sim_base_addr:;\n\n  insn = *pc++;\n  r2 = (*(reg_t *) (((char *) regs) + (insn.f1.s2 << 2)));\n  s1 = (insn.f1.s1 << 2);\n  goto *(base_addr + insn.f1.offset);\n\n L_LOAD32_RR:\n  {\n    target_addr_t vaddr_page = r2 / 4096;\n    unsigned int x = vaddr_page % 0x100;\n    insn = *pc++;\n\n    for (;;)\n      {\n\ttarget_addr_t tag = tlb[x].vaddr_tag;\n\thost_addr_t rigged_paddr = tlb[x].rigged_paddr;\n\n\tif (tag == vaddr_page)\n\t  {\n\t    *(reg_t *) (((char *) regs) + s1) = *(uint32 *) (rigged_paddr + r2);\n\t    r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));\n\t    s1 = insn.f1.s1 << 2;\n\t    goto *(base_addr + insn.f1.offset);\n\t  }\n\n\tif (((target_saddr_t) tag < 0))\n\t  {\n\t    *(reg_t *) (((char *) regs) + s1) = *(uint32 *) f ();\n\t    r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));\n\t    s1 = insn.f1.s1 << 2;\n\t    goto *(base_addr + insn.f1.offset);\n\t  }\n\n\tx = (x - 1) % 0x100;\n      }\n\n    L_METAOP_DONE:\n      return (*(reg_t *) (((char *) regs) + s1));\n  }\n}\n\ninsn_t program[2 + 1];\n\nvoid *malloc ();\n\nint\nmain ()\n{\n  environment_t env;\n  insn_t insn;\n  int i, res;\n  host_addr_t a_page = (host_addr_t) malloc (2 * 4096);\n  target_addr_t a_vaddr = 0x123450;\n  target_addr_t vaddr_page = a_vaddr / 4096;\n  a_page = (a_page + 4096 - 1) & -4096;\n\n  env.tlb_tab[((vaddr_page) % 0x100)].vaddr_tag = vaddr_page;\n  env.tlb_tab[((vaddr_page) % 0x100)].rigged_paddr = a_page - vaddr_page * 4096;\n  insn.f1.offset = LOAD32_RR;\n  env.registers[0] = 0;\n  env.registers[2] = a_vaddr;\n  *(sint32 *) (a_page + a_vaddr % 4096) = 88;\n  insn.f1.s1 = 0;\n  insn.f1.s2 = 2;\n\n  for (i = 0; i < 2; i++)\n    program[i] = insn;\n\n  insn.f1.offset = METAOP_DONE;\n  insn.f1.s1 = 0;\n  program[2] = insn;\n\n  env.pc = program;\n  env.program = program;\n\n  res = simulator_kernel (2 + 1, &env);\n\n  if (res != 88)\n    abort ();\n  exit (0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c",
    "content": "/* A slight variation of 920501-7.c.  */\n\n#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 1000\n#endif\n\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\nx(a)\n{\n  __label__ xlab;\n  void y(a)\n    {\n      void *x = &&llab;\n      if (a==-1)\n\tgoto *x;\n      if (a==0)\n\tgoto xlab;\n    llab:\n      y (a-1);\n    }\n  y (a);\n xlab:;\n  return a;\n}\n#endif\n\nmain ()\n{\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\n  if (x (DEPTH) != DEPTH)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/compare-1.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Test for correctness of composite comparisons.\n\n   Written by Roger Sayle, 3rd June 2002.  */\n\nextern void abort (void);\n\nint ieq (int x, int y, int ok)\n{\n  if ((x<=y) && (x>=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((x<=y) && (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((x<=y) && (y<=x))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((y==x) && (x<=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ine (int x, int y, int ok)\n{\n  if ((x<y) || (x>y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ilt (int x, int y, int ok)\n{\n  if ((x<y) && (x!=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ile (int x, int y, int ok)\n{\n  if ((x<y) || (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint igt (int x, int y, int ok)\n{\n  if ((x>y) && (x!=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ige (int x, int y, int ok)\n{\n  if ((x>y) || (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint\nmain ()\n{\n  ieq (1, 4, 0);\n  ieq (3, 3, 1);\n  ieq (5, 2, 0);\n\n  ine (1, 4, 1);\n  ine (3, 3, 0);\n  ine (5, 2, 1);\n\n  ilt (1, 4, 1);\n  ilt (3, 3, 0);\n  ilt (5, 2, 0);\n\n  ile (1, 4, 1);\n  ile (3, 3, 1);\n  ile (5, 2, 0);\n\n  igt (1, 4, 0);\n  igt (3, 3, 0);\n  igt (5, 2, 1);\n\n  ige (1, 4, 0);\n  ige (3, 3, 1);\n  ige (5, 2, 1);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/compare-2.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Ensure that the composite comparison optimization doesn't misfire\n   and attempt to combine a signed comparison with an unsigned one.\n\n   Written by Roger Sayle, 3rd June 2002.  */\n\nextern void abort (void);\n\nint\nfoo (int x, int y)\n{\n  /* If miscompiled the following may become \"x == y\".  */\n  return (x<=y) && ((unsigned int)x >= (unsigned int)y);\n}\n\nint\nmain ()\n{\n  if (! foo (-1,0))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/compare-3.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Test for composite comparison always true/false optimization.\n\n   Written by Roger Sayle, 7th June 2002.  */\n\nextern void link_error0 ();\nextern void link_error1 ();\n\nvoid\ntest1 (int x, int y)\n{\n  if ((x==y) && (x!=y))\n    link_error0();\n}\n\nvoid\ntest2 (int x, int y)\n{\n  if ((x<y) && (x>y))\n    link_error0();\n}\n\nvoid\ntest3 (int x, int y)\n{\n  if ((x<y) && (y<x))\n    link_error0();\n}\n\nvoid \ntest4 (int x, int y)\n{\n  if ((x==y) || (x!=y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest5 (int x, int y)\n{\n  if ((x>=y) || (x<y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest6 (int x, int y)\n{\n  if ((x<=y) || (y<x))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\nall_tests (int x, int y)\n{\n  test1 (x, y);\n  test2 (x, y);\n  test3 (x, y);\n  test4 (x, y);\n  test5 (x, y);\n  test6 (x, y);\n}\n\nint\nmain ()\n{\n  all_tests (0, 0);\n  all_tests (1, 2);\n  all_tests (4, 3);\n\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid link_error0() {}\nvoid link_error1() {}\n#endif /* ! __OPTIMIZE__ */\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-1.c",
    "content": "double\ng0 (double x)\n{\n  return 1.0;\n}\n\ndouble\ng1 (double x)\n{\n  return -1.0;\n}\n\ndouble\ng2 (double x)\n{\n  return 0.0;\n}\n\n__complex__ double\nxcexp (__complex__ double x)\n{\n  double r;\n\n  r = g0 (__real__ x);\n  __real__ x = r * g1 (__imag__ x);\n  __imag__ x = r * g2 (__imag__ x);\n  return x;\n}\n\nmain ()\n{\n  __complex__ double x;\n\n  x = xcexp (1.0i);\n  if (__real__ x != -1.0)\n    abort ();\n  if (__imag__ x != 0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-2.c",
    "content": "__complex__ double\nf (__complex__ double x, __complex__ double y)\n{\n  x += y;\n  return x;\n}\n\n__complex__ double ag = 1.0 + 1.0i;\n__complex__ double bg = -2.0 + 2.0i;\n\nmain ()\n{\n  __complex__ double a, b, c;\n\n  a = ag;\n  b = -2.0 + 2.0i;\n  c = f (a, b);\n\n  if (a != 1.0 + 1.0i)\n    abort ();\n  if (b != -2.0 + 2.0i)\n    abort ();\n  if (c != -1.0 + 3.0i)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-3.c",
    "content": "struct complex\n{\n  float r;\n  float i;\n};\n\nstruct complex cmplx (float, float);\n\nstruct complex\nf (float a, float b)\n{\n  struct complex c;\n  c.r = a;\n  c.i = b;\n  return c;\n}\n\nmain ()\n{\n  struct complex z = f (1.0, 0.0);\n\n  if (z.r != 1.0 || z.i != 0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-4.c",
    "content": "main ()\n{\n  if ((__complex__ double) 0.0 != (__complex__ double) (-0.0))\n    abort ();\n\n  if (0.0 != -0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-5.c",
    "content": "float __complex__\np (float __complex__  a, float __complex__  b)\n{\n  return a + b;\n}\n\nfloat __complex__  x = 1.0 + 14.0 * (1.0fi);\nfloat __complex__  y = 7.0 + 5.0 * (1.0fi);\nfloat __complex__  w = 8.0 + 19.0 * (1.0fi);\nfloat __complex__  z;\n\nmain ()\n{\n\n  z = p (x,y);\n  y = p (x, 1.0f / z);\n  if (z != w)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-6.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n/* This test tests complex conjugate and passing/returning of\n   complex parameter.  */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nint err;\n\n#define TEST(TYPE, FUNC)\t\t\t\t\t\\\n__complex__ TYPE\t\t\t\t\t\t\\\nctest_ ## FUNC (__complex__ TYPE x)\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  __complex__ TYPE res;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  res = ~x;\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  return res;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\t\t\\\ntest_ ## FUNC (void)\t\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  __complex__ TYPE res, x;\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  x = 1.0 + 2.0i;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  res = ctest_ ## FUNC (x);\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  if (res != 1.0 - 2.0i)\t\t\t\t\t\\\n    {\t\t\t\t\t\t\t\t\\\n      printf (\"test_\" #FUNC \" failed\\n\");\t\t\t\\\n      ++err;\t\t\t\t\t\t\t\\\n    }\t\t\t\t\t\t\t\t\\\n}\n\n\nTEST(float, float)\nTEST(double, double)\nTEST(long double, long_double)\nTEST(int, int)\nTEST(long int, long_int)\n\nint\nmain (void)\n{\n\n  err = 0;\n\n  test_float ();\n  test_double ();\n  test_long_double ();\n  test_int ();\n  test_long_int ();\n\n  if (err != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/complex-7.c",
    "content": "/* Test argument passing of complex values.  The MIPS64 compiler had a\n   bug when they were split between registers and the stack.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\nvolatile _Complex float f1 = 1.1f + 2.2if;\nvolatile _Complex float f2 = 3.3f + 4.4if;\nvolatile _Complex float f3 = 5.5f + 6.6if;\nvolatile _Complex float f4 = 7.7f + 8.8if;\nvolatile _Complex float f5 = 9.9f + 10.1if;\nvolatile _Complex double d1 = 1.1 + 2.2i;\nvolatile _Complex double d2 = 3.3 + 4.4i;\nvolatile _Complex double d3 = 5.5 + 6.6i;\nvolatile _Complex double d4 = 7.7 + 8.8i;\nvolatile _Complex double d5 = 9.9 + 10.1i;\nvolatile _Complex long double ld1 = 1.1L + 2.2iL;\nvolatile _Complex long double ld2 = 3.3L + 4.4iL;\nvolatile _Complex long double ld3 = 5.5L + 6.6iL;\nvolatile _Complex long double ld4 = 7.7L + 8.8iL;\nvolatile _Complex long double ld5 = 9.9L + 10.1iL;\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__((noinline)) void\ncheck_float (int a, _Complex float a1, _Complex float a2,\n\t     _Complex float a3, _Complex float a4, _Complex float a5)\n{\n  if (a1 != f1 || a2 != f2 || a3 != f3 || a4 != f4 || a5 != f5)\n    abort ();\n}\n\n__attribute__((noinline)) void\ncheck_double (int a, _Complex double a1, _Complex double a2,\n\t     _Complex double a3, _Complex double a4, _Complex double a5)\n{\n  if (a1 != d1 || a2 != d2 || a3 != d3 || a4 != d4 || a5 != d5)\n    abort ();\n}\n\n__attribute__((noinline)) void\ncheck_long_double (int a, _Complex long double a1, _Complex long double a2,\n\t     _Complex long double a3, _Complex long double a4,\n\t\t   _Complex long double a5)\n{\n  if (a1 != ld1 || a2 != ld2 || a3 != ld3 || a4 != ld4 || a5 != ld5)\n    abort ();\n}\n\nint\nmain (void)\n{\n  check_float (0, f1, f2, f3, f4, f5);\n  check_double (0, d1, d2, d3, d4, d5);\n  check_long_double (0, ld1, ld2, ld3, ld4, ld5);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/compndlit-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct S\n{\n  int a:3;\n  unsigned b:1, c:28;\n};\n\nstruct S x = {1, 1, 1};\n\nmain ()\n{\n  x = (struct S) {b:0, a:0, c:({ struct S o = x; o.a == 1 ? 10 : 20;})};\n  if (x.c != 10)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/const-addr-expr-1.c",
    "content": "#include        <stdio.h>\n#include        <stdlib.h>\nextern void abort();\n\ntypedef struct foo\n{\n        int     uaattrid;\n        char    *name;\n} FOO;\n\nFOO     Upgrade_items[] =\n{\n        {1, \"1\"},\n        {2, \"2\"},\n        {0, NULL}\n};\n\nint     *Upgd_minor_ID = \n        (int *) &((Upgrade_items + 1)->uaattrid);\n\nint     *Upgd_minor_ID1 = \n        (int *) &((Upgrade_items)->uaattrid);\n\nint\nmain(int argc, char **argv)\n{\n\tif (*Upgd_minor_ID != 2)\n\t  abort();\n\n\tif (*Upgd_minor_ID1 != 1)\n\t  abort();\n\treturn 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/conversion.c",
    "content": "/* Test front-end conversions, optimizer conversions, and run-time\n   conversions between different arithmetic types.\n\n   Constants are specified in a non-obvious way to make them work for\n   any word size.  Their value on a 32-bit machine is indicated in the\n   comments.\n\n   Note that this code is NOT intended for testing of accuracy of fp\n   conversions.  */\n\nfloat\nu2f(u)\n     unsigned int u;\n{\n  return u;\n}\n\ndouble\nu2d(u)\n     unsigned int u;\n{\n  return u;\n}\n\nlong double\nu2ld(u)\n     unsigned int u;\n{\n  return u;\n}\n\nfloat\ns2f(s)\n     int s;\n{\n  return s;\n}\n\ndouble\ns2d(s)\n     int s;\n{\n  return s;\n}\n\nlong double\ns2ld(s)\n     int s;\n{\n  return s;\n}\n\nint\nfnear (float x, float y)\n{\n  float t = x - y;\n  return t == 0 || x / t > 1000000.0;\n}\n\nint\ndnear (double x, double y)\n{\n  double t = x - y;\n  return t == 0 || x / t > 100000000000000.0;\n}\n\nint\nldnear (long double x, long double y)\n{\n  long double t = x - y;\n  return t == 0 || x / t > 100000000000000000000000000000000.0;\n}\n\ntest_integer_to_float()\n{\n  if (u2f(0U) != (float) 0U)\t\t\t\t/* 0 */\n    abort();\n  if (!fnear (u2f(~0U), (float) ~0U))\t\t\t/* 0xffffffff */\n    abort();\n  if (!fnear (u2f((~0U) >> 1), (float) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2f(~((~0U) >> 1)) != (float) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (u2d(0U) != (double) 0U)\t\t\t\t/* 0 */\n    abort();\n  if (!dnear (u2d(~0U), (double) ~0U))\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (u2d((~0U) >> 1),(double) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2d(~((~0U) >> 1)) != (double) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (u2ld(0U) != (long double) 0U)\t\t\t/* 0 */\n    abort();\n  if (!ldnear (u2ld(~0U), (long double) ~0U))\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (u2ld((~0U) >> 1),(long double) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2ld(~((~0U) >> 1)) != (long double) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (s2f(0) != (float) 0)\t\t\t\t/* 0 */\n    abort();\n  if (!fnear (s2f(~0), (float) ~0))\t\t\t/* 0xffffffff */\n    abort();\n  if (!fnear (s2f((int)((~0U) >> 1)), (float)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2f((int)(~((~0U) >> 1))) != (float)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (s2d(0) != (double) 0)\t\t\t\t/* 0 */\n    abort();\n  if (!dnear (s2d(~0), (double) ~0))\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (s2d((int)((~0U) >> 1)), (double)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (s2ld(0) != (long double) 0)\t\t\t/* 0 */\n    abort();\n  if (!ldnear (s2ld(~0), (long double) ~0))\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (s2ld((int)((~0U) >> 1)), (long double)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2ld((int)~((~0U) >> 1)) != (long double)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n}\n\n#if __GNUC__\nfloat\null2f(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\ndouble\null2d(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\nlong double\null2ld(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\nfloat\nsll2f(s)\n     long long int s;\n{\n  return s;\n}\n\ndouble\nsll2d(s)\n     long long int s;\n{\n  return s;\n}\n\nlong double\nsll2ld(s)\n     long long int s;\n{\n  return s;\n}\n\ntest_longlong_integer_to_float()\n{\n  if (ull2f(0ULL) != (float) 0ULL)\t\t\t/* 0 */\n    abort();\n  if (ull2f(~0ULL) != (float) ~0ULL)\t\t\t/* 0xffffffff */\n    abort();\n  if (ull2f((~0ULL) >> 1) != (float) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n  if (ull2f(~((~0ULL) >> 1)) != (float) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ull2d(0ULL) != (double) 0ULL)\t\t\t/* 0 */\n    abort();\n#if __HAVE_68881__\n  /* Some 68881 targets return values in fp0, with excess precision.\n     But the compile-time conversion to double works correctly.  */\n  if (! dnear (ull2d(~0ULL), (double) ~0ULL))\t\t/* 0xffffffff */\n    abort();\n  if (! dnear (ull2d((~0ULL) >> 1), (double) ((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n#else\n  if (ull2d(~0ULL) != (double) ~0ULL)\t\t\t/* 0xffffffff */\n    abort();\n  if (ull2d((~0ULL) >> 1) != (double) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n#endif\n  if (ull2d(~((~0ULL) >> 1)) != (double) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ull2ld(0ULL) != (long double) 0ULL)\t\t/* 0 */\n    abort();\n  if (ull2ld(~0ULL) != (long double) ~0ULL)\t\t/* 0xffffffff */\n    abort();\n  if (ull2ld((~0ULL) >> 1) != (long double) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n  if (ull2ld(~((~0ULL) >> 1)) != (long double) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (sll2f(0LL) != (float) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2f(~0LL) != (float) ~0LL)\t\t\t/* 0xffffffff */\n    abort();\n  if (! fnear (sll2f((long long int)((~0ULL) >> 1)), (float)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (sll2f((long long int)(~((~0ULL) >> 1))) != (float)(long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (sll2d(0LL) != (double) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2d(~0LL) != (double) ~0LL)\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (sll2d((long long int)((~0ULL) >> 1)), (double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (! dnear (sll2d((long long int)~((~0ULL) >> 1)), (double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */\n    abort();\n\n  if (sll2ld(0LL) != (long double) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2ld(~0LL) != (long double) ~0LL)\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (sll2ld((long long int)((~0ULL) >> 1)), (long double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (! ldnear (sll2ld((long long int)~((~0ULL) >> 1)), (long double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */\n    abort();\n}\n#endif\n\nunsigned int\nf2u(float f)\n{\n  return (unsigned) f;\n}\n\nunsigned int\nd2u(double d)\n{\n  return (unsigned) d;\n}\n\nunsigned int\nld2u(long double d)\n{\n  return (unsigned) d;\n}\n\nint\nf2s(float f)\n{\n  return (int) f;\n}\n\nint\nd2s(double d)\n{\n  return (int) d;\n}\n\nint\nld2s(long double d)\n{\n  return (int) d;\n}\n\ntest_float_to_integer()\n{\n  if (f2u(0.0) != 0)\n    abort();\n  if (f2u(0.999) != 0)\n    abort();\n  if (f2u(1.0) != 1)\n    abort();\n  if (f2u(1.99) != 1)\n    abort();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2u((float) ((~0U) >> 1)) != 0x7fffff80)\n    abort();\n#else\n  if (f2u((float) ((~0U) >> 1)) != (~0U) >> 1 &&\t/* 0x7fffffff */\n      f2u((float) ((~0U) >> 1)) != ((~0U) >> 1) + 1)\n    abort();\n#endif\n  if (f2u((float) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n /* These tests require double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (double) >= 8) {\n  if (d2u(0.0) != 0)\n    abort();\n  if (d2u(0.999) != 0)\n    abort();\n  if (d2u(1.0) != 1)\n    abort();\n  if (d2u(1.99) != 1)\n    abort();\n  if (d2u((double) (~0U)) != ~0U)\t\t\t/* 0xffffffff */\n    abort();\n  if (d2u((double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (d2u((double) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n }\n\n /* These tests require long double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (long double) >= 8) {\n  if (ld2u(0.0) != 0)\n    abort();\n  if (ld2u(0.999) != 0)\n    abort();\n  if (ld2u(1.0) != 1)\n    abort();\n  if (ld2u(1.99) != 1)\n    abort();\n  if (ld2u((long double) (~0U)) != ~0U)\t\t\t/* 0xffffffff */\n    abort();\n  if (ld2u((long double) ((~0U) >> 1)) != (~0U) >> 1)\t/* 0x7fffffff */\n    abort();\n  if (ld2u((long double) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n }\n\n  if (f2s(0.0) != 0)\n    abort();\n  if (f2s(0.999) != 0)\n    abort();\n  if (f2s(1.0) != 1)\n    abort();\n  if (f2s(1.99) != 1)\n    abort();\n  if (f2s(-0.999) != 0)\n    abort();\n  if (f2s(-1.0) != -1)\n    abort();\n  if (f2s(-1.99) != -1)\n    abort();\n  if (f2s((float)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n /* These tests require double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (double) >= 8) {\n  if (d2s(0.0) != 0)\n    abort();\n  if (d2s(0.999) != 0)\n    abort();\n  if (d2s(1.0) != 1)\n    abort();\n  if (d2s(1.99) != 1)\n    abort();\n  if (d2s(-0.999) != 0)\n    abort();\n  if (d2s(-1.0) != -1)\n    abort();\n  if (d2s(-1.99) != -1)\n    abort();\n  if (d2s((double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (d2s((double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n }\n\n /* These tests require long double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (long double) >= 8) {\n  if (ld2s(0.0) != 0)\n    abort();\n  if (ld2s(0.999) != 0)\n    abort();\n  if (ld2s(1.0) != 1)\n    abort();\n  if (ld2s(1.99) != 1)\n    abort();\n  if (ld2s(-0.999) != 0)\n    abort();\n  if (ld2s(-1.0) != -1)\n    abort();\n  if (ld2s(-1.99) != -1)\n    abort();\n  if (ld2s((long double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (ld2s((long double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n }\n}\n\n#if __GNUC__\nunsigned long long int\nf2ull(float f)\n{\n  return (unsigned long long int) f;\n}\n\nunsigned long long int\nd2ull(double d)\n{\n  return (unsigned long long int) d;\n}\n\nunsigned long long int\nld2ull(long double d)\n{\n  return (unsigned long long int) d;\n}\n\nlong long int\nf2sll(float f)\n{\n  return (long long int) f;\n}\n\nlong long int\nd2sll(double d)\n{\n  return (long long int) d;\n}\n\nlong long int\nld2sll(long double d)\n{\n  return (long long int) d;\n}\n\ntest_float_to_longlong_integer()\n{\n  if (f2ull(0.0) != 0LL)\n    abort();\n  if (f2ull(0.999) != 0LL)\n    abort();\n  if (f2ull(1.0) != 1LL)\n    abort();\n  if (f2ull(1.99) != 1LL)\n    abort();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2ull((float) ((~0ULL) >> 1)) != 0x7fffff8000000000ULL)\n    abort();\n#else\n  if (f2ull((float) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      f2ull((float) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n#endif\n  if (f2ull((float) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (d2ull(0.0) != 0LL)\n    abort();\n  if (d2ull(0.999) != 0LL)\n    abort();\n  if (d2ull(1.0) != 1LL)\n    abort();\n  if (d2ull(1.99) != 1LL)\n    abort();\n  if (d2ull((double) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      d2ull((double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n  if (d2ull((double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ld2ull(0.0) != 0LL)\n    abort();\n  if (ld2ull(0.999) != 0LL)\n    abort();\n  if (ld2ull(1.0) != 1LL)\n    abort();\n  if (ld2ull(1.99) != 1LL)\n    abort();\n  if (ld2ull((long double) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      ld2ull((long double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n  if (ld2ull((long double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n\n  if (f2sll(0.0) != 0LL)\n    abort();\n  if (f2sll(0.999) != 0LL)\n    abort();\n  if (f2sll(1.0) != 1LL)\n    abort();\n  if (f2sll(1.99) != 1LL)\n    abort();\n  if (f2sll(-0.999) != 0LL)\n    abort();\n  if (f2sll(-1.0) != -1LL)\n    abort();\n  if (f2sll(-1.99) != -1LL)\n    abort();\n  if (f2sll((float)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (d2sll(0.0) != 0LL)\n    abort();\n  if (d2sll(0.999) != 0LL)\n    abort();\n  if (d2sll(1.0) != 1LL)\n    abort();\n  if (d2sll(1.99) != 1LL)\n    abort();\n  if (d2sll(-0.999) != 0LL)\n    abort();\n  if (d2sll(-1.0) != -1LL)\n    abort();\n  if (d2sll(-1.99) != -1LL)\n    abort();\n  if (d2sll((double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ld2sll(0.0) != 0LL)\n    abort();\n  if (ld2sll(0.999) != 0LL)\n    abort();\n  if (ld2sll(1.0) != 1LL)\n    abort();\n  if (ld2sll(1.99) != 1LL)\n    abort();\n  if (ld2sll(-0.999) != 0LL)\n    abort();\n  if (ld2sll(-1.0) != -1LL)\n    abort();\n  if (ld2sll(-1.99) != -1LL)\n    abort();\n  if (ld2sll((long double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n}\n#endif\n\nmain()\n{\n  test_integer_to_float();\n  test_float_to_integer();\n#if __GNUC__\n  test_longlong_integer_to_float();\n  test_float_to_longlong_integer();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/cvt-1.c",
    "content": "static inline long\ng1 (double x)\n{\n  return (double) (long) x;\n}\n\nlong\ng2 (double f)\n{\n  return f;\n}\n\ndouble\nf (long i)\n{\n  if (g1 (i) != g2 (i))\n    abort ();\n  return g2 (i);\n}\n\nmain ()\n{\n  if (f (123456789L) != 123456789L)\n    abort ();\n  if (f (123456789L) != g2 (123456789L))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/dbra-1.c",
    "content": "f1 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a == -1)\n\treturn i;\n    }\n  return -1;\n}\n\nf2 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a != -1)\n\treturn i;\n    }\n  return -1;\n}\n\nf3 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a == 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf4 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a != 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf5 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (++a == 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf6 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (++a != 0)\n\treturn i;\n    }\n  return -1;\n}\n\n\nmain()\n{\n  if (f1 (5L) != 5)\n    abort ();\n  if (f2 (1L) != 0)\n    abort ();\n  if (f2 (0L) != 1)\n    abort ();\n  if (f3 (5L) != 4)\n    abort ();\n  if (f4 (1L) != 1)\n    abort ();\n  if (f4 (0L) != 0)\n    abort ();\n  if (f5 (-5L) != 4)\n    abort ();\n  if (f6 (-1L) != 1)\n    abort ();\n  if (f6 (0L) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divcmp-1.c",
    "content": "extern void abort(void);\n\nint test1(int x)\n{\n  return x/10 == 2;\n}\n\nint test1u(unsigned int x)\n{\n  return x/10U == 2;\n}\n\nint test2(int x)\n{\n  return x/10 == 0;\n}\n\nint test2u(unsigned int x)\n{\n  return x/10U == 0;\n}\n\nint test3(int x)\n{\n  return x/10 != 2;\n}\n\nint test3u(unsigned int x)\n{\n  return x/10U != 2;\n}\n\nint test4(int x)\n{\n  return x/10 != 0;\n}\n\nint test4u(unsigned int x)\n{\n  return x/10U != 0;\n}\n\nint test5(int x)\n{\n  return x/10 < 2;\n}\n\nint test5u(unsigned int x)\n{\n  return x/10U < 2;\n}\n\nint test6(int x)\n{\n  return x/10 < 0;\n}\n\nint test7(int x)\n{\n  return x/10  <= 2;\n}\n\nint test7u(unsigned int x)\n{\n  return x/10U <= 2;\n}\n\nint test8(int x)\n{\n  return x/10 <= 0;\n}\n\nint test8u(unsigned int x)\n{\n  return x/10U <= 0;\n}\n\nint test9(int x)\n{\n  return x/10 > 2;\n}\n\nint test9u(unsigned int x)\n{\n  return x/10U > 2;\n}\n\nint test10(int x)\n{\n  return x/10 > 0;\n}\n\nint test10u(unsigned int x)\n{\n  return x/10U > 0;\n}\n\nint test11(int x)\n{\n  return x/10 >= 2;\n}\n\nint test11u(unsigned int x)\n{\n  return x/10U >= 2;\n}\n\nint test12(int x)\n{\n  return x/10 >= 0;\n}\n\n\nint main()\n{\n  if (test1(19) != 0)\n    abort ();\n  if (test1(20) != 1)\n    abort ();\n  if (test1(29) != 1)\n    abort ();\n  if (test1(30) != 0)\n    abort ();\n\n  if (test1u(19) != 0)\n    abort ();\n  if (test1u(20) != 1)\n    abort ();\n  if (test1u(29) != 1)\n    abort ();\n  if (test1u(30) != 0)\n    abort ();\n\n  if (test2(0) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n  if (test2(-1) != 1)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(-10) != 0)\n    abort ();\n\n  if (test2u(0) != 1)\n    abort ();\n  if (test2u(9) != 1)\n    abort ();\n  if (test2u(10) != 0)\n    abort ();\n  if (test2u(-1) != 0)\n    abort ();\n  if (test2u(-9) != 0)\n    abort ();\n  if (test2u(-10) != 0)\n    abort ();\n\n  if (test3(19) != 1)\n    abort ();\n  if (test3(20) != 0)\n    abort ();\n  if (test3(29) != 0)\n    abort ();\n  if (test3(30) != 1)\n    abort ();\n\n  if (test3u(19) != 1)\n    abort ();\n  if (test3u(20) != 0)\n    abort ();\n  if (test3u(29) != 0)\n    abort ();\n  if (test3u(30) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(9) != 0)\n    abort ();\n  if (test4(10) != 1)\n    abort ();\n  if (test4(-1) != 0)\n    abort ();\n  if (test4(-9) != 0)\n    abort ();\n  if (test4(-10) != 1)\n    abort ();\n\n  if (test4u(0) != 0)\n    abort ();\n  if (test4u(9) != 0)\n    abort ();\n  if (test4u(10) != 1)\n    abort ();\n  if (test4u(-1) != 1)\n    abort ();\n  if (test4u(-9) != 1)\n    abort ();\n  if (test4u(-10) != 1)\n    abort ();\n\n  if (test5(19) != 1)\n    abort ();\n  if (test5(20) != 0)\n    abort ();\n  if (test5(29) != 0)\n    abort ();\n  if (test5(30) != 0)\n    abort ();\n\n  if (test5u(19) != 1)\n    abort ();\n  if (test5u(20) != 0)\n    abort ();\n  if (test5u(29) != 0)\n    abort ();\n  if (test5u(30) != 0)\n    abort ();\n\n  if (test6(0) != 0)\n    abort ();\n  if (test6(9) != 0)\n    abort ();\n  if (test6(10) != 0)\n    abort ();\n  if (test6(-1) != 0)\n    abort ();\n  if (test6(-9) != 0)\n    abort ();\n  if (test6(-10) != 1)\n    abort ();\n\n  if (test7(19) != 1)\n    abort ();\n  if (test7(20) != 1)\n    abort ();\n  if (test7(29) != 1)\n    abort ();\n  if (test7(30) != 0)\n    abort ();\n\n  if (test7u(19) != 1)\n    abort ();\n  if (test7u(20) != 1)\n    abort ();\n  if (test7u(29) != 1)\n    abort ();\n  if (test7u(30) != 0)\n    abort ();\n\n  if (test8(0) != 1)\n    abort ();\n  if (test8(9) != 1)\n    abort ();\n  if (test8(10) != 0)\n    abort ();\n  if (test8(-1) != 1)\n    abort ();\n  if (test8(-9) != 1)\n    abort ();\n  if (test8(-10) != 1)\n    abort ();\n\n  if (test8u(0) != 1)\n    abort ();\n  if (test8u(9) != 1)\n    abort ();\n  if (test8u(10) != 0)\n    abort ();\n  if (test8u(-1) != 0)\n    abort ();\n  if (test8u(-9) != 0)\n    abort ();\n  if (test8u(-10) != 0)\n    abort ();\n\n  if (test9(19) != 0)\n    abort ();\n  if (test9(20) != 0)\n    abort ();\n  if (test9(29) != 0)\n    abort ();\n  if (test9(30) != 1)\n    abort ();\n\n  if (test9u(19) != 0)\n    abort ();\n  if (test9u(20) != 0)\n    abort ();\n  if (test9u(29) != 0)\n    abort ();\n  if (test9u(30) != 1)\n    abort ();\n\n  if (test10(0) != 0)\n    abort ();\n  if (test10(9) != 0)\n    abort ();\n  if (test10(10) != 1)\n    abort ();\n  if (test10(-1) != 0)\n    abort ();\n  if (test10(-9) != 0)\n    abort ();\n  if (test10(-10) != 0)\n    abort ();\n\n  if (test10u(0) != 0)\n    abort ();\n  if (test10u(9) != 0)\n    abort ();\n  if (test10u(10) != 1)\n    abort ();\n  if (test10u(-1) != 1)\n    abort ();\n  if (test10u(-9) != 1)\n    abort ();\n  if (test10u(-10) != 1)\n    abort ();\n\n  if (test11(19) != 0)\n    abort ();\n  if (test11(20) != 1)\n    abort ();\n  if (test11(29) != 1)\n    abort ();\n  if (test11(30) != 1)\n    abort ();\n\n  if (test11u(19) != 0)\n    abort ();\n  if (test11u(20) != 1)\n    abort ();\n  if (test11u(29) != 1)\n    abort ();\n  if (test11u(30) != 1)\n    abort ();\n\n  if (test12(0) != 1)\n    abort ();\n  if (test12(9) != 1)\n    abort ();\n  if (test12(10) != 1)\n    abort ();\n  if (test12(-1) != 1)\n    abort ();\n  if (test12(-9) != 1)\n    abort ();\n  if (test12(-10) != 0)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divcmp-2.c",
    "content": "extern void abort (void);\n\nint test1(int x)\n{\n  return x/10 == 2;\n}\n\nint test2(int x)\n{\n  return x/10 == 0;\n}\n\nint test3(int x)\n{\n  return x/10 == -2;\n}\n\nint test4(int x)\n{\n  return x/-10 == 2;\n}\n\nint test5(int x)\n{\n  return x/-10 == 0;\n}\n\nint test6(int x)\n{\n  return x/-10 == -2;\n}\n\n\nint main()\n{\n  if (test1(19) != 0)\n    abort ();\n  if (test1(20) != 1)\n    abort ();\n  if (test1(29) != 1)\n    abort ();\n  if (test1(30) != 0)\n    abort ();\n\n  if (test2(-10) != 0)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n\n  if (test3(-30) != 0)\n    abort ();\n  if (test3(-29) != 1)\n    abort ();\n  if (test3(-20) != 1)\n    abort ();\n  if (test3(-19) != 0)\n    abort ();\n\n  if (test4(-30) != 0)\n    abort ();\n  if (test4(-29) != 1)\n    abort ();\n  if (test4(-20) != 1)\n    abort ();\n  if (test4(-19) != 0)\n    abort ();\n\n  if (test5(-10) != 0)\n    abort ();\n  if (test5(-9) != 1)\n    abort ();\n  if (test5(9) != 1)\n    abort ();\n  if (test5(10) != 0)\n    abort ();\n\n  if (test6(19) != 0)\n    abort ();\n  if (test6(20) != 1)\n    abort ();\n  if (test6(29) != 1)\n    abort ();\n  if (test6(30) != 0)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divcmp-3.c",
    "content": "extern void abort(void);\n\nint test1(char x)\n{\n  return x/100 == 3;\n}\n\nint test1u(unsigned char x)\n{\n  return x/100 == 3;\n}\n\nint test2(char x)\n{\n  return x/100 != 3;\n}\n\nint test2u(unsigned char x)\n{\n  return x/100 != 3;\n}\n\nint test3(char x)\n{\n  return x/100 < 3;\n}\n\nint test3u(unsigned char x)\n{\n  return x/100 < 3;\n}\n\nint test4(char x)\n{\n  return x/100 <= 3;\n}\n\nint test4u(unsigned char x)\n{\n  return x/100 <= 3;\n}\n\nint test5(char x)\n{\n  return x/100 > 3;\n}\n\nint test5u(unsigned char x)\n{\n  return x/100 > 3;\n}\n\nint test6(char x)\n{\n  return x/100 >= 3;\n}\n\nint test6u(unsigned char x)\n{\n  return x/100 >= 3;\n}\n\n\nint main()\n{\n  int c;\n\n  for (c=-128; c<256; c++)\n  {\n    if (test1(c) != 0)\n      abort ();\n    if (test1u(c) != 0)\n      abort ();\n    if (test2(c) != 1)\n      abort ();\n    if (test2u(c) != 1)\n      abort ();\n    if (test3(c) != 1)\n      abort ();\n    if (test3u(c) != 1)\n      abort ();\n    if (test4(c) != 1)\n      abort ();\n    if (test4u(c) != 1)\n      abort ();\n    if (test5(c) != 0)\n      abort ();\n    if (test5u(c) != 0)\n      abort ();\n    if (test6(c) != 0)\n      abort ();\n    if (test6u(c) != 0)\n      abort ();\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divcmp-4.c",
    "content": "/* PR middle-end/17894 */\n\nextern void abort(void);\n\nint test1(int x)\n{\n  return x/-10 == 2;\n}\n\nint test2(int x)\n{\n  return x/-10 == 0;\n}\n\nint test3(int x)\n{\n  return x/-10 != 2;\n}\n\nint test4(int x)\n{\n  return x/-10 != 0;\n}\n\nint test5(int x)\n{\n  return x/-10 < 2;\n}\n\nint test6(int x)\n{\n  return x/-10 < 0;\n}\n\nint test7(int x)\n{\n  return x/-10  <= 2;\n}\n\nint test8(int x)\n{\n  return x/-10 <= 0;\n}\n\nint test9(int x)\n{\n  return x/-10 > 2;\n}\n\nint test10(int x)\n{\n  return x/-10 > 0;\n}\n\nint test11(int x)\n{\n  return x/-10 >= 2;\n}\n\nint test12(int x)\n{\n  return x/-10 >= 0;\n}\n\n\nint main()\n{\n  if (test1(-30) != 0)\n    abort ();\n  if (test1(-29) != 1)\n    abort ();\n  if (test1(-20) != 1)\n    abort ();\n  if (test1(-19) != 0)\n    abort ();\n\n  if (test2(0) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n  if (test2(-1) != 1)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(-10) != 0)\n    abort ();\n\n  if (test3(-30) != 1)\n    abort ();\n  if (test3(-29) != 0)\n    abort ();\n  if (test3(-20) != 0)\n    abort ();\n  if (test3(-19) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(9) != 0)\n    abort ();\n  if (test4(10) != 1)\n    abort ();\n  if (test4(-1) != 0)\n    abort ();\n  if (test4(-9) != 0)\n    abort ();\n  if (test4(-10) != 1)\n    abort ();\n\n  if (test5(-30) != 0)\n    abort ();\n  if (test5(-29) != 0)\n    abort ();\n  if (test5(-20) != 0)\n    abort ();\n  if (test5(-19) != 1)\n    abort ();\n\n  if (test6(0) != 0)\n    abort ();\n  if (test6(9) != 0)\n    abort ();\n  if (test6(10) != 1)\n    abort ();\n  if (test6(-1) != 0)\n    abort ();\n  if (test6(-9) != 0)\n    abort ();\n  if (test6(-10) != 0)\n    abort ();\n\n  if (test7(-30) != 0)\n    abort ();\n  if (test7(-29) != 1)\n    abort ();\n  if (test7(-20) != 1)\n    abort ();\n  if (test7(-19) != 1)\n    abort ();\n\n  if (test8(0) != 1)\n    abort ();\n  if (test8(9) != 1)\n    abort ();\n  if (test8(10) != 1)\n    abort ();\n  if (test8(-1) != 1)\n    abort ();\n  if (test8(-9) != 1)\n    abort ();\n  if (test8(-10) != 0)\n    abort ();\n\n  if (test9(-30) != 1)\n    abort ();\n  if (test9(-29) != 0)\n    abort ();\n  if (test9(-20) != 0)\n    abort ();\n  if (test9(-19) != 0)\n    abort ();\n\n  if (test10(0) != 0)\n    abort ();\n  if (test10(9) != 0)\n    abort ();\n  if (test10(10) != 0)\n    abort ();\n  if (test10(-1) != 0)\n    abort ();\n  if (test10(-9) != 0)\n    abort ();\n  if (test10(-10) != 1)\n    abort ();\n\n  if (test11(-30) != 1)\n    abort ();\n  if (test11(-29) != 1)\n    abort ();\n  if (test11(-20) != 1)\n    abort ();\n  if (test11(-19) != 0)\n    abort ();\n\n  if (test12(0) != 1)\n    abort ();\n  if (test12(9) != 1)\n    abort ();\n  if (test12(10) != 0)\n    abort ();\n  if (test12(-1) != 1)\n    abort ();\n  if (test12(-9) != 1)\n    abort ();\n  if (test12(-10) != 1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divcmp-5.c",
    "content": "/* PR middle-end/26561 */\n\nextern void abort(void);\n\nint always_one_1 (int a)\n{\n  if (a/100 >= -999999999)\n    return 1;\n  else\n    return 0;\n}\n\nint always_one_2 (int a)\n{\n  if (a/100 < -999999999)\n    return 0;\n  else\n    return 1;\n}\n\nint main(void)\n{\n  if (always_one_1 (0) != 1)\n    abort ();\n\n  if (always_one_2 (0) != 1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divconst-1.c",
    "content": "typedef struct\n{\n  unsigned a, b, c, d;\n} t1;\n\nf (t1 *ps)\n{\n    ps->a = 10000;\n    ps->b = ps->a / 3;\n    ps->c = 10000;\n    ps->d = ps->c / 3;\n}\n\nmain ()\n{\n  t1 s;\n  f (&s);\n  if (s.a != 10000 || s.b != 3333 || s.c != 10000 || s.d != 3333)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divconst-2.c",
    "content": "long\nf (long x)\n{\n  return x / (-0x7fffffffL - 1L);\n}\n\nlong\nr (long x)\n{\n  return x % (-0x7fffffffL - 1L);\n}\n\n/* Since we have a negative divisor, this equation must hold for the\n   results of / and %; no specific results are guaranteed.  */\nlong\nstd_eqn (long num, long denom, long quot, long rem)\n{\n  /* For completeness, a check for \"ABS (rem) < ABS (denom)\" belongs here,\n     but causes trouble on 32-bit machines and isn't worthwhile.  */\n  return quot * (-0x7fffffffL - 1L) + rem == num;\n}\n\nlong nums[] =\n{\n  -1L, 0x7fffffffL, -0x7fffffffL - 1L\n};\n\nmain ()\n{\n  int i;\n\n  for (i = 0;\n       i < sizeof (nums) / sizeof (nums[0]);\n       i++)\n    if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)\n      abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divconst-3.c",
    "content": "long long\nf (long long x)\n{\n  return x / 10000000000LL;\n}\n\nmain ()\n{\n  if (f (10000000000LL) != 1 || f (100000000000LL) != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/divmod-1.c",
    "content": "div1 (signed char x)\n{\n  return x / -1;\n}\n\ndiv2 (signed short x)\n{\n  return x / -1;\n}\n\ndiv3 (signed char x, signed char y)\n{\n  return x / y;\n}\n\ndiv4 (signed short x, signed short y)\n{\n  return x / y;\n}\n\nmod1 (signed char x)\n{\n  return x % -1;\n}\n\nmod2 (signed short x)\n{\n  return x % -1;\n}\n\nmod3 (signed char x, signed char y)\n{\n  return x % y;\n}\n\nmod4 (signed short x, signed short y)\n{\n  return x % y;\n}\n\nsigned long\nmod5 (signed long x, signed long y)\n{\n  return x % y;\n}\n     \nunsigned long\nmod6 (unsigned long x, unsigned long y)\n{\n  return x % y;\n}\n     \nmain ()\n{\n  if (div1 (-(1 << 7)) != 1 << 7)\n    abort ();\n  if (div2 (-(1 << 15)) != 1 << 15)\n    abort ();\n  if (div3 (-(1 << 7), -1) != 1 << 7)\n    abort ();\n  if (div4 (-(1 << 15), -1) != 1 << 15)\n    abort ();\n  if (mod1 (-(1 << 7)) != 0)\n    abort ();\n  if (mod2 (-(1 << 15)) != 0)\n    abort ();\n  if (mod3 (-(1 << 7), -1) != 0)\n    abort ();\n  if (mod4 (-(1 << 15), -1) != 0)\n    abort ();\n  if (mod5 (0x50000000, 2) != 0)\n    abort ();\n  if (mod6 (0x50000000, 2) != 0)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/doloop-1.c",
    "content": "#include <limits.h>\n\nextern void exit (int);\nextern void abort (void);\n\nvolatile unsigned int i;\n\nint\nmain (void)\n{\n  unsigned char z = 0;\n\n  do ++i;\n  while (--z > 0);\n  if (i != UCHAR_MAX + 1U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/doloop-2.c",
    "content": "#include <limits.h>\n\nextern void exit (int);\nextern void abort (void);\n\nvolatile unsigned int i;\n\nint\nmain (void)\n{\n  unsigned short z = 0;\n\n  do ++i;\n  while (--z > 0);\n  if (i != USHRT_MAX + 1U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/eeprof-1.c",
    "content": "/* { dg-require-effective-target return_address } */\n/* { dg-options \"-finstrument-functions\" } */\n/* { dg-xfail-run-if \"\" { powerpc-ibm-aix* } \"*\" \"\" } */\n\nextern void abort (void);\n\n#define ASSERT(X)\tif (!(X)) abort ();\n#define NOCHK __attribute__ ((no_instrument_function))\n\nint entry_calls, exit_calls;\nvoid (*last_fn_entered)();\nvoid (*last_fn_exited)();\n\n__attribute__ ((noinline))\nint main () NOCHK;\n\n__attribute__ ((noinline))\nvoid foo ()\n{\n  ASSERT (last_fn_entered == foo);\n}\n\n__attribute__ ((noinline))\nstatic void foo2 ()\n{\n  ASSERT (entry_calls == 1 && exit_calls == 0);\n  ASSERT (last_fn_entered == foo2);\n  foo ();\n  ASSERT (entry_calls == 2 && exit_calls == 1);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo);\n}\n\n__attribute__ ((noinline))\nvoid nfoo (void) NOCHK;\nvoid nfoo ()\n{\n  ASSERT (entry_calls == 2 && exit_calls == 2);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo2);\n  foo ();\n  ASSERT (entry_calls == 3 && exit_calls == 3);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo);\n}\n\nint main ()\n{\n  ASSERT (entry_calls == 0 && exit_calls == 0);\n\n  foo2 ();\n\n  ASSERT (entry_calls == 2 && exit_calls == 2);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo2);\n\n  nfoo ();\n\n  ASSERT (entry_calls == 3 && exit_calls == 3);\n  ASSERT (last_fn_entered == foo);\n\n  return 0;\n}\n\nvoid __cyg_profile_func_enter (void (*fn)(), void (*parent)()) NOCHK;\nvoid __cyg_profile_func_exit (void (*fn)(), void (*parent)()) NOCHK;\n\n__attribute__ ((noinline))\nvoid __cyg_profile_func_enter (void (*fn)(), void (*parent)())\n{\n  entry_calls++;\n  last_fn_entered = fn;\n}\n__attribute__ ((noinline))\nvoid __cyg_profile_func_exit (void (*fn)(), void (*parent)())\n{\n  exit_calls++;\n  last_fn_exited = fn;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/enum-1.c",
    "content": "typedef enum\n{\n  END = -1,\n  EMPTY = (1 << 8 ) ,\n  BACKREF,\n  BEGLINE,\n  ENDLINE,\n  BEGWORD,\n  ENDWORD,\n  LIMWORD,\n  NOTLIMWORD,\n  QMARK,\n  STAR,\n  PLUS,\n  REPMN,\n  CAT,\n  OR,\n  ORTOP,\n  LPAREN,\n  RPAREN,\n  CSET\n} token;\n\nstatic token tok;\n\nstatic int\natom ()\n{\n  if ((tok >= 0 && tok < (1 << 8 ) ) || tok >= CSET || tok == BACKREF\n      || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD\n      || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)\n    return 1;\n  else\n    return 0;\n}\n\nmain ()\n{\n  tok = 0;\n  if (atom () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/enum-2.c",
    "content": "/* Copyright (C) 2000 Free Software Foundation */\n/* by Alexandre Oliva  <aoliva@redhat.com> */\n\nenum foo { FOO, BAR };\n\n/* Even though the underlying type of an enum is unspecified, the type\n   of enumeration constants is explicitly defined as int (6.4.4.3/2 in\n   the C99 Standard).  Therefore, `i' must not be promoted to\n   `unsigned' in the comparison below; we must exit the loop when it\n   becomes negative. */\n\nint\nmain ()\n{\n  int i;\n  for (i = BAR; i >= FOO; --i)\n    if (i == -1)\n      abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/enum-3.c",
    "content": "/* The composite type of int and an enum compatible with int might be\n   either of the two types, but it isn't an unsigned type.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\n#include <limits.h>\n\n#include <stdio.h>\n\nextern void abort (void);\nextern void exit (int);\n\nenum e { a = INT_MIN };\n\nint *p;\nenum e *q;\nint\nmain (void)\n{\n  enum e x = a;\n  q = &x;\n  if (*(1 ? q : p) > 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/execute.exp",
    "content": "# Copyright (C) 1991-2016 Free Software Foundation, Inc.\n\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n# \n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n# \n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n\n# This file was written by Rob Savoye. (rob@cygnus.com)\n# Modified and maintained by Jeffrey Wheat (cassidy@cygnus.com)\n\n#\n# These tests come from Torbjorn Granlund (tege@cygnus.com)\n# C torture test suite.\n#\n\n# Load support procs.\nload_lib gcc-dg.exp\n\n# Initialize `dg'.\ndg-init\n\n# Main loop.\nset saved-dg-do-what-default ${dg-do-what-default}\nset dg-do-what-default \"run\"\ngcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\\[cS\\]]] \"\" \"-w\"\nset dg-do-what-default ${saved-dg-do-what-default}\n\n# All done.\ndg-finish\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/extzvsi.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\n/* Failed on powerpc due to bad extzvsi pattern.  */\n\nstruct ieee\n{\n  unsigned int negative:1;\n  unsigned int exponent:11;\n  unsigned int mantissa0:20;\n  unsigned int mantissa1:32;\n} x;\n\nunsigned int\nfoo (void)\n{\n  unsigned int exponent;\n\n  exponent = x.exponent;\n  if (exponent == 0)\n    return 1;\n  else if (exponent > 1)\n    return 2;\n  return 0;\n}\n\nint\nmain (void)\n{\n  x.exponent = 1;\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ffs-1.c",
    "content": "__volatile int a = 0;\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  if (__builtin_ffs (a) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ffs-2.c",
    "content": "struct\n  {\n    int input;\n    int output;\n  }\nffstesttab[] =\n  {\n#if __INT_MAX__ >= 2147483647\n    /* at least 32-bit integers */\n    { 0x80000000, 32 },\n    { 0xa5a5a5a5, 1 },\n    { 0x5a5a5a5a, 2 },\n    { 0xcafe0000, 18 },\n#endif\n#if __INT_MAX__ >= 32767\n    /* at least 16-bit integers */\n    { 0x8000, 16 },\n    { 0xa5a5, 1 },\n    { 0x5a5a, 2 },\n    { 0x0ca0, 6 },\n#endif\n#if __INT_MAX__ < 32767\n#error integers are too small\n#endif\n  };\n\n#define NFFSTESTS (sizeof (ffstesttab) / sizeof (ffstesttab[0]))\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NFFSTESTS; i++)\n    {\n      if (__builtin_ffs (ffstesttab[i].input) != ffstesttab[i].output)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/float-floor.c",
    "content": "\n#if(__SIZEOF_DOUBLE__==8)\ndouble d = 1024.0 - 1.0 / 32768.0;\n#else\ndouble d = 1024.0 - 1.0 / 16384.0;\n#endif\n\nextern double floor(double);\nextern float floorf(float);\nextern void abort();\n\nint main() {\n\n    double df = floor(d);\n    float f1 = (float)floor(d);\n\n    if ((int)df != 1023 || (int)f1 != 1023)\n      abort ();\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/floatunsisf-1.c",
    "content": "/* The fp-bit.c function __floatunsisf had a latent bug where guard bits\n   could be lost leading to incorrect rounding.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\nextern void abort (void);\nextern void exit (int);\n#if __INT_MAX__ >= 0x7fffffff\nvolatile unsigned u = 0x80000081;\n#else\nvolatile unsigned long u = 0x80000081;\n#endif\nvolatile float f1, f2;\nint\nmain (void)\n{\n  f1 = (float) u;\n  f2 = (float) 0x80000081;\n  if (f1 != f2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/fprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain (void)\n{\n#define test(ret, args...) \\\n  fprintf (stdout, args); \t\t\\\n  if (fprintf (stdout, args) != ret)\t\\\n    abort ();\n  test (5, \"hello\");\n  test (6, \"hello\\n\");\n  test (1, \"a\");\n  test (0, \"\");\n  test (5, \"%s\", \"hello\");\n  test (6, \"%s\", \"hello\\n\");\n  test (1, \"%s\", \"a\");\n  test (0, \"%s\", \"\");\n  test (1, \"%c\", 'x');\n  test (7, \"%s\\n\", \"hello\\n\");\n  test (2, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/fprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__fprintf_chk (FILE *f, int flag, const char *fmt, ...)\n{\n  va_list ap;\n  int ret;\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  va_start (ap, fmt);\n  ret = vfprintf (f, fmt, ap);\n  va_end (ap);\n  return ret;\n}\n\nint\nmain (void)\n{\n#define test(ret, opt, args...) \\\n  should_optimize = opt;\t\t\t\\\n  __fprintf_chk (stdout, 1, args); \t\t\\\n  if (!should_optimize)\t\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  should_optimize = 0;\t\t\t\t\\\n  if (__fprintf_chk (stdout, 1, args) != ret)\t\\\n    abort ();\t\t\t\t\t\\\n  if (!should_optimize)\t\t\t\t\\\n    abort ();\n  test (5, 1, \"hello\");\n  test (6, 1, \"hello\\n\");\n  test (1, 1, \"a\");\n  test (0, 1, \"\");\n  test (5, 1, \"%s\", \"hello\");\n  test (6, 1, \"%s\", \"hello\\n\");\n  test (1, 1, \"%s\", \"a\");\n  test (0, 1, \"%s\", \"\");\n  test (1, 1, \"%c\", 'x');\n  test (7, 0, \"%s\\n\", \"hello\\n\");\n  test (2, 0, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/frame-address.c",
    "content": "/* { dg-require-effective-target return_address } */\nint check_fa_work (const char *, const char *) __attribute__((noinline));\nint check_fa_mid (const char *) __attribute__((noinline));\nint check_fa (char *) __attribute__((noinline));\nint how_much (void) __attribute__((noinline));\n\nint check_fa_work (const char *c, const char *f)\n{\n  const char d = 0;\n\n  if (c >= &d)\n    return c >= f && f >= &d;\n  else\n    return c <= f && f <= &d;\n}\n\nint check_fa_mid (const char *c)\n{\n  const char *f = __builtin_frame_address (0);\n\n  /* Prevent a tail call to check_fa_work, eliding the current stack frame.  */\n  return check_fa_work (c, f) != 0;\n}\n\nint check_fa (char *unused)\n{\n  const char c = 0;\n\n  /* Prevent a tail call to check_fa_mid, eliding the current stack frame.  */\n  return check_fa_mid (&c) != 0;\n}\n\nint how_much (void)\n{\n\treturn 8;\n}\n\nint main (void)\n{\n  char *unused = __builtin_alloca (how_much ());\n\n  if (!check_fa(unused))\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/func-ptr-1.c",
    "content": "static double f (float a);\nstatic double (*fp) (float a);\n\nmain ()\n{\n  fp = f;\n  if (fp ((float) 1) != 1.0)\n    abort ();\n  exit (0);\n}\n\nstatic double\nf (float a)\n{\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/gofast.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n/* Program to test gcc's usage of the gofast library.  */\n\n/* The main guiding themes are to make it trivial to add test cases over time\n   and to make it easy for a program to parse the output to see if the right\n   libcalls are being made.  */\n\n#include <stdio.h>\n\nfloat fp_add (float a, float b) { return a + b; }\nfloat fp_sub (float a, float b) { return a - b; }\nfloat fp_mul (float a, float b) { return a * b; }\nfloat fp_div (float a, float b) { return a / b; }\nfloat fp_neg (float a) { return -a; }\n\ndouble dp_add (double a, double b) { return a + b; }\ndouble dp_sub (double a, double b) { return a - b; }\ndouble dp_mul (double a, double b) { return a * b; }\ndouble dp_div (double a, double b) { return a / b; }\ndouble dp_neg (double a) { return -a; }\n\ndouble fp_to_dp (float f) { return f; }\nfloat dp_to_fp (double d) { return d; }\n\nint eqsf2 (float a, float b) { return a == b; }\nint nesf2 (float a, float b) { return a != b; }\nint gtsf2 (float a, float b) { return a > b; }\nint gesf2 (float a, float b) { return a >= b; }\nint ltsf2 (float a, float b) { return a < b; }\nint lesf2 (float a, float b) { return a <= b; }\n\nint eqdf2 (double a, double b) { return a == b; }\nint nedf2 (double a, double b) { return a != b; }\nint gtdf2 (double a, double b) { return a > b; }\nint gedf2 (double a, double b) { return a >= b; }\nint ltdf2 (double a, double b) { return a < b; }\nint ledf2 (double a, double b) { return a <= b; }\n\nfloat floatsisf (int i) { return i; }\ndouble floatsidf (int i) { return i; }\nint fixsfsi (float f) { return f; }\nint fixdfsi (double d) { return d; }\nunsigned int fixunssfsi (float f) { return f; }\nunsigned int fixunsdfsi (double d) { return d; }\n\nint fail_count = 0;\n\nint\nfail (char *msg)\n{\n  fail_count++;\n  fprintf (stderr, \"Test failed: %s\\n\", msg);\n}\n\nint\nmain()\n{\n  if (fp_add (1, 1) != 2) fail (\"fp_add 1+1\");\n  if (fp_sub (3, 2) != 1) fail (\"fp_sub 3-2\");\n  if (fp_mul (2, 3) != 6) fail (\"fp_mul 2*3\");\n  if (fp_div (3, 2) != 1.5) fail (\"fp_div 3/2\");\n  if (fp_neg (1) != -1) fail (\"fp_neg 1\");\n\n  if (dp_add (1, 1) != 2) fail (\"dp_add 1+1\");\n  if (dp_sub (3, 2) != 1) fail (\"dp_sub 3-2\");\n  if (dp_mul (2, 3) != 6) fail (\"dp_mul 2*3\");\n  if (dp_div (3, 2) != 1.5) fail (\"dp_div 3/2\");\n  if (dp_neg (1) != -1) fail (\"dp_neg 1\");\n\n  if (fp_to_dp (1.5) != 1.5) fail (\"fp_to_dp 1.5\");\n  if (dp_to_fp (1.5) != 1.5) fail (\"dp_to_fp 1.5\");\n\n  if (floatsisf (1) != 1) fail (\"floatsisf 1\");\n  if (floatsidf (1) != 1) fail (\"floatsidf 1\");\n  if (fixsfsi (1.42) != 1) fail (\"fixsfsi 1.42\");\n  if (fixunssfsi (1.42) != 1) fail (\"fixunssfsi 1.42\");\n  if (fixdfsi (1.42) != 1) fail (\"fixdfsi 1.42\");\n  if (fixunsdfsi (1.42) != 1) fail (\"fixunsdfsi 1.42\");\n\n  if (eqsf2 (1, 1) == 0) fail (\"eqsf2 1==1\");\n  if (eqsf2 (1, 2) != 0) fail (\"eqsf2 1==2\");\n  if (nesf2 (1, 2) == 0) fail (\"nesf2 1!=1\");\n  if (nesf2 (1, 1) != 0) fail (\"nesf2 1!=1\");\n  if (gtsf2 (2, 1) == 0) fail (\"gtsf2 2>1\");\n  if (gtsf2 (1, 1) != 0) fail (\"gtsf2 1>1\");\n  if (gtsf2 (0, 1) != 0) fail (\"gtsf2 0>1\");\n  if (gesf2 (2, 1) == 0) fail (\"gesf2 2>=1\");\n  if (gesf2 (1, 1) == 0) fail (\"gesf2 1>=1\");\n  if (gesf2 (0, 1) != 0) fail (\"gesf2 0>=1\");\n  if (ltsf2 (1, 2) == 0) fail (\"ltsf2 1<2\");\n  if (ltsf2 (1, 1) != 0) fail (\"ltsf2 1<1\");\n  if (ltsf2 (1, 0) != 0) fail (\"ltsf2 1<0\");\n  if (lesf2 (1, 2) == 0) fail (\"lesf2 1<=2\");\n  if (lesf2 (1, 1) == 0) fail (\"lesf2 1<=1\");\n  if (lesf2 (1, 0) != 0) fail (\"lesf2 1<=0\");\n\n  if (fail_count != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20000320-1.c",
    "content": "#if __INT_MAX__ != 2147483647 || (__LONG_LONG_MAX__ != 9223372036854775807ll && __LONG_MAX__ != 9223372036854775807ll)\nint main(void) { exit (0); }\n#else\n#if __LONG_MAX__ != 9223372036854775807ll\ntypedef unsigned long long ull;\n#else\ntypedef unsigned long ull;\n#endif\ntypedef unsigned ul;\n\nunion fl {\n  float\tf;\n  ul l;\n} uf;\nunion dl {\n  double d;\n  ull ll;\n} ud;\n\nint failed = 0;\n\nvoid c(ull d, ul f)\n{\n  ud.ll = d;\n  uf.f = (float) ud.d;\n  if (uf.l != f)\n    {\n      failed++;\n    }\n}\n\nint main()\n{\n  if (sizeof (float) != sizeof (ul)\n      || sizeof (double) != sizeof (ull))\n    exit (0);\n  \n#if (defined __arm__ || defined __thumb__) && ! (defined __ARMEB__ || defined __VFP_FP__)\n  /* The ARM always stores FP numbers in big-wordian format,\n     even when running in little-byteian mode.  */\n  c(0x0000000036900000ULL, 0x00000000U);\n  c(0x0000000136900000ULL, 0x00000001U);\n  c(0xffffffff369fffffULL, 0x00000001U);\n  c(0x0000000036A00000ULL, 0x00000001U);\n  c(0xffffffff36A7ffffULL, 0x00000001U);\n  c(0x0000000036A80000ULL, 0x00000002U);\n  c(0xffffffff36AfffffULL, 0x00000002U);\n  c(0x0000000036b00000ULL, 0x00000002U);\n  c(0x0000000136b00000ULL, 0x00000002U);\n  \n  c(0xdfffffff380fffffULL, 0x007fffffU);\n  c(0xe0000000380fffffULL, 0x00800000U);\n  c(0xe0000001380fffffULL, 0x00800000U);\n  c(0xffffffff380fffffULL, 0x00800000U);\n  c(0x0000000038100000ULL, 0x00800000U);\n  c(0x0000000138100000ULL, 0x00800000U);\n  c(0x1000000038100000ULL, 0x00800000U);\n  c(0x1000000138100000ULL, 0x00800001U);\n  c(0x2fffffff38100000ULL, 0x00800001U);\n  c(0x3000000038100000ULL, 0x00800002U);\n  c(0x5000000038100000ULL, 0x00800002U);\n  c(0x5000000138100000ULL, 0x00800003U);\n#else\n  c(0x3690000000000000ULL, 0x00000000U);\n  c(0x3690000000000001ULL, 0x00000001U);\n  c(0x369fffffffffffffULL, 0x00000001U);\n  c(0x36A0000000000000ULL, 0x00000001U);\n  c(0x36A7ffffffffffffULL, 0x00000001U);\n  c(0x36A8000000000000ULL, 0x00000002U);\n  c(0x36AfffffffffffffULL, 0x00000002U);\n  c(0x36b0000000000000ULL, 0x00000002U);\n  c(0x36b0000000000001ULL, 0x00000002U);\n  \n  c(0x380fffffdfffffffULL, 0x007fffffU);\n  c(0x380fffffe0000000ULL, 0x00800000U);\n  c(0x380fffffe0000001ULL, 0x00800000U);\n  c(0x380fffffffffffffULL, 0x00800000U);\n  c(0x3810000000000000ULL, 0x00800000U);\n  c(0x3810000000000001ULL, 0x00800000U);\n  c(0x3810000010000000ULL, 0x00800000U);\n  c(0x3810000010000001ULL, 0x00800001U);\n  c(0x381000002fffffffULL, 0x00800001U);\n  c(0x3810000030000000ULL, 0x00800002U);\n  c(0x3810000050000000ULL, 0x00800002U);\n  c(0x3810000050000001ULL, 0x00800003U);\n#endif\n\n  if (failed)\n    abort ();\n  else\n    exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20000320-1.x",
    "content": "if {[istarget \"m68k-*-*\"] && [check_effective_target_coldfire_fpu]} {\n    # ColdFire FPUs require software handling of subnormals.  We are\n    # not aware of any system that has this.\n    set torture_execute_xfail \"m68k-*-*\"\n}\nif [istarget \"avr-*-*\"] {\n    # AVR doubles are floats\n    return 1\n}\nif { [istarget \"tic6x-*-*\"] && [check_effective_target_ti_c67x] } {\n    # C6X floating point hardware turns denormals to zero in FP conversions.\n    set torture_execute_xfail \"tic6x-*-*\"\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20001122-1.c",
    "content": "volatile double a, *p;\n\nint main ()\n{\n  double c, d;\n  volatile double b;\n\n  d = 1.0;\n  p = &b;\n  do\n  {\n    c = d;\n    d = c * 0.5;\n    b = 1 + d;\n  } while (b != 1.0);\n\n  a = 1.0 + c;\n  if (a == 1.0)\n    abort();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20010114-2.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nfloat\nrintf (float x)\n{\n  static const float TWO23 = 8388608.0;\n\n  if (__builtin_fabs (x) < TWO23)\n    {\n      if (x > 0.0)\n        {\n          x += TWO23;\n          x -= TWO23;\n        }\n      else if (x < 0.0)\n        {\n          x = TWO23 - x;\n          x = -(x - TWO23);\n        }\n    }\n\n  return x;\n}\n\nint main (void)\n{\n  if (rintf (-1.5) != -2.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20010114-2.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # This doesn't work on the SPU because single precision floats are\n    # always rounded toward 0.\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20010226-1.c",
    "content": "#include <float.h>\n\nlong double dfrom = 1.1L;\nlong double m1;\nlong double m2;\nunsigned long mant_long;\n\nint main()\n{\n  /* Some targets don't support a conforming long double type.  This is\n     common with very small parts which set long double == float.   Look\n     to see if the type has at least 32 bits of precision.  */\n  if (LDBL_EPSILON > 0x1p-31L)\n    return 0;\n\n  m1 = dfrom / 2.0L;\n  m2 = m1 * 4294967296.0L;\n  mant_long = ((unsigned long) m2) & 0xffffffff;\n\n  if (mant_long == 0x8ccccccc)\n    return 0;\n  else\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20011123-1.c",
    "content": "main()\n{\n  double db1 = 1.7976931348623157e+308;\n  long double ldb1 = db1;\n\n  if (sizeof (double) != 8 || sizeof (long double) != 16)\n    exit (0);\n\n  if (ldb1 != 1.7976931348623157e+308)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20030331-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\nfloat x = -1.5f;\n\nfloat\nrintf ()\n{\n  static const float TWO23 = 8388608.0;\n\n  if (__builtin_fabs (x) < TWO23)\n    {\n      if (x > 0.0)\n        {\n          x += TWO23;\n          x -= TWO23;\n        }\n      else if (x < 0.0)\n        {\n          x = TWO23 - x;\n          x = -(x - TWO23);\n        }\n    }\n\n  return x;\n}\n\nint main (void)\n{\n  if (rintf () != -2.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20030331-1.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # This doesn't work on the SPU because single precision floats are\n    # always rounded toward 0.\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/20041213-1.c",
    "content": "extern double sqrt (double);\nextern void abort (void);\nint once;\n\ndouble foo (void)\n{\n  if (once++)\n    abort ();\n  return 0.0 / 0.0;\n}\n\ndouble x;\nint main (void)\n{\n  x = sqrt (foo ());\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/920518-1.c",
    "content": "unsigned u=2147483839;float f0=2147483648e0,f1=2147483904e0;\nmain()\n{\n  float f=u;\n  if(f==f0)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/920518-1.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # This doesn't work on the SPU because single precision floats are\n    # always rounded toward 0.\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/920810-1.c",
    "content": "#include <stdio.h>\ndouble normalize(x)double x;{if(x==0)x=0;return x;}\nmain(){char b[9];sprintf(b,\"%g\",normalize(-0.0));if(strcmp(b,\"0\"))abort();exit(0);}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/930529-1.c",
    "content": "main ()\n{\n  union {\n    double d;\n    unsigned char c[8];\n  } d;\n\n  d.d = 1.0/7.0;\n\n  if (sizeof (char) * 8 == sizeof (double))\n    {\n      if (d.c[0] == 0x92 && d.c[1] == 0x24 && d.c[2] == 0x49 && d.c[3] == 0x92\n\t  && d.c[4] == 0x24 && d.c[5] == 0x49 && d.c[6] == 0xc2 && d.c[7] == 0x3f)\n\texit (0);\n      if (d.c[7] == 0x92 && d.c[6] == 0x24 && d.c[5] == 0x49 && d.c[4] == 0x92\n\t  && d.c[3] == 0x24 && d.c[2] == 0x49 && d.c[1] == 0xc2 && d.c[0] == 0x3f)\n\texit (0);\n#if defined __arm__ || defined __thumb__\n      if (d.c[4] == 0x92 && d.c[5] == 0x24 && d.c[6] == 0x49 && d.c[7] == 0x92\n\t  && d.c[0] == 0x24 && d.c[1] == 0x49 && d.c[2] == 0xc2 && d.c[3] == 0x3f)\n\texit (0);\n#endif\n      abort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/980619-1.c",
    "content": "\tint main(void)\n\t{\n\t\tfloat reale = 1.0f;\n\t\tfloat oneplus;\n\t\tint i;\n\t\n\t \tif (sizeof (float) != 4)\n\t\t  exit (0);\n\n\t\tfor (i = 0; ; i++)\n\t\t{\n\t\t\toneplus = 1.0f + reale;\n\t\t\tif (oneplus == 1.0f)\n\t\t\t\tbreak;\n\t\t\treale=reale/2.0f;\n\t\t}\n\t\t/* Assumes ieee754 accurate arithmetic above.  */\n\t\tif (i != 24)\n\t\t  abort ();\n\t\telse\n\t\t  exit (0);\n\t}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/980619-1.x",
    "content": "# This used to fail on ia32, with or without -ffloat-store.\n# It works now, but some people think that's a fluke, so I'm\n# keeping this around just in case.\n\n#set torture_eval_before_execute {\n#\n#    set compiler_conditional_xfail_data {\n#        \"ia32 fp rounding isn't pedantic\" \\\n#        \"i?86-*-*\" \\\n#        { \"-O3\" \"-O2\" \"-O1\" \"-Os\"} \\\n#        { \"\" }\n#        }    \n#}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/acc1.c",
    "content": "/* Tail call optimizations would reverse the order of additions in func().  */\n\ndouble func (const double *array)\n{\n  double d = *array;\n  if (d == 0.0)\n    return d;\n  else\n    return d + func (array + 1);\n}\n\nint main ()\n{\n  double values[] = { 0.1e-100, 1.0, -1.0, 0.0 };\n  if (func (values) != 0.1e-100)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/acc2.c",
    "content": "/* Tail call optimizations would reverse the order of multiplications\n   in func().  */\n\ndouble func (const double *array)\n{\n  double d = *array;\n  if (d == 1.0)\n    return d;\n  else\n    return d * func (array + 1);\n}\n\nint main ()\n{\n  double values[] = { __DBL_MAX__, 2.0, 0.5, 1.0 };\n  if (func (values) != __DBL_MAX__)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/builtin-nan-1.c",
    "content": "/* PR middle-end/19983 */\n\ntypedef __SIZE_TYPE__ size_t;\n\nextern void abort(void);\nextern int memcmp(const void *, const void *, size_t);\n\ndouble n1 = __builtin_nan(\"0x1\");\ndouble n2 = __builtin_nan(\"0X1\");\n\nint main()\n{\n  if (memcmp (&n1, &n2, sizeof(double)))\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-1.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Test for correctness of composite floating-point comparisons.\n\n   Written by Paolo Bonzini, 26th May 2004.  */\n\nextern void abort (void);\n\n#define TEST(c) if ((c) != ok) abort ();\n#define ORD(a, b) (!__builtin_isunordered ((a), (b)))\n#define UNORD(a, b) (__builtin_isunordered ((a), (b)))\n#define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b)))\n#define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b)))\n#define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b)))\n#define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b)))\n#define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b)))\n#define LTGT(a, b) (__builtin_islessgreater ((a), (b)))\n\nfloat pinf;\nfloat ninf;\nfloat NaN;\n\nint iuneq (float x, float y, int ok)\n{\n  TEST (UNEQ (x, y));\n  TEST (!LTGT (x, y));\n  TEST (UNLE (x, y) && UNGE (x,y));\n}\n\nint ieq (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNEQ (x, y));\n}\n\nint iltgt (float x, float y, int ok)\n{\n  TEST (!UNEQ (x, y)); /* Not optimizable. */\n  TEST (LTGT (x, y)); /* Same, __builtin_islessgreater does not trap. */\n  TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y)));\n}\n\nint ine (float x, float y, int ok)\n{\n  TEST (UNLT (x, y) || UNGT (x, y));\n}\n\nint iunlt (float x, float y, int ok)\n{\n  TEST (UNLT (x, y));\n  TEST (UNORD (x, y) || (x < y));\n}\n\nint ilt (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNLT (x, y)); /* Not optimized */\n  TEST ((x <= y) && (x != y));\n  TEST ((x <= y) && (y != x));\n  TEST ((x != y) && (x <= y)); /* Not optimized */\n  TEST ((y != x) && (x <= y)); /* Not optimized */\n}\n\nint iunle (float x, float y, int ok)\n{\n  TEST (UNLE (x, y));\n  TEST (UNORD (x, y) || (x <= y));\n}\n\nint ile (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNLE (x, y)); /* Not optimized */\n  TEST ((x < y) || (x == y));\n  TEST ((y > x) || (x == y));\n  TEST ((x == y) || (x < y)); /* Not optimized */\n  TEST ((y == x) || (x < y)); /* Not optimized */\n}\n\nint iungt (float x, float y, int ok)\n{\n  TEST (UNGT (x, y));\n  TEST (UNORD (x, y) || (x > y));\n}\n\nint igt (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNGT (x, y)); /* Not optimized */\n  TEST ((x >= y) && (x != y));\n  TEST ((x >= y) && (y != x));\n  TEST ((x != y) && (x >= y)); /* Not optimized */\n  TEST ((y != x) && (x >= y)); /* Not optimized */\n}\n\nint iunge (float x, float y, int ok)\n{\n  TEST (UNGE (x, y));\n  TEST (UNORD (x, y) || (x >= y));\n}\n\nint ige (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNGE (x, y)); /* Not optimized */\n  TEST ((x > y) || (x == y));\n  TEST ((y < x) || (x == y));\n  TEST ((x == y) || (x > y)); /* Not optimized */\n  TEST ((y == x) || (x > y)); /* Not optimized */\n}\n\nint\nmain ()\n{\n  pinf = __builtin_inf ();\n  ninf = -__builtin_inf ();\n  NaN = __builtin_nan (\"\");\n\n  iuneq (ninf, pinf, 0);\n  iuneq (NaN, NaN, 1);\n  iuneq (pinf, ninf, 0);\n  iuneq (1, 4, 0);\n  iuneq (3, 3, 1);\n  iuneq (5, 2, 0);\n\n  ieq (1, 4, 0);\n  ieq (3, 3, 1);\n  ieq (5, 2, 0);\n\n  iltgt (ninf, pinf, 1);\n  iltgt (NaN, NaN, 0);\n  iltgt (pinf, ninf, 1);\n  iltgt (1, 4, 1);\n  iltgt (3, 3, 0);\n  iltgt (5, 2, 1);\n\n  ine (1, 4, 1);\n  ine (3, 3, 0);\n  ine (5, 2, 1);\n\n  iunlt (NaN, ninf, 1);\n  iunlt (pinf, NaN, 1);\n  iunlt (pinf, ninf, 0);\n  iunlt (pinf, pinf, 0);\n  iunlt (ninf, ninf, 0);\n  iunlt (1, 4, 1);\n  iunlt (3, 3, 0);\n  iunlt (5, 2, 0);\n\n  ilt (1, 4, 1);\n  ilt (3, 3, 0);\n  ilt (5, 2, 0);\n\n  iunle (NaN, ninf, 1);\n  iunle (pinf, NaN, 1);\n  iunle (pinf, ninf, 0);\n  iunle (pinf, pinf, 1);\n  iunle (ninf, ninf, 1);\n  iunle (1, 4, 1);\n  iunle (3, 3, 1);\n  iunle (5, 2, 0);\n\n  ile (1, 4, 1);\n  ile (3, 3, 1);\n  ile (5, 2, 0);\n\n  iungt (NaN, ninf, 1);\n  iungt (pinf, NaN, 1);\n  iungt (pinf, ninf, 1);\n  iungt (pinf, pinf, 0);\n  iungt (ninf, ninf, 0);\n  iungt (1, 4, 0);\n  iungt (3, 3, 0);\n  iungt (5, 2, 1);\n\n  igt (1, 4, 0);\n  igt (3, 3, 0);\n  igt (5, 2, 1);\n\n  iunge (NaN, ninf, 1);\n  iunge (pinf, NaN, 1);\n  iunge (ninf, pinf, 0);\n  iunge (pinf, pinf, 1);\n  iunge (ninf, ninf, 1);\n  iunge (1, 4, 0);\n  iunge (3, 3, 1);\n  iunge (5, 2, 1);\n\n  ige (1, 4, 0);\n  ige (3, 3, 1);\n  ige (5, 2, 1);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-1.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support Nan & Inf. \n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-2.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Ensure that the composite comparison optimization doesn't misfire\n   and attempt to combine an integer comparison with a floating-point one.\n\n   Written by Paolo Bonzini, 26th May 2004.  */\n\nextern void abort (void);\n\nint\nfoo (double x, double y)\n{\n  /* If miscompiled the following may become false.  */\n  return (x > y) && ((int)x == (int)y);\n}\n\nint\nmain ()\n{\n  if (! foo (1.3,1.0))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Test for composite comparison always true/false optimization.\n\n   Written by Paolo Bonzini, 26th May 2004.  */\n\nextern void link_error0 ();\nextern void link_error1 ();\n\nvoid\ntest1 (float x, float y)\n{\n  if ((x==y) && (x!=y))\n    link_error0();\n}\n\nvoid\ntest2 (float x, float y)\n{\n  if ((x<y) && (x>y))\n    link_error0();\n}\n\nvoid\ntest3 (float x, float y)\n{\n  if ((x<y) && (y<x))\n    link_error0();\n}\n\nvoid \ntest4 (float x, float y)\n{\n  if ((x==y) || (x!=y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest5 (float x, float y)\n{\n  if (__builtin_isunordered (x, y) || (x>=y) || (x<y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest6 (float x, float y)\n{\n  if (__builtin_isunordered (y, x) || (x<=y) || (y<x))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest7 (float x, float y)\n{\n  if (__builtin_isunordered (x, y) || !__builtin_isunordered (x, y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\nall_tests (float x, float y)\n{\n  test1 (x, y);\n  test2 (x, y);\n  test3 (x, y);\n  test4 (x, y);\n  test5 (x, y);\n  test6 (x, y);\n  test7 (x, y);\n}\n\nint\nmain ()\n{\n  all_tests (0, 0);\n  all_tests (1, 2);\n  all_tests (4, 3);\n\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid link_error0() {}\nvoid link_error1() {}\n#endif /* ! __OPTIMIZE__ */\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.x",
    "content": "lappend additional_flags \"-fno-trapping-math\"\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Test for correctness of composite floating-point comparisons.\n\n   Written by Paolo Bonzini, 26th May 2004.  */\n\nextern void abort (void);\n\n#define TEST(c) if ((c) != ok) abort ();\n#define ORD(a, b) (((a) < (b)) || (a) >= (b))\n#define UNORD(a, b) (!ORD ((a), (b)))\n#define UNEQ(a, b) (!LTGT ((a), (b)))\n#define UNLT(a, b) (((a) < (b)) || __builtin_isunordered ((a), (b)))\n#define UNLE(a, b) (((a) <= (b)) || __builtin_isunordered ((a), (b)))\n#define UNGT(a, b) (((a) > (b)) || __builtin_isunordered ((a), (b)))\n#define UNGE(a, b) (((a) >= (b)) || __builtin_isunordered ((a), (b)))\n#define LTGT(a, b) (((a) < (b)) || (a) > (b))\n\nfloat pinf;\nfloat ninf;\nfloat NaN;\n\nint iuneq (float x, float y, int ok)\n{\n  TEST (UNEQ (x, y));\n  TEST (!LTGT (x, y));\n  TEST (UNLE (x, y) && UNGE (x,y));\n}\n\nint ieq (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNEQ (x, y));\n}\n\nint iltgt (float x, float y, int ok)\n{\n  TEST (!UNEQ (x, y));\n  TEST (LTGT (x, y));\n  TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y)));\n}\n\nint ine (float x, float y, int ok)\n{\n  TEST (UNLT (x, y) || UNGT (x, y));\n  TEST ((x < y) || (x > y) || UNORD (x, y));\n}\n\nint iunlt (float x, float y, int ok)\n{\n  TEST (UNLT (x, y));\n  TEST (UNORD (x, y) || (x < y));\n}\n\nint ilt (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNLT (x, y));\n  TEST ((x <= y) && (x != y));\n  TEST ((x <= y) && (y != x));\n  TEST ((x != y) && (x <= y));\n  TEST ((y != x) && (x <= y));\n}\n\nint iunle (float x, float y, int ok)\n{\n  TEST (UNLE (x, y));\n  TEST (UNORD (x, y) || (x <= y));\n}\n\nint ile (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNLE (x, y));\n  TEST ((x < y) || (x == y));\n  TEST ((y > x) || (x == y));\n  TEST ((x == y) || (x < y));\n  TEST ((y == x) || (x < y));\n}\n\nint iungt (float x, float y, int ok)\n{\n  TEST (UNGT (x, y));\n  TEST (UNORD (x, y) || (x > y));\n}\n\nint igt (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNGT (x, y));\n  TEST ((x >= y) && (x != y));\n  TEST ((x >= y) && (y != x));\n  TEST ((x != y) && (x >= y));\n  TEST ((y != x) && (x >= y));\n}\n\nint iunge (float x, float y, int ok)\n{\n  TEST (UNGE (x, y));\n  TEST (UNORD (x, y) || (x >= y));\n}\n\nint ige (float x, float y, int ok)\n{\n  TEST (ORD (x, y) && UNGE (x, y));\n  TEST ((x > y) || (x == y));\n  TEST ((y < x) || (x == y));\n  TEST ((x == y) || (x > y));\n  TEST ((y == x) || (x > y));\n}\n\nint\nmain ()\n{\n  pinf = __builtin_inf ();\n  ninf = -__builtin_inf ();\n  NaN = __builtin_nan (\"\");\n\n  iuneq (ninf, pinf, 0);\n  iuneq (NaN, NaN, 1);\n  iuneq (pinf, ninf, 0);\n  iuneq (1, 4, 0);\n  iuneq (3, 3, 1);\n  iuneq (5, 2, 0);\n\n  ieq (1, 4, 0);\n  ieq (3, 3, 1);\n  ieq (5, 2, 0);\n\n  iltgt (ninf, pinf, 1);\n  iltgt (NaN, NaN, 0);\n  iltgt (pinf, ninf, 1);\n  iltgt (1, 4, 1);\n  iltgt (3, 3, 0);\n  iltgt (5, 2, 1);\n\n  ine (1, 4, 1);\n  ine (3, 3, 0);\n  ine (5, 2, 1);\n\n  iunlt (NaN, ninf, 1);\n  iunlt (pinf, NaN, 1);\n  iunlt (pinf, ninf, 0);\n  iunlt (pinf, pinf, 0);\n  iunlt (ninf, ninf, 0);\n  iunlt (1, 4, 1);\n  iunlt (3, 3, 0);\n  iunlt (5, 2, 0);\n\n  ilt (1, 4, 1);\n  ilt (3, 3, 0);\n  ilt (5, 2, 0);\n\n  iunle (NaN, ninf, 1);\n  iunle (pinf, NaN, 1);\n  iunle (pinf, ninf, 0);\n  iunle (pinf, pinf, 1);\n  iunle (ninf, ninf, 1);\n  iunle (1, 4, 1);\n  iunle (3, 3, 1);\n  iunle (5, 2, 0);\n\n  ile (1, 4, 1);\n  ile (3, 3, 1);\n  ile (5, 2, 0);\n\n  iungt (NaN, ninf, 1);\n  iungt (pinf, NaN, 1);\n  iungt (pinf, ninf, 1);\n  iungt (pinf, pinf, 0);\n  iungt (ninf, ninf, 0);\n  iungt (1, 4, 0);\n  iungt (3, 3, 0);\n  iungt (5, 2, 1);\n\n  igt (1, 4, 0);\n  igt (3, 3, 0);\n  igt (5, 2, 1);\n\n  iunge (NaN, ninf, 1);\n  iunge (pinf, NaN, 1);\n  iunge (ninf, pinf, 0);\n  iunge (pinf, pinf, 1);\n  iunge (ninf, ninf, 1);\n  iunge (1, 4, 0);\n  iunge (3, 3, 1);\n  iunge (5, 2, 1);\n\n  ige (1, 4, 0);\n  ige (3, 3, 1);\n  ige (5, 2, 1);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.x",
    "content": "# The ARM VxWorks kernel uses an external floating-point library in\n# which routines like __ledf2 are just aliases for __cmpdf2.  These\n# routines therefore don't handle NaNs correctly.\nif [istarget \"arm*-*-vxworks*\"] {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The ARM kernel uses a flawed floating-point library.\"\n\t    { \"*-*-*\" }\n\t    {}\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nif [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support Nan & Inf.\n    return 1\n}\n\nlappend additional_flags \"-fno-trapping-math\"\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c",
    "content": "#include <string.h>\n#include <stdlib.h>\n#include <float.h>\n\n#define fpsizeoff\tsizeof(float)\n#define fpsizeof\tsizeof(double)\n#define fpsizeofl\tsizeof(long double)\n\n/* Work around the fact that with the Intel double-extended precision,\n   we've got a 10 byte type stuffed into some amount of padding.  And\n   the fact that -ffloat-store is going to stuff this value temporarily\n   into some bit of stack frame that we've no control over and can't zero.  */\n#if LDBL_MANT_DIG == 64\n# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)\n#  undef fpsizeofl\n#  define fpsizeofl\t10\n# endif\n#endif\n\n/* Work around the fact that the sign of the second double in the IBM\n   double-double format is not strictly specified when it contains a zero.\n   For instance, -0.0L can be represented with either (-0.0, +0.0) or\n   (-0.0, -0.0).  The former is what we'll get from the compiler when it\n   builds constants; the later is what we'll get from the negation operator\n   at runtime.  */\n/* ??? This hack only works for big-endian, which is fortunately true for\n   AIX and, Darwin.  */\n#if LDBL_MANT_DIG == 106\n# undef fpsizeofl\n# define fpsizeofl\tsizeof(double)\n#endif\n\n\n#define TEST(TYPE, EXT)\t\t\t\t\t\t\\\nTYPE c##EXT (TYPE x, TYPE y)\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  return __builtin_copysign##EXT (x, y);\t\t\t\\\n}\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nstruct D##EXT { TYPE x, y, z; };\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nstatic const struct D##EXT T##EXT[] = {\t\t\t\t\\\n  { 1.0, 2.0, 1.0 },\t\t\t\t\t\t\\\n  { 1.0, -2.0, -1.0 },\t\t\t\t\t\t\\\n  { -1.0, -2.0, -1.0 },\t\t\t\t\t\t\\\n  { 0.0, -2.0, -0.0 },\t\t\t\t\t\t\\\n  { -0.0, -2.0, -0.0 },\t\t\t\t\t\t\\\n  { -0.0, 2.0, 0.0 },\t\t\t\t\t\t\\\n  { __builtin_inf##EXT (), -0.0, -__builtin_inf##EXT () },\t\\\n  { -__builtin_nan##EXT (\"\"), __builtin_inf##EXT (),\t\t\\\n    __builtin_nan##EXT (\"\") }\t\t\t\t\t\\\n};\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nvoid test##EXT (void)\t\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  int i, n = sizeof (T##EXT) / sizeof (T##EXT[0]);\t\t\\\n  TYPE r;\t\t\t\t\t\t\t\\\n  for (i = 0; i < n; ++i)\t\t\t\t\t\\\n    {\t\t\t\t\t\t\t\t\\\n      r = c##EXT (T##EXT[i].x, T##EXT[i].y);\t\t\t\\\n      if (memcmp (&r, &T##EXT[i].z, fpsizeof##EXT) != 0)\t\\\n\tabort ();\t\t\t\t\t\t\\\n    }\t\t\t\t\t\t\t\t\\\n}\n\nTEST(float, f)\nTEST(double, )\nTEST(long double, l)\n\nint main()\n{\n  testf();\n  test();\n  testl();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c",
    "content": "#include <string.h>\n#include <stdlib.h>\n#include <float.h>\n\n#define fpsizeoff\tsizeof(float)\n#define fpsizeof\tsizeof(double)\n#define fpsizeofl\tsizeof(long double)\n\n/* Work around the fact that with the Intel double-extended precision,\n   we've got a 10 byte type stuffed into some amount of padding.  And\n   the fact that -ffloat-store is going to stuff this value temporarily\n   into some bit of stack frame that we've no control over and can't zero.  */\n#if LDBL_MANT_DIG == 64\n# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)\n#  undef fpsizeofl\n#  define fpsizeofl\t10\n# endif\n#endif\n\n/* Work around the fact that the sign of the second double in the IBM\n   double-double format is not strictly specified when it contains a zero.\n   For instance, -0.0L can be represented with either (-0.0, +0.0) or\n   (-0.0, -0.0).  The former is what we'll get from the compiler when it\n   builds constants; the later is what we'll get from the negation operator\n   at runtime.  */\n/* ??? This hack only works for big-endian, which is fortunately true for\n   AIX and Darwin.  */\n#if LDBL_MANT_DIG == 106\n# undef fpsizeofl\n# define fpsizeofl\tsizeof(double)\n#endif\n\n\n#define TEST(TYPE, EXT)\t\t\t\t\t\t\\\nstatic TYPE Y##EXT[] = {\t\t\t\t\t\\\n  2.0, -2.0, -2.0, -2.0, -2.0, 2.0, -0.0, __builtin_inf##EXT ()\t\\\n};\t\t\t\t\t\t\t\t\\\nstatic const TYPE Z##EXT[] = {\t\t\t\t\t\\\n  1.0, -1.0, -1.0, -0.0, -0.0, 0.0, -__builtin_inf##EXT (),\t\\\n  __builtin_nan##EXT (\"\")\t\t\t\t\t\\\n};\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nvoid test##EXT (void)\t\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  TYPE r[8];\t\t\t\t\t\t\t\\\n  int i;\t\t\t\t\t\t\t\\\n  r[0] = __builtin_copysign##EXT (1.0, Y##EXT[0]);\t\t\\\n  r[1] = __builtin_copysign##EXT (1.0, Y##EXT[1]);\t\t\\\n  r[2] = __builtin_copysign##EXT (-1.0, Y##EXT[2]);\t\t\\\n  r[3] = __builtin_copysign##EXT (0.0, Y##EXT[3]);\t\t\\\n  r[4] = __builtin_copysign##EXT (-0.0, Y##EXT[4]);\t\t\\\n  r[5] = __builtin_copysign##EXT (-0.0, Y##EXT[5]);\t\t\\\n  r[6] = __builtin_copysign##EXT (__builtin_inf##EXT (), Y##EXT[6]); \\\n  r[7] = __builtin_copysign##EXT (-__builtin_nan##EXT (\"\"), Y##EXT[7]); \\\n  for (i = 0; i < 8; ++i)\t\t\t\t\t\\\n    if (memcmp (r+i, Z##EXT+i, fpsizeof##EXT) != 0)\t\t\\\n      abort ();\t\t\t\t\t\t\t\\\n}\n\nTEST(float, f)\nTEST(double, )\nTEST(long double, l)\n\nint main()\n{\n  testf();\n  test();\n  testl();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c",
    "content": "#ifndef SIGNAL_SUPPRESS\n#include <signal.h>\n#endif\n\ndouble dnan = 1.0/0.0 - 1.0/0.0;\ndouble x = 1.0;\n\nvoid leave ()\n{\n  exit (0);\n}\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  /* Move this line earlier, for architectures (like alpha) that issue \n     SIGFPE on the first comparisons. */\n#ifndef SIGNAL_SUPPRESS\n  /* Some machines catches a SIGFPE when a NaN is compared.\n     Let this test succeed o such machines.  */\n  signal (SIGFPE, leave);\n#endif\n  /* NaN is an IEEE unordered operand.  All these test should be false.  */\n  if (dnan == dnan)\n    abort ();\n  if (dnan != x)\n    x = 1.0;\n  else\n    abort ();\n\n  if (dnan < x)\n    abort ();\n  if (dnan > x)\n    abort ();\n  if (dnan <= x)\n    abort ();\n  if (dnan >= x)\n    abort ();\n  if (dnan == x)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.x",
    "content": "# The ARM VxWorks kernel uses an external floating-point library in\n# which routines like __ledf2 are just aliases for __cmpdf2.  These\n# routines therefore don't handle NaNs correctly.\nif [istarget \"arm*-*-vxworks*\"] {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The ARM kernel uses a flawed floating-point library.\"\n\t    { \"*-*-*\" }\n\t    {}\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.c",
    "content": "#ifndef SIGNAL_SUPPRESS\n#include <signal.h>\n#endif\n\nfloat fnan = 1.0f/0.0f - 1.0f/0.0f;\nfloat x = 1.0f;\n\nvoid leave ()\n{\n  exit (0);\n}\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  /* Move this line earlier, for architectures (like alpha) that issue \n     SIGFPE on the first comparisons. */\n#ifndef SIGNAL_SUPPRESS\n  /* Some machines catches a SIGFPE when a NaN is compared.\n     Let this test succeed o such machines.  */\n  signal (SIGFPE, leave);\n#endif\n  /* NaN is an IEEE unordered operand.  All these test should be false.  */\n  if (fnan == fnan)\n    abort ();\n  if (fnan != x)\n    x = 1.0;\n  else\n    abort ();\n\n  if (fnan < x)\n    abort ();\n  if (fnan > x)\n    abort ();\n  if (fnan <= x)\n    abort ();\n  if (fnan >= x)\n    abort ();\n  if (fnan == x)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-2.x",
    "content": "# The ARM VxWorks kernel uses an external floating-point library in\n# which routines like __ledf2 are just aliases for __cmpdf2.  These\n# routines therefore don't handle NaNs correctly.\nif [istarget \"arm*-*-vxworks*\"] {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The ARM kernel uses a flawed floating-point library.\"\n\t    { \"*-*-*\" }\n\t    {}\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nif [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support Nan & Inf.\n    return 1\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.c",
    "content": "#ifndef SIGNAL_SUPPRESS\n#include <signal.h>\n#endif\n\nlong double dnan = 1.0l/0.0l - 1.0l/0.0l;\nlong double x = 1.0l;\n\nvoid leave ()\n{\n  exit (0);\n}\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  /* Move this line earlier, for architectures (like alpha) that issue \n     SIGFPE on the first comparisons. */\n#ifndef SIGNAL_SUPPRESS\n  /* Some machines catches a SIGFPE when a NaN is compared.\n     Let this test succeed o such machines.  */\n  signal (SIGFPE, leave);\n#endif\n  /* NaN is an IEEE unordered operand.  All these test should be false.  */\n  if (dnan == dnan)\n    abort ();\n  if (dnan != x)\n    x = 1.0;\n  else\n    abort ();\n\n  if (dnan < x)\n    abort ();\n  if (dnan > x)\n    abort ();\n  if (dnan <= x)\n    abort ();\n  if (dnan >= x)\n    abort ();\n  if (dnan == x)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-3.x",
    "content": "# The ARM VxWorks kernel uses an external floating-point library in\n# which routines like __ledf2 are just aliases for __cmpdf2.  These\n# routines therefore don't handle NaNs correctly.\nif [istarget \"arm*-*-vxworks*\"] {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The ARM kernel uses a flawed floating-point library.\"\n\t    { \"*-*-*\" }\n\t    {}\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c",
    "content": "#ifndef FLOAT\n#define FLOAT double\n#endif\n\nvoid\ntest_isunordered(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_isunordered(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\nvoid\ntest_isless(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_isless(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\nvoid\ntest_islessequal(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_islessequal(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\nvoid\ntest_isgreater(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_isgreater(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\nvoid\ntest_isgreaterequal(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_isgreaterequal(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\nvoid\ntest_islessgreater(FLOAT x, FLOAT y, int true)\n{\n  if (__builtin_islessgreater(x, y))\n    {\n      if (! true)\n\tabort ();\n    }\n  else\n    {\n      if (true)\n\tabort ();\n    }\n}\n\n#define NAN (0.0 / 0.0)\n\nint\nmain()\n{\n  struct try\n  {\n    FLOAT x, y;\n    unsigned unord : 1;\n    unsigned lt : 1;\n    unsigned le : 1;\n    unsigned gt : 1;\n    unsigned ge : 1;\n    unsigned lg : 1;\n  };\n\n  static struct try const data[] =\n  {\n    { NAN, NAN, 1, 0, 0, 0, 0, 0 },\n    { 0.0, NAN, 1, 0, 0, 0, 0, 0 },\n    { NAN, 0.0, 1, 0, 0, 0, 0, 0 },\n    { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },\n    { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },\n    { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },\n  };\n\n  const int n = sizeof(data) / sizeof(data[0]);\n  int i;\n\n  for (i = 0; i < n; ++i)\n    {\n      test_isunordered (data[i].x, data[i].y, data[i].unord);\n      test_isless (data[i].x, data[i].y, data[i].lt);\n      test_islessequal (data[i].x, data[i].y, data[i].le);\n      test_isgreater (data[i].x, data[i].y, data[i].gt);\n      test_isgreaterequal (data[i].x, data[i].y, data[i].ge);\n      test_islessgreater (data[i].x, data[i].y, data[i].lg);\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4e.c",
    "content": "#if defined (__ia64__) && defined (__hpux__)\n#define FLOAT __float80\n#include \"fp-cmp-4.c\"\n#else\nint\nmain ()\n{\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4f.c",
    "content": "#define FLOAT float\n#include \"fp-cmp-4.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4f.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support Nan & Inf. \n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4l.c",
    "content": "#define FLOAT long double\n#include \"fp-cmp-4.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-5.c",
    "content": "/* Like fp-cmp-4.c, but test that the setcc patterns are correct.  */\n\nstatic int\ntest_isunordered(double x, double y)\n{\n  return __builtin_isunordered(x, y);\n}\n\nstatic int\ntest_not_isunordered(double x, double y)\n{\n  return !__builtin_isunordered(x, y);\n}\n\nstatic int\ntest_isless(double x, double y)\n{\n  return __builtin_isless(x, y);\n}\n\nstatic int\ntest_not_isless(double x, double y)\n{\n  return !__builtin_isless(x, y);\n}\n\nstatic int\ntest_islessequal(double x, double y)\n{\n  return __builtin_islessequal(x, y);\n}\n\nstatic int\ntest_not_islessequal(double x, double y)\n{\n  return !__builtin_islessequal(x, y);\n}\n\nstatic int\ntest_isgreater(double x, double y)\n{\n  return __builtin_isgreater(x, y);\n}\n\nstatic int\ntest_not_isgreater(double x, double y)\n{\n  return !__builtin_isgreater(x, y);\n}\n\nstatic int\ntest_isgreaterequal(double x, double y)\n{\n  return __builtin_isgreaterequal(x, y);\n}\n\nstatic int\ntest_not_isgreaterequal(double x, double y)\n{\n  return !__builtin_isgreaterequal(x, y);\n}\n\nstatic int\ntest_islessgreater(double x, double y)\n{\n  return __builtin_islessgreater(x, y);\n}\n\nstatic int\ntest_not_islessgreater(double x, double y)\n{\n  return !__builtin_islessgreater(x, y);\n}\n\nstatic void\none_test(double x, double y, int expected,\n         int (*pos) (double, double), int (*neg) (double, double))\n{\n  if ((*pos)(x, y) != expected)\n    abort ();\n  if ((*neg)(x, y) != !expected)\n    abort ();\n}\n\n#define NAN (0.0 / 0.0)\n\nint\nmain()\n{\n  struct try\n  {\n    double x, y;\n    int result[6];\n  };\n\n  static struct try const data[] =\n  {\n    { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },\n    { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },\n    { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },\n    { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },\n    { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },\n    { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },\n  };\n\n  struct test\n  {\n    int (*pos)(double, double);\n    int (*neg)(double, double);\n  };\n\n  static struct test const tests[] =\n  {\n    { test_isunordered, test_not_isunordered },\n    { test_isless, test_not_isless },\n    { test_islessequal, test_not_islessequal },\n    { test_isgreater, test_not_isgreater },\n    { test_isgreaterequal, test_not_isgreaterequal },\n    { test_islessgreater, test_not_islessgreater }\n  };\n\n  const int n = sizeof(data) / sizeof(data[0]);\n  int i, j;\n\n  for (i = 0; i < n; ++i)\n    for (j = 0; j < 6; ++j)\n      one_test (data[i].x, data[i].y, data[i].result[j],\n\t\ttests[j].pos, tests[j].neg);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-6.c",
    "content": "\nconst double dnan = 1.0/0.0 - 1.0/0.0;\ndouble x = 1.0;\n\nextern void link_error (void);\nextern void abort (void);\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  /* NaN is an IEEE unordered operand.  All these test should be false.  */\n  if (dnan == dnan)\n    link_error ();\n  if (dnan != x)\n    x = 1.0;\n  else\n    link_error ();\n\n  if (dnan < x)\n    link_error ();\n  if (dnan > x)\n    link_error ();\n  if (dnan <= x)\n    link_error ();\n  if (dnan >= x)\n    link_error ();\n  if (dnan == x)\n    link_error ();\n#endif\n  exit (0);\n}\n\n#ifndef __OPTIMIZE__\nvoid link_error (void)\n{\n  abort ();\n}\n#endif\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-6.x",
    "content": "# The ARM VxWorks kernel uses an external floating-point library in\n# which routines like __ledf2 are just aliases for __cmpdf2.  These\n# routines therefore don't handle NaNs correctly.\nif [istarget \"arm*-*-vxworks*\"] {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The ARM kernel uses a flawed floating-point library.\"\n\t    { \"*-*-*\" }\n\t    { \"-O0\" }\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-7.c",
    "content": "extern void link_error ();\n\nvoid foo(double x)\n{\n  if (x > __builtin_inf())\n    link_error ();\n}\n\nint main ()\n{\n  foo (1.0);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-8.c",
    "content": "#ifndef FLOAT\n#define FLOAT double\n#endif\n\n/* Like fp-cmp-4.c, but test that the cmove patterns are correct.  */\n\nstatic FLOAT\ntest_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_isunordered(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_isunordered(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_isless(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_isless(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_islessequal(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_islessequal(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_isgreater(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_isgreater(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_isgreaterequal(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_isgreaterequal(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return __builtin_islessgreater(x, y) ? a : b;\n}\n\nstatic FLOAT\ntest_not_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)\n{\n  return !__builtin_islessgreater(x, y) ? a : b;\n}\n\nstatic void\none_test(FLOAT x, FLOAT y, int expected,\n         FLOAT (*pos) (FLOAT, FLOAT, FLOAT, FLOAT), \n\t FLOAT (*neg) (FLOAT, FLOAT, FLOAT, FLOAT))\n{\n  if (((*pos)(x, y, 1.0, 2.0) == 1.0) != expected)\n    abort ();\n  if (((*neg)(x, y, 3.0, 4.0) == 4.0) != expected)\n    abort ();\n}\n\n#define NAN (0.0 / 0.0)\n#define INF (1.0 / 0.0)\n\nint\nmain()\n{\n  struct try\n  {\n    FLOAT x, y;\n    int result[6];\n  };\n\n  static struct try const data[] =\n  {\n    { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },\n    { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },\n    { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },\n    { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },\n    { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },\n    { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },\n    { INF, 0.0, { 0, 0, 0, 1, 1, 1 } },\n    { 1.0, INF, { 0, 1, 1, 0, 0, 1 } },\n    { INF, INF, { 0, 0, 1, 0, 1, 0 } },\n    { 0.0, -INF, { 0, 0, 0, 1, 1, 1 } },\n    { -INF, 1.0, { 0, 1, 1, 0, 0, 1 } },\n    { -INF, -INF, { 0, 0, 1, 0, 1, 0 } },\n    { INF, -INF, { 0, 0, 0, 1, 1, 1 } },\n    { -INF, INF, { 0, 1, 1, 0, 0, 1 } },\n  };\n\n  struct test\n  {\n    FLOAT (*pos)(FLOAT, FLOAT, FLOAT, FLOAT);\n    FLOAT (*neg)(FLOAT, FLOAT, FLOAT, FLOAT);\n  };\n\n  static struct test const tests[] =\n  {\n    { test_isunordered, test_not_isunordered },\n    { test_isless, test_not_isless },\n    { test_islessequal, test_not_islessequal },\n    { test_isgreater, test_not_isgreater },\n    { test_isgreaterequal, test_not_isgreaterequal },\n    { test_islessgreater, test_not_islessgreater }\n  };\n\n  const int n = sizeof(data) / sizeof(data[0]);\n  int i, j;\n\n  for (i = 0; i < n; ++i)\n    for (j = 0; j < 6; ++j)\n      one_test (data[i].x, data[i].y, data[i].result[j],\n\t\ttests[j].pos, tests[j].neg);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-8e.c",
    "content": "#if defined (__ia64__) && defined (__hpux__)\n#define FLOAT __float80\n#include \"fp-cmp-8.c\"\n#else\nint\nmain ()\n{\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-8f.c",
    "content": "#define FLOAT float\n#include \"fp-cmp-8.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-8f.x",
    "content": "if [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support Nan & Inf. \n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-8l.c",
    "content": "#define FLOAT long double\n#include \"fp-cmp-8.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/hugeval.c",
    "content": "#include <math.h>\n\nstatic const double zero =  0.0;\nstatic const double pone =  1.0;\nstatic const double none = -1.0;\nstatic const double pinf =  1.0 / 0.0;\nstatic const double ninf = -1.0 / 0.0;\n\nint\nmain ()\n{\n  if (pinf != pone/zero)\n    abort ();\n\n  if (ninf != none/zero)\n    abort ();\n\n#ifdef HUGE_VAL\n  if (HUGE_VAL != pinf)\n    abort ();\n\n  if (-HUGE_VAL != ninf)\n    abort ();\n#endif\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/hugeval.x",
    "content": "# This test fails under hpux 9.X and 10.X because HUGE_VAL is DBL_MAX\n# instead of +Infinity.\n\nglobal target_triplet\nif { [istarget \"hppa*-*-hpux9*\"] || [istarget \"hppa*-*-hpux10*\"] } {\n      set torture_execute_xfail \"$target_triplet\"\n}\n\n# VxWorks kernel mode has the same problem.\nif {[istarget \"*-*-vxworks*\"]} {\n    set torture_eval_before_execute {\n\tglobal compiler_conditional_xfail_data\n\tset compiler_conditional_xfail_data {\n\t    \"The kernel HUGE_VAL is defined to DBL_MAX instead of +Inf.\"\n\t    { \"*-*-*\" }\n\t    {}\n\t    { \"-mrtp\" }\n\t}\n    }\n}\n\nif { [istarget \"tic6x-*-*\"] && [check_effective_target_ti_c67x] } {\n    # C6X uses -freciprocal-math by default.\n    set torture_execute_xfail \"$target_triplet\"\n    return 1\n}\n\nreturn 0\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp",
    "content": "#\n# Expect driver script for GCC Regression Tests\n#   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n#\n# This file is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n#\n# Written by Jeffrey Wheat (cassidy@cygnus.com)\n#\n\n# Load support procs.\nload_lib gcc-dg.exp\nload_lib torture-options.exp\nload_lib c-torture.exp\n\n# These tests come from Torbjorn Granlund's (tege@cygnus.com)\n# C torture test suite, and other contributors.\n\n# Disable tests on machines with no hardware support for IEEE arithmetic.\nif { [istarget \"vax-*-*\"] || [ istarget \"powerpc-*-*spe\"] || [istarget \"pdp11-*-*\"] } { return }\n\nif $tracelevel then {\n    strace $tracelevel\n}\n\ntorture-init\nset-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS\n\nset additional_flags \"-fno-inline\"\n\n# We must use -ffloat-store/-mieee to ensure that excess precision on some\n# machines does not cause problems\nif { ([istarget \"i?86-*-*\"] || [istarget \"x86_64-*-*\"])\n     && [check_effective_target_ia32] } then {\n  lappend additional_flags \"-ffloat-store\"\n}\nif [istarget \"m68k-*-*\"] then {\n  lappend additional_flags \"-ffloat-store\"\n}\nif { [istarget \"alpha*-*-*\"] \n     || [istarget \"sh*-*-*\"] } then {\n  lappend additional_flags \"-mieee\"\n}\n\n# load support procs\nload_lib c-torture.exp\n\n# initialize harness\ngcc_init\n\n#\n# main test loop\n#\n\nforeach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {\n    # If we're only testing specific files and this isn't one of them, skip it.\n    if ![runtest_file_p $runtests $src] then {\n\tcontinue\n    }\n\n    c-torture-execute $src $additional_flags\n}\n\n# All done.\ntorture-finish\ngcc_finish\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/inf-1.c",
    "content": "extern void abort (void);\n\nint main()\n{\n#ifndef __SPU__\n  /* The SPU single-precision floating point format does not support Inf.  */\n  float fi = __builtin_inff();\n#endif\n  double di = __builtin_inf();\n  long double li = __builtin_infl();\n\n  float fh = __builtin_huge_valf();\n  double dh = __builtin_huge_val();\n  long double lh = __builtin_huge_vall();\n\n#ifndef __SPU__\n  if (fi + fi != fi)\n    abort ();\n#endif\n  if (di + di != di)\n    abort ();\n  if (li + li != li)\n    abort ();\n\n#ifndef __SPU__\n  if (fi != fh)\n    abort ();\n#endif\n  if (di != dh)\n    abort ();\n  if (li != lh)\n    abort ();\n\n#ifndef __SPU__\n  if (fi <= 0)\n    abort ();\n#endif\n  if (di <= 0)\n    abort ();\n  if (li <= 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c",
    "content": "extern void abort (void);\n\nvoid test(double f, double i)\n{\n  if (f == __builtin_inf())\n    abort ();\n  if (f == -__builtin_inf())\n    abort ();\n  if (i == -__builtin_inf())\n    abort ();\n  if (i != __builtin_inf())\n    abort ();\n\n  if (f >= __builtin_inf())\n    abort ();\n  if (f > __builtin_inf())\n    abort ();\n  if (i > __builtin_inf())\n    abort ();\n  if (f <= -__builtin_inf())\n    abort ();\n  if (f < -__builtin_inf())\n    abort ();\n}\n\nvoid testf(float f, float i)\n{\n#ifndef __SPU__\n  /* The SPU single-precision floating point format does not support Inf.  */\n\n  if (f == __builtin_inff())\n    abort ();\n  if (f == -__builtin_inff())\n    abort ();\n  if (i == -__builtin_inff())\n    abort ();\n  if (i != __builtin_inff())\n    abort ();\n\n  if (f >= __builtin_inff())\n    abort ();\n  if (f > __builtin_inff())\n    abort ();\n  if (i > __builtin_inff())\n    abort ();\n  if (f <= -__builtin_inff())\n    abort ();\n  if (f < -__builtin_inff())\n    abort ();\n#endif\n}\n\nvoid testl(long double f, long double i)\n{\n  if (f == __builtin_infl())\n    abort ();\n  if (f == -__builtin_infl())\n    abort ();\n  if (i == -__builtin_infl())\n    abort ();\n  if (i != __builtin_infl())\n    abort ();\n\n  if (f >= __builtin_infl())\n    abort ();\n  if (f > __builtin_infl())\n    abort ();\n  if (i > __builtin_infl())\n    abort ();\n  if (f <= -__builtin_infl())\n    abort ();\n  if (f < -__builtin_infl())\n    abort ();\n}\n\nint main()\n{\n  test (34.0, __builtin_inf());\n  testf (34.0f, __builtin_inff());\n  testl (34.0l, __builtin_infl());\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c",
    "content": "extern void abort (void);\n\nvoid test(double f, double i)\n{\n  if (f == __builtin_huge_val())\n    abort ();\n  if (f == -__builtin_huge_val())\n    abort ();\n  if (i == -__builtin_huge_val())\n    abort ();\n  if (i != __builtin_huge_val())\n    abort ();\n\n  if (f >= __builtin_huge_val())\n    abort ();\n  if (f > __builtin_huge_val())\n    abort ();\n  if (i > __builtin_huge_val())\n    abort ();\n  if (f <= -__builtin_huge_val())\n    abort ();\n  if (f < -__builtin_huge_val())\n    abort ();\n}\n\nvoid testf(float f, float i)\n{\n  if (f == __builtin_huge_valf())\n    abort ();\n  if (f == -__builtin_huge_valf())\n    abort ();\n  if (i == -__builtin_huge_valf())\n    abort ();\n  if (i != __builtin_huge_valf())\n    abort ();\n\n  if (f >= __builtin_huge_valf())\n    abort ();\n  if (f > __builtin_huge_valf())\n    abort ();\n  if (i > __builtin_huge_valf())\n    abort ();\n  if (f <= -__builtin_huge_valf())\n    abort ();\n  if (f < -__builtin_huge_valf())\n    abort ();\n}\n\nvoid testl(long double f, long double i)\n{\n  if (f == __builtin_huge_vall())\n    abort ();\n  if (f == -__builtin_huge_vall())\n    abort ();\n  if (i == -__builtin_huge_vall())\n    abort ();\n  if (i != __builtin_huge_vall())\n    abort ();\n\n  if (f >= __builtin_huge_vall())\n    abort ();\n  if (f > __builtin_huge_vall())\n    abort ();\n  if (i > __builtin_huge_vall())\n    abort ();\n  if (f <= -__builtin_huge_vall())\n    abort ();\n  if (f < -__builtin_huge_vall())\n    abort ();\n}\n\nint main()\n{\n  test (34.0, __builtin_huge_val());\n  testf (34.0f, __builtin_huge_valf());\n  testl (34.0l, __builtin_huge_vall());\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/minuszero.c",
    "content": "main ()\n{\n  union\n    {\n      double d;\n      unsigned short i[sizeof (double) / sizeof (short)];\n    } u;\n  int a = 0;\n  int b = -5;\n  int j;\n\n  u.d = (double) a / b;\n\n  /* Look for the right pattern, but be sloppy since\n     we don't know the byte order.  */\n  for (j = 0; j < sizeof (double) / sizeof (short); j++)\n    {\n      if (u.i[j] == 0x8000)\n\texit (0);\n    }\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mul-subnormal-single-1.c",
    "content": "/* Check that certain subnormal numbers (formerly known as denormalized\n   numbers) are rounded to within 0.5 ulp.  PR other/14354.  */\n\n/* This test requires that float and unsigned int are the same size and\n   that the sign-bit of the float is at MSB of the unsigned int.  */\n\n#if __INT_MAX__ != 2147483647L\nint main () { exit (0); }\n#else\n\nunion uf\n{\n  unsigned int u;\n  float f;\n};\n\nstatic float\nu2f (unsigned int v)\n{\n  union uf u;\n  u.u = v;\n  return u.f;\n}\n\nstatic unsigned int\nf2u (float v)\n{\n  union uf u;\n  u.f = v;\n  return u.u;\n}\n\nint ok = 1;\n\nstatic void\ntstmul (unsigned int ux, unsigned int uy, unsigned int ur)\n{\n  float x = u2f (ux);\n  float y = u2f (uy);\n\n  if (f2u (x * y) != ur)\n    /* Set a variable rather than aborting here, to simplify tracing when\n       several computations are wrong.  */\n    ok = 0;\n}\n\n/* We don't want to make this const and static, or else we risk inlining\n   causing the test to fold as constants at compile-time.  */\nstruct\n{\n  unsigned int p1, p2, res;\n} expected[] =\n  {\n    {0xfff, 0x3f800400, 0xfff},\n    {0xf, 0x3fc88888, 0x17},\n    {0xf, 0x3f844444, 0xf}\n  };\n\nint\nmain ()\n{\n  unsigned int i;\n\n  for (i = 0; i < sizeof (expected) / sizeof (expected[0]); i++)\n    {\n      tstmul (expected[i].p1, expected[i].p2, expected[i].res);\n      tstmul (expected[i].p2, expected[i].p1, expected[i].res);\n    }\n\n  if (!ok)\n    abort ();\n\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mul-subnormal-single-1.x",
    "content": "if [istarget \"epiphany-*-*\"] {\n    # The Epiphany single-precision floating point format does not\n    # support subnormals.\n    return 1\n}\nif {[istarget \"m68k-*-*\"] && [check_effective_target_coldfire_fpu]} {\n    # ColdFire FPUs require software handling of subnormals.  We are\n    # not aware of any system that has this.\n    set torture_execute_xfail \"m68k-*-*\"\n}\nif [istarget \"spu-*-*\"] {\n    # The SPU single-precision floating point format does not\n    # support subnormals.\n    return 1\n}\nif { [istarget \"tic6x-*-*\"] && [check_effective_target_ti_c67x] } {\n    # C6X floating point hardware turns denormals to zero in multiplications.\n    set torture_execute_xfail \"tic6x-*-*\"\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero2.c",
    "content": "/* Test IEEE +0/-0 rules */\n\nstatic double pzero = +0.0;\nstatic double nzero = -0.0;\nstatic double pinf  = +1.0 / 0.0;\nstatic double ninf  = -1.0 / 0.0;\nstatic double nan   =  0.0 / 0.0;\n\nvoid\nexpect (double value, double expected)\n{\n  if (expected != expected)\t/* expected value is Not a number */\n    {\n      if (value == value)\t/* actual value is a number */\n\tabort ();\n    }\n\n  else if (value != value)\n    abort ();\t\t\t/* actual value is a NaN */\n\n  else if (memcmp ((void *)&value, (void *)&expected, sizeof (double)) != 0)\n    abort ();\t\t\t/* values don't match */\n}\n\nmain ()\n{\n  expect (pzero + pzero, pzero);\n  expect (pzero + nzero, pzero);\n  expect (nzero + pzero, pzero);\n  expect (nzero + nzero, nzero);\n\n  expect (pzero - pzero, pzero);\n  expect (pzero - nzero, pzero);\n  expect (nzero - pzero, nzero);\n  expect (nzero - nzero, pzero);\n\n  expect (pzero * pzero, pzero);\n  expect (pzero * nzero, nzero);\n  expect (nzero * pzero, nzero);\n  expect (nzero * nzero, pzero);\n\n  expect (+1.00 * pzero, pzero);\n  expect (-1.00 * pzero, nzero);\n  expect (+1.00 * nzero, nzero);\n  expect (-1.00 * nzero, pzero);\n\n#ifndef _TMS320C6700\n  /* C6X floating point division is implemented using reciprocals.  */\n  expect (pzero / pzero, nan);\n  expect (pzero / nzero, nan);\n  expect (nzero / pzero, nan);\n  expect (nzero / nzero, nan);\n\n  expect (+1.00 / pzero, pinf);\n  expect (-1.00 / pzero, ninf);\n  expect (+1.00 / nzero, ninf);\n  expect (-1.00 / nzero, pinf);\n#endif\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero2.x",
    "content": "# freebsd sets up the fpu with a different precision control which causes\n# this test to \"fail\".\nif { [istarget \"i?86-*-freebsd*\\[123\\]\\.*\"] } {\n\tset torture_execute_xfail \"i?86-*-freebsd*\"\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero3.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n   by Hans-Peter Nilsson  <hp@bitrange.com>, derived from mzero2.c\n\n   In the MMIX port, negdf2 was bogusly expanding -x into 0 - x.  */\n\ndouble nzerod = -0.0;\nfloat nzerof = -0.0;\ndouble zerod = 0.0;\nfloat zerof = 0.0;\n\nvoid expectd (double, double);\nvoid expectf (float, float);\ndouble negd (double);\nfloat negf (float);\n\nmain ()\n{\n  expectd (negd (zerod), nzerod);\n  expectf (negf (zerof), nzerof);\n  expectd (negd (nzerod), zerod);\n  expectf (negf (nzerof), zerof);\n  exit (0);\n}\n\nvoid\nexpectd (double value, double expected)\n{\n  if (value != expected\n      || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)\n    abort ();\n}\n\nvoid\nexpectf (float value, float expected)\n{\n  if (value != expected\n      || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)\n    abort ();\n}\n\ndouble\nnegd (double v)\n{\n  return -v;\n}\n\nfloat\nnegf (float v)\n{\n  return -v;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero4.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n   by Roger Sayle <roger@eyesopen.com>, derived from mzero3.c\n\n   Constant folding of sin(-0.0), tan(-0.0) and atan(-0.0) should\n   all return -0.0, for both double and float forms.  */\n\nvoid abort (void);\ntypedef __SIZE_TYPE__ size_t;\nextern int memcmp (const void *, const void *, size_t);\n\ndouble sin (double);\ndouble tan (double);\ndouble atan (double);\n\nfloat sinf (float);\nfloat tanf (float);\nfloat atanf (float);\n\nvoid expectd (double, double);\nvoid expectf (float, float);\n\nvoid\nexpectd (double value, double expected)\n{\n  if (value != expected\n      || memcmp ((void *)&value, (void *) &expected, sizeof (double)) != 0)\n    abort ();\n}\n\nvoid\nexpectf (float value, float expected)\n{\n  if (value != expected\n      || memcmp ((void *)&value, (void *) &expected, sizeof (float)) != 0)\n    abort ();\n}\n\nint main ()\n{\n  expectd (sin (0.0), 0.0);\n  expectd (tan (0.0), 0.0);\n  expectd (atan (0.0), 0.0);\n\n  expectd (sin (-0.0), -0.0);\n  expectd (tan (-0.0), -0.0);\n  expectd (atan (-0.0), -0.0);\n\n  expectf (sinf (0.0f), 0.0f);\n  expectf (tanf (0.0f), 0.0f);\n  expectf (atanf (0.0f), 0.0f);\n\n  expectf (sinf (-0.0f), -0.0f);\n  expectf (tanf (-0.0f), -0.0f);\n  expectf (atanf (-0.0f), -0.0f);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero5.c",
    "content": "/* Test gcse handling of IEEE 0/-0 rules.  */\nstatic double zero = 0.0;\n\nint\nnegzero_check (double d)\n{\n  if (d == 0)\n    return !!memcmp ((void *)&zero, (void *)&d, sizeof (double));\n  return 0;\n}\n\nint\nsub (double d, double e)\n{\n  if (d == 0.0 && e == 0.0\n      && negzero_check (d) == 0 && negzero_check (e) == 0)\n    return 1;\n  else\n    return 0;\n}\n\nint\nmain (void)\n{\n  double minus_zero = -0.0;\n  if (sub (minus_zero, 0))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/mzero6.c",
    "content": "/* Tail call optimizations would convert func() into the moral equivalent of:\n\n       double acc = 0.0;\n       for (int i = 0; i <= n; i++)\n\t acc += d;\n       return acc;\n\n   which mishandles the case where 'd' is -0.  They also initialised 'acc'\n   to a zero int rather than a zero double.  */\n\ndouble func (double d, int n)\n{\n  if (n == 0)\n    return d;\n  else\n    return d + func (d, n - 1);\n}\n\nint main ()\n{\n  if (__builtin_copysign (1.0, func (0.0 / -5.0, 10)) != -1.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c",
    "content": "/* PR rtl-optimization/28634.  On targets with delayed branches,\n   dbr_schedule could do the next iteration's addition in the\n   branch delay slot, then subtract the value again if the branch\n   wasn't taken.  This can lead to rounding errors.  */\ndouble x = -0x1.0p53;\ndouble y = 1;\nint\nmain (void)\n{\n  while (y > 0)\n    y += x;\n  if (y != x + 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr29302-1.c",
    "content": "extern void abort (void);\n\nint main (void)\n{\n  int n;\n  long double x;\n\n  x = 1/0.0;\n\n  n = (x == 1/0.0);\n\n  if (n == 1)\n    return 0;\n  else\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr29302-1.x",
    "content": "if { [istarget \"tic6x-*-*\"] && [check_effective_target_ti_c67x] } {\n    # C6X uses -freciprocal-math by default.\n    set torture_execute_xfail \"tic6x-*-*\"\n    return 1\n}\nreturn 0\nif { [istarget \"tic6x-*-*\"] && [check_effective_target_ti_c67x] } {\n    # C6X uses -freciprocal-math by default.\n    set torture_execute_xfail \"tic6x-*-*\"\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr30704.c",
    "content": "/* PR middle-end/30704 */\n\ntypedef __SIZE_TYPE__ size_t;\nextern void abort (void);\nextern int memcmp (const void *, const void *, size_t);\nextern void *memcpy (void *, const void *, size_t);\n\nlong long\nf1 (void)\n{\n  long long t;\n  double d = 0x0.fffffffffffff000p-1022;\n  memcpy (&t, &d, sizeof (long long));\n  return t;\n}\n\ndouble\nf2 (void)\n{\n  long long t = 0x000fedcba9876543LL;\n  double d;\n  memcpy (&d, &t, sizeof (long long));\n  return d;\n}\n\nint\nmain ()\n{\n  union\n  {\n    long long ll;\n    double d;\n  } u;\n\n  if (sizeof (long long) != sizeof (double) || __DBL_MIN_EXP__ != -1021)\n    return 0;\n\n  u.ll = f1 ();\n  if (u.d != 0x0.fffffffffffff000p-1022)\n    abort ();\n\n  u.d = f2 ();\n  if (u.ll != 0x000fedcba9876543LL)\n    abort ();\n\n  double b = 234.0;\n  long long c;\n  double d = b;\n  memcpy (&c, &b, sizeof (double));\n  long long e = c;\n  if (memcmp (&e, &d, sizeof (double)) != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr30704.x",
    "content": "if [istarget \"avr-*-*\"] {\r\n    # AVR doubles are floats\r\n    return 1\r\n}\r\nreturn 0\r\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr36332.c",
    "content": "/* PR target/36332 */\n\nint\nfoo (long double ld)\n{\n  return ld == __builtin_infl ();\n}\n\nint\nmain ()\n{\n  if (foo (__LDBL_MAX__))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr38016.c",
    "content": "#include \"fp-cmp-8.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr38016.x",
    "content": "lappend additional_flags \"-fno-ivopts\" \"-fno-gcse\"\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr50310.c",
    "content": "/* PR target/50310 */\n\nextern void abort (void);\ndouble s1[4], s2[4], s3[64];\n\nvoid\nfoo (void)\n{\n  int i;\n  for (i = 0; i < 4; i++)\n    s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[2 * 4 + i] = __builtin_isgreaterequal (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[3 * 4 + i] = (!__builtin_isgreaterequal (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[4 * 4 + i] = __builtin_isless (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[5 * 4 + i] = (!__builtin_isless (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[6 * 4 + i] = __builtin_islessequal (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[7 * 4 + i] = (!__builtin_islessequal (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[8 * 4 + i] = __builtin_islessgreater (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[9 * 4 + i] = (!__builtin_islessgreater (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[10 * 4 + i] = __builtin_isunordered (s1[i], s2[i]) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[11 * 4 + i] = (!__builtin_isunordered (s1[i], s2[i])) ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[12 * 4 + i] = s1[i] > s2[i] ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[13 * 4 + i] = s1[i] <= s2[i] ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[14 * 4 + i] = s1[i] < s2[i] ? -1.0 : 0.0;\n  for (i = 0; i < 4; i++)\n    s3[15 * 4 + i] = s1[i] >= s2[i] ? -1.0 : 0.0;\n}\n\nint\nmain ()\n{\n  int i;\n  s1[0] = 5.0;\n  s1[1] = 6.0;\n  s1[2] = 5.0;\n  s1[3] = __builtin_nan (\"\");\n  s2[0] = 6.0;\n  s2[1] = 5.0;\n  s2[2] = 5.0;\n  s2[3] = 5.0;\n  asm volatile (\"\" : : : \"memory\");\n  foo ();\n  asm volatile (\"\" : : : \"memory\");\n  for (i = 0; i < 16 * 4; i++)\n    if (i >= 12 * 4 && (i & 3) == 3)\n      {\n\tif (s3[i] != 0.0) abort ();\n      }\n    else\n      {\n        static int masks[] = { 2, 2|4, 1, 1|4, 1|2, 8, 2, 1 };\n        if (s3[i]\n\t    != (((1 << (i & 3)) & ((i & 4) ? ~masks[i / 8] : masks[i / 8]))\n\t\t? -1.0 : 0.0))\n\t  abort ();\n      }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr67218.c",
    "content": "extern void abort (void) __attribute__ ((noreturn));\n\ndouble __attribute__ ((noinline, noclone))\nfoo (unsigned int x)\n{\n  return (double) (float) (x | 0xffff0000);\n}\n\nint\nmain ()\n{\n  if (foo (1) != 0x1.fffep31)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr72824-2.c",
    "content": "/* PR tree-optimization/72824 */\n\ntypedef float V __attribute__((vector_size (4 * sizeof (float))));\n\nstatic inline void\nfoo (V *x, V value)\n{\n  int i;\n  for (i = 0; i < 32; ++i)\n    x[i] = value;\n}\n\nint\nmain ()\n{\n  V x[32];\n  foo (x, (V) { 0.f, -0.f, 0.f, -0.f });\n  if (__builtin_copysignf (1.0, x[3][1]) != -1.0f)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/pr72824.c",
    "content": "/* PR tree-optimization/72824 */\n\nstatic inline void\nfoo (float *x, float value)\n{\n  int i;\n  for (i = 0; i < 32; ++i)\n    x[i] = value;\n}\n\nint\nmain ()\n{\n  float x[32];\n  foo (x, -0.f);\n  if (__builtin_copysignf (1.0, x[3]) != -1.0f)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c",
    "content": "#if defined(__i386__) && defined(__FreeBSD__)\n#include <ieeefp.h>\n#endif\n\ndouble d (unsigned long long k)\n{\n  double x;\n\n  x = (double) k;\n  return x;\n}\n\nfloat s (unsigned long long k)\n{\n  float x;\n\n  x = (float) k;\n  return x;\n}\n\nmain ()\n{\n  unsigned long long int k;\n  double x;\n\n#if defined(__i386__) && defined(__FreeBSD__)\n  /* This test case assumes extended-precision, but FreeBSD defaults to\n     double-precision.  Make it so.  */\n  fpsetprec (FP_PE);\n#endif\n\n  if (sizeof (double) >= 8)\n    {\n      k = 0x8693ba6d7d220401ULL;\n      x = d (k);\n      k = (unsigned long long) x;\n      if (k != 0x8693ba6d7d220800ULL)\n\tabort ();\n    }\n\n  k = 0x8234508000000001ULL;\n  x = s (k);\n  k = (unsigned long long) x;\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (k != 0x8234500000000000ULL)\n    abort ();\n#else\n  if (k != 0x8234510000000000ULL)\n    abort ();\n#endif\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.x",
    "content": "# This doesn't work on d10v if doubles are not 64 bits\n\nif { [istarget \"d10v-*-*\"] && ! [string-match \"*-mdouble64*\" $CFLAGS] } {\n\tset torture_execute_xfail \"d10v-*-*\"\n}\nif [istarget \"avr-*-*\"] {\n    # AVR doubles are floats\n    return 1\n}\nreturn 0\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c",
    "content": "extern void abort();\n\ntypedef union {\n       struct {\n  unsigned int hi;\n  unsigned int lo;\n } i;\n       double d;\n} hexdouble;\n\nstatic const double twoTo52 = 0x1.0p+52;\n\nvoid func ( double x )\n{\n      hexdouble argument;\n      register double y, z;\n      unsigned int xHead;\n      argument.d = x;\n      xHead = argument.i.hi & 0x7fffffff;\n      if (__builtin_expect(!!(xHead < 0x43300000u), 1))\n       {\n                  y = ( x - twoTo52 ) + twoTo52;\n                  if ( y != x )\n\t\t    abort();\n                  z = x - 0.5;\t\t\t\n                  y = ( z - twoTo52 ) + twoTo52;\n                  if ( y == (( x - twoTo52 ) + twoTo52) )\n\t\t    abort();\n       }\n     return;\n}\n\nint main()\n{\n\tif (sizeof (double) == 4)\n\t\treturn 0;\n\tfunc((double)1.00);\n\treturn 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.x",
    "content": "if [istarget \"avr-*-*\"] {\r\n    # AVR doubles are floats\r\n    return 1\r\n}\r\nreturn 0\r\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ieee/unsafe-fp-assoc.c",
    "content": "#include <float.h>\n\nextern void abort(void);\n\nstatic const double C = DBL_MAX;\n\ndouble foo(double x)\n{\n        return ( ( (x * C) * C ) * C);\n}\n\nint main ()\n{\n  double d = foo (0.0);\n  if (d != 0.0)\n   abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ifcvt-onecmpl-abs-1.c",
    "content": "\nextern void abort(void);\n\n__attribute__ ((noinline))\nint foo(int n)\n{\n  if (n < 0)\n    n = ~n;\n\n  return n;\n}\n\nint main(void)\n{\n  if (foo (-1) != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/index-1.c",
    "content": "int a[] =\n{\n  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,\n  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n  30, 31, 32, 33, 34, 35, 36, 37, 38, 39\n};\n\nint\nf (long n)\n{\n  return a[n - 100000];\n}\n\nmain ()\n{\n  if (f (100030L) != 30)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/inst-check.c",
    "content": "#include <stdarg.h>\n\nf(m)\n{\n  int i,s=0;\n  for(i=0;i<m;i++)\n    s+=i;\n  return s;\n}\n\nmain()\n{\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/int-compare.c",
    "content": "#include <limits.h>\n\ngt (a, b)\n{\n  return a > b;\n}\n\nge (a, b)\n{\n  return a >= b;\n}\n\nlt (a, b)\n{\n  return a < b;\n}\n\nle (a, b)\n{\n  return a <= b;\n}\n\nvoid\ntrue (c)\n{\n  if (!c)\n    abort();\n}\n\nvoid\nfalse (c)\n{\n  if (c)\n    abort();\n}\n\nf ()\n{\n  true (gt (2, 1));\n  false (gt (1, 2));\n\n  true (gt (INT_MAX, 0));\n  false (gt (0, INT_MAX));\n  true (gt (INT_MAX, 1));\n  false (gt (1, INT_MAX));\n\n  false (gt (INT_MIN, 0));\n  true (gt (0, INT_MIN));\n  false (gt (INT_MIN, 1));\n  true (gt (1, INT_MIN));\n\n  true (gt (INT_MAX, INT_MIN));\n  false (gt (INT_MIN, INT_MAX));\n\n  true (ge (2, 1));\n  false (ge (1, 2));\n\n  true (ge (INT_MAX, 0));\n  false (ge (0, INT_MAX));\n  true (ge (INT_MAX, 1));\n  false (ge (1, INT_MAX));\n\n  false (ge (INT_MIN, 0));\n  true (ge (0, INT_MIN));\n  false (ge (INT_MIN, 1));\n  true (ge (1, INT_MIN));\n\n  true (ge (INT_MAX, INT_MIN));\n  false (ge (INT_MIN, INT_MAX));\n\n  false (lt (2, 1));\n  true (lt (1, 2));\n\n  false (lt (INT_MAX, 0));\n  true (lt (0, INT_MAX));\n  false (lt (INT_MAX, 1));\n  true (lt (1, INT_MAX));\n\n  true (lt (INT_MIN, 0));\n  false (lt (0, INT_MIN));\n  true (lt (INT_MIN, 1));\n  false (lt (1, INT_MIN));\n\n  false (lt (INT_MAX, INT_MIN));\n  true (lt (INT_MIN, INT_MAX));\n\n  false (le (2, 1));\n  true (le (1, 2));\n\n  false (le (INT_MAX, 0));\n  true (le (0, INT_MAX));\n  false (le (INT_MAX, 1));\n  true (le (1, INT_MAX));\n\n  true (le (INT_MIN, 0));\n  false (le (0, INT_MIN));\n  true (le (INT_MIN, 1));\n  false (le (1, INT_MIN));\n\n  false (le (INT_MAX, INT_MIN));\n  true (le (INT_MIN, INT_MAX));\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ipa-sra-1.c",
    "content": "/* Trivially making sure IPA-SRA does not introduce segfaults where they should\n   not be.  */\n\nstruct bovid\n{\n  float red;\n  int green;\n  void *blue;\n};\n\nstatic int\n__attribute__((noinline))\nox (int fail, struct bovid *cow)\n{\n  int r;\n  if (fail)\n    r = cow->red;\n  else\n    r = 0;\n  return r;\n}\n\nint main (int argc, char *argv[])\n{\n  int r;\n\n  r = ox ((argc > 2000), (void *) 0);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ipa-sra-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\nstruct big\n{\n  int data[1000000];\n};\n\nstruct small\n{\n  int data[10];\n};\n\nunion both\n{\n  struct big big;\n  struct small small;\n};\n\nextern void *calloc (__SIZE_TYPE__, __SIZE_TYPE__);\nextern void free (void *);\n\nstatic int __attribute__((noinline))\nfoo (int fail, union both *agg)\n{\n  int r;\n  if (fail)\n    r = agg->big.data[999999];\n  else\n    r = agg->small.data[0];\n  return r;\n}\n\nint main (int argc, char *argv[])\n{\n  union both *agg = calloc (1, sizeof (struct small));\n  int r;\n\n  r = foo ((argc > 2000), agg);\n\n  free (agg);\n  return r;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/longlong.c",
    "content": "/* Source: PR 321 modified for test suite by Neil Booth 14 Jan 2001.  */\n\ntypedef unsigned long long uint64;\nunsigned long pars;\n\nuint64 b[32];\nuint64 *r = b;\n\nvoid alpha_ep_extbl_i_eq_0()\n{\n  unsigned int rb, ra, rc;\n\n  rb  = (((unsigned long)(pars) >> 27)) & 0x1fUL;\n  ra  = (((unsigned int)(pars) >> 5)) & 0x1fUL;\n  rc  = (((unsigned int)(pars) >> 0)) & 0x1fUL;\n  {\n    uint64 temp = ((r[ra] >> ((r[rb] & 0x7) << 3)) & 0x00000000000000FFLL); \n    if (rc != 31) \n      r[rc] = temp;  \n  }\n}\n\nint \nmain(void)\n{\n  if (sizeof (uint64) == 8)\n    {\n      b[17] = 0x0000000000303882ULL; /* rb */\n      b[2] = 0x534f4f4c494d000aULL; /* ra & rc */\n\n      pars = 0x88000042;\t/* 17, 2, 2 coded */\n      alpha_ep_extbl_i_eq_0();\n\n      if (b[2] != 0x4d)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-1.c",
    "content": "main ()\n{\n  int i, j, k[3];\n\n  j = 0;\n  for (i=0; i < 3; i++)\n    {\n      k[i] = j++;\n    }\n\n  for (i=2; i >= 0; i--)\n    {\n      if (k[i] != i)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-10.c",
    "content": "/* Reduced from PR optimization/5076, PR optimization/2847 */\n\nstatic int count = 0;\n\nstatic void\ninc (void)\n{\n  count++;\n}\n\nint\nmain (void)\n{\n  int iNbr = 1;\n  int test = 0;\n  while (test == 0)\n    {\n      inc ();\n      if (iNbr == 0)\n        break;\n      else\n        {\n          inc ();\n          iNbr--;\n        }\n      test = 1;\n    }\n  if (count != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-11.c",
    "content": "static int a[199];\n\nstatic void\nfoo ()\n{\n  int i;\n  for (i = 198; i >= 0; i--)\n    a[i] = i;\n}\n\nint\nmain ()\n{\n  int i;\n  foo ();\n  for (i = 0; i < 199; i++)\n    if (a[i] != i)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-12.c",
    "content": "/* Checks that pure functions are not treated as const.  */\n\nchar *p;\n\nstatic int __attribute__ ((pure))\nis_end_of_statement (void)\n{\n  return *p == '\\n' || *p == ';' || *p == '!';\n}\n\nvoid foo (void)\n{\n  /* The is_end_of_statement call was moved out of the loop at one stage,\n     resulting in an endless loop.  */\n  while (!is_end_of_statement ())\n    p++;\n}\n\nint\nmain (void)\n{\n  p = \"abc\\n\";\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-13.c",
    "content": "/* PR opt/7130 */\n#define TYPE long\n\nvoid\nscale (TYPE *alpha, TYPE *x, int n)\n{\n  int i, ix;\n\n  if (*alpha != 1)\n    for (i = 0, ix = 0; i < n; i++, ix += 2)\n      {\n\tTYPE tmpr, tmpi;\n\ttmpr = *alpha * x[ix];\n\ttmpi = *alpha * x[ix + 1];\n\tx[ix] = tmpr;\n\tx[ix + 1] = tmpi;\n      }\n}\n\nint\nmain (void)\n{\n  int i;\n  TYPE x[10];\n  TYPE alpha = 2;\n\n  for (i = 0; i < 10; i++)\n    x[i] = i;\n\n  scale (&alpha, x, 5);\n\n  if (x[9] != 18)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-14.c",
    "content": "int a3[3];\n\nvoid f(int *a)\n{\n  int i;\n\n  for (i=3; --i;)\n    a[i] = 42 / i;\n}\n\nint\nmain ()\n{\n  f(a3);\n\n  if (a3[1] != 42 || a3[2] != 21)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-15.c",
    "content": "/* Bombed with a segfault on powerpc-linux.  doloop.c generated wrong\n   loop count.  */\nvoid\nfoo (unsigned long *start, unsigned long *end)\n{\n  unsigned long *temp = end - 1;\n\n  while (end > start)\n    *end-- = *temp--;\n}\n\nint\nmain (void)\n{\n  unsigned long a[5];\n  int start, end, k;\n\n  for (start = 0; start < 5; start++)\n    for (end = 0; end < 5; end++)\n      {\n\tfor (k = 0; k < 5; k++)\n\t  a[k] = k;\n\n\tfoo (a + start, a + end);\n\n\tfor (k = 0; k <= start; k++)\n\t  if (a[k] != k)\n\t    abort ();\n\n\tfor (k = start + 1; k <= end; k++)\n\t  if (a[k] != k - 1)\n\t    abort ();\n\n\tfor (k = end + 1; k < 5; k++)\n\t  if (a[k] != k)\n\t    abort ();\n      }\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2.c",
    "content": "int a[2];\n\nf (b)\n{\n  unsigned int i;\n  for (i = 0; i < b; i++)\n    a[i] = i - 2;\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (2);\n  if (a[0] != -2 || a[1] != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2b.c",
    "content": "#include <limits.h>\n\nint a[2];\n\nf (int i)\n{\n  for (; i < INT_MAX; i++)\n    {\n      a[i] = -2;\n      if (&a[i] == &a[1])\n\tbreak;\n    }\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (0);\n  if (a[0] != -2 || a[1] != -2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2c.c",
    "content": "/* { dg-options \"-fgnu89-inline -Wno-pointer-to-int-cast\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint a[2];\n\n__inline__ void f (int b, int o)\n{\n  unsigned int i;\n  int *p;\n  for (p = &a[b], i = b; --i < ~0; )\n    *--p = i * 3 + o;\n}\n\nvoid\ng(int b)\n{\n  f (b, (int)a);\n}\n\nint\nmain ()\n{\n  a[0] = a[1] = 0;\n  g (2);\n  if (a[0] != (int)a || a[1] != (int)a + 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2d.c",
    "content": "int a[2];\n\nf (b)\n{\n  unsigned int i;\n  int *p;\n  for (p = &a[b], i = b; --i < ~0; )\n    *--p = i * 3 + (int)a;\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (2);\n  if (a[0] != (int)a || a[1] != (int)a + 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2e.c",
    "content": "void f (int *p, int **q)\n{\n  int i;\n  for (i = 0; i < 40; i++)\n    {\n      *q++ = &p[i];\n    }\n}\n\nint main ()\n{\n  void *p;\n  int *q[40];\n  __SIZE_TYPE__ start;\n\n  /* Find the signed middle of the address space.  */\n  if (sizeof(start) == sizeof(int))\n    start = (__SIZE_TYPE__) __INT_MAX__;\n  else if (sizeof(start) == sizeof(long))\n    start = (__SIZE_TYPE__) __LONG_MAX__;\n  else if (sizeof(start) == sizeof(long long))\n    start = (__SIZE_TYPE__) __LONG_LONG_MAX__;\n  else\n    return 0;\n\n  /* Arbitrarily align the pointer.  */\n  start &= -32;\n\n  /* Pretend that's good enough to start address arithmetic.  */\n  p = (void *)start;\n\n  /* Verify that GIV replacement computes the correct results.  */\n  q[39] = 0;\n  f (p, q);\n  if (q[39] != (int *)p + 39)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2f.c",
    "content": "/* { dg-require-effective-target mmap } */\n/* { dg-skip-if \"the executable is at the same position the test tries to remap\" { m68k-*-linux* } { \"*\" } { \"\" } } */\n\n#include <limits.h>\n\n#include <sys/types.h>\n#include <sys/mman.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifndef MAP_ANON\n#ifdef MAP_ANONYMOUS\n#define MAP_ANON MAP_ANONYMOUS\n#else\n#define MAP_ANON MAP_FILE\n#endif\n#endif\n#ifndef MAP_FILE\n#define MAP_FILE 0\n#endif\n#ifndef MAP_FIXED\n#define MAP_FIXED 0\n#endif\n\n#define MAP_START (void *)0x7fff8000\n#define MAP_LEN 0x10000\n\n#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));\n\nf (int s, char *p)\n{\n  int i;\n  for (i = s; i >= 0 && &p[i] < &p[40]; i++)\n    {\n      p[i] = -2;\n    }\n}\n\nmain ()\n{\n#ifdef MAP_ANON\n  char *p;\n  int dev_zero;\n\n  dev_zero = open (\"/dev/zero\", O_RDONLY);\n  /* -1 is OK when we have MAP_ANON; else mmap will flag an error.  */\n  if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))\n    exit (0);\n  p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,\n\t    MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);\n  if (p != (char *)-1)\n    {\n      p += OFFSET;\n      p[39] = 0;\n      f (0, p);\n      if (p[39] != (char)-2)\n\tabort ();\n      p[39] = 0;\n      f (-1, p);\n      if (p[39] != 0)\n\tabort ();\n    }\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-2g.c",
    "content": "/* { dg-require-effective-target mmap } */\n/* { dg-skip-if \"the executable is at the same position the test tries to remap\" { m68k-*-linux* } { \"*\" } { \"\" } } */\n\n#include <limits.h>\n\n#include <sys/types.h>\n#include <sys/mman.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifndef MAP_ANON\n#ifdef MAP_ANONYMOUS\n#define MAP_ANON MAP_ANONYMOUS\n#else\n#define MAP_ANON MAP_FILE\n#endif\n#endif\n#ifndef MAP_FILE\n#define MAP_FILE 0\n#endif\n#ifndef MAP_FIXED\n#define MAP_FIXED 0\n#endif\n\n#define MAP_START (void *)0x7fff8000\n#define MAP_LEN 0x10000\n\n#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));\n\nf (int s, char *p)\n{\n  int i;\n  for (i = s; &p[i] < &p[40] && i >= 0; i++)\n    {\n      p[i] = -2;\n    }\n}\n\nmain ()\n{\n#ifdef MAP_ANON\n  char *p;\n  int dev_zero;\n\n  dev_zero = open (\"/dev/zero\", O_RDONLY);\n  /* -1 is OK when we have MAP_ANON; else mmap will flag an error.  */\n  if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))\n    exit (0);\n  p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,\n\t    MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);\n  if (p != (char *)-1)\n    {\n      p += OFFSET;\n      p[39] = 0;\n      f (0, p);\n      if (p[39] != (char)-2)\n\tabort ();\n      p[39] = 0;\n      f (-1, p);\n      if (p[39] != 0)\n\tabort ();\n    }\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-3.c",
    "content": "#include <limits.h>\n\nint n = 0;\n\ng (i)\n{\n  n++;\n}\n\nf (m)\n{\n  int i;\n  i = m;\n  do\n    {\n      g (i * INT_MAX / 2);\n    }\n  while (--i > 0);\n}\n\nmain ()\n{\n  f (4);\n  if (n != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-3b.c",
    "content": "#include <limits.h>\n\nint n = 0;\n\ng (i)\n{\n  n++;\n}\n\nf (m)\n{\n  int i;\n  i = m;\n  do\n    {\n      g (i * 4);\n      i -= INT_MAX / 8;\n    }\n  while (i > 0);\n}\n\nmain ()\n{\n  f (INT_MAX/8*4);\n  if (n != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-3c.c",
    "content": "#include <limits.h>\n\nvoid * a[255];\n\nf (m)\n{\n  int i;\n  int sh = 0x100;\n  i = m;\n  do\n    {\n      a[sh >>= 1] = ((unsigned)i << 3)  + (char*)a;\n      i += 4;\n    }\n  while (i < INT_MAX/2 + 1 + 4 * 4);\n}\n\nmain ()\n{\n  a[0x10] = 0;\n  a[0x08] = 0;\n  f (INT_MAX/2 + INT_MAX/4 + 2);\n  if (a[0x10] || a[0x08])\n    abort ();\n  a[0x10] = 0;\n  a[0x08] = 0;\n  f (INT_MAX/2 + 1);\n  if (! a[0x10] || a[0x08])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-4.c",
    "content": "int\nf()\n{\n  int j = 1;\n  long i;\n  for (i = -0x70000000L; i < 0x60000000L; i += 0x10000000L) j <<= 1;\n  return j;\n}\n\nint\nmain ()\n{\n  if (f () != 8192)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-4b.c",
    "content": "int\nf()\n{\n  int j = 1;\n  long i;\n  i = 0x60000000L;\n  do\n    {\n      j <<= 1;\n      i += 0x10000000L;\n    } while (i < -0x60000000L);\n  return j;\n}\n\nint\nmain ()\n{\n  if (f () != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-5.c",
    "content": "static int ap(int i);\nstatic void testit(void){\n  int ir[4] = {0,1,2,3};\n  int ix,n,m;\n  n=1; m=3;\n  for (ix=1;ix<=4;ix++) {\n    if (n == 1) m = 4;\n    else        m = n-1;\n    ap(ir[n-1]);\n    n = m;\n  }\n}\n\nstatic int t = 0;\nstatic int a[4];\n\nstatic int ap(int i){\n  if (t > 3)\n    abort();\n  a[t++] = i;\n  return 1;\n}\n\nint main(void)\n{\n  testit();\n  if (a[0] != 0)\n    abort();\n  if (a[1] != 3)\n    abort();\n  if (a[2] != 2)\n    abort();\n  if (a[3] != 1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-6.c",
    "content": "main()\n{\n  char c;\n  char d;\n  int nbits;\n  c = -1;\n  for (nbits = 1 ; nbits < 100; nbits++) {\n    d = (1 << nbits) - 1;\n    if (d == c)\n      break;\n  }\n  if (nbits == 100)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-7.c",
    "content": "void foo (unsigned int n)\n{\n  int i, j = -1;\n\n  for (i = 0; i < 10 && j < 0; i++)\n    {\n      if ((1UL << i) == n)\n\tj = i;\n    }\n\n  if (j < 0)\n    abort ();\n}\n\nmain()\n{\n  foo (64);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-8.c",
    "content": "double a[3] = { 0.0, 1.0, 2.0 };\n\nvoid bar (int x, double *y)\n{\n  if (x || *y != 1.0)\n    abort ();\n}\n\nint main ()\n{\n  double c;\n  int d;\n  for (d = 0; d < 3; d++)\n  {\n    c = a[d];\n    if (c > 0.0) goto e;\n  }\n  bar(1, &c);\n  exit (1);\ne:\n  bar(0, &c);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-9.c",
    "content": "/* Source: Neil Booth, from PR # 115.  */\n\nint false()\n{\n  return 0;\n}\n\nextern void abort (void);\n\nint main (int argc,char *argv[])\n{\n  int count = 0;\n\n  while (false() || count < -123)\n    ++count;\n\n  if (count)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-ivopts-1.c",
    "content": "/* From PR 18977.  */\nvoid foo(float * x);\n\nint main()\n{\n  float x[4];\n  foo (x);\n  return 0;\n}\n\nvoid foo (float *x)\n{\n    int i,j,k;\n    float temp;\n    static float t16[16]={1.,2.,3.,4.,5.,6.,7.,8.,9.,\n\t\t\t  10.,11.,12.,13.,14.,15.,16.};\n    static float tmp[4]={0.,0.,0.,0.};\n\n    for (i=0; i<4; i++) {\n\tk = 3 - i;\n\ttemp = t16[5*k];\n\tfor(j=k+1; j<4; j++) {\n\t    tmp[k] = t16[k+  j*4] * temp;\n\t}\n    }\n    x[0] = tmp[0];\n    x[1] = tmp[1];\n    x[2] = tmp[2];\n    x[3] = tmp[3];\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/loop-ivopts-2.c",
    "content": "/* PR rtl-optimization/20290  */\n   \n/* We used to mis-optimize the second loop in main on at least ppc and\n   arm, because tree loop would change the loop to something like:\n\n  ivtmp.65 = &l[i];\n  ivtmp.16 = 113;\n  goto <bb 4> (<L4>);\n\n<L3>:;\n  *(ivtmp.65 + 4294967292B) = 9;\n  i = i + 1;\n\n<L4>:;\n  ivtmp.16 = ivtmp.16 - 1;\n  ivtmp.65 = ivtmp.65 + 4B;\n  if (ivtmp.16 != 0) goto <L3>; \n\n  We used to consider the increment of i as executed in every\n  iteration, so we'd miscompute the final value.  */\n\nextern void abort (void);\n\nvoid\ncheck (unsigned int *l)\n{\n  int i;\n  for (i = 0; i < 288; i++)\n    if (l[i] != 7 + (i < 256 || i >= 280) + (i >= 144 && i < 256))\n      abort ();\n}\n\nint\nmain (void)\n{\n  int i;\n  unsigned int l[288];\n\n  for (i = 0; i < 144; i++)\n    l[i] = 8;\n  for (; i < 256; i++)\n    l[i] = 9;\n  for (; i < 280; i++)\n    l[i] = 7;\n  for (; i < 288; i++)\n    l[i] = 8;\n  check (l);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/lshrdi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic unsigned long long const zext[64] = {\n  0x87654321fedcba90ULL,\n  0x43b2a190ff6e5d48ULL,\n  0x21d950c87fb72ea4ULL,\n  0x10eca8643fdb9752ULL,\n  0x87654321fedcba9ULL,\n  0x43b2a190ff6e5d4ULL,\n  0x21d950c87fb72eaULL,\n  0x10eca8643fdb975ULL,\n  0x87654321fedcbaULL,\n  0x43b2a190ff6e5dULL,\n  0x21d950c87fb72eULL,\n  0x10eca8643fdb97ULL,\n  0x87654321fedcbULL,\n  0x43b2a190ff6e5ULL,\n  0x21d950c87fb72ULL,\n  0x10eca8643fdb9ULL,\n  0x87654321fedcULL,\n  0x43b2a190ff6eULL,\n  0x21d950c87fb7ULL,\n  0x10eca8643fdbULL,\n  0x87654321fedULL,\n  0x43b2a190ff6ULL,\n  0x21d950c87fbULL,\n  0x10eca8643fdULL,\n  0x87654321feULL,\n  0x43b2a190ffULL,\n  0x21d950c87fULL,\n  0x10eca8643fULL,\n  0x87654321fULL,\n  0x43b2a190fULL,\n  0x21d950c87ULL,\n  0x10eca8643ULL,\n  0x87654321ULL,\n  0x43b2a190ULL,\n  0x21d950c8ULL,\n  0x10eca864ULL,\n  0x8765432ULL,\n  0x43b2a19ULL,\n  0x21d950cULL,\n  0x10eca86ULL,\n  0x876543ULL,\n  0x43b2a1ULL,\n  0x21d950ULL,\n  0x10eca8ULL,\n  0x87654ULL,\n  0x43b2aULL,\n  0x21d95ULL,\n  0x10ecaULL,\n  0x8765ULL,\n  0x43b2ULL,\n  0x21d9ULL,\n  0x10ecULL,\n  0x876ULL,\n  0x43bULL,\n  0x21dULL,\n  0x10eULL,\n  0x87ULL,\n  0x43ULL,\n  0x21ULL,\n  0x10ULL,\n  0x8ULL,\n  0x4ULL,\n  0x2ULL,\n  0x1ULL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic unsigned long long const zext[32] = {\n  0x87654321ULL,\n  0x43b2a190ULL,\n  0x21d950c8ULL,\n  0x10eca864ULL,\n  0x8765432ULL,\n  0x43b2a19ULL,\n  0x21d950cULL,\n  0x10eca86ULL,\n  0x876543ULL,\n  0x43b2a1ULL,\n  0x21d950ULL,\n  0x10eca8ULL,\n  0x87654ULL,\n  0x43b2aULL,\n  0x21d95ULL,\n  0x10ecaULL,\n  0x8765ULL,\n  0x43b2ULL,\n  0x21d9ULL,\n  0x10ecULL,\n  0x876ULL,\n  0x43bULL,\n  0x21dULL,\n  0x10eULL,\n  0x87ULL,\n  0x43ULL,\n  0x21ULL,\n  0x10ULL,\n  0x8ULL,\n  0x4ULL,\n  0x2ULL,\n  0x1ULL,\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic unsigned long long\nvariable_shift(unsigned long long x, int i)\n{\n  return x >> i;\n}\n\nstatic unsigned long long\nconstant_shift(unsigned long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x >> 0; break;\n    case 1: x = x >> 1; break;\n    case 2: x = x >> 2; break;\n    case 3: x = x >> 3; break;\n    case 4: x = x >> 4; break;\n    case 5: x = x >> 5; break;\n    case 6: x = x >> 6; break;\n    case 7: x = x >> 7; break;\n    case 8: x = x >> 8; break;\n    case 9: x = x >> 9; break;\n    case 10: x = x >> 10; break;\n    case 11: x = x >> 11; break;\n    case 12: x = x >> 12; break;\n    case 13: x = x >> 13; break;\n    case 14: x = x >> 14; break;\n    case 15: x = x >> 15; break;\n    case 16: x = x >> 16; break;\n    case 17: x = x >> 17; break;\n    case 18: x = x >> 18; break;\n    case 19: x = x >> 19; break;\n    case 20: x = x >> 20; break;\n    case 21: x = x >> 21; break;\n    case 22: x = x >> 22; break;\n    case 23: x = x >> 23; break;\n    case 24: x = x >> 24; break;\n    case 25: x = x >> 25; break;\n    case 26: x = x >> 26; break;\n    case 27: x = x >> 27; break;\n    case 28: x = x >> 28; break;\n    case 29: x = x >> 29; break;\n    case 30: x = x >> 30; break;\n    case 31: x = x >> 31; break;\n#if BITS > 32\n    case 32: x = x >> 32; break;\n    case 33: x = x >> 33; break;\n    case 34: x = x >> 34; break;\n    case 35: x = x >> 35; break;\n    case 36: x = x >> 36; break;\n    case 37: x = x >> 37; break;\n    case 38: x = x >> 38; break;\n    case 39: x = x >> 39; break;\n    case 40: x = x >> 40; break;\n    case 41: x = x >> 41; break;\n    case 42: x = x >> 42; break;\n    case 43: x = x >> 43; break;\n    case 44: x = x >> 44; break;\n    case 45: x = x >> 45; break;\n    case 46: x = x >> 46; break;\n    case 47: x = x >> 47; break;\n    case 48: x = x >> 48; break;\n    case 49: x = x >> 49; break;\n    case 50: x = x >> 50; break;\n    case 51: x = x >> 51; break;\n    case 52: x = x >> 52; break;\n    case 53: x = x >> 53; break;\n    case 54: x = x >> 54; break;\n    case 55: x = x >> 55; break;\n    case 56: x = x >> 56; break;\n    case 57: x = x >> 57; break;\n    case 58: x = x >> 58; break;\n    case 59: x = x >> 59; break;\n    case 60: x = x >> 60; break;\n    case 61: x = x >> 61; break;\n    case 62: x = x >> 62; break;\n    case 63: x = x >> 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = variable_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = constant_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/lto-tbaa-1.c",
    "content": "/* { dg-additional-options \"-fno-early-inlining -fno-ipa-cp\" }  */\nstruct a {\n  float *b;\n} *a;\nstruct b {\n  int *b;\n} b;\nstruct c {\n  float *b;\n} *c;\nint d;\nuse_a (struct a *a)\n{\n}\nset_b (int **a)\n{\n  *a=&d;\n}\nuse_c (struct c *a)\n{\n}\n__attribute__ ((noinline)) int **retme(int **val)\n{\n  return val;\n}\nint e;\nstruct b b= {&e};\nstruct b b2;\nstruct b b3;\nint **ptr = &b2.b;\nmain ()\n{\n  a= (void *)0;\n  b.b=&e;\n  ptr =retme ( &b.b);\n  set_b (ptr);\n  b3=b;\n  if (b3.b != &d)\n  __builtin_abort ();\n  c= (void *)0;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/mayalias-1.c",
    "content": "/* Tests that the may_alias attribute works as expected.\n   Author: Osku Salerma <osku@iki.fi> Apr 2002.  */\n \nextern void abort(void);\nextern void exit(int);\n\ntypedef short __attribute__((__may_alias__)) short_a;\n\nint\nmain (void)\n{\n  int a = 0x12345678;\n  short_a *b = (short_a*) &a;\n\n  b[1] = 0;\n\n  if (a == 0x12345678)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/mayalias-2.c",
    "content": "typedef struct __attribute__((__may_alias__)) { short x; } test;\n\nint f() {\n  int a=10;\n  test *p=(test *)&a;\n  p->x = 1;\n  return a;\n}\n\nint main() {\n  if (f() == 10)\n    __builtin_abort();\n  return 0;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c",
    "content": "typedef struct __attribute__((__may_alias__)) { short x; } test;\n\ntest *p;\n\nint g(int *a)\n{\n p = (test*)a;\n}\n\nint f()\n{\n  int a;\n  g(&a);\n  a = 10;\n  test s={1};\n  *p=s;\n  return a;\n}\n\nint main() {\n  if (f() == 10)\n    __builtin_abort();\n  return 0;\n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/medce-1.c",
    "content": "\nextern void abort (void);\nextern void link_error (void);\n\nstatic int ok = 0;\n\nvoid bar (void)\n{\n  ok = 1;\n}\n\nvoid foo(int x)\n{\n  switch (x)\n  {\n  case 0:\n    if (0)\n    {\n      link_error();\n  case 1:\n      bar();\n    }\n  }\n}\n\nint main()\n{\n  foo (1);\n  if (!ok)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c",
    "content": "#include <string.h>\n\n#if defined (STACK_SIZE)\n#define MEMCPY_SIZE (STACK_SIZE / 3)\n#else\n#define MEMCPY_SIZE (1 << 17)\n#endif\n\n\nvoid *copy (void *o, const void *i, unsigned l)\n{\n  return memcpy (o, i, l);\n}\n\nmain ()\n{\n  unsigned i;\n  unsigned char src[MEMCPY_SIZE];\n  unsigned char dst[MEMCPY_SIZE];\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    src[i] = (unsigned char) i,  dst[i] = 0;\n\n  (void) memcpy (dst, src, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 1, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != 1)\n      abort ();\n\n  (void) memcpy (dst, src, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 0, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != 0)\n      abort ();\n\n  (void) copy (dst, src, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 0, MEMCPY_SIZE);\n\n  (void) copy (dst, src, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memcpy with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nmain ()\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\n\t  p = memcpy (u1.buf + off1, u2.buf + off2, len);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memcpy-bi.c",
    "content": "/* Test builtin-memcpy (which may emit different code for different N).  */\n#include <string.h>\n\n#define TESTSIZE 80\n\nchar src[TESTSIZE] __attribute__ ((aligned));\nchar dst[TESTSIZE] __attribute__ ((aligned));\n\nvoid\ncheck (char *test, char *match, int n)\n{\n  if (memcmp (test, match, n))\n    abort ();\n}\n\n#define TN(n) \\\n{ memset (dst, 0, n); memcpy (dst, src, n); check (dst, src, n); }\n#define T(n) \\\nTN (n) \\\nTN ((n) + 1) \\\nTN ((n) + 2) \\\nTN ((n) + 3)\n\nmain ()\n{\n  int i,j;\n\n  for (i = 0; i < sizeof (src); ++i)\n      src[i] = 'a' + i % 26;\n\n  T (0);\n  T (4);\n  T (8);\n  T (12);\n  T (16);\n  T (20);\n  T (24);\n  T (28);\n  T (32);\n  T (36);\n  T (40);\n  T (44);\n  T (48);\n  T (52);\n  T (56);\n  T (60);\n  T (64);\n  T (68);\n  T (72);\n  T (76);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memset-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nmain ()\n{\n  int off, len, i;\n  char *p, *q;\n\n  for (off = 0; off < MAX_OFFSET; off++)\n    for (len = 1; len < MAX_COPY; len++)\n      {\n\tfor (i = 0; i < MAX_LENGTH; i++)\n\t  u.buf[i] = 'a';\n\n\tp = memset (u.buf + off, '\\0', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != '\\0')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, A, len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'A')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, 'B', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'B')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n      }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memset-2.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of pointer alignments and constant\n   lengths to make sure any optimizations in the compiler are correct.\n\n   Written by Roger Sayle, April 22, 2002.  */\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY 15\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nvoid reset ()\n{\n  int i;\n\n  for (i = 0; i < MAX_LENGTH; i++)\n    u.buf[i] = 'a';\n}\n\nvoid check (int off, int len, int ch)\n{\n  char *q;\n  int i;\n\n  q = u.buf;\n  for (i = 0; i < off; i++, q++)\n    if (*q != 'a')\n      abort ();\n\n  for (i = 0; i < len; i++, q++)\n    if (*q != ch)\n      abort ();\n\n  for (i = 0; i < MAX_EXTRA; i++, q++)\n    if (*q != 'a')\n      abort ();\n}\n\nint main ()\n{\n  int off;\n  char *p;\n\n  /* len == 1 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, '\\0');\n\n      p = memset (u.buf + off, A, 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, 'A');\n\n      p = memset (u.buf + off, 'B', 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, 'B');\n    }\n\n  /* len == 2 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, '\\0');\n\n      p = memset (u.buf + off, A, 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, 'A');\n\n      p = memset (u.buf + off, 'B', 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, 'B');\n    }\n\n  /* len == 3 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, '\\0');\n\n      p = memset (u.buf + off, A, 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, 'A');\n\n      p = memset (u.buf + off, 'B', 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, 'B');\n    }\n\n  /* len == 4 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, '\\0');\n\n      p = memset (u.buf + off, A, 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, 'A');\n\n      p = memset (u.buf + off, 'B', 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, 'B');\n    }\n\n  /* len == 5 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, '\\0');\n\n      p = memset (u.buf + off, A, 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, 'A');\n\n      p = memset (u.buf + off, 'B', 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, 'B');\n    }\n\n  /* len == 6 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, '\\0');\n\n      p = memset (u.buf + off, A, 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, 'A');\n\n      p = memset (u.buf + off, 'B', 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, 'B');\n    }\n\n  /* len == 7 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, '\\0');\n\n      p = memset (u.buf + off, A, 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, 'A');\n\n      p = memset (u.buf + off, 'B', 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, 'B');\n    }\n\n  /* len == 8 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, '\\0');\n\n      p = memset (u.buf + off, A, 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, 'A');\n\n      p = memset (u.buf + off, 'B', 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, 'B');\n    }\n\n  /* len == 9 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, '\\0');\n\n      p = memset (u.buf + off, A, 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, 'A');\n\n      p = memset (u.buf + off, 'B', 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, 'B');\n    }\n\n  /* len == 10 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, '\\0');\n\n      p = memset (u.buf + off, A, 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, 'A');\n\n      p = memset (u.buf + off, 'B', 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, 'B');\n    }\n\n  /* len == 11 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, '\\0');\n\n      p = memset (u.buf + off, A, 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, 'A');\n\n      p = memset (u.buf + off, 'B', 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, 'B');\n    }\n\n  /* len == 12 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, '\\0');\n\n      p = memset (u.buf + off, A, 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, 'A');\n\n      p = memset (u.buf + off, 'B', 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, 'B');\n    }\n\n  /* len == 13 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, '\\0');\n\n      p = memset (u.buf + off, A, 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, 'A');\n\n      p = memset (u.buf + off, 'B', 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, 'B');\n    }\n\n  /* len == 14 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, '\\0');\n\n      p = memset (u.buf + off, A, 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, 'A');\n\n      p = memset (u.buf + off, 'B', 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, 'B');\n    }\n\n  /* len == 15 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, '\\0');\n\n      p = memset (u.buf + off, A, 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, 'A');\n\n      p = memset (u.buf + off, 'B', 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, 'B');\n    }\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memset-3.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of constant pointer alignments and\n   lengths to make sure any optimizations in the compiler are correct.\n\n   Written by Roger Sayle, July 22, 2002.  */\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY 15\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nvoid reset ()\n{\n  int i;\n\n  for (i = 0; i < MAX_LENGTH; i++)\n    u.buf[i] = 'a';\n}\n\nvoid check (int off, int len, int ch)\n{\n  char *q;\n  int i;\n\n  q = u.buf;\n  for (i = 0; i < off; i++, q++)\n    if (*q != 'a')\n      abort ();\n\n  for (i = 0; i < len; i++, q++)\n    if (*q != ch)\n      abort ();\n\n  for (i = 0; i < MAX_EXTRA; i++, q++)\n    if (*q != 'a')\n      abort ();\n}\n\nint main ()\n{\n  int len;\n  char *p;\n\n  /* off == 0 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf, '\\0', len);\n      if (p != u.buf) abort ();\n      check (0, len, '\\0');\n\n      p = memset (u.buf, A, len);\n      if (p != u.buf) abort ();\n      check (0, len, 'A');\n\n      p = memset (u.buf, 'B', len);\n      if (p != u.buf) abort ();\n      check (0, len, 'B');\n    }\n\n  /* off == 1 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+1, '\\0', len);\n      if (p != u.buf+1) abort ();\n      check (1, len, '\\0');\n\n      p = memset (u.buf+1, A, len);\n      if (p != u.buf+1) abort ();\n      check (1, len, 'A');\n\n      p = memset (u.buf+1, 'B', len);\n      if (p != u.buf+1) abort ();\n      check (1, len, 'B');\n    }\n\n  /* off == 2 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+2, '\\0', len);\n      if (p != u.buf+2) abort ();\n      check (2, len, '\\0');\n\n      p = memset (u.buf+2, A, len);\n      if (p != u.buf+2) abort ();\n      check (2, len, 'A');\n\n      p = memset (u.buf+2, 'B', len);\n      if (p != u.buf+2) abort ();\n      check (2, len, 'B');\n    }\n\n  /* off == 3 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+3, '\\0', len);\n      if (p != u.buf+3) abort ();\n      check (3, len, '\\0');\n\n      p = memset (u.buf+3, A, len);\n      if (p != u.buf+3) abort ();\n      check (3, len, 'A');\n\n      p = memset (u.buf+3, 'B', len);\n      if (p != u.buf+3) abort ();\n      check (3, len, 'B');\n    }\n\n  /* off == 4 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+4, '\\0', len);\n      if (p != u.buf+4) abort ();\n      check (4, len, '\\0');\n\n      p = memset (u.buf+4, A, len);\n      if (p != u.buf+4) abort ();\n      check (4, len, 'A');\n\n      p = memset (u.buf+4, 'B', len);\n      if (p != u.buf+4) abort ();\n      check (4, len, 'B');\n    }\n\n  /* off == 5 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+5, '\\0', len);\n      if (p != u.buf+5) abort ();\n      check (5, len, '\\0');\n\n      p = memset (u.buf+5, A, len);\n      if (p != u.buf+5) abort ();\n      check (5, len, 'A');\n\n      p = memset (u.buf+5, 'B', len);\n      if (p != u.buf+5) abort ();\n      check (5, len, 'B');\n    }\n\n  /* off == 6 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+6, '\\0', len);\n      if (p != u.buf+6) abort ();\n      check (6, len, '\\0');\n\n      p = memset (u.buf+6, A, len);\n      if (p != u.buf+6) abort ();\n      check (6, len, 'A');\n\n      p = memset (u.buf+6, 'B', len);\n      if (p != u.buf+6) abort ();\n      check (6, len, 'B');\n    }\n\n  /* off == 7 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+7, '\\0', len);\n      if (p != u.buf+7) abort ();\n      check (7, len, '\\0');\n\n      p = memset (u.buf+7, A, len);\n      if (p != u.buf+7) abort ();\n      check (7, len, 'A');\n\n      p = memset (u.buf+7, 'B', len);\n      if (p != u.buf+7) abort ();\n      check (7, len, 'B');\n    }\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/memset-4.c",
    "content": "/* Test to make sure memset of small old size works\n   correctly. */\n#define SIZE 15\n\nvoid f(char *a) __attribute__((noinline));\nvoid f(char *a)\n{\n  __builtin_memset (a, 0, SIZE);\n}\n\n\nint main(void)\n{\n  int i;\n  char b[SIZE];\n  for(i = 0; i < sizeof(b); i++)\n    {\n      b[i] = i;\n    }\n  f(b);\n  for(i = 0; i < sizeof(b); i++)\n    {\n      if (0 != b[i])\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/mod-1.c",
    "content": "f (x, y)\n{\n  if (x % y != 0)\n    abort ();\n}\n\nmain ()\n{\n  f (-5, 5);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/mode-dependent-address.c",
    "content": "/* { dg-require-effective-target stdint_types } */\n\n#include <stdint.h>\n#include <string.h>\n#include <stdlib.h>\n\nvoid f883b (int8_t * result,\n    int16_t * __restrict arg1,\n    uint32_t * __restrict arg2,\n    uint64_t * __restrict arg3,\n    uint8_t * __restrict arg4)\n{\n    int idx;\n    for (idx=0;idx<96;idx += 1) {\n\tresult[idx] = (((((((((((-27 + 2+1)>>1) || arg4[idx]) < arg1[idx])\n\t\t\t\t? (((-27 + 2+1)>>1) || arg4[idx])\n\t\t\t\t: arg1[idx])\n\t\t\t       >> (arg2[idx] & 31)) ^ 1) - -32)>>7) | -5) & arg3[idx]);\n    }\n}\n\nint8_t result[96];\nint16_t arg1[96];\nuint32_t arg2[96];\nuint64_t arg3[96];\nuint8_t arg4[96];\n\nint main (void) \n{\n  int i;\n  int correct[] = {0x0,0x1,0x2,0x3,0x0,0x1,0x2,0x3,0x8,0x9,0xa,0xb,0x8,0x9,\n                   0xa,0xb,0x10,0x11,0x12,0x13,0x10,0x11,0x12,0x13,\n                   0x18,0x19,0x1a,0x1b,0x18,0x19,0x1a,0x1b,0x20,0x21,0x22,\n                   0x23,0x20,0x21,0x22,0x23,0x28,0x29,0x2a,\n                   0x2b,0x28,0x29,0x2a,0x2b,0x30,0x31,0x32,0x33,\n                   0x30,0x31,0x32,0x33,0x38,0x39,0x3a,0x3b,0x38,0x39,0x3a,\n                   0x3b,0x40,0x41,0x42,0x43,0x40,0x41,0x42,0x43,0x48,0x49,\n                   0x4a,0x4b,0x48,0x49,0x4a,0x4b,0x50,0x51,\n                   0x52,0x53,0x50,0x51,0x52,0x53,0x58,0x59,0x5a,0x5b,\n                   0x58,0x59,0x5a,0x5b};\n\n  for (i=0; i < 96; i++)\n    arg3[i] = arg2[i] = arg1[i] = arg4[i] = i;\n\n  f883b(result, arg1, arg2, arg3, arg4);\n\n  for (i=0; i < 96; i++)\n    if (result[i] != correct[i]) abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/multdi-1.c",
    "content": "/* PR target/9348 */\n\n#define u_l_l unsigned long long\n#define l_l long long\n\nl_l mpy_res;\n\nu_l_l mpy (long a, long b)\n{\n  return (u_l_l) a * (u_l_l) b;\n}\n \nint main(void)\n{\n  mpy_res = mpy(1,-1);\n  if (mpy_res != -1LL)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/multi-ix.c",
    "content": "/* Test for a reload bug:\n   if you have a memory reference using the indexed addressing\n   mode, and the base address is a pseudo containing an address in the frame\n   and this pseudo fails to get a hard register, we end up with a double PLUS,\n   so the frame address gets reloaded.  Now, when the index got a hard register,\n   and it dies in this insn, push_reload will consider that hard register as\n   a reload register, and disregrad overlaps with rld[n_reloads].in .  That is\n   fine as long as the add can be done with a single insn, but when the\n   constant is so large that it has to be reloaded into a register first,\n   that clobbers the index.  */\n\n#include <stdarg.h>\n\n#ifdef STACK_SIZE\n/* We need to be careful that we don't blow our stack.  Function f, in the\n   worst case, needs to fit on the stack:\n\n   * 40 int[CHUNK] arrays;\n   * ~40 ints;\n   * ~40 pointers for stdarg passing.\n\n   Subtract the last two off STACK_SIZE and figure out what the maximum\n   chunk size can be.  We make the last bit conservative to account for\n   register saves and other processor-dependent saving.  Limit the\n   chunk size to some sane values.  */\n\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))\n\n#define CHUNK\t\t\t\t\t\t\t\t\\\n  MIN (500, (MAX (1, (signed)(STACK_SIZE-40*sizeof(int)-256*sizeof(void *)) \\\n\t\t      / (signed)(40*sizeof(int)))))\n#else\n#define CHUNK 500\n#endif\n\nvoid s(int, ...);\nvoid z(int, ...);\nvoid c(int, ...);\n\ntypedef int l[CHUNK];\n\nvoid\nf (int n)\n{\n  int i;\n  l a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;\n  l a10, a11, a12, a13, a14, a15, a16, a17, a18, a19;\n  l a20, a21, a22, a23, a24, a25, a26, a27, a28, a29;\n  l a30, a31, a32, a33, a34, a35, a36, a37, a38, a39;\n  int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;\n  int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;\n  int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;\n  int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;\n\n  for (i = 0; i < n; i++)\n    {\n      s (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n      i0 = a0[0];\n      i1 = a1[0];\n      i2 = a2[0];\n      i3 = a3[0];\n      i4 = a4[0];\n      i5 = a5[0];\n      i6 = a6[0];\n      i7 = a7[0];\n      i8 = a8[0];\n      i9 = a9[0];\n      i10 = a10[0];\n      i11 = a11[0];\n      i12 = a12[0];\n      i13 = a13[0];\n      i14 = a14[0];\n      i15 = a15[0];\n      i16 = a16[0];\n      i17 = a17[0];\n      i18 = a18[0];\n      i19 = a19[0];\n      i20 = a20[0];\n      i21 = a21[0];\n      i22 = a22[0];\n      i23 = a23[0];\n      i24 = a24[0];\n      i25 = a25[0];\n      i26 = a26[0];\n      i27 = a27[0];\n      i28 = a28[0];\n      i29 = a29[0];\n      i30 = a30[0];\n      i31 = a31[0];\n      i32 = a32[0];\n      i33 = a33[0];\n      i34 = a34[0];\n      i35 = a35[0];\n      i36 = a36[0];\n      i37 = a37[0];\n      i38 = a38[0];\n      i39 = a39[0];\n      z (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n      a0[i0] = i0;\n      a1[i1] = i1;\n      a2[i2] = i2;\n      a3[i3] = i3;\n      a4[i4] = i4;\n      a5[i5] = i5;\n      a6[i6] = i6;\n      a7[i7] = i7;\n      a8[i8] = i8;\n      a9[i9] = i9;\n      a10[i10] = i10;\n      a11[i11] = i11;\n      a12[i12] = i12;\n      a13[i13] = i13;\n      a14[i14] = i14;\n      a15[i15] = i15;\n      a16[i16] = i16;\n      a17[i17] = i17;\n      a18[i18] = i18;\n      a19[i19] = i19;\n      a20[i20] = i20;\n      a21[i21] = i21;\n      a22[i22] = i22;\n      a23[i23] = i23;\n      a24[i24] = i24;\n      a25[i25] = i25;\n      a26[i26] = i26;\n      a27[i27] = i27;\n      a28[i28] = i28;\n      a29[i29] = i29;\n      a30[i30] = i30;\n      a31[i31] = i31;\n      a32[i32] = i32;\n      a33[i33] = i33;\n      a34[i34] = i34;\n      a35[i35] = i35;\n      a36[i36] = i36;\n      a37[i37] = i37;\n      a38[i38] = i38;\n      a39[i39] = i39;\n      c (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n    }\n}\n\nint\nmain ()\n{\n  /* CHUNK needs to be at least 40 to avoid stack corruption,\n     since index variable i0 in \"a[i0] = i0\" equals 39.  */\n  if (CHUNK < 40)\n    exit (0);\n\n  f (1);\n  exit (0);\n}\n\nvoid s(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      a[0] = n;\n    }\n  va_end (list);\n}\n\nvoid z(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      __builtin_memset (a, 0, sizeof (l));\n    }\n  va_end (list);\n}\n\nvoid c(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      if (a[n] != n)\n\tabort ();\n    }\n  va_end (list);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c",
    "content": "/* Test for alignment handling when a variable is accessed by nested\n   function.  */\n/* Origin: Joey Ye <joey.ye@intel.com> */\n\n/* Force bigger stack alignment for PowerPC EABI targets.  */\n/* { dg-options \"-mno-eabi\" { target powerpc-*-eabi* } } */\n\n#include <stddef.h>\n\ntypedef int aligned __attribute__((aligned));\nextern void abort (void);\n\nvoid\ncheck (int *i)\n{\n  *i = 20;\n  if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0)\n    abort ();\n}\n\nvoid\nfoo (void)\n{\n  aligned jj;\n  void bar ()\n    {\n      jj = -20;\n    }\n  jj = 0;\n  bar ();\n  if (jj != -20)\n    abort ();\n  check (&jj);\n  if (jj != 20)\n    abort ();\n}\n\nint\nmain()\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c",
    "content": "#include <stdarg.h>\n\nmain ()\n{\n  double f (int x, ...)\n    {\n      va_list args;\n      double a;\n\n      va_start (args, x);\n      a = va_arg (args, double);\n      va_end (args);\n      return a;\n    }\n\n  if (f (1, (double)1) != 1.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-1.c",
    "content": "int\ng (int a, int b, int (*gi) (int, int))\n{\n  if ((*gi) (a, b))\n    return a;\n  else\n    return b;\n}\n\nf ()\n{\n#ifndef NO_TRAMPOLINES\n  int i, j;\n  int f2 (int a, int b)\n    {\n      return a > b;\n    }\n\n  if (g (1, 2, f2) != 2)\n    abort ();\n#endif\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c",
    "content": "extern int foo (int, int, int (*) (int, int, int, int, int, int, int));\n\nint z;\n\nint\nmain (void)\n{\n#ifndef NO_TRAMPOLINES\n  int sum = 0;\n  int i;\n\n  int nested (int a, int b, int c, int d, int e, int f, int g)\n    {\n      z = c + d + e + f + g;\n      \n      if (a > 2 * b)\n        return a - b;\n      else\n        return b - a;\n    }\n\n  for (i = 0; i < 10; ++i)\n    {\n      int j;\n\n      for (j = 0; j < 10; ++j)\n        {\n          int k;\n\n          for (k = 0; k < 10; ++k)\n            sum += foo (i, j > k ? j - k : k - j, nested);\n        }\n    }\n\n  if (sum != 2300)\n    abort ();\n\n  if (z != 0x1b)\n    abort ();\n#endif\n  \n  exit (0);\n}\n\nint\nfoo (int a, int b, int (* fp) (int, int, int, int, int, int, int))\n{\n  return fp (a, b, a, b, a, b, a);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c",
    "content": "\nextern long foo (long, long, long (*) (long, long));\nextern long use (long (*) (long, long), long, long);\n\nint\nmain (void)\n{\n#ifndef NO_TRAMPOLINES\n  long sum = 0;\n  long i;\n\n  long nested_0 (long a, long b)\n    {\n      if (a > 2 * b)\n        return a - b;\n      else\n        return b - a;\n    }\n\n  long nested_1 (long a, long b)\n    {\n      return use (nested_0, b, a) + sum;\n    }\n\n  long nested_2 (long a, long b)\n    {\n      return nested_1 (b, a);\n    }\n\n  for (i = 0; i < 10; ++i)\n    {\n      long j;\n\n      for (j = 0; j < 10; ++j)\n        {\n          long k;\n\n          for (k = 0; k < 10; ++k)\n            sum += foo (i, j > k ? j - k : k - j, nested_2);\n        }\n    }\n\n  if ((sum & 0xffffffff) != 0xbecfcbf5)\n    abort ();\n#endif\n\n  exit (0);\n}\n\nlong\nuse (long (* func)(long, long), long a, long b)\n{\n  return func (b, a);\n}\n\nlong\nfoo (long a, long b, long (* func) (long, long))\n{\n  return func (a, b);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c",
    "content": "/* Origin: hp@bitrange.com\n   Test that return values come out right from a 1000-level call chain to\n   functions without parameters that each need at least one \"long\"\n   preserved.  Exposed problems related to the MMIX port.  */\n\nlong level = 0;\nextern long foo (void);\nextern long bar (void);\n\n#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 500\n#endif\n\nint\nmain (void)\n{\n  if (foo () == -42)\n    exit (0);\n\n  abort ();\n}\n\nlong\nfoo (void)\n{\n  long tmp = ++level;\n  return bar () + tmp;\n}\n\nlong\nbar (void)\n{\n  long tmp = level;\n  return tmp > DEPTH - 1 ? -42 - tmp : foo () - tmp;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-5.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\n#ifndef NO_TRAMPOLINES\nstatic void recursive (int n, void (*proc) (void))\n{\n  __label__ l1;\n\n  void do_goto (void)\n  {\n    goto l1;\n  }\n\n  if (n == 3)\n      recursive (n - 1, do_goto);\n  else if (n > 0)\n    recursive (n - 1, proc);\n  else\n    (*proc) ();\n  return;\n\nl1:\n  if (n == 3)\n    exit (0);\n  else\n    abort ();\n}\n\nint main ()\n{\n  recursive (10, abort);\n  abort ();\n}\n#else\nint main () { return 0; }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-6.c",
    "content": "/* Test that the GP gets properly restored, either by the nonlocal\n   receiver or the nested function.  */\n\n#ifndef NO_TRAMPOLINES\n\ntypedef __SIZE_TYPE__ size_t;\nextern void abort (void);\nextern void exit (int);\nextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));\n\nint main ()\n{\n  __label__ nonlocal;\n  int compare (const void *a, const void *b)\n  {\n    goto nonlocal;\n  }\n\n  char array[3];\n  qsort (array, 3, 1, compare);\n  abort ();\n\n nonlocal:\n  exit (0);\n}\n\n#else\nint main() { return 0; }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/nestfunc-7.c",
    "content": "struct A\n{\n  int one;\n  int two;\n  int three;\n  int four;\n  int five;\n  int six;\n};\n\nstatic int test (void)\n{\n  int base;\n\n  struct A Foo (void)\n    {\n      struct A a;\n\n      a.one = base + 1;\n      a.two = base + 2;\n      a.three = base + 3;\n      a.four = base + 4;\n      a.five = base + 5;\n      a.six = base + 6;\n\n      return a;\n    }\n\n  base = 10;\n  struct A a = Foo ();\n\n  return (a.one == 11\n\t  && a.two == 12\n\t  && a.three == 13\n\t  && a.four == 14\n\t  && a.five == 15\n\t  && a.six == 16);\n}\n\nint main (void)\n{\n  return !test ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/p18298.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\n#include <stdbool.h>\n#include <stdlib.h>\nextern void abort (void);\nint strcmp (const char*, const char*);\nchar s[2048] = \"a\";\ninline bool foo(const char *str) {\n  return !strcmp(s,str);\n}\nint main() {\nint i = 0;\n  while(!(foo(\"\"))) {\n    i ++;\n    s[0] = '\\0';\n    if (i>2)\n     abort ();\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/packed-1.c",
    "content": "short x1 = 17;\n\nstruct\n{\n  short i __attribute__ ((packed));\n} t;\n\nf ()\n{\n  t.i = x1;\n  if (t.i != 17)\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/packed-2.c",
    "content": "typedef struct s {\n\tunsigned short a;\n\tunsigned long b __attribute__ ((packed));\n} s;\n\ns t;\n\nint main()\n{\n        t.b = 0;\n\treturn 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pending-4.c",
    "content": "\nvoid dummy (x, y)\n     int *x;\n     int y;\n{}\n\nint\nmain (argc, argv)\n     int argc;\n     char **argv;\n{\n  int number_columns=9;\n  int cnt0 = 0;\n  int cnt1 = 0;\n  int i,A1;\n\n  for (i = number_columns-1; i != 0; i--)\n    {         \n      if (i == 1)\n\t{\n\t  dummy(&A1, i);\n\t  cnt0++;\n\t}\n      else\n\t{\n          dummy(&A1, i-1);\n          cnt1++;\n\t}\n    }\n  if (cnt0 != 1 || cnt1 != 7)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/postmod-1.c",
    "content": "#define DECLARE_ARRAY(A) array##A[0x10]\n#define DECLARE_COUNTER(A) counter##A = 0\n#define DECLARE_POINTER(A) *pointer##A = array##A + x\n/* Create a loop that allows post-modification of pointerA, followed by\n   a use of the post-modified address.  */\n#define BEFORE(A) counter##A += *pointer##A, pointer##A += 3\n#define AFTER(A) counter##A += pointer##A[x]\n\n/* Set up the arrays so that one iteration of the loop sets the counter\n   to 3.0f.  */\n#define INIT_ARRAY(A) array##A[1] = 1.0f, array##A[5] = 2.0f\n\n/* Check that the loop worked correctly for all values.  */\n#define CHECK_ARRAY(A) exit_code |= (counter##A != 3.0f)\n\n/* Having 6 copies triggered the bug for ARM and Thumb.  */\n#define MANY(A) A (0), A (1), A (2), A (3), A (4), A (5)\n\n/* Each addendA should be allocated a register.  */\n#define INIT_VOLATILE(A) addend##A = vol\n#define ADD_VOLATILE(A) vol += addend##A\n\n/* Having 5 copies triggered the bug for ARM and Thumb.  */\n#define MANY2(A) A (0), A (1), A (2), A (3), A (4)\n\nfloat MANY (DECLARE_ARRAY);\nfloat MANY (DECLARE_COUNTER);\n\nvolatile int stop = 1;\nvolatile int vol;\n\nvoid __attribute__((noinline))\nfoo (int x)\n{\n  float MANY (DECLARE_POINTER);\n  int i;\n\n  do\n    {\n      MANY (BEFORE);\n      MANY (AFTER);\n      /* Create an inner loop that should ensure the code above\n\t has registers free for reload inheritance.  */\n      {\n\tint MANY2 (INIT_VOLATILE);\n\tfor (i = 0; i < 10; i++)\n\t  MANY2 (ADD_VOLATILE);\n      }\n    }\n  while (!stop);\n}\n\nint\nmain (void)\n{\n  int exit_code = 0;\n\n  MANY (INIT_ARRAY);\n  foo (1);\n  MANY (CHECK_ARRAY);\n  return exit_code;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr15262-1.c",
    "content": "/* PR 15262.\n   The alias analyzer only considers relations between pointers and\n   symbols.  If two pointers P and Q point to the same symbol S, then\n   their respective memory tags will either be the same or they will\n   have S in their alias set.\n   \n   However, if there are no common symbols between P and Q, TBAA will\n   currently miss their alias relationship altogether.  */\nstruct A\n{\n  int t;\n  int i;\n};\n\nint foo () { return 3; }\n\nmain ()\n{\n  struct A loc, *locp;\n  float f, g, *p;\n  int T355, *T356;\n\n  /* Avoid the partial hack in TBAA that would consider memory tags if\n     the program had no addressable symbols.  */\n  f = 3;\n  g = 2;\n  p = foo () ? &g : &f;\n  if (*p > 0.0)\n    g = 1;\n\n  /* Store into *locp and cache its current value.  */\n  locp = malloc (sizeof (*locp));\n  locp->i = 10;\n  T355 = locp->i;\n\n  /* Take the address of one of locp's fields and write to it.  */\n  T356 = &locp->i;\n  *T356 = 1;\n\n  /* Read the recently stored value.  If TBAA fails, this will appear\n     as a redundant load that will be replaced with '10'.  */\n  T355 = locp->i;\n  if (T355 != 1)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr15262-2.c",
    "content": "/* PR 15262.  Similar to pr15262-1.c but with no obvious addresses\n   being taken in function foo().  Without IPA, by only looking inside\n   foo() we cannot tell for certain whether 'q' and 'b' alias each\n   other.  */\nstruct A\n{\n  int t;\n  int i;\n};\n\nstruct B\n{\n  int *p;\n  float b;\n};\n\nfloat X;\n\nfoo (struct B b, struct A *q, float *h)\n{\n  X += *h;\n  *(b.p) = 3;\n  q->t = 2;\n  return *(b.p);\n}\n\nmain()\n{\n  struct A a;\n  struct B b;\n\n  b.p = &a.t;\n  if (foo (b, &a, &X) == 3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr15262.c",
    "content": "/* We used to mis-compile this testcase as we did not know that\n   &a+offsetof(b,a) was the same as &a.b */\nstruct A\n{\n  int t;\n  int i;\n};\n\nvoid\nbar (float *p)\n{\n  *p = 5.2;\n}\n\nint\nfoo(struct A *locp, int i, int str)\n{\n  float f, g, *p;\n  int T355;\n  int *T356;\n  /* Currently, the alias analyzer has limited support for handling\n     aliases of structure fields when no other variables are aliased.\n     Introduce additional aliases to confuse it.  */\n  p =  i ? &g : &f;\n  bar (p);\n  if (*p > 0.0)\n    str = 1;\n\n  T355 = locp->i;\n  T356 = &locp->i;\n  *T356 = str;\n  T355 = locp->i;\n\n  return T355;\n}\n\nmain ()\n{\n  struct A loc;\n  int str;\n\n  loc.i = 2;\n  str = foo (&loc, 10, 3);\n  if (str!=1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr15296.c",
    "content": "/* PR optimization/15296.  The delayed-branch scheduler caused code that\n   SEGV:d for CRIS; a register was set to -1 in a delay-slot for the\n   fall-through code, while that register held a pointer used in code at\n   the branch target.  */\n\ntypedef __INTPTR_TYPE__ intptr_t;\ntypedef intptr_t W;\nunion u0\n{\n  union u0 *r;\n  W i;\n};\nstruct s1\n{\n  union u0 **m0;\n  union u0 m1[4];\n};\n\nvoid f (void *, struct s1 *, const union u0 *, W, W, W)\n     __attribute__ ((__noinline__));\nvoid g (void *, char *) __attribute__ ((__noinline__));\n\nvoid\nf (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4)\n{\n  union u0 *e = 0;\n  union u0 *k = 0;\n  union u0 **v5 = b->m0;\n  union u0 *c = b->m1;\n  union u0 **d = &v5[0];\nl0:;\n  if (v0 < v1)\n    goto l0;\n  if (v0 == 0)\n    goto l3;\n  v0 = v4;\n  if (v0 != 0)\n    goto l3;\n  c[0].r = *d;\n  v1 = -1;\n  e = c[0].r;\n  if (e != 0)\n    g (a, \"\");\n  k = e + 3;\n  k->i = v1;\n  goto l4;\nl3:;\n  c[0].i = v0;\n  e = c[1].r;\n  if (e != 0)\n    g (a, \"\");\n  e = c[0].r;\n  if (e == 0)\n    g (a, \"\");\n  k = e + 2;\n  k->r = c[1].r;\nl4:;\n}\n\nvoid g (void *a, char *b) { abort (); }\n\nint\nmain ()\n{\n  union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }};\n  struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}};\n  f (0, &s, 0, 20000, 10000, (W) uv);\n  if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999\n      || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222\n      || uv[2].i != 0 || uv[3].i != 444)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr16790-1.c",
    "content": "/* PR middle-end/16790.  */\n\nextern void abort ();\n\nstatic void test1(unsigned int u1)\n{\n  unsigned int y_final_1;\n  signed short y_middle;\n  unsigned int y_final_2;\n\n  y_final_1 = (unsigned int)( (signed short)(u1 * 2) * 3 );\n  y_middle  =                 (signed short)(u1 * 2);\n  y_final_2 = (unsigned int)( y_middle * 3 );\n\n  if (y_final_1 != y_final_2)\n    abort ();\n}\n\n\nstatic void test2(unsigned int u1)\n{\n  unsigned int y_final_1;\n  signed short y_middle;\n  unsigned int y_final_2;\n\n  y_final_1 = (unsigned int)( (signed short)(u1 << 1) * 3 );\n  y_middle  =                 (signed short)(u1 << 1);\n  y_final_2 = (unsigned int)( y_middle * 3 );\n\n  if (y_final_1 != y_final_2)\n    abort ();\n}\n\n\nint main()\n{\n  test1(0x4000U);\n  test2(0x4000U);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr17078-1.c",
    "content": "extern void abort(void);\n\nvoid test(int *ptr)\n{\n  int i = 1;\n  goto useless;\n  if (0)\n    {\n      useless:\n      i = 0;\n    }\n  else\n    i = 1;\n  *ptr = i;\n}\n\nint main()\n{\n  int i = 1;\n  test(&i);\n  if (i)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr17133.c",
    "content": "extern void abort (void);\n\nint foo = 0;\nvoid *bar = 0;\nunsigned int baz = 100;\n\nvoid *pure_alloc ()\n{\n  void *res;\n  \n  while (1)\n    {\n      res = (void *) ((((unsigned int) (foo + bar))) & ~1);\n      foo += 2;\n      if (foo < baz)\n        return res;\n      foo = 0;\n    }\n}\n\nint main ()\n{\n  pure_alloc ();\n  if (!foo)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr17252.c",
    "content": "/* PR 17252.  When a char * pointer P takes its own address, storing\n   into *P changes P itself.  */\n\nchar *a;\n\nmain ()\n{\n  /* Make 'a' point to itself.  */\n  a = (char *)&a;\n\n  /* Change what 'a' is pointing to.  */\n  a[0]++;\n\n  /* If a's memory tag does not contain 'a' in its alias set, we will\n     think that this predicate is superfluous and change it to\n     'if (1)'.  */\n  if (a == (char *)&a)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr17377.c",
    "content": "/* PR target/17377\n   Bug in code emitted by \"return\" pattern on CRIS: missing pop of\n   forced return address on stack.  */\n/* { dg-require-effective-target return_address } */\nint calls = 0;\n\nvoid *f (int) __attribute__ ((__noinline__));\nvoid *\nf (int i)\n{\n  /* The code does a little brittle song and dance to trig the \"return\"\n     pattern instead of the function epilogue.  This must still be a\n     leaf function for the bug to be exposed.  */\n\n  if (calls++ == 0)\n    return __builtin_return_address (0);\n\n  switch (i)\n    {\n    case 1:\n      return f;\n    case 0:\n      return __builtin_return_address (0);\n    }\n  return 0;\n}\n\nint x;\n\nvoid *y (int i) __attribute__ ((__noinline__,__noclone__));\nvoid *\ny (int i)\n{\n  x = 0;\n\n  /* This must not be a sibling call: the return address must appear\n     constant for different calls to this function.  Postincrementing x\n     catches otherwise unidentified multiple returns (e.g. through the\n     return-address register and then this epilogue popping the address\n     stored on stack in \"f\").  */\n  return (char *) f (i) + x++;\n}\n\nint\nmain (void)\n{\n  void *v = y (4);\n  if (y (1) != f\n      /* Can't reasonably check the validity of the return address\n\t above, but it's not that important: the test-case will probably\n\t crash on the first call to f with the bug present, or it will\n\t run wild including returning early (in y or here), so we also\n\t try and check the number of calls.  */\n      || y (0) != v\n      || y (3) != 0\n      || y (-1) != 0\n      || calls != 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19005.c",
    "content": "/* PR target/19005 */\nextern void abort (void);\n\nint v, s;\n\nvoid\nbar (int a, int b)\n{\n  unsigned char x = v;\n\n  if (!s)\n    {\n      if (a != x || b != (unsigned char) (x + 1))\n        abort ();\n    }\n  else if (a != (unsigned char) (x + 1) || b != x)\n    abort ();\n  s ^= 1;\n}\n\nint\nfoo (int x)\n{\n  unsigned char a = x, b = x + 1;\n\n  bar (a, b);\n  a ^= b; b ^= a; a ^= b;\n  bar (a, b);\n  return 0;\n}\n\nint\nmain (void)\n{\n  for (v = -10; v < 266; v++)\n    foo (v);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19449.c",
    "content": "/* PR c/19449 */\n\nextern void abort (void);\n\nint y;\nint z = __builtin_choose_expr (!__builtin_constant_p (y), 3, 4);\n\nint\nfoo (int x)\n{\n  return __builtin_choose_expr (!__builtin_constant_p (x), 3, y++);\n}\n\nint\nmain ()\n{\n  if (y || z != 3 || foo (4) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19515.c",
    "content": "/* PR 19515 */\n\ntypedef union {\n      char a2[8];\n}aun;\n\nvoid abort (void);\n\nint main(void)\n{\n  aun a = {{0}};\n\n  if (a.a2[2] != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19606.c",
    "content": "/* PR c/19606\n   The C front end used to shorten the type of a division to a type\n   that does not preserve the semantics of the original computation.\n   Make sure that won't happen.  */\n\nsigned char a = -4;\n\nint\nfoo (void)\n{\n  return ((unsigned int) (signed int) a) / 2LL;\n}\n\nint\nbar (void)\n{\n  return ((unsigned int) (signed int) a) % 5LL;\n}\n\nint\nmain (void)\n{\n  int r;\n\n  r = foo ();\n  if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL)\n    abort ();\n\n  r = bar ();\n  if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19687.c",
    "content": "extern void abort (void);\n\nunion U\n{\n  int i, j[4];\n};\n\nint main ()\n{\n  union U t = {};\n  int i;\n\n  for (i = 0; i < 4; ++i)\n    if (t.j[i] != 0)\n      abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr19689.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort (void);\n\nstruct\n{\n  int b : 29;\n} f;\n\nvoid foo (short j)\n{\n  f.b = j;\n}\n\nint main()\n{\n  foo (-55);\n  if (f.b != -55)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20100-1.c",
    "content": "/* PR tree-optimization/20100\n   Pure function being treated as const.\n   Author: Hans-Peter Nilsson.  */\n\nstatic unsigned short g = 0;\nstatic unsigned short p = 0;\nunsigned char e;\n\nstatic unsigned short\nnext_g (void)\n{\n  return g == e - 1 ? 0 : g + 1;\n}\n\nstatic unsigned short\ncurr_p (void)\n{\n  return p;\n}\n\nstatic unsigned short\ninc_g (void)\n{\n  return g = next_g ();\n}\n\nstatic unsigned short\ncurr_g (void)\n{\n  return g;\n}\n\nstatic char\nring_empty (void)\n{\n  if (curr_p () == curr_g ())\n    return 1;\n  else\n    return 0;\n}\n\nchar\nfrob (unsigned short a, unsigned short b)\n{\n  g = a;\n  p = b;\n  inc_g ();\n  return ring_empty ();\n}\n\nunsigned short\nget_n (void)\n{\n  unsigned short n = 0;\n  unsigned short org_g;\n  org_g = curr_g ();\n  while (!ring_empty () && n < 5)\n    {\n      inc_g ();\n      n++;\n    }\n\n  return n;\n}\n\nvoid abort (void);\nvoid exit (int);\nint main (void)\n{\n  e = 3;\n  if (frob (0, 2) != 0 || g != 1 || p != 2 || e != 3\n      || get_n () != 1\n      || g != 2 || p != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20187-1.c",
    "content": "int a = 0x101;\nint b = 0x100;\n\nint\ntest (void)\n{\n  return (((unsigned char) (unsigned long long) ((a ? a : 1) & (a * b)))\n\t  ? 0 : 1);\n}\n\nint\nmain (void)\n{\n  return 1 - test ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20466-1.c",
    "content": "int f (int **, int *, int *, int **, int **) __attribute__ ((__noinline__));\nint\nf (int **ipp, int *i1p, int *i2p, int **i3, int **i4)\n{\n  **ipp = *i1p;\n  *ipp = i2p;\n  *i3 = *i4;\n  **ipp = 99;\n  return 3;\n}\n\nextern void exit (int);\nextern void abort (void);\n\nint main (void)\n{\n  int i = 42, i1 = 66, i2 = 1, i3 = -1, i4 = 55;\n  int *ip = &i;\n  int *i3p = &i3;\n  int *i4p = &i4;\n\n  f (&ip, &i1, &i2, &i3p, &i4p);\n  if (i != 66 || ip != &i2 || i2 != 99 || i3 != -1 || i3p != i4p || i4 != 55)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20527-1.c",
    "content": "/* PR rtl-optimization/20527\n   Mishandled postincrement.  This test-case is derived from the\n   function BZ2_hbCreateDecodeTables in the file huffman.c from\n   bzip2-1.0.2, hence requiring the following disclaimer copied here:  */\n\n/*--\n  This file is a part of bzip2 and/or libbzip2, a program and\n  library for lossless, block-sorting data compression.\n\n  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.\n\n  Redistribution and use in source and binary forms, with or without\n  modification, are permitted provided that the following conditions\n  are met:\n\n  1. Redistributions of source code must retain the above copyright\n     notice, this list of conditions and the following disclaimer.\n\n  2. The origin of this software must not be misrepresented; you must \n     not claim that you wrote the original software.  If you use this \n     software in a product, an acknowledgment in the product \n     documentation would be appreciated but is not required.\n\n  3. Altered source versions must be plainly marked as such, and must\n     not be misrepresented as being the original software.\n\n  4. The name of the author may not be used to endorse or promote \n     products derived from this software without specific prior written \n     permission.\n\n  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\n  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n  Julian Seward, Cambridge, UK.\n  jseward@acm.org\n  bzip2/libbzip2 version 1.0 of 21 March 2000\n\n  This program is based on (at least) the work of:\n     Mike Burrows\n     David Wheeler\n     Peter Fenwick\n     Alistair Moffat\n     Radford Neal\n     Ian H. Witten\n     Robert Sedgewick\n     Jon L. Bentley\n\n  For more information on these sources, see the manual.\n--*/\n\nvoid f (long *limit, long *base, long minLen, long maxLen) __attribute__ ((__noinline__));\nvoid f (long *limit, long *base, long minLen, long maxLen)\n{\n  long i;\n  long vec;\n  vec = 0;\n  for (i = minLen; i <= maxLen; i++) {\n    vec += (base[i+1] - base[i]);\n    limit[i] = vec-1;\n  }\n}\nextern void abort (void);\nextern void exit (int);\nlong b[] = {1, 5, 11, 23};\nint main (void)\n{\n  long l[3];\n  f (l, b, 0, 2);\n  if (l[0] != 3 || l[1] != 9 || l[2] != 21)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c",
    "content": "/* PR tree-optimization/20601 */\n/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\nextern void abort (void);\nextern void exit (int);\n\nstruct T\n{\n  char *t1;\n  char t2[4096];\n  char **t3;\n};\n\nint a[5];\nint b;\nchar **c;\nint d;\nchar **e;\nstruct T t;\nchar *f[16];\nchar *g[] = { \"a\", \"-u\", \"b\", \"c\" };\n\n__attribute__ ((__noreturn__)) void\nfoo (void)\n{\n  while (1);\n}\n\n__attribute__ ((noinline)) char *\nbar (char *x, unsigned int y)\n{\n  return 0;\n}\n\nstatic inline char *\nbaz (char *x, unsigned int y)\n{\n  if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2))\n    foo ();\n  return bar (x, y);\n}\n\nstatic inline int\nsetup1 (int x)\n{\n  char *p;\n  int rval;\n\n  if (!baz (t.t2, sizeof (t.t2)))\n    baz (t.t2, sizeof (t.t2));\n\n  if (x & 0x200)\n    {\n      char **h, **i = e;\n\n      ++d;\n      e = f;\n      if (t.t1 && *t.t1)\n        e[0] = t.t1;\n      else\n        abort ();\n\n      for (h = e + 1; (*h = *i); ++i, ++h)\n        ;\n    }\n  return 1;\n}\n\nstatic inline int\nsetup2 (void)\n{\n  int j = 1;\n\n  e = c + 1;\n  d = b - 1;\n  while (d > 0 && e[0][0] == '-')\n    {\n      if (e[0][1] != '\\0' && e[0][2] != '\\0')\n        abort ();\n\n      switch (e[0][1])\n        {\n        case 'u':\n          if (!e[1])\n            abort ();\n\n          t.t3 = &e[1];\n          d--;\n          e++;\n          break;\n        case 'P':\n          j |= 0x1000;\n          break;\n        case '-':\n          d--;\n          e++;\n          if (j == 1)\n            j |= 0x600;\n          return j;\n        }\n      d--;\n      e++;\n    }\n\n  if (d > 0 && !(j & 1))\n    abort ();\n\n  return j;\n}\n\nint\nmain (void)\n{\n  int x;\n  c = g;\n  b = 4;\n  x = setup2 ();\n  t.t1 = \"/bin/sh\";\n  setup1 (x);\n  /* PRE shouldn't transform x into the constant 0x601 here, it's not legal.  */\n  if ((x & 0x400) && !a[4])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c",
    "content": "/* When generating o32 MIPS PIC, main's $gp save slot was out of range\n   of a single load instruction.  */\nstruct big { int i[sizeof (int) >= 4 && sizeof (void *) >= 4 ? 0x4000 : 4]; };\nstruct big gb;\nint foo (struct big b, int x) { return b.i[x]; }\n#if defined(STACK_SIZE) && STACK_SIZE <= 0x10000\nint main (void) { return 0; }\n#else\nint main (void) { return foo (gb, 0) + foo (gb, 1); }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr21173.c",
    "content": "void abort (void);\n\nchar q;\nvoid *a[2];\n\nvoid foo (char *p)\n{\n  int i;\n  for (i = 0; i < 2; i++)\n    a[i] += p - &q;\n}\n\nint main (void)\n{\n  int i;\n  foo (&q);\n  for (i = 0; i < 2; i ++)\n    if (a[i])\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr21331.c",
    "content": "void abort (void);\n\nint bar (void) {  return -1;  }\n\nunsigned long\nfoo ()\n{ unsigned long retval;\n  retval = bar ();\n  if (retval == -1)  return 0;\n  return 3;  }\n\nmain ()\n{ if (foo () != 0)  abort ();\n  return 0;  }\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr21964-1.c",
    "content": "void\nfoo (int n, int m)\n{\n  if (m == 0)\n    exit (0);\n  else if (n != 0)\n    abort ();\n  else\n    foo (n++, m - 1);\n}\n \nint\nmain (void)\n{\n  foo (0, 4);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22061-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nint N = 1;\nvoid foo() {} /* Necessary to trigger the original ICE.  */\nvoid bar (char a[2][N]) { a[1][0] = N; }\nint\nmain (void)\n{\n  void *x;\n\n  N = 4;\n  x = alloca (2 * N);\n  memset (x, 0, 2 * N);\n  bar (x);\n  if (N[(char *) x] != N)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22061-2.c",
    "content": "int *x;\nstatic void bar (char a[2][(*x)++]) {}\nint\nmain (void)\n{\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22061-3.c",
    "content": "void\nbar (int N)\n{\n  int foo (char a[2][++N]) { N += 4; return sizeof (a[0]); }\n  if (foo (0) != 2)\n    abort ();\n  if (foo (0) != 7)\n    abort ();\n  if (N != 11)\n    abort ();\n}\n\nint\nmain()\n{\n  bar (1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22061-4.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nvoid\nbar (int N)\n{\n  void foo (int a[2][N++]) {}\n  int a[2][N];\n  foo (a);\n  int b[2][N];\n  foo (b);\n  if (sizeof (a) != sizeof (int) * 2 * 1)\n    abort ();\n  if (sizeof (b) != sizeof (int) * 2 * 2)\n    abort ();\n  if (N != 3)\n    abort ();\n}\n\nint\nmain (void)\n{\n  bar (1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22098-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, 1, 2}[++a]);\n  if (a != 1 || *p != 1 || *(int *)b != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22098-2.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, 1, 2}[1]);\n  if (*p != 1 || *(int *)b != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22098-3.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint n = 0;\nint f (void) { return ++n; }\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, f(), 2}[1]);\n  if (*p != 1 || *(int *)b != 1 || n != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22348.c",
    "content": "void abort (void);\nvoid f(int i)\n{\n  if (i>4 + 3 * 16)\n    abort();\n}\n\nint main()\n{\n  unsigned int buflen, i;\n  buflen = 4 + 3 * 16;\n  for (i = 4; i < buflen; i+= 3)\n    f(i);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22429.c",
    "content": "extern void abort (void);\n\n#define N\t(1 << (sizeof(int) * __CHAR_BIT__ - 2))\n\nint f(int n)\n{\n  if (-N <= n && n <= N-1)\n    return 1;\n  return 0;\n}\n\nint main ()\n{\n  if (f (N))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22493-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\n#include <limits.h>\nextern void abort ();\nextern void exit (int);\nvoid f(int i)\n{\n  if (i>0)\n    abort();\n  i = -i;\n  if (i<0)\n    return;\n  abort ();\n}\n\nint main(int argc, char *argv[])\n{\n  f(INT_MIN);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr22630.c",
    "content": "void abort (void);\n\nint j;\n\nvoid bla (int *r)\n{\n  int *p, *q;\n\n  p = q = r;\n  if (!p)\n    p = &j;\n  \n  if (p != q)\n    j = 1;\n}\n\nint main (void)\n{\n  bla (0);\n  if (!j)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23047.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n#include <limits.h>\nextern void abort ();\nextern void exit (int);\nvoid f(int i)\n{\n  i = i > 0 ? i : -i;\n  if (i<0)\n    return;\n  abort ();\n}\n\nint main(int argc, char *argv[])\n{\n  f(INT_MIN);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23135.c",
    "content": "/* Based on execute/simd-1.c, modified by joern.rennecke@st.com to\n   trigger a reload bug.  Verified for gcc mainline from 20050722 13:00 UTC\n   for sh-elf -m4 -O2.  */\n/* { dg-options \"-Wno-psabi\" } */\n\n#ifndef STACK_SIZE\n#define STACK_SIZE (256*1024)\n#endif\n\nextern void abort (void);\nextern void exit (int);\n\ntypedef struct { char c[STACK_SIZE/2]; } big_t;\n\ntypedef int __attribute__((mode(SI))) __attribute__((vector_size (8))) vecint;\ntypedef int __attribute__((mode(SI))) siint;\n\nvecint i = { 150, 100 };\nvecint j = { 10, 13 };\nvecint k;\n\nunion {\n  vecint v;\n  siint i[2];\n} res;\n\nvoid\nverify (siint a1, siint a2, siint b1, siint b2, big_t big)\n{\n  if (a1 != b1\n      || a2 != b2)\n    abort ();\n}\n\nint\nmain ()\n{\n  big_t big;\n  vecint k0, k1, k2, k3, k4, k5, k6, k7;\n\n  k0 = i + j;\n  res.v = k0;\n\n  verify (res.i[0], res.i[1], 160, 113, big);\n\n  k1 = i * j;\n  res.v = k1;\n\n  verify (res.i[0], res.i[1], 1500, 1300, big);\n\n  k2 = i / j;\n/* This is the observed failure - reload 0 has the wrong type and thus the\n   conflict with reload 1 is missed:\n\n(insn:HI 94 92 96 1 pr23135.c:46 (parallel [\n            (set (subreg:SI (reg:DI 253) 0)\n                (div:SI (reg:SI 4 r4)\n                    (reg:SI 5 r5)))\n            (clobber (reg:SI 146 pr))\n            (clobber (reg:DF 64 fr0))\n            (clobber (reg:DF 66 fr2))\n            (use (reg:PSI 151 ))\n            (use (reg/f:SI 256))\n        ]) 60 {divsi3_i4} (insn_list:REG_DEP_TRUE 90 (insn_list:REG_DEP_TRUE 89\n(insn_list:REG_DEP_TRUE 42 (insn_list:REG_DEP_TRUE 83 (insn_list:REG_DEP_TRUE 92\n (insn_list:REG_DEP_TRUE 91 (nil)))))))\n    (expr_list:REG_DEAD (reg:SI 4 r4)\n        (expr_list:REG_DEAD (reg:SI 5 r5)\n            (expr_list:REG_UNUSED (reg:DF 66 fr2)\n                (expr_list:REG_UNUSED (reg:DF 64 fr0)\n                    (expr_list:REG_UNUSED (reg:SI 146 pr)\n                        (insn_list:REG_RETVAL 91 (nil))))))))\n\nReloads for insn # 94\nReload 0: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)\n                                                    (const_int 64 [0x40]))\n        GENERAL_REGS, RELOAD_FOR_OUTADDR_ADDRESS (opnum = 0)\n        reload_in_reg: (plus:SI (reg/f:SI 14 r14)\n                                                    (const_int 64 [0x40]))\n        reload_reg_rtx: (reg:SI 3 r3)\nReload 1: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, se\ncondary_reload_p\n        reload_reg_rtx: (reg:SI 3 r3)\nReload 2: reload_out (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)\n                                                            (const_int 64 [0x40]))\n                                                        (const_int 28 [0x1c])) [ 16 S8 A32])\n        FPUL_REGS, RELOAD_FOR_OUTPUT (opnum = 0)\n        reload_out_reg: (subreg:SI (reg:DI 253) 0)\n        reload_reg_rtx: (reg:SI 150 fpul)\n        secondary_out_reload = 1\n\nReload 3: reload_in (SI) = (symbol_ref:SI (\"__sdivsi3_i4\") [flags 0x1])\n        GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine\n        reload_in_reg: (reg/f:SI 256)\n        reload_reg_rtx: (reg:SI 3 r3)\n  */\n\n\n  res.v = k2;\n\n  verify (res.i[0], res.i[1], 15, 7, big);\n\n  k3 = i & j;\n  res.v = k3;\n\n  verify (res.i[0], res.i[1], 2, 4, big);\n\n  k4 = i | j;\n  res.v = k4;\n\n  verify (res.i[0], res.i[1], 158, 109, big);\n\n  k5 = i ^ j;\n  res.v = k5;\n\n  verify (res.i[0], res.i[1], 156, 105, big);\n\n  k6 = -i;\n  res.v = k6;\n  verify (res.i[0], res.i[1], -150, -100, big);\n\n  k7 = ~i;\n  res.v = k7;\n  verify (res.i[0], res.i[1], -151, -101, big);\n\n  k = k0 + k1 + k3 + k4 + k5 + k6 + k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 1675, 1430, big);\n\n  k = k0 * k1 * k3 * k4 * k5 * k6 * k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 1456467968, -1579586240, big);\n\n  k = k0 / k1 / k2 / k3 / k4 / k5 / k6 / k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 0, 0, big);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23324.c",
    "content": "extern void abort (void);\n#define A(x) if (!(x)) abort ()\n\nstatic union at6 {} vv6 = {};\nstatic struct et6\n{\n  struct bt6\n  {\n    signed av6:6;\n    signed bv6:7;\n    signed cv6:6;\n    signed dv6:5;\n    unsigned char ev6;\n    unsigned int fv6;\n    long int gv6;\n  } mv6;\n  unsigned long int nv6;\n  signed ov6:12;\n  signed pv6:3;\n  signed qv6:2;\n  signed rv6:10;\n  union ct6 { long int hv6; float iv6; float jv6; } sv6;\n  int *tv6;\n  union dt6 { double kv6; float lv6; } uv6;\n} wv6 = {\n  { 8, 9, 2, 4, '\\x10', 67426805U, 1047191860L },\n  1366022414UL, 858, 1, 1, 305,\n  { 1069379046L }, (int *) 358273621U,\n  { 3318.041978 }\n};\nstatic double xv6 = 19239.101269;\nstatic long long int yv6 = 1207859169L;\nstatic int zv6 = 660195606;\n\nstatic union at6\ncallee_af6 (struct et6 ap6, double bp6, long long int cp6, int dp6)\n{\n  A (wv6.mv6.av6 == ap6.mv6.av6);\n  A (wv6.mv6.bv6 == ap6.mv6.bv6);\n  A (wv6.mv6.cv6 == ap6.mv6.cv6);\n  A (wv6.mv6.dv6 == ap6.mv6.dv6);\n  A (wv6.mv6.ev6 == ap6.mv6.ev6);\n  A (wv6.mv6.fv6 == ap6.mv6.fv6);\n  A (wv6.mv6.gv6 == ap6.mv6.gv6);\n  A (wv6.nv6 == ap6.nv6);\n  A (wv6.ov6 == ap6.ov6);\n  A (wv6.pv6 == ap6.pv6);\n  A (wv6.qv6 == ap6.qv6);\n  A (wv6.rv6 == ap6.rv6);\n  A (wv6.sv6.hv6 == ap6.sv6.hv6);\n  A (wv6.tv6 == ap6.tv6);\n  A (wv6.uv6.kv6 == ap6.uv6.kv6);\n  A (xv6 == bp6);\n  A (yv6 == cp6);\n  A (zv6 == dp6);\n  return vv6;\n}\n\nstatic void\ncaller_bf6 (void)\n{\n  union at6 bav6;\n  bav6 = callee_af6 (wv6, xv6, yv6, zv6);\n}\n\nstatic unsigned char uv7 = '\\x46';\nstatic float vv7 = 96636.982442;\nstatic double wv7 = 28450.711801;\nstatic union ct7 {} xv7 = {};\nstatic struct et7\n{\n  struct dt7\n  {\n    float iv7;\n    unsigned short int jv7;\n  } kv7;\n  float lv7[0];\n  signed mv7:9;\n  short int nv7;\n  double ov7;\n  float pv7;\n} yv7 = {\n  { 30135.996213, 42435 },\n  {}, 170, 22116, 26479.628148, 4082.960685\n};\nstatic union ft7\n{\n  float qv7;\n  float *rv7;\n  unsigned int *sv7;\n} zv7 = { 5042.227886 };\nstatic int bav7 = 1345451862;\nstatic struct gt7 { double tv7; } bbv7 = { 47875.491954 };\nstatic long int bcv7[1] = { 1732133482L };\nstatic long long int bdv7 = 381678602L;\n\nstatic unsigned char\ncallee_af7 (float ap7, double bp7, union ct7 cp7, struct et7 dp7,\n            union ft7 ep7, int fp7, struct gt7 gp7, long int hp7[1],\n            long long int ip7)\n{\n  A (vv7 == ap7);\n  A (wv7 == bp7);\n  A (yv7.kv7.iv7 == dp7.kv7.iv7);\n  A (yv7.kv7.jv7 == dp7.kv7.jv7);\n  A (yv7.mv7 == dp7.mv7);\n  A (yv7.nv7 == dp7.nv7);\n  A (yv7.ov7 == dp7.ov7);\n  A (yv7.pv7 == dp7.pv7);\n  A (zv7.qv7 == ep7.qv7);\n  A (bav7 == fp7);\n  A (bbv7.tv7 == gp7.tv7);\n  A (bcv7[0] == hp7[0]);\n  A (bdv7 == ip7);\n  return uv7;\n}\n\nstatic void\ncaller_bf7 (void)\n{\n  unsigned char bev7;\n\n  bev7 = callee_af7 (vv7, wv7, xv7, yv7, zv7, bav7, bbv7, bcv7, bdv7);\n  A (uv7 == bev7);\n}\n\nint\nmain ()\n{\n  caller_bf6 ();\n  caller_bf7 ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23467.c",
    "content": "struct s1\n{\n  int __attribute__ ((aligned (8))) a;\n};\n\nstruct\n{\n  char c;\n  struct s1 m;\n} v;\n\nint\nmain (void)\n{\n  if ((int)&v.m & 7)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23604.c",
    "content": "extern void abort (void);\n\nint g(int i, int j)\n{\n  if (i>-1)\n    if (i<2)\n     {\n        if (i != j)\n          {\n            if (j != 0)\n                return 0;\n          }\n     }\n  return 1;\n}\n\nint main(void)\n{\n  if (!g(1, 0))\n   abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr23941.c",
    "content": "extern void abort (void);\ndouble d = __FLT_MIN__ / 2.0;\nint main()\n{\n  double x = __FLT_MIN__ / 2.0;\n  if (x != d)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr24135.c",
    "content": "#ifndef NO_TRAMPOLINES\nextern void abort (void);\n\nint x(int a, int b)\n{\n  __label__ xlab;\n  __label__ xlab2;\n\n  void y(int b)\n    {\n       switch (b)\n        {\n          case 1: goto xlab;\n          case 2: goto xlab;\n        }\n    }\n\n  a = a + 2;\n  y (b);\n\n xlab:\n  return a;\n\n xlab2:\n  a++;\n  return a;\n\n}\n\nint main ()\n{\n  int i, j;\n\n  for (j = 1; j <= 2; ++j)\n    for (i = 1; i <= 2; ++i)\n      {\n\tint a = x (j, i);\n\tif (a != 2 + j)\n\t  abort ();\n      }\n\n  return 0;\n}\n#else\nint main() { return 0; }\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr24141.c",
    "content": "// reduced testcase, compile with -O2. Also, with --disable-checking\n// gcc produces wrong code.\n\nvoid abort (void);\nint i;\n\nvoid g (void)\n{\n  i = 1;\n}\n\nvoid f (int a, int b)\n{\n  int c = 0;\n  if (a == 0)\n    c = 1;\n  if (c)\n    return;\n  if (c == 1)\n    c = 0;\n  if (b == 0)\n    c = 1;\n  if (c)\n    g ();\n}\n\nint main (void)\n{\n  f (1, 0);\n  if (i != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr24142.c",
    "content": "void abort (void);\n\nint f (int a, int b)\n{\n  if (a == 1)\n    a = 0;\n  if (b == 0)\n    a = 1;\n  if (a != 0)\n    return 0;\n  return 1;\n}\n\nint main (void)\n{\n  if (f (1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr24716.c",
    "content": "/* PR24716, scalar evolution returning the wrong result\n   for pdest.  */\n\nint Link[] = { -1 };\nint W[] = { 2 };\n\nextern void abort (void);\n\nint f (int k, int p)\n{\n  int pdest, j, D1361;\n  j = 0;\n  pdest = 0;\n  for (;;) {\n    if (pdest > 2)\n      do\n        j--, pdest++;\n      while (j > 2);\n\n    if (j == 1)\n      break;\n\n    while (pdest > p)\n      if (j == p)\n        pdest++;\n\n    do\n      {\n        D1361 = W[k];\n        do\n          if (D1361 != 0)\n            pdest = 1, W[k] = D1361 = 0;\n        while (p < 1);\n    } while (k > 0);\n\n    do\n      {\n        p = 0;\n        k = Link[k];\n        while (p < j)\n          if (k != -1)\n            pdest++, p++;\n      }\n    while (k != -1);\n    j = 1;\n  }\n\n  /* The correct return value should be pdest (1 in the call from main).\n     DOM3 is mistaken and propagates a 0 here.  */\n  return pdest;\n}\n\nint main ()\n{\n  if (!f (0, 2))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr24851.c",
    "content": "/* We used to handle pointer addition wrongly\n   at the time of recombining to an ARRAY_REF\n   in the case of\n     p + -4B\n   where -4B is represented as unsigned.  */\n\nvoid abort(void);\nint main()\n{\n  int a[10], *p, *q;\n  q = &a[1];\n  p = &q[-1];\n  if (p >= &a[9])\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr25125.c",
    "content": "extern void exit (int);\nextern void abort (void);\nextern unsigned short f (short a) __attribute__((__noinline__));\n\nunsigned short\nf (short a)\n{\n  short b;\n\n  if (a > 0)\n    return 0;\n  b = ((int) a) + - (int) 32768;\n  return b;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) < 2\n      || sizeof (short) >= sizeof (int))\n    exit (0);\n\n  if (f (-32767) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr25737.c",
    "content": "extern void abort (void);\n\nstruct delay_block {\n  struct delay_block *succ;\n};\n\nstatic struct delay_block Timer_Queue;\n\nstruct delay_block* time_enqueue (struct delay_block *d)\n{\n  struct delay_block *q = Timer_Queue.succ; \n  d->succ =  (void *)0;\n  return Timer_Queue.succ;\n}\n\nint main(void)\n{\n  Timer_Queue.succ = &Timer_Queue;\n  if (time_enqueue (&Timer_Queue) != (void*)0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr27073.c",
    "content": "void __attribute__((noinline))\nfoo (int *p, int d1, int d2, int d3,\n     short count, int s1, int s2, int s3, int s4, int s5)\n{\n  int n = count;\n  while (n--)\n    {\n      *p++ = s1;\n      *p++ = s2;\n      *p++ = s3;\n      *p++ = s4;\n      *p++ = s5;\n    }\n}\n\nint main()\n{\n  int x[10], i;\n\n  foo (x, 0, 0, 0, 2, 100, 200, 300, 400, 500);\n  for (i = 0; i < 10; i++)\n    if (x[i] != (i % 5 + 1) * 100)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr27260.c",
    "content": "/* PR middle-end/27260 */\n\nextern void abort (void);\nextern void *memset (void *, int, __SIZE_TYPE__);\n\nchar buf[65];\n\nvoid\nfoo (int x)\n{\n  memset (buf, x != 2 ? 1 : 0, 64);\n}\n\nint\nmain (void)\n{\n  int i;\n  buf[64] = 2;\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 0)\n      abort ();\n  foo (0);\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 1)\n      abort ();\n  foo (2);\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 0)\n      abort ();\n  if (buf[64] != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr27285.c",
    "content": "/* PR tree-optimization/27285 */\n\nextern void abort (void);\n\nstruct S { unsigned char a, b, c, d[16]; };\n\nvoid __attribute__ ((noinline))\nfoo (struct S *x, struct S *y)\n{\n  int a, b;\n  unsigned char c, *d, *e;\n\n  b = x->b;\n  d = x->d;\n  e = y->d;\n  a = 0;\n  while (b)\n    {\n      if (b >= 8)\n\t{\n\t  c = 0xff;\n\t  b -= 8;\n\t}\n      else\n\t{\n\t  c = 0xff << (8 - b);\n\t  b = 0;\n\t}\n\n      e[a] = d[a] & c;\n      a++;\n    }\n}\n\nint\nmain (void)\n{\n  struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};\n  struct S y = { 0, 0, 0, { 0 }};\n\n  foo (&x, &y);\n  if (x.d[0] != y.d[0] || x.d[1] != y.d[1]\n      || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])\n    abort ();\n   return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr27364.c",
    "content": "int f(unsigned number_of_digits_to_use)\n{\n  if (number_of_digits_to_use >1294)\n    return 0;\n  return (number_of_digits_to_use * 3321928 / 1000000 + 1) /16;\n}\n\nint main(void)\n{\n  if (f(11) != 2)\n    __builtin_abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c",
    "content": "/* PR rtl-optimization/27671.\n   The combiner used to simplify \"a ^ b == a\" to \"a\" via\n   simplify_relational_operation_1 in simplify-rtx.c.  */\n\nextern void abort (void) __attribute__ ((noreturn));\nextern void exit (int) __attribute__ ((noreturn));\n\nstatic int __attribute__((noinline))\nfoo (int a, int b)\n{\n  int c = a ^ b;\n  if (c == a)\n    abort ();\n}\n\nint\nmain (void)\n{\n  foo (0, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28289.c",
    "content": "extern int ok (int);\nextern void exit ();\nstatic int gen_x86_64_shrd (int);\nstatic int\ngen_x86_64_shrd(int a __attribute__ ((__unused__)))\n{\n  return 0;\n}\n\nextern int gen_x86_shrd_1 (int);\nextern void ix86_split_ashr (int);\n\nvoid\nix86_split_ashr (int mode)\n{\n          (mode != 0\n                      ? ok\n                      : gen_x86_64_shrd) (0);\n}\n\nvolatile int one = 1;\nint\nmain (void)\n{\n  ix86_split_ashr (one);\n  return 1;\n}\n\nint\nok (int i)\n{\n  exit (i);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28403.c",
    "content": "typedef unsigned long long ull;\nint global;\n\nint __attribute__((noinline))\nfoo (int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8)\n{\n  global = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8;\n}\n\null __attribute__((noinline))\nbar (ull x)\n{\n  foo (1, 2, 1, 3, 1, 4, 1, 5);\n  return x >> global;\n}\n\nint\nmain (void)\n{\n  if (bar (0x123456789abcdefULL) != (0x123456789abcdefULL >> 18))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28651.c",
    "content": "#include <limits.h>\n\nextern void abort (void);\nint __attribute__((noinline))\nfoo (unsigned int u)\n{\n  return (int)(u + 4) < (int)u;\n}\n\nint\nmain (int argc, char *argv[])\n{\n  unsigned int u = INT_MAX;\n\n  if (foo (u) == 0)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28778.c",
    "content": "extern void abort(void);\ntypedef long GLint;\nvoid aglChoosePixelFormat (const GLint *);\n\nvoid\nfind (const int *alistp)\n{\n  const int *blist;\n  int list[32];\n  if (alistp)\n    blist = alistp;\n  else\n    {\n      list[3] = 42;\n      blist = list;\n    }\n  aglChoosePixelFormat ((GLint *) blist);\n}\n\nvoid\naglChoosePixelFormat (const GLint * a)\n{\n  int *b = (int *) a;\n  if (b[3] != 42)\n    abort ();\n}\n\nint\nmain (void)\n{\n  find (0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28865.c",
    "content": "struct A { int a; char b[]; };\nunion B { struct A a; char b[sizeof (struct A) + 31]; };\nunion B b = { { 1, \"123456789012345678901234567890\" } };\nunion B c = { { 2, \"123456789012345678901234567890\" } };\n\n__attribute__((noinline, noclone)) void\nfoo (int *x[2])\n{\n  x[0] = &b.a.a;\n  x[1] = &c.a.a;\n}\n\nint\nmain ()\n{\n  int *x[2];\n  foo (x);\n  if (*x[0] != 1 || *x[1] != 2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28982a.c",
    "content": "/* PR rtl-optimization/28982.  Function foo() does the equivalent of:\n\n     float tmp_results[NVARS];\n     for (int i = 0; i < NVARS; i++)\n       {\n\t int inc = incs[i];\n\t float *ptr = ptrs[i], result = 0;\n\t for (int j = 0; j < n; j++)\n\t   result += *ptr, ptr += inc;\n\t tmp_results[i] = result;\n       }\n     memcpy (results, tmp_results, sizeof (results));\n\n   but without the outermost loop.  The idea is to create high register\n   pressure and ensure that some INC and PTR variables are spilled.\n\n   On ARM targets, sequences like \"result += *ptr, ptr += inc\" can\n   usually be implemented using (mem (post_modify ...)), and we do\n   indeed create such MEMs before reload for this testcase.  However,\n   (post_modify ...) is not a valid address for coprocessor loads, so\n   for -mfloat-abi=softfp, reload reloads the POST_MODIFY into a base\n   register.  GCC did not deal correctly with cases where the base and\n   index of the POST_MODIFY are themselves reloaded.  */\n#define NITER 4\n#define NVARS 20\n#define MULTI(X) \\\n  X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \\\n  X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)\n\n#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]\n#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0\n#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX\n#define COPYOUT(INDEX) results[INDEX] = result##INDEX\n\nfloat *ptrs[NVARS];\nfloat results[NVARS];\nint incs[NVARS];\n\nvoid __attribute__((noinline))\nfoo (int n)\n{\n  int MULTI (DECLAREI);\n  float MULTI (DECLAREF);\n  while (n--)\n    MULTI (LOOP);\n  MULTI (COPYOUT);\n}\n\nfloat input[NITER * NVARS];\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NVARS; i++)\n    ptrs[i] = input + i, incs[i] = i;\n  for (i = 0; i < NITER * NVARS; i++)\n    input[i] = i;\n  foo (NITER);\n  for (i = 0; i < NVARS; i++)\n    if (results[i] != i * NITER * (NITER + 1) / 2)\n      return 1;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr28982b.c",
    "content": "/* Like pr28982a.c, but with the spill slots outside the range of\n   a single sp-based load on ARM.  This test tests for cases where\n   the addresses in the base and index reloads require further reloads.  */\n#if defined(STACK_SIZE) && STACK_SIZE <= 0x80100\nint main (void) { return 0; }\n#else\n#define NITER 4\n#define NVARS 20\n#define MULTI(X) \\\n  X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \\\n  X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)\n\n#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]\n#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0\n#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX\n#define COPYOUT(INDEX) results[INDEX] = result##INDEX\n\nfloat *ptrs[NVARS];\nfloat results[NVARS];\nint incs[NVARS];\n\nstruct big { int i[0x10000]; };\nvoid __attribute__((noinline))\nbar (struct big b)\n{\n  incs[0] += b.i[0];\n}\n\nvoid __attribute__((noinline))\nfoo (int n)\n{\n  struct big b = {};\n  int MULTI (DECLAREI);\n  float MULTI (DECLAREF);\n  while (n--)\n    MULTI (LOOP);\n  MULTI (COPYOUT);\n  bar (b);\n}\n\nfloat input[NITER * NVARS];\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NVARS; i++)\n    ptrs[i] = input + i, incs[i] = i;\n  for (i = 0; i < NITER * NVARS; i++)\n    input[i] = i;\n  foo (NITER);\n  for (i = 0; i < NVARS; i++)\n    if (results[i] != i * NITER * (NITER + 1) / 2)\n      return 1;\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29006.c",
    "content": "struct __attribute__((__packed__)) s { char c; unsigned long long x; };\nvoid __attribute__((__noinline__)) foo (struct s *s) { s->x = 0; }\nint main (void) { struct s s = { 1, ~0ULL }; foo (&s); return s.x != 0; }\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29156.c",
    "content": "extern void abort(void);\nstruct test1\n{\n  int a;\n  int b;\n};\nstruct test2\n{\n  float d;\n  struct test1 sub;\n};\n\nint global;\n\nint bla(struct test1 *xa, struct test2 *xb)\n{\n  global = 1;\n  xb->sub.a = 1;\n  xa->a = 8;\n  return xb->sub.a;\n}\n\nint main(void)\n{\n  struct test2 pom;\n\n  if (bla (&pom.sub, &pom) != 8)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29695-1.c",
    "content": "/* PR middle-end/29695 */\n\nextern void abort (void);\n\nint\nf1 (void)\n{\n  int a = 128;\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf2 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf3 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? 0x380 : 0;\n}\n\nint\nf4 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? -128 : 0;\n}\n\nlong long\nf5 (void)\n{\n  long long a = 0x80000000LL;\n  return (a & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf6 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf7 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? 0x380000000LL : 0LL;\n}\n\nlong long\nf8 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? -2147483648LL : 0LL;\n}\n\nint\nmain (void)\n{\n  if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)\n    return 0;\n  if (f1 () != 128)\n    abort ();\n  if (f2 () != 128)\n    abort ();\n  if (f3 () != 896)\n    abort ();\n  if (f4 () != -128)\n    abort ();\n  if (f5 () != 0x80000000LL)\n    abort ();\n  if (f6 () != 0x80000000LL)\n    abort ();\n  if (f7 () != 0x380000000LL)\n    abort ();\n  if (f8 () != -2147483648LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29695-2.c",
    "content": "/* PR middle-end/29695 */\n\nextern void abort (void);\n\nint a = 128;\nunsigned char b = 128;\nlong long c = 0x80000000LL;\nunsigned int d = 0x80000000;\n\nint\nf1 (void)\n{\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf2 (void)\n{\n  return (b & 0x80) ? 0x80 : 0;\n}\n\nint\nf3 (void)\n{\n  return (b & 0x80) ? 0x380 : 0;\n}\n\nint\nf4 (void)\n{\n  return (b & 0x80) ? -128 : 0;\n}\n\nlong long\nf5 (void)\n{\n  return (c & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf6 (void)\n{\n  return (d & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf7 (void)\n{\n  return (d & 0x80000000) ? 0x380000000LL : 0LL;\n}\n\nlong long\nf8 (void)\n{\n  return (d & 0x80000000) ? -2147483648LL : 0LL;\n}\n\nint\nmain (void)\n{\n  if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)\n    return 0;\n  if (f1 () != 128)\n    abort ();\n  if (f2 () != 128)\n    abort ();\n  if (f3 () != 896)\n    abort ();\n  if (f4 () != -128)\n    abort ();\n  if (f5 () != 0x80000000LL)\n    abort ();\n  if (f6 () != 0x80000000LL)\n    abort ();\n  if (f7 () != 0x380000000LL)\n    abort ();\n  if (f8 () != -2147483648LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29797-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort(void);\n\nunsigned int bar(void) { return 32768; }\n\nint main()\n{\n  unsigned int nStyle = bar ();\n  if (nStyle & 32768)\n    nStyle |= 65536;\n  if (nStyle != (32768 | 65536))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29797-2.c",
    "content": "extern void abort(void);\n\nunsigned long bar(void) { return 32768; }\n\nint main()\n{\n  unsigned long nStyle = bar ();\n  if (nStyle & 32768)\n    nStyle |= 65536;\n  if (nStyle != (32768 | 65536))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr29798.c",
    "content": "extern void abort ();\n\nint\nmain ()\n{\n  int i;\n  double oldrho;\n  double beta = 0.0;\n  double work = 1.0;\n  for (i = 1; i <= 2; i++)\n    {\n      double rho = work * work;\n      if (i != 1)\n        beta = rho / oldrho;\n      if (beta == 1.0)\n        abort ();\n\n      /* All targets even remotely likely to ever get supported\n\t use at least an even base, so there will never be any\n\t floating-point rounding. All computation in this test\n\t case is exact for even bases.  */\n      work /= 2.0;\n      oldrho = rho;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr30185.c",
    "content": "/* PR target/30185 */\n\nextern void abort (void);\n\ntypedef struct S { char a; long long b; } S;\n\nS\nfoo (S x, S y)\n{\n  S z;\n  z.b = x.b / y.b;\n  return z;\n}\n\nint\nmain (void)\n{\n  S a, b;\n  a.b = 32LL;\n  b.b = 4LL;\n  if (foo (a, b).b != 8LL)\n    abort ();\n  a.b = -8LL;\n  b.b = -2LL;\n  if (foo (a, b).b != 4LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr30778.c",
    "content": "extern void *memset (void *, int, unsigned long);\nextern void abort (void);\n\nstruct reg_stat {\n  void *last_death;\n  void *last_set;\n  void *last_set_value;\n  int   last_set_label;\n  char  last_set_sign_bit_copies;\n  int   last_set_mode : 8;\n  char  last_set_invalid;\n  char sign_bit_copies;\n  long nonzero_bits;\n};\n\nstatic struct reg_stat *reg_stat;\n\nvoid __attribute__((noinline))\ninit_reg_last (void)\n{\n  memset (reg_stat, 0, __builtin_offsetof (struct reg_stat, sign_bit_copies));\n}\n\nint main (void)\n{\n  struct reg_stat r;\n\n  reg_stat = &r;\n  r.nonzero_bits = -1;\n  init_reg_last ();\n  if (r.nonzero_bits != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31072.c",
    "content": "extern volatile int ReadyFlag_NotProperlyInitialized;\n\nvolatile int ReadyFlag_NotProperlyInitialized=1;\n\nint main(void)\n{\n  if (ReadyFlag_NotProperlyInitialized != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31136.c",
    "content": "extern void abort (void);\n\nstruct S {\n  unsigned b4:4;\n  unsigned b6:6;\n} s;\n\nint main()\n{\n  s.b6 = 31;\n  s.b4 = s.b6;\n  s.b6 = s.b4;\n  if (s.b6 != 15)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31169.c",
    "content": "extern void abort();\n\n#define HOST_WIDE_INT long\n#define HOST_BITS_PER_WIDE_INT (sizeof(long)*8)\n\nstruct tree_type\n{\n  unsigned int precision : 9;\n};\n\nint\nsign_bit_p (struct tree_type *t, HOST_WIDE_INT val_hi, unsigned HOST_WIDE_INT val_lo)\n{\n  unsigned HOST_WIDE_INT mask_lo, lo;\n  HOST_WIDE_INT mask_hi, hi;\n  int width = t->precision;\n\n  if (width > HOST_BITS_PER_WIDE_INT)\n    {\n      hi = (unsigned HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT - 1);\n      lo = 0;\n\n      mask_hi = ((unsigned HOST_WIDE_INT) -1\n                 >> (2 * HOST_BITS_PER_WIDE_INT - width));\n      mask_lo = -1;\n    }\n  else\n    {\n      hi = 0;\n      lo = (unsigned HOST_WIDE_INT) 1 << (width - 1);\n    \n      mask_hi = 0;\n      mask_lo = ((unsigned HOST_WIDE_INT) -1\n                 >> (HOST_BITS_PER_WIDE_INT - width));\n    }\n\n  if ((val_hi & mask_hi) == hi\n      && (val_lo & mask_lo) == lo)\n    return 1;\n\n  return 0;\n}\n\nint main()\n{\n  struct tree_type t;\n  t.precision = 1;\n  if (!sign_bit_p (&t, 0, -1))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31448-2.c",
    "content": "/* PR middle-end/31448, this used to ICE during expand because\n   reduce_to_bit_field_precision was not ready to handle constants. */\n\ntypedef struct _st {\n    long int iIndex : 24;\n    long int iIndex1 : 24;\n} st;\nst *next;\nvoid g(void)\n{\n    st *next = 0;\n    int nIndx;\n    const static int constreg[] = { 0,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n}\nvoid f(void)\n{\n    int nIndx;\n    const static long int constreg[] = { 0xFEFEFEFE,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n    next->iIndex1 = constreg[nIndx];\n}\nint main(void)\n{\n  st a;\n  next = &a;\n  f();\n  if (next->iIndex != 0xFFFEFEFE)\n    __builtin_abort ();\n  if (next->iIndex1 != 0xFFFEFEFE)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31448.c",
    "content": "/* PR middle-end/31448, this used to ICE during expand because\n   reduce_to_bit_field_precision was not ready to handle constants. */\n/* { dg-require-effective-target int32plus } */\n\ntypedef struct _st {\n    int iIndex : 24;\n    int iIndex1 : 24;\n} st;\nst *next;\nvoid g(void)\n{\n    st *next = 0;\n    int nIndx;\n    const static int constreg[] = { 0,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n}\nvoid f(void)\n{\n    int nIndx;\n    const static int constreg[] = { 0xFEFEFEFE,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n    next->iIndex1 = constreg[nIndx];\n}\nint main(void)\n{\n  st a;\n  next = &a;\n  f();\n  if (next->iIndex != 0xFFFEFEFE)\n    __builtin_abort ();\n  if (next->iIndex1 != 0xFFFEFEFE)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr31605.c",
    "content": "void put_field (unsigned int start, unsigned int len)\n{\n  int cur_bitshift = ((start + len) % 8) - 8;\n  if (cur_bitshift > -8)\n    exit (0);\n}\n\nint\nmain ()\n{\n  put_field (0, 1);\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr32244-1.c",
    "content": "struct foo\n{\n  unsigned long long b:40;\n} x;\n\nextern void abort (void);\n\nvoid test1(unsigned long long res)\n{\n  /* The shift is carried out in 40 bit precision.  */\n  if (x.b<<32 != res)\n    abort ();\n}\n\nint main()\n{\n  x.b = 0x0100;\n  test1(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr32500.c",
    "content": "extern void abort(void);\nextern void exit(int);\nvoid foo(int) __attribute__((noinline));\nvoid bar(void) __attribute__((noinline));\n\n/* Make sure foo is not inlined or considered pure/const.  */\nint x;\nvoid foo(int i) { x = i; }\nvoid bar(void) { exit(0); }\n\nint\nmain(int argc, char *argv[])\n{\n\tint i;\n\tint numbers[4] = { 0xdead, 0xbeef, 0x1337, 0x4242 };\n\n\tfor (i = 1; i <= 12; i++) {\n\t\tif (i <= 4)\n\t\t\tfoo(numbers[i-1]);\n\t\telse if (i >= 7 && i <= 9)\n\t\t\tbar();\n\t}\n\n\tabort();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33142.c",
    "content": "int abs(int j);\nextern void abort(void);\n\n__attribute__((noinline)) int lisp_atan2(long dy, long dx) {\n    if (dx <= 0)\n        if (dy > 0)\n            return abs(dx) <= abs(dy);\n    return 0;\n}\n\nint main() {   \n    volatile long dy = 63, dx = -77;\n    if (lisp_atan2(dy, dx))\n        abort();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33382.c",
    "content": "struct Foo {\n  int i;\n  int j[];\n};\n\nstruct Foo x = { 1, { 2, 0, 2, 3 } };\n\nint foo(void)\n{\n  x.j[0] = 1;\n  return x.j[1];\n}\n\nextern void abort(void);\n\nint main()\n{\n  if (foo() != 0)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33631.c",
    "content": "typedef union\n{\n  int __lock;\n} pthread_mutex_t;\n\nextern void abort (void);\n\nint main()\n{\n    struct { int c; pthread_mutex_t m; } r = { .m = 0 };\n    if (r.c != 0)\n      abort ();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33669.c",
    "content": "extern void abort (void);\n\ntypedef struct foo_t\n{ \n  unsigned int blksz;\n  unsigned int bf_cnt; \n} foo_t;\n\n#define _RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) * (unit))\n#define _RNDDOWN(x, unit)  ((x) - ((x)%(unit)))\n\nlong long\nfoo (foo_t *const pxp,  long long offset, unsigned int extent)\n{\n  long long blkoffset = _RNDDOWN(offset, (long long )pxp->blksz);\n  unsigned int diff = (unsigned int)(offset - blkoffset);\n  unsigned int blkextent = _RNDUP(diff + extent, pxp->blksz);\n\n  if (pxp->blksz < blkextent)\n    return -1LL;\n\n  if (pxp->bf_cnt > pxp->blksz)\n    pxp->bf_cnt = pxp->blksz;\n\n  return blkoffset;\n}\n\nint\nmain ()\n{\n  foo_t x;\n  long long xx;\n\n  x.blksz = 8192;\n  x.bf_cnt = 0;\n  xx = foo (&x, 0, 4096);\n  if (xx != 0LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33779-1.c",
    "content": "int foo(int i)\n{\n  if (((unsigned)(i + 1)) * 4 == 0)\n    return 1;\n  return 0;\n}\n\nextern void abort(void);\nint main()\n{\n  if (foo(0x3fffffff) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33779-2.c",
    "content": "int foo(int i)\n{\n  return ((int)((unsigned)(i + 1) * 4)) / 4;\n}\n\nextern void abort(void);\nint main()\n{\n  if (foo(0x3fffffff) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33870-1.c",
    "content": "extern void abort (void);\n\ntypedef struct PgHdr PgHdr;\ntypedef unsigned char u8;\nstruct PgHdr {\nint y;\nstruct {\n unsigned int pgno;\n PgHdr *pNextHash, *pPrevHash;\n PgHdr *pNextFree, *pPrevFree;\n PgHdr *pNextAll;\n u8 inJournal;\n short int nRef;\n PgHdr *pDirty, *pPrevDirty;\n unsigned int notUsed;\n} x;\n};\nPgHdr **xx;\nvolatile int vx;\nstatic inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)\n{\n PgHdr result;\n PgHdr *pTail;\n xx = &result.x.pDirty;\n pTail = &result;\n while( pA && pB ){\n   if( pA->x.pgno<pB->x.pgno ){\n     pTail->x.pDirty = pA;\n     pTail = pA;\n     pA = pA->x.pDirty;\n   }else{\n     pTail->x.pDirty = pB;\n     pTail = pB;\n     pB = pB->x.pDirty;\n   }\n   vx = (*xx)->y;\n }\n if( pA ){\n   pTail->x.pDirty = pA;\n }else if( pB ){\n   pTail->x.pDirty = pB;\n }else{\n   pTail->x.pDirty = 0;\n }\n return result.x.pDirty;\n}\n\nPgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)\n{\n PgHdr *a[25], *p;\n int i;\n __builtin_memset (a, 0, sizeof (a));\n while( pIn ){\n   p = pIn;\n   pIn = p->x.pDirty;\n   p->x.pDirty = 0;\n   for(i=0; i<25 -1; i++){\n     if( a[i]==0 ){\n       a[i] = p;\n       break;\n     }else{\n       p = merge_pagelist(a[i], p);\n       a[i] = 0;\n       a[i] = 0;\n     }\n   }\n   if( i==25 -1 ){\n     a[i] = merge_pagelist(a[i], p);\n   }\n }\n p = a[0];\n for(i=1; i<25; i++){\n   p = merge_pagelist (p, a[i]);\n }\n return p;\n}\n\nint main()\n{\n PgHdr a[5];\n PgHdr *p;\n a[0].x.pgno = 5;\n a[0].x.pDirty = &a[1];\n a[1].x.pgno = 4;\n a[1].x.pDirty = &a[2];\n a[2].x.pgno = 1;\n a[2].x.pDirty = &a[3];\n a[3].x.pgno = 3;\n a[3].x.pDirty = 0;\n p = sort_pagelist (&a[0]);\n if (p->x.pDirty == p)\n   abort ();\n return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33870.c",
    "content": "extern void abort (void);\n\ntypedef struct PgHdr PgHdr;\ntypedef unsigned char u8;\nstruct PgHdr {\n  unsigned int pgno;\n  PgHdr *pNextHash, *pPrevHash;\n  PgHdr *pNextFree, *pPrevFree;\n  PgHdr *pNextAll;\n  u8 inJournal;\n  short int nRef;\n  PgHdr *pDirty, *pPrevDirty;\n  unsigned int notUsed;\n};\n\nstatic inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)\n{\n  PgHdr result;\n  PgHdr *pTail;\n  pTail = &result;\n  while( pA && pB ){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n    }\n  }\n  if( pA ){\n    pTail->pDirty = pA;\n  }else if( pB ){\n    pTail->pDirty = pB;\n  }else{\n    pTail->pDirty = 0;\n  }\n  return result.pDirty;\n}\n\nPgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)\n{\n  PgHdr *a[25], *p;\n  int i;\n  __builtin_memset (a, 0, sizeof (a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; i<25 -1; i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = merge_pagelist(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( i==25 -1 ){\n      a[i] = merge_pagelist(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<25; i++){\n    p = merge_pagelist (p, a[i]);\n  }\n  return p;\n}\n\nint main()\n{\n  PgHdr a[5];\n  PgHdr *p;\n  a[0].pgno = 5;\n  a[0].pDirty = &a[1];\n  a[1].pgno = 4;\n  a[1].pDirty = &a[2];\n  a[2].pgno = 1;\n  a[2].pDirty = &a[3];\n  a[3].pgno = 3;\n  a[3].pDirty = 0;\n  p = sort_pagelist (&a[0]);\n  if (p->pDirty == p)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr33992.c",
    "content": "extern void abort ();\n\nvoid __attribute__((noinline))\nbar (unsigned long long i)\n{\n  if (i)\n    abort ();\n}\n\nstatic void __attribute__((always_inline))\nfoo (unsigned long long *r)\n{\n  int i;\n\n  for (i = 0; ; i++)\n    if (*r & ((unsigned long long)1 << (63 - i)))\n      break;\n\n  bar (i);\n}\n\nvoid __attribute__((noinline))\ndo_test (unsigned long long *r)\n{\n  int i;\n\n  for (i = 0; i < 2; ++i)\n    foo (r);\n}\n\nint main()\n{\n  unsigned long long r = 0x8000000000000001ull;\n\n  do_test (&r);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34070-1.c",
    "content": "extern void abort (void);\n\nint f(unsigned int x)\n{\n    return ((int)x) % 4;\n}\n\nint main()\n{\n  if (f(-1) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34070-2.c",
    "content": "extern void abort (void);\n\nint f(unsigned int x, int n)\n{\n    return ((int)x) / (1 << n);\n}\n\nint main()\n{\n  if (f(-1, 1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34099-2.c",
    "content": "int test1 (int b, int c)\n{\n  char x;\n  if (b)\n    return x / c;\n  else\n    return 1;\n}\nint test2 (int b, int c)\n{\n  int x;\n  if (b)\n    return x * c;\n  else\n    return 1;\n}\nint test3 (int b, int c)\n{\n  int x;\n  if (b)\n    return x % c;\n  else\n    return 1;\n}\nint test4 (int b, int c)\n{\n  char x;\n  if (b)\n    return x == c;\n  else\n    return 1;\n}\n\nextern void abort (void);\nint main()\n{\n  if (test1(1, 1000) != 0)\n    abort ();\n  if (test2(1, 0) != 0)\n    abort ();\n  if (test3(1, 1) != 0)\n    abort ();\n  if (test4(1, 1000) != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34099.c",
    "content": "int foo (int b, int c)\n{\n  int x;\n  if (b)\n    return x & c;\n  else\n    return 1;\n}\nextern void abort (void);\nint main()\n{\n  if (foo(1, 0) != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34130.c",
    "content": "extern void abort (void);\nint foo (int i)\n{\n  return -2 * __builtin_abs(i - 2);\n}\nint main()\n{\n  if (foo(1) != -2\n      || foo(3) != -2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34154.c",
    "content": "int foo( unsigned long long aLL )\n{\n    switch( aLL )\n    {\n        case 1000000000000000000ULL ... 9999999999999999999ULL : return 19 ; \n        default                                 : return 20 ;\n    };\n};\nextern void abort (void);\nint main()\n{\n    unsigned long long aLL = 1000000000000000000ULL;\n    if (foo (aLL) != 19)\n\tabort ();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34176.c",
    "content": "\ntypedef __SIZE_TYPE__ size_t;\ntypedef unsigned int index_ty;\ntypedef index_ty *index_list_ty;\n\nstruct mult_index\n{\n  index_ty index;\n  unsigned int count;\n};\n\nstruct mult_index_list\n{\n  struct mult_index *item;\n  size_t nitems;\n  size_t nitems_max;\n\n  struct mult_index *item2;\n  size_t nitems2_max;\n};\n\nint __attribute__((noinline))\nhash_find_entry (size_t *result)\n{\n    *result = 2;\n    return 0;\n}\n\nextern void abort (void);\nstruct mult_index * __attribute__((noinline))\nfoo (size_t n)\n{\n  static count = 0;\n  if (count++ > 0)\n    abort ();\n  return 0;\n}\n\nint\nmain (void)\n{\n    size_t nitems = 0;\n\n    for (;;)\n    {\n        size_t list;\n\n        hash_find_entry (&list);\n        {\n            size_t len2 = list;\n            struct mult_index *destptr;\n            struct mult_index *dest;\n            size_t new_max  = nitems + len2;\n\n            if (new_max != len2)\n                break;\n            dest = foo (new_max);\n\n            destptr = dest;\n            while (len2--)\n                destptr++;\n\n            nitems = destptr - dest;\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34415.c",
    "content": "const char *__attribute__((noinline))\nfoo (const char *p)\n{\n  const char *end;\n  int len = 1;\n  for (;;)\n    {\n      int c = *p;\n      c = (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);\n      if (c == 'B')\n\tend = p;\n      else if (c == 'A')\n\t{\n\t  end = p;\n\t  do\n\t    p++;\n\t  while (*p == '+');\n\t}\n      else\n\tbreak;\n      p++;\n      len++;\n    }\n  if (len > 2 && *p == ':')\n    p = end;\n  return p;\n}\n\nint\nmain (void)\n{\n  const char *input = \"Bbb:\";\n  return foo (input) != input + 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34456.c",
    "content": "/* { dg-skip-if \"requires qsort\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdlib.h>\n\nint __attribute__ ((noinline)) debug (void) { return 1; }\nint errors;\n\nstruct s { int elt; int (*compare) (int); };\n\nstatic int\ncompare (const void *x, const void *y)\n{\n  const struct s *s1 = x, *s2 = y;\n  int (*compare1) (int);\n  int elt2;\n\n  compare1 = s1->compare;\n  elt2 = s2->elt;\n  if (elt2 != 0 && debug () && compare1 (s1->elt) != 0)\n    errors++;\n  return compare1 (elt2);\n}\n\nint bad_compare (int x) { return -x; }\nstruct s array[2] = { { 1, bad_compare }, { -1, bad_compare } };\n\nint\nmain (void)\n{\n  qsort (array, 2, sizeof (struct s), compare);\n  return errors == 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34768-1.c",
    "content": "int x;\n\nvoid __attribute__((noinline)) foo (void)\n{\n  x = -x;\n}\nvoid __attribute__((const,noinline)) bar (void)\n{\n}\n\nint __attribute__((noinline))\ntest (int c)\n{\n  int tmp = x;\n  (c ? foo : bar) ();\n  return tmp + x;\n}\n\nextern void abort (void);\nint main()\n{\n  x = 1;\n  if (test (1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34768-2.c",
    "content": "int x;\n\nint __attribute__((noinline)) foo (void)\n{\n  x = -x;\n  return 0;\n}\nint __attribute__((const,noinline)) bar (void)\n{\n  return 0;\n}\n\nint __attribute__((noinline))\ntest (int c)\n{\n  int tmp = x;\n  int res = (c ? foo : bar) ();\n  return tmp + x + res;\n}\n\nextern void abort (void);\nint main()\n{\n  x = 1;\n  if (test (1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34971.c",
    "content": "struct foo\n{\n  unsigned long long b:40;\n} x;\n\nextern void abort (void);\n\nvoid test1(unsigned long long res)\n{\n  /* Build a rotate expression on a 40 bit argument.  */\n  if ((x.b<<8) + (x.b>>32) != res)\n    abort ();\n}\n\nint main()\n{\n  x.b = 0x0100000001;\n  test1(0x0000000101);\n  x.b = 0x0100000000;\n  test1(0x0000000001);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr34982.c",
    "content": "extern void abort (void);\n\nstatic void something();\n\nint main()\n{\n  something(-1);\n  return 0;\n}\n\nstatic void something(int i)\n{\n  if (i != -1)\n    abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35163.c",
    "content": "extern void abort(void);\n\nint main()\n{\n  signed char a = -30;\n  signed char b = -31;\n  #if(__SIZEOF_INT__ >= 4)\n  if (a > (unsigned short)b)\n#else\n  if ((long) a > (unsigned short)b)\n#endif\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35231.c",
    "content": "extern void abort(void);\n\nint __attribute__((noinline))\nfoo(int bits_per_pixel, int depth)\n{\n  if ((bits_per_pixel | depth) == 1)\n    abort ();\n  return bits_per_pixel;\n}\n\nint main()\n{\n  if (foo(2, 0) != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35390.c",
    "content": "extern void abort (void);\n\nunsigned int foo (int n)\n{\n  return ~((unsigned int)~n);\n}\n\nint main()\n{\n  if (foo(0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35456.c",
    "content": "/* { dg-skip-if \"signed zero not supported\" { \"vax-*-*\" } { \"*\" } { \"\" } } */\nextern void abort (void);\n\ndouble\n__attribute__ ((noinline))\nnot_fabs (double x)\n{\n  return x >= 0.0 ? x : -x;\n}\n\nint main()\n{\n  double x = -0.0;\n  double y;\n\n  y = not_fabs (x);\n\n  if (!__builtin_signbit (y))\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35472.c",
    "content": "extern void abort (void);\nextern void *memset (void *s, int c, __SIZE_TYPE__ n);\nstruct S { int i[16]; };\nstruct S *p;\nvoid __attribute__((noinline,noclone))\nfoo(struct S *a, struct S *b) { a->i[0] = -1; p = b; }\nvoid test (void)\n{\n  struct S a, b;\n  memset (&a.i[0], '\\0', sizeof (a.i));\n  memset (&b.i[0], '\\0', sizeof (b.i));\n  foo (&a, &b);\n  *p = a;\n  *p = b;\n  if (b.i[0] != -1)\n    abort ();\n}\nint main()\n{\n  test();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr35800.c",
    "content": "extern void abort (void);\n\nint stab_xcoff_builtin_type (int typenum)\n{\n  const char *name;\n  if (typenum >= 0 || typenum < -34)\n    {\n      return 0;\n    }\n  switch (-typenum)\n    {\n    case 1:\n      name = \"int\";\n      break;\n    case 2:\n      name = \"char\";\n    case 3:\n      name = \"short\";\n      break;\n    case 4:\n      name = \"long\";\n    case 5:\n      name = \"unsigned char\";\n    case 6:\n      name = \"signed char\";\n    case 7:\n      name = \"unsigned short\";\n    case 8:\n      name = \"unsigned int\";\n    case 9:\n      name = \"unsigned\";\n    case 10:\n      name = \"unsigned long\";\n    case 11:\n      name = \"void\";\n    case 12:\n      name = \"float\";\n    case 13:\n      name = \"double\";\n    case 14:\n      name = \"long double\";\n    case 15:\n      name = \"integer\";\n    case 16:\n      name = \"boolean\";\n    case 17:\n      name = \"short real\";\n    case 18:\n      name = \"real\";\n    case 19:\n      name = \"stringptr\";\n    case 20:\n      name = \"character\";\n    case 21:\n      name = \"logical*1\";\n    case 22:\n      name = \"logical*2\";\n    case 23:\n      name = \"logical*4\";\n    case 24:\n      name = \"logical\";\n    case 25:\n      name = \"complex\";\n    case 26:\n      name = \"double complex\";\n    case 27:\n      name = \"integer*1\";\n    case 28:\n      name = \"integer*2\";\n    case 29:\n      name = \"integer*4\";\n    case 30:\n      name = \"wchar\";\n    case 31:\n      name = \"long long\";\n    case 32:\n      name = \"unsigned long long\";\n    case 33:\n      name = \"logical*8\";\n    case 34:\n      name = \"integer*8\";\n    }\n  return name[0];\n}\n\nint main()\n{\n  int i;\n  if (stab_xcoff_builtin_type(0) != 0)\n    abort ();\n  if (stab_xcoff_builtin_type(-1) != 'i')\n    abort ();\n  if (stab_xcoff_builtin_type(-2) != 's')\n    abort ();\n  if (stab_xcoff_builtin_type(-3) != 's')\n    abort ();\n  for (i = -4; i >= -34; --i)\n    if (stab_xcoff_builtin_type(i) != 'i')\n      abort ();\n  if (stab_xcoff_builtin_type(-35) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36034-1.c",
    "content": "double x[5][10] = { { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1 },\n                    { 21, 22, 23, 24, 25, 26, -1, -1, -1, -1 },\n                    { 32, 33, 34, 35, 36, 37, -1, -1, -1, -1 },\n                    { 43, 44, 45, 46, 47, 48, -1, -1, -1, -1 },\n                    { 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 } };\ndouble tmp[5][6];\n\nvoid __attribute__((noinline))\ntest (void)\n{ \n  int i, j;\n  for (i = 0; i < 5; ++i)\n    {\n      tmp[i][0] = x[i][0];\n      tmp[i][1] = x[i][1];\n      tmp[i][2] = x[i][2];\n      tmp[i][3] = x[i][3];\n      tmp[i][4] = x[i][4];\n      tmp[i][5] = x[i][5];\n    }\n}\nextern void abort (void);\nint main()\n{\n  int i, j;\n  test();\n  for (i = 0; i < 5; ++i)\n    for (j = 0; j < 6; ++j)\n      if (tmp[i][j] == -1)\n        abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36034-2.c",
    "content": "double x[50] = { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1,\n                 21, 22, 23, 24, 25, 26, -1, -1, -1, -1,\n                 32, 33, 34, 35, 36, 37, -1, -1, -1, -1,\n                 43, 44, 45, 46, 47, 48, -1, -1, -1, -1,\n                 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 };\ndouble tmp[30];\n\nvoid __attribute__((noinline))\ntest (void)\n{\n  int i, j;\n  for (i = 0; i < 5; ++i)\n    {\n      tmp[i*6] = x[i*10];\n      tmp[i*6+1] = x[i*10+1];\n      tmp[i*6+2] = x[i*10+2];\n      tmp[i*6+3] = x[i*10+3];\n      tmp[i*6+4] = x[i*10+4];\n      tmp[i*6+5] = x[i*10+5];\n    }\n}\nextern void abort (void);\nint main()\n{\n  int i, j;\n  test();\n  for (i = 0; i < 5; ++i)\n    for (j = 0; j < 6; ++j)\n      if (tmp[i*6+j] == -1)\n        abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36038.c",
    "content": "/* PR tree-optimization/36038 */\n\nlong long list[10];\nlong long expect[10] = { 0, 1, 2, 3, 4, 4, 5, 6, 7, 9 };\nlong long *stack_base;\nint indices[10];\nint *markstack_ptr;\n\nvoid\ndoit (void)\n{\n  long long *src;\n  long long *dst;\n  long long *sp = stack_base + 5;\n  int diff = 2;\n  int shift;\n  int count;\n\n  shift = diff - (markstack_ptr[-1] - markstack_ptr[-2]);\n  count = (sp - stack_base) - markstack_ptr[-1] + 2;\n  src = sp;\n  dst = (sp += shift);\n  while (--count)\n    *dst-- = *src--;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    list[i] = i;\n\n  markstack_ptr = indices + 9;\n  markstack_ptr[-1] = 2;\n  markstack_ptr[-2] = 1;\n\n  stack_base = list + 2;\n  doit ();\n  if (__builtin_memcmp (expect, list, sizeof (list)))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36077.c",
    "content": "extern void abort (void);\n\nunsigned int test (unsigned int x)\n{\n  return x / 0x80000001U / 0x00000002U;\n}\n\nint main()\n{\n  if (test(2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36093.c",
    "content": "extern void abort (void);\n\ntypedef struct Bar {\n      char c[129];\n} Bar __attribute__((__aligned__(128)));\n\ntypedef struct Foo {\n      Bar bar[4];\n} Foo;\n\nFoo foo[4];\n\nint main()\n{\n   int i, j;\n   Foo *foop = &foo[0];\n\n   for (i=0; i < 4; i++) {\n      Bar *bar = &foop->bar[i];\n      for (j=0; j < 129; j++) {\n         bar->c[j] = 'a' + i;\n      }\n   }\n\n   if (foo[0].bar[3].c[128] != 'd')\n     abort ();\n   return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36321.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nextern void abort (void);\n\nextern __SIZE_TYPE__ strlen (const char *);\nvoid foo(char *str)\n{\n  int len2 = strlen (str);\n  char *a = (char *) __builtin_alloca (0);\n  char *b = (char *) __builtin_alloca (len2*3);\n\n  if ((int) (a-b) < (len2*3))\n    {\n#ifdef _WIN32\n      abort ();\n#endif\n      return;\n    }\n}\n\nstatic char * volatile argp = \"pr36321.x\";\n\nint main(int argc, char **argv)\n{\n  foo (argp);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36339.c",
    "content": "extern void abort (void);\n\ntypedef unsigned long my_uintptr_t;\n\nint check_a(my_uintptr_t tagged_ptr);\n\nint __attribute__((noinline)) try_a(my_uintptr_t x)\n{\n  my_uintptr_t heap[2];\n  my_uintptr_t *hp = heap;\n\n  hp[0] = x;\n  hp[1] = 0;\n  return check_a((my_uintptr_t)(void*)((char*)hp + 1));\n}\n\nint __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr)\n{\n  my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1);\n\n  if (hp[0] == 42 && hp[1] == 0)\n    return 0;\n  return -1;\n}\n\nint main(void)\n{\n  if (try_a(42) < 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36343.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline))\nbar (int **p)\n{\n  float *q = (float *)p;\n  *q = 0.0;\n}\n\nfloat __attribute__((noinline))\nfoo (int b)\n{\n  int *i = 0;\n  float f = 1.0;\n  int **p;\n  if (b)\n    p = &i;\n  else\n    p = (int **)&f;\n  bar (p);\n  if (b)\n    return **p;\n  return f;\n}\n\nint main()\n{\n  if (foo(0) != 0.0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36691.c",
    "content": "unsigned char g_5;\n\nvoid func_1 (void)\n{\n  for (g_5 = 9; g_5 >= 4; g_5 -= 5)\n    ;\n}\n\nextern void abort (void);\nint main (void)\n{\n  func_1 ();\n  if (g_5 != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr36765.c",
    "content": "int __attribute__((noinline))\nfoo(int i)\n{\n  int *p = __builtin_malloc (4 * sizeof(int));\n  *p = 0;\n  p[i] = 1;\n  return *p;\n}\nextern void abort (void);\nint main()\n{\n  if (foo(0) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37102.c",
    "content": "extern void abort (void);\n\nunsigned int a, b = 1, c;\n\nvoid __attribute__ ((noinline))\nfoo (int x)\n{\n  if (x != 5)\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned int d, e;\n  for (d = 1; d < 5; d++)\n    if (c)\n      a = b;\n  a = b;\n  e = a << 1;\n  if (e)\n    e = (e << 1) ^ 1;\n  foo (e);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37125.c",
    "content": "extern void abort (void);\n\nstatic inline unsigned int\nmod_rhs(int rhs)\n{\n  if (rhs == 0) return 1;\n  return rhs;\n}\n\nvoid func_44 (unsigned int p_45);\nvoid func_44 (unsigned int p_45)\n{\n  if (!((p_45 * -9) % mod_rhs (-9))) {\n      abort();\n  }\n}\n\nint main (void)\n{\n  func_44 (2);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37573.c",
    "content": "/* PR tree-optimization/37573 */\n/* { dg-require-effective-target int32plus } */\n\nstruct S\n{\n  unsigned int *a;\n  unsigned int b;\n  unsigned int c[624];\n};\n\nstatic unsigned char __attribute__((noinline))\nfoo (struct S *s)\n{\n  unsigned int r;\n  if (!--s->b)\n    {\n      unsigned int *c = s->c;\n      unsigned int i;\n      s->a = c;\n      for (i = 0; i < 227; i++)\n\tc[i] = ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1)\n\t    ^ ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];\n    }\n  r = *(s->a++);\n  r ^= (r >> 11);\n  r ^= ((r & 0xff3a58ad) << 7);\n  r ^= ((r & 0xffffdf8c) << 15);\n  r ^= (r >> 18);\n  return (unsigned char) (r >> 1);\n}\n\nstatic void __attribute__((noinline))\nbar (unsigned char *p, unsigned int q, unsigned int r)\n{\n  struct S s;\n  unsigned int i;\n  unsigned int *c = s.c;\n  *c = r;\n  for (i = 1; i < 624; i++)\n    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);\n  s.b = 1;\n  while (q--)\n    *p++ ^= foo (&s);\n};\n\nstatic unsigned char p[23] = {\n  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,\n  0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38\n};\n\nstatic unsigned char q[23] = {\n  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,\n  0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c\n};\n\nint\nmain (void)\n{\n  unsigned int s;\n  s = 23;\n  bar (p, s, s + 0xa25e);\n  if (__builtin_memcmp (p, q, s) != 0)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37882.c",
    "content": "/* PR middle-end/37882 */\n\nstruct S\n{\n  unsigned char b : 3;\n} s;\n\nint\nmain ()\n{\n  s.b = 4;\n  if (s.b > 0 && s.b < 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37924.c",
    "content": "/* PR c/37924 */\n\nextern void abort (void);\n\nsigned char a;\nunsigned char b;\n\nint\ntest1 (void)\n{\n  int c = -1;\n  return ((unsigned int) (a ^ c)) >> 9;\n}\n\nint\ntest2 (void)\n{\n  int c = -1;\n  return ((unsigned int) (b ^ c)) >> 9;\n}\n\nint\nmain (void)\n{\n  a = 0;\n  if (test1 () != (-1U >> 9))\n    abort ();\n  a = 0x40;\n  if (test1 () != (-1U >> 9))\n    abort ();\n  a = 0x80;\n  if (test1 () != (a < 0) ? 0 : (-1U >> 9))\n    abort ();\n  a = 0xff;\n  if (test1 () != (a < 0) ? 0 : (-1U >> 9))\n    abort ();\n  b = 0;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0x40;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0x80;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0xff;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr37931.c",
    "content": "/* PR middle-end/37931 */\n\nextern void abort (void);\n\nint\nfoo (int a, unsigned int b)\n{\n  return (a | 1) & (b | 1);\n}\n\nint\nmain (void)\n{\n  if (foo (6, 0xc6) != 7)\n    abort ();\n  if (foo (0x80, 0xc1) != 0x81)\n    abort ();\n  if (foo (4, 4) != 5)\n    abort ();\n  if (foo (5, 4) != 5)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c",
    "content": "extern void abort(void);\n\nint foo ()\n{\n  int mat[2][1];\n  int (*a)[1] = mat;\n  int det = 0;\n  int i;\n  mat[0][0] = 1;\n  mat[1][0] = 2;\n  for (i = 0; i < 2; ++i)\n    det += a[i][0];\n  return det;\n}\n\nint main()\n{\n  if (foo () != 3)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c",
    "content": "extern void abort (void);\n\nstatic int inv_J(int a[][2])\n{\n  int i, j;\n  int det = 0.0;\n   for (j=0; j<2; ++j)\n     det += a[j][0] + a[j][1];\n  return det;\n}\n\nint foo()\n{\n  int mat[2][2];\n  mat[0][0] = 1;\n  mat[0][1] = 2;\n  mat[1][0] = 4;\n  mat[1][1] = 8;\n  return inv_J(mat);\n}\n\nint main()\n{\n  if (foo () != 15)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38051.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nstatic int mymemcmp1 (unsigned long int, unsigned long int)\n  __attribute__ ((__nothrow__));\n\n__inline static int\nmymemcmp1 (unsigned long int a, unsigned long int b)\n{\n  long int srcp1 = (long int) &a;\n  long int srcp2 = (long int) &b;\n  unsigned long int a0, b0;\n  do\n    {\n      a0 = ((unsigned char *) srcp1)[0];\n      b0 = ((unsigned char *) srcp2)[0];\n      srcp1 += 1;\n      srcp2 += 1;\n    }\n  while (a0 == b0);\n  return a0 - b0;\n}\n\nstatic int mymemcmp2 (long, long, size_t) __attribute__ ((__nothrow__));\n\nstatic int\nmymemcmp2 (long int srcp1, long int srcp2, size_t len)\n{\n  unsigned long int a0, a1;\n  unsigned long int b0, b1;\n  switch (len % 4)\n    {\n    default:\n    case 2:\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= 2 * (sizeof (unsigned long int));\n      srcp2 -= 2 * (sizeof (unsigned long int));\n      len += 2;\n      goto do1;\n    case 3:\n      a1 = ((unsigned long int *) srcp1)[0];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= (sizeof (unsigned long int));\n      srcp2 -= (sizeof (unsigned long int));\n      len += 1;\n      goto do2;\n    case 0:\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        return 0;\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      goto do3;\n    case 1:\n      a1 = ((unsigned long int *) srcp1)[0];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp1 += (sizeof (unsigned long int));\n      srcp2 += (sizeof (unsigned long int));\n      len -= 1;\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        goto do0;\n    }\n  do\n    {\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      if (a1 != b1)\n        return mymemcmp1 ((a1), (b1));\n    do3:\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[1];\n      if (a0 != b0)\n        return mymemcmp1 ((a0), (b0));\n    do2:\n      a0 = ((unsigned long int *) srcp1)[2];\n      b0 = ((unsigned long int *) srcp2)[2];\n      if (a1 != b1)\n        return mymemcmp1 ((a1), (b1));\n    do1:\n      a1 = ((unsigned long int *) srcp1)[3];\n      b1 = ((unsigned long int *) srcp2)[3];\n      if (a0 != b0)\n        return mymemcmp1 ((a0), (b0));\n      srcp1 += 4 * (sizeof (unsigned long int));\n      srcp2 += 4 * (sizeof (unsigned long int));\n      len -= 4;\n    }\n  while (len != 0);\ndo0:\n  if (a1 != b1)\n    return mymemcmp1 ((a1), (b1));\n  return 0;\n}\n\nstatic int mymemcmp3 (long, long, size_t) __attribute__ ((__nothrow__));\n\nstatic int\nmymemcmp3 (long int srcp1, long int srcp2, size_t len)\n{\n  unsigned long int a0, a1, a2, a3;\n  unsigned long int b0, b1, b2, b3;\n  unsigned long int x;\n  int shl, shr;\n  shl = 8 * (srcp1 % (sizeof (unsigned long int)));\n  shr = 8 * (sizeof (unsigned long int)) - shl;\n  srcp1 &= -(sizeof (unsigned long int));\n  switch (len % 4)\n    {\n    default:\n    case 2:\n      a1 = ((unsigned long int *) srcp1)[0];\n      a2 = ((unsigned long int *) srcp1)[1];\n      b2 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= 1 * (sizeof (unsigned long int));\n      srcp2 -= 2 * (sizeof (unsigned long int));\n      len += 2;\n      goto do1;\n    case 3:\n      a0 = ((unsigned long int *) srcp1)[0];\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp2 -= 1 * (sizeof (unsigned long int));\n      len += 1;\n      goto do2;\n    case 0:\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        return 0;\n      a3 = ((unsigned long int *) srcp1)[0];\n      a0 = ((unsigned long int *) srcp1)[1];\n      b0 = ((unsigned long int *) srcp2)[0];\n      srcp1 += 1 * (sizeof (unsigned long int));\n      goto do3;\n    case 1:\n      a2 = ((unsigned long int *) srcp1)[0];\n      a3 = ((unsigned long int *) srcp1)[1];\n      b3 = ((unsigned long int *) srcp2)[0];\n      srcp1 += 2 * (sizeof (unsigned long int));\n      srcp2 += 1 * (sizeof (unsigned long int));\n      len -= 1;\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        goto do0;\n    }\n  do\n    {\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      x = (((a2) >> (shl)) | ((a3) << (shr)));\n      if (x != b3)\n        return mymemcmp1 ((x), (b3));\n    do3:\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[1];\n      x = (((a3) >> (shl)) | ((a0) << (shr)));\n      if (x != b0)\n        return mymemcmp1 ((x), (b0));\n    do2:\n      a2 = ((unsigned long int *) srcp1)[2];\n      b2 = ((unsigned long int *) srcp2)[2];\n      x = (((a0) >> (shl)) | ((a1) << (shr)));\n      if (x != b1)\n        return mymemcmp1 ((x), (b1));\n    do1:\n      a3 = ((unsigned long int *) srcp1)[3];\n      b3 = ((unsigned long int *) srcp2)[3];\n      x = (((a1) >> (shl)) | ((a2) << (shr)));\n      if (x != b2)\n        return mymemcmp1 ((x), (b2));\n      srcp1 += 4 * (sizeof (unsigned long int));\n      srcp2 += 4 * (sizeof (unsigned long int));\n      len -= 4;\n    }\n  while (len != 0);\ndo0:\n  x = (((a2) >> (shl)) | ((a3) << (shr)));\n  if (x != b3)\n    return mymemcmp1 ((x), (b3));\n  return 0;\n}\n\n__attribute__ ((noinline))\nint mymemcmp (const void *s1, const void *s2, size_t len)\n{\n  unsigned long int a0;\n  unsigned long int b0;\n  long int srcp1 = (long int) s1;\n  long int srcp2 = (long int) s2;\n  if (srcp1 % (sizeof (unsigned long int)) == 0)\n    return mymemcmp2 (srcp1, srcp2, len / (sizeof (unsigned long int)));\n  else\n    return mymemcmp3 (srcp1, srcp2, len / (sizeof (unsigned long int)));\n}\n\nchar buf[256];\n\nint\nmain (void)\n{\n  char *p;\n  union { long int l; char c[sizeof (long int)]; } u;\n\n  /* The test above assumes little endian and long being the same size\n     as pointer.  */\n  if (sizeof (long int) != sizeof (void *) || sizeof (long int) < 4)\n    return 0;\n  u.l = 0x12345678L;\n  if (u.c[0] != 0x78 || u.c[1] != 0x56 || u.c[2] != 0x34 || u.c[3] != 0x12)\n    return 0;\n\n  p = buf + 16 - (((long int) buf) & 15);\n  __builtin_memcpy (p + 9,\n\"\\x1\\x37\\x82\\xa7\\x55\\x49\\x9d\\xbf\\xf8\\x44\\xb6\\x55\\x17\\x8e\\xf9\", 15);\n  __builtin_memcpy (p + 128 + 24,\n\"\\x1\\x37\\x82\\xa7\\x55\\x49\\xd0\\xf3\\xb7\\x2a\\x6d\\x23\\x71\\x49\\x6a\", 15);\n  if (mymemcmp (p + 9, p + 128 + 24, 33) != -51)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38151.c",
    "content": "/* { dg-options \"-Wno-psabi\" } */\nvoid abort (void);\n\nstruct S2848\n{\n  unsigned int a;\n  _Complex int b;\n  struct\n  {\n  } __attribute__ ((aligned)) c;\n};\n\nstruct S2848 s2848;\n\nint fails;\n\nvoid  __attribute__((noinline))\ncheck2848va (int z, ...)\n{\n  struct S2848 arg;\n  __builtin_va_list ap;\n\n  __builtin_va_start (ap, z);\n\n  arg = __builtin_va_arg (ap, struct S2848);\n\n  if (s2848.a != arg.a)\n    ++fails;\n  if (s2848.b != arg.b)\n    ++fails;\n\n  __builtin_va_end (ap);\n}\n\nint main (void)\n{\n  s2848.a = 4027477739U;\n  s2848.b = (723419448 + -218144346 * __extension__ 1i);\n\n  check2848va (1, s2848);\n\n  if (fails)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38212.c",
    "content": "int __attribute__((noinline))\nfoo (int *__restrict p, int i)\n{\n  int *__restrict q;\n  int *__restrict r;\n  int v, w;\n  q = p + 1;\n  r = q - i;\n  v = *r;\n  *p = 1;\n  w = *r;\n  return v + w;\n}\nextern void abort (void);\nint main()\n{\n  int i = 0;\n  if (foo (&i, 1) != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38236.c",
    "content": "struct X { int i; };\n\nint __attribute__((noinline))\nfoo (struct X *p, int *q, int a, int b)\n{\n  struct X x, y;\n  if (a)\n    p = &x;\n  if (b)\n    q = &x.i;\n  else\n    q = &y.i;\n  *q = 1;\n  return p->i; \n}\nextern void abort (void);\nint main()\n{\n  if (foo((void *)0, (void *)0, 1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38422.c",
    "content": "/* PR middle-end/38422 */\n\nextern void abort (void);\n\nstruct S\n{\n  int s : (sizeof (int) * __CHAR_BIT__ - 2);\n} s;\n\nvoid\nfoo (void)\n{\n  s.s *= 2;\n}\n\nint\nmain ()\n{\n  s.s = 24;\n  foo ();\n  if (s.s != 48)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38533.c",
    "content": "/* PR middle-end/38533 */\n\n#define A asm volatile (\"\" : \"=r\" (f) : \"0\" (0)); e |= f;\n#define B A A A A A A A A A A A\n#define C B B B B B B B B B B B\n\nint\nfoo (void)\n{\n  int e = 0, f;\n  C C B B B B B A A A A A A\n  return e;\n}\n\nint\nmain (void)\n{\n  if (foo ())\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38819.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nvolatile int a = 1;\nvolatile int b = 0;\nvolatile int x = 2;\nvolatile signed int r = 8;\n\nvoid __attribute__((noinline))\nfoo (void)\n{\n  exit (0);\n}\n\nint\nmain (void)\n{\n  int si1 = a;\n  int si2 = b;\n  int i;\n\n  for (i = 0; i < 100; ++i) {\n      foo ();\n      if (x == 8)\n\ti++;\n      r += i + si1 % si2;\n  }\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr38969.c",
    "content": "__complex__ float\n__attribute__ ((noinline)) foo (__complex__ float x)\n{\n  return x;\n}\n\n__complex__ float\n__attribute__ ((noinline)) bar (__complex__ float x)\n{\n  return foo (x);\n}\n\nint main()\n{\n  __complex__ float a, b;\n  __real__ a = 9;\n  __imag__ a = 42;\n\n  b = bar (a);\n\n  if (a != b)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39100.c",
    "content": "/* Bad PTA results (incorrect store handling) was causing us to delete\n   *na = 0 store.  */\n\ntypedef struct E\n{\n  int p;\n  struct E *n;\n} *EP;   \n\ntypedef struct C\n{\n  EP x;\n  short cn, cp; \n} *CP;\n\n__attribute__((noinline)) CP\nfoo (CP h, EP x)\n{\n  EP pl = 0, *pa = &pl;\n  EP nl = 0, *na = &nl;\n  EP n;\n\n  while (x)\n    {\n      n = x->n;   \n      if ((x->p & 1) == 1) \n        {\n          h->cp++;\n          *pa = x;\n          pa = &((*pa)->n);\n        }\n      else\n        {\n          h->cn++;\n          *na = x;\n          na = &((*na)->n);\n        }    \n      x = n;\n    }\n  *pa = nl;\n  *na = 0;\n  h->x = pl;\n  return h;\n}\n\nint\nmain (void)\n{  \n  struct C c = { 0, 0, 0 };\n  struct E e[2] = { { 0, &e[1] }, { 1, 0 } };\n  EP p;\n\n  foo (&c, &e[0]);\n  if (c.cn != 1 || c.cp != 1)\n    __builtin_abort ();\n  if (c.x != &e[1])\n    __builtin_abort ();\n  if (e[1].n != &e[0])\n    __builtin_abort ();\n  if (e[0].n)\n    __builtin_abort ();\n  return 0;  \n}\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39120.c",
    "content": "struct X { int *p; } x;\n\nstruct X __attribute__((noinline))\nfoo(int *p) { struct X x; x.p = p; return x; }\n\nvoid __attribute((noinline))\nbar() { *x.p = 1; }\n\nextern void abort (void);\nint main()\n{\n  int i = 0;\n  x = foo(&i);\n  bar();\n  if (i != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39228.c",
    "content": "/* { dg-add-options ieee } */\n/* { dg-skip-if \"No Inf/NaN support\" { spu-*-* } \"*\" \"\" } */\n\nextern void abort (void);\n\nstatic inline int __attribute__((always_inline)) testf (float b)\n{\n  float c = 1.01f * b;\n\n  return __builtin_isinff (c);\n}\n\nstatic inline int __attribute__((always_inline)) test (double b)\n{\n  double c = 1.01 * b;\n\n  return __builtin_isinf (c);\n}\n\nstatic inline int __attribute__((always_inline)) testl (long double b)\n{\n  long double c = 1.01L * b;\n\n  return __builtin_isinfl (c);\n}\n\nint main()\n{\n  if (testf (__FLT_MAX__) < 1)\n    abort ();\n\n  if (test (__DBL_MAX__) < 1)\n    abort ();\n\n  if (testl (__LDBL_MAX__) < 1)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39233.c",
    "content": "extern void abort (void);\n\n__attribute__((noinline)) void\nfoo (void *p)\n{\n  long l = (long) p;\n  if (l < 0 || l > 6)\n    abort ();\n}\n\nint\nmain ()\n{\n  short i;\n  for (i = 6; i >= 0; i--)\n    foo ((void *) (long) i);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39240.c",
    "content": "/* PR target/39240 */\n\nextern void abort (void);\n\n__attribute__ ((noinline))\nstatic int foo1 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned int bar1 (int x)\n{\n  return foo1 (x + 6);\n}\n\nvolatile unsigned long l1 = (unsigned int) -4;\n\n__attribute__ ((noinline))\nstatic short int foo2 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned short int bar2 (int x)\n{\n  return foo2 (x + 6);\n}\n\nvolatile unsigned long l2 = (unsigned short int) -4;\n\n__attribute__ ((noinline))\nstatic signed char foo3 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned char bar3 (int x)\n{\n  return foo3 (x + 6);\n}\n\nvolatile unsigned long l3 = (unsigned char) -4;\n\n__attribute__ ((noinline))\nstatic unsigned int foo4 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nint bar4 (int x)\n{\n  return foo4 (x + 6);\n}\n\nvolatile unsigned long l4 = (int) -4;\n\n__attribute__ ((noinline))\nstatic unsigned short int foo5 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nshort int bar5 (int x)\n{\n  return foo5 (x + 6);\n}\n\nvolatile unsigned long l5 = (short int) -4;\n\n__attribute__ ((noinline))\nstatic unsigned char foo6 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nsigned char bar6 (int x)\n{\n  return foo6 (x + 6);\n}\n\nvolatile unsigned long l6 = (signed char) -4;\n\nint\nmain (void)\n{\n  if (bar1 (-10) != l1)\n    abort ();\n  if (bar2 (-10) != l2)\n    abort ();\n  if (bar3 (-10) != l3)\n    abort ();\n  if (bar4 (-10) != l4)\n    abort ();\n  if (bar5 (-10) != l5)\n    abort ();\n  if (bar6 (-10) != l6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39339.c",
    "content": "struct C\n{\n  unsigned int c;\n  struct D\n  {\n    unsigned int columns : 4;\n    unsigned int fore : 12;\n    unsigned int back : 6;\n    unsigned int fragment : 1;\n    unsigned int standout : 1;\n    unsigned int underline : 1;\n    unsigned int strikethrough : 1;\n    unsigned int reverse : 1;\n    unsigned int blink : 1;\n    unsigned int half : 1;\n    unsigned int bold : 1;\n    unsigned int invisible : 1;\n    unsigned int pad : 1;\n  } attr;\n};\n\nstruct A\n{\n  struct C *data;\n  unsigned int len;\n};\n\nstruct B\n{\n  struct A *cells;\n  unsigned char soft_wrapped : 1;\n};\n\nstruct E\n{\n  long row, col;\n  struct C defaults;\n};\n\n__attribute__ ((noinline))\nvoid foo (struct E *screen, unsigned int c, int columns, struct B *row)\n{\n  struct D attr;\n  long col;\n  int i;\n  col = screen->col;\n  attr = screen->defaults.attr;\n  attr.columns = columns;\n  row->cells->data[col].c = c;\n  row->cells->data[col].attr = attr;\n  col++;\n  attr.fragment = 1;\n  for (i = 1; i < columns; i++)\n    {\n      row->cells->data[col].c = c;\n      row->cells->data[col].attr = attr;\n      col++;\n    }\n}\n\nint\nmain (void)\n{\n  struct E e = {.row = 5,.col = 0,.defaults =\n      {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} };\n  struct C c[4];\n  struct A a = { c, 4 };\n  struct B b = { &a, 1 };\n  struct D d;\n  __builtin_memset (&c, 0, sizeof c);\n  foo (&e, 65, 2, &b);\n  d = e.defaults.attr;\n  d.columns = 2;\n  if (__builtin_memcmp (&d, &c[0].attr, sizeof d))\n    __builtin_abort ();\n  d.fragment = 1;\n  if (__builtin_memcmp (&d, &c[1].attr, sizeof d))\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr39501.c",
    "content": "/* { dg-options \"-ffast-math\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#define min1(a,b) ((a) < (b) ? (a) : (b))\n#define max1(a,b) ((a) > (b) ? (a) : (b))\n\n#define min2(a,b) ((a) <= (b) ? (a) : (b))\n#define max2(a,b) ((a) >= (b) ? (a) : (b))\n\n#define F(type,n)\t\t\t\t\t\t\\\n  type __attribute__((noinline)) type##_##n(type a, type b)\t\\\n  {\t\t\t\t\t\t\t\t\\\n    return n(a, b);\t\t\t\t\t\t\\\n  }\n\nF(float,min1)\nF(float,min2)\nF(float,max1)\nF(float,max2)\n\nF(double,min1)\nF(double,min2)\nF(double,max1)\nF(double,max2)\n\nint main()\n{\n  if (float_min1(0.f, -1.f) != -1.f) abort();\n  if (float_min1(-1.f, 0.f) != -1.f) abort();\n  if (float_min1(0.f, 1.f)  != 0.f)  abort();\n  if (float_min1(1.f, 0.f)  != 0.f)  abort();\n  if (float_min1(-1.f, 1.f) != -1.f) abort();\n  if (float_min1(1.f, -1.f) != -1.f) abort();\n  \n  if (float_max1(0.f, -1.f) != 0.f)  abort();\n  if (float_max1(-1.f, 0.f) != 0.f)  abort();\n  if (float_max1(0.f, 1.f)  != 1.f)  abort();\n  if (float_max1(1.f, 0.f)  != 1.f)  abort();\n  if (float_max1(-1.f, 1.f) != 1.f)  abort();\n  if (float_max1(1.f, -1.f) != 1.f)  abort();\n  \n  if (float_min2(0.f, -1.f) != -1.f) abort();\n  if (float_min2(-1.f, 0.f) != -1.f) abort();\n  if (float_min2(0.f, 1.f)  != 0.f)  abort();\n  if (float_min2(1.f, 0.f)  != 0.f)  abort();\n  if (float_min2(-1.f, 1.f) != -1.f) abort();\n  if (float_min2(1.f, -1.f) != -1.f) abort();\n  \n  if (float_max2(0.f, -1.f) != 0.f)  abort();\n  if (float_max2(-1.f, 0.f) != 0.f)  abort();\n  if (float_max2(0.f, 1.f)  != 1.f)  abort();\n  if (float_max2(1.f, 0.f)  != 1.f)  abort();\n  if (float_max2(-1.f, 1.f) != 1.f)  abort();\n  if (float_max2(1.f, -1.f) != 1.f)  abort();\n  \n  if (double_min1(0., -1.) != -1.) abort();\n  if (double_min1(-1., 0.) != -1.) abort();\n  if (double_min1(0., 1.)  != 0.)  abort();\n  if (double_min1(1., 0.)  != 0.)  abort();\n  if (double_min1(-1., 1.) != -1.) abort();\n  if (double_min1(1., -1.) != -1.) abort();\n  \n  if (double_max1(0., -1.) != 0.)  abort();\n  if (double_max1(-1., 0.) != 0.)  abort();\n  if (double_max1(0., 1.)  != 1.)  abort();\n  if (double_max1(1., 0.)  != 1.)  abort();\n  if (double_max1(-1., 1.) != 1.)  abort();\n  if (double_max1(1., -1.) != 1.)  abort();\n  \n  if (double_min2(0., -1.) != -1.) abort();\n  if (double_min2(-1., 0.) != -1.) abort();\n  if (double_min2(0., 1.)  != 0.)  abort();\n  if (double_min2(1., 0.)  != 0.)  abort();\n  if (double_min2(-1., 1.) != -1.) abort();\n  if (double_min2(1., -1.) != -1.) abort();\n  \n  if (double_max2(0., -1.) != 0.)  abort();\n  if (double_max2(-1., 0.) != 0.)  abort();\n  if (double_max2(0., 1.)  != 1.)  abort();\n  if (double_max2(1., 0.)  != 1.)  abort();\n  if (double_max2(-1., 1.) != 1.)  abort();\n  if (double_max2(1., -1.) != 1.)  abort();\n  \n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40022.c",
    "content": "extern void abort (void);\n\nstruct A\n{\n  struct A *a;\n};\n\nstruct B\n{\n  struct A *b;\n};\n\n__attribute__((noinline))\nstruct A *\nfoo (struct A *x)\n{\n  asm volatile (\"\" : : \"g\" (x) : \"memory\");\n  return x;\n}\n\n__attribute__((noinline))\nvoid\nbar (struct B *w, struct A *x, struct A *y, struct A *z)\n{\n  struct A **c;\n  c = &w->b;\n  *c = foo (x);\n  while (*c)\n    c = &(*c)->a;\n  *c = foo (y);\n  while (*c)\n    c = &(*c)->a;\n  *c = foo (z);\n}\n\nstruct B d;\nstruct A e, f, g;\n\nint\nmain (void)\n{\n  f.a = &g;\n  bar (&d, &e, &f, 0);\n  if (d.b == 0\n      || d.b->a == 0\n      || d.b->a->a == 0\n      || d.b->a->a->a != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40057.c",
    "content": "/* PR middle-end/40057 */\n\nextern void abort (void);\n\n__attribute__((noinline)) int\nfoo (unsigned long long x)\n{\n  unsigned long long y = (x >> 31ULL) & 1ULL;\n  if (y == 0ULL)\n    return 0;\n  return -1;\n}\n\n__attribute__((noinline)) int\nbar (long long x)\n{\n  long long y = (x >> 31LL) & 1LL;\n  if (y == 0LL)\n    return 0;\n  return -1;\n}\n\nint\nmain (void)\n{\n  if (sizeof (long long) != 8)\n    return 0;\n  if (foo (0x1682a9aaaULL))\n    abort ();\n  if (!foo (0x1882a9aaaULL))\n    abort ();\n  if (bar (0x1682a9aaaLL))\n    abort ();\n  if (!bar (0x1882a9aaaLL))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40386.c",
    "content": "/* { dg-options \"-fno-ira-share-spill-slots -Wno-shift-overflow\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#define CHAR_BIT 8\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0xf234)\n#define SHORT_VALUE ((short)0xf234)\n#define INT_VALUE ((int)0xf234)\n#define LONG_VALUE ((long)0xf2345678L)\n#define LL_VALUE ((long long)0xf2345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nint\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40404.c",
    "content": "extern void abort (void);\n\n#if (__SIZEOF_INT__ <= 2)\nstruct S {\n  unsigned long ui17 : 17;\n} s;\n#else\nstruct S {\n  unsigned int ui17 : 17;\n} s;\n#endif\nint main()\n{\n  s.ui17 = 0x1ffff;\n  if (s.ui17 >= 0xfffffffeu)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40493.c",
    "content": "extern void abort (void);\n\ntypedef union i386_operand_type\n{\n  struct\n    {\n      unsigned int reg8:1;\n      unsigned int reg16:1;\n      unsigned int reg32:1;\n      unsigned int reg64:1;\n      unsigned int floatreg:1;\n      unsigned int regmmx:1;\n      unsigned int regxmm:1;\n      unsigned int regymm:1;\n      unsigned int control:1;\n      unsigned int debug:1;\n      unsigned int test:1;\n      unsigned int sreg2:1;\n      unsigned int sreg3:1;\n      unsigned int imm1:1;\n      unsigned int imm8:1;\n      unsigned int imm8s:1;\n      unsigned int imm16:1;\n      unsigned int imm32:1;\n      unsigned int imm32s:1;\n      unsigned int imm64:1;\n      unsigned int disp8:1;\n      unsigned int disp16:1;\n      unsigned int disp32:1;\n      unsigned int disp32s:1;\n      unsigned int disp64:1;\n      unsigned int acc:1;\n      unsigned int floatacc:1;\n      unsigned int baseindex:1;\n      unsigned int inoutportreg:1;\n      unsigned int shiftcount:1;\n      unsigned int jumpabsolute:1;\n      unsigned int esseg:1;\n      unsigned int regmem:1;\n      unsigned int mem:1;\n      unsigned int byte:1;\n      unsigned int word:1;\n      unsigned int dword:1;\n      unsigned int fword:1;\n      unsigned int qword:1;\n      unsigned int tbyte:1;\n      unsigned int xmmword:1;\n      unsigned int ymmword:1;\n      unsigned int unspecified:1;\n      unsigned int anysize:1;\n    } bitfield;\n  unsigned int array[2];\n} i386_operand_type;\n\nunsigned int x00, x01, y00, y01;\n\nint main (int argc, char *argv[])\n{\n  i386_operand_type a,b,c,d;\n\n  a.bitfield.reg16 = 1;\n  a.bitfield.imm16 = 0;\n  a.array[1] = 22;\n\n  b = a;\n  x00 = b.array[0];\n  x01 = b.array[1];\n\n  c = b;\n  y00 = c.array[0];\n  y01 = c.array[1];\n\n  d = c;\n  if (d.bitfield.reg16 != 1)\n    abort();\n  if (d.bitfield.imm16 != 0)\n    abort();\n  if (d.array[1] != 22)\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40579.c",
    "content": "extern void abort (void);\nstatic char * __attribute__((noinline))\nitos(int num)\n{\n  return (char *)0;\n}\nstatic void __attribute__((noinline))\nfoo(int i, const char *x)\n{\n  if (i >= 4)\n    abort ();\n}\nint main()\n{\n  int x = -__INT_MAX__ + 3;\n  int i;\n\n  for (i = 0; i < 4; ++i)\n    {\n      char *p;\n      --x;\n      p = itos(x);\n      foo(i, p);\n    }\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40657.c",
    "content": "/* Verify that that Thumb-1 epilogue size optimization does not clobber the\n   return value.  */\n\nlong long v = 0x123456789abc;\n\n__attribute__((noinline)) void bar (int *x)\n{\n  asm volatile (\"\" : \"=m\" (x) ::);\n}\n\n__attribute__((noinline)) long long foo()\n{\n  int x;\n  bar(&x);\n  return v;\n}\n\nint main ()\n{\n  if (foo () != v)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40668.c",
    "content": "#if (__SIZEOF_INT__ == 2)\n#define TESTVALUE 0x1234\n#else\n#define TESTVALUE 0x12345678\n#endif\nstatic void\nfoo (unsigned int x, void *p)\n{\n  __builtin_memcpy (p, &x, sizeof x);\n}\n\nvoid\nbar (int type, void *number)\n{\n  switch (type)\n    {\n    case 1:\n      foo (TESTVALUE, number);\n      break;\n    case 7:\n      foo (0, number);\n      break;\n    case 8:\n      foo (0, number);\n      break;\n    case 9:\n      foo (0, number);\n      break;\n    }\n}\n\nint\nmain (void)\n{\n  unsigned int x;\n  bar (1, &x);\n  if (x != TESTVALUE)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr40747.c",
    "content": "/* PR middle-end/40747 */\n\nextern void abort (void);\n\nint\nfoo (int i)\n{\n  return (i < 4 && i >= 0) ? i : 4;\n}\n\nint\nmain ()\n{\n  if (foo (-1) != 4) abort ();\n  if (foo (0) != 0) abort ();\n  if (foo (1) != 1) abort ();\n  if (foo (2) != 2) abort ();\n  if (foo (3) != 3) abort ();\n  if (foo (4) != 4) abort ();\n  if (foo (5) != 4) abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41239.c",
    "content": "/* PR rtl-optimization/41239 */\n\nstruct S\n{\n  short nargs;\n  unsigned long arg[2];\n};\n\nextern void abort (void);\nextern void exit (int);\nextern char fn1 (int, const char *, int, const char *, const char *);\nextern void fn2 (int, ...);\nextern int fn3 (int);\nextern int fn4 (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));\n\nunsigned long\ntest (struct S *x)\n{\n  signed int arg1 = x->arg[0];\n  long int arg2 = x->arg[1];\n\n  if (arg2 == 0)\n    (fn1 (20, \"foo\", 924, __func__, ((void *) 0))\n     ? (fn2 (fn3 (0x2040082), fn4 (\"division by zero\")))\n     : (void) 0);\n\n  return (long int) arg1 / arg2;\n}\n\nint\nmain (void)\n{\n  struct S s = { 2, { 5, 0 } };\n  test (&s);\n  abort ();\n}\n\n__attribute__((noinline)) char\nfn1 (int x, const char *y, int z, const char *w, const char *v)\n{\n  asm volatile (\"\" : : \"r\" (w), \"r\" (v) : \"memory\");\n  asm volatile (\"\" : \"+r\" (x) : \"r\" (y), \"r\" (z) : \"memory\");\n  return x;\n}\n\n__attribute__((noinline)) int\nfn3 (int x)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  return x;\n}\n\n__attribute__((noinline)) int\nfn4 (const char *x, ...)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  return *x;\n}\n\n__attribute__((noinline)) void\nfn2 (int x, ...)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  if (x)\n    /* Could be a longjmp or throw too.  */\n    exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41317.c",
    "content": "extern void abort (void);\n\nstruct A\n{\n  int i;\n};\nstruct B\n{\n  struct A a;\n  int j;\n};\n\nstatic void\nfoo (struct B *p)\n{\n  ((struct A *)p)->i = 1;\n}\n\nint main()\n{\n  struct A a;\n  a.i = 0;\n  foo ((struct B *)&a);\n  if (a.i != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41395-1.c",
    "content": "struct VEC_char_base\n{\n  unsigned num;\n  unsigned alloc;\n  short vec[1];\n};\n\nshort __attribute__((noinline))\nfoo (struct VEC_char_base *p, int i)\n{\n  short *q;\n  p->vec[i] = 0;\n  q = &p->vec[8];\n  *q = 1;\n  return p->vec[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);\n  if (foo (p, 8) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41395-2.c",
    "content": "struct VEC_char_base\n{\n  unsigned num;\n  unsigned alloc;\n  union {\n      short vec[1];\n      struct {\n\t  int i;\n\t  int j;\n\t  int k;\n      } a;\n  } u;\n};\n\nshort __attribute__((noinline))\nfoo (struct VEC_char_base *p, int i)\n{\n  short *q;\n  p->u.vec[i] = 0;\n  q = &p->u.vec[16];\n  *q = 1;\n  return p->u.vec[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);\n  if (foo (p, 16) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41463.c",
    "content": "#include <stdlib.h>\n\nunion tree_node;\n\nstruct tree_common \n{\n  int a;\n  long b;\n  long c;\n  void *p;\n  int d;\n};\n\nstruct other_tree\n{\n  struct tree_common common;\n  int arr[14];\n};\n\nstruct tree_vec\n{\n  struct tree_common common;\n  int length;\n  union tree_node *a[1];\n};\n\nunion tree_node\n{\n  struct other_tree othr;\n  struct tree_vec vec;\n};\n\nunion tree_node global;\n\nunion tree_node * __attribute__((noinline))\nfoo (union tree_node *p, int i)\n{\n  union tree_node **q;\n  p->vec.a[i] = (union tree_node *) 0;\n  q = &p->vec.a[1];\n  *q = &global;\n  return p->vec.a[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  union tree_node *p = malloc (sizeof (union tree_node));\n  if (foo (p, 1) != &global)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41750.c",
    "content": "/* PR 41750 - IPA-SRA used to pass hash->sgot by value rather than by\n   reference.  */\n\nstruct bfd_link_hash_table\n{\n  int hash;\n};\n\nstruct foo_link_hash_table\n{\n  struct bfd_link_hash_table root;\n  int *dynobj;\n  int *sgot;\n};\n\nstruct foo_link_info\n{\n  struct foo_link_hash_table *hash;\n};\n\nextern void abort (void);\n\nint __attribute__((noinline))\nfoo_create_got_section (int *abfd, struct foo_link_info *info)\n{\n  info->hash->sgot = abfd;\n  return 1;\n}\n\nstatic int *\nget_got (int *abfd, struct foo_link_info *info,\n\t struct foo_link_hash_table *hash)\n{\n  int *got;\n  int *dynobj;\n\n  got = hash->sgot;\n  if (!got)\n    {\n      dynobj = hash->dynobj;\n      if (!dynobj)\n\thash->dynobj = dynobj = abfd;\n      if (!foo_create_got_section (dynobj, info))\n\treturn 0;\n      got = hash->sgot;\n    }\n  return got;\n}\n\nint * __attribute__((noinline,noclone))\nelf64_ia64_check_relocs (int *abfd, struct foo_link_info *info)\n{\n  return get_got (abfd, info, info->hash);\n}\n\nstruct foo_link_info link_info;\nstruct foo_link_hash_table hash;\nint abfd;\n\nint\nmain ()\n{\n  link_info.hash = &hash;\n  if (elf64_ia64_check_relocs (&abfd, &link_info) != &abfd)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41917.c",
    "content": "/* PR rtl-optimization/41917 */\n\nextern void abort (void);\nunsigned int a = 1;\n\nint\nmain (void)\n{\n  unsigned int b, c, d;\n\n  if (sizeof (int) != 4 || (int) 0xc7d24b5e > 0)\n    return 0;\n\n  c = 0xc7d24b5e;\n  d = a | -2;\n  b = (d == 0) ? c : (c % d);\n  if (b != c)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41919.c",
    "content": "extern void abort (void);\n\n#define assert(x) if(!(x)) abort()\n\nstruct S1\n{\n  signed char f0;\n};\n\nint g_23 = 0;\n\nstatic struct S1\nfoo (void)\n{\n  int *l_100 = &g_23;\n  int **l_110 = &l_100;\n  struct S1 l_128 = { 1 };\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  return l_128;\n}\n\nstatic signed char bar(signed char si1, signed char si2)\n{\n  return (si1 <= 0) ? si1 : (si2 * 2);\n}\nint main (void)\n{\n  struct S1 s = foo();\n  if (bar(0x99 ^ (s.f0 && 1), 1) != -104)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr41935.c",
    "content": "/* PR middle-end/41935 */\n\nextern void abort (void);\n\nlong int\nfoo (int n, int i, int j)\n{\n  typedef int T[n];\n  struct S { int a; T b[n]; };\n  return __builtin_offsetof (struct S, b[i][j]);\n}\n\nint\nmain (void)\n{\n  typedef int T[5];\n  struct S { int a; T b[5]; };\n  if (foo (5, 2, 3)\n      != __builtin_offsetof (struct S, b) + (5 * 2 + 3) * sizeof (int))\n    abort ();\n  if (foo (5, 5, 5)\n      != __builtin_offsetof (struct S, b) + (5 * 5 + 5) * sizeof (int))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42006.c",
    "content": "extern void abort (void);\n\nstatic unsigned int\nmy_add(unsigned int si1, unsigned int si2)\n{\n  return (si1 > (50-si2)) ? si1 : (si1 + si2);\n}\n\nstatic unsigned int\nmy_shift(unsigned int left, unsigned int right)\n{\n  return  (right > 100) ? left : (left >> right);\n}\n\nstatic int func_4(unsigned int p_6)\n{\n  int count = 0;\n  for (p_6 = 1; p_6 < 3; p_6 = my_add(p_6, 1))\n    {\n      if (count++ > 1)\n\tabort ();\n\n      if (my_shift(p_6, p_6))\n\treturn 0;\n    }\n  return 0;\n}\n\nint main(void)\n{\n  func_4(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42142.c",
    "content": "int __attribute__((noinline,noclone))\nsort(int L)\n{\n  int end[2] = { 10, 10, }, i=0, R;\n  while (i<2)\n    {\n      R = end[i];\n      if (L<R)\n        {\n          end[i+1] = 1;\n          end[i] = 10;\n          ++i;\n        }\n      else\n        break;\n    }\n  return i;\n}\nextern void abort (void);\nint main()\n{\n  if (sort (5) != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42154.c",
    "content": "struct A { char x[1]; };\nextern void abort (void);\nvoid __attribute__((noinline,noclone))\nfoo (struct A a)\n{\n  if (a.x[0] != 'a')\n    abort ();\n}\nint main ()\n{\n  struct A a;\n  int i;\n  for (i = 0; i < 1; ++i)\n    a.x[i] = 'a';\n  foo (a);\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42231.c",
    "content": "extern void abort (void);\n\nstatic max;\n\nstatic void __attribute__((noinline)) storemax (int i)\n{\n  if (i > max)\n    max = i;\n}\n\nstatic int CallFunctionRec(int (*fun)(int depth), int depth) {\n  if (!fun(depth)) {\n    return 0;\n  }\n  if (depth < 10) {\n    CallFunctionRec(fun, depth + 1);\n  }\n  return 1;\n}\n\nstatic int CallFunction(int (*fun)(int depth)) {\n  return CallFunctionRec(fun, 1) && !fun(0);\n}\n\nstatic int callback(int depth) {\n  storemax (depth);\n  return depth != 0;\n}\n\nint main() {\n  CallFunction(callback);\n  if (max != 10)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42248.c",
    "content": "typedef struct {\n  _Complex double a;\n  _Complex double b;\n} Scf10;\n\nScf10 g1s;\n\nvoid\ncheck (Scf10 x, _Complex double y)\n{\n  if (x.a != y) __builtin_abort ();\n}\n\nvoid\ninit (Scf10 *p, _Complex double y)\n{\n  p->a = y;\n}\n\nint\nmain ()\n{\n  init (&g1s, (_Complex double)1);\n  check (g1s, (_Complex double)1);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42269-2.c",
    "content": "/* Make sure that language + abi extensions in passing S interoperate.  */\n\nstatic long long __attribute__((noinline))\nfoo (unsigned short s)\n{\n  return (short) s;\n}\n\nunsigned short s = 0xFFFF;\n\nint\nmain (void)\n{\n  return foo (s) + 1 != 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42512.c",
    "content": "extern void abort (void);\n\nshort g_3;\n\nint main (void)\n{\n    int l_2;\n    for (l_2 = -1; l_2 != 0; l_2 = (unsigned char)(l_2 - 1))\n      g_3 |= l_2;\n    if (g_3 != -1)\n      abort ();\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42544.c",
    "content": "/* PR c/42544 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  signed short s = -1;\n  if (sizeof (long long) == sizeof (unsigned int))\n    return 0;\n  if ((unsigned int) s >= 0x100000000ULL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42570.c",
    "content": "typedef unsigned char uint8_t;\nuint8_t foo[1][0];\nextern void abort (void);\nint main()\n{\n  if (sizeof (foo) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42614.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\nextern void abort(void);\nextern void free(void *);\n\ntypedef struct SEntry\n{\n  unsigned char num;\n} TEntry;\n\ntypedef struct STable\n{\n  TEntry data[2];\n} TTable;\n\nTTable *init ()\n{\n  return malloc(sizeof(TTable));\n}\n\nvoid\nexpect_func (int a, unsigned char *b) __attribute__ ((noinline));\n\nstatic inline void\ninlined_wrong (TEntry *entry_p, int flag);\n\nvoid\ninlined_wrong (TEntry *entry_p, int flag)\n{\n  unsigned char index;\n  entry_p->num = 0;\n\n  if (flag == 0)\n    abort();\n\n  for (index = 0; index < 1; index++)\n    entry_p->num++;\n\n  if (!entry_p->num)\n    {\n      abort();\n    }\n}\n\nvoid\nexpect_func (int a, unsigned char *b)\n{\n  if (abs ((a == 0)))\n    abort ();\n  if (abs ((b == 0)))\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned char index = 0;\n  TTable *table_p = init();\n  TEntry work;\n\n  inlined_wrong (&(table_p->data[1]), 1);\n  expect_func (1, &index);\n  inlined_wrong (&work, 1);\n\n  free (table_p);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42691.c",
    "content": "extern void abort (void);\n\nunion _D_rep\n{\n  unsigned short rep[4];\n  double val;\n};\n\nint add(double* key, double* table)\n{\n  unsigned i = 0;\n  double* deletedEntry = 0;\n  while (1) {\n    double* entry = table + i;\n\n    if (*entry == *key)\n      break;\n\n    union _D_rep _D_inf = {{ 0, 0, 0, 0x7ff0 }};\n    if (*entry != _D_inf.val)\n      abort ();\n\n    union _D_rep _D_inf2 = {{ 0, 0, 0, 0x7ff0 }};\n    if (!_D_inf2.val)\n      deletedEntry = entry;\n\n    i++;\n  }\n  if (deletedEntry)\n    *deletedEntry = 0.0;\n  return 0;\n}\n\nint main ()\n{\n  union _D_rep infinit = {{ 0, 0, 0, 0x7ff0 }};\n  double table[2] = { infinit.val, 23 };\n  double key = 23;\n  int ret = add (&key, table);\n  return ret;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42721.c",
    "content": "/* PR c/42721 */\n\nextern void abort (void);\n\nstatic unsigned long long\nfoo (unsigned long long x, unsigned long long y)\n{\n  return x / y;\n}\n\nstatic int a, b;\n\nint\nmain (void)\n{\n  unsigned long long c = 1;\n  b ^= c && (foo (a, -1ULL) != 1L);\n  if (b != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr42833.c",
    "content": "typedef __INT_LEAST8_TYPE__ int8_t;\ntypedef __UINT_LEAST32_TYPE__ uint32_t;\ntypedef int ssize_t;\ntypedef struct { int8_t v1; int8_t v2; int8_t v3; int8_t v4; } neon_s8;\n\nuint32_t helper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2);\n\nuint32_t\nhelper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2)\n{\n  uint32_t res;\n  neon_s8 vsrc1;\n  neon_s8 vsrc2;\n  neon_s8 vdest;\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.i = (arg1);\n      vsrc1 = conv_u.v;\n    }\n  while (0);\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.i = (arg2);\n      vsrc2 = conv_u.v;\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v1;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = vsrc1.v1 >> (sizeof (vsrc1.v1) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = vsrc1.v1 >> (tmp - 1);\n\t  vdest.v1++;\n\t  vdest.v1 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v1 = (vsrc1.v1 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v1 = vsrc1.v1 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v2;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = vsrc1.v2 >> (sizeof (vsrc1.v2) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = vsrc1.v2 >> (tmp - 1);\n\t  vdest.v2++;\n\t  vdest.v2 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v2 = (vsrc1.v2 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v2 = vsrc1.v2 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v3;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = vsrc1.v3 >> (sizeof (vsrc1.v3) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = vsrc1.v3 >> (tmp - 1);\n\t  vdest.v3++;\n\t  vdest.v3 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v3 = (vsrc1.v3 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v3 = vsrc1.v3 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v4;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = vsrc1.v4 >> (sizeof (vsrc1.v4) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = vsrc1.v4 >> (tmp - 1);\n\t  vdest.v4++;\n\t  vdest.v4 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v4 = (vsrc1.v4 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v4 = vsrc1.v4 << tmp;\n\t}\n    }\n  while (0);;\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.v = (vdest);\n      res = conv_u.i;\n    }\n  while (0);\n  return res;\n}\n\nextern void abort(void);\n\nint main()\n{\n  uint32_t r = helper_neon_rshl_s8 (0x05050505, 0x01010101);\n  if (r != 0x0a0a0a0a)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43008.c",
    "content": "int i;\nstruct X {\n  int *p;\n};\nstruct X * __attribute__((malloc))\nmy_alloc (void)\n{\n  struct X *p = __builtin_malloc (sizeof (struct X));\n  p->p = &i;\n  return p;\n}\nextern void abort (void);\nint main()\n{\n  struct X *p, *q;\n  p = my_alloc ();\n  q = my_alloc ();\n  *(p->p) = 1;\n  *(q->p) = 0;\n  if (*(p->p) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43220.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target alloca } */\n\nvoid *volatile p;\n\nint\nmain (void)\n{\n  int n = 0;\nlab:;\n    {\n      int x[n % 1000 + 1];\n      x[0] = 1;\n      x[n % 1000] = 2;\n      p = x;\n      n++;\n    }\n\n    {\n      int x[n % 1000 + 1];\n      x[0] = 1;\n      x[n % 1000] = 2;\n      p = x;\n      n++;\n    }\n\n  if (n < 1000000)\n    goto lab;\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43236.c",
    "content": "/* { dg-options \"-ftree-loop-distribution\" } */\nextern void abort(void);\nextern void *memset(void *s, int c, __SIZE_TYPE__ n);\nextern int memcmp(const void *s1, const void *s2, __SIZE_TYPE__ n);\n/*extern int printf(const char *format, ...);*/\n\nint main()\n{\n  char A[30], B[30], C[30];\n  int i;\n\n  /* prepare arrays */\n  memset(A, 1, 30);\n  memset(B, 1, 30);\n\n  for (i = 20; i-- > 10;) {\n    A[i] = 0;\n    B[i] = 0;\n  }\n\n  /* expected result */\n  memset(C, 1, 30);\n  memset(C + 10, 0, 10);\n\n  /* show result */\n/*  for (i = 0; i < 30; i++)\n    printf(\"%d %d %d\\n\", A[i], B[i], C[i]); */\n\n  /* compare results */\n  if (memcmp(A, C, 30) || memcmp(B, C, 30)) abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43269.c",
    "content": "int g_21;\nint g_211;\nint g_261;\n\nstatic void __attribute__((noinline,noclone))\nfunc_32 (int b)\n{\n  if (b) {\nlbl_370:\n      g_21 = 1;\n  }\n\n  for (g_261 = -1; g_261 > -2; g_261--) {\n      if (g_211 + 1) {\n\t  return;\n      } else {\n\t  g_21 = 1;\n\t  goto lbl_370;\n      }\n  }\n}\n\nextern void abort (void);\n\nint main(void)\n{\n  func_32(0);\n  if (g_261 != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43385.c",
    "content": "/* PR c/43385 */\n\nextern void abort (void);\n\nint e;\n\n__attribute__((noinline)) void\nfoo (int x, int y)\n{\n  if (__builtin_expect (x, 0) && y != 0)\n    e++;\n}\n\n__attribute__((noinline)) int\nbar (int x, int y)\n{\n  if (__builtin_expect (x, 0) && y != 0)\n    return 1;\n  else\n    return 0;\n}\n\nint\nmain (void)\n{\n  int z = 0;\n  asm (\"\" : \"+r\" (z));\n  foo (z + 2, z + 1);\n  if (e != 1)\n    abort ();\n  foo (z + 2, z);\n  if (e != 1)\n    abort ();\n  foo (z + 1, z + 1);\n  if (e != 2)\n    abort ();\n  foo (z + 1, z);\n  if (e != 2)\n    abort ();\n  foo (z, z + 1);\n  if (e != 2)\n    abort ();\n  foo (z, z);\n  if (e != 2)\n    abort ();\n  if (bar (z + 2, z + 1) != 1)\n    abort ();\n  if (bar (z + 2, z) != 0)\n    abort ();\n  if (bar (z + 1, z + 1) != 1)\n    abort ();\n  if (bar (z + 1, z) != 0)\n    abort ();\n  if (bar (z, z + 1) != 0)\n    abort ();\n  if (bar (z, z) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43438.c",
    "content": "extern void abort (void);\n\nstatic unsigned char g_2 = 1;\nstatic int g_9;\nstatic int *l_8 = &g_9;\n\nstatic void func_12(int p_13)\n{\n  int * l_17 = &g_9;\n  *l_17 &= 0 < p_13;\n}\n\nint main(void)\n{\n  unsigned char l_11 = 254;\n  *l_8 |= g_2;\n  l_11 |= *l_8;\n  func_12(l_11);\n  if (g_9 != 1)\n    abort ();\n  return 0;\n} \n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43560.c",
    "content": "/* PR tree-optimization/43560 */\n\nstruct S\n{\n  int a, b;\n  char c[10];\n};\n\n__attribute__ ((noinline)) void\ntest (struct S *x)\n{\n  while (x->b > 1 && x->c[x->b - 1] == '/')\n    {\n      x->b--;\n      x->c[x->b] = '\\0';\n    }\n}\n\nconst struct S s = { 0, 0, \"\" };\n\nint\nmain ()\n{\n  struct S *p;\n  asm (\"\" : \"=r\" (p) : \"0\" (&s));\n  test (p);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43629.c",
    "content": "int flag;\nextern void abort (void);\nint main()\n{\n  int x;\n  if (flag)\n    x = -1;\n  else \n    x &= 0xff;\n  if (x & ~0xff)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43783.c",
    "content": "typedef __attribute__((aligned(16)))\nstruct {\n  unsigned long long w[3];\n} UINT192;\n\nUINT192 bid_Kx192[32];\n\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  unsigned long x = 0;\n  for (i = 0; i < 32; ++i)\n    bid_Kx192[i].w[1] = i == 1;\n  for (i = 0; i < 32; ++i)\n    x += bid_Kx192[1].w[1];\n  if (x != 32)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43784.c",
    "content": "struct s {\n  unsigned char a[256];\n};\nunion u {\n  struct { struct s b; int c; } d;\n  struct { int c; struct s b; } e;\n};\n\nstatic union u v;\nstatic struct s *p = &v.d.b;\nstatic struct s *q = &v.e.b;\n\nstatic struct s __attribute__((noinline)) rp(void)\n{\n  return *p;\n}\n\nstatic void qp(void)\n{\n  *q = rp();\n}\n\nint main()\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    p->a[i] = i;\n  qp();\n  for (i = 0; i < 256; i++)\n    if (q->a[i] != i)\n      __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43835.c",
    "content": "struct PMC {\n    unsigned flags;\n};\n\ntypedef struct Pcc_cell\n{\n    struct PMC *p;\n    long bla;\n    long type;\n} Pcc_cell;\n\nextern void abort ();\nextern void Parrot_gc_mark_PMC_alive_fun(int * interp, struct PMC *pmc)\n     __attribute__((noinline));\n\nvoid Parrot_gc_mark_PMC_alive_fun (int * interp, struct PMC *pmc)\n{\n  abort ();\n}\n\nstatic void mark_cell(int * interp, Pcc_cell *c)\n        __attribute__((__nonnull__(1)))\n        __attribute__((__nonnull__(2)))\n        __attribute__((noinline));\n\nstatic void\nmark_cell(int * interp, Pcc_cell *c)\n{\n            if (c->type == 4 && c->p\n\t\t&& !(c->p->flags & (1<<18)))\n\t      Parrot_gc_mark_PMC_alive_fun(interp, c->p);\n}\n\nvoid foo(int * interp, Pcc_cell *c);\n\nvoid\nfoo(int * interp, Pcc_cell *c)\n{\n  mark_cell(interp, c);\n}\n\nint main()\n{\n  int i;\n  Pcc_cell c;\n  c.p = 0;\n  c.bla = 42;\n  c.type = 4;\n  foo (&i, &c);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr43987.c",
    "content": "char B[256 * sizeof(void *)];\ntypedef void *FILE;\ntypedef struct globals {\n    int c;\n    FILE *l;\n} __attribute__((may_alias)) T;\nvoid add_input_file(FILE *file)\n{\n  (*(T*)&B).l[0] = file;\n}\nextern void abort (void);\nint main()\n{\n  FILE x;\n  (*(T*)&B).l = &x;\n  add_input_file ((void *)-1);\n  if ((*(T*)&B).l[0] != (void *)-1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44164.c",
    "content": "struct X {\n    struct Y {\n\tstruct YY {\n\t    struct Z {\n\t\tint i;\n\t    } c;\n\t} bb;\n    } b;\n} a;\nint __attribute__((noinline, noclone))\nfoo (struct Z *p)\n{\n  int i = p->i;\n  a.b = (struct Y){};\n  return p->i + i;\n}\nextern void abort (void);\nint main()\n{\n  a.b.bb.c.i = 1;\n  if (foo (&a.b.bb.c) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44202-1.c",
    "content": "extern __attribute__ ((__noreturn__)) void exit(int);\nextern __attribute__ ((__noreturn__)) void abort(void);\n__attribute__ ((__noinline__))\nint\nadd512(int a, int *b)\n{\n  int c = a + 512;\n  if (c != 0)\n    *b = a;\n  return c;\n}\n\n__attribute__ ((__noinline__))\nint\nadd513(int a, int *b)\n{\n  int c = a + 513;\n  if (c == 0)\n    *b = a;\n  return c;\n}\n\nint main(void)\n{\n  int b0 = -1;\n  int b1 = -1;\n  if (add512(-512, &b0) != 0 || b0 != -1 || add513(-513, &b1) != 0 || b1 != -513)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44468.c",
    "content": "#include <stddef.h>\n\nstruct S {\n  int i;\n  int j;\n};\nstruct R {\n  int k;\n  struct S a;\n};\nstruct Q {\n  float k;\n  struct S a;\n};\nstruct Q s;\nint __attribute__((noinline,noclone))\ntest1 (void *q)\n{\n  struct S *b = (struct S *)((char *)q + sizeof (int));\n  s.a.i = 0;\n  b->i = 3;\n  return s.a.i;\n}\nint __attribute__((noinline,noclone))\ntest2 (void *q)\n{\n  struct S *b = &((struct R *)q)->a;\n  s.a.i = 0;\n  b->i = 3;\n  return s.a.i;\n}\nint __attribute__((noinline,noclone))\ntest3 (void *q)\n{\n  s.a.i = 0;\n  ((struct S *)((char *)q + sizeof (int)))->i = 3;\n  return s.a.i;\n}\nextern void abort (void);\nint\nmain()\n{\n  if (sizeof (float) != sizeof (int)\n      || offsetof (struct R, a) != sizeof (int)\n      || offsetof (struct Q, a) != sizeof (int))\n    return 0;\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test1 ((void *)&s) != 3)\n    abort ();\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test2 ((void *)&s) != 3)\n    abort ();\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test3 ((void *)&s) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44555.c",
    "content": "struct a {\n    char b[100];\n};\nint foo(struct a *a)\n{\n  if (&a->b)\n    return 1;\n  return 0;\n}\nextern void abort (void);\nint main()\n{\n  if (foo((struct a *)0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44575.c",
    "content": "/* PR target/44575 */\n\n#include <stdarg.h>\n\nint fails = 0;\nstruct S { float a[3]; };\nstruct S a[5];\n\nvoid\ncheck (int z, ...)\n{\n  struct S arg, *p;\n  va_list ap;\n  int j = 0, k = 0;\n  int i;\n  va_start (ap, z);\n  for (i = 2; i < 4; ++i)\n    {\n      p = 0;\n      j++;\n      k += 2;\n      switch ((z << 4) | i)\n\t{\n\tcase 0x12:\n\tcase 0x13:\n\t  p = &a[2];\n\t  arg = va_arg (ap, struct S);\n\t  break;\n\tdefault:\n\t  ++fails;\n\t  break;\n\t}\n      if (p && p->a[2] != arg.a[2])\n\t++fails;\n      if (fails)\n\tbreak;\n    }\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  a[2].a[2] = -49026;\n  check (1, a[2], a[2]);\n  if (fails)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44683.c",
    "content": "int __attribute__((noinline,noclone))\ncopysign_bug (double x)\n{\n  if (x != 0.0 && (x * 0.5 == x))\n    return 1;\n  if (__builtin_copysign(1.0, x) < 0.0)\n    return 2;\n  else\n    return 3;\n}\nint main(void)\n{\n  double x = -0.0;\n  if (copysign_bug (x) != 2)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44828.c",
    "content": "extern void abort (void);\n\nstatic signed char\nfoo (signed char si1, signed char si2)\n{\n  return si1 * si2;\n}\n\nint a = 0x105F61CA;\n\nint\nmain (void)\n{\n  int b = 0x0332F5C8;\n  if (foo (b, a) > 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44852.c",
    "content": "__attribute__ ((__noinline__))\nchar *sf(char *s, char *s0)\n{\n  asm (\"\");\n  while (*--s == '9')\n    if (s == s0)\n      {\n\t*s = '0';\n\tbreak;\n      }\n  ++*s++;\n  return s;\n}\n\nint main()\n{\n  char s[] = \"999999\";\n  char *x = sf (s+2, s);\n  if (x != s+1 || __builtin_strcmp (s, \"199999\") != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44858.c",
    "content": "/* PR rtl-optimization/44858 */\n\nextern void abort (void);\nint a = 3;\nint b = 1;\n\n__attribute__((noinline)) long long\nfoo (int x, int y)\n{\n  return x / y;\n}\n\n__attribute__((noinline)) int\nbar (void)\n{\n  int c = 2;\n  c &= foo (1, b) > b;\n  b = (a != 0) | c;\n  return c;\n}\n\nint\nmain (void)\n{\n  if (bar () != 0 || b != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr44942.c",
    "content": "/* PR target/44942 */\n\n#include <stdarg.h>\n\nvoid\ntest1 (int a, int b, int c, int d, int e, int f, int g, long double h, ...)\n{\n  int i;\n  va_list ap;\n\n  va_start (ap, h);\n  i = va_arg (ap, int);\n  if (i != 1234)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest2 (int a, int b, int c, int d, int e, int f, int g, long double h, int i,\n       long double j, int k, long double l, int m, long double n, ...)\n{\n  int o;\n  va_list ap;\n\n  va_start (ap, n);\n  o = va_arg (ap, int);\n  if (o != 1234)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest3 (double a, double b, double c, double d, double e, double f,\n       double g, long double h, ...)\n{\n  double i;\n  va_list ap;\n\n  va_start (ap, h);\n  i = va_arg (ap, double);\n  if (i != 1234.0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest4 (double a, double b, double c, double d, double e, double f, double g,\n       long double h, double i, long double j, double k, long double l,\n       double m, long double n, ...)\n{\n  double o;\n  va_list ap;\n\n  va_start (ap, n);\n  o = va_arg (ap, double);\n  if (o != 1234.0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  test1 (0, 0, 0, 0, 0, 0, 0, 0.0L, 1234);\n  test2 (0, 0, 0, 0, 0, 0, 0, 0.0L, 0, 0.0L, 0, 0.0L, 0, 0.0L, 1234);\n  test3 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 1234.0);\n  test4 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 0.0, 0.0L,\n\t 0.0, 0.0L, 0.0, 0.0L, 1234.0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr45034.c",
    "content": "extern void abort (void);\nstatic void fixnum_neg(signed char x, signed char *py, int *pv)\n{\n  unsigned char ux, uy;\n\n  ux = (unsigned char)x;\n  uy = -ux;\n  *py = (uy <= 127) ? (signed char)uy : (-(signed char)(255 - uy) - 1);\n  *pv = (x == -128) ? 1 : 0;\n}\n\nvoid __attribute__((noinline)) foo(int x, int y, int v)\n{\n  if (y < -128 || y > 127)\n    abort();\n}\n\nint test_neg(void)\n{\n  signed char x, y;\n  int v, err;\n\n  err = 0;\n  x = -128;\n  for (;;) {\n      fixnum_neg(x, &y, &v);\n      foo((int)x, (int)y, v);\n      if ((v && x != -128) || (!v && x == -128))\n\t++err;\n      if (x == 127)\n\tbreak;\n      ++x;\n  }\n  return err;\n}\n\nint main(void)\n{\n  if (sizeof (char) != 1)\n    return 0;\n  if (test_neg() != 0)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr45070.c",
    "content": "/* PR45070 */\nextern void abort(void);\n\nstruct packed_ushort {\n    unsigned short ucs;\n} __attribute__((packed));\n\nstruct source {\n    int pos, length;\n    int flag;\n};\n\nstatic void __attribute__((noinline)) fetch(struct source *p)\n{\n    p->length = 128;\n}\n    \nstatic struct packed_ushort __attribute__((noinline)) next(struct source *p)\n{\n    struct packed_ushort rv;\n\n    if (p->pos >= p->length) {\n\tif (p->flag) {\n\t    p->flag = 0;\n\t    fetch(p);\n\t    return next(p);\n\t}\n\tp->flag = 1;\n\trv.ucs = 0xffff;\n\treturn rv;\n    }\n    rv.ucs = 0;\n    return rv;\n}\n\nint main(void)\n{\n    struct source s;\n    int i;\n\n    s.pos = 0;\n    s.length = 0;\n    s.flag = 0;\n\n    for (i = 0; i < 16; i++) {\n\tstruct packed_ushort rv = next(&s);\n\tif ((i == 0 && rv.ucs != 0xffff)\n\t    || (i > 0 && rv.ucs != 0))\n\t    abort();\n    }\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr45262.c",
    "content": "/* PR middle-end/45262 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nint\nfoo (unsigned int x)\n{\n  return ((int) x < 0) || ((int) (-x) < 0);\n}\n\nint\nbar (unsigned int x)\n{\n  return x >> 31 || (-x) >> 31;\n}\n\nint\nmain (void)\n{\n  if (foo (1) != 1)\n    abort ();\n  if (foo (0) != 0)\n    abort ();\n  if (foo (-1) != 1)\n    abort ();\n  if (bar (1) != 1)\n    abort ();\n  if (bar (0) != 0)\n    abort ();\n  if (bar (-1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr45695.c",
    "content": "/* PR rtl-optimization/45695 */\n\nextern void abort (void);\n\n__attribute__((noinline)) void\ng (int x)\n{\n  asm volatile (\"\" : \"+r\" (x));\n}\n\n__attribute__((noinline)) int\nf (int a, int b, int d)\n{\n  int r = -1;\n  b += d;\n  if (d == a)\n    r = b - d;\n  g (b);\n  return r;\n}\n\nint\nmain (void)\n{\n  int l;\n  asm (\"\" : \"=r\" (l) : \"0\" (0));\n  if (f (l + 0, l + 1, l + 4) != -1)\n    abort ();\n  if (f (l + 4, l + 1, l + 4) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr46019.c",
    "content": "/* PR middle-end/46019 */\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  unsigned long long l = 0x40000000000ULL;\n  int n;\n  for (n = 0; n < 8; n++)\n    if (l / (0x200000000ULL << n) != (0x200 >> n))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr46309.c",
    "content": "/* PR tree-optimization/46309 */\n\nextern void abort (void);\n\nunsigned int *q;\n\n__attribute__((noinline, noclone)) void\nbar (unsigned int *p)\n{\n  if (*p != 2 && *p != 3)\n    (!(!(*q & 263) || *p != 1)) ? abort () : 0;\n}\n\nint\nmain ()\n{\n  unsigned int x, y;\n  asm volatile (\"\" : : : \"memory\");\n  x = 2;\n  bar (&x);\n  x = 3;\n  bar (&x);\n  y = 1;\n  x = 0;\n  q = &y;\n  bar (&x);\n  y = 0;\n  x = 1;\n  bar (&x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr46316.c",
    "content": "extern void abort (void);\n\nlong long __attribute__((noinline,noclone))\nfoo (long long t)\n{\n  while (t > -4)\n    t -= 2;\n\n  return t;\n}\n\nint main(void)\n{\n  if (foo (0) != -4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr46909-1.c",
    "content": "/* PR tree-optimization/46909 */\n\nextern void abort ();\n\nint\n__attribute__ ((__noinline__))\nfoo (unsigned int x)\n{\n  if (! (x == 4 || x == 6) || (x == 2 || x == 6))\n    return 1;\n  return -1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = -10; i < 10; i++)\n    if (foo (i) != 1 - 2 * (i == 4))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr46909-2.c",
    "content": "/* PR tree-optimization/46909 */\n\nextern void abort (void);\n\nint\n__attribute__((noinline))\nfoo (int x)\n{\n  if ((x != 0 && x != 13) || x == 5 || x == 20)\n    return 1;\n  return -1;\n}\n\nint\nmain (void)\n{\n  int i;\n  for (i = -10; i < 30; i++)\n    if (foo (i) != 1 - 2 * (i == 0) - 2 * (i == 13))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47148.c",
    "content": "/* PR tree-optimization/47148 */\n\nstatic inline unsigned\nbar (unsigned x, unsigned y)\n{\n  if (y >= 32)\n    return x;\n  else\n    return x >> y;\n}\n\nstatic unsigned a = 1, b = 1;\n\nstatic inline void\nfoo (unsigned char x, unsigned y)\n{\n  if (!y)\n    return;\n  unsigned c = (0x7000U / (x - 2)) ^ a;\n  unsigned d = bar (a, a);\n  b &= ((a - d) && (a - 1)) + c;\n}\n\nint\nmain (void)\n{\n  foo (1, 1);\n  foo (-1, 1);\n  if (b && ((unsigned char) -1) == 255)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47155.c",
    "content": "/* PR tree-optimization/47155 */\n\nunsigned int a;\nstatic signed char b = -127;\nint c = 1;\n\nint\nmain (void)\n{\n  a = b <= (unsigned char) (-6 * c);\n  if (!a)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47237.c",
    "content": "/* { dg-xfail-if \"can cause stack underflow\" { nios2-*-* } \"*\" \"\" } */\n/* { dg-require-effective-target untyped_assembly } */\n#define INTEGER_ARG  5\n\nextern void abort(void);\n\nstatic void foo(int arg)\n{\n  if (arg != INTEGER_ARG)\n    abort();\n}\n\nstatic void bar(int arg)\n{\n  foo(arg);\n  __builtin_apply(foo, __builtin_apply_args(), 16);\n}\n\nint main(void)\n{\n  bar(INTEGER_ARG);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47299.c",
    "content": "/* PR rtl-optimization/47299 */\n\nextern void abort (void);\n\n__attribute__ ((noinline, noclone)) unsigned short\nfoo (unsigned char x)\n{\n  return x * 255;\n}\n\nint\nmain ()\n{\n  if (foo (0x40) != 0x3fc0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47337.c",
    "content": "/* PR rtl-optimization/47337 */\n\nstatic unsigned int a[256], b = 0;\nstatic char c = 0;\nstatic int d = 0, *f = &d;\nstatic long long e = 0;\n\nstatic short\nfoo (long long x, long long y)\n{\n  return x / y;\n}\n\nstatic char\nbar (char x, char y)\n{\n  return x - y;\n}\n\nstatic int\nbaz (int x, int y)\n{\n  *f = (y != (short) (y * 3));\n  for (c = 0; c < 2; c++)\n    {\n    lab:\n      if (d)\n\t{\n\t  if (e)\n\t    e = 1;\n\t  else\n\t    return x;\n\t}\n      else\n\t{\n\t  d = 1;\n\t  goto lab;\n\t}\n      f = &d;\n    }\n  return x;\n}\n\nstatic void\nfnx (unsigned long long x, int y)\n{\n  if (!y)\n    {\n      b = a[b & 1];\n      b = a[b & 1];\n      b = a[(b ^ (x & 1)) & 1];\n      b = a[(b ^ (x & 1)) & 1];\n    }\n}\n\nchar *volatile w = \"2\";\n\nint\nmain ()\n{\n  int h = 0;\n  unsigned int k = 0;\n  int l[8];\n  int i, j;\n\n  if (__builtin_strcmp (w, \"1\") == 0)\n    h = 1;\n\n  for (i = 0; i < 256; i++)\n    {\n      for (j = 8; j > 0; j--)\n\tk = 1;\n      a[i] = k;\n    }\n  for (i = 0; i < 8; i++)\n    l[i] = 0;\n\n  d = bar (c, c);\n  d = baz (c, 1 | foo (l[0], 10));\n  fnx (d, h);\n  fnx (e, h);\n\n  if (d != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47538.c",
    "content": "/* PR tree-optimization/47538 */\n\nstruct S\n{\n  double a, b, *c;\n  unsigned long d;\n};\n\n__attribute__((noinline, noclone)) void\nfoo (struct S *x, const struct S *y)\n{\n  const unsigned long n = y->d + 1;\n  const double m = 0.25 * (y->b - y->a);\n  x->a = y->a;\n  x->b = y->b;\n  if (n == 1)\n    {\n      x->c[0] = 0.;\n    }\n  else if (n == 2)\n    {\n      x->c[1] = m * y->c[0];\n      x->c[0] = 2.0 * x->c[1];\n    }\n  else\n    {\n      double o = 0.0, p = 1.0;\n      unsigned long i;\n\n      for (i = 1; i <= n - 2; i++)\n\t{\n\t  x->c[i] = m * (y->c[i - 1] - y->c[i + 1]) / (double) i;\n\t  o += p * x->c[i];\n\t  p = -p;\n\t}\n      x->c[n - 1] = m * y->c[n - 2] / (n - 1.0);\n      o += p * x->c[n - 1];\n      x->c[0] = 2.0 * o;\n    }\n}\n\nint\nmain (void)\n{\n  struct S x, y;\n  double c[4] = { 10, 20, 30, 40 }, d[4], e[4] = { 118, 118, 118, 118 };\n\n  y.a = 10;\n  y.b = 6;\n  y.c = c;\n  x.c = d;\n  y.d = 3;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 0 || d[1] != 20 || d[2] != 10 || d[3] != -10)\n    __builtin_abort ();\n  y.d = 2;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 60 || d[1] != 20 || d[2] != -10 || d[3] != 118)\n    __builtin_abort ();\n  y.d = 1;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != -20 || d[1] != -10 || d[2] != 118 || d[3] != 118)\n    __builtin_abort ();\n  y.d = 0;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 0 || d[1] != 118 || d[2] != 118 || d[3] != 118)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr47925.c",
    "content": "struct s { volatile struct s *next; };\n\nvoid __attribute__((noinline))\nbar (int ignored, int n)\n{\n  asm volatile (\"\");\n}\n\nint __attribute__((noinline))\nfoo (volatile struct s *ptr, int n)\n{\n  int i;\n\n  bar (0, n);\n  for (i = 0; i < n; i++)\n    ptr = ptr->next;\n}\n\nint main (void)\n{\n  volatile struct s rec = { &rec };\n  foo (&rec, 10);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48197.c",
    "content": "/* PR c/48197 */\n\nextern void abort (void);\nstatic int y = 0x8000;\n\nint\nmain ()\n{\n  unsigned int x = (short)y;\n  if (sizeof (0LL) == sizeof (0U))\n    return 0;\n  if (0LL > (0U ^ (short)-0x8000))\n    abort ();\n  if (0LL > (0U ^ x))\n    abort ();\n  if (0LL > (0U ^ (short)y))\n    abort ();\n  if ((0U ^ (short)-0x8000) < 0LL)\n    abort ();\n  if ((0U ^ x) < 0LL)\n    abort ();\n  if ((0U ^ (short)y) < 0LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48571-1.c",
    "content": "#define S (sizeof (int))\n\nunsigned int c[624];\nvoid __attribute__((noinline))\nbar (void)\n{\n  unsigned int i;\n  /* Obfuscated c[i] = c[i-1] * 2.  */\n  for (i = 1; i < 624; ++i)\n    *(unsigned int *)((void *)c + (__SIZE_TYPE__)i * S)\n\t= 2 * *(unsigned int *)((void *)c + ((__SIZE_TYPE__)i +\n\t\t\t\t\t     ((__SIZE_TYPE__)-S)/S) * S);\n}\nextern void abort (void);\nint\nmain()\n{\n  unsigned int i, j;\n  for (i = 0; i < 624; ++i)\n    c[i] = 1;\n  bar();\n  j = 1;\n  for (i = 0; i < 624; ++i)\n    {\n      if (c[i] != j)\n\tabort ();\n      j = j * 2;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48717.c",
    "content": "/* PR tree-optimization/48717 */\n\nextern void abort (void);\n\nint v = 1, w;\n\nunsigned short\nfoo (unsigned short x, unsigned short y)\n{\n  return x + y;\n}\n\nvoid\nbar (void)\n{\n  v = foo (~w, w);\n}\n\nint\nmain ()\n{\n  bar ();\n  if (v != (unsigned short) -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48809.c",
    "content": "/* PR tree-optimization/48809 */\n\nextern void abort (void);\n\nint\nfoo (signed char x)\n{\n  int y = 0;\n  switch (x)\n    {\n    case 0: y = 1; break;\n    case 1: y = 7; break;\n    case 2: y = 2; break;\n    case 3: y = 19; break;\n    case 4: y = 5; break;\n    case 5: y = 17; break;\n    case 6: y = 31; break;\n    case 7: y = 8; break;\n    case 8: y = 28; break;\n    case 9: y = 16; break;\n    case 10: y = 31; break;\n    case 11: y = 12; break;\n    case 12: y = 15; break;\n    case 13: y = 111; break;\n    case 14: y = 17; break;\n    case 15: y = 10; break;\n    case 16: y = 31; break;\n    case 17: y = 7; break;\n    case 18: y = 2; break;\n    case 19: y = 19; break;\n    case 20: y = 5; break;\n    case 21: y = 107; break;\n    case 22: y = 31; break;\n    case 23: y = 8; break;\n    case 24: y = 28; break;\n    case 25: y = 106; break;\n    case 26: y = 31; break;\n    case 27: y = 102; break;\n    case 28: y = 105; break;\n    case 29: y = 111; break;\n    case 30: y = 17; break;\n    case 31: y = 10; break;\n    case 32: y = 31; break;\n    case 98: y = 18; break;\n    case -62: y = 19; break;\n    }\n  return y;\n}\n\nint\nmain ()\n{\n  if (foo (98) != 18 || foo (97) != 0 || foo (99) != 0)\n    abort ();\n  if (foo (-62) != 19 || foo (-63) != 0 || foo (-61) != 0)\n    abort ();\n  if (foo (28) != 105 || foo (27) != 102 || foo (29) != 111)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48814-1.c",
    "content": "extern void abort (void);\n\nint arr[] = {1,2,3,4};\nint count = 0;\n\nint __attribute__((noinline))\nincr (void)\n{\n  return ++count;\n}\n\nint main()\n{\n  arr[count++] = incr ();\n  if (count != 2 || arr[count] != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48814-2.c",
    "content": "extern void abort (void);\n\nint arr[] = {1,2,3,4};\nint count = 0;\n\nint\nincr (void)\n{\n  return ++count;\n}\n\nint main()\n{\n  arr[count++] = incr ();\n  if (count != 2 || arr[count] != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c",
    "content": "/* PR middle-end/48973 */\n\nextern void abort (void);\nstruct S { int f : 1; } s;\nint v = -1;\n\nvoid\nfoo (unsigned int x)\n{\n  if (x != -1U)\n    abort ();\n}\n\nint\nmain ()\n{\n  s.f = (v & 1) > 0;\n  foo (s.f);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c",
    "content": "/* PR middle-end/48973 */\n\nextern void abort (void);\nstruct S { int f : 1; } s;\nint v = -1;\n\nint\nmain ()\n{\n  s.f = v < 0;\n  if ((unsigned int) s.f != -1U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49039.c",
    "content": "/* PR tree-optimization/49039 */\nextern void abort (void);\nint cnt;\n\n__attribute__((noinline, noclone)) void\nfoo (unsigned int x, unsigned int y)\n{\n  unsigned int minv, maxv;\n  if (x == 1 || y == -2U)\n    return;\n  minv = x < y ? x : y;\n  maxv = x > y ? x : y;\n  if (minv == 1)\n    ++cnt;\n  if (maxv == -2U)\n    ++cnt;\n}\n\nint\nmain ()\n{\n  foo (-2U, 1);\n  if (cnt != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49073.c",
    "content": "/* PR tree-optimization/49073 */\n\nextern void abort (void);\nint a[] = { 1, 2, 3, 4, 5, 6, 7 }, c;\n\nint\nmain ()\n{\n  int d = 1, i = 1;\n  _Bool f = 0;\n  do\n    {\n      d = a[i];\n      if (f && d == 4)\n\t{\n\t  ++c;\n\t  break;\n\t}\n      i++;\n      f = (d == 3);\n    }\n  while (d < 7);\n  if (c != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49123.c",
    "content": "/* PR lto/49123 */\n\nextern void abort (void);\nstatic struct S { int f : 1; } s;\nstatic int v = -1;\n\nint\nmain ()\n{\n  s.f = v < 0;\n  if ((unsigned int) s.f != -1U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49161.c",
    "content": "/* PR tree-optimization/49161 */\n\nextern void abort (void);\n\nint c;\n\n__attribute__((noinline, noclone)) void\nbar (int x)\n{\n  if (x != c++)\n    abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  switch (x)\n    {\n    case 3: goto l1;\n    case 4: goto l2;\n    case 6: goto l3;\n    default: return;\n    }\nl1:\n  goto l4;\nl2:\n  goto l4;\nl3:\n  bar (-1);\nl4:\n  bar (0);\n  if (x != 4)\n    bar (1);\n  if (x != 3)\n    bar (-1);\n  bar (2);\n}\n\nint\nmain ()\n{\n  foo (3);\n  if (c != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49186.c",
    "content": "/* PR target/49186 */\nextern void abort (void);\n\nint\nmain ()\n{\n  int x;\n  unsigned long long uv = 0x1000000001ULL;\n\n  x = (uv < 0x80) ? 1 : ((uv < 0x800) ? 2 : 3);\n  if (x != 3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49218.c",
    "content": "#ifdef __SIZEOF_INT128__\ntypedef __int128 L;\n#else\ntypedef long long L;\n#endif\nfloat f;\n\nint\nmain ()\n{\n  L i = f;\n  if (i <= 10)\n    do\n      {\n\t++i;\n\tasm (\"\");\n      }\n    while (i != 11);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49279.c",
    "content": "/* PR tree-optimization/49279 */\nextern void abort (void);\n\nstruct S { int a; int *__restrict p; };\n\n__attribute__((noinline, noclone))\nstruct S *bar (struct S *p)\n{\n  struct S *r;\n  asm volatile (\"\" : \"=r\" (r) : \"0\" (p) : \"memory\");\n  return r;\n}\n\n__attribute__((noinline, noclone))\nint\nfoo (int *p, int *q)\n{\n  struct S s, *t;\n  s.a = 1;\n  s.p = p;\n  t = bar (&s);\n  t->p = q;\n  s.p[0] = 0;\n  t->p[0] = 1;\n  return s.p[0];\n}\n\nint\nmain ()\n{\n  int a, b;\n  if (foo (&a, &b) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49281.c",
    "content": "/* PR target/49281 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  return (x << 2) | 4;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int x)\n{\n  return (x << 2) | 3;\n}\n\nint\nmain ()\n{\n  if (foo (43) != 172 || foo (1) != 4 || foo (2) != 12)\n    abort ();\n  if (bar (43) != 175 || bar (1) != 7 || bar (2) != 11)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49390.c",
    "content": "/* PR rtl-optimization/49390 */\n\nstruct S { unsigned int s1; unsigned int s2; };\nstruct T { unsigned int t1; struct S t2; };\nstruct U { unsigned short u1; unsigned short u2; };\nstruct V { struct U v1; struct T v2; };\nstruct S a;\nchar *b;\nunion { char b[64]; struct V v; } u;\nvolatile int v;\nextern void abort (void);\n\n__attribute__((noinline, noclone)) void\nfoo (int x, void *y, unsigned int z, unsigned int w)\n{\n  if (x != 4 || y != (void *) &u.v.v2)\n    abort ();\n  v = z + w;\n  v = 16384;\n}\n\n__attribute__((noinline, noclone)) void\nbar (struct S x)\n{\n  v = x.s1;\n  v = x.s2;\n}\n\n__attribute__((noinline, noclone)) int\nbaz (struct S *x)\n{\n  v = x->s1;\n  v = x->s2;\n  v = 0;\n  return v + 1;\n}\n\n__attribute__((noinline, noclone)) void\ntest (struct S *c)\n{\n  struct T *d;\n  struct S e = a;\n  unsigned int f, g;\n  if (c == 0)\n    c = &e;\n  else\n    {\n      if (c->s2 % 8192 <= 15 || (8192 - c->s2 % 8192) <= 31)\n\tfoo (1, 0, c->s1, c->s2);\n    }\n  if (!baz (c))\n    return;\n  g = (((struct U *) b)->u2 & 2) ? 32 : __builtin_offsetof (struct V, v2);\n  f = c->s2 % 8192;\n  if (f == 0)\n    {\n      e.s2 += g;\n      f = g;\n    }\n  else if (f < g)\n    {\n      foo (2, 0, c->s1, c->s2);\n      return;\n    }\n  if ((((struct U *) b)->u2 & 1) && f == g)\n    {\n      bar (*c);\n      foo (3, 0, c->s1, c->s2);\n      return;\n    }\n  d = (struct T *) (b + c->s2 % 8192);\n  if (d->t2.s1 >= c->s1 && (d->t2.s1 != c->s1 || d->t2.s2 >= c->s2))\n    foo (4, d, c->s1, c->s2);\n  return;\n}\n\nint\nmain ()\n{\n  struct S *c = 0;\n  asm (\"\" : \"+r\" (c) : \"r\" (&a));\n  u.v.v2.t2.s1 = 8192;\n  b = u.b;\n  test (c);\n  if (v != 16384)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49419.c",
    "content": "/* PR tree-optimization/49419 */\n\nextern void abort (void);\n\nstruct S { int w, x, y; } *t;\n\nint\nfoo (int n, int f, int *s, int m)\n{\n  int x, i, a;\n  if (n == -1)\n    return 0;\n  for (x = n, i = 0; t[x].w == f && i < m; i++)\n    x = t[x].x;\n  if (i == m)\n    abort ();\n  a = i + 1;\n  for (x = n; i > 0; i--)\n    {\n      s[i] = t[x].y;\n      x = t[x].x;\n    }\n  s[0] = x;\n  return a;\n}\n\nint\nmain (void)\n{\n  int s[3], i;\n  struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } };\n  t = buf;\n  if (foo (0, 1, s, 3) != 2)\n    abort ();\n  if (s[0] != 1 || s[1] != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49644.c",
    "content": "/* PR c/49644 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  _Complex double a[12], *c = a, s = 3.0 + 1.0i;\n  double b[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, *d = b;\n  int i;\n  for (i = 0; i < 6; i++)\n    *c++ = *d++ * s;\n  if (c != a + 6 || d != b + 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49712.c",
    "content": "/* PR tree-optimization/49712 */\n\nint a[2], b, c, d, e;\n\nvoid\nfoo (int x, int y)\n{\n}\n\nint\nbar (void)\n{\n  int i;\n  for (; d <= 0; d = 1)\n    for (i = 0; i < 4; i++)\n      for (e = 0; e; e = 1)\n\t;\n  return 0;\n}\n\nint\nmain ()\n{\n  for (b = 0; b < 2; b++)\n    while (c)\n      foo (a[b] = 0, bar ());\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49768.c",
    "content": "/* PR tree-optimization/49768 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  static struct { unsigned int : 1; unsigned int s : 1; } s = { .s = 1 };\n  if (s.s != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr49886.c",
    "content": "struct PMC {\n    unsigned flags;\n};\n\ntypedef struct Pcc_cell\n{\n    struct PMC *p;\n    long bla;\n    long type;\n} Pcc_cell;\n\nint gi;\nint cond;\n\nextern void abort ();\nextern void never_ever(int interp, struct PMC *pmc)\n  __attribute__((noinline,noclone));\n\nvoid never_ever (int interp, struct PMC *pmc)\n{\n  abort ();\n}\n\nstatic void mark_cell(int * interp, Pcc_cell *c)\n  __attribute__((__nonnull__(1)));\n\nstatic void\nmark_cell(int * interp, Pcc_cell *c)\n{\n  if (!cond)\n    return;\n\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<18)))\n    never_ever(gi + 1, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<17)))\n    never_ever(gi + 2, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<16)))\n    never_ever(gi + 3, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<15)))\n    never_ever(gi + 4, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<14)))\n    never_ever(gi + 5, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<13)))\n    never_ever(gi + 6, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<12)))\n    never_ever(gi + 7, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<11)))\n    never_ever(gi + 8, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<10)))\n    never_ever(gi + 9, c->p);\n}\n\nstatic void\nfoo(int * interp, Pcc_cell *c)\n{\n  mark_cell(interp, c);\n}\n\nstatic struct Pcc_cell *\n__attribute__((noinline,noclone))\ngetnull(void)\n{\n  return (struct Pcc_cell *) 0;\n}\n\n\nint main()\n{\n  int i;\n\n  cond = 1;\n  for (i = 0; i < 100; i++)\n    foo (&gi, getnull ());\n  return 0;\n}\n\n\nvoid\nbar_1 (int * interp, Pcc_cell *c)\n{\n  c->bla += 1;\n  mark_cell(interp, c);\n}\n\nvoid\nbar_2 (int * interp, Pcc_cell *c)\n{\n  c->bla += 2;\n  mark_cell(interp, c);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr50865.c",
    "content": "/* PR middle-end/50865 */\n\n#define INT64_MIN (-__LONG_LONG_MAX__ - 1)\n\nint\nmain ()\n{\n  volatile long long l1 = 1;\n  volatile long long l2 = -1;\n  volatile long long l3 = -1;\n\n  if ((INT64_MIN % 1LL) != 0)\n    __builtin_abort ();\n  if ((INT64_MIN % l1) != 0)\n    __builtin_abort ();\n  if (l2 == -1)\n    {\n      if ((INT64_MIN % 1LL) != 0)\n\t__builtin_abort ();\n    }\n  else if ((INT64_MIN % -l2) != 0)\n    __builtin_abort ();\n  if ((INT64_MIN % -l3) != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51023.c",
    "content": "/* PR rtl-optimization/51023 */\n\nextern void abort (void);\n\nshort int\nfoo (long int x)\n{\n  return x;\n}\n\nint\nmain ()\n{\n  long int a = 0x4272AL;\n  if (foo (a) == a)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51323.c",
    "content": "/* PR middle-end/51323 */\n\nextern void abort (void);\nstruct S { int a, b, c; };\nint v;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int y, int z)\n{\n  if (x != v || y != 0 || z != 9)\n    abort ();\n}\n\nstatic inline int\nbaz (const struct S *p)\n{\n  return p->b;\n}\n\n__attribute__((noinline, noclone)) void\nbar (int x, struct S y)\n{\n  foo (baz (&y), 0, x);\n}\n\nint\nmain ()\n{\n  struct S s;\n  v = 3; s.a = v - 1; s.b = v; s.c = v + 1;\n  bar (9, s);\n  v = 17; s.a = v - 1; s.b = v; s.c = v + 1;\n  bar (9, s);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51447.c",
    "content": "/* PR rtl-optimization/51447 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\n#ifdef __x86_64__\nregister void *ptr asm (\"rbx\");\n#else\nvoid *ptr;\n#endif\n\nint\nmain (void)\n{\n  __label__ nonlocal_lab;\n  __attribute__((noinline, noclone)) void\n    bar (void *func)\n      {\n\tptr = func;\n\tgoto nonlocal_lab;\n      }\n  bar (&&nonlocal_lab);\n  return 1;\nnonlocal_lab:\n  if (ptr != &&nonlocal_lab)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51466.c",
    "content": "/* PR tree-optimization/51466 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nfoo (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[i];\n  return *p;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[i];\n  *p = 8;\n  return v[i];\n}\n\n__attribute__((noinline, noclone)) int\nbaz (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[0];\n  *p = 8;\n  return v[i];\n}\n\nint\nmain ()\n{\n  if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51581-1.c",
    "content": "/* PR tree-optimization/51581 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\n#define N 4096\nint a[N], c[N];\nunsigned int b[N], d[N];\n\n__attribute__((noinline, noclone)) void\nf1 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 3;\n}\n\n__attribute__((noinline, noclone)) void\nf2 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 3;\n}\n\n__attribute__((noinline, noclone)) void\nf3 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 18;\n}\n\n__attribute__((noinline, noclone)) void\nf4 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 18;\n}\n\n__attribute__((noinline, noclone)) void\nf5 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 19;\n}\n\n__attribute__((noinline, noclone)) void\nf6 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 19;\n}\n\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) void\nf7 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf8 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);\n}\n\n__attribute__((noinline, noclone)) void\nf9 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf10 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;\n}\n\n__attribute__((noinline, noclone)) void\nf11 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf12 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;\n      d[i] = (((b[i] - tmp) >> 1) + tmp) >> 4;\n    }\n}\n#endif\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      asm (\"\");\n      a[i] = i - N / 2;\n      b[i] = i;\n    }\n  a[0] = -__INT_MAX__ - 1;\n  a[1] = -__INT_MAX__;\n  a[N - 1] = __INT_MAX__;\n  b[N - 1] = ~0;\n  f1 ();\n  f2 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 3 || d[i] != b[i] / 3)\n      abort ();\n  f3 ();\n  f4 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 18 || d[i] != b[i] / 18)\n      abort ();\n  f5 ();\n  f6 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 19 || d[i] != b[i] / 19)\n      abort ();\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  f7 ();\n  f8 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 3 || d[i] != b[i] / 3)\n      abort ();\n  f9 ();\n  f10 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 18 || d[i] != b[i] / 18)\n      abort ();\n  f11 ();\n  f12 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 19 || d[i] != b[i] / 19)\n      abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51581-2.c",
    "content": "/* PR tree-optimization/51581 */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\n#define N 4096\nint a[N], c[N];\nunsigned int b[N], d[N];\n\n__attribute__((noinline, noclone)) void\nf1 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 3;\n}\n\n__attribute__((noinline, noclone)) void\nf2 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 3;\n}\n\n__attribute__((noinline, noclone)) void\nf3 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 18;\n}\n\n__attribute__((noinline, noclone)) void\nf4 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 18;\n}\n\n__attribute__((noinline, noclone)) void\nf5 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 19;\n}\n\n__attribute__((noinline, noclone)) void\nf6 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 19;\n}\n\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) void\nf7 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);\n      c[i] = a[i] - x * 3;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf8 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int x = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);\n      d[i] = b[i] - x * 3;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf9 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);\n      c[i] = a[i] - x * 18;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf10 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int x = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;\n      d[i] = b[i] - x * 18;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf11 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);\n      c[i] = a[i] - x * 19;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf12 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;\n      unsigned int x = (((b[i] - tmp) >> 1) + tmp) >> 4;\n      d[i] = b[i] - x * 19;\n    }\n}\n#endif\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      asm (\"\");\n      a[i] = i - N / 2;\n      b[i] = i;\n    }\n  a[0] = -__INT_MAX__ - 1;\n  a[1] = -__INT_MAX__;\n  a[N - 1] = __INT_MAX__;\n  b[N - 1] = ~0;\n  f1 ();\n  f2 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 3 || d[i] != b[i] % 3)\n      abort ();\n  f3 ();\n  f4 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 18 || d[i] != b[i] % 18)\n      abort ();\n  f5 ();\n  f6 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 19 || d[i] != b[i] % 19)\n      abort ();\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  f7 ();\n  f8 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 3 || d[i] != b[i] % 3)\n      abort ();\n  f9 ();\n  f10 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 18 || d[i] != b[i] % 18)\n      abort ();\n  f11 ();\n  f12 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 19 || d[i] != b[i] % 19)\n      abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51877.c",
    "content": "/* PR tree-optimization/51877 */\n\nextern void abort (void);\nstruct A { int a; char b[32]; } a, b;\n\n__attribute__((noinline, noclone))\nstruct A\nbar (int x)\n{\n  struct A r;\n  static int n;\n  r.a = ++n;\n  __builtin_memset (r.b, 0, sizeof (r.b));\n  r.b[0] = x;\n  return r;\n}\n\n__attribute__((noinline, noclone))\nvoid\nbaz (void)\n{\n  asm volatile (\"\" : : : \"memory\");\n}\n\n__attribute__((noinline, noclone))\nvoid\nfoo (struct A *x, int y)\n{\n  if (y == 6)\n    a = bar (7);\n  else\n    *x = bar (7);\n  baz ();\n}\n\nint\nmain ()\n{\n  a = bar (3);\n  b = bar (4);\n  if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4)\n    abort ();\n  foo (&b, 0);\n  if (a.a != 1 || a.b[0] != 3 || b.a != 3 || b.b[0] != 7)\n    abort ();\n  foo (&b, 6);\n  if (a.a != 4 || a.b[0] != 7 || b.a != 3 || b.b[0] != 7)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr51933.c",
    "content": "/* PR rtl-optimization/51933 */\n\nstatic signed char v1;\nstatic unsigned char v2[256], v3[256];\n\n__attribute__((noclone, noinline)) void\nfoo (void)\n{\n#if defined(__s390__) && !defined(__zarch__)\n  /* S/390 31 bit cannot deal with more than one literal pool\n     reference per insn.  */\n  asm volatile (\"\" : : \"g\" (&v1) : \"memory\");\n  asm volatile (\"\" : : \"g\" (&v2[0]));\n  asm volatile (\"\" : : \"g\" (&v3[0]));\n#else\n  asm volatile (\"\" : : \"g\" (&v1), \"g\" (&v2[0]), \"g\" (&v3[0]) : \"memory\");\n#endif\n}\n\n__attribute__((noclone, noinline)) int\nbar (const int x, const unsigned short *y, char *z)\n{\n  int i;\n  unsigned short u;\n  if (!v1)\n    foo ();\n  for (i = 0; i < x; i++)\n    {\n      u = y[i];\n      z[i] = u < 0x0100 ? v2[u] : v3[u & 0xff];\n    }\n  z[x] = '\\0';\n  return x;\n}\n\nint\nmain (void)\n{\n  char buf[18];\n  unsigned short s[18];\n  unsigned char c[18] = \"abcdefghijklmnopq\";\n  int i;\n  for (i = 0; i < 256; i++)\n    {\n      v2[i] = i;\n      v3[i] = i + 1;\n    }\n  for (i = 0; i < 18; i++)\n    s[i] = c[i];\n  s[5] |= 0x600;\n  s[6] |= 0x500;\n  s[11] |= 0x2000;\n  s[15] |= 0x500;\n  foo ();\n  if (bar (17, s, buf) != 17\n      || __builtin_memcmp (buf, \"abcdeghhijkmmnoqq\", 18) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52129.c",
    "content": "/* PR target/52129 */\n/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\n\nextern void abort (void);\nstruct S { void *p; unsigned int q; };\nstruct T { char a[64]; char b[64]; } t;\n\n__attribute__((noinline, noclone)) int\nfoo (void *x, struct S s, void *y, void *z)\n{\n  if (x != &t.a[2] || s.p != &t.b[5] || s.q != 27 || y != &t.a[17] || z != &t.b[17])\n    abort ();\n  return 29;\n}\n\n__attribute__((noinline, noclone)) int\nbar (void *x, void *y, void *z, struct S s, int t, struct T *u)\n{\n  return foo (x, s, &u->a[t], &u->b[t]);\n}\n\nint\nmain ()\n{\n  struct S s = { &t.b[5], 27 };\n  if (bar (&t.a[2], (void *) 0, (void *) 0, s, 17, &t) != 29)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52209.c",
    "content": "/* PR middle-end/52209 */\n\nextern void abort (void);\nstruct S0 { int f2 : 1; } c;\nint b;\n\nint\nmain ()\n{\n  b = -1 ^ c.f2;\n  if (b != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52286.c",
    "content": "/* PR tree-optimization/52286 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n#if __SIZEOF_INT__ > 2\n  int a, b;\n  asm (\"\" : \"=r\" (a) : \"0\" (0));\n  b = (~a | 1) & -2038094497;\n#else\n  long a, b;\n  asm (\"\" : \"=r\" (a) : \"0\" (0));\n  b = (~a | 1) & -2038094497L;\n#endif\n  if (b >= 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52760.c",
    "content": "/* PR tree-optimization/52760 */\n\nstruct T { unsigned short a, b, c, d; };\n\n__attribute__((noinline, noclone)) void\nfoo (int x, struct T *y)\n{\n  int i;\n\n  for (i = 0; i < x; i++)\n    {\n      y[i].a = ((0x00ff & y[i].a >> 8) | (0xff00 & y[i].a << 8));\n      y[i].b = ((0x00ff & y[i].b >> 8) | (0xff00 & y[i].b << 8));\n      y[i].c = ((0x00ff & y[i].c >> 8) | (0xff00 & y[i].c << 8));\n      y[i].d = ((0x00ff & y[i].d >> 8) | (0xff00 & y[i].d << 8));\n    }\n}\n\nint\nmain ()\n{\n  struct T t = { 0x0001, 0x0203, 0x0405, 0x0607 };\n  foo (1, &t);\n  if (t.a != 0x0100 || t.b != 0x0302 || t.c != 0x0504 || t.d != 0x0706)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52979-1.c",
    "content": "/* PR middle-end/52979 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nint c, d, e;\n\nvoid\nfoo (void)\n{\n}\n\nstruct __attribute__((packed)) S { int g : 31; int h : 6; };\nstruct S a = { 1 };\nstatic struct S b = { 1 };\n\nvoid\nbar (void)\n{\n  a.h = 1;\n  struct S f = { };\n  b = f;\n  e = 0;\n  if (d)\n    c = a.g;\n}\n\nvoid\nbaz (void)\n{\n  bar ();\n  a = b;\n}\n\nint\nmain ()\n{\n  baz ();\n  if (a.g)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr52979-2.c",
    "content": "/* PR middle-end/52979 */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nint c, d, e;\n\nvoid\nfoo (void)\n{\n}\n\nstruct __attribute__((packed)) S { int g : 31; int h : 6; };\nstatic struct S b = { 1 };\nstruct S a = { 1 };\n\nvoid\nbar (void)\n{\n  a.h = 1;\n  struct S f = { };\n  b = f;\n  e = 0;\n  if (d)\n    c = a.g;\n}\n\nvoid\nbaz (void)\n{\n  bar ();\n  a = b;\n}\n\nint\nmain ()\n{\n  baz ();\n  if (a.g)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53084.c",
    "content": "/* PR middle-end/53084 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) void\nbar (const char *p)\n{\n  if (p[0] != 'o' || p[1] != 'o' || p[2])\n    abort ();\n}\n\nint\nmain ()\n{\n  static const char *const foo[] = {\"foo\" + 1};\n  bar (foo[0]);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53160.c",
    "content": "/* PR rtl-optimization/53160 */\n\nextern void abort (void);\n\nint a, c = 1, d, e, g;\nvolatile int b;\nvolatile char f;\nlong h;\nshort i;\n\nvoid\nfoo (void)\n{\n  for (e = 0; e; ++e)\n    ;\n}\n\nint\nmain ()\n{\n  if (g)\n    (void) b;\n  foo ();\n  for (d = 0; d >= 0; d--)\n    {\n      short j = f;\n      int k = 0;\n      i = j ? j : j << k;\n    }\n  h = c == 0 ? 0 : i;\n  a = h;\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53465.c",
    "content": "/* PR tree-optimization/53465 */\n\nextern void abort ();\n\nstatic const int a[] = { 1, 2 };\n\nvoid\nfoo (const int *x, int y)\n{\n  int i;\n  int b = 0;\n  int c;\n  for (i = 0; i < y; i++)\n    {\n      int d = x[i];\n      if (d == 0)\n\tbreak;\n      if (b && d <= c)\n\tabort ();\n      c = d;\n      b = 1;\n    }\n}\n\nint\nmain ()\n{\n  foo (a, 2);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53645-2.c",
    "content": "/* PR tree-optimization/53645 */\n/* { dg-options \"-std=gnu89\" } */\n\ntypedef unsigned short int UV __attribute__((vector_size (16)));\ntypedef short int SV __attribute__((vector_size (16)));\nextern void abort (void);\n\n#define TEST(a, b, c, d, e, f, g, h) \\\n__attribute__((noinline)) void\t\t\t\\\nuq##a##b##c##d##e##f##g##h (UV *x, UV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y / ((UV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nur##a##b##c##d##e##f##g##h (UV *x, UV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y % ((UV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nsq##a##b##c##d##e##f##g##h (SV *x, SV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y / ((SV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nsr##a##b##c##d##e##f##g##h (SV *x, SV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y % ((SV) { a, b, c, d, e, f, g, h });\t\\\n}\n\n#define TESTS \\\nTEST (4, 4, 4, 4, 4, 4, 4, 4)\t\t\\\nTEST (1, 4, 2, 8, 16, 64, 32, 128)\t\\\nTEST (3, 3, 3, 3, 3, 3, 3, 3)\t\t\\\nTEST (6, 5, 6, 5, 6, 5, 6, 5)\t\t\\\nTEST (14, 14, 14, 6, 14, 6, 14, 14)\t\\\nTEST (7, 7, 7, 7, 7, 7, 7, 7)\t\t\\\n\nTESTS\n\nUV u[] =\n  { ((UV) { 73U, 65531U, 0U, 174U, 921U, 65535U, 17U, 178U }),\n    ((UV) { 1U, 8173U, 65535U, 65472U, 12U, 29612U, 128U, 8912U }) };\nSV s[] =\n  { ((SV) { 73, -9123, 32761, 8191, 16371, 1201, 12701, 9999 }),\n    ((SV) { 9903, -1, -7323, 0, -7, -323, 9124, -9199 }) };\n\nint\nmain ()\n{\n  UV ur, ur2;\n  SV sr, sr2;\n  int i;\n#undef TEST\n#define TEST(a, b, c, d, e, f, g, h)\t\t\t\\\n    uq##a##b##c##d##e##f##g##h (&ur, u + i);\t\t\\\n    if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[4] != u[i][4] / e || ur[7] != u[i][7] / h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[6] != u[i][6] / g || ur[5] != u[i][5] / f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    ur##a##b##c##d##e##f##g##h (&ur, u + i);\t\t\\\n    if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[4] != u[i][4] % e || ur[7] != u[i][7] % h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[6] != u[i][6] % g || ur[5] != u[i][5] % f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\n  for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)\n    {\n      TESTS\n    }\n#undef TEST\n#define TEST(a, b, c, d, e, f, g, h)\t\t\t\\\n    sq##a##b##c##d##e##f##g##h (&sr, s + i);\t\t\\\n    if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[4] != s[i][4] / e || sr[7] != s[i][7] / h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[6] != s[i][6] / g || sr[5] != s[i][5] / f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    sr##a##b##c##d##e##f##g##h (&sr, s + i);\t\t\\\n    if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[4] != s[i][4] % e || sr[7] != s[i][7] % h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[6] != s[i][6] % g || sr[5] != s[i][5] % f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\n  for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)\n    {\n      TESTS\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53645.c",
    "content": "/* PR tree-optimization/53645 */\n/* { dg-options \"-std=gnu89\" } */\n\ntypedef unsigned int UV __attribute__((vector_size (16)));\ntypedef int SV __attribute__((vector_size (16)));\nextern void abort (void);\n\n#define TEST(a, b, c, d) \\\n__attribute__((noinline)) void\t\t\\\nuq##a##b##c##d (UV *x, UV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y / ((UV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nur##a##b##c##d (UV *x, UV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y % ((UV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nsq##a##b##c##d (SV *x, SV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y / ((SV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nsr##a##b##c##d (SV *x, SV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y % ((SV) { a, b, c, d });\t\\\n}\n\n#define TESTS \\\nTEST (4, 4, 4, 4)\t\t\t\\\nTEST (1, 4, 2, 8)\t\t\t\\\nTEST (3, 3, 3, 3)\t\t\t\\\nTEST (6, 5, 6, 5)\t\t\t\\\nTEST (14, 14, 14, 6)\t\t\t\\\nTEST (7, 7, 7, 7)\t\t\t\\\n\nTESTS\n\nUV u[] =\n  { ((UV) { 73U, 65531U, 0U, 174U }),\n    ((UV) { 1U, 8173U, ~0U, ~0U - 63 }) };\nSV s[] =\n  { ((SV) { 73, -9123, 32761, 8191 }),\n    ((SV) { 9903, -1, -7323, 0 }) };\n\nint\nmain ()\n{\n  UV ur, ur2;\n  SV sr, sr2;\n  int i;\n#undef TEST\n#define TEST(a, b, c, d)\t\t\t\t\\\n    uq##a##b##c##d (&ur, u + i);\t\t\t\\\n    if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    ur##a##b##c##d (&ur, u + i);\t\t\t\\\n    if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\n  for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)\n    {\n      TESTS\n    }\n#undef TEST\n#define TEST(a, b, c, d)\t\t\t\t\\\n    sq##a##b##c##d (&sr, s + i);\t\t\t\\\n    if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    sr##a##b##c##d (&sr, s + i);\t\t\t\\\n    if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\n  for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)\n    {\n      TESTS\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr53688.c",
    "content": "char headline[256];\nstruct hdr {\n  char part1[9];\n  char part2[8];\n} p;\n\nvoid __attribute__((noinline,noclone))\ninit()\n{\n  __builtin_memcpy (p.part1, \"FOOBARFOO\", sizeof (p.part1));\n  __builtin_memcpy (p.part2, \"SPEC CPU\", sizeof (p.part2));\n}\n\nint main()\n{\n  char *x;\n  int c;\n  init();\n  __builtin_memcpy (&headline[0], p.part1, 9);\n  c = 9;\n  x = &headline[0];\n  x = x + c;\n  __builtin_memset (x, ' ', 245);\n  __builtin_memcpy (&headline[10], p.part2, 8);\n  c = 18;\n  x = &headline[0];\n  x = x + c;\n  __builtin_memset (x, ' ', 238);\n  if (headline[10] != 'S')\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr54471.c",
    "content": "/* PR tree-optimization/54471 */\n\n#ifdef __SIZEOF_INT128__\n#define T __int128\n#else\n#define T long long\n#endif\n\nextern void abort (void);\n\n__attribute__ ((noinline))\nunsigned T\nfoo (T ixi, unsigned ctr)\n{\n  unsigned T irslt = 1;\n  T ix = ixi;\n\n  for (; ctr; ctr--)\n    {\n      irslt *= ix;\n      ix *= ix;\n    }\n\n  if (irslt != 14348907)\n    abort ();\n  return irslt;\n}\n\nint\nmain ()\n{\n  unsigned T res;\n\n  res = foo (3, 4);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr54937.c",
    "content": "\nvoid exit (int);\nvoid abort (void);\nint a[1];\nvoid (*terminate_me)(int);\n\n__attribute__((noinline,noclone))\nt(int c)\n{ int i;\n  for (i=0;i<c;i++)\n    {\n      if (i)\n       terminate_me(0);\n      a[i]=0;\n    }\n}\nmain()\n{\n  terminate_me = exit;\n  t(100);\n  abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr54985.c",
    "content": "\ntypedef struct st {\n    int a;\n} ST;\n\nint __attribute__((noinline,noclone))\nfoo(ST *s, int c)\n{\n  int first = 1;\n  int count = c;\n  ST *item = s;\n  int a = s->a;\n  int x;\n\n  while (count--)\n    {\n      x = item->a;\n      if (first)\n        first = 0;\n      else if (x >= a)\n        return 1;\n      a = x;\n      item++;\n    }\n  return 0;\n}\n\nextern void abort (void);\n\nint main ()\n{\n  ST _1[2] = {{2}, {1}};\n  if (foo(_1, 2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr55137.c",
    "content": "/* PR c++/55137 */\n\nextern void abort (void);\n\nint\nfoo (unsigned int x)\n{\n  return ((int) (x + 1U) + 1) < (int) x;\n}\n\nint\nbar (unsigned int x)\n{\n  return (int) (x + 1U) + 1;\n}\n\nint\nbaz (unsigned int x)\n{\n  return x + 1U;\n}\n\nint\nmain ()\n{\n  if (foo (__INT_MAX__) != (bar (__INT_MAX__) < __INT_MAX__)\n      || foo (__INT_MAX__) != ((int) baz (__INT_MAX__) + 1 < __INT_MAX__))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr55750.c",
    "content": "/* PR middle-end/55750 */\n\nextern void abort (void);\n\nstruct S\n{\n  int m : 1;\n  int n : 7;\n} arr[2];\n\n__attribute__((noinline, noclone)) void\nfoo (unsigned i)\n{\n  arr[i].n++;\n}\n\nint\nmain ()\n{\n  arr[0].m = -1;\n  arr[0].n = (1 << 6) - 1;\n  arr[1].m = 0;\n  arr[1].n = -1;\n  foo (0);\n  foo (1);\n  if (arr[0].m != -1 || arr[0].n != -(1 << 6) || arr[1].m != 0 || arr[1].n != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr55875.c",
    "content": "int a[251];\n__attribute__ ((noinline))\nt(int i)\n{\n  if (i==0)\n    exit(0);\n  if (i>255)\n    abort ();\n}\nmain()\n{\n  unsigned int i;\n  for (i=0;;i++)\n    {\n      a[i]=t((unsigned char)(i+5));\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56051.c",
    "content": "/* PR tree-optimization/56051 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  unsigned char x1[1] = { 0 };\n  unsigned int s1 = __CHAR_BIT__;\n  int a1 = x1[0] < (unsigned char) (1 << s1);\n  unsigned char y1 = (unsigned char) (1 << s1);\n  int b1 = x1[0] < y1;\n  if (a1 != b1)\n    abort ();\n#if __SIZEOF_LONG_LONG__ > __SIZEOF_INT__\n  unsigned long long x2[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };\n  unsigned int s2 = sizeof (int) * __CHAR_BIT__ - 1;\n  int a2 = x2[0] >= (unsigned long long) (1 << s2);\n  unsigned long long y2 = 1 << s2;\n  int b2 = x2[0] >= y2;\n  if (a2 != b2)\n    abort ();\n  unsigned long long x3[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };\n  unsigned int s3 = sizeof (int) * __CHAR_BIT__ - 1;\n  int a3 = x3[0] >= (unsigned long long) (1U << s3);\n  unsigned long long y3 = 1U << s3;\n  int b3 = x3[0] >= y3;\n  if (a3 != b3)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56205.c",
    "content": "/* PR tree-optimization/56205 */\n\n#include <stdarg.h>\n\nint a, b;\nchar c[128];\n\n__attribute__((noinline, noclone)) static void\nf1 (const char *fmt, ...)\n{\n  va_list ap;\n  asm volatile (\"\" : : : \"memory\");\n  if (__builtin_strcmp (fmt, \"%s %d %s\") != 0)\n    __builtin_abort ();\n  va_start (ap, fmt);\n  if (__builtin_strcmp (va_arg (ap, const char *), \"foo\") != 0\n      || va_arg (ap, int) != 1\n      || __builtin_strcmp (va_arg (ap, const char *), \"bar\") != 0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\n__attribute__((noinline, noclone)) static void\nf2 (const char *fmt, va_list ap)\n{\n  asm volatile (\"\" : : : \"memory\");\n  if (__builtin_strcmp (fmt, \"baz\") != 0\n      || __builtin_strcmp (va_arg (ap, const char *), \"foo\") != 0\n      || va_arg (ap, double) != 12.0\n      || va_arg (ap, int) != 26)\n    __builtin_abort ();\n}\n\nstatic void\nf3 (int x, char const *y, va_list z)\n{\n  f1 (\"%s %d %s\", x ? \"\" : \"foo\", ++a, (y && *y) ? \"bar\" : \"\");\n  if (y && *y)\n    f2 (y, z);\n}\n\n__attribute__((noinline, noclone)) void\nf4 (int x, char const *y, ...)\n{\n  va_list z;\n  va_start (z, y);\n  if (!x && *c == '\\0')\n    ++b;\n  f3 (x, y, z);\n  va_end (z);\n}\n\nint\nmain ()\n{\n  asm volatile (\"\" : : : \"memory\");\n  f4 (0, \"baz\", \"foo\", 12.0, 26);\n  if (a != 1 || b != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56250.c",
    "content": "/* PR tree-optimization/56250 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  unsigned int x = 2;\n  unsigned int y = (0U - x / 2) / 2;\n  if (-1U / x != y)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56799.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#include <stdio.h>\ntypedef struct { int x; int y;} S;\nextern int foo(S*);\nint hi = 0, lo = 0;\n\nint main()\n{\n  S a;\n  int r;\n  a.x = (int) 0x00010000;\n  a.y = 1;\n  r = foo (&a);\n  if (r == 2 && lo==0 && hi==1)\n    {\n      exit (0);\n    }\n  abort ();\n}\n\ntypedef unsigned short u16;\n\n__attribute__ ((noinline)) int foo (S* ptr)\n{\n  int a = ptr->x;\n  int c = 0;\n  u16 b = (u16) a;\n  if (b != 0)\n  {\n    lo = 1;\n    c += ptr->y;\n  }\n  b = a >> 16;\n  if (b != 0)\n  {\n    hi = 1;\n    c+= ptr->y;\n  }\n  c += ptr->y;\n  return c;\n}\n\n     \n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56837.c",
    "content": "extern void abort (void);\n_Complex int a[1024];\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  int i;\n  for (i = 0; i < 1024; i++)\n    a[i] = -1;\n}\n\nint\nmain ()\n{\n  int i;\n  foo ();\n  for (i = 0; i < 1024; i++)\n    if (a[i] != -1)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56866.c",
    "content": "/* PR target/56866 */\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_SHORT__ == 2\n  unsigned long long wq[256], rq[256];\n  unsigned int wi[256], ri[256];\n  unsigned short ws[256], rs[256];\n  unsigned char wc[256], rc[256];\n  int t;\n\n  __builtin_memset (wq, 0, sizeof wq);\n  __builtin_memset (wi, 0, sizeof wi);\n  __builtin_memset (ws, 0, sizeof ws);\n  __builtin_memset (wc, 0, sizeof wc);\n  wq[0] = 0x0123456789abcdefULL;\n  wi[0] = 0x01234567;\n  ws[0] = 0x4567;\n  wc[0] = 0x73;\n\n  asm volatile (\"\" : : \"g\" (wq), \"g\" (wi), \"g\" (ws), \"g\" (wc) : \"memory\");\n\n  for (t = 0; t < 256; ++t)\n    rq[t] = (wq[t] >> 8) | (wq[t] << (sizeof (wq[0]) * __CHAR_BIT__ - 8));\n  for (t = 0; t < 256; ++t)\n    ri[t] = (wi[t] >> 8) | (wi[t] << (sizeof (wi[0]) * __CHAR_BIT__ - 8));\n  for (t = 0; t < 256; ++t)\n    rs[t] = (ws[t] >> 9) | (ws[t] << (sizeof (ws[0]) * __CHAR_BIT__ - 9));\n  for (t = 0; t < 256; ++t)\n    rc[t] = (wc[t] >> 5) | (wc[t] << (sizeof (wc[0]) * __CHAR_BIT__ - 5));\n\n  asm volatile (\"\" : : \"g\" (rq), \"g\" (ri), \"g\" (rs), \"g\" (rc) : \"memory\");\n\n  if (rq[0] != 0xef0123456789abcdULL || rq[1])\n    __builtin_abort ();\n  if (ri[0] != 0x67012345 || ri[1])\n    __builtin_abort ();\n  if (rs[0] != 0xb3a2 || rs[1])\n    __builtin_abort ();\n  if (rc[0] != 0x9b || rc[1])\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56899.c",
    "content": "/* PR tree-optimization/56899 */\n\n#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8\n__attribute__((noinline, noclone)) void\nf1 (int v)\n{\n  int x = -214748365 * (v - 1);\n  if (x != -1932735285)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf2 (int v)\n{\n  int x = 214748365 * (v + 1);\n  if (x != -1932735285)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf3 (unsigned int v)\n{\n  unsigned int x = -214748365U * (v - 1);\n  if (x != -1932735285U)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf4 (unsigned int v)\n{\n  unsigned int x = 214748365U * (v + 1);\n  if (x != -1932735285U)\n    __builtin_abort ();\n}\n#endif\n\nint\nmain ()\n{\n#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8\n  f1 (10);\n  f2 (-10);\n  f3 (10);\n  f4 (-10U);\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56962.c",
    "content": "/* PR tree-optimization/56962 */\n\nextern void abort (void);\nlong long v[144];\n\n__attribute__((noinline, noclone)) void\nbar (long long *x)\n{\n  if (x != &v[29])\n    abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (long long *x, long y, long z)\n{\n  long long a, b, c;\n  a = x[z * 4 + y * 3];\n  b = x[z * 5 + y * 3];\n  c = x[z * 5 + y * 4];\n  x[y * 4] = a;\n  bar (&x[z * 5 + y]);\n  x[z * 5 + y * 5] = b + c;\n}\n\nint\nmain ()\n{\n  foo (v, 24, 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr56982.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n#include <setjmp.h>\n\nextern void abort (void);\nextern void exit (int);\n\nstatic jmp_buf env;\n\nvoid baz (void)\n{\n  __asm__ volatile (\"\" : : : \"memory\");\n}\n\nstatic inline int g(int x)\n{\n    if (x)\n    {\n        baz();\n        return 0;\n    }\n    else\n    {\n        baz();\n        return 1;\n    }\n}\n\nint f(int *e)\n{\n    if (*e)\n      return 1;\n\n    int x = setjmp(env);\n    int n = g(x);\n    if (n == 0)\n      exit(0);\n    if (x)\n      abort();\n    longjmp(env, 42);\n}\n\nint main(int argc, char** argv)\n{\n    int v = 0;\n    return f(&v);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57124.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-fno-strict-overflow\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__ ((noinline)) void\nfoo(short unsigned int *p1, short unsigned int *p2)\n{\n  short unsigned int x1, x4;\n  int x2, x3, x5, x6;\n  unsigned int x7;\n  \n  x1 = *p1;\n  x2 = (int) x1;\n  x3 = x2 * 65536;\n  x4 = *p2;\n  x5 = (int) x4;\n  x6 = x3 + x4;\n  x7 = (unsigned int) x6;\n  if (x7 <= 268435455U)\n    abort ();\n  exit (0);\n}\n\nint\nmain()\n{\n  short unsigned int x, y;\n  x = -5;\n  y = -10;\n  foo (&x, &y);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57130.c",
    "content": "/* PR rtl-optimization/57130 */\n\nstruct S { int a, b, c, d; } s[2] = { { 6, 8, -8, -5 }, { 0, 2, -1, 2 } };\n\n__attribute__((noinline, noclone)) void\nfoo (struct S r)\n{\n  static int cnt;\n  if (__builtin_memcmp (&r, &s[cnt++], sizeof r) != 0)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  struct S r = { 6, 8, -8, -5 };\n  foo (r);\n  r = (struct S) { 0, 2, -1, 2 };\n  foo (r);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57131.c",
    "content": "/* PR rtl-optimization/57131 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  volatile int x1 = 0;\n  volatile long long x2 = 0;\n  volatile int x3 = 0;\n  volatile int x4 = 1;\n  volatile int x5 = 1;\n  volatile long long x6 = 1;\n  long long t = ((x1 * (x2 << x3)) / (x4 * x5)) + x6;\n\n  if (t != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57144.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid __attribute__ ((noinline))\nfoo(int a)\n{\n  int z = a > 0 ? a : -a;\n  long long x = z;\n  if (x > 0x100000000LL)\n    abort ();\n  else\n    exit (0);\n}\n\nint\nmain()\n{\n  foo (1);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57281.c",
    "content": "/* PR rtl-optimization/57281 */\n\nint a = 1, b, d, *e = &d;\nlong long c, *g = &c;\nvolatile long long f;\n\nint\nfoo (int h)\n{\n  int j = *g = b;\n  return h == 0 ? j : 0;\n}\n\nint\nmain ()\n{\n  int h = a;\n  for (; b != -20; b--)\n    {\n      (int) f;\n      *e = 0;\n      *e = foo (h);\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57321.c",
    "content": "/* PR tree-optimization/57321 */\n\nint a = 1, *b, **c;\n\nstatic int\nfoo (int *p)\n{\n  if (*p == a)\n    {\n      int *i[7][5] = { { 0 } };\n      int **j[1][1];\n      j[0][0] = &i[0][0];\n      *b = &p != c;\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  int i = 0;\n  foo (&i);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57344-1.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  int a : 11;\n#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32\n  int b : 22;\n#else\n  int b : 13;\n#endif\n  char c;\n  int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != -3161)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161L };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57344-2.c",
    "content": "/* PR middle-end/57344 */\n/* { dg-require-effective-target int32plus } */\n\nstruct __attribute__((packed)) S\n{\n  int a : 27;\n#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32\n  int b : 22;\n#else\n  int b : 13;\n#endif\n  char c;\n  int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != -3161)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161L };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57344-3.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  long long int a : 43;\n  long long int b : 22;\n  char c;\n  long long int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (long long int x)\n{\n  if (x != -3161LL)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161LL };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57344-4.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  long long int a : 59;\n  long long int b : 54;\n  char c;\n  long long int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (long long int x)\n{\n  if (x != -1220975898975746LL)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -1220975898975746LL };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57568.c",
    "content": "/* PR target/57568 */\n\nextern void abort (void);\nint a[6][9] = { }, b = 1, *c = &a[3][5];\n\nint\nmain ()\n{\n  if (b && (*c = *c + *c))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57829.c",
    "content": "/* PR rtl-optimization/57829 */\n\n__attribute__((noinline, noclone))\nint\nf1 (int k)\n{\n  return 2 | ((k - 1) >> ((int) sizeof (int) * __CHAR_BIT__ - 1));\n}\n\n__attribute__((noinline, noclone))\nlong int\nf2 (long int k)\n{\n  return 2L | ((k - 1L) >> ((int) sizeof (long int) * __CHAR_BIT__ - 1));\n}\n\n__attribute__((noinline, noclone))\nint\nf3 (int k)\n{\n  k &= 63;\n  return 4 | ((k + 2) >> 5);\n}\n\nint\nmain ()\n{\n  if (f1 (1) != 2 || f2 (1L) != 2L || f3 (63) != 6 || f3 (1) != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57860.c",
    "content": "/* PR rtl-optimization/57860 */\n\nextern void abort (void);\nint a, *b = &a, c, d, e, *f = &e, g, *h = &d, k[1] = { 1 };\n\nint\nfoo (int p)\n{\n  for (;; g++)\n    {\n      for (; c; c--);\n      *f = *h = p > ((0x1FFFFFFFFLL ^ a) & *b);\n      if (k[g])\n\treturn 0;\n    }\n}\n\nint\nmain ()\n{\n  foo (1);\n  if (d != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57861.c",
    "content": "/* PR rtl-optimization/57861 */\n\nextern void abort (void);\nshort a = 1, f;\nint b, c, d, *g = &b, h, i, j;\nunsigned int e;\n\nstatic int\nfoo (char p)\n{\n  int k;\n  for (c = 0; c < 2; c++)\n    {\n      i = (j = 0) || p;\n      k = i * p;\n      if (e < k)\n\t{\n\t  short *l = &f;\n\t  a = d && h;\n\t  *l = 0;\n\t}\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  *g = foo (a);\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57875.c",
    "content": "/* PR rtl-optimization/57875 */\n\nextern void abort (void);\nint a[1], b, c, d, f, i;\nchar e[1];\n\nint\nmain ()\n{\n  for (; i < 1; i++)\n    if (!d)\n      {\n\tif (!c)\n\t  f = 2;\n\te[0] &= f ^= 0;\n      }\n  b = a[e[0] >> 1 & 1];\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57876.c",
    "content": "/* PR rtl-optimization/57876 */\n\nextern void abort (void);\nint a, b = 1, c, *d = &c, f, *g, h, j;\nstatic int e;\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 2; i++)\n    {\n      long long k = b;\n      int l;\n      for (f = 0; f < 8; f++)\n\t{\n\t  int *m = &e;\n\t  j = *d;\n\t  h = a * j - 1;\n\t  *m = (h == 0) < k;\n\t  g = &l;\n\t}\n    }\n  if (e != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr57877.c",
    "content": "/* PR rtl-optimization/57877 */\n\nextern void abort (void);\nint a, b, *c = &b, e, f = 6, g, h;\nshort d;\n\nstatic unsigned char\nfoo (unsigned long long p1, int *p2)\n{\n  for (; g <= 0; g++)\n    {\n      short *i = &d;\n      int *j = &e;\n      h = *c;\n      *i = h;\n      *j = (*i == *p2) < p1;\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  foo (f, &a);\n  if (e != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58209.c",
    "content": "/* PR tree-optimization/58209 */\n\nextern void abort (void);\ntypedef __INTPTR_TYPE__ T;\nT buf[1024];\n\nT *\nfoo (T n)\n{\n  if (n == 0)\n    return (T *) buf;\n  T s = (T) foo (n - 1);\n  return (T *) (s + sizeof (T));\n}\n\nT *\nbar (T n)\n{\n  if (n == 0)\n    return buf;\n  return foo (n - 1) + 1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 27; i++)\n    if (foo (i) != buf + i || bar (i) != buf + i)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c",
    "content": "/* PR tree-optimization/58277 */\n\nextern void abort (void);\nstatic int a[2];\nint b, c, d, *e, f, g, h, **i = &e, k, l = 1, n, o, p;\nstatic int **volatile j = &e;\nconst int m;\nchar u;\n\nint\nbar ()\n{\n  u = 0;\n  return m;\n}\n\n__attribute__((noinline, noclone)) void\nbaz ()\n{\n  asm (\"\");\n}\n\nstatic int\nfoo ()\n{\n  int t1;\n  g = bar ();\n  if (l)\n    ;\n  else\n    for (;; h++)\n      {\n\t*i = 0;\n\to = *e = 0;\n\tif (p)\n\t  {\n\t    f = 0;\n\t    return 0;\n\t  }\n\tfor (;; k++)\n\t  {\n\t    int *t2 = 0;\n\t    int *const *t3[] = {\n\t      0, 0, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, &t2, &t2, &t2,\n\t      &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0,\n\t      0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, &t2,\n\t      &t2, &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0,\n\t      &t2, 0, 0, 0, &t2, 0, &t2, 0, 0, &t2, 0, 0, 0, 0,\n\t      0, &t2, 0, 0, 0, 0, &t2, &t2, 0, 0, 0, 0, &t2, 0,\n\t      0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, &t2, 0, 0, 0,\n\t      &t2, &t2\n\t    };\n\t    int *const **t4[] = {&t3[0]};\n\t    **i = 0;\n\t    if (**j)\n\t      break;\n\t    u = 0;\n\t  }\n\t*i = *j;\n\tt1 = 0;\n\tfor (; t1 < 5; t1++)\n\t  *i = *j;\n      }\n  *j = 0;\n  return 1;\n}\n\nint\nmain ()\n{\n  int t5;\n  a[0] = 1;\n  {\n    int *t6[6] = {&d, &d};\n    for (n = 1; n; n--)\n      if (foo())\n\t{\n\t  int *t7[] = {0};\n\t  d = 0;\n\t  for (; u < 1; u++)\n\t    *i = *j;\n\t  *i = 0;\n\t  *i = 0;\n\t  int t8[5] = {0};\n\t  *i = &t8[0];\n\t  int *const *t9 = &t6[0];\n\t  int *const **t10 = &t9;\n\t  *t10 = &t7[0];\n\t}\n  }\n  u = 0;\n  for (; b; b++)\n    for (t5 = 0; t5 < 10; t5++)\n      c = a[a[a[a[a[a[a[a[c]]]]]]]];\n\n  baz ();\n\n  if (!a[a[a[a[a[a[a[a[a[a[a[a[a[a[a[u]]]]]]]]]]]]]]])\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c",
    "content": "/* PR tree-optimization/58277 */\n\nextern void abort (void);\nstatic int a[1], b, c, e, i, j, k, m, q[] = { 1, 1 }, t;\nint volatile d;\nint **r;\nstatic int ***volatile s = &r;\nint f, g, o, x;\nstatic int *volatile h = &f, *p;\nchar n;\n\nstatic void\nfn1 ()\n{\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[b]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n}\n\nstatic int\nfn2 ()\n{\n  n = 0;\n  for (; g; t++)\n    {\n      for (;; m++)\n\t{\n\t  d;\n\t  int *u;\n\t  int **v[] = {\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, &u, 0, 0, 0, 0, &u, &u, &u, &u, &u, &u, &u, 0,\n\t    &u, 0, &u, &u, &u, 0, &u, &u, 0, &u, &u, &u, &u, 0, &u, &u, &u,\n\t    &u, &u, 0, &u, &u, 0, &u, 0, &u, &u, 0, &u, &u, &u, &u, &u, 0,\n\t    &u, 0, 0, 0, &u, &u, &u, 0, 0, &u, &u, &u, 0, &u, 0, &u, &u\n\t  };\n\t  int ***w[] = { &v[0] };\n\t  if (*p)\n\t    break;\n\t  return 0;\n\t}\n      *h = 0;\n    }\n  return 1;\n}\n\nstatic void\nfn3 ()\n{\n  int *y[] = { 0, 0, 0, 0, 0, 0, 0, 0 };\n  for (; i; i++)\n    x = 0;\n  if (fn2 ())\n    {\n      int *z[6] = { };\n      for (; n < 1; n++)\n\t*h = 0;\n      int t1[7];\n      for (; c; c++)\n\to = t1[0];\n      for (; e; e--)\n\t{\n\t  int **t2 = &y[0];\n\t  int ***t3 = &t2;\n\t  *t3 = &z[0];\n\t}\n    }\n  *s = 0;\n  for (n = 0;; n = 0)\n    {\n      int t4 = 0;\n      if (q[n])\n\tbreak;\n      *r = &t4;\n    }\n}\n\nint\nmain ()\n{\n  for (; j; j--)\n    a[0] = 0;\n  fn3 ();\n  for (; k; k++)\n    fn1 ();\n  fn1 ();\n \n  if (n)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58364.c",
    "content": "/* PR tree-optimization/58364 */\n\nint a = 1, b, c;\n\nint\nfoo (int x)\n{\n  return x < 0 ? 1 : x;\n}\n\nint\nmain ()\n{\n  if (foo (a > c == (b = 0)))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58365.c",
    "content": "/* PR rtl-optimization/58365 */\n\nextern void abort (void);\n\nstruct S\n{\n  volatile int a;\n  int b, c, d, e;\n} f;\nstatic struct S g, h;\nint i = 1;\n\nchar\nfoo (void)\n{\n  return i;\n}\n\nstatic struct S\nbar (void)\n{\n  if (foo ())\n    return f;\n  return g;\n}\n\nint\nmain ()\n{\n  h = bar ();\n  f.b = 1;\n  if (h.b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58385.c",
    "content": "/* PR tree-optimization/58385 */\n\nextern void abort (void);\n\nint a, b = 1;\n\nint\nfoo ()\n{\n  b = 0;\n  return 0;\n}\n\nint\nmain ()\n{\n  ((0 || a) & foo () >= 0) <= 1 && 1;\n  if (b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58387.c",
    "content": "extern void abort(void);\n\nint a = -1; \n\nint main ()\n{\n  int b = a == 0 ? 0 : -a;\n  if (b < 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58419.c",
    "content": "__attribute__((__noinline__))\nvoid\ndummy ()\n{\n  asm volatile(\"\");\n}\n\nint a, g, i, k, *p;\nsigned char b;\nchar e;\nshort c, h;\nstatic short *d = &c;\n\nchar\nfoo (int p1, int p2)\n{\n  return p1 - p2;\n}\n\nint\nbar ()\n{\n  short *q = &c;\n  *q = 1;\n  *p = 0;\n  return 0;\n}\n\nint\nmain ()\n{\n  for (b = -22; b >= -29; b--)\n    {\n      short *l = &h;\n      char *m = &e;\n      *l = a;\n      g = foo (*m = k && *d, 1 > i) || bar (); \n    }\n  dummy();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58431.c",
    "content": "char a, h;\nint b, d, e, g, j, k;\nvolatile int c;\nshort i;\n\nint\nmain ()\n{\n  int m;\n\n  m = i ^= 1;\n  for (b = 0; b < 1; b++)\n    {\n      char o = m;\n      g = k;\n      j = j || c;\n      if (a != o)\n\tfor (; d < 1; d++)\n\t  ;\n      else\n\t{\n\t  char *p = &h;\n\t  *p = 1;\n\t  for (; e; e++)\n\t    ;\n\t}\n    }\n\n  if (h != 0)\n    __builtin_abort(); \n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58564.c",
    "content": "/* PR middle-end/58564 */\n\nextern void abort (void);\nint a, b;\nshort *c, **d = &c;\n\nint\nmain ()\n{\n  b = (0, 0 > ((&c == d) & (1 && (a ^ 1)))) | 0U;\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58570.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#pragma pack(1)\nstruct S\n{\n  int f0:15;\n  int f1:29;\n};\n\nint e = 1, i;\nstatic struct S d[6];\n\nint\nmain (void)\n{\n  if (e)\n    {\n      d[i].f0 = 1;\n      d[i].f1 = 1;\n    }\n  if (d[0].f1 != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58574.c",
    "content": "/* PR target/58574 */\n\n__attribute__((noinline, noclone)) double\nfoo (double x)\n{\n  double t;\n  switch ((int) x)\n    {\n    case 0:\n      t = 2 * x - 1;\n      return 0.70878e-3 + (0.71234e-3 + (0.35779e-5 + (0.17403e-7 + (0.81710e-10 + (0.36885e-12 + 0.15917e-14 * t) * t) * t) * t) * t) * t;\n    case 1:\n      t = 2 * x - 3;\n      return 0.21479e-2 + (0.72686e-3 + (0.36843e-5 + (0.18071e-7 + (0.85496e-10 + (0.38852e-12 + 0.16868e-14 * t) * t) * t) * t) * t) * t;\n    case 2:\n      t = 2 * x - 5;\n      return 0.36165e-2 + (0.74182e-3 + (0.37948e-5 + (0.18771e-7 + (0.89484e-10 + (0.40935e-12 + 0.17872e-14 * t) * t) * t) * t) * t) * t;\n    case 3:\n      t = 2 * x - 7;\n      return 0.51154e-2 + (0.75722e-3 + (0.39096e-5 + (0.19504e-7 + (0.93687e-10 + (0.43143e-12 + 0.18939e-14 * t) * t) * t) * t) * t) * t;\n    case 4:\n      t = 2 * x - 9;\n      return 0.66457e-2 + (0.77310e-3 + (0.40289e-5 + (0.20271e-7 + (0.98117e-10 + (0.45484e-12 + 0.20076e-14 * t) * t) * t) * t) * t) * t;\n    case 5:\n      t = 2 * x - 11;\n      return 0.82082e-2 + (0.78946e-3 + (0.41529e-5 + (0.21074e-7 + (0.10278e-9 + (0.47965e-12 + 0.21285e-14 * t) * t) * t) * t) * t) * t;\n    case 6:\n      t = 2 * x - 13;\n      return 0.98039e-2 + (0.80633e-3 + (0.42819e-5 + (0.21916e-7 + (0.10771e-9 + (0.50595e-12 + 0.22573e-14 * t) * t) * t) * t) * t) * t;\n    case 7:\n      t = 2 * x - 15;\n      return 0.11433e-1 + (0.82372e-3 + (0.44160e-5 + (0.22798e-7 + (0.11291e-9 + (0.53386e-12 + 0.23944e-14 * t) * t) * t) * t) * t) * t;\n    case 8:\n      t = 2 * x - 17;\n      return 0.13099e-1 + (0.84167e-3 + (0.45555e-5 + (0.23723e-7 + (0.11839e-9 + (0.56346e-12 + 0.25403e-14 * t) * t) * t) * t) * t) * t;\n    case 9:\n      t = 2 * x - 19;\n      return 0.14800e-1 + (0.86018e-3 + (0.47008e-5 + (0.24694e-7 + (0.12418e-9 + (0.59486e-12 + 0.26957e-14 * t) * t) * t) * t) * t) * t;\n    case 10:\n      t = 2 * x - 21;\n      return 0.16540e-1 + (0.87928e-3 + (0.48520e-5 + (0.25711e-7 + (0.13030e-9 + (0.62820e-12 + 0.28612e-14 * t) * t) * t) * t) * t) * t;\n    case 11:\n      t = 2 * x - 23;\n      return 0.18318e-1 + (0.89900e-3 + (0.50094e-5 + (0.26779e-7 + (0.13675e-9 + (0.66358e-12 + 0.30375e-14 * t) * t) * t) * t) * t) * t;\n    case 12:\n      t = 2 * x - 25;\n      return 0.20136e-1 + (0.91936e-3 + (0.51734e-5 + (0.27900e-7 + (0.14357e-9 + (0.70114e-12 + 0.32252e-14 * t) * t) * t) * t) * t) * t;\n    case 13:\n      t = 2 * x - 27;\n      return 0.21996e-1 + (0.94040e-3 + (0.53443e-5 + (0.29078e-7 + (0.15078e-9 + (0.74103e-12 + 0.34251e-14 * t) * t) * t) * t) * t) * t;\n    case 14:\n      t = 2 * x - 29;\n      return 0.23898e-1 + (0.96213e-3 + (0.55225e-5 + (0.30314e-7 + (0.15840e-9 + (0.78340e-12 + 0.36381e-14 * t) * t) * t) * t) * t) * t;\n    case 15:\n      t = 2 * x - 31;\n      return 0.25845e-1 + (0.98459e-3 + (0.57082e-5 + (0.31613e-7 + (0.16646e-9 + (0.82840e-12 + 0.38649e-14 * t) * t) * t) * t) * t) * t;\n    case 16:\n      t = 2 * x - 33;\n      return 0.27837e-1 + (0.10078e-2 + (0.59020e-5 + (0.32979e-7 + (0.17498e-9 + (0.87622e-12 + 0.41066e-14 * t) * t) * t) * t) * t) * t;\n    case 17:\n      t = 2 * x - 35;\n      return 0.29877e-1 + (0.10318e-2 + (0.61041e-5 + (0.34414e-7 + (0.18399e-9 + (0.92703e-12 + 0.43639e-14 * t) * t) * t) * t) * t) * t;\n    case 18:\n      t = 2 * x - 37;\n      return 0.31965e-1 + (0.10566e-2 + (0.63151e-5 + (0.35924e-7 + (0.19353e-9 + (0.98102e-12 + 0.46381e-14 * t) * t) * t) * t) * t) * t;\n    case 19:\n      t = 2 * x - 39;\n      return 0.34104e-1 + (0.10823e-2 + (0.65354e-5 + (0.37512e-7 + (0.20362e-9 + (0.10384e-11 + 0.49300e-14 * t) * t) * t) * t) * t) * t;\n    case 20:\n      t = 2 * x - 41;\n      return 0.36295e-1 + (0.11089e-2 + (0.67654e-5 + (0.39184e-7 + (0.21431e-9 + (0.10994e-11 + 0.52409e-14 * t) * t) * t) * t) * t) * t;\n    case 21:\n      t = 2 * x - 43;\n      return 0.38540e-1 + (0.11364e-2 + (0.70058e-5 + (0.40943e-7 + (0.22563e-9 + (0.11642e-11 + 0.55721e-14 * t) * t) * t) * t) * t) * t;\n    case 22:\n      t = 2 * x - 45;\n      return 0.40842e-1 + (0.11650e-2 + (0.72569e-5 + (0.42796e-7 + (0.23761e-9 + (0.12332e-11 + 0.59246e-14 * t) * t) * t) * t) * t) * t;\n    case 23:\n      t = 2 * x - 47;\n      return 0.43201e-1 + (0.11945e-2 + (0.75195e-5 + (0.44747e-7 + (0.25030e-9 + (0.13065e-11 + 0.63000e-14 * t) * t) * t) * t) * t) * t;\n    case 24:\n      t = 2 * x - 49;\n      return 0.45621e-1 + (0.12251e-2 + (0.77941e-5 + (0.46803e-7 + (0.26375e-9 + (0.13845e-11 + 0.66996e-14 * t) * t) * t) * t) * t) * t;\n    case 25:\n      t = 2 * x - 51;\n      return 0.48103e-1 + (0.12569e-2 + (0.80814e-5 + (0.48969e-7 + (0.27801e-9 + (0.14674e-11 + 0.71249e-14 * t) * t) * t) * t) * t) * t;\n    case 26:\n      t = 2 * x - 59;\n      return 0.58702e-1 + (0.13962e-2 + (0.93714e-5 + (0.58882e-7 + (0.34414e-9 + (0.18552e-11 + 0.91160e-14 * t) * t) * t) * t) * t) * t;\n    case 30:\n      t = 2 * x - 79;\n      return 0.90908e-1 + (0.18544e-2 + (0.13903e-4 + (0.95549e-7 + (0.59752e-9 + (0.33656e-11 + 0.16815e-13 * t) * t) * t) * t) * t) * t;\n    case 40:\n      t = 2 * x - 99;\n      return 0.13443e0 + (0.25474e-2 + (0.21385e-4 + (0.15996e-6 + (0.10585e-8 + (0.61258e-11 + 0.30412e-13 * t) * t) * t) * t) * t) * t;\n    case 50:\n      t = 2 * x - 119;\n      return 0.19540e0 + (0.36342e-2 + (0.34096e-4 + (0.27479e-6 + (0.18934e-8 + (0.11021e-10 + 0.52931e-13 * t) * t) * t) * t) * t) * t;\n    case 60:\n      t = 2 * x - 121;\n      return 0.20281e0 + (0.37739e-2 + (0.35791e-4 + (0.29038e-6 + (0.20068e-8 + (0.11673e-10 + 0.55790e-13 * t) * t) * t) * t) * t) * t;\n    case 61:\n      t = 2 * x - 123;\n      return 0.21050e0 + (0.39206e-2 + (0.37582e-4 + (0.30691e-6 + (0.21270e-8 + (0.12361e-10 + 0.58770e-13 * t) * t) * t) * t) * t) * t;\n    case 62:\n      t = 2 * x - 125;\n      return 0.21849e0 + (0.40747e-2 + (0.39476e-4 + (0.32443e-6 + (0.22542e-8 + (0.13084e-10 + 0.61873e-13 * t) * t) * t) * t) * t) * t;\n    case 63:\n      t = 2 * x - 127;\n      return 0.22680e0 + (0.42366e-2 + (0.41477e-4 + (0.34300e-6 + (0.23888e-8 + (0.13846e-10 + 0.65100e-13 * t) * t) * t) * t) * t) * t;\n    case 64:\n      t = 2 * x - 129;\n      return 0.23545e0 + (0.44067e-2 + (0.43594e-4 + (0.36268e-6 + (0.25312e-8 + (0.14647e-10 + 0.68453e-13 * t) * t) * t) * t) * t) * t;\n    case 65:\n      t = 2 * x - 131;\n      return 0.24444e0 + (0.45855e-2 + (0.45832e-4 + (0.38352e-6 + (0.26819e-8 + (0.15489e-10 + 0.71933e-13 * t) * t) * t) * t) * t) * t;\n    case 66:\n      t = 2 * x - 133;\n      return 0.25379e0 + (0.47735e-2 + (0.48199e-4 + (0.40561e-6 + (0.28411e-8 + (0.16374e-10 + 0.75541e-13 * t) * t) * t) * t) * t) * t;\n    case 67:\n      t = 2 * x - 135;\n      return 0.26354e0 + (0.49713e-2 + (0.50702e-4 + (0.42901e-6 + (0.30095e-8 + (0.17303e-10 + 0.79278e-13 * t) * t) * t) * t) * t) * t;\n    case 68:\n      t = 2 * x - 137;\n      return 0.27369e0 + (0.51793e-2 + (0.53350e-4 + (0.45379e-6 + (0.31874e-8 + (0.18277e-10 + 0.83144e-13 * t) * t) * t) * t) * t) * t;\n    case 69:\n      t = 2 * x - 139;\n      return 0.28426e0 + (0.53983e-2 + (0.56150e-4 + (0.48003e-6 + (0.33752e-8 + (0.19299e-10 + 0.87139e-13 * t) * t) * t) * t) * t) * t;\n    case 70:\n      t = 2 * x - 141;\n      return 0.29529e0 + (0.56288e-2 + (0.59113e-4 + (0.50782e-6 + (0.35735e-8 + (0.20369e-10 + 0.91262e-13 * t) * t) * t) * t) * t) * t;\n    case 71:\n      t = 2 * x - 143;\n      return 0.30679e0 + (0.58714e-2 + (0.62248e-4 + (0.53724e-6 + (0.37827e-8 + (0.21490e-10 + 0.95513e-13 * t) * t) * t) * t) * t) * t;\n    case 72:\n      t = 2 * x - 145;\n      return 0.31878e0 + (0.61270e-2 + (0.65564e-4 + (0.56837e-6 + (0.40035e-8 + (0.22662e-10 + 0.99891e-13 * t) * t) * t) * t) * t) * t;\n    case 73:\n      t = 2 * x - 147;\n      return 0.33130e0 + (0.63962e-2 + (0.69072e-4 + (0.60133e-6 + (0.42362e-8 + (0.23888e-10 + 0.10439e-12 * t) * t) * t) * t) * t) * t;\n    case 74:\n      t = 2 * x - 149;\n      return 0.34438e0 + (0.66798e-2 + (0.72783e-4 + (0.63619e-6 + (0.44814e-8 + (0.25168e-10 + 0.10901e-12 * t) * t) * t) * t) * t) * t;\n    case 75:\n      t = 2 * x - 151;\n      return 0.35803e0 + (0.69787e-2 + (0.76710e-4 + (0.67306e-6 + (0.47397e-8 + (0.26505e-10 + 0.11376e-12 * t) * t) * t) * t) * t) * t;\n    case 76:\n      t = 2 * x - 153;\n      return 0.37230e0 + (0.72938e-2 + (0.80864e-4 + (0.71206e-6 + (0.50117e-8 + (0.27899e-10 + 0.11862e-12 * t) * t) * t) * t) * t) * t;\n    case 77:\n      t = 2 * x - 155;\n      return 0.38722e0 + (0.76260e-2 + (0.85259e-4 + (0.75329e-6 + (0.52979e-8 + (0.29352e-10 + 0.12360e-12 * t) * t) * t) * t) * t) * t;\n    case 78:\n      t = 2 * x - 157;\n      return 0.40282e0 + (0.79762e-2 + (0.89909e-4 + (0.79687e-6 + (0.55989e-8 + (0.30866e-10 + 0.12868e-12 * t) * t) * t) * t) * t) * t;\n    case 79:\n      t = 2 * x - 159;\n      return 0.41914e0 + (0.83456e-2 + (0.94827e-4 + (0.84291e-6 + (0.59154e-8 + (0.32441e-10 + 0.13387e-12 * t) * t) * t) * t) * t) * t;\n    case 80:\n      t = 2 * x - 161;\n      return 0.43621e0 + (0.87352e-2 + (0.10002e-3 + (0.89156e-6 + (0.62480e-8 + (0.34079e-10 + 0.13917e-12 * t) * t) * t) * t) * t) * t;\n    case 81:\n      t = 2 * x - 163;\n      return 0.45409e0 + (0.91463e-2 + (0.10553e-3 + (0.94293e-6 + (0.65972e-8 + (0.35782e-10 + 0.14455e-12 * t) * t) * t) * t) * t) * t;\n    case 82:\n      t = 2 * x - 165;\n      return 0.47282e0 + (0.95799e-2 + (0.11135e-3 + (0.99716e-6 + (0.69638e-8 + (0.37549e-10 + 0.15003e-12 * t) * t) * t) * t) * t) * t;\n    case 83:\n      t = 2 * x - 167;\n      return 0.49243e0 + (0.10037e-1 + (0.11750e-3 + (0.10544e-5 + (0.73484e-8 + (0.39383e-10 + 0.15559e-12 * t) * t) * t) * t) * t) * t;\n    case 84:\n      t = 2 * x - 169;\n      return 0.51298e0 + (0.10520e-1 + (0.12400e-3 + (0.11147e-5 + (0.77517e-8 + (0.41283e-10 + 0.16122e-12 * t) * t) * t) * t) * t) * t;\n    case 85:\n      t = 2 * x - 171;\n      return 0.53453e0 + (0.11030e-1 + (0.13088e-3 + (0.11784e-5 + (0.81743e-8 + (0.43252e-10 + 0.16692e-12 * t) * t) * t) * t) * t) * t;\n    case 86:\n      t = 2 * x - 173;\n      return 0.55712e0 + (0.11568e-1 + (0.13815e-3 + (0.12456e-5 + (0.86169e-8 + (0.45290e-10 + 0.17268e-12 * t) * t) * t) * t) * t) * t;\n    case 87:\n      t = 2 * x - 175;\n      return 0.58082e0 + (0.12135e-1 + (0.14584e-3 + (0.13164e-5 + (0.90803e-8 + (0.47397e-10 + 0.17850e-12 * t) * t) * t) * t) * t) * t;\n    case 88:\n      t = 2 * x - 177;\n      return 0.60569e0 + (0.12735e-1 + (0.15396e-3 + (0.13909e-5 + (0.95651e-8 + (0.49574e-10 + 0.18435e-12 * t) * t) * t) * t) * t) * t;\n    case 89:\n      t = 2 * x - 179;\n      return 0.63178e0 + (0.13368e-1 + (0.16254e-3 + (0.14695e-5 + (0.10072e-7 + (0.51822e-10 + 0.19025e-12 * t) * t) * t) * t) * t) * t;\n    case 90:\n      t = 2 * x - 181;\n      return 0.65918e0 + (0.14036e-1 + (0.17160e-3 + (0.15521e-5 + (0.10601e-7 + (0.54140e-10 + 0.19616e-12 * t) * t) * t) * t) * t) * t;\n    case 91:\n      t = 2 * x - 183;\n      return 0.68795e0 + (0.14741e-1 + (0.18117e-3 + (0.16392e-5 + (0.11155e-7 + (0.56530e-10 + 0.20209e-12 * t) * t) * t) * t) * t) * t;\n    case 92:\n      t = 2 * x - 185;\n      return 0.71818e0 + (0.15486e-1 + (0.19128e-3 + (0.17307e-5 + (0.11732e-7 + (0.58991e-10 + 0.20803e-12 * t) * t) * t) * t) * t) * t;\n    case 93:\n      t = 2 * x - 187;\n      return 0.74993e0 + (0.16272e-1 + (0.20195e-3 + (0.18269e-5 + (0.12335e-7 + (0.61523e-10 + 0.21395e-12 * t) * t) * t) * t) * t) * t;\n    }\n  return 1.0;\n}\n\nint\nmain ()\n{\n#ifdef __s390x__\n  {\n    register unsigned long r5 __asm (\"r5\");\n    r5 = 0xdeadbeefUL;\n    asm volatile (\"\":\"+r\" (r5));\n  }\n#endif\n  double d = foo (78.4);\n  if (d < 0.38 || d > 0.42)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58640-2.c",
    "content": "extern void abort (void);\n\nint a[20], b, c; \n\nint\nfn1 ()\n{\n  int d, e, f, g = 0; \n\n  a[12] = 1;\n  for (e = 0; e < 3; e++)\n    for (d = 0; d < 2; d++)\n      {\n\tfor (f = 0; f < 2; f++)\n\t  {\n\t    g ^= a[12] > 1;\n\t    if (g)\n\t      return 0;\n\t    if (b)\n\t      break;\n\t  }\n\tfor (c = 0; c < 1; c++)\n\t  a[d] = a[e * 3 + 9]; \n      }\n  return 0;\n}\n\nint\nmain ()\n{\n  fn1 ();\n  if (a[0] != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58640.c",
    "content": "int a, b, c, d = 1, e;\n\nstatic signed char\nfoo ()\n{\n  int f, g = a;\n\n  for (f = 1; f < 3; f++)\n    for (; b < 1; b++)\n      {\n        if (d)\n          for (c = 0; c < 4; c++)\n            for (f = 0; f < 3; f++)\n              {\n                for (e = 0; e < 1; e++)\n                  a = g;\n                if (f)\n                  break;\n              }\n        else if (f)\n          continue;\n        return 0;\n      }\n  return 0;\n}\n\nint\nmain ()\n{\n  foo ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58662.c",
    "content": "extern void abort (void);\n\nint a, c, d;\nvolatile int b;\n\nstatic int\nfoo (int p1, short p2)\n{\n  return p1 / p2;\n}\n\nint\nmain ()\n{\n  char e;\n  d = foo (a == 0, (0, 35536)); \n  e = d % 14;\n  b = e && c;\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58726.c",
    "content": "/* PR rtl-optimization/58726 */\n\nint a, c;\nunion { int f1; int f2 : 1; } b;\n\nshort\nfoo (short p)\n{\n  return p < 0 ? p : a;\n}\n\nint\nmain ()\n{\n  if (sizeof (short) * __CHAR_BIT__ != 16\n      || sizeof (int) * __CHAR_BIT__ != 32)\n    return 0;\n  b.f1 = 56374;\n  unsigned short d;\n  int e = b.f2;\n  d = e == 0 ? b.f1 : 0;\n  c = foo (d);\n  if (c != (short) 56374)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58831.c",
    "content": "#include <assert.h>\n\nint a, *b, c, d, f, **i, p, q, *r;\nshort o, j;\n\nstatic int __attribute__((noinline, noclone))\nfn1 (int *p1, int **p2)\n{\n  int **e = &b;\n  for (; p; p++)\n    *p1 = 1;\n  *e = *p2 = &d;\n\n  assert (r);\n\n  return c;\n}\n\nstatic int ** __attribute__((noinline, noclone))\nfn2 (void)\n{\n  for (f = 0; f != 42; f++)\n    {\n      int *g[3] = {0, 0, 0};\n      for (o = 0; o; o--)\n        for (; a > 1;)\n          {\n            int **h[1] = { &g[2] };\n          }\n    }\n  return &r;\n}\n\nint\nmain (void)\n{\n  i = fn2 ();\n  fn1 (b, i);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58943.c",
    "content": "/* PR c/58943 */\n\nunsigned int x[1] = { 2 };\n\nunsigned int\nfoo (void)\n{\n  x[0] |= 128;\n  return 1;\n}\n\nint\nmain ()\n{\n  x[0] |= foo ();\n  if (x[0] != 131)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr58984.c",
    "content": "/* PR tree-optimization/58984 */\n\nstruct S { int f0 : 8; int : 6; int f1 : 5; };\nstruct T { char f0; int : 6; int f1 : 5; };\n\nint a, *c = &a, e, n, b, m;\n\nstatic int\nfoo (struct S p)\n{\n  const unsigned short *f[36];\n  for (; e < 2; e++)\n    {\n      const unsigned short **i = &f[0];\n      *c ^= 1;\n      if (p.f1)\n\t{\n\t  *i = 0;\n\t  return b;\n\t}\n    }\n  return 0;\n}\n\nstatic int\nbar (struct T p)\n{\n  const unsigned short *f[36];\n  for (; e < 2; e++)\n    {\n      const unsigned short **i = &f[0];\n      *c ^= 1;\n      if (p.f1)\n\t{\n\t  *i = 0;\n\t  return b;\n\t}\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  struct S o = { 1, 1 };\n  foo (o);\n  m = n || o.f0;\n  if (a != 1)\n    __builtin_abort ();\n  e = 0;\n  struct T p = { 1, 1 };\n  bar (p);\n  m |= n || p.f0;\n  if (a != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c",
    "content": "/* PR tree-optimization/59014 */\n\n__attribute__((noinline, noclone)) long long int\nfoo (long long int x, long long int y)\n{\n  if (((int) x | (int) y) != 0)\n    return 6;\n  return x + y;\n}\n\nint\nmain ()\n{\n  if (sizeof (long long) == sizeof (int))\n    return 0;\n  int shift_half = sizeof (int) * __CHAR_BIT__ / 2;\n  long long int x = (3LL << shift_half) << shift_half;\n  long long int y = (5LL << shift_half) << shift_half;\n  long long int z = foo (x, y);\n  if (z != ((8LL << shift_half) << shift_half))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59014.c",
    "content": "/* PR tree-optimization/59014 */\n\nint a = 2, b, c, d;\n\nint\nfoo ()\n{\n  for (;; c++)\n    if ((b > 0) | (a & 1))\n      ;\n    else\n      {\n\td = a;\n\treturn 0;\n      }\n}\n\nint\nmain ()\n{\n  foo ();\n  if (d != 2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59101.c",
    "content": "/* PR target/59101 */\n\n__attribute__((noinline, noclone)) int\nfoo (int a)\n{\n  return (~a & 4102790424LL) > 0 | 6;\n}\n\nint\nmain ()\n{\n  if (foo (0) != 7)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59221.c",
    "content": "/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"*\" } { \"-O0\" \"-Os\" } } */\n\n\nint a = 1, b, d;\nshort e;\n\nint\nmain ()\n{\n  for (; b; b++)\n    ;\n  short f = a;\n  int g = 15;\n  e = f ? f : 1 << g;\n  int h = e;\n  d = h == 83647 ? 0 : h;\n  if (d != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59229.c",
    "content": "int i;\n\n__attribute__((noinline, noclone)) void\nbar (char *p)\n{\n  if (i < 1 || i > 6)\n    __builtin_abort ();\n  if (__builtin_memcmp (p, \"abcdefg\", i + 1) != 0)\n    __builtin_abort ();\n  __builtin_memset (p, ' ', 7);\n}\n\n__attribute__((noinline, noclone)) void\nfoo (char *p, unsigned long l)\n{\n  if (l < 1 || l > 6)\n    return;\n  char buf[7];\n  __builtin_memcpy (buf, p, l + 1);\n  bar (buf);\n}\n\nint\nmain ()\n{\n  for (i = 0; i < 16; i++)\n    foo (\"abcdefghijklmnop\", i);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59358.c",
    "content": "/* PR tree-optimization/59358 */\n\n__attribute__((noinline, noclone)) int\nfoo (int *x, int y)\n{\n  int z = *x;\n  if (y > z && y <= 16)\n    while (y > z)\n      z *= 2;\n  return z;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 1; i < 17; i++)\n    {\n      int j = foo (&i, 16);\n      int k;\n      if (i >= 8 && i <= 15)\n\tk = 16 + (i - 8) * 2;\n      else if (i >= 4 && i <= 7)\n\tk = 16 + (i - 4) * 4;\n      else if (i == 3)\n\tk = 24;\n      else\n\tk = 16;\n      if (j != k)\n\t__builtin_abort ();\n      j = foo (&i, 7);\n      if (i >= 7)\n\tk = i;\n      else if (i >= 4)\n\tk = 8 + (i - 4) * 2;\n      else if (i == 3)\n\tk = 12;\n      else\n\tk = 8;\n      if (j != k)\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59387.c",
    "content": "/* PR tree-optimization/59387 */\n\nint a, *d, **e = &d, f;\nchar c;\nstruct S { int f1; } b;\n\nint\nmain ()\n{\n  for (a = -19; a; a++)\n    {\n      for (b.f1 = 0; b.f1 < 24; b.f1++)\n\tc--;\n      *e = &f;\n      if (!d)\n\treturn 0;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59388.c",
    "content": "/* PR tree-optimization/59388 */\n\nint a;\nstruct S { unsigned int f:1; } b;\n\nint\nmain ()\n{\n  a = (0 < b.f) | b.f;\n  return a;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59413.c",
    "content": "/* PR tree-optimization/59413 */\n\ntypedef unsigned int uint32_t;\n\nuint32_t a;\nint b;\n\nint\nmain ()\n{\n  uint32_t c;\n  for (a = 7; a <= 1; a++)\n    {\n      char d = a;\n      c = d;\n      b = a == c;\n    }\n  if (a != 7)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59643.c",
    "content": "/* PR tree-optimization/59643 */\n\n#define N 32\n\n__attribute__((noinline, noclone)) void\nfoo (double *a, double *b, double *c, double d, double e, int n)\n{\n  int i;\n  for (i = 1; i < n - 1; i++)\n    a[i] = d * (b[i] + c[i] + a[i - 1] + a[i + 1]) + e * a[i];\n}\n\ndouble expected[] = {\n  0.0, 10.0, 44.0, 110.0, 232.0, 490.0, 1020.0, 2078.0, 4152.0, 8314.0,\n  16652.0, 33326.0, 66664.0, 133354.0, 266748.0, 533534.0, 1067064.0,\n  2134138.0, 4268300.0, 8536622.0, 17073256.0, 34146538.0, 68293116.0,\n  136586270.0, 273172536.0, 546345082.0, 1092690188.0, 2185380398.0,\n  4370760808.0, 8741521642.0, 17483043324.0, 6.0\n};\n\nint\nmain ()\n{\n  int i;\n  double a[N], b[N], c[N];\n  if (__DBL_MANT_DIG__ <= 35)\n    return 0;\n  for (i = 0; i < N; i++)\n    {\n      a[i] = (i & 3) * 2.0;\n      b[i] = (i & 7) - 4;\n      c[i] = i & 7;\n    }\n  foo (a, b, c, 2.0, 3.0, N);\n  for (i = 0; i < N; i++)\n    if (a[i] != expected[i])\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr59747.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint a[6], c = 1, d;\nshort e;\n\nint __attribute__ ((noinline))\nfn1 (int p)\n{\n  return a[p];\n}\n\nint\nmain ()\n{\n  if (sizeof (long long) != 8)\n    exit (0);\n\n  a[0] = 1;\n  if (c)\n    e--;\n  d = e;\n  long long f = e;\n  if (fn1 ((f >> 56) & 1) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60003.c",
    "content": "/* PR tree-optimization/60003 */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nunsigned long long jmp_buf[5];\n\n__attribute__((noinline, noclone)) void\nbaz (void)\n{\n  __builtin_longjmp (&jmp_buf, 1);\n}\n\nvoid\nbar (void)\n{\n  baz ();\n}\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  int a = 0;\n\n  if (__builtin_setjmp (&jmp_buf) == 0)\n    {\n      while (1)\n\t{\n\t  a = 1;\n\t  bar ();  /* OK if baz () instead */\n\t}\n    }\n  else\n    {\n      if (a == 0)\n\treturn 0;\n      else\n\treturn x;\n    }\n}\n\nint\nmain ()\n{\n  if (foo (1) == 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60017.c",
    "content": "/* PR target/60017 */\n\nextern void abort (void);\n\nstruct S0\n{\n  short m0;\n  short m1;\n};\n\nstruct S1\n{\n  unsigned m0:1;\n  char m1[2][2];\n  struct S0 m2[2];\n};\n\nstruct S1 x = { 1, {{2, 3}, {4, 5}}, {{6, 7}, {8, 9}} };\n\nstruct S1 func (void)\n{\n  return x;\n}\n\nint main (void)\n{\n  struct S1 ret = func ();\n\n  if (ret.m2[1].m1 != 9)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60062.c",
    "content": "/* PR target/60062 */\n\nint a;\n\nstatic void\nfoo (const char *p1, int p2)\n{\n  if (__builtin_strcmp (p1, \"hello\") != 0)\n    __builtin_abort ();\n}\n\nstatic void\nbar (const char *p1)\n{\n  if (__builtin_strcmp (p1, \"hello\") != 0)\n    __builtin_abort ();\n}\n\n__attribute__((optimize (0))) int\nmain ()\n{\n  foo (\"hello\", a);\n  bar (\"hello\");\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60072.c",
    "content": "/* PR target/60072 */\n\nint c = 1;\n\n__attribute__ ((optimize (1)))\nstatic int *foo (int *p)\n{\n  return p;\n}\n\nint\nmain ()\n{\n  *foo (&c) = 2;\n  return c - 2;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60454.c",
    "content": "#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t\t      \\\n        (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |            \\\n        (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |            \\\n        (((uint32_t)(x) & (uint32_t)0x000000ffUL) <<  8) |            \\\n        (((uint32_t)(x) & (uint32_t)0x0000ff00UL)      ) |            \\\n        (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))\n\n/* Previous version of bswap optimization would detect byte swap when none\n   happen. This test aims at catching such wrong detection to avoid\n   regressions.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_swap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint main(void)\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (fake_swap32 (0x12345678UL) != 0x78567E12UL)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60822.c",
    "content": "/* { dg-require-effective-target int32plus } */\nstruct X {\n    char fill0[800000];\n    int a;\n    char fill1[900000];\n    int b;\n};\n\nint __attribute__((noinline,noclone))\nAvg(struct X *p, int s)\n{\n    return (s * (long long)(p->a + p->b)) >> 17;\n}\n\nstruct X x;\n\nint main()\n{\n    x.a = 1 << 17;\n    x.b = 2 << 17;\n    if (Avg(&x, 1) != 3)\n\t__builtin_abort();\n    return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr60960.c",
    "content": "/* PR tree-optimization/60960 */\n\ntypedef unsigned char v4qi __attribute__ ((vector_size (4)));\n\n__attribute__((noinline, noclone)) v4qi\nf1 (v4qi v)\n{\n  return v / 2;\n}\n\n__attribute__((noinline, noclone)) v4qi\nf2 (v4qi v)\n{\n  return v / (v4qi) { 2, 2, 2, 2 };\n}\n\n__attribute__((noinline, noclone)) v4qi\nf3 (v4qi x, v4qi y)\n{\n  return x / y;\n}\n\nint\nmain ()\n{\n  v4qi x = { 5, 5, 5, 5 };\n  v4qi y = { 2, 2, 2, 2 };\n  v4qi z = f1 (x);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  z = f2 (x);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  z = f3 (x, y);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61306-1.c",
    "content": "#ifdef __INT32_TYPE__\ntypedef __INT32_TYPE__ int32_t;\n#else\ntypedef int int32_t;\n#endif\n\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t      \\\n\t(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |    \\\n\t(((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |    \\\n\t(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |    \\\n\t(( (int32_t)(x) &  (int32_t)0xff000000UL) >> 24)))\n\n/* Previous version of bswap optimization failed to consider sign extension\n   and as a result would replace an expression *not* doing a bswap by a\n   bswap.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_bswap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint\nmain(void)\n{\n  if (sizeof (int32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (fake_bswap32 (0x87654321) != 0xffffff87)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61306-2.c",
    "content": "#ifdef __INT16_TYPE__\ntypedef __INT16_TYPE__ int16_t;\n#else\ntypedef short int16_t;\n#endif\n\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t\t      \\\n\t(((uint32_t)         (x) & (uint32_t)0x000000ffUL) << 24) |   \\\n\t(((uint32_t)(int16_t)(x) & (uint32_t)0x00ffff00UL) <<  8) |   \\\n\t(((uint32_t)         (x) & (uint32_t)0x00ff0000UL) >>  8) |   \\\n\t(((uint32_t)         (x) & (uint32_t)0xff000000UL) >> 24)))\n\n\n/* Previous version of bswap optimization failed to consider sign extension\n   and as a result would replace an expression *not* doing a bswap by a\n   bswap.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_bswap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint\nmain(void)\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (sizeof (int16_t) * __CHAR_BIT__ != 16)\n    return 0;\n  if (fake_bswap32 (0x81828384) != 0xff838281)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61306-3.c",
    "content": "short a = -1;\nint b;\nchar c;\n\nint\nmain ()\n{\n  c = a;\n  b = a | c;\n  if (b != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61375.c",
    "content": "#ifdef __UINT64_TYPE__\ntypedef __UINT64_TYPE__ uint64_t;\n#else\ntypedef unsigned long long uint64_t;\n#endif\n\n#ifndef __SIZEOF_INT128__\n#define __int128 long long\n#endif\n\n/* Some version of bswap optimization would ICE when analyzing a mask constant\n   too big for an uint64_t variable (PR210931).  */\n\n__attribute__ ((noinline, noclone)) uint64_t\nuint128_central_bitsi_ior (unsigned __int128 in1, uint64_t in2)\n{\n  __int128 mask = (__int128)0xffff << 56;\n  return ((in1 & mask) >> 56) | in2;\n}\n\nint\nmain(int argc, char **argv)\n{\n  __int128 in = 1;\n#ifdef __SIZEOF_INT128__\n  in <<= 64;\n#endif\n  if (sizeof (uint64_t) * __CHAR_BIT__ != 64)\n    return 0;\n  if (sizeof (unsigned __int128) * __CHAR_BIT__ != 128)\n    return 0;\n  if (uint128_central_bitsi_ior (in, 2) != 0x102)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61517.c",
    "content": "int a, b, *c = &a;\nunsigned short d;\n\nint\nmain ()\n{\n  unsigned int e = a;\n  *c = 1;\n  if (!b)\n    {\n      d = e;\n      *c = d | e;\n    }\n\n  if (a != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61673.c",
    "content": "/* PR rtl-optimization/61673 */\n\nchar e;\n\n__attribute__((noinline, noclone)) void\nbar (char x)\n{\n  if (x != 0x54 && x != (char) 0x87)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (const char *x)\n{\n  char d = x[0];\n  int c = d;\n  if ((c >= 0 && c <= 0x7f) == 0)\n    e = d;\n  bar (d);\n}\n\n__attribute__((noinline, noclone)) void\nbaz (const char *x)\n{\n  char d = x[0];\n  int c = d;\n  if ((c >= 0 && c <= 0x7f) == 0)\n    e = d;\n}\n\nint\nmain ()\n{\n  const char c[] = { 0x54, 0x87 };\n  e = 0x21;\n  foo (c);\n  if (e != 0x21)\n    __builtin_abort ();\n  foo (c + 1);\n  if (e != (char) 0x87)\n    __builtin_abort ();\n  e = 0x21;\n  baz (c);\n  if (e != 0x21)\n    __builtin_abort ();\n  baz (c + 1);\n  if (e != (char) 0x87)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61682.c",
    "content": "/* PR tree-optimization/61682 */\n\nint a, b;\nstatic int *c = &b;\n\nint\nmain ()\n{\n  int *d = &a;\n  for (a = 0; a < 12; a++)\n    *c |= *d / 9;\n\n  if (b != 1)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr61725.c",
    "content": "/* PR tree-optimization/61725 */\n\nint\nmain ()\n{\n  int x;\n  for (x = -128; x <= 128; x++)\n    {\n      int a = __builtin_ffs (x);\n      if (x == 0 && a != 0)\n        __builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr62151.c",
    "content": "/* PR rtl-optimization/62151 */\n\nint a, c, d, e, f, g, h, i;\nshort b;\n\nint\nfn1 ()\n{\n  b = 0;\n  for (;;)\n    {\n      int j[2];\n      j[f] = 0;\n      if (h)\n\td = 0;\n      else\n\t{\n\t  for (; f; f++)\n\t    ;\n\t  for (a = 0; a < 1; a++)\n\t    for (;;)\n\t      {\n\t\ti = b & ((b ^ 1) & 83647) ? b : b - 1;\n\t\tg = 1 ? i : 0;\n\t\te = j[0];\n\t\tif (c)\n\t\t  break;\n\t\treturn 0;\n\t      }\n\t}\n    }\n}\n\nint\nmain ()\n{\n  fn1 ();\n  if (g != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr63209.c",
    "content": "static int Sub(int a, int b) {\n  return  b -a;\n}\n\nstatic unsigned Select(unsigned a, unsigned b, unsigned c) {\n  const int pa_minus_pb =\n      Sub((a >>  8) & 0xff, (b >>  8) & 0xff) + \n      Sub((a >>  0) & 0xff, (b >>  0) & 0xff); \n  return (pa_minus_pb <= 0) ? a : b;\n}\n\n__attribute__((noinline)) unsigned Predictor(unsigned left, const unsigned* const top) {\n  const unsigned pred = Select(top[1], left, top[0]);\n  return pred;\n}\n\nint main(void) {\n  const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a};\n  const unsigned left = 0xff7b7b7b;\n  const unsigned pred = Predictor(left, top /*+ 1*/);\n  if (pred == left)\n    return 0;\n  return 1;\n}\n\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr63302.c",
    "content": "/* PR tree-optimization/63302 */\n\n#ifdef __SIZEOF_INT128__\n#if __SIZEOF_INT128__ * __CHAR_BIT__ == 128\n#define USE_INT128\n#endif\n#endif\n#if __SIZEOF_LONG_LONG__ * __CHAR_BIT__ == 64\n#define USE_LLONG\n#endif\n\n#ifdef USE_INT128\n__attribute__((noinline, noclone)) int\nfoo (__int128 x)\n{\n  __int128 v = x & (((__int128) -1 << 63) | 0x7ff);\n \n  return v == 0 || v == ((__int128) -1 << 63);\n}\n#endif\n\n#ifdef USE_LLONG\n__attribute__((noinline, noclone)) int\nbar (long long x)\n{\n  long long v = x & (((long long) -1 << 31) | 0x7ff);\n \n  return v == 0 || v == ((long long) -1 << 31);\n}\n#endif\n\nint\nmain ()\n{\n#ifdef USE_INT128\n  if (foo (0) != 1\n      || foo (1) != 0\n      || foo (0x800) != 1\n      || foo (0x801) != 0\n      || foo ((__int128) 1 << 63) != 0\n      || foo ((__int128) -1 << 63) != 1\n      || foo (((__int128) -1 << 63) | 1) != 0\n      || foo (((__int128) -1 << 63) | 0x800) != 1\n      || foo (((__int128) -1 << 63) | 0x801) != 0)\n    __builtin_abort ();\n#endif\n#ifdef USE_LLONG\n  if (bar (0) != 1\n      || bar (1) != 0\n      || bar (0x800) != 1\n      || bar (0x801) != 0\n      || bar (1LL << 31) != 0\n      || bar (-1LL << 31) != 1\n      || bar ((-1LL << 31) | 1) != 0\n      || bar ((-1LL << 31) | 0x800) != 1\n      || bar ((-1LL << 31) | 0x801) != 0)\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr63641.c",
    "content": "/* PR tree-optimization/63641 */\n\n__attribute__ ((noinline, noclone)) int\nfoo (unsigned char b)\n{\n  if (0x0 <= b && b <= 0x8)\n    goto lab;\n  if (b == 0x0b)\n    goto lab;\n  if (0x0e <= b && b <= 0x1a)\n    goto lab;\n  if (0x1c <= b && b <= 0x1f)\n    goto lab;\n  return 0;\nlab:\n  return 1;\n}\n\n__attribute__ ((noinline, noclone)) int\nbar (unsigned char b)\n{\n  if (0x0 <= b && b <= 0x8)\n    goto lab;\n  if (b == 0x0b)\n    goto lab;\n  if (0x0e <= b && b <= 0x1a)\n    goto lab;\n  if (0x3c <= b && b <= 0x3f)\n    goto lab;\n  return 0;\nlab:\n  return 1;\n}\n\nchar tab1[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,\n\t\t1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 };\nchar tab2[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,\n\t\t1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 };\n\nint\nmain ()\n{\n  int i;\n  asm volatile (\"\" : : : \"memory\");\n  for (i = 0; i < 256; i++)\n    if (foo (i) != (i < 32 ? tab1[i] : 0))\n      __builtin_abort ();\n  for (i = 0; i < 256; i++)\n    if (bar (i) != (i < 64 ? tab2[i] : 0))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr63659.c",
    "content": "/* PR rtl-optimization/63659 */\n\nint a, b, c, *d = &b, g, h, i;\nunsigned char e;\nchar f;\n\nint\nmain ()\n{\n  while (a)\n    {\n      for (a = 0; a; a++)\n\tfor (; c; c++)\n\t  ;\n      if (i)\n\tbreak;\n    }\n\n  char j = c, k = -1, l;\n  l = g = j >> h;\n  f = l == 0 ? k : k % l;\n  e = 0 ? 0 : f;\n  *d = e;\n\n  if (b != 255)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr63843.c",
    "content": "/* PR rtl-optimization/63843 */\n\nstatic inline __attribute__ ((always_inline))\nunsigned short foo (unsigned short v)\n{\n  return (v << 8) | (v >> 8);\n}\n\nunsigned short __attribute__ ((noinline, noclone, hot))\nbar (unsigned char *x)\n{\n  unsigned int a;\n  unsigned short b;\n  __builtin_memcpy (&a, &x[0], sizeof (a));\n  a ^= 0x80808080U;\n  __builtin_memcpy (&x[0], &a, sizeof (a));\n  __builtin_memcpy (&b, &x[2], sizeof (b));\n  return foo (b);\n}\n\nint\nmain ()\n{\n  unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };\n  if (__CHAR_BIT__ == 8\n      && sizeof (short) == 2\n      && sizeof (int) == 4\n      && bar (x) != 0x8181U)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64006.c",
    "content": "/* PR tree-optimization/64006 */\n\nint v;\n\nlong __attribute__ ((noinline, noclone))\ntest (long *x, int y)\n{\n  int i;\n  long s = 1;\n  for (i = 0; i < y; i++)\n    if (__builtin_mul_overflow (s, x[i], &s))\n      v++;\n  return s;\n}\n\nint\nmain ()\n{\n  long d[7] = { 975, 975, 975, 975, 975, 975, 975 };\n  long r = test (d, 7);\n  if (sizeof (long) * __CHAR_BIT__ == 64 && v != 1)\n    __builtin_abort ();\n  else if (sizeof (long) * __CHAR_BIT__ == 32 && v != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64255.c",
    "content": "/* PR rtl-optimization/64255 */\n\n__attribute__((noinline, noclone)) void\nbar (long i, unsigned long j)\n{\n  if (i != 1 || j != 1)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (long i)\n{\n  unsigned long j;\n\n  if (!i)\n    return;\n  j = i >= 0 ? (unsigned long) i : - (unsigned long) i;\n  if ((i >= 0 ? (unsigned long) i : - (unsigned long) i) != j)\n    __builtin_abort ();\n  bar (i, j);\n}\n\nint\nmain ()\n{\n  foo (1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64260.c",
    "content": "/* PR rtl-optimization/64260 */\n\nint a = 1, b;\n\nvoid\nfoo (char p)\n{\n  int t = 0;\n  for (; b < 1; b++)\n    {\n      int *s = &a;\n      if (--t)\n\t*s &= p;\n      *s &= 1;\n    }\n}\n\nint\nmain ()\n{\n  foo (0);\n  if (a != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64682.c",
    "content": "/* PR rtl-optimization/64682 */\n\nint a, b = 1;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != 5)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 56; i++)\n    for (; a; a--)\n      ;\n  int *c = &b;\n  if (*c)\n    *c = 1 % (unsigned int) *c | 5;\n\n  foo (b);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64718.c",
    "content": "static int __attribute__ ((noinline, noclone))\nswap (int x)\n{\n  return (unsigned short) ((unsigned short) x << 8 | (unsigned short) x >> 8);\n}\n\nstatic int a = 0x1234;\n\nint\nmain (void)\n{\n  int b = 0x1234;\n  if (swap (a) != 0x3412)\n    __builtin_abort ();\n  if (swap (b) != 0x3412)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64756.c",
    "content": "/* PR rtl-optimization/64756 */\n\nint a, *tmp, **c = &tmp;\nvolatile int d;\nstatic int *volatile *e = &tmp;\nunsigned int f;\n\nstatic void\nfn1 (int *p)\n{\n  int g;\n  for (; f < 1; f++)\n    for (g = 1; g >= 0; g--)\n      {\n\td || d;\n\t*c = p;\n\n\tif (tmp != &a)\n\t  __builtin_abort ();\n\n\t*e = 0;\n      }\n}\n\nint\nmain ()\n{\n  fn1 (&a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64957.c",
    "content": "/* PR rtl-optimization/64957 */\n\n__attribute__((noinline, noclone)) int\nfoo (int b)\n{\n  return (((b ^ 5) | 1) ^ 5) | 1;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int b)\n{\n  return (((b ^ ~5) & ~1) ^ ~5) & ~1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 16; i++)\n    if (foo (i) != (i | 1) || bar (i) != (i & ~1))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr64979.c",
    "content": "/* PR target/64979 */\n\n#include <stdarg.h>\n\nvoid __attribute__((noinline, noclone))\nbar (int x, va_list *ap)\n{\n  if (ap)\n    {\n      int i;\n      for (i = 0; i < 10; i++)\n\tif (i != va_arg (*ap, int))\n\t  __builtin_abort ();\n      if (va_arg (*ap, double) != 0.5)\n\t__builtin_abort ();\n    }\n}\n\nvoid __attribute__((noinline, noclone))\nfoo (int x, ...)\n{\n  va_list ap;\n  int n;\n\n  va_start (ap, x);\n  n = va_arg (ap, int);\n  bar (x, (va_list *) ((n == 0) ? ((void *) 0) : &ap));\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  foo (100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65053-1.c",
    "content": "/* PR tree-optimization/65053 */\n\nint i;\n\n__attribute__ ((noinline, noclone))\nunsigned int foo (void)\n{\n  return 0;\n}\n\nint\nmain ()\n{\n  unsigned int u = -1;\n  if (u == -1)\n    {\n      unsigned int n = foo ();\n      if (n > 0)\n\tu = n - 1;\n    }\n\n  while (u != -1)\n    {\n      asm (\"\" : \"+g\" (u));\n      u = -1;\n      i = 1;\n    }\n\n  if (i)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65053-2.c",
    "content": "/* PR tree-optimization/65053 */\n\nint i;\nunsigned int x;\n\nint\nmain ()\n{\n  asm volatile (\"\" : \"+g\" (x));\n  unsigned int n = x;\n  unsigned int u = 32;\n  if (n >= 32)\n    __builtin_abort ();\n  if (n != 0)\n    u = n + 32;\n\n  while (u != 32)\n    {\n      asm (\"\" : : \"g\" (u));\n      u = 32;\n      i = 1;\n    }\n\n  if (i)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65170.c",
    "content": "/* PR tree-optimization/65170 */\n\n#ifdef __SIZEOF_INT128__\ntypedef unsigned __int128 V;\ntypedef unsigned long long int H;\n#else\ntypedef unsigned long long int V;\ntypedef unsigned int H;\n#endif\n\n__attribute__((noinline, noclone)) void\nfoo (V b, V c)\n{\n  V a;\n  b &= (H) -1;\n  c &= (H) -1;\n  a = b * c;\n  if (a != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  foo (1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65215-1.c",
    "content": "/* PR tree-optimization/65215 */\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (unsigned long long *x)\n{\n  return foo (*x);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  unsigned long long l = foo (0xdeadbeefU) | 0xfeedbea800000000ULL;\n  if (bar (&l) != 0xdeadbeefU)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65215-2.c",
    "content": "/* PR tree-optimization/65215 */\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned long long\nbar (unsigned long long *x)\n{\n  return ((unsigned long long) foo (*x) << 32) | foo (*x >> 32);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  unsigned long long l = foo (0xfeedbea8U) | ((unsigned long long) foo (0xdeadbeefU) << 32);\n  if (bar (&l) != 0xfeedbea8deadbeefULL)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65215-3.c",
    "content": "/* PR tree-optimization/65215 */\n\nstruct S { unsigned long long l1 : 24, l2 : 8, l3 : 32; };\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned long long\nbar (struct S *x)\n{\n  unsigned long long x1 = foo (((unsigned int) x->l1 << 8) | x->l2);\n  unsigned long long x2 = foo (x->l3);\n  return (x2 << 32) | x1;\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  struct S s = { 0xdeadbeU, 0xefU, 0xfeedbea8U };\n  unsigned long long l = bar (&s);\n  if (foo (l >> 32) != s.l3\n      || (foo (l) >> 8) != s.l1\n      || (foo (l) & 0xff) != s.l2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65215-4.c",
    "content": "/* PR tree-optimization/65215 */\n\nstruct S { unsigned long long l1 : 48; };\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (struct S *x)\n{\n  return foo (x->l1);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  struct S s;\n  s.l1 = foo (0xdeadbeefU) | (0xfeedULL << 32);\n  if (bar (&s) != 0xdeadbeefU)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65215-5.c",
    "content": "/* PR tree-optimization/65215 */\n\n__attribute__((noinline, noclone)) unsigned int\nfoo (unsigned char *p)\n{\n  return ((unsigned int) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (unsigned char *p)\n{\n  return ((unsigned int) p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];\n}\n\nstruct S { unsigned int a; unsigned char b[5]; };\n\nint\nmain ()\n{\n  struct S s = { 1, { 2, 3, 4, 5, 6 } };\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4)\n    return 0;\n  if (foo (&s.b[1]) != 0x03040506U\n      || bar (&s.b[1]) != 0x06050403U)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65216.c",
    "content": "/* PR tree-optimization/65216 */\n\nint a, b = 62, e;\nvolatile int c, d;\n\nint\nmain ()\n{\n  int f = 0;\n  for (a = 0; a < 2; a++)\n    {\n      b &= (8 ^ f) & 1;\n      for (e = 0; e < 6; e++)\n\tif (c)\n\t  f = d;\n    }\n  if (b != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65369.c",
    "content": "/* PR tree-optimization/65369 */\n#include <stdint.h>\n\nstatic const char data[] =\n  \"12345678901234567890123456789012345678901234567890\"\n  \"123456789012345678901234567890\";\n\n__attribute__ ((noinline))\nstatic void foo (const unsigned int *buf)\n{\n  if (__builtin_memcmp (buf, data, 64))\n    __builtin_abort ();\n}\n\n__attribute__ ((noinline))\nstatic void bar (const unsigned char *block)\n{\n  uint32_t buf[16];\n  __builtin_memcpy (buf +  0, block +  0, 4);\n  __builtin_memcpy (buf +  1, block +  4, 4);\n  __builtin_memcpy (buf +  2, block +  8, 4);\n  __builtin_memcpy (buf +  3, block + 12, 4);\n  __builtin_memcpy (buf +  4, block + 16, 4);\n  __builtin_memcpy (buf +  5, block + 20, 4);\n  __builtin_memcpy (buf +  6, block + 24, 4);\n  __builtin_memcpy (buf +  7, block + 28, 4);\n  __builtin_memcpy (buf +  8, block + 32, 4);\n  __builtin_memcpy (buf +  9, block + 36, 4);\n  __builtin_memcpy (buf + 10, block + 40, 4);\n  __builtin_memcpy (buf + 11, block + 44, 4);\n  __builtin_memcpy (buf + 12, block + 48, 4);\n  __builtin_memcpy (buf + 13, block + 52, 4);\n  __builtin_memcpy (buf + 14, block + 56, 4);\n  __builtin_memcpy (buf + 15, block + 60, 4);\n  foo (buf);\n}\n\nint\nmain ()\n{\n  unsigned char input[sizeof data + 16] __attribute__((aligned (16)));\n  __builtin_memset (input, 0, sizeof input);\n  __builtin_memcpy (input + 1, data, sizeof data);\n  bar (input + 1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65401.c",
    "content": "/* PR rtl-optimization/65401 */\n\nstruct S { unsigned short s[64]; };\n\n__attribute__((noinline, noclone)) void\nfoo (struct S *x)\n{\n  unsigned int i;\n  unsigned char *s;\n\n  s = (unsigned char *) x->s;\n  for (i = 0; i < 64; i++)\n    x->s[i] = s[i * 2] | (s[i * 2 + 1] << 8);\n}  \n\n__attribute__((noinline, noclone)) void\nbar (struct S *x)\n{\n  unsigned int i;\n  unsigned char *s;\n\n  s = (unsigned char *) x->s;\n  for (i = 0; i < 64; i++)\n    x->s[i] = (s[i * 2] << 8) | s[i * 2 + 1];\n}  \n\nint\nmain ()\n{\n  unsigned int i;\n  struct S s;\n  if (sizeof (unsigned short) != 2)\n    return 0;\n  for (i = 0; i < 64; i++)\n    s.s[i] = i + ((64 - i) << 8);\n  foo (&s);\n#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != (64 - i) + (i << 8))\n      __builtin_abort ();\n#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != i + ((64 - i) << 8))\n      __builtin_abort ();\n#endif\n  for (i = 0; i < 64; i++)\n    s.s[i] = i + ((64 - i) << 8);\n  bar (&s);\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != (64 - i) + (i << 8))\n      __builtin_abort ();\n#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != i + ((64 - i) << 8))\n      __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c",
    "content": "/* PR tree-optimization/65418 */\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  if (x == -216 || x == -132 || x == -218 || x == -146)\n     return 1;\n  return 0;\n}\n\nint\nmain ()\n{\n  volatile int i;\n  for (i = -230; i < -120; i++)\n    if (foo (i) != (i == -216 || i == -132 || i == -218 || i == -146))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c",
    "content": "/* PR tree-optimization/65418 */\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  if (x == -216 || x == -211 || x == -218 || x == -205 || x == -223)\n     return 1;\n  return 0;\n}\n\nint\nmain ()\n{\n  volatile int i;\n  for (i = -230; i < -200; i++)\n    if (foo (i) != (i == -216 || i == -211 || i == -218 || i == -205 || i == -223))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65427.c",
    "content": "/* PR tree-optimization/65427 */\n\ntypedef int V __attribute__ ((vector_size (8 * sizeof (int))));\nV a, b, c, d, e, f;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int y)\n{\n  do\n    {\n      if (x)\n\td = a ^ c;\n      else\n\td = a ^ b;\n    }\n  while (y);\n}\n\nint\nmain ()\n{\n  a = (V) { 1, 2, 3, 4, 5, 6, 7, 8 };\n  b = (V) { 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80 };\n  e = (V) { 0x41, 0x82, 0x43, 0x84, 0x45, 0x86, 0x47, 0x88 };\n  foo (0, 0);\n  if (__builtin_memcmp (&d, &e, sizeof (V)) != 0)\n    __builtin_abort ();\n  c = (V) { 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40 };\n  f = (V) { 0x81, 0x42, 0x83, 0x44, 0x85, 0x46, 0x87, 0x48 };\n  foo (1, 0);\n  if (__builtin_memcmp (&d, &f, sizeof (V)) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65648.c",
    "content": "/* PR target/65648 */\n\nint a = 0, *b = 0, c = 0;\nstatic int d = 0;\nshort e = 1;\nstatic long long f = 0;\nlong long *i = &f;\nunsigned char j = 0;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int *y)\n{\n  asm volatile (\"\" : : \"r\" (x), \"r\" (y) : \"memory\");\n}\n\n__attribute__((noinline, noclone)) void\nbar (const char *x, long long y)\n{\n  asm volatile (\"\" : : \"r\" (x), \"r\" (&y) : \"memory\");\n  if (y != 0)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  int k = 0;\n  b = &k;\n  j = (!a) - (c <= e);\n  *i = j;\n  foo (a, &k);\n  bar (\"\", f);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr65956.c",
    "content": "/* PR target/65956 */\n\nstruct A { char *a; int b; long long c; };\nchar v[3];\n\n__attribute__((noinline, noclone)) void\nfn1 (char *x, char *y)\n{\n  if (x != &v[1] || y != &v[2])\n    __builtin_abort ();\n  v[1]++;\n}\n\n__attribute__((noinline, noclone)) int\nfn2 (char *x)\n{\n  asm volatile (\"\" : \"+g\" (x) : : \"memory\");\n  return x == &v[0];\n}\n\n__attribute__((noinline, noclone)) void\nfn3 (const char *x)\n{\n  if (x[0] != 0)\n    __builtin_abort ();\n}\n\nstatic struct A\nfoo (const char *x, struct A y, struct A z)\n{\n  struct A r = { 0, 0, 0 };\n  if (y.b && z.b)\n    {\n      if (fn2 (y.a) && fn2 (z.a))\n\tswitch (x[0])\n\t  {\n\t  case '|':\n\t    break;\n\t  default:\n\t    fn3 (x);\n\t  }\n      fn1 (y.a, z.a);\n    }\n  return r;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int x, struct A *y)\n{\n  switch (x)\n    {\n    case 219:\n      foo (\"+\", y[-2], y[0]);\n    case 220:\n      foo (\"-\", y[-2], y[0]);\n    }\n}\n\nint\nmain ()\n{\n  struct A a[3] = { { &v[1], 1, 1LL }, { &v[0], 0, 0LL }, { &v[2], 2, 2LL } };\n  bar (220, a + 2);\n  if (v[1] != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr66187.c",
    "content": "/* PR tree-optimization/66187 */\n\nint a = 1, e = -1;\nshort b, f;\n\nint\nmain ()\n{\n  f = e;\n  int g = b < 0 ? 0 : f + b;\n  if ((g & -4) < 0)\n    a = 0;\n  if (a)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr66233.c",
    "content": "/* PR tree-optimization/66233 */\n\nunsigned int v[8];\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  int i;\n  for (i = 0; i < 8; i++)\n    v[i] = (float) i;\n}\n\nint\nmain ()\n{\n  unsigned int i;\n  foo ();\n  for (i = 0; i < 8; i++)\n    if (v[i] != i)\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr66556.c",
    "content": "/* { dg-do run } */\n\nextern void abort (void);\n\nstruct {\n  unsigned f2;\n  unsigned f3 : 15;\n  unsigned f5 : 3;\n  short f6;\n} b = {0x7f8000, 6, 5, 0}, g = {8, 0, 5, 0};\n\nshort d, l;\nint a, c, h = 8;\nvolatile char e[237] = {4};\nshort *f = &d;\nshort i[5] = {3};\nchar j;\nint *k = &c;\n\nint\nfn1 (unsigned p1) { return -p1; }\n\nvoid\nfn2 (char p1)\n{\n  a = p1;\n  e[0];\n}\n\nshort\nfn3 ()\n{\n  *k = 4;\n  return *f;\n}\n\nint\nmain ()\n{\n\n  unsigned m;\n  short *n = &i[4];\n\n  m = fn1 ((h && j) <= b.f5);\n  l = m > g.f3;\n  *n = 3;\n  fn2 (b.f2 >> 15);\n  if ((a & 0xff) != 0xff)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr66757.c",
    "content": "/* PR tree-optimization/66757 */\n/* Testcase by Zhendong Su <su@cs.ucdavis.edu> */\n\nint a, b;\n\nint\nmain (void)\n{\n  unsigned int t = (unsigned char) (~b); \n\n  if ((t ^ 1) / 255)\n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr67037.c",
    "content": "long (*extfunc)();\n\nstatic inline void lstrcpynW( short *d, const short *s, int n )\n{\n    unsigned int count = n;\n\n    while ((count > 1) && *s)\n    {\n        count--;\n        *d++ = *s++;\n    }\n    if (count) *d = 0;\n}\n\nint __attribute__((noinline,noclone))\nbadfunc(int u0, int u1, int u2, int u3,\n  short *fsname, unsigned int fsname_len)\n{\n    static const short ntfsW[] = {'N','T','F','S',0};\n    char superblock[2048+3300];\n    int ret = 0;\n    short *p;\n\n    if (extfunc())\n        return 0;\n    p = (void *)extfunc();\n    if (p != 0)\n        goto done;\n\n    extfunc(superblock);\n\n    lstrcpynW(fsname, ntfsW, fsname_len);\n\n    ret = 1;\ndone:\n    return ret;\n}\n\nstatic long f()\n{\n    return 0;\n}\n\nint main()\n{\n    short buf[6];\n    extfunc = f;\n    return !badfunc(0, 0, 0, 0, buf, 6);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr67226.c",
    "content": "struct assembly_operand\n{\n  int type, value, symtype, symflags, marker;\n};\n\nstruct assembly_operand to_input, from_input;\n\nvoid __attribute__ ((__noinline__, __noclone__))\nassemblez_1 (int internal_number, struct assembly_operand o1)\n{\n  if (o1.type != from_input.type)\n    __builtin_abort ();\n}\n\nvoid __attribute__ ((__noinline__, __noclone__))\nt0 (struct assembly_operand to, struct assembly_operand from)\n{\n  if (to.value == 0)\n    assemblez_1 (32, from);\n  else\n    __builtin_abort ();\n}\n\nint\nmain (void)\n{\n  to_input.value = 0;\n  to_input.type = 1;\n  to_input.symtype = 2;\n  to_input.symflags = 3;\n  to_input.marker = 4;\n\n  from_input.value = 5;\n  from_input.type = 6;\n  from_input.symtype = 7;\n  from_input.symflags = 8;\n  from_input.marker = 9;\n\n  t0 (to_input, from_input);\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr67714.c",
    "content": "unsigned int b;\nint c;\n\nsigned char\nfn1 ()\n{\n  signed char d;\n  for (int i = 0; i < 1; i++)\n    d = -15;\n  return d;\n}\n\nint\nmain (void)\n{\n  for (c = 0; c < 1; c++)\n    b = 0;\n  char e = fn1 ();\n  signed char f = e ^ b;\n  volatile int g = (int) f;\n\n  if (g != -15)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr67781.c",
    "content": "#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#ifdef __UINT8_TYPE__\ntypedef __UINT8_TYPE__ uint8_t;\n#else\ntypedef unsigned char uint8_t;\n#endif\n\nstruct\n{\n  uint32_t a;\n  uint8_t b;\n} s = { 0x123456, 0x78 };\n\nint pr67781()\n{\n  uint32_t c = (s.a << 8) | s.b;\n  return c;\n}\n\nint\nmain ()\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n\n  if (pr67781 () != 0x12345678)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr67929_1.c",
    "content": "int __attribute__ ((noinline, noclone))\nfoo (float a)\n{\n  return a * 4.9f;\n}\n\n\nint\nmain (void)\n{\n  if (foo (10.0f) != 49)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68143_1.c",
    "content": "#define NULL 0\n\nstruct stuff\n{\n    int a;\n    int b;\n    int c;\n    int d;\n    int e;\n    char *f;\n    int g;\n};\n\nvoid __attribute__ ((noinline))\nbar (struct stuff *x)\n{\n  if (x->g != 2)\n    __builtin_abort ();\n}\n\nint\nmain (int argc, char** argv)\n{\n  struct stuff x = {0, 0, 0, 0, 0, NULL, 0};\n  x.a = 100;\n  x.d = 100;\n  x.g = 2;\n  /* Struct should now look like {100, 0, 0, 100, 0, 0, 0, 2}.  */\n  bar (&x);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68185.c",
    "content": "int a, b, d = 1, e, f, o, u, w = 1, z;\nshort c, q, t;\n\nint\nmain ()\n{\n  char g;\n  for (; d; d--)\n    {\n      while (o)\n\tfor (; e;)\n\t  {\n\t    c = b;\n\t    int h = o = z;\n\t    for (; u;)\n\t      for (; a;)\n\t\t;\n\t  }\n      if (t < 1)\n\tg = w;\n      f = g;\n      g && (q = 1);\n    }\n\n  if (q != 1)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68249.c",
    "content": "/* PR rtl-optimization/68249 */\n\nint a, b, c, g, k, l, m, n;\nchar h;\n\nvoid\nfn1 ()\n{\n  for (; k; k++)\n    {\n      m = b || c < 0 || c > 1 ? : c;\n      g = l = n || m < 0 || (m > 1) > 1 >> m ? : 1 << m;\n    }\n  l = b + 1;\n  for (; b < 1; b++)\n    h = a + 1;\n}\n\nint\nmain ()\n{\n  char j; \n  for (; a < 1; a++)\n    {\n      fn1 ();\n      if (h)\n\tj = h;\n      if (j > c)\n\tg = 0;\n    }\n\n  if (h != 1) \n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68250.c",
    "content": "/* PR rtl-optimization/68250 */\n\nsigned char a, b, h, k, l, m, o;\nshort c, d, n;\nint e, f, g, j, q;\n\nvoid\nfn1 (void)\n{\n  int p = b || a;\n  n = o > 0 || d > 1 >> o ? d : d << o;\n  for (; j; j++)\n    m = c < 0 || m || c << p;\n  l = f + 1;\n  for (; f < 1; f = 1)\n    k = h + 1;\n}\n\n__attribute__((noinline, noclone)) void\nfn2 (int k)\n{\n  if (k != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  signed char i;\n  for (; e < 1; e++)\n    {\n      fn1 ();\n      if (k)\n\ti = k;\n      if (i > q)\n\tg = 0;\n    }\n  fn2 (k);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68321.c",
    "content": "/* PR rtl-optimization/68321 */\n\nint e = 1, u = 5, t2, t5, i, k;\nint a[1], b, m;\nchar n, t;\n\nint\nfn1 (int p1)\n{\n  int g[1];\n  for (;;)\n    {\n      if (p1 / 3)\n\tfor (; t5;)\n\t  u || n;\n      t2 = p1 & 4;\n      if (b + 1)\n\treturn 0;\n      u = g[0];\n    }\n}\n\nint\nmain ()\n{\n  for (; e >= 0; e--)\n    {\n      char c;\n      if (!m)\n\tc = t;\n      fn1 (c);\n    }\n  \n  if (a[t2] != 0) \n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68328.c",
    "content": "int a, b, c = 1, d = 1, e;\n\n__attribute__ ((noinline, noclone))\n     int foo (void)\n{\n  asm volatile (\"\":::\"memory\");\n  return 4195552;\n}\n\n__attribute__ ((noinline, noclone))\n     void bar (int x, int y)\n{\n  asm volatile (\"\"::\"g\" (x), \"g\" (y):\"memory\");\n  if (y == 0)\n    __builtin_abort ();\n}\n\nint\nbaz (int x)\n{\n  char g, h;\n  int i, j;\n\n  foo ();\n  for (;;)\n    {\n      if (c)\n\th = d;\n      g = h < x ? h : 0;\n      i = (signed char) ((unsigned char) (g - 120) ^ 1);\n      j = i > 97;\n      if (a - j)\n\tbar (0x123456, 0);\n      if (!b)\n\treturn e;\n    }\n}\n\nint\nmain ()\n{\n  baz (2);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68376-1.c",
    "content": "/* PR rtl-optimization/68376 */\n\nint a, b, c = 1;\nsigned char d;\n\nint\nmain ()\n{\n  for (; a < 1; a++)\n    for (; b < 1; b++)\n      {\n\tsigned char e = ~d;\n\tif (d < 1)\n\t  e = d;\n\td = e;\n\tif (!c)\n\t  __builtin_abort ();\n      }\n\n  if (d != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68376-2.c",
    "content": "/* PR rtl-optimization/68376 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nf1 (int x)\n{\n  return x < 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf2 (int x)\n{\n  return x < 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf3 (int x)\n{\n  return x <= 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf4 (int x)\n{\n  return x <= 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf5 (int x)\n{\n  return x >= 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf6 (int x)\n{\n  return x >= 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf7 (int x)\n{\n  return x > 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf8 (int x)\n{\n  return x > 0 ? x : ~x;\n}\n\nint\nmain ()\n{\n  if (f1 (5) != 5 || f1 (-5) != 4 || f1 (0) != 0)\n    abort ();\n  if (f2 (5) != -6 || f2 (-5) != -5 || f2 (0) != -1)\n    abort ();\n  if (f3 (5) != 5 || f3 (-5) != 4 || f3 (0) != -1)\n    abort ();\n  if (f4 (5) != -6 || f4 (-5) != -5 || f4 (0) != 0)\n    abort ();\n  if (f5 (5) != -6 || f5 (-5) != -5 || f5 (0) != -1)\n    abort ();\n  if (f6 (5) != 5 || f6 (-5) != 4 || f6 (0) != 0)\n    abort ();\n  if (f7 (5) != -6 || f7 (-5) != -5 || f7 (0) != 0)\n    abort ();\n  if (f8 (5) != 5 || f8 (-5) != 4 || f8 (0) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68381.c",
    "content": "/* { dg-options \"-O -fexpensive-optimizations -fno-tree-bit-ccp\" } */\n\n__attribute__ ((noinline, noclone))\nint\nfoo (unsigned short x, unsigned short y)\n{\n  int r;\n  if (__builtin_mul_overflow (x, y, &r))\n    __builtin_abort ();\n  return r;\n}\n\nint\nmain (void)\n{\n  int x = 1;\n  int y = 2;\n  if (foo (x, y) != x * y)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68390.c",
    "content": "/* { dg-do run }  */\n/* { dg-options \"-O2\" } */\n\n__attribute__ ((noinline))\ndouble direct(int x, ...)\n{\n  return x*x;\n}\n\n__attribute__ ((noinline))\ndouble broken(double (*indirect)(int x, ...), int v)\n{\n  return indirect(v);\n}\n\nint main ()\n{\n  double d1, d2;\n  int i = 2;\n  d1 = broken (direct, i);\n  if (d1 != i*i)\n    {\n      __builtin_abort ();\n    }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68506.c",
    "content": "/* { dg-options \"-fno-builtin-abort\" } */\n\nint a, b, m, n, o, p, s, u, i;\nchar c, q, y;\nshort d;\nunsigned char e;\nstatic int f, h;\nstatic short g, r, v;\nunsigned t;\n\nextern void abort ();\n\nint\nfn1 (int p1)\n{\n  return a ? p1 : p1 + a;\n}\n\nunsigned char\nfn2 (unsigned char p1, int p2)\n{\n  return p2 >= 2 ? p1 : p1 >> p2;\n}\n\nstatic short\nfn3 ()\n{\n  int w, x = 0;\n  for (; p < 31; p++)\n    {\n      s = fn1 (c | ((1 && c) == c));\n      t = fn2 (s, x);\n      c = (unsigned) c > -(unsigned) ((o = (m = d = t) == p) <= 4UL) && n;\n      v = -c;\n      y = 1;\n      for (; y; y++)\n\te = v == 1;\n      d = 0;\n      for (; h != 2;)\n\t{\n\t  for (;;)\n\t    {\n\t      if (!m)\n\t\tabort ();\n\t      r = 7 - f;\n\t      x = e = i | r;\n\t      q = u * g;\n\t      w = b == q;\n\t      if (w)\n\t\tbreak;\n\t    }\n\t  break;\n\t}\n    }\n  return x;\n}\n\nint\nmain ()\n{\n  fn3 ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68532.c",
    "content": "/* { dg-options \"-O2 -ftree-vectorize -fno-vect-cost-model\" } */\n/* { dg-additional-options \"-fno-common\" { target hppa*-*-hpux* } } */\n\n#define SIZE 128\nunsigned short _Alignas (16) in[SIZE];\n\n__attribute__ ((noinline)) int\ntest (unsigned short sum, unsigned short *in, int x)\n{\n  for (int j = 0; j < SIZE; j += 8)\n    sum += in[j] * x;\n  return sum;\n}\n\nint\nmain ()\n{\n  for (int i = 0; i < SIZE; i++)\n    in[i] = i;\n  if (test (0, in, 1) != 960)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68624.c",
    "content": "int b, c, d, e = 1, f, g, h, j;\n\nstatic int\nfn1 ()\n{\n  int a = c;\n  if (h)\n    return 9;\n  g = (c || b) % e;\n  if ((g || f) && b)\n    return 9;\n  e = d;\n  for (c = 0; c > -4; c--)\n    ;\n  if (d)\n    c--;\n  j = c;\n  return d;\n}\n\nint\nmain ()\n{\n  fn1 ();\n\n  if (c != -4)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68648.c",
    "content": "int __attribute__ ((noinline))\nfoo (void)\n{\n  return 123;\n}\n\nint __attribute__ ((noinline))\nbar (void)\n{\n  int c = 1;\n  c |= 4294967295 ^ (foo () | 4073709551608);\n  return c;\n}\n\nint\nmain ()\n{\n  if (bar () != 0x83fd4005)\n    __builtin_abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68841.c",
    "content": "static inline int\nfoo (int *x, int y)\n{\n  int z = *x;\n  while (y > z)\n    z *= 2;\n  return z;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 1; i < 17; i++)\n    {\n      int j;\n      int k;\n      j = foo (&i, 7);\n      if (i >= 7)\n\tk = i;\n      else if (i >= 4)\n\tk = 8 + (i - 4) * 2;\n      else if (i == 3)\n\tk = 12;\n      else\n\tk = 8;\n      if (j != k)\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr68911.c",
    "content": "extern void abort (void);\n\nchar a;\nint b, c;\nshort d;\n\nint main ()\n{\n  unsigned e = 2;\n  unsigned timeout = 0;\n\n  for (; c < 2; c++)\n    {\n      int f = ~e / 7;\n      if (f)\n\ta = e = ~(b && d);\n      while (e < 94)\n\t{\n\t  e++;\n\t  if (++timeout > 100)\n\t    goto die;\n\t}\n    }\n  return 0;\ndie:\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69097-1.c",
    "content": "/* PR tree-optimization/69097 */\n\nint a, b;\nunsigned int c;\n\nint\nmain ()\n{\n  int d = b;\n  b = ~(~a + (~d | b));\n  a = ~(~c >> b);\n  c = a % b;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69097-2.c",
    "content": "/* PR tree-optimization/69097 */\n\n__attribute__((noinline, noclone)) int\nf1 (int x, int y)\n{\n  return x % y;\n}\n\n__attribute__((noinline, noclone)) int\nf2 (int x, int y)\n{\n  return x % -y;\n}\n\n__attribute__((noinline, noclone)) int\nf3 (int x, int y)\n{\n  int z = -y;\n  return x % z;\n}\n\nint\nmain ()\n{\n  if (f1 (-__INT_MAX__ - 1, 1) != 0\n      || f2 (-__INT_MAX__ - 1, -1) != 0\n      || f3 (-__INT_MAX__ - 1, -1) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69320-1.c",
    "content": "#include <stdlib.h>\nint a, b, d, f;\nchar c;\nstatic int *e = &d;\nint main() {\n  int g = -1L;\n  *e = g;\n  c = 4;\n  for (; c >= 14; c++)\n    *e = 1;\n  f = a == 0;\n  *e ^= f;\n  int h = ~d;\n  if (d)\n    b = h;\n  if (h)\n    exit (0);\n  abort ();\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69320-2.c",
    "content": "\n#include <stdlib.h>\n\nint a, *c, d, e, g, f;\nshort b;\n\nint \nfn1 ()\n{\n  int h = d != 10;\n  if (h > g)\n     asm volatile (\"\" : : : \"memory\");\n  if (h == 10)\n    {\n      int *i = 0;\n      a = 0;\n      for (; a < 7; a++)\n\tfor (; *i;)\n\t  ;\n    }\n  else\n    {\n      b = e / h;\n      return f;\n    }\n  c = &h;\n  abort ();\n}\n\nint\nmain ()\n{\n  fn1 ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69320-3.c",
    "content": "#include <stdlib.h>\n\nstatic int a[40] = {7, 5, 3, 3, 0, 0, 3};\nshort b;\nint c = 5;\nint main() {\n  b = 0;\n  for (; b <= 3; b++)\n    if (a[b + 6] ^ (0 || c))\n      ;\n    else\n      break;\n  if (b != 4)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69320-4.c",
    "content": "#include <stdlib.h>\n\nint a;\nchar b, d;\nshort c;\nshort fn1(int p1, int p2) { return p2 >= 2 ? p1 : p1 > p2; }\n\nint main() {\n  int *e = &a, *f = &a;\n  b = 1;\n  for (; b <= 9; b++) {\n    c = *e != 5 || d;\n    *f = fn1(c || b, a);\n  }\n  if ((long long) a != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69403.c",
    "content": "/* PR target/69403.  */\n\nint a, b, c;\n\n__attribute__ ((__noinline__)) int\nfn1 ()\n{\n  if ((b | (a != (a & c))) == 1)\n    __builtin_abort ();\n  return 0;\n}\n\nint\nmain (void)\n{\n  a = 5;\n  c = 1;\n  b = 6;\n  return fn1 ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69447.c",
    "content": "typedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\ntypedef unsigned long long u64;\n\nu64 __attribute__((noinline, noclone))\nfoo(u8 u8_0, u16 u16_0, u64 u64_0, u8 u8_1, u16 u16_1, u64 u64_1, u64 u64_2, u8 u8_3, u64 u64_3)\n{\n\tu64_1 *= 0x7730;\n\tu64_3 *= u64_3;\n\tu16_1 |= u64_3;\n\tu64_3 -= 2;\n\tu8_3 /= u64_2;\n\tu8_0 |= 3;\n\tu64_3 %= u8_0;\n\tu8_0 -= 1;\n\treturn u8_0 + u16_0 + u64_0 + u8_1 + u16_1 + u64_1 + u8_3 + u64_3;\n}\n\nint main()\n{\n\tunsigned x = foo(1, 1, 1, 1, 1, 1, 1, 1, 1);\n\tif (x != 0x7737)\n\t\t__builtin_abort();\n\treturn 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr69691.c",
    "content": "/* PR rtl-optimization/69691 */\n\nchar u[] = { 46, 97, 99, 104, 52, 0 };\nchar *v[] = { u, 0 };\nstruct S { char a[10]; struct S *b[31]; };\nstruct S r[7], *r2 = r;\nstatic struct S *w = 0;\n\n__attribute__((noinline, noclone)) int\nfn (int x)\n{\n  if (__builtin_strchr (u, x) || x == 96)\n    return x;\n  __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) int\nfoo (char x)\n{\n  if (x == 0)\n    __builtin_abort ();\n  if (fn (x) >= 96 && fn (x) <= 122)\n    return (fn (x) - 96);\n  else if (x == 46)\n    return 0;\n  else\n    {\n      __builtin_printf (\"foo %d\\n\", x);\n      return -1;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nbar (char **x)\n{\n  char **b, c, *d, e[500], *f, g[10];\n  int z, l, h, i;\n  struct S *s;\n\n  w = r2++;\n  for (b = x; *b; b++)\n    {\n      __builtin_strcpy (e, *b);\n      f = e;\n      do\n\t{\n\t  d = __builtin_strchr (f, 32);\n\t  if (d)\n\t    *d = 0;\n\t  l = __builtin_strlen (f);\n\t  h = 0;\n\t  s = w;\n\t  __builtin_memset (g, 0, sizeof (g));\n\t  for (z = 0; z < l; z++)\n\t    {\n\t      c = f[z];\n\t      if (c >= 48 && c <= 57)\n\t\tg[h] = c - 48;\n\t      else\n\t\t{\n\t\t  i = foo (c);\n\t\t  if (!s->b[i])\n\t\t    {\n\t\t      s->b[i] = r2++;\n\t\t      if (r2 == &r[7])\n\t\t\t__builtin_abort ();\n\t\t    }\n\t\t  s = s->b[i];\n\t\t  h++;\n\t\t}\n\t    }\n\t  __builtin_memcpy (s->a, g, 10);\n\t  if (d)\n\t    f = d + 1;\n\t}\n      while (d);\n    }\n}\n\n__attribute__((noinline, noclone)) void\nbaz (char *x)\n{\n  char a[300], b[300];\n  int z, y, t, l;\n  struct S *s;\n\n  l = __builtin_strlen (x);\n  *a = 96;\n  for (z = 0; z < l; z++)\n    {\n      a[z + 1] = fn ((unsigned int) x[z]);\n      if (foo (a[z + 1]) <= 0)\n\treturn;\n    }\n  a[l + 1] = 96;\n  l += 2;\n  __builtin_memset (b, 0, l + 2);\n\n  if (!w)\n    return;\n\n  for (z = 0; z < l; z++)\n    {\n      s = w;\n      for (y = z; y < l; y++)\n\t{\n\t  s = s->b[foo (a[y])];\n\t  if (!s)\n\t    break;\n\t  for (t = 0; t <= y - z + 2; t++)\n\t    if (s->a[t] > b[z + t])\n\t      b[z + t] = s->a[t];\n\t}\n    }\n  for (z = 3; z < l - 2; z++)\n    if ((b[z] & 1) == 1)\n     asm (\"\");\n}\n\nint\nmain ()\n{\n  bar (v);\n  char c[] = { 97, 97, 97, 97, 97, 0 };\n  baz (c);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70005.c",
    "content": "\nunsigned char a = 6;\nint b, c;\n\nstatic void\nfn1 ()\n{\n  int i = a > 1 ? 1 : a, j = 6 & (c = a && (b = a));\n  int d = 0, e = a, f = ~c, g = b || a;\n  unsigned char h = ~a;\n  if (a)\n    f = j;\n  if (h && g)\n    d = a;\n  i = -~(f * d * h) + c && (e || i) ^ f;\n  if (i != 1) \n    __builtin_abort (); \n}\n\nint\nmain ()\n{\n  fn1 ();\n  return 0; \n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70127.c",
    "content": "/* PR tree-optimization/70127 */\n\nstruct S { int f; signed int g : 2; } a[1], c = {5, 1}, d;\nshort b;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  while (b++ <= 0)\n    {\n      struct S e = {1, 1};\n      d = e = a[0] = c;\n    }\n  foo (a[0].g);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70222-1.c",
    "content": "/* PR rtl-optimization/70222 */\n\nint a = 1;\nunsigned int b = 2;\nint c = 0;\nint d = 0;\n\nvoid\nfoo ()\n{\n  int e = ((-(c >= c)) < b) > ((int) (-1ULL >> ((a / a) * 15)));\n  d = -e;\n}\n\n__attribute__((noinline, noclone)) void\nbar (int x)\n{\n  if (x != -1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  foo ();\n  bar (d);\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70222-2.c",
    "content": "/* PR rtl-optimization/70222 */\n\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) unsigned int\nfoo (int x)\n{\n  unsigned long long y = -1ULL >> x;\n  return (unsigned int) y >> 31;\n}\n#endif\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  if (foo (15) != 1 || foo (32) != 1 || foo (33) != 0)\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70429.c",
    "content": "/* PR rtl-optimization/70429 */\n\n__attribute__((noinline, noclone)) int\nfoo (int a)\n{\n  return (int) (0x14ff6e2207db5d1fLL >> a) >> 4;\n}\n\nint\nmain ()\n{\n  if (sizeof (int) != 4 || sizeof (long long) != 8 || __CHAR_BIT__ != 8)\n    return 0;\n  if (foo (1) != 0x3edae8 || foo (2) != -132158092)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70460.c",
    "content": "/* PR rtl-optimization/70460 */\n\nint c;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  static int b[] = { &&lab1 - &&lab0, &&lab2 - &&lab0 };\n  void *a = &&lab0 + b[x];\n  goto *a;\nlab1:\n  c += 2;\nlab2:\n  c++;\nlab0:\n  ;\n}\n\nint\nmain ()\n{\n  foo (0);\n  if (c != 3)\n    __builtin_abort ();\n  foo (1);\n  if (c != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70566.c",
    "content": "/* PR target/70566.  */\n\n#define NULL 0\n\nstruct mystruct\n{\n  unsigned int f1 : 1;\n  unsigned int f2 : 1;\n  unsigned int f3 : 1;\n};\n\n__attribute__ ((noinline)) void\nmyfunc (int a, void *b)\n{\n}\n__attribute__ ((noinline)) int\nmyfunc2 (void *a)\n{\n  return 0;\n}\n\nstatic void\nset_f2 (struct mystruct *user, int f2)\n{\n  if (user->f2 != f2)\n    myfunc (myfunc2 (NULL), NULL);\n  else\n    __builtin_abort ();\n}\n\n__attribute__ ((noinline)) void\nfoo (void *data)\n{\n  struct mystruct *user = data;\n  if (!user->f2)\n    set_f2 (user, 1);\n}\n\nint\nmain (void)\n{\n  struct mystruct a;\n  a.f1 = 1;\n  a.f2 = 0;\n  foo (&a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70586.c",
    "content": "/* PR tree-optimization/70586 */\n\nint a, e, f;\nshort b, c, d;\n\nint\nfoo (int x, int y)\n{\n  return (y == 0 || (x && y == 1)) ? x : x % y;\n}\n\nstatic short\nbar (void)\n{\n  int i = foo (c, f);\n  f = foo (d, 2);\n  int g = foo (b, c);\n  int h = foo (g > 0, c);\n  c = (3 >= h ^ 7) <= foo (i, c);\n  if (foo (e, 1))\n    return a;\n  return 0;\n}\n\nint\nmain ()\n{\n  bar ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr70602.c",
    "content": "/* PR tree-optimization/70602 */\n\nstruct __attribute__((packed)) S\n{\n  int s : 1;\n  int t : 20;\n};\n\nint a, b, c;\n\nint\nmain ()\n{\n  for (; a < 1; a++)\n    {\n      struct S e[] = { {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, \n\t\t       {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, \n\t\t       {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9} };\n      b = b || e[0].s;\n      c = e[0].t;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71083.c",
    "content": "struct lock_chain {\n  unsigned int irq_context: 2,\n    depth: 6,\n    base: 24;\n};\n\n__attribute__((noinline, noclone))\nstruct lock_chain * foo (struct lock_chain *chain)\n{\n  int i;\n  for (i = 0; i < 100; i++)\n    {\n      chain[i+1].base = chain[i].base;\n    }\n  return chain;\n}\n\nstruct lock_chain1 {\n  char x;\n  unsigned short base;\n} __attribute__((packed));\n\n__attribute__((noinline, noclone))\nstruct lock_chain1 * bar (struct lock_chain1 *chain)\n{\n  int i;\n  for (i = 0; i < 100; i++)\n    {\n      chain[i+1].base = chain[i].base;\n    }\n  return chain;\n}\n\nstruct lock_chain test [101];\nstruct lock_chain1 test1 [101];\n\nint\nmain ()\n{\n  foo (test);\n  bar (test1);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71494.c",
    "content": "/* PR middle-end/71494 */\n\nint\nmain ()\n{\n  void *label = &&out;\n  int i = 0;\n  void test (void)\n  {\n    label = &&out2;\n    goto *label;\n   out2:;\n    i++;\n  }\n  goto *label;\n out:\n  i += 2;\n  test ();\n  if (i != 3)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71554.c",
    "content": "/* PR target/71554 */\n\nint v;\n\n__attribute__ ((noinline, noclone)) void\nbar (void)\n{\n  v++;\n}\n\n__attribute__ ((noinline, noclone))\nvoid\nfoo (unsigned int x)\n{\n  signed int y = ((-__INT_MAX__ - 1) / 2);\n  signed int r;\n  if (__builtin_mul_overflow (x, y, &r))\n    bar ();\n}\n\nint\nmain ()\n{\n  foo (2);\n  if (v)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71626-1.c",
    "content": "/* PR middle-end/71626 */\n\ntypedef __INTPTR_TYPE__ V __attribute__((__vector_size__(sizeof (__INTPTR_TYPE__))));\n\n__attribute__((noinline, noclone)) V\nfoo ()\n{\n  V v = { (__INTPTR_TYPE__) foo };\n  return v;\n}\n\nint\nmain ()\n{\n  V v = foo ();\n  if (v[0] != (__INTPTR_TYPE__) foo)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71626-2.c",
    "content": "/* PR middle-end/71626 */\n/* { dg-additional-options \"-fpic\" { target fpic } } */\n\n#include \"pr71626-1.c\"\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr71700.c",
    "content": "struct S\n{\n  signed f0 : 16;\n  unsigned f1 : 1;\n};\n\nint b;\nstatic struct S c[] = {{-1, 0}, {-1, 0}};\nstruct S d;\n\nint\nmain ()\n{\n  struct S e = c[0];\n  d = e;\n  if (d.f1 != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr7284-1.c",
    "content": "/* Signed left-shift is implementation-defined in C89 (and see\n   DR#081), not undefined.  Bug 7284 from Al Grant (AlGrant at\n   myrealbox.com).  */\n\n/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-std=c89\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint\nf (int n)\n{\n  return (n << 24) / (1 << 23);\n}\n\nvolatile int x = 128;\n\nint\nmain (void)\n{\n  if (f(x) != -256)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pr78378.c",
    "content": "/* PR rtl-optimization/78378 */\n\nunsigned long long __attribute__ ((noinline, noclone))\nfoo (unsigned long long x)\n{\n  x <<= 41;\n  x /= 232;\n  return 1 + (unsigned short) x;\n}\n\nint\nmain ()\n{\n  unsigned long long x = foo (1);\n  if (x != 0x2c24)\n    __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/printf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain (void)\n{\n#define test(ret, args...) \\\n  printf (args); \t\t\\\n  if (printf (args) != ret)\t\\\n    abort ();\n  test (5, \"hello\");\n  test (6, \"hello\\n\");\n  test (1, \"a\");\n  test (0, \"\");\n  test (5, \"%s\", \"hello\");\n  test (6, \"%s\", \"hello\\n\");\n  test (1, \"%s\", \"a\");\n  test (0, \"%s\", \"\");\n  test (1, \"%c\", 'x');\n  test (7, \"%s\\n\", \"hello\\n\");\n  test (2, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__printf_chk (int flag, const char *fmt, ...)\n{\n  va_list ap;\n  int ret;\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  va_start (ap, fmt);\n  ret = vprintf (fmt, ap);\n  va_end (ap);\n  return ret;\n}\n\nint\nmain (void)\n{\n#define test(ret, opt, args...) \\\n  should_optimize = opt;\t\t\\\n  __printf_chk (1, args); \t\t\\\n  if (!should_optimize)\t\t\t\\\n    abort ();\t\t\t\t\\\n  should_optimize = 0;\t\t\t\\\n  if (__printf_chk (1, args) != ret)\t\\\n    abort ();\t\t\t\t\\\n  if (!should_optimize)\t\t\t\\\n    abort ();\n  test (5, 0, \"hello\");\n  test (6, 1, \"hello\\n\");\n  test (1, 1, \"a\");\n  test (0, 1, \"\");\n  test (5, 0, \"%s\", \"hello\");\n  test (6, 1, \"%s\", \"hello\\n\");\n  test (1, 1, \"%s\", \"a\");\n  test (0, 1, \"%s\", \"\");\n  test (1, 1, \"%c\", 'x');\n  test (7, 1, \"%s\\n\", \"hello\\n\");\n  test (2, 0, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pta-field-1.c",
    "content": "struct Foo {\n  int *p;\n  int *q;\n};\n\nvoid __attribute__((noinline))\nbar (int **x)\n{\n  struct Foo *f = (struct Foo *)x;\n  *(f->q) = 0;\n}\n\nint foo(void)\n{\n  struct Foo f;\n  int i = 1, j = 2;\n  f.p = &i;\n  f.q = &j;\n  bar(&f.p);\n  return j;\n}\n\nextern void abort (void);\nint main()\n{\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pta-field-2.c",
    "content": "struct Foo {\n  int *p;\n  int *q;\n};\n\nvoid __attribute__((noinline))\nbar (int **x)\n{\n  struct Foo *f = (struct Foo *)(x - 1);\n  *(f->p) = 0;\n}\n\nint foo(void)\n{\n  struct Foo f;\n  int i = 1, j = 2;\n  f.p = &i;\n  f.q = &j;\n  bar(&f.q);\n  return i;\n}\n\nextern void abort (void);\nint main()\n{\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/ptr-arith-1.c",
    "content": "char *\nf (char *s, unsigned int i)\n{\n  return &s[i + 3 - 1];\n}\n\nmain ()\n{\n  char *str = \"abcdefghijkl\";\n  char *x2 = f (str, 12);\n  if (str + 14 != x2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pure-1.c",
    "content": "\n/* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-05-27.  */\n\n/* Use a different function for each test so the link failures\n   indicate which one is broken.  */\nextern void link_error0 (void);\nextern void link_error1 (void);\nextern void link_error2 (void);\nextern void link_error3 (void);\nextern void link_error4 (void);\nextern void link_error5 (void);\nextern void link_error6 (void);\nextern void link_error7 (void);\n\nextern int i;\n\nextern int func0 (int) __attribute__ ((__pure__));\nextern int func1 (int) __attribute__ ((__const__));\n\n/* GCC should automatically detect attributes for these functions.\n   At -O3 They'll be inlined, but that's ok.  */\nstatic int func2 (int a) { return i + a; } /* pure */\nstatic int func3 (int a) { return a * 3; } /* const */\nstatic int func4 (int a) { return func0(a) + a; } /* pure */\nstatic int func5 (int a) { return a + func1(a); } /* const */\nstatic int func6 (int a) { return func2(a) + a; } /* pure */\nstatic int func7 (int a) { return a + func3(a); } /* const */\n\nint main ()\n{\n  int i[10], r;\n\n  i[0] = 0;\n  r = func0(0);\n  if (i[0])\n    link_error0();\n\n  i[1] = 0;\n  r = func1(0);\n  if (i[1])\n    link_error1();\n\n  i[2] = 0;\n  r = func2(0);\n  if (i[2])\n    link_error2();\n\n  i[3] = 0;\n  r = func3(0);\n  if (i[3])\n    link_error3();\n\n  i[4] = 0;\n  r = func4(0);\n  if (i[4])\n    link_error4();\n\n  i[5] = 0;\n  r = func5(0);\n  if (i[5])\n    link_error5();\n\n  i[6] = 0;\n  r = func6(0);\n  if (i[6])\n    link_error6();\n\n  i[7] = 0;\n  r = func7(0);\n  if (i[7])\n    link_error7();\n\n  return r;\n}\n\nint func0 (int a) { return a - i; } /* pure */\nint func1 (int a) { return a - a; } /* const */\n\nint i = 2;\n\n#ifndef __OPTIMIZE__\n/* Avoid link failures when not optimizing. */\nvoid link_error0() {}\nvoid link_error1() {}\nvoid link_error2() {}\nvoid link_error3() {}\nvoid link_error4() {}\nvoid link_error5() {}\nvoid link_error6() {}\nvoid link_error7() {}\n#endif /* ! __OPTIMIZE__ */\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/pushpop_macro.c",
    "content": "extern void abort ();\n\n#define _ 2\n#pragma push_macro(\"_\")\n#undef _\n#define _ 1\n#pragma pop_macro(\"_\")\n\nint main ()\n{\n  if (_ != 2)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/regstack-1.c",
    "content": "long double C = 5;\nlong double U = 1;\nlong double Y2 = 11;\nlong double Y1 = 17;\nlong double X, Y, Z, T, R, S;\nmain ()\n{\n  X = (C + U) * Y2;\n  Y = C - U - U;\n  Z = C + U + U;\n  T = (C - U) * Y1;\n  X = X - (Z + U);\n  R = Y * Y1;\n  S = Z * Y2;\n  T = T - Y;\n  Y = (U - Y) + R;\n  Z = S - (Z + U + U);\n  R = (Y2 + U) * Y1;\n  Y1 = Y2 * Y1;\n  R = R - Y2;\n  Y1 = Y1 - 0.5L;\n  if (Z != 68. || Y != 49. || X != 58. || Y1 != 186.5 || R != 193. || S != 77.\n      || T != 65. || Y2 != 11.)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/restrict-1.c",
    "content": "/*  PR rtl-optimization/16536\n    Origin:  Jeremy Denise      <jeremy.denise@libertysurf.fr>\n    Reduced: Wolfgang Bangerth  <bangerth@dealii.org>\n             Volker Reichelt    <reichelt@igpm.rwth-aachen.de>  */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort ();\n\ntypedef struct\n{\n  int i, dummy;\n} A;\n\ninline A foo (const A* p, const A* q)\n{\n  return (A){p->i+q->i};\n}\n\nvoid bar (A* __restrict__ p)\n{\n  *p=foo(p,p);\n  if (p->i!=2)\n    abort();\n}\n\nint main ()\n{\n  A a={1};\n  bar(&a);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define operl(a, b, op) (a op b)\n#define operr(a, b, op) (b op a)\n\n#define check(type, count, vec0, vec1, num, op, lr) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) {\\\n        if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \\\n            __builtin_abort (); \\\n    }\\\n} while (0)\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\nvolatile int one = 1;\n\nint main (int argc, char *argv[]) {\n#define fvec_2 (vector(4, float)){2., 2., 2., 2.}\n#define dvec_2 (vector(2, double)){2., 2.}\n\n\n    vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};\n    vector(8, short) v1;\n\n    vector(4, float) f0 = {1., 2., 3., 4.};\n    vector(4, float) f1, f2;\n\n    vector(2, double) d0 = {1., 2.};\n    vector(2, double) d1, d2;\n\n\n\n    v1 = 2 + v0;   check (short, 8, v0, v1, 2, +, l);\n    v1 = 2 - v0;   check (short, 8, v0, v1, 2, -, l);\n    v1 = 2 * v0;   check (short, 8, v0, v1, 2, *, l);\n    v1 = 2 / v0;   check (short, 8, v0, v1, 2, /, l);\n    v1 = 2 % v0;   check (short, 8, v0, v1, 2, %, l);\n    v1 = 2 ^ v0;   check (short, 8, v0, v1, 2, ^, l);\n    v1 = 2 & v0;   check (short, 8, v0, v1, 2, &, l);\n    v1 = 2 | v0;   check (short, 8, v0, v1, 2, |, l);\n    v1 = 2 << v0;   check (short, 8, v0, v1, 2, <<, l);\n    v1 = 2 >> v0;   check (short, 8, v0, v1, 2, >>, l);\n\n    v1 = v0 + 2;   check (short, 8, v0, v1, 2, +, r);\n    v1 = v0 - 2;   check (short, 8, v0, v1, 2, -, r);\n    v1 = v0 * 2;   check (short, 8, v0, v1, 2, *, r);\n    v1 = v0 / 2;   check (short, 8, v0, v1, 2, /, r);\n    v1 = v0 % 2;   check (short, 8, v0, v1, 2, %, r);\n    v1 = v0 ^ 2;   check (short, 8, v0, v1, 2, ^, r);\n    v1 = v0 & 2;   check (short, 8, v0, v1, 2, &, r);\n    v1 = v0 | 2;   check (short, 8, v0, v1, 2, |, r);\n\n    f1 = 2. + f0;  f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);\n    f1 = 2. - f0;  f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);\n    f1 = 2. * f0;  f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);\n    f1 = 2. / f0;  f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);\n\n    f1 = f0 + 2.;  f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 - 2.;  f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 * 2.;  f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 / 2.;  f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);\n\n    d1 = 2. + d0;  d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);\n    d1 = 2. - d0;  d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);\n    d1 = 2. * d0;  d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);\n    d1 = 2. / d0;  d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);\n\n    d1 = d0 + 2.;  d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 - 2.;  d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 * 2.;  d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 / 2.;  d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/scal-to-vec2.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define operl(a, b, op) (a op b)\n#define operr(a, b, op) (b op a)\n\n#define check(type, count, vec0, vec1, num, op, lr) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) {\\\n        if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \\\n            __builtin_abort (); \\\n    }\\\n} while (0)\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\n\nlong __attribute__ ((noinline)) vlng () {   return (long)42; }\nint  __attribute__ ((noinline)) vint () {   return (int) 43; }\nshort __attribute__ ((noinline)) vsrt () {   return (short)42; }\nchar __attribute__ ((noinline)) vchr () {    return (char)42; }\n\n\nint main (int argc, char *argv[]) {\n    vector(16, char) c0 = {argc, 1,2,3,4,5,6,7, argc, 1,2,3,4,5,6,7};\n    vector(16, char) c1;\n    \n    vector(8, short) s0 = {argc, 1,2,3,4,5,6,7};\n    vector(8, short) s1;\n\n    vector(4, int) i0 = {argc, 1, 2, 3};\n    vector(4, int) i1;\n\n    vector(2, long) l0 = {argc, 1};\n    vector(2, long) l1;\n\n    c1 = vchr() + c0; check (char, 16, c0, c1, vchr(), +, l);\n    \n    s1 = vsrt() + s0; check (short, 8, s0, s1, vsrt(), +, l);\n    s1 = vchr() + s0; check (short, 8, s0, s1, vchr(), +, l);\n\n    i1 = vint() * i0; check (int, 4, i0, i1, vint(), *, l);\n    i1 = vsrt() * i0; check (int, 4, i0, i1, vsrt(), *, l);\n    i1 = vchr() * i0; check (int, 4, i0, i1, vchr(), *, l);\n\n    l1 = vlng() * l0; check (long, 2, l0, l1, vlng(), *, l);\n    l1 = vint() * l0; check (long, 2, l0, l1, vint(), *, l);\n    l1 = vsrt() * l0; check (long, 2, l0, l1, vsrt(), *, l);\n    l1 = vchr() * l0; check (long, 2, l0, l1, vchr(), *, l);\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/scal-to-vec3.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\n\nint main (int argc, char *argv[]) {\n#define fvec_2 (vector(4, float)){2., 2., 2., 2.}\n#define dvec_2 (vector(2, double)){2., 2.}\n\n    vector(4, float) f0 = {1., 2., 3., 4.};\n    vector(4, float) f1, f2;\n\n    vector(2, double) d0 = {1., 2.};\n    vector(2, double) d1, d2;\n\n\n    f1 = 2 + f0;  f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);\n    f1 = 2 - f0;  f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);\n    f1 = 2 * f0;  f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);\n    f1 = 2 / f0;  f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);\n\n    f1 = f0 + 2;  f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 - 2;  f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 * 2;  f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 / 2;  f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);\n\n    d1 = 2 + d0;  d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);\n    d1 = 2 - d0;  d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);\n    d1 = 2 * d0;  d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);\n    d1 = 2 / d0;  d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);\n\n    d1 = d0 + 2;  d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 - 2;  d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 * 2;  d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 / 2;  d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);\n\n    return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/scope-1.c",
    "content": "int v = 3;\n\nf ()\n{\n  int v = 4;\n  {\n    extern int v;\n    if (v != 3)\n      abort ();\n  }\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/shiftdi.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Failed on sparc with -mv8plus because sparc.c:set_extends() thought\n   erroneously that SImode ASHIFT chops the upper bits, it does not.  */\n\ntypedef unsigned long long uint64;\n\nvoid g(uint64 x, int y, int z, uint64 *p)\n{\n\tunsigned w = ((x >> y) & 0xffffffffULL) << (z & 0x1f);\n\t*p |= (w & 0xffffffffULL) << z;\n}\n\nint main(void)\n{\n\tuint64 a = 0;\n\tg(0xdeadbeef01234567ULL, 0, 0, &a);\n\treturn (a == 0x01234567) ? 0 : 1;\n}\n\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation\n\n   Check that constant folding of shift operations is working.\n\n   Roger Sayle, 10th October 2002.  */\n\nextern void abort (void);\nextern void link_error (void);\n\nvoid\nutest (unsigned int x)\n{\n  if (x >> 0 != x)\n    link_error ();\n\n  if (x << 0 != x)\n    link_error ();\n\n  if (0 << x != 0)\n    link_error ();\n\n  if (0 >> x != 0)\n    link_error ();\n\n  if (-1 >> x != -1)\n    link_error ();\n\n  if (~0 >> x != ~0)\n    link_error ();\n}\n\nvoid\nstest (int x)\n{\n  if (x >> 0 != x)\n    link_error ();\n\n  if (x << 0 != x)\n    link_error ();\n\n  if (0 << x != 0)\n    link_error ();\n\n  if (0 >> x != 0)\n    link_error ();\n}\n\nint\nmain ()\n{\n  utest(9);\n  utest(0);\n\n  stest(9);\n  stest(0);\n\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_error ()\n{\n  abort ();\n}\n#endif\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/simd-1.c",
    "content": "/* Origin: Aldy Hernandez <aldyh@redhat.com>\n\n   Purpose: Test generic SIMD support.  This test should work\n   regardless of if the target has SIMD instructions.\n*/\n\ntypedef int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint;\ntypedef int __attribute__((mode(SI))) siint;\n\nvecint i = { 150, 100, 150, 200 };\nvecint j = { 10, 13, 20, 30 };\nvecint k;\n\nunion {\n  vecint v;\n  siint i[4];\n} res;\n\n/* This should go away once we can use == and != on vector types.  */\nvoid\nverify (siint a1, siint a2, siint a3, siint a4,\n\tsiint b1, siint b2, siint b3, siint b4)\n{\n  if (a1 != b1\n      || a2 != b2\n      || a3 != b3\n      || a4 != b4)\n    abort ();\n}\n\nint\nmain ()\n{\n  k = i + j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);\n\n  k = i * j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);\n\n  k = i / j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);\n\n  k = i & j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);\n\n  k = i | j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);\n\n  k = i ^ j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);\n\n  k = -i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3],\n\t  -150, -100, -150, -200);\n\n  k = ~i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/simd-2.c",
    "content": "/* \n   Purpose: Test generic SIMD support, V8HImode.  This test should work\n   regardless of if the target has SIMD instructions.\n*/\n\ntypedef short __attribute__((vector_size (16))) vecint;\n\nvecint i = { 150, 100, 150, 200, 0, 0, 0, 0 };\nvecint j = { 10, 13, 20, 30, 1, 1, 1, 1 };\nvecint k;\n\nunion {\n  vecint v;\n  short i[8];\n} res;\n\n/* This should go away once we can use == and != on vector types.  */\nvoid\nverify (int a1, int a2, int a3, int a4,\n\tint b1, int b2, int b3, int b4)\n{\n  if (a1 != b1\n      || a2 != b2\n      || a3 != b3\n      || a4 != b4)\n    abort ();\n}\n\nint\nmain ()\n{\n  k = i + j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);\n\n  k = i * j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);\n\n  k = i / j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);\n\n  k = i & j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);\n\n  k = i | j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);\n\n  k = i ^ j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);\n\n  k = -i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3],\n\t  -150, -100, -150, -200);\n\n  k = ~i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/simd-4.c",
    "content": "/* { dg-require-effective-target stdint_types } */\n#include <stdint.h>\ntypedef int32_t __attribute__((vector_size(8))) v2si;\nint64_t s64;\n\nstatic inline int64_t\n__ev_convert_s64 (v2si a)\n{\n  return (int64_t) a;\n}\n\nint main()\n{\n  union { int64_t ll; int32_t i[2]; } endianness_test;\n  endianness_test.ll = 1;\n  int32_t little_endian = endianness_test.i[0];\n  s64 = __ev_convert_s64 ((v2si){1,0xffffffff});\n  if (s64 != (little_endian ? 0xffffffff00000001LL : 0x1ffffffffLL))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/simd-5.c",
    "content": "/* Test saving and restoring of SIMD registers.  */\n\ntypedef short Q __attribute__((vector_size(8)));\n\nQ q1 = {1, 2}, q2 = {3, 4}, q3 = {5, 6}, q4 = {7, 8};\n\nQ w1, w2, w3, w4;\nQ z1, z2, z3, z4;\n\nvolatile int dummy;\n\nvoid  __attribute__((__noinline__))\nfunc0 (void)\n{\n  dummy = 1;\n}\n\nvoid __attribute__((__noinline__))\nfunc1 (void)\n{\n  Q a, b;\n  a = q1 * q2;\n  b = q3 * q4;\n  w1 = a;\n  w2 = b;\n  func0 ();\n  w3 = a;\n  w4 = b;\n}\n\nvoid __attribute__((__noinline__))\nfunc2 (void)\n{\n  Q a, b;\n  a = q1 + q2;\n  b = q3 - q4;\n  z1 = a;\n  z2 = b;\n  func1 ();\n  z3 = a;\n  z4 = b;\n}\n\nint\nmain (void)\n{\n  func2 ();\n\n  if (memcmp (&w1, &w3, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&w2, &w4, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&z1, &z3, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&z2, &z4, sizeof (Q)) != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/simd-6.c",
    "content": "extern void abort (void);\nextern int memcmp (const void *, const void *, __SIZE_TYPE__);\n\ntypedef unsigned char v8qi __attribute__((vector_size(8)));\n\nv8qi foo(v8qi x, v8qi y)\n{\n  return x * y;\n}\n\nint main()\n{\n  v8qi a = { 1, 2, 3, 4, 5, 6, 7, 8 };\n  v8qi b = { 3, 3, 3, 3, 3, 3, 3, 3 };\n  v8qi c = { 3, 6, 9, 12, 15, 18, 21, 24 };\n  v8qi r;\n\n  r = foo (a, b);\n  if (memcmp (&r, &c, 8) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/stdarg-1.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\nva_list *pap;\n\nvoid\nfoo (int v, va_list ap)\n{\n  switch (v)\n    {\n    case 5: foo_arg = va_arg (ap, int); break;\n    default: abort ();\n    }\n}\n\nvoid\nbar (int v)\n{\n  if (v == 0x4006)\n    {\n      if (va_arg (gap, double) != 17.0\n\t  || va_arg (gap, long) != 129L)\n\tabort ();\n    }\n  else if (v == 0x4008)\n    {\n      if (va_arg (*pap, long long) != 14LL\n\t  || va_arg (*pap, long double) != 131.0L\n\t  || va_arg (*pap, int) != 17)\n\tabort ();\n    }\n  bar_arg = v;\n}\n\nvoid\nf0 (int i, ...)\n{\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  va_end (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  bar (d);\n  x = va_arg (ap, long);\n  bar (x);\n  va_end (ap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  d = va_arg (ap, double);\n  va_end (ap);\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  x = va_arg (ap, double);\n  foo (i, ap);\n  va_end (ap);\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  va_copy (gap, ap);\n  bar (i);\n  va_end (ap);\n  va_end (gap);\n}\n\nvoid\nf6 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  bar (d);\n  va_arg (ap, long);\n  va_arg (ap, long);\n  x = va_arg (ap, long);\n  bar (x);\n  va_end (ap);\n}\n\nvoid\nf7 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  pap = &ap;\n  bar (i);\n  va_end (ap);\n}\n\nvoid\nf8 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  pap = &ap;\n  bar (i);\n  d = va_arg (ap, double);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  f0 (1);\n  f1 (2);\n  d = 31.0;\n  f2 (3, 28L);\n  if (bar_arg != 28 || x != 28)\n    abort ();\n  f3 (4, 131.0);\n  if (d != 131.0)\n    abort ();\n  f4 (5, 16.0, 128);\n  if (x != 16 || foo_arg != 128)\n    abort ();\n  f5 (0x4006, 17.0, 129L);\n  if (bar_arg != 0x4006)\n    abort ();\n  f6 (7, 12L, 14L, -31L);\n  if (bar_arg != -31)\n    abort ();\n  f7 (0x4008, 14LL, 131.0L, 17, 26.0);\n  if (bar_arg != 0x4008)\n    abort ();\n  f8 (0x4008, 14LL, 131.0L, 17, 27.0);\n  if (bar_arg != 0x4008 || d != 27.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/stdarg-2.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\n\nvoid\nfoo (int v, va_list ap)\n{\n  switch (v)\n    {\n    case 5:\n      foo_arg = va_arg (ap, int);\n      foo_arg += va_arg (ap, double);\n      foo_arg += va_arg (ap, long long);\n      break;\n    case 8:\n      foo_arg = va_arg (ap, long long);\n      foo_arg += va_arg (ap, double);\n      break;\n    case 11:\n      foo_arg = va_arg (ap, int);\n      foo_arg += va_arg (ap, long double);\n      break;\n    default:\n      abort ();\n    }\n}\n\nvoid\nbar (int v)\n{\n  if (v == 0x4002)\n    {\n      if (va_arg (gap, int) != 13 || va_arg (gap, double) != -14.0)\n\tabort ();\n    }\n  bar_arg = v;\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_start (gap, i);\n  x = va_arg (gap, long);\n  va_end (gap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_start (gap, i);\n  bar (i);\n  va_end (gap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  x = va_arg (aps[4], long);\n  va_end (aps[4]);\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  bar (i);\n  va_end (aps[4]);\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  foo (i, aps[4]);\n  va_end (aps[4]);\n}\n\nstruct A { int i; va_list g; va_list h[2]; };\n\nvoid\nf6 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  x = va_arg (a.g, long);\n  va_end (a.g);\n}\n\nvoid\nf7 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  bar (i);\n  va_end (a.g);\n}\n\nvoid\nf8 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  foo (i, a.g);\n  va_end (a.g);\n}\n\nvoid\nf10 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  x = va_arg (a.h[1], long);\n  va_end (a.h[1]);\n}\n\nvoid\nf11 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  bar (i);\n  va_end (a.h[1]);\n}\n\nvoid\nf12 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  foo (i, a.h[1]);\n  va_end (a.h[1]);\n}\n\nint\nmain (void)\n{\n  f1 (1, 79L);\n  if (x != 79L)\n    abort ();\n  f2 (0x4002, 13, -14.0);\n  if (bar_arg != 0x4002)\n    abort ();\n  f3 (3, 2031L);\n  if (x != 2031)\n    abort ();\n  f4 (4, 18);\n  if (bar_arg != 4)\n    abort ();\n  f5 (5, 1, 19.0, 18LL);\n  if (foo_arg != 38)\n    abort ();\n  f6 (6, 18L);\n  if (x != 18L)\n    abort ();\n  f7 (7);\n  if (bar_arg != 7)\n    abort ();\n  f8 (8, 2031LL, 13.0);\n  if (foo_arg != 2044)\n    abort ();\n  f10 (9, 180L);\n  if (x != 180L)\n    abort ();\n  f11 (10);\n  if (bar_arg != 10)\n    abort ();\n  f12 (11, 2030, 12.0L);\n  if (foo_arg != 2042)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/stdarg-3.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\nstruct S1 { int i; double d; int j; double e; } s1;\nstruct S2 { double d; long i; } s2;\nint y;\n\nvoid\nbar (int v)\n{\n  bar_arg = v;\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    x = va_arg (ap, long);\n  va_end (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    d = va_arg (ap, double);\n  va_end (ap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      x = va_arg (ap, long);\n      va_end (ap);\n      bar (x);\n    }\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      d = va_arg (ap, double);\n      va_end (ap);\n      bar (d + 4.0);\n    }\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    s1 = va_arg (ap, struct S1);\n  va_end (ap);\n}\n\nvoid\nf6 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    s2 = va_arg (ap, struct S2);\n  va_end (ap);\n}\n\nvoid\nf7 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      s1 = va_arg (ap, struct S1);\n      va_end (ap);\n      bar (s1.i);\n    }\n}\n\nvoid\nf8 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      s2 = va_arg (ap, struct S2);\n      y = va_arg (ap, int);\n      va_end (ap);\n      bar (s2.i);\n    }\n}\n\nint\nmain (void)\n{\n  struct S1 a1, a3;\n  struct S2 a2, a4;\n\n  f1 (7, 1L, 2L, 3L, 5L, 7L, 9L, 11L, 13L);\n  if (x != 11L)\n    abort ();\n  f2 (6, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0);\n  if (d != 32.0)\n    abort ();\n  f3 (2, 1L, 3L);\n  if (bar_arg != 1L || x != 1L)\n    abort ();\n  f4 (2, 17.0, 19.0);\n  if (bar_arg != 21 || d != 17.0)\n    abort ();\n  a1.i = 131;\n  a1.j = 251;\n  a1.d = 15.0;\n  a1.e = 191.0;\n  a3 = a1;\n  a3.j = 254;\n  a3.e = 178.0;\n  f5 (2, a1, a3, a1);\n  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)\n    abort ();\n  f5 (3, a1, a3, a1);\n  if (s1.i != 131 || s1.j != 251 || s1.d != 15.0 || s1.e != 191.0)\n    abort ();\n  a2.i = 138;\n  a2.d = 16.0;\n  a4.i = 257;\n  a4.d = 176.0;\n  f6 (2, a2, a4, a2);\n  if (s2.i != 257 || s2.d != 176.0)\n    abort ();\n  f6 (3, a2, a4, a2);\n  if (s2.i != 138 || s2.d != 16.0)\n    abort ();\n  f7 (2, a3, a1, a1);\n  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)\n    abort ();\n  if (bar_arg != 131)\n    abort ();\n  f8 (3, a4, a2, a2);\n  if (s2.i != 257 || s2.d != 176.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/stdarg-4.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\nlong x, y;\n\ninline void __attribute__((always_inline))\nf1i (va_list ap)\n{\n  x = va_arg (ap, double);\n  x += va_arg (ap, long);\n  x += va_arg (ap, double);\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  f1i (ap);\n  va_end (ap);\n}\n\ninline void __attribute__((always_inline))\nf2i (va_list ap)\n{\n  y = va_arg (ap, int);\n  y += va_arg (ap, long);\n  y += va_arg (ap, double);\n  f1i (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  f2i (ap);\n  va_end (ap);\n}\n\nlong\nf3h (int i, long arg0, long arg1, long arg2, long arg3)\n{\n  return i + arg0 + arg1 + arg2 + arg3;\n}\n\nlong\nf3 (int i, ...)\n{\n  long t, arg0, arg1, arg2, arg3;\n  va_list ap;\n\n  va_start (ap, i);\n  switch (i)\n    {\n    case 0:\n      t = f3h (i, 0, 0, 0, 0);\n      break;\n    case 1:\n      arg0 = va_arg (ap, long);\n      t = f3h (i, arg0, 0, 0, 0);\n      break;\n    case 2:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, 0, 0);\n      break;\n    case 3:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      arg2 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, arg2, 0);\n      break;\n    case 4:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      arg2 = va_arg (ap, long);\n      arg3 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, arg2, arg3);\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n\n  return t;\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n\n  va_start (ap, i);\n  switch (i)\n    {\n    case 4:\n      y = va_arg (ap, double);\n      break;\n    case 5:\n      y = va_arg (ap, double);\n      y += va_arg (ap, double);\n      break;\n    default:\n      abort ();\n    }\n  f1i (ap);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  f1 (3, 16.0, 128L, 32.0);\n  if (x != 176L)\n    abort ();\n  f2 (6, 5, 7L, 18.0, 19.0, 17L, 64.0);\n  if (x != 100L || y != 30L)\n    abort ();\n  if (f3 (0) != 0)\n    abort ();\n  if (f3 (1, 18L) != 19L)\n    abort ();\n  if (f3 (2, 18L, 100L) != 120L)\n    abort ();\n  if (f3 (3, 18L, 100L, 300L) != 421L)\n    abort ();\n  if (f3 (4, 18L, 71L, 64L, 86L) != 243L)\n    abort ();\n  f4 (4, 6.0, 9.0, 16L, 18.0);\n  if (x != 43L || y != 6L)\n    abort ();\n  f4 (5, 7.0, 21.0, 1.0, 17L, 126.0);\n  if (x != 144L || y != 28L)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/stkalign.c",
    "content": "/* { dg-options \"-fno-inline\" } */\n/* Check that stack alignment is not affected by variables not placed\n   on the stack.  */\n\n#include <assert.h>\n\n#define ALIGNMENT 64\n\nunsigned test(unsigned n, unsigned p)\n{\n  static struct { char __attribute__((__aligned__(ALIGNMENT))) c; } s;\n  unsigned x;\n\n  assert(__alignof__(s) == ALIGNMENT);\n  asm (\"\" : \"=g\" (x), \"+m\" (s) : \"0\" (&x));\n\n  return n ? test(n - 1, x) : (x ^ p);\n}\n\nunsigned test2(unsigned n, unsigned p)\n{\n  static struct { char c; } s;\n  unsigned x;\n\n  assert(__alignof__(s) != ALIGNMENT);\n  asm (\"\" : \"=g\" (x), \"+m\" (s) : \"0\" (&x));\n\n  return n ? test2(n - 1, x) : (x ^ p);\n}\n\nint main (int argc, char *argv[] __attribute__((unused)))\n{\n  unsigned int x, y;\n\n  x = test(argc, 0);\n  x |= test(argc + 1, 0);\n  x |= test(argc + 2, 0);\n\n  y = test2(argc, 0);\n  y |= test2(argc + 1, 0);\n  y |= test2(argc + 2, 0);\n\n  return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strcmp-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strcmp with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 2)\n\nstatic union {\n  unsigned char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\ntest (const unsigned char *s1, const unsigned char *s2, int expected)\n{\n  int value = strcmp ((char *) s1, (char *) s2);\n\n  if (expected < 0 && value >= 0)\n    abort ();\n  else if (expected == 0 && value != 0)\n    abort ();\n  else if (expected > 0 && value <= 0)\n    abort ();\n}\n\nmain ()\n{\n  size_t off1, off2, len, i;\n  unsigned char *buf1, *buf2;\n  unsigned char *mod1, *mod2;\n  unsigned char *p1, *p2;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 0; len < MAX_TEST; len++)\n\t{\n\t  p1 = u1.buf;\n\t  for (i = 0; i < off1; i++)\n\t    *p1++ = '\\0';\n\n\t  buf1 = p1;\n\t  for (i = 0; i < len; i++)\n\t    *p1++ = 'a';\n\n\t  mod1 = p1;\n\t  for (i = 0; i < MAX_EXTRA+2; i++)\n\t    *p1++ = 'x';\n\n\t  p2 = u2.buf;\n\t  for (i = 0; i < off2; i++)\n\t    *p2++ = '\\0';\n\n\t  buf2 = p2;\n\t  for (i = 0; i < len; i++)\n\t    *p2++ = 'a';\n\n\t  mod2 = p2;\n\t  for (i = 0; i < MAX_EXTRA+2; i++)\n\t    *p2++ = 'x';\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, 0);\n\n\t  mod1[0] = 'a';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = 'a';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'c';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = 'c';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\252';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = (unsigned char)'\\252';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strcpy-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strcpy with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nmain ()\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\t  u2.buf[off2 + len] = '\\0';\n\n\t  p = strcpy (u1.buf + off1, u2.buf + off2);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  if (*q++ != '\\0')\n\t    abort ();\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strcpy-2.c",
    "content": "/* Test to make sure strcpy works correctly. */\n#define STRING \"Hi!THE\"\n\nconst char a[] = STRING;\n\nvoid f(char *a) __attribute__((noinline));\nvoid f(char *a)\n{\n  __builtin_strcpy (a, STRING);\n}\n\n\nint main(void)\n{\n  int i;\n  char b[sizeof(a)] = {};\n  f(b);\n  for(i = 0; i < sizeof(b); i++)\n    {\n      if (a[i] != b[i])\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-pack-1.c",
    "content": "typedef struct\n{\n  short s __attribute__ ((aligned(2), packed));\n  double d __attribute__ ((aligned(2), packed));\n} TRIAL;\n\nint\ncheck (TRIAL *t)\n{\n  if (t->s != 1 || t->d != 16.0)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  TRIAL trial;\n\n  trial.s = 1;\n  trial.d = 16.0;\n\n  if (check (&trial) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-pack-2.c",
    "content": "typedef struct\n{\n  short a __attribute__ ((aligned (2),packed));\n  short *ap[2]  __attribute__ ((aligned (2),packed));\n} A;\n\nmain ()\n{\n  short i, j = 1;\n  A a, *ap = &a;\n  ap->ap[j] = &i;\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c",
    "content": "typedef struct\n{\n  short i __attribute__ ((aligned (2),packed));\n  int f[2] __attribute__ ((aligned (2),packed));\n} A;\n\nf (ap)\n  A *ap;\n{\n  short i, j = 1;\n\n  i = ap->f[1];\n  i += ap->f[j];\n  for (j = 0; j < 2; j++)\n    i += ap->f[j];\n\n  return i;\n}\n\nmain ()\n{\n  A a;\n  a.f[0] = 100;\n  a.f[1] = 13;\n  if (f (&a) != 139)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-pack-4.c",
    "content": "typedef struct\n{\n  unsigned char a __attribute__((packed));\n  unsigned short b __attribute__((packed));\n} three_char_t;\n\nunsigned char\nmy_set_a (void)\n{\n  return 0xab;\n}\n\nunsigned short\nmy_set_b (void)\n{\n  return 0x1234;\n}\n\nmain ()\n{\n  three_char_t three_char;\n\n  three_char.a = my_set_a ();\n  three_char.b = my_set_b ();\n  if (three_char.a != 0xab || three_char.b != 0x1234)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-stdarg-1.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n  char g;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n      if (x.f != i + 40)\n\tabort();\n      if (x.g != i + 50)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  x[0].g = 50;\n  x[1].g = 51;\n  x[2].g = 52;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.c",
    "content": "#include <stdarg.h>\n\nstruct s { int x, y; };\n\nf (int attr, ...)\n{\n  struct s va_values;\n  va_list va;\n  int i;\n\n  va_start (va, attr);\n\n  if (attr != 2)\n    abort ();\n\n  va_values = va_arg (va, struct s);\n  if (va_values.x != 0xaaaa || va_values.y != 0x5555)\n    abort ();\n\n  attr = va_arg (va, int);\n  if (attr != 3)\n    abort ();\n\n  va_values = va_arg (va, struct s);\n  if (va_values.x != 0xffff || va_values.y != 0x1111)\n    abort ();\n\n  va_end (va);\n}\n\nmain ()\n{\n  struct s a, b;\n\n  a.x = 0xaaaa;\n  a.y = 0x5555;\n  b.x = 0xffff;\n  b.y = 0x1111;\n\n  f (2, a, 3, b);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/string-opt-17.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test strcpy optimizations don't evaluate side-effects twice.\n      \n   Written by Jakub Jelinek, June 23, 2003.  */\n\ntypedef __SIZE_TYPE__ size_t;\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void abort (void);\nextern void exit (int);\n\nsize_t\ntest1 (char *s, size_t i)\n{\n  strcpy (s, \"foobarbaz\" + i++);\n  return i;\n}\n\nsize_t\ncheck2 (void)\n{\n  static size_t r = 5;\n  if (r != 5)\n    abort ();\n  return ++r;\n}\n\nvoid\ntest2 (char *s)\n{\n  strcpy (s, \"foobarbaz\" + check2 ());\n}\n\nint\nmain (void)\n{\n  char buf[10];\n  if (test1 (buf, 7) != 8 || memcmp (buf, \"az\", 3))\n    abort ();\n  test2 (buf);\n  if (memcmp (buf, \"baz\", 4))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test equal pointer optimizations don't break anything.\n\n   Written by Roger Sayle, July 14, 2003.  */\n\nextern void abort ();\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memcpy(void*, const void*, size_t);\nextern void *mempcpy(void*, const void*, size_t);\nextern void *memmove(void*, const void*, size_t);\nextern char *strcpy(char*, const char*);\nextern int memcmp(const void*, const void*, size_t);\nextern int strcmp(const char*, const char*);\nextern int strncmp(const char*, const char*, size_t);\n\n\nvoid test1 (void *ptr)\n{\n  if (memcpy(ptr,ptr,8) != ptr)\n    abort ();\n}\n\nvoid test2 (char *ptr)\n{\n  if (mempcpy(ptr,ptr,8) != ptr+8)\n    abort ();\n}\n\nvoid test3 (void *ptr)\n{\n  if (memmove(ptr,ptr,8) != ptr)\n    abort ();\n}\n\nvoid test4 (char *ptr)\n{\n  if (strcpy(ptr,ptr) != ptr)\n    abort ();\n}\n\nvoid test5 (void *ptr)\n{\n  if (memcmp(ptr,ptr,8) != 0)\n    abort ();\n}\n\nvoid test6 (const char *ptr)\n{\n  if (strcmp(ptr,ptr) != 0)\n    abort ();\n}\n\nvoid test7 (const char *ptr)\n{\n  if (strncmp(ptr,ptr,8) != 0)\n    abort ();\n}\n\n\nint main ()\n{\n  char buf[10];\n\n  test1 (buf);\n  test2 (buf);\n  test3 (buf);\n  test4 (buf);\n  test5 (buf);\n  test6 (buf);\n  test7 (buf);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/string-opt-5.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure builtin strlen, strcmp, strchr, strrchr and strncpy\n   perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.  */\n\nextern void abort (void);\nextern __SIZE_TYPE__ strlen (const char *);\nextern int strcmp (const char *, const char *);\nextern char *strchr (const char *, int);\nextern char *strrchr (const char *, int);\nextern char *strncpy (char *, const char *, __SIZE_TYPE__);\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern int memcmp (const void *, const void *, __SIZE_TYPE__);\n\nint x = 6;\nint y = 1;\nchar *bar = \"hi world\";\nchar buf [64];\n\nint main()\n{\n  const char *const foo = \"hello world\";\n  char dst [64];\n\n  if (strlen (bar) != 8)\n    abort ();\n  if (strlen (bar + (++x & 2)) != 6)\n    abort ();\n  if (x != 7)\n    abort ();\n  if (strlen (foo + (x++, 6)) != 5)\n    abort ();\n  if (x != 8)\n    abort ();\n  if (strlen (foo + (++x & 1)) != 10)\n    abort ();\n  if (x != 9)\n    abort ();\n  if (strcmp (foo + (x -= 6), \"lo world\"))\n    abort ();\n  if (x != 3)\n    abort ();\n  if (strcmp (foo, bar) >= 0)\n    abort ();\n  if (strcmp (foo, bar + (x++ & 1)) >= 0)\n    abort ();\n  if (x != 4)\n    abort ();\n  if (strchr (foo + (x++ & 7), 'l') != foo + 9)\n    abort ();\n  if (x != 5)\n    abort ();\n  if (strchr (bar, 'o') != bar + 4)\n    abort ();\n  if (strchr (bar, '\\0')  != bar + 8)\n    abort ();\n  if (strrchr (bar, 'x'))\n    abort ();\n  if (strrchr (bar, 'o') != bar + 4)\n    abort ();\n  if (strcmp (foo + (x++ & 1), \"ello world\" + (--y & 1)))\n    abort ();\n  if (x != 6 || y != 0)\n    abort ();\n  dst[5] = ' ';\n  dst[6] = '\\0';\n  x = 5;\n  y = 1;\n  if (strncpy (dst + 1, foo + (x++ & 3), 4) != dst + 1\n      || x != 6\n      || strcmp (dst + 1, \"ello \"))\n    abort ();\n  memset (dst, ' ', sizeof dst);\n  if (strncpy (dst + (++x & 1), (y++ & 3) + \"foo\", 10) != dst + 1\n      || x != 7\n      || y != 2\n      || memcmp (dst, \" oo\\0\\0\\0\\0\\0\\0\\0\\0 \", 12))\n    abort ();\n  memset (dst, ' ', sizeof dst);\n  if (strncpy (dst, \"hello\", 8) != dst || memcmp (dst, \"hello\\0\\0\\0 \", 9))\n    abort ();\n  x = '!';\n  memset (buf, ' ', sizeof buf);\n  if (memset (buf, x++, ++y) != buf\n      || x != '!' + 1\n      || y != 3\n      || memcmp (buf, \"!!!\", 3))\n    abort ();\n  if (memset (buf + y++, '-', 8) != buf + 3\n      || y != 4\n      || memcmp (buf, \"!!!--------\", 11))\n    abort ();\n  x = 10;\n  if (memset (buf + ++x, 0, y++) != buf + 11\n      || x != 11\n      || y != 5\n      || memcmp (buf + 8, \"---\\0\\0\\0\", 7))\n    abort ();\n  if (memset (buf + (x += 4), 0, 6) != buf + 15\n      || x != 15\n      || memcmp (buf + 10, \"-\\0\\0\\0\\0\\0\\0\\0\\0\\0\", 11))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strlen-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strlen with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 1)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nmain ()\n{\n  size_t off, len, len2, i;\n  char *p;\n\n  for (off = 0; off < MAX_OFFSET; off++)\n    for (len = 0; len < MAX_TEST; len++)\n      {\n\tp = u.buf;\n\tfor (i = 0; i < off; i++)\n\t  *p++ = '\\0';\n\n\tfor (i = 0; i < len; i++)\n\t  *p++ = 'a';\n\n\t*p++ = '\\0';\n\tfor (i = 0; i < MAX_EXTRA; i++)\n\t  *p++ = 'b';\n\n\tp = u.buf + off;\n\tlen2 = strlen (p);\n\tif (len != len2)\n\t  abort ();\n      }\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/strncmp-1.c",
    "content": "/* { dg-xfail-if \"kernel strncmp does not perform unsigned comparisons\" { vxworks_kernel } \"*\" \"\" } */\n/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strncmp with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA)\n\nstatic union {\n  unsigned char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\ntest (const unsigned char *s1, const unsigned char *s2, size_t len, int expected)\n{\n  int value = strncmp ((char *) s1, (char *) s2, len);\n\n  if (expected < 0 && value >= 0)\n    abort ();\n  else if (expected == 0 && value != 0)\n    abort ();\n  else if (expected > 0 && value <= 0)\n    abort ();\n}\n\nmain ()\n{\n  size_t off1, off2, len, i;\n  unsigned char *buf1, *buf2;\n  unsigned char *mod1, *mod2;\n  unsigned char *p1, *p2;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 0; len < MAX_TEST; len++)\n\t{\n\t  p1 = u1.buf;\n\t  for (i = 0; i < off1; i++)\n\t    *p1++ = '\\0';\n\n\t  buf1 = p1;\n\t  for (i = 0; i < len; i++)\n\t    *p1++ = 'a';\n\n\t  mod1 = p1;\n\t  for (i = 0; i < MAX_EXTRA; i++)\n\t    *p1++ = 'x';\n\n\t  p2 = u2.buf;\n\t  for (i = 0; i < off2; i++)\n\t    *p2++ = '\\0';\n\n\t  buf2 = p2;\n\t  for (i = 0; i < len; i++)\n\t    *p2++ = 'a';\n\n\t  mod2 = p2;\n\t  for (i = 0; i < MAX_EXTRA; i++)\n\t    *p2++ = 'x';\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, 0);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'a';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = 'a';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'c';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'c';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\252';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\252';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-aliasing-1.c",
    "content": "struct S { float f; };\nint __attribute__((noinline))\nfoo (int *r, struct S *p)\n{\n  int *q = (int *)&p->f;\n  int i = *q;\n  *r = 0;\n  return i + *q;\n}\nextern void abort (void);\nint main()\n{\n  int i = 1;\n  if (foo (&i, (struct S *)&i) != 1)\n    abort ();\n  return (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-cpy-1.c",
    "content": "/* powerpc64-linux gcc miscompiled this due to rs6000.c:expand_block_move\n   not setting mem aliasing info correctly for the code implementing the\n   structure assignment.  */\n\nstruct termios\n{\n  unsigned int a;\n  unsigned int b;\n  unsigned int c;\n  unsigned int d;\n  unsigned char pad[28];\n};\n\nstruct tty_driver\n{\n  unsigned char pad1[38];\n  struct termios t __attribute__ ((aligned (8)));\n};\n\nstatic struct termios zero_t;\nstatic struct tty_driver pty;\n\nvoid ini (void)\n{\n  pty.t = zero_t;\n  pty.t.a = 1;\n  pty.t.b = 2;\n  pty.t.c = 3;\n  pty.t.d = 4;\n}\n\nint main (void)\n{\n  extern void abort (void);\n\n  ini ();\n  if (pty.t.a != 1\n      || pty.t.b != 2\n      || pty.t.c != 3\n      || pty.t.d != 4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ini-1.c",
    "content": "struct S\n{\n  char f1;\n  int f2[2];\n};\n\nstruct S object = {'X', 8, 9};\n\nmain ()\n{\n  if (object.f1 != 'X' || object.f2[0] != 8 || object.f2[1] != 9)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ini-2.c",
    "content": "struct {\n  int a:4;\n  int :4;\n  int b:4;\n  int c:4;\n} x = { 2,3,4 };\n\nmain ()\n{\n  if (x.a != 2)\n    abort ();\n  if (x.b != 3)\n    abort ();\n  if (x.c != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ini-3.c",
    "content": "struct\n{\n  unsigned int f1:1, f2:1, f3:3, f4:3, f5:2, f6:1, f7:1;\n} result = {1, 1, 7, 7, 3, 1, 1};\n\nmain ()\n{\n  if ((result.f3 & ~7) != 0 || (result.f4 & ~7) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ini-4.c",
    "content": "struct s {\n  int a[3];\n  int c[3];\n};\n\nstruct s s = {\n  c: {1, 2, 3}\n};\n\nmain()\n{\n  if (s.c[0] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c",
    "content": "#include <stdio.h>\n#include <string.h>\n\nchar out[100];\n\ntypedef struct { double d; int i[3]; } B;\ntypedef struct { char c[33],c1; } X;\n\nchar c1 = 'a';\nchar c2 = 127;\nchar c3 = (char)128;\nchar c4 = (char)255;\nchar c5 = -1;\n\ndouble d1 = 0.1;\ndouble d2 = 0.2;\ndouble d3 = 0.3;\ndouble d4 = 0.4;\ndouble d5 = 0.5;\ndouble d6 = 0.6;\ndouble d7 = 0.7;\ndouble d8 = 0.8;\ndouble d9 = 0.9;\n\nB B1 = {0.1,{1,2,3}};\nB B2 = {0.2,{5,4,3}};\nX X1 = {\"abcdefghijklmnopqrstuvwxyzABCDEF\", 'G'};\nX X2 = {\"123\",'9'};\nX X3 = {\"return-return-return\",'R'};\n\nX f (B a, char b, double c, B d)\n{\n  static X xr = {\"return val\", 'R'};\n  X r;\n  r = xr;\n  r.c1 = b;\n  sprintf (out, \"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})\",\n\t   a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]);\n  return r;\n}\n\nX (*fp) (B, char, double, B) = &f;\n\nmain ()\n{\n  X Xr;\n  char tmp[100];\n\n  Xr = f (B1, c2, d3, B2);\n  strcpy (tmp, out);\n  Xr.c[0] = Xr.c1 = '\\0';\n  Xr = (*fp) (B1, c2, d3, B2);\n  if (strcmp (tmp, out))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/struct-ret-2.c",
    "content": "typedef struct\n{\n  unsigned char a __attribute__ ((packed));\n  unsigned short b __attribute__ ((packed));\n} three_byte_t;\n\nunsigned char\nf (void)\n{\n  return 0xab;\n}\n\nunsigned short\ng (void)\n{\n  return 0x1234;\n}\n\nmain ()\n{\n  three_byte_t three_byte;\n\n  three_byte.a = f ();\n  three_byte.b = g ();\n  if (three_byte.a != 0xab || three_byte.b != 0x1234)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/switch-1.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test that switch statements suitable using case bit tests are\n   implemented correctly.\n\n   Written by Roger Sayle, 01/25/2001.  */\n\nextern void abort (void);\n\nint\nfoo (int x)\n{\n  switch (x)\n    {\n    case 4:\n    case 6:\n    case 9:\n    case 11:\n      return 30;\n    }\n  return 31;\n}\n\nint\nmain ()\n{\n  int i, r;\n\n  for (i=-1; i<66; i++)\n    {\n      r = foo (i);\n      if (i == 4)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 6)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 9)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 11)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (r != 31)\n\tabort ();\n    }\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/tstdi-1.c",
    "content": "#define FALSE 140\n#define TRUE 13\n\nfeq (x)\n     long long int x;\n{\n  if (x == 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfne (x)\n     long long int x;\n{\n  if (x != 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nflt (x)\n     long long int x;\n{\n  if (x < 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfge (x)\n     long long int x;\n{\n  if (x >= 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfgt (x)\n     long long int x;\n{\n  if (x > 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfle (x)\n     long long int x;\n{\n  if (x <= 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nmain ()\n{\n  if (feq (0LL) != TRUE)\n    abort ();\n  if (feq (-1LL) != FALSE)\n    abort ();\n  if (feq (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (feq (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (feq (1LL) != FALSE)\n    abort ();\n  if (feq (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  if (fne (0LL) != FALSE)\n    abort ();\n  if (fne (-1LL) != TRUE)\n    abort ();\n  if (fne (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (fne (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (fne (1LL) != TRUE)\n    abort ();\n  if (fne (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (flt (0LL) != FALSE)\n    abort ();\n  if (flt (-1LL) != TRUE)\n    abort ();\n  if (flt (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (flt (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (flt (1LL) != FALSE)\n    abort ();\n  if (flt (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  if (fge (0LL) != TRUE)\n    abort ();\n  if (fge (-1LL) != FALSE)\n    abort ();\n  if (fge (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (fge (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (fge (1LL) != TRUE)\n    abort ();\n  if (fge (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (fgt (0LL) != FALSE)\n    abort ();\n  if (fgt (-1LL) != FALSE)\n    abort ();\n  if (fgt (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (fgt (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (fgt (1LL) != TRUE)\n    abort ();\n  if (fgt (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (fle (0LL) != TRUE)\n    abort ();\n  if (fle (-1LL) != TRUE)\n    abort ();\n  if (fle (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (fle (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (fle (1LL) != FALSE)\n    abort ();\n  if (fle (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/unroll-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\ninline int\nf (int x)\n{\n  return (x + 1);\n}\n \nint\nmain (void)\n{\n  int a = 0 ;\n \n  while ( (f(f(f(f(f(f(f(f(f(f(1))))))))))) + a < 12 )\n    {\n      a++;\n      exit (0);\n    }\n  if (a != 1)\n    abort();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/usmul.c",
    "content": "/* { dg-require-effective-target int32plus } */\nint __attribute__ ((noinline)) foo (short x, unsigned short y)\n{\n  return x * y;\n}\n\nint __attribute__ ((noinline)) bar (unsigned short x, short y)\n{\n  return x * y;\n}\n\nint main ()\n{\n  if (foo (-2, 0xffff) != -131070)\n    abort ();\n  if (foo (2, 0xffff) != 131070)\n    abort ();\n  if (foo (-32768, 0x8000) != -1073741824)\n    abort ();\n  if (foo (32767, 0x8000) != 1073709056)\n    abort ();\n\n  if (bar (0xffff, -2) != -131070)\n    abort ();\n  if (bar (0xffff, 2) != 131070)\n    abort ();\n  if (bar (0x8000, -32768) != -1073741824)\n    abort ();\n  if (bar (0x8000, 32767) != 1073709056)\n    abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-1.c",
    "content": "#include <stdarg.h>\n\ntypedef unsigned long L;\nf (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, L) != 10)\n    abort ();\n  if (va_arg (select, L) != 11)\n    abort ();\n  if (va_arg (select, L) != 0)\n    abort ();\n\n  va_end (select);\n}\n\nmain ()\n{\n  f (1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 0L);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-10.c",
    "content": "/* This is a modfied version of va-arg-9.c to test va_copy.  */\n\n#include <stdarg.h>\n\n#ifndef va_copy\n#define va_copy __va_copy\n#endif\n\nextern __SIZE_TYPE__ strlen (const char *);\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nfap (int i, char* format, va_list ap)\n{\n  va_list apc;\n  char *formatc;\n\n  va_copy (apc, ap);\n  formatc = format;\n\n  if (strlen (format) != 16 - i)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  while (*formatc)\n    if (*formatc++ != to_hex (va_arg (apc, int)))\n      abort ();\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  fap(0, format, ap);\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(1, format, ap);\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(2, format, ap);\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(3, format, ap);\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(4, format, ap);\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(5, format, ap);\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(6, format, ap);\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(7, format, ap);\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(8, format, ap);\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8, int a9,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(9, format, ap);\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(10, format, ap);\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(11, format, ap);\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(12, format, ap);\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(13, format, ap);\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(14, format, ap);\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(15, format, ap);\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-11.c",
    "content": "/* Test va_arg when the result is ignored and only the pointer increment\n   side effect is used.  */\n#include <stdarg.h>\n\nstatic int\nfoo (int a, ...)\n{\n  va_list va;\n  int i, res;\n\n  va_start (va, a);\n\n  for (i = 0; i < 4; ++i)\n    (void) va_arg (va, int);\n\n  res = va_arg (va, int);\n\n  va_end (va);\n\n  return res;\n}\n\nint\nmain (void)\n{\n  if (foo (5, 4, 3, 2, 1, 0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-12.c",
    "content": "#include <stdarg.h>\n\n/*typedef unsigned long L;*/\ntypedef double L;\nvoid f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, L) != 10.)\n    abort ();\n  if (va_arg (select, L) != 11.)\n    abort ();\n  if (va_arg (select, L) != 0.)\n    abort ();\n\n  va_end (select);\n}\n\nint main ()\n{\n  f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 0.);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-13.c",
    "content": "/* derived from mozilla source code */\n\n#include <stdarg.h>\n\ntypedef struct {\n  void *stream;\n  va_list ap;\n  int nChar;  \n} ScanfState;\n\nvoid dummy (va_list vap)\n{\n  if (va_arg (vap, int) != 1234) abort();\n  return;\n}\n\nvoid test (int fmt, ...)\n{\n  ScanfState state, *statep;\n\n  statep = &state;\n\n  va_start (statep->ap, fmt);\n  dummy (statep->ap);\n  va_end (statep->ap);\n  \n  va_start (state.ap, fmt);\n  dummy (state.ap);\n  va_end (state.ap);\n  \n  return;\n}\n\nint main (void)\n{\n  test (456, 1234);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-14.c",
    "content": "#include <stdarg.h>\n\nva_list global;\n\nvoid vat(va_list param, ...)\n{\n  va_list local;\n\n  va_start (local, param);\n  va_copy (global, local);\n  va_copy (param, local);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  if (va_arg (global, int) != 1)\n    abort();\n  va_end (global);\n  if (va_arg (param, int) != 1)\n    abort();\n  va_end (param);\n\n  va_start (param, param);\n  va_start (global, param);\n  va_copy (local, param);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  va_copy (local, global);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  if (va_arg (global, int) != 1)\n    abort();\n  va_end (global);\n  if (va_arg (param, int) != 1)\n    abort();\n  va_end (param);\n}\n\nint main(void) \n{\n  va_list t;\n  vat (t, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-15.c",
    "content": "#include <stdarg.h>\n\nvoid vafunction (char *dummy, ...)\n{\n  double darg;\n  int iarg;\n  int flag = 0;\n  int i;\n  va_list ap;\n\n  va_start(ap, dummy);\n  for (i = 1; i <= 18; i++, flag++) \n    {\n      if (flag & 1)\n\t{\n\t  darg = va_arg (ap, double);\t\n\t  if (darg != (double)i)\n\t    abort();\n\t}\n      else\n\t{\n\t  iarg = va_arg (ap, int);\n\t  if (iarg != i)\n\t    abort();\n\t}\n    }\n    va_end(ap);\n}\n\nint main (void)\n{\n  vafunction( \"\", \n\t1, 2., \n\t3, 4., \n\t5, 6., \n\t7, 8., \n\t9, 10.,\n\t11, 12.,\n\t13, 14.,\n\t15, 16.,\n\t17, 18. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-16.c",
    "content": "#include <stdarg.h>\n\ntypedef double TYPE;\n\nvoid vafunction (TYPE dummy1, TYPE dummy2, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy2);\n  if (dummy1 != 888.)\n    abort();\n  if (dummy2 != 999.)\n    abort();\n  if (va_arg (ap, TYPE) != 1.)\n    abort();\n  if (va_arg (ap, TYPE) != 2.)\n    abort();\n  if (va_arg (ap, TYPE) != 3.)\n    abort();\n  if (va_arg (ap, TYPE) != 4.)\n    abort();\n  if (va_arg (ap, TYPE) != 5.)\n    abort();\n  if (va_arg (ap, TYPE) != 6.)\n    abort();\n  if (va_arg (ap, TYPE) != 7.)\n    abort();\n  if (va_arg (ap, TYPE) != 8.)\n    abort();\n  if (va_arg (ap, TYPE) != 9.)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( 888., 999., 1., 2., 3., 4., 5., 6., 7., 8., 9. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-17.c",
    "content": "#include <stdarg.h>\n\ntypedef double TYPE;\n\nvoid vafunction (char *dummy, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy);\n  if (va_arg (ap, TYPE) != 1.)\n    abort();\n  if (va_arg (ap, TYPE) != 2.)\n    abort();\n  if (va_arg (ap, TYPE) != 3.)\n    abort();\n  if (va_arg (ap, TYPE) != 4.)\n    abort();\n  if (va_arg (ap, TYPE) != 5.)\n    abort();\n  if (va_arg (ap, TYPE) != 6.)\n    abort();\n  if (va_arg (ap, TYPE) != 7.)\n    abort();\n  if (va_arg (ap, TYPE) != 8.)\n    abort();\n  if (va_arg (ap, TYPE) != 9.)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( \"\", 1., 2., 3., 4., 5., 6., 7., 8., 9. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-18.c",
    "content": "#include <stdarg.h>\n\ntypedef double L;\nvoid f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, int) != 10)\n    abort ();\n  if (va_arg (select, int) != 11)\n    abort ();\n  if (va_arg (select, int) != 12)\n    abort ();\n\n  va_end (select);\n}\n\nint main ()\n{\n  f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10, 11, 12);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-19.c",
    "content": "#include <stdarg.h>\n\ntypedef int TYPE;\n\nvoid vafunction (char *dummy, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy);\n  if (va_arg (ap, TYPE) != 1)\n    abort();\n  if (va_arg (ap, TYPE) != 2)\n    abort();\n  if (va_arg (ap, TYPE) != 3)\n    abort();\n  if (va_arg (ap, TYPE) != 4)\n    abort();\n  if (va_arg (ap, TYPE) != 5)\n    abort();\n  if (va_arg (ap, TYPE) != 6)\n    abort();\n  if (va_arg (ap, TYPE) != 7)\n    abort();\n  if (va_arg (ap, TYPE) != 8)\n    abort();\n  if (va_arg (ap, TYPE) != 9)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( \"\", 1, 2, 3, 4, 5, 6, 7, 8, 9 );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-2.c",
    "content": "/* The purpose of this test is to catch edge cases when arguments are passed\n   in regs and on the stack.  We test 16 cases, trying to catch multiple\n   targets (some use 3 regs for argument passing, some use 12, etc.).\n   We test both the arguments and the `lastarg' (the argument to va_start).  */\n\n#include <stdarg.h>\n\nextern __SIZE_TYPE__ strlen ();\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  if (strlen (format) != 16 - 0)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 1)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 2)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 3)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 4)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 5)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 6)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 7)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 8)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 9)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 10)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 11)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 12)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 13)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 14)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 15)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-20.c",
    "content": "#include <stdarg.h>\n\nvoid foo(va_list v)\n{\n    unsigned long long x = va_arg (v, unsigned long long);\n    if (x != 16LL)\n\tabort();\n}\n\nvoid bar(char c, char d, ...)\n{\n    va_list v;\n    va_start(v, d);\n    foo(v);\n    va_end(v);\n}\n\nint main(void)\n{\n    bar(0, 0, 16LL);\n    exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-21.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   If the argument to va_end() has side effects, test whether side\n   effects from that argument are honored.\n\n   Written by Kaveh R. Ghazi, 10/31/2000.  */\n\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#ifndef __GNUC__\n#define __attribute__(x)\n#endif\n\nstatic void __attribute__ ((__format__ (__printf__, 1, 2)))\ndoit (const char *s, ...) \n{\n  va_list *ap_array[3], **ap_ptr = ap_array;\n\n  ap_array[0] = malloc (sizeof(va_list));\n  ap_array[1] = NULL;\n  ap_array[2] = malloc (sizeof(va_list));\n  \n  va_start (*ap_array[0], s);\n  vprintf (s, **ap_ptr);\n  /* Increment the va_list pointer once.  */\n  va_end (**ap_ptr++);\n\n  /* Increment the va_list pointer a second time.  */\n  ap_ptr++;\n  \n  va_start (*ap_array[2], s);\n  /* If we failed to increment ap_ptr twice, then the parameter passed\n     in here will dereference NULL and should cause a crash.  */\n  vprintf (s, **ap_ptr);\n  va_end (**ap_ptr);\n\n  /* Just in case, If *ap_ptr is NULL abort anyway.  */\n  if (*ap_ptr == 0)\n    abort();\n}\n\nint main()\n{\n  doit (\"%s\", \"hello world\\n\");\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-22.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\nextern void exit (int);\n\nvoid bar (int n, int c)\n{\n  static int lastn = -1, lastc = -1;\n\n  if (lastn != n)\n    {\n      if (lastc != lastn)\n\tabort ();\n      lastc = 0;\n      lastn = n;\n    }\n\n  if (c != (char) (lastc ^ (n << 3)))\n    abort ();\n  lastc++;\n}\n\n#define D(N) typedef struct { char x[N]; } A##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n\nvoid foo (int size, ...)\n{\n#define D(N) A##N a##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  va_list ap;\n  int i;\n\n  if (size != 21)\n    abort ();\n  va_start (ap, size);\n#define D(N)\t\t\t\t\t\\\n  a##N = va_arg (ap, typeof (a##N));\t\t\\\n  for (i = 0; i < N; i++)\t\t\t\\\n    bar (N, a##N.x[i]);\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  va_end (ap);\n}\n\nint main (void)\n{\n#define D(N) A##N a##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  int i;\n\n#define D(N)\t\t\t\t\t\\\n  for (i = 0; i < N; i++)\t\t\t\\\n    a##N.x[i] = i ^ (N << 3);\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n\n  foo (21\n#define D(N) , a##N\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n      );\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-23.c",
    "content": "/* PR 9700 */\n/* Alpha got the base address for the va_list incorrect when there was\n   a structure that was passed partially in registers and partially on\n   the stack.  */\n\n#include <stdarg.h>\n\nstruct two { long x, y; };\n\nvoid foo(int a, int b, int c, int d, int e, struct two f, int g, ...)\n{\n  va_list args;\n  int h;\n\n  va_start(args, g);\n  h = va_arg(args, int);\n  if (g != 1 || h != 2)\n    abort ();\n}\n\nint main()\n{\n  struct two t = { 0, 0 };\n  foo(0, 0, 0, 0, 0, t, 1, 2);\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-24.c",
    "content": "/* The purpose of this code is to test argument passing of a tuple of\n   11 integers, with the break point between named and unnamed arguments\n   at every possible position.\t*/\n\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic int errors = 0;\n\nstatic void\nverify (const char *tcase, int n[11])\n{\n  int i;\n  for (i = 0; i <= 10; i++)\n    if (n[i] != i)\n      {\n\tprintf (\" %s: n[%d] = %d expected %d\\n\", tcase, i, n[i], i);\n\terrors++;\n      }\n}\n\n#define STR(x) #x\n\n#define p(i) int q##i,\n#define P(i) n[i] = q##i;\n\n#define p0 p(0)\n#define p1 p(1)\n#define p2 p(2)\n#define p3 p(3)\n#define p4 p(4)\n#define p5 p(5)\n#define p6 p(6)\n#define p7 p(7)\n#define p8 p(8)\n#define p9 p(9)\n\n#define P0 P(0)\n#define P1 P(1)\n#define P2 P(2)\n#define P3 P(3)\n#define P4 P(4)\n#define P5 P(5)\n#define P6 P(6)\n#define P7 P(7)\n#define P8 P(8)\n#define P9 P(9)\n\n#define TCASE(x, params, vecinit)\t\t\\\nstatic void\t\t\t\t\t\\\nvarargs##x (params ...)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  va_list ap;\t\t\t\t\t\\\n  int n[11];\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n  va_start (ap, q##x);\t\t\t\t\\\n  vecinit\t\t\t\t\t\\\n  for (i = x + 1; i <= 10; i++)\t\t\t\\\n    n[i] = va_arg (ap, int);\t\t\t\\\n  va_end (ap);\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n  verify (STR(varargs##x), n);\t\t\t\\\n}\n\n#define TEST(x) varargs##x (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n\nTCASE(0, p0\t\t\t      , P0\t\t\t     )\nTCASE(1, p0 p1\t\t\t      , P0 P1\t\t\t     )\nTCASE(2, p0 p1 p2\t\t      , P0 P1 P2\t\t     )\nTCASE(3, p0 p1 p2 p3\t\t      , P0 P1 P2 P3\t\t     )\nTCASE(4, p0 p1 p2 p3 p4\t\t      , P0 P1 P2 P3 P4\t\t     )\nTCASE(5, p0 p1 p2 p3 p4 p5\t      , P0 P1 P2 P3 P4 P5\t     )\nTCASE(6, p0 p1 p2 p3 p4 p5 p6\t      , P0 P1 P2 P3 P4 P5 P6\t     )\nTCASE(7, p0 p1 p2 p3 p4 p5 p6 p7      , P0 P1 P2 P3 P4 P5 P6 P7\t     )\nTCASE(8, p0 p1 p2 p3 p4 p5 p6 p7 p8   , P0 P1 P2 P3 P4 P5 P6 P7 P8   )\nTCASE(9, p0 p1 p2 p3 p4 p5 p6 p7 p8 p9, P0 P1 P2 P3 P4 P5 P6 P7 P8 P9)\n\nint main(void)\n{\n  TEST(0);\n  TEST(1);\n  TEST(2);\n  TEST(3);\n  TEST(4);\n  TEST(5);\n  TEST(6);\n  TEST(7);\n  TEST(8);\n  TEST(9);\n\n  if (errors)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-26.c",
    "content": "#include <stdarg.h>\n\ndouble f (float f1, float f2, float f3, float f4,\n\t  float f5, float f6, ...)\n{\n  va_list ap;\n  double d;\n\n  va_start (ap, f6);\n  d = va_arg (ap, double);\n  va_end (ap);\n  return d;\n}\n\nint main ()\n{\n  if (f (1, 2, 3, 4, 5, 6, 7.0) != 7.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-4.c",
    "content": "/* On the i960 any arg bigger than 16 bytes causes all subsequent args\n   to be passed on the stack.  We test this.  */\n\n#include <stdarg.h>\n\ntypedef struct {\n  char a[32];\n} big;\n\nvoid\nf (big x, char *s, ...)\n{\n  va_list ap;\n\n  if (x.a[0] != 'a' || x.a[1] != 'b' || x.a[2] != 'c')\n    abort ();\n  va_start (ap, s);\n  if (va_arg (ap, int) != 42)\n    abort ();\n  if (va_arg (ap, int) != 'x')\n    abort ();\n  if (va_arg (ap, int) != 0)\n    abort ();\n  va_end (ap);\n}\n\nmain ()\n{\n  static big x = { \"abc\" };\n\n  f (x, \"\", 42, 'x', 0);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-5.c",
    "content": "#include <stdarg.h>\n\nva_double (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, double) != 3.141592)\n    abort ();\n  if (va_arg (args, double) != 2.71827)\n    abort ();\n  if (va_arg (args, double) != 2.2360679)\n    abort ();\n  if (va_arg (args, double) != 2.1474836)\n    abort ();\n\n  va_end (args);\n}\n\nva_long_double (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, long double) != 3.141592L)\n    abort ();\n  if (va_arg (args, long double) != 2.71827L)\n    abort ();\n  if (va_arg (args, long double) != 2.2360679L)\n    abort ();\n  if (va_arg (args, long double) != 2.1474836L)\n    abort ();\n\n  va_end (args);\n}\n\nmain ()\n{\n  va_double (4, 3.141592, 2.71827, 2.2360679, 2.1474836);\n  va_long_double (4, 3.141592L, 2.71827L, 2.2360679L, 2.1474836L);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-6.c",
    "content": "#include <stdarg.h>\n\nf (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, int) != 10)\n    abort ();\n  if (va_arg (args, long long) != 10000000000LL)\n    abort ();\n  if (va_arg (args, int) != 11)\n    abort ();\n  if (va_arg (args, long double) != 3.14L)\n    abort ();\n  if (va_arg (args, int) != 12)\n    abort ();\n  if (va_arg (args, int) != 13)\n    abort ();\n  if (va_arg (args, long long) != 20000000000LL)\n    abort ();\n  if (va_arg (args, int) != 14)\n    abort ();\n  if (va_arg (args, double) != 2.72)\n    abort ();\n\n  va_end(args);\n}\n\nmain ()\n{\n  f (4, 10, 10000000000LL, 11, 3.14L, 12, 13, 20000000000LL, 14, 2.72);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-7.c",
    "content": "/* Origin: Franz Sirl <Franz.Sirl-kernel@lauterbach.com> */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#include <stdarg.h>\n\ninline void\ndebug(int i1, int i2, int i3, int i4, int i5, int i6, int i7,\n      double f1, double f2, double f3, double f4, double f5,\n      double f6, double f7, double f8, double f9, ...)\n{\n  va_list ap;\n\n  va_start (ap, f9);\n\n  if (va_arg (ap,int) != 8)\n    abort ();\n  if (va_arg (ap,int) != 9)\n    abort ();\n  if (va_arg (ap,int) != 10)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain(void)\n{\n  debug (1, 2, 3, 4, 5, 6, 7,\n\t 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,\n\t 8, 9, 10);\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-8.c",
    "content": "/* Origin: Franz Sirl <Franz.Sirl-kernel@lauterbach.com> */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#include <stdarg.h>\n#include <limits.h>\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n\ntypedef long long int INT64;\n\ninline void\ndebug(int i1, int i2, int i3, int i4, int i5,\n      int i6, int i7, int i8, int i9, ...)\n{\n  va_list ap;\n\n  va_start (ap, i9);\n\n  if (va_arg (ap,int) != 10)\n    abort ();\n  if (va_arg (ap,INT64) != 0x123400005678LL)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain(void)\n{\n  debug(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0x123400005678LL);\n  exit(0);\n}\n\n#else\n\nint\nmain(void)\n{\n  exit(0);\n}\n\n#endif /* long long 64 bits */\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-9.c",
    "content": "/* This is a modfied version of va-arg-2.c to test passing a va_list as\n   a parameter to another function.  */\n\n#include <stdarg.h>\n\nextern __SIZE_TYPE__ strlen (const char *);\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nfap (int i, char* format, va_list ap)\n{\n  if (strlen (format) != 16 - i)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  fap(0, format, ap);\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(1, format, ap);\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(2, format, ap);\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(3, format, ap);\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(4, format, ap);\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(5, format, ap);\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(6, format, ap);\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(7, format, ap);\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(8, format, ap);\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8, int a9,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(9, format, ap);\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(10, format, ap);\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(11, format, ap);\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(12, format, ap);\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(13, format, ap);\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(14, format, ap);\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(15, format, ap);\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-pack-1.c",
    "content": "/* __builtin_va_arg_pack () builtin tests.  */\n\n#include <stdarg.h>\n\nextern void abort (void);\n\nint v1 = 8;\nlong int v2 = 3;\nvoid *v3 = (void *) &v2;\nstruct A { char c[16]; } v4 = { \"foo\" };\nlong double v5 = 40;\nchar seen[20];\nint cnt;\n\n__attribute__ ((noinline)) int\nfoo1 (int x, int y, ...)\n{\n  int i;\n  long int l;\n  void *v;\n  struct A a;\n  long double ld;\n  va_list ap;\n\n  va_start (ap, y);\n  if (x < 0 || x >= 20 || seen[x])\n    abort ();\n  seen[x] = ++cnt;\n  if (y != 6)\n    abort ();\n  i = va_arg (ap, int);\n  if (i != 5)\n    abort ();\n  switch (x)\n    {\n    case 0:\n      i = va_arg (ap, int);\n      if (i != 9 || v1 != 9)\n\tabort ();\n      a = va_arg (ap, struct A);\n      if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)\n\tabort ();\n      v = (void *) va_arg (ap, struct A *);\n      if (v != (void *) &v4)\n\tabort ();\n      l = va_arg (ap, long int);\n      if (l != 3 || v2 != 4)\n\tabort ();\n      break;\n    case 1:\n      ld = va_arg (ap, long double);\n      if (ld != 41 || v5 != ld)\n\tabort ();\n      i = va_arg (ap, int);\n      if (i != 8)\n\tabort ();\n      v = va_arg (ap, void *);\n      if (v != &v2)\n\tabort ();\n      break;\n    case 2:\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n  return x;\n}\n\n__attribute__ ((noinline)) int\nfoo2 (int x, int y, ...)\n{\n  long long int ll;\n  void *v;\n  struct A a, b;\n  long double ld;\n  va_list ap;\n\n  va_start (ap, y);\n  if (x < 0 || x >= 20 || seen[x])\n    abort ();\n  seen[x] = ++cnt | 64;\n  if (y != 10)\n    abort ();\n  switch (x)\n    {\n    case 11:\n      break;\n    case 12:\n      ld = va_arg (ap, long double);\n      if (ld != 41 || v5 != 40)\n\tabort ();\n      a = va_arg (ap, struct A);\n      if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)\n\tabort ();\n      b = va_arg (ap, struct A);\n      if (__builtin_memcmp (b.c, v4.c, sizeof (b.c)) != 0)\n\tabort ();\n      v = va_arg (ap, void *);\n      if (v != &v2)\n\tabort ();\n      ll = va_arg (ap, long long int);\n      if (ll != 16LL)\n\tabort ();\n      break;\n    case 2:\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n  return x + 8;\n}\n\n__attribute__ ((noinline)) int\nfoo3 (void)\n{\n  return 6;\n}\n\nextern inline __attribute__ ((always_inline, gnu_inline)) int\nbar (int x, ...)\n{\n  if (x < 10)\n    return foo1 (x, foo3 (), 5, __builtin_va_arg_pack ());\n  return foo2 (x, foo3 () + 4, __builtin_va_arg_pack ());\n}\n\nint\nmain (void)\n{\n  if (bar (0, ++v1, v4, &v4, v2++) != 0)\n    abort ();\n  if (bar (1, ++v5, 8, v3) != 1)\n    abort ();\n  if (bar (2) != 2)\n    abort ();\n  if (bar (v1 + 2) != 19)\n    abort ();\n  if (bar (v1 + 3, v5--, v4, v4, v3, 16LL) != 20)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/va-arg-trap-1.c",
    "content": "/* Undefined behavior from a call to va_arg with a type other than\n   that of the argument passed (in particular, with a type such as\n   \"float\" that can never be the type of an argument passed through\n   \"...\") does not appear until after the va_list expression is\n   evaluated.  PR 38483.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\n#include <stdarg.h>\n\nextern void exit (int);\nextern void abort (void);\n\nva_list ap;\nfloat f;\n\nva_list *\nfoo (void)\n{\n  exit (0);\n  return &ap;\n}\n\nvoid\nbar (int i, ...)\n{\n  va_start (ap, i);\n  f = va_arg (*foo (), float);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  bar (1, 0);\n  abort ();\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vfprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, fmt, args) \\\n    case n:\t\t\t\t\t\\\n      vfprintf (stdout, fmt, ap);\t\t\\\n      if (vfprintf (stdout, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\\\n      break;\n#include \"vfprintf-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, fmt, args) \\\n  inner args;\n#include \"vfprintf-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, \"hello\", (0));\n  test (1, 6, \"hello\\n\", (1));\n  test (2, 1, \"a\", (2));\n  test (3, 0, \"\", (3));\n  test (4, 5, \"%s\", (4, \"hello\"));\n  test (5, 6, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, \"%s\", (6, \"a\"));\n  test (7, 0, \"%s\", (7, \"\"));\n  test (8, 1, \"%c\", (8, 'x'));\n  test (9, 7, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__vfprintf_chk (FILE *f, int flag, const char *fmt, va_list ap)\n{\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  return vfprintf (f, fmt, ap);\n}\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, opt, fmt, args) \\\n    case n:\t\t\t\t\t\t\\\n      should_optimize = opt;\t\t\t\t\\\n      __vfprintf_chk (stdout, 1, fmt, ap);\t\t\\\n      if (! should_optimize)\t\t\t\t\\\n\tabort ();\t\t\t\t\t\\\n      should_optimize = 0;\t\t\t\t\\\n      if (__vfprintf_chk (stdout, 1, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\t\\\n      if (! should_optimize)\t\t\t\t\\\n\tabort ();\t\t\t\t\t\\\n      break;\n#include \"vfprintf-chk-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, opt, fmt, args) \\\n  inner args;\n#include \"vfprintf-chk-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, 1, \"hello\", (0));\n  test (1, 6, 1, \"hello\\n\", (1));\n  test (2, 1, 1, \"a\", (2));\n  test (3, 0, 1, \"\", (3));\n  test (4, 5, 0, \"%s\", (4, \"hello\"));\n  test (5, 6, 0, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, 0, \"%s\", (6, \"a\"));\n  test (7, 0, 0, \"%s\", (7, \"\"));\n  test (8, 1, 0, \"%c\", (8, 'x'));\n  test (9, 7, 0, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, 0, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vla-dealloc-1.c",
    "content": "/* VLAs should be deallocated on a jump to before their definition,\n   including a jump to a label in an inner scope.  PR 19771.  */\n/* { dg-require-effective-target alloca } */\n\n#if (__SIZEOF_INT__ <= 2)\n#define LIMIT 10000\n#else\n#define LIMIT 1000000\n#endif\n\nvoid *volatile p;\n\nint\nmain (void)\n{\n  int n = 0;\n  if (0)\n    {\n    lab:;\n    }\n  int x[n % 1000 + 1];\n  x[0] = 1;\n  x[n % 1000] = 2;\n  p = x;\n  n++;\n  if (n < LIMIT)\n    goto lab;\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, fmt, args) \\\n    case n:\t\t\t\t\\\n      vprintf (fmt, ap);\t\t\\\n      if (vprintf (fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\\\n      break;\n#include \"vprintf-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, fmt, args) \\\n  inner args;\n#include \"vprintf-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, \"hello\", (0));\n  test (1, 6, \"hello\\n\", (1));\n  test (2, 1, \"a\", (2));\n  test (3, 0, \"\", (3));\n  test (4, 5, \"%s\", (4, \"hello\"));\n  test (5, 6, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, \"%s\", (6, \"a\"));\n  test (7, 0, \"%s\", (7, \"\"));\n  test (8, 1, \"%c\", (8, 'x'));\n  test (9, 7, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__vprintf_chk (int flag, const char *fmt, va_list ap)\n{\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  return vprintf (fmt, ap);\n}\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, opt, fmt, args) \\\n    case n:\t\t\t\t\t\\\n      should_optimize = opt;\t\t\t\\\n      __vprintf_chk (1, fmt, ap);\t\t\\\n      if (! should_optimize)\t\t\t\\\n\tabort ();\t\t\t\t\\\n      should_optimize = 0;\t\t\t\\\n      if (__vprintf_chk (1, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\\\n      if (! should_optimize)\t\t\t\\\n\tabort ();\t\t\t\t\\\n      break;\n#include \"vprintf-chk-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, opt, fmt, args) \\\n  inner args;\n#include \"vprintf-chk-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, 0, \"hello\", (0));\n  test (1, 6, 1, \"hello\\n\", (1));\n  test (2, 1, 1, \"a\", (2));\n  test (3, 0, 1, \"\", (3));\n  test (4, 5, 0, \"%s\", (4, \"hello\"));\n  test (5, 6, 0, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, 0, \"%s\", (6, \"a\"));\n  test (7, 0, 0, \"%s\", (7, \"\"));\n  test (8, 1, 0, \"%c\", (8, 'x'));\n  test (9, 7, 0, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, 0, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-1.c",
    "content": "\nextern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a != 2) {\n\t\ta = -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-2.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a != 2) {\n\t\ta = a > 0 ? a : -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-3.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a < 12) {\n\t  if (a > -15) {\n\t\ta = a > 0 ? a : -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t  }\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-4.c",
    "content": "extern void exit (int);\nextern void abort ();\n\nvoid test(int x, int y)\n{\n\tint c;\n\n\tif (x == 1) abort();\n\tif (y == 1) abort();\n\n\tc = x / y;\n\n\tif (c != 1) abort();\n}\n\nint main()\n{\n\ttest(2, 2);\n\texit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-5.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void exit (int);\nextern void abort ();\n\nvoid test(unsigned int a, unsigned int b)\n{\n  if (a < 5)\n    abort();\n  if (b < 5)\n    abort();\n  if (a + b != 0U)\n    abort();\n}\n\nint main(int argc, char *argv[])\n{\n  unsigned int x = 0x80000000;\n  test(x, x);\n  exit (0);\n}\n\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-6.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#include <limits.h>\n\nextern void exit (int);\nextern void abort ();\n\nvoid test01(unsigned int a, unsigned int b)\n{\n  if (a < 5)\n    abort();\n  if (b < 5)\n    abort();\n  if (a - b != 5)\n    abort();\n}\n\nvoid test02(unsigned int a, unsigned int b)\n{\n  if (a >= 12)\n    if (b > 15)\n      if (a - b < UINT_MAX - 15U)\n\tabort ();\n}\n\nint main(int argc, char *argv[])\n{\n  unsigned x = 0x80000000;\n  test01(x + 5, x);\n  test02(14, 16);\n  exit (0);\n}\n\n\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/vrp-7.c",
    "content": "\nvoid abort (void);\n\nstruct T\n{\n  int b : 1;\n} t;\n\nvoid __attribute__((noinline)) foo (int f)\n{\n  t.b = (f & 0x10) ? 1 : 0;\n}\n\nint main (void)\n{\n  foo (0x10);\n  if (!t.b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c",
    "content": "/* { dg-options \"-finput-charset=utf-8\" } */\ntypedef __WCHAR_TYPE__ wchar_t;\nwchar_t x[] = L\"Ä\";\nwchar_t y = L'Ä';\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  if (sizeof (x) / sizeof (wchar_t) != 2)\n    abort ();\n  if (x[0] != L'Ä' || x[1] != L'\\0')\n    abort ();\n  if (y != L'Ä')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/widechar-1.c",
    "content": "#define C L'\\400'\n\n#if C\n#define zero (!C)\n#else\n#define zero C\n#endif\n\nmain()\n{\n  if (zero != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/widechar-2.c",
    "content": "#include <stddef.h>\n\nconst wchar_t ws[] = L\"foo\";\n\nint\nmain (void)\n{\n  if (ws[0] != L'f' || ws[1] != L'o' || ws[2] != L'o' || ws[3] != L'\\0')\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/zero-struct-1.c",
    "content": "struct g{};\nchar y[3];\nchar *f = &y[0];\nchar *ff = &y[0];\nvoid h(void)\n{\n  struct g t;\n  *((struct g*)(f++)) = *((struct g*)(ff++));\n  *((struct g*)(f++)) = (struct g){};\n  t = *((struct g*)(ff++));\n}\n\nvoid abort (void);\n\nint main(void)\n{\n  h();\n  if (f != &y[2])\n    abort();\n  if (ff != &y[2])\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/zero-struct-2.c",
    "content": "void abort (void);\nint ii;\ntypedef struct {} raw_spinlock_t;\ntypedef struct {\n  raw_spinlock_t raw_lock;\n} spinlock_t;\nraw_spinlock_t one_raw_spinlock (void)\n{\n  raw_spinlock_t raw_lock;\n  ii++;\n  return raw_lock;\n}\nint main(void)\n{\n  spinlock_t lock = (spinlock_t) { .raw_lock = one_raw_spinlock() };\n  if (ii != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/zerolen-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nunion iso_directory_record {\n   char carr[4];\n   struct {\n           unsigned char name_len [1];\n           char name [0];\n   } u;\n} entry;\n\nvoid set(union iso_directory_record *);\n\nint main (void)\n{\n   union iso_directory_record *de;\n\n   de = &entry;\n   set(de);\n\n   if (de->u.name_len[0] == 1 && de->u.name[0] == 0)\n     exit (0);\n   else\n     abort ();\n}\n\nvoid set (union iso_directory_record *p)\n{\n   p->carr[0] = 1;\n   p->carr[1] = 0;\n   return;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/zerolen-2.c",
    "content": "/* { dg-skip-if \"assumes absence of larger-than-word padding\" { epiphany-*-* } \"*\" \"\" } */\nextern void abort(void);\n\ntypedef int word __attribute__((mode(word)));\n\nstruct foo\n{\n  word x;\n  word y[0];\n};\n\nint main()\n{\n  if (sizeof(word) != sizeof(struct foo))\n    abort();\n  if (__alignof__(word) != __alignof__(struct foo))\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/unsorted/dump-noaddr.c",
    "content": "#include <limits.h>\n\n#if MASK & 1\n#define t11(x) x x x x x x x x x x x\n#define t16(x) x x x x x x x x x x x x x x x x\n#if INT_MAX < 2147483647\n#define M (sizeof (t11(t11(t16(t16(\" \"))))) - 1)\n#else\n#define M (sizeof (t16(t16(t16(t16(t16(\" \")))))) - 1)\n#endif\n#endif\n#if MASK & 2\n#if INT_MAX < 2147483647\n#define M 30976\n#else\n#define M 1048576\n#endif\n#endif\n\ntypedef struct s {\n  int c;\n  void *vp;\n  struct s *s;\n}s;\n\ntypedef int (*fpt) (const char *, void *, int *);\n\nint M_var = M;\n\nextern void exit (int);\n\nint\nf (int start, int end, int *a, int *b, int c, s *sp)\n{\n  int count = 0;\n  int i;\n\n  for (i = start; i <= end; i++)\n    {\n      a[i] = b[i] + c;\n      count ++;\n    }\n  (*(fpt)sp->s->vp) (\"Hello World!\\n\", &exit, &M_var);\n  return count;\n}\n\nint\ng (int i)\n{\n  switch (i)\n    {\n    case 1: return 42;\n    case 2: return 60;\n    case 3: return 7;\n    case 4: return 3;\n    case 5: return M;\n    default: return 0;\n    }\n}\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/unsorted/dump-noaddr.x",
    "content": "# This checks if -fdump-noaddr dumps are done consistently.\nproc dump_compare { src options } {\n    global srcdir subdir\n    global tmpdir\n\n    global torture_with_loops\n    set option_list $torture_with_loops\n    set dumpbase [file tail $src]\n\n    # loop through all the options\n    foreach option $option_list {\n\tfile delete -force dump1\n\tfile mkdir dump1\n\tc-torture-compile $src \"$option $options -dumpbase dump1/$dumpbase -DMASK=1 -x c --param ggc-min-heapsize=1 -fdump-ipa-all -fdump-rtl-all -fdump-tree-all -fdump-noaddr\"\n\tfile delete -force dump2\n\tfile mkdir dump2\n\tc-torture-compile $src \"$option $options -dumpbase dump2/$dumpbase -DMASK=2 -x c -fdump-ipa-all -fdump-rtl-all -fdump-tree-all -fdump-noaddr\"\n\tforeach dump1 [lsort [glob -nocomplain dump1/*]] {\n\t    regsub dump1/ $dump1 dump2/ dump2\n\t    set dumptail \"gcc.c-torture/unsorted/[file tail $dump1]\"\n\t    regsub {\\.\\d+((t|r|i)\\.[^.]+)$} $dumptail {.*\\1} dumptail\n\t    set tmp [ diff \"$dump1\" \"$dump2\" ]\n\t    if { $tmp == 0 } {\n\t\tuntested \"$dumptail, $option comparison\"\n\t    } elseif { $tmp == 1 } {\n\t\tpass \"$dumptail, $option comparison\"\n\t    } else {\n\t\tfail \"$dumptail, $option comparison\"\n\t    }\n\t}\n    }\n    file delete -force dump1\n    file delete -force dump2\n}\n\ndump_compare $src $options\nreturn 1\n"
  },
  {
    "path": "testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/unsorted/unsorted.exp",
    "content": "#\n# Expect driver script for GCC Regression Tests\n#   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n#\n# This file is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n#\n# Written by Jeffrey Wheat (cassidy@cygnus.com)\n#\n\n#\n# These tests come from Torbjorn Granlund's (tege@cygnus.com)\n# C torture test suite, and other contributors.\n#\n\nif $tracelevel then {\n    strace $tracelevel\n}\n\n# load support procs\nload_lib c-torture.exp\nload_lib torture-options.exp\n\ntorture-init\nset-torture-options $C_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS\n\n#\n# This loop will run c-torture on any *.c file found in this directory.\n# If a *.c has a corresponding *.exp file, then the test is skipped as\n# as the *.exp will drive the test itself.  It is done this way so that\n# generic tests do not need a separate .exp for it.  Only the tests that \n# require unique options need their own .exp file.\n#\n\nforeach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {\n    if [file exists [file rootname $testcase].exp] then {\n\tverbose \"INFO:\\\"[file rootname $testcase].exp\\\" exists, skipping test\" 3\n\tcontinue\n    }\n\n    # If we're only testing specific files and this isn't one of them, skip it.\n    if ![runtest_file_p $runtests $testcase] then {\n\tcontinue\n    }\n\n    c-torture $testcase\n}\n\ntorture-finish\n"
  },
  {
    "path": "testdata/gcc-6.3.0/source-url",
    "content": "ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-6.3.0/gcc-6.3.0.tar.gz\n"
  },
  {
    "path": "testdata/issue3.h",
    "content": "#define FOO 3\r\n\r\nvoid foo(int a, int b);\r\n\r\n#define do_foo(x) \\\r\n  foo(x, FOO)\r\n"
  },
  {
    "path": "testdata/issue4.c",
    "content": "typedef int int_t;\n\n// redeclaration error:\nint foo(void *ptr);\ntypedef int foo(void *ptr);\n\n// redeclaration error:\nint_t foo2(void *ptr);\ntypedef int_t foo2(void *ptr);\n"
  },
  {
    "path": "testdata/issue50.h",
    "content": "#ifdef __cplusplus\nextern \"C\";\n\n"
  },
  {
    "path": "testdata/issue57.c",
    "content": "typedef int bool_t;\n\ntypedef bool_t (*bool_func) (void);\ntypedef bool_func func1;\n"
  },
  {
    "path": "testdata/issue62.c",
    "content": "struct global {\n\tint i;\n};\n\nextern struct global2 {\n\tint j;\n};\n\nstatic struct local {\n\tint k;\n};\n"
  },
  {
    "path": "testdata/issue64.c",
    "content": "typedef struct foo foo;\n\nfoo bar = {0};\n"
  },
  {
    "path": "testdata/issue65.c",
    "content": "struct {\n\tint i;\n\tint j:1;\n\tint k:2;\n\tint l:3;\n\tint m;\n} foo;\n"
  },
  {
    "path": "testdata/issue66.c",
    "content": "short *p = ((short*)3)[5];\n"
  },
  {
    "path": "testdata/issue67.c",
    "content": "int foo; // bar1\nchar /*\nbaz3\n*/\nqux;\n\n// abc7\n// def8\nint ghi;\n\n/* abc11 */\n/* def12\n */\nint ghi;\n\n/* abc16\n */\n/* def18 */\nint ghi;\n\n/* abc21 */\n// def22\nint ghi;\n\n// def25\n/* abc26 */\nint ghi;\n\n// abc29\n\n// def31\nint ghi;\n"
  },
  {
    "path": "testdata/issue68.h",
    "content": "typedef struct a *b;\n#define c(type, name, paramName)                          \\\n  void set##name(const b node, type paramName); \\\n  type get##name(const b node);\n\nc(void *, Context, context); // The final semicolon is a C++11 empty declaration, illegal in C99.\n\n// See also http://en.cppreference.com/w/cpp/language/declarations\n"
  },
  {
    "path": "testdata/issue69.h",
    "content": "int i;\n#ifndef a\n// Next line DOES NOT end with newline.\n#endif /* a */"
  },
  {
    "path": "testdata/issue72.h",
    "content": "enum {\n  PERF_TXN_ABORT_MASK  = (0xffffffffULL << 32)\n};\n"
  },
  {
    "path": "testdata/issue74.h",
    "content": "struct foobar {\n\tunsigned long long baz : 36;\n};\n"
  },
  {
    "path": "testdata/issue77.c",
    "content": "void f() {\n\tif (\"abc\"[0] == 'a') {}\n}\n"
  },
  {
    "path": "testdata/issue78.c",
    "content": "f(){}\n"
  },
  {
    "path": "testdata/issue8.h",
    "content": "#define __signed signed\r\n\r\ntypedef __signed char __int8_t;\r\n\r\n// for future tests\r\n// (on the real code this producting another error)\r\n// #if 5 > 1\r\n// // ok?\r\n// #endif\r\n\r\n// remove this block -> works!\r\n#if !defined(A) && (!defined(B) || defined(C))\r\n// ok?\r\n#endif\r\n\r\n#define FOO (4)\r\n\r\n// remove this block -> works!\r\n#if (FOO) > 4\r\n// ok?\r\n#endif\r\n"
  },
  {
    "path": "testdata/issue80.c",
    "content": "char s[] = \"abcdef\";\nchar *t = \"abcdef\";\nchar u[11] = \"abcdef\";\n"
  },
  {
    "path": "testdata/issue81.c",
    "content": "char *s = \"\\0\\377\\0\";\nchar *t = \"\\0\\0\";\n"
  },
  {
    "path": "testdata/issue82.c",
    "content": "#define a(b, c, ...) d(c)\na(1, 2, 3)\n#undef a\n#define a(b, c...) d(c)\na(1, 2, 3)\n"
  },
  {
    "path": "testdata/issue84.c",
    "content": "#define a(b, ...) c(b, __VA_ARGS__)\na(1, 2, 3);\na(1, 2);\na(1);\n"
  },
  {
    "path": "testdata/issue85.c",
    "content": "int i;\nextern int j;\n"
  },
  {
    "path": "testdata/issue86.c",
    "content": "int i = 42;\nextern int j = 24;\n"
  },
  {
    "path": "testdata/issue87.c",
    "content": "typedef int foo;\ntypedef int foo;\n"
  },
  {
    "path": "testdata/issue88.c",
    "content": "void foo();\nvoid bar() {\n\tfoo == foo;\n}\n"
  },
  {
    "path": "testdata/issue89.c",
    "content": "struct a\n{\n  unsigned f : 3;\n};\n\nvoid h()\n{\n  struct a a;\n  g(a.f);\n}\n\nint g(unsigned);\n"
  },
  {
    "path": "testdata/issue9.c",
    "content": "typedef short JBLOCK[64];\ntypedef JBLOCK *JBLOCKROW;\ntypedef JBLOCKROW *JBLOCKARRAY;\ntypedef JBLOCKARRAY *JBLOCKIMAGE;\n\nshort v6[64];\nshort (v6)[64];\nJBLOCK v6;\nJBLOCK (v6);\n\nshort (*v11)[64];\nshort ((*v11))[64];\nshort ((*v11)[64]);\nJBLOCKROW v11;\nJBLOCKROW (v11);\n\nshort (**v17)[64];\nshort ((**v17))[64];\nshort ((**v17)[64]);\nJBLOCKARRAY v17;\nJBLOCKARRAY (v17);\n\nshort (***v23)[64];\nshort ((***v23))[64];\nshort ((***v23)[64]);\nJBLOCKIMAGE v23;\nJBLOCKIMAGE (v23);\n"
  },
  {
    "path": "testdata/issue90.c",
    "content": "struct {\n\tunsigned a:1;\n\tunsigned b:1;\n} x;\n\nvoid f() {\n\tx.a + x.b;\n}\n"
  },
  {
    "path": "testdata/issue92.c",
    "content": "typedef struct{int i;} t;\ntypedef struct{int i;} t;\n"
  },
  {
    "path": "testdata/issue93.c",
    "content": "#include \"issue93.h\"\nextern int hello;\n\nint main() { return 0; }\n"
  },
  {
    "path": "testdata/issue93.h",
    "content": "// This line DOES NOT end with newline. Use '$ truncate -s -1 issue93.h' to remove the final newline if necessary."
  },
  {
    "path": "testdata/issue9b.c",
    "content": "typedef short JBLOCK[64];\ntypedef JBLOCK *JBLOCKROW;\ntypedef JBLOCKROW *JBLOCKARRAY;\ntypedef JBLOCKARRAY *JBLOCKIMAGE;\n\nshort (**ok)[64];\nJBLOCKARRAY ok;\n\nshort ***bad[64];\nJBLOCKARRAY bad;\n"
  },
  {
    "path": "testdata/paste.c",
    "content": "# define __REPB_PREFIX(name) __##name\n\nunsigned char *__REPB_PREFIX(buffer);\n"
  },
  {
    "path": "testdata/paste2.c",
    "content": "# define __intN_t(N) typedef int int##N##_t\n__intN_t (8);\n"
  },
  {
    "path": "testdata/redecl.c",
    "content": "// [0]6.7.7, 7, p.124\n\ntypedef void fv(int), (*pfv)(int);\n\nvoid (*signal(int, void (*)(int)))(int);\nfv *signal(int, fv *);\npfv signal(int, pfv);\n\n// Denormalized forms.\n\nvoid ((*signal(int, void (*)(int)))(int));\nvoid (((*signal(int, void (*)(int)))(int)));\n\nvoid (*signal(int, void ((*))(int)))(int);\nvoid (*signal(int, void (((*)))(int)))(int);\n\nfv (*signal(int, fv *));\nfv ((*signal(int, fv *)));\nfv *signal(int, fv (*));\nfv *signal(int, fv ((*)));\n\npfv (signal(int, pfv));\npfv ((signal(int, pfv)));\n\n// ----------------------------------------------------------------------------\n\ntypedef int t;\n\nint f29();\nt f29();\n\nint *f32();\nt *f32();\n\nint (*f35)();\nt (*f35)();\n\nint (*f38())();\nt (*f38())();\n\ntypedef int *t2;\n\nint *f43();\nt2 f43();\n\nint *(*f46)();\nt2 (*f46)();\n\nint *(*f49());\nt2 (*f49());\n\nint **f52();\nt2 *f52();\n\nint a55[4];\nt a55[4];\n\nint *a58[4];\nt *a58[4];\n\nint *a61[4];\nt2 a61[4];\n\nint **a64[4];\nt2 *a64[4];\n\nint *(*a67[4]);\nt2 *(a67[4]);\n\nint (**a67[4]);\nt2 (*a67[4]);\n"
  },
  {
    "path": "testdata/tcc-0.9.26/COPYING",
    "content": "\t\t  GNU LESSER GENERAL PUBLIC LICENSE\n\t\t       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\f\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\f\n\t\t  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n  \n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\f\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\f\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\f\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\f\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\f\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n\n\n"
  },
  {
    "path": "testdata/tcc-0.9.26/source-url",
    "content": "http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.26.tar.bz2\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/00_assignment.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int a;\n   a = 42;\n   printf(\"%d\\n\", a);\n\n   int b = 64;\n   printf(\"%d\\n\", b);\n\n   int c = 12, d = 34;\n   printf(\"%d, %d\\n\", c, d);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/00_assignment.expect",
    "content": "42\n64\n12, 34\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/01_comment.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   printf(\"Hello\\n\");\n   printf(\"Hello\\n\"); /* this is a comment */ printf(\"Hello\\n\");\n   printf(\"Hello\\n\");\n   // this is also a comment sayhello();\n   printf(\"Hello\\n\");\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/01_comment.expect",
    "content": "Hello\nHello\nHello\nHello\nHello\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/02_printf.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   printf(\"Hello world\\n\");\n\n   int Count;\n   for (Count = -5; Count <= 5; Count++)\n      printf(\"Count = %d\\n\", Count);\n\n   printf(\"String 'hello', 'there' is '%s', '%s'\\n\", \"hello\", \"there\");\n   printf(\"Character 'A' is '%c'\\n\", 65);\n   printf(\"Character 'a' is '%c'\\n\", 'a');\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/02_printf.expect",
    "content": "Hello world\nCount = -5\nCount = -4\nCount = -3\nCount = -2\nCount = -1\nCount = 0\nCount = 1\nCount = 2\nCount = 3\nCount = 4\nCount = 5\nString 'hello', 'there' is 'hello', 'there'\nCharacter 'A' is 'A'\nCharacter 'a' is 'a'\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/03_struct.c",
    "content": "#include <stdio.h>\n\nstruct fred\n{\n   int boris;\n   int natasha;\n};\n\nvoid main() \n{\n   struct fred bloggs;\n\n   bloggs.boris = 12;\n   bloggs.natasha = 34;\n\n   printf(\"%d\\n\", bloggs.boris);\n   printf(\"%d\\n\", bloggs.natasha);\n\n   struct fred jones[2];\n   jones[0].boris = 12;\n   jones[0].natasha = 34;\n   jones[1].boris = 56;\n   jones[1].natasha = 78;\n\n   printf(\"%d\\n\", jones[0].boris);\n   printf(\"%d\\n\", jones[0].natasha);\n   printf(\"%d\\n\", jones[1].boris);\n   printf(\"%d\\n\", jones[1].natasha);\n\n   return 0;\n}\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/03_struct.expect",
    "content": "12\n34\n12\n34\n56\n78\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/04_for.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int Count;\n\n   for (Count = 1; Count <= 10; Count++)\n   {\n      printf(\"%d\\n\", Count);\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/04_for.expect",
    "content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/05_array.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int Count;\n   int Array[10];\n\n   for (Count = 1; Count <= 10; Count++)\n   {\n      Array[Count-1] = Count * Count;\n   }\n\n   for (Count = 0; Count < 10; Count++)\n   {\n      printf(\"%d\\n\", Array[Count]);\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/05_array.expect",
    "content": "1\n4\n9\n16\n25\n36\n49\n64\n81\n100\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/06_case.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   for (Count = 0; Count < 4; Count++)\n   {\n      printf(\"%d\\n\", Count);\n      switch (Count)\n      {\n         case 1:\n            printf(\"%d\\n\", 1);\n            break;\n\n         case 2:\n            printf(\"%d\\n\", 2);\n            break;\n\n         default:\n            printf(\"%d\\n\", 0);\n            break;\n      }\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/06_case.expect",
    "content": "0\n0\n1\n1\n2\n2\n3\n0\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/07_function.c",
    "content": "#include <stdio.h>\n\nint myfunc(int x)\n{\n   return x * x;\n}\n\nvoid vfunc(int a)\n{\n   printf(\"a=%d\\n\", a);\n}\n\nvoid qfunc()\n{\n   printf(\"qfunc()\\n\");\n}\n\nint main()\n{\n   printf(\"%d\\n\", myfunc(3));\n   printf(\"%d\\n\", myfunc(4));\n\n   vfunc(1234);\n\n   qfunc();\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/07_function.expect",
    "content": "9\n16\na=1234\nqfunc()\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/08_while.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int p;\n   int t;\n\n   a = 1;\n   p = 0;\n   t = 0;\n\n   while (a < 100)\n   {\n      printf(\"%d\\n\", a);\n      t = a;\n      a = t + p;\n      p = t;\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/08_while.expect",
    "content": "1\n1\n2\n3\n5\n8\n13\n21\n34\n55\n89\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/09_do_while.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int p;\n   int t;\n\n   a = 1;\n   p = 0;\n   t = 0;\n\n   do\n   {\n      printf(\"%d\\n\", a);\n      t = a;\n      a = t + p;\n      p = t;\n   } while (a < 100);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/09_do_while.expect",
    "content": "1\n1\n2\n3\n5\n8\n13\n21\n34\n55\n89\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/10_pointer.c",
    "content": "#include <stdio.h>\n\nstruct ziggy\n{\n   int a;\n   int b;\n   int c;\n} bolshevic;\n\nint main()\n{\n   int a;\n   int *b;\n   int c;\n\n   a = 42;\n   b = &a;\n   printf(\"a = %d\\n\", *b);\n\n   bolshevic.a = 12;\n   bolshevic.b = 34;\n   bolshevic.c = 56;\n\n   printf(\"bolshevic.a = %d\\n\", bolshevic.a);\n   printf(\"bolshevic.b = %d\\n\", bolshevic.b);\n   printf(\"bolshevic.c = %d\\n\", bolshevic.c);\n\n   struct ziggy *tsar = &bolshevic;\n\n   printf(\"tsar->a = %d\\n\", tsar->a);\n   printf(\"tsar->b = %d\\n\", tsar->b);\n   printf(\"tsar->c = %d\\n\", tsar->c);\n\n   b = &(bolshevic.b);\n   printf(\"bolshevic.b = %d\\n\", *b);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/10_pointer.expect",
    "content": "a = 42\nbolshevic.a = 12\nbolshevic.b = 34\nbolshevic.c = 56\ntsar->a = 12\ntsar->b = 34\ntsar->c = 56\nbolshevic.b = 34\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/11_precedence.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int b;\n   int c;\n   int d;\n   int e;\n   int f;\n   int x;\n   int y;\n\n   a = 12;\n   b = 34;\n   c = 56;\n   d = 78;\n   e = 0;\n   f = 1;\n\n   printf(\"%d\\n\", c + d);\n   printf(\"%d\\n\", (y = c + d));\n   printf(\"%d\\n\", e || e && f);\n   printf(\"%d\\n\", e || f && f);\n   printf(\"%d\\n\", e && e || f);\n   printf(\"%d\\n\", e && f || f);\n   printf(\"%d\\n\", a && f | f);\n   printf(\"%d\\n\", a | b ^ c & d);\n   printf(\"%d, %d\\n\", a == a, a == b);\n   printf(\"%d, %d\\n\", a != a, a != b);\n   printf(\"%d\\n\", a != b && c != d);\n   printf(\"%d\\n\", a + b * c / f);\n   printf(\"%d\\n\", a + b * c / f);\n   printf(\"%d\\n\", (4 << 4));\n   printf(\"%d\\n\", (64 >> 4));\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/11_precedence.expect",
    "content": "134\n134\n0\n1\n1\n1\n1\n46\n1, 0\n0, 1\n1\n1916\n1916\n64\n4\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/12_hashdefine.c",
    "content": "#include <stdio.h>\n\n#define FRED 12\n#define BLOGGS(x) (12*(x))\n\nint main()\n{\n   printf(\"%d\\n\", FRED);\n   printf(\"%d, %d, %d\\n\", BLOGGS(1), BLOGGS(2), BLOGGS(3));\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/12_hashdefine.expect",
    "content": "12\n12, 24, 36\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/13_integer_literals.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a = 24680;\n   int b = 01234567;\n   int c = 0x2468ac;\n   int d = 0x2468AC;\n   int e = 0x555; //TODO extension 0b010101010101;\n\n   printf(\"%d\\n\", a);\n   printf(\"%d\\n\", b);\n   printf(\"%d\\n\", c);\n   printf(\"%d\\n\", d);\n   printf(\"%d\\n\", e);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/13_integer_literals.expect",
    "content": "24680\n342391\n2386092\n2386092\n1365\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/14_if.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a = 1;\n\n   if (a)\n      printf(\"a is true\\n\");\n   else\n      printf(\"a is false\\n\");\n\n   int b = 0;\n   if (b)\n      printf(\"b is true\\n\");\n   else\n      printf(\"b is false\\n\");\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/14_if.expect",
    "content": "a is true\nb is false\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/15_recursion.c",
    "content": "#include <stdio.h>\n\nint factorial(int i) \n{\n   if (i < 2)\n      return i;\n   else\n      return i * factorial(i - 1);\n}\n\nint main()\n{\n   int Count;\n\n   for (Count = 1; Count <= 10; Count++)\n      printf(\"%d\\n\", factorial(Count));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/15_recursion.expect",
    "content": "1\n2\n6\n24\n120\n720\n5040\n40320\n362880\n3628800\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/16_nesting.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int x, y, z;\n\n   for (x = 0; x < 2; x++)\n   {\n      for (y = 0; y < 3; y++)\n      {\n         for (z = 0; z < 3; z++)\n         {\n            printf(\"%d %d %d\\n\", x, y, z);\n         }\n      }\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/16_nesting.expect",
    "content": "0 0 0\n0 0 1\n0 0 2\n0 1 0\n0 1 1\n0 1 2\n0 2 0\n0 2 1\n0 2 2\n1 0 0\n1 0 1\n1 0 2\n1 1 0\n1 1 1\n1 1 2\n1 2 0\n1 2 1\n1 2 2\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/17_enum.c",
    "content": "#include <stdio.h>\n\nenum fred\n{\n   a,\n   b,\n   c,\n   d,\n   e = 54,\n   f = 73,\n   g,\n   h\n};\n\nint main()\n{\n   enum fred frod;\n\n   printf(\"%d %d %d %d %d %d %d %d\\n\", a, b, c, d, e, f, g, h);\n   /* printf(\"%d\\n\", frod); */\n   frod = 12;\n   printf(\"%d\\n\", frod);\n   frod = e;\n   printf(\"%d\\n\", frod);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/17_enum.expect",
    "content": "0 1 2 3 54 73 74 75\n12\n54\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/18_include.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"including\\n\");\n#include \"18_include.h\"\n   printf(\"done\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/18_include.expect",
    "content": "including\nincluded\ndone\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/18_include.h",
    "content": "printf(\"included\\n\");\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int *b;\n   int *c;\n\n   a = 42;\n   b = &a;\n   c = NULL;\n\n   printf(\"%d\\n\", *b);\n\n   if (b == NULL)\n      printf(\"b is NULL\\n\");\n   else\n      printf(\"b is not NULL\\n\");\n\n   if (c == NULL)\n      printf(\"c is NULL\\n\");\n   else\n      printf(\"c is not NULL\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.expect",
    "content": "42\nb is not NULL\nc is NULL\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/20_pointer_comparison.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int b;\n   int *d;\n   int *e;\n   d = &a;\n   e = &b;\n   a = 12;\n   b = 34;\n   printf(\"%d\\n\", *d);\n   printf(\"%d\\n\", *e);\n   printf(\"%d\\n\", d == e);\n   printf(\"%d\\n\", d != e);\n   d = e;\n   printf(\"%d\\n\", d == e);\n   printf(\"%d\\n\", d != e);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/20_pointer_comparison.expect",
    "content": "12\n34\n0\n1\n1\n0\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/21_char_array.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int x = 'a';\n   char y = x;\n\n   char *a = \"hello\";\n\n   printf(\"%s\\n\", a);\n\n   int c;\n   c = *a;\n\n   char *b;\n   for (b = a; *b != 0; b++)\n      printf(\"%c: %d\\n\", *b, *b);\n\n   char destarray[10];\n   char *dest = &destarray[0];\n   char *src = a;\n\n   while (*src != 0)\n      *dest++ = *src++;\n\n   *dest = 0;\n\n   printf(\"copied string is %s\\n\", destarray);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/21_char_array.expect",
    "content": "hello\nh: 104\ne: 101\nl: 108\nl: 108\no: 111\ncopied string is hello\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/22_floating_point.c",
    "content": "#include <stdio.h>\n#include <math.h>\n\nint main()\n{\n   // variables\n   float a = 12.34 + 56.78;\n   printf(\"%f\\n\", a);\n\n   // infix operators\n   printf(\"%f\\n\", 12.34 + 56.78);\n   printf(\"%f\\n\", 12.34 - 56.78);\n   printf(\"%f\\n\", 12.34 * 56.78);\n   printf(\"%f\\n\", 12.34 / 56.78);\n\n   // comparison operators\n   printf(\"%d %d %d %d %d %d\\n\", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78);\n   printf(\"%d %d %d %d %d %d\\n\", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34);\n   printf(\"%d %d %d %d %d %d\\n\", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34);\n\n   // assignment operators\n   a = 12.34;\n   a += 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a -= 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a *= 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a /= 56.78;\n   printf(\"%f\\n\", a);\n\n   // prefix operators\n   printf(\"%f\\n\", +12.34);\n   printf(\"%f\\n\", -12.34);\n\n   // type coercion\n   a = 2;\n   printf(\"%f\\n\", a);\n   printf(\"%f\\n\", sin(2));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/22_floating_point.expect",
    "content": "69.120003\n69.120000\n-44.440000\n700.665200\n0.217330\n1 1 0 0 0 1\n0 1 1 1 0 0\n0 0 0 1 1 1\n69.120003\n-44.439999\n700.665222\n0.217330\n12.340000\n-12.340000\n2.000000\n0.909297\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/23_type_coercion.c",
    "content": "#include <stdio.h>\n\nvoid charfunc(char a)\n{\n   printf(\"char: %c\\n\", a);\n}\n\nvoid intfunc(int a)\n{\n   printf(\"int: %d\\n\", a);\n}\n\nvoid floatfunc(float a)\n{\n   printf(\"float: %f\\n\", a);\n}\n\nint main()\n{\n   charfunc('a');\n   charfunc(98);\n   charfunc(99.0);\n\n   intfunc('a');\n   intfunc(98);\n   intfunc(99.0);\n\n   floatfunc('a');\n   floatfunc(98);\n   floatfunc(99.0);\n\n   /* printf(\"%c %d %f\\n\", 'a', 'b', 'c'); */\n   /* printf(\"%c %d %f\\n\", 97, 98, 99); */\n   /* printf(\"%c %d %f\\n\", 97.0, 98.0, 99.0); */\n\n   char b = 97;\n   char c = 97.0;\n\n   printf(\"%d %d\\n\", b, c);\n\n   int d = 'a';\n   int e = 97.0;\n\n   printf(\"%d %d\\n\", d, e);\n\n   float f = 'a';\n   float g = 97;\n\n   printf(\"%f %f\\n\", f, g);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/23_type_coercion.expect",
    "content": "char: a\nchar: b\nchar: c\nint: 97\nint: 98\nint: 99\nfloat: 97.000000\nfloat: 98.000000\nfloat: 99.000000\n97 97\n97 97\n97.000000 97.000000\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/24_math_library.c",
    "content": "#include <stdio.h>\n#include <math.h>\n\nint main()\n{\n   printf(\"%f\\n\", sin(0.12));\n   printf(\"%f\\n\", cos(0.12));\n   printf(\"%f\\n\", tan(0.12));\n   printf(\"%f\\n\", asin(0.12));\n   printf(\"%f\\n\", acos(0.12));\n   printf(\"%f\\n\", atan(0.12));\n   printf(\"%f\\n\", sinh(0.12));\n   printf(\"%f\\n\", cosh(0.12));\n   printf(\"%f\\n\", tanh(0.12));\n   printf(\"%f\\n\", exp(0.12));\n   printf(\"%f\\n\", fabs(-0.12));\n   printf(\"%f\\n\", log(0.12));\n   printf(\"%f\\n\", log10(0.12));\n   printf(\"%f\\n\", pow(0.12, 0.12));\n   printf(\"%f\\n\", sqrt(0.12));\n   printf(\"%f\\n\", round(12.34));\n   printf(\"%f\\n\", ceil(12.34));\n   printf(\"%f\\n\", floor(12.34));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/24_math_library.expect",
    "content": "0.119712\n0.992809\n0.120579\n0.120290\n1.450506\n0.119429\n0.120288\n1.007209\n0.119427\n1.127497\n0.120000\n-2.120264\n-0.920819\n0.775357\n0.346410\n12.000000\n13.000000\n12.000000\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/25_quicksort.c",
    "content": "#include <stdio.h>\n\nint array[16];\n\n//Swap integer values by array indexes\nvoid swap(int a, int b)\n{\n   int tmp  = array[a];\n   array[a] = array[b];\n   array[b] = tmp;\n}\n\n//Partition the array into two halves and return the\n//index about which the array is partitioned\nint partition(int left, int right)\n{\n   int pivotIndex = left;\n   int pivotValue = array[pivotIndex];\n   int index = left;\n   int i;\n\n   swap(pivotIndex, right);\n   for(i = left; i < right; i++)\n   {\n      if(array[i] < pivotValue)\n      {\n         swap(i, index);\n         index += 1;\n      }\n   }\n   swap(right, index);\n\n   return index;\n}\n\n//Quicksort the array\nvoid quicksort(int left, int right)\n{\n   if(left >= right)\n      return;\n\n   int index = partition(left, right);\n   quicksort(left, index - 1);\n   quicksort(index + 1, right);\n}\n\nint main()\n{\n   int i;\n\n   array[0] = 62;\n   array[1] = 83;\n   array[2] = 4;\n   array[3] = 89;\n   array[4] = 36;\n   array[5] = 21;\n   array[6] = 74;\n   array[7] = 37;\n   array[8] = 65;\n   array[9] = 33;\n   array[10] = 96;\n   array[11] = 38;\n   array[12] = 53;\n   array[13] = 16;\n   array[14] = 74;\n   array[15] = 55;\n\n   for (i = 0; i < 16; i++)\n      printf(\"%d \", array[i]);\n\n   printf(\"\\n\");\n\n   quicksort(0, 15);\n\n   for (i = 0; i < 16; i++)\n      printf(\"%d \", array[i]);\n\n   printf(\"\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/25_quicksort.expect",
    "content": "62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55 \n4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96 \n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/26_character_constants.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"%d\\n\", '\\1');\n   printf(\"%d\\n\", '\\10');\n   printf(\"%d\\n\", '\\100');\n   printf(\"%d\\n\", '\\x01');\n   printf(\"%d\\n\", '\\x0e');\n   printf(\"%d\\n\", '\\x10');\n   printf(\"%d\\n\", '\\x40');\n   printf(\"test \\x40\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/26_character_constants.expect",
    "content": "1\n8\n64\n1\n14\n16\n64\ntest @\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/27_sizeof.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char a;\n   int b;\n   double c;\n\n   printf(\"%d\\n\", sizeof(a));\n   printf(\"%d\\n\", sizeof(b));\n   printf(\"%d\\n\", sizeof(c));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/27_sizeof.expect",
    "content": "1\n4\n8\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/28_strings.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include <strings.h>\n\nint main()\n{\n   char a[10];\n\n   strcpy(a, \"hello\");\n   printf(\"%s\\n\", a);\n\n   strncpy(a, \"gosh\", 2);\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", strcmp(a, \"apple\") > 0);\n   printf(\"%d\\n\", strcmp(a, \"goere\") > 0);\n   printf(\"%d\\n\", strcmp(a, \"zebra\") < 0);\n\n   printf(\"%d\\n\", strlen(a));\n\n   strcat(a, \"!\");\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", strncmp(a, \"apple\", 2) > 0);\n   printf(\"%d\\n\", strncmp(a, \"goere\", 2) == 0);\n   printf(\"%d\\n\", strncmp(a, \"goerg\", 2) == 0);\n   printf(\"%d\\n\", strncmp(a, \"zebra\", 2) < 0);\n\n   printf(\"%s\\n\", index(a, 'o'));\n   printf(\"%s\\n\", rindex(a, 'l'));\n   printf(\"%d\\n\", rindex(a, 'x') == NULL);\n\n   memset(&a[1], 'r', 4);\n   printf(\"%s\\n\", a);\n\n   memcpy(&a[2], a, 2);\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", memcmp(a, \"apple\", 4) > 0);\n   printf(\"%d\\n\", memcmp(a, \"grgr\", 4) == 0);\n   printf(\"%d\\n\", memcmp(a, \"zebra\", 4) < 0);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/28_strings.expect",
    "content": "hello\ngollo\n1\n1\n1\n5\ngollo!\n1\n1\n1\n1\nollo!\nlo!\n1\ngrrrr!\ngrgrr!\n1\n1\n1\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/29_array_address.c",
    "content": "#include <stdio.h>\n#include <string.h>\n\nint main()\n{\n   char a[10];\n   strcpy(a, \"abcdef\");\n   printf(\"%s\\n\", &a[1]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/29_array_address.expect",
    "content": "bcdef\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/30_hanoi.c",
    "content": "/* example from http://barnyard.syr.edu/quickies/hanoi.c */\n\n/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */\n/* By Terry R. McConnell (12/2/97) */\n/* Compile: cc -o hanoi hanoi.c */\n\n/* This program does no error checking. But then, if it's right, \n   it's right ... right ? */\n\n\n/* The original towers of hanoi problem seems to have been originally posed\n   by one M. Claus in 1883. There is a popular legend that goes along with\n   it that has been often repeated and paraphrased. It goes something like this:\n   In the great temple at Benares there are 3 golden spikes. On one of them,\n   God placed 64 disks increasing in size from bottom to top, at the beginning\n   of time. Since then, and to this day, the priest on duty constantly transfers\n   disks, one at a time, in such a way that no larger disk is ever put on top\n   of a smaller one. When the disks have been transferred entirely to another\n   spike the Universe will come to an end in a large thunderclap.\n\n   This paraphrases the original legend due to DeParville, La Nature, Paris 1884,\n   Part I, 285-286. For this and further information see: Mathematical \n   Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967,\n   303-305.\n *\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#define TRUE 1\n#define FALSE 0\n\n/* This is the number of \"disks\" on tower A initially. Taken to be 64 in the\n * legend. The number of moves required, in general, is 2^N - 1. For N = 64,\n * this is 18,446,744,073,709,551,615 */\n#define N 4\n\n/* These are the three towers. For example if the state of A is 0,1,3,4, that\n * means that there are three discs on A of sizes 1, 3, and 4. (Think of right\n * as being the \"down\" direction.) */\nint A[N], B[N], C[N]; \n\nvoid Hanoi(int,int*,int*,int*);\n\n/* Print the current configuration of A, B, and C to the screen */\nvoid PrintAll()\n{\n   int i;\n\n   printf(\"A: \");\n   for(i=0;i<N;i++)printf(\" %d \",A[i]);\n   printf(\"\\n\");\n\n   printf(\"B: \");\n   for(i=0;i<N;i++)printf(\" %d \",B[i]);\n   printf(\"\\n\");\n\n   printf(\"C: \");\n   for(i=0;i<N;i++)printf(\" %d \",C[i]);\n   printf(\"\\n\");\n   printf(\"------------------------------------------\\n\");\n   return;\n}\n\n/* Move the leftmost nonzero element of source to dest, leave behind 0. */\n/* Returns the value moved (not used.) */\nint Move(int *source, int *dest)\n{\n   int i = 0, j = 0;\n\n   while (i<N && (source[i])==0) i++;\n   while (j<N && (dest[j])==0) j++;\n\n   dest[j-1] = source[i];\n   source[i] = 0;\n   PrintAll();       /* Print configuration after each move. */\n   return dest[j-1];\n}\n\n\n/* Moves first n nonzero numbers from source to dest using the rules of Hanoi.\n   Calls itself recursively.\n   */\nvoid Hanoi(int n,int *source, int *dest, int *spare)\n{\n   int i;\n   if(n==1){\n      Move(source,dest);\n      return;\n   }\n\n   Hanoi(n-1,source,spare,dest);\n   Move(source,dest);\n   Hanoi(n-1,spare,dest,source);\t\n   return;\n}\n\nint main()\n{\n   int i;\n\n   /* initialize the towers */\n   for(i=0;i<N;i++)A[i]=i+1;\n   for(i=0;i<N;i++)B[i]=0;\n   for(i=0;i<N;i++)C[i]=0;\n\n   printf(\"Solution of Tower of Hanoi Problem with %d Disks\\n\\n\",N);\n\n   /* Print the starting state */\n   printf(\"Starting state:\\n\");\n   PrintAll();\n   printf(\"\\n\\nSubsequent states:\\n\\n\");\n\n   /* Do it! Use A = Source, B = Destination, C = Spare */\n   Hanoi(N,A,B,C);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/30_hanoi.expect",
    "content": "Solution of Tower of Hanoi Problem with 4 Disks\n\nStarting state:\nA:  1  2  3  4 \nB:  0  0  0  0 \nC:  0  0  0  0 \n------------------------------------------\n\n\nSubsequent states:\n\nA:  0  2  3  4 \nB:  0  0  0  0 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  3  4 \nB:  0  0  0  2 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  3  4 \nB:  0  0  1  2 \nC:  0  0  0  0 \n------------------------------------------\nA:  0  0  0  4 \nB:  0  0  1  2 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  4 \nB:  0  0  0  2 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  4 \nB:  0  0  0  0 \nC:  0  0  2  3 \n------------------------------------------\nA:  0  0  0  4 \nB:  0  0  0  0 \nC:  0  1  2  3 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  0  0  4 \nC:  0  1  2  3 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  0  1  4 \nC:  0  0  2  3 \n------------------------------------------\nA:  0  0  0  2 \nB:  0  0  1  4 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  2 \nB:  0  0  0  4 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  2 \nB:  0  0  3  4 \nC:  0  0  0  0 \n------------------------------------------\nA:  0  0  0  2 \nB:  0  0  3  4 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  2  3  4 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  0  0 \nB:  1  2  3  4 \nC:  0  0  0  0 \n------------------------------------------\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/31_args.c",
    "content": "#include <stdio.h>\n\nint main(int argc, char **argv)\n{\n   int Count;\n\n   printf(\"hello world %d\\n\", argc);\n   for (Count = 0; Count < argc; Count++)\n      printf(\"arg %d: %s\\n\", Count, argv[Count]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/31_args.expect",
    "content": "hello world 6\narg 0: ./test\narg 1: -\narg 2: arg1\narg 3: arg2\narg 4: arg3\narg 5: arg4\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/32_led.c",
    "content": "/* example from http://barnyard.syr.edu/quickies/led.c */\n\n/* led.c: print out number as if on 7 line led display. I.e., write integer\n   given on command line like this:  \n      _   _       _  \n   |  _|  _| |_| |_  \n   | |_   _|   |  _| etc.\n\n   We assume the terminal behaves like a classical teletype. So the top\n   lines of all digits have to be printed first, then the middle lines of\n   all digits, etc.\n\n   By Terry R. McConnell\n\ncompile: cc -o led led.c\n\nIf you just want to link in the subroutine print_led that does all the\nwork, compile with -DNO_MAIN, and declare the following in any source file\nthat uses the call:\n\nextern void print_led(unsigned long x, char *buf);\n\nBug: you cannot call repeatedly to print more than one number to a line.\nThat would require curses or some other terminal API that allows moving the\ncursor to a previous line.\n\n*/\n\n\n\n#include <stdlib.h>\n#include <stdio.h>\n\n#define MAX_DIGITS 32\n#define NO_MAIN\n\n\n/* Print the top line of the digit d into buffer. \n   Does not null terminate buffer. */\n\nvoid topline(int d, char *p){\n\n   *p++ = ' ';\n   switch(d){\n\n      /* all these have _ on top line */\n\n      case 0:\n      case 2:\n      case 3:\n      case 5:\n      case 7:\n      case 8:\n      case 9:\n         *p++ = '_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   *p++=' ';\n}\n\n/* Print the middle line of the digit d into the buffer. \n   Does not null terminate. */\n\nvoid midline(int d, char *p){\n\n   switch(d){\n\n      /* those that have leading | on middle line */\n\n      case 0:\n      case 4:\n      case 5:\n      case 6:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\t\n   }\n   switch(d){\n\n      /* those that have _ on middle line */\n\n      case 2:\n      case 3:\n      case 4:\n      case 5:\n      case 6:\n      case 8:\n      case 9:\n         *p++='_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   switch(d){\n\n      /* those that have closing | on middle line */\n\n      case 0:\n      case 1:\n      case 2:\n      case 3:\n      case 4:\n      case 7:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\n\n   }\n}\n\n/* Print the bottom line of the digit d. Does not null terminate. */\n\nvoid botline(int d, char *p){\n\n\n   switch(d){\n\n      /* those that have leading | on bottom line */\n\n      case 0:\n      case 2:\n      case 6:\n      case 8:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\t\n   }\n   switch(d){\n\n      /* those that have _ on bottom line */\n\n      case 0:\n      case 2:\n      case 3:\n      case 5:\n      case 6:\n      case 8:\n         *p++='_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   switch(d){\n\n      /* those that have closing | on bottom line */\n\n      case 0:\n      case 1:\n      case 3:\n      case 4:\n      case 5:\n      case 6:\n      case 7:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\n\n   }\n}\n\n/* Write the led representation of integer to string buffer. */\n\nvoid print_led(unsigned long x, char *buf)\n{\n\n   int i=0,n;\n   static int d[MAX_DIGITS];\n\n\n   /* extract digits from x */\n\n   n = ( x == 0L ? 1 : 0 );  /* 0 is a digit, hence a special case */\n\n   while(x){\n      d[n++] = (int)(x%10L);\n      if(n >= MAX_DIGITS)break;\n      x = x/10L;\n   }\n\n   /* print top lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      topline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n'; /* move teletype to next line */\n\n   /* print middle lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      midline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n';\n\n   /* print bottom lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      botline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n';\n   *buf='\\0';\n}\n\nint main()\n{\n   char buf[5*MAX_DIGITS];\n   print_led(1234567, buf);\n   printf(\"%s\\n\",buf);\n\n   return 0;\n}\n\n#ifndef NO_MAIN\nint main(int argc, char **argv)\n{\n\n   int i=0,n;\n   long x;\n   static int d[MAX_DIGITS];\n   char buf[5*MAX_DIGITS];\n\n   if(argc != 2){\n      fprintf(stderr,\"led: usage: led integer\\n\");\n      return 1;\n   }\n\n   /* fetch argument from command line */\n\n   x = atol(argv[1]);\n\n   /* sanity check */\n\n   if(x<0){\n      fprintf(stderr,\"led: %d must be non-negative\\n\",x);\n      return 1;\n   }\n\n   print_led(x,buf);\n   printf(\"%s\\n\",buf);\n\n   return 0;\n\n}\n#endif\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/32_led.expect",
    "content": "     _   _       _       _  \n  |  _|  _| |_| |_  |_    | \n  | |_   _|   |  _| |_|   | \n\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/33_ternary_op.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   for (Count = 0; Count < 10; Count++)\n   {\n      printf(\"%d\\n\", (Count < 5) ? (Count*Count) : (Count * 3));\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/33_ternary_op.expect",
    "content": "0\n1\n4\n9\n16\n15\n18\n21\n24\n27\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/34_array_assignment.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a[4];\n\n   a[0] = 12;\n   a[1] = 23;\n   a[2] = 34;\n   a[3] = 45;\n\n   printf(\"%d %d %d %d\\n\", a[0], a[1], a[2], a[3]);\n\n   int b[4];\n\n   b = a;\n\n   printf(\"%d %d %d %d\\n\", b[0], b[1], b[2], b[3]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/34_array_assignment.expect",
    "content": "12 23 34 45\n12 23 34 45\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/35_sizeof.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char a;\n   short b;\n\n   printf(\"%d %d\\n\", sizeof(char), sizeof(a));\n   printf(\"%d %d\\n\", sizeof(short), sizeof(b));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/35_sizeof.expect",
    "content": "1 1\n2 2\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/36_array_initialisers.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 };\n\n   for (Count = 0; Count < 10; Count++)\n      printf(\"%d: %d\\n\", Count, Array[Count]);\n\n   int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, };\n\n   for (Count = 0; Count < 10; Count++)\n      printf(\"%d: %d\\n\", Count, Array2[Count]);\n\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/36_array_initialisers.expect",
    "content": "0: 12\n1: 34\n2: 56\n3: 78\n4: 90\n5: 123\n6: 456\n7: 789\n8: 8642\n9: 9753\n0: 12\n1: 34\n2: 56\n3: 78\n4: 90\n5: 123\n6: 456\n7: 789\n8: 8642\n9: 9753\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/37_sprintf.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char Buf[100];\n   int Count;\n\n   for (Count = 1; Count <= 20; Count++)\n   {\n      sprintf(Buf, \"->%02d<-\\n\", Count);\n      printf(\"%s\", Buf);\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/37_sprintf.expect",
    "content": "->01<-\n->02<-\n->03<-\n->04<-\n->05<-\n->06<-\n->07<-\n->08<-\n->09<-\n->10<-\n->11<-\n->12<-\n->13<-\n->14<-\n->15<-\n->16<-\n->17<-\n->18<-\n->19<-\n->20<-\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/38_multiple_array_index.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a[4][4];\n   int b = 0;\n   int x;\n   int y;\n\n   for (x = 0; x < 4; x++)\n   {\n      for (y = 0; y < 4; y++)\n      {\n         b++;\n         a[x][y] = b;\n      }\n   }\n\n   for (x = 0; x < 4; x++)\n   {\n      printf(\"x=%d: \", x);\n      for (y = 0; y < 4; y++)\n      {\n         printf(\"%d \", a[x][y]);\n      }\n      printf(\"\\n\");\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/38_multiple_array_index.expect",
    "content": "x=0: 1 2 3 4 \nx=1: 5 6 7 8 \nx=2: 9 10 11 12 \nx=3: 13 14 15 16 \n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/39_typedef.c",
    "content": "#include <stdio.h>\n\ntypedef int MyInt;\n\nstruct FunStruct\n{\n   int i;\n   int j;\n};\n\ntypedef struct FunStruct MyFunStruct;\n\ntypedef MyFunStruct *MoreFunThanEver;\n\nint main()\n{\n   MyInt a = 1;\n   printf(\"%d\\n\", a);\n\n   MyFunStruct b;\n   b.i = 12;\n   b.j = 34;\n   printf(\"%d,%d\\n\", b.i, b.j);\n\n   MoreFunThanEver c = &b;\n   printf(\"%d,%d\\n\", c->i, c->j);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/39_typedef.expect",
    "content": "1\n12,34\n12,34\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/40_stdio.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   FILE *f = fopen(\"fred.txt\", \"w\");\n   fwrite(\"hello\\nhello\\n\", 1, 12, f);\n   fclose(f);\n\n   char freddy[7];\n   f = fopen(\"fred.txt\", \"r\");\n   if (fread(freddy, 1, 6, f) != 6)\n      printf(\"couldn't read fred.txt\\n\");\n\n   freddy[6] = '\\0';\n   fclose(f);\n\n   printf(\"%s\", freddy);\n\n   int InChar;\n   char ShowChar;\n   f = fopen(\"fred.txt\", \"r\");\n   while ( (InChar = fgetc(f)) != EOF)\n   {\n      ShowChar = InChar;\n      if (ShowChar < ' ')\n         ShowChar = '.';\n\n      printf(\"ch: %d '%c'\\n\", InChar, ShowChar);\n   }\n   fclose(f);\n\n   f = fopen(\"fred.txt\", \"r\");\n   while ( (InChar = getc(f)) != EOF)\n   {\n      ShowChar = InChar;\n      if (ShowChar < ' ')\n         ShowChar = '.';\n\n      printf(\"ch: %d '%c'\\n\", InChar, ShowChar);\n   }\n   fclose(f);\n\n   f = fopen(\"fred.txt\", \"r\");\n   while (fgets(freddy, sizeof(freddy), f) != NULL)\n      printf(\"x: %s\", freddy);\n\n   fclose(f);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/40_stdio.expect",
    "content": "hello\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nx: hello\nx: hello\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/41_hashif.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"#include test\\n\");\n\n#if 1\n#if 0\n   printf(\"a\\n\");\n#else\n   printf(\"b\\n\");\n#endif\n#else\n#if 0\n   printf(\"c\\n\");\n#else\n   printf(\"d\\n\");\n#endif\n#endif\n\n#if 0\n#if 1\n   printf(\"e\\n\");\n#else\n   printf(\"f\\n\");\n#endif\n#else\n#if 1\n   printf(\"g\\n\");\n#else\n   printf(\"h\\n\");\n#endif\n#endif\n\n#define DEF\n\n#ifdef DEF\n#ifdef DEF\n   printf(\"i\\n\");\n#else\n   printf(\"j\\n\");\n#endif\n#else\n#ifdef DEF\n   printf(\"k\\n\");\n#else\n   printf(\"l\\n\");\n#endif\n#endif\n\n#ifndef DEF\n#ifndef DEF\n   printf(\"m\\n\");\n#else\n   printf(\"n\\n\");\n#endif\n#else\n#ifndef DEF\n   printf(\"o\\n\");\n#else\n   printf(\"p\\n\");\n#endif\n#endif\n\n#define ONE 1\n#define ZERO 0\n\n#if ONE\n#if ZERO\n   printf(\"q\\n\");\n#else\n   printf(\"r\\n\");\n#endif\n#else\n#if ZERO\n   printf(\"s\\n\");\n#else\n   printf(\"t\\n\");\n#endif\n#endif\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/41_hashif.expect",
    "content": "#include test\nb\ng\ni\np\nr\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/42_function_pointer.c",
    "content": "#include <stdio.h>\n\nint fred(int p)\n{\n   printf(\"yo %d\\n\", p);\n   return 42;\n}\n\nint (*f)(int) = &fred;\n\nint main()\n{\n   printf(\"%d\\n\", (*f)(24));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/42_function_pointer.expect",
    "content": "yo 24\n42\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/43_void_param.c",
    "content": "#include <stdio.h>\n\nvoid fred(void)\n{\n   printf(\"yo\\n\");\n}\n\nint main()\n{\n   fred();\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/43_void_param.expect",
    "content": "yo\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/44_scoped_declarations.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n\n   for (a = 0; a < 2; a++)\n   {\n      int b = a;\n   }\n\n   printf(\"it's all good\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/44_scoped_declarations.expect",
    "content": "it's all good\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/45_empty_for.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count = 0;\n\n   for (;;)\n   {\n      Count++;\n      printf(\"%d\\n\", Count);\n      if (Count >= 10)\n         break;\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/45_empty_for.expect",
    "content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/46_grep.c",
    "content": "/*\n * The  information  in  this  document  is  subject  to  change\n * without  notice  and  should not be construed as a commitment\n * by Digital Equipment Corporation or by DECUS.\n *\n * Neither Digital Equipment Corporation, DECUS, nor the authors\n * assume any responsibility for the use or reliability of  this\n * document or the described software.\n *\n *      Copyright (C) 1980, DECUS\n *\n * General permission to copy or modify, but not for profit,  is\n * hereby  granted,  provided that the above copyright notice is\n * included and reference made to  the  fact  that  reproduction\n * privileges were granted by DECUS.\n */\n\n#include <ctype.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nint match();\nvoid badpat(char *message, char *source, char *stop);\nvoid error(char *s);\nvoid store(int op);\n\n/*\n * grep\n *\n * Runs on the Decus compiler or on vms, On vms, define as:\n *      grep :== \"$disk:[account]grep\"      (native)\n *      grep :== \"$disk:[account]grep grep\" (Decus)\n * See below for more information.\n */\n\nchar    *documentation[] = {\n   \"grep searches a file for a given pattern.  Execute by\",\n   \"   grep [flags] regular_expression file_list\\n\",\n   \"Flags are single characters preceeded by '-':\",\n   \"   -c      Only a count of matching lines is printed\",\n   \"   -f      Print file name for matching lines switch, see below\",\n   \"   -n      Each line is preceeded by its line number\",\n   \"   -v      Only print non-matching lines\\n\",\n   \"The file_list is a list of files (wildcards are acceptable on RSX modes).\",\n   \"\\nThe file name is normally printed if there is a file given.\",\n   \"The -f flag reverses this action (print name no file, not if more).\\n\",\n   0 };\n\nchar    *patdoc[] = {\n   \"The regular_expression defines the pattern to search for.  Upper- and\",\n   \"lower-case are always ignored.  Blank lines never match.  The expression\",\n   \"should be quoted to prevent file-name translation.\",\n   \"x      An ordinary character (not mentioned below) matches that character.\",\n   \"'\\\\'    The backslash quotes any character.  \\\"\\\\$\\\" matches a dollar-sign.\",\n   \"'^'    A circumflex at the beginning of an expression matches the\",\n   \"       beginning of a line.\",\n   \"'$'    A dollar-sign at the end of an expression matches the end of a line.\",\n   \"'.'    A period matches any character except \\\"new-line\\\".\",\n   \"':a'   A colon matches a class of characters described by the following\",\n   \"':d'     character.  \\\":a\\\" matches any alphabetic, \\\":d\\\" matches digits,\",\n   \"':n'     \\\":n\\\" matches alphanumerics, \\\": \\\" matches spaces, tabs, and\",\n   \"': '     other control characters, such as new-line.\",\n   \"'*'    An expression followed by an asterisk matches zero or more\",\n   \"       occurrances of that expression: \\\"fo*\\\" matches \\\"f\\\", \\\"fo\\\"\",\n   \"       \\\"foo\\\", etc.\",\n   \"'+'    An expression followed by a plus sign matches one or more\",\n   \"       occurrances of that expression: \\\"fo+\\\" matches \\\"fo\\\", etc.\",\n   \"'-'    An expression followed by a minus sign optionally matches\",\n   \"       the expression.\",\n   \"'[]'   A string enclosed in square brackets matches any character in\",\n   \"       that string, but no others.  If the first character in the\",\n   \"       string is a circumflex, the expression matches any character\",\n   \"       except \\\"new-line\\\" and the characters in the string.  For\",\n   \"       example, \\\"[xyz]\\\" matches \\\"xx\\\" and \\\"zyx\\\", while \\\"[^xyz]\\\"\",\n   \"       matches \\\"abc\\\" but not \\\"axb\\\".  A range of characters may be\",\n   \"       specified by two characters separated by \\\"-\\\".  Note that,\",\n   \"       [a-z] matches alphabetics, while [z-a] never matches.\",\n   \"The concatenation of regular expressions is a regular expression.\",\n   0};\n\n#define LMAX    512\n#define PMAX    256\n\n#define CHAR    1\n#define BOL     2\n#define EOL     3\n#define ANY     4\n#define CLASS   5\n#define NCLASS  6\n#define STAR    7\n#define PLUS    8\n#define MINUS   9\n#define ALPHA   10\n#define DIGIT   11\n#define NALPHA  12\n#define PUNCT   13\n#define RANGE   14\n#define ENDPAT  15\n\nint cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0;\n\nchar *pp, lbuf[LMAX], pbuf[PMAX];\n\nchar *cclass();\nchar *pmatch();\n\n\n/*** Display a file name *******************************/\nvoid file(char *s)\n{\n   printf(\"File %s:\\n\", s);\n}\n\n/*** Report unopenable file ****************************/\nvoid cant(char *s)\n{\n   fprintf(stderr, \"%s: cannot open\\n\", s);\n}\n\n/*** Give good help ************************************/\nvoid help(char **hp)\n{\n   char   **dp;\n\n   for (dp = hp; *dp; ++dp)\n      printf(\"%s\\n\", *dp);\n}\n\n/*** Display usage summary *****************************/\nvoid usage(char *s)\n{\n   fprintf(stderr, \"?GREP-E-%s\\n\", s);\n   fprintf(stderr,\n         \"Usage: grep [-cfnv] pattern [file ...].  grep ? for help\\n\");\n   exit(1);\n}\n\n/*** Compile the pattern into global pbuf[] ************/\nvoid compile(char *source)\n{\n   char  *s;         /* Source string pointer     */\n   char  *lp;        /* Last pattern pointer      */\n   int   c;          /* Current character         */\n   int            o;          /* Temp                      */\n   char           *spp;       /* Save beginning of pattern */\n\n   s = source;\n   if (debug)\n      printf(\"Pattern = \\\"%s\\\"\\n\", s);\n   pp = pbuf;\n   while (c = *s++) {\n      /*\n       * STAR, PLUS and MINUS are special.\n       */\n      if (c == '*' || c == '+' || c == '-') {\n         if (pp == pbuf ||\n               (o=pp[-1]) == BOL ||\n               o == EOL ||\n               o == STAR ||\n               o == PLUS ||\n               o == MINUS)\n            badpat(\"Illegal occurrance op.\", source, s);\n         store(ENDPAT);\n         store(ENDPAT);\n         spp = pp;               /* Save pattern end     */\n         while (--pp > lp)       /* Move pattern down    */\n            *pp = pp[-1];        /* one byte             */\n         *pp =   (c == '*') ? STAR :\n            (c == '-') ? MINUS : PLUS;\n         pp = spp;               /* Restore pattern end  */\n         continue;\n      }\n      /*\n       * All the rest.\n       */\n      lp = pp;         /* Remember start       */\n      switch(c) {\n\n         case '^':\n            store(BOL);\n            break;\n\n         case '$':\n            store(EOL);\n            break;\n\n         case '.':\n            store(ANY);\n            break;\n\n         case '[':\n            s = cclass(source, s);\n            break;\n\n         case ':':\n            if (*s) {\n               switch(tolower(c = *s++)) {\n\n                  case 'a':\n                  case 'A':\n                     store(ALPHA);\n                     break;\n\n                  case 'd':\n                  case 'D':\n                     store(DIGIT);\n                     break;\n\n                  case 'n':\n                  case 'N':\n                     store(NALPHA);\n                     break;\n\n                  case ' ':\n                     store(PUNCT);\n                     break;\n\n                  default:\n                     badpat(\"Unknown : type\", source, s);\n\n               }\n               break;\n            }\n            else    badpat(\"No : type\", source, s);\n\n         case '\\\\':\n            if (*s)\n               c = *s++;\n\n         default:\n            store(CHAR);\n            store(tolower(c));\n      }\n   }\n   store(ENDPAT);\n   store(0);                /* Terminate string     */\n   if (debug) {\n      for (lp = pbuf; lp < pp;) {\n         if ((c = (*lp++ & 0377)) < ' ')\n            printf(\"\\\\%o \", c);\n         else    printf(\"%c \", c);\n      }\n      printf(\"\\n\");\n   }\n}\n\n/*** Compile a class (within []) ***********************/\nchar *cclass(char *source, char *src)\n   /* char       *source;   // Pattern start -- for error msg. */\n   /* char       *src;      // Class start */\n{\n   char   *s;        /* Source pointer    */\n   char   *cp;       /* Pattern start     */\n   int    c;         /* Current character */\n   int             o;         /* Temp              */\n\n   s = src;\n   o = CLASS;\n   if (*s == '^') {\n      ++s;\n      o = NCLASS;\n   }\n   store(o);\n   cp = pp;\n   store(0);                          /* Byte count      */\n   while ((c = *s++) && c!=']') {\n      if (c == '\\\\') {                /* Store quoted char    */\n         if ((c = *s++) == '\\0')      /* Gotta get something  */\n            badpat(\"Class terminates badly\", source, s);\n         else    store(tolower(c));\n      }\n      else if (c == '-' &&\n            (pp - cp) > 1 && *s != ']' && *s != '\\0') {\n         c = pp[-1];             /* Range start     */\n         pp[-1] = RANGE;         /* Range signal    */\n         store(c);               /* Re-store start  */\n         c = *s++;               /* Get end char and*/\n         store(tolower(c));      /* Store it        */\n      }\n      else {\n         store(tolower(c));      /* Store normal char */\n      }\n   }\n   if (c != ']')\n      badpat(\"Unterminated class\", source, s);\n   if ((c = (pp - cp)) >= 256)\n      badpat(\"Class too large\", source, s);\n   if (c == 0)\n      badpat(\"Empty class\", source, s);\n   *cp = c;\n   return(s);\n}\n\n/*** Store an entry in the pattern buffer **************/\nvoid store(int op)\n{\n   if (pp >= &pbuf[PMAX])\n      error(\"Pattern too complex\\n\");\n   *pp++ = op;\n}\n\n/*** Report a bad pattern specification ****************/\nvoid badpat(char *message, char *source, char *stop)\n   /* char  *message;       // Error message */\n   /* char  *source;        // Pattern start */\n   /* char  *stop;          // Pattern end   */\n{\n   fprintf(stderr, \"-GREP-E-%s, pattern is\\\"%s\\\"\\n\", message, source);\n   fprintf(stderr, \"-GREP-E-Stopped at byte %d, '%c'\\n\",\n         stop-source, stop[-1]);\n   error(\"?GREP-E-Bad pattern\\n\");\n}\n\n/*** Scan the file for the pattern in pbuf[] ***********/\nvoid grep(FILE *fp, char *fn)\n   /* FILE       *fp;       // File to process            */\n   /* char       *fn;       // File name (for -f option)  */\n{\n   int lno, count, m;\n\n   lno = 0;\n   count = 0;\n   while (fgets(lbuf, LMAX, fp)) {\n      ++lno;\n      m = match();\n      if ((m && !vflag) || (!m && vflag)) {\n         ++count;\n         if (!cflag) {\n            if (fflag && fn) {\n               file(fn);\n               fn = 0;\n            }\n            if (nflag)\n               printf(\"%d\\t\", lno);\n            printf(\"%s\\n\", lbuf);\n         }\n      }\n   }\n   if (cflag) {\n      if (fflag && fn)\n         file(fn);\n      printf(\"%d\\n\", count);\n   }\n}\n\n/*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/\nint match()\n{\n   char   *l;        /* Line pointer       */\n\n   for (l = lbuf; *l; ++l) {\n      if (pmatch(l, pbuf))\n         return(1);\n   }\n   return(0);\n}\n\n/*** Match partial line with pattern *******************/\nchar *pmatch(char *line, char *pattern)\n   /* char               *line;     // (partial) line to match      */\n   /* char               *pattern;  // (partial) pattern to match   */\n{\n   char   *l;        /* Current line pointer         */\n   char   *p;        /* Current pattern pointer      */\n   char   c;         /* Current character            */\n   char            *e;        /* End for STAR and PLUS match  */\n   int             op;        /* Pattern operation            */\n   int             n;         /* Class counter                */\n   char            *are;      /* Start of STAR match          */\n\n   l = line;\n   if (debug > 1)\n      printf(\"pmatch(\\\"%s\\\")\\n\", line);\n   p = pattern;\n   while ((op = *p++) != ENDPAT) {\n      if (debug > 1)\n         printf(\"byte[%d] = 0%o, '%c', op = 0%o\\n\",\n               l-line, *l, *l, op);\n      switch(op) {\n\n         case CHAR:\n            if (tolower(*l++) != *p++)\n               return(0);\n            break;\n\n         case BOL:\n            if (l != lbuf)\n               return(0);\n            break;\n\n         case EOL:\n            if (*l != '\\0')\n               return(0);\n            break;\n\n         case ANY:\n            if (*l++ == '\\0')\n               return(0);\n            break;\n\n         case DIGIT:\n            if ((c = *l++) < '0' || (c > '9'))\n               return(0);\n            break;\n\n         case ALPHA:\n            c = tolower(*l++);\n            if (c < 'a' || c > 'z')\n               return(0);\n            break;\n\n         case NALPHA:\n            c = tolower(*l++);\n            if (c >= 'a' && c <= 'z')\n               break;\n            else if (c < '0' || c > '9')\n               return(0);\n            break;\n\n         case PUNCT:\n            c = *l++;\n            if (c == 0 || c > ' ')\n               return(0);\n            break;\n\n         case CLASS:\n         case NCLASS:\n            c = tolower(*l++);\n            n = *p++ & 0377;\n            do {\n               if (*p == RANGE) {\n                  p += 3;\n                  n -= 2;\n                  if (c >= p[-2] && c <= p[-1])\n                     break;\n               }\n               else if (c == *p++)\n                  break;\n            } while (--n > 1);\n            if ((op == CLASS) == (n <= 1))\n               return(0);\n            if (op == CLASS)\n               p += n - 2;\n            break;\n\n         case MINUS:\n            e = pmatch(l, p);       /* Look for a match    */\n            while (*p++ != ENDPAT); /* Skip over pattern   */\n            if (e)                  /* Got a match?        */\n               l = e;               /* Yes, update string  */\n            break;                  /* Always succeeds     */\n\n         case PLUS:                 /* One or more ...     */\n            if ((l = pmatch(l, p)) == 0)\n               return(0);           /* Gotta have a match  */\n         case STAR:                 /* Zero or more ...    */\n            are = l;                /* Remember line start */\n            while (*l && (e = pmatch(l, p)))\n               l = e;               /* Get longest match   */\n            while (*p++ != ENDPAT); /* Skip over pattern   */\n            while (l >= are) {      /* Try to match rest   */\n               if (e = pmatch(l, p))\n                  return(e);\n               --l;                 /* Nope, try earlier   */\n            }\n            return(0);              /* Nothing else worked */\n\n         default:\n            printf(\"Bad op code %d\\n\", op);\n            error(\"Cannot happen -- match\\n\");\n      }\n   }\n   return(l);\n}\n\n/*** Report an error ***********************************/\nvoid error(char *s)\n{\n   fprintf(stderr, \"%s\", s);\n   exit(1);\n}\n\n/*** Main program - parse arguments & grep *************/\nint main(int argc, char **argv)\n{\n   char   *p;\n   int    c, i;\n   int             gotpattern;\n\n   FILE            *f;\n\n   if (argc <= 1)\n      usage(\"No arguments\");\n   if (argc == 2 && argv[1][0] == '?' && argv[1][1] == 0) {\n      help(documentation);\n      help(patdoc);\n      return 0;\n   }\n   nfile = argc-1;\n   gotpattern = 0;\n   for (i=1; i < argc; ++i) {\n      p = argv[i];\n      if (*p == '-') {\n         ++p;\n         while (c = *p++) {\n            switch(tolower(c)) {\n\n               case '?':\n                  help(documentation);\n                  break;\n\n               case 'C':\n               case 'c':\n                  ++cflag;\n                  break;\n\n               case 'D':\n               case 'd':\n                  ++debug;\n                  break;\n\n               case 'F':\n               case 'f':\n                  ++fflag;\n                  break;\n\n               case 'n':\n               case 'N':\n                  ++nflag;\n                  break;\n\n               case 'v':\n               case 'V':\n                  ++vflag;\n                  break;\n\n               default:\n                  usage(\"Unknown flag\");\n            }\n         }\n         argv[i] = 0;\n         --nfile;\n      } else if (!gotpattern) {\n         compile(p);\n         argv[i] = 0;\n         ++gotpattern;\n         --nfile;\n      }\n   }\n   if (!gotpattern)\n      usage(\"No pattern\");\n   if (nfile == 0)\n      grep(stdin, 0);\n   else {\n      fflag = fflag ^ (nfile > 0);\n      for (i=1; i < argc; ++i) {\n         if (p = argv[i]) {\n            if ((f=fopen(p, \"r\")) == NULL)\n               cant(p);\n            else {\n               grep(f, p);\n               fclose(f);\n            }\n         }\n      }\n   }\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/47_switch_return.c",
    "content": "#include <stdio.h>\n\nvoid fred(int x)\n{\n   switch (x)\n   {\n      case 1: printf(\"1\\n\"); return;\n      case 2: printf(\"2\\n\"); break;\n      case 3: printf(\"3\\n\"); return;\n   }\n\n   printf(\"out\\n\");\n}\n\nint main()\n{\n   fred(1);\n   fred(2);\n   fred(3);\n\n   return 0;\n}    \n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/47_switch_return.expect",
    "content": "1\n2\nout\n3\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/48_nested_break.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   char b;\n\n   a = 0;\n   while (a < 2)\n   {\n      printf(\"%d\", a++);\n      break;\n\n      b = 'A';\n      while (b < 'C')\n      {\n         printf(\"%c\", b++);\n      }\n      printf(\"e\");\n   }\n   printf(\"\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/48_nested_break.expect",
    "content": "0\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/49_bracket_evaluation.c",
    "content": "#include <stdio.h>\n\nstruct point\n{\n   double x;\n   double y;\n};\n\nstruct point point_array[100];\n\nint main()\n{\n   int my_point = 10;\n\n   point_array[my_point].x = 12.34;\n   point_array[my_point].y = 56.78;\n\n   printf(\"%f, %f\\n\", point_array[my_point].x, point_array[my_point].y);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/49_bracket_evaluation.expect",
    "content": "12.340000, 56.780000\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/50_logical_second_arg.c",
    "content": "#include <stdio.h>\n\nint fred()\n{\n   printf(\"fred\\n\");\n   return 0;\n}\n\nint joe()\n{\n   printf(\"joe\\n\");\n   return 1;\n}\n\nint main()\n{\n   printf(\"%d\\n\", fred() && joe());\n   printf(\"%d\\n\", fred() || joe());\n   printf(\"%d\\n\", joe() && fred());\n   printf(\"%d\\n\", joe() || fred());\n   printf(\"%d\\n\", fred() && (1 + joe()));\n   printf(\"%d\\n\", fred() || (0 + joe()));\n   printf(\"%d\\n\", joe() && (0 + fred()));\n   printf(\"%d\\n\", joe() || (1 + fred()));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/50_logical_second_arg.expect",
    "content": "fred\n0\nfred\njoe\n1\njoe\nfred\n0\njoe\n1\nfred\n0\nfred\njoe\n1\njoe\nfred\n0\njoe\n1\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/51_static.c",
    "content": "#include <stdio.h>\n\nstatic int fred = 1234;\nstatic int joe;\n\nvoid henry()\n{\n   static int fred = 4567;\n\n   printf(\"%d\\n\", fred);\n   fred++;\n}\n\nint main()\n{\n   printf(\"%d\\n\", fred);\n   henry();\n   henry();\n   henry();\n   henry();\n   printf(\"%d\\n\", fred);\n   fred = 8901;\n   joe = 2345;\n   printf(\"%d\\n\", fred);\n   printf(\"%d\\n\", joe);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/51_static.expect",
    "content": "1234\n4567\n4568\n4569\n4570\n1234\n8901\n2345\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/52_unnamed_enum.c",
    "content": "#include <stdio.h>\n\nenum fred { a, b, c };\n\nint main()\n{\n   printf(\"a=%d\\n\", a);\n   printf(\"b=%d\\n\", b);\n   printf(\"c=%d\\n\", c);\n\n   enum fred d;\n\n   typedef enum { e, f, g } h;\n   typedef enum { i, j, k } m;\n\n   printf(\"e=%d\\n\", e);\n   printf(\"f=%d\\n\", f);\n   printf(\"g=%d\\n\", g);\n\n   printf(\"i=%d\\n\", i);\n   printf(\"j=%d\\n\", j);\n   printf(\"k=%d\\n\", k);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/52_unnamed_enum.expect",
    "content": "a=0\nb=1\nc=2\ne=0\nf=1\ng=2\ni=0\nj=1\nk=2\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/54_goto.c",
    "content": "#include <stdio.h>\n\nvoid fred()\n{\n   printf(\"In fred()\\n\");\n   goto done;\n   printf(\"In middle\\n\");\ndone:\n   printf(\"At end\\n\");\n}\n\nvoid joe()\n{\n   int b = 5678;\n\n   printf(\"In joe()\\n\");\n\n   {\n      int c = 1234;\n      printf(\"c = %d\\n\", c);\n      goto outer;\n      printf(\"uh-oh\\n\");\n   }\n\nouter:    \n\n   printf(\"done\\n\");\n}\n\nvoid henry()\n{\n   int a;\n\n   printf(\"In henry()\\n\");\n   goto inner;\n\n   {\n      int b;\ninner:    \n      b = 1234;\n      printf(\"b = %d\\n\", b);\n   }\n\n   printf(\"done\\n\");\n}\n\nint main()\n{\n   fred();\n   joe();\n   henry();\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/54_goto.expect",
    "content": "In fred()\nAt end\nIn joe()\nc = 1234\ndone\nIn henry()\nb = 1234\ndone\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/55_lshift_type.c",
    "content": "/* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $\n\nTests on left-shift type, written by Vincent Lefevre <vincent@vinc17.net>.\n\nISO C99 TC3 says: [6.5.7#3] \"The integer promotions are performed on\neach of the operands. The type of the result is that of the promoted\nleft operand.\"\n*/\n\n#include <stdio.h>\n\n#define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0)\n#define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1))\n#define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0)\n#define TEST2(X)                 \\\n  do                             \\\n    {                            \\\n      TEST1((X),short);          \\\n      TEST1((X),int);            \\\n      TEST1((X),long);           \\\n      TEST1((X),long long);      \\\n    }                            \\\n  while (0)\n#define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0)\n#define TEST4(X)                 \\\n  do                             \\\n    {                            \\\n      TEST3((X),short);          \\\n      TEST3((X),int);            \\\n      TEST3((X),long);           \\\n      TEST3((X),long long);      \\\n    }                            \\\n while (0)\n\nstatic int debug, nfailed = 0;\n\nstatic void check (const char *s, int arg1, int shift)\n{\n  int failed = arg1 != shift;\n  if (debug || failed)\n    printf (\"%s %d %d\\n\", s, arg1, shift);\n  nfailed += failed;\n}\n\nint main (int argc, char **argv)\n{\n  debug = argc > 1;\n  TEST4(1);\n  TEST4(-1);\n  printf (\"%d test(s) failed\\n\", nfailed);\n  return nfailed != 0;\n}\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/55_lshift_type.expect",
    "content": "0 test(s) failed\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/LICENSE",
    "content": "The tests in this directory are either directly copied from the picoc project or\nare subsequently modified and added to for the purpose of TinyCC project. All\nthese modifications are licensed under the same terms as TinyCC as specified in\nthe file COPYING.\n\n=== picoc license ===\n\nCopyright (c) 2009-2011, Zik Saleeba\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without \nmodification, are permitted provided that the following conditions are \nmet:\n\n    * Redistributions of source code must retain the above copyright \n      notice, this list of conditions and the following disclaimer.\n      \n    * Redistributions in binary form must reproduce the above copyright \n      notice, this list of conditions and the following disclaimer in \n      the documentation and/or other materials provided with the \n      distribution.\n      \n    * Neither the name of the Zik Saleeba nor the names of its \n      contributors may be used to endorse or promote products derived \n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "testdata/tcc-0.9.26/tests/tests2/Makefile",
    "content": "TOP = ../..\ninclude $(TOP)/Makefile\nVPATH = $(top_srcdir)/tests/tests2\n\nTCCFLAGS = -B$(TOP)\nifdef CONFIG_WIN32\n TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)\nendif\n\nifeq ($(TARGETOS),Darwin)\n CFLAGS += -Wl,-flat_namespace,-undefined,warning\n TCCFLAGS += -D_ANSI_SOURCE\n export MACOSX_DEPLOYMENT_TARGET:=10.2\nendif\n\nTCC_RUN = $(TOP)/tcc $(TCCFLAGS) -run\n\nTESTS =\t\\\n 00_assignment.test \\\n 01_comment.test \\\n 02_printf.test \\\n 03_struct.test \\\n 04_for.test \\\n 05_array.test \\\n 06_case.test \\\n 07_function.test \\\n 08_while.test \\\n 09_do_while.test \\\n 10_pointer.test \\\n 11_precedence.test \\\n 12_hashdefine.test \\\n 13_integer_literals.test \\\n 14_if.test \\\n 15_recursion.test \\\n 16_nesting.test \\\n 17_enum.test \\\n 18_include.test \\\n 19_pointer_arithmetic.test \\\n 20_pointer_comparison.test \\\n 21_char_array.test \\\n 22_floating_point.test \\\n 23_type_coercion.test \\\n 24_math_library.test \\\n 25_quicksort.test \\\n 26_character_constants.test \\\n 27_sizeof.test \\\n 28_strings.test \\\n 29_array_address.test \\\n 31_args.test \\\n 32_led.test \\\n 33_ternary_op.test \\\n 35_sizeof.test \\\n 36_array_initialisers.test \\\n 37_sprintf.test \\\n 38_multiple_array_index.test \\\n 39_typedef.test \\\n 40_stdio.test \\\n 41_hashif.test \\\n 42_function_pointer.test \\\n 43_void_param.test \\\n 44_scoped_declarations.test \\\n 45_empty_for.test \\\n 47_switch_return.test \\\n 48_nested_break.test \\\n 49_bracket_evaluation.test \\\n 50_logical_second_arg.test \\\n 51_static.test \\\n 52_unnamed_enum.test \\\n 54_goto.test \\\n 55_lshift_type.test\n\n# 30_hanoi.test -- seg fault in the code, gcc as well\n# 34_array_assignment.test -- array assignment is not in C standard\n# 46_grep.test -- does not compile even with gcc\n\n# some tests do not pass on all platforms, remove them for now\nifeq ($(TARGETOS),Darwin)\n  TESTS := $(filter-out 40_stdio.test,$(TESTS))\nendif\nifdef CONFIG_WIN32\n  TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS))\nendif\n\n%.test: %.c %.expect\n\t@echo Test: $*...\n\t@if [ \"x`echo $* | grep args`\" != \"x\" ]; \\\n\tthen $(TCC_RUN) $< - arg1 arg2 arg3 arg4 >$*.output; \\\n\telse $(TCC_RUN) $< >$*.output; \\\n\tfi\n\t@if diff -bu $(<:.c=.expect) $*.output ; \\\n\tthen rm -f $*.output; \\\n\telse exit 1; \\\n\tfi\n\nall test: $(TESTS)\n\nclean:\n\trm -vf fred.txt *.output\n"
  },
  {
    "path": "testdata/vers2.h",
    "content": "vers2.h included from testdata/example-6.10.3.5-4.h\n"
  },
  {
    "path": "trigraphs.go",
    "content": "// Code generated by golex. DO NOT EDIT.\n\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n//\n\n// Implements translation phases 1 and 2 of [0], 5.1.1.2.\n\npackage cc\n\nimport (\n\t\"fmt\"\n)\n\nconst (\n\t_ = iota\n\tscTRIGRAPHS\n)\n\nfunc (t *trigraphsReader) scan() (r int) {\n\tc := t.Enter()\n\nyystate0:\n\tyyrule := -1\n\t_ = yyrule\n\tc = t.Rule0()\n\n\tswitch yyt := t.sc; yyt {\n\tdefault:\n\t\tpanic(fmt.Errorf(`invalid start condition %d`, yyt))\n\tcase 0: // start condition: INITIAL\n\t\tgoto yystart1\n\tcase 1: // start condition: TRIGRAPHS\n\t\tgoto yystart5\n\t}\n\n\tgoto yystate0 // silence unused label error\n\tgoto yyAction // silence unused label error\nyyAction:\n\tswitch yyrule {\n\tcase 1:\n\t\tgoto yyrule1\n\tcase 2:\n\t\tgoto yyrule2\n\tcase 3:\n\t\tgoto yyrule3\n\tcase 4:\n\t\tgoto yyrule4\n\tcase 5:\n\t\tgoto yyrule5\n\tcase 6:\n\t\tgoto yyrule6\n\tcase 7:\n\t\tgoto yyrule7\n\tcase 8:\n\t\tgoto yyrule8\n\tcase 9:\n\t\tgoto yyrule9\n\tcase 10:\n\t\tgoto yyrule10\n\tcase 11:\n\t\tgoto yyrule11\n\t}\n\tgoto yystate1 // silence unused label error\nyystate1:\n\tc = t.Next()\nyystart1:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate3\n\tcase c == '\\r':\n\t\tgoto yystate2\n\t}\n\nyystate2:\n\tc = t.Next()\n\tyyrule = 10\n\tt.Mark()\n\tgoto yyrule10\n\nyystate3:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate2\n\tcase c == '\\r':\n\t\tgoto yystate4\n\t}\n\nyystate4:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate2\n\t}\n\n\tgoto yystate5 // silence unused label error\nyystate5:\n\tc = t.Next()\nyystart5:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '?':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate3\n\tcase c == '\\r':\n\t\tgoto yystate2\n\t}\n\nyystate6:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '?':\n\t\tgoto yystate7\n\t}\n\nyystate7:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate8\n\tcase c == '(':\n\t\tgoto yystate10\n\tcase c == ')':\n\t\tgoto yystate11\n\tcase c == '-':\n\t\tgoto yystate12\n\tcase c == '/':\n\t\tgoto yystate13\n\tcase c == '<':\n\t\tgoto yystate16\n\tcase c == '=':\n\t\tgoto yystate17\n\tcase c == '>':\n\t\tgoto yystate18\n\tcase c == '\\'':\n\t\tgoto yystate9\n\t}\n\nyystate8:\n\tc = t.Next()\n\tyyrule = 1\n\tt.Mark()\n\tgoto yyrule1\n\nyystate9:\n\tc = t.Next()\n\tyyrule = 2\n\tt.Mark()\n\tgoto yyrule2\n\nyystate10:\n\tc = t.Next()\n\tyyrule = 3\n\tt.Mark()\n\tgoto yyrule3\n\nyystate11:\n\tc = t.Next()\n\tyyrule = 4\n\tt.Mark()\n\tgoto yyrule4\n\nyystate12:\n\tc = t.Next()\n\tyyrule = 5\n\tt.Mark()\n\tgoto yyrule5\n\nyystate13:\n\tc = t.Next()\n\tyyrule = 6\n\tt.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule6\n\tcase c == '\\n':\n\t\tgoto yystate14\n\tcase c == '\\r':\n\t\tgoto yystate15\n\t}\n\nyystate14:\n\tc = t.Next()\n\tyyrule = 11\n\tt.Mark()\n\tgoto yyrule11\n\nyystate15:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate14\n\t}\n\nyystate16:\n\tc = t.Next()\n\tyyrule = 7\n\tt.Mark()\n\tgoto yyrule7\n\nyystate17:\n\tc = t.Next()\n\tyyrule = 8\n\tt.Mark()\n\tgoto yyrule8\n\nyystate18:\n\tc = t.Next()\n\tyyrule = 9\n\tt.Mark()\n\tgoto yyrule9\n\nyyrule1: // \"??!\"\n\t{\n\t\treturn '|'\n\t}\nyyrule2: // \"??'\"\n\t{\n\t\treturn '^'\n\t}\nyyrule3: // \"??(\"\n\t{\n\t\treturn '['\n\t}\nyyrule4: // \"??)\"\n\t{\n\t\treturn ']'\n\t}\nyyrule5: // \"??-\"\n\t{\n\t\treturn '~'\n\t}\nyyrule6: // \"??/\"\n\t{\n\t\treturn '\\\\'\n\t}\nyyrule7: // \"??<\"\n\t{\n\t\treturn '{'\n\t}\nyyrule8: // \"??=\"\n\t{\n\t\treturn '#'\n\t}\nyyrule9: // \"??>\"\n\t{\n\t\treturn '}'\n\t}\nyyrule10: // \\\\\\r?\\n|\\r\nyyrule11: // \"??/\"\\r?\\n\n\n\tgoto yystate0\n\tpanic(\"unreachable\")\n\n\tgoto yyabort // silence unused label error\n\nyyabort: // no lexem recognized\n\tif c, ok := t.Abort(); ok {\n\t\treturn c\n\t}\n\n\tgoto yyAction\n}\n"
  },
  {
    "path": "trigraphs.l",
    "content": "%{\n// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n//\n\n// Implements translation phases 1 and 2 of [0], 5.1.1.2.\n%}\n\n%yyc c\n%yyn c = t.Next()\n%yym t.Mark()\n%yyt t.sc\n\n%s TRIGRAPHS\n\n%{\npackage cc\n\nimport (\n        \"fmt\"\n)\n\nconst (\n        _ = iota\n        scTRIGRAPHS\n)\n\nfunc (t *trigraphsReader) scan() (r int) {\n        c := t.Enter()\n%}\n\n%%\n        c = t.Rule0()\n\n<TRIGRAPHS>\"??!\"        return '|'\n<TRIGRAPHS>\"??'\"        return '^'\n<TRIGRAPHS>\"??(\"        return '['\n<TRIGRAPHS>\"??)\"        return ']'\n<TRIGRAPHS>\"??-\"        return '~'\n<TRIGRAPHS>\"??/\"        return '\\\\'\n<TRIGRAPHS>\"??<\"        return '{'\n<TRIGRAPHS>\"??=\"        return '#'\n<TRIGRAPHS>\"??>\"        return '}'\n\n\\\\\\r?\\n|\\r |\n<TRIGRAPHS>\"??/\"\\r?\\n\n\n%%\n        if c, ok := t.Abort(); ok {\n                return c\n        }\n        \n        goto yyAction\n}\n"
  },
  {
    "path": "ucn32.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build 386 arm armbe mips mipsle sparc\n\npackage cc\n\nvar ucnDigits = [...]uint32{\n\t0x33: 0x3ff,\n\t0x37: 0x3ff0000,\n\t0x4b: 0xffc0,\n\t0x4f: 0xffc0,\n\t0x53: 0xffc0,\n\t0x57: 0xffc0,\n\t0x5b: 0xffc0,\n\t0x5f: 0xff80,\n\t0x63: 0xffc0,\n\t0x67: 0xffc0,\n\t0x6b: 0xffc0,\n\t0x72: 0x3ff0000,\n\t0x76: 0x3ff0000,\n\t0x79: 0xfffff,\n}\n\nvar ucnNonDigits = [...]uint32{\n\t0x5: 0x4a00400, 0xff7fffff, 0xff7fffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xfc3fffff,\n\t0xffffff, 0x12: 0xffff0000, 0xffffffff,\n\t0xffffffff, 0xe9ff01ff, 0x30003, 0x1f,\n\t0x1b: 0x4000000,\n\t0xffffd740, 0xfffffffb, 0x547f7fff, 0xffffd,\n\t0xffffdffe, 0xffffffff, 0xdffeffff, 0xffffffff,\n\t0xffff0003, 0xffffffff, 0xffff199f, 0x33fcfff,\n\t0x29: 0xfffe0000, 0x27fffff, 0xfffffffe,\n\t0xff, 0x3ff0000, 0x2f: 0x70000,\n\t0x31: 0x7fffffe, 0x7ffff, 0xffff0000,\n\t0xffffffff, 0x7cffffff, 0x1fff7fff, 0x3de0,\n\t0x48: 0xffffffee, 0xe3ffffff, 0xff073fff, 0xf,\n\t0xfff99fee, 0xc3c5fdff, 0xb000399f, 0x3000f,\n\t0xfff987e4, 0xc36dfdff, 0x5e003987, 0x100000,\n\t0xfffbafee, 0xe3edfdff, 0x13bbf, 0x1,\n\t0xfff99fee, 0xe3cdfdff, 0xb000398f, 0x3,\n\t0xd63dc7ec, 0xc3bfc718, 0x3dc7,\n\t0x60: 0xfffddfee, 0xc3effdff, 0x3ddf, 0x3,\n\t0xfffddfec, 0xc3effdff, 0x40003ddf, 0x3,\n\t0xfffddfec, 0xc3fffdff, 0x3dcf, 0x3,\n\t0x70: 0xfffffffe, 0x7ffffff, 0xc00ffff,\n\t0x74: 0xfef02596, 0x3bff6cae, 0x30003f5f,\n\t0x78: 0x3000001, 0xc2a00000, 0xfffffeff, 0xfffe03ff,\n\t0xfebf0fdf, 0x2fe3fff,\n\t0x85: 0xffffffff, 0xffff003f, 0x7fffff,\n\t0xf0: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xfffffff, 0xffffffff, 0xffffffff, 0x3ffffff,\n\t0x3f3fffff, 0xffffffff, 0xaaff3f3f, 0x3fffffff,\n\t0xffffffff, 0x5fdfffff, 0xfcf1fdc, 0x1fdc1fff,\n\t0x101: 0x80000000, 0x1, 0x80000000,\n\t0x108: 0x3f2ffc84, 0x1fbfd50, 0x10b: 0xffffffff,\n\t0x7,\n\t0x180: 0xe0, 0x3fe, 0xfffffffe, 0xffffffff,\n\t0x180fffff, 0xfffffffe, 0xffffffff, 0x187fffff,\n\t0xffffffe0, 0x1fff,\n\t0x270: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0x3f,\n\t0x560: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xf,\n}\n"
  },
  {
    "path": "ucn64.go",
    "content": "// Copyright 2016 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build amd64 amd64p32 arm64 arm64be ppc64 ppc64le mips64 mips64le mips64p32 mips64p32le sparc64\n\npackage cc\n\nvar ucnDigits = [...]uint64{\n\t0x19: 0x3ff00000000, 0x1b: 0x3ff000000000000,\n\t0x25: 0xffc000000000, 0x27: 0xffc000000000,\n\t0x29: 0xffc000000000, 0x2b: 0xffc000000000,\n\t0x2d: 0xffc000000000, 0x2f: 0xff8000000000,\n\t0x31: 0xffc000000000, 0x33: 0xffc000000000,\n\t0x35: 0xffc000000000,\n\t0x39: 0x3ff0000, 0x3b: 0x3ff0000,\n\t0xfffff00000000,\n}\n\nvar ucnNonDigits = [...]uint64{\n\t0x2: 0x4a0040000000000, 0xff7fffffff7fffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xfc3fffffffffffff,\n\t0xffffff, 0xffffffffffff0000, 0xe9ff01ffffffffff, 0x1f00030003,\n\t0xd: 0x400000000000000, 0xfffffffbffffd740, 0xffffd547f7fff,\n\t0xffffffffffffdffe, 0xffffffffdffeffff, 0xffffffffffff0003, 0x33fcfffffff199f,\n\t0xfffe000000000000, 0xfffffffe027fffff, 0x3ff0000000000ff, 0x7000000000000,\n\t0x7fffffe00000000, 0xffff00000007ffff, 0x7cffffffffffffff, 0x3de01fff7fff,\n\t0x24: 0xe3ffffffffffffee, 0xfff073fff, 0xc3c5fdfffff99fee, 0x3000fb000399f,\n\t0xc36dfdfffff987e4, 0x1000005e003987, 0xe3edfdfffffbafee, 0x100013bbf,\n\t0xe3cdfdfffff99fee, 0x3b000398f, 0xc3bfc718d63dc7ec, 0x3dc7,\n\t0xc3effdfffffddfee, 0x300003ddf, 0xc3effdfffffddfec, 0x340003ddf,\n\t0xc3fffdfffffddfec, 0x300003dcf,\n\t0x38: 0x7fffffffffffffe, 0xc00ffff, 0x3bff6caefef02596, 0x30003f5f,\n\t0xc2a0000003000001, 0xfffe03fffffffeff, 0x2fe3ffffebf0fdf,\n\t0x42: 0xffffffff00000000, 0x7fffffffff003f,\n\t0x78: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffff0fffffff, 0x3ffffffffffffff,\n\t0xffffffff3f3fffff, 0x3fffffffaaff3f3f, 0x5fdfffffffffffff, 0x1fdc1fff0fcf1fdc,\n\t0x8000000000000000, 0x8000000000000001,\n\t0x84: 0x1fbfd503f2ffc84, 0xffffffff00000000, 0x7,\n\t0xc0: 0x3fe000000e0, 0xfffffffffffffffe, 0xfffffffe180fffff, 0x187fffffffffffff,\n\t0x1fffffffffe0,\n\t0x138: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0x3fffffffff,\n\t0x2b0: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xfffffffff,\n}\n"
  },
  {
    "path": "v2/AUTHORS",
    "content": "# This file lists authors for copyright purposes.  This file is distinct from\n# the CONTRIBUTORS files.  See the latter for an explanation.\n#\n# Names should be added to this file as:\n#     Name or Organization <email address>\n#\n# The email address is not required for organizations.\n#\n# Please keep the list sorted.\n\nDan Kortschak <dan.kortschak@adelaide.edu.au>\nJan Mercl <0xjnml@gmail.com>\nMaxim Kupriianov <max@kc.vc>\nPeter Waller <p@pwaller.net>\nSteffen Butzer <steffen(dot)butzer@outlook.com>\nYasuhiro Matsumoto <mattn.jp@gmail.com>\n"
  },
  {
    "path": "v2/CONTRIBUTORS",
    "content": "# This file lists people who contributed code to this repository.  The AUTHORS\n# file lists the copyright holders; this file lists people.\n#\n# Names should be added to this file like so:\n#     Name <email address>\n#\n# Please keep the list sorted.\n\nDan Kortschak <dan.kortschak@adelaide.edu.au>\nJan Mercl <0xjnml@gmail.com>\nMaxim Kupriianov <max@kc.vc>\nPeter Waller <p@pwaller.net>\nSteffen Butzer <steffen(dot)butzer@outlook.com>\nYasuhiro Matsumoto <mattn.jp@gmail.com>\nZvi Effron <zeffron@cs.hmc.edu>\n"
  },
  {
    "path": "v2/LICENSE",
    "content": "Copyright (c) 2017 The CC Authors. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n   * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n   * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n   * Neither the names of the authors nor the names of the\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "v2/Makefile",
    "content": "# Copyright 2017 The CC Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style\n# license that can be found in the LICENSE file.\n\n.PHONY:\tall clean cover cpu editor internalError later mem nuke todo edit\n\ngrep=--include=*.go --include=*.l --include=*.y --include=*.yy\nngrep='TODOOK\\|parser\\.go\\|scanner\\.go\\|trigraphs\\.go\\|.*_string\\.go'\n\nall: editor\n\tgo vet 2>&1 | grep -v $(ngrep) || true\n\tgolint 2>&1 | grep -v $(ngrep) || true\n\tmake todo\n\tunused . || true\n\tmisspell *.go\n\tgosimple || true\n\tmaligned || true\n\tunconvert -apply\n\nclean:\n\tgo clean\n\trm -f *~ *.test *.out\n\ncover:\n\tt=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t\n\ncpu: clean\n\tgo test -run @ -bench . -cpuprofile cpu.out\n\tgo tool pprof -lines *.test cpu.out\n\nedit:\n\ttouch log\n\tgvim -p Makefile *.l *.yy *_test.go log ast2.go cc.go cpp.go encoding.go enum.go etc.go lexer.go model.go operand.go type.go\n\neditor: ast.go parser.go scanner.go trigraphs.go stringer.go\n\tgofmt -l -s -w *.go\n\tGOOS=linux GOARCH=arm go build\n\tGOOS=linux GOARCH=386 go build\n\tGOOS=linux GOARCH=amd64 go build\n\tGOOS=windows GOARCH=386 go build\n\tGOOS=windows GOARCH=amd64 go build\n\tgo test -i\n\tgo test -short 2>&1 | tee log\n\tsleep 1\n\tgo install\n\ninternalError:\n\tegrep -ho '\"internal error.*\"' *.go | sort | cat -n\n\nlater:\n\t@grep -n $(grep) LATER * || true\n\t@grep -n $(grep) MAYBE * || true\n\nmem: clean\n\tgo test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h\n\tgo tool pprof -lines -web -alloc_space *.test mem.out\n\nnuke: clean\n\tgo clean -i\n\ntodo:\n\t@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) TODO * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) BUG * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true\n\nast.go parser.go scanner.go trigraphs.go stringer.go: parser.yy scanner.l trigraphs.l enum.go\n\tgo generate\t\n"
  },
  {
    "path": "v2/README.md",
    "content": "# c99\n\nPackage CC is a C99 compiler front end. Work In Progress. API unstable.\n\nInstallation\n\n    $ go get github.com/cznic/cc/v2\n\nDocumentation: [godoc.org/github.com/cznic/cc/v2](http://godoc.org/github.com/cznic/cc/v2)\n"
  },
  {
    "path": "v2/all_test.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\nimport (\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n\t\"unicode\"\n\t\"unicode/utf8\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/xc\"\n)\n\nfunc caller(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(2)\n\tfmt.Fprintf(os.Stderr, \"# caller: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\t_, fn, fl, _ = runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"# \\tcallee: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc caller3(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(3)\n\tfmt.Fprintf(os.Stderr, \"# caller: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\t_, fn, fl, _ = runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"# \\tcallee: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc dbg(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"# dbg %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc TODO(...interface{}) string { //TODOOK\n\t_, fn, fl, _ := runtime.Caller(1)\n\treturn fmt.Sprintf(\"# TODO: %s:%d:\\n\", path.Base(fn), fl) //TODOOK\n}\n\nfunc use(...interface{}) {}\n\nfunc init() {\n\tuse(caller, caller3, dbg, TODO, toksDump) //TODOOK\n\tflag.IntVar(&yyDebug, \"yydebug\", 0, \"\")\n\tflag.BoolVar(&traceMacroDefs, \"macros\", false, \"\")\n}\n\n// ============================================================================\n\nvar (\n\toRE = flag.String(\"re\", \"\", \"\")\n\n\tshellc      = filepath.FromSlash(\"testdata/_sqlite/sqlite-amalgamation-3210000/shell.c\")\n\tsqlite3c    = filepath.FromSlash(\"testdata/_sqlite/sqlite-amalgamation-3210000/sqlite3.c\")\n\tsearchPaths []string\n)\n\nfunc init() {\n\tvar err error\n\tsearchPaths, err = Paths(true)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc testUCNTable(t *testing.T, tab []rune, fOk, fOther func(rune) bool, fcategory func(rune) bool, tag string) {\n\tm := map[rune]struct{}{}\n\tfor i := 0; i < len(tab); i += 2 {\n\t\tl, h := tab[i], tab[i+1]\n\t\tif h == 0 {\n\t\t\th = l\n\t\t}\n\t\tfor r := l; r <= h; r++ {\n\t\t\tm[r] = struct{}{}\n\t\t}\n\t}\n\tfor r := rune(0); r < 0xffff; r++ {\n\t\t_, ok := m[r]\n\t\tif g, e := fOk(r), ok; g != e {\n\t\t\tt.Errorf(\"%#04x %v %v\", r, g, e)\n\t\t}\n\n\t\tif ok {\n\t\t\tif g, e := fOther(r), false; g != e {\n\t\t\t\tt.Errorf(\"%#04x %v %v\", r, g, e)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestUCNDigitsTable(t *testing.T) {\n\ttab := []rune{\n\t\t0x0660, 0x0669, 0x06F0, 0x06F9, 0x0966, 0x096F, 0x09E6, 0x09EF, 0x0A66, 0x0A6F,\n\t\t0x0AE6, 0x0AEF, 0x0B66, 0x0B6F, 0x0BE7, 0x0BEF, 0x0C66, 0x0C6F, 0x0CE6, 0x0CEF,\n\t\t0x0D66, 0x0D6F, 0x0E50, 0x0E59, 0x0ED0, 0x0ED9, 0x0F20, 0x0F33,\n\t}\n\ttestUCNTable(t, tab, isUCNDigit, isUCNNonDigit, unicode.IsDigit, \"unicode.IsDigit\")\n}\n\nfunc TestUCNNonDigitsTable(t *testing.T) {\n\ttab := []rune{\n\t\t0x00AA, 0x0000, 0x00B5, 0x0000, 0x00B7, 0x0000, 0x00BA, 0x0000, 0x00C0, 0x00D6,\n\t\t0x00D8, 0x00F6, 0x00F8, 0x01F5, 0x01FA, 0x0217, 0x0250, 0x02A8, 0x02B0, 0x02B8,\n\t\t0x02BB, 0x0000, 0x02BD, 0x02C1, 0x02D0, 0x02D1, 0x02E0, 0x02E4, 0x037A, 0x0000,\n\t\t0x0386, 0x0000, 0x0388, 0x038A, 0x038C, 0x0000, 0x038E, 0x03A1, 0x03A3, 0x03CE,\n\t\t0x03D0, 0x03D6, 0x03DA, 0x0000, 0x03DC, 0x0000, 0x03DE, 0x0000, 0x03E0, 0x0000,\n\t\t0x03E2, 0x03F3, 0x0401, 0x040C, 0x040E, 0x044F, 0x0451, 0x045C, 0x045E, 0x0481,\n\t\t0x0490, 0x04C4, 0x04C7, 0x04C8, 0x04CB, 0x04CC, 0x04D0, 0x04EB, 0x04EE, 0x04F5,\n\t\t0x04F8, 0x04F9, 0x0531, 0x0556, 0x0559, 0x0000, 0x0561, 0x0587, 0x05B0, 0x05B9,\n\t\t0x05F0, 0x05F2, 0x0621, 0x063A, 0x0640, 0x0652, 0x0670, 0x06B7, 0x06BA, 0x06BE,\n\t\t0x06C0, 0x06CE, 0x06D0, 0x06DC, 0x06E5, 0x06E8, 0x06EA, 0x06ED, 0x0901, 0x0903,\n\t\t0x0905, 0x0939, 0x093D, 0x0000, 0x093E, 0x094D, 0x0950, 0x0952, 0x0958, 0x0963,\n\t\t0x0981, 0x0983, 0x0985, 0x098C, 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA, 0x09B0,\n\t\t0x09B2, 0x0000, 0x09B6, 0x09B9, 0x09BE, 0x09C4, 0x09C7, 0x09C8, 0x09CB, 0x09CD,\n\t\t0x09DC, 0x09DD, 0x09DF, 0x09E3, 0x09F0, 0x09F1, 0x0A02, 0x0000, 0x0A05, 0x0A0A,\n\t\t0x0A0F, 0x0A10, 0x0A13, 0x0A28, 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36,\n\t\t0x0A38, 0x0A39, 0x0A3E, 0x0A42, 0x0A47, 0x0A48, 0x0A4B, 0x0A4D, 0x0A59, 0x0A5C,\n\t\t0x0A5E, 0x0000, 0x0A74, 0x0000, 0x0A81, 0x0A83, 0x0A85, 0x0A8B, 0x0A8D, 0x0000,\n\t\t0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, 0x0AB5, 0x0AB9,\n\t\t0x0ABD, 0x0AC5, 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0AD0, 0x0000, 0x0AE0, 0x0000,\n\t\t0x0B01, 0x0B03, 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28, 0x0B2A, 0x0B30,\n\t\t0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B3D, 0x0000, 0x0B3E, 0x0B43, 0x0B47, 0x0B48,\n\t\t0x0B4B, 0x0B4D, 0x0B5C, 0x0B5D, 0x0B5F, 0x0B61, 0x0B82, 0x0B83, 0x0B85, 0x0B8A,\n\t\t0x0B8E, 0x0B90, 0x0B92, 0x0B95, 0x0B99, 0x0B9A, 0x0B9C, 0x0000, 0x0B9E, 0x0B9F,\n\t\t0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA, 0x0BAE, 0x0BB5, 0x0BB7, 0x0BB9, 0x0BBE, 0x0BC2,\n\t\t0x0BC6, 0x0BC8, 0x0BCA, 0x0BCD, 0x0C01, 0x0C03, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10,\n\t\t0x0C12, 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C3E, 0x0C44, 0x0C46, 0x0C48,\n\t\t0x0C4A, 0x0C4D, 0x0C60, 0x0C61, 0x0C82, 0x0C83, 0x0C85, 0x0C8C, 0x0C8E, 0x0C90,\n\t\t0x0C92, 0x0CA8, 0x0CAA, 0x0CB3, 0x0CB5, 0x0CB9, 0x0CBE, 0x0CC4, 0x0CC6, 0x0CC8,\n\t\t0x0CCA, 0x0CCD, 0x0CDE, 0x0000, 0x0CE0, 0x0CE1, 0x0D02, 0x0D03, 0x0D05, 0x0D0C,\n\t\t0x0D0E, 0x0D10, 0x0D12, 0x0D28, 0x0D2A, 0x0D39, 0x0D3E, 0x0D43, 0x0D46, 0x0D48,\n\t\t0x0D4A, 0x0D4D, 0x0D60, 0x0D61, 0x0E01, 0x0E3A,\n\n\t\t// In [0], Annex D, Thai [0x0E40, 0x0E5B] overlaps with digits\n\t\t// [0x0E50, 0x0E59]. Exclude them.\n\t\t0x0E40, 0x0E4F,\n\t\t0x0E5A, 0x0E5B,\n\n\t\t0x0E81, 0x0E82,\n\t\t0x0E84, 0x0000, 0x0E87, 0x0E88, 0x0E8A, 0x0000, 0x0E8D, 0x0000, 0x0E94, 0x0E97,\n\t\t0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EA5, 0x0000, 0x0EA7, 0x0000, 0x0EAA, 0x0EAB,\n\t\t0x0EAD, 0x0EAE, 0x0EB0, 0x0EB9, 0x0EBB, 0x0EBD, 0x0EC0, 0x0EC4, 0x0EC6, 0x0000,\n\t\t0x0EC8, 0x0ECD, 0x0EDC, 0x0EDD, 0x0F00, 0x0000, 0x0F18, 0x0F19, 0x0F35, 0x0000,\n\t\t0x0F37, 0x0000, 0x0F39, 0x0000, 0x0F3E, 0x0F47, 0x0F49, 0x0F69, 0x0F71, 0x0F84,\n\t\t0x0F86, 0x0F8B, 0x0F90, 0x0F95, 0x0F97, 0x0000, 0x0F99, 0x0FAD, 0x0FB1, 0x0FB7,\n\t\t0x0FB9, 0x0000, 0x10A0, 0x10C5, 0x10D0, 0x10F6, 0x1E00, 0x1E9B, 0x1EA0, 0x1EF9,\n\t\t0x1F00, 0x1F15, 0x1F18, 0x1F1D, 0x1F20, 0x1F45, 0x1F48, 0x1F4D, 0x1F50, 0x1F57,\n\t\t0x1F59, 0x0000, 0x1F5B, 0x0000, 0x1F5D, 0x0000, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4,\n\t\t0x1FB6, 0x1FBC, 0x1FBE, 0x0000, 0x1FC2, 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3,\n\t\t0x1FD6, 0x1FDB, 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC, 0x203F, 0x2040,\n\t\t0x207F, 0x0000, 0x2102, 0x0000, 0x2107, 0x0000, 0x210A, 0x2113, 0x2115, 0x0000,\n\t\t0x2118, 0x211D, 0x2124, 0x0000, 0x2126, 0x0000, 0x2128, 0x0000, 0x212A, 0x2131,\n\t\t0x2133, 0x2138, 0x2160, 0x2182, 0x3005, 0x3007, 0x3021, 0x3029, 0x3041, 0x3093,\n\t\t0x309B, 0x309C, 0x30A1, 0x30F6, 0x30FB, 0x30FC, 0x3105, 0x312C, 0x4E00, 0x9FA5,\n\t\t0xAC00, 0xD7A3,\n\t}\n\ttestUCNTable(t, tab, isUCNNonDigit, isUCNDigit, unicode.IsLetter, \"unicode.IsLetter\")\n}\n\nfunc charStr(c rune) string { return yySymName(int(c)) }\n\nfunc charsStr(chars []lex.Char, delta token.Pos) (a []string) {\n\tfor _, v := range chars {\n\t\ta = append(a, fmt.Sprintf(\"{%s %d}\", charStr(v.Rune), v.Pos()-delta))\n\t}\n\treturn a\n}\n\ntype x []struct {\n\tc   rune\n\tpos token.Pos\n}\n\ntype lexerTests []struct {\n\tsrc   string\n\tchars x\n}\n\nfunc testLexer(t *testing.T, newLexer func(i int, src string) (*lexer, error), tab lexerTests) {\nnextTest:\n\tfor ti, test := range tab {\n\t\tlx, err := newLexer(ti, test.src)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tdelta := token.Pos(lx.File.Base() - 1)\n\t\tvar chars []lex.Char\n\t\tvar c lex.Char\n\t\tvar lval yySymType\n\t\tfor i := 0; c.Rune >= 0 && i < len(test.src)+2; i++ {\n\t\t\tlx.Lex(&lval)\n\t\t\tc = lval.Token.Char\n\t\t\tchars = append(chars, c)\n\t\t}\n\t\tif c.Rune >= 0 {\n\t\t\tt.Errorf(\"%d: scanner stall %v\", ti, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tif g, e := lx.error(), error(nil); g != e {\n\t\t\tt.Errorf(\"%d: lx.err %v %v %v\", ti, g, e, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tif g, e := len(chars), len(test.chars); g != e {\n\t\t\tt.Errorf(\"%d: len(chars) %v %v %v\", ti, g, e, charsStr(chars, delta))\n\t\t\tcontinue\n\t\t}\n\n\t\tfor i, c := range chars {\n\t\t\tc = chars[i]\n\t\t\te := test.chars[i]\n\t\t\tg := c.Rune\n\t\t\tif e := e.c; g != e {\n\t\t\t\tt.Errorf(\"%d: c[%d] %v %v %v\", ti, i, charStr(g), charStr(e), charsStr(chars, delta))\n\t\t\t\tcontinue nextTest\n\t\t\t}\n\n\t\t\tif g, e := c.Pos()-delta, e.pos; g != e {\n\t\t\t\tt.Errorf(\"%d: pos[%d] %v %v %v\", ti, i, g, e, charsStr(chars, delta))\n\t\t\t\tcontinue nextTest\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc TestLexer(t *testing.T) {\n\tctx, err := newContext(&Tweaks{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttestLexer(\n\t\tt,\n\t\tfunc(i int, src string) (*lexer, error) {\n\t\t\treturn newLexer(ctx, fmt.Sprintf(\"TestLexer.%d\", i), len(src), strings.NewReader(src))\n\t\t},\n\t\tlexerTests{\n\t\t\t{\"\", x{{-1, 1}}},\n\t\t\t{\"%0\", x{{'%', 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"%:%:\", x{{PPPASTE, 1}, {-1, 5}}},\n\t\t\t{\"%>\", x{{'}', 1}, {-1, 3}}},\n\t\t\t{\"0\", x{{INTCONST, 1}, {-1, 2}}},\n\t\t\t{\"01\", x{{INTCONST, 1}, {-1, 3}}},\n\t\t\t{\"0??/1\\n\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {INTCONST, 5}, {'\\n', 6}, {-1, 7}}},\n\t\t\t{\"0??/1\\n2\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {INTCONST, 5}, {'\\n', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"0??/\\n\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"0??/\\n2\", x{{INTCONST, 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"0\\\\1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"0\\\\1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"0\\\\\\n\", x{{INTCONST, 1}, {-1, 4}}},\n\t\t\t{\"0\\\\\\n2\", x{{INTCONST, 1}, {-1, 5}}},\n\t\t\t{\"0\\x00\", x{{INTCONST, 1}, {0, 2}, {-1, 3}}},\n\t\t\t{\"0\\x001\", x{{INTCONST, 1}, {0, 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\":>\", x{{']', 1}, {-1, 3}}},\n\t\t\t{\"<%\", x{{'{', 1}, {-1, 3}}},\n\t\t\t{\"<:\", x{{'[', 1}, {-1, 3}}},\n\t\t\t{\"??!\", x{{'?', 1}, {'?', 2}, {'!', 3}, {-1, 4}}},\n\t\t\t{\"??!0\", x{{'?', 1}, {'?', 2}, {'!', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"??!01\", x{{'?', 1}, {'?', 2}, {'!', 3}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"??!=\", x{{'?', 1}, {'?', 2}, {NEQ, 3}, {-1, 5}}},\n\t\t\t{\"??'\", x{{'?', 1}, {'?', 2}, {'\\'', 3}, {-1, 4}}},\n\t\t\t{\"??(\", x{{'?', 1}, {'?', 2}, {'(', 3}, {-1, 4}}},\n\t\t\t{\"??)\", x{{'?', 1}, {'?', 2}, {')', 3}, {-1, 4}}},\n\t\t\t{\"??-\", x{{'?', 1}, {'?', 2}, {'-', 3}, {-1, 4}}},\n\t\t\t{\"??/\", x{{'?', 1}, {'?', 2}, {'/', 3}, {-1, 4}}},\n\t\t\t{\"??/1\\n\", x{{'?', 1}, {'?', 2}, {'/', 3}, {INTCONST, 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"??/1\\n2\", x{{'?', 1}, {'?', 2}, {'/', 3}, {INTCONST, 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"??/\\n\", x{{'?', 1}, {'?', 2}, {'/', 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"??/\\n2\", x{{'?', 1}, {'?', 2}, {'/', 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"??<\", x{{'?', 1}, {'?', 2}, {'<', 3}, {-1, 4}}},\n\t\t\t{\"??=??=\", x{{'?', 1}, {'?', 2}, {'=', 3}, {'?', 4}, {'?', 5}, {'=', 6}, {-1, 7}}},\n\t\t\t{\"??>\", x{{'?', 1}, {'?', 2}, {'>', 3}, {-1, 4}}},\n\t\t\t{\"???!\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'!', 4}, {-1, 5}}},\n\t\t\t{\"???!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'!', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"???/\\n2\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'/', 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"????!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {'?', 4}, {'!', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"???x0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {-1, 6}}},\n\t\t\t{\"???x??!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {'?', 5}, {'?', 6}, {'!', 7}, {INTCONST, 8}, {-1, 9}}},\n\t\t\t{\"??x0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {-1, 5}}},\n\t\t\t{\"??x??!0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {'?', 4}, {'?', 5}, {'!', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"?x0\", x{{'?', 1}, {IDENTIFIER, 2}, {-1, 4}}},\n\t\t\t{\"?x??!0\", x{{'?', 1}, {IDENTIFIER, 2}, {'?', 3}, {'?', 4}, {'!', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"@\", x{{'@', 1}, {-1, 2}}},\n\t\t\t{\"@%\", x{{'@', 1}, {'%', 2}, {-1, 3}}},\n\t\t\t{\"@%0\", x{{'@', 1}, {'%', 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"@%:\", x{{'@', 1}, {'#', 2}, {-1, 4}}},\n\t\t\t{\"@%:0\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"@%:01\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"@??=\", x{{'@', 1}, {'?', 2}, {'?', 3}, {'=', 4}, {-1, 5}}},\n\t\t\t{\"\\\"(a\\\\\\nz\", x{{'\"', 1}, {'(', 2}, {IDENTIFIER, 3}, {-1, 7}}},\n\t\t\t{\"\\\\1\\n\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {-1, 4}}},\n\t\t\t{\"\\\\1\\n2\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\\\\\n\", x{{-1, 3}}},\n\t\t\t{\"\\\\\\n2\", x{{INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"\\\\\\r\\n\", x{{-1, 4}}},\n\t\t\t{\"\\\\\\r\\n2\", x{{INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\r\", x{{-1, 2}}},\n\t\t\t{\"\\r0\", x{{INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"\\r01\", x{{INTCONST, 2}, {-1, 4}}},\n\t\t\t{\"\\x00\", x{{0, 1}, {-1, 2}}},\n\t\t\t{\"\\x000\", x{{0, 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t},\n\t)\n}\n\nfunc TestLexerTrigraphs(t *testing.T) {\n\tctx, err := newContext(&Tweaks{EnableTrigraphs: true})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\ttestLexer(\n\t\tt,\n\t\tfunc(i int, src string) (*lexer, error) {\n\t\t\treturn newLexer(ctx, fmt.Sprintf(\"TestLexer.%d\", i), len(src), strings.NewReader(src))\n\t\t},\n\t\tlexerTests{\n\t\t\t{\"\", x{{-1, 1}}},\n\t\t\t{\"%0\", x{{'%', 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"%:%:\", x{{PPPASTE, 1}, {-1, 5}}},\n\t\t\t{\"%>\", x{{'}', 1}, {-1, 3}}},\n\t\t\t{\"0\", x{{INTCONST, 1}, {-1, 2}}},\n\t\t\t{\"01\", x{{INTCONST, 1}, {-1, 3}}},\n\t\t\t{\"0??/1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 5}, {'\\n', 6}, {-1, 7}}},\n\t\t\t{\"0??/1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 5}, {'\\n', 6}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"0??/\\n\", x{{INTCONST, 1}, {-1, 6}}},\n\t\t\t{\"0??/\\n2\", x{{INTCONST, 1}, {-1, 7}}},\n\t\t\t{\"0\\\\1\\n\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {-1, 5}}},\n\t\t\t{\"0\\\\1\\n2\", x{{INTCONST, 1}, {'\\\\', 2}, {INTCONST, 3}, {'\\n', 4}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"0\\\\\\n\", x{{INTCONST, 1}, {-1, 4}}},\n\t\t\t{\"0\\\\\\n2\", x{{INTCONST, 1}, {-1, 5}}},\n\t\t\t{\"0\\x00\", x{{INTCONST, 1}, {0, 2}, {-1, 3}}},\n\t\t\t{\"0\\x001\", x{{INTCONST, 1}, {0, 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\":>\", x{{']', 1}, {-1, 3}}},\n\t\t\t{\"<%\", x{{'{', 1}, {-1, 3}}},\n\t\t\t{\"<:\", x{{'[', 1}, {-1, 3}}},\n\t\t\t{\"??!\", x{{'|', 1}, {-1, 4}}},\n\t\t\t{\"??!0\", x{{'|', 1}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"??!01\", x{{'|', 1}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"??!=\", x{{ORASSIGN, 1}, {-1, 5}}},\n\t\t\t{\"??'\", x{{'^', 1}, {-1, 4}}},\n\t\t\t{\"??(\", x{{'[', 1}, {-1, 4}}},\n\t\t\t{\"??)\", x{{']', 1}, {-1, 4}}},\n\t\t\t{\"??-\", x{{'~', 1}, {-1, 4}}},\n\t\t\t{\"??/\", x{{'\\\\', 1}, {-1, 4}}},\n\t\t\t{\"??/1\\n\", x{{'\\\\', 1}, {INTCONST, 4}, {'\\n', 5}, {-1, 6}}},\n\t\t\t{\"??/1\\n2\", x{{'\\\\', 1}, {INTCONST, 4}, {'\\n', 5}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"??/\\n\", x{{-1, 5}}},\n\t\t\t{\"??/\\n2\", x{{INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"??<\", x{{'{', 1}, {-1, 4}}},\n\t\t\t{\"??=??=\", x{{PPPASTE, 1}, {-1, 7}}},\n\t\t\t{\"??>\", x{{'}', 1}, {-1, 4}}},\n\t\t\t{\"???!\", x{{'?', 1}, {'|', 2}, {-1, 5}}},\n\t\t\t{\"???!0\", x{{'?', 1}, {'|', 2}, {INTCONST, 5}, {-1, 6}}},\n\t\t\t{\"???/\\n2\", x{{'?', 1}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"????!0\", x{{'?', 1}, {'?', 2}, {'|', 3}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"???x0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {-1, 6}}},\n\t\t\t{\"???x??!0\", x{{'?', 1}, {'?', 2}, {'?', 3}, {IDENTIFIER, 4}, {'|', 5}, {INTCONST, 8}, {-1, 9}}},\n\t\t\t{\"??x0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {-1, 5}}},\n\t\t\t{\"??x??!0\", x{{'?', 1}, {'?', 2}, {IDENTIFIER, 3}, {'|', 4}, {INTCONST, 7}, {-1, 8}}},\n\t\t\t{\"?x0\", x{{'?', 1}, {IDENTIFIER, 2}, {-1, 4}}},\n\t\t\t{\"?x??!0\", x{{'?', 1}, {IDENTIFIER, 2}, {'|', 3}, {INTCONST, 6}, {-1, 7}}},\n\t\t\t{\"@\", x{{'@', 1}, {-1, 2}}},\n\t\t\t{\"@%\", x{{'@', 1}, {'%', 2}, {-1, 3}}},\n\t\t\t{\"@%0\", x{{'@', 1}, {'%', 2}, {INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"@%:\", x{{'@', 1}, {'#', 2}, {-1, 4}}},\n\t\t\t{\"@%:0\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"@%:01\", x{{'@', 1}, {'#', 2}, {INTCONST, 4}, {-1, 6}}},\n\t\t\t{\"@??=\", x{{'@', 1}, {'#', 2}, {-1, 5}}},\n\t\t\t{\"\\\"(a\\\\\\nz\", x{{'\"', 1}, {'(', 2}, {IDENTIFIER, 3}, {-1, 7}}},\n\t\t\t{\"\\\\1\\n\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {-1, 4}}},\n\t\t\t{\"\\\\1\\n2\", x{{'\\\\', 1}, {INTCONST, 2}, {'\\n', 3}, {INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\\\\\n\", x{{-1, 3}}},\n\t\t\t{\"\\\\\\n2\", x{{INTCONST, 3}, {-1, 4}}},\n\t\t\t{\"\\\\\\r\\n\", x{{-1, 4}}},\n\t\t\t{\"\\\\\\r\\n2\", x{{INTCONST, 4}, {-1, 5}}},\n\t\t\t{\"\\r\", x{{-1, 2}}},\n\t\t\t{\"\\r0\", x{{INTCONST, 2}, {-1, 3}}},\n\t\t\t{\"\\r01\", x{{INTCONST, 2}, {-1, 4}}},\n\t\t\t{\"\\x00\", x{{0, 1}, {-1, 2}}},\n\t\t\t{\"\\x000\", x{{0, 1}, {INTCONST, 2}, {-1, 3}}},\n\t\t},\n\t)\n}\n\nfunc exampleAST(rule int, src string) interface{} {\n\tctx, err := newContext(&Tweaks{\n\t\tEnableAnonymousStructFields: true,\n\t\tEnableEmptyStructs:          true,\n\t\tEnableOmitFuncDeclSpec:      true,\n\t})\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"TODO: %v\", err) //TODOOK\n\t}\n\n\tctx.exampleRule = rule\n\tsrc = strings.TrimSpace(src)\n\tr, n := utf8.DecodeRuneInString(src)\n\tsrc = src[n:]\n\tl, err := newLexer(ctx, fmt.Sprintf(\"example%v.c\", rule), len(src), strings.NewReader(src))\n\tif err != nil {\n\t\treturn fmt.Sprintf(\"TODO: %v\", err) //TODOOK\n\t}\n\n\tl.unget(cppToken{Token: xc.Token{Char: lex.Char{Rune: r}}})\n\tyyParse(l)\n\tif err := ctx.error(); err != nil {\n\t\treturn fmt.Sprintf(\"TODO: %v\", err) //TODOOK\n\t}\n\n\tif ctx.exampleAST == nil {\n\t\treturn \"TODO: nil\" //TODOOK\n\t}\n\n\treturn ctx.exampleAST\n}\n\nfunc testCPPParseSource(ctx *context, src Source) (*cpp, tokenReader, error) {\n\tif ctx == nil {\n\t\tvar err error\n\t\tif ctx, err = newContext(&Tweaks{}); err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\tc := newCPP(ctx)\n\tr, err := c.parse(src)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn c, r, nil\n}\n\nfunc testCPPParseFile(ctx *context, nm string) (*cpp, tokenReader, error) {\n\treturn testCPPParseSource(ctx, MustFileSource(nm))\n}\n\nfunc testCPPParseString(ctx *context, name, src string) (*cpp, tokenReader, error) {\n\treturn testCPPParseSource(ctx, NewStringSource(name, src))\n}\n\nfunc TestCPPParse0(t *testing.T) {\n\tctx, err := newContext(&Tweaks{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tfor i, v := range []string{\n\t\t\"\",\n\t\t\"\\n\",\n\t\t\"foo\\n\",\n\t\t`#if 1\n#endif\n`,\n\t\t`#if 1\n# /* foo */\n#endif\n`,\n\t} {\n\t\tif _, _, err := testCPPParseString(ctx, \"test\", v); err != nil {\n\t\t\tt.Error(i, err)\n\t\t}\n\t}\n}\n\nfunc TestCPPExpand(t *testing.T) {\n\tvar re *regexp.Regexp\n\tif s := *oRE; s != \"\" {\n\t\tre = regexp.MustCompile(s)\n\t}\n\n\tmodel, err := NewModel()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif err := filepath.Walk(filepath.FromSlash(\"testdata/cpp-expand/\"), func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif info.IsDir() || (!strings.HasSuffix(path, \".c\") && !strings.HasSuffix(path, \".h\")) {\n\t\t\treturn nil\n\t\t}\n\n\t\tif re != nil && !re.MatchString(path) {\n\t\t\treturn nil\n\t\t}\n\n\t\tt.Log(path)\n\t\tctx, err := newContext(&Tweaks{\n\t\t\tcppExpandTest: true,\n\t\t})\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tctx.model = model\n\t\tb, err := ioutil.ReadFile(path)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tc, r, err := testCPPParseFile(ctx, path)\n\t\tif err != nil {\n\t\t\tt.Fatal(ErrString(err))\n\t\t}\n\n\t\tvar tb tokenBuffer\n\t\tif err := c.eval(r, &tb); err != nil {\n\t\t\tt.Fatal(ErrString(err))\n\t\t}\n\n\t\tswitch {\n\t\tcase strings.Contains(filepath.ToSlash(path), \"/mustfail/\"):\n\t\t\terr := c.error()\n\t\t\tif err != nil {\n\t\t\t\tt.Logf(ErrString(err))\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tt.Fatalf(\"unexpected success: %s\", path)\n\t\tdefault:\n\t\t\tif err := c.error(); err != nil {\n\t\t\t\tt.Fatal(ErrString(err))\n\t\t\t}\n\t\t}\n\n\t\tvar a []string\n\t\tfor {\n\t\t\tt := tb.read()\n\t\t\tif t.Rune == ccEOF {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ta = append(a, TokSrc(t.Token))\n\t\t}\n\t\ts := strings.Join(a, \"\")\n\t\texp, err := ioutil.ReadFile(path + \".expect\")\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tif g, e := s, string(exp); g != e {\n\t\t\tt.Errorf(\"\\n---- src %s\\n%s---- got\\n%s---- exp %s\\n%s\", path, b, g, path+\".expect\", e)\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\nfunc (b *tokenBuffer) WriteTo(fset *token.FileSet, w io.Writer) {\n\tvar lpos token.Position\n\tfor {\n\t\tt := b.read()\n\t\tif t.Rune == ccEOF {\n\t\t\treturn\n\t\t}\n\n\t\tpos := fset.Position(t.Pos())\n\t\tif pos.Filename != lpos.Filename {\n\t\t\tfmt.Fprintf(w, \"# %d %v\\n\", pos.Line, pos.Filename)\n\t\t}\n\t\tlpos = pos\n\t\tw.Write([]byte(TokSrc(t.Token)))\n\t}\n}\n\nfunc (b *tokenBuffer) Bytes(fset *token.FileSet) []byte {\n\tvar buf bytes.Buffer\n\tb.WriteTo(fset, &buf)\n\treturn buf.Bytes()\n}\n\nfunc TestPreprocessSQLite(t *testing.T) {\n\tmodel, err := NewModel()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx, err := newContext(&Tweaks{})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx.model = model\n\tcpp := newCPP(ctx)\n\tcpp.includePaths = []string{\"@\"}\n\tcpp.sysIncludePaths = searchPaths\n\tr, err := cpp.parse(MustBuiltin(), MustFileSource(sqlite3c))\n\tif err != nil {\n\t\tt.Fatalf(\"%v: %v\", sqlite3c, err)\n\t}\n\n\tvar w tokenBuffer\n\tif err := cpp.eval(r, &w); err != nil {\n\t\tt.Fatalf(\"%v: %v\", sqlite3c, ErrString(err))\n\t}\n\n\tif err := cpp.error(); err != nil {\n\t\tt.Fatalf(\"%v: %v\", sqlite3c, ErrString(err))\n\t}\n\n\tif n := len(cpp.lx.ungetBuffer); n != 0 {\n\t\tt.Fatal(n)\n\t}\n}\n\nfunc TestParseSQLite(t *testing.T) {\n\tmodel, err := NewModel()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx, err := newContext(&Tweaks{\n\t\tEnableAnonymousStructFields: true,\n\t\tEnableEmptyStructs:          true,\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx.model = model\n\tctx.includePaths = []string{\"@\"}\n\tctx.sysIncludePaths = searchPaths\n\tif _, err := ctx.parse([]Source{MustBuiltin(), MustFileSource(sqlite3c)}); err != nil {\n\t\tdbg(\"%T %v\", err, PrettyString(err))\n\t\tt.Fatalf(\"%v\", ErrString(err))\n\t}\n}\n\nfunc TestFunc(t *testing.T) {\n\tmodel, err := NewModel()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx, err := newContext(&Tweaks{InjectFinalNL: true})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tctx.model = model\n\ttu, err := ctx.parse(\n\t\t[]Source{NewStringSource(\"testfunc.c\", `int (*foo(char bar))(double baz){}`)},\n\t)\n\tif err != nil {\n\t\tt.Fatalf(\"%v\", ErrString(err))\n\t}\n\n\tif err := tu.ExternalDeclarationList.check(ctx); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif err := ctx.error(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tfileScope := ctx.scope\n\tn := fileScope.LookupIdent(dict.SID(\"foo\"))\n\td, ok := n.(*Declarator)\n\tif !ok {\n\t\tt.Fatalf(\"%T\", n)\n\t}\n\n\tfd := d\n\tif g, e := d.Type.String(), \"function (char) returning pointer to function (double) returning int\"; g != e {\n\t\tt.Fatalf(\"got %q\\nexp %q\", g, e)\n\t}\n\n\tif g, e := fmt.Sprint(d.Type.(*FunctionType).Params), \"[char]\"; g != e {\n\t\tt.Fatalf(\"got %q\\nexp %q\", g, e)\n\t}\n\n\tfnScope := tu.ExternalDeclarationList.ExternalDeclaration.FunctionDefinition.FunctionBody.CompoundStmt.scope\n\tn = fnScope.LookupIdent(dict.SID(\"bar\"))\n\tif d, ok = n.(*Declarator); !ok {\n\t\tt.Fatalf(\"%T\", n)\n\t}\n\n\tif g, e := fmt.Sprint(d.Type), \"char\"; g != e {\n\t\tt.Fatalf(\"got %q\\nexp %q\", g, e)\n\t}\n\n\tnames := fd.ParameterNames()\n\tif g, e := len(names), 1; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := names[0], dict.SID(\"bar\"); g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tparams := fd.Parameters\n\tif g, e := len(params), 1; g != e {\n\t\tt.Fatal(g, e)\n\t}\n\n\tif g, e := params[0].Name(), dict.SID(\"bar\"); g != e {\n\t\tt.Fatal(g, e)\n\t}\n}\n\nfunc TestTypecheckSQLite(t *testing.T) {\n\tif _, err := Translate(\n\t\t&Tweaks{\n\t\t\tEnableAnonymousStructFields: true,\n\t\t\tEnableEmptyStructs:          true,\n\t\t},\n\t\t[]string{\"@\"},\n\t\tsearchPaths,\n\t\tMustBuiltin(),\n\t\tMustFileSource(sqlite3c),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\nfunc TestTypecheckSQLiteShell(t *testing.T) {\n\tif _, err := Translate(\n\t\t&Tweaks{\n\t\t\tEnableAnonymousStructFields: true,\n\t\t\tEnableEmptyStructs:          true,\n\t\t},\n\t\t[]string{\"@\"},\n\t\tsearchPaths,\n\t\tMustBuiltin(),\n\t\tMustCrt0(),\n\t\tMustFileSource(shellc),\n\t); err != nil {\n\t\tt.Fatal(err)\n\t}\n}\n\nfunc TestTypecheckTCCTests(t *testing.T) {\n\tblacklist := map[string]struct{}{\n\t\t\"34_array_assignment.c\": {}, // gcc: main.c:16:6: error: incompatible types when assigning to type ‘int[4]’ from type ‘int *’\n\t\t\"46_grep.c\":             {}, // gcc: 46_grep.c:489:12: error: ‘documentation’ undeclared (first use in this function)\n\t}\n\tm, err := filepath.Glob(\"testdata/tcc-0.9.26/tests/tests2/*.c\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tfor _, pth := range m {\n\t\tif _, ok := blacklist[filepath.Base(pth)]; ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tif _, err := Translate(\n\t\t\t&Tweaks{\n\t\t\t\tEnableBinaryLiterals:        true,\n\t\t\t\tEnableEmptyStructs:          true,\n\t\t\t\tEnableImplicitDeclarations:  true,\n\t\t\t\tEnableReturnExprInVoidFunc:  true,\n\t\t\t\tEnableAnonymousStructFields: true,\n\t\t\t},\n\t\t\t[]string{\"@\"},\n\t\t\tsearchPaths,\n\t\t\tMustBuiltin(),\n\t\t\tMustCrt0(),\n\t\t\tMustFileSource(pth),\n\t\t); err != nil {\n\t\t\tt.Fatal(ErrString(err))\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "v2/ast.go",
    "content": "// Code generated by yy. DO NOT EDIT.\n\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\t\"github.com/cznic/xc\"\n\t\"go/token\"\n)\n\n// AbstractDeclaratorCase represents case numbers of production AbstractDeclarator\ntype AbstractDeclaratorCase int\n\n// Values of type AbstractDeclaratorCase\nconst (\n\tAbstractDeclaratorPointer AbstractDeclaratorCase = iota\n\tAbstractDeclaratorAbstract\n)\n\n// String implements fmt.Stringer\nfunc (n AbstractDeclaratorCase) String() string {\n\tswitch n {\n\tcase AbstractDeclaratorPointer:\n\t\treturn \"AbstractDeclaratorPointer\"\n\tcase AbstractDeclaratorAbstract:\n\t\treturn \"AbstractDeclaratorAbstract\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"AbstractDeclaratorCase(%v)\", int(n))\n\t}\n}\n\n// AbstractDeclarator represents data reduced by productions:\n//\n//\tAbstractDeclarator:\n//\t        Pointer                              // Case AbstractDeclaratorPointer\n//\t|       PointerOpt DirectAbstractDeclarator  // Case AbstractDeclaratorAbstract\ntype AbstractDeclarator struct {\n\tDeclarationSpecifier     *DeclarationSpecifier\n\tType                     Type\n\tTypeQualifiers           []*TypeQualifier // From the PointerOpt production, if any.\n\tCase                     AbstractDeclaratorCase\n\tDirectAbstractDeclarator *DirectAbstractDeclarator\n\tPointer                  *Pointer\n\tPointerOpt               *PointerOpt\n}\n\nfunc (n *AbstractDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AbstractDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AbstractDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Pointer.Pos()\n\tcase 1:\n\t\tif p := n.PointerOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.DirectAbstractDeclarator.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// AbstractDeclaratorOpt represents data reduced by productions:\n//\n//\tAbstractDeclaratorOpt:\n//\t        /* empty */         // Case 0\n//\t|       AbstractDeclarator  // Case 1\ntype AbstractDeclaratorOpt struct {\n\tAbstractDeclarator *AbstractDeclarator\n}\n\nfunc (n *AbstractDeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *AbstractDeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *AbstractDeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.AbstractDeclarator.Pos()\n}\n\n// ArgumentExprList represents data reduced by productions:\n//\n//\tArgumentExprList:\n//\t        Expr                       // Case 0\n//\t|       ArgumentExprList ',' Expr  // Case 1\ntype ArgumentExprList struct {\n\tArgumentExprList *ArgumentExprList\n\tCase             int\n\tExpr             *Expr\n\tToken            xc.Token\n}\n\nfunc (n *ArgumentExprList) reverse() *ArgumentExprList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ArgumentExprList\n\tfor nb != nil {\n\t\tnc := nb.ArgumentExprList\n\t\tnb.ArgumentExprList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ArgumentExprList = nil\n\treturn na\n}\n\nfunc (n *ArgumentExprList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ArgumentExprList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ArgumentExprList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.ArgumentExprList.Pos()\n\tcase 0:\n\t\treturn n.Expr.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ArgumentExprListOpt represents data reduced by productions:\n//\n//\tArgumentExprListOpt:\n//\t        /* empty */       // Case 0\n//\t|       ArgumentExprList  // Case 1\ntype ArgumentExprListOpt struct {\n\tArgumentExprList *ArgumentExprList\n}\n\nfunc (n *ArgumentExprListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ArgumentExprListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ArgumentExprListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ArgumentExprList.Pos()\n}\n\n// BlockItemCase represents case numbers of production BlockItem\ntype BlockItemCase int\n\n// Values of type BlockItemCase\nconst (\n\tBlockItemDecl BlockItemCase = iota\n\tBlockItemStmt\n)\n\n// String implements fmt.Stringer\nfunc (n BlockItemCase) String() string {\n\tswitch n {\n\tcase BlockItemDecl:\n\t\treturn \"BlockItemDecl\"\n\tcase BlockItemStmt:\n\t\treturn \"BlockItemStmt\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"BlockItemCase(%v)\", int(n))\n\t}\n}\n\n// BlockItem represents data reduced by productions:\n//\n//\tBlockItem:\n//\t        Declaration  // Case BlockItemDecl\n//\t|       Stmt         // Case BlockItemStmt\ntype BlockItem struct {\n\tCase        BlockItemCase\n\tDeclaration *Declaration\n\tStmt        *Stmt\n}\n\nfunc (n *BlockItem) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItem) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItem) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declaration.Pos()\n\tcase 1:\n\t\treturn n.Stmt.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// BlockItemList represents data reduced by productions:\n//\n//\tBlockItemList:\n//\t        BlockItem                // Case 0\n//\t|       BlockItemList BlockItem  // Case 1\ntype BlockItemList struct {\n\tBlockItem     *BlockItem\n\tBlockItemList *BlockItemList\n\tCase          int\n}\n\nfunc (n *BlockItemList) reverse() *BlockItemList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.BlockItemList\n\tfor nb != nil {\n\t\tnc := nb.BlockItemList\n\t\tnb.BlockItemList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.BlockItemList = nil\n\treturn na\n}\n\nfunc (n *BlockItemList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItemList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItemList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.BlockItem.Pos()\n\tcase 1:\n\t\treturn n.BlockItemList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// BlockItemListOpt represents data reduced by productions:\n//\n//\tBlockItemListOpt:\n//\t        /* empty */    // Case 0\n//\t|       BlockItemList  // Case 1\ntype BlockItemListOpt struct {\n\tBlockItemList *BlockItemList\n}\n\nfunc (n *BlockItemListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *BlockItemListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *BlockItemListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.BlockItemList.Pos()\n}\n\n// CommaOpt represents data reduced by productions:\n//\n//\tCommaOpt:\n//\t        /* empty */  // Case 0\n//\t|       ','          // Case 1\ntype CommaOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *CommaOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *CommaOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *CommaOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// CompoundStmt represents data reduced by production:\n//\n//\tCompoundStmt:\n//\t        '{' BlockItemListOpt '}'  // Case 0\ntype CompoundStmt struct {\n\tscope            *Scope\n\tBlockItemListOpt *BlockItemListOpt\n\tToken            xc.Token\n\tToken2           xc.Token\n}\n\nfunc (n *CompoundStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *CompoundStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *CompoundStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ConstExpr represents data reduced by production:\n//\n//\tConstExpr:\n//\t        Expr  // Case 0\ntype ConstExpr struct {\n\tOperand Operand\n\tExpr    *Expr\n}\n\nfunc (n *ConstExpr) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ConstExpr) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ConstExpr) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Expr.Pos()\n}\n\n// Declaration represents data reduced by production:\n//\n//\tDeclaration:\n//\t        DeclarationSpecifiers InitDeclaratorListOpt ';'  // Case 0\ntype Declaration struct {\n\tAttributes            [][]xc.Token\n\tScope                 *Scope\n\tDeclarationSpecifiers *DeclarationSpecifiers\n\tInitDeclaratorListOpt *InitDeclaratorListOpt\n\tToken                 xc.Token\n}\n\nfunc (n *Declaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Declaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Declaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationSpecifiers.Pos()\n}\n\n// DeclarationList represents data reduced by productions:\n//\n//\tDeclarationList:\n//\t        Declaration                  // Case 0\n//\t|       DeclarationList Declaration  // Case 1\ntype DeclarationList struct {\n\tCase            int\n\tDeclaration     *Declaration\n\tDeclarationList *DeclarationList\n}\n\nfunc (n *DeclarationList) reverse() *DeclarationList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.DeclarationList\n\tfor nb != nil {\n\t\tnc := nb.DeclarationList\n\t\tnb.DeclarationList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.DeclarationList = nil\n\treturn na\n}\n\nfunc (n *DeclarationList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declaration.Pos()\n\tcase 1:\n\t\treturn n.DeclarationList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DeclarationListOpt represents data reduced by productions:\n//\n//\tDeclarationListOpt:\n//\t        /* empty */      // Case 0\n//\t|       DeclarationList  // Case 1\ntype DeclarationListOpt struct {\n\tDeclarationList *DeclarationList\n}\n\nfunc (n *DeclarationListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationList.Pos()\n}\n\n// DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers\ntype DeclarationSpecifiersCase int\n\n// Values of type DeclarationSpecifiersCase\nconst (\n\tDeclarationSpecifiersFunc DeclarationSpecifiersCase = iota\n\tDeclarationSpecifiersStorage\n\tDeclarationSpecifiersQualifier\n\tDeclarationSpecifiersSpecifier\n)\n\n// String implements fmt.Stringer\nfunc (n DeclarationSpecifiersCase) String() string {\n\tswitch n {\n\tcase DeclarationSpecifiersFunc:\n\t\treturn \"DeclarationSpecifiersFunc\"\n\tcase DeclarationSpecifiersStorage:\n\t\treturn \"DeclarationSpecifiersStorage\"\n\tcase DeclarationSpecifiersQualifier:\n\t\treturn \"DeclarationSpecifiersQualifier\"\n\tcase DeclarationSpecifiersSpecifier:\n\t\treturn \"DeclarationSpecifiersSpecifier\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"DeclarationSpecifiersCase(%v)\", int(n))\n\t}\n}\n\n// DeclarationSpecifiers represents data reduced by productions:\n//\n//\tDeclarationSpecifiers:\n//\t        FunctionSpecifier DeclarationSpecifiersOpt      // Case DeclarationSpecifiersFunc\n//\t|       StorageClassSpecifier DeclarationSpecifiersOpt  // Case DeclarationSpecifiersStorage\n//\t|       TypeQualifier DeclarationSpecifiersOpt          // Case DeclarationSpecifiersQualifier\n//\t|       TypeSpecifier DeclarationSpecifiersOpt          // Case DeclarationSpecifiersSpecifier\ntype DeclarationSpecifiers struct {\n\tCase                     DeclarationSpecifiersCase\n\tDeclarationSpecifiersOpt *DeclarationSpecifiersOpt\n\tFunctionSpecifier        *FunctionSpecifier\n\tStorageClassSpecifier    *StorageClassSpecifier\n\tTypeQualifier            *TypeQualifier\n\tTypeSpecifier            *TypeSpecifier\n}\n\nfunc (n *DeclarationSpecifiers) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationSpecifiers) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationSpecifiers) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.FunctionSpecifier.Pos()\n\tcase 1:\n\t\treturn n.StorageClassSpecifier.Pos()\n\tcase 2:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 3:\n\t\treturn n.TypeSpecifier.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DeclarationSpecifiersOpt represents data reduced by productions:\n//\n//\tDeclarationSpecifiersOpt:\n//\t        /* empty */            // Case 0\n//\t|       DeclarationSpecifiers  // Case 1\ntype DeclarationSpecifiersOpt struct {\n\tDeclarationSpecifiers *DeclarationSpecifiers\n}\n\nfunc (n *DeclarationSpecifiersOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclarationSpecifiersOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclarationSpecifiersOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationSpecifiers.Pos()\n}\n\n// Declarator represents data reduced by production:\n//\n//\tDeclarator:\n//\t        PointerOpt DirectDeclarator  // Case 0\ntype Declarator struct {\n\tAssignedTo           int // Declarator appears at the left side of assignment.\n\tAttributes           [][]xc.Token\n\tBits                 int                   // StructDeclarator: bit width when a bit field.\n\tDeclarationSpecifier *DeclarationSpecifier // Nil for embedded declarators.\n\tDefinition           *Declarator           // Declaration -> definition.\n\tField                int                   // Declaration order# if struct field declarator.\n\tFunctionDefinition   *FunctionDefinition   // When the declarator defines a function.\n\tInitializer          *Initializer          // Only when part of an InitDeclarator.\n\tLinkage              Linkage               // Linkage of the declared name, [0]6.2.2.\n\tParameters           []*Declarator         // Of the function declarator.\n\tReferenced           int\n\tScope                *Scope           // Declaration scope.\n\tScopeNum             int              // Sequential scope number within function body.\n\tStorageDuration      StorageDuration  // Storage duration of the declared name, [0]6.2.4.\n\tType                 Type             // Declared type.\n\tTypeQualifiers       []*TypeQualifier // From the PointerOpt production, if any.\n\tunnamed              int\n\tvars                 []*Declarator // Function declarator only.\n\tAddressTaken         bool\n\tAlloca               bool // Function declarator: Body calls __builtin_alloca\n\tEmbedded             bool // [0]6.7.5-3: Not a full declarator.\n\tIsField              bool\n\tIsFunctionParameter  bool\n\tIsBuiltin            bool\n\tDirectDeclarator     *DirectDeclarator\n\tPointerOpt           *PointerOpt\n}\n\nfunc (n *Declarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Declarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Declarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tif p := n.PointerOpt.Pos(); p != 0 {\n\t\treturn p\n\t}\n\n\treturn n.DirectDeclarator.Pos()\n}\n\n// DeclaratorOpt represents data reduced by productions:\n//\n//\tDeclaratorOpt:\n//\t        /* empty */  // Case 0\n//\t|       Declarator   // Case 1\ntype DeclaratorOpt struct {\n\tDeclarator *Declarator\n}\n\nfunc (n *DeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Declarator.Pos()\n}\n\n// Designation represents data reduced by production:\n//\n//\tDesignation:\n//\t        DesignatorList '='  // Case 0\ntype Designation struct {\n\tList           []int64\n\tDesignatorList *DesignatorList\n\tToken          xc.Token\n}\n\nfunc (n *Designation) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Designation) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Designation) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DesignatorList.Pos()\n}\n\n// DesignatorCase represents case numbers of production Designator\ntype DesignatorCase int\n\n// Values of type DesignatorCase\nconst (\n\tDesignatorField DesignatorCase = iota\n\tDesignatorIndex\n)\n\n// String implements fmt.Stringer\nfunc (n DesignatorCase) String() string {\n\tswitch n {\n\tcase DesignatorField:\n\t\treturn \"DesignatorField\"\n\tcase DesignatorIndex:\n\t\treturn \"DesignatorIndex\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"DesignatorCase(%v)\", int(n))\n\t}\n}\n\n// Designator represents data reduced by productions:\n//\n//\tDesignator:\n//\t        '.' IDENTIFIER     // Case DesignatorField\n//\t|       '[' ConstExpr ']'  // Case DesignatorIndex\ntype Designator struct {\n\tCase      DesignatorCase\n\tConstExpr *ConstExpr\n\tToken     xc.Token\n\tToken2    xc.Token\n}\n\nfunc (n *Designator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Designator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Designator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// DesignatorList represents data reduced by productions:\n//\n//\tDesignatorList:\n//\t        Designator                 // Case 0\n//\t|       DesignatorList Designator  // Case 1\ntype DesignatorList struct {\n\tCase           int\n\tDesignator     *Designator\n\tDesignatorList *DesignatorList\n}\n\nfunc (n *DesignatorList) reverse() *DesignatorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.DesignatorList\n\tfor nb != nil {\n\t\tnc := nb.DesignatorList\n\t\tnb.DesignatorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.DesignatorList = nil\n\treturn na\n}\n\nfunc (n *DesignatorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *DesignatorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DesignatorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Designator.Pos()\n\tcase 1:\n\t\treturn n.DesignatorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator\ntype DirectAbstractDeclaratorCase int\n\n// Values of type DirectAbstractDeclaratorCase\nconst (\n\tDirectAbstractDeclaratorAbstract DirectAbstractDeclaratorCase = iota\n\tDirectAbstractDeclaratorParamList\n\tDirectAbstractDeclaratorDFn\n\tDirectAbstractDeclaratorDArrSize\n\tDirectAbstractDeclaratorDArrVL\n\tDirectAbstractDeclaratorDArr\n\tDirectAbstractDeclaratorDArrSize2\n\tDirectAbstractDeclaratorDArr2\n)\n\n// String implements fmt.Stringer\nfunc (n DirectAbstractDeclaratorCase) String() string {\n\tswitch n {\n\tcase DirectAbstractDeclaratorAbstract:\n\t\treturn \"DirectAbstractDeclaratorAbstract\"\n\tcase DirectAbstractDeclaratorParamList:\n\t\treturn \"DirectAbstractDeclaratorParamList\"\n\tcase DirectAbstractDeclaratorDFn:\n\t\treturn \"DirectAbstractDeclaratorDFn\"\n\tcase DirectAbstractDeclaratorDArrSize:\n\t\treturn \"DirectAbstractDeclaratorDArrSize\"\n\tcase DirectAbstractDeclaratorDArrVL:\n\t\treturn \"DirectAbstractDeclaratorDArrVL\"\n\tcase DirectAbstractDeclaratorDArr:\n\t\treturn \"DirectAbstractDeclaratorDArr\"\n\tcase DirectAbstractDeclaratorDArrSize2:\n\t\treturn \"DirectAbstractDeclaratorDArrSize2\"\n\tcase DirectAbstractDeclaratorDArr2:\n\t\treturn \"DirectAbstractDeclaratorDArr2\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"DirectAbstractDeclaratorCase(%v)\", int(n))\n\t}\n}\n\n// DirectAbstractDeclarator represents data reduced by productions:\n//\n//\tDirectAbstractDeclarator:\n//\t        '(' AbstractDeclarator ')'                                              // Case DirectAbstractDeclaratorAbstract\n//\t|       '(' ParameterTypeListOpt ')'                                            // Case DirectAbstractDeclaratorParamList\n//\t|       DirectAbstractDeclarator '(' ParameterTypeListOpt ')'                   // Case DirectAbstractDeclaratorDFn\n//\t|       DirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expr ']'  // Case DirectAbstractDeclaratorDArrSize\n//\t|       DirectAbstractDeclaratorOpt '[' '*' ']'                                 // Case DirectAbstractDeclaratorDArrVL\n//\t|       DirectAbstractDeclaratorOpt '[' ExprOpt ']'                             // Case DirectAbstractDeclaratorDArr\n//\t|       DirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expr ']'     // Case DirectAbstractDeclaratorDArrSize2\n//\t|       DirectAbstractDeclaratorOpt '[' TypeQualifierList ExprOpt ']'           // Case DirectAbstractDeclaratorDArr2\ntype DirectAbstractDeclarator struct {\n\tAbstractDeclarator          *AbstractDeclarator\n\tCase                        DirectAbstractDeclaratorCase\n\tDirectAbstractDeclarator    *DirectAbstractDeclarator\n\tDirectAbstractDeclaratorOpt *DirectAbstractDeclaratorOpt\n\tExpr                        *Expr\n\tExprOpt                     *ExprOpt\n\tParameterTypeListOpt        *ParameterTypeListOpt\n\tToken                       xc.Token\n\tToken2                      xc.Token\n\tToken3                      xc.Token\n\tTypeQualifierList           *TypeQualifierList\n\tTypeQualifierListOpt        *TypeQualifierListOpt\n}\n\nfunc (n *DirectAbstractDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectAbstractDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectAbstractDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 2:\n\t\treturn n.DirectAbstractDeclarator.Pos()\n\tcase 3, 4, 5, 6, 7:\n\t\tif p := n.DirectAbstractDeclaratorOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tcase 0, 1:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// DirectAbstractDeclaratorOpt represents data reduced by productions:\n//\n//\tDirectAbstractDeclaratorOpt:\n//\t        /* empty */               // Case 0\n//\t|       DirectAbstractDeclarator  // Case 1\ntype DirectAbstractDeclaratorOpt struct {\n\tDirectAbstractDeclarator *DirectAbstractDeclarator\n}\n\nfunc (n *DirectAbstractDeclaratorOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectAbstractDeclaratorOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectAbstractDeclaratorOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DirectAbstractDeclarator.Pos()\n}\n\n// DirectDeclaratorCase represents case numbers of production DirectDeclarator\ntype DirectDeclaratorCase int\n\n// Values of type DirectDeclaratorCase\nconst (\n\tDirectDeclaratorParen DirectDeclaratorCase = iota\n\tDirectDeclaratorIdentList\n\tDirectDeclaratorParamList\n\tDirectDeclaratorArraySize\n\tDirectDeclaratorArraySize2\n\tDirectDeclaratorArrayVar\n\tDirectDeclaratorArray\n\tDirectDeclaratorIdent\n)\n\n// String implements fmt.Stringer\nfunc (n DirectDeclaratorCase) String() string {\n\tswitch n {\n\tcase DirectDeclaratorParen:\n\t\treturn \"DirectDeclaratorParen\"\n\tcase DirectDeclaratorIdentList:\n\t\treturn \"DirectDeclaratorIdentList\"\n\tcase DirectDeclaratorParamList:\n\t\treturn \"DirectDeclaratorParamList\"\n\tcase DirectDeclaratorArraySize:\n\t\treturn \"DirectDeclaratorArraySize\"\n\tcase DirectDeclaratorArraySize2:\n\t\treturn \"DirectDeclaratorArraySize2\"\n\tcase DirectDeclaratorArrayVar:\n\t\treturn \"DirectDeclaratorArrayVar\"\n\tcase DirectDeclaratorArray:\n\t\treturn \"DirectDeclaratorArray\"\n\tcase DirectDeclaratorIdent:\n\t\treturn \"DirectDeclaratorIdent\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"DirectDeclaratorCase(%v)\", int(n))\n\t}\n}\n\n// DirectDeclarator represents data reduced by productions:\n//\n//\tDirectDeclarator:\n//\t        '(' Declarator ')'                                           // Case DirectDeclaratorParen\n//\t|       DirectDeclarator '(' IdentifierListOpt ')'                   // Case DirectDeclaratorIdentList\n//\t|       DirectDeclarator '(' ParameterTypeList ')'                   // Case DirectDeclaratorParamList\n//\t|       DirectDeclarator '[' \"static\" TypeQualifierListOpt Expr ']'  // Case DirectDeclaratorArraySize\n//\t|       DirectDeclarator '[' TypeQualifierList \"static\" Expr ']'     // Case DirectDeclaratorArraySize2\n//\t|       DirectDeclarator '[' TypeQualifierListOpt '*' ']'            // Case DirectDeclaratorArrayVar\n//\t|       DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'        // Case DirectDeclaratorArray\n//\t|       IDENTIFIER                                                   // Case DirectDeclaratorIdent\ntype DirectDeclarator struct {\n\tparamScope           *Scope\n\tCase                 DirectDeclaratorCase\n\tDeclarator           *Declarator\n\tDirectDeclarator     *DirectDeclarator\n\tExpr                 *Expr\n\tExprOpt              *ExprOpt\n\tIdentifierListOpt    *IdentifierListOpt\n\tParameterTypeList    *ParameterTypeList\n\tToken                xc.Token\n\tToken2               xc.Token\n\tToken3               xc.Token\n\tTypeQualifierList    *TypeQualifierList\n\tTypeQualifierListOpt *TypeQualifierListOpt\n}\n\nfunc (n *DirectDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *DirectDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *DirectDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1, 2, 3, 4, 5, 6:\n\t\treturn n.DirectDeclarator.Pos()\n\tcase 0, 7:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// EnumSpecifierCase represents case numbers of production EnumSpecifier\ntype EnumSpecifierCase int\n\n// Values of type EnumSpecifierCase\nconst (\n\tEnumSpecifierTag EnumSpecifierCase = iota\n\tEnumSpecifierDefine\n)\n\n// String implements fmt.Stringer\nfunc (n EnumSpecifierCase) String() string {\n\tswitch n {\n\tcase EnumSpecifierTag:\n\t\treturn \"EnumSpecifierTag\"\n\tcase EnumSpecifierDefine:\n\t\treturn \"EnumSpecifierDefine\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"EnumSpecifierCase(%v)\", int(n))\n\t}\n}\n\n// EnumSpecifier represents data reduced by productions:\n//\n//\tEnumSpecifier:\n//\t        \"enum\" IDENTIFIER                                     // Case EnumSpecifierTag\n//\t|       \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'  // Case EnumSpecifierDefine\ntype EnumSpecifier struct {\n\tTag            int\n\tscope          *Scope // Where to declare enumeration constants.\n\ttyp            Type\n\tCase           EnumSpecifierCase\n\tCommaOpt       *CommaOpt\n\tEnumeratorList *EnumeratorList\n\tIdentifierOpt  *IdentifierOpt\n\tToken          xc.Token\n\tToken2         xc.Token\n\tToken3         xc.Token\n}\n\nfunc (n *EnumSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *EnumSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// EnumerationConstant represents data reduced by production:\n//\n//\tEnumerationConstant:\n//\t        IDENTIFIER  // Case 0\ntype EnumerationConstant struct {\n\tOperand Operand\n\tToken   xc.Token\n}\n\nfunc (n *EnumerationConstant) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *EnumerationConstant) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumerationConstant) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// EnumeratorCase represents case numbers of production Enumerator\ntype EnumeratorCase int\n\n// Values of type EnumeratorCase\nconst (\n\tEnumeratorBase EnumeratorCase = iota\n\tEnumeratorInit\n)\n\n// String implements fmt.Stringer\nfunc (n EnumeratorCase) String() string {\n\tswitch n {\n\tcase EnumeratorBase:\n\t\treturn \"EnumeratorBase\"\n\tcase EnumeratorInit:\n\t\treturn \"EnumeratorInit\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"EnumeratorCase(%v)\", int(n))\n\t}\n}\n\n// Enumerator represents data reduced by productions:\n//\n//\tEnumerator:\n//\t        EnumerationConstant                // Case EnumeratorBase\n//\t|       EnumerationConstant '=' ConstExpr  // Case EnumeratorInit\ntype Enumerator struct {\n\tCase                EnumeratorCase\n\tConstExpr           *ConstExpr\n\tEnumerationConstant *EnumerationConstant\n\tToken               xc.Token\n}\n\nfunc (n *Enumerator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Enumerator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Enumerator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.EnumerationConstant.Pos()\n}\n\n// EnumeratorList represents data reduced by productions:\n//\n//\tEnumeratorList:\n//\t        Enumerator                     // Case 0\n//\t|       EnumeratorList ',' Enumerator  // Case 1\ntype EnumeratorList struct {\n\tCase           int\n\tEnumerator     *Enumerator\n\tEnumeratorList *EnumeratorList\n\tToken          xc.Token\n}\n\nfunc (n *EnumeratorList) reverse() *EnumeratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.EnumeratorList\n\tfor nb != nil {\n\t\tnc := nb.EnumeratorList\n\t\tnb.EnumeratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.EnumeratorList = nil\n\treturn na\n}\n\nfunc (n *EnumeratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *EnumeratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *EnumeratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Enumerator.Pos()\n\tcase 1:\n\t\treturn n.EnumeratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExprCase represents case numbers of production Expr\ntype ExprCase int\n\n// Values of type ExprCase\nconst (\n\tExprPreInc ExprCase = iota\n\tExprPreDec\n\tExprAlignofType\n\tExprAlignofExpr\n\tExprSizeofType\n\tExprSizeofExpr\n\tExprNot\n\tExprAddrof\n\tExprStatement\n\tExprPExprList\n\tExprCompLit\n\tExprCast\n\tExprDeref\n\tExprUnaryPlus\n\tExprUnaryMinus\n\tExprCpl\n\tExprChar\n\tExprNe\n\tExprModAssign\n\tExprLAnd\n\tExprAndAssign\n\tExprMulAssign\n\tExprPostInc\n\tExprAddAssign\n\tExprPostDec\n\tExprSubAssign\n\tExprPSelect\n\tExprDivAssign\n\tExprLsh\n\tExprLshAssign\n\tExprLe\n\tExprEq\n\tExprGe\n\tExprRsh\n\tExprRshAssign\n\tExprXorAssign\n\tExprOrAssign\n\tExprLOr\n\tExprMod\n\tExprAnd\n\tExprCall\n\tExprMul\n\tExprAdd\n\tExprSub\n\tExprSelect\n\tExprDiv\n\tExprLt\n\tExprAssign\n\tExprGt\n\tExprCond\n\tExprIndex\n\tExprXor\n\tExprOr\n\tExprFloat\n\tExprIdent\n\tExprInt\n\tExprLChar\n\tExprLString\n\tExprString\n)\n\n// String implements fmt.Stringer\nfunc (n ExprCase) String() string {\n\tswitch n {\n\tcase ExprPreInc:\n\t\treturn \"ExprPreInc\"\n\tcase ExprPreDec:\n\t\treturn \"ExprPreDec\"\n\tcase ExprAlignofType:\n\t\treturn \"ExprAlignofType\"\n\tcase ExprAlignofExpr:\n\t\treturn \"ExprAlignofExpr\"\n\tcase ExprSizeofType:\n\t\treturn \"ExprSizeofType\"\n\tcase ExprSizeofExpr:\n\t\treturn \"ExprSizeofExpr\"\n\tcase ExprNot:\n\t\treturn \"ExprNot\"\n\tcase ExprAddrof:\n\t\treturn \"ExprAddrof\"\n\tcase ExprStatement:\n\t\treturn \"ExprStatement\"\n\tcase ExprPExprList:\n\t\treturn \"ExprPExprList\"\n\tcase ExprCompLit:\n\t\treturn \"ExprCompLit\"\n\tcase ExprCast:\n\t\treturn \"ExprCast\"\n\tcase ExprDeref:\n\t\treturn \"ExprDeref\"\n\tcase ExprUnaryPlus:\n\t\treturn \"ExprUnaryPlus\"\n\tcase ExprUnaryMinus:\n\t\treturn \"ExprUnaryMinus\"\n\tcase ExprCpl:\n\t\treturn \"ExprCpl\"\n\tcase ExprChar:\n\t\treturn \"ExprChar\"\n\tcase ExprNe:\n\t\treturn \"ExprNe\"\n\tcase ExprModAssign:\n\t\treturn \"ExprModAssign\"\n\tcase ExprLAnd:\n\t\treturn \"ExprLAnd\"\n\tcase ExprAndAssign:\n\t\treturn \"ExprAndAssign\"\n\tcase ExprMulAssign:\n\t\treturn \"ExprMulAssign\"\n\tcase ExprPostInc:\n\t\treturn \"ExprPostInc\"\n\tcase ExprAddAssign:\n\t\treturn \"ExprAddAssign\"\n\tcase ExprPostDec:\n\t\treturn \"ExprPostDec\"\n\tcase ExprSubAssign:\n\t\treturn \"ExprSubAssign\"\n\tcase ExprPSelect:\n\t\treturn \"ExprPSelect\"\n\tcase ExprDivAssign:\n\t\treturn \"ExprDivAssign\"\n\tcase ExprLsh:\n\t\treturn \"ExprLsh\"\n\tcase ExprLshAssign:\n\t\treturn \"ExprLshAssign\"\n\tcase ExprLe:\n\t\treturn \"ExprLe\"\n\tcase ExprEq:\n\t\treturn \"ExprEq\"\n\tcase ExprGe:\n\t\treturn \"ExprGe\"\n\tcase ExprRsh:\n\t\treturn \"ExprRsh\"\n\tcase ExprRshAssign:\n\t\treturn \"ExprRshAssign\"\n\tcase ExprXorAssign:\n\t\treturn \"ExprXorAssign\"\n\tcase ExprOrAssign:\n\t\treturn \"ExprOrAssign\"\n\tcase ExprLOr:\n\t\treturn \"ExprLOr\"\n\tcase ExprMod:\n\t\treturn \"ExprMod\"\n\tcase ExprAnd:\n\t\treturn \"ExprAnd\"\n\tcase ExprCall:\n\t\treturn \"ExprCall\"\n\tcase ExprMul:\n\t\treturn \"ExprMul\"\n\tcase ExprAdd:\n\t\treturn \"ExprAdd\"\n\tcase ExprSub:\n\t\treturn \"ExprSub\"\n\tcase ExprSelect:\n\t\treturn \"ExprSelect\"\n\tcase ExprDiv:\n\t\treturn \"ExprDiv\"\n\tcase ExprLt:\n\t\treturn \"ExprLt\"\n\tcase ExprAssign:\n\t\treturn \"ExprAssign\"\n\tcase ExprGt:\n\t\treturn \"ExprGt\"\n\tcase ExprCond:\n\t\treturn \"ExprCond\"\n\tcase ExprIndex:\n\t\treturn \"ExprIndex\"\n\tcase ExprXor:\n\t\treturn \"ExprXor\"\n\tcase ExprOr:\n\t\treturn \"ExprOr\"\n\tcase ExprFloat:\n\t\treturn \"ExprFloat\"\n\tcase ExprIdent:\n\t\treturn \"ExprIdent\"\n\tcase ExprInt:\n\t\treturn \"ExprInt\"\n\tcase ExprLChar:\n\t\treturn \"ExprLChar\"\n\tcase ExprLString:\n\t\treturn \"ExprLString\"\n\tcase ExprString:\n\t\treturn \"ExprString\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"ExprCase(%v)\", int(n))\n\t}\n}\n\n// Expr represents data reduced by productions:\n//\n//\tExpr:\n//\t        \"++\" Expr                                          // Case ExprPreInc\n//\t|       \"--\" Expr                                          // Case ExprPreDec\n//\t|       \"__alignof__\" '(' TypeName ')'                     // Case ExprAlignofType\n//\t|       \"__alignof__\" Expr                                 // Case ExprAlignofExpr\n//\t|       \"sizeof\" '(' TypeName ')'                          // Case ExprSizeofType\n//\t|       \"sizeof\" Expr                                      // Case ExprSizeofExpr\n//\t|       '!' Expr                                           // Case ExprNot\n//\t|       '&' Expr                                           // Case ExprAddrof\n//\t|       '(' CompoundStmt ')'                               // Case ExprStatement\n//\t|       '(' ExprList ')'                                   // Case ExprPExprList\n//\t|       '(' TypeName ')' '{' InitializerList CommaOpt '}'  // Case ExprCompLit\n//\t|       '(' TypeName ')' Expr                              // Case ExprCast\n//\t|       '*' Expr                                           // Case ExprDeref\n//\t|       '+' Expr                                           // Case ExprUnaryPlus\n//\t|       '-' Expr                                           // Case ExprUnaryMinus\n//\t|       '~' Expr                                           // Case ExprCpl\n//\t|       CHARCONST                                          // Case ExprChar\n//\t|       Expr \"!=\" Expr                                     // Case ExprNe\n//\t|       Expr \"%=\" Expr                                     // Case ExprModAssign\n//\t|       Expr \"&&\" Expr                                     // Case ExprLAnd\n//\t|       Expr \"&=\" Expr                                     // Case ExprAndAssign\n//\t|       Expr \"*=\" Expr                                     // Case ExprMulAssign\n//\t|       Expr \"++\"                                          // Case ExprPostInc\n//\t|       Expr \"+=\" Expr                                     // Case ExprAddAssign\n//\t|       Expr \"--\"                                          // Case ExprPostDec\n//\t|       Expr \"-=\" Expr                                     // Case ExprSubAssign\n//\t|       Expr \"->\" IDENTIFIER                               // Case ExprPSelect\n//\t|       Expr \"/=\" Expr                                     // Case ExprDivAssign\n//\t|       Expr \"<<\" Expr                                     // Case ExprLsh\n//\t|       Expr \"<<=\" Expr                                    // Case ExprLshAssign\n//\t|       Expr \"<=\" Expr                                     // Case ExprLe\n//\t|       Expr \"==\" Expr                                     // Case ExprEq\n//\t|       Expr \">=\" Expr                                     // Case ExprGe\n//\t|       Expr \">>\" Expr                                     // Case ExprRsh\n//\t|       Expr \">>=\" Expr                                    // Case ExprRshAssign\n//\t|       Expr \"^=\" Expr                                     // Case ExprXorAssign\n//\t|       Expr \"|=\" Expr                                     // Case ExprOrAssign\n//\t|       Expr \"||\" Expr                                     // Case ExprLOr\n//\t|       Expr '%' Expr                                      // Case ExprMod\n//\t|       Expr '&' Expr                                      // Case ExprAnd\n//\t|       Expr '(' ArgumentExprListOpt ')'                   // Case ExprCall\n//\t|       Expr '*' Expr                                      // Case ExprMul\n//\t|       Expr '+' Expr                                      // Case ExprAdd\n//\t|       Expr '-' Expr                                      // Case ExprSub\n//\t|       Expr '.' IDENTIFIER                                // Case ExprSelect\n//\t|       Expr '/' Expr                                      // Case ExprDiv\n//\t|       Expr '<' Expr                                      // Case ExprLt\n//\t|       Expr '=' Expr                                      // Case ExprAssign\n//\t|       Expr '>' Expr                                      // Case ExprGt\n//\t|       Expr '?' ExprList ':' Expr                         // Case ExprCond\n//\t|       Expr '[' ExprList ']'                              // Case ExprIndex\n//\t|       Expr '^' Expr                                      // Case ExprXor\n//\t|       Expr '|' Expr                                      // Case ExprOr\n//\t|       FLOATCONST                                         // Case ExprFloat\n//\t|       IDENTIFIER                                         // Case ExprIdent\n//\t|       INTCONST                                           // Case ExprInt\n//\t|       LONGCHARCONST                                      // Case ExprLChar\n//\t|       LONGSTRINGLITERAL                                  // Case ExprLString\n//\t|       STRINGLITERAL                                      // Case ExprString\ntype Expr struct {\n\tCallArgs            []Operand   // Promoted arguments of Call.\n\tDeclarator          *Declarator // Case Ident.\n\tOperand             Operand\n\tScope               *Scope // Case Ident, CompLit.\n\tenum                *EnumType\n\tAssignedTo          bool // Expression appears at the left side of assignment.\n\tArgumentExprListOpt *ArgumentExprListOpt\n\tCase                ExprCase\n\tCommaOpt            *CommaOpt\n\tCompoundStmt        *CompoundStmt\n\tExpr                *Expr\n\tExpr2               *Expr\n\tExprList            *ExprList\n\tInitializerList     *InitializerList\n\tToken               xc.Token\n\tToken2              xc.Token\n\tToken3              xc.Token\n\tToken4              xc.Token\n\tTypeName            *TypeName\n}\n\nfunc (n *Expr) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Expr) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Expr) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52:\n\t\treturn n.Expr.Pos()\n\tcase 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 53, 54, 55, 56, 57, 58:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExprList represents data reduced by productions:\n//\n//\tExprList:\n//\t        Expr               // Case 0\n//\t|       ExprList ',' Expr  // Case 1\ntype ExprList struct {\n\tOperand  Operand\n\tCase     int\n\tExpr     *Expr\n\tExprList *ExprList\n\tToken    xc.Token\n}\n\nfunc (n *ExprList) reverse() *ExprList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ExprList\n\tfor nb != nil {\n\t\tnc := nb.ExprList\n\t\tnb.ExprList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ExprList = nil\n\treturn na\n}\n\nfunc (n *ExprList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ExprList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExprList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Expr.Pos()\n\tcase 1:\n\t\treturn n.ExprList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExprListOpt represents data reduced by productions:\n//\n//\tExprListOpt:\n//\t        /* empty */  // Case 0\n//\t|       ExprList     // Case 1\ntype ExprListOpt struct {\n\tExprList *ExprList\n}\n\nfunc (n *ExprListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExprListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExprListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ExprList.Pos()\n}\n\n// ExprOpt represents data reduced by productions:\n//\n//\tExprOpt:\n//\t        /* empty */  // Case 0\n//\t|       Expr         // Case 1\ntype ExprOpt struct {\n\tExpr *Expr\n}\n\nfunc (n *ExprOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExprOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExprOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Expr.Pos()\n}\n\n// ExprStmt represents data reduced by production:\n//\n//\tExprStmt:\n//\t        ExprListOpt ';'  // Case 0\ntype ExprStmt struct {\n\tExprListOpt *ExprListOpt\n\tToken       xc.Token\n}\n\nfunc (n *ExprStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExprStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExprStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tif p := n.ExprListOpt.Pos(); p != 0 {\n\t\treturn p\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ExternalDeclarationCase represents case numbers of production ExternalDeclaration\ntype ExternalDeclarationCase int\n\n// Values of type ExternalDeclarationCase\nconst (\n\tExternalDeclarationDecl ExternalDeclarationCase = iota\n\tExternalDeclarationFunc\n)\n\n// String implements fmt.Stringer\nfunc (n ExternalDeclarationCase) String() string {\n\tswitch n {\n\tcase ExternalDeclarationDecl:\n\t\treturn \"ExternalDeclarationDecl\"\n\tcase ExternalDeclarationFunc:\n\t\treturn \"ExternalDeclarationFunc\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"ExternalDeclarationCase(%v)\", int(n))\n\t}\n}\n\n// ExternalDeclaration represents data reduced by productions:\n//\n//\tExternalDeclaration:\n//\t        Declaration         // Case ExternalDeclarationDecl\n//\t|       FunctionDefinition  // Case ExternalDeclarationFunc\ntype ExternalDeclaration struct {\n\tCase               ExternalDeclarationCase\n\tDeclaration        *Declaration\n\tFunctionDefinition *FunctionDefinition\n}\n\nfunc (n *ExternalDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ExternalDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExternalDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declaration.Pos()\n\tcase 1:\n\t\treturn n.FunctionDefinition.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ExternalDeclarationList represents data reduced by productions:\n//\n//\tExternalDeclarationList:\n//\t        ExternalDeclaration                          // Case 0\n//\t|       ExternalDeclarationList ExternalDeclaration  // Case 1\ntype ExternalDeclarationList struct {\n\tCase                    int\n\tExternalDeclaration     *ExternalDeclaration\n\tExternalDeclarationList *ExternalDeclarationList\n}\n\nfunc (n *ExternalDeclarationList) reverse() *ExternalDeclarationList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ExternalDeclarationList\n\tfor nb != nil {\n\t\tnc := nb.ExternalDeclarationList\n\t\tnb.ExternalDeclarationList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ExternalDeclarationList = nil\n\treturn na\n}\n\nfunc (n *ExternalDeclarationList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ExternalDeclarationList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ExternalDeclarationList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.ExternalDeclaration.Pos()\n\tcase 1:\n\t\treturn n.ExternalDeclarationList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// FunctionBody represents data reduced by production:\n//\n//\tFunctionBody:\n//\t        CompoundStmt  // Case 0\ntype FunctionBody struct {\n\tCompoundStmt *CompoundStmt\n}\n\nfunc (n *FunctionBody) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionBody) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionBody) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.CompoundStmt.Pos()\n}\n\n// FunctionDefinitionCase represents case numbers of production FunctionDefinition\ntype FunctionDefinitionCase int\n\n// Values of type FunctionDefinitionCase\nconst (\n\tFunctionDefinitionSpec FunctionDefinitionCase = iota\n\tFunctionDefinitionInt\n)\n\n// String implements fmt.Stringer\nfunc (n FunctionDefinitionCase) String() string {\n\tswitch n {\n\tcase FunctionDefinitionSpec:\n\t\treturn \"FunctionDefinitionSpec\"\n\tcase FunctionDefinitionInt:\n\t\treturn \"FunctionDefinitionInt\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"FunctionDefinitionCase(%v)\", int(n))\n\t}\n}\n\n// FunctionDefinition represents data reduced by productions:\n//\n//\tFunctionDefinition:\n//\t        DeclarationSpecifiers Declarator DeclarationListOpt FunctionBody  // Case FunctionDefinitionSpec\n//\t|       Declarator DeclarationListOpt FunctionBody                        // Case FunctionDefinitionInt\ntype FunctionDefinition struct {\n\tCase                  FunctionDefinitionCase\n\tDeclarationListOpt    *DeclarationListOpt\n\tDeclarationSpecifiers *DeclarationSpecifiers\n\tDeclarator            *Declarator\n\tFunctionBody          *FunctionBody\n}\n\nfunc (n *FunctionDefinition) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionDefinition) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionDefinition) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.DeclarationSpecifiers.Pos()\n\tcase 1:\n\t\treturn n.Declarator.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// FunctionSpecifier represents data reduced by production:\n//\n//\tFunctionSpecifier:\n//\t        \"inline\"  // Case 0\ntype FunctionSpecifier struct {\n\tToken xc.Token\n}\n\nfunc (n *FunctionSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *FunctionSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *FunctionSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// IdentifierList represents data reduced by productions:\n//\n//\tIdentifierList:\n//\t        IDENTIFIER                     // Case 0\n//\t|       IdentifierList ',' IDENTIFIER  // Case 1\ntype IdentifierList struct {\n\tCase           int\n\tIdentifierList *IdentifierList\n\tToken          xc.Token\n\tToken2         xc.Token\n}\n\nfunc (n *IdentifierList) reverse() *IdentifierList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.IdentifierList\n\tfor nb != nil {\n\t\tnc := nb.IdentifierList\n\t\tnb.IdentifierList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.IdentifierList = nil\n\treturn na\n}\n\nfunc (n *IdentifierList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.IdentifierList.Pos()\n\tcase 0:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// IdentifierListOpt represents data reduced by productions:\n//\n//\tIdentifierListOpt:\n//\t        /* empty */     // Case 0\n//\t|       IdentifierList  // Case 1\ntype IdentifierListOpt struct {\n\tIdentifierList *IdentifierList\n}\n\nfunc (n *IdentifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.IdentifierList.Pos()\n}\n\n// IdentifierOpt represents data reduced by productions:\n//\n//\tIdentifierOpt:\n//\t        /* empty */  // Case 0\n//\t|       IDENTIFIER   // Case 1\ntype IdentifierOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *IdentifierOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IdentifierOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IdentifierOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// InitDeclaratorCase represents case numbers of production InitDeclarator\ntype InitDeclaratorCase int\n\n// Values of type InitDeclaratorCase\nconst (\n\tInitDeclaratorBase InitDeclaratorCase = iota\n\tInitDeclaratorInit\n)\n\n// String implements fmt.Stringer\nfunc (n InitDeclaratorCase) String() string {\n\tswitch n {\n\tcase InitDeclaratorBase:\n\t\treturn \"InitDeclaratorBase\"\n\tcase InitDeclaratorInit:\n\t\treturn \"InitDeclaratorInit\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"InitDeclaratorCase(%v)\", int(n))\n\t}\n}\n\n// InitDeclarator represents data reduced by productions:\n//\n//\tInitDeclarator:\n//\t        Declarator                  // Case InitDeclaratorBase\n//\t|       Declarator '=' Initializer  // Case InitDeclaratorInit\ntype InitDeclarator struct {\n\tCase        InitDeclaratorCase\n\tDeclarator  *Declarator\n\tInitializer *Initializer\n\tToken       xc.Token\n}\n\nfunc (n *InitDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Declarator.Pos()\n}\n\n// InitDeclaratorList represents data reduced by productions:\n//\n//\tInitDeclaratorList:\n//\t        InitDeclarator                         // Case 0\n//\t|       InitDeclaratorList ',' InitDeclarator  // Case 1\ntype InitDeclaratorList struct {\n\tCase               int\n\tInitDeclarator     *InitDeclarator\n\tInitDeclaratorList *InitDeclaratorList\n\tToken              xc.Token\n}\n\nfunc (n *InitDeclaratorList) reverse() *InitDeclaratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.InitDeclaratorList\n\tfor nb != nil {\n\t\tnc := nb.InitDeclaratorList\n\t\tnb.InitDeclaratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.InitDeclaratorList = nil\n\treturn na\n}\n\nfunc (n *InitDeclaratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclaratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclaratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.InitDeclarator.Pos()\n\tcase 1:\n\t\treturn n.InitDeclaratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// InitDeclaratorListOpt represents data reduced by productions:\n//\n//\tInitDeclaratorListOpt:\n//\t        /* empty */         // Case 0\n//\t|       InitDeclaratorList  // Case 1\ntype InitDeclaratorListOpt struct {\n\tInitDeclaratorList *InitDeclaratorList\n}\n\nfunc (n *InitDeclaratorListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *InitDeclaratorListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitDeclaratorListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.InitDeclaratorList.Pos()\n}\n\n// InitializerCase represents case numbers of production Initializer\ntype InitializerCase int\n\n// Values of type InitializerCase\nconst (\n\tInitializerCompLit InitializerCase = iota\n\tInitializerExpr\n)\n\n// String implements fmt.Stringer\nfunc (n InitializerCase) String() string {\n\tswitch n {\n\tcase InitializerCompLit:\n\t\treturn \"InitializerCompLit\"\n\tcase InitializerExpr:\n\t\treturn \"InitializerExpr\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"InitializerCase(%v)\", int(n))\n\t}\n}\n\n// Initializer represents data reduced by productions:\n//\n//\tInitializer:\n//\t        '{' InitializerList CommaOpt '}'  // Case InitializerCompLit\n//\t|       Expr                              // Case InitializerExpr\ntype Initializer struct {\n\tCase            InitializerCase\n\tCommaOpt        *CommaOpt\n\tExpr            *Expr\n\tInitializerList *InitializerList\n\tToken           xc.Token\n\tToken2          xc.Token\n}\n\nfunc (n *Initializer) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Initializer) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Initializer) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 1:\n\t\treturn n.Expr.Pos()\n\tcase 0:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// InitializerList represents data reduced by productions:\n//\n//\tInitializerList:\n//\t        /* empty */                                  // Case 0\n//\t|       Initializer                                  // Case 1\n//\t|       Designation Initializer                      // Case 2\n//\t|       InitializerList ',' Initializer              // Case 3\n//\t|       InitializerList ',' Designation Initializer  // Case 4\ntype InitializerList struct {\n\tOperand         Operand //TODO-\n\tLen             int\n\tCase            int\n\tDesignation     *Designation\n\tInitializer     *Initializer\n\tInitializerList *InitializerList\n\tToken           xc.Token\n}\n\nfunc (n *InitializerList) reverse() *InitializerList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.InitializerList\n\tfor nb != nil {\n\t\tnc := nb.InitializerList\n\t\tnb.InitializerList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.InitializerList = nil\n\treturn na\n}\n\nfunc (n *InitializerList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *InitializerList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *InitializerList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn 0\n\tcase 2:\n\t\treturn n.Designation.Pos()\n\tcase 1:\n\t\treturn n.Initializer.Pos()\n\tcase 3, 4:\n\t\tif p := n.InitializerList.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// IterationStmtCase represents case numbers of production IterationStmt\ntype IterationStmtCase int\n\n// Values of type IterationStmtCase\nconst (\n\tIterationStmtDo IterationStmtCase = iota\n\tIterationStmtForDecl\n\tIterationStmtFor\n\tIterationStmtWhile\n)\n\n// String implements fmt.Stringer\nfunc (n IterationStmtCase) String() string {\n\tswitch n {\n\tcase IterationStmtDo:\n\t\treturn \"IterationStmtDo\"\n\tcase IterationStmtForDecl:\n\t\treturn \"IterationStmtForDecl\"\n\tcase IterationStmtFor:\n\t\treturn \"IterationStmtFor\"\n\tcase IterationStmtWhile:\n\t\treturn \"IterationStmtWhile\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"IterationStmtCase(%v)\", int(n))\n\t}\n}\n\n// IterationStmt represents data reduced by productions:\n//\n//\tIterationStmt:\n//\t        \"do\" Stmt \"while\" '(' ExprList ')' ';'                          // Case IterationStmtDo\n//\t|       \"for\" '(' Declaration ExprListOpt ';' ExprListOpt ')' Stmt      // Case IterationStmtForDecl\n//\t|       \"for\" '(' ExprListOpt ';' ExprListOpt ';' ExprListOpt ')' Stmt  // Case IterationStmtFor\n//\t|       \"while\" '(' ExprList ')' Stmt                                   // Case IterationStmtWhile\ntype IterationStmt struct {\n\tCase         IterationStmtCase\n\tDeclaration  *Declaration\n\tExprList     *ExprList\n\tExprListOpt  *ExprListOpt\n\tExprListOpt2 *ExprListOpt\n\tExprListOpt3 *ExprListOpt\n\tStmt         *Stmt\n\tToken        xc.Token\n\tToken2       xc.Token\n\tToken3       xc.Token\n\tToken4       xc.Token\n\tToken5       xc.Token\n}\n\nfunc (n *IterationStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *IterationStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *IterationStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// JumpStmtCase represents case numbers of production JumpStmt\ntype JumpStmtCase int\n\n// Values of type JumpStmtCase\nconst (\n\tJumpStmtBreak JumpStmtCase = iota\n\tJumpStmtContinue\n\tJumpStmtGoto\n\tJumpStmtReturn\n)\n\n// String implements fmt.Stringer\nfunc (n JumpStmtCase) String() string {\n\tswitch n {\n\tcase JumpStmtBreak:\n\t\treturn \"JumpStmtBreak\"\n\tcase JumpStmtContinue:\n\t\treturn \"JumpStmtContinue\"\n\tcase JumpStmtGoto:\n\t\treturn \"JumpStmtGoto\"\n\tcase JumpStmtReturn:\n\t\treturn \"JumpStmtReturn\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"JumpStmtCase(%v)\", int(n))\n\t}\n}\n\n// JumpStmt represents data reduced by productions:\n//\n//\tJumpStmt:\n//\t        \"break\" ';'               // Case JumpStmtBreak\n//\t|       \"continue\" ';'            // Case JumpStmtContinue\n//\t|       \"goto\" IDENTIFIER ';'     // Case JumpStmtGoto\n//\t|       \"return\" ExprListOpt ';'  // Case JumpStmtReturn\ntype JumpStmt struct {\n\tReturnOperand Operand\n\tscope         *Scope\n\tCase          JumpStmtCase\n\tExprListOpt   *ExprListOpt\n\tToken         xc.Token\n\tToken2        xc.Token\n\tToken3        xc.Token\n}\n\nfunc (n *JumpStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *JumpStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *JumpStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// LabeledStmtCase represents case numbers of production LabeledStmt\ntype LabeledStmtCase int\n\n// Values of type LabeledStmtCase\nconst (\n\tLabeledStmtSwitchCase LabeledStmtCase = iota\n\tLabeledStmtDefault\n\tLabeledStmtLabel\n\tLabeledStmtLabel2\n)\n\n// String implements fmt.Stringer\nfunc (n LabeledStmtCase) String() string {\n\tswitch n {\n\tcase LabeledStmtSwitchCase:\n\t\treturn \"LabeledStmtSwitchCase\"\n\tcase LabeledStmtDefault:\n\t\treturn \"LabeledStmtDefault\"\n\tcase LabeledStmtLabel:\n\t\treturn \"LabeledStmtLabel\"\n\tcase LabeledStmtLabel2:\n\t\treturn \"LabeledStmtLabel2\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"LabeledStmtCase(%v)\", int(n))\n\t}\n}\n\n// LabeledStmt represents data reduced by productions:\n//\n//\tLabeledStmt:\n//\t        \"case\" ConstExpr ':' Stmt  // Case LabeledStmtSwitchCase\n//\t|       \"default\" ':' Stmt         // Case LabeledStmtDefault\n//\t|       IDENTIFIER ':' Stmt        // Case LabeledStmtLabel\n//\t|       TYPEDEF_NAME ':' Stmt      // Case LabeledStmtLabel2\ntype LabeledStmt struct {\n\tCase      LabeledStmtCase\n\tConstExpr *ConstExpr\n\tStmt      *Stmt\n\tToken     xc.Token\n\tToken2    xc.Token\n}\n\nfunc (n *LabeledStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *LabeledStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *LabeledStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// ParameterDeclarationCase represents case numbers of production ParameterDeclaration\ntype ParameterDeclarationCase int\n\n// Values of type ParameterDeclarationCase\nconst (\n\tParameterDeclarationAbstract ParameterDeclarationCase = iota\n\tParameterDeclarationDeclarator\n)\n\n// String implements fmt.Stringer\nfunc (n ParameterDeclarationCase) String() string {\n\tswitch n {\n\tcase ParameterDeclarationAbstract:\n\t\treturn \"ParameterDeclarationAbstract\"\n\tcase ParameterDeclarationDeclarator:\n\t\treturn \"ParameterDeclarationDeclarator\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"ParameterDeclarationCase(%v)\", int(n))\n\t}\n}\n\n// ParameterDeclaration represents data reduced by productions:\n//\n//\tParameterDeclaration:\n//\t        DeclarationSpecifiers AbstractDeclaratorOpt  // Case ParameterDeclarationAbstract\n//\t|       DeclarationSpecifiers Declarator             // Case ParameterDeclarationDeclarator\ntype ParameterDeclaration struct {\n\tAbstractDeclaratorOpt *AbstractDeclaratorOpt\n\tCase                  ParameterDeclarationCase\n\tDeclarationSpecifiers *DeclarationSpecifiers\n\tDeclarator            *Declarator\n}\n\nfunc (n *ParameterDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.DeclarationSpecifiers.Pos()\n}\n\n// ParameterList represents data reduced by productions:\n//\n//\tParameterList:\n//\t        ParameterDeclaration                    // Case 0\n//\t|       ParameterList ',' ParameterDeclaration  // Case 1\ntype ParameterList struct {\n\tCase                 int\n\tParameterDeclaration *ParameterDeclaration\n\tParameterList        *ParameterList\n\tToken                xc.Token\n}\n\nfunc (n *ParameterList) reverse() *ParameterList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.ParameterList\n\tfor nb != nil {\n\t\tnc := nb.ParameterList\n\t\tnb.ParameterList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.ParameterList = nil\n\treturn na\n}\n\nfunc (n *ParameterList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.ParameterDeclaration.Pos()\n\tcase 1:\n\t\treturn n.ParameterList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// ParameterTypeListCase represents case numbers of production ParameterTypeList\ntype ParameterTypeListCase int\n\n// Values of type ParameterTypeListCase\nconst (\n\tParameterTypeListBase ParameterTypeListCase = iota\n\tParameterTypeListDots\n)\n\n// String implements fmt.Stringer\nfunc (n ParameterTypeListCase) String() string {\n\tswitch n {\n\tcase ParameterTypeListBase:\n\t\treturn \"ParameterTypeListBase\"\n\tcase ParameterTypeListDots:\n\t\treturn \"ParameterTypeListDots\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"ParameterTypeListCase(%v)\", int(n))\n\t}\n}\n\n// ParameterTypeList represents data reduced by productions:\n//\n//\tParameterTypeList:\n//\t        ParameterList            // Case ParameterTypeListBase\n//\t|       ParameterList ',' \"...\"  // Case ParameterTypeListDots\ntype ParameterTypeList struct {\n\tCase          ParameterTypeListCase\n\tParameterList *ParameterList\n\tToken         xc.Token\n\tToken2        xc.Token\n}\n\nfunc (n *ParameterTypeList) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterTypeList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterTypeList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ParameterList.Pos()\n}\n\n// ParameterTypeListOpt represents data reduced by productions:\n//\n//\tParameterTypeListOpt:\n//\t        /* empty */        // Case 0\n//\t|       ParameterTypeList  // Case 1\ntype ParameterTypeListOpt struct {\n\tParameterTypeList *ParameterTypeList\n}\n\nfunc (n *ParameterTypeListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *ParameterTypeListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *ParameterTypeListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.ParameterTypeList.Pos()\n}\n\n// PointerCase represents case numbers of production Pointer\ntype PointerCase int\n\n// Values of type PointerCase\nconst (\n\tPointerBase PointerCase = iota\n\tPointerPtr\n)\n\n// String implements fmt.Stringer\nfunc (n PointerCase) String() string {\n\tswitch n {\n\tcase PointerBase:\n\t\treturn \"PointerBase\"\n\tcase PointerPtr:\n\t\treturn \"PointerPtr\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"PointerCase(%v)\", int(n))\n\t}\n}\n\n// Pointer represents data reduced by productions:\n//\n//\tPointer:\n//\t        '*' TypeQualifierListOpt          // Case PointerBase\n//\t|       '*' TypeQualifierListOpt Pointer  // Case PointerPtr\ntype Pointer struct {\n\tCase                 PointerCase\n\tPointer              *Pointer\n\tToken                xc.Token\n\tTypeQualifierListOpt *TypeQualifierListOpt\n}\n\nfunc (n *Pointer) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Pointer) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Pointer) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// PointerOpt represents data reduced by productions:\n//\n//\tPointerOpt:\n//\t        /* empty */  // Case 0\n//\t|       Pointer      // Case 1\ntype PointerOpt struct {\n\tPointer *Pointer\n}\n\nfunc (n *PointerOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *PointerOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *PointerOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Pointer.Pos()\n}\n\n// SelectionStmtCase represents case numbers of production SelectionStmt\ntype SelectionStmtCase int\n\n// Values of type SelectionStmtCase\nconst (\n\tSelectionStmtIfElse SelectionStmtCase = iota\n\tSelectionStmtIf\n\tSelectionStmtSwitch\n)\n\n// String implements fmt.Stringer\nfunc (n SelectionStmtCase) String() string {\n\tswitch n {\n\tcase SelectionStmtIfElse:\n\t\treturn \"SelectionStmtIfElse\"\n\tcase SelectionStmtIf:\n\t\treturn \"SelectionStmtIf\"\n\tcase SelectionStmtSwitch:\n\t\treturn \"SelectionStmtSwitch\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"SelectionStmtCase(%v)\", int(n))\n\t}\n}\n\n// SelectionStmt represents data reduced by productions:\n//\n//\tSelectionStmt:\n//\t        \"if\" '(' ExprList ')' Stmt \"else\" Stmt  // Case SelectionStmtIfElse\n//\t|       \"if\" '(' ExprList ')' Stmt              // Case SelectionStmtIf\n//\t|       \"switch\" '(' ExprList ')' Stmt          // Case SelectionStmtSwitch\ntype SelectionStmt struct {\n\tCases    []*LabeledStmt\n\tSwitchOp Operand // Promoted switch operand\n\tCase     SelectionStmtCase\n\tExprList *ExprList\n\tStmt     *Stmt\n\tStmt2    *Stmt\n\tToken    xc.Token\n\tToken2   xc.Token\n\tToken3   xc.Token\n\tToken4   xc.Token\n}\n\nfunc (n *SelectionStmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SelectionStmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SelectionStmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList\ntype SpecifierQualifierListCase int\n\n// Values of type SpecifierQualifierListCase\nconst (\n\tSpecifierQualifierListQualifier SpecifierQualifierListCase = iota\n\tSpecifierQualifierListSpecifier\n)\n\n// String implements fmt.Stringer\nfunc (n SpecifierQualifierListCase) String() string {\n\tswitch n {\n\tcase SpecifierQualifierListQualifier:\n\t\treturn \"SpecifierQualifierListQualifier\"\n\tcase SpecifierQualifierListSpecifier:\n\t\treturn \"SpecifierQualifierListSpecifier\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"SpecifierQualifierListCase(%v)\", int(n))\n\t}\n}\n\n// SpecifierQualifierList represents data reduced by productions:\n//\n//\tSpecifierQualifierList:\n//\t        TypeQualifier SpecifierQualifierListOpt  // Case SpecifierQualifierListQualifier\n//\t|       TypeSpecifier SpecifierQualifierListOpt  // Case SpecifierQualifierListSpecifier\ntype SpecifierQualifierList struct {\n\tCase                      SpecifierQualifierListCase\n\tSpecifierQualifierListOpt *SpecifierQualifierListOpt\n\tTypeQualifier             *TypeQualifier\n\tTypeSpecifier             *TypeSpecifier\n}\n\nfunc (n *SpecifierQualifierList) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SpecifierQualifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SpecifierQualifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 1:\n\t\treturn n.TypeSpecifier.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// SpecifierQualifierListOpt represents data reduced by productions:\n//\n//\tSpecifierQualifierListOpt:\n//\t        /* empty */             // Case 0\n//\t|       SpecifierQualifierList  // Case 1\ntype SpecifierQualifierListOpt struct {\n\tSpecifierQualifierList *SpecifierQualifierList\n}\n\nfunc (n *SpecifierQualifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *SpecifierQualifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *SpecifierQualifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.SpecifierQualifierList.Pos()\n}\n\n// StmtCase represents case numbers of production Stmt\ntype StmtCase int\n\n// Values of type StmtCase\nconst (\n\tStmtBlock StmtCase = iota\n\tStmtExpr\n\tStmtIter\n\tStmtJump\n\tStmtLabeled\n\tStmtSelect\n)\n\n// String implements fmt.Stringer\nfunc (n StmtCase) String() string {\n\tswitch n {\n\tcase StmtBlock:\n\t\treturn \"StmtBlock\"\n\tcase StmtExpr:\n\t\treturn \"StmtExpr\"\n\tcase StmtIter:\n\t\treturn \"StmtIter\"\n\tcase StmtJump:\n\t\treturn \"StmtJump\"\n\tcase StmtLabeled:\n\t\treturn \"StmtLabeled\"\n\tcase StmtSelect:\n\t\treturn \"StmtSelect\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StmtCase(%v)\", int(n))\n\t}\n}\n\n// Stmt represents data reduced by productions:\n//\n//\tStmt:\n//\t        CompoundStmt   // Case StmtBlock\n//\t|       ExprStmt       // Case StmtExpr\n//\t|       IterationStmt  // Case StmtIter\n//\t|       JumpStmt       // Case StmtJump\n//\t|       LabeledStmt    // Case StmtLabeled\n//\t|       SelectionStmt  // Case StmtSelect\ntype Stmt struct {\n\tCase          StmtCase\n\tCompoundStmt  *CompoundStmt\n\tExprStmt      *ExprStmt\n\tIterationStmt *IterationStmt\n\tJumpStmt      *JumpStmt\n\tLabeledStmt   *LabeledStmt\n\tSelectionStmt *SelectionStmt\n}\n\nfunc (n *Stmt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *Stmt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *Stmt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.CompoundStmt.Pos()\n\tcase 1:\n\t\treturn n.ExprStmt.Pos()\n\tcase 2:\n\t\treturn n.IterationStmt.Pos()\n\tcase 3:\n\t\treturn n.JumpStmt.Pos()\n\tcase 4:\n\t\treturn n.LabeledStmt.Pos()\n\tcase 5:\n\t\treturn n.SelectionStmt.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier\ntype StorageClassSpecifierCase int\n\n// Values of type StorageClassSpecifierCase\nconst (\n\tStorageClassSpecifierAuto StorageClassSpecifierCase = iota\n\tStorageClassSpecifierExtern\n\tStorageClassSpecifierRegister\n\tStorageClassSpecifierStatic\n\tStorageClassSpecifierTypedef\n)\n\n// String implements fmt.Stringer\nfunc (n StorageClassSpecifierCase) String() string {\n\tswitch n {\n\tcase StorageClassSpecifierAuto:\n\t\treturn \"StorageClassSpecifierAuto\"\n\tcase StorageClassSpecifierExtern:\n\t\treturn \"StorageClassSpecifierExtern\"\n\tcase StorageClassSpecifierRegister:\n\t\treturn \"StorageClassSpecifierRegister\"\n\tcase StorageClassSpecifierStatic:\n\t\treturn \"StorageClassSpecifierStatic\"\n\tcase StorageClassSpecifierTypedef:\n\t\treturn \"StorageClassSpecifierTypedef\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StorageClassSpecifierCase(%v)\", int(n))\n\t}\n}\n\n// StorageClassSpecifier represents data reduced by productions:\n//\n//\tStorageClassSpecifier:\n//\t        \"auto\"      // Case StorageClassSpecifierAuto\n//\t|       \"extern\"    // Case StorageClassSpecifierExtern\n//\t|       \"register\"  // Case StorageClassSpecifierRegister\n//\t|       \"static\"    // Case StorageClassSpecifierStatic\n//\t|       \"typedef\"   // Case StorageClassSpecifierTypedef\ntype StorageClassSpecifier struct {\n\tCase  StorageClassSpecifierCase\n\tToken xc.Token\n}\n\nfunc (n *StorageClassSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StorageClassSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StorageClassSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// StructDeclarationCase represents case numbers of production StructDeclaration\ntype StructDeclarationCase int\n\n// Values of type StructDeclarationCase\nconst (\n\tStructDeclarationBase StructDeclarationCase = iota\n\tStructDeclarationAnon\n)\n\n// String implements fmt.Stringer\nfunc (n StructDeclarationCase) String() string {\n\tswitch n {\n\tcase StructDeclarationBase:\n\t\treturn \"StructDeclarationBase\"\n\tcase StructDeclarationAnon:\n\t\treturn \"StructDeclarationAnon\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StructDeclarationCase(%v)\", int(n))\n\t}\n}\n\n// StructDeclaration represents data reduced by productions:\n//\n//\tStructDeclaration:\n//\t        SpecifierQualifierList StructDeclaratorList ';'  // Case StructDeclarationBase\n//\t|       SpecifierQualifierList ';'                       // Case StructDeclarationAnon\ntype StructDeclaration struct {\n\tCase                   StructDeclarationCase\n\tSpecifierQualifierList *SpecifierQualifierList\n\tStructDeclaratorList   *StructDeclaratorList\n\tToken                  xc.Token\n}\n\nfunc (n *StructDeclaration) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclaration) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclaration) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.SpecifierQualifierList.Pos()\n}\n\n// StructDeclarationList represents data reduced by productions:\n//\n//\tStructDeclarationList:\n//\t        StructDeclaration                        // Case 0\n//\t|       StructDeclarationList StructDeclaration  // Case 1\ntype StructDeclarationList struct {\n\tCase                  int\n\tStructDeclaration     *StructDeclaration\n\tStructDeclarationList *StructDeclarationList\n}\n\nfunc (n *StructDeclarationList) reverse() *StructDeclarationList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.StructDeclarationList\n\tfor nb != nil {\n\t\tnc := nb.StructDeclarationList\n\t\tnb.StructDeclarationList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.StructDeclarationList = nil\n\treturn na\n}\n\nfunc (n *StructDeclarationList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclarationList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclarationList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.StructDeclaration.Pos()\n\tcase 1:\n\t\treturn n.StructDeclarationList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructDeclaratorCase represents case numbers of production StructDeclarator\ntype StructDeclaratorCase int\n\n// Values of type StructDeclaratorCase\nconst (\n\tStructDeclaratorBase StructDeclaratorCase = iota\n\tStructDeclaratorBits\n)\n\n// String implements fmt.Stringer\nfunc (n StructDeclaratorCase) String() string {\n\tswitch n {\n\tcase StructDeclaratorBase:\n\t\treturn \"StructDeclaratorBase\"\n\tcase StructDeclaratorBits:\n\t\treturn \"StructDeclaratorBits\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StructDeclaratorCase(%v)\", int(n))\n\t}\n}\n\n// StructDeclarator represents data reduced by productions:\n//\n//\tStructDeclarator:\n//\t        Declarator                   // Case StructDeclaratorBase\n//\t|       DeclaratorOpt ':' ConstExpr  // Case StructDeclaratorBits\ntype StructDeclarator struct {\n\tBits          int\n\tCase          StructDeclaratorCase\n\tConstExpr     *ConstExpr\n\tDeclarator    *Declarator\n\tDeclaratorOpt *DeclaratorOpt\n\tToken         xc.Token\n}\n\nfunc (n *StructDeclarator) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclarator) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclarator) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.Declarator.Pos()\n\tcase 1:\n\t\tif p := n.DeclaratorOpt.Pos(); p != 0 {\n\t\t\treturn p\n\t\t}\n\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructDeclaratorList represents data reduced by productions:\n//\n//\tStructDeclaratorList:\n//\t        StructDeclarator                           // Case 0\n//\t|       StructDeclaratorList ',' StructDeclarator  // Case 1\ntype StructDeclaratorList struct {\n\tCase                 int\n\tStructDeclarator     *StructDeclarator\n\tStructDeclaratorList *StructDeclaratorList\n\tToken                xc.Token\n}\n\nfunc (n *StructDeclaratorList) reverse() *StructDeclaratorList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.StructDeclaratorList\n\tfor nb != nil {\n\t\tnc := nb.StructDeclaratorList\n\t\tnb.StructDeclaratorList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.StructDeclaratorList = nil\n\treturn na\n}\n\nfunc (n *StructDeclaratorList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *StructDeclaratorList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructDeclaratorList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.StructDeclarator.Pos()\n\tcase 1:\n\t\treturn n.StructDeclaratorList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// StructOrUnionCase represents case numbers of production StructOrUnion\ntype StructOrUnionCase int\n\n// Values of type StructOrUnionCase\nconst (\n\tStructOrUnionStruct StructOrUnionCase = iota\n\tStructOrUnionUnion\n)\n\n// String implements fmt.Stringer\nfunc (n StructOrUnionCase) String() string {\n\tswitch n {\n\tcase StructOrUnionStruct:\n\t\treturn \"StructOrUnionStruct\"\n\tcase StructOrUnionUnion:\n\t\treturn \"StructOrUnionUnion\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StructOrUnionCase(%v)\", int(n))\n\t}\n}\n\n// StructOrUnion represents data reduced by productions:\n//\n//\tStructOrUnion:\n//\t        \"struct\"  // Case StructOrUnionStruct\n//\t|       \"union\"   // Case StructOrUnionUnion\ntype StructOrUnion struct {\n\tCase  StructOrUnionCase\n\tToken xc.Token\n}\n\nfunc (n *StructOrUnion) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructOrUnion) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructOrUnion) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier\ntype StructOrUnionSpecifierCase int\n\n// Values of type StructOrUnionSpecifierCase\nconst (\n\tStructOrUnionSpecifierTag StructOrUnionSpecifierCase = iota\n\tStructOrUnionSpecifierEmpty\n\tStructOrUnionSpecifierDefine\n)\n\n// String implements fmt.Stringer\nfunc (n StructOrUnionSpecifierCase) String() string {\n\tswitch n {\n\tcase StructOrUnionSpecifierTag:\n\t\treturn \"StructOrUnionSpecifierTag\"\n\tcase StructOrUnionSpecifierEmpty:\n\t\treturn \"StructOrUnionSpecifierEmpty\"\n\tcase StructOrUnionSpecifierDefine:\n\t\treturn \"StructOrUnionSpecifierDefine\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"StructOrUnionSpecifierCase(%v)\", int(n))\n\t}\n}\n\n// StructOrUnionSpecifier represents data reduced by productions:\n//\n//\tStructOrUnionSpecifier:\n//\t        StructOrUnion IDENTIFIER                                   // Case StructOrUnionSpecifierTag\n//\t|       StructOrUnion IdentifierOpt '{' '}'                        // Case StructOrUnionSpecifierEmpty\n//\t|       StructOrUnion IdentifierOpt '{' StructDeclarationList '}'  // Case StructOrUnionSpecifierDefine\ntype StructOrUnionSpecifier struct {\n\tscope                 *Scope // Declare the struct tag in scope.parent.\n\ttyp                   Type\n\tCase                  StructOrUnionSpecifierCase\n\tIdentifierOpt         *IdentifierOpt\n\tStructDeclarationList *StructDeclarationList\n\tStructOrUnion         *StructOrUnion\n\tToken                 xc.Token\n\tToken2                xc.Token\n}\n\nfunc (n *StructOrUnionSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *StructOrUnionSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *StructOrUnionSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.StructOrUnion.Pos()\n}\n\n// TypeName represents data reduced by production:\n//\n//\tTypeName:\n//\t        SpecifierQualifierList AbstractDeclaratorOpt  // Case 0\ntype TypeName struct {\n\tType                   Type\n\tAbstractDeclaratorOpt  *AbstractDeclaratorOpt\n\tSpecifierQualifierList *SpecifierQualifierList\n}\n\nfunc (n *TypeName) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeName) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeName) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.SpecifierQualifierList.Pos()\n}\n\n// TypeQualifierCase represents case numbers of production TypeQualifier\ntype TypeQualifierCase int\n\n// Values of type TypeQualifierCase\nconst (\n\tTypeQualifierConst TypeQualifierCase = iota\n\tTypeQualifierRestrict\n\tTypeQualifierVolatile\n)\n\n// String implements fmt.Stringer\nfunc (n TypeQualifierCase) String() string {\n\tswitch n {\n\tcase TypeQualifierConst:\n\t\treturn \"TypeQualifierConst\"\n\tcase TypeQualifierRestrict:\n\t\treturn \"TypeQualifierRestrict\"\n\tcase TypeQualifierVolatile:\n\t\treturn \"TypeQualifierVolatile\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"TypeQualifierCase(%v)\", int(n))\n\t}\n}\n\n// TypeQualifier represents data reduced by productions:\n//\n//\tTypeQualifier:\n//\t        \"const\"     // Case TypeQualifierConst\n//\t|       \"restrict\"  // Case TypeQualifierRestrict\n//\t|       \"volatile\"  // Case TypeQualifierVolatile\ntype TypeQualifier struct {\n\tCase  TypeQualifierCase\n\tToken xc.Token\n}\n\nfunc (n *TypeQualifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n\n// TypeQualifierList represents data reduced by productions:\n//\n//\tTypeQualifierList:\n//\t        TypeQualifier                    // Case 0\n//\t|       TypeQualifierList TypeQualifier  // Case 1\ntype TypeQualifierList struct {\n\tCase              int\n\tTypeQualifier     *TypeQualifier\n\tTypeQualifierList *TypeQualifierList\n}\n\nfunc (n *TypeQualifierList) reverse() *TypeQualifierList {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\tna := n\n\tnb := na.TypeQualifierList\n\tfor nb != nil {\n\t\tnc := nb.TypeQualifierList\n\t\tnb.TypeQualifierList = na\n\t\tna = nb\n\t\tnb = nc\n\t}\n\tn.TypeQualifierList = nil\n\treturn na\n}\n\nfunc (n *TypeQualifierList) fragment() interface{} { return n.reverse() }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifierList) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifierList) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 0:\n\t\treturn n.TypeQualifier.Pos()\n\tcase 1:\n\t\treturn n.TypeQualifierList.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// TypeQualifierListOpt represents data reduced by productions:\n//\n//\tTypeQualifierListOpt:\n//\t        /* empty */        // Case 0\n//\t|       TypeQualifierList  // Case 1\ntype TypeQualifierListOpt struct {\n\tTypeQualifierList *TypeQualifierList\n}\n\nfunc (n *TypeQualifierListOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeQualifierListOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeQualifierListOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.TypeQualifierList.Pos()\n}\n\n// TypeSpecifierCase represents case numbers of production TypeSpecifier\ntype TypeSpecifierCase int\n\n// Values of type TypeSpecifierCase\nconst (\n\tTypeSpecifierBool TypeSpecifierCase = iota\n\tTypeSpecifierComplex\n\tTypeSpecifierChar\n\tTypeSpecifierDouble\n\tTypeSpecifierFloat\n\tTypeSpecifierInt\n\tTypeSpecifierLong\n\tTypeSpecifierShort\n\tTypeSpecifierSigned\n\tTypeSpecifierUnsigned\n\tTypeSpecifierVoid\n\tTypeSpecifierEnum\n\tTypeSpecifierStruct\n\tTypeSpecifierName\n\tTypeSpecifierTypeofExpr\n\tTypeSpecifierTypeof\n)\n\n// String implements fmt.Stringer\nfunc (n TypeSpecifierCase) String() string {\n\tswitch n {\n\tcase TypeSpecifierBool:\n\t\treturn \"TypeSpecifierBool\"\n\tcase TypeSpecifierComplex:\n\t\treturn \"TypeSpecifierComplex\"\n\tcase TypeSpecifierChar:\n\t\treturn \"TypeSpecifierChar\"\n\tcase TypeSpecifierDouble:\n\t\treturn \"TypeSpecifierDouble\"\n\tcase TypeSpecifierFloat:\n\t\treturn \"TypeSpecifierFloat\"\n\tcase TypeSpecifierInt:\n\t\treturn \"TypeSpecifierInt\"\n\tcase TypeSpecifierLong:\n\t\treturn \"TypeSpecifierLong\"\n\tcase TypeSpecifierShort:\n\t\treturn \"TypeSpecifierShort\"\n\tcase TypeSpecifierSigned:\n\t\treturn \"TypeSpecifierSigned\"\n\tcase TypeSpecifierUnsigned:\n\t\treturn \"TypeSpecifierUnsigned\"\n\tcase TypeSpecifierVoid:\n\t\treturn \"TypeSpecifierVoid\"\n\tcase TypeSpecifierEnum:\n\t\treturn \"TypeSpecifierEnum\"\n\tcase TypeSpecifierStruct:\n\t\treturn \"TypeSpecifierStruct\"\n\tcase TypeSpecifierName:\n\t\treturn \"TypeSpecifierName\"\n\tcase TypeSpecifierTypeofExpr:\n\t\treturn \"TypeSpecifierTypeofExpr\"\n\tcase TypeSpecifierTypeof:\n\t\treturn \"TypeSpecifierTypeof\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"TypeSpecifierCase(%v)\", int(n))\n\t}\n}\n\n// TypeSpecifier represents data reduced by productions:\n//\n//\tTypeSpecifier:\n//\t        \"_Bool\"                    // Case TypeSpecifierBool\n//\t|       \"_Complex\"                 // Case TypeSpecifierComplex\n//\t|       \"char\"                     // Case TypeSpecifierChar\n//\t|       \"double\"                   // Case TypeSpecifierDouble\n//\t|       \"float\"                    // Case TypeSpecifierFloat\n//\t|       \"int\"                      // Case TypeSpecifierInt\n//\t|       \"long\"                     // Case TypeSpecifierLong\n//\t|       \"short\"                    // Case TypeSpecifierShort\n//\t|       \"signed\"                   // Case TypeSpecifierSigned\n//\t|       \"unsigned\"                 // Case TypeSpecifierUnsigned\n//\t|       \"void\"                     // Case TypeSpecifierVoid\n//\t|       EnumSpecifier              // Case TypeSpecifierEnum\n//\t|       StructOrUnionSpecifier     // Case TypeSpecifierStruct\n//\t|       TYPEDEF_NAME               // Case TypeSpecifierName\n//\t|       \"typeof\" '(' Expr ')'      // Case TypeSpecifierTypeofExpr\n//\t|       \"typeof\" '(' TypeName ')'  // Case TypeSpecifierTypeof\ntype TypeSpecifier struct {\n\tscope                  *Scope\n\ttyp                    Type // typeof\n\tCase                   TypeSpecifierCase\n\tEnumSpecifier          *EnumSpecifier\n\tExpr                   *Expr\n\tStructOrUnionSpecifier *StructOrUnionSpecifier\n\tToken                  xc.Token\n\tToken2                 xc.Token\n\tToken3                 xc.Token\n\tTypeName               *TypeName\n}\n\nfunc (n *TypeSpecifier) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *TypeSpecifier) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *TypeSpecifier) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\tswitch n.Case {\n\tcase 11:\n\t\treturn n.EnumSpecifier.Pos()\n\tcase 12:\n\t\treturn n.StructOrUnionSpecifier.Pos()\n\tcase 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15:\n\t\treturn n.Token.Pos()\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// VolatileOpt represents data reduced by productions:\n//\n//\tVolatileOpt:\n//\t        /* empty */  // Case 0\n//\t|       \"volatile\"   // Case 1\ntype VolatileOpt struct {\n\tToken xc.Token\n}\n\nfunc (n *VolatileOpt) fragment() interface{} { return n }\n\n// String implements fmt.Stringer.\nfunc (n *VolatileOpt) String() string {\n\treturn PrettyString(n)\n}\n\n// Pos reports the position of the first component of n or zero if it's empty.\nfunc (n *VolatileOpt) Pos() token.Pos {\n\tif n == nil {\n\t\treturn 0\n\t}\n\n\treturn n.Token.Pos()\n}\n"
  },
  {
    "path": "v2/ast2.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\nimport (\n\t\"fmt\"\n\t\"go/token\"\n\t\"math\"\n\t\"math/big\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/mathutil\"\n)\n\n// Node represents an AST node.\ntype Node interface {\n\tPos() token.Pos\n}\n\n// Pos implements Node.\nfunc (n *TranslationUnit) Pos() token.Pos { return token.Pos(0) }\n\n// DeclarationSpecifier describes declaration specifiers.\ntype DeclarationSpecifier struct {\n\tFunctionSpecifiers     []*FunctionSpecifier\n\tStorageClassSpecifiers []*StorageClassSpecifier\n\tTypeQualifiers         []*TypeQualifier\n\tTypeSpecifiers         []*TypeSpecifier\n\ttypeSpecifiers         []TypeSpecifierCase\n}\n\nfunc (d *DeclarationSpecifier) typ(ctx *context) Type {\n\tif d.typeSpecifiers == nil {\n\t\td.typeSpecifiers = make([]TypeSpecifierCase, len(d.TypeSpecifiers))\n\t\tfor i, v := range d.TypeSpecifiers {\n\t\t\td.typeSpecifiers[i] = v.Case\n\t\t}\n\t\tsort.Slice(d.typeSpecifiers, func(i, j int) bool { return d.typeSpecifiers[i] < d.typeSpecifiers[j] })\n\t}\n\n\t// [0]6.7.2-2\n\tif len(d.typeSpecifiers) == 1 {\n\t\tswitch d.typeSpecifiers[0] {\n\t\tcase TypeSpecifierBool:\n\t\t\treturn Bool\n\t\tcase TypeSpecifierChar:\n\t\t\treturn Char\n\t\tcase TypeSpecifierDouble:\n\t\t\treturn Double\n\t\tcase TypeSpecifierFloat:\n\t\t\treturn Float\n\t\tcase TypeSpecifierInt:\n\t\t\treturn Int\n\t\tcase TypeSpecifierLong:\n\t\t\treturn Long\n\t\tcase TypeSpecifierName:\n\t\t\tts := d.TypeSpecifiers[0]\n\t\t\tr := &NamedType{Name: ts.Token.Val}\n\t\t\tswitch x := ts.scope.LookupIdent(ts.Token.Val).(type) {\n\t\t\tcase *Declarator:\n\t\t\t\tif !x.DeclarationSpecifier.IsTypedef() {\n\t\t\t\t\tpanic(\"internal error 1\")\n\t\t\t\t}\n\n\t\t\t\tr.Type = x.Type\n\t\t\t\tt := r.Type\n\t\t\t\tfor {\n\t\t\t\t\tswitch x := t.(type) {\n\t\t\t\t\tcase\n\t\t\t\t\t\t*ArrayType,\n\t\t\t\t\t\t*EnumType,\n\t\t\t\t\t\t*FunctionType,\n\t\t\t\t\t\t*StructType,\n\t\t\t\t\t\t*UnionType:\n\n\t\t\t\t\t\treturn r\n\t\t\t\t\tcase *NamedType:\n\t\t\t\t\t\tt = x.Type\n\t\t\t\t\tcase *PointerType:\n\t\t\t\t\t\tt = x.Item\n\t\t\t\t\tcase *TaggedStructType:\n\t\t\t\t\t\tx.getType()\n\t\t\t\t\t\treturn r\n\t\t\t\t\tcase *TaggedUnionType:\n\t\t\t\t\t\tx.getType()\n\t\t\t\t\t\treturn r\n\t\t\t\t\tcase *TaggedEnumType:\n\t\t\t\t\t\tx.getType()\n\t\t\t\t\t\treturn r\n\t\t\t\t\tcase TypeKind:\n\t\t\t\t\t\tswitch x {\n\t\t\t\t\t\tcase\n\t\t\t\t\t\t\tChar,\n\t\t\t\t\t\t\tDouble,\n\t\t\t\t\t\t\tFloat,\n\t\t\t\t\t\t\tInt,\n\t\t\t\t\t\t\tLong,\n\t\t\t\t\t\t\tLongDouble,\n\t\t\t\t\t\t\tLongLong,\n\t\t\t\t\t\t\tSChar,\n\t\t\t\t\t\t\tShort,\n\t\t\t\t\t\t\tUChar,\n\t\t\t\t\t\t\tUInt,\n\t\t\t\t\t\t\tULong,\n\t\t\t\t\t\t\tULongLong,\n\t\t\t\t\t\t\tUShort,\n\t\t\t\t\t\t\tVoid:\n\n\t\t\t\t\t\t\treturn r\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tpanic(x)\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%T %v\", x, x))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t\t}\n\t\tcase TypeSpecifierShort:\n\t\t\treturn Short\n\t\tcase TypeSpecifierStruct:\n\t\t\tt := d.TypeSpecifiers[0].StructOrUnionSpecifier.typ\n\t\t\tswitch x := t.(type) {\n\t\t\tcase *TaggedStructType:\n\t\t\t\tx.getType()\n\t\t\tcase *TaggedUnionType:\n\t\t\t\tx.getType()\n\t\t\t}\n\t\t\treturn t\n\t\tcase TypeSpecifierSigned:\n\t\t\treturn Int\n\t\tcase TypeSpecifierUnsigned:\n\t\t\treturn UInt\n\t\tcase TypeSpecifierVoid:\n\t\t\treturn Void\n\t\tcase TypeSpecifierEnum:\n\t\t\tt := d.TypeSpecifiers[0].EnumSpecifier.typ\n\t\t\tif x, ok := t.(*TaggedEnumType); ok {\n\t\t\t\tx.getType()\n\t\t\t}\n\t\t\treturn t\n\t\tcase\n\t\t\tTypeSpecifierTypeof,\n\t\t\tTypeSpecifierTypeofExpr:\n\n\t\t\treturn d.TypeSpecifiers[0].typ\n\t\tdefault:\n\t\t\tpanic(d.typeSpecifiers)\n\t\t}\n\t}\n\n\tswitch {\n\tcase d.is(TypeSpecifierChar, TypeSpecifierSigned):\n\t\treturn SChar\n\tcase d.is(TypeSpecifierChar, TypeSpecifierUnsigned):\n\t\treturn UChar\n\tcase d.is(TypeSpecifierComplex, TypeSpecifierDouble):\n\t\treturn DoubleComplex\n\tcase d.is(TypeSpecifierComplex, TypeSpecifierDouble, TypeSpecifierLong):\n\t\treturn LongDoubleComplex\n\tcase d.is(TypeSpecifierComplex, TypeSpecifierFloat):\n\t\treturn FloatComplex\n\tcase d.is(TypeSpecifierDouble, TypeSpecifierLong):\n\t\treturn LongDouble\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong):\n\t\treturn Long\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong, TypeSpecifierLong):\n\t\treturn LongLong\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong, TypeSpecifierLong, TypeSpecifierUnsigned):\n\t\treturn ULongLong\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong, TypeSpecifierSigned):\n\t\treturn Long\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong, TypeSpecifierLong, TypeSpecifierSigned):\n\t\treturn LongLong\n\tcase d.is(TypeSpecifierInt, TypeSpecifierLong, TypeSpecifierUnsigned):\n\t\treturn ULong\n\tcase d.is(TypeSpecifierInt, TypeSpecifierShort):\n\t\treturn Short\n\tcase d.is(TypeSpecifierInt, TypeSpecifierShort, TypeSpecifierSigned):\n\t\treturn Short\n\tcase d.is(TypeSpecifierInt, TypeSpecifierShort, TypeSpecifierUnsigned):\n\t\treturn UShort\n\tcase d.is(TypeSpecifierInt, TypeSpecifierSigned):\n\t\treturn Int\n\tcase d.is(TypeSpecifierInt, TypeSpecifierUnsigned):\n\t\treturn UInt\n\tcase d.is(TypeSpecifierLong, TypeSpecifierLong):\n\t\treturn LongLong\n\tcase d.is(TypeSpecifierLong, TypeSpecifierSigned):\n\t\treturn Long\n\tcase d.is(TypeSpecifierLong, TypeSpecifierUnsigned):\n\t\treturn ULong\n\tcase d.is(TypeSpecifierLong, TypeSpecifierLong, TypeSpecifierSigned):\n\t\treturn LongLong\n\tcase d.is(TypeSpecifierLong, TypeSpecifierLong, TypeSpecifierUnsigned):\n\t\treturn ULongLong\n\tcase d.is(TypeSpecifierShort, TypeSpecifierUnsigned):\n\t\treturn UShort\n\tcase d.is(TypeSpecifierShort, TypeSpecifierSigned):\n\t\treturn Short\n\tdefault:\n\t\tpanic(d.typeSpecifiers)\n\t}\n}\n\nfunc (d *DeclarationSpecifier) is(a ...TypeSpecifierCase) bool {\n\tif d == nil {\n\t\treturn false\n\t}\n\n\tif len(d.typeSpecifiers) != len(a) {\n\t\treturn false\n\t}\n\n\tfor i, v := range a {\n\t\tif v != d.typeSpecifiers[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// IsTypedef reports whether the storage class specifier \"typedef\" is present.\nfunc (d *DeclarationSpecifier) IsTypedef() bool {\n\tif d == nil {\n\t\treturn false\n\t}\n\n\tfor _, v := range d.StorageClassSpecifiers {\n\t\tif v.Case == StorageClassSpecifierTypedef {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// IsStatic reports whether the storage class specifier \"static\" is present.\nfunc (d *DeclarationSpecifier) IsStatic() bool {\n\tif d == nil {\n\t\treturn false\n\t}\n\n\tfor _, v := range d.StorageClassSpecifiers {\n\t\tif v.Case == StorageClassSpecifierStatic {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// IsExtern reports whether the storage class specifier \"extern\" is present.\nfunc (d *DeclarationSpecifier) IsExtern() bool {\n\tif d == nil {\n\t\treturn false\n\t}\n\n\tfor _, v := range d.StorageClassSpecifiers {\n\t\tif v.Case == StorageClassSpecifierExtern {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc (n *ConstExpr) eval(ctx *context) Operand {\n\tif n.Operand.Type == nil {\n\t\tn.Operand = n.Expr.eval(ctx, true, nil, nil, nil)\n\t\tif n.Operand.Value == nil { // not a constant expression\n\t\t\tpanic(fmt.Errorf(\"TODO247 %v\", ctx.position(n)))\n\t\t}\n\t}\n\treturn n.Operand\n}\n\nfunc (n *Expr) eval(ctx *context, arr2ptr bool, fn *Declarator, seq *int, sc []int) Operand {\n\tif n.Operand.Type != nil {\n\t\treturn n.Operand\n\t}\n\n\tdefer func() {\n\t\tif n.Operand.Type != nil && n.Operand.Type.IsArithmeticType() {\n\t\t\tn.Operand = n.Operand.normalize(ctx.model)\n\t\t}\n\t}()\n\nouter:\n\tswitch n.Case {\n\tcase ExprPreInc: // \"++\" Expr\n\t\t// [0]6.5.3.1\n\t\t//\n\t\t// The operand of the prefix increment or decrement operator\n\t\t// shall have qualified or unqualified real or pointer type and\n\t\t// shall be a modifiable lvalue.\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !n.Operand.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprPreDec: // \"--\" Expr\n\t\t// [0]6.5.3.1\n\t\t//\n\t\t// The operand of the prefix increment or decrement operator\n\t\t// shall have qualified or unqualified real or pointer type and\n\t\t// shall be a modifiable lvalue.\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !n.Operand.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprAlignofType: // \"__alignof__\" '(' TypeName ')'\n\t\tt := n.TypeName.check(ctx)\n\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: int64(ctx.model.Alignof(t))}}\n\tcase ExprAlignofExpr: // \"__alignof__\" Expr\n\t\top := n.Expr.eval(ctx, false, fn, seq, sc)\n\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: int64(ctx.model.Alignof(underlyingType(op.Type, false)))}}\n\tcase ExprSizeofType: // \"sizeof\" '(' TypeName ')'\n\t\tt := n.TypeName.check(ctx)\n\t\tn.Operand = ctx.sizeof(t)\n\tcase ExprSizeofExpr: // \"sizeof\" Expr\n\t\t// [0]6.5.3.4\n\t\tswitch t := n.Expr.eval(ctx, false, fn, seq, sc).Type.(type) { // [0]6.3.2.1-3\n\t\tcase *ArrayType:\n\t\t\tif t.Size.Type == nil {\n\t\t\t\tpanic(fmt.Errorf(\"%v\", ctx.position(n)))\n\t\t\t}\n\n\t\t\tswitch d := n.Expr.Declarator; {\n\t\t\tcase d != nil && d.IsFunctionParameter:\n\t\t\t\tn.Operand = ctx.sizeof(Ptr)\n\t\t\tdefault:\n\t\t\t\tn.Operand = t.Size.mul(ctx, ctx.sizeof(t.Item))\n\t\t\t}\n\t\tcase\n\t\t\t*PointerType,\n\t\t\t*StructType,\n\t\t\t*TaggedStructType,\n\t\t\t*TaggedUnionType,\n\t\t\t*UnionType:\n\n\t\t\tn.Operand = ctx.sizeof(t)\n\t\tcase *NamedType:\n\t\t\tn.Operand = ctx.sizeof(t.Type)\n\t\tcase TypeKind:\n\t\t\tswitch t {\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tDouble,\n\t\t\t\tFloat,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDouble,\n\t\t\t\tLongLong,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort:\n\n\t\t\t\tn.Operand = ctx.sizeof(t)\n\t\t\tdefault:\n\t\t\t\tpanic(t)\n\t\t\t}\n\t\tdefault:\n\t\t\t//dbg(\"\", ctx.position(n))\n\t\t\tpanic(t)\n\t\t}\n\t\tif n.Operand.Value == nil {\n\t\t\tpanic(fmt.Errorf(\"%v\", ctx.position(n)))\n\t\t}\n\tcase ExprNot: // '!' Expr\n\t\tn.Operand = Operand{Type: Int}\n\t\ta := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif a.IsZero() { //TODO n.Expr.IsZero everywhere\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tbreak\n\t\t}\n\n\t\tif a.IsNonZero() { //TODO n.Expr.IsNonZero everywhere\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t}\n\tcase ExprAddrof: // '&' Expr\n\t\t// [0]6.5.3.2\n\t\top := n.Expr.eval(ctx, false, fn, seq, sc) // [0]6.3.2.1-3\n\t\tn.Operand = Operand{Type: &PointerType{op.Type}}\n\t\tif d := n.Expr.Declarator; d != nil && n.Expr.Case != ExprPSelect {\n\t\t\td.AddressTaken = true\n\t\t}\n\t\tn.Operand.Value = op.Value\n\tcase ExprPExprList: // '(' ExprList ')'\n\t\tn.Operand = n.ExprList.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tn.Declarator = n.ExprList.declarator(ctx)\n\tcase ExprCompLit: // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\tt := n.TypeName.check(ctx)\n\t\tn.Operand = Operand{Type: t}\n\t\tif n.InitializerList == nil {\n\t\t\tn.InitializerList = &InitializerList{}\n\t\t}\n\t\tn.InitializerList.check(ctx, t, fn)\n\t\tif fn == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tnmTok := n.Token\n\t\tnmTok.Char.Rune = IDENTIFIER\n\t\tfn.unnamed++\n\t\tnmTok.Val = dict.SID(fmt.Sprintf(\"unnamed%d\", fn.unnamed))\n\t\td := &Declarator{\n\t\t\tDirectDeclarator: &DirectDeclarator{\n\t\t\t\tCase:  DirectDeclaratorIdent,\n\t\t\t\tToken: nmTok,\n\t\t\t},\n\t\t\tInitializer: &Initializer{\n\t\t\t\tCase:            InitializerCompLit,\n\t\t\t\tInitializerList: n.InitializerList,\n\t\t\t},\n\t\t\tReferenced: 1,\n\t\t\tScope:      n.Scope,\n\t\t\tType:       t,\n\t\t}\n\t\tn.Declarator = d\n\t\tfn.vars = append(fn.vars, d)\n\tcase ExprCast: // '(' TypeName ')' Expr\n\t\t// [0]6.5.4\n\t\tt := n.TypeName.check(ctx)\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif t == Void {\n\t\t\tn.Operand = Operand{Type: Void}\n\t\t\tbreak\n\t\t}\n\tmore:\n\t\tswitch x := t.(type) {\n\t\tcase *EnumType:\n\t\t\tn.Operand = op.ConvertTo(ctx.model, t)\n\t\tcase *PointerType:\n\t\t\t//dbg(\"\", ctx.position(n), t, op)\n\t\t\tn.Operand = op.ConvertTo(ctx.model, t)\n\t\tcase *NamedType:\n\t\t\tt = x.Type\n\t\t\tgoto more\n\t\tcase *TaggedEnumType:\n\t\t\tn.Operand = op.ConvertTo(ctx.model, t)\n\t\tcase *TaggedStructType:\n\t\t\tn.Operand.Type = t\n\t\tcase *TaggedUnionType:\n\t\t\tn.Operand = op.ConvertTo(ctx.model, t)\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tDouble,\n\t\t\t\tDoubleComplex,\n\t\t\t\tFloat,\n\t\t\t\tFloatComplex,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDouble,\n\t\t\t\tLongDoubleComplex,\n\t\t\t\tLongLong,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort:\n\n\t\t\t\tn.Operand = op.ConvertTo(ctx.model, t)\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t}\n\t\tif n.Expr.Operand.Value != nil {\n\t\t\top := n.Expr.Operand.ConvertTo(ctx.model, t)\n\t\t\tn.Operand.Value = op.Value\n\t\t}\n\tcase ExprDeref: // '*' Expr\n\t\t// [0]6.5.3\n\t\tif !arr2ptr && n.Expr.Case == ExprCall { // int *f(); int *p = &*f();\n\t\t\tarr2ptr = true\n\t\t}\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tfor t, done := op.Type, false; !done; {\n\t\t\tswitch x := t.(type) {\n\t\t\tcase *ArrayType:\n\t\t\t\tn.Operand = Operand{Type: x.Item}\n\t\t\t\tdone = true\n\t\t\tcase *NamedType:\n\t\t\t\tt = x.Type\n\t\t\tcase *PointerType:\n\t\t\t\tn.Operand = Operand{Type: x.Item}\n\t\t\t\tdone = true\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: ExprDeref %v, arr2ptr %v\", ctx.position(n), op, arr2ptr))\n\t\t\t}\n\t\t}\n\tcase ExprUnaryPlus: // '+' Expr\n\t\t// [0]6.5.3.3\n\t\t// The operand of the unary + or - operator shall have\n\t\t// arithmetic type; of the ~ operator, integer type; of the !\n\t\t// operator, scalar type.\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !op.isArithmeticType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Operand = op.integerPromotion(ctx.model)\n\tcase ExprUnaryMinus: // '-' Expr\n\t\t// [0]6.5.3.3\n\t\t// The operand of the unary + or - operator shall have\n\t\t// arithmetic type; of the ~ operator, integer type; of the !\n\t\t// operator, scalar type.\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !op.isArithmeticType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Operand = op.unaryMinus(ctx)\n\tcase ExprCpl: // '~' Expr\n\t\t// [0]6.5.3.3\n\t\t// The operand of the unary + or - operator shall have\n\t\t// arithmetic type; of the ~ operator, integer type; of the !\n\t\t// operator, scalar type.\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc).integerPromotion(ctx.model)\n\t\tif !op.Type.IsIntegerType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Operand = op.cpl(ctx)\n\tcase ExprChar: // CHARCONST\n\t\tn.Operand = ctx.charConst(n.Token)\n\tcase ExprNe: // Expr \"!=\" Expr\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: 0}}\n\t\t\tbreak\n\t\t}\n\n\t\t// [0]6.5.9\n\t\tswitch {\n\t\t// One of the following shall hold:\n\t\tcase\n\t\t\t// both operands have arithmetic type\n\t\t\tlhs.isArithmeticType() && rhs.isArithmeticType():\n\n\t\t\tn.Operand = lhs.ne(ctx, rhs)\n\t\t\t// fmt.Printf(\"TODO497 %v\\n\", ctx.position(n))\n\t\t\t// n.Operand = n.Operand.normalize(ctx.model)\n\t\t\t// n.DumpOperands(\"· \") //TODO-\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null\n\t\t\t// pointer constant.\n\t\t\tlhs.isPointerType() && rhs.isNullPtrConst():\n\n\t\t\tn.Operand = Operand{Type: Int}\n\t\t\tswitch {\n\t\t\tcase n.Expr.IsNonZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tcase n.Expr.IsZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\t}\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null\n\t\t\t// pointer constant.\n\t\t\tlhs.isNullPtrConst() && rhs.isPointerType():\n\n\t\t\tn.Operand = Operand{Type: Int}\n\t\t\tswitch {\n\t\t\tcase n.Expr2.IsNonZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tcase n.Expr2.IsZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\t}\n\t\tcase\n\t\t\t// both operands are pointers to qualified or unqualified versions of compatible types\n\t\t\tlhs.isPointerType() && rhs.isPointerType() && (lhs.Type.IsCompatible(rhs.Type) || ctx.tweaks.EnablePointerCompatibility):\n\n\t\t\tn.Operand = Operand{Type: Int}\n\t\t\tif n.Expr.Case == ExprAddrof && n.Expr.Expr.Case == ExprIdent &&\n\t\t\t\tn.Expr2.Case == ExprAddrof && n.Expr2.Expr.Case == ExprIdent {\n\t\t\t\tvar val int64\n\t\t\t\tif n.Expr.Expr.Token.Val != n.Expr2.Expr.Token.Val {\n\t\t\t\t\tval = 1\n\t\t\t\t}\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: val}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v %v\", ctx.position(n), lhs, rhs))\n\t\t}\n\tcase ExprModAssign: // Expr \"%=\" Expr\n\t\t// [0]6.5.16.2\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).mod(ctx, n, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprLAnd: // Expr \"&&\" Expr\n\t\tn.Operand = Operand{Type: Int}\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif n.Expr.IsZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\tbreak\n\t\t}\n\n\t\tn.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif n.Expr2.IsZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\tbreak\n\t\t}\n\n\t\tif n.Expr.IsNonZero() && n.Expr2.IsNonZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tbreak\n\t\t}\n\tcase ExprAndAssign: // Expr \"&=\" Expr\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).and(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprMulAssign: // Expr \"*=\" Expr\n\t\t// [0]6.5.16.2\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).mul(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprPostInc: // Expr \"++\"\n\t\t// [0]6.5.2.4\n\t\t//\n\t\t// The operand of the postfix increment or decrement operator\n\t\t// shall have qualified or unqualified real or pointer type and\n\t\t// shall be a modifiable lvalue.\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !n.Operand.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprAddAssign: // Expr \"+=\" Expr\n\t\t// [0]6.5.16.2\n\t\t//\n\t\t// 1. For the operators += and -= only, either the left operand\n\t\t// shall be a pointer to an object type and the right shall\n\t\t// have integer type, or the left operand shall have qualified\n\t\t// or unqualified arithmetic type and the right shall have\n\t\t// arithmetic type.\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tswitch {\n\t\tcase\n\t\t\tlhs.isPointerType() && rhs.isIntegerType(),\n\t\t\tlhs.isArithmeticType() && rhs.isArithmeticType():\n\n\t\t\t// ok\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Operand = lhs\n\tcase ExprPostDec: // Expr \"--\"\n\t\t// [0]6.5.2.4\n\t\t//\n\t\t// The operand of the postfix increment or decrement operator\n\t\t// shall have qualified or unqualified real or pointer type and\n\t\t// shall be a modifiable lvalue.\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif !n.Operand.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprSubAssign: // Expr \"-=\" Expr\n\t\t// [0]6.5.16.2\n\t\t//\n\t\t// 1. For the operators += and -= only, either the left operand\n\t\t// shall be a pointer to an object type and the right shall\n\t\t// have integer type, or the left operand shall have qualified\n\t\t// or unqualified arithmetic type and the right shall have\n\t\t// arithmetic type.\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tswitch {\n\t\tcase\n\t\t\tlhs.isPointerType() && rhs.isIntegerType(),\n\t\t\tlhs.isArithmeticType() && rhs.isArithmeticType():\n\n\t\t\t// ok\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Operand = lhs\n\tcase ExprPSelect: // Expr \"->\" IDENTIFIER\n\t\tn.Expr.AssignedTo = n.AssignedTo\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif d := n.Expr.Declarator; d != nil && n.AssignedTo {\n\t\t\td.AssignedTo++\n\t\t}\n\t\tt := op.Type\n\t\tfor done := false; !done; {\n\t\t\tswitch x := t.(type) {\n\t\t\tcase *ArrayType:\n\t\t\t\tt = x.Item\n\t\t\t\tdone = true\n\t\t\tcase *NamedType:\n\t\t\t\tt = x.Type\n\t\t\tcase *PointerType:\n\t\t\t\tt = x.Item\n\t\t\t\tdone = true\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t\t}\n\t\t}\n\tout:\n\t\tfor {\n\t\t\tswitch x := t.(type) {\n\t\t\tcase *NamedType:\n\t\t\t\tt = x.Type\n\t\t\tcase *StructType:\n\t\t\t\tctx.model.Layout(x)\n\t\t\t\tfp := x.Field(n.Token2.Val)\n\t\t\t\tif fp == nil {\n\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t}\n\n\t\t\t\tn.Operand = Operand{Type: fp.Declarator.Type}\n\t\t\t\tn.Operand.FieldProperties = fp\n\t\t\t\tif op.Value == Null {\n\t\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: fp.Offset}\n\t\t\t\t}\n\t\t\t\tbreak out\n\t\t\tcase *TaggedStructType:\n\t\t\t\tt = x.getType()\n\t\t\t\tif t == x {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %q\", ctx.position(n), dict.S(x.Tag)))\n\t\t\t\t}\n\t\t\tcase *TaggedUnionType:\n\t\t\t\tt = x.getType()\n\t\t\t\tif t == x {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %q\", ctx.position(n), dict.S(x.Tag)))\n\t\t\t\t}\n\t\t\tcase *UnionType:\n\t\t\t\tctx.model.Layout(x)\n\t\t\t\tfp := x.Field(n.Token2.Val)\n\t\t\t\tif fp == nil {\n\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t}\n\n\t\t\t\tn.Operand = Operand{Type: fp.Declarator.Type}\n\t\t\t\tn.Operand.FieldProperties = fp\n\t\t\t\tif op.Value == Null {\n\t\t\t\t\tn.Operand.Value = &ir.Int64Value{}\n\t\t\t\t}\n\t\t\t\tbreak out\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\t}\n\tcase ExprSelect: // Expr '.' IDENTIFIER\n\t\tn.Expr.AssignedTo = n.AssignedTo\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif d := n.Expr.Declarator; d != nil && n.AssignedTo {\n\t\t\td.AssignedTo++\n\t\t}\n\t\tt := op.Type\n\tout3:\n\t\tfor {\n\t\t\tswitch x := t.(type) {\n\t\t\tcase *NamedType:\n\t\t\t\tt = x.Type\n\t\t\tcase *StructType:\n\t\t\t\tctx.model.Layout(x)\n\t\t\t\tfp := x.Field(n.Token2.Val)\n\t\t\t\tif fp == nil {\n\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t}\n\n\t\t\t\tn.Operand = Operand{Type: fp.Declarator.Type}\n\t\t\t\tn.Operand.FieldProperties = fp\n\t\t\t\tbreak out3\n\t\t\tcase *TaggedStructType:\n\t\t\t\ty := x.getType()\n\t\t\t\tif x == y {\n\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t}\n\n\t\t\t\tt = y\n\t\t\tcase *TaggedUnionType:\n\t\t\t\ty := x.getType()\n\t\t\t\tif x == y {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\t}\n\n\t\t\t\tt = y\n\t\t\tcase *UnionType:\n\t\t\t\tctx.model.Layout(x)\n\t\t\t\tfp := x.Field(n.Token2.Val)\n\t\t\t\tif fp == nil {\n\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t}\n\n\t\t\t\tn.Operand = Operand{Type: fp.Declarator.Type}\n\t\t\t\tn.Operand.FieldProperties = fp\n\t\t\t\tbreak out3\n\t\t\tdefault:\n\t\t\t\t//dbg(\"%v: %T\", ctx.position(n), x)\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\t}\n\t\tif d := n.Expr.Declarator; d != nil {\n\t\t\td.Referenced++\n\t\t\td.AddressTaken = true\n\t\t}\n\tcase ExprDivAssign: // Expr \"/=\" Expr\n\t\t// [0]6.5.16.2\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).div(ctx, n, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprLsh: // Expr \"<<\" Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).lsh(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\tcase ExprLshAssign: // Expr \"<<=\" Expr\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).lsh(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprLe: // Expr \"<=\" Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).le(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: 1}}\n\t\t}\n\tcase ExprEq: // Expr \"==\" Expr\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tswitch x := underlyingType(lhs.Type, true).(type) {\n\t\tcase *EnumType:\n\t\t\tn.Expr2.enum = x\n\t\t}\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tn.Operand.Type = Int\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tbreak\n\t\t}\n\n\t\t// [0]6.5.9\n\t\tswitch {\n\t\t// One of the following shall hold:\n\t\tcase\n\t\t\t// both operands have arithmetic type\n\t\t\tlhs.isArithmeticType() && rhs.isArithmeticType():\n\n\t\t\tn.Operand = lhs.eq(ctx, rhs)\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null\n\t\t\t// pointer constant.\n\t\t\tlhs.isPointerType() && rhs.isNullPtrConst():\n\n\t\t\tswitch {\n\t\t\tcase n.Expr.IsNonZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\tcase n.Expr.IsZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\t}\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null\n\t\t\t// pointer constant.\n\t\t\tlhs.isNullPtrConst() && rhs.isPointerType():\n\n\t\t\tswitch {\n\t\t\tcase n.Expr2.IsNonZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\tcase n.Expr2.IsZero():\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\t}\n\t\tcase\n\t\t\t// both operands are pointers to qualified or unqualified versions of compatible types\n\t\t\tlhs.isPointerType() && rhs.isPointerType() && (lhs.Type.IsCompatible(rhs.Type) || ctx.tweaks.EnablePointerCompatibility):\n\n\t\t\tif n.Expr.Case == ExprAddrof && n.Expr.Expr.Case == ExprIdent &&\n\t\t\t\tn.Expr2.Case == ExprAddrof && n.Expr2.Expr.Case == ExprIdent {\n\t\t\t\tvar val int64\n\t\t\t\tif n.Expr.Expr.Token.Val == n.Expr2.Expr.Token.Val {\n\t\t\t\t\tval = 1\n\t\t\t\t}\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: val}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v %v\", ctx.position(n), lhs, rhs))\n\t\t}\n\tcase ExprGe: // Expr \">=\" Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).ge(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: 1}}\n\t\t}\n\tcase ExprRsh: // Expr \">>\" Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).rsh(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\tcase ExprRshAssign: // Expr \">>=\" Expr\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).rsh(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprXorAssign: // Expr \"^=\" Expr\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).xor(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprOrAssign: // Expr \"|=\" Expr\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc).or(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tn.Operand = n.Expr.Operand\n\tcase ExprLOr: // Expr \"||\" Expr\n\t\tn.Operand = Operand{Type: Int}\n\t\tn.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif n.Expr.IsNonZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tbreak\n\t\t}\n\n\t\tn.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif n.Expr2.IsNonZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 1}\n\t\t\tbreak\n\t\t}\n\n\t\tif n.Expr.IsZero() && n.Expr2.IsZero() {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t}\n\tcase ExprMod: // Expr '%' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).mod(ctx, n, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)) // [0]6.5.5\n\tcase ExprAnd: // Expr '&' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).and(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.isSideEffectsFree() {\n\t\t\t// x & (x | y) == x\n\t\t\tx, y := n.Expr, n.Expr2\n\t\t\tif y.Case == ExprIdent {\n\t\t\t\tx, y = y, x\n\t\t\t}\n\t\t\tif x.Case == ExprIdent && y.Case == ExprPExprList && y.ExprList.ExprList == nil {\n\t\t\t\tif z := y.ExprList.Expr; z.Case == ExprOr {\n\t\t\t\t\tif z.Expr.Case == ExprIdent && z.Expr.Token.Val == x.Token.Val ||\n\t\t\t\t\t\tz.Expr2.Case == ExprIdent && z.Expr2.Token.Val == x.Token.Val {\n\t\t\t\t\t\t*n = *x\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\tcase ExprCall: // Expr '(' ArgumentExprListOpt ')'\n\t\tif n.Expr.Case == ExprIdent {\n\t\t\tswitch n.Expr.Token.Val {\n\t\t\tcase idBuiltinTypesCompatible:\n\t\t\t\t// using #define __builtin_types_compatible_p(type1, type2) __builtin_types_compatible__((type1){}, (type2){})\n\t\t\t\to := n.ArgumentExprListOpt\n\t\t\t\tif o == nil {\n\t\t\t\t\tpanic(\"missing arguments of __builtin_types_compatible_p\")\n\t\t\t\t}\n\n\t\t\t\targs := o.ArgumentExprList\n\t\t\t\targ1 := args.Expr\n\t\t\t\tif arg1.Case != ExprCompLit { // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\t\t\t\tpanic(\"invalid argument of __builtin_types_compatible__p\")\n\t\t\t\t}\n\n\t\t\t\targs = args.ArgumentExprList\n\t\t\t\tif args == nil {\n\t\t\t\t\tpanic(\"missing argument of __builtin_types_compatible_p\")\n\t\t\t\t}\n\n\t\t\t\targ2 := args.Expr\n\t\t\t\tif arg2.Case != ExprCompLit { // '(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\t\t\t\tpanic(\"invalid argument of __builtin_types_compatible__\")\n\t\t\t\t}\n\n\t\t\t\tif args.ArgumentExprList != nil {\n\t\t\t\t\tpanic(\"too many arguments of __builtin_types_compatible_p\")\n\t\t\t\t}\n\n\t\t\t\tt := arg1.eval(ctx, arr2ptr, fn, seq, sc).Type\n\t\t\t\tu := arg2.eval(ctx, arr2ptr, fn, seq, sc).Type\n\t\t\t\tvar v int64\n\t\t\t\tif t.IsCompatible(u) {\n\t\t\t\t\tv = 1\n\t\t\t\t}\n\t\t\t\tn.Operand.Type = Int\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: v}\n\t\t\t\tbreak outer\n\t\t\tcase idBuiltinClasifyType:\n\t\t\t\to := n.ArgumentExprListOpt\n\t\t\t\tif o == nil {\n\t\t\t\t\tpanic(\"missing argument of __builtin_classify_type\")\n\t\t\t\t}\n\n\t\t\t\targs := o.ArgumentExprList\n\t\t\t\tif args.ArgumentExprList != nil {\n\t\t\t\t\tpanic(\"too many arguments of __builtin_classify_type\")\n\t\t\t\t}\n\n\t\t\t\top := args.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t\t\tv := noTypeClass\n\t\t\t\tif x, ok := classifyType[op.Type.Kind()]; ok {\n\t\t\t\t\tv = x\n\t\t\t\t}\n\t\t\t\tn.Case = ExprInt\n\t\t\t\tn.Operand.Type = Int\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: int64(v)}\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t}\n\n\t\t// [0]6.5.2.2\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\targs := n.ArgumentExprListOpt.eval(ctx, fn, seq, sc)\n\t\tops := make([]Operand, len(args))\n\t\tn.CallArgs = ops\n\t\tt := checkFn(ctx, op.Type)\n\t\tif t == nil {\n\t\t\tif !ctx.tweaks.EnableImplicitDeclarations {\n\t\t\t\tpanic(ctx.position(n))\n\t\t\t}\n\n\t\t\tif n.Expr.Case == ExprIdent && n.Expr.Token.Val == idAsm {\n\t\t\t\tpanic(ctx.position(n).String())\n\t\t\t}\n\n\t\t\tn.Operand = Operand{Type: Int}\n\t\t\tbreak\n\t\t}\n\n\t\tif _, ok := t.Result.(*ArrayType); ok {\n\t\t\tpanic(ctx.position)\n\t\t}\n\n\t\tn.Operand = Operand{Type: t.Result}\n\n\t\t// 2. If the expression that denotes the called function has a\n\t\t// type that includes a prototype, the number of arguments\n\t\t// shall agree with the number of parameters. Each argument\n\t\t// shall have a type such that its value may be assigned to an\n\t\t// object with the unqualified version of the type of its\n\t\t// corresponding parameter.\n\t\tparams := t.Params\n\t\tvar voidParams bool\n\t\tif voidParams = len(params) == 1 && params[0].Kind() == Void; voidParams {\n\t\t\tparams = nil\n\t\t}\n\t\tswitch {\n\t\tcase voidParams && len(args) != 0:\n\t\t\tpanic(fmt.Errorf(\"%v: %v args %v params %v variadic %v voidParams %v\", ctx.position(n), n.Case, len(args), len(params), t.Variadic, voidParams))\n\t\tcase len(args) < len(params):\n\t\t\tpanic(fmt.Errorf(\"%v: %v args %v params %v variadic %v voidParams %v\", ctx.position(n), n.Case, len(args), len(params), t.Variadic, voidParams))\n\t\tcase len(args) == len(params):\n\t\t\tfor i, rhs := range args {\n\t\t\t\tswitch {\n\t\t\t\tcase rhs.Type.Kind() == Ptr && t.Params[i].IsIntegerType():\n\t\t\t\t\tops[i] = rhs.ConvertTo(ctx.model, t.Params[i])\n\t\t\t\tdefault:\n\t\t\t\t\tops[i] = AdjustedParameterType(t.Params[i]).assign(ctx, n, rhs)\n\t\t\t\t}\n\t\t\t}\n\n\t\t// len(args) > len(params)\n\t\tcase t.Variadic:\n\t\t\tfor i, rhs := range args {\n\t\t\t\tswitch {\n\t\t\t\tcase i >= len(t.Params):\n\t\t\t\t\tops[i] = ctx.model.defaultArgumentPromotion(rhs)\n\t\t\t\tcase rhs.Type.Kind() == Ptr && t.Params[i].IsIntegerType():\n\t\t\t\t\tops[i] = rhs.ConvertTo(ctx.model, t.Params[i])\n\t\t\t\tdefault:\n\t\t\t\t\tops[i] = AdjustedParameterType(t.Params[i]).assign(ctx, n, rhs)\n\t\t\t\t}\n\t\t\t}\n\t\tcase len(params) == 0:\n\t\t\tfor i, rhs := range args {\n\t\t\t\tops[i] = ctx.model.defaultArgumentPromotion(rhs)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v args %v params %v variadic %v voidParams %v\", ctx.position(n), n.Case, len(args), len(params), t.Variadic, voidParams))\n\t\t}\n\n\t\tfor i, v := range ops {\n\t\t\tif v.Value != nil {\n\t\t\t\tops[i] = v.ConvertTo(ctx.model, ops[i].Type)\n\t\t\t}\n\t\t}\n\tcase ExprMul: // Expr '*' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).mul(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\tcase ExprAdd: // Expr '+' Expr\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t// [0]6.5.6\n\t\t//\n\t\t// For addition, either both operands shall have arithmetic\n\t\t// type, or one operand shall be a pointer to an object type\n\t\t// and the other shall have integer type. (Incrementing is\n\t\t// equivalent to adding 1.)\n\t\tswitch {\n\t\tcase lhs.isArithmeticType() && rhs.isArithmeticType():\n\t\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).add(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tcase lhs.isPointerType() && rhs.isIntegerType():\n\t\t\tn.Operand = lhs\n\t\t\tn.Operand.Value = nil\n\t\tcase lhs.isIntegerType() && rhs.isPointerType():\n\t\t\tn.Operand = rhs\n\t\t\tn.Operand.Value = nil\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprSub: // Expr '-' Expr\n\t\t// [0]6.5.6\n\t\tlhs := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tswitch {\n\t\t// 3. For subtraction, one of the following shall hold:\n\t\tcase\n\t\t\t// both operands have arithmetic type;\n\t\t\tlhs.isArithmeticType() && rhs.isArithmeticType():\n\n\t\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).sub(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\t\tif n.Operand.Type.IsIntegerType() && n.Expr.Equals(n.Expr2) {\n\t\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t\t}\n\t\tcase\n\t\t\t// both operands are pointers to qualified or\n\t\t\t// unqualified versions of compatible object types;\n\t\t\tlhs.isPointerType() && rhs.isPointerType() && (lhs.Type.IsCompatible(rhs.Type) || ctx.tweaks.EnablePointerCompatibility):\n\n\t\t\tn.Operand = Operand{Type: ctx.ptrDiff()}\n\t\t\tif rhs.IsZero() {\n\t\t\t\tn.Operand.Value = lhs.Value\n\t\t\t}\n\t\tcase\n\t\t\t// the left operand is a pointer to an object type and\n\t\t\t// the right operand has integer type.\n\t\t\tlhs.isPointerType() && rhs.isIntegerType():\n\n\t\t\tn.Operand = lhs\n\t\tdefault:\n\t\t\t//dbg(\"\", lhs, rhs)\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase ExprDiv: // Expr '/' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).div(ctx, n, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)) // [0]6.5.5\n\tcase ExprLt: // Expr '<' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).lt(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: 0}}\n\t\t}\n\tcase ExprAssign: // Expr '=' Expr\n\t\tn.Expr.AssignedTo = true\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tif d := n.Expr.Declarator; d != nil {\n\t\t\td.AssignedTo++\n\t\t\tif n.Expr.Case == ExprIdent {\n\t\t\t\tn.Operand.Type = d.Type\n\t\t\t}\n\t\t}\n\t\tswitch x := underlyingType(n.Operand.Type, true).(type) {\n\t\tcase *EnumType:\n\t\t\tn.Expr2.enum = x\n\t\t}\n\t\trhs := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tn.Operand.Type.assign(ctx, n, rhs)\n\tcase ExprGt: // Expr '>' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).gt(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand = Operand{Type: Int, Value: &ir.Int64Value{Value: 0}}\n\t\t}\n\tcase ExprCond: // Expr '?' ExprList ':' Expr\n\t\t// [0]6.5.15\n\t\tcond := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t// 2. The first operand shall have scalar type.\n\t\tif !cond.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\n\t\tswitch {\n\t\tcase cond.IsNonZero():\n\t\t\tn.Operand = n.ExprList.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t\tbreak outer\n\t\tcase cond.IsZero():\n\t\t\tn.Operand = n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t\tbreak outer\n\t\t}\n\n\t\ta := n.ExprList.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tb := n.Expr2.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tswitch {\n\t\t// 3. One of the following shall hold for the second and third\n\t\t// operands:\n\t\tcase\n\t\t\t// both operands have arithmetic type;\n\t\t\ta.isArithmeticType() && b.isArithmeticType():\n\n\t\t\t// 5. If both the second and third operands have\n\t\t\t// arithmetic type, the result type that would be\n\t\t\t// determined by the usual arithmetic conversions, were\n\t\t\t// they applied to those two operands, is the type of\n\t\t\t// the result.\n\t\t\tx, _ := UsualArithmeticConversions(ctx.model, a, b)\n\t\t\tn.Operand = Operand{Type: x.Type}\n\t\tcase\n\t\t\t// both operands have the same structure or union type\n\t\t\ta.Type.Kind() == Struct && b.Type.Kind() == Struct && a.Type.Equal(b.Type),\n\t\t\ta.Type.Kind() == Union && b.Type.Kind() == Union && a.Type.Equal(b.Type):\n\n\t\t\tn.Operand = Operand{Type: a.Type}\n\t\tcase\n\t\t\t// both operands are pointers to qualified or\n\t\t\t// unqualified versions of compatible types;\n\t\t\ta.isPointerType() && b.isPointerType() && (a.Type.IsCompatible(b.Type) || ctx.tweaks.EnablePointerCompatibility):\n\n\t\t\tn.Operand = Operand{Type: a.Type}\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null pointer constant\n\t\t\ta.isNullPtrConst() && b.isPointerType():\n\n\t\t\tn.Operand = Operand{Type: b.Type}\n\t\t\tif cond.IsNonZero() {\n\t\t\t\tn.Operand.Value = Null\n\t\t\t}\n\t\tcase\n\t\t\t// one operand is a pointer and the other is a null pointer constant\n\t\t\ta.isPointerType() && b.isNullPtrConst():\n\n\t\t\tn.Operand = Operand{Type: a.Type}\n\t\t\tif cond.IsZero() {\n\t\t\t\tn.Operand.Value = Null\n\t\t\t}\n\t\tcase a.Type.Kind() == Void && b.Type.Kind() == Void: // assert\n\t\t\tn.Operand = Operand{Type: Void}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v, %v\", ctx.position(n), a, b))\n\t\t}\n\tcase ExprIndex: // Expr '[' ExprList ']'\n\t\t// [0]6.5.2.1\n\t\top := n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\tindex := n.ExprList.eval(ctx, true, fn, seq, sc)\n\t\tswitch t := op.Type.(type) {\n\t\tcase *ArrayType:\n\t\t\tif arr2ptr {\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\t\t\tn.Operand = Operand{Type: t.Item}\n\t\tcase *PointerType:\n\t\t\tn.Operand = Operand{Type: t.Item}\n\t\tcase *NamedType:\n\t\t\tn.Operand = Operand{Type: t.Type}\n\t\tcase TypeKind:\n\t\t\tif !t.IsIntegerType() {\n\t\t\t\tpanic(fmt.Errorf(\"%v: %T %v\", ctx.position(n), t, t))\n\t\t\t}\n\n\t\t\tr := UnderlyingType(index.Type)\n\t\t\tswitch {\n\t\t\tcase r.IsPointerType():\n\t\t\t\tn.Operand = Operand{Type: r.(*PointerType).Item}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v[%v]\", ctx.position(n), op.Type, index))\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %T %v\", ctx.position(n), t, t))\n\t\t}\n\t\tif !index.isIntegerType() {\n\t\t\tl := UnderlyingType(op.Type)\n\t\t\tswitch {\n\t\t\tcase l.IsIntegerType() && index.isPointerType():\n\t\t\t\tn.Operand = Operand{Type: UnderlyingType(index.Type).(*PointerType).Item}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v[%v]\", ctx.position(n), op.Type, index))\n\t\t\t}\n\t\t}\n\t\tif d := n.Expr.Declarator; d != nil {\n\t\t\td.Referenced++\n\t\t}\n\tcase ExprXor: // Expr '^' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).xor(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\t\tif n.Expr.Equals(n.Expr2) {\n\t\t\tn.Operand.Value = &ir.Int64Value{Value: 0}\n\t\t}\n\tcase ExprOr: // Expr '|' Expr\n\t\tn.Operand = n.Expr.eval(ctx, arr2ptr, fn, seq, sc).or(ctx, n.Expr2.eval(ctx, arr2ptr, fn, seq, sc))\n\tcase ExprFloat: // FLOATCONST\n\t\tn.floatConst(ctx)\n\tcase ExprIdent: // IDENTIFIER\n\t\tbuiltin := false\n\t\t// [0]6.5.1\n\t\tnm := n.Token.Val\n\t\tvar nm2 int\n\t\tif ctx.tweaks.EnableImplicitBuiltins {\n\t\t\tnm2 = dict.SID(\"__builtin_\" + string(dict.S(nm)))\n\t\t\tif n.Scope.LookupIdent(nm2) != nil {\n\t\t\t\tbuiltin = true\n\t\t\t}\n\t\t}\n\t\tif n.Scope.LookupIdent(nm) == nil {\n\t\t\tif n.enum != nil {\n\t\t\t\tif c := n.enum.find(nm); c != nil {\n\t\t\t\t\tn.Operand = c.Operand\n\t\t\t\t\treturn n.Operand\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch {\n\t\t\tcase builtin:\n\t\t\t\tnm = nm2\n\t\t\tdefault:\n\t\t\t\tif !ctx.tweaks.EnableImplicitDeclarations {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: undefined %q\", ctx.position(n), dict.S(nm)))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tswitch x := n.Scope.LookupIdent(nm).(type) {\n\t\tcase *Declarator:\n\t\t\tx.IsBuiltin = builtin\n\t\t\tn.Declarator = x\n\t\t\tif arr2ptr {\n\t\t\t\tx.Referenced++\n\t\t\t}\n\t\t\tt := x.Type\n\t\t\tt0 := t\n\t\tmore2:\n\t\t\tswitch y := t.(type) {\n\t\t\tcase *ArrayType:\n\t\t\t\tif !x.IsFunctionParameter && y.Size.Type == nil {\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase x.IsTLD() && x.DeclarationSpecifier.IsExtern():\n\t\t\t\t\t\t// ok\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %s has incomplete type: %v\", ctx.position(x), dict.S(x.Name()), t0))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tn.Operand = Operand{Type: t0}\n\t\t\tcase\n\t\t\t\t*EnumType,\n\t\t\t\t*PointerType,\n\t\t\t\t*StructType,\n\t\t\t\t*TaggedEnumType,\n\t\t\t\t*TaggedStructType,\n\t\t\t\t*TaggedUnionType,\n\t\t\t\t*UnionType:\n\n\t\t\t\tn.Operand = Operand{Type: t0}\n\t\t\tcase *FunctionType:\n\t\t\t\tn.Operand = Operand{Type: t0}\n\t\t\t\tif nm == idBuiltinAlloca {\n\t\t\t\t\tfn.Alloca = true\n\t\t\t\t}\n\t\t\tcase *NamedType:\n\t\t\t\tt = y.Type\n\t\t\t\tgoto more2\n\t\t\tcase TypeKind:\n\t\t\t\tswitch y {\n\t\t\t\tcase\n\t\t\t\t\tBool,\n\t\t\t\t\tChar,\n\t\t\t\t\tDouble,\n\t\t\t\t\tDoubleComplex,\n\t\t\t\t\tFloat,\n\t\t\t\t\tFloatComplex,\n\t\t\t\t\tInt,\n\t\t\t\t\tLong,\n\t\t\t\t\tLongDouble,\n\t\t\t\t\tLongDoubleComplex,\n\t\t\t\t\tLongLong,\n\t\t\t\t\tSChar,\n\t\t\t\t\tShort,\n\t\t\t\t\tUChar,\n\t\t\t\t\tUInt,\n\t\t\t\t\tULong,\n\t\t\t\t\tULongLong,\n\t\t\t\t\tUShort:\n\n\t\t\t\t\tn.Operand = Operand{Type: t0}\n\t\t\t\tdefault:\n\t\t\t\t\t//dbg(\"\", ctx.position(n))\n\t\t\t\t\tpanic(y)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\t//dbg(\"\", ctx.position(n))\n\t\t\t\tpanic(y)\n\t\t\t}\n\t\tcase *EnumerationConstant:\n\t\t\tn.Operand = x.Operand\n\t\tcase nil:\n\t\t\tif ctx.tweaks.EnableImplicitDeclarations {\n\t\t\t\treturn Operand{}\n\t\t\t}\n\n\t\t\tpanic(fmt.Errorf(\"%v: undefined: %q\", ctx.position(n), dict.S(nm)))\n\t\tdefault:\n\n\t\t\t//dbg(\"%s\", dict.S(nm))\n\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t}\n\tcase ExprInt: // INTCONST\n\t\ts0 := string(dict.S(n.Token.Val))\n\t\ts := s0\n\t\tif strings.Contains(s, \"p\") {\n\t\t\tn.Case = ExprFloat\n\t\t\tn.floatConst(ctx)\n\t\t\tbreak\n\t\t}\n\n\tloop:\n\t\tfor i := len(s) - 1; i > 0; i-- {\n\t\t\tswitch s0[i] {\n\t\t\tcase 'l', 'L', 'u', 'U':\n\t\t\t\ts = s[:i]\n\t\t\tdefault:\n\t\t\t\tbreak loop\n\t\t\t}\n\t\t}\n\t\tdecadic := s == \"0\" || !strings.HasPrefix(s, \"0\")\n\t\tv, err := strconv.ParseUint(s, 0, 64)\n\t\tif err != nil {\n\t\t\tif ctx.tweaks.EnableBinaryLiterals && (strings.HasPrefix(s, \"0b\") || strings.HasPrefix(s, \"0B\")) {\n\t\t\t\tdecadic = false\n\t\t\t\tv, err = strconv.ParseUint(s[2:], 2, 64)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v %v\", ctx.position(n), n.Case, err))\n\t\t\t}\n\t\t}\n\n\t\t// [0]6.4.4.1\n\t\tswitch suff := strings.ToUpper(s0[len(s):]); {\n\t\tcase suff == \"\" && decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, Int, Long, LongLong)\n\t\tcase suff == \"\" && !decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, Int, UInt, Long, ULong, LongLong, ULongLong)\n\t\tcase suff == \"U\":\n\t\t\tn.Operand = newIntConst(ctx, n, v, UInt, ULong, ULongLong)\n\t\tcase suff == \"L\" && decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, Long, LongLong)\n\t\tcase suff == \"L\" && !decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, Long, ULong, LongLong, ULongLong)\n\t\tcase suff == \"UL\", suff == \"LU\":\n\t\t\tn.Operand = newIntConst(ctx, n, v, ULong, ULongLong)\n\t\tcase suff == \"LL\" && decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, LongLong)\n\t\tcase suff == \"LL\" && !decadic:\n\t\t\tn.Operand = newIntConst(ctx, n, v, LongLong, ULongLong)\n\t\tcase suff == \"ULL\", suff == \"LLU\":\n\t\t\tn.Operand = newIntConst(ctx, n, v, ULongLong)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: TODO %q %q decadic: %v\\n%s\", ctx.position(n), s, suff, decadic, PrettyString(n)))\n\t\t}\n\tcase ExprLChar: // LONGCHARCONST\n\t\tn.Operand = ctx.charConst(n.Token)\n\tcase ExprLString: // LONGSTRINGLITERAL\n\t\tn.Operand = ctx.strConst(n.Token)\n\tcase ExprString: // STRINGLITERAL\n\t\tn.Operand = ctx.strConst(n.Token)\n\tcase ExprStatement: // '(' CompoundStmt ')'\n\t\tn.Operand = n.CompoundStmt.check(ctx, fn, seq, sc, nil, false)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\n\tif !arr2ptr {\n\t\treturn n.Operand\n\t}\n\n\t// [0]6.3.2.1\n\t//\n\t// 3. Except when it is the operand of the sizeof operator or\n\t// the unary & operator, or is a string literal used to\n\t// initialize an array, an expression that has type ‘‘array of\n\t// type’’ is converted to an expression with type ‘‘pointer to\n\t// type’’ that points to the initial element of the array\n\t// object and is not an lvalue. If the array object has\n\t// register storage class, the behavior is undefined.\n\tt := n.Operand.Type\n\tfor {\n\t\tswitch x := t.(type) {\n\t\tcase *ArrayType:\n\t\t\tn.Operand.Type = &PointerType{x.Item}\n\t\t\treturn n.Operand\n\t\tcase *FunctionType:\n\t\t\tn.Operand.Type = &PointerType{x}\n\t\t\treturn n.Operand\n\t\tcase *NamedType:\n\t\t\tt = x.Type\n\t\tcase\n\t\t\t*EnumType,\n\t\t\t*PointerType,\n\t\t\t*StructType,\n\t\t\t*TaggedEnumType,\n\t\t\t*TaggedStructType,\n\t\t\t*TaggedUnionType,\n\t\t\t*UnionType:\n\n\t\t\treturn n.Operand\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tBool,\n\t\t\t\tChar,\n\t\t\t\tDouble,\n\t\t\t\tDoubleComplex,\n\t\t\t\tFloat,\n\t\t\t\tFloatComplex,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDouble,\n\t\t\t\tLongDoubleComplex,\n\t\t\t\tLongLong,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort,\n\t\t\t\tVoid:\n\n\t\t\t\treturn n.Operand\n\t\t\tdefault:\n\t\t\t\t//dbg(\"\", ctx.position(n))\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tcase nil:\n\t\t\tif ctx.tweaks.EnableImplicitDeclarations {\n\t\t\t\treturn n.Operand\n\t\t\t}\n\n\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\tdefault:\n\t\t\t//dbg(\"\", ctx.position(n))\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n}\n\nfunc (n *Expr) floatConst(ctx *context) {\n\ts0 := string(dict.S(n.Token.Val))\n\ts := s0\nloop2:\n\tfor i := len(s) - 1; i > 0; i-- {\n\t\tswitch s0[i] {\n\t\tcase 'l', 'L', 'f', 'F':\n\t\t\ts = s[:i]\n\t\tdefault:\n\t\t\tbreak loop2\n\t\t}\n\t}\n\n\tvar v float64\n\tvar err error\n\tswitch {\n\tcase strings.Contains(s, \"p\"):\n\t\tvar bf *big.Float\n\t\tbf, _, err = big.ParseFloat(s, 0, 53, big.ToNearestEven)\n\t\tif err == nil {\n\t\t\tv, _ = bf.Float64()\n\t\t}\n\tdefault:\n\t\tv, err = strconv.ParseFloat(s, 64)\n\t}\n\tif err != nil {\n\t\tswitch {\n\t\tcase !strings.HasPrefix(s, \"-\") && strings.Contains(err.Error(), \"value out of range\"):\n\t\t\t// linux_386/usr/include/math.h\n\t\t\t//\n\t\t\t// \t/* Value returned on overflow.  With IEEE 754 floating point, this is\n\t\t\t// \t   +Infinity, otherwise the largest representable positive value.  */\n\t\t\t// \t#if __GNUC_PREREQ (3, 3)\n\t\t\t// \t# define HUGE_VAL (__builtin_huge_val ())\n\t\t\t// \t#else\n\t\t\t// \t/* This may provoke compiler warnings, and may not be rounded to\n\t\t\t// \t   +Infinity in all IEEE 754 rounding modes, but is the best that can\n\t\t\t// \t   be done in ISO C while remaining a constant expression.  10,000 is\n\t\t\t// \t   greater than the maximum (decimal) exponent for all supported\n\t\t\t// \t   floating-point formats and widths.  */\n\t\t\t// \t# define HUGE_VAL 1e10000\n\t\t\t// \t#endif\n\t\t\tv = math.Inf(1)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v\", ctx.position(n), err))\n\t\t}\n\t}\n\n\t// [0]6.4.4.2\n\tswitch suff := strings.ToUpper(s0[len(s):]); suff {\n\tcase \"\", \"l\", \"L\":\n\t\tn.Operand = Operand{Type: Double, Value: &ir.Float64Value{Value: v}}\n\tcase \"f\", \"F\":\n\t\tn.Operand = Operand{Type: Float, Value: &ir.Float32Value{Value: float32(v)}}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %q %q %v\", ctx.position(n), s, suff, v))\n\t}\n}\n\nfunc checkFn(ctx *context, t Type) *FunctionType {\n\t// 1. The expression that denotes the called function 80) shall\n\t// have type pointer to function returning void or returning an\n\t// object type other than an array type.\n\tfor {\n\t\tswitch x := t.(type) {\n\t\tcase *FunctionType:\n\t\t\treturn x\n\t\tcase *NamedType:\n\t\t\tt = x.Type\n\t\tcase *PointerType:\n\t\t\tswitch x := x.Item.(type) {\n\t\t\tcase *FunctionType:\n\t\t\t\treturn x\n\t\t\tcase *NamedType:\n\t\t\t\tt = x.Type\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t\t}\n\t\tcase nil:\n\t\t\treturn nil\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n}\n\nfunc (n *ArgumentExprListOpt) eval(ctx *context, fn *Declarator, seq *int, sc []int) []Operand {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\treturn n.ArgumentExprList.eval(ctx, fn, seq, sc)\n}\n\nfunc (n *ArgumentExprList) eval(ctx *context, fn *Declarator, seq *int, sc []int) (r []Operand) {\n\tfor ; n != nil; n = n.ArgumentExprList {\n\t\tr = append(r, n.Expr.eval(ctx, true, fn, seq, sc))\n\t}\n\treturn r\n}\n\nfunc (n *TypeName) check(ctx *context) Type {\n\t// SpecifierQualifierList AbstractDeclaratorOpt\n\tds := &DeclarationSpecifier{}\n\tn.SpecifierQualifierList.check(ctx, ds)\n\tif n.AbstractDeclaratorOpt == nil {\n\t\tn.Type = ds.typ(ctx)\n\t\treturn n.Type\n\t}\n\n\tn.AbstractDeclaratorOpt.check(ctx, ds, ds.typ(ctx))\n\tn.Type = n.AbstractDeclaratorOpt.AbstractDeclarator.Type\n\treturn n.Type\n}\n\nfunc (n *ExprListOpt) eval(ctx *context, arr2ptr bool, fn *Declarator, seq *int, sc []int) Operand {\n\tif n == nil {\n\t\treturn Operand{}\n\t}\n\n\treturn n.ExprList.eval(ctx, arr2ptr, fn, seq, sc)\n}\n\nfunc (n *ExprList) eval(ctx *context, arr2ptr bool, fn *Declarator, seq *int, sc []int) Operand {\n\tif n.Operand.Type == nil {\n\t\tfor l := n; l != nil; l = l.ExprList {\n\t\t\tn.Operand = l.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n\t\t}\n\t}\n\treturn n.Operand\n}\n\nfunc (n *ExprList) declarator(ctx *context) (r *Declarator) {\n\tfor l := n; ; l = l.ExprList {\n\t\tif l.ExprList == nil {\n\t\t\treturn l.Expr.Declarator\n\t\t}\n\t}\n}\n\nfunc (n *ExprOpt) eval(ctx *context, arr2ptr bool, fn *Declarator, seq *int, sc []int) Operand {\n\tif n == nil {\n\t\treturn Operand{}\n\t}\n\n\treturn n.Expr.eval(ctx, arr2ptr, fn, seq, sc)\n}\n\n// Name returns the ID of the declared name.\nfunc (n *Declarator) Name() int { return n.DirectDeclarator.nm() }\n\nfunc (n *DirectDeclarator) nm() int {\n\tswitch n.Case {\n\tcase\n\t\tDirectDeclaratorArray,\n\t\tDirectDeclaratorArraySize,\n\t\tDirectDeclaratorArrayVar,\n\t\tDirectDeclaratorIdentList,\n\t\tDirectDeclaratorParamList:\n\n\t\treturn n.DirectDeclarator.nm()\n\tcase DirectDeclaratorIdent:\n\t\treturn n.Token.Val\n\tcase DirectDeclaratorParen:\n\t\treturn n.Declarator.Name()\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %v\", n.Case))\n\t}\n}\n\nfunc (n *ExternalDeclarationList) check(ctx *context) (err error) {\n\tfor ; n != nil; n = n.ExternalDeclarationList {\n\t\tn.ExternalDeclaration.check(ctx)\n\t}\n\treturn nil\n}\n\nfunc (n *ExternalDeclaration) check(ctx *context) {\n\tswitch n.Case {\n\tcase ExternalDeclarationDecl: // Declaration\n\t\tn.Declaration.check(ctx, nil, nil, nil, nil, false)\n\tcase ExternalDeclarationFunc: // FunctionDefinition\n\t\tn.FunctionDefinition.check(ctx)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\n// LocalVariables returns all local variables declared in a function in the\n// order of appearance. The result does not include function parameters.\nfunc (n *FunctionDefinition) LocalVariables() []*Declarator { return n.Declarator.vars }\n\nfunc (n *FunctionDefinition) check(ctx *context) {\n\tds := &DeclarationSpecifier{}\n\tswitch n.Case {\n\tcase FunctionDefinitionSpec: // DeclarationSpecifiers Declarator DeclarationListOpt FunctionBody\n\t\tn.DeclarationSpecifiers.check(ctx, ds)\n\t\tif len(ds.TypeSpecifiers) == 0 { // [0]6.7.2-2\n\t\t\tds.typeSpecifiers = []TypeSpecifierCase{TypeSpecifierInt}\n\t\t}\n\tcase FunctionDefinitionInt: // Declarator DeclarationListOpt FunctionBody\n\t\tds.typeSpecifiers = []TypeSpecifierCase{TypeSpecifierInt}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\tswitch o := n.DeclarationListOpt; {\n\tcase o != nil:\n\t\tsc := n.Declarator.fpScope(ctx)\n\t\tparams := n.DeclarationListOpt.check(ctx, sc)\n\t\tn.Declarator.check0(ctx, ds, ds.typ(ctx), false, nil, nil, params)\n\t\tif n.Declarator.Type.Kind() != Function {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\td := n.Declarator\n\t\tn.FunctionBody.check(ctx, n.Declarator)\n\t\tfor _, v := range d.ParameterNames() {\n\t\t\tp, _ := sc.Idents[v].(*Declarator)\n\t\t\tp.IsFunctionParameter = true\n\t\t\td.Parameters = append(d.Parameters, p)\n\t\t}\n\tdefault:\n\t\tn.Declarator.check(ctx, ds, ds.typ(ctx), false, nil, nil)\n\t\tif n.Declarator.Type.Kind() != Function {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\td := n.Declarator\n\t\tsc := d.fpScope(ctx)\n\t\tn.FunctionBody.check(ctx, n.Declarator)\n\t\tfor _, v := range d.ParameterNames() {\n\t\t\tp, _ := sc.Idents[v].(*Declarator)\n\t\t\td.Parameters = append(d.Parameters, p)\n\t\t}\n\t}\n}\n\nfunc (n *DeclarationListOpt) check(ctx *context, scope *Scope) (r []*Declarator) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tfor l := n.DeclarationList; l != nil; l = l.DeclarationList {\n\t\tr = append(r, l.Declaration.check(ctx, nil, nil, nil, scope, true)...)\n\t}\n\treturn r\n}\n\nfunc (n *FunctionBody) check(ctx *context, fn *Declarator) {\n\t// CompoundStmt *CompoundStmt\n\tseq := -1\n\tn.CompoundStmt.check(ctx, fn, &seq, nil, nil, false)\n}\n\nfunc (n *CompoundStmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) Operand {\n\t// '{' BlockItemListOpt '}'\n\t*seq++\n\tsc = append(sc, *seq)\n\tif *seq == 0 { // Pull function parameters into the outermost block scope.\n\t\tfor _, v := range fn.fpScope(ctx).Idents {\n\t\t\td := v.(*Declarator)\n\t\t\tnm := d.Name()\n\t\t\tif ex := n.scope.Idents[nm]; ex != nil {\n\t\t\t\tpanic(\"TODO\") // redeclared\n\t\t\t}\n\n\t\t\tn.scope.insertDeclarator(ctx, d)\n\t\t}\n\t}\n\treturn n.BlockItemListOpt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n}\n\nfunc (n *Declarator) fpScope(ctx *context) *Scope { return n.DirectDeclarator.fpScope(ctx) }\n\nfunc (n *DirectDeclarator) fpScope(ctx *context) *Scope {\n\tswitch n.Case {\n\t//TODO case DirectDeclaratorParen: // '(' Declarator ')'\n\tcase DirectDeclaratorIdentList: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\tswitch n.DirectDeclarator.Case {\n\t\tcase DirectDeclaratorIdent:\n\t\t\treturn n.paramScope\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.DirectDeclarator.Case))\n\t\t}\n\tcase DirectDeclaratorParamList: // DirectDeclarator '(' ParameterTypeList ')'\n\t\tswitch n.DirectDeclarator.Case {\n\t\tcase DirectDeclaratorParen:\n\t\t\tif n.DirectDeclarator.Declarator.DirectDeclarator.Case == DirectDeclaratorIdent {\n\t\t\t\treturn n.paramScope\n\t\t\t}\n\n\t\t\treturn n.DirectDeclarator.Declarator.DirectDeclarator.fpScope(ctx)\n\t\tcase DirectDeclaratorIdent:\n\t\t\treturn n.paramScope\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.DirectDeclarator.Case))\n\t\t}\n\t//TODO case DirectDeclaratorArraySize: // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expr ']'\n\t//TODO case DirectDeclaratorArraySize2: // DirectDeclarator '[' TypeQualifierList \"static\" Expr ']'\n\t//TODO case DirectDeclaratorArrayVar: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t//TODO case DirectDeclaratorArray: // DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'\n\t//TODO case DirectDeclaratorIdent: // IDENTIFIER\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\n// ParameterNames returns a list of IDs of names of parameters of n. The\n// function panics if n is not function type.\nfunc (n *Declarator) ParameterNames() []int { return n.DirectDeclarator.parameterNames() }\n\nfunc (n *DirectDeclarator) parameterNames() (r []int) {\n\tswitch n.Case {\n\t//TODO case DirectDeclaratorParen: // '(' Declarator ')'\n\tcase DirectDeclaratorIdentList: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\tswitch n.DirectDeclarator.Case {\n\t\tcase DirectDeclaratorIdent:\n\t\t\treturn n.IdentifierListOpt.check()\n\t\tdefault:\n\t\t\tpanic(n.DirectDeclarator.Case)\n\t\t}\n\tcase DirectDeclaratorParamList: // DirectDeclarator '(' ParameterTypeList ')'\n\t\tswitch n.DirectDeclarator.Case {\n\t\tcase DirectDeclaratorIdent:\n\t\t\tfor l := n.ParameterTypeList.ParameterList; l != nil; l = l.ParameterList {\n\t\t\t\tswitch n := l.ParameterDeclaration; n.Case {\n\t\t\t\tcase ParameterDeclarationAbstract: // DeclarationSpecifiers AbstractDeclaratorOpt\n\t\t\t\t\tr = append(r, 0)\n\t\t\t\tcase ParameterDeclarationDeclarator: // DeclarationSpecifiers Declarator\n\t\t\t\t\tr = append(r, n.Declarator.Name())\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(n.Case)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn r\n\t\tcase DirectDeclaratorParen:\n\t\t\tif n.DirectDeclarator.Declarator.DirectDeclarator.Case == DirectDeclaratorIdent {\n\t\t\t\tfor l := n.ParameterTypeList.ParameterList; l != nil; l = l.ParameterList {\n\t\t\t\t\tswitch n := l.ParameterDeclaration; n.Case {\n\t\t\t\t\tcase ParameterDeclarationAbstract: // DeclarationSpecifiers AbstractDeclaratorOpt\n\t\t\t\t\t\tr = append(r, 0)\n\t\t\t\t\tcase ParameterDeclarationDeclarator: // DeclarationSpecifiers Declarator\n\t\t\t\t\t\tr = append(r, n.Declarator.Name())\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(n.Case)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn r\n\t\t\t}\n\n\t\t\treturn n.DirectDeclarator.Declarator.DirectDeclarator.parameterNames()\n\t\tdefault:\n\t\t\tpanic(n.DirectDeclarator.Case)\n\t\t}\n\t//TODO case DirectDeclaratorArraySize: // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expr ']'\n\t//TODO case DirectDeclaratorArraySize2: // DirectDeclarator '[' TypeQualifierList \"static\" Expr ']'\n\t//TODO case DirectDeclaratorArrayVar: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t//TODO case DirectDeclaratorArray: // DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'\n\t//TODO case DirectDeclaratorIdent: // IDENTIFIER\n\tdefault:\n\t\tpanic(n.Case)\n\t}\n}\n\nfunc (n *BlockItemListOpt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) Operand {\n\tif n == nil {\n\t\treturn Operand{Type: Void}\n\t}\n\n\treturn n.BlockItemList.check(ctx, fn, seq, sc, inSwitch, inLoop)\n}\n\nfunc (n *BlockItemList) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) (r Operand) {\n\tfor ; n != nil; n = n.BlockItemList {\n\t\top := n.BlockItem.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\t\tif n.BlockItemList == nil {\n\t\t\tr = op\n\t\t}\n\t}\n\treturn r\n}\n\nfunc (n *BlockItem) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) (r Operand) {\n\tr = Operand{Type: Void}\n\tswitch n.Case {\n\tcase BlockItemDecl: // Declaration\n\t\tn.Declaration.check(ctx, seq, sc, fn, nil, false)\n\tcase BlockItemStmt: // Stmt\n\t\tr = n.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\treturn r\n}\n\nfunc (n *Stmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) (r Operand) {\n\tr = Operand{Type: Void}\n\tswitch n.Case {\n\tcase StmtBlock: // CompoundStmt\n\t\tn.CompoundStmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase StmtExpr: // ExprStmt\n\t\tr = n.ExprStmt.check(ctx, fn, seq, sc)\n\tcase StmtIter: // IterationStmt\n\t\tn.IterationStmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase StmtJump: // JumpStmt\n\t\tn.JumpStmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase StmtLabeled: // LabeledStmt\n\t\tn.LabeledStmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase StmtSelect: // SelectionStmt\n\t\tn.SelectionStmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\treturn r\n}\n\nfunc (n *LabeledStmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) {\n\t//[0]6.8.1\n\tswitch n.Case {\n\tcase LabeledStmtSwitchCase: // \"case\" ConstExpr ':' Stmt\n\t\top := n.ConstExpr.eval(ctx).ConvertTo(ctx.model, inSwitch.SwitchOp.Type)\n\t\tn.ConstExpr.Operand = op\n\t\tif op.Value == nil {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tif inSwitch == nil {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tinSwitch.Cases = append(inSwitch.Cases, n)\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase LabeledStmtDefault: // \"default\" ':' Stmt\n\t\tif inSwitch == nil {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tinSwitch.Cases = append(inSwitch.Cases, n)\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase LabeledStmtLabel: // IDENTIFIER ':' Stmt\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase LabeledStmtLabel2: // TYPEDEF_NAME ':' Stmt\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *SelectionStmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) {\n\tswitch n.Case {\n\tcase SelectionStmtIfElse: // \"if\" '(' ExprList ')' Stmt \"else\" Stmt\n\t\tif !n.ExprList.eval(ctx, true, fn, seq, sc).isScalarType() {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\t\tn.Stmt2.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase SelectionStmtIf: // \"if\" '(' ExprList ')' Stmt\n\t\tif !n.ExprList.eval(ctx, true, fn, seq, sc).isScalarType() {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, inLoop)\n\tcase SelectionStmtSwitch: // \"switch\" '(' ExprList ')' Stmt\n\t\t// [0]6.8.4.2\n\t\tif !n.ExprList.eval(ctx, true, fn, seq, sc).isIntegerType() {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tn.SwitchOp = n.ExprList.Operand.integerPromotion(ctx.model)\n\t\tn.Stmt.check(ctx, fn, seq, sc, n, inLoop)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *IterationStmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) {\n\tswitch n.Case {\n\tcase IterationStmtDo: // \"do\" Stmt \"while\" '(' ExprList ')' ';'\n\t\tif !n.ExprList.eval(ctx, true, fn, seq, sc).isScalarType() {\n\t\t\tpanic(ctx.position)\n\t\t}\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, true)\n\tcase IterationStmtForDecl: // \"for\" '(' Declaration ExprListOpt ';' ExprListOpt ')' Stmt\n\t\tn.Declaration.check(ctx, seq, sc, fn, n.Declaration.Scope, false)\n\t\tn.ExprListOpt.eval(ctx, true, fn, seq, sc)\n\t\tif e := n.ExprListOpt.eval(ctx, true, fn, seq, sc); e.Type != nil && !e.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.ExprListOpt2.eval(ctx, true, fn, seq, sc)\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, true)\n\tcase IterationStmtFor: // \"for\" '(' ExprListOpt ';' ExprListOpt ';' ExprListOpt ')' Stmt\n\t\t// [0]6.8.5.3\n\t\tn.ExprListOpt.eval(ctx, true, fn, seq, sc)\n\t\tif e := n.ExprListOpt2.eval(ctx, true, fn, seq, sc); e.Type != nil && !e.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.ExprListOpt3.eval(ctx, true, fn, seq, sc)\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, true)\n\tcase IterationStmtWhile: // \"while\" '(' ExprList ')' Stmt\n\t\tif e := n.ExprList.eval(ctx, true, fn, seq, sc); e.Type != nil && !e.isScalarType() {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tn.Stmt.check(ctx, fn, seq, sc, inSwitch, true)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *JumpStmt) check(ctx *context, fn *Declarator, seq *int, sc []int, inSwitch *SelectionStmt, inLoop bool) {\n\tswitch n.Case {\n\tcase JumpStmtBreak: // \"break\" ';'\n\t\t// [0]6.8.6.3\n\t\t//\n\t\t// 1. A break statement shall appear only in or as a switch\n\t\t// body or loop body.\n\t\tif inSwitch == nil && !inLoop {\n\t\t\tpanic(ctx.position)\n\t\t}\n\tcase JumpStmtContinue: // \"continue\" ';'\n\t\t// [0]6.8.6.2\n\t\t//\n\t\t// 1. A continue statement shall appear only in or as a loop\n\t\t// body.\n\t\tif !inLoop {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase JumpStmtGoto: // \"goto\" IDENTIFIER ';'\n\t\tif nm := n.Token2.Val; n.scope.LookupLabel(nm) == nil {\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase JumpStmtReturn: // \"return\" ExprListOpt ';'\n\t\t// [0]6.8.6.4\n\t\top := n.ExprListOpt.eval(ctx, true, fn, seq, sc)\n\t\tswitch t := fn.Type.(*FunctionType).Result; t.Kind() {\n\t\tcase Void:\n\t\t\tif op.Type != nil {\n\t\t\t\tif ctx.tweaks.EnableReturnExprInVoidFunc {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tpanic(ctx.position(n))\n\t\t\t}\n\t\tdefault:\n\t\t\tif op.Type == nil {\n\t\t\t\tpanic(ctx.position(n))\n\t\t\t}\n\t\t\tn.ReturnOperand = op.ConvertTo(ctx.model, t)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *ExprStmt) check(ctx *context, fn *Declarator, seq *int, sc []int) Operand {\n\t// ExprListOpt ';'\n\treturn n.ExprListOpt.eval(ctx, true, fn, seq, sc)\n}\n\nfunc (n *Declaration) check(ctx *context, seq *int, sc []int, fn *Declarator, scope *Scope, fnParam bool) []*Declarator {\n\t// DeclarationSpecifiers InitDeclaratorListOpt ';'\n\tds := &DeclarationSpecifier{}\n\tn.DeclarationSpecifiers.check(ctx, ds)\n\tif len(ds.TypeSpecifiers) == 0 { // [0]6.7.2-2\n\t\tpanic(\"TODO\")\n\t}\n\tr := n.InitDeclaratorListOpt.check(ctx, ds, seq, sc, fn, scope)\n\tfor _, v := range r {\n\t\tif fnParam {\n\t\t\tv.IsFunctionParameter = true\n\t\t\tcontinue\n\t\t}\n\n\t\tif v.Linkage == LinkageExternal && v.DeclarationSpecifier.IsExtern() {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch x := UnderlyingType(v.Type).(type) {\n\t\tcase *ArrayType:\n\t\t\tif x.Size.Type == nil {\n\t\t\t\tpanic(fmt.Errorf(\"%v: %s has incomplete type: %v\", ctx.position(v), dict.S(v.Name()), v.Type))\n\t\t\t}\n\t\t}\n\t}\n\treturn r\n}\n\nfunc (n *InitDeclaratorListOpt) check(ctx *context, ds *DeclarationSpecifier, seq *int, sc []int, fn *Declarator, scope *Scope) []*Declarator {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\treturn n.InitDeclaratorList.check(ctx, ds, seq, sc, fn, scope)\n}\n\nfunc (n *InitDeclaratorList) check(ctx *context, ds *DeclarationSpecifier, seq *int, sc []int, fn *Declarator, scope *Scope) (r []*Declarator) {\n\tfor ; n != nil; n = n.InitDeclaratorList {\n\t\tr = append(r, n.InitDeclarator.check(ctx, ds, seq, sc, fn, scope))\n\t}\n\treturn r\n}\n\nfunc (n *InitDeclarator) check(ctx *context, ds *DeclarationSpecifier, seq *int, sc []int, fn *Declarator, scope *Scope) *Declarator {\n\tif scope != nil {\n\t\tn.Declarator.Scope = scope\n\t}\n\tswitch n.Case {\n\tcase InitDeclaratorBase: // Declarator\n\t\tn.Declarator.check(ctx, ds, ds.typ(ctx), !ds.IsTypedef(), sc, fn)\n\tcase InitDeclaratorInit: // Declarator '=' Initializer\n\t\tif ds.IsTypedef() || ds.IsExtern() {\n\t\t\tpanic(ctx.position(n)) // error\n\t\t}\n\t\tn.Declarator.Initializer = n.Initializer\n\t\tn.Declarator.check(ctx, ds, ds.typ(ctx), true, sc, fn)\n\t\tn.Initializer.check(ctx, n.Declarator.Type, fn, false, nil, seq, sc)\n\t\tif ex := n.Declarator.Scope.Idents[n.Declarator.Name()].(*Declarator); ex != nil && ex != n.Declarator {\n\t\t\tswitch {\n\t\t\tcase ex.Initializer == nil:\n\t\t\t\tex.Initializer = n.Initializer\n\t\t\tdefault:\n\t\t\t\tif n.Initializer != nil {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: existing initializer at %v\", ctx.position(n), ctx.position(ex))) // More than one initializer\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\treturn n.Declarator\n}\n\nfunc (n *Initializer) check(ctx *context, t Type, fn *Declarator, field bool, arr *ArrayType, seq *int, sc []int) (r Operand) {\n\t// [0]6.7.8\n\tswitch n.Case {\n\tcase InitializerCompLit: // '{' InitializerList CommaOpt '}'\n\t\treturn n.InitializerList.check(ctx, t, fn)\n\tcase InitializerExpr: // Expr\n\t\top := n.Expr.eval(ctx, true, fn, seq, sc)\n\t\tswitch {\n\t\tcase t.Kind() == Function && op.Type.IsPointerType() && UnderlyingType(op.Type).(*PointerType).Item.Kind() == Function:\n\t\t\tt.assign(ctx, n, op)\n\t\t\treturn n.Expr.Operand\n\t\tcase op.isPointerType() && !t.IsPointerType() && arr != nil:\n\t\t\tt = arr\n\t\tcase t.IsScalarType():\n\t\t\t// 11. The initializer for a scalar shall be a single\n\t\t\t// expression, optionally enclosed in braces. The\n\t\t\t// initial value of the object is that of the\n\t\t\t// expression (after conversion); the same type\n\t\t\t// constraints and conversions as for simple assignment\n\t\t\t// apply, taking the type of the scalar to be the\n\t\t\t// unqualified version of its declared type.\n\t\t\tt.assign(ctx, n, op)\n\t\t\treturn n.Expr.Operand\n\t\tcase op.IsZero():\n\t\t\tswitch k := UnderlyingType(t).Kind(); k {\n\t\t\tcase\n\t\t\t\tArray,\n\t\t\t\tStruct,\n\t\t\t\tUnion:\n\n\t\t\t\treturn op\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", ctx.position(n.Expr), k))\n\t\t\t}\n\t\t}\n\n\t\tif t.Kind() == Struct || t.Kind() == Union {\n\t\t\t// 13. The initializer for a structure or union object\n\t\t\t// that has automatic storage duration shall be either\n\t\t\t// an initializer list as described below, or a single\n\t\t\t// expression that has compatible structure or union\n\t\t\t// type. In the latter case, the initial value of the\n\t\t\t// object, including unnamed members, is that of the\n\t\t\t// expression.\n\t\t\tif t.IsCompatible(op.Type) {\n\t\t\t\treturn Operand{}\n\t\t\t}\n\n\t\t\tswitch t.Kind() {\n\t\t\tcase Union:\n\t\t\t\tx := UnderlyingType(t).(*UnionType)\n\t\t\t\tif x.Fields[0].Type.Kind() == Array && n.Expr.IsZero() {\n\t\t\t\t\treturn op\n\t\t\t\t}\n\n\t\t\t\tif x.Fields[0].Type.IsCompatible(op.Type) {\n\t\t\t\t\treturn op\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tpanic(fmt.Errorf(\"%v: typ %v, op type %v\", ctx.position(n), t, op.Type))\n\t\t}\n\n\t\tif t.Kind() == Array {\n\t\t\tat := UnderlyingType(t).(*ArrayType)\n\t\t\tit := at.Item\n\t\t\tswitch x := it.(type) {\n\t\t\tcase TypeKind:\n\t\t\t\tswitch x {\n\t\t\t\tcase Char, UChar:\n\t\t\t\t\tif op.isPointerType() && op.Type.(*PointerType).Item == Char {\n\t\t\t\t\t\t// 14. An array of character type may be initialized by\n\t\t\t\t\t\t// a character string literal, optionally enclosed in\n\t\t\t\t\t\t// braces. Successive characters of the character\n\t\t\t\t\t\t// string literal (including the terminating null\n\t\t\t\t\t\t// character if there is room or if the array is of\n\t\t\t\t\t\t// unknown size) initialize the elements of the array.\n\t\t\t\t\t\tx := t.(*ArrayType)\n\t\t\t\t\t\tif !field && x.Size.Type == nil {\n\t\t\t\t\t\t\tswitch y := op.Value.(type) {\n\t\t\t\t\t\t\tcase *ir.StringValue:\n\t\t\t\t\t\t\t\tx.Size = newIntConst(ctx, n, uint64(len(dict.S(int(y.StringID)))+1), UInt, ULong, ULongLong)\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO\", ctx.position(n)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn op\n\t\t\t\t\t}\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\t}\n\t\t\tcase *NamedType:\n\t\t\t\tswitch {\n\t\t\t\tcase x.Name == idWcharT:\n\t\t\t\t\tif op.isPointerType() && op.Type.(*PointerType).Item == UnderlyingType(x) {\n\t\t\t\t\t\t// 14. An array of character type may be initialized by\n\t\t\t\t\t\t// a character string literal, optionally enclosed in\n\t\t\t\t\t\t// braces. Successive characters of the character\n\t\t\t\t\t\t// string literal (including the terminating null\n\t\t\t\t\t\t// character if there is room or if the array is of\n\t\t\t\t\t\t// unknown size) initialize the elements of the array.\n\t\t\t\t\t\tif !field && at.Size.Type == nil {\n\t\t\t\t\t\t\tswitch y := op.Value.(type) {\n\t\t\t\t\t\t\tcase *ir.WideStringValue:\n\t\t\t\t\t\t\t\tat.Size = newIntConst(ctx, n, uint64(len(y.Value)+1), UInt, ULong, ULongLong)\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO\", ctx.position(n)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn op\n\t\t\t\t\t}\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\t}\n\t\t\tcase *ArrayType:\n\t\t\t\tat2 := UnderlyingType(it).(*ArrayType)\n\t\t\t\tswitch UnderlyingType(at2.Item).Kind() {\n\t\t\t\tcase Char, UChar:\n\t\t\t\t\tif op.isPointerType() && op.Type.(*PointerType).Item == Char {\n\t\t\t\t\t\t// 14. An array of character type may be initialized by\n\t\t\t\t\t\t// a character string literal, optionally enclosed in\n\t\t\t\t\t\t// braces. Successive characters of the character\n\t\t\t\t\t\t// string literal (including the terminating null\n\t\t\t\t\t\t// character if there is room or if the array is of\n\t\t\t\t\t\t// unknown size) initialize the elements of the array.\n\t\t\t\t\t\tif !field && at2.Size.Type == nil {\n\t\t\t\t\t\t\tswitch y := op.Value.(type) {\n\t\t\t\t\t\t\tcase *ir.StringValue:\n\t\t\t\t\t\t\t\tat2.Size = newIntConst(ctx, n, uint64(len(dict.S(int(y.StringID)))+1), UInt, ULong, ULongLong)\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO\", ctx.position(n)))\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn op\n\t\t\t\t\t}\n\t\t\t\tcase Array:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO Initializer t %v, op %v\", ctx.position(n), at2, op))\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v:\", ctx.position(n)))\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t\t}\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%v: TODO Initializer t %v, op %v\", ctx.position(n), t, op))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO Initializer %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *InitializerList) check(ctx *context, t Type, fn *Declarator) Operand {\n\t// InitializerList:\n\t//         /* empty */                                  // Case 0\n\t// |       Initializer                                  // Case 1\n\t// |       Designation Initializer                      // Case 2\n\t// |       InitializerList ',' Initializer              // Case 3\n\t// |       InitializerList ',' Designation Initializer  // Case 4\n\tr := &ir.CompositeValue{}\n\tn.Operand = Operand{Type: t, Value: r}\n\tn0 := n\n\tfor {\n\t\tswitch x := t.(type) {\n\t\tcase *ArrayType:\n\t\t\tvar index, maxIndex int64 = 0, -1\n\t\t\tfor ; n != nil; n = n.InitializerList {\n\t\t\t\tn0.Len++\n\t\t\t\tif n.Designation != nil {\n\t\t\t\t\tdst, nt := n.Designation.check(ctx, x)\n\t\t\t\t\t_ = nt //TODO\n\t\t\t\t\tif len(dst) != 1 {\n\t\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t\t}\n\n\t\t\t\t\tindex = dst[0]\n\t\t\t\t\tswitch nv := int64(len(r.Values)); {\n\t\t\t\t\tcase nv < index:\n\t\t\t\t\t\tr.Values = append(r.Values, make([]ir.Value, index-nv)...)\n\t\t\t\t\tcase nv > index:\n\t\t\t\t\t\tr.Values[index] = n.Initializer.check(ctx, x.Item, fn, false, x, nil, nil)\n\t\t\t\t\t\tindex++\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tr.Values = append(r.Values, n.Initializer.check(ctx, x.Item, fn, false, x, nil, nil))\n\t\t\t\tif index > maxIndex {\n\t\t\t\t\tmaxIndex = index\n\t\t\t\t}\n\t\t\t\tindex++\n\t\t\t}\n\t\t\tif x.Size.Type == nil {\n\t\t\t\tx.Size = newIntConst(ctx, n0, uint64(maxIndex+1), UInt, ULong, ULongLong)\n\t\t\t}\n\t\t\treturn Operand{Type: t, Value: r}\n\t\tcase *NamedType:\n\t\t\tt = x.Type\n\t\tcase *StructType:\n\t\t\tfield := 0\n\t\t\tfor ; n != nil; n = n.InitializerList {\n\t\t\t\tif n.Designation != nil {\n\t\t\t\t\tdst, nt := n.Designation.check(ctx, x)\n\t\t\t\t\tfield = int(dst[0])\n\t\t\t\t\tif len(dst) != 1 {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v %v\", ctx.position(n), dst, nt))\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch nv := len(r.Values); {\n\n\t\t\t\t\tcase nv < field:\n\t\t\t\t\t\tr.Values = append(r.Values, make([]ir.Value, field-nv)...)\n\t\t\t\t\tcase nv > field:\n\t\t\t\t\t\tr.Values[field] = n.Initializer.check(ctx, x.Fields[field].Type, fn, true, nil, nil, nil)\n\t\t\t\t\t\tfield++\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor x.Fields[field].Bits < 0 {\n\t\t\t\t\tfield++\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase field < len(x.Fields):\n\t\t\t\t\tr.Values = append(r.Values, n.Initializer.check(ctx, x.Fields[field].Type, fn, true, nil, nil, nil))\n\t\t\t\t\tfield++\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO\", ctx.position(n.Initializer)))\n\t\t\t\t}\n\t\t\t\tn0.Len++\n\t\t\t}\n\t\t\treturn Operand{Type: t, Value: r}\n\t\tcase *TaggedStructType:\n\t\t\tt = x.getType()\n\t\t\tif t == x {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\t\tcase *TaggedUnionType:\n\t\t\tt = x.getType()\n\t\t\tif t == x {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\t\tcase TypeKind:\n\t\t\tswitch {\n\t\t\tcase x.IsArithmeticType():\n\t\t\t\tswitch n.Case {\n\t\t\t\tcase 0: //  /* empty */\n\t\t\t\t\tif x.IsIntegerType() {\n\t\t\t\t\t\treturn Operand{Type: t, Value: &ir.Int64Value{}}\n\t\t\t\t\t}\n\n\t\t\t\t\tswitch t {\n\t\t\t\t\tcase Double, LongDouble:\n\t\t\t\t\t\treturn Operand{Type: t, Value: &ir.Float64Value{}}\n\t\t\t\t\tcase Float:\n\t\t\t\t\t\treturn Operand{Type: t, Value: &ir.Float64Value{}}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", ctx.position(n), t))\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", ctx.position(n), n.Case))\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\t\tcase *UnionType:\n\t\t\tfield := 0\n\t\t\tfor ; n != nil; n = n.InitializerList {\n\t\t\t\tif n.Designation != nil {\n\t\t\t\t\tdst, nt := n.Designation.check(ctx, x)\n\t\t\t\t\t_ = nt //TODO\n\t\t\t\t\tif len(dst) != 1 {\n\t\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t\t}\n\n\t\t\t\t\tfield = int(dst[0])\n\t\t\t\t\tswitch nv := len(r.Values); {\n\t\t\t\t\tcase nv < field:\n\t\t\t\t\t\tr.Values = append(r.Values, make([]ir.Value, field-nv)...)\n\t\t\t\t\tcase nv > field:\n\t\t\t\t\t\tr.Values[field] = n.Initializer.check(ctx, x.Fields[field].Type, fn, true, nil, nil, nil)\n\t\t\t\t\t\tfield++\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor x.Fields[field].Bits < 0 {\n\t\t\t\t\tfield++\n\t\t\t\t}\n\t\t\t\tswitch {\n\t\t\t\tcase field < len(x.Fields):\n\t\t\t\t\tr.Values = append(r.Values, n.Initializer.check(ctx, x.Fields[field].Type, fn, true, nil, nil, nil))\n\t\t\t\t\tfield++\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: TODO\", ctx.position(n.Initializer)))\n\t\t\t\t}\n\t\t\t\tn0.Len++\n\t\t\t}\n\t\t\treturn Operand{Type: t, Value: r}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: TODO %T\", ctx.position(n), x))\n\t\t}\n\t}\n}\n\nfunc (n *Designation) check(ctx *context, t Type) (r []int64, nt Type) {\n\tswitch x := underlyingType(t, true).(type) {\n\tcase *ArrayType:\n\t\tnt = x.Item\n\t\tfor l := n.DesignatorList; l != nil; l = l.DesignatorList {\n\t\t\tswitch n := l.Designator; n.Case {\n\t\t\tcase DesignatorField: // '.' IDENTIFIER\n\t\t\t\tpanic(\"TODO\")\n\t\t\tcase DesignatorIndex: // '[' ConstExpr ']'\n\t\t\t\top := n.ConstExpr.eval(ctx)\n\t\t\t\tswitch x := op.Value.(type) {\n\t\t\t\tcase *ir.Int64Value:\n\t\t\t\t\tif v := x.Value; v < mathutil.MinInt || v > mathutil.MaxInt {\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t}\n\n\t\t\t\t\tr = append(r, x.Value)\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\t\t}\n\tcase *StructType:\n\t\tt := Type(x)\n\t\tfor l := n.DesignatorList; l != nil; l = l.DesignatorList {\n\t\t\tswitch n := l.Designator; n.Case {\n\t\t\tcase DesignatorField: // '.' IDENTIFIER\n\t\t\t\tnm := n.Token2.Val\n\t\t\t\tvar f *FieldProperties\n\t\t\t\tswitch x := t.(type) {\n\t\t\t\tcase *StructType:\n\t\t\t\t\tctx.model.Layout(t)\n\t\t\t\t\tf = x.Field(nm)\n\t\t\t\t\tif f == nil || f.Type == nil {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"(C) %v: TODO %q\", ctx.position(n.Token2), dict.S(nm)))\n\t\t\t\t\t}\n\n\t\t\t\t\tif fi := f.Declarator.Field; fi > len(x.Fields) || x.Fields[fi].Name != nm {\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t}\n\t\t\t\tcase *UnionType:\n\t\t\t\t\tctx.model.Layout(t)\n\t\t\t\t\tf = x.Field(nm)\n\t\t\t\t\tif f == nil || f.Type == nil {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"(C) %v: TODO %q\", ctx.position(n.Token2), dict.S(nm)))\n\t\t\t\t\t}\n\n\t\t\t\t\tif fi := f.Declarator.Field; fi > len(x.Fields) || x.Fields[fi].Name != nm {\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v\", ctx.position(n)))\n\t\t\t\t}\n\n\t\t\t\tr = append(r, int64(f.Declarator.Field))\n\t\t\t\tt = f.Type\n\t\t\t\tnt = t\n\t\t\tcase DesignatorIndex: // '[' ConstExpr ']'\n\t\t\t\top := n.ConstExpr.eval(ctx)\n\t\t\t\tswitch x := UnderlyingType(t).(type) {\n\t\t\t\tcase *ArrayType:\n\t\t\t\t\tnt = x.Item\n\t\t\t\t\tswitch y := op.Value.(type) {\n\t\t\t\t\tcase *ir.Int64Value:\n\t\t\t\t\t\tif x.Size.Value == nil {\n\t\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif y.Value >= x.Size.Value.(*ir.Int64Value).Value {\n\t\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr = append(r, y.Value)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v %T %v\", ctx.position(n), t, y, op))\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v %T %v\", ctx.position(n), t, x, op))\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\t\t}\n\tcase *UnionType:\n\t\tt := Type(x)\n\t\tfor l := n.DesignatorList; l != nil; l = l.DesignatorList {\n\t\t\tswitch n := l.Designator; n.Case {\n\t\t\tcase DesignatorField: // '.' IDENTIFIER\n\t\t\t\tnm := n.Token2.Val\n\t\t\t\tvar f *FieldProperties\n\t\t\t\tswitch x := t.(type) {\n\t\t\t\t//TODO case *StructType:\n\t\t\t\t//TODO \tf = x.Field(nm)\n\t\t\t\t//TODO \tif f == nil || f.Type == nil {\n\t\t\t\t//TODO \t\tpanic(fmt.Errorf(\"(C) %v: TODO %q\", ctx.position(n.Token2), dict.S(nm)))\n\t\t\t\t//TODO \t}\n\n\t\t\t\t//TODO \tif fi := f.Declarator.Field; fi > len(x.Fields) || x.Fields[fi].Name != nm {\n\t\t\t\t//TODO \t\tpanic(\"TODO\")\n\t\t\t\t//TODO \t}\n\t\t\t\tcase *UnionType:\n\t\t\t\t\tctx.model.Layout(t)\n\t\t\t\t\tf = x.Field(nm)\n\t\t\t\t\tif f == nil || f.Type == nil {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"(C) %v: TODO %q\", ctx.position(n.Token2), dict.S(nm)))\n\t\t\t\t\t}\n\n\t\t\t\t\tif fi := f.Declarator.Field; fi > len(x.Fields) || x.Fields[fi].Name != nm {\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t\t\t\t}\n\n\t\t\t\tr = append(r, int64(f.Declarator.Field))\n\t\t\t\tt = f.Type\n\t\t\t\tnt = t\n\t\t\t//TODO case DesignatorIndex: // '[' ConstExpr ']'\n\t\t\t//TODO \tpanic(\"TODO\")\n\t\t\tdefault:\n\t\t\t\tpanic(n.Case)\n\t\t\t}\n\t\t}\n\t\tif len(r) > 1 {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t}\n\tn.List = r\n\treturn r, nt\n}\n\nfunc (n *Declarator) check(ctx *context, ds *DeclarationSpecifier, t Type, isObject bool, sc []int, fn *Declarator) (r Type) {\n\treturn n.check0(ctx, ds, t, isObject, sc, fn, nil)\n}\n\nfunc (n *Declarator) check0(ctx *context, ds *DeclarationSpecifier, t Type, isObject bool, sc []int, fn *Declarator, fnParams []*Declarator) (r Type) {\n\t// PointerOpt DirectDeclarator\n\tif l := len(sc); l != 0 {\n\t\tn.ScopeNum = sc[l-1]\n\t}\n\tn.DeclarationSpecifier = ds\n\tt = n.PointerOpt.check(ctx, t, &n.TypeQualifiers)\n\tn.Type = n.DirectDeclarator.check(ctx, t, sc, fn)\n\tisFunction := n.Type.Kind() == Function && !ds.IsTypedef()\n\tif fn != nil && !n.Embedded && !isFunction {\n\t\tfn.vars = append(fn.vars, n)\n\t}\n\tif isFunction && fnParams != nil {\n\t\tt := underlyingType(n.Type, true).(*FunctionType)\n\t\tif n := len(t.Params); n != 0 && n != len(fnParams) {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\tn.Parameters = nil\n\t\tt.Params = make([]Type, len(fnParams))\n\touter:\n\t\tfor _, v := range fnParams {\n\t\t\tnm := v.Name()\n\t\t\tfor i, w := range t.params {\n\t\t\t\tif nm == w {\n\t\t\t\t\tv.IsFunctionParameter = true\n\t\t\t\t\tt.Params[i] = v.Type\n\t\t\t\t\tcontinue outer\n\t\t\t\t}\n\t\t\t}\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t}\n\tif n.Embedded {\n\t\treturn n.Type\n\t}\n\n\t// [0]6.2.2\n\tswitch {\n\tcase\n\t\t// 3. If the declaration of a file scope identifier for an\n\t\t// object or a function contains the storage-class specifier\n\t\t// static, the identifier has internal linkage.\n\t\t(isObject || isFunction) && n.Scope == ctx.scope && ds.IsStatic():\n\n\t\tn.Linkage = LinkageInternal\n\tcase\n\t\t// 4. For an identifier declared with the storage-class\n\t\t// specifier extern in a scope in which a prior declaration of\n\t\t// that identifier is visible, if the prior declaration\n\t\t// specifies internal or external linkage, the linkage of the\n\t\t// identifier at the later declaration is the same as the\n\t\t// linkage specified at the prior declaration. If no prior\n\t\t// declaration is visible, or if the prior declaration\n\t\t// specifies no linkage, then the identifier has external\n\t\t// linkage.\n\t\t(isObject || isFunction) && ds.IsExtern():\n\n\t\tn.Linkage = LinkageExternal\n\tcase\n\t\t// 5. If the declaration of an identifier for a function has no\n\t\t// storage-class specifier, its linkage is determined exactly\n\t\t// as if it were declared with the storage-class specifier\n\t\t// extern. If the declaration of an identifier for an object\n\t\t// has file scope and no storage-class specifier, its linkage\n\t\t// is external.\n\t\t(isObject || isFunction) && (n.Scope == ctx.scope || isFunction) && len(ds.StorageClassSpecifiers) == 0:\n\n\t\tn.Linkage = LinkageExternal\n\tcase\n\t\t// 6. The following identifiers have no linkage: an identifier\n\t\t// declared to be anything other than an object or a function;\n\t\t// an identifier declared to be a function parameter; a block\n\t\t// scope identifier for an object declared without the\n\t\t// storage-class specifier extern.\n\t\t!(isObject || isFunction),\n\t\tn.IsFunctionParameter,\n\t\tn.Scope != ctx.scope && !ds.IsExtern():\n\n\t\tn.Linkage = LinkageNone\n\tdefault:\n\t\tpanic(ctx.position(n))\n\t}\n\n\t// [0]6.2.4\n\tswitch {\n\tcase\n\t\t// 3. An object whose identifier is declared with external or\n\t\t// internal linkage, or with the storage-class specifier static\n\t\t// has static storage duration. Its lifetime is the entire\n\t\t// execution of the program and its stored value is initialized\n\t\t// only once, prior to program startup.\n\t\tn.Linkage == LinkageExternal,\n\t\tn.Linkage == LinkageInternal,\n\t\tds.IsStatic():\n\n\t\tn.StorageDuration = StorageDurationStatic\n\tcase\n\t\t// 4. An object whose identifier is declared with no linkage\n\t\t// and without the storage-class specifier static has automatic\n\t\t// storage duration.\n\t\tn.Linkage == LinkageNone && !ds.IsStatic():\n\n\t\tn.StorageDuration = StorageDurationAutomatic\n\tdefault:\n\t\tpanic(ctx.position(n))\n\t}\n\n\tif (ds.IsExtern() || isFunction) && n.Scope != ctx.scope {\n\t\tif ds.IsExtern() {\n\t\t\tn.insert(ctx, isFunction)\n\t\t}\n\t\tn.Scope = ctx.scope\n\t}\n\tn.insert(ctx, isFunction)\n\treturn n.Type\n}\n\nfunc (n *Declarator) insert(ctx *context, isFunction bool) {\n\tnm := n.Name()\n\tswitch ex := n.Scope.Idents[n.Name()]; ex := ex.(type) {\n\tcase nil:\n\t\tn.Scope.insertDeclarator(ctx, n)\n\tcase *Declarator:\n\t\tswitch ex.Linkage {\n\t\tcase LinkageNone:\n\t\t\tswitch n.Linkage {\n\t\t\tcase LinkageNone:\n\t\t\t\tif ex.DeclarationSpecifier.IsTypedef() && n.DeclarationSpecifier.IsTypedef() && ex.Type.IsCompatible(n.Type) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tpanic(fmt.Errorf(\"%v: %s %v, %v %v:\", ctx.position(ex), dict.S(nm), ex.Type, n.Type, ctx.position(n)))\n\t\t\tdefault:\n\t\t\t\tpanic(n.Linkage)\n\t\t\t}\n\t\tcase LinkageExternal:\n\t\t\tswitch n.Linkage {\n\t\t\tcase LinkageExternal:\n\t\t\t\tif isFunction && (n.Scope.Parent != nil || n.FunctionDefinition == nil) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif !ex.Type.IsCompatible(n.Type) {\n\t\t\t\t\tif ex.Type.Kind() == Function && ex.FunctionDefinition == nil && n.FunctionDefinition != nil {\n\t\t\t\t\t\tif len(ex.Type.(*FunctionType).Params) == 0 {\n\t\t\t\t\t\t\tn.Scope.Idents[nm] = n\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif !(n.Name() == idMain && n.Scope.Parent == nil && n.Type.Kind() == Function) {\n\t\t\t\t\t\t//IncompatibleTypeDiff(ex.Type, n.Type) //TODO-\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\\n%v: %v\", ctx.position(ex), ex.Type, ctx.position(n), n.Type))\n\t\t\t\t\t}\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tif prefer(n) || !prefer(ex) {\n\t\t\t\t\tn.Scope.Idents[nm] = n\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v %v %v:\", ctx.position(n), n.Linkage, isFunction, ctx.position(ex)))\n\t\t\t}\n\t\tcase LinkageInternal:\n\t\t\tswitch n.Linkage {\n\t\t\tcase LinkageInternal:\n\t\t\t\tif !ex.Type.IsCompatible(n.Type) {\n\t\t\t\t\t//IncompatibleTypeDiff(ex.Type, n.Type) //TODO-\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\\n%v: %v\", ctx.position(ex), ex.Type, ctx.position(n), n.Type))\n\t\t\t\t}\n\t\t\tcase LinkageExternal:\n\t\t\t\tex.Linkage = n.Linkage\n\t\t\t\tn.Scope.Idents[nm] = n\n\t\t\tdefault:\n\t\t\t\t// Keep it internal.\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(ex.Linkage)\n\t\t}\n\n\t\tif isFunction {\n\t\t\tswitch {\n\t\t\tcase n.FunctionDefinition != nil:\n\t\t\t\tif ex.FunctionDefinition != nil {\n\t\t\t\t\tpanic(ctx.position(n))\n\t\t\t\t}\n\n\t\t\t\tex.Definition = n\n\t\t\t\tn.Scope.Idents[nm] = n\n\t\t\tcase ex.FunctionDefinition != nil:\n\t\t\t\tn.Definition = ex\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\n\t\tswitch {\n\t\tcase n.Initializer != nil:\n\t\t\tif ex.Initializer != nil {\n\t\t\t\tpanic(ctx.position(n))\n\t\t\t}\n\n\t\t\tex.Definition = n\n\t\t\tn.Scope.Idents[nm] = n\n\t\tcase ex.Initializer != nil:\n\t\t\tn.Definition = ex\n\t\t}\n\tdefault:\n\t\tpanic(ctx.position(n))\n\t}\n}\n\nfunc (n *PointerOpt) check(ctx *context, t Type, tq *[]*TypeQualifier) Type {\n\tif n == nil {\n\t\treturn t\n\t}\n\n\treturn n.Pointer.check(ctx, t, tq)\n}\n\nfunc (n *Pointer) check(ctx *context, t Type, tq *[]*TypeQualifier) Type {\n\tn.TypeQualifierListOpt.check(ctx, tq)\n\tswitch n.Case {\n\tcase PointerBase: // '*' TypeQualifierListOpt\n\t\treturn &PointerType{t}\n\tcase PointerPtr: // '*' TypeQualifierListOpt Pointer\n\t\treturn n.Pointer.check(ctx, &PointerType{t}, tq)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *TypeQualifierListOpt) check(ctx *context, tq *[]*TypeQualifier) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tn.TypeQualifierList.check(ctx, tq)\n}\n\nfunc (n *TypeQualifierList) check(ctx *context, tq *[]*TypeQualifier) {\n\ts := *tq\n\tfor ; n != nil; n = n.TypeQualifierList {\n\t\ts = append(s, n.TypeQualifier)\n\t}\n\t*tq = s\n}\n\nfunc (n *DirectDeclarator) check(ctx *context, t Type, sc []int, fn *Declarator) Type {\n\tswitch n.Case {\n\tcase DirectDeclaratorParen: // '(' Declarator ')'\n\t\treturn n.Declarator.check(ctx, nil, t, false, sc, fn)\n\tcase DirectDeclaratorIdentList: // DirectDeclarator '(' IdentifierListOpt ')'\n\t\tt := &FunctionType{\n\t\t\tparams: n.IdentifierListOpt.check(),\n\t\t\tResult: t,\n\t\t}\n\t\treturn n.DirectDeclarator.check(ctx, t, sc, fn)\n\tcase DirectDeclaratorParamList: // DirectDeclarator '(' ParameterTypeList ')'\n\t\tfp, variadic := n.ParameterTypeList.check(ctx)\n\t\tt := &FunctionType{\n\t\t\tParams:   fp,\n\t\t\tResult:   t,\n\t\t\tVariadic: variadic,\n\t\t}\n\t\treturn n.DirectDeclarator.check(ctx, t, sc, fn)\n\tcase DirectDeclaratorArraySize: // DirectDeclarator '[' \"static\" TypeQualifierListOpt Expr ']'\n\t\tvar tq []*TypeQualifier\n\t\tn.TypeQualifierListOpt.check(ctx, &tq)\n\t\tsz := n.Expr.eval(ctx, true, fn, nil, nil)\n\t\tt := &ArrayType{\n\t\t\tItem:           t,\n\t\t\tSize:           sz,\n\t\t\tTypeQualifiers: tq,\n\t\t}\n\t\treturn n.DirectDeclarator.check(ctx, t, sc, fn)\n\t//TODO case DirectDeclaratorArraySize2: // DirectDeclarator '[' TypeQualifierList \"static\" Expr ']'\n\tcase DirectDeclaratorArrayVar: // DirectDeclarator '[' TypeQualifierListOpt '*' ']'\n\t\tvar tq []*TypeQualifier\n\t\tn.TypeQualifierListOpt.check(ctx, &tq)\n\t\tt := &ArrayType{\n\t\t\tItem:           t,\n\t\t\tTypeQualifiers: tq,\n\t\t}\n\t\treturn n.DirectDeclarator.check(ctx, t, sc, fn)\n\tcase DirectDeclaratorArray: // DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'\n\t\tvar tq []*TypeQualifier\n\t\tn.TypeQualifierListOpt.check(ctx, &tq)\n\t\tn.ExprOpt.eval(ctx, true, fn, nil, nil)\n\t\tvar sz Operand\n\t\tif o := n.ExprOpt; o != nil {\n\t\t\tsz = o.Expr.Operand\n\t\t}\n\t\tt := &ArrayType{\n\t\t\tItem:           t,\n\t\t\tSize:           sz,\n\t\t\tTypeQualifiers: tq,\n\t\t}\n\t\treturn n.DirectDeclarator.check(ctx, t, sc, fn)\n\tcase DirectDeclaratorIdent: // IDENTIFIER\n\t\treturn t\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *IdentifierListOpt) check() []int {\n\tif n == nil {\n\t\treturn nil\n\t}\n\n\treturn n.IdentifierList.check()\n}\n\nfunc (n *IdentifierList) check() (r []int) {\n\tm := map[int]struct{}{}\n\tfor ; n != nil; n = n.IdentifierList {\n\t\tnm := n.Token.Val\n\t\tif n.Token.Rune == ',' {\n\t\t\tnm = n.Token2.Val\n\t\t}\n\n\t\tif _, ok := m[nm]; ok {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\tm[nm] = struct{}{}\n\t\tr = append(r, nm)\n\t}\n\treturn r\n}\n\nfunc (n *ParameterTypeList) check(ctx *context) ([]Type, bool) {\n\tswitch n.Case {\n\tcase ParameterTypeListBase: // ParameterList\n\t\treturn n.ParameterList.check(ctx), false\n\tcase ParameterTypeListDots: // ParameterList ',' \"...\"\n\t\treturn n.ParameterList.check(ctx), true\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *ParameterList) check(ctx *context) (r []Type) {\n\tfor ; n != nil; n = n.ParameterList {\n\t\tr = append(r, n.ParameterDeclaration.check(ctx))\n\t}\n\treturn r\n}\n\nfunc (n *ParameterDeclaration) check(ctx *context) Type {\n\tswitch n.Case {\n\tcase ParameterDeclarationAbstract: // DeclarationSpecifiers AbstractDeclaratorOpt\n\t\tds := &DeclarationSpecifier{}\n\t\tn.DeclarationSpecifiers.check(ctx, ds)\n\t\tn.AbstractDeclaratorOpt.check(ctx, ds, ds.typ(ctx))\n\t\tif n.AbstractDeclaratorOpt == nil {\n\t\t\treturn ds.typ(ctx)\n\t\t}\n\n\t\treturn n.AbstractDeclaratorOpt.AbstractDeclarator.Type\n\tcase ParameterDeclarationDeclarator: // DeclarationSpecifiers Declarator\n\t\tds := &DeclarationSpecifier{}\n\t\tn.DeclarationSpecifiers.check(ctx, ds)\n\t\tn.Declarator.IsFunctionParameter = true\n\t\treturn n.Declarator.check(ctx, ds, ds.typ(ctx), true, nil, nil)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *AbstractDeclaratorOpt) check(ctx *context, ds *DeclarationSpecifier, t Type) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tn.AbstractDeclarator.check(ctx, ds, t)\n}\n\nfunc (n *AbstractDeclarator) check(ctx *context, ds *DeclarationSpecifier, t Type) Type {\n\tn.DeclarationSpecifier = ds\n\tswitch n.Case {\n\tcase AbstractDeclaratorPointer: // Pointer\n\t\tn.Type = n.Pointer.check(ctx, t, &n.TypeQualifiers)\n\tcase AbstractDeclaratorAbstract: // PointerOpt DirectAbstractDeclarator\n\t\tt = n.PointerOpt.check(ctx, t, &n.TypeQualifiers)\n\t\tn.Type = n.DirectAbstractDeclarator.check(ctx, t)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\treturn n.Type\n}\n\nfunc (n *DirectAbstractDeclarator) check(ctx *context, t Type) Type {\n\tswitch n.Case {\n\tcase DirectAbstractDeclaratorAbstract: // '(' AbstractDeclarator ')'\n\t\treturn n.AbstractDeclarator.check(ctx, nil, t)\n\tcase DirectAbstractDeclaratorParamList: // '(' ParameterTypeListOpt ')'\n\t\tfp, variadic := n.ParameterTypeListOpt.check(ctx)\n\t\tt := &FunctionType{\n\t\t\tParams:   fp,\n\t\t\tResult:   t,\n\t\t\tVariadic: variadic,\n\t\t}\n\t\treturn t\n\tcase DirectAbstractDeclaratorDFn: // DirectAbstractDeclarator '(' ParameterTypeListOpt ')'\n\t\tfp, variadic := n.ParameterTypeListOpt.check(ctx)\n\t\tt := &FunctionType{\n\t\t\tParams:   fp,\n\t\t\tResult:   t,\n\t\t\tVariadic: variadic,\n\t\t}\n\t\treturn n.DirectAbstractDeclarator.check(ctx, t)\n\tcase DirectAbstractDeclaratorDArrSize: // DirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expr ']'\n\t\tvar tq []*TypeQualifier\n\t\tn.TypeQualifierListOpt.check(ctx, &tq)\n\t\tsz := n.Expr.eval(ctx, true, nil, nil, nil)\n\t\tt := &ArrayType{\n\t\t\tItem: t,\n\t\t\tSize: sz,\n\t\t}\n\t\tif n.DirectAbstractDeclaratorOpt == nil {\n\t\t\treturn t\n\t\t}\n\n\t\treturn n.DirectAbstractDeclaratorOpt.DirectAbstractDeclarator.check(ctx, t)\n\t//TODO case DirectAbstractDeclaratorDArrVL: // DirectAbstractDeclaratorOpt '[' '*' ']'\n\tcase DirectAbstractDeclaratorDArr: // DirectAbstractDeclaratorOpt '[' ExprOpt ']'\n\t\tn.ExprOpt.eval(ctx, true, nil, nil, nil)\n\t\tvar sz Operand\n\t\tif o := n.ExprOpt; o != nil {\n\t\t\tsz = o.Expr.Operand\n\t\t}\n\t\tt := &ArrayType{\n\t\t\tItem: t,\n\t\t\tSize: sz,\n\t\t}\n\t\tif n.DirectAbstractDeclaratorOpt == nil {\n\t\t\treturn t\n\t\t}\n\n\t\treturn n.DirectAbstractDeclaratorOpt.DirectAbstractDeclarator.check(ctx, t)\n\t//TODO case DirectAbstractDeclaratorDArrSize2: // DirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expr ']'\n\tcase DirectAbstractDeclaratorDArr2: // DirectAbstractDeclaratorOpt '[' TypeQualifierList ExprOpt ']'\n\t\tvar tq []*TypeQualifier\n\t\tn.TypeQualifierListOpt.check(ctx, &tq)\n\t\tn.ExprOpt.eval(ctx, true, nil, nil, nil)\n\t\tvar sz Operand\n\t\tif o := n.ExprOpt; o != nil {\n\t\t\tsz = o.Expr.Operand\n\t\t}\n\t\tt := &ArrayType{\n\t\t\tItem: t,\n\t\t\tSize: sz,\n\t\t}\n\t\tif n.DirectAbstractDeclaratorOpt == nil {\n\t\t\treturn t\n\t\t}\n\n\t\treturn n.DirectAbstractDeclaratorOpt.DirectAbstractDeclarator.check(ctx, t)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *ParameterTypeListOpt) check(ctx *context) ([]Type, bool) {\n\tif n == nil {\n\t\treturn nil, false\n\t}\n\n\treturn n.ParameterTypeList.check(ctx)\n}\n\nfunc (n *DeclarationSpecifiers) check(ctx *context, ds *DeclarationSpecifier) {\n\tswitch n.Case {\n\tcase DeclarationSpecifiersFunc: // FunctionSpecifier DeclarationSpecifiersOpt\n\t\tn.FunctionSpecifier.check(ctx, ds)\n\tcase DeclarationSpecifiersStorage: // StorageClassSpecifier DeclarationSpecifiersOpt\n\t\tn.StorageClassSpecifier.check(ctx, ds)\n\tcase DeclarationSpecifiersQualifier: // TypeQualifier DeclarationSpecifiersOpt\n\t\tn.TypeQualifier.check(ctx, ds)\n\tcase DeclarationSpecifiersSpecifier: // TypeSpecifier DeclarationSpecifiersOpt\n\t\tn.TypeSpecifier.check(ctx, ds)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\tn.DeclarationSpecifiersOpt.check(ctx, ds)\n}\n\nfunc (n *FunctionSpecifier) check(ctx *context, ds *DeclarationSpecifier) {\n\tds.FunctionSpecifiers = append(ds.FunctionSpecifiers, n)\n}\n\nfunc (n *TypeQualifier) check(ctx *context, ds *DeclarationSpecifier) {\n\tswitch n.Case {\n\tcase\n\t\tTypeQualifierConst,    // \"const\"\n\t\tTypeQualifierRestrict, // \"restrict\"\n\t\tTypeQualifierVolatile: // \"volatile\"\n\n\t\t//nop\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\tds.TypeQualifiers = append(ds.TypeQualifiers, n)\n}\n\nfunc (n *TypeSpecifier) check(ctx *context, ds *DeclarationSpecifier) {\n\tswitch n.Case {\n\tcase\n\t\tTypeSpecifierBool,     // \"_Bool\"\n\t\tTypeSpecifierChar,     // \"char\"\n\t\tTypeSpecifierComplex,  // \"_Complex\"\n\t\tTypeSpecifierDouble,   // \"double\"\n\t\tTypeSpecifierFloat,    // \"float\"\n\t\tTypeSpecifierInt,      // \"int\"\n\t\tTypeSpecifierLong,     // \"long\"\n\t\tTypeSpecifierName,     // TYPEDEF_NAME\n\t\tTypeSpecifierShort,    // \"short\"\n\t\tTypeSpecifierSigned,   // \"signed\"\n\t\tTypeSpecifierUnsigned, // \"unsigned\"\n\t\tTypeSpecifierVoid:     // \"void\"\n\n\t\t// nop\n\tcase TypeSpecifierEnum: // EnumSpecifier\n\t\tn.EnumSpecifier.check(ctx)\n\tcase TypeSpecifierStruct: // StructOrUnionSpecifier\n\t\tn.StructOrUnionSpecifier.check(ctx)\n\tcase TypeSpecifierTypeof: // \"typeof\" '(' TypeName ')'\n\t\tn.typ = n.TypeName.check(ctx)\n\tcase TypeSpecifierTypeofExpr: // \"typeof\" '(' Expr ')'\n\t\top := n.Expr.eval(ctx, false, nil, nil, nil)\n\t\tn.typ = op.Type\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n\tds.TypeSpecifiers = append(ds.TypeSpecifiers, n)\n}\n\nfunc (n *EnumSpecifier) check(ctx *context) { // [0]6.7.2.2\n\tn.Tag = n.Token2.Val\n\tif n.IdentifierOpt != nil {\n\t\tn.Tag = n.IdentifierOpt.Token.Val\n\t}\n\tswitch n.Case {\n\tcase EnumSpecifierTag: // \"enum\" IDENTIFIER\n\t\tn.typ = &TaggedEnumType{Tag: n.Tag, scope: n.scope}\n\tcase EnumSpecifierDefine: // \"enum\" IdentifierOpt '{' EnumeratorList CommaOpt '}'\n\t\tt := n.EnumeratorList.check(ctx, n.scope)\n\t\tt.Tag = n.Tag\n\t\tn.typ = t\n\t\tvar min int64\n\t\tvar max uint64\n\t\tfor _, v := range t.Enums {\n\t\t\tw := v.Operand.Value.(*ir.Int64Value).Value\n\t\t\tu := uint64(w)\n\t\t\tif !v.Operand.Type.IsUnsigned() && w < 0 {\n\t\t\t\tif w < min {\n\t\t\t\t\tmin = w\n\t\t\t\t}\n\t\t\t\tu = uint64(-w)\n\t\t\t}\n\t\t\tif u > max {\n\t\t\t\tmax = u\n\t\t\t}\n\t\t}\n\t\tt.Min = min\n\t\tt.Max = max\n\t\tvar x Operand\n\t\t//TODO- switch {\n\t\t//TODO- case min < 0:\n\t\tif u := uint64(-min); u > max {\n\t\t\tmax = u\n\t\t}\n\t\tx = newIntConst(ctx, n, max /*TODO- Char, */, Int, Long, LongLong, ULongLong)\n\t\t//TODO- default:\n\t\t//TODO- \tx = newIntConst(ctx, n, max /*TODO- UChar, */, UInt, ULong, ULongLong)\n\t\t//TODO- }\n\t\tfor i := range t.Enums {\n\t\t\tt.Enums[i].Operand.Type = x.Type\n\t\t\tt.Enums[i].Operand.IsEnumConst = true\n\t\t}\n\t\tif n.IdentifierOpt != nil {\n\t\t\tn.scope.insertEnumTag(ctx, n.IdentifierOpt.Token.Val, n)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *EnumSpecifier) isCompatible(m *EnumSpecifier) bool {\n\tif n.Tag != m.Tag || (n.EnumeratorList != nil) != (m.EnumeratorList != nil) {\n\t\treturn false\n\t}\n\n\tif n.typ != nil && m.typ != nil {\n\t\treturn n.typ.IsCompatible(m.typ)\n\t}\n\n\tpanic(fmt.Errorf(\"%v, %v\", n, m))\n}\n\nfunc (n *EnumeratorList) check(ctx *context, s *Scope) *EnumType {\n\tr := &EnumType{}\n\tiota := int64(-1)\n\tfor ; n != nil; n = n.EnumeratorList {\n\t\tr.Enums = append(r.Enums, n.Enumerator.check(ctx, s, &iota))\n\t}\n\treturn r\n}\n\nfunc (n *Enumerator) check(ctx *context, s *Scope, iota *int64) *EnumerationConstant {\n\tc := n.EnumerationConstant\n\tswitch n.Case {\n\tcase EnumeratorBase: // EnumerationConstant\n\t\t*iota++\n\t\tc.Operand = Operand{Value: &ir.Int64Value{Value: *iota}, Type: Int}\n\t\ts.insertEnumerationConstant(ctx, c)\n\t\treturn c\n\tcase EnumeratorInit: // EnumerationConstant '=' ConstExpr\n\t\tc.Operand = n.ConstExpr.eval(ctx)\n\t\ts.insertEnumerationConstant(ctx, c)\n\t\tswitch x := c.Operand.Value.(type) {\n\t\tcase *ir.Int64Value:\n\t\t\t*iota = x.Value\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\treturn c\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *StructOrUnionSpecifier) check(ctx *context) {\n\tvar tag int\n\tif n.IdentifierOpt != nil {\n\t\ttag = n.IdentifierOpt.Token.Val\n\t}\n\tswitch n.Case {\n\tcase StructOrUnionSpecifierTag: // StructOrUnion IDENTIFIER\n\t\tswitch n.StructOrUnion.Case {\n\t\tcase StructOrUnionStruct:\n\t\t\tn.typ = &TaggedStructType{Tag: n.Token.Val, scope: n.scope}\n\t\tcase StructOrUnionUnion:\n\t\t\tn.typ = &TaggedUnionType{Tag: n.Token.Val, scope: n.scope}\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\tcase StructOrUnionSpecifierEmpty: // StructOrUnion IdentifierOpt '{' '}'\n\t\tswitch n.StructOrUnion.Case {\n\t\tcase StructOrUnionStruct:\n\t\t\tn.typ = &StructType{structBase{Tag: tag}}\n\t\tdefault:\n\t\t\tpanic(ctx.position(n))\n\t\t}\n\t\tif tag != 0 {\n\t\t\tn.scope.Parent.insertStructTag(ctx, n)\n\t\t}\n\tcase StructOrUnionSpecifierDefine: // StructOrUnion IdentifierOpt '{' StructDeclarationList '}'\n\t\tswitch n.StructOrUnion.Case {\n\t\tcase StructOrUnionStruct:\n\t\t\tn.typ = &StructType{structBase{Tag: tag, Fields: n.StructDeclarationList.check(ctx), scope: n.scope}}\n\t\tdefault:\n\t\t\tn.typ = &UnionType{structBase{Tag: tag, Fields: n.StructDeclarationList.check(ctx), scope: n.scope}}\n\t\t}\n\t\tif tag != 0 {\n\t\t\tn.scope.Parent.insertStructTag(ctx, n)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *StructDeclarationList) check(ctx *context) (r []Field) {\n\tfield := 0\n\tfor ; n != nil; n = n.StructDeclarationList {\n\t\tr = append(r, n.StructDeclaration.check(ctx, &field)...)\n\t}\n\tfor len(r) > 0 && r[len(r)-1].Bits < 0 {\n\t\tr = r[:len(r)-1]\n\t}\n\treturn r\n}\n\nfunc (n *StructDeclaration) check(ctx *context, field *int) []Field {\n\tswitch n.Case {\n\tcase StructDeclarationBase: // SpecifierQualifierList StructDeclaratorList ';'\n\t\tds := &DeclarationSpecifier{}\n\t\tn.SpecifierQualifierList.check(ctx, ds)\n\t\treturn n.StructDeclaratorList.check(ctx, ds, field)\n\tcase StructDeclarationAnon: // SpecifierQualifierList ';'\n\t\tds := &DeclarationSpecifier{}\n\t\tn.SpecifierQualifierList.check(ctx, ds)\n\t\t*field++\n\t\treturn []Field{{Type: ds.typ(ctx), Anonymous: true}}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *StructDeclaratorList) check(ctx *context, ds *DeclarationSpecifier, field *int) (r []Field) {\n\tfor ; n != nil; n = n.StructDeclaratorList {\n\t\tr = append(r, n.StructDeclarator.check(ctx, ds, *field))\n\t\t*field++\n\t}\n\treturn r\n}\n\nfunc (n *StructDeclarator) check(ctx *context, ds *DeclarationSpecifier, field int) Field {\n\tswitch n.Case {\n\tcase StructDeclaratorBase: // Declarator\n\t\tf := Field{Type: n.Declarator.check(ctx, ds, ds.typ(ctx), false, nil, nil), Name: n.Declarator.Name(), Declarator: n.Declarator}\n\t\tn.Declarator.IsField = true\n\t\tn.Declarator.Field = field\n\t\treturn f\n\tcase StructDeclaratorBits: // DeclaratorOpt ':' ConstExpr\n\t\tvar d *Declarator\n\t\tvar nm int\n\t\tt := ds.typ(ctx)\n\t\tif n.DeclaratorOpt != nil {\n\t\t\td = n.DeclaratorOpt.Declarator\n\t\t\tnm = d.Name()\n\t\t\td.IsField = true\n\t\t\td.Field = field\n\t\t\tt = d.check(ctx, ds, t, false, nil, nil)\n\t\t}\n\t\top := n.ConstExpr.eval(ctx)\n\t\tif op.Value == nil {\n\t\t\tpanic(ctx.position)\n\t\t}\n\t\tif !op.isIntegerType() {\n\t\t\tpanic(ctx.position)\n\t\t}\n\t\tbits := op.Value.(*ir.Int64Value).Value\n\t\tif bits > 64 {\n\t\t\tpanic(ctx.position)\n\t\t}\n\n\t\tif bits == 0 {\n\t\t\tbits = -1\n\t\t}\n\t\tn.Bits = int(bits)\n\t\tif d != nil {\n\t\t\td.Bits = n.Bits\n\t\t}\n\t\treturn Field{Type: t, Name: nm, Bits: n.Bits, Declarator: d}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *SpecifierQualifierList) check(ctx *context, ds *DeclarationSpecifier) {\n\tswitch n.Case {\n\tcase SpecifierQualifierListQualifier: // TypeQualifier SpecifierQualifierListOpt\n\t\tn.TypeQualifier.check(ctx, ds)\n\t\tn.SpecifierQualifierListOpt.check(ctx, ds)\n\tcase SpecifierQualifierListSpecifier: // TypeSpecifier SpecifierQualifierListOpt\n\t\tn.TypeSpecifier.check(ctx, ds)\n\t\tn.SpecifierQualifierListOpt.check(ctx, ds)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: TODO %v\", ctx.position(n), n.Case))\n\t}\n}\n\nfunc (n *SpecifierQualifierListOpt) check(ctx *context, ds *DeclarationSpecifier) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tn.SpecifierQualifierList.check(ctx, ds)\n}\n\nfunc (n *StorageClassSpecifier) check(ctx *context, ds *DeclarationSpecifier) {\n\tif len(ds.StorageClassSpecifiers) != 0 {\n\t\tpanic(\"TODO\") // [0]6.7.1-2\n\t}\n\tds.StorageClassSpecifiers = []*StorageClassSpecifier{n}\n}\n\nfunc (n *DeclarationSpecifiersOpt) check(ctx *context, ds *DeclarationSpecifier) {\n\tif n == nil {\n\t\treturn\n\t}\n\n\tn.DeclarationSpecifiers.check(ctx, ds)\n}\n\n// IsTLD reports whether n is declared in file scope.\nfunc (n *Declarator) IsTLD() bool { return n.Scope.Parent == nil }\n\nfunc (n *Expr) isSideEffectsFree() bool {\n\treturn false //TODO-\n\n\tswitch n.Case {\n\tcase\n\t\tExprChar,       // CHARCONST\n\t\tExprFloat,      // FLOATCONST\n\t\tExprIdent,      // IDENTIFIER\n\t\tExprInt,        // INTCONST\n\t\tExprLChar,      // LONGCHARCONST\n\t\tExprSizeofExpr, // \"sizeof\" Expr\n\t\tExprSizeofType, // \"sizeof\" '(' TypeName ')'\n\t\tExprString:     // STRINGLITERAL\n\n\t\treturn true\n\tcase ExprPExprList: // '(' ExprList ')'\n\t\treturn n.ExprList.isSideEffectsFree()\n\tcase\n\t\tExprAddAssign, // Expr \"+=\" Expr\n\t\tExprAndAssign, // Expr \"&=\" Expr\n\t\tExprAssign,    // Expr '=' Expr\n\t\tExprCall,      // Expr '(' ArgumentExprListOpt ')'\n\t\tExprCompLit,   // '(' TypeName ')' '{' InitializerList CommaOpt '}' //TODO we can do better\n\t\tExprDivAssign, // Expr \"/=\" Expr\n\t\tExprLshAssign, // Expr \"<<=\" Expr\n\t\tExprModAssign, // Expr \"%=\" Expr\n\t\tExprMulAssign, // Expr \"*=\" Expr\n\t\tExprOrAssign,  // Expr \"|=\" Expr\n\t\tExprPostDec,   // Expr \"--\"\n\t\tExprPostInc,   // Expr \"++\"\n\t\tExprPreDec,    // \"--\" Expr\n\t\tExprPreInc,    // \"++\" Expr\n\t\tExprRshAssign, // Expr \">>=\" Expr\n\t\tExprStatement, // '(' CompoundStmt ')' //TODO we can do better\n\t\tExprSubAssign, // Expr \"-=\" Expr\n\t\tExprXorAssign: // Expr \"^=\" Expr\n\n\t\treturn false\n\tcase ExprCast: // '(' TypeName ')' Expr\n\t\treturn !isVaList(n.Expr.Operand.Type) && n.Expr.isSideEffectsFree()\n\tcase ExprCond: // Expr '?' ExprList ':' Expr\n\t\tif !n.Expr.isSideEffectsFree() {\n\t\t\treturn false\n\t\t}\n\n\t\tswitch {\n\t\tcase n.Expr.Operand.IsNonZero():\n\t\t\treturn n.ExprList.isSideEffectsFree()\n\t\tcase n.Expr.Operand.IsZero():\n\t\t\treturn n.Expr2.isSideEffectsFree()\n\t\t}\n\t\treturn false\n\tcase\n\t\tExprAdd, // Expr '+' Expr\n\t\tExprAnd, // Expr '&' Expr\n\t\tExprDiv, // Expr '/' Expr\n\t\tExprEq,  // Expr \"==\" Expr\n\t\tExprGe,  // Expr \">=\" Expr\n\t\tExprGt,  // Expr \">\" Expr\n\t\tExprLe,  // Expr \"<=\" Expr\n\t\tExprLsh, // Expr \"<<\" Expr\n\t\tExprLt,  // Expr '<' Expr\n\t\tExprMod, // Expr '%' Expr\n\t\tExprMul, // Expr '*' Expr\n\t\tExprNe,  // Expr \"!=\" Expr\n\t\tExprOr,  // Expr '|' Expr\n\t\tExprRsh, // Expr \">>\" Expr\n\t\tExprSub, // Expr '-' Expr\n\t\tExprXor: // Expr '^' Expr\n\n\t\treturn n.Expr.isSideEffectsFree() && n.Expr2.isSideEffectsFree()\n\tcase ExprLAnd: // Expr \"&&\" Expr\n\t\treturn n.Expr.isSideEffectsFree() && n.Expr2.isSideEffectsFree()\n\tcase ExprLOr: // Expr \"||\" Expr\n\t\treturn n.Expr.isSideEffectsFree() && n.Expr2.isSideEffectsFree()\n\tcase\n\t\tExprAddrof,     // '&' Expr\n\t\tExprCpl,        // '~' Expr\n\t\tExprDeref,      // '*' Expr\n\t\tExprNot,        // '!' Expr\n\t\tExprPSelect,    // Expr \"->\" IDENTIFIER\n\t\tExprSelect,     // Expr '.' IDENTIFIER\n\t\tExprUnaryMinus, // '-' Expr\n\t\tExprUnaryPlus:  // '+' Expr\n\n\t\treturn n.Expr.isSideEffectsFree()\n\tcase ExprIndex: // Expr '[' ExprList ']'\n\t\treturn n.Expr.isSideEffectsFree() && n.ExprList.isSideEffectsFree()\n\tdefault:\n\t\tpanic(fmt.Sprint(n.Case, n.Operand))\n\t}\n}\n\nfunc (n *ExprList) isSideEffectsFree() bool {\n\tfor l := n; l != nil; l = l.ExprList {\n\t\tif !l.Expr.isSideEffectsFree() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\n// IsNonZero reports whether n is provably non zero.\nfunc (n *ExprList) IsNonZero() bool {\n\tfor n.ExprList != nil {\n\t\tn = n.ExprList\n\t}\n\treturn n.Expr.IsNonZero()\n}\n\n// IsNonZero reports whether n is provably non zero.\nfunc (n *Expr) IsNonZero() bool {\n\treturn n.Operand.IsNonZero() //TODO-\n\n\tif n.Operand.IsNonZero() {\n\t\treturn true\n\t}\n\n\tswitch n.Case {\n\tcase\n\t\tExprAdd,        // Expr '+' Expr\n\t\tExprAddAssign,  // Expr \"+=\" Expr\n\t\tExprAnd,        // Expr '&' Expr\n\t\tExprAndAssign,  // Expr \"&=\" Expr\n\t\tExprCall,       // Expr '(' ArgumentExprListOpt ')'\n\t\tExprChar,       // CHARCONST\n\t\tExprDeref,      // '*' Expr\n\t\tExprDiv,        // Expr '/' Expr\n\t\tExprEq,         // Expr \"==\" Expr\n\t\tExprFloat,      // FLOATCONST\n\t\tExprGe,         // Expr \">=\" Expr\n\t\tExprGt,         // Expr '>' Expr\n\t\tExprIdent,      // IDENTIFIER\n\t\tExprIndex,      // Expr '[' ExprList ']'\n\t\tExprInt,        // INTCONST\n\t\tExprLe,         // Expr \"<=\" Expr\n\t\tExprLsh,        // Expr \"<<\" Expr\n\t\tExprLt,         // Expr '<' Expr\n\t\tExprMod,        // Expr '%' Expr\n\t\tExprMul,        // Expr '*' Expr\n\t\tExprPSelect,    // Expr \"->\" IDENTIFIER\n\t\tExprPostDec,    // Expr \"--\"\n\t\tExprPostInc,    // Expr \"++\"\n\t\tExprPreDec,     // \"--\" Expr\n\t\tExprPreInc,     // Expr \"++\"\n\t\tExprRsh,        // Expr \">>\" Expr\n\t\tExprRshAssign,  // Expr \">>=\" Expr\n\t\tExprSelect,     // Expr '.' IDENTIFIER\n\t\tExprSizeofExpr, // \"sizeof\" Expr\n\t\tExprSizeofType, // \"sizeof\" '(' TypeName ')'\n\t\tExprString,     // STRINGLITERAL\n\t\tExprSubAssign,  // Expr \"-=\" Expr\n\t\tExprSub:        // Expr '-' Expr\n\n\t\treturn false\n\tcase ExprAddrof: // '&' Expr\n\t\tn = n.Expr\n\t\tfor {\n\t\t\tswitch n.Case {\n\t\t\tcase ExprIdent: // IDENTIFIER\n\t\t\t\treturn true\n\t\t\tcase ExprIndex: // Expr '[' ExprList ']'\n\t\t\t\tn = n.Expr\n\t\t\tcase ExprPSelect: // Expr \"->\" IDENTIFIER\n\t\t\t\treturn false\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"Expr.IsNonZero %s\", n.Case))\n\t\t\t}\n\t\t}\n\tcase ExprAssign: // Expr '=' Expr\n\t\treturn n.Expr2.IsNonZero()\n\tcase ExprCast: // '(' TypeName ')' Expr\n\t\treturn n.Expr.IsNonZero()\n\tcase ExprCond: // Expr '?' ExprList ':' Expr\n\t\treturn n.Expr.IsNonZero() && n.ExprList.IsNonZero() || n.Expr.IsZero() && n.Expr2.IsNonZero()\n\tcase ExprCpl: // '~' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprLAnd: // Expr \"&&\" Expr\n\t\treturn n.Expr.IsNonZero() && n.Expr2.IsNonZero()\n\tcase ExprLOr: // Expr \"||\" Expr\n\t\treturn n.Expr.IsNonZero() || n.Expr2.IsNonZero()\n\tcase ExprNe: // Expr \"!=\" Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsNonZero() || n.Expr.IsNonZero() && n.Expr2.IsZero()\n\tcase ExprNot: // '!' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprOr: // Expr '|' Expr\n\t\treturn n.Expr.IsNonZero() || n.Expr2.IsNonZero()\n\tcase ExprOrAssign: // Expr \"|=\" Expr\n\t\treturn n.Expr.IsNonZero() || n.Expr2.IsNonZero()\n\tcase ExprPExprList: // '(' ExprList ')'\n\t\treturn n.ExprList.IsNonZero()\n\tcase ExprUnaryMinus: // '-' Expr\n\t\treturn n.Expr.IsNonZero()\n\tcase ExprUnaryPlus: // '+' Expr\n\t\treturn n.Expr.IsNonZero()\n\tcase ExprXor: // Expr '^' Expr\n\t\treturn n.Expr.IsNonZero() && n.Expr2.IsZero() || n.Expr.IsZero() && n.Expr2.IsNonZero()\n\tcase ExprXorAssign: // Expr \"^=\" Expr\n\t\treturn n.Expr.IsNonZero() && n.Expr2.IsZero() || n.Expr.IsZero() && n.Expr2.IsNonZero()\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T.IsNonZero %v\", n, n.Case))\n\t}\n}\n\n// IsZero reports whether n is provably zero.\nfunc (n *ExprList) IsZero() bool {\n\tfor n.ExprList != nil {\n\t\tn = n.ExprList\n\t}\n\treturn n.Expr.IsZero()\n}\n\n// IsZero reports whether n is provably zero.\nfunc (n *Expr) IsZero() bool {\n\treturn n.Operand.IsZero() //TODO-\n\n\tif n.Operand.IsZero() {\n\t\treturn true\n\t}\n\n\tswitch n.Case {\n\tcase\n\t\tExprAdd,        // Expr '+' Expr\n\t\tExprAddAssign,  // Expr \"+=\" Expr\n\t\tExprAddrof,     // '&' Expr\n\t\tExprCall,       // Expr '(' ArgumentExprListOpt ')'\n\t\tExprChar,       // CHARCONST\n\t\tExprCompLit,    // '(' TypeName ')' '{' InitializerList CommaOpt '}' //TODO we can do better\n\t\tExprCpl,        // '~' Expr\n\t\tExprDeref,      // '*' Expr\n\t\tExprDiv,        // Expr '/' Expr\n\t\tExprEq,         // Expr \"==\" Expr\n\t\tExprFloat,      // FLOATCONST\n\t\tExprGe,         // Expr \">=\" Expr\n\t\tExprGt,         // Expr '>' Expr\n\t\tExprIdent,      // IDENTIFIER\n\t\tExprIndex,      // Expr '[' ExprList ']'\n\t\tExprInt,        // INTCONST\n\t\tExprLe,         // Expr \"<=\" Expr\n\t\tExprLsh,        // Expr \"<<\" Expr\n\t\tExprLt,         // Expr '<' Expr\n\t\tExprPSelect,    // Expr \"->\" IDENTIFIER\n\t\tExprPostDec,    // \"--\" Expr\n\t\tExprPostInc,    // Expr \"++\"\n\t\tExprPreDec,     // \"--\" Expr\n\t\tExprPreInc,     // Expr \"++\"\n\t\tExprRsh,        // Expr \">>\" Expr\n\t\tExprRshAssign,  // Expr \">>=\" Expr\n\t\tExprSubAssign,  // Expr \"-=\" Expr\n\t\tExprSelect,     // Expr '.' IDENTIFIER\n\t\tExprSizeofExpr, // \"sizeof\" Expr\n\t\tExprSizeofType, // \"sizeof\" '(' TypeName ')'\n\t\tExprString,     // STRINGLITERAL\n\t\tExprSub:        // Expr '-' Expr\n\n\t\treturn false\n\tcase ExprAnd: // Expr '&' Expr\n\t\treturn n.Expr.IsZero() || n.Expr2.IsZero()\n\tcase ExprAndAssign: // Expr \"&=\" Expr\n\t\treturn n.Expr.IsZero() || n.Expr2.IsZero()\n\tcase ExprAssign: // Expr '=' Expr\n\t\treturn n.Expr2.IsZero()\n\tcase ExprCast: // '(' TypeName ')' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprCond: // Expr '?' ExprList ':' Expr\n\t\treturn n.Expr.IsNonZero() && n.ExprList.IsZero() || n.Expr.IsNonZero() && n.Expr2.IsZero()\n\tcase ExprLAnd: // Expr \"&&\" Expr\n\t\treturn n.Expr.IsZero() || n.Expr2.IsZero()\n\tcase ExprLOr: // Expr \"||\" Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero()\n\tcase ExprMod: // Expr '%' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprMul: // Expr '*' Expr\n\t\treturn n.Expr.IsZero() || n.Expr2.IsZero()\n\tcase ExprNe: // Expr \"!=\" Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero()\n\tcase ExprNot: // '!' Expr\n\t\treturn n.Expr.IsNonZero()\n\tcase ExprOr: // Expr '|' Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero()\n\tcase ExprOrAssign: // Expr \"|=\" Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero()\n\tcase ExprPExprList: // '(' ExprList ')'\n\t\treturn n.ExprList.IsZero()\n\tcase ExprUnaryMinus: // '-' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprUnaryPlus: // '+' Expr\n\t\treturn n.Expr.IsZero()\n\tcase ExprXor: // Expr '^' Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero() || n.Expr.Equals(n.Expr2)\n\tcase ExprXorAssign: // Expr \"^=\" Expr\n\t\treturn n.Expr.IsZero() && n.Expr2.IsZero() || n.Expr.Equals(n.Expr2)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T.IsZero %v\", n, n.Case))\n\t}\n}\n\nfunc (n *ExprList) equals(m *ExprList) bool {\n\tif (n.ExprList == nil) != (m.ExprList == nil) {\n\t\treturn false\n\t}\n\n\tfor l, k := n, m; l != nil; l, k = l.ExprList, k.ExprList {\n\t\tif (l.ExprList == nil) != (k.ExprList == nil) || !l.Expr.Equals(k.Expr) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc (n *ExprList) equals2(m *Expr) bool {\n\tfor n.ExprList != nil {\n\t\tn = n.ExprList\n\t}\n\treturn n.Expr.Equals(m)\n}\n\n// Equals reports whether s equals m.\nfunc (n *Expr) Equals(m *Expr) bool {\n\treturn false //TODO-\n\n\tif n.Operand.Type != m.Operand.Type || n.Operand.Value != m.Operand.Value || !n.isSideEffectsFree() || !m.isSideEffectsFree() {\n\t\treturn false\n\t}\n\n\tif n.Case != m.Case {\n\t\tswitch {\n\t\tcase n.Case == ExprPExprList:\n\t\t\treturn n.ExprList.equals2(m)\n\t\tcase m.Case == ExprPExprList:\n\t\t\treturn m.ExprList.equals2(n)\n\t\t}\n\t\treturn false\n\t}\n\n\tswitch n.Case {\n\tcase\n\t\tExprPSelect, // Expr \"->\" IDENTIFIER\n\t\tExprSelect:  // Expr '.' IDENTIFIER\n\n\t\treturn n.Expr.Equals(m.Expr) && n.Token.Val == m.Token.Val && n.Token2.Val == m.Token2.Val\n\tcase ExprIdent: // IDENTIFIER\n\t\treturn n.Token.Val == m.Token.Val\n\tcase ExprPExprList: // '(' ExprList ')'\n\t\treturn n.ExprList.equals(m.ExprList)\n\tcase ExprInt: // INTCONST\n\t\treturn true\n\tcase // unary\n\t\tExprCast,      // '(' TypeName ')' Expr\n\t\tExprCpl,       // '~' Expr\n\t\tExprDeref,     // '*' Expr\n\t\tExprNot,       // '!' Expr\n\t\tExprUnaryPlus: // '+' Expr\n\n\t\treturn n.Expr.Equals(m.Expr)\n\tcase ExprIndex: // Expr '[' ExprList ']'\n\t\treturn n.Expr.Equals(m.Expr) && n.ExprList.equals(m.ExprList)\n\tcase // binary commutative\n\t\tExprAdd, // Expr '+' Expr\n\t\tExprAnd, // Expr '&' Expr\n\t\tExprEq,  // Expr \"==\" Expr\n\t\tExprGe,  // Expr \"==\" Expr\n\t\tExprLe,  // Expr \"==\" Expr\n\t\tExprLt,  // Expr \"==\" Expr\n\t\tExprMul, // Expr '*' Expr\n\t\tExprNe,  // Expr \"==\" Expr\n\t\tExprOr,  // Expr '|' Expr\n\t\tExprXor: // Expr '^' Expr\n\n\t\treturn n.Expr.Equals(m.Expr) && n.Expr2.Equals(m.Expr2) || n.Expr.Equals(m.Expr2) && n.Expr2.Equals(m.Expr)\n\tcase // binary\n\t\tExprDiv,  // Expr '/' Expr\n\t\tExprGt,   // Expr '>' Expr\n\t\tExprLAnd, // Expr \"&&\" Expr\n\t\tExprLOr,  // Expr \"||\" Expr\n\t\tExprLsh,  // Expr \"<<\" Expr\n\t\tExprMod,  // Expr '%' Expr\n\t\tExprRsh,  // Expr \">>\" Expr\n\t\tExprSub:  // Expr '-' Expr\n\n\t\treturn n.Expr.Equals(m.Expr) && n.Expr2.Equals(m.Expr2)\n\tcase ExprCall: // Expr '(' ArgumentExprListOpt ')'\n\t\tif !n.Expr.Equals(m.Expr) {\n\t\t\treturn false\n\t\t}\n\n\t\tif (n.ArgumentExprListOpt == nil) != (m.ArgumentExprListOpt == nil) {\n\t\t\treturn false\n\t\t}\n\n\t\tif n.ArgumentExprListOpt == nil {\n\t\t\treturn true\n\t\t}\n\n\t\tfor l, k := n.ArgumentExprListOpt.ArgumentExprList, m.ArgumentExprListOpt.ArgumentExprList; l != nil; l, k = l.ArgumentExprList, k.ArgumentExprList {\n\t\t\tif (l.ArgumentExprList == nil) != (k.ArgumentExprList == nil) || !l.Expr.Equals(k.Expr) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T.Equal %v\", n, n.Case))\n\t}\n}\n\nfunc (n *EnumerationConstant) equal(m *EnumerationConstant) (r bool) {\n\treturn n.Token.Val == m.Token.Val && n.Operand.Value.(*ir.Int64Value).Value == m.Operand.Value.(*ir.Int64Value).Value\n}\n\n// DumpOperands dumps the operands of n to stdout.\nfunc (n *ExprList) DumpOperands(s string) {\n\tfor l := n; l != nil; l = l.ExprList {\n\t\tl.Expr.DumpOperands(s + \"· \")\n\t}\n}\n\n// DumpOperands dumps the operands of n to stdout.\nfunc (n *Expr) DumpOperands(s string) {\n\tz := \"\"\n\tswitch {\n\tcase n.IsZero():\n\t\tz = \".Z\"\n\tcase n.IsNonZero():\n\t\tz = \".NZ\"\n\t}\n\tfmt.Printf(\"%s%v%v %v\\n\", s, n.Case, z, n.Operand)\n\tswitch n.Case {\n\tcase\n\t\tExprAddrof,\n\t\tExprCast,\n\t\tExprCpl,\n\t\tExprDeref,\n\t\tExprIndex,\n\t\tExprNot,\n\t\tExprPSelect,\n\t\tExprPostDec,\n\t\tExprPostInc,\n\t\tExprPreDec,\n\t\tExprPreInc,\n\t\tExprSelect,\n\t\tExprSizeofExpr,\n\t\tExprUnaryMinus,\n\t\tExprUnaryPlus:\n\n\t\tn.Expr.DumpOperands(s + \"· \")\n\tcase\n\t\tExprAdd,\n\t\tExprAnd,\n\t\tExprAndAssign,\n\t\tExprAssign,\n\t\tExprDiv,\n\t\tExprEq,\n\t\tExprGe,\n\t\tExprGt,\n\t\tExprLAnd,\n\t\tExprLOr,\n\t\tExprLe,\n\t\tExprLsh,\n\t\tExprLt,\n\t\tExprMod,\n\t\tExprMul,\n\t\tExprNe,\n\t\tExprOr,\n\t\tExprOrAssign,\n\t\tExprRsh,\n\t\tExprSub,\n\t\tExprXor,\n\t\tExprXorAssign:\n\n\t\tn.Expr.DumpOperands(s + \"· \")\n\t\tn.Expr2.DumpOperands(s + \"· \")\n\tcase ExprPExprList:\n\t\tn.ExprList.DumpOperands(s + \"· \")\n\tcase ExprCond:\n\t\tn.Expr.DumpOperands(s + \"· \")\n\t\tn.ExprList.DumpOperands(s + \"· \")\n\t\tn.Expr2.DumpOperands(s + \"· \")\n\tcase\n\t\tExprCall,\n\t\tExprChar,\n\t\tExprFloat,\n\t\tExprIdent,\n\t\tExprInt,\n\t\tExprSizeofType,\n\t\tExprString:\n\n\t\t// nop\n\tdefault:\n\t\tpanic(n.Case.String())\n\t}\n}\n"
  },
  {
    "path": "v2/ast_test.go",
    "content": "// Code generated by yy. DO NOT EDIT.\n\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"fmt\"\n)\n\nfunc ExampleAbstractDeclarator_pointer() {\n\tfmt.Println(exampleAST(177, \"\\U00100000 ( _Bool * )\"))\n\t// Output:\n\t// &cc.AbstractDeclarator{\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: '*',\n\t// · },\n\t// }\n}\n\nfunc ExampleAbstractDeclarator_abstract() {\n\tfmt.Println(exampleAST(178, \"\\U00100000 ( _Bool ( ) )\"))\n\t// Output:\n\t// &cc.AbstractDeclarator{\n\t// · Case: 1,\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 1,\n\t// · · Token: '(',\n\t// · · Token2: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleAbstractDeclaratorOpt_case0() {\n\tfmt.Println(exampleAST(179, \"\\U00100000 ( _Bool )\") == (*AbstractDeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleAbstractDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(180, \"\\U00100000 ( _Bool * )\"))\n\t// Output:\n\t// &cc.AbstractDeclaratorOpt{\n\t// · AbstractDeclarator: &cc.AbstractDeclarator{\n\t// · · Pointer: &cc.Pointer{\n\t// · · · Token: '*',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExprList_case0() {\n\tfmt.Println(exampleAST(4, \"\\U00100000 'a' ( 'b' )\"))\n\t// Output:\n\t// &cc.ArgumentExprList{\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExprList_case1() {\n\tfmt.Println(exampleAST(5, \"\\U00100000 'a' ( 'b' , 'c' )\"))\n\t// Output:\n\t// &cc.ArgumentExprList{\n\t// · ArgumentExprList: &cc.ArgumentExprList{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'c'\",\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleArgumentExprListOpt_case0() {\n\tfmt.Println(exampleAST(6, \"\\U00100000 'a' ( )\") == (*ArgumentExprListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleArgumentExprListOpt_case1() {\n\tfmt.Println(exampleAST(7, \"\\U00100000 'a' ( 'b' )\"))\n\t// Output:\n\t// &cc.ArgumentExprListOpt{\n\t// · ArgumentExprList: &cc.ArgumentExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItem_decl() {\n\tfmt.Println(exampleAST(219, \"\\U00100001 a { auto ; !\"))\n\t// Output:\n\t// &cc.BlockItem{\n\t// · Declaration: &cc.Declaration{\n\t// · · Scope: &cc.Scope{\n\t// · · },\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · Case: 2,\n\t// · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · Case: 3,\n\t// · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · Case: 2,\n\t// · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · Token: CONST \"const\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Case: 3,\n\t// · · · · Token: STATIC \"static\",\n\t// · · · },\n\t// · · },\n\t// · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · Case: 1,\n\t// · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · Linkage: LinkageNone,\n\t// · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · },\n\t// · · · · · · · Token: '[',\n\t// · · · · · · · Token2: ']',\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · Case: 1,\n\t// · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · Case: ExprString,\n\t// · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · Token: '=',\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItem_stmt() {\n\tfmt.Println(exampleAST(220, \"\\U00100001 a { ; !\"))\n\t// Output:\n\t// &cc.BlockItem{\n\t// · Case: 1,\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemList_case0() {\n\tfmt.Println(exampleAST(215, \"\\U00100001 a { ; !\"))\n\t// Output:\n\t// &cc.BlockItemList{\n\t// · BlockItem: &cc.BlockItem{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · Scope: &cc.Scope{\n\t// · · · },\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · Case: 2,\n\t// · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · Case: 3,\n\t// · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · Case: 2,\n\t// · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · Token: CONST \"const\",\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: STATIC \"static\",\n\t// · · · · },\n\t// · · · },\n\t// · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · Case: 1,\n\t// · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · },\n\t// · · · · · · · · Token: '[',\n\t// · · · · · · · · Token2: ']',\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · Case: 1,\n\t// · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · Case: ExprString,\n\t// · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · Token: '=',\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemList_case1() {\n\tfmt.Println(exampleAST(216, \"\\U00100001 a { ; ; !\"))\n\t// Output:\n\t// &cc.BlockItemList{\n\t// · BlockItem: &cc.BlockItem{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · Scope: &cc.Scope{\n\t// · · · },\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · Case: 2,\n\t// · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · Case: 3,\n\t// · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · Case: 2,\n\t// · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · Token: CONST \"const\",\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Case: 3,\n\t// · · · · · Token: STATIC \"static\",\n\t// · · · · },\n\t// · · · },\n\t// · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · Case: 1,\n\t// · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · },\n\t// · · · · · · · · Token: '[',\n\t// · · · · · · · · Token2: ']',\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · Case: 1,\n\t// · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · Case: ExprString,\n\t// · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · Token: '=',\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · BlockItemList: &cc.BlockItemList{\n\t// · · BlockItem: &cc.BlockItem{\n\t// · · · Case: 1,\n\t// · · · Stmt: &cc.Stmt{\n\t// · · · · Case: 1,\n\t// · · · · ExprStmt: &cc.ExprStmt{\n\t// · · · · · Token: ';',\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Case: 1,\n\t// · },\n\t// }\n}\n\nfunc ExampleBlockItemListOpt_case0() {\n\tfmt.Println(exampleAST(217, \"\\U00100001 a { }\") == (*BlockItemListOpt)(nil))\n\t// Output:\n\t// false\n}\n\nfunc ExampleBlockItemListOpt_case1() {\n\tfmt.Println(exampleAST(218, \"\\U00100001 a { ; }\"))\n\t// Output:\n\t// &cc.BlockItemListOpt{\n\t// · BlockItemList: &cc.BlockItemList{\n\t// · · BlockItem: &cc.BlockItem{\n\t// · · · Declaration: &cc.Declaration{\n\t// · · · · Scope: &cc.Scope{\n\t// · · · · },\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · Case: 1,\n\t// · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · Case: 2,\n\t// · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · Case: 3,\n\t// · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Case: 3,\n\t// · · · · · · Token: STATIC \"static\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · Case: 1,\n\t// · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · },\n\t// · · · · · · · · · Token: '[',\n\t// · · · · · · · · · Token2: ']',\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · Case: 1,\n\t// · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · Token: '=',\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · Token: ';',\n\t// · · · },\n\t// · · },\n\t// · · BlockItemList: &cc.BlockItemList{\n\t// · · · BlockItem: &cc.BlockItem{\n\t// · · · · Case: 1,\n\t// · · · · Stmt: &cc.Stmt{\n\t// · · · · · Case: 1,\n\t// · · · · · ExprStmt: &cc.ExprStmt{\n\t// · · · · · · Token: ';',\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Case: 1,\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleCommaOpt_case0() {\n\tfmt.Println(exampleAST(129, \"\\U00100000 ( _Bool ) { }\") == (*CommaOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleCommaOpt_case1() {\n\tfmt.Println(exampleAST(130, \"\\U00100001 auto a = { , }\"))\n\t// Output:\n\t// &cc.CommaOpt{\n\t// · Token: ',',\n\t// }\n}\n\nfunc ExampleCompoundStmt_case0() {\n\tfmt.Println(exampleAST(214, \"\\U00100001 a { }\"))\n\t// Output:\n\t// &cc.CompoundStmt{\n\t// · BlockItemListOpt: &cc.BlockItemListOpt{\n\t// · · BlockItemList: &cc.BlockItemList{\n\t// · · · BlockItem: &cc.BlockItem{\n\t// · · · · Declaration: &cc.Declaration{\n\t// · · · · · Scope: &cc.Scope{\n\t// · · · · · },\n\t// · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · Case: 1,\n\t// · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · Case: 2,\n\t// · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · · Case: 3,\n\t// · · · · · · · Token: STATIC \"static\",\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · · Case: 1,\n\t// · · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · Token: '[',\n\t// · · · · · · · · · · Token2: ']',\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · · Case: 1,\n\t// · · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · Token: '=',\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · · Token: ';',\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: '{',\n\t// · Token2: '}',\n\t// }\n}\n\nfunc ExampleConstExpr_case0() {\n\tfmt.Println(exampleAST(73, \"\\U00100000 'a'\"))\n\t// Output:\n\t// &cc.ConstExpr{\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclaration_case0() {\n\tfmt.Println(exampleAST(75, \"\\U00100001 auto ;\"))\n\t// Output:\n\t// &cc.Declaration{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · Case: 1,\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Token: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Token: ';',\n\t// }\n}\n\nfunc ExampleDeclarationList_case0() {\n\tfmt.Println(exampleAST(243, \"\\U00100001 a auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationList{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationList_case1() {\n\tfmt.Println(exampleAST(244, \"\\U00100001 a auto ; auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationList{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// · DeclarationList: &cc.DeclarationList{\n\t// · · Case: 1,\n\t// · · Declaration: &cc.Declaration{\n\t// · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationListOpt_case0() {\n\tfmt.Println(exampleAST(245, \"\\U00100001 a {\") == (*DeclarationListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclarationListOpt_case1() {\n\tfmt.Println(exampleAST(246, \"\\U00100001 a auto ; {\"))\n\t// Output:\n\t// &cc.DeclarationListOpt{\n\t// · DeclarationList: &cc.DeclarationList{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_func() {\n\tfmt.Println(exampleAST(76, \"\\U00100001 inline (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · FunctionSpecifier: &cc.FunctionSpecifier{\n\t// · · Token: INLINE \"inline\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_storage() {\n\tfmt.Println(exampleAST(77, \"\\U00100001 auto (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 1,\n\t// · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · Token: AUTO \"auto\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_qualifier() {\n\tfmt.Println(exampleAST(78, \"\\U00100001 const (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 2,\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiers_specifier() {\n\tfmt.Println(exampleAST(79, \"\\U00100001 _Bool (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiers{\n\t// · Case: 3,\n\t// · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · Token: BOOL \"_Bool\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarationSpecifiersOpt_case0() {\n\tfmt.Println(exampleAST(80, \"\\U00100001 inline (\") == (*DeclarationSpecifiersOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclarationSpecifiersOpt_case1() {\n\tfmt.Println(exampleAST(81, \"\\U00100001 const auto (\"))\n\t// Output:\n\t// &cc.DeclarationSpecifiersOpt{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · Case: 1,\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Token: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclarator_case0() {\n\tfmt.Println(exampleAST(141, \"\\U00100001 a )\"))\n\t// Output:\n\t// &cc.Declarator{\n\t// · Linkage: LinkageNone,\n\t// · StorageDuration: StorageDurationAutomatic,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDeclaratorOpt_case0() {\n\tfmt.Println(exampleAST(142, \"\\U00100001 struct { _Bool :\") == (*DeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(143, \"\\U00100001 struct { _Bool a :\"))\n\t// Output:\n\t// &cc.DeclaratorOpt{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · Scope: &cc.Scope{\n\t// · · },\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDesignation_case0() {\n\tfmt.Println(exampleAST(198, \"\\U00100000 ( _Bool ) { . a = !\"))\n\t// Output:\n\t// &cc.Designation{\n\t// · DesignatorList: &cc.DesignatorList{\n\t// · · Designator: &cc.Designator{\n\t// · · · Token: '.',\n\t// · · · Token2: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · Token: '=',\n\t// }\n}\n\nfunc ExampleDesignator_field() {\n\tfmt.Println(exampleAST(201, \"\\U00100000 ( _Bool ) { . a .\"))\n\t// Output:\n\t// &cc.Designator{\n\t// · Token: '.',\n\t// · Token2: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleDesignator_index() {\n\tfmt.Println(exampleAST(202, \"\\U00100000 ( _Bool ) { [ 'a' ] .\"))\n\t// Output:\n\t// &cc.Designator{\n\t// · Case: 1,\n\t// · ConstExpr: &cc.ConstExpr{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: '[',\n\t// · Token2: ']',\n\t// }\n}\n\nfunc ExampleDesignatorList_case0() {\n\tfmt.Println(exampleAST(199, \"\\U00100000 ( _Bool ) { . a .\"))\n\t// Output:\n\t// &cc.DesignatorList{\n\t// · Designator: &cc.Designator{\n\t// · · Token: '.',\n\t// · · Token2: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleDesignatorList_case1() {\n\tfmt.Println(exampleAST(200, \"\\U00100000 ( _Bool ) { . a . b .\"))\n\t// Output:\n\t// &cc.DesignatorList{\n\t// · Designator: &cc.Designator{\n\t// · · Token: '.',\n\t// · · Token2: IDENTIFIER \"a\",\n\t// · },\n\t// · DesignatorList: &cc.DesignatorList{\n\t// · · Case: 1,\n\t// · · Designator: &cc.Designator{\n\t// · · · Token: '.',\n\t// · · · Token2: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_abstract() {\n\tfmt.Println(exampleAST(181, \"\\U00100000 ( _Bool ( * ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · AbstractDeclarator: &cc.AbstractDeclarator{\n\t// · · Pointer: &cc.Pointer{\n\t// · · · Token: '*',\n\t// · · },\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_paramList() {\n\tfmt.Println(exampleAST(182, \"\\U00100000 ( _Bool ( ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 1,\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dFn() {\n\tfmt.Println(exampleAST(183, \"\\U00100000 ( _Bool ( ) ( ) (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 2,\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 1,\n\t// · · Token: '(',\n\t// · · Token2: ')',\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dArrSize() {\n\tfmt.Println(exampleAST(184, \"\\U00100000 ( _Bool [ static 'a' ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 3,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: STATIC \"static\",\n\t// · Token3: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dArrVL() {\n\tfmt.Println(exampleAST(185, \"\\U00100000 ( _Bool [ * ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 4,\n\t// · Token: '[',\n\t// · Token2: '*',\n\t// · Token3: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dArr() {\n\tfmt.Println(exampleAST(186, \"\\U00100000 ( _Bool [ ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 5,\n\t// · Token: '[',\n\t// · Token2: ']',\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dArrSize2() {\n\tfmt.Println(exampleAST(187, \"\\U00100000 ( _Bool [ const static 'a' ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 6,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: STATIC \"static\",\n\t// · Token3: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclarator_dArr2() {\n\tfmt.Println(exampleAST(188, \"\\U00100000 ( _Bool [ const ] (\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclarator{\n\t// · Case: 7,\n\t// · Token: '[',\n\t// · Token2: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectAbstractDeclaratorOpt_case0() {\n\tfmt.Println(exampleAST(189, \"\\U00100000 ( _Bool [\") == (*DirectAbstractDeclaratorOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleDirectAbstractDeclaratorOpt_case1() {\n\tfmt.Println(exampleAST(190, \"\\U00100000 ( _Bool ( ) [\"))\n\t// Output:\n\t// &cc.DirectAbstractDeclaratorOpt{\n\t// · DirectAbstractDeclarator: &cc.DirectAbstractDeclarator{\n\t// · · Case: 1,\n\t// · · Token: '(',\n\t// · · Token2: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectDeclarator_paren() {\n\tfmt.Println(exampleAST(144, \"\\U00100001 ( a ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorParen,\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · Embedded: true,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_identList() {\n\tfmt.Println(exampleAST(146, \"\\U00100001 a ( ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorIdentList,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_paramList() {\n\tfmt.Println(exampleAST(148, \"\\U00100001 a ( auto ) (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorParamList,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · ParameterTypeList: &cc.ParameterTypeList{\n\t// · · ParameterList: &cc.ParameterList{\n\t// · · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · Case: 1,\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Token: AUTO \"auto\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_arraySize() {\n\tfmt.Println(exampleAST(149, \"\\U00100001 a [ static 'b' ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorArraySize,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: STATIC \"static\",\n\t// · Token3: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_arraySize2() {\n\tfmt.Println(exampleAST(150, \"\\U00100001 a [ const static 'b' ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorArraySize2,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: STATIC \"static\",\n\t// · Token3: ']',\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleDirectDeclarator_arrayVar() {\n\tfmt.Println(exampleAST(151, \"\\U00100001 a [ * ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorArrayVar,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: '*',\n\t// · Token3: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_array() {\n\tfmt.Println(exampleAST(152, \"\\U00100001 a [ ] (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorArray,\n\t// · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · Case: DirectDeclaratorIdent,\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: '[',\n\t// · Token2: ']',\n\t// }\n}\n\nfunc ExampleDirectDeclarator_ident() {\n\tfmt.Println(exampleAST(153, \"\\U00100001 a (\"))\n\t// Output:\n\t// &cc.DirectDeclarator{\n\t// · Case: DirectDeclaratorIdent,\n\t// · Token: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleEnumSpecifier_tag() {\n\tfmt.Println(exampleAST(131, \"\\U00100001 enum a (\"))\n\t// Output:\n\t// &cc.EnumSpecifier{\n\t// · Token: ENUM \"enum\",\n\t// · Token2: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleEnumSpecifier_define() {\n\tfmt.Println(exampleAST(132, \"\\U00100001 enum { a } (\"))\n\t// Output:\n\t// &cc.EnumSpecifier{\n\t// · Case: 1,\n\t// · EnumeratorList: &cc.EnumeratorList{\n\t// · · Enumerator: &cc.Enumerator{\n\t// · · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: ENUM \"enum\",\n\t// · Token2: '{',\n\t// · Token3: '}',\n\t// }\n}\n\nfunc ExampleEnumerationConstant_case0() {\n\tfmt.Println(exampleAST(3, \"\\U00100001 enum { a ,\"))\n\t// Output:\n\t// &cc.EnumerationConstant{\n\t// · Token: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleEnumerator_base() {\n\tfmt.Println(exampleAST(135, \"\\U00100001 enum { a ,\"))\n\t// Output:\n\t// &cc.Enumerator{\n\t// · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleEnumerator_init() {\n\tfmt.Println(exampleAST(136, \"\\U00100001 enum { a = 'b' ,\"))\n\t// Output:\n\t// &cc.Enumerator{\n\t// · Case: 1,\n\t// · ConstExpr: &cc.ConstExpr{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// · Token: '=',\n\t// }\n}\n\nfunc ExampleEnumeratorList_case0() {\n\tfmt.Println(exampleAST(133, \"\\U00100001 enum { a ,\"))\n\t// Output:\n\t// &cc.EnumeratorList{\n\t// · Enumerator: &cc.Enumerator{\n\t// · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleEnumeratorList_case1() {\n\tfmt.Println(exampleAST(134, \"\\U00100001 enum { a , b ,\"))\n\t// Output:\n\t// &cc.EnumeratorList{\n\t// · Enumerator: &cc.Enumerator{\n\t// · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · EnumeratorList: &cc.EnumeratorList{\n\t// · · Case: 1,\n\t// · · Enumerator: &cc.Enumerator{\n\t// · · · EnumerationConstant: &cc.EnumerationConstant{\n\t// · · · · Token: IDENTIFIER \"b\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleExpr_preInc() {\n\tfmt.Println(exampleAST(8, \"\\U00100000 ++ 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPreInc,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: INC,\n\t// }\n}\n\nfunc ExampleExpr_preDec() {\n\tfmt.Println(exampleAST(9, \"\\U00100000 -- 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPreDec,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: DEC,\n\t// }\n}\n\nfunc ExampleExpr_alignofType() {\n\tfmt.Println(exampleAST(10, \"\\U00100000 __alignof__ ( _Bool )\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAlignofType,\n\t// · Token: ALIGNOF \"__alignof__\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpr_alignofExpr() {\n\tfmt.Println(exampleAST(11, \"\\U00100000 __alignof__ 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAlignofExpr,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: ALIGNOF \"__alignof__\",\n\t// }\n}\n\nfunc ExampleExpr_sizeofType() {\n\tfmt.Println(exampleAST(12, \"\\U00100000 sizeof ( _Bool )\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprSizeofType,\n\t// · Token: SIZEOF \"sizeof\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpr_sizeofExpr() {\n\tfmt.Println(exampleAST(13, \"\\U00100000 sizeof 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprSizeofExpr,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: SIZEOF \"sizeof\",\n\t// }\n}\n\nfunc ExampleExpr_not() {\n\tfmt.Println(exampleAST(14, \"\\U00100000 ! 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprNot,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '!',\n\t// }\n}\n\nfunc ExampleExpr_addrof() {\n\tfmt.Println(exampleAST(15, \"\\U00100000 & 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAddrof,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '&',\n\t// }\n}\n\nfunc ExampleExpr_statement() {\n\tfmt.Println(exampleAST(16, \"\\U00100000 ( { } )\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprStatement,\n\t// · CompoundStmt: &cc.CompoundStmt{\n\t// · · Token: '{',\n\t// · · Token2: '}',\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleExpr_pExprList() {\n\tfmt.Println(exampleAST(17, \"\\U00100000 ( 'a' )\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPExprList,\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleExpr_compLit() {\n\tfmt.Println(exampleAST(18, \"\\U00100000 ( _Bool ) { }\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprCompLit,\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// · Token3: '{',\n\t// · Token4: '}',\n\t// · TypeName: &cc.TypeName{\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpr_cast() {\n\tfmt.Println(exampleAST(19, \"\\U00100000 ( _Bool ) 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprCast,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExpr_deref() {\n\tfmt.Println(exampleAST(20, \"\\U00100000 * 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprDeref,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '*',\n\t// }\n}\n\nfunc ExampleExpr_unaryPlus() {\n\tfmt.Println(exampleAST(21, \"\\U00100000 + 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprUnaryPlus,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '+',\n\t// }\n}\n\nfunc ExampleExpr_unaryMinus() {\n\tfmt.Println(exampleAST(22, \"\\U00100000 - 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprUnaryMinus,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '-',\n\t// }\n}\n\nfunc ExampleExpr_cpl() {\n\tfmt.Println(exampleAST(23, \"\\U00100000 ~ 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprCpl,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '~',\n\t// }\n}\n\nfunc ExampleExpr_char() {\n\tfmt.Println(exampleAST(24, \"\\U00100000 'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprChar,\n\t// · Token: CHARCONST \"'a'\",\n\t// }\n}\n\nfunc ExampleExpr_ne() {\n\tfmt.Println(exampleAST(25, \"\\U00100000 'a' != 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprNe,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: NEQ,\n\t// }\n}\n\nfunc ExampleExpr_modAssign() {\n\tfmt.Println(exampleAST(26, \"\\U00100000 'a' %= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprModAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: MODASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_lAnd() {\n\tfmt.Println(exampleAST(27, \"\\U00100000 'a' && 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLAnd,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: ANDAND,\n\t// }\n}\n\nfunc ExampleExpr_andAssign() {\n\tfmt.Println(exampleAST(28, \"\\U00100000 'a' &= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAndAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: ANDASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_mulAssign() {\n\tfmt.Println(exampleAST(29, \"\\U00100000 'a' *= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprMulAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: MULASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_postInc() {\n\tfmt.Println(exampleAST(30, \"\\U00100000 'a' ++\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPostInc,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: INC,\n\t// }\n}\n\nfunc ExampleExpr_addAssign() {\n\tfmt.Println(exampleAST(31, \"\\U00100000 'a' += 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAddAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: ADDASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_postDec() {\n\tfmt.Println(exampleAST(32, \"\\U00100000 'a' --\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPostDec,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: DEC,\n\t// }\n}\n\nfunc ExampleExpr_subAssign() {\n\tfmt.Println(exampleAST(33, \"\\U00100000 'a' -= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprSubAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: SUBASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_pSelect() {\n\tfmt.Println(exampleAST(34, \"\\U00100000 'a' -> b\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprPSelect,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: ARROW,\n\t// · Token2: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleExpr_divAssign() {\n\tfmt.Println(exampleAST(35, \"\\U00100000 'a' /= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprDivAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: DIVASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_lsh() {\n\tfmt.Println(exampleAST(36, \"\\U00100000 'a' << 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLsh,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: LSH,\n\t// }\n}\n\nfunc ExampleExpr_lshAssign() {\n\tfmt.Println(exampleAST(37, \"\\U00100000 'a' <<= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLshAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: LSHASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_le() {\n\tfmt.Println(exampleAST(38, \"\\U00100000 'a' <= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLe,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: LEQ,\n\t// }\n}\n\nfunc ExampleExpr_eq() {\n\tfmt.Println(exampleAST(39, \"\\U00100000 'a' == 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprEq,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: EQ,\n\t// }\n}\n\nfunc ExampleExpr_ge() {\n\tfmt.Println(exampleAST(40, \"\\U00100000 'a' >= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprGe,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: GEQ,\n\t// }\n}\n\nfunc ExampleExpr_rsh() {\n\tfmt.Println(exampleAST(41, \"\\U00100000 'a' >> 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprRsh,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: RSH,\n\t// }\n}\n\nfunc ExampleExpr_rshAssign() {\n\tfmt.Println(exampleAST(42, \"\\U00100000 'a' >>= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprRshAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: RSHASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_xorAssign() {\n\tfmt.Println(exampleAST(43, \"\\U00100000 'a' ^= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprXorAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: XORASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_orAssign() {\n\tfmt.Println(exampleAST(44, \"\\U00100000 'a' |= 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprOrAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: ORASSIGN,\n\t// }\n}\n\nfunc ExampleExpr_lOr() {\n\tfmt.Println(exampleAST(45, \"\\U00100000 'a' || 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLOr,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: OROR,\n\t// }\n}\n\nfunc ExampleExpr_mod() {\n\tfmt.Println(exampleAST(46, \"\\U00100000 'a' % 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprMod,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '%',\n\t// }\n}\n\nfunc ExampleExpr_and() {\n\tfmt.Println(exampleAST(47, \"\\U00100000 'a' & 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAnd,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '&',\n\t// }\n}\n\nfunc ExampleExpr_call() {\n\tfmt.Println(exampleAST(48, \"\\U00100000 'a' ( )\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprCall,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '(',\n\t// · Token2: ')',\n\t// }\n}\n\nfunc ExampleExpr_mul() {\n\tfmt.Println(exampleAST(49, \"\\U00100000 'a' * 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprMul,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '*',\n\t// }\n}\n\nfunc ExampleExpr_add() {\n\tfmt.Println(exampleAST(50, \"\\U00100000 'a' + 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAdd,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '+',\n\t// }\n}\n\nfunc ExampleExpr_sub() {\n\tfmt.Println(exampleAST(51, \"\\U00100000 'a' - 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprSub,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '-',\n\t// }\n}\n\nfunc ExampleExpr_select() {\n\tfmt.Println(exampleAST(52, \"\\U00100000 'a' . b\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprSelect,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: '.',\n\t// · Token2: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleExpr_div() {\n\tfmt.Println(exampleAST(53, \"\\U00100000 'a' / 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprDiv,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '/',\n\t// }\n}\n\nfunc ExampleExpr_lt() {\n\tfmt.Println(exampleAST(54, \"\\U00100000 'a' < 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLt,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '<',\n\t// }\n}\n\nfunc ExampleExpr_assign() {\n\tfmt.Println(exampleAST(55, \"\\U00100000 'a' = 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprAssign,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '=',\n\t// }\n}\n\nfunc ExampleExpr_gt() {\n\tfmt.Println(exampleAST(56, \"\\U00100000 'a' > 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprGt,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '>',\n\t// }\n}\n\nfunc ExampleExpr_cond() {\n\tfmt.Println(exampleAST(57, \"\\U00100000 'a' ? 'b' : 'c'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprCond,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'c'\",\n\t// · },\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: '?',\n\t// · Token2: ':',\n\t// }\n}\n\nfunc ExampleExpr_index() {\n\tfmt.Println(exampleAST(58, \"\\U00100000 'a' [ 'b' ]\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprIndex,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: '[',\n\t// · Token2: ']',\n\t// }\n}\n\nfunc ExampleExpr_xor() {\n\tfmt.Println(exampleAST(59, \"\\U00100000 'a' ^ 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprXor,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '^',\n\t// }\n}\n\nfunc ExampleExpr_or() {\n\tfmt.Println(exampleAST(60, \"\\U00100000 'a' | 'b'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprOr,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Expr2: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// · Token: '|',\n\t// }\n}\n\nfunc ExampleExpr_float() {\n\tfmt.Println(exampleAST(61, \"\\U00100000 1.97\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprFloat,\n\t// · Token: FLOATCONST \"1.97\",\n\t// }\n}\n\nfunc ExampleExpr_ident() {\n\tfmt.Println(exampleAST(62, \"\\U00100001 a { b %\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Scope: &cc.Scope{\n\t// · },\n\t// · Case: ExprIdent,\n\t// · Token: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleExpr_int() {\n\tfmt.Println(exampleAST(63, \"\\U00100000 97\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprInt,\n\t// · Token: INTCONST \"97\",\n\t// }\n}\n\nfunc ExampleExpr_lChar() {\n\tfmt.Println(exampleAST(64, \"\\U00100000 L'a'\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLChar,\n\t// · Token: LONGCHARCONST \"L'a'\",\n\t// }\n}\n\nfunc ExampleExpr_lString() {\n\tfmt.Println(exampleAST(65, \"\\U00100000 L\\\"a\\\"\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprLString,\n\t// · Token: LONGSTRINGLITERAL \"L\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleExpr_string() {\n\tfmt.Println(exampleAST(66, \"\\U00100000 \\\"a\\\"\"))\n\t// Output:\n\t// &cc.Expr{\n\t// · Case: ExprString,\n\t// · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// }\n}\n\nfunc ExampleExprList_case0() {\n\tfmt.Println(exampleAST(69, \"\\U00100000 ( 'a' )\"))\n\t// Output:\n\t// &cc.ExprList{\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleExprList_case1() {\n\tfmt.Println(exampleAST(70, \"\\U00100000 ( 'a' , 'b' )\"))\n\t// Output:\n\t// &cc.ExprList{\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · ExprList: &cc.ExprList{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleExprListOpt_case0() {\n\tfmt.Println(exampleAST(71, \"\\U00100001 a { ;\") == (*ExprListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleExprListOpt_case1() {\n\tfmt.Println(exampleAST(72, \"\\U00100001 a { 'b' )\"))\n\t// Output:\n\t// &cc.ExprListOpt{\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExprOpt_case0() {\n\tfmt.Println(exampleAST(67, \"\\U00100000 ( _Bool [ ]\") == (*ExprOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleExprOpt_case1() {\n\tfmt.Println(exampleAST(68, \"\\U00100001 a [ 'b' ]\"))\n\t// Output:\n\t// &cc.ExprOpt{\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleExprStmt_case0() {\n\tfmt.Println(exampleAST(221, \"\\U00100001 a { ; !\"))\n\t// Output:\n\t// &cc.ExprStmt{\n\t// · Token: ';',\n\t// }\n}\n\nfunc ExampleExternalDeclaration_decl() {\n\tfmt.Println(exampleAST(235, \"\\U00100001 auto ;\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · Declaration: &cc.Declaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleExternalDeclaration_func() {\n\tfmt.Println(exampleAST(236, \"\\U00100001 a { }\"))\n\t// Output:\n\t// &cc.ExternalDeclaration{\n\t// · Case: 1,\n\t// · FunctionDefinition: &cc.FunctionDefinition{\n\t// · · Case: 1,\n\t// · · Declarator: &cc.Declarator{\n\t// · · · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },\n\t// · · · Linkage: LinkageNone,\n\t// · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Case: DirectDeclaratorIdent,\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · · FunctionBody: &cc.FunctionBody{\n\t// · · · CompoundStmt: &cc.CompoundStmt{\n\t// · · · · BlockItemListOpt: &cc.BlockItemListOpt{\n\t// · · · · · BlockItemList: &cc.BlockItemList{\n\t// · · · · · · BlockItem: &cc.BlockItem{\n\t// · · · · · · · Declaration: &cc.Declaration{\n\t// · · · · · · · · Scope: &cc.Scope{\n\t// · · · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · },\n\t// · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · Case: 1,\n\t// · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · · · · · },\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · Token: STATIC \"static\",\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · · · · · },\n\t// · · · · · · · · · · · · · Token: '[',\n\t// · · · · · · · · · · · · · Token2: ']',\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · · Token: '=',\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · Token: ';',\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · Token: '{',\n\t// · · · · Token2: '}',\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExternalDeclarationList_case0() {\n\tfmt.Println(exampleAST(233, \"\\U00100001 auto ;\"))\n\t// Output:\n\t// &cc.ExternalDeclarationList{\n\t// · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleExternalDeclarationList_case1() {\n\tfmt.Println(exampleAST(234, \"\\U00100001 auto ; auto ;\"))\n\t// Output:\n\t// &cc.ExternalDeclarationList{\n\t// · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · Declaration: &cc.Declaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · ExternalDeclarationList: &cc.ExternalDeclarationList{\n\t// · · Case: 1,\n\t// · · ExternalDeclaration: &cc.ExternalDeclaration{\n\t// · · · Declaration: &cc.Declaration{\n\t// · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · Case: 1,\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Token: AUTO \"auto\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · · Token: ';',\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionBody_case0() {\n\tfmt.Println(exampleAST(242, \"\\U00100001 a { }\"))\n\t// Output:\n\t// &cc.FunctionBody{\n\t// · CompoundStmt: &cc.CompoundStmt{\n\t// · · BlockItemListOpt: &cc.BlockItemListOpt{\n\t// · · · BlockItemList: &cc.BlockItemList{\n\t// · · · · BlockItem: &cc.BlockItem{\n\t// · · · · · Declaration: &cc.Declaration{\n\t// · · · · · · Scope: &cc.Scope{\n\t// · · · · · · },\n\t// · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · Case: 1,\n\t// · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · Case: 2,\n\t// · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · · · Case: 3,\n\t// · · · · · · · · Token: STATIC \"static\",\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · · · Case: 1,\n\t// · · · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · · Token: '[',\n\t// · · · · · · · · · · · Token2: ']',\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · · Token: '=',\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · },\n\t// · · · · · · Token: ';',\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: '{',\n\t// · · Token2: '}',\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionDefinition_spec() {\n\tfmt.Println(exampleAST(238, \"\\U00100001 auto a { }\"))\n\t// Output:\n\t// &cc.FunctionDefinition{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · Case: 1,\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Token: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Declarator: &cc.Declarator{\n\t// · · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },\n\t// · · Linkage: LinkageNone,\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · FunctionBody: &cc.FunctionBody{\n\t// · · CompoundStmt: &cc.CompoundStmt{\n\t// · · · BlockItemListOpt: &cc.BlockItemListOpt{\n\t// · · · · BlockItemList: &cc.BlockItemList{\n\t// · · · · · BlockItem: &cc.BlockItem{\n\t// · · · · · · Declaration: &cc.Declaration{\n\t// · · · · · · · Scope: &cc.Scope{\n\t// · · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · },\n\t// · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · Case: 1,\n\t// · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · · · · Case: 3,\n\t// · · · · · · · · · Token: STATIC \"static\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · · Token: '[',\n\t// · · · · · · · · · · · · Token2: ']',\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · Token: '=',\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · Token: ';',\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: '{',\n\t// · · · Token2: '}',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionDefinition_int() {\n\tfmt.Println(exampleAST(240, \"\\U00100001 a { }\"))\n\t// Output:\n\t// &cc.FunctionDefinition{\n\t// · Case: 1,\n\t// · Declarator: &cc.Declarator{\n\t// · · FunctionDefinition: &cc.FunctionDefinition{ /* recursive/repetitive pointee not shown */ },\n\t// · · Linkage: LinkageNone,\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · FunctionBody: &cc.FunctionBody{\n\t// · · CompoundStmt: &cc.CompoundStmt{\n\t// · · · BlockItemListOpt: &cc.BlockItemListOpt{\n\t// · · · · BlockItemList: &cc.BlockItemList{\n\t// · · · · · BlockItem: &cc.BlockItem{\n\t// · · · · · · Declaration: &cc.Declaration{\n\t// · · · · · · · Scope: &cc.Scope{\n\t// · · · · · · · · Parent: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · },\n\t// · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · Case: 1,\n\t// · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · DeclarationSpecifiersOpt: &cc.DeclarationSpecifiersOpt{\n\t// · · · · · · · · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · · · · · · · · Case: 3,\n\t// · · · · · · · · · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · · · · · · · · · Case: 2,\n\t// · · · · · · · · · · · · · Token: CHAR \"char\",\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · · · · · · · · · Token: CONST \"const\",\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · · · · Case: 3,\n\t// · · · · · · · · · Token: STATIC \"static\",\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · InitDeclaratorListOpt: &cc.InitDeclaratorListOpt{\n\t// · · · · · · · · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · · · · · · · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · Declarator: &cc.Declarator{\n\t// · · · · · · · · · · · Linkage: LinkageNone,\n\t// · · · · · · · · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · · · · · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · Case: DirectDeclaratorArray,\n\t// · · · · · · · · · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · · · · · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · · · · · · · · · Token: IDENTIFIER \"__func__\",\n\t// · · · · · · · · · · · · },\n\t// · · · · · · · · · · · · Token: '[',\n\t// · · · · · · · · · · · · Token2: ']',\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · Initializer: &cc.Initializer{\n\t// · · · · · · · · · · · Case: 1,\n\t// · · · · · · · · · · · Expr: &cc.Expr{\n\t// · · · · · · · · · · · · Case: ExprString,\n\t// · · · · · · · · · · · · Token: STRINGLITERAL \"\\\"a\\\"\",\n\t// · · · · · · · · · · · },\n\t// · · · · · · · · · · },\n\t// · · · · · · · · · · Token: '=',\n\t// · · · · · · · · · },\n\t// · · · · · · · · },\n\t// · · · · · · · },\n\t// · · · · · · · Token: ';',\n\t// · · · · · · },\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: '{',\n\t// · · · Token2: '}',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleFunctionSpecifier_case0() {\n\tfmt.Println(exampleAST(140, \"\\U00100001 inline (\"))\n\t// Output:\n\t// &cc.FunctionSpecifier{\n\t// · Token: INLINE \"inline\",\n\t// }\n}\n\nfunc ExampleIdentifierList_case0() {\n\tfmt.Println(exampleAST(170, \"\\U00100001 a ( b )\"))\n\t// Output:\n\t// &cc.IdentifierList{\n\t// · Token: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleIdentifierList_case1() {\n\tfmt.Println(exampleAST(171, \"\\U00100001 a ( b , c )\"))\n\t// Output:\n\t// &cc.IdentifierList{\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Case: 1,\n\t// · · Token: ',',\n\t// · · Token2: IDENTIFIER \"c\",\n\t// · },\n\t// · Token: IDENTIFIER \"b\",\n\t// }\n}\n\nfunc ExampleIdentifierListOpt_case0() {\n\tfmt.Println(exampleAST(172, \"\\U00100001 a ( )\") == (*IdentifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleIdentifierListOpt_case1() {\n\tfmt.Println(exampleAST(173, \"\\U00100001 a ( b )\"))\n\t// Output:\n\t// &cc.IdentifierListOpt{\n\t// · IdentifierList: &cc.IdentifierList{\n\t// · · Token: IDENTIFIER \"b\",\n\t// · },\n\t// }\n}\n\nfunc ExampleIdentifierOpt_case0() {\n\tfmt.Println(exampleAST(174, \"\\U00100001 struct {\") == (*IdentifierOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleIdentifierOpt_case1() {\n\tfmt.Println(exampleAST(175, \"\\U00100001 enum a {\"))\n\t// Output:\n\t// &cc.IdentifierOpt{\n\t// · Token: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleInitDeclarator_base() {\n\tfmt.Println(exampleAST(86, \"\\U00100001 a auto b ,\"))\n\t// Output:\n\t// &cc.InitDeclarator{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclarator_init() {\n\tfmt.Println(exampleAST(87, \"\\U00100001 auto a = 'b' ,\"))\n\t// Output:\n\t// &cc.InitDeclarator{\n\t// · Case: 1,\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// · Initializer: &cc.Initializer{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: '=',\n\t// }\n}\n\nfunc ExampleInitDeclaratorList_case0() {\n\tfmt.Println(exampleAST(82, \"\\U00100001 auto a ,\"))\n\t// Output:\n\t// &cc.InitDeclaratorList{\n\t// · InitDeclarator: &cc.InitDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: LinkageNone,\n\t// · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Case: DirectDeclaratorIdent,\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclaratorList_case1() {\n\tfmt.Println(exampleAST(83, \"\\U00100001 auto a , b ,\"))\n\t// Output:\n\t// &cc.InitDeclaratorList{\n\t// · InitDeclarator: &cc.InitDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: LinkageNone,\n\t// · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Case: DirectDeclaratorIdent,\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · Case: 1,\n\t// · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: LinkageNone,\n\t// · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · Token: IDENTIFIER \"b\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleInitDeclaratorListOpt_case0() {\n\tfmt.Println(exampleAST(84, \"\\U00100001 auto ;\") == (*InitDeclaratorListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleInitDeclaratorListOpt_case1() {\n\tfmt.Println(exampleAST(85, \"\\U00100001 auto a ;\"))\n\t// Output:\n\t// &cc.InitDeclaratorListOpt{\n\t// · InitDeclaratorList: &cc.InitDeclaratorList{\n\t// · · InitDeclarator: &cc.InitDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: LinkageNone,\n\t// · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · Token: IDENTIFIER \"a\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializer_compLit() {\n\tfmt.Println(exampleAST(191, \"\\U00100001 auto a = { } ,\"))\n\t// Output:\n\t// &cc.Initializer{\n\t// · Token: '{',\n\t// · Token2: '}',\n\t// }\n}\n\nfunc ExampleInitializer_expr() {\n\tfmt.Println(exampleAST(192, \"\\U00100001 auto a = 'b' ,\"))\n\t// Output:\n\t// &cc.Initializer{\n\t// · Case: 1,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'b'\",\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializerList_case0() {\n\tfmt.Println(exampleAST(193, \"\\U00100000 ( _Bool ) { ,\") == (*InitializerList)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleInitializerList_case1() {\n\tfmt.Println(exampleAST(194, \"\\U00100000 ( _Bool ) { 'a' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Case: 1,\n\t// · Initializer: &cc.Initializer{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializerList_case2() {\n\tfmt.Println(exampleAST(195, \"\\U00100001 auto a = { . b = 'c' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Case: 2,\n\t// · Designation: &cc.Designation{\n\t// · · DesignatorList: &cc.DesignatorList{\n\t// · · · Designator: &cc.Designator{\n\t// · · · · Token: '.',\n\t// · · · · Token2: IDENTIFIER \"b\",\n\t// · · · },\n\t// · · },\n\t// · · Token: '=',\n\t// · },\n\t// · Initializer: &cc.Initializer{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'c'\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleInitializerList_case3() {\n\tfmt.Println(exampleAST(196, \"\\U00100001 auto a = { , 'b' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Case: 3,\n\t// · Initializer: &cc.Initializer{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Token: ',',\n\t// }\n}\n\nfunc ExampleInitializerList_case4() {\n\tfmt.Println(exampleAST(197, \"\\U00100001 auto a = { , . b = 'c' ,\"))\n\t// Output:\n\t// &cc.InitializerList{\n\t// · Case: 4,\n\t// · Designation: &cc.Designation{\n\t// · · DesignatorList: &cc.DesignatorList{\n\t// · · · Designator: &cc.Designator{\n\t// · · · · Token: '.',\n\t// · · · · Token2: IDENTIFIER \"b\",\n\t// · · · },\n\t// · · },\n\t// · · Token: '=',\n\t// · },\n\t// · Initializer: &cc.Initializer{\n\t// · · Case: 1,\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'c'\",\n\t// · · },\n\t// · },\n\t// · Token: ',',\n\t// }\n}\n\nfunc ExampleIterationStmt_do() {\n\tfmt.Println(exampleAST(225, \"\\U00100001 a { do ; while ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.IterationStmt{\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: DO \"do\",\n\t// · Token2: WHILE \"while\",\n\t// · Token3: '(',\n\t// · Token4: ')',\n\t// · Token5: ';',\n\t// }\n}\n\nfunc ExampleIterationStmt_forDecl() {\n\tfmt.Println(exampleAST(226, \"\\U00100001 a { for ( auto ; ; ) ; !\"))\n\t// Output:\n\t// &cc.IterationStmt{\n\t// · Case: 1,\n\t// · Declaration: &cc.Declaration{\n\t// · · Scope: &cc.Scope{\n\t// · · · Parent: &cc.Scope{\n\t// · · · },\n\t// · · },\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: FOR \"for\",\n\t// · Token2: '(',\n\t// · Token3: ';',\n\t// · Token4: ')',\n\t// }\n}\n\nfunc ExampleIterationStmt_for() {\n\tfmt.Println(exampleAST(227, \"\\U00100001 a { for ( ; ; ) ; !\"))\n\t// Output:\n\t// &cc.IterationStmt{\n\t// · Case: 2,\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: FOR \"for\",\n\t// · Token2: '(',\n\t// · Token3: ';',\n\t// · Token4: ';',\n\t// · Token5: ')',\n\t// }\n}\n\nfunc ExampleIterationStmt_while() {\n\tfmt.Println(exampleAST(228, \"\\U00100001 a { while ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.IterationStmt{\n\t// · Case: 3,\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: WHILE \"while\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// }\n}\n\nfunc ExampleJumpStmt_break() {\n\tfmt.Println(exampleAST(229, \"\\U00100001 a { break ; !\"))\n\t// Output:\n\t// &cc.JumpStmt{\n\t// · Token: BREAK \"break\",\n\t// · Token2: ';',\n\t// }\n}\n\nfunc ExampleJumpStmt_continue() {\n\tfmt.Println(exampleAST(230, \"\\U00100001 a { continue ; !\"))\n\t// Output:\n\t// &cc.JumpStmt{\n\t// · Case: 1,\n\t// · Token: CONTINUE \"continue\",\n\t// · Token2: ';',\n\t// }\n}\n\nfunc ExampleJumpStmt_goto() {\n\tfmt.Println(exampleAST(231, \"\\U00100001 a { goto b ; !\"))\n\t// Output:\n\t// &cc.JumpStmt{\n\t// · Case: 2,\n\t// · Token: GOTO \"goto\",\n\t// · Token2: IDENTIFIER \"b\",\n\t// · Token3: ';',\n\t// }\n}\n\nfunc ExampleJumpStmt_return() {\n\tfmt.Println(exampleAST(232, \"\\U00100001 a { return ; !\"))\n\t// Output:\n\t// &cc.JumpStmt{\n\t// · Case: 3,\n\t// · Token: RETURN \"return\",\n\t// · Token2: ';',\n\t// }\n}\n\nfunc ExampleLabeledStmt_switchCase() {\n\tfmt.Println(exampleAST(209, \"\\U00100001 a { case 'b' : ; !\"))\n\t// Output:\n\t// &cc.LabeledStmt{\n\t// · ConstExpr: &cc.ConstExpr{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: CASE \"case\",\n\t// · Token2: ':',\n\t// }\n}\n\nfunc ExampleLabeledStmt_default() {\n\tfmt.Println(exampleAST(210, \"\\U00100001 a { default : ; !\"))\n\t// Output:\n\t// &cc.LabeledStmt{\n\t// · Case: 1,\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: DEFAULT \"default\",\n\t// · Token2: ':',\n\t// }\n}\n\nfunc ExampleLabeledStmt_label() {\n\tfmt.Println(exampleAST(211, \"\\U00100001 a { b : ; !\"))\n\t// Output:\n\t// &cc.LabeledStmt{\n\t// · Case: 2,\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: IDENTIFIER \"b\",\n\t// · Token2: ':',\n\t// }\n}\n\nfunc ExampleLabeledStmt_label2() {\n\tfmt.Println(exampleAST(212, \"\\U00100001 a { typedef name : ; !\"))\n\t// Output:\n\t// TODO: example212.c:1:19: unexpected ':', expected one of [',', ';', '=']\n}\n\nfunc ExampleParameterDeclaration_abstract() {\n\tfmt.Println(exampleAST(168, \"\\U00100001 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterDeclaration{\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · Case: 1,\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Token: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterDeclaration_declarator() {\n\tfmt.Println(exampleAST(169, \"\\U00100001 a ( auto b )\"))\n\t// Output:\n\t// &cc.ParameterDeclaration{\n\t// · Case: 1,\n\t// · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · Case: 1,\n\t// · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · Token: AUTO \"auto\",\n\t// · · },\n\t// · },\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · Scope: &cc.Scope{\n\t// · · },\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"b\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterList_case0() {\n\tfmt.Println(exampleAST(166, \"\\U00100001 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterList{\n\t// · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterList_case1() {\n\tfmt.Println(exampleAST(167, \"\\U00100001 a ( auto , auto )\"))\n\t// Output:\n\t// &cc.ParameterList{\n\t// · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · Case: 1,\n\t// · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · Token: AUTO \"auto\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · ParameterList: &cc.ParameterList{\n\t// · · Case: 1,\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterTypeList_base() {\n\tfmt.Println(exampleAST(162, \"\\U00100001 a ( auto )\"))\n\t// Output:\n\t// &cc.ParameterTypeList{\n\t// · ParameterList: &cc.ParameterList{\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleParameterTypeList_dots() {\n\tfmt.Println(exampleAST(163, \"\\U00100001 a ( auto , ... )\"))\n\t// Output:\n\t// &cc.ParameterTypeList{\n\t// · Case: 1,\n\t// · ParameterList: &cc.ParameterList{\n\t// · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · Case: 1,\n\t// · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · Token: AUTO \"auto\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: ',',\n\t// · Token2: DDD,\n\t// }\n}\n\nfunc ExampleParameterTypeListOpt_case0() {\n\tfmt.Println(exampleAST(164, \"\\U00100000 ( _Bool ( )\") == (*ParameterTypeListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleParameterTypeListOpt_case1() {\n\tfmt.Println(exampleAST(165, \"\\U00100000 ( _Bool ( auto )\"))\n\t// Output:\n\t// &cc.ParameterTypeListOpt{\n\t// · ParameterTypeList: &cc.ParameterTypeList{\n\t// · · ParameterList: &cc.ParameterList{\n\t// · · · ParameterDeclaration: &cc.ParameterDeclaration{\n\t// · · · · DeclarationSpecifiers: &cc.DeclarationSpecifiers{\n\t// · · · · · Case: 1,\n\t// · · · · · StorageClassSpecifier: &cc.StorageClassSpecifier{\n\t// · · · · · · Token: AUTO \"auto\",\n\t// · · · · · },\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExamplePointer_base() {\n\tfmt.Println(exampleAST(154, \"\\U00100001 * (\"))\n\t// Output:\n\t// &cc.Pointer{\n\t// · Token: '*',\n\t// }\n}\n\nfunc ExamplePointer_ptr() {\n\tfmt.Println(exampleAST(155, \"\\U00100001 * * (\"))\n\t// Output:\n\t// &cc.Pointer{\n\t// · Case: 1,\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: '*',\n\t// · },\n\t// · Token: '*',\n\t// }\n}\n\nfunc ExamplePointerOpt_case0() {\n\tfmt.Println(exampleAST(156, \"\\U00100001 (\") == (*PointerOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExamplePointerOpt_case1() {\n\tfmt.Println(exampleAST(157, \"\\U00100001 * (\"))\n\t// Output:\n\t// &cc.PointerOpt{\n\t// · Pointer: &cc.Pointer{\n\t// · · Token: '*',\n\t// · },\n\t// }\n}\n\nfunc ExampleSelectionStmt_ifElse() {\n\tfmt.Println(exampleAST(222, \"\\U00100001 a { if ( 'b' ) ; else ; !\"))\n\t// Output:\n\t// &cc.SelectionStmt{\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Stmt2: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: IF \"if\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// · Token4: ELSE \"else\",\n\t// }\n}\n\nfunc ExampleSelectionStmt_if() {\n\tfmt.Println(exampleAST(223, \"\\U00100001 a { if ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.SelectionStmt{\n\t// · Case: 1,\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: IF \"if\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// }\n}\n\nfunc ExampleSelectionStmt_switch() {\n\tfmt.Println(exampleAST(224, \"\\U00100001 a { switch ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.SelectionStmt{\n\t// · Case: 2,\n\t// · ExprList: &cc.ExprList{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'b'\",\n\t// · · },\n\t// · },\n\t// · Stmt: &cc.Stmt{\n\t// · · Case: 1,\n\t// · · ExprStmt: &cc.ExprStmt{\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · Token: SWITCH \"switch\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// }\n}\n\nfunc ExampleSpecifierQualifierList_qualifier() {\n\tfmt.Println(exampleAST(121, \"\\U00100000 ( const (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierList{\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleSpecifierQualifierList_specifier() {\n\tfmt.Println(exampleAST(122, \"\\U00100000 ( _Bool (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierList{\n\t// · Case: 1,\n\t// · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · Token: BOOL \"_Bool\",\n\t// · },\n\t// }\n}\n\nfunc ExampleSpecifierQualifierListOpt_case0() {\n\tfmt.Println(exampleAST(123, \"\\U00100000 ( const (\") == (*SpecifierQualifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleSpecifierQualifierListOpt_case1() {\n\tfmt.Println(exampleAST(124, \"\\U00100000 ( const _Bool (\"))\n\t// Output:\n\t// &cc.SpecifierQualifierListOpt{\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · Case: 1,\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Token: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_block() {\n\tfmt.Println(exampleAST(203, \"\\U00100001 a { { } !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · CompoundStmt: &cc.CompoundStmt{\n\t// · · Token: '{',\n\t// · · Token2: '}',\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_expr() {\n\tfmt.Println(exampleAST(204, \"\\U00100001 a { ; !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · Case: 1,\n\t// · ExprStmt: &cc.ExprStmt{\n\t// · · Token: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_iter() {\n\tfmt.Println(exampleAST(205, \"\\U00100001 a { while ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · Case: 2,\n\t// · IterationStmt: &cc.IterationStmt{\n\t// · · Case: 3,\n\t// · · ExprList: &cc.ExprList{\n\t// · · · Expr: &cc.Expr{\n\t// · · · · Case: ExprChar,\n\t// · · · · Token: CHARCONST \"'b'\",\n\t// · · · },\n\t// · · },\n\t// · · Stmt: &cc.Stmt{\n\t// · · · Case: 1,\n\t// · · · ExprStmt: &cc.ExprStmt{\n\t// · · · · Token: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: WHILE \"while\",\n\t// · · Token2: '(',\n\t// · · Token3: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_jump() {\n\tfmt.Println(exampleAST(206, \"\\U00100001 a { break ; !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · Case: 3,\n\t// · JumpStmt: &cc.JumpStmt{\n\t// · · Token: BREAK \"break\",\n\t// · · Token2: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_labeled() {\n\tfmt.Println(exampleAST(207, \"\\U00100001 a { default : ; !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · Case: 4,\n\t// · LabeledStmt: &cc.LabeledStmt{\n\t// · · Case: 1,\n\t// · · Stmt: &cc.Stmt{\n\t// · · · Case: 1,\n\t// · · · ExprStmt: &cc.ExprStmt{\n\t// · · · · Token: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: DEFAULT \"default\",\n\t// · · Token2: ':',\n\t// · },\n\t// }\n}\n\nfunc ExampleStmt_select() {\n\tfmt.Println(exampleAST(208, \"\\U00100001 a { if ( 'b' ) ; !\"))\n\t// Output:\n\t// &cc.Stmt{\n\t// · Case: 5,\n\t// · SelectionStmt: &cc.SelectionStmt{\n\t// · · Case: 1,\n\t// · · ExprList: &cc.ExprList{\n\t// · · · Expr: &cc.Expr{\n\t// · · · · Case: ExprChar,\n\t// · · · · Token: CHARCONST \"'b'\",\n\t// · · · },\n\t// · · },\n\t// · · Stmt: &cc.Stmt{\n\t// · · · Case: 1,\n\t// · · · ExprStmt: &cc.ExprStmt{\n\t// · · · · Token: ';',\n\t// · · · },\n\t// · · },\n\t// · · Token: IF \"if\",\n\t// · · Token2: '(',\n\t// · · Token3: ')',\n\t// · },\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_auto() {\n\tfmt.Println(exampleAST(88, \"\\U00100001 auto (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Token: AUTO \"auto\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_extern() {\n\tfmt.Println(exampleAST(89, \"\\U00100001 extern (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 1,\n\t// · Token: EXTERN \"extern\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_register() {\n\tfmt.Println(exampleAST(90, \"\\U00100001 register (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 2,\n\t// · Token: REGISTER \"register\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_static() {\n\tfmt.Println(exampleAST(91, \"\\U00100001 static (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 3,\n\t// · Token: STATIC \"static\",\n\t// }\n}\n\nfunc ExampleStorageClassSpecifier_typedef() {\n\tfmt.Println(exampleAST(92, \"\\U00100001 typedef (\"))\n\t// Output:\n\t// &cc.StorageClassSpecifier{\n\t// · Case: 4,\n\t// · Token: TYPEDEF \"typedef\",\n\t// }\n}\n\nfunc ExampleStructDeclaration_base() {\n\tfmt.Println(exampleAST(119, \"\\U00100001 struct { _Bool a ; }\"))\n\t// Output:\n\t// &cc.StructDeclaration{\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · Case: 1,\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Token: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// · StructDeclaratorList: &cc.StructDeclaratorList{\n\t// · · StructDeclarator: &cc.StructDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: LinkageNone,\n\t// · · · · Scope: &cc.Scope{\n\t// · · · · },\n\t// · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · Token: IDENTIFIER \"a\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · Token: ';',\n\t// }\n}\n\nfunc ExampleStructDeclaration_anon() {\n\tfmt.Println(exampleAST(120, \"\\U00100001 struct { _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclaration{\n\t// · Case: 1,\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · Case: 1,\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Token: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// · Token: ';',\n\t// }\n}\n\nfunc ExampleStructDeclarationList_case0() {\n\tfmt.Println(exampleAST(117, \"\\U00100001 struct { _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclarationList{\n\t// · StructDeclaration: &cc.StructDeclaration{\n\t// · · Case: 1,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarationList_case1() {\n\tfmt.Println(exampleAST(118, \"\\U00100001 struct { _Bool ; _Bool ; }\"))\n\t// Output:\n\t// &cc.StructDeclarationList{\n\t// · StructDeclaration: &cc.StructDeclaration{\n\t// · · Case: 1,\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · · Token: ';',\n\t// · },\n\t// · StructDeclarationList: &cc.StructDeclarationList{\n\t// · · Case: 1,\n\t// · · StructDeclaration: &cc.StructDeclaration{\n\t// · · · Case: 1,\n\t// · · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · · Case: 1,\n\t// · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · Token: BOOL \"_Bool\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarator_base() {\n\tfmt.Println(exampleAST(127, \"\\U00100001 struct { _Bool a ,\"))\n\t// Output:\n\t// &cc.StructDeclarator{\n\t// · Declarator: &cc.Declarator{\n\t// · · Linkage: LinkageNone,\n\t// · · Scope: &cc.Scope{\n\t// · · },\n\t// · · StorageDuration: StorageDurationAutomatic,\n\t// · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · Case: DirectDeclaratorIdent,\n\t// · · · Token: IDENTIFIER \"a\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclarator_bits() {\n\tfmt.Println(exampleAST(128, \"\\U00100001 struct { _Bool : 'a' ,\"))\n\t// Output:\n\t// &cc.StructDeclarator{\n\t// · Case: 1,\n\t// · ConstExpr: &cc.ConstExpr{\n\t// · · Expr: &cc.Expr{\n\t// · · · Case: ExprChar,\n\t// · · · Token: CHARCONST \"'a'\",\n\t// · · },\n\t// · },\n\t// · Token: ':',\n\t// }\n}\n\nfunc ExampleStructDeclaratorList_case0() {\n\tfmt.Println(exampleAST(125, \"\\U00100001 struct { _Bool a ,\"))\n\t// Output:\n\t// &cc.StructDeclaratorList{\n\t// · StructDeclarator: &cc.StructDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: LinkageNone,\n\t// · · · Scope: &cc.Scope{\n\t// · · · },\n\t// · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Case: DirectDeclaratorIdent,\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleStructDeclaratorList_case1() {\n\tfmt.Println(exampleAST(126, \"\\U00100001 struct { _Bool a , b ,\"))\n\t// Output:\n\t// &cc.StructDeclaratorList{\n\t// · StructDeclarator: &cc.StructDeclarator{\n\t// · · Declarator: &cc.Declarator{\n\t// · · · Linkage: LinkageNone,\n\t// · · · Scope: &cc.Scope{\n\t// · · · },\n\t// · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · Case: DirectDeclaratorIdent,\n\t// · · · · Token: IDENTIFIER \"a\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// · StructDeclaratorList: &cc.StructDeclaratorList{\n\t// · · Case: 1,\n\t// · · StructDeclarator: &cc.StructDeclarator{\n\t// · · · Declarator: &cc.Declarator{\n\t// · · · · Linkage: LinkageNone,\n\t// · · · · Scope: &cc.Scope{ /* recursive/repetitive pointee not shown */ },\n\t// · · · · StorageDuration: StorageDurationAutomatic,\n\t// · · · · DirectDeclarator: &cc.DirectDeclarator{\n\t// · · · · · Case: DirectDeclaratorIdent,\n\t// · · · · · Token: IDENTIFIER \"b\",\n\t// · · · · },\n\t// · · · },\n\t// · · },\n\t// · · Token: ',',\n\t// · },\n\t// }\n}\n\nfunc ExampleStructOrUnion_struct() {\n\tfmt.Println(exampleAST(115, \"\\U00100001 struct {\"))\n\t// Output:\n\t// &cc.StructOrUnion{\n\t// · Token: STRUCT \"struct\",\n\t// }\n}\n\nfunc ExampleStructOrUnion_union() {\n\tfmt.Println(exampleAST(116, \"\\U00100001 union {\"))\n\t// Output:\n\t// &cc.StructOrUnion{\n\t// · Case: 1,\n\t// · Token: UNION \"union\",\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier_tag() {\n\tfmt.Println(exampleAST(109, \"\\U00100001 struct a (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: STRUCT \"struct\",\n\t// · },\n\t// · Token: IDENTIFIER \"a\",\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier_empty() {\n\tfmt.Println(exampleAST(111, \"\\U00100001 struct { } (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · Case: 1,\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: STRUCT \"struct\",\n\t// · },\n\t// · Token: '{',\n\t// · Token2: '}',\n\t// }\n}\n\nfunc ExampleStructOrUnionSpecifier_define() {\n\tfmt.Println(exampleAST(114, \"\\U00100001 struct { _Bool ; } (\"))\n\t// Output:\n\t// &cc.StructOrUnionSpecifier{\n\t// · Case: 2,\n\t// · StructDeclarationList: &cc.StructDeclarationList{\n\t// · · StructDeclaration: &cc.StructDeclaration{\n\t// · · · Case: 1,\n\t// · · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · · Case: 1,\n\t// · · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · · Token: BOOL \"_Bool\",\n\t// · · · · },\n\t// · · · },\n\t// · · · Token: ';',\n\t// · · },\n\t// · },\n\t// · StructOrUnion: &cc.StructOrUnion{\n\t// · · Token: STRUCT \"struct\",\n\t// · },\n\t// · Token: '{',\n\t// · Token2: '}',\n\t// }\n}\n\nfunc ExampleTypeName_case0() {\n\tfmt.Println(exampleAST(176, \"\\U00100000 ( _Bool )\"))\n\t// Output:\n\t// &cc.TypeName{\n\t// · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · Case: 1,\n\t// · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · Token: BOOL \"_Bool\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifier_const() {\n\tfmt.Println(exampleAST(137, \"\\U00100001 const !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Token: CONST \"const\",\n\t// }\n}\n\nfunc ExampleTypeQualifier_restrict() {\n\tfmt.Println(exampleAST(138, \"\\U00100001 restrict !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Case: 1,\n\t// · Token: RESTRICT \"restrict\",\n\t// }\n}\n\nfunc ExampleTypeQualifier_volatile() {\n\tfmt.Println(exampleAST(139, \"\\U00100001 volatile !\"))\n\t// Output:\n\t// &cc.TypeQualifier{\n\t// · Case: 2,\n\t// · Token: VOLATILE \"volatile\",\n\t// }\n}\n\nfunc ExampleTypeQualifierList_case0() {\n\tfmt.Println(exampleAST(158, \"\\U00100001 * const !\"))\n\t// Output:\n\t// &cc.TypeQualifierList{\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: CONST \"const\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifierList_case1() {\n\tfmt.Println(exampleAST(159, \"\\U00100001 * const const !\"))\n\t// Output:\n\t// &cc.TypeQualifierList{\n\t// · TypeQualifier: &cc.TypeQualifier{\n\t// · · Token: CONST \"const\",\n\t// · },\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · Case: 1,\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeQualifierListOpt_case0() {\n\tfmt.Println(exampleAST(160, \"\\U00100001 * (\") == (*TypeQualifierListOpt)(nil))\n\t// Output:\n\t// true\n}\n\nfunc ExampleTypeQualifierListOpt_case1() {\n\tfmt.Println(exampleAST(161, \"\\U00100001 * const !\"))\n\t// Output:\n\t// &cc.TypeQualifierListOpt{\n\t// · TypeQualifierList: &cc.TypeQualifierList{\n\t// · · TypeQualifier: &cc.TypeQualifier{\n\t// · · · Token: CONST \"const\",\n\t// · · },\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier_bool() {\n\tfmt.Println(exampleAST(93, \"\\U00100001 _Bool (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Token: BOOL \"_Bool\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_complex() {\n\tfmt.Println(exampleAST(94, \"\\U00100001 _Complex (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 1,\n\t// · Token: COMPLEX \"_Complex\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_char() {\n\tfmt.Println(exampleAST(95, \"\\U00100001 char (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 2,\n\t// · Token: CHAR \"char\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_double() {\n\tfmt.Println(exampleAST(96, \"\\U00100001 double (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 3,\n\t// · Token: DOUBLE \"double\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_float() {\n\tfmt.Println(exampleAST(97, \"\\U00100001 float (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 4,\n\t// · Token: FLOAT \"float\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_int() {\n\tfmt.Println(exampleAST(98, \"\\U00100001 int (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 5,\n\t// · Token: INT \"int\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_long() {\n\tfmt.Println(exampleAST(99, \"\\U00100001 long (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 6,\n\t// · Token: LONG \"long\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_short() {\n\tfmt.Println(exampleAST(100, \"\\U00100001 short (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 7,\n\t// · Token: SHORT \"short\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_signed() {\n\tfmt.Println(exampleAST(101, \"\\U00100001 signed (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 8,\n\t// · Token: SIGNED \"signed\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_unsigned() {\n\tfmt.Println(exampleAST(102, \"\\U00100001 unsigned (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 9,\n\t// · Token: UNSIGNED \"unsigned\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_void() {\n\tfmt.Println(exampleAST(103, \"\\U00100001 void (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 10,\n\t// · Token: VOID \"void\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_enum() {\n\tfmt.Println(exampleAST(104, \"\\U00100001 enum a (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 11,\n\t// · EnumSpecifier: &cc.EnumSpecifier{\n\t// · · Token: ENUM \"enum\",\n\t// · · Token2: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier_struct() {\n\tfmt.Println(exampleAST(105, \"\\U00100001 struct a (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 12,\n\t// · StructOrUnionSpecifier: &cc.StructOrUnionSpecifier{\n\t// · · StructOrUnion: &cc.StructOrUnion{\n\t// · · · Token: STRUCT \"struct\",\n\t// · · },\n\t// · · Token: IDENTIFIER \"a\",\n\t// · },\n\t// }\n}\n\nfunc ExampleTypeSpecifier_name() {\n\tfmt.Println(exampleAST(106, \"\\U00100001 typedef int foo; foo bar;\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 13,\n\t// · Token: TYPEDEF_NAME \"foo\",\n\t// }\n}\n\nfunc ExampleTypeSpecifier_typeofExpr() {\n\tfmt.Println(exampleAST(107, \"\\U00100001 typeof ( 'a' ) (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 14,\n\t// · Expr: &cc.Expr{\n\t// · · Case: ExprChar,\n\t// · · Token: CHARCONST \"'a'\",\n\t// · },\n\t// · Token: TYPEOF \"typeof\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// }\n}\n\nfunc ExampleTypeSpecifier_typeof() {\n\tfmt.Println(exampleAST(108, \"\\U00100001 typeof ( _Bool ) (\"))\n\t// Output:\n\t// &cc.TypeSpecifier{\n\t// · Case: 15,\n\t// · Token: TYPEOF \"typeof\",\n\t// · Token2: '(',\n\t// · Token3: ')',\n\t// · TypeName: &cc.TypeName{\n\t// · · SpecifierQualifierList: &cc.SpecifierQualifierList{\n\t// · · · Case: 1,\n\t// · · · TypeSpecifier: &cc.TypeSpecifier{\n\t// · · · · Token: BOOL \"_Bool\",\n\t// · · · },\n\t// · · },\n\t// · },\n\t// }\n}\n"
  },
  {
    "path": "v2/cc.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n//go:generate rm -f scanner.go trigraphs.go\n//go:generate golex -o trigraphs.go trigraphs.l\n//go:generate golex -o scanner.go scanner.l\n\n//go:generate rm -f ast.go\n//go:generate yy -kind Case -o parser.y -astImport \"\\\"github.com/cznic/xc\\\";\\\"go/token\\\";\\\"fmt\\\"\" -prettyString PrettyString parser.yy\n\n//go:generate rm -f parser.go\n//go:generate goyacc -o /dev/null -xegen xegen parser.y\n//go:generate goyacc -o parser.go -pool -fs -xe xegen -dlvalf \"%v\" -dlval \"PrettyString(lval.Token)\" parser.y\n//go:generate rm -f xegen\n\n//go:generate stringer -output stringer.go -type=cond,Linkage,StorageDuration enum.go\n//go:generate sh -c \"go test -run ^Example |fe\"\n//go:generate gofmt -l -s -w .\n\n// Package cc is a C99 compiler front end. Work In Progress. API unstable.\npackage cc\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/scanner\"\n\t\"go/token\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"runtime/debug\"\n\t\"sort\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nconst (\n\t// CRT0Source is the source code of the C startup code.\n\tCRT0Source = `int main();\n\n__FILE_TYPE__ __stdfiles[3];\nchar **environ;\nvoid *stdin = &__stdfiles[0], *stdout = &__stdfiles[1], *stderr = &__stdfiles[2];\n\nvoid _start(int argc, char **argv)\n{\n\t__register_stdfiles(stdin, stdout, stderr, &environ);\n\t__builtin_exit(((int (*)(int, char **))main) (argc, argv));\n}\t\n`\n\tcacheSize = 500\n)\n\nvar (\n\t_ Source = (*FileSource)(nil)\n\t_ Source = (*StringSource)(nil)\n\n\t_ debug.GCStats\n\n\t// YYDebug points to parser's yyDebug variable.\n\tYYDebug        = &yyDebug\n\ttraceMacroDefs bool\n\n\tcache   = make(map[cacheKey][]uint32, cacheSize)\n\tcacheMu sync.Mutex // Guards cache, fset\n\tfset    = token.NewFileSet()\n\n\tpackageDir     string\n\theaders        string\n\tselfImportPath string\n)\n\nfunc init() {\n\tip, err := strutil.ImportPath()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tselfImportPath = ip\n\tif packageDir, err = findRepo(ip); err != nil {\n\t\tpanic(err)\n\t}\n\n\theaders = filepath.Join(packageDir, \"headers\", fmt.Sprintf(\"%v_%v\", env(\"GOOS\", runtime.GOOS), env(\"GOARCH\", runtime.GOARCH)))\n}\n\nfunc findRepo(s string) (string, error) {\n\ts = filepath.FromSlash(s)\n\tfor _, v := range strings.Split(strutil.Gopath(), string(os.PathListSeparator)) {\n\t\tp := filepath.Join(v, \"src\", s)\n\t\tfi, err := os.Lstat(p)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fi.IsDir() {\n\t\t\twd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tif p, err = filepath.Rel(wd, p); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tif p, err = filepath.Abs(p); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\treturn p, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"%q: cannot find repository\", s)\n}\n\n// ImportPath reports the import path of this package.\nfunc ImportPath() string { return selfImportPath }\n\n// Builtin returns the Source for built-in and predefined stuff or an error, if any.\nfunc Builtin() (Source, error) { return NewFileSource(filepath.Join(headers, \"builtin.h\")) }\n\n// Crt0 returns the Source for program initialization code.\nfunc Crt0() (Source, error) { return NewStringSource(\"crt0.c\", CRT0Source), nil } //TODO mv to ccgo\n\n// MustBuiltin is like Builtin but panics on error.\nfunc MustBuiltin() Source { return MustFileSource(filepath.Join(headers, \"builtin.h\")) }\n\n// MustCrt0 is like Crt0 but panics on error.\nfunc MustCrt0() Source { //TODO mv to ccgo\n\ts, err := Crt0()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn s\n}\n\n// MustFileSource is like NewFileSource but panics on error.\nfunc MustFileSource(nm string) *FileSource { return MustFileSource2(nm, true) }\n\n// MustFileSource2 is like NewFileSource but panics on error.\nfunc MustFileSource2(nm string, cacheable bool) *FileSource {\n\tsrc, err := NewFileSource2(nm, cacheable)\n\tif err != nil {\n\t\twd, _ := os.Getwd()\n\t\tpanic(fmt.Errorf(\"%v: %v (wd %v)\", nm, err, wd))\n\t}\n\n\treturn src\n}\n\n// Paths returns the system header search paths, or an error, if any. If local\n// is true the package-local, cached header search paths are returned.\nfunc Paths(local bool) ([]string, error) {\n\tp := filepath.Join(headers, \"paths\")\n\tb, err := ioutil.ReadFile(p)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ta := strings.Split(string(b), \"\\n\")\n\tfor i, v := range a {\n\t\tswitch {\n\t\tcase local:\n\t\t\ta[i] = filepath.Join(headers, strings.TrimSpace(v))\n\t\tdefault:\n\t\t\ta[i] = strings.TrimSpace(v)\n\t\t}\n\t}\n\treturn a, nil\n}\n\n// HostConfig executes HostCppConfig with the cpp argument set to \"cpp\". For\n// more info please see the documentation of HostCppConfig.\nfunc HostConfig(opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error) {\n\treturn HostCppConfig(\"cpp\", opts...)\n}\n\n// HostCppConfig returns the system C preprocessor configuration, or an error,\n// if any.  The configuration is obtained by running the cpp command. For the\n// predefined macros list the '-dM' options is added. For the include paths\n// lists, the option '-v' is added and the output is parsed to extract the\n// \"...\" include and <...> include paths. To add any other options to cpp, list\n// them in opts.\n//\n// The function relies on a POSIX compatible C preprocessor installed.\n// Execution of HostConfig is not free, so caching the results is recommended\n// whenever possible.\nfunc HostCppConfig(cpp string, opts ...string) (predefined string, includePaths, sysIncludePaths []string, err error) {\n\targs := append(append([]string{\"-dM\"}, opts...), os.DevNull)\n\t// cross-compile e.g. win64 -> win32\n\tif env(\"GOARCH\", runtime.GOARCH) == \"386\" {\n\t\targs = append(args, \"-m32\")\n\t}\n\tpre, err := exec.Command(cpp, args...).Output()\n\tif err != nil {\n\t\treturn \"\", nil, nil, err\n\t}\n\n\targs = append(append([]string{\"-v\"}, opts...), os.DevNull)\n\tout, err := exec.Command(cpp, args...).CombinedOutput()\n\tif err != nil {\n\t\treturn \"\", nil, nil, err\n\t}\n\n\tsep := \"\\n\"\n\tif env(\"GOOS\", runtime.GOOS) == \"windows\" {\n\t\tsep = \"\\r\\n\"\n\t}\n\n\ta := strings.Split(string(out), sep)\n\tfor i := 0; i < len(a); {\n\t\tswitch a[i] {\n\t\tcase \"#include \\\"...\\\" search starts here:\":\n\t\tloop:\n\t\t\tfor i = i + 1; i < len(a); {\n\t\t\t\tswitch v := a[i]; {\n\t\t\t\tcase strings.HasPrefix(v, \"#\") || v == \"End of search list.\":\n\t\t\t\t\tbreak loop\n\t\t\t\tdefault:\n\t\t\t\t\tincludePaths = append(includePaths, strings.TrimSpace(v))\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"#include <...> search starts here:\":\n\t\t\tfor i = i + 1; i < len(a); {\n\t\t\t\tswitch v := a[i]; {\n\t\t\t\tcase strings.HasPrefix(v, \"#\") || v == \"End of search list.\":\n\t\t\t\t\treturn string(pre), includePaths, sysIncludePaths, nil\n\t\t\t\tdefault:\n\t\t\t\t\tsysIncludePaths = append(sysIncludePaths, strings.TrimSpace(v))\n\t\t\t\t\ti++\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\ti++\n\t\t}\n\t}\n\treturn \"\", nil, nil, fmt.Errorf(\"failed parsing %s -v output\", cpp)\n}\n\ntype cacheKey struct {\n\tname  string\n\tmtime int64\n}\n\n// FlushCache removes all items in the file cache used by instances of FileSource.\nfunc FlushCache() { //TODO-\n\tcacheMu.Lock()\n\tcache = make(map[cacheKey][]uint32, cacheSize)\n\tfset = token.NewFileSet()\n\tcacheMu.Unlock()\n}\n\n// TranslationUnit represents a translation unit, see [0]6.9.\ntype TranslationUnit struct {\n\tExternalDeclarationList *ExternalDeclarationList\n\tFileScope               *Scope\n\tFileSet                 *token.FileSet\n\tIncludePaths            []string\n\tMacros                  map[int]*Macro\n\tModel                   Model\n\tSysIncludePaths         []string\n}\n\n// Tweaks amend the behavior of the parser.\ntype Tweaks struct { //TODO- remove all options\n\tTrackExpand   func(string)\n\tTrackIncludes func(string)\n\n\tDefinesOnly                 bool // like in CC -E -dM foo.c\n\tEnableAnonymousStructFields bool // struct{int;}\n\tEnableBinaryLiterals        bool // 0b101010 == 42\n\tEnableEmptyStructs          bool // struct{}\n\tEnableImplicitBuiltins      bool // Undefined printf becomes __builtin_printf.\n\tEnableImplicitDeclarations  bool // eg. using exit(1) w/o #include <stdlib.h>\n\tEnableOmitFuncDeclSpec      bool // foo() { ... } == int foo() { ... }\n\tEnablePointerCompatibility  bool // All pointers are assignment compatible.\n\tEnableReturnExprInVoidFunc  bool // void f() { return 1; }\n\tEnableTrigraphs             bool\n\tEnableUnionCasts            bool // (union foo)0\n\tIgnoreUnknownPragmas        bool // #pragma\n\tInjectFinalNL               bool // Specs want the source to always end in a newline.\n\tPreprocessOnly              bool // like in CC -E foo.c\n\tcppExpandTest               bool // Fake includes\n}\n\n// Translate preprocesses, parses and type checks a translation unit using fset\n// to record node and error positions, includePaths and sysIncludePaths for\n// looking for \"foo.h\" and <foo.h> files. A special path \"@\" is interpretted as\n// 'the same directory as where the file with the #include is'. The input\n// consists of sources which must include any predefined/builtin stuff.\n//\n// The returned scope is the file scope of the Translation unit.\nfunc Translate(tweaks *Tweaks, includePaths, sysIncludePaths []string, sources ...Source) (tu *TranslationUnit, err error) {\n\treturned := false\n\n\tdefer func() {\n\t\te := recover()\n\t\tif !returned && err == nil {\n\t\t\tif e != nil {\n\t\t\t\terr = fmt.Errorf(\"%v\\n%s\", e, debugStack())\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\terr = fmt.Errorf(\"PANIC: %v\\n%s\", e, debugStack())\n\t\t}\n\t}()\n\n\tmodel, err := NewModel()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tctx, err := newContext(tweaks)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tctx.model = model\n\tctx.includePaths = append([]string(nil), includePaths...)\n\tctx.sysIncludePaths = append([]string(nil), sysIncludePaths...)\n\tif tu, err = ctx.parse(sources); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif tweaks.PreprocessOnly {\n\t\treturned = true\n\t\treturn nil, nil\n\t}\n\n\tif err := tu.ExternalDeclarationList.check(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := ctx.error(); err != nil {\n\t\treturn nil, err\n\t}\n\n\ttu.IncludePaths = append([]string(nil), includePaths...)\n\ttu.SysIncludePaths = append([]string(nil), sysIncludePaths...)\n\treturned = true\n\treturn tu, nil\n}\n\n// Translation unit context.\ntype context struct {\n\terrors       scanner.ErrorList\n\texampleAST   interface{}\n\texampleRule  int\n\tincludePaths []string\n\tmodel        Model\n\tscope        *Scope\n\tsync.Mutex\n\tsysIncludePaths []string\n\ttweaks          *Tweaks\n}\n\nfunc newContext(t *Tweaks) (*context, error) {\n\treturn &context{\n\t\tscope:  newScope(nil),\n\t\ttweaks: t,\n\t}, nil\n}\n\nfunc (c *context) err(n Node, msg string, args ...interface{}) { c.errPos(n.Pos(), msg, args...) }\nfunc (c *context) newScope()                                   { c.scope = newScope(c.scope) }\nfunc (c *context) newStructScope()                             { c.scope = newScope(c.scope); c.scope.structScope = true }\n\nfunc (c *context) position(n Node) (r token.Position) {\n\tif n != nil {\n\t\treturn fset.PositionFor(n.Pos(), true)\n\t}\n\n\treturn r\n}\n\nfunc (c *context) errPos(pos token.Pos, msg string, args ...interface{}) {\n\tc.Lock()\n\ts := fmt.Sprintf(msg, args...)\n\t//s = fmt.Sprintf(\"%s\\n====%s\\n----\", s, debug.Stack())\n\tc.errors.Add(fset.PositionFor(pos, true), s)\n\tc.Unlock()\n}\n\nfunc (c *context) error() error {\n\tc.Lock()\n\n\tdefer c.Unlock()\n\n\tif len(c.errors) == 0 {\n\t\treturn nil\n\t}\n\n\tc.errors.Sort()\n\terr := append(scanner.ErrorList(nil), c.errors...)\n\treturn err\n}\n\nfunc (c *context) parse(in []Source) (_ *TranslationUnit, err error) {\n\tcpp := newCPP(c)\n\tr, err := cpp.parse(in...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlx, err := newLexer(c, \"\", 0, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tp := newTokenPipe(1024)\n\tif c.tweaks.PreprocessOnly {\n\t\tp.emitWhiteSpace = true\n\t}\n\tlx.tc = p\n\n\tvar cppErr error\n\tch := make(chan struct{})\n\tgo func() {\n\t\treturned := false\n\n\t\tdefer func() {\n\t\t\tp.close()\n\t\t\te := recover()\n\t\t\tif !returned && cppErr == nil {\n\t\t\t\tcppErr = fmt.Errorf(\"PANIC: %v\\n%s\", e, debugStack())\n\t\t\t\tc.err(nopos, \"%v\", cppErr)\n\t\t\t}\n\t\t\tch <- struct{}{}\n\t\t}()\n\n\t\tif cppErr = cpp.eval(r, p); cppErr != nil {\n\t\t\tc.err(nopos, \"%v\", cppErr)\n\t\t}\n\t\treturned = true\n\t}()\n\n\tif c.tweaks.PreprocessOnly {\n\t\tfor {\n\t\t\tt := p.read()\n\t\t\tif t.Rune == ccEOF {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif f := c.tweaks.TrackExpand; f != nil {\n\t\t\t\tif p := c.position(t); filepath.Base(p.Filename) != \"builtin.h\" {\n\t\t\t\t\tf(TokSrc(t.Token))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif err := c.error(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn nil, cppErr\n\t}\n\n\tok := lx.parse(TRANSLATION_UNIT)\n\tif err := c.error(); err != nil || !ok {\n\t\tgo func() { // drain\n\t\t\tfor range p.ch {\n\t\t\t}\n\t\t}()\n\t\treturn nil, err\n\t}\n\n\tif c.scope.Parent != nil {\n\t\tpanic(\"internal error\")\n\t}\n\n\t<-ch\n\tif cppErr != nil {\n\t\treturn nil, cppErr\n\t}\n\n\ttu := lx.ast.(*TranslationUnit)\n\ttu.Macros = cpp.macros\n\treturn tu, nil\n}\n\nfunc (c *context) popScope() (old, new *Scope) {\n\told = c.scope\n\tc.scope = c.scope.Parent\n\treturn old, c.scope\n}\n\nfunc (c *context) ptrDiff() Type {\n\td, ok := c.scope.LookupIdent(idPtrdiffT).(*Declarator)\n\tif !ok {\n\t\tpsz := c.model[Ptr].Size\n\t\tfor _, v := range []TypeKind{Int, Long, LongLong} {\n\t\t\tif c.model[v].Size >= psz {\n\t\t\t\treturn v\n\t\t\t}\n\t\t}\n\t\tpanic(\"internal error\")\n\t}\n\n\tif !d.DeclarationSpecifier.IsTypedef() {\n\t\tpanic(d.Type)\n\t}\n\n\treturn d.Type\n}\n\nfunc (c *context) wideChar() Type {\n\td, ok := c.scope.LookupIdent(idWcharT).(*Declarator)\n\tif !ok {\n\t\tvar sz int\n\t\tswitch goos := env(\"GOOS\", \"\"); goos {\n\t\tcase \"windows\":\n\t\t\tsz = 2\n\t\tcase \"linux\":\n\t\t\tsz = 4\n\t\tdefault:\n\t\t\tpanic(goos)\n\t\t}\n\t\tfor _, v := range []TypeKind{SChar, Short, Int, Long, LongLong} {\n\t\t\tif c.model[v].Size >= sz {\n\t\t\t\treturn v\n\t\t\t}\n\t\t}\n\t\tpanic(\"internal error\")\n\t}\n\n\tif !d.DeclarationSpecifier.IsTypedef() {\n\t\tpanic(d.Type)\n\t}\n\n\treturn d.Type\n}\n\nfunc (c *context) charConst(t xc.Token) Operand {\n\tswitch t.Rune {\n\tcase CHARCONST:\n\t\ts := string(t.S())\n\t\ts = s[1 : len(s)-1] // Remove outer 's.\n\t\tif len(s) == 1 {\n\t\t\treturn Operand{Type: Int, Value: &ir.Int64Value{Value: int64(s[0])}}\n\t\t}\n\n\t\trunes := []rune(s)\n\t\tvar r rune\n\t\tswitch runes[0] {\n\t\tcase '\\\\':\n\t\t\tr, _ = decodeEscapeSequence(runes)\n\t\t\tif r < 0 {\n\t\t\t\tr = -r\n\t\t\t}\n\t\tdefault:\n\t\t\tr = runes[0]\n\t\t}\n\t\treturn Operand{Type: Int, Value: &ir.Int64Value{Value: int64(r)}}\n\tcase LONGCHARCONST:\n\t\ts := t.S()\n\t\tvar buf bytes.Buffer\n\t\ts = s[2 : len(s)-1]\n\t\trunes := []rune(string(s))\n\t\tfor i := 0; i < len(runes); {\n\t\t\tswitch r := runes[i]; {\n\t\t\tcase r == '\\\\':\n\t\t\t\tr, n := decodeEscapeSequence(runes[i:])\n\t\t\t\tswitch {\n\t\t\t\tcase r < 0:\n\t\t\t\t\tbuf.WriteByte(byte(-r))\n\t\t\t\tdefault:\n\t\t\t\t\tbuf.WriteRune(r)\n\t\t\t\t}\n\t\t\t\ti += n\n\t\t\tdefault:\n\t\t\t\tbuf.WriteByte(byte(r))\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\ts = buf.Bytes()\n\t\trunes = []rune(string(s))\n\t\tif len(runes) != 1 {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn Operand{Type: Long, Value: &ir.Int64Value{Value: int64(runes[0])}}\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\nfunc (c *context) strConst(t xc.Token) Operand {\n\ts := t.S()\n\tswitch t.Rune {\n\tcase LONGSTRINGLITERAL:\n\t\ts = s[1:] // Remove leading 'L'.\n\t\tfallthrough\n\tcase STRINGLITERAL:\n\t\tvar buf bytes.Buffer\n\t\ts = s[1 : len(s)-1] // Remove outer \"s.\n\t\trunes := []rune(string(s))\n\t\tfor i := 0; i < len(runes); {\n\t\t\tswitch r := runes[i]; {\n\t\t\tcase r == '\\\\':\n\t\t\t\tr, n := decodeEscapeSequence(runes[i:])\n\t\t\t\tswitch {\n\t\t\t\tcase r < 0:\n\t\t\t\t\tbuf.WriteByte(byte(-r))\n\t\t\t\tdefault:\n\t\t\t\t\tbuf.WriteRune(r)\n\t\t\t\t}\n\t\t\t\ti += n\n\t\t\tdefault:\n\t\t\t\tbuf.WriteByte(byte(r))\n\t\t\t\ti++\n\t\t\t}\n\t\t}\n\t\tswitch t.Rune {\n\t\tcase LONGSTRINGLITERAL:\n\t\t\trunes := []rune(buf.String())\n\t\t\ttyp := c.wideChar()\n\t\t\treturn Operand{\n\t\t\t\tType:  &ArrayType{Item: typ, Size: Operand{Type: Int, Value: &ir.Int64Value{Value: c.model.Sizeof(typ) * int64(len(runes)+1)}}},\n\t\t\t\tValue: &ir.WideStringValue{Value: runes},\n\t\t\t}\n\t\tcase STRINGLITERAL:\n\t\t\treturn Operand{\n\t\t\t\tType:  &ArrayType{Item: Char, Size: Operand{Type: Int, Value: &ir.Int64Value{Value: int64(len(buf.Bytes()) + 1)}}},\n\t\t\t\tValue: &ir.StringValue{StringID: ir.StringID(dict.ID(buf.Bytes()))},\n\t\t\t}\n\t\t}\n\t}\n\tpanic(\"internal error\")\n}\n\nfunc (c *context) sizeof(t Type) Operand {\n\tsz := c.model.Sizeof(t)\n\td, ok := c.scope.LookupIdent(idSizeT).(*Declarator)\n\tif !ok {\n\t\tpsz := c.model[Ptr].Size\n\t\tfor _, v := range []TypeKind{UInt, ULong, ULongLong} {\n\t\t\tif c.model[v].Size >= psz {\n\t\t\t\treturn newIntConst(c, nopos, uint64(sz), v)\n\t\t\t}\n\t\t}\n\t\tpanic(\"internal error\")\n\t}\n\n\tif !d.DeclarationSpecifier.IsTypedef() {\n\t\tpanic(d.Type)\n\t}\n\n\treturn Operand{Type: d.Type, Value: &ir.Int64Value{Value: sz}}\n}\n\nfunc (c *context) toC(ch rune, val int) rune {\n\tif ch != IDENTIFIER {\n\t\treturn ch\n\t}\n\n\tif x, ok := keywords[val]; ok {\n\t\treturn x\n\t}\n\n\treturn ch\n}\n\n// Source represents parser's input.\ntype Source interface {\n\tCache([]uint32)                     // Optionally cache the encoded source. Can be a no-operation.\n\tCached() []uint32                   // Return nil or the optionally encoded source cached by earlier call to Cache.\n\tName() string                       // Result will be used in reporting source code positions.\n\tReadCloser() (io.ReadCloser, error) // Where to read the source from\n\tSize() (int64, error)               // Report the size of the source in bytes.\n\tString() string\n}\n\n// FileSource is a Source reading from a named file.\ntype FileSource struct {\n\t*bufio.Reader\n\tf    *os.File\n\tpath string\n\tkey  cacheKey\n\tsize int64\n\n\tcacheable bool\n}\n\n// NewFileSource returns a newly created *FileSource reading from name.\nfunc NewFileSource(name string) (*FileSource, error) { return NewFileSource2(name, true) }\n\n// NewFileSource2 returns a newly created *FileSource reading from name.\nfunc NewFileSource2(name string, cacheable bool) (*FileSource, error) { //TODO-?\n\tf, err := os.Open(name)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr := &FileSource{f: f, path: name, cacheable: cacheable}\n\tfi, err := f.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tr.size = fi.Size()\n\tr.key = cacheKey{name, fi.ModTime().UnixNano()}\n\treturn r, nil\n}\n\nfunc (s *FileSource) String() string { return s.Name() }\n\n// Cache implements Source.\nfunc (s *FileSource) Cache(a []uint32) {\n\tif !s.cacheable {\n\t\treturn\n\t}\n\n\tcacheMu.Lock()\n\tif len(cache) > cacheSize {\n\t\tfor k := range cache {\n\t\t\tdelete(cache, k)\n\t\t\tbreak\n\t\t}\n\t}\n\tcache[s.key] = a\n\tcacheMu.Unlock()\n}\n\n// Cached implements Source.\nfunc (s *FileSource) Cached() (r []uint32) {\n\tif !s.cacheable {\n\t\treturn nil\n\t}\n\n\tcacheMu.Lock()\n\tvar ok bool\n\tr, ok = cache[s.key]\n\tcacheMu.Unlock()\n\tif ok {\n\t\ts.Close()\n\t}\n\treturn r\n}\n\n// Close implements io.ReadCloser.\nfunc (s *FileSource) Close() error {\n\tif f := s.f; f != nil {\n\t\ts.f = nil\n\t\treturn f.Close()\n\t}\n\n\treturn nil\n}\n\n// Name implements Source.\nfunc (s *FileSource) Name() string { return s.path }\n\n// ReadCloser implements Source.\nfunc (s *FileSource) ReadCloser() (io.ReadCloser, error) {\n\ts.Reader = bufio.NewReader(s.f)\n\treturn s, nil\n}\n\n// Size implements Source.\nfunc (s *FileSource) Size() (int64, error) { return s.size, nil }\n\n// StringSource is a Source reading from a string.\ntype StringSource struct {\n\t*strings.Reader\n\tname string\n\tsrc  string\n}\n\n// NewStringSource returns a newly created *StringSource reading from src and\n// having the presumed name.\nfunc NewStringSource(name, src string) *StringSource { return &StringSource{name: name, src: src} }\n\nfunc (s *StringSource) String() string { return s.Name() }\n\n// Cache implements Source.\nfunc (s *StringSource) Cache(a []uint32) {\n\tcacheMu.Lock()\n\tif len(cache) > cacheSize {\n\t\tfor k := range cache {\n\t\t\tdelete(cache, k)\n\t\t\tbreak\n\t\t}\n\t}\n\tcache[cacheKey{mtime: -1, name: s.src}] = a\n\tcacheMu.Unlock()\n}\n\n// Cached implements Source.\nfunc (s *StringSource) Cached() (r []uint32) {\n\tcacheMu.Lock()\n\tr = cache[cacheKey{mtime: -1, name: s.src}]\n\tcacheMu.Unlock()\n\treturn r\n}\n\n// Close implements io.ReadCloser.\nfunc (s *StringSource) Close() error { return nil }\n\n// Name implements Source.\nfunc (s *StringSource) Name() string { return s.name }\n\n// Size implements Source.\nfunc (s *StringSource) Size() (int64, error) { return int64(len(s.src)), nil }\n\n// ReadCloser implements Source.\nfunc (s *StringSource) ReadCloser() (io.ReadCloser, error) {\n\ts.Reader = strings.NewReader(s.src)\n\treturn s, nil\n}\n\n// Scope binds names to declarations.\ntype Scope struct {\n\tEnumTags   map[int]*EnumSpecifier // name ID: *EnumSpecifier\n\tIdents     map[int]Node           // name ID: Node in {*Declarator, EnumerationConstant}\n\tLabels     map[int]*LabeledStmt   // name ID: label\n\tParent     *Scope\n\tStructTags map[int]*StructOrUnionSpecifier // name ID: *StructOrUnionSpecifier\n\n\t// parser support\n\ttypedefs    map[int]struct{} // name: nothing\n\ttypedef     bool\n\tstructScope bool\n}\n\nfunc newScope(parent *Scope) *Scope { return &Scope{Parent: parent} }\n\nfunc (s *Scope) insertLabel(ctx *context, st *LabeledStmt) {\n\tfor s.Parent != nil && s.Parent.Parent != nil {\n\t\ts = s.Parent\n\t}\n\tif s.Labels == nil {\n\t\ts.Labels = map[int]*LabeledStmt{}\n\t}\n\tif ex := s.Labels[st.Token.Val]; ex != nil {\n\t\tpanic(\"TODO\")\n\t}\n\n\ts.Labels[st.Token.Val] = st\n}\n\nfunc (s *Scope) insertEnumTag(ctx *context, nm int, es *EnumSpecifier) {\n\tfor s.structScope {\n\t\ts = s.Parent\n\t}\n\tif s.EnumTags == nil {\n\t\ts.EnumTags = map[int]*EnumSpecifier{}\n\t}\n\tif ex := s.EnumTags[nm]; ex != nil {\n\t\tif ex == es || ex.isCompatible(es) {\n\t\t\treturn\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%s\\n----\\n%s\", ex, es))\n\t}\n\n\ts.EnumTags[nm] = es\n}\n\nfunc (s *Scope) insertDeclarator(ctx *context, d *Declarator) {\n\tif s.Idents == nil {\n\t\ts.Idents = map[int]Node{}\n\t}\n\tnm := d.Name()\n\tif ex := s.Idents[nm]; ex != nil {\n\t\tpanic(\"internal error 8\")\n\t}\n\n\ts.Idents[nm] = d\n}\n\nfunc (s *Scope) insertEnumerationConstant(ctx *context, c *EnumerationConstant) {\n\tfor s.structScope {\n\t\ts = s.Parent\n\t}\n\tif s.Idents == nil {\n\t\ts.Idents = map[int]Node{}\n\t}\n\tnm := c.Token.Val\n\tif ex := s.Idents[nm]; ex != nil {\n\t\tif ex == c {\n\t\t\treturn\n\t\t}\n\n\t\tif x, ok := ex.(*EnumerationConstant); ok && x.equal(c) {\n\t\t\treturn\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%v: %v, %v\", ctx.position(c), ex, c))\n\t}\n\n\ts.Idents[nm] = c\n}\n\nfunc (s *Scope) insertStructTag(ctx *context, ss *StructOrUnionSpecifier) {\n\tfor s.structScope {\n\t\ts = s.Parent\n\t}\n\tif s.StructTags == nil {\n\t\ts.StructTags = map[int]*StructOrUnionSpecifier{}\n\t}\n\tnm := ss.IdentifierOpt.Token.Val\n\tif ex := s.StructTags[nm]; ex != nil && !ex.typ.IsCompatible(ss.typ) {\n\t\tpanic(fmt.Errorf(\"%v: %v, %v\", ctx.position(ss), ex.typ, ss.typ))\n\t}\n\n\ts.StructTags[nm] = ss\n}\n\nfunc (s *Scope) insertTypedef(ctx *context, d *Declarator) {\n\tif s.typedefs == nil {\n\t\ts.typedefs = map[int]struct{}{}\n\t}\n\t// Redefinitions, if any, are ignored during parsing, but checked later in insertDeclarator.\n\ts.typedefs[d.Name()] = struct{}{}\n}\n\nfunc (s *Scope) isTypedef(nm int) bool {\n\tfor s != nil {\n\t\tif _, ok := s.typedefs[nm]; ok {\n\t\t\treturn true\n\t\t}\n\n\t\ts = s.Parent\n\t}\n\treturn false\n}\n\n// LookupIdent will return the Node associated with name ID nm.\nfunc (s *Scope) LookupIdent(nm int) Node {\n\tfor s != nil {\n\t\tif n := s.Idents[nm]; n != nil {\n\t\t\treturn n\n\t\t}\n\n\t\ts = s.Parent\n\t}\n\treturn nil\n}\n\n// LookupLabel will return the Node associated with label ID nm.\nfunc (s *Scope) LookupLabel(nm int) Node {\n\tfor s != nil {\n\t\tif n := s.Labels[nm]; n != nil {\n\t\t\tif s.Parent == nil && s.Parent.Parent != nil {\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\n\t\t\treturn n\n\t\t}\n\n\t\ts = s.Parent\n\t}\n\treturn nil\n}\n\nfunc (s *Scope) lookupEnumTag(nm int) *EnumSpecifier {\n\tfor s != nil {\n\t\tif n := s.EnumTags[nm]; n != nil {\n\t\t\treturn n\n\t\t}\n\n\t\ts = s.Parent\n\t}\n\treturn nil\n}\n\nfunc (s *Scope) lookupStructTag(nm int) *StructOrUnionSpecifier {\n\tfor s != nil {\n\t\tif n := s.StructTags[nm]; n != nil {\n\t\t\treturn n\n\t\t}\n\n\t\ts = s.Parent\n\t}\n\treturn nil\n}\n\nfunc (s *Scope) String() string {\n\tvar a []string\n\tfor _, v := range s.Idents {\n\t\tswitch x := v.(type) {\n\t\tcase *Declarator:\n\t\t\ta = append(a, string(dict.S(x.Name())))\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n\tsort.Strings(a)\n\treturn \"{\" + strings.Join(a, \", \") + \"}\"\n}\n"
  },
  {
    "path": "v2/cpp.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n// [1]: https://www.spinellis.gr/blog/20060626/cpp.algo.pdf\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"io\"\n\t\"math\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\nconst (\n\tmaxIncludeLevel = 200 // gcc, std is at least 15.\n)\n\nvar (\n\t_ tokenReader = (*cppReader)(nil)\n\t_ tokenReader = (*tokenBuffer)(nil)\n\t_ tokenReader = (*tokenPipe)(nil)\n\t_ tokenWriter = (*tokenBuffer)(nil)\n\t_ tokenWriter = (*tokenPipe)(nil)\n)\n\ntype cppToken struct {\n\txc.Token\n\ths map[int]struct{}\n}\n\nfunc (t *cppToken) has(nm int) bool { _, ok := t.hs[nm]; return ok }\n\nfunc (t *cppToken) cloneAdd(nm int) map[int]struct{} {\n\tnhs := map[int]struct{}{nm: {}}\n\tfor k, v := range t.hs {\n\t\tnhs[k] = v\n\t}\n\treturn nhs\n}\n\nfunc (t *cppToken) hsAdd(hs map[int]struct{}) {\n\tif len(hs) == 0 {\n\t\treturn\n\t}\n\n\tif len(t.hs) == 0 {\n\t\tt.hs = map[int]struct{}{}\n\t}\n\tfor k := range hs {\n\t\tt.hs[k] = struct{}{}\n\t}\n}\n\ntype tokenWriter interface {\n\twrite(...cppToken)\n}\n\ntype tokenReader interface {\n\tread() cppToken\n\tunget(cppToken)\n\tungets(...cppToken)\n}\n\ntype tokenPipe struct {\n\tb  []byte\n\tch chan cppToken\n\ts  []cppToken\n\n\temitWhiteSpace bool\n}\n\nfunc newTokenPipe(n int) *tokenPipe { return &tokenPipe{ch: make(chan cppToken, n)} }\n\nfunc (*tokenPipe) unget(cppToken)     { panic(\"internal error\") }\nfunc (*tokenPipe) ungets(...cppToken) { panic(\"internal error\") }\n\nfunc (p *tokenPipe) close() {\n\tif len(p.s) != 0 {\n\t\tp.flush()\n\t}\n\tclose(p.ch)\n}\n\nfunc (p *tokenPipe) flush() {\n\tp.b = p.b[:0]\n\tp.b = append(p.b, '\"')\n\tfor _, t := range p.s {\n\t\ts := dict.S(t.Val)\n\t\tp.b = append(p.b, s[1:len(s)-1]...)\n\t}\n\tp.b = append(p.b, '\"')\n\tp.s[0].Val = dict.ID(p.b)\n\tp.ch <- p.s[0]\n\tp.s = p.s[:0]\n}\n\nfunc (p *tokenPipe) read() cppToken {\n\tt, ok := <-p.ch\n\tif !ok {\n\t\tt.Rune = ccEOF\n\t}\n\treturn t\n}\n\nfunc (p *tokenPipe) write(toks ...cppToken) {\n\tfor _, t := range toks {\n\t\tswitch t.Rune {\n\t\tcase '\\n', ' ':\n\t\t\tif p.emitWhiteSpace {\n\t\t\t\tp.ch <- t\n\t\t\t}\n\t\tcase STRINGLITERAL, LONGSTRINGLITERAL:\n\t\t\tp.s = append(p.s, t)\n\t\tdefault:\n\t\t\tif len(p.s) != 0 {\n\t\t\t\tp.flush()\n\t\t\t}\n\t\t\tp.ch <- t\n\t\t}\n\t}\n}\n\ntype tokenBuffer struct {\n\ttoks0 []cppToken\n\ttoks  []cppToken\n\tungetBuffer\n\n\tlast rune\n}\n\nfunc (b *tokenBuffer) write(t ...cppToken) {\n\tb.toks = append(b.toks, t...)\n\tif b.toks0 == nil || &b.toks0[0] != &b.toks[0] {\n\t\tb.toks0 = b.toks\n\t}\n}\n\nfunc (b *tokenBuffer) read() (t cppToken) {\n\tif len(b.ungetBuffer) != 0 {\n\t\treturn b.ungetBuffer.read()\n\t}\n\n\tif len(b.toks) == 0 {\n\t\tt.Rune = ccEOF\n\t\treturn\n\t}\n\n\tt = b.toks[0]\n\tb.toks = b.toks[1:]\n\tif len(b.toks) == 0 {\n\t\tb.toks = b.toks0[:0]\n\t}\n\tif t.Rune == '#' && (b.last == '\\n' || b.last == 0) {\n\t\tt.Rune = DIRECTIVE\n\t}\n\tb.last = t.Rune\n\treturn t\n}\n\ntype cppReader struct {\n\tdecBuf []byte\n\tdecPos token.Pos\n\ttu     [][]uint32\n\tungetBuffer\n\n\tlast rune\n}\n\nfunc (c *cppReader) unget(t cppToken) { c.ungetBuffer = append(c.ungetBuffer, t) }\n\nfunc (c *cppReader) read() (t cppToken) {\n\tif len(c.ungetBuffer) != 0 {\n\t\treturn c.ungetBuffer.read()\n\t}\n\nmore:\n\tif len(c.decBuf) == 0 {\n\t\tif len(c.tu) == 0 {\n\t\t\tt.Rune = ccEOF\n\t\t\treturn t\n\t\t}\n\n\t\tif len(c.tu[0]) == 0 {\n\t\t\tc.tu = c.tu[1:]\n\t\t\tgoto more\n\t\t}\n\n\t\tc.decBuf = dict.S(int(c.tu[0][0]))\n\t\tc.tu[0] = c.tu[0][1:]\n\t\tc.decPos = 0\n\t}\n\n\tc.decBuf, c.decPos, t.Token = decodeToken(c.decBuf, c.decPos)\n\tif t.Rune == '#' && (c.last == '\\n' || c.last == 0) {\n\t\tt.Rune = DIRECTIVE\n\t}\n\tc.last = t.Rune\n\treturn t\n}\n\ntype conds []cond\n\nfunc (c conds) on() bool          { return condOn[c.tos()] }\nfunc (c conds) pop() conds        { return c[:len(c)-1] }\nfunc (c conds) push(n cond) conds { return append(c, n) }\nfunc (c conds) tos() cond         { return c[len(c)-1] }\n\n// Macro represents a preprocessor Macro.\ntype Macro struct {\n\tArgs            []int      // Numeric IDs of argument identifiers.\n\tDefTok          xc.Token   // Macro name definition token.\n\tReplacementToks []xc.Token // The tokens that replace the macro. R/O\n\n\tIsFnLike   bool // Whether the macro is function like.\n\tIsVariadic bool // Whether the macro is variadic.\n\tident      bool\n}\n\nfunc newMacro(def xc.Token, repl []xc.Token) *Macro {\n\treturn &Macro{DefTok: def, ReplacementToks: append([]xc.Token(nil), repl...)}\n}\n\n// Eval attempts to evaluate m, which must be a simple macro, like `#define foo numeric-literal`.\nfunc (m *Macro) Eval(model Model, macros map[int]*Macro) (op Operand, err error) {\n\treturned := false\n\n\tdefer func() {\n\t\te := recover()\n\t\tif !returned && err == nil {\n\t\t\terr = fmt.Errorf(\"PANIC: %v\\n%s\", e, debugStack())\n\t\t}\n\t}()\n\n\tif m.IsFnLike {\n\t\treturn op, fmt.Errorf(\"cannot evaluate function-like macro\")\n\t}\n\n\tctx, err := newContext(&Tweaks{})\n\tif err != nil {\n\t\treturn op, err\n\t}\n\n\tctx.model = model\n\tc := newCPP(ctx)\n\tc.macros = macros\n\tif op, _ = c.constExpr(cppToks(m.ReplacementToks), false); op.Type == nil {\n\t\treturn op, fmt.Errorf(\"cannot evaluate macro\")\n\t}\n\n\treturned = true\n\treturn op, nil\n}\n\nfunc (m *Macro) param(ap [][]cppToken, nm int, out *[]cppToken) bool {\n\t*out = nil\n\tif nm == idVaArgs {\n\t\tif !m.IsVariadic {\n\t\t\treturn false\n\t\t}\n\n\t\tif i := len(m.Args); i < len(ap) {\n\t\t\to := *out\n\t\t\tfor i, v := range ap[i:] {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tswitch lo := len(o); lo {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tvar t cppToken\n\t\t\t\t\t\tt.Rune = ','\n\t\t\t\t\t\tt.Val = 0\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tt := o[len(o)-1]\n\t\t\t\t\t\tt.Rune = ','\n\t\t\t\t\t\tt.Val = 0\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\t\tt.Rune = ' '\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\to = append(o, v...)\n\t\t\t}\n\t\t\t*out = o\n\t\t}\n\t\treturn true\n\t}\n\n\tif len(m.Args) != 0 && nm == m.Args[len(m.Args)-1] && m.IsVariadic && !m.ident {\n\t\tif i := len(m.Args) - 1; i < len(ap) {\n\t\t\to := *out\n\t\t\tfor i, v := range ap[i:] {\n\t\t\t\tif i != 0 {\n\t\t\t\t\tswitch lo := len(o); lo {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tvar t cppToken\n\t\t\t\t\t\tt.Rune = ','\n\t\t\t\t\t\tt.Val = 0\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tt := o[len(o)-1]\n\t\t\t\t\t\tt.Rune = ','\n\t\t\t\t\t\tt.Val = 0\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\t\tt.Rune = ' '\n\t\t\t\t\t\to = append(o, t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\to = append(o, v...)\n\t\t\t}\n\t\t\t*out = o\n\t\t}\n\t\treturn true\n\t}\n\n\tfor i, v := range m.Args {\n\t\tif v == nm {\n\t\t\t*out = ap[i]\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\ntype nullReader struct{}\n\nfunc (nullReader) Read([]byte) (int, error) { return 0, io.EOF }\n\ntype cpp struct {\n\t*context\n\tincludeLevel int\n\tlx           *lexer\n\tmacroStack   map[int][]*Macro\n\tmacros       map[int]*Macro // name ID: macro\n\ttoks         []cppToken\n}\n\nfunc newCPP(ctx *context) *cpp {\n\tlx, err := newLexer(ctx, \"\", 0, nullReader{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tlx.context = ctx\n\tr := &cpp{\n\t\tcontext:    ctx,\n\t\tlx:         lx,\n\t\tmacroStack: map[int][]*Macro{},\n\t\tmacros:     map[int]*Macro{},\n\t}\n\treturn r\n}\n\nfunc (c *cpp) parse(src ...Source) (tokenReader, error) {\n\tvar (\n\t\tencBuf  []byte\n\t\tencBuf1 [30]byte // Rune, position, optional value ID.\n\t\ttokBuf  []cppToken\n\t\ttu      [][]uint32\n\t)\n\tfor _, v := range src {\n\t\tif pf := v.Cached(); pf != nil {\n\t\t\ttu = append(tu, pf)\n\t\t\tcontinue\n\t\t}\n\n\t\tsz, err := v.Size()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif sz > mathutil.MaxInt {\n\t\t\treturn nil, fmt.Errorf(\"%v: file too big: %v\", v.Name(), sz)\n\t\t}\n\n\t\tr, err := v.ReadCloser()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tlx, err := newLexer(c.context, v.Name(), int(sz), r)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif err := func() (err error) {\n\t\t\treturned := false\n\n\t\t\tdefer func() {\n\t\t\t\te := recover()\n\t\t\t\tif !returned && err == nil {\n\t\t\t\t\terr = fmt.Errorf(\"PANIC: %v\\n%s\", e, debugStack())\n\t\t\t\t\tc.err(nopos, \"%v\", err)\n\t\t\t\t}\n\t\t\t\tif e := r.Close(); e != nil && err == nil {\n\t\t\t\t\terr = e\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tvar pf []uint32\n\t\t\tvar t cppToken\n\t\t\tvar toks []cppToken\n\t\t\tfor {\n\t\t\t\tch := lx.cppScan()\n\t\t\t\tif ch.Rune == ccEOF {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\ttokBuf = tokBuf[:0]\n\t\t\t\tfor {\n\t\t\t\t\tt.Char = ch\n\t\t\t\t\tt.Val = 0\n\t\t\t\t\tif ch.Rune == '\\n' {\n\t\t\t\t\t\ttoks = append(cppTrimSpace(tokBuf), t)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tif _, ok := tokHasVal[ch.Rune]; ok {\n\t\t\t\t\t\tt.Val = dict.ID(lx.TokenBytes(nil))\n\t\t\t\t\t}\n\t\t\t\t\ttokBuf = append(tokBuf, t)\n\n\t\t\t\t\tif ch = lx.cppScan(); ch.Rune == ccEOF {\n\t\t\t\t\t\tif !c.tweaks.InjectFinalNL {\n\t\t\t\t\t\t\tc.errPos(lx.last.Pos(), \"file is missing final newline\")\n\t\t\t\t\t\t}\n\t\t\t\t\t\tch.Rune = '\\n'\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar encPos token.Pos\n\t\t\t\tencBuf = encBuf[:0]\n\t\t\t\tfor _, t := range toks {\n\t\t\t\t\tn := binary.PutUvarint(encBuf1[:], uint64(t.Rune))\n\t\t\t\t\tpos := t.Pos()\n\t\t\t\t\tn += binary.PutUvarint(encBuf1[n:], uint64(pos-encPos))\n\t\t\t\t\tencPos = pos\n\t\t\t\t\tif t.Val != 0 {\n\t\t\t\t\t\tn += binary.PutUvarint(encBuf1[n:], uint64(t.Val))\n\t\t\t\t\t}\n\t\t\t\t\tencBuf = append(encBuf, encBuf1[:n]...)\n\t\t\t\t}\n\t\t\t\tid := dict.ID(encBuf)\n\t\t\t\tif int64(id) > math.MaxUint32 {\n\t\t\t\t\tpanic(\"internal error 4\")\n\t\t\t\t}\n\n\t\t\t\tpf = append(pf, uint32(id))\n\t\t\t}\n\t\t\tv.Cache(pf)\n\t\t\ttu = append(tu, pf)\n\t\t\treturned = true\n\t\t\treturn nil\n\t\t}(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn &cppReader{tu: tu}, nil\n}\nfunc (c *cpp) eval(r tokenReader, w tokenWriter) (err error) {\n\tc.macros[idFile] = &Macro{ReplacementToks: []xc.Token{{Char: lex.NewChar(0, STRINGLITERAL)}}}\n\tc.macros[idLineMacro] = &Macro{ReplacementToks: []xc.Token{{Char: lex.NewChar(0, INTCONST)}}}\n\tif cs := c.expand(r, w, conds(nil).push(condZero), 0, false); len(cs) != 1 || cs.tos() != condZero {\n\t\treturn fmt.Errorf(\"unexpected top of condition stack value: %v\", cs)\n\t}\n\n\treturn nil\n}\n\n// [1]pg 1.\n//\n// expand(TS ) /* recur, substitute, pushback, rescan */\n// {\n// \tif TS is {} then\n//\t\t// ---------------------------------------------------------- A\n// \t\treturn {};\n//\n// \telse if TS is T^HS • TS’ and T is in HS then\n//\t\t//----------------------------------------------------------- B\n// \t\treturn T^HS • expand(TS’);\n//\n// \telse if TS is T^HS • TS’ and T is a \"()-less macro\" then\n//\t\t// ---------------------------------------------------------- C\n// \t\treturn expand(subst(ts(T), {}, {}, HS \\cup {T}, {}) • TS’ );\n//\n// \telse if TS is T^HS •(•TS’ and T is a \"()’d macro\" then\n//\t\t// ---------------------------------------------------------- D\n// \t\tcheck TS’ is actuals • )^HS’ • TS’’ and actuals are \"correct for T\"\n// \t\treturn expand(subst(ts(T), fp(T), actuals,(HS \\cap HS’) \\cup {T }, {}) • TS’’);\n//\n//\t// ------------------------------------------------------------------ E\n// \tnote TS must be T^HS • TS’\n// \treturn T^HS • expand(TS’);\n// }\nfunc (c *cpp) expand(r tokenReader, w tokenWriter, cs conds, lvl int, expandDefined bool) conds {\n\tfor {\n\t\tt := r.read()\n\t\tswitch t.Rune {\n\t\t// First, if TS is the empty set, the result is the\n\t\t// empty set.\n\t\tcase ccEOF:\n\t\t\t// -------------------------------------------------- A\n\t\t\t// \t\treturn {};\n\t\t\treturn cs\n\t\tcase DIRECTIVE:\n\t\t\tcs = c.directive(r, w, cs)\n\t\t\tt.Rune = '\\n'\n\t\t\tt.Val = 0\n\t\t\tw.write(t)\n\t\tcase IDENTIFIER:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tnm := t.Val\n\t\t\tif nm == idDefined && expandDefined {\n\t\t\tmore:\n\t\t\t\tswitch t = r.read(); t.Rune {\n\t\t\t\tcase ccEOF:\n\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\tcase IDENTIFIER:\n\t\t\t\t\tnm := t.Val\n\t\t\t\t\tt.Rune = INTCONST\n\t\t\t\t\tt.Val = idZero\n\t\t\t\t\tif _, ok := c.macros[nm]; ok {\n\t\t\t\t\t\tt.Val = idOne\n\t\t\t\t\t}\n\t\t\t\t\tw.write(t)\n\t\t\t\t\tcontinue\n\t\t\t\tcase ' ':\n\t\t\t\t\tgoto more\n\t\t\t\tcase '(': // defined(name)\n\t\t\t\t\tvar u cppToken\n\t\t\t\t\tswitch t = r.read(); t.Rune {\n\t\t\t\t\tcase ccEOF:\n\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\tcase IDENTIFIER:\n\t\t\t\t\t\tnm := t.Val\n\t\t\t\t\t\tu = t\n\t\t\t\t\t\tu.Rune = INTCONST\n\t\t\t\t\t\tu.Val = idZero\n\t\t\t\t\t\tif _, ok := c.macros[nm]; ok {\n\t\t\t\t\t\t\tu.Val = idOne\n\t\t\t\t\t\t}\n\t\t\t\t\tmore2:\n\t\t\t\t\t\tswitch t = r.read(); t.Rune {\n\t\t\t\t\t\tcase ccEOF:\n\t\t\t\t\t\t\tpanic(\"TODO\")\n\t\t\t\t\t\tcase ' ':\n\t\t\t\t\t\t\tgoto more2\n\t\t\t\t\t\tcase ')':\n\t\t\t\t\t\t\t// ok done\n\t\t\t\t\t\t\tw.write(u)\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tpanic(t.String())\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(t.String())\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(t.String())\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Otherwise, if the token sequence begins with a token\n\t\t\t// whose hide set contains that token, then the result\n\t\t\t// is the token sequence beginning with that token\n\t\t\t// (including its hide set) followed by the result of\n\t\t\t// expand on the rest of the token sequence.\n\t\t\tif t.has(nm) {\n\t\t\t\t// ------------------------------------------ B\n\t\t\t\t// \t\treturn T^HS • expand(TS’);\n\t\t\t\tw.write(t)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tm := c.macros[nm]\n\t\t\tif m != nil && !m.IsFnLike {\n\t\t\t\t// Otherwise, if the token sequence begins with\n\t\t\t\t// an object-like macro, the result is the\n\t\t\t\t// expansion of the rest of the token sequence\n\t\t\t\t// beginning with the sequence returned by\n\t\t\t\t// subst invoked with the replacement token\n\t\t\t\t// sequence for the macro, two empty sets, the\n\t\t\t\t// union of the macro’s hide set and the macro\n\t\t\t\t// itself, and an empty set.\n\t\t\t\tswitch nm {\n\t\t\t\tcase idFile:\n\t\t\t\t\tm.ReplacementToks[0].Val = dict.SID(fmt.Sprintf(\"%q\", c.position(t).Filename))\n\t\t\t\tcase idLineMacro:\n\t\t\t\t\tm.ReplacementToks[0].Val = dict.SID(fmt.Sprint(c.position(t).Line))\n\t\t\t\t}\n\t\t\t\t// ------------------------------------------ C\n\t\t\t\t// \t\treturn expand(subst(ts(T), {}, {}, HS \\cup {T}, {}) • TS’ );\n\t\t\t\ttoks := c.subst(m, nil, t.cloneAdd(nm), expandDefined)\n\t\t\t\tfor i, v := range toks {\n\t\t\t\t\ttoks[i].Char = lex.NewChar(t.Pos(), v.Rune)\n\t\t\t\t}\n\t\t\t\tr.ungets(toks...)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif m != nil && m.IsFnLike {\n\t\t\t\t// ------------------------------------------ D\n\t\t\t\t// \t\tcheck TS’ is actuals • )^HS’ • TS’’ and actuals are \"correct for T\"\n\t\t\t\t// \t\treturn expand(subst(ts(T), fp(T), actuals,(HS \\cap HS’) \\cup {T }, {}) • TS’’);\n\t\t\t\ths := t.hs\n\t\t\tagain:\n\t\t\t\tswitch t2 := r.read(); t2.Rune {\n\t\t\t\tcase '\\n', ' ':\n\t\t\t\t\tgoto again\n\t\t\t\tcase '(':\n\t\t\t\t\t// ok\n\t\t\t\tcase ccEOF:\n\t\t\t\t\tw.write(t)\n\t\t\t\t\tcontinue\n\t\t\t\tdefault:\n\t\t\t\t\tw.write(t)\n\t\t\t\t\tw.write(t2)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tap, hs2 := c.actuals(m, r)\n\t\t\t\tswitch {\n\t\t\t\tcase len(hs2) == 0:\n\t\t\t\t\ths2 = map[int]struct{}{nm: {}}\n\t\t\t\tdefault:\n\t\t\t\t\tnhs := map[int]struct{}{}\n\t\t\t\t\tfor k := range hs {\n\t\t\t\t\t\tif _, ok := hs2[k]; ok {\n\t\t\t\t\t\t\tnhs[k] = struct{}{}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnhs[nm] = struct{}{}\n\t\t\t\t\ths2 = nhs\n\t\t\t\t}\n\t\t\t\ttoks := c.subst(m, ap, hs2, expandDefined)\n\t\t\t\tfor i, v := range toks {\n\t\t\t\t\ttoks[i].Char = lex.NewChar(t.Pos(), v.Rune)\n\t\t\t\t}\n\t\t\t\tr.ungets(toks...)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tw.write(t)\n\t\tdefault:\n\t\t\t// -------------------------------------------------- E\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tw.write(t)\n\t\t}\n\t}\n}\n\nfunc (c *cpp) pragmaActuals(nd Node, line []cppToken) (out []cppToken) {\n\tfirst := true\n\tfor {\n\t\tif len(line) == 0 {\n\t\t\tc.err(nd, \"unexpected EOF\")\n\t\t\treturn nil\n\t\t}\n\n\t\tt := line[0]\n\t\tline = line[1:]\n\t\tswitch t.Rune {\n\t\tcase '(':\n\t\t\tif !first {\n\t\t\t\tpanic(fmt.Errorf(\"%v\", t))\n\t\t\t}\n\n\t\t\tfirst = false\n\t\tcase STRINGLITERAL:\n\t\t\tout = append(out, t)\n\t\tcase ')':\n\t\t\treturn out\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v (%v)\", c.position(t), t, yySymName(int(t.Rune))))\n\t\t}\n\t}\n}\n\nfunc (c *cpp) actuals(m *Macro, r tokenReader) (out [][]cppToken, hs map[int]struct{}) {\n\tvar lvl, n int\n\tfor {\n\t\tt := r.read()\n\t\tif t.Rune < 0 {\n\t\t\tc.err(t, \"unexpected EOF\")\n\t\t\treturn nil, nil\n\t\t}\n\n\t\tswitch t.Rune {\n\t\tcase ',':\n\t\t\tif lvl == 0 {\n\t\t\t\tn++\n\t\t\t\tcontinue\n\t\t\t}\n\t\tcase ')':\n\t\t\tif lvl == 0 {\n\t\t\t\tfor i, v := range out {\n\t\t\t\t\tout[i] = cppTrimSpace(v)\n\t\t\t\t}\n\t\t\t\tfor len(out) < len(m.Args) {\n\t\t\t\t\tout = append(out, nil)\n\t\t\t\t}\n\t\t\t\treturn out, t.hs\n\t\t\t}\n\n\t\t\tlvl--\n\t\tcase '(':\n\t\t\tlvl++\n\t\t}\n\n\t\tfor len(out) <= n {\n\t\t\tout = append(out, []cppToken{})\n\t\t}\n\t\tif t.Rune == '\\n' {\n\t\t\tt.Rune = ' '\n\t\t}\n\t\tout[n] = append(out[n], t)\n\t}\n}\n\nfunc (c *cpp) expands(toks []cppToken, expandDefined bool) (out []cppToken) {\n\tvar r, w tokenBuffer\n\tr.toks = toks\n\tc.expand(&r, &w, conds(nil).push(condZero), 1, expandDefined)\n\treturn w.toks\n}\n\n// [1]pg 2.\n//\n// subst(IS, FP, AP, HS, OS) /* substitute args, handle stringize and paste */\n// {\n// \tif IS is {} then\n//\t\t// ---------------------------------------------------------- A\n// \t\treturn hsadd(HS, OS);\n//\n// \telse if IS is # • T • IS’ and T is FP[i] then\n//\t\t// ---------------------------------------------------------- B\n// \t\treturn subst(IS’, FP, AP, HS, OS • stringize(select(i, AP)));\n//\n// \telse if IS is ## • T • IS’ and T is FP[i] then\n//\t{\n//\t\t// ---------------------------------------------------------- C\n// \t\tif select(i, AP) is {} then /* only if actuals can be empty */\n//\t\t\t// -------------------------------------------------- D\n// \t\t\treturn subst(IS’, FP, AP, HS, OS);\n// \t\telse\n//\t\t\t// -------------------------------------------------- E\n// \t\t\treturn subst(IS’, FP, AP, HS, glue(OS, select(i, AP)));\n// \t}\n//\n// \telse if IS is ## • T^HS’ • IS’ then\n//\t\t// ---------------------------------------------------------- F\n// \t\treturn subst(IS’, FP, AP, HS, glue(OS, T^HS’));\n//\n// \telse if IS is T • ##^HS’ • IS’ and T is FP[i] then\n//\t{\n//\t\t// ---------------------------------------------------------- G\n// \t\tif select(i, AP) is {} then /* only if actuals can be empty */\n//\t\t{\n//\t\t\t// -------------------------------------------------- H\n// \t\t\tif IS’ is T’ • IS’’ and T’ is FP[j] then\n//\t\t\t\t// ------------------------------------------ I\n// \t\t\t\treturn subst(IS’’, FP, AP, HS, OS • select(j, AP));\n// \t\t\telse\n//\t\t\t\t// ------------------------------------------ J\n// \t\t\t\treturn subst(IS’, FP, AP, HS, OS);\n// \t\t}\n//\t\telse\n//\t\t\t// -------------------------------------------------- K\n// \t\t\treturn subst(##^HS’ • IS’, FP, AP, HS, OS • select(i, AP));\n//\n//\t}\n//\n// \telse if IS is T • IS’ and T is FP[i] then\n//\t\t// ---------------------------------------------------------- L\n// \t\treturn subst(IS’, FP, AP, HS, OS • expand(select(i, AP)));\n//\n//\t// ------------------------------------------------------------------ M\n// \tnote IS must be T^HS’ • IS’\n// \treturn subst(IS’, FP, AP, HS, OS • T^HS’);\n// }\n//\n// A quick overview of subst is that it walks through the input sequence, IS,\n// building up an output sequence, OS, by handling each token from left to\n// right. (The order that this operation takes is left to the implementation\n// also, walking from left to right is more natural since the rest of the\n// algorithm is constrained to this ordering.) Stringizing is easy, pasting\n// requires trickier handling because the operation has a bunch of\n// combinations. After the entire input sequence is finished, the updated hide\n// set is applied to the output sequence, and that is the result of subst.\nfunc (c *cpp) subst(m *Macro, ap [][]cppToken, hs map[int]struct{}, expandDefined bool) (out []cppToken) {\n\t// dbg(\"%s %v %v\", m.def.S(), m.variadic, ap)\n\trepl := cppToks(m.ReplacementToks)\n\tvar arg []cppToken\n\tfor {\n\t\tif len(repl) == 0 {\n\t\t\t// -------------------------------------------------- A\n\t\t\t// \t\treturn hsadd(HS, OS);\n\t\t\tout := cppTrimSpace(out)\n\t\t\tfor i := range out {\n\t\t\t\tout[i].hsAdd(hs)\n\t\t\t}\n\t\t\treturn out\n\t\t}\n\n\t\tif repl[0].Rune == '#' && len(repl) > 1 && repl[1].Rune == IDENTIFIER && m.param(ap, repl[1].Val, &arg) {\n\t\t\t// -------------------------------------------------- B\n\t\t\t// \t\treturn subst(IS’, FP, AP, HS, OS • stringize(select(i, AP)));\n\t\t\tout = append(out, c.stringize(arg))\n\t\t\trepl = repl[2:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == '#' && len(repl) > 2 && repl[1].Rune == ' ' && repl[2].Rune == IDENTIFIER && m.param(ap, repl[2].Val, &arg) {\n\t\t\t// -------------------------------------------------- B\n\t\t\t// \t\treturn subst(IS’, FP, AP, HS, OS • stringize(select(i, AP)));\n\t\t\tout = append(out, c.stringize(arg))\n\t\t\trepl = repl[3:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == PPPASTE && len(repl) > 1 && repl[1].Rune == IDENTIFIER && m.param(ap, repl[1].Val, &arg) {\n\t\t\t// -------------------------------------------------- C\n\t\t\tif len(arg) == 0 {\n\t\t\t\t// ------------------------------------------ D\n\t\t\t\t// \t\t\treturn subst(IS’, FP, AP, HS, OS);\n\t\t\t\trepl = repl[2:]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// -------------------------------------------------- E\n\t\t\t// \t\t\treturn subst(IS’, FP, AP, HS, glue(OS, select(i, AP)));\n\t\t\t_, out = c.glue(out, arg)\n\t\t\trepl = repl[2:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == PPPASTE && len(repl) > 2 && repl[1].Rune == ' ' && repl[2].Rune == IDENTIFIER && m.param(ap, repl[2].Val, &arg) {\n\t\t\t// -------------------------------------------------- C\n\t\t\tif len(arg) == 0 {\n\t\t\t\t// ------------------------------------------ D\n\t\t\t\t// \t\t\treturn subst(IS’, FP, AP, HS, OS);\n\t\t\t\trepl = repl[3:]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// -------------------------------------------------- E\n\t\t\t// \t\t\treturn subst(IS’, FP, AP, HS, glue(OS, select(i, AP)));\n\t\t\t_, out = c.glue(out, arg)\n\t\t\trepl = repl[3:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == PPPASTE && len(repl) > 1 && repl[1].Rune != ' ' {\n\t\t\t// -------------------------------------------------- F\n\t\t\t// \t\treturn subst(IS’, FP, AP, HS, glue(OS, T^HS’));\n\t\t\t_, out = c.glue(out, repl[1:2])\n\t\t\trepl = repl[2:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == PPPASTE && len(repl) > 2 && repl[1].Rune == ' ' {\n\t\t\t// -------------------------------------------------- F\n\t\t\t// \t\treturn subst(IS’, FP, AP, HS, glue(OS, T^HS’));\n\t\t\t_, out = c.glue(out, repl[2:3])\n\t\t\trepl = repl[3:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(repl) > 1 && repl[0].Rune == IDENTIFIER && m.param(ap, repl[0].Val, &arg) && repl[1].Rune == PPPASTE {\n\t\t\t// -------------------------------------------------- G\n\t\t\tif len(arg) == 0 {\n\t\t\t\t// ------------------------------------------ H\n\t\t\t\tpanic(c.position(repl[0]))\n\t\t\t}\n\n\t\t\t// -------------------------------------------------- K\n\t\t\t// \t\t\treturn subst(##^HS’ • IS’, FP, AP, HS, OS • select(i, AP));\n\t\t\tout = append(out, arg...)\n\t\t\trepl = repl[1:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif len(repl) > 2 && repl[0].Rune == IDENTIFIER && m.param(ap, repl[0].Val, &arg) && repl[1].Rune == ' ' && repl[2].Rune == PPPASTE {\n\t\t\t// -------------------------------------------------- G\n\t\t\tif len(arg) == 0 {\n\t\t\t\t// ------------------------------------------ H\n\t\t\t\tif len(repl) > 3 && repl[3].Rune == IDENTIFIER && m.param(ap, repl[3].Val, &arg) {\n\t\t\t\t\t// ---------------------------------- I\n\t\t\t\t\tpanic(c.position(repl[0]))\n\t\t\t\t}\n\n\t\t\t\t// ------------------------------------------ J\n\t\t\t\t// \t\t\t\treturn subst(IS’, FP, AP, HS, OS);\n\t\t\t\trepl = repl[3:]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// -------------------------------------------------- K\n\t\t\t// \t\t\treturn subst(##^HS’ • IS’, FP, AP, HS, OS • select(i, AP));\n\t\t\tout = append(out, arg...)\n\t\t\trepl = repl[2:]\n\t\t\tcontinue\n\t\t}\n\n\t\tif repl[0].Rune == IDENTIFIER && m.param(ap, repl[0].Val, &arg) {\n\t\t\t// -------------------------------------------------- L\n\t\t\t// \t\treturn subst(IS’, FP, AP, HS, OS • expand(select(i, AP)));\n\t\t\tout = append(out, c.expands(arg, expandDefined)...)\n\t\t\trepl = repl[1:]\n\t\t\tcontinue\n\t\t}\n\n\t\t// ---------------------------------------------------------- M\n\t\t// \tnote IS must be T^HS’ • IS’\n\t\t// \treturn subst(IS’, FP, AP, HS, OS • T^HS’);\n\t\tout = append(out, repl[0])\n\t\trepl = repl[1:]\n\t}\n}\n\n// paste last of left side with first of right side\n//\n// [1] pg. 3\nfunc (c *cpp) glue(ls, rs []cppToken) (n int, out []cppToken) {\n\tfor len(ls) != 0 && ls[len(ls)-1].Rune == ' ' {\n\t\tls = ls[:len(ls)-1]\n\t}\n\n\tfor len(rs) != 0 && rs[0].Rune == ' ' {\n\t\trs = rs[1:]\n\t\tn++\n\t}\n\tif len(rs) == 0 {\n\t\tpanic(\"TODO\")\n\t}\n\n\tif len(ls) == 0 {\n\t\treturn n, rs\n\t}\n\n\tl := ls[len(ls)-1]\n\tls = ls[:len(ls)-1]\n\tr := rs[0]\n\trs = rs[1:]\n\tn++\n\n\tswitch l.Rune {\n\tcase '#':\n\t\tswitch r.Rune {\n\t\tcase '#':\n\t\t\tl.Rune = PPPASTE\n\t\tdefault:\n\t\t\tpanic(PrettyString([]cppToken{l, r}))\n\t\t}\n\tdefault:\n\t\tswitch l.Rune {\n\t\tcase STRINGLITERAL:\n\t\t\ts := TokSrc(l.Token)\n\t\t\tif len(s) > 2 && s[0] == '\"' && s[len(s)-1] == '\"' {\n\t\t\t\ts = s[1 : len(s)-1]\n\t\t\t}\n\t\t\tl.Val = dict.SID(s + TokSrc(r.Token))\n\t\tdefault:\n\t\t\tl.Val = dict.SID(TokSrc(l.Token) + TokSrc(r.Token))\n\t\t}\n\t}\n\treturn n, append(append(ls, l), rs...)\n}\n\n// Given a token sequence, stringize returns a single string literal token\n// containing the concatenated spellings of the tokens.\n//\n// [1] pg. 3\nfunc (c *cpp) stringize(s []cppToken) cppToken {\n\tvar a []string\n\tfor _, v := range s {\n\t\tswitch v.Rune {\n\t\tcase CHARCONST, LONGCHARCONST, LONGSTRINGLITERAL, STRINGLITERAL:\n\t\t\ts := fmt.Sprintf(\"%q\", TokSrc(v.Token))\n\t\t\ta = append(a, s[1:len(s)-1])\n\t\tdefault:\n\t\t\ta = append(a, TokSrc(v.Token))\n\t\t}\n\t}\n\tif v := dict.SID(fmt.Sprintf(`\"%s\"`, strings.Join(a, \"\"))); v != 0 {\n\t\tvar t cppToken\n\t\tif len(s) != 0 {\n\t\t\tt = s[0]\n\t\t}\n\t\tt.Rune = STRINGLITERAL\n\t\tt.Val = v\n\t\treturn t\n\t}\n\n\treturn cppToken{}\n}\n\nfunc (c *cpp) directive(r tokenReader, w tokenWriter, cs conds) (y conds) {\n\tline := c.line(r)\n\tif len(line) == 0 {\n\t\treturn cs\n\t}\n\n\tif cs.on() {\n\t\tif f := c.tweaks.TrackExpand; f != nil && c.tweaks.DefinesOnly {\n\t\t\tif s := cppToksDump(line, \"\"); strings.HasPrefix(s, \"define\") {\n\t\t\t\tf(fmt.Sprintf(\"#%s\", cppToksDump(line, \"\")))\n\t\t\t}\n\t\t}\n\t}\n\nouter:\n\tswitch t := line[0]; t.Rune {\n\tcase ccEOF:\n\t\t// nop\n\tcase IDENTIFIER:\n\t\tswitch t.Val {\n\t\tcase idDefine:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif len(line) == 1 {\n\t\t\t\tc.err(t, \"empty define not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tc.define(line[1:])\n\t\tcase idElif:\n\t\t\tswitch cs.tos() {\n\t\t\tcase condIfOff:\n\t\t\t\tif _, ok := c.constExpr(line[1:], true); ok {\n\t\t\t\t\treturn cs.pop().push(condIfOn)\n\t\t\t\t}\n\t\t\tcase condIfOn:\n\t\t\t\treturn cs.pop().push(condIfSkip)\n\t\t\tcase condIfSkip:\n\t\t\t\t// nop\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", c.position(t), cs.tos()))\n\t\t\t}\n\t\tcase idElse:\n\t\t\tswitch cs.tos() {\n\t\t\tcase condIfOff:\n\t\t\t\treturn cs.pop().push(condIfOn)\n\t\t\tcase condIfOn:\n\t\t\t\treturn cs.pop().push(condIfOff)\n\t\t\tcase condIfSkip:\n\t\t\t\t// nop\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", c.position(t), cs.tos()))\n\t\t\t}\n\t\tcase idError:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tc.err(t, \"%s\", cppToksDump(line, \"\"))\n\t\tcase idIf:\n\t\t\tif !cs.on() {\n\t\t\t\treturn cs.push(condIfSkip)\n\t\t\t}\n\n\t\t\tswitch _, ok := c.constExpr(line[1:], true); {\n\t\t\tcase ok:\n\t\t\t\treturn cs.push(condIfOn)\n\t\t\tdefault:\n\t\t\t\treturn cs.push(condIfOff)\n\t\t\t}\n\t\tcase idIfdef:\n\t\t\tif !cs.on() {\n\t\t\t\treturn cs.push(condIfSkip)\n\t\t\t}\n\n\t\t\tline = cppTrimAllSpace(line[1:])\n\t\t\tif len(line) == 0 {\n\t\t\t\tc.err(t, \"empty #ifdef not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif len(line) > 1 {\n\t\t\t\tc.err(t, \"extra tokens after #ifdef not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif line[0].Rune != IDENTIFIER {\n\t\t\t\tc.err(line[0], \"expected identifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif _, ok := c.macros[line[0].Val]; ok {\n\t\t\t\treturn cs.push(condIfOn)\n\t\t\t}\n\n\t\t\treturn cs.push(condIfOff)\n\t\tcase idIfndef:\n\t\t\tif !cs.on() {\n\t\t\t\treturn cs.push(condIfSkip)\n\t\t\t}\n\n\t\t\tline = cppTrimAllSpace(line[1:])\n\t\t\tif len(line) == 0 {\n\t\t\t\tc.err(t, \"empty #ifndef not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif len(line) > 1 {\n\t\t\t\tc.err(t, \"extra tokens after #ifndef not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif line[0].Rune != IDENTIFIER {\n\t\t\t\tc.err(line[0], \"expected identifier\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tif _, ok := c.macros[line[0].Val]; ok {\n\t\t\t\treturn cs.push(condIfOff)\n\t\t\t}\n\n\t\t\treturn cs.push(condIfOn)\n\t\tcase\n\t\t\tidIncludeNext,\n\t\t\tidInclude:\n\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tline = cppTrimAllSpace(line[1:])\n\t\t\tif len(line) == 0 {\n\t\t\t\tc.err(t, \"empty include not allowed\")\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\texpanded := false\n\t\tagain:\n\t\t\tswitch line[0].Rune {\n\t\t\tcase '<':\n\t\t\t\tif c.tweaks.cppExpandTest {\n\t\t\t\t\tw.write(line...)\n\t\t\t\t\treturn cs\n\t\t\t\t}\n\n\t\t\t\tvar nm string\n\t\t\t\tfor _, v := range line[1:] {\n\t\t\t\t\tif v.Rune == '>' {\n\t\t\t\t\t\tc.include(t, nm, c.sysIncludePaths, w)\n\t\t\t\t\t\treturn cs\n\t\t\t\t\t}\n\n\t\t\t\t\tnm += TokSrc(v.Token)\n\t\t\t\t}\n\t\t\t\tc.err(t, \"invalid include file name specification\")\n\t\t\tcase STRINGLITERAL:\n\t\t\t\tif c.tweaks.cppExpandTest {\n\t\t\t\t\tw.write(line...)\n\t\t\t\t\treturn cs\n\t\t\t\t}\n\n\t\t\t\tb := dict.S(line[0].Val)      // `\"foo.h\"`\n\t\t\t\tnm := string(b[1 : len(b)-1]) // `foo.h`\n\t\t\t\tc.include(t, nm, c.includePaths, w)\n\t\t\t\treturn cs\n\t\t\tdefault:\n\t\t\t\tif expanded {\n\t\t\t\t\tpanic(PrettyString(line))\n\t\t\t\t}\n\n\t\t\t\tline = c.expands(cppTrimAllSpace(line), false)\n\t\t\t\texpanded = true\n\t\t\t\tif c.tweaks.cppExpandTest {\n\t\t\t\t\tw.write(line...)\n\t\t\t\t\treturn cs\n\t\t\t\t}\n\n\t\t\t\tgoto again\n\t\t\t}\n\t\tcase idEndif:\n\t\t\tswitch cs.tos() {\n\t\t\tcase condIfOn, condIfOff, condIfSkip:\n\t\t\t\treturn cs.pop()\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", c.position(t), cs.tos()))\n\t\t\t}\n\t\tcase idLine:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tf := fset.File(line[0].Pos())\n\t\t\toff := f.Offset(line[0].Pos())\n\t\t\tpos := c.position(line[0])\n\t\t\tline = c.expands(cppTrimAllSpace(line[1:]), false)\n\t\t\tswitch len(line) {\n\t\t\tcase 1: // #line linenum\n\t\t\t\tn, err := strconv.ParseUint(string(line[0].S()), 10, 31)\n\t\t\t\tif err != nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tf.AddLineInfo(off, pos.Filename, int(n-1))\n\t\t\t\t//TODO\n\t\t\tcase 2: // #line linenum filename\n\t\t\t\t//TODO\n\t\t\tdefault:\n\t\t\t\t// ignore\n\t\t\t}\n\n\t\t\t// ignored\n\t\tcase idPragma:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tfor {\n\t\t\t\tline = line[1:]\n\t\t\t\tif len(line) == 0 {\n\t\t\t\t\tpanic(fmt.Errorf(\"%v\", c.position(t)))\n\t\t\t\t}\n\n\t\t\t\tswitch t = line[0]; {\n\t\t\t\tcase t.Rune == ' ':\n\t\t\t\t\t// nop\n\t\t\t\tcase t.Val == idPushMacro:\n\t\t\t\t\tactuals := c.pragmaActuals(t, line[1:])\n\t\t\t\t\tif len(actuals) != 1 {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v\", c.position(t)))\n\t\t\t\t\t}\n\n\t\t\t\t\tt := actuals[0]\n\t\t\t\t\tswitch t.Rune {\n\t\t\t\t\tcase STRINGLITERAL:\n\t\t\t\t\t\tnm := int(c.strConst(t.Token).Value.(*ir.StringValue).StringID)\n\t\t\t\t\t\tm := c.macros[nm]\n\t\t\t\t\t\tif m != nil {\n\t\t\t\t\t\t\tc.macroStack[nm] = append(c.macroStack[nm], m)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak outer\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", c.position(t), yySymName(int(actuals[0].Rune))))\n\t\t\t\t\t}\n\t\t\t\tcase t.Val == idPopMacro:\n\t\t\t\t\tactuals := c.pragmaActuals(t, line[1:])\n\t\t\t\t\tif len(actuals) != 1 {\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v\", c.position(t)))\n\t\t\t\t\t}\n\n\t\t\t\t\tt := actuals[0]\n\t\t\t\t\tswitch t.Rune {\n\t\t\t\t\tcase STRINGLITERAL:\n\t\t\t\t\t\tnm := int(c.strConst(t.Token).Value.(*ir.StringValue).StringID)\n\t\t\t\t\t\ts := c.macroStack[nm]\n\t\t\t\t\t\tif n := len(s); n != 0 {\n\t\t\t\t\t\t\tm := s[n-1]\n\t\t\t\t\t\t\ts = s[:n-1]\n\t\t\t\t\t\t\tc.macroStack[nm] = s\n\t\t\t\t\t\t\tc.macros[nm] = m\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak outer\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpanic(fmt.Errorf(\"%v: %v\", c.position(t), yySymName(int(actuals[0].Rune))))\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tif c.tweaks.IgnoreUnknownPragmas {\n\t\t\t\t\t\tbreak outer\n\t\t\t\t\t}\n\n\t\t\t\t\tpanic(fmt.Errorf(\"%v: %#x, %v\", c.position(t), t.Rune, t))\n\t\t\t\t}\n\t\t\t}\n\t\tcase idUndef:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tline = cppTrimSpace(line[1:])\n\t\t\tif len(line) == 0 {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tif len(line) > 1 {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tif line[0].Rune != IDENTIFIER {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tdelete(c.macros, line[0].Val)\n\t\tcase idWarning:\n\t\t\tif !cs.on() {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tpanic(fmt.Errorf(\"%v\", c.position(t)))\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v %v\", c.position(t), PrettyString(t)))\n\t\t}\n\tdefault:\n\t\tpanic(PrettyString(t))\n\t}\n\treturn cs\n}\n\nfunc (c *cpp) include(n Node, nm string, paths []string, w tokenWriter) {\n\tif c.includeLevel == maxIncludeLevel {\n\t\tc.err(n, \"too many include levels\")\n\t}\n\n\tc.includeLevel++\n\n\tdefer func() { c.includeLevel-- }()\n\n\tdir := filepath.Dir(c.position(n).Filename)\n\tif d, err := filepath.Abs(dir); err == nil {\n\t\tdir = d\n\t}\n\tvar path string\n\tif n.(cppToken).Val == idIncludeNext {\n\t\tnmDir, _ := filepath.Split(nm)\n\t\tfor i, v := range paths {\n\t\t\tif w, err := filepath.Abs(v); err == nil {\n\t\t\t\tv = w\n\t\t\t}\n\t\t\tv = filepath.Join(v, nmDir)\n\t\t\tif v == dir {\n\t\t\t\tpaths = paths[i+1:]\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tfor _, v := range paths {\n\t\tif v == \"@\" {\n\t\t\tv = dir\n\t\t}\n\n\t\tvar p string\n\t\tswitch {\n\t\tcase strings.HasPrefix(nm, \"./\"):\n\t\t\tp = nm\n\t\tdefault:\n\t\t\tp = filepath.Join(v, nm)\n\t\t}\n\t\tfi, err := os.Stat(p)\n\t\tif err != nil || fi.IsDir() {\n\t\t\tcontinue\n\t\t}\n\n\t\tpath = p\n\t\tbreak\n\t}\n\n\tif path == \"\" {\n\t\twd, _ := os.Getwd()\n\t\tc.err(n, \"include file not found: %s\\nworking dir: %s\\nsearch paths:\\n\\t%s\", nm, wd, strings.Join(paths, \"\\n\\t\"))\n\t\treturn\n\t}\n\n\ts, err := NewFileSource2(path, true)\n\tif err != nil {\n\t\tc.err(n, \"%s\", err.Error())\n\t\treturn\n\t}\n\n\tif n, _ := s.Size(); n == 0 {\n\t\treturn\n\t}\n\n\tif f := c.tweaks.TrackIncludes; f != nil {\n\t\tf(path)\n\t}\n\tr, err := c.parse(s)\n\tif err != nil {\n\t\tc.err(n, \"%s\", err.Error())\n\t}\n\n\tc.expand(r, w, conds(nil).push(condZero), 0, false)\n}\n\nfunc (c *cpp) constExpr(toks []cppToken, expandDefined bool) (op Operand, y bool) {\n\ttoks = cppTrimAllSpace(c.expands(cppTrimAllSpace(toks), expandDefined))\n\tfor i, v := range toks {\n\t\tif v.Rune == IDENTIFIER {\n\t\t\ttoks[i].Rune = INTCONST\n\t\t\ttoks[i].Val = idZero\n\t\t}\n\t}\n\tc.lx.ungetBuffer = c.lx.ungetBuffer[:0]\n\tc.lx.ungets(toks...)\n\tif !c.lx.parseExpr() {\n\t\treturn Operand{}, false\n\t}\n\n\te := c.lx.ast.(*ConstExpr)\n\tv := e.eval(c.context)\n\tif v.Type != Int {\n\t\treturn v, false\n\t}\n\n\tswitch x := v.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn v, x.Value != 0\n\tdefault:\n\t\treturn v, false\n\t}\n}\n\nfunc (c *cpp) define(line []cppToken) {\n\tswitch line[0].Rune {\n\tcase ' ':\n\t\tc.defineMacro(xcToks(line[1:]))\n\tdefault:\n\t\tpanic(PrettyString(line))\n\t}\n}\n\nfunc (c *cpp) defineMacro(line []xc.Token) {\n\tif len(line) == 0 {\n\t\tpanic(\"internal error\")\n\t}\n\n\tif line[0].Rune == ' ' {\n\t\tline = line[1:]\n\t}\n\n\tswitch t := line[0]; t.Rune {\n\tcase IDENTIFIER:\n\t\tnm := t.Val\n\t\tif protectedMacro[nm] {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tline := line[1:]\n\t\tvar repl []xc.Token\n\t\tif len(line) != 0 {\n\t\t\tswitch line[0].Rune {\n\t\t\tcase '\\n', ccEOF:\n\t\t\t\t// nop\n\t\t\tcase ' ':\n\t\t\t\trepl = line[1:]\n\t\t\tcase '(':\n\t\t\t\tc.defineFnMacro(t, line[1:])\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(PrettyString(line[0])))\n\t\t\t}\n\t\t}\n\n\t\tif ex := c.macros[nm]; ex != nil {\n\t\t\tif c.identicalReplacementLists(repl, ex.ReplacementToks) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tc.err(t, \"%q replacement lists differ: %q, %q\", dict.S(nm), toksDump(ex.ReplacementToks, \"\"), toksDump(repl, \"\"))\n\t\t\treturn\n\t\t}\n\n\t\tif traceMacroDefs {\n\t\t\tfmt.Fprintf(os.Stderr, \"#define %s %s\\n\", dict.S(nm), toksDump(repl, \"\"))\n\t\t}\n\t\tc.macros[nm] = newMacro(t, repl)\n\tdefault:\n\t\tpanic(PrettyString(t))\n\t}\n}\n\nfunc (c *cpp) identicalReplacementLists(a, b []xc.Token) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\tfor i, v := range a {\n\t\tw := b[i]\n\t\tif v.Rune != w.Rune || v.Val != w.Val {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc (c *cpp) defineFnMacro(nmTok xc.Token, line []xc.Token) {\n\tident := true\n\tvar params []int\n\tvariadic := false\n\tfor i, v := range line {\n\t\tswitch v.Rune {\n\t\tcase IDENTIFIER:\n\t\t\tif !ident {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tparams = append(params, v.Val)\n\t\t\tident = false\n\t\tcase ')':\n\t\t\tm := newMacro(nmTok, trimSpace(line[i+1:]))\n\t\t\tm.IsFnLike = true\n\t\t\tm.ident = ident\n\t\t\tm.IsVariadic = variadic\n\t\t\tm.Args = params\n\t\t\tif ex := c.macros[nmTok.Val]; ex != nil {\n\t\t\t\tif c.identicalParamLists(params, ex.Args) && c.identicalReplacementLists(m.ReplacementToks, ex.ReplacementToks) && m.IsVariadic == ex.IsVariadic {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tc.err(nmTok, \"parameter and/or replacement lists differ\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif traceMacroDefs {\n\t\t\t\tvar a [][]byte\n\t\t\t\tfor _, v := range m.Args {\n\t\t\t\t\ta = append(a, dict.S(v))\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(os.Stderr, \"#define %s(%s) %s\\n\", dict.S(nmTok.Val), bytes.Join(a, []byte(\", \")), toksDump(m.ReplacementToks, \"\"))\n\t\t\t}\n\t\t\tc.macros[nmTok.Val] = m\n\t\t\treturn\n\t\tcase ',':\n\t\t\tif ident {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tident = true\n\t\tcase ' ':\n\t\t\t// nop\n\t\tcase DDD:\n\t\t\tvariadic = true\n\t\tdefault:\n\t\t\tpanic(PrettyString(v))\n\t\t}\n\t}\n}\n\nfunc (c *cpp) identicalParamLists(a, b []int) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\n\tfor i, v := range a {\n\t\tif v != b[i] {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}\n\nfunc (c *cpp) line(r tokenReader) []cppToken {\n\tc.toks = c.toks[:0]\n\tfor {\n\t\tswitch t := r.read(); t.Rune {\n\t\tcase '\\n', ccEOF:\n\t\t\tif len(c.toks) == 0 || c.toks[0].Rune != ' ' {\n\t\t\t\treturn c.toks\n\t\t\t}\n\n\t\t\tfor i, v := range c.toks {\n\t\t\t\tif v.Rune != ' ' {\n\t\t\t\t\tn := copy(c.toks, c.toks[i:])\n\t\t\t\t\tc.toks = c.toks[:n]\n\t\t\t\t\treturn c.toks\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tc.toks = c.toks[:0]\n\t\t\treturn c.toks\n\t\tdefault:\n\t\t\tc.toks = append(c.toks, t)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "v2/encoding.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"encoding/binary\"\n\t\"go/token\"\n\t\"reflect\"\n\t\"strconv\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\tdict       = xc.Dict\n\tprintHooks = strutil.PrettyPrintHooks{}\n)\n\nfunc init() {\n\tfor k, v := range xc.PrintHooks {\n\t\tprintHooks[k] = v\n\t}\n\tdelete(printHooks, reflect.TypeOf(token.Pos(0)))\n\tlcRT := reflect.TypeOf(lex.Char{})\n\tlcH := func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tc := v.(lex.Char)\n\t\tr := c.Rune\n\t\ts := yySymName(int(r))\n\t\tif x := s[0]; x >= '0' && x <= '9' {\n\t\t\ts = strconv.QuoteRune(r)\n\t\t}\n\t\tf.Format(prefix)\n\t\tf.Format(\"%s\", s)\n\t\tf.Format(suffix)\n\t}\n\n\tprintHooks[lcRT] = lcH\n\tprintHooks[reflect.TypeOf(xc.Token{})] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\tt := v.(xc.Token)\n\t\tif (t == xc.Token{}) {\n\t\t\treturn\n\t\t}\n\n\t\tlcH(f, t.Char, prefix, \"\")\n\t\tif s := t.S(); len(s) != 0 {\n\t\t\tf.Format(\" %q\", s)\n\t\t}\n\t\tf.Format(suffix)\n\t}\n\tfor _, v := range []interface{}{\n\t\t(*ir.Float32Value)(nil),\n\t\t(*ir.Float64Value)(nil),\n\t\t(*ir.Int32Value)(nil),\n\t\t(*ir.Int64Value)(nil),\n\t\t(*ir.StringValue)(nil),\n\t\tDirectDeclaratorCase(0),\n\t\tExprCase(0),\n\t\tLinkage(0),\n\t\tStorageDuration(0),\n\t\tTypeKind(0),\n\t\tir.Linkage(0),\n\t} {\n\t\tprintHooks[reflect.TypeOf(v)] = func(f strutil.Formatter, v interface{}, prefix, suffix string) {\n\t\t\tf.Format(prefix)\n\t\t\tf.Format(\"%v\", v)\n\t\t\tf.Format(suffix)\n\t\t}\n\t}\n}\n\nvar (\n\tnopos xc.Token\n\n\t// Null pointer, [0]6.3.2.3-3.\n\tNull = &ir.AddressValue{}\n\n\tidAsm                    = dict.SID(\"asm\")\n\tidAttribute              = dict.SID(\"__attribute__\")\n\tidBuiltinAlloca          = dict.SID(\"__builtin_alloca\")\n\tidBuiltinClasifyType     = dict.SID(\"__builtin_classify_type\")\n\tidBuiltinTypesCompatible = dict.SID(\"__builtin_types_compatible__\") // Implements __builtin_types_compatible_p\n\tidBuiltinVaList          = dict.SID(\"__builtin_va_list\")\n\tidChar                   = dict.SID(\"char\")\n\tidConst                  = dict.SID(\"const\")\n\tidDefine                 = dict.SID(\"define\")\n\tidDefined                = dict.SID(\"defined\")\n\tidElif                   = dict.SID(\"elif\")\n\tidElse                   = dict.SID(\"else\")\n\tidEndif                  = dict.SID(\"endif\")\n\tidError                  = dict.SID(\"error\")\n\tidFile                   = dict.SID(\"__FILE__\")\n\tidFuncName               = dict.SID(\"__func__\")\n\tidIf                     = dict.SID(\"if\")\n\tidIfdef                  = dict.SID(\"ifdef\")\n\tidIfndef                 = dict.SID(\"ifndef\")\n\tidInclude                = dict.SID(\"include\")\n\tidIncludeNext            = dict.SID(\"include_next\")\n\tidLine                   = dict.SID(\"line\")\n\tidLineMacro              = dict.SID(\"__LINE__\")\n\tidMain                   = dict.SID(\"main\")\n\tidOne                    = dict.SID(\"1\")\n\tidPopMacro               = dict.SID(\"pop_macro\")\n\tidPragma                 = dict.SID(\"pragma\")\n\tidPtrdiffT               = dict.SID(\"ptrdiff_t\")\n\tidPushMacro              = dict.SID(\"push_macro\")\n\tidSizeT                  = dict.SID(\"size_t\")\n\tidStatic                 = dict.SID(\"static\")\n\tidUndef                  = dict.SID(\"undef\")\n\tidVaArgs                 = dict.SID(\"__VA_ARGS__\")\n\tidVaList                 = dict.SID(\"va_list\")\n\tidWarning                = dict.SID(\"warning\")\n\tidWcharT                 = dict.SID(\"wchar_t\")\n\tidZero                   = dict.SID(\"0\")\n\n\tprotectedMacro = map[int]bool{\n\t\tidFile:      true,\n\t\tidLineMacro: true,\n\t}\n\n\tkeywords = map[int]rune{\n\t\tdict.SID(\"_Bool\"):       BOOL,\n\t\tdict.SID(\"_Complex\"):    COMPLEX,\n\t\tdict.SID(\"__alignof__\"): ALIGNOF,\n\t\tdict.SID(\"auto\"):        AUTO,\n\t\tdict.SID(\"break\"):       BREAK,\n\t\tdict.SID(\"case\"):        CASE,\n\t\tdict.SID(\"char\"):        CHAR,\n\t\tdict.SID(\"const\"):       CONST,\n\t\tdict.SID(\"continue\"):    CONTINUE,\n\t\tdict.SID(\"default\"):     DEFAULT,\n\t\tdict.SID(\"do\"):          DO,\n\t\tdict.SID(\"double\"):      DOUBLE,\n\t\tdict.SID(\"else\"):        ELSE,\n\t\tdict.SID(\"enum\"):        ENUM,\n\t\tdict.SID(\"extern\"):      EXTERN,\n\t\tdict.SID(\"float\"):       FLOAT,\n\t\tdict.SID(\"for\"):         FOR,\n\t\tdict.SID(\"goto\"):        GOTO,\n\t\tdict.SID(\"if\"):          IF,\n\t\tdict.SID(\"inline\"):      INLINE,\n\t\tdict.SID(\"int\"):         INT,\n\t\tdict.SID(\"long\"):        LONG,\n\t\tdict.SID(\"register\"):    REGISTER,\n\t\tdict.SID(\"restrict\"):    RESTRICT,\n\t\tdict.SID(\"return\"):      RETURN,\n\t\tdict.SID(\"short\"):       SHORT,\n\t\tdict.SID(\"signed\"):      SIGNED,\n\t\tdict.SID(\"sizeof\"):      SIZEOF,\n\t\tdict.SID(\"static\"):      STATIC,\n\t\tdict.SID(\"struct\"):      STRUCT,\n\t\tdict.SID(\"switch\"):      SWITCH,\n\t\tdict.SID(\"typedef\"):     TYPEDEF,\n\t\tdict.SID(\"typeof\"):      TYPEOF,\n\t\tdict.SID(\"union\"):       UNION,\n\t\tdict.SID(\"unsigned\"):    UNSIGNED,\n\t\tdict.SID(\"void\"):        VOID,\n\t\tdict.SID(\"volatile\"):    VOLATILE,\n\t\tdict.SID(\"while\"):       WHILE,\n\t}\n\n\ttokConstVals = map[rune]int{\n\t\tADDASSIGN: dict.SID(\"+=\"),\n\t\tANDAND:    dict.SID(\"&&\"),\n\t\tANDASSIGN: dict.SID(\"&=\"),\n\t\tARROW:     dict.SID(\"->\"),\n\t\tAUTO:      dict.SID(\"auto\"),\n\t\tBOOL:      dict.SID(\"_Bool\"),\n\t\tBREAK:     dict.SID(\"break\"),\n\t\tCASE:      dict.SID(\"case\"),\n\t\tCHAR:      dict.SID(\"char\"),\n\t\tCOMPLEX:   dict.SID(\"_Complex\"),\n\t\tCONST:     dict.SID(\"const\"),\n\t\tCONTINUE:  dict.SID(\"continue\"),\n\t\tDDD:       dict.SID(\"...\"),\n\t\tDEC:       dict.SID(\"--\"),\n\t\tDEFAULT:   dict.SID(\"default\"),\n\t\tDIVASSIGN: dict.SID(\"/=\"),\n\t\tDO:        dict.SID(\"do\"),\n\t\tDOUBLE:    dict.SID(\"double\"),\n\t\tELSE:      dict.SID(\"else\"),\n\t\tENUM:      dict.SID(\"enum\"),\n\t\tEQ:        dict.SID(\"==\"),\n\t\tEXTERN:    dict.SID(\"extern\"),\n\t\tFLOAT:     dict.SID(\"float\"),\n\t\tFOR:       dict.SID(\"for\"),\n\t\tGEQ:       dict.SID(\">=\"),\n\t\tGOTO:      dict.SID(\"goto\"),\n\t\tIF:        dict.SID(\"if\"),\n\t\tINC:       dict.SID(\"++\"),\n\t\tINLINE:    dict.SID(\"inline\"),\n\t\tINT:       dict.SID(\"int\"),\n\t\tLEQ:       dict.SID(\"<=\"),\n\t\tLONG:      dict.SID(\"long\"),\n\t\tLSH:       dict.SID(\"<<\"),\n\t\tLSHASSIGN: dict.SID(\"<<=\"),\n\t\tMODASSIGN: dict.SID(\"%=\"),\n\t\tMULASSIGN: dict.SID(\"*=\"),\n\t\tNEQ:       dict.SID(\"!=\"),\n\t\tORASSIGN:  dict.SID(\"|=\"),\n\t\tOROR:      dict.SID(\"||\"),\n\t\tPPPASTE:   dict.SID(\"##\"),\n\t\tREGISTER:  dict.SID(\"register\"),\n\t\tRESTRICT:  dict.SID(\"restrict\"),\n\t\tRETURN:    dict.SID(\"return\"),\n\t\tRSH:       dict.SID(\">>\"),\n\t\tRSHASSIGN: dict.SID(\">>=\"),\n\t\tSHORT:     dict.SID(\"short\"),\n\t\tSIGNED:    dict.SID(\"signed\"),\n\t\tSIZEOF:    dict.SID(\"sizeof\"),\n\t\tSTATIC:    dict.SID(\"static\"),\n\t\tSTRUCT:    dict.SID(\"struct\"),\n\t\tSUBASSIGN: dict.SID(\"-=\"),\n\t\tSWITCH:    dict.SID(\"switch\"),\n\t\tTYPEDEF:   dict.SID(\"typedef\"),\n\t\tTYPEOF:    dict.SID(\"typeof\"),\n\t\tUNION:     dict.SID(\"union\"),\n\t\tUNSIGNED:  dict.SID(\"unsigned\"),\n\t\tVOID:      dict.SID(\"void\"),\n\t\tVOLATILE:  dict.SID(\"volatile\"),\n\t\tWHILE:     dict.SID(\"while\"),\n\t\tXORASSIGN: dict.SID(\"^=\"),\n\t}\n\n\ttokHasVal = map[rune]struct{}{\n\t\tCHARCONST:         {},\n\t\tFLOATCONST:        {},\n\t\tIDENTIFIER:        {},\n\t\tINTCONST:          {},\n\t\tLONGCHARCONST:     {},\n\t\tLONGSTRINGLITERAL: {},\n\t\tNON_REPL:          {},\n\t\tPPNUMBER:          {},\n\t\tSTRINGLITERAL:     {},\n\t\tTYPEDEF_NAME:      {},\n\t}\n\n\tfollowSetHasTypedefName = [len(yyParseTab)]bool{}\n\n\tclassifyType = map[TypeKind]int{\n\t\t0:                 noTypeClass,\n\t\tVoid:              voidTypeClass,\n\t\tPtr:               pointerTypeClass,\n\t\tChar:              charTypeClass,\n\t\tSChar:             charTypeClass,\n\t\tUChar:             charTypeClass,\n\t\tShort:             integerTypeClass,\n\t\tUShort:            integerTypeClass,\n\t\tInt:               integerTypeClass,\n\t\tUInt:              integerTypeClass,\n\t\tLong:              integerTypeClass,\n\t\tULong:             integerTypeClass,\n\t\tLongLong:          integerTypeClass,\n\t\tULongLong:         integerTypeClass,\n\t\tFloat:             realTypeClass,\n\t\tDouble:            realTypeClass,\n\t\tLongDouble:        realTypeClass,\n\t\tBool:              booleanTypeClass,\n\t\tFloatComplex:      complexTypeClass,\n\t\tDoubleComplex:     complexTypeClass,\n\t\tLongDoubleComplex: complexTypeClass,\n\t\tStruct:            recordTypeClass,\n\t\tUnion:             unionTypeClass,\n\t\tEnum:              enumeralTypeClass,\n\t\tTypedefName:       noTypeClass,\n\t\tFunction:          functionTypeClass,\n\t\tArray:             arrayTypeClass,\n\t}\n)\n\nfunc init() {\n\tfor i, v := range yyFollow {\n\t\tfor _, v := range v {\n\t\t\tif v == TYPEDEF_NAME {\n\t\t\t\tfollowSetHasTypedefName[i] = true\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc isUCNDigit(r rune) bool {\n\treturn int(r) < len(ucnDigits)<<bitShift && ucnDigits[uint(r)>>bitShift]&(1<<uint(r&bitMask)) != 0\n}\n\nfunc isUCNNonDigit(r rune) bool {\n\treturn int(r) < len(ucnNonDigits)<<bitShift && ucnNonDigits[uint(r)>>bitShift]&(1<<uint(r&bitMask)) != 0\n}\n\nfunc rune2class(r rune) (c int) {\n\tswitch {\n\tcase r == lex.RuneEOF:\n\t\treturn ccEOF\n\tcase r < 128:\n\t\treturn int(r)\n\tcase isUCNDigit(r):\n\t\treturn ccUCNDigit\n\tcase isUCNNonDigit(r):\n\t\treturn ccUCNNonDigit\n\tdefault:\n\t\treturn ccOther\n\t}\n}\n\nfunc decodeToken(b []byte, pos token.Pos) ([]byte, token.Pos, xc.Token) {\n\tr, n := binary.Uvarint(b)\n\tb = b[n:]\n\td, n := binary.Uvarint(b)\n\tb = b[n:]\n\tnp := pos + token.Pos(d)\n\tc := lex.NewChar(np, rune(r))\n\tvar v uint64\n\tif _, ok := tokHasVal[c.Rune]; ok {\n\t\tv, n = binary.Uvarint(b)\n\t\tb = b[n:]\n\t}\n\treturn b, np, xc.Token{Char: c, Val: int(v)}\n}\n\n// TokSrc returns t in its source form.\nfunc TokSrc(t xc.Token) string {\n\tif x, ok := tokConstVals[t.Rune]; ok {\n\t\treturn string(dict.S(x))\n\t}\n\n\tif _, ok := tokHasVal[t.Rune]; ok {\n\t\treturn string(t.S())\n\t}\n\n\treturn string(t.Rune)\n}\n\n// escape-sequence\t\t{simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}\n// simple-sequence\t\t\\\\['\\x22?\\\\abfnrtv]\n// octal-escape-sequence\t\\\\{octal-digit}{octal-digit}?{octal-digit}?\n// hexadecimal-escape-sequence\t\\\\x{hexadecimal-digit}+\nfunc decodeEscapeSequence(runes []rune) (rune, int) {\n\tif runes[0] != '\\\\' {\n\t\tpanic(\"internal error\")\n\t}\n\n\tr := runes[1]\n\tswitch r {\n\tcase '\\'', '\"', '?', '\\\\':\n\t\treturn r, 2\n\tcase 'a':\n\t\treturn 7, 2\n\tcase 'b':\n\t\treturn 8, 2\n\tcase 'f':\n\t\treturn 12, 2\n\tcase 'n':\n\t\treturn 10, 2\n\tcase 'r':\n\t\treturn 13, 2\n\tcase 't':\n\t\treturn 9, 2\n\tcase 'v':\n\t\treturn 11, 2\n\tcase 'x':\n\t\tv, n := 0, 2\n\tloop2:\n\t\tfor _, r := range runes[2:] {\n\t\t\tswitch {\n\t\t\tcase r >= '0' && r <= '9', r >= 'a' && r <= 'f', r >= 'A' && r <= 'F':\n\t\t\t\tv = v<<4 | decodeHex(r)\n\t\t\t\tn++\n\t\t\tdefault:\n\t\t\t\tbreak loop2\n\t\t\t}\n\t\t}\n\t\treturn -rune(v & 0xff), n\n\tcase 'u', 'U':\n\t\treturn decodeUCN(runes)\n\t}\n\n\tif r < '0' || r > '7' {\n\t\tpanic(\"internal error\")\n\t}\n\n\tv, n := 0, 1\nloop:\n\tfor _, r := range runes[1:] {\n\t\tswitch {\n\t\tcase r >= '0' && r <= '7':\n\t\t\tv = v<<3 | (int(r) - '0')\n\t\t\tn++\n\t\tdefault:\n\t\t\tbreak loop\n\t\t}\n\t}\n\treturn -rune(v), n\n}\n\nfunc decodeHex(r rune) int {\n\tswitch {\n\tcase r >= '0' && r <= '9':\n\t\treturn int(r) - '0'\n\tdefault:\n\t\tx := int(r) &^ 0x20\n\t\treturn x - 'A' + 10\n\t}\n}\n\n// universal-character-name\t\\\\u{hex-quad}|\\\\U{hex-quad}{hex-quad}\nfunc decodeUCN(runes []rune) (rune, int) {\n\tif runes[0] != '\\\\' {\n\t\tpanic(\"internal error\")\n\t}\n\n\trunes = runes[1:]\n\tswitch runes[0] {\n\tcase 'u':\n\t\treturn rune(decodeHexQuad(runes[1:])), 6\n\tcase 'U':\n\t\treturn rune(decodeHexQuad(runes[1:])<<16 | decodeHexQuad(runes[5:])), 10\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n}\n\n// hex-quad\t{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}\nfunc decodeHexQuad(runes []rune) int {\n\tn := 0\n\tfor _, r := range runes[:4] {\n\t\tn = n<<4 | decodeHex(r)\n\t}\n\treturn n\n}\n\n// Values from GCC's typeclass.h\nconst (\n\tnoTypeClass = iota - 1\n\tvoidTypeClass\n\tintegerTypeClass\n\tcharTypeClass\n\tenumeralTypeClass\n\tbooleanTypeClass\n\tpointerTypeClass\n\treferenceTypeClass\n\toffsetTypeClass\n\trealTypeClass\n\tcomplexTypeClass\n\tfunctionTypeClass\n\tmethodTypeClass\n\trecordTypeClass\n\tunionTypeClass\n\tarrayTypeClass\n\tstringTypeClass\n\tlangTypeClass\n)\n"
  },
  {
    "path": "v2/enum.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"github.com/cznic/ir\"\n)\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\ntype cond int\n\nconst (\n\tcondZero cond = iota\n\n\tcondIfOff\n\tcondIfOn\n\tcondIfSkip\n\n\tmaxCond\n)\n\nvar (\n\tcondOn = [maxCond]bool{\n\t\tcondIfOn: true,\n\t\tcondZero: true,\n\t}\n)\n\n// Linkage describes linkage of identifiers, [0]6.2.2.\ntype Linkage int\n\n// Values of Linkage\nconst (\n\tLinkageNone     Linkage = iota\n\tLinkageInternal Linkage = Linkage(ir.InternalLinkage)\n\tLinkageExternal Linkage = Linkage(ir.ExternalLinkage)\n)\n\n// StorageDuration describes lifetime of an object, [0]6.2.4.\ntype StorageDuration int\n\n// Values of StorageDuration\nconst (\n\tStorageDurationAutomatic StorageDuration = iota\n\tStorageDurationStatic\n)\n"
  },
  {
    "path": "v2/etc.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"go/scanner\"\n\t\"io\"\n\t\"os\"\n\t\"runtime/debug\"\n\t\"strings\"\n\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\tbNL    = []byte{'\\n'}\n\tbPanic = []byte(\"panic\")\n)\n\n// PrettyString returns pretty strings for things produced by this package.\nfunc PrettyString(v interface{}) string {\n\treturn strutil.PrettyString(v, \"\", \"\", printHooks)\n}\n\nfunc debugStack() []byte {\n\tb := debug.Stack()\n\tb = b[bytes.Index(b, bPanic)+1:]\n\tb = b[bytes.Index(b, bPanic):]\n\tb = b[bytes.Index(b, bNL)+1:]\n\treturn b\n}\n\nfunc cppTrimSpace(toks []cppToken) []cppToken {\n\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\ttoks = toks[1:]\n\t}\n\tfor len(toks) != 0 && toks[len(toks)-1].Rune == ' ' {\n\t\ttoks = toks[:len(toks)-1]\n\t}\n\treturn toks\n}\n\nfunc trimSpace(toks []xc.Token) []xc.Token {\n\tfor len(toks) != 0 && toks[0].Rune == ' ' {\n\t\ttoks = toks[1:]\n\t}\n\tfor len(toks) != 0 && toks[len(toks)-1].Rune == ' ' {\n\t\ttoks = toks[:len(toks)-1]\n\t}\n\treturn toks\n}\n\nfunc cppTrimAllSpace(toks []cppToken) []cppToken {\n\tw := 0\n\tfor _, v := range toks {\n\t\tswitch v.Rune {\n\t\tcase ' ', '\\n':\n\t\t\t// nop\n\t\tdefault:\n\t\t\ttoks[w] = v\n\t\t\tw++\n\t\t}\n\t}\n\treturn toks[:w]\n}\n\nfunc trimAllSpace(toks []xc.Token) []xc.Token {\n\tw := 0\n\tfor _, v := range toks {\n\t\tswitch v.Rune {\n\t\tcase ' ', '\\n':\n\t\t\t// nop\n\t\tdefault:\n\t\t\ttoks[w] = v\n\t\t\tw++\n\t\t}\n\t}\n\treturn toks[:w]\n}\n\nfunc isVaList(t Type) bool { //TODO export and use\n\tx, ok := t.(*NamedType)\n\treturn ok && (x.Name == idVaList || x.Name == idBuiltinVaList)\n}\n\nfunc cppToksDump(toks []cppToken, sep string) string {\n\tvar a []string\n\tfor _, t := range toks {\n\t\tif t.Rune == '\\n' {\n\t\t\tcontinue\n\t\t}\n\n\t\ta = append(a, TokSrc(t.Token))\n\t}\n\treturn strings.Join(a, sep)\n}\n\nfunc toksDump(toks []xc.Token, sep string) string {\n\tvar a []string\n\tfor _, t := range toks {\n\t\tif t.Rune == '\\n' {\n\t\t\tcontinue\n\t\t}\n\n\t\ta = append(a, TokSrc(t))\n\t}\n\treturn strings.Join(a, sep)\n}\n\nfunc prefer(d *Declarator) bool {\n\tif d.DeclarationSpecifier.IsExtern() {\n\t\treturn false\n\t}\n\n\tt := d.Type\n\tfor {\n\t\tswitch x := UnderlyingType(t).(type) {\n\t\tcase *ArrayType:\n\t\t\treturn x.Size.Type != nil\n\t\tcase *FunctionType:\n\t\t\treturn d.FunctionDefinition != nil\n\t\tcase\n\t\t\t*EnumType,\n\t\t\t*StructType,\n\t\t\t*UnionType:\n\n\t\t\treturn true\n\t\tcase *PointerType:\n\t\t\tt = x.Item\n\t\tcase *TaggedStructType:\n\t\t\treturn x.Type != nil\n\t\tcase TypeKind:\n\t\t\tif x.IsScalarType() || x == Void {\n\t\t\t\treturn true\n\t\t\t}\n\n\t\t\tpanic(x)\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\t}\n}\n\nfunc env(key, val string) string {\n\tif s := os.Getenv(key); s != \"\" {\n\t\treturn s\n\t}\n\n\treturn val\n}\n\n// IncompatibleTypeDiff is a debug helper.\nfunc IncompatibleTypeDiff(a, b Type) {\n\tif a == nil || b == nil {\n\t\tpanic(fmt.Errorf(\"TODO\\n\\t%v\\n\\t%v\", a, b))\n\t}\n\n\tok0 := a.IsCompatible(b)\n\ta0 := a\n\tb0 := b\n\ta = UnderlyingType(a)\n\tb = UnderlyingType(b)\n\tif ok := a.IsCompatible(b); ok != ok0 {\n\t\tfmt.Printf(`UnderlyingType changed compatibility from %v to %v (%T %T)\\n\n\t%v\n\t%v\n\t----\n\t%v\n\t%v\n\t====\n\t%v\n\t%v\n\t----\n\t%v\n\t%v\n\t----\n`, ok0, ok, a0, b0, a0, b0, a, b, PrettyString(a0), PrettyString(b0), PrettyString(a), PrettyString(b))\n\t}\n\tswitch x := a.(type) {\n\tcase *FunctionType:\n\t\ty := b.(*FunctionType)\n\t\tif g, e := x.Variadic, y.Variadic; g != e {\n\t\t\tfmt.Printf(\"different .Variadic %v %v\\n\", g, e)\n\t\t}\n\t\tif g, e := x.Result, y.Result; g != e && !g.IsCompatible(e) {\n\t\t\tfmt.Printf(\"Incompatible result types in %v, %T(%v) and %T(%v)\\n\", x, g, g, e, e)\n\t\t\tIncompatibleTypeDiff(g, e)\n\t\t}\n\t\tif g, e := len(x.Params), len(y.Params); g != e {\n\t\t\tfmt.Printf(\"len(Params) %v %v\\n\", g, e)\n\t\t\treturn\n\t\t}\n\n\t\tfor i, v := range x.Params {\n\t\t\tw := y.Params[i]\n\t\t\tif g, e := v, w; g != e && !g.IsCompatible(e) {\n\t\t\t\tfmt.Printf(\"Parameter %v.Type: types not compatible %T %T\\n\\t%v\\n\\t%v\\n\", i, g, e, g, e)\n\t\t\t\tIncompatibleTypeDiff(g, e)\n\t\t\t}\n\t\t}\n\tcase *PointerType:\n\t\ty := b.(*PointerType)\n\t\tIncompatibleTypeDiff(x.Item, y.Item)\n\tcase *StructType:\n\t\tswitch y := b.(type) {\n\t\tcase *StructType:\n\t\t\tif g, e := x.Tag, y.Tag; g != e {\n\t\t\t\tfmt.Printf(\"Tags %q %q\\n\", dict.S(g), dict.S(e))\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif g, e := len(x.Fields), len(y.Fields); g != e {\n\t\t\t\tfmt.Printf(\"len(Fields) %v %v\\n\", g, e)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tfor i, v := range x.Fields {\n\t\t\t\tw := y.Fields[i]\n\t\t\t\tif g, e := v.Name, w.Name; g != e {\n\t\t\t\t\tfmt.Printf(\"Field %v.Name: %q %q\\n\", i, dict.S(g), dict.S(e))\n\t\t\t\t}\n\t\t\t\tif g, e := v.Bits, w.Bits; g != e {\n\t\t\t\t\tfmt.Printf(\"Field %v.Bits: %v %v\\n\", i, g, e)\n\t\t\t\t}\n\t\t\t\tif g, e := v.PackedType, w.PackedType; g != e && !g.IsCompatible(e) {\n\t\t\t\t\tfmt.Printf(\"Field %v.PackedType: incompatible types\\n\\t%v\\n\\t%v\\n\", i, g, e)\n\t\t\t\t\tIncompatibleTypeDiff(g, e)\n\t\t\t\t}\n\t\t\t\tif g, e := v.Type, w.Type; g != e && !g.IsCompatible(e) {\n\t\t\t\t\tfmt.Printf(\"Field %v.Type: incompatible types\\n\\t%v\\n\\t%v\\n\", i, g, e)\n\t\t\t\t\tIncompatibleTypeDiff(g, e)\n\t\t\t\t}\n\t\t\t}\n\t\tcase *TaggedStructType:\n\t\t\tb = y.Type\n\t\t\tif b == y {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\tif b == nil {\n\t\t\t\tpanic(fmt.Errorf(\"%T(%v).Type: %v\", y, y, y.Type))\n\t\t\t}\n\n\t\t\tIncompatibleTypeDiff(x, b)\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", y))\n\t\t}\n\tcase TypeKind:\n\t\ty := b.(TypeKind)\n\t\tif g, e := x, y; g != e && !g.IsCompatible(e) {\n\t\t\tfmt.Printf(\"TypeKinds differ: %v %v\\n\", g, e)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// ErrString is like error.Error() but expands scanner.ErrorList.\nfunc ErrString(err error) string {\n\tvar b bytes.Buffer\n\tprintError(&b, \"\", err)\n\treturn b.String()\n}\n\nfunc printError(w io.Writer, pref string, err error) {\n\tswitch x := err.(type) {\n\tcase scanner.ErrorList:\n\t\tfor i, v := range x {\n\t\t\tfmt.Fprintf(w, \"%s%v\\n\", pref, v)\n\t\t\tif i == 50 {\n\t\t\t\tfmt.Fprintln(w, \"too many errors\")\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tfmt.Fprintf(w, \"%s%v\\n\", pref, err)\n\t}\n}\n\nfunc cppToks(toks []xc.Token) []cppToken {\n\tr := make([]cppToken, len(toks))\n\tfor i, v := range toks {\n\t\tr[i].Token = v\n\t}\n\treturn r\n}\n\nfunc xcToks(toks []cppToken) []xc.Token {\n\tr := make([]xc.Token, len(toks))\n\tfor i, v := range toks {\n\t\tr[i] = v.Token\n\t}\n\treturn r\n}\n"
  },
  {
    "path": "v2/headers/LICENSE-GCC-RTE-V3.1",
    "content": "GCC RUNTIME LIBRARY EXCEPTION Version 3.1, 31 March 2009\n\nCopyright © 2009 Free Software Foundation, Inc. <https://fsf.org/>\n\nEveryone is permitted to copy and distribute verbatim copies of this license\ndocument, but changing it is not allowed.\n\nThis GCC Runtime Library Exception (\"Exception\") is an additional permission\nunder section 7 of the GNU General Public License, version 3 (\"GPLv3\"). It\napplies to a given file (the \"Runtime Library\") that bears a notice placed by\nthe copyright holder of the file stating that the file is governed by GPLv3\nalong with this Exception.\n\nWhen you use GCC to compile a program, GCC may combine portions of certain GCC\nheader files and runtime libraries with the compiled program. The purpose of\nthis Exception is to allow compilation of non-GPL (including proprietary)\nprograms to use, in this way, the header files and runtime libraries covered by\nthis Exception.\n\n0. Definitions.  A file is an \"Independent Module\" if it either requires the\nRuntime Library for execution after a Compilation Process, or makes use of an\ninterface provided by the Runtime Library, but is not otherwise based on the\nRuntime Library.\n\n\"GCC\" means a version of the GNU Compiler Collection, with or without\nmodifications, governed by version 3 (or a specified later version) of the GNU\nGeneral Public License (GPL) with the option of using any subsequent versions\npublished by the FSF.\n\n\"GPL-compatible Software\" is software whose conditions of propagation,\nmodification and use would permit combination with GCC in accord with the\nlicense of GCC.\n\n\"Target Code\" refers to output from any compiler for a real or virtual target\nprocessor architecture, in executable form or suitable for input to an\nassembler, loader, linker and/or execution phase. Notwithstanding that, Target\nCode does not include data in any format that is used as a compiler\nintermediate representation, or used for producing a compiler intermediate\nrepresentation.\n\nThe \"Compilation Process\" transforms code entirely represented in\nnon-intermediate languages designed for human-written code, and/or in Java\nVirtual Machine byte code, into Target Code. Thus, for example, use of source\ncode generators and preprocessors need not be considered part of the\nCompilation Process, since the Compilation Process can be understood as\nstarting with the output of the generators or preprocessors.\n\nA Compilation Process is \"Eligible\" if it is done using GCC, alone or with\nother GPL-compatible software, or if it is done without using any work based on\nGCC. For example, using non-GPL-compatible Software to optimize any GCC\nintermediate representations would not qualify as an Eligible Compilation\nProcess.\n\n1. Grant of Additional Permission.  You have permission to propagate a work of\nTarget Code formed by combining the Runtime Library with Independent Modules,\neven if such propagation would otherwise violate the terms of GPLv3, provided\nthat all Target Code was generated by Eligible Compilation Processes. You may\nthen convey such a combination under terms of your choice, consistent with the\nlicensing of the Independent Modules.\n\n2. No Weakening of GCC Copyleft.  The availability of this Exception does not\nimply any general presumption that third-party software is unaffected by the\ncopyleft requirements of the license of GCC.\n"
  },
  {
    "path": "v2/headers/LICENSE-GPL-V3.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "v2/headers/Makefile",
    "content": "# Copyright 2017 The CC Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style\n# license that can be found in the LICENSE file.\n#\n.PHONY:\tall clean cover cpu editor internalError later mem nuke todo edit\n\ngrep=--include=*.go --include=*.l --include=*.y --include=*.yy\nngrep='TODOOK\\|parser\\.go\\|scanner\\.go\\|.*_string\\.go'\n\nall: editor\n\tgo vet 2>&1 | grep -v $(ngrep) || true\n\tgolint 2>&1 | grep -v $(ngrep) || true\n\tmake todo\n\tunused . || true\n\tmisspell *.go\n\tgosimple || true\n\tmaligned || true\n\tunconvert -apply\n\nclean:\n\tgo clean\n\trm -f *~ *.test *.out\n\ncover:\n\tt=$(shell mktemp) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t\n\ncpu: clean\n\tgo test -run @ -bench . -cpuprofile cpu.out\n\tgo tool pprof -lines *.test cpu.out\n\nedit:\n\tgvim -p Makefile *.go\n\neditor:\n\tgofmt -l -s -w *.go\n\tgo test -i\n\tgo test 2>&1 | tee log\n\tgo run generator.go -crt github.com/cznic/crt 2>&1 | tee -a log\n\tfind -name \\*.c -or -name \\*.h | xargs -n1 indent -linux -l -1\n\tfind -name \\*.c~ -or -name \\*.h~ | xargs rm\n\ninternalError:\n\tegrep -ho '\"internal error.*\"' *.go | sort | cat -n\n\nlater:\n\t@grep -n $(grep) LATER * || true\n\t@grep -n $(grep) MAYBE * || true\n\nmem: clean\n\tgo test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h\n\tgo tool pprof -lines -web -alloc_space *.test mem.out\n\nnuke: clean\n\tgo clean -i\n\ntodo:\n\t@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) TODO * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) BUG * | grep -v $(ngrep) || true\n\t@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true\n"
  },
  {
    "path": "v2/headers/all_test.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n//go:generate go run generator.go\n\npackage headers\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path\"\n\t\"runtime\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc caller(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(2)\n\tfmt.Fprintf(os.Stderr, \"# caller: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\t_, fn, fl, _ = runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"# \\tcallee: %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc dbg(s string, va ...interface{}) {\n\tif s == \"\" {\n\t\ts = strings.Repeat(\"%v \", len(va))\n\t}\n\t_, fn, fl, _ := runtime.Caller(1)\n\tfmt.Fprintf(os.Stderr, \"# dbg %s:%d: \", path.Base(fn), fl)\n\tfmt.Fprintf(os.Stderr, s, va...)\n\tfmt.Fprintln(os.Stderr)\n\tos.Stderr.Sync()\n}\n\nfunc TODO(...interface{}) string { //TODOOK\n\t_, fn, fl, _ := runtime.Caller(1)\n\treturn fmt.Sprintf(\"# TODO: %s:%d:\\n\", path.Base(fn), fl) //TODOOK\n}\n\nfunc use(...interface{}) {}\n\nfunc init() {\n\tuse(caller, dbg, TODO) //TODOOK\n}\n\n// ============================================================================\n\nfunc Test(t *testing.T) {\n\tt.Logf(\"TODO\")\n}\n"
  },
  {
    "path": "v2/headers/features.c",
    "content": "// +build ignore\n\n#include <features.h>\n#include <stdio.h>\n\nint main()\n{\n#ifdef _POSIX_SOURCE\n\tprintf(\"_POSIX_SOURCE %li\\n\", (long)_POSIX_SOURCE);\n#endif\n#ifdef _POSIX_C_SOURCE\n\tprintf(\"_POSIX_C_SOURCE %li\\n\", (long)_POSIX_C_SOURCE);\n#endif\n#ifdef _XOPEN_SOURCE\n\tprintf(\"_XOPEN_SOURCE %li\\n\", (long)_XOPEN_SOURCE);\n#endif\n#ifdef _XOPEN_SOURCE_EXTENDED\n\tprintf(\"_XOPEN_SOURCE_EXTENDED %li\\n\", (long)_XOPEN_SOURCE_EXTENDED);\n#endif\n#ifdef _LARGEFILE_SOURCE\n\tprintf(\"_LARGEFILE_SOURCE %li\\n\", (long)_LARGEFILE_SOURCE);\n#endif\n#ifdef _LARGEFILE64_SOURCE\n\tprintf(\"_LARGEFILE64_SOURCE %li\\n\", (long)_LARGEFILE64_SOURCE);\n#endif\n#ifdef _FILE_OFFSET_BITS\n\tprintf(\"_FILE_OFFSET_BITS %li\\n\", (long)_FILE_OFFSET_BITS);\n#endif\n#ifdef _ISOC99_SOURCE\n\tprintf(\"_ISOC99_SOURCE %li\\n\", (long)_ISOC99_SOURCE);\n#endif\n#ifdef __STDC_WANT_LIB_EXT2__\n\tprintf(\"__STDC_WANT_LIB_EXT2__ %li\\n\", (long)__STDC_WANT_LIB_EXT2__);\n#endif\n#ifdef __STDC_WANT_IEC_60559_BFP_EXT__\n\tprintf(\"__STDC_WANT_IEC_60559_BFP_EXT__ %li\\n\", (long)__STDC_WANT_IEC_60559_BFP_EXT__);\n#endif\n#ifdef __STDC_WANT_IEC_60559_FUNCS_EXT__\n\tprintf(\"__STDC_WANT_IEC_60559_FUNCS_EXT__ %li\\n\", (long)__STDC_WANT_IEC_60559_FUNCS_EXT__);\n#endif\n#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__\n\tprintf(\"__STDC_WANT_IEC_60559_TYPES_EXT__ %li\\n\", (long)__STDC_WANT_IEC_60559_TYPES_EXT__);\n#endif\n#ifdef _GNU_SOURCE\n\tprintf(\"_GNU_SOURCE %li\\n\", (long)_GNU_SOURCE);\n#endif\n#ifdef _DEFAULT_SOURCE\n\tprintf(\"_DEFAULT_SOURCE %li\\n\", (long)_DEFAULT_SOURCE);\n#endif\n#ifdef _REENTRANT\n\tprintf(\"_REENTRANT %li\\n\", (long)_REENTRANT);\n#endif\n#ifdef _THREAD_SAFE\n\tprintf(\"_THREAD_SAFE %li\\n\", (long)_THREAD_SAFE);\n#endif\n}\n"
  },
  {
    "path": "v2/headers/generator.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build ignore\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"flag\"\n\t\"fmt\"\n\t\"go/format\"\n\t\"go/token\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/cznic/cc/v2\"\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/sortutil\"\n\t\"github.com/cznic/strutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\tgoOS   = runtime.GOOS\n\tgoArch = runtime.GOARCH\n\tosArch = fmt.Sprintf(\"%s_%s\", goOS, goArch)\n\n\tcrt  string\n\tdict = xc.Dict\n\n\tneed = map[string][]string{ // \"goos_goarch\" or \"goos\" or \"all\": list of headers\n\t\t\"all\": {\n\t\t\t\"alloca.h\",\n\t\t\t\"assert.h\",\n\t\t\t\"ctype.h\",\n\t\t\t\"errno.h\",\n\t\t\t\"fcntl.h\",\n\t\t\t\"float.h\",\n\t\t\t\"inttypes.h\",\n\t\t\t\"limits.h\",\n\t\t\t\"locale.h\",\n\t\t\t\"malloc.h\",\n\t\t\t\"math.h\",\n\t\t\t\"setjmp.h\",\n\t\t\t\"stdarg.h\",\n\t\t\t\"stdbool.h\",\n\t\t\t\"stddef.h\",\n\t\t\t\"stdint.h\",\n\t\t\t\"stdio.h\",\n\t\t\t\"stdlib.h\",\n\t\t\t\"string.h\",\n\t\t\t\"strings.h\",\n\t\t\t\"sys/stat.h\",\n\t\t\t\"sys/time.h\",\n\t\t\t\"sys/wait.h\",\n\t\t\t\"time.h\",\n\t\t\t\"unistd.h\",\n\t\t\t\"wchar.h\",\n\t\t\t\"zlib.h\",\n\t\t},\n\t\t\"linux\": {\n\t\t\t\"arpa/inet.h\",\n\t\t\t\"dirent.h\",\n\t\t\t\"dlfcn.h\",\n\t\t\t\"execinfo.h\",\n\t\t\t\"fts.h\",\n\t\t\t\"getopt.h\",\n\t\t\t\"grp.h\",\n\t\t\t\"memory.h\",\n\t\t\t\"netdb.h\",\n\t\t\t\"pthread.h\",\n\t\t\t\"pwd.h\",\n\t\t\t\"sched.h\",\n\t\t\t\"signal.h\",\n\t\t\t\"signal.h\",\n\t\t\t\"sys/file.h\",\n\t\t\t\"sys/ioctl.h\",\n\t\t\t\"sys/mman.h\",\n\t\t\t\"sys/param.h\",\n\t\t\t\"sys/resource.h\",\n\t\t\t\"sys/select.h\",\n\t\t\t\"sys/socket.h\",\n\t\t\t\"sys/statfs.h\",\n\t\t\t\"sys/times.h\",\n\t\t\t\"sys/types.h\",\n\t\t\t\"sys/uio.h\",\n\t\t\t\"sys/un.h\",\n\t\t\t\"sys/utsname.h\",\n\t\t\t\"termios.h\",\n\t\t\t\"utime.h\",\n\t\t},\n\t\t\"windows\": {\n\t\t\t\"io.h\",\n\t\t\t\"process.h\",\n\t\t\t\"windows.h\",\n\t\t},\n\t}\n)\n\nfunc main() {\n\toCRT := flag.String(\"crt\", \"\", \"CRT import path to update\")\n\tflag.Parse()\n\tif s := *oCRT; s != \"\" {\n\t\tvar err error\n\t\tif crt, err = findRepo(s); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n\tsys := predefined()\n\tvar want []string\n\tfor k, v := range need {\n\t\tswitch {\n\t\tcase\n\t\t\tk == \"all\",\n\t\t\tk == goOS,\n\t\t\tk == osArch:\n\n\t\t\twant = append(want, v...)\n\t\t}\n\t}\n\twant = want[:sortutil.Dedupe(sort.StringSlice(want))]\n\tvar got []string\n\ttweaks := &cc.Tweaks{\n\t\tEnableAnonymousStructFields: true,\n\t\tEnableEmptyStructs:          true,\n\t\tTrackIncludes: func(s string) {\n\t\t\tif strings.HasSuffix(s, \"builtin.h\") || strings.HasSuffix(s, \"predefined.h\") {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tgot = append(got, s)\n\t\t},\n\t}\n\tfor _, v := range want {\n\t\ttu, err := cc.Translate(\n\t\t\ttweaks,\n\t\t\tappend([]string{\"@\"}, sys...),\n\t\t\tsys,\n\t\t\tcc.NewStringSource(\"main.c\", fmt.Sprintf(`\n#include \"./%s/builtin.h\"\n\n// Output of gcc features.c && ./a.out in github.com/cznic/cc/v2/headers on linux_amd64.\n#define _POSIX_SOURCE 1\n#define _POSIX_C_SOURCE 200809\n#define _DEFAULT_SOURCE 1\n\n\n#include \"%v\"\n`, osArch, v)),\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(cc.ErrString(err))\n\t\t}\n\n\t\tif crt != \"\" {\n\t\t\tdefs(v, tu)\n\t\t}\n\t}\n\tgot = got[:sortutil.Dedupe(sort.StringSlice(got))]\n\tfor _, v := range got {\n\t\tb, err := ioutil.ReadFile(v)\n\t\tif err != nil {\n\t\t\tpanic(cc.ErrString(err))\n\t\t}\n\n\t\tf := filepath.Join(osArch, v)\n\t\tmkdir(filepath.Dir(f))\n\t\tif err := ioutil.WriteFile(f, b, 0644); err != nil {\n\t\t\tpanic(cc.ErrString(err))\n\t\t}\n\t}\n}\n\nfunc predefined() []string {\n\tpredefined, inc, sys, err := cc.HostConfig(\"-std=c99\")\n\tif err != nil {\n\t\tpanic(cc.ErrString(err))\n\t}\n\n\tif len(inc) != 0 {\n\t\tpanic(inc)\n\t}\n\n\ta := strings.Split(predefined, \"\\n\")\n\tw := 0\n\tfor _, v := range a {\n\t\tv = strings.TrimSpace(v)\n\t\tif s := strings.ToLower(v); strings.Contains(s, \"gcc\") || strings.Contains(s, \"gnu\") {\n\t\t\tcontinue\n\t\t}\n\n\t\ta[w] = v\n\t\tw++\n\t}\n\ta = a[:w]\n\tosArch = fmt.Sprintf(\"%s_%s\", goOS, goArch)\n\tmkdir(osArch)\n\tb := bytes.NewBufferString(`// Code generated by $ go generate - DO NOT EDIT.\n\n// +build ignore\n\t\n`)\n\tfor _, v := range a {\n\t\tfmt.Fprintln(b, v)\n\t}\n\n\tif err := ioutil.WriteFile(filepath.Join(osArch, \"predefined.h\"), b.Bytes(), 0644); err != nil {\n\t\tpanic(cc.ErrString(err))\n\t}\n\n\tb.Reset()\n\tm := map[string]struct{}{}\n\tw = 0\n\tfor _, v := range sys {\n\t\tv := filepath.Clean(v)\n\t\tif _, ok := m[v]; !ok {\n\t\t\tfmt.Fprintf(b, \"%s\\n\", v)\n\t\t\tsys[w] = v\n\t\t\tw++\n\t\t}\n\t\tm[v] = struct{}{}\n\t}\n\tsys = sys[:w]\n\tif err := ioutil.WriteFile(filepath.Join(osArch, \"paths\"), b.Bytes(), 0664); err != nil {\n\t\tpanic(cc.ErrString(err))\n\t}\n\n\treturn sys\n}\n\nfunc mkdir(p string) {\n\tif _, err := os.Stat(p); err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\tpanic(cc.ErrString(err))\n\t\t}\n\n\t\tif err := os.MkdirAll(p, 0775); err != nil {\n\t\t\tpanic(fmt.Errorf(\"%q: %v\", p, err))\n\t\t}\n\t}\n}\n\nfunc findRepo(s string) (string, error) {\n\ts = filepath.FromSlash(s)\n\tfor _, v := range strings.Split(strutil.Gopath(), string(os.PathListSeparator)) {\n\t\tp := filepath.Join(v, \"src\", s)\n\t\tfi, err := os.Lstat(p)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fi.IsDir() {\n\t\t\twd, err := os.Getwd()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tif p, err = filepath.Rel(wd, p); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\tif p, err = filepath.Abs(p); err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\n\t\t\treturn p, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"%q: cannot find repository\", s)\n}\n\nfunc defs(include string, tu *cc.TranslationUnit) {\n\tmodel, err := cc.NewModel()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar a []string\n\tfor _, v := range tu.Macros {\n\t\tif v.IsFnLike {\n\t\t\tcontinue\n\t\t}\n\n\t\tfrom := tu.FileSet.Position(v.DefTok.Pos()).Filename\n\t\tif from == \"\" || strings.Contains(from, \"predefined.h\") || strings.Contains(from, \"builtin.h\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tnm := string(dict.S(v.DefTok.Val))\n\t\tif strings.HasPrefix(nm, \"__\") {\n\t\t\tcontinue\n\t\t}\n\n\t\tif strings.HasPrefix(nm, \"_\") && len(nm) > 1 {\n\t\t\tif c := nm[1]; c >= 'A' && c <= 'Z' {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\ta = append(a, nm)\n\t}\n\tsort.Strings(a)\n\tfn := include[:len(include)-2] // sans .h\n\tdir := filepath.Join(crt, filepath.FromSlash(fn))\n\tfn = filepath.Join(dir, fmt.Sprintf(\"const_%s_%s.go\", runtime.GOOS, runtime.GOARCH))\n\tpn := filepath.Base(dir)\n\tif token.Lookup(pn).IsKeyword() {\n\t\tpn += \"_\"\n\t}\n\tbuf := bytes.NewBufferString(fmt.Sprintf(`// Code generated by $ go generate - DO NOT EDIT.\n\npackage %s\n\nconst (`, pn))\n\tfor _, nm := range a {\n\t\tv := tu.Macros[dict.SID(nm)]\n\t\top, err := v.Eval(model, tu.Macros)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tbuf.WriteByte('\\n')\n\t\tswitch x := op.Value.(type) {\n\t\tcase *ir.Float32Value:\n\t\t\tfmt.Fprintf(buf, \"X%s = %v\", nm, x.Value)\n\t\tcase *ir.Float64Value:\n\t\t\tfmt.Fprintf(buf, \"X%s = %v\", nm, x.Value)\n\t\tcase *ir.Int64Value:\n\t\t\tswitch {\n\t\t\tcase op.Type.IsUnsigned():\n\t\t\t\tfmt.Fprintf(buf, \"X%s = %v\", nm, uint64(cc.ConvertInt64(x.Value, op.Type, model)))\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(buf, \"X%s = %v\", nm, x.Value)\n\t\t\t}\n\t\tcase *ir.StringValue:\n\t\t\tfmt.Fprintf(buf, \"X%s = %q\", nm, dict.S(int(x.StringID)))\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n\ta = a[:0]\n\tfor _, v := range tu.FileScope.Idents {\n\t\tswitch x := v.(type) {\n\t\tcase *cc.EnumerationConstant:\n\t\t\tnm := string(dict.S(x.Token.Val))\n\t\t\tif strings.HasPrefix(nm, \"__\") {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\ta = append(a, string(dict.S(x.Token.Val)))\n\t\t}\n\t}\n\tsort.Strings(a)\n\tif len(a) != 0 {\n\t\tbuf.WriteByte('\\n')\n\t}\n\tfor _, nm := range a {\n\t\top := tu.FileScope.Idents[dict.SID(nm)].(*cc.EnumerationConstant).Operand\n\t\tx := op.Value.(*ir.Int64Value)\n\t\tbuf.WriteByte('\\n')\n\t\tswitch {\n\t\tcase op.Type.IsUnsigned():\n\t\t\tfmt.Fprintf(buf, \"C%s = %v\", nm, uint64(cc.ConvertInt64(x.Value, op.Type, model)))\n\t\tdefault:\n\t\t\tfmt.Fprintf(buf, \"C%s = %v\", nm, x.Value)\n\t\t}\n\t}\n\tbuf.WriteString(\"\\n)\\n\")\n\tb, err := format.Source(buf.Bytes())\n\tif err != nil {\n\t\tfmt.Printf(\"%s\\n\", buf.Bytes())\n\t\tpanic(err)\n\t}\n\tmkdir(dir)\n\tif err := ioutil.WriteFile(fn, b, 0644); err != nil {\n\t\tpanic(err)\n\t}\n}\n"
  },
  {
    "path": "v2/headers/linux_386/builtin.h",
    "content": "//  Copyright 2018 The CC Authors. All rights reserved.\n//  Use of this source code is governed by a BSD-style\n//  license that can be found in the LICENSE file.\n\n// +build ignore\n\n#ifndef _BUILTIN_H_\n#define _BUILTIN_H_\n\n#include \"predefined.h\"\n\ntypedef struct {\n\tvoid *_[2];\t\t// Go *[]interface{}\n} *__builtin_va_list;\n\ntypedef void *__FILE_TYPE__;\n\n__SIZE_TYPE__ __builtin_strlen(char *__s);\n__UINT64_TYPE__ __builtin_bswap64(__UINT64_TYPE__ x);\nchar *__builtin_strchrnul(char *, int);\nchar *__builtin_strcpy(char *__dest, char *__src);\ndouble __builtin_copysign(double x, double y);\nint __builtin_abs(int j);\nint __builtin_ffs(int i);\nint __builtin_isprint(int);\nint __builtin_memcmp(void *__s1, void *__s2, __SIZE_TYPE__ __n);\nint __builtin_printf(char *__format, ...);\nint __builtin_sprintf(char *__s, char *__format, ...);\nint __builtin_strcmp(char *__s1, char *__s2);\nint __signbit(double x);\nint __signbitf(float x);\nvoid *__builtin_alloca(__SIZE_TYPE__ __size);\nvoid *__builtin_memcpy(void *dest, const void *src, __SIZE_TYPE__ n);\nvoid *__builtin_memset(void *s, int c, __SIZE_TYPE__ n);\n#ifdef __ccgo__\nextern void *__ccgo_va_end;\nextern void *__ccgo_va_start;\n#endif\nvoid __GO__(char*);\nvoid __builtin_abort(void);\nvoid __builtin_exit(int __status);\nvoid __builtin_trap(void);\nvoid __register_stdfiles(void *, void *, void *, void *);\n\n#define __builtin_choose_expr(a, b, c) (a) ? (b) : (c)\n#define __builtin_expect(exp, c) (exp)\n#define __builtin_offsetof(st, m) ((__SIZE_TYPE__)(&((st *)0)->m))\n#define __builtin_prefetch(addr, ...) (void)(addr)\n#define __builtin_signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : sizeof (x) == sizeof(double) ? __signbit(x) : __signbitl(x))\n#define __builtin_types_compatible_p(type1, type2) __builtin_types_compatible__((type1){}, (type2){})\n#define __builtin_va_arg(ap, type) (type)ap\n#define __builtin_va_copy(dest, src) dest = src\n#ifdef __ccgo__\n#define __builtin_va_end(ap) ap = __ccgo_va_end\n#define __builtin_va_start(ap, arg) ap = __ccgo_va_start\n#else\n#define __builtin_va_end(ap) ap = (void*)0\n#define __builtin_va_start(ap, arg) ap = (void*)-1\n#endif\n#define __complex__ _Complex\n#define __const const\n#define __extension__\n#define __typeof__ typeof\n#define __volatile volatile\n\n#endif\t\t\t\t/* _BUILTIN_H_ */\n"
  },
  {
    "path": "v2/headers/linux_386/paths",
    "content": "/usr/lib/gcc/i686-linux-gnu/7/include\n/usr/local/include\n/usr/lib/gcc/i686-linux-gnu/7/include-fixed\n/usr/include/i386-linux-gnu\n/usr/include\n"
  },
  {
    "path": "v2/headers/linux_386/predefined.h",
    "content": "// Code generated by $ go generate - DO NOT EDIT.\n\n// +build ignore\n\n#define __SSP_STRONG__ 3\n#define __DBL_MIN_EXP__ (-1021)\n#define __FLT32X_MAX_EXP__ 1024\n#define __pentiumpro__ 1\n#define __UINT_LEAST16_MAX__ 0xffff\n#define __ATOMIC_ACQUIRE 2\n#define __FLT128_MAX_10_EXP__ 4932\n#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F\n#define __UINT_LEAST8_TYPE__ unsigned char\n#define __SIZEOF_FLOAT80__ 12\n#define __INTMAX_C(c) c ## LL\n#define __CHAR_BIT__ 8\n#define __UINT8_MAX__ 0xff\n#define __WINT_MAX__ 0xffffffffU\n#define __FLT32_MIN_EXP__ (-125)\n#define __ORDER_LITTLE_ENDIAN__ 1234\n#define __SIZE_MAX__ 0xffffffffU\n#define __WCHAR_MAX__ 0x7fffffffL\n#define __DBL_DENORM_MIN__ ((double)4.94065645841246544176568792868221372e-324L)\n#define __FLT32X_DECIMAL_DIG__ 17\n#define __FLT_EVAL_METHOD__ 2\n#define __unix__ 1\n#define __FLT64_DECIMAL_DIG__ 17\n#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL\n#define __SIG_ATOMIC_TYPE__ int\n#define __DBL_MIN_10_EXP__ (-307)\n#define __FINITE_MATH_ONLY__ 0\n#define __FLT32_HAS_DENORM__ 1\n#define __UINT_FAST8_MAX__ 0xff\n#define __has_include(STR) __has_include__(STR)\n#define __DEC64_MAX_EXP__ 385\n#define __INT8_C(c) c\n#define __INT_LEAST8_WIDTH__ 8\n#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL\n#define __SHRT_MAX__ 0x7fff\n#define __LDBL_MAX__ 1.18973149535723176502126385303097021e+4932L\n#define __FLT64X_MAX_10_EXP__ 4932\n#define __UINT_LEAST8_MAX__ 0xff\n#define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128\n#define __UINTMAX_TYPE__ long long unsigned int\n#define __linux 1\n#define __DEC32_EPSILON__ 1E-6DF\n#define __FLT_EVAL_METHOD_TS_18661_3__ 2\n#define __unix 1\n#define __UINT32_MAX__ 0xffffffffU\n#define __LDBL_MAX_EXP__ 16384\n#define __FLT128_MIN_EXP__ (-16381)\n#define __WINT_MIN__ 0U\n#define __linux__ 1\n#define __FLT128_MIN_10_EXP__ (-4931)\n#define __INT_LEAST16_WIDTH__ 16\n#define __SCHAR_MAX__ 0x7f\n#define __FLT128_MANT_DIG__ 113\n#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)\n#define __INT64_C(c) c ## LL\n#define __DBL_DIG__ 15\n#define __FLT64X_MANT_DIG__ 64\n#define __SIZEOF_INT__ 4\n#define __SIZEOF_POINTER__ 4\n#define __USER_LABEL_PREFIX__\n#define __FLT64X_EPSILON__ 1.08420217248550443400745280086994171e-19F64x\n#define __STDC_HOSTED__ 1\n#define __LDBL_HAS_INFINITY__ 1\n#define __FLT32_DIG__ 6\n#define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F\n#define __SHRT_WIDTH__ 16\n#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L\n#define __DEC32_MAX__ 9.999999E96DF\n#define __FLT64X_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951F64x\n#define __FLT32X_HAS_INFINITY__ 1\n#define __INT32_MAX__ 0x7fffffff\n#define __INT_WIDTH__ 32\n#define __SIZEOF_LONG__ 4\n#define __STDC_IEC_559__ 1\n#define __STDC_ISO_10646__ 201706L\n#define __UINT16_C(c) c\n#define __PTRDIFF_WIDTH__ 32\n#define __DECIMAL_DIG__ 21\n#define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64\n#define __INTMAX_WIDTH__ 64\n#define __has_include_next(STR) __has_include_next__(STR)\n#define __FLT64X_MIN_10_EXP__ (-4931)\n#define __LDBL_HAS_QUIET_NAN__ 1\n#define __FLT64_MANT_DIG__ 53\n#define __pie__ 2\n#define __FLT_HAS_DENORM__ 1\n#define __SIZEOF_LONG_DOUBLE__ 12\n#define __BIGGEST_ALIGNMENT__ 16\n#define __FLT64_MAX_10_EXP__ 308\n#define __i686 1\n#define __FLT32_HAS_INFINITY__ 1\n#define __DBL_MAX__ ((double)1.79769313486231570814527423731704357e+308L)\n#define __INT_FAST32_MAX__ 0x7fffffff\n#define __DBL_HAS_INFINITY__ 1\n#define __DEC32_MIN_EXP__ (-94)\n#define __INTPTR_WIDTH__ 32\n#define __FLT32X_HAS_DENORM__ 1\n#define __INT_FAST16_TYPE__ int\n#define __STRICT_ANSI__ 1\n#define __LDBL_HAS_DENORM__ 1\n#define __FLT128_HAS_INFINITY__ 1\n#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL\n#define __INT_LEAST32_MAX__ 0x7fffffff\n#define __DEC32_MIN__ 1E-95DF\n#define __DBL_MAX_EXP__ 1024\n#define __WCHAR_WIDTH__ 32\n#define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32\n#define __DEC128_EPSILON__ 1E-33DL\n#define __ATOMIC_HLE_RELEASE 131072\n#define __PTRDIFF_MAX__ 0x7fffffff\n#define __STDC_NO_THREADS__ 1\n#define __ATOMIC_HLE_ACQUIRE 65536\n#define __FLT32_HAS_QUIET_NAN__ 1\n#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL\n#define __SIZEOF_SIZE_T__ 4\n#define __FLT64X_MIN_EXP__ (-16381)\n#define __SIZEOF_WINT_T__ 4\n#define __LONG_LONG_WIDTH__ 64\n#define __FLT32_MAX_EXP__ 128\n#define __GXX_ABI_VERSION 1011\n#define __FLT_MIN_EXP__ (-125)\n#define __i686__ 1\n#define __FLT64X_HAS_QUIET_NAN__ 1\n#define __INT_FAST64_TYPE__ long long int\n#define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64\n#define __DBL_MIN__ ((double)2.22507385850720138309023271733240406e-308L)\n#define __PIE__ 2\n#define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x\n#define __DECIMAL_BID_FORMAT__ 1\n#define __FLT64_MIN_EXP__ (-1021)\n#define __FLT64_MIN_10_EXP__ (-307)\n#define __FLT64X_DECIMAL_DIG__ 21\n#define __DEC128_MIN__ 1E-6143DL\n#define __REGISTER_PREFIX__\n#define __UINT16_MAX__ 0xffff\n#define __DBL_HAS_DENORM__ 1\n#define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32\n#define __UINT8_TYPE__ unsigned char\n#define __NO_INLINE__ 1\n#define __i386 1\n#define __FLT_MANT_DIG__ 24\n#define __LDBL_DECIMAL_DIG__ 21\n#define __VERSION__ \"7.3.0\"\n#define __UINT64_C(c) c ## ULL\n#define _STDC_PREDEF_H 1\n#define __FLT128_MAX_EXP__ 16384\n#define __FLT32_MANT_DIG__ 24\n#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __STDC_IEC_559_COMPLEX__ 1\n#define __FLT128_HAS_DENORM__ 1\n#define __FLT128_DIG__ 33\n#define __SCHAR_WIDTH__ 8\n#define __INT32_C(c) c\n#define __DEC64_EPSILON__ 1E-15DD\n#define __ORDER_PDP_ENDIAN__ 3412\n#define __DEC128_MIN_EXP__ (-6142)\n#define __code_model_32__ 1\n#define __FLT32_MAX_10_EXP__ 38\n#define __INT_FAST32_TYPE__ int\n#define __UINT_LEAST16_TYPE__ short unsigned int\n#define __FLT64X_HAS_INFINITY__ 1\n#define __INT16_MAX__ 0x7fff\n#define __i386__ 1\n#define __SIZE_TYPE__ unsigned int\n#define __UINT64_MAX__ 0xffffffffffffffffULL\n#define __FLT64X_DIG__ 18\n#define __INT8_TYPE__ signed char\n#define __ELF__ 1\n#define __FLT_RADIX__ 2\n#define __INT_LEAST16_TYPE__ short int\n#define __LDBL_EPSILON__ 1.08420217248550443400745280086994171e-19L\n#define __UINTMAX_C(c) c ## ULL\n#define __SIG_ATOMIC_MAX__ 0x7fffffff\n#define __SIZEOF_PTRDIFF_T__ 4\n#define __FLT32X_MANT_DIG__ 53\n#define __FLT32X_MIN_EXP__ (-1021)\n#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF\n#define __pentiumpro 1\n#define __INT_FAST16_MAX__ 0x7fffffff\n#define __FLT64_DIG__ 15\n#define __UINT_FAST32_MAX__ 0xffffffffU\n#define __UINT_LEAST64_TYPE__ long long unsigned int\n#define __FLT_HAS_QUIET_NAN__ 1\n#define __FLT_MAX_10_EXP__ 38\n#define __LONG_MAX__ 0x7fffffffL\n#define __FLT64X_HAS_DENORM__ 1\n#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL\n#define __FLT_HAS_INFINITY__ 1\n#define __UINT_FAST16_TYPE__ unsigned int\n#define __DEC64_MAX__ 9.999999999999999E384DD\n#define __INT_FAST32_WIDTH__ 32\n#define __CHAR16_TYPE__ short unsigned int\n#define __PRAGMA_REDEFINE_EXTNAME 1\n#define __SIZE_WIDTH__ 32\n#define __SEG_FS 1\n#define __INT_LEAST16_MAX__ 0x7fff\n#define __DEC64_MANT_DIG__ 16\n#define __INT64_MAX__ 0x7fffffffffffffffLL\n#define __UINT_LEAST32_MAX__ 0xffffffffU\n#define __SEG_GS 1\n#define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32\n#define __SIG_ATOMIC_WIDTH__ 32\n#define __INT_LEAST64_TYPE__ long long int\n#define __INT16_TYPE__ short int\n#define __INT_LEAST8_TYPE__ signed char\n#define __STDC_VERSION__ 199901L\n#define __DEC32_MAX_EXP__ 97\n#define __INT_FAST8_MAX__ 0x7f\n#define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128\n#define __INTPTR_MAX__ 0x7fffffff\n#define __FLT64_HAS_QUIET_NAN__ 1\n#define __FLT32_MIN_10_EXP__ (-37)\n#define __FLT32X_DIG__ 15\n#define __LDBL_MANT_DIG__ 64\n#define __DBL_HAS_QUIET_NAN__ 1\n#define __FLT64_HAS_INFINITY__ 1\n#define __FLT64X_MAX__ 1.18973149535723176502126385303097021e+4932F64x\n#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)\n#define __INTPTR_TYPE__ int\n#define __UINT16_TYPE__ short unsigned int\n#define __WCHAR_TYPE__ long int\n#define __SIZEOF_FLOAT__ 4\n#define __pic__ 2\n#define __UINTPTR_MAX__ 0xffffffffU\n#define __INT_FAST64_WIDTH__ 64\n#define __DEC64_MIN_EXP__ (-382)\n#define __FLT32_DECIMAL_DIG__ 9\n#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL\n#define __FLT_DIG__ 6\n#define __FLT64X_MAX_EXP__ 16384\n#define __UINT_FAST64_TYPE__ long long unsigned int\n#define __INT_MAX__ 0x7fffffff\n#define __INT64_TYPE__ long long int\n#define __FLT_MAX_EXP__ 128\n#define __DBL_MANT_DIG__ 53\n#define __SIZEOF_FLOAT128__ 16\n#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL\n#define __DEC64_MIN__ 1E-383DD\n#define __WINT_TYPE__ unsigned int\n#define __UINT_LEAST32_TYPE__ unsigned int\n#define __SIZEOF_SHORT__ 2\n#define __LDBL_MIN_EXP__ (-16381)\n#define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64\n#define __WINT_WIDTH__ 32\n#define __INT_LEAST8_MAX__ 0x7f\n#define __FLT32X_MAX_10_EXP__ 308\n#define __LDBL_MAX_10_EXP__ 4932\n#define __ATOMIC_RELAXED 0\n#define __DBL_EPSILON__ ((double)2.22044604925031308084726333618164062e-16L)\n#define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128\n#define __UINT8_C(c) c\n#define __FLT64_MAX_EXP__ 1024\n#define __INT_LEAST32_TYPE__ int\n#define __SIZEOF_WCHAR_T__ 4\n#define __UINT64_TYPE__ long long unsigned int\n#define __FLT128_HAS_QUIET_NAN__ 1\n#define __INT_FAST8_TYPE__ signed char\n#define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x\n#define __FLT64_HAS_DENORM__ 1\n#define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32\n#define __DBL_DECIMAL_DIG__ 17\n#define __INT_FAST8_WIDTH__ 8\n#define __DEC_EVAL_METHOD__ 2\n#define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x\n#define __ORDER_BIG_ENDIAN__ 4321\n#define __UINT32_C(c) c ## U\n#define __INTMAX_MAX__ 0x7fffffffffffffffLL\n#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F\n#define __INT8_MAX__ 0x7f\n#define __LONG_WIDTH__ 32\n#define __PIC__ 2\n#define __UINT_FAST32_TYPE__ unsigned int\n#define __CHAR32_TYPE__ unsigned int\n#define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F\n#define __INT32_TYPE__ int\n#define __SIZEOF_DOUBLE__ 8\n#define __FLT_MIN_10_EXP__ (-37)\n#define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64\n#define __INT_LEAST32_WIDTH__ 32\n#define __INTMAX_TYPE__ long long int\n#define __DEC128_MAX_EXP__ 6145\n#define __FLT32X_HAS_QUIET_NAN__ 1\n#define __ATOMIC_CONSUME 1\n#define __INT_FAST16_WIDTH__ 32\n#define __UINTMAX_MAX__ 0xffffffffffffffffULL\n#define __DEC32_MANT_DIG__ 7\n#define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x\n#define __DBL_MAX_10_EXP__ 308\n#define __LDBL_DENORM_MIN__ 3.64519953188247460252840593361941982e-4951L\n#define __INT16_C(c) c\n#define __STDC__ 1\n#define __PTRDIFF_TYPE__ int\n#define __ATOMIC_SEQ_CST 5\n#define __UINT32_TYPE__ unsigned int\n#define __FLT32X_MIN_10_EXP__ (-307)\n#define __UINTPTR_TYPE__ unsigned int\n#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD\n#define __DEC128_MANT_DIG__ 34\n#define __LDBL_MIN_10_EXP__ (-4931)\n#define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128\n#define __SIZEOF_LONG_LONG__ 8\n#define __FLT128_DECIMAL_DIG__ 36\n#define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x\n#define __LDBL_DIG__ 18\n#define __FLT_DECIMAL_DIG__ 9\n#define __UINT_FAST16_MAX__ 0xffffffffU\n#define __INT_LEAST64_WIDTH__ 64\n#define __UINT_FAST8_TYPE__ unsigned char\n#define __ATOMIC_ACQ_REL 4\n#define __ATOMIC_RELEASE 3\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/alloca.h",
    "content": "/* Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ALLOCA_H\n#define\t_ALLOCA_H\t1\n\n#include <features.h>\n\n#define\t__need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS\n/* Remove any previous definitions.  */\n#undef\talloca\n/* Allocate a block that will be freed when the calling function exits.  */\nextern void *alloca(size_t __size) __THROW;\n\n#ifdef\t__GNUC__\n# define alloca(size)\t__builtin_alloca (size)\n#endif\t\t\t\t/* GCC.  */\n\n__END_DECLS\n#endif\t\t\t\t/* alloca.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/arpa/inet.h",
    "content": "/* Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _ARPA_INET_H\n#define\t_ARPA_INET_H\t1\n\n#include <features.h>\n#include <netinet/in.h>\t\t/* To define `struct in_addr'.  */\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n# define __socklen_t_defined\n#endif\n\n__BEGIN_DECLS\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data in network byte order.  */\nextern in_addr_t inet_addr(const char *__cp) __THROW;\n\n/* Return the local host address part of the Internet address in IN.  */\nextern in_addr_t inet_lnaof(struct in_addr __in) __THROW;\n\n/* Make Internet host address in network byte order by combining the\n   network number NET with the local address HOST.  */\nextern struct in_addr inet_makeaddr(in_addr_t __net, in_addr_t __host) __THROW;\n\n/* Return network number part of the Internet address IN.  */\nextern in_addr_t inet_netof(struct in_addr __in) __THROW;\n\n/* Extract the network number in network byte order from the address\n   in numbers-and-dots natation starting at CP.  */\nextern in_addr_t inet_network(const char *__cp) __THROW;\n\n/* Convert Internet number in IN to ASCII representation.  The return value\n   is a pointer to an internal array containing the string.  */\nextern char *inet_ntoa(struct in_addr __in) __THROW;\n\n/* Convert from presentation format of an Internet number in buffer\n   starting at CP to the binary network format and store result for\n   interface type AF in buffer starting at BUF.  */\nextern int inet_pton(int __af, const char *__restrict __cp, void *__restrict __buf) __THROW;\n\n/* Convert a Internet address in binary network format for interface\n   type AF in buffer starting at CP to presentation form and place\n   result in buffer of length LEN astarting at BUF.  */\nextern const char *inet_ntop(int __af, const void *__restrict __cp, char *__restrict __buf, socklen_t __len) __THROW;\n\n/* The following functions are not part of XNS 5.2.  */\n#ifdef __USE_MISC\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data and store the result in the structure INP.  */\nextern int inet_aton(const char *__cp, struct in_addr *__inp) __THROW;\n\n/* Format a network number NET into presentation format and place result\n   in buffer starting at BUF with length of LEN bytes.  */\nextern char *inet_neta(in_addr_t __net, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF in buffer starting at\n   CP to presentation format.  The result will specifiy BITS bits of\n   the number.  */\nextern char *inet_net_ntop(int __af, const void *__cp, int __bits, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF from presentation in\n   buffer starting at CP to network format and store result int\n   buffer starting at BUF of size LEN.  */\nextern int inet_net_pton(int __af, const char *__cp, void *__buf, size_t __len) __THROW;\n\n/* Convert ASCII representation in hexadecimal form of the Internet\n   address to binary form and place result in buffer of length LEN\n   starting at BUF.  */\nextern unsigned int inet_nsap_addr(const char *__cp, unsigned char *__buf, int __len) __THROW;\n\n/* Convert internet address in binary form in LEN bytes starting at CP\n   a presentation form and place result in BUF.  */\nextern char *inet_nsap_ntoa(int __len, const unsigned char *__cp, char *__buf) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* arpa/inet.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/errno-base.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _ASM_GENERIC_ERRNO_BASE_H\n#define _ASM_GENERIC_ERRNO_BASE_H\n\n#define\tEPERM\t\t 1\t/* Operation not permitted */\n#define\tENOENT\t\t 2\t/* No such file or directory */\n#define\tESRCH\t\t 3\t/* No such process */\n#define\tEINTR\t\t 4\t/* Interrupted system call */\n#define\tEIO\t\t 5\t/* I/O error */\n#define\tENXIO\t\t 6\t/* No such device or address */\n#define\tE2BIG\t\t 7\t/* Argument list too long */\n#define\tENOEXEC\t\t 8\t/* Exec format error */\n#define\tEBADF\t\t 9\t/* Bad file number */\n#define\tECHILD\t\t10\t/* No child processes */\n#define\tEAGAIN\t\t11\t/* Try again */\n#define\tENOMEM\t\t12\t/* Out of memory */\n#define\tEACCES\t\t13\t/* Permission denied */\n#define\tEFAULT\t\t14\t/* Bad address */\n#define\tENOTBLK\t\t15\t/* Block device required */\n#define\tEBUSY\t\t16\t/* Device or resource busy */\n#define\tEEXIST\t\t17\t/* File exists */\n#define\tEXDEV\t\t18\t/* Cross-device link */\n#define\tENODEV\t\t19\t/* No such device */\n#define\tENOTDIR\t\t20\t/* Not a directory */\n#define\tEISDIR\t\t21\t/* Is a directory */\n#define\tEINVAL\t\t22\t/* Invalid argument */\n#define\tENFILE\t\t23\t/* File table overflow */\n#define\tEMFILE\t\t24\t/* Too many open files */\n#define\tENOTTY\t\t25\t/* Not a typewriter */\n#define\tETXTBSY\t\t26\t/* Text file busy */\n#define\tEFBIG\t\t27\t/* File too large */\n#define\tENOSPC\t\t28\t/* No space left on device */\n#define\tESPIPE\t\t29\t/* Illegal seek */\n#define\tEROFS\t\t30\t/* Read-only file system */\n#define\tEMLINK\t\t31\t/* Too many links */\n#define\tEPIPE\t\t32\t/* Broken pipe */\n#define\tEDOM\t\t33\t/* Math argument out of domain of func */\n#define\tERANGE\t\t34\t/* Math result not representable */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/errno.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _ASM_GENERIC_ERRNO_H\n#define _ASM_GENERIC_ERRNO_H\n\n#include <asm-generic/errno-base.h>\n\n#define\tEDEADLK\t\t35\t/* Resource deadlock would occur */\n#define\tENAMETOOLONG\t36\t/* File name too long */\n#define\tENOLCK\t\t37\t/* No record locks available */\n\n/*\n * This error code is special: arch syscall entry code will return\n * -ENOSYS if users try to call a syscall that doesn't exist.  To keep\n * failures of syscalls that really do exist distinguishable from\n * failures due to attempts to use a nonexistent syscall, syscall\n * implementations should refrain from returning -ENOSYS.\n */\n#define\tENOSYS\t\t38\t/* Invalid system call number */\n\n#define\tENOTEMPTY\t39\t/* Directory not empty */\n#define\tELOOP\t\t40\t/* Too many symbolic links encountered */\n#define\tEWOULDBLOCK\tEAGAIN\t/* Operation would block */\n#define\tENOMSG\t\t42\t/* No message of desired type */\n#define\tEIDRM\t\t43\t/* Identifier removed */\n#define\tECHRNG\t\t44\t/* Channel number out of range */\n#define\tEL2NSYNC\t45\t/* Level 2 not synchronized */\n#define\tEL3HLT\t\t46\t/* Level 3 halted */\n#define\tEL3RST\t\t47\t/* Level 3 reset */\n#define\tELNRNG\t\t48\t/* Link number out of range */\n#define\tEUNATCH\t\t49\t/* Protocol driver not attached */\n#define\tENOCSI\t\t50\t/* No CSI structure available */\n#define\tEL2HLT\t\t51\t/* Level 2 halted */\n#define\tEBADE\t\t52\t/* Invalid exchange */\n#define\tEBADR\t\t53\t/* Invalid request descriptor */\n#define\tEXFULL\t\t54\t/* Exchange full */\n#define\tENOANO\t\t55\t/* No anode */\n#define\tEBADRQC\t\t56\t/* Invalid request code */\n#define\tEBADSLT\t\t57\t/* Invalid slot */\n\n#define\tEDEADLOCK\tEDEADLK\n\n#define\tEBFONT\t\t59\t/* Bad font file format */\n#define\tENOSTR\t\t60\t/* Device not a stream */\n#define\tENODATA\t\t61\t/* No data available */\n#define\tETIME\t\t62\t/* Timer expired */\n#define\tENOSR\t\t63\t/* Out of streams resources */\n#define\tENONET\t\t64\t/* Machine is not on the network */\n#define\tENOPKG\t\t65\t/* Package not installed */\n#define\tEREMOTE\t\t66\t/* Object is remote */\n#define\tENOLINK\t\t67\t/* Link has been severed */\n#define\tEADV\t\t68\t/* Advertise error */\n#define\tESRMNT\t\t69\t/* Srmount error */\n#define\tECOMM\t\t70\t/* Communication error on send */\n#define\tEPROTO\t\t71\t/* Protocol error */\n#define\tEMULTIHOP\t72\t/* Multihop attempted */\n#define\tEDOTDOT\t\t73\t/* RFS specific error */\n#define\tEBADMSG\t\t74\t/* Not a data message */\n#define\tEOVERFLOW\t75\t/* Value too large for defined data type */\n#define\tENOTUNIQ\t76\t/* Name not unique on network */\n#define\tEBADFD\t\t77\t/* File descriptor in bad state */\n#define\tEREMCHG\t\t78\t/* Remote address changed */\n#define\tELIBACC\t\t79\t/* Can not access a needed shared library */\n#define\tELIBBAD\t\t80\t/* Accessing a corrupted shared library */\n#define\tELIBSCN\t\t81\t/* .lib section in a.out corrupted */\n#define\tELIBMAX\t\t82\t/* Attempting to link in too many shared libraries */\n#define\tELIBEXEC\t83\t/* Cannot exec a shared library directly */\n#define\tEILSEQ\t\t84\t/* Illegal byte sequence */\n#define\tERESTART\t85\t/* Interrupted system call should be restarted */\n#define\tESTRPIPE\t86\t/* Streams pipe error */\n#define\tEUSERS\t\t87\t/* Too many users */\n#define\tENOTSOCK\t88\t/* Socket operation on non-socket */\n#define\tEDESTADDRREQ\t89\t/* Destination address required */\n#define\tEMSGSIZE\t90\t/* Message too long */\n#define\tEPROTOTYPE\t91\t/* Protocol wrong type for socket */\n#define\tENOPROTOOPT\t92\t/* Protocol not available */\n#define\tEPROTONOSUPPORT\t93\t/* Protocol not supported */\n#define\tESOCKTNOSUPPORT\t94\t/* Socket type not supported */\n#define\tEOPNOTSUPP\t95\t/* Operation not supported on transport endpoint */\n#define\tEPFNOSUPPORT\t96\t/* Protocol family not supported */\n#define\tEAFNOSUPPORT\t97\t/* Address family not supported by protocol */\n#define\tEADDRINUSE\t98\t/* Address already in use */\n#define\tEADDRNOTAVAIL\t99\t/* Cannot assign requested address */\n#define\tENETDOWN\t100\t/* Network is down */\n#define\tENETUNREACH\t101\t/* Network is unreachable */\n#define\tENETRESET\t102\t/* Network dropped connection because of reset */\n#define\tECONNABORTED\t103\t/* Software caused connection abort */\n#define\tECONNRESET\t104\t/* Connection reset by peer */\n#define\tENOBUFS\t\t105\t/* No buffer space available */\n#define\tEISCONN\t\t106\t/* Transport endpoint is already connected */\n#define\tENOTCONN\t107\t/* Transport endpoint is not connected */\n#define\tESHUTDOWN\t108\t/* Cannot send after transport endpoint shutdown */\n#define\tETOOMANYREFS\t109\t/* Too many references: cannot splice */\n#define\tETIMEDOUT\t110\t/* Connection timed out */\n#define\tECONNREFUSED\t111\t/* Connection refused */\n#define\tEHOSTDOWN\t112\t/* Host is down */\n#define\tEHOSTUNREACH\t113\t/* No route to host */\n#define\tEALREADY\t114\t/* Operation already in progress */\n#define\tEINPROGRESS\t115\t/* Operation now in progress */\n#define\tESTALE\t\t116\t/* Stale file handle */\n#define\tEUCLEAN\t\t117\t/* Structure needs cleaning */\n#define\tENOTNAM\t\t118\t/* Not a XENIX named type file */\n#define\tENAVAIL\t\t119\t/* No XENIX semaphores available */\n#define\tEISNAM\t\t120\t/* Is a named type file */\n#define\tEREMOTEIO\t121\t/* Remote I/O error */\n#define\tEDQUOT\t\t122\t/* Quota exceeded */\n\n#define\tENOMEDIUM\t123\t/* No medium found */\n#define\tEMEDIUMTYPE\t124\t/* Wrong medium type */\n#define\tECANCELED\t125\t/* Operation Canceled */\n#define\tENOKEY\t\t126\t/* Required key not available */\n#define\tEKEYEXPIRED\t127\t/* Key has expired */\n#define\tEKEYREVOKED\t128\t/* Key has been revoked */\n#define\tEKEYREJECTED\t129\t/* Key was rejected by service */\n\n/* for robust mutexes */\n#define\tEOWNERDEAD\t130\t/* Owner died */\n#define\tENOTRECOVERABLE\t131\t/* State not recoverable */\n\n#define ERFKILL\t\t132\t/* Operation not possible due to RF-kill */\n\n#define EHWPOISON\t133\t/* Memory page has hardware error */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/ioctl.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _ASM_GENERIC_IOCTL_H\n#define _ASM_GENERIC_IOCTL_H\n\n/* ioctl command encoding: 32 bits total, command in lower 16 bits,\n * size of the parameter structure in the lower 14 bits of the\n * upper 16 bits.\n * Encoding the size of the parameter structure in the ioctl request\n * is useful for catching programs compiled with old versions\n * and to avoid overwriting user space outside the user buffer area.\n * The highest 2 bits are reserved for indicating the ``access mode''.\n * NOTE: This limits the max parameter size to 16kB -1 !\n */\n\n/*\n * The following is for compatibility across the various Linux\n * platforms.  The generic ioctl numbering scheme doesn't really enforce\n * a type field.  De facto, however, the top 8 bits of the lower 16\n * bits are indeed used as a type field, so we might just as well make\n * this explicit here.  Please be sure to use the decoding macros\n * below from now on.\n */\n#define _IOC_NRBITS\t8\n#define _IOC_TYPEBITS\t8\n\n/*\n * Let any architecture override either of the following before\n * including this file.\n */\n\n#ifndef _IOC_SIZEBITS\n# define _IOC_SIZEBITS\t14\n#endif\n\n#ifndef _IOC_DIRBITS\n# define _IOC_DIRBITS\t2\n#endif\n\n#define _IOC_NRMASK\t((1 << _IOC_NRBITS)-1)\n#define _IOC_TYPEMASK\t((1 << _IOC_TYPEBITS)-1)\n#define _IOC_SIZEMASK\t((1 << _IOC_SIZEBITS)-1)\n#define _IOC_DIRMASK\t((1 << _IOC_DIRBITS)-1)\n\n#define _IOC_NRSHIFT\t0\n#define _IOC_TYPESHIFT\t(_IOC_NRSHIFT+_IOC_NRBITS)\n#define _IOC_SIZESHIFT\t(_IOC_TYPESHIFT+_IOC_TYPEBITS)\n#define _IOC_DIRSHIFT\t(_IOC_SIZESHIFT+_IOC_SIZEBITS)\n\n/*\n * Direction bits, which any architecture can choose to override\n * before including this file.\n *\n * NOTE: _IOC_WRITE means userland is writing and kernel is\n * reading. _IOC_READ means userland is reading and kernel is writing.\n */\n\n#ifndef _IOC_NONE\n# define _IOC_NONE\t0U\n#endif\n\n#ifndef _IOC_WRITE\n# define _IOC_WRITE\t1U\n#endif\n\n#ifndef _IOC_READ\n# define _IOC_READ\t2U\n#endif\n\n#define _IOC(dir,type,nr,size) \\\n\t(((dir)  << _IOC_DIRSHIFT) | \\\n\t ((type) << _IOC_TYPESHIFT) | \\\n\t ((nr)   << _IOC_NRSHIFT) | \\\n\t ((size) << _IOC_SIZESHIFT))\n\n#define _IOC_TYPECHECK(t) (sizeof(t))\n\n/*\n * Used to create numbers.\n *\n * NOTE: _IOW means userland is writing and kernel is reading. _IOR\n * means userland is reading and kernel is writing.\n */\n#define _IO(type,nr)\t\t_IOC(_IOC_NONE,(type),(nr),0)\n#define _IOR(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOW(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOWR(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOR_BAD(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),sizeof(size))\n#define _IOW_BAD(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),sizeof(size))\n#define _IOWR_BAD(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))\n\n/* used to decode ioctl numbers.. */\n#define _IOC_DIR(nr)\t\t(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)\n#define _IOC_TYPE(nr)\t\t(((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)\n#define _IOC_NR(nr)\t\t(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)\n#define _IOC_SIZE(nr)\t\t(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)\n\n/* ...and for the drivers/sound files... */\n\n#define IOC_IN\t\t(_IOC_WRITE << _IOC_DIRSHIFT)\n#define IOC_OUT\t\t(_IOC_READ << _IOC_DIRSHIFT)\n#define IOC_INOUT\t((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)\n#define IOCSIZE_MASK\t(_IOC_SIZEMASK << _IOC_SIZESHIFT)\n#define IOCSIZE_SHIFT\t(_IOC_SIZESHIFT)\n\n#endif\t\t\t\t/* _ASM_GENERIC_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/ioctls.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef __ASM_GENERIC_IOCTLS_H\n#define __ASM_GENERIC_IOCTLS_H\n\n#include <linux/ioctl.h>\n\n/*\n * These are the most common definitions for tty ioctl numbers.\n * Most of them do not use the recommended _IOC(), but there is\n * probably some source code out there hardcoding the number,\n * so we might as well use them for all new platforms.\n *\n * The architectures that use different values here typically\n * try to be compatible with some Unix variants for the same\n * architecture.\n */\n\n/* 0x54 is just a magic number to make these relatively unique ('T') */\n\n#define TCGETS\t\t0x5401\n#define TCSETS\t\t0x5402\n#define TCSETSW\t\t0x5403\n#define TCSETSF\t\t0x5404\n#define TCGETA\t\t0x5405\n#define TCSETA\t\t0x5406\n#define TCSETAW\t\t0x5407\n#define TCSETAF\t\t0x5408\n#define TCSBRK\t\t0x5409\n#define TCXONC\t\t0x540A\n#define TCFLSH\t\t0x540B\n#define TIOCEXCL\t0x540C\n#define TIOCNXCL\t0x540D\n#define TIOCSCTTY\t0x540E\n#define TIOCGPGRP\t0x540F\n#define TIOCSPGRP\t0x5410\n#define TIOCOUTQ\t0x5411\n#define TIOCSTI\t\t0x5412\n#define TIOCGWINSZ\t0x5413\n#define TIOCSWINSZ\t0x5414\n#define TIOCMGET\t0x5415\n#define TIOCMBIS\t0x5416\n#define TIOCMBIC\t0x5417\n#define TIOCMSET\t0x5418\n#define TIOCGSOFTCAR\t0x5419\n#define TIOCSSOFTCAR\t0x541A\n#define FIONREAD\t0x541B\n#define TIOCINQ\t\tFIONREAD\n#define TIOCLINUX\t0x541C\n#define TIOCCONS\t0x541D\n#define TIOCGSERIAL\t0x541E\n#define TIOCSSERIAL\t0x541F\n#define TIOCPKT\t\t0x5420\n#define FIONBIO\t\t0x5421\n#define TIOCNOTTY\t0x5422\n#define TIOCSETD\t0x5423\n#define TIOCGETD\t0x5424\n#define TCSBRKP\t\t0x5425\t/* Needed for POSIX tcsendbreak() */\n#define TIOCSBRK\t0x5427\t/* BSD compatibility */\n#define TIOCCBRK\t0x5428\t/* BSD compatibility */\n#define TIOCGSID\t0x5429\t/* Return the session ID of FD */\n#define TCGETS2\t\t_IOR('T', 0x2A, struct termios2)\n#define TCSETS2\t\t_IOW('T', 0x2B, struct termios2)\n#define TCSETSW2\t_IOW('T', 0x2C, struct termios2)\n#define TCSETSF2\t_IOW('T', 0x2D, struct termios2)\n#define TIOCGRS485\t0x542E\n#ifndef TIOCSRS485\n#define TIOCSRS485\t0x542F\n#endif\n#define TIOCGPTN\t_IOR('T', 0x30, unsigned int)\t/* Get Pty Number (of pty-mux device) */\n#define TIOCSPTLCK\t_IOW('T', 0x31, int)\t/* Lock/unlock Pty */\n#define TIOCGDEV\t_IOR('T', 0x32, unsigned int)\t/* Get primary device node of /dev/console */\n#define TCGETX\t\t0x5432\t/* SYS5 TCGETX compatibility */\n#define TCSETX\t\t0x5433\n#define TCSETXF\t\t0x5434\n#define TCSETXW\t\t0x5435\n#define TIOCSIG\t\t_IOW('T', 0x36, int)\t/* pty: generate signal */\n#define TIOCVHANGUP\t0x5437\n#define TIOCGPKT\t_IOR('T', 0x38, int)\t/* Get packet mode state */\n#define TIOCGPTLCK\t_IOR('T', 0x39, int)\t/* Get Pty lock state */\n#define TIOCGEXCL\t_IOR('T', 0x40, int)\t/* Get exclusive mode state */\n#define TIOCGPTPEER\t_IO('T', 0x41)\t/* Safely open the slave */\n\n#define FIONCLEX\t0x5450\n#define FIOCLEX\t\t0x5451\n#define FIOASYNC\t0x5452\n#define TIOCSERCONFIG\t0x5453\n#define TIOCSERGWILD\t0x5454\n#define TIOCSERSWILD\t0x5455\n#define TIOCGLCKTRMIOS\t0x5456\n#define TIOCSLCKTRMIOS\t0x5457\n#define TIOCSERGSTRUCT\t0x5458\t/* For debugging only */\n#define TIOCSERGETLSR   0x5459\t/* Get line status register */\n#define TIOCSERGETMULTI 0x545A\t/* Get multiport config  */\n#define TIOCSERSETMULTI 0x545B\t/* Set multiport config */\n\n#define TIOCMIWAIT\t0x545C\t/* wait for a change on serial input line(s) */\n#define TIOCGICOUNT\t0x545D\t/* read serial port __inline__ interrupt counts */\n\n/*\n * Some arches already define FIOQSIZE due to a historical\n * conflict with a Hayes modem-specific ioctl value.\n */\n#ifndef FIOQSIZE\n# define FIOQSIZE\t0x5460\n#endif\n\n/* Used for packet mode */\n#define TIOCPKT_DATA\t\t 0\n#define TIOCPKT_FLUSHREAD\t 1\n#define TIOCPKT_FLUSHWRITE\t 2\n#define TIOCPKT_STOP\t\t 4\n#define TIOCPKT_START\t\t 8\n#define TIOCPKT_NOSTOP\t\t16\n#define TIOCPKT_DOSTOP\t\t32\n#define TIOCPKT_IOCTL\t\t64\n\n#define TIOCSER_TEMT\t0x01\t/* Transmitter physically empty */\n\n#endif\t\t\t\t/* __ASM_GENERIC_IOCTLS_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/param.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef __ASM_GENERIC_PARAM_H\n#define __ASM_GENERIC_PARAM_H\n\n#ifndef HZ\n#define HZ 100\n#endif\n\n#ifndef EXEC_PAGESIZE\n#define EXEC_PAGESIZE\t4096\n#endif\n\n#ifndef NOGROUP\n#define NOGROUP\t\t(-1)\n#endif\n\n#define MAXHOSTNAMELEN\t64\t/* max length of hostname */\n\n#endif\t\t\t\t/* __ASM_GENERIC_PARAM_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/socket.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef __ASM_GENERIC_SOCKET_H\n#define __ASM_GENERIC_SOCKET_H\n\n#include <asm/sockios.h>\n\n/* For setsockopt(2) */\n#define SOL_SOCKET\t1\n\n#define SO_DEBUG\t1\n#define SO_REUSEADDR\t2\n#define SO_TYPE\t\t3\n#define SO_ERROR\t4\n#define SO_DONTROUTE\t5\n#define SO_BROADCAST\t6\n#define SO_SNDBUF\t7\n#define SO_RCVBUF\t8\n#define SO_SNDBUFFORCE\t32\n#define SO_RCVBUFFORCE\t33\n#define SO_KEEPALIVE\t9\n#define SO_OOBINLINE\t10\n#define SO_NO_CHECK\t11\n#define SO_PRIORITY\t12\n#define SO_LINGER\t13\n#define SO_BSDCOMPAT\t14\n#define SO_REUSEPORT\t15\n#ifndef SO_PASSCRED\t\t/* powerpc only differs in these */\n#define SO_PASSCRED\t16\n#define SO_PEERCRED\t17\n#define SO_RCVLOWAT\t18\n#define SO_SNDLOWAT\t19\n#define SO_RCVTIMEO\t20\n#define SO_SNDTIMEO\t21\n#endif\n\n/* Security levels - as per NRL IPv6 - don't actually do anything */\n#define SO_SECURITY_AUTHENTICATION\t\t22\n#define SO_SECURITY_ENCRYPTION_TRANSPORT\t23\n#define SO_SECURITY_ENCRYPTION_NETWORK\t\t24\n\n#define SO_BINDTODEVICE\t25\n\n/* Socket filtering */\n#define SO_ATTACH_FILTER\t26\n#define SO_DETACH_FILTER\t27\n#define SO_GET_FILTER\t\tSO_ATTACH_FILTER\n\n#define SO_PEERNAME\t\t28\n#define SO_TIMESTAMP\t\t29\n#define SCM_TIMESTAMP\t\tSO_TIMESTAMP\n\n#define SO_ACCEPTCONN\t\t30\n\n#define SO_PEERSEC\t\t31\n#define SO_PASSSEC\t\t34\n#define SO_TIMESTAMPNS\t\t35\n#define SCM_TIMESTAMPNS\t\tSO_TIMESTAMPNS\n\n#define SO_MARK\t\t\t36\n\n#define SO_TIMESTAMPING\t\t37\n#define SCM_TIMESTAMPING\tSO_TIMESTAMPING\n\n#define SO_PROTOCOL\t\t38\n#define SO_DOMAIN\t\t39\n\n#define SO_RXQ_OVFL             40\n\n#define SO_WIFI_STATUS\t\t41\n#define SCM_WIFI_STATUS\tSO_WIFI_STATUS\n#define SO_PEEK_OFF\t\t42\n\n/* Instruct lower device to use last 4-bytes of skb data as FCS */\n#define SO_NOFCS\t\t43\n\n#define SO_LOCK_FILTER\t\t44\n\n#define SO_SELECT_ERR_QUEUE\t45\n\n#define SO_BUSY_POLL\t\t46\n\n#define SO_MAX_PACING_RATE\t47\n\n#define SO_BPF_EXTENSIONS\t48\n\n#define SO_INCOMING_CPU\t\t49\n\n#define SO_ATTACH_BPF\t\t50\n#define SO_DETACH_BPF\t\tSO_DETACH_FILTER\n\n#define SO_ATTACH_REUSEPORT_CBPF\t51\n#define SO_ATTACH_REUSEPORT_EBPF\t52\n\n#define SO_CNX_ADVICE\t\t53\n\n#define SCM_TIMESTAMPING_OPT_STATS\t54\n\n#define SO_MEMINFO\t\t55\n\n#define SO_INCOMING_NAPI_ID\t56\n\n#define SO_COOKIE\t\t57\n\n#define SCM_TIMESTAMPING_PKTINFO\t58\n\n#define SO_PEERGROUPS\t\t59\n\n#define SO_ZEROCOPY\t\t60\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKET_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/asm-generic/sockios.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef __ASM_GENERIC_SOCKIOS_H\n#define __ASM_GENERIC_SOCKIOS_H\n\n/* Socket-level I/O control calls. */\n#define FIOSETOWN\t0x8901\n#define SIOCSPGRP\t0x8902\n#define FIOGETOWN\t0x8903\n#define SIOCGPGRP\t0x8904\n#define SIOCATMARK\t0x8905\n#define SIOCGSTAMP\t0x8906\t/* Get stamp (timeval) */\n#define SIOCGSTAMPNS\t0x8907\t/* Get stamp (timespec) */\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKIOS_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/assert.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.2 Diagnostics\t<assert.h>\n */\n\n#ifdef\t_ASSERT_H\n\n# undef\t_ASSERT_H\n# undef\tassert\n# undef __ASSERT_VOID_CAST\n\n# ifdef\t__USE_GNU\n#  undef assert_perror\n# endif\n\n#endif\t\t\t\t/* assert.h      */\n\n#define\t_ASSERT_H\t1\n#include <features.h>\n\n#if defined __cplusplus && __GNUC_PREREQ (2,95)\n# define __ASSERT_VOID_CAST static_cast<void>\n#else\n# define __ASSERT_VOID_CAST (void)\n#endif\n\n/* void assert (int expression);\n\n   If NDEBUG is defined, do nothing.\n   If not, and EXPRESSION is zero, print an error message and abort.  */\n\n#ifdef\tNDEBUG\n\n# define assert(expr)\t\t(__ASSERT_VOID_CAST (0))\n\n/* void assert_perror (int errnum);\n\n   If NDEBUG is defined, do nothing.  If not, and ERRNUM is not zero, print an\n   error message with the error text for ERRNUM and abort.\n   (This is a GNU extension.) */\n\n# ifdef\t__USE_GNU\n#  define assert_perror(errnum)\t(__ASSERT_VOID_CAST (0))\n# endif\n\n#else\t\t\t\t/* Not NDEBUG.  */\n\n#ifndef _ASSERT_H_DECLS\n#define _ASSERT_H_DECLS\n__BEGIN_DECLS\n/* This prints an \"Assertion failed\" message and aborts.  */\nextern void __assert_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* Likewise, but prints the error text for ERRNUM.  */\nextern void __assert_perror_fail(int __errnum, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* The following is not at all used here but needed for standard\n   compliance.  */\nextern void __assert(const char *__assertion, const char *__file, int __line)\n__THROW __attribute__ ((__noreturn__));\n\n__END_DECLS\n#endif\t\t\t\t/* Not _ASSERT_H_DECLS */\n/* When possible, define assert so that it does not add extra\n   parentheses around EXPR.  Otherwise, those added parentheses would\n   suppress warnings we'd expect to be detected by gcc's -Wparentheses.  */\n# if defined __cplusplus\n#  define assert(expr)\t\t\t\t\t\t\t\\\n     (static_cast <bool> (expr)\t\t\t\t\t\t\\\n      ? void (0)\t\t\t\t\t\t\t\\\n      : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))\n# elif !defined __GNUC__ || defined __STRICT_ANSI__\n#  define assert(expr)\t\t\t\t\t\t\t\\\n    ((expr)\t\t\t\t\t\t\t\t\\\n     ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n     : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))\n# else\n/* The first occurrence of EXPR is not evaluated due to the sizeof,\n   but will trigger any pedantic warnings masked by the __extension__\n   for the second occurrence.  The ternary operator is required to\n   support function pointers and bit fields in this context, and to\n   suppress the evaluation of variable length arrays.  */\n#  define assert(expr)\t\t\t\t\t\t\t\\\n  ((void) sizeof ((expr) ? 1 : 0), __extension__ ({\t\t\t\\\n      if (expr)\t\t\t\t\t\t\t\t\\\n        ; /* empty */\t\t\t\t\t\t\t\\\n      else\t\t\t\t\t\t\t\t\\\n        __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);\t\\\n    }))\n# endif\n# ifdef\t__USE_GNU\n#  define assert_perror(errnum)\t\t\t\t\t\t\\\n  (!(errnum)\t\t\t\t\t\t\t\t\\\n   ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n   : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))\n# endif\n/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'\n   which contains the name of the function currently being defined.\n   This is broken in G++ before version 2.6.\n   C9x has a similar variable called __func__, but prefer the GCC one since\n   it demangles C++ function names.  */\n# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)\n#   define __ASSERT_FUNCTION\t__extension__ __PRETTY_FUNCTION__\n# else\n#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#   define __ASSERT_FUNCTION\t__func__\n#  else\n#   define __ASSERT_FUNCTION\t((const char *) 0)\n#  endif\n# endif\n#endif\t\t\t\t/* NDEBUG.  */\n#if defined __USE_ISOC11 && !defined __cplusplus\n# undef static_assert\n# define static_assert _Static_assert\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/ctype.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard 7.4: Character handling\t<ctype.h>\n */\n\n#ifndef\t_CTYPE_H\n#define\t_CTYPE_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n#ifndef _ISbit\n/* These are all the characteristics of characters.\n   If there get to be more than 16 distinct characteristics,\n   many things must be changed that use `unsigned short int's.\n\n   The characteristics are stored always in network byte order (big\n   endian).  We define the bit value interpretations here dependent on the\n   machine's byte order.  */\n# include <endian.h>\n# if __BYTE_ORDER == __BIG_ENDIAN\n#  define _ISbit(bit)\t(1 << (bit))\n# else\t\t\t\t/* __BYTE_ORDER == __LITTLE_ENDIAN */\n#  define _ISbit(bit)\t((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))\n# endif\n    enum {\n\t_ISupper = _ISbit(0),\t/* UPPERCASE.  */\n\t_ISlower = _ISbit(1),\t/* lowercase.  */\n\t_ISalpha = _ISbit(2),\t/* Alphabetic.  */\n\t_ISdigit = _ISbit(3),\t/* Numeric.  */\n\t_ISxdigit = _ISbit(4),\t/* Hexadecimal numeric.  */\n\t_ISspace = _ISbit(5),\t/* Whitespace.  */\n\t_ISprint = _ISbit(6),\t/* Printing.  */\n\t_ISgraph = _ISbit(7),\t/* Graphical.  */\n\t_ISblank = _ISbit(8),\t/* Blank (usually SPC and TAB).  */\n\t_IScntrl = _ISbit(9),\t/* Control character.  */\n\t_ISpunct = _ISbit(10),\t/* Punctuation.  */\n\t_ISalnum = _ISbit(11)\t/* Alphanumeric.  */\n};\n#endif\t\t\t\t/* ! _ISbit  */\n\n/* These are defined in ctype-info.c.\n   The declarations here must match those in localeinfo.h.\n\n   In the thread-specific locale model (see `uselocale' in <locale.h>)\n   we cannot use global variables for these as was done in the past.\n   Instead, the following accessor functions return the address of\n   each variable, which is local to the current thread if multithreaded.\n\n   These point into arrays of 384, so they can be indexed by any `unsigned\n   char' value [0,255]; by EOF (-1); or by any `signed char' value\n   [-128,-1).  ISO C requires that the ctype functions work for `unsigned\n   char' values and for EOF; we also support negative `signed char' values\n   for broken old programs.  The case conversion arrays are of `int's\n   rather than `unsigned char's because tolower (EOF) must be EOF, which\n   doesn't fit into an `unsigned char'.  But today more important is that\n   the arrays are also used for multi-byte character sets.  */\nextern const unsigned short int **__ctype_b_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_tolower_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_toupper_loc(void)\n__THROW __attribute__ ((__const__));\n\n#ifndef __cplusplus\n# define __isctype(c, type) \\\n  ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)\n#elif defined __USE_EXTERN_INLINES\n# define __isctype_f(type) \\\n  __extern_inline int\t\t\t\t\t\t\t      \\\n  is##type (int __c) __THROW\t\t\t\t\t\t      \\\n  {\t\t\t\t\t\t\t\t\t      \\\n    return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \\\n  }\n#endif\n\n#define\t__isascii(c)\t(((c) & ~0x7f) == 0)\t/* If C is a 7 bit value.  */\n#define\t__toascii(c)\t((c) & 0x7f)\t/* Mask off high bits.  */\n\n#define\t__exctype(name)\textern int name (int) __THROW\n\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype(isalnum);\n__exctype(isalpha);\n__exctype(iscntrl);\n__exctype(isdigit);\n__exctype(islower);\n__exctype(isgraph);\n__exctype(isprint);\n__exctype(ispunct);\n__exctype(isspace);\n__exctype(isupper);\n__exctype(isxdigit);\n\n/* Return the lowercase version of C.  */\nextern int tolower(int __c) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int toupper(int __c) __THROW;\n\n/* ISO C99 introduced one new function.  */\n#ifdef\t__USE_ISOC99\n__exctype(isblank);\n#endif\n\n#ifdef __USE_GNU\n/* Test C for a set of character classes according to MASK.  */\nextern int isctype(int __c, int __mask) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n\n/* Return nonzero iff C is in the ASCII set\n   (i.e., is no more than 7 bits wide).  */\nextern int isascii(int __c) __THROW;\n\n/* Return the part of C that is in the ASCII set\n   (i.e., the low-order 7 bits of C).  */\nextern int toascii(int __c) __THROW;\n\n/* These are the same as `toupper' and `tolower' except that they do not\n   check the argument for being in the range of a `char'.  */\n__exctype(_toupper);\n__exctype(_tolower);\n#endif\t\t\t\t/* Use X/Open or use misc.  */\n\n/* This code is needed for the optimized mapping functions.  */\n#define __tobody(c, f, a, args) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ int __res;\t\t\t\t\t\t\t      \\\n      if (sizeof (c) > 1)\t\t\t\t\t\t      \\\n\t{\t\t\t\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (c))\t\t\t\t\t      \\\n\t    {\t\t\t\t\t\t\t\t      \\\n\t      int __c = (c);\t\t\t\t\t\t      \\\n\t      __res = __c < -128 || __c > 255 ? __c : (a)[__c];\t\t      \\\n\t    }\t\t\t\t\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __res = f args;\t\t\t\t\t\t      \\\n\t}\t\t\t\t\t\t\t\t      \\\n      else\t\t\t\t\t\t\t\t      \\\n\t__res = (a)[(int) (c)];\t\t\t\t\t\t      \\\n      __res; }))\n\n#if !defined __NO_CTYPE\n# ifdef __isctype_f\n__isctype_f(alnum)\n    __isctype_f(alpha)\n    __isctype_f(cntrl)\n    __isctype_f(digit)\n    __isctype_f(lower)\n    __isctype_f(graph)\n    __isctype_f(print)\n    __isctype_f(punct)\n    __isctype_f(space)\n    __isctype_f(upper)\n    __isctype_f(xdigit)\n#  ifdef __USE_ISOC99\n    __isctype_f(blank)\n#  endif\n# elif defined __isctype\n# define isalnum(c)\t__isctype((c), _ISalnum)\n# define isalpha(c)\t__isctype((c), _ISalpha)\n# define iscntrl(c)\t__isctype((c), _IScntrl)\n# define isdigit(c)\t__isctype((c), _ISdigit)\n# define islower(c)\t__isctype((c), _ISlower)\n# define isgraph(c)\t__isctype((c), _ISgraph)\n# define isprint(c)\t__isctype((c), _ISprint)\n# define ispunct(c)\t__isctype((c), _ISpunct)\n# define isspace(c)\t__isctype((c), _ISspace)\n# define isupper(c)\t__isctype((c), _ISupper)\n# define isxdigit(c)\t__isctype((c), _ISxdigit)\n#  ifdef __USE_ISOC99\n#   define isblank(c)\t__isctype((c), _ISblank)\n#  endif\n# endif\n\n# ifdef __USE_EXTERN_INLINES\n__extern_inline int __NTH(tolower(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_tolower_loc())[__c] : __c;\n}\n\n__extern_inline int __NTH(toupper(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_toupper_loc())[__c] : __c;\n}\n# endif\n\n# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#  define tolower(c)\t__tobody (c, tolower, *__ctype_tolower_loc (), (c))\n#  define toupper(c)\t__tobody (c, toupper, *__ctype_toupper_loc (), (c))\n# endif\t\t\t\t/* Optimizing gcc */\n\n# if defined __USE_MISC || defined __USE_XOPEN\n#  define isascii(c)\t__isascii (c)\n#  define toascii(c)\t__toascii (c)\n\n#  define _tolower(c)\t((int) (*__ctype_tolower_loc ())[(int) (c)])\n#  define _toupper(c)\t((int) (*__ctype_toupper_loc ())[(int) (c)])\n# endif\n\n#endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#ifdef __USE_XOPEN2K8\n/* POSIX.1-2008 extended locale interface (see locale.h).  */\n# include <bits/types/locale_t.h>\n\n/* These definitions are similar to the ones above but all functions\n   take as an argument a handle for the locale which shall be used.  */\n#  define __isctype_l(c, type, locale) \\\n  ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)\n\n# define __exctype_l(name) \t\t\t\t\t\t      \\\n  extern int name (int, locale_t) __THROW\n\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c, locale_t *locale);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype_l(isalnum_l);\n__exctype_l(isalpha_l);\n__exctype_l(iscntrl_l);\n__exctype_l(isdigit_l);\n__exctype_l(islower_l);\n__exctype_l(isgraph_l);\n__exctype_l(isprint_l);\n__exctype_l(ispunct_l);\n__exctype_l(isspace_l);\n__exctype_l(isupper_l);\n__exctype_l(isxdigit_l);\n\n__exctype_l(isblank_l);\n\n/* Return the lowercase version of C in locale L.  */\nextern int __tolower_l(int __c, locale_t __l) __THROW;\nextern int tolower_l(int __c, locale_t __l) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int __toupper_l(int __c, locale_t __l) __THROW;\nextern int toupper_l(int __c, locale_t __l) __THROW;\n\n# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#  define __tolower_l(c, locale) \\\n  __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))\n#  define __toupper_l(c, locale) \\\n  __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))\n#  define tolower_l(c, locale)\t__tolower_l ((c), (locale))\n#  define toupper_l(c, locale)\t__toupper_l ((c), (locale))\n# endif\t\t\t\t/* Optimizing gcc */\n\n# ifndef __NO_CTYPE\n#  define __isalnum_l(c,l)\t__isctype_l((c), _ISalnum, (l))\n#  define __isalpha_l(c,l)\t__isctype_l((c), _ISalpha, (l))\n#  define __iscntrl_l(c,l)\t__isctype_l((c), _IScntrl, (l))\n#  define __isdigit_l(c,l)\t__isctype_l((c), _ISdigit, (l))\n#  define __islower_l(c,l)\t__isctype_l((c), _ISlower, (l))\n#  define __isgraph_l(c,l)\t__isctype_l((c), _ISgraph, (l))\n#  define __isprint_l(c,l)\t__isctype_l((c), _ISprint, (l))\n#  define __ispunct_l(c,l)\t__isctype_l((c), _ISpunct, (l))\n#  define __isspace_l(c,l)\t__isctype_l((c), _ISspace, (l))\n#  define __isupper_l(c,l)\t__isctype_l((c), _ISupper, (l))\n#  define __isxdigit_l(c,l)\t__isctype_l((c), _ISxdigit, (l))\n\n#  define __isblank_l(c,l)\t__isctype_l((c), _ISblank, (l))\n\n#  ifdef __USE_MISC\n#   define __isascii_l(c,l)\t((l), __isascii (c))\n#   define __toascii_l(c,l)\t((l), __toascii (c))\n#  endif\n\n#  define isalnum_l(c,l)\t__isalnum_l ((c), (l))\n#  define isalpha_l(c,l)\t__isalpha_l ((c), (l))\n#  define iscntrl_l(c,l)\t__iscntrl_l ((c), (l))\n#  define isdigit_l(c,l)\t__isdigit_l ((c), (l))\n#  define islower_l(c,l)\t__islower_l ((c), (l))\n#  define isgraph_l(c,l)\t__isgraph_l ((c), (l))\n#  define isprint_l(c,l)\t__isprint_l ((c), (l))\n#  define ispunct_l(c,l)\t__ispunct_l ((c), (l))\n#  define isspace_l(c,l)\t__isspace_l ((c), (l))\n#  define isupper_l(c,l)\t__isupper_l ((c), (l))\n#  define isxdigit_l(c,l)\t__isxdigit_l ((c), (l))\n\n#  define isblank_l(c,l)\t__isblank_l ((c), (l))\n\n#  ifdef __USE_MISC\n#   define isascii_l(c,l)\t__isascii_l ((c), (l))\n#   define toascii_l(c,l)\t__toascii_l ((c), (l))\n#  endif\n\n# endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#endif\t\t\t\t/* Use POSIX 2008.  */\n\n__END_DECLS\n#endif\t\t\t\t/* ctype.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/dirent.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.1.2 Directory Operations\t<dirent.h>\n */\n\n#ifndef\t_DIRENT_H\n#define\t_DIRENT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef __USE_XOPEN\n# ifndef __ino_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#  else\ntypedef __ino64_t ino_t;\n#  endif\n#  define __ino_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n#  define __ino64_t_defined\n# endif\n#endif\n\n/* This file defines `struct dirent'.\n\n   It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen'\n   member that gives the length of `d_name'.\n\n   It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen'\n   member that gives the size of the entire directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off'\n   member that gives the file offset of the next directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type'\n   member that gives the type of the file.\n */\n\n#include <bits/dirent.h>\n\n#if defined __USE_MISC && !defined d_fileno\n# define d_ino\td_fileno\t/* Backward compatibility.  */\n#endif\n\n/* These macros extract size information from a `struct dirent *'.\n   They may evaluate their argument multiple times, so it must not\n   have side effects.  Each of these may involve a relatively costly\n   call to `strlen' on some systems, so these values should be cached.\n\n   _D_EXACT_NAMLEN (DP)\treturns the length of DP->d_name, not including\n   its terminating null character.\n\n   _D_ALLOC_NAMLEN (DP)\treturns a size at least (_D_EXACT_NAMLEN (DP) + 1);\n   that is, the allocation size needed to hold the DP->d_name string.\n   Use this macro when you don't need the exact length, just an upper bound.\n   This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN.\n   */\n\n#ifdef _DIRENT_HAVE_D_NAMLEN\n# define _D_EXACT_NAMLEN(d) ((d)->d_namlen)\n# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)\n#else\n# define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name))\n# ifdef _DIRENT_HAVE_D_RECLEN\n#  define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])\n# else\n#  define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \\\n\t\t\t      _D_EXACT_NAMLEN (d) + 1)\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* File types for `d_type'.  */\nenum {\n\tDT_UNKNOWN = 0,\n# define DT_UNKNOWN\tDT_UNKNOWN\n\tDT_FIFO = 1,\n# define DT_FIFO\tDT_FIFO\n\tDT_CHR = 2,\n# define DT_CHR\t\tDT_CHR\n\tDT_DIR = 4,\n# define DT_DIR\t\tDT_DIR\n\tDT_BLK = 6,\n# define DT_BLK\t\tDT_BLK\n\tDT_REG = 8,\n# define DT_REG\t\tDT_REG\n\tDT_LNK = 10,\n# define DT_LNK\t\tDT_LNK\n\tDT_SOCK = 12,\n# define DT_SOCK\tDT_SOCK\n\tDT_WHT = 14\n# define DT_WHT\t\tDT_WHT\n};\n\n/* Convert between stat structure types and directory types.  */\n# define IFTODT(mode)\t(((mode) & 0170000) >> 12)\n# define DTTOIF(dirtype)\t((dirtype) << 12)\n#endif\n\n/* This is the data type of directory stream objects.\n   The actual structure is opaque to users.  */\ntypedef struct __dirstream DIR;\n\n/* Open a directory stream on NAME.\n   Return a DIR stream on the directory, or NULL if it could not be opened.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *opendir(const char *__name) __nonnull((1));\n\n#ifdef __USE_XOPEN2K8\n/* Same as opendir, but open the stream on the file descriptor FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *fdopendir(int __fd);\n#endif\n\n/* Close the directory stream DIRP.\n   Return 0 if successful, -1 if not.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int closedir(DIR * __dirp) __nonnull((1));\n\n/* Read a directory entry from DIRP.  Return a pointer to a `struct\n   dirent' describing the entry, or NULL for EOF or error.  The\n   storage returned may be overwritten by a later readdir call on the\n   same DIR stream.\n\n   If the Large File Support API is selected we have to use the\n   appropriate interface.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern struct dirent *readdir(DIR * __dirp) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern struct dirent *__REDIRECT(readdir, (DIR * __dirp), readdir64) __nonnull((1));\n# else\n#  define readdir readdir64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern struct dirent64 *readdir64(DIR * __dirp) __nonnull((1));\n#endif\n\n#ifdef __USE_POSIX\n/* Reentrant version of `readdir'.  Return in RESULT a pointer to the\n   next entry.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int readdir_r(DIR * __restrict __dirp, struct dirent *__restrict __entry, struct dirent **__restrict __result) __nonnull((1, 2, 3)) __attribute_deprecated__;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(readdir_r, (DIR * __restrict __dirp, struct dirent * __restrict __entry, struct dirent ** __restrict __result), readdir64_r) __nonnull((1, 2, 3)) __attribute_deprecated__;\n#  else\n#   define readdir_r readdir64_r\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int readdir64_r(DIR * __restrict __dirp, struct dirent64 *__restrict __entry, struct dirent64 **__restrict __result) __nonnull((1, 2, 3)) __attribute_deprecated__;\n# endif\n#endif\t\t\t\t/* POSIX or misc */\n\n/* Rewind DIRP to the beginning of the directory.  */\nextern void rewinddir(DIR * __dirp)\n__THROW __nonnull((1));\n\n#if defined __USE_MISC || defined __USE_XOPEN\n# include <bits/types.h>\n\n/* Seek to position POS on DIRP.  */\nextern void seekdir(DIR * __dirp, long int __pos)\n__THROW __nonnull((1));\n\n/* Return the current position of DIRP.  */\nextern long int telldir(DIR * __dirp)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K8\n\n/* Return the file descriptor used by DIRP.  */\nextern int dirfd(DIR * __dirp)\n__THROW __nonnull((1));\n\n# if defined __OPTIMIZE__ && defined _DIR_dirfd\n#  define dirfd(dirp)\t_DIR_dirfd (dirp)\n# endif\n\n# ifdef __USE_MISC\n#  ifndef MAXNAMLEN\n/* Get the definitions of the POSIX.1 limits.  */\n#  include <bits/posix1_lim.h>\n\n/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'.  */\n#   ifdef NAME_MAX\n#    define MAXNAMLEN\tNAME_MAX\n#   else\n#    define MAXNAMLEN\t255\n#   endif\n#  endif\n# endif\n\n# define __need_size_t\n# include <stddef.h>\n\n/* Scan the directory DIR, calling SELECTOR on each directory entry.\n   Entries for which SELECT returns nonzero are individually malloc'd,\n   sorted using qsort with CMP, and collected in a malloc'd array in\n   *NAMELIST.  Returns the number of entries selected, or -1 on error.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int scandir(const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(scandir, (const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandir64) __nonnull((1, 2));\n#  else\n#   define scandir scandir64\n#  endif\n# endif\n\n# if defined __USE_GNU && defined __USE_LARGEFILE64\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandir64(const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((1, 2));\n# endif\n\n# ifdef __USE_GNU\n/* Similar to `scandir' but a relative DIR name is interpreted relative\n   to the directory for which DFD is a descriptor.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#  ifndef __USE_FILE_OFFSET64\nextern int scandirat(int __dfd, const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((2, 3));\n#  else\n#   ifdef __REDIRECT\nextern int __REDIRECT(scandirat, (int __dfd, const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandirat64) __nonnull((2, 3));\n#   else\n#    define scandirat scandirat64\n#   endif\n#  endif\n\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandirat64(int __dfd, const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((2, 3));\n# endif\n\n/* Function to compare two `struct dirent's alphabetically.  */\n# ifndef __USE_FILE_OFFSET64\nextern int alphasort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT_NTH(alphasort, (const struct dirent ** __e1, const struct dirent ** __e2), alphasort64)\n__attribute_pure__ __nonnull((1, 2));\n#  else\n#   define alphasort alphasort64\n#  endif\n# endif\n\n# if defined __USE_GNU && defined __USE_LARGEFILE64\nextern int alphasort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\t\t\t\t/* Use XPG7.  */\n\n#ifdef __USE_MISC\n/* Read directory entries from FD into BUF, reading at most NBYTES.\n   Reading starts at offset *BASEP, and *BASEP is updated with the new\n   position after reading.  Returns the number of bytes read; zero when at\n   end of directory; or -1 for errors.  */\n# ifndef __USE_FILE_OFFSET64\nextern __ssize_t getdirentries(int __fd, char *__restrict __buf, size_t __nbytes, __off_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n# else\n#  ifdef __REDIRECT\nextern __ssize_t __REDIRECT_NTH(getdirentries, (int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep), getdirentries64) __nonnull((2, 4));\n#  else\n#   define getdirentries getdirentries64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern __ssize_t getdirentries64(int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_GNU\n/* Function to compare two `struct dirent's by name & version.  */\n# ifndef __USE_FILE_OFFSET64\nextern int versionsort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT_NTH(versionsort, (const struct dirent ** __e1, const struct dirent ** __e2), versionsort64)\n__attribute_pure__ __nonnull((1, 2));\n#  else\n#   define versionsort versionsort64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int versionsort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\t\t\t\t/* Use GNU.  */\n\n__END_DECLS\n#endif\t\t\t\t/* dirent.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/dlfcn.h",
    "content": "/* User functions for run-time dynamic loading.\n   Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_DLFCN_H\n#define\t_DLFCN_H 1\n\n#include <features.h>\n#define __need_size_t\n#include <stddef.h>\n\n/* Collect various system dependent definitions and declarations.  */\n#include <bits/dlfcn.h>\n\n#ifdef __USE_GNU\n/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT\n   the run-time address of the symbol called NAME in the next shared\n   object is returned.  The \"next\" relation is defined by the order\n   the shared objects were loaded.  */\n# define RTLD_NEXT\t((void *) -1l)\n\n/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT\n   the run-time address of the symbol called NAME in the global scope\n   is returned.  */\n# define RTLD_DEFAULT\t((void *) 0)\n\n/* Type for namespace indeces.  */\ntypedef long int Lmid_t;\n\n/* Special namespace ID values.  */\n# define LM_ID_BASE\t0\t/* Initial namespace.  */\n# define LM_ID_NEWLM\t-1\t/* For dlmopen: request new namespace.  */\n#endif\n\n__BEGIN_DECLS\n/* Open the shared object FILE and map it in; return a handle that can be\n   passed to `dlsym' to get symbol values from it.  */\nextern void *dlopen(const char *__file, int __mode) __THROWNL;\n\n/* Unmap and close a shared object opened by `dlopen'.\n   The handle cannot be used again after calling `dlclose'.  */\nextern int dlclose(void *__handle)\n__THROWNL __nonnull((1));\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME.  */\nextern void *dlsym(void *__restrict __handle, const char *__restrict __name)\n__THROW __nonnull((2));\n\n#ifdef __USE_GNU\n/* Like `dlopen', but request object to be allocated in a new namespace.  */\nextern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode) __THROWNL;\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME with VERSION.  */\nextern void *dlvsym(void *__restrict __handle, const char *__restrict __name, const char *__restrict __version)\n__THROW __nonnull((2, 3));\n#endif\n\n/* When any of the above functions fails, call this function\n   to return a string describing the error.  Each call resets\n   the error string so that a following call returns null.  */\nextern char *dlerror(void) __THROW;\n\n#ifdef __USE_GNU\n/* Structure containing information about object searched using\n   `dladdr'.  */\ntypedef struct {\n\tconst char *dli_fname;\t/* File name of defining object.  */\n\tvoid *dli_fbase;\t/* Load address of that object.  */\n\tconst char *dli_sname;\t/* Name of nearest symbol.  */\n\tvoid *dli_saddr;\t/* Exact value of nearest symbol.  */\n} Dl_info;\n\n/* Fill in *INFO with the following information about ADDRESS.\n   Returns 0 iff no shared object's segments contain that address.  */\nextern int dladdr(const void *__address, Dl_info * __info)\n__THROW __nonnull((2));\n\n/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS.  */\nextern int dladdr1(const void *__address, Dl_info * __info, void **__extra_info, int __flags)\n__THROW __nonnull((2));\n\n/* These are the possible values for the FLAGS argument to `dladdr1'.\n   This indicates what extra information is stored at *EXTRA_INFO.\n   It may also be zero, in which case the EXTRA_INFO argument is not used.  */\nenum {\n\t/* Matching symbol table entry (const ElfNN_Sym *).  */\n\tRTLD_DL_SYMENT = 1,\n\n\t/* The object containing the address (struct link_map *).  */\n\tRTLD_DL_LINKMAP = 2\n};\n\n/* Get information about the shared object HANDLE refers to.\n   REQUEST is from among the values below, and determines the use of ARG.\n\n   On success, returns zero.  On failure, returns -1 and records an error\n   message to be fetched with `dlerror'.  */\nextern int dlinfo(void *__restrict __handle, int __request, void *__restrict __arg)\n__THROW __nonnull((1, 3));\n\n/* These are the possible values for the REQUEST argument to `dlinfo'.  */\nenum {\n\t/* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there.  */\n\tRTLD_DI_LMID = 1,\n\n\t/* Treat ARG as `struct link_map **';\n\t   store the `struct link_map *' for HANDLE there.  */\n\tRTLD_DI_LINKMAP = 2,\n\n\tRTLD_DI_CONFIGADDR = 3,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the\n\t   directories that will be searched for dependencies of this object.\n\t   RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size'\n\t   entries to indicate the size of the buffer that must be passed to\n\t   RTLD_DI_SERINFO to fill in the full information.  */\n\tRTLD_DI_SERINFO = 4,\n\tRTLD_DI_SERINFOSIZE = 5,\n\n\t/* Treat ARG as `char *', and store there the directory name used to\n\t   expand $ORIGIN in this shared object's dependency file names.  */\n\tRTLD_DI_ORIGIN = 6,\n\n\tRTLD_DI_PROFILENAME = 7,\t/* Unsupported, defined by Solaris.  */\n\tRTLD_DI_PROFILEOUT = 8,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `size_t *', and store there the TLS module ID\n\t   of this object's PT_TLS segment, as used in TLS relocations;\n\t   store zero if this object does not define a PT_TLS segment.  */\n\tRTLD_DI_TLS_MODID = 9,\n\n\t/* Treat ARG as `void **', and store there a pointer to the calling\n\t   thread's TLS block corresponding to this object's PT_TLS segment.\n\t   Store a null pointer if this object does not define a PT_TLS\n\t   segment, or if the calling thread has not allocated a block for it.  */\n\tRTLD_DI_TLS_DATA = 10,\n\n\tRTLD_DI_MAX = 10\n};\n\n/* This is the type of elements in `Dl_serinfo', below.\n   The `dls_name' member points to space in the buffer passed to `dlinfo'.  */\ntypedef struct {\n\tchar *dls_name;\t\t/* Name of library search path directory.  */\n\tunsigned int dls_flags;\t/* Indicates where this directory came from. */\n} Dl_serpath;\n\n/* This is the structure that must be passed (by reference) to `dlinfo' for\n   the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests.  */\ntypedef struct {\n\tsize_t dls_size;\t/* Size in bytes of the whole buffer.  */\n\tunsigned int dls_cnt;\t/* Number of elements in `dls_serpath'.  */\n\tDl_serpath dls_serpath[1];\t/* Actually longer, dls_cnt elements.  */\n} Dl_serinfo;\n#endif\t\t\t\t/* __USE_GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* dlfcn.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/endian.h",
    "content": "/* Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ENDIAN_H\n#define\t_ENDIAN_H\t1\n\n#include <features.h>\n\n/* Definitions for byte order, according to significance of bytes,\n   from low addresses to high addresses.  The value is what you get by\n   putting '4' in the most significant byte, '3' in the second most\n   significant byte, '2' in the second least significant byte, and '1'\n   in the least significant byte, and then writing down one digit for\n   each byte, starting with the byte at the lowest address at the left,\n   and proceeding to the byte with the highest address at the right.  */\n\n#define\t__LITTLE_ENDIAN\t1234\n#define\t__BIG_ENDIAN\t4321\n#define\t__PDP_ENDIAN\t3412\n\n/* This file defines `__BYTE_ORDER' for the particular machine.  */\n#include <bits/endian.h>\n\n/* Some machines may need to use a different endianness for floating point\n   values.  */\n#ifndef __FLOAT_WORD_ORDER\n# define __FLOAT_WORD_ORDER __BYTE_ORDER\n#endif\n\n#ifdef\t__USE_MISC\n# define LITTLE_ENDIAN\t__LITTLE_ENDIAN\n# define BIG_ENDIAN\t__BIG_ENDIAN\n# define PDP_ENDIAN\t__PDP_ENDIAN\n# define BYTE_ORDER\t__BYTE_ORDER\n#endif\n\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n# define __LONG_LONG_PAIR(HI, LO) LO, HI\n#elif __BYTE_ORDER == __BIG_ENDIAN\n# define __LONG_LONG_PAIR(HI, LO) HI, LO\n#endif\n\n#if defined __USE_MISC && !defined __ASSEMBLER__\n/* Conversion interfaces.  */\n# include <bits/byteswap.h>\n# include <bits/uintn-identity.h>\n\n# if __BYTE_ORDER == __LITTLE_ENDIAN\n#  define htobe16(x) __bswap_16 (x)\n#  define htole16(x) __uint16_identity (x)\n#  define be16toh(x) __bswap_16 (x)\n#  define le16toh(x) __uint16_identity (x)\n\n#  define htobe32(x) __bswap_32 (x)\n#  define htole32(x) __uint32_identity (x)\n#  define be32toh(x) __bswap_32 (x)\n#  define le32toh(x) __uint32_identity (x)\n\n#  define htobe64(x) __bswap_64 (x)\n#  define htole64(x) __uint64_identity (x)\n#  define be64toh(x) __bswap_64 (x)\n#  define le64toh(x) __uint64_identity (x)\n\n# else\n#  define htobe16(x) __uint16_identity (x)\n#  define htole16(x) __bswap_16 (x)\n#  define be16toh(x) __uint16_identity (x)\n#  define le16toh(x) __bswap_16 (x)\n\n#  define htobe32(x) __uint32_identity (x)\n#  define htole32(x) __bswap_32 (x)\n#  define be32toh(x) __uint32_identity (x)\n#  define le32toh(x) __bswap_32 (x)\n\n#  define htobe64(x) __uint64_identity (x)\n#  define htole64(x) __bswap_64 (x)\n#  define be64toh(x) __uint64_identity (x)\n#  define le64toh(x) __bswap_64 (x)\n# endif\n#endif\n\n#endif\t\t\t\t/* endian.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/errno.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.5 Errors\t<errno.h>\n */\n\n#ifndef\t_ERRNO_H\n#define\t_ERRNO_H 1\n\n#include <features.h>\n\n/* The system-specific definitions of the E* constants, as macros.  */\n#include <bits/errno.h>\n\n/* When included from assembly language, this header only provides the\n   E* constants.  */\n#ifndef __ASSEMBLER__\n\n__BEGIN_DECLS\n/* The error code set by various library functions.  */\nextern int *__errno_location(void)\n__THROW __attribute_const__;\n# define errno (*__errno_location ())\n\n# ifdef __USE_GNU\n\n/* The full and simple forms of the name with which the program was\n   invoked.  These variables are set up automatically at startup based on\n   the value of argv[0].  */\nextern char *program_invocation_name;\nextern char *program_invocation_short_name;\n\n/* bits/errno.h may have defined this type.  If it didn't, provide a\n   fallback definition.  */\n#  ifndef __error_t_defined\n#   define __error_t_defined 1\ntypedef int error_t;\n#  endif\n\n# endif\t\t\t\t/* __USE_GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* !__ASSEMBLER__ */\n#endif\t\t\t\t/* errno.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/execinfo.h",
    "content": "/* Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _EXECINFO_H\n#define _EXECINFO_H 1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Store up to SIZE return address of the current program state in\n   ARRAY and return the exact number of values stored.  */\nextern int backtrace(void **__array, int __size) __nonnull((1));\n\n/* Return names of functions from the backtrace list in ARRAY in a newly\n   malloc()ed memory block.  */\nextern char **backtrace_symbols(void *const *__array, int __size)\n__THROW __nonnull((1));\n\n/* This function is similar to backtrace_symbols() but it writes the result\n   immediately to a file.  */\nextern void backtrace_symbols_fd(void *const *__array, int __size, int __fd)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* execinfo.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/fcntl.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 6.5 File Control Operations\t<fcntl.h>\n */\n\n#ifndef\t_FCNTL_H\n#define\t_FCNTL_H\t1\n\n#include <features.h>\n\n/* This must be early so <bits/fcntl.h> can define types winningly.  */\n__BEGIN_DECLS\n/* Get __mode_t, __dev_t and __off_t  .*/\n#include <bits/types.h>\n/* Get the definitions of O_*, F_*, FD_*: all the\n   numbers and flag bits for `open', `fcntl', et al.  */\n#include <bits/fcntl.h>\n/* Detect if open needs mode as a third argument (or for openat as a fourth\n   argument).  */\n#ifdef __O_TMPFILE\n# define __OPEN_NEEDS_MODE(oflag) \\\n  (((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)\n#else\n# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)\n#endif\n/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.\n   Earlier POSIX standards permitted any type ending in `_t' to be defined\n   by any POSIX header, so we don't conditionalize the definitions here.  */\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n/* For XPG all symbols from <sys/stat.h> should also be available.  */\n#ifdef __USE_XOPEN2K8\n# include <bits/types/struct_timespec.h>\n#endif\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# include <bits/stat.h>\n\n# define S_IFMT\t\t__S_IFMT\n# define S_IFDIR\t__S_IFDIR\n# define S_IFCHR\t__S_IFCHR\n# define S_IFBLK\t__S_IFBLK\n# define S_IFREG\t__S_IFREG\n# ifdef __S_IFIFO\n#  define S_IFIFO\t__S_IFIFO\n# endif\n# ifdef __S_IFLNK\n#  define S_IFLNK\t__S_IFLNK\n# endif\n# if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK\n#  define S_IFSOCK\t__S_IFSOCK\n# endif\n\n/* Protection bits.  */\n\n# define S_ISUID\t__S_ISUID\t/* Set user ID on execution.  */\n# define S_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n\n# if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n#  define S_ISVTX\t__S_ISVTX\n# endif\n\n# define S_IRUSR\t__S_IREAD\t/* Read by owner.  */\n# define S_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n# define S_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n# define S_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n\n# define S_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n# define S_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n# define S_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n# define S_IRWXG\t(S_IRWXU >> 3)\n\n# define S_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n# define S_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n# define S_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n# define S_IRWXO\t(S_IRWXG >> 3)\n#endif\n\n#ifdef\t__USE_MISC\n# ifndef R_OK\t\t\t/* Verbatim from <unistd.h>.  Ugh.  */\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#  define R_OK\t4\t\t/* Test for read permission.  */\n#  define W_OK\t2\t\t/* Test for write permission.  */\n#  define X_OK\t1\t\t/* Test for execute permission.  */\n#  define F_OK\t0\t\t/* Test for existence.  */\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n/* XPG wants the following symbols.   <stdio.h> has the same definitions.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# define SEEK_SET\t0\t/* Seek from beginning of file.  */\n# define SEEK_CUR\t1\t/* Seek from current position.  */\n# define SEEK_END\t2\t/* Seek from end of file.  */\n#endif\t\t\t\t/* XPG */\n\n/* Do the file control operation described by CMD on FD.\n   The remaining arguments are interpreted depending on CMD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fcntl(int __fd, int __cmd, ...);\n\n/* Open FILE and return a new file descriptor for it, or -1 on error.\n   OFLAG determines the type of access used.  If O_CREAT or O_TMPFILE is set\n   in OFLAG, the third argument is taken as a `mode_t', the mode of the\n   created file.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int open(const char *__file, int __oflag, ...) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(open, (const char *__file, int __oflag, ...), open64) __nonnull((1));\n# else\n#  define open open64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int open64(const char *__file, int __oflag, ...) __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to `open' but a relative path name is interpreted relative to\n   the directory for which FD is a descriptor.\n\n   NOTE: some other `openat' implementation support additional functionality\n   through this interface, especially using the O_XATTR flag.  This is not\n   yet supported here.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int openat(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(openat, (int __fd, const char *__file, int __oflag, ...), openat64) __nonnull((2));\n#  else\n#   define openat openat64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int openat64(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n# endif\n#endif\n\n/* Create and open FILE, with mode MODE.  This takes an `int' MODE\n   argument because that is what `mode_t' will be widened to.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int creat(const char *__file, mode_t __mode) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(creat, (const char *__file, mode_t __mode), creat64) __nonnull((1));\n# else\n#  define creat creat64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int creat64(const char *__file, mode_t __mode) __nonnull((1));\n#endif\n\n#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \\\n\t\t\t\t\t       && !defined __USE_POSIX))\n/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.  */\n\n# define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n# define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n# define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n# define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n# ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, off_t __len);\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64);\n#  else\n#   define lockf lockf64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, off64_t __len);\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Advice the system about the expected behaviour of the application with\n   respect to the file associated with FD.  */\n# ifndef __USE_FILE_OFFSET64\nextern int posix_fadvise(int __fd, off_t __offset, off_t __len, int __advise) __THROW;\n# else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(posix_fadvise, (int __fd, __off64_t __offset, __off64_t __len, int __advise), posix_fadvise64);\n#  else\n#   define posix_fadvise posix_fadvise64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int posix_fadvise64(int __fd, off64_t __offset, off64_t __len, int __advise) __THROW;\n# endif\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int posix_fallocate(int __fd, off_t __offset, off_t __len);\n# else\n# ifdef __REDIRECT\nextern int __REDIRECT(posix_fallocate, (int __fd, __off64_t __offset, __off64_t __len), posix_fallocate64);\n#  else\n#   define posix_fallocate posix_fallocate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int posix_fallocate64(int __fd, off64_t __offset, off64_t __len);\n# endif\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \\\n    && defined __va_arg_pack_len\n# include <bits/fcntl2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* fcntl.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/features.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FEATURES_H\n#define\t_FEATURES_H\t1\n\n/* These are defined by the user (or the compiler)\n   to specify the desired environment:\n\n   __STRICT_ANSI__\tISO Standard C.\n   _ISOC99_SOURCE\tExtensions to ISO C89 from ISO C99.\n   _ISOC11_SOURCE\tExtensions to ISO C99 from ISO C11.\n   __STDC_WANT_LIB_EXT2__\n\t\t\tExtensions to ISO C99 from TR 27431-2:2010.\n   __STDC_WANT_IEC_60559_BFP_EXT__\n\t\t\tExtensions to ISO C11 from TS 18661-1:2014.\n   __STDC_WANT_IEC_60559_FUNCS_EXT__\n\t\t\tExtensions to ISO C11 from TS 18661-4:2015.\n   __STDC_WANT_IEC_60559_TYPES_EXT__\n\t\t\tExtensions to ISO C11 from TS 18661-3:2015.\n\n   _POSIX_SOURCE\tIEEE Std 1003.1.\n   _POSIX_C_SOURCE\tIf ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;\n\t\t\tif >=199309L, add IEEE Std 1003.1b-1993;\n\t\t\tif >=199506L, add IEEE Std 1003.1c-1995;\n\t\t\tif >=200112L, all of IEEE 1003.1-2004\n\t\t\tif >=200809L, all of IEEE 1003.1-2008\n   _XOPEN_SOURCE\tIncludes POSIX and XPG things.  Set to 500 if\n\t\t\tSingle Unix conformance is wanted, to 600 for the\n\t\t\tsixth revision, to 700 for the seventh revision.\n   _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.\n   _LARGEFILE_SOURCE\tSome more functions for correct standard I/O.\n   _LARGEFILE64_SOURCE\tAdditional functionality from LFS for large files.\n   _FILE_OFFSET_BITS=N\tSelect default filesystem interface.\n   _ATFILE_SOURCE\tAdditional *at interfaces.\n   _GNU_SOURCE\t\tAll of the above, plus GNU extensions.\n   _DEFAULT_SOURCE\tThe default set of features (taking precedence over\n\t\t\t__STRICT_ANSI__).\n\n   _FORTIFY_SOURCE\tAdd security hardening to many library functions.\n\t\t\tSet to 1 or 2; 2 performs stricter checks than 1.\n\n   _REENTRANT, _THREAD_SAFE\n\t\t\tObsolete; equivalent to _POSIX_C_SOURCE=199506L.\n\n   The `-ansi' switch to the GNU C compiler, and standards conformance\n   options such as `-std=c99', define __STRICT_ANSI__.  If none of\n   these are defined, or if _DEFAULT_SOURCE is defined, the default is\n   to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to\n   200809L, as well as enabling miscellaneous functions from BSD and\n   SVID.  If more than one of these are defined, they accumulate.  For\n   example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together\n   give you ISO C, 1003.1, and 1003.2, but nothing else.\n\n   These are defined by this file and are used by the\n   header files to decide what to declare or define:\n\n   __GLIBC_USE (F)\tDefine things from feature set F.  This is defined\n\t\t\tto 1 or 0; the subsequent macros are either defined\n\t\t\tor undefined, and those tests should be moved to\n\t\t\t__GLIBC_USE.\n   __USE_ISOC11\t\tDefine ISO C11 things.\n   __USE_ISOC99\t\tDefine ISO C99 things.\n   __USE_ISOC95\t\tDefine ISO C90 AMD1 (C95) things.\n   __USE_ISOCXX11\tDefine ISO C++11 things.\n   __USE_POSIX\t\tDefine IEEE Std 1003.1 things.\n   __USE_POSIX2\t\tDefine IEEE Std 1003.2 things.\n   __USE_POSIX199309\tDefine IEEE Std 1003.1, and .1b things.\n   __USE_POSIX199506\tDefine IEEE Std 1003.1, .1b, .1c and .1i things.\n   __USE_XOPEN\t\tDefine XPG things.\n   __USE_XOPEN_EXTENDED\tDefine X/Open Unix things.\n   __USE_UNIX98\t\tDefine Single Unix V2 things.\n   __USE_XOPEN2K        Define XPG6 things.\n   __USE_XOPEN2KXSI     Define XPG6 XSI things.\n   __USE_XOPEN2K8       Define XPG7 things.\n   __USE_XOPEN2K8XSI    Define XPG7 XSI things.\n   __USE_LARGEFILE\tDefine correct standard I/O things.\n   __USE_LARGEFILE64\tDefine LFS things with separate names.\n   __USE_FILE_OFFSET64\tDefine 64bit interface as default.\n   __USE_MISC\t\tDefine things from 4.3BSD or System V Unix.\n   __USE_ATFILE\t\tDefine *at interfaces and AT_* constants for them.\n   __USE_GNU\t\tDefine GNU extensions.\n   __USE_FORTIFY_LEVEL\tAdditional security measures used, according to level.\n\n   The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are\n   defined by this file unconditionally.  `__GNU_LIBRARY__' is provided\n   only for compatibility.  All new code should use the other symbols\n   to test for features.\n\n   All macros listed above as possibly being defined by this file are\n   explicitly undefined if they are not explicitly defined.\n   Feature-test macros that are not defined by the user or compiler\n   but are implied by the other feature-test macros defined (or by the\n   lack of any definitions) are defined by the file.\n\n   ISO C feature test macros depend on the definition of the macro\n   when an affected header is included, not when the first system\n   header is included, and so they are handled in\n   <bits/libc-header-start.h>, which does not have a multiple include\n   guard.  Feature test macros that can be handled from the first\n   system header included are handled here.  */\n\n/* Undefine everything, so we get a clean slate.  */\n#undef\t__USE_ISOC11\n#undef\t__USE_ISOC99\n#undef\t__USE_ISOC95\n#undef\t__USE_ISOCXX11\n#undef\t__USE_POSIX\n#undef\t__USE_POSIX2\n#undef\t__USE_POSIX199309\n#undef\t__USE_POSIX199506\n#undef\t__USE_XOPEN\n#undef\t__USE_XOPEN_EXTENDED\n#undef\t__USE_UNIX98\n#undef\t__USE_XOPEN2K\n#undef\t__USE_XOPEN2KXSI\n#undef\t__USE_XOPEN2K8\n#undef\t__USE_XOPEN2K8XSI\n#undef\t__USE_LARGEFILE\n#undef\t__USE_LARGEFILE64\n#undef\t__USE_FILE_OFFSET64\n#undef\t__USE_MISC\n#undef\t__USE_ATFILE\n#undef\t__USE_GNU\n#undef\t__USE_FORTIFY_LEVEL\n#undef\t__KERNEL_STRICT_NAMES\n#undef\t__GLIBC_USE_DEPRECATED_GETS\n\n/* Suppress kernel-name space pollution unless user expressedly asks\n   for it.  */\n#ifndef _LOOSE_KERNEL_NAMES\n# define __KERNEL_STRICT_NAMES\n#endif\n\n/* Convenience macro to test the version of gcc.\n   Use like this:\n   #if __GNUC_PREREQ (2,8)\n   ... code requiring gcc 2.8 or later ...\n   #endif\n   Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was\n   added in 2.0.  */\n#if defined __GNUC__ && defined __GNUC_MINOR__\n# define __GNUC_PREREQ(maj, min) \\\n\t((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))\n#else\n# define __GNUC_PREREQ(maj, min) 0\n#endif\n\n/* Similarly for clang.  Features added to GCC after version 4.2 may\n   or may not also be available in clang, and clang's definitions of\n   __GNUC(_MINOR)__ are fixed at 4 and 2 respectively.  Not all such\n   features can be queried via __has_extension/__has_feature.  */\n#if defined __clang_major__ && defined __clang_minor__\n# define __glibc_clang_prereq(maj, min) \\\n  ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))\n#else\n# define __glibc_clang_prereq(maj, min) 0\n#endif\n\n/* Whether to use feature set F.  */\n#define __GLIBC_USE(F)\t__GLIBC_USE_ ## F\n\n/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for\n   _DEFAULT_SOURCE.  If _DEFAULT_SOURCE is present we do not\n   issue a warning; the expectation is that the source is being\n   transitioned to use the new macro.  */\n#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \\\n    && !defined _DEFAULT_SOURCE\n# warning \"_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE\"\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n#endif\n\n/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */\n#ifdef _GNU_SOURCE\n# undef  _ISOC95_SOURCE\n# define _ISOC95_SOURCE\t1\n# undef  _ISOC99_SOURCE\n# define _ISOC99_SOURCE\t1\n# undef  _ISOC11_SOURCE\n# define _ISOC11_SOURCE\t1\n# undef  _POSIX_SOURCE\n# define _POSIX_SOURCE\t1\n# undef  _POSIX_C_SOURCE\n# define _POSIX_C_SOURCE\t200809L\n# undef  _XOPEN_SOURCE\n# define _XOPEN_SOURCE\t700\n# undef  _XOPEN_SOURCE_EXTENDED\n# define _XOPEN_SOURCE_EXTENDED\t1\n# undef\t _LARGEFILE64_SOURCE\n# define _LARGEFILE64_SOURCE\t1\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n# undef  _ATFILE_SOURCE\n# define _ATFILE_SOURCE\t1\n#endif\n\n/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,\n   define _DEFAULT_SOURCE.  */\n#if (defined _DEFAULT_SOURCE\t\t\t\t\t\\\n     || (!defined __STRICT_ANSI__\t\t\t\t\\\n\t && !defined _ISOC99_SOURCE\t\t\t\t\\\n\t && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\t\\\n\t && !defined _XOPEN_SOURCE))\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n#endif\n\n/* This is to enable the ISO C11 extension.  */\n#if (defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))\n# define __USE_ISOC11\t1\n#endif\n\n/* This is to enable the ISO C99 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))\n# define __USE_ISOC99\t1\n#endif\n\n/* This is to enable the ISO C90 Amendment 1:1995 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))\n# define __USE_ISOC95\t1\n#endif\n\n#ifdef __cplusplus\n/* This is to enable compatibility for ISO C++17.  */\n# if __cplusplus >= 201703L\n#  define __USE_ISOC11\t1\n# endif\n/* This is to enable compatibility for ISO C++11.\n   Check the temporary macro for now, too.  */\n# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__\n#  define __USE_ISOCXX11\t1\n#  define __USE_ISOC99\t1\n# endif\n#endif\n\n/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE\n   is defined, use POSIX.1-2008 (or another version depending on\n   _XOPEN_SOURCE).  */\n#ifdef _DEFAULT_SOURCE\n# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\n#  define __USE_POSIX_IMPLICITLY\t1\n# endif\n# undef  _POSIX_SOURCE\n# define _POSIX_SOURCE\t1\n# undef  _POSIX_C_SOURCE\n# define _POSIX_C_SOURCE\t200809L\n#endif\n\n#if ((!defined __STRICT_ANSI__\t\t\t\t\t\\\n      || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500))\t\\\n     && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)\n# define _POSIX_SOURCE\t1\n# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500\n#  define _POSIX_C_SOURCE\t2\n# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600\n#  define _POSIX_C_SOURCE\t199506L\n# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700\n#  define _POSIX_C_SOURCE\t200112L\n# else\n#  define _POSIX_C_SOURCE\t200809L\n# endif\n# define __USE_POSIX_IMPLICITLY\t1\n#endif\n\n/* Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be\n   defined in all multithreaded code.  GNU libc has not required this\n   for many years.  We now treat them as compatibility synonyms for\n   _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with\n   comprehensive support for multithreaded code.  Using them never\n   lowers the selected level of POSIX conformance, only raises it.  */\n#if ((!defined _POSIX_C_SOURCE || (_POSIX_C_SOURCE - 0) < 199506L) \\\n     && (defined _REENTRANT || defined _THREAD_SAFE))\n# define _POSIX_SOURCE   1\n# undef  _POSIX_C_SOURCE\n# define _POSIX_C_SOURCE 199506L\n#endif\n\n#if (defined _POSIX_SOURCE\t\t\t\t\t\\\n     || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1)\t\\\n     || defined _XOPEN_SOURCE)\n# define __USE_POSIX\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE\n# define __USE_POSIX2\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L\n# define __USE_POSIX199309\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L\n# define __USE_POSIX199506\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L\n# define __USE_XOPEN2K\t\t1\n# undef __USE_ISOC95\n# define __USE_ISOC95\t\t1\n# undef __USE_ISOC99\n# define __USE_ISOC99\t\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L\n# define __USE_XOPEN2K8\t\t1\n# undef  _ATFILE_SOURCE\n# define _ATFILE_SOURCE\t1\n#endif\n\n#ifdef\t_XOPEN_SOURCE\n# define __USE_XOPEN\t1\n# if (_XOPEN_SOURCE - 0) >= 500\n#  define __USE_XOPEN_EXTENDED\t1\n#  define __USE_UNIX98\t1\n#  undef _LARGEFILE_SOURCE\n#  define _LARGEFILE_SOURCE\t1\n#  if (_XOPEN_SOURCE - 0) >= 600\n#   if (_XOPEN_SOURCE - 0) >= 700\n#    define __USE_XOPEN2K8\t1\n#    define __USE_XOPEN2K8XSI\t1\n#   endif\n#   define __USE_XOPEN2K\t1\n#   define __USE_XOPEN2KXSI\t1\n#   undef __USE_ISOC95\n#   define __USE_ISOC95\t\t1\n#   undef __USE_ISOC99\n#   define __USE_ISOC99\t\t1\n#  endif\n# else\n#  ifdef _XOPEN_SOURCE_EXTENDED\n#   define __USE_XOPEN_EXTENDED\t1\n#  endif\n# endif\n#endif\n\n#ifdef _LARGEFILE_SOURCE\n# define __USE_LARGEFILE\t1\n#endif\n\n#ifdef _LARGEFILE64_SOURCE\n# define __USE_LARGEFILE64\t1\n#endif\n\n#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64\n# define __USE_FILE_OFFSET64\t1\n#endif\n\n#if defined _DEFAULT_SOURCE\n# define __USE_MISC\t1\n#endif\n\n#ifdef\t_ATFILE_SOURCE\n# define __USE_ATFILE\t1\n#endif\n\n#ifdef\t_GNU_SOURCE\n# define __USE_GNU\t1\n#endif\n\n#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \\\n    && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0\n# if _FORTIFY_SOURCE > 1\n#  define __USE_FORTIFY_LEVEL 2\n# else\n#  define __USE_FORTIFY_LEVEL 1\n# endif\n#else\n# define __USE_FORTIFY_LEVEL 0\n#endif\n\n/* The function 'gets' existed in C89, but is impossible to use\n   safely.  It has been removed from ISO C11 and ISO C++14.  Note: for\n   compatibility with various implementations of <cstdio>, this test\n   must consider only the value of __cplusplus when compiling C++.  */\n#if defined __cplusplus ? __cplusplus >= 201402L : defined __USE_ISOC11\n# define __GLIBC_USE_DEPRECATED_GETS 0\n#else\n# define __GLIBC_USE_DEPRECATED_GETS 1\n#endif\n\n/* Get definitions of __STDC_* predefined macros, if the compiler has\n   not preincluded this header automatically.  */\n#include <stdc-predef.h>\n\n/* This macro indicates that the installed library is the GNU C Library.\n   For historic reasons the value now is 6 and this will stay from now\n   on.  The use of this variable is deprecated.  Use __GLIBC__ and\n   __GLIBC_MINOR__ now (see below) when you want to test for a specific\n   GNU C library version and use the values in <gnu/lib-names.h> to get\n   the sonames of the shared libraries.  */\n#undef  __GNU_LIBRARY__\n#define __GNU_LIBRARY__ 6\n\n/* Major and minor version number of the GNU C library package.  Use\n   these macros to test for features in specific releases.  */\n#define\t__GLIBC__\t2\n#define\t__GLIBC_MINOR__\t27\n\n#define __GLIBC_PREREQ(maj, min) \\\n\t((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))\n\n/* This is here only because every header file already includes this one.  */\n#ifndef __ASSEMBLER__\n# ifndef _SYS_CDEFS_H\n#  include <sys/cdefs.h>\n# endif\n\n/* If we don't have __REDIRECT, prototypes will be missing if\n   __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */\n# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT\n#  define __USE_LARGEFILE\t1\n#  define __USE_LARGEFILE64\t1\n# endif\n\n#endif\t\t\t\t/* !ASSEMBLER */\n\n/* Decide whether we can define 'extern inline' functions in headers.  */\n#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \\\n    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \\\n    && defined __extern_inline\n# define __USE_EXTERN_INLINES\t1\n#endif\n\n/* This is here only because every header file already includes this one.\n   Get the definitions of all the appropriate `__stub_FUNCTION' symbols.\n   <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub\n   that will always return failure (and set errno to ENOSYS).  */\n#include <gnu/stubs.h>\n\n#endif\t\t\t\t/* features.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/fts.h",
    "content": "/* File tree traversal functions declarations.\n   Copyright (C) 1994-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Copyright (c) 1989, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)fts.h\t8.3 (Berkeley) 8/14/94\n */\n\n#ifndef\t_FTS_H\n#define\t_FTS_H 1\n\n#include <features.h>\n#include <sys/types.h>\n\ntypedef struct {\n\tstruct _ftsent *fts_cur;\t/* current node */\n\tstruct _ftsent *fts_child;\t/* linked list of children */\n\tstruct _ftsent **fts_array;\t/* sort array */\n\tdev_t fts_dev;\t\t/* starting device # */\n\tchar *fts_path;\t\t/* path for this descent */\n\tint fts_rfd;\t\t/* fd for root */\n\tint fts_pathlen;\t/* sizeof(path) */\n\tint fts_nitems;\t\t/* elements in the sort array */\n\tint (*fts_compar) (const void *, const void *);\t/* compare fn */\n\n#define\tFTS_COMFOLLOW\t0x0001\t/* follow command line symlinks */\n#define\tFTS_LOGICAL\t0x0002\t/* logical walk */\n#define\tFTS_NOCHDIR\t0x0004\t/* don't change directories */\n#define\tFTS_NOSTAT\t0x0008\t/* don't get stat info */\n#define\tFTS_PHYSICAL\t0x0010\t/* physical walk */\n#define\tFTS_SEEDOT\t0x0020\t/* return dot and dot-dot */\n#define\tFTS_XDEV\t0x0040\t/* don't cross devices */\n#define FTS_WHITEOUT\t0x0080\t/* return whiteout information */\n#define\tFTS_OPTIONMASK\t0x00ff\t/* valid user option mask */\n\n#define\tFTS_NAMEONLY\t0x0100\t/* (private) child names only */\n#define\tFTS_STOP\t0x0200\t/* (private) unrecoverable error */\n\tint fts_options;\t/* fts_open options, global flags */\n} FTS;\n\n#ifdef __USE_LARGEFILE64\ntypedef struct {\n\tstruct _ftsent64 *fts_cur;\t/* current node */\n\tstruct _ftsent64 *fts_child;\t/* linked list of children */\n\tstruct _ftsent64 **fts_array;\t/* sort array */\n\tdev_t fts_dev;\t\t/* starting device # */\n\tchar *fts_path;\t\t/* path for this descent */\n\tint fts_rfd;\t\t/* fd for root */\n\tint fts_pathlen;\t/* sizeof(path) */\n\tint fts_nitems;\t\t/* elements in the sort array */\n\tint (*fts_compar) (const void *, const void *);\t/* compare fn */\n\tint fts_options;\t/* fts_open options, global flags */\n} FTS64;\n#endif\n\ntypedef struct _ftsent {\n\tstruct _ftsent *fts_cycle;\t/* cycle node */\n\tstruct _ftsent *fts_parent;\t/* parent directory */\n\tstruct _ftsent *fts_link;\t/* next file in directory */\n\tlong fts_number;\t/* local numeric value */\n\tvoid *fts_pointer;\t/* local address value */\n\tchar *fts_accpath;\t/* access path */\n\tchar *fts_path;\t\t/* root path */\n\tint fts_errno;\t\t/* errno for this node */\n\tint fts_symfd;\t\t/* fd for symlink */\n\tunsigned short fts_pathlen;\t/* strlen(fts_path) */\n\tunsigned short fts_namelen;\t/* strlen(fts_name) */\n\n\tino_t fts_ino;\t\t/* inode */\n\tdev_t fts_dev;\t\t/* device */\n\tnlink_t fts_nlink;\t/* link count */\n\n#define\tFTS_ROOTPARENTLEVEL\t-1\n#define\tFTS_ROOTLEVEL\t\t 0\n\tshort fts_level;\t/* depth (-1 to N) */\n\n#define\tFTS_D\t\t 1\t/* preorder directory */\n#define\tFTS_DC\t\t 2\t/* directory that causes cycles */\n#define\tFTS_DEFAULT\t 3\t/* none of the above */\n#define\tFTS_DNR\t\t 4\t/* unreadable directory */\n#define\tFTS_DOT\t\t 5\t/* dot or dot-dot */\n#define\tFTS_DP\t\t 6\t/* postorder directory */\n#define\tFTS_ERR\t\t 7\t/* error; errno is set */\n#define\tFTS_F\t\t 8\t/* regular file */\n#define\tFTS_INIT\t 9\t/* initialized only */\n#define\tFTS_NS\t\t10\t/* stat(2) failed */\n#define\tFTS_NSOK\t11\t/* no stat(2) requested */\n#define\tFTS_SL\t\t12\t/* symbolic link */\n#define\tFTS_SLNONE\t13\t/* symbolic link without target */\n#define FTS_W\t\t14\t/* whiteout object */\n\tunsigned short fts_info;\t/* user flags for FTSENT structure */\n\n#define\tFTS_DONTCHDIR\t 0x01\t/* don't chdir .. to the parent */\n#define\tFTS_SYMFOLLOW\t 0x02\t/* followed a symlink to get here */\n\tunsigned short fts_flags;\t/* private flags for FTSENT structure */\n\n#define\tFTS_AGAIN\t 1\t/* read node again */\n#define\tFTS_FOLLOW\t 2\t/* follow symbolic link */\n#define\tFTS_NOINSTR\t 3\t/* no instructions */\n#define\tFTS_SKIP\t 4\t/* discard node */\n\tunsigned short fts_instr;\t/* fts_set() instructions */\n\n\tstruct stat *fts_statp;\t/* stat(2) information */\n\tchar fts_name[1];\t/* file name */\n} FTSENT;\n\n#ifdef __USE_LARGEFILE64\ntypedef struct _ftsent64 {\n\tstruct _ftsent64 *fts_cycle;\t/* cycle node */\n\tstruct _ftsent64 *fts_parent;\t/* parent directory */\n\tstruct _ftsent64 *fts_link;\t/* next file in directory */\n\tlong fts_number;\t/* local numeric value */\n\tvoid *fts_pointer;\t/* local address value */\n\tchar *fts_accpath;\t/* access path */\n\tchar *fts_path;\t\t/* root path */\n\tint fts_errno;\t\t/* errno for this node */\n\tint fts_symfd;\t\t/* fd for symlink */\n\tunsigned short fts_pathlen;\t/* strlen(fts_path) */\n\tunsigned short fts_namelen;\t/* strlen(fts_name) */\n\n\tino64_t fts_ino;\t/* inode */\n\tdev_t fts_dev;\t\t/* device */\n\tnlink_t fts_nlink;\t/* link count */\n\n\tshort fts_level;\t/* depth (-1 to N) */\n\n\tunsigned short fts_info;\t/* user flags for FTSENT structure */\n\n\tunsigned short fts_flags;\t/* private flags for FTSENT structure */\n\n\tunsigned short fts_instr;\t/* fts_set() instructions */\n\n\tstruct stat64 *fts_statp;\t/* stat(2) information */\n\tchar fts_name[1];\t/* file name */\n} FTSENT64;\n#endif\n\n__BEGIN_DECLS\n#ifndef __USE_FILE_OFFSET64\n    FTSENT * fts_children(FTS *, int);\nint fts_close(FTS *);\nFTS *fts_open(char *const *, int, int (*)(const FTSENT **, const FTSENT **));\nFTSENT *fts_read(FTS *);\nint fts_set(FTS *, FTSENT *, int) __THROW;\n#else\n# ifdef __REDIRECT\n    FTSENT * __REDIRECT(fts_children, (FTS *, int), fts64_children);\nint __REDIRECT(fts_close, (FTS *), fts64_close);\nFTS *__REDIRECT(fts_open, (char *const *, int, int (*)(const FTSENT **, const FTSENT **)), fts64_open);\nFTSENT *__REDIRECT(fts_read, (FTS *), fts64_read);\nint __REDIRECT_NTH(fts_set, (FTS *, FTSENT *, int), fts64_set);\n# else\n#  define fts_children fts64_children\n#  define fts_close fts64_close\n#  define fts_open fts64_open\n#  define fts_read fts64_read\n#  define fts_set fts64_set\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\n    FTSENT64 * fts64_children(FTS64 *, int);\nint fts64_close(FTS64 *);\nFTS64 *fts64_open(char *const *, int, int (*)(const FTSENT64 **, const FTSENT64 **));\nFTSENT64 *fts64_read(FTS64 *);\nint fts64_set(FTS64 *, FTSENT64 *, int) __THROW;\n#endif\n__END_DECLS\n#endif\t\t\t\t/* fts.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/getopt.h",
    "content": "/* Declarations for getopt.\n   Copyright (C) 1989-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Unlike the bulk of the getopt implementation, this file is NOT part\n   of gnulib; gnulib also has a getopt.h but it is different.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_H\n#define _GETOPT_H 1\n\n#include <features.h>\n\n/* The type of the 'argv' argument to getopt_long and getopt_long_only\n   is properly 'char **', since both functions may write to the array\n   (in order to move all the options to the beginning).  However, for\n   compatibility with old versions of LSB, glibc has to use 'char *const *'\n   instead.  */\n#ifndef __getopt_argv_const\n# define __getopt_argv_const const\n#endif\n\n#include <bits/getopt_core.h>\n#include <bits/getopt_ext.h>\n\n#endif\t\t\t\t/* getopt.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/grp.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.1 Group Database Access\t<grp.h>\n */\n\n#ifndef\t_GRP_H\n#define\t_GRP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n/* For the Single Unix specification we must define this type here.  */\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined\ntypedef __gid_t gid_t;\n# define __gid_t_defined\n#endif\n\n/* The group structure.\t */\nstruct group {\n\tchar *gr_name;\t\t/* Group name.  */\n\tchar *gr_passwd;\t/* Password.    */\n\t__gid_t gr_gid;\t\t/* Group ID.    */\n\tchar **gr_mem;\t\t/* Member list. */\n};\n\n#ifdef __USE_MISC\n# include <bits/types/FILE.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setgrent(void);\n\n/* Close the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endgrent(void);\n\n/* Read an entry from the group-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read a group entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct group *fgetgrent(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putgrent(const struct group *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrgid(__gid_t __gid);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrnam(const char *__name);\n\n#ifdef __USE_POSIX\n\n# ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#  define NSS_BUFLEN_GROUP\t1024\n# endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\n\n# ifdef __USE_GNU\nextern int getgrent_r(struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n# endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrgid_r(__gid_t __gid, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrnam_r(const char *__restrict __name, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n# ifdef\t__USE_MISC\n/* Read a group entry from STREAM.  This function is not standardized\n   an probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetgrent_r(FILE * __restrict __stream, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n# endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef\t__USE_MISC\n\n# define __need_size_t\n# include <stddef.h>\n\n/* Set the group set for the current user to GROUPS (N of them).  */\nextern int setgroups(size_t __n, const __gid_t * __groups) __THROW;\n\n/* Store at most *NGROUPS members of the group set for USER into\n   *GROUPS.  Also include GROUP.  The actual number of groups found is\n   returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getgrouplist(const char *__user, __gid_t __group, __gid_t * __groups, int *__ngroups);\n\n/* Initialize the group set for the current user\n   by reading the group database and using all groups\n   of which USER is a member.  Also include GROUP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int initgroups(const char *__user, __gid_t __group);\n\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* grp.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/errno.h",
    "content": "#include <asm-generic/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/ioctl.h",
    "content": "#include <asm-generic/ioctl.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/ioctls.h",
    "content": "#include <asm-generic/ioctls.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/param.h",
    "content": "#include <asm-generic/param.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/socket.h",
    "content": "#include <asm-generic/socket.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/asm/sockios.h",
    "content": "#include <asm-generic/sockios.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/_G_config.h",
    "content": "/* This file is needed by libio to define various configuration parameters.\n   These are always the same in the GNU C library.  */\n\n#ifndef _BITS_G_CONFIG_H\n#define _BITS_G_CONFIG_H 1\n\n#if !defined _BITS_LIBIO_H && !defined _G_CONFIG_H\n# error \"Never include <bits/_G_config.h> directly; use <stdio.h> instead.\"\n#endif\n\n/* Define types for libio in terms of the standard internal type names.  */\n\n#include <bits/types.h>\n#define __need_size_t\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# define __need_wchar_t\n#endif\n#define __need_NULL\n#include <stddef.h>\n\n#include <bits/types/__mbstate_t.h>\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# include <bits/types/wint_t.h>\n#endif\n\ntypedef struct {\n\t__off_t __pos;\n\t__mbstate_t __state;\n} _G_fpos_t;\ntypedef struct {\n\t__off64_t __pos;\n\t__mbstate_t __state;\n} _G_fpos64_t;\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# include <gconv.h>\ntypedef union {\n\tstruct __gconv_info __cd;\n\tstruct {\n\t\tstruct __gconv_info __cd;\n\t\tstruct __gconv_step_data __data;\n\t} __combined;\n} _G_iconv_t;\n#endif\n\n/* These library features are always available in the GNU C library.  */\n#define _G_va_list __gnuc_va_list\n\n#define _G_HAVE_MMAP 1\n#define _G_HAVE_MREMAP 1\n\n#define _G_IO_IO_FILE_VERSION 0x20001\n\n/* This is defined by <bits/stat.h> if `st_blksize' exists.  */\n#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)\n\n#define _G_BUFSIZ 8192\n\n#endif\t\t\t\t/* bits/_G_config.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/byteswap-16.h",
    "content": "/* Macros to swap the order of bytes in 16-bit integer values.\n   Copyright (C) 2012-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_BYTESWAP_H\n# error \"Never use <bits/byteswap-16.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifdef __GNUC__\n# if __GNUC__ >= 2\n#  define __bswap_16(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned short int __v, __x = (unsigned short int) (x);\t      \\\n\t if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t   __v = __bswap_constant_16 (__x);\t\t\t\t      \\\n\t else\t\t\t\t\t\t\t\t      \\\n\t   __asm__ (\"rorw $8, %w0\"\t\t\t\t\t      \\\n\t\t    : \"=r\" (__v)\t\t\t\t\t      \\\n\t\t    : \"0\" (__x)\t\t\t\t\t\t      \\\n\t\t    : \"cc\");\t\t\t\t\t\t      \\\n\t __v; }))\n# else\n/* This is better than nothing.  */\n#  define __bswap_16(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned short int __x = (unsigned short int) (x);\t\t      \\\n\t __bswap_constant_16 (__x); }))\n# endif\n#else\nstatic __inline unsigned short int __bswap_16(unsigned short int __bsx)\n{\n\treturn __bswap_constant_16(__bsx);\n}\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/byteswap.h",
    "content": "/* Macros to swap the order of bytes in integer values.\n   Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H\n# error \"Never use <bits/byteswap.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifndef _BITS_BYTESWAP_H\n#define _BITS_BYTESWAP_H 1\n\n#include <features.h>\n#include <bits/types.h>\n#include <bits/wordsize.h>\n\n/* Swap bytes in 16 bit value.  */\n#define __bswap_constant_16(x) \\\n     ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))\n\n/* Get __bswap_16.  */\n#include <bits/byteswap-16.h>\n\n/* Swap bytes in 32 bit value.  */\n#define __bswap_constant_32(x) \\\n     ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |\t\t      \\\n      (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))\n\n#ifdef __GNUC__\n# if __GNUC_PREREQ (4, 3)\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __builtin_bswap32(__bsx);\n}\n# elif __GNUC__ >= 2\n#  if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__\t      \\\n\t\t\t   || defined __pentiumpro__ || defined __pentium4__  \\\n\t\t\t   || defined __k8__ || defined __athlon__\t      \\\n\t\t\t   || defined __k6__ || defined __nocona__\t      \\\n\t\t\t   || defined __core2__ || defined __geode__\t      \\\n\t\t\t   || defined __amdfam10__)\n/* To swap the bytes in a word the i486 processors and up provide the\n   `bswap' opcode.  On i386 we have to use three instructions.  */\n#   define __bswap_32(x) \\\n      (__extension__\t\t\t\t\t\t\t      \\\n       ({ unsigned int __v, __x = (x);\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t    __v = __bswap_constant_32 (__x);\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __asm__ (\"bswap %0\" : \"=r\" (__v) : \"0\" (__x));\t\t      \\\n\t  __v; }))\n#  else\n#   define __bswap_32(x)\t\t\t\t\t\t      \\\n      (__extension__\t\t\t\t\t\t\t      \\\n       ({ unsigned int __v, __x = (x);\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t    __v = __bswap_constant_32 (__x);\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __asm__ (\"rorw $8, %w0;\"\t\t\t\t\t      \\\n\t\t     \"rorl $16, %0;\"\t\t\t\t\t      \\\n\t\t     \"rorw $8, %w0\"\t\t\t\t\t      \\\n\t\t     : \"=r\" (__v)\t\t\t\t\t      \\\n\t\t     : \"0\" (__x)\t\t\t\t\t      \\\n\t\t     : \"cc\");\t\t\t\t\t\t      \\\n\t  __v; }))\n#  endif\n# else\n#  define __bswap_32(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned int __x = (x); __bswap_constant_32 (__x); }))\n# endif\n#else\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __bswap_constant_32(__bsx);\n}\n#endif\n\n#if __GNUC_PREREQ (2, 0)\n/* Swap bytes in 64 bit value.  */\n# define __bswap_constant_64(x) \\\n     (__extension__ ((((x) & 0xff00000000000000ull) >> 56)\t\t      \\\n\t\t     | (((x) & 0x00ff000000000000ull) >> 40)\t\t      \\\n\t\t     | (((x) & 0x0000ff0000000000ull) >> 24)\t\t      \\\n\t\t     | (((x) & 0x000000ff00000000ull) >> 8)\t\t      \\\n\t\t     | (((x) & 0x00000000ff000000ull) << 8)\t\t      \\\n\t\t     | (((x) & 0x0000000000ff0000ull) << 24)\t\t      \\\n\t\t     | (((x) & 0x000000000000ff00ull) << 40)\t\t      \\\n\t\t     | (((x) & 0x00000000000000ffull) << 56)))\n\n# if __GNUC_PREREQ (4, 3)\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __builtin_bswap64(__bsx);\n}\n# elif __WORDSIZE == 64\n#  define __bswap_64(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ __uint64_t __v, __x = (x);\t\t\t\t\t      \\\n\t if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t   __v = __bswap_constant_64 (__x);\t\t\t\t      \\\n\t else\t\t\t\t\t\t\t\t      \\\n\t   __asm__ (\"bswap %q0\" : \"=r\" (__v) : \"0\" (__x));\t\t      \\\n\t __v; }))\n# else\n#  define __bswap_64(x) \\\n     (__extension__                                                           \\\n      ({ union { __extension__ __uint64_t __ll;\t\t                      \\\n\t\t unsigned int __l[2]; } __w, __r;                             \\\n\t if (__builtin_constant_p (x))                                        \\\n\t   __r.__ll = __bswap_constant_64 (x);                                \\\n\t else                                                                 \\\n\t   {                                                                  \\\n\t     __w.__ll = (x);                                                  \\\n\t     __r.__l[0] = __bswap_32 (__w.__l[1]);                            \\\n\t     __r.__l[1] = __bswap_32 (__w.__l[0]);                            \\\n\t   }                                                                  \\\n\t __r.__ll; }))\n# endif\n#else\n# define __bswap_constant_64(x) \\\n     ((((x) & 0xff00000000000000ull) >> 56)\t\t\t\t      \\\n      | (((x) & 0x00ff000000000000ull) >> 40)\t\t\t\t      \\\n      | (((x) & 0x0000ff0000000000ull) >> 24)\t\t\t\t      \\\n      | (((x) & 0x000000ff00000000ull) >> 8)\t\t\t\t      \\\n      | (((x) & 0x00000000ff000000ull) << 8)\t\t\t\t      \\\n      | (((x) & 0x0000000000ff0000ull) << 24)\t\t\t\t      \\\n      | (((x) & 0x000000000000ff00ull) << 40)\t\t\t\t      \\\n      | (((x) & 0x00000000000000ffull) << 56))\n\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __bswap_constant_64(__bsx);\n}\n#endif\n\n#endif\t\t\t\t/* _BITS_BYTESWAP_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/confname.h",
    "content": "/* `sysconf', `pathconf', and `confstr' NAME values.  Generic version.\n   Copyright (C) 1993-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n# error \"Never use <bits/confname.h> directly; include <unistd.h> instead.\"\n#endif\n\n/* Values for the NAME argument to `pathconf' and `fpathconf'.  */\nenum {\n\t_PC_LINK_MAX,\n#define\t_PC_LINK_MAX\t\t\t_PC_LINK_MAX\n\t_PC_MAX_CANON,\n#define\t_PC_MAX_CANON\t\t\t_PC_MAX_CANON\n\t_PC_MAX_INPUT,\n#define\t_PC_MAX_INPUT\t\t\t_PC_MAX_INPUT\n\t_PC_NAME_MAX,\n#define\t_PC_NAME_MAX\t\t\t_PC_NAME_MAX\n\t_PC_PATH_MAX,\n#define\t_PC_PATH_MAX\t\t\t_PC_PATH_MAX\n\t_PC_PIPE_BUF,\n#define\t_PC_PIPE_BUF\t\t\t_PC_PIPE_BUF\n\t_PC_CHOWN_RESTRICTED,\n#define\t_PC_CHOWN_RESTRICTED\t\t_PC_CHOWN_RESTRICTED\n\t_PC_NO_TRUNC,\n#define\t_PC_NO_TRUNC\t\t\t_PC_NO_TRUNC\n\t_PC_VDISABLE,\n#define _PC_VDISABLE\t\t\t_PC_VDISABLE\n\t_PC_SYNC_IO,\n#define\t_PC_SYNC_IO\t\t\t_PC_SYNC_IO\n\t_PC_ASYNC_IO,\n#define\t_PC_ASYNC_IO\t\t\t_PC_ASYNC_IO\n\t_PC_PRIO_IO,\n#define\t_PC_PRIO_IO\t\t\t_PC_PRIO_IO\n\t_PC_SOCK_MAXBUF,\n#define\t_PC_SOCK_MAXBUF\t\t\t_PC_SOCK_MAXBUF\n\t_PC_FILESIZEBITS,\n#define _PC_FILESIZEBITS\t\t_PC_FILESIZEBITS\n\t_PC_REC_INCR_XFER_SIZE,\n#define _PC_REC_INCR_XFER_SIZE\t\t_PC_REC_INCR_XFER_SIZE\n\t_PC_REC_MAX_XFER_SIZE,\n#define _PC_REC_MAX_XFER_SIZE\t\t_PC_REC_MAX_XFER_SIZE\n\t_PC_REC_MIN_XFER_SIZE,\n#define _PC_REC_MIN_XFER_SIZE\t\t_PC_REC_MIN_XFER_SIZE\n\t_PC_REC_XFER_ALIGN,\n#define _PC_REC_XFER_ALIGN\t\t_PC_REC_XFER_ALIGN\n\t_PC_ALLOC_SIZE_MIN,\n#define _PC_ALLOC_SIZE_MIN\t\t_PC_ALLOC_SIZE_MIN\n\t_PC_SYMLINK_MAX,\n#define _PC_SYMLINK_MAX\t\t\t_PC_SYMLINK_MAX\n\t_PC_2_SYMLINKS\n#define _PC_2_SYMLINKS\t\t\t_PC_2_SYMLINKS\n};\n\n/* Values for the argument to `sysconf'.  */\nenum {\n\t_SC_ARG_MAX,\n#define\t_SC_ARG_MAX\t\t\t_SC_ARG_MAX\n\t_SC_CHILD_MAX,\n#define\t_SC_CHILD_MAX\t\t\t_SC_CHILD_MAX\n\t_SC_CLK_TCK,\n#define\t_SC_CLK_TCK\t\t\t_SC_CLK_TCK\n\t_SC_NGROUPS_MAX,\n#define\t_SC_NGROUPS_MAX\t\t\t_SC_NGROUPS_MAX\n\t_SC_OPEN_MAX,\n#define\t_SC_OPEN_MAX\t\t\t_SC_OPEN_MAX\n\t_SC_STREAM_MAX,\n#define\t_SC_STREAM_MAX\t\t\t_SC_STREAM_MAX\n\t_SC_TZNAME_MAX,\n#define\t_SC_TZNAME_MAX\t\t\t_SC_TZNAME_MAX\n\t_SC_JOB_CONTROL,\n#define\t_SC_JOB_CONTROL\t\t\t_SC_JOB_CONTROL\n\t_SC_SAVED_IDS,\n#define\t_SC_SAVED_IDS\t\t\t_SC_SAVED_IDS\n\t_SC_REALTIME_SIGNALS,\n#define\t_SC_REALTIME_SIGNALS\t\t_SC_REALTIME_SIGNALS\n\t_SC_PRIORITY_SCHEDULING,\n#define\t_SC_PRIORITY_SCHEDULING\t\t_SC_PRIORITY_SCHEDULING\n\t_SC_TIMERS,\n#define\t_SC_TIMERS\t\t\t_SC_TIMERS\n\t_SC_ASYNCHRONOUS_IO,\n#define\t_SC_ASYNCHRONOUS_IO\t\t_SC_ASYNCHRONOUS_IO\n\t_SC_PRIORITIZED_IO,\n#define\t_SC_PRIORITIZED_IO\t\t_SC_PRIORITIZED_IO\n\t_SC_SYNCHRONIZED_IO,\n#define\t_SC_SYNCHRONIZED_IO\t\t_SC_SYNCHRONIZED_IO\n\t_SC_FSYNC,\n#define\t_SC_FSYNC\t\t\t_SC_FSYNC\n\t_SC_MAPPED_FILES,\n#define\t_SC_MAPPED_FILES\t\t_SC_MAPPED_FILES\n\t_SC_MEMLOCK,\n#define\t_SC_MEMLOCK\t\t\t_SC_MEMLOCK\n\t_SC_MEMLOCK_RANGE,\n#define\t_SC_MEMLOCK_RANGE\t\t_SC_MEMLOCK_RANGE\n\t_SC_MEMORY_PROTECTION,\n#define\t_SC_MEMORY_PROTECTION\t\t_SC_MEMORY_PROTECTION\n\t_SC_MESSAGE_PASSING,\n#define\t_SC_MESSAGE_PASSING\t\t_SC_MESSAGE_PASSING\n\t_SC_SEMAPHORES,\n#define\t_SC_SEMAPHORES\t\t\t_SC_SEMAPHORES\n\t_SC_SHARED_MEMORY_OBJECTS,\n#define\t_SC_SHARED_MEMORY_OBJECTS\t_SC_SHARED_MEMORY_OBJECTS\n\t_SC_AIO_LISTIO_MAX,\n#define\t_SC_AIO_LISTIO_MAX\t\t_SC_AIO_LISTIO_MAX\n\t_SC_AIO_MAX,\n#define\t_SC_AIO_MAX\t\t\t_SC_AIO_MAX\n\t_SC_AIO_PRIO_DELTA_MAX,\n#define\t_SC_AIO_PRIO_DELTA_MAX\t\t_SC_AIO_PRIO_DELTA_MAX\n\t_SC_DELAYTIMER_MAX,\n#define\t_SC_DELAYTIMER_MAX\t\t_SC_DELAYTIMER_MAX\n\t_SC_MQ_OPEN_MAX,\n#define\t_SC_MQ_OPEN_MAX\t\t\t_SC_MQ_OPEN_MAX\n\t_SC_MQ_PRIO_MAX,\n#define\t_SC_MQ_PRIO_MAX\t\t\t_SC_MQ_PRIO_MAX\n\t_SC_VERSION,\n#define\t_SC_VERSION\t\t\t_SC_VERSION\n\t_SC_PAGESIZE,\n#define\t_SC_PAGESIZE\t\t\t_SC_PAGESIZE\n#define\t_SC_PAGE_SIZE\t\t\t_SC_PAGESIZE\n\t_SC_RTSIG_MAX,\n#define\t_SC_RTSIG_MAX\t\t\t_SC_RTSIG_MAX\n\t_SC_SEM_NSEMS_MAX,\n#define\t_SC_SEM_NSEMS_MAX\t\t_SC_SEM_NSEMS_MAX\n\t_SC_SEM_VALUE_MAX,\n#define\t_SC_SEM_VALUE_MAX\t\t_SC_SEM_VALUE_MAX\n\t_SC_SIGQUEUE_MAX,\n#define\t_SC_SIGQUEUE_MAX\t\t_SC_SIGQUEUE_MAX\n\t_SC_TIMER_MAX,\n#define\t_SC_TIMER_MAX\t\t\t_SC_TIMER_MAX\n\n\t/* Values for the argument to `sysconf'\n\t   corresponding to _POSIX2_* symbols.  */\n\t_SC_BC_BASE_MAX,\n#define\t_SC_BC_BASE_MAX\t\t\t_SC_BC_BASE_MAX\n\t_SC_BC_DIM_MAX,\n#define\t_SC_BC_DIM_MAX\t\t\t_SC_BC_DIM_MAX\n\t_SC_BC_SCALE_MAX,\n#define\t_SC_BC_SCALE_MAX\t\t_SC_BC_SCALE_MAX\n\t_SC_BC_STRING_MAX,\n#define\t_SC_BC_STRING_MAX\t\t_SC_BC_STRING_MAX\n\t_SC_COLL_WEIGHTS_MAX,\n#define\t_SC_COLL_WEIGHTS_MAX\t\t_SC_COLL_WEIGHTS_MAX\n\t_SC_EQUIV_CLASS_MAX,\n#define\t_SC_EQUIV_CLASS_MAX\t\t_SC_EQUIV_CLASS_MAX\n\t_SC_EXPR_NEST_MAX,\n#define\t_SC_EXPR_NEST_MAX\t\t_SC_EXPR_NEST_MAX\n\t_SC_LINE_MAX,\n#define\t_SC_LINE_MAX\t\t\t_SC_LINE_MAX\n\t_SC_RE_DUP_MAX,\n#define\t_SC_RE_DUP_MAX\t\t\t_SC_RE_DUP_MAX\n\t_SC_CHARCLASS_NAME_MAX,\n#define\t_SC_CHARCLASS_NAME_MAX\t\t_SC_CHARCLASS_NAME_MAX\n\n\t_SC_2_VERSION,\n#define\t_SC_2_VERSION\t\t\t_SC_2_VERSION\n\t_SC_2_C_BIND,\n#define\t_SC_2_C_BIND\t\t\t_SC_2_C_BIND\n\t_SC_2_C_DEV,\n#define\t_SC_2_C_DEV\t\t\t_SC_2_C_DEV\n\t_SC_2_FORT_DEV,\n#define\t_SC_2_FORT_DEV\t\t\t_SC_2_FORT_DEV\n\t_SC_2_FORT_RUN,\n#define\t_SC_2_FORT_RUN\t\t\t_SC_2_FORT_RUN\n\t_SC_2_SW_DEV,\n#define\t_SC_2_SW_DEV\t\t\t_SC_2_SW_DEV\n\t_SC_2_LOCALEDEF,\n#define\t_SC_2_LOCALEDEF\t\t\t_SC_2_LOCALEDEF\n\n\t_SC_PII,\n#define\t_SC_PII\t\t\t\t_SC_PII\n\t_SC_PII_XTI,\n#define\t_SC_PII_XTI\t\t\t_SC_PII_XTI\n\t_SC_PII_SOCKET,\n#define\t_SC_PII_SOCKET\t\t\t_SC_PII_SOCKET\n\t_SC_PII_INTERNET,\n#define\t_SC_PII_INTERNET\t\t_SC_PII_INTERNET\n\t_SC_PII_OSI,\n#define\t_SC_PII_OSI\t\t\t_SC_PII_OSI\n\t_SC_POLL,\n#define\t_SC_POLL\t\t\t_SC_POLL\n\t_SC_SELECT,\n#define\t_SC_SELECT\t\t\t_SC_SELECT\n\t_SC_UIO_MAXIOV,\n#define\t_SC_UIO_MAXIOV\t\t\t_SC_UIO_MAXIOV\n\t_SC_IOV_MAX = _SC_UIO_MAXIOV,\n#define _SC_IOV_MAX\t\t\t_SC_IOV_MAX\n\t_SC_PII_INTERNET_STREAM,\n#define\t_SC_PII_INTERNET_STREAM\t\t_SC_PII_INTERNET_STREAM\n\t_SC_PII_INTERNET_DGRAM,\n#define\t_SC_PII_INTERNET_DGRAM\t\t_SC_PII_INTERNET_DGRAM\n\t_SC_PII_OSI_COTS,\n#define\t_SC_PII_OSI_COTS\t\t_SC_PII_OSI_COTS\n\t_SC_PII_OSI_CLTS,\n#define\t_SC_PII_OSI_CLTS\t\t_SC_PII_OSI_CLTS\n\t_SC_PII_OSI_M,\n#define\t_SC_PII_OSI_M\t\t\t_SC_PII_OSI_M\n\t_SC_T_IOV_MAX,\n#define\t_SC_T_IOV_MAX\t\t\t_SC_T_IOV_MAX\n\n\t/* Values according to POSIX 1003.1c (POSIX threads).  */\n\t_SC_THREADS,\n#define\t_SC_THREADS\t\t\t_SC_THREADS\n\t_SC_THREAD_SAFE_FUNCTIONS,\n#define _SC_THREAD_SAFE_FUNCTIONS\t_SC_THREAD_SAFE_FUNCTIONS\n\t_SC_GETGR_R_SIZE_MAX,\n#define\t_SC_GETGR_R_SIZE_MAX\t\t_SC_GETGR_R_SIZE_MAX\n\t_SC_GETPW_R_SIZE_MAX,\n#define\t_SC_GETPW_R_SIZE_MAX\t\t_SC_GETPW_R_SIZE_MAX\n\t_SC_LOGIN_NAME_MAX,\n#define\t_SC_LOGIN_NAME_MAX\t\t_SC_LOGIN_NAME_MAX\n\t_SC_TTY_NAME_MAX,\n#define\t_SC_TTY_NAME_MAX\t\t_SC_TTY_NAME_MAX\n\t_SC_THREAD_DESTRUCTOR_ITERATIONS,\n#define\t_SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS\n\t_SC_THREAD_KEYS_MAX,\n#define\t_SC_THREAD_KEYS_MAX\t\t_SC_THREAD_KEYS_MAX\n\t_SC_THREAD_STACK_MIN,\n#define\t_SC_THREAD_STACK_MIN\t\t_SC_THREAD_STACK_MIN\n\t_SC_THREAD_THREADS_MAX,\n#define\t_SC_THREAD_THREADS_MAX\t\t_SC_THREAD_THREADS_MAX\n\t_SC_THREAD_ATTR_STACKADDR,\n#define\t_SC_THREAD_ATTR_STACKADDR\t_SC_THREAD_ATTR_STACKADDR\n\t_SC_THREAD_ATTR_STACKSIZE,\n#define\t_SC_THREAD_ATTR_STACKSIZE\t_SC_THREAD_ATTR_STACKSIZE\n\t_SC_THREAD_PRIORITY_SCHEDULING,\n#define\t_SC_THREAD_PRIORITY_SCHEDULING\t_SC_THREAD_PRIORITY_SCHEDULING\n\t_SC_THREAD_PRIO_INHERIT,\n#define\t_SC_THREAD_PRIO_INHERIT\t\t_SC_THREAD_PRIO_INHERIT\n\t_SC_THREAD_PRIO_PROTECT,\n#define\t_SC_THREAD_PRIO_PROTECT\t\t_SC_THREAD_PRIO_PROTECT\n\t_SC_THREAD_PROCESS_SHARED,\n#define\t_SC_THREAD_PROCESS_SHARED\t_SC_THREAD_PROCESS_SHARED\n\n\t_SC_NPROCESSORS_CONF,\n#define _SC_NPROCESSORS_CONF\t\t_SC_NPROCESSORS_CONF\n\t_SC_NPROCESSORS_ONLN,\n#define _SC_NPROCESSORS_ONLN\t\t_SC_NPROCESSORS_ONLN\n\t_SC_PHYS_PAGES,\n#define _SC_PHYS_PAGES\t\t\t_SC_PHYS_PAGES\n\t_SC_AVPHYS_PAGES,\n#define _SC_AVPHYS_PAGES\t\t_SC_AVPHYS_PAGES\n\t_SC_ATEXIT_MAX,\n#define _SC_ATEXIT_MAX\t\t\t_SC_ATEXIT_MAX\n\t_SC_PASS_MAX,\n#define _SC_PASS_MAX\t\t\t_SC_PASS_MAX\n\n\t_SC_XOPEN_VERSION,\n#define _SC_XOPEN_VERSION\t\t_SC_XOPEN_VERSION\n\t_SC_XOPEN_XCU_VERSION,\n#define _SC_XOPEN_XCU_VERSION\t\t_SC_XOPEN_XCU_VERSION\n\t_SC_XOPEN_UNIX,\n#define _SC_XOPEN_UNIX\t\t\t_SC_XOPEN_UNIX\n\t_SC_XOPEN_CRYPT,\n#define _SC_XOPEN_CRYPT\t\t\t_SC_XOPEN_CRYPT\n\t_SC_XOPEN_ENH_I18N,\n#define _SC_XOPEN_ENH_I18N\t\t_SC_XOPEN_ENH_I18N\n\t_SC_XOPEN_SHM,\n#define _SC_XOPEN_SHM\t\t\t_SC_XOPEN_SHM\n\n\t_SC_2_CHAR_TERM,\n#define _SC_2_CHAR_TERM\t\t\t_SC_2_CHAR_TERM\n\t_SC_2_C_VERSION,\n#define _SC_2_C_VERSION\t\t\t_SC_2_C_VERSION\n\t_SC_2_UPE,\n#define _SC_2_UPE\t\t\t_SC_2_UPE\n\n\t_SC_XOPEN_XPG2,\n#define _SC_XOPEN_XPG2\t\t\t_SC_XOPEN_XPG2\n\t_SC_XOPEN_XPG3,\n#define _SC_XOPEN_XPG3\t\t\t_SC_XOPEN_XPG3\n\t_SC_XOPEN_XPG4,\n#define _SC_XOPEN_XPG4\t\t\t_SC_XOPEN_XPG4\n\n\t_SC_CHAR_BIT,\n#define\t_SC_CHAR_BIT\t\t\t_SC_CHAR_BIT\n\t_SC_CHAR_MAX,\n#define\t_SC_CHAR_MAX\t\t\t_SC_CHAR_MAX\n\t_SC_CHAR_MIN,\n#define\t_SC_CHAR_MIN\t\t\t_SC_CHAR_MIN\n\t_SC_INT_MAX,\n#define\t_SC_INT_MAX\t\t\t_SC_INT_MAX\n\t_SC_INT_MIN,\n#define\t_SC_INT_MIN\t\t\t_SC_INT_MIN\n\t_SC_LONG_BIT,\n#define\t_SC_LONG_BIT\t\t\t_SC_LONG_BIT\n\t_SC_WORD_BIT,\n#define\t_SC_WORD_BIT\t\t\t_SC_WORD_BIT\n\t_SC_MB_LEN_MAX,\n#define\t_SC_MB_LEN_MAX\t\t\t_SC_MB_LEN_MAX\n\t_SC_NZERO,\n#define\t_SC_NZERO\t\t\t_SC_NZERO\n\t_SC_SSIZE_MAX,\n#define\t_SC_SSIZE_MAX\t\t\t_SC_SSIZE_MAX\n\t_SC_SCHAR_MAX,\n#define\t_SC_SCHAR_MAX\t\t\t_SC_SCHAR_MAX\n\t_SC_SCHAR_MIN,\n#define\t_SC_SCHAR_MIN\t\t\t_SC_SCHAR_MIN\n\t_SC_SHRT_MAX,\n#define\t_SC_SHRT_MAX\t\t\t_SC_SHRT_MAX\n\t_SC_SHRT_MIN,\n#define\t_SC_SHRT_MIN\t\t\t_SC_SHRT_MIN\n\t_SC_UCHAR_MAX,\n#define\t_SC_UCHAR_MAX\t\t\t_SC_UCHAR_MAX\n\t_SC_UINT_MAX,\n#define\t_SC_UINT_MAX\t\t\t_SC_UINT_MAX\n\t_SC_ULONG_MAX,\n#define\t_SC_ULONG_MAX\t\t\t_SC_ULONG_MAX\n\t_SC_USHRT_MAX,\n#define\t_SC_USHRT_MAX\t\t\t_SC_USHRT_MAX\n\n\t_SC_NL_ARGMAX,\n#define\t_SC_NL_ARGMAX\t\t\t_SC_NL_ARGMAX\n\t_SC_NL_LANGMAX,\n#define\t_SC_NL_LANGMAX\t\t\t_SC_NL_LANGMAX\n\t_SC_NL_MSGMAX,\n#define\t_SC_NL_MSGMAX\t\t\t_SC_NL_MSGMAX\n\t_SC_NL_NMAX,\n#define\t_SC_NL_NMAX\t\t\t_SC_NL_NMAX\n\t_SC_NL_SETMAX,\n#define\t_SC_NL_SETMAX\t\t\t_SC_NL_SETMAX\n\t_SC_NL_TEXTMAX,\n#define\t_SC_NL_TEXTMAX\t\t\t_SC_NL_TEXTMAX\n\n\t_SC_XBS5_ILP32_OFF32,\n#define _SC_XBS5_ILP32_OFF32\t\t_SC_XBS5_ILP32_OFF32\n\t_SC_XBS5_ILP32_OFFBIG,\n#define _SC_XBS5_ILP32_OFFBIG\t\t_SC_XBS5_ILP32_OFFBIG\n\t_SC_XBS5_LP64_OFF64,\n#define _SC_XBS5_LP64_OFF64\t\t_SC_XBS5_LP64_OFF64\n\t_SC_XBS5_LPBIG_OFFBIG,\n#define _SC_XBS5_LPBIG_OFFBIG\t\t_SC_XBS5_LPBIG_OFFBIG\n\n\t_SC_XOPEN_LEGACY,\n#define _SC_XOPEN_LEGACY\t\t_SC_XOPEN_LEGACY\n\t_SC_XOPEN_REALTIME,\n#define _SC_XOPEN_REALTIME\t\t_SC_XOPEN_REALTIME\n\t_SC_XOPEN_REALTIME_THREADS,\n#define _SC_XOPEN_REALTIME_THREADS\t_SC_XOPEN_REALTIME_THREADS\n\n\t_SC_ADVISORY_INFO,\n#define _SC_ADVISORY_INFO\t\t_SC_ADVISORY_INFO\n\t_SC_BARRIERS,\n#define _SC_BARRIERS\t\t\t_SC_BARRIERS\n\t_SC_BASE,\n#define _SC_BASE\t\t\t_SC_BASE\n\t_SC_C_LANG_SUPPORT,\n#define _SC_C_LANG_SUPPORT\t\t_SC_C_LANG_SUPPORT\n\t_SC_C_LANG_SUPPORT_R,\n#define _SC_C_LANG_SUPPORT_R\t\t_SC_C_LANG_SUPPORT_R\n\t_SC_CLOCK_SELECTION,\n#define _SC_CLOCK_SELECTION\t\t_SC_CLOCK_SELECTION\n\t_SC_CPUTIME,\n#define _SC_CPUTIME\t\t\t_SC_CPUTIME\n\t_SC_THREAD_CPUTIME,\n#define _SC_THREAD_CPUTIME\t\t_SC_THREAD_CPUTIME\n\t_SC_DEVICE_IO,\n#define _SC_DEVICE_IO\t\t\t_SC_DEVICE_IO\n\t_SC_DEVICE_SPECIFIC,\n#define _SC_DEVICE_SPECIFIC\t\t_SC_DEVICE_SPECIFIC\n\t_SC_DEVICE_SPECIFIC_R,\n#define _SC_DEVICE_SPECIFIC_R\t\t_SC_DEVICE_SPECIFIC_R\n\t_SC_FD_MGMT,\n#define _SC_FD_MGMT\t\t\t_SC_FD_MGMT\n\t_SC_FIFO,\n#define _SC_FIFO\t\t\t_SC_FIFO\n\t_SC_PIPE,\n#define _SC_PIPE\t\t\t_SC_PIPE\n\t_SC_FILE_ATTRIBUTES,\n#define _SC_FILE_ATTRIBUTES\t\t_SC_FILE_ATTRIBUTES\n\t_SC_FILE_LOCKING,\n#define _SC_FILE_LOCKING\t\t_SC_FILE_LOCKING\n\t_SC_FILE_SYSTEM,\n#define _SC_FILE_SYSTEM\t\t\t_SC_FILE_SYSTEM\n\t_SC_MONOTONIC_CLOCK,\n#define _SC_MONOTONIC_CLOCK\t\t_SC_MONOTONIC_CLOCK\n\t_SC_MULTI_PROCESS,\n#define _SC_MULTI_PROCESS\t\t_SC_MULTI_PROCESS\n\t_SC_SINGLE_PROCESS,\n#define _SC_SINGLE_PROCESS\t\t_SC_SINGLE_PROCESS\n\t_SC_NETWORKING,\n#define _SC_NETWORKING\t\t\t_SC_NETWORKING\n\t_SC_READER_WRITER_LOCKS,\n#define _SC_READER_WRITER_LOCKS\t\t_SC_READER_WRITER_LOCKS\n\t_SC_SPIN_LOCKS,\n#define _SC_SPIN_LOCKS\t\t\t_SC_SPIN_LOCKS\n\t_SC_REGEXP,\n#define _SC_REGEXP\t\t\t_SC_REGEXP\n\t_SC_REGEX_VERSION,\n#define _SC_REGEX_VERSION\t\t_SC_REGEX_VERSION\n\t_SC_SHELL,\n#define _SC_SHELL\t\t\t_SC_SHELL\n\t_SC_SIGNALS,\n#define _SC_SIGNALS\t\t\t_SC_SIGNALS\n\t_SC_SPAWN,\n#define _SC_SPAWN\t\t\t_SC_SPAWN\n\t_SC_SPORADIC_SERVER,\n#define _SC_SPORADIC_SERVER\t\t_SC_SPORADIC_SERVER\n\t_SC_THREAD_SPORADIC_SERVER,\n#define _SC_THREAD_SPORADIC_SERVER\t_SC_THREAD_SPORADIC_SERVER\n\t_SC_SYSTEM_DATABASE,\n#define _SC_SYSTEM_DATABASE\t\t_SC_SYSTEM_DATABASE\n\t_SC_SYSTEM_DATABASE_R,\n#define _SC_SYSTEM_DATABASE_R\t\t_SC_SYSTEM_DATABASE_R\n\t_SC_TIMEOUTS,\n#define _SC_TIMEOUTS\t\t\t_SC_TIMEOUTS\n\t_SC_TYPED_MEMORY_OBJECTS,\n#define _SC_TYPED_MEMORY_OBJECTS\t_SC_TYPED_MEMORY_OBJECTS\n\t_SC_USER_GROUPS,\n#define _SC_USER_GROUPS\t\t\t_SC_USER_GROUPS\n\t_SC_USER_GROUPS_R,\n#define _SC_USER_GROUPS_R\t\t_SC_USER_GROUPS_R\n\t_SC_2_PBS,\n#define _SC_2_PBS\t\t\t_SC_2_PBS\n\t_SC_2_PBS_ACCOUNTING,\n#define _SC_2_PBS_ACCOUNTING\t\t_SC_2_PBS_ACCOUNTING\n\t_SC_2_PBS_LOCATE,\n#define _SC_2_PBS_LOCATE\t\t_SC_2_PBS_LOCATE\n\t_SC_2_PBS_MESSAGE,\n#define _SC_2_PBS_MESSAGE\t\t_SC_2_PBS_MESSAGE\n\t_SC_2_PBS_TRACK,\n#define _SC_2_PBS_TRACK\t\t\t_SC_2_PBS_TRACK\n\t_SC_SYMLOOP_MAX,\n#define _SC_SYMLOOP_MAX\t\t\t_SC_SYMLOOP_MAX\n\t_SC_STREAMS,\n#define _SC_STREAMS\t\t\t_SC_STREAMS\n\t_SC_2_PBS_CHECKPOINT,\n#define _SC_2_PBS_CHECKPOINT\t\t_SC_2_PBS_CHECKPOINT\n\n\t_SC_V6_ILP32_OFF32,\n#define _SC_V6_ILP32_OFF32\t\t_SC_V6_ILP32_OFF32\n\t_SC_V6_ILP32_OFFBIG,\n#define _SC_V6_ILP32_OFFBIG\t\t_SC_V6_ILP32_OFFBIG\n\t_SC_V6_LP64_OFF64,\n#define _SC_V6_LP64_OFF64\t\t_SC_V6_LP64_OFF64\n\t_SC_V6_LPBIG_OFFBIG,\n#define _SC_V6_LPBIG_OFFBIG\t\t_SC_V6_LPBIG_OFFBIG\n\n\t_SC_HOST_NAME_MAX,\n#define _SC_HOST_NAME_MAX\t\t_SC_HOST_NAME_MAX\n\t_SC_TRACE,\n#define _SC_TRACE\t\t\t_SC_TRACE\n\t_SC_TRACE_EVENT_FILTER,\n#define _SC_TRACE_EVENT_FILTER\t\t_SC_TRACE_EVENT_FILTER\n\t_SC_TRACE_INHERIT,\n#define _SC_TRACE_INHERIT\t\t_SC_TRACE_INHERIT\n\t_SC_TRACE_LOG,\n#define _SC_TRACE_LOG\t\t\t_SC_TRACE_LOG\n\n\t_SC_LEVEL1_ICACHE_SIZE,\n#define _SC_LEVEL1_ICACHE_SIZE\t\t_SC_LEVEL1_ICACHE_SIZE\n\t_SC_LEVEL1_ICACHE_ASSOC,\n#define _SC_LEVEL1_ICACHE_ASSOC\t\t_SC_LEVEL1_ICACHE_ASSOC\n\t_SC_LEVEL1_ICACHE_LINESIZE,\n#define _SC_LEVEL1_ICACHE_LINESIZE\t_SC_LEVEL1_ICACHE_LINESIZE\n\t_SC_LEVEL1_DCACHE_SIZE,\n#define _SC_LEVEL1_DCACHE_SIZE\t\t_SC_LEVEL1_DCACHE_SIZE\n\t_SC_LEVEL1_DCACHE_ASSOC,\n#define _SC_LEVEL1_DCACHE_ASSOC\t\t_SC_LEVEL1_DCACHE_ASSOC\n\t_SC_LEVEL1_DCACHE_LINESIZE,\n#define _SC_LEVEL1_DCACHE_LINESIZE\t_SC_LEVEL1_DCACHE_LINESIZE\n\t_SC_LEVEL2_CACHE_SIZE,\n#define _SC_LEVEL2_CACHE_SIZE\t\t_SC_LEVEL2_CACHE_SIZE\n\t_SC_LEVEL2_CACHE_ASSOC,\n#define _SC_LEVEL2_CACHE_ASSOC\t\t_SC_LEVEL2_CACHE_ASSOC\n\t_SC_LEVEL2_CACHE_LINESIZE,\n#define _SC_LEVEL2_CACHE_LINESIZE\t_SC_LEVEL2_CACHE_LINESIZE\n\t_SC_LEVEL3_CACHE_SIZE,\n#define _SC_LEVEL3_CACHE_SIZE\t\t_SC_LEVEL3_CACHE_SIZE\n\t_SC_LEVEL3_CACHE_ASSOC,\n#define _SC_LEVEL3_CACHE_ASSOC\t\t_SC_LEVEL3_CACHE_ASSOC\n\t_SC_LEVEL3_CACHE_LINESIZE,\n#define _SC_LEVEL3_CACHE_LINESIZE\t_SC_LEVEL3_CACHE_LINESIZE\n\t_SC_LEVEL4_CACHE_SIZE,\n#define _SC_LEVEL4_CACHE_SIZE\t\t_SC_LEVEL4_CACHE_SIZE\n\t_SC_LEVEL4_CACHE_ASSOC,\n#define _SC_LEVEL4_CACHE_ASSOC\t\t_SC_LEVEL4_CACHE_ASSOC\n\t_SC_LEVEL4_CACHE_LINESIZE,\n#define _SC_LEVEL4_CACHE_LINESIZE\t_SC_LEVEL4_CACHE_LINESIZE\n\t/* Leave room here, maybe we need a few more cache levels some day.  */\n\n\t_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,\n#define _SC_IPV6\t\t\t_SC_IPV6\n\t_SC_RAW_SOCKETS,\n#define _SC_RAW_SOCKETS\t\t\t_SC_RAW_SOCKETS\n\n\t_SC_V7_ILP32_OFF32,\n#define _SC_V7_ILP32_OFF32\t\t_SC_V7_ILP32_OFF32\n\t_SC_V7_ILP32_OFFBIG,\n#define _SC_V7_ILP32_OFFBIG\t\t_SC_V7_ILP32_OFFBIG\n\t_SC_V7_LP64_OFF64,\n#define _SC_V7_LP64_OFF64\t\t_SC_V7_LP64_OFF64\n\t_SC_V7_LPBIG_OFFBIG,\n#define _SC_V7_LPBIG_OFFBIG\t\t_SC_V7_LPBIG_OFFBIG\n\n\t_SC_SS_REPL_MAX,\n#define _SC_SS_REPL_MAX\t\t\t_SC_SS_REPL_MAX\n\n\t_SC_TRACE_EVENT_NAME_MAX,\n#define _SC_TRACE_EVENT_NAME_MAX\t_SC_TRACE_EVENT_NAME_MAX\n\t_SC_TRACE_NAME_MAX,\n#define _SC_TRACE_NAME_MAX\t\t_SC_TRACE_NAME_MAX\n\t_SC_TRACE_SYS_MAX,\n#define _SC_TRACE_SYS_MAX\t\t_SC_TRACE_SYS_MAX\n\t_SC_TRACE_USER_EVENT_MAX,\n#define _SC_TRACE_USER_EVENT_MAX\t_SC_TRACE_USER_EVENT_MAX\n\n\t_SC_XOPEN_STREAMS,\n#define _SC_XOPEN_STREAMS\t\t_SC_XOPEN_STREAMS\n\n\t_SC_THREAD_ROBUST_PRIO_INHERIT,\n#define _SC_THREAD_ROBUST_PRIO_INHERIT\t_SC_THREAD_ROBUST_PRIO_INHERIT\n\t_SC_THREAD_ROBUST_PRIO_PROTECT\n#define _SC_THREAD_ROBUST_PRIO_PROTECT\t_SC_THREAD_ROBUST_PRIO_PROTECT\n};\n\n/* Values for the NAME argument to `confstr'.  */\nenum {\n\t_CS_PATH,\t\t/* The default search path.  */\n#define _CS_PATH\t\t_CS_PATH\n\n\t_CS_V6_WIDTH_RESTRICTED_ENVS,\n#define _CS_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n\n\t_CS_GNU_LIBC_VERSION,\n#define _CS_GNU_LIBC_VERSION\t_CS_GNU_LIBC_VERSION\n\t_CS_GNU_LIBPTHREAD_VERSION,\n#define _CS_GNU_LIBPTHREAD_VERSION\t_CS_GNU_LIBPTHREAD_VERSION\n\n\t_CS_V5_WIDTH_RESTRICTED_ENVS,\n#define _CS_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n\n\t_CS_V7_WIDTH_RESTRICTED_ENVS,\n#define _CS_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n\n\t_CS_LFS_CFLAGS = 1000,\n#define _CS_LFS_CFLAGS\t_CS_LFS_CFLAGS\n\t_CS_LFS_LDFLAGS,\n#define _CS_LFS_LDFLAGS\t_CS_LFS_LDFLAGS\n\t_CS_LFS_LIBS,\n#define _CS_LFS_LIBS\t\t_CS_LFS_LIBS\n\t_CS_LFS_LINTFLAGS,\n#define _CS_LFS_LINTFLAGS\t_CS_LFS_LINTFLAGS\n\t_CS_LFS64_CFLAGS,\n#define _CS_LFS64_CFLAGS\t_CS_LFS64_CFLAGS\n\t_CS_LFS64_LDFLAGS,\n#define _CS_LFS64_LDFLAGS\t_CS_LFS64_LDFLAGS\n\t_CS_LFS64_LIBS,\n#define _CS_LFS64_LIBS\t_CS_LFS64_LIBS\n\t_CS_LFS64_LINTFLAGS,\n#define _CS_LFS64_LINTFLAGS\t_CS_LFS64_LINTFLAGS\n\n\t_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,\n#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS\n\t_CS_XBS5_ILP32_OFF32_LDFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS\n\t_CS_XBS5_ILP32_OFF32_LIBS,\n#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS\n\t_CS_XBS5_ILP32_OFF32_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_CFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LDFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LIBS,\n#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS\n\t_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS\n\t_CS_XBS5_LP64_OFF64_CFLAGS,\n#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS\n\t_CS_XBS5_LP64_OFF64_LDFLAGS,\n#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS\n\t_CS_XBS5_LP64_OFF64_LIBS,\n#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS\n\t_CS_XBS5_LP64_OFF64_LINTFLAGS,\n#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_CFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LIBS,\n#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS\n\t_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V6_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS\n\t_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LIBS,\n#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS\n\t_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V7_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS\n\t_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LIBS,\n#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS\n\t_CS_POSIX_V7_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_V6_ENV,\n#define _CS_V6_ENV\t\t\t_CS_V6_ENV\n\t_CS_V7_ENV\n#define _CS_V7_ENV\t\t\t_CS_V7_ENV\n};\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/cpu-set.h",
    "content": "/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993\n   scheduling interface.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_CPU_SET_H\n#define _BITS_CPU_SET_H 1\n\n#ifndef _SCHED_H\n# error \"Never include <bits/cpu-set.h> directly; use <sched.h> instead.\"\n#endif\n\n/* Size definition for CPU sets.  */\n#define __CPU_SETSIZE\t1024\n#define __NCPUBITS\t(8 * sizeof (__cpu_mask))\n\n/* Type for array elements in 'cpu_set_t'.  */\ntypedef __CPU_MASK_TYPE __cpu_mask;\n\n/* Basic access functions.  */\n#define __CPUELT(cpu)\t((cpu) / __NCPUBITS)\n#define __CPUMASK(cpu)\t((__cpu_mask) 1 << ((cpu) % __NCPUBITS))\n\n/* Data structure to describe CPU mask.  */\ntypedef struct {\n\t__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];\n} cpu_set_t;\n\n/* Access functions for CPU masks.  */\n#if __GNUC_PREREQ (2, 91)\n# define __CPU_ZERO_S(setsize, cpusetp) \\\n  do __builtin_memset (cpusetp, '\\0', setsize); while (0)\n#else\n# define __CPU_ZERO_S(setsize, cpusetp) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    size_t __i;\t\t\t\t\t\t\t\t      \\\n    size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n    __cpu_mask *__bits = (cpusetp)->__bits;\t\t\t\t      \\\n    for (__i = 0; __i < __imax; ++__i)\t\t\t\t\t      \\\n      __bits[__i] = 0;\t\t\t\t\t\t\t      \\\n  } while (0)\n#endif\n#define __CPU_SET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t |= __CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n#define __CPU_CLR_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t &= ~__CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n#define __CPU_ISSET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t      \\\n\t  & __CPUMASK (__cpu))) != 0\t\t\t\t\t      \\\n      : 0; }))\n\n#define __CPU_COUNT_S(setsize, cpusetp) \\\n  __sched_cpucount (setsize, cpusetp)\n\n#if __GNUC_PREREQ (2, 91)\n# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)\n#else\n# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (cpusetp2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\tif (__arr1[__i] != __arr2[__i])\t\t\t\t\t      \\\n\t  break;\t\t\t\t\t\t\t      \\\n      __i == __imax; }))\n#endif\n\n#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ cpu_set_t *__dest = (destset);\t\t\t\t\t      \\\n      const __cpu_mask *__arr1 = (srcset1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (srcset2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\t((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i];    \\\n      __dest; }))\n\n#define __CPU_ALLOC_SIZE(count) \\\n  ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))\n#define __CPU_ALLOC(count) __sched_cpualloc (count)\n#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)\n\n__BEGIN_DECLS extern int __sched_cpucount(size_t __setsize, const cpu_set_t * __setp) __THROW;\nextern cpu_set_t *__sched_cpualloc(size_t __count)\n__THROW __wur;\nextern void __sched_cpufree(cpu_set_t * __set) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* bits/cpu-set.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/dirent.h",
    "content": "/* Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DIRENT_H\n# error \"Never use <bits/dirent.h> directly; include <dirent.h> instead.\"\n#endif\n\nstruct dirent {\n#ifndef __USE_FILE_OFFSET64\n\t__ino_t d_ino;\n\t__off_t d_off;\n#else\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n#endif\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct dirent64 {\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n#endif\n\n#define d_fileno\td_ino\t/* Backwards compatibility.  */\n\n#undef  _DIRENT_HAVE_D_NAMLEN\n#define _DIRENT_HAVE_D_RECLEN\n#define _DIRENT_HAVE_D_OFF\n#define _DIRENT_HAVE_D_TYPE\n\n#if defined __OFF_T_MATCHES_OFF64_T && defined __INO_T_MATCHES_INO64_T\n/* Inform libc code that these two types are effectively identical.  */\n# define _DIRENT_MATCHES_DIRENT64\t1\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/dlfcn.h",
    "content": "/* System dependent definitions for run-time dynamic loading.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DLFCN_H\n# error \"Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead.\"\n#endif\n\n/* The MODE argument to `dlopen' contains one of the following: */\n#define RTLD_LAZY\t0x00001\t/* Lazy function call binding.  */\n#define RTLD_NOW\t0x00002\t/* Immediate function call binding.  */\n#define\tRTLD_BINDING_MASK   0x3\t/* Mask of binding time value.  */\n#define RTLD_NOLOAD\t0x00004\t/* Do not load the object.  */\n#define RTLD_DEEPBIND\t0x00008\t/* Use deep binding.  */\n\n/* If the following bit is set in the MODE argument to `dlopen',\n   the symbols of the loaded object and its dependencies are made\n   visible as if the object were linked directly into the program.  */\n#define RTLD_GLOBAL\t0x00100\n\n/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.\n   The implementation does this by default and so we can define the\n   value to zero.  */\n#define RTLD_LOCAL\t0\n\n/* Do not delete object when closed.  */\n#define RTLD_NODELETE\t0x01000\n\n#ifdef __USE_GNU\n/* To support profiling of shared objects it is a good idea to call\n   the function found using `dlsym' using the following macro since\n   these calls do not use the PLT.  But this would mean the dynamic\n   loader has no chance to find out when the function is called.  The\n   macro applies the necessary magic so that profiling is possible.\n   Rewrite\n\tfoo = (*fctp) (arg1, arg2);\n   into\n        foo = DL_CALL_FCT (fctp, (arg1, arg2));\n*/\n# define DL_CALL_FCT(fctp, args) \\\n  (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)\n\n__BEGIN_DECLS\n/* This function calls the profiling functions.  */\nextern void _dl_mcount_wrapper_check(void *__selfpc) __THROW;\n\n__END_DECLS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/endian.h",
    "content": "/* i386/x86_64 are little-endian.  */\n\n#ifndef _ENDIAN_H\n# error \"Never use <bits/endian.h> directly; include <endian.h> instead.\"\n#endif\n\n#define __BYTE_ORDER __LITTLE_ENDIAN\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/environments.h",
    "content": "/* Copyright (C) 1999-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n# error \"Never include this file directly.  Use <unistd.h> instead\"\n#endif\n\n#include <bits/wordsize.h>\n\n/* This header should define the following symbols under the described\n   situations.  A value `1' means that the model is always supported,\n   `-1' means it is never supported.  Undefined means it cannot be\n   statically decided.\n\n   _POSIX_V7_ILP32_OFF32   32bit int, long, pointers, and off_t type\n   _POSIX_V7_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type\n\n   _POSIX_V7_LP64_OFF32\t   64bit long and pointers and 32bit off_t type\n   _POSIX_V7_LPBIG_OFFBIG  64bit long and pointers and large off_t type\n\n   The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,\n   _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,\n   _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were\n   used in previous versions of the Unix standard and are available\n   only for compatibility.\n*/\n\n#if __WORDSIZE == 64\n\n/* Environments with 32-bit wide pointers are optionally provided.\n   Therefore following macros aren't defined:\n   # undef _POSIX_V7_ILP32_OFF32\n   # undef _POSIX_V7_ILP32_OFFBIG\n   # undef _POSIX_V6_ILP32_OFF32\n   # undef _POSIX_V6_ILP32_OFFBIG\n   # undef _XBS5_ILP32_OFF32\n   # undef _XBS5_ILP32_OFFBIG\n   and users need to check at runtime.  */\n\n/* We also have no use (for now) for an environment with bigger pointers\n   and offsets.  */\n# define _POSIX_V7_LPBIG_OFFBIG\t-1\n# define _POSIX_V6_LPBIG_OFFBIG\t-1\n# define _XBS5_LPBIG_OFFBIG\t-1\n\n/* By default we have 64-bit wide `long int', pointers and `off_t'.  */\n# define _POSIX_V7_LP64_OFF64\t1\n# define _POSIX_V6_LP64_OFF64\t1\n# define _XBS5_LP64_OFF64\t1\n\n#else\t\t\t\t/* __WORDSIZE == 32 */\n\n/* We have 32-bit wide `int', `long int' and pointers and all platforms\n   support LFS.  -mx32 has 64-bit wide `off_t'.  */\n# define _POSIX_V7_ILP32_OFFBIG\t1\n# define _POSIX_V6_ILP32_OFFBIG 1\n# define _XBS5_ILP32_OFFBIG\t1\n\n# ifndef __x86_64__\n/* -m32 has 32-bit wide `off_t'.  */\n#  define _POSIX_V7_ILP32_OFF32\t1\n#  define _POSIX_V6_ILP32_OFF32\t1\n#  define _XBS5_ILP32_OFF32\t1\n# endif\n\n/* We optionally provide an environment with the above size but an 64-bit\n   side `off_t'.  Therefore we don't define _POSIX_V7_ILP32_OFFBIG.  */\n\n/* Environments with 64-bit wide pointers can be provided,\n   so these macros aren't defined:\n   # undef _POSIX_V7_LP64_OFF64\n   # undef _POSIX_V7_LPBIG_OFFBIG\n   # undef _POSIX_V6_LP64_OFF64\n   # undef _POSIX_V6_LPBIG_OFFBIG\n   # undef _XBS5_LP64_OFF64\n   # undef _XBS5_LPBIG_OFFBIG\n   and sysconf tests for it at runtime.  */\n\n#endif\t\t\t\t/* __WORDSIZE == 32 */\n\n#define __ILP32_OFF32_CFLAGS\t\"-m32\"\n#define __ILP32_OFF32_LDFLAGS\t\"-m32\"\n#if defined __x86_64__ && defined __ILP32__\n# define __ILP32_OFFBIG_CFLAGS\t\"-mx32\"\n# define __ILP32_OFFBIG_LDFLAGS\t\"-mx32\"\n#else\n# define __ILP32_OFFBIG_CFLAGS\t\"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64\"\n# define __ILP32_OFFBIG_LDFLAGS\t\"-m32\"\n#endif\n#define __LP64_OFF64_CFLAGS\t\"-m64\"\n#define __LP64_OFF64_LDFLAGS\t\"-m64\"\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/errno.h",
    "content": "/* Error constants.  Linux specific version.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_ERRNO_H\n#define _BITS_ERRNO_H 1\n\n#if !defined _ERRNO_H\n# error \"Never include <bits/errno.h> directly; use <errno.h> instead.\"\n#endif\n\n# include <linux/errno.h>\n\n/* Older Linux headers do not define these constants.  */\n# ifndef ENOTSUP\n#  define ENOTSUP\t\tEOPNOTSUPP\n# endif\n\n# ifndef ECANCELED\n#  define ECANCELED\t\t125\n# endif\n\n# ifndef EOWNERDEAD\n#  define EOWNERDEAD\t\t130\n# endif\n\n#ifndef ENOTRECOVERABLE\n#  define ENOTRECOVERABLE\t131\n# endif\n\n# ifndef ERFKILL\n#  define ERFKILL\t\t132\n# endif\n\n# ifndef EHWPOISON\n#  define EHWPOISON\t\t133\n# endif\n\n#endif\t\t\t\t/* bits/errno.h.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/fcntl-linux.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux.\n   Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FCNTL_H\n# error \"Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead.\"\n#endif\n\n/* This file contains shared definitions between Linux architectures\n   and is included by <bits/fcntl.h> to declare them.  The various\n   #ifndef cases allow the architecture specific file to define those\n   values with different values.\n\n   A minimal <bits/fcntl.h> contains just:\n\n   struct flock {...}\n   #ifdef __USE_LARGEFILE64\n   struct flock64 {...}\n   #endif\n   #include <bits/fcntl-linux.h>\n*/\n\n#ifdef __USE_GNU\n# include <bits/types/struct_iovec.h>\n#endif\n\n/* open/fcntl.  */\n#define O_ACCMODE\t   0003\n#define O_RDONLY\t     00\n#define O_WRONLY\t     01\n#define O_RDWR\t\t     02\n#ifndef O_CREAT\n# define O_CREAT\t   0100\t/* Not fcntl.  */\n#endif\n#ifndef O_EXCL\n# define O_EXCL\t\t   0200\t/* Not fcntl.  */\n#endif\n#ifndef O_NOCTTY\n# define O_NOCTTY\t   0400\t/* Not fcntl.  */\n#endif\n#ifndef O_TRUNC\n# define O_TRUNC\t  01000\t/* Not fcntl.  */\n#endif\n#ifndef O_APPEND\n# define O_APPEND\t  02000\n#endif\n#ifndef O_NONBLOCK\n# define O_NONBLOCK\t  04000\n#endif\n#ifndef O_NDELAY\n# define O_NDELAY\tO_NONBLOCK\n#endif\n#ifndef O_SYNC\n# define O_SYNC\t       04010000\n#endif\n#define O_FSYNC\t\tO_SYNC\n#ifndef O_ASYNC\n# define O_ASYNC\t 020000\n#endif\n#ifndef __O_LARGEFILE\n# define __O_LARGEFILE\t0100000\n#endif\n\n#ifndef __O_DIRECTORY\n# define __O_DIRECTORY\t0200000\n#endif\n#ifndef __O_NOFOLLOW\n# define __O_NOFOLLOW\t0400000\n#endif\n#ifndef __O_CLOEXEC\n# define __O_CLOEXEC   02000000\n#endif\n#ifndef __O_DIRECT\n# define __O_DIRECT\t 040000\n#endif\n#ifndef __O_NOATIME\n# define __O_NOATIME   01000000\n#endif\n#ifndef __O_PATH\n# define __O_PATH     010000000\n#endif\n#ifndef __O_DSYNC\n# define __O_DSYNC\t 010000\n#endif\n#ifndef __O_TMPFILE\n# define __O_TMPFILE   (020000000 | __O_DIRECTORY)\n#endif\n\n#ifndef F_GETLK\n# ifndef __USE_FILE_OFFSET64\n#  define F_GETLK\t5\t/* Get record locking info.  */\n#  define F_SETLK\t6\t/* Set record locking info (non-blocking).  */\n#  define F_SETLKW\t7\t/* Set record locking info (blocking).  */\n# else\n#  define F_GETLK\tF_GETLK64\t/* Get record locking info.  */\n#  define F_SETLK\tF_SETLK64\t/* Set record locking info (non-blocking). */\n#  define F_SETLKW\tF_SETLKW64\t/* Set record locking info (blocking).  */\n# endif\n#endif\n#ifndef F_GETLK64\n# define F_GETLK64\t12\t/* Get record locking info.  */\n# define F_SETLK64\t13\t/* Set record locking info (non-blocking).  */\n# define F_SETLKW64\t14\t/* Set record locking info (blocking).  */\n#endif\n\n/* open file description locks.\n\n   Usually record locks held by a process are released on *any* close and are\n   not inherited across a fork.\n\n   These cmd values will set locks that conflict with process-associated record\n   locks, but are \"owned\" by the opened file description, not the process.\n   This means that they are inherited across fork or clone with CLONE_FILES\n   like BSD (flock) locks, and they are only released automatically when the\n   last reference to the the file description against which they were acquired\n   is put. */\n#ifdef __USE_GNU\n# define F_OFD_GETLK\t36\n# define F_OFD_SETLK\t37\n# define F_OFD_SETLKW\t38\n#endif\n\n#ifdef __USE_LARGEFILE64\n# define O_LARGEFILE __O_LARGEFILE\n#endif\n\n#ifdef __USE_XOPEN2K8\n# define O_DIRECTORY\t__O_DIRECTORY\t/* Must be a directory.  */\n# define O_NOFOLLOW\t__O_NOFOLLOW\t/* Do not follow links.  */\n# define O_CLOEXEC\t__O_CLOEXEC\t/* Set close_on_exec.  */\n#endif\n\n#ifdef __USE_GNU\n# define O_DIRECT\t__O_DIRECT\t/* Direct disk access.  */\n# define O_NOATIME\t__O_NOATIME\t/* Do not set atime.  */\n# define O_PATH\t\t__O_PATH\t/* Resolve pathname but do not open file.  */\n# define O_TMPFILE\t__O_TMPFILE\t/* Atomically create nameless file.  */\n#endif\n\n/* For now, Linux has no separate synchronicity options for read\n   operations.  We define O_RSYNC therefore as the same as O_SYNC\n   since this is a superset.  */\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n# define O_DSYNC\t__O_DSYNC\t/* Synchronize data.  */\n# if defined __O_RSYNC\n#  define O_RSYNC\t__O_RSYNC\t/* Synchronize read operations.  */\n# else\n#  define O_RSYNC\tO_SYNC\t/* Synchronize read operations.  */\n# endif\n#endif\n\n/* Values for the second argument to `fcntl'.  */\n#define F_DUPFD\t\t0\t/* Duplicate file descriptor.  */\n#define F_GETFD\t\t1\t/* Get file descriptor flags.  */\n#define F_SETFD\t\t2\t/* Set file descriptor flags.  */\n#define F_GETFL\t\t3\t/* Get file status flags.  */\n#define F_SETFL\t\t4\t/* Set file status flags.  */\n\n#ifndef __F_SETOWN\n# define __F_SETOWN\t8\n# define __F_GETOWN\t9\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n# define F_SETOWN\t__F_SETOWN\t/* Get owner (process receiving SIGIO).  */\n# define F_GETOWN\t__F_GETOWN\t/* Set owner (process receiving SIGIO).  */\n#endif\n\n#ifndef __F_SETSIG\n# define __F_SETSIG\t10\t/* Set number of signal to be sent.  */\n# define __F_GETSIG\t11\t/* Get number of signal to be sent.  */\n#endif\n#ifndef __F_SETOWN_EX\n# define __F_SETOWN_EX\t15\t/* Get owner (thread receiving SIGIO).  */\n# define __F_GETOWN_EX\t16\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n# define F_SETSIG\t__F_SETSIG\t/* Set number of signal to be sent.  */\n# define F_GETSIG\t__F_GETSIG\t/* Get number of signal to be sent.  */\n# define F_SETOWN_EX\t__F_SETOWN_EX\t/* Get owner (thread receiving SIGIO).  */\n# define F_GETOWN_EX\t__F_GETOWN_EX\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n# define F_SETLEASE\t1024\t/* Set a lease.  */\n# define F_GETLEASE\t1025\t/* Enquire what lease is active.  */\n# define F_NOTIFY\t1026\t/* Request notifications on a directory.  */\n# define F_SETPIPE_SZ\t1031\t/* Set pipe page size array.  */\n# define F_GETPIPE_SZ\t1032\t/* Set pipe page size array.  */\n# define F_ADD_SEALS\t1033\t/* Add seals to file.  */\n# define F_GET_SEALS\t1034\t/* Get seals for file.  */\n/* Set / get write life time hints.  */\n# define F_GET_RW_HINT\t1035\n# define F_SET_RW_HINT\t1036\n# define F_GET_FILE_RW_HINT\t1037\n# define F_SET_FILE_RW_HINT\t1038\n#endif\n#ifdef __USE_XOPEN2K8\n# define F_DUPFD_CLOEXEC 1030\t/* Duplicate file descriptor with\n\t\t\t\t   close-on-exit set.  */\n#endif\n\n/* For F_[GET|SET]FD.  */\n#define FD_CLOEXEC\t1\t/* Actually anything with low bit set goes */\n\n#ifndef F_RDLCK\n/* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */\n# define F_RDLCK\t\t0\t/* Read lock.  */\n# define F_WRLCK\t\t1\t/* Write lock.  */\n# define F_UNLCK\t\t2\t/* Remove lock.  */\n#endif\n\n/* For old implementation of BSD flock.  */\n#ifndef F_EXLCK\n# define F_EXLCK\t\t4\t/* or 3 */\n# define F_SHLCK\t\t8\t/* or 4 */\n#endif\n\n#ifdef __USE_MISC\n/* Operations for BSD flock, also used by the kernel implementation.  */\n# define LOCK_SH\t1\t/* Shared lock.  */\n# define LOCK_EX\t2\t/* Exclusive lock.  */\n# define LOCK_NB\t4\t/* Or'd with one of the above to prevent\n\t\t\t\t   blocking.  */\n# define LOCK_UN\t8\t/* Remove lock.  */\n#endif\n\n#ifdef __USE_GNU\n# define LOCK_MAND\t32\t/* This is a mandatory flock:  */\n# define LOCK_READ\t64\t/* ... which allows concurrent read operations.  */\n# define LOCK_WRITE\t128\t/* ... which allows concurrent write operations.  */\n# define LOCK_RW\t192\t/* ... Which allows concurrent read & write operations.  */\n#endif\n\n#ifdef __USE_GNU\n/* Types of directory notifications that may be requested with F_NOTIFY.  */\n# define DN_ACCESS\t0x00000001\t/* File accessed.  */\n# define DN_MODIFY\t0x00000002\t/* File modified.  */\n# define DN_CREATE\t0x00000004\t/* File created.  */\n# define DN_DELETE\t0x00000008\t/* File removed.  */\n# define DN_RENAME\t0x00000010\t/* File renamed.  */\n# define DN_ATTRIB\t0x00000020\t/* File changed attributes.  */\n# define DN_MULTISHOT\t0x80000000\t/* Don't remove notifier.  */\n#endif\n\n#ifdef __USE_GNU\n/* Owner types.  */\nenum __pid_type {\n\tF_OWNER_TID = 0,\t/* Kernel thread.  */\n\tF_OWNER_PID,\t\t/* Process.  */\n\tF_OWNER_PGRP,\t\t/* Process group.  */\n\tF_OWNER_GID = F_OWNER_PGRP\t/* Alternative, obsolete name.  */\n};\n\n/* Structure to use with F_GETOWN_EX and F_SETOWN_EX.  */\nstruct f_owner_ex {\n\tenum __pid_type type;\t/* Owner type of ID.  */\n\t__pid_t pid;\t\t/* ID of owner.  */\n};\n#endif\n\n#ifdef __USE_GNU\n/* Types of seals.  */\n# define F_SEAL_SEAL\t0x0001\t/* Prevent further seals from being set.  */\n# define F_SEAL_SHRINK\t0x0002\t/* Prevent file from shrinking.  */\n# define F_SEAL_GROW\t0x0004\t/* Prevent file from growing.  */\n# define F_SEAL_WRITE\t0x0008\t/* Prevent writes.  */\n#endif\n\n#ifdef __USE_GNU\n/* Hint values for F_{GET,SET}_RW_HINT.  */\n# define RWF_WRITE_LIFE_NOT_SET\t0\n# define RWH_WRITE_LIFE_NONE\t1\n# define RWH_WRITE_LIFE_SHORT\t2\n# define RWH_WRITE_LIFE_MEDIUM\t3\n# define RWH_WRITE_LIFE_LONG\t4\n# define RWH_WRITE_LIFE_EXTREME\t5\n#endif\n\n/* Define some more compatibility macros to be backward compatible with\n   BSD systems which did not managed to hide these kernel macros.  */\n#ifdef\t__USE_MISC\n# define FAPPEND\tO_APPEND\n# define FFSYNC\t\tO_FSYNC\n# define FASYNC\t\tO_ASYNC\n# define FNONBLOCK\tO_NONBLOCK\n# define FNDELAY\tO_NDELAY\n#endif\t\t\t\t/* Use misc.  */\n\n#ifndef __POSIX_FADV_DONTNEED\n#  define __POSIX_FADV_DONTNEED\t4\n#  define __POSIX_FADV_NOREUSE\t5\n#endif\n/* Advise to `posix_fadvise'.  */\n#ifdef __USE_XOPEN2K\n# define POSIX_FADV_NORMAL\t0\t/* No further special treatment.  */\n# define POSIX_FADV_RANDOM\t1\t/* Expect random page references.  */\n# define POSIX_FADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n# define POSIX_FADV_WILLNEED\t3\t/* Will need these pages.  */\n# define POSIX_FADV_DONTNEED\t__POSIX_FADV_DONTNEED\t/* Don't need these pages.  */\n# define POSIX_FADV_NOREUSE\t__POSIX_FADV_NOREUSE\t/* Data will be accessed once.  */\n#endif\n\n#ifdef __USE_GNU\n/* Flags for SYNC_FILE_RANGE.  */\n# define SYNC_FILE_RANGE_WAIT_BEFORE\t1\t/* Wait upon writeout of all pages\n\t\t\t\t\t\t   in the range before performing the\n\t\t\t\t\t\t   write.  */\n# define SYNC_FILE_RANGE_WRITE\t\t2\t/* Initiate writeout of all those\n\t\t\t\t\t\t   dirty pages in the range which are\n\t\t\t\t\t\t   not presently under writeback.  */\n# define SYNC_FILE_RANGE_WAIT_AFTER\t4\t/* Wait upon writeout of all pages in\n\t\t\t\t\t\t   the range after performing the\n\t\t\t\t\t\t   write.  */\n\n/* Flags for SPLICE and VMSPLICE.  */\n# define SPLICE_F_MOVE\t\t1\t/* Move pages instead of copying.  */\n# define SPLICE_F_NONBLOCK\t2\t/* Don't block on the pipe splicing\n\t\t\t\t\t   (but we may still block on the fd\n\t\t\t\t\t   we splice from/to).  */\n# define SPLICE_F_MORE\t\t4\t/* Expect more data.  */\n# define SPLICE_F_GIFT\t\t8\t/* Pages passed in are a gift.  */\n\n/* Flags for fallocate.  */\n# include <linux/falloc.h>\n\n/* File handle structure.  */\nstruct file_handle {\n\tunsigned int handle_bytes;\n\tint handle_type;\n\t/* File identifier.  */\n\tunsigned char f_handle[0];\n};\n\n/* Maximum handle size (for now).  */\n# define MAX_HANDLE_SZ\t128\n#endif\n\n/* Values for `*at' functions.  */\n#ifdef __USE_ATFILE\n# define AT_FDCWD\t\t-100\t/* Special value used to indicate\n\t\t\t\t\t   the *at functions should use the\n\t\t\t\t\t   current working directory. */\n# define AT_SYMLINK_NOFOLLOW\t0x100\t/* Do not follow symbolic links.  */\n# define AT_REMOVEDIR\t\t0x200\t/* Remove directory instead of\n\t\t\t\t\t   unlinking file.  */\n# define AT_SYMLINK_FOLLOW\t0x400\t/* Follow symbolic links.  */\n# ifdef __USE_GNU\n#  define AT_NO_AUTOMOUNT\t0x800\t/* Suppress terminal automount\n\t\t\t\t\t   traversal.  */\n#  define AT_EMPTY_PATH\t\t0x1000\t/* Allow empty relative pathname.  */\n# endif\n# define AT_EACCESS\t\t0x200\t/* Test access permitted for\n\t\t\t\t\t   effective IDs, not real IDs.  */\n#endif\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Provide kernel hint to read ahead.  */\nextern __ssize_t readahead(int __fd, __off64_t __offset, size_t __count) __THROW;\n\n/* Selective file content synch'ing.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int sync_file_range(int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags);\n\n/* Splice address range into a pipe.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags);\n\n/* Splice two files together.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __ssize_t splice(int __fdin, __off64_t * __offin, int __fdout, __off64_t * __offout, size_t __len, unsigned int __flags);\n\n/* In-kernel implementation of tee for pipe buffers.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __ssize_t tee(int __fdin, int __fdout, size_t __len, unsigned int __flags);\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int fallocate(int __fd, int __mode, __off_t __offset, __off_t __len);\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(fallocate, (int __fd, int __mode, __off64_t __offset, __off64_t __len), fallocate64);\n#  else\n#   define fallocate fallocate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int fallocate64(int __fd, int __mode, __off64_t __offset, __off64_t __len);\n# endif\n\n/* Map file name to file handle.  */\nextern int name_to_handle_at(int __dfd, const char *__name, struct file_handle *__handle, int *__mnt_id, int __flags) __THROW;\n\n/* Open file using the file handle.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int open_by_handle_at(int __mountdirfd, struct file_handle *__handle, int __flags);\n\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/fcntl.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux/x86.\n   Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _FCNTL_H\n# error \"Never use <bits/fcntl.h> directly; include <fcntl.h> instead.\"\n#endif\n\n#ifdef __x86_64__\n# define __O_LARGEFILE\t0\n#endif\n\n#ifdef __x86_64__\n/* Not necessary, we always have 64-bit offsets.  */\n# define F_GETLK64\t5\t/* Get record locking info.  */\n# define F_SETLK64\t6\t/* Set record locking info (non-blocking).  */\n# define F_SETLKW64\t7\t/* Set record locking info (blocking).  */\n#endif\n\nstruct flock {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n#ifndef __USE_FILE_OFFSET64\n\t__off_t l_start;\t/* Offset where the lock begins.  */\n\t__off_t l_len;\t\t/* Size of the locked area; zero means until EOF.  */\n#else\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n#endif\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct flock64 {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/fcntl-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/floatn-common.h",
    "content": "/* Macros to control TS 18661-3 glibc features where the same\n   definitions are appropriate for all platforms.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_FLOATN_COMMON_H\n#define _BITS_FLOATN_COMMON_H\n\n#include <features.h>\n#include <bits/long-double.h>\n\n/* This header should be included at the bottom of each bits/floatn.h.\n   It defines the following macros for each _FloatN and _FloatNx type,\n   where the same definitions, or definitions based only on the macros\n   in bits/floatn.h, are appropriate for all glibc configurations.  */\n\n/* Defined to 1 if the current compiler invocation provides a\n   floating-point type with the right format for this type, and this\n   glibc includes corresponding *fN or *fNx interfaces for it.  */\n#define __HAVE_FLOAT16 0\n#define __HAVE_FLOAT32 1\n#define __HAVE_FLOAT64 1\n#define __HAVE_FLOAT32X 1\n#define __HAVE_FLOAT128X 0\n\n/* Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the\n   type is the first with its format in the sequence of (the default\n   choices for) float, double, long double, _Float16, _Float32,\n   _Float64, _Float128, _Float32x, _Float64x, _Float128x for this\n   glibc; that is, if functions present once per floating-point format\n   rather than once per type are present for this type.\n\n   All configurations supported by glibc have _Float32 the same format\n   as float, _Float64 and _Float32x the same format as double, the\n   _Float64x the same format as either long double or _Float128.  No\n   configurations support _Float128x or, as of GCC 7, have compiler\n   support for a type meeting the requirements for _Float128x.  */\n#define __HAVE_DISTINCT_FLOAT16 __HAVE_FLOAT16\n#define __HAVE_DISTINCT_FLOAT32 0\n#define __HAVE_DISTINCT_FLOAT64 0\n#define __HAVE_DISTINCT_FLOAT32X 0\n#define __HAVE_DISTINCT_FLOAT64X 0\n#define __HAVE_DISTINCT_FLOAT128X __HAVE_FLOAT128X\n\n/* Defined to 1 if any _FloatN or _FloatNx types that are not\n   ABI-distinct are however distinct types at the C language level (so\n   for the purposes of __builtin_types_compatible_p and _Generic).  */\n#if __GNUC_PREREQ (7, 0) && !defined __cplusplus\n# define __HAVE_FLOATN_NOT_TYPEDEF 1\n#else\n# define __HAVE_FLOATN_NOT_TYPEDEF 0\n#endif\n\n#ifndef __ASSEMBLER__\n\n/* Defined to concatenate the literal suffix to be used with _FloatN\n   or _FloatNx types, if __HAVE_<type> is 1.  The corresponding\n   literal suffixes exist since GCC 7, for C only.  */\n# if __HAVE_FLOAT16\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n/* No corresponding suffix available for this type.  */\n#   define __f16(x) ((_Float16) x##f)\n#  else\n#   define __f16(x) x##f16\n#  endif\n# endif\n\n# if __HAVE_FLOAT32\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   define __f32(x) x##f\n#  else\n#   define __f32(x) x##f32\n#  endif\n# endif\n\n# if __HAVE_FLOAT64\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   ifdef __NO_LONG_DOUBLE_MATH\n#    define __f64(x) x##l\n#   else\n#    define __f64(x) x\n#   endif\n#  else\n#   define __f64(x) x##f64\n#  endif\n# endif\n\n# if __HAVE_FLOAT32X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   define __f32x(x) x\n#  else\n#   define __f32x(x) x##f32x\n#  endif\n# endif\n\n# if __HAVE_FLOAT64X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   if __HAVE_FLOAT64X_LONG_DOUBLE\n#    define __f64x(x) x##l\n#   else\n#    define __f64x(x) __f128 (x)\n#   endif\n#  else\n#   define __f64x(x) x##f64x\n#  endif\n# endif\n\n# if __HAVE_FLOAT128X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   error \"_Float128X supported but no constant suffix\"\n#  else\n#   define __f128x(x) x##f128x\n#  endif\n# endif\n\n/* Defined to a complex type if __HAVE_<type> is 1.  */\n# if __HAVE_FLOAT16\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef _Complex float __cfloat16 __attribute__ ((__mode__(__HC__)));\n#   define __CFLOAT16 __cfloat16\n#  else\n#   define __CFLOAT16 _Complex _Float16\n#  endif\n# endif\n\n# if __HAVE_FLOAT32\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   define __CFLOAT32 _Complex float\n#  else\n#   define __CFLOAT32 _Complex _Float32\n#  endif\n# endif\n\n# if __HAVE_FLOAT64\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   ifdef __NO_LONG_DOUBLE_MATH\n#    define __CFLOAT64 _Complex long double\n#   else\n#    define __CFLOAT64 _Complex double\n#   endif\n#  else\n#   define __CFLOAT64 _Complex _Float64\n#  endif\n# endif\n\n# if __HAVE_FLOAT32X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   define __CFLOAT32X _Complex double\n#  else\n#   define __CFLOAT32X _Complex _Float32x\n#  endif\n# endif\n\n# if __HAVE_FLOAT64X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   if __HAVE_FLOAT64X_LONG_DOUBLE\n#    define __CFLOAT64X _Complex long double\n#   else\n#    define __CFLOAT64X __CFLOAT128\n#   endif\n#  else\n#   define __CFLOAT64X _Complex _Float64x\n#  endif\n# endif\n\n# if __HAVE_FLOAT128X\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   error \"_Float128X supported but no complex type\"\n#  else\n#   define __CFLOAT128X _Complex _Float128x\n#  endif\n# endif\n\n/* The remaining of this file provides support for older compilers.  */\n# if __HAVE_FLOAT16\n\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef float _Float16 __attribute__ ((__mode__(__HF__)));\n#  endif\n\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_huge_valf16() ((_Float16) __builtin_huge_val ())\n#   define __builtin_inff16() ((_Float16) __builtin_inf ())\n#   define __builtin_nanf16(x) ((_Float16) __builtin_nan (x))\n#   define __builtin_nansf16(x) ((_Float16) __builtin_nans (x))\n#  endif\n\n# endif\n\n# if __HAVE_FLOAT32\n\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef float _Float32;\n#  endif\n\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_huge_valf32() (__builtin_huge_valf ())\n#   define __builtin_inff32() (__builtin_inff ())\n#   define __builtin_nanf32(x) (__builtin_nanf (x))\n#   define __builtin_nansf32(x) (__builtin_nansf (x))\n#  endif\n\n# endif\n\n# if __HAVE_FLOAT64\n\n/* If double, long double and _Float64 all have the same set of\n   values, TS 18661-3 requires the usual arithmetic conversions on\n   long double and _Float64 to produce _Float64.  For this to be the\n   case when building with a compiler without a distinct _Float64\n   type, _Float64 must be a typedef for long double, not for\n   double.  */\n\n#  ifdef __NO_LONG_DOUBLE_MATH\n\n#   if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef long double _Float64;\n#   endif\n\n#   if !__GNUC_PREREQ (7, 0)\n#    define __builtin_huge_valf64() (__builtin_huge_vall ())\n#    define __builtin_inff64() (__builtin_infl ())\n#    define __builtin_nanf64(x) (__builtin_nanl (x))\n#    define __builtin_nansf64(x) (__builtin_nansl (x))\n#   endif\n\n#  else\n\n#   if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef double _Float64;\n#   endif\n\n#   if !__GNUC_PREREQ (7, 0)\n#    define __builtin_huge_valf64() (__builtin_huge_val ())\n#    define __builtin_inff64() (__builtin_inf ())\n#    define __builtin_nanf64(x) (__builtin_nan (x))\n#    define __builtin_nansf64(x) (__builtin_nans (x))\n#   endif\n\n#  endif\n\n# endif\n\n# if __HAVE_FLOAT32X\n\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef double _Float32x;\n#  endif\n\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_huge_valf32x() (__builtin_huge_val ())\n#   define __builtin_inff32x() (__builtin_inf ())\n#   define __builtin_nanf32x(x) (__builtin_nan (x))\n#   define __builtin_nansf32x(x) (__builtin_nans (x))\n#  endif\n\n# endif\n\n# if __HAVE_FLOAT64X\n\n#  if __HAVE_FLOAT64X_LONG_DOUBLE\n\n#   if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef long double _Float64x;\n#   endif\n\n#   if !__GNUC_PREREQ (7, 0)\n#    define __builtin_huge_valf64x() (__builtin_huge_vall ())\n#    define __builtin_inff64x() (__builtin_infl ())\n#    define __builtin_nanf64x(x) (__builtin_nanl (x))\n#    define __builtin_nansf64x(x) (__builtin_nansl (x))\n#   endif\n\n#  else\n\n#   if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef _Float128 _Float64x;\n#   endif\n\n#   if !__GNUC_PREREQ (7, 0)\n#    define __builtin_huge_valf64x() (__builtin_huge_valf128 ())\n#    define __builtin_inff64x() (__builtin_inff128 ())\n#    define __builtin_nanf64x(x) (__builtin_nanf128 (x))\n#    define __builtin_nansf64x(x) (__builtin_nansf128 (x))\n#   endif\n\n#  endif\n\n# endif\n\n# if __HAVE_FLOAT128X\n\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n#   error \"_Float128x supported but no type\"\n#  endif\n\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_huge_valf128x() ((_Float128x) __builtin_huge_val ())\n#   define __builtin_inff128x() ((_Float128x) __builtin_inf ())\n#   define __builtin_nanf128x(x) ((_Float128x) __builtin_nan (x))\n#   define __builtin_nansf128x(x) ((_Float128x) __builtin_nans (x))\n#  endif\n\n# endif\n\n#endif\t\t\t\t/* !__ASSEMBLER__.  */\n\n#endif\t\t\t\t/* _BITS_FLOATN_COMMON_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/floatn.h",
    "content": "/* Macros to control TS 18661-3 glibc features on x86.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_FLOATN_H\n#define _BITS_FLOATN_H\n\n#include <features.h>\n\n/* Defined to 1 if the current compiler invocation provides a\n   floating-point type with the IEEE 754 binary128 format, and this\n   glibc includes corresponding *f128 interfaces for it.  The required\n   libgcc support was added some time after the basic compiler\n   support, for x86_64 and x86.  */\n#if (defined __x86_64__\t\t\t\t\t\t\t\\\n     ? __GNUC_PREREQ (4, 3)\t\t\t\t\t\t\\\n     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \\\n     &&  !defined(__CUDACC__) && !defined(__ICC)\n# define __HAVE_FLOAT128 1\n#else\n# define __HAVE_FLOAT128 0\n#endif\n\n/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct\n   from the default float, double and long double types in this glibc.  */\n#if __HAVE_FLOAT128\n# define __HAVE_DISTINCT_FLOAT128 1\n#else\n# define __HAVE_DISTINCT_FLOAT128 0\n#endif\n\n/* Defined to 1 if the current compiler invocation provides a\n   floating-point type with the right format for _Float64x, and this\n   glibc includes corresponding *f64x interfaces for it.  */\n#define __HAVE_FLOAT64X 1\n\n/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format\n   of long double.  Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has\n   the format of _Float128, which must be different from that of long\n   double.  */\n#define __HAVE_FLOAT64X_LONG_DOUBLE 1\n\n#ifndef __ASSEMBLER__\n\n/* Defined to concatenate the literal suffix to be used with _Float128\n   types, if __HAVE_FLOAT128 is 1. */\n# if __HAVE_FLOAT128\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n/* The literal suffix f128 exists only since GCC 7.0.  */\n#   define __f128(x) x##q\n#  else\n#   define __f128(x) x##f128\n#  endif\n# endif\n\n/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */\n# if __HAVE_FLOAT128\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\n/* Add a typedef for older GCC compilers which don't natively support\n   _Complex _Float128.  */\ntypedef _Complex float __cfloat128 __attribute__ ((__mode__(__TC__)));\n#   define __CFLOAT128 __cfloat128\n#  else\n#   define __CFLOAT128 _Complex _Float128\n#  endif\n# endif\n\n/* The remaining of this file provides support for older compilers.  */\n# if __HAVE_FLOAT128\n\n/* The type _Float128 exists only since GCC 7.0.  */\n#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus\ntypedef __float128 _Float128;\n#  endif\n\n/* __builtin_huge_valf128 doesn't exist before GCC 7.0.  */\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())\n#  endif\n\n/* Older GCC has only a subset of built-in functions for _Float128 on\n   x86, and __builtin_infq is not usable in static initializers.\n   Converting a narrower sNaN to _Float128 produces a quiet NaN, so\n   attempts to use _Float128 sNaNs will not work properly with older\n   compilers.  */\n#  if !__GNUC_PREREQ (7, 0)\n#   define __builtin_copysignf128 __builtin_copysignq\n#   define __builtin_fabsf128 __builtin_fabsq\n#   define __builtin_inff128() ((_Float128) __builtin_inf ())\n#   define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))\n#   define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))\n#  endif\n\n/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,\n   e.g.: __builtin_signbitf128, before GCC 6.  However, there has never\n   been a __builtin_signbitf128 in GCC and the type-generic builtin is\n   only available since GCC 6.  */\n#  if !__GNUC_PREREQ (6, 0)\n#   define __builtin_signbitf128 __signbitf128\n#  endif\n\n# endif\n\n#endif\t\t\t\t/* !__ASSEMBLER__.  */\n\n#include <bits/floatn-common.h>\n\n#endif\t\t\t\t/* _BITS_FLOATN_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/flt-eval-method.h",
    "content": "/* Define __GLIBC_FLT_EVAL_METHOD.  x86 version.\n   Copyright (C) 2016-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/flt-eval-method.h> directly; include <math.h> instead.\"\n#endif\n\n#ifdef __FLT_EVAL_METHOD__\n# if __FLT_EVAL_METHOD__ == -1\n#  define __GLIBC_FLT_EVAL_METHOD\t2\n# else\n#  define __GLIBC_FLT_EVAL_METHOD\t__FLT_EVAL_METHOD__\n# endif\n#elif defined __x86_64__\n# define __GLIBC_FLT_EVAL_METHOD\t0\n#else\n# define __GLIBC_FLT_EVAL_METHOD\t2\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/fp-fast.h",
    "content": "/* Define FP_FAST_* macros.\n   Copyright (C) 2016-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/fp-fast.h> directly; include <math.h> instead.\"\n#endif\n\n#ifdef __USE_ISOC99\n\n/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}\n   builtins are supported.  */\n# ifdef __FP_FAST_FMA\n#  define FP_FAST_FMA 1\n# endif\n\n# ifdef __FP_FAST_FMAF\n#  define FP_FAST_FMAF 1\n# endif\n\n# ifdef __FP_FAST_FMAL\n#  define FP_FAST_FMAL 1\n# endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/fp-logb.h",
    "content": "/* Define __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.  x86 version.\n   Copyright (C) 2016-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/fp-logb.h> directly; include <math.h> instead.\"\n#endif\n\n#define __FP_LOGB0_IS_MIN\t1\n#define __FP_LOGBNAN_IS_MIN\t1\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/getopt_core.h",
    "content": "/* Declarations for getopt (basic, portable features only).\n   Copyright (C) 1989-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library and is also part of gnulib.\n   Patches to this file should be submitted to both projects.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_CORE_H\n#define _GETOPT_CORE_H 1\n\n/* This header should not be used directly; include getopt.h or\n   unistd.h instead.  Unlike most bits headers, it does not have\n   a protective #error, because the guard macro for getopt.h in\n   gnulib is not fixed.  */\n\n__BEGIN_DECLS\n/* For communication from 'getopt' to the caller.\n   When 'getopt' finds an option that takes an argument,\n   the argument value is returned here.\n   Also, when 'ordering' is RETURN_IN_ORDER,\n   each non-option ARGV-element is returned here.  */\nextern char *optarg;\n\n/* Index in ARGV of the next element to be scanned.\n   This is used for communication to and from the caller\n   and for communication between successive calls to 'getopt'.\n\n   On entry to 'getopt', zero means this is the first call; initialize.\n\n   When 'getopt' returns -1, this is the index of the first of the\n   non-option elements that the caller should itself scan.\n\n   Otherwise, 'optind' communicates from one call to the next\n   how much of ARGV has been scanned so far.  */\n\nextern int optind;\n\n/* Callers store zero here to inhibit the error message 'getopt' prints\n   for unrecognized options.  */\n\nextern int opterr;\n\n/* Set to an option character which was unrecognized.  */\n\nextern int optopt;\n\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.\n\n   Return the option character from OPTS just read.  Return -1 when\n   there are no more options.  For unrecognized options, or options\n   missing arguments, 'optopt' is set to the option letter, and '?' is\n   returned.\n\n   The OPTS string is a list of characters which are recognized option\n   letters, optionally followed by colons, specifying that that letter\n   takes an argument, to be placed in 'optarg'.\n\n   If a letter in OPTS is followed by two colons, its argument is\n   optional.  This behavior is specific to the GNU 'getopt'.\n\n   The argument '--' causes premature termination of argument\n   scanning, explicitly telling 'getopt' that there are no more\n   options.\n\n   If OPTS begins with '-', then non-option arguments are treated as\n   arguments to the option '\\1'.  This behavior is specific to the GNU\n   'getopt'.  If OPTS begins with '+', or POSIXLY_CORRECT is set in\n   the environment, then do not permute arguments.\n\n   For standards compliance, the 'argv' argument has the type\n   char *const *, but this is inaccurate; if argument permutation is\n   enabled, the argv array (not the strings it points to) must be\n   writable.  */\n\nextern int getopt(int ___argc, char *const *___argv, const char *__shortopts)\n__THROW __nonnull((2, 3));\n\n__END_DECLS\n#endif\t\t\t\t/* getopt_core.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/getopt_ext.h",
    "content": "/* Declarations for getopt (GNU extensions).\n   Copyright (C) 1989-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library and is also part of gnulib.\n   Patches to this file should be submitted to both projects.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_EXT_H\n#define _GETOPT_EXT_H 1\n\n/* This header should not be used directly; include getopt.h instead.\n   Unlike most bits headers, it does not have a protective #error,\n   because the guard macro for getopt.h in gnulib is not fixed.  */\n\n__BEGIN_DECLS\n/* Describe the long-named options requested by the application.\n   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector\n   of 'struct option' terminated by an element containing a name which is\n   zero.\n\n   The field 'has_arg' is:\n   no_argument\t\t(or 0) if the option does not take an argument,\n   required_argument\t(or 1) if the option requires an argument,\n   optional_argument \t(or 2) if the option takes an optional argument.\n\n   If the field 'flag' is not NULL, it points to a variable that is set\n   to the value given in the field 'val' when the option is found, but\n   left unchanged if the option is not found.\n\n   To have a long-named option do something other than set an 'int' to\n   a compiled-in constant, such as set a value from 'optarg', set the\n   option's 'flag' field to zero and its 'val' field to a nonzero\n   value (the equivalent single-letter option character, if there is\n   one).  For long options that have a zero 'flag' field, 'getopt'\n   returns the contents of the 'val' field.  */\n    struct option {\n\tconst char *name;\n\t/* has_arg can't be an enum because some compilers complain about\n\t   type mismatches in all the code that assumes it is an int.  */\n\tint has_arg;\n\tint *flag;\n\tint val;\n};\n\n/* Names for the values of the 'has_arg' field of 'struct option'.  */\n\n#define no_argument\t\t0\n#define required_argument\t1\n#define optional_argument\t2\n\nextern int getopt_long(int ___argc, char *__getopt_argv_const * ___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n__THROW __nonnull((2, 3));\nextern int getopt_long_only(int ___argc, char *__getopt_argv_const * ___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n__THROW __nonnull((2, 3));\n\n__END_DECLS\n#endif\t\t\t\t/* getopt_ext.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/getopt_posix.h",
    "content": "/* Declarations for getopt (POSIX compatibility shim).\n   Copyright (C) 1989-2018 Free Software Foundation, Inc.\n   Unlike the bulk of the getopt implementation, this file is NOT part\n   of gnulib.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_POSIX_H\n#define _GETOPT_POSIX_H 1\n\n#if !defined _UNISTD_H && !defined _STDIO_H\n#error \"Never include getopt_posix.h directly; use unistd.h instead.\"\n#endif\n\n#include <bits/getopt_core.h>\n\n__BEGIN_DECLS\n#if defined __USE_POSIX2 && !defined __USE_POSIX_IMPLICITLY \\\n    && !defined __USE_GNU && !defined _GETOPT_H\n/* GNU getopt has more functionality than POSIX getopt.  When we are\n   explicitly conforming to POSIX and not GNU, and getopt.h (which is\n   not part of POSIX) has not been included, the extra functionality\n   is disabled.  */\n# ifdef __REDIRECT\nextern int __REDIRECT_NTH(getopt, (int ___argc, char *const *___argv, const char *__shortopts), __posix_getopt);\n# else\nextern int __posix_getopt(int ___argc, char *const *___argv, const char *__shortopts)\n__THROW __nonnull((2, 3));\n#  define getopt __posix_getopt\n# endif\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* getopt_posix.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/in.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Linux version.  */\n\n#ifndef _NETINET_IN_H\n# error \"Never use <bits/in.h> directly; include <netinet/in.h> instead.\"\n#endif\n\n/* If the application has already included linux/in6.h from a linux-based\n   kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the\n   defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo\n   in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly.\n   Neither the linux kernel nor glibc should break this ABI without coordination.\n   In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check\n   for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for\n   maximum backwards compatibility.  */\n#if defined _UAPI_LINUX_IN6_H \\\n    || defined _UAPI_IPV6_H \\\n    || defined _LINUX_IN6_H \\\n    || defined _IPV6_H\n/* This is not quite the same API since the kernel always defines s6_addr16 and\n   s6_addr32. This is not a violation of POSIX since POSIX says \"at least the\n   following member\" and that holds true.  */\n# define __USE_KERNEL_IPV6_DEFS 1\n#else\n# define __USE_KERNEL_IPV6_DEFS 0\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IP level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define        IP_OPTIONS      4\t/* ip_opts; IP per-packet options.  */\n#define        IP_HDRINCL      3\t/* int; Header is included with data.  */\n#define        IP_TOS          1\t/* int; IP type of service and precedence.  */\n#define        IP_TTL          2\t/* int; IP time to live.  */\n#define        IP_RECVOPTS     6\t/* bool; Receive all IP options w/datagram.  */\n/* For BSD compatibility.  */\n#define        IP_RECVRETOPTS  IP_RETOPTS\t/* bool; Receive IP options for response.  */\n#define        IP_RETOPTS      7\t/* ip_opts; Set/get IP per-packet options.  */\n#define IP_MULTICAST_IF 32\t/* in_addr; set/get IP multicast i/f */\n#define IP_MULTICAST_TTL 33\t/* unsigned char; set/get IP multicast ttl */\n#define IP_MULTICAST_LOOP 34\t/* bool; set/get IP multicast loopback */\n#define IP_ADD_MEMBERSHIP 35\t/* ip_mreq; add an IP group membership */\n#define IP_DROP_MEMBERSHIP 36\t/* ip_mreq; drop an IP group membership */\n#define IP_UNBLOCK_SOURCE 37\t/* ip_mreq_source: unblock data from source */\n#define IP_BLOCK_SOURCE 38\t/* ip_mreq_source: block data from source */\n#define IP_ADD_SOURCE_MEMBERSHIP 39\t/* ip_mreq_source: join source group */\n#define IP_DROP_SOURCE_MEMBERSHIP 40\t/* ip_mreq_source: leave source group */\n#define IP_MSFILTER 41\n#ifdef __USE_MISC\n# define MCAST_JOIN_GROUP 42\t/* group_req: join any-source group */\n# define MCAST_BLOCK_SOURCE 43\t/* group_source_req: block from given group */\n# define MCAST_UNBLOCK_SOURCE 44\t/* group_source_req: unblock from given group */\n# define MCAST_LEAVE_GROUP 45\t/* group_req: leave any-source group */\n# define MCAST_JOIN_SOURCE_GROUP 46\t/* group_source_req: join source-spec gr */\n# define MCAST_LEAVE_SOURCE_GROUP 47\t/* group_source_req: leave source-spec gr */\n# define MCAST_MSFILTER 48\n# define IP_MULTICAST_ALL 49\n# define IP_UNICAST_IF 50\n\n# define MCAST_EXCLUDE   0\n# define MCAST_INCLUDE   1\n#endif\n\n#define IP_ROUTER_ALERT\t5\t/* bool */\n#define IP_PKTINFO\t8\t/* bool */\n#define IP_PKTOPTIONS\t9\n#define IP_PMTUDISC\t10\t/* obsolete name? */\n#define IP_MTU_DISCOVER\t10\t/* int; see below */\n#define IP_RECVERR\t11\t/* bool */\n#define IP_RECVTTL\t12\t/* bool */\n#define IP_RECVTOS\t13\t/* bool */\n#define IP_MTU\t\t14\t/* int */\n#define IP_FREEBIND\t15\n#define IP_IPSEC_POLICY 16\n#define IP_XFRM_POLICY\t17\n#define IP_PASSSEC\t18\n#define IP_TRANSPARENT\t19\n#define IP_MULTICAST_ALL 49\t/* bool */\n\n/* TProxy original addresses */\n#define IP_ORIGDSTADDR       20\n#define IP_RECVORIGDSTADDR   IP_ORIGDSTADDR\n\n#define IP_MINTTL       21\n#define IP_NODEFRAG     22\n#define IP_CHECKSUM     23\n#define IP_BIND_ADDRESS_NO_PORT 24\n#define IP_RECVFRAGSIZE 25\n\n/* IP_MTU_DISCOVER arguments.  */\n#define IP_PMTUDISC_DONT   0\t/* Never send DF frames.  */\n#define IP_PMTUDISC_WANT   1\t/* Use per route hints.  */\n#define IP_PMTUDISC_DO     2\t/* Always DF.  */\n#define IP_PMTUDISC_PROBE  3\t/* Ignore dst pmtu.  */\n/* Always use interface mtu (ignores dst pmtu) but don't set DF flag.\n   Also incoming ICMP frag_needed notifications will be ignored on\n   this socket to prevent accepting spoofed ones.  */\n#define IP_PMTUDISC_INTERFACE           4\n/* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented.  */\n#define IP_PMTUDISC_OMIT\t\t5\n\n#define IP_MULTICAST_IF\t\t\t32\n#define IP_MULTICAST_TTL \t\t33\n#define IP_MULTICAST_LOOP \t\t34\n#define IP_ADD_MEMBERSHIP\t\t35\n#define IP_DROP_MEMBERSHIP\t\t36\n#define IP_UNBLOCK_SOURCE\t\t37\n#define IP_BLOCK_SOURCE\t\t\t38\n#define IP_ADD_SOURCE_MEMBERSHIP\t39\n#define IP_DROP_SOURCE_MEMBERSHIP\t40\n#define IP_MSFILTER\t\t\t41\n#define IP_MULTICAST_ALL\t\t49\n#define IP_UNICAST_IF\t\t\t50\n\n/* To select the IP level.  */\n#define SOL_IP\t0\n\n#define IP_DEFAULT_MULTICAST_TTL        1\n#define IP_DEFAULT_MULTICAST_LOOP       1\n#define IP_MAX_MEMBERSHIPS              20\n\n#ifdef __USE_MISC\n/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.\n   The `ip_dst' field is used for the first-hop gateway when using a\n   source route (this gets put into the header proper).  */\nstruct ip_opts {\n\tstruct in_addr ip_dst;\t/* First hop; zero without source route.  */\n\tchar ip_opts[40];\t/* Actually variable in size.  */\n};\n\n/* Like `struct ip_mreq' but including interface specification by index.  */\nstruct ip_mreqn {\n\tstruct in_addr imr_multiaddr;\t/* IP multicast address of group */\n\tstruct in_addr imr_address;\t/* local IP address of interface */\n\tint imr_ifindex;\t/* Interface index */\n};\n\n/* Structure used for IP_PKTINFO.  */\nstruct in_pktinfo {\n\tint ipi_ifindex;\t/* Interface index  */\n\tstruct in_addr ipi_spec_dst;\t/* Routing destination address  */\n\tstruct in_addr ipi_addr;\t/* Header destination address  */\n};\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define IPV6_ADDRFORM\t\t1\n#define IPV6_2292PKTINFO\t2\n#define IPV6_2292HOPOPTS\t3\n#define IPV6_2292DSTOPTS\t4\n#define IPV6_2292RTHDR\t\t5\n#define IPV6_2292PKTOPTIONS\t6\n#define IPV6_CHECKSUM\t\t7\n#define IPV6_2292HOPLIMIT\t8\n\n#define SCM_SRCRT\t\tIPV6_RXSRCRT\n\n#define IPV6_NEXTHOP\t\t9\n#define IPV6_AUTHHDR\t\t10\n#define IPV6_UNICAST_HOPS\t16\n#define IPV6_MULTICAST_IF\t17\n#define IPV6_MULTICAST_HOPS\t18\n#define IPV6_MULTICAST_LOOP\t19\n#define IPV6_JOIN_GROUP\t\t20\n#define IPV6_LEAVE_GROUP\t21\n#define IPV6_ROUTER_ALERT\t22\n#define IPV6_MTU_DISCOVER\t23\n#define IPV6_MTU\t\t24\n#define IPV6_RECVERR\t\t25\n#define IPV6_V6ONLY\t\t26\n#define IPV6_JOIN_ANYCAST\t27\n#define IPV6_LEAVE_ANYCAST\t28\n#define IPV6_IPSEC_POLICY\t34\n#define IPV6_XFRM_POLICY\t35\n#define IPV6_HDRINCL\t\t36\n\n/* Advanced API (RFC3542) (1).  */\n#define IPV6_RECVPKTINFO\t49\n#define IPV6_PKTINFO\t\t50\n#define IPV6_RECVHOPLIMIT\t51\n#define IPV6_HOPLIMIT\t\t52\n#define IPV6_RECVHOPOPTS\t53\n#define IPV6_HOPOPTS\t\t54\n#define IPV6_RTHDRDSTOPTS\t55\n#define IPV6_RECVRTHDR\t\t56\n#define IPV6_RTHDR\t\t57\n#define IPV6_RECVDSTOPTS\t58\n#define IPV6_DSTOPTS\t\t59\n#define IPV6_RECVPATHMTU\t60\n#define IPV6_PATHMTU\t\t61\n#define IPV6_DONTFRAG\t\t62\n\n/* Advanced API (RFC3542) (2).  */\n#define IPV6_RECVTCLASS\t\t66\n#define IPV6_TCLASS\t\t67\n\n#define IPV6_AUTOFLOWLABEL\t70\n\n/* RFC5014.  */\n#define IPV6_ADDR_PREFERENCES\t72\n\n/* RFC5082.  */\n#define IPV6_MINHOPCOUNT\t73\n\n#define IPV6_ORIGDSTADDR\t74\n#define IPV6_RECVORIGDSTADDR\tIPV6_ORIGDSTADDR\n#define IPV6_TRANSPARENT\t75\n#define IPV6_UNICAST_IF\t\t76\n#define IPV6_RECVFRAGSIZE\t77\n\n/* Obsolete synonyms for the above.  */\n#if !__USE_KERNEL_IPV6_DEFS\n# define IPV6_ADD_MEMBERSHIP\tIPV6_JOIN_GROUP\n# define IPV6_DROP_MEMBERSHIP\tIPV6_LEAVE_GROUP\n#endif\n#define IPV6_RXHOPOPTS\t\tIPV6_HOPOPTS\n#define IPV6_RXDSTOPTS\t\tIPV6_DSTOPTS\n\n/* IPV6_MTU_DISCOVER values.  */\n#define IPV6_PMTUDISC_DONT\t0\t/* Never send DF frames.  */\n#define IPV6_PMTUDISC_WANT\t1\t/* Use per route hints.  */\n#define IPV6_PMTUDISC_DO\t2\t/* Always DF.  */\n#define IPV6_PMTUDISC_PROBE\t3\t/* Ignore dst pmtu.  */\n#define IPV6_PMTUDISC_INTERFACE\t4\t/* See IP_PMTUDISC_INTERFACE.  */\n#define IPV6_PMTUDISC_OMIT\t5\t/* See IP_PMTUDISC_OMIT.  */\n\n/* Socket level values for IPv6.  */\n#define SOL_IPV6        41\n#define SOL_ICMPV6      58\n\n/* Routing header options for IPv6.  */\n#define IPV6_RTHDR_LOOSE\t0\t/* Hop doesn't need to be neighbour. */\n#define IPV6_RTHDR_STRICT\t1\t/* Hop must be a neighbour.  */\n\n#define IPV6_RTHDR_TYPE_0\t0\t/* IPv6 Routing header type 0.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/ioctl-types.h",
    "content": "/* Structure types for pre-termios terminal ioctls.  Linux version.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n# error \"Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Get definition of constants for use with `ioctl'.  */\n#include <asm/ioctls.h>\n\nstruct winsize {\n\tunsigned short int ws_row;\n\tunsigned short int ws_col;\n\tunsigned short int ws_xpixel;\n\tunsigned short int ws_ypixel;\n};\n\n#define NCC 8\nstruct termio {\n\tunsigned short int c_iflag;\t/* input mode flags */\n\tunsigned short int c_oflag;\t/* output mode flags */\n\tunsigned short int c_cflag;\t/* control mode flags */\n\tunsigned short int c_lflag;\t/* local mode flags */\n\tunsigned char c_line;\t/* line discipline */\n\tunsigned char c_cc[NCC];\t/* control characters */\n};\n\n/* modem lines */\n#define TIOCM_LE\t0x001\n#define TIOCM_DTR\t0x002\n#define TIOCM_RTS\t0x004\n#define TIOCM_ST\t0x008\n#define TIOCM_SR\t0x010\n#define TIOCM_CTS\t0x020\n#define TIOCM_CAR\t0x040\n#define TIOCM_RNG\t0x080\n#define TIOCM_DSR\t0x100\n#define TIOCM_CD\tTIOCM_CAR\n#define TIOCM_RI\tTIOCM_RNG\n\n/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */\n\n/* line disciplines */\n#define N_TTY\t\t0\n#define N_SLIP\t\t1\n#define N_MOUSE\t\t2\n#define N_PPP\t\t3\n#define N_STRIP\t\t4\n#define N_AX25\t\t5\n#define N_X25\t\t6\t/* X.25 async  */\n#define N_6PACK\t\t7\n#define N_MASC\t\t8\t/* Mobitex module  */\n#define N_R3964\t\t9\t/* Simatic R3964 module  */\n#define N_PROFIBUS_FDL\t10\t/* Profibus  */\n#define N_IRDA\t\t11\t/* Linux IR  */\n#define N_SMSBLOCK\t12\t/* SMS block mode  */\n#define N_HDLC\t\t13\t/* synchronous HDLC  */\n#define N_SYNC_PPP\t14\t/* synchronous PPP  */\n#define\tN_HCI\t\t15\t/* Bluetooth HCI UART  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/ioctls.h",
    "content": "/* Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n# error \"Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Use the definitions from the kernel header files.  */\n#include <asm/ioctls.h>\n\n/* Routing table calls.  */\n#define SIOCADDRT\t0x890B\t/* add routing table entry      */\n#define SIOCDELRT\t0x890C\t/* delete routing table entry   */\n#define SIOCRTMSG\t0x890D\t/* call to routing system       */\n\n/* Socket configuration controls. */\n#define SIOCGIFNAME\t0x8910\t/* get iface name               */\n#define SIOCSIFLINK\t0x8911\t/* set iface channel            */\n#define SIOCGIFCONF\t0x8912\t/* get iface list               */\n#define SIOCGIFFLAGS\t0x8913\t/* get flags                    */\n#define SIOCSIFFLAGS\t0x8914\t/* set flags                    */\n#define SIOCGIFADDR\t0x8915\t/* get PA address               */\n#define SIOCSIFADDR\t0x8916\t/* set PA address               */\n#define SIOCGIFDSTADDR\t0x8917\t/* get remote PA address        */\n#define SIOCSIFDSTADDR\t0x8918\t/* set remote PA address        */\n#define SIOCGIFBRDADDR\t0x8919\t/* get broadcast PA address     */\n#define SIOCSIFBRDADDR\t0x891a\t/* set broadcast PA address     */\n#define SIOCGIFNETMASK\t0x891b\t/* get network PA mask          */\n#define SIOCSIFNETMASK\t0x891c\t/* set network PA mask          */\n#define SIOCGIFMETRIC\t0x891d\t/* get metric                   */\n#define SIOCSIFMETRIC\t0x891e\t/* set metric                   */\n#define SIOCGIFMEM\t0x891f\t/* get memory address (BSD)     */\n#define SIOCSIFMEM\t0x8920\t/* set memory address (BSD)     */\n#define SIOCGIFMTU\t0x8921\t/* get MTU size                 */\n#define SIOCSIFMTU\t0x8922\t/* set MTU size                 */\n#define SIOCSIFNAME\t0x8923\t/* set interface name           */\n#define\tSIOCSIFHWADDR\t0x8924\t/* set hardware address         */\n#define SIOCGIFENCAP\t0x8925\t/* get/set encapsulations       */\n#define SIOCSIFENCAP\t0x8926\n#define SIOCGIFHWADDR\t0x8927\t/* Get hardware address         */\n#define SIOCGIFSLAVE\t0x8929\t/* Driver slaving support       */\n#define SIOCSIFSLAVE\t0x8930\n#define SIOCADDMULTI\t0x8931\t/* Multicast address lists      */\n#define SIOCDELMULTI\t0x8932\n#define SIOCGIFINDEX\t0x8933\t/* name -> if_index mapping     */\n#define SIOGIFINDEX\tSIOCGIFINDEX\t/* misprint compatibility :-)   */\n#define SIOCSIFPFLAGS\t0x8934\t/* set/get extended flags set   */\n#define SIOCGIFPFLAGS\t0x8935\n#define SIOCDIFADDR\t0x8936\t/* delete PA address            */\n#define\tSIOCSIFHWBROADCAST\t0x8937\t/* set hardware broadcast addr  */\n#define SIOCGIFCOUNT\t0x8938\t/* get number of devices */\n\n#define SIOCGIFBR\t0x8940\t/* Bridging support             */\n#define SIOCSIFBR\t0x8941\t/* Set bridging options         */\n\n#define SIOCGIFTXQLEN\t0x8942\t/* Get the tx queue length      */\n#define SIOCSIFTXQLEN\t0x8943\t/* Set the tx queue length      */\n\n/* ARP cache control calls. */\n\t\t    /*  0x8950 - 0x8952  * obsolete calls, don't re-use */\n#define SIOCDARP\t0x8953\t/* delete ARP table entry       */\n#define SIOCGARP\t0x8954\t/* get ARP table entry          */\n#define SIOCSARP\t0x8955\t/* set ARP table entry          */\n\n/* RARP cache control calls. */\n#define SIOCDRARP\t0x8960\t/* delete RARP table entry      */\n#define SIOCGRARP\t0x8961\t/* get RARP table entry         */\n#define SIOCSRARP\t0x8962\t/* set RARP table entry         */\n\n/* Driver configuration calls */\n\n#define SIOCGIFMAP\t0x8970\t/* Get device parameters        */\n#define SIOCSIFMAP\t0x8971\t/* Set device parameters        */\n\n/* DLCI configuration calls */\n\n#define SIOCADDDLCI\t0x8980\t/* Create new DLCI device       */\n#define SIOCDELDLCI\t0x8981\t/* Delete DLCI device           */\n\n/* Device private ioctl calls.  */\n\n/* These 16 ioctls are available to devices via the do_ioctl() device\n   vector.  Each device should include this file and redefine these\n   names as their own. Because these are device dependent it is a good\n   idea _NOT_ to issue them to random objects and hope.  */\n\n#define SIOCDEVPRIVATE \t\t0x89F0\t/* to 89FF */\n\n/*\n *\tThese 16 ioctl calls are protocol private\n */\n\n#define SIOCPROTOPRIVATE 0x89E0\t/* to 89EF */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/libc-header-start.h",
    "content": "/* Handle feature test macros at the start of a header.\n   Copyright (C) 2016-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* This header is internal to glibc and should not be included outside\n   of glibc headers.  Headers including it must define\n   __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first.  This header\n   cannot have multiple include guards because ISO C feature test\n   macros depend on the definition of the macro when an affected\n   header is included, not when the first system header is\n   included.  */\n\n#ifndef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n# error \"Never include <bits/libc-header-start.h> directly.\"\n#endif\n\n#undef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n\n#include <features.h>\n\n/* ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__\n   macro.  */\n#undef __GLIBC_USE_LIB_EXT2\n#if (defined __USE_GNU\t\t\t\t\t\t\t\\\n     || (defined __STDC_WANT_LIB_EXT2__ && __STDC_WANT_LIB_EXT2__ > 0))\n# define __GLIBC_USE_LIB_EXT2 1\n#else\n# define __GLIBC_USE_LIB_EXT2 0\n#endif\n\n/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__\n   macro.  */\n#undef __GLIBC_USE_IEC_60559_BFP_EXT\n#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__\n# define __GLIBC_USE_IEC_60559_BFP_EXT 1\n#else\n# define __GLIBC_USE_IEC_60559_BFP_EXT 0\n#endif\n\n/* ISO/IEC TS 18661-4:2015 defines the\n   __STDC_WANT_IEC_60559_FUNCS_EXT__ macro.  */\n#undef __GLIBC_USE_IEC_60559_FUNCS_EXT\n#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__\n# define __GLIBC_USE_IEC_60559_FUNCS_EXT 1\n#else\n# define __GLIBC_USE_IEC_60559_FUNCS_EXT 0\n#endif\n\n/* ISO/IEC TS 18661-3:2015 defines the\n   __STDC_WANT_IEC_60559_TYPES_EXT__ macro.  */\n#undef __GLIBC_USE_IEC_60559_TYPES_EXT\n#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_TYPES_EXT__\n# define __GLIBC_USE_IEC_60559_TYPES_EXT 1\n#else\n# define __GLIBC_USE_IEC_60559_TYPES_EXT 0\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/libio.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Written by Per Bothner <bothner@cygnus.com>.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.\n\n   As a special exception, if you link the code in this file with\n   files compiled with a GNU compiler to produce an executable,\n   that does not cause the resulting executable to be covered by\n   the GNU Lesser General Public License.  This exception does not\n   however invalidate any other reasons why the executable file\n   might be covered by the GNU Lesser General Public License.\n   This exception applies to code released by its copyright holders\n   in files containing the exception.  */\n\n#ifndef _BITS_LIBIO_H\n#define _BITS_LIBIO_H 1\n\n#if !defined _STDIO_H && !defined _LIBIO_H\n# error \"Never include <bits/libio.h> directly; use <stdio.h> instead.\"\n#endif\n\n#include <bits/_G_config.h>\n/* ALL of these should be defined in _G_config.h */\n#define _IO_fpos_t _G_fpos_t\n#define _IO_fpos64_t _G_fpos64_t\n#define _IO_size_t size_t\n#define _IO_ssize_t __ssize_t\n#define _IO_off_t __off_t\n#define _IO_off64_t __off64_t\n#define _IO_pid_t __pid_t\n#define _IO_uid_t __uid_t\n#define _IO_iconv_t _G_iconv_t\n#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE\n#define _IO_BUFSIZ _G_BUFSIZ\n#define _IO_va_list _G_va_list\n#define _IO_wint_t wint_t\n\n/* This define avoids name pollution if we're using GNU stdarg.h */\n#define __need___va_list\n#include <stdarg.h>\n#ifdef __GNUC_VA_LIST\n# undef _IO_va_list\n# define _IO_va_list __gnuc_va_list\n#endif\t\t\t\t/* __GNUC_VA_LIST */\n\n#ifndef __P\n# include <sys/cdefs.h>\n#endif\t\t\t\t/*!__P */\n\n#define _IO_UNIFIED_JUMPTABLES 1\n\n#ifndef EOF\n# define EOF (-1)\n#endif\n#ifndef NULL\n# if defined __GNUG__ && \\\n    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n#  define NULL (__null)\n# else\n#  if !defined(__cplusplus)\n#   define NULL ((void*)0)\n#  else\n#   define NULL (0)\n#  endif\n# endif\n#endif\n\n#define _IOS_INPUT\t1\n#define _IOS_OUTPUT\t2\n#define _IOS_ATEND\t4\n#define _IOS_APPEND\t8\n#define _IOS_TRUNC\t16\n#define _IOS_NOCREATE\t32\n#define _IOS_NOREPLACE\t64\n#define _IOS_BIN\t128\n\n/* Magic numbers and bits for the _flags field.\n   The magic numbers use the high-order bits of _flags;\n   the remaining bits are available for variable flags.\n   Note: The magic numbers must all be negative if stdio\n   emulation is desired. */\n\n#define _IO_MAGIC 0xFBAD0000\t/* Magic number */\n#define _OLD_STDIO_MAGIC 0xFABC0000\t/* Emulate old stdio. */\n#define _IO_MAGIC_MASK 0xFFFF0000\n#define _IO_USER_BUF 1\t\t/* User owns buffer; don't delete it on close. */\n#define _IO_UNBUFFERED 2\n#define _IO_NO_READS 4\t\t/* Reading not allowed */\n#define _IO_NO_WRITES 8\t\t/* Writing not allowd */\n#define _IO_EOF_SEEN 0x10\n#define _IO_ERR_SEEN 0x20\n#define _IO_DELETE_DONT_CLOSE 0x40\t/* Don't call close(_fileno) on cleanup. */\n#define _IO_LINKED 0x80\t\t/* Set if linked (using _chain) to streambuf::_list_all. */\n#define _IO_IN_BACKUP 0x100\n#define _IO_LINE_BUF 0x200\n#define _IO_TIED_PUT_GET 0x400\t/* Set if put and get pointer logicly tied. */\n#define _IO_CURRENTLY_PUTTING 0x800\n#define _IO_IS_APPENDING 0x1000\n#define _IO_IS_FILEBUF 0x2000\n#define _IO_BAD_SEEN 0x4000\n#define _IO_USER_LOCK 0x8000\n\n#define _IO_FLAGS2_MMAP 1\n#define _IO_FLAGS2_NOTCANCEL 2\n#ifdef _LIBC\n# define _IO_FLAGS2_FORTIFY 4\n#endif\n#define _IO_FLAGS2_USER_WBUF 8\n#ifdef _LIBC\n# define _IO_FLAGS2_SCANF_STD 16\n# define _IO_FLAGS2_NOCLOSE 32\n# define _IO_FLAGS2_CLOEXEC 64\n# define _IO_FLAGS2_NEED_LOCK 128\n#endif\n\n/* These are \"formatting flags\" matching the iostream fmtflags enum values. */\n#define _IO_SKIPWS 01\n#define _IO_LEFT 02\n#define _IO_RIGHT 04\n#define _IO_INTERNAL 010\n#define _IO_DEC 020\n#define _IO_OCT 040\n#define _IO_HEX 0100\n#define _IO_SHOWBASE 0200\n#define _IO_SHOWPOINT 0400\n#define _IO_UPPERCASE 01000\n#define _IO_SHOWPOS 02000\n#define _IO_SCIENTIFIC 04000\n#define _IO_FIXED 010000\n#define _IO_UNITBUF 020000\n#define _IO_STDIO 040000\n#define _IO_DONT_CLOSE 0100000\n#define _IO_BOOLALPHA 0200000\n\nstruct _IO_jump_t;\nstruct _IO_FILE;\n\n/* During the build of glibc itself, _IO_lock_t will already have been\n   defined by internal headers.  */\n#ifndef _IO_lock_t_defined\ntypedef void _IO_lock_t;\n#endif\n\n/* A streammarker remembers a position in a buffer. */\n\nstruct _IO_marker {\n\tstruct _IO_marker *_next;\n\tstruct _IO_FILE *_sbuf;\n\t/* If _pos >= 0\n\t   it points to _buf->Gbase()+_pos. FIXME comment */\n\t/* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */\n\tint _pos;\n#if 0\n\tvoid set_streampos(streampos sp) {\n\t\t_spos = sp;\n\t} void set_offset(int offset) {\n\t\t_pos = offset;\n\t\t_spos = (streampos) (-2);\n\t}\n public:\n\tstreammarker(streambuf * sb);\n\t~streammarker();\n\tint saving() {\n\t\treturn _spos == -2;\n\t}\n\tint delta(streammarker &);\n\tint delta();\n#endif\n};\n\n/* This is the structure from the libstdc++ codecvt class.  */\nenum __codecvt_result {\n\t__codecvt_ok,\n\t__codecvt_partial,\n\t__codecvt_error,\n\t__codecvt_noconv\n};\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n/* The order of the elements in the following struct must match the order\n   of the virtual functions in the libstdc++ codecvt class.  */\nstruct _IO_codecvt {\n\tvoid (*__codecvt_destr) (struct _IO_codecvt *);\n\tenum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, __mbstate_t *, const wchar_t *, const wchar_t *, const wchar_t **, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, __mbstate_t *, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, const char **, wchar_t *, wchar_t *, wchar_t **);\n\tint (*__codecvt_do_encoding) (struct _IO_codecvt *);\n\tint (*__codecvt_do_always_noconv) (struct _IO_codecvt *);\n\tint (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, _IO_size_t);\n\tint (*__codecvt_do_max_length) (struct _IO_codecvt *);\n\n\t_IO_iconv_t __cd_in;\n\t_IO_iconv_t __cd_out;\n};\n\n/* Extra data for wide character streams.  */\nstruct _IO_wide_data {\n\twchar_t *_IO_read_ptr;\t/* Current read pointer */\n\twchar_t *_IO_read_end;\t/* End of get area. */\n\twchar_t *_IO_read_base;\t/* Start of putback+get area. */\n\twchar_t *_IO_write_base;\t/* Start of put area. */\n\twchar_t *_IO_write_ptr;\t/* Current put pointer. */\n\twchar_t *_IO_write_end;\t/* End of put area. */\n\twchar_t *_IO_buf_base;\t/* Start of reserve area. */\n\twchar_t *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\twchar_t *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\twchar_t *_IO_backup_base;\t/* Pointer to first valid character of\n\t\t\t\t\t   backup area */\n\twchar_t *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\t__mbstate_t _IO_state;\n\t__mbstate_t _IO_last_state;\n\tstruct _IO_codecvt _codecvt;\n\n\twchar_t _shortbuf[1];\n\n\tconst struct _IO_jump_t *_wide_vtable;\n};\n#endif\n\nstruct _IO_FILE {\n\tint _flags;\t\t/* High-order word is _IO_MAGIC; rest is flags. */\n#define _IO_file_flags _flags\n\n\t/* The following pointers correspond to the C++ streambuf protocol. */\n\t/* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */\n\tchar *_IO_read_ptr;\t/* Current read pointer */\n\tchar *_IO_read_end;\t/* End of get area. */\n\tchar *_IO_read_base;\t/* Start of putback+get area. */\n\tchar *_IO_write_base;\t/* Start of put area. */\n\tchar *_IO_write_ptr;\t/* Current put pointer. */\n\tchar *_IO_write_end;\t/* End of put area. */\n\tchar *_IO_buf_base;\t/* Start of reserve area. */\n\tchar *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\tchar *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\tchar *_IO_backup_base;\t/* Pointer to first valid character of backup area */\n\tchar *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\tstruct _IO_marker *_markers;\n\n\tstruct _IO_FILE *_chain;\n\n\tint _fileno;\n#if 0\n\tint _blksize;\n#else\n\tint _flags2;\n#endif\n\t_IO_off_t _old_offset;\t/* This used to be _offset but it's too small.  */\n\n#define __HAVE_COLUMN\t\t/* temporary */\n\t/* 1+column number of pbase(); 0 is unknown. */\n\tunsigned short _cur_column;\n\tsigned char _vtable_offset;\n\tchar _shortbuf[1];\n\n\t/*  char* _save_gptr;  char* _save_egptr; */\n\n\t_IO_lock_t *_lock;\n#ifdef _IO_USE_OLD_IO_FILE\n};\n\nstruct _IO_FILE_complete {\n\tstruct _IO_FILE _file;\n#endif\n#if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001\n\t_IO_off64_t _offset;\n# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\t/* Wide character stream stuff.  */\n\tstruct _IO_codecvt *_codecvt;\n\tstruct _IO_wide_data *_wide_data;\n\tstruct _IO_FILE *_freeres_list;\n\tvoid *_freeres_buf;\n# else\n\tvoid *__pad1;\n\tvoid *__pad2;\n\tvoid *__pad3;\n\tvoid *__pad4;\n# endif\n\tsize_t __pad5;\n\tint _mode;\n\t/* Make sure we don't get into trouble again.  */\n\tchar _unused2[15 * sizeof(int) - 4 * sizeof(void *) - sizeof(size_t)];\n#endif\n};\n\n#ifndef __cplusplus\ntypedef struct _IO_FILE _IO_FILE;\n#endif\n\nstruct _IO_FILE_plus;\n\nextern struct _IO_FILE_plus _IO_2_1_stdin_;\nextern struct _IO_FILE_plus _IO_2_1_stdout_;\nextern struct _IO_FILE_plus _IO_2_1_stderr_;\n#ifndef _LIBC\n#define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))\n#define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))\n#define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))\n#else\nextern _IO_FILE *_IO_stdin attribute_hidden;\nextern _IO_FILE *_IO_stdout attribute_hidden;\nextern _IO_FILE *_IO_stderr attribute_hidden;\n#endif\n\n/* Functions to do I/O and file management for a stream.  */\n\n/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.\n   Return number of bytes read.  */\ntypedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __nbytes);\n\n/* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes\n   unless there is an error.  Return number of bytes written.  If\n   there is an error, return 0 and do not write anything.  If the file\n   has been opened for append (__mode.__append set), then set the file\n   pointer to the end of the file and then do the write; if not, just\n   write at the current file pointer.  */\ntypedef __ssize_t __io_write_fn(void *__cookie, const char *__buf, size_t __n);\n\n/* Move COOKIE's file position to *POS bytes from the\n   beginning of the file (if W is SEEK_SET),\n   the current position (if W is SEEK_CUR),\n   or the end of the file (if W is SEEK_END).\n   Set *POS to the new file position.\n   Returns zero if successful, nonzero if not.  */\ntypedef int __io_seek_fn(void *__cookie, _IO_off64_t * __pos, int __w);\n\n/* Close COOKIE.  */\ntypedef int __io_close_fn(void *__cookie);\n\n#ifdef __USE_GNU\n/* User-visible names for the above.  */\ntypedef __io_read_fn cookie_read_function_t;\ntypedef __io_write_fn cookie_write_function_t;\ntypedef __io_seek_fn cookie_seek_function_t;\ntypedef __io_close_fn cookie_close_function_t;\n\n/* The structure with the cookie function pointers.  */\ntypedef struct {\n\t__io_read_fn *read;\t/* Read bytes.  */\n\t__io_write_fn *write;\t/* Write bytes.  */\n\t__io_seek_fn *seek;\t/* Seek/tell file position.  */\n\t__io_close_fn *close;\t/* Close file.  */\n} _IO_cookie_io_functions_t;\ntypedef _IO_cookie_io_functions_t cookie_io_functions_t;\n\nstruct _IO_cookie_file;\n\n/* Initialize one of those.  */\nextern void _IO_cookie_init(struct _IO_cookie_file *__cfile, int __read_write, void *__cookie, _IO_cookie_io_functions_t __fns);\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\textern int __underflow(_IO_FILE *);\n\textern int __uflow(_IO_FILE *);\n\textern int __overflow(_IO_FILE *, int);\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t __wunderflow(_IO_FILE *);\n\textern _IO_wint_t __wuflow(_IO_FILE *);\n\textern _IO_wint_t __woverflow(_IO_FILE *, _IO_wint_t);\n#endif\n\n#if  __GNUC__ >= 3\n# define _IO_BE(expr, res) __builtin_expect ((expr), res)\n#else\n# define _IO_BE(expr, res) (expr)\n#endif\n\n#define _IO_getc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)\n#define _IO_peekc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t  && __underflow (_fp) == EOF ? EOF \\\n\t: *(unsigned char *) (_fp)->_IO_read_ptr)\n#define _IO_putc_unlocked(_ch, _fp) \\\n   (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \\\n    ? __overflow (_fp, (unsigned char) (_ch)) \\\n    : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# define _IO_getwc_unlocked(_fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_read_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_read_end), 0)\t\t\t\\\n   ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)\n# define _IO_putwc_unlocked(_wch, _fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_write_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_write_end), 0)\t\t\t\\\n   ? __woverflow (_fp, _wch)\t\t\t\t\t\t\\\n   : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))\n#endif\n\n#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)\n#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)\n\n\textern int _IO_getc(_IO_FILE * __fp);\n\textern int _IO_putc(int __c, _IO_FILE * __fp);\n\textern int _IO_feof(_IO_FILE * __fp) __THROW;\n\textern int _IO_ferror(_IO_FILE * __fp) __THROW;\n\n\textern int _IO_peekc_locked(_IO_FILE * __fp);\n\n/* This one is for Emacs. */\n#define _IO_PENDING_OUTPUT_COUNT(_fp)\t\\\n\t((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)\n\n\textern void _IO_flockfile(_IO_FILE *) __THROW;\n\textern void _IO_funlockfile(_IO_FILE *) __THROW;\n\textern int _IO_ftrylockfile(_IO_FILE *) __THROW;\n\n#define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)\n#define _IO_flockfile(_fp) /**/\n#define _IO_funlockfile(_fp) /**/\n#define _IO_ftrylockfile(_fp) /**/\n#ifndef _IO_cleanup_region_start\n#define _IO_cleanup_region_start(_fct, _fp) /**/\n#endif\n#ifndef _IO_cleanup_region_end\n#define _IO_cleanup_region_end(_Doit) /**/\n#endif\n#define _IO_need_lock(_fp) \\\n  (((_fp)->_flags2 & _IO_FLAGS2_NEED_LOCK) != 0)\n\t extern int _IO_vfscanf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfprintf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_padn(_IO_FILE *, int, _IO_ssize_t);\n\textern _IO_size_t _IO_sgetn(_IO_FILE *, void *, _IO_size_t);\n\n\textern _IO_off64_t _IO_seekoff(_IO_FILE *, _IO_off64_t, int, int);\n\textern _IO_off64_t _IO_seekpos(_IO_FILE *, _IO_off64_t, int);\n\n\textern void _IO_free_backup_area(_IO_FILE *) __THROW;\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t _IO_getwc(_IO_FILE * __fp);\n\textern _IO_wint_t _IO_putwc(wchar_t __wc, _IO_FILE * __fp);\n\textern int _IO_fwide(_IO_FILE * __fp, int __mode) __THROW;\n# if __GNUC__ >= 2\n/* While compiling glibc we have to handle compatibility with very old\n   versions.  */\n#  if defined _LIBC && defined SHARED\n#   include <shlib-compat.h>\n#   if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)\n#    define _IO_fwide_maybe_incompatible \\\n  (__builtin_expect (&_IO_stdin_used == NULL, 0))\n\textern const int _IO_stdin_used;\n\t weak_extern(_IO_stdin_used);\n#   endif\n#  endif\n#  ifndef _IO_fwide_maybe_incompatible\n#   define _IO_fwide_maybe_incompatible (0)\n#  endif\n/* A special optimized version of the function above.  It optimizes the\n   case of initializing an unoriented byte stream.  */\n#  define _IO_fwide(__fp, __mode) \\\n  ({ int __result = (__mode);\t\t\t\t\t\t      \\\n     if (__result < 0 && ! _IO_fwide_maybe_incompatible)\t\t      \\\n       {\t\t\t\t\t\t\t\t      \\\n\t if ((__fp)->_mode == 0)\t\t\t\t\t      \\\n\t   /* We know that all we have to do is to set the flag.  */\t      \\\n\t   (__fp)->_mode = -1;\t\t\t\t\t\t      \\\n\t __result = (__fp)->_mode;\t\t\t\t\t      \\\n       }\t\t\t\t\t\t\t\t      \\\n     else if (__builtin_constant_p (__mode) && (__mode) == 0)\t\t      \\\n       __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode;\t      \\\n     else\t\t\t\t\t\t\t\t      \\\n       __result = _IO_fwide (__fp, __result);\t\t\t\t      \\\n     __result; })\n# endif\n\n\textern int _IO_vfwscanf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfwprintf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_wpadn(_IO_FILE *, wint_t, _IO_ssize_t);\n\textern void _IO_free_wbackup_area(_IO_FILE *) __THROW;\n#endif\n\n#ifdef __LDBL_COMPAT\n# include <bits/libio-ldbl.h>\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* _BITS_LIBIO_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/libm-simd-decl-stubs.h",
    "content": "/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h.\n   Copyright (C) 2014-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/libm-simd-decl-stubs.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Needed definitions could be generated with:\n   for func in $(grep __MATHCALL_VEC math/bits/mathcalls.h |\\\n\t\t sed -r \"s|__MATHCALL_VEC.?\\(||; s|,.*||\"); do\n     echo \"#define __DECL_SIMD_${func}\";\n     echo \"#define __DECL_SIMD_${func}f\";\n     echo \"#define __DECL_SIMD_${func}l\";\n   done\n */\n\n#ifndef _BITS_LIBM_SIMD_DECL_STUBS_H\n#define _BITS_LIBM_SIMD_DECL_STUBS_H 1\n\n#define __DECL_SIMD_cos\n#define __DECL_SIMD_cosf\n#define __DECL_SIMD_cosl\n#define __DECL_SIMD_cosf16\n#define __DECL_SIMD_cosf32\n#define __DECL_SIMD_cosf64\n#define __DECL_SIMD_cosf128\n#define __DECL_SIMD_cosf32x\n#define __DECL_SIMD_cosf64x\n#define __DECL_SIMD_cosf128x\n\n#define __DECL_SIMD_sin\n#define __DECL_SIMD_sinf\n#define __DECL_SIMD_sinl\n#define __DECL_SIMD_sinf16\n#define __DECL_SIMD_sinf32\n#define __DECL_SIMD_sinf64\n#define __DECL_SIMD_sinf128\n#define __DECL_SIMD_sinf32x\n#define __DECL_SIMD_sinf64x\n#define __DECL_SIMD_sinf128x\n\n#define __DECL_SIMD_sincos\n#define __DECL_SIMD_sincosf\n#define __DECL_SIMD_sincosl\n#define __DECL_SIMD_sincosf16\n#define __DECL_SIMD_sincosf32\n#define __DECL_SIMD_sincosf64\n#define __DECL_SIMD_sincosf128\n#define __DECL_SIMD_sincosf32x\n#define __DECL_SIMD_sincosf64x\n#define __DECL_SIMD_sincosf128x\n\n#define __DECL_SIMD_log\n#define __DECL_SIMD_logf\n#define __DECL_SIMD_logl\n#define __DECL_SIMD_logf16\n#define __DECL_SIMD_logf32\n#define __DECL_SIMD_logf64\n#define __DECL_SIMD_logf128\n#define __DECL_SIMD_logf32x\n#define __DECL_SIMD_logf64x\n#define __DECL_SIMD_logf128x\n\n#define __DECL_SIMD_exp\n#define __DECL_SIMD_expf\n#define __DECL_SIMD_expl\n#define __DECL_SIMD_expf16\n#define __DECL_SIMD_expf32\n#define __DECL_SIMD_expf64\n#define __DECL_SIMD_expf128\n#define __DECL_SIMD_expf32x\n#define __DECL_SIMD_expf64x\n#define __DECL_SIMD_expf128x\n\n#define __DECL_SIMD_pow\n#define __DECL_SIMD_powf\n#define __DECL_SIMD_powl\n#define __DECL_SIMD_powf16\n#define __DECL_SIMD_powf32\n#define __DECL_SIMD_powf64\n#define __DECL_SIMD_powf128\n#define __DECL_SIMD_powf32x\n#define __DECL_SIMD_powf64x\n#define __DECL_SIMD_powf128x\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/local_lim.h",
    "content": "/* Minimum guaranteed maximum values for system limits.  Linux version.\n   Copyright (C) 1993-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n/* The kernel header pollutes the namespace with the NR_OPEN symbol\n   and defines LINK_MAX although filesystems have different maxima.  A\n   similar thing is true for OPEN_MAX: the limit can be changed at\n   runtime and therefore the macro must not be defined.  Remove this\n   after including the header if necessary.  */\n#ifndef NR_OPEN\n# define __undef_NR_OPEN\n#endif\n#ifndef LINK_MAX\n# define __undef_LINK_MAX\n#endif\n#ifndef OPEN_MAX\n# define __undef_OPEN_MAX\n#endif\n#ifndef ARG_MAX\n# define __undef_ARG_MAX\n#endif\n\n/* The kernel sources contain a file with all the needed information.  */\n#include <linux/limits.h>\n\n/* Have to remove NR_OPEN?  */\n#ifdef __undef_NR_OPEN\n# undef NR_OPEN\n# undef __undef_NR_OPEN\n#endif\n/* Have to remove LINK_MAX?  */\n#ifdef __undef_LINK_MAX\n# undef LINK_MAX\n# undef __undef_LINK_MAX\n#endif\n/* Have to remove OPEN_MAX?  */\n#ifdef __undef_OPEN_MAX\n# undef OPEN_MAX\n# undef __undef_OPEN_MAX\n#endif\n/* Have to remove ARG_MAX?  */\n#ifdef __undef_ARG_MAX\n# undef ARG_MAX\n# undef __undef_ARG_MAX\n#endif\n\n/* The number of data keys per process.  */\n#define _POSIX_THREAD_KEYS_MAX\t128\n/* This is the value this implementation supports.  */\n#define PTHREAD_KEYS_MAX\t1024\n\n/* Controlling the iterations of destructors for thread-specific data.  */\n#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS\t4\n/* Number of iterations this implementation does.  */\n#define PTHREAD_DESTRUCTOR_ITERATIONS\t_POSIX_THREAD_DESTRUCTOR_ITERATIONS\n\n/* The number of threads per process.  */\n#define _POSIX_THREAD_THREADS_MAX\t64\n/* We have no predefined limit on the number of threads.  */\n#undef PTHREAD_THREADS_MAX\n\n/* Maximum amount by which a process can descrease its asynchronous I/O\n   priority level.  */\n#define AIO_PRIO_DELTA_MAX\t20\n\n/* Minimum size for a thread.  We are free to choose a reasonable value.  */\n#define PTHREAD_STACK_MIN\t16384\n\n/* Maximum number of timer expiration overruns.  */\n#define DELAYTIMER_MAX\t2147483647\n\n/* Maximum tty name length.  */\n#define TTY_NAME_MAX\t\t32\n\n/* Maximum login name length.  This is arbitrary.  */\n#define LOGIN_NAME_MAX\t\t256\n\n/* Maximum host name length.  */\n#define HOST_NAME_MAX\t\t64\n\n/* Maximum message queue priority level.  */\n#define MQ_PRIO_MAX\t\t32768\n\n/* Maximum value the semaphore can have.  */\n#define SEM_VALUE_MAX   (2147483647)\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/locale.h",
    "content": "/* Definition of locale category symbol values.\n   Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _LOCALE_H && !defined _LANGINFO_H\n# error \"Never use <bits/locale.h> directly; include <locale.h> instead.\"\n#endif\n\n#ifndef _BITS_LOCALE_H\n#define _BITS_LOCALE_H\t1\n\n#define __LC_CTYPE\t\t 0\n#define __LC_NUMERIC\t\t 1\n#define __LC_TIME\t\t 2\n#define __LC_COLLATE\t\t 3\n#define __LC_MONETARY\t\t 4\n#define __LC_MESSAGES\t\t 5\n#define __LC_ALL\t\t 6\n#define __LC_PAPER\t\t 7\n#define __LC_NAME\t\t 8\n#define __LC_ADDRESS\t\t 9\n#define __LC_TELEPHONE\t\t10\n#define __LC_MEASUREMENT\t11\n#define __LC_IDENTIFICATION\t12\n\n#endif\t\t\t\t/* bits/locale.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/long-double.h",
    "content": "/* Properties of long double type.  ldbl-96 version.\n   Copyright (C) 2016-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License  published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* long double is distinct from double, so there is nothing to\n   define here.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/math-vector.h",
    "content": "/* Platform-specific SIMD declarations of math functions.\n   Copyright (C) 2014-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/math-vector.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Get default empty definitions for simd declarations.  */\n#include <bits/libm-simd-decl-stubs.h>\n\n#if defined __x86_64__ && defined __FAST_MATH__\n# if defined _OPENMP && _OPENMP >= 201307\n/* OpenMP case.  */\n#  define __DECL_SIMD_x86_64 _Pragma (\"omp declare simd notinbranch\")\n# elif __GNUC_PREREQ (6,0)\n/* W/o OpenMP use GCC 6.* __attribute__ ((__simd__)).  */\n#  define __DECL_SIMD_x86_64 __attribute__ ((__simd__ (\"notinbranch\")))\n# endif\n\n# ifdef __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_cos\n#  define __DECL_SIMD_cos __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_cosf\n#  define __DECL_SIMD_cosf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sin\n#  define __DECL_SIMD_sin __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sinf\n#  define __DECL_SIMD_sinf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sincos\n#  define __DECL_SIMD_sincos __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sincosf\n#  define __DECL_SIMD_sincosf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_log\n#  define __DECL_SIMD_log __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_logf\n#  define __DECL_SIMD_logf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_exp\n#  define __DECL_SIMD_exp __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_expf\n#  define __DECL_SIMD_expf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_pow\n#  define __DECL_SIMD_pow __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_powf\n#  define __DECL_SIMD_powf __DECL_SIMD_x86_64\n\n# endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/mathcalls-helper-functions.h",
    "content": "/* Prototype declarations for math classification macros helpers.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Classify given number.  */\n__MATHDECL_1(int, __fpclassify,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Test for negative number.  */\n__MATHDECL_1(int, __signbit,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return nonzero if VALUE is finite and not NaN.  Used by isfinite macro.  */\n__MATHDECL_1(int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Test equality.  */\n__MATHDECL_1(int, __iseqsig,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Test for signaling NaN.  */\n__MATHDECL_1(int, __issignaling,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/mathcalls.h",
    "content": "/* Prototype declarations for math functions; helper file for <math.h>.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* NOTE: Because of the special way this file is used by <math.h>, this\n   file must NOT be protected from multiple inclusion as header files\n   usually are.\n\n   This file provides prototype declarations for the math functions.\n   Most functions are declared using the macro:\n\n   __MATHCALL (NAME,[_r], (ARGS...));\n\n   This means there is a function `NAME' returning `double' and a function\n   `NAMEf' returning `float'.  Each place `_Mdouble_' appears in the\n   prototype, that is actually `double' in the prototype for `NAME' and\n   `float' in the prototype for `NAMEf'.  Reentrant variant functions are\n   called `NAME_r' and `NAMEf_r'.\n\n   Functions returning other types like `int' are declared using the macro:\n\n   __MATHDECL (TYPE, NAME,[_r], (ARGS...));\n\n   This is just like __MATHCALL but for a function returning `TYPE'\n   instead of `_Mdouble_'.  In all of these cases, there is still\n   both a `NAME' and a `NAMEf' that takes `float' arguments.\n\n   Note that there must be no whitespace before the argument passed for\n   NAME, to make token pasting work with -traditional.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/mathcalls.h> directly; include <math.h> instead.\"\n#endif\n\n/* Trigonometric functions.  */\n\n/* Arc cosine of X.  */\n__MATHCALL(acos,, (_Mdouble_ __x));\n/* Arc sine of X.  */\n__MATHCALL(asin,, (_Mdouble_ __x));\n/* Arc tangent of X.  */\n__MATHCALL(atan,, (_Mdouble_ __x));\n/* Arc tangent of Y/X.  */\n__MATHCALL(atan2,, (_Mdouble_ __y, _Mdouble_ __x));\n\n/* Cosine of X.  */\n__MATHCALL_VEC(cos,, (_Mdouble_ __x));\n/* Sine of X.  */\n__MATHCALL_VEC(sin,, (_Mdouble_ __x));\n/* Tangent of X.  */\n__MATHCALL(tan,, (_Mdouble_ __x));\n\n/* Hyperbolic functions.  */\n\n/* Hyperbolic cosine of X.  */\n__MATHCALL(cosh,, (_Mdouble_ __x));\n/* Hyperbolic sine of X.  */\n__MATHCALL(sinh,, (_Mdouble_ __x));\n/* Hyperbolic tangent of X.  */\n__MATHCALL(tanh,, (_Mdouble_ __x));\n\n#ifdef __USE_GNU\n/* Cosine and sine of X.  */\n__MATHDECL_VEC(void, sincos,, (_Mdouble_ __x, _Mdouble_ * __sinx, _Mdouble_ * __cosx));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n/* Hyperbolic arc cosine of X.  */\n__MATHCALL(acosh,, (_Mdouble_ __x));\n/* Hyperbolic arc sine of X.  */\n__MATHCALL(asinh,, (_Mdouble_ __x));\n/* Hyperbolic arc tangent of X.  */\n__MATHCALL(atanh,, (_Mdouble_ __x));\n#endif\n\n/* Exponential and logarithmic functions.  */\n\n/* Exponential function of X.  */\n__MATHCALL_VEC(exp,, (_Mdouble_ __x));\n\n/* Break VALUE into a normalized fraction and an integral power of 2.  */\n__MATHCALL(frexp,, (_Mdouble_ __x, int *__exponent));\n\n/* X times (two to the EXP power).  */\n__MATHCALL(ldexp,, (_Mdouble_ __x, int __exponent));\n\n/* Natural logarithm of X.  */\n__MATHCALL_VEC(log,, (_Mdouble_ __x));\n\n/* Base-ten logarithm of X.  */\n__MATHCALL(log10,, (_Mdouble_ __x));\n\n/* Break VALUE into integral and fractional parts.  */\n__MATHCALL(modf,, (_Mdouble_ __x, _Mdouble_ * __iptr)) __nonnull((2));\n\n#if __GLIBC_USE (IEC_60559_FUNCS_EXT)\n/* Compute exponent to base ten.  */\n__MATHCALL(exp10,, (_Mdouble_ __x));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n/* Return exp(X) - 1.  */\n__MATHCALL(expm1,, (_Mdouble_ __x));\n\n/* Return log(1 + X).  */\n__MATHCALL(log1p,, (_Mdouble_ __x));\n\n/* Return the base 2 signed integral exponent of X.  */\n__MATHCALL(logb,, (_Mdouble_ __x));\n#endif\n\n#ifdef __USE_ISOC99\n/* Compute base-2 exponential of X.  */\n__MATHCALL(exp2,, (_Mdouble_ __x));\n\n/* Compute base-2 logarithm of X.  */\n__MATHCALL(log2,, (_Mdouble_ __x));\n#endif\n\n/* Power functions.  */\n\n/* Return X to the Y power.  */\n__MATHCALL_VEC(pow,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the square root of X.  */\n__MATHCALL(sqrt,, (_Mdouble_ __x));\n\n#if defined __USE_XOPEN || defined __USE_ISOC99\n/* Return `sqrt(X*X + Y*Y)'.  */\n__MATHCALL(hypot,, (_Mdouble_ __x, _Mdouble_ __y));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n/* Return the cube root of X.  */\n__MATHCALL(cbrt,, (_Mdouble_ __x));\n#endif\n\n/* Nearest integer, absolute value, and remainder functions.  */\n\n/* Smallest integral value not less than X.  */\n__MATHCALLX(ceil,, (_Mdouble_ __x), (__const__));\n\n/* Absolute value of X.  */\n__MATHCALLX(fabs,, (_Mdouble_ __x), (__const__));\n\n/* Largest integer not greater than X.  */\n__MATHCALLX(floor,, (_Mdouble_ __x), (__const__));\n\n/* Floating-point modulo remainder of X/Y.  */\n__MATHCALL(fmod,, (_Mdouble_ __x, _Mdouble_ __y));\n\n#ifdef __USE_MISC\n# if ((!defined __cplusplus \\\n       || __cplusplus < 201103L /* isinf conflicts with C++11.  */ \\\n       || __MATH_DECLARING_DOUBLE == 0)) /* isinff or isinfl don't.  */ \\\n      && !__MATH_DECLARING_FLOATN\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n# endif\n\n# if !__MATH_DECLARING_FLOATN\n/* Return nonzero if VALUE is finite and not NaN.  */\n__MATHDECL_1(int, finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return the remainder of X/Y.  */\n__MATHCALL(drem,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the fractional part of X after dividing out `ilogb (X)'.  */\n__MATHCALL(significand,, (_Mdouble_ __x));\n# endif\n\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n/* Return X with its signed changed to Y's.  */\n__MATHCALLX(copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n#endif\n\n#ifdef __USE_ISOC99\n/* Return representation of qNaN for double type.  */\n__MATHCALLX(nan,, (const char *__tagb), (__const__));\n#endif\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n# if ((!defined __cplusplus \\\n       || __cplusplus < 201103L /* isnan conflicts with C++11.  */ \\\n       || __MATH_DECLARING_DOUBLE == 0)) /* isnanf or isnanl don't.  */ \\\n      && !__MATH_DECLARING_FLOATN\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n# endif\n#endif\n\n#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)\n/* Bessel functions.  */\n__MATHCALL(j0,, (_Mdouble_));\n__MATHCALL(j1,, (_Mdouble_));\n__MATHCALL(jn,, (int, _Mdouble_));\n__MATHCALL(y0,, (_Mdouble_));\n__MATHCALL(y1,, (_Mdouble_));\n__MATHCALL(yn,, (int, _Mdouble_));\n#endif\n\n#if defined __USE_XOPEN || defined __USE_ISOC99\n/* Error and gamma functions.  */\n__MATHCALL(erf,, (_Mdouble_));\n__MATHCALL(erfc,, (_Mdouble_));\n__MATHCALL(lgamma,, (_Mdouble_));\n#endif\n\n#ifdef __USE_ISOC99\n/* True gamma function.  */\n__MATHCALL(tgamma,, (_Mdouble_));\n#endif\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n# if !__MATH_DECLARING_FLOATN\n/* Obsolete alias for `lgamma'.  */\n__MATHCALL(gamma,, (_Mdouble_));\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* Reentrant version of lgamma.  This function uses the global variable\n   `signgam'.  The reentrant version instead takes a pointer and stores\n   the value through it.  */\n__MATHCALL(lgamma, _r, (_Mdouble_, int *__signgamp));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n/* Return the integer nearest X in the direction of the\n   prevailing rounding mode.  */\n__MATHCALL(rint,, (_Mdouble_ __x));\n\n/* Return X + epsilon if X < Y, X - epsilon if X > Y.  */\n__MATHCALL(nextafter,, (_Mdouble_ __x, _Mdouble_ __y));\n# if defined __USE_ISOC99 && !defined __LDBL_COMPAT && !__MATH_DECLARING_FLOATN\n__MATHCALL(nexttoward,, (_Mdouble_ __x, long double __y));\n# endif\n\n# if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN\n/* Return X - epsilon.  */\n__MATHCALL(nextdown,, (_Mdouble_ __x));\n/* Return X + epsilon.  */\n__MATHCALL(nextup,, (_Mdouble_ __x));\n# endif\n\n/* Return the remainder of integer divison X / Y with infinite precision.  */\n__MATHCALL(remainder,, (_Mdouble_ __x, _Mdouble_ __y));\n\n# ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbn,, (_Mdouble_ __x, int __n));\n# endif\n\n/* Return the binary exponent of X, which must be nonzero.  */\n__MATHDECL(int, ilogb,, (_Mdouble_ __x));\n#endif\n\n#if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN\n/* Like ilogb, but returning long int.  */\n__MATHDECL(long int, llogb,, (_Mdouble_ __x));\n#endif\n\n#ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbln,, (_Mdouble_ __x, long int __n));\n\n/* Round X to integral value in floating-point format using current\n   rounding direction, but do not raise inexact exception.  */\n__MATHCALL(nearbyint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHCALLX(round,, (_Mdouble_ __x), (__const__));\n\n/* Round X to the integral value in floating-point format nearest but\n   not larger in magnitude.  */\n__MATHCALLX(trunc,, (_Mdouble_ __x), (__const__));\n\n/* Compute remainder of X and Y and put in *QUO a value with sign of x/y\n   and magnitude congruent `mod 2^n' to the magnitude of the integral\n   quotient x/y, with n >= 3.  */\n__MATHCALL(remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));\n\n/* Conversion functions.  */\n\n/* Round X to nearest integral value according to current rounding\n   direction.  */\n__MATHDECL(long int, lrint,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llrint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHDECL(long int, lround,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llround,, (_Mdouble_ __x));\n\n/* Return positive difference between X and Y.  */\n__MATHCALL(fdim,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return maximum numeric value from X and Y.  */\n__MATHCALLX(fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Return minimum numeric value from X and Y.  */\n__MATHCALLX(fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Multiply-add function computed as a ternary operation.  */\n__MATHCALL(fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#if __GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN\n/* Round X to nearest integer value, rounding halfway cases to even.  */\n__MATHCALLX(roundeven,, (_Mdouble_ __x), (__const__));\n\n/* Round X to nearest signed integer value, not raising inexact, with\n   control of rounding direction and width of result.  */\n__MATHDECL(__intmax_t, fromfp,, (_Mdouble_ __x, int __round, unsigned int __width));\n\n/* Round X to nearest unsigned integer value, not raising inexact,\n   with control of rounding direction and width of result.  */\n__MATHDECL(__uintmax_t, ufromfp,, (_Mdouble_ __x, int __round, unsigned int __width));\n\n/* Round X to nearest signed integer value, raising inexact for\n   non-integers, with control of rounding direction and width of\n   result.  */\n__MATHDECL(__intmax_t, fromfpx,, (_Mdouble_ __x, int __round, unsigned int __width));\n\n/* Round X to nearest unsigned integer value, raising inexact for\n   non-integers, with control of rounding direction and width of\n   result.  */\n__MATHDECL(__uintmax_t, ufromfpx,, (_Mdouble_ __x, int __round, unsigned int __width));\n\n/* Return value with maximum magnitude.  */\n__MATHCALLX(fmaxmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Return value with minimum magnitude.  */\n__MATHCALLX(fminmag,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Total order operation.  */\n__MATHDECL_1(int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))\n    __attribute__ ((__const__));\n\n/* Total order operation on absolute values.  */\n__MATHDECL_1(int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y))\n    __attribute__ ((__const__));\n\n/* Canonicalize floating-point representation.  */\n__MATHDECL_1(int, canonicalize,, (_Mdouble_ * __cx, const _Mdouble_ * __x));\n\n/* Get NaN payload.  */\n__MATHCALL(getpayload,, (const _Mdouble_ * __x));\n\n/* Set quiet NaN payload.  */\n__MATHDECL_1(int, setpayload,, (_Mdouble_ * __x, _Mdouble_ __payload));\n\n/* Set signaling NaN payload.  */\n__MATHDECL_1(int, setpayloadsig,, (_Mdouble_ * __x, _Mdouble_ __payload));\n#endif\n\n#if (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \\\n\t\t\t    && __MATH_DECLARING_DOUBLE\t  \\\n\t\t\t    && !defined __USE_XOPEN2K8))  \\\n     && !__MATH_DECLARING_FLOATN\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalb,, (_Mdouble_ __x, _Mdouble_ __n));\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/mman-linux.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux generic version.\n   Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n# error \"Never use <bits/mman-linux.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.  */\n\n/* Protections are chosen from these bits, OR'd together.  The\n   implementation does not necessarily support PROT_EXEC or PROT_WRITE\n   without PROT_READ.  The only guarantees are that no writing will be\n   allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */\n\n#define PROT_READ\t0x1\t/* Page can be read.  */\n#define PROT_WRITE\t0x2\t/* Page can be written.  */\n#define PROT_EXEC\t0x4\t/* Page can be executed.  */\n#define PROT_NONE\t0x0\t/* Page can not be accessed.  */\n#define PROT_GROWSDOWN\t0x01000000\t/* Extend change to start of\n\t\t\t\t\t   growsdown vma (mprotect only).  */\n#define PROT_GROWSUP\t0x02000000\t/* Extend change to start of\n\t\t\t\t\t   growsup vma (mprotect only).  */\n\n/* Sharing types (must choose one and only one of these).  */\n#define MAP_SHARED\t0x01\t/* Share changes.  */\n#define MAP_PRIVATE\t0x02\t/* Changes are private.  */\n#ifdef __USE_MISC\n# define MAP_TYPE\t0x0f\t/* Mask for type of mapping.  */\n#endif\n\n/* Other flags.  */\n#define MAP_FIXED\t0x10\t/* Interpret addr exactly.  */\n#ifdef __USE_MISC\n# define MAP_FILE\t0\n# ifdef __MAP_ANONYMOUS\n#  define MAP_ANONYMOUS\t__MAP_ANONYMOUS\t/* Don't use a file.  */\n# else\n#  define MAP_ANONYMOUS\t0x20\t/* Don't use a file.  */\n# endif\n# define MAP_ANON\tMAP_ANONYMOUS\n/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.  */\n# define MAP_HUGE_SHIFT\t26\n# define MAP_HUGE_MASK\t0x3f\n#endif\n\n/* Flags to `msync'.  */\n#define MS_ASYNC\t1\t/* Sync memory asynchronously.  */\n#define MS_SYNC\t\t4\t/* Synchronous memory sync.  */\n#define MS_INVALIDATE\t2\t/* Invalidate the caches.  */\n\n/* Flags for `mremap'.  */\n#ifdef __USE_GNU\n# define MREMAP_MAYMOVE\t1\n# define MREMAP_FIXED\t2\n#endif\n\n/* Advice to `madvise'.  */\n#ifdef __USE_MISC\n# define MADV_NORMAL\t  0\t/* No further special treatment.  */\n# define MADV_RANDOM\t  1\t/* Expect random page references.  */\n# define MADV_SEQUENTIAL  2\t/* Expect sequential page references.  */\n# define MADV_WILLNEED\t  3\t/* Will need these pages.  */\n# define MADV_DONTNEED\t  4\t/* Don't need these pages.  */\n# define MADV_FREE\t  8\t/* Free pages only if memory pressure.  */\n# define MADV_REMOVE\t  9\t/* Remove these pages and resources.  */\n# define MADV_DONTFORK\t  10\t/* Do not inherit across fork.  */\n# define MADV_DOFORK\t  11\t/* Do inherit across fork.  */\n# define MADV_MERGEABLE\t  12\t/* KSM may merge identical pages.  */\n# define MADV_UNMERGEABLE 13\t/* KSM may not merge identical pages.  */\n# define MADV_HUGEPAGE\t  14\t/* Worth backing with hugepages.  */\n# define MADV_NOHUGEPAGE  15\t/* Not worth backing with hugepages.  */\n# define MADV_DONTDUMP\t  16\t/* Explicity exclude from the core dump,\n\t\t\t\t   overrides the coredump filter bits.  */\n# define MADV_DODUMP\t  17\t/* Clear the MADV_DONTDUMP flag.  */\n# define MADV_WIPEONFORK  18\t/* Zero memory on fork, child only.  */\n# define MADV_KEEPONFORK  19\t/* Undo MADV_WIPEONFORK.  */\n# define MADV_HWPOISON\t  100\t/* Poison a page for testing.  */\n#endif\n\n/* The POSIX people had to invent similar names for the same things.  */\n#ifdef __USE_XOPEN2K\n# define POSIX_MADV_NORMAL\t0\t/* No further special treatment.  */\n# define POSIX_MADV_RANDOM\t1\t/* Expect random page references.  */\n# define POSIX_MADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n# define POSIX_MADV_WILLNEED\t3\t/* Will need these pages.  */\n# define POSIX_MADV_DONTNEED\t4\t/* Don't need these pages.  */\n#endif\n\n/* Flags for `mlockall'.  */\n#ifndef MCL_CURRENT\n# define MCL_CURRENT\t1\t/* Lock all currently mapped pages.  */\n# define MCL_FUTURE\t2\t/* Lock all additions to address\n\t\t\t\t   space.  */\n# define MCL_ONFAULT\t4\t/* Lock all pages that are\n\t\t\t\t   faulted in.  */\n#endif\n\n#include <bits/mman-shared.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/mman-shared.h",
    "content": "/* Memory-mapping-related declarations/definitions, not architecture-specific.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n# error \"Never use <bits/mman-shared.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n#ifdef __USE_GNU\n/* Flags for memfd_create.  */\n# ifndef MFD_CLOEXEC\n#  define MFD_CLOEXEC 1U\n#  define MFD_ALLOW_SEALING 2U\n#  define MFD_HUGETLB 4U\n# endif\n\n/* Flags for mlock2.  */\n# ifndef MLOCK_ONFAULT\n#  define MLOCK_ONFAULT 1U\n# endif\n\n/* Access rights for pkey_alloc.  */\n# ifndef PKEY_DISABLE_ACCESS\n#  define PKEY_DISABLE_ACCESS 0x1\n#  define PKEY_DISABLE_WRITE 0x2\n# endif\n\n__BEGIN_DECLS\n/* Create a new memory file descriptor.  NAME is a name for debugging.\n   FLAGS is a combination of the MFD_* constants.  */\nint memfd_create(const char *__name, unsigned int __flags) __THROW;\n\n/* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into\n   memory.  FLAGS is a combination of the MLOCK_* flags above.  */\nint mlock2(const void *__addr, size_t __length, unsigned int __flags) __THROW;\n\n/* Allocate a new protection key, with the PKEY_DISABLE_* bits\n   specified in ACCESS_RIGHTS.  The protection key mask for the\n   current thread is updated to match the access privilege for the new\n   key.  */\nint pkey_alloc(unsigned int __flags, unsigned int __access_rights) __THROW;\n\n/* Update the access rights for the current thread for KEY, which must\n   have been allocated using pkey_alloc.  */\nint pkey_set(int __key, unsigned int __access_rights) __THROW;\n\n/* Return the access rights for the current thread for KEY, which must\n   have been allocated using pkey_alloc.  */\nint pkey_get(int __key) __THROW;\n\n/* Free an allocated protection key, which must have been allocated\n   using pkey_alloc.  */\nint pkey_free(int __key) __THROW;\n\n/* Apply memory protection flags for KEY to the specified address\n   range.  */\nint pkey_mprotect(void *__addr, size_t __len, int __prot, int __pkey) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* __USE_GNU */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/mman.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux/x86_64 version.\n   Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n# error \"Never use <bits/mman.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.  */\n\n/* Other flags.  */\n#ifdef __USE_MISC\n# define MAP_32BIT\t0x40\t/* Only give out 32-bit addresses.  */\n#endif\n\n/* These are Linux-specific.  */\n#ifdef __USE_MISC\n# define MAP_GROWSDOWN\t0x00100\t/* Stack-like segment.  */\n# define MAP_DENYWRITE\t0x00800\t/* ETXTBSY */\n# define MAP_EXECUTABLE\t0x01000\t/* Mark it as an executable.  */\n# define MAP_LOCKED\t0x02000\t/* Lock the mapping.  */\n# define MAP_NORESERVE\t0x04000\t/* Don't check for reservations.  */\n# define MAP_POPULATE\t0x08000\t/* Populate (prefault) pagetables.  */\n# define MAP_NONBLOCK\t0x10000\t/* Do not block on IO.  */\n# define MAP_STACK\t0x20000\t/* Allocation is for a stack.  */\n# define MAP_HUGETLB\t0x40000\t/* Create huge page mapping.  */\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/mman-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/netdb.h",
    "content": "/* Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _NETDB_H\n# error \"Never include <bits/netdb.h> directly; use <netdb.h> instead.\"\n#endif\n\n/* Description of data base entry for a single network.  NOTE: here a\n   poor assumption is made.  The network number is expected to fit\n   into an unsigned long int variable.  */\nstruct netent {\n\tchar *n_name;\t\t/* Official name of network.  */\n\tchar **n_aliases;\t/* Alias list.  */\n\tint n_addrtype;\t\t/* Net address type.  */\n\tuint32_t n_net;\t\t/* Network number.  */\n};\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/param.h",
    "content": "/* Old-style Unix parameters and limits.  Linux version.\n   Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n# error \"Never use <bits/param.h> directly; include <sys/param.h> instead.\"\n#endif\n\n#ifndef ARG_MAX\n# define __undef_ARG_MAX\n#endif\n\n#include <linux/limits.h>\n#include <linux/param.h>\n\n/* The kernel headers define ARG_MAX.  The value is wrong, though.  */\n#ifdef __undef_ARG_MAX\n# undef ARG_MAX\n# undef __undef_ARG_MAX\n#endif\n\n#define\tMAXSYMLINKS\t20\n\n/* The following are not really correct but it is a value we used for a\n   long time and which seems to be usable.  People should not use NOFILE\n   and NCARGS anyway.  */\n#define NOFILE\t\t256\n#define\tNCARGS\t\t131072\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/posix1_lim.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.9.2 Minimum Values\tAdded to <limits.h>\n *\n *\tNever include this file directly; use <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX1_LIM_H\n#define\t_BITS_POSIX1_LIM_H\t1\n\n/* These are the standard-mandated minimum values.  */\n\n/* Minimum number of operations in one list I/O call.  */\n#define _POSIX_AIO_LISTIO_MAX\t2\n\n/* Minimal number of outstanding asynchronous I/O operations.  */\n#define _POSIX_AIO_MAX\t\t1\n\n/* Maximum length of arguments to `execve', including environment.  */\n#define\t_POSIX_ARG_MAX\t\t4096\n\n/* Maximum simultaneous processes per real user ID.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_CHILD_MAX\t25\n#else\n# define _POSIX_CHILD_MAX\t6\n#endif\n\n/* Minimal number of timer expiration overruns.  */\n#define _POSIX_DELAYTIMER_MAX\t32\n\n/* Maximum length of a host name (not including the terminating null)\n   as returned from the GETHOSTNAME function.  */\n#define _POSIX_HOST_NAME_MAX\t255\n\n/* Maximum link count of a file.  */\n#define\t_POSIX_LINK_MAX\t\t8\n\n/* Maximum length of login name.  */\n#define\t_POSIX_LOGIN_NAME_MAX\t9\n\n/* Number of bytes in a terminal canonical input queue.  */\n#define\t_POSIX_MAX_CANON\t255\n\n/* Number of bytes for which space will be\n   available in a terminal input queue.  */\n#define\t_POSIX_MAX_INPUT\t255\n\n/* Maximum number of message queues open for a process.  */\n#define _POSIX_MQ_OPEN_MAX\t8\n\n/* Maximum number of supported message priorities.  */\n#define _POSIX_MQ_PRIO_MAX\t32\n\n/* Number of bytes in a filename.  */\n#define\t_POSIX_NAME_MAX\t\t14\n\n/* Number of simultaneous supplementary group IDs per process.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_NGROUPS_MAX\t8\n#else\n# define _POSIX_NGROUPS_MAX\t0\n#endif\n\n/* Number of files one process can have open at once.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_OPEN_MAX\t20\n#else\n# define _POSIX_OPEN_MAX\t16\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Number of descriptors that a process may examine with `pselect' or\n   `select'.  */\n# define _POSIX_FD_SETSIZE\t_POSIX_OPEN_MAX\n#endif\n\n/* Number of bytes in a pathname.  */\n#define\t_POSIX_PATH_MAX\t\t256\n\n/* Number of bytes than can be written atomically to a pipe.  */\n#define\t_POSIX_PIPE_BUF\t\t512\n\n/* The number of repeated occurrences of a BRE permitted by the\n   REGEXEC and REGCOMP functions when using the interval notation.  */\n#define _POSIX_RE_DUP_MAX\t255\n\n/* Minimal number of realtime signals reserved for the application.  */\n#define _POSIX_RTSIG_MAX\t8\n\n/* Number of semaphores a process can have.  */\n#define _POSIX_SEM_NSEMS_MAX\t256\n\n/* Maximal value of a semaphore.  */\n#define _POSIX_SEM_VALUE_MAX\t32767\n\n/* Number of pending realtime signals.  */\n#define _POSIX_SIGQUEUE_MAX\t32\n\n/* Largest value of a `ssize_t'.  */\n#define\t_POSIX_SSIZE_MAX\t32767\n\n/* Number of streams a process can have open at once.  */\n#define\t_POSIX_STREAM_MAX\t8\n\n/* The number of bytes in a symbolic link.  */\n#define _POSIX_SYMLINK_MAX\t255\n\n/* The number of symbolic links that can be traversed in the\n   resolution of a pathname in the absence of a loop.  */\n#define _POSIX_SYMLOOP_MAX\t8\n\n/* Number of timer for a process.  */\n#define _POSIX_TIMER_MAX\t32\n\n/* Maximum number of characters in a tty name.  */\n#define\t_POSIX_TTY_NAME_MAX\t9\n\n/* Maximum length of a timezone name (element of `tzname').  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_TZNAME_MAX\t6\n#else\n# define _POSIX_TZNAME_MAX\t3\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Maximum number of connections that can be queued on a socket.  */\n# define _POSIX_QLIMIT\t\t1\n\n/* Maximum number of bytes that can be buffered on a socket for send\n   or receive.  */\n# define _POSIX_HIWAT\t\t_POSIX_PIPE_BUF\n\n/* Maximum number of elements in an `iovec' array.  */\n# define _POSIX_UIO_MAXIOV\t16\n#endif\n\n/* Maximum clock resolution in nanoseconds.  */\n#define _POSIX_CLOCKRES_MIN\t20000000\n\n/* Get the implementation-specific values for the above.  */\n#include <bits/local_lim.h>\n\n#ifndef\tSSIZE_MAX\n# define SSIZE_MAX\tLONG_MAX\n#endif\n\n/* This value is a guaranteed minimum maximum.\n   The current maximum can be got from `sysconf'.  */\n\n#ifndef\tNGROUPS_MAX\n# define NGROUPS_MAX\t8\n#endif\n\n#endif\t\t\t\t/* bits/posix1_lim.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/posix2_lim.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; include <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX2_LIM_H\n#define\t_BITS_POSIX2_LIM_H\t1\n\n/* The maximum `ibase' and `obase' values allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_BASE_MAX\t\t99\n\n/* The maximum number of elements allowed in an array by the `bc' utility.  */\n#define\t_POSIX2_BC_DIM_MAX\t\t2048\n\n/* The maximum `scale' value allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_SCALE_MAX\t\t99\n\n/* The maximum length of a string constant accepted by the `bc' utility.  */\n#define\t_POSIX2_BC_STRING_MAX\t\t1000\n\n/* The maximum number of weights that can be assigned to an entry of\n   the LC_COLLATE `order' keyword in the locale definition file.  */\n#define\t_POSIX2_COLL_WEIGHTS_MAX\t2\n\n/* The maximum number of expressions that can be nested\n   within parentheses by the `expr' utility.  */\n#define\t_POSIX2_EXPR_NEST_MAX\t\t32\n\n/* The maximum length, in bytes, of an input line.  */\n#define\t_POSIX2_LINE_MAX\t\t2048\n\n/* The maximum number of repeated occurrences of a regular expression\n   permitted when using the interval notation `\\{M,N\\}'.  */\n#define\t_POSIX2_RE_DUP_MAX\t\t255\n\n/* The maximum number of bytes in a character class name.  We have no\n   fixed limit, 2048 is a high number.  */\n#define\t_POSIX2_CHARCLASS_NAME_MAX\t14\n\n/* These values are implementation-specific,\n   and may vary within the implementation.\n   Their precise values can be obtained from sysconf.  */\n\n#ifndef\tBC_BASE_MAX\n#define\tBC_BASE_MAX\t\t_POSIX2_BC_BASE_MAX\n#endif\n#ifndef\tBC_DIM_MAX\n#define\tBC_DIM_MAX\t\t_POSIX2_BC_DIM_MAX\n#endif\n#ifndef\tBC_SCALE_MAX\n#define\tBC_SCALE_MAX\t\t_POSIX2_BC_SCALE_MAX\n#endif\n#ifndef\tBC_STRING_MAX\n#define\tBC_STRING_MAX\t\t_POSIX2_BC_STRING_MAX\n#endif\n#ifndef\tCOLL_WEIGHTS_MAX\n#define\tCOLL_WEIGHTS_MAX\t255\n#endif\n#ifndef\tEXPR_NEST_MAX\n#define\tEXPR_NEST_MAX\t\t_POSIX2_EXPR_NEST_MAX\n#endif\n#ifndef\tLINE_MAX\n#define\tLINE_MAX\t\t_POSIX2_LINE_MAX\n#endif\n#ifndef\tCHARCLASS_NAME_MAX\n#define\tCHARCLASS_NAME_MAX\t2048\n#endif\n\n/* This value is defined like this in regex.h.  */\n#define\tRE_DUP_MAX (0x7fff)\n\n#endif\t\t\t\t/* bits/posix2_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/posix_opt.h",
    "content": "/* Define POSIX options for Linux.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_BITS_POSIX_OPT_H\n#define\t_BITS_POSIX_OPT_H\t1\n\n/* Job control is supported.  */\n#define\t_POSIX_JOB_CONTROL\t1\n\n/* Processes have a saved set-user-ID and a saved set-group-ID.  */\n#define\t_POSIX_SAVED_IDS\t1\n\n/* Priority scheduling is supported.  */\n#define\t_POSIX_PRIORITY_SCHEDULING\t200809L\n\n/* Synchronizing file data is supported.  */\n#define\t_POSIX_SYNCHRONIZED_IO\t200809L\n\n/* The fsync function is present.  */\n#define\t_POSIX_FSYNC\t200809L\n\n/* Mapping of files to memory is supported.  */\n#define\t_POSIX_MAPPED_FILES\t200809L\n\n/* Locking of all memory is supported.  */\n#define\t_POSIX_MEMLOCK\t200809L\n\n/* Locking of ranges of memory is supported.  */\n#define\t_POSIX_MEMLOCK_RANGE\t200809L\n\n/* Setting of memory protections is supported.  */\n#define\t_POSIX_MEMORY_PROTECTION\t200809L\n\n/* Some filesystems allow all users to change file ownership.  */\n#define\t_POSIX_CHOWN_RESTRICTED\t0\n\n/* `c_cc' member of 'struct termios' structure can be disabled by\n   using the value _POSIX_VDISABLE.  */\n#define\t_POSIX_VDISABLE\t'\\0'\n\n/* Filenames are not silently truncated.  */\n#define\t_POSIX_NO_TRUNC\t1\n\n/* X/Open realtime support is available.  */\n#define _XOPEN_REALTIME\t1\n\n/* X/Open thread realtime support is available.  */\n#define _XOPEN_REALTIME_THREADS\t1\n\n/* XPG4.2 shared memory is supported.  */\n#define\t_XOPEN_SHM\t1\n\n/* Tell we have POSIX threads.  */\n#define _POSIX_THREADS\t200809L\n\n/* We have the reentrant functions described in POSIX.  */\n#define _POSIX_REENTRANT_FUNCTIONS      1\n#define _POSIX_THREAD_SAFE_FUNCTIONS\t200809L\n\n/* We provide priority scheduling for threads.  */\n#define _POSIX_THREAD_PRIORITY_SCHEDULING\t200809L\n\n/* We support user-defined stack sizes.  */\n#define _POSIX_THREAD_ATTR_STACKSIZE\t200809L\n\n/* We support user-defined stacks.  */\n#define _POSIX_THREAD_ATTR_STACKADDR\t200809L\n\n/* We support priority inheritence.  */\n#define _POSIX_THREAD_PRIO_INHERIT\t200809L\n\n/* We support priority protection, though only for non-robust\n   mutexes.  */\n#define _POSIX_THREAD_PRIO_PROTECT\t200809L\n\n#ifdef __USE_XOPEN2K8\n/* We support priority inheritence for robust mutexes.  */\n# define _POSIX_THREAD_ROBUST_PRIO_INHERIT\t200809L\n\n/* We do not support priority protection for robust mutexes.  */\n# define _POSIX_THREAD_ROBUST_PRIO_PROTECT\t-1\n#endif\n\n/* We support POSIX.1b semaphores.  */\n#define _POSIX_SEMAPHORES\t200809L\n\n/* Real-time signals are supported.  */\n#define _POSIX_REALTIME_SIGNALS\t200809L\n\n/* We support asynchronous I/O.  */\n#define _POSIX_ASYNCHRONOUS_IO\t200809L\n#define _POSIX_ASYNC_IO\t\t1\n/* Alternative name for Unix98.  */\n#define _LFS_ASYNCHRONOUS_IO\t1\n/* Support for prioritization is also available.  */\n#define _POSIX_PRIORITIZED_IO\t200809L\n\n/* The LFS support in asynchronous I/O is also available.  */\n#define _LFS64_ASYNCHRONOUS_IO\t1\n\n/* The rest of the LFS is also available.  */\n#define _LFS_LARGEFILE\t\t1\n#define _LFS64_LARGEFILE\t1\n#define _LFS64_STDIO\t\t1\n\n/* POSIX shared memory objects are implemented.  */\n#define _POSIX_SHARED_MEMORY_OBJECTS\t200809L\n\n/* CPU-time clocks support needs to be checked at runtime.  */\n#define _POSIX_CPUTIME\t0\n\n/* Clock support in threads must be also checked at runtime.  */\n#define _POSIX_THREAD_CPUTIME\t0\n\n/* GNU libc provides regular expression handling.  */\n#define _POSIX_REGEXP\t1\n\n/* Reader/Writer locks are available.  */\n#define _POSIX_READER_WRITER_LOCKS\t200809L\n\n/* We have a POSIX shell.  */\n#define _POSIX_SHELL\t1\n\n/* We support the Timeouts option.  */\n#define _POSIX_TIMEOUTS\t200809L\n\n/* We support spinlocks.  */\n#define _POSIX_SPIN_LOCKS\t200809L\n\n/* The `spawn' function family is supported.  */\n#define _POSIX_SPAWN\t200809L\n\n/* We have POSIX timers.  */\n#define _POSIX_TIMERS\t200809L\n\n/* The barrier functions are available.  */\n#define _POSIX_BARRIERS\t200809L\n\n/* POSIX message queues are available.  */\n#define\t_POSIX_MESSAGE_PASSING\t200809L\n\n/* Thread process-shared synchronization is supported.  */\n#define _POSIX_THREAD_PROCESS_SHARED\t200809L\n\n/* The monotonic clock might be available.  */\n#define _POSIX_MONOTONIC_CLOCK\t0\n\n/* The clock selection interfaces are available.  */\n#define _POSIX_CLOCK_SELECTION\t200809L\n\n/* Advisory information interfaces are available.  */\n#define _POSIX_ADVISORY_INFO\t200809L\n\n/* IPv6 support is available.  */\n#define _POSIX_IPV6\t200809L\n\n/* Raw socket support is available.  */\n#define _POSIX_RAW_SOCKETS\t200809L\n\n/* We have at least one terminal.  */\n#define _POSIX2_CHAR_TERM\t200809L\n\n/* Neither process nor thread sporadic server interfaces is available.  */\n#define _POSIX_SPORADIC_SERVER\t-1\n#define _POSIX_THREAD_SPORADIC_SERVER\t-1\n\n/* trace.h is not available.  */\n#define _POSIX_TRACE\t-1\n#define _POSIX_TRACE_EVENT_FILTER\t-1\n#define _POSIX_TRACE_INHERIT\t-1\n#define _POSIX_TRACE_LOG\t-1\n\n/* Typed memory objects are not available.  */\n#define _POSIX_TYPED_MEMORY_OBJECTS\t-1\n\n#endif\t\t\t\t/* bits/posix_opt.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/pthreadtypes-arch.h",
    "content": "/* Copyright (C) 2002-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_PTHREADTYPES_ARCH_H\n#define _BITS_PTHREADTYPES_ARCH_H\t1\n\n#include <bits/wordsize.h>\n\n#ifdef __x86_64__\n# if __WORDSIZE == 64\n#  define __SIZEOF_PTHREAD_MUTEX_T 40\n#  define __SIZEOF_PTHREAD_ATTR_T 56\n#  define __SIZEOF_PTHREAD_MUTEX_T 40\n#  define __SIZEOF_PTHREAD_RWLOCK_T 56\n#  define __SIZEOF_PTHREAD_BARRIER_T 32\n# else\n#  define __SIZEOF_PTHREAD_MUTEX_T 32\n#  define __SIZEOF_PTHREAD_ATTR_T 32\n#  define __SIZEOF_PTHREAD_MUTEX_T 32\n#  define __SIZEOF_PTHREAD_RWLOCK_T 44\n#  define __SIZEOF_PTHREAD_BARRIER_T 20\n# endif\n#else\n# define __SIZEOF_PTHREAD_MUTEX_T 24\n# define __SIZEOF_PTHREAD_ATTR_T 36\n# define __SIZEOF_PTHREAD_MUTEX_T 24\n# define __SIZEOF_PTHREAD_RWLOCK_T 32\n# define __SIZEOF_PTHREAD_BARRIER_T 20\n#endif\n#define __SIZEOF_PTHREAD_MUTEXATTR_T 4\n#define __SIZEOF_PTHREAD_COND_T 48\n#define __SIZEOF_PTHREAD_CONDATTR_T 4\n#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8\n#define __SIZEOF_PTHREAD_BARRIERATTR_T 4\n\n/* Definitions for internal mutex struct.  */\n#define __PTHREAD_COMPAT_PADDING_MID\n#define __PTHREAD_COMPAT_PADDING_END\n#define __PTHREAD_MUTEX_LOCK_ELISION    1\n#ifdef __x86_64__\n# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND  0\n# define __PTHREAD_MUTEX_USE_UNION          0\n#else\n# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND  1\n# define __PTHREAD_MUTEX_USE_UNION          1\n#endif\n\n#define __LOCK_ALIGNMENT\n#define __ONCE_ALIGNMENT\n\nstruct __pthread_rwlock_arch_t {\n\tunsigned int __readers;\n\tunsigned int __writers;\n\tunsigned int __wrphase_futex;\n\tunsigned int __writers_futex;\n\tunsigned int __pad3;\n\tunsigned int __pad4;\n#ifdef __x86_64__\n\tint __cur_writer;\n\tint __shared;\n\tsigned char __rwelision;\n# ifdef  __ILP32__\n\tunsigned char __pad1[3];\n#  define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 }\n# else\n\tunsigned char __pad1[7];\n#  define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }\n# endif\n\tunsigned long int __pad2;\n\t/* FLAGS must stay at this position in the structure to maintain\n\t   binary compatibility.  */\n\tunsigned int __flags;\n# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED\t1\n#else\n\t/* FLAGS must stay at this position in the structure to maintain\n\t   binary compatibility.  */\n\tunsigned char __flags;\n\tunsigned char __shared;\n\tsigned char __rwelision;\n# define __PTHREAD_RWLOCK_ELISION_EXTRA 0\n\tunsigned char __pad2;\n\tint __cur_writer;\n#endif\n};\n\n#ifndef __x86_64__\n/* Extra attributes for the cleanup functions.  */\n# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))\n#endif\n\n#endif\t\t\t\t/* bits/pthreadtypes.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/pthreadtypes.h",
    "content": "/* Declaration of common pthread types for all architectures.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_PTHREADTYPES_COMMON_H\n# define _BITS_PTHREADTYPES_COMMON_H\t1\n\n/* For internal mutex and condition variable definitions.  */\n#include <bits/thread-shared-types.h>\n\n/* Thread identifiers.  The structure of the attribute type is not\n   exposed on purpose.  */\ntypedef unsigned long int pthread_t;\n\n/* Data structures for mutex handling.  The structure of the attribute\n   type is not exposed on purpose.  */\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_MUTEXATTR_T];\n\tint __align;\n} pthread_mutexattr_t;\n\n/* Data structure for condition variable handling.  The structure of\n   the attribute type is not exposed on purpose.  */\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_CONDATTR_T];\n\tint __align;\n} pthread_condattr_t;\n\n/* Keys for thread-specific data */\ntypedef unsigned int pthread_key_t;\n\n/* Once-only execution */\ntypedef int __ONCE_ALIGNMENT pthread_once_t;\n\nunion pthread_attr_t {\n\tchar __size[__SIZEOF_PTHREAD_ATTR_T];\n\tlong int __align;\n};\n#ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n# define __have_pthread_attr_t 1\n#endif\n\ntypedef union {\n\tstruct __pthread_mutex_s __data;\n\tchar __size[__SIZEOF_PTHREAD_MUTEX_T];\n\tlong int __align;\n} pthread_mutex_t;\n\ntypedef union {\n\tstruct __pthread_cond_s __data;\n\tchar __size[__SIZEOF_PTHREAD_COND_T];\n\t__extension__ long long int __align;\n} pthread_cond_t;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Data structure for reader-writer lock variable handling.  The\n   structure of the attribute type is deliberately not exposed.  */\ntypedef union {\n\tstruct __pthread_rwlock_arch_t __data;\n\tchar __size[__SIZEOF_PTHREAD_RWLOCK_T];\n\tlong int __align;\n} pthread_rwlock_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];\n\tlong int __align;\n} pthread_rwlockattr_t;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* POSIX spinlock data type.  */\ntypedef volatile int pthread_spinlock_t;\n\n/* POSIX barriers data type.  The structure of the type is\n   deliberately not exposed.  */\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIER_T];\n\tlong int __align;\n} pthread_barrier_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIERATTR_T];\n\tint __align;\n} pthread_barrierattr_t;\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/resource.h",
    "content": "/* Bit values & structures for resource limits.  Linux version.\n   Copyright (C) 1994-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_RESOURCE_H\n# error \"Never use <bits/resource.h> directly; include <sys/resource.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\n/* Transmute defines to enumerations.  The macro re-definitions are\n   necessary because some programs want to test for operating system\n   features with #ifdef RUSAGE_SELF.  In ISO C the reflexive\n   definition is a no-op.  */\n\n/* Kinds of resource limit.  */\nenum __rlimit_resource {\n\t/* Per-process CPU limit, in seconds.  */\n\tRLIMIT_CPU = 0,\n#define RLIMIT_CPU RLIMIT_CPU\n\n\t/* Largest file that can be created, in bytes.  */\n\tRLIMIT_FSIZE = 1,\n#define\tRLIMIT_FSIZE RLIMIT_FSIZE\n\n\t/* Maximum size of data segment, in bytes.  */\n\tRLIMIT_DATA = 2,\n#define\tRLIMIT_DATA RLIMIT_DATA\n\n\t/* Maximum size of stack segment, in bytes.  */\n\tRLIMIT_STACK = 3,\n#define\tRLIMIT_STACK RLIMIT_STACK\n\n\t/* Largest core file that can be created, in bytes.  */\n\tRLIMIT_CORE = 4,\n#define\tRLIMIT_CORE RLIMIT_CORE\n\n\t/* Largest resident set size, in bytes.\n\t   This affects swapping; processes that are exceeding their\n\t   resident set size will be more likely to have physical memory\n\t   taken from them.  */\n\t__RLIMIT_RSS = 5,\n#define\tRLIMIT_RSS __RLIMIT_RSS\n\n\t/* Number of open files.  */\n\tRLIMIT_NOFILE = 7,\n\t__RLIMIT_OFILE = RLIMIT_NOFILE,\t/* BSD name for same.  */\n#define RLIMIT_NOFILE RLIMIT_NOFILE\n#define RLIMIT_OFILE __RLIMIT_OFILE\n\n\t/* Address space limit.  */\n\tRLIMIT_AS = 9,\n#define RLIMIT_AS RLIMIT_AS\n\n\t/* Number of processes.  */\n\t__RLIMIT_NPROC = 6,\n#define RLIMIT_NPROC __RLIMIT_NPROC\n\n\t/* Locked-in-memory address space.  */\n\t__RLIMIT_MEMLOCK = 8,\n#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK\n\n\t/* Maximum number of file locks.  */\n\t__RLIMIT_LOCKS = 10,\n#define RLIMIT_LOCKS __RLIMIT_LOCKS\n\n\t/* Maximum number of pending signals.  */\n\t__RLIMIT_SIGPENDING = 11,\n#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING\n\n\t/* Maximum bytes in POSIX message queues.  */\n\t__RLIMIT_MSGQUEUE = 12,\n#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE\n\n\t/* Maximum nice priority allowed to raise to.\n\t   Nice levels 19 .. -20 correspond to 0 .. 39\n\t   values of this resource limit.  */\n\t__RLIMIT_NICE = 13,\n#define RLIMIT_NICE __RLIMIT_NICE\n\n\t/* Maximum realtime priority allowed for non-priviledged\n\t   processes.  */\n\t__RLIMIT_RTPRIO = 14,\n#define RLIMIT_RTPRIO __RLIMIT_RTPRIO\n\n\t/* Maximum CPU time in µs that a process scheduled under a real-time\n\t   scheduling policy may consume without making a blocking system\n\t   call before being forcibly descheduled.  */\n\t__RLIMIT_RTTIME = 15,\n#define RLIMIT_RTTIME __RLIMIT_RTTIME\n\n\t__RLIMIT_NLIMITS = 16,\n\t__RLIM_NLIMITS = __RLIMIT_NLIMITS\n#define RLIMIT_NLIMITS __RLIMIT_NLIMITS\n#define RLIM_NLIMITS __RLIM_NLIMITS\n};\n\n/* Value to indicate that there is no limit.  */\n#ifndef __USE_FILE_OFFSET64\n# define RLIM_INFINITY ((__rlim_t) -1)\n#else\n# define RLIM_INFINITY 0xffffffffffffffffuLL\n#endif\n\n#ifdef __USE_LARGEFILE64\n# define RLIM64_INFINITY 0xffffffffffffffffuLL\n#endif\n\n/* We can represent all limits.  */\n#define RLIM_SAVED_MAX\tRLIM_INFINITY\n#define RLIM_SAVED_CUR\tRLIM_INFINITY\n\n/* Type for resource quantity measurement.  */\n#ifndef __USE_FILE_OFFSET64\ntypedef __rlim_t rlim_t;\n#else\ntypedef __rlim64_t rlim_t;\n#endif\n#ifdef __USE_LARGEFILE64\ntypedef __rlim64_t rlim64_t;\n#endif\n\nstruct rlimit {\n\t/* The current (soft) limit.  */\n\trlim_t rlim_cur;\n\t/* The hard limit.  */\n\trlim_t rlim_max;\n};\n\n#ifdef __USE_LARGEFILE64\nstruct rlimit64 {\n\t/* The current (soft) limit.  */\n\trlim64_t rlim_cur;\n\t/* The hard limit.  */\n\trlim64_t rlim_max;\n};\n#endif\n\n/* Whose usage statistics do you want?  */\nenum __rusage_who {\n\t/* The calling process.  */\n\tRUSAGE_SELF = 0,\n#define RUSAGE_SELF RUSAGE_SELF\n\n\t/* All of its terminated child processes.  */\n\tRUSAGE_CHILDREN = -1\n#define RUSAGE_CHILDREN RUSAGE_CHILDREN\n#ifdef __USE_GNU\n\t    ,\n\t/* The calling thread.  */\n\tRUSAGE_THREAD = 1\n# define RUSAGE_THREAD RUSAGE_THREAD\n\t    /* Name for the same functionality on Solaris.  */\n# define RUSAGE_LWP RUSAGE_THREAD\n#endif\n};\n\n#include <bits/types/struct_timeval.h>\n#include <bits/types/struct_rusage.h>\n\n/* Priority limits.  */\n#define PRIO_MIN\t-20\t/* Minimum priority a process can have.  */\n#define PRIO_MAX\t20\t/* Maximum priority a process can have.  */\n\n/* The type of the WHICH argument to `getpriority' and `setpriority',\n   indicating what flavor of entity the WHO argument specifies.  */\nenum __priority_which {\n\tPRIO_PROCESS = 0,\t/* WHO is a process ID.  */\n#define PRIO_PROCESS PRIO_PROCESS\n\tPRIO_PGRP = 1,\t\t/* WHO is a process group ID.  */\n#define PRIO_PGRP PRIO_PGRP\n\tPRIO_USER = 2\t\t/* WHO is a user ID.  */\n#define PRIO_USER PRIO_USER\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Modify and return resource limits of a process atomically.  */\n# ifndef __USE_FILE_OFFSET64\nextern int prlimit(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit *__new_limit, struct rlimit *__old_limit) __THROW;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(prlimit, (__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit * __new_limit, struct rlimit * __old_limit), prlimit64);\n#  else\n#   define prlimit prlimit64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int prlimit64(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit64 *__new_limit, struct rlimit64 *__old_limit) __THROW;\n# endif\n#endif\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sched.h",
    "content": "/* Definitions of constants and data structure for POSIX 1003.1b-1993\n   scheduling interface.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SCHED_H\n#define _BITS_SCHED_H 1\n\n#ifndef _SCHED_H\n# error \"Never include <bits/sched.h> directly; use <sched.h> instead.\"\n#endif\n\n/* Scheduling algorithms.  */\n#define SCHED_OTHER\t\t0\n#define SCHED_FIFO\t\t1\n#define SCHED_RR\t\t2\n#ifdef __USE_GNU\n# define SCHED_BATCH\t\t3\n# define SCHED_ISO\t\t4\n# define SCHED_IDLE\t\t5\n# define SCHED_DEADLINE\t\t6\n\n# define SCHED_RESET_ON_FORK\t0x40000000\n#endif\n\n#ifdef __USE_GNU\n/* Cloning flags.  */\n# define CSIGNAL       0x000000ff\t/* Signal mask to be sent at exit.  */\n# define CLONE_VM      0x00000100\t/* Set if VM shared between processes.  */\n# define CLONE_FS      0x00000200\t/* Set if fs info shared between processes.  */\n# define CLONE_FILES   0x00000400\t/* Set if open files shared between processes.  */\n# define CLONE_SIGHAND 0x00000800\t/* Set if signal handlers shared.  */\n# define CLONE_PTRACE  0x00002000\t/* Set if tracing continues on the child.  */\n# define CLONE_VFORK   0x00004000\t/* Set if the parent wants the child to\n\t\t\t\t\t   wake it up on mm_release.  */\n# define CLONE_PARENT  0x00008000\t/* Set if we want to have the same\n\t\t\t\t\t   parent as the cloner.  */\n# define CLONE_THREAD  0x00010000\t/* Set to add to same thread group.  */\n# define CLONE_NEWNS   0x00020000\t/* Set to create new namespace.  */\n# define CLONE_SYSVSEM 0x00040000\t/* Set to shared SVID SEM_UNDO semantics.  */\n# define CLONE_SETTLS  0x00080000\t/* Set TLS info.  */\n# define CLONE_PARENT_SETTID 0x00100000\t/* Store TID in userlevel buffer\n\t\t\t\t\t   before MM copy.  */\n# define CLONE_CHILD_CLEARTID 0x00200000\t/* Register exit futex and memory\n\t\t\t\t\t\t   location to clear.  */\n# define CLONE_DETACHED 0x00400000\t/* Create clone detached.  */\n# define CLONE_UNTRACED 0x00800000\t/* Set if the tracing process can't\n\t\t\t\t\t   force CLONE_PTRACE on this clone.  */\n# define CLONE_CHILD_SETTID 0x01000000\t/* Store TID in userlevel buffer in\n\t\t\t\t\t   the child.  */\n# define CLONE_NEWCGROUP    0x02000000\t/* New cgroup namespace.  */\n# define CLONE_NEWUTS\t0x04000000\t/* New utsname group.  */\n# define CLONE_NEWIPC\t0x08000000\t/* New ipcs.  */\n# define CLONE_NEWUSER\t0x10000000\t/* New user namespace.  */\n# define CLONE_NEWPID\t0x20000000\t/* New pid namespace.  */\n# define CLONE_NEWNET\t0x40000000\t/* New network namespace.  */\n# define CLONE_IO\t0x80000000\t/* Clone I/O context.  */\n#endif\n\n/* Data structure to describe a process' schedulability.  */\nstruct sched_param {\n\tint sched_priority;\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Clone current process.  */\nextern int clone(int (*__fn) (void *__arg), void *__child_stack, int __flags, void *__arg, ...) __THROW;\n\n/* Unshare the specified resources.  */\nextern int unshare(int __flags) __THROW;\n\n/* Get index of currently used CPU.  */\nextern int sched_getcpu(void) __THROW;\n\n/* Switch process to namespace of type NSTYPE indicated by FD.  */\nextern int setns(int __fd, int __nstype) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* bits/sched.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/select.h",
    "content": "/* Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SELECT_H\n# error \"Never use <bits/select.h> directly; include <sys/select.h> instead.\"\n#endif\n\n#include <bits/wordsize.h>\n\n#if defined __GNUC__ && __GNUC__ >= 2\n\n# if __WORDSIZE == 64\n#  define __FD_ZERO_STOS \"stosq\"\n# else\n#  define __FD_ZERO_STOS \"stosl\"\n# endif\n\n# define __FD_ZERO(fdsp) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    int __d0, __d1;\t\t\t\t\t\t\t      \\\n    __asm__ __volatile__ (\"cld; rep; \" __FD_ZERO_STOS\t\t\t      \\\n\t\t\t  : \"=c\" (__d0), \"=D\" (__d1)\t\t\t      \\\n\t\t\t  : \"a\" (0), \"0\" (sizeof (fd_set)\t\t      \\\n\t\t\t\t\t  / sizeof (__fd_mask)),\t      \\\n\t\t\t    \"1\" (&__FDS_BITS (fdsp)[0])\t\t\t      \\\n\t\t\t  : \"memory\");\t\t\t\t\t      \\\n  } while (0)\n\n#else\t\t\t\t/* ! GNU CC */\n\n/* We don't use `memset' because this would require a prototype and\n   the array isn't too big.  */\n# define __FD_ZERO(set)  \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    unsigned int __i;\t\t\t\t\t\t\t      \\\n    fd_set *__arr = (set);\t\t\t\t\t\t      \\\n    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)\t      \\\n      __FDS_BITS (__arr)[__i] = 0;\t\t\t\t\t      \\\n  } while (0)\n\n#endif\t\t\t\t/* GNU CC */\n\n#define __FD_SET(d, set) \\\n  ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))\n#define __FD_CLR(d, set) \\\n  ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))\n#define __FD_ISSET(d, set) \\\n  ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/setjmp.h",
    "content": "/* Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Define the machine-dependent type `jmp_buf'.  x86-64 version.  */\n#ifndef _BITS_SETJMP_H\n#define _BITS_SETJMP_H  1\n\n#if !defined _SETJMP_H && !defined _PTHREAD_H\n# error \"Never include <bits/setjmp.h> directly; use <setjmp.h> instead.\"\n#endif\n\n#include <bits/wordsize.h>\n\n#ifndef _ASM\n\n# if __WORDSIZE == 64\ntypedef long int __jmp_buf[8];\n# elif defined  __x86_64__\n__extension__ typedef long long int __jmp_buf[8];\n# else\ntypedef int __jmp_buf[6];\n# endif\n\n#endif\n\n#endif\t\t\t\t/* bits/setjmp.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sigaction.h",
    "content": "/* The proper definitions for Linux's sigaction.\n   Copyright (C) 1993-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SIGNAL_H\n# error \"Never include <bits/sigaction.h> directly; use <signal.h> instead.\"\n#endif\n\n/* Structure describing the action to be taken when a signal arrives.  */\nstruct sigaction {\n\t/* Signal handler.  */\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\n\tunion {\n\t\t/* Used if SA_SIGINFO is not set.  */\n\t\t__sighandler_t sa_handler;\n\t\t/* Used if SA_SIGINFO is set.  */\n\t\tvoid (*sa_sigaction) (int, siginfo_t *, void *);\n\t} __sigaction_handler;\n# define sa_handler\t__sigaction_handler.sa_handler\n# define sa_sigaction\t__sigaction_handler.sa_sigaction\n#else\n\t__sighandler_t sa_handler;\n#endif\n\n\t/* Additional set of signals to be blocked.  */\n\t__sigset_t sa_mask;\n\n\t/* Special flags.  */\n\tint sa_flags;\n\n\t/* Restore handler.  */\n\tvoid (*sa_restorer) (void);\n};\n\n/* Bits in `sa_flags'.  */\n#define\tSA_NOCLDSTOP  1\t\t/* Don't send SIGCHLD when children stop.  */\n#define SA_NOCLDWAIT  2\t\t/* Don't create zombie on child death.  */\n#define SA_SIGINFO    4\t\t/* Invoke signal-catching function with\n\t\t\t\t   three arguments instead of one.  */\n#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC\n# define SA_ONSTACK   0x08000000\t/* Use signal stack by using `sa_restorer'. */\n#endif\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# define SA_RESTART   0x10000000\t/* Restart syscall on signal return.  */\n# define SA_NODEFER   0x40000000\t/* Don't automatically block the signal when\n\t\t\t\t\t   its handler is being executed.  */\n# define SA_RESETHAND 0x80000000\t/* Reset to SIG_DFL on entry to handler.  */\n#endif\n#ifdef __USE_MISC\n# define SA_INTERRUPT 0x20000000\t/* Historical no-op.  */\n\n/* Some aliases for the SA_ constants.  */\n# define SA_NOMASK    SA_NODEFER\n# define SA_ONESHOT   SA_RESETHAND\n# define SA_STACK     SA_ONSTACK\n#endif\n\n/* Values for the HOW argument to `sigprocmask'.  */\n#define\tSIG_BLOCK     0\t\t/* Block signals.  */\n#define\tSIG_UNBLOCK   1\t\t/* Unblock signals.  */\n#define\tSIG_SETMASK   2\t\t/* Set the set of blocked signals.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sigcontext.h",
    "content": "/* Copyright (C) 2002-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\t See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGCONTEXT_H\n#define _BITS_SIGCONTEXT_H  1\n\n#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H\n# error \"Never use <bits/sigcontext.h> directly; include <signal.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\n#define FP_XSTATE_MAGIC1\t0x46505853U\n#define FP_XSTATE_MAGIC2\t0x46505845U\n#define FP_XSTATE_MAGIC2_SIZE\tsizeof(FP_XSTATE_MAGIC2)\n\nstruct _fpx_sw_bytes {\n\t__uint32_t magic1;\n\t__uint32_t extended_size;\n\t__uint64_t xstate_bv;\n\t__uint32_t xstate_size;\n\t__uint32_t __glibc_reserved1[7];\n};\n\nstruct _fpreg {\n\tunsigned short significand[4];\n\tunsigned short exponent;\n};\n\nstruct _fpxreg {\n\tunsigned short significand[4];\n\tunsigned short exponent;\n\tunsigned short __glibc_reserved1[3];\n};\n\nstruct _xmmreg {\n\t__uint32_t element[4];\n};\n\n#ifndef __x86_64__\n\nstruct _fpstate {\n\t/* Regular FPU environment.  */\n\t__uint32_t cw;\n\t__uint32_t sw;\n\t__uint32_t tag;\n\t__uint32_t ipoff;\n\t__uint32_t cssel;\n\t__uint32_t dataoff;\n\t__uint32_t datasel;\n\tstruct _fpreg _st[8];\n\tunsigned short status;\n\tunsigned short magic;\n\n\t/* FXSR FPU environment.  */\n\t__uint32_t _fxsr_env[6];\n\t__uint32_t mxcsr;\n\t__uint32_t __glibc_reserved1;\n\tstruct _fpxreg _fxsr_st[8];\n\tstruct _xmmreg _xmm[8];\n\t__uint32_t __glibc_reserved2[56];\n};\n\n#ifndef sigcontext_struct\n/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but\n   we need sigcontext.  Some packages have come to rely on\n   sigcontext_struct being defined on 32-bit x86, so define this for\n   their benefit.  */\n# define sigcontext_struct sigcontext\n#endif\n\n#define X86_FXSR_MAGIC\t\t0x0000\n\nstruct sigcontext {\n\tunsigned short gs, __gsh;\n\tunsigned short fs, __fsh;\n\tunsigned short es, __esh;\n\tunsigned short ds, __dsh;\n\tunsigned long edi;\n\tunsigned long esi;\n\tunsigned long ebp;\n\tunsigned long esp;\n\tunsigned long ebx;\n\tunsigned long edx;\n\tunsigned long ecx;\n\tunsigned long eax;\n\tunsigned long trapno;\n\tunsigned long err;\n\tunsigned long eip;\n\tunsigned short cs, __csh;\n\tunsigned long eflags;\n\tunsigned long esp_at_signal;\n\tunsigned short ss, __ssh;\n\tstruct _fpstate *fpstate;\n\tunsigned long oldmask;\n\tunsigned long cr2;\n};\n\n#else\t\t\t\t/* __x86_64__ */\n\nstruct _fpstate {\n\t/* FPU environment matching the 64-bit FXSAVE layout.  */\n\t__uint16_t cwd;\n\t__uint16_t swd;\n\t__uint16_t ftw;\n\t__uint16_t fop;\n\t__uint64_t rip;\n\t__uint64_t rdp;\n\t__uint32_t mxcsr;\n\t__uint32_t mxcr_mask;\n\tstruct _fpxreg _st[8];\n\tstruct _xmmreg _xmm[16];\n\t__uint32_t __glibc_reserved1[24];\n};\n\nstruct sigcontext {\n\t__uint64_t r8;\n\t__uint64_t r9;\n\t__uint64_t r10;\n\t__uint64_t r11;\n\t__uint64_t r12;\n\t__uint64_t r13;\n\t__uint64_t r14;\n\t__uint64_t r15;\n\t__uint64_t rdi;\n\t__uint64_t rsi;\n\t__uint64_t rbp;\n\t__uint64_t rbx;\n\t__uint64_t rdx;\n\t__uint64_t rax;\n\t__uint64_t rcx;\n\t__uint64_t rsp;\n\t__uint64_t rip;\n\t__uint64_t eflags;\n\tunsigned short cs;\n\tunsigned short gs;\n\tunsigned short fs;\n\tunsigned short __pad0;\n\t__uint64_t err;\n\t__uint64_t trapno;\n\t__uint64_t oldmask;\n\t__uint64_t cr2;\n\t__extension__ union {\n\t\tstruct _fpstate *fpstate;\n\t\t__uint64_t __fpstate_word;\n\t};\n\t__uint64_t __reserved1[8];\n};\n\n#endif\t\t\t\t/* __x86_64__ */\n\nstruct _xsave_hdr {\n\t__uint64_t xstate_bv;\n\t__uint64_t __glibc_reserved1[2];\n\t__uint64_t __glibc_reserved2[5];\n};\n\nstruct _ymmh_state {\n\t__uint32_t ymmh_space[64];\n};\n\nstruct _xstate {\n\tstruct _fpstate fpstate;\n\tstruct _xsave_hdr xstate_hdr;\n\tstruct _ymmh_state ymmh;\n};\n\n#endif\t\t\t\t/* _BITS_SIGCONTEXT_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sigevent-consts.h",
    "content": "/* sigevent constants.  Linux version.\n   Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGEVENT_CONSTS_H\n#define _BITS_SIGEVENT_CONSTS_H 1\n\n#if !defined _SIGNAL_H && !defined _AIO_H\n#error \"Don't include <bits/sigevent-consts.h> directly; use <signal.h> instead.\"\n#endif\n\n/* `sigev_notify' values.  */\nenum {\n\tSIGEV_SIGNAL = 0,\t/* Notify via signal.  */\n# define SIGEV_SIGNAL\tSIGEV_SIGNAL\n\tSIGEV_NONE,\t\t/* Other notification: meaningless.  */\n# define SIGEV_NONE\tSIGEV_NONE\n\tSIGEV_THREAD,\t\t/* Deliver via thread creation.  */\n# define SIGEV_THREAD\tSIGEV_THREAD\n\n\tSIGEV_THREAD_ID = 4\t/* Send signal to specific thread.\n\t\t\t\t   This is a Linux extension.  */\n#define SIGEV_THREAD_ID\tSIGEV_THREAD_ID\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/siginfo-arch.h",
    "content": "/* Architecture-specific adjustments to siginfo_t.  x86 version.  */\n#ifndef _BITS_SIGINFO_ARCH_H\n#define _BITS_SIGINFO_ARCH_H 1\n\n#if defined __x86_64__ && __WORDSIZE == 32\n/* si_utime and si_stime must be 4 byte aligned for x32 to match the\n   kernel.  We align siginfo_t to 8 bytes so that si_utime and\n   si_stime are actually aligned to 8 bytes since their offsets are\n   multiple of 8 bytes.  Note: with some compilers, the alignment\n   attribute would be ignored if it were put in __SI_CLOCK_T instead\n   of encapsulated in a typedef.  */\ntypedef __clock_t __attribute__ ((__aligned__(4))) __sigchld_clock_t;\n# define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))\n# define __SI_CLOCK_T __sigchld_clock_t\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/siginfo-consts.h",
    "content": "/* siginfo constants.  Linux version.\n   Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGINFO_CONSTS_H\n#define _BITS_SIGINFO_CONSTS_H 1\n\n#ifndef _SIGNAL_H\n#error \"Don't include <bits/siginfo-consts.h> directly; use <signal.h> instead.\"\n#endif\n\n/* Most of these constants are uniform across all architectures, but there\n   is one exception.  */\n#include <bits/siginfo-arch.h>\n#ifndef __SI_ASYNCIO_AFTER_SIGIO\n# define __SI_ASYNCIO_AFTER_SIGIO 1\n#endif\n\n/* Values for `si_code'.  Positive values are reserved for kernel-generated\n   signals.  */\nenum {\n\tSI_ASYNCNL = -60,\t/* Sent by asynch name lookup completion.  */\n\tSI_TKILL = -6,\t\t/* Sent by tkill.  */\n\tSI_SIGIO,\t\t/* Sent by queued SIGIO. */\n#if __SI_ASYNCIO_AFTER_SIGIO\n\tSI_ASYNCIO,\t\t/* Sent by AIO completion.  */\n\tSI_MESGQ,\t\t/* Sent by real time mesq state change.  */\n\tSI_TIMER,\t\t/* Sent by timer expiration.  */\n#else\n\tSI_MESGQ,\n\tSI_TIMER,\n\tSI_ASYNCIO,\n#endif\n\tSI_QUEUE,\t\t/* Sent by sigqueue.  */\n\tSI_USER,\t\t/* Sent by kill, sigsend.  */\n\tSI_KERNEL = 0x80\t/* Send by kernel.  */\n#define SI_ASYNCNL\tSI_ASYNCNL\n#define SI_TKILL\tSI_TKILL\n#define SI_SIGIO\tSI_SIGIO\n#define SI_ASYNCIO\tSI_ASYNCIO\n#define SI_MESGQ\tSI_MESGQ\n#define SI_TIMER\tSI_TIMER\n#define SI_ASYNCIO\tSI_ASYNCIO\n#define SI_QUEUE\tSI_QUEUE\n#define SI_USER\t\tSI_USER\n#define SI_KERNEL\tSI_KERNEL\n};\n\n# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGILL signal.  */\nenum {\n\tILL_ILLOPC = 1,\t\t/* Illegal opcode.  */\n#  define ILL_ILLOPC\tILL_ILLOPC\n\tILL_ILLOPN,\t\t/* Illegal operand.  */\n#  define ILL_ILLOPN\tILL_ILLOPN\n\tILL_ILLADR,\t\t/* Illegal addressing mode.  */\n#  define ILL_ILLADR\tILL_ILLADR\n\tILL_ILLTRP,\t\t/* Illegal trap. */\n#  define ILL_ILLTRP\tILL_ILLTRP\n\tILL_PRVOPC,\t\t/* Privileged opcode.  */\n#  define ILL_PRVOPC\tILL_PRVOPC\n\tILL_PRVREG,\t\t/* Privileged register.  */\n#  define ILL_PRVREG\tILL_PRVREG\n\tILL_COPROC,\t\t/* Coprocessor error.  */\n#  define ILL_COPROC\tILL_COPROC\n\tILL_BADSTK\t\t/* Internal stack error.  */\n#  define ILL_BADSTK\tILL_BADSTK\n};\n\n/* `si_code' values for SIGFPE signal.  */\nenum {\n\tFPE_INTDIV = 1,\t\t/* Integer divide by zero.  */\n#  define FPE_INTDIV\tFPE_INTDIV\n\tFPE_INTOVF,\t\t/* Integer overflow.  */\n#  define FPE_INTOVF\tFPE_INTOVF\n\tFPE_FLTDIV,\t\t/* Floating point divide by zero.  */\n#  define FPE_FLTDIV\tFPE_FLTDIV\n\tFPE_FLTOVF,\t\t/* Floating point overflow.  */\n#  define FPE_FLTOVF\tFPE_FLTOVF\n\tFPE_FLTUND,\t\t/* Floating point underflow.  */\n#  define FPE_FLTUND\tFPE_FLTUND\n\tFPE_FLTRES,\t\t/* Floating point inexact result.  */\n#  define FPE_FLTRES\tFPE_FLTRES\n\tFPE_FLTINV,\t\t/* Floating point invalid operation.  */\n#  define FPE_FLTINV\tFPE_FLTINV\n\tFPE_FLTSUB\t\t/* Subscript out of range.  */\n#  define FPE_FLTSUB\tFPE_FLTSUB\n};\n\n/* `si_code' values for SIGSEGV signal.  */\nenum {\n\tSEGV_MAPERR = 1,\t/* Address not mapped to object.  */\n#  define SEGV_MAPERR\tSEGV_MAPERR\n\tSEGV_ACCERR,\t\t/* Invalid permissions for mapped object.  */\n#  define SEGV_ACCERR\tSEGV_ACCERR\n\tSEGV_BNDERR,\t\t/* Bounds checking failure.  */\n#  define SEGV_BNDERR\tSEGV_BNDERR\n\tSEGV_PKUERR\t\t/* Protection key checking failure.  */\n#  define SEGV_PKUERR\tSEGV_PKUERR\n};\n\n/* `si_code' values for SIGBUS signal.  */\nenum {\n\tBUS_ADRALN = 1,\t\t/* Invalid address alignment.  */\n#  define BUS_ADRALN\tBUS_ADRALN\n\tBUS_ADRERR,\t\t/* Non-existant physical address.  */\n#  define BUS_ADRERR\tBUS_ADRERR\n\tBUS_OBJERR,\t\t/* Object specific hardware error.  */\n#  define BUS_OBJERR\tBUS_OBJERR\n\tBUS_MCEERR_AR,\t\t/* Hardware memory error: action required.  */\n#  define BUS_MCEERR_AR\tBUS_MCEERR_AR\n\tBUS_MCEERR_AO\t\t/* Hardware memory error: action optional.  */\n#  define BUS_MCEERR_AO\tBUS_MCEERR_AO\n};\n# endif\n\n# ifdef __USE_XOPEN_EXTENDED\n/* `si_code' values for SIGTRAP signal.  */\nenum {\n\tTRAP_BRKPT = 1,\t\t/* Process breakpoint.  */\n#  define TRAP_BRKPT\tTRAP_BRKPT\n\tTRAP_TRACE\t\t/* Process trace trap.  */\n#  define TRAP_TRACE\tTRAP_TRACE\n};\n# endif\n\n# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGCHLD signal.  */\nenum {\n\tCLD_EXITED = 1,\t\t/* Child has exited.  */\n#  define CLD_EXITED\tCLD_EXITED\n\tCLD_KILLED,\t\t/* Child was killed.  */\n#  define CLD_KILLED\tCLD_KILLED\n\tCLD_DUMPED,\t\t/* Child terminated abnormally.  */\n#  define CLD_DUMPED\tCLD_DUMPED\n\tCLD_TRAPPED,\t\t/* Traced child has trapped.  */\n#  define CLD_TRAPPED\tCLD_TRAPPED\n\tCLD_STOPPED,\t\t/* Child has stopped.  */\n#  define CLD_STOPPED\tCLD_STOPPED\n\tCLD_CONTINUED\t\t/* Stopped child has continued.  */\n#  define CLD_CONTINUED\tCLD_CONTINUED\n};\n\n/* `si_code' values for SIGPOLL signal.  */\nenum {\n\tPOLL_IN = 1,\t\t/* Data input available.  */\n#  define POLL_IN\tPOLL_IN\n\tPOLL_OUT,\t\t/* Output buffers available.  */\n#  define POLL_OUT\tPOLL_OUT\n\tPOLL_MSG,\t\t/* Input message available.   */\n#  define POLL_MSG\tPOLL_MSG\n\tPOLL_ERR,\t\t/* I/O error.  */\n#  define POLL_ERR\tPOLL_ERR\n\tPOLL_PRI,\t\t/* High priority input available.  */\n#  define POLL_PRI\tPOLL_PRI\n\tPOLL_HUP\t\t/* Device disconnected.  */\n#  define POLL_HUP\tPOLL_HUP\n};\n# endif\n\n/* Architectures might also add architecture-specific constants.\n   These are all considered GNU extensions.  */\n#ifdef __USE_GNU\n# include <bits/siginfo-consts-arch.h>\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/signum-generic.h",
    "content": "/* Signal number constants.  Generic template.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_BITS_SIGNUM_GENERIC_H\n#define _BITS_SIGNUM_GENERIC_H 1\n\n#ifndef _SIGNAL_H\n#error \"Never include <bits/signum-generic.h> directly; use <signal.h> instead.\"\n#endif\n\n/* Fake signal functions.  */\n\n#define\tSIG_ERR\t ((__sighandler_t) -1)\t/* Error return.  */\n#define\tSIG_DFL\t ((__sighandler_t)  0)\t/* Default action.  */\n#define\tSIG_IGN\t ((__sighandler_t)  1)\t/* Ignore signal.  */\n\n#ifdef __USE_XOPEN\n# define SIG_HOLD ((__sighandler_t) 2)\t/* Add signal to hold mask.  */\n#endif\n\n/* We define here all the signal names listed in POSIX (1003.1-2008);\n   as of 1003.1-2013, no additional signals have been added by POSIX.\n   We also define here signal names that historically exist in every\n   real-world POSIX variant (e.g. SIGWINCH).\n\n   Signals in the 1-15 range are defined with their historical numbers.\n   For other signals, we use the BSD numbers.\n   There are two unallocated signal numbers in the 1-31 range: 7 and 29.\n   Signal number 0 is reserved for use as kill(pid, 0), to test whether\n   a process exists without sending it a signal.  */\n\n/* ISO C99 signals.  */\n#define\tSIGINT\t\t2\t/* Interactive attention signal.  */\n#define\tSIGILL\t\t4\t/* Illegal instruction.  */\n#define\tSIGABRT\t\t6\t/* Abnormal termination.  */\n#define\tSIGFPE\t\t8\t/* Erroneous arithmetic operation.  */\n#define\tSIGSEGV\t\t11\t/* Invalid access to storage.  */\n#define\tSIGTERM\t\t15\t/* Termination request.  */\n\n/* Historical signals specified by POSIX. */\n#define\tSIGHUP\t\t1\t/* Hangup.  */\n#define\tSIGQUIT\t\t3\t/* Quit.  */\n#define\tSIGTRAP\t\t5\t/* Trace/breakpoint trap.  */\n#define\tSIGKILL\t\t9\t/* Killed.  */\n#define SIGBUS\t\t10\t/* Bus error.  */\n#define\tSIGSYS\t\t12\t/* Bad system call.  */\n#define\tSIGPIPE\t\t13\t/* Broken pipe.  */\n#define\tSIGALRM\t\t14\t/* Alarm clock.  */\n\n/* New(er) POSIX signals (1003.1-2008, 1003.1-2013).  */\n#define\tSIGURG\t\t16\t/* Urgent data is available at a socket.  */\n#define\tSIGSTOP\t\t17\t/* Stop, unblockable.  */\n#define\tSIGTSTP\t\t18\t/* Keyboard stop.  */\n#define\tSIGCONT\t\t19\t/* Continue.  */\n#define\tSIGCHLD\t\t20\t/* Child terminated or stopped.  */\n#define\tSIGTTIN\t\t21\t/* Background read from control terminal.  */\n#define\tSIGTTOU\t\t22\t/* Background write to control terminal.  */\n#define\tSIGPOLL\t\t23\t/* Pollable event occurred (System V).  */\n#define\tSIGXCPU\t\t24\t/* CPU time limit exceeded.  */\n#define\tSIGXFSZ\t\t25\t/* File size limit exceeded.  */\n#define\tSIGVTALRM\t26\t/* Virtual timer expired.  */\n#define\tSIGPROF\t\t27\t/* Profiling timer expired.  */\n#define\tSIGUSR1\t\t30\t/* User-defined signal 1.  */\n#define\tSIGUSR2\t\t31\t/* User-defined signal 2.  */\n\n/* Nonstandard signals found in all modern POSIX systems\n   (including both BSD and Linux).  */\n#define\tSIGWINCH\t28\t/* Window size change (4.3 BSD, Sun).  */\n\n/* Archaic names for compatibility.  */\n#define\tSIGIO\t\tSIGPOLL\t/* I/O now possible (4.2 BSD).  */\n#define\tSIGIOT\t\tSIGABRT\t/* IOT instruction, abort() on a PDP-11.  */\n#define\tSIGCLD\t\tSIGCHLD\t/* Old System V name */\n\n/* Not all systems support real-time signals.  bits/signum.h indicates\n   that they are supported by overriding __SIGRTMAX to a value greater\n   than __SIGRTMIN.  These constants give the kernel-level hard limits,\n   but some real-time signals may be used internally by glibc.  Do not\n   use these constants in application code; use SIGRTMIN and SIGRTMAX\n   (defined in signal.h) instead.  */\n#define __SIGRTMIN\t32\n#define __SIGRTMAX\t__SIGRTMIN\n\n/* Biggest signal number + 1 (including real-time signals).  */\n#define _NSIG\t\t(__SIGRTMAX + 1)\n\n#endif\t\t\t\t/* bits/signum-generic.h.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/signum.h",
    "content": "/* Signal number definitions.  Linux version.\n   Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGNUM_H\n#define _BITS_SIGNUM_H 1\n\n#ifndef _SIGNAL_H\n#error \"Never include <bits/signum.h> directly; use <signal.h> instead.\"\n#endif\n\n#include <bits/signum-generic.h>\n\n/* Adjustments and additions to the signal number constants for\n   most Linux systems.  */\n\n#define\tSIGSTKFLT\t16\t/* Stack fault (obsolete).  */\n#define\tSIGPWR\t\t30\t/* Power failure imminent.  */\n\n#undef\tSIGBUS\n#define\tSIGBUS\t\t 7\n#undef\tSIGUSR1\n#define\tSIGUSR1\t\t10\n#undef\tSIGUSR2\n#define\tSIGUSR2\t\t12\n#undef\tSIGCHLD\n#define\tSIGCHLD\t\t17\n#undef\tSIGCONT\n#define\tSIGCONT\t\t18\n#undef\tSIGSTOP\n#define\tSIGSTOP\t\t19\n#undef\tSIGTSTP\n#define\tSIGTSTP\t\t20\n#undef\tSIGURG\n#define\tSIGURG\t\t23\n#undef\tSIGPOLL\n#define\tSIGPOLL\t\t29\n#undef\tSIGSYS\n#define SIGSYS\t\t31\n\n#undef\t__SIGRTMAX\n#define __SIGRTMAX\t64\n\n#endif\t\t\t\t/* <signal.h> included.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sigstack.h",
    "content": "/* sigstack, sigaltstack definitions.\n   Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGSTACK_H\n#define _BITS_SIGSTACK_H 1\n\n#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H\n# error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n/* Minimum stack size for a signal handler.  */\n#define MINSIGSTKSZ\t2048\n\n/* System default stack size.  */\n#define SIGSTKSZ\t8192\n\n#endif\t\t\t\t/* bits/sigstack.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sigthread.h",
    "content": "/* Signal handling function for threaded programs.\n   Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGTHREAD_H\n#define _BITS_SIGTHREAD_H\t1\n\n#if !defined _SIGNAL_H && !defined _PTHREAD_H\n# error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n/* Functions for handling signals. */\n#include <bits/types/__sigset_t.h>\n\n/* Modify the signal mask for the calling thread.  The arguments have\n   the same meaning as for sigprocmask(2). */\nextern int pthread_sigmask(int __how, const __sigset_t * __restrict __newmask, __sigset_t * __restrict __oldmask) __THROW;\n\n/* Send signal SIGNO to the given thread. */\nextern int pthread_kill(pthread_t __threadid, int __signo) __THROW;\n\n#ifdef __USE_GNU\n/* Queue signal and data to a thread.  */\nextern int pthread_sigqueue(pthread_t __threadid, int __signo, const union sigval __value) __THROW;\n#endif\n\n#endif\t\t\t\t/* bits/sigthread.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sockaddr.h",
    "content": "/* Definition of struct sockaddr_* common members and sizes, generic version.\n   Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/socket.h> instead.\n */\n\n#ifndef _BITS_SOCKADDR_H\n#define _BITS_SOCKADDR_H\t1\n\n/* POSIX.1g specifies this type name for the `sa_family' member.  */\ntypedef unsigned short int sa_family_t;\n\n/* This macro is used to declare the initial common members\n   of the data types used for socket addresses, `struct sockaddr',\n   `struct sockaddr_in', `struct sockaddr_un', etc.  */\n\n#define\t__SOCKADDR_COMMON(sa_prefix) \\\n  sa_family_t sa_prefix##family\n\n#define __SOCKADDR_COMMON_SIZE\t(sizeof (unsigned short int))\n\n/* Size of struct sockaddr_storage.  */\n#define _SS_SIZE 128\n\n#endif\t\t\t\t/* bits/sockaddr.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/socket.h",
    "content": "/* System-specific socket constants and types.  Linux version.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __BITS_SOCKET_H\n#define __BITS_SOCKET_H\n\n#ifndef _SYS_SOCKET_H\n# error \"Never include <bits/socket.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n#define __need_size_t\n#include <stddef.h>\n\n#include <sys/types.h>\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n# define __socklen_t_defined\n#endif\n\n/* Get the architecture-dependent definition of enum __socket_type.  */\n#include <bits/socket_type.h>\n\n/* Protocol families.  */\n#define PF_UNSPEC\t0\t/* Unspecified.  */\n#define PF_LOCAL\t1\t/* Local to host (pipes and file-domain).  */\n#define PF_UNIX\t\tPF_LOCAL\t/* POSIX name for PF_LOCAL.  */\n#define PF_FILE\t\tPF_LOCAL\t/* Another non-standard name for PF_LOCAL.  */\n#define PF_INET\t\t2\t/* IP protocol family.  */\n#define PF_AX25\t\t3\t/* Amateur Radio AX.25.  */\n#define PF_IPX\t\t4\t/* Novell Internet Protocol.  */\n#define PF_APPLETALK\t5\t/* Appletalk DDP.  */\n#define PF_NETROM\t6\t/* Amateur radio NetROM.  */\n#define PF_BRIDGE\t7\t/* Multiprotocol bridge.  */\n#define PF_ATMPVC\t8\t/* ATM PVCs.  */\n#define PF_X25\t\t9\t/* Reserved for X.25 project.  */\n#define PF_INET6\t10\t/* IP version 6.  */\n#define PF_ROSE\t\t11\t/* Amateur Radio X.25 PLP.  */\n#define PF_DECnet\t12\t/* Reserved for DECnet project.  */\n#define PF_NETBEUI\t13\t/* Reserved for 802.2LLC project.  */\n#define PF_SECURITY\t14\t/* Security callback pseudo AF.  */\n#define PF_KEY\t\t15\t/* PF_KEY key management API.  */\n#define PF_NETLINK\t16\n#define PF_ROUTE\tPF_NETLINK\t/* Alias to emulate 4.4BSD.  */\n#define PF_PACKET\t17\t/* Packet family.  */\n#define PF_ASH\t\t18\t/* Ash.  */\n#define PF_ECONET\t19\t/* Acorn Econet.  */\n#define PF_ATMSVC\t20\t/* ATM SVCs.  */\n#define PF_RDS\t\t21\t/* RDS sockets.  */\n#define PF_SNA\t\t22\t/* Linux SNA Project */\n#define PF_IRDA\t\t23\t/* IRDA sockets.  */\n#define PF_PPPOX\t24\t/* PPPoX sockets.  */\n#define PF_WANPIPE\t25\t/* Wanpipe API sockets.  */\n#define PF_LLC\t\t26\t/* Linux LLC.  */\n#define PF_IB\t\t27\t/* Native InfiniBand address.  */\n#define PF_MPLS\t\t28\t/* MPLS.  */\n#define PF_CAN\t\t29\t/* Controller Area Network.  */\n#define PF_TIPC\t\t30\t/* TIPC sockets.  */\n#define PF_BLUETOOTH\t31\t/* Bluetooth sockets.  */\n#define PF_IUCV\t\t32\t/* IUCV sockets.  */\n#define PF_RXRPC\t33\t/* RxRPC sockets.  */\n#define PF_ISDN\t\t34\t/* mISDN sockets.  */\n#define PF_PHONET\t35\t/* Phonet sockets.  */\n#define PF_IEEE802154\t36\t/* IEEE 802.15.4 sockets.  */\n#define PF_CAIF\t\t37\t/* CAIF sockets.  */\n#define PF_ALG\t\t38\t/* Algorithm sockets.  */\n#define PF_NFC\t\t39\t/* NFC sockets.  */\n#define PF_VSOCK\t40\t/* vSockets.  */\n#define PF_KCM\t\t41\t/* Kernel Connection Multiplexor.  */\n#define PF_QIPCRTR\t42\t/* Qualcomm IPC Router.  */\n#define PF_SMC\t\t43\t/* SMC sockets.  */\n#define PF_MAX\t\t44\t/* For now..  */\n\n/* Address families.  */\n#define AF_UNSPEC\tPF_UNSPEC\n#define AF_LOCAL\tPF_LOCAL\n#define AF_UNIX\t\tPF_UNIX\n#define AF_FILE\t\tPF_FILE\n#define AF_INET\t\tPF_INET\n#define AF_AX25\t\tPF_AX25\n#define AF_IPX\t\tPF_IPX\n#define AF_APPLETALK\tPF_APPLETALK\n#define AF_NETROM\tPF_NETROM\n#define AF_BRIDGE\tPF_BRIDGE\n#define AF_ATMPVC\tPF_ATMPVC\n#define AF_X25\t\tPF_X25\n#define AF_INET6\tPF_INET6\n#define AF_ROSE\t\tPF_ROSE\n#define AF_DECnet\tPF_DECnet\n#define AF_NETBEUI\tPF_NETBEUI\n#define AF_SECURITY\tPF_SECURITY\n#define AF_KEY\t\tPF_KEY\n#define AF_NETLINK\tPF_NETLINK\n#define AF_ROUTE\tPF_ROUTE\n#define AF_PACKET\tPF_PACKET\n#define AF_ASH\t\tPF_ASH\n#define AF_ECONET\tPF_ECONET\n#define AF_ATMSVC\tPF_ATMSVC\n#define AF_RDS\t\tPF_RDS\n#define AF_SNA\t\tPF_SNA\n#define AF_IRDA\t\tPF_IRDA\n#define AF_PPPOX\tPF_PPPOX\n#define AF_WANPIPE\tPF_WANPIPE\n#define AF_LLC\t\tPF_LLC\n#define AF_IB\t\tPF_IB\n#define AF_MPLS\t\tPF_MPLS\n#define AF_CAN\t\tPF_CAN\n#define AF_TIPC\t\tPF_TIPC\n#define AF_BLUETOOTH\tPF_BLUETOOTH\n#define AF_IUCV\t\tPF_IUCV\n#define AF_RXRPC\tPF_RXRPC\n#define AF_ISDN\t\tPF_ISDN\n#define AF_PHONET\tPF_PHONET\n#define AF_IEEE802154\tPF_IEEE802154\n#define AF_CAIF\t\tPF_CAIF\n#define AF_ALG\t\tPF_ALG\n#define AF_NFC\t\tPF_NFC\n#define AF_VSOCK\tPF_VSOCK\n#define AF_KCM\t\tPF_KCM\n#define AF_QIPCRTR\tPF_QIPCRTR\n#define AF_SMC\t\tPF_SMC\n#define AF_MAX\t\tPF_MAX\n\n/* Socket level values.  Others are defined in the appropriate headers.\n\n   XXX These definitions also should go into the appropriate headers as\n   far as they are available.  */\n#define SOL_RAW\t\t255\n#define SOL_DECNET      261\n#define SOL_X25         262\n#define SOL_PACKET\t263\n#define SOL_ATM\t\t264\t/* ATM layer (cell level).  */\n#define SOL_AAL\t\t265\t/* ATM Adaption Layer (packet level).  */\n#define SOL_IRDA\t266\n#define SOL_NETBEUI\t267\n#define SOL_LLC\t\t268\n#define SOL_DCCP\t269\n#define SOL_NETLINK\t270\n#define SOL_TIPC\t271\n#define SOL_RXRPC\t272\n#define SOL_PPPOL2TP\t273\n#define SOL_BLUETOOTH\t274\n#define SOL_PNPIPE\t275\n#define SOL_RDS\t\t276\n#define SOL_IUCV\t277\n#define SOL_CAIF\t278\n#define SOL_ALG\t\t279\n#define SOL_NFC\t\t280\n#define SOL_KCM\t\t281\n#define SOL_TLS\t\t282\n\n/* Maximum queue length specifiable by listen.  */\n#define SOMAXCONN\t128\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n/* Structure describing a generic socket address.  */\nstruct sockaddr {\n\t__SOCKADDR_COMMON(sa_);\t/* Common data: address family and length.  */\n\tchar sa_data[14];\t/* Address data.  */\n};\n\n/* Structure large enough to hold any socket address (with the historical\n   exception of AF_UNIX).  */\n#define __ss_aligntype\tunsigned long int\n#define _SS_PADSIZE \\\n  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))\n\nstruct sockaddr_storage {\n\t__SOCKADDR_COMMON(ss_);\t/* Address family, etc.  */\n\tchar __ss_padding[_SS_PADSIZE];\n\t__ss_aligntype __ss_align;\t/* Force desired alignment.  */\n};\n\n/* Bits in the FLAGS argument to `send', `recv', et al.  */\nenum {\n\tMSG_OOB = 0x01,\t\t/* Process out-of-band data.  */\n#define MSG_OOB\t\tMSG_OOB\n\tMSG_PEEK = 0x02,\t/* Peek at incoming messages.  */\n#define MSG_PEEK\tMSG_PEEK\n\tMSG_DONTROUTE = 0x04,\t/* Don't use local routing.  */\n#define MSG_DONTROUTE\tMSG_DONTROUTE\n#ifdef __USE_GNU\n\t/* DECnet uses a different name.  */\n\tMSG_TRYHARD = MSG_DONTROUTE,\n# define MSG_TRYHARD\tMSG_DONTROUTE\n#endif\n\tMSG_CTRUNC = 0x08,\t/* Control data lost before delivery.  */\n#define MSG_CTRUNC\tMSG_CTRUNC\n\tMSG_PROXY = 0x10,\t/* Supply or ask second address.  */\n#define MSG_PROXY\tMSG_PROXY\n\tMSG_TRUNC = 0x20,\n#define MSG_TRUNC\tMSG_TRUNC\n\tMSG_DONTWAIT = 0x40,\t/* Nonblocking IO.  */\n#define MSG_DONTWAIT\tMSG_DONTWAIT\n\tMSG_EOR = 0x80,\t\t/* End of record.  */\n#define MSG_EOR\t\tMSG_EOR\n\tMSG_WAITALL = 0x100,\t/* Wait for a full request.  */\n#define MSG_WAITALL\tMSG_WAITALL\n\tMSG_FIN = 0x200,\n#define MSG_FIN\t\tMSG_FIN\n\tMSG_SYN = 0x400,\n#define MSG_SYN\t\tMSG_SYN\n\tMSG_CONFIRM = 0x800,\t/* Confirm path validity.  */\n#define MSG_CONFIRM\tMSG_CONFIRM\n\tMSG_RST = 0x1000,\n#define MSG_RST\t\tMSG_RST\n\tMSG_ERRQUEUE = 0x2000,\t/* Fetch message from error queue.  */\n#define MSG_ERRQUEUE\tMSG_ERRQUEUE\n\tMSG_NOSIGNAL = 0x4000,\t/* Do not generate SIGPIPE.  */\n#define MSG_NOSIGNAL\tMSG_NOSIGNAL\n\tMSG_MORE = 0x8000,\t/* Sender will send more.  */\n#define MSG_MORE\tMSG_MORE\n\tMSG_WAITFORONE = 0x10000,\t/* Wait for at least one packet to return. */\n#define MSG_WAITFORONE\tMSG_WAITFORONE\n\tMSG_BATCH = 0x40000,\t/* sendmmsg: more messages coming.  */\n#define MSG_BATCH\tMSG_BATCH\n\tMSG_ZEROCOPY = 0x4000000,\t/* Use user data in kernel path.  */\n#define MSG_ZEROCOPY\tMSG_ZEROCOPY\n\tMSG_FASTOPEN = 0x20000000,\t/* Send data in TCP SYN.  */\n#define MSG_FASTOPEN\tMSG_FASTOPEN\n\n\tMSG_CMSG_CLOEXEC = 0x40000000\t/* Set close_on_exit for file\n\t\t\t\t\t   descriptor received through\n\t\t\t\t\t   SCM_RIGHTS.  */\n#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC\n};\n\n/* Structure describing messages sent by\n   `sendmsg' and received by `recvmsg'.  */\nstruct msghdr {\n\tvoid *msg_name;\t\t/* Address to send to/receive from.  */\n\tsocklen_t msg_namelen;\t/* Length of address data.  */\n\n\tstruct iovec *msg_iov;\t/* Vector of data to send/receive into.  */\n\tsize_t msg_iovlen;\t/* Number of elements in the vector.  */\n\n\tvoid *msg_control;\t/* Ancillary data (eg BSD filedesc passing). */\n\tsize_t msg_controllen;\t/* Ancillary data buffer length.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\n\tint msg_flags;\t\t/* Flags on received message.  */\n};\n\n/* Structure used for storage of ancillary data object information.  */\nstruct cmsghdr {\n\tsize_t cmsg_len;\t/* Length of data in cmsg_data plus length\n\t\t\t\t   of cmsghdr structure.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\tint cmsg_level;\t\t/* Originating protocol.  */\n\tint cmsg_type;\t\t/* Protocol specific type.  */\n#if __glibc_c99_flexarr_available\n\t__extension__ unsigned char __cmsg_data __flexarr;\t/* Ancillary data.  */\n#endif\n};\n\n/* Ancillary data object manipulation macros.  */\n#if __glibc_c99_flexarr_available\n# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)\n#else\n# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))\n#endif\n#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)\n#define CMSG_FIRSTHDR(mhdr) \\\n  ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr)\t\t      \\\n   ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)\n#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \\\n\t\t\t & (size_t) ~(sizeof (size_t) - 1))\n#define CMSG_SPACE(len) (CMSG_ALIGN (len) \\\n\t\t\t + CMSG_ALIGN (sizeof (struct cmsghdr)))\n#define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))\n\nextern struct cmsghdr *__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW;\n#ifdef __USE_EXTERN_INLINES\n# ifndef _EXTERN_INLINE\n#  define _EXTERN_INLINE __extern_inline\n# endif\n_EXTERN_INLINE struct cmsghdr *__NTH(__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg))\n{\n\tif ((size_t) __cmsg->cmsg_len < sizeof(struct cmsghdr))\n\t\t/* The kernel header does this so there may be a reason.  */\n\t\treturn (struct cmsghdr *)0;\n\n\t__cmsg = (struct cmsghdr *)((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len));\n\tif ((unsigned char *)(__cmsg + 1) > ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)\n\t    || ((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len)\n\t\t> ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)))\n\t\t/* No more entries.  */\n\t\treturn (struct cmsghdr *)0;\n\treturn __cmsg;\n}\n#endif\t\t\t\t/* Use `extern inline'.  */\n\n/* Socket level message types.  This must match the definitions in\n   <linux/socket.h>.  */\nenum {\n\tSCM_RIGHTS = 0x01\t/* Transfer file descriptors.  */\n#define SCM_RIGHTS SCM_RIGHTS\n#ifdef __USE_GNU\n\t    , SCM_CREDENTIALS = 0x02\t/* Credentials passing.  */\n# define SCM_CREDENTIALS SCM_CREDENTIALS\n#endif\n};\n\n#ifdef __USE_GNU\n/* User visible structure for SCM_CREDENTIALS message */\nstruct ucred {\n\tpid_t pid;\t\t/* PID of sending process.  */\n\tuid_t uid;\t\t/* UID of sending process.  */\n\tgid_t gid;\t\t/* GID of sending process.  */\n};\n#endif\n\n/* Ugly workaround for unclean kernel headers.  */\n#ifndef __USE_MISC\n# ifndef FIOGETOWN\n#  define __SYS_SOCKET_H_undef_FIOGETOWN\n# endif\n# ifndef FIOSETOWN\n#  define __SYS_SOCKET_H_undef_FIOSETOWN\n# endif\n# ifndef SIOCATMARK\n#  define __SYS_SOCKET_H_undef_SIOCATMARK\n# endif\n# ifndef SIOCGPGRP\n#  define __SYS_SOCKET_H_undef_SIOCGPGRP\n# endif\n# ifndef SIOCGSTAMP\n#  define __SYS_SOCKET_H_undef_SIOCGSTAMP\n# endif\n# ifndef SIOCGSTAMPNS\n#  define __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n# endif\n# ifndef SIOCSPGRP\n#  define __SYS_SOCKET_H_undef_SIOCSPGRP\n# endif\n#endif\n#ifndef IOCSIZE_MASK\n# define __SYS_SOCKET_H_undef_IOCSIZE_MASK\n#endif\n#ifndef IOCSIZE_SHIFT\n# define __SYS_SOCKET_H_undef_IOCSIZE_SHIFT\n#endif\n#ifndef IOC_IN\n# define __SYS_SOCKET_H_undef_IOC_IN\n#endif\n#ifndef IOC_INOUT\n# define __SYS_SOCKET_H_undef_IOC_INOUT\n#endif\n#ifndef IOC_OUT\n# define __SYS_SOCKET_H_undef_IOC_OUT\n#endif\n\n/* Get socket manipulation related informations from kernel headers.  */\n#include <asm/socket.h>\n\n#ifndef __USE_MISC\n# ifdef __SYS_SOCKET_H_undef_FIOGETOWN\n#  undef __SYS_SOCKET_H_undef_FIOGETOWN\n#  undef FIOGETOWN\n# endif\n# ifdef __SYS_SOCKET_H_undef_FIOSETOWN\n#  undef __SYS_SOCKET_H_undef_FIOSETOWN\n#  undef FIOSETOWN\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCATMARK\n#  undef __SYS_SOCKET_H_undef_SIOCATMARK\n#  undef SIOCATMARK\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGPGRP\n#  undef __SYS_SOCKET_H_undef_SIOCGPGRP\n#  undef SIOCGPGRP\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#  undef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#  undef SIOCGSTAMP\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#  undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#  undef SIOCGSTAMPNS\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCSPGRP\n#  undef __SYS_SOCKET_H_undef_SIOCSPGRP\n#  undef SIOCSPGRP\n# endif\n#endif\n#ifdef __SYS_SOCKET_H_undef_IOCSIZE_MASK\n# undef __SYS_SOCKET_H_undef_IOCSIZE_MASK\n# undef IOCSIZE_MASK\n#endif\n#ifdef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT\n# undef __SYS_SOCKET_H_undef_IOCSIZE_SHIFT\n# undef IOCSIZE_SHIFT\n#endif\n#ifdef __SYS_SOCKET_H_undef_IOC_IN\n# undef __SYS_SOCKET_H_undef_IOC_IN\n# undef IOC_IN\n#endif\n#ifdef __SYS_SOCKET_H_undef_IOC_INOUT\n# undef __SYS_SOCKET_H_undef_IOC_INOUT\n# undef IOC_INOUT\n#endif\n#ifdef __SYS_SOCKET_H_undef_IOC_OUT\n# undef __SYS_SOCKET_H_undef_IOC_OUT\n# undef IOC_OUT\n#endif\n\n/* Structure used to manipulate the SO_LINGER option.  */\nstruct linger {\n\tint l_onoff;\t\t/* Nonzero to linger on close.  */\n\tint l_linger;\t\t/* Time to linger.  */\n};\n\n#endif\t\t\t\t/* bits/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/socket_type.h",
    "content": "/* Define enum __socket_type for generic Linux.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SOCKET_H\n# error \"Never include <bits/socket_type.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n/* Types of sockets.  */\nenum __socket_type {\n\tSOCK_STREAM = 1,\t/* Sequenced, reliable, connection-based\n\t\t\t\t   byte streams.  */\n#define SOCK_STREAM SOCK_STREAM\n\tSOCK_DGRAM = 2,\t\t/* Connectionless, unreliable datagrams\n\t\t\t\t   of fixed maximum length.  */\n#define SOCK_DGRAM SOCK_DGRAM\n\tSOCK_RAW = 3,\t\t/* Raw protocol interface.  */\n#define SOCK_RAW SOCK_RAW\n\tSOCK_RDM = 4,\t\t/* Reliably-delivered messages.  */\n#define SOCK_RDM SOCK_RDM\n\tSOCK_SEQPACKET = 5,\t/* Sequenced, reliable, connection-based,\n\t\t\t\t   datagrams of fixed maximum length.  */\n#define SOCK_SEQPACKET SOCK_SEQPACKET\n\tSOCK_DCCP = 6,\t\t/* Datagram Congestion Control Protocol.  */\n#define SOCK_DCCP SOCK_DCCP\n\tSOCK_PACKET = 10,\t/* Linux specific way of getting packets\n\t\t\t\t   at the dev level.  For writing rarp and\n\t\t\t\t   other similar things on the user level. */\n#define SOCK_PACKET SOCK_PACKET\n\n\t/* Flags to be ORed into the type parameter of socket and socketpair and\n\t   used for the flags parameter of paccept.  */\n\n\tSOCK_CLOEXEC = 02000000,\t/* Atomically set close-on-exec flag for the\n\t\t\t\t\t   new descriptor(s).  */\n#define SOCK_CLOEXEC SOCK_CLOEXEC\n\tSOCK_NONBLOCK = 00004000\t/* Atomically mark descriptor(s) as\n\t\t\t\t\t   non-blocking.  */\n#define SOCK_NONBLOCK SOCK_NONBLOCK\n};\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/ss_flags.h",
    "content": "/* ss_flags values for stack_t.  Linux version.\n   Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SS_FLAGS_H\n#define _BITS_SS_FLAGS_H 1\n\n#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H\n# error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n/* Possible values for `ss_flags'.  */\nenum {\n\tSS_ONSTACK = 1,\n#define SS_ONSTACK\tSS_ONSTACK\n\tSS_DISABLE\n#define SS_DISABLE\tSS_DISABLE\n};\n\n#endif\t\t\t\t/* bits/ss_flags.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/stat.h",
    "content": "/* Copyright (C) 1999-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_STAT_H && !defined _FCNTL_H\n# error \"Never include <bits/stat.h> directly; use <sys/stat.h> instead.\"\n#endif\n\n#ifndef _BITS_STAT_H\n#define _BITS_STAT_H\t1\n\n/* Versions of the `struct stat' data structure.  */\n#ifndef __x86_64__\n# define _STAT_VER_LINUX_OLD\t1\n# define _STAT_VER_KERNEL\t1\n# define _STAT_VER_SVR4\t\t2\n# define _STAT_VER_LINUX\t3\n\n/* i386 versions of the `xmknod' interface.  */\n# define _MKNOD_VER_LINUX\t1\n# define _MKNOD_VER_SVR4\t2\n# define _MKNOD_VER\t\t_MKNOD_VER_LINUX\t/* The bits defined below.  */\n#else\n# define _STAT_VER_KERNEL\t0\n# define _STAT_VER_LINUX\t1\n\n/* x86-64 versions of the `xmknod' interface.  */\n# define _MKNOD_VER_LINUX\t0\n#endif\n\n#define _STAT_VER\t\t_STAT_VER_LINUX\n\nstruct stat {\n\t__dev_t st_dev;\t\t/* Device.  */\n#ifndef __x86_64__\n\tunsigned short int __pad1;\n#endif\n#if defined __x86_64__ || !defined __USE_FILE_OFFSET64\n\t__ino_t st_ino;\t\t/* File serial number.  */\n#else\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n#endif\n#ifndef __x86_64__\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n#else\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__mode_t st_mode;\t/* File mode.  */\n#endif\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n#ifdef __x86_64__\n\tint __pad0;\n#endif\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n#ifndef __x86_64__\n\tunsigned short int __pad2;\n#endif\n#if defined __x86_64__ || !defined __USE_FILE_OFFSET64\n\t__off_t st_size;\t/* Size of file, in bytes.  */\n#else\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n#endif\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n#if defined __x86_64__  || !defined __USE_FILE_OFFSET64\n\t__blkcnt_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#else\n\t__blkcnt64_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#endif\n#ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n# define st_atime st_atim.tv_sec\t/* Backward compatibility.  */\n# define st_mtime st_mtim.tv_sec\n# define st_ctime st_ctim.tv_sec\n#else\n\t__time_t st_atime;\t/* Time of last access.  */\n\t__syscall_ulong_t st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\t__syscall_ulong_t st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\t__syscall_ulong_t st_ctimensec;\t/* Nsecs of last status change.  */\n#endif\n#ifdef __x86_64__\n\t__syscall_slong_t __glibc_reserved[3];\n#else\n# ifndef __USE_FILE_OFFSET64\n\tunsigned long int __glibc_reserved4;\n\tunsigned long int __glibc_reserved5;\n# else\n\t__ino64_t st_ino;\t/* File serial number.  */\n# endif\n#endif\n};\n\n#ifdef __USE_LARGEFILE64\n/* Note stat64 has the same shape as stat for x86-64.  */\nstruct stat64 {\n\t__dev_t st_dev;\t\t/* Device.  */\n# ifdef __x86_64__\n\t__ino64_t st_ino;\t/* File serial number.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__mode_t st_mode;\t/* File mode.  */\n# else\n\tunsigned int __pad1;\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n# endif\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n# ifdef __x86_64__\n\tint __pad0;\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\t__off_t st_size;\t/* Size of file, in bytes.  */\n# else\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\tunsigned int __pad2;\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n# endif\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n\t__blkcnt64_t st_blocks;\t/* Nr. 512-byte blocks allocated.  */\n# ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n# else\n\t__time_t st_atime;\t/* Time of last access.  */\n\t__syscall_ulong_t st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\t__syscall_ulong_t st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\t__syscall_ulong_t st_ctimensec;\t/* Nsecs of last status change.  */\n# endif\n# ifdef __x86_64__\n\t__syscall_slong_t __glibc_reserved[3];\n# else\n\t__ino64_t st_ino;\t/* File serial number.          */\n# endif\n};\n#endif\n\n/* Tell code we have these members.  */\n#define\t_STATBUF_ST_BLKSIZE\n#define _STATBUF_ST_RDEV\n/* Nanosecond resolution time values are supported.  */\n#define _STATBUF_ST_NSEC\n\n/* Encoding of the file mode.  */\n\n#define\t__S_IFMT\t0170000\t/* These bits determine file type.  */\n\n/* File types.  */\n#define\t__S_IFDIR\t0040000\t/* Directory.  */\n#define\t__S_IFCHR\t0020000\t/* Character device.  */\n#define\t__S_IFBLK\t0060000\t/* Block device.  */\n#define\t__S_IFREG\t0100000\t/* Regular file.  */\n#define\t__S_IFIFO\t0010000\t/* FIFO.  */\n#define\t__S_IFLNK\t0120000\t/* Symbolic link.  */\n#define\t__S_IFSOCK\t0140000\t/* Socket.  */\n\n/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But\n   they do it by enforcing the correct use of the macros.  */\n#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)\n\n/* Protection bits.  */\n\n#define\t__S_ISUID\t04000\t/* Set user ID on execution.  */\n#define\t__S_ISGID\t02000\t/* Set group ID on execution.  */\n#define\t__S_ISVTX\t01000\t/* Save swapped text after use (sticky).  */\n#define\t__S_IREAD\t0400\t/* Read by owner.  */\n#define\t__S_IWRITE\t0200\t/* Write by owner.  */\n#define\t__S_IEXEC\t0100\t/* Execute by owner.  */\n\n#ifdef __USE_ATFILE\n# define UTIME_NOW\t((1l << 30) - 1l)\n# define UTIME_OMIT\t((1l << 30) - 2l)\n#endif\n\n#endif\t\t\t\t/* bits/stat.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/statfs.h",
    "content": "/* Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_STATFS_H\n# error \"Never include <bits/statfs.h> directly; use <sys/statfs.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\nstruct statfs {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n#ifndef __USE_FILE_OFFSET64\n\t__fsblkcnt_t f_blocks;\n\t__fsblkcnt_t f_bfree;\n\t__fsblkcnt_t f_bavail;\n\t__fsfilcnt_t f_files;\n\t__fsfilcnt_t f_ffree;\n#else\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n#endif\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n\n#ifdef __USE_LARGEFILE64\nstruct statfs64 {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n#endif\n\n/* Tell code we have these members.  */\n#define _STATFS_F_NAMELEN\n#define _STATFS_F_FRSIZE\n#define _STATFS_F_FLAGS\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/stdint-intn.h",
    "content": "/* Define intN_t types.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_STDINT_INTN_H\n#define _BITS_STDINT_INTN_H\t1\n\n#include <bits/types.h>\n\ntypedef __int8_t int8_t;\ntypedef __int16_t int16_t;\ntypedef __int32_t int32_t;\ntypedef __int64_t int64_t;\n\n#endif\t\t\t\t/* bits/stdint-intn.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/stdint-uintn.h",
    "content": "/* Define uintN_t types.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_STDINT_UINTN_H\n#define _BITS_STDINT_UINTN_H\t1\n\n#include <bits/types.h>\n\ntypedef __uint8_t uint8_t;\ntypedef __uint16_t uint16_t;\ntypedef __uint32_t uint32_t;\ntypedef __uint64_t uint64_t;\n\n#endif\t\t\t\t/* bits/stdint-uintn.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/stdio_lim.h",
    "content": "/* Copyright (C) 1994-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_STDIO_LIM_H\n#define _BITS_STDIO_LIM_H 1\n\n#ifndef _STDIO_H\n# error \"Never include <bits/stdio_lim.h> directly; use <stdio.h> instead.\"\n#endif\n\n#define L_tmpnam 20\n#define TMP_MAX 238328\n#define FILENAME_MAX 4096\n\n#ifdef __USE_POSIX\n# define L_ctermid 9\n# if !defined __USE_XOPEN2K || defined __USE_GNU\n#  define L_cuserid 9\n# endif\n#endif\n\n#undef  FOPEN_MAX\n#define FOPEN_MAX 16\n\n#endif\t\t\t\t/* bits/stdio_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/stdlib-float.h",
    "content": "/* Floating-point inline functions for stdlib.h.\n   Copyright (C) 2012-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDLIB_H\n# error \"Never use <bits/stdlib-float.h> directly; include <stdlib.h> instead.\"\n#endif\n\n#ifdef __USE_EXTERN_INLINES\n__extern_inline double __NTH(atof(const char *__nptr))\n{\n\treturn strtod(__nptr, (char **)NULL);\n}\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sys_errlist.h",
    "content": "/* Declare sys_errlist and sys_nerr, or don't.  Compatibility (do) version.\n   Copyright (C) 2002-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDIO_H\n# error \"Never include <bits/sys_errlist.h> directly; use <stdio.h> instead.\"\n#endif\n\n/* sys_errlist and sys_nerr are deprecated.  Use strerror instead.  */\n\n#ifdef  __USE_MISC\nextern int sys_nerr;\nextern const char *const sys_errlist[];\n#endif\n#ifdef  __USE_GNU\nextern int _sys_nerr;\nextern const char *const _sys_errlist[];\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/sysmacros.h",
    "content": "/* Definitions of macros to access `dev_t' values.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SYSMACROS_H\n#define _BITS_SYSMACROS_H 1\n\n#ifndef _SYS_SYSMACROS_H\n# error \"Never include <bits/sysmacros.h> directly; use <sys/sysmacros.h> instead.\"\n#endif\n\n/* dev_t in glibc is a 64-bit quantity, with 32-bit major and minor numbers.\n   Our default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of\n   the major number and m is a hex digit of the minor number.  This is\n   downward compatible with legacy systems where dev_t is 16 bits wide,\n   encoded as MMmm.  It is also downward compatible with the Linux kernel,\n   which (as of 2016) uses 32-bit dev_t, encoded as mmmM MMmm.\n\n   Systems that use an incompatible encoding for dev_t should override this\n   file in the appropriate sysdeps subdirectory.  */\n\n#define __SYSMACROS_DECLARE_MAJOR(DECL_TEMPL)\t\t\t\\\n  DECL_TEMPL(unsigned int, major, (__dev_t __dev))\n\n#define __SYSMACROS_DEFINE_MAJOR(DECL_TEMPL)\t\t\t\\\n  __SYSMACROS_DECLARE_MAJOR (DECL_TEMPL)\t\t\t\\\n  {\t\t\t\t\t\t\t\t\\\n    unsigned int __major;\t\t\t\t\t\\\n    __major  = ((__dev & (__dev_t) 0x00000000000fff00u) >>  8); \\\n    __major |= ((__dev & (__dev_t) 0xfffff00000000000u) >> 32); \\\n    return __major;\t\t\t\t\t\t\\\n  }\n\n#define __SYSMACROS_DECLARE_MINOR(DECL_TEMPL)\t\t\t\\\n  DECL_TEMPL(unsigned int, minor, (__dev_t __dev))\n\n#define __SYSMACROS_DEFINE_MINOR(DECL_TEMPL)\t\t\t\\\n  __SYSMACROS_DECLARE_MINOR (DECL_TEMPL)\t\t\t\\\n  {\t\t\t\t\t\t\t\t\\\n    unsigned int __minor;\t\t\t\t\t\\\n    __minor  = ((__dev & (__dev_t) 0x00000000000000ffu) >>  0); \\\n    __minor |= ((__dev & (__dev_t) 0x00000ffffff00000u) >> 12); \\\n    return __minor;\t\t\t\t\t\t\\\n  }\n\n#define __SYSMACROS_DECLARE_MAKEDEV(DECL_TEMPL)\t\t\t\\\n  DECL_TEMPL(__dev_t, makedev, (unsigned int __major, unsigned int __minor))\n\n#define __SYSMACROS_DEFINE_MAKEDEV(DECL_TEMPL)\t\t\t\\\n  __SYSMACROS_DECLARE_MAKEDEV (DECL_TEMPL)\t\t\t\\\n  {\t\t\t\t\t\t\t\t\\\n    __dev_t __dev;\t\t\t\t\t\t\\\n    __dev  = (((__dev_t) (__major & 0x00000fffu)) <<  8);\t\\\n    __dev |= (((__dev_t) (__major & 0xfffff000u)) << 32);\t\\\n    __dev |= (((__dev_t) (__minor & 0x000000ffu)) <<  0);\t\\\n    __dev |= (((__dev_t) (__minor & 0xffffff00u)) << 12);\t\\\n    return __dev;\t\t\t\t\t\t\\\n  }\n\n#endif\t\t\t\t/* bits/sysmacros.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/termios.h",
    "content": "/* termios type and macro definitions.  Linux version.\n   Copyright (C) 1993-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _TERMIOS_H\n# error \"Never include <bits/termios.h> directly; use <termios.h> instead.\"\n#endif\n\ntypedef unsigned char cc_t;\ntypedef unsigned int speed_t;\ntypedef unsigned int tcflag_t;\n\n#define NCCS 32\nstruct termios {\n\ttcflag_t c_iflag;\t/* input mode flags */\n\ttcflag_t c_oflag;\t/* output mode flags */\n\ttcflag_t c_cflag;\t/* control mode flags */\n\ttcflag_t c_lflag;\t/* local mode flags */\n\tcc_t c_line;\t\t/* line discipline */\n\tcc_t c_cc[NCCS];\t/* control characters */\n\tspeed_t c_ispeed;\t/* input speed */\n\tspeed_t c_ospeed;\t/* output speed */\n#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1\n#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1\n};\n\n/* c_cc characters */\n#define VINTR 0\n#define VQUIT 1\n#define VERASE 2\n#define VKILL 3\n#define VEOF 4\n#define VTIME 5\n#define VMIN 6\n#define VSWTC 7\n#define VSTART 8\n#define VSTOP 9\n#define VSUSP 10\n#define VEOL 11\n#define VREPRINT 12\n#define VDISCARD 13\n#define VWERASE 14\n#define VLNEXT 15\n#define VEOL2 16\n\n/* c_iflag bits */\n#define IGNBRK\t0000001\n#define BRKINT\t0000002\n#define IGNPAR\t0000004\n#define PARMRK\t0000010\n#define INPCK\t0000020\n#define ISTRIP\t0000040\n#define INLCR\t0000100\n#define IGNCR\t0000200\n#define ICRNL\t0000400\n#define IUCLC\t0001000\n#define IXON\t0002000\n#define IXANY\t0004000\n#define IXOFF\t0010000\n#define IMAXBEL\t0020000\n#define IUTF8\t0040000\n\n/* c_oflag bits */\n#define OPOST\t0000001\n#define OLCUC\t0000002\n#define ONLCR\t0000004\n#define OCRNL\t0000010\n#define ONOCR\t0000020\n#define ONLRET\t0000040\n#define OFILL\t0000100\n#define OFDEL\t0000200\n#if defined __USE_MISC || defined __USE_XOPEN\n# define NLDLY\t0000400\n# define   NL0\t0000000\n# define   NL1\t0000400\n# define CRDLY\t0003000\n# define   CR0\t0000000\n# define   CR1\t0001000\n# define   CR2\t0002000\n# define   CR3\t0003000\n# define TABDLY\t0014000\n# define   TAB0\t0000000\n# define   TAB1\t0004000\n# define   TAB2\t0010000\n# define   TAB3\t0014000\n# define BSDLY\t0020000\n# define   BS0\t0000000\n# define   BS1\t0020000\n# define FFDLY\t0100000\n# define   FF0\t0000000\n# define   FF1\t0100000\n#endif\n\n#define VTDLY\t0040000\n#define   VT0\t0000000\n#define   VT1\t0040000\n\n#ifdef __USE_MISC\n# define XTABS\t0014000\n#endif\n\n/* c_cflag bit meaning */\n#ifdef __USE_MISC\n# define CBAUD\t0010017\n#endif\n#define  B0\t0000000\t\t/* hang up */\n#define  B50\t0000001\n#define  B75\t0000002\n#define  B110\t0000003\n#define  B134\t0000004\n#define  B150\t0000005\n#define  B200\t0000006\n#define  B300\t0000007\n#define  B600\t0000010\n#define  B1200\t0000011\n#define  B1800\t0000012\n#define  B2400\t0000013\n#define  B4800\t0000014\n#define  B9600\t0000015\n#define  B19200\t0000016\n#define  B38400\t0000017\n#ifdef __USE_MISC\n# define EXTA B19200\n# define EXTB B38400\n#endif\n#define CSIZE\t0000060\n#define   CS5\t0000000\n#define   CS6\t0000020\n#define   CS7\t0000040\n#define   CS8\t0000060\n#define CSTOPB\t0000100\n#define CREAD\t0000200\n#define PARENB\t0000400\n#define PARODD\t0001000\n#define HUPCL\t0002000\n#define CLOCAL\t0004000\n#ifdef __USE_MISC\n# define CBAUDEX 0010000\n#endif\n#define  B57600   0010001\n#define  B115200  0010002\n#define  B230400  0010003\n#define  B460800  0010004\n#define  B500000  0010005\n#define  B576000  0010006\n#define  B921600  0010007\n#define  B1000000 0010010\n#define  B1152000 0010011\n#define  B1500000 0010012\n#define  B2000000 0010013\n#define  B2500000 0010014\n#define  B3000000 0010015\n#define  B3500000 0010016\n#define  B4000000 0010017\n#define __MAX_BAUD B4000000\n#ifdef __USE_MISC\n# define CIBAUD\t  002003600000\t/* input baud rate (not used) */\n# define CMSPAR   010000000000\t/* mark or space (stick) parity */\n# define CRTSCTS  020000000000\t/* flow control */\n#endif\n\n/* c_lflag bits */\n#define ISIG\t0000001\n#define ICANON\t0000002\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n# define XCASE\t0000004\n#endif\n#define ECHO\t0000010\n#define ECHOE\t0000020\n#define ECHOK\t0000040\n#define ECHONL\t0000100\n#define NOFLSH\t0000200\n#define TOSTOP\t0000400\n#ifdef __USE_MISC\n# define ECHOCTL 0001000\n# define ECHOPRT 0002000\n# define ECHOKE\t 0004000\n# define FLUSHO\t 0010000\n# define PENDIN\t 0040000\n#endif\n#define IEXTEN\t0100000\n#ifdef __USE_MISC\n# define EXTPROC 0200000\n#endif\n\n/* tcflow() and TCXONC use these */\n#define\tTCOOFF\t\t0\n#define\tTCOON\t\t1\n#define\tTCIOFF\t\t2\n#define\tTCION\t\t3\n\n/* tcflush() and TCFLSH use these */\n#define\tTCIFLUSH\t0\n#define\tTCOFLUSH\t1\n#define\tTCIOFLUSH\t2\n\n/* tcsetattr uses these */\n#define\tTCSANOW\t\t0\n#define\tTCSADRAIN\t1\n#define\tTCSAFLUSH\t2\n\n#define _IOT_termios /* Hurd ioctl type field.  */ \\\n  _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/thread-shared-types.h",
    "content": "/* Common threading primitives definitions for both POSIX and C11.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _THREAD_SHARED_TYPES_H\n#define _THREAD_SHARED_TYPES_H 1\n\n/* Arch-specific definitions.  Each architecture must define the following\n   macros to define the expected sizes of pthread data types:\n\n   __SIZEOF_PTHREAD_ATTR_T        - size of pthread_attr_t.\n   __SIZEOF_PTHREAD_MUTEX_T       - size of pthread_mutex_t.\n   __SIZEOF_PTHREAD_MUTEXATTR_T   - size of pthread_mutexattr_t.\n   __SIZEOF_PTHREAD_COND_T        - size of pthread_cond_t.\n   __SIZEOF_PTHREAD_CONDATTR_T    - size of pthread_condattr_t.\n   __SIZEOF_PTHREAD_RWLOCK_T      - size of pthread_rwlock_t.\n   __SIZEOF_PTHREAD_RWLOCKATTR_T  - size of pthread_rwlockattr_t.\n   __SIZEOF_PTHREAD_BARRIER_T     - size of pthread_barrier_t.\n   __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t.\n\n   Also, the following macros must be define for internal pthread_mutex_t\n   struct definitions (struct __pthread_mutex_s):\n\n   __PTHREAD_COMPAT_PADDING_MID   - any additional members after 'kind'\n\t\t\t\t    and before '__spin' (for 64 bits) or\n\t\t\t\t    '__nusers' (for 32 bits).\n   __PTHREAD_COMPAT_PADDING_END   - any additional members at the end of\n\t\t\t\t    the internal structure.\n   __PTHREAD_MUTEX_LOCK_ELISION   - 1 if the architecture supports lock\n\t\t\t\t    elision or 0 otherwise.\n   __PTHREAD_MUTEX_NUSERS_AFTER_KIND - control where to put __nusers.  The\n\t\t\t\t       preferred value for new architectures\n\t\t\t\t       is 0.\n   __PTHREAD_MUTEX_USE_UNION      - control whether internal __spins and\n\t\t\t\t    __list will be place inside a union for\n\t\t\t\t    linuxthreads compatibility.\n\t\t\t\t    The preferred value for new architectures\n\t\t\t\t    is 0.\n\n   For a new port the preferred values for the required defines are:\n\n   #define __PTHREAD_COMPAT_PADDING_MID\n   #define __PTHREAD_COMPAT_PADDING_END\n   #define __PTHREAD_MUTEX_LOCK_ELISION         0\n   #define __PTHREAD_MUTEX_NUSERS_AFTER_KIND    0\n   #define __PTHREAD_MUTEX_USE_UNION            0\n\n   __PTHREAD_MUTEX_LOCK_ELISION can be set to 1 if the hardware plans to\n   eventually support lock elision using transactional memory.\n\n   The additional macro defines any constraint for the lock alignment\n   inside the thread structures:\n\n   __LOCK_ALIGNMENT - for internal lock/futex usage.\n\n   Same idea but for the once locking primitive:\n\n   __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition.\n\n   And finally the internal pthread_rwlock_t (struct __pthread_rwlock_arch_t)\n   must be defined.\n */\n#include <bits/pthreadtypes-arch.h>\n\n/* Common definition of pthread_mutex_t. */\n\n#if !__PTHREAD_MUTEX_USE_UNION\ntypedef struct __pthread_internal_list {\n\tstruct __pthread_internal_list *__prev;\n\tstruct __pthread_internal_list *__next;\n} __pthread_list_t;\n#else\ntypedef struct __pthread_internal_slist {\n\tstruct __pthread_internal_slist *__next;\n} __pthread_slist_t;\n#endif\n\n/* Lock elision support.  */\n#if __PTHREAD_MUTEX_LOCK_ELISION\n# if !__PTHREAD_MUTEX_USE_UNION\n#  define __PTHREAD_SPINS_DATA\t\\\n  short __spins;\t\t\\\n  short __elision\n#  define __PTHREAD_SPINS             0, 0\n# else\n#  define __PTHREAD_SPINS_DATA\t\\\n  struct\t\t\t\\\n  {\t\t\t\t\\\n    short __espins;\t\t\\\n    short __eelision;\t\t\\\n  } __elision_data\n#  define __PTHREAD_SPINS         { 0, 0 }\n#  define __spins __elision_data.__espins\n#  define __elision __elision_data.__eelision\n# endif\n#else\n# define __PTHREAD_SPINS_DATA int __spins\n/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */\n# define __PTHREAD_SPINS 0\n#endif\n\nstruct __pthread_mutex_s {\n\tint __lock __LOCK_ALIGNMENT;\n\tunsigned int __count;\n\tint __owner;\n#if !__PTHREAD_MUTEX_NUSERS_AFTER_KIND\n\tunsigned int __nusers;\n#endif\n\t/* KIND must stay at this position in the structure to maintain\n\t   binary compatibility with static initializers.  */\n\tint __kind;\n\t __PTHREAD_COMPAT_PADDING_MID\n#if __PTHREAD_MUTEX_NUSERS_AFTER_KIND\n\tunsigned int __nusers;\n#endif\n#if !__PTHREAD_MUTEX_USE_UNION\n\t __PTHREAD_SPINS_DATA;\n\t__pthread_list_t __list;\n# define __PTHREAD_MUTEX_HAVE_PREV      1\n#else\n\t__extension__ union {\n\t\t__PTHREAD_SPINS_DATA;\n\t\t__pthread_slist_t __list;\n\t};\n# define __PTHREAD_MUTEX_HAVE_PREV      0\n#endif\n __PTHREAD_COMPAT_PADDING_END};\n\n/* Common definition of pthread_cond_t. */\n\nstruct __pthread_cond_s {\n\t__extension__ union {\n\t\t__extension__ unsigned long long int __wseq;\n\t\tstruct {\n\t\t\tunsigned int __low;\n\t\t\tunsigned int __high;\n\t\t} __wseq32;\n\t};\n\t__extension__ union {\n\t\t__extension__ unsigned long long int __g1_start;\n\t\tstruct {\n\t\t\tunsigned int __low;\n\t\t\tunsigned int __high;\n\t\t} __g1_start32;\n\t};\n\tunsigned int __g_refs[2] __LOCK_ALIGNMENT;\n\tunsigned int __g_size[2];\n\tunsigned int __g1_orig_size;\n\tunsigned int __wrefs;\n\tunsigned int __g_signals[2];\n};\n\n#endif\t\t\t\t/* _THREAD_SHARED_TYPES_H  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/time.h",
    "content": "/* System-dependent timing definitions.  Linux version.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <time.h> instead.\n */\n\n#ifndef _BITS_TIME_H\n#define _BITS_TIME_H\t1\n\n#include <bits/types.h>\n\n/* ISO/IEC 9899:1999 7.23.1: Components of time\n   The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is\n   the number per second of the value returned by the `clock' function.  */\n/* CAE XSH, Issue 4, Version 2: <time.h>\n   The value of CLOCKS_PER_SEC is required to be 1 million on all\n   XSI-conformant systems. */\n#define CLOCKS_PER_SEC  ((__clock_t) 1000000)\n\n#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \\\n   && !defined __USE_XOPEN2K\n/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK\n   presents the real value for clock ticks per second for the system.  */\nextern long int __sysconf(int);\n# define CLK_TCK ((__clock_t) __sysconf (2))\t/* 2 is _SC_CLK_TCK */\n#endif\n\n#ifdef __USE_POSIX199309\n/* Identifier for system-wide realtime clock.  */\n# define CLOCK_REALTIME\t\t\t0\n/* Monotonic system-wide clock.  */\n# define CLOCK_MONOTONIC\t\t1\n/* High-resolution timer from the CPU.  */\n# define CLOCK_PROCESS_CPUTIME_ID\t2\n/* Thread-specific CPU-time clock.  */\n# define CLOCK_THREAD_CPUTIME_ID\t3\n/* Monotonic system-wide clock, not adjusted for frequency scaling.  */\n# define CLOCK_MONOTONIC_RAW\t\t4\n/* Identifier for system-wide realtime clock, updated only on ticks.  */\n# define CLOCK_REALTIME_COARSE\t\t5\n/* Monotonic system-wide clock, updated only on ticks.  */\n# define CLOCK_MONOTONIC_COARSE\t\t6\n/* Monotonic system-wide clock that includes time spent in suspension.  */\n# define CLOCK_BOOTTIME\t\t\t7\n/* Like CLOCK_REALTIME but also wakes suspended system.  */\n# define CLOCK_REALTIME_ALARM\t\t8\n/* Like CLOCK_BOOTTIME but also wakes suspended system.  */\n# define CLOCK_BOOTTIME_ALARM\t\t9\n/* Like CLOCK_REALTIME but in International Atomic Time.  */\n# define CLOCK_TAI\t\t\t11\n\n/* Flag to indicate time is absolute.  */\n# define TIMER_ABSTIME\t\t\t1\n#endif\n\n#ifdef __USE_GNU\n# include <bits/timex.h>\n\n__BEGIN_DECLS\n/* Tune a POSIX clock.  */\nextern int clock_adjtime(__clockid_t __clock_id, struct timex *__utx) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* use GNU */\n#endif\t\t\t\t/* bits/time.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/FILE.h",
    "content": "#ifndef __FILE_defined\n#define __FILE_defined 1\n\nstruct _IO_FILE;\n\n/* The opaque type of streams.  This is the definition used elsewhere.  */\ntypedef struct _IO_FILE FILE;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/__FILE.h",
    "content": "#ifndef ____FILE_defined\n#define ____FILE_defined 1\n\nstruct _IO_FILE;\ntypedef struct _IO_FILE __FILE;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/__locale_t.h",
    "content": "/* Definition of struct __locale_struct and __locale_t.\n   Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_TYPES___LOCALE_T_H\n#define _BITS_TYPES___LOCALE_T_H 1\n\n/* POSIX.1-2008: the locale_t type, representing a locale context\n   (implementation-namespace version).  This type should be treated\n   as opaque by applications; some details are exposed for the sake of\n   efficiency in e.g. ctype functions.  */\n\nstruct __locale_struct {\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tstruct __locale_data *__locales[13];\t/* 13 = __LC_LAST. */\n\n\t/* To increase the speed of this solution we add some special members.  */\n\tconst unsigned short int *__ctype_b;\n\tconst int *__ctype_tolower;\n\tconst int *__ctype_toupper;\n\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tconst char *__names[13];\n};\n\ntypedef struct __locale_struct *__locale_t;\n\n#endif\t\t\t\t/* bits/types/__locale_t.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/__mbstate_t.h",
    "content": "#ifndef ____mbstate_t_defined\n#define ____mbstate_t_defined 1\n\n/* Integral type unchanged by default argument promotions that can\n   hold any value corresponding to members of the extended character\n   set, as well as at least one value that does not correspond to any\n   member of the extended character set.  */\n#ifndef __WINT_TYPE__\n# define __WINT_TYPE__ unsigned int\n#endif\n\n/* Conversion state information.  */\ntypedef struct {\n\tint __count;\n\tunion {\n\t\t__WINT_TYPE__ __wch;\n\t\tchar __wchb[4];\n\t} __value;\t\t/* Value so far.  */\n} __mbstate_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/__sigset_t.h",
    "content": "#ifndef ____sigset_t_defined\n#define ____sigset_t_defined\n\n#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int)))\ntypedef struct {\n\tunsigned long int __val[_SIGSET_NWORDS];\n} __sigset_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/__sigval_t.h",
    "content": "/* Define __sigval_t.\n   Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef ____sigval_t_defined\n#define ____sigval_t_defined\n\n/* Type for data associated with a signal.  */\n#ifdef __USE_POSIX199309\nunion sigval {\n\tint sival_int;\n\tvoid *sival_ptr;\n};\n\ntypedef union sigval __sigval_t;\n#else\nunion __sigval {\n\tint __sival_int;\n\tvoid *__sival_ptr;\n};\n\ntypedef union __sigval __sigval_t;\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/clock_t.h",
    "content": "#ifndef __clock_t_defined\n#define __clock_t_defined 1\n\n#include <bits/types.h>\n\n/* Returned by `clock'.  */\ntypedef __clock_t clock_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/clockid_t.h",
    "content": "#ifndef __clockid_t_defined\n#define __clockid_t_defined 1\n\n#include <bits/types.h>\n\n/* Clock ID used in clock and timer functions.  */\ntypedef __clockid_t clockid_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/locale_t.h",
    "content": "/* Definition of locale_t.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_TYPES_LOCALE_T_H\n#define _BITS_TYPES_LOCALE_T_H 1\n\n#include <bits/types/__locale_t.h>\n\ntypedef __locale_t locale_t;\n\n#endif\t\t\t\t/* bits/types/locale_t.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/mbstate_t.h",
    "content": "#ifndef __mbstate_t_defined\n#define __mbstate_t_defined 1\n\n#include <bits/types/__mbstate_t.h>\n\ntypedef __mbstate_t mbstate_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/sig_atomic_t.h",
    "content": "#ifndef __sig_atomic_t_defined\n#define __sig_atomic_t_defined 1\n\n#include <bits/types.h>\n\n/* An integral type that can be modified atomically, without the\n   possibility of a signal arriving in the middle of the operation.  */\ntypedef __sig_atomic_t sig_atomic_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/sigevent_t.h",
    "content": "#ifndef __sigevent_t_defined\n#define __sigevent_t_defined 1\n\n#include <bits/wordsize.h>\n#include <bits/types.h>\n#include <bits/types/__sigval_t.h>\n\n#define __SIGEV_MAX_SIZE\t64\n#if __WORDSIZE == 64\n# define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 4)\n#else\n# define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 3)\n#endif\n\n/* Forward declaration.  */\n#ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n# define __have_pthread_attr_t\t1\n#endif\n\n/* Structure to transport application-defined values with signals.  */\ntypedef struct sigevent {\n\t__sigval_t sigev_value;\n\tint sigev_signo;\n\tint sigev_notify;\n\n\tunion {\n\t\tint _pad[__SIGEV_PAD_SIZE];\n\n\t\t/* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the\n\t\t   thread to receive the signal.  */\n\t\t__pid_t _tid;\n\n\t\tstruct {\n\t\t\tvoid (*_function) (__sigval_t);\t/* Function to start.  */\n\t\t\tpthread_attr_t *_attribute;\t/* Thread attributes.  */\n\t\t} _sigev_thread;\n\t} _sigev_un;\n} sigevent_t;\n\n/* POSIX names to access some of the members.  */\n#define sigev_notify_function   _sigev_un._sigev_thread._function\n#define sigev_notify_attributes _sigev_un._sigev_thread._attribute\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/siginfo_t.h",
    "content": "#ifndef __siginfo_t_defined\n#define __siginfo_t_defined 1\n\n#include <bits/wordsize.h>\n#include <bits/types.h>\n#include <bits/types/__sigval_t.h>\n\n#define __SI_MAX_SIZE\t128\n#if __WORDSIZE == 64\n# define __SI_PAD_SIZE\t((__SI_MAX_SIZE / sizeof (int)) - 4)\n#else\n# define __SI_PAD_SIZE\t((__SI_MAX_SIZE / sizeof (int)) - 3)\n#endif\n\n/* Some fields of siginfo_t have architecture-specific variations.  */\n#include <bits/siginfo-arch.h>\n#ifndef __SI_ALIGNMENT\n# define __SI_ALIGNMENT\t\t/* nothing */\n#endif\n#ifndef __SI_BAND_TYPE\n# define __SI_BAND_TYPE\t\tlong int\n#endif\n#ifndef __SI_CLOCK_T\n# define __SI_CLOCK_T\t\t__clock_t\n#endif\n#ifndef __SI_ERRNO_THEN_CODE\n# define __SI_ERRNO_THEN_CODE\t1\n#endif\n#ifndef __SI_HAVE_SIGSYS\n# define __SI_HAVE_SIGSYS\t1\n#endif\n#ifndef __SI_SIGFAULT_ADDL\n# define __SI_SIGFAULT_ADDL\t/* nothing */\n#endif\n\ntypedef struct {\n\tint si_signo;\t\t/* Signal number.  */\n#if __SI_ERRNO_THEN_CODE\n\tint si_errno;\t\t/* If non-zero, an errno value associated with\n\t\t\t\t   this signal, as defined in <errno.h>.  */\n\tint si_code;\t\t/* Signal code.  */\n#else\n\tint si_code;\n\tint si_errno;\n#endif\n#if __WORDSIZE == 64\n\tint __pad0;\t\t/* Explicit padding.  */\n#endif\n\n\tunion {\n\t\tint _pad[__SI_PAD_SIZE];\n\n\t\t/* kill().  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t} _kill;\n\n\t\t/* POSIX.1b timers.  */\n\t\tstruct {\n\t\t\tint si_tid;\t/* Timer ID.  */\n\t\t\tint si_overrun;\t/* Overrun count.  */\n\t\t\t__sigval_t si_sigval;\t/* Signal value.  */\n\t\t} _timer;\n\n\t\t/* POSIX.1b signals.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\t__sigval_t si_sigval;\t/* Signal value.  */\n\t\t} _rt;\n\n\t\t/* SIGCHLD.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Which child.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\tint si_status;\t/* Exit value or signal.  */\n\t\t\t__SI_CLOCK_T si_utime;\n\t\t\t__SI_CLOCK_T si_stime;\n\t\t} _sigchld;\n\n\t\t/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */\n\t\tstruct {\n\t\t\tvoid *si_addr;\t/* Faulting insn/memory ref.  */\n\t\t\t __SI_SIGFAULT_ADDL short int si_addr_lsb;\t/* Valid LSB of the reported address.  */\n\t\t\tunion {\n\t\t\t\t/* used when si_code=SEGV_BNDERR */\n\t\t\t\tstruct {\n\t\t\t\t\tvoid *_lower;\n\t\t\t\t\tvoid *_upper;\n\t\t\t\t} _addr_bnd;\n\t\t\t\t/* used when si_code=SEGV_PKUERR */\n\t\t\t\t__uint32_t _pkey;\n\t\t\t} _bounds;\n\t\t} _sigfault;\n\n\t\t/* SIGPOLL.  */\n\t\tstruct {\n\t\t\tlong int si_band;\t/* Band event for SIGPOLL.  */\n\t\t\tint si_fd;\n\t\t} _sigpoll;\n\n\t\t/* SIGSYS.  */\n#if __SI_HAVE_SIGSYS\n\t\tstruct {\n\t\t\tvoid *_call_addr;\t/* Calling user insn.  */\n\t\t\tint _syscall;\t/* Triggering system call number.  */\n\t\t\tunsigned int _arch;\t/* AUDIT_ARCH_* of syscall.  */\n\t\t} _sigsys;\n#endif\n\t} _sifields;\n} siginfo_t __SI_ALIGNMENT;\n\n/* X/Open requires some more fields with fixed names.  */\n#define si_pid\t\t_sifields._kill.si_pid\n#define si_uid\t\t_sifields._kill.si_uid\n#define si_timerid\t_sifields._timer.si_tid\n#define si_overrun\t_sifields._timer.si_overrun\n#define si_status\t_sifields._sigchld.si_status\n#define si_utime\t_sifields._sigchld.si_utime\n#define si_stime\t_sifields._sigchld.si_stime\n#define si_value\t_sifields._rt.si_sigval\n#define si_int\t\t_sifields._rt.si_sigval.sival_int\n#define si_ptr\t\t_sifields._rt.si_sigval.sival_ptr\n#define si_addr\t\t_sifields._sigfault.si_addr\n#define si_addr_lsb\t_sifields._sigfault.si_addr_lsb\n#define si_lower\t_sifields._sigfault._bounds._addr_bnd._lower\n#define si_upper\t_sifields._sigfault._bounds._addr_bnd._upper\n#define si_pkey\t\t_sifields._sigfault._bounds._pkey\n#define si_band\t\t_sifields._sigpoll.si_band\n#define si_fd\t\t_sifields._sigpoll.si_fd\n#if __SI_HAVE_SIGSYS\n# define si_call_addr\t_sifields._sigsys._call_addr\n# define si_syscall\t_sifields._sigsys._syscall\n# define si_arch\t_sifields._sigsys._arch\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/sigset_t.h",
    "content": "#ifndef __sigset_t_defined\n#define __sigset_t_defined 1\n\n#include <bits/types/__sigset_t.h>\n\n/* A set of signals to be blocked, unblocked, or waited for.  */\ntypedef __sigset_t sigset_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/sigval_t.h",
    "content": "#ifndef __sigval_t_defined\n#define __sigval_t_defined\n\n#include <bits/types/__sigval_t.h>\n\n/* To avoid sigval_t (not a standard type name) having C++ name\n   mangling depending on whether the selected standard includes union\n   sigval, it should not be defined at all when using a standard for\n   which the sigval name is not reserved; in that case, headers should\n   not include <bits/types/sigval_t.h> and should use only the\n   internal __sigval_t name.  */\n#ifndef __USE_POSIX199309\n# error \"sigval_t defined for standard not including union sigval\"\n#endif\n\ntypedef __sigval_t sigval_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/stack_t.h",
    "content": "/* Define stack_t.  Linux version.\n   Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __stack_t_defined\n#define __stack_t_defined 1\n\n#define __need_size_t\n#include <stddef.h>\n\n/* Structure describing a signal stack.  */\ntypedef struct {\n\tvoid *ss_sp;\n\tint ss_flags;\n\tsize_t ss_size;\n} stack_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_iovec.h",
    "content": "/* Define struct iovec.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __iovec_defined\n#define __iovec_defined 1\n\n#define __need_size_t\n#include <stddef.h>\n\n/* Structure for scatter/gather I/O.  */\nstruct iovec {\n\tvoid *iov_base;\t\t/* Pointer to data.  */\n\tsize_t iov_len;\t\t/* Length of data.  */\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_itimerspec.h",
    "content": "#ifndef __itimerspec_defined\n#define __itimerspec_defined 1\n\n#include <bits/types.h>\n#include <bits/types/struct_timespec.h>\n\n/* POSIX.1b structure for timer start values and intervals.  */\nstruct itimerspec {\n\tstruct timespec it_interval;\n\tstruct timespec it_value;\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_osockaddr.h",
    "content": "#ifndef __osockaddr_defined\n#define __osockaddr_defined 1\n\n/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire\n   format in the grotty old 4.3 `talk' protocol.  */\nstruct osockaddr {\n\tunsigned short int sa_family;\n\tunsigned char sa_data[14];\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_rusage.h",
    "content": "/* Define struct rusage.\n   Copyright (C) 1994-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __rusage_defined\n#define __rusage_defined 1\n\n#include <bits/types.h>\n#include <bits/types/struct_timeval.h>\n\n/* Structure which says how much of each resource has been used.  */\n\n/* The purpose of all the unions is to have the kernel-compatible layout\n   while keeping the API type as 'long int', and among machines where\n   __syscall_slong_t is not 'long int', this only does the right thing\n   for little-endian ones, like x32.  */\nstruct rusage {\n\t/* Total amount of user time used.  */\n\tstruct timeval ru_utime;\n\t/* Total amount of system time used.  */\n\tstruct timeval ru_stime;\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_maxrss;\n\t\t__syscall_slong_t __ru_maxrss_word;\n\t};\n\t/* Amount of sharing of text segment memory\n\t   with other processes (kilobyte-seconds).  */\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_ixrss;\n\t\t__syscall_slong_t __ru_ixrss_word;\n\t};\n\t/* Amount of data segment memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_idrss;\n\t\t__syscall_slong_t __ru_idrss_word;\n\t};\n\t/* Amount of stack memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_isrss;\n\t\t__syscall_slong_t __ru_isrss_word;\n\t};\n\t/* Number of soft page faults (i.e. those serviced by reclaiming\n\t   a page from the list of pages awaiting reallocation.  */\n\t__extension__ union {\n\t\tlong int ru_minflt;\n\t\t__syscall_slong_t __ru_minflt_word;\n\t};\n\t/* Number of hard page faults (i.e. those that required I/O).  */\n\t__extension__ union {\n\t\tlong int ru_majflt;\n\t\t__syscall_slong_t __ru_majflt_word;\n\t};\n\t/* Number of times a process was swapped out of physical memory.  */\n\t__extension__ union {\n\t\tlong int ru_nswap;\n\t\t__syscall_slong_t __ru_nswap_word;\n\t};\n\t/* Number of input operations via the file system.  Note: This\n\t   and `ru_oublock' do not include operations with the cache.  */\n\t__extension__ union {\n\t\tlong int ru_inblock;\n\t\t__syscall_slong_t __ru_inblock_word;\n\t};\n\t/* Number of output operations via the file system.  */\n\t__extension__ union {\n\t\tlong int ru_oublock;\n\t\t__syscall_slong_t __ru_oublock_word;\n\t};\n\t/* Number of IPC messages sent.  */\n\t__extension__ union {\n\t\tlong int ru_msgsnd;\n\t\t__syscall_slong_t __ru_msgsnd_word;\n\t};\n\t/* Number of IPC messages received.  */\n\t__extension__ union {\n\t\tlong int ru_msgrcv;\n\t\t__syscall_slong_t __ru_msgrcv_word;\n\t};\n\t/* Number of signals delivered.  */\n\t__extension__ union {\n\t\tlong int ru_nsignals;\n\t\t__syscall_slong_t __ru_nsignals_word;\n\t};\n\t/* Number of voluntary context switches, i.e. because the process\n\t   gave up the process before it had to (usually to wait for some\n\t   resource to be available).  */\n\t__extension__ union {\n\t\tlong int ru_nvcsw;\n\t\t__syscall_slong_t __ru_nvcsw_word;\n\t};\n\t/* Number of involuntary context switches, i.e. a higher priority process\n\t   became runnable or the current process used up its time slice.  */\n\t__extension__ union {\n\t\tlong int ru_nivcsw;\n\t\t__syscall_slong_t __ru_nivcsw_word;\n\t};\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_sigstack.h",
    "content": "/* Define struct sigstack.\n   Copyright (C) 1998-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __sigstack_defined\n#define __sigstack_defined 1\n\n/* Structure describing a signal stack (obsolete).  */\nstruct sigstack {\n\tvoid *ss_sp;\t\t/* Signal stack pointer.  */\n\tint ss_onstack;\t\t/* Nonzero if executing on this stack.  */\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_timespec.h",
    "content": "#ifndef __timespec_defined\n#define __timespec_defined 1\n\n#include <bits/types.h>\n\n/* POSIX.1b structure for a time value.  This is like a `struct timeval' but\n   has nanoseconds instead of microseconds.  */\nstruct timespec {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__syscall_slong_t tv_nsec;\t/* Nanoseconds.  */\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_timeval.h",
    "content": "#ifndef __timeval_defined\n#define __timeval_defined 1\n\n#include <bits/types.h>\n\n/* A time value that is accurate to the nearest\n   microsecond but also has a range of years.  */\nstruct timeval {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__suseconds_t tv_usec;\t/* Microseconds.  */\n};\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/struct_tm.h",
    "content": "#ifndef __struct_tm_defined\n#define __struct_tm_defined 1\n\n#include <bits/types.h>\n\n/* ISO C `broken-down time' structure.  */\nstruct tm {\n\tint tm_sec;\t\t/* Seconds.     [0-60] (1 leap second) */\n\tint tm_min;\t\t/* Minutes.     [0-59] */\n\tint tm_hour;\t\t/* Hours.       [0-23] */\n\tint tm_mday;\t\t/* Day.         [1-31] */\n\tint tm_mon;\t\t/* Month.       [0-11] */\n\tint tm_year;\t\t/* Year - 1900.  */\n\tint tm_wday;\t\t/* Day of week. [0-6] */\n\tint tm_yday;\t\t/* Days in year.[0-365] */\n\tint tm_isdst;\t\t/* DST.         [-1/0/1] */\n\n# ifdef\t__USE_MISC\n\tlong int tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *tm_zone;\t/* Timezone abbreviation.  */\n# else\n\tlong int __tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *__tm_zone;\t/* Timezone abbreviation.  */\n# endif\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/time_t.h",
    "content": "#ifndef __time_t_defined\n#define __time_t_defined 1\n\n#include <bits/types.h>\n\n/* Returned by `time'.  */\ntypedef __time_t time_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/timer_t.h",
    "content": "#ifndef __timer_t_defined\n#define __timer_t_defined 1\n\n#include <bits/types.h>\n\n/* Timer ID returned by `timer_create'.  */\ntypedef __timer_t timer_t;\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types/wint_t.h",
    "content": "#ifndef __wint_t_defined\n#define __wint_t_defined 1\n\n/* Some versions of stddef.h provide wint_t, even though neither the\n   C nor C++ standards, nor POSIX, specifies this.  We assume that\n   stddef.h will define the macro _WINT_T if and only if it provides\n   wint_t, and conversely, that it will avoid providing wint_t if\n   _WINT_T is already defined.  */\n#ifndef _WINT_T\n#define _WINT_T 1\n\n/* Integral type unchanged by default argument promotions that can\n   hold any value corresponding to members of the extended character\n   set, as well as at least one value that does not correspond to any\n   member of the extended character set.  */\n#ifndef __WINT_TYPE__\n# define __WINT_TYPE__ unsigned int\n#endif\n\ntypedef __WINT_TYPE__ wint_t;\n\n#endif\t\t\t\t/* _WINT_T */\n#endif\t\t\t\t/* bits/types/wint_t.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/types.h",
    "content": "/* bits/types.h -- definitions of __*_t types underlying *_t types.\n   Copyright (C) 2002-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/types.h> instead.\n */\n\n#ifndef\t_BITS_TYPES_H\n#define\t_BITS_TYPES_H\t1\n\n#include <features.h>\n#include <bits/wordsize.h>\n\n/* Convenience types.  */\ntypedef unsigned char __u_char;\ntypedef unsigned short int __u_short;\ntypedef unsigned int __u_int;\ntypedef unsigned long int __u_long;\n\n/* Fixed-size types, underlying types depend on word size and compiler.  */\ntypedef signed char __int8_t;\ntypedef unsigned char __uint8_t;\ntypedef signed short int __int16_t;\ntypedef unsigned short int __uint16_t;\ntypedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\n#if __WORDSIZE == 64\ntypedef signed long int __int64_t;\ntypedef unsigned long int __uint64_t;\n#else\n__extension__ typedef signed long long int __int64_t;\n__extension__ typedef unsigned long long int __uint64_t;\n#endif\n\n/* quad_t is also 64 bits.  */\n#if __WORDSIZE == 64\ntypedef long int __quad_t;\ntypedef unsigned long int __u_quad_t;\n#else\n__extension__ typedef long long int __quad_t;\n__extension__ typedef unsigned long long int __u_quad_t;\n#endif\n\n/* Largest integral types.  */\n#if __WORDSIZE == 64\ntypedef long int __intmax_t;\ntypedef unsigned long int __uintmax_t;\n#else\n__extension__ typedef long long int __intmax_t;\n__extension__ typedef unsigned long long int __uintmax_t;\n#endif\n\n/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE\n   macros for each of the OS types we define below.  The definitions\n   of those macros must use the following macros for underlying types.\n   We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned\n   variants of each of the following integer types on this machine.\n\n\t16\t\t-- \"natural\" 16-bit type (always short)\n\t32\t\t-- \"natural\" 32-bit type (always int)\n\t64\t\t-- \"natural\" 64-bit type (long or long long)\n\tLONG32\t\t-- 32-bit type, traditionally long\n\tQUAD\t\t-- 64-bit type, always long long\n\tWORD\t\t-- natural type of __WORDSIZE bits (int or long)\n\tLONGWORD\t-- type of __WORDSIZE bits, traditionally long\n\n   We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the\n   conventional uses of `long' or `long long' type modifiers match the\n   types we define, even when a less-adorned type would be the same size.\n   This matters for (somewhat) portably writing printf/scanf formats for\n   these types, where using the appropriate l or ll format modifiers can\n   make the typedefs and the formats match up across all GNU platforms.  If\n   we used `long' when it's 64 bits where `long long' is expected, then the\n   compiler would warn about the formats not matching the argument types,\n   and the programmer changing them to shut up the compiler would break the\n   program's portability.\n\n   Here we assume what is presently the case in all the GCC configurations\n   we support: long long is always 64 bits, long is always word/address size,\n   and int is always 32 bits.  */\n\n#define\t__S16_TYPE\t\tshort int\n#define __U16_TYPE\t\tunsigned short int\n#define\t__S32_TYPE\t\tint\n#define __U32_TYPE\t\tunsigned int\n#define __SLONGWORD_TYPE\tlong int\n#define __ULONGWORD_TYPE\tunsigned long int\n#if __WORDSIZE == 32\n# define __SQUAD_TYPE\t\t__quad_t\n# define __UQUAD_TYPE\t\t__u_quad_t\n# define __SWORD_TYPE\t\tint\n# define __UWORD_TYPE\t\tunsigned int\n# define __SLONG32_TYPE\t\tlong int\n# define __ULONG32_TYPE\t\tunsigned long int\n# define __S64_TYPE\t\t__quad_t\n# define __U64_TYPE\t\t__u_quad_t\n/* We want __extension__ before typedef's that use nonstandard base types\n   such as `long long' in C89 mode.  */\n# define __STD_TYPE\t\t__extension__ typedef\n#elif __WORDSIZE == 64\n# define __SQUAD_TYPE\t\tlong int\n# define __UQUAD_TYPE\t\tunsigned long int\n# define __SWORD_TYPE\t\tlong int\n# define __UWORD_TYPE\t\tunsigned long int\n# define __SLONG32_TYPE\t\tint\n# define __ULONG32_TYPE\t\tunsigned int\n# define __S64_TYPE\t\tlong int\n# define __U64_TYPE\t\tunsigned long int\n/* No need to mark the typedef with __extension__.   */\n# define __STD_TYPE\t\ttypedef\n#else\n# error\n#endif\n#include <bits/typesizes.h>\t/* Defines __*_T_TYPE macros.  */\n\n__STD_TYPE __DEV_T_TYPE __dev_t;\t/* Type of device numbers.  */\n__STD_TYPE __UID_T_TYPE __uid_t;\t/* Type of user identifications.  */\n__STD_TYPE __GID_T_TYPE __gid_t;\t/* Type of group identifications.  */\n__STD_TYPE __INO_T_TYPE __ino_t;\t/* Type of file serial numbers.  */\n__STD_TYPE __INO64_T_TYPE __ino64_t;\t/* Type of file serial numbers (LFS). */\n__STD_TYPE __MODE_T_TYPE __mode_t;\t/* Type of file attribute bitmasks.  */\n__STD_TYPE __NLINK_T_TYPE __nlink_t;\t/* Type of file link counts.  */\n__STD_TYPE __OFF_T_TYPE __off_t;\t/* Type of file sizes and offsets.  */\n__STD_TYPE __OFF64_T_TYPE __off64_t;\t/* Type of file sizes and offsets (LFS).  */\n__STD_TYPE __PID_T_TYPE __pid_t;\t/* Type of process identifications.  */\n__STD_TYPE __FSID_T_TYPE __fsid_t;\t/* Type of file system IDs.  */\n__STD_TYPE __CLOCK_T_TYPE __clock_t;\t/* Type of CPU usage counts.  */\n__STD_TYPE __RLIM_T_TYPE __rlim_t;\t/* Type for resource measurement.  */\n__STD_TYPE __RLIM64_T_TYPE __rlim64_t;\t/* Type for resource measurement (LFS).  */\n__STD_TYPE __ID_T_TYPE __id_t;\t/* General type for IDs.  */\n__STD_TYPE __TIME_T_TYPE __time_t;\t/* Seconds since the Epoch.  */\n__STD_TYPE __USECONDS_T_TYPE __useconds_t;\t/* Count of microseconds.  */\n__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t;\t/* Signed count of microseconds.  */\n\n__STD_TYPE __DADDR_T_TYPE __daddr_t;\t/* The type of a disk address.  */\n__STD_TYPE __KEY_T_TYPE __key_t;\t/* Type of an IPC key.  */\n\n/* Clock ID used in clock and timer functions.  */\n__STD_TYPE __CLOCKID_T_TYPE __clockid_t;\n\n/* Timer ID returned by `timer_create'.  */\n__STD_TYPE __TIMER_T_TYPE __timer_t;\n\n/* Type to represent block size.  */\n__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;\n\n/* Types from the Large File Support interface.  */\n\n/* Type to count number of disk blocks.  */\n__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;\n__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;\n\n/* Type to count file system blocks.  */\n__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;\n__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;\n\n/* Type to count file system nodes.  */\n__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;\n__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;\n\n/* Type of miscellaneous file system fields.  */\n__STD_TYPE __FSWORD_T_TYPE __fsword_t;\n\n__STD_TYPE __SSIZE_T_TYPE __ssize_t;\t/* Type of a byte count, or error.  */\n\n/* Signed long type used in system calls.  */\n__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;\n/* Unsigned long type used in system calls.  */\n__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;\n\n/* These few don't really vary by system, they always correspond\n   to one of the other defined types.  */\ntypedef __off64_t __loff_t;\t/* Type of file sizes and offsets (LFS).  */\ntypedef char *__caddr_t;\n\n/* Duplicates info from stdint.h but this is used in unistd.h.  */\n__STD_TYPE __SWORD_TYPE __intptr_t;\n\n/* Duplicate info from sys/socket.h.  */\n__STD_TYPE __U32_TYPE __socklen_t;\n\n/* C99: An integer type that can be accessed as an atomic entity,\n   even in the presence of asynchronous interrupts.\n   It is not currently necessary for this to be machine-specific.  */\ntypedef int __sig_atomic_t;\n\n#undef __STD_TYPE\n\n#endif\t\t\t\t/* bits/types.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/typesizes.h",
    "content": "/* bits/typesizes.h -- underlying types for *_t.  Linux/x86-64 version.\n   Copyright (C) 2012-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_TYPES_H\n# error \"Never include <bits/typesizes.h> directly; use <sys/types.h> instead.\"\n#endif\n\n#ifndef\t_BITS_TYPESIZES_H\n#define\t_BITS_TYPESIZES_H\t1\n\n/* See <bits/types.h> for the meaning of these macros.  This file exists so\n   that <bits/types.h> need not vary across different GNU platforms.  */\n\n/* X32 kernel interface is 64-bit.  */\n#if defined __x86_64__ && defined __ILP32__\n# define __SYSCALL_SLONG_TYPE\t__SQUAD_TYPE\n# define __SYSCALL_ULONG_TYPE\t__UQUAD_TYPE\n#else\n# define __SYSCALL_SLONG_TYPE\t__SLONGWORD_TYPE\n# define __SYSCALL_ULONG_TYPE\t__ULONGWORD_TYPE\n#endif\n\n#define __DEV_T_TYPE\t\t__UQUAD_TYPE\n#define __UID_T_TYPE\t\t__U32_TYPE\n#define __GID_T_TYPE\t\t__U32_TYPE\n#define __INO_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n#define __INO64_T_TYPE\t\t__UQUAD_TYPE\n#define __MODE_T_TYPE\t\t__U32_TYPE\n#ifdef __x86_64__\n# define __NLINK_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n# define __FSWORD_T_TYPE\t__SYSCALL_SLONG_TYPE\n#else\n# define __NLINK_T_TYPE\t\t__UWORD_TYPE\n# define __FSWORD_T_TYPE\t__SWORD_TYPE\n#endif\n#define __OFF_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __OFF64_T_TYPE\t\t__SQUAD_TYPE\n#define __PID_T_TYPE\t\t__S32_TYPE\n#define __RLIM_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n#define __RLIM64_T_TYPE\t\t__UQUAD_TYPE\n#define __BLKCNT_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __BLKCNT64_T_TYPE\t__SQUAD_TYPE\n#define __FSBLKCNT_T_TYPE\t__SYSCALL_ULONG_TYPE\n#define __FSBLKCNT64_T_TYPE\t__UQUAD_TYPE\n#define __FSFILCNT_T_TYPE\t__SYSCALL_ULONG_TYPE\n#define __FSFILCNT64_T_TYPE\t__UQUAD_TYPE\n#define __ID_T_TYPE\t\t__U32_TYPE\n#define __CLOCK_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __TIME_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __USECONDS_T_TYPE\t__U32_TYPE\n#define __SUSECONDS_T_TYPE\t__SYSCALL_SLONG_TYPE\n#define __DADDR_T_TYPE\t\t__S32_TYPE\n#define __KEY_T_TYPE\t\t__S32_TYPE\n#define __CLOCKID_T_TYPE\t__S32_TYPE\n#define __TIMER_T_TYPE\t\tvoid *\n#define __BLKSIZE_T_TYPE\t__SYSCALL_SLONG_TYPE\n#define __FSID_T_TYPE\t\tstruct { int __val[2]; }\n#define __SSIZE_T_TYPE\t\t__SWORD_TYPE\n#define __CPU_MASK_TYPE \t__SYSCALL_ULONG_TYPE\n\n#ifdef __x86_64__\n/* Tell the libc code that off_t and off64_t are actually the same type\n   for all ABI purposes, even if possibly expressed as different base types\n   for C type-checking purposes.  */\n# define __OFF_T_MATCHES_OFF64_T\t1\n\n/* Same for ino_t and ino64_t.  */\n# define __INO_T_MATCHES_INO64_T\t1\n\n/* And for __rlim_t and __rlim64_t.  */\n# define __RLIM_T_MATCHES_RLIM64_T\t1\n#else\n# define __RLIM_T_MATCHES_RLIM64_T\t0\n#endif\n\n/* Number of descriptors that can fit in an `fd_set'.  */\n#define __FD_SETSIZE\t\t1024\n\n#endif\t\t\t\t/* bits/typesizes.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/uintn-identity.h",
    "content": "/* Inline functions to return unsigned integer values unchanged.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _NETINET_IN_H && !defined _ENDIAN_H\n# error \"Never use <bits/uintn-identity.h> directly; include <netinet/in.h> or <endian.h> instead.\"\n#endif\n\n#ifndef _BITS_UINTN_IDENTITY_H\n#define _BITS_UINTN_IDENTITY_H 1\n\n#include <bits/types.h>\n\n/* These inline functions are to ensure the appropriate type\n   conversions and associated diagnostics from macros that convert to\n   a given endianness.  */\n\nstatic __inline __uint16_t __uint16_identity(__uint16_t __x)\n{\n\treturn __x;\n}\n\nstatic __inline __uint32_t __uint32_identity(__uint32_t __x)\n{\n\treturn __x;\n}\n\nstatic __inline __uint64_t __uint64_identity(__uint64_t __x)\n{\n\treturn __x;\n}\n\n#endif\t\t\t\t/* _BITS_UINTN_IDENTITY_H.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/uio_lim.h",
    "content": "/* Implementation limits related to sys/uio.h - Linux version.\n   Copyright (C) 2017-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_UIO_LIM_H\n#define _BITS_UIO_LIM_H 1\n\n/* Maximum length of the 'struct iovec' array in a single call to\n   readv or writev.\n\n   This macro has different values in different kernel versions.  The\n   latest versions of the kernel use 1024 and this is good choice.  Since\n   the C library implementation of readv/writev is able to emulate the\n   functionality even if the currently running kernel does not support\n   this large value the readv/writev call will not fail because of this.  */\n#define __IOV_MAX\t1024\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/utsname.h",
    "content": "/* Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UTSNAME_H\n# error \"Never include <bits/utsname.h> directly; use <sys/utsname.h> instead.\"\n#endif\n\n/* Length of the entries in `struct utsname' is 65.  */\n#define _UTSNAME_LENGTH 65\n\n/* Linux provides as additional information in the `struct utsname'\n   the name of the current domain.  Define _UTSNAME_DOMAIN_LENGTH\n   to a value != 0 to activate this entry.  */\n#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/waitflags.h",
    "content": "/* Definitions of flag bits for `waitpid' et al.\n   Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n# error \"Never include <bits/waitflags.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Bits in the third argument to `waitpid'.  */\n#define\tWNOHANG\t\t1\t/* Don't block waiting.  */\n#define\tWUNTRACED\t2\t/* Report status of stopped children.  */\n\n/* Bits in the fourth argument to `waitid'.  */\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# define WSTOPPED\t2\t/* Report stopped child (same as WUNTRACED). */\n# define WEXITED\t4\t/* Report dead child.  */\n# define WCONTINUED\t8\t/* Report continued child.  */\n# define WNOWAIT\t0x01000000\t/* Don't reap, just poll status.  */\n#endif\n\n#define __WNOTHREAD     0x20000000\t/* Don't wait on children of other threads\n\t\t\t\t\t   in this group */\n#define __WALL\t\t0x40000000\t/* Wait for any child.  */\n#define __WCLONE\t0x80000000\t/* Wait for cloned process.  */\n\n/* The following values are used by the `waitid' function.  */\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# ifndef __ENUM_IDTYPE_T\n# define __ENUM_IDTYPE_T 1\n\n/* The Linux kernel defines these bare, rather than an enum,\n   which causes a conflict if the include order is reversed. */\n# undef P_ALL\n# undef P_PID\n# undef P_PGID\n\ntypedef enum {\n\tP_ALL,\t\t\t/* Wait for any child.  */\n\tP_PID,\t\t\t/* Wait for specified process.  */\n\tP_PGID\t\t\t/* Wait for members of process group.  */\n} idtype_t;\n# endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/waitstatus.h",
    "content": "/* Definitions of status bits for `wait' et al.\n   Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n# error \"Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Everything extant so far uses these same bits.  */\n\n/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */\n#define\t__WEXITSTATUS(status)\t(((status) & 0xff00) >> 8)\n\n/* If WIFSIGNALED(STATUS), the terminating signal.  */\n#define\t__WTERMSIG(status)\t((status) & 0x7f)\n\n/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */\n#define\t__WSTOPSIG(status)\t__WEXITSTATUS(status)\n\n/* Nonzero if STATUS indicates normal termination.  */\n#define\t__WIFEXITED(status)\t(__WTERMSIG(status) == 0)\n\n/* Nonzero if STATUS indicates termination by a signal.  */\n#define __WIFSIGNALED(status) \\\n  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)\n\n/* Nonzero if STATUS indicates the child is stopped.  */\n#define\t__WIFSTOPPED(status)\t(((status) & 0xff) == 0x7f)\n\n/* Nonzero if STATUS indicates the child continued after a stop.  We only\n   define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */\n#ifdef WCONTINUED\n# define __WIFCONTINUED(status)\t((status) == __W_CONTINUED)\n#endif\n\n/* Nonzero if STATUS indicates the child dumped core.  */\n#define\t__WCOREDUMP(status)\t((status) & __WCOREFLAG)\n\n/* Macros for constructing status values.  */\n#define\t__W_EXITCODE(ret, sig)\t((ret) << 8 | (sig))\n#define\t__W_STOPCODE(sig)\t((sig) << 8 | 0x7f)\n#define __W_CONTINUED\t\t0xffff\n#define\t__WCOREFLAG\t\t0x80\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/wchar.h",
    "content": "/* wchar_t type related definitions.\n   Copyright (C) 2000-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_WCHAR_H\n#define _BITS_WCHAR_H\t1\n\n/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__\n   are not defined, give the right value and type as long as both int\n   and wchar_t are 32-bit types.  Adding L'\\0' to a constant value\n   ensures that the type is correct; it is necessary to use (L'\\0' +\n   0) rather than just L'\\0' so that the type in C++ is the promoted\n   version of wchar_t rather than the distinct wchar_t type itself.\n   Because wchar_t in preprocessor #if expressions is treated as\n   intmax_t or uintmax_t, the expression (L'\\0' - 1) would have the\n   wrong value for WCHAR_MAX in such expressions and so cannot be used\n   to define __WCHAR_MAX in the unsigned case.  */\n\n#ifdef __WCHAR_MAX__\n# define __WCHAR_MAX\t__WCHAR_MAX__\n#elif L'\\0' - 1 > 0\n# define __WCHAR_MAX\t(0xffffffffu + L'\\0')\n#else\n# define __WCHAR_MAX\t(0x7fffffff + L'\\0')\n#endif\n\n#ifdef __WCHAR_MIN__\n# define __WCHAR_MIN\t__WCHAR_MIN__\n#elif L'\\0' - 1 > 0\n# define __WCHAR_MIN\t(L'\\0' + 0)\n#else\n# define __WCHAR_MIN\t(-__WCHAR_MAX - 1)\n#endif\n\n#endif\t\t\t\t/* bits/wchar.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/wordsize.h",
    "content": "/* Determine the wordsize from the preprocessor defines.  */\n\n#if defined __x86_64__ && !defined __ILP32__\n# define __WORDSIZE\t64\n#else\n# define __WORDSIZE\t32\n#define __WORDSIZE32_SIZE_ULONG\t\t0\n#define __WORDSIZE32_PTRDIFF_LONG\t0\n#endif\n\n#ifdef __x86_64__\n# define __WORDSIZE_TIME64_COMPAT32\t1\n/* Both x86-64 and x32 use the 64-bit system call interface.  */\n# define __SYSCALL_WORDSIZE\t\t64\n#else\n# define __WORDSIZE_TIME64_COMPAT32\t0\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/bits/xopen_lim.h",
    "content": "/* Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <limits.h> instead.\n */\n\n/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2\n   System Interfaces and Headers, 4.16 <limits.h>\n\n   Please note only the values which are not greater than the minimum\n   stated in the standard document are listed.  The `sysconf' functions\n   should be used to obtain the actual value.  */\n\n#ifndef _XOPEN_LIM_H\n#define _XOPEN_LIM_H\t1\n\n/* We do not provide fixed values for\n\n   ARG_MAX\tMaximum length of argument to the `exec' function\n\t\tincluding environment data.\n\n   ATEXIT_MAX\tMaximum number of functions that may be registered\n\t\twith `atexit'.\n\n   CHILD_MAX\tMaximum number of simultaneous processes per real\n\t\tuser ID.\n\n   OPEN_MAX\tMaximum number of files that one process can have open\n\t\tat anyone time.\n\n   PAGESIZE\n   PAGE_SIZE\tSize of bytes of a page.\n\n   PASS_MAX\tMaximum number of significant bytes in a password.\n\n   We only provide a fixed limit for\n\n   IOV_MAX\tMaximum number of `iovec' structures that one process has\n\t\tavailable for use with `readv' or writev'.\n\n   if this is indeed fixed by the underlying system.\n*/\n\n/* Maximum number of `iovec' structures that may be used in a single call\n   to `readv', `writev', etc.  */\n#define\t_XOPEN_IOV_MAX\t_POSIX_UIO_MAXIOV\n\n#include <bits/uio_lim.h>\n#ifdef __IOV_MAX\n# define IOV_MAX __IOV_MAX\n#else\n# undef IOV_MAX\n#endif\n\n/* Maximum value of `digit' in calls to the `printf' and `scanf'\n   functions.  We have no limit, so return a reasonable value.  */\n#define NL_ARGMAX\t_POSIX_ARG_MAX\n\n/* Maximum number of bytes in a `LANG' name.  We have no limit.  */\n#define NL_LANGMAX\t_POSIX2_LINE_MAX\n\n/* Maximum message number.  We have no limit.  */\n#define NL_MSGMAX\tINT_MAX\n\n/* Maximum number of bytes in N-to-1 collation mapping.  We have no\n   limit.  */\n#if defined __USE_GNU || !defined __USE_XOPEN2K8\n# define NL_NMAX\tINT_MAX\n#endif\n\n/* Maximum set number.  We have no limit.  */\n#define NL_SETMAX\tINT_MAX\n\n/* Maximum number of bytes in a message.  We have no limit.  */\n#define NL_TEXTMAX\tINT_MAX\n\n/* Default process priority.  */\n#define NZERO\t\t20\n\n/* Number of bits in a word of type `int'.  */\n#ifdef INT_MAX\n# if INT_MAX == 32767\n#  define WORD_BIT\t16\n# else\n#  if INT_MAX == 2147483647\n#   define WORD_BIT\t32\n#  else\n/* Safe assumption.  */\n#   define WORD_BIT\t64\n#  endif\n# endif\n#elif defined __INT_MAX__\n# if __INT_MAX__ == 32767\n#  define WORD_BIT\t16\n# else\n#  if __INT_MAX__ == 2147483647\n#   define WORD_BIT\t32\n#  else\n/* Safe assumption.  */\n#   define WORD_BIT\t64\n#  endif\n# endif\n#else\n# define WORD_BIT\t32\n#endif\n\n/* Number of bits in a word of type `long int'.  */\n#ifdef LONG_MAX\n# if LONG_MAX == 2147483647\n#  define LONG_BIT\t32\n# else\n/* Safe assumption.  */\n#  define LONG_BIT\t64\n# endif\n#elif defined __LONG_MAX__\n# if __LONG_MAX__ == 2147483647\n#  define LONG_BIT\t32\n# else\n/* Safe assumption.  */\n#  define LONG_BIT\t64\n# endif\n#else\n# include <bits/wordsize.h>\n# if __WORDSIZE == 64\n#  define LONG_BIT\t64\n# else\n#  define LONG_BIT\t32\n# endif\n#endif\n\n#endif\t\t\t\t/* bits/xopen_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/gnu/stubs-32.h",
    "content": "/* This file is automatically generated.\n   It defines a symbol `__stub_FUNCTION' for each function\n   in the C library which is a stub, meaning it will fail\n   every time called, usually setting errno to ENOSYS.  */\n\n#ifdef _LIBC\n# error Applications may not define the macro _LIBC\n#endif\n\n#define __stub_chflags\n#define __stub_fattach\n#define __stub_fchflags\n#define __stub_fdetach\n#define __stub_gtty\n#define __stub_lchmod\n#define __stub_revoke\n#define __stub_setlogin\n#define __stub_sigreturn\n#define __stub_sstk\n#define __stub_stty\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/gnu/stubs.h",
    "content": "/* This file is automatically generated.\n   This file selects the right generated file of `__stub_FUNCTION' macros\n   based on the architecture being compiled for.  */\n\n#if !defined __x86_64__\n# include <gnu/stubs-32.h>\n#endif\n#if defined __x86_64__ && defined __LP64__\n# include <gnu/stubs-64.h>\n#endif\n#if defined __x86_64__ && defined __ILP32__\n# include <gnu/stubs-x32.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/cdefs.h",
    "content": "/* Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_CDEFS_H\n#define\t_SYS_CDEFS_H\t1\n\n/* We are almost always included from features.h. */\n#ifndef _FEATURES_H\n# include <features.h>\n#endif\n\n/* The GNU libc does not support any K&R compilers or the traditional mode\n   of ISO C compilers anymore.  Check for some of the combinations not\n   anymore supported.  */\n#if defined __GNUC__ && !defined __STDC__\n# error \"You need a ISO C conforming compiler to use the glibc headers\"\n#endif\n\n/* Some user header file might have defined this before.  */\n#undef\t__P\n#undef\t__PMT\n\n#ifdef __GNUC__\n\n/* All functions, except those with callbacks or those that\n   synchronize memory, are leaf functions.  */\n# if __GNUC_PREREQ (4, 6) && !defined _LIBC\n#  define __LEAF , __leaf__\n#  define __LEAF_ATTR __attribute__ ((__leaf__))\n# else\n#  define __LEAF\n#  define __LEAF_ATTR\n# endif\n\n/* GCC can always grok prototypes.  For C++ programs we add throw()\n   to help it optimize the function calls.  But this works only with\n   gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions\n   as non-throwing using a function attribute since programs can use\n   the -fexceptions options for C code as well.  */\n# if !defined __cplusplus && __GNUC_PREREQ (3, 3)\n#  define __THROW\t__attribute__ ((__nothrow__ __LEAF))\n#  define __THROWNL\t__attribute__ ((__nothrow__))\n#  define __NTH(fct)\t__attribute__ ((__nothrow__ __LEAF)) fct\n#  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct\n# else\n#  if defined __cplusplus && __GNUC_PREREQ (2,8)\n#   define __THROW\tthrow ()\n#   define __THROWNL\tthrow ()\n#   define __NTH(fct)\t__LEAF_ATTR fct throw ()\n#   define __NTHNL(fct) fct throw ()\n#  else\n#   define __THROW\n#   define __THROWNL\n#   define __NTH(fct)\tfct\n#   define __NTHNL(fct) fct\n#  endif\n# endif\n\n#else\t\t\t\t/* Not GCC.  */\n\n# define __inline\t\t/* No inline functions.  */\n\n# define __THROW\n# define __THROWNL\n# define __NTH(fct)\tfct\n\n#endif\t\t\t\t/* GCC.  */\n\n/* Compilers that are not clang may object to\n       #if defined __clang__ && __has_extension(...)\n   even though they do not need to evaluate the right-hand side of the &&.  */\n#if defined __clang__ && defined __has_extension\n# define __glibc_clang_has_extension(ext) __has_extension (ext)\n#else\n# define __glibc_clang_has_extension(ext) 0\n#endif\n\n/* These two macros are not used in glibc anymore.  They are kept here\n   only because some other projects expect the macros to be defined.  */\n#define __P(args)\targs\n#define __PMT(args)\targs\n\n/* For these things, GCC behaves the ANSI way normally,\n   and the non-ANSI way under -traditional.  */\n\n#define __CONCAT(x,y)\tx ## y\n#define __STRING(x)\t#x\n\n/* This is not a typedef so `const __ptr_t' does the right thing.  */\n#define __ptr_t void *\n\n/* C++ needs to know that types and declarations are C, not C++.  */\n#ifdef\t__cplusplus\n# define __BEGIN_DECLS\textern \"C\" {\n# define __END_DECLS\t}\n#else\n# define __BEGIN_DECLS\n# define __END_DECLS\n#endif\n\n/* Fortify support.  */\n#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)\n#define __bos0(ptr) __builtin_object_size (ptr, 0)\n\n#if __GNUC_PREREQ (4,3)\n# define __warndecl(name, msg) \\\n  extern void name (void) __attribute__((__warning__ (msg)))\n# define __warnattr(msg) __attribute__((__warning__ (msg)))\n# define __errordecl(name, msg) \\\n  extern void name (void) __attribute__((__error__ (msg)))\n#else\n# define __warndecl(name, msg) extern void name (void)\n# define __warnattr(msg)\n# define __errordecl(name, msg) extern void name (void)\n#endif\n\n/* Support for flexible arrays.\n   Headers that should use flexible arrays only if they're \"real\"\n   (e.g. only if they won't affect sizeof()) should test\n   #if __glibc_c99_flexarr_available.  */\n#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n# define __flexarr\t[]\n# define __glibc_c99_flexarr_available 1\n#elif __GNUC_PREREQ (2,97)\n/* GCC 2.97 supports C99 flexible array members as an extension,\n   even when in C89 mode or compiling C++ (any version).  */\n# define __flexarr\t[]\n# define __glibc_c99_flexarr_available 1\n#elif defined __GNUC__\n/* Pre-2.97 GCC did not support C99 flexible arrays but did have\n   an equivalent extension with slightly different notation.  */\n# define __flexarr\t[0]\n# define __glibc_c99_flexarr_available 1\n#else\n/* Some other non-C99 compiler.  Approximate with [1].  */\n# define __flexarr\t[1]\n# define __glibc_c99_flexarr_available 0\n#endif\n\n/* __asm__ (\"xyz\") is used throughout the headers to rename functions\n   at the assembly language level.  This is wrapped by the __REDIRECT\n   macro, in order to support compilers that can do this some other\n   way.  When compilers don't support asm-names at all, we have to do\n   preprocessor tricks instead (which don't have exactly the right\n   semantics, but it's the best we can do).\n\n   Example:\n   int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */\n\n#if defined __GNUC__ && __GNUC__ >= 2\n\n# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))\n# ifdef __cplusplus\n#  define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __THROW __asm__ (__ASMNAME (#alias))\n#  define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __THROWNL __asm__ (__ASMNAME (#alias))\n# else\n#  define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROW\n#  define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROWNL\n# endif\n# define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n# define __ASMNAME2(prefix, cname) __STRING (prefix) cname\n\n/*\n#elif __SOME_OTHER_COMPILER__\n\n# define __REDIRECT(name, proto, alias) name proto; \\\n\t_Pragma(\"let \" #name \" = \" #alias)\n*/\n#endif\n\n/* GCC has various useful declarations that can be made with the\n   `__attribute__' syntax.  All of the ways we use this do fine if\n   they are omitted for compilers that don't understand it. */\n#if !defined __GNUC__ || __GNUC__ < 2\n# define __attribute__(xyz)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.96 development the `malloc' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n# define __attribute_malloc__ __attribute__ ((__malloc__))\n#else\n# define __attribute_malloc__\t/* Ignore */\n#endif\n\n/* Tell the compiler which arguments to an allocation function\n   indicate the size of the allocation.  */\n#if __GNUC_PREREQ (4, 3)\n# define __attribute_alloc_size__(params) \\\n  __attribute__ ((__alloc_size__ params))\n#else\n# define __attribute_alloc_size__(params)\t/* Ignore.  */\n#endif\n\n/* At some point during the gcc 2.96 development the `pure' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n# define __attribute_pure__ __attribute__ ((__pure__))\n#else\n# define __attribute_pure__\t/* Ignore */\n#endif\n\n/* This declaration tells the compiler that the value is constant.  */\n#if __GNUC_PREREQ (2,5)\n# define __attribute_const__ __attribute__ ((__const__))\n#else\n# define __attribute_const__\t/* Ignore */\n#endif\n\n/* At some point during the gcc 3.1 development the `used' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (3,1)\n# define __attribute_used__ __attribute__ ((__used__))\n# define __attribute_noinline__ __attribute__ ((__noinline__))\n#else\n# define __attribute_used__ __attribute__ ((__unused__))\n# define __attribute_noinline__\t/* Ignore */\n#endif\n\n/* Since version 3.2, gcc allows marking deprecated functions.  */\n#if __GNUC_PREREQ (3,2)\n# define __attribute_deprecated__ __attribute__ ((__deprecated__))\n#else\n# define __attribute_deprecated__\t/* Ignore */\n#endif\n\n/* Since version 4.5, gcc also allows one to specify the message printed\n   when a deprecated function is used.  clang claims to be gcc 4.2, but\n   may also support this feature.  */\n#if __GNUC_PREREQ (4,5) || \\\n    __glibc_clang_has_extension (__attribute_deprecated_with_message__)\n# define __attribute_deprecated_msg__(msg) \\\n\t __attribute__ ((__deprecated__ (msg)))\n#else\n# define __attribute_deprecated_msg__(msg) __attribute_deprecated__\n#endif\n\n/* At some point during the gcc 2.8 development the `format_arg' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.\n   If several `format_arg' attributes are given for the same function, in\n   gcc-3.0 and older, all but the last one are ignored.  In newer gccs,\n   all designated arguments are considered.  */\n#if __GNUC_PREREQ (2,8)\n# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))\n#else\n# define __attribute_format_arg__(x)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.97 development the `strfmon' format\n   attribute for functions was introduced.  We don't want to use it\n   unconditionally (although this would be possible) since it\n   generates warnings.  */\n#if __GNUC_PREREQ (2,97)\n# define __attribute_format_strfmon__(a,b) \\\n  __attribute__ ((__format__ (__strfmon__, a, b)))\n#else\n# define __attribute_format_strfmon__(a,b)\t/* Ignore */\n#endif\n\n/* The nonull function attribute allows to mark pointer parameters which\n   must not be NULL.  */\n#if __GNUC_PREREQ (3,3)\n# define __nonnull(params) __attribute__ ((__nonnull__ params))\n#else\n# define __nonnull(params)\n#endif\n\n/* If fortification mode, we warn about unused results of certain\n   function calls which can lead to problems.  */\n#if __GNUC_PREREQ (3,4)\n# define __attribute_warn_unused_result__ \\\n   __attribute__ ((__warn_unused_result__))\n# if __USE_FORTIFY_LEVEL > 0\n#  define __wur __attribute_warn_unused_result__\n# endif\n#else\n# define __attribute_warn_unused_result__\t/* empty */\n#endif\n#ifndef __wur\n# define __wur\t\t\t/* Ignore */\n#endif\n\n/* Forces a function to be always inlined.  */\n#if __GNUC_PREREQ (3,2)\n/* The Linux kernel defines __always_inline in stddef.h (283d7573), and\n   it conflicts with this definition.  Therefore undefine it first to\n   allow either header to be included first.  */\n# undef __always_inline\n# define __always_inline __inline __attribute__ ((__always_inline__))\n#else\n# undef __always_inline\n# define __always_inline __inline\n#endif\n\n/* Associate error messages with the source location of the call site rather\n   than with the source location inside the function.  */\n#if __GNUC_PREREQ (4,3)\n# define __attribute_artificial__ __attribute__ ((__artificial__))\n#else\n# define __attribute_artificial__\t/* Ignore */\n#endif\n\n/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99\n   inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__\n   or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions\n   older than 4.3 may define these macros and still not guarantee GNU inlining\n   semantics.\n\n   clang++ identifies itself as gcc-4.2, but has support for GNU inlining\n   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and\n   __GNUC_GNU_INLINE__ macro definitions.  */\n#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \\\n     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \\\n\t\t\t       || defined __GNUC_GNU_INLINE__)))\n# if defined __GNUC_STDC_INLINE__ || defined __cplusplus\n#  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))\n#  define __extern_always_inline \\\n  extern __always_inline __attribute__ ((__gnu_inline__))\n# else\n#  define __extern_inline extern __inline\n#  define __extern_always_inline extern __always_inline\n# endif\n#endif\n\n#ifdef __extern_always_inline\n# define __fortify_function __extern_always_inline __attribute_artificial__\n#endif\n\n/* GCC 4.3 and above allow passing all anonymous arguments of an\n   __extern_always_inline function to some other vararg function.  */\n#if __GNUC_PREREQ (4,3)\n# define __va_arg_pack() __builtin_va_arg_pack ()\n# define __va_arg_pack_len() __builtin_va_arg_pack_len ()\n#endif\n\n/* It is possible to compile containing GCC extensions even if GCC is\n   run in pedantic mode if the uses are carefully marked using the\n   `__extension__' keyword.  But this is not generally available before\n   version 2.8.  */\n#if !__GNUC_PREREQ (2,8)\n# define __extension__\t\t/* Ignore */\n#endif\n\n/* __restrict is known in EGCS 1.2 and above. */\n#if !__GNUC_PREREQ (2,92)\n# define __restrict\t\t/* Ignore */\n#endif\n\n/* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is\n     array_name[restrict]\n   GCC 3.1 supports this.  */\n#if __GNUC_PREREQ (3,1) && !defined __GNUG__\n# define __restrict_arr\t__restrict\n#else\n# ifdef __GNUC__\n#  define __restrict_arr\t/* Not supported in old GCC.  */\n# else\n#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#   define __restrict_arr\trestrict\n#  else\n/* Some other non-C99 compiler.  */\n#   define __restrict_arr\t/* Not supported.  */\n#  endif\n# endif\n#endif\n\n#if __GNUC__ >= 3\n# define __glibc_unlikely(cond)\t__builtin_expect ((cond), 0)\n# define __glibc_likely(cond)\t__builtin_expect ((cond), 1)\n#else\n# define __glibc_unlikely(cond)\t(cond)\n# define __glibc_likely(cond)\t(cond)\n#endif\n\n#if (!defined _Noreturn \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     &&  !__GNUC_PREREQ (4,7))\n# if __GNUC_PREREQ (2,8)\n#  define _Noreturn __attribute__ ((__noreturn__))\n# else\n#  define _Noreturn\n# endif\n#endif\n\n#if __GNUC_PREREQ (8, 0)\n/* Describes a char array whose address can safely be passed as the first\n   argument to strncpy and strncat, as the char array is not necessarily\n   a NUL-terminated string.  */\n# define __attribute_nonstring__ __attribute__ ((__nonstring__))\n#else\n# define __attribute_nonstring__\n#endif\n\n#if (!defined _Static_assert && !defined __cplusplus \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))\n# define _Static_assert(expr, diagnostic) \\\n    extern int (*__Static_assert_function (void)) \\\n      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]\n#endif\n\n#include <bits/wordsize.h>\n#include <bits/long-double.h>\n\n#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH\n# define __LDBL_COMPAT 1\n# ifdef __REDIRECT\n#  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)\n#  define __LDBL_REDIR(name, proto) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##name)\n#  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)\n#  define __LDBL_REDIR_NTH(name, proto) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)\n#  define __LDBL_REDIR1_DECL(name, alias) \\\n  extern __typeof (name) name __asm (__ASMNAME (#alias));\n#  define __LDBL_REDIR_DECL(name) \\\n  extern __typeof (name) name __asm (__ASMNAME (\"__nldbl_\" #name));\n#  define __REDIRECT_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##alias)\n#  define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)\n# endif\n#endif\n#if !defined __LDBL_COMPAT || !defined __REDIRECT\n# define __LDBL_REDIR1(name, proto, alias) name proto\n# define __LDBL_REDIR(name, proto) name proto\n# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW\n# define __LDBL_REDIR_NTH(name, proto) name proto __THROW\n# define __LDBL_REDIR_DECL(name)\n# ifdef __REDIRECT\n#  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)\n#  define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __REDIRECT_NTH (name, proto, alias)\n# endif\n#endif\n\n/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE.  This is\n   intended for use in preprocessor macros.\n\n   Note: MESSAGE must be a _single_ string; concatenation of string\n   literals is not supported.  */\n#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)\n# define __glibc_macro_warning1(message) _Pragma (#message)\n# define __glibc_macro_warning(message) \\\n  __glibc_macro_warning1 (GCC warning message)\n#else\n# define __glibc_macro_warning(msg)\n#endif\n\n/* Generic selection (ISO C11) is a C-only feature, available in GCC\n   since version 4.9.  Previous versions do not provide generic\n   selection, even though they might set __STDC_VERSION__ to 201112L,\n   when in -std=c11 mode.  Thus, we must check for !defined __GNUC__\n   when testing __STDC_VERSION__ for generic selection support.\n   On the other hand, Clang also defines __GNUC__, so a clang-specific\n   check is required to enable the use of generic selection.  */\n#if !defined __cplusplus \\\n    && (__GNUC_PREREQ (4, 9) \\\n\t|| __glibc_clang_has_extension (c_generic_selections) \\\n\t|| (!defined __GNUC__ && defined __STDC_VERSION__ \\\n\t    && __STDC_VERSION__ >= 201112L))\n# define __HAVE_GENERIC_SELECTION 1\n#else\n# define __HAVE_GENERIC_SELECTION 0\n#endif\n\n#endif\t\t\t\t/* sys/cdefs.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/file.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_FILE_H\n#define\t_SYS_FILE_H\t1\n\n#include <features.h>\n\n#ifndef\t_FCNTL_H\n# include <fcntl.h>\n#endif\n\n__BEGIN_DECLS\n/* Alternate names for values for the WHENCE argument to `lseek'.\n   These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively.  */\n#ifndef L_SET\n# define L_SET\t0\t\t/* Seek from beginning of file.  */\n# define L_INCR\t1\t\t/* Seek from current position.  */\n# define L_XTND\t2\t\t/* Seek from end of file.  */\n#endif\n/* Operations for the `flock' call.  */\n#define\tLOCK_SH\t1\t\t/* Shared lock.  */\n#define\tLOCK_EX\t2\t\t/* Exclusive lock.  */\n#define\tLOCK_UN\t8\t\t/* Unlock.  */\n#define\t__LOCK_ATOMIC\t16\t/* Atomic update.  */\n/* Can be OR'd in to one of the above.  */\n#define\tLOCK_NB\t4\t\t/* Don't block when locking.  */\n/* Apply or remove an advisory lock, according to OPERATION,\n   on the file FD refers to.  */\nextern int flock(int __fd, int __operation) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/file.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/ioctl.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_IOCTL_H\n#define\t_SYS_IOCTL_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get the list of `ioctl' requests and related constants.  */\n#include <bits/ioctls.h>\n/* Define some types used by `ioctl' requests.  */\n#include <bits/ioctl-types.h>\n/* On a Unix system, the system <sys/ioctl.h> probably defines some of\n   the symbols we define in <sys/ttydefaults.h> (usually with the same\n   values).  The code to generate <bits/ioctls.h> has omitted these\n   symbols to avoid the conflict, but a Unix program expects <sys/ioctl.h>\n   to define them, so we must include <sys/ttydefaults.h> here.  */\n#include <sys/ttydefaults.h>\n/* Perform the I/O control operation specified by REQUEST on FD.\n   One argument may follow; its presence and type depend on REQUEST.\n   Return value depends on REQUEST.  Usually -1 indicates error.  */\nextern int ioctl(int __fd, unsigned long int __request, ...) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/ioctl.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/mman.h",
    "content": "/* Definitions for BSD-style memory management.\n   Copyright (C) 1994-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_MMAN_H\n#define\t_SYS_MMAN_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#include <bits/mman.h>\n\n/* Return value of `mmap' in case of an error.  */\n#define MAP_FAILED\t((void *) -1)\n\n__BEGIN_DECLS\n/* Map addresses starting near ADDR and extending for LEN bytes.  from\n   OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR\n   is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is\n   set in FLAGS, the mapping will be at ADDR exactly (which must be\n   page-aligned); otherwise the system chooses a convenient nearby address.\n   The return value is the actual mapping address chosen or MAP_FAILED\n   for errors (in which case `errno' is set).  A successful `mmap' call\n   deallocates any previous mapping for the affected region.  */\n#ifndef __USE_FILE_OFFSET64\nextern void *mmap(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern void *__REDIRECT_NTH(mmap, (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset), mmap64);\n# else\n#  define mmap mmap64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern void *mmap64(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) __THROW;\n#endif\n\n/* Deallocate any mapping for the region starting at ADDR and extending LEN\n   bytes.  Returns 0 if successful, -1 for errors (and sets errno).  */\nextern int munmap(void *__addr, size_t __len) __THROW;\n\n/* Change the memory protection of the region starting at ADDR and\n   extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors\n   (and sets errno).  */\nextern int mprotect(void *__addr, size_t __len, int __prot) __THROW;\n\n/* Synchronize the region starting at ADDR and extending LEN bytes with the\n   file it maps.  Filesystem operations on a file being mapped are\n   unpredictable before this is done.  Flags are from the MS_* set.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int msync(void *__addr, size_t __len, int __flags);\n\n#ifdef __USE_MISC\n/* Advise the system about particular usage patterns the program follows\n   for the region starting at ADDR and extending LEN bytes.  */\nextern int madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n#ifdef __USE_XOPEN2K\n/* This is the POSIX name for this function.  */\nextern int posix_madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n\n/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to\n   be memory resident.  */\nextern int mlock(const void *__addr, size_t __len) __THROW;\n\n/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN).  */\nextern int munlock(const void *__addr, size_t __len) __THROW;\n\n/* Cause all currently mapped pages of the process to be memory resident\n   until unlocked by a call to the `munlockall', until the process exits,\n   or until the process calls `execve'.  */\nextern int mlockall(int __flags) __THROW;\n\n/* All currently mapped pages of the process' address space become\n   unlocked.  */\nextern int munlockall(void) __THROW;\n\n#ifdef __USE_MISC\n/* mincore returns the memory residency status of the pages in the\n   current process's address space specified by [start, start + len).\n   The status is returned in a vector of bytes.  The least significant\n   bit of each byte is 1 if the referenced page is in memory, otherwise\n   it is zero.  */\nextern int mincore(void *__start, size_t __len, unsigned char *__vec) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length\n   NEW_LEN.  If MREMAP_MAYMOVE is set in FLAGS the returned address\n   may differ from ADDR.  If MREMAP_FIXED is set in FLAGS the function\n   takes another parameter which is a fixed address at which the block\n   resides after a successful call.  */\nextern void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...) __THROW;\n\n/* Remap arbitrary pages of a shared backing store within an existing\n   VMA.  */\nextern int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags) __THROW;\n#endif\n\n/* Open shared memory segment.  */\nextern int shm_open(const char *__name, int __oflag, mode_t __mode);\n\n/* Remove shared memory segment.  */\nextern int shm_unlink(const char *__name);\n\n__END_DECLS\n#endif\t\t\t\t/* sys/mman.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/param.h",
    "content": "/* Compatibility header for old-style Unix parameters and limits.\n   Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n#define _SYS_PARAM_H    1\n\n#define __need_NULL\n#include <stddef.h>\n\n#include <sys/types.h>\n#include <limits.h>\n#include <endian.h>\t\t/* Define BYTE_ORDER et al.  */\n#include <signal.h>\t\t/* Define NSIG.  */\n\n/* This file defines some things in system-specific ways.  */\n#include <bits/param.h>\n\n/* BSD names for some <limits.h> values.  */\n\n#define NBBY\t\tCHAR_BIT\n\n#if !defined NGROUPS && defined NGROUPS_MAX\n# define NGROUPS\tNGROUPS_MAX\n#endif\n#if !defined MAXSYMLINKS && defined SYMLOOP_MAX\n# define MAXSYMLINKS\tSYMLOOP_MAX\n#endif\n#if !defined CANBSIZ && defined MAX_CANON\n# define CANBSIZ\tMAX_CANON\n#endif\n#if !defined MAXPATHLEN && defined PATH_MAX\n# define MAXPATHLEN\tPATH_MAX\n#endif\n#if !defined NOFILE && defined OPEN_MAX\n# define NOFILE\t\tOPEN_MAX\n#endif\n#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX\n# define MAXHOSTNAMELEN\tHOST_NAME_MAX\n#endif\n#ifndef NCARGS\n# ifdef ARG_MAX\n#  define NCARGS\tARG_MAX\n# else\n/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to\n   compare against some fixed limit.  */\n# define NCARGS\t\tINT_MAX\n# endif\n#endif\n\n/* Magical constants.  */\n#ifndef NOGROUP\n# define NOGROUP\t65535\t/* Marker for empty group set member.  */\n#endif\n#ifndef NODEV\n# define NODEV\t\t((dev_t) -1)\t/* Non-existent device.  */\n#endif\n\n/* Unit of `st_blocks'.  */\n#ifndef DEV_BSIZE\n# define DEV_BSIZE\t512\n#endif\n\n/* Bit map related macros.  */\n#define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))\n#define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))\n#define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))\n#define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)\n\n/* Macros for counting and rounding.  */\n#ifndef howmany\n# define howmany(x, y)  (((x) + ((y) - 1)) / (y))\n#endif\n#ifdef __GNUC__\n# define roundup(x, y)  (__builtin_constant_p (y) && powerof2 (y)             \\\n                         ? (((x) + (y) - 1) & ~((y) - 1))                     \\\n                         : ((((x) + ((y) - 1)) / (y)) * (y)))\n#else\n# define roundup(x, y)  ((((x) + ((y) - 1)) / (y)) * (y))\n#endif\n#define powerof2(x)     ((((x) - 1) & (x)) == 0)\n\n/* Macros for min/max.  */\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#define MAX(a,b) (((a)>(b))?(a):(b))\n\n#endif\t\t\t\t/* sys/param.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/resource.h",
    "content": "/* Copyright (C) 1992-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_RESOURCE_H\n#define\t_SYS_RESOURCE_H\t1\n\n#include <features.h>\n\n/* Get the system-dependent definitions of structures and bit values.  */\n#include <bits/resource.h>\n\n#ifndef __id_t_defined\ntypedef __id_t id_t;\n# define __id_t_defined\n#endif\n\n__BEGIN_DECLS\n/* The X/Open standard defines that all the functions below must use\n   `int' as the type for the first argument.  When we are compiling with\n   GNU extensions we change this slightly to provide better error\n   checking.  */\n#if defined __USE_GNU && !defined __cplusplus\ntypedef enum __rlimit_resource __rlimit_resource_t;\ntypedef enum __rusage_who __rusage_who_t;\ntypedef enum __priority_which __priority_which_t;\n#else\ntypedef int __rlimit_resource_t;\ntypedef int __rusage_who_t;\ntypedef int __priority_which_t;\n#endif\n\n/* Put the soft and hard limits for RESOURCE in *RLIMITS.\n   Returns 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int getrlimit(__rlimit_resource_t __resource, struct rlimit *__rlimits) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(getrlimit, (__rlimit_resource_t __resource, struct rlimit * __rlimits), getrlimit64);\n# else\n#  define getrlimit getrlimit64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int getrlimit64(__rlimit_resource_t __resource, struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Set the soft and hard limits for RESOURCE to *RLIMITS.\n   Only the super-user can increase hard limits.\n   Return 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int setrlimit(__rlimit_resource_t __resource, const struct rlimit *__rlimits) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(setrlimit, (__rlimit_resource_t __resource, const struct rlimit * __rlimits), setrlimit64);\n# else\n#  define setrlimit setrlimit64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int setrlimit64(__rlimit_resource_t __resource, const struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Return resource usage information on process indicated by WHO\n   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */\nextern int getrusage(__rusage_who_t __who, struct rusage *__usage) __THROW;\n\n/* Return the highest priority of any process specified by WHICH and WHO\n   (see above); if WHO is zero, the current process, process group, or user\n   (as specified by WHO) is used.  A lower priority number means higher\n   priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */\nextern int getpriority(__priority_which_t __which, id_t __who) __THROW;\n\n/* Set the priority of all processes specified by WHICH and WHO (see above)\n   to PRIO.  Returns 0 on success, -1 on errors.  */\nextern int setpriority(__priority_which_t __which, id_t __who, int __prio) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/resource.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/select.h",
    "content": "/* `fd_set' type and related macros, and `select'/`pselect' declarations.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\tPOSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h>  */\n\n#ifndef _SYS_SELECT_H\n#define _SYS_SELECT_H\t1\n\n#include <features.h>\n\n/* Get definition of needed basic types.  */\n#include <bits/types.h>\n\n/* Get __FD_* definitions.  */\n#include <bits/select.h>\n\n/* Get sigset_t.  */\n#include <bits/types/sigset_t.h>\n\n/* Get definition of timer specification structures.  */\n#include <bits/types/time_t.h>\n#include <bits/types/struct_timeval.h>\n#ifdef __USE_XOPEN2K\n# include <bits/types/struct_timespec.h>\n#endif\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n# define __suseconds_t_defined\n#endif\n\n/* The fd_set member is required to be an array of longs.  */\ntypedef long int __fd_mask;\n\n/* Some versions of <linux/posix_types.h> define this macros.  */\n#undef\t__NFDBITS\n/* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */\n#define __NFDBITS\t(8 * (int) sizeof (__fd_mask))\n#define\t__FD_ELT(d)\t((d) / __NFDBITS)\n#define\t__FD_MASK(d)\t((__fd_mask) (1UL << ((d) % __NFDBITS)))\n\n/* fd_set for select and pselect.  */\ntypedef struct {\n\t/* XPG4.2 requires this member name.  Otherwise avoid the name\n\t   from the global namespace.  */\n#ifdef __USE_XOPEN\n\t__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];\n# define __FDS_BITS(set) ((set)->fds_bits)\n#else\n\t__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];\n# define __FDS_BITS(set) ((set)->__fds_bits)\n#endif\n} fd_set;\n\n/* Maximum number of file descriptors in `fd_set'.  */\n#define\tFD_SETSIZE\t\t__FD_SETSIZE\n\n#ifdef __USE_MISC\n/* Sometimes the fd_set member is assumed to have this type.  */\ntypedef __fd_mask fd_mask;\n\n/* Number of bits per word of `fd_set' (some code assumes this is 32).  */\n# define NFDBITS\t\t__NFDBITS\n#endif\n\n/* Access macros for `fd_set'.  */\n#define\tFD_SET(fd, fdsetp)\t__FD_SET (fd, fdsetp)\n#define\tFD_CLR(fd, fdsetp)\t__FD_CLR (fd, fdsetp)\n#define\tFD_ISSET(fd, fdsetp)\t__FD_ISSET (fd, fdsetp)\n#define\tFD_ZERO(fdsetp)\t\t__FD_ZERO (fdsetp)\n\n__BEGIN_DECLS\n/* Check the first NFDS descriptors each in READFDS (if not NULL) for read\n   readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS\n   (if not NULL) for exceptional conditions.  If TIMEOUT is not NULL, time out\n   after waiting the interval specified therein.  Returns the number of ready\n   descriptors, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int select(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, struct timeval *__restrict __timeout);\n\n#ifdef __USE_XOPEN2K\n/* Same as above only that the TIMEOUT value is given with higher\n   resolution and a sigmask which is been set temporarily.  This version\n   should be used.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pselect(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t * __restrict __sigmask);\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__\n# include <bits/select2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/select.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/socket.h",
    "content": "/* Declarations of socket constants, types, and functions.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_SOCKET_H\n#define\t_SYS_SOCKET_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types/struct_iovec.h>\n#define\t__need_size_t\n#include <stddef.h>\n/* This operating system-specific header file defines the SOCK_*, PF_*,\n   AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',\n   `struct msghdr', and `struct linger' types.  */\n#include <bits/socket.h>\n#ifdef __USE_MISC\n# include <bits/types/struct_osockaddr.h>\n#endif\n/* The following constants should be used for the second parameter of\n   `shutdown'.  */\n    enum {\n\tSHUT_RD = 0,\t\t/* No more receptions.  */\n#define SHUT_RD\t\tSHUT_RD\n\tSHUT_WR,\t\t/* No more transmissions.  */\n#define SHUT_WR\t\tSHUT_WR\n\tSHUT_RDWR\t\t/* No more receptions or transmissions.  */\n#define SHUT_RDWR\tSHUT_RDWR\n};\n\n/* This is the type we use for generic socket address arguments.\n\n   With GCC 2.7 and later, the funky union causes redeclarations or\n   uses with any of the listed types to be allowed without complaint.\n   G++ 2.7 does not support transparent unions so there we want the\n   old-style declaration, too.  */\n#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU\n# define __SOCKADDR_ARG\t\tstruct sockaddr *__restrict\n# define __CONST_SOCKADDR_ARG\tconst struct sockaddr *\n#else\n/* Add more `struct sockaddr_AF' types here as necessary.\n   These are all the ones I found on NetBSD and Linux.  */\n# define __SOCKADDR_ALLTYPES \\\n  __SOCKADDR_ONETYPE (sockaddr) \\\n  __SOCKADDR_ONETYPE (sockaddr_at) \\\n  __SOCKADDR_ONETYPE (sockaddr_ax25) \\\n  __SOCKADDR_ONETYPE (sockaddr_dl) \\\n  __SOCKADDR_ONETYPE (sockaddr_eon) \\\n  __SOCKADDR_ONETYPE (sockaddr_in) \\\n  __SOCKADDR_ONETYPE (sockaddr_in6) \\\n  __SOCKADDR_ONETYPE (sockaddr_inarp) \\\n  __SOCKADDR_ONETYPE (sockaddr_ipx) \\\n  __SOCKADDR_ONETYPE (sockaddr_iso) \\\n  __SOCKADDR_ONETYPE (sockaddr_ns) \\\n  __SOCKADDR_ONETYPE (sockaddr_un) \\\n  __SOCKADDR_ONETYPE (sockaddr_x25)\n\n# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __SOCKADDR_ARG __attribute__ ((__transparent_union__));\n# undef __SOCKADDR_ONETYPE\n# define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));\n# undef __SOCKADDR_ONETYPE\n#endif\n\n#ifdef __USE_GNU\n/* For `recvmmsg' and `sendmmsg'.  */\nstruct mmsghdr {\n\tstruct msghdr msg_hdr;\t/* Actual message header.  */\n\tunsigned int msg_len;\t/* Number of received or sent bytes for the\n\t\t\t\t   entry.  */\n};\n#endif\n\n/* Create a new socket of type TYPE in domain DOMAIN, using\n   protocol PROTOCOL.  If PROTOCOL is zero, one is chosen automatically.\n   Returns a file descriptor for the new socket, or -1 for errors.  */\nextern int socket(int __domain, int __type, int __protocol) __THROW;\n\n/* Create two new sockets, of type TYPE in domain DOMAIN and using\n   protocol PROTOCOL, which are connected to each other, and put file\n   descriptors for them in FDS[0] and FDS[1].  If PROTOCOL is zero,\n   one will be chosen automatically.  Returns 0 on success, -1 for errors.  */\nextern int socketpair(int __domain, int __type, int __protocol, int __fds[2]) __THROW;\n\n/* Give the socket FD the local address ADDR (which is LEN bytes long).  */\nextern int bind(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) __THROW;\n\n/* Put the local address of FD into *ADDR and its length in *LEN.  */\nextern int getsockname(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).\n   For connectionless socket types, just set the default address to send to\n   and the only address from which to accept transmissions.\n   Return 0 on success, -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int connect(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);\n\n/* Put the address of the peer connected to socket FD into *ADDR\n   (which is *LEN bytes long), and its actual length into *LEN.  */\nextern int getpeername(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Send N bytes of BUF to socket FD.  Returns the number sent or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t send(int __fd, const void *__buf, size_t __n, int __flags);\n\n/* Read N bytes into BUF from socket FD.\n   Returns the number read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recv(int __fd, void *__buf, size_t __n, int __flags);\n\n/* Send N bytes of BUF on socket FD to peer at address ADDR (which is\n   ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendto(int __fd, const void *__buf, size_t __n, int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);\n\n/* Read N bytes into BUF through socket FD.\n   If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of\n   the sender, and store the actual size of the address in *ADDR_LEN.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvfrom(int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n/* Send a message described MESSAGE on socket FD.\n   Returns the number of bytes sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendmsg(int __fd, const struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Send a VLEN messages as described by VMESSAGES to socket FD.\n   Returns the number of datagrams successfully written or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sendmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags);\n#endif\n\n/* Receive a message as described by MESSAGE from socket FD.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Receive up to VLEN messages as described by VMESSAGES from socket FD.\n   Returns the number of messages received or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int recvmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, struct timespec *__tmo);\n#endif\n\n/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL\n   into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's\n   actual length.  Returns 0 on success, -1 for errors.  */\nextern int getsockopt(int __fd, int __level, int __optname, void *__restrict __optval, socklen_t * __restrict __optlen) __THROW;\n\n/* Set socket FD's option OPTNAME at protocol level LEVEL\n   to *OPTVAL (which is OPTLEN bytes long).\n   Returns 0 on success, -1 for errors.  */\nextern int setsockopt(int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) __THROW;\n\n/* Prepare to accept connections on socket FD.\n   N connection requests will be queued before further requests are refused.\n   Returns 0 on success, -1 for errors.  */\nextern int listen(int __fd, int __n) __THROW;\n\n/* Await a connection on socket FD.\n   When a connection arrives, open a new socket to communicate with it,\n   set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting\n   peer and *ADDR_LEN to the address's actual length, and return the\n   new socket's descriptor, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n#ifdef __USE_GNU\n/* Similar to 'accept' but takes an additional parameter to specify flags.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept4(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len, int __flags);\n#endif\n\n/* Shut down all or part of the connection open on socket FD.\n   HOW determines what to shut down:\n     SHUT_RD   = No more receptions;\n     SHUT_WR   = No more transmissions;\n     SHUT_RDWR = No more receptions or transmissions.\n   Returns 0 on success, -1 for errors.  */\nextern int shutdown(int __fd, int __how) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Determine wheter socket is at a out-of-band mark.  */\nextern int sockatmark(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;\n   returns 1 if FD is open on an object of the indicated type, 0 if not,\n   or -1 for errors (setting errno).  */\nextern int isfdtype(int __fd, int __fdtype) __THROW;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/socket2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/stat.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6 File Characteristics\t<sys/stat.h>\n */\n\n#ifndef\t_SYS_STAT_H\n#define\t_SYS_STAT_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\t\t/* For __mode_t and __dev_t.  */\n\n#ifdef __USE_XOPEN2K8\n# include <bits/types/struct_timespec.h>\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n\n# include <bits/types/time_t.h>\n\n# ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n#  define __dev_t_defined\n# endif\n\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __ino_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#  else\ntypedef __ino64_t ino_t;\n#  endif\n#  define __ino_t_defined\n# endif\n\n# ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#  define __mode_t_defined\n# endif\n\n# ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n#  define __nlink_t_defined\n# endif\n\n# ifndef __off_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#  else\ntypedef __off64_t off_t;\n#  endif\n#  define __off_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\t\t\t\t/* X/Open */\n\n#ifdef __USE_UNIX98\n# ifndef __blkcnt_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __blkcnt_t blkcnt_t;\n#  else\ntypedef __blkcnt64_t blkcnt_t;\n#  endif\n#  define __blkcnt_t_defined\n# endif\n\n# ifndef __blksize_t_defined\ntypedef __blksize_t blksize_t;\n#  define __blksize_t_defined\n# endif\n#endif\t\t\t\t/* Unix98 */\n\n__BEGIN_DECLS\n#include <bits/stat.h>\n#if defined __USE_MISC || defined __USE_XOPEN\n# define S_IFMT\t\t__S_IFMT\n# define S_IFDIR\t__S_IFDIR\n# define S_IFCHR\t__S_IFCHR\n# define S_IFBLK\t__S_IFBLK\n# define S_IFREG\t__S_IFREG\n# ifdef __S_IFIFO\n#  define S_IFIFO\t__S_IFIFO\n# endif\n# ifdef __S_IFLNK\n#  define S_IFLNK\t__S_IFLNK\n# endif\n# if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \\\n     && defined __S_IFSOCK\n#  define S_IFSOCK\t__S_IFSOCK\n# endif\n#endif\n/* Test macros for file types.\t*/\n#define\t__S_ISTYPE(mode, mask)\t(((mode) & __S_IFMT) == (mask))\n#define\tS_ISDIR(mode)\t __S_ISTYPE((mode), __S_IFDIR)\n#define\tS_ISCHR(mode)\t __S_ISTYPE((mode), __S_IFCHR)\n#define\tS_ISBLK(mode)\t __S_ISTYPE((mode), __S_IFBLK)\n#define\tS_ISREG(mode)\t __S_ISTYPE((mode), __S_IFREG)\n#ifdef __S_IFIFO\n# define S_ISFIFO(mode)\t __S_ISTYPE((mode), __S_IFIFO)\n#endif\n#ifdef __S_IFLNK\n# define S_ISLNK(mode)\t __S_ISTYPE((mode), __S_IFLNK)\n#endif\n#if defined __USE_MISC && !defined __S_IFLNK\n# define S_ISLNK(mode)  0\n#endif\n#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K) \\\n    && defined __S_IFSOCK\n# define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)\n#elif defined __USE_XOPEN2K\n# define S_ISSOCK(mode) 0\n#endif\n/* These are from POSIX.1b.  If the objects are not implemented using separate\n   distinct file types, the macros always will evaluate to zero.  Unlike the\n   other S_* macros the following three take a pointer to a `struct stat'\n   object as the argument.  */\n#ifdef\t__USE_POSIX199309\n# define S_TYPEISMQ(buf) __S_TYPEISMQ(buf)\n# define S_TYPEISSEM(buf) __S_TYPEISSEM(buf)\n# define S_TYPEISSHM(buf) __S_TYPEISSHM(buf)\n#endif\n/* Protection bits.  */\n#define\tS_ISUID __S_ISUID\t/* Set user ID on execution.  */\n#define\tS_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n# define S_ISVTX\t__S_ISVTX\n#endif\n#define\tS_IRUSR\t__S_IREAD\t/* Read by owner.  */\n#define\tS_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n#define\tS_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n#define\tS_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n#ifdef __USE_MISC\n# define S_IREAD\tS_IRUSR\n# define S_IWRITE\tS_IWUSR\n# define S_IEXEC\tS_IXUSR\n#endif\n#define\tS_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n#define\tS_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n#define\tS_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n#define\tS_IRWXG\t(S_IRWXU >> 3)\n#define\tS_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n#define\tS_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n#define\tS_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n#define\tS_IRWXO\t(S_IRWXG >> 3)\n#ifdef\t__USE_MISC\n/* Macros for common mode bit masks.  */\n# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)\t/* 0777 */\n# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\t/* 07777 */\n# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)\t/* 0666 */\n# define S_BLKSIZE\t512\t/* Block size for `st_blocks'.  */\n#endif\n#ifndef __USE_FILE_OFFSET64\n/* Get file attributes for FILE and put them in BUF.  */\nextern int stat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n\n/* Get file attributes for the file, device, pipe, or socket\n   that file descriptor FD is open on and put them in BUF.  */\nextern int fstat(int __fd, struct stat *__buf)\n__THROW __nonnull((2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(stat, (const char *__restrict __file, struct stat * __restrict __buf), stat64) __nonnull((1, 2));\nextern int __REDIRECT_NTH(fstat, (int __fd, struct stat * __buf), fstat64) __nonnull((2));\n# else\n#  define stat stat64\n#  define fstat fstat64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int stat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\nextern int fstat64(int __fd, struct stat64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to stat, get the attributes for FILE and put them in BUF.\n   Relative path names are interpreted relative to FD unless FD is\n   AT_FDCWD.  */\n# ifndef __USE_FILE_OFFSET64\nextern int fstatat(int __fd, const char *__restrict __file, struct stat *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatat, (int __fd, const char *__restrict __file, struct stat * __restrict __buf, int __flag), fstatat64) __nonnull((2, 3));\n#  else\n#   define fstatat fstatat64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int fstatat64(int __fd, const char *__restrict __file, struct stat64 *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n# endif\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n# ifndef __USE_FILE_OFFSET64\n/* Get file attributes about FILE and put them in BUF.\n   If FILE is a symbolic link, do not follow it.  */\nextern int lstat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(lstat, (const char *__restrict __file, struct stat * __restrict __buf), lstat64) __nonnull((1, 2));\n#  else\n#   define lstat lstat64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lstat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\n# endif\n#endif\n\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects its target instead.  */\nextern int chmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects the link itself\n   rather than its target.  */\nextern int lchmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n#endif\n\n/* Set file access permissions of the file FD is open on to MODE.  */\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\nextern int fchmod(int __fd, __mode_t __mode) __THROW;\n#endif\n\n#ifdef __USE_ATFILE\n/* Set file access permissions of FILE relative to\n   the directory FD is open on.  */\nextern int fchmodat(int __fd, const char *__file, __mode_t __mode, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use ATFILE.  */\n\n/* Set the file creation mask of the current process to MASK,\n   and return the old creation mask.  */\nextern __mode_t umask(__mode_t __mask) __THROW;\n\n#ifdef\t__USE_GNU\n/* Get the current `umask' value without changing it.\n   This function is only available under the GNU Hurd.  */\nextern __mode_t getumask(void) __THROW;\n#endif\n\n/* Create a new directory named PATH, with permission bits MODE.  */\nextern int mkdir(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkdir, create a new directory with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkdirat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\n/* Create a device file named PATH, with permission and special bits MODE\n   and device number DEV (which can be constructed from major and minor\n   device numbers with the `makedev' macro above).  */\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\nextern int mknod(const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((1));\n\n# ifdef __USE_ATFILE\n/* Like mknod, create a new device file with permission bits MODE and\n   device number DEV.  But interpret relative PATH names relative to\n   the directory associated with FD.  */\nextern int mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((2));\n# endif\n#endif\n\n/* Create a new FIFO named PATH, with permission bits MODE.  */\nextern int mkfifo(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkfifo, create a new FIFO with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkfifoat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\f\n#ifdef __USE_ATFILE\n/* Set file access and modification times relative to directory file\n   descriptor.  */\nextern int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flags)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Set file access and modification times of the file associated with FD.  */\nextern int futimens(int __fd, const struct timespec __times[2]) __THROW;\n#endif\n\f\n/* To allow the `struct stat' structure and the file type `mode_t'\n   bits to vary without changing shared library major version number,\n   the `stat' family of functions and `mknod' are in fact inline\n   wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',\n   which all take a leading version-number argument designating the\n   data structure and bits used.  <bits/stat.h> defines _STAT_VER with\n   the version number corresponding to `struct stat' as defined in\n   that file; and _MKNOD_VER with the version number corresponding to\n   the S_IF* macros defined therein.  It is arranged that when not\n   inlined these function are always statically linked; that way a\n   dynamically-linked executable always encodes the version number\n   corresponding to the data structures it uses, so the `x' functions\n   in the shared library can adapt without needing to recompile all\n   callers.  */\n\n#ifndef _STAT_VER\n# define _STAT_VER\t0\n#endif\n#ifndef _MKNOD_VER\n# define _MKNOD_VER\t0\n#endif\n\n/* Wrappers for stat and mknod system calls.  */\n#ifndef __USE_FILE_OFFSET64\nextern int __fxstat(int __ver, int __fildes, struct stat *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat(int __ver, int __fildes, const char *__filename, struct stat *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(__fxstat, (int __ver, int __fildes, struct stat * __stat_buf), __fxstat64) __nonnull((3));\nextern int __REDIRECT_NTH(__xstat, (int __ver, const char *__filename, struct stat * __stat_buf), __xstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__lxstat, (int __ver, const char *__filename, struct stat * __stat_buf), __lxstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__fxstatat, (int __ver, int __fildes, const char *__filename, struct stat * __stat_buf, int __flag), __fxstatat64) __nonnull((3, 4));\n\n# else\n#  define __fxstat __fxstat64\n#  define __xstat __xstat64\n#  define __lxstat __lxstat64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int __fxstat64(int __ver, int __fildes, struct stat64 *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat64(int __ver, int __fildes, const char *__filename, struct stat64 *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#endif\nextern int __xmknod(int __ver, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((2, 4));\n\nextern int __xmknodat(int __ver, int __fd, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((3, 5));\n\n#ifdef __USE_EXTERN_INLINES\n/* Inlined versions of the real stat and mknod functions.  */\n\n__extern_inline int __NTH(stat(const char *__path, struct stat *__statbuf))\n{\n\treturn __xstat(_STAT_VER, __path, __statbuf);\n}\n\n# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat(const char *__path, struct stat *__statbuf))\n{\n\treturn __lxstat(_STAT_VER, __path, __statbuf);\n}\n# endif\n\n__extern_inline int __NTH(fstat(int __fd, struct stat *__statbuf))\n{\n\treturn __fxstat(_STAT_VER, __fd, __statbuf);\n}\n\n# ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat(int __fd, const char *__filename, struct stat *__statbuf, int __flag))\n{\n\treturn __fxstatat(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n# endif\n\n# ifdef __USE_MISC\n__extern_inline int __NTH(mknod(const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknod(_MKNOD_VER, __path, __mode, &__dev);\n}\n# endif\n\n# ifdef __USE_ATFILE\n__extern_inline int __NTH(mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknodat(_MKNOD_VER, __fd, __path, __mode, &__dev);\n}\n# endif\n\n# if defined __USE_LARGEFILE64 \\\n  && (! defined __USE_FILE_OFFSET64 \\\n      || (defined __REDIRECT_NTH && defined __OPTIMIZE__))\n__extern_inline int __NTH(stat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __xstat64(_STAT_VER, __path, __statbuf);\n}\n\n#  if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __lxstat64(_STAT_VER, __path, __statbuf);\n}\n#  endif\n\n__extern_inline int __NTH(fstat64(int __fd, struct stat64 *__statbuf))\n{\n\treturn __fxstat64(_STAT_VER, __fd, __statbuf);\n}\n\n#  ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat64(int __fd, const char *__filename, struct stat64 *__statbuf, int __flag))\n{\n\treturn __fxstatat64(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n#  endif\n\n# endif\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/stat.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/statfs.h",
    "content": "/* Definitions for getting information about a filesystem.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_STATFS_H\n#define\t_SYS_STATFS_H\t1\n\n#include <features.h>\n\n/* Get the system-specific definition of `struct statfs'.  */\n#include <bits/statfs.h>\n\n__BEGIN_DECLS\n/* Return information about the filesystem on which FILE resides.  */\n#ifndef __USE_FILE_OFFSET64\nextern int statfs(const char *__file, struct statfs *__buf)\n__THROW __nonnull((1, 2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(statfs, (const char *__file, struct statfs * __buf), statfs64) __nonnull((1, 2));\n# else\n#  define statfs statfs64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int statfs64(const char *__file, struct statfs64 *__buf)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Return information about the filesystem containing the file FILDES\n   refers to.  */\n#ifndef __USE_FILE_OFFSET64\nextern int fstatfs(int __fildes, struct statfs *__buf)\n__THROW __nonnull((2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatfs, (int __fildes, struct statfs * __buf), fstatfs64) __nonnull((2));\n# else\n#  define fstatfs fstatfs64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int fstatfs64(int __fildes, struct statfs64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/statfs.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/sysmacros.h",
    "content": "/* Definitions of macros to access `dev_t' values.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SYSMACROS_H_OUTER\n\n#ifndef __SYSMACROS_DEPRECATED_INCLUSION\n# define _SYS_SYSMACROS_H_OUTER 1\n#endif\n\n/* If <sys/sysmacros.h> is included after <sys/types.h>, these macros\n   will already be defined, and we need to redefine them without the\n   deprecation warnings.  (If they are included in the opposite order,\n   the outer #ifndef will suppress this entire file and the macros\n   will be usable without warnings.)  */\n#undef major\n#undef minor\n#undef makedev\n\n/* This is the macro that must be defined to satisfy the misuse check\n   in bits/sysmacros.h. */\n#ifndef _SYS_SYSMACROS_H\n#define _SYS_SYSMACROS_H 1\n\n#include <features.h>\n#include <bits/types.h>\n#include <bits/sysmacros.h>\n\n/* Caution: The text of this deprecation message is unquoted, so that\n   #symbol can be substituted.  (It is converted to a string by\n   __SYSMACROS_DM1.)  This means the message must be a sequence of\n   complete pp-tokens; in particular, English contractions (it's,\n   can't) cannot be used.\n\n   The message has been manually word-wrapped to fit in 80 columns\n   when output by GCC 5 and 6.  The first line is shorter to leave\n   some room for the \"foo.c:23: warning:\" annotation.  */\n#define __SYSMACROS_DM(symbol) __SYSMACROS_DM1 \\\n (In the GNU C Library, #symbol is defined\\n\\\n  by <sys/sysmacros.h>. For historical compatibility, it is\\n\\\n  currently defined by <sys/types.h> as well, but we plan to\\n\\\n  remove this soon.  To use #symbol, include <sys/sysmacros.h>\\n\\\n  directly.  If you did not intend to use a system-defined macro\\n\\\n  #symbol, you should undefine it after including <sys/types.h>.)\n\n/* This macro is variadic because the deprecation message above\n   contains commas.  */\n#define __SYSMACROS_DM1(...) __glibc_macro_warning (#__VA_ARGS__)\n\n#define __SYSMACROS_DECL_TEMPL(rtype, name, proto)\t\t\t     \\\n  extern rtype gnu_dev_##name proto __THROW __attribute_const__;\n\n#define __SYSMACROS_IMPL_TEMPL(rtype, name, proto)\t\t\t     \\\n  __extension__ __extern_inline __attribute_const__ rtype\t\t     \\\n  __NTH (gnu_dev_##name proto)\n\n__BEGIN_DECLS __SYSMACROS_DECLARE_MAJOR(__SYSMACROS_DECL_TEMPL) __SYSMACROS_DECLARE_MINOR(__SYSMACROS_DECL_TEMPL) __SYSMACROS_DECLARE_MAKEDEV(__SYSMACROS_DECL_TEMPL)\n#ifdef __USE_EXTERN_INLINES\n__SYSMACROS_DEFINE_MAJOR(__SYSMACROS_IMPL_TEMPL) __SYSMACROS_DEFINE_MINOR(__SYSMACROS_IMPL_TEMPL) __SYSMACROS_DEFINE_MAKEDEV(__SYSMACROS_IMPL_TEMPL)\n#endif\n    __END_DECLS\n#endif\t\t\t\t/* _SYS_SYSMACROS_H */\n#ifndef __SYSMACROS_NEED_IMPLEMENTATION\n# undef __SYSMACROS_DECL_TEMPL\n# undef __SYSMACROS_IMPL_TEMPL\n# undef __SYSMACROS_DECLARE_MAJOR\n# undef __SYSMACROS_DECLARE_MINOR\n# undef __SYSMACROS_DECLARE_MAKEDEV\n# undef __SYSMACROS_DEFINE_MAJOR\n# undef __SYSMACROS_DEFINE_MINOR\n# undef __SYSMACROS_DEFINE_MAKEDEV\n#endif\n#ifdef __SYSMACROS_DEPRECATED_INCLUSION\n# define major(dev) __SYSMACROS_DM (major) gnu_dev_major (dev)\n# define minor(dev) __SYSMACROS_DM (minor) gnu_dev_minor (dev)\n# define makedev(maj, min) __SYSMACROS_DM (makedev) gnu_dev_makedev (maj, min)\n#else\n# define major(dev) gnu_dev_major (dev)\n# define minor(dev) gnu_dev_minor (dev)\n# define makedev(maj, min) gnu_dev_makedev (maj, min)\n#endif\n#endif\t\t\t\t/* sys/sysmacros.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/time.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_TIME_H\n#define _SYS_TIME_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\n#include <bits/types/time_t.h>\n#include <bits/types/struct_timeval.h>\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n# define __suseconds_t_defined\n#endif\n\n#include <sys/select.h>\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Macros for converting between `struct timeval' and `struct timespec'.  */\n# define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \\\n\t(ts)->tv_sec = (tv)->tv_sec;                                    \\\n\t(ts)->tv_nsec = (tv)->tv_usec * 1000;                           \\\n}\n# define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \\\n\t(tv)->tv_sec = (ts)->tv_sec;                                    \\\n\t(tv)->tv_usec = (ts)->tv_nsec / 1000;                           \\\n}\n#endif\n#ifdef __USE_MISC\n/* Structure crudely representing a timezone.\n   This is obsolete and should never be used.  */\n    struct timezone {\n\tint tz_minuteswest;\t/* Minutes west of GMT.  */\n\tint tz_dsttime;\t\t/* Nonzero if DST is ever in effect.  */\n};\n\ntypedef struct timezone *__restrict __timezone_ptr_t;\n#else\ntypedef void *__restrict __timezone_ptr_t;\n#endif\n\n/* Get the current time of day and timezone information,\n   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.\n   Returns 0 on success, -1 on errors.\n   NOTE: This form of timezone information is obsolete.\n   Use the functions and variables declared in <time.h> instead.  */\nextern int gettimeofday(struct timeval *__restrict __tv, __timezone_ptr_t __tz)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set the current time of day and timezone information.\n   This call is restricted to the super-user.  */\nextern int settimeofday(const struct timeval *__tv, const struct timezone *__tz) __THROW;\n\n/* Adjust the current time of day by the amount in DELTA.\n   If OLDDELTA is not NULL, it is filled in with the amount\n   of time adjustment remaining to be done from the last `adjtime' call.\n   This call is restricted to the super-user.  */\nextern int adjtime(const struct timeval *__delta, struct timeval *__olddelta) __THROW;\n#endif\n\n/* Values for the first argument to `getitimer' and `setitimer'.  */\nenum __itimer_which {\n\t/* Timers run in real time.  */\n\tITIMER_REAL = 0,\n#define ITIMER_REAL ITIMER_REAL\n\t/* Timers run only when the process is executing.  */\n\tITIMER_VIRTUAL = 1,\n#define ITIMER_VIRTUAL ITIMER_VIRTUAL\n\t/* Timers run when the process is executing and when\n\t   the system is executing on behalf of the process.  */\n\tITIMER_PROF = 2\n#define ITIMER_PROF ITIMER_PROF\n};\n\n/* Type of the second argument to `getitimer' and\n   the second and third arguments `setitimer'.  */\nstruct itimerval {\n\t/* Value to put into `it_value' when the timer expires.  */\n\tstruct timeval it_interval;\n\t/* Time to the next timer expiration.  */\n\tstruct timeval it_value;\n};\n\n#if defined __USE_GNU && !defined __cplusplus\n/* Use the nicer parameter type only in GNU mode and not for C++ since the\n   strict C++ rules prevent the automatic promotion.  */\ntypedef enum __itimer_which __itimer_which_t;\n#else\ntypedef int __itimer_which_t;\n#endif\n\n/* Set *VALUE to the current setting of timer WHICH.\n   Return 0 on success, -1 on errors.  */\nextern int getitimer(__itimer_which_t __which, struct itimerval *__value) __THROW;\n\n/* Set the timer WHICH to *NEW.  If OLD is not NULL,\n   set *OLD to the old value of timer WHICH.\n   Returns 0 on success, -1 on errors.  */\nextern int setitimer(__itimer_which_t __which, const struct itimerval *__restrict __new, struct itimerval *__restrict __old) __THROW;\n\n/* Change the access time of FILE to TVP[0] and the modification time of\n   FILE to TVP[1].  If TVP is a null pointer, use the current time instead.\n   Returns 0 on success, -1 on errors.  */\nextern int utimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Same as `utimes', but does not follow symbolic links.  */\nextern int lutimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n/* Same as `utimes', but takes an open file descriptor instead of a name.  */\nextern int futimes(int __fd, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Change the access time of FILE relative to FD to TVP[0] and the\n   modification time of FILE to TVP[1].  If TVP is a null pointer, use\n   the current time instead.  Returns 0 on success, -1 on errors.  */\nextern int futimesat(int __fd, const char *__file, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Convenience macros for operations on timevals.\n   NOTE: `timercmp' does not work for >= or <=.  */\n# define timerisset(tvp)\t((tvp)->tv_sec || (tvp)->tv_usec)\n# define timerclear(tvp)\t((tvp)->tv_sec = (tvp)->tv_usec = 0)\n# define timercmp(a, b, CMP) \t\t\t\t\t\t      \\\n  (((a)->tv_sec == (b)->tv_sec) ? \t\t\t\t\t      \\\n   ((a)->tv_usec CMP (b)->tv_usec) : \t\t\t\t\t      \\\n   ((a)->tv_sec CMP (b)->tv_sec))\n# define timeradd(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec >= 1000000)\t\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t++(result)->tv_sec;\t\t\t\t\t\t      \\\n\t(result)->tv_usec -= 1000000;\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n# define timersub(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec < 0) {\t\t\t\t\t      \\\n      --(result)->tv_sec;\t\t\t\t\t\t      \\\n      (result)->tv_usec += 1000000;\t\t\t\t\t      \\\n    }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n#endif\t\t\t\t/* Misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/time.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/ttydefaults.h",
    "content": "/*-\n * Copyright (c) 1982, 1986, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n * (c) UNIX System Laboratories, Inc.\n * All or some portions of this file are derived from material licensed\n * to the University of California by American Telephone and Telegraph\n * Co. or Unix System Laboratories, Inc. and are reproduced herein with\n * the permission of UNIX System Laboratories, Inc.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)ttydefaults.h\t8.4 (Berkeley) 1/21/94\n */\n\n/*\n * System wide defaults for terminal state.  Linux version.\n */\n#ifndef _SYS_TTYDEFAULTS_H_\n#define\t_SYS_TTYDEFAULTS_H_\n\n/*\n * Defaults on \"first\" open.\n */\n#define\tTTYDEF_IFLAG\t(BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)\n#define TTYDEF_OFLAG\t(OPOST | ONLCR | XTABS)\n#define TTYDEF_LFLAG\t(ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)\n#define TTYDEF_CFLAG\t(CREAD | CS7 | PARENB | HUPCL)\n#define TTYDEF_SPEED\t(B9600)\n\n/*\n * Control Character Defaults\n */\n#define CTRL(x)\t(x&037)\n#define\tCEOF\t\tCTRL('d')\n#ifdef _POSIX_VDISABLE\n# define CEOL\t\t_POSIX_VDISABLE\n#else\n# define CEOL\t\t'\\0'\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCERASE\t\t0177\n#define\tCINTR\t\tCTRL('c')\n#ifdef _POSIX_VDISABLE\n# define CSTATUS\t_POSIX_VDISABLE\n#else\n# define CSTATUS\t'\\0'\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCKILL\t\tCTRL('u')\n#define\tCMIN\t\t1\n#define\tCQUIT\t\t034\t/* FS, ^\\ */\n#define\tCSUSP\t\tCTRL('z')\n#define\tCTIME\t\t0\n#define\tCDSUSP\t\tCTRL('y')\n#define\tCSTART\t\tCTRL('q')\n#define\tCSTOP\t\tCTRL('s')\n#define\tCLNEXT\t\tCTRL('v')\n#define\tCDISCARD \tCTRL('o')\n#define\tCWERASE \tCTRL('w')\n#define\tCREPRINT \tCTRL('r')\n#define\tCEOT\t\tCEOF\n/* compat */\n#define\tCBRK\t\tCEOL\n#define CRPRNT\t\tCREPRINT\n#define\tCFLUSH\t\tCDISCARD\n\n/* PROTECTED INCLUSION ENDS HERE */\n#endif\t\t\t\t/* !_SYS_TTYDEFAULTS_H_ */\n\n/*\n * #define TTYDEFCHARS to include an array of default control characters.\n */\n#ifdef TTYDEFCHARS\ncc_t ttydefchars[NCCS] = {\n\tCEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,\n\t_POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,\n\tCDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE\n};\n\n#undef TTYDEFCHARS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/types.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.6 Primitive System Data Types\t<sys/types.h>\n */\n\n#ifndef\t_SYS_TYPES_H\n#define\t_SYS_TYPES_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef\t__USE_MISC\n# ifndef __u_char_defined\ntypedef __u_char u_char;\ntypedef __u_short u_short;\ntypedef __u_int u_int;\ntypedef __u_long u_long;\ntypedef __quad_t quad_t;\ntypedef __u_quad_t u_quad_t;\ntypedef __fsid_t fsid_t;\n#  define __u_char_defined\n# endif\n#endif\n\ntypedef __loff_t loff_t;\n\n#ifndef __ino_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n# else\ntypedef __ino64_t ino_t;\n# endif\n# define __ino_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n# define __ino64_t_defined\n#endif\n\n#ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n# define __dev_t_defined\n#endif\n\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n# define __gid_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n# define __nlink_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n# define __uid_t_defined\n#endif\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \\\n    && !defined __id_t_defined\ntypedef __id_t id_t;\n# define __id_t_defined\n#endif\n\n#ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n#endif\n\n#ifdef\t__USE_MISC\n# ifndef __daddr_t_defined\ntypedef __daddr_t daddr_t;\ntypedef __caddr_t caddr_t;\n#  define __daddr_t_defined\n# endif\n#endif\n\n#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined\ntypedef __key_t key_t;\n# define __key_t_defined\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# include <bits/types/clock_t.h>\n#endif\n#include <bits/types/clockid_t.h>\n#include <bits/types/time_t.h>\n#include <bits/types/timer_t.h>\n\n#ifdef __USE_XOPEN\n# ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#  define __useconds_t_defined\n# endif\n# ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n#  define __suseconds_t_defined\n# endif\n#endif\n\n#define\t__need_size_t\n#include <stddef.h>\n\n#ifdef __USE_MISC\n/* Old compatibility names for C types.  */\ntypedef unsigned long int ulong;\ntypedef unsigned short int ushort;\ntypedef unsigned int uint;\n#endif\n\n/* These size-specific names are used by some of the inet code.  */\n\n#include <bits/stdint-intn.h>\n\n#if !__GNUC_PREREQ (2, 7)\n\n/* These were defined by ISO C without the first `_'.  */\ntypedef unsigned char u_int8_t;\ntypedef unsigned short int u_int16_t;\ntypedef unsigned int u_int32_t;\n# if __WORDSIZE == 64\ntypedef unsigned long int u_int64_t;\n# else\n__extension__ typedef unsigned long long int u_int64_t;\n# endif\n\ntypedef int register_t;\n\n#else\n\n/* For GCC 2.7 and later, we can use specific type-size attributes.  */\n# define __u_intN_t(N, MODE) \\\n  typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))\n\n__u_intN_t(8, __QI__);\n__u_intN_t(16, __HI__);\n__u_intN_t(32, __SI__);\n__u_intN_t(64, __DI__);\n\ntypedef int register_t __attribute__ ((__mode__(__word__)));\n\n/* Some code from BIND tests this macro to see if the types above are\n   defined.  */\n#endif\n#define __BIT_TYPES_DEFINED__\t1\n\n#ifdef\t__USE_MISC\n/* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */\n# include <endian.h>\n\n/* It also defines `fd_set' and the FD_* macros for `select'.  */\n# include <sys/select.h>\n\n/* BSD defines `major', `minor', and `makedev' in this header.\n   However, these symbols are likely to collide with user code, so we are\n   going to stop defining them here in an upcoming release.  Code that needs\n   these macros should include <sys/sysmacros.h> directly.  Code that does\n   not need these macros should #undef them after including this header.  */\n# define __SYSMACROS_DEPRECATED_INCLUSION\n# include <sys/sysmacros.h>\n# undef __SYSMACROS_DEPRECATED_INCLUSION\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \\\n    && !defined __blksize_t_defined\ntypedef __blksize_t blksize_t;\n# define __blksize_t_defined\n#endif\n\n/* Types from the Large File Support interface.  */\n#ifndef __USE_FILE_OFFSET64\n# ifndef __blkcnt_t_defined\ntypedef __blkcnt_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#  define __blkcnt_t_defined\n# endif\n# ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#  define __fsblkcnt_t_defined\n# endif\n# ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#  define __fsfilcnt_t_defined\n# endif\n#else\n# ifndef __blkcnt_t_defined\ntypedef __blkcnt64_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#  define __blkcnt_t_defined\n# endif\n# ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt64_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#  define __fsblkcnt_t_defined\n# endif\n# ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt64_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#  define __fsfilcnt_t_defined\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\ntypedef __blkcnt64_t blkcnt64_t;\t/* Type to count number of disk blocks. */\ntypedef __fsblkcnt64_t fsblkcnt64_t;\t/* Type to count file system blocks.  */\ntypedef __fsfilcnt64_t fsfilcnt64_t;\t/* Type to count file system inodes.  */\n#endif\n\n/* Now add the thread types.  */\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n# include <bits/pthreadtypes.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/types.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/ucontext.h",
    "content": "/* Copyright (C) 2001-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UCONTEXT_H\n#define _SYS_UCONTEXT_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\n#include <bits/types/sigset_t.h>\n#include <bits/types/stack_t.h>\n\n#ifdef __USE_MISC\n# define __ctx(fld) fld\n#else\n# define __ctx(fld) __ ## fld\n#endif\n\n#ifdef __x86_64__\n\n/* Type for general register.  */\n__extension__ typedef long long int greg_t;\n\n/* Number of general registers.  */\n#define __NGREG\t23\n#ifdef __USE_MISC\n# define NGREG\t__NGREG\n#endif\n\n/* Container for all general registers.  */\ntypedef greg_t gregset_t[__NGREG];\n\n#ifdef __USE_GNU\n/* Number of each register in the `gregset_t' array.  */\nenum {\n\tREG_R8 = 0,\n# define REG_R8\t\tREG_R8\n\tREG_R9,\n# define REG_R9\t\tREG_R9\n\tREG_R10,\n# define REG_R10\tREG_R10\n\tREG_R11,\n# define REG_R11\tREG_R11\n\tREG_R12,\n# define REG_R12\tREG_R12\n\tREG_R13,\n# define REG_R13\tREG_R13\n\tREG_R14,\n# define REG_R14\tREG_R14\n\tREG_R15,\n# define REG_R15\tREG_R15\n\tREG_RDI,\n# define REG_RDI\tREG_RDI\n\tREG_RSI,\n# define REG_RSI\tREG_RSI\n\tREG_RBP,\n# define REG_RBP\tREG_RBP\n\tREG_RBX,\n# define REG_RBX\tREG_RBX\n\tREG_RDX,\n# define REG_RDX\tREG_RDX\n\tREG_RAX,\n# define REG_RAX\tREG_RAX\n\tREG_RCX,\n# define REG_RCX\tREG_RCX\n\tREG_RSP,\n# define REG_RSP\tREG_RSP\n\tREG_RIP,\n# define REG_RIP\tREG_RIP\n\tREG_EFL,\n# define REG_EFL\tREG_EFL\n\tREG_CSGSFS,\t\t/* Actually short cs, gs, fs, __pad0.  */\n# define REG_CSGSFS\tREG_CSGSFS\n\tREG_ERR,\n# define REG_ERR\tREG_ERR\n\tREG_TRAPNO,\n# define REG_TRAPNO\tREG_TRAPNO\n\tREG_OLDMASK,\n# define REG_OLDMASK\tREG_OLDMASK\n\tREG_CR2\n# define REG_CR2\tREG_CR2\n};\n#endif\n\nstruct _libc_fpxreg {\n\tunsigned short int __ctx(significand)[4];\n\tunsigned short int __ctx(exponent);\n\tunsigned short int __glibc_reserved1[3];\n};\n\nstruct _libc_xmmreg {\n\t__uint32_t __ctx(element)[4];\n};\n\nstruct _libc_fpstate {\n\t/* 64-bit FXSAVE format.  */\n\t__uint16_t __ctx(cwd);\n\t__uint16_t __ctx(swd);\n\t__uint16_t __ctx(ftw);\n\t__uint16_t __ctx(fop);\n\t__uint64_t __ctx(rip);\n\t__uint64_t __ctx(rdp);\n\t__uint32_t __ctx(mxcsr);\n\t__uint32_t __ctx(mxcr_mask);\n\tstruct _libc_fpxreg _st[8];\n\tstruct _libc_xmmreg _xmm[16];\n\t__uint32_t __glibc_reserved1[24];\n};\n\n/* Structure to describe FPU registers.  */\ntypedef struct _libc_fpstate *fpregset_t;\n\n/* Context to describe whole processor state.  */\ntypedef struct {\n\tgregset_t __ctx(gregs);\n\t/* Note that fpregs is a pointer.  */\n\tfpregset_t __ctx(fpregs);\n\t__extension__ unsigned long long __reserved1[8];\n} mcontext_t;\n\n/* Userlevel context.  */\ntypedef struct ucontext_t {\n\tunsigned long int __ctx(uc_flags);\n\tstruct ucontext_t *uc_link;\n\tstack_t uc_stack;\n\tmcontext_t uc_mcontext;\n\tsigset_t uc_sigmask;\n\tstruct _libc_fpstate __fpregs_mem;\n} ucontext_t;\n\n#else\t\t\t\t/* !__x86_64__ */\n\n/* Type for general register.  */\ntypedef int greg_t;\n\n/* Number of general registers.  */\n#define __NGREG\t19\n#ifdef __USE_MISC\n# define NGREG\t__NGREG\n#endif\n\n/* Container for all general registers.  */\ntypedef greg_t gregset_t[__NGREG];\n\n#ifdef __USE_GNU\n/* Number of each register is the `gregset_t' array.  */\nenum {\n\tREG_GS = 0,\n# define REG_GS\t\tREG_GS\n\tREG_FS,\n# define REG_FS\t\tREG_FS\n\tREG_ES,\n# define REG_ES\t\tREG_ES\n\tREG_DS,\n# define REG_DS\t\tREG_DS\n\tREG_EDI,\n# define REG_EDI\tREG_EDI\n\tREG_ESI,\n# define REG_ESI\tREG_ESI\n\tREG_EBP,\n# define REG_EBP\tREG_EBP\n\tREG_ESP,\n# define REG_ESP\tREG_ESP\n\tREG_EBX,\n# define REG_EBX\tREG_EBX\n\tREG_EDX,\n# define REG_EDX\tREG_EDX\n\tREG_ECX,\n# define REG_ECX\tREG_ECX\n\tREG_EAX,\n# define REG_EAX\tREG_EAX\n\tREG_TRAPNO,\n# define REG_TRAPNO\tREG_TRAPNO\n\tREG_ERR,\n# define REG_ERR\tREG_ERR\n\tREG_EIP,\n# define REG_EIP\tREG_EIP\n\tREG_CS,\n# define REG_CS\t\tREG_CS\n\tREG_EFL,\n# define REG_EFL\tREG_EFL\n\tREG_UESP,\n# define REG_UESP\tREG_UESP\n\tREG_SS\n# define REG_SS\tREG_SS\n};\n#endif\n\n/* Definitions taken from the kernel headers.  */\nstruct _libc_fpreg {\n\tunsigned short int __ctx(significand)[4];\n\tunsigned short int __ctx(exponent);\n};\n\nstruct _libc_fpstate {\n\tunsigned long int __ctx(cw);\n\tunsigned long int __ctx(sw);\n\tunsigned long int __ctx(tag);\n\tunsigned long int __ctx(ipoff);\n\tunsigned long int __ctx(cssel);\n\tunsigned long int __ctx(dataoff);\n\tunsigned long int __ctx(datasel);\n\tstruct _libc_fpreg _st[8];\n\tunsigned long int __ctx(status);\n};\n\n/* Structure to describe FPU registers.  */\ntypedef struct _libc_fpstate *fpregset_t;\n\n/* Context to describe whole processor state.  */\ntypedef struct {\n\tgregset_t __ctx(gregs);\n\t/* Due to Linux's history we have to use a pointer here.  The SysV/i386\n\t   ABI requires a struct with the values.  */\n\tfpregset_t __ctx(fpregs);\n\tunsigned long int __ctx(oldmask);\n\tunsigned long int __ctx(cr2);\n} mcontext_t;\n\n/* Userlevel context.  */\ntypedef struct ucontext_t {\n\tunsigned long int __ctx(uc_flags);\n\tstruct ucontext_t *uc_link;\n\tstack_t uc_stack;\n\tmcontext_t uc_mcontext;\n\tsigset_t uc_sigmask;\n\tstruct _libc_fpstate __fpregs_mem;\n} ucontext_t;\n\n#endif\t\t\t\t/* !__x86_64__ */\n\n#undef __ctx\n\n#endif\t\t\t\t/* sys/ucontext.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/uio.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UIO_H\n#define _SYS_UIO_H\t1\n\n#include <features.h>\n#include <sys/types.h>\n#include <bits/types/struct_iovec.h>\n#include <bits/uio_lim.h>\n#ifdef __IOV_MAX\n# define UIO_MAXIOV __IOV_MAX\n#else\n# undef UIO_MAXIOV\n#endif\n\n__BEGIN_DECLS\n/* Read data from file descriptor FD, and put the result in the\n   buffers described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.\n   Operates just like 'read' (see <unistd.h>) except that data are\n   put in IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t readv(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which\n   is a vector of COUNT 'struct iovec's, to file descriptor FD.\n   The data is written in the order specified.\n   Operates just like 'write' (see <unistd.h>) except that the data\n   are taken from IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t writev(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n#ifdef __USE_MISC\n# ifndef __USE_FILE_OFFSET64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n\n# else\n#  ifdef __REDIRECT\nextern ssize_t __REDIRECT(preadv, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), preadv64) __wur;\nextern ssize_t __REDIRECT(pwritev, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), pwritev64) __wur;\n#  else\n#   define preadv preadv64\n#   define pwritev pwritev64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_GNU\n# ifndef __USE_FILE_OFFSET64\n/* Same as preadv but with an additional flag argumenti defined at uio.h.  */\nextern ssize_t preadv2(int __fp, const struct iovec *__iovec, int __count, __off_t __offset, int ___flags) __wur;\n\n/* Same as preadv but with an additional flag argument defined at uio.h.  */\nextern ssize_t pwritev2(int __fd, const struct iovec *__iodev, int __count, __off_t __offset, int __flags) __wur;\n\n# else\n#  ifdef __REDIRECT\nextern ssize_t __REDIRECT(pwritev2, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset, int __flags), pwritev64v2) __wur;\nextern ssize_t __REDIRECT(preadv2, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset, int __flags), preadv64v2) __wur;\n#  else\n#   define preadv2 preadv64v2\n#   define pwritev2 pwritev64v2\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\n/* Same as preadv but with an additional flag argumenti defined at uio.h.  */\nextern ssize_t preadv64v2(int __fp, const struct iovec *__iovec, int __count, __off64_t __offset, int ___flags) __wur;\n\n/* Same as preadv but with an additional flag argument defined at uio.h.  */\nextern ssize_t pwritev64v2(int __fd, const struct iovec *__iodev, int __count, __off64_t __offset, int __flags) __wur;\n# endif\n#endif\t\t\t\t/* Use GNU.  */\n\n__END_DECLS\n/* Some operating systems provide system-specific extensions to this\n   header.  */\n#ifdef __USE_GNU\n# include <bits/uio-ext.h>\n#endif\n#endif\t\t\t\t/* sys/uio.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/un.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_UN_H\n#define\t_SYS_UN_H\t1\n\n#include <sys/cdefs.h>\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n__BEGIN_DECLS\n/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket.  */\n    struct sockaddr_un {\n\t__SOCKADDR_COMMON(sun_);\n\tchar sun_path[108];\t/* Path name.  */\n};\n\n#ifdef __USE_MISC\n# include <string.h>\t\t/* For prototype of `strlen'.  */\n\n/* Evaluate to actual length of the `sockaddr_un' structure.  */\n# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)\t      \\\n\t\t      + strlen ((ptr)->sun_path))\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/un.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/utsname.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 4.4 System Identification\t<sys/utsname.h>\n */\n\n#ifndef\t_SYS_UTSNAME_H\n#define\t_SYS_UTSNAME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/utsname.h>\n#ifndef _UTSNAME_SYSNAME_LENGTH\n# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_NODENAME_LENGTH\n# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_RELEASE_LENGTH\n# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_VERSION_LENGTH\n# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_MACHINE_LENGTH\n# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH\n#endif\n/* Structure describing the system and machine.  */\n    struct utsname {\n\t/* Name of the implementation of the operating system.  */\n\tchar sysname[_UTSNAME_SYSNAME_LENGTH];\n\n\t/* Name of this node on the network.  */\n\tchar nodename[_UTSNAME_NODENAME_LENGTH];\n\n\t/* Current release level of this implementation.  */\n\tchar release[_UTSNAME_RELEASE_LENGTH];\n\t/* Current version level of this release.  */\n\tchar version[_UTSNAME_VERSION_LENGTH];\n\n\t/* Name of the hardware type the system is running on.  */\n\tchar machine[_UTSNAME_MACHINE_LENGTH];\n\n#if _UTSNAME_DOMAIN_LENGTH - 0\n\t/* Name of the domain of this node on the network.  */\n# ifdef __USE_GNU\n\tchar domainname[_UTSNAME_DOMAIN_LENGTH];\n# else\n\tchar __domainname[_UTSNAME_DOMAIN_LENGTH];\n# endif\n#endif\n};\n\n#ifdef __USE_MISC\n/* Note that SVID assumes all members have the same size.  */\n# define SYS_NMLN  _UTSNAME_LENGTH\n#endif\n\n/* Put information about the system in NAME.  */\nextern int uname(struct utsname *__name) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/utsname.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/i386-linux-gnu/sys/wait.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 3.2.1 Wait for Process Termination\t<sys/wait.h>\n */\n\n#ifndef\t_SYS_WAIT_H\n#define\t_SYS_WAIT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# include <signal.h>\n#endif\n\n#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8\n/* Some older standards require the contents of struct rusage to be\n   defined here.  */\n# include <bits/types/struct_rusage.h>\n#endif\n\n/* These macros could also be defined in <stdlib.h>.  */\n#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)\n/* This will define the `W*' macros for the flag\n   bits to `waitpid', `wait3', and `wait4'.  */\n# include <bits/waitflags.h>\n\n/* This will define all the `__W*' macros.  */\n# include <bits/waitstatus.h>\n\n# define WEXITSTATUS(status)\t__WEXITSTATUS (status)\n# define WTERMSIG(status)\t__WTERMSIG (status)\n# define WSTOPSIG(status)\t__WSTOPSIG (status)\n# define WIFEXITED(status)\t__WIFEXITED (status)\n# define WIFSIGNALED(status)\t__WIFSIGNALED (status)\n# define WIFSTOPPED(status)\t__WIFSTOPPED (status)\n# ifdef __WIFCONTINUED\n#  define WIFCONTINUED(status)\t__WIFCONTINUED (status)\n# endif\n#endif\t\t\t\t/* <stdlib.h> not included.  */\n\n#ifdef\t__USE_MISC\n# define WCOREFLAG\t\t__WCOREFLAG\n# define WCOREDUMP(status)\t__WCOREDUMP (status)\n# define W_EXITCODE(ret, sig)\t__W_EXITCODE (ret, sig)\n# define W_STOPCODE(sig)\t__W_STOPCODE (sig)\n#endif\n\n/* Wait for a child to die.  When one does, put its status in *STAT_LOC\n   and return its process ID.  For errors, return (pid_t) -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t wait(int *__stat_loc);\n\n#ifdef\t__USE_MISC\n/* Special values for the PID argument to `waitpid' and `wait4'.  */\n# define WAIT_ANY\t(-1)\t/* Any process.  */\n# define WAIT_MYPGRP\t0\t/* Any process in my process group.  */\n#endif\n\n/* Wait for a child matching PID to die.\n   If PID is greater than 0, match any process whose process ID is PID.\n   If PID is (pid_t) -1, match any process.\n   If PID is (pid_t) 0, match any process with the\n   same process group as the current process.\n   If PID is less than -1, match any process whose\n   process group is the absolute value of PID.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, return (pid_t) 0.  If successful,\n   return PID and store the dead child's status in STAT_LOC.\n   Return (pid_t) -1 for errors.  If the WUNTRACED bit is\n   set in OPTIONS, return status for stopped children; otherwise don't.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t waitpid(__pid_t __pid, int *__stat_loc, int __options);\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# ifndef __id_t_defined\ntypedef __id_t id_t;\n#  define __id_t_defined\n# endif\n\n# include <bits/types/siginfo_t.h>\n\n/* Wait for a childing matching IDTYPE and ID to change the status and\n   place appropriate information in *INFOP.\n   If IDTYPE is P_PID, match any process whose process ID is ID.\n   If IDTYPE is P_PGID, match any process whose process group is ID.\n   If IDTYPE is P_ALL, match any process.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, clear *INFOP and return 0.  If successful, store\n   exit code and status in *INFOP.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int waitid(idtype_t __idtype, __id_t __id, siginfo_t * __infop, int __options);\n#endif\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K)\n/* This being here makes the prototypes valid whether or not\n   we have already included <sys/resource.h> to define `struct rusage'.  */\nstruct rusage;\n\n/* Wait for a child to exit.  When one does, put its status in *STAT_LOC and\n   return its process ID.  For errors return (pid_t) -1.  If USAGE is not\n   nil, store information about the child's resource usage there.  If the\n   WUNTRACED bit is set in OPTIONS, return status for stopped children;\n   otherwise don't.  */\nextern __pid_t wait3(int *__stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\n\n#ifdef __USE_MISC\n/* PID is like waitpid.  Other args are like wait3.  */\nextern __pid_t wait4(__pid_t __pid, int *__stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/wait.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/inttypes.h",
    "content": "/* Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.8 Format conversion of integer types\t<inttypes.h>\n */\n\n#ifndef _INTTYPES_H\n#define _INTTYPES_H\t1\n\n#include <features.h>\n/* Get the type definitions.  */\n#include <stdint.h>\n\n/* Get a definition for wchar_t.  But we must not define wchar_t itself.  */\n#ifndef ____gwchar_t_defined\n# ifdef __cplusplus\n#  define __gwchar_t wchar_t\n# elif defined __WCHAR_TYPE__\ntypedef __WCHAR_TYPE__ __gwchar_t;\n# else\n#  define __need_wchar_t\n#  include <stddef.h>\ntypedef wchar_t __gwchar_t;\n# endif\n# define ____gwchar_t_defined\t1\n#endif\n\n# if __WORDSIZE == 64\n#  define __PRI64_PREFIX\t\"l\"\n#  define __PRIPTR_PREFIX\t\"l\"\n# else\n#  define __PRI64_PREFIX\t\"ll\"\n#  define __PRIPTR_PREFIX\n# endif\n\n/* Macros for printing format specifiers.  */\n\n/* Decimal notation.  */\n# define PRId8\t\t\"d\"\n# define PRId16\t\t\"d\"\n# define PRId32\t\t\"d\"\n# define PRId64\t\t__PRI64_PREFIX \"d\"\n\n# define PRIdLEAST8\t\"d\"\n# define PRIdLEAST16\t\"d\"\n# define PRIdLEAST32\t\"d\"\n# define PRIdLEAST64\t__PRI64_PREFIX \"d\"\n\n# define PRIdFAST8\t\"d\"\n# define PRIdFAST16\t__PRIPTR_PREFIX \"d\"\n# define PRIdFAST32\t__PRIPTR_PREFIX \"d\"\n# define PRIdFAST64\t__PRI64_PREFIX \"d\"\n\n# define PRIi8\t\t\"i\"\n# define PRIi16\t\t\"i\"\n# define PRIi32\t\t\"i\"\n# define PRIi64\t\t__PRI64_PREFIX \"i\"\n\n# define PRIiLEAST8\t\"i\"\n# define PRIiLEAST16\t\"i\"\n# define PRIiLEAST32\t\"i\"\n# define PRIiLEAST64\t__PRI64_PREFIX \"i\"\n\n# define PRIiFAST8\t\"i\"\n# define PRIiFAST16\t__PRIPTR_PREFIX \"i\"\n# define PRIiFAST32\t__PRIPTR_PREFIX \"i\"\n# define PRIiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Octal notation.  */\n# define PRIo8\t\t\"o\"\n# define PRIo16\t\t\"o\"\n# define PRIo32\t\t\"o\"\n# define PRIo64\t\t__PRI64_PREFIX \"o\"\n\n# define PRIoLEAST8\t\"o\"\n# define PRIoLEAST16\t\"o\"\n# define PRIoLEAST32\t\"o\"\n# define PRIoLEAST64\t__PRI64_PREFIX \"o\"\n\n# define PRIoFAST8\t\"o\"\n# define PRIoFAST16\t__PRIPTR_PREFIX \"o\"\n# define PRIoFAST32\t__PRIPTR_PREFIX \"o\"\n# define PRIoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Unsigned integers.  */\n# define PRIu8\t\t\"u\"\n# define PRIu16\t\t\"u\"\n# define PRIu32\t\t\"u\"\n# define PRIu64\t\t__PRI64_PREFIX \"u\"\n\n# define PRIuLEAST8\t\"u\"\n# define PRIuLEAST16\t\"u\"\n# define PRIuLEAST32\t\"u\"\n# define PRIuLEAST64\t__PRI64_PREFIX \"u\"\n\n# define PRIuFAST8\t\"u\"\n# define PRIuFAST16\t__PRIPTR_PREFIX \"u\"\n# define PRIuFAST32\t__PRIPTR_PREFIX \"u\"\n# define PRIuFAST64\t__PRI64_PREFIX \"u\"\n\n/* lowercase hexadecimal notation.  */\n# define PRIx8\t\t\"x\"\n# define PRIx16\t\t\"x\"\n# define PRIx32\t\t\"x\"\n# define PRIx64\t\t__PRI64_PREFIX \"x\"\n\n# define PRIxLEAST8\t\"x\"\n# define PRIxLEAST16\t\"x\"\n# define PRIxLEAST32\t\"x\"\n# define PRIxLEAST64\t__PRI64_PREFIX \"x\"\n\n# define PRIxFAST8\t\"x\"\n# define PRIxFAST16\t__PRIPTR_PREFIX \"x\"\n# define PRIxFAST32\t__PRIPTR_PREFIX \"x\"\n# define PRIxFAST64\t__PRI64_PREFIX \"x\"\n\n/* UPPERCASE hexadecimal notation.  */\n# define PRIX8\t\t\"X\"\n# define PRIX16\t\t\"X\"\n# define PRIX32\t\t\"X\"\n# define PRIX64\t\t__PRI64_PREFIX \"X\"\n\n# define PRIXLEAST8\t\"X\"\n# define PRIXLEAST16\t\"X\"\n# define PRIXLEAST32\t\"X\"\n# define PRIXLEAST64\t__PRI64_PREFIX \"X\"\n\n# define PRIXFAST8\t\"X\"\n# define PRIXFAST16\t__PRIPTR_PREFIX \"X\"\n# define PRIXFAST32\t__PRIPTR_PREFIX \"X\"\n# define PRIXFAST64\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intmax_t' and `uintmax_t'.  */\n# define PRIdMAX\t__PRI64_PREFIX \"d\"\n# define PRIiMAX\t__PRI64_PREFIX \"i\"\n# define PRIoMAX\t__PRI64_PREFIX \"o\"\n# define PRIuMAX\t__PRI64_PREFIX \"u\"\n# define PRIxMAX\t__PRI64_PREFIX \"x\"\n# define PRIXMAX\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intptr_t' and `uintptr_t'.  */\n# define PRIdPTR\t__PRIPTR_PREFIX \"d\"\n# define PRIiPTR\t__PRIPTR_PREFIX \"i\"\n# define PRIoPTR\t__PRIPTR_PREFIX \"o\"\n# define PRIuPTR\t__PRIPTR_PREFIX \"u\"\n# define PRIxPTR\t__PRIPTR_PREFIX \"x\"\n# define PRIXPTR\t__PRIPTR_PREFIX \"X\"\n\n/* Macros for scanning format specifiers.  */\n\n/* Signed decimal notation.  */\n# define SCNd8\t\t\"hhd\"\n# define SCNd16\t\t\"hd\"\n# define SCNd32\t\t\"d\"\n# define SCNd64\t\t__PRI64_PREFIX \"d\"\n\n# define SCNdLEAST8\t\"hhd\"\n# define SCNdLEAST16\t\"hd\"\n# define SCNdLEAST32\t\"d\"\n# define SCNdLEAST64\t__PRI64_PREFIX \"d\"\n\n# define SCNdFAST8\t\"hhd\"\n# define SCNdFAST16\t__PRIPTR_PREFIX \"d\"\n# define SCNdFAST32\t__PRIPTR_PREFIX \"d\"\n# define SCNdFAST64\t__PRI64_PREFIX \"d\"\n\n/* Signed decimal notation.  */\n# define SCNi8\t\t\"hhi\"\n# define SCNi16\t\t\"hi\"\n# define SCNi32\t\t\"i\"\n# define SCNi64\t\t__PRI64_PREFIX \"i\"\n\n# define SCNiLEAST8\t\"hhi\"\n# define SCNiLEAST16\t\"hi\"\n# define SCNiLEAST32\t\"i\"\n# define SCNiLEAST64\t__PRI64_PREFIX \"i\"\n\n# define SCNiFAST8\t\"hhi\"\n# define SCNiFAST16\t__PRIPTR_PREFIX \"i\"\n# define SCNiFAST32\t__PRIPTR_PREFIX \"i\"\n# define SCNiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Unsigned decimal notation.  */\n# define SCNu8\t\t\"hhu\"\n# define SCNu16\t\t\"hu\"\n# define SCNu32\t\t\"u\"\n# define SCNu64\t\t__PRI64_PREFIX \"u\"\n\n# define SCNuLEAST8\t\"hhu\"\n# define SCNuLEAST16\t\"hu\"\n# define SCNuLEAST32\t\"u\"\n# define SCNuLEAST64\t__PRI64_PREFIX \"u\"\n\n# define SCNuFAST8\t\"hhu\"\n# define SCNuFAST16\t__PRIPTR_PREFIX \"u\"\n# define SCNuFAST32\t__PRIPTR_PREFIX \"u\"\n# define SCNuFAST64\t__PRI64_PREFIX \"u\"\n\n/* Octal notation.  */\n# define SCNo8\t\t\"hho\"\n# define SCNo16\t\t\"ho\"\n# define SCNo32\t\t\"o\"\n# define SCNo64\t\t__PRI64_PREFIX \"o\"\n\n# define SCNoLEAST8\t\"hho\"\n# define SCNoLEAST16\t\"ho\"\n# define SCNoLEAST32\t\"o\"\n# define SCNoLEAST64\t__PRI64_PREFIX \"o\"\n\n# define SCNoFAST8\t\"hho\"\n# define SCNoFAST16\t__PRIPTR_PREFIX \"o\"\n# define SCNoFAST32\t__PRIPTR_PREFIX \"o\"\n# define SCNoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Hexadecimal notation.  */\n# define SCNx8\t\t\"hhx\"\n# define SCNx16\t\t\"hx\"\n# define SCNx32\t\t\"x\"\n# define SCNx64\t\t__PRI64_PREFIX \"x\"\n\n# define SCNxLEAST8\t\"hhx\"\n# define SCNxLEAST16\t\"hx\"\n# define SCNxLEAST32\t\"x\"\n# define SCNxLEAST64\t__PRI64_PREFIX \"x\"\n\n# define SCNxFAST8\t\"hhx\"\n# define SCNxFAST16\t__PRIPTR_PREFIX \"x\"\n# define SCNxFAST32\t__PRIPTR_PREFIX \"x\"\n# define SCNxFAST64\t__PRI64_PREFIX \"x\"\n\n/* Macros for scanning `intmax_t' and `uintmax_t'.  */\n# define SCNdMAX\t__PRI64_PREFIX \"d\"\n# define SCNiMAX\t__PRI64_PREFIX \"i\"\n# define SCNoMAX\t__PRI64_PREFIX \"o\"\n# define SCNuMAX\t__PRI64_PREFIX \"u\"\n# define SCNxMAX\t__PRI64_PREFIX \"x\"\n\n/* Macros for scaning `intptr_t' and `uintptr_t'.  */\n# define SCNdPTR\t__PRIPTR_PREFIX \"d\"\n# define SCNiPTR\t__PRIPTR_PREFIX \"i\"\n# define SCNoPTR\t__PRIPTR_PREFIX \"o\"\n# define SCNuPTR\t__PRIPTR_PREFIX \"u\"\n# define SCNxPTR\t__PRIPTR_PREFIX \"x\"\n\n__BEGIN_DECLS\n#if __WORDSIZE == 64\n/* We have to define the `uintmax_t' type using `ldiv_t'.  */\n    typedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} imaxdiv_t;\n\n#else\n/* We have to define the `uintmax_t' type using `lldiv_t'.  */\n    typedef struct {\n\t__extension__ long long int quot;\t/* Quotient.  */\n\t__extension__ long long int rem;\t/* Remainder.  */\n} imaxdiv_t;\n\n#endif\n\n/* Compute absolute value of N.  */\nextern intmax_t imaxabs(intmax_t __n)\n__THROW __attribute__ ((__const__));\n\n/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */\nextern imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom)\n__THROW __attribute__ ((__const__));\n\n/* Like `strtol' but convert to `intmax_t'.  */\nextern intmax_t strtoimax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `strtoul' but convert to `uintmax_t'.  */\nextern uintmax_t strtoumax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `wcstol' but convert to `intmax_t'.  */\nextern intmax_t wcstoimax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Like `wcstoul' but convert to `uintmax_t'.  */\nextern uintmax_t wcstoumax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n\n# if __WORDSIZE == 64\n\nextern long int __strtol_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __strtoul_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoul_internal(nptr, endptr, base, 0);\n}\n\nextern long int __wcstol_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __wcstoul_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoul_internal(nptr, endptr, base, 0);\n}\n\n# else\t\t\t\t/* __WORDSIZE == 32 */\n\n__extension__ extern long long int __strtoll_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __strtoull_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoull_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern long long int __wcstoll_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __wcstoull_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoull_internal(nptr, endptr, base, 0);\n}\n\n# endif\t\t\t\t/* __WORDSIZE == 32     */\n#endif\t\t\t\t/* Use extern inlines.  */\n\n__END_DECLS\n#endif\t\t\t\t/* inttypes.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/limits.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types\t<limits.h>\n */\n\n#ifndef _LIBC_LIMITS_H_\n#define _LIBC_LIMITS_H_\t1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n/* Maximum length of any multibyte character in any locale.\n   We define this value here since the gcc header does not define\n   the correct value.  */\n#define MB_LEN_MAX\t16\n\n/* If we are not using GNU CC we have to define all the symbols ourself.\n   Otherwise use gcc's definitions (see below).  */\n#if !defined __GNUC__ || __GNUC__ < 2\n\n/* We only protect from multiple inclusion here, because all the other\n   #include's protect themselves, and in GCC 2 we may #include_next through\n   multiple copies of this file before we get to GCC's.  */\n# ifndef _LIMITS_H\n#  define _LIMITS_H\t1\n\n#include <bits/wordsize.h>\n\n/* We don't have #include_next.\n   Define ANSI <limits.h> for standard 32-bit words.  */\n\n/* These assume 8-bit `char's, 16-bit `short int's,\n   and 32-bit `int's and `long int's.  */\n\n/* Number of bits in a `char'.\t*/\n#  define CHAR_BIT\t8\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#  define SCHAR_MIN\t(-128)\n#  define SCHAR_MAX\t127\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */\n#  define UCHAR_MAX\t255\n\n/* Minimum and maximum values a `char' can hold.  */\n#  ifdef __CHAR_UNSIGNED__\n#   define CHAR_MIN\t0\n#   define CHAR_MAX\tUCHAR_MAX\n#  else\n#   define CHAR_MIN\tSCHAR_MIN\n#   define CHAR_MAX\tSCHAR_MAX\n#  endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#  define SHRT_MIN\t(-32768)\n#  define SHRT_MAX\t32767\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */\n#  define USHRT_MAX\t65535\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#  define INT_MIN\t(-INT_MAX - 1)\n#  define INT_MAX\t2147483647\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */\n#  define UINT_MAX\t4294967295U\n\n/* Minimum and maximum values a `signed long int' can hold.  */\n#  if __WORDSIZE == 64\n#   define LONG_MAX\t9223372036854775807L\n#  else\n#   define LONG_MAX\t2147483647L\n#  endif\n#  define LONG_MIN\t(-LONG_MAX - 1L)\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */\n#  if __WORDSIZE == 64\n#   define ULONG_MAX\t18446744073709551615UL\n#  else\n#   define ULONG_MAX\t4294967295UL\n#  endif\n\n#  ifdef __USE_ISOC99\n\n/* Minimum and maximum values a `signed long long int' can hold.  */\n#   define LLONG_MAX\t9223372036854775807LL\n#   define LLONG_MIN\t(-LLONG_MAX - 1LL)\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */\n#   define ULLONG_MAX\t18446744073709551615ULL\n\n#  endif\t\t\t/* ISO C99 */\n\n# endif\t\t\t\t/* limits.h  */\n#endif\t\t\t\t/* GCC 2.  */\n\n#endif\t\t\t\t/* !_LIBC_LIMITS_H_ */\n\n /* Get the compiler's limits.h, which defines almost all the ISO constants.\n\n    We put this #include_next outside the double inclusion check because\n    it should be possible to include this file more than once and still get\n    the definitions from gcc's header.  */\n#if defined __GNUC__ && !defined _GCC_LIMITS_H_\n/* `_GCC_LIMITS_H_' is what GCC's file defines.  */\n# include_next <limits.h>\n#endif\n\n/* The <limits.h> files in some gcc versions don't define LLONG_MIN,\n   LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined for\n   ages are available.  */\n#if defined __USE_ISOC99 && defined __GNUC__\n# ifndef LLONG_MIN\n#  define LLONG_MIN\t(-LLONG_MAX-1)\n# endif\n# ifndef LLONG_MAX\n#  define LLONG_MAX\t__LONG_LONG_MAX__\n# endif\n# ifndef ULLONG_MAX\n#  define ULLONG_MAX\t(LLONG_MAX * 2ULL + 1)\n# endif\n#endif\n\n/* The integer width macros are not defined by GCC's <limits.h> before\n   GCC 7, or if _GNU_SOURCE rather than\n   __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature.  */\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n# ifndef CHAR_WIDTH\n#  define CHAR_WIDTH 8\n# endif\n# ifndef SCHAR_WIDTH\n#  define SCHAR_WIDTH 8\n# endif\n# ifndef UCHAR_WIDTH\n#  define UCHAR_WIDTH 8\n# endif\n# ifndef SHRT_WIDTH\n#  define SHRT_WIDTH 16\n# endif\n# ifndef USHRT_WIDTH\n#  define USHRT_WIDTH 16\n# endif\n# ifndef INT_WIDTH\n#  define INT_WIDTH 32\n# endif\n# ifndef UINT_WIDTH\n#  define UINT_WIDTH 32\n# endif\n# ifndef LONG_WIDTH\n#  define LONG_WIDTH __WORDSIZE\n# endif\n# ifndef ULONG_WIDTH\n#  define ULONG_WIDTH __WORDSIZE\n# endif\n# ifndef LLONG_WIDTH\n#  define LLONG_WIDTH 64\n# endif\n# ifndef ULLONG_WIDTH\n#  define ULLONG_WIDTH 64\n# endif\n#endif\t\t\t\t/* Use IEC_60559_BFP_EXT.  */\n\n#ifdef\t__USE_POSIX\n/* POSIX adds things to <limits.h>.  */\n# include <bits/posix1_lim.h>\n#endif\n\n#ifdef\t__USE_POSIX2\n# include <bits/posix2_lim.h>\n#endif\n\n#ifdef\t__USE_XOPEN\n# include <bits/xopen_lim.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/linux/errno.h",
    "content": "#include <asm/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/linux/ioctl.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _LINUX_IOCTL_H\n#define _LINUX_IOCTL_H\n\n#include <asm/ioctl.h>\n\n#endif\t\t\t\t/* _LINUX_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/linux/limits.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _LINUX_LIMITS_H\n#define _LINUX_LIMITS_H\n\n#define NR_OPEN\t        1024\n\n#define NGROUPS_MAX    65536\t/* supplemental group IDs are available */\n#define ARG_MAX       131072\t/* # bytes of args + environ for exec() */\n#define LINK_MAX         127\t/* # links a file may have */\n#define MAX_CANON        255\t/* size of the canonical input queue */\n#define MAX_INPUT        255\t/* size of the type-ahead buffer */\n#define NAME_MAX         255\t/* # chars in a file name */\n#define PATH_MAX        4096\t/* # chars in a path name including nul */\n#define PIPE_BUF        4096\t/* # bytes in atomic write to a pipe */\n#define XATTR_NAME_MAX   255\t/* # chars in an extended attribute name */\n#define XATTR_SIZE_MAX 65536\t/* size of an extended attribute value (64k) */\n#define XATTR_LIST_MAX 65536\t/* size of extended attribute namelist (64k) */\n\n#define RTSIG_MAX\t  32\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/linux/param.h",
    "content": "/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */\n#ifndef _LINUX_PARAM_H\n#define _LINUX_PARAM_H\n\n#include <asm/param.h>\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/locale.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.11 Localization\t<locale.h>\n */\n\n#ifndef\t_LOCALE_H\n#define\t_LOCALE_H\t1\n\n#include <features.h>\n\n#define __need_NULL\n#include <stddef.h>\n#include <bits/locale.h>\n\n__BEGIN_DECLS\n/* These are the possibilities for the first argument to setlocale.\n   The code assumes that the lowest LC_* symbol has the value zero.  */\n#define LC_CTYPE          __LC_CTYPE\n#define LC_NUMERIC        __LC_NUMERIC\n#define LC_TIME           __LC_TIME\n#define LC_COLLATE        __LC_COLLATE\n#define LC_MONETARY       __LC_MONETARY\n#define LC_MESSAGES       __LC_MESSAGES\n#define\tLC_ALL\t\t  __LC_ALL\n#define LC_PAPER\t  __LC_PAPER\n#define LC_NAME\t\t  __LC_NAME\n#define LC_ADDRESS\t  __LC_ADDRESS\n#define LC_TELEPHONE\t  __LC_TELEPHONE\n#define LC_MEASUREMENT\t  __LC_MEASUREMENT\n#define LC_IDENTIFICATION __LC_IDENTIFICATION\n/* Structure giving information about numeric and monetary notation.  */\n    struct lconv {\n\t/* Numeric (non-monetary) information.  */\n\n\tchar *decimal_point;\t/* Decimal point character.  */\n\tchar *thousands_sep;\t/* Thousands separator.  */\n\t/* Each element is the number of digits in each group;\n\t   elements with higher indices are farther left.\n\t   An element with value CHAR_MAX means that no further grouping is done.\n\t   An element with value 0 means that the previous element is used\n\t   for all groups farther left.  */\n\tchar *grouping;\n\n\t/* Monetary information.  */\n\n\t/* First three chars are a currency symbol from ISO 4217.\n\t   Fourth char is the separator.  Fifth char is '\\0'.  */\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\t/* Local currency symbol.  */\n\tchar *mon_decimal_point;\t/* Decimal point character.  */\n\tchar *mon_thousands_sep;\t/* Thousands separator.  */\n\tchar *mon_grouping;\t/* Like `grouping' element (above).  */\n\tchar *positive_sign;\t/* Sign for positive values.  */\n\tchar *negative_sign;\t/* Sign for negative values.  */\n\tchar int_frac_digits;\t/* Int'l fractional digits.  */\n\tchar frac_digits;\t/* Local fractional digits.  */\n\t/* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */\n\tchar p_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a positive value.  */\n\tchar p_sep_by_space;\n\t/* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */\n\tchar n_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a negative value.  */\n\tchar n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and currency_symbol.\n\t   1 The sign string precedes the quantity and currency_symbol.\n\t   2 The sign string follows the quantity and currency_symbol.\n\t   3 The sign string immediately precedes the currency_symbol.\n\t   4 The sign string immediately follows the currency_symbol.  */\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n#ifdef __USE_ISOC99\n\t/* 1 if int_curr_symbol precedes a positive value, 0 if succeeds.  */\n\tchar int_p_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a positive value.  */\n\tchar int_p_sep_by_space;\n\t/* 1 if int_curr_symbol precedes a negative value, 0 if succeeds.  */\n\tchar int_n_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a negative value.  */\n\tchar int_n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and int_curr_symbol.\n\t   1 The sign string precedes the quantity and int_curr_symbol.\n\t   2 The sign string follows the quantity and int_curr_symbol.\n\t   3 The sign string immediately precedes the int_curr_symbol.\n\t   4 The sign string immediately follows the int_curr_symbol.  */\n\tchar int_p_sign_posn;\n\tchar int_n_sign_posn;\n#else\n\tchar __int_p_cs_precedes;\n\tchar __int_p_sep_by_space;\n\tchar __int_n_cs_precedes;\n\tchar __int_n_sep_by_space;\n\tchar __int_p_sign_posn;\n\tchar __int_n_sign_posn;\n#endif\n};\n\n/* Set and/or return the current locale.  */\nextern char *setlocale(int __category, const char *__locale) __THROW;\n\n/* Return the numeric/monetary information for the current locale.  */\nextern struct lconv *localeconv(void) __THROW;\n\n#ifdef\t__USE_XOPEN2K8\n/* POSIX.1-2008 extends the locale interface with functions for\n   explicit creation and manipulation of 'locale_t' objects\n   representing locale contexts, and a set of parallel\n   locale-sensitive text processing functions that take a locale_t\n   argument.  This enables applications to work with data from\n   multiple locales simultaneously and thread-safely.  */\n# include <bits/types/locale_t.h>\n\n/* Return a reference to a data structure representing a set of locale\n   datasets.  Unlike for the CATEGORY parameter for `setlocale' the\n   CATEGORY_MASK parameter here uses a single bit for each category,\n   made by OR'ing together LC_*_MASK bits above.  */\nextern locale_t newlocale(int __category_mask, const char *__locale, locale_t __base) __THROW;\n\n/* These are the bits that can be set in the CATEGORY_MASK argument to\n   `newlocale'.  In the GNU implementation, LC_FOO_MASK has the value\n   of (1 << LC_FOO), but this is not a part of the interface that\n   callers can assume will be true.  */\n# define LC_CTYPE_MASK\t\t(1 << __LC_CTYPE)\n# define LC_NUMERIC_MASK\t(1 << __LC_NUMERIC)\n# define LC_TIME_MASK\t\t(1 << __LC_TIME)\n# define LC_COLLATE_MASK\t(1 << __LC_COLLATE)\n# define LC_MONETARY_MASK\t(1 << __LC_MONETARY)\n# define LC_MESSAGES_MASK\t(1 << __LC_MESSAGES)\n# define LC_PAPER_MASK\t\t(1 << __LC_PAPER)\n# define LC_NAME_MASK\t\t(1 << __LC_NAME)\n# define LC_ADDRESS_MASK\t(1 << __LC_ADDRESS)\n# define LC_TELEPHONE_MASK\t(1 << __LC_TELEPHONE)\n# define LC_MEASUREMENT_MASK\t(1 << __LC_MEASUREMENT)\n# define LC_IDENTIFICATION_MASK\t(1 << __LC_IDENTIFICATION)\n# define LC_ALL_MASK\t\t(LC_CTYPE_MASK \\\n\t\t\t\t | LC_NUMERIC_MASK \\\n\t\t\t\t | LC_TIME_MASK \\\n\t\t\t\t | LC_COLLATE_MASK \\\n\t\t\t\t | LC_MONETARY_MASK \\\n\t\t\t\t | LC_MESSAGES_MASK \\\n\t\t\t\t | LC_PAPER_MASK \\\n\t\t\t\t | LC_NAME_MASK \\\n\t\t\t\t | LC_ADDRESS_MASK \\\n\t\t\t\t | LC_TELEPHONE_MASK \\\n\t\t\t\t | LC_MEASUREMENT_MASK \\\n\t\t\t\t | LC_IDENTIFICATION_MASK \\\n\t\t\t\t )\n\n/* Return a duplicate of the set of locale in DATASET.  All usage\n   counters are increased if necessary.  */\nextern locale_t duplocale(locale_t __dataset) __THROW;\n\n/* Free the data associated with a locale dataset previously returned\n   by a call to `setlocale_r'.  */\nextern void freelocale(locale_t __dataset) __THROW;\n\n/* Switch the current thread's locale to DATASET.\n   If DATASET is null, instead just return the current setting.\n   The special value LC_GLOBAL_LOCALE is the initial setting\n   for all threads and can also be installed any time, meaning\n   the thread uses the global settings controlled by `setlocale'.  */\nextern locale_t uselocale(locale_t __dataset) __THROW;\n\n/* This value can be passed to `uselocale' and may be returned by it.\n   Passing this value to any other function has undefined behavior.  */\n# define LC_GLOBAL_LOCALE\t((locale_t) -1L)\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* locale.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/malloc.h",
    "content": "/* Prototypes and definition for malloc implementation.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MALLOC_H\n#define _MALLOC_H 1\n\n#include <features.h>\n#include <stddef.h>\n#include <stdio.h>\n\n#ifdef _LIBC\n# define __MALLOC_HOOK_VOLATILE\n# define __MALLOC_DEPRECATED\n#else\n# define __MALLOC_HOOK_VOLATILE volatile\n# define __MALLOC_DEPRECATED __attribute_deprecated__\n#endif\n\n__BEGIN_DECLS\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Re-allocate the previously allocated block in __ptr, making the new\n   block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n\n/* Re-allocate the previously allocated block in PTR, making the new\n   block large enough for NMEMB elements of SIZE bytes each.  */\n/* __attribute_malloc__ is not used, because if reallocarray returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *reallocarray(void *__ptr, size_t __nmemb, size_t __size)\n__THROW __attribute_warn_unused_result__;\n\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n\n/* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */\nextern void *memalign(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate SIZE bytes on a page boundary.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up\n   __size to nearest pagesize. */\nextern void *pvalloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Underlying allocation function; successive calls should return\n   contiguous pieces of memory.  */\nextern void *(*__morecore) (ptrdiff_t __size);\n\n/* Default value of `__morecore'.  */\nextern void *__default_morecore(ptrdiff_t __size)\n__THROW __attribute_malloc__;\n\n/* SVID2/XPG mallinfo structure */\n\nstruct mallinfo {\n\tint arena;\t\t/* non-mmapped space allocated from system */\n\tint ordblks;\t\t/* number of free chunks */\n\tint smblks;\t\t/* number of fastbin blocks */\n\tint hblks;\t\t/* number of mmapped regions */\n\tint hblkhd;\t\t/* space in mmapped regions */\n\tint usmblks;\t\t/* always 0, preserved for backwards compatibility */\n\tint fsmblks;\t\t/* space available in freed fastbin blocks */\n\tint uordblks;\t\t/* total allocated space */\n\tint fordblks;\t\t/* total free space */\n\tint keepcost;\t\t/* top-most, releasable (via malloc_trim) space */\n};\n\n/* Returns a copy of the updated current mallinfo. */\nextern struct mallinfo mallinfo(void) __THROW;\n\n/* SVID2/XPG mallopt options */\n#ifndef M_MXFAST\n# define M_MXFAST  1\t\t/* maximum request size for \"fastbins\" */\n#endif\n#ifndef M_NLBLKS\n# define M_NLBLKS  2\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_GRAIN\n# define M_GRAIN   3\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_KEEP\n# define M_KEEP    4\t\t/* UNUSED in this malloc */\n#endif\n\n/* mallopt options that actually do something */\n#define M_TRIM_THRESHOLD    -1\n#define M_TOP_PAD           -2\n#define M_MMAP_THRESHOLD    -3\n#define M_MMAP_MAX          -4\n#define M_CHECK_ACTION      -5\n#define M_PERTURB           -6\n#define M_ARENA_TEST        -7\n#define M_ARENA_MAX         -8\n\n/* General SVID/XPG interface to tunable parameters. */\nextern int mallopt(int __param, int __val) __THROW;\n\n/* Release all but __pad bytes of freed top-most memory back to the\n   system. Return 1 if successful, else 0. */\nextern int malloc_trim(size_t __pad) __THROW;\n\n/* Report the number of usable allocated bytes associated with allocated\n   chunk __ptr. */\nextern size_t malloc_usable_size(void *__ptr) __THROW;\n\n/* Prints brief summary statistics on stderr. */\nextern void malloc_stats(void) __THROW;\n\n/* Output information about state of allocator to stream FP.  */\nextern int malloc_info(int __options, FILE * __fp) __THROW;\n\n/* Hooks for debugging and user-defined versions. */\nextern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);\n\n/* Activate a standard set of debugging hooks. */\nextern void __malloc_check_init(void)\n__THROW __MALLOC_DEPRECATED;\n\n__END_DECLS\n#endif\t\t\t\t/* malloc.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/math.h",
    "content": "/* Declarations for math functions.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.12 Mathematics\t<math.h>\n */\n\n#ifndef\t_MATH_H\n#define\t_MATH_H\t1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n#if defined log && defined __GNUC__\n# warning A macro called log was already defined when <math.h> was included.\n# warning This will cause compilation problems.\n#endif\n\n__BEGIN_DECLS\n/* Get definitions of __intmax_t and __uintmax_t.  */\n#include <bits/types.h>\n/* Get machine-dependent vector math functions declarations.  */\n#include <bits/math-vector.h>\n/* Gather machine dependent type support.  */\n#include <bits/floatn.h>\n/* Value returned on overflow.  With IEEE 754 floating point, this is\n   +Infinity, otherwise the largest representable positive value.  */\n#if __GNUC_PREREQ (3, 3)\n# define HUGE_VAL (__builtin_huge_val ())\n#else\n/* This may provoke compiler warnings, and may not be rounded to\n   +Infinity in all IEEE 754 rounding modes, but is the best that can\n   be done in ISO C while remaining a constant expression.  10,000 is\n   greater than the maximum (decimal) exponent for all supported\n   floating-point formats and widths.  */\n# define HUGE_VAL 1e10000\n#endif\n#ifdef __USE_ISOC99\n# if __GNUC_PREREQ (3, 3)\n#  define HUGE_VALF (__builtin_huge_valf ())\n#  define HUGE_VALL (__builtin_huge_vall ())\n# else\n#  define HUGE_VALF 1e10000f\n#  define HUGE_VALL 1e10000L\n# endif\n#endif\n#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F16 (__builtin_huge_valf16 ())\n#endif\n#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F32 (__builtin_huge_valf32 ())\n#endif\n#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F64 (__builtin_huge_valf64 ())\n#endif\n#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F128 (__builtin_huge_valf128 ())\n#endif\n#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F32X (__builtin_huge_valf32x ())\n#endif\n#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F64X (__builtin_huge_valf64x ())\n#endif\n#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define HUGE_VAL_F128X (__builtin_huge_valf128x ())\n#endif\n#ifdef __USE_ISOC99\n/* IEEE positive infinity.  */\n# if __GNUC_PREREQ (3, 3)\n#  define INFINITY (__builtin_inff ())\n# else\n#  define INFINITY HUGE_VALF\n# endif\n/* IEEE Not A Number.  */\n# if __GNUC_PREREQ (3, 3)\n#  define NAN (__builtin_nanf (\"\"))\n# else\n/* This will raise an \"invalid\" exception outside static initializers,\n   but is the best that can be done in ISO C while remaining a\n   constant expression.  */\n#  define NAN (0.0f / 0.0f)\n# endif\n#endif\t\t\t\t/* __USE_ISOC99 */\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n/* Signaling NaN macros, if supported.  */\n# if __GNUC_PREREQ (3, 3)\n#  define SNANF (__builtin_nansf (\"\"))\n#  define SNAN (__builtin_nans (\"\"))\n#  define SNANL (__builtin_nansl (\"\"))\n# endif\n#endif\n#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF16 (__builtin_nansf16 (\"\"))\n#endif\n#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF32 (__builtin_nansf32 (\"\"))\n#endif\n#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF64 (__builtin_nansf64 (\"\"))\n#endif\n#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF128 (__builtin_nansf128 (\"\"))\n#endif\n#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF32X (__builtin_nansf32x (\"\"))\n#endif\n#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF64X (__builtin_nansf64x (\"\"))\n#endif\n#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)\n# define SNANF128X (__builtin_nansf128x (\"\"))\n#endif\n/* Get __GLIBC_FLT_EVAL_METHOD.  */\n#include <bits/flt-eval-method.h>\n#ifdef __USE_ISOC99\n/* Define the following typedefs.\n\n    float_t\tfloating-point type at least as wide as `float' used\n\t\tto evaluate `float' expressions\n    double_t\tfloating-point type at least as wide as `double' used\n\t\tto evaluate `double' expressions\n*/\n# if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16\ntypedef float float_t;\ntypedef double double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 1\ntypedef double float_t;\ntypedef double double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 2\ntypedef long double float_t;\ntypedef long double double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 32\ntypedef _Float32 float_t;\ntypedef double double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 33\ntypedef _Float32x float_t;\ntypedef _Float32x double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 64\ntypedef _Float64 float_t;\ntypedef _Float64 double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 65\ntypedef _Float64x float_t;\ntypedef _Float64x double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 128\ntypedef _Float128 float_t;\ntypedef _Float128 double_t;\n# elif __GLIBC_FLT_EVAL_METHOD == 129\ntypedef _Float128x float_t;\ntypedef _Float128x double_t;\n# else\n#  error \"Unknown __GLIBC_FLT_EVAL_METHOD\"\n# endif\n#endif\n/* Define macros for the return values of ilogb and llogb, based on\n   __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.\n\n    FP_ILOGB0\tExpands to a value returned by `ilogb (0.0)'.\n    FP_ILOGBNAN\tExpands to a value returned by `ilogb (NAN)'.\n    FP_LLOGB0\tExpands to a value returned by `llogb (0.0)'.\n    FP_LLOGBNAN\tExpands to a value returned by `llogb (NAN)'.\n\n*/\n#include <bits/fp-logb.h>\n#ifdef __USE_ISOC99\n# if __FP_LOGB0_IS_MIN\n#  define FP_ILOGB0\t(-2147483647 - 1)\n# else\n#  define FP_ILOGB0\t(-2147483647)\n# endif\n# if __FP_LOGBNAN_IS_MIN\n#  define FP_ILOGBNAN\t(-2147483647 - 1)\n# else\n#  define FP_ILOGBNAN\t2147483647\n# endif\n#endif\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n# if __WORDSIZE == 32\n#  define __FP_LONG_MAX 0x7fffffffL\n# else\n#  define __FP_LONG_MAX 0x7fffffffffffffffL\n# endif\n# if __FP_LOGB0_IS_MIN\n#  define FP_LLOGB0\t(-__FP_LONG_MAX - 1)\n# else\n#  define FP_LLOGB0\t(-__FP_LONG_MAX)\n# endif\n# if __FP_LOGBNAN_IS_MIN\n#  define FP_LLOGBNAN\t(-__FP_LONG_MAX - 1)\n# else\n#  define FP_LLOGBNAN\t__FP_LONG_MAX\n# endif\n#endif\n/* Get the architecture specific values describing the floating-point\n   evaluation.  The following symbols will get defined:\n\n    FP_FAST_FMA\n    FP_FAST_FMAF\n    FP_FAST_FMAL\n\t\tIf defined it indicates that the `fma' function\n\t\tgenerally executes about as fast as a multiply and an add.\n\t\tThis macro is defined only iff the `fma' function is\n\t\timplemented directly with a hardware multiply-add instructions.\n*/\n#include <bits/fp-fast.h>\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n/* Rounding direction macros for fromfp functions.  */\n    enum {\n\tFP_INT_UPWARD =\n# define FP_INT_UPWARD 0\n\t    FP_INT_UPWARD,\n\tFP_INT_DOWNWARD =\n# define FP_INT_DOWNWARD 1\n\t    FP_INT_DOWNWARD,\n\tFP_INT_TOWARDZERO =\n# define FP_INT_TOWARDZERO 2\n\t    FP_INT_TOWARDZERO,\n\tFP_INT_TONEARESTFROMZERO =\n# define FP_INT_TONEARESTFROMZERO 3\n\t    FP_INT_TONEARESTFROMZERO,\n\tFP_INT_TONEAREST =\n# define FP_INT_TONEAREST 4\n\t    FP_INT_TONEAREST,\n};\n#endif\n\n/* The file <bits/mathcalls.h> contains the prototypes for all the\n   actual math functions.  These macros are used for those prototypes,\n   so we can easily declare each function as both `name' and `__name',\n   and can declare the float versions `namef' and `__namef'.  */\n\n#define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)\n\n#define __MATHCALL_VEC(function, suffix, args) \t\\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHCALL (function, suffix, args)\n\n#define __MATHDECL_VEC(type, function,suffix, args) \\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHDECL(type, function,suffix, args)\n\n#define __MATHCALL(function,suffix, args)\t\\\n  __MATHDECL (_Mdouble_,function,suffix, args)\n#define __MATHDECL(type, function,suffix, args) \\\n  __MATHDECL_1(type, function,suffix, args); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args)\n#define __MATHCALLX(function,suffix, args, attrib)\t\\\n  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)\n#define __MATHDECLX(type, function,suffix, args, attrib) \\\n  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)\n#define __MATHDECL_1(type, function,suffix, args) \\\n  extern type __MATH_PRECNAME(function,suffix) args __THROW\n\n#define _Mdouble_\t\tdouble\n#define __MATH_PRECNAME(name,r)\t__CONCAT(name,r)\n#define __MATH_DECLARING_DOUBLE  1\n#define __MATH_DECLARING_FLOATN  0\n#include <bits/mathcalls-helper-functions.h>\n#include <bits/mathcalls.h>\n#undef\t_Mdouble_\n#undef\t__MATH_PRECNAME\n#undef __MATH_DECLARING_DOUBLE\n#undef __MATH_DECLARING_FLOATN\n\n#ifdef __USE_ISOC99\n\n/* Include the file of declarations again, this time using `float'\n   instead of `double' and appending f to each function name.  */\n\n# define _Mdouble_\t\tfloat\n# define __MATH_PRECNAME(name,r) name##f##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  0\n# include <bits/mathcalls-helper-functions.h>\n# include <bits/mathcalls.h>\n# undef\t_Mdouble_\n# undef\t__MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n\n# if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \\\n     || defined __LDBL_COMPAT \\\n     || defined _LIBC_TEST\n#  ifdef __LDBL_COMPAT\n\n#   ifdef __USE_ISOC99\nextern float __nldbl_nexttowardf(float __x, long double __y)\n__THROW __attribute__ ((__const__));\n#    ifdef __REDIRECT_NTH\nextern float __REDIRECT_NTH(nexttowardf, (float __x, long double __y), __nldbl_nexttowardf)\n    __attribute__ ((__const__));\nextern double __REDIRECT_NTH(nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__));\nextern long double __REDIRECT_NTH(nexttowardl, (long double __x, long double __y), nextafter) __attribute__ ((__const__));\n#    endif\n#   endif\n\n#   undef __MATHDECL_1\n#   define __MATHDECL_2(type, function,suffix, args, alias) \\\n  extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \\\n\t\t\t     args, alias)\n#   define __MATHDECL_1(type, function,suffix, args) \\\n  __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))\n#  endif\n\n/* Include the file of declarations again, this time using `long double'\n   instead of `double' and appending l to each function name.  */\n\n#  define _Mdouble_\t\tlong double\n#  define __MATH_PRECNAME(name,r) name##l##r\n#  define __MATH_DECLARING_DOUBLE  0\n#  define __MATH_DECLARING_FLOATN  0\n#  define __MATH_DECLARE_LDOUBLE   1\n#  include <bits/mathcalls-helper-functions.h>\n#  include <bits/mathcalls.h>\n#  undef _Mdouble_\n#  undef __MATH_PRECNAME\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n\n# endif\t\t\t\t/* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */\n\n#endif\t\t\t\t/* Use ISO C99.  */\n\n/* Include the file of declarations for _FloatN and _FloatNx\n   types.  */\n\n#if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)\n# define _Mdouble_\t\t_Float16\n# define __MATH_PRECNAME(name,r) name##f16##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT16\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)\n# define _Mdouble_\t\t_Float32\n# define __MATH_PRECNAME(name,r) name##f32##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT32\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)\n# define _Mdouble_\t\t_Float64\n# define __MATH_PRECNAME(name,r) name##f64##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT64\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)\n# define _Mdouble_\t\t_Float128\n# define __MATH_PRECNAME(name,r) name##f128##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT128\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)\n# define _Mdouble_\t\t_Float32x\n# define __MATH_PRECNAME(name,r) name##f32x##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT32X\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)\n# define _Mdouble_\t\t_Float64x\n# define __MATH_PRECNAME(name,r) name##f64x##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT64X\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC).  */\n\n#if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)\n# define _Mdouble_\t\t_Float128x\n# define __MATH_PRECNAME(name,r) name##f128x##r\n# define __MATH_DECLARING_DOUBLE  0\n# define __MATH_DECLARING_FLOATN  1\n# if __HAVE_DISTINCT_FLOAT128X\n#  include <bits/mathcalls-helper-functions.h>\n# endif\n# if __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  include <bits/mathcalls.h>\n# endif\n# undef _Mdouble_\n# undef __MATH_PRECNAME\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n#endif\t\t\t\t/* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */\n\n#undef\t__MATHDECL_1\n#undef\t__MATHDECL\n#undef\t__MATHCALL\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* This variable is used by `gamma' and `lgamma'.  */\nextern int signgam;\n#endif\n\n#if (__HAVE_DISTINCT_FLOAT16\t\t\t\\\n     || __HAVE_DISTINCT_FLOAT32\t\t\t\\\n     || __HAVE_DISTINCT_FLOAT64\t\t\t\\\n     || __HAVE_DISTINCT_FLOAT32X\t\t\\\n     || __HAVE_DISTINCT_FLOAT64X\t\t\\\n     || __HAVE_DISTINCT_FLOAT128X)\n# error \"Unsupported _FloatN or _FloatNx types for <math.h>.\"\n#endif\n\n/* Depending on the type of TG_ARG, call an appropriately suffixed\n   version of FUNC with arguments (including parentheses) ARGS.\n   Suffixed functions may not exist for long double if it has the same\n   format as double, or for other types with the same format as float,\n   double or long double.  The behavior is undefined if the argument\n   does not have a real floating type.  The definition may use a\n   conditional expression, so all suffixed versions of FUNC must\n   return the same type (FUNC may include a cast if necessary rather\n   than being a single identifier).  */\n#ifdef __NO_LONG_DOUBLE_MATH\n# if __HAVE_DISTINCT_FLOAT128\n#  error \"Distinct _Float128 without distinct long double not supported.\"\n# endif\n# define __MATH_TG(TG_ARG, FUNC, ARGS)\t\t\t\t\t\\\n  (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)\n#elif __HAVE_DISTINCT_FLOAT128\n# if __HAVE_GENERIC_SELECTION\n#  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32\n#   define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,\n#  else\n#   define __MATH_TG_F32(FUNC, ARGS)\n#  endif\n#  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X\n#   if __HAVE_FLOAT64X_LONG_DOUBLE\n#    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,\n#   else\n#    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,\n#   endif\n#  else\n#   define __MATH_TG_F64X(FUNC, ARGS)\n#  endif\n#  define __MATH_TG(TG_ARG, FUNC, ARGS)\t\\\n     _Generic ((TG_ARG),\t\t\t\\\n\t       float: FUNC ## f ARGS,\t\t\\\n\t       __MATH_TG_F32 (FUNC, ARGS)\t\\\n\t       default: FUNC ARGS,\t\t\\\n\t       long double: FUNC ## l ARGS,\t\\\n\t       __MATH_TG_F64X (FUNC, ARGS)\t\\\n\t       _Float128: FUNC ## f128 ARGS)\n# else\n#  if __HAVE_FLOATN_NOT_TYPEDEF\n#   error \"Non-typedef _FloatN but no _Generic.\"\n#  endif\n#  define __MATH_TG(TG_ARG, FUNC, ARGS)\t\t\t\t\t\\\n     __builtin_choose_expr\t\t\t\t\t\t\\\n     (__builtin_types_compatible_p (__typeof (TG_ARG), float),\t\t\\\n      FUNC ## f ARGS,\t\t\t\t\t\t\t\\\n      __builtin_choose_expr\t\t\t\t\t\t\\\n      (__builtin_types_compatible_p (__typeof (TG_ARG), double),\t\\\n       FUNC ARGS,\t\t\t\t\t\t\t\\\n       __builtin_choose_expr\t\t\t\t\t\t\\\n       (__builtin_types_compatible_p (__typeof (TG_ARG), long double),\t\\\n\tFUNC ## l ARGS,\t\t\t\t\t\t\t\\\n\tFUNC ## f128 ARGS)))\n# endif\n#else\n# define __MATH_TG(TG_ARG, FUNC, ARGS)\t\t\\\n  (sizeof (TG_ARG) == sizeof (float)\t\t\\\n   ? FUNC ## f ARGS\t\t\t\t\\\n   : sizeof (TG_ARG) == sizeof (double)\t\t\\\n   ? FUNC ARGS\t\t\t\t\t\\\n   : FUNC ## l ARGS)\n#endif\n\n/* ISO C99 defines some generic macros which work on any data type.  */\n#ifdef __USE_ISOC99\n\n/* All floating-point numbers can be put in one of these categories.  */\nenum {\n\tFP_NAN =\n# define FP_NAN 0\n\t    FP_NAN,\n\tFP_INFINITE =\n# define FP_INFINITE 1\n\t    FP_INFINITE,\n\tFP_ZERO =\n# define FP_ZERO 2\n\t    FP_ZERO,\n\tFP_SUBNORMAL =\n# define FP_SUBNORMAL 3\n\t    FP_SUBNORMAL,\n\tFP_NORMAL =\n# define FP_NORMAL 4\n\tFP_NORMAL\n};\n\n/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,\n   so disable builtins if this is enabled.  When fixed in a newer GCC,\n   the __SUPPORT_SNAN__ check may be skipped for those versions.  */\n\n/* Return number of classification appropriate for X.  */\n# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\t\t\t      \\\n     && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)\n     /* The check for __cplusplus allows the use of the builtin, even\n        when optimization for size is on.  This is provided for\n        libstdc++, only to let its configure test work when it is built\n        with -Os.  No further use of this definition of fpclassify is\n        expected in C++ mode, since libstdc++ provides its own version\n        of fpclassify in cmath (which undefines fpclassify).  */\n#  define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,\t      \\\n     FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)\n# else\n#  define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))\n# endif\n\n/* Return nonzero value if sign of X is negative.  */\n# if __GNUC_PREREQ (6,0)\n#  define signbit(x) __builtin_signbit (x)\n# elif defined __cplusplus\n  /* In C++ mode, __MATH_TG cannot be used, because it relies on\n     __builtin_types_compatible_p, which is a C-only builtin.\n     The check for __cplusplus allows the use of the builtin instead of\n     __MATH_TG. This is provided for libstdc++, only to let its configure\n     test work. No further use of this definition of signbit is expected\n     in C++ mode, since libstdc++ provides its own version of signbit\n     in cmath (which undefines signbit). */\n#  define signbit(x) __builtin_signbitl (x)\n# elif __GNUC_PREREQ (4,0)\n#  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))\n# else\n#  define signbit(x) __MATH_TG ((x), __signbit, (x))\n# endif\n\n/* Return nonzero value if X is not +-Inf or NaN.  */\n# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#  define isfinite(x) __builtin_isfinite (x)\n# else\n#  define isfinite(x) __MATH_TG ((x), __finite, (x))\n# endif\n\n/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */\n# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#  define isnormal(x) __builtin_isnormal (x)\n# else\n#  define isnormal(x) (fpclassify (x) == FP_NORMAL)\n# endif\n\n/* Return nonzero value if X is a NaN.  We could use `fpclassify' but\n   we already have this functions `__isnan' and it is faster.  */\n# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#  define isnan(x) __builtin_isnan (x)\n# else\n#  define isnan(x) __MATH_TG ((x), __isnan, (x))\n# endif\n\n/* Return nonzero value if X is positive or negative infinity.  */\n# if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \\\n     && !defined __SUPPORT_SNAN__ && !defined __cplusplus\n   /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,\n      use the helper function, __isinff128, with older compilers.  This is\n      only provided for C mode, because in C++ mode, GCC has no support\n      for __builtin_types_compatible_p (and when in C++ mode, this macro is\n      not used anyway, because libstdc++ headers undefine it).  */\n#  define isinf(x) \\\n    (__builtin_types_compatible_p (__typeof (x), _Float128) \\\n     ? __isinff128 (x) : __builtin_isinf_sign (x))\n# elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#  define isinf(x) __builtin_isinf_sign (x)\n# else\n#  define isinf(x) __MATH_TG ((x), __isinf, (x))\n# endif\n\n/* Bitmasks for the math_errhandling macro.  */\n# define MATH_ERRNO\t1\t/* errno set by math functions.  */\n# define MATH_ERREXCEPT\t2\t/* Exceptions raised by math functions.  */\n\n/* By default all math functions support both errno and exception handling\n   (except for soft floating point implementations which may only support\n   errno handling).  If errno handling is disabled, exceptions are still\n   supported by GLIBC.  Set math_errhandling to 0 with -ffast-math (this is\n   nonconforming but it is more useful than leaving it undefined).  */\n# ifdef __FAST_MATH__\n#  define math_errhandling\t0\n# elif defined __NO_MATH_ERRNO__\n#  define math_errhandling\t(MATH_ERREXCEPT)\n# else\n#  define math_errhandling\t(MATH_ERRNO | MATH_ERREXCEPT)\n# endif\n\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n# include <bits/iscanonical.h>\n\n/* Return nonzero value if X is a signaling NaN.  */\n# ifndef __cplusplus\n#  define issignaling(x) __MATH_TG ((x), __issignaling, (x))\n# else\n   /* In C++ mode, __MATH_TG cannot be used, because it relies on\n      __builtin_types_compatible_p, which is a C-only builtin.  On the\n      other hand, overloading provides the means to distinguish between\n      the floating-point types.  The overloading resolution will match\n      the correct parameter (regardless of type qualifiers (i.e.: const\n      and volatile)).  */\nextern \"C++\" {\n\tinline int issignaling(float __val)\n{\n\treturn __issignalingf(__val);\n} inline int issignaling(double __val) {\n\t\treturn __issignaling(__val);\n}\n\tinline int issignaling(long double __val) {\n#  ifdef __NO_LONG_DOUBLE_MATH\n\t\treturn __issignaling(__val);\n#  else\n\t\treturn __issignalingl(__val);\n#  endif\n\t}\n#  if __HAVE_DISTINCT_FLOAT128\n\tinline int issignaling(_Float128 __val) {\n\t\treturn __issignalingf128(__val);\n\t}\n#  endif\n}\t\t\t\t/* extern C++ */\n# endif\n\n/* Return nonzero value if X is subnormal.  */\n# define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)\n\n/* Return nonzero value if X is zero.  */\n# ifndef __cplusplus\n#  ifdef __SUPPORT_SNAN__\n#   define iszero(x) (fpclassify (x) == FP_ZERO)\n#  else\n#   define iszero(x) (((__typeof (x)) (x)) == 0)\n#  endif\n# else\t\t\t\t/* __cplusplus */\nextern \"C++\" {\n#  ifdef __SUPPORT_SNAN__\n\tinline int iszero(float __val) {\n\t\treturn __fpclassifyf(__val) == FP_ZERO;\n\t} inline int iszero(double __val) {\n\t\treturn __fpclassify(__val) == FP_ZERO;\n\t}\n\tinline int iszero(long double __val) {\n#   ifdef __NO_LONG_DOUBLE_MATH\n\t\treturn __fpclassify(__val) == FP_ZERO;\n#   else\n\t\treturn __fpclassifyl(__val) == FP_ZERO;\n#   endif\n\t}\n#   if __HAVE_DISTINCT_FLOAT128\n\tinline int iszero(_Float128 __val) {\n\t\treturn __fpclassifyf128(__val) == FP_ZERO;\n\t}\n#   endif\n#  else\n\ttemplate < class __T > inline bool iszero(__T __val) {\n\t\treturn __val == 0;\n\t}\n#  endif\n}\t\t\t\t/* extern C++ */\n# endif\t\t\t\t/* __cplusplus */\n#endif\t\t\t\t/* Use IEC_60559_BFP_EXT.  */\n#ifdef __USE_XOPEN\n/* X/Open wants another strange constant.  */\n# define MAXFLOAT\t3.40282347e+38F\n#endif\n/* Some useful constants.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n# define M_E\t\t2.7182818284590452354\t/* e */\n# define M_LOG2E\t1.4426950408889634074\t/* log_2 e */\n# define M_LOG10E\t0.43429448190325182765\t/* log_10 e */\n# define M_LN2\t\t0.69314718055994530942\t/* log_e 2 */\n# define M_LN10\t\t2.30258509299404568402\t/* log_e 10 */\n# define M_PI\t\t3.14159265358979323846\t/* pi */\n# define M_PI_2\t\t1.57079632679489661923\t/* pi/2 */\n# define M_PI_4\t\t0.78539816339744830962\t/* pi/4 */\n# define M_1_PI\t\t0.31830988618379067154\t/* 1/pi */\n# define M_2_PI\t\t0.63661977236758134308\t/* 2/pi */\n# define M_2_SQRTPI\t1.12837916709551257390\t/* 2/sqrt(pi) */\n# define M_SQRT2\t1.41421356237309504880\t/* sqrt(2) */\n# define M_SQRT1_2\t0.70710678118654752440\t/* 1/sqrt(2) */\n#endif\n/* The above constants are not adequate for computation using `long double's.\n   Therefore we provide as an extension constants with similar names as a\n   GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */\n#ifdef __USE_GNU\n# define M_El\t\t2.718281828459045235360287471352662498L\t/* e */\n# define M_LOG2El\t1.442695040888963407359924681001892137L\t/* log_2 e */\n# define M_LOG10El\t0.434294481903251827651128918916605082L\t/* log_10 e */\n# define M_LN2l\t\t0.693147180559945309417232121458176568L\t/* log_e 2 */\n# define M_LN10l\t2.302585092994045684017991454684364208L\t/* log_e 10 */\n# define M_PIl\t\t3.141592653589793238462643383279502884L\t/* pi */\n# define M_PI_2l\t1.570796326794896619231321691639751442L\t/* pi/2 */\n# define M_PI_4l\t0.785398163397448309615660845819875721L\t/* pi/4 */\n# define M_1_PIl\t0.318309886183790671537767526745028724L\t/* 1/pi */\n# define M_2_PIl\t0.636619772367581343075535053490057448L\t/* 2/pi */\n# define M_2_SQRTPIl\t1.128379167095512573896158903121545172L\t/* 2/sqrt(pi) */\n# define M_SQRT2l\t1.414213562373095048801688724209698079L\t/* sqrt(2) */\n# define M_SQRT1_2l\t0.707106781186547524400844362104849039L\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT16 && defined __USE_GNU\n# define M_Ef16\t\t__f16 (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef16\t__f16 (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef16\t__f16 (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f16\t__f16 (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f16\t__f16 (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf16\t__f16 (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f16\t__f16 (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f16\t__f16 (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf16\t__f16 (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf16\t__f16 (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf16\t__f16 (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f16\t__f16 (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f16\t__f16 (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT32 && defined __USE_GNU\n# define M_Ef32\t\t__f32 (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef32\t__f32 (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef32\t__f32 (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f32\t__f32 (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f32\t__f32 (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf32\t__f32 (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f32\t__f32 (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f32\t__f32 (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf32\t__f32 (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf32\t__f32 (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf32\t__f32 (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f32\t__f32 (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f32\t__f32 (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT64 && defined __USE_GNU\n# define M_Ef64\t\t__f64 (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef64\t__f64 (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef64\t__f64 (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f64\t__f64 (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f64\t__f64 (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf64\t__f64 (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f64\t__f64 (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f64\t__f64 (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf64\t__f64 (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf64\t__f64 (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf64\t__f64 (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f64\t__f64 (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f64\t__f64 (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT128 && defined __USE_GNU\n# define M_Ef128\t__f128 (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef128\t__f128 (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef128\t__f128 (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f128\t__f128 (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f128\t__f128 (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf128\t__f128 (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f128\t__f128 (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f128\t__f128 (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf128\t__f128 (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf128\t__f128 (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf128\t__f128 (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f128\t__f128 (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f128\t__f128 (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT32X && defined __USE_GNU\n# define M_Ef32x\t__f32x (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef32x\t__f32x (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef32x\t__f32x (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f32x\t__f32x (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f32x\t__f32x (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf32x\t__f32x (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f32x\t__f32x (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f32x\t__f32x (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf32x\t__f32x (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf32x\t__f32x (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf32x\t__f32x (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f32x\t__f32x (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f32x\t__f32x (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT64X && defined __USE_GNU\n# define M_Ef64x\t__f64x (2.718281828459045235360287471352662498)\t/* e */\n# define M_LOG2Ef64x\t__f64x (1.442695040888963407359924681001892137)\t/* log_2 e */\n# define M_LOG10Ef64x\t__f64x (0.434294481903251827651128918916605082)\t/* log_10 e */\n# define M_LN2f64x\t__f64x (0.693147180559945309417232121458176568)\t/* log_e 2 */\n# define M_LN10f64x\t__f64x (2.302585092994045684017991454684364208)\t/* log_e 10 */\n# define M_PIf64x\t__f64x (3.141592653589793238462643383279502884)\t/* pi */\n# define M_PI_2f64x\t__f64x (1.570796326794896619231321691639751442)\t/* pi/2 */\n# define M_PI_4f64x\t__f64x (0.785398163397448309615660845819875721)\t/* pi/4 */\n# define M_1_PIf64x\t__f64x (0.318309886183790671537767526745028724)\t/* 1/pi */\n# define M_2_PIf64x\t__f64x (0.636619772367581343075535053490057448)\t/* 2/pi */\n# define M_2_SQRTPIf64x\t__f64x (1.128379167095512573896158903121545172)\t/* 2/sqrt(pi) */\n# define M_SQRT2f64x\t__f64x (1.414213562373095048801688724209698079)\t/* sqrt(2) */\n# define M_SQRT1_2f64x\t__f64x (0.707106781186547524400844362104849039)\t/* 1/sqrt(2) */\n#endif\n#if __HAVE_FLOAT128X && defined __USE_GNU\n# error \"M_* values needed for _Float128x\"\n#endif\n/* When compiling in strict ISO C compatible mode we must not use the\n   inline functions since they, among other things, do not set the\n   `errno' variable correctly.  */\n#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES\n# define __NO_MATH_INLINES\t1\n#endif\n#ifdef __USE_ISOC99\n# if __GNUC_PREREQ (3, 1)\n/* ISO C99 defines some macros to compare number while taking care for\n   unordered numbers.  Many FPUs provide special instructions to support\n   these operations.  Generic support in GCC for these as builtins went\n   in 2.97, but not all cpus added their patterns until 3.1.  Therefore\n   we enable the builtins from 3.1 onwards and use a generic implementation\n   othwerwise.  */\n#  define isgreater(x, y)\t__builtin_isgreater(x, y)\n#  define isgreaterequal(x, y)\t__builtin_isgreaterequal(x, y)\n#  define isless(x, y)\t\t__builtin_isless(x, y)\n#  define islessequal(x, y)\t__builtin_islessequal(x, y)\n#  define islessgreater(x, y)\t__builtin_islessgreater(x, y)\n#  define isunordered(x, y)\t__builtin_isunordered(x, y)\n# else\n#  define isgreater(x, y) \\\n  (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \\\n\t\t    !isunordered (__x, __y) && __x > __y; }))\n#  define isgreaterequal(x, y) \\\n  (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \\\n\t\t    !isunordered (__x, __y) && __x >= __y; }))\n#  define isless(x, y) \\\n  (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \\\n\t\t    !isunordered (__x, __y) && __x < __y; }))\n#  define islessequal(x, y) \\\n  (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \\\n\t\t    !isunordered (__x, __y) && __x <= __y; }))\n#  define islessgreater(x, y) \\\n  (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \\\n\t\t    !isunordered (__x, __y) && __x != __y; }))\n/* isunordered must always check both operands first for signaling NaNs.  */\n#  define isunordered(x, y) \\\n  (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \\\n\t\t    __u != __v && (__u != __u || __v != __v); }))\n# endif\n#endif\n/* Get machine-dependent inline versions (if there are any).  */\n#ifdef __USE_EXTERN_INLINES\n# include <bits/mathinline.h>\n#endif\n/* Define special entry points to use when the compiler got told to\n   only expect finite results.  */\n#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0\n/* Include bits/math-finite.h for double.  */\n# define _Mdouble_ double\n# define __MATH_DECLARING_DOUBLE 1\n# define __MATH_DECLARING_FLOATN 0\n# define __REDIRFROM_X(function, reentrant) \\\n  function ## reentrant\n# define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## reentrant ## _finite\n# include <bits/math-finite.h>\n# undef _Mdouble_\n# undef __MATH_DECLARING_DOUBLE\n# undef __MATH_DECLARING_FLOATN\n# undef __REDIRFROM_X\n# undef __REDIRTO_X\n/* When __USE_ISOC99 is defined, include math-finite for float and\n   long double, as well.  */\n# ifdef __USE_ISOC99\n/* Include bits/math-finite.h for float.  */\n#  define _Mdouble_ float\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 0\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f ## reentrant\n#  define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f ## reentrant ## _finite\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n/* Include bits/math-finite.h for long double.  */\n#  ifdef __MATH_DECLARE_LDOUBLE\n#   define _Mdouble_ long double\n#   define __MATH_DECLARING_DOUBLE 0\n#   define __MATH_DECLARING_FLOATN 0\n#   define __REDIRFROM_X(function, reentrant) \\\n  function ## l ## reentrant\n#   ifdef __NO_LONG_DOUBLE_MATH\n#    define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## reentrant ## _finite\n#   else\n#    define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## l ## reentrant ## _finite\n#   endif\n#   include <bits/math-finite.h>\n#   undef _Mdouble_\n#   undef __MATH_DECLARING_DOUBLE\n#   undef __MATH_DECLARING_FLOATN\n#   undef __REDIRFROM_X\n#   undef __REDIRTO_X\n#  endif\n# endif\t\t\t\t/* __USE_ISOC99.  */\n/* Include bits/math-finite.h for _FloatN and _FloatNx.  */\n# if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float16\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f16 ## reentrant\n#  if __HAVE_DISTINCT_FLOAT16\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f16 ## reentrant ## _finite\n#  else\n#   error \"non-disinct _Float16\"\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float32\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f32 ## reentrant\n#  if __HAVE_DISTINCT_FLOAT32\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f32 ## reentrant ## _finite\n#  else\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f ## reentrant ## _finite\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float64\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f64 ## reentrant\n#  if __HAVE_DISTINCT_FLOAT64\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f64 ## reentrant ## _finite\n#  else\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## reentrant ## _finite\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float128\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f128 ## reentrant\n#  if __HAVE_DISTINCT_FLOAT128\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f128 ## reentrant ## _finite\n#  else\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## l ## reentrant ## _finite\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float32x\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f32x ## reentrant\n#  if __HAVE_DISTINCT_FLOAT32X\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f32x ## reentrant ## _finite\n#  else\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## reentrant ## _finite\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC))\t\\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float64x\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f64x ## reentrant\n#  if __HAVE_DISTINCT_FLOAT64X\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f64x ## reentrant ## _finite\n#  elif __HAVE_FLOAT64X_LONG_DOUBLE\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## l ## reentrant ## _finite\n#  else\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f128 ## reentrant ## _finite\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n# if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \\\n      && __GLIBC_USE (IEC_60559_TYPES_EXT)\n#  define _Mdouble_ _Float128x\n#  define __MATH_DECLARING_DOUBLE 0\n#  define __MATH_DECLARING_FLOATN 1\n#  define __REDIRFROM_X(function, reentrant) \\\n  function ## f128x ## reentrant\n#  if __HAVE_DISTINCT_FLOAT128X\n#   define __REDIRTO_X(function, reentrant) \\\n   __ ## function ## f128x ## reentrant ## _finite\n#  else\n#   error \"non-disinct _Float128x\"\n#  endif\n#  include <bits/math-finite.h>\n#  undef _Mdouble_\n#  undef __MATH_DECLARING_DOUBLE\n#  undef __MATH_DECLARING_FLOATN\n#  undef __REDIRFROM_X\n#  undef __REDIRTO_X\n# endif\n#endif\t\t\t\t/* __FINITE_MATH_ONLY__ > 0.  */\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n/* An expression whose type has the widest of the evaluation formats\n   of X and Y (which are of floating-point types).  */\n# if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64\n#  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L)\n# elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32\n#  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0)\n# elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32\n#  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f)\n# else\n#  define __MATH_EVAL_FMT2(x, y) ((x) + (y))\n# endif\n/* Return X == Y but raising \"invalid\" and setting errno if X or Y is\n   a NaN.  */\n# if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__)\n#  define iseqsig(x, y) \\\n   __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y)))\n# else\n/* In C++ mode, __MATH_TG cannot be used, because it relies on\n   __builtin_types_compatible_p, which is a C-only builtin.  Moreover,\n   the comparison macros from ISO C take two floating-point arguments,\n   which need not have the same type.  Choosing what underlying function\n   to call requires evaluating the formats of the arguments, then\n   selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this\n   information, however, only the type of the macro expansion is\n   relevant (actually evaluating the expression would be incorrect).\n   Thus, the type is used as a template parameter for __iseqsig_type,\n   which calls the appropriate underlying function.  */ extern \"C++\" {\n\ttemplate < typename > struct __iseqsig_type;\n\n\t template <> struct __iseqsig_type <float > {\n\t\tstatic int __call(float __x, float __y) throw() {\n\t\t\treturn __iseqsigf(__x, __y);\n\t}};\n\n\ttemplate <> struct __iseqsig_type <double > {\n\t\tstatic int __call(double __x, double __y) throw() {\n\t\t\treturn __iseqsig(__x, __y);\n\t}};\n\n\ttemplate <> struct __iseqsig_type <long double > {\n\t\tstatic int __call(double __x, double __y) throw() {\n#  ifndef __NO_LONG_DOUBLE_MATH\n\t\t\treturn __iseqsigl(__x, __y);\n#  else\n\t\t\treturn __iseqsig(__x, __y);\n#  endif\n\t}};\n\n#  if __HAVE_DISTINCT_FLOAT128\n\ttemplate <> struct __iseqsig_type <_Float128 > {\n\t\tstatic int __call(_Float128 __x, _Float128 __y) throw() {\n\t\t\treturn __iseqsigf128(__x, __y);\n\t}};\n#  endif\n\n\ttemplate < typename _T1, typename _T2 > inline int iseqsig(_T1 __x, _T2 __y) throw() {\n#  if __cplusplus >= 201103L\n\t\ttypedef decltype(__MATH_EVAL_FMT2(__x, __y)) _T3;\n#  else\n\t\ttypedef __typeof(__MATH_EVAL_FMT2(__x, __y)) _T3;\n#  endif\n\t\treturn __iseqsig_type < _T3 >::__call(__x, __y);\n\t}\n\n}\t\t\t\t/* extern \"C++\" */\n# endif\t\t\t\t/* __cplusplus */\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* math.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/memory.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * SVID\n */\n\n#ifndef\t_MEMORY_H\n#define\t_MEMORY_H\t1\n\n#include <features.h>\n\n#ifndef\t_STRING_H\n# include <string.h>\n#endif\t\t\t\t/* string.h  */\n\n#endif\t\t\t\t/* memory.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/netdb.h",
    "content": "  /* Copyright (C) 1996-2018 Free Software Foundation, Inc.\n     This file is part of the GNU C Library.\n\n     The GNU C Library is free software; you can redistribute it and/or\n     modify it under the terms of the GNU Lesser General Public\n     License as published by the Free Software Foundation; either\n     version 2.1 of the License, or (at your option) any later version.\n\n     The GNU C Library is distributed in the hope that it will be useful,\n     but WITHOUT ANY WARRANTY; without even the implied warranty of\n     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n     Lesser General Public License for more details.\n\n     You should have received a copy of the GNU Lesser General Public\n     License along with the GNU C Library; if not, see\n     <http://www.gnu.org/licenses/>.  */\n\n/* All data returned by the network data base library are supplied in\n   host order and returned in network order (suitable for use in\n   system calls).  */\n\n#ifndef\t_NETDB_H\n#define\t_NETDB_H\t1\n\n#include <features.h>\n\n#include <netinet/in.h>\n#include <bits/stdint-uintn.h>\n#ifdef __USE_MISC\n/* This is necessary to make this include file properly replace the\n   Sun version.  */\n# include <rpc/netdb.h>\n#endif\n\n#ifdef __USE_GNU\n# include <bits/types/sigevent_t.h>\n# include <bits/types/struct_timespec.h>\n#endif\n\n#include <bits/netdb.h>\n\n/* Absolute file name for network data base files.  */\n#define\t_PATH_HEQUIV\t\t\"/etc/hosts.equiv\"\n#define\t_PATH_HOSTS\t\t\"/etc/hosts\"\n#define\t_PATH_NETWORKS\t\t\"/etc/networks\"\n#define\t_PATH_NSSWITCH_CONF\t\"/etc/nsswitch.conf\"\n#define\t_PATH_PROTOCOLS\t\t\"/etc/protocols\"\n#define\t_PATH_SERVICES\t\t\"/etc/services\"\n\n__BEGIN_DECLS\n#if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Error status for non-reentrant lookup functions.\n   We use a macro to access always the thread-specific `h_errno' variable.  */\n# define h_errno (*__h_errno_location ())\n/* Function to get address of global `h_errno' variable.  */\nextern int *__h_errno_location(void)\n__THROW __attribute__ ((__const__));\n\n/* Possible values left in `h_errno'.  */\n# define HOST_NOT_FOUND\t1\t/* Authoritative Answer Host not found.  */\n# define TRY_AGAIN\t2\t/* Non-Authoritative Host not found,\n\t\t\t\t   or SERVERFAIL.  */\n# define NO_RECOVERY\t3\t/* Non recoverable errors, FORMERR, REFUSED,\n\t\t\t\t   NOTIMP.  */\n# define NO_DATA\t4\t/* Valid name, no data record of requested\n\t\t\t\t   type.  */\n#endif\n#ifdef __USE_MISC\n# define NETDB_INTERNAL\t-1\t/* See errno.  */\n# define NETDB_SUCCESS\t0\t/* No problem.  */\n# define NO_ADDRESS\tNO_DATA\t/* No address, look for MX record.  */\n#endif\n\n#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED\n/* Highest reserved Internet port number.  */\n# define IPPORT_RESERVED\t1024\n#endif\n\n#ifdef __USE_GNU\n/* Scope delimiter for getaddrinfo(), getnameinfo().  */\n# define SCOPE_DELIMITER\t'%'\n#endif\n\n#ifdef __USE_MISC\n/* Print error indicated by `h_errno' variable on standard error.  STR\n   if non-null is printed before the error string.  */\nextern void herror(const char *__str) __THROW;\n\n/* Return string associated with error ERR_NUM.  */\nextern const char *hstrerror(int __err_num) __THROW;\n#endif\n\n/* Description of data base entry for a single host.  */\nstruct hostent {\n\tchar *h_name;\t\t/* Official name of host.  */\n\tchar **h_aliases;\t/* Alias list.  */\n\tint h_addrtype;\t\t/* Host address type.  */\n\tint h_length;\t\t/* Length of address.  */\n\tchar **h_addr_list;\t/* List of addresses from name server.  */\n#ifdef __USE_MISC\n# define\th_addr\th_addr_list[0]\t/* Address, for backward compatibility. */\n#endif\n};\n\n/* Open host data base files and mark them as staying open even after\n   a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void sethostent(int __stay_open);\n\n/* Close host data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endhostent(void);\n\n/* Get next entry from host data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostent(void);\n\n/* Return entry from host data base which address match ADDR with\n   length LEN and type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyaddr(const void *__addr, __socklen_t __len, int __type);\n\n/* Return entry from host data base for host with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyname(const char *__name);\n\n#ifdef __USE_MISC\n/* Return entry from host data base for host with NAME.  AF must be\n   set to the address type which is `AF_INET' for IPv4 or `AF_INET6'\n   for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct hostent *gethostbyname2(const char *__name, int __af);\n\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int gethostent_r(struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyaddr_r(const void *__restrict __addr, __socklen_t __len, int __type, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname_r(const char *__restrict __name, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname2_r(const char *__restrict __name, int __af, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Open network data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setnetent(int __stay_open);\n\n/* Close network data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endnetent(void);\n\n/* Get next entry from network data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetent(void);\n\n/* Return entry from network data base which address match NET and\n   type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyaddr(uint32_t __net, int __type);\n\n/* Return entry from network data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyname(const char *__name);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getnetent_r(struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyaddr_r(uint32_t __net, int __type, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyname_r(const char *__restrict __name, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct servent {\n\tchar *s_name;\t\t/* Official service name.  */\n\tchar **s_aliases;\t/* Alias list.  */\n\tint s_port;\t\t/* Port number.  */\n\tchar *s_proto;\t\t/* Protocol to use.  */\n};\n\n/* Open service data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setservent(int __stay_open);\n\n/* Close service data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endservent(void);\n\n/* Get next entry from service data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservent(void);\n\n/* Return entry from network data base for network with NAME and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyname(const char *__name, const char *__proto);\n\n/* Return entry from service data base which matches port PORT and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyport(int __port, const char *__proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getservent_r(struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyname_r(const char *__restrict __name, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyport_r(int __port, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct protoent {\n\tchar *p_name;\t\t/* Official protocol name.  */\n\tchar **p_aliases;\t/* Alias list.  */\n\tint p_proto;\t\t/* Protocol number.  */\n};\n\n/* Open protocol data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setprotoent(int __stay_open);\n\n/* Close protocol data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endprotoent(void);\n\n/* Get next entry from protocol data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotoent(void);\n\n/* Return entry from protocol data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobyname(const char *__name);\n\n/* Return entry from protocol data base which number is PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobynumber(int __proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getprotoent_r(struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobyname_r(const char *__restrict __name, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobynumber_r(int __proto, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\n/* Establish network group NETGROUP for enumeration.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int setnetgrent(const char *__netgroup);\n\n/* Free all space allocated by previous `setnetgrent' call.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern void endnetgrent(void);\n\n/* Get next member of netgroup established by last `setnetgrent' call\n   and return pointers to elements in HOSTP, USERP, and DOMAINP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp);\n\n/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int innetgr(const char *__netgroup, const char *__host, const char *__user, const char *__domain);\n\n/* Reentrant version of `getnetgrent' where result is placed in BUFFER.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent_r(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp, char *__restrict __buffer, size_t __buflen);\n#endif\t\t\t\t/* misc */\n\n#ifdef __USE_MISC\n/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.\n   The local user is LOCUSER, on the remote machine the command is\n   executed as REMUSER.  In *FD2P the descriptor to the socket for the\n   connection is returned.  The caller must have the right to use a\n   reserved port.  When the function returns *AHOST contains the\n   official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd_af(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Call `rexecd' at port RPORT on remote machine *AHOST to execute\n   CMD.  The process runs at the remote machine using the ID of user\n   NAME whose cleartext password is PASSWD.  In *FD2P the descriptor\n   to the socket for the connection is returned.  When the function\n   returns *AHOST contains the official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec_af(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.\n   If SUSER is not zero the user tries to become superuser.  Return 0 if\n   it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok(const char *__rhost, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok_af(const char *__rhost, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Check whether user REMUSER on system indicated by IPv4 address\n   RADDR is allowed to login as LOCUSER.  Non-IPv4 (e.g., IPv6) are\n   not supported.  If SUSER is not zero the user tries to become\n   superuser.  Return 0 if it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok(uint32_t __raddr, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the pfamiliy if the address\n   pointed to by RADDR is determined by the value of AF.  It therefore\n   can be used for IPv6\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok_af(const void *__raddr, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Try to allocate reserved port, returning a descriptor for a socket opened\n   at this port or -1 if unsuccessful.  The search for an available port\n   will start at ALPORT and continues with lower numbers.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport(int *__alport);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport_af(int *__alport, sa_family_t __af);\n#endif\n\n/* Extension from POSIX.1:2001.  */\n#ifdef __USE_XOPEN2K\n/* Structure to contain information about address of a service provider.  */\nstruct addrinfo {\n\tint ai_flags;\t\t/* Input flags.  */\n\tint ai_family;\t\t/* Protocol family for socket.  */\n\tint ai_socktype;\t/* Socket type.  */\n\tint ai_protocol;\t/* Protocol for socket.  */\n\tsocklen_t ai_addrlen;\t/* Length of socket address.  */\n\tstruct sockaddr *ai_addr;\t/* Socket address for socket.  */\n\tchar *ai_canonname;\t/* Canonical name for service location.  */\n\tstruct addrinfo *ai_next;\t/* Pointer to next in list.  */\n};\n\n# ifdef __USE_GNU\n/* Structure used as control block for asynchronous lookup.  */\nstruct gaicb {\n\tconst char *ar_name;\t/* Name to look up.  */\n\tconst char *ar_service;\t/* Service name.  */\n\tconst struct addrinfo *ar_request;\t/* Additional request specification.  */\n\tstruct addrinfo *ar_result;\t/* Pointer to result.  */\n\t/* The following are internal elements.  */\n\tint __return;\n\tint __glibc_reserved[5];\n};\n\n/* Lookup mode.  */\n#  define GAI_WAIT\t0\n#  define GAI_NOWAIT\t1\n# endif\n\n/* Possible values for `ai_flags' field in `addrinfo' structure.  */\n# define AI_PASSIVE\t0x0001\t/* Socket address is intended for `bind'.  */\n# define AI_CANONNAME\t0x0002\t/* Request for canonical name.  */\n# define AI_NUMERICHOST\t0x0004\t/* Don't use name resolution.  */\n# define AI_V4MAPPED\t0x0008\t/* IPv4 mapped addresses are acceptable.  */\n# define AI_ALL\t\t0x0010\t/* Return IPv4 mapped and IPv6 addresses.  */\n# define AI_ADDRCONFIG\t0x0020\t/* Use configuration of this host to choose\n\t\t\t\t   returned address type..  */\n# ifdef __USE_GNU\n#  define AI_IDN\t0x0040\t/* IDN encode input (assuming it is encoded\n\t\t\t\t   in the current locale's character set)\n\t\t\t\t   before looking it up. */\n#  define AI_CANONIDN\t0x0080\t/* Translate canonical name from IDN format. */\n#  define AI_IDN_ALLOW_UNASSIGNED 0x0100\t/* Don't reject unassigned Unicode\n\t\t\t\t\t\t   code points.  */\n#  define AI_IDN_USE_STD3_ASCII_RULES 0x0200\t/* Validate strings according to\n\t\t\t\t\t\t   STD3 rules.  */\n# endif\n# define AI_NUMERICSERV\t0x0400\t/* Don't use name resolution.  */\n\n/* Error values for `getaddrinfo' function.  */\n# define EAI_BADFLAGS\t  -1\t/* Invalid value for `ai_flags' field.  */\n# define EAI_NONAME\t  -2\t/* NAME or SERVICE is unknown.  */\n# define EAI_AGAIN\t  -3\t/* Temporary failure in name resolution.  */\n# define EAI_FAIL\t  -4\t/* Non-recoverable failure in name res.  */\n# define EAI_FAMILY\t  -6\t/* `ai_family' not supported.  */\n# define EAI_SOCKTYPE\t  -7\t/* `ai_socktype' not supported.  */\n# define EAI_SERVICE\t  -8\t/* SERVICE not supported for `ai_socktype'.  */\n# define EAI_MEMORY\t  -10\t/* Memory allocation failure.  */\n# define EAI_SYSTEM\t  -11\t/* System error returned in `errno'.  */\n# define EAI_OVERFLOW\t  -12\t/* Argument buffer overflow.  */\n# ifdef __USE_GNU\n#  define EAI_NODATA\t  -5\t/* No address associated with NAME.  */\n#  define EAI_ADDRFAMILY  -9\t/* Address family for NAME not supported.  */\n#  define EAI_INPROGRESS  -100\t/* Processing request in progress.  */\n#  define EAI_CANCELED\t  -101\t/* Request canceled.  */\n#  define EAI_NOTCANCELED -102\t/* Request not canceled.  */\n#  define EAI_ALLDONE\t  -103\t/* All requests done.  */\n#  define EAI_INTR\t  -104\t/* Interrupted by a signal.  */\n#  define EAI_IDN_ENCODE  -105\t/* IDN encoding failed.  */\n# endif\n\n# ifdef __USE_MISC\n#  define NI_MAXHOST      1025\n#  define NI_MAXSERV      32\n# endif\n\n# define NI_NUMERICHOST\t1\t/* Don't try to look up hostname.  */\n# define NI_NUMERICSERV 2\t/* Don't convert port number to name.  */\n# define NI_NOFQDN\t4\t/* Only return nodename portion.  */\n# define NI_NAMEREQD\t8\t/* Don't return numeric addresses.  */\n# define NI_DGRAM\t16\t/* Look up UDP service rather than TCP.  */\n# ifdef __USE_GNU\n#  define NI_IDN\t32\t/* Convert name from IDN format.  */\n#  define NI_IDN_ALLOW_UNASSIGNED 64\t/* Don't reject unassigned Unicode\n\t\t\t\t\t   code points.  */\n#  define NI_IDN_USE_STD3_ASCII_RULES 128\t/* Validate strings according to\n\t\t\t\t\t\t   STD3 rules.  */\n# endif\n\n/* Translate name of a service location and/or a service name to set of\n   socket addresses.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai);\n\n/* Free `addrinfo' structure AI including associated storage.  */\nextern void freeaddrinfo(struct addrinfo *__ai) __THROW;\n\n/* Convert error return from getaddrinfo() to a string.  */\nextern const char *gai_strerror(int __ecode) __THROW;\n\n/* Translate a socket address to a location and service name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, int __flags);\n#endif\t\t\t\t/* POSIX */\n\n#ifdef __USE_GNU\n/* Enqueue ENT requests from the LIST.  If MODE is GAI_WAIT wait until all\n   requests are handled.  If WAIT is GAI_NOWAIT return immediately after\n   queueing the requests and signal completion according to SIG.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getaddrinfo_a(int __mode, struct gaicb *__list[__restrict_arr], int __ent, struct sigevent *__restrict __sig);\n\n/* Suspend execution of the thread until at least one of the ENT requests\n   in LIST is handled.  If TIMEOUT is not a null pointer it specifies the\n   longest time the function keeps waiting before returning with an error.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int gai_suspend(const struct gaicb *const __list[], int __ent, const struct timespec *__timeout);\n\n/* Get the error status of the request REQ.  */\nextern int gai_error(struct gaicb *__req) __THROW;\n\n/* Cancel the requests associated with GAICBP.  */\nextern int gai_cancel(struct gaicb *__gaicbp) __THROW;\n#endif\t\t\t\t/* GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/netinet/in.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_NETINET_IN_H\n#define\t_NETINET_IN_H\t1\n\n#include <features.h>\n#include <bits/stdint-uintn.h>\n#include <sys/socket.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n/* Internet address.  */\ntypedef uint32_t in_addr_t;\nstruct in_addr {\n\tin_addr_t s_addr;\n};\n\n/* Get system-specific definitions.  */\n#include <bits/in.h>\n\n/* Standard well-defined IP protocols.  */\nenum {\n\tIPPROTO_IP = 0,\t\t/* Dummy protocol for TCP.  */\n#define IPPROTO_IP\t\tIPPROTO_IP\n\tIPPROTO_ICMP = 1,\t/* Internet Control Message Protocol.  */\n#define IPPROTO_ICMP\t\tIPPROTO_ICMP\n\tIPPROTO_IGMP = 2,\t/* Internet Group Management Protocol. */\n#define IPPROTO_IGMP\t\tIPPROTO_IGMP\n\tIPPROTO_IPIP = 4,\t/* IPIP tunnels (older KA9Q tunnels use 94).  */\n#define IPPROTO_IPIP\t\tIPPROTO_IPIP\n\tIPPROTO_TCP = 6,\t/* Transmission Control Protocol.  */\n#define IPPROTO_TCP\t\tIPPROTO_TCP\n\tIPPROTO_EGP = 8,\t/* Exterior Gateway Protocol.  */\n#define IPPROTO_EGP\t\tIPPROTO_EGP\n\tIPPROTO_PUP = 12,\t/* PUP protocol.  */\n#define IPPROTO_PUP\t\tIPPROTO_PUP\n\tIPPROTO_UDP = 17,\t/* User Datagram Protocol.  */\n#define IPPROTO_UDP\t\tIPPROTO_UDP\n\tIPPROTO_IDP = 22,\t/* XNS IDP protocol.  */\n#define IPPROTO_IDP\t\tIPPROTO_IDP\n\tIPPROTO_TP = 29,\t/* SO Transport Protocol Class 4.  */\n#define IPPROTO_TP\t\tIPPROTO_TP\n\tIPPROTO_DCCP = 33,\t/* Datagram Congestion Control Protocol.  */\n#define IPPROTO_DCCP\t\tIPPROTO_DCCP\n\tIPPROTO_IPV6 = 41,\t/* IPv6 header.  */\n#define IPPROTO_IPV6\t\tIPPROTO_IPV6\n\tIPPROTO_RSVP = 46,\t/* Reservation Protocol.  */\n#define IPPROTO_RSVP\t\tIPPROTO_RSVP\n\tIPPROTO_GRE = 47,\t/* General Routing Encapsulation.  */\n#define IPPROTO_GRE\t\tIPPROTO_GRE\n\tIPPROTO_ESP = 50,\t/* encapsulating security payload.  */\n#define IPPROTO_ESP\t\tIPPROTO_ESP\n\tIPPROTO_AH = 51,\t/* authentication header.  */\n#define IPPROTO_AH\t\tIPPROTO_AH\n\tIPPROTO_MTP = 92,\t/* Multicast Transport Protocol.  */\n#define IPPROTO_MTP\t\tIPPROTO_MTP\n\tIPPROTO_BEETPH = 94,\t/* IP option pseudo header for BEET.  */\n#define IPPROTO_BEETPH\t\tIPPROTO_BEETPH\n\tIPPROTO_ENCAP = 98,\t/* Encapsulation Header.  */\n#define IPPROTO_ENCAP\t\tIPPROTO_ENCAP\n\tIPPROTO_PIM = 103,\t/* Protocol Independent Multicast.  */\n#define IPPROTO_PIM\t\tIPPROTO_PIM\n\tIPPROTO_COMP = 108,\t/* Compression Header Protocol.  */\n#define IPPROTO_COMP\t\tIPPROTO_COMP\n\tIPPROTO_SCTP = 132,\t/* Stream Control Transmission Protocol.  */\n#define IPPROTO_SCTP\t\tIPPROTO_SCTP\n\tIPPROTO_UDPLITE = 136,\t/* UDP-Lite protocol.  */\n#define IPPROTO_UDPLITE\t\tIPPROTO_UDPLITE\n\tIPPROTO_MPLS = 137,\t/* MPLS in IP.  */\n#define IPPROTO_MPLS\t\tIPPROTO_MPLS\n\tIPPROTO_RAW = 255,\t/* Raw IP packets.  */\n#define IPPROTO_RAW\t\tIPPROTO_RAW\n\tIPPROTO_MAX\n};\n\n/* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel\n   network headers first and we should use those ABI-identical definitions\n   instead of our own, otherwise 0.  */\n#if !__USE_KERNEL_IPV6_DEFS\nenum {\n\tIPPROTO_HOPOPTS = 0,\t/* IPv6 Hop-by-Hop options.  */\n#define IPPROTO_HOPOPTS\t\tIPPROTO_HOPOPTS\n\tIPPROTO_ROUTING = 43,\t/* IPv6 routing header.  */\n#define IPPROTO_ROUTING\t\tIPPROTO_ROUTING\n\tIPPROTO_FRAGMENT = 44,\t/* IPv6 fragmentation header.  */\n#define IPPROTO_FRAGMENT\tIPPROTO_FRAGMENT\n\tIPPROTO_ICMPV6 = 58,\t/* ICMPv6.  */\n#define IPPROTO_ICMPV6\t\tIPPROTO_ICMPV6\n\tIPPROTO_NONE = 59,\t/* IPv6 no next header.  */\n#define IPPROTO_NONE\t\tIPPROTO_NONE\n\tIPPROTO_DSTOPTS = 60,\t/* IPv6 destination options.  */\n#define IPPROTO_DSTOPTS\t\tIPPROTO_DSTOPTS\n\tIPPROTO_MH = 135\t/* IPv6 mobility header.  */\n#define IPPROTO_MH\t\tIPPROTO_MH\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Type to represent a port.  */\ntypedef uint16_t in_port_t;\n\n/* Standard well-known ports.  */\nenum {\n\tIPPORT_ECHO = 7,\t/* Echo service.  */\n\tIPPORT_DISCARD = 9,\t/* Discard transmissions service.  */\n\tIPPORT_SYSTAT = 11,\t/* System status service.  */\n\tIPPORT_DAYTIME = 13,\t/* Time of day service.  */\n\tIPPORT_NETSTAT = 15,\t/* Network status service.  */\n\tIPPORT_FTP = 21,\t/* File Transfer Protocol.  */\n\tIPPORT_TELNET = 23,\t/* Telnet protocol.  */\n\tIPPORT_SMTP = 25,\t/* Simple Mail Transfer Protocol.  */\n\tIPPORT_TIMESERVER = 37,\t/* Timeserver service.  */\n\tIPPORT_NAMESERVER = 42,\t/* Domain Name Service.  */\n\tIPPORT_WHOIS = 43,\t/* Internet Whois service.  */\n\tIPPORT_MTP = 57,\n\n\tIPPORT_TFTP = 69,\t/* Trivial File Transfer Protocol.  */\n\tIPPORT_RJE = 77,\n\tIPPORT_FINGER = 79,\t/* Finger service.  */\n\tIPPORT_TTYLINK = 87,\n\tIPPORT_SUPDUP = 95,\t/* SUPDUP protocol.  */\n\n\tIPPORT_EXECSERVER = 512,\t/* execd service.  */\n\tIPPORT_LOGINSERVER = 513,\t/* rlogind service.  */\n\tIPPORT_CMDSERVER = 514,\n\tIPPORT_EFSSERVER = 520,\n\n\t/* UDP ports.  */\n\tIPPORT_BIFFUDP = 512,\n\tIPPORT_WHOSERVER = 513,\n\tIPPORT_ROUTESERVER = 520,\n\n\t/* Ports less than this value are reserved for privileged processes.  */\n\tIPPORT_RESERVED = 1024,\n\n\t/* Ports greater this value are reserved for (non-privileged) servers.  */\n\tIPPORT_USERRESERVED = 5000\n};\n\n/* Definitions of the bits in an Internet address integer.\n\n   On subnets, host and network parts are found according to\n   the subnet mask, not these masks.  */\n\n#define\tIN_CLASSA(a)\t\t((((in_addr_t)(a)) & 0x80000000) == 0)\n#define\tIN_CLASSA_NET\t\t0xff000000\n#define\tIN_CLASSA_NSHIFT\t24\n#define\tIN_CLASSA_HOST\t\t(0xffffffff & ~IN_CLASSA_NET)\n#define\tIN_CLASSA_MAX\t\t128\n\n#define\tIN_CLASSB(a)\t\t((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)\n#define\tIN_CLASSB_NET\t\t0xffff0000\n#define\tIN_CLASSB_NSHIFT\t16\n#define\tIN_CLASSB_HOST\t\t(0xffffffff & ~IN_CLASSB_NET)\n#define\tIN_CLASSB_MAX\t\t65536\n\n#define\tIN_CLASSC(a)\t\t((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)\n#define\tIN_CLASSC_NET\t\t0xffffff00\n#define\tIN_CLASSC_NSHIFT\t8\n#define\tIN_CLASSC_HOST\t\t(0xffffffff & ~IN_CLASSC_NET)\n\n#define\tIN_CLASSD(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)\n#define\tIN_MULTICAST(a)\t\tIN_CLASSD(a)\n\n#define\tIN_EXPERIMENTAL(a)\t((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)\n#define\tIN_BADCLASS(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)\n\n/* Address to accept any incoming messages.  */\n#define\tINADDR_ANY\t\t((in_addr_t) 0x00000000)\n/* Address to send to all hosts.  */\n#define\tINADDR_BROADCAST\t((in_addr_t) 0xffffffff)\n/* Address indicating an error return.  */\n#define\tINADDR_NONE\t\t((in_addr_t) 0xffffffff)\n\n/* Network number for local host loopback.  */\n#define\tIN_LOOPBACKNET\t\t127\n/* Address to loopback in software to local host.  */\n#ifndef INADDR_LOOPBACK\n# define INADDR_LOOPBACK\t((in_addr_t) 0x7f000001)\t/* Inet 127.0.0.1.  */\n#endif\n\n/* Defines for Multicast INADDR.  */\n#define INADDR_UNSPEC_GROUP\t((in_addr_t) 0xe0000000)\t/* 224.0.0.0 */\n#define INADDR_ALLHOSTS_GROUP\t((in_addr_t) 0xe0000001)\t/* 224.0.0.1 */\n#define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002)\t/* 224.0.0.2 */\n#define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)\t/* 224.0.0.255 */\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* IPv6 address */\nstruct in6_addr {\n\tunion {\n\t\tuint8_t __u6_addr8[16];\n\t\tuint16_t __u6_addr16[8];\n\t\tuint32_t __u6_addr32[4];\n\t} __in6_u;\n#define s6_addr\t\t\t__in6_u.__u6_addr8\n#ifdef __USE_MISC\n# define s6_addr16\t\t__in6_u.__u6_addr16\n# define s6_addr32\t\t__in6_u.__u6_addr32\n#endif\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\nextern const struct in6_addr in6addr_any;\t/* :: */\nextern const struct in6_addr in6addr_loopback;\t/* ::1 */\n#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }\n#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }\n\n#define INET_ADDRSTRLEN 16\n#define INET6_ADDRSTRLEN 46\n\n/* Structure describing an Internet socket address.  */\nstruct sockaddr_in {\n\t__SOCKADDR_COMMON(sin_);\n\tin_port_t sin_port;\t/* Port number.  */\n\tstruct in_addr sin_addr;\t/* Internet address.  */\n\n\t/* Pad to size of `struct sockaddr'.  */\n\tunsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof(in_port_t) - sizeof(struct in_addr)];\n};\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* Ditto, for IPv6.  */\nstruct sockaddr_in6 {\n\t__SOCKADDR_COMMON(sin6_);\n\tin_port_t sin6_port;\t/* Transport layer port # */\n\tuint32_t sin6_flowinfo;\t/* IPv6 flow information */\n\tstruct in6_addr sin6_addr;\t/* IPv6 address */\n\tuint32_t sin6_scope_id;\t/* IPv6 scope-id */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* IPv4 multicast request.  */\nstruct ip_mreq {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imr_interface;\n};\n\nstruct ip_mreq_source {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* IP address of interface.  */\n\tstruct in_addr imr_interface;\n\n\t/* IP address of source.  */\n\tstruct in_addr imr_sourceaddr;\n};\n#endif\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* Likewise, for IPv6.  */\nstruct ipv6_mreq {\n\t/* IPv6 multicast address of group */\n\tstruct in6_addr ipv6mr_multiaddr;\n\n\t/* local interface */\n\tunsigned int ipv6mr_interface;\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* Multicast group request.  */\nstruct group_req {\n\t/* Interface index.  */\n\tuint32_t gr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gr_group;\n};\n\nstruct group_source_req {\n\t/* Interface index.  */\n\tuint32_t gsr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gsr_group;\n\n\t/* Source address.  */\n\tstruct sockaddr_storage gsr_source;\n};\n\n/* Full-state filter operations.  */\nstruct ip_msfilter {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imsf_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imsf_interface;\n\n\t/* Filter mode.  */\n\tuint32_t imsf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t imsf_numsrc;\n\t/* Source addresses.  */\n\tstruct in_addr imsf_slist[1];\n};\n\n#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \\\n\t\t\t\t  - sizeof (struct in_addr)\t\t      \\\n\t\t\t\t  + (numsrc) * sizeof (struct in_addr))\n\nstruct group_filter {\n\t/* Interface index.  */\n\tuint32_t gf_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gf_group;\n\n\t/* Filter mode.  */\n\tuint32_t gf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t gf_numsrc;\n\t/* Source addresses.  */\n\tstruct sockaddr_storage gf_slist[1];\n};\n\n#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \\\n\t\t\t\t   - sizeof (struct sockaddr_storage)\t      \\\n\t\t\t\t   + ((numsrc)\t\t\t\t      \\\n\t\t\t\t      * sizeof (struct sockaddr_storage)))\n#endif\n\n/* Functions to convert between host and network byte order.\n\n   Please note that these functions normally take `unsigned long int' or\n   `unsigned short int' values as arguments and also return them.  But\n   this was a short-sighted decision since on different systems the types\n   may have different representations but the values are always the same.  */\n\nextern uint32_t ntohl(uint32_t __netlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t ntohs(uint16_t __netshort)\n__THROW __attribute__ ((__const__));\nextern uint32_t htonl(uint32_t __hostlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t htons(uint16_t __hostshort)\n__THROW __attribute__ ((__const__));\n\n#include <endian.h>\n\n/* Get machine dependent optimized versions of byte swapping functions.  */\n#include <bits/byteswap.h>\n#include <bits/uintn-identity.h>\n\n#ifdef __OPTIMIZE__\n/* We can optimize calls to the conversion functions.  Either nothing has\n   to be done or we are using directly the byte-swapping functions which\n   often can be inlined.  */\n# if __BYTE_ORDER == __BIG_ENDIAN\n/* The host byte order is the same as network byte order,\n   so these functions are all just identity.  */\n# define ntohl(x)\t__uint32_identity (x)\n# define ntohs(x)\t__uint16_identity (x)\n# define htonl(x)\t__uint32_identity (x)\n# define htons(x)\t__uint16_identity (x)\n# else\n#  if __BYTE_ORDER == __LITTLE_ENDIAN\n#   define ntohl(x)\t__bswap_32 (x)\n#   define ntohs(x)\t__bswap_16 (x)\n#   define htonl(x)\t__bswap_32 (x)\n#   define htons(x)\t__bswap_16 (x)\n#  endif\n# endif\n#endif\n\n#ifdef __GNUC__\n# define IN6_IS_ADDR_UNSPECIFIED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->__in6_u.__u6_addr32[0] == 0\t\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[1] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[2] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[3] == 0; }))\n\n# define IN6_IS_ADDR_LOOPBACK(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->__in6_u.__u6_addr32[0] == 0\t\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[1] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[2] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[3] == htonl (1); }))\n\n# define IN6_IS_ADDR_LINKLOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))\n\n# define IN6_IS_ADDR_SITELOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))\n\n# define IN6_IS_ADDR_V4MAPPED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->__in6_u.__u6_addr32[0] == 0\t\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[1] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); }))\n\n# define IN6_IS_ADDR_V4COMPAT(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->__in6_u.__u6_addr32[0] == 0\t\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[1] == 0\t\t\t\t      \\\n      && __a->__in6_u.__u6_addr32[2] == 0\t\t\t\t      \\\n      && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; }))\n\n# define IN6_ARE_ADDR_EQUAL(a,b) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      const struct in6_addr *__b = (const struct in6_addr *) (b);\t      \\\n      __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0]\t      \\\n      && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1]\t      \\\n      && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2]\t      \\\n      && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; }))\n#else\n# define IN6_IS_ADDR_UNSPECIFIED(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == 0)\n\n# define IN6_IS_ADDR_LOOPBACK(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == htonl (1))\n\n# define IN6_IS_ADDR_LINKLOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfe800000))\n\n# define IN6_IS_ADDR_SITELOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfec00000))\n\n# define IN6_IS_ADDR_V4MAPPED(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == htonl (0xffff)))\n\n# define IN6_IS_ADDR_V4COMPAT(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == 0)\t\t\t\t      \\\n\t && (ntohl (((const uint32_t *) (a))[3]) > 1))\n\n# define IN6_ARE_ADDR_EQUAL(a,b) \\\n\t((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])\t      \\\n\t && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \\\n\t && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \\\n\t && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))\n#endif\n\n#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)\n\n#ifdef __USE_MISC\n/* Bind socket to a privileged IP port.  */\nextern int bindresvport(int __sockfd, struct sockaddr_in *__sock_in) __THROW;\n\n/* The IPv6 version of this function.  */\nextern int bindresvport6(int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;\n#endif\n\n#define IN6_IS_ADDR_MC_NODELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))\n\n#define IN6_IS_ADDR_MC_LINKLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))\n\n#define IN6_IS_ADDR_MC_SITELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))\n\n#define IN6_IS_ADDR_MC_ORGLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))\n\n#define IN6_IS_ADDR_MC_GLOBAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))\n\n#ifdef __USE_GNU\nstruct cmsghdr;\t\t\t/* Forward declaration.  */\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* IPv6 packet information.  */\nstruct in6_pktinfo {\n\tstruct in6_addr ipi6_addr;\t/* src/dst IPv6 address */\n\tunsigned int ipi6_ifindex;\t/* send/recv interface index */\n};\n\n/* IPv6 MTU information.  */\nstruct ip6_mtuinfo {\n\tstruct sockaddr_in6 ip6m_addr;\t/* dst address including zone ID */\n\tuint32_t ip6m_mtu;\t/* path MTU in host byte order */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */\nextern int inet6_option_space(int __nbytes)\n__THROW __attribute_deprecated__;\nextern int inet6_option_init(void *__bp, struct cmsghdr **__cmsgp, int __type)\n__THROW __attribute_deprecated__;\nextern int inet6_option_append(struct cmsghdr *__cmsg, const uint8_t * __typep, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern uint8_t *inet6_option_alloc(struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern int inet6_option_next(const struct cmsghdr *__cmsg, uint8_t ** __tptrp)\n__THROW __attribute_deprecated__;\nextern int inet6_option_find(const struct cmsghdr *__cmsg, uint8_t ** __tptrp, int __type)\n__THROW __attribute_deprecated__;\n\n/* Hop-by-Hop and Destination Options Processing (RFC 3542).  */\nextern int inet6_opt_init(void *__extbuf, socklen_t __extlen) __THROW;\nextern int inet6_opt_append(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;\nextern int inet6_opt_finish(void *__extbuf, socklen_t __extlen, int __offset) __THROW;\nextern int inet6_opt_set_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\nextern int inet6_opt_next(void *__extbuf, socklen_t __extlen, int __offset, uint8_t * __typep, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_find(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_get_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\n\n/* Routing Header Option (RFC 3542).  */\nextern socklen_t inet6_rth_space(int __type, int __segments) __THROW;\nextern void *inet6_rth_init(void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW;\nextern int inet6_rth_add(void *__bp, const struct in6_addr *__addr) __THROW;\nextern int inet6_rth_reverse(const void *__in, void *__out) __THROW;\nextern int inet6_rth_segments(const void *__bp) __THROW;\nextern struct in6_addr *inet6_rth_getaddr(const void *__bp, int __index) __THROW;\n\n/* Multicast source filter support.  */\n\n/* Get IPv4 source filter.  */\nextern int getipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t * __fmode, uint32_t * __numsrc, struct in_addr *__slist) __THROW;\n\n/* Set IPv4 source filter.  */\nextern int setipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t __fmode, uint32_t __numsrc, const struct in_addr *__slist) __THROW;\n\n/* Get source filter.  */\nextern int getsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t * __fmode, uint32_t * __numsrc, struct sockaddr_storage *__slist) __THROW;\n\n/* Set source filter.  */\nextern int setsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t __fmode, uint32_t __numsrc, const struct sockaddr_storage *__slist) __THROW;\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netinet/in.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/pthread.h",
    "content": "/* Copyright (C) 2002-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _PTHREAD_H\n#define _PTHREAD_H\t1\n\n#include <features.h>\n#include <endian.h>\n#include <sched.h>\n#include <time.h>\n\n#include <bits/pthreadtypes.h>\n#include <bits/setjmp.h>\n#include <bits/wordsize.h>\n#include <bits/types/struct_timespec.h>\n\n/* Detach state.  */\nenum {\n\tPTHREAD_CREATE_JOINABLE,\n#define PTHREAD_CREATE_JOINABLE\tPTHREAD_CREATE_JOINABLE\n\tPTHREAD_CREATE_DETACHED\n#define PTHREAD_CREATE_DETACHED\tPTHREAD_CREATE_DETACHED\n};\n\n/* Mutex types.  */\nenum {\n\tPTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_ADAPTIVE_NP\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n\t    ,\n\tPTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL\n#endif\n#ifdef __USE_GNU\n\t    /* For compatibility.  */\n\t    , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP\n#endif\n};\n\n#ifdef __USE_XOPEN2K\n/* Robust mutex or not flags.  */\nenum {\n\tPTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_ROBUST,\n\tPTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST\n};\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Mutex protocols.  */\nenum {\n\tPTHREAD_PRIO_NONE,\n\tPTHREAD_PRIO_INHERIT,\n\tPTHREAD_PRIO_PROTECT\n};\n#endif\n\n#if __PTHREAD_MUTEX_HAVE_PREV\n# define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }\n# ifdef __USE_GNU\n#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n\n# endif\n#else\n# define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }\n# ifdef __USE_GNU\n#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }\n#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }\n#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }\n\n# endif\n#endif\n\n/* Read-write lock types.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\nenum {\n\tPTHREAD_RWLOCK_PREFER_READER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\n\tPTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP\n};\n\n/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t\n   has the shared field.  All 64-bit architectures have the shared field\n   in pthread_rwlock_t.  */\n#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n# if __WORDSIZE == 64\n#  define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1\n# endif\n#endif\n\n/* Read-write lock initializers.  */\n# define PTHREAD_RWLOCK_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n# ifdef __USE_GNU\n#  ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0,\t\t\t\t\t      \\\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }\n#  else\n#   if __BYTE_ORDER == __LITTLE_ENDIAN\n#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \\\n      0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n#   else\n#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\\\n      0 } }\n#   endif\n#  endif\n# endif\n#endif\t\t\t\t/* Unix98 or XOpen2K */\n\n/* Scheduler inheritance.  */\nenum {\n\tPTHREAD_INHERIT_SCHED,\n#define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED\n\tPTHREAD_EXPLICIT_SCHED\n#define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED\n};\n\n/* Scope handling.  */\nenum {\n\tPTHREAD_SCOPE_SYSTEM,\n#define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM\n\tPTHREAD_SCOPE_PROCESS\n#define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS\n};\n\n/* Process shared or private flag.  */\nenum {\n\tPTHREAD_PROCESS_PRIVATE,\n#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE\n\tPTHREAD_PROCESS_SHARED\n#define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED\n};\n\n/* Conditional variable handling.  */\n#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }\n\n/* Cleanup buffers */\nstruct _pthread_cleanup_buffer {\n\tvoid (*__routine) (void *);\t/* Function to call.  */\n\tvoid *__arg;\t\t/* Its argument.  */\n\tint __canceltype;\t/* Saved cancellation type. */\n\tstruct _pthread_cleanup_buffer *__prev;\t/* Chaining of cleanup functions.  */\n};\n\n/* Cancellation */\nenum {\n\tPTHREAD_CANCEL_ENABLE,\n#define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE\n\tPTHREAD_CANCEL_DISABLE\n#define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE\n};\nenum {\n\tPTHREAD_CANCEL_DEFERRED,\n#define PTHREAD_CANCEL_DEFERRED\tPTHREAD_CANCEL_DEFERRED\n\tPTHREAD_CANCEL_ASYNCHRONOUS\n#define PTHREAD_CANCEL_ASYNCHRONOUS\tPTHREAD_CANCEL_ASYNCHRONOUS\n};\n#define PTHREAD_CANCELED ((void *) -1)\n\n/* Single execution handling.  */\n#define PTHREAD_ONCE_INIT 0\n\n#ifdef __USE_XOPEN2K\n/* Value returned by 'pthread_barrier_wait' for one of the threads after\n   the required number of threads have called this function.\n   -1 is distinct from 0 and all errno constants */\n# define PTHREAD_BARRIER_SERIAL_THREAD -1\n#endif\n\n__BEGIN_DECLS\n/* Create a new thread, starting with execution of START-ROUTINE\n   getting passed ARG.  Creation attributed come from ATTR.  The new\n   handle is stored in *NEWTHREAD.  */\nextern int pthread_create(pthread_t * __restrict __newthread, const pthread_attr_t * __restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg)\n__THROWNL __nonnull((1, 3));\n\n/* Terminate calling thread.\n\n   The registered cleanup handlers are called via exception handling\n   so we cannot mark this function with __THROW.*/\nextern void pthread_exit(void *__retval) __attribute__ ((__noreturn__));\n\n/* Make calling thread wait for termination of the thread TH.  The\n   exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN\n   is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_join(pthread_t __th, void **__thread_return);\n\n#ifdef __USE_GNU\n/* Check whether thread TH has terminated.  If yes return the status of\n   the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */\nextern int pthread_tryjoin_np(pthread_t __th, void **__thread_return) __THROW;\n\n/* Make calling thread wait for termination of the thread TH, but only\n   until TIMEOUT.  The exit status of the thread is stored in\n   *THREAD_RETURN, if THREAD_RETURN is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_timedjoin_np(pthread_t __th, void **__thread_return, const struct timespec *__abstime);\n#endif\n\n/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.\n   The resources of TH will therefore be freed immediately when it\n   terminates, instead of waiting for another thread to perform PTHREAD_JOIN\n   on it.  */\nextern int pthread_detach(pthread_t __th) __THROW;\n\n/* Obtain the identifier of the current thread.  */\nextern pthread_t pthread_self(void)\n__THROW __attribute__ ((__const__));\n\n/* Compare two thread identifiers.  */\nextern int pthread_equal(pthread_t __thread1, pthread_t __thread2)\n__THROW __attribute__ ((__const__));\n\n/* Thread attribute handling.  */\n\n/* Initialize thread attribute *ATTR with default attributes\n   (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,\n    no user-provided stack).  */\nextern int pthread_attr_init(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy thread attribute *ATTR.  */\nextern int pthread_attr_destroy(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get detach state attribute.  */\nextern int pthread_attr_getdetachstate(const pthread_attr_t * __attr, int *__detachstate)\n__THROW __nonnull((1, 2));\n\n/* Set detach state attribute.  */\nextern int pthread_attr_setdetachstate(pthread_attr_t * __attr, int __detachstate)\n__THROW __nonnull((1));\n\n/* Get the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_getguardsize(const pthread_attr_t * __attr, size_t * __guardsize)\n__THROW __nonnull((1, 2));\n\n/* Set the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_setguardsize(pthread_attr_t * __attr, size_t __guardsize)\n__THROW __nonnull((1));\n\n/* Return in *PARAM the scheduling parameters of *ATTR.  */\nextern int pthread_attr_getschedparam(const pthread_attr_t * __restrict __attr, struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */\nextern int pthread_attr_setschedparam(pthread_attr_t * __restrict __attr, const struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Return in *POLICY the scheduling policy of *ATTR.  */\nextern int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict __attr, int *__restrict __policy)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling policy in *ATTR according to POLICY.  */\nextern int pthread_attr_setschedpolicy(pthread_attr_t * __attr, int __policy)\n__THROW __nonnull((1));\n\n/* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */\nextern int pthread_attr_getinheritsched(const pthread_attr_t * __restrict __attr, int *__restrict __inherit)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling inheritance mode in *ATTR according to INHERIT.  */\nextern int pthread_attr_setinheritsched(pthread_attr_t * __attr, int __inherit)\n__THROW __nonnull((1));\n\n/* Return in *SCOPE the scheduling contention scope of *ATTR.  */\nextern int pthread_attr_getscope(const pthread_attr_t * __restrict __attr, int *__restrict __scope)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling contention scope in *ATTR according to SCOPE.  */\nextern int pthread_attr_setscope(pthread_attr_t * __attr, int __scope)\n__THROW __nonnull((1));\n\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstackaddr(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr)\n__THROW __nonnull((1, 2)) __attribute_deprecated__;\n\n/* Set the starting address of the stack of the thread to be created.\n   Depending on whether the stack grows up or down the value must either\n   be higher or lower than all the address in the memory block.  The\n   minimal size of the block must be PTHREAD_STACK_MIN.  */\nextern int pthread_attr_setstackaddr(pthread_attr_t * __attr, void *__stackaddr)\n__THROW __nonnull((1)) __attribute_deprecated__;\n\n/* Return the currently used minimal stack size.  */\nextern int pthread_attr_getstacksize(const pthread_attr_t * __restrict __attr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2));\n\n/* Add information about the minimum stack size needed for the thread\n   to be started.  This size must never be less than PTHREAD_STACK_MIN\n   and must also not exceed the system limits.  */\nextern int pthread_attr_setstacksize(pthread_attr_t * __attr, size_t __stacksize)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstack(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2, 3));\n\n/* The following two interfaces are intended to replace the last two.  They\n   require setting the address as well as the size since only setting the\n   address will make the implementation on some architectures impossible.  */\nextern int pthread_attr_setstack(pthread_attr_t * __attr, void *__stackaddr, size_t __stacksize)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_GNU\n/* Thread created with attribute ATTR will be limited to run only on\n   the processors represented in CPUSET.  */\nextern int pthread_attr_setaffinity_np(pthread_attr_t * __attr, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get bit set in CPUSET representing the processors threads created with\n   ATTR can run on.  */\nextern int pthread_attr_getaffinity_np(const pthread_attr_t * __attr, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get the default attributes used by pthread_create in this process.  */\nextern int pthread_getattr_default_np(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Set the default attributes to be used by pthread_create in this\n   process.  */\nextern int pthread_setattr_default_np(const pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Initialize thread attribute *ATTR with attributes corresponding to the\n   already running thread TH.  It shall be called on uninitialized ATTR\n   and destroyed with pthread_attr_destroy when no longer needed.  */\nextern int pthread_getattr_np(pthread_t __th, pthread_attr_t * __attr)\n__THROW __nonnull((2));\n#endif\n\n/* Functions for scheduling control.  */\n\n/* Set the scheduling parameters for TARGET_THREAD according to POLICY\n   and *PARAM.  */\nextern int pthread_setschedparam(pthread_t __target_thread, int __policy, const struct sched_param *__param)\n__THROW __nonnull((3));\n\n/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */\nextern int pthread_getschedparam(pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param)\n__THROW __nonnull((2, 3));\n\n/* Set the scheduling priority for TARGET_THREAD.  */\nextern int pthread_setschedprio(pthread_t __target_thread, int __prio) __THROW;\n\n#ifdef __USE_GNU\n/* Get thread name visible in the kernel and its interfaces.  */\nextern int pthread_getname_np(pthread_t __target_thread, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Set thread name visible in the kernel and its interfaces.  */\nextern int pthread_setname_np(pthread_t __target_thread, const char *__name)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_UNIX98\n/* Determine level of concurrency.  */\nextern int pthread_getconcurrency(void) __THROW;\n\n/* Set new concurrency level to LEVEL.  */\nextern int pthread_setconcurrency(int __level) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Yield the processor to another thread or process.\n   This function is similar to the POSIX `sched_yield' function but\n   might be differently implemented in the case of a m-on-n thread\n   implementation.  */\nextern int pthread_yield(void) __THROW;\n\n/* Limit specified thread TH to run only on the processors represented\n   in CPUSET.  */\nextern int pthread_setaffinity_np(pthread_t __th, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n\n/* Get bit set in CPUSET representing the processors TH can run on.  */\nextern int pthread_getaffinity_np(pthread_t __th, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n#endif\n\n/* Functions for handling initialization.  */\n\n/* Guarantee that the initialization function INIT_ROUTINE will be called\n   only once, even if pthread_once is executed several times with the\n   same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or\n   extern variable initialized to PTHREAD_ONCE_INIT.\n\n   The initialization functions might throw exception which is why\n   this function is not marked with __THROW.  */\nextern int pthread_once(pthread_once_t * __once_control, void (*__init_routine) (void)) __nonnull((1, 2));\n\n/* Functions for handling cancellation.\n\n   Note that these functions are explicitly not marked to not throw an\n   exception in C++ code.  If cancellation is implemented by unwinding\n   this is necessary to have the compiler generate the unwind information.  */\n\n/* Set cancelability state of current thread to STATE, returning old\n   state in *OLDSTATE if OLDSTATE is not NULL.  */\nextern int pthread_setcancelstate(int __state, int *__oldstate);\n\n/* Set cancellation state of current thread to TYPE, returning the old\n   type in *OLDTYPE if OLDTYPE is not NULL.  */\nextern int pthread_setcanceltype(int __type, int *__oldtype);\n\n/* Cancel THREAD immediately or at the next possibility.  */\nextern int pthread_cancel(pthread_t __th);\n\n/* Test for pending cancellation for the current thread and terminate\n   the thread as per pthread_exit(PTHREAD_CANCELED) if it has been\n   cancelled.  */\nextern void pthread_testcancel(void);\n\n/* Cancellation handling with integration into exception handling.  */\n\ntypedef struct {\n\tstruct {\n\t\t__jmp_buf __cancel_jmp_buf;\n\t\tint __mask_was_saved;\n\t} __cancel_jmp_buf[1];\n\tvoid *__pad[4];\n} __pthread_unwind_buf_t __attribute__ ((__aligned__));\n\n/* No special attributes by default.  */\n#ifndef __cleanup_fct_attribute\n# define __cleanup_fct_attribute\n#endif\n\n/* Structure to hold the cleanup handler information.  */\nstruct __pthread_cleanup_frame {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n};\n\n#if defined __GNUC__ && defined __EXCEPTIONS\n# ifdef __cplusplus\n/* Class to handle cancellation handler invocation.  */\nclass __pthread_cleanup_class {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n\n public:\n\t__pthread_cleanup_class(void (*__fct) (void *), void *__arg)\n\t:__cancel_routine(__fct), __cancel_arg(__arg), __do_it(1)\n{\n} ~__pthread_cleanup_class() {\n\t\tif (__do_it)\n\t\t\t__cancel_routine(__cancel_arg);\n}\nvoid __setdoit(int __newval) {\n\t__do_it = __newval;\n}\nvoid __defer() {\n\tpthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &__cancel_type);\n}\nvoid __restore() const {\n\tpthread_setcanceltype(__cancel_type, 0);\n}};\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#  define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg)\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#  define pthread_cleanup_pop(execute) \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#  ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#   define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg);\t\t\t      \\\n    __clframe.__defer ()\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#   define pthread_cleanup_pop_restore_np(execute) \\\n    __clframe.__restore ();\t\t\t\t\t\t      \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n#  endif\n# else\n/* Function called to call the cleanup handler.  As an extern inline\n   function the compiler is free to decide inlining the change when\n   needed or fall back on the copy which must exist somewhere\n   else.  */\n__extern_inline void __pthread_cleanup_routine(struct __pthread_cleanup_frame *__frame)\n{\n\tif (__frame->__do_it)\n\t\t__frame->__cancel_routine(__frame->__cancel_arg);\n}\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#  define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t \t      \\\n\t  .__do_it = 1 };\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#  define pthread_cleanup_pop(execute) \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#  ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#   define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t\t      \\\n\t  .__do_it = 1 };\t\t\t\t\t\t      \\\n    (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,\t\t      \\\n\t\t\t\t  &__clframe.__cancel_type)\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#   define pthread_cleanup_pop_restore_np(execute) \\\n    (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);\t      \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n#  endif\n# endif\n#else\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n# define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel (&__cancel_buf);\t\t\t\t      \\\n    do {\nextern void __pthread_register_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n# define pthread_cleanup_pop(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel (&__cancel_buf);\t\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n# ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#  define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel_defer (&__cancel_buf);\t\t\t      \\\n    do {\nextern void __pthread_register_cancel_defer(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#  define pthread_cleanup_pop_restore_np(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel_restore (&__cancel_buf);\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel_restore(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n# endif\n\n/* Internal interface to initiate cleanup.  */\nextern void __pthread_unwind_next(__pthread_unwind_buf_t * __buf)\n__cleanup_fct_attribute __attribute__ ((__noreturn__))\n# ifndef SHARED\n    __attribute__ ((__weak__))\n# endif\n    ;\n#endif\n\n/* Function used in the macros.  */\nstruct __jmp_buf_tag;\nextern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask) __THROWNL;\n\n/* Mutex handling.  */\n\n/* Initialize a mutex.  */\nextern int pthread_mutex_init(pthread_mutex_t * __mutex, const pthread_mutexattr_t * __mutexattr)\n__THROW __nonnull((1));\n\n/* Destroy a mutex.  */\nextern int pthread_mutex_destroy(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n\n/* Try locking a mutex.  */\nextern int pthread_mutex_trylock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Lock a mutex.  */\nextern int pthread_mutex_lock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Wait until lock becomes available, or specified time passes. */\nextern int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n#endif\n\n/* Unlock a mutex.  */\nextern int pthread_mutex_unlock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Get the priority ceiling of MUTEX.  */\nextern int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the priority ceiling of MUTEX to PRIOCEILING, return old\n   priority ceiling value in *OLD_CEILING.  */\nextern int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict __mutex, int __prioceiling, int *__restrict __old_ceiling)\n__THROW __nonnull((1, 3));\n\n#ifdef __USE_XOPEN2K8\n/* Declare the state protected by MUTEX as consistent.  */\nextern int pthread_mutex_consistent(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n# ifdef __USE_GNU\nextern int pthread_mutex_consistent_np(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n# endif\n#endif\n\n/* Functions for handling mutex attributes.  */\n\n/* Initialize mutex attribute object ATTR with default attributes\n   (kind is PTHREAD_MUTEX_TIMED_NP).  */\nextern int pthread_mutexattr_init(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy mutex attribute object ATTR.  */\nextern int pthread_mutexattr_destroy(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setpshared(pthread_mutexattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n/* Return in *KIND the mutex kind attribute in *ATTR.  */\nextern int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict __attr, int *__restrict __kind)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,\n   PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or\n   PTHREAD_MUTEX_DEFAULT).  */\nextern int pthread_mutexattr_settype(pthread_mutexattr_t * __attr, int __kind)\n__THROW __nonnull((1));\n#endif\n\n/* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */\nextern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either\n   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */\nextern int pthread_mutexattr_setprotocol(pthread_mutexattr_t * __attr, int __protocol)\n__THROW __nonnull((1));\n\n/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */\nextern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */\nextern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t * __attr, int __prioceiling)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getrobust(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n# ifdef __USE_GNU\nextern int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n# endif\n\n/* Set the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setrobust(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n# ifdef __USE_GNU\nextern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n# endif\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Functions for handling read-write locks.  */\n\n/* Initialize read-write lock RWLOCK using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, const pthread_rwlockattr_t * __restrict __attr)\n__THROW __nonnull((1));\n\n/* Destroy read-write lock RWLOCK.  */\nextern int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock)\n__THROW __nonnull((1));\n\n/* Acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n# ifdef __USE_XOPEN2K\n/* Try to acquire read lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n# endif\n\n/* Acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n# ifdef __USE_XOPEN2K\n/* Try to acquire write lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n# endif\n\n/* Unlock RWLOCK.  */\nextern int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Functions for handling read-write lock attributes.  */\n\n/* Initialize attribute object ATTR with default values.  */\nextern int pthread_rwlockattr_init(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy attribute object ATTR.  */\nextern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Return current setting of process-shared attribute of ATTR in PSHARED.  */\nextern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set process-shared attribute of ATTR to PSHARED.  */\nextern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n/* Return current setting of reader/writer preference.  */\nextern int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref)\n__THROW __nonnull((1, 2));\n\n/* Set reader/write preference.  */\nextern int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t * __attr, int __pref)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling conditional variables.  */\n\n/* Initialize condition variable COND using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_cond_init(pthread_cond_t * __restrict __cond, const pthread_condattr_t * __restrict __cond_attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable COND.  */\nextern int pthread_cond_destroy(pthread_cond_t * __cond)\n__THROW __nonnull((1));\n\n/* Wake up one thread waiting for condition variable COND.  */\nextern int pthread_cond_signal(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wake up all threads waiting for condition variables COND.  */\nextern int pthread_cond_broadcast(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wait for condition variable COND to be signaled or broadcast.\n   MUTEX is assumed to be locked before.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_wait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex) __nonnull((1, 2));\n\n/* Wait for condition variable COND to be signaled or broadcast until\n   ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an\n   absolute time specification; zero is the beginning of the epoch\n   (00:00:00 GMT, January 1, 1970).\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_timedwait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime) __nonnull((1, 2, 3));\n\n/* Functions for handling condition variable attributes.  */\n\n/* Initialize condition variable attribute ATTR.  */\nextern int pthread_condattr_init(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable attribute ATTR.  */\nextern int pthread_condattr_destroy(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_getpshared(const pthread_condattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_setpshared(pthread_condattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_getclock(const pthread_condattr_t * __restrict __attr, __clockid_t * __restrict __clock_id)\n__THROW __nonnull((1, 2));\n\n/* Set the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_setclock(pthread_condattr_t * __attr, __clockid_t __clock_id)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Functions to handle spinlocks.  */\n\n/* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can\n   be shared between different processes.  */\nextern int pthread_spin_init(pthread_spinlock_t * __lock, int __pshared)\n__THROW __nonnull((1));\n\n/* Destroy the spinlock LOCK.  */\nextern int pthread_spin_destroy(pthread_spinlock_t * __lock)\n__THROW __nonnull((1));\n\n/* Wait until spinlock LOCK is retrieved.  */\nextern int pthread_spin_lock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Try to lock spinlock LOCK.  */\nextern int pthread_spin_trylock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Release spinlock LOCK.  */\nextern int pthread_spin_unlock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Functions to handle barriers.  */\n\n/* Initialize BARRIER with the attributes in ATTR.  The barrier is\n   opened when COUNT waiters arrived.  */\nextern int pthread_barrier_init(pthread_barrier_t * __restrict __barrier, const pthread_barrierattr_t * __restrict __attr, unsigned int __count)\n__THROW __nonnull((1));\n\n/* Destroy a previously dynamically initialized barrier BARRIER.  */\nextern int pthread_barrier_destroy(pthread_barrier_t * __barrier)\n__THROW __nonnull((1));\n\n/* Wait on barrier BARRIER.  */\nextern int pthread_barrier_wait(pthread_barrier_t * __barrier)\n__THROWNL __nonnull((1));\n\n/* Initialize barrier attribute ATTR.  */\nextern int pthread_barrierattr_init(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy previously dynamically initialized barrier attribute ATTR.  */\nextern int pthread_barrierattr_destroy(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_setpshared(pthread_barrierattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling thread-specific data.  */\n\n/* Create a key value identifying a location in the thread-specific\n   data area.  Each thread maintains a distinct thread-specific data\n   area.  DESTR_FUNCTION, if non-NULL, is called with the value\n   associated to that key when the key is destroyed.\n   DESTR_FUNCTION is not called if the value associated is NULL when\n   the key is destroyed.  */\nextern int pthread_key_create(pthread_key_t * __key, void (*__destr_function) (void *))\n__THROW __nonnull((1));\n\n/* Destroy KEY.  */\nextern int pthread_key_delete(pthread_key_t __key) __THROW;\n\n/* Return current value of the thread-specific data slot identified by KEY.  */\nextern void *pthread_getspecific(pthread_key_t __key) __THROW;\n\n/* Store POINTER in the thread-specific data slot identified by KEY. */\nextern int pthread_setspecific(pthread_key_t __key, const void *__pointer) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Get ID of CPU-time clock for thread THREAD_ID.  */\nextern int pthread_getcpuclockid(pthread_t __thread_id, __clockid_t * __clock_id)\n__THROW __nonnull((2));\n#endif\n\n/* Install handlers to be called when a new process is created with FORK.\n   The PREPARE handler is called in the parent process just before performing\n   FORK. The PARENT handler is called in the parent process just after FORK.\n   The CHILD handler is called in the child process.  Each of the three\n   handlers can be NULL, meaning that no handler needs to be called at that\n   point.\n   PTHREAD_ATFORK can be called several times, in which case the PREPARE\n   handlers are called in LIFO order (last added with PTHREAD_ATFORK,\n   first called before FORK), and the PARENT and CHILD handlers are called\n   in FIFO (first added, first called).  */\n\nextern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n/* Optimizations.  */\n__extern_inline int __NTH(pthread_equal(pthread_t __thread1, pthread_t __thread2))\n{\n\treturn __thread1 == __thread2;\n}\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pthread.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/pwd.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.2 User Database Access\t<pwd.h>\n */\n\n#ifndef\t_PWD_H\n#define\t_PWD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\n\n/* The passwd structure.  */\nstruct passwd {\n\tchar *pw_name;\t\t/* Username.  */\n\tchar *pw_passwd;\t/* Password.  */\n\t__uid_t pw_uid;\t\t/* User ID.  */\n\t__gid_t pw_gid;\t\t/* Group ID.  */\n\tchar *pw_gecos;\t\t/* Real name.  */\n\tchar *pw_dir;\t\t/* Home directory.  */\n\tchar *pw_shell;\t\t/* Shell program.  */\n};\n\n#ifdef __USE_MISC\n# include <bits/types/FILE.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setpwent(void);\n\n/* Close the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endpwent(void);\n\n/* Read an entry from the password-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read an entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct passwd *fgetpwent(FILE * __stream) __nonnull((1));\n\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putpwent(const struct passwd *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching user ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwuid(__uid_t __uid);\n\n/* Search for an entry with a matching username.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwnam(const char *__name) __nonnull((1));\n\n#ifdef __USE_POSIX\n\n# ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#  define NSS_BUFLEN_PASSWD\t1024\n# endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.  */\n\n# ifdef __USE_MISC\n/* This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpwent_r(struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 4));\n# endif\n\nextern int getpwuid_r(__uid_t __uid, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((2, 3, 5));\n\nextern int getpwnam_r(const char *__restrict __name, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n\n# ifdef\t__USE_MISC\n/* Read an entry from STREAM.  This function is not standardized and\n   probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetpwent_r(FILE * __restrict __stream, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n# endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef __USE_GNU\n/* Re-construct the password-file line for the given uid\n   in the given buffer.  This knows the format that the caller\n   will expect, but this need not be the format of the password file.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpw(__uid_t __uid, char *__buffer);\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pwd.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/rpc/netdb.h",
    "content": "/* @(#)netdb.h\t2.1 88/07/29 3.9 RPCSRC */\n/*\n * Copyright (c) 2010, Oracle America, Inc.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials\n *       provided with the distribution.\n *     * Neither the name of the \"Oracle America, Inc.\" nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Cleaned up for GNU C library roland@gnu.ai.mit.edu:\n   added multiple inclusion protection and use of <sys/cdefs.h>.\n   In GNU this file is #include'd by <netdb.h>.  */\n\n#ifndef _RPC_NETDB_H\n#define _RPC_NETDB_H\t1\n\n#include <features.h>\n\n#define __need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS struct rpcent {\n\tchar *r_name;\t\t/* Name of server for this rpc program.  */\n\tchar **r_aliases;\t/* Alias list.  */\n\tint r_number;\t\t/* RPC program number.  */\n};\n\nextern void setrpcent(int __stayopen) __THROW;\nextern void endrpcent(void) __THROW;\nextern struct rpcent *getrpcbyname(const char *__name) __THROW;\nextern struct rpcent *getrpcbynumber(int __number) __THROW;\nextern struct rpcent *getrpcent(void) __THROW;\n\n#ifdef __USE_MISC\nextern int getrpcbyname_r(const char *__name, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcbynumber_r(int __number, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcent_r(struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* rpc/netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/sched.h",
    "content": "/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.\n   Copyright (C) 1996-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SCHED_H\n#define\t_SCHED_H\t1\n\n#include <features.h>\n\n/* Get type definitions.  */\n#include <bits/types.h>\n\n#define __need_size_t\n#define __need_NULL\n#include <stddef.h>\n\n#include <bits/types/time_t.h>\n#include <bits/types/struct_timespec.h>\n#ifndef __USE_XOPEN2K\n# include <time.h>\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n/* Get system specific constant and data structure definitions.  */\n#include <bits/sched.h>\n#include <bits/cpu-set.h>\n\n/* Backward compatibility.  */\n#define sched_priority    sched_priority\n#define __sched_priority  sched_priority\n\n__BEGIN_DECLS\n/* Set scheduling parameters for a process.  */\nextern int sched_setparam(__pid_t __pid, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling parameters for a particular process.  */\nextern int sched_getparam(__pid_t __pid, struct sched_param *__param) __THROW;\n\n/* Set scheduling algorithm and/or parameters for a process.  */\nextern int sched_setscheduler(__pid_t __pid, int __policy, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling algorithm for a particular purpose.  */\nextern int sched_getscheduler(__pid_t __pid) __THROW;\n\n/* Yield the processor.  */\nextern int sched_yield(void) __THROW;\n\n/* Get maximum priority value for a scheduler.  */\nextern int sched_get_priority_max(int __algorithm) __THROW;\n\n/* Get minimum priority value for a scheduler.  */\nextern int sched_get_priority_min(int __algorithm) __THROW;\n\n/* Get the SCHED_RR interval for the named process.  */\nextern int sched_rr_get_interval(__pid_t __pid, struct timespec *__t) __THROW;\n\n#ifdef __USE_GNU\n/* Access macros for `cpu_set'.  */\n# define CPU_SETSIZE __CPU_SETSIZE\n# define CPU_SET(cpu, cpusetp)\t __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)\n# define CPU_CLR(cpu, cpusetp)\t __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)\n# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \\\n\t\t\t\t\t\tcpusetp)\n# define CPU_ZERO(cpusetp)\t __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)\n# define CPU_COUNT(cpusetp)\t __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)\n\n# define CPU_SET_S(cpu, setsize, cpusetp)   __CPU_SET_S (cpu, setsize, cpusetp)\n# define CPU_CLR_S(cpu, setsize, cpusetp)   __CPU_CLR_S (cpu, setsize, cpusetp)\n# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \\\n\t\t\t\t\t\t\t   cpusetp)\n# define CPU_ZERO_S(setsize, cpusetp)\t    __CPU_ZERO_S (setsize, cpusetp)\n# define CPU_COUNT_S(setsize, cpusetp)\t    __CPU_COUNT_S (setsize, cpusetp)\n\n# define CPU_EQUAL(cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)\n# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)\n\n# define CPU_AND(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)\n# define CPU_OR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)\n# define CPU_XOR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)\n# define CPU_AND_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, &)\n# define CPU_OR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, |)\n# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)\n\n# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)\n# define CPU_ALLOC(count) __CPU_ALLOC (count)\n# define CPU_FREE(cpuset) __CPU_FREE (cpuset)\n\n/* Set the CPU affinity for a task */\nextern int sched_setaffinity(__pid_t __pid, size_t __cpusetsize, const cpu_set_t * __cpuset) __THROW;\n\n/* Get the CPU affinity for a task */\nextern int sched_getaffinity(__pid_t __pid, size_t __cpusetsize, cpu_set_t * __cpuset) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sched.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/setjmp.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.13 Nonlocal jumps\t<setjmp.h>\n */\n\n#ifndef\t_SETJMP_H\n#define\t_SETJMP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/setjmp.h>\t/* Get `__jmp_buf'.  */\n#include <bits/types/__sigset_t.h>\n/* Calling environment, plus possibly a saved signal mask.  */\n    struct __jmp_buf_tag {\n\t/* NOTE: The machine-dependent definitions of `__sigsetjmp'\n\t   assume that a `jmp_buf' begins with a `__jmp_buf' and that\n\t   `__mask_was_saved' follows it.  Do not move these members\n\t   or add others before it.  */\n\t__jmp_buf __jmpbuf;\t/* Calling environment.  */\n\tint __mask_was_saved;\t/* Saved the signal mask?  */\n\t__sigset_t __saved_mask;\t/* Saved signal mask.  */\n};\n\ntypedef struct __jmp_buf_tag jmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the signal mask.\n   Return 0.  */\nextern int setjmp(jmp_buf __env) __THROWNL;\n\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.\n   This is the internal name for `sigsetjmp'.  */\nextern int __sigsetjmp(struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;\n\n/* Store the calling environment in ENV, not saving the signal mask.\n   Return 0.  */\nextern int _setjmp(struct __jmp_buf_tag __env[1]) __THROWNL;\n\n/* Do not save the signal mask.  This is equivalent to the `_setjmp'\n   BSD function.  */\n#define setjmp(env)\t_setjmp (env)\n\n/* Jump to the environment saved in ENV, making the\n   `setjmp' call there return VAL, or 1 if VAL is 0.  */\nextern void longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Same.  Usually `_longjmp' is used with `_setjmp', which does not save\n   the signal mask.  But it is how ENV was saved that determines whether\n   `longjmp' restores the mask; `_longjmp' is just an alias.  */\nextern void _longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\n\n#ifdef\t__USE_POSIX\n/* Use the same type for `jmp_buf' and `sigjmp_buf'.\n   The `__mask_was_saved' flag determines whether\n   or not `longjmp' will restore the signal mask.  */\ntypedef struct __jmp_buf_tag sigjmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.  */\n# define sigsetjmp(env, savemask)\t__sigsetjmp (env, savemask)\n\n/* Jump to the environment saved in ENV, making the\n   sigsetjmp call there return VAL, or 1 if VAL is 0.\n   Restore the signal mask if that sigsetjmp call saved it.\n   This is just an alias `longjmp'.  */\nextern void siglongjmp(sigjmp_buf __env, int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\t\t\t\t/* Use POSIX.  */\n\n/* Define helper functions to catch unsafe code.  */\n#if __USE_FORTIFY_LEVEL > 0\n# include <bits/setjmp2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* setjmp.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/signal.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.14 Signal handling <signal.h>\n */\n\n#ifndef\t_SIGNAL_H\n#define _SIGNAL_H\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#include <bits/signum.h>\n#include <bits/types/sig_atomic_t.h>\n#if defined __USE_POSIX\n#include <bits/types/sigset_t.h>\n#endif\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n#endif\n#ifdef __USE_XOPEN\n# endif\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\t\t\t\t/* Unix98 */\n\n#ifdef __USE_POSIX199309\n/* We need `struct timespec' later on.  */\n# include <bits/types/struct_timespec.h>\n#endif\n\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\n# include <bits/types/siginfo_t.h>\n# include <bits/siginfo-consts.h>\n#endif\n\n#ifdef __USE_MISC\n# include <bits/types/sigval_t.h>\n#endif\n\n#ifdef __USE_POSIX199309\n# include <bits/types/sigevent_t.h>\n# include <bits/sigevent-consts.h>\n#endif\n\n/* Type of a signal handler.  */\ntypedef void (*__sighandler_t) (int);\n\n/* The X/Open definition of `signal' specifies the SVID semantic.  Use\n   the additional function `sysv_signal' when X/Open compatibility is\n   requested.  */\nextern __sighandler_t __sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#ifdef __USE_GNU\nextern __sighandler_t sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Set the handler for the signal SIG to HANDLER, returning the old\n   handler, or SIG_ERR on error.\n   By default `signal' has the BSD semantic.  */\n#ifdef __USE_MISC\nextern __sighandler_t signal(int __sig, __sighandler_t __handler) __THROW;\n#else\n/* Make sure the used `signal' implementation is the SVID version. */\n# ifdef __REDIRECT_NTH\nextern __sighandler_t __REDIRECT_NTH(signal, (int __sig, __sighandler_t __handler), __sysv_signal);\n# else\n#  define signal __sysv_signal\n# endif\n#endif\n\n#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8\n/* The X/Open definition of `signal' conflicts with the BSD version.\n   So they defined another function `bsd_signal'.  */\nextern __sighandler_t bsd_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Send signal SIG to process number PID.  If PID is zero,\n   send SIG to all processes in the current process's process group.\n   If PID is < -1, send SIG to all processes in process group - PID.  */\n#ifdef __USE_POSIX\nextern int kill(__pid_t __pid, int __sig) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Send SIG to all processes in process group PGRP.\n   If PGRP is zero, send SIG to all processes in\n   the current process's process group.  */\nextern int killpg(__pid_t __pgrp, int __sig) __THROW;\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n/* Raise signal SIG, i.e., send SIG to yourself.  */\nextern int raise(int __sig) __THROW;\n\n#ifdef __USE_MISC\n/* SVID names for the same things.  */\nextern __sighandler_t ssignal(int __sig, __sighandler_t __handler) __THROW;\nextern int gsignal(int __sig) __THROW;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_XOPEN2K8\n/* Print a message describing the meaning of the given signal number.  */\nextern void psignal(int __sig, const char *__s);\n\n/* Print a message describing the meaning of the given signal information.  */\nextern void psiginfo(const siginfo_t * __pinfo, const char *__s);\n#endif\t\t\t\t/* POSIX 2008.  */\n\n/* The `sigpause' function in X/Open defines the argument as the\n   signal number.  This requires redirecting to another function\n   because the default version in glibc uses an old BSD interface.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n#ifdef __USE_XOPEN_EXTENDED\n# ifdef __GNUC__\nextern int sigpause(int __sig) __asm__(\"__xpg_sigpause\");\n# else\nextern int __sigpause(int __sig_or_mask, int __is_sig);\n/* Remove a signal from the signal mask and suspend the process.  */\n#  define sigpause(sig) __sigpause ((sig), 1)\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* None of the following functions should be used anymore.  They are here\n   only for compatibility.  A single word (`int') is not guaranteed to be\n   enough to hold a complete signal mask and therefore these functions\n   simply do not work in many situations.  Use `sigprocmask' instead.  */\n\n/* Compute mask for signal SIG.  */\n# define sigmask(sig) ((int)(1u << ((sig) - 1)))\n\n/* Block signals in MASK, returning the old mask.  */\nextern int sigblock(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Set the mask of blocked signals to MASK, returning the old mask.  */\nextern int sigsetmask(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Return currently selected signal mask.  */\nextern int siggetmask(void)\n__THROW __attribute_deprecated__;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_MISC\n# define NSIG\t_NSIG\n#endif\n\n#ifdef __USE_GNU\ntypedef __sighandler_t sighandler_t;\n#endif\n\n/* 4.4 BSD uses the name `sig_t' for this.  */\n#ifdef __USE_MISC\ntypedef __sighandler_t sig_t;\n#endif\n\n#ifdef __USE_POSIX\n\n/* Clear all signals from SET.  */\nextern int sigemptyset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Set all signals in SET.  */\nextern int sigfillset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Add SIGNO to SET.  */\nextern int sigaddset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Remove SIGNO from SET.  */\nextern int sigdelset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Return 1 if SIGNO is in SET, 0 if not.  */\nextern int sigismember(const sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n# ifdef __USE_GNU\n/* Return non-empty value is SET is not empty.  */\nextern int sigisemptyset(const sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Build new signal set by combining the two inputs set using logical AND.  */\nextern int sigandset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n\n/* Build new signal set by combining the two inputs set using logical OR.  */\nextern int sigorset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n# endif\t\t\t\t/* GNU */\n\n/* Get the system-specific definitions of `struct sigaction'\n   and the `SA_*' and `SIG_*'. constants.  */\n# include <bits/sigaction.h>\n\n/* Get and/or change the set of blocked signals.  */\nextern int sigprocmask(int __how, const sigset_t * __restrict __set, sigset_t * __restrict __oset) __THROW;\n\n/* Change the set of blocked signals to SET,\n   wait until a signal arrives, and restore the set of blocked signals.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigsuspend(const sigset_t * __set) __nonnull((1));\n\n/* Get and/or set the action for signal SIG.  */\nextern int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __THROW;\n\n/* Put in SET all signals that are blocked and waiting to be delivered.  */\nextern int sigpending(sigset_t * __set)\n__THROW __nonnull((1));\n\n# ifdef __USE_POSIX199506\n/* Select any of pending signals from SET or wait for any to arrive.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwait(const sigset_t * __restrict __set, int *__restrict __sig) __nonnull((1, 2));\n# endif\t\t\t\t/* Use POSIX 1995.  */\n\n# ifdef __USE_POSIX199309\n/* Select any of pending signals from SET and place information in INFO.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwaitinfo(const sigset_t * __restrict __set, siginfo_t * __restrict __info) __nonnull((1));\n\n/* Select any of pending signals from SET and place information in INFO.\n   Wait the time specified by TIMEOUT if no signal is pending.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigtimedwait(const sigset_t * __restrict __set, siginfo_t * __restrict __info, const struct timespec *__restrict __timeout) __nonnull((1));\n\n/* Send signal SIG to the process PID.  Associate data in VAL with the\n   signal.  */\nextern int sigqueue(__pid_t __pid, int __sig, const union sigval __val) __THROW;\n# endif\t\t\t\t/* Use POSIX 199306.  */\n\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n\n/* Names of the signals.  This variable exists only for compatibility.\n   Use `strsignal' instead (see <string.h>).  */\nextern const char *const _sys_siglist[_NSIG];\nextern const char *const sys_siglist[_NSIG];\n\n/* Get machine-dependent `struct sigcontext' and signal subcodes.  */\n# include <bits/sigcontext.h>\n\n/* Restore the state saved in SCP.  */\nextern int sigreturn(struct sigcontext *__scp) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# define __need_size_t\n# include <stddef.h>\n\n# include <bits/types/stack_t.h>\n# if defined __USE_XOPEN || defined __USE_XOPEN2K8\n/* This will define `ucontext_t' and `mcontext_t'.  */\n#  include <sys/ucontext.h>\n# endif\n#endif\t\t\t\t/* Use POSIX.1-2008 or X/Open Unix.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC\n/* If INTERRUPT is nonzero, make signal SIG interrupt system calls\n   (causing them to fail with EINTR); if INTERRUPT is zero, make system\n   calls be restarted after signal SIG.  */\nextern int siginterrupt(int __sig, int __interrupt) __THROW;\n\n# include <bits/sigstack.h>\n# include <bits/ss_flags.h>\n\n/* Alternate signal handler stack interface.\n   This interface should always be preferred over `sigstack'.  */\nextern int sigaltstack(const stack_t * __restrict __ss, stack_t * __restrict __oss) __THROW;\n#endif\t\t\t\t/* __USE_XOPEN_EXTENDED || __USE_MISC */\n\n#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)\t\\\n     || defined __USE_MISC)\n# include <bits/types/struct_sigstack.h>\n#endif\n\n#if ((defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K)\t\\\n     || defined __USE_MISC)\n/* Run signals handlers on the stack specified by SS (if not NULL).\n   If OSS is not NULL, it is filled in with the old signal stack status.\n   This interface is obsolete and on many platform not implemented.  */\nextern int sigstack(struct sigstack *__ss, struct sigstack *__oss)\n__THROW __attribute_deprecated__;\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* Simplified interface for signal management.  */\n\n/* Add SIG to the calling process' signal mask.  */\nextern int sighold(int __sig) __THROW;\n\n/* Remove SIG from the calling process' signal mask.  */\nextern int sigrelse(int __sig) __THROW;\n\n/* Set the disposition of SIG to SIG_IGN.  */\nextern int sigignore(int __sig) __THROW;\n\n/* Set the disposition of SIG.  */\nextern __sighandler_t sigset(int __sig, __sighandler_t __disp) __THROW;\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Some of the functions for handling signals in threaded programs must\n   be defined here.  */\n# include <bits/pthreadtypes.h>\n# include <bits/sigthread.h>\n#endif\t\t\t\t/* use Unix98 */\n\n/* The following functions are used internally in the C library and in\n   other code which need deep insights.  */\n\n/* Return number of available real-time signal with highest priority.  */\nextern int __libc_current_sigrtmin(void) __THROW;\n/* Return number of available real-time signal with lowest priority.  */\nextern int __libc_current_sigrtmax(void) __THROW;\n\n#define SIGRTMIN        (__libc_current_sigrtmin ())\n#define SIGRTMAX        (__libc_current_sigrtmax ())\n\n__END_DECLS\n#endif\t\t\t\t/* not signal.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/stdc-predef.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STDC_PREDEF_H\n#define\t_STDC_PREDEF_H\t1\n\n/* This header is separate from features.h so that the compiler can\n   include it implicitly at the start of every compilation.  It must\n   not itself include <features.h> or any other header that includes\n   <features.h> because the implicit include comes before any feature\n   test macros that may be defined in a source file before it first\n   explicitly includes a system header.  GCC knows the name of this\n   header in order to preinclude it.  */\n\n/* glibc's intent is to support the IEC 559 math functionality, real\n   and complex.  If the GCC (4.9 and later) predefined macros\n   specifying compiler intent are available, use them to determine\n   whether the overall intent is to support these features; otherwise,\n   presume an older compiler has intent to support these features and\n   define these macros by default.  */\n\n#ifdef __GCC_IEC_559\n# if __GCC_IEC_559 > 0\n#  define __STDC_IEC_559__\t\t1\n# endif\n#else\n# define __STDC_IEC_559__\t\t1\n#endif\n\n#ifdef __GCC_IEC_559_COMPLEX\n# if __GCC_IEC_559_COMPLEX > 0\n#  define __STDC_IEC_559_COMPLEX__\t1\n# endif\n#else\n# define __STDC_IEC_559_COMPLEX__\t1\n#endif\n\n/* wchar_t uses Unicode 10.0.0.  Version 10.0 of the Unicode Standard is\n   synchronized with ISO/IEC 10646:2017, fifth edition, plus\n   the following additions from Amendment 1 to the fifth edition:\n   - 56 emoji characters\n   - 285 hentaigana\n   - 3 additional Zanabazar Square characters */\n#define __STDC_ISO_10646__\t\t201706L\n\n/* We do not support C11 <threads.h>.  */\n#define __STDC_NO_THREADS__\t\t1\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/stdint.h",
    "content": "/* Copyright (C) 1997-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.18 Integer types <stdint.h>\n */\n\n#ifndef _STDINT_H\n#define _STDINT_H\t1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n#include <bits/types.h>\n#include <bits/wchar.h>\n#include <bits/wordsize.h>\n\n/* Exact integral types.  */\n\n/* Signed.  */\n#include <bits/stdint-intn.h>\n\n/* Unsigned.  */\n#include <bits/stdint-uintn.h>\n\n/* Small types.  */\n\n/* Signed.  */\ntypedef signed char int_least8_t;\ntypedef short int int_least16_t;\ntypedef int int_least32_t;\n#if __WORDSIZE == 64\ntypedef long int int_least64_t;\n#else\n__extension__ typedef long long int int_least64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_least8_t;\ntypedef unsigned short int uint_least16_t;\ntypedef unsigned int uint_least32_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_least64_t;\n#else\n__extension__ typedef unsigned long long int uint_least64_t;\n#endif\n\n/* Fast types.  */\n\n/* Signed.  */\ntypedef signed char int_fast8_t;\n#if __WORDSIZE == 64\ntypedef long int int_fast16_t;\ntypedef long int int_fast32_t;\ntypedef long int int_fast64_t;\n#else\ntypedef int int_fast16_t;\ntypedef int int_fast32_t;\n__extension__ typedef long long int int_fast64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_fast8_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_fast16_t;\ntypedef unsigned long int uint_fast32_t;\ntypedef unsigned long int uint_fast64_t;\n#else\ntypedef unsigned int uint_fast16_t;\ntypedef unsigned int uint_fast32_t;\n__extension__ typedef unsigned long long int uint_fast64_t;\n#endif\n\n/* Types for `void *' pointers.  */\n#if __WORDSIZE == 64\n# ifndef __intptr_t_defined\ntypedef long int intptr_t;\n#  define __intptr_t_defined\n# endif\ntypedef unsigned long int uintptr_t;\n#else\n# ifndef __intptr_t_defined\ntypedef int intptr_t;\n#  define __intptr_t_defined\n# endif\ntypedef unsigned int uintptr_t;\n#endif\n\n/* Largest integral types.  */\ntypedef __intmax_t intmax_t;\ntypedef __uintmax_t uintmax_t;\n\n# if __WORDSIZE == 64\n#  define __INT64_C(c)\tc ## L\n#  define __UINT64_C(c)\tc ## UL\n# else\n#  define __INT64_C(c)\tc ## LL\n#  define __UINT64_C(c)\tc ## ULL\n# endif\n\n/* Limits of integral types.  */\n\n/* Minimum of signed integral types.  */\n# define INT8_MIN\t\t(-128)\n# define INT16_MIN\t\t(-32767-1)\n# define INT32_MIN\t\t(-2147483647-1)\n# define INT64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types.  */\n# define INT8_MAX\t\t(127)\n# define INT16_MAX\t\t(32767)\n# define INT32_MAX\t\t(2147483647)\n# define INT64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types.  */\n# define UINT8_MAX\t\t(255)\n# define UINT16_MAX\t\t(65535)\n# define UINT32_MAX\t\t(4294967295U)\n# define UINT64_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of signed integral types having a minimum size.  */\n# define INT_LEAST8_MIN\t\t(-128)\n# define INT_LEAST16_MIN\t(-32767-1)\n# define INT_LEAST32_MIN\t(-2147483647-1)\n# define INT_LEAST64_MIN\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types having a minimum size.  */\n# define INT_LEAST8_MAX\t\t(127)\n# define INT_LEAST16_MAX\t(32767)\n# define INT_LEAST32_MAX\t(2147483647)\n# define INT_LEAST64_MAX\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types having a minimum size.  */\n# define UINT_LEAST8_MAX\t(255)\n# define UINT_LEAST16_MAX\t(65535)\n# define UINT_LEAST32_MAX\t(4294967295U)\n# define UINT_LEAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of fast signed integral types having a minimum size.  */\n# define INT_FAST8_MIN\t\t(-128)\n# if __WORDSIZE == 64\n#  define INT_FAST16_MIN\t(-9223372036854775807L-1)\n#  define INT_FAST32_MIN\t(-9223372036854775807L-1)\n# else\n#  define INT_FAST16_MIN\t(-2147483647-1)\n#  define INT_FAST32_MIN\t(-2147483647-1)\n# endif\n# define INT_FAST64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of fast signed integral types having a minimum size.  */\n# define INT_FAST8_MAX\t\t(127)\n# if __WORDSIZE == 64\n#  define INT_FAST16_MAX\t(9223372036854775807L)\n#  define INT_FAST32_MAX\t(9223372036854775807L)\n# else\n#  define INT_FAST16_MAX\t(2147483647)\n#  define INT_FAST32_MAX\t(2147483647)\n# endif\n# define INT_FAST64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of fast unsigned integral types having a minimum size.  */\n# define UINT_FAST8_MAX\t\t(255)\n# if __WORDSIZE == 64\n#  define UINT_FAST16_MAX\t(18446744073709551615UL)\n#  define UINT_FAST32_MAX\t(18446744073709551615UL)\n# else\n#  define UINT_FAST16_MAX\t(4294967295U)\n#  define UINT_FAST32_MAX\t(4294967295U)\n# endif\n# define UINT_FAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Values to test for integral types holding `void *' pointer.  */\n# if __WORDSIZE == 64\n#  define INTPTR_MIN\t\t(-9223372036854775807L-1)\n#  define INTPTR_MAX\t\t(9223372036854775807L)\n#  define UINTPTR_MAX\t\t(18446744073709551615UL)\n# else\n#  define INTPTR_MIN\t\t(-2147483647-1)\n#  define INTPTR_MAX\t\t(2147483647)\n#  define UINTPTR_MAX\t\t(4294967295U)\n# endif\n\n/* Minimum for largest signed integral type.  */\n# define INTMAX_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum for largest signed integral type.  */\n# define INTMAX_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum for largest unsigned integral type.  */\n# define UINTMAX_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Limits of other integer types.  */\n\n/* Limits of `ptrdiff_t' type.  */\n# if __WORDSIZE == 64\n#  define PTRDIFF_MIN\t\t(-9223372036854775807L-1)\n#  define PTRDIFF_MAX\t\t(9223372036854775807L)\n# else\n#  if __WORDSIZE32_PTRDIFF_LONG\n#   define PTRDIFF_MIN\t\t(-2147483647L-1)\n#   define PTRDIFF_MAX\t\t(2147483647L)\n#  else\n#   define PTRDIFF_MIN\t\t(-2147483647-1)\n#   define PTRDIFF_MAX\t\t(2147483647)\n#  endif\n# endif\n\n/* Limits of `sig_atomic_t'.  */\n# define SIG_ATOMIC_MIN\t\t(-2147483647-1)\n# define SIG_ATOMIC_MAX\t\t(2147483647)\n\n/* Limit of `size_t' type.  */\n# if __WORDSIZE == 64\n#  define SIZE_MAX\t\t(18446744073709551615UL)\n# else\n#  if __WORDSIZE32_SIZE_ULONG\n#   define SIZE_MAX\t\t(4294967295UL)\n#  else\n#   define SIZE_MAX\t\t(4294967295U)\n#  endif\n# endif\n\n/* Limits of `wchar_t'.  */\n# ifndef WCHAR_MIN\n/* These constants might also be defined in <wchar.h>.  */\n#  define WCHAR_MIN\t\t__WCHAR_MIN\n#  define WCHAR_MAX\t\t__WCHAR_MAX\n# endif\n\n/* Limits of `wint_t'.  */\n# define WINT_MIN\t\t(0u)\n# define WINT_MAX\t\t(4294967295u)\n\n/* Signed.  */\n# define INT8_C(c)\tc\n# define INT16_C(c)\tc\n# define INT32_C(c)\tc\n# if __WORDSIZE == 64\n#  define INT64_C(c)\tc ## L\n# else\n#  define INT64_C(c)\tc ## LL\n# endif\n\n/* Unsigned.  */\n# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc\n# define UINT32_C(c)\tc ## U\n# if __WORDSIZE == 64\n#  define UINT64_C(c)\tc ## UL\n# else\n#  define UINT64_C(c)\tc ## ULL\n# endif\n\n/* Maximal type.  */\n# if __WORDSIZE == 64\n#  define INTMAX_C(c)\tc ## L\n#  define UINTMAX_C(c)\tc ## UL\n# else\n#  define INTMAX_C(c)\tc ## LL\n#  define UINTMAX_C(c)\tc ## ULL\n# endif\n\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\n\n# define INT8_WIDTH 8\n# define UINT8_WIDTH 8\n# define INT16_WIDTH 16\n# define UINT16_WIDTH 16\n# define INT32_WIDTH 32\n# define UINT32_WIDTH 32\n# define INT64_WIDTH 64\n# define UINT64_WIDTH 64\n\n# define INT_LEAST8_WIDTH 8\n# define UINT_LEAST8_WIDTH 8\n# define INT_LEAST16_WIDTH 16\n# define UINT_LEAST16_WIDTH 16\n# define INT_LEAST32_WIDTH 32\n# define UINT_LEAST32_WIDTH 32\n# define INT_LEAST64_WIDTH 64\n# define UINT_LEAST64_WIDTH 64\n\n# define INT_FAST8_WIDTH 8\n# define UINT_FAST8_WIDTH 8\n# define INT_FAST16_WIDTH __WORDSIZE\n# define UINT_FAST16_WIDTH __WORDSIZE\n# define INT_FAST32_WIDTH __WORDSIZE\n# define UINT_FAST32_WIDTH __WORDSIZE\n# define INT_FAST64_WIDTH 64\n# define UINT_FAST64_WIDTH 64\n\n# define INTPTR_WIDTH __WORDSIZE\n# define UINTPTR_WIDTH __WORDSIZE\n\n# define INTMAX_WIDTH 64\n# define UINTMAX_WIDTH 64\n\n# define PTRDIFF_WIDTH __WORDSIZE\n# define SIG_ATOMIC_WIDTH 32\n# define SIZE_WIDTH __WORDSIZE\n# define WCHAR_WIDTH 32\n# define WINT_WIDTH 32\n\n#endif\n\n#endif\t\t\t\t/* stdint.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/stdio.h",
    "content": "/* Define ISO C stdio on top of C++ iostreams.\n   Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.19 Input/output\t<stdio.h>\n */\n\n#ifndef _STDIO_H\n#define _STDIO_H\t1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n__BEGIN_DECLS\n#define __need_size_t\n#define __need_NULL\n#include <stddef.h>\n#include <bits/types.h>\n#include <bits/types/__FILE.h>\n#include <bits/types/FILE.h>\n#define _STDIO_USES_IOSTREAM\n#include <bits/libio.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# ifdef __GNUC__\n#  ifndef _VA_LIST_DEFINED\ntypedef _G_va_list va_list;\n#   define _VA_LIST_DEFINED\n#  endif\n# else\n#  include <stdarg.h>\n# endif\n#endif\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n# ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n# ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n# endif\n#endif\n\n/* The type of the second argument to `fgetpos' and `fsetpos'.  */\n#ifndef __USE_FILE_OFFSET64\ntypedef _G_fpos_t fpos_t;\n#else\ntypedef _G_fpos64_t fpos_t;\n#endif\n#ifdef __USE_LARGEFILE64\ntypedef _G_fpos64_t fpos64_t;\n#endif\n\n/* The possibilities for the third argument to `setvbuf'.  */\n#define _IOFBF 0\t\t/* Fully buffered.  */\n#define _IOLBF 1\t\t/* Line buffered.  */\n#define _IONBF 2\t\t/* No buffering.  */\n\n/* Default buffer size.  */\n#ifndef BUFSIZ\n# define BUFSIZ _IO_BUFSIZ\n#endif\n\n/* End of file character.\n   Some things throughout the library rely on this being -1.  */\n#ifndef EOF\n# define EOF (-1)\n#endif\n\n/* The possibilities for the third argument to `fseek'.\n   These values should not be changed.  */\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n#define SEEK_END\t2\t/* Seek from end of file.  */\n#ifdef __USE_GNU\n# define SEEK_DATA\t3\t/* Seek to next data.  */\n# define SEEK_HOLE\t4\t/* Seek to next hole.  */\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Default path prefix for `tempnam' and `tmpnam'.  */\n# define P_tmpdir\t\"/tmp\"\n#endif\n\n/* Get the values:\n   L_tmpnam\tHow long an array of chars must be to be passed to `tmpnam'.\n   TMP_MAX\tThe minimum number of unique filenames generated by tmpnam\n\t\t(and tempnam when it uses tmpnam's name space),\n\t\tor tempnam (the two are separate).\n   L_ctermid\tHow long an array to pass to `ctermid'.\n   L_cuserid\tHow long an array to pass to `cuserid'.\n   FOPEN_MAX\tMinimum number of files that can be open at once.\n   FILENAME_MAX\tMaximum length of a filename.  */\n#include <bits/stdio_lim.h>\n\n/* Standard streams.  */\nextern struct _IO_FILE *stdin;\t/* Standard input stream.  */\nextern struct _IO_FILE *stdout;\t/* Standard output stream.  */\nextern struct _IO_FILE *stderr;\t/* Standard error output stream.  */\n/* C89/C99 say they're macros.  Make them happy.  */\n#define stdin stdin\n#define stdout stdout\n#define stderr stderr\n\n/* Remove file FILENAME.  */\nextern int remove(const char *__filename) __THROW;\n/* Rename file OLD to NEW.  */\nextern int rename(const char *__old, const char *__new) __THROW;\n\n#ifdef __USE_ATFILE\n/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */\nextern int renameat(int __oldfd, const char *__old, int __newfd, const char *__new) __THROW;\n#endif\n\n/* Create a temporary file and open it read/write.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern FILE *tmpfile(void) __wur;\n#else\n# ifdef __REDIRECT\nextern FILE *__REDIRECT(tmpfile, (void), tmpfile64) __wur;\n# else\n#  define tmpfile tmpfile64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern FILE *tmpfile64(void) __wur;\n#endif\n\n/* Generate a temporary filename.  */\nextern char *tmpnam(char *__s)\n__THROW __wur;\n\n#ifdef __USE_MISC\n/* This is the reentrant variant of `tmpnam'.  The only difference is\n   that it does not allow S to be NULL.  */\nextern char *tmpnam_r(char *__s)\n__THROW __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Generate a unique temporary filename using up to five characters of PFX\n   if it is not NULL.  The directory to put this file in is searched for\n   as follows: First the environment variable \"TMPDIR\" is checked.\n   If it contains the name of a writable directory, that directory is used.\n   If not and if DIR is not NULL, that value is checked.  If that fails,\n   P_tmpdir is tried and finally \"/tmp\".  The storage for the filename\n   is allocated by `malloc'.  */\nextern char *tempnam(const char *__dir, const char *__pfx)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n/* Close STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fclose(FILE * __stream);\n/* Flush STREAM, or all streams if STREAM is NULL.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fflush(FILE * __stream);\n\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fflush_unlocked(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Close all streams.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fcloseall(void);\n#endif\n\n#ifndef __USE_FILE_OFFSET64\n/* Open a file and create a new stream for it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *fopen(const char *__restrict __filename, const char *__restrict __modes) __wur;\n/* Open a file, replacing an existing stream with it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *freopen(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#else\n# ifdef __REDIRECT\nextern FILE *__REDIRECT(fopen, (const char *__restrict __filename, const char *__restrict __modes), fopen64) __wur;\nextern FILE *__REDIRECT(freopen, (const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream), freopen64) __wur;\n# else\n#  define fopen fopen64\n#  define freopen freopen64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern FILE *fopen64(const char *__restrict __filename, const char *__restrict __modes) __wur;\nextern FILE *freopen64(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#endif\n\n#ifdef\t__USE_POSIX\n/* Create a new stream that refers to an existing system file descriptor.  */\nextern FILE *fdopen(int __fd, const char *__modes)\n__THROW __wur;\n#endif\n\n#ifdef\t__USE_GNU\n/* Create a new stream that refers to the given magic cookie,\n   and uses the given functions for input and output.  */\nextern FILE *fopencookie(void *__restrict __magic_cookie, const char *__restrict __modes, _IO_cookie_io_functions_t __io_funcs)\n__THROW __wur;\n#endif\n\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n/* Create a new stream that refers to a memory buffer.  */\nextern FILE *fmemopen(void *__s, size_t __len, const char *__modes)\n__THROW __wur;\n\n/* Open a stream that writes into a malloc'd buffer that is expanded as\n   necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location\n   and the number of characters written on fflush or fclose.  */\nextern FILE *open_memstream(char **__bufloc, size_t * __sizeloc)\n__THROW __wur;\n#endif\n\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use buffer BUF, of size BUFSIZ.  */\nextern void setbuf(FILE * __restrict __stream, char *__restrict __buf) __THROW;\n/* Make STREAM use buffering mode MODE.\n   If BUF is not NULL, use N bytes of it for buffering;\n   else allocate an internal buffer N bytes long.  */\nextern int setvbuf(FILE * __restrict __stream, char *__restrict __buf, int __modes, size_t __n) __THROW;\n\n#ifdef\t__USE_MISC\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use SIZE bytes of BUF for buffering.  */\nextern void setbuffer(FILE * __restrict __stream, char *__restrict __buf, size_t __size) __THROW;\n\n/* Make STREAM line-buffered.  */\nextern void setlinebuf(FILE * __stream) __THROW;\n#endif\n\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fprintf(FILE * __restrict __stream, const char *__restrict __format, ...);\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int printf(const char *__restrict __format, ...);\n/* Write formatted output to S.  */\nextern int sprintf(char *__restrict __s, const char *__restrict __format, ...) __THROWNL;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfprintf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vprintf(const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to S from argument list ARG.  */\nextern int vsprintf(char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROWNL;\n\n#if defined __USE_ISOC99 || defined __USE_UNIX98\n/* Maximum chars of output to write in MAXLEN.  */\nextern int snprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 4)));\n\nextern int vsnprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 0)));\n#endif\n\n#if __GLIBC_USE (LIB_EXT2)\n/* Write formatted output to a string dynamically allocated with `malloc'.\n   Store the address of the string in *PTR.  */\nextern int vasprintf(char **__restrict __ptr, const char *__restrict __f, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0))) __wur;\nextern int __asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\nextern int asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Write formatted output to a file descriptor.  */\nextern int vdprintf(int __fd, const char *__restrict __fmt, _G_va_list __arg)\n    __attribute__ ((__format__(__printf__, 2, 0)));\nextern int dprintf(int __fd, const char *__restrict __fmt, ...)\n    __attribute__ ((__format__(__printf__, 2, 3)));\n#endif\n\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int scanf(const char *__restrict __format, ...) __wur;\n/* Read formatted input from S.  */\nextern int sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n\n#if defined __USE_ISOC99 && !defined __USE_GNU \\\n    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n# ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fscanf, (FILE * __restrict __stream, const char *__restrict __format, ...), __isoc99_fscanf) __wur;\nextern int __REDIRECT(scanf, (const char *__restrict __format, ...), __isoc99_scanf) __wur;\nextern int __REDIRECT_NTH(sscanf, (const char *__restrict __s, const char *__restrict __format, ...), __isoc99_sscanf);\n# else\nextern int __isoc99_fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\nextern int __isoc99_scanf(const char *__restrict __format, ...) __wur;\nextern int __isoc99_sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n#  define fscanf __isoc99_fscanf\n#  define scanf __isoc99_scanf\n#  define sscanf __isoc99_sscanf\n# endif\n#endif\n\n#ifdef\t__USE_ISOC99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\n\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vscanf(const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\n\n/* Read formatted input from S into argument list ARG.  */\nextern int vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg)\n__THROW __attribute__ ((__format__(__scanf__, 2, 0)));\n\n# if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(vfscanf, (FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vfscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\nextern int __REDIRECT(vscanf, (const char *__restrict __format, _G_va_list __arg), __isoc99_vscanf)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\nextern int __REDIRECT_NTH(vsscanf, (const char *__restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vsscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0)));\n#  else\nextern int __isoc99_vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vscanf(const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROW;\n#   define vfscanf __isoc99_vfscanf\n#   define vscanf __isoc99_vscanf\n#   define vsscanf __isoc99_vsscanf\n#  endif\n# endif\n#endif\t\t\t\t/* Use ISO C9x.  */\n\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int fgetc(FILE * __stream);\nextern int getc(FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getchar(void);\n\n/* The C standard explicitly says this is a macro, so we always do the\n   optimization for it.  */\n#define getc(_fp) _IO_getc (_fp)\n\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int getc_unlocked(FILE * __stream);\nextern int getchar_unlocked(void);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetc_unlocked(FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.\n\n   These functions is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputc(int __c, FILE * __stream);\nextern int putc(int __c, FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int putchar(int __c);\n\n/* The C standard explicitly says this can be a macro,\n   so we always do the optimization for it.  */\n#define putc(_ch, _fp) _IO_putc (_ch, _fp)\n\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputc_unlocked(int __c, FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int putc_unlocked(int __c, FILE * __stream);\nextern int putchar_unlocked(int __c);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Get a word (int) from STREAM.  */\nextern int getw(FILE * __stream);\n\n/* Write a word (int) to STREAM.  */\nextern int putw(int __w, FILE * __stream);\n#endif\n\n/* Get a newline-terminated string of finite length from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *fgets(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n\n#if __GLIBC_USE (DEPRECATED_GETS)\n/* Get a newline-terminated string from stdin, removing the newline.\n\n   This function is impossible to use safely.  It has been officially\n   removed from ISO C11 and ISO C++14, and we have also removed it\n   from the _GNU_SOURCE feature list.  It remains available when\n   explicitly using an old ISO C, Unix, or POSIX standard.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *gets(char *__s)\n__wur __attribute_deprecated__;\n#endif\n\n#ifdef __USE_GNU\n/* This function does the same as `fgets' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern char *fgets_unlocked(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n#endif\n\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR\n   (and null-terminate it). *LINEPTR is a pointer returned from malloc (or\n   NULL), pointing to *N characters of space.  It is realloc'd as\n   necessary.  Returns the number of characters read (not including the\n   null terminator), or -1 on error or EOF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t __getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\nextern _IO_ssize_t getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\n\n/* Like `getdelim', but reads up to a newline.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t getline(char **__restrict __lineptr, size_t * __restrict __n, FILE * __restrict __stream) __wur;\n#endif\n\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputs(const char *__restrict __s, FILE * __restrict __stream);\n\n/* Write a string, followed by a newline, to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int puts(const char *__s);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int ungetc(int __c, FILE * __stream);\n\n/* Read chunks of generic data from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fread(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\n/* Write chunks of generic data to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fwrite(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __s);\n\n#ifdef __USE_GNU\n/* This function does the same as `fputs' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputs_unlocked(const char *__restrict __s, FILE * __restrict __stream);\n#endif\n\n#ifdef __USE_MISC\n/* Faster versions when locking is not necessary.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern size_t fread_unlocked(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\nextern size_t fwrite_unlocked(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream);\n#endif\n\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseek(FILE * __stream, long int __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern long int ftell(FILE * __stream) __wur;\n/* Rewind to the beginning of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void rewind(FILE * __stream);\n\n/* The Single Unix Specification, Version 2, specifies an alternative,\n   more adequate interface for the two functions above which deal with\n   file offset.  `long int' is not the right type.  These definitions\n   are originally defined in the Large File Support API.  */\n\n#if defined __USE_LARGEFILE || defined __USE_XOPEN2K\n# ifndef __USE_FILE_OFFSET64\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseeko(FILE * __stream, __off_t __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __off_t ftello(FILE * __stream) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(fseeko, (FILE * __stream, __off64_t __off, int __whence), fseeko64);\nextern __off64_t __REDIRECT(ftello, (FILE * __stream), ftello64);\n#  else\n#   define fseeko fseeko64\n#   define ftello ftello64\n#  endif\n# endif\n#endif\n\n#ifndef __USE_FILE_OFFSET64\n/* Get STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fgetpos(FILE * __restrict __stream, fpos_t * __restrict __pos);\n/* Set STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fsetpos(FILE * __stream, const fpos_t * __pos);\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(fgetpos, (FILE * __restrict __stream, fpos_t * __restrict __pos), fgetpos64);\nextern int __REDIRECT(fsetpos, (FILE * __stream, const fpos_t * __pos), fsetpos64);\n# else\n#  define fgetpos fgetpos64\n#  define fsetpos fsetpos64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int fseeko64(FILE * __stream, __off64_t __off, int __whence);\nextern __off64_t ftello64(FILE * __stream) __wur;\nextern int fgetpos64(FILE * __restrict __stream, fpos64_t * __restrict __pos);\nextern int fsetpos64(FILE * __stream, const fpos64_t * __pos);\n#endif\n\n/* Clear the error and EOF indicators for STREAM.  */\nextern void clearerr(FILE * __stream) __THROW;\n/* Return the EOF indicator for STREAM.  */\nextern int feof(FILE * __stream)\n__THROW __wur;\n/* Return the error indicator for STREAM.  */\nextern int ferror(FILE * __stream)\n__THROW __wur;\n\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.  */\nextern void clearerr_unlocked(FILE * __stream) __THROW;\nextern int feof_unlocked(FILE * __stream)\n__THROW __wur;\nextern int ferror_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n/* Print a message describing the meaning of the value of errno.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void perror(const char *__s);\n\n/* Provide the declarations for `sys_errlist' and `sys_nerr' if they\n   are available on this system.  Even if available, these variables\n   should not be used directly.  The `strerror' function provides\n   all the necessary functionality.  */\n#include <bits/sys_errlist.h>\n\n#ifdef\t__USE_POSIX\n/* Return the system file descriptor for STREAM.  */\nextern int fileno(FILE * __stream)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not required.  */\nextern int fileno_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n#ifdef __USE_POSIX2\n/* Create a new stream connected to a pipe running the given command.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *popen(const char *__command, const char *__modes) __wur;\n\n/* Close a stream opened by popen and return the status of its child.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int pclose(FILE * __stream);\n#endif\n\n#ifdef\t__USE_POSIX\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU\n/* Return the name of the current user.  */\nextern char *cuserid(char *__s);\n#endif\t\t\t\t/* Use X/Open, but not issue 6.  */\n\n#ifdef\t__USE_GNU\nstruct obstack;\t\t\t/* See <obstack.h>.  */\n\n/* Write formatted output to an obstack.  */\nextern int obstack_printf(struct obstack *__restrict __obstack, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3)));\nextern int obstack_vprintf(struct obstack *__restrict __obstack, const char *__restrict __format, _G_va_list __args)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0)));\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.  */\n\n/* Acquire ownership of STREAM.  */\nextern void flockfile(FILE * __stream) __THROW;\n\n/* Try to acquire ownership of STREAM but do not block if it is not\n   possible.  */\nextern int ftrylockfile(FILE * __stream)\n__THROW __wur;\n\n/* Relinquish the ownership granted for STREAM.  */\nextern void funlockfile(FILE * __stream) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU\n/*  X/Open Issues 1-5 required getopt to be declared in this\n   header.  It was removed in Issue 6.  GNU follows Issue 6.  */\n# include <bits/getopt_posix.h>\n#endif\n\n/* If we are compiling with optimizing read this file.  It contains\n   several optimizing inline functions and macros.  */\n#ifdef __USE_EXTERN_INLINES\n# include <bits/stdio.h>\n#endif\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/stdio2.h>\n#endif\n#ifdef __LDBL_COMPAT\n# include <bits/stdio-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* <stdio.h> included.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/stdlib.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.20 General utilities\t<stdlib.h>\n */\n\n#ifndef\t_STDLIB_H\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n/* Get size_t, wchar_t and NULL from <stddef.h>.  */\n#define __need_size_t\n#define __need_wchar_t\n#define __need_NULL\n#include <stddef.h>\n\n__BEGIN_DECLS\n#define\t_STDLIB_H\t1\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H\n/* XPG requires a few symbols from <sys/wait.h> being defined.  */\n# include <bits/waitflags.h>\n# include <bits/waitstatus.h>\n/* Define the macros <sys/wait.h> also would define this way.  */\n# define WEXITSTATUS(status)\t__WEXITSTATUS (status)\n# define WTERMSIG(status)\t__WTERMSIG (status)\n# define WSTOPSIG(status)\t__WSTOPSIG (status)\n# define WIFEXITED(status)\t__WIFEXITED (status)\n# define WIFSIGNALED(status)\t__WIFSIGNALED (status)\n# define WIFSTOPPED(status)\t__WIFSTOPPED (status)\n# ifdef __WIFCONTINUED\n#  define WIFCONTINUED(status)\t__WIFCONTINUED (status)\n# endif\n#endif\t\t\t\t/* X/Open or XPG7 and <sys/wait.h> not included.  */\n/* _FloatN API tests for enablement.  */\n#include <bits/floatn.h>\n/* Returned by `div'.  */\n    typedef struct {\n\tint quot;\t\t/* Quotient.  */\n\tint rem;\t\t/* Remainder.  */\n} div_t;\n\n/* Returned by `ldiv'.  */\n#ifndef __ldiv_t_defined\ntypedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} ldiv_t;\n# define __ldiv_t_defined\t1\n#endif\n\n#if defined __USE_ISOC99 && !defined __lldiv_t_defined\n/* Returned by `lldiv'.  */\n__extension__ typedef struct {\n\tlong long int quot;\t/* Quotient.  */\n\tlong long int rem;\t/* Remainder.  */\n} lldiv_t;\n# define __lldiv_t_defined\t1\n#endif\n\n/* The largest number rand will return (same as INT_MAX).  */\n#define\tRAND_MAX\t2147483647\n\n/* We define these the same for all machines.\n   Changes from this to the outside world should be done in `_exit'.  */\n#define\tEXIT_FAILURE\t1\t/* Failing exit status.  */\n#define\tEXIT_SUCCESS\t0\t/* Successful exit status.  */\n\n/* Maximum length of a multibyte character in the current locale.  */\n#define\tMB_CUR_MAX\t(__ctype_get_mb_cur_max ())\nextern size_t __ctype_get_mb_cur_max(void)\n__THROW __wur;\n\n/* Convert a string to a floating-point number.  */\nextern double atof(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to an integer.  */\nextern int atoi(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to a long integer.  */\nextern long int atol(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n\n#ifdef __USE_ISOC99\n/* Convert a string to a long long integer.  */\n__extension__ extern long long int atoll(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n#endif\n\n/* Convert a string to a floating-point number.  */\nextern double strtod(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n\n#ifdef\t__USE_ISOC99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float strtof(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n\nextern long double strtold(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n/* Likewise for '_FloatN' and '_FloatNx'.  */\n\n#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float16 strtof16(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float32 strtof32(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float64 strtof64(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float128 strtof128(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float32x strtof32x(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float64x strtof64x(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern _Float128x strtof128x(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n#endif\n\n/* Convert a string to a long integer.  */\nextern long int strtol(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned long integer.  */\nextern unsigned long int strtoul(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtouq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoll(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtoull(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n#endif\t\t\t\t/* ISO C99 or use MISC.  */\n\n/* Convert a floating-point number to a string.  */\n#if __GLIBC_USE (IEC_60559_BFP_EXT)\nextern int strfromd(char *__dest, size_t __size, const char *__format, double __f)\n__THROW __nonnull((3));\n\nextern int strfromf(char *__dest, size_t __size, const char *__format, float __f)\n__THROW __nonnull((3));\n\nextern int strfroml(char *__dest, size_t __size, const char *__format, long double __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf16(char *__dest, size_t __size, const char *__format, _Float16 __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf32(char *__dest, size_t __size, const char *__format, _Float32 __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf64(char *__dest, size_t __size, const char *__format, _Float64 __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf128(char *__dest, size_t __size, const char *__format, _Float128 __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf32x(char *__dest, size_t __size, const char *__format, _Float32x __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf64x(char *__dest, size_t __size, const char *__format, _Float64x __f)\n__THROW __nonnull((3));\n#endif\n\n#if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)\nextern int strfromf128x(char *__dest, size_t __size, const char *__format, _Float128x __f)\n__THROW __nonnull((3));\n#endif\n\n#ifdef __USE_GNU\n/* Parallel versions of the functions above which take the locale to\n   use as an additional parameter.  These are GNU extensions inspired\n   by the POSIX.1-2008 extended locale API.  */\n# include <bits/types/locale_t.h>\n\nextern long int strtol_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern unsigned long int strtoul_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern long long int strtoll_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern unsigned long long int strtoull_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern double strtod_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern float strtof_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern long double strtold_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n\n# if __HAVE_FLOAT16\nextern _Float16 strtof16_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT32\nextern _Float32 strtof32_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT64\nextern _Float64 strtof64_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT128\nextern _Float128 strtof128_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT32X\nextern _Float32x strtof32x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT64X\nextern _Float64x strtof64x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n\n# if __HAVE_FLOAT128X\nextern _Float128x strtof128x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc)\n__THROW __nonnull((1, 3));\n# endif\n#endif\t\t\t\t/* GNU */\n\n#ifdef __USE_EXTERN_INLINES\n__extern_inline int __NTH(atoi(const char *__nptr))\n{\n\treturn (int)strtol(__nptr, (char **)NULL, 10);\n}\n\n__extern_inline long int __NTH(atol(const char *__nptr))\n{\n\treturn strtol(__nptr, (char **)NULL, 10);\n}\n\n# ifdef __USE_ISOC99\n__extension__ __extern_inline long long int __NTH(atoll(const char *__nptr))\n{\n\treturn strtoll(__nptr, (char **)NULL, 10);\n}\n# endif\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Convert N to base 64 using the digits \"./0-9A-Za-z\", least-significant\n   digit first.  Returns a pointer to static storage overwritten by the\n   next call.  */\nextern char *l64a(long int __n)\n__THROW __wur;\n\n/* Read a number from a string S in base 64 as above.  */\nextern long int a64l(const char *__s)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use misc || extended X/Open.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n# include <sys/types.h>\t\t/* we need int32_t... */\n\n/* These are the functions that actually do things.  The `random', `srandom',\n   `initstate' and `setstate' functions are those from BSD Unices.\n   The `rand' and `srand' functions are required by the ANSI standard.\n   We provide both interfaces to the same random number generator.  */\n/* Return a random long integer between 0 and RAND_MAX inclusive.  */\nextern long int random(void) __THROW;\n\n/* Seed the random number generator with the given number.  */\nextern void srandom(unsigned int __seed) __THROW;\n\n/* Initialize the random number generator to use state buffer STATEBUF,\n   of length STATELEN, and seed it with SEED.  Optimal lengths are 8, 16,\n   32, 64, 128 and 256, the bigger the better; values less than 8 will\n   cause an error and values greater than 256 will be rounded down.  */\nextern char *initstate(unsigned int __seed, char *__statebuf, size_t __statelen)\n__THROW __nonnull((2));\n\n/* Switch the random number generator to state buffer STATEBUF,\n   which should have been previously initialized by `initstate'.  */\nextern char *setstate(char *__statebuf)\n__THROW __nonnull((1));\n\n# ifdef __USE_MISC\n/* Reentrant versions of the `random' family of functions.\n   These functions all use the following data structure to contain\n   state, rather than global state variables.  */\n\nstruct random_data {\n\tint32_t *fptr;\t\t/* Front pointer.  */\n\tint32_t *rptr;\t\t/* Rear pointer.  */\n\tint32_t *state;\t\t/* Array of state values.  */\n\tint rand_type;\t\t/* Type of random number generator.  */\n\tint rand_deg;\t\t/* Degree of random number generator.  */\n\tint rand_sep;\t\t/* Distance between front and rear.  */\n\tint32_t *end_ptr;\t/* Pointer behind state table.  */\n};\n\nextern int random_r(struct random_data *__restrict __buf, int32_t * __restrict __result)\n__THROW __nonnull((1, 2));\n\nextern int srandom_r(unsigned int __seed, struct random_data *__buf)\n__THROW __nonnull((2));\n\nextern int initstate_r(unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf)\n__THROW __nonnull((2, 4));\n\nextern int setstate_r(char *__restrict __statebuf, struct random_data *__restrict __buf)\n__THROW __nonnull((1, 2));\n# endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use extended X/Open || misc. */\n\n/* Return a random integer between 0 and RAND_MAX inclusive.  */\nextern int rand(void) __THROW;\n/* Seed the random number generator with the given number.  */\nextern void srand(unsigned int __seed) __THROW;\n\n#ifdef __USE_POSIX199506\n/* Reentrant interface according to POSIX.1.  */\nextern int rand_r(unsigned int *__seed) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* System V style 48-bit random number generator functions.  */\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern double drand48(void) __THROW;\nextern double erand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern long int lrand48(void) __THROW;\nextern long int nrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern long int mrand48(void) __THROW;\nextern long int jrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Seed random number generator.  */\nextern void srand48(long int __seedval) __THROW;\nextern unsigned short int *seed48(unsigned short int __seed16v[3])\n__THROW __nonnull((1));\nextern void lcong48(unsigned short int __param[7])\n__THROW __nonnull((1));\n\n# ifdef __USE_MISC\n/* Data structure for communication with thread safe versions.  This\n   type is to be regarded as opaque.  It's only exported because users\n   have to allocate objects of this type.  */\nstruct drand48_data {\n\tunsigned short int __x[3];\t/* Current state.  */\n\tunsigned short int __old_x[3];\t/* Old state.  */\n\tunsigned short int __c;\t/* Additive const. in congruential formula.  */\n\tunsigned short int __init;\t/* Flag for initializing.  */\n\t__extension__ unsigned long long int __a;\t/* Factor in congruential\n\t\t\t\t\t\t\t   formula.  */\n};\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern int drand48_r(struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int erand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern int lrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int nrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern int mrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int jrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Seed random number generator.  */\nextern int srand48_r(long int __seedval, struct drand48_data *__buffer)\n__THROW __nonnull((2));\n\nextern int seed48_r(unsigned short int __seed16v[3], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n\nextern int lcong48_r(unsigned short int __param[7], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n# endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Re-allocate the previously allocated block\n   in PTR, making the new block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n\n#ifdef __USE_GNU\n/* Re-allocate the previously allocated block in PTR, making the new\n   block large enough for NMEMB elements of SIZE bytes each.  */\n/* __attribute_malloc__ is not used, because if reallocarray returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *reallocarray(void *__ptr, size_t __nmemb, size_t __size)\n__THROW __attribute_warn_unused_result__;\n#endif\n\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n\n#ifdef __USE_MISC\n# include <alloca.h>\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n/* Allocate SIZE bytes on a page boundary.  The storage cannot be freed.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT.  */\nextern int posix_memalign(void **__memptr, size_t __alignment, size_t __size)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_ISOC11\n/* ISO C variant of aligned allocation.  */\nextern void *aligned_alloc(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __attribute_alloc_size__((2)) __wur;\n#endif\n\n/* Abort execution and generate a core-dump.  */\nextern void abort(void)\n__THROW __attribute__ ((__noreturn__));\n\n/* Register a function to be called when `exit' is called.  */\nextern int atexit(void (*__func) (void))\n__THROW __nonnull((1));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Register a function to be called when `quick_exit' is called.  */\n# ifdef __cplusplus\nextern \"C++\" int at_quick_exit(void (*__func) (void))\n__THROW __asm(\"at_quick_exit\") __nonnull((1));\n# else\nextern int at_quick_exit(void (*__func) (void))\n__THROW __nonnull((1));\n# endif\n#endif\n\n#ifdef\t__USE_MISC\n/* Register a function to be called with the status\n   given to `exit' and the given argument.  */\nextern int on_exit(void (*__func) (int __status, void *__arg), void *__arg)\n__THROW __nonnull((1));\n#endif\n\n/* Call all functions registered with `atexit' and `on_exit',\n   in the reverse of the order in which they were registered,\n   perform stdio cleanup, and terminate program execution with STATUS.  */\nextern void exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Call all functions registered with `at_quick_exit' in the reverse\n   of the order in which they were registered and terminate program\n   execution with STATUS.  */\nextern void quick_exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n#endif\n\n#ifdef __USE_ISOC99\n/* Terminate the program with STATUS without calling any of the\n   functions registered with `atexit' or `on_exit'.  */\nextern void _Exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n#endif\n\n/* Return the value of envariable NAME, or NULL if it doesn't exist.  */\nextern char *getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n\n#ifdef __USE_GNU\n/* This function is similar to the above but returns NULL if the\n   programs is running with SUID or SGID enabled.  */\nextern char *secure_getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* The SVID says this is in <stdio.h>, but this seems a better place.\t*/\n/* Put STRING, which is of the form \"NAME=VALUE\", in the environment.\n   If there is no `=', remove NAME from the environment.  */\nextern int putenv(char *__string)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set NAME to VALUE in the environment.\n   If REPLACE is nonzero, overwrite an existing value.  */\nextern int setenv(const char *__name, const char *__value, int __replace)\n__THROW __nonnull((2));\n\n/* Remove the variable NAME from the environment.  */\nextern int unsetenv(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* The `clearenv' was planned to be added to POSIX.1 but probably\n   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings\n   for Fortran 77) requires this function.  */\nextern int clearenv(void) __THROW;\n#endif\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the file name unique.\n   Always returns TEMPLATE, it's either a temporary file name or a null\n   string if it cannot get a unique file name.  */\nextern char *mktemp(char *__template)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the filename unique.\n   Returns a file descriptor open on the file for reading and writing,\n   or -1 if it cannot create a uniquely-named file.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkstemp(char *__template) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkstemp, (char *__template), mkstemp64) __nonnull((1)) __wur;\n#  else\n#   define mkstemp mkstemp64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkstemp64(char *__template) __nonnull((1)) __wur;\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* Similar to mkstemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkstemps(char *__template, int __suffixlen) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkstemps, (char *__template, int __suffixlen), mkstemps64) __nonnull((1)) __wur;\n#  else\n#   define mkstemps mkstemps64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkstemps64(char *__template, int __suffixlen) __nonnull((1)) __wur;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Create a unique temporary directory from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the directory name unique.\n   Returns TEMPLATE, or a null pointer if it cannot get a unique name.\n   The directory is created mode 700.  */\nextern char *mkdtemp(char *__template)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Generate a unique temporary file name from TEMPLATE similar to\n   mkstemp.  But allow the caller to pass additional flags which are\n   used in the open call to create the file..\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkostemp(char *__template, int __flags) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkostemp, (char *__template, int __flags), mkostemp64) __nonnull((1)) __wur;\n#  else\n#   define mkostemp mkostemp64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkostemp64(char *__template, int __flags) __nonnull((1)) __wur;\n# endif\n\n/* Similar to mkostemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkostemps(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkostemps, (char *__template, int __suffixlen, int __flags), mkostemps64) __nonnull((1)) __wur;\n#  else\n#   define mkostemps mkostemps64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkostemps64(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n# endif\n#endif\n\n/* Execute the given line as a shell command.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int system(const char *__command) __wur;\n\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the canonical absolute name of the\n   existing named file.  */\nextern char *canonicalize_file_name(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Return the canonical absolute name of file NAME.  If RESOLVED is\n   null, the result is malloc'd; otherwise, if the canonical name is\n   PATH_MAX chars or more, returns null with `errno' set to\n   ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,\n   returns the name in RESOLVED.  */\nextern char *realpath(const char *__restrict __name, char *__restrict __resolved)\n__THROW __wur;\n#endif\n\n/* Shorthand for type of comparison functions.  */\n#ifndef __COMPAR_FN_T\n# define __COMPAR_FN_T\ntypedef int (*__compar_fn_t) (const void *, const void *);\n\n# ifdef\t__USE_GNU\ntypedef __compar_fn_t comparison_fn_t;\n# endif\n#endif\n#ifdef __USE_GNU\ntypedef int (*__compar_d_fn_t) (const void *, const void *, void *);\n#endif\n\n/* Do a binary search for KEY in BASE, which consists of NMEMB elements\n   of SIZE bytes each, using COMPAR to perform the comparisons.  */\nextern void *bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 2, 5)) __wur;\n\n#ifdef __USE_EXTERN_INLINES\n# include <bits/stdlib-bsearch.h>\n#endif\n\n/* Sort NMEMB elements of BASE, of SIZE bytes each,\n   using COMPAR to perform the comparisons.  */\nextern void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 4));\n#ifdef __USE_GNU\nextern void qsort_r(void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg) __nonnull((1, 4));\n#endif\n\n/* Return the absolute value of X.  */\nextern int abs(int __x)\n__THROW __attribute__ ((__const__)) __wur;\nextern long int labs(long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n\n#ifdef __USE_ISOC99\n__extension__ extern long long int llabs(long long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n#endif\n\n/* Return the `div_t', `ldiv_t' or `lldiv_t' representation\n   of the value of NUMER over DENOM. */\n/* GCC may have built-ins for these someday.  */\nextern div_t div(int __numer, int __denom)\n__THROW __attribute__ ((__const__)) __wur;\nextern ldiv_t ldiv(long int __numer, long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n\n#ifdef __USE_ISOC99\n__extension__ extern lldiv_t lldiv(long long int __numer, long long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n#endif\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Convert floating point numbers to strings.  The returned values are\n   valid only until another call to the same function.  */\n\n/* Convert VALUE to a string with NDIGIT digits and return a pointer to\n   this.  Set *DECPT with the position of the decimal character and *SIGN\n   with the sign of the number.  */\nextern char *ecvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* Convert VALUE to a string rounded to NDIGIT decimal digits.  Set *DECPT\n   with the position of the decimal character and *SIGN with the sign of\n   the number.  */\nextern char *fcvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* If possible convert VALUE to a string with NDIGIT significant digits.\n   Otherwise use exponential representation.  The resulting string will\n   be written to BUF.  */\nextern char *gcvt(double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n#endif\n\n#ifdef __USE_MISC\n/* Long double versions of above functions.  */\nextern char *qecvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qfcvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qgcvt(long double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n\n/* Reentrant version of the functions above which provide their own\n   buffers.  */\nextern int ecvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int fcvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n\nextern int qecvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int qfcvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n#endif\t\t\t\t/* misc */\n\n/* Return the length of the multibyte character\n   in S, which is no longer than N.  */\nextern int mblen(const char *__s, size_t __n) __THROW;\n/* Return the length of the given multibyte character,\n   putting its `wchar_t' representation in *PWC.  */\nextern int mbtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n) __THROW;\n/* Put the multibyte character represented\n   by WCHAR in S, returning its length.  */\nextern int wctomb(char *__s, wchar_t __wchar) __THROW;\n\n/* Convert a multibyte string to a wide char string.  */\nextern size_t mbstowcs(wchar_t * __restrict __pwcs, const char *__restrict __s, size_t __n) __THROW;\n/* Convert a wide char string to multibyte string.  */\nextern size_t wcstombs(char *__restrict __s, const wchar_t * __restrict __pwcs, size_t __n) __THROW;\n\n#ifdef __USE_MISC\n/* Determine whether the string value of RESPONSE matches the affirmation\n   or negative response expression as specified by the LC_MESSAGES category\n   in the program's current locale.  Returns 1 if affirmative, 0 if\n   negative, and -1 if not matching.  */\nextern int rpmatch(const char *__response)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Parse comma separated suboption from *OPTIONP and match against\n   strings in TOKENS.  If found return index and set *VALUEP to\n   optional value introduced by an equal sign.  If the suboption is\n   not part of TOKENS return in *VALUEP beginning of unknown\n   suboption.  On exit *OPTIONP is set to the beginning of the next\n   token or at the terminating NUL character.  */\nextern int getsubopt(char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep)\n__THROW __nonnull((1, 2, 3)) __wur;\n#endif\n\n#ifdef __USE_XOPEN\n/* Setup DES tables according KEY.  */\nextern void setkey(const char *__key)\n__THROW __nonnull((1));\n#endif\n\n/* X/Open pseudo terminal handling.  */\n\n#ifdef __USE_XOPEN2KXSI\n/* Return a master pseudo-terminal handle.  */\nextern int posix_openpt(int __oflag) __wur;\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* The next four functions all take a master pseudo-tty fd and\n   perform an operation on the associated slave:  */\n\n/* Chown the slave to the calling user.  */\nextern int grantpt(int __fd) __THROW;\n\n/* Release an internal lock so the slave can be opened.\n   Call after grantpt().  */\nextern int unlockpt(int __fd) __THROW;\n\n/* Return the pathname of the pseudo terminal slave associated with\n   the master FD is open on, or NULL on errors.\n   The returned storage is good until the next call to this function.  */\nextern char *ptsname(int __fd)\n__THROW __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Store at most BUFLEN characters of the pathname of the slave pseudo\n   terminal associated with the master FD is open on in BUF.\n   Return 0 on success, otherwise an error number.  */\nextern int ptsname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Open a master pseudo terminal and return its file descriptor.  */\nextern int getpt(void);\n#endif\n\n#ifdef __USE_MISC\n/* Put the 1 minute, 5 minute and 15 minute load averages into the first\n   NELEM elements of LOADAVG.  Return the number written (never more than\n   three, but may be less than NELEM), or -1 if an error occurred.  */\nextern int getloadavg(double __loadavg[], int __nelem)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K\n/* Return the index into the active-logins file (utmp) for\n   the controlling terminal.  */\nextern int ttyslot(void) __THROW;\n#endif\n\n#include <bits/stdlib-float.h>\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/stdlib.h>\n#endif\n#ifdef __LDBL_COMPAT\n# include <bits/stdlib-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* stdlib.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/string.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.21 String handling\t<string.h>\n */\n\n#ifndef\t_STRING_H\n#define\t_STRING_H\t1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n__BEGIN_DECLS\n/* Get size_t and NULL from <stddef.h>.  */\n#define\t__need_size_t\n#define\t__need_NULL\n#include <stddef.h>\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n# define __CORRECT_ISO_CPP_STRING_H_PROTO\n#endif\n/* Copy N bytes of SRC to DEST.  */\nextern void *memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n/* Copy N bytes of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern void *memmove(void *__dest, const void *__src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N bytes of SRC to DEST, stopping when C is found.\n   Return the position in DEST one byte past where C was copied,\n   or NULL if C was not found in the first N bytes of SRC.  */\n#if defined __USE_MISC || defined __USE_XOPEN\nextern void *memccpy(void *__restrict __dest, const void *__restrict __src, int __c, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\t\t\t\t/* Misc || X/Open.  */\n\n/* Set N bytes of S to C.  */\nextern void *memset(void *__s, int __c, size_t __n)\n__THROW __nonnull((1));\n\n/* Compare N bytes of S1 and S2.  */\nextern int memcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Search N bytes of S for C.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern void *memchr(void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\textern const void *memchr(const void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline void *memchr(void *__s, int __c, size_t __n) __THROW\n{\n\treturn __builtin_memchr(__s, __c, __n);\n} __extern_always_inline const void *memchr(const void *__s, int __c, size_t __n) __THROW {\n\t\treturn __builtin_memchr(__s, __c, __n);\n}\n# endif\n}\n#else\nextern void *memchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n#ifdef __USE_GNU\n/* Search in S for C.  This is similar to `memchr' but there is no\n   length limit.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *rawmemchr(void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *rawmemchr(const void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\n# else\nextern void *rawmemchr(const void *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n\n/* Search N bytes of S for the final occurrence of C.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *memrchr(void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\n# else\nextern void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n#endif\n\n/* Copy SRC to DEST.  */\nextern char *strcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Copy no more than N characters of SRC to DEST.  */\nextern char *strncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern char *strcat(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Append no more than N characters from SRC onto DEST.  */\nextern char *strncat(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Compare S1 and S2.  */\nextern int strcmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Compare N characters of S1 and S2.  */\nextern int strncmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare the collated forms of S1 and S2.  */\nextern int strcoll(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Put a transformation of SRC into no more than N bytes of DEST.  */\nextern size_t strxfrm(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((2));\n\n#ifdef __USE_XOPEN2K8\n/* POSIX.1-2008 extended locale interface (see locale.h).  */\n# include <bits/types/locale_t.h>\n\n/* Compare the collated forms of S1 and S2, using sorting rules from L.  */\nextern int strcoll_l(const char *__s1, const char *__s2, locale_t __l)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n/* Put a transformation of SRC into no more than N bytes of DEST,\n   using sorting rules from L.  */\nextern size_t strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t __l)\n__THROW __nonnull((2, 4));\n#endif\n\n#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\t\\\n     || __GLIBC_USE (LIB_EXT2))\n/* Duplicate S, returning an identical malloc'd string.  */\nextern char *strdup(const char *__s)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n/* Return a malloc'd copy of at most N bytes of STRING.  The\n   resultant string is terminated even if no null terminator\n   appears before STRING[N].  */\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\nextern char *strndup(const char *__string, size_t __n)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n#if defined __USE_GNU && defined __GNUC__\n/* Duplicate S, returning an identical alloca'd string.  */\n# define strdupa(s)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strlen (__old) + 1;\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len);\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n\n/* Return an alloca'd copy of at most N bytes of string.  */\n# define strndupa(s, n)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strnlen (__old, (n));\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len + 1);\t\t      \\\n      __new[__len] = '\\0';\t\t\t\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n#endif\n\n/* Find the first occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strchr(char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strchr(const char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strchr(__s, __c);\n} __extern_always_inline const char *strchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strchr(__s, __c);\n}\n# endif\n}\n#else\nextern char *strchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n/* Find the last occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strrchr(char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strrchr(const char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strrchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strrchr(__s, __c);\n} __extern_always_inline const char *strrchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strrchr(__s, __c);\n}\n# endif\n}\n#else\nextern char *strrchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n#ifdef __USE_GNU\n/* This function is similar to `strchr'.  But it returns a pointer to\n   the closing NUL byte in case C is not found in S.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strchrnul(char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const char *strchrnul(const char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\n# else\nextern char *strchrnul(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n#endif\n\n/* Return the length of the initial segment of S which\n   consists entirely of characters not in REJECT.  */\nextern size_t strcspn(const char *__s, const char *__reject)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Return the length of the initial segment of S which\n   consists entirely of characters in ACCEPT.  */\nextern size_t strspn(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Find the first occurrence in S of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strpbrk(char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strpbrk(const char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strpbrk(char *__s, const char *__accept) __THROW\n{\n\treturn __builtin_strpbrk(__s, __accept);\n} __extern_always_inline const char *strpbrk(const char *__s, const char *__accept) __THROW {\n\t\treturn __builtin_strpbrk(__s, __accept);\n}\n# endif\n}\n#else\nextern char *strpbrk(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strstr(char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strstr(const char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strstr(char *__haystack, const char *__needle) __THROW\n{\n\treturn __builtin_strstr(__haystack, __needle);\n} __extern_always_inline const char *strstr(const char *__haystack, const char *__needle) __THROW {\n\t\treturn __builtin_strstr(__haystack, __needle);\n}\n# endif\n}\n#else\nextern char *strstr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n\n/* Divide S into tokens separated by characters in DELIM.  */\nextern char *strtok(char *__restrict __s, const char *__restrict __delim)\n__THROW __nonnull((2));\n\n/* Divide S into tokens separated by characters in DELIM.  Information\n   passed between calls are stored in SAVE_PTR.  */\nextern char *__strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#ifdef __USE_POSIX\nextern char *strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#endif\n\n#ifdef __USE_GNU\n/* Similar to `strstr' but this function ignores the case of both strings.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strcasestr(char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\nextern \"C++\" const char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\n# else\nextern char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\n\n#ifdef __USE_GNU\n/* Find the first occurrence of NEEDLE in HAYSTACK.\n   NEEDLE is NEEDLELEN bytes long;\n   HAYSTACK is HAYSTACKLEN bytes long.  */\nextern void *memmem(const void *__haystack, size_t __haystacklen, const void *__needle, size_t __needlelen)\n__THROW __attribute_pure__ __nonnull((1, 3));\n\n/* Copy N bytes of SRC to DEST, return pointer to bytes after the\n   last written byte.  */\nextern void *__mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern void *mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Return the length of S.  */\nextern size_t strlen(const char *__s)\n__THROW __attribute_pure__ __nonnull((1));\n\n#ifdef\t__USE_XOPEN2K8\n/* Find the length of STRING, but scan at most MAXLEN characters.\n   If no '\\0' terminator is found in that many characters, return MAXLEN.  */\nextern size_t strnlen(const char *__string, size_t __maxlen)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n/* Return a string describing the meaning of the `errno' code in ERRNUM.  */\nextern char *strerror(int __errnum) __THROW;\n#ifdef __USE_XOPEN2K\n/* Reentrant version of `strerror'.\n   There are 2 flavors of `strerror_r', GNU which returns the string\n   and may or may not use the supplied temporary buffer and POSIX one\n   which fills the string into the buffer.\n   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L\n   without -D_GNU_SOURCE is needed, otherwise the GNU version is\n   preferred.  */\n# if defined __USE_XOPEN2K && !defined __USE_GNU\n/* Fill BUF with a string describing the meaning of the `errno' code in\n   ERRNUM.  */\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(strerror_r, (int __errnum, char *__buf, size_t __buflen), __xpg_strerror_r) __nonnull((2));\n#  else\nextern int __xpg_strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n#   define strerror_r __xpg_strerror_r\n#  endif\n# else\n/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be\n   used.  */\nextern char *strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Translate error number to string according to the locale L.  */\nextern char *strerror_l(int __errnum, locale_t __l) __THROW;\n#endif\n\n#ifdef __USE_MISC\n# include <strings.h>\n\n/* Set N bytes of S to 0.  The compiler will not delete a call to this\n   function, even if S is dead after the call.  */\nextern void explicit_bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n/* Return the next DELIM-delimited token from *STRINGP,\n   terminating it with a '\\0', and update *STRINGP to point past it.  */\nextern char *strsep(char **__restrict __stringp, const char *__restrict __delim)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_XOPEN2K8\n/* Return a string describing the meaning of the signal number in SIG.  */\nextern char *strsignal(int __sig) __THROW;\n\n/* Copy SRC to DEST, returning the address of the terminating '\\0' in DEST.  */\nextern char *__stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\nextern char *stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern char *__stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern char *stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_GNU\n/* Compare S1 and S2 as strings holding name & indices/version numbers.  */\nextern int strverscmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Sautee STRING briskly.  */\nextern char *strfry(char *__string)\n__THROW __nonnull((1));\n\n/* Frobnicate N bytes of S.  */\nextern void *memfrob(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n# ifndef basename\n/* Return the file name within directory of FILENAME.  We don't\n   declare the function if the `basename' macro is available (defined\n   in <libgen.h>) which makes the XPG version of this function\n   available.  */\n#  ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *basename(char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\nextern \"C++\" const char *basename(const char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\n#  else\nextern char *basename(const char *__filename)\n__THROW __nonnull((1));\n#  endif\n# endif\n#endif\n\n#if __GNUC_PREREQ (3,4)\n# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n/* Functions with security checks.  */\n#  include <bits/string_fortified.h>\n# endif\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* string.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/strings.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STRINGS_H\n#define\t_STRINGS_H\t1\n\n#include <features.h>\n#define __need_size_t\n#include <stddef.h>\n\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n# define __CORRECT_ISO_CPP_STRINGS_H_PROTO\n#endif\n\n__BEGIN_DECLS\n#if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Compare N bytes of S1 and S2 (same as memcmp).  */\nextern int bcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */\nextern void bcopy(const void *__src, void *__dest, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Set N bytes of S to 0.  */\nextern void bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n/* Find the first occurrence of C in S (same as strchr).  */\n# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *index(char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\textern const char *index(const char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\n#  if defined __OPTIMIZE__\n\t__extern_always_inline char *index(char *__s, int __c) __THROW\n{\n\treturn __builtin_index(__s, __c);\n} __extern_always_inline const char *index(const char *__s, int __c) __THROW {\n\t\treturn __builtin_index(__s, __c);\n}\n#  endif\n}\n# else\nextern char *index(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n\n/* Find the last occurrence of C in S (same as strrchr).  */\n# ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *rindex(char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\textern const char *rindex(const char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\n#  if defined __OPTIMIZE__\n\t__extern_always_inline char *rindex(char *__s, int __c) __THROW\n{\n\treturn __builtin_rindex(__s, __c);\n} __extern_always_inline const char *rindex(const char *__s, int __c) __THROW {\n\t\treturn __builtin_rindex(__s, __c);\n}\n#  endif\n}\n# else\nextern char *rindex(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n#endif\n\n#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI\n/* Return the position of the first bit set in I, or 0 if none are set.\n   The least-significant bit is position 1, the most-significant 32.  */\nextern int ffs(int __i)\n__THROW __attribute_const__;\n#endif\n\n/* The following two functions are non-standard but necessary for non-32 bit\n   platforms.  */\n# ifdef\t__USE_MISC\nextern int ffsl(long int __l)\n__THROW __attribute_const__;\n__extension__ extern int ffsll(long long int __ll)\n__THROW __attribute_const__;\n# endif\n\n/* Compare S1 and S2, ignoring case.  */\nextern int strcasecmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int strncasecmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n#ifdef\t__USE_XOPEN2K8\n/* POSIX.1-2008 extended locale interface (see locale.h).  */\n# include <bits/types/locale_t.h>\n\n/* Compare S1 and S2, ignoring case, using collation rules from LOC.  */\nextern int strcasecmp_l(const char *__s1, const char *__s2, locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n\n/* Compare no more than N chars of S1 and S2, ignoring case, using\n   collation rules from LOC.  */\nextern int strncasecmp_l(const char *__s1, const char *__s2, size_t __n, locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 4));\n#endif\n\n__END_DECLS\n#if __GNUC_PREREQ (3,4) && __USE_FORTIFY_LEVEL > 0 \\\n    && defined __fortify_function\n/* Functions with security checks.  */\n# if defined __USE_MISC || !defined __USE_XOPEN2K8\n#  include <bits/strings_fortified.h>\n# endif\n#endif\n#endif\t\t\t\t/* strings.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/termios.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 7.1-2 General Terminal Interface\t<termios.h>\n */\n\n#ifndef\t_TERMIOS_H\n#define\t_TERMIOS_H\t1\n\n#include <features.h>\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* We need `pid_t'.  */\n# include <bits/types.h>\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n# endif\n#endif\n\n__BEGIN_DECLS\n/* Get the system-dependent definitions of `struct termios', `tcflag_t',\n   `cc_t', `speed_t', and all the macros specifying the flag bits.  */\n#include <bits/termios.h>\n#ifdef __USE_MISC\n/* Compare a character C to a value VAL from the `c_cc' array in a\n   `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */\n# define CCEQ(val, c)\t((c) == (val) && (val) != _POSIX_VDISABLE)\n#endif\n/* Return the output baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetospeed(const struct termios *__termios_p) __THROW;\n\n/* Return the input baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetispeed(const struct termios *__termios_p) __THROW;\n\n/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetospeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n/* Set the input baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetispeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */\nextern int cfsetspeed(struct termios *__termios_p, speed_t __speed) __THROW;\n#endif\n\n/* Put the state of FD into *TERMIOS_P.  */\nextern int tcgetattr(int __fd, struct termios *__termios_p) __THROW;\n\n/* Set the state of FD to *TERMIOS_P.\n   Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>.  */\nextern int tcsetattr(int __fd, int __optional_actions, const struct termios *__termios_p) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set *TERMIOS_P to indicate raw mode.  */\nextern void cfmakeraw(struct termios *__termios_p) __THROW;\n#endif\n\n/* Send zero bits on FD.  */\nextern int tcsendbreak(int __fd, int __duration) __THROW;\n\n/* Wait for pending output to be written on FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int tcdrain(int __fd);\n\n/* Flush pending data on FD.\n   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>.  */\nextern int tcflush(int __fd, int __queue_selector) __THROW;\n\n/* Suspend or restart transmission on FD.\n   Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>.  */\nextern int tcflow(int __fd, int __action) __THROW;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Get process group ID for session leader for controlling terminal FD.  */\nextern __pid_t tcgetsid(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n# include <sys/ttydefaults.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* termios.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/time.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.23 Date and time\t<time.h>\n */\n\n#ifndef\t_TIME_H\n#define _TIME_H\t1\n\n#include <features.h>\n\n#define __need_size_t\n#define __need_NULL\n#include <stddef.h>\n\n/* This defines CLOCKS_PER_SEC, which is the number of processor clock\n   ticks per second, and possibly a number of other constants.   */\n#include <bits/time.h>\n\n/* Many of the typedefs and structs whose official home is this header\n   may also need to be defined by other headers.  */\n#include <bits/types/clock_t.h>\n#include <bits/types/time_t.h>\n#include <bits/types/struct_tm.h>\n\n#if defined __USE_POSIX199309 || defined __USE_ISOC11\n# include <bits/types/struct_timespec.h>\n#endif\n\n#ifdef __USE_POSIX199309\n# include <bits/types/clockid_t.h>\n# include <bits/types/timer_t.h>\n# include <bits/types/struct_itimerspec.h>\nstruct sigevent;\n#endif\n\n#ifdef __USE_XOPEN2K\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n# include <bits/types/locale_t.h>\n#endif\n\n#ifdef __USE_ISOC11\n/* Time base values for timespec_get.  */\n# define TIME_UTC 1\n#endif\n\n__BEGIN_DECLS\n/* Time used by the program so far (user time + system time).\n   The result / CLOCKS_PER_SEC is program time in seconds.  */\nextern clock_t clock(void) __THROW;\n\n/* Return the current time and put it in *TIMER if TIMER is not NULL.  */\nextern time_t time(time_t * __timer) __THROW;\n\n/* Return the difference between TIME1 and TIME0.  */\nextern double difftime(time_t __time1, time_t __time0)\n__THROW __attribute__ ((__const__));\n\n/* Return the `time_t' representation of TP and normalize TP.  */\nextern time_t mktime(struct tm *__tp) __THROW;\n\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE characters and return the number\n   of characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t strftime(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp) __THROW;\n\n#ifdef __USE_XOPEN\n/* Parse S according to FORMAT and store binary time information in TP.\n   The return value is a pointer to the first unparsed character in S.  */\nextern char *strptime(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp) __THROW;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n\nextern size_t strftime_l(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp, locale_t __loc) __THROW;\n#endif\n\n#ifdef __USE_GNU\nextern char *strptime_l(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp, locale_t __loc) __THROW;\n#endif\n\n/* Return the `struct tm' representation of *TIMER\n   in Universal Coordinated Time (aka Greenwich Mean Time).  */\nextern struct tm *gmtime(const time_t * __timer) __THROW;\n\n/* Return the `struct tm' representation\n   of *TIMER in the local timezone.  */\nextern struct tm *localtime(const time_t * __timer) __THROW;\n\n#ifdef __USE_POSIX\n/* Return the `struct tm' representation of *TIMER in UTC,\n   using *TP to store the result.  */\nextern struct tm *gmtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n\n/* Return the `struct tm' representation of *TIMER in local time,\n   using *TP to store the result.  */\nextern struct tm *localtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n/* Return a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime(const struct tm *__tp) __THROW;\n\n/* Equivalent to `asctime (localtime (timer))'.  */\nextern char *ctime(const time_t * __timer) __THROW;\n\n#ifdef __USE_POSIX\n/* Reentrant versions of the above functions.  */\n\n/* Return in BUF a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime_r(const struct tm *__restrict __tp, char *__restrict __buf) __THROW;\n\n/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */\nextern char *ctime_r(const time_t * __restrict __timer, char *__restrict __buf) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n/* Defined in localtime.c.  */\nextern char *__tzname[2];\t/* Current timezone names.  */\nextern int __daylight;\t\t/* If daylight-saving time is ever in use.  */\nextern long int __timezone;\t/* Seconds west of UTC.  */\n\n#ifdef\t__USE_POSIX\n/* Same as above.  */\nextern char *tzname[2];\n\n/* Set time conversion information from the TZ environment variable.\n   If TZ is not defined, a locale-dependent default is used.  */\nextern void tzset(void) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\nextern int daylight;\nextern long int timezone;\n#endif\n\n#ifdef __USE_MISC\n/* Set the system time to *WHEN.\n   This call is restricted to the superuser.  */\nextern int stime(const time_t * __when) __THROW;\n#endif\n\n/* Nonzero if YEAR is a leap year (every 4 years,\n   except every 100th isn't, and every 400th is).  */\n#define __isleap(year)\t\\\n  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))\n\n#ifdef __USE_MISC\n/* Miscellaneous functions many Unices inherited from the public domain\n   localtime package.  These are included only for compatibility.  */\n\n/* Like `mktime', but for TP represents Universal Time, not local time.  */\nextern time_t timegm(struct tm *__tp) __THROW;\n\n/* Another name for `mktime'.  */\nextern time_t timelocal(struct tm *__tp) __THROW;\n\n/* Return the number of days in YEAR.  */\nextern int dysize(int __year)\n__THROW __attribute__ ((__const__));\n#endif\n\n#ifdef __USE_POSIX199309\n/* Pause execution for a number of nanoseconds.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int nanosleep(const struct timespec *__requested_time, struct timespec *__remaining);\n\n/* Get resolution of clock CLOCK_ID.  */\nextern int clock_getres(clockid_t __clock_id, struct timespec *__res) __THROW;\n\n/* Get current value of clock CLOCK_ID and store it in TP.  */\nextern int clock_gettime(clockid_t __clock_id, struct timespec *__tp) __THROW;\n\n/* Set clock CLOCK_ID to value TP.  */\nextern int clock_settime(clockid_t __clock_id, const struct timespec *__tp) __THROW;\n\n# ifdef __USE_XOPEN2K\n/* High-resolution sleep with the specified clock.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int clock_nanosleep(clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem);\n\n/* Return clock ID for CPU-time clock.  */\nextern int clock_getcpuclockid(pid_t __pid, clockid_t * __clock_id) __THROW;\n# endif\n\n/* Create new per-process timer using CLOCK_ID.  */\nextern int timer_create(clockid_t __clock_id, struct sigevent *__restrict __evp, timer_t * __restrict __timerid) __THROW;\n\n/* Delete timer TIMERID.  */\nextern int timer_delete(timer_t __timerid) __THROW;\n\n/* Set timer TIMERID to VALUE, returning old value in OVALUE.  */\nextern int timer_settime(timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW;\n\n/* Get current value of timer TIMERID and store it in VALUE.  */\nextern int timer_gettime(timer_t __timerid, struct itimerspec *__value) __THROW;\n\n/* Get expiration overrun for timer TIMERID.  */\nextern int timer_getoverrun(timer_t __timerid) __THROW;\n#endif\n\n#ifdef __USE_ISOC11\n/* Set TS to calendar time based in time base BASE.  */\nextern int timespec_get(struct timespec *__ts, int __base)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* Set to one of the following values to indicate an error.\n     1  the DATEMSK environment variable is null or undefined,\n     2  the template file cannot be opened for reading,\n     3  failed to get file status information,\n     4  the template file is not a regular file,\n     5  an error is encountered while reading the template file,\n     6  memory allication failed (not enough memory available),\n     7  there is no line in the template that matches the input,\n     8  invalid input specification Example: February 31 or a time is\n\tspecified that can not be represented in a time_t (representing\n\tthe time in seconds since 00:00:00 UTC, January 1, 1970) */\nextern int getdate_err;\n\n/* Parse the given string as a date specification and return a value\n   representing the value.  The templates from the file identified by\n   the environment variable DATEMSK are used.  In case of an error\n   `getdate_err' is set.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct tm *getdate(const char *__string);\n#endif\n\n#ifdef __USE_GNU\n/* Since `getdate' is not reentrant because of the use of `getdate_err'\n   and the static buffer to return the result in, we provide a thread-safe\n   variant.  The functionality is the same.  The result is returned in\n   the buffer pointed to by RESBUFP and in case of an error the return\n   value is != 0 with the same values as given above for `getdate_err'.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getdate_r(const char *__restrict __string, struct tm *__restrict __resbufp);\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* time.h.  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/unistd.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.10 Symbolic Constants\t\t<unistd.h>\n */\n\n#ifndef\t_UNISTD_H\n#define\t_UNISTD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* These may be used to determine what facilities are present at compile time.\n   Their values can be obtained at run time from `sysconf'.  */\n#ifdef __USE_XOPEN2K8\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008.  */\n# define _POSIX_VERSION\t200809L\n#elif defined __USE_XOPEN2K\n/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001.  */\n# define _POSIX_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995.  */\n# define _POSIX_VERSION\t199506L\n#elif defined __USE_POSIX199309\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993.  */\n# define _POSIX_VERSION\t199309L\n#else\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990.  */\n# define _POSIX_VERSION\t199009L\n#endif\n/* These are not #ifdef __USE_POSIX2 because they are\n   in the theoretically application-owned namespace.  */\n#ifdef __USE_XOPEN2K8\n# define __POSIX2_THIS_VERSION\t200809L\n/* The utilities on GNU systems also correspond to this version.  */\n#elif defined __USE_XOPEN2K\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t199506L\n#else\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t199209L\n#endif\n/* The utilities on GNU systems also correspond to this version.  */\n#define _POSIX2_VERSION\t__POSIX2_THIS_VERSION\n/* This symbol was required until the 2001 edition of POSIX.  */\n#define\t_POSIX2_C_VERSION\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Bindings Option.  */\n#define\t_POSIX2_C_BIND\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Development Utilities Option.  */\n#define\t_POSIX2_C_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   Software Development Utilities Option.  */\n#define\t_POSIX2_SW_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   creation of locales with the localedef utility.  */\n#define _POSIX2_LOCALEDEF       __POSIX2_THIS_VERSION\n/* X/Open version number to which the library conforms.  It is selectable.  */\n#ifdef __USE_XOPEN2K8\n# define _XOPEN_VERSION\t700\n#elif defined __USE_XOPEN2K\n# define _XOPEN_VERSION\t600\n#elif defined __USE_UNIX98\n# define _XOPEN_VERSION\t500\n#else\n# define _XOPEN_VERSION\t4\n#endif\n/* Commands and utilities from XPG4 are available.  */\n#define _XOPEN_XCU_VERSION\t4\n/* We are compatible with the old published standards as well.  */\n#define _XOPEN_XPG2\t1\n#define _XOPEN_XPG3\t1\n#define _XOPEN_XPG4\t1\n/* The X/Open Unix extensions are available.  */\n#define _XOPEN_UNIX\t1\n/* Encryption is present.  */\n#define\t_XOPEN_CRYPT\t1\n/* The enhanced internationalization capabilities according to XPG4.2\n   are present.  */\n#define\t_XOPEN_ENH_I18N\t1\n/* The legacy interfaces are also available.  */\n#define _XOPEN_LEGACY\t1\n/* Get values of POSIX options:\n\n   If these symbols are defined, the corresponding features are\n   always available.  If not, they may be available sometimes.\n   The current values can be obtained with `sysconf'.\n\n   _POSIX_JOB_CONTROL\t\tJob control is supported.\n   _POSIX_SAVED_IDS\t\tProcesses have a saved set-user-ID\n\t\t\t\tand a saved set-group-ID.\n   _POSIX_REALTIME_SIGNALS\tReal-time, queued signals are supported.\n   _POSIX_PRIORITY_SCHEDULING\tPriority scheduling is supported.\n   _POSIX_TIMERS\t\tPOSIX.4 clocks and timers are supported.\n   _POSIX_ASYNCHRONOUS_IO\tAsynchronous I/O is supported.\n   _POSIX_PRIORITIZED_IO\tPrioritized asynchronous I/O is supported.\n   _POSIX_SYNCHRONIZED_IO\tSynchronizing file data is supported.\n   _POSIX_FSYNC\t\t\tThe fsync function is present.\n   _POSIX_MAPPED_FILES\t\tMapping of files to memory is supported.\n   _POSIX_MEMLOCK\t\tLocking of all memory is supported.\n   _POSIX_MEMLOCK_RANGE\t\tLocking of ranges of memory is supported.\n   _POSIX_MEMORY_PROTECTION\tSetting of memory protections is supported.\n   _POSIX_MESSAGE_PASSING\tPOSIX.4 message queues are supported.\n   _POSIX_SEMAPHORES\t\tPOSIX.4 counting semaphores are supported.\n   _POSIX_SHARED_MEMORY_OBJECTS\tPOSIX.4 shared memory objects are supported.\n   _POSIX_THREADS\t\tPOSIX.1c pthreads are supported.\n   _POSIX_THREAD_ATTR_STACKADDR\tThread stack address attribute option supported.\n   _POSIX_THREAD_ATTR_STACKSIZE\tThread stack size attribute option supported.\n   _POSIX_THREAD_SAFE_FUNCTIONS\tThread-safe functions are supported.\n   _POSIX_THREAD_PRIORITY_SCHEDULING\n\t\t\t\tPOSIX.1c thread execution scheduling supported.\n   _POSIX_THREAD_PRIO_INHERIT\tThread priority inheritance option supported.\n   _POSIX_THREAD_PRIO_PROTECT\tThread priority protection option supported.\n   _POSIX_THREAD_PROCESS_SHARED\tProcess-shared synchronization supported.\n   _POSIX_PII\t\t\tProtocol-independent interfaces are supported.\n   _POSIX_PII_XTI\t\tXTI protocol-indep. interfaces are supported.\n   _POSIX_PII_SOCKET\t\tSocket protocol-indep. interfaces are supported.\n   _POSIX_PII_INTERNET\t\tInternet family of protocols supported.\n   _POSIX_PII_INTERNET_STREAM\tConnection-mode Internet protocol supported.\n   _POSIX_PII_INTERNET_DGRAM\tConnectionless Internet protocol supported.\n   _POSIX_PII_OSI\t\tISO/OSI family of protocols supported.\n   _POSIX_PII_OSI_COTS\t\tConnection-mode ISO/OSI service supported.\n   _POSIX_PII_OSI_CLTS\t\tConnectionless ISO/OSI service supported.\n   _POSIX_POLL\t\t\tImplementation supports `poll' function.\n   _POSIX_SELECT\t\tImplementation supports `select' and `pselect'.\n\n   _XOPEN_REALTIME\t\tX/Open realtime support is available.\n   _XOPEN_REALTIME_THREADS\tX/Open realtime thread support is available.\n   _XOPEN_SHM\t\t\tShared memory interface according to XPG4.2.\n\n   _XBS5_ILP32_OFF32\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, pointer, and off_t types.\n   _XBS5_ILP32_OFFBIG\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, and pointer and off_t with at least\n\t\t\t\t64 bits.\n   _XBS5_LP64_OFF64\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, and 64-bit long, pointer, and off_t types.\n   _XBS5_LPBIG_OFFBIG\t\tImplementation provides environment with at\n\t\t\t\tleast 32 bits int and long, pointer, and off_t\n\t\t\t\twith at least 64 bits.\n\n   If any of these symbols is defined as -1, the corresponding option is not\n   true for any file.  If any is defined as other than -1, the corresponding\n   option is true for all files.  If a symbol is not defined at all, the value\n   for a specific file can be obtained from `pathconf' and `fpathconf'.\n\n   _POSIX_CHOWN_RESTRICTED\tOnly the super user can use `chown' to change\n\t\t\t\tthe owner of a file.  `chown' can only be used\n\t\t\t\tto change the group ID of a file to a group of\n\t\t\t\twhich the calling process is a member.\n   _POSIX_NO_TRUNC\t\tPathname components longer than\n\t\t\t\tNAME_MAX generate an error.\n   _POSIX_VDISABLE\t\tIf defined, if the value of an element of the\n\t\t\t\t`c_cc' member of `struct termios' is\n\t\t\t\t_POSIX_VDISABLE, no character will have the\n\t\t\t\teffect associated with that element.\n   _POSIX_SYNC_IO\t\tSynchronous I/O may be performed.\n   _POSIX_ASYNC_IO\t\tAsynchronous I/O may be performed.\n   _POSIX_PRIO_IO\t\tPrioritized Asynchronous I/O may be performed.\n\n   Support for the Large File Support interface is not generally available.\n   If it is available the following constants are defined to one.\n   _LFS64_LARGEFILE\t\tLow-level I/O supports large files.\n   _LFS64_STDIO\t\t\tStandard I/O supports large files.\n   */\n#include <bits/posix_opt.h>\n/* Get the environment definitions from Unix98.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n# include <bits/environments.h>\n#endif\n/* Standard file descriptors.  */\n#define\tSTDIN_FILENO\t0\t/* Standard input.  */\n#define\tSTDOUT_FILENO\t1\t/* Standard output.  */\n#define\tSTDERR_FILENO\t2\t/* Standard error output.  */\n/* All functions that are not declared anywhere else.  */\n#include <bits/types.h>\n#ifndef\t__ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n#endif\n\n#define\t__need_size_t\n#define __need_NULL\n#include <stddef.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n\n# ifndef __off_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#  else\ntypedef __off64_t off_t;\n#  endif\n#  define __off_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#  define __off64_t_defined\n# endif\n\n# ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#  define __useconds_t_defined\n# endif\n\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n# endif\n#endif\t\t\t\t/* X/Open */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n# ifndef __intptr_t_defined\ntypedef __intptr_t intptr_t;\n#  define __intptr_t_defined\n# endif\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n# ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n#  define __socklen_t_defined\n# endif\n#endif\n\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#define\tR_OK\t4\t\t/* Test for read permission.  */\n#define\tW_OK\t2\t\t/* Test for write permission.  */\n#define\tX_OK\t1\t\t/* Test for execute permission.  */\n#define\tF_OK\t0\t\t/* Test for existence.  */\n\n/* Test for access to NAME using the real UID and real GID.  */\nextern int access(const char *__name, int __type)\n__THROW __nonnull((1));\n\n#ifdef __USE_GNU\n/* Test for access to NAME using the effective UID and GID\n   (as normal file operations use).  */\nextern int euidaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n\n/* An alias for `euidaccess', used by some other systems.  */\nextern int eaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Test for access to FILE relative to the directory FD is open on.\n   If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',\n   otherwise use real IDs like `access'.  */\nextern int faccessat(int __fd, const char *__file, int __type, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Values for the WHENCE argument to lseek.  */\n#ifndef\t_STDIO_H\t\t/* <stdio.h> has the same definitions.  */\n# define SEEK_SET\t0\t/* Seek from beginning of file.  */\n# define SEEK_CUR\t1\t/* Seek from current position.  */\n# define SEEK_END\t2\t/* Seek from end of file.  */\n# ifdef __USE_GNU\n#  define SEEK_DATA\t3\t/* Seek to next data.  */\n#  define SEEK_HOLE\t4\t/* Seek to next hole.  */\n# endif\n#endif\n\n#if defined __USE_MISC && !defined L_SET\n/* Old BSD names for the same constants; just for compatibility.  */\n# define L_SET\t\tSEEK_SET\n# define L_INCR\t\tSEEK_CUR\n# define L_XTND\t\tSEEK_END\n#endif\n\n/* Move FD's file position to OFFSET bytes from the\n   beginning of the file (if WHENCE is SEEK_SET),\n   the current position (if WHENCE is SEEK_CUR),\n   or the end of the file (if WHENCE is SEEK_END).\n   Return the new file position.  */\n#ifndef __USE_FILE_OFFSET64\nextern __off_t lseek(int __fd, __off_t __offset, int __whence) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern __off64_t __REDIRECT_NTH(lseek, (int __fd, __off64_t __offset, int __whence), lseek64);\n# else\n#  define lseek lseek64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern __off64_t lseek64(int __fd, __off64_t __offset, int __whence) __THROW;\n#endif\n\n/* Close the file descriptor FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int close(int __fd);\n\n/* Read NBYTES into BUF from FD.  Return the\n   number read, -1 for errors or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t read(int __fd, void *__buf, size_t __nbytes) __wur;\n\n/* Write N bytes of BUF to FD.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t write(int __fd, const void *__buf, size_t __n) __wur;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n# ifndef __USE_FILE_OFFSET64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pread(int __fd, void *__buf, size_t __nbytes, __off_t __offset) __wur;\n\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwrite(int __fd, const void *__buf, size_t __n, __off_t __offset) __wur;\n# else\n#  ifdef __REDIRECT\nextern ssize_t __REDIRECT(pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), pread64) __wur;\nextern ssize_t __REDIRECT(pwrite, (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset), pwrite64) __wur;\n#  else\n#   define pread pread64\n#   define pwrite pwrite64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.  */\nextern ssize_t pread64(int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __wur;\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.  */\nextern ssize_t pwrite64(int __fd, const void *__buf, size_t __n, __off64_t __offset) __wur;\n# endif\n#endif\n\n/* Create a one-way communication channel (pipe).\n   If successful, two file descriptors are stored in PIPEDES;\n   bytes written on PIPEDES[1] can be read from PIPEDES[0].\n   Returns 0 if successful, -1 if not.  */\nextern int pipe(int __pipedes[2])\n__THROW __wur;\n\n#ifdef __USE_GNU\n/* Same as pipe but apply flags passed in FLAGS to the new file\n   descriptors.  */\nextern int pipe2(int __pipedes[2], int __flags)\n__THROW __wur;\n#endif\n\n/* Schedule an alarm.  In SECONDS seconds, the process will get a SIGALRM.\n   If SECONDS is zero, any currently scheduled alarm will be cancelled.\n   The function returns the number of seconds remaining until the last\n   alarm scheduled would have signaled, or zero if there wasn't one.\n   There is no return value to indicate an error, but you can set `errno'\n   to 0 and check its value after calling `alarm', and this might tell you.\n   The signal may come late due to processor scheduling.  */\nextern unsigned int alarm(unsigned int __seconds) __THROW;\n\n/* Make the process sleep for SECONDS seconds, or until a signal arrives\n   and is not ignored.  The function returns the number of seconds less\n   than SECONDS which it actually slept (thus zero if it slept the full time).\n   If a signal handler does a `longjmp' or modifies the handling of the\n   SIGALRM signal while inside `sleep' call, the handling of the SIGALRM\n   signal afterwards is undefined.  There is no return value to indicate\n   error, but if `sleep' returns SECONDS, it probably didn't work.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern unsigned int sleep(unsigned int __seconds);\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Set an alarm to go off (generating a SIGALRM signal) in VALUE\n   microseconds.  If INTERVAL is nonzero, when the alarm goes off, the\n   timer is reset to go off every INTERVAL microseconds thereafter.\n   Returns the number of microseconds remaining before the alarm.  */\nextern __useconds_t ualarm(__useconds_t __value, __useconds_t __interval) __THROW;\n\n/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked\n   or ignored.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int usleep(__useconds_t __useconds);\n#endif\n\n/* Suspend the process until a signal arrives.\n   This always returns -1 and sets `errno' to EINTR.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pause(void);\n\n/* Change the owner and group of FILE.  */\nextern int chown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the owner and group of the file that FD is open on.  */\nextern int fchown(int __fd, __uid_t __owner, __gid_t __group)\n__THROW __wur;\n\n/* Change owner and group of FILE, if it is a symbolic\n   link the ownership of the symbolic link is changed.  */\nextern int lchown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use X/Open Unix.  */\n\n#ifdef __USE_ATFILE\n/* Change the owner and group of FILE relative to the directory FD is open\n   on.  */\nextern int fchownat(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Change the process's working directory to PATH.  */\nextern int chdir(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the process's working directory to the one FD is open on.  */\nextern int fchdir(int __fd)\n__THROW __wur;\n#endif\n\n/* Get the pathname of the current working directory,\n   and put it in SIZE bytes of BUF.  Returns NULL if the\n   directory couldn't be determined or SIZE was too small.\n   If successful, returns BUF.  In GNU, if BUF is NULL,\n   an array is allocated with `malloc'; the array is SIZE\n   bytes long, unless SIZE == 0, in which case it is as\n   big as necessary.  */\nextern char *getcwd(char *__buf, size_t __size)\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the current directory name.\n   If the environment variable `PWD' is set, and its value is correct,\n   that value is used.  */\nextern char *get_current_dir_name(void) __THROW;\n#endif\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Put the absolute pathname of the current working directory in BUF.\n   If successful, return BUF.  If not, put an error message in\n   BUF and return NULL.  BUF should be at least PATH_MAX bytes long.  */\nextern char *getwd(char *__buf)\n__THROW __nonnull((1))\n__attribute_deprecated__ __wur;\n#endif\n\n/* Duplicate FD, returning a new file descriptor on the same file.  */\nextern int dup(int __fd)\n__THROW __wur;\n\n/* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */\nextern int dup2(int __fd, int __fd2) __THROW;\n\n#ifdef __USE_GNU\n/* Duplicate FD to FD2, closing FD2 and making it open on the same\n   file while setting flags according to FLAGS.  */\nextern int dup3(int __fd, int __fd2, int __flags) __THROW;\n#endif\n\n/* NULL-terminated array of \"NAME=VALUE\" environment variables.  */\nextern char **__environ;\n#ifdef __USE_GNU\nextern char **environ;\n#endif\n\n/* Replace the current process, executing PATH with arguments ARGV and\n   environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */\nextern int execve(const char *__path, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_XOPEN2K8\n/* Execute the file FD refers to, overlaying the running program image.\n   ARGV and ENVP are passed to the new program, as for `execve'.  */\nextern int fexecve(int __fd, char *const __argv[], char *const __envp[])\n__THROW __nonnull((2));\n#endif\n\n/* Execute PATH with arguments ARGV and environment from `environ'.  */\nextern int execv(const char *__path, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until a NULL pointer,\n   and the argument after that for environment.  */\nextern int execle(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until\n   a NULL pointer and environment from `environ'.  */\nextern int execl(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvp(const char *__file, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if\n   it contains no slashes, with all arguments after FILE until a\n   NULL pointer and environment from `environ'.  */\nextern int execlp(const char *__file, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_GNU\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvpe(const char *__file, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Add INC to priority of the current process.  */\nextern int nice(int __inc)\n__THROW __wur;\n#endif\n\n/* Terminate program execution with the low-order 8 bits of STATUS.  */\nextern void _exit(int __status) __attribute__ ((__noreturn__));\n\n/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';\n   the `_SC_*' symbols for the NAME argument to `sysconf';\n   and the `_CS_*' symbols for the NAME argument to `confstr'.  */\n#include <bits/confname.h>\n\n/* Get file-specific configuration information about PATH.  */\nextern long int pathconf(const char *__path, int __name)\n__THROW __nonnull((1));\n\n/* Get file-specific configuration about descriptor FD.  */\nextern long int fpathconf(int __fd, int __name) __THROW;\n\n/* Get the value of the system variable NAME.  */\nextern long int sysconf(int __name) __THROW;\n\n#ifdef\t__USE_POSIX2\n/* Get the value of the string-valued system variable NAME.  */\nextern size_t confstr(int __name, char *__buf, size_t __len) __THROW;\n#endif\n\n/* Get the process ID of the calling process.  */\nextern __pid_t getpid(void) __THROW;\n\n/* Get the process ID of the calling process's parent.  */\nextern __pid_t getppid(void) __THROW;\n\n/* Get the process group ID of the calling process.  */\nextern __pid_t getpgrp(void) __THROW;\n\n/* Get the process group ID of process PID.  */\nextern __pid_t __getpgid(__pid_t __pid) __THROW;\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\nextern __pid_t getpgid(__pid_t __pid) __THROW;\n#endif\n\n/* Set the process group ID of the process matching PID to PGID.\n   If PID is zero, the current process's process group ID is set.\n   If PGID is zero, the process ID of the process is used.  */\nextern int setpgid(__pid_t __pid, __pid_t __pgid) __THROW;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Both System V and BSD have `setpgrp' functions, but with different\n   calling conventions.  The BSD function is the same as POSIX.1 `setpgid'\n   (above).  The System V function takes no arguments and puts the calling\n   process in its on group like `setpgid (0, 0)'.\n\n   New programs should always use `setpgid' instead.\n\n   GNU provides the POSIX.1 function.  */\n\n/* Set the process group ID of the calling process to its own PID.\n   This is exactly the same as `setpgid (0, 0)'.  */\nextern int setpgrp(void) __THROW;\n\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n/* Create a new session with the calling process as its leader.\n   The process group IDs of the session and the calling process\n   are set to the process ID of the calling process, which is returned.  */\nextern __pid_t setsid(void) __THROW;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Return the session ID of the given process.  */\nextern __pid_t getsid(__pid_t __pid) __THROW;\n#endif\n\n/* Get the real user ID of the calling process.  */\nextern __uid_t getuid(void) __THROW;\n\n/* Get the effective user ID of the calling process.  */\nextern __uid_t geteuid(void) __THROW;\n\n/* Get the real group ID of the calling process.  */\nextern __gid_t getgid(void) __THROW;\n\n/* Get the effective group ID of the calling process.  */\nextern __gid_t getegid(void) __THROW;\n\n/* If SIZE is zero, return the number of supplementary groups\n   the calling process is in.  Otherwise, fill in the group IDs\n   of its supplementary groups in LIST and return the number written.  */\nextern int getgroups(int __size, __gid_t __list[])\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return nonzero iff the calling process is in group GID.  */\nextern int group_member(__gid_t __gid) __THROW;\n#endif\n\n/* Set the user ID of the calling process to UID.\n   If the calling process is the super-user, set the real\n   and effective user IDs, and the saved set-user-ID to UID;\n   if not, the effective user ID is set to UID.  */\nextern int setuid(__uid_t __uid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real user ID of the calling process to RUID,\n   and the effective user ID of the calling process to EUID.  */\nextern int setreuid(__uid_t __ruid, __uid_t __euid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective user ID of the calling process to UID.  */\nextern int seteuid(__uid_t __uid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n/* Set the group ID of the calling process to GID.\n   If the calling process is the super-user, set the real\n   and effective group IDs, and the saved set-group-ID to GID;\n   if not, the effective group ID is set to GID.  */\nextern int setgid(__gid_t __gid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real group ID of the calling process to RGID,\n   and the effective group ID of the calling process to EGID.  */\nextern int setregid(__gid_t __rgid, __gid_t __egid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective group ID of the calling process to GID.  */\nextern int setegid(__gid_t __gid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_GNU\n/* Fetch the real user ID, effective user ID, and saved-set user ID,\n   of the calling process.  */\nextern int getresuid(__uid_t * __ruid, __uid_t * __euid, __uid_t * __suid) __THROW;\n\n/* Fetch the real group ID, effective group ID, and saved-set group ID,\n   of the calling process.  */\nextern int getresgid(__gid_t * __rgid, __gid_t * __egid, __gid_t * __sgid) __THROW;\n\n/* Set the real user ID, effective user ID, and saved-set user ID,\n   of the calling process to RUID, EUID, and SUID, respectively.  */\nextern int setresuid(__uid_t __ruid, __uid_t __euid, __uid_t __suid)\n__THROW __wur;\n\n/* Set the real group ID, effective group ID, and saved-set group ID,\n   of the calling process to RGID, EGID, and SGID, respectively.  */\nextern int setresgid(__gid_t __rgid, __gid_t __egid, __gid_t __sgid)\n__THROW __wur;\n#endif\n\n/* Clone the calling process, creating an exact copy.\n   Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t fork(void) __THROWNL;\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Clone the calling process, but without copying the whole address space.\n   The calling process is suspended until the new process exits or is\n   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t vfork(void) __THROW;\n#endif\t\t\t\t/* Use misc or XPG < 7. */\n\n/* Return the pathname of the terminal FD is open on, or NULL on errors.\n   The returned storage is good only until the next call to this function.  */\nextern char *ttyname(int __fd) __THROW;\n\n/* Store at most BUFLEN characters of the pathname of the terminal FD is\n   open on in BUF.  Return 0 on success, otherwise an error number.  */\nextern int ttyname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n\n/* Return 1 if FD is a valid descriptor associated\n   with a terminal, zero if not.  */\nextern int isatty(int __fd) __THROW;\n\n#ifdef __USE_MISC\n/* Return the index into the active-logins file (utmp) for\n   the controlling terminal.  */\nextern int ttyslot(void) __THROW;\n#endif\n\n/* Make a link to FROM named TO.  */\nextern int link(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n#ifdef __USE_ATFILE\n/* Like link but relative paths in TO and FROM are interpreted relative\n   to FROMFD and TOFD respectively.  */\nextern int linkat(int __fromfd, const char *__from, int __tofd, const char *__to, int __flags)\n__THROW __nonnull((2, 4)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n/* Make a symbolic link to FROM named TO.  */\nextern int symlink(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n/* Read the contents of the symbolic link PATH into no more than\n   LEN bytes of BUF.  The contents are not null-terminated.\n   Returns the number of characters read, or -1 for errors.  */\nextern ssize_t readlink(const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((1, 2)) __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_ATFILE\n/* Like symlink but a relative path in TO is interpreted relative to TOFD.  */\nextern int symlinkat(const char *__from, int __tofd, const char *__to)\n__THROW __nonnull((1, 3)) __wur;\n\n/* Like readlink but a relative PATH is interpreted relative to FD.  */\nextern ssize_t readlinkat(int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((2, 3)) __wur;\n#endif\n\n/* Remove the link NAME.  */\nextern int unlink(const char *__name)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Remove the link NAME relative to FD.  */\nextern int unlinkat(int __fd, const char *__name, int __flag)\n__THROW __nonnull((2));\n#endif\n\n/* Remove the directory PATH.  */\nextern int rmdir(const char *__path)\n__THROW __nonnull((1));\n\n/* Return the foreground process group ID of FD.  */\nextern __pid_t tcgetpgrp(int __fd) __THROW;\n\n/* Set the foreground process group ID of FD set PGRP_ID.  */\nextern int tcsetpgrp(int __fd, __pid_t __pgrp_id) __THROW;\n\n/* Return the login name of the user.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *getlogin(void);\n#ifdef __USE_POSIX199506\n/* Return at most NAME_LEN characters of the login name of the user in NAME.\n   If it cannot be determined or some other error occurred, return the error\n   code.  Otherwise return 0.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getlogin_r(char *__name, size_t __name_len) __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* Set the login name returned by `getlogin'.  */\nextern int setlogin(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_POSIX2\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.  */\n# include <bits/getopt_posix.h>\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n/* Put the name of the current host in no more than LEN bytes of NAME.\n   The result is null-terminated if LEN is large enough for the full\n   name and the terminator.  */\nextern int gethostname(char *__name, size_t __len)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_MISC\n/* Set the name of the current host to NAME, which is LEN bytes long.\n   This call is restricted to the super-user.  */\nextern int sethostname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Set the current machine's Internet number to ID.\n   This call is restricted to the super-user.  */\nextern int sethostid(long int __id)\n__THROW __wur;\n\n/* Get and set the NIS (aka YP) domain name, if any.\n   Called just like `gethostname' and `sethostname'.\n   The NIS domain name is usually the empty string when not using NIS.  */\nextern int getdomainname(char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\nextern int setdomainname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Revoke access permissions to all processes currently communicating\n   with the control terminal, and then send a SIGHUP signal to the process\n   group of the control terminal.  */\nextern int vhangup(void) __THROW;\n\n/* Revoke the access of all descriptors currently open on FILE.  */\nextern int revoke(const char *__file)\n__THROW __nonnull((1)) __wur;\n\n/* Enable statistical profiling, writing samples of the PC into at most\n   SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling\n   is enabled, the system examines the user PC and increments\n   SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536].  If SCALE is zero,\n   disable profiling.  Returns zero on success, -1 on error.  */\nextern int profil(unsigned short int *__sample_buffer, size_t __size, size_t __offset, unsigned int __scale)\n__THROW __nonnull((1));\n\n/* Turn accounting on if NAME is an existing file.  The system will then write\n   a record for each process as it terminates, to this file.  If NAME is NULL,\n   turn accounting off.  This call is restricted to the super-user.  */\nextern int acct(const char *__name) __THROW;\n\n/* Successive calls return the shells listed in `/etc/shells'.  */\nextern char *getusershell(void) __THROW;\nextern void endusershell(void) __THROW;\t/* Discard cached info.  */\nextern void setusershell(void) __THROW;\t/* Rewind and re-read the file.  */\n\n/* Put the program in the background, and dissociate from the controlling\n   terminal.  If NOCHDIR is zero, do `chdir (\"/\")'.  If NOCLOSE is zero,\n   redirects stdin, stdout, and stderr to /dev/null.  */\nextern int daemon(int __nochdir, int __noclose)\n__THROW __wur;\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Make PATH be the root directory (the starting point for absolute paths).\n   This call is restricted to the super-user.  */\nextern int chroot(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n/* Prompt with PROMPT and read a string from the terminal without echoing.\n   Uses /dev/tty if possible; otherwise stderr and stdin.  */\nextern char *getpass(const char *__prompt) __nonnull((1));\n#endif\t\t\t\t/* Use misc || X/Open.  */\n\n/* Make all changes done to FD actually appear on disk.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fsync(int __fd);\n\n#ifdef __USE_GNU\n/* Make all changes done to all files on the file system associated\n   with FD actually appear on disk.  */\nextern int syncfs(int __fd) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n\n/* Return identifier for the current host.  */\nextern long int gethostid(void);\n\n/* Make all changes done to all files actually appear on disk.  */\nextern void sync(void) __THROW;\n\n# if defined __USE_MISC || !defined __USE_XOPEN2K\n/* Return the number of bytes in a page.  This is the system's page size,\n   which is not necessarily the same as the hardware page size.  */\nextern int getpagesize(void)\n__THROW __attribute__ ((__const__));\n\n/* Return the maximum number of file descriptors\n   the current process could possibly have.  */\nextern int getdtablesize(void) __THROW;\n# endif\n\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n\n/* Truncate FILE to LENGTH bytes.  */\n# ifndef __USE_FILE_OFFSET64\nextern int truncate(const char *__file, __off_t __length)\n__THROW __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(truncate, (const char *__file, __off64_t __length), truncate64) __nonnull((1)) __wur;\n#  else\n#   define truncate truncate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int truncate64(const char *__file, __off64_t __length)\n__THROW __nonnull((1)) __wur;\n# endif\n\n#endif\t\t\t\t/* Use X/Open Unix || POSIX 2008.  */\n\n#if defined __USE_POSIX199309 \\\n    || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n\n/* Truncate the file FD is open on to LENGTH bytes.  */\n# ifndef __USE_FILE_OFFSET64\nextern int ftruncate(int __fd, __off_t __length)\n__THROW __wur;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(ftruncate, (int __fd, __off64_t __length), ftruncate64) __wur;\n#  else\n#   define ftruncate ftruncate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int ftruncate64(int __fd, __off64_t __length)\n__THROW __wur;\n# endif\n\n#endif\t\t\t\t/* Use POSIX.1b || X/Open Unix || XPG6.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n\n/* Set the end of accessible data space (aka \"the break\") to ADDR.\n   Returns zero on success and -1 for errors (with errno set).  */\nextern int brk(void *__addr)\n__THROW __wur;\n\n/* Increase or decrease the end of accessible data space by DELTA bytes.\n   If successful, returns the address the previous end of data space\n   (i.e. the beginning of the new space, if DELTA > 0);\n   returns (void *) -1 for errors (with errno set).  */\nextern void *sbrk(intptr_t __delta) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Invoke `system call' number SYSNO, passing it the remaining arguments.\n   This is completely system-dependent, and not often useful.\n\n   In Unix, `syscall' sets `errno' for all errors and most calls return -1\n   for errors; in many systems you cannot pass arguments or get return\n   values for all system calls (`pipe', `fork', and `getppid' typically\n   among them).\n\n   In Mach, all system calls take normal arguments and always return an\n   error code (zero for success).  */\nextern long int syscall(long int __sysno, ...) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK\n/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n# define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n# define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n# define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n# define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n# ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, __off_t __len) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64) __wur;\n#  else\n#   define lockf lockf64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, __off64_t __len) __wur;\n# endif\n#endif\t\t\t\t/* Use misc and F_LOCK not already defined.  */\n\n#ifdef __USE_GNU\n\n/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'\n   set to EINTR.  */\n\n# define TEMP_FAILURE_RETRY(expression) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({ long int __result;\t\t\t\t\t\t      \\\n       do __result = (long int) (expression);\t\t\t\t      \\\n       while (__result == -1L && errno == EINTR);\t\t\t      \\\n       __result; }))\n\n/* Copy LENGTH bytes from INFD to OUTFD.  */\nssize_t copy_file_range(int __infd, __off64_t * __pinoff, int __outfd, __off64_t * __poutoff, size_t __length, unsigned int __flags);\n#endif\t\t\t\t/* __USE_GNU */\n\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n/* Synchronize at least the data part of a file with the underlying\n   media.  */\nextern int fdatasync(int __fildes);\n#endif\t\t\t\t/* Use POSIX199309 */\n\n/* XPG4.2 specifies that prototypes for the encryption functions must\n   be defined here.  */\n#ifdef\t__USE_XOPEN\n/* Encrypt at most 8 characters from KEY using salt to perturb DES.  */\nextern char *crypt(const char *__key, const char *__salt)\n__THROW __nonnull((1, 2));\n\n/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt\n   block in place.  */\nextern void encrypt(char *__glibc_block, int __edflag)\n__THROW __nonnull((1));\n\n/* Swab pairs bytes in the first N bytes of the area pointed to by\n   FROM and copy the result to TO.  The value of TO must not be in the\n   range [FROM - N + 1, FROM - 1].  If N is odd the first byte in FROM\n   is without partner.  */\nextern void swab(const void *__restrict __from, void *__restrict __to, ssize_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Prior to Issue 6, the Single Unix Specification required these\n   prototypes to appear in this header.  They are also found in\n   <stdio.h>.  */\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n\n/* Return the name of the current user.  */\nextern char *cuserid(char *__s);\n#endif\n\n/* Unix98 requires this function to be declared here.  In other\n   standards it is in <pthread.h>.  */\n#if defined __USE_UNIX98 && !defined __USE_XOPEN2K\nextern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on\n   success or -1 on error.  */\nint getentropy(void *__buffer, size_t __length) __wur;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/unistd.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* unistd.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/utime.h",
    "content": "/* Copyright (C) 1991-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6.6 Set File Access and Modification Times  <utime.h>\n */\n\n#ifndef\t_UTIME_H\n#define\t_UTIME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n# include <bits/types/time_t.h>\n#endif\n/* Structure describing file times.  */\n    struct utimbuf {\n\t__time_t actime;\t/* Access time.  */\n\t__time_t modtime;\t/* Modification time.  */\n};\n\n/* Set the access and modification times of FILE to those given in\n   *FILE_TIMES.  If FILE_TIMES is NULL, set them to the current time.  */\nextern int utime(const char *__file, const struct utimbuf *__file_times)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* utime.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/wchar.h",
    "content": "/* Copyright (C) 1995-2018 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *      ISO C99 Standard: 7.24\n *\tExtended multibyte and wide character utilities\t<wchar.h>\n */\n\n#ifndef _WCHAR_H\n#define _WCHAR_H 1\n\n#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION\n#include <bits/libc-header-start.h>\n\n/* Gather machine dependent type support.  */\n#include <bits/floatn.h>\n\n#define __need_size_t\n#define __need_wchar_t\n#define __need_NULL\n#include <stddef.h>\n\n#define __need___va_list\n#include <stdarg.h>\n\n#include <bits/wchar.h>\n#include <bits/types/wint_t.h>\n#include <bits/types/mbstate_t.h>\n#include <bits/types/__FILE.h>\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n# include <bits/types/FILE.h>\n#endif\n#ifdef __USE_XOPEN2K8\n# include <bits/types/locale_t.h>\n#endif\n\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n# define __CORRECT_ISO_CPP_WCHAR_H_PROTO\n#endif\n\n#ifndef WCHAR_MIN\n/* These constants might also be defined in <inttypes.h>.  */\n# define WCHAR_MIN __WCHAR_MIN\n# define WCHAR_MAX __WCHAR_MAX\n#endif\n\n#ifndef WEOF\n# define WEOF (0xffffffffu)\n#endif\n\n/* All versions of XPG prior to the publication of ISO C99 required\n   the bulk of <wctype.h>'s declarations to appear in this header\n   (because <wctype.h> did not exist prior to C99).  In POSIX.1-2001\n   those declarations were marked as XSI extensions; in -2008 they\n   were additionally marked as obsolescent.  _GNU_SOURCE mode\n   anticipates the removal of these declarations in the next revision\n   of POSIX.  */\n#if (defined __USE_XOPEN && !defined __USE_GNU \\\n     && !(defined __USE_XOPEN2K && !defined __USE_XOPEN2KXSI))\n# include <bits/wctype-wchar.h>\n#endif\n\n__BEGIN_DECLS\n/* This incomplete type is defined in <time.h> but needed here because\n   of `wcsftime'.  */\n    struct tm;\n\n/* Copy SRC to DEST.  */\nextern wchar_t *wcscpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N wide-characters of SRC to DEST.  */\nextern wchar_t *wcsncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern wchar_t *wcscat(wchar_t * __restrict __dest, const wchar_t * __restrict __src)\n__THROW __nonnull((1, 2));\n/* Append no more than N wide-characters of SRC onto DEST.  */\nextern wchar_t *wcsncat(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Compare S1 and S2.  */\nextern int wcscmp(const wchar_t * __s1, const wchar_t * __s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Compare N wide-characters of S1 and S2.  */\nextern int wcsncmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n#ifdef __USE_XOPEN2K8\n/* Compare S1 and S2, ignoring case.  */\nextern int wcscasecmp(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int wcsncasecmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\nextern int wcscasecmp_l(const wchar_t * __s1, const wchar_t * __s2, locale_t __loc) __THROW;\n\nextern int wcsncasecmp_l(const wchar_t * __s1, const wchar_t * __s2, size_t __n, locale_t __loc) __THROW;\n#endif\n\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the current locale.  */\nextern int wcscoll(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n\n#ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the given locale.  */\nextern int wcscoll_l(const wchar_t * __s1, const wchar_t * __s2, locale_t __loc) __THROW;\n\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm_l(wchar_t * __s1, const wchar_t * __s2, size_t __n, locale_t __loc) __THROW;\n\n/* Duplicate S, returning an identical malloc'd string.  */\nextern wchar_t *wcsdup(const wchar_t * __s)\n__THROW __attribute_malloc__;\n#endif\n\n/* Find the first occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcschr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\n#else\nextern wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n/* Find the last occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsrchr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\n#else\nextern wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n\n#ifdef __USE_GNU\n/* This function is similar to `wcschr'.  But it returns a pointer to\n   the closing NUL wide character in case C is not found in S.  */\nextern wchar_t *wcschrnul(const wchar_t * __s, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters not in REJECT.  */\nextern size_t wcscspn(const wchar_t * __wcs, const wchar_t * __reject)\n__THROW __attribute_pure__;\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters in  ACCEPT.  */\nextern size_t wcsspn(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n/* Find the first occurrence in WCS of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcspbrk(wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\n#else\nextern wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsstr(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\n#else\nextern wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n#endif\n\n/* Divide WCS into tokens separated by characters in DELIM.  */\nextern wchar_t *wcstok(wchar_t * __restrict __s, const wchar_t * __restrict __delim, wchar_t ** __restrict __ptr) __THROW;\n\n/* Return the number of wide characters in S.  */\nextern size_t wcslen(const wchar_t * __s)\n__THROW __attribute_pure__;\n\n#ifdef __USE_XOPEN\n/* Another name for `wcsstr' from XPG4.  */\n# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcswcs(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\n# else\nextern wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Return the number of wide characters in S, but at most MAXLEN.  */\nextern size_t wcsnlen(const wchar_t * __s, size_t __maxlen)\n__THROW __attribute_pure__;\n#endif\n\n/* Search N wide characters of S for C.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wmemchr(wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\n#else\nextern wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __attribute_pure__;\n#endif\n\n/* Compare N wide characters of S1 and S2.  */\nextern int wmemcmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__;\n\n/* Copy N wide characters of SRC to DEST.  */\nextern wchar_t *wmemcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n\n/* Copy N wide characters of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern wchar_t *wmemmove(wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Set N wide characters of S to C.  */\nextern wchar_t *wmemset(wchar_t * __s, wchar_t __c, size_t __n) __THROW;\n\n#ifdef __USE_GNU\n/* Copy N wide characters of SRC to DEST and return pointer to following\n   wide character.  */\nextern wchar_t *wmempcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n#endif\n\n/* Determine whether C constitutes a valid (one-byte) multibyte\n   character.  */\nextern wint_t btowc(int __c) __THROW;\n\n/* Determine whether C corresponds to a member of the extended\n   character set whose multibyte representation is a single byte.  */\nextern int wctob(wint_t __c) __THROW;\n\n/* Determine whether PS points to an object representing the initial\n   state.  */\nextern int mbsinit(const mbstate_t * __ps)\n__THROW __attribute_pure__;\n\n/* Write wide character representation of multibyte character pointed\n   to by S to PWC.  */\nextern size_t mbrtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n, mbstate_t * __restrict __p) __THROW;\n\n/* Write multibyte representation of wide character WC to S.  */\nextern size_t wcrtomb(char *__restrict __s, wchar_t __wc, mbstate_t * __restrict __ps) __THROW;\n\n/* Return number of bytes in multibyte character pointed to by S.  */\nextern size_t __mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\nextern size_t mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n/* Define inline function as optimization.  */\n\n/* We can use the BTOWC and WCTOB optimizations since we know that all\n   locales must use ASCII encoding for the values in the ASCII range\n   and because the wchar_t encoding is always ISO 10646.  */\nextern wint_t __btowc_alias(int __c) __asm(\"btowc\");\n__extern_inline wint_t __NTH(btowc(int __c))\n{\n\treturn (__builtin_constant_p(__c) && __c >= '\\0' && __c <= '\\x7f' ? (wint_t) __c : __btowc_alias(__c));\n}\n\nextern int __wctob_alias(wint_t __c) __asm(\"wctob\");\n__extern_inline int __NTH(wctob(wint_t __wc))\n{\n\treturn (__builtin_constant_p(__wc) && __wc >= L'\\0' && __wc <= L'\\x7f' ? (int)__wc : __wctob_alias(__wc));\n}\n\n__extern_inline size_t __NTH(mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps))\n{\n\treturn (__ps != NULL ? mbrtowc(NULL, __s, __n, __ps) : __mbrlen(__s, __n, NULL));\n}\n#endif\n\n/* Write wide character representation of multibyte character string\n   SRC to DST.  */\nextern size_t mbsrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of wide character string\n   SRC to DST.  */\nextern size_t wcsrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n#ifdef\t__USE_XOPEN2K8\n/* Write wide character representation of at most NMC bytes of the\n   multibyte character string SRC to DST.  */\nextern size_t mbsnrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __nmc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of at most NWC characters\n   from the wide character string SRC to DST.  */\nextern size_t wcsnrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __nwc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n#endif\t\t\t\t/* use POSIX 2008 */\n\n/* The following functions are extensions found in X/Open CAE.  */\n#ifdef __USE_XOPEN\n/* Determine number of column positions required for C.  */\nextern int wcwidth(wchar_t __c) __THROW;\n\n/* Determine number of column positions required for first N wide\n   characters (or fewer if S ends before this) in S.  */\nextern int wcswidth(const wchar_t * __s, size_t __n) __THROW;\n#endif\t\t\t\t/* Use X/Open.  */\n\n/* Convert initial portion of the wide string NPTR to `double'\n   representation.  */\nextern double wcstod(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n\n#ifdef __USE_ISOC99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float wcstof(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\nextern long double wcstold(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\t\t\t\t/* C99 */\n\n/* Likewise for `_FloatN' and `_FloatNx' when support is enabled.  */\n\n#if __HAVE_FLOAT16 && defined __USE_GNU\nextern _Float16 wcstof16(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT32 && defined __USE_GNU\nextern _Float32 wcstof32(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT64 && defined __USE_GNU\nextern _Float64 wcstof64(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT128 && defined __USE_GNU\nextern _Float128 wcstof128(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT32X && defined __USE_GNU\nextern _Float32x wcstof32x(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT64X && defined __USE_GNU\nextern _Float64x wcstof64x(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n#if __HAVE_FLOAT128X && defined __USE_GNU\nextern _Float128x wcstof128x(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n#endif\n\n/* Convert initial portion of wide string NPTR to `long int'\n   representation.  */\nextern long int wcstol(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long int'\n   representation.  */\nextern unsigned long int wcstoul(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n#ifdef __USE_ISOC99\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoll(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstoull(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n#endif\t\t\t\t/* ISO C99.  */\n\n#ifdef __USE_GNU\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstouq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_GNU\n/* Parallel versions of the functions above which take the locale to\n   use as an additional parameter.  These are GNU extensions inspired\n   by the POSIX.1-2008 extended locale API.  */\nextern long int wcstol_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, locale_t __loc) __THROW;\n\nextern unsigned long int wcstoul_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, locale_t __loc) __THROW;\n\n__extension__ extern long long int wcstoll_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, locale_t __loc) __THROW;\n\n__extension__ extern unsigned long long int wcstoull_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, locale_t __loc) __THROW;\n\nextern double wcstod_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n\nextern float wcstof_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n\nextern long double wcstold_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n\n# if __HAVE_FLOAT16\nextern _Float16 wcstof16_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT32\nextern _Float32 wcstof32_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT64\nextern _Float64 wcstof64_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT128\nextern _Float128 wcstof128_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT32X\nextern _Float32x wcstof32x_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT64X\nextern _Float64x wcstof64x_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n\n# if __HAVE_FLOAT128X\nextern _Float128x wcstof128x_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, locale_t __loc) __THROW;\n# endif\n#endif\t\t\t\t/* use GNU */\n\n#ifdef __USE_XOPEN2K8\n/* Copy SRC to DEST, returning the address of the terminating L'\\0' in\n   DEST.  */\nextern wchar_t *wcpcpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src) __THROW;\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern wchar_t *wcpncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n) __THROW;\n#endif\n\n/* Wide character I/O functions.  */\n\n#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)\n/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces\n   a wide character string.  */\nextern __FILE *open_wmemstream(wchar_t ** __bufloc, size_t * __sizeloc) __THROW;\n#endif\n\n#if defined __USE_ISOC95 || defined __USE_UNIX98\n\n/* Select orientation for stream.  */\nextern int fwide(__FILE * __fp, int __mode) __THROW;\n\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwprintf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */ ;\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wprintf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */ ;\n/* Write formatted output of at most N characters to S.  */\nextern int swprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */ ;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwprintf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */ ;\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwprintf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */ ;\n/* Write formatted output of at most N character to S from argument\n   list ARG.  */\nextern int vswprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */ ;\n\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wscanf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\n/* Read formatted input from S.  */\nextern int swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n\n# if defined __USE_ISOC99 && !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fwscanf, (__FILE * __restrict __stream, const wchar_t * __restrict __format, ...), __isoc99_fwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\nextern int __REDIRECT(wscanf, (const wchar_t * __restrict __format, ...), __isoc99_wscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\nextern int __REDIRECT_NTH(swscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...), __isoc99_swscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n#  else\nextern int __isoc99_fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...);\nextern int __isoc99_wscanf(const wchar_t * __restrict __format, ...);\nextern int __isoc99_swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW;\n#   define fwscanf __isoc99_fwscanf\n#   define wscanf __isoc99_wscanf\n#   define swscanf __isoc99_swscanf\n#  endif\n# endif\n\n#endif\t\t\t\t/* Use ISO C95, C99 and Unix98. */\n\n#ifdef __USE_ISOC99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\n/* Read formatted input from S into argument list ARG.  */\nextern int vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n\n# if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\nextern int __REDIRECT(vfwscanf, (__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vfwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\nextern int __REDIRECT(vwscanf, (const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\nextern int __REDIRECT_NTH(vswscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vswscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n#  else\nextern int __isoc99_vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW;\n#   define vfwscanf __isoc99_vfwscanf\n#   define vwscanf __isoc99_vwscanf\n#   define vswscanf __isoc99_vswscanf\n#  endif\n# endif\n\n#endif\t\t\t\t/* Use ISO C99. */\n\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fgetwc(__FILE * __stream);\nextern wint_t getwc(__FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t getwchar(void);\n\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fputwc(wchar_t __wc, __FILE * __stream);\nextern wint_t putwc(wchar_t __wc, __FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t putwchar(wchar_t __wc);\n\n/* Get a newline-terminated wide character string of finite length\n   from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wchar_t *fgetws(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputws(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t ungetwc(wint_t __wc, __FILE * __stream);\n\n#ifdef __USE_GNU\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t getwc_unlocked(__FILE * __stream);\nextern wint_t getwchar_unlocked(void);\n\n/* This is the wide character version of a GNU extension.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fgetwc_unlocked(__FILE * __stream);\n\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fputwc_unlocked(wchar_t __wc, __FILE * __stream);\n\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t putwc_unlocked(wchar_t __wc, __FILE * __stream);\nextern wint_t putwchar_unlocked(wchar_t __wc);\n\n/* This function does the same as `fgetws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wchar_t *fgetws_unlocked(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* This function does the same as `fputws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputws_unlocked(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n#endif\n\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE wide characters and return the number\n   of wide characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t wcsftime(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp) __THROW;\n\n# ifdef __USE_GNU\n/* Similar to `wcsftime' but takes the information from\n   the provided locale and not the global locale.  */\nextern size_t wcsftime_l(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp, locale_t __loc) __THROW;\n# endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/wchar2.h>\n#endif\n\n#ifdef __LDBL_COMPAT\n# include <bits/wchar-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* wchar.h  */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX\t\t\t/* may be set to #if 1 by ./configure */\n#  define Z_PREFIX_SET\n\n/* all linked symbols and init macros */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_bits        z__tr_flush_bits\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  define adler32_z             z_adler32_z\n#  ifndef Z_SOLO\n#    define compress              z_compress\n#    define compress2             z_compress2\n#    define compressBound         z_compressBound\n#  endif\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define crc32_z               z_crc32_z\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateGetDictionary  z_deflateGetDictionary\n#  define deflateInit           z_deflateInit\n#  define deflateInit2          z_deflateInit2\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePending        z_deflatePending\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateResetKeep      z_deflateResetKeep\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  ifndef Z_SOLO\n#    define gz_error              z_gz_error\n#    define gz_intmax             z_gz_intmax\n#    define gz_strwinerror        z_gz_strwinerror\n#    define gzbuffer              z_gzbuffer\n#    define gzclearerr            z_gzclearerr\n#    define gzclose               z_gzclose\n#    define gzclose_r             z_gzclose_r\n#    define gzclose_w             z_gzclose_w\n#    define gzdirect              z_gzdirect\n#    define gzdopen               z_gzdopen\n#    define gzeof                 z_gzeof\n#    define gzerror               z_gzerror\n#    define gzflush               z_gzflush\n#    define gzfread               z_gzfread\n#    define gzfwrite              z_gzfwrite\n#    define gzgetc                z_gzgetc\n#    define gzgetc_               z_gzgetc_\n#    define gzgets                z_gzgets\n#    define gzoffset              z_gzoffset\n#    define gzoffset64            z_gzoffset64\n#    define gzopen                z_gzopen\n#    define gzopen64              z_gzopen64\n#    ifdef _WIN32\n#      define gzopen_w              z_gzopen_w\n#    endif\n#    define gzprintf              z_gzprintf\n#    define gzputc                z_gzputc\n#    define gzputs                z_gzputs\n#    define gzread                z_gzread\n#    define gzrewind              z_gzrewind\n#    define gzseek                z_gzseek\n#    define gzseek64              z_gzseek64\n#    define gzsetparams           z_gzsetparams\n#    define gztell                z_gztell\n#    define gztell64              z_gztell64\n#    define gzungetc              z_gzungetc\n#    define gzvprintf             z_gzvprintf\n#    define gzwrite               z_gzwrite\n#  endif\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit       z_inflateBackInit\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCodesUsed      z_inflateCodesUsed\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetDictionary  z_inflateGetDictionary\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit           z_inflateInit\n#  define inflateInit2          z_inflateInit2\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateResetKeep      z_inflateResetKeep\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflateValidate       z_inflateValidate\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  ifndef Z_SOLO\n#    define uncompress            z_uncompress\n#    define uncompress2           z_uncompress2\n#  endif\n#  define zError                z_zError\n#  ifndef Z_SOLO\n#    define zcalloc               z_zcalloc\n#    define zcfree                z_zcfree\n#  endif\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  ifndef Z_SOLO\n#    define gzFile                z_gzFile\n#  endif\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)\t/* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const\t\t\t/* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const\t\t/* note: need a more gentle solution here */\n#  endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#  define z_const const\n#else\n#  define z_const\n#endif\n\n#ifdef Z_SOLO\ntypedef unsigned long z_size_t;\n#else\n#  define z_longlong long long\n#  if defined(NO_SIZE_T)\ntypedef unsigned NO_SIZE_T z_size_t;\n#  elif defined(STDC)\n#    include <stddef.h>\ntypedef size_t z_size_t;\n#  else\ntypedef unsigned long z_size_t;\n#  endif\n#  undef z_longlong\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15\t/* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus about 7 kilobytes\n for small objects.\n*/\n\n\t\t\t/* Type declarations */\n\n#ifndef OF\t\t\t/* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n#ifndef Z_ARG\t\t\t/* function prototypes for stdarg */\n#  if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#    define Z_ARG(args)  args\n#  else\n#    define Z_ARG(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif\t\t\t/* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char Byte;\t/* 8 bits */\n#endif\ntypedef unsigned int uInt;\t/* 16 bits or more */\ntypedef unsigned long uLong;\t/* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\ntypedef Byte FAR Bytef;\n#endif\ntypedef char FAR charf;\ntypedef int FAR intf;\ntypedef uInt FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\ntypedef void const *voidpc;\ntypedef void FAR *voidpf;\ntypedef void *voidp;\n#else\ntypedef Byte const *voidpc;\ntypedef Byte FAR *voidpf;\ntypedef Byte *voidp;\n#endif\n\n#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)\n#  include <limits.h>\n#  if (UINT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned\n#  elif (ULONG_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned long\n#  elif (USHRT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned short\n#  endif\n#endif\n\n#ifdef Z_U4\ntypedef Z_U4 z_crc_t;\n#else\ntypedef unsigned long z_crc_t;\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#  define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#  ifndef Z_SOLO\n#    include <sys/types.h>\t/* for off_t */\n#  endif\n#endif\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n#    include <stdarg.h>\t\t/* for va_list */\n#  endif\n#endif\n\n#ifdef _WIN32\n#  ifndef Z_SOLO\n#    include <stddef.h>\t\t/* for wchar_t */\n#  endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)\n#  define Z_HAVE_UNISTD_H\n#endif\n#ifndef Z_SOLO\n#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#    include <unistd.h>\t\t/* for SEEK_*, off_t, and _LFS64_LARGEFILE */\n#    ifdef VMS\n#      include <unixio.h>\t/* for off_t */\n#    endif\n#    ifndef z_off_t\n#      define z_off_t off_t\n#    endif\n#  endif\n#endif\n\n#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0\n#  define Z_LFS64\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)\n#  define Z_LARGE64\n#endif\n\n#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)\n#  define Z_WANT64\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#  define SEEK_SET        0\t/* Seek from beginning of file.  */\n#  define SEEK_CUR        1\t/* Seek from current position.  */\n#  define SEEK_END        2\t/* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if !defined(_WIN32) && defined(Z_LARGE64)\n#  define z_off64_t off64_t\n#else\n#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)\n#    define z_off64_t __int64\n#  else\n#    define z_off64_t z_off_t\n#  endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n#pragma map(deflateInit_,\"DEIN\")\n#pragma map(deflateInit2_,\"DEIN2\")\n#pragma map(deflateEnd,\"DEEND\")\n#pragma map(deflateBound,\"DEBND\")\n#pragma map(inflateInit_,\"ININ\")\n#pragma map(inflateInit2_,\"ININ2\")\n#pragma map(inflateEnd,\"INEND\")\n#pragma map(inflateSync,\"INSY\")\n#pragma map(inflateSetDictionary,\"INSEDI\")\n#pragma map(compressBound,\"CMBND\")\n#pragma map(inflate_table,\"INTABL\")\n#pragma map(inflate_fast,\"INFA\")\n#pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif\t\t\t\t/* ZCONF_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/include/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.11, January 15th, 2017\n\n  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.11\"\n#define ZLIB_VERNUM 0x12b0\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 11\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip and raw deflate streams in\n  memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in the case of corrupted input.\n*/\n\n\ttypedef voidpf(*alloc_func) OF((voidpf opaque, uInt items, uInt size));\n\ttypedef void (*free_func) OF((voidpf opaque, voidpf address));\n\n\tstruct internal_state;\n\n\ttypedef struct z_stream_s {\n\t\tz_const Bytef *next_in;\t/* next input byte */\n\t\tuInt avail_in;\t/* number of bytes available at next_in */\n\t\tuLong total_in;\t/* total number of input bytes read so far */\n\n\t\tBytef *next_out;\t/* next output byte will go here */\n\t\tuInt avail_out;\t/* remaining free space at next_out */\n\t\tuLong total_out;\t/* total number of bytes output so far */\n\n\t\tz_const char *msg;\t/* last error message, NULL if no error */\n\t\tstruct internal_state FAR *state;\t/* not visible by applications */\n\n\t\talloc_func zalloc;\t/* used to allocate the internal state */\n\t\tfree_func zfree;\t/* used to free the internal state */\n\t\tvoidpf opaque;\t/* private data object passed to zalloc and zfree */\n\n\t\tint data_type;\t/* best guess about the data type: binary or text\n\t\t\t\t   for deflate, or the decoding state for inflate */\n\t\tuLong adler;\t/* Adler-32 or CRC-32 value of the uncompressed data */\n\t\tuLong reserved;\t/* reserved for future use */\n\t} z_stream;\n\n\ttypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\n\ttypedef struct gz_header_s {\n\t\tint text;\t/* true if compressed data believed to be text */\n\t\tuLong time;\t/* modification time */\n\t\tint xflags;\t/* extra flags (not used when writing a gzip file) */\n\t\tint os;\t\t/* operating system */\n\t\tBytef *extra;\t/* pointer to extra field or Z_NULL if none */\n\t\tuInt extra_len;\t/* extra field length (valid if extra != Z_NULL) */\n\t\tuInt extra_max;\t/* space at extra (only when reading header) */\n\t\tBytef *name;\t/* pointer to zero-terminated file name or Z_NULL */\n\t\tuInt name_max;\t/* space at name (only when reading header) */\n\t\tBytef *comment;\t/* pointer to zero-terminated comment or Z_NULL */\n\t\tuInt comm_max;\t/* space at comment (only when reading header) */\n\t\tint hcrc;\t/* true if there was or will be a header crc */\n\t\tint done;\t/* true when done reading gzip header (not used\n\t\t\t\t   when writing a gzip file) */\n\t} gz_header;\n\n\ttypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.  In that case, zlib is thread-safe.  When zalloc and zfree are\n   Z_NULL on entry to the initialization function, they are set to internal\n   routines that use the standard library functions malloc() and free().\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use by the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n\t/* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT\t/* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field for deflate() */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0\t\t/* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\t/* basic functions */\n\n\tZEXTERN const char *ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary.  Some output may be provided even if\n    flush is zero.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending. See deflatePending(),\n  which can be used if desired to determine whether or not there is more ouput\n  in that case.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed\n  codes block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space.  If deflate returns with Z_OK or Z_BUF_ERROR, this\n  function must be called again with Z_FINISH and more output space (updated\n  avail_out) but no more input data, until it returns with Z_STREAM_END or an\n  error.  After deflate has returned Z_STREAM_END, the only possible operations\n  on the stream are deflateReset or deflateEnd.\n\n    Z_FINISH can be used in the first deflate call after deflateInit if all the\n  compression is to be done in a single step.  In order to complete in one\n  call, avail_out must be at least the value returned by deflateBound (see\n  below).  Then deflate is guaranteed to return Z_STREAM_END.  If not enough\n  output space is provided, deflate will not return Z_STREAM_END, and it must\n  be called again as described above.\n\n    deflate() sets strm->adler to the Adler-32 checksum of all input read\n  so far (that is, total_in bytes).  If a gzip stream is being generated, then\n  strm->adler will be the CRC-32 checksum of the input read so far.  (See\n  deflateInit2 below.)\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  If in doubt, the data is\n  considered binary.  This field is only for information purposes and does not\n  affect the compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL or the state was inadvertently written over\n  by the application), or Z_BUF_ERROR if no progress is possible (for example\n  avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not fatal, and\n  deflate() can be called again with more input and more output space to\n  continue compressing.\n*/\n\n\tZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  In the current version of inflate, the provided input is not\n   read or consumed.  The allocation of a sliding window will be deferred to\n   the first call of inflate (if the decompression does not complete on the\n   first call).  If zalloc and zfree are set to Z_NULL, inflateInit updates\n   them to use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression.\n   Actual decompression will be done by inflate().  So next_in, and avail_in,\n   next_out, and avail_out are unused and unchanged.  The current\n   implementation of inflateInit() does not process any header information --\n   that is deferred until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), then next_in and avail_in are updated\n    accordingly, and processing will resume at this point for the next call of\n    inflate().\n\n  - Generate more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  If the\n  caller of inflate() does not provide both available input and available\n  output space, it is possible that there will be no progress made.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  To assist in this, on return inflate() always sets strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all of the uncompressed data for the\n  operation to complete.  (The size of the uncompressed data may have been\n  saved by the compressor for this purpose.)  The use of Z_FINISH is not\n  required to perform an inflation in one step.  However it may be used to\n  inform inflate that a faster approach can be used for the single inflate()\n  call.  Z_FINISH also informs inflate to not maintain a sliding window if the\n  stream completes, which reduces inflate's memory footprint.  If the stream\n  does not complete, either because not all of the stream is provided or not\n  enough output space is provided, then a sliding window will be allocated and\n  inflate() can be called again to continue the operation as if Z_NO_FLUSH had\n  been used.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed Adler-32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained unless inflateGetHeader() is used.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  produced so far.  The CRC-32 is checked against the gzip trailer, as is the\n  uncompressed length, modulo 2^32.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value, in which case strm->msg points to a string with a more specific\n  error), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL, or the state was inadvertently written over\n  by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR\n  if no progress was possible or if there was not enough room in the output\n  buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is to be attempted.\n*/\n\n\tZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state\n   was inconsistent.\n*/\n\n\t/* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     For the current implementation of deflate(), a windowBits value of 8 (a\n   window size of 256 bytes) is not supported.  As a result, a request for 8\n   will result in 9 (a 512-byte window).  In that case, providing 8 to\n   inflateInit2() will result in an error when the zlib header with 9 is\n   checked against the initialization of inflate().  The remedy is to not use 8\n   with deflateInit2() with this initialization, or at least in that case use 9\n   with inflateInit2().\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute a check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to the appropriate value,\n   if the operating system was determined at compile time.  If a gzip stream is\n   being written, strm->adler is a CRC-32 instead of an Adler-32.\n\n     For raw deflate or gzip encoding, a request for a 256-byte window is\n   rejected as invalid, since only the zlib header provides a means of\n   transmitting the window size to the decompressor.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the Adler-32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The Adler-32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   Adler-32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, Bytef * dictionary, uInt * dictLength));\n/*\n     Returns the sliding dictionary being maintained by deflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If deflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     deflateGetDictionary() may return a length less than the window size, even\n   when more than the window size in input has been provided. It may return up\n   to 258 bytes less in that case, due to how zlib's implementation of deflate\n   manages the sliding window and lookahead for matches, where matches can be\n   up to 258 bytes long. If the application needs the last window-size bytes of\n   input, then that would need to be saved by the application outside of zlib.\n\n     deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit, but\n   does not free and reallocate the internal compression state.  The stream\n   will leave the compression level and any other attributes that may have been\n   set unchanged.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2().  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression approach (which is a function of the level) or the\n   strategy is changed, and if there have been any deflate() calls since the\n   state was initialized or reset, then the input available so far is\n   compressed with the old level and strategy using deflate(strm, Z_BLOCK).\n   There are three approaches for the compression levels 0, 1..3, and 4..9\n   respectively.  The new level and strategy will take effect at the next call\n   of deflate().\n\n     If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does\n   not have enough output space to complete, then the parameter change will not\n   take effect.  In this case, deflateParams() can be called again with the\n   same parameters and more output space to try again.\n\n     In order to assure a change in the parameters on the first try, the\n   deflate stream should be flushed using deflate() with Z_BLOCK or other flush\n   request until strm.avail_out is not zero, before calling deflateParams().\n   Then no more input data should be provided before the deflateParams() call.\n   If this is done, the old level and strategy will be applied to the data\n   compressed before deflateParams(), and the new level and strategy will be\n   applied to the the data compressed after deflateParams().\n\n     deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream\n   state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if\n   there was not enough output space to complete the compression of the\n   available input data before a change in the strategy or approach.  Note that\n   in the case of a Z_BUF_ERROR, the parameters are not changed.  A return\n   value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be\n   retried with more output space.\n*/\n\n\tZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\n\tZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\n\tZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, unsigned *pending, int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\n\tZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an Adler-32 or a CRC-32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   CRC-32 instead of an Adler-32.  Unlike the gunzip utility and gzread() (see\n   below), inflate() will not automatically decode concatenated gzip streams.\n   inflate() will return Z_STREAM_END at the end of the gzip stream.  The state\n   would need to be reset to continue decoding a subsequent gzip stream.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the Adler-32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect Adler-32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\n\tZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, Bytef * dictionary, uInt * dictLength));\n/*\n     Returns the sliding dictionary being maintained by inflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If inflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurrences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\n\tZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.  If the window size is changed, then the\n   memory allocated for the window is freed, and the window will be reallocated\n   by inflate() if needed.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\n\tZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n\tZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above, or -65536 if the provided\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\n\ttypedef unsigned (*in_func) OF((void FAR *, z_const unsigned char FAR * FAR *));\n\ttypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\n\tZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR * in_desc, out_func out, void FAR * out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is potentially more efficient than\n   inflate() for file i/o applications, in that it avoids copying between the\n   output and the sliding window by simply making the window itself the output\n   buffer.  inflate() can be faster on modern CPUs when used with large\n   buffers.  inflateBack() trusts the application to not change the output\n   buffer passed by the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the default\n   behavior of inflate(), which expects a zlib header and trailer around the\n   deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero -- buf is ignored in that\n   case -- and inflateBack() will return a buffer error.  inflateBack() will\n   call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].\n   out() should return zero on success, or non-zero on failure.  If out()\n   returns non-zero, inflateBack() will return with an error.  Neither in() nor\n   out() are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.)  Note that inflateBack()\n   cannot return Z_OK.\n*/\n\n\tZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\n\tZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: ZLIB_DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n\t/* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\n\tZEXTERN int ZEXPORT compress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.  compress() is equivalent to compress2() with a level\n   parameter of Z_DEFAULT_COMPRESSION.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\n\tZEXTERN int ZEXPORT compress2 OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen, int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed data.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\n\tZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\n\tZEXTERN int ZEXPORT uncompress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed data.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\n\tZEXTERN int ZEXPORT uncompress2 OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong * sourceLen));\n/*\n     Same as uncompress, except that sourceLen is a pointer, where the\n   length of the source is *sourceLen.  On return, *sourceLen is the number of\n   source bytes consumed.\n*/\n\n\t/* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\n\ttypedef struct gzFile_s *gzFile;\t/* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.  The addition of\n   \"x\" when writing will create the file exclusively, which fails if the file\n   already exists.  On systems that support it, the addition of \"e\" when\n   reading or writing will set the flag to close the file on an execve() call.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\n\tZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\n\tZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Three times that size in buffer space is allocated.  A larger buffer\n   size of, for example, 64K or 128K bytes will noticeably increase the speed\n   of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\n\tZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.  Previously provided\n   data is flushed before the parameter change.\n\n     gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not\n   opened for writing, Z_ERRNO if there is an error writing the flushed data,\n   or Z_MEM_ERROR if there is a memory allocation error.\n*/\n\n\tZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.  If len is too large to fit in an int,\n   then nothing is read, -1 is returned, and the error state is set to\n   Z_STREAM_ERROR.\n*/\n\n\tZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, gzFile file));\n/*\n     Read up to nitems items of size size from file to buf, otherwise operating\n   as gzread() does.  This duplicates the interface of stdio's fread(), with\n   size_t request and return types.  If the library defines size_t, then\n   z_size_t is identical to size_t.  If not, then z_size_t is an unsigned\n   integer type that can contain a pointer.\n\n     gzfread() returns the number of full items read of size size, or zero if\n   the end of the file was reached and a full item could not be read, or if\n   there was an error.  gzerror() must be consulted if zero is returned in\n   order to determine if there was an error.  If the multiplication of size and\n   nitems overflows, i.e. the product does not fit in a z_size_t, then nothing\n   is read, zero is returned, and the error state is set to Z_STREAM_ERROR.\n\n     In the event that the end of file is reached and only a partial item is\n   available at the end, i.e. the remaining uncompressed data length is not a\n   multiple of size, then the final partial item is nevetheless read into buf\n   and the end-of-file flag is set.  The length of the partial item read is not\n   provided, but could be inferred from the result of gztell().  This behavior\n   is the same as the behavior of fread() implementations in common libraries,\n   but it prevents the direct use of gzfread() to read a concurrently written\n   file, reseting and retrying on end-of-file, when size is not 1.\n*/\n\n\tZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\n\tZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, z_size_t nitems, gzFile file));\n/*\n     gzfwrite() writes nitems items of size size from buf to file, duplicating\n   the interface of stdio's fwrite(), with size_t request and return types.  If\n   the library defines size_t, then z_size_t is identical to size_t.  If not,\n   then z_size_t is an unsigned integer type that can contain a pointer.\n\n     gzfwrite() returns the number of full items written of size size, or zero\n   if there was an error.  If the multiplication of size and nitems overflows,\n   i.e. the product does not fit in a z_size_t, then nothing is written, zero\n   is returned, and the error state is set to Z_STREAM_ERROR.\n*/\n\n\tZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or a negative zlib error code in case\n   of error.  The number of uncompressed bytes written is limited to 8191, or\n   one less than the buffer size given to gzbuffer().  The caller should assure\n   that this limit is not exceeded.  If it is exceeded, then gzprintf() will\n   return an error (0) with nothing written.  In this case, there may also be a\n   buffer overflow with unpredictable consequences, which is possible only if\n   zlib was compiled with the insecure functions sprintf() or vsprintf()\n   because the secure snprintf() or vsnprintf() functions were not available.\n   This can be determined using zlibCompileFlags().\n*/\n\n\tZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\n\tZEXTERN char *ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\n\tZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\n\tZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\n\tZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\n\tZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatenated gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\n\tZEXTERN int ZEXPORT gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\n\tZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\n\tZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\n\tZEXTERN int ZEXPORT gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\n\tZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\n\tZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\n\tZEXTERN const char *ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\n\tZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n\t/* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\n\tZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef * buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n\tZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef * buf, z_size_t len));\n/*\n     Same as adler32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\n\tZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef * buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the crc.  Pre- and post-conditioning (one's complement) is\n   performed within this function so it shouldn't be done by the application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n\tZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef * buf, z_size_t len));\n/*\n     Same as crc32(), but with a size_t length.\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\t/* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\n\tZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR * window, const char *version, int stream_size));\n#ifdef Z_PREFIX_SET\n#  define z_deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define z_inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define z_inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#else\n#  define deflateInit(strm, level) \\\n          deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit(strm) \\\n          inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n          deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                        (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#  define inflateInit2(strm, windowBits) \\\n          inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                        (int)sizeof(z_stream))\n#  define inflateBackInit(strm, windowBits, window) \\\n          inflateBackInit_((strm), (windowBits), (window), \\\n                           ZLIB_VERSION, (int)sizeof(z_stream))\n#endif\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\n\tstruct gzFile_s {\n\t\tunsigned have;\n\t\tunsigned char *next;\n\t\tz_off64_t pos;\n\t};\n\tZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));\t/* backward compatibility */\n#ifdef Z_PREFIX_SET\n#  undef z_gzgetc\n#  define z_gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#else\n#  define gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))\n#endif\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#ifdef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n\tZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)\n#  ifdef Z_PREFIX_SET\n#    define z_gzopen z_gzopen64\n#    define z_gzseek z_gzseek64\n#    define z_gztell z_gztell64\n#    define z_gzoffset z_gzoffset64\n#    define z_adler32_combine z_adler32_combine64\n#    define z_crc32_combine z_crc32_combine64\n#  else\n#    define gzopen gzopen64\n#    define gzseek gzseek64\n#    define gztell gztell64\n#    define gzoffset gzoffset64\n#    define adler32_combine adler32_combine64\n#    define crc32_combine crc32_combine64\n#  endif\n#  ifndef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n\tZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else\t\t\t\t/* Z_SOLO */\n\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n/* undocumented functions */\n\tZEXTERN const char *ZEXPORT zError OF((int));\n\tZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));\n\tZEXTERN const z_crc_t FAR *ZEXPORT get_crc_table OF((void));\n\tZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));\n\tZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));\n\tZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp));\n\tZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));\n\tZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));\n#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)\n\tZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t * path, const char *mode));\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n\tZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format, va_list va));\n#  endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* ZLIB_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include/float.h",
    "content": "/* Copyright (C) 2002-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  5.2.4.2.2  Characteristics of floating types <float.h>\n */\n\n#ifndef _FLOAT_H___\n#define _FLOAT_H___\n\n/* Radix of exponent representation, b. */\n#undef FLT_RADIX\n#define FLT_RADIX\t__FLT_RADIX__\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef FLT_MANT_DIG\n#undef DBL_MANT_DIG\n#undef LDBL_MANT_DIG\n#define FLT_MANT_DIG\t__FLT_MANT_DIG__\n#define DBL_MANT_DIG\t__DBL_MANT_DIG__\n#define LDBL_MANT_DIG\t__LDBL_MANT_DIG__\n\n/* Number of decimal digits, q, such that any floating-point number with q\n   decimal digits can be rounded into a floating-point number with p radix b\n   digits and back again without change to the q decimal digits,\n\n\tp * log10(b)\t\t\tif b is a power of 10\n\tfloor((p - 1) * log10(b))\totherwise\n*/\n#undef FLT_DIG\n#undef DBL_DIG\n#undef LDBL_DIG\n#define FLT_DIG\t\t__FLT_DIG__\n#define DBL_DIG\t\t__DBL_DIG__\n#define LDBL_DIG\t__LDBL_DIG__\n\n/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */\n#undef FLT_MIN_EXP\n#undef DBL_MIN_EXP\n#undef LDBL_MIN_EXP\n#define FLT_MIN_EXP\t__FLT_MIN_EXP__\n#define DBL_MIN_EXP\t__DBL_MIN_EXP__\n#define LDBL_MIN_EXP\t__LDBL_MIN_EXP__\n\n/* Minimum negative integer such that 10 raised to that power is in the\n   range of normalized floating-point numbers,\n\n\tceil(log10(b) * (emin - 1))\n*/\n#undef FLT_MIN_10_EXP\n#undef DBL_MIN_10_EXP\n#undef LDBL_MIN_10_EXP\n#define FLT_MIN_10_EXP\t__FLT_MIN_10_EXP__\n#define DBL_MIN_10_EXP\t__DBL_MIN_10_EXP__\n#define LDBL_MIN_10_EXP\t__LDBL_MIN_10_EXP__\n\n/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax.  */\n#undef FLT_MAX_EXP\n#undef DBL_MAX_EXP\n#undef LDBL_MAX_EXP\n#define FLT_MAX_EXP\t__FLT_MAX_EXP__\n#define DBL_MAX_EXP\t__DBL_MAX_EXP__\n#define LDBL_MAX_EXP\t__LDBL_MAX_EXP__\n\n/* Maximum integer such that 10 raised to that power is in the range of\n   representable finite floating-point numbers,\n\n\tfloor(log10((1 - b**-p) * b**emax))\n*/\n#undef FLT_MAX_10_EXP\n#undef DBL_MAX_10_EXP\n#undef LDBL_MAX_10_EXP\n#define FLT_MAX_10_EXP\t__FLT_MAX_10_EXP__\n#define DBL_MAX_10_EXP\t__DBL_MAX_10_EXP__\n#define LDBL_MAX_10_EXP\t__LDBL_MAX_10_EXP__\n\n/* Maximum representable finite floating-point number,\n\n\t(1 - b**-p) * b**emax\n*/\n#undef FLT_MAX\n#undef DBL_MAX\n#undef LDBL_MAX\n#define FLT_MAX\t\t__FLT_MAX__\n#define DBL_MAX\t\t__DBL_MAX__\n#define LDBL_MAX\t__LDBL_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type, b**1-p.  */\n#undef FLT_EPSILON\n#undef DBL_EPSILON\n#undef LDBL_EPSILON\n#define FLT_EPSILON\t__FLT_EPSILON__\n#define DBL_EPSILON\t__DBL_EPSILON__\n#define LDBL_EPSILON\t__LDBL_EPSILON__\n\n/* Minimum normalized positive floating-point number, b**(emin - 1).  */\n#undef FLT_MIN\n#undef DBL_MIN\n#undef LDBL_MIN\n#define FLT_MIN\t\t__FLT_MIN__\n#define DBL_MIN\t\t__DBL_MIN__\n#define LDBL_MIN\t__LDBL_MIN__\n\n/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown.  */\n/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */\n#undef FLT_ROUNDS\n#define FLT_ROUNDS 1\n\n#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \\\n     || (defined (__cplusplus) && __cplusplus >= 201103L)\n/* The floating-point expression evaluation method.  The precise\n   definitions of these values are generalised to include support for\n   the interchange and extended types defined in ISO/IEC TS 18661-3.\n   Prior to this (for C99/C11) the definitions were:\n\n\t-1  indeterminate\n\t 0  evaluate all operations and constants just to the range and\n\t    precision of the type\n\t 1  evaluate operations and constants of type float and double\n\t    to the range and precision of the double type, evaluate\n\t    long double operations and constants to the range and\n\t    precision of the long double type\n\t 2  evaluate all operations and constants to the range and\n\t    precision of the long double type\n\n   The TS 18661-3 definitions are:\n\n\t-1  indeterminate\n\t 0  evaluate all operations and constants, whose semantic type has\n\t    at most the range and precision of float, to the range and\n\t    precision of float; evaluate all other operations and constants\n\t    to the range and precision of the semantic type.\n\t 1  evaluate all operations and constants, whose semantic type has\n\t    at most the range and precision of double, to the range and\n\t    precision of double; evaluate all other operations and constants\n\t    to the range and precision of the semantic type.\n\t 2  evaluate all operations and constants, whose semantic type has\n\t    at most the range and precision of long double, to the range and\n\t    precision of long double; evaluate all other operations and\n\t    constants to the range and precision of the semantic type.\n\t N  where _FloatN  is a supported interchange floating type\n\t    evaluate all operations and constants, whose semantic type has\n\t    at most the range and precision of the _FloatN type, to the\n\t    range and precision of the _FloatN type; evaluate all other\n\t    operations and constants to the range and precision of the\n\t    semantic type.\n\t N + 1, where _FloatNx is a supported extended floating type\n\t    evaluate operations and constants, whose semantic type has at\n\t    most the range and precision of the _FloatNx type, to the range\n\t    and precision of the _FloatNx type; evaluate all other\n\t    operations and constants to the range and precision of the\n\t    semantic type.\n\n   The compiler predefines two macros:\n\n      __FLT_EVAL_METHOD__\n      Which, depending on the value given for\n      -fpermitted-flt-eval-methods, may be limited to only those values\n      for FLT_EVAL_METHOD defined in C99/C11.\n\n     __FLT_EVAL_METHOD_TS_18661_3__\n      Which always permits the values for FLT_EVAL_METHOD defined in\n      ISO/IEC TS 18661-3.\n\n     Here we want to use __FLT_EVAL_METHOD__, unless\n     __STDC_WANT_IEC_60559_TYPES_EXT__ is defined, in which case the user\n     is specifically asking for the ISO/IEC TS 18661-3 types, so we use\n     __FLT_EVAL_METHOD_TS_18661_3__.\n\n   ??? This ought to change with the setting of the fp control word;\n   the value provided by the compiler assumes the widest setting.  */\n#undef FLT_EVAL_METHOD\n#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__\n#define FLT_EVAL_METHOD __FLT_EVAL_METHOD_TS_18661_3__\n#else\n#define FLT_EVAL_METHOD\t__FLT_EVAL_METHOD__\n#endif\n\n/* Number of decimal digits, n, such that any floating-point number in the\n   widest supported floating type with pmax radix b digits can be rounded\n   to a floating-point number with n decimal digits and back again without\n   change to the value,\n\n\tpmax * log10(b)\t\t\tif b is a power of 10\n\tceil(1 + pmax * log10(b))\totherwise\n*/\n#undef DECIMAL_DIG\n#define DECIMAL_DIG\t__DECIMAL_DIG__\n\n#endif\t\t\t\t/* C99 */\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L\n/* Versions of DECIMAL_DIG for each floating-point type.  */\n#undef FLT_DECIMAL_DIG\n#undef DBL_DECIMAL_DIG\n#undef LDBL_DECIMAL_DIG\n#define FLT_DECIMAL_DIG\t\t__FLT_DECIMAL_DIG__\n#define DBL_DECIMAL_DIG\t\t__DBL_DECIMAL_DIG__\n#define LDBL_DECIMAL_DIG\t__LDBL_DECIMAL_DIG__\n\n/* Whether types support subnormal numbers.  */\n#undef FLT_HAS_SUBNORM\n#undef DBL_HAS_SUBNORM\n#undef LDBL_HAS_SUBNORM\n#define FLT_HAS_SUBNORM\t\t__FLT_HAS_DENORM__\n#define DBL_HAS_SUBNORM\t\t__DBL_HAS_DENORM__\n#define LDBL_HAS_SUBNORM\t__LDBL_HAS_DENORM__\n\n/* Minimum positive values, including subnormals.  */\n#undef FLT_TRUE_MIN\n#undef DBL_TRUE_MIN\n#undef LDBL_TRUE_MIN\n#define FLT_TRUE_MIN\t__FLT_DENORM_MIN__\n#define DBL_TRUE_MIN\t__DBL_DENORM_MIN__\n#define LDBL_TRUE_MIN\t__LDBL_DENORM_MIN__\n\n#endif\t\t\t\t/* C11 */\n\n#ifdef __STDC_WANT_IEC_60559_BFP_EXT__\n/* Number of decimal digits for which conversions between decimal\n   character strings and binary formats, in both directions, are\n   correctly rounded.  */\n#define CR_DECIMAL_DIG\t__UINTMAX_MAX__\n#endif\n\n#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__\n/* Constants for _FloatN and _FloatNx types from TS 18661-3.  See\n   comments above for their semantics.  */\n\n#ifdef __FLT16_MANT_DIG__\n#undef FLT16_MANT_DIG\n#define FLT16_MANT_DIG\t\t__FLT16_MANT_DIG__\n#undef FLT16_DIG\n#define FLT16_DIG\t\t__FLT16_DIG__\n#undef FLT16_MIN_EXP\n#define FLT16_MIN_EXP\t\t__FLT16_MIN_EXP__\n#undef FLT16_MIN_10_EXP\n#define FLT16_MIN_10_EXP\t__FLT16_MIN_10_EXP__\n#undef FLT16_MAX_EXP\n#define FLT16_MAX_EXP\t\t__FLT16_MAX_EXP__\n#undef FLT16_MAX_10_EXP\n#define FLT16_MAX_10_EXP\t__FLT16_MAX_10_EXP__\n#undef FLT16_MAX\n#define FLT16_MAX\t\t__FLT16_MAX__\n#undef FLT16_EPSILON\n#define FLT16_EPSILON\t\t__FLT16_EPSILON__\n#undef FLT16_MIN\n#define FLT16_MIN\t\t__FLT16_MIN__\n#undef FLT16_DECIMAL_DIG\n#define FLT16_DECIMAL_DIG\t__FLT16_DECIMAL_DIG__\n#undef FLT16_TRUE_MIN\n#define FLT16_TRUE_MIN\t\t__FLT16_DENORM_MIN__\n#endif\t\t\t\t/* __FLT16_MANT_DIG__.  */\n\n#ifdef __FLT32_MANT_DIG__\n#undef FLT32_MANT_DIG\n#define FLT32_MANT_DIG\t\t__FLT32_MANT_DIG__\n#undef FLT32_DIG\n#define FLT32_DIG\t\t__FLT32_DIG__\n#undef FLT32_MIN_EXP\n#define FLT32_MIN_EXP\t\t__FLT32_MIN_EXP__\n#undef FLT32_MIN_10_EXP\n#define FLT32_MIN_10_EXP\t__FLT32_MIN_10_EXP__\n#undef FLT32_MAX_EXP\n#define FLT32_MAX_EXP\t\t__FLT32_MAX_EXP__\n#undef FLT32_MAX_10_EXP\n#define FLT32_MAX_10_EXP\t__FLT32_MAX_10_EXP__\n#undef FLT32_MAX\n#define FLT32_MAX\t\t__FLT32_MAX__\n#undef FLT32_EPSILON\n#define FLT32_EPSILON\t\t__FLT32_EPSILON__\n#undef FLT32_MIN\n#define FLT32_MIN\t\t__FLT32_MIN__\n#undef FLT32_DECIMAL_DIG\n#define FLT32_DECIMAL_DIG\t__FLT32_DECIMAL_DIG__\n#undef FLT32_TRUE_MIN\n#define FLT32_TRUE_MIN\t\t__FLT32_DENORM_MIN__\n#endif\t\t\t\t/* __FLT32_MANT_DIG__.  */\n\n#ifdef __FLT64_MANT_DIG__\n#undef FLT64_MANT_DIG\n#define FLT64_MANT_DIG\t\t__FLT64_MANT_DIG__\n#undef FLT64_DIG\n#define FLT64_DIG\t\t__FLT64_DIG__\n#undef FLT64_MIN_EXP\n#define FLT64_MIN_EXP\t\t__FLT64_MIN_EXP__\n#undef FLT64_MIN_10_EXP\n#define FLT64_MIN_10_EXP\t__FLT64_MIN_10_EXP__\n#undef FLT64_MAX_EXP\n#define FLT64_MAX_EXP\t\t__FLT64_MAX_EXP__\n#undef FLT64_MAX_10_EXP\n#define FLT64_MAX_10_EXP\t__FLT64_MAX_10_EXP__\n#undef FLT64_MAX\n#define FLT64_MAX\t\t__FLT64_MAX__\n#undef FLT64_EPSILON\n#define FLT64_EPSILON\t\t__FLT64_EPSILON__\n#undef FLT64_MIN\n#define FLT64_MIN\t\t__FLT64_MIN__\n#undef FLT64_DECIMAL_DIG\n#define FLT64_DECIMAL_DIG\t__FLT64_DECIMAL_DIG__\n#undef FLT64_TRUE_MIN\n#define FLT64_TRUE_MIN\t\t__FLT64_DENORM_MIN__\n#endif\t\t\t\t/* __FLT64_MANT_DIG__.  */\n\n#ifdef __FLT128_MANT_DIG__\n#undef FLT128_MANT_DIG\n#define FLT128_MANT_DIG\t\t__FLT128_MANT_DIG__\n#undef FLT128_DIG\n#define FLT128_DIG\t\t__FLT128_DIG__\n#undef FLT128_MIN_EXP\n#define FLT128_MIN_EXP\t\t__FLT128_MIN_EXP__\n#undef FLT128_MIN_10_EXP\n#define FLT128_MIN_10_EXP\t__FLT128_MIN_10_EXP__\n#undef FLT128_MAX_EXP\n#define FLT128_MAX_EXP\t\t__FLT128_MAX_EXP__\n#undef FLT128_MAX_10_EXP\n#define FLT128_MAX_10_EXP\t__FLT128_MAX_10_EXP__\n#undef FLT128_MAX\n#define FLT128_MAX\t\t__FLT128_MAX__\n#undef FLT128_EPSILON\n#define FLT128_EPSILON\t\t__FLT128_EPSILON__\n#undef FLT128_MIN\n#define FLT128_MIN\t\t__FLT128_MIN__\n#undef FLT128_DECIMAL_DIG\n#define FLT128_DECIMAL_DIG\t__FLT128_DECIMAL_DIG__\n#undef FLT128_TRUE_MIN\n#define FLT128_TRUE_MIN\t\t__FLT128_DENORM_MIN__\n#endif\t\t\t\t/* __FLT128_MANT_DIG__.  */\n\n#ifdef __FLT32X_MANT_DIG__\n#undef FLT32X_MANT_DIG\n#define FLT32X_MANT_DIG\t\t__FLT32X_MANT_DIG__\n#undef FLT32X_DIG\n#define FLT32X_DIG\t\t__FLT32X_DIG__\n#undef FLT32X_MIN_EXP\n#define FLT32X_MIN_EXP\t\t__FLT32X_MIN_EXP__\n#undef FLT32X_MIN_10_EXP\n#define FLT32X_MIN_10_EXP\t__FLT32X_MIN_10_EXP__\n#undef FLT32X_MAX_EXP\n#define FLT32X_MAX_EXP\t\t__FLT32X_MAX_EXP__\n#undef FLT32X_MAX_10_EXP\n#define FLT32X_MAX_10_EXP\t__FLT32X_MAX_10_EXP__\n#undef FLT32X_MAX\n#define FLT32X_MAX\t\t__FLT32X_MAX__\n#undef FLT32X_EPSILON\n#define FLT32X_EPSILON\t\t__FLT32X_EPSILON__\n#undef FLT32X_MIN\n#define FLT32X_MIN\t\t__FLT32X_MIN__\n#undef FLT32X_DECIMAL_DIG\n#define FLT32X_DECIMAL_DIG\t__FLT32X_DECIMAL_DIG__\n#undef FLT32X_TRUE_MIN\n#define FLT32X_TRUE_MIN\t\t__FLT32X_DENORM_MIN__\n#endif\t\t\t\t/* __FLT32X_MANT_DIG__.  */\n\n#ifdef __FLT64X_MANT_DIG__\n#undef FLT64X_MANT_DIG\n#define FLT64X_MANT_DIG\t\t__FLT64X_MANT_DIG__\n#undef FLT64X_DIG\n#define FLT64X_DIG\t\t__FLT64X_DIG__\n#undef FLT64X_MIN_EXP\n#define FLT64X_MIN_EXP\t\t__FLT64X_MIN_EXP__\n#undef FLT64X_MIN_10_EXP\n#define FLT64X_MIN_10_EXP\t__FLT64X_MIN_10_EXP__\n#undef FLT64X_MAX_EXP\n#define FLT64X_MAX_EXP\t\t__FLT64X_MAX_EXP__\n#undef FLT64X_MAX_10_EXP\n#define FLT64X_MAX_10_EXP\t__FLT64X_MAX_10_EXP__\n#undef FLT64X_MAX\n#define FLT64X_MAX\t\t__FLT64X_MAX__\n#undef FLT64X_EPSILON\n#define FLT64X_EPSILON\t\t__FLT64X_EPSILON__\n#undef FLT64X_MIN\n#define FLT64X_MIN\t\t__FLT64X_MIN__\n#undef FLT64X_DECIMAL_DIG\n#define FLT64X_DECIMAL_DIG\t__FLT64X_DECIMAL_DIG__\n#undef FLT64X_TRUE_MIN\n#define FLT64X_TRUE_MIN\t\t__FLT64X_DENORM_MIN__\n#endif\t\t\t\t/* __FLT64X_MANT_DIG__.  */\n\n#ifdef __FLT128X_MANT_DIG__\n#undef FLT128X_MANT_DIG\n#define FLT128X_MANT_DIG\t__FLT128X_MANT_DIG__\n#undef FLT128X_DIG\n#define FLT128X_DIG\t\t__FLT128X_DIG__\n#undef FLT128X_MIN_EXP\n#define FLT128X_MIN_EXP\t\t__FLT128X_MIN_EXP__\n#undef FLT128X_MIN_10_EXP\n#define FLT128X_MIN_10_EXP\t__FLT128X_MIN_10_EXP__\n#undef FLT128X_MAX_EXP\n#define FLT128X_MAX_EXP\t\t__FLT128X_MAX_EXP__\n#undef FLT128X_MAX_10_EXP\n#define FLT128X_MAX_10_EXP\t__FLT128X_MAX_10_EXP__\n#undef FLT128X_MAX\n#define FLT128X_MAX\t\t__FLT128X_MAX__\n#undef FLT128X_EPSILON\n#define FLT128X_EPSILON\t\t__FLT128X_EPSILON__\n#undef FLT128X_MIN\n#define FLT128X_MIN\t\t__FLT128X_MIN__\n#undef FLT128X_DECIMAL_DIG\n#define FLT128X_DECIMAL_DIG\t__FLT128X_DECIMAL_DIG__\n#undef FLT128X_TRUE_MIN\n#define FLT128X_TRUE_MIN\t__FLT128X_DENORM_MIN__\n#endif\t\t\t\t/* __FLT128X_MANT_DIG__.  */\n\n#endif\t\t\t\t/* __STDC_WANT_IEC_60559_TYPES_EXT__.  */\n\n#ifdef __STDC_WANT_DEC_FP__\n/* Draft Technical Report 24732, extension for decimal floating-point\n   arithmetic: Characteristic of decimal floating types <float.h>.  */\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef DEC32_MANT_DIG\n#undef DEC64_MANT_DIG\n#undef DEC128_MANT_DIG\n#define DEC32_MANT_DIG\t__DEC32_MANT_DIG__\n#define DEC64_MANT_DIG\t__DEC64_MANT_DIG__\n#define DEC128_MANT_DIG\t__DEC128_MANT_DIG__\n\n/* Minimum exponent. */\n#undef DEC32_MIN_EXP\n#undef DEC64_MIN_EXP\n#undef DEC128_MIN_EXP\n#define DEC32_MIN_EXP\t__DEC32_MIN_EXP__\n#define DEC64_MIN_EXP\t__DEC64_MIN_EXP__\n#define DEC128_MIN_EXP\t__DEC128_MIN_EXP__\n\n/* Maximum exponent. */\n#undef DEC32_MAX_EXP\n#undef DEC64_MAX_EXP\n#undef DEC128_MAX_EXP\n#define DEC32_MAX_EXP\t__DEC32_MAX_EXP__\n#define DEC64_MAX_EXP\t__DEC64_MAX_EXP__\n#define DEC128_MAX_EXP\t__DEC128_MAX_EXP__\n\n/* Maximum representable finite decimal floating-point number\n   (there are 6, 15, and 33 9s after the decimal points respectively). */\n#undef DEC32_MAX\n#undef DEC64_MAX\n#undef DEC128_MAX\n#define DEC32_MAX   __DEC32_MAX__\n#define DEC64_MAX   __DEC64_MAX__\n#define DEC128_MAX  __DEC128_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type. */\n#undef DEC32_EPSILON\n#undef DEC64_EPSILON\n#undef DEC128_EPSILON\n#define DEC32_EPSILON\t__DEC32_EPSILON__\n#define DEC64_EPSILON\t__DEC64_EPSILON__\n#define DEC128_EPSILON\t__DEC128_EPSILON__\n\n/* Minimum normalized positive floating-point number. */\n#undef DEC32_MIN\n#undef DEC64_MIN\n#undef DEC128_MIN\n#define DEC32_MIN\t__DEC32_MIN__\n#define DEC64_MIN\t__DEC64_MIN__\n#define DEC128_MIN\t__DEC128_MIN__\n\n/* Minimum subnormal positive floating-point number. */\n#undef DEC32_SUBNORMAL_MIN\n#undef DEC64_SUBNORMAL_MIN\n#undef DEC128_SUBNORMAL_MIN\n#define DEC32_SUBNORMAL_MIN       __DEC32_SUBNORMAL_MIN__\n#define DEC64_SUBNORMAL_MIN       __DEC64_SUBNORMAL_MIN__\n#define DEC128_SUBNORMAL_MIN      __DEC128_SUBNORMAL_MIN__\n\n/* The floating-point expression evaluation method.\n         -1  indeterminate\n         0  evaluate all operations and constants just to the range and\n            precision of the type\n         1  evaluate operations and constants of type _Decimal32 \n\t    and _Decimal64 to the range and precision of the _Decimal64 \n            type, evaluate _Decimal128 operations and constants to the \n\t    range and precision of the _Decimal128 type;\n\t 2  evaluate all operations and constants to the range and\n\t    precision of the _Decimal128 type.  */\n\n#undef DEC_EVAL_METHOD\n#define DEC_EVAL_METHOD\t__DEC_EVAL_METHOD__\n\n#endif\t\t\t\t/* __STDC_WANT_DEC_FP__ */\n\n#endif\t\t\t\t/* _FLOAT_H___ */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include/stdarg.h",
    "content": "/* Copyright (C) 1989-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.15  Variable arguments  <stdarg.h>\n */\n\n#ifndef _STDARG_H\n#ifndef _ANSI_STDARG_H_\n#ifndef __need___va_list\n#define _STDARG_H\n#define _ANSI_STDARG_H_\n#endif\t\t\t\t/* not __need___va_list */\n#undef __need___va_list\n\n/* Define __gnuc_va_list.  */\n\n#ifndef __GNUC_VA_LIST\n#define __GNUC_VA_LIST\ntypedef __builtin_va_list __gnuc_va_list;\n#endif\n\n/* Define the standard macros for the user,\n   if this invocation was from the user program.  */\n#ifdef _STDARG_H\n\n#define va_start(v,l)\t__builtin_va_start(v,l)\n#define va_end(v)\t__builtin_va_end(v)\n#define va_arg(v,l)\t__builtin_va_arg(v,l)\n#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L \\\n    || __cplusplus + 0 >= 201103L\n#define va_copy(d,s)\t__builtin_va_copy(d,s)\n#endif\n#define __va_copy(d,s)\t__builtin_va_copy(d,s)\n\n/* Define va_list, if desired, from __gnuc_va_list. */\n/* We deliberately do not define va_list when called from\n   stdio.h, because ANSI C says that stdio.h is not supposed to define\n   va_list.  stdio.h needs to have access to that data type, \n   but must not use that name.  It should use the name __gnuc_va_list,\n   which is safe because it is reserved for the implementation.  */\n\n#ifdef _BSD_VA_LIST\n#undef _BSD_VA_LIST\n#endif\n\n#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))\n/* SVR4.2 uses _VA_LIST for an internal alias for va_list,\n   so we must avoid testing it and setting it here.\n   SVR4 uses _VA_LIST as a flag in stdarg.h, but we should\n   have no conflict with that.  */\n#ifndef _VA_LIST_\n#define _VA_LIST_\n#ifdef __i860__\n#ifndef _VA_LIST\n#define _VA_LIST va_list\n#endif\n#endif\t\t\t\t/* __i860__ */\ntypedef __gnuc_va_list va_list;\n#ifdef _SCO_DS\n#define __VA_LIST\n#endif\n#endif\t\t\t\t/* _VA_LIST_ */\n#else\t\t\t\t/* not __svr4__ || _SCO_DS */\n\n/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.\n   But on BSD NET2 we must not test or define or undef it.\n   (Note that the comments in NET 2's ansi.h\n   are incorrect for _VA_LIST_--see stdio.h!)  */\n#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)\n/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */\n#ifndef _VA_LIST_DEFINED\n/* The macro _VA_LIST is used in SCO Unix 3.2.  */\n#ifndef _VA_LIST\n/* The macro _VA_LIST_T_H is used in the Bull dpx2  */\n#ifndef _VA_LIST_T_H\n/* The macro __va_list__ is used by BeOS.  */\n#ifndef __va_list__\ntypedef __gnuc_va_list va_list;\n#endif\t\t\t\t/* not __va_list__ */\n#endif\t\t\t\t/* not _VA_LIST_T_H */\n#endif\t\t\t\t/* not _VA_LIST */\n#endif\t\t\t\t/* not _VA_LIST_DEFINED */\n#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))\n#define _VA_LIST_\n#endif\n#ifndef _VA_LIST\n#define _VA_LIST\n#endif\n#ifndef _VA_LIST_DEFINED\n#define _VA_LIST_DEFINED\n#endif\n#ifndef _VA_LIST_T_H\n#define _VA_LIST_T_H\n#endif\n#ifndef __va_list__\n#define __va_list__\n#endif\n\n#endif\t\t\t\t/* not _VA_LIST_, except on certain systems */\n\n#endif\t\t\t\t/* not __svr4__ */\n\n#endif\t\t\t\t/* _STDARG_H */\n\n#endif\t\t\t\t/* not _ANSI_STDARG_H_ */\n#endif\t\t\t\t/* not _STDARG_H */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include/stdbool.h",
    "content": "/* Copyright (C) 1998-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.16  Boolean type and values  <stdbool.h>\n */\n\n#ifndef _STDBOOL_H\n#define _STDBOOL_H\n\n#ifndef __cplusplus\n\n#define bool\t_Bool\n#define true\t1\n#define false\t0\n\n#else\t\t\t\t/* __cplusplus */\n\n/* Supporting _Bool in C++ is a GCC extension.  */\n#define _Bool\tbool\n\n#if __cplusplus < 201103L\n/* Defining these macros in C++98 is a GCC extension.  */\n#define bool\tbool\n#define false\tfalse\n#define true\ttrue\n#endif\n\n#endif\t\t\t\t/* __cplusplus */\n\n/* Signal that all the definitions are present.  */\n#define __bool_true_false_are_defined\t1\n\n#endif\t\t\t\t/* stdbool.h */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include/stddef.h",
    "content": "/* Copyright (C) 1989-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.17  Common definitions  <stddef.h>\n */\n#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \\\n     && !defined(__STDDEF_H__)) \\\n    || defined(__need_wchar_t) || defined(__need_size_t) \\\n    || defined(__need_ptrdiff_t) || defined(__need_NULL) \\\n    || defined(__need_wint_t)\n\n/* Any one of these symbols __need_* means that GNU libc\n   wants us just to define one data type.  So don't define\n   the symbols that indicate this file's entire job has been done.  */\n#if (!defined(__need_wchar_t) && !defined(__need_size_t)\t\\\n     && !defined(__need_ptrdiff_t) && !defined(__need_NULL)\t\\\n     && !defined(__need_wint_t))\n#define _STDDEF_H\n#define _STDDEF_H_\n/* snaroff@next.com says the NeXT needs this.  */\n#define _ANSI_STDDEF_H\n#endif\n\n#ifndef __sys_stdtypes_h\n/* This avoids lossage on SunOS but only if stdtypes.h comes first.\n   There's no way to win with the other order!  Sun lossage.  */\n\n/* On 4.3bsd-net2, make sure ansi.h is included, so we have\n   one less case to deal with in the following.  */\n#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)\n#include <machine/ansi.h>\n#endif\n/* On FreeBSD 5, machine/ansi.h does not exist anymore... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#include <sys/_types.h>\n#endif\n\n/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are\n   defined if the corresponding type is *not* defined.\n   FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.\n   NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_)  || defined(_I386_ANSI_H_)\n#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)\n#define _SIZE_T\n#endif\n#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)\n#define _PTRDIFF_T\n#endif\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_. */\n#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)\n#ifndef _BSD_WCHAR_T_\n#define _WCHAR_T\n#endif\n#endif\n/* Undef _FOO_T_ if we are supposed to define foo_t.  */\n#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#if defined (__need_size_t) || defined (_STDDEF_H_)\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#if defined (__need_wchar_t) || defined (_STDDEF_H_)\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */\n\n/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.\n   Just ignore it.  */\n#if defined (__sequent__) && defined (_PTRDIFF_T_)\n#undef _PTRDIFF_T_\n#endif\n\n/* On VxWorks, <type/vxTypesBase.h> may have defined macros like\n   _TYPE_size_t which will typedef size_t.  fixincludes patched the\n   vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is\n   not defined, and so that defining this macro defines _GCC_SIZE_T.\n   If we find that the macros are still defined at this point, we must\n   invoke them so that the type is defined as expected.  */\n#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))\n_TYPE_ptrdiff_t;\n#undef _TYPE_ptrdiff_t\n#endif\n#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))\n_TYPE_size_t;\n#undef _TYPE_size_t\n#endif\n#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))\n_TYPE_wchar_t;\n#undef _TYPE_wchar_t\n#endif\n\n/* In case nobody has defined these types, but we aren't running under\n   GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and\n   __WCHAR_TYPE__ have reasonable values.  This can happen if the\n   parts of GCC is compiled by an older compiler, that actually\n   include gstddef.h, such as collect2.  */\n\n/* Signed type of difference of two pointers.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)\n#ifndef _PTRDIFF_T\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _T_PTRDIFF_\n#ifndef _T_PTRDIFF\n#ifndef __PTRDIFF_T\n#ifndef _PTRDIFF_T_\n#ifndef _BSD_PTRDIFF_T_\n#ifndef ___int_ptrdiff_t_h\n#ifndef _GCC_PTRDIFF_T\n#ifndef _PTRDIFF_T_DECLARED\t/* DragonFly */\n#define _PTRDIFF_T\n#define _T_PTRDIFF_\n#define _T_PTRDIFF\n#define __PTRDIFF_T\n#define _PTRDIFF_T_\n#define _BSD_PTRDIFF_T_\n#define ___int_ptrdiff_t_h\n#define _GCC_PTRDIFF_T\n#define _PTRDIFF_T_DECLARED\n#ifndef __PTRDIFF_TYPE__\n#define __PTRDIFF_TYPE__ long int\n#endif\ntypedef __PTRDIFF_TYPE__ ptrdiff_t;\n#endif\t\t\t\t/* _PTRDIFF_T_DECLARED */\n#endif\t\t\t\t/* _GCC_PTRDIFF_T */\n#endif\t\t\t\t/* ___int_ptrdiff_t_h */\n#endif\t\t\t\t/* _BSD_PTRDIFF_T_ */\n#endif\t\t\t\t/* _PTRDIFF_T_ */\n#endif\t\t\t\t/* __PTRDIFF_T */\n#endif\t\t\t\t/* _T_PTRDIFF */\n#endif\t\t\t\t/* _T_PTRDIFF_ */\n#endif\t\t\t\t/* _PTRDIFF_T */\n\n/* If this symbol has done its job, get rid of it.  */\n#undef\t__need_ptrdiff_t\n\n#endif\t\t\t\t/* _STDDEF_H or __need_ptrdiff_t.  */\n\n/* Unsigned type of `sizeof' something.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_size_t)\n#ifndef __size_t__\t\t/* BeOS */\n#ifndef __SIZE_T__\t\t/* Cray Unicos/Mk */\n#ifndef _SIZE_T\t\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _SYS_SIZE_T_H\n#ifndef _T_SIZE_\n#ifndef _T_SIZE\n#ifndef __SIZE_T\n#ifndef _SIZE_T_\n#ifndef _BSD_SIZE_T_\n#ifndef _SIZE_T_DEFINED_\n#ifndef _SIZE_T_DEFINED\n#ifndef _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#ifndef _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#ifndef ___int_size_t_h\n#ifndef _GCC_SIZE_T\n#ifndef _SIZET_\n#ifndef __size_t\n#define __size_t__\t\t/* BeOS */\n#define __SIZE_T__\t\t/* Cray Unicos/Mk */\n#define _SIZE_T\n#define _SYS_SIZE_T_H\n#define _T_SIZE_\n#define _T_SIZE\n#define __SIZE_T\n#define _SIZE_T_\n#define _BSD_SIZE_T_\n#define _SIZE_T_DEFINED_\n#define _SIZE_T_DEFINED\n#define _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#define _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#define ___int_size_t_h\n#define _GCC_SIZE_T\n#define _SIZET_\n#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \\\n  || defined(__DragonFly__) \\\n  || defined(__FreeBSD_kernel__)\n/* __size_t is a typedef on FreeBSD 5, must not trash it. */\n#elif defined (__VMS__)\n/* __size_t is also a typedef on VMS.  */\n#else\n#define __size_t\n#endif\n#ifndef __SIZE_TYPE__\n#define __SIZE_TYPE__ long unsigned int\n#endif\n#if !(defined (__GNUG__) && defined (size_t))\ntypedef __SIZE_TYPE__ size_t;\n#ifdef __BEOS__\ntypedef long ssize_t;\n#endif\t\t\t\t/* __BEOS__ */\n#endif\t\t\t\t/* !(defined (__GNUG__) && defined (size_t)) */\n#endif\t\t\t\t/* __size_t */\n#endif\t\t\t\t/* _SIZET_ */\n#endif\t\t\t\t/* _GCC_SIZE_T */\n#endif\t\t\t\t/* ___int_size_t_h */\n#endif\t\t\t\t/* _SIZE_T_DECLARED */\n#endif\t\t\t\t/* _BSD_SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _SIZE_T_DEFINED */\n#endif\t\t\t\t/* _SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _BSD_SIZE_T_ */\n#endif\t\t\t\t/* _SIZE_T_ */\n#endif\t\t\t\t/* __SIZE_T */\n#endif\t\t\t\t/* _T_SIZE */\n#endif\t\t\t\t/* _T_SIZE_ */\n#endif\t\t\t\t/* _SYS_SIZE_T_H */\n#endif\t\t\t\t/* _SIZE_T */\n#endif\t\t\t\t/* __SIZE_T__ */\n#endif\t\t\t\t/* __size_t__ */\n#undef\t__need_size_t\n#endif\t\t\t\t/* _STDDEF_H or __need_size_t.  */\n\n/* Wide character type.\n   Locale-writers should change this as necessary to\n   be big enough to hold unique values not between 0 and 127,\n   and not (wchar_t) -1, for each defined multibyte character.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_wchar_t)\n#ifndef __wchar_t__\t\t/* BeOS */\n#ifndef __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#ifndef _WCHAR_T\n#ifndef _T_WCHAR_\n#ifndef _T_WCHAR\n#ifndef __WCHAR_T\n#ifndef _WCHAR_T_\n#ifndef _BSD_WCHAR_T_\n#ifndef _BSD_WCHAR_T_DEFINED_\t/* Darwin */\n#ifndef _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#ifndef _WCHAR_T_DECLARED\t/* FreeBSD 5 */\n#ifndef _WCHAR_T_DEFINED_\n#ifndef _WCHAR_T_DEFINED\n#ifndef _WCHAR_T_H\n#ifndef ___int_wchar_t_h\n#ifndef __INT_WCHAR_T_H\n#ifndef _GCC_WCHAR_T\n#define __wchar_t__\t\t/* BeOS */\n#define __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#define _WCHAR_T\n#define _T_WCHAR_\n#define _T_WCHAR\n#define __WCHAR_T\n#define _WCHAR_T_\n#define _BSD_WCHAR_T_\n#define _WCHAR_T_DEFINED_\n#define _WCHAR_T_DEFINED\n#define _WCHAR_T_H\n#define ___int_wchar_t_h\n#define __INT_WCHAR_T_H\n#define _GCC_WCHAR_T\n#define _WCHAR_T_DECLARED\n\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other\n   symbols in the _FOO_T_ family, stays defined even after its\n   corresponding type is defined).  If we define wchar_t, then we\n   must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if\n   we undef _WCHAR_T_, then we must also define rune_t, since \n   headers like runetype.h assume that if machine/ansi.h is included,\n   and _BSD_WCHAR_T_ is not defined, then rune_t is available.\n   machine/ansi.h says, \"Note that _WCHAR_T_ and _RUNE_T_ must be of\n   the same type.\" */\n#ifdef _BSD_WCHAR_T_\n#undef _BSD_WCHAR_T_\n#ifdef _BSD_RUNE_T_\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\ntypedef _BSD_RUNE_T_ rune_t;\n#define _BSD_WCHAR_T_DEFINED_\n#define _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#if defined (__FreeBSD__) && (__FreeBSD__ < 5)\n/* Why is this file so hard to maintain properly?  In contrast to\n   the comment above regarding BSD/386 1.1, on FreeBSD for as long\n   as the symbol has existed, _BSD_RUNE_T_ must not stay defined or\n   redundant typedefs will occur when stdlib.h is included after this file. */\n#undef _BSD_RUNE_T_\n#endif\n#endif\n#endif\n#endif\n/* FreeBSD 5 can't be handled well using \"traditional\" logic above\n   since it no longer defines _BSD_RUNE_T_ yet still desires to export\n   rune_t in some cases... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\n#if __BSD_VISIBLE\n#ifndef _RUNE_T_DECLARED\ntypedef __rune_t rune_t;\n#define _RUNE_T_DECLARED\n#endif\n#endif\n#endif\n#endif\n\n#ifndef __WCHAR_TYPE__\n#define __WCHAR_TYPE__ int\n#endif\n#ifndef __cplusplus\ntypedef __WCHAR_TYPE__ wchar_t;\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* _WCHAR_T_DECLARED */\n#endif\t\t\t\t/* _BSD_RUNE_T_DEFINED_ */\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* __WCHAR_T__ */\n#endif\t\t\t\t/* __wchar_t__ */\n#undef\t__need_wchar_t\n#endif\t\t\t\t/* _STDDEF_H or __need_wchar_t.  */\n\n#if defined (__need_wint_t)\n#ifndef _WINT_T\n#define _WINT_T\n\n#ifndef __WINT_TYPE__\n#define __WINT_TYPE__ unsigned int\n#endif\ntypedef __WINT_TYPE__ wint_t;\n#endif\n#undef __need_wint_t\n#endif\n\n/*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.\n    are already defined.  */\n/*  BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.  */\n/*  NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here.  */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)\n/*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_\n    are probably typos and should be removed before 2.8 is released.  */\n#ifdef _GCC_PTRDIFF_T_\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T_\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T_\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n/*  The following ones are the real ones.  */\n#ifdef _GCC_PTRDIFF_T\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */\n\n#endif\t\t\t\t/* __sys_stdtypes_h */\n\n/* A null pointer constant.  */\n\n#if defined (_STDDEF_H) || defined (__need_NULL)\n#undef NULL\t\t\t/* in case <stdio.h> has defined it. */\n#ifdef __GNUG__\n#define NULL __null\n#else\t\t\t\t/* G++ */\n#ifndef __cplusplus\n#define NULL ((void *)0)\n#else\t\t\t\t/* C++ */\n#define NULL 0\n#endif\t\t\t\t/* C++ */\n#endif\t\t\t\t/* G++ */\n#endif\t\t\t\t/* NULL not defined and <stddef.h> or need NULL.  */\n#undef\t__need_NULL\n\n#ifdef _STDDEF_H\n\n/* Offset of member MEMBER in a struct of type TYPE. */\n#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)\n\n#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \\\n  || (defined(__cplusplus) && __cplusplus >= 201103L)\n#ifndef _GCC_MAX_ALIGN_T\n#define _GCC_MAX_ALIGN_T\n/* Type whose alignment is supported in every context and is at least\n   as great as that of any standard type not using alignment\n   specifiers.  */\ntypedef struct {\n\tlong long __max_align_ll __attribute__ ((__aligned__(__alignof__(long long))));\n\tlong double __max_align_ld __attribute__ ((__aligned__(__alignof__(long double))));\n\t/* _Float128 is defined as a basic type, so max_align_t must be\n\t   sufficiently aligned for it.  This code must work in C++, so we\n\t   use __float128 here; that is only available on some\n\t   architectures, but only on i386 is extra alignment needed for\n\t   __float128.  */\n#ifdef __i386__\n\t__float128 __max_align_f128 __attribute__ ((__aligned__(__alignof(__float128))));\n#endif\n} max_align_t;\n#endif\n#endif\t\t\t\t/* C11 or C++11.  */\n\n#if defined(__cplusplus) && __cplusplus >= 201103L\n#ifndef _GXX_NULLPTR_T\n#define _GXX_NULLPTR_T\ntypedef decltype(nullptr) nullptr_t;\n#endif\n#endif\t\t\t\t/* C++11.  */\n\n#endif\t\t\t\t/* _STDDEF_H was defined this time */\n\n#endif\t\t\t\t/* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__\n\t\t\t\t   || __need_XXX was not defined before */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include/stdint.h",
    "content": "#ifndef _GCC_WRAP_STDINT_H\n#if __STDC_HOSTED__\n# if defined __cplusplus && __cplusplus >= 201103L\n#  undef __STDC_LIMIT_MACROS\n#  define __STDC_LIMIT_MACROS\n#  undef __STDC_CONSTANT_MACROS\n#  define __STDC_CONSTANT_MACROS\n# endif\n# include_next <stdint.h>\n#else\n# include \"stdint-gcc.h\"\n#endif\n#define _GCC_WRAP_STDINT_H\n#endif\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include-fixed/limits.h",
    "content": "/* Copyright (C) 1992-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/* This administrivia gets added to the beginning of limits.h\n   if the system has its own version of limits.h.  */\n\n/* We use _GCC_LIMITS_H_ because we want this not to match\n   any macros that the system's limits.h uses for its own purposes.  */\n#ifndef _GCC_LIMITS_H_\t\t/* Terminated in limity.h.  */\n#define _GCC_LIMITS_H_\n\n#ifndef _LIBC_LIMITS_H_\n/* Use \"...\" so that we find syslimits.h only in this same directory.  */\n#include \"syslimits.h\"\n#endif\n/* Copyright (C) 1991-2017 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n#ifndef _LIMITS_H___\n#define _LIMITS_H___\n\n/* Number of bits in a `char'.  */\n#undef CHAR_BIT\n#define CHAR_BIT __CHAR_BIT__\n\n/* Maximum length of a multibyte character.  */\n#ifndef MB_LEN_MAX\n#define MB_LEN_MAX 1\n#endif\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#undef SCHAR_MIN\n#define SCHAR_MIN (-SCHAR_MAX - 1)\n#undef SCHAR_MAX\n#define SCHAR_MAX __SCHAR_MAX__\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0).  */\n#undef UCHAR_MAX\n#if __SCHAR_MAX__ == __INT_MAX__\n# define UCHAR_MAX (SCHAR_MAX * 2U + 1U)\n#else\n# define UCHAR_MAX (SCHAR_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `char' can hold.  */\n#ifdef __CHAR_UNSIGNED__\n# undef CHAR_MIN\n# if __SCHAR_MAX__ == __INT_MAX__\n#  define CHAR_MIN 0U\n# else\n#  define CHAR_MIN 0\n# endif\n# undef CHAR_MAX\n# define CHAR_MAX UCHAR_MAX\n#else\n# undef CHAR_MIN\n# define CHAR_MIN SCHAR_MIN\n# undef CHAR_MAX\n# define CHAR_MAX SCHAR_MAX\n#endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#undef SHRT_MIN\n#define SHRT_MIN (-SHRT_MAX - 1)\n#undef SHRT_MAX\n#define SHRT_MAX __SHRT_MAX__\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0).  */\n#undef USHRT_MAX\n#if __SHRT_MAX__ == __INT_MAX__\n# define USHRT_MAX (SHRT_MAX * 2U + 1U)\n#else\n# define USHRT_MAX (SHRT_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#undef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#undef INT_MAX\n#define INT_MAX __INT_MAX__\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */\n#undef UINT_MAX\n#define UINT_MAX (INT_MAX * 2U + 1U)\n\n/* Minimum and maximum values a `signed long int' can hold.\n   (Same as `int').  */\n#undef LONG_MIN\n#define LONG_MIN (-LONG_MAX - 1L)\n#undef LONG_MAX\n#define LONG_MAX __LONG_MAX__\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0).  */\n#undef ULONG_MAX\n#define ULONG_MAX (LONG_MAX * 2UL + 1UL)\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n/* Minimum and maximum values a `signed long long int' can hold.  */\n# undef LLONG_MIN\n# define LLONG_MIN (-LLONG_MAX - 1LL)\n# undef LLONG_MAX\n# define LLONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n# undef ULLONG_MAX\n# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)\n#endif\n\n#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)\n/* Minimum and maximum values a `signed long long int' can hold.  */\n# undef LONG_LONG_MIN\n# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)\n# undef LONG_LONG_MAX\n# define LONG_LONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n# undef ULONG_LONG_MAX\n# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)\n#endif\n\n#ifdef __STDC_WANT_IEC_60559_BFP_EXT__\n/* TS 18661-1 widths of integer types.  */\n# undef CHAR_WIDTH\n# define CHAR_WIDTH __SCHAR_WIDTH__\n# undef SCHAR_WIDTH\n# define SCHAR_WIDTH __SCHAR_WIDTH__\n# undef UCHAR_WIDTH\n# define UCHAR_WIDTH __SCHAR_WIDTH__\n# undef SHRT_WIDTH\n# define SHRT_WIDTH __SHRT_WIDTH__\n# undef USHRT_WIDTH\n# define USHRT_WIDTH __SHRT_WIDTH__\n# undef INT_WIDTH\n# define INT_WIDTH __INT_WIDTH__\n# undef UINT_WIDTH\n# define UINT_WIDTH __INT_WIDTH__\n# undef LONG_WIDTH\n# define LONG_WIDTH __LONG_WIDTH__\n# undef ULONG_WIDTH\n# define ULONG_WIDTH __LONG_WIDTH__\n# undef LLONG_WIDTH\n# define LLONG_WIDTH __LONG_LONG_WIDTH__\n# undef ULLONG_WIDTH\n# define ULLONG_WIDTH __LONG_LONG_WIDTH__\n#endif\n\n#endif\t\t\t\t/* _LIMITS_H___ */\n/* This administrivia gets added to the end of limits.h\n   if the system has its own version of limits.h.  */\n\n#else\t\t\t\t/* not _GCC_LIMITS_H_ */\n\n#ifdef _GCC_NEXT_LIMITS_H\n#include_next <limits.h>\t/* recurse down to the real one */\n#endif\n\n#endif\t\t\t\t/* not _GCC_LIMITS_H_ */\n"
  },
  {
    "path": "v2/headers/linux_386/usr/lib/gcc/i686-linux-gnu/7/include-fixed/syslimits.h",
    "content": "/* syslimits.h stands for the system's own limits.h file.\n   If we can use it ok unmodified, then we install this text.\n   If fixincludes fixes it, then the fixed version is installed\n   instead of this text.  */\n\n#define _GCC_NEXT_LIMITS_H\t/* tell gcc's limits.h to recurse */\n#include_next <limits.h>\n#undef _GCC_NEXT_LIMITS_H\n"
  },
  {
    "path": "v2/headers/linux_amd64/builtin.h",
    "content": "//  Copyright 2018 The CC Authors. All rights reserved.\n//  Use of this source code is governed by a BSD-style\n//  license that can be found in the LICENSE file.\n\n// +build ignore\n\n#ifndef _BUILTIN_H_\n#define _BUILTIN_H_\n\n#include \"predefined.h\"\n\ntypedef void *__builtin_va_list;\n\ntypedef void *__FILE_TYPE__;\n\n__SIZE_TYPE__ __builtin_strlen(char *__s);\n__UINT64_TYPE__ __builtin_bswap64(__UINT64_TYPE__ x);\n__builtin_va_list __builtin_va_copy();\nchar *__builtin_strchrnul(char *, int);\nchar *__builtin_strcpy(char *__dest, char *__src);\ndouble __builtin_copysign(double x, double y);\nint __builtin_abs(int j);\nint __builtin_ffs(int i);\nint __builtin_isprint(int);\nint __builtin_memcmp(void *__s1, void *__s2, __SIZE_TYPE__ __n);\nint __builtin_printf(char *__format, ...);\nint __builtin_sprintf(char *__s, char *__format, ...);\nint __builtin_strcmp(char *__s1, char *__s2);\nint __signbit(double x);\nint __signbitf(float x);\nvoid *__GO2__(char*);\nvoid *__builtin_alloca(__SIZE_TYPE__ __size);\nvoid *__builtin_memcpy(void *dest, const void *src, __SIZE_TYPE__ n);\nvoid *__builtin_memset(void *s, int c, __SIZE_TYPE__ n);\nvoid __GO__(char*);\nvoid __builtin_abort(void);\nvoid __builtin_exit(int __status);\nvoid __builtin_free(void*);\nvoid __builtin_trap(void);\nvoid __builtin_va_end(__builtin_va_list);\nvoid __register_stdfiles(void *, void *, void *, void *);\n\n#define __builtin_choose_expr(a, b, c) (a) ? (b) : (c)\n#define __builtin_expect(exp, c) (exp)\n#define __builtin_offsetof(st, m) ((__SIZE_TYPE__)(&((st *)0)->m))\n#define __builtin_prefetch(addr, ...) (void)(addr)\n#define __builtin_signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : sizeof (x) == sizeof(double) ? __signbit(x) : __signbitl(x))\n#define __builtin_types_compatible_p(type1, type2) __builtin_types_compatible__((type1){}, (type2){})\n#define __builtin_va_arg(ap, type) (type)ap\n#ifdef __ccgo__\n#define __builtin_va_copy(dest, src) dest = __builtin_va_copy(src)\n#define __builtin_va_end(ap) __builtin_va_end(ap)\n#define __builtin_va_start(ap, arg) ap = __GO2__(\"X__builtin_va_start(tls, ap)\")\n#else\n#define __builtin_va_copy(dest, src) dest = src\n#define __builtin_va_end(ap) ap = (void*)0\n#define __builtin_va_start(ap, arg) ap = (void*)-1\n#endif\n#define __complex__ _Complex\n#define __const const\n#define __extension__\n#define __typeof__ typeof\n#define __volatile volatile\n\n#endif\t\t\t\t/* _BUILTIN_H_ */\n"
  },
  {
    "path": "v2/headers/linux_amd64/paths",
    "content": "/usr/lib64/gcc/x86_64-suse-linux/4.8/include\n/usr/local/include\n/usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed\n/usr/x86_64-suse-linux/include\n/usr/include\n"
  },
  {
    "path": "v2/headers/linux_amd64/predefined.h",
    "content": "// Code generated by $ go generate - DO NOT EDIT.\n\n// +build ignore\n\n#define __DBL_MIN_EXP__ (-1021)\n#define __UINT_LEAST16_MAX__ 65535\n#define __ATOMIC_ACQUIRE 2\n#define __FLT_MIN__ 1.17549435082228750797e-38F\n#define __UINT_LEAST8_TYPE__ unsigned char\n#define __INTMAX_C(c) c ## L\n#define __CHAR_BIT__ 8\n#define __UINT8_MAX__ 255\n#define __WINT_MAX__ 4294967295U\n#define __ORDER_LITTLE_ENDIAN__ 1234\n#define __SIZE_MAX__ 18446744073709551615UL\n#define __WCHAR_MAX__ 2147483647\n#define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L)\n#define __FLT_EVAL_METHOD__ 0\n#define __unix__ 1\n#define __x86_64 1\n#define __UINT_FAST64_MAX__ 18446744073709551615UL\n#define __SIG_ATOMIC_TYPE__ int\n#define __DBL_MIN_10_EXP__ (-307)\n#define __FINITE_MATH_ONLY__ 0\n#define __UINT_FAST8_MAX__ 255\n#define __DEC64_MAX_EXP__ 385\n#define __INT8_C(c) c\n#define __UINT_LEAST64_MAX__ 18446744073709551615UL\n#define __SHRT_MAX__ 32767\n#define __LDBL_MAX__ 1.18973149535723176502e+4932L\n#define __UINT_LEAST8_MAX__ 255\n#define __UINTMAX_TYPE__ long unsigned int\n#define __linux 1\n#define __DEC32_EPSILON__ 1E-6DF\n#define __unix 1\n#define __UINT32_MAX__ 4294967295U\n#define __LDBL_MAX_EXP__ 16384\n#define __WINT_MIN__ 0U\n#define __linux__ 1\n#define __SCHAR_MAX__ 127\n#define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1)\n#define __INT64_C(c) c ## L\n#define __DBL_DIG__ 15\n#define __SIZEOF_INT__ 4\n#define __SIZEOF_POINTER__ 8\n#define __USER_LABEL_PREFIX__\n#define __STDC_HOSTED__ 1\n#define __LDBL_HAS_INFINITY__ 1\n#define __FLT_EPSILON__ 1.19209289550781250000e-7F\n#define __LDBL_MIN__ 3.36210314311209350626e-4932L\n#define __DEC32_MAX__ 9.999999E96DF\n#define __INT32_MAX__ 2147483647\n#define __SIZEOF_LONG__ 8\n#define __STDC_IEC_559__ 1\n#define __STDC_ISO_10646__ 201304L\n#define __UINT16_C(c) c\n#define __DECIMAL_DIG__ 21\n#define __LDBL_HAS_QUIET_NAN__ 1\n#define __MMX__ 1\n#define __FLT_HAS_DENORM__ 1\n#define __SIZEOF_LONG_DOUBLE__ 16\n#define __BIGGEST_ALIGNMENT__ 16\n#define __DBL_MAX__ ((double)1.79769313486231570815e+308L)\n#define __INT_FAST32_MAX__ 9223372036854775807L\n#define __DBL_HAS_INFINITY__ 1\n#define __DEC32_MIN_EXP__ (-94)\n#define __INT_FAST16_TYPE__ long int\n#define __STRICT_ANSI__ 1\n#define __LDBL_HAS_DENORM__ 1\n#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL\n#define __INT_LEAST32_MAX__ 2147483647\n#define __DEC32_MIN__ 1E-95DF\n#define __DBL_MAX_EXP__ 1024\n#define __DEC128_EPSILON__ 1E-33DL\n#define __SSE2_MATH__ 1\n#define __ATOMIC_HLE_RELEASE 131072\n#define __PTRDIFF_MAX__ 9223372036854775807L\n#define __amd64 1\n#define __STDC_NO_THREADS__ 1\n#define __ATOMIC_HLE_ACQUIRE 65536\n#define __LONG_LONG_MAX__ 9223372036854775807LL\n#define __SIZEOF_SIZE_T__ 8\n#define __SIZEOF_WINT_T__ 4\n#define __GXX_ABI_VERSION 1002\n#define __FLT_MIN_EXP__ (-125)\n#define __INT_FAST64_TYPE__ long int\n#define __DBL_MIN__ ((double)2.22507385850720138309e-308L)\n#define __LP64__ 1\n#define __DECIMAL_BID_FORMAT__ 1\n#define __DEC128_MIN__ 1E-6143DL\n#define __REGISTER_PREFIX__\n#define __UINT16_MAX__ 65535\n#define __DBL_HAS_DENORM__ 1\n#define __UINT8_TYPE__ unsigned char\n#define __NO_INLINE__ 1\n#define __FLT_MANT_DIG__ 24\n#define __VERSION__ \"4.8.5\"\n#define __UINT64_C(c) c ## UL\n#define _STDC_PREDEF_H 1\n#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __STDC_IEC_559_COMPLEX__ 1\n#define __INT32_C(c) c\n#define __DEC64_EPSILON__ 1E-15DD\n#define __ORDER_PDP_ENDIAN__ 3412\n#define __DEC128_MIN_EXP__ (-6142)\n#define __INT_FAST32_TYPE__ long int\n#define __UINT_LEAST16_TYPE__ short unsigned int\n#define __INT16_MAX__ 32767\n#define __SIZE_TYPE__ long unsigned int\n#define __UINT64_MAX__ 18446744073709551615UL\n#define __INT8_TYPE__ signed char\n#define __ELF__ 1\n#define __FLT_RADIX__ 2\n#define __INT_LEAST16_TYPE__ short int\n#define __LDBL_EPSILON__ 1.08420217248550443401e-19L\n#define __UINTMAX_C(c) c ## UL\n#define __SSE_MATH__ 1\n#define __k8 1\n#define __SIG_ATOMIC_MAX__ 2147483647\n#define __SIZEOF_PTRDIFF_T__ 8\n#define __x86_64__ 1\n#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF\n#define __INT_FAST16_MAX__ 9223372036854775807L\n#define __UINT_FAST32_MAX__ 18446744073709551615UL\n#define __UINT_LEAST64_TYPE__ long unsigned int\n#define __FLT_HAS_QUIET_NAN__ 1\n#define __FLT_MAX_10_EXP__ 38\n#define __LONG_MAX__ 9223372036854775807L\n#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL\n#define __FLT_HAS_INFINITY__ 1\n#define __UINT_FAST16_TYPE__ long unsigned int\n#define __DEC64_MAX__ 9.999999999999999E384DD\n#define __CHAR16_TYPE__ short unsigned int\n#define __PRAGMA_REDEFINE_EXTNAME 1\n#define __INT_LEAST16_MAX__ 32767\n#define __DEC64_MANT_DIG__ 16\n#define __INT64_MAX__ 9223372036854775807L\n#define __UINT_LEAST32_MAX__ 4294967295U\n#define __INT_LEAST64_TYPE__ long int\n#define __INT16_TYPE__ short int\n#define __INT_LEAST8_TYPE__ signed char\n#define __STDC_VERSION__ 199901L\n#define __DEC32_MAX_EXP__ 97\n#define __INT_FAST8_MAX__ 127\n#define __INTPTR_MAX__ 9223372036854775807L\n#define __SSE2__ 1\n#define __LDBL_MANT_DIG__ 64\n#define __DBL_HAS_QUIET_NAN__ 1\n#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)\n#define __code_model_small__ 1\n#define __k8__ 1\n#define __INTPTR_TYPE__ long int\n#define __UINT16_TYPE__ short unsigned int\n#define __WCHAR_TYPE__ int\n#define __SIZEOF_FLOAT__ 4\n#define __UINTPTR_MAX__ 18446744073709551615UL\n#define __DEC64_MIN_EXP__ (-382)\n#define __INT_FAST64_MAX__ 9223372036854775807L\n#define __FLT_DIG__ 6\n#define __UINT_FAST64_TYPE__ long unsigned int\n#define __INT_MAX__ 2147483647\n#define __amd64__ 1\n#define __INT64_TYPE__ long int\n#define __FLT_MAX_EXP__ 128\n#define __ORDER_BIG_ENDIAN__ 4321\n#define __DBL_MANT_DIG__ 53\n#define __INT_LEAST64_MAX__ 9223372036854775807L\n#define __DEC64_MIN__ 1E-383DD\n#define __WINT_TYPE__ unsigned int\n#define __UINT_LEAST32_TYPE__ unsigned int\n#define __SIZEOF_SHORT__ 2\n#define __SSE__ 1\n#define __LDBL_MIN_EXP__ (-16381)\n#define __INT_LEAST8_MAX__ 127\n#define __SIZEOF_INT128__ 16\n#define __LDBL_MAX_10_EXP__ 4932\n#define __ATOMIC_RELAXED 0\n#define __DBL_EPSILON__ ((double)2.22044604925031308085e-16L)\n#define _LP64 1\n#define __UINT8_C(c) c\n#define __INT_LEAST32_TYPE__ int\n#define __SIZEOF_WCHAR_T__ 4\n#define __UINT64_TYPE__ long unsigned int\n#define __INT_FAST8_TYPE__ signed char\n#define __DBL_DECIMAL_DIG__ 17\n#define __FXSR__ 1\n#define __DEC_EVAL_METHOD__ 2\n#define __UINT32_C(c) c ## U\n#define __INTMAX_MAX__ 9223372036854775807L\n#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F\n#define __INT8_MAX__ 127\n#define __UINT_FAST32_TYPE__ long unsigned int\n#define __CHAR32_TYPE__ unsigned int\n#define __FLT_MAX__ 3.40282346638528859812e+38F\n#define __INT32_TYPE__ int\n#define __SIZEOF_DOUBLE__ 8\n#define __FLT_MIN_10_EXP__ (-37)\n#define __INTMAX_TYPE__ long int\n#define __DEC128_MAX_EXP__ 6145\n#define __ATOMIC_CONSUME 1\n#define __UINTMAX_MAX__ 18446744073709551615UL\n#define __DEC32_MANT_DIG__ 7\n#define __DBL_MAX_10_EXP__ 308\n#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L\n#define __INT16_C(c) c\n#define __STDC__ 1\n#define __PTRDIFF_TYPE__ long int\n#define __ATOMIC_SEQ_CST 5\n#define __UINT32_TYPE__ unsigned int\n#define __UINTPTR_TYPE__ long unsigned int\n#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD\n#define __DEC128_MANT_DIG__ 34\n#define __LDBL_MIN_10_EXP__ (-4931)\n#define __SIZEOF_LONG_LONG__ 8\n#define __LDBL_DIG__ 18\n#define __FLT_DECIMAL_DIG__ 9\n#define __UINT_FAST16_MAX__ 18446744073709551615UL\n#define __UINT_FAST8_TYPE__ unsigned char\n#define __ATOMIC_ACQ_REL 4\n#define __ATOMIC_RELEASE 3\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/_G_config.h",
    "content": "/* This file is needed by libio to define various configuration parameters.\n   These are always the same in the GNU C library.  */\n\n#ifndef _G_config_h\n#define _G_config_h 1\n\n/* Define types for libio in terms of the standard internal type names.  */\n\n#include <bits/types.h>\n#define __need_size_t\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# define __need_wchar_t\n#endif\n#define __need_NULL\n#include <stddef.h>\n#define __need_mbstate_t\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# define __need_wint_t\n#endif\n#include <wchar.h>\ntypedef struct {\n\t__off_t __pos;\n\t__mbstate_t __state;\n} _G_fpos_t;\ntypedef struct {\n\t__off64_t __pos;\n\t__mbstate_t __state;\n} _G_fpos64_t;\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# include <gconv.h>\ntypedef union {\n\tstruct __gconv_info __cd;\n\tstruct {\n\t\tstruct __gconv_info __cd;\n\t\tstruct __gconv_step_data __data;\n\t} __combined;\n} _G_iconv_t;\n#endif\n\n/* These library features are always available in the GNU C library.  */\n#define _G_va_list __gnuc_va_list\n\n#define _G_HAVE_MMAP 1\n#define _G_HAVE_MREMAP 1\n\n#define _G_IO_IO_FILE_VERSION 0x20001\n\n/* This is defined by <bits/stat.h> if `st_blksize' exists.  */\n#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)\n\n#define _G_BUFSIZ 8192\n\n#endif\t\t\t\t/* _G_config.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/alloca.h",
    "content": "/* Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ALLOCA_H\n#define\t_ALLOCA_H\t1\n\n#include <features.h>\n\n#define\t__need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS\n/* Remove any previous definitions.  */\n#undef\talloca\n/* Allocate a block that will be freed when the calling function exits.  */\nextern void *alloca(size_t __size) __THROW;\n\n#ifdef\t__GNUC__\n# define alloca(size)\t__builtin_alloca (size)\n#endif\t\t\t\t/* GCC.  */\n\n__END_DECLS\n#endif\t\t\t\t/* alloca.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/arpa/inet.h",
    "content": "/* Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _ARPA_INET_H\n#define\t_ARPA_INET_H\t1\n\n#include <features.h>\n#include <netinet/in.h>\t\t/* To define `struct in_addr'.  */\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n# define __socklen_t_defined\n#endif\n\n__BEGIN_DECLS\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data in network byte order.  */\nextern in_addr_t inet_addr(const char *__cp) __THROW;\n\n/* Return the local host address part of the Internet address in IN.  */\nextern in_addr_t inet_lnaof(struct in_addr __in) __THROW;\n\n/* Make Internet host address in network byte order by combining the\n   network number NET with the local address HOST.  */\nextern struct in_addr inet_makeaddr(in_addr_t __net, in_addr_t __host) __THROW;\n\n/* Return network number part of the Internet address IN.  */\nextern in_addr_t inet_netof(struct in_addr __in) __THROW;\n\n/* Extract the network number in network byte order from the address\n   in numbers-and-dots natation starting at CP.  */\nextern in_addr_t inet_network(const char *__cp) __THROW;\n\n/* Convert Internet number in IN to ASCII representation.  The return value\n   is a pointer to an internal array containing the string.  */\nextern char *inet_ntoa(struct in_addr __in) __THROW;\n\n/* Convert from presentation format of an Internet number in buffer\n   starting at CP to the binary network format and store result for\n   interface type AF in buffer starting at BUF.  */\nextern int inet_pton(int __af, const char *__restrict __cp, void *__restrict __buf) __THROW;\n\n/* Convert a Internet address in binary network format for interface\n   type AF in buffer starting at CP to presentation form and place\n   result in buffer of length LEN astarting at BUF.  */\nextern const char *inet_ntop(int __af, const void *__restrict __cp, char *__restrict __buf, socklen_t __len) __THROW;\n\n/* The following functions are not part of XNS 5.2.  */\n#ifdef __USE_MISC\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data and store the result in the structure INP.  */\nextern int inet_aton(const char *__cp, struct in_addr *__inp) __THROW;\n\n/* Format a network number NET into presentation format and place result\n   in buffer starting at BUF with length of LEN bytes.  */\nextern char *inet_neta(in_addr_t __net, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF in buffer starting at\n   CP to presentation format.  The result will specifiy BITS bits of\n   the number.  */\nextern char *inet_net_ntop(int __af, const void *__cp, int __bits, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF from presentation in\n   buffer starting at CP to network format and store result int\n   buffer starting at BUF of size LEN.  */\nextern int inet_net_pton(int __af, const char *__cp, void *__buf, size_t __len) __THROW;\n\n/* Convert ASCII representation in hexadecimal form of the Internet\n   address to binary form and place result in buffer of length LEN\n   starting at BUF.  */\nextern unsigned int inet_nsap_addr(const char *__cp, unsigned char *__buf, int __len) __THROW;\n\n/* Convert internet address in binary form in LEN bytes starting at CP\n   a presentation form and place result in BUF.  */\nextern char *inet_nsap_ntoa(int __len, const unsigned char *__cp, char *__buf) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* arpa/inet.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/errno.h",
    "content": "#include <asm-generic/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/ioctl.h",
    "content": "#include <asm-generic/ioctl.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/ioctls.h",
    "content": "#include <asm-generic/ioctls.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/param.h",
    "content": "#include <asm-generic/param.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/socket.h",
    "content": "#include <asm-generic/socket.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm/sockios.h",
    "content": "#include <asm-generic/sockios.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/errno-base.h",
    "content": "#ifndef _ASM_GENERIC_ERRNO_BASE_H\n#define _ASM_GENERIC_ERRNO_BASE_H\n\n#define\tEPERM\t\t 1\t/* Operation not permitted */\n#define\tENOENT\t\t 2\t/* No such file or directory */\n#define\tESRCH\t\t 3\t/* No such process */\n#define\tEINTR\t\t 4\t/* Interrupted system call */\n#define\tEIO\t\t 5\t/* I/O error */\n#define\tENXIO\t\t 6\t/* No such device or address */\n#define\tE2BIG\t\t 7\t/* Argument list too long */\n#define\tENOEXEC\t\t 8\t/* Exec format error */\n#define\tEBADF\t\t 9\t/* Bad file number */\n#define\tECHILD\t\t10\t/* No child processes */\n#define\tEAGAIN\t\t11\t/* Try again */\n#define\tENOMEM\t\t12\t/* Out of memory */\n#define\tEACCES\t\t13\t/* Permission denied */\n#define\tEFAULT\t\t14\t/* Bad address */\n#define\tENOTBLK\t\t15\t/* Block device required */\n#define\tEBUSY\t\t16\t/* Device or resource busy */\n#define\tEEXIST\t\t17\t/* File exists */\n#define\tEXDEV\t\t18\t/* Cross-device link */\n#define\tENODEV\t\t19\t/* No such device */\n#define\tENOTDIR\t\t20\t/* Not a directory */\n#define\tEISDIR\t\t21\t/* Is a directory */\n#define\tEINVAL\t\t22\t/* Invalid argument */\n#define\tENFILE\t\t23\t/* File table overflow */\n#define\tEMFILE\t\t24\t/* Too many open files */\n#define\tENOTTY\t\t25\t/* Not a typewriter */\n#define\tETXTBSY\t\t26\t/* Text file busy */\n#define\tEFBIG\t\t27\t/* File too large */\n#define\tENOSPC\t\t28\t/* No space left on device */\n#define\tESPIPE\t\t29\t/* Illegal seek */\n#define\tEROFS\t\t30\t/* Read-only file system */\n#define\tEMLINK\t\t31\t/* Too many links */\n#define\tEPIPE\t\t32\t/* Broken pipe */\n#define\tEDOM\t\t33\t/* Math argument out of domain of func */\n#define\tERANGE\t\t34\t/* Math result not representable */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/errno.h",
    "content": "#ifndef _ASM_GENERIC_ERRNO_H\n#define _ASM_GENERIC_ERRNO_H\n\n#include <asm-generic/errno-base.h>\n\n#define\tEDEADLK\t\t35\t/* Resource deadlock would occur */\n#define\tENAMETOOLONG\t36\t/* File name too long */\n#define\tENOLCK\t\t37\t/* No record locks available */\n\n/*\n * This error code is special: arch syscall entry code will return\n * -ENOSYS if users try to call a syscall that doesn't exist.  To keep\n * failures of syscalls that really do exist distinguishable from\n * failures due to attempts to use a nonexistent syscall, syscall\n * implementations should refrain from returning -ENOSYS.\n */\n#define\tENOSYS\t\t38\t/* Invalid system call number */\n\n#define\tENOTEMPTY\t39\t/* Directory not empty */\n#define\tELOOP\t\t40\t/* Too many symbolic links encountered */\n#define\tEWOULDBLOCK\tEAGAIN\t/* Operation would block */\n#define\tENOMSG\t\t42\t/* No message of desired type */\n#define\tEIDRM\t\t43\t/* Identifier removed */\n#define\tECHRNG\t\t44\t/* Channel number out of range */\n#define\tEL2NSYNC\t45\t/* Level 2 not synchronized */\n#define\tEL3HLT\t\t46\t/* Level 3 halted */\n#define\tEL3RST\t\t47\t/* Level 3 reset */\n#define\tELNRNG\t\t48\t/* Link number out of range */\n#define\tEUNATCH\t\t49\t/* Protocol driver not attached */\n#define\tENOCSI\t\t50\t/* No CSI structure available */\n#define\tEL2HLT\t\t51\t/* Level 2 halted */\n#define\tEBADE\t\t52\t/* Invalid exchange */\n#define\tEBADR\t\t53\t/* Invalid request descriptor */\n#define\tEXFULL\t\t54\t/* Exchange full */\n#define\tENOANO\t\t55\t/* No anode */\n#define\tEBADRQC\t\t56\t/* Invalid request code */\n#define\tEBADSLT\t\t57\t/* Invalid slot */\n\n#define\tEDEADLOCK\tEDEADLK\n\n#define\tEBFONT\t\t59\t/* Bad font file format */\n#define\tENOSTR\t\t60\t/* Device not a stream */\n#define\tENODATA\t\t61\t/* No data available */\n#define\tETIME\t\t62\t/* Timer expired */\n#define\tENOSR\t\t63\t/* Out of streams resources */\n#define\tENONET\t\t64\t/* Machine is not on the network */\n#define\tENOPKG\t\t65\t/* Package not installed */\n#define\tEREMOTE\t\t66\t/* Object is remote */\n#define\tENOLINK\t\t67\t/* Link has been severed */\n#define\tEADV\t\t68\t/* Advertise error */\n#define\tESRMNT\t\t69\t/* Srmount error */\n#define\tECOMM\t\t70\t/* Communication error on send */\n#define\tEPROTO\t\t71\t/* Protocol error */\n#define\tEMULTIHOP\t72\t/* Multihop attempted */\n#define\tEDOTDOT\t\t73\t/* RFS specific error */\n#define\tEBADMSG\t\t74\t/* Not a data message */\n#define\tEOVERFLOW\t75\t/* Value too large for defined data type */\n#define\tENOTUNIQ\t76\t/* Name not unique on network */\n#define\tEBADFD\t\t77\t/* File descriptor in bad state */\n#define\tEREMCHG\t\t78\t/* Remote address changed */\n#define\tELIBACC\t\t79\t/* Can not access a needed shared library */\n#define\tELIBBAD\t\t80\t/* Accessing a corrupted shared library */\n#define\tELIBSCN\t\t81\t/* .lib section in a.out corrupted */\n#define\tELIBMAX\t\t82\t/* Attempting to link in too many shared libraries */\n#define\tELIBEXEC\t83\t/* Cannot exec a shared library directly */\n#define\tEILSEQ\t\t84\t/* Illegal byte sequence */\n#define\tERESTART\t85\t/* Interrupted system call should be restarted */\n#define\tESTRPIPE\t86\t/* Streams pipe error */\n#define\tEUSERS\t\t87\t/* Too many users */\n#define\tENOTSOCK\t88\t/* Socket operation on non-socket */\n#define\tEDESTADDRREQ\t89\t/* Destination address required */\n#define\tEMSGSIZE\t90\t/* Message too long */\n#define\tEPROTOTYPE\t91\t/* Protocol wrong type for socket */\n#define\tENOPROTOOPT\t92\t/* Protocol not available */\n#define\tEPROTONOSUPPORT\t93\t/* Protocol not supported */\n#define\tESOCKTNOSUPPORT\t94\t/* Socket type not supported */\n#define\tEOPNOTSUPP\t95\t/* Operation not supported on transport endpoint */\n#define\tEPFNOSUPPORT\t96\t/* Protocol family not supported */\n#define\tEAFNOSUPPORT\t97\t/* Address family not supported by protocol */\n#define\tEADDRINUSE\t98\t/* Address already in use */\n#define\tEADDRNOTAVAIL\t99\t/* Cannot assign requested address */\n#define\tENETDOWN\t100\t/* Network is down */\n#define\tENETUNREACH\t101\t/* Network is unreachable */\n#define\tENETRESET\t102\t/* Network dropped connection because of reset */\n#define\tECONNABORTED\t103\t/* Software caused connection abort */\n#define\tECONNRESET\t104\t/* Connection reset by peer */\n#define\tENOBUFS\t\t105\t/* No buffer space available */\n#define\tEISCONN\t\t106\t/* Transport endpoint is already connected */\n#define\tENOTCONN\t107\t/* Transport endpoint is not connected */\n#define\tESHUTDOWN\t108\t/* Cannot send after transport endpoint shutdown */\n#define\tETOOMANYREFS\t109\t/* Too many references: cannot splice */\n#define\tETIMEDOUT\t110\t/* Connection timed out */\n#define\tECONNREFUSED\t111\t/* Connection refused */\n#define\tEHOSTDOWN\t112\t/* Host is down */\n#define\tEHOSTUNREACH\t113\t/* No route to host */\n#define\tEALREADY\t114\t/* Operation already in progress */\n#define\tEINPROGRESS\t115\t/* Operation now in progress */\n#define\tESTALE\t\t116\t/* Stale file handle */\n#define\tEUCLEAN\t\t117\t/* Structure needs cleaning */\n#define\tENOTNAM\t\t118\t/* Not a XENIX named type file */\n#define\tENAVAIL\t\t119\t/* No XENIX semaphores available */\n#define\tEISNAM\t\t120\t/* Is a named type file */\n#define\tEREMOTEIO\t121\t/* Remote I/O error */\n#define\tEDQUOT\t\t122\t/* Quota exceeded */\n\n#define\tENOMEDIUM\t123\t/* No medium found */\n#define\tEMEDIUMTYPE\t124\t/* Wrong medium type */\n#define\tECANCELED\t125\t/* Operation Canceled */\n#define\tENOKEY\t\t126\t/* Required key not available */\n#define\tEKEYEXPIRED\t127\t/* Key has expired */\n#define\tEKEYREVOKED\t128\t/* Key has been revoked */\n#define\tEKEYREJECTED\t129\t/* Key was rejected by service */\n\n/* for robust mutexes */\n#define\tEOWNERDEAD\t130\t/* Owner died */\n#define\tENOTRECOVERABLE\t131\t/* State not recoverable */\n\n#define ERFKILL\t\t132\t/* Operation not possible due to RF-kill */\n\n#define EHWPOISON\t133\t/* Memory page has hardware error */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/ioctl.h",
    "content": "#ifndef _ASM_GENERIC_IOCTL_H\n#define _ASM_GENERIC_IOCTL_H\n\n/* ioctl command encoding: 32 bits total, command in lower 16 bits,\n * size of the parameter structure in the lower 14 bits of the\n * upper 16 bits.\n * Encoding the size of the parameter structure in the ioctl request\n * is useful for catching programs compiled with old versions\n * and to avoid overwriting user space outside the user buffer area.\n * The highest 2 bits are reserved for indicating the ``access mode''.\n * NOTE: This limits the max parameter size to 16kB -1 !\n */\n\n/*\n * The following is for compatibility across the various Linux\n * platforms.  The generic ioctl numbering scheme doesn't really enforce\n * a type field.  De facto, however, the top 8 bits of the lower 16\n * bits are indeed used as a type field, so we might just as well make\n * this explicit here.  Please be sure to use the decoding macros\n * below from now on.\n */\n#define _IOC_NRBITS\t8\n#define _IOC_TYPEBITS\t8\n\n/*\n * Let any architecture override either of the following before\n * including this file.\n */\n\n#ifndef _IOC_SIZEBITS\n# define _IOC_SIZEBITS\t14\n#endif\n\n#ifndef _IOC_DIRBITS\n# define _IOC_DIRBITS\t2\n#endif\n\n#define _IOC_NRMASK\t((1 << _IOC_NRBITS)-1)\n#define _IOC_TYPEMASK\t((1 << _IOC_TYPEBITS)-1)\n#define _IOC_SIZEMASK\t((1 << _IOC_SIZEBITS)-1)\n#define _IOC_DIRMASK\t((1 << _IOC_DIRBITS)-1)\n\n#define _IOC_NRSHIFT\t0\n#define _IOC_TYPESHIFT\t(_IOC_NRSHIFT+_IOC_NRBITS)\n#define _IOC_SIZESHIFT\t(_IOC_TYPESHIFT+_IOC_TYPEBITS)\n#define _IOC_DIRSHIFT\t(_IOC_SIZESHIFT+_IOC_SIZEBITS)\n\n/*\n * Direction bits, which any architecture can choose to override\n * before including this file.\n */\n\n#ifndef _IOC_NONE\n# define _IOC_NONE\t0U\n#endif\n\n#ifndef _IOC_WRITE\n# define _IOC_WRITE\t1U\n#endif\n\n#ifndef _IOC_READ\n# define _IOC_READ\t2U\n#endif\n\n#define _IOC(dir,type,nr,size) \\\n\t(((dir)  << _IOC_DIRSHIFT) | \\\n\t ((type) << _IOC_TYPESHIFT) | \\\n\t ((nr)   << _IOC_NRSHIFT) | \\\n\t ((size) << _IOC_SIZESHIFT))\n\n#define _IOC_TYPECHECK(t) (sizeof(t))\n\n/* used to create numbers */\n#define _IO(type,nr)\t\t_IOC(_IOC_NONE,(type),(nr),0)\n#define _IOR(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOW(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOWR(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOR_BAD(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),sizeof(size))\n#define _IOW_BAD(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),sizeof(size))\n#define _IOWR_BAD(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))\n\n/* used to decode ioctl numbers.. */\n#define _IOC_DIR(nr)\t\t(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)\n#define _IOC_TYPE(nr)\t\t(((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)\n#define _IOC_NR(nr)\t\t(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)\n#define _IOC_SIZE(nr)\t\t(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)\n\n/* ...and for the drivers/sound files... */\n\n#define IOC_IN\t\t(_IOC_WRITE << _IOC_DIRSHIFT)\n#define IOC_OUT\t\t(_IOC_READ << _IOC_DIRSHIFT)\n#define IOC_INOUT\t((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)\n#define IOCSIZE_MASK\t(_IOC_SIZEMASK << _IOC_SIZESHIFT)\n#define IOCSIZE_SHIFT\t(_IOC_SIZESHIFT)\n\n#endif\t\t\t\t/* _ASM_GENERIC_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/ioctls.h",
    "content": "#ifndef __ASM_GENERIC_IOCTLS_H\n#define __ASM_GENERIC_IOCTLS_H\n\n#include <linux/ioctl.h>\n\n/*\n * These are the most common definitions for tty ioctl numbers.\n * Most of them do not use the recommended _IOC(), but there is\n * probably some source code out there hardcoding the number,\n * so we might as well use them for all new platforms.\n *\n * The architectures that use different values here typically\n * try to be compatible with some Unix variants for the same\n * architecture.\n */\n\n/* 0x54 is just a magic number to make these relatively unique ('T') */\n\n#define TCGETS\t\t0x5401\n#define TCSETS\t\t0x5402\n#define TCSETSW\t\t0x5403\n#define TCSETSF\t\t0x5404\n#define TCGETA\t\t0x5405\n#define TCSETA\t\t0x5406\n#define TCSETAW\t\t0x5407\n#define TCSETAF\t\t0x5408\n#define TCSBRK\t\t0x5409\n#define TCXONC\t\t0x540A\n#define TCFLSH\t\t0x540B\n#define TIOCEXCL\t0x540C\n#define TIOCNXCL\t0x540D\n#define TIOCSCTTY\t0x540E\n#define TIOCGPGRP\t0x540F\n#define TIOCSPGRP\t0x5410\n#define TIOCOUTQ\t0x5411\n#define TIOCSTI\t\t0x5412\n#define TIOCGWINSZ\t0x5413\n#define TIOCSWINSZ\t0x5414\n#define TIOCMGET\t0x5415\n#define TIOCMBIS\t0x5416\n#define TIOCMBIC\t0x5417\n#define TIOCMSET\t0x5418\n#define TIOCGSOFTCAR\t0x5419\n#define TIOCSSOFTCAR\t0x541A\n#define FIONREAD\t0x541B\n#define TIOCINQ\t\tFIONREAD\n#define TIOCLINUX\t0x541C\n#define TIOCCONS\t0x541D\n#define TIOCGSERIAL\t0x541E\n#define TIOCSSERIAL\t0x541F\n#define TIOCPKT\t\t0x5420\n#define FIONBIO\t\t0x5421\n#define TIOCNOTTY\t0x5422\n#define TIOCSETD\t0x5423\n#define TIOCGETD\t0x5424\n#define TCSBRKP\t\t0x5425\t/* Needed for POSIX tcsendbreak() */\n#define TIOCSBRK\t0x5427\t/* BSD compatibility */\n#define TIOCCBRK\t0x5428\t/* BSD compatibility */\n#define TIOCGSID\t0x5429\t/* Return the session ID of FD */\n#define TCGETS2\t\t_IOR('T', 0x2A, struct termios2)\n#define TCSETS2\t\t_IOW('T', 0x2B, struct termios2)\n#define TCSETSW2\t_IOW('T', 0x2C, struct termios2)\n#define TCSETSF2\t_IOW('T', 0x2D, struct termios2)\n#define TIOCGRS485\t0x542E\n#ifndef TIOCSRS485\n#define TIOCSRS485\t0x542F\n#endif\n#define TIOCGPTN\t_IOR('T', 0x30, unsigned int)\t/* Get Pty Number (of pty-mux device) */\n#define TIOCSPTLCK\t_IOW('T', 0x31, int)\t/* Lock/unlock Pty */\n#define TIOCGDEV\t_IOR('T', 0x32, unsigned int)\t/* Get primary device node of /dev/console */\n#define TCGETX\t\t0x5432\t/* SYS5 TCGETX compatibility */\n#define TCSETX\t\t0x5433\n#define TCSETXF\t\t0x5434\n#define TCSETXW\t\t0x5435\n#define TIOCSIG\t\t_IOW('T', 0x36, int)\t/* pty: generate signal */\n#define TIOCVHANGUP\t0x5437\n#define TIOCGPKT\t_IOR('T', 0x38, int)\t/* Get packet mode state */\n#define TIOCGPTLCK\t_IOR('T', 0x39, int)\t/* Get Pty lock state */\n#define TIOCGEXCL\t_IOR('T', 0x40, int)\t/* Get exclusive mode state */\n\n#define FIONCLEX\t0x5450\n#define FIOCLEX\t\t0x5451\n#define FIOASYNC\t0x5452\n#define TIOCSERCONFIG\t0x5453\n#define TIOCSERGWILD\t0x5454\n#define TIOCSERSWILD\t0x5455\n#define TIOCGLCKTRMIOS\t0x5456\n#define TIOCSLCKTRMIOS\t0x5457\n#define TIOCSERGSTRUCT\t0x5458\t/* For debugging only */\n#define TIOCSERGETLSR   0x5459\t/* Get line status register */\n#define TIOCSERGETMULTI 0x545A\t/* Get multiport config  */\n#define TIOCSERSETMULTI 0x545B\t/* Set multiport config */\n\n#define TIOCMIWAIT\t0x545C\t/* wait for a change on serial input line(s) */\n#define TIOCGICOUNT\t0x545D\t/* read serial port __inline__ interrupt counts */\n\n/*\n * Some arches already define FIOQSIZE due to a historical\n * conflict with a Hayes modem-specific ioctl value.\n */\n#ifndef FIOQSIZE\n# define FIOQSIZE\t0x5460\n#endif\n\n/* Used for packet mode */\n#define TIOCPKT_DATA\t\t 0\n#define TIOCPKT_FLUSHREAD\t 1\n#define TIOCPKT_FLUSHWRITE\t 2\n#define TIOCPKT_STOP\t\t 4\n#define TIOCPKT_START\t\t 8\n#define TIOCPKT_NOSTOP\t\t16\n#define TIOCPKT_DOSTOP\t\t32\n#define TIOCPKT_IOCTL\t\t64\n\n#define TIOCSER_TEMT\t0x01\t/* Transmitter physically empty */\n\n#endif\t\t\t\t/* __ASM_GENERIC_IOCTLS_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/param.h",
    "content": "#ifndef __ASM_GENERIC_PARAM_H\n#define __ASM_GENERIC_PARAM_H\n\n#ifndef HZ\n#define HZ 100\n#endif\n\n#ifndef EXEC_PAGESIZE\n#define EXEC_PAGESIZE\t4096\n#endif\n\n#ifndef NOGROUP\n#define NOGROUP\t\t(-1)\n#endif\n\n#define MAXHOSTNAMELEN\t64\t/* max length of hostname */\n\n#endif\t\t\t\t/* __ASM_GENERIC_PARAM_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/socket.h",
    "content": "#ifndef __ASM_GENERIC_SOCKET_H\n#define __ASM_GENERIC_SOCKET_H\n\n#include <asm/sockios.h>\n\n/* For setsockopt(2) */\n#define SOL_SOCKET\t1\n\n#define SO_DEBUG\t1\n#define SO_REUSEADDR\t2\n#define SO_TYPE\t\t3\n#define SO_ERROR\t4\n#define SO_DONTROUTE\t5\n#define SO_BROADCAST\t6\n#define SO_SNDBUF\t7\n#define SO_RCVBUF\t8\n#define SO_SNDBUFFORCE\t32\n#define SO_RCVBUFFORCE\t33\n#define SO_KEEPALIVE\t9\n#define SO_OOBINLINE\t10\n#define SO_NO_CHECK\t11\n#define SO_PRIORITY\t12\n#define SO_LINGER\t13\n#define SO_BSDCOMPAT\t14\n#define SO_REUSEPORT\t15\n#ifndef SO_PASSCRED\t\t/* powerpc only differs in these */\n#define SO_PASSCRED\t16\n#define SO_PEERCRED\t17\n#define SO_RCVLOWAT\t18\n#define SO_SNDLOWAT\t19\n#define SO_RCVTIMEO\t20\n#define SO_SNDTIMEO\t21\n#endif\n\n/* Security levels - as per NRL IPv6 - don't actually do anything */\n#define SO_SECURITY_AUTHENTICATION\t\t22\n#define SO_SECURITY_ENCRYPTION_TRANSPORT\t23\n#define SO_SECURITY_ENCRYPTION_NETWORK\t\t24\n\n#define SO_BINDTODEVICE\t25\n\n/* Socket filtering */\n#define SO_ATTACH_FILTER\t26\n#define SO_DETACH_FILTER\t27\n#define SO_GET_FILTER\t\tSO_ATTACH_FILTER\n\n#define SO_PEERNAME\t\t28\n#define SO_TIMESTAMP\t\t29\n#define SCM_TIMESTAMP\t\tSO_TIMESTAMP\n\n#define SO_ACCEPTCONN\t\t30\n\n#define SO_PEERSEC\t\t31\n#define SO_PASSSEC\t\t34\n#define SO_TIMESTAMPNS\t\t35\n#define SCM_TIMESTAMPNS\t\tSO_TIMESTAMPNS\n\n#define SO_MARK\t\t\t36\n\n#define SO_TIMESTAMPING\t\t37\n#define SCM_TIMESTAMPING\tSO_TIMESTAMPING\n\n#define SO_PROTOCOL\t\t38\n#define SO_DOMAIN\t\t39\n\n#define SO_RXQ_OVFL             40\n\n#define SO_WIFI_STATUS\t\t41\n#define SCM_WIFI_STATUS\tSO_WIFI_STATUS\n#define SO_PEEK_OFF\t\t42\n\n/* Instruct lower device to use last 4-bytes of skb data as FCS */\n#define SO_NOFCS\t\t43\n\n#define SO_LOCK_FILTER\t\t44\n\n#define SO_SELECT_ERR_QUEUE\t45\n\n#define SO_BUSY_POLL\t\t46\n\n#define SO_MAX_PACING_RATE\t47\n\n#define SO_BPF_EXTENSIONS\t48\n\n#define SO_INCOMING_CPU\t\t49\n\n#define SO_ATTACH_BPF\t\t50\n#define SO_DETACH_BPF\t\tSO_DETACH_FILTER\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKET_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/asm-generic/sockios.h",
    "content": "#ifndef __ASM_GENERIC_SOCKIOS_H\n#define __ASM_GENERIC_SOCKIOS_H\n\n/* Socket-level I/O control calls. */\n#define FIOSETOWN\t0x8901\n#define SIOCSPGRP\t0x8902\n#define FIOGETOWN\t0x8903\n#define SIOCGPGRP\t0x8904\n#define SIOCATMARK\t0x8905\n#define SIOCGSTAMP\t0x8906\t/* Get stamp (timeval) */\n#define SIOCGSTAMPNS\t0x8907\t/* Get stamp (timespec) */\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKIOS_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/assert.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.2 Diagnostics\t<assert.h>\n */\n\n#ifdef\t_ASSERT_H\n\n# undef\t_ASSERT_H\n# undef\tassert\n# undef __ASSERT_VOID_CAST\n\n# ifdef\t__USE_GNU\n#  undef assert_perror\n# endif\n\n#endif\t\t\t\t/* assert.h      */\n\n#define\t_ASSERT_H\t1\n#include <features.h>\n\n#if defined __cplusplus && __GNUC_PREREQ (2,95)\n# define __ASSERT_VOID_CAST static_cast<void>\n#else\n# define __ASSERT_VOID_CAST (void)\n#endif\n\n/* void assert (int expression);\n\n   If NDEBUG is defined, do nothing.\n   If not, and EXPRESSION is zero, print an error message and abort.  */\n\n#ifdef\tNDEBUG\n\n# define assert(expr)\t\t(__ASSERT_VOID_CAST (0))\n\n/* void assert_perror (int errnum);\n\n   If NDEBUG is defined, do nothing.  If not, and ERRNUM is not zero, print an\n   error message with the error text for ERRNUM and abort.\n   (This is a GNU extension.) */\n\n# ifdef\t__USE_GNU\n#  define assert_perror(errnum)\t(__ASSERT_VOID_CAST (0))\n# endif\n\n#else\t\t\t\t/* Not NDEBUG.  */\n\n__BEGIN_DECLS\n/* This prints an \"Assertion failed\" message and aborts.  */\nextern void __assert_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* Likewise, but prints the error text for ERRNUM.  */\nextern void __assert_perror_fail(int __errnum, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* The following is not at all used here but needed for standard\n   compliance.  */\nextern void __assert(const char *__assertion, const char *__file, int __line)\n__THROW __attribute__ ((__noreturn__));\n\n__END_DECLS\n# define assert(expr)\t\t\t\t\t\t\t\\\n  ((expr)\t\t\t\t\t\t\t\t\\\n   ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n   : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION))\n# ifdef\t__USE_GNU\n#  define assert_perror(errnum)\t\t\t\t\t\t\\\n  (!(errnum)\t\t\t\t\t\t\t\t\\\n   ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n   : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))\n# endif\n/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'\n   which contains the name of the function currently being defined.\n   This is broken in G++ before version 2.6.\n   C9x has a similar variable called __func__, but prefer the GCC one since\n   it demangles C++ function names.  */\n# if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)\n#   define __ASSERT_FUNCTION\t__PRETTY_FUNCTION__\n# else\n#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#   define __ASSERT_FUNCTION\t__func__\n#  else\n#   define __ASSERT_FUNCTION\t((const char *) 0)\n#  endif\n# endif\n#endif\t\t\t\t/* NDEBUG.  */\n#if defined __USE_ISOC11 && !defined __cplusplus\n# undef static_assert\n# define static_assert _Static_assert\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/byteswap-16.h",
    "content": "/* Macros to swap the order of bytes in 16-bit integer values.\n   Copyright (C) 2012-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_BYTESWAP_H\n# error \"Never use <bits/byteswap-16.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifdef __GNUC__\n# if __GNUC__ >= 2\n#  define __bswap_16(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned short int __v, __x = (unsigned short int) (x);\t      \\\n\t if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t   __v = __bswap_constant_16 (__x);\t\t\t\t      \\\n\t else\t\t\t\t\t\t\t\t      \\\n\t   __asm__ (\"rorw $8, %w0\"\t\t\t\t\t      \\\n\t\t    : \"=r\" (__v)\t\t\t\t\t      \\\n\t\t    : \"0\" (__x)\t\t\t\t\t\t      \\\n\t\t    : \"cc\");\t\t\t\t\t\t      \\\n\t __v; }))\n# else\n/* This is better than nothing.  */\n#  define __bswap_16(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned short int __x = (unsigned short int) (x);\t\t      \\\n\t __bswap_constant_16 (__x); }))\n# endif\n#else\nstatic __inline unsigned short int __bswap_16(unsigned short int __bsx)\n{\n\treturn __bswap_constant_16(__bsx);\n}\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/byteswap.h",
    "content": "/* Macros to swap the order of bytes in integer values.\n   Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H\n# error \"Never use <bits/byteswap.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifndef _BITS_BYTESWAP_H\n#define _BITS_BYTESWAP_H 1\n\n#include <features.h>\n#include <bits/types.h>\n#include <bits/wordsize.h>\n\n/* Swap bytes in 16 bit value.  */\n#define __bswap_constant_16(x) \\\n     ((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))\n\n/* Get __bswap_16.  */\n#include <bits/byteswap-16.h>\n\n/* Swap bytes in 32 bit value.  */\n#define __bswap_constant_32(x) \\\n     ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) |\t\t      \\\n      (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))\n\n#ifdef __GNUC__\n# if __GNUC_PREREQ (4, 3)\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __builtin_bswap32(__bsx);\n}\n# elif __GNUC__ >= 2\n#  if __WORDSIZE == 64 || (defined __i486__ || defined __pentium__\t      \\\n\t\t\t   || defined __pentiumpro__ || defined __pentium4__  \\\n\t\t\t   || defined __k8__ || defined __athlon__\t      \\\n\t\t\t   || defined __k6__ || defined __nocona__\t      \\\n\t\t\t   || defined __core2__ || defined __geode__\t      \\\n\t\t\t   || defined __amdfam10__)\n/* To swap the bytes in a word the i486 processors and up provide the\n   `bswap' opcode.  On i386 we have to use three instructions.  */\n#   define __bswap_32(x) \\\n      (__extension__\t\t\t\t\t\t\t      \\\n       ({ unsigned int __v, __x = (x);\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t    __v = __bswap_constant_32 (__x);\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __asm__ (\"bswap %0\" : \"=r\" (__v) : \"0\" (__x));\t\t      \\\n\t  __v; }))\n#  else\n#   define __bswap_32(x)\t\t\t\t\t\t      \\\n      (__extension__\t\t\t\t\t\t\t      \\\n       ({ unsigned int __v, __x = (x);\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t    __v = __bswap_constant_32 (__x);\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __asm__ (\"rorw $8, %w0;\"\t\t\t\t\t      \\\n\t\t     \"rorl $16, %0;\"\t\t\t\t\t      \\\n\t\t     \"rorw $8, %w0\"\t\t\t\t\t      \\\n\t\t     : \"=r\" (__v)\t\t\t\t\t      \\\n\t\t     : \"0\" (__x)\t\t\t\t\t      \\\n\t\t     : \"cc\");\t\t\t\t\t\t      \\\n\t  __v; }))\n#  endif\n# else\n#  define __bswap_32(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ unsigned int __x = (x); __bswap_constant_32 (__x); }))\n# endif\n#else\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __bswap_constant_32(__bsx);\n}\n#endif\n\n#if __GNUC_PREREQ (2, 0)\n/* Swap bytes in 64 bit value.  */\n# define __bswap_constant_64(x) \\\n     (__extension__ ((((x) & 0xff00000000000000ull) >> 56)\t\t      \\\n\t\t     | (((x) & 0x00ff000000000000ull) >> 40)\t\t      \\\n\t\t     | (((x) & 0x0000ff0000000000ull) >> 24)\t\t      \\\n\t\t     | (((x) & 0x000000ff00000000ull) >> 8)\t\t      \\\n\t\t     | (((x) & 0x00000000ff000000ull) << 8)\t\t      \\\n\t\t     | (((x) & 0x0000000000ff0000ull) << 24)\t\t      \\\n\t\t     | (((x) & 0x000000000000ff00ull) << 40)\t\t      \\\n\t\t     | (((x) & 0x00000000000000ffull) << 56)))\n\n# if __GNUC_PREREQ (4, 3)\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __builtin_bswap64(__bsx);\n}\n# elif __WORDSIZE == 64\n#  define __bswap_64(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ __uint64_t __v, __x = (x);\t\t\t\t\t      \\\n\t if (__builtin_constant_p (__x))\t\t\t\t      \\\n\t   __v = __bswap_constant_64 (__x);\t\t\t\t      \\\n\t else\t\t\t\t\t\t\t\t      \\\n\t   __asm__ (\"bswap %q0\" : \"=r\" (__v) : \"0\" (__x));\t\t      \\\n\t __v; }))\n# else\n#  define __bswap_64(x) \\\n     (__extension__                                                           \\\n      ({ union { __extension__ __uint64_t __ll;\t\t                      \\\n\t\t unsigned int __l[2]; } __w, __r;                             \\\n\t if (__builtin_constant_p (x))                                        \\\n\t   __r.__ll = __bswap_constant_64 (x);                                \\\n\t else                                                                 \\\n\t   {                                                                  \\\n\t     __w.__ll = (x);                                                  \\\n\t     __r.__l[0] = __bswap_32 (__w.__l[1]);                            \\\n\t     __r.__l[1] = __bswap_32 (__w.__l[0]);                            \\\n\t   }                                                                  \\\n\t __r.__ll; }))\n# endif\n#else\n# define __bswap_constant_64(x) \\\n     ((((x) & 0xff00000000000000ull) >> 56)\t\t\t\t      \\\n      | (((x) & 0x00ff000000000000ull) >> 40)\t\t\t\t      \\\n      | (((x) & 0x0000ff0000000000ull) >> 24)\t\t\t\t      \\\n      | (((x) & 0x000000ff00000000ull) >> 8)\t\t\t\t      \\\n      | (((x) & 0x00000000ff000000ull) << 8)\t\t\t\t      \\\n      | (((x) & 0x0000000000ff0000ull) << 24)\t\t\t\t      \\\n      | (((x) & 0x000000000000ff00ull) << 40)\t\t\t\t      \\\n      | (((x) & 0x00000000000000ffull) << 56))\n\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __bswap_constant_64(__bsx);\n}\n#endif\n\n#endif\t\t\t\t/* _BITS_BYTESWAP_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/confname.h",
    "content": "/* `sysconf', `pathconf', and `confstr' NAME values.  Generic version.\n   Copyright (C) 1993-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n# error \"Never use <bits/confname.h> directly; include <unistd.h> instead.\"\n#endif\n\n/* Values for the NAME argument to `pathconf' and `fpathconf'.  */\nenum {\n\t_PC_LINK_MAX,\n#define\t_PC_LINK_MAX\t\t\t_PC_LINK_MAX\n\t_PC_MAX_CANON,\n#define\t_PC_MAX_CANON\t\t\t_PC_MAX_CANON\n\t_PC_MAX_INPUT,\n#define\t_PC_MAX_INPUT\t\t\t_PC_MAX_INPUT\n\t_PC_NAME_MAX,\n#define\t_PC_NAME_MAX\t\t\t_PC_NAME_MAX\n\t_PC_PATH_MAX,\n#define\t_PC_PATH_MAX\t\t\t_PC_PATH_MAX\n\t_PC_PIPE_BUF,\n#define\t_PC_PIPE_BUF\t\t\t_PC_PIPE_BUF\n\t_PC_CHOWN_RESTRICTED,\n#define\t_PC_CHOWN_RESTRICTED\t\t_PC_CHOWN_RESTRICTED\n\t_PC_NO_TRUNC,\n#define\t_PC_NO_TRUNC\t\t\t_PC_NO_TRUNC\n\t_PC_VDISABLE,\n#define _PC_VDISABLE\t\t\t_PC_VDISABLE\n\t_PC_SYNC_IO,\n#define\t_PC_SYNC_IO\t\t\t_PC_SYNC_IO\n\t_PC_ASYNC_IO,\n#define\t_PC_ASYNC_IO\t\t\t_PC_ASYNC_IO\n\t_PC_PRIO_IO,\n#define\t_PC_PRIO_IO\t\t\t_PC_PRIO_IO\n\t_PC_SOCK_MAXBUF,\n#define\t_PC_SOCK_MAXBUF\t\t\t_PC_SOCK_MAXBUF\n\t_PC_FILESIZEBITS,\n#define _PC_FILESIZEBITS\t\t_PC_FILESIZEBITS\n\t_PC_REC_INCR_XFER_SIZE,\n#define _PC_REC_INCR_XFER_SIZE\t\t_PC_REC_INCR_XFER_SIZE\n\t_PC_REC_MAX_XFER_SIZE,\n#define _PC_REC_MAX_XFER_SIZE\t\t_PC_REC_MAX_XFER_SIZE\n\t_PC_REC_MIN_XFER_SIZE,\n#define _PC_REC_MIN_XFER_SIZE\t\t_PC_REC_MIN_XFER_SIZE\n\t_PC_REC_XFER_ALIGN,\n#define _PC_REC_XFER_ALIGN\t\t_PC_REC_XFER_ALIGN\n\t_PC_ALLOC_SIZE_MIN,\n#define _PC_ALLOC_SIZE_MIN\t\t_PC_ALLOC_SIZE_MIN\n\t_PC_SYMLINK_MAX,\n#define _PC_SYMLINK_MAX\t\t\t_PC_SYMLINK_MAX\n\t_PC_2_SYMLINKS\n#define _PC_2_SYMLINKS\t\t\t_PC_2_SYMLINKS\n};\n\n/* Values for the argument to `sysconf'.  */\nenum {\n\t_SC_ARG_MAX,\n#define\t_SC_ARG_MAX\t\t\t_SC_ARG_MAX\n\t_SC_CHILD_MAX,\n#define\t_SC_CHILD_MAX\t\t\t_SC_CHILD_MAX\n\t_SC_CLK_TCK,\n#define\t_SC_CLK_TCK\t\t\t_SC_CLK_TCK\n\t_SC_NGROUPS_MAX,\n#define\t_SC_NGROUPS_MAX\t\t\t_SC_NGROUPS_MAX\n\t_SC_OPEN_MAX,\n#define\t_SC_OPEN_MAX\t\t\t_SC_OPEN_MAX\n\t_SC_STREAM_MAX,\n#define\t_SC_STREAM_MAX\t\t\t_SC_STREAM_MAX\n\t_SC_TZNAME_MAX,\n#define\t_SC_TZNAME_MAX\t\t\t_SC_TZNAME_MAX\n\t_SC_JOB_CONTROL,\n#define\t_SC_JOB_CONTROL\t\t\t_SC_JOB_CONTROL\n\t_SC_SAVED_IDS,\n#define\t_SC_SAVED_IDS\t\t\t_SC_SAVED_IDS\n\t_SC_REALTIME_SIGNALS,\n#define\t_SC_REALTIME_SIGNALS\t\t_SC_REALTIME_SIGNALS\n\t_SC_PRIORITY_SCHEDULING,\n#define\t_SC_PRIORITY_SCHEDULING\t\t_SC_PRIORITY_SCHEDULING\n\t_SC_TIMERS,\n#define\t_SC_TIMERS\t\t\t_SC_TIMERS\n\t_SC_ASYNCHRONOUS_IO,\n#define\t_SC_ASYNCHRONOUS_IO\t\t_SC_ASYNCHRONOUS_IO\n\t_SC_PRIORITIZED_IO,\n#define\t_SC_PRIORITIZED_IO\t\t_SC_PRIORITIZED_IO\n\t_SC_SYNCHRONIZED_IO,\n#define\t_SC_SYNCHRONIZED_IO\t\t_SC_SYNCHRONIZED_IO\n\t_SC_FSYNC,\n#define\t_SC_FSYNC\t\t\t_SC_FSYNC\n\t_SC_MAPPED_FILES,\n#define\t_SC_MAPPED_FILES\t\t_SC_MAPPED_FILES\n\t_SC_MEMLOCK,\n#define\t_SC_MEMLOCK\t\t\t_SC_MEMLOCK\n\t_SC_MEMLOCK_RANGE,\n#define\t_SC_MEMLOCK_RANGE\t\t_SC_MEMLOCK_RANGE\n\t_SC_MEMORY_PROTECTION,\n#define\t_SC_MEMORY_PROTECTION\t\t_SC_MEMORY_PROTECTION\n\t_SC_MESSAGE_PASSING,\n#define\t_SC_MESSAGE_PASSING\t\t_SC_MESSAGE_PASSING\n\t_SC_SEMAPHORES,\n#define\t_SC_SEMAPHORES\t\t\t_SC_SEMAPHORES\n\t_SC_SHARED_MEMORY_OBJECTS,\n#define\t_SC_SHARED_MEMORY_OBJECTS\t_SC_SHARED_MEMORY_OBJECTS\n\t_SC_AIO_LISTIO_MAX,\n#define\t_SC_AIO_LISTIO_MAX\t\t_SC_AIO_LISTIO_MAX\n\t_SC_AIO_MAX,\n#define\t_SC_AIO_MAX\t\t\t_SC_AIO_MAX\n\t_SC_AIO_PRIO_DELTA_MAX,\n#define\t_SC_AIO_PRIO_DELTA_MAX\t\t_SC_AIO_PRIO_DELTA_MAX\n\t_SC_DELAYTIMER_MAX,\n#define\t_SC_DELAYTIMER_MAX\t\t_SC_DELAYTIMER_MAX\n\t_SC_MQ_OPEN_MAX,\n#define\t_SC_MQ_OPEN_MAX\t\t\t_SC_MQ_OPEN_MAX\n\t_SC_MQ_PRIO_MAX,\n#define\t_SC_MQ_PRIO_MAX\t\t\t_SC_MQ_PRIO_MAX\n\t_SC_VERSION,\n#define\t_SC_VERSION\t\t\t_SC_VERSION\n\t_SC_PAGESIZE,\n#define\t_SC_PAGESIZE\t\t\t_SC_PAGESIZE\n#define\t_SC_PAGE_SIZE\t\t\t_SC_PAGESIZE\n\t_SC_RTSIG_MAX,\n#define\t_SC_RTSIG_MAX\t\t\t_SC_RTSIG_MAX\n\t_SC_SEM_NSEMS_MAX,\n#define\t_SC_SEM_NSEMS_MAX\t\t_SC_SEM_NSEMS_MAX\n\t_SC_SEM_VALUE_MAX,\n#define\t_SC_SEM_VALUE_MAX\t\t_SC_SEM_VALUE_MAX\n\t_SC_SIGQUEUE_MAX,\n#define\t_SC_SIGQUEUE_MAX\t\t_SC_SIGQUEUE_MAX\n\t_SC_TIMER_MAX,\n#define\t_SC_TIMER_MAX\t\t\t_SC_TIMER_MAX\n\n\t/* Values for the argument to `sysconf'\n\t   corresponding to _POSIX2_* symbols.  */\n\t_SC_BC_BASE_MAX,\n#define\t_SC_BC_BASE_MAX\t\t\t_SC_BC_BASE_MAX\n\t_SC_BC_DIM_MAX,\n#define\t_SC_BC_DIM_MAX\t\t\t_SC_BC_DIM_MAX\n\t_SC_BC_SCALE_MAX,\n#define\t_SC_BC_SCALE_MAX\t\t_SC_BC_SCALE_MAX\n\t_SC_BC_STRING_MAX,\n#define\t_SC_BC_STRING_MAX\t\t_SC_BC_STRING_MAX\n\t_SC_COLL_WEIGHTS_MAX,\n#define\t_SC_COLL_WEIGHTS_MAX\t\t_SC_COLL_WEIGHTS_MAX\n\t_SC_EQUIV_CLASS_MAX,\n#define\t_SC_EQUIV_CLASS_MAX\t\t_SC_EQUIV_CLASS_MAX\n\t_SC_EXPR_NEST_MAX,\n#define\t_SC_EXPR_NEST_MAX\t\t_SC_EXPR_NEST_MAX\n\t_SC_LINE_MAX,\n#define\t_SC_LINE_MAX\t\t\t_SC_LINE_MAX\n\t_SC_RE_DUP_MAX,\n#define\t_SC_RE_DUP_MAX\t\t\t_SC_RE_DUP_MAX\n\t_SC_CHARCLASS_NAME_MAX,\n#define\t_SC_CHARCLASS_NAME_MAX\t\t_SC_CHARCLASS_NAME_MAX\n\n\t_SC_2_VERSION,\n#define\t_SC_2_VERSION\t\t\t_SC_2_VERSION\n\t_SC_2_C_BIND,\n#define\t_SC_2_C_BIND\t\t\t_SC_2_C_BIND\n\t_SC_2_C_DEV,\n#define\t_SC_2_C_DEV\t\t\t_SC_2_C_DEV\n\t_SC_2_FORT_DEV,\n#define\t_SC_2_FORT_DEV\t\t\t_SC_2_FORT_DEV\n\t_SC_2_FORT_RUN,\n#define\t_SC_2_FORT_RUN\t\t\t_SC_2_FORT_RUN\n\t_SC_2_SW_DEV,\n#define\t_SC_2_SW_DEV\t\t\t_SC_2_SW_DEV\n\t_SC_2_LOCALEDEF,\n#define\t_SC_2_LOCALEDEF\t\t\t_SC_2_LOCALEDEF\n\n\t_SC_PII,\n#define\t_SC_PII\t\t\t\t_SC_PII\n\t_SC_PII_XTI,\n#define\t_SC_PII_XTI\t\t\t_SC_PII_XTI\n\t_SC_PII_SOCKET,\n#define\t_SC_PII_SOCKET\t\t\t_SC_PII_SOCKET\n\t_SC_PII_INTERNET,\n#define\t_SC_PII_INTERNET\t\t_SC_PII_INTERNET\n\t_SC_PII_OSI,\n#define\t_SC_PII_OSI\t\t\t_SC_PII_OSI\n\t_SC_POLL,\n#define\t_SC_POLL\t\t\t_SC_POLL\n\t_SC_SELECT,\n#define\t_SC_SELECT\t\t\t_SC_SELECT\n\t_SC_UIO_MAXIOV,\n#define\t_SC_UIO_MAXIOV\t\t\t_SC_UIO_MAXIOV\n\t_SC_IOV_MAX = _SC_UIO_MAXIOV,\n#define _SC_IOV_MAX\t\t\t_SC_IOV_MAX\n\t_SC_PII_INTERNET_STREAM,\n#define\t_SC_PII_INTERNET_STREAM\t\t_SC_PII_INTERNET_STREAM\n\t_SC_PII_INTERNET_DGRAM,\n#define\t_SC_PII_INTERNET_DGRAM\t\t_SC_PII_INTERNET_DGRAM\n\t_SC_PII_OSI_COTS,\n#define\t_SC_PII_OSI_COTS\t\t_SC_PII_OSI_COTS\n\t_SC_PII_OSI_CLTS,\n#define\t_SC_PII_OSI_CLTS\t\t_SC_PII_OSI_CLTS\n\t_SC_PII_OSI_M,\n#define\t_SC_PII_OSI_M\t\t\t_SC_PII_OSI_M\n\t_SC_T_IOV_MAX,\n#define\t_SC_T_IOV_MAX\t\t\t_SC_T_IOV_MAX\n\n\t/* Values according to POSIX 1003.1c (POSIX threads).  */\n\t_SC_THREADS,\n#define\t_SC_THREADS\t\t\t_SC_THREADS\n\t_SC_THREAD_SAFE_FUNCTIONS,\n#define _SC_THREAD_SAFE_FUNCTIONS\t_SC_THREAD_SAFE_FUNCTIONS\n\t_SC_GETGR_R_SIZE_MAX,\n#define\t_SC_GETGR_R_SIZE_MAX\t\t_SC_GETGR_R_SIZE_MAX\n\t_SC_GETPW_R_SIZE_MAX,\n#define\t_SC_GETPW_R_SIZE_MAX\t\t_SC_GETPW_R_SIZE_MAX\n\t_SC_LOGIN_NAME_MAX,\n#define\t_SC_LOGIN_NAME_MAX\t\t_SC_LOGIN_NAME_MAX\n\t_SC_TTY_NAME_MAX,\n#define\t_SC_TTY_NAME_MAX\t\t_SC_TTY_NAME_MAX\n\t_SC_THREAD_DESTRUCTOR_ITERATIONS,\n#define\t_SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS\n\t_SC_THREAD_KEYS_MAX,\n#define\t_SC_THREAD_KEYS_MAX\t\t_SC_THREAD_KEYS_MAX\n\t_SC_THREAD_STACK_MIN,\n#define\t_SC_THREAD_STACK_MIN\t\t_SC_THREAD_STACK_MIN\n\t_SC_THREAD_THREADS_MAX,\n#define\t_SC_THREAD_THREADS_MAX\t\t_SC_THREAD_THREADS_MAX\n\t_SC_THREAD_ATTR_STACKADDR,\n#define\t_SC_THREAD_ATTR_STACKADDR\t_SC_THREAD_ATTR_STACKADDR\n\t_SC_THREAD_ATTR_STACKSIZE,\n#define\t_SC_THREAD_ATTR_STACKSIZE\t_SC_THREAD_ATTR_STACKSIZE\n\t_SC_THREAD_PRIORITY_SCHEDULING,\n#define\t_SC_THREAD_PRIORITY_SCHEDULING\t_SC_THREAD_PRIORITY_SCHEDULING\n\t_SC_THREAD_PRIO_INHERIT,\n#define\t_SC_THREAD_PRIO_INHERIT\t\t_SC_THREAD_PRIO_INHERIT\n\t_SC_THREAD_PRIO_PROTECT,\n#define\t_SC_THREAD_PRIO_PROTECT\t\t_SC_THREAD_PRIO_PROTECT\n\t_SC_THREAD_PROCESS_SHARED,\n#define\t_SC_THREAD_PROCESS_SHARED\t_SC_THREAD_PROCESS_SHARED\n\n\t_SC_NPROCESSORS_CONF,\n#define _SC_NPROCESSORS_CONF\t\t_SC_NPROCESSORS_CONF\n\t_SC_NPROCESSORS_ONLN,\n#define _SC_NPROCESSORS_ONLN\t\t_SC_NPROCESSORS_ONLN\n\t_SC_PHYS_PAGES,\n#define _SC_PHYS_PAGES\t\t\t_SC_PHYS_PAGES\n\t_SC_AVPHYS_PAGES,\n#define _SC_AVPHYS_PAGES\t\t_SC_AVPHYS_PAGES\n\t_SC_ATEXIT_MAX,\n#define _SC_ATEXIT_MAX\t\t\t_SC_ATEXIT_MAX\n\t_SC_PASS_MAX,\n#define _SC_PASS_MAX\t\t\t_SC_PASS_MAX\n\n\t_SC_XOPEN_VERSION,\n#define _SC_XOPEN_VERSION\t\t_SC_XOPEN_VERSION\n\t_SC_XOPEN_XCU_VERSION,\n#define _SC_XOPEN_XCU_VERSION\t\t_SC_XOPEN_XCU_VERSION\n\t_SC_XOPEN_UNIX,\n#define _SC_XOPEN_UNIX\t\t\t_SC_XOPEN_UNIX\n\t_SC_XOPEN_CRYPT,\n#define _SC_XOPEN_CRYPT\t\t\t_SC_XOPEN_CRYPT\n\t_SC_XOPEN_ENH_I18N,\n#define _SC_XOPEN_ENH_I18N\t\t_SC_XOPEN_ENH_I18N\n\t_SC_XOPEN_SHM,\n#define _SC_XOPEN_SHM\t\t\t_SC_XOPEN_SHM\n\n\t_SC_2_CHAR_TERM,\n#define _SC_2_CHAR_TERM\t\t\t_SC_2_CHAR_TERM\n\t_SC_2_C_VERSION,\n#define _SC_2_C_VERSION\t\t\t_SC_2_C_VERSION\n\t_SC_2_UPE,\n#define _SC_2_UPE\t\t\t_SC_2_UPE\n\n\t_SC_XOPEN_XPG2,\n#define _SC_XOPEN_XPG2\t\t\t_SC_XOPEN_XPG2\n\t_SC_XOPEN_XPG3,\n#define _SC_XOPEN_XPG3\t\t\t_SC_XOPEN_XPG3\n\t_SC_XOPEN_XPG4,\n#define _SC_XOPEN_XPG4\t\t\t_SC_XOPEN_XPG4\n\n\t_SC_CHAR_BIT,\n#define\t_SC_CHAR_BIT\t\t\t_SC_CHAR_BIT\n\t_SC_CHAR_MAX,\n#define\t_SC_CHAR_MAX\t\t\t_SC_CHAR_MAX\n\t_SC_CHAR_MIN,\n#define\t_SC_CHAR_MIN\t\t\t_SC_CHAR_MIN\n\t_SC_INT_MAX,\n#define\t_SC_INT_MAX\t\t\t_SC_INT_MAX\n\t_SC_INT_MIN,\n#define\t_SC_INT_MIN\t\t\t_SC_INT_MIN\n\t_SC_LONG_BIT,\n#define\t_SC_LONG_BIT\t\t\t_SC_LONG_BIT\n\t_SC_WORD_BIT,\n#define\t_SC_WORD_BIT\t\t\t_SC_WORD_BIT\n\t_SC_MB_LEN_MAX,\n#define\t_SC_MB_LEN_MAX\t\t\t_SC_MB_LEN_MAX\n\t_SC_NZERO,\n#define\t_SC_NZERO\t\t\t_SC_NZERO\n\t_SC_SSIZE_MAX,\n#define\t_SC_SSIZE_MAX\t\t\t_SC_SSIZE_MAX\n\t_SC_SCHAR_MAX,\n#define\t_SC_SCHAR_MAX\t\t\t_SC_SCHAR_MAX\n\t_SC_SCHAR_MIN,\n#define\t_SC_SCHAR_MIN\t\t\t_SC_SCHAR_MIN\n\t_SC_SHRT_MAX,\n#define\t_SC_SHRT_MAX\t\t\t_SC_SHRT_MAX\n\t_SC_SHRT_MIN,\n#define\t_SC_SHRT_MIN\t\t\t_SC_SHRT_MIN\n\t_SC_UCHAR_MAX,\n#define\t_SC_UCHAR_MAX\t\t\t_SC_UCHAR_MAX\n\t_SC_UINT_MAX,\n#define\t_SC_UINT_MAX\t\t\t_SC_UINT_MAX\n\t_SC_ULONG_MAX,\n#define\t_SC_ULONG_MAX\t\t\t_SC_ULONG_MAX\n\t_SC_USHRT_MAX,\n#define\t_SC_USHRT_MAX\t\t\t_SC_USHRT_MAX\n\n\t_SC_NL_ARGMAX,\n#define\t_SC_NL_ARGMAX\t\t\t_SC_NL_ARGMAX\n\t_SC_NL_LANGMAX,\n#define\t_SC_NL_LANGMAX\t\t\t_SC_NL_LANGMAX\n\t_SC_NL_MSGMAX,\n#define\t_SC_NL_MSGMAX\t\t\t_SC_NL_MSGMAX\n\t_SC_NL_NMAX,\n#define\t_SC_NL_NMAX\t\t\t_SC_NL_NMAX\n\t_SC_NL_SETMAX,\n#define\t_SC_NL_SETMAX\t\t\t_SC_NL_SETMAX\n\t_SC_NL_TEXTMAX,\n#define\t_SC_NL_TEXTMAX\t\t\t_SC_NL_TEXTMAX\n\n\t_SC_XBS5_ILP32_OFF32,\n#define _SC_XBS5_ILP32_OFF32\t\t_SC_XBS5_ILP32_OFF32\n\t_SC_XBS5_ILP32_OFFBIG,\n#define _SC_XBS5_ILP32_OFFBIG\t\t_SC_XBS5_ILP32_OFFBIG\n\t_SC_XBS5_LP64_OFF64,\n#define _SC_XBS5_LP64_OFF64\t\t_SC_XBS5_LP64_OFF64\n\t_SC_XBS5_LPBIG_OFFBIG,\n#define _SC_XBS5_LPBIG_OFFBIG\t\t_SC_XBS5_LPBIG_OFFBIG\n\n\t_SC_XOPEN_LEGACY,\n#define _SC_XOPEN_LEGACY\t\t_SC_XOPEN_LEGACY\n\t_SC_XOPEN_REALTIME,\n#define _SC_XOPEN_REALTIME\t\t_SC_XOPEN_REALTIME\n\t_SC_XOPEN_REALTIME_THREADS,\n#define _SC_XOPEN_REALTIME_THREADS\t_SC_XOPEN_REALTIME_THREADS\n\n\t_SC_ADVISORY_INFO,\n#define _SC_ADVISORY_INFO\t\t_SC_ADVISORY_INFO\n\t_SC_BARRIERS,\n#define _SC_BARRIERS\t\t\t_SC_BARRIERS\n\t_SC_BASE,\n#define _SC_BASE\t\t\t_SC_BASE\n\t_SC_C_LANG_SUPPORT,\n#define _SC_C_LANG_SUPPORT\t\t_SC_C_LANG_SUPPORT\n\t_SC_C_LANG_SUPPORT_R,\n#define _SC_C_LANG_SUPPORT_R\t\t_SC_C_LANG_SUPPORT_R\n\t_SC_CLOCK_SELECTION,\n#define _SC_CLOCK_SELECTION\t\t_SC_CLOCK_SELECTION\n\t_SC_CPUTIME,\n#define _SC_CPUTIME\t\t\t_SC_CPUTIME\n\t_SC_THREAD_CPUTIME,\n#define _SC_THREAD_CPUTIME\t\t_SC_THREAD_CPUTIME\n\t_SC_DEVICE_IO,\n#define _SC_DEVICE_IO\t\t\t_SC_DEVICE_IO\n\t_SC_DEVICE_SPECIFIC,\n#define _SC_DEVICE_SPECIFIC\t\t_SC_DEVICE_SPECIFIC\n\t_SC_DEVICE_SPECIFIC_R,\n#define _SC_DEVICE_SPECIFIC_R\t\t_SC_DEVICE_SPECIFIC_R\n\t_SC_FD_MGMT,\n#define _SC_FD_MGMT\t\t\t_SC_FD_MGMT\n\t_SC_FIFO,\n#define _SC_FIFO\t\t\t_SC_FIFO\n\t_SC_PIPE,\n#define _SC_PIPE\t\t\t_SC_PIPE\n\t_SC_FILE_ATTRIBUTES,\n#define _SC_FILE_ATTRIBUTES\t\t_SC_FILE_ATTRIBUTES\n\t_SC_FILE_LOCKING,\n#define _SC_FILE_LOCKING\t\t_SC_FILE_LOCKING\n\t_SC_FILE_SYSTEM,\n#define _SC_FILE_SYSTEM\t\t\t_SC_FILE_SYSTEM\n\t_SC_MONOTONIC_CLOCK,\n#define _SC_MONOTONIC_CLOCK\t\t_SC_MONOTONIC_CLOCK\n\t_SC_MULTI_PROCESS,\n#define _SC_MULTI_PROCESS\t\t_SC_MULTI_PROCESS\n\t_SC_SINGLE_PROCESS,\n#define _SC_SINGLE_PROCESS\t\t_SC_SINGLE_PROCESS\n\t_SC_NETWORKING,\n#define _SC_NETWORKING\t\t\t_SC_NETWORKING\n\t_SC_READER_WRITER_LOCKS,\n#define _SC_READER_WRITER_LOCKS\t\t_SC_READER_WRITER_LOCKS\n\t_SC_SPIN_LOCKS,\n#define _SC_SPIN_LOCKS\t\t\t_SC_SPIN_LOCKS\n\t_SC_REGEXP,\n#define _SC_REGEXP\t\t\t_SC_REGEXP\n\t_SC_REGEX_VERSION,\n#define _SC_REGEX_VERSION\t\t_SC_REGEX_VERSION\n\t_SC_SHELL,\n#define _SC_SHELL\t\t\t_SC_SHELL\n\t_SC_SIGNALS,\n#define _SC_SIGNALS\t\t\t_SC_SIGNALS\n\t_SC_SPAWN,\n#define _SC_SPAWN\t\t\t_SC_SPAWN\n\t_SC_SPORADIC_SERVER,\n#define _SC_SPORADIC_SERVER\t\t_SC_SPORADIC_SERVER\n\t_SC_THREAD_SPORADIC_SERVER,\n#define _SC_THREAD_SPORADIC_SERVER\t_SC_THREAD_SPORADIC_SERVER\n\t_SC_SYSTEM_DATABASE,\n#define _SC_SYSTEM_DATABASE\t\t_SC_SYSTEM_DATABASE\n\t_SC_SYSTEM_DATABASE_R,\n#define _SC_SYSTEM_DATABASE_R\t\t_SC_SYSTEM_DATABASE_R\n\t_SC_TIMEOUTS,\n#define _SC_TIMEOUTS\t\t\t_SC_TIMEOUTS\n\t_SC_TYPED_MEMORY_OBJECTS,\n#define _SC_TYPED_MEMORY_OBJECTS\t_SC_TYPED_MEMORY_OBJECTS\n\t_SC_USER_GROUPS,\n#define _SC_USER_GROUPS\t\t\t_SC_USER_GROUPS\n\t_SC_USER_GROUPS_R,\n#define _SC_USER_GROUPS_R\t\t_SC_USER_GROUPS_R\n\t_SC_2_PBS,\n#define _SC_2_PBS\t\t\t_SC_2_PBS\n\t_SC_2_PBS_ACCOUNTING,\n#define _SC_2_PBS_ACCOUNTING\t\t_SC_2_PBS_ACCOUNTING\n\t_SC_2_PBS_LOCATE,\n#define _SC_2_PBS_LOCATE\t\t_SC_2_PBS_LOCATE\n\t_SC_2_PBS_MESSAGE,\n#define _SC_2_PBS_MESSAGE\t\t_SC_2_PBS_MESSAGE\n\t_SC_2_PBS_TRACK,\n#define _SC_2_PBS_TRACK\t\t\t_SC_2_PBS_TRACK\n\t_SC_SYMLOOP_MAX,\n#define _SC_SYMLOOP_MAX\t\t\t_SC_SYMLOOP_MAX\n\t_SC_STREAMS,\n#define _SC_STREAMS\t\t\t_SC_STREAMS\n\t_SC_2_PBS_CHECKPOINT,\n#define _SC_2_PBS_CHECKPOINT\t\t_SC_2_PBS_CHECKPOINT\n\n\t_SC_V6_ILP32_OFF32,\n#define _SC_V6_ILP32_OFF32\t\t_SC_V6_ILP32_OFF32\n\t_SC_V6_ILP32_OFFBIG,\n#define _SC_V6_ILP32_OFFBIG\t\t_SC_V6_ILP32_OFFBIG\n\t_SC_V6_LP64_OFF64,\n#define _SC_V6_LP64_OFF64\t\t_SC_V6_LP64_OFF64\n\t_SC_V6_LPBIG_OFFBIG,\n#define _SC_V6_LPBIG_OFFBIG\t\t_SC_V6_LPBIG_OFFBIG\n\n\t_SC_HOST_NAME_MAX,\n#define _SC_HOST_NAME_MAX\t\t_SC_HOST_NAME_MAX\n\t_SC_TRACE,\n#define _SC_TRACE\t\t\t_SC_TRACE\n\t_SC_TRACE_EVENT_FILTER,\n#define _SC_TRACE_EVENT_FILTER\t\t_SC_TRACE_EVENT_FILTER\n\t_SC_TRACE_INHERIT,\n#define _SC_TRACE_INHERIT\t\t_SC_TRACE_INHERIT\n\t_SC_TRACE_LOG,\n#define _SC_TRACE_LOG\t\t\t_SC_TRACE_LOG\n\n\t_SC_LEVEL1_ICACHE_SIZE,\n#define _SC_LEVEL1_ICACHE_SIZE\t\t_SC_LEVEL1_ICACHE_SIZE\n\t_SC_LEVEL1_ICACHE_ASSOC,\n#define _SC_LEVEL1_ICACHE_ASSOC\t\t_SC_LEVEL1_ICACHE_ASSOC\n\t_SC_LEVEL1_ICACHE_LINESIZE,\n#define _SC_LEVEL1_ICACHE_LINESIZE\t_SC_LEVEL1_ICACHE_LINESIZE\n\t_SC_LEVEL1_DCACHE_SIZE,\n#define _SC_LEVEL1_DCACHE_SIZE\t\t_SC_LEVEL1_DCACHE_SIZE\n\t_SC_LEVEL1_DCACHE_ASSOC,\n#define _SC_LEVEL1_DCACHE_ASSOC\t\t_SC_LEVEL1_DCACHE_ASSOC\n\t_SC_LEVEL1_DCACHE_LINESIZE,\n#define _SC_LEVEL1_DCACHE_LINESIZE\t_SC_LEVEL1_DCACHE_LINESIZE\n\t_SC_LEVEL2_CACHE_SIZE,\n#define _SC_LEVEL2_CACHE_SIZE\t\t_SC_LEVEL2_CACHE_SIZE\n\t_SC_LEVEL2_CACHE_ASSOC,\n#define _SC_LEVEL2_CACHE_ASSOC\t\t_SC_LEVEL2_CACHE_ASSOC\n\t_SC_LEVEL2_CACHE_LINESIZE,\n#define _SC_LEVEL2_CACHE_LINESIZE\t_SC_LEVEL2_CACHE_LINESIZE\n\t_SC_LEVEL3_CACHE_SIZE,\n#define _SC_LEVEL3_CACHE_SIZE\t\t_SC_LEVEL3_CACHE_SIZE\n\t_SC_LEVEL3_CACHE_ASSOC,\n#define _SC_LEVEL3_CACHE_ASSOC\t\t_SC_LEVEL3_CACHE_ASSOC\n\t_SC_LEVEL3_CACHE_LINESIZE,\n#define _SC_LEVEL3_CACHE_LINESIZE\t_SC_LEVEL3_CACHE_LINESIZE\n\t_SC_LEVEL4_CACHE_SIZE,\n#define _SC_LEVEL4_CACHE_SIZE\t\t_SC_LEVEL4_CACHE_SIZE\n\t_SC_LEVEL4_CACHE_ASSOC,\n#define _SC_LEVEL4_CACHE_ASSOC\t\t_SC_LEVEL4_CACHE_ASSOC\n\t_SC_LEVEL4_CACHE_LINESIZE,\n#define _SC_LEVEL4_CACHE_LINESIZE\t_SC_LEVEL4_CACHE_LINESIZE\n\t/* Leave room here, maybe we need a few more cache levels some day.  */\n\n\t_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,\n#define _SC_IPV6\t\t\t_SC_IPV6\n\t_SC_RAW_SOCKETS,\n#define _SC_RAW_SOCKETS\t\t\t_SC_RAW_SOCKETS\n\n\t_SC_V7_ILP32_OFF32,\n#define _SC_V7_ILP32_OFF32\t\t_SC_V7_ILP32_OFF32\n\t_SC_V7_ILP32_OFFBIG,\n#define _SC_V7_ILP32_OFFBIG\t\t_SC_V7_ILP32_OFFBIG\n\t_SC_V7_LP64_OFF64,\n#define _SC_V7_LP64_OFF64\t\t_SC_V7_LP64_OFF64\n\t_SC_V7_LPBIG_OFFBIG,\n#define _SC_V7_LPBIG_OFFBIG\t\t_SC_V7_LPBIG_OFFBIG\n\n\t_SC_SS_REPL_MAX,\n#define _SC_SS_REPL_MAX\t\t\t_SC_SS_REPL_MAX\n\n\t_SC_TRACE_EVENT_NAME_MAX,\n#define _SC_TRACE_EVENT_NAME_MAX\t_SC_TRACE_EVENT_NAME_MAX\n\t_SC_TRACE_NAME_MAX,\n#define _SC_TRACE_NAME_MAX\t\t_SC_TRACE_NAME_MAX\n\t_SC_TRACE_SYS_MAX,\n#define _SC_TRACE_SYS_MAX\t\t_SC_TRACE_SYS_MAX\n\t_SC_TRACE_USER_EVENT_MAX,\n#define _SC_TRACE_USER_EVENT_MAX\t_SC_TRACE_USER_EVENT_MAX\n\n\t_SC_XOPEN_STREAMS,\n#define _SC_XOPEN_STREAMS\t\t_SC_XOPEN_STREAMS\n\n\t_SC_THREAD_ROBUST_PRIO_INHERIT,\n#define _SC_THREAD_ROBUST_PRIO_INHERIT\t_SC_THREAD_ROBUST_PRIO_INHERIT\n\t_SC_THREAD_ROBUST_PRIO_PROTECT\n#define _SC_THREAD_ROBUST_PRIO_PROTECT\t_SC_THREAD_ROBUST_PRIO_PROTECT\n};\n\n/* Values for the NAME argument to `confstr'.  */\nenum {\n\t_CS_PATH,\t\t/* The default search path.  */\n#define _CS_PATH\t\t_CS_PATH\n\n\t_CS_V6_WIDTH_RESTRICTED_ENVS,\n#define _CS_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n\n\t_CS_GNU_LIBC_VERSION,\n#define _CS_GNU_LIBC_VERSION\t_CS_GNU_LIBC_VERSION\n\t_CS_GNU_LIBPTHREAD_VERSION,\n#define _CS_GNU_LIBPTHREAD_VERSION\t_CS_GNU_LIBPTHREAD_VERSION\n\n\t_CS_V5_WIDTH_RESTRICTED_ENVS,\n#define _CS_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n\n\t_CS_V7_WIDTH_RESTRICTED_ENVS,\n#define _CS_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n\n\t_CS_LFS_CFLAGS = 1000,\n#define _CS_LFS_CFLAGS\t_CS_LFS_CFLAGS\n\t_CS_LFS_LDFLAGS,\n#define _CS_LFS_LDFLAGS\t_CS_LFS_LDFLAGS\n\t_CS_LFS_LIBS,\n#define _CS_LFS_LIBS\t\t_CS_LFS_LIBS\n\t_CS_LFS_LINTFLAGS,\n#define _CS_LFS_LINTFLAGS\t_CS_LFS_LINTFLAGS\n\t_CS_LFS64_CFLAGS,\n#define _CS_LFS64_CFLAGS\t_CS_LFS64_CFLAGS\n\t_CS_LFS64_LDFLAGS,\n#define _CS_LFS64_LDFLAGS\t_CS_LFS64_LDFLAGS\n\t_CS_LFS64_LIBS,\n#define _CS_LFS64_LIBS\t_CS_LFS64_LIBS\n\t_CS_LFS64_LINTFLAGS,\n#define _CS_LFS64_LINTFLAGS\t_CS_LFS64_LINTFLAGS\n\n\t_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,\n#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS\n\t_CS_XBS5_ILP32_OFF32_LDFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS\n\t_CS_XBS5_ILP32_OFF32_LIBS,\n#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS\n\t_CS_XBS5_ILP32_OFF32_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_CFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LDFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LIBS,\n#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS\n\t_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS\n\t_CS_XBS5_LP64_OFF64_CFLAGS,\n#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS\n\t_CS_XBS5_LP64_OFF64_LDFLAGS,\n#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS\n\t_CS_XBS5_LP64_OFF64_LIBS,\n#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS\n\t_CS_XBS5_LP64_OFF64_LINTFLAGS,\n#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_CFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LIBS,\n#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS\n\t_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V6_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS\n\t_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LIBS,\n#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS\n\t_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V7_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS\n\t_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LIBS,\n#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS\n\t_CS_POSIX_V7_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_V6_ENV,\n#define _CS_V6_ENV\t\t\t_CS_V6_ENV\n\t_CS_V7_ENV\n#define _CS_V7_ENV\t\t\t_CS_V7_ENV\n};\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/dirent.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DIRENT_H\n# error \"Never use <bits/dirent.h> directly; include <dirent.h> instead.\"\n#endif\n\nstruct dirent {\n#ifndef __USE_FILE_OFFSET64\n\t__ino_t d_ino;\n\t__off_t d_off;\n#else\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n#endif\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct dirent64 {\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n#endif\n\n#define d_fileno\td_ino\t/* Backwards compatibility.  */\n\n#undef  _DIRENT_HAVE_D_NAMLEN\n#define _DIRENT_HAVE_D_RECLEN\n#define _DIRENT_HAVE_D_OFF\n#define _DIRENT_HAVE_D_TYPE\n\n#if defined __OFF_T_MATCHES_OFF64_T && defined __INO_T_MATCHES_INO64_T\n/* Inform libc code that these two types are effectively identical.  */\n# define _DIRENT_MATCHES_DIRENT64\t1\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/dlfcn.h",
    "content": "/* System dependent definitions for run-time dynamic loading.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DLFCN_H\n# error \"Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead.\"\n#endif\n\n/* The MODE argument to `dlopen' contains one of the following: */\n#define RTLD_LAZY\t0x00001\t/* Lazy function call binding.  */\n#define RTLD_NOW\t0x00002\t/* Immediate function call binding.  */\n#define\tRTLD_BINDING_MASK   0x3\t/* Mask of binding time value.  */\n#define RTLD_NOLOAD\t0x00004\t/* Do not load the object.  */\n#define RTLD_DEEPBIND\t0x00008\t/* Use deep binding.  */\n\n/* If the following bit is set in the MODE argument to `dlopen',\n   the symbols of the loaded object and its dependencies are made\n   visible as if the object were linked directly into the program.  */\n#define RTLD_GLOBAL\t0x00100\n\n/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.\n   The implementation does this by default and so we can define the\n   value to zero.  */\n#define RTLD_LOCAL\t0\n\n/* Do not delete object when closed.  */\n#define RTLD_NODELETE\t0x01000\n\n#ifdef __USE_GNU\n/* To support profiling of shared objects it is a good idea to call\n   the function found using `dlsym' using the following macro since\n   these calls do not use the PLT.  But this would mean the dynamic\n   loader has no chance to find out when the function is called.  The\n   macro applies the necessary magic so that profiling is possible.\n   Rewrite\n\tfoo = (*fctp) (arg1, arg2);\n   into\n        foo = DL_CALL_FCT (fctp, (arg1, arg2));\n*/\n# define DL_CALL_FCT(fctp, args) \\\n  (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)\n\n__BEGIN_DECLS\n/* This function calls the profiling functions.  */\nextern void _dl_mcount_wrapper_check(void *__selfpc) __THROW;\n\n__END_DECLS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/endian.h",
    "content": "/* i386/x86_64 are little-endian.  */\n\n#ifndef _ENDIAN_H\n# error \"Never use <bits/endian.h> directly; include <endian.h> instead.\"\n#endif\n\n#define __BYTE_ORDER __LITTLE_ENDIAN\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/environments.h",
    "content": "/* Copyright (C) 1999-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n# error \"Never include this file directly.  Use <unistd.h> instead\"\n#endif\n\n#include <bits/wordsize.h>\n\n/* This header should define the following symbols under the described\n   situations.  A value `1' means that the model is always supported,\n   `-1' means it is never supported.  Undefined means it cannot be\n   statically decided.\n\n   _POSIX_V7_ILP32_OFF32   32bit int, long, pointers, and off_t type\n   _POSIX_V7_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type\n\n   _POSIX_V7_LP64_OFF32\t   64bit long and pointers and 32bit off_t type\n   _POSIX_V7_LPBIG_OFFBIG  64bit long and pointers and large off_t type\n\n   The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,\n   _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,\n   _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were\n   used in previous versions of the Unix standard and are available\n   only for compatibility.\n*/\n\n#if __WORDSIZE == 64\n\n/* Environments with 32-bit wide pointers are optionally provided.\n   Therefore following macros aren't defined:\n   # undef _POSIX_V7_ILP32_OFF32\n   # undef _POSIX_V7_ILP32_OFFBIG\n   # undef _POSIX_V6_ILP32_OFF32\n   # undef _POSIX_V6_ILP32_OFFBIG\n   # undef _XBS5_ILP32_OFF32\n   # undef _XBS5_ILP32_OFFBIG\n   and users need to check at runtime.  */\n\n/* We also have no use (for now) for an environment with bigger pointers\n   and offsets.  */\n# define _POSIX_V7_LPBIG_OFFBIG\t-1\n# define _POSIX_V6_LPBIG_OFFBIG\t-1\n# define _XBS5_LPBIG_OFFBIG\t-1\n\n/* By default we have 64-bit wide `long int', pointers and `off_t'.  */\n# define _POSIX_V7_LP64_OFF64\t1\n# define _POSIX_V6_LP64_OFF64\t1\n# define _XBS5_LP64_OFF64\t1\n\n#else\t\t\t\t/* __WORDSIZE == 32 */\n\n/* We have 32-bit wide `int', `long int' and pointers and all platforms\n   support LFS.  -mx32 has 64-bit wide `off_t'.  */\n# define _POSIX_V7_ILP32_OFFBIG\t1\n# define _POSIX_V6_ILP32_OFFBIG 1\n# define _XBS5_ILP32_OFFBIG\t1\n\n# ifndef __x86_64__\n/* -m32 has 32-bit wide `off_t'.  */\n#  define _POSIX_V7_ILP32_OFF32\t1\n#  define _POSIX_V6_ILP32_OFF32\t1\n#  define _XBS5_ILP32_OFF32\t1\n# endif\n\n/* We optionally provide an environment with the above size but an 64-bit\n   side `off_t'.  Therefore we don't define _POSIX_V7_ILP32_OFFBIG.  */\n\n/* Environments with 64-bit wide pointers can be provided,\n   so these macros aren't defined:\n   # undef _POSIX_V7_LP64_OFF64\n   # undef _POSIX_V7_LPBIG_OFFBIG\n   # undef _POSIX_V6_LP64_OFF64\n   # undef _POSIX_V6_LPBIG_OFFBIG\n   # undef _XBS5_LP64_OFF64\n   # undef _XBS5_LPBIG_OFFBIG\n   and sysconf tests for it at runtime.  */\n\n#endif\t\t\t\t/* __WORDSIZE == 32 */\n\n#define __ILP32_OFF32_CFLAGS\t\"-m32\"\n#define __ILP32_OFF32_LDFLAGS\t\"-m32\"\n#if defined __x86_64__ && defined __ILP32__\n# define __ILP32_OFFBIG_CFLAGS\t\"-mx32\"\n# define __ILP32_OFFBIG_LDFLAGS\t\"-mx32\"\n#else\n# define __ILP32_OFFBIG_CFLAGS\t\"-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64\"\n# define __ILP32_OFFBIG_LDFLAGS\t\"-m32\"\n#endif\n#define __LP64_OFF64_CFLAGS\t\"-m64\"\n#define __LP64_OFF64_LDFLAGS\t\"-m64\"\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/errno.h",
    "content": "/* Error constants.  Linux specific version.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifdef _ERRNO_H\n\n# undef EDOM\n# undef EILSEQ\n# undef ERANGE\n# include <linux/errno.h>\n\n/* Linux has no ENOTSUP error code.  */\n# define ENOTSUP EOPNOTSUPP\n\n/* Older Linux versions also had no ECANCELED error code.  */\n# ifndef ECANCELED\n#  define ECANCELED\t125\n# endif\n\n/* Support for error codes to support robust mutexes was added later, too.  */\n# ifndef EOWNERDEAD\n#  define EOWNERDEAD\t\t130\n#  define ENOTRECOVERABLE\t131\n# endif\n\n# ifndef ERFKILL\n#  define ERFKILL\t\t132\n# endif\n\n# ifndef EHWPOISON\n#  define EHWPOISON\t\t133\n# endif\n\n# ifndef __ASSEMBLER__\n/* Function to get address of global `errno' variable.  */\nextern int *__errno_location(void)\n__THROW __attribute__ ((__const__));\n\n#  if !defined _LIBC || defined _LIBC_REENTRANT\n/* When using threads, errno is a per-thread value.  */\n#   define errno (*__errno_location ())\n#  endif\n# endif\t\t\t\t/* !__ASSEMBLER__ */\n#endif\t\t\t\t/* _ERRNO_H */\n\n#if !defined _ERRNO_H && defined __need_Emath\n/* This is ugly but the kernel header is not clean enough.  We must\n   define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is\n   defined.  */\n# define EDOM\t33\t\t/* Math argument out of domain of function.  */\n# define EILSEQ\t84\t\t/* Illegal byte sequence.  */\n# define ERANGE\t34\t\t/* Math result not representable.  */\n#endif\t\t\t\t/* !_ERRNO_H && __need_Emath */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/fcntl-linux.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux.\n   Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FCNTL_H\n# error \"Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead.\"\n#endif\n\n/* This file contains shared definitions between Linux architectures\n   and is included by <bits/fcntl.h> to declare them.  The various\n   #ifndef cases allow the architecture specific file to define those\n   values with different values.\n\n   A minimal <bits/fcntl.h> contains just:\n\n   struct flock {...}\n   #ifdef __USE_LARGEFILE64\n   struct flock64 {...}\n   #endif\n   #include <bits/fcntl-linux.h>\n*/\n\n#ifdef __USE_GNU\n# include <bits/uio.h>\n#endif\n\n/* open/fcntl.  */\n#define O_ACCMODE\t   0003\n#define O_RDONLY\t     00\n#define O_WRONLY\t     01\n#define O_RDWR\t\t     02\n#ifndef O_CREAT\n# define O_CREAT\t   0100\t/* Not fcntl.  */\n#endif\n#ifndef O_EXCL\n# define O_EXCL\t\t   0200\t/* Not fcntl.  */\n#endif\n#ifndef O_NOCTTY\n# define O_NOCTTY\t   0400\t/* Not fcntl.  */\n#endif\n#ifndef O_TRUNC\n# define O_TRUNC\t  01000\t/* Not fcntl.  */\n#endif\n#ifndef O_APPEND\n# define O_APPEND\t  02000\n#endif\n#ifndef O_NONBLOCK\n# define O_NONBLOCK\t  04000\n#endif\n#ifndef O_NDELAY\n# define O_NDELAY\tO_NONBLOCK\n#endif\n#ifndef O_SYNC\n# define O_SYNC\t       04010000\n#endif\n#define O_FSYNC\t\tO_SYNC\n#ifndef O_ASYNC\n# define O_ASYNC\t 020000\n#endif\n#ifndef __O_LARGEFILE\n# define __O_LARGEFILE\t0100000\n#endif\n\n#ifndef __O_DIRECTORY\n# define __O_DIRECTORY  0200000\n#endif\n#ifndef __O_NOFOLLOW\n# define __O_NOFOLLOW\t0400000\n#endif\n#ifndef __O_CLOEXEC\n# define __O_CLOEXEC   02000000\n#endif\n#ifndef __O_DIRECT\n# define __O_DIRECT\t 040000\n#endif\n#ifndef __O_NOATIME\n# define __O_NOATIME   01000000\n#endif\n#ifndef __O_PATH\n# define __O_PATH     010000000\n#endif\n#ifndef __O_DSYNC\n# define __O_DSYNC\t 010000\n#endif\n#ifndef __O_TMPFILE\n# define __O_TMPFILE   (020000000 | __O_DIRECTORY)\n#endif\n\n#ifndef F_GETLK\n# ifndef __USE_FILE_OFFSET64\n#  define F_GETLK\t5\t/* Get record locking info.  */\n#  define F_SETLK\t6\t/* Set record locking info (non-blocking).  */\n#  define F_SETLKW\t7\t/* Set record locking info (blocking).  */\n# else\n#  define F_GETLK\tF_GETLK64\t/* Get record locking info.  */\n#  define F_SETLK\tF_SETLK64\t/* Set record locking info (non-blocking). */\n#  define F_SETLKW\tF_SETLKW64\t/* Set record locking info (blocking).  */\n# endif\n#endif\n#ifndef F_GETLK64\n# define F_GETLK64\t12\t/* Get record locking info.  */\n# define F_SETLK64\t13\t/* Set record locking info (non-blocking).  */\n# define F_SETLKW64\t14\t/* Set record locking info (blocking).  */\n#endif\n\n/* open file description locks.\n\n   Usually record locks held by a process are released on *any* close and are\n   not inherited across a fork.\n\n   These cmd values will set locks that conflict with process-associated record\n   locks, but are \"owned\" by the opened file description, not the process.\n   This means that they are inherited across fork or clone with CLONE_FILES\n   like BSD (flock) locks, and they are only released automatically when the\n   last reference to the the file description against which they were acquired\n   is put. */\n#ifdef __USE_GNU\n# define F_OFD_GETLK\t36\n# define F_OFD_SETLK\t37\n# define F_OFD_SETLKW\t38\n#endif\n\n#ifdef __USE_LARGEFILE64\n# define O_LARGEFILE __O_LARGEFILE\n#endif\n\n#ifdef __USE_XOPEN2K8\n# define O_DIRECTORY\t__O_DIRECTORY\t/* Must be a directory.  */\n# define O_NOFOLLOW\t__O_NOFOLLOW\t/* Do not follow links.  */\n# define O_CLOEXEC\t__O_CLOEXEC\t/* Set close_on_exec.  */\n#endif\n\n#ifdef __USE_GNU\n# define O_DIRECT\t__O_DIRECT\t/* Direct disk access.  */\n# define O_NOATIME\t__O_NOATIME\t/* Do not set atime.  */\n# define O_PATH\t\t__O_PATH\t/* Resolve pathname but do not open file.  */\n# define O_TMPFILE\t__O_TMPFILE\t/* Atomically create nameless file.  */\n#endif\n\n/* For now, Linux has no separate synchronicitiy options for read\n   operations.  We define O_RSYNC therefore as the same as O_SYNC\n   since this is a superset.  */\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n# define O_DSYNC\t__O_DSYNC\t/* Synchronize data.  */\n# if defined __O_RSYNC\n#  define O_RSYNC\t__O_RSYNC\t/* Synchronize read operations.  */\n# else\n#  define O_RSYNC\tO_SYNC\t/* Synchronize read operations.  */\n# endif\n#endif\n\n/* Values for the second argument to `fcntl'.  */\n#define F_DUPFD\t\t0\t/* Duplicate file descriptor.  */\n#define F_GETFD\t\t1\t/* Get file descriptor flags.  */\n#define F_SETFD\t\t2\t/* Set file descriptor flags.  */\n#define F_GETFL\t\t3\t/* Get file status flags.  */\n#define F_SETFL\t\t4\t/* Set file status flags.  */\n\n#ifndef __F_SETOWN\n# define __F_SETOWN\t8\n# define __F_GETOWN\t9\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n# define F_SETOWN\t__F_SETOWN\t/* Get owner (process receiving SIGIO).  */\n# define F_GETOWN\t__F_GETOWN\t/* Set owner (process receiving SIGIO).  */\n#endif\n\n#ifndef __F_SETSIG\n# define __F_SETSIG\t10\t/* Set number of signal to be sent.  */\n# define __F_GETSIG\t11\t/* Get number of signal to be sent.  */\n#endif\n#ifndef __F_SETOWN_EX\n# define __F_SETOWN_EX\t15\t/* Get owner (thread receiving SIGIO).  */\n# define __F_GETOWN_EX\t16\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n# define F_SETSIG\t__F_SETSIG\t/* Set number of signal to be sent.  */\n# define F_GETSIG\t__F_GETSIG\t/* Get number of signal to be sent.  */\n# define F_SETOWN_EX\t__F_SETOWN_EX\t/* Get owner (thread receiving SIGIO).  */\n# define F_GETOWN_EX\t__F_GETOWN_EX\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n# define F_SETLEASE\t1024\t/* Set a lease.  */\n# define F_GETLEASE\t1025\t/* Enquire what lease is active.  */\n# define F_NOTIFY\t1026\t/* Request notifications on a directory.  */\n# define F_SETPIPE_SZ\t1031\t/* Set pipe page size array.  */\n# define F_GETPIPE_SZ\t1032\t/* Set pipe page size array.  */\n#endif\n#ifdef __USE_XOPEN2K8\n# define F_DUPFD_CLOEXEC 1030\t/* Duplicate file descriptor with\n\t\t\t\t   close-on-exit set.  */\n#endif\n\n/* For F_[GET|SET]FD.  */\n#define FD_CLOEXEC\t1\t/* Actually anything with low bit set goes */\n\n#ifndef F_RDLCK\n/* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */\n# define F_RDLCK\t\t0\t/* Read lock.  */\n# define F_WRLCK\t\t1\t/* Write lock.  */\n# define F_UNLCK\t\t2\t/* Remove lock.  */\n#endif\n\n/* For old implementation of BSD flock.  */\n#ifndef F_EXLCK\n# define F_EXLCK\t\t4\t/* or 3 */\n# define F_SHLCK\t\t8\t/* or 4 */\n#endif\n\n#ifdef __USE_MISC\n/* Operations for BSD flock, also used by the kernel implementation.  */\n# define LOCK_SH\t1\t/* Shared lock.  */\n# define LOCK_EX\t2\t/* Exclusive lock.  */\n# define LOCK_NB\t4\t/* Or'd with one of the above to prevent\n\t\t\t\t   blocking.  */\n# define LOCK_UN\t8\t/* Remove lock.  */\n#endif\n\n#ifdef __USE_GNU\n# define LOCK_MAND\t32\t/* This is a mandatory flock:   */\n# define LOCK_READ\t64\t/* ... which allows concurrent read operations.  */\n# define LOCK_WRITE\t128\t/* ... which allows concurrent write operations.  */\n# define LOCK_RW\t192\t/* ... Which allows concurrent read & write operations.  */\n#endif\n\n#ifdef __USE_GNU\n/* Types of directory notifications that may be requested with F_NOTIFY.  */\n# define DN_ACCESS\t0x00000001\t/* File accessed.  */\n# define DN_MODIFY\t0x00000002\t/* File modified.  */\n# define DN_CREATE\t0x00000004\t/* File created.  */\n# define DN_DELETE\t0x00000008\t/* File removed.  */\n# define DN_RENAME\t0x00000010\t/* File renamed.  */\n# define DN_ATTRIB\t0x00000020\t/* File changed attributes.  */\n# define DN_MULTISHOT\t0x80000000\t/* Don't remove notifier.  */\n#endif\n\n#ifdef __USE_GNU\n/* Owner types.  */\nenum __pid_type {\n\tF_OWNER_TID = 0,\t/* Kernel thread.  */\n\tF_OWNER_PID,\t\t/* Process.  */\n\tF_OWNER_PGRP,\t\t/* Process group.  */\n\tF_OWNER_GID = F_OWNER_PGRP\t/* Alternative, obsolete name.  */\n};\n\n/* Structure to use with F_GETOWN_EX and F_SETOWN_EX.  */\nstruct f_owner_ex {\n\tenum __pid_type type;\t/* Owner type of ID.  */\n\t__pid_t pid;\t\t/* ID of owner.  */\n};\n#endif\n\n/* Define some more compatibility macros to be backward compatible with\n   BSD systems which did not managed to hide these kernel macros.  */\n#ifdef\t__USE_MISC\n# define FAPPEND\tO_APPEND\n# define FFSYNC\t\tO_FSYNC\n# define FASYNC\t\tO_ASYNC\n# define FNONBLOCK\tO_NONBLOCK\n# define FNDELAY\tO_NDELAY\n#endif\t\t\t\t/* Use misc.  */\n\n#ifndef __POSIX_FADV_DONTNEED\n#  define __POSIX_FADV_DONTNEED\t4\n#  define __POSIX_FADV_NOREUSE\t5\n#endif\n/* Advise to `posix_fadvise'.  */\n#ifdef __USE_XOPEN2K\n# define POSIX_FADV_NORMAL\t0\t/* No further special treatment.  */\n# define POSIX_FADV_RANDOM\t1\t/* Expect random page references.  */\n# define POSIX_FADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n# define POSIX_FADV_WILLNEED\t3\t/* Will need these pages.  */\n# define POSIX_FADV_DONTNEED\t__POSIX_FADV_DONTNEED\t/* Don't need these pages.  */\n# define POSIX_FADV_NOREUSE\t__POSIX_FADV_NOREUSE\t/* Data will be accessed once.  */\n#endif\n\n#ifdef __USE_GNU\n/* Flags for SYNC_FILE_RANGE.  */\n# define SYNC_FILE_RANGE_WAIT_BEFORE\t1\t/* Wait upon writeout of all pages\n\t\t\t\t\t\t   in the range before performing the\n\t\t\t\t\t\t   write.  */\n# define SYNC_FILE_RANGE_WRITE\t\t2\t/* Initiate writeout of all those\n\t\t\t\t\t\t   dirty pages in the range which are\n\t\t\t\t\t\t   not presently under writeback.  */\n# define SYNC_FILE_RANGE_WAIT_AFTER\t4\t/* Wait upon writeout of all pages in\n\t\t\t\t\t\t   the range after performing the\n\t\t\t\t\t\t   write.  */\n\n/* Flags for SPLICE and VMSPLICE.  */\n# define SPLICE_F_MOVE\t\t1\t/* Move pages instead of copying.  */\n# define SPLICE_F_NONBLOCK\t2\t/* Don't block on the pipe splicing\n\t\t\t\t\t   (but we may still block on the fd\n\t\t\t\t\t   we splice from/to).  */\n# define SPLICE_F_MORE\t\t4\t/* Expect more data.  */\n# define SPLICE_F_GIFT\t\t8\t/* Pages passed in are a gift.  */\n\n/* Flags for fallocate.  */\n# define FALLOC_FL_KEEP_SIZE\t\t1\t/* Don't extend size of file\n\t\t\t\t\t\t   even if offset + len is\n\t\t\t\t\t\t   greater than file size.  */\n# define FALLOC_FL_PUNCH_HOLE\t\t2\t/* Create a hole in the file.  */\n# define FALLOC_FL_COLLAPSE_RANGE\t8\t/* Remove a range of a file\n\t\t\t\t\t\t   without leaving a\n\t\t\t\t\t\t   hole.  */\n# define FALLOC_FL_ZERO_RANGE\t\t16\t/* Convert a range of a\n\t\t\t\t\t\t   file to zeros.  */\n\n/* File handle structure.  */\nstruct file_handle {\n\tunsigned int handle_bytes;\n\tint handle_type;\n\t/* File identifier.  */\n\tunsigned char f_handle[0];\n};\n\n/* Maximum handle size (for now).  */\n# define MAX_HANDLE_SZ\t128\n#endif\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Provide kernel hint to read ahead.  */\nextern ssize_t readahead(int __fd, __off64_t __offset, size_t __count) __THROW;\n\n/* Selective file content synch'ing.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int sync_file_range(int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags);\n\n/* Splice address range into a pipe.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags);\n\n/* Splice two files together.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t splice(int __fdin, __off64_t * __offin, int __fdout, __off64_t * __offout, size_t __len, unsigned int __flags);\n\n/* In-kernel implementation of tee for pipe buffers.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t tee(int __fdin, int __fdout, size_t __len, unsigned int __flags);\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int fallocate(int __fd, int __mode, __off_t __offset, __off_t __len);\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(fallocate, (int __fd, int __mode, __off64_t __offset, __off64_t __len), fallocate64);\n#  else\n#   define fallocate fallocate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int fallocate64(int __fd, int __mode, __off64_t __offset, __off64_t __len);\n# endif\n\n/* Map file name to file handle.  */\nextern int name_to_handle_at(int __dfd, const char *__name, struct file_handle *__handle, int *__mnt_id, int __flags) __THROW;\n\n/* Open file using the file handle.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int open_by_handle_at(int __mountdirfd, struct file_handle *__handle, int __flags);\n\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/fcntl.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux/x86.\n   Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _FCNTL_H\n# error \"Never use <bits/fcntl.h> directly; include <fcntl.h> instead.\"\n#endif\n\n#ifdef __x86_64__\n# define __O_LARGEFILE\t0\n#endif\n\n#ifdef __x86_64__\n/* Not necessary, we always have 64-bit offsets.  */\n# define F_GETLK64\t5\t/* Get record locking info.  */\n# define F_SETLK64\t6\t/* Set record locking info (non-blocking).  */\n# define F_SETLKW64\t7\t/* Set record locking info (blocking).  */\n#endif\n\nstruct flock {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n#ifndef __USE_FILE_OFFSET64\n\t__off_t l_start;\t/* Offset where the lock begins.  */\n\t__off_t l_len;\t\t/* Size of the locked area; zero means until EOF.  */\n#else\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n#endif\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct flock64 {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/fcntl-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/huge_val.h",
    "content": "/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/huge_val.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity (-HUGE_VAL is negative infinity).  */\n\n#if __GNUC_PREREQ(3,3)\n# define HUGE_VAL\t(__builtin_huge_val())\n#elif __GNUC_PREREQ(2,96)\n# define HUGE_VAL\t(__extension__ 0x1.0p2047)\n#elif defined __GNUC__\n\n# define HUGE_VAL \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; })   \\\n    { __l: 0x7ff0000000000000ULL }).__d)\n\n#else\t\t\t\t/* not GCC */\n\n# include <endian.h>\n\ntypedef union {\n\tunsigned char __c[8];\n\tdouble __d;\n} __huge_val_t;\n\n# if __BYTE_ORDER == __BIG_ENDIAN\n#  define __HUGE_VAL_bytes\t{ 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }\n# endif\n# if __BYTE_ORDER == __LITTLE_ENDIAN\n#  define __HUGE_VAL_bytes\t{ 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }\n# endif\n\nstatic __huge_val_t __huge_val = { __HUGE_VAL_bytes };\n\n# define HUGE_VAL\t(__huge_val.__d)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/huge_valf.h",
    "content": "/* `HUGE_VALF' constant for IEEE 754 machines (where it is infinity).\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/huge_valf.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity (-HUGE_VAL is negative infinity).  */\n\n#if __GNUC_PREREQ(3,3)\n# define HUGE_VALF\t(__builtin_huge_valf())\n#elif __GNUC_PREREQ(2,96)\n# define HUGE_VALF\t(__extension__ 0x1.0p255f)\n#elif defined __GNUC__\n\n#   define HUGE_VALF \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; })    \\\n    { __l: 0x7f800000UL }).__d)\n\n#else\t\t\t\t/* not GCC */\n\ntypedef union {\n\tunsigned char __c[4];\n\tfloat __f;\n} __huge_valf_t;\n\n# if __BYTE_ORDER == __BIG_ENDIAN\n#  define __HUGE_VALF_bytes\t{ 0x7f, 0x80, 0, 0 }\n# endif\n# if __BYTE_ORDER == __LITTLE_ENDIAN\n#  define __HUGE_VALF_bytes\t{ 0, 0, 0x80, 0x7f }\n# endif\n\nstatic __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };\n\n# define HUGE_VALF\t(__huge_valf.__f)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/huge_vall.h",
    "content": "/* `HUGE_VALL' constant for ix86 (where it is infinity).\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/huge_vall.h> directly; include <math.h> instead.\"\n#endif\n\n#if __GNUC_PREREQ(3,3)\n# define HUGE_VALL\t(__builtin_huge_vall())\n#elif __GNUC_PREREQ(2,96)\n# define HUGE_VALL\t(__extension__ 0x1.0p32767L)\n#else\n\n# define __HUGE_VALL_bytes\t{ 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 }\n\n# define __huge_vall_t\tunion { unsigned char __c[12]; long double __ld; }\n# ifdef __GNUC__\n#  define HUGE_VALL\t(__extension__ \\\n\t\t\t ((__huge_vall_t) { __c: __HUGE_VALL_bytes }).__ld)\n# else\t\t\t\t/* Not GCC.  */\nstatic __huge_vall_t __huge_vall = { __HUGE_VALL_bytes };\n\n#  define HUGE_VALL\t(__huge_vall.__ld)\n#  endif\t\t\t/* GCC.  */\n\n#endif\t\t\t\t/* GCC 2.95 */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/in.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Linux version.  */\n\n#ifndef _NETINET_IN_H\n# error \"Never use <bits/in.h> directly; include <netinet/in.h> instead.\"\n#endif\n\n/* If the application has already included linux/in6.h from a linux-based\n   kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the\n   defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo\n   in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly.\n   Neither the linux kernel nor glibc should break this ABI without coordination.  */\n#if defined _UAPI_LINUX_IN6_H || defined _UAPI_IPV6_H\n/* This is not quite the same API since the kernel always defines s6_addr16 and\n   s6_addr32. This is not a violation of POSIX since POSIX says \"at least the\n   following member\" and that holds true.  */\n# define __USE_KERNEL_IPV6_DEFS\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IP level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define        IP_OPTIONS      4\t/* ip_opts; IP per-packet options.  */\n#define        IP_HDRINCL      3\t/* int; Header is included with data.  */\n#define        IP_TOS          1\t/* int; IP type of service and precedence.  */\n#define        IP_TTL          2\t/* int; IP time to live.  */\n#define        IP_RECVOPTS     6\t/* bool; Receive all IP options w/datagram.  */\n/* For BSD compatibility.  */\n#define        IP_RECVRETOPTS  IP_RETOPTS\t/* bool; Receive IP options for response.  */\n#define        IP_RETOPTS      7\t/* ip_opts; Set/get IP per-packet options.  */\n#define IP_MULTICAST_IF 32\t/* in_addr; set/get IP multicast i/f */\n#define IP_MULTICAST_TTL 33\t/* u_char; set/get IP multicast ttl */\n#define IP_MULTICAST_LOOP 34\t/* i_char; set/get IP multicast loopback */\n#define IP_ADD_MEMBERSHIP 35\t/* ip_mreq; add an IP group membership */\n#define IP_DROP_MEMBERSHIP 36\t/* ip_mreq; drop an IP group membership */\n#define IP_UNBLOCK_SOURCE 37\t/* ip_mreq_source: unblock data from source */\n#define IP_BLOCK_SOURCE 38\t/* ip_mreq_source: block data from source */\n#define IP_ADD_SOURCE_MEMBERSHIP 39\t/* ip_mreq_source: join source group */\n#define IP_DROP_SOURCE_MEMBERSHIP 40\t/* ip_mreq_source: leave source group */\n#define IP_MSFILTER 41\n#ifdef __USE_MISC\n# define MCAST_JOIN_GROUP 42\t/* group_req: join any-source group */\n# define MCAST_BLOCK_SOURCE 43\t/* group_source_req: block from given group */\n# define MCAST_UNBLOCK_SOURCE 44\t/* group_source_req: unblock from given group */\n# define MCAST_LEAVE_GROUP 45\t/* group_req: leave any-source group */\n# define MCAST_JOIN_SOURCE_GROUP 46\t/* group_source_req: join source-spec gr */\n# define MCAST_LEAVE_SOURCE_GROUP 47\t/* group_source_req: leave source-spec gr */\n# define MCAST_MSFILTER 48\n# define IP_MULTICAST_ALL 49\n# define IP_UNICAST_IF 50\n\n# define MCAST_EXCLUDE   0\n# define MCAST_INCLUDE   1\n#endif\n\n#define IP_ROUTER_ALERT\t5\t/* bool */\n#define IP_PKTINFO\t8\t/* bool */\n#define IP_PKTOPTIONS\t9\n#define IP_PMTUDISC\t10\t/* obsolete name? */\n#define IP_MTU_DISCOVER\t10\t/* int; see below */\n#define IP_RECVERR\t11\t/* bool */\n#define IP_RECVTTL\t12\t/* bool */\n#define IP_RECVTOS\t13\t/* bool */\n#define IP_MTU\t\t14\t/* int */\n#define IP_FREEBIND\t15\n#define IP_IPSEC_POLICY 16\n#define IP_XFRM_POLICY\t17\n#define IP_PASSSEC\t18\n#define IP_TRANSPARENT\t19\n#define IP_MULTICAST_ALL 49\t/* bool */\n\n/* TProxy original addresses */\n#define IP_ORIGDSTADDR       20\n#define IP_RECVORIGDSTADDR   IP_ORIGDSTADDR\n\n#define IP_MINTTL       21\n#define IP_NODEFRAG     22\n#define IP_CHECKSUM     23\n\n/* IP_MTU_DISCOVER arguments.  */\n#define IP_PMTUDISC_DONT   0\t/* Never send DF frames.  */\n#define IP_PMTUDISC_WANT   1\t/* Use per route hints.  */\n#define IP_PMTUDISC_DO     2\t/* Always DF.  */\n#define IP_PMTUDISC_PROBE  3\t/* Ignore dst pmtu.  */\n/* Always use interface mtu (ignores dst pmtu) but don't set DF flag.\n   Also incoming ICMP frag_needed notifications will be ignored on\n   this socket to prevent accepting spoofed ones.  */\n#define IP_PMTUDISC_INTERFACE           4\n/* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented.  */\n#define IP_PMTUDISC_OMIT\t\t5\n\n#define IP_MULTICAST_IF\t\t\t32\n#define IP_MULTICAST_TTL \t\t33\n#define IP_MULTICAST_LOOP \t\t34\n#define IP_ADD_MEMBERSHIP\t\t35\n#define IP_DROP_MEMBERSHIP\t\t36\n#define IP_UNBLOCK_SOURCE\t\t37\n#define IP_BLOCK_SOURCE\t\t\t38\n#define IP_ADD_SOURCE_MEMBERSHIP\t39\n#define IP_DROP_SOURCE_MEMBERSHIP\t40\n#define IP_MSFILTER\t\t\t41\n#define IP_MULTICAST_ALL\t\t49\n#define IP_UNICAST_IF\t\t\t50\n\n/* To select the IP level.  */\n#define SOL_IP\t0\n\n#define IP_DEFAULT_MULTICAST_TTL        1\n#define IP_DEFAULT_MULTICAST_LOOP       1\n#define IP_MAX_MEMBERSHIPS              20\n\n#ifdef __USE_MISC\n/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.\n   The `ip_dst' field is used for the first-hop gateway when using a\n   source route (this gets put into the header proper).  */\nstruct ip_opts {\n\tstruct in_addr ip_dst;\t/* First hop; zero without source route.  */\n\tchar ip_opts[40];\t/* Actually variable in size.  */\n};\n\n/* Like `struct ip_mreq' but including interface specification by index.  */\nstruct ip_mreqn {\n\tstruct in_addr imr_multiaddr;\t/* IP multicast address of group */\n\tstruct in_addr imr_address;\t/* local IP address of interface */\n\tint imr_ifindex;\t/* Interface index */\n};\n\n/* Structure used for IP_PKTINFO.  */\nstruct in_pktinfo {\n\tint ipi_ifindex;\t/* Interface index  */\n\tstruct in_addr ipi_spec_dst;\t/* Routing destination address  */\n\tstruct in_addr ipi_addr;\t/* Header destination address  */\n};\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define IPV6_ADDRFORM\t\t1\n#define IPV6_2292PKTINFO\t2\n#define IPV6_2292HOPOPTS\t3\n#define IPV6_2292DSTOPTS\t4\n#define IPV6_2292RTHDR\t\t5\n#define IPV6_2292PKTOPTIONS\t6\n#define IPV6_CHECKSUM\t\t7\n#define IPV6_2292HOPLIMIT\t8\n\n#define SCM_SRCRT\t\tIPV6_RXSRCRT\n\n#define IPV6_NEXTHOP\t\t9\n#define IPV6_AUTHHDR\t\t10\n#define IPV6_UNICAST_HOPS\t16\n#define IPV6_MULTICAST_IF\t17\n#define IPV6_MULTICAST_HOPS\t18\n#define IPV6_MULTICAST_LOOP\t19\n#define IPV6_JOIN_GROUP\t\t20\n#define IPV6_LEAVE_GROUP\t21\n#define IPV6_ROUTER_ALERT\t22\n#define IPV6_MTU_DISCOVER\t23\n#define IPV6_MTU\t\t24\n#define IPV6_RECVERR\t\t25\n#define IPV6_V6ONLY\t\t26\n#define IPV6_JOIN_ANYCAST\t27\n#define IPV6_LEAVE_ANYCAST\t28\n#define IPV6_IPSEC_POLICY\t34\n#define IPV6_XFRM_POLICY\t35\n\n/* Advanced API (RFC3542) (1).  */\n#define IPV6_RECVPKTINFO\t49\n#define IPV6_PKTINFO\t\t50\n#define IPV6_RECVHOPLIMIT\t51\n#define IPV6_HOPLIMIT\t\t52\n#define IPV6_RECVHOPOPTS\t53\n#define IPV6_HOPOPTS\t\t54\n#define IPV6_RTHDRDSTOPTS\t55\n#define IPV6_RECVRTHDR\t\t56\n#define IPV6_RTHDR\t\t57\n#define IPV6_RECVDSTOPTS\t58\n#define IPV6_DSTOPTS\t\t59\n#define IPV6_RECVPATHMTU\t60\n#define IPV6_PATHMTU\t\t61\n#define IPV6_DONTFRAG\t\t62\n\n/* Advanced API (RFC3542) (2).  */\n#define IPV6_RECVTCLASS\t\t66\n#define IPV6_TCLASS\t\t67\n\n/* Obsolete synonyms for the above.  */\n#define IPV6_ADD_MEMBERSHIP\tIPV6_JOIN_GROUP\n#define IPV6_DROP_MEMBERSHIP\tIPV6_LEAVE_GROUP\n#define IPV6_RXHOPOPTS\t\tIPV6_HOPOPTS\n#define IPV6_RXDSTOPTS\t\tIPV6_DSTOPTS\n\n/* IPV6_MTU_DISCOVER values.  */\n#define IPV6_PMTUDISC_DONT\t0\t/* Never send DF frames.  */\n#define IPV6_PMTUDISC_WANT\t1\t/* Use per route hints.  */\n#define IPV6_PMTUDISC_DO\t2\t/* Always DF.  */\n#define IPV6_PMTUDISC_PROBE\t3\t/* Ignore dst pmtu.  */\n#define IPV6_PMTUDISC_INTERFACE\t4\t/* See IP_PMTUDISC_INTERFACE.  */\n#define IPV6_PMTUDISC_OMIT\t5\t/* See IP_PMTUDISC_OMIT.  */\n\n/* Socket level values for IPv6.  */\n#define SOL_IPV6        41\n#define SOL_ICMPV6      58\n\n/* Routing header options for IPv6.  */\n#define IPV6_RTHDR_LOOSE\t0\t/* Hop doesn't need to be neighbour. */\n#define IPV6_RTHDR_STRICT\t1\t/* Hop must be a neighbour.  */\n\n#define IPV6_RTHDR_TYPE_0\t0\t/* IPv6 Routing header type 0.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/inf.h",
    "content": "/* `INFINITY' constant for IEEE 754 machines.\n   Copyright (C) 2004-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/inf.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity.  */\n\n#if __GNUC_PREREQ(3,3)\n# define INFINITY\t(__builtin_inff())\n#else\n# define INFINITY\tHUGE_VALF\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/ioctl-types.h",
    "content": "/* Structure types for pre-termios terminal ioctls.  Linux version.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n# error \"Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Get definition of constants for use with `ioctl'.  */\n#include <asm/ioctls.h>\n\nstruct winsize {\n\tunsigned short int ws_row;\n\tunsigned short int ws_col;\n\tunsigned short int ws_xpixel;\n\tunsigned short int ws_ypixel;\n};\n\n#define NCC 8\nstruct termio {\n\tunsigned short int c_iflag;\t/* input mode flags */\n\tunsigned short int c_oflag;\t/* output mode flags */\n\tunsigned short int c_cflag;\t/* control mode flags */\n\tunsigned short int c_lflag;\t/* local mode flags */\n\tunsigned char c_line;\t/* line discipline */\n\tunsigned char c_cc[NCC];\t/* control characters */\n};\n\n/* modem lines */\n#define TIOCM_LE\t0x001\n#define TIOCM_DTR\t0x002\n#define TIOCM_RTS\t0x004\n#define TIOCM_ST\t0x008\n#define TIOCM_SR\t0x010\n#define TIOCM_CTS\t0x020\n#define TIOCM_CAR\t0x040\n#define TIOCM_RNG\t0x080\n#define TIOCM_DSR\t0x100\n#define TIOCM_CD\tTIOCM_CAR\n#define TIOCM_RI\tTIOCM_RNG\n\n/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */\n\n/* line disciplines */\n#define N_TTY\t\t0\n#define N_SLIP\t\t1\n#define N_MOUSE\t\t2\n#define N_PPP\t\t3\n#define N_STRIP\t\t4\n#define N_AX25\t\t5\n#define N_X25\t\t6\t/* X.25 async  */\n#define N_6PACK\t\t7\n#define N_MASC\t\t8\t/* Mobitex module  */\n#define N_R3964\t\t9\t/* Simatic R3964 module  */\n#define N_PROFIBUS_FDL\t10\t/* Profibus  */\n#define N_IRDA\t\t11\t/* Linux IR  */\n#define N_SMSBLOCK\t12\t/* SMS block mode  */\n#define N_HDLC\t\t13\t/* synchronous HDLC  */\n#define N_SYNC_PPP\t14\t/* synchronous PPP  */\n#define\tN_HCI\t\t15\t/* Bluetooth HCI UART  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/ioctls.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n# error \"Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Use the definitions from the kernel header files.  */\n#include <asm/ioctls.h>\n\n/* Routing table calls.  */\n#define SIOCADDRT\t0x890B\t/* add routing table entry      */\n#define SIOCDELRT\t0x890C\t/* delete routing table entry   */\n#define SIOCRTMSG\t0x890D\t/* call to routing system       */\n\n/* Socket configuration controls. */\n#define SIOCGIFNAME\t0x8910\t/* get iface name               */\n#define SIOCSIFLINK\t0x8911\t/* set iface channel            */\n#define SIOCGIFCONF\t0x8912\t/* get iface list               */\n#define SIOCGIFFLAGS\t0x8913\t/* get flags                    */\n#define SIOCSIFFLAGS\t0x8914\t/* set flags                    */\n#define SIOCGIFADDR\t0x8915\t/* get PA address               */\n#define SIOCSIFADDR\t0x8916\t/* set PA address               */\n#define SIOCGIFDSTADDR\t0x8917\t/* get remote PA address        */\n#define SIOCSIFDSTADDR\t0x8918\t/* set remote PA address        */\n#define SIOCGIFBRDADDR\t0x8919\t/* get broadcast PA address     */\n#define SIOCSIFBRDADDR\t0x891a\t/* set broadcast PA address     */\n#define SIOCGIFNETMASK\t0x891b\t/* get network PA mask          */\n#define SIOCSIFNETMASK\t0x891c\t/* set network PA mask          */\n#define SIOCGIFMETRIC\t0x891d\t/* get metric                   */\n#define SIOCSIFMETRIC\t0x891e\t/* set metric                   */\n#define SIOCGIFMEM\t0x891f\t/* get memory address (BSD)     */\n#define SIOCSIFMEM\t0x8920\t/* set memory address (BSD)     */\n#define SIOCGIFMTU\t0x8921\t/* get MTU size                 */\n#define SIOCSIFMTU\t0x8922\t/* set MTU size                 */\n#define SIOCSIFNAME\t0x8923\t/* set interface name           */\n#define\tSIOCSIFHWADDR\t0x8924\t/* set hardware address         */\n#define SIOCGIFENCAP\t0x8925\t/* get/set encapsulations       */\n#define SIOCSIFENCAP\t0x8926\n#define SIOCGIFHWADDR\t0x8927\t/* Get hardware address         */\n#define SIOCGIFSLAVE\t0x8929\t/* Driver slaving support       */\n#define SIOCSIFSLAVE\t0x8930\n#define SIOCADDMULTI\t0x8931\t/* Multicast address lists      */\n#define SIOCDELMULTI\t0x8932\n#define SIOCGIFINDEX\t0x8933\t/* name -> if_index mapping     */\n#define SIOGIFINDEX\tSIOCGIFINDEX\t/* misprint compatibility :-)   */\n#define SIOCSIFPFLAGS\t0x8934\t/* set/get extended flags set   */\n#define SIOCGIFPFLAGS\t0x8935\n#define SIOCDIFADDR\t0x8936\t/* delete PA address            */\n#define\tSIOCSIFHWBROADCAST\t0x8937\t/* set hardware broadcast addr  */\n#define SIOCGIFCOUNT\t0x8938\t/* get number of devices */\n\n#define SIOCGIFBR\t0x8940\t/* Bridging support             */\n#define SIOCSIFBR\t0x8941\t/* Set bridging options         */\n\n#define SIOCGIFTXQLEN\t0x8942\t/* Get the tx queue length      */\n#define SIOCSIFTXQLEN\t0x8943\t/* Set the tx queue length      */\n\n/* ARP cache control calls. */\n\t\t    /*  0x8950 - 0x8952  * obsolete calls, don't re-use */\n#define SIOCDARP\t0x8953\t/* delete ARP table entry       */\n#define SIOCGARP\t0x8954\t/* get ARP table entry          */\n#define SIOCSARP\t0x8955\t/* set ARP table entry          */\n\n/* RARP cache control calls. */\n#define SIOCDRARP\t0x8960\t/* delete RARP table entry      */\n#define SIOCGRARP\t0x8961\t/* get RARP table entry         */\n#define SIOCSRARP\t0x8962\t/* set RARP table entry         */\n\n/* Driver configuration calls */\n\n#define SIOCGIFMAP\t0x8970\t/* Get device parameters        */\n#define SIOCSIFMAP\t0x8971\t/* Set device parameters        */\n\n/* DLCI configuration calls */\n\n#define SIOCADDDLCI\t0x8980\t/* Create new DLCI device       */\n#define SIOCDELDLCI\t0x8981\t/* Delete DLCI device           */\n\n/* Device private ioctl calls.  */\n\n/* These 16 ioctls are available to devices via the do_ioctl() device\n   vector.  Each device should include this file and redefine these\n   names as their own. Because these are device dependent it is a good\n   idea _NOT_ to issue them to random objects and hope.  */\n\n#define SIOCDEVPRIVATE \t\t0x89F0\t/* to 89FF */\n\n/*\n *\tThese 16 ioctl calls are protocol private\n */\n\n#define SIOCPROTOPRIVATE 0x89E0\t/* to 89EF */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/libm-simd-decl-stubs.h",
    "content": "/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h.\n   Copyright (C) 2014-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/libm-simd-decl-stubs.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Needed definitions could be generated with:\n   for func in $(grep __MATHCALL_VEC math/bits/mathcalls.h |\\\n\t\t sed -r \"s|__MATHCALL_VEC.?\\(||; s|,.*||\"); do\n     echo \"#define __DECL_SIMD_${func}\";\n     echo \"#define __DECL_SIMD_${func}f\";\n     echo \"#define __DECL_SIMD_${func}l\";\n   done\n */\n\n#ifndef _BITS_LIBM_SIMD_DECL_STUBS_H\n#define _BITS_LIBM_SIMD_DECL_STUBS_H 1\n\n#define __DECL_SIMD_cos\n#define __DECL_SIMD_cosf\n#define __DECL_SIMD_cosl\n\n#define __DECL_SIMD_sin\n#define __DECL_SIMD_sinf\n#define __DECL_SIMD_sinl\n\n#define __DECL_SIMD_sincos\n#define __DECL_SIMD_sincosf\n#define __DECL_SIMD_sincosl\n\n#define __DECL_SIMD_log\n#define __DECL_SIMD_logf\n#define __DECL_SIMD_logl\n\n#define __DECL_SIMD_exp\n#define __DECL_SIMD_expf\n#define __DECL_SIMD_expl\n\n#define __DECL_SIMD_pow\n#define __DECL_SIMD_powf\n#define __DECL_SIMD_powl\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/local_lim.h",
    "content": "/* Minimum guaranteed maximum values for system limits.  Linux version.\n   Copyright (C) 1993-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n/* The kernel header pollutes the namespace with the NR_OPEN symbol\n   and defines LINK_MAX although filesystems have different maxima.  A\n   similar thing is true for OPEN_MAX: the limit can be changed at\n   runtime and therefore the macro must not be defined.  Remove this\n   after including the header if necessary.  */\n#ifndef NR_OPEN\n# define __undef_NR_OPEN\n#endif\n#ifndef LINK_MAX\n# define __undef_LINK_MAX\n#endif\n#ifndef OPEN_MAX\n# define __undef_OPEN_MAX\n#endif\n#ifndef ARG_MAX\n# define __undef_ARG_MAX\n#endif\n\n/* The kernel sources contain a file with all the needed information.  */\n#include <linux/limits.h>\n\n/* Have to remove NR_OPEN?  */\n#ifdef __undef_NR_OPEN\n# undef NR_OPEN\n# undef __undef_NR_OPEN\n#endif\n/* Have to remove LINK_MAX?  */\n#ifdef __undef_LINK_MAX\n# undef LINK_MAX\n# undef __undef_LINK_MAX\n#endif\n/* Have to remove OPEN_MAX?  */\n#ifdef __undef_OPEN_MAX\n# undef OPEN_MAX\n# undef __undef_OPEN_MAX\n#endif\n/* Have to remove ARG_MAX?  */\n#ifdef __undef_ARG_MAX\n# undef ARG_MAX\n# undef __undef_ARG_MAX\n#endif\n\n/* The number of data keys per process.  */\n#define _POSIX_THREAD_KEYS_MAX\t128\n/* This is the value this implementation supports.  */\n#define PTHREAD_KEYS_MAX\t1024\n\n/* Controlling the iterations of destructors for thread-specific data.  */\n#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS\t4\n/* Number of iterations this implementation does.  */\n#define PTHREAD_DESTRUCTOR_ITERATIONS\t_POSIX_THREAD_DESTRUCTOR_ITERATIONS\n\n/* The number of threads per process.  */\n#define _POSIX_THREAD_THREADS_MAX\t64\n/* We have no predefined limit on the number of threads.  */\n#undef PTHREAD_THREADS_MAX\n\n/* Maximum amount by which a process can descrease its asynchronous I/O\n   priority level.  */\n#define AIO_PRIO_DELTA_MAX\t20\n\n/* Minimum size for a thread.  We are free to choose a reasonable value.  */\n#define PTHREAD_STACK_MIN\t16384\n\n/* Maximum number of timer expiration overruns.  */\n#define DELAYTIMER_MAX\t2147483647\n\n/* Maximum tty name length.  */\n#define TTY_NAME_MAX\t\t32\n\n/* Maximum login name length.  This is arbitrary.  */\n#define LOGIN_NAME_MAX\t\t256\n\n/* Maximum host name length.  */\n#define HOST_NAME_MAX\t\t64\n\n/* Maximum message queue priority level.  */\n#define MQ_PRIO_MAX\t\t32768\n\n/* Maximum value the semaphore can have.  */\n#define SEM_VALUE_MAX   (2147483647)\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/locale.h",
    "content": "/* Definition of locale category symbol values.\n   Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _LOCALE_H && !defined _LANGINFO_H\n# error \"Never use <bits/locale.h> directly; include <locale.h> instead.\"\n#endif\n\n#ifndef _BITS_LOCALE_H\n#define _BITS_LOCALE_H\t1\n\n#define __LC_CTYPE\t\t 0\n#define __LC_NUMERIC\t\t 1\n#define __LC_TIME\t\t 2\n#define __LC_COLLATE\t\t 3\n#define __LC_MONETARY\t\t 4\n#define __LC_MESSAGES\t\t 5\n#define __LC_ALL\t\t 6\n#define __LC_PAPER\t\t 7\n#define __LC_NAME\t\t 8\n#define __LC_ADDRESS\t\t 9\n#define __LC_TELEPHONE\t\t10\n#define __LC_MEASUREMENT\t11\n#define __LC_IDENTIFICATION\t12\n\n#endif\t\t\t\t/* bits/locale.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/math-vector.h",
    "content": "/* Platform-specific SIMD declarations of math functions.\n   Copyright (C) 2014-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/math-vector.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Get default empty definitions for simd declarations.  */\n#include <bits/libm-simd-decl-stubs.h>\n\n#if defined __x86_64__ && defined __FAST_MATH__\n# if defined _OPENMP && _OPENMP >= 201307\n/* OpenMP case.  */\n#  define __DECL_SIMD_x86_64 _Pragma (\"omp declare simd notinbranch\")\n# elif __GNUC_PREREQ (6,0)\n/* W/o OpenMP use GCC 6.* __attribute__ ((__simd__)).  */\n#  define __DECL_SIMD_x86_64 __attribute__ ((__simd__ (\"notinbranch\")))\n# endif\n\n# ifdef __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_cos\n#  define __DECL_SIMD_cos __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_cosf\n#  define __DECL_SIMD_cosf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sin\n#  define __DECL_SIMD_sin __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sinf\n#  define __DECL_SIMD_sinf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sincos\n#  define __DECL_SIMD_sincos __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_sincosf\n#  define __DECL_SIMD_sincosf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_log\n#  define __DECL_SIMD_log __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_logf\n#  define __DECL_SIMD_logf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_exp\n#  define __DECL_SIMD_exp __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_expf\n#  define __DECL_SIMD_expf __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_pow\n#  define __DECL_SIMD_pow __DECL_SIMD_x86_64\n#  undef __DECL_SIMD_powf\n#  define __DECL_SIMD_powf __DECL_SIMD_x86_64\n\n# endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/mathcalls.h",
    "content": "/* Prototype declarations for math functions; helper file for <math.h>.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* NOTE: Because of the special way this file is used by <math.h>, this\n   file must NOT be protected from multiple inclusion as header files\n   usually are.\n\n   This file provides prototype declarations for the math functions.\n   Most functions are declared using the macro:\n\n   __MATHCALL (NAME,[_r], (ARGS...));\n\n   This means there is a function `NAME' returning `double' and a function\n   `NAMEf' returning `float'.  Each place `_Mdouble_' appears in the\n   prototype, that is actually `double' in the prototype for `NAME' and\n   `float' in the prototype for `NAMEf'.  Reentrant variant functions are\n   called `NAME_r' and `NAMEf_r'.\n\n   Functions returning other types like `int' are declared using the macro:\n\n   __MATHDECL (TYPE, NAME,[_r], (ARGS...));\n\n   This is just like __MATHCALL but for a function returning `TYPE'\n   instead of `_Mdouble_'.  In all of these cases, there is still\n   both a `NAME' and a `NAMEf' that takes `float' arguments.\n\n   Note that there must be no whitespace before the argument passed for\n   NAME, to make token pasting work with -traditional.  */\n\n#ifndef _MATH_H\n# error \"Never include <bits/mathcalls.h> directly; include <math.h> instead.\"\n#endif\n\n/* Trigonometric functions.  */\n\n_Mdouble_BEGIN_NAMESPACE\n/* Arc cosine of X.  */\n__MATHCALL(acos,, (_Mdouble_ __x));\n/* Arc sine of X.  */\n__MATHCALL(asin,, (_Mdouble_ __x));\n/* Arc tangent of X.  */\n__MATHCALL(atan,, (_Mdouble_ __x));\n/* Arc tangent of Y/X.  */\n__MATHCALL(atan2,, (_Mdouble_ __y, _Mdouble_ __x));\n\n/* Cosine of X.  */\n__MATHCALL_VEC(cos,, (_Mdouble_ __x));\n/* Sine of X.  */\n__MATHCALL_VEC(sin,, (_Mdouble_ __x));\n/* Tangent of X.  */\n__MATHCALL(tan,, (_Mdouble_ __x));\n\n/* Hyperbolic functions.  */\n\n/* Hyperbolic cosine of X.  */\n__MATHCALL(cosh,, (_Mdouble_ __x));\n/* Hyperbolic sine of X.  */\n__MATHCALL(sinh,, (_Mdouble_ __x));\n/* Hyperbolic tangent of X.  */\n__MATHCALL(tanh,, (_Mdouble_ __x));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_GNU\n/* Cosine and sine of X.  */\n__MATHDECL_VEC(void, sincos,, (_Mdouble_ __x, _Mdouble_ * __sinx, _Mdouble_ * __cosx));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Hyperbolic arc cosine of X.  */\n __MATHCALL(acosh,, (_Mdouble_ __x));\n/* Hyperbolic arc sine of X.  */\n__MATHCALL(asinh,, (_Mdouble_ __x));\n/* Hyperbolic arc tangent of X.  */\n__MATHCALL(atanh,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Exponential and logarithmic functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Exponential function of X.  */\n __MATHCALL_VEC(exp,, (_Mdouble_ __x));\n\n/* Break VALUE into a normalized fraction and an integral power of 2.  */\n__MATHCALL(frexp,, (_Mdouble_ __x, int *__exponent));\n\n/* X times (two to the EXP power).  */\n__MATHCALL(ldexp,, (_Mdouble_ __x, int __exponent));\n\n/* Natural logarithm of X.  */\n__MATHCALL_VEC(log,, (_Mdouble_ __x));\n\n/* Base-ten logarithm of X.  */\n__MATHCALL(log10,, (_Mdouble_ __x));\n\n/* Break VALUE into integral and fractional parts.  */\n__MATHCALL(modf,, (_Mdouble_ __x, _Mdouble_ * __iptr)) __nonnull((2));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_GNU\n/* A function missing in all standards: compute exponent to base ten.  */\n__MATHCALL(exp10,, (_Mdouble_ __x));\n/* Another name occasionally used.  */\n__MATHCALL(pow10,, (_Mdouble_ __x));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return exp(X) - 1.  */\n__MATHCALL(expm1,, (_Mdouble_ __x));\n\n/* Return log(1 + X).  */\n__MATHCALL(log1p,, (_Mdouble_ __x));\n\n/* Return the base 2 signed integral exponent of X.  */\n__MATHCALL(logb,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Compute base-2 exponential of X.  */\n__MATHCALL(exp2,, (_Mdouble_ __x));\n\n/* Compute base-2 logarithm of X.  */\n__MATHCALL(log2,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Power functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Return X to the Y power.  */\n__MATHCALL_VEC(pow,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the square root of X.  */\n__MATHCALL(sqrt,, (_Mdouble_ __x));\n_Mdouble_END_NAMESPACE\n#if defined __USE_XOPEN || defined __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return `sqrt(X*X + Y*Y)'.  */\n__MATHCALL(hypot,, (_Mdouble_ __x, _Mdouble_ __y));\n__END_NAMESPACE_C99\n#endif\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return the cube root of X.  */\n__MATHCALL(cbrt,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Nearest integer, absolute value, and remainder functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Smallest integral value not less than X.  */\n__MATHCALLX(ceil,, (_Mdouble_ __x), (__const__));\n\n/* Absolute value of X.  */\n__MATHCALLX(fabs,, (_Mdouble_ __x), (__const__));\n\n/* Largest integer not greater than X.  */\n__MATHCALLX(floor,, (_Mdouble_ __x), (__const__));\n\n/* Floating-point modulo remainder of X/Y.  */\n__MATHCALL(fmod,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return nonzero if VALUE is finite and not NaN.  */\n__MATHDECL_1(int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_MISC\n# if (!defined __cplusplus \\\n      || __cplusplus < 201103L /* isinf conflicts with C++11.  */ \\\n      || __MATH_DECLARING_DOUBLE == 0)\t/* isinff or isinfl don't.  */\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n# endif\n\n/* Return nonzero if VALUE is finite and not NaN.  */\n__MATHDECL_1(int, finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return the remainder of X/Y.  */\n__MATHCALL(drem,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the fractional part of X after dividing out `ilogb (X)'.  */\n__MATHCALL(significand,, (_Mdouble_ __x));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return X with its signed changed to Y's.  */\n__MATHCALLX(copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return representation of qNaN for double type.  */\n__MATHCALLX(nan,, (const char *__tagb), (__const__));\n__END_NAMESPACE_C99\n#endif\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n#if defined __USE_MISC || defined __USE_XOPEN\n# if (!defined __cplusplus \\\n      || __cplusplus < 201103L /* isnan conflicts with C++11.  */ \\\n      || __MATH_DECLARING_DOUBLE == 0)\t/* isnanf or isnanl don't.  */\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n# endif\n\n/* Bessel functions.  */\n__MATHCALL(j0,, (_Mdouble_));\n__MATHCALL(j1,, (_Mdouble_));\n__MATHCALL(jn,, (int, _Mdouble_));\n__MATHCALL(y0,, (_Mdouble_));\n__MATHCALL(y1,, (_Mdouble_));\n__MATHCALL(yn,, (int, _Mdouble_));\n#endif\n\n#if defined __USE_XOPEN || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Error and gamma functions.  */\n__MATHCALL(erf,, (_Mdouble_));\n__MATHCALL(erfc,, (_Mdouble_));\n__MATHCALL(lgamma,, (_Mdouble_));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* True gamma function.  */\n__MATHCALL(tgamma,, (_Mdouble_));\n__END_NAMESPACE_C99\n#endif\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Obsolete alias for `lgamma'.  */\n__MATHCALL(gamma,, (_Mdouble_));\n#endif\n\n#ifdef __USE_MISC\n/* Reentrant version of lgamma.  This function uses the global variable\n   `signgam'.  The reentrant version instead takes a pointer and stores\n   the value through it.  */\n__MATHCALL(lgamma, _r, (_Mdouble_, int *__signgamp));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return the integer nearest X in the direction of the\n   prevailing rounding mode.  */\n__MATHCALL(rint,, (_Mdouble_ __x));\n\n/* Return X + epsilon if X < Y, X - epsilon if X > Y.  */\n__MATHCALLX(nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n# if defined __USE_ISOC99 && !defined __LDBL_COMPAT\n__MATHCALLX(nexttoward,, (_Mdouble_ __x, long double __y), (__const__));\n# endif\n\n/* Return the remainder of integer divison X / Y with infinite precision.  */\n__MATHCALL(remainder,, (_Mdouble_ __x, _Mdouble_ __y));\n\n# ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbn,, (_Mdouble_ __x, int __n));\n# endif\n\n/* Return the binary exponent of X, which must be nonzero.  */\n__MATHDECL(int, ilogb,, (_Mdouble_ __x));\n#endif\n\n#ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbln,, (_Mdouble_ __x, long int __n));\n\n/* Round X to integral value in floating-point format using current\n   rounding direction, but do not raise inexact exception.  */\n__MATHCALL(nearbyint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHCALLX(round,, (_Mdouble_ __x), (__const__));\n\n/* Round X to the integral value in floating-point format nearest but\n   not larger in magnitude.  */\n__MATHCALLX(trunc,, (_Mdouble_ __x), (__const__));\n\n/* Compute remainder of X and Y and put in *QUO a value with sign of x/y\n   and magnitude congruent `mod 2^n' to the magnitude of the integral\n   quotient x/y, with n >= 3.  */\n__MATHCALL(remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));\n\n/* Conversion functions.  */\n\n/* Round X to nearest integral value according to current rounding\n   direction.  */\n__MATHDECL(long int, lrint,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llrint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHDECL(long int, lround,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llround,, (_Mdouble_ __x));\n\n/* Return positive difference between X and Y.  */\n__MATHCALL(fdim,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return maximum numeric value from X and Y.  */\n__MATHCALLX(fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Return minimum numeric value from X and Y.  */\n__MATHCALLX(fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Classify given number.  */\n__MATHDECL_1(int, __fpclassify,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Test for negative number.  */\n__MATHDECL_1(int, __signbit,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Multiply-add function computed as a ternary operation.  */\n__MATHCALL(fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Test for signaling NaN.  */\n__MATHDECL_1(int, __issignaling,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalb,, (_Mdouble_ __x, _Mdouble_ __n));\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/mathdef.h",
    "content": "/* Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _MATH_H && !defined _COMPLEX_H\n# error \"Never use <bits/mathdef.h> directly; include <math.h> instead\"\n#endif\n\n#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF\n# define _MATH_H_MATHDEF\t1\n\n# if defined __x86_64__ || (defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 0)\n/* The x86-64 architecture computes values with the precission of the\n   used type.  Similarly for -m32 -mfpmath=sse.  */\ntypedef float float_t;\t\t/* `float' expressions are evaluated as `float'.  */\ntypedef double double_t;\t/* `double' expressions are evaluated\n\t\t\t\t   as `double'.  */\n# else\n/* The ix87 FPUs evaluate all values in the 80 bit floating-point format\n   which is also available for the user as `long double'.  Therefore we\n   define:  */\ntypedef long double float_t;\t/* `float' expressions are evaluated as\n\t\t\t\t   `long double'.  */\ntypedef long double double_t;\t/* `double' expressions are evaluated as\n\t\t\t\t   `long double'.  */\n# endif\n\n/* The values returned by `ilogb' for 0 and NaN respectively.  */\n# define FP_ILOGB0\t(-2147483647 - 1)\n# define FP_ILOGBNAN\t(-2147483647 - 1)\n\n/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}\n   builtins are supported.  */\n# ifdef __FP_FAST_FMA\n#  define FP_FAST_FMA 1\n# endif\n\n# ifdef __FP_FAST_FMAF\n#  define FP_FAST_FMAF 1\n# endif\n\n# ifdef __FP_FAST_FMAL\n#  define FP_FAST_FMAL 1\n# endif\n\n#endif\t\t\t\t/* ISO C99 */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/mman-linux.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux generic version.\n   Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n# error \"Never use <bits/mman-linux.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.\n\n   This file is also used by some non-Linux configurations of the\n   GNU C Library, for other systems that use these same bit values.  */\n\n/* Protections are chosen from these bits, OR'd together.  The\n   implementation does not necessarily support PROT_EXEC or PROT_WRITE\n   without PROT_READ.  The only guarantees are that no writing will be\n   allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */\n\n#define PROT_READ\t0x1\t/* Page can be read.  */\n#define PROT_WRITE\t0x2\t/* Page can be written.  */\n#define PROT_EXEC\t0x4\t/* Page can be executed.  */\n#define PROT_NONE\t0x0\t/* Page can not be accessed.  */\n#define PROT_GROWSDOWN\t0x01000000\t/* Extend change to start of\n\t\t\t\t\t   growsdown vma (mprotect only).  */\n#define PROT_GROWSUP\t0x02000000\t/* Extend change to start of\n\t\t\t\t\t   growsup vma (mprotect only).  */\n\n/* Sharing types (must choose one and only one of these).  */\n#define MAP_SHARED\t0x01\t/* Share changes.  */\n#define MAP_PRIVATE\t0x02\t/* Changes are private.  */\n#ifdef __USE_MISC\n# define MAP_TYPE\t0x0f\t/* Mask for type of mapping.  */\n#endif\n\n/* Other flags.  */\n#define MAP_FIXED\t0x10\t/* Interpret addr exactly.  */\n#ifdef __USE_MISC\n# define MAP_FILE\t0\n# ifdef __MAP_ANONYMOUS\n#  define MAP_ANONYMOUS\t__MAP_ANONYMOUS\t/* Don't use a file.  */\n# else\n#  define MAP_ANONYMOUS\t0x20\t/* Don't use a file.  */\n# endif\n# define MAP_ANON\tMAP_ANONYMOUS\n/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.  */\n# define MAP_HUGE_SHIFT\t26\n# define MAP_HUGE_MASK\t0x3f\n#endif\n\n/* Flags to `msync'.  */\n#define MS_ASYNC\t1\t/* Sync memory asynchronously.  */\n#define MS_SYNC\t\t4\t/* Synchronous memory sync.  */\n#define MS_INVALIDATE\t2\t/* Invalidate the caches.  */\n\n/* Flags for `mremap'.  */\n#ifdef __USE_GNU\n# define MREMAP_MAYMOVE\t1\n# define MREMAP_FIXED\t2\n#endif\n\n/* Advice to `madvise'.  */\n#ifdef __USE_MISC\n# define MADV_NORMAL\t  0\t/* No further special treatment.  */\n# define MADV_RANDOM\t  1\t/* Expect random page references.  */\n# define MADV_SEQUENTIAL  2\t/* Expect sequential page references.  */\n# define MADV_WILLNEED\t  3\t/* Will need these pages.  */\n# define MADV_DONTNEED\t  4\t/* Don't need these pages.  */\n# define MADV_REMOVE\t  9\t/* Remove these pages and resources.  */\n# define MADV_DONTFORK\t  10\t/* Do not inherit across fork.  */\n# define MADV_DOFORK\t  11\t/* Do inherit across fork.  */\n# define MADV_MERGEABLE\t  12\t/* KSM may merge identical pages.  */\n# define MADV_UNMERGEABLE 13\t/* KSM may not merge identical pages.  */\n# define MADV_HUGEPAGE\t  14\t/* Worth backing with hugepages.  */\n# define MADV_NOHUGEPAGE  15\t/* Not worth backing with hugepages.  */\n# define MADV_DONTDUMP\t  16\t/* Explicity exclude from the core dump,\n\t\t\t\t   overrides the coredump filter bits.  */\n# define MADV_DODUMP\t  17\t/* Clear the MADV_DONTDUMP flag.  */\n# define MADV_HWPOISON\t  100\t/* Poison a page for testing.  */\n#endif\n\n/* The POSIX people had to invent similar names for the same things.  */\n#ifdef __USE_XOPEN2K\n# define POSIX_MADV_NORMAL\t0\t/* No further special treatment.  */\n# define POSIX_MADV_RANDOM\t1\t/* Expect random page references.  */\n# define POSIX_MADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n# define POSIX_MADV_WILLNEED\t3\t/* Will need these pages.  */\n# define POSIX_MADV_DONTNEED\t4\t/* Don't need these pages.  */\n#endif\n\n/* Flags for `mlockall'.  */\n#ifndef MCL_CURRENT\n# define MCL_CURRENT\t1\t/* Lock all currently mapped pages.  */\n# define MCL_FUTURE\t2\t/* Lock all additions to address\n\t\t\t\t   space.  */\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/mman.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux/x86_64 version.\n   Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n# error \"Never use <bits/mman.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.  */\n\n/* Other flags.  */\n#ifdef __USE_MISC\n# define MAP_32BIT\t0x40\t/* Only give out 32-bit addresses.  */\n#endif\n\n/* These are Linux-specific.  */\n#ifdef __USE_MISC\n# define MAP_GROWSDOWN\t0x00100\t/* Stack-like segment.  */\n# define MAP_DENYWRITE\t0x00800\t/* ETXTBSY */\n# define MAP_EXECUTABLE\t0x01000\t/* Mark it as an executable.  */\n# define MAP_LOCKED\t0x02000\t/* Lock the mapping.  */\n# define MAP_NORESERVE\t0x04000\t/* Don't check for reservations.  */\n# define MAP_POPULATE\t0x08000\t/* Populate (prefault) pagetables.  */\n# define MAP_NONBLOCK\t0x10000\t/* Do not block on IO.  */\n# define MAP_STACK\t0x20000\t/* Allocation is for a stack.  */\n# define MAP_HUGETLB\t0x40000\t/* Create huge page mapping.  */\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/mman-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/nan.h",
    "content": "/* `NAN' constant for IEEE 754 machines.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n# error \"Never use <bits/nan.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE Not A Number.  */\n\n#if __GNUC_PREREQ(3,3)\n\n# define NAN\t(__builtin_nanf (\"\"))\n\n#elif defined __GNUC__\n\n# define NAN \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; })  \\\n    { __l: 0x7fc00000UL }).__d)\n\n#else\n\n# include <endian.h>\n\n# if __BYTE_ORDER == __BIG_ENDIAN\n#  define __qnan_bytes\t\t{ 0x7f, 0xc0, 0, 0 }\n# endif\n# if __BYTE_ORDER == __LITTLE_ENDIAN\n#  define __qnan_bytes\t\t{ 0, 0, 0xc0, 0x7f }\n# endif\n\nstatic union {\n\tunsigned char __c[4];\n\tfloat __d;\n} __qnan_union __attribute__ ((__unused__)) = {\n__qnan_bytes};\n\n# define NAN\t(__qnan_union.__d)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/netdb.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _NETDB_H\n# error \"Never include <bits/netdb.h> directly; use <netdb.h> instead.\"\n#endif\n\n/* Description of data base entry for a single network.  NOTE: here a\n   poor assumption is made.  The network number is expected to fit\n   into an unsigned long int variable.  */\nstruct netent {\n\tchar *n_name;\t\t/* Official name of network.  */\n\tchar **n_aliases;\t/* Alias list.  */\n\tint n_addrtype;\t\t/* Net address type.  */\n\tuint32_t n_net;\t\t/* Network number.  */\n};\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/param.h",
    "content": "/* Old-style Unix parameters and limits.  Linux version.\n   Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n# error \"Never use <bits/param.h> directly; include <sys/param.h> instead.\"\n#endif\n\n#ifndef ARG_MAX\n# define __undef_ARG_MAX\n#endif\n\n#include <linux/limits.h>\n#include <linux/param.h>\n\n/* The kernel headers define ARG_MAX.  The value is wrong, though.  */\n#ifdef __undef_ARG_MAX\n# undef ARG_MAX\n# undef __undef_ARG_MAX\n#endif\n\n#define\tMAXSYMLINKS\t20\n\n/* The following are not really correct but it is a value we used for a\n   long time and which seems to be usable.  People should not use NOFILE\n   and NCARGS anyway.  */\n#define NOFILE\t\t256\n#define\tNCARGS\t\t131072\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/posix1_lim.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.9.2 Minimum Values\tAdded to <limits.h>\n *\n *\tNever include this file directly; use <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX1_LIM_H\n#define\t_BITS_POSIX1_LIM_H\t1\n\n/* These are the standard-mandated minimum values.  */\n\n/* Minimum number of operations in one list I/O call.  */\n#define _POSIX_AIO_LISTIO_MAX\t2\n\n/* Minimal number of outstanding asynchronous I/O operations.  */\n#define _POSIX_AIO_MAX\t\t1\n\n/* Maximum length of arguments to `execve', including environment.  */\n#define\t_POSIX_ARG_MAX\t\t4096\n\n/* Maximum simultaneous processes per real user ID.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_CHILD_MAX\t25\n#else\n# define _POSIX_CHILD_MAX\t6\n#endif\n\n/* Minimal number of timer expiration overruns.  */\n#define _POSIX_DELAYTIMER_MAX\t32\n\n/* Maximum length of a host name (not including the terminating null)\n   as returned from the GETHOSTNAME function.  */\n#define _POSIX_HOST_NAME_MAX\t255\n\n/* Maximum link count of a file.  */\n#define\t_POSIX_LINK_MAX\t\t8\n\n/* Maximum length of login name.  */\n#define\t_POSIX_LOGIN_NAME_MAX\t9\n\n/* Number of bytes in a terminal canonical input queue.  */\n#define\t_POSIX_MAX_CANON\t255\n\n/* Number of bytes for which space will be\n   available in a terminal input queue.  */\n#define\t_POSIX_MAX_INPUT\t255\n\n/* Maximum number of message queues open for a process.  */\n#define _POSIX_MQ_OPEN_MAX\t8\n\n/* Maximum number of supported message priorities.  */\n#define _POSIX_MQ_PRIO_MAX\t32\n\n/* Number of bytes in a filename.  */\n#define\t_POSIX_NAME_MAX\t\t14\n\n/* Number of simultaneous supplementary group IDs per process.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_NGROUPS_MAX\t8\n#else\n# define _POSIX_NGROUPS_MAX\t0\n#endif\n\n/* Number of files one process can have open at once.  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_OPEN_MAX\t20\n#else\n# define _POSIX_OPEN_MAX\t16\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Number of descriptors that a process may examine with `pselect' or\n   `select'.  */\n# define _POSIX_FD_SETSIZE\t_POSIX_OPEN_MAX\n#endif\n\n/* Number of bytes in a pathname.  */\n#define\t_POSIX_PATH_MAX\t\t256\n\n/* Number of bytes than can be written atomically to a pipe.  */\n#define\t_POSIX_PIPE_BUF\t\t512\n\n/* The number of repeated occurrences of a BRE permitted by the\n   REGEXEC and REGCOMP functions when using the interval notation.  */\n#define _POSIX_RE_DUP_MAX\t255\n\n/* Minimal number of realtime signals reserved for the application.  */\n#define _POSIX_RTSIG_MAX\t8\n\n/* Number of semaphores a process can have.  */\n#define _POSIX_SEM_NSEMS_MAX\t256\n\n/* Maximal value of a semaphore.  */\n#define _POSIX_SEM_VALUE_MAX\t32767\n\n/* Number of pending realtime signals.  */\n#define _POSIX_SIGQUEUE_MAX\t32\n\n/* Largest value of a `ssize_t'.  */\n#define\t_POSIX_SSIZE_MAX\t32767\n\n/* Number of streams a process can have open at once.  */\n#define\t_POSIX_STREAM_MAX\t8\n\n/* The number of bytes in a symbolic link.  */\n#define _POSIX_SYMLINK_MAX\t255\n\n/* The number of symbolic links that can be traversed in the\n   resolution of a pathname in the absence of a loop.  */\n#define _POSIX_SYMLOOP_MAX\t8\n\n/* Number of timer for a process.  */\n#define _POSIX_TIMER_MAX\t32\n\n/* Maximum number of characters in a tty name.  */\n#define\t_POSIX_TTY_NAME_MAX\t9\n\n/* Maximum length of a timezone name (element of `tzname').  */\n#ifdef __USE_XOPEN2K\n# define _POSIX_TZNAME_MAX\t6\n#else\n# define _POSIX_TZNAME_MAX\t3\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Maximum number of connections that can be queued on a socket.  */\n# define _POSIX_QLIMIT\t\t1\n\n/* Maximum number of bytes that can be buffered on a socket for send\n   or receive.  */\n# define _POSIX_HIWAT\t\t_POSIX_PIPE_BUF\n\n/* Maximum number of elements in an `iovec' array.  */\n# define _POSIX_UIO_MAXIOV\t16\n#endif\n\n/* Maximum clock resolution in nanoseconds.  */\n#define _POSIX_CLOCKRES_MIN\t20000000\n\n/* Get the implementation-specific values for the above.  */\n#include <bits/local_lim.h>\n\n#ifndef\tSSIZE_MAX\n# define SSIZE_MAX\tLONG_MAX\n#endif\n\n/* This value is a guaranteed minimum maximum.\n   The current maximum can be got from `sysconf'.  */\n\n#ifndef\tNGROUPS_MAX\n# define NGROUPS_MAX\t8\n#endif\n\n#endif\t\t\t\t/* bits/posix1_lim.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/posix2_lim.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; include <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX2_LIM_H\n#define\t_BITS_POSIX2_LIM_H\t1\n\n/* The maximum `ibase' and `obase' values allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_BASE_MAX\t\t99\n\n/* The maximum number of elements allowed in an array by the `bc' utility.  */\n#define\t_POSIX2_BC_DIM_MAX\t\t2048\n\n/* The maximum `scale' value allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_SCALE_MAX\t\t99\n\n/* The maximum length of a string constant accepted by the `bc' utility.  */\n#define\t_POSIX2_BC_STRING_MAX\t\t1000\n\n/* The maximum number of weights that can be assigned to an entry of\n   the LC_COLLATE `order' keyword in the locale definition file.  */\n#define\t_POSIX2_COLL_WEIGHTS_MAX\t2\n\n/* The maximum number of expressions that can be nested\n   within parentheses by the `expr' utility.  */\n#define\t_POSIX2_EXPR_NEST_MAX\t\t32\n\n/* The maximum length, in bytes, of an input line.  */\n#define\t_POSIX2_LINE_MAX\t\t2048\n\n/* The maximum number of repeated occurrences of a regular expression\n   permitted when using the interval notation `\\{M,N\\}'.  */\n#define\t_POSIX2_RE_DUP_MAX\t\t255\n\n/* The maximum number of bytes in a character class name.  We have no\n   fixed limit, 2048 is a high number.  */\n#define\t_POSIX2_CHARCLASS_NAME_MAX\t14\n\n/* These values are implementation-specific,\n   and may vary within the implementation.\n   Their precise values can be obtained from sysconf.  */\n\n#ifndef\tBC_BASE_MAX\n#define\tBC_BASE_MAX\t\t_POSIX2_BC_BASE_MAX\n#endif\n#ifndef\tBC_DIM_MAX\n#define\tBC_DIM_MAX\t\t_POSIX2_BC_DIM_MAX\n#endif\n#ifndef\tBC_SCALE_MAX\n#define\tBC_SCALE_MAX\t\t_POSIX2_BC_SCALE_MAX\n#endif\n#ifndef\tBC_STRING_MAX\n#define\tBC_STRING_MAX\t\t_POSIX2_BC_STRING_MAX\n#endif\n#ifndef\tCOLL_WEIGHTS_MAX\n#define\tCOLL_WEIGHTS_MAX\t255\n#endif\n#ifndef\tEXPR_NEST_MAX\n#define\tEXPR_NEST_MAX\t\t_POSIX2_EXPR_NEST_MAX\n#endif\n#ifndef\tLINE_MAX\n#define\tLINE_MAX\t\t_POSIX2_LINE_MAX\n#endif\n#ifndef\tCHARCLASS_NAME_MAX\n#define\tCHARCLASS_NAME_MAX\t2048\n#endif\n\n/* This value is defined like this in regex.h.  */\n#define\tRE_DUP_MAX (0x7fff)\n\n#endif\t\t\t\t/* bits/posix2_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/posix_opt.h",
    "content": "/* Define POSIX options for Linux.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_BITS_POSIX_OPT_H\n#define\t_BITS_POSIX_OPT_H\t1\n\n/* Job control is supported.  */\n#define\t_POSIX_JOB_CONTROL\t1\n\n/* Processes have a saved set-user-ID and a saved set-group-ID.  */\n#define\t_POSIX_SAVED_IDS\t1\n\n/* Priority scheduling is supported.  */\n#define\t_POSIX_PRIORITY_SCHEDULING\t200809L\n\n/* Synchronizing file data is supported.  */\n#define\t_POSIX_SYNCHRONIZED_IO\t200809L\n\n/* The fsync function is present.  */\n#define\t_POSIX_FSYNC\t200809L\n\n/* Mapping of files to memory is supported.  */\n#define\t_POSIX_MAPPED_FILES\t200809L\n\n/* Locking of all memory is supported.  */\n#define\t_POSIX_MEMLOCK\t200809L\n\n/* Locking of ranges of memory is supported.  */\n#define\t_POSIX_MEMLOCK_RANGE\t200809L\n\n/* Setting of memory protections is supported.  */\n#define\t_POSIX_MEMORY_PROTECTION\t200809L\n\n/* Some filesystems allow all users to change file ownership.  */\n#define\t_POSIX_CHOWN_RESTRICTED\t0\n\n/* `c_cc' member of 'struct termios' structure can be disabled by\n   using the value _POSIX_VDISABLE.  */\n#define\t_POSIX_VDISABLE\t'\\0'\n\n/* Filenames are not silently truncated.  */\n#define\t_POSIX_NO_TRUNC\t1\n\n/* X/Open realtime support is available.  */\n#define _XOPEN_REALTIME\t1\n\n/* X/Open thread realtime support is available.  */\n#define _XOPEN_REALTIME_THREADS\t1\n\n/* XPG4.2 shared memory is supported.  */\n#define\t_XOPEN_SHM\t1\n\n/* Tell we have POSIX threads.  */\n#define _POSIX_THREADS\t200809L\n\n/* We have the reentrant functions described in POSIX.  */\n#define _POSIX_REENTRANT_FUNCTIONS      1\n#define _POSIX_THREAD_SAFE_FUNCTIONS\t200809L\n\n/* We provide priority scheduling for threads.  */\n#define _POSIX_THREAD_PRIORITY_SCHEDULING\t200809L\n\n/* We support user-defined stack sizes.  */\n#define _POSIX_THREAD_ATTR_STACKSIZE\t200809L\n\n/* We support user-defined stacks.  */\n#define _POSIX_THREAD_ATTR_STACKADDR\t200809L\n\n/* We support priority inheritence.  */\n#define _POSIX_THREAD_PRIO_INHERIT\t200809L\n\n/* We support priority protection, though only for non-robust\n   mutexes.  */\n#define _POSIX_THREAD_PRIO_PROTECT\t200809L\n\n#ifdef __USE_XOPEN2K8\n/* We support priority inheritence for robust mutexes.  */\n# define _POSIX_THREAD_ROBUST_PRIO_INHERIT\t200809L\n\n/* We do not support priority protection for robust mutexes.  */\n# define _POSIX_THREAD_ROBUST_PRIO_PROTECT\t-1\n#endif\n\n/* We support POSIX.1b semaphores.  */\n#define _POSIX_SEMAPHORES\t200809L\n\n/* Real-time signals are supported.  */\n#define _POSIX_REALTIME_SIGNALS\t200809L\n\n/* We support asynchronous I/O.  */\n#define _POSIX_ASYNCHRONOUS_IO\t200809L\n#define _POSIX_ASYNC_IO\t\t1\n/* Alternative name for Unix98.  */\n#define _LFS_ASYNCHRONOUS_IO\t1\n/* Support for prioritization is also available.  */\n#define _POSIX_PRIORITIZED_IO\t200809L\n\n/* The LFS support in asynchronous I/O is also available.  */\n#define _LFS64_ASYNCHRONOUS_IO\t1\n\n/* The rest of the LFS is also available.  */\n#define _LFS_LARGEFILE\t\t1\n#define _LFS64_LARGEFILE\t1\n#define _LFS64_STDIO\t\t1\n\n/* POSIX shared memory objects are implemented.  */\n#define _POSIX_SHARED_MEMORY_OBJECTS\t200809L\n\n/* CPU-time clocks support needs to be checked at runtime.  */\n#define _POSIX_CPUTIME\t0\n\n/* Clock support in threads must be also checked at runtime.  */\n#define _POSIX_THREAD_CPUTIME\t0\n\n/* GNU libc provides regular expression handling.  */\n#define _POSIX_REGEXP\t1\n\n/* Reader/Writer locks are available.  */\n#define _POSIX_READER_WRITER_LOCKS\t200809L\n\n/* We have a POSIX shell.  */\n#define _POSIX_SHELL\t1\n\n/* We support the Timeouts option.  */\n#define _POSIX_TIMEOUTS\t200809L\n\n/* We support spinlocks.  */\n#define _POSIX_SPIN_LOCKS\t200809L\n\n/* The `spawn' function family is supported.  */\n#define _POSIX_SPAWN\t200809L\n\n/* We have POSIX timers.  */\n#define _POSIX_TIMERS\t200809L\n\n/* The barrier functions are available.  */\n#define _POSIX_BARRIERS\t200809L\n\n/* POSIX message queues are available.  */\n#define\t_POSIX_MESSAGE_PASSING\t200809L\n\n/* Thread process-shared synchronization is supported.  */\n#define _POSIX_THREAD_PROCESS_SHARED\t200809L\n\n/* The monotonic clock might be available.  */\n#define _POSIX_MONOTONIC_CLOCK\t0\n\n/* The clock selection interfaces are available.  */\n#define _POSIX_CLOCK_SELECTION\t200809L\n\n/* Advisory information interfaces are available.  */\n#define _POSIX_ADVISORY_INFO\t200809L\n\n/* IPv6 support is available.  */\n#define _POSIX_IPV6\t200809L\n\n/* Raw socket support is available.  */\n#define _POSIX_RAW_SOCKETS\t200809L\n\n/* We have at least one terminal.  */\n#define _POSIX2_CHAR_TERM\t200809L\n\n/* Neither process nor thread sporadic server interfaces is available.  */\n#define _POSIX_SPORADIC_SERVER\t-1\n#define _POSIX_THREAD_SPORADIC_SERVER\t-1\n\n/* trace.h is not available.  */\n#define _POSIX_TRACE\t-1\n#define _POSIX_TRACE_EVENT_FILTER\t-1\n#define _POSIX_TRACE_INHERIT\t-1\n#define _POSIX_TRACE_LOG\t-1\n\n/* Typed memory objects are not available.  */\n#define _POSIX_TYPED_MEMORY_OBJECTS\t-1\n\n#endif\t\t\t\t/* bits/posix_opt.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/pthreadtypes.h",
    "content": "/* Copyright (C) 2002-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_PTHREADTYPES_H\n#define _BITS_PTHREADTYPES_H\t1\n\n#include <bits/wordsize.h>\n\n#ifdef __x86_64__\n# if __WORDSIZE == 64\n#  define __SIZEOF_PTHREAD_ATTR_T 56\n#  define __SIZEOF_PTHREAD_MUTEX_T 40\n#  define __SIZEOF_PTHREAD_MUTEXATTR_T 4\n#  define __SIZEOF_PTHREAD_COND_T 48\n#  define __SIZEOF_PTHREAD_CONDATTR_T 4\n#  define __SIZEOF_PTHREAD_RWLOCK_T 56\n#  define __SIZEOF_PTHREAD_RWLOCKATTR_T 8\n#  define __SIZEOF_PTHREAD_BARRIER_T 32\n#  define __SIZEOF_PTHREAD_BARRIERATTR_T 4\n# else\n#  define __SIZEOF_PTHREAD_ATTR_T 32\n#  define __SIZEOF_PTHREAD_MUTEX_T 32\n#  define __SIZEOF_PTHREAD_MUTEXATTR_T 4\n#  define __SIZEOF_PTHREAD_COND_T 48\n#  define __SIZEOF_PTHREAD_CONDATTR_T 4\n#  define __SIZEOF_PTHREAD_RWLOCK_T 44\n#  define __SIZEOF_PTHREAD_RWLOCKATTR_T 8\n#  define __SIZEOF_PTHREAD_BARRIER_T 20\n#  define __SIZEOF_PTHREAD_BARRIERATTR_T 4\n# endif\n#else\n# define __SIZEOF_PTHREAD_ATTR_T 36\n# define __SIZEOF_PTHREAD_MUTEX_T 24\n# define __SIZEOF_PTHREAD_MUTEXATTR_T 4\n# define __SIZEOF_PTHREAD_COND_T 48\n# define __SIZEOF_PTHREAD_CONDATTR_T 4\n# define __SIZEOF_PTHREAD_RWLOCK_T 32\n# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8\n# define __SIZEOF_PTHREAD_BARRIER_T 20\n# define __SIZEOF_PTHREAD_BARRIERATTR_T 4\n#endif\n\n/* Thread identifiers.  The structure of the attribute type is not\n   exposed on purpose.  */\ntypedef unsigned long int pthread_t;\n\nunion pthread_attr_t {\n\tchar __size[__SIZEOF_PTHREAD_ATTR_T];\n\tlong int __align;\n};\n#ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n# define __have_pthread_attr_t\t1\n#endif\n\n#ifdef __x86_64__\ntypedef struct __pthread_internal_list {\n\tstruct __pthread_internal_list *__prev;\n\tstruct __pthread_internal_list *__next;\n} __pthread_list_t;\n#else\ntypedef struct __pthread_internal_slist {\n\tstruct __pthread_internal_slist *__next;\n} __pthread_slist_t;\n#endif\n\n/* Data structures for mutex handling.  The structure of the attribute\n   type is not exposed on purpose.  */\ntypedef union {\n\tstruct __pthread_mutex_s {\n\t\tint __lock;\n\t\tunsigned int __count;\n\t\tint __owner;\n#ifdef __x86_64__\n\t\tunsigned int __nusers;\n#endif\n\t\t/* KIND must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tint __kind;\n#ifdef __x86_64__\n\t\tshort __spins;\n\t\tshort __elision;\n\t\t__pthread_list_t __list;\n# define __PTHREAD_MUTEX_HAVE_PREV\t1\n/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */\n# define __PTHREAD_SPINS             0, 0\n#else\n\t\tunsigned int __nusers;\n\t\t__extension__ union {\n\t\t\tstruct {\n\t\t\t\tshort __espins;\n\t\t\t\tshort __elision;\n# define __spins __elision_data.__espins\n# define __elision __elision_data.__elision\n# define __PTHREAD_SPINS         { 0, 0 }\n\t\t\t} __elision_data;\n\t\t\t__pthread_slist_t __list;\n\t\t};\n#endif\n\t} __data;\n\tchar __size[__SIZEOF_PTHREAD_MUTEX_T];\n\tlong int __align;\n} pthread_mutex_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_MUTEXATTR_T];\n\tint __align;\n} pthread_mutexattr_t;\n\n/* Data structure for conditional variable handling.  The structure of\n   the attribute type is not exposed on purpose.  */\ntypedef union {\n\tstruct {\n\t\tint __lock;\n\t\tunsigned int __futex;\n\t\t__extension__ unsigned long long int __total_seq;\n\t\t__extension__ unsigned long long int __wakeup_seq;\n\t\t__extension__ unsigned long long int __woken_seq;\n\t\tvoid *__mutex;\n\t\tunsigned int __nwaiters;\n\t\tunsigned int __broadcast_seq;\n\t} __data;\n\tchar __size[__SIZEOF_PTHREAD_COND_T];\n\t__extension__ long long int __align;\n} pthread_cond_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_CONDATTR_T];\n\tint __align;\n} pthread_condattr_t;\n\n/* Keys for thread-specific data */\ntypedef unsigned int pthread_key_t;\n\n/* Once-only execution */\ntypedef int pthread_once_t;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Data structure for read-write lock variable handling.  The\n   structure of the attribute type is not exposed on purpose.  */\ntypedef union {\n# ifdef __x86_64__\n\tstruct {\n\t\tint __lock;\n\t\tunsigned int __nr_readers;\n\t\tunsigned int __readers_wakeup;\n\t\tunsigned int __writer_wakeup;\n\t\tunsigned int __nr_readers_queued;\n\t\tunsigned int __nr_writers_queued;\n\t\tint __writer;\n\t\tint __shared;\n\t\tsigned char __rwelision;\n#  ifdef  __ILP32__\n\t\tunsigned char __pad1[3];\n#    define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0 }\n#  else\n\t\tunsigned char __pad1[7];\n#    define __PTHREAD_RWLOCK_ELISION_EXTRA 0, { 0, 0, 0, 0, 0, 0, 0 }\n#  endif\n\t\tunsigned long int __pad2;\n\t\t/* FLAGS must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tunsigned int __flags;\n# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED\t1\n\t} __data;\n# else\n\tstruct {\n\t\tint __lock;\n\t\tunsigned int __nr_readers;\n\t\tunsigned int __readers_wakeup;\n\t\tunsigned int __writer_wakeup;\n\t\tunsigned int __nr_readers_queued;\n\t\tunsigned int __nr_writers_queued;\n\t\t/* FLAGS must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tunsigned char __flags;\n\t\tunsigned char __shared;\n\t\tsigned char __rwelision;\n# define __PTHREAD_RWLOCK_ELISION_EXTRA 0\n\t\tunsigned char __pad2;\n\t\tint __writer;\n\t} __data;\n# endif\n\tchar __size[__SIZEOF_PTHREAD_RWLOCK_T];\n\tlong int __align;\n} pthread_rwlock_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];\n\tlong int __align;\n} pthread_rwlockattr_t;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* POSIX spinlock data type.  */\ntypedef volatile int pthread_spinlock_t;\n\n/* POSIX barriers data type.  The structure of the type is\n   deliberately not exposed.  */\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIER_T];\n\tlong int __align;\n} pthread_barrier_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIERATTR_T];\n\tint __align;\n} pthread_barrierattr_t;\n#endif\n\n#ifndef __x86_64__\n/* Extra attributes for the cleanup functions.  */\n# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))\n#endif\n\n#endif\t\t\t\t/* bits/pthreadtypes.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/resource.h",
    "content": "/* Bit values & structures for resource limits.  Linux version.\n   Copyright (C) 1994-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_RESOURCE_H\n# error \"Never use <bits/resource.h> directly; include <sys/resource.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\n/* Transmute defines to enumerations.  The macro re-definitions are\n   necessary because some programs want to test for operating system\n   features with #ifdef RUSAGE_SELF.  In ISO C the reflexive\n   definition is a no-op.  */\n\n/* Kinds of resource limit.  */\nenum __rlimit_resource {\n\t/* Per-process CPU limit, in seconds.  */\n\tRLIMIT_CPU = 0,\n#define RLIMIT_CPU RLIMIT_CPU\n\n\t/* Largest file that can be created, in bytes.  */\n\tRLIMIT_FSIZE = 1,\n#define\tRLIMIT_FSIZE RLIMIT_FSIZE\n\n\t/* Maximum size of data segment, in bytes.  */\n\tRLIMIT_DATA = 2,\n#define\tRLIMIT_DATA RLIMIT_DATA\n\n\t/* Maximum size of stack segment, in bytes.  */\n\tRLIMIT_STACK = 3,\n#define\tRLIMIT_STACK RLIMIT_STACK\n\n\t/* Largest core file that can be created, in bytes.  */\n\tRLIMIT_CORE = 4,\n#define\tRLIMIT_CORE RLIMIT_CORE\n\n\t/* Largest resident set size, in bytes.\n\t   This affects swapping; processes that are exceeding their\n\t   resident set size will be more likely to have physical memory\n\t   taken from them.  */\n\t__RLIMIT_RSS = 5,\n#define\tRLIMIT_RSS __RLIMIT_RSS\n\n\t/* Number of open files.  */\n\tRLIMIT_NOFILE = 7,\n\t__RLIMIT_OFILE = RLIMIT_NOFILE,\t/* BSD name for same.  */\n#define RLIMIT_NOFILE RLIMIT_NOFILE\n#define RLIMIT_OFILE __RLIMIT_OFILE\n\n\t/* Address space limit.  */\n\tRLIMIT_AS = 9,\n#define RLIMIT_AS RLIMIT_AS\n\n\t/* Number of processes.  */\n\t__RLIMIT_NPROC = 6,\n#define RLIMIT_NPROC __RLIMIT_NPROC\n\n\t/* Locked-in-memory address space.  */\n\t__RLIMIT_MEMLOCK = 8,\n#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK\n\n\t/* Maximum number of file locks.  */\n\t__RLIMIT_LOCKS = 10,\n#define RLIMIT_LOCKS __RLIMIT_LOCKS\n\n\t/* Maximum number of pending signals.  */\n\t__RLIMIT_SIGPENDING = 11,\n#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING\n\n\t/* Maximum bytes in POSIX message queues.  */\n\t__RLIMIT_MSGQUEUE = 12,\n#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE\n\n\t/* Maximum nice priority allowed to raise to.\n\t   Nice levels 19 .. -20 correspond to 0 .. 39\n\t   values of this resource limit.  */\n\t__RLIMIT_NICE = 13,\n#define RLIMIT_NICE __RLIMIT_NICE\n\n\t/* Maximum realtime priority allowed for non-priviledged\n\t   processes.  */\n\t__RLIMIT_RTPRIO = 14,\n#define RLIMIT_RTPRIO __RLIMIT_RTPRIO\n\n\t/* Maximum CPU time in µs that a process scheduled under a real-time\n\t   scheduling policy may consume without making a blocking system\n\t   call before being forcibly descheduled.  */\n\t__RLIMIT_RTTIME = 15,\n#define RLIMIT_RTTIME __RLIMIT_RTTIME\n\n\t__RLIMIT_NLIMITS = 16,\n\t__RLIM_NLIMITS = __RLIMIT_NLIMITS\n#define RLIMIT_NLIMITS __RLIMIT_NLIMITS\n#define RLIM_NLIMITS __RLIM_NLIMITS\n};\n\n/* Value to indicate that there is no limit.  */\n#ifndef __USE_FILE_OFFSET64\n# define RLIM_INFINITY ((__rlim_t) -1)\n#else\n# define RLIM_INFINITY 0xffffffffffffffffuLL\n#endif\n\n#ifdef __USE_LARGEFILE64\n# define RLIM64_INFINITY 0xffffffffffffffffuLL\n#endif\n\n/* We can represent all limits.  */\n#define RLIM_SAVED_MAX\tRLIM_INFINITY\n#define RLIM_SAVED_CUR\tRLIM_INFINITY\n\n/* Type for resource quantity measurement.  */\n#ifndef __USE_FILE_OFFSET64\ntypedef __rlim_t rlim_t;\n#else\ntypedef __rlim64_t rlim_t;\n#endif\n#ifdef __USE_LARGEFILE64\ntypedef __rlim64_t rlim64_t;\n#endif\n\nstruct rlimit {\n\t/* The current (soft) limit.  */\n\trlim_t rlim_cur;\n\t/* The hard limit.  */\n\trlim_t rlim_max;\n};\n\n#ifdef __USE_LARGEFILE64\nstruct rlimit64 {\n\t/* The current (soft) limit.  */\n\trlim64_t rlim_cur;\n\t/* The hard limit.  */\n\trlim64_t rlim_max;\n};\n#endif\n\n/* Whose usage statistics do you want?  */\nenum __rusage_who {\n\t/* The calling process.  */\n\tRUSAGE_SELF = 0,\n#define RUSAGE_SELF RUSAGE_SELF\n\n\t/* All of its terminated child processes.  */\n\tRUSAGE_CHILDREN = -1\n#define RUSAGE_CHILDREN RUSAGE_CHILDREN\n#ifdef __USE_GNU\n\t    ,\n\t/* The calling thread.  */\n\tRUSAGE_THREAD = 1\n# define RUSAGE_THREAD RUSAGE_THREAD\n\t    /* Name for the same functionality on Solaris.  */\n# define RUSAGE_LWP RUSAGE_THREAD\n#endif\n};\n\n#define __need_timeval\n#include <bits/time.h>\t\t/* For `struct timeval'.  */\n\n/* Structure which says how much of each resource has been used.  */\n\n/* The purpose of all the unions is to have the kernel-compatible layout\n   while keeping the API type as 'long int', and among machines where\n   __syscall_slong_t is not 'long int', this only does the right thing\n   for little-endian ones, like x32.  */\nstruct rusage {\n\t/* Total amount of user time used.  */\n\tstruct timeval ru_utime;\n\t/* Total amount of system time used.  */\n\tstruct timeval ru_stime;\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_maxrss;\n\t\t__syscall_slong_t __ru_maxrss_word;\n\t};\n\t/* Amount of sharing of text segment memory\n\t   with other processes (kilobyte-seconds).  */\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_ixrss;\n\t\t__syscall_slong_t __ru_ixrss_word;\n\t};\n\t/* Amount of data segment memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_idrss;\n\t\t__syscall_slong_t __ru_idrss_word;\n\t};\n\t/* Amount of stack memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_isrss;\n\t\t__syscall_slong_t __ru_isrss_word;\n\t};\n\t/* Number of soft page faults (i.e. those serviced by reclaiming\n\t   a page from the list of pages awaiting reallocation.  */\n\t__extension__ union {\n\t\tlong int ru_minflt;\n\t\t__syscall_slong_t __ru_minflt_word;\n\t};\n\t/* Number of hard page faults (i.e. those that required I/O).  */\n\t__extension__ union {\n\t\tlong int ru_majflt;\n\t\t__syscall_slong_t __ru_majflt_word;\n\t};\n\t/* Number of times a process was swapped out of physical memory.  */\n\t__extension__ union {\n\t\tlong int ru_nswap;\n\t\t__syscall_slong_t __ru_nswap_word;\n\t};\n\t/* Number of input operations via the file system.  Note: This\n\t   and `ru_oublock' do not include operations with the cache.  */\n\t__extension__ union {\n\t\tlong int ru_inblock;\n\t\t__syscall_slong_t __ru_inblock_word;\n\t};\n\t/* Number of output operations via the file system.  */\n\t__extension__ union {\n\t\tlong int ru_oublock;\n\t\t__syscall_slong_t __ru_oublock_word;\n\t};\n\t/* Number of IPC messages sent.  */\n\t__extension__ union {\n\t\tlong int ru_msgsnd;\n\t\t__syscall_slong_t __ru_msgsnd_word;\n\t};\n\t/* Number of IPC messages received.  */\n\t__extension__ union {\n\t\tlong int ru_msgrcv;\n\t\t__syscall_slong_t __ru_msgrcv_word;\n\t};\n\t/* Number of signals delivered.  */\n\t__extension__ union {\n\t\tlong int ru_nsignals;\n\t\t__syscall_slong_t __ru_nsignals_word;\n\t};\n\t/* Number of voluntary context switches, i.e. because the process\n\t   gave up the process before it had to (usually to wait for some\n\t   resource to be available).  */\n\t__extension__ union {\n\t\tlong int ru_nvcsw;\n\t\t__syscall_slong_t __ru_nvcsw_word;\n\t};\n\t/* Number of involuntary context switches, i.e. a higher priority process\n\t   became runnable or the current process used up its time slice.  */\n\t__extension__ union {\n\t\tlong int ru_nivcsw;\n\t\t__syscall_slong_t __ru_nivcsw_word;\n\t};\n};\n\n/* Priority limits.  */\n#define PRIO_MIN\t-20\t/* Minimum priority a process can have.  */\n#define PRIO_MAX\t20\t/* Maximum priority a process can have.  */\n\n/* The type of the WHICH argument to `getpriority' and `setpriority',\n   indicating what flavor of entity the WHO argument specifies.  */\nenum __priority_which {\n\tPRIO_PROCESS = 0,\t/* WHO is a process ID.  */\n#define PRIO_PROCESS PRIO_PROCESS\n\tPRIO_PGRP = 1,\t\t/* WHO is a process group ID.  */\n#define PRIO_PGRP PRIO_PGRP\n\tPRIO_USER = 2\t\t/* WHO is a user ID.  */\n#define PRIO_USER PRIO_USER\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Modify and return resource limits of a process atomically.  */\n# ifndef __USE_FILE_OFFSET64\nextern int prlimit(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit *__new_limit, struct rlimit *__old_limit) __THROW;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(prlimit, (__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit * __new_limit, struct rlimit * __old_limit), prlimit64);\n#  else\n#   define prlimit prlimit64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int prlimit64(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit64 *__new_limit, struct rlimit64 *__old_limit) __THROW;\n# endif\n#endif\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sched.h",
    "content": "/* Definitions of constants and data structure for POSIX 1003.1b-1993\n   scheduling interface.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __need_schedparam\n\n#ifndef _SCHED_H\n# error \"Never include <bits/sched.h> directly; use <sched.h> instead.\"\n#endif\n\n/* Scheduling algorithms.  */\n#define SCHED_OTHER\t\t0\n#define SCHED_FIFO\t\t1\n#define SCHED_RR\t\t2\n#ifdef __USE_GNU\n# define SCHED_BATCH\t\t3\n# define SCHED_IDLE\t\t5\n\n# define SCHED_RESET_ON_FORK\t0x40000000\n#endif\n\n#ifdef __USE_GNU\n/* Cloning flags.  */\n# define CSIGNAL       0x000000ff\t/* Signal mask to be sent at exit.  */\n# define CLONE_VM      0x00000100\t/* Set if VM shared between processes.  */\n# define CLONE_FS      0x00000200\t/* Set if fs info shared between processes.  */\n# define CLONE_FILES   0x00000400\t/* Set if open files shared between processes.  */\n# define CLONE_SIGHAND 0x00000800\t/* Set if signal handlers shared.  */\n# define CLONE_PTRACE  0x00002000\t/* Set if tracing continues on the child.  */\n# define CLONE_VFORK   0x00004000\t/* Set if the parent wants the child to\n\t\t\t\t\t   wake it up on mm_release.  */\n# define CLONE_PARENT  0x00008000\t/* Set if we want to have the same\n\t\t\t\t\t   parent as the cloner.  */\n# define CLONE_THREAD  0x00010000\t/* Set to add to same thread group.  */\n# define CLONE_NEWNS   0x00020000\t/* Set to create new namespace.  */\n# define CLONE_SYSVSEM 0x00040000\t/* Set to shared SVID SEM_UNDO semantics.  */\n# define CLONE_SETTLS  0x00080000\t/* Set TLS info.  */\n# define CLONE_PARENT_SETTID 0x00100000\t/* Store TID in userlevel buffer\n\t\t\t\t\t   before MM copy.  */\n# define CLONE_CHILD_CLEARTID 0x00200000\t/* Register exit futex and memory\n\t\t\t\t\t\t   location to clear.  */\n# define CLONE_DETACHED 0x00400000\t/* Create clone detached.  */\n# define CLONE_UNTRACED 0x00800000\t/* Set if the tracing process can't\n\t\t\t\t\t   force CLONE_PTRACE on this clone.  */\n# define CLONE_CHILD_SETTID 0x01000000\t/* Store TID in userlevel buffer in\n\t\t\t\t\t   the child.  */\n# define CLONE_NEWUTS\t0x04000000\t/* New utsname group.  */\n# define CLONE_NEWIPC\t0x08000000\t/* New ipcs.  */\n# define CLONE_NEWUSER\t0x10000000\t/* New user namespace.  */\n# define CLONE_NEWPID\t0x20000000\t/* New pid namespace.  */\n# define CLONE_NEWNET\t0x40000000\t/* New network namespace.  */\n# define CLONE_IO\t0x80000000\t/* Clone I/O context.  */\n#endif\n\n/* The official definition.  */\nstruct sched_param {\n\tint __sched_priority;\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Clone current process.  */\nextern int clone(int (*__fn) (void *__arg), void *__child_stack, int __flags, void *__arg, ...) __THROW;\n\n/* Unshare the specified resources.  */\nextern int unshare(int __flags) __THROW;\n\n/* Get index of currently used CPU.  */\nextern int sched_getcpu(void) __THROW;\n\n/* Switch process to namespace of type NSTYPE indicated by FD.  */\nextern int setns(int __fd, int __nstype) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* need schedparam */\n#if !defined __defined_schedparam \\\n    && (defined __need_schedparam || defined _SCHED_H)\n# define __defined_schedparam\t1\n/* Data structure to describe a process' schedulability.  */\nstruct __sched_param {\n\tint __sched_priority;\n};\n# undef __need_schedparam\n#endif\n\n#if defined _SCHED_H && !defined __cpu_set_t_defined\n# define __cpu_set_t_defined\n/* Size definition for CPU sets.  */\n# define __CPU_SETSIZE\t4096\n# define __NCPUBITS\t(8 * sizeof (__cpu_mask))\n\n/* Type for array elements in 'cpu_set_t'.  */\ntypedef unsigned long int __cpu_mask;\n\n/* Basic access functions.  */\n# define __CPUELT(cpu)\t((cpu) / __NCPUBITS)\n# define __CPUMASK(cpu)\t((__cpu_mask) 1 << ((cpu) % __NCPUBITS))\n\n/* Data structure to describe CPU mask.  */\ntypedef struct {\n\t__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];\n} cpu_set_t;\n\n/* Access functions for CPU masks.  */\n# if __GNUC_PREREQ (2, 91)\n#  define __CPU_ZERO_S(setsize, cpusetp) \\\n  do __builtin_memset (cpusetp, '\\0', setsize); while (0)\n# else\n#  define __CPU_ZERO_S(setsize, cpusetp) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    size_t __i;\t\t\t\t\t\t\t\t      \\\n    size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n    __cpu_mask *__bits = (cpusetp)->__bits;\t\t\t\t      \\\n    for (__i = 0; __i < __imax; ++__i)\t\t\t\t\t      \\\n      __bits[__i] = 0;\t\t\t\t\t\t\t      \\\n  } while (0)\n# endif\n# define __CPU_SET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t |= __CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n# define __CPU_CLR_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t &= ~__CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n# define __CPU_ISSET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t      \\\n\t  & __CPUMASK (__cpu))) != 0\t\t\t\t\t      \\\n      : 0; }))\n\n# define __CPU_COUNT_S(setsize, cpusetp) \\\n  __sched_cpucount (setsize, cpusetp)\n\n# if __GNUC_PREREQ (2, 91)\n#  define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)\n# else\n#  define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (cpusetp2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\tif (__arr1[__i] != __arr2[__i])\t\t\t\t\t      \\\n\t  break;\t\t\t\t\t\t\t      \\\n      __i == __imax; }))\n# endif\n\n# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ cpu_set_t *__dest = (destset);\t\t\t\t\t      \\\n      const __cpu_mask *__arr1 = (srcset1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (srcset2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\t((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i];    \\\n      __dest; }))\n\n# define __CPU_ALLOC_SIZE(count) \\\n  ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))\n# define __CPU_ALLOC(count) __sched_cpualloc (count)\n# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)\n\n__BEGIN_DECLS extern int __sched_cpucount(size_t __setsize, const cpu_set_t * __setp) __THROW;\nextern cpu_set_t *__sched_cpualloc(size_t __count)\n__THROW __wur;\nextern void __sched_cpufree(cpu_set_t * __set) __THROW;\n\n__END_DECLS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/select.h",
    "content": "/* Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SELECT_H\n# error \"Never use <bits/select.h> directly; include <sys/select.h> instead.\"\n#endif\n\n#include <bits/wordsize.h>\n\n#if defined __GNUC__ && __GNUC__ >= 2\n\n# if __WORDSIZE == 64\n#  define __FD_ZERO_STOS \"stosq\"\n# else\n#  define __FD_ZERO_STOS \"stosl\"\n# endif\n\n# define __FD_ZERO(fdsp) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    int __d0, __d1;\t\t\t\t\t\t\t      \\\n    __asm__ __volatile__ (\"cld; rep; \" __FD_ZERO_STOS\t\t\t      \\\n\t\t\t  : \"=c\" (__d0), \"=D\" (__d1)\t\t\t      \\\n\t\t\t  : \"a\" (0), \"0\" (sizeof (fd_set)\t\t      \\\n\t\t\t\t\t  / sizeof (__fd_mask)),\t      \\\n\t\t\t    \"1\" (&__FDS_BITS (fdsp)[0])\t\t\t      \\\n\t\t\t  : \"memory\");\t\t\t\t\t      \\\n  } while (0)\n\n#else\t\t\t\t/* ! GNU CC */\n\n/* We don't use `memset' because this would require a prototype and\n   the array isn't too big.  */\n# define __FD_ZERO(set)  \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    unsigned int __i;\t\t\t\t\t\t\t      \\\n    fd_set *__arr = (set);\t\t\t\t\t\t      \\\n    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)\t      \\\n      __FDS_BITS (__arr)[__i] = 0;\t\t\t\t\t      \\\n  } while (0)\n\n#endif\t\t\t\t/* GNU CC */\n\n#define __FD_SET(d, set) \\\n  ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))\n#define __FD_CLR(d, set) \\\n  ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))\n#define __FD_ISSET(d, set) \\\n  ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/setjmp.h",
    "content": "/* Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Define the machine-dependent type `jmp_buf'.  x86-64 version.  */\n#ifndef _BITS_SETJMP_H\n#define _BITS_SETJMP_H  1\n\n#if !defined _SETJMP_H && !defined _PTHREAD_H\n# error \"Never include <bits/setjmp.h> directly; use <setjmp.h> instead.\"\n#endif\n\n#include <bits/wordsize.h>\n\n#ifndef _ASM\n\n# if __WORDSIZE == 64\ntypedef long int __jmp_buf[8];\n# elif defined  __x86_64__\n__extension__ typedef long long int __jmp_buf[8];\n# else\ntypedef int __jmp_buf[6];\n# endif\n\n#endif\n\n#endif\t\t\t\t/* bits/setjmp.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sigaction.h",
    "content": "/* The proper definitions for Linux's sigaction.\n   Copyright (C) 1993-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SIGNAL_H\n# error \"Never include <bits/sigaction.h> directly; use <signal.h> instead.\"\n#endif\n\n/* Structure describing the action to be taken when a signal arrives.  */\nstruct sigaction {\n\t/* Signal handler.  */\n#ifdef __USE_POSIX199309\n\tunion {\n\t\t/* Used if SA_SIGINFO is not set.  */\n\t\t__sighandler_t sa_handler;\n\t\t/* Used if SA_SIGINFO is set.  */\n\t\tvoid (*sa_sigaction) (int, siginfo_t *, void *);\n\t} __sigaction_handler;\n# define sa_handler\t__sigaction_handler.sa_handler\n# define sa_sigaction\t__sigaction_handler.sa_sigaction\n#else\n\t__sighandler_t sa_handler;\n#endif\n\n\t/* Additional set of signals to be blocked.  */\n\t__sigset_t sa_mask;\n\n\t/* Special flags.  */\n\tint sa_flags;\n\n\t/* Restore handler.  */\n\tvoid (*sa_restorer) (void);\n};\n\n/* Bits in `sa_flags'.  */\n#define\tSA_NOCLDSTOP  1\t\t/* Don't send SIGCHLD when children stop.  */\n#define SA_NOCLDWAIT  2\t\t/* Don't create zombie on child death.  */\n#define SA_SIGINFO    4\t\t/* Invoke signal-catching function with\n\t\t\t\t   three arguments instead of one.  */\n#if defined __USE_UNIX98 || defined __USE_MISC\n# define SA_ONSTACK   0x08000000\t/* Use signal stack by using `sa_restorer'. */\n#endif\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n# define SA_RESTART   0x10000000\t/* Restart syscall on signal return.  */\n# define SA_NODEFER   0x40000000\t/* Don't automatically block the signal when\n\t\t\t\t\t   its handler is being executed.  */\n# define SA_RESETHAND 0x80000000\t/* Reset to SIG_DFL on entry to handler.  */\n#endif\n#ifdef __USE_MISC\n# define SA_INTERRUPT 0x20000000\t/* Historical no-op.  */\n\n/* Some aliases for the SA_ constants.  */\n# define SA_NOMASK    SA_NODEFER\n# define SA_ONESHOT   SA_RESETHAND\n# define SA_STACK     SA_ONSTACK\n#endif\n\n/* Values for the HOW argument to `sigprocmask'.  */\n#define\tSIG_BLOCK     0\t\t/* Block signals.  */\n#define\tSIG_UNBLOCK   1\t\t/* Unblock signals.  */\n#define\tSIG_SETMASK   2\t\t/* Set the set of blocked signals.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sigcontext.h",
    "content": "/* Copyright (C) 2002-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\t See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGCONTEXT_H\n#define _BITS_SIGCONTEXT_H  1\n\n#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H\n# error \"Never use <bits/sigcontext.h> directly; include <signal.h> instead.\"\n#endif\n\n#define FP_XSTATE_MAGIC1\t0x46505853U\n#define FP_XSTATE_MAGIC2\t0x46505845U\n#define FP_XSTATE_MAGIC2_SIZE\tsizeof(FP_XSTATE_MAGIC2)\n\nstruct _fpx_sw_bytes {\n\t__uint32_t magic1;\n\t__uint32_t extended_size;\n\t__uint64_t xstate_bv;\n\t__uint32_t xstate_size;\n\t__uint32_t padding[7];\n};\n\nstruct _fpreg {\n\tunsigned short significand[4];\n\tunsigned short exponent;\n};\n\nstruct _fpxreg {\n\tunsigned short significand[4];\n\tunsigned short exponent;\n\tunsigned short padding[3];\n};\n\nstruct _xmmreg {\n\t__uint32_t element[4];\n};\n\n#ifndef __x86_64__\n\nstruct _fpstate {\n\t/* Regular FPU environment.  */\n\t__uint32_t cw;\n\t__uint32_t sw;\n\t__uint32_t tag;\n\t__uint32_t ipoff;\n\t__uint32_t cssel;\n\t__uint32_t dataoff;\n\t__uint32_t datasel;\n\tstruct _fpreg _st[8];\n\tunsigned short status;\n\tunsigned short magic;\n\n\t/* FXSR FPU environment.  */\n\t__uint32_t _fxsr_env[6];\n\t__uint32_t mxcsr;\n\t__uint32_t reserved;\n\tstruct _fpxreg _fxsr_st[8];\n\tstruct _xmmreg _xmm[8];\n\t__uint32_t padding[56];\n};\n\n#ifndef sigcontext_struct\n/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but\n   we need sigcontext.  Some packages have come to rely on\n   sigcontext_struct being defined on 32-bit x86, so define this for\n   their benefit.  */\n# define sigcontext_struct sigcontext\n#endif\n\n#define X86_FXSR_MAGIC\t\t0x0000\n\nstruct sigcontext {\n\tunsigned short gs, __gsh;\n\tunsigned short fs, __fsh;\n\tunsigned short es, __esh;\n\tunsigned short ds, __dsh;\n\tunsigned long edi;\n\tunsigned long esi;\n\tunsigned long ebp;\n\tunsigned long esp;\n\tunsigned long ebx;\n\tunsigned long edx;\n\tunsigned long ecx;\n\tunsigned long eax;\n\tunsigned long trapno;\n\tunsigned long err;\n\tunsigned long eip;\n\tunsigned short cs, __csh;\n\tunsigned long eflags;\n\tunsigned long esp_at_signal;\n\tunsigned short ss, __ssh;\n\tstruct _fpstate *fpstate;\n\tunsigned long oldmask;\n\tunsigned long cr2;\n};\n\n#else\t\t\t\t/* __x86_64__ */\n\nstruct _fpstate {\n\t/* FPU environment matching the 64-bit FXSAVE layout.  */\n\t__uint16_t cwd;\n\t__uint16_t swd;\n\t__uint16_t ftw;\n\t__uint16_t fop;\n\t__uint64_t rip;\n\t__uint64_t rdp;\n\t__uint32_t mxcsr;\n\t__uint32_t mxcr_mask;\n\tstruct _fpxreg _st[8];\n\tstruct _xmmreg _xmm[16];\n\t__uint32_t padding[24];\n};\n\nstruct sigcontext {\n\t__uint64_t r8;\n\t__uint64_t r9;\n\t__uint64_t r10;\n\t__uint64_t r11;\n\t__uint64_t r12;\n\t__uint64_t r13;\n\t__uint64_t r14;\n\t__uint64_t r15;\n\t__uint64_t rdi;\n\t__uint64_t rsi;\n\t__uint64_t rbp;\n\t__uint64_t rbx;\n\t__uint64_t rdx;\n\t__uint64_t rax;\n\t__uint64_t rcx;\n\t__uint64_t rsp;\n\t__uint64_t rip;\n\t__uint64_t eflags;\n\tunsigned short cs;\n\tunsigned short gs;\n\tunsigned short fs;\n\tunsigned short __pad0;\n\t__uint64_t err;\n\t__uint64_t trapno;\n\t__uint64_t oldmask;\n\t__uint64_t cr2;\n\t__extension__ union {\n\t\tstruct _fpstate *fpstate;\n\t\t__uint64_t __fpstate_word;\n\t};\n\t__uint64_t __reserved1[8];\n};\n\n#endif\t\t\t\t/* __x86_64__ */\n\nstruct _xsave_hdr {\n\t__uint64_t xstate_bv;\n\t__uint64_t reserved1[2];\n\t__uint64_t reserved2[5];\n};\n\nstruct _ymmh_state {\n\t__uint32_t ymmh_space[64];\n};\n\nstruct _xstate {\n\tstruct _fpstate fpstate;\n\tstruct _xsave_hdr xstate_hdr;\n\tstruct _ymmh_state ymmh;\n};\n\n#endif\t\t\t\t/* _BITS_SIGCONTEXT_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/siginfo.h",
    "content": "/* siginfo_t, sigevent and constants.  Linux x86-64 version.\n   Copyright (C) 2012-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SIGNAL_H && !defined __need_siginfo_t \\\n    && !defined __need_sigevent_t\n# error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n#include <bits/wordsize.h>\n\n#if (!defined __have_sigval_t \\\n     && (defined _SIGNAL_H || defined __need_siginfo_t \\\n\t || defined __need_sigevent_t))\n# define __have_sigval_t\t1\n\n/* Type for data associated with a signal.  */\ntypedef union sigval {\n\tint sival_int;\n\tvoid *sival_ptr;\n} sigval_t;\n#endif\n\n#if (!defined __have_siginfo_t \\\n     && (defined _SIGNAL_H || defined __need_siginfo_t))\n# define __have_siginfo_t\t1\n\n# define __SI_MAX_SIZE     128\n# if __WORDSIZE == 64\n#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)\n# else\n#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)\n# endif\n\n# if defined __x86_64__ && __WORDSIZE == 32\n/* si_utime and si_stime must be 4 byte aligned for x32 to match the\n   kernel.  We align siginfo_t to 8 bytes so that si_utime and si_stime\n   are actually aligned to 8 bytes since their offsets are multiple of\n   8 bytes.  */\ntypedef __clock_t __attribute__ ((__aligned__(4))) __sigchld_clock_t;\n#  define __SI_ALIGNMENT __attribute__ ((__aligned__ (8)))\n# else\ntypedef __clock_t __sigchld_clock_t;\n#  define __SI_ALIGNMENT\n# endif\n\ntypedef struct {\n\tint si_signo;\t\t/* Signal number.  */\n\tint si_errno;\t\t/* If non-zero, an errno value associated with\n\t\t\t\t   this signal, as defined in <errno.h>.  */\n\tint si_code;\t\t/* Signal code.  */\n\n\tunion {\n\t\tint _pad[__SI_PAD_SIZE];\n\n\t\t/* kill().  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t} _kill;\n\n\t\t/* POSIX.1b timers.  */\n\t\tstruct {\n\t\t\tint si_tid;\t/* Timer ID.  */\n\t\t\tint si_overrun;\t/* Overrun count.  */\n\t\t\tsigval_t si_sigval;\t/* Signal value.  */\n\t\t} _timer;\n\n\t\t/* POSIX.1b signals.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\tsigval_t si_sigval;\t/* Signal value.  */\n\t\t} _rt;\n\n\t\t/* SIGCHLD.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Which child.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\tint si_status;\t/* Exit value or signal.  */\n\t\t\t__sigchld_clock_t si_utime;\n\t\t\t__sigchld_clock_t si_stime;\n\t\t} _sigchld;\n\n\t\t/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */\n\t\tstruct {\n\t\t\tvoid *si_addr;\t/* Faulting insn/memory ref.  */\n\t\t\tshort int si_addr_lsb;\t/* Valid LSB of the reported address.  */\n\t\t\tstruct {\n\t\t\t\tvoid *_lower;\n\t\t\t\tvoid *_upper;\n\t\t\t} si_addr_bnd;\n\t\t} _sigfault;\n\n\t\t/* SIGPOLL.  */\n\t\tstruct {\n\t\t\tlong int si_band;\t/* Band event for SIGPOLL.  */\n\t\t\tint si_fd;\n\t\t} _sigpoll;\n\n\t\t/* SIGSYS.  */\n\t\tstruct {\n\t\t\tvoid *_call_addr;\t/* Calling user insn.  */\n\t\t\tint _syscall;\t/* Triggering system call number.  */\n\t\t\tunsigned int _arch;\t/* AUDIT_ARCH_* of syscall.  */\n\t\t} _sigsys;\n\t} _sifields;\n} siginfo_t __SI_ALIGNMENT;\n\n/* X/Open requires some more fields with fixed names.  */\n# define si_pid\t\t_sifields._kill.si_pid\n# define si_uid\t\t_sifields._kill.si_uid\n# define si_timerid\t_sifields._timer.si_tid\n# define si_overrun\t_sifields._timer.si_overrun\n# define si_status\t_sifields._sigchld.si_status\n# define si_utime\t_sifields._sigchld.si_utime\n# define si_stime\t_sifields._sigchld.si_stime\n# define si_value\t_sifields._rt.si_sigval\n# define si_int\t\t_sifields._rt.si_sigval.sival_int\n# define si_ptr\t\t_sifields._rt.si_sigval.sival_ptr\n# define si_addr\t_sifields._sigfault.si_addr\n# define si_addr_lsb\t_sifields._sigfault.si_addr_lsb\n# define si_lower\t_sifields._sigfault.si_addr_bnd._lower\n# define si_upper\t_sifields._sigfault.si_addr_bnd._upper\n# define si_band\t_sifields._sigpoll.si_band\n# define si_fd\t\t_sifields._sigpoll.si_fd\n# define si_call_addr \t_sifields._sigsys._call_addr\n# define si_syscall\t_sifields._sigsys._syscall\n# define si_arch\t_sifields._sigsys._arch\n\n/* Values for `si_code'.  Positive values are reserved for kernel-generated\n   signals.  */\nenum {\n\tSI_ASYNCNL = -60,\t/* Sent by asynch name lookup completion.  */\n# define SI_ASYNCNL\tSI_ASYNCNL\n\tSI_TKILL = -6,\t\t/* Sent by tkill.  */\n# define SI_TKILL\tSI_TKILL\n\tSI_SIGIO,\t\t/* Sent by queued SIGIO. */\n# define SI_SIGIO\tSI_SIGIO\n\tSI_ASYNCIO,\t\t/* Sent by AIO completion.  */\n# define SI_ASYNCIO\tSI_ASYNCIO\n\tSI_MESGQ,\t\t/* Sent by real time mesq state change.  */\n# define SI_MESGQ\tSI_MESGQ\n\tSI_TIMER,\t\t/* Sent by timer expiration.  */\n# define SI_TIMER\tSI_TIMER\n\tSI_QUEUE,\t\t/* Sent by sigqueue.  */\n# define SI_QUEUE\tSI_QUEUE\n\tSI_USER,\t\t/* Sent by kill, sigsend.  */\n# define SI_USER\tSI_USER\n\tSI_KERNEL = 0x80\t/* Send by kernel.  */\n#define SI_KERNEL\tSI_KERNEL\n};\n\n# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGILL signal.  */\nenum {\n\tILL_ILLOPC = 1,\t\t/* Illegal opcode.  */\n#  define ILL_ILLOPC\tILL_ILLOPC\n\tILL_ILLOPN,\t\t/* Illegal operand.  */\n#  define ILL_ILLOPN\tILL_ILLOPN\n\tILL_ILLADR,\t\t/* Illegal addressing mode.  */\n#  define ILL_ILLADR\tILL_ILLADR\n\tILL_ILLTRP,\t\t/* Illegal trap. */\n#  define ILL_ILLTRP\tILL_ILLTRP\n\tILL_PRVOPC,\t\t/* Privileged opcode.  */\n#  define ILL_PRVOPC\tILL_PRVOPC\n\tILL_PRVREG,\t\t/* Privileged register.  */\n#  define ILL_PRVREG\tILL_PRVREG\n\tILL_COPROC,\t\t/* Coprocessor error.  */\n#  define ILL_COPROC\tILL_COPROC\n\tILL_BADSTK\t\t/* Internal stack error.  */\n#  define ILL_BADSTK\tILL_BADSTK\n};\n\n/* `si_code' values for SIGFPE signal.  */\nenum {\n\tFPE_INTDIV = 1,\t\t/* Integer divide by zero.  */\n#  define FPE_INTDIV\tFPE_INTDIV\n\tFPE_INTOVF,\t\t/* Integer overflow.  */\n#  define FPE_INTOVF\tFPE_INTOVF\n\tFPE_FLTDIV,\t\t/* Floating point divide by zero.  */\n#  define FPE_FLTDIV\tFPE_FLTDIV\n\tFPE_FLTOVF,\t\t/* Floating point overflow.  */\n#  define FPE_FLTOVF\tFPE_FLTOVF\n\tFPE_FLTUND,\t\t/* Floating point underflow.  */\n#  define FPE_FLTUND\tFPE_FLTUND\n\tFPE_FLTRES,\t\t/* Floating point inexact result.  */\n#  define FPE_FLTRES\tFPE_FLTRES\n\tFPE_FLTINV,\t\t/* Floating point invalid operation.  */\n#  define FPE_FLTINV\tFPE_FLTINV\n\tFPE_FLTSUB\t\t/* Subscript out of range.  */\n#  define FPE_FLTSUB\tFPE_FLTSUB\n};\n\n/* `si_code' values for SIGSEGV signal.  */\nenum {\n\tSEGV_MAPERR = 1,\t/* Address not mapped to object.  */\n#  define SEGV_MAPERR\tSEGV_MAPERR\n\tSEGV_ACCERR\t\t/* Invalid permissions for mapped object.  */\n#  define SEGV_ACCERR\tSEGV_ACCERR\n};\n\n/* `si_code' values for SIGBUS signal.  */\nenum {\n\tBUS_ADRALN = 1,\t\t/* Invalid address alignment.  */\n#  define BUS_ADRALN\tBUS_ADRALN\n\tBUS_ADRERR,\t\t/* Non-existant physical address.  */\n#  define BUS_ADRERR\tBUS_ADRERR\n\tBUS_OBJERR,\t\t/* Object specific hardware error.  */\n#  define BUS_OBJERR\tBUS_OBJERR\n\tBUS_MCEERR_AR,\t\t/* Hardware memory error: action required.  */\n#  define BUS_MCEERR_AR\tBUS_MCEERR_AR\n\tBUS_MCEERR_AO\t\t/* Hardware memory error: action optional.  */\n#  define BUS_MCEERR_AO\tBUS_MCEERR_AO\n};\n# endif\n\n# ifdef __USE_XOPEN_EXTENDED\n/* `si_code' values for SIGTRAP signal.  */\nenum {\n\tTRAP_BRKPT = 1,\t\t/* Process breakpoint.  */\n#  define TRAP_BRKPT\tTRAP_BRKPT\n\tTRAP_TRACE\t\t/* Process trace trap.  */\n#  define TRAP_TRACE\tTRAP_TRACE\n};\n# endif\n\n# if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGCHLD signal.  */\nenum {\n\tCLD_EXITED = 1,\t\t/* Child has exited.  */\n#  define CLD_EXITED\tCLD_EXITED\n\tCLD_KILLED,\t\t/* Child was killed.  */\n#  define CLD_KILLED\tCLD_KILLED\n\tCLD_DUMPED,\t\t/* Child terminated abnormally.  */\n#  define CLD_DUMPED\tCLD_DUMPED\n\tCLD_TRAPPED,\t\t/* Traced child has trapped.  */\n#  define CLD_TRAPPED\tCLD_TRAPPED\n\tCLD_STOPPED,\t\t/* Child has stopped.  */\n#  define CLD_STOPPED\tCLD_STOPPED\n\tCLD_CONTINUED\t\t/* Stopped child has continued.  */\n#  define CLD_CONTINUED\tCLD_CONTINUED\n};\n\n/* `si_code' values for SIGPOLL signal.  */\nenum {\n\tPOLL_IN = 1,\t\t/* Data input available.  */\n#  define POLL_IN\tPOLL_IN\n\tPOLL_OUT,\t\t/* Output buffers available.  */\n#  define POLL_OUT\tPOLL_OUT\n\tPOLL_MSG,\t\t/* Input message available.   */\n#  define POLL_MSG\tPOLL_MSG\n\tPOLL_ERR,\t\t/* I/O error.  */\n#  define POLL_ERR\tPOLL_ERR\n\tPOLL_PRI,\t\t/* High priority input available.  */\n#  define POLL_PRI\tPOLL_PRI\n\tPOLL_HUP\t\t/* Device disconnected.  */\n#  define POLL_HUP\tPOLL_HUP\n};\n# endif\n\n# undef __need_siginfo_t\n#endif\t\t\t\t/* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */\n\n#if (defined _SIGNAL_H || defined __need_sigevent_t) \\\n    && !defined __have_sigevent_t\n# define __have_sigevent_t\t1\n\n/* Structure to transport application-defined values with signals.  */\n# define __SIGEV_MAX_SIZE\t64\n# if __WORDSIZE == 64\n#  define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 4)\n# else\n#  define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 3)\n# endif\n\n/* Forward declaration.  */\n# ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n#  define __have_pthread_attr_t\t1\n# endif\n\ntypedef struct sigevent {\n\tsigval_t sigev_value;\n\tint sigev_signo;\n\tint sigev_notify;\n\n\tunion {\n\t\tint _pad[__SIGEV_PAD_SIZE];\n\n\t\t/* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the\n\t\t   thread to receive the signal.  */\n\t\t__pid_t _tid;\n\n\t\tstruct {\n\t\t\tvoid (*_function) (sigval_t);\t/* Function to start.  */\n\t\t\tpthread_attr_t *_attribute;\t/* Thread attributes.  */\n\t\t} _sigev_thread;\n\t} _sigev_un;\n} sigevent_t;\n\n/* POSIX names to access some of the members.  */\n# define sigev_notify_function   _sigev_un._sigev_thread._function\n# define sigev_notify_attributes _sigev_un._sigev_thread._attribute\n\n/* `sigev_notify' values.  */\nenum {\n\tSIGEV_SIGNAL = 0,\t/* Notify via signal.  */\n# define SIGEV_SIGNAL\tSIGEV_SIGNAL\n\tSIGEV_NONE,\t\t/* Other notification: meaningless.  */\n# define SIGEV_NONE\tSIGEV_NONE\n\tSIGEV_THREAD,\t\t/* Deliver via thread creation.  */\n# define SIGEV_THREAD\tSIGEV_THREAD\n\n\tSIGEV_THREAD_ID = 4\t/* Send signal to specific thread.  */\n#define SIGEV_THREAD_ID\tSIGEV_THREAD_ID\n};\n\n#endif\t\t\t\t/* have _SIGNAL_H.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/signum.h",
    "content": "/* Signal number definitions.  Linux version.\n   Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifdef\t_SIGNAL_H\n\n/* Fake signal functions.  */\n#define SIG_ERR\t((__sighandler_t) -1)\t/* Error return.  */\n#define SIG_DFL\t((__sighandler_t) 0)\t/* Default action.  */\n#define SIG_IGN\t((__sighandler_t) 1)\t/* Ignore signal.  */\n\n#ifdef __USE_UNIX98\n# define SIG_HOLD\t((__sighandler_t) 2)\t/* Add signal to hold mask.  */\n#endif\n\n/* Signals.  */\n#define\tSIGHUP\t\t1\t/* Hangup (POSIX).  */\n#define\tSIGINT\t\t2\t/* Interrupt (ANSI).  */\n#define\tSIGQUIT\t\t3\t/* Quit (POSIX).  */\n#define\tSIGILL\t\t4\t/* Illegal instruction (ANSI).  */\n#define\tSIGTRAP\t\t5\t/* Trace trap (POSIX).  */\n#define\tSIGABRT\t\t6\t/* Abort (ANSI).  */\n#define\tSIGIOT\t\t6\t/* IOT trap (4.2 BSD).  */\n#define\tSIGBUS\t\t7\t/* BUS error (4.2 BSD).  */\n#define\tSIGFPE\t\t8\t/* Floating-point exception (ANSI).  */\n#define\tSIGKILL\t\t9\t/* Kill, unblockable (POSIX).  */\n#define\tSIGUSR1\t\t10\t/* User-defined signal 1 (POSIX).  */\n#define\tSIGSEGV\t\t11\t/* Segmentation violation (ANSI).  */\n#define\tSIGUSR2\t\t12\t/* User-defined signal 2 (POSIX).  */\n#define\tSIGPIPE\t\t13\t/* Broken pipe (POSIX).  */\n#define\tSIGALRM\t\t14\t/* Alarm clock (POSIX).  */\n#define\tSIGTERM\t\t15\t/* Termination (ANSI).  */\n#define\tSIGSTKFLT\t16\t/* Stack fault.  */\n#define\tSIGCLD\t\tSIGCHLD\t/* Same as SIGCHLD (System V).  */\n#define\tSIGCHLD\t\t17\t/* Child status has changed (POSIX).  */\n#define\tSIGCONT\t\t18\t/* Continue (POSIX).  */\n#define\tSIGSTOP\t\t19\t/* Stop, unblockable (POSIX).  */\n#define\tSIGTSTP\t\t20\t/* Keyboard stop (POSIX).  */\n#define\tSIGTTIN\t\t21\t/* Background read from tty (POSIX).  */\n#define\tSIGTTOU\t\t22\t/* Background write to tty (POSIX).  */\n#define\tSIGURG\t\t23\t/* Urgent condition on socket (4.2 BSD).  */\n#define\tSIGXCPU\t\t24\t/* CPU limit exceeded (4.2 BSD).  */\n#define\tSIGXFSZ\t\t25\t/* File size limit exceeded (4.2 BSD).  */\n#define\tSIGVTALRM\t26\t/* Virtual alarm clock (4.2 BSD).  */\n#define\tSIGPROF\t\t27\t/* Profiling alarm clock (4.2 BSD).  */\n#define\tSIGWINCH\t28\t/* Window size change (4.3 BSD, Sun).  */\n#define\tSIGPOLL\t\tSIGIO\t/* Pollable event occurred (System V).  */\n#define\tSIGIO\t\t29\t/* I/O now possible (4.2 BSD).  */\n#define\tSIGPWR\t\t30\t/* Power failure restart (System V).  */\n#define SIGSYS\t\t31\t/* Bad system call.  */\n#define SIGUNUSED\t31\n\n#define\t_NSIG\t\t65\t/* Biggest signal number + 1\n\t\t\t\t   (including real-time signals).  */\n\n#define SIGRTMIN        (__libc_current_sigrtmin ())\n#define SIGRTMAX        (__libc_current_sigrtmax ())\n\n/* These are the hard limits of the kernel.  These values should not be\n   used directly at user level.  */\n#define __SIGRTMIN\t32\n#define __SIGRTMAX\t(_NSIG - 1)\n\n#endif\t\t\t\t/* <signal.h> included.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sigset.h",
    "content": "/* __sig_atomic_t, __sigset_t, and related definitions.  Linux version.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SIGSET_H_types\n# define _SIGSET_H_types\t1\n\ntypedef int __sig_atomic_t;\n\n/* A `sigset_t' has a bit for each signal.  */\n\n# define _SIGSET_NWORDS\t(1024 / (8 * sizeof (unsigned long int)))\ntypedef struct {\n\tunsigned long int __val[_SIGSET_NWORDS];\n} __sigset_t;\n\n#endif\n\n/* We only want to define these functions if <signal.h> was actually\n   included; otherwise we were included just to define the types.  Since we\n   are namespace-clean, it wouldn't hurt to define extra macros.  But\n   trouble can be caused by functions being defined (e.g., any global\n   register vars declared later will cause compilation errors).  */\n\n#if !defined _SIGSET_H_fns && defined _SIGNAL_H\n# define _SIGSET_H_fns 1\n\n# ifndef _EXTERN_INLINE\n#  define _EXTERN_INLINE __extern_inline\n# endif\n\n/* Return a mask that includes the bit for SIG only.  */\n# define __sigmask(sig) \\\n  (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))\n\n/* Return the word index for SIG.  */\n# define __sigword(sig)\t(((sig) - 1) / (8 * sizeof (unsigned long int)))\n\n# if defined __GNUC__ && __GNUC__ >= 2\n#  define __sigemptyset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__set = (set);\t\t\t\t      \\\n\t\t    while (--__cnt >= 0) __set->__val[__cnt] = 0;\t      \\\n\t\t    0; }))\n#  define __sigfillset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__set = (set);\t\t\t\t      \\\n\t\t    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;\t      \\\n\t\t    0; }))\n\n#  ifdef __USE_GNU\n/* The POSIX does not specify for handling the whole signal set in one\n   command.  This is often wanted and so we define three more functions\n   here.  */\n#   define __sigisemptyset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    const sigset_t *__set = (set);\t\t\t      \\\n\t\t    int __ret = __set->__val[--__cnt];\t\t\t      \\\n\t\t    while (!__ret && --__cnt >= 0)\t\t\t      \\\n\t\t\t__ret = __set->__val[__cnt];\t\t\t      \\\n\t\t    __ret == 0; }))\n#   define __sigandset(dest, left, right) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__dest = (dest);\t\t\t\t      \\\n\t\t    const sigset_t *__left = (left);\t\t\t      \\\n\t\t    const sigset_t *__right = (right);\t\t\t      \\\n\t\t    while (--__cnt >= 0)\t\t\t\t      \\\n\t\t      __dest->__val[__cnt] = (__left->__val[__cnt]\t      \\\n\t\t\t\t\t      & __right->__val[__cnt]);\t      \\\n\t\t    0; }))\n#   define __sigorset(dest, left, right) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__dest = (dest);\t\t\t\t      \\\n\t\t    const sigset_t *__left = (left);\t\t\t      \\\n\t\t    const sigset_t *__right = (right);\t\t\t      \\\n\t\t    while (--__cnt >= 0)\t\t\t\t      \\\n\t\t      __dest->__val[__cnt] = (__left->__val[__cnt]\t      \\\n\t\t\t\t\t      | __right->__val[__cnt]);\t      \\\n\t\t    0; }))\n#  endif\n# endif\n\n/* These functions needn't check for a bogus signal number -- error\n   checking is done in the non __ versions.  */\n\nextern int __sigismember(const __sigset_t *, int);\nextern int __sigaddset(__sigset_t *, int);\nextern int __sigdelset(__sigset_t *, int);\n\n# ifdef __USE_EXTERN_INLINES\n#  define __SIGSETFN(NAME, BODY, CONST)\t\t\t\t\t      \\\n  _EXTERN_INLINE int\t\t\t\t\t\t\t      \\\n  NAME (CONST __sigset_t *__set, int __sig)\t\t\t\t      \\\n  {\t\t\t\t\t\t\t\t\t      \\\n    unsigned long int __mask = __sigmask (__sig);\t\t\t      \\\n    unsigned long int __word = __sigword (__sig);\t\t\t      \\\n    return BODY;\t\t\t\t\t\t\t      \\\n  }\n\n__SIGSETFN(__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, const) __SIGSETFN(__sigaddset, ((__set->__val[__word] |= __mask), 0),) __SIGSETFN(__sigdelset, ((__set->__val[__word] &= ~__mask), 0),)\n#  undef __SIGSETFN\n# endif\n#endif\t\t\t\t/* ! _SIGSET_H_fns.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sigstack.h",
    "content": "/* sigstack, sigaltstack definitions.\n   Copyright (C) 1998-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SIGNAL_H\n# error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n/* Structure describing a signal stack (obsolete).  */\nstruct sigstack {\n\tvoid *ss_sp;\t\t/* Signal stack pointer.  */\n\tint ss_onstack;\t\t/* Nonzero if executing on this stack.  */\n};\n\n/* Possible values for `ss_flags.'.  */\nenum {\n\tSS_ONSTACK = 1,\n#define SS_ONSTACK\tSS_ONSTACK\n\tSS_DISABLE\n#define SS_DISABLE\tSS_DISABLE\n};\n\n/* Minimum stack size for a signal handler.  */\n#define MINSIGSTKSZ\t2048\n\n/* System default stack size.  */\n#define SIGSTKSZ\t8192\n\n/* Alternate, preferred interface.  */\ntypedef struct sigaltstack {\n\tvoid *ss_sp;\n\tint ss_flags;\n\tsize_t ss_size;\n} stack_t;\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sigthread.h",
    "content": "/* Signal handling function for threaded programs.\n   Copyright (C) 1998-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGTHREAD_H\n#define _BITS_SIGTHREAD_H\t1\n\n#if !defined _SIGNAL_H && !defined _PTHREAD_H\n# error \"Never include this file directly.  Use <pthread.h> instead\"\n#endif\n\n/* Functions for handling signals. */\n\n/* Modify the signal mask for the calling thread.  The arguments have\n   the same meaning as for sigprocmask(2). */\nextern int pthread_sigmask(int __how, const __sigset_t * __restrict __newmask, __sigset_t * __restrict __oldmask) __THROW;\n\n/* Send signal SIGNO to the given thread. */\nextern int pthread_kill(pthread_t __threadid, int __signo) __THROW;\n\n#ifdef __USE_GNU\n/* Queue signal and data to a thread.  */\nextern int pthread_sigqueue(pthread_t __threadid, int __signo, const union sigval __value) __THROW;\n#endif\n\n#endif\t\t\t\t/* bits/sigthread.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sockaddr.h",
    "content": "/* Definition of `struct sockaddr_*' common members.  Generic/4.2 BSD version.\n   Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/socket.h> instead.\n */\n\n#ifndef _BITS_SOCKADDR_H\n#define _BITS_SOCKADDR_H\t1\n\n/* POSIX.1g specifies this type name for the `sa_family' member.  */\ntypedef unsigned short int sa_family_t;\n\n/* This macro is used to declare the initial common members\n   of the data types used for socket addresses, `struct sockaddr',\n   `struct sockaddr_in', `struct sockaddr_un', etc.  */\n\n#define\t__SOCKADDR_COMMON(sa_prefix) \\\n  sa_family_t sa_prefix##family\n\n#define __SOCKADDR_COMMON_SIZE\t(sizeof (unsigned short int))\n\n#endif\t\t\t\t/* bits/sockaddr.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/socket.h",
    "content": "/* System-specific socket constants and types.  Linux version.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __BITS_SOCKET_H\n#define __BITS_SOCKET_H\n\n#ifndef _SYS_SOCKET_H\n# error \"Never include <bits/socket.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n#define __need_size_t\n#include <stddef.h>\n\n#include <sys/types.h>\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n# define __socklen_t_defined\n#endif\n\n/* Get the architecture-dependent definition of enum __socket_type.  */\n#include <bits/socket_type.h>\n\n/* Protocol families.  */\n#define PF_UNSPEC\t0\t/* Unspecified.  */\n#define PF_LOCAL\t1\t/* Local to host (pipes and file-domain).  */\n#define PF_UNIX\t\tPF_LOCAL\t/* POSIX name for PF_LOCAL.  */\n#define PF_FILE\t\tPF_LOCAL\t/* Another non-standard name for PF_LOCAL.  */\n#define PF_INET\t\t2\t/* IP protocol family.  */\n#define PF_AX25\t\t3\t/* Amateur Radio AX.25.  */\n#define PF_IPX\t\t4\t/* Novell Internet Protocol.  */\n#define PF_APPLETALK\t5\t/* Appletalk DDP.  */\n#define PF_NETROM\t6\t/* Amateur radio NetROM.  */\n#define PF_BRIDGE\t7\t/* Multiprotocol bridge.  */\n#define PF_ATMPVC\t8\t/* ATM PVCs.  */\n#define PF_X25\t\t9\t/* Reserved for X.25 project.  */\n#define PF_INET6\t10\t/* IP version 6.  */\n#define PF_ROSE\t\t11\t/* Amateur Radio X.25 PLP.  */\n#define PF_DECnet\t12\t/* Reserved for DECnet project.  */\n#define PF_NETBEUI\t13\t/* Reserved for 802.2LLC project.  */\n#define PF_SECURITY\t14\t/* Security callback pseudo AF.  */\n#define PF_KEY\t\t15\t/* PF_KEY key management API.  */\n#define PF_NETLINK\t16\n#define PF_ROUTE\tPF_NETLINK\t/* Alias to emulate 4.4BSD.  */\n#define PF_PACKET\t17\t/* Packet family.  */\n#define PF_ASH\t\t18\t/* Ash.  */\n#define PF_ECONET\t19\t/* Acorn Econet.  */\n#define PF_ATMSVC\t20\t/* ATM SVCs.  */\n#define PF_RDS\t\t21\t/* RDS sockets.  */\n#define PF_SNA\t\t22\t/* Linux SNA Project */\n#define PF_IRDA\t\t23\t/* IRDA sockets.  */\n#define PF_PPPOX\t24\t/* PPPoX sockets.  */\n#define PF_WANPIPE\t25\t/* Wanpipe API sockets.  */\n#define PF_LLC\t\t26\t/* Linux LLC.  */\n#define PF_IB\t\t27\t/* Native InfiniBand address.  */\n#define PF_MPLS\t\t28\t/* MPLS.  */\n#define PF_CAN\t\t29\t/* Controller Area Network.  */\n#define PF_TIPC\t\t30\t/* TIPC sockets.  */\n#define PF_BLUETOOTH\t31\t/* Bluetooth sockets.  */\n#define PF_IUCV\t\t32\t/* IUCV sockets.  */\n#define PF_RXRPC\t33\t/* RxRPC sockets.  */\n#define PF_ISDN\t\t34\t/* mISDN sockets.  */\n#define PF_PHONET\t35\t/* Phonet sockets.  */\n#define PF_IEEE802154\t36\t/* IEEE 802.15.4 sockets.  */\n#define PF_CAIF\t\t37\t/* CAIF sockets.  */\n#define PF_ALG\t\t38\t/* Algorithm sockets.  */\n#define PF_NFC\t\t39\t/* NFC sockets.  */\n#define PF_VSOCK\t40\t/* vSockets.  */\n#define PF_MAX\t\t41\t/* For now..  */\n\n/* Address families.  */\n#define AF_UNSPEC\tPF_UNSPEC\n#define AF_LOCAL\tPF_LOCAL\n#define AF_UNIX\t\tPF_UNIX\n#define AF_FILE\t\tPF_FILE\n#define AF_INET\t\tPF_INET\n#define AF_AX25\t\tPF_AX25\n#define AF_IPX\t\tPF_IPX\n#define AF_APPLETALK\tPF_APPLETALK\n#define AF_NETROM\tPF_NETROM\n#define AF_BRIDGE\tPF_BRIDGE\n#define AF_ATMPVC\tPF_ATMPVC\n#define AF_X25\t\tPF_X25\n#define AF_INET6\tPF_INET6\n#define AF_ROSE\t\tPF_ROSE\n#define AF_DECnet\tPF_DECnet\n#define AF_NETBEUI\tPF_NETBEUI\n#define AF_SECURITY\tPF_SECURITY\n#define AF_KEY\t\tPF_KEY\n#define AF_NETLINK\tPF_NETLINK\n#define AF_ROUTE\tPF_ROUTE\n#define AF_PACKET\tPF_PACKET\n#define AF_ASH\t\tPF_ASH\n#define AF_ECONET\tPF_ECONET\n#define AF_ATMSVC\tPF_ATMSVC\n#define AF_RDS\t\tPF_RDS\n#define AF_SNA\t\tPF_SNA\n#define AF_IRDA\t\tPF_IRDA\n#define AF_PPPOX\tPF_PPPOX\n#define AF_WANPIPE\tPF_WANPIPE\n#define AF_LLC\t\tPF_LLC\n#define AF_IB\t\tPF_IB\n#define AF_MPLS\t\tPF_MPLS\n#define AF_CAN\t\tPF_CAN\n#define AF_TIPC\t\tPF_TIPC\n#define AF_BLUETOOTH\tPF_BLUETOOTH\n#define AF_IUCV\t\tPF_IUCV\n#define AF_RXRPC\tPF_RXRPC\n#define AF_ISDN\t\tPF_ISDN\n#define AF_PHONET\tPF_PHONET\n#define AF_IEEE802154\tPF_IEEE802154\n#define AF_CAIF\t\tPF_CAIF\n#define AF_ALG\t\tPF_ALG\n#define AF_NFC\t\tPF_NFC\n#define AF_VSOCK\tPF_VSOCK\n#define AF_MAX\t\tPF_MAX\n\n/* Socket level values.  Others are defined in the appropriate headers.\n\n   XXX These definitions also should go into the appropriate headers as\n   far as they are available.  */\n#define SOL_RAW\t\t255\n#define SOL_DECNET      261\n#define SOL_X25         262\n#define SOL_PACKET\t263\n#define SOL_ATM\t\t264\t/* ATM layer (cell level).  */\n#define SOL_AAL\t\t265\t/* ATM Adaption Layer (packet level).  */\n#define SOL_IRDA\t266\n\n/* Maximum queue length specifiable by listen.  */\n#define SOMAXCONN\t128\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n/* Structure describing a generic socket address.  */\nstruct sockaddr {\n\t__SOCKADDR_COMMON(sa_);\t/* Common data: address family and length.  */\n\tchar sa_data[14];\t/* Address data.  */\n};\n\n/* Structure large enough to hold any socket address (with the historical\n   exception of AF_UNIX).  We reserve 128 bytes.  */\n#define __ss_aligntype\tunsigned long int\n#define _SS_SIZE\t128\n#define _SS_PADSIZE\t(_SS_SIZE - (2 * sizeof (__ss_aligntype)))\n\nstruct sockaddr_storage {\n\t__SOCKADDR_COMMON(ss_);\t/* Address family, etc.  */\n\t__ss_aligntype __ss_align;\t/* Force desired alignment.  */\n\tchar __ss_padding[_SS_PADSIZE];\n};\n\n/* Bits in the FLAGS argument to `send', `recv', et al.  */\nenum {\n\tMSG_OOB = 0x01,\t\t/* Process out-of-band data.  */\n#define MSG_OOB\t\tMSG_OOB\n\tMSG_PEEK = 0x02,\t/* Peek at incoming messages.  */\n#define MSG_PEEK\tMSG_PEEK\n\tMSG_DONTROUTE = 0x04,\t/* Don't use local routing.  */\n#define MSG_DONTROUTE\tMSG_DONTROUTE\n#ifdef __USE_GNU\n\t/* DECnet uses a different name.  */\n\tMSG_TRYHARD = MSG_DONTROUTE,\n# define MSG_TRYHARD\tMSG_DONTROUTE\n#endif\n\tMSG_CTRUNC = 0x08,\t/* Control data lost before delivery.  */\n#define MSG_CTRUNC\tMSG_CTRUNC\n\tMSG_PROXY = 0x10,\t/* Supply or ask second address.  */\n#define MSG_PROXY\tMSG_PROXY\n\tMSG_TRUNC = 0x20,\n#define MSG_TRUNC\tMSG_TRUNC\n\tMSG_DONTWAIT = 0x40,\t/* Nonblocking IO.  */\n#define MSG_DONTWAIT\tMSG_DONTWAIT\n\tMSG_EOR = 0x80,\t\t/* End of record.  */\n#define MSG_EOR\t\tMSG_EOR\n\tMSG_WAITALL = 0x100,\t/* Wait for a full request.  */\n#define MSG_WAITALL\tMSG_WAITALL\n\tMSG_FIN = 0x200,\n#define MSG_FIN\t\tMSG_FIN\n\tMSG_SYN = 0x400,\n#define MSG_SYN\t\tMSG_SYN\n\tMSG_CONFIRM = 0x800,\t/* Confirm path validity.  */\n#define MSG_CONFIRM\tMSG_CONFIRM\n\tMSG_RST = 0x1000,\n#define MSG_RST\t\tMSG_RST\n\tMSG_ERRQUEUE = 0x2000,\t/* Fetch message from error queue.  */\n#define MSG_ERRQUEUE\tMSG_ERRQUEUE\n\tMSG_NOSIGNAL = 0x4000,\t/* Do not generate SIGPIPE.  */\n#define MSG_NOSIGNAL\tMSG_NOSIGNAL\n\tMSG_MORE = 0x8000,\t/* Sender will send more.  */\n#define MSG_MORE\tMSG_MORE\n\tMSG_WAITFORONE = 0x10000,\t/* Wait for at least one packet to return. */\n#define MSG_WAITFORONE\tMSG_WAITFORONE\n\tMSG_FASTOPEN = 0x20000000,\t/* Send data in TCP SYN.  */\n#define MSG_FASTOPEN\tMSG_FASTOPEN\n\n\tMSG_CMSG_CLOEXEC = 0x40000000\t/* Set close_on_exit for file\n\t\t\t\t\t   descriptor received through\n\t\t\t\t\t   SCM_RIGHTS.  */\n#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC\n};\n\n/* Structure describing messages sent by\n   `sendmsg' and received by `recvmsg'.  */\nstruct msghdr {\n\tvoid *msg_name;\t\t/* Address to send to/receive from.  */\n\tsocklen_t msg_namelen;\t/* Length of address data.  */\n\n\tstruct iovec *msg_iov;\t/* Vector of data to send/receive into.  */\n\tsize_t msg_iovlen;\t/* Number of elements in the vector.  */\n\n\tvoid *msg_control;\t/* Ancillary data (eg BSD filedesc passing). */\n\tsize_t msg_controllen;\t/* Ancillary data buffer length.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\n\tint msg_flags;\t\t/* Flags on received message.  */\n};\n\n/* Structure used for storage of ancillary data object information.  */\nstruct cmsghdr {\n\tsize_t cmsg_len;\t/* Length of data in cmsg_data plus length\n\t\t\t\t   of cmsghdr structure.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\tint cmsg_level;\t\t/* Originating protocol.  */\n\tint cmsg_type;\t\t/* Protocol specific type.  */\n#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L\n\t__extension__ unsigned char __cmsg_data __flexarr;\t/* Ancillary data.  */\n#endif\n};\n\n/* Ancillary data object manipulation macros.  */\n#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L\n# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)\n#else\n# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))\n#endif\n#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)\n#define CMSG_FIRSTHDR(mhdr) \\\n  ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr)\t\t      \\\n   ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)\n#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \\\n\t\t\t & (size_t) ~(sizeof (size_t) - 1))\n#define CMSG_SPACE(len) (CMSG_ALIGN (len) \\\n\t\t\t + CMSG_ALIGN (sizeof (struct cmsghdr)))\n#define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))\n\nextern struct cmsghdr *__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW;\n#ifdef __USE_EXTERN_INLINES\n# ifndef _EXTERN_INLINE\n#  define _EXTERN_INLINE __extern_inline\n# endif\n_EXTERN_INLINE struct cmsghdr *__NTH(__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg))\n{\n\tif ((size_t) __cmsg->cmsg_len < sizeof(struct cmsghdr))\n\t\t/* The kernel header does this so there may be a reason.  */\n\t\treturn (struct cmsghdr *)0;\n\n\t__cmsg = (struct cmsghdr *)((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len));\n\tif ((unsigned char *)(__cmsg + 1) > ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)\n\t    || ((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len)\n\t\t> ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)))\n\t\t/* No more entries.  */\n\t\treturn (struct cmsghdr *)0;\n\treturn __cmsg;\n}\n#endif\t\t\t\t/* Use `extern inline'.  */\n\n/* Socket level message types.  This must match the definitions in\n   <linux/socket.h>.  */\nenum {\n\tSCM_RIGHTS = 0x01\t/* Transfer file descriptors.  */\n#define SCM_RIGHTS SCM_RIGHTS\n#ifdef __USE_GNU\n\t    , SCM_CREDENTIALS = 0x02\t/* Credentials passing.  */\n# define SCM_CREDENTIALS SCM_CREDENTIALS\n#endif\n};\n\n#ifdef __USE_GNU\n/* User visible structure for SCM_CREDENTIALS message */\nstruct ucred {\n\tpid_t pid;\t\t/* PID of sending process.  */\n\tuid_t uid;\t\t/* UID of sending process.  */\n\tgid_t gid;\t\t/* GID of sending process.  */\n};\n#endif\n\n/* Ugly workaround for unclean kernel headers.  */\n#ifndef __USE_MISC\n# ifndef FIOGETOWN\n#  define __SYS_SOCKET_H_undef_FIOGETOWN\n# endif\n# ifndef FIOSETOWN\n#  define __SYS_SOCKET_H_undef_FIOSETOWN\n# endif\n# ifndef SIOCATMARK\n#  define __SYS_SOCKET_H_undef_SIOCATMARK\n# endif\n# ifndef SIOCGPGRP\n#  define __SYS_SOCKET_H_undef_SIOCGPGRP\n# endif\n# ifndef SIOCGSTAMP\n#  define __SYS_SOCKET_H_undef_SIOCGSTAMP\n# endif\n# ifndef SIOCGSTAMPNS\n#  define __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n# endif\n# ifndef SIOCSPGRP\n#  define __SYS_SOCKET_H_undef_SIOCSPGRP\n# endif\n#endif\n\n/* Get socket manipulation related informations from kernel headers.  */\n#include <asm/socket.h>\n\n#ifndef __USE_MISC\n# ifdef __SYS_SOCKET_H_undef_FIOGETOWN\n#  undef __SYS_SOCKET_H_undef_FIOGETOWN\n#  undef FIOGETOWN\n# endif\n# ifdef __SYS_SOCKET_H_undef_FIOSETOWN\n#  undef __SYS_SOCKET_H_undef_FIOSETOWN\n#  undef FIOSETOWN\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCATMARK\n#  undef __SYS_SOCKET_H_undef_SIOCATMARK\n#  undef SIOCATMARK\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGPGRP\n#  undef __SYS_SOCKET_H_undef_SIOCGPGRP\n#  undef SIOCGPGRP\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#  undef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#  undef SIOCGSTAMP\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#  undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#  undef SIOCGSTAMPNS\n# endif\n# ifdef __SYS_SOCKET_H_undef_SIOCSPGRP\n#  undef __SYS_SOCKET_H_undef_SIOCSPGRP\n#  undef SIOCSPGRP\n# endif\n#endif\n\n/* Structure used to manipulate the SO_LINGER option.  */\nstruct linger {\n\tint l_onoff;\t\t/* Nonzero to linger on close.  */\n\tint l_linger;\t\t/* Time to linger.  */\n};\n\n#endif\t\t\t\t/* bits/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/socket_type.h",
    "content": "/* Define enum __socket_type for generic Linux.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SOCKET_H\n# error \"Never include <bits/socket_type.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n/* Types of sockets.  */\nenum __socket_type {\n\tSOCK_STREAM = 1,\t/* Sequenced, reliable, connection-based\n\t\t\t\t   byte streams.  */\n#define SOCK_STREAM SOCK_STREAM\n\tSOCK_DGRAM = 2,\t\t/* Connectionless, unreliable datagrams\n\t\t\t\t   of fixed maximum length.  */\n#define SOCK_DGRAM SOCK_DGRAM\n\tSOCK_RAW = 3,\t\t/* Raw protocol interface.  */\n#define SOCK_RAW SOCK_RAW\n\tSOCK_RDM = 4,\t\t/* Reliably-delivered messages.  */\n#define SOCK_RDM SOCK_RDM\n\tSOCK_SEQPACKET = 5,\t/* Sequenced, reliable, connection-based,\n\t\t\t\t   datagrams of fixed maximum length.  */\n#define SOCK_SEQPACKET SOCK_SEQPACKET\n\tSOCK_DCCP = 6,\t\t/* Datagram Congestion Control Protocol.  */\n#define SOCK_DCCP SOCK_DCCP\n\tSOCK_PACKET = 10,\t/* Linux specific way of getting packets\n\t\t\t\t   at the dev level.  For writing rarp and\n\t\t\t\t   other similar things on the user level. */\n#define SOCK_PACKET SOCK_PACKET\n\n\t/* Flags to be ORed into the type parameter of socket and socketpair and\n\t   used for the flags parameter of paccept.  */\n\n\tSOCK_CLOEXEC = 02000000,\t/* Atomically set close-on-exec flag for the\n\t\t\t\t\t   new descriptor(s).  */\n#define SOCK_CLOEXEC SOCK_CLOEXEC\n\tSOCK_NONBLOCK = 00004000\t/* Atomically mark descriptor(s) as\n\t\t\t\t\t   non-blocking.  */\n#define SOCK_NONBLOCK SOCK_NONBLOCK\n};\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/stat.h",
    "content": "/* Copyright (C) 1999-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_STAT_H && !defined _FCNTL_H\n# error \"Never include <bits/stat.h> directly; use <sys/stat.h> instead.\"\n#endif\n\n#ifndef _BITS_STAT_H\n#define _BITS_STAT_H\t1\n\n/* Versions of the `struct stat' data structure.  */\n#ifndef __x86_64__\n# define _STAT_VER_LINUX_OLD\t1\n# define _STAT_VER_KERNEL\t1\n# define _STAT_VER_SVR4\t\t2\n# define _STAT_VER_LINUX\t3\n\n/* i386 versions of the `xmknod' interface.  */\n# define _MKNOD_VER_LINUX\t1\n# define _MKNOD_VER_SVR4\t2\n# define _MKNOD_VER\t\t_MKNOD_VER_LINUX\t/* The bits defined below.  */\n#else\n# define _STAT_VER_KERNEL\t0\n# define _STAT_VER_LINUX\t1\n\n/* x86-64 versions of the `xmknod' interface.  */\n# define _MKNOD_VER_LINUX\t0\n#endif\n\n#define _STAT_VER\t\t_STAT_VER_LINUX\n\nstruct stat {\n\t__dev_t st_dev;\t\t/* Device.  */\n#ifndef __x86_64__\n\tunsigned short int __pad1;\n#endif\n#if defined __x86_64__ || !defined __USE_FILE_OFFSET64\n\t__ino_t st_ino;\t\t/* File serial number.  */\n#else\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n#endif\n#ifndef __x86_64__\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n#else\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__mode_t st_mode;\t/* File mode.  */\n#endif\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n#ifdef __x86_64__\n\tint __pad0;\n#endif\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n#ifndef __x86_64__\n\tunsigned short int __pad2;\n#endif\n#if defined __x86_64__ || !defined __USE_FILE_OFFSET64\n\t__off_t st_size;\t/* Size of file, in bytes.  */\n#else\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n#endif\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n#if defined __x86_64__  || !defined __USE_FILE_OFFSET64\n\t__blkcnt_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#else\n\t__blkcnt64_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#endif\n#ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n# define st_atime st_atim.tv_sec\t/* Backward compatibility.  */\n# define st_mtime st_mtim.tv_sec\n# define st_ctime st_ctim.tv_sec\n#else\n\t__time_t st_atime;\t/* Time of last access.  */\n\t__syscall_ulong_t st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\t__syscall_ulong_t st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\t__syscall_ulong_t st_ctimensec;\t/* Nsecs of last status change.  */\n#endif\n#ifdef __x86_64__\n\t__syscall_slong_t __glibc_reserved[3];\n#else\n# ifndef __USE_FILE_OFFSET64\n\tunsigned long int __glibc_reserved4;\n\tunsigned long int __glibc_reserved5;\n# else\n\t__ino64_t st_ino;\t/* File serial number.  */\n# endif\n#endif\n};\n\n#ifdef __USE_LARGEFILE64\n/* Note stat64 has the same shape as stat for x86-64.  */\nstruct stat64 {\n\t__dev_t st_dev;\t\t/* Device.  */\n# ifdef __x86_64__\n\t__ino64_t st_ino;\t/* File serial number.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__mode_t st_mode;\t/* File mode.  */\n# else\n\tunsigned int __pad1;\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n# endif\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n# ifdef __x86_64__\n\tint __pad0;\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\t__off_t st_size;\t/* Size of file, in bytes.  */\n# else\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\tunsigned int __pad2;\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n# endif\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n\t__blkcnt64_t st_blocks;\t/* Nr. 512-byte blocks allocated.  */\n# ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n# else\n\t__time_t st_atime;\t/* Time of last access.  */\n\t__syscall_ulong_t st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\t__syscall_ulong_t st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\t__syscall_ulong_t st_ctimensec;\t/* Nsecs of last status change.  */\n# endif\n# ifdef __x86_64__\n\t__syscall_slong_t __glibc_reserved[3];\n# else\n\t__ino64_t st_ino;\t/* File serial number.          */\n# endif\n};\n#endif\n\n/* Tell code we have these members.  */\n#define\t_STATBUF_ST_BLKSIZE\n#define _STATBUF_ST_RDEV\n/* Nanosecond resolution time values are supported.  */\n#define _STATBUF_ST_NSEC\n\n/* Encoding of the file mode.  */\n\n#define\t__S_IFMT\t0170000\t/* These bits determine file type.  */\n\n/* File types.  */\n#define\t__S_IFDIR\t0040000\t/* Directory.  */\n#define\t__S_IFCHR\t0020000\t/* Character device.  */\n#define\t__S_IFBLK\t0060000\t/* Block device.  */\n#define\t__S_IFREG\t0100000\t/* Regular file.  */\n#define\t__S_IFIFO\t0010000\t/* FIFO.  */\n#define\t__S_IFLNK\t0120000\t/* Symbolic link.  */\n#define\t__S_IFSOCK\t0140000\t/* Socket.  */\n\n/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But\n   they do it by enforcing the correct use of the macros.  */\n#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)\n\n/* Protection bits.  */\n\n#define\t__S_ISUID\t04000\t/* Set user ID on execution.  */\n#define\t__S_ISGID\t02000\t/* Set group ID on execution.  */\n#define\t__S_ISVTX\t01000\t/* Save swapped text after use (sticky).  */\n#define\t__S_IREAD\t0400\t/* Read by owner.  */\n#define\t__S_IWRITE\t0200\t/* Write by owner.  */\n#define\t__S_IEXEC\t0100\t/* Execute by owner.  */\n\n#ifdef __USE_ATFILE\n# define UTIME_NOW\t((1l << 30) - 1l)\n# define UTIME_OMIT\t((1l << 30) - 2l)\n#endif\n\n#endif\t\t\t\t/* bits/stat.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/statfs.h",
    "content": "/* Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_STATFS_H\n# error \"Never include <bits/statfs.h> directly; use <sys/statfs.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\nstruct statfs {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n#ifndef __USE_FILE_OFFSET64\n\t__fsblkcnt_t f_blocks;\n\t__fsblkcnt_t f_bfree;\n\t__fsblkcnt_t f_bavail;\n\t__fsfilcnt_t f_files;\n\t__fsfilcnt_t f_ffree;\n#else\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n#endif\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n\n#ifdef __USE_LARGEFILE64\nstruct statfs64 {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n#endif\n\n/* Tell code we have these members.  */\n#define _STATFS_F_NAMELEN\n#define _STATFS_F_FRSIZE\n#define _STATFS_F_FLAGS\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/stdio_lim.h",
    "content": "/* Copyright (C) 1994-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _STDIO_H && !defined __need_FOPEN_MAX && !defined __need_IOV_MAX\n# error \"Never include <bits/stdio_lim.h> directly; use <stdio.h> instead.\"\n#endif\n\n#ifdef _STDIO_H\n# define L_tmpnam 20\n# define TMP_MAX 238328\n# define FILENAME_MAX 4096\n\n# ifdef __USE_POSIX\n#  define L_ctermid 9\n#  if !defined __USE_XOPEN2K || defined __USE_GNU\n#   define L_cuserid 9\n#  endif\n# endif\n#endif\n\n#if defined __need_FOPEN_MAX || defined _STDIO_H\n# undef  FOPEN_MAX\n# define FOPEN_MAX 16\n#endif\n\n#if defined __need_IOV_MAX && !defined IOV_MAX\n# define IOV_MAX 1024\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/stdlib-float.h",
    "content": "/* Floating-point inline functions for stdlib.h.\n   Copyright (C) 2012-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDLIB_H\n# error \"Never use <bits/stdlib-float.h> directly; include <stdlib.h> instead.\"\n#endif\n\n#ifdef __USE_EXTERN_INLINES\n__BEGIN_NAMESPACE_STD __extern_inline double __NTH(atof(const char *__nptr))\n{\n\treturn strtod(__nptr, (char **)NULL);\n}\n\n__END_NAMESPACE_STD\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/sys_errlist.h",
    "content": "/* Declare sys_errlist and sys_nerr, or don't.  Compatibility (do) version.\n   Copyright (C) 2002-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDIO_H\n# error \"Never include <bits/sys_errlist.h> directly; use <stdio.h> instead.\"\n#endif\n\n/* sys_errlist and sys_nerr are deprecated.  Use strerror instead.  */\n\n#ifdef  __USE_MISC\nextern int sys_nerr;\nextern const char *const sys_errlist[];\n#endif\n#ifdef  __USE_GNU\nextern int _sys_nerr;\nextern const char *const _sys_errlist[];\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/termios.h",
    "content": "/* termios type and macro definitions.  Linux version.\n   Copyright (C) 1993-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _TERMIOS_H\n# error \"Never include <bits/termios.h> directly; use <termios.h> instead.\"\n#endif\n\ntypedef unsigned char cc_t;\ntypedef unsigned int speed_t;\ntypedef unsigned int tcflag_t;\n\n#define NCCS 32\nstruct termios {\n\ttcflag_t c_iflag;\t/* input mode flags */\n\ttcflag_t c_oflag;\t/* output mode flags */\n\ttcflag_t c_cflag;\t/* control mode flags */\n\ttcflag_t c_lflag;\t/* local mode flags */\n\tcc_t c_line;\t\t/* line discipline */\n\tcc_t c_cc[NCCS];\t/* control characters */\n\tspeed_t c_ispeed;\t/* input speed */\n\tspeed_t c_ospeed;\t/* output speed */\n#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1\n#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1\n};\n\n/* c_cc characters */\n#define VINTR 0\n#define VQUIT 1\n#define VERASE 2\n#define VKILL 3\n#define VEOF 4\n#define VTIME 5\n#define VMIN 6\n#define VSWTC 7\n#define VSTART 8\n#define VSTOP 9\n#define VSUSP 10\n#define VEOL 11\n#define VREPRINT 12\n#define VDISCARD 13\n#define VWERASE 14\n#define VLNEXT 15\n#define VEOL2 16\n\n/* c_iflag bits */\n#define IGNBRK\t0000001\n#define BRKINT\t0000002\n#define IGNPAR\t0000004\n#define PARMRK\t0000010\n#define INPCK\t0000020\n#define ISTRIP\t0000040\n#define INLCR\t0000100\n#define IGNCR\t0000200\n#define ICRNL\t0000400\n#define IUCLC\t0001000\n#define IXON\t0002000\n#define IXANY\t0004000\n#define IXOFF\t0010000\n#define IMAXBEL\t0020000\n#define IUTF8\t0040000\n\n/* c_oflag bits */\n#define OPOST\t0000001\n#define OLCUC\t0000002\n#define ONLCR\t0000004\n#define OCRNL\t0000010\n#define ONOCR\t0000020\n#define ONLRET\t0000040\n#define OFILL\t0000100\n#define OFDEL\t0000200\n#if defined __USE_MISC || defined __USE_XOPEN\n# define NLDLY\t0000400\n# define   NL0\t0000000\n# define   NL1\t0000400\n# define CRDLY\t0003000\n# define   CR0\t0000000\n# define   CR1\t0001000\n# define   CR2\t0002000\n# define   CR3\t0003000\n# define TABDLY\t0014000\n# define   TAB0\t0000000\n# define   TAB1\t0004000\n# define   TAB2\t0010000\n# define   TAB3\t0014000\n# define BSDLY\t0020000\n# define   BS0\t0000000\n# define   BS1\t0020000\n# define FFDLY\t0100000\n# define   FF0\t0000000\n# define   FF1\t0100000\n#endif\n\n#define VTDLY\t0040000\n#define   VT0\t0000000\n#define   VT1\t0040000\n\n#ifdef __USE_MISC\n# define XTABS\t0014000\n#endif\n\n/* c_cflag bit meaning */\n#ifdef __USE_MISC\n# define CBAUD\t0010017\n#endif\n#define  B0\t0000000\t\t/* hang up */\n#define  B50\t0000001\n#define  B75\t0000002\n#define  B110\t0000003\n#define  B134\t0000004\n#define  B150\t0000005\n#define  B200\t0000006\n#define  B300\t0000007\n#define  B600\t0000010\n#define  B1200\t0000011\n#define  B1800\t0000012\n#define  B2400\t0000013\n#define  B4800\t0000014\n#define  B9600\t0000015\n#define  B19200\t0000016\n#define  B38400\t0000017\n#ifdef __USE_MISC\n# define EXTA B19200\n# define EXTB B38400\n#endif\n#define CSIZE\t0000060\n#define   CS5\t0000000\n#define   CS6\t0000020\n#define   CS7\t0000040\n#define   CS8\t0000060\n#define CSTOPB\t0000100\n#define CREAD\t0000200\n#define PARENB\t0000400\n#define PARODD\t0001000\n#define HUPCL\t0002000\n#define CLOCAL\t0004000\n#ifdef __USE_MISC\n# define CBAUDEX 0010000\n#endif\n#define  B57600   0010001\n#define  B115200  0010002\n#define  B230400  0010003\n#define  B460800  0010004\n#define  B500000  0010005\n#define  B576000  0010006\n#define  B921600  0010007\n#define  B1000000 0010010\n#define  B1152000 0010011\n#define  B1500000 0010012\n#define  B2000000 0010013\n#define  B2500000 0010014\n#define  B3000000 0010015\n#define  B3500000 0010016\n#define  B4000000 0010017\n#define __MAX_BAUD B4000000\n#ifdef __USE_MISC\n# define CIBAUD\t  002003600000\t/* input baud rate (not used) */\n# define CMSPAR   010000000000\t/* mark or space (stick) parity */\n# define CRTSCTS  020000000000\t/* flow control */\n#endif\n\n/* c_lflag bits */\n#define ISIG\t0000001\n#define ICANON\t0000002\n#if defined __USE_MISC || defined __USE_XOPEN\n# define XCASE\t0000004\n#endif\n#define ECHO\t0000010\n#define ECHOE\t0000020\n#define ECHOK\t0000040\n#define ECHONL\t0000100\n#define NOFLSH\t0000200\n#define TOSTOP\t0000400\n#ifdef __USE_MISC\n# define ECHOCTL 0001000\n# define ECHOPRT 0002000\n# define ECHOKE\t 0004000\n# define FLUSHO\t 0010000\n# define PENDIN\t 0040000\n#endif\n#define IEXTEN\t0100000\n#ifdef __USE_MISC\n# define EXTPROC 0200000\n#endif\n\n/* tcflow() and TCXONC use these */\n#define\tTCOOFF\t\t0\n#define\tTCOON\t\t1\n#define\tTCIOFF\t\t2\n#define\tTCION\t\t3\n\n/* tcflush() and TCFLSH use these */\n#define\tTCIFLUSH\t0\n#define\tTCOFLUSH\t1\n#define\tTCIOFLUSH\t2\n\n/* tcsetattr uses these */\n#define\tTCSANOW\t\t0\n#define\tTCSADRAIN\t1\n#define\tTCSAFLUSH\t2\n\n#define _IOT_termios /* Hurd ioctl type field.  */ \\\n  _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/time.h",
    "content": "/* System-dependent timing definitions.  Linux version.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <time.h> instead.\n */\n\n#if defined __need_timeval || defined __USE_GNU\n# ifndef _STRUCT_TIMEVAL\n#  define _STRUCT_TIMEVAL\t1\n#  include <bits/types.h>\n\n/* A time value that is accurate to the nearest\n   microsecond but also has a range of years.  */\nstruct timeval {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__suseconds_t tv_usec;\t/* Microseconds.  */\n};\n# endif\t\t\t\t/* struct timeval */\n#endif\n\n#ifndef __need_timeval\n# ifndef _BITS_TIME_H\n#  define _BITS_TIME_H\t1\n\n/* ISO/IEC 9899:1999 7.23.1: Components of time\n   The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is\n   the number per second of the value returned by the `clock' function.  */\n/* CAE XSH, Issue 4, Version 2: <time.h>\n   The value of CLOCKS_PER_SEC is required to be 1 million on all\n   XSI-conformant systems. */\n#  define CLOCKS_PER_SEC  ((clock_t) 1000000)\n\n#  if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \\\n   && !defined __USE_XOPEN2K\n/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK\n   presents the real value for clock ticks per second for the system.  */\n#   include <bits/types.h>\nextern long int __sysconf(int);\n#   define CLK_TCK ((__clock_t) __sysconf (2))\t/* 2 is _SC_CLK_TCK */\n#  endif\n\n#  ifdef __USE_POSIX199309\n/* Identifier for system-wide realtime clock.  */\n#   define CLOCK_REALTIME\t\t0\n/* Monotonic system-wide clock.  */\n#   define CLOCK_MONOTONIC\t\t1\n/* High-resolution timer from the CPU.  */\n#   define CLOCK_PROCESS_CPUTIME_ID\t2\n/* Thread-specific CPU-time clock.  */\n#   define CLOCK_THREAD_CPUTIME_ID\t3\n/* Monotonic system-wide clock, not adjusted for frequency scaling.  */\n#   define CLOCK_MONOTONIC_RAW\t\t4\n/* Identifier for system-wide realtime clock, updated only on ticks.  */\n#   define CLOCK_REALTIME_COARSE\t5\n/* Monotonic system-wide clock, updated only on ticks.  */\n#   define CLOCK_MONOTONIC_COARSE\t6\n/* Monotonic system-wide clock that includes time spent in suspension.  */\n#   define CLOCK_BOOTTIME\t\t7\n/* Like CLOCK_REALTIME but also wakes suspended system.  */\n#   define CLOCK_REALTIME_ALARM\t\t8\n/* Like CLOCK_BOOTTIME but also wakes suspended system.  */\n#   define CLOCK_BOOTTIME_ALARM\t\t9\n/* Like CLOCK_REALTIME but in International Atomic Time.  */\n#   define CLOCK_TAI\t\t\t11\n\n/* Flag to indicate time is absolute.  */\n#   define TIMER_ABSTIME\t\t1\n#  endif\n\n#  ifdef __USE_GNU\n#   include <bits/timex.h>\n\n__BEGIN_DECLS\n/* Tune a POSIX clock.  */\nextern int clock_adjtime(__clockid_t __clock_id, struct timex *__utx) __THROW;\n\n__END_DECLS\n#  endif\t\t\t/* use GNU */\n# endif\t\t\t\t/* bits/time.h */\n#endif\n#undef __need_timeval\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/types.h",
    "content": "/* bits/types.h -- definitions of __*_t types underlying *_t types.\n   Copyright (C) 2002-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/types.h> instead.\n */\n\n#ifndef\t_BITS_TYPES_H\n#define\t_BITS_TYPES_H\t1\n\n#include <features.h>\n#include <bits/wordsize.h>\n\n/* Convenience types.  */\ntypedef unsigned char __u_char;\ntypedef unsigned short int __u_short;\ntypedef unsigned int __u_int;\ntypedef unsigned long int __u_long;\n\n/* Fixed-size types, underlying types depend on word size and compiler.  */\ntypedef signed char __int8_t;\ntypedef unsigned char __uint8_t;\ntypedef signed short int __int16_t;\ntypedef unsigned short int __uint16_t;\ntypedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\n#if __WORDSIZE == 64\ntypedef signed long int __int64_t;\ntypedef unsigned long int __uint64_t;\n#else\n__extension__ typedef signed long long int __int64_t;\n__extension__ typedef unsigned long long int __uint64_t;\n#endif\n\n/* quad_t is also 64 bits.  */\n#if __WORDSIZE == 64\ntypedef long int __quad_t;\ntypedef unsigned long int __u_quad_t;\n#else\n__extension__ typedef long long int __quad_t;\n__extension__ typedef unsigned long long int __u_quad_t;\n#endif\n\n/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE\n   macros for each of the OS types we define below.  The definitions\n   of those macros must use the following macros for underlying types.\n   We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned\n   variants of each of the following integer types on this machine.\n\n\t16\t\t-- \"natural\" 16-bit type (always short)\n\t32\t\t-- \"natural\" 32-bit type (always int)\n\t64\t\t-- \"natural\" 64-bit type (long or long long)\n\tLONG32\t\t-- 32-bit type, traditionally long\n\tQUAD\t\t-- 64-bit type, always long long\n\tWORD\t\t-- natural type of __WORDSIZE bits (int or long)\n\tLONGWORD\t-- type of __WORDSIZE bits, traditionally long\n\n   We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the\n   conventional uses of `long' or `long long' type modifiers match the\n   types we define, even when a less-adorned type would be the same size.\n   This matters for (somewhat) portably writing printf/scanf formats for\n   these types, where using the appropriate l or ll format modifiers can\n   make the typedefs and the formats match up across all GNU platforms.  If\n   we used `long' when it's 64 bits where `long long' is expected, then the\n   compiler would warn about the formats not matching the argument types,\n   and the programmer changing them to shut up the compiler would break the\n   program's portability.\n\n   Here we assume what is presently the case in all the GCC configurations\n   we support: long long is always 64 bits, long is always word/address size,\n   and int is always 32 bits.  */\n\n#define\t__S16_TYPE\t\tshort int\n#define __U16_TYPE\t\tunsigned short int\n#define\t__S32_TYPE\t\tint\n#define __U32_TYPE\t\tunsigned int\n#define __SLONGWORD_TYPE\tlong int\n#define __ULONGWORD_TYPE\tunsigned long int\n#if __WORDSIZE == 32\n# define __SQUAD_TYPE\t\t__quad_t\n# define __UQUAD_TYPE\t\t__u_quad_t\n# define __SWORD_TYPE\t\tint\n# define __UWORD_TYPE\t\tunsigned int\n# define __SLONG32_TYPE\t\tlong int\n# define __ULONG32_TYPE\t\tunsigned long int\n# define __S64_TYPE\t\t__quad_t\n# define __U64_TYPE\t\t__u_quad_t\n/* We want __extension__ before typedef's that use nonstandard base types\n   such as `long long' in C89 mode.  */\n# define __STD_TYPE\t\t__extension__ typedef\n#elif __WORDSIZE == 64\n# define __SQUAD_TYPE\t\tlong int\n# define __UQUAD_TYPE\t\tunsigned long int\n# define __SWORD_TYPE\t\tlong int\n# define __UWORD_TYPE\t\tunsigned long int\n# define __SLONG32_TYPE\t\tint\n# define __ULONG32_TYPE\t\tunsigned int\n# define __S64_TYPE\t\tlong int\n# define __U64_TYPE\t\tunsigned long int\n/* No need to mark the typedef with __extension__.   */\n# define __STD_TYPE\t\ttypedef\n#else\n# error\n#endif\n#include <bits/typesizes.h>\t/* Defines __*_T_TYPE macros.  */\n\n__STD_TYPE __DEV_T_TYPE __dev_t;\t/* Type of device numbers.  */\n__STD_TYPE __UID_T_TYPE __uid_t;\t/* Type of user identifications.  */\n__STD_TYPE __GID_T_TYPE __gid_t;\t/* Type of group identifications.  */\n__STD_TYPE __INO_T_TYPE __ino_t;\t/* Type of file serial numbers.  */\n__STD_TYPE __INO64_T_TYPE __ino64_t;\t/* Type of file serial numbers (LFS). */\n__STD_TYPE __MODE_T_TYPE __mode_t;\t/* Type of file attribute bitmasks.  */\n__STD_TYPE __NLINK_T_TYPE __nlink_t;\t/* Type of file link counts.  */\n__STD_TYPE __OFF_T_TYPE __off_t;\t/* Type of file sizes and offsets.  */\n__STD_TYPE __OFF64_T_TYPE __off64_t;\t/* Type of file sizes and offsets (LFS).  */\n__STD_TYPE __PID_T_TYPE __pid_t;\t/* Type of process identifications.  */\n__STD_TYPE __FSID_T_TYPE __fsid_t;\t/* Type of file system IDs.  */\n__STD_TYPE __CLOCK_T_TYPE __clock_t;\t/* Type of CPU usage counts.  */\n__STD_TYPE __RLIM_T_TYPE __rlim_t;\t/* Type for resource measurement.  */\n__STD_TYPE __RLIM64_T_TYPE __rlim64_t;\t/* Type for resource measurement (LFS).  */\n__STD_TYPE __ID_T_TYPE __id_t;\t/* General type for IDs.  */\n__STD_TYPE __TIME_T_TYPE __time_t;\t/* Seconds since the Epoch.  */\n__STD_TYPE __USECONDS_T_TYPE __useconds_t;\t/* Count of microseconds.  */\n__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t;\t/* Signed count of microseconds.  */\n\n__STD_TYPE __DADDR_T_TYPE __daddr_t;\t/* The type of a disk address.  */\n__STD_TYPE __KEY_T_TYPE __key_t;\t/* Type of an IPC key.  */\n\n/* Clock ID used in clock and timer functions.  */\n__STD_TYPE __CLOCKID_T_TYPE __clockid_t;\n\n/* Timer ID returned by `timer_create'.  */\n__STD_TYPE __TIMER_T_TYPE __timer_t;\n\n/* Type to represent block size.  */\n__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;\n\n/* Types from the Large File Support interface.  */\n\n/* Type to count number of disk blocks.  */\n__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;\n__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;\n\n/* Type to count file system blocks.  */\n__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;\n__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;\n\n/* Type to count file system nodes.  */\n__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;\n__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;\n\n/* Type of miscellaneous file system fields.  */\n__STD_TYPE __FSWORD_T_TYPE __fsword_t;\n\n__STD_TYPE __SSIZE_T_TYPE __ssize_t;\t/* Type of a byte count, or error.  */\n\n/* Signed long type used in system calls.  */\n__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;\n/* Unsigned long type used in system calls.  */\n__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;\n\n/* These few don't really vary by system, they always correspond\n   to one of the other defined types.  */\ntypedef __off64_t __loff_t;\t/* Type of file sizes and offsets (LFS).  */\ntypedef __quad_t *__qaddr_t;\ntypedef char *__caddr_t;\n\n/* Duplicates info from stdint.h but this is used in unistd.h.  */\n__STD_TYPE __SWORD_TYPE __intptr_t;\n\n/* Duplicate info from sys/socket.h.  */\n__STD_TYPE __U32_TYPE __socklen_t;\n\n#undef __STD_TYPE\n\n#endif\t\t\t\t/* bits/types.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/typesizes.h",
    "content": "/* bits/typesizes.h -- underlying types for *_t.  Linux/x86-64 version.\n   Copyright (C) 2012-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_TYPES_H\n# error \"Never include <bits/typesizes.h> directly; use <sys/types.h> instead.\"\n#endif\n\n#ifndef\t_BITS_TYPESIZES_H\n#define\t_BITS_TYPESIZES_H\t1\n\n/* See <bits/types.h> for the meaning of these macros.  This file exists so\n   that <bits/types.h> need not vary across different GNU platforms.  */\n\n/* X32 kernel interface is 64-bit.  */\n#if defined __x86_64__ && defined __ILP32__\n# define __SYSCALL_SLONG_TYPE\t__SQUAD_TYPE\n# define __SYSCALL_ULONG_TYPE\t__UQUAD_TYPE\n#else\n# define __SYSCALL_SLONG_TYPE\t__SLONGWORD_TYPE\n# define __SYSCALL_ULONG_TYPE\t__ULONGWORD_TYPE\n#endif\n\n#define __DEV_T_TYPE\t\t__UQUAD_TYPE\n#define __UID_T_TYPE\t\t__U32_TYPE\n#define __GID_T_TYPE\t\t__U32_TYPE\n#define __INO_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n#define __INO64_T_TYPE\t\t__UQUAD_TYPE\n#define __MODE_T_TYPE\t\t__U32_TYPE\n#ifdef __x86_64__\n# define __NLINK_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n# define __FSWORD_T_TYPE\t__SYSCALL_SLONG_TYPE\n#else\n# define __NLINK_T_TYPE\t\t__UWORD_TYPE\n# define __FSWORD_T_TYPE\t__SWORD_TYPE\n#endif\n#define __OFF_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __OFF64_T_TYPE\t\t__SQUAD_TYPE\n#define __PID_T_TYPE\t\t__S32_TYPE\n#define __RLIM_T_TYPE\t\t__SYSCALL_ULONG_TYPE\n#define __RLIM64_T_TYPE\t\t__UQUAD_TYPE\n#define __BLKCNT_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __BLKCNT64_T_TYPE\t__SQUAD_TYPE\n#define __FSBLKCNT_T_TYPE\t__SYSCALL_ULONG_TYPE\n#define __FSBLKCNT64_T_TYPE\t__UQUAD_TYPE\n#define __FSFILCNT_T_TYPE\t__SYSCALL_ULONG_TYPE\n#define __FSFILCNT64_T_TYPE\t__UQUAD_TYPE\n#define __ID_T_TYPE\t\t__U32_TYPE\n#define __CLOCK_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __TIME_T_TYPE\t\t__SYSCALL_SLONG_TYPE\n#define __USECONDS_T_TYPE\t__U32_TYPE\n#define __SUSECONDS_T_TYPE\t__SYSCALL_SLONG_TYPE\n#define __DADDR_T_TYPE\t\t__S32_TYPE\n#define __KEY_T_TYPE\t\t__S32_TYPE\n#define __CLOCKID_T_TYPE\t__S32_TYPE\n#define __TIMER_T_TYPE\t\tvoid *\n#define __BLKSIZE_T_TYPE\t__SYSCALL_SLONG_TYPE\n#define __FSID_T_TYPE\t\tstruct { int __val[2]; }\n#define __SSIZE_T_TYPE\t\t__SWORD_TYPE\n\n#ifdef __x86_64__\n/* Tell the libc code that off_t and off64_t are actually the same type\n   for all ABI purposes, even if possibly expressed as different base types\n   for C type-checking purposes.  */\n# define __OFF_T_MATCHES_OFF64_T\t1\n\n/* Same for ino_t and ino64_t.  */\n# define __INO_T_MATCHES_INO64_T\t1\n#endif\n\n/* Number of descriptors that can fit in an `fd_set'.  */\n#define __FD_SETSIZE\t\t1024\n\n#endif\t\t\t\t/* bits/typesizes.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/uio.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_UIO_H && !defined _FCNTL_H\n# error \"Never include <bits/uio.h> directly; use <sys/uio.h> instead.\"\n#endif\n\n#ifndef _BITS_UIO_H\n#define _BITS_UIO_H\t1\n\n#include <sys/types.h>\n\n/* We should normally use the Linux kernel header file to define this\n   type and macros but this calls for trouble because of the header\n   includes other kernel headers.  */\n\n/* Size of object which can be written atomically.\n\n   This macro has different values in different kernel versions.  The\n   latest versions of the kernel use 1024 and this is good choice.  Since\n   the C library implementation of readv/writev is able to emulate the\n   functionality even if the currently running kernel does not support\n   this large value the readv/writev call will not fail because of this.  */\n#define UIO_MAXIOV\t1024\n\n/* Structure for scatter/gather I/O.  */\nstruct iovec {\n\tvoid *iov_base;\t\t/* Pointer to data.  */\n\tsize_t iov_len;\t\t/* Length of data.  */\n};\n\n#endif\n\n#ifdef __USE_GNU\n# if defined _SYS_UIO_H && !defined _BITS_UIO_H_FOR_SYS_UIO_H\n#  define _BITS_UIO_H_FOR_SYS_UIO_H 1\n\n__BEGIN_DECLS\n/* Read from another process' address space.  */\nextern ssize_t process_vm_readv(pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt, unsigned long int __flags) __THROW;\n\n/* Write to another process' address space.  */\nextern ssize_t process_vm_writev(pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt, unsigned long int __flags) __THROW;\n\n__END_DECLS\n# endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/utsname.h",
    "content": "/* Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UTSNAME_H\n# error \"Never include <bits/utsname.h> directly; use <sys/utsname.h> instead.\"\n#endif\n\n/* Length of the entries in `struct utsname' is 65.  */\n#define _UTSNAME_LENGTH 65\n\n/* Linux provides as additional information in the `struct utsname'\n   the name of the current domain.  Define _UTSNAME_DOMAIN_LENGTH\n   to a value != 0 to activate this entry.  */\n#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/waitflags.h",
    "content": "/* Definitions of flag bits for `waitpid' et al.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n# error \"Never include <bits/waitflags.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Bits in the third argument to `waitpid'.  */\n#define\tWNOHANG\t\t1\t/* Don't block waiting.  */\n#define\tWUNTRACED\t2\t/* Report status of stopped children.  */\n\n/* Bits in the fourth argument to `waitid'.  */\n#define WSTOPPED\t2\t/* Report stopped child (same as WUNTRACED). */\n#define WEXITED\t\t4\t/* Report dead child.  */\n#define WCONTINUED\t8\t/* Report continued child.  */\n#define WNOWAIT\t\t0x01000000\t/* Don't reap, just poll status.  */\n\n#define __WNOTHREAD     0x20000000\t/* Don't wait on children of other threads\n\t\t\t\t\t   in this group */\n#define __WALL\t\t0x40000000\t/* Wait for any child.  */\n#define __WCLONE\t0x80000000\t/* Wait for cloned process.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/waitstatus.h",
    "content": "/* Definitions of status bits for `wait' et al.\n   Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n# error \"Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Everything extant so far uses these same bits.  */\n\n/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */\n#define\t__WEXITSTATUS(status)\t(((status) & 0xff00) >> 8)\n\n/* If WIFSIGNALED(STATUS), the terminating signal.  */\n#define\t__WTERMSIG(status)\t((status) & 0x7f)\n\n/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */\n#define\t__WSTOPSIG(status)\t__WEXITSTATUS(status)\n\n/* Nonzero if STATUS indicates normal termination.  */\n#define\t__WIFEXITED(status)\t(__WTERMSIG(status) == 0)\n\n/* Nonzero if STATUS indicates termination by a signal.  */\n#define __WIFSIGNALED(status) \\\n  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)\n\n/* Nonzero if STATUS indicates the child is stopped.  */\n#define\t__WIFSTOPPED(status)\t(((status) & 0xff) == 0x7f)\n\n/* Nonzero if STATUS indicates the child continued after a stop.  We only\n   define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */\n#ifdef WCONTINUED\n# define __WIFCONTINUED(status)\t((status) == __W_CONTINUED)\n#endif\n\n/* Nonzero if STATUS indicates the child dumped core.  */\n#define\t__WCOREDUMP(status)\t((status) & __WCOREFLAG)\n\n/* Macros for constructing status values.  */\n#define\t__W_EXITCODE(ret, sig)\t((ret) << 8 | (sig))\n#define\t__W_STOPCODE(sig)\t((sig) << 8 | 0x7f)\n#define __W_CONTINUED\t\t0xffff\n#define\t__WCOREFLAG\t\t0x80\n\n#ifdef\t__USE_MISC\n\n# include <endian.h>\n\nunion wait {\n\tint w_status;\n\tstruct {\n# if\t__BYTE_ORDER == __LITTLE_ENDIAN\n\t\tunsigned int __w_termsig:7;\t/* Terminating signal.  */\n\t\tunsigned int __w_coredump:1;\t/* Set if dumped core.  */\n\t\tunsigned int __w_retcode:8;\t/* Return code if exited normally.  */\n\t\tunsigned int:16;\n# endif\t\t\t\t/* Little endian.  */\n# if\t__BYTE_ORDER == __BIG_ENDIAN\n\t\tunsigned int:16;\n\t\tunsigned int __w_retcode:8;\n\t\tunsigned int __w_coredump:1;\n\t\tunsigned int __w_termsig:7;\n# endif\t\t\t\t/* Big endian.  */\n\t} __wait_terminated;\n\tstruct {\n# if\t__BYTE_ORDER == __LITTLE_ENDIAN\n\t\tunsigned int __w_stopval:8;\t/* W_STOPPED if stopped.  */\n\t\tunsigned int __w_stopsig:8;\t/* Stopping signal.  */\n\t\tunsigned int:16;\n# endif\t\t\t\t/* Little endian.  */\n# if\t__BYTE_ORDER == __BIG_ENDIAN\n\t\tunsigned int:16;\n\t\tunsigned int __w_stopsig:8;\t/* Stopping signal.  */\n\t\tunsigned int __w_stopval:8;\t/* W_STOPPED if stopped.  */\n# endif\t\t\t\t/* Big endian.  */\n\t} __wait_stopped;\n};\n\n# define w_termsig\t__wait_terminated.__w_termsig\n# define w_coredump\t__wait_terminated.__w_coredump\n# define w_retcode\t__wait_terminated.__w_retcode\n# define w_stopsig\t__wait_stopped.__w_stopsig\n# define w_stopval\t__wait_stopped.__w_stopval\n\n#endif\t\t\t\t/* Use misc.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/wchar.h",
    "content": "/* wchar_t type related definitions.\n   Copyright (C) 2000-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_WCHAR_H\n#define _BITS_WCHAR_H\t1\n\n/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__\n   are not defined, give the right value and type as long as both int\n   and wchar_t are 32-bit types.  Adding L'\\0' to a constant value\n   ensures that the type is correct; it is necessary to use (L'\\0' +\n   0) rather than just L'\\0' so that the type in C++ is the promoted\n   version of wchar_t rather than the distinct wchar_t type itself.\n   Because wchar_t in preprocessor #if expressions is treated as\n   intmax_t or uintmax_t, the expression (L'\\0' - 1) would have the\n   wrong value for WCHAR_MAX in such expressions and so cannot be used\n   to define __WCHAR_MAX in the unsigned case.  */\n\n#ifdef __WCHAR_MAX__\n# define __WCHAR_MAX\t__WCHAR_MAX__\n#elif L'\\0' - 1 > 0\n# define __WCHAR_MAX\t(0xffffffffu + L'\\0')\n#else\n# define __WCHAR_MAX\t(0x7fffffff + L'\\0')\n#endif\n\n#ifdef __WCHAR_MIN__\n# define __WCHAR_MIN\t__WCHAR_MIN__\n#elif L'\\0' - 1 > 0\n# define __WCHAR_MIN\t(L'\\0' + 0)\n#else\n# define __WCHAR_MIN\t(-__WCHAR_MAX - 1)\n#endif\n\n#endif\t\t\t\t/* bits/wchar.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/wordsize.h",
    "content": "/* Determine the wordsize from the preprocessor defines.  */\n\n#if defined __x86_64__ && !defined __ILP32__\n# define __WORDSIZE\t64\n#else\n# define __WORDSIZE\t32\n#endif\n\n#ifdef __x86_64__\n# define __WORDSIZE_TIME64_COMPAT32\t1\n/* Both x86-64 and x32 use the 64-bit system call interface.  */\n# define __SYSCALL_WORDSIZE\t\t64\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/bits/xopen_lim.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <limits.h> instead.\n */\n\n/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2\n   System Interfaces and Headers, 4.16 <limits.h>\n\n   Please note only the values which are not greater than the minimum\n   stated in the standard document are listed.  The `sysconf' functions\n   should be used to obtain the actual value.  */\n\n#ifndef _XOPEN_LIM_H\n#define _XOPEN_LIM_H\t1\n\n#define __need_IOV_MAX\n#include <bits/stdio_lim.h>\n\n/* We do not provide fixed values for\n\n   ARG_MAX\tMaximum length of argument to the `exec' function\n\t\tincluding environment data.\n\n   ATEXIT_MAX\tMaximum number of functions that may be registered\n\t\twith `atexit'.\n\n   CHILD_MAX\tMaximum number of simultaneous processes per real\n\t\tuser ID.\n\n   OPEN_MAX\tMaximum number of files that one process can have open\n\t\tat anyone time.\n\n   PAGESIZE\n   PAGE_SIZE\tSize of bytes of a page.\n\n   PASS_MAX\tMaximum number of significant bytes in a password.\n\n   We only provide a fixed limit for\n\n   IOV_MAX\tMaximum number of `iovec' structures that one process has\n\t\tavailable for use with `readv' or writev'.\n\n   if this is indeed fixed by the underlying system.\n*/\n\n/* Maximum number of `iovec' structures that one process has available\n   for use with `readv' or writev'.  */\n#define\t_XOPEN_IOV_MAX\t_POSIX_UIO_MAXIOV\n\n/* Maximum value of `digit' in calls to the `printf' and `scanf'\n   functions.  We have no limit, so return a reasonable value.  */\n#define NL_ARGMAX\t_POSIX_ARG_MAX\n\n/* Maximum number of bytes in a `LANG' name.  We have no limit.  */\n#define NL_LANGMAX\t_POSIX2_LINE_MAX\n\n/* Maximum message number.  We have no limit.  */\n#define NL_MSGMAX\tINT_MAX\n\n/* Maximum number of bytes in N-to-1 collation mapping.  We have no\n   limit.  */\n#define NL_NMAX\t\tINT_MAX\n\n/* Maximum set number.  We have no limit.  */\n#define NL_SETMAX\tINT_MAX\n\n/* Maximum number of bytes in a message.  We have no limit.  */\n#define NL_TEXTMAX\tINT_MAX\n\n/* Default process priority.  */\n#define NZERO\t\t20\n\n/* Number of bits in a word of type `int'.  */\n#ifdef INT_MAX\n# if INT_MAX == 32767\n#  define WORD_BIT\t16\n# else\n#  if INT_MAX == 2147483647\n#   define WORD_BIT\t32\n#  else\n/* Safe assumption.  */\n#   define WORD_BIT\t64\n#  endif\n# endif\n#elif defined __INT_MAX__\n# if __INT_MAX__ == 32767\n#  define WORD_BIT\t16\n# else\n#  if __INT_MAX__ == 2147483647\n#   define WORD_BIT\t32\n#  else\n/* Safe assumption.  */\n#   define WORD_BIT\t64\n#  endif\n# endif\n#else\n# define WORD_BIT\t32\n#endif\n\n/* Number of bits in a word of type `long int'.  */\n#ifdef LONG_MAX\n# if LONG_MAX == 2147483647\n#  define LONG_BIT\t32\n# else\n/* Safe assumption.  */\n#  define LONG_BIT\t64\n# endif\n#elif defined __LONG_MAX__\n# if __LONG_MAX__ == 2147483647\n#  define LONG_BIT\t32\n# else\n/* Safe assumption.  */\n#  define LONG_BIT\t64\n# endif\n#else\n# include <bits/wordsize.h>\n# if __WORDSIZE == 64\n#  define LONG_BIT\t64\n# else\n#  define LONG_BIT\t32\n# endif\n#endif\n\n#endif\t\t\t\t/* bits/xopen_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/ctype.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard 7.4: Character handling\t<ctype.h>\n */\n\n#ifndef\t_CTYPE_H\n#define\t_CTYPE_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n#ifndef _ISbit\n/* These are all the characteristics of characters.\n   If there get to be more than 16 distinct characteristics,\n   many things must be changed that use `unsigned short int's.\n\n   The characteristics are stored always in network byte order (big\n   endian).  We define the bit value interpretations here dependent on the\n   machine's byte order.  */\n# include <endian.h>\n# if __BYTE_ORDER == __BIG_ENDIAN\n#  define _ISbit(bit)\t(1 << (bit))\n# else\t\t\t\t/* __BYTE_ORDER == __LITTLE_ENDIAN */\n#  define _ISbit(bit)\t((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))\n# endif\n    enum {\n\t_ISupper = _ISbit(0),\t/* UPPERCASE.  */\n\t_ISlower = _ISbit(1),\t/* lowercase.  */\n\t_ISalpha = _ISbit(2),\t/* Alphabetic.  */\n\t_ISdigit = _ISbit(3),\t/* Numeric.  */\n\t_ISxdigit = _ISbit(4),\t/* Hexadecimal numeric.  */\n\t_ISspace = _ISbit(5),\t/* Whitespace.  */\n\t_ISprint = _ISbit(6),\t/* Printing.  */\n\t_ISgraph = _ISbit(7),\t/* Graphical.  */\n\t_ISblank = _ISbit(8),\t/* Blank (usually SPC and TAB).  */\n\t_IScntrl = _ISbit(9),\t/* Control character.  */\n\t_ISpunct = _ISbit(10),\t/* Punctuation.  */\n\t_ISalnum = _ISbit(11)\t/* Alphanumeric.  */\n};\n#endif\t\t\t\t/* ! _ISbit  */\n\n/* These are defined in ctype-info.c.\n   The declarations here must match those in localeinfo.h.\n\n   In the thread-specific locale model (see `uselocale' in <locale.h>)\n   we cannot use global variables for these as was done in the past.\n   Instead, the following accessor functions return the address of\n   each variable, which is local to the current thread if multithreaded.\n\n   These point into arrays of 384, so they can be indexed by any `unsigned\n   char' value [0,255]; by EOF (-1); or by any `signed char' value\n   [-128,-1).  ISO C requires that the ctype functions work for `unsigned\n   char' values and for EOF; we also support negative `signed char' values\n   for broken old programs.  The case conversion arrays are of `int's\n   rather than `unsigned char's because tolower (EOF) must be EOF, which\n   doesn't fit into an `unsigned char'.  But today more important is that\n   the arrays are also used for multi-byte character sets.  */\nextern const unsigned short int **__ctype_b_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_tolower_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_toupper_loc(void)\n__THROW __attribute__ ((__const__));\n\n#ifndef __cplusplus\n# define __isctype(c, type) \\\n  ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)\n#elif defined __USE_EXTERN_INLINES\n# define __isctype_f(type) \\\n  __extern_inline int\t\t\t\t\t\t\t      \\\n  is##type (int __c) __THROW\t\t\t\t\t\t      \\\n  {\t\t\t\t\t\t\t\t\t      \\\n    return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \\\n  }\n#endif\n\n#define\t__isascii(c)\t(((c) & ~0x7f) == 0)\t/* If C is a 7 bit value.  */\n#define\t__toascii(c)\t((c) & 0x7f)\t/* Mask off high bits.  */\n\n#define\t__exctype(name)\textern int name (int) __THROW\n\n__BEGIN_NAMESPACE_STD\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype(isalnum);\n__exctype(isalpha);\n__exctype(iscntrl);\n__exctype(isdigit);\n__exctype(islower);\n__exctype(isgraph);\n__exctype(isprint);\n__exctype(ispunct);\n__exctype(isspace);\n__exctype(isupper);\n__exctype(isxdigit);\n\n/* Return the lowercase version of C.  */\nextern int tolower(int __c) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int toupper(int __c) __THROW;\n\n__END_NAMESPACE_STD\n/* ISO C99 introduced one new function.  */\n#ifdef\t__USE_ISOC99\n__BEGIN_NAMESPACE_C99 __exctype(isblank);\n\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Test C for a set of character classes according to MASK.  */\nextern int isctype(int __c, int __mask) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n\n/* Return nonzero iff C is in the ASCII set\n   (i.e., is no more than 7 bits wide).  */\nextern int isascii(int __c) __THROW;\n\n/* Return the part of C that is in the ASCII set\n   (i.e., the low-order 7 bits of C).  */\nextern int toascii(int __c) __THROW;\n\n/* These are the same as `toupper' and `tolower' except that they do not\n   check the argument for being in the range of a `char'.  */\n__exctype(_toupper);\n__exctype(_tolower);\n#endif\t\t\t\t/* Use X/Open or use misc.  */\n\n/* This code is needed for the optimized mapping functions.  */\n#define __tobody(c, f, a, args) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ int __res;\t\t\t\t\t\t\t      \\\n      if (sizeof (c) > 1)\t\t\t\t\t\t      \\\n\t{\t\t\t\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (c))\t\t\t\t\t      \\\n\t    {\t\t\t\t\t\t\t\t      \\\n\t      int __c = (c);\t\t\t\t\t\t      \\\n\t      __res = __c < -128 || __c > 255 ? __c : (a)[__c];\t\t      \\\n\t    }\t\t\t\t\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __res = f args;\t\t\t\t\t\t      \\\n\t}\t\t\t\t\t\t\t\t      \\\n      else\t\t\t\t\t\t\t\t      \\\n\t__res = (a)[(int) (c)];\t\t\t\t\t\t      \\\n      __res; }))\n\n#if !defined __NO_CTYPE\n# ifdef __isctype_f\n__isctype_f(alnum)\n    __isctype_f(alpha)\n    __isctype_f(cntrl)\n    __isctype_f(digit)\n    __isctype_f(lower)\n    __isctype_f(graph)\n    __isctype_f(print)\n    __isctype_f(punct)\n    __isctype_f(space)\n    __isctype_f(upper)\n    __isctype_f(xdigit)\n#  ifdef __USE_ISOC99\n    __isctype_f(blank)\n#  endif\n# elif defined __isctype\n# define isalnum(c)\t__isctype((c), _ISalnum)\n# define isalpha(c)\t__isctype((c), _ISalpha)\n# define iscntrl(c)\t__isctype((c), _IScntrl)\n# define isdigit(c)\t__isctype((c), _ISdigit)\n# define islower(c)\t__isctype((c), _ISlower)\n# define isgraph(c)\t__isctype((c), _ISgraph)\n# define isprint(c)\t__isctype((c), _ISprint)\n# define ispunct(c)\t__isctype((c), _ISpunct)\n# define isspace(c)\t__isctype((c), _ISspace)\n# define isupper(c)\t__isctype((c), _ISupper)\n# define isxdigit(c)\t__isctype((c), _ISxdigit)\n#  ifdef __USE_ISOC99\n#   define isblank(c)\t__isctype((c), _ISblank)\n#  endif\n# endif\n\n# ifdef __USE_EXTERN_INLINES\n__extern_inline int __NTH(tolower(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_tolower_loc())[__c] : __c;\n}\n\n__extern_inline int __NTH(toupper(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_toupper_loc())[__c] : __c;\n}\n# endif\n\n# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#  define tolower(c)\t__tobody (c, tolower, *__ctype_tolower_loc (), (c))\n#  define toupper(c)\t__tobody (c, toupper, *__ctype_toupper_loc (), (c))\n# endif\t\t\t\t/* Optimizing gcc */\n\n# if defined __USE_MISC || defined __USE_XOPEN\n#  define isascii(c)\t__isascii (c)\n#  define toascii(c)\t__toascii (c)\n\n#  define _tolower(c)\t((int) (*__ctype_tolower_loc ())[(int) (c)])\n#  define _toupper(c)\t((int) (*__ctype_toupper_loc ())[(int) (c)])\n# endif\n\n#endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#ifdef __USE_XOPEN2K8\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n# include <xlocale.h>\n\n/* These definitions are similar to the ones above but all functions\n   take as an argument a handle for the locale which shall be used.  */\n#  define __isctype_l(c, type, locale) \\\n  ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)\n\n# define __exctype_l(name) \t\t\t\t\t\t      \\\n  extern int name (int, __locale_t) __THROW\n\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c, locale_t *locale);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype_l(isalnum_l);\n__exctype_l(isalpha_l);\n__exctype_l(iscntrl_l);\n__exctype_l(isdigit_l);\n__exctype_l(islower_l);\n__exctype_l(isgraph_l);\n__exctype_l(isprint_l);\n__exctype_l(ispunct_l);\n__exctype_l(isspace_l);\n__exctype_l(isupper_l);\n__exctype_l(isxdigit_l);\n\n__exctype_l(isblank_l);\n\n/* Return the lowercase version of C in locale L.  */\nextern int __tolower_l(int __c, __locale_t __l) __THROW;\nextern int tolower_l(int __c, __locale_t __l) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int __toupper_l(int __c, __locale_t __l) __THROW;\nextern int toupper_l(int __c, __locale_t __l) __THROW;\n\n# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#  define __tolower_l(c, locale) \\\n  __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))\n#  define __toupper_l(c, locale) \\\n  __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))\n#  define tolower_l(c, locale)\t__tolower_l ((c), (locale))\n#  define toupper_l(c, locale)\t__toupper_l ((c), (locale))\n# endif\t\t\t\t/* Optimizing gcc */\n\n# ifndef __NO_CTYPE\n#  define __isalnum_l(c,l)\t__isctype_l((c), _ISalnum, (l))\n#  define __isalpha_l(c,l)\t__isctype_l((c), _ISalpha, (l))\n#  define __iscntrl_l(c,l)\t__isctype_l((c), _IScntrl, (l))\n#  define __isdigit_l(c,l)\t__isctype_l((c), _ISdigit, (l))\n#  define __islower_l(c,l)\t__isctype_l((c), _ISlower, (l))\n#  define __isgraph_l(c,l)\t__isctype_l((c), _ISgraph, (l))\n#  define __isprint_l(c,l)\t__isctype_l((c), _ISprint, (l))\n#  define __ispunct_l(c,l)\t__isctype_l((c), _ISpunct, (l))\n#  define __isspace_l(c,l)\t__isctype_l((c), _ISspace, (l))\n#  define __isupper_l(c,l)\t__isctype_l((c), _ISupper, (l))\n#  define __isxdigit_l(c,l)\t__isctype_l((c), _ISxdigit, (l))\n\n#  define __isblank_l(c,l)\t__isctype_l((c), _ISblank, (l))\n\n#  ifdef __USE_MISC\n#   define __isascii_l(c,l)\t((l), __isascii (c))\n#   define __toascii_l(c,l)\t((l), __toascii (c))\n#  endif\n\n#  define isalnum_l(c,l)\t__isalnum_l ((c), (l))\n#  define isalpha_l(c,l)\t__isalpha_l ((c), (l))\n#  define iscntrl_l(c,l)\t__iscntrl_l ((c), (l))\n#  define isdigit_l(c,l)\t__isdigit_l ((c), (l))\n#  define islower_l(c,l)\t__islower_l ((c), (l))\n#  define isgraph_l(c,l)\t__isgraph_l ((c), (l))\n#  define isprint_l(c,l)\t__isprint_l ((c), (l))\n#  define ispunct_l(c,l)\t__ispunct_l ((c), (l))\n#  define isspace_l(c,l)\t__isspace_l ((c), (l))\n#  define isupper_l(c,l)\t__isupper_l ((c), (l))\n#  define isxdigit_l(c,l)\t__isxdigit_l ((c), (l))\n\n#  define isblank_l(c,l)\t__isblank_l ((c), (l))\n\n#  ifdef __USE_MISC\n#   define isascii_l(c,l)\t__isascii_l ((c), (l))\n#   define toascii_l(c,l)\t__toascii_l ((c), (l))\n#  endif\n\n# endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#endif\t\t\t\t/* Use POSIX 2008.  */\n\n__END_DECLS\n#endif\t\t\t\t/* ctype.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/dirent.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.1.2 Directory Operations\t<dirent.h>\n */\n\n#ifndef\t_DIRENT_H\n#define\t_DIRENT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef __USE_XOPEN\n# ifndef __ino_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#  else\ntypedef __ino64_t ino_t;\n#  endif\n#  define __ino_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n#  define __ino64_t_defined\n# endif\n#endif\n\n/* This file defines `struct dirent'.\n\n   It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen'\n   member that gives the length of `d_name'.\n\n   It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen'\n   member that gives the size of the entire directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off'\n   member that gives the file offset of the next directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type'\n   member that gives the type of the file.\n */\n\n#include <bits/dirent.h>\n\n#if defined __USE_MISC && !defined d_fileno\n# define d_ino\td_fileno\t/* Backward compatibility.  */\n#endif\n\n/* These macros extract size information from a `struct dirent *'.\n   They may evaluate their argument multiple times, so it must not\n   have side effects.  Each of these may involve a relatively costly\n   call to `strlen' on some systems, so these values should be cached.\n\n   _D_EXACT_NAMLEN (DP)\treturns the length of DP->d_name, not including\n   its terminating null character.\n\n   _D_ALLOC_NAMLEN (DP)\treturns a size at least (_D_EXACT_NAMLEN (DP) + 1);\n   that is, the allocation size needed to hold the DP->d_name string.\n   Use this macro when you don't need the exact length, just an upper bound.\n   This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN.\n   */\n\n#ifdef _DIRENT_HAVE_D_NAMLEN\n# define _D_EXACT_NAMLEN(d) ((d)->d_namlen)\n# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)\n#else\n# define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name))\n# ifdef _DIRENT_HAVE_D_RECLEN\n#  define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])\n# else\n#  define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \\\n\t\t\t      _D_EXACT_NAMLEN (d) + 1)\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* File types for `d_type'.  */\nenum {\n\tDT_UNKNOWN = 0,\n# define DT_UNKNOWN\tDT_UNKNOWN\n\tDT_FIFO = 1,\n# define DT_FIFO\tDT_FIFO\n\tDT_CHR = 2,\n# define DT_CHR\t\tDT_CHR\n\tDT_DIR = 4,\n# define DT_DIR\t\tDT_DIR\n\tDT_BLK = 6,\n# define DT_BLK\t\tDT_BLK\n\tDT_REG = 8,\n# define DT_REG\t\tDT_REG\n\tDT_LNK = 10,\n# define DT_LNK\t\tDT_LNK\n\tDT_SOCK = 12,\n# define DT_SOCK\tDT_SOCK\n\tDT_WHT = 14\n# define DT_WHT\t\tDT_WHT\n};\n\n/* Convert between stat structure types and directory types.  */\n# define IFTODT(mode)\t(((mode) & 0170000) >> 12)\n# define DTTOIF(dirtype)\t((dirtype) << 12)\n#endif\n\n/* This is the data type of directory stream objects.\n   The actual structure is opaque to users.  */\ntypedef struct __dirstream DIR;\n\n/* Open a directory stream on NAME.\n   Return a DIR stream on the directory, or NULL if it could not be opened.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *opendir(const char *__name) __nonnull((1));\n\n#ifdef __USE_XOPEN2K8\n/* Same as opendir, but open the stream on the file descriptor FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *fdopendir(int __fd);\n#endif\n\n/* Close the directory stream DIRP.\n   Return 0 if successful, -1 if not.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int closedir(DIR * __dirp) __nonnull((1));\n\n/* Read a directory entry from DIRP.  Return a pointer to a `struct\n   dirent' describing the entry, or NULL for EOF or error.  The\n   storage returned may be overwritten by a later readdir call on the\n   same DIR stream.\n\n   If the Large File Support API is selected we have to use the\n   appropriate interface.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern struct dirent *readdir(DIR * __dirp) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern struct dirent *__REDIRECT(readdir, (DIR * __dirp), readdir64) __nonnull((1));\n# else\n#  define readdir readdir64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern struct dirent64 *readdir64(DIR * __dirp) __nonnull((1));\n#endif\n\n#ifdef __USE_POSIX\n/* Reentrant version of `readdir'.  Return in RESULT a pointer to the\n   next entry.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int readdir_r(DIR * __restrict __dirp, struct dirent *__restrict __entry, struct dirent **__restrict __result) __nonnull((1, 2, 3));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(readdir_r, (DIR * __restrict __dirp, struct dirent * __restrict __entry, struct dirent ** __restrict __result), readdir64_r) __nonnull((1, 2, 3));\n#  else\n#   define readdir_r readdir64_r\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int readdir64_r(DIR * __restrict __dirp, struct dirent64 *__restrict __entry, struct dirent64 **__restrict __result) __nonnull((1, 2, 3));\n# endif\n#endif\t\t\t\t/* POSIX or misc */\n\n/* Rewind DIRP to the beginning of the directory.  */\nextern void rewinddir(DIR * __dirp)\n__THROW __nonnull((1));\n\n#if defined __USE_MISC || defined __USE_XOPEN\n# include <bits/types.h>\n\n/* Seek to position POS on DIRP.  */\nextern void seekdir(DIR * __dirp, long int __pos)\n__THROW __nonnull((1));\n\n/* Return the current position of DIRP.  */\nextern long int telldir(DIR * __dirp)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K8\n\n/* Return the file descriptor used by DIRP.  */\nextern int dirfd(DIR * __dirp)\n__THROW __nonnull((1));\n\n# if defined __OPTIMIZE__ && defined _DIR_dirfd\n#  define dirfd(dirp)\t_DIR_dirfd (dirp)\n# endif\n\n# ifdef __USE_MISC\n#  ifndef MAXNAMLEN\n/* Get the definitions of the POSIX.1 limits.  */\n#  include <bits/posix1_lim.h>\n\n/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'.  */\n#   ifdef NAME_MAX\n#    define MAXNAMLEN\tNAME_MAX\n#   else\n#    define MAXNAMLEN\t255\n#   endif\n#  endif\n# endif\n\n# define __need_size_t\n# include <stddef.h>\n\n/* Scan the directory DIR, calling SELECTOR on each directory entry.\n   Entries for which SELECT returns nonzero are individually malloc'd,\n   sorted using qsort with CMP, and collected in a malloc'd array in\n   *NAMELIST.  Returns the number of entries selected, or -1 on error.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int scandir(const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(scandir, (const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandir64) __nonnull((1, 2));\n#  else\n#   define scandir scandir64\n#  endif\n# endif\n\n# if defined __USE_GNU && defined __USE_LARGEFILE64\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandir64(const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((1, 2));\n# endif\n\n# ifdef __USE_GNU\n/* Similar to `scandir' but a relative DIR name is interpreted relative\n   to the directory for which DFD is a descriptor.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#  ifndef __USE_FILE_OFFSET64\nextern int scandirat(int __dfd, const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((2, 3));\n#  else\n#   ifdef __REDIRECT\nextern int __REDIRECT(scandirat, (int __dfd, const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandirat64) __nonnull((2, 3));\n#   else\n#    define scandirat scandirat64\n#   endif\n#  endif\n\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandirat64(int __dfd, const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((2, 3));\n# endif\n\n/* Function to compare two `struct dirent's alphabetically.  */\n# ifndef __USE_FILE_OFFSET64\nextern int alphasort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT_NTH(alphasort, (const struct dirent ** __e1, const struct dirent ** __e2), alphasort64)\n__attribute_pure__ __nonnull((1, 2));\n#  else\n#   define alphasort alphasort64\n#  endif\n# endif\n\n# if defined __USE_GNU && defined __USE_LARGEFILE64\nextern int alphasort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\t\t\t\t/* Use XPG7.  */\n\n#ifdef __USE_MISC\n/* Read directory entries from FD into BUF, reading at most NBYTES.\n   Reading starts at offset *BASEP, and *BASEP is updated with the new\n   position after reading.  Returns the number of bytes read; zero when at\n   end of directory; or -1 for errors.  */\n# ifndef __USE_FILE_OFFSET64\nextern __ssize_t getdirentries(int __fd, char *__restrict __buf, size_t __nbytes, __off_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n# else\n#  ifdef __REDIRECT\nextern __ssize_t __REDIRECT_NTH(getdirentries, (int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep), getdirentries64) __nonnull((2, 4));\n#  else\n#   define getdirentries getdirentries64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern __ssize_t getdirentries64(int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_GNU\n/* Function to compare two `struct dirent's by name & version.  */\n# ifndef __USE_FILE_OFFSET64\nextern int versionsort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT_NTH(versionsort, (const struct dirent ** __e1, const struct dirent ** __e2), versionsort64)\n__attribute_pure__ __nonnull((1, 2));\n#  else\n#   define versionsort versionsort64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int versionsort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\t\t\t\t/* Use GNU.  */\n\n__END_DECLS\n#endif\t\t\t\t/* dirent.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/dlfcn.h",
    "content": "/* User functions for run-time dynamic loading.\n   Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_DLFCN_H\n#define\t_DLFCN_H 1\n\n#include <features.h>\n#define __need_size_t\n#include <stddef.h>\n\n/* Collect various system dependent definitions and declarations.  */\n#include <bits/dlfcn.h>\n\n#ifdef __USE_GNU\n/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT\n   the run-time address of the symbol called NAME in the next shared\n   object is returned.  The \"next\" relation is defined by the order\n   the shared objects were loaded.  */\n# define RTLD_NEXT\t((void *) -1l)\n\n/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT\n   the run-time address of the symbol called NAME in the global scope\n   is returned.  */\n# define RTLD_DEFAULT\t((void *) 0)\n\n/* Type for namespace indeces.  */\ntypedef long int Lmid_t;\n\n/* Special namespace ID values.  */\n# define LM_ID_BASE\t0\t/* Initial namespace.  */\n# define LM_ID_NEWLM\t-1\t/* For dlmopen: request new namespace.  */\n#endif\n\n__BEGIN_DECLS\n/* Open the shared object FILE and map it in; return a handle that can be\n   passed to `dlsym' to get symbol values from it.  */\nextern void *dlopen(const char *__file, int __mode) __THROWNL;\n\n/* Unmap and close a shared object opened by `dlopen'.\n   The handle cannot be used again after calling `dlclose'.  */\nextern int dlclose(void *__handle)\n__THROWNL __nonnull((1));\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME.  */\nextern void *dlsym(void *__restrict __handle, const char *__restrict __name)\n__THROW __nonnull((2));\n\n#ifdef __USE_GNU\n/* Like `dlopen', but request object to be allocated in a new namespace.  */\nextern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode) __THROWNL;\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME with VERSION.  */\nextern void *dlvsym(void *__restrict __handle, const char *__restrict __name, const char *__restrict __version)\n__THROW __nonnull((2, 3));\n#endif\n\n/* When any of the above functions fails, call this function\n   to return a string describing the error.  Each call resets\n   the error string so that a following call returns null.  */\nextern char *dlerror(void) __THROW;\n\n#ifdef __USE_GNU\n/* Structure containing information about object searched using\n   `dladdr'.  */\ntypedef struct {\n\tconst char *dli_fname;\t/* File name of defining object.  */\n\tvoid *dli_fbase;\t/* Load address of that object.  */\n\tconst char *dli_sname;\t/* Name of nearest symbol.  */\n\tvoid *dli_saddr;\t/* Exact value of nearest symbol.  */\n} Dl_info;\n\n/* Fill in *INFO with the following information about ADDRESS.\n   Returns 0 iff no shared object's segments contain that address.  */\nextern int dladdr(const void *__address, Dl_info * __info)\n__THROW __nonnull((2));\n\n/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS.  */\nextern int dladdr1(const void *__address, Dl_info * __info, void **__extra_info, int __flags)\n__THROW __nonnull((2));\n\n/* These are the possible values for the FLAGS argument to `dladdr1'.\n   This indicates what extra information is stored at *EXTRA_INFO.\n   It may also be zero, in which case the EXTRA_INFO argument is not used.  */\nenum {\n\t/* Matching symbol table entry (const ElfNN_Sym *).  */\n\tRTLD_DL_SYMENT = 1,\n\n\t/* The object containing the address (struct link_map *).  */\n\tRTLD_DL_LINKMAP = 2\n};\n\n/* Get information about the shared object HANDLE refers to.\n   REQUEST is from among the values below, and determines the use of ARG.\n\n   On success, returns zero.  On failure, returns -1 and records an error\n   message to be fetched with `dlerror'.  */\nextern int dlinfo(void *__restrict __handle, int __request, void *__restrict __arg)\n__THROW __nonnull((1, 3));\n\n/* These are the possible values for the REQUEST argument to `dlinfo'.  */\nenum {\n\t/* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there.  */\n\tRTLD_DI_LMID = 1,\n\n\t/* Treat ARG as `struct link_map **';\n\t   store the `struct link_map *' for HANDLE there.  */\n\tRTLD_DI_LINKMAP = 2,\n\n\tRTLD_DI_CONFIGADDR = 3,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the\n\t   directories that will be searched for dependencies of this object.\n\t   RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size'\n\t   entries to indicate the size of the buffer that must be passed to\n\t   RTLD_DI_SERINFO to fill in the full information.  */\n\tRTLD_DI_SERINFO = 4,\n\tRTLD_DI_SERINFOSIZE = 5,\n\n\t/* Treat ARG as `char *', and store there the directory name used to\n\t   expand $ORIGIN in this shared object's dependency file names.  */\n\tRTLD_DI_ORIGIN = 6,\n\n\tRTLD_DI_PROFILENAME = 7,\t/* Unsupported, defined by Solaris.  */\n\tRTLD_DI_PROFILEOUT = 8,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `size_t *', and store there the TLS module ID\n\t   of this object's PT_TLS segment, as used in TLS relocations;\n\t   store zero if this object does not define a PT_TLS segment.  */\n\tRTLD_DI_TLS_MODID = 9,\n\n\t/* Treat ARG as `void **', and store there a pointer to the calling\n\t   thread's TLS block corresponding to this object's PT_TLS segment.\n\t   Store a null pointer if this object does not define a PT_TLS\n\t   segment, or if the calling thread has not allocated a block for it.  */\n\tRTLD_DI_TLS_DATA = 10,\n\n\tRTLD_DI_MAX = 10\n};\n\n/* This is the type of elements in `Dl_serinfo', below.\n   The `dls_name' member points to space in the buffer passed to `dlinfo'.  */\ntypedef struct {\n\tchar *dls_name;\t\t/* Name of library search path directory.  */\n\tunsigned int dls_flags;\t/* Indicates where this directory came from. */\n} Dl_serpath;\n\n/* This is the structure that must be passed (by reference) to `dlinfo' for\n   the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests.  */\ntypedef struct {\n\tsize_t dls_size;\t/* Size in bytes of the whole buffer.  */\n\tunsigned int dls_cnt;\t/* Number of elements in `dls_serpath'.  */\n\tDl_serpath dls_serpath[1];\t/* Actually longer, dls_cnt elements.  */\n} Dl_serinfo;\n#endif\t\t\t\t/* __USE_GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* dlfcn.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/endian.h",
    "content": "/* Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ENDIAN_H\n#define\t_ENDIAN_H\t1\n\n#include <features.h>\n\n/* Definitions for byte order, according to significance of bytes,\n   from low addresses to high addresses.  The value is what you get by\n   putting '4' in the most significant byte, '3' in the second most\n   significant byte, '2' in the second least significant byte, and '1'\n   in the least significant byte, and then writing down one digit for\n   each byte, starting with the byte at the lowest address at the left,\n   and proceeding to the byte with the highest address at the right.  */\n\n#define\t__LITTLE_ENDIAN\t1234\n#define\t__BIG_ENDIAN\t4321\n#define\t__PDP_ENDIAN\t3412\n\n/* This file defines `__BYTE_ORDER' for the particular machine.  */\n#include <bits/endian.h>\n\n/* Some machines may need to use a different endianness for floating point\n   values.  */\n#ifndef __FLOAT_WORD_ORDER\n# define __FLOAT_WORD_ORDER __BYTE_ORDER\n#endif\n\n#ifdef\t__USE_MISC\n# define LITTLE_ENDIAN\t__LITTLE_ENDIAN\n# define BIG_ENDIAN\t__BIG_ENDIAN\n# define PDP_ENDIAN\t__PDP_ENDIAN\n# define BYTE_ORDER\t__BYTE_ORDER\n#endif\n\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n# define __LONG_LONG_PAIR(HI, LO) LO, HI\n#elif __BYTE_ORDER == __BIG_ENDIAN\n# define __LONG_LONG_PAIR(HI, LO) HI, LO\n#endif\n\n#if defined __USE_MISC && !defined __ASSEMBLER__\n/* Conversion interfaces.  */\n# include <bits/byteswap.h>\n\n# if __BYTE_ORDER == __LITTLE_ENDIAN\n#  define htobe16(x) __bswap_16 (x)\n#  define htole16(x) (x)\n#  define be16toh(x) __bswap_16 (x)\n#  define le16toh(x) (x)\n\n#  define htobe32(x) __bswap_32 (x)\n#  define htole32(x) (x)\n#  define be32toh(x) __bswap_32 (x)\n#  define le32toh(x) (x)\n\n#  define htobe64(x) __bswap_64 (x)\n#  define htole64(x) (x)\n#  define be64toh(x) __bswap_64 (x)\n#  define le64toh(x) (x)\n\n# else\n#  define htobe16(x) (x)\n#  define htole16(x) __bswap_16 (x)\n#  define be16toh(x) (x)\n#  define le16toh(x) __bswap_16 (x)\n\n#  define htobe32(x) (x)\n#  define htole32(x) __bswap_32 (x)\n#  define be32toh(x) (x)\n#  define le32toh(x) __bswap_32 (x)\n\n#  define htobe64(x) (x)\n#  define htole64(x) __bswap_64 (x)\n#  define be64toh(x) (x)\n#  define le64toh(x) __bswap_64 (x)\n# endif\n#endif\n\n#endif\t\t\t\t/* endian.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/errno.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.5 Errors\t<errno.h>\n */\n\n#ifndef\t_ERRNO_H\n\n/* The includer defined __need_Emath if he wants only the definitions\n   of EDOM and ERANGE, and not everything else.  */\n#ifndef\t__need_Emath\n# define _ERRNO_H\t1\n# include <features.h>\n#endif\n\n__BEGIN_DECLS\n/* Get the error number constants from the system-specific file.\n   This file will test __need_Emath and _ERRNO_H.  */\n#include <bits/errno.h>\n#undef\t__need_Emath\n#ifdef\t_ERRNO_H\n/* Declare the `errno' variable, unless it's defined as a macro by\n   bits/errno.h.  This is the case in GNU, where it is a per-thread\n   variable.  This redeclaration using the macro still works, but it\n   will be a function declaration without a prototype and may trigger\n   a -Wstrict-prototypes warning.  */\n#ifndef\terrno\nextern int errno;\n#endif\n\n#ifdef __USE_GNU\n\n/* The full and simple forms of the name with which the program was\n   invoked.  These variables are set up automatically at startup based on\n   the value of ARGV[0] (this works only if you use GNU ld).  */\nextern char *program_invocation_name, *program_invocation_short_name;\n#endif\t\t\t\t/* __USE_GNU */\n#endif\t\t\t\t/* _ERRNO_H */\n\n__END_DECLS\n#endif\t\t\t\t/* _ERRNO_H */\n/* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so\n   that printing `error_t' values in the debugger shows the names.  We\n   might need this definition sometimes even if this file was included\n   before.  */\n#if defined __USE_GNU || defined __need_error_t\n# ifndef __error_t_defined\ntypedef int error_t;\n#  define __error_t_defined\t1\n# endif\n# undef __need_error_t\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/execinfo.h",
    "content": "/* Copyright (C) 1998-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _EXECINFO_H\n#define _EXECINFO_H 1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Store up to SIZE return address of the current program state in\n   ARRAY and return the exact number of values stored.  */\nextern int backtrace(void **__array, int __size) __nonnull((1));\n\n/* Return names of functions from the backtrace list in ARRAY in a newly\n   malloc()ed memory block.  */\nextern char **backtrace_symbols(void *const *__array, int __size)\n__THROW __nonnull((1));\n\n/* This function is similar to backtrace_symbols() but it writes the result\n   immediately to a file.  */\nextern void backtrace_symbols_fd(void *const *__array, int __size, int __fd)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* execinfo.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/fcntl.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 6.5 File Control Operations\t<fcntl.h>\n */\n\n#ifndef\t_FCNTL_H\n#define\t_FCNTL_H\t1\n\n#include <features.h>\n\n/* This must be early so <bits/fcntl.h> can define types winningly.  */\n__BEGIN_DECLS\n/* Get __mode_t, __dev_t and __off_t  .*/\n#include <bits/types.h>\n/* Get the definitions of O_*, F_*, FD_*: all the\n   numbers and flag bits for `open', `fcntl', et al.  */\n#include <bits/fcntl.h>\n/* Detect if open needs mode as a third argument (or for openat as a fourth\n   argument).  */\n#ifdef __O_TMPFILE\n# define __OPEN_NEEDS_MODE(oflag) \\\n  (((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)\n#else\n# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)\n#endif\n/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.\n   Earlier POSIX standards permitted any type ending in `_t' to be defined\n   by any POSIX header, so we don't conditionalize the definitions here.  */\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n/* For XPG all symbols from <sys/stat.h> should also be available.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# define __need_timespec\n# include <time.h>\n# include <bits/stat.h>\n\n# define S_IFMT\t\t__S_IFMT\n# define S_IFDIR\t__S_IFDIR\n# define S_IFCHR\t__S_IFCHR\n# define S_IFBLK\t__S_IFBLK\n# define S_IFREG\t__S_IFREG\n# ifdef __S_IFIFO\n#  define S_IFIFO\t__S_IFIFO\n# endif\n# ifdef __S_IFLNK\n#  define S_IFLNK\t__S_IFLNK\n# endif\n# if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK\n#  define S_IFSOCK\t__S_IFSOCK\n# endif\n\n/* Protection bits.  */\n\n# define S_ISUID\t__S_ISUID\t/* Set user ID on execution.  */\n# define S_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n\n# if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n#  define S_ISVTX\t__S_ISVTX\n# endif\n\n# define S_IRUSR\t__S_IREAD\t/* Read by owner.  */\n# define S_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n# define S_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n# define S_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n\n# define S_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n# define S_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n# define S_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n# define S_IRWXG\t(S_IRWXU >> 3)\n\n# define S_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n# define S_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n# define S_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n# define S_IRWXO\t(S_IRWXG >> 3)\n#endif\n\n#ifdef\t__USE_MISC\n# ifndef R_OK\t\t\t/* Verbatim from <unistd.h>.  Ugh.  */\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#  define R_OK\t4\t\t/* Test for read permission.  */\n#  define W_OK\t2\t\t/* Test for write permission.  */\n#  define X_OK\t1\t\t/* Test for execute permission.  */\n#  define F_OK\t0\t\t/* Test for existence.  */\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n/* XPG wants the following symbols.   <stdio.h> has the same definitions.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# define SEEK_SET\t0\t/* Seek from beginning of file.  */\n# define SEEK_CUR\t1\t/* Seek from current position.  */\n# define SEEK_END\t2\t/* Seek from end of file.  */\n#endif\t\t\t\t/* XPG */\n\n/* The constants AT_REMOVEDIR and AT_EACCESS have the same value.  AT_EASSESS\n   is meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to\n   unlinkat.  The two functions do completely different things and therefore,\n   the flags can be allowed to overlap.  For example, passing AT_REMOVEDIR to\n   faccessat would be undefined behavior and thus treating it equivalent to\n   AT_EACCESS is valid undefined behavior.  */\n#ifdef __USE_ATFILE\n# define AT_FDCWD\t\t-100\t/* Special value used to indicate\n\t\t\t\t\t   the *at functions should use the\n\t\t\t\t\t   current working directory. */\n# define AT_SYMLINK_NOFOLLOW\t0x100\t/* Do not follow symbolic links.  */\n# define AT_REMOVEDIR\t\t0x200\t/* Remove directory instead of\n\t\t\t\t\t   unlinking file.  */\n# define AT_SYMLINK_FOLLOW\t0x400\t/* Follow symbolic links.  */\n# ifdef __USE_GNU\n#  define AT_NO_AUTOMOUNT\t0x800\t/* Suppress terminal automount\n\t\t\t\t\t   traversal.  */\n#  define AT_EMPTY_PATH\t\t0x1000\t/* Allow empty relative pathname.  */\n# endif\n# define AT_EACCESS\t\t0x200\t/* Test access permitted for\n\t\t\t\t\t   effective IDs, not real IDs.  */\n#endif\n\n/* Do the file control operation described by CMD on FD.\n   The remaining arguments are interpreted depending on CMD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fcntl(int __fd, int __cmd, ...);\n\n/* Open FILE and return a new file descriptor for it, or -1 on error.\n   OFLAG determines the type of access used.  If O_CREAT or O_TMPFILE is set\n   in OFLAG, the third argument is taken as a `mode_t', the mode of the\n   created file.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int open(const char *__file, int __oflag, ...) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(open, (const char *__file, int __oflag, ...), open64) __nonnull((1));\n# else\n#  define open open64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int open64(const char *__file, int __oflag, ...) __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to `open' but a relative path name is interpreted relative to\n   the directory for which FD is a descriptor.\n\n   NOTE: some other `openat' implementation support additional functionality\n   through this interface, especially using the O_XATTR flag.  This is not\n   yet supported here.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int openat(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(openat, (int __fd, const char *__file, int __oflag, ...), openat64) __nonnull((2));\n#  else\n#   define openat openat64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int openat64(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n# endif\n#endif\n\n/* Create and open FILE, with mode MODE.  This takes an `int' MODE\n   argument because that is what `mode_t' will be widened to.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int creat(const char *__file, mode_t __mode) __nonnull((1));\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(creat, (const char *__file, mode_t __mode), creat64) __nonnull((1));\n# else\n#  define creat creat64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int creat64(const char *__file, mode_t __mode) __nonnull((1));\n#endif\n\n#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \\\n\t\t\t\t\t       && !defined __USE_POSIX))\n/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.  */\n\n# define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n# define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n# define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n# define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n# ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, off_t __len);\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64);\n#  else\n#   define lockf lockf64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, off64_t __len);\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Advice the system about the expected behaviour of the application with\n   respect to the file associated with FD.  */\n# ifndef __USE_FILE_OFFSET64\nextern int posix_fadvise(int __fd, off_t __offset, off_t __len, int __advise) __THROW;\n# else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(posix_fadvise, (int __fd, __off64_t __offset, __off64_t __len, int __advise), posix_fadvise64);\n#  else\n#   define posix_fadvise posix_fadvise64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int posix_fadvise64(int __fd, off64_t __offset, off64_t __len, int __advise) __THROW;\n# endif\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int posix_fallocate(int __fd, off_t __offset, off_t __len);\n# else\n# ifdef __REDIRECT\nextern int __REDIRECT(posix_fallocate, (int __fd, __off64_t __offset, __off64_t __len), posix_fallocate64);\n#  else\n#   define posix_fallocate posix_fallocate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int posix_fallocate64(int __fd, off64_t __offset, off64_t __len);\n# endif\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \\\n    && defined __va_arg_pack_len\n# include <bits/fcntl2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* fcntl.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/features.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FEATURES_H\n#define\t_FEATURES_H\t1\n\n/* These are defined by the user (or the compiler)\n   to specify the desired environment:\n\n   __STRICT_ANSI__\tISO Standard C.\n   _ISOC99_SOURCE\tExtensions to ISO C89 from ISO C99.\n   _ISOC11_SOURCE\tExtensions to ISO C99 from ISO C11.\n   _POSIX_SOURCE\tIEEE Std 1003.1.\n   _POSIX_C_SOURCE\tIf ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;\n\t\t\tif >=199309L, add IEEE Std 1003.1b-1993;\n\t\t\tif >=199506L, add IEEE Std 1003.1c-1995;\n\t\t\tif >=200112L, all of IEEE 1003.1-2004\n\t\t\tif >=200809L, all of IEEE 1003.1-2008\n   _XOPEN_SOURCE\tIncludes POSIX and XPG things.  Set to 500 if\n\t\t\tSingle Unix conformance is wanted, to 600 for the\n\t\t\tsixth revision, to 700 for the seventh revision.\n   _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.\n   _LARGEFILE_SOURCE\tSome more functions for correct standard I/O.\n   _LARGEFILE64_SOURCE\tAdditional functionality from LFS for large files.\n   _FILE_OFFSET_BITS=N\tSelect default filesystem interface.\n   _ATFILE_SOURCE\tAdditional *at interfaces.\n   _GNU_SOURCE\t\tAll of the above, plus GNU extensions.\n   _DEFAULT_SOURCE\tThe default set of features (taking precedence over\n\t\t\t__STRICT_ANSI__).\n   _REENTRANT\t\tSelect additionally reentrant object.\n   _THREAD_SAFE\t\tSame as _REENTRANT, often used by other systems.\n   _FORTIFY_SOURCE\tIf set to numeric value > 0 additional security\n\t\t\tmeasures are defined, according to level.\n\n   The `-ansi' switch to the GNU C compiler, and standards conformance\n   options such as `-std=c99', define __STRICT_ANSI__.  If none of\n   these are defined, or if _DEFAULT_SOURCE is defined, the default is\n   to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to\n   200809L, as well as enabling miscellaneous functions from BSD and\n   SVID.  If more than one of these are defined, they accumulate.  For\n   example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together\n   give you ISO C, 1003.1, and 1003.2, but nothing else.\n\n   These are defined by this file and are used by the\n   header files to decide what to declare or define:\n\n   __USE_ISOC11\t\tDefine ISO C11 things.\n   __USE_ISOC99\t\tDefine ISO C99 things.\n   __USE_ISOC95\t\tDefine ISO C90 AMD1 (C95) things.\n   __USE_POSIX\t\tDefine IEEE Std 1003.1 things.\n   __USE_POSIX2\t\tDefine IEEE Std 1003.2 things.\n   __USE_POSIX199309\tDefine IEEE Std 1003.1, and .1b things.\n   __USE_POSIX199506\tDefine IEEE Std 1003.1, .1b, .1c and .1i things.\n   __USE_XOPEN\t\tDefine XPG things.\n   __USE_XOPEN_EXTENDED\tDefine X/Open Unix things.\n   __USE_UNIX98\t\tDefine Single Unix V2 things.\n   __USE_XOPEN2K        Define XPG6 things.\n   __USE_XOPEN2KXSI     Define XPG6 XSI things.\n   __USE_XOPEN2K8       Define XPG7 things.\n   __USE_XOPEN2K8XSI    Define XPG7 XSI things.\n   __USE_LARGEFILE\tDefine correct standard I/O things.\n   __USE_LARGEFILE64\tDefine LFS things with separate names.\n   __USE_FILE_OFFSET64\tDefine 64bit interface as default.\n   __USE_MISC\t\tDefine things from 4.3BSD or System V Unix.\n   __USE_ATFILE\t\tDefine *at interfaces and AT_* constants for them.\n   __USE_GNU\t\tDefine GNU extensions.\n   __USE_REENTRANT\tDefine reentrant/thread-safe *_r functions.\n   __USE_FORTIFY_LEVEL\tAdditional security measures used, according to level.\n\n   The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are\n   defined by this file unconditionally.  `__GNU_LIBRARY__' is provided\n   only for compatibility.  All new code should use the other symbols\n   to test for features.\n\n   All macros listed above as possibly being defined by this file are\n   explicitly undefined if they are not explicitly defined.\n   Feature-test macros that are not defined by the user or compiler\n   but are implied by the other feature-test macros defined (or by the\n   lack of any definitions) are defined by the file.  */\n\n/* Undefine everything, so we get a clean slate.  */\n#undef\t__USE_ISOC11\n#undef\t__USE_ISOC99\n#undef\t__USE_ISOC95\n#undef\t__USE_ISOCXX11\n#undef\t__USE_POSIX\n#undef\t__USE_POSIX2\n#undef\t__USE_POSIX199309\n#undef\t__USE_POSIX199506\n#undef\t__USE_XOPEN\n#undef\t__USE_XOPEN_EXTENDED\n#undef\t__USE_UNIX98\n#undef\t__USE_XOPEN2K\n#undef\t__USE_XOPEN2KXSI\n#undef\t__USE_XOPEN2K8\n#undef\t__USE_XOPEN2K8XSI\n#undef\t__USE_LARGEFILE\n#undef\t__USE_LARGEFILE64\n#undef\t__USE_FILE_OFFSET64\n#undef\t__USE_MISC\n#undef\t__USE_ATFILE\n#undef\t__USE_GNU\n#undef\t__USE_REENTRANT\n#undef\t__USE_FORTIFY_LEVEL\n#undef\t__KERNEL_STRICT_NAMES\n\n/* Suppress kernel-name space pollution unless user expressedly asks\n   for it.  */\n#ifndef _LOOSE_KERNEL_NAMES\n# define __KERNEL_STRICT_NAMES\n#endif\n\n/* Convenience macros to test the versions of glibc and gcc.\n   Use them like this:\n   #if __GNUC_PREREQ (2,8)\n   ... code requiring gcc 2.8 or later ...\n   #endif\n   Note - they won't work for gcc1 or glibc1, since the _MINOR macros\n   were not defined then.  */\n#if defined __GNUC__ && defined __GNUC_MINOR__\n# define __GNUC_PREREQ(maj, min) \\\n\t((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))\n#else\n# define __GNUC_PREREQ(maj, min) 0\n#endif\n\n/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for\n   _DEFAULT_SOURCE.  If _DEFAULT_SOURCE is present we do not\n   issue a warning; the expectation is that the source is being\n   transitioned to use the new macro.  */\n#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \\\n    && !defined _DEFAULT_SOURCE\n/* # warning \"_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE\" */\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n#endif\n\n/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */\n#ifdef _GNU_SOURCE\n# undef  _ISOC95_SOURCE\n# define _ISOC95_SOURCE\t1\n# undef  _ISOC99_SOURCE\n# define _ISOC99_SOURCE\t1\n# undef  _ISOC11_SOURCE\n# define _ISOC11_SOURCE\t1\n# undef  _POSIX_SOURCE\n# define _POSIX_SOURCE\t1\n# undef  _POSIX_C_SOURCE\n# define _POSIX_C_SOURCE\t200809L\n# undef  _XOPEN_SOURCE\n# define _XOPEN_SOURCE\t700\n# undef  _XOPEN_SOURCE_EXTENDED\n# define _XOPEN_SOURCE_EXTENDED\t1\n# undef\t _LARGEFILE64_SOURCE\n# define _LARGEFILE64_SOURCE\t1\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n# undef  _ATFILE_SOURCE\n# define _ATFILE_SOURCE\t1\n#endif\n\n/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,\n   define _DEFAULT_SOURCE.  */\n#if (defined _DEFAULT_SOURCE\t\t\t\t\t\\\n     || (!defined __STRICT_ANSI__\t\t\t\t\\\n\t && !defined _ISOC99_SOURCE\t\t\t\t\\\n\t && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\t\\\n\t && !defined _XOPEN_SOURCE))\n# undef  _DEFAULT_SOURCE\n# define _DEFAULT_SOURCE\t1\n#endif\n\n/* This is to enable the ISO C11 extension.  */\n#if (defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))\n# define __USE_ISOC11\t1\n#endif\n\n/* This is to enable the ISO C99 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))\n# define __USE_ISOC99\t1\n#endif\n\n/* This is to enable the ISO C90 Amendment 1:1995 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))\n# define __USE_ISOC95\t1\n#endif\n\n/* This is to enable compatibility for ISO C++11.\n\n   So far g++ does not provide a macro.  Check the temporary macro for\n   now, too.  */\n#if ((defined __cplusplus && __cplusplus >= 201103L)\t\t\t      \\\n     || defined __GXX_EXPERIMENTAL_CXX0X__)\n# define __USE_ISOCXX11\t1\n#endif\n\n/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE\n   is defined, use POSIX.1-2008 (or another version depending on\n   _XOPEN_SOURCE).  */\n#ifdef _DEFAULT_SOURCE\n# if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\n#  define __USE_POSIX_IMPLICITLY\t1\n# endif\n# undef  _POSIX_SOURCE\n# define _POSIX_SOURCE\t1\n# undef  _POSIX_C_SOURCE\n# define _POSIX_C_SOURCE\t200809L\n#endif\n#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \\\n     !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)\n# define _POSIX_SOURCE\t1\n# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500\n#  define _POSIX_C_SOURCE\t2\n# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600\n#  define _POSIX_C_SOURCE\t199506L\n# elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700\n#  define _POSIX_C_SOURCE\t200112L\n# else\n#  define _POSIX_C_SOURCE\t200809L\n# endif\n# define __USE_POSIX_IMPLICITLY\t1\n#endif\n\n#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE\n# define __USE_POSIX\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE\n# define __USE_POSIX2\t1\n#endif\n\n#if (_POSIX_C_SOURCE - 0) >= 199309L\n# define __USE_POSIX199309\t1\n#endif\n\n#if (_POSIX_C_SOURCE - 0) >= 199506L\n# define __USE_POSIX199506\t1\n#endif\n\n#if (_POSIX_C_SOURCE - 0) >= 200112L\n# define __USE_XOPEN2K\t\t1\n# undef __USE_ISOC95\n# define __USE_ISOC95\t\t1\n# undef __USE_ISOC99\n# define __USE_ISOC99\t\t1\n#endif\n\n#if (_POSIX_C_SOURCE - 0) >= 200809L\n# define __USE_XOPEN2K8\t\t1\n# undef  _ATFILE_SOURCE\n# define _ATFILE_SOURCE\t1\n#endif\n\n#ifdef\t_XOPEN_SOURCE\n# define __USE_XOPEN\t1\n# if (_XOPEN_SOURCE - 0) >= 500\n#  define __USE_XOPEN_EXTENDED\t1\n#  define __USE_UNIX98\t1\n#  undef _LARGEFILE_SOURCE\n#  define _LARGEFILE_SOURCE\t1\n#  if (_XOPEN_SOURCE - 0) >= 600\n#   if (_XOPEN_SOURCE - 0) >= 700\n#    define __USE_XOPEN2K8\t1\n#    define __USE_XOPEN2K8XSI\t1\n#   endif\n#   define __USE_XOPEN2K\t1\n#   define __USE_XOPEN2KXSI\t1\n#   undef __USE_ISOC95\n#   define __USE_ISOC95\t\t1\n#   undef __USE_ISOC99\n#   define __USE_ISOC99\t\t1\n#  endif\n# else\n#  ifdef _XOPEN_SOURCE_EXTENDED\n#   define __USE_XOPEN_EXTENDED\t1\n#  endif\n# endif\n#endif\n\n#ifdef _LARGEFILE_SOURCE\n# define __USE_LARGEFILE\t1\n#endif\n\n#ifdef _LARGEFILE64_SOURCE\n# define __USE_LARGEFILE64\t1\n#endif\n\n#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64\n# define __USE_FILE_OFFSET64\t1\n#endif\n\n#if defined _DEFAULT_SOURCE\n# define __USE_MISC\t1\n#endif\n\n#ifdef\t_ATFILE_SOURCE\n# define __USE_ATFILE\t1\n#endif\n\n#ifdef\t_GNU_SOURCE\n# define __USE_GNU\t1\n#endif\n\n#if defined _REENTRANT || defined _THREAD_SAFE\n# define __USE_REENTRANT\t1\n#endif\n\n#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0\n# if !defined __OPTIMIZE__ || __OPTIMIZE__ <= 0\n#  warning _FORTIFY_SOURCE requires compiling with optimization (-O)\n# elif !__GNUC_PREREQ (4, 1)\n#  warning _FORTIFY_SOURCE requires GCC 4.1 or later\n# elif _FORTIFY_SOURCE > 1\n#  define __USE_FORTIFY_LEVEL 2\n# else\n#  define __USE_FORTIFY_LEVEL 1\n# endif\n#endif\n#ifndef __USE_FORTIFY_LEVEL\n# define __USE_FORTIFY_LEVEL 0\n#endif\n\n/* Get definitions of __STDC_* predefined macros, if the compiler has\n   not preincluded this header automatically.  */\n#include <stdc-predef.h>\n\n/* This macro indicates that the installed library is the GNU C Library.\n   For historic reasons the value now is 6 and this will stay from now\n   on.  The use of this variable is deprecated.  Use __GLIBC__ and\n   __GLIBC_MINOR__ now (see below) when you want to test for a specific\n   GNU C library version and use the values in <gnu/lib-names.h> to get\n   the sonames of the shared libraries.  */\n#undef  __GNU_LIBRARY__\n#define __GNU_LIBRARY__ 6\n\n/* Major and minor version number of the GNU C library package.  Use\n   these macros to test for features in specific releases.  */\n#define\t__GLIBC__\t2\n#define\t__GLIBC_MINOR__\t22\n\n#define __GLIBC_PREREQ(maj, min) \\\n\t((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))\n\n/* This is here only because every header file already includes this one.  */\n#ifndef __ASSEMBLER__\n# ifndef _SYS_CDEFS_H\n#  include <sys/cdefs.h>\n# endif\n\n/* If we don't have __REDIRECT, prototypes will be missing if\n   __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */\n# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT\n#  define __USE_LARGEFILE\t1\n#  define __USE_LARGEFILE64\t1\n# endif\n\n#endif\t\t\t\t/* !ASSEMBLER */\n\n/* Decide whether we can define 'extern inline' functions in headers.  */\n#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \\\n    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \\\n    && defined __extern_inline\n# define __USE_EXTERN_INLINES\t1\n#endif\n\n/* This is here only because every header file already includes this one.\n   Get the definitions of all the appropriate `__stub_FUNCTION' symbols.\n   <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub\n   that will always return failure (and set errno to ENOSYS).  */\n#include <gnu/stubs.h>\n\n#endif\t\t\t\t/* features.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/fts.h",
    "content": "/*\n * Copyright (c) 1989, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)fts.h\t8.3 (Berkeley) 8/14/94\n */\n\n#ifndef\t_FTS_H\n#define\t_FTS_H 1\n\n#include <features.h>\n#include <sys/types.h>\n\n/* The fts interface is incompatible with the LFS interface which\n   transparently uses the 64-bit file access functions.  */\n#ifdef __USE_FILE_OFFSET64\n# error \"<fts.h> cannot be used with -D_FILE_OFFSET_BITS==64\"\n#endif\n\ntypedef struct {\n\tstruct _ftsent *fts_cur;\t/* current node */\n\tstruct _ftsent *fts_child;\t/* linked list of children */\n\tstruct _ftsent **fts_array;\t/* sort array */\n\tdev_t fts_dev;\t\t/* starting device # */\n\tchar *fts_path;\t\t/* path for this descent */\n\tint fts_rfd;\t\t/* fd for root */\n\tint fts_pathlen;\t/* sizeof(path) */\n\tint fts_nitems;\t\t/* elements in the sort array */\n\tint (*fts_compar) (const void *, const void *);\t/* compare fn */\n\n#define\tFTS_COMFOLLOW\t0x0001\t/* follow command line symlinks */\n#define\tFTS_LOGICAL\t0x0002\t/* logical walk */\n#define\tFTS_NOCHDIR\t0x0004\t/* don't change directories */\n#define\tFTS_NOSTAT\t0x0008\t/* don't get stat info */\n#define\tFTS_PHYSICAL\t0x0010\t/* physical walk */\n#define\tFTS_SEEDOT\t0x0020\t/* return dot and dot-dot */\n#define\tFTS_XDEV\t0x0040\t/* don't cross devices */\n#define FTS_WHITEOUT\t0x0080\t/* return whiteout information */\n#define\tFTS_OPTIONMASK\t0x00ff\t/* valid user option mask */\n\n#define\tFTS_NAMEONLY\t0x0100\t/* (private) child names only */\n#define\tFTS_STOP\t0x0200\t/* (private) unrecoverable error */\n\tint fts_options;\t/* fts_open options, global flags */\n} FTS;\n\ntypedef struct _ftsent {\n\tstruct _ftsent *fts_cycle;\t/* cycle node */\n\tstruct _ftsent *fts_parent;\t/* parent directory */\n\tstruct _ftsent *fts_link;\t/* next file in directory */\n\tlong fts_number;\t/* local numeric value */\n\tvoid *fts_pointer;\t/* local address value */\n\tchar *fts_accpath;\t/* access path */\n\tchar *fts_path;\t\t/* root path */\n\tint fts_errno;\t\t/* errno for this node */\n\tint fts_symfd;\t\t/* fd for symlink */\n\tu_short fts_pathlen;\t/* strlen(fts_path) */\n\tu_short fts_namelen;\t/* strlen(fts_name) */\n\n\tino_t fts_ino;\t\t/* inode */\n\tdev_t fts_dev;\t\t/* device */\n\tnlink_t fts_nlink;\t/* link count */\n\n#define\tFTS_ROOTPARENTLEVEL\t-1\n#define\tFTS_ROOTLEVEL\t\t 0\n\tshort fts_level;\t/* depth (-1 to N) */\n\n#define\tFTS_D\t\t 1\t/* preorder directory */\n#define\tFTS_DC\t\t 2\t/* directory that causes cycles */\n#define\tFTS_DEFAULT\t 3\t/* none of the above */\n#define\tFTS_DNR\t\t 4\t/* unreadable directory */\n#define\tFTS_DOT\t\t 5\t/* dot or dot-dot */\n#define\tFTS_DP\t\t 6\t/* postorder directory */\n#define\tFTS_ERR\t\t 7\t/* error; errno is set */\n#define\tFTS_F\t\t 8\t/* regular file */\n#define\tFTS_INIT\t 9\t/* initialized only */\n#define\tFTS_NS\t\t10\t/* stat(2) failed */\n#define\tFTS_NSOK\t11\t/* no stat(2) requested */\n#define\tFTS_SL\t\t12\t/* symbolic link */\n#define\tFTS_SLNONE\t13\t/* symbolic link without target */\n#define FTS_W\t\t14\t/* whiteout object */\n\tu_short fts_info;\t/* user flags for FTSENT structure */\n\n#define\tFTS_DONTCHDIR\t 0x01\t/* don't chdir .. to the parent */\n#define\tFTS_SYMFOLLOW\t 0x02\t/* followed a symlink to get here */\n\tu_short fts_flags;\t/* private flags for FTSENT structure */\n\n#define\tFTS_AGAIN\t 1\t/* read node again */\n#define\tFTS_FOLLOW\t 2\t/* follow symbolic link */\n#define\tFTS_NOINSTR\t 3\t/* no instructions */\n#define\tFTS_SKIP\t 4\t/* discard node */\n\tu_short fts_instr;\t/* fts_set() instructions */\n\n\tstruct stat *fts_statp;\t/* stat(2) information */\n\tchar fts_name[1];\t/* file name */\n} FTSENT;\n\n__BEGIN_DECLS FTSENT * fts_children(FTS *, int);\nint fts_close(FTS *);\nFTS *fts_open(char *const *, int, int (*)(const FTSENT **, const FTSENT **));\nFTSENT *fts_read(FTS *);\nint fts_set(FTS *, FTSENT *, int) __THROW;\n__END_DECLS\n#endif\t\t\t\t/* fts.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/getopt.h",
    "content": "/* Declarations for getopt.\n   Copyright (C) 1989-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_H\n\n#ifndef __need_getopt\n# define _GETOPT_H 1\n#endif\n\n/* If __GNU_LIBRARY__ is not already defined, either we are being used\n   standalone, or this is the first header included in the source file.\n   If we are being used with glibc, we need to include <features.h>, but\n   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is\n   not defined, include <ctype.h>, which will pull in <features.h> for us\n   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it\n   doesn't flood the namespace with stuff the way some other headers do.)  */\n#if !defined __GNU_LIBRARY__\n# include <ctype.h>\n#endif\n\n#ifndef __THROW\n# ifndef __GNUC_PREREQ\n#  define __GNUC_PREREQ(maj, min) (0)\n# endif\n# if defined __cplusplus && __GNUC_PREREQ (2,8)\n#  define __THROW\tthrow ()\n# else\n#  define __THROW\n# endif\n#endif\n\n#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n/* For communication from `getopt' to the caller.\n   When `getopt' finds an option that takes an argument,\n   the argument value is returned here.\n   Also, when `ordering' is RETURN_IN_ORDER,\n   each non-option ARGV-element is returned here.  */\n\n\textern char *optarg;\n\n/* Index in ARGV of the next element to be scanned.\n   This is used for communication to and from the caller\n   and for communication between successive calls to `getopt'.\n\n   On entry to `getopt', zero means this is the first call; initialize.\n\n   When `getopt' returns -1, this is the index of the first of the\n   non-option elements that the caller should itself scan.\n\n   Otherwise, `optind' communicates from one call to the next\n   how much of ARGV has been scanned so far.  */\n\n\textern int optind;\n\n/* Callers store zero here to inhibit the error message `getopt' prints\n   for unrecognized options.  */\n\n\textern int opterr;\n\n/* Set to an option character which was unrecognized.  */\n\n\textern int optopt;\n\n#ifndef __need_getopt\n/* Describe the long-named options requested by the application.\n   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector\n   of `struct option' terminated by an element containing a name which is\n   zero.\n\n   The field `has_arg' is:\n   no_argument\t\t(or 0) if the option does not take an argument,\n   required_argument\t(or 1) if the option requires an argument,\n   optional_argument \t(or 2) if the option takes an optional argument.\n\n   If the field `flag' is not NULL, it points to a variable that is set\n   to the value given in the field `val' when the option is found, but\n   left unchanged if the option is not found.\n\n   To have a long-named option do something other than set an `int' to\n   a compiled-in constant, such as set a value from `optarg', set the\n   option's `flag' field to zero and its `val' field to a nonzero\n   value (the equivalent single-letter option character, if there is\n   one).  For long options that have a zero `flag' field, `getopt'\n   returns the contents of the `val' field.  */\n\n\tstruct option {\n\t\tconst char *name;\n\t\t/* has_arg can't be an enum because some compilers complain about\n\t\t   type mismatches in all the code that assumes it is an int.  */\n\t\tint has_arg;\n\t\tint *flag;\n\t\tint val;\n\t};\n\n/* Names for the values of the `has_arg' field of `struct option'.  */\n\n# define no_argument\t\t0\n# define required_argument\t1\n# define optional_argument\t2\n#endif\t\t\t\t/* need getopt */\n\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.\n\n   Return the option character from OPTS just read.  Return -1 when\n   there are no more options.  For unrecognized options, or options\n   missing arguments, `optopt' is set to the option letter, and '?' is\n   returned.\n\n   The OPTS string is a list of characters which are recognized option\n   letters, optionally followed by colons, specifying that that letter\n   takes an argument, to be placed in `optarg'.\n\n   If a letter in OPTS is followed by two colons, its argument is\n   optional.  This behavior is specific to the GNU `getopt'.\n\n   The argument `--' causes premature termination of argument\n   scanning, explicitly telling `getopt' that there are no more\n   options.\n\n   If OPTS begins with `--', then non-option arguments are treated as\n   arguments to the option '\\0'.  This behavior is specific to the GNU\n   `getopt'.  */\n\n#ifdef __GNU_LIBRARY__\n/* Many other libraries have conflicting prototypes for getopt, with\n   differences in the consts, in stdlib.h.  To avoid compilation\n   errors, only prototype getopt for the GNU C library.  */\n\textern int getopt(int ___argc, char *const *___argv, const char *__shortopts)\n\t __THROW;\n\n# if defined __need_getopt && defined __USE_POSIX2 \\\n  && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU\n/* The GNU getopt has more functionality than the standard version.  The\n   additional functionality can be disable at runtime.  This redirection\n   helps to also do this at runtime.  */\n#  ifdef __REDIRECT\n\textern int __REDIRECT_NTH(getopt, (int ___argc, char *const *___argv, const char *__shortopts), __posix_getopt);\n#  else\n\textern int __posix_getopt(int ___argc, char *const *___argv, const char *__shortopts) __THROW;\n#   define getopt __posix_getopt\n#  endif\n# endif\n#else\t\t\t\t/* not __GNU_LIBRARY__ */\n\textern int getopt();\n#endif\t\t\t\t/* __GNU_LIBRARY__ */\n\n#ifndef __need_getopt\n\textern int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n\t __THROW;\n\textern int getopt_long_only(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n\t __THROW;\n\n#endif\n\n#ifdef\t__cplusplus\n}\n#endif\n/* Make sure we later can get all the definitions and declarations.  */\n#undef __need_getopt\n#endif\t\t\t\t/* getopt.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/gnu/stubs-64.h",
    "content": "/* This file is automatically generated.\n   It defines a symbol `__stub_FUNCTION' for each function\n   in the C library which is a stub, meaning it will fail\n   every time called, usually setting errno to ENOSYS.  */\n\n#ifdef _LIBC\n#error Applications may not define the macro _LIBC\n#endif\n\n#define __stub_bdflush\n#define __stub_chflags\n#define __stub_fattach\n#define __stub_fchflags\n#define __stub_fdetach\n#define __stub_getmsg\n#define __stub_gtty\n#define __stub_lchmod\n#define __stub_putmsg\n#define __stub_revoke\n#define __stub_setlogin\n#define __stub_sigreturn\n#define __stub_sstk\n#define __stub_stty\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/gnu/stubs.h",
    "content": "/* This file is automatically generated.\n   This file selects the right generated file of `__stub_FUNCTION' macros\n   based on the architecture being compiled for.  */\n\n#if !defined __x86_64__\n# include <gnu/stubs-32.h>\n#endif\n#if defined __x86_64__ && defined __LP64__\n# include <gnu/stubs-64.h>\n#endif\n#if defined __x86_64__ && defined __ILP32__\n# include <gnu/stubs-x32.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/grp.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.1 Group Database Access\t<grp.h>\n */\n\n#ifndef\t_GRP_H\n#define\t_GRP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n/* For the Single Unix specification we must define this type here.  */\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined\ntypedef __gid_t gid_t;\n# define __gid_t_defined\n#endif\n\n/* The group structure.\t */\nstruct group {\n\tchar *gr_name;\t\t/* Group name.  */\n\tchar *gr_passwd;\t/* Password.    */\n\t__gid_t gr_gid;\t\t/* Group ID.    */\n\tchar **gr_mem;\t\t/* Member list. */\n};\n\n#ifdef __USE_MISC\n# define __need_FILE\n# include <stdio.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setgrent(void);\n\n/* Close the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endgrent(void);\n\n/* Read an entry from the group-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read a group entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct group *fgetgrent(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putgrent(const struct group *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrgid(__gid_t __gid);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrnam(const char *__name);\n\n#ifdef __USE_POSIX\n\n# ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#  define NSS_BUFLEN_GROUP\t1024\n# endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\n\n# ifdef __USE_GNU\nextern int getgrent_r(struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n# endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrgid_r(__gid_t __gid, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrnam_r(const char *__restrict __name, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n# ifdef\t__USE_MISC\n/* Read a group entry from STREAM.  This function is not standardized\n   an probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetgrent_r(FILE * __restrict __stream, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n# endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef\t__USE_MISC\n\n# define __need_size_t\n# include <stddef.h>\n\n/* Set the group set for the current user to GROUPS (N of them).  */\nextern int setgroups(size_t __n, const __gid_t * __groups) __THROW;\n\n/* Store at most *NGROUPS members of the group set for USER into\n   *GROUPS.  Also include GROUP.  The actual number of groups found is\n   returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getgrouplist(const char *__user, __gid_t __group, __gid_t * __groups, int *__ngroups);\n\n/* Initialize the group set for the current user\n   by reading the group database and using all groups\n   of which USER is a member.  Also include GROUP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int initgroups(const char *__user, __gid_t __group);\n\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* grp.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/inttypes.h",
    "content": "/* Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.8 Format conversion of integer types\t<inttypes.h>\n */\n\n#ifndef _INTTYPES_H\n#define _INTTYPES_H\t1\n\n#include <features.h>\n/* Get the type definitions.  */\n#include <stdint.h>\n\n/* Get a definition for wchar_t.  But we must not define wchar_t itself.  */\n#ifndef ____gwchar_t_defined\n# ifdef __cplusplus\n#  define __gwchar_t wchar_t\n# elif defined __WCHAR_TYPE__\ntypedef __WCHAR_TYPE__ __gwchar_t;\n# else\n#  define __need_wchar_t\n#  include <stddef.h>\ntypedef wchar_t __gwchar_t;\n# endif\n# define ____gwchar_t_defined\t1\n#endif\n\n# if __WORDSIZE == 64\n#  define __PRI64_PREFIX\t\"l\"\n#  define __PRIPTR_PREFIX\t\"l\"\n# else\n#  define __PRI64_PREFIX\t\"ll\"\n#  define __PRIPTR_PREFIX\n# endif\n\n/* Macros for printing format specifiers.  */\n\n/* Decimal notation.  */\n# define PRId8\t\t\"d\"\n# define PRId16\t\t\"d\"\n# define PRId32\t\t\"d\"\n# define PRId64\t\t__PRI64_PREFIX \"d\"\n\n# define PRIdLEAST8\t\"d\"\n# define PRIdLEAST16\t\"d\"\n# define PRIdLEAST32\t\"d\"\n# define PRIdLEAST64\t__PRI64_PREFIX \"d\"\n\n# define PRIdFAST8\t\"d\"\n# define PRIdFAST16\t__PRIPTR_PREFIX \"d\"\n# define PRIdFAST32\t__PRIPTR_PREFIX \"d\"\n# define PRIdFAST64\t__PRI64_PREFIX \"d\"\n\n# define PRIi8\t\t\"i\"\n# define PRIi16\t\t\"i\"\n# define PRIi32\t\t\"i\"\n# define PRIi64\t\t__PRI64_PREFIX \"i\"\n\n# define PRIiLEAST8\t\"i\"\n# define PRIiLEAST16\t\"i\"\n# define PRIiLEAST32\t\"i\"\n# define PRIiLEAST64\t__PRI64_PREFIX \"i\"\n\n# define PRIiFAST8\t\"i\"\n# define PRIiFAST16\t__PRIPTR_PREFIX \"i\"\n# define PRIiFAST32\t__PRIPTR_PREFIX \"i\"\n# define PRIiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Octal notation.  */\n# define PRIo8\t\t\"o\"\n# define PRIo16\t\t\"o\"\n# define PRIo32\t\t\"o\"\n# define PRIo64\t\t__PRI64_PREFIX \"o\"\n\n# define PRIoLEAST8\t\"o\"\n# define PRIoLEAST16\t\"o\"\n# define PRIoLEAST32\t\"o\"\n# define PRIoLEAST64\t__PRI64_PREFIX \"o\"\n\n# define PRIoFAST8\t\"o\"\n# define PRIoFAST16\t__PRIPTR_PREFIX \"o\"\n# define PRIoFAST32\t__PRIPTR_PREFIX \"o\"\n# define PRIoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Unsigned integers.  */\n# define PRIu8\t\t\"u\"\n# define PRIu16\t\t\"u\"\n# define PRIu32\t\t\"u\"\n# define PRIu64\t\t__PRI64_PREFIX \"u\"\n\n# define PRIuLEAST8\t\"u\"\n# define PRIuLEAST16\t\"u\"\n# define PRIuLEAST32\t\"u\"\n# define PRIuLEAST64\t__PRI64_PREFIX \"u\"\n\n# define PRIuFAST8\t\"u\"\n# define PRIuFAST16\t__PRIPTR_PREFIX \"u\"\n# define PRIuFAST32\t__PRIPTR_PREFIX \"u\"\n# define PRIuFAST64\t__PRI64_PREFIX \"u\"\n\n/* lowercase hexadecimal notation.  */\n# define PRIx8\t\t\"x\"\n# define PRIx16\t\t\"x\"\n# define PRIx32\t\t\"x\"\n# define PRIx64\t\t__PRI64_PREFIX \"x\"\n\n# define PRIxLEAST8\t\"x\"\n# define PRIxLEAST16\t\"x\"\n# define PRIxLEAST32\t\"x\"\n# define PRIxLEAST64\t__PRI64_PREFIX \"x\"\n\n# define PRIxFAST8\t\"x\"\n# define PRIxFAST16\t__PRIPTR_PREFIX \"x\"\n# define PRIxFAST32\t__PRIPTR_PREFIX \"x\"\n# define PRIxFAST64\t__PRI64_PREFIX \"x\"\n\n/* UPPERCASE hexadecimal notation.  */\n# define PRIX8\t\t\"X\"\n# define PRIX16\t\t\"X\"\n# define PRIX32\t\t\"X\"\n# define PRIX64\t\t__PRI64_PREFIX \"X\"\n\n# define PRIXLEAST8\t\"X\"\n# define PRIXLEAST16\t\"X\"\n# define PRIXLEAST32\t\"X\"\n# define PRIXLEAST64\t__PRI64_PREFIX \"X\"\n\n# define PRIXFAST8\t\"X\"\n# define PRIXFAST16\t__PRIPTR_PREFIX \"X\"\n# define PRIXFAST32\t__PRIPTR_PREFIX \"X\"\n# define PRIXFAST64\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intmax_t' and `uintmax_t'.  */\n# define PRIdMAX\t__PRI64_PREFIX \"d\"\n# define PRIiMAX\t__PRI64_PREFIX \"i\"\n# define PRIoMAX\t__PRI64_PREFIX \"o\"\n# define PRIuMAX\t__PRI64_PREFIX \"u\"\n# define PRIxMAX\t__PRI64_PREFIX \"x\"\n# define PRIXMAX\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intptr_t' and `uintptr_t'.  */\n# define PRIdPTR\t__PRIPTR_PREFIX \"d\"\n# define PRIiPTR\t__PRIPTR_PREFIX \"i\"\n# define PRIoPTR\t__PRIPTR_PREFIX \"o\"\n# define PRIuPTR\t__PRIPTR_PREFIX \"u\"\n# define PRIxPTR\t__PRIPTR_PREFIX \"x\"\n# define PRIXPTR\t__PRIPTR_PREFIX \"X\"\n\n/* Macros for scanning format specifiers.  */\n\n/* Signed decimal notation.  */\n# define SCNd8\t\t\"hhd\"\n# define SCNd16\t\t\"hd\"\n# define SCNd32\t\t\"d\"\n# define SCNd64\t\t__PRI64_PREFIX \"d\"\n\n# define SCNdLEAST8\t\"hhd\"\n# define SCNdLEAST16\t\"hd\"\n# define SCNdLEAST32\t\"d\"\n# define SCNdLEAST64\t__PRI64_PREFIX \"d\"\n\n# define SCNdFAST8\t\"hhd\"\n# define SCNdFAST16\t__PRIPTR_PREFIX \"d\"\n# define SCNdFAST32\t__PRIPTR_PREFIX \"d\"\n# define SCNdFAST64\t__PRI64_PREFIX \"d\"\n\n/* Signed decimal notation.  */\n# define SCNi8\t\t\"hhi\"\n# define SCNi16\t\t\"hi\"\n# define SCNi32\t\t\"i\"\n# define SCNi64\t\t__PRI64_PREFIX \"i\"\n\n# define SCNiLEAST8\t\"hhi\"\n# define SCNiLEAST16\t\"hi\"\n# define SCNiLEAST32\t\"i\"\n# define SCNiLEAST64\t__PRI64_PREFIX \"i\"\n\n# define SCNiFAST8\t\"hhi\"\n# define SCNiFAST16\t__PRIPTR_PREFIX \"i\"\n# define SCNiFAST32\t__PRIPTR_PREFIX \"i\"\n# define SCNiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Unsigned decimal notation.  */\n# define SCNu8\t\t\"hhu\"\n# define SCNu16\t\t\"hu\"\n# define SCNu32\t\t\"u\"\n# define SCNu64\t\t__PRI64_PREFIX \"u\"\n\n# define SCNuLEAST8\t\"hhu\"\n# define SCNuLEAST16\t\"hu\"\n# define SCNuLEAST32\t\"u\"\n# define SCNuLEAST64\t__PRI64_PREFIX \"u\"\n\n# define SCNuFAST8\t\"hhu\"\n# define SCNuFAST16\t__PRIPTR_PREFIX \"u\"\n# define SCNuFAST32\t__PRIPTR_PREFIX \"u\"\n# define SCNuFAST64\t__PRI64_PREFIX \"u\"\n\n/* Octal notation.  */\n# define SCNo8\t\t\"hho\"\n# define SCNo16\t\t\"ho\"\n# define SCNo32\t\t\"o\"\n# define SCNo64\t\t__PRI64_PREFIX \"o\"\n\n# define SCNoLEAST8\t\"hho\"\n# define SCNoLEAST16\t\"ho\"\n# define SCNoLEAST32\t\"o\"\n# define SCNoLEAST64\t__PRI64_PREFIX \"o\"\n\n# define SCNoFAST8\t\"hho\"\n# define SCNoFAST16\t__PRIPTR_PREFIX \"o\"\n# define SCNoFAST32\t__PRIPTR_PREFIX \"o\"\n# define SCNoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Hexadecimal notation.  */\n# define SCNx8\t\t\"hhx\"\n# define SCNx16\t\t\"hx\"\n# define SCNx32\t\t\"x\"\n# define SCNx64\t\t__PRI64_PREFIX \"x\"\n\n# define SCNxLEAST8\t\"hhx\"\n# define SCNxLEAST16\t\"hx\"\n# define SCNxLEAST32\t\"x\"\n# define SCNxLEAST64\t__PRI64_PREFIX \"x\"\n\n# define SCNxFAST8\t\"hhx\"\n# define SCNxFAST16\t__PRIPTR_PREFIX \"x\"\n# define SCNxFAST32\t__PRIPTR_PREFIX \"x\"\n# define SCNxFAST64\t__PRI64_PREFIX \"x\"\n\n/* Macros for scanning `intmax_t' and `uintmax_t'.  */\n# define SCNdMAX\t__PRI64_PREFIX \"d\"\n# define SCNiMAX\t__PRI64_PREFIX \"i\"\n# define SCNoMAX\t__PRI64_PREFIX \"o\"\n# define SCNuMAX\t__PRI64_PREFIX \"u\"\n# define SCNxMAX\t__PRI64_PREFIX \"x\"\n\n/* Macros for scaning `intptr_t' and `uintptr_t'.  */\n# define SCNdPTR\t__PRIPTR_PREFIX \"d\"\n# define SCNiPTR\t__PRIPTR_PREFIX \"i\"\n# define SCNoPTR\t__PRIPTR_PREFIX \"o\"\n# define SCNuPTR\t__PRIPTR_PREFIX \"u\"\n# define SCNxPTR\t__PRIPTR_PREFIX \"x\"\n\n__BEGIN_DECLS\n#if __WORDSIZE == 64\n/* We have to define the `uintmax_t' type using `ldiv_t'.  */\n    typedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} imaxdiv_t;\n\n#else\n/* We have to define the `uintmax_t' type using `lldiv_t'.  */\n    typedef struct {\n\t__extension__ long long int quot;\t/* Quotient.  */\n\t__extension__ long long int rem;\t/* Remainder.  */\n} imaxdiv_t;\n\n#endif\n\n/* Compute absolute value of N.  */\nextern intmax_t imaxabs(intmax_t __n)\n__THROW __attribute__ ((__const__));\n\n/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */\nextern imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom)\n__THROW __attribute__ ((__const__));\n\n/* Like `strtol' but convert to `intmax_t'.  */\nextern intmax_t strtoimax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `strtoul' but convert to `uintmax_t'.  */\nextern uintmax_t strtoumax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `wcstol' but convert to `intmax_t'.  */\nextern intmax_t wcstoimax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Like `wcstoul' but convert to `uintmax_t'.  */\nextern uintmax_t wcstoumax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n\n# if __WORDSIZE == 64\n\nextern long int __strtol_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __strtoul_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoul_internal(nptr, endptr, base, 0);\n}\n\nextern long int __wcstol_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __wcstoul_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoul_internal(nptr, endptr, base, 0);\n}\n\n# else\t\t\t\t/* __WORDSIZE == 32 */\n\n__extension__ extern long long int __strtoll_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __strtoull_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoull_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern long long int __wcstoll_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __wcstoull_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoull_internal(nptr, endptr, base, 0);\n}\n\n# endif\t\t\t\t/* __WORDSIZE == 32     */\n#endif\t\t\t\t/* Use extern inlines.  */\n\n__END_DECLS\n#endif\t\t\t\t/* inttypes.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/libio.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Written by Per Bothner <bothner@cygnus.com>.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.\n\n   As a special exception, if you link the code in this file with\n   files compiled with a GNU compiler to produce an executable,\n   that does not cause the resulting executable to be covered by\n   the GNU Lesser General Public License.  This exception does not\n   however invalidate any other reasons why the executable file\n   might be covered by the GNU Lesser General Public License.\n   This exception applies to code released by its copyright holders\n   in files containing the exception.  */\n\n#ifndef _IO_STDIO_H\n#define _IO_STDIO_H\n\n#include <_G_config.h>\n/* ALL of these should be defined in _G_config.h */\n#define _IO_fpos_t _G_fpos_t\n#define _IO_fpos64_t _G_fpos64_t\n#define _IO_size_t size_t\n#define _IO_ssize_t __ssize_t\n#define _IO_off_t __off_t\n#define _IO_off64_t __off64_t\n#define _IO_pid_t __pid_t\n#define _IO_uid_t __uid_t\n#define _IO_iconv_t _G_iconv_t\n#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE\n#define _IO_BUFSIZ _G_BUFSIZ\n#define _IO_va_list _G_va_list\n#define _IO_wint_t wint_t\n\n/* This define avoids name pollution if we're using GNU stdarg.h */\n#define __need___va_list\n#include <stdarg.h>\n#ifdef __GNUC_VA_LIST\n# undef _IO_va_list\n# define _IO_va_list __gnuc_va_list\n#endif\t\t\t\t/* __GNUC_VA_LIST */\n\n#ifndef __P\n# include <sys/cdefs.h>\n#endif\t\t\t\t/*!__P */\n\n#define _IO_UNIFIED_JUMPTABLES 1\n\n#ifndef EOF\n# define EOF (-1)\n#endif\n#ifndef NULL\n# if defined __GNUG__ && \\\n    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n#  define NULL (__null)\n# else\n#  if !defined(__cplusplus)\n#   define NULL ((void*)0)\n#  else\n#   define NULL (0)\n#  endif\n# endif\n#endif\n\n#define _IOS_INPUT\t1\n#define _IOS_OUTPUT\t2\n#define _IOS_ATEND\t4\n#define _IOS_APPEND\t8\n#define _IOS_TRUNC\t16\n#define _IOS_NOCREATE\t32\n#define _IOS_NOREPLACE\t64\n#define _IOS_BIN\t128\n\n/* Magic numbers and bits for the _flags field.\n   The magic numbers use the high-order bits of _flags;\n   the remaining bits are available for variable flags.\n   Note: The magic numbers must all be negative if stdio\n   emulation is desired. */\n\n#define _IO_MAGIC 0xFBAD0000\t/* Magic number */\n#define _OLD_STDIO_MAGIC 0xFABC0000\t/* Emulate old stdio. */\n#define _IO_MAGIC_MASK 0xFFFF0000\n#define _IO_USER_BUF 1\t\t/* User owns buffer; don't delete it on close. */\n#define _IO_UNBUFFERED 2\n#define _IO_NO_READS 4\t\t/* Reading not allowed */\n#define _IO_NO_WRITES 8\t\t/* Writing not allowd */\n#define _IO_EOF_SEEN 0x10\n#define _IO_ERR_SEEN 0x20\n#define _IO_DELETE_DONT_CLOSE 0x40\t/* Don't call close(_fileno) on cleanup. */\n#define _IO_LINKED 0x80\t\t/* Set if linked (using _chain) to streambuf::_list_all. */\n#define _IO_IN_BACKUP 0x100\n#define _IO_LINE_BUF 0x200\n#define _IO_TIED_PUT_GET 0x400\t/* Set if put and get pointer logicly tied. */\n#define _IO_CURRENTLY_PUTTING 0x800\n#define _IO_IS_APPENDING 0x1000\n#define _IO_IS_FILEBUF 0x2000\n#define _IO_BAD_SEEN 0x4000\n#define _IO_USER_LOCK 0x8000\n\n#define _IO_FLAGS2_MMAP 1\n#define _IO_FLAGS2_NOTCANCEL 2\n#ifdef _LIBC\n# define _IO_FLAGS2_FORTIFY 4\n#endif\n#define _IO_FLAGS2_USER_WBUF 8\n#ifdef _LIBC\n# define _IO_FLAGS2_SCANF_STD 16\n# define _IO_FLAGS2_NOCLOSE 32\n# define _IO_FLAGS2_CLOEXEC 64\n#endif\n\n/* These are \"formatting flags\" matching the iostream fmtflags enum values. */\n#define _IO_SKIPWS 01\n#define _IO_LEFT 02\n#define _IO_RIGHT 04\n#define _IO_INTERNAL 010\n#define _IO_DEC 020\n#define _IO_OCT 040\n#define _IO_HEX 0100\n#define _IO_SHOWBASE 0200\n#define _IO_SHOWPOINT 0400\n#define _IO_UPPERCASE 01000\n#define _IO_SHOWPOS 02000\n#define _IO_SCIENTIFIC 04000\n#define _IO_FIXED 010000\n#define _IO_UNITBUF 020000\n#define _IO_STDIO 040000\n#define _IO_DONT_CLOSE 0100000\n#define _IO_BOOLALPHA 0200000\n\nstruct _IO_jump_t;\nstruct _IO_FILE;\n\n/* Handle lock.  */\n#ifdef _IO_MTSAFE_IO\n# if defined __GLIBC__ && __GLIBC__ >= 2\n#  include <bits/stdio-lock.h>\n# else\n/*# include <comthread.h>*/\n# endif\n#else\ntypedef void _IO_lock_t;\n#endif\n\n/* A streammarker remembers a position in a buffer. */\n\nstruct _IO_marker {\n\tstruct _IO_marker *_next;\n\tstruct _IO_FILE *_sbuf;\n\t/* If _pos >= 0\n\t   it points to _buf->Gbase()+_pos. FIXME comment */\n\t/* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */\n\tint _pos;\n#if 0\n\tvoid set_streampos(streampos sp) {\n\t\t_spos = sp;\n\t} void set_offset(int offset) {\n\t\t_pos = offset;\n\t\t_spos = (streampos) (-2);\n\t}\n public:\n\tstreammarker(streambuf * sb);\n\t~streammarker();\n\tint saving() {\n\t\treturn _spos == -2;\n\t}\n\tint delta(streammarker &);\n\tint delta();\n#endif\n};\n\n/* This is the structure from the libstdc++ codecvt class.  */\nenum __codecvt_result {\n\t__codecvt_ok,\n\t__codecvt_partial,\n\t__codecvt_error,\n\t__codecvt_noconv\n};\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n/* The order of the elements in the following struct must match the order\n   of the virtual functions in the libstdc++ codecvt class.  */\nstruct _IO_codecvt {\n\tvoid (*__codecvt_destr) (struct _IO_codecvt *);\n\tenum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, __mbstate_t *, const wchar_t *, const wchar_t *, const wchar_t **, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, __mbstate_t *, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, const char **, wchar_t *, wchar_t *, wchar_t **);\n\tint (*__codecvt_do_encoding) (struct _IO_codecvt *);\n\tint (*__codecvt_do_always_noconv) (struct _IO_codecvt *);\n\tint (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, _IO_size_t);\n\tint (*__codecvt_do_max_length) (struct _IO_codecvt *);\n\n\t_IO_iconv_t __cd_in;\n\t_IO_iconv_t __cd_out;\n};\n\n/* Extra data for wide character streams.  */\nstruct _IO_wide_data {\n\twchar_t *_IO_read_ptr;\t/* Current read pointer */\n\twchar_t *_IO_read_end;\t/* End of get area. */\n\twchar_t *_IO_read_base;\t/* Start of putback+get area. */\n\twchar_t *_IO_write_base;\t/* Start of put area. */\n\twchar_t *_IO_write_ptr;\t/* Current put pointer. */\n\twchar_t *_IO_write_end;\t/* End of put area. */\n\twchar_t *_IO_buf_base;\t/* Start of reserve area. */\n\twchar_t *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\twchar_t *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\twchar_t *_IO_backup_base;\t/* Pointer to first valid character of\n\t\t\t\t\t   backup area */\n\twchar_t *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\t__mbstate_t _IO_state;\n\t__mbstate_t _IO_last_state;\n\tstruct _IO_codecvt _codecvt;\n\n\twchar_t _shortbuf[1];\n\n\tconst struct _IO_jump_t *_wide_vtable;\n};\n#endif\n\nstruct _IO_FILE {\n\tint _flags;\t\t/* High-order word is _IO_MAGIC; rest is flags. */\n#define _IO_file_flags _flags\n\n\t/* The following pointers correspond to the C++ streambuf protocol. */\n\t/* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */\n\tchar *_IO_read_ptr;\t/* Current read pointer */\n\tchar *_IO_read_end;\t/* End of get area. */\n\tchar *_IO_read_base;\t/* Start of putback+get area. */\n\tchar *_IO_write_base;\t/* Start of put area. */\n\tchar *_IO_write_ptr;\t/* Current put pointer. */\n\tchar *_IO_write_end;\t/* End of put area. */\n\tchar *_IO_buf_base;\t/* Start of reserve area. */\n\tchar *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\tchar *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\tchar *_IO_backup_base;\t/* Pointer to first valid character of backup area */\n\tchar *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\tstruct _IO_marker *_markers;\n\n\tstruct _IO_FILE *_chain;\n\n\tint _fileno;\n#if 0\n\tint _blksize;\n#else\n\tint _flags2;\n#endif\n\t_IO_off_t _old_offset;\t/* This used to be _offset but it's too small.  */\n\n#define __HAVE_COLUMN\t\t/* temporary */\n\t/* 1+column number of pbase(); 0 is unknown. */\n\tunsigned short _cur_column;\n\tsigned char _vtable_offset;\n\tchar _shortbuf[1];\n\n\t/*  char* _save_gptr;  char* _save_egptr; */\n\n\t_IO_lock_t *_lock;\n#ifdef _IO_USE_OLD_IO_FILE\n};\n\nstruct _IO_FILE_complete {\n\tstruct _IO_FILE _file;\n#endif\n#if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001\n\t_IO_off64_t _offset;\n# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\t/* Wide character stream stuff.  */\n\tstruct _IO_codecvt *_codecvt;\n\tstruct _IO_wide_data *_wide_data;\n\tstruct _IO_FILE *_freeres_list;\n\tvoid *_freeres_buf;\n\tsize_t _freeres_size;\n# else\n\tvoid *__pad1;\n\tvoid *__pad2;\n\tvoid *__pad3;\n\tvoid *__pad4;\n\tsize_t __pad5;\n# endif\n\tint _mode;\n\t/* Make sure we don't get into trouble again.  */\n\tchar _unused2[15 * sizeof(int) - 4 * sizeof(void *) - sizeof(size_t)];\n#endif\n};\n\n#ifndef __cplusplus\ntypedef struct _IO_FILE _IO_FILE;\n#endif\n\nstruct _IO_FILE_plus;\n\nextern struct _IO_FILE_plus _IO_2_1_stdin_;\nextern struct _IO_FILE_plus _IO_2_1_stdout_;\nextern struct _IO_FILE_plus _IO_2_1_stderr_;\n#ifndef _LIBC\n#define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))\n#define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))\n#define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))\n#else\nextern _IO_FILE *_IO_stdin attribute_hidden;\nextern _IO_FILE *_IO_stdout attribute_hidden;\nextern _IO_FILE *_IO_stderr attribute_hidden;\n#endif\n\n/* Functions to do I/O and file management for a stream.  */\n\n/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.\n   Return number of bytes read.  */\ntypedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __nbytes);\n\n/* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes\n   unless there is an error.  Return number of bytes written.  If\n   there is an error, return 0 and do not write anything.  If the file\n   has been opened for append (__mode.__append set), then set the file\n   pointer to the end of the file and then do the write; if not, just\n   write at the current file pointer.  */\ntypedef __ssize_t __io_write_fn(void *__cookie, const char *__buf, size_t __n);\n\n/* Move COOKIE's file position to *POS bytes from the\n   beginning of the file (if W is SEEK_SET),\n   the current position (if W is SEEK_CUR),\n   or the end of the file (if W is SEEK_END).\n   Set *POS to the new file position.\n   Returns zero if successful, nonzero if not.  */\ntypedef int __io_seek_fn(void *__cookie, _IO_off64_t * __pos, int __w);\n\n/* Close COOKIE.  */\ntypedef int __io_close_fn(void *__cookie);\n\n#ifdef _GNU_SOURCE\n/* User-visible names for the above.  */\ntypedef __io_read_fn cookie_read_function_t;\ntypedef __io_write_fn cookie_write_function_t;\ntypedef __io_seek_fn cookie_seek_function_t;\ntypedef __io_close_fn cookie_close_function_t;\n\n/* The structure with the cookie function pointers.  */\ntypedef struct {\n\t__io_read_fn *read;\t/* Read bytes.  */\n\t__io_write_fn *write;\t/* Write bytes.  */\n\t__io_seek_fn *seek;\t/* Seek/tell file position.  */\n\t__io_close_fn *close;\t/* Close file.  */\n} _IO_cookie_io_functions_t;\ntypedef _IO_cookie_io_functions_t cookie_io_functions_t;\n\nstruct _IO_cookie_file;\n\n/* Initialize one of those.  */\nextern void _IO_cookie_init(struct _IO_cookie_file *__cfile, int __read_write, void *__cookie, _IO_cookie_io_functions_t __fns);\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\textern int __underflow(_IO_FILE *);\n\textern int __uflow(_IO_FILE *);\n\textern int __overflow(_IO_FILE *, int);\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t __wunderflow(_IO_FILE *);\n\textern _IO_wint_t __wuflow(_IO_FILE *);\n\textern _IO_wint_t __woverflow(_IO_FILE *, _IO_wint_t);\n#endif\n\n#if  __GNUC__ >= 3\n# define _IO_BE(expr, res) __builtin_expect ((expr), res)\n#else\n# define _IO_BE(expr, res) (expr)\n#endif\n\n#define _IO_getc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)\n#define _IO_peekc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t  && __underflow (_fp) == EOF ? EOF \\\n\t: *(unsigned char *) (_fp)->_IO_read_ptr)\n#define _IO_putc_unlocked(_ch, _fp) \\\n   (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \\\n    ? __overflow (_fp, (unsigned char) (_ch)) \\\n    : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n# define _IO_getwc_unlocked(_fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_read_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_read_end), 0)\t\t\t\\\n   ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)\n# define _IO_putwc_unlocked(_wch, _fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_write_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_write_end), 0)\t\t\t\\\n   ? __woverflow (_fp, _wch)\t\t\t\t\t\t\\\n   : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))\n#endif\n\n#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)\n#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)\n\n\textern int _IO_getc(_IO_FILE * __fp);\n\textern int _IO_putc(int __c, _IO_FILE * __fp);\n\textern int _IO_feof(_IO_FILE * __fp) __THROW;\n\textern int _IO_ferror(_IO_FILE * __fp) __THROW;\n\n\textern int _IO_peekc_locked(_IO_FILE * __fp);\n\n/* This one is for Emacs. */\n#define _IO_PENDING_OUTPUT_COUNT(_fp)\t\\\n\t((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)\n\n\textern void _IO_flockfile(_IO_FILE *) __THROW;\n\textern void _IO_funlockfile(_IO_FILE *) __THROW;\n\textern int _IO_ftrylockfile(_IO_FILE *) __THROW;\n\n#ifdef _IO_MTSAFE_IO\n# define _IO_peekc(_fp) _IO_peekc_locked (_fp)\n# define _IO_flockfile(_fp) \\\n  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)\n# define _IO_funlockfile(_fp) \\\n  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)\n#else\n# define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)\n# define _IO_flockfile(_fp) /**/\n# define _IO_funlockfile(_fp) /**/\n# define _IO_ftrylockfile(_fp) /**/\n# define _IO_cleanup_region_start(_fct, _fp) /**/\n# define _IO_cleanup_region_end(_Doit) /**/\n#endif\t\t\t\t/* !_IO_MTSAFE_IO */\n\t extern int _IO_vfscanf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfprintf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_padn(_IO_FILE *, int, _IO_ssize_t);\n\textern _IO_size_t _IO_sgetn(_IO_FILE *, void *, _IO_size_t);\n\n\textern _IO_off64_t _IO_seekoff(_IO_FILE *, _IO_off64_t, int, int);\n\textern _IO_off64_t _IO_seekpos(_IO_FILE *, _IO_off64_t, int);\n\n\textern void _IO_free_backup_area(_IO_FILE *) __THROW;\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t _IO_getwc(_IO_FILE * __fp);\n\textern _IO_wint_t _IO_putwc(wchar_t __wc, _IO_FILE * __fp);\n\textern int _IO_fwide(_IO_FILE * __fp, int __mode) __THROW;\n# if __GNUC__ >= 2\n/* While compiling glibc we have to handle compatibility with very old\n   versions.  */\n#  if defined _LIBC && defined SHARED\n#   include <shlib-compat.h>\n#   if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)\n#    define _IO_fwide_maybe_incompatible \\\n  (__builtin_expect (&_IO_stdin_used == NULL, 0))\n\textern const int _IO_stdin_used;\n\t weak_extern(_IO_stdin_used);\n#   endif\n#  endif\n#  ifndef _IO_fwide_maybe_incompatible\n#   define _IO_fwide_maybe_incompatible (0)\n#  endif\n/* A special optimized version of the function above.  It optimizes the\n   case of initializing an unoriented byte stream.  */\n#  define _IO_fwide(__fp, __mode) \\\n  ({ int __result = (__mode);\t\t\t\t\t\t      \\\n     if (__result < 0 && ! _IO_fwide_maybe_incompatible)\t\t      \\\n       {\t\t\t\t\t\t\t\t      \\\n\t if ((__fp)->_mode == 0)\t\t\t\t\t      \\\n\t   /* We know that all we have to do is to set the flag.  */\t      \\\n\t   (__fp)->_mode = -1;\t\t\t\t\t\t      \\\n\t __result = (__fp)->_mode;\t\t\t\t\t      \\\n       }\t\t\t\t\t\t\t\t      \\\n     else if (__builtin_constant_p (__mode) && (__mode) == 0)\t\t      \\\n       __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode;\t      \\\n     else\t\t\t\t\t\t\t\t      \\\n       __result = _IO_fwide (__fp, __result);\t\t\t\t      \\\n     __result; })\n# endif\n\n\textern int _IO_vfwscanf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfwprintf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_wpadn(_IO_FILE *, wint_t, _IO_ssize_t);\n\textern void _IO_free_wbackup_area(_IO_FILE *) __THROW;\n#endif\n\n#ifdef __LDBL_COMPAT\n# include <bits/libio-ldbl.h>\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* _IO_STDIO_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/limits.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types\t<limits.h>\n */\n\n#ifndef _LIBC_LIMITS_H_\n#define _LIBC_LIMITS_H_\t1\n\n#include <features.h>\n\n/* Maximum length of any multibyte character in any locale.\n   We define this value here since the gcc header does not define\n   the correct value.  */\n#define MB_LEN_MAX\t16\n\n/* If we are not using GNU CC we have to define all the symbols ourself.\n   Otherwise use gcc's definitions (see below).  */\n#if !defined __GNUC__ || __GNUC__ < 2\n\n/* We only protect from multiple inclusion here, because all the other\n   #include's protect themselves, and in GCC 2 we may #include_next through\n   multiple copies of this file before we get to GCC's.  */\n# ifndef _LIMITS_H\n#  define _LIMITS_H\t1\n\n#include <bits/wordsize.h>\n\n/* We don't have #include_next.\n   Define ANSI <limits.h> for standard 32-bit words.  */\n\n/* These assume 8-bit `char's, 16-bit `short int's,\n   and 32-bit `int's and `long int's.  */\n\n/* Number of bits in a `char'.\t*/\n#  define CHAR_BIT\t8\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#  define SCHAR_MIN\t(-128)\n#  define SCHAR_MAX\t127\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */\n#  define UCHAR_MAX\t255\n\n/* Minimum and maximum values a `char' can hold.  */\n#  ifdef __CHAR_UNSIGNED__\n#   define CHAR_MIN\t0\n#   define CHAR_MAX\tUCHAR_MAX\n#  else\n#   define CHAR_MIN\tSCHAR_MIN\n#   define CHAR_MAX\tSCHAR_MAX\n#  endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#  define SHRT_MIN\t(-32768)\n#  define SHRT_MAX\t32767\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */\n#  define USHRT_MAX\t65535\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#  define INT_MIN\t(-INT_MAX - 1)\n#  define INT_MAX\t2147483647\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */\n#  define UINT_MAX\t4294967295U\n\n/* Minimum and maximum values a `signed long int' can hold.  */\n#  if __WORDSIZE == 64\n#   define LONG_MAX\t9223372036854775807L\n#  else\n#   define LONG_MAX\t2147483647L\n#  endif\n#  define LONG_MIN\t(-LONG_MAX - 1L)\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */\n#  if __WORDSIZE == 64\n#   define ULONG_MAX\t18446744073709551615UL\n#  else\n#   define ULONG_MAX\t4294967295UL\n#  endif\n\n#  ifdef __USE_ISOC99\n\n/* Minimum and maximum values a `signed long long int' can hold.  */\n#   define LLONG_MAX\t9223372036854775807LL\n#   define LLONG_MIN\t(-LLONG_MAX - 1LL)\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */\n#   define ULLONG_MAX\t18446744073709551615ULL\n\n#  endif\t\t\t/* ISO C99 */\n\n# endif\t\t\t\t/* limits.h  */\n#endif\t\t\t\t/* GCC 2.  */\n\n#endif\t\t\t\t/* !_LIBC_LIMITS_H_ */\n\n /* Get the compiler's limits.h, which defines almost all the ISO constants.\n\n    We put this #include_next outside the double inclusion check because\n    it should be possible to include this file more than once and still get\n    the definitions from gcc's header.  */\n#if defined __GNUC__ && !defined _GCC_LIMITS_H_\n/* `_GCC_LIMITS_H_' is what GCC's file defines.  */\n# include_next <limits.h>\n#endif\n\n/* The <limits.h> files in some gcc versions don't define LLONG_MIN,\n   LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined for\n   ages are available.  */\n#if defined __USE_ISOC99 && defined __GNUC__\n# ifndef LLONG_MIN\n#  define LLONG_MIN\t(-LLONG_MAX-1)\n# endif\n# ifndef LLONG_MAX\n#  define LLONG_MAX\t__LONG_LONG_MAX__\n# endif\n# ifndef ULLONG_MAX\n#  define ULLONG_MAX\t(LLONG_MAX * 2ULL + 1)\n# endif\n#endif\n\n#ifdef\t__USE_POSIX\n/* POSIX adds things to <limits.h>.  */\n# include <bits/posix1_lim.h>\n#endif\n\n#ifdef\t__USE_POSIX2\n# include <bits/posix2_lim.h>\n#endif\n\n#ifdef\t__USE_XOPEN\n# include <bits/xopen_lim.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/linux/errno.h",
    "content": "#include <asm/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/linux/ioctl.h",
    "content": "#ifndef _LINUX_IOCTL_H\n#define _LINUX_IOCTL_H\n\n#include <asm/ioctl.h>\n\n#endif\t\t\t\t/* _LINUX_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/linux/limits.h",
    "content": "#ifndef _LINUX_LIMITS_H\n#define _LINUX_LIMITS_H\n\n#define NR_OPEN\t        1024\n\n#define NGROUPS_MAX    65536\t/* supplemental group IDs are available */\n#define ARG_MAX       131072\t/* # bytes of args + environ for exec() */\n#define LINK_MAX         127\t/* # links a file may have */\n#define MAX_CANON        255\t/* size of the canonical input queue */\n#define MAX_INPUT        255\t/* size of the type-ahead buffer */\n#define NAME_MAX         255\t/* # chars in a file name */\n#define PATH_MAX        4096\t/* # chars in a path name including nul */\n#define PIPE_BUF        4096\t/* # bytes in atomic write to a pipe */\n#define XATTR_NAME_MAX   255\t/* # chars in an extended attribute name */\n#define XATTR_SIZE_MAX 65536\t/* size of an extended attribute value (64k) */\n#define XATTR_LIST_MAX 65536\t/* size of extended attribute namelist (64k) */\n\n#define RTSIG_MAX\t  32\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/linux/param.h",
    "content": "#ifndef _LINUX_PARAM_H\n#define _LINUX_PARAM_H\n\n#include <asm/param.h>\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/locale.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.11 Localization\t<locale.h>\n */\n\n#ifndef\t_LOCALE_H\n#define\t_LOCALE_H\t1\n\n#include <features.h>\n\n#define __need_NULL\n#include <stddef.h>\n#include <bits/locale.h>\n\n__BEGIN_DECLS\n/* These are the possibilities for the first argument to setlocale.\n   The code assumes that the lowest LC_* symbol has the value zero.  */\n#define LC_CTYPE          __LC_CTYPE\n#define LC_NUMERIC        __LC_NUMERIC\n#define LC_TIME           __LC_TIME\n#define LC_COLLATE        __LC_COLLATE\n#define LC_MONETARY       __LC_MONETARY\n#define LC_MESSAGES       __LC_MESSAGES\n#define\tLC_ALL\t\t  __LC_ALL\n#define LC_PAPER\t  __LC_PAPER\n#define LC_NAME\t\t  __LC_NAME\n#define LC_ADDRESS\t  __LC_ADDRESS\n#define LC_TELEPHONE\t  __LC_TELEPHONE\n#define LC_MEASUREMENT\t  __LC_MEASUREMENT\n#define LC_IDENTIFICATION __LC_IDENTIFICATION\n    __BEGIN_NAMESPACE_STD\n/* Structure giving information about numeric and monetary notation.  */\n    struct lconv {\n\t/* Numeric (non-monetary) information.  */\n\n\tchar *decimal_point;\t/* Decimal point character.  */\n\tchar *thousands_sep;\t/* Thousands separator.  */\n\t/* Each element is the number of digits in each group;\n\t   elements with higher indices are farther left.\n\t   An element with value CHAR_MAX means that no further grouping is done.\n\t   An element with value 0 means that the previous element is used\n\t   for all groups farther left.  */\n\tchar *grouping;\n\n\t/* Monetary information.  */\n\n\t/* First three chars are a currency symbol from ISO 4217.\n\t   Fourth char is the separator.  Fifth char is '\\0'.  */\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\t/* Local currency symbol.  */\n\tchar *mon_decimal_point;\t/* Decimal point character.  */\n\tchar *mon_thousands_sep;\t/* Thousands separator.  */\n\tchar *mon_grouping;\t/* Like `grouping' element (above).  */\n\tchar *positive_sign;\t/* Sign for positive values.  */\n\tchar *negative_sign;\t/* Sign for negative values.  */\n\tchar int_frac_digits;\t/* Int'l fractional digits.  */\n\tchar frac_digits;\t/* Local fractional digits.  */\n\t/* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */\n\tchar p_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a positive value.  */\n\tchar p_sep_by_space;\n\t/* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */\n\tchar n_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a negative value.  */\n\tchar n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and currency_symbol.\n\t   1 The sign string precedes the quantity and currency_symbol.\n\t   2 The sign string follows the quantity and currency_symbol.\n\t   3 The sign string immediately precedes the currency_symbol.\n\t   4 The sign string immediately follows the currency_symbol.  */\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n#ifdef __USE_ISOC99\n\t/* 1 if int_curr_symbol precedes a positive value, 0 if succeeds.  */\n\tchar int_p_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a positive value.  */\n\tchar int_p_sep_by_space;\n\t/* 1 if int_curr_symbol precedes a negative value, 0 if succeeds.  */\n\tchar int_n_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a negative value.  */\n\tchar int_n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and int_curr_symbol.\n\t   1 The sign string precedes the quantity and int_curr_symbol.\n\t   2 The sign string follows the quantity and int_curr_symbol.\n\t   3 The sign string immediately precedes the int_curr_symbol.\n\t   4 The sign string immediately follows the int_curr_symbol.  */\n\tchar int_p_sign_posn;\n\tchar int_n_sign_posn;\n#else\n\tchar __int_p_cs_precedes;\n\tchar __int_p_sep_by_space;\n\tchar __int_n_cs_precedes;\n\tchar __int_n_sep_by_space;\n\tchar __int_p_sign_posn;\n\tchar __int_n_sign_posn;\n#endif\n};\n\n/* Set and/or return the current locale.  */\nextern char *setlocale(int __category, const char *__locale) __THROW;\n\n/* Return the numeric/monetary information for the current locale.  */\nextern struct lconv *localeconv(void) __THROW;\n\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n/* Get locale datatype definition.  */\n# include <xlocale.h>\n/* Return a reference to a data structure representing a set of locale\n   datasets.  Unlike for the CATEGORY parameter for `setlocale' the\n   CATEGORY_MASK parameter here uses a single bit for each category,\n   made by OR'ing together LC_*_MASK bits above.  */\nextern __locale_t newlocale(int __category_mask, const char *__locale, __locale_t __base) __THROW;\n\n/* These are the bits that can be set in the CATEGORY_MASK argument to\n   `newlocale'.  In the GNU implementation, LC_FOO_MASK has the value\n   of (1 << LC_FOO), but this is not a part of the interface that\n   callers can assume will be true.  */\n# define LC_CTYPE_MASK\t\t(1 << __LC_CTYPE)\n# define LC_NUMERIC_MASK\t(1 << __LC_NUMERIC)\n# define LC_TIME_MASK\t\t(1 << __LC_TIME)\n# define LC_COLLATE_MASK\t(1 << __LC_COLLATE)\n# define LC_MONETARY_MASK\t(1 << __LC_MONETARY)\n# define LC_MESSAGES_MASK\t(1 << __LC_MESSAGES)\n# define LC_PAPER_MASK\t\t(1 << __LC_PAPER)\n# define LC_NAME_MASK\t\t(1 << __LC_NAME)\n# define LC_ADDRESS_MASK\t(1 << __LC_ADDRESS)\n# define LC_TELEPHONE_MASK\t(1 << __LC_TELEPHONE)\n# define LC_MEASUREMENT_MASK\t(1 << __LC_MEASUREMENT)\n# define LC_IDENTIFICATION_MASK\t(1 << __LC_IDENTIFICATION)\n# define LC_ALL_MASK\t\t(LC_CTYPE_MASK \\\n\t\t\t\t | LC_NUMERIC_MASK \\\n\t\t\t\t | LC_TIME_MASK \\\n\t\t\t\t | LC_COLLATE_MASK \\\n\t\t\t\t | LC_MONETARY_MASK \\\n\t\t\t\t | LC_MESSAGES_MASK \\\n\t\t\t\t | LC_PAPER_MASK \\\n\t\t\t\t | LC_NAME_MASK \\\n\t\t\t\t | LC_ADDRESS_MASK \\\n\t\t\t\t | LC_TELEPHONE_MASK \\\n\t\t\t\t | LC_MEASUREMENT_MASK \\\n\t\t\t\t | LC_IDENTIFICATION_MASK \\\n\t\t\t\t )\n\n/* Return a duplicate of the set of locale in DATASET.  All usage\n   counters are increased if necessary.  */\nextern __locale_t duplocale(__locale_t __dataset) __THROW;\n\n/* Free the data associated with a locale dataset previously returned\n   by a call to `setlocale_r'.  */\nextern void freelocale(__locale_t __dataset) __THROW;\n\n/* Switch the current thread's locale to DATASET.\n   If DATASET is null, instead just return the current setting.\n   The special value LC_GLOBAL_LOCALE is the initial setting\n   for all threads and can also be installed any time, meaning\n   the thread uses the global settings controlled by `setlocale'.  */\nextern __locale_t uselocale(__locale_t __dataset) __THROW;\n\n/* This value can be passed to `uselocale' and may be returned by it.\n   Passing this value to any other function has undefined behavior.  */\n# define LC_GLOBAL_LOCALE\t((__locale_t) -1L)\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* locale.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/malloc.h",
    "content": "/* Prototypes and definition for malloc implementation.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MALLOC_H\n#define _MALLOC_H 1\n\n#include <features.h>\n#include <stddef.h>\n#include <stdio.h>\n\n#ifdef _LIBC\n# define __MALLOC_HOOK_VOLATILE\n# define __MALLOC_DEPRECATED\n#else\n# define __MALLOC_HOOK_VOLATILE volatile\n# define __MALLOC_DEPRECATED __attribute_deprecated__\n#endif\n\n__BEGIN_DECLS\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Re-allocate the previously allocated block in __ptr, making the new\n   block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n\n/* Free a block allocated by `calloc'. */\nextern void cfree(void *__ptr) __THROW;\n\n/* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */\nextern void *memalign(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate SIZE bytes on a page boundary.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up\n   __size to nearest pagesize. */\nextern void *pvalloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Underlying allocation function; successive calls should return\n   contiguous pieces of memory.  */\nextern void *(*__morecore) (ptrdiff_t __size);\n\n/* Default value of `__morecore'.  */\nextern void *__default_morecore(ptrdiff_t __size)\n__THROW __attribute_malloc__;\n\n/* SVID2/XPG mallinfo structure */\n\nstruct mallinfo {\n\tint arena;\t\t/* non-mmapped space allocated from system */\n\tint ordblks;\t\t/* number of free chunks */\n\tint smblks;\t\t/* number of fastbin blocks */\n\tint hblks;\t\t/* number of mmapped regions */\n\tint hblkhd;\t\t/* space in mmapped regions */\n\tint usmblks;\t\t/* maximum total allocated space */\n\tint fsmblks;\t\t/* space available in freed fastbin blocks */\n\tint uordblks;\t\t/* total allocated space */\n\tint fordblks;\t\t/* total free space */\n\tint keepcost;\t\t/* top-most, releasable (via malloc_trim) space */\n};\n\n/* Returns a copy of the updated current mallinfo. */\nextern struct mallinfo mallinfo(void) __THROW;\n\n/* SVID2/XPG mallopt options */\n#ifndef M_MXFAST\n# define M_MXFAST  1\t\t/* maximum request size for \"fastbins\" */\n#endif\n#ifndef M_NLBLKS\n# define M_NLBLKS  2\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_GRAIN\n# define M_GRAIN   3\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_KEEP\n# define M_KEEP    4\t\t/* UNUSED in this malloc */\n#endif\n\n/* mallopt options that actually do something */\n#define M_TRIM_THRESHOLD    -1\n#define M_TOP_PAD           -2\n#define M_MMAP_THRESHOLD    -3\n#define M_MMAP_MAX          -4\n#define M_CHECK_ACTION      -5\n#define M_PERTURB           -6\n#define M_ARENA_TEST        -7\n#define M_ARENA_MAX         -8\n\n/* General SVID/XPG interface to tunable parameters. */\nextern int mallopt(int __param, int __val) __THROW;\n\n/* Release all but __pad bytes of freed top-most memory back to the\n   system. Return 1 if successful, else 0. */\nextern int malloc_trim(size_t __pad) __THROW;\n\n/* Report the number of usable allocated bytes associated with allocated\n   chunk __ptr. */\nextern size_t malloc_usable_size(void *__ptr) __THROW;\n\n/* Prints brief summary statistics on stderr. */\nextern void malloc_stats(void) __THROW;\n\n/* Output information about state of allocator to stream FP.  */\nextern int malloc_info(int __options, FILE * __fp) __THROW;\n\n/* Record the state of all malloc variables in an opaque data structure. */\nextern void *malloc_get_state(void) __THROW;\n\n/* Restore the state of all malloc variables from data obtained with\n   malloc_get_state(). */\nextern int malloc_set_state(void *__ptr) __THROW;\n\n/* Called once when malloc is initialized; redefining this variable in\n   the application provides the preferred way to set up the hook\n   pointers. */\nextern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void)__MALLOC_DEPRECATED;\n/* Hooks for debugging and user-defined versions. */\nextern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);\n\n/* Activate a standard set of debugging hooks. */\nextern void __malloc_check_init(void)\n__THROW __MALLOC_DEPRECATED;\n\n__END_DECLS\n#endif\t\t\t\t/* malloc.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/math.h",
    "content": "/* Declarations for math functions.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.12 Mathematics\t<math.h>\n */\n\n#ifndef\t_MATH_H\n#define\t_MATH_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get machine-dependent vector math functions declarations.  */\n#include <bits/math-vector.h>\n/* Get machine-dependent HUGE_VAL value (returned on overflow).\n   On all IEEE754 machines, this is +Infinity.  */\n#include <bits/huge_val.h>\n#ifdef __USE_ISOC99\n# include <bits/huge_valf.h>\n# include <bits/huge_vall.h>\n/* Get machine-dependent INFINITY value.  */\n# include <bits/inf.h>\n/* Get machine-dependent NAN value (returned for some domain errors).  */\n# include <bits/nan.h>\n#endif\t\t\t\t/* __USE_ISOC99 */\n/* Get general and ISO C99 specific information.  */\n#include <bits/mathdef.h>\n/* The file <bits/mathcalls.h> contains the prototypes for all the\n   actual math functions.  These macros are used for those prototypes,\n   so we can easily declare each function as both `name' and `__name',\n   and can declare the float versions `namef' and `__namef'.  */\n#define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)\n#define __MATHCALL_VEC(function, suffix, args) \t\\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHCALL (function, suffix, args)\n#define __MATHDECL_VEC(type, function,suffix, args) \\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHDECL(type, function,suffix, args)\n#define __MATHCALL(function,suffix, args)\t\\\n  __MATHDECL (_Mdouble_,function,suffix, args)\n#define __MATHDECL(type, function,suffix, args) \\\n  __MATHDECL_1(type, function,suffix, args); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args)\n#define __MATHCALLX(function,suffix, args, attrib)\t\\\n  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)\n#define __MATHDECLX(type, function,suffix, args, attrib) \\\n  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)\n#define __MATHDECL_1(type, function,suffix, args) \\\n  extern type __MATH_PRECNAME(function,suffix) args __THROW\n#define _Mdouble_\t\tdouble\n#define __MATH_PRECNAME(name,r)\t__CONCAT(name,r)\n#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD\n#define _Mdouble_END_NAMESPACE   __END_NAMESPACE_STD\n#include <bits/mathcalls.h>\n#undef\t_Mdouble_\n#undef _Mdouble_BEGIN_NAMESPACE\n#undef _Mdouble_END_NAMESPACE\n#undef\t__MATH_PRECNAME\n#ifdef __USE_ISOC99\n/* Include the file of declarations again, this time using `float'\n   instead of `double' and appending f to each function name.  */\n# ifndef _Mfloat_\n#  define _Mfloat_\t\tfloat\n# endif\n# define _Mdouble_\t\t_Mfloat_\n# define __MATH_PRECNAME(name,r) name##f##r\n# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99\n# define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99\n# include <bits/mathcalls.h>\n# undef\t_Mdouble_\n# undef _Mdouble_BEGIN_NAMESPACE\n# undef _Mdouble_END_NAMESPACE\n# undef\t__MATH_PRECNAME\n# if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \\\n     || defined __LDBL_COMPAT \\\n     || defined _LIBC_TEST\n#  ifdef __LDBL_COMPAT\n#   ifdef __USE_ISOC99\nextern float __nldbl_nexttowardf(float __x, long double __y)\n__THROW __attribute__ ((__const__));\n#    ifdef __REDIRECT_NTH\nextern float __REDIRECT_NTH(nexttowardf, (float __x, long double __y), __nldbl_nexttowardf)\n    __attribute__ ((__const__));\nextern double __REDIRECT_NTH(nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__));\nextern long double __REDIRECT_NTH(nexttowardl, (long double __x, long double __y), nextafter) __attribute__ ((__const__));\n#    endif\n#   endif\n\n#   undef __MATHDECL_1\n#   define __MATHDECL_2(type, function,suffix, args, alias) \\\n  extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \\\n\t\t\t     args, alias)\n#   define __MATHDECL_1(type, function,suffix, args) \\\n  __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))\n#  endif\n\n/* Include the file of declarations again, this time using `long double'\n   instead of `double' and appending l to each function name.  */\n\n#  ifndef _Mlong_double_\n#   define _Mlong_double_\tlong double\n#  endif\n#  define _Mdouble_\t\t_Mlong_double_\n#  define __MATH_PRECNAME(name,r) name##l##r\n#  define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99\n#  define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99\n#  define __MATH_DECLARE_LDOUBLE   1\n#  include <bits/mathcalls.h>\n#  undef _Mdouble_\n#  undef _Mdouble_BEGIN_NAMESPACE\n#  undef _Mdouble_END_NAMESPACE\n#  undef __MATH_PRECNAME\n\n# endif\t\t\t\t/* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */\n\n#endif\t\t\t\t/* Use ISO C99.  */\n#undef\t__MATHDECL_1\n#undef\t__MATHDECL\n#undef\t__MATHCALL\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* This variable is used by `gamma' and `lgamma'.  */\nextern int signgam;\n#endif\n\n/* ISO C99 defines some generic macros which work on any data type.  */\n#ifdef __USE_ISOC99\n\n/* Get the architecture specific values describing the floating-point\n   evaluation.  The following symbols will get defined:\n\n    float_t\tfloating-point type at least as wide as `float' used\n\t\tto evaluate `float' expressions\n    double_t\tfloating-point type at least as wide as `double' used\n\t\tto evaluate `double' expressions\n\n    FLT_EVAL_METHOD\n\t\tDefined to\n\t\t  0\tif `float_t' is `float' and `double_t' is `double'\n\t\t  1\tif `float_t' and `double_t' are `double'\n\t\t  2\tif `float_t' and `double_t' are `long double'\n\t\t  else\t`float_t' and `double_t' are unspecified\n\n    INFINITY\trepresentation of the infinity value of type `float'\n\n    FP_FAST_FMA\n    FP_FAST_FMAF\n    FP_FAST_FMAL\n\t\tIf defined it indicates that the `fma' function\n\t\tgenerally executes about as fast as a multiply and an add.\n\t\tThis macro is defined only iff the `fma' function is\n\t\timplemented directly with a hardware multiply-add instructions.\n\n    FP_ILOGB0\tExpands to a value returned by `ilogb (0.0)'.\n    FP_ILOGBNAN\tExpands to a value returned by `ilogb (NAN)'.\n\n    DECIMAL_DIG\tNumber of decimal digits supported by conversion between\n\t\tdecimal and all internal floating-point formats.\n\n*/\n\n/* All floating-point numbers can be put in one of these categories.  */\nenum {\n\tFP_NAN =\n# define FP_NAN 0\n\t    FP_NAN,\n\tFP_INFINITE =\n# define FP_INFINITE 1\n\t    FP_INFINITE,\n\tFP_ZERO =\n# define FP_ZERO 2\n\t    FP_ZERO,\n\tFP_SUBNORMAL =\n# define FP_SUBNORMAL 3\n\t    FP_SUBNORMAL,\n\tFP_NORMAL =\n# define FP_NORMAL 4\n\tFP_NORMAL\n};\n\n/* Return number of classification appropriate for X.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define fpclassify(x) \\\n     (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))\n# else\n#  define fpclassify(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __fpclassifyf (x)\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __fpclassify (x) : __fpclassifyl (x))\n# endif\n\n/* Return nonzero value if sign of X is negative.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define signbit(x) \\\n     (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))\n# else\n#  define signbit(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __signbitf (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __signbit (x) : __signbitl (x))\n# endif\n\n/* Return nonzero value if X is not +-Inf or NaN.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define isfinite(x) \\\n     (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))\n# else\n#  define isfinite(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __finitef (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __finite (x) : __finitel (x))\n# endif\n\n/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */\n# define isnormal(x) (fpclassify (x) == FP_NORMAL)\n\n/* Return nonzero value if X is a NaN.  We could use `fpclassify' but\n   we already have this functions `__isnan' and it is faster.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define isnan(x) \\\n     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))\n# else\n#  define isnan(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __isnanf (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __isnan (x) : __isnanl (x))\n# endif\n\n/* Return nonzero value if X is positive or negative infinity.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define isinf(x) \\\n     (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))\n# else\n#  define isinf(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __isinff (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __isinf (x) : __isinfl (x))\n# endif\n\n/* Bitmasks for the math_errhandling macro.  */\n# define MATH_ERRNO\t1\t/* errno set by math functions.  */\n# define MATH_ERREXCEPT\t2\t/* Exceptions raised by math functions.  */\n\n/* By default all functions support both errno and exception handling.\n   In gcc's fast math mode and if inline functions are defined this\n   might not be true.  */\n# ifndef __FAST_MATH__\n#  define math_errhandling\t(MATH_ERRNO | MATH_ERREXCEPT)\n# endif\n\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#ifdef __USE_GNU\n/* Return nonzero value if X is a signaling NaN.  */\n# ifdef __NO_LONG_DOUBLE_MATH\n#  define issignaling(x) \\\n     (sizeof (x) == sizeof (float) ? __issignalingf (x) : __issignaling (x))\n# else\n#  define issignaling(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __issignalingf (x)\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __issignaling (x) : __issignalingl (x))\n# endif\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef\t__USE_MISC\n/* Support for various different standard error handling behaviors.  */\ntypedef enum {\n\t_IEEE_ = -1,\t\t/* According to IEEE 754/IEEE 854.  */\n\t_SVID_,\t\t\t/* According to System V, release 4.  */\n\t_XOPEN_,\t\t/* Nowadays also Unix98.  */\n\t_POSIX_,\n\t_ISOC_\t\t\t/* Actually this is ISO C99.  */\n} _LIB_VERSION_TYPE;\n\n/* This variable can be changed at run-time to any of the values above to\n   affect floating point error handling behavior (it may also be necessary\n   to change the hardware FPU exception settings).  */\nextern _LIB_VERSION_TYPE _LIB_VERSION;\n#endif\n\n#ifdef __USE_MISC\n/* In SVID error handling, `matherr' is called with this description\n   of the exceptional condition.\n\n   We have a problem when using C++ since `exception' is a reserved\n   name in C++.  */\n# ifdef __cplusplus\nstruct __exception\n# else\nstruct exception\n# endif\n{\n\tint type;\n\tchar *name;\n\tdouble arg1;\n\tdouble arg2;\n\tdouble retval;\n};\n\n# ifdef __cplusplus\nextern int matherr(struct __exception *__exc) throw();\n# else\nextern int matherr(struct exception *__exc);\n# endif\n\n# define X_TLOSS\t1.41484755040568800000e+16\n\n/* Types of exceptions in the `type' field.  */\n# define DOMAIN\t\t1\n# define SING\t\t2\n# define OVERFLOW\t3\n# define UNDERFLOW\t4\n# define TLOSS\t\t5\n# define PLOSS\t\t6\n\n/* SVID mode specifies returning this large value instead of infinity.  */\n# define HUGE\t\t3.40282347e+38F\n\n#else\t\t\t\t/* !Misc.  */\n\n# ifdef __USE_XOPEN\n/* X/Open wants another strange constant.  */\n#  define MAXFLOAT\t3.40282347e+38F\n# endif\n\n#endif\t\t\t\t/* Misc.  */\n\n/* Some useful constants.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n# define M_E\t\t2.7182818284590452354\t/* e */\n# define M_LOG2E\t1.4426950408889634074\t/* log_2 e */\n# define M_LOG10E\t0.43429448190325182765\t/* log_10 e */\n# define M_LN2\t\t0.69314718055994530942\t/* log_e 2 */\n# define M_LN10\t\t2.30258509299404568402\t/* log_e 10 */\n# define M_PI\t\t3.14159265358979323846\t/* pi */\n# define M_PI_2\t\t1.57079632679489661923\t/* pi/2 */\n# define M_PI_4\t\t0.78539816339744830962\t/* pi/4 */\n# define M_1_PI\t\t0.31830988618379067154\t/* 1/pi */\n# define M_2_PI\t\t0.63661977236758134308\t/* 2/pi */\n# define M_2_SQRTPI\t1.12837916709551257390\t/* 2/sqrt(pi) */\n# define M_SQRT2\t1.41421356237309504880\t/* sqrt(2) */\n# define M_SQRT1_2\t0.70710678118654752440\t/* 1/sqrt(2) */\n#endif\n\n/* The above constants are not adequate for computation using `long double's.\n   Therefore we provide as an extension constants with similar names as a\n   GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */\n#ifdef __USE_GNU\n# define M_El\t\t2.718281828459045235360287471352662498L\t/* e */\n# define M_LOG2El\t1.442695040888963407359924681001892137L\t/* log_2 e */\n# define M_LOG10El\t0.434294481903251827651128918916605082L\t/* log_10 e */\n# define M_LN2l\t\t0.693147180559945309417232121458176568L\t/* log_e 2 */\n# define M_LN10l\t2.302585092994045684017991454684364208L\t/* log_e 10 */\n# define M_PIl\t\t3.141592653589793238462643383279502884L\t/* pi */\n# define M_PI_2l\t1.570796326794896619231321691639751442L\t/* pi/2 */\n# define M_PI_4l\t0.785398163397448309615660845819875721L\t/* pi/4 */\n# define M_1_PIl\t0.318309886183790671537767526745028724L\t/* 1/pi */\n# define M_2_PIl\t0.636619772367581343075535053490057448L\t/* 2/pi */\n# define M_2_SQRTPIl\t1.128379167095512573896158903121545172L\t/* 2/sqrt(pi) */\n# define M_SQRT2l\t1.414213562373095048801688724209698079L\t/* sqrt(2) */\n# define M_SQRT1_2l\t0.707106781186547524400844362104849039L\t/* 1/sqrt(2) */\n#endif\n\n/* When compiling in strict ISO C compatible mode we must not use the\n   inline functions since they, among other things, do not set the\n   `errno' variable correctly.  */\n#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES\n# define __NO_MATH_INLINES\t1\n#endif\n\n#if defined __USE_ISOC99 && __GNUC_PREREQ(2,97)\n/* ISO C99 defines some macros to compare number while taking care for\n   unordered numbers.  Many FPUs provide special instructions to support\n   these operations.  Generic support in GCC for these as builtins went\n   in before 3.0.0, but not all cpus added their patterns.  We define\n   versions that use the builtins here, and <bits/mathinline.h> will\n   undef/redefine as appropriate for the specific GCC version in use.  */\n# define isgreater(x, y)\t__builtin_isgreater(x, y)\n# define isgreaterequal(x, y)\t__builtin_isgreaterequal(x, y)\n# define isless(x, y)\t\t__builtin_isless(x, y)\n# define islessequal(x, y)\t__builtin_islessequal(x, y)\n# define islessgreater(x, y)\t__builtin_islessgreater(x, y)\n# define isunordered(u, v)\t__builtin_isunordered(u, v)\n#endif\n\n/* Get machine-dependent inline versions (if there are any).  */\n#ifdef __USE_EXTERN_INLINES\n# include <bits/mathinline.h>\n#endif\n\n/* Define special entry points to use when the compiler got told to\n   only expect finite results.  */\n#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0\n# include <bits/math-finite.h>\n#endif\n\n#ifdef __USE_ISOC99\n/* If we've still got undefined comparison macros, provide defaults.  */\n\n/* Return nonzero value if X is greater than Y.  */\n# ifndef isgreater\n#  define isgreater(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x > __y; }))\n# endif\n\n/* Return nonzero value if X is greater than or equal to Y.  */\n# ifndef isgreaterequal\n#  define isgreaterequal(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x >= __y; }))\n# endif\n\n/* Return nonzero value if X is less than Y.  */\n# ifndef isless\n#  define isless(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x < __y; }))\n# endif\n\n/* Return nonzero value if X is less than or equal to Y.  */\n# ifndef islessequal\n#  define islessequal(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x <= __y; }))\n# endif\n\n/* Return nonzero value if either X is less than Y or Y is less than X.  */\n# ifndef islessgreater\n#  define islessgreater(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && (__x < __y || __y < __x); }))\n# endif\n\n/* Return nonzero value if arguments are unordered.  */\n# ifndef isunordered\n#  define isunordered(u, v) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v);\t\t\t      \\\n      fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))\n# endif\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* math.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/memory.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * SVID\n */\n\n#ifndef\t_MEMORY_H\n#define\t_MEMORY_H\t1\n\n#include <features.h>\n\n#ifndef\t_STRING_H\n# include <string.h>\n#endif\t\t\t\t/* string.h  */\n\n#endif\t\t\t\t/* memory.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/netdb.h",
    "content": "  /* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n     This file is part of the GNU C Library.\n\n     The GNU C Library is free software; you can redistribute it and/or\n     modify it under the terms of the GNU Lesser General Public\n     License as published by the Free Software Foundation; either\n     version 2.1 of the License, or (at your option) any later version.\n\n     The GNU C Library is distributed in the hope that it will be useful,\n     but WITHOUT ANY WARRANTY; without even the implied warranty of\n     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n     Lesser General Public License for more details.\n\n     You should have received a copy of the GNU Lesser General Public\n     License along with the GNU C Library; if not, see\n     <http://www.gnu.org/licenses/>.  */\n\n/* All data returned by the network data base library are supplied in\n   host order and returned in network order (suitable for use in\n   system calls).  */\n\n#ifndef\t_NETDB_H\n#define\t_NETDB_H\t1\n\n#include <features.h>\n\n#include <netinet/in.h>\n#include <stdint.h>\n#ifdef __USE_MISC\n/* This is necessary to make this include file properly replace the\n   Sun version.  */\n# include <rpc/netdb.h>\n#endif\n\n#ifdef __USE_GNU\n# define __need_sigevent_t\n# include <bits/siginfo.h>\n# define __need_timespec\n# include <time.h>\n#endif\n\n#include <bits/netdb.h>\n\n/* Absolute file name for network data base files.  */\n#define\t_PATH_HEQUIV\t\t\"/etc/hosts.equiv\"\n#define\t_PATH_HOSTS\t\t\"/etc/hosts\"\n#define\t_PATH_NETWORKS\t\t\"/etc/networks\"\n#define\t_PATH_NSSWITCH_CONF\t\"/etc/nsswitch.conf\"\n#define\t_PATH_PROTOCOLS\t\t\"/etc/protocols\"\n#define\t_PATH_SERVICES\t\t\"/etc/services\"\n\n__BEGIN_DECLS\n#if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Error status for non-reentrant lookup functions.\n   We use a macro to access always the thread-specific `h_errno' variable.  */\n# define h_errno (*__h_errno_location ())\n/* Function to get address of global `h_errno' variable.  */\nextern int *__h_errno_location(void)\n__THROW __attribute__ ((__const__));\n\n/* Possible values left in `h_errno'.  */\n# define HOST_NOT_FOUND\t1\t/* Authoritative Answer Host not found.  */\n# define TRY_AGAIN\t2\t/* Non-Authoritative Host not found,\n\t\t\t\t   or SERVERFAIL.  */\n# define NO_RECOVERY\t3\t/* Non recoverable errors, FORMERR, REFUSED,\n\t\t\t\t   NOTIMP.  */\n# define NO_DATA\t4\t/* Valid name, no data record of requested\n\t\t\t\t   type.  */\n#endif\n#ifdef __USE_MISC\n# define NETDB_INTERNAL\t-1\t/* See errno.  */\n# define NETDB_SUCCESS\t0\t/* No problem.  */\n# define NO_ADDRESS\tNO_DATA\t/* No address, look for MX record.  */\n#endif\n\n#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED\n/* Highest reserved Internet port number.  */\n# define IPPORT_RESERVED\t1024\n#endif\n\n#ifdef __USE_GNU\n/* Scope delimiter for getaddrinfo(), getnameinfo().  */\n# define SCOPE_DELIMITER\t'%'\n#endif\n\n#ifdef __USE_MISC\n/* Print error indicated by `h_errno' variable on standard error.  STR\n   if non-null is printed before the error string.  */\nextern void herror(const char *__str) __THROW;\n\n/* Return string associated with error ERR_NUM.  */\nextern const char *hstrerror(int __err_num) __THROW;\n#endif\n\n/* Description of data base entry for a single host.  */\nstruct hostent {\n\tchar *h_name;\t\t/* Official name of host.  */\n\tchar **h_aliases;\t/* Alias list.  */\n\tint h_addrtype;\t\t/* Host address type.  */\n\tint h_length;\t\t/* Length of address.  */\n\tchar **h_addr_list;\t/* List of addresses from name server.  */\n#ifdef __USE_MISC\n# define\th_addr\th_addr_list[0]\t/* Address, for backward compatibility. */\n#endif\n};\n\n/* Open host data base files and mark them as staying open even after\n   a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void sethostent(int __stay_open);\n\n/* Close host data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endhostent(void);\n\n/* Get next entry from host data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostent(void);\n\n/* Return entry from host data base which address match ADDR with\n   length LEN and type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyaddr(const void *__addr, __socklen_t __len, int __type);\n\n/* Return entry from host data base for host with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyname(const char *__name);\n\n#ifdef __USE_MISC\n/* Return entry from host data base for host with NAME.  AF must be\n   set to the address type which is `AF_INET' for IPv4 or `AF_INET6'\n   for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct hostent *gethostbyname2(const char *__name, int __af);\n\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int gethostent_r(struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyaddr_r(const void *__restrict __addr, __socklen_t __len, int __type, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname_r(const char *__restrict __name, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname2_r(const char *__restrict __name, int __af, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Open network data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setnetent(int __stay_open);\n\n/* Close network data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endnetent(void);\n\n/* Get next entry from network data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetent(void);\n\n/* Return entry from network data base which address match NET and\n   type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyaddr(uint32_t __net, int __type);\n\n/* Return entry from network data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyname(const char *__name);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getnetent_r(struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyaddr_r(uint32_t __net, int __type, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyname_r(const char *__restrict __name, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct servent {\n\tchar *s_name;\t\t/* Official service name.  */\n\tchar **s_aliases;\t/* Alias list.  */\n\tint s_port;\t\t/* Port number.  */\n\tchar *s_proto;\t\t/* Protocol to use.  */\n};\n\n/* Open service data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setservent(int __stay_open);\n\n/* Close service data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endservent(void);\n\n/* Get next entry from service data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservent(void);\n\n/* Return entry from network data base for network with NAME and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyname(const char *__name, const char *__proto);\n\n/* Return entry from service data base which matches port PORT and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyport(int __port, const char *__proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getservent_r(struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyname_r(const char *__restrict __name, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyport_r(int __port, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct protoent {\n\tchar *p_name;\t\t/* Official protocol name.  */\n\tchar **p_aliases;\t/* Alias list.  */\n\tint p_proto;\t\t/* Protocol number.  */\n};\n\n/* Open protocol data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setprotoent(int __stay_open);\n\n/* Close protocol data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endprotoent(void);\n\n/* Get next entry from protocol data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotoent(void);\n\n/* Return entry from protocol data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobyname(const char *__name);\n\n/* Return entry from protocol data base which number is PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobynumber(int __proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getprotoent_r(struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobyname_r(const char *__restrict __name, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobynumber_r(int __proto, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\n/* Establish network group NETGROUP for enumeration.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int setnetgrent(const char *__netgroup);\n\n/* Free all space allocated by previous `setnetgrent' call.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern void endnetgrent(void);\n\n/* Get next member of netgroup established by last `setnetgrent' call\n   and return pointers to elements in HOSTP, USERP, and DOMAINP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp);\n\n/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int innetgr(const char *__netgroup, const char *__host, const char *__user, const char *__domain);\n\n/* Reentrant version of `getnetgrent' where result is placed in BUFFER.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent_r(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp, char *__restrict __buffer, size_t __buflen);\n#endif\t\t\t\t/* misc */\n\n#ifdef __USE_MISC\n/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.\n   The local user is LOCUSER, on the remote machine the command is\n   executed as REMUSER.  In *FD2P the descriptor to the socket for the\n   connection is returned.  The caller must have the right to use a\n   reserved port.  When the function returns *AHOST contains the\n   official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd_af(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Call `rexecd' at port RPORT on remote machine *AHOST to execute\n   CMD.  The process runs at the remote machine using the ID of user\n   NAME whose cleartext password is PASSWD.  In *FD2P the descriptor\n   to the socket for the connection is returned.  When the function\n   returns *AHOST contains the official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec_af(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.\n   If SUSER is not zero the user tries to become superuser.  Return 0 if\n   it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok(const char *__rhost, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok_af(const char *__rhost, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Check whether user REMUSER on system indicated by IPv4 address\n   RADDR is allowed to login as LOCUSER.  Non-IPv4 (e.g., IPv6) are\n   not supported.  If SUSER is not zero the user tries to become\n   superuser.  Return 0 if it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok(uint32_t __raddr, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the pfamiliy if the address\n   pointed to by RADDR is determined by the value of AF.  It therefore\n   can be used for IPv6\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok_af(const void *__raddr, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Try to allocate reserved port, returning a descriptor for a socket opened\n   at this port or -1 if unsuccessful.  The search for an available port\n   will start at ALPORT and continues with lower numbers.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport(int *__alport);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport_af(int *__alport, sa_family_t __af);\n#endif\n\n/* Extension from POSIX.1:2001.  */\n#ifdef __USE_XOPEN2K\n/* Structure to contain information about address of a service provider.  */\nstruct addrinfo {\n\tint ai_flags;\t\t/* Input flags.  */\n\tint ai_family;\t\t/* Protocol family for socket.  */\n\tint ai_socktype;\t/* Socket type.  */\n\tint ai_protocol;\t/* Protocol for socket.  */\n\tsocklen_t ai_addrlen;\t/* Length of socket address.  */\n\tstruct sockaddr *ai_addr;\t/* Socket address for socket.  */\n\tchar *ai_canonname;\t/* Canonical name for service location.  */\n\tstruct addrinfo *ai_next;\t/* Pointer to next in list.  */\n};\n\n# ifdef __USE_GNU\n/* Structure used as control block for asynchronous lookup.  */\nstruct gaicb {\n\tconst char *ar_name;\t/* Name to look up.  */\n\tconst char *ar_service;\t/* Service name.  */\n\tconst struct addrinfo *ar_request;\t/* Additional request specification.  */\n\tstruct addrinfo *ar_result;\t/* Pointer to result.  */\n\t/* The following are internal elements.  */\n\tint __return;\n\tint __glibc_reserved[5];\n};\n\n/* Lookup mode.  */\n#  define GAI_WAIT\t0\n#  define GAI_NOWAIT\t1\n# endif\n\n/* Possible values for `ai_flags' field in `addrinfo' structure.  */\n# define AI_PASSIVE\t0x0001\t/* Socket address is intended for `bind'.  */\n# define AI_CANONNAME\t0x0002\t/* Request for canonical name.  */\n# define AI_NUMERICHOST\t0x0004\t/* Don't use name resolution.  */\n# define AI_V4MAPPED\t0x0008\t/* IPv4 mapped addresses are acceptable.  */\n# define AI_ALL\t\t0x0010\t/* Return IPv4 mapped and IPv6 addresses.  */\n# define AI_ADDRCONFIG\t0x0020\t/* Use configuration of this host to choose\n\t\t\t\t   returned address type..  */\n# ifdef __USE_GNU\n#  define AI_IDN\t0x0040\t/* IDN encode input (assuming it is encoded\n\t\t\t\t   in the current locale's character set)\n\t\t\t\t   before looking it up. */\n#  define AI_CANONIDN\t0x0080\t/* Translate canonical name from IDN format. */\n#  define AI_IDN_ALLOW_UNASSIGNED 0x0100\t/* Don't reject unassigned Unicode\n\t\t\t\t\t\t   code points.  */\n#  define AI_IDN_USE_STD3_ASCII_RULES 0x0200\t/* Validate strings according to\n\t\t\t\t\t\t   STD3 rules.  */\n# endif\n# define AI_NUMERICSERV\t0x0400\t/* Don't use name resolution.  */\n\n/* Error values for `getaddrinfo' function.  */\n# define EAI_BADFLAGS\t  -1\t/* Invalid value for `ai_flags' field.  */\n# define EAI_NONAME\t  -2\t/* NAME or SERVICE is unknown.  */\n# define EAI_AGAIN\t  -3\t/* Temporary failure in name resolution.  */\n# define EAI_FAIL\t  -4\t/* Non-recoverable failure in name res.  */\n# define EAI_FAMILY\t  -6\t/* `ai_family' not supported.  */\n# define EAI_SOCKTYPE\t  -7\t/* `ai_socktype' not supported.  */\n# define EAI_SERVICE\t  -8\t/* SERVICE not supported for `ai_socktype'.  */\n# define EAI_MEMORY\t  -10\t/* Memory allocation failure.  */\n# define EAI_SYSTEM\t  -11\t/* System error returned in `errno'.  */\n# define EAI_OVERFLOW\t  -12\t/* Argument buffer overflow.  */\n# ifdef __USE_GNU\n#  define EAI_NODATA\t  -5\t/* No address associated with NAME.  */\n#  define EAI_ADDRFAMILY  -9\t/* Address family for NAME not supported.  */\n#  define EAI_INPROGRESS  -100\t/* Processing request in progress.  */\n#  define EAI_CANCELED\t  -101\t/* Request canceled.  */\n#  define EAI_NOTCANCELED -102\t/* Request not canceled.  */\n#  define EAI_ALLDONE\t  -103\t/* All requests done.  */\n#  define EAI_INTR\t  -104\t/* Interrupted by a signal.  */\n#  define EAI_IDN_ENCODE  -105\t/* IDN encoding failed.  */\n# endif\n\n# ifdef __USE_MISC\n#  define NI_MAXHOST      1025\n#  define NI_MAXSERV      32\n# endif\n\n# define NI_NUMERICHOST\t1\t/* Don't try to look up hostname.  */\n# define NI_NUMERICSERV 2\t/* Don't convert port number to name.  */\n# define NI_NOFQDN\t4\t/* Only return nodename portion.  */\n# define NI_NAMEREQD\t8\t/* Don't return numeric addresses.  */\n# define NI_DGRAM\t16\t/* Look up UDP service rather than TCP.  */\n# ifdef __USE_GNU\n#  define NI_IDN\t32\t/* Convert name from IDN format.  */\n#  define NI_IDN_ALLOW_UNASSIGNED 64\t/* Don't reject unassigned Unicode\n\t\t\t\t\t   code points.  */\n#  define NI_IDN_USE_STD3_ASCII_RULES 128\t/* Validate strings according to\n\t\t\t\t\t\t   STD3 rules.  */\n# endif\n\n/* Translate name of a service location and/or a service name to set of\n   socket addresses.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai);\n\n/* Free `addrinfo' structure AI including associated storage.  */\nextern void freeaddrinfo(struct addrinfo *__ai) __THROW;\n\n/* Convert error return from getaddrinfo() to a string.  */\nextern const char *gai_strerror(int __ecode) __THROW;\n\n/* Translate a socket address to a location and service name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, int __flags);\n#endif\t\t\t\t/* POSIX */\n\n#ifdef __USE_GNU\n/* Enqueue ENT requests from the LIST.  If MODE is GAI_WAIT wait until all\n   requests are handled.  If WAIT is GAI_NOWAIT return immediately after\n   queueing the requests and signal completion according to SIG.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getaddrinfo_a(int __mode, struct gaicb *__list[__restrict_arr], int __ent, struct sigevent *__restrict __sig);\n\n/* Suspend execution of the thread until at least one of the ENT requests\n   in LIST is handled.  If TIMEOUT is not a null pointer it specifies the\n   longest time the function keeps waiting before returning with an error.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int gai_suspend(const struct gaicb *const __list[], int __ent, const struct timespec *__timeout);\n\n/* Get the error status of the request REQ.  */\nextern int gai_error(struct gaicb *__req) __THROW;\n\n/* Cancel the requests associated with GAICBP.  */\nextern int gai_cancel(struct gaicb *__gaicbp) __THROW;\n#endif\t\t\t\t/* GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/netinet/in.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_NETINET_IN_H\n#define\t_NETINET_IN_H\t1\n\n#include <features.h>\n#include <stdint.h>\n#include <sys/socket.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n/* Internet address.  */\ntypedef uint32_t in_addr_t;\nstruct in_addr {\n\tin_addr_t s_addr;\n};\n\n/* Get system-specific definitions.  */\n#include <bits/in.h>\n\n/* Standard well-defined IP protocols.  */\nenum {\n\tIPPROTO_IP = 0,\t\t/* Dummy protocol for TCP.  */\n#define IPPROTO_IP\t\tIPPROTO_IP\n\tIPPROTO_ICMP = 1,\t/* Internet Control Message Protocol.  */\n#define IPPROTO_ICMP\t\tIPPROTO_ICMP\n\tIPPROTO_IGMP = 2,\t/* Internet Group Management Protocol. */\n#define IPPROTO_IGMP\t\tIPPROTO_IGMP\n\tIPPROTO_IPIP = 4,\t/* IPIP tunnels (older KA9Q tunnels use 94).  */\n#define IPPROTO_IPIP\t\tIPPROTO_IPIP\n\tIPPROTO_TCP = 6,\t/* Transmission Control Protocol.  */\n#define IPPROTO_TCP\t\tIPPROTO_TCP\n\tIPPROTO_EGP = 8,\t/* Exterior Gateway Protocol.  */\n#define IPPROTO_EGP\t\tIPPROTO_EGP\n\tIPPROTO_PUP = 12,\t/* PUP protocol.  */\n#define IPPROTO_PUP\t\tIPPROTO_PUP\n\tIPPROTO_UDP = 17,\t/* User Datagram Protocol.  */\n#define IPPROTO_UDP\t\tIPPROTO_UDP\n\tIPPROTO_IDP = 22,\t/* XNS IDP protocol.  */\n#define IPPROTO_IDP\t\tIPPROTO_IDP\n\tIPPROTO_TP = 29,\t/* SO Transport Protocol Class 4.  */\n#define IPPROTO_TP\t\tIPPROTO_TP\n\tIPPROTO_DCCP = 33,\t/* Datagram Congestion Control Protocol.  */\n#define IPPROTO_DCCP\t\tIPPROTO_DCCP\n\tIPPROTO_IPV6 = 41,\t/* IPv6 header.  */\n#define IPPROTO_IPV6\t\tIPPROTO_IPV6\n\tIPPROTO_RSVP = 46,\t/* Reservation Protocol.  */\n#define IPPROTO_RSVP\t\tIPPROTO_RSVP\n\tIPPROTO_GRE = 47,\t/* General Routing Encapsulation.  */\n#define IPPROTO_GRE\t\tIPPROTO_GRE\n\tIPPROTO_ESP = 50,\t/* encapsulating security payload.  */\n#define IPPROTO_ESP\t\tIPPROTO_ESP\n\tIPPROTO_AH = 51,\t/* authentication header.  */\n#define IPPROTO_AH\t\tIPPROTO_AH\n\tIPPROTO_MTP = 92,\t/* Multicast Transport Protocol.  */\n#define IPPROTO_MTP\t\tIPPROTO_MTP\n\tIPPROTO_BEETPH = 94,\t/* IP option pseudo header for BEET.  */\n#define IPPROTO_BEETPH\t\tIPPROTO_BEETPH\n\tIPPROTO_ENCAP = 98,\t/* Encapsulation Header.  */\n#define IPPROTO_ENCAP\t\tIPPROTO_ENCAP\n\tIPPROTO_PIM = 103,\t/* Protocol Independent Multicast.  */\n#define IPPROTO_PIM\t\tIPPROTO_PIM\n\tIPPROTO_COMP = 108,\t/* Compression Header Protocol.  */\n#define IPPROTO_COMP\t\tIPPROTO_COMP\n\tIPPROTO_SCTP = 132,\t/* Stream Control Transmission Protocol.  */\n#define IPPROTO_SCTP\t\tIPPROTO_SCTP\n\tIPPROTO_UDPLITE = 136,\t/* UDP-Lite protocol.  */\n#define IPPROTO_UDPLITE\t\tIPPROTO_UDPLITE\n\tIPPROTO_RAW = 255,\t/* Raw IP packets.  */\n#define IPPROTO_RAW\t\tIPPROTO_RAW\n\tIPPROTO_MAX\n};\n\n/* If __USE_KERNEL_IPV6_DEFS is defined then the user has included the kernel\n   network headers first and we should use those ABI-identical definitions\n   instead of our own.  */\n#ifndef __USE_KERNEL_IPV6_DEFS\nenum {\n\tIPPROTO_HOPOPTS = 0,\t/* IPv6 Hop-by-Hop options.  */\n#define IPPROTO_HOPOPTS\t\tIPPROTO_HOPOPTS\n\tIPPROTO_ROUTING = 43,\t/* IPv6 routing header.  */\n#define IPPROTO_ROUTING\t\tIPPROTO_ROUTING\n\tIPPROTO_FRAGMENT = 44,\t/* IPv6 fragmentation header.  */\n#define IPPROTO_FRAGMENT\tIPPROTO_FRAGMENT\n\tIPPROTO_ICMPV6 = 58,\t/* ICMPv6.  */\n#define IPPROTO_ICMPV6\t\tIPPROTO_ICMPV6\n\tIPPROTO_NONE = 59,\t/* IPv6 no next header.  */\n#define IPPROTO_NONE\t\tIPPROTO_NONE\n\tIPPROTO_DSTOPTS = 60,\t/* IPv6 destination options.  */\n#define IPPROTO_DSTOPTS\t\tIPPROTO_DSTOPTS\n\tIPPROTO_MH = 135\t/* IPv6 mobility header.  */\n#define IPPROTO_MH\t\tIPPROTO_MH\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Type to represent a port.  */\ntypedef uint16_t in_port_t;\n\n/* Standard well-known ports.  */\nenum {\n\tIPPORT_ECHO = 7,\t/* Echo service.  */\n\tIPPORT_DISCARD = 9,\t/* Discard transmissions service.  */\n\tIPPORT_SYSTAT = 11,\t/* System status service.  */\n\tIPPORT_DAYTIME = 13,\t/* Time of day service.  */\n\tIPPORT_NETSTAT = 15,\t/* Network status service.  */\n\tIPPORT_FTP = 21,\t/* File Transfer Protocol.  */\n\tIPPORT_TELNET = 23,\t/* Telnet protocol.  */\n\tIPPORT_SMTP = 25,\t/* Simple Mail Transfer Protocol.  */\n\tIPPORT_TIMESERVER = 37,\t/* Timeserver service.  */\n\tIPPORT_NAMESERVER = 42,\t/* Domain Name Service.  */\n\tIPPORT_WHOIS = 43,\t/* Internet Whois service.  */\n\tIPPORT_MTP = 57,\n\n\tIPPORT_TFTP = 69,\t/* Trivial File Transfer Protocol.  */\n\tIPPORT_RJE = 77,\n\tIPPORT_FINGER = 79,\t/* Finger service.  */\n\tIPPORT_TTYLINK = 87,\n\tIPPORT_SUPDUP = 95,\t/* SUPDUP protocol.  */\n\n\tIPPORT_EXECSERVER = 512,\t/* execd service.  */\n\tIPPORT_LOGINSERVER = 513,\t/* rlogind service.  */\n\tIPPORT_CMDSERVER = 514,\n\tIPPORT_EFSSERVER = 520,\n\n\t/* UDP ports.  */\n\tIPPORT_BIFFUDP = 512,\n\tIPPORT_WHOSERVER = 513,\n\tIPPORT_ROUTESERVER = 520,\n\n\t/* Ports less than this value are reserved for privileged processes.  */\n\tIPPORT_RESERVED = 1024,\n\n\t/* Ports greater this value are reserved for (non-privileged) servers.  */\n\tIPPORT_USERRESERVED = 5000\n};\n\n/* Definitions of the bits in an Internet address integer.\n\n   On subnets, host and network parts are found according to\n   the subnet mask, not these masks.  */\n\n#define\tIN_CLASSA(a)\t\t((((in_addr_t)(a)) & 0x80000000) == 0)\n#define\tIN_CLASSA_NET\t\t0xff000000\n#define\tIN_CLASSA_NSHIFT\t24\n#define\tIN_CLASSA_HOST\t\t(0xffffffff & ~IN_CLASSA_NET)\n#define\tIN_CLASSA_MAX\t\t128\n\n#define\tIN_CLASSB(a)\t\t((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)\n#define\tIN_CLASSB_NET\t\t0xffff0000\n#define\tIN_CLASSB_NSHIFT\t16\n#define\tIN_CLASSB_HOST\t\t(0xffffffff & ~IN_CLASSB_NET)\n#define\tIN_CLASSB_MAX\t\t65536\n\n#define\tIN_CLASSC(a)\t\t((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)\n#define\tIN_CLASSC_NET\t\t0xffffff00\n#define\tIN_CLASSC_NSHIFT\t8\n#define\tIN_CLASSC_HOST\t\t(0xffffffff & ~IN_CLASSC_NET)\n\n#define\tIN_CLASSD(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)\n#define\tIN_MULTICAST(a)\t\tIN_CLASSD(a)\n\n#define\tIN_EXPERIMENTAL(a)\t((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)\n#define\tIN_BADCLASS(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)\n\n/* Address to accept any incoming messages.  */\n#define\tINADDR_ANY\t\t((in_addr_t) 0x00000000)\n/* Address to send to all hosts.  */\n#define\tINADDR_BROADCAST\t((in_addr_t) 0xffffffff)\n/* Address indicating an error return.  */\n#define\tINADDR_NONE\t\t((in_addr_t) 0xffffffff)\n\n/* Network number for local host loopback.  */\n#define\tIN_LOOPBACKNET\t\t127\n/* Address to loopback in software to local host.  */\n#ifndef INADDR_LOOPBACK\n# define INADDR_LOOPBACK\t((in_addr_t) 0x7f000001)\t/* Inet 127.0.0.1.  */\n#endif\n\n/* Defines for Multicast INADDR.  */\n#define INADDR_UNSPEC_GROUP\t((in_addr_t) 0xe0000000)\t/* 224.0.0.0 */\n#define INADDR_ALLHOSTS_GROUP\t((in_addr_t) 0xe0000001)\t/* 224.0.0.1 */\n#define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002)\t/* 224.0.0.2 */\n#define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)\t/* 224.0.0.255 */\n\n#ifndef __USE_KERNEL_IPV6_DEFS\n/* IPv6 address */\nstruct in6_addr {\n\tunion {\n\t\tuint8_t __u6_addr8[16];\n#ifdef __USE_MISC\n\t\tuint16_t __u6_addr16[8];\n\t\tuint32_t __u6_addr32[4];\n#endif\n\t} __in6_u;\n#define s6_addr\t\t\t__in6_u.__u6_addr8\n#ifdef __USE_MISC\n# define s6_addr16\t\t__in6_u.__u6_addr16\n# define s6_addr32\t\t__in6_u.__u6_addr32\n#endif\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\nextern const struct in6_addr in6addr_any;\t/* :: */\nextern const struct in6_addr in6addr_loopback;\t/* ::1 */\n#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }\n#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }\n\n#define INET_ADDRSTRLEN 16\n#define INET6_ADDRSTRLEN 46\n\n/* Structure describing an Internet socket address.  */\nstruct sockaddr_in {\n\t__SOCKADDR_COMMON(sin_);\n\tin_port_t sin_port;\t/* Port number.  */\n\tstruct in_addr sin_addr;\t/* Internet address.  */\n\n\t/* Pad to size of `struct sockaddr'.  */\n\tunsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof(in_port_t) - sizeof(struct in_addr)];\n};\n\n#ifndef __USE_KERNEL_IPV6_DEFS\n/* Ditto, for IPv6.  */\nstruct sockaddr_in6 {\n\t__SOCKADDR_COMMON(sin6_);\n\tin_port_t sin6_port;\t/* Transport layer port # */\n\tuint32_t sin6_flowinfo;\t/* IPv6 flow information */\n\tstruct in6_addr sin6_addr;\t/* IPv6 address */\n\tuint32_t sin6_scope_id;\t/* IPv6 scope-id */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* IPv4 multicast request.  */\nstruct ip_mreq {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imr_interface;\n};\n\nstruct ip_mreq_source {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* IP address of source.  */\n\tstruct in_addr imr_interface;\n\n\t/* IP address of interface.  */\n\tstruct in_addr imr_sourceaddr;\n};\n#endif\n\n#ifndef __USE_KERNEL_IPV6_DEFS\n/* Likewise, for IPv6.  */\nstruct ipv6_mreq {\n\t/* IPv6 multicast address of group */\n\tstruct in6_addr ipv6mr_multiaddr;\n\n\t/* local interface */\n\tunsigned int ipv6mr_interface;\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* Multicast group request.  */\nstruct group_req {\n\t/* Interface index.  */\n\tuint32_t gr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gr_group;\n};\n\nstruct group_source_req {\n\t/* Interface index.  */\n\tuint32_t gsr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gsr_group;\n\n\t/* Source address.  */\n\tstruct sockaddr_storage gsr_source;\n};\n\n/* Full-state filter operations.  */\nstruct ip_msfilter {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imsf_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imsf_interface;\n\n\t/* Filter mode.  */\n\tuint32_t imsf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t imsf_numsrc;\n\t/* Source addresses.  */\n\tstruct in_addr imsf_slist[1];\n};\n\n#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \\\n\t\t\t\t  - sizeof (struct in_addr)\t\t      \\\n\t\t\t\t  + (numsrc) * sizeof (struct in_addr))\n\nstruct group_filter {\n\t/* Interface index.  */\n\tuint32_t gf_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gf_group;\n\n\t/* Filter mode.  */\n\tuint32_t gf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t gf_numsrc;\n\t/* Source addresses.  */\n\tstruct sockaddr_storage gf_slist[1];\n};\n\n#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \\\n\t\t\t\t   - sizeof (struct sockaddr_storage)\t      \\\n\t\t\t\t   + ((numsrc)\t\t\t\t      \\\n\t\t\t\t      * sizeof (struct sockaddr_storage)))\n#endif\n\n/* Functions to convert between host and network byte order.\n\n   Please note that these functions normally take `unsigned long int' or\n   `unsigned short int' values as arguments and also return them.  But\n   this was a short-sighted decision since on different systems the types\n   may have different representations but the values are always the same.  */\n\nextern uint32_t ntohl(uint32_t __netlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t ntohs(uint16_t __netshort)\n__THROW __attribute__ ((__const__));\nextern uint32_t htonl(uint32_t __hostlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t htons(uint16_t __hostshort)\n__THROW __attribute__ ((__const__));\n\n#include <endian.h>\n\n/* Get machine dependent optimized versions of byte swapping functions.  */\n#include <bits/byteswap.h>\n\n#ifdef __OPTIMIZE__\n/* We can optimize calls to the conversion functions.  Either nothing has\n   to be done or we are using directly the byte-swapping functions which\n   often can be inlined.  */\n# if __BYTE_ORDER == __BIG_ENDIAN\n/* The host byte order is the same as network byte order,\n   so these functions are all just identity.  */\n# define ntohl(x)\t(x)\n# define ntohs(x)\t(x)\n# define htonl(x)\t(x)\n# define htons(x)\t(x)\n# else\n#  if __BYTE_ORDER == __LITTLE_ENDIAN\n#   define ntohl(x)\t__bswap_32 (x)\n#   define ntohs(x)\t__bswap_16 (x)\n#   define htonl(x)\t__bswap_32 (x)\n#   define htons(x)\t__bswap_16 (x)\n#  endif\n# endif\n#endif\n\n#ifdef __GNUC__\n# define IN6_IS_ADDR_UNSPECIFIED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[3] == 0; }))\n\n# define IN6_IS_ADDR_LOOPBACK(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[3] == htonl (1); }))\n\n# define IN6_IS_ADDR_LINKLOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))\n\n# define IN6_IS_ADDR_SITELOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))\n\n# define IN6_IS_ADDR_V4MAPPED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == htonl (0xffff); }))\n\n# define IN6_IS_ADDR_V4COMPAT(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && ntohl (__a->s6_addr32[3]) > 1; }))\n\n# define IN6_ARE_ADDR_EQUAL(a,b) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      const struct in6_addr *__b = (const struct in6_addr *) (b);\t      \\\n      __a->s6_addr32[0] == __b->s6_addr32[0]\t\t\t\t      \\\n      && __a->s6_addr32[1] == __b->s6_addr32[1]\t\t\t\t      \\\n      && __a->s6_addr32[2] == __b->s6_addr32[2]\t\t\t\t      \\\n      && __a->s6_addr32[3] == __b->s6_addr32[3]; }))\n#else\n# define IN6_IS_ADDR_UNSPECIFIED(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == 0)\n\n# define IN6_IS_ADDR_LOOPBACK(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == htonl (1))\n\n# define IN6_IS_ADDR_LINKLOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfe800000))\n\n# define IN6_IS_ADDR_SITELOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfec00000))\n\n# define IN6_IS_ADDR_V4MAPPED(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == htonl (0xffff)))\n\n# define IN6_IS_ADDR_V4COMPAT(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == 0)\t\t\t\t      \\\n\t && (ntohl (((const uint32_t *) (a))[3]) > 1))\n\n# define IN6_ARE_ADDR_EQUAL(a,b) \\\n\t((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])\t      \\\n\t && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \\\n\t && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \\\n\t && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))\n#endif\n\n#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)\n\n#ifdef __USE_MISC\n/* Bind socket to a privileged IP port.  */\nextern int bindresvport(int __sockfd, struct sockaddr_in *__sock_in) __THROW;\n\n/* The IPv6 version of this function.  */\nextern int bindresvport6(int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;\n#endif\n\n#define IN6_IS_ADDR_MC_NODELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))\n\n#define IN6_IS_ADDR_MC_LINKLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))\n\n#define IN6_IS_ADDR_MC_SITELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))\n\n#define IN6_IS_ADDR_MC_ORGLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))\n\n#define IN6_IS_ADDR_MC_GLOBAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))\n\n#ifdef __USE_GNU\nstruct cmsghdr;\t\t\t/* Forward declaration.  */\n\n#ifndef __USE_KERNEL_IPV6_DEFS\n/* IPv6 packet information.  */\nstruct in6_pktinfo {\n\tstruct in6_addr ipi6_addr;\t/* src/dst IPv6 address */\n\tunsigned int ipi6_ifindex;\t/* send/recv interface index */\n};\n\n/* IPv6 MTU information.  */\nstruct ip6_mtuinfo {\n\tstruct sockaddr_in6 ip6m_addr;\t/* dst address including zone ID */\n\tuint32_t ip6m_mtu;\t/* path MTU in host byte order */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */\nextern int inet6_option_space(int __nbytes)\n__THROW __attribute_deprecated__;\nextern int inet6_option_init(void *__bp, struct cmsghdr **__cmsgp, int __type)\n__THROW __attribute_deprecated__;\nextern int inet6_option_append(struct cmsghdr *__cmsg, const uint8_t * __typep, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern uint8_t *inet6_option_alloc(struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern int inet6_option_next(const struct cmsghdr *__cmsg, uint8_t ** __tptrp)\n__THROW __attribute_deprecated__;\nextern int inet6_option_find(const struct cmsghdr *__cmsg, uint8_t ** __tptrp, int __type)\n__THROW __attribute_deprecated__;\n\n/* Hop-by-Hop and Destination Options Processing (RFC 3542).  */\nextern int inet6_opt_init(void *__extbuf, socklen_t __extlen) __THROW;\nextern int inet6_opt_append(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;\nextern int inet6_opt_finish(void *__extbuf, socklen_t __extlen, int __offset) __THROW;\nextern int inet6_opt_set_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\nextern int inet6_opt_next(void *__extbuf, socklen_t __extlen, int __offset, uint8_t * __typep, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_find(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_get_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\n\n/* Routing Header Option (RFC 3542).  */\nextern socklen_t inet6_rth_space(int __type, int __segments) __THROW;\nextern void *inet6_rth_init(void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW;\nextern int inet6_rth_add(void *__bp, const struct in6_addr *__addr) __THROW;\nextern int inet6_rth_reverse(const void *__in, void *__out) __THROW;\nextern int inet6_rth_segments(const void *__bp) __THROW;\nextern struct in6_addr *inet6_rth_getaddr(const void *__bp, int __index) __THROW;\n\n/* Multicast source filter support.  */\n\n/* Get IPv4 source filter.  */\nextern int getipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t * __fmode, uint32_t * __numsrc, struct in_addr *__slist) __THROW;\n\n/* Set IPv4 source filter.  */\nextern int setipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t __fmode, uint32_t __numsrc, const struct in_addr *__slist) __THROW;\n\n/* Get source filter.  */\nextern int getsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t * __fmode, uint32_t * __numsrc, struct sockaddr_storage *__slist) __THROW;\n\n/* Set source filter.  */\nextern int setsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t __fmode, uint32_t __numsrc, const struct sockaddr_storage *__slist) __THROW;\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netinet/in.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/pthread.h",
    "content": "/* Copyright (C) 2002-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _PTHREAD_H\n#define _PTHREAD_H\t1\n\n#include <features.h>\n#include <endian.h>\n#include <sched.h>\n#include <time.h>\n\n#include <bits/pthreadtypes.h>\n#include <bits/setjmp.h>\n#include <bits/wordsize.h>\n\n/* Detach state.  */\nenum {\n\tPTHREAD_CREATE_JOINABLE,\n#define PTHREAD_CREATE_JOINABLE\tPTHREAD_CREATE_JOINABLE\n\tPTHREAD_CREATE_DETACHED\n#define PTHREAD_CREATE_DETACHED\tPTHREAD_CREATE_DETACHED\n};\n\n/* Mutex types.  */\nenum {\n\tPTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_ADAPTIVE_NP\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n\t    ,\n\tPTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL\n#endif\n#ifdef __USE_GNU\n\t    /* For compatibility.  */\n\t    , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP\n#endif\n};\n\n#ifdef __USE_XOPEN2K\n/* Robust mutex or not flags.  */\nenum {\n\tPTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_ROBUST,\n\tPTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST\n};\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Mutex protocols.  */\nenum {\n\tPTHREAD_PRIO_NONE,\n\tPTHREAD_PRIO_INHERIT,\n\tPTHREAD_PRIO_PROTECT\n};\n#endif\n\n#ifdef __PTHREAD_MUTEX_HAVE_PREV\n# define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }\n# ifdef __USE_GNU\n#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n\n# endif\n#else\n# define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }\n# ifdef __USE_GNU\n#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }\n#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }\n#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }\n\n# endif\n#endif\n\n/* Read-write lock types.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\nenum {\n\tPTHREAD_RWLOCK_PREFER_READER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\n\tPTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP\n};\n\n/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t\n   has the shared field.  All 64-bit architectures have the shared field\n   in pthread_rwlock_t.  */\n#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n# if __WORDSIZE == 64\n#  define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1\n# endif\n#endif\n\n/* Read-write lock initializers.  */\n# define PTHREAD_RWLOCK_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n# ifdef __USE_GNU\n#  ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0,\t\t\t\t\t      \\\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }\n#  else\n#   if __BYTE_ORDER == __LITTLE_ENDIAN\n#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \\\n      0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n#   else\n#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\\\n      0 } }\n#   endif\n#  endif\n# endif\n#endif\t\t\t\t/* Unix98 or XOpen2K */\n\n/* Scheduler inheritance.  */\nenum {\n\tPTHREAD_INHERIT_SCHED,\n#define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED\n\tPTHREAD_EXPLICIT_SCHED\n#define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED\n};\n\n/* Scope handling.  */\nenum {\n\tPTHREAD_SCOPE_SYSTEM,\n#define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM\n\tPTHREAD_SCOPE_PROCESS\n#define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS\n};\n\n/* Process shared or private flag.  */\nenum {\n\tPTHREAD_PROCESS_PRIVATE,\n#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE\n\tPTHREAD_PROCESS_SHARED\n#define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED\n};\n\n/* Conditional variable handling.  */\n#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }\n\n/* Cleanup buffers */\nstruct _pthread_cleanup_buffer {\n\tvoid (*__routine) (void *);\t/* Function to call.  */\n\tvoid *__arg;\t\t/* Its argument.  */\n\tint __canceltype;\t/* Saved cancellation type. */\n\tstruct _pthread_cleanup_buffer *__prev;\t/* Chaining of cleanup functions.  */\n};\n\n/* Cancellation */\nenum {\n\tPTHREAD_CANCEL_ENABLE,\n#define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE\n\tPTHREAD_CANCEL_DISABLE\n#define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE\n};\nenum {\n\tPTHREAD_CANCEL_DEFERRED,\n#define PTHREAD_CANCEL_DEFERRED\tPTHREAD_CANCEL_DEFERRED\n\tPTHREAD_CANCEL_ASYNCHRONOUS\n#define PTHREAD_CANCEL_ASYNCHRONOUS\tPTHREAD_CANCEL_ASYNCHRONOUS\n};\n#define PTHREAD_CANCELED ((void *) -1)\n\n/* Single execution handling.  */\n#define PTHREAD_ONCE_INIT 0\n\n#ifdef __USE_XOPEN2K\n/* Value returned by 'pthread_barrier_wait' for one of the threads after\n   the required number of threads have called this function.\n   -1 is distinct from 0 and all errno constants */\n# define PTHREAD_BARRIER_SERIAL_THREAD -1\n#endif\n\n__BEGIN_DECLS\n/* Create a new thread, starting with execution of START-ROUTINE\n   getting passed ARG.  Creation attributed come from ATTR.  The new\n   handle is stored in *NEWTHREAD.  */\nextern int pthread_create(pthread_t * __restrict __newthread, const pthread_attr_t * __restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg)\n__THROWNL __nonnull((1, 3));\n\n/* Terminate calling thread.\n\n   The registered cleanup handlers are called via exception handling\n   so we cannot mark this function with __THROW.*/\nextern void pthread_exit(void *__retval) __attribute__ ((__noreturn__));\n\n/* Make calling thread wait for termination of the thread TH.  The\n   exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN\n   is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_join(pthread_t __th, void **__thread_return);\n\n#ifdef __USE_GNU\n/* Check whether thread TH has terminated.  If yes return the status of\n   the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */\nextern int pthread_tryjoin_np(pthread_t __th, void **__thread_return) __THROW;\n\n/* Make calling thread wait for termination of the thread TH, but only\n   until TIMEOUT.  The exit status of the thread is stored in\n   *THREAD_RETURN, if THREAD_RETURN is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_timedjoin_np(pthread_t __th, void **__thread_return, const struct timespec *__abstime);\n#endif\n\n/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.\n   The resources of TH will therefore be freed immediately when it\n   terminates, instead of waiting for another thread to perform PTHREAD_JOIN\n   on it.  */\nextern int pthread_detach(pthread_t __th) __THROW;\n\n/* Obtain the identifier of the current thread.  */\nextern pthread_t pthread_self(void)\n__THROW __attribute__ ((__const__));\n\n/* Compare two thread identifiers.  */\nextern int pthread_equal(pthread_t __thread1, pthread_t __thread2)\n__THROW __attribute__ ((__const__));\n\n/* Thread attribute handling.  */\n\n/* Initialize thread attribute *ATTR with default attributes\n   (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,\n    no user-provided stack).  */\nextern int pthread_attr_init(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy thread attribute *ATTR.  */\nextern int pthread_attr_destroy(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get detach state attribute.  */\nextern int pthread_attr_getdetachstate(const pthread_attr_t * __attr, int *__detachstate)\n__THROW __nonnull((1, 2));\n\n/* Set detach state attribute.  */\nextern int pthread_attr_setdetachstate(pthread_attr_t * __attr, int __detachstate)\n__THROW __nonnull((1));\n\n/* Get the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_getguardsize(const pthread_attr_t * __attr, size_t * __guardsize)\n__THROW __nonnull((1, 2));\n\n/* Set the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_setguardsize(pthread_attr_t * __attr, size_t __guardsize)\n__THROW __nonnull((1));\n\n/* Return in *PARAM the scheduling parameters of *ATTR.  */\nextern int pthread_attr_getschedparam(const pthread_attr_t * __restrict __attr, struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */\nextern int pthread_attr_setschedparam(pthread_attr_t * __restrict __attr, const struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Return in *POLICY the scheduling policy of *ATTR.  */\nextern int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict __attr, int *__restrict __policy)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling policy in *ATTR according to POLICY.  */\nextern int pthread_attr_setschedpolicy(pthread_attr_t * __attr, int __policy)\n__THROW __nonnull((1));\n\n/* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */\nextern int pthread_attr_getinheritsched(const pthread_attr_t * __restrict __attr, int *__restrict __inherit)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling inheritance mode in *ATTR according to INHERIT.  */\nextern int pthread_attr_setinheritsched(pthread_attr_t * __attr, int __inherit)\n__THROW __nonnull((1));\n\n/* Return in *SCOPE the scheduling contention scope of *ATTR.  */\nextern int pthread_attr_getscope(const pthread_attr_t * __restrict __attr, int *__restrict __scope)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling contention scope in *ATTR according to SCOPE.  */\nextern int pthread_attr_setscope(pthread_attr_t * __attr, int __scope)\n__THROW __nonnull((1));\n\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstackaddr(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr)\n__THROW __nonnull((1, 2)) __attribute_deprecated__;\n\n/* Set the starting address of the stack of the thread to be created.\n   Depending on whether the stack grows up or down the value must either\n   be higher or lower than all the address in the memory block.  The\n   minimal size of the block must be PTHREAD_STACK_MIN.  */\nextern int pthread_attr_setstackaddr(pthread_attr_t * __attr, void *__stackaddr)\n__THROW __nonnull((1)) __attribute_deprecated__;\n\n/* Return the currently used minimal stack size.  */\nextern int pthread_attr_getstacksize(const pthread_attr_t * __restrict __attr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2));\n\n/* Add information about the minimum stack size needed for the thread\n   to be started.  This size must never be less than PTHREAD_STACK_MIN\n   and must also not exceed the system limits.  */\nextern int pthread_attr_setstacksize(pthread_attr_t * __attr, size_t __stacksize)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstack(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2, 3));\n\n/* The following two interfaces are intended to replace the last two.  They\n   require setting the address as well as the size since only setting the\n   address will make the implementation on some architectures impossible.  */\nextern int pthread_attr_setstack(pthread_attr_t * __attr, void *__stackaddr, size_t __stacksize)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_GNU\n/* Thread created with attribute ATTR will be limited to run only on\n   the processors represented in CPUSET.  */\nextern int pthread_attr_setaffinity_np(pthread_attr_t * __attr, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get bit set in CPUSET representing the processors threads created with\n   ATTR can run on.  */\nextern int pthread_attr_getaffinity_np(const pthread_attr_t * __attr, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get the default attributes used by pthread_create in this process.  */\nextern int pthread_getattr_default_np(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Set the default attributes to be used by pthread_create in this\n   process.  */\nextern int pthread_setattr_default_np(const pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Initialize thread attribute *ATTR with attributes corresponding to the\n   already running thread TH.  It shall be called on uninitialized ATTR\n   and destroyed with pthread_attr_destroy when no longer needed.  */\nextern int pthread_getattr_np(pthread_t __th, pthread_attr_t * __attr)\n__THROW __nonnull((2));\n#endif\n\n/* Functions for scheduling control.  */\n\n/* Set the scheduling parameters for TARGET_THREAD according to POLICY\n   and *PARAM.  */\nextern int pthread_setschedparam(pthread_t __target_thread, int __policy, const struct sched_param *__param)\n__THROW __nonnull((3));\n\n/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */\nextern int pthread_getschedparam(pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param)\n__THROW __nonnull((2, 3));\n\n/* Set the scheduling priority for TARGET_THREAD.  */\nextern int pthread_setschedprio(pthread_t __target_thread, int __prio) __THROW;\n\n#ifdef __USE_GNU\n/* Get thread name visible in the kernel and its interfaces.  */\nextern int pthread_getname_np(pthread_t __target_thread, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Set thread name visible in the kernel and its interfaces.  */\nextern int pthread_setname_np(pthread_t __target_thread, const char *__name)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_UNIX98\n/* Determine level of concurrency.  */\nextern int pthread_getconcurrency(void) __THROW;\n\n/* Set new concurrency level to LEVEL.  */\nextern int pthread_setconcurrency(int __level) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Yield the processor to another thread or process.\n   This function is similar to the POSIX `sched_yield' function but\n   might be differently implemented in the case of a m-on-n thread\n   implementation.  */\nextern int pthread_yield(void) __THROW;\n\n/* Limit specified thread TH to run only on the processors represented\n   in CPUSET.  */\nextern int pthread_setaffinity_np(pthread_t __th, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n\n/* Get bit set in CPUSET representing the processors TH can run on.  */\nextern int pthread_getaffinity_np(pthread_t __th, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n#endif\n\n/* Functions for handling initialization.  */\n\n/* Guarantee that the initialization function INIT_ROUTINE will be called\n   only once, even if pthread_once is executed several times with the\n   same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or\n   extern variable initialized to PTHREAD_ONCE_INIT.\n\n   The initialization functions might throw exception which is why\n   this function is not marked with __THROW.  */\nextern int pthread_once(pthread_once_t * __once_control, void (*__init_routine) (void)) __nonnull((1, 2));\n\n/* Functions for handling cancellation.\n\n   Note that these functions are explicitly not marked to not throw an\n   exception in C++ code.  If cancellation is implemented by unwinding\n   this is necessary to have the compiler generate the unwind information.  */\n\n/* Set cancelability state of current thread to STATE, returning old\n   state in *OLDSTATE if OLDSTATE is not NULL.  */\nextern int pthread_setcancelstate(int __state, int *__oldstate);\n\n/* Set cancellation state of current thread to TYPE, returning the old\n   type in *OLDTYPE if OLDTYPE is not NULL.  */\nextern int pthread_setcanceltype(int __type, int *__oldtype);\n\n/* Cancel THREAD immediately or at the next possibility.  */\nextern int pthread_cancel(pthread_t __th);\n\n/* Test for pending cancellation for the current thread and terminate\n   the thread as per pthread_exit(PTHREAD_CANCELED) if it has been\n   cancelled.  */\nextern void pthread_testcancel(void);\n\n/* Cancellation handling with integration into exception handling.  */\n\ntypedef struct {\n\tstruct {\n\t\t__jmp_buf __cancel_jmp_buf;\n\t\tint __mask_was_saved;\n\t} __cancel_jmp_buf[1];\n\tvoid *__pad[4];\n} __pthread_unwind_buf_t __attribute__ ((__aligned__));\n\n/* No special attributes by default.  */\n#ifndef __cleanup_fct_attribute\n# define __cleanup_fct_attribute\n#endif\n\n/* Structure to hold the cleanup handler information.  */\nstruct __pthread_cleanup_frame {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n};\n\n#if defined __GNUC__ && defined __EXCEPTIONS\n# ifdef __cplusplus\n/* Class to handle cancellation handler invocation.  */\nclass __pthread_cleanup_class {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n\n public:\n\t__pthread_cleanup_class(void (*__fct) (void *), void *__arg)\n\t:__cancel_routine(__fct), __cancel_arg(__arg), __do_it(1)\n{\n} ~__pthread_cleanup_class() {\n\t\tif (__do_it)\n\t\t\t__cancel_routine(__cancel_arg);\n}\nvoid __setdoit(int __newval) {\n\t__do_it = __newval;\n}\nvoid __defer() {\n\tpthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &__cancel_type);\n}\nvoid __restore() const {\n\tpthread_setcanceltype(__cancel_type, 0);\n}};\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#  define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg)\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#  define pthread_cleanup_pop(execute) \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#  ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#   define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg);\t\t\t      \\\n    __clframe.__defer ()\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#   define pthread_cleanup_pop_restore_np(execute) \\\n    __clframe.__restore ();\t\t\t\t\t\t      \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n#  endif\n# else\n/* Function called to call the cleanup handler.  As an extern inline\n   function the compiler is free to decide inlining the change when\n   needed or fall back on the copy which must exist somewhere\n   else.  */\n__extern_inline void __pthread_cleanup_routine(struct __pthread_cleanup_frame *__frame)\n{\n\tif (__frame->__do_it)\n\t\t__frame->__cancel_routine(__frame->__cancel_arg);\n}\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#  define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t \t      \\\n\t  .__do_it = 1 };\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#  define pthread_cleanup_pop(execute) \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#  ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#   define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t\t      \\\n\t  .__do_it = 1 };\t\t\t\t\t\t      \\\n    (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,\t\t      \\\n\t\t\t\t  &__clframe.__cancel_type)\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#   define pthread_cleanup_pop_restore_np(execute) \\\n    (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);\t      \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n#  endif\n# endif\n#else\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n# define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel (&__cancel_buf);\t\t\t\t      \\\n    do {\nextern void __pthread_register_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n# define pthread_cleanup_pop(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel (&__cancel_buf);\t\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n# ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#  define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel_defer (&__cancel_buf);\t\t\t      \\\n    do {\nextern void __pthread_register_cancel_defer(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#  define pthread_cleanup_pop_restore_np(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel_restore (&__cancel_buf);\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel_restore(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n# endif\n\n/* Internal interface to initiate cleanup.  */\nextern void __pthread_unwind_next(__pthread_unwind_buf_t * __buf)\n__cleanup_fct_attribute __attribute__ ((__noreturn__))\n# ifndef SHARED\n    __attribute__ ((__weak__))\n# endif\n    ;\n#endif\n\n/* Function used in the macros.  */\nstruct __jmp_buf_tag;\nextern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask) __THROWNL;\n\n/* Mutex handling.  */\n\n/* Initialize a mutex.  */\nextern int pthread_mutex_init(pthread_mutex_t * __mutex, const pthread_mutexattr_t * __mutexattr)\n__THROW __nonnull((1));\n\n/* Destroy a mutex.  */\nextern int pthread_mutex_destroy(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n\n/* Try locking a mutex.  */\nextern int pthread_mutex_trylock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Lock a mutex.  */\nextern int pthread_mutex_lock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Wait until lock becomes available, or specified time passes. */\nextern int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n#endif\n\n/* Unlock a mutex.  */\nextern int pthread_mutex_unlock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Get the priority ceiling of MUTEX.  */\nextern int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the priority ceiling of MUTEX to PRIOCEILING, return old\n   priority ceiling value in *OLD_CEILING.  */\nextern int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict __mutex, int __prioceiling, int *__restrict __old_ceiling)\n__THROW __nonnull((1, 3));\n\n#ifdef __USE_XOPEN2K8\n/* Declare the state protected by MUTEX as consistent.  */\nextern int pthread_mutex_consistent(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n# ifdef __USE_GNU\nextern int pthread_mutex_consistent_np(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n# endif\n#endif\n\n/* Functions for handling mutex attributes.  */\n\n/* Initialize mutex attribute object ATTR with default attributes\n   (kind is PTHREAD_MUTEX_TIMED_NP).  */\nextern int pthread_mutexattr_init(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy mutex attribute object ATTR.  */\nextern int pthread_mutexattr_destroy(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setpshared(pthread_mutexattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n/* Return in *KIND the mutex kind attribute in *ATTR.  */\nextern int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict __attr, int *__restrict __kind)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,\n   PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or\n   PTHREAD_MUTEX_DEFAULT).  */\nextern int pthread_mutexattr_settype(pthread_mutexattr_t * __attr, int __kind)\n__THROW __nonnull((1));\n#endif\n\n/* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */\nextern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either\n   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */\nextern int pthread_mutexattr_setprotocol(pthread_mutexattr_t * __attr, int __protocol)\n__THROW __nonnull((1));\n\n/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */\nextern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */\nextern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t * __attr, int __prioceiling)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getrobust(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n# ifdef __USE_GNU\nextern int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n# endif\n\n/* Set the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setrobust(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n# ifdef __USE_GNU\nextern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n# endif\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Functions for handling read-write locks.  */\n\n/* Initialize read-write lock RWLOCK using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, const pthread_rwlockattr_t * __restrict __attr)\n__THROW __nonnull((1));\n\n/* Destroy read-write lock RWLOCK.  */\nextern int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock)\n__THROW __nonnull((1));\n\n/* Acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n# ifdef __USE_XOPEN2K\n/* Try to acquire read lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n# endif\n\n/* Acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n# ifdef __USE_XOPEN2K\n/* Try to acquire write lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n# endif\n\n/* Unlock RWLOCK.  */\nextern int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Functions for handling read-write lock attributes.  */\n\n/* Initialize attribute object ATTR with default values.  */\nextern int pthread_rwlockattr_init(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy attribute object ATTR.  */\nextern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Return current setting of process-shared attribute of ATTR in PSHARED.  */\nextern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set process-shared attribute of ATTR to PSHARED.  */\nextern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n/* Return current setting of reader/writer preference.  */\nextern int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref)\n__THROW __nonnull((1, 2));\n\n/* Set reader/write preference.  */\nextern int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t * __attr, int __pref)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling conditional variables.  */\n\n/* Initialize condition variable COND using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_cond_init(pthread_cond_t * __restrict __cond, const pthread_condattr_t * __restrict __cond_attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable COND.  */\nextern int pthread_cond_destroy(pthread_cond_t * __cond)\n__THROW __nonnull((1));\n\n/* Wake up one thread waiting for condition variable COND.  */\nextern int pthread_cond_signal(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wake up all threads waiting for condition variables COND.  */\nextern int pthread_cond_broadcast(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wait for condition variable COND to be signaled or broadcast.\n   MUTEX is assumed to be locked before.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_wait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex) __nonnull((1, 2));\n\n/* Wait for condition variable COND to be signaled or broadcast until\n   ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an\n   absolute time specification; zero is the beginning of the epoch\n   (00:00:00 GMT, January 1, 1970).\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_timedwait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime) __nonnull((1, 2, 3));\n\n/* Functions for handling condition variable attributes.  */\n\n/* Initialize condition variable attribute ATTR.  */\nextern int pthread_condattr_init(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable attribute ATTR.  */\nextern int pthread_condattr_destroy(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_getpshared(const pthread_condattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_setpshared(pthread_condattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_getclock(const pthread_condattr_t * __restrict __attr, __clockid_t * __restrict __clock_id)\n__THROW __nonnull((1, 2));\n\n/* Set the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_setclock(pthread_condattr_t * __attr, __clockid_t __clock_id)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Functions to handle spinlocks.  */\n\n/* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can\n   be shared between different processes.  */\nextern int pthread_spin_init(pthread_spinlock_t * __lock, int __pshared)\n__THROW __nonnull((1));\n\n/* Destroy the spinlock LOCK.  */\nextern int pthread_spin_destroy(pthread_spinlock_t * __lock)\n__THROW __nonnull((1));\n\n/* Wait until spinlock LOCK is retrieved.  */\nextern int pthread_spin_lock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Try to lock spinlock LOCK.  */\nextern int pthread_spin_trylock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Release spinlock LOCK.  */\nextern int pthread_spin_unlock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Functions to handle barriers.  */\n\n/* Initialize BARRIER with the attributes in ATTR.  The barrier is\n   opened when COUNT waiters arrived.  */\nextern int pthread_barrier_init(pthread_barrier_t * __restrict __barrier, const pthread_barrierattr_t * __restrict __attr, unsigned int __count)\n__THROW __nonnull((1));\n\n/* Destroy a previously dynamically initialized barrier BARRIER.  */\nextern int pthread_barrier_destroy(pthread_barrier_t * __barrier)\n__THROW __nonnull((1));\n\n/* Wait on barrier BARRIER.  */\nextern int pthread_barrier_wait(pthread_barrier_t * __barrier)\n__THROWNL __nonnull((1));\n\n/* Initialize barrier attribute ATTR.  */\nextern int pthread_barrierattr_init(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy previously dynamically initialized barrier attribute ATTR.  */\nextern int pthread_barrierattr_destroy(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_setpshared(pthread_barrierattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling thread-specific data.  */\n\n/* Create a key value identifying a location in the thread-specific\n   data area.  Each thread maintains a distinct thread-specific data\n   area.  DESTR_FUNCTION, if non-NULL, is called with the value\n   associated to that key when the key is destroyed.\n   DESTR_FUNCTION is not called if the value associated is NULL when\n   the key is destroyed.  */\nextern int pthread_key_create(pthread_key_t * __key, void (*__destr_function) (void *))\n__THROW __nonnull((1));\n\n/* Destroy KEY.  */\nextern int pthread_key_delete(pthread_key_t __key) __THROW;\n\n/* Return current value of the thread-specific data slot identified by KEY.  */\nextern void *pthread_getspecific(pthread_key_t __key) __THROW;\n\n/* Store POINTER in the thread-specific data slot identified by KEY. */\nextern int pthread_setspecific(pthread_key_t __key, const void *__pointer) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Get ID of CPU-time clock for thread THREAD_ID.  */\nextern int pthread_getcpuclockid(pthread_t __thread_id, __clockid_t * __clock_id)\n__THROW __nonnull((2));\n#endif\n\n/* Install handlers to be called when a new process is created with FORK.\n   The PREPARE handler is called in the parent process just before performing\n   FORK. The PARENT handler is called in the parent process just after FORK.\n   The CHILD handler is called in the child process.  Each of the three\n   handlers can be NULL, meaning that no handler needs to be called at that\n   point.\n   PTHREAD_ATFORK can be called several times, in which case the PREPARE\n   handlers are called in LIFO order (last added with PTHREAD_ATFORK,\n   first called before FORK), and the PARENT and CHILD handlers are called\n   in FIFO (first added, first called).  */\n\nextern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n/* Optimizations.  */\n__extern_inline int __NTH(pthread_equal(pthread_t __thread1, pthread_t __thread2))\n{\n\treturn __thread1 == __thread2;\n}\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pthread.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/pwd.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.2 User Database Access\t<pwd.h>\n */\n\n#ifndef\t_PWD_H\n#define\t_PWD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\n\n/* The passwd structure.  */\nstruct passwd {\n\tchar *pw_name;\t\t/* Username.  */\n\tchar *pw_passwd;\t/* Password.  */\n\t__uid_t pw_uid;\t\t/* User ID.  */\n\t__gid_t pw_gid;\t\t/* Group ID.  */\n\tchar *pw_gecos;\t\t/* Real name.  */\n\tchar *pw_dir;\t\t/* Home directory.  */\n\tchar *pw_shell;\t\t/* Shell program.  */\n};\n\n#ifdef __USE_MISC\n# define __need_FILE\n# include <stdio.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setpwent(void);\n\n/* Close the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endpwent(void);\n\n/* Read an entry from the password-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read an entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct passwd *fgetpwent(FILE * __stream) __nonnull((1));\n\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putpwent(const struct passwd *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching user ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwuid(__uid_t __uid);\n\n/* Search for an entry with a matching username.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwnam(const char *__name) __nonnull((1));\n\n#ifdef __USE_POSIX\n\n# ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#  define NSS_BUFLEN_PASSWD\t1024\n# endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.  */\n\n# ifdef __USE_MISC\n/* This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpwent_r(struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 4));\n# endif\n\nextern int getpwuid_r(__uid_t __uid, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((2, 3, 5));\n\nextern int getpwnam_r(const char *__restrict __name, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n\n# ifdef\t__USE_MISC\n/* Read an entry from STREAM.  This function is not standardized and\n   probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetpwent_r(FILE * __restrict __stream, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n# endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef __USE_GNU\n/* Re-construct the password-file line for the given uid\n   in the given buffer.  This knows the format that the caller\n   will expect, but this need not be the format of the password file.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpw(__uid_t __uid, char *__buffer);\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pwd.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/rpc/netdb.h",
    "content": "/* @(#)netdb.h\t2.1 88/07/29 3.9 RPCSRC */\n/*\n * Copyright (c) 2010, Oracle America, Inc.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials\n *       provided with the distribution.\n *     * Neither the name of the \"Oracle America, Inc.\" nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Cleaned up for GNU C library roland@gnu.ai.mit.edu:\n   added multiple inclusion protection and use of <sys/cdefs.h>.\n   In GNU this file is #include'd by <netdb.h>.  */\n\n#ifndef _RPC_NETDB_H\n#define _RPC_NETDB_H\t1\n\n#include <features.h>\n\n#define __need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS struct rpcent {\n\tchar *r_name;\t\t/* Name of server for this rpc program.  */\n\tchar **r_aliases;\t/* Alias list.  */\n\tint r_number;\t\t/* RPC program number.  */\n};\n\nextern void setrpcent(int __stayopen) __THROW;\nextern void endrpcent(void) __THROW;\nextern struct rpcent *getrpcbyname(const char *__name) __THROW;\nextern struct rpcent *getrpcbynumber(int __number) __THROW;\nextern struct rpcent *getrpcent(void) __THROW;\n\n#ifdef __USE_MISC\nextern int getrpcbyname_r(const char *__name, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcbynumber_r(int __number, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcent_r(struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* rpc/netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sched.h",
    "content": "/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SCHED_H\n#define\t_SCHED_H\t1\n\n#include <features.h>\n\n/* Get type definitions.  */\n#include <bits/types.h>\n\n#define __need_size_t\n#include <stddef.h>\n\n#ifdef __USE_XOPEN2K\n# define __need_time_t\n# define __need_timespec\n#endif\n#include <time.h>\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n/* Get system specific constant and data structure definitions.  */\n#include <bits/sched.h>\n/* Define the real names for the elements of `struct sched_param'.  */\n#define sched_priority\t__sched_priority\n\n__BEGIN_DECLS\n/* Set scheduling parameters for a process.  */\nextern int sched_setparam(__pid_t __pid, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling parameters for a particular process.  */\nextern int sched_getparam(__pid_t __pid, struct sched_param *__param) __THROW;\n\n/* Set scheduling algorithm and/or parameters for a process.  */\nextern int sched_setscheduler(__pid_t __pid, int __policy, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling algorithm for a particular purpose.  */\nextern int sched_getscheduler(__pid_t __pid) __THROW;\n\n/* Yield the processor.  */\nextern int sched_yield(void) __THROW;\n\n/* Get maximum priority value for a scheduler.  */\nextern int sched_get_priority_max(int __algorithm) __THROW;\n\n/* Get minimum priority value for a scheduler.  */\nextern int sched_get_priority_min(int __algorithm) __THROW;\n\n/* Get the SCHED_RR interval for the named process.  */\nextern int sched_rr_get_interval(__pid_t __pid, struct timespec *__t) __THROW;\n\n#ifdef __USE_GNU\n/* Access macros for `cpu_set'.  */\n# define CPU_SETSIZE __CPU_SETSIZE\n# define CPU_SET(cpu, cpusetp)\t __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)\n# define CPU_CLR(cpu, cpusetp)\t __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)\n# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \\\n\t\t\t\t\t\tcpusetp)\n# define CPU_ZERO(cpusetp)\t __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)\n# define CPU_COUNT(cpusetp)\t __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)\n\n# define CPU_SET_S(cpu, setsize, cpusetp)   __CPU_SET_S (cpu, setsize, cpusetp)\n# define CPU_CLR_S(cpu, setsize, cpusetp)   __CPU_CLR_S (cpu, setsize, cpusetp)\n# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \\\n\t\t\t\t\t\t\t   cpusetp)\n# define CPU_ZERO_S(setsize, cpusetp)\t    __CPU_ZERO_S (setsize, cpusetp)\n# define CPU_COUNT_S(setsize, cpusetp)\t    __CPU_COUNT_S (setsize, cpusetp)\n\n# define CPU_EQUAL(cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)\n# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)\n\n# define CPU_AND(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)\n# define CPU_OR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)\n# define CPU_XOR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)\n# define CPU_AND_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, &)\n# define CPU_OR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, |)\n# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)\n\n# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)\n# define CPU_ALLOC(count) __CPU_ALLOC (count)\n# define CPU_FREE(cpuset) __CPU_FREE (cpuset)\n\n/* Set the CPU affinity for a task */\nextern int sched_setaffinity(__pid_t __pid, size_t __cpusetsize, const cpu_set_t * __cpuset) __THROW;\n\n/* Get the CPU affinity for a task */\nextern int sched_getaffinity(__pid_t __pid, size_t __cpusetsize, cpu_set_t * __cpuset) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sched.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/setjmp.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.13 Nonlocal jumps\t<setjmp.h>\n */\n\n#ifndef\t_SETJMP_H\n#define\t_SETJMP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/setjmp.h>\t/* Get `__jmp_buf'.  */\n#include <bits/sigset.h>\t/* Get `__sigset_t'.  */\n/* Calling environment, plus possibly a saved signal mask.  */\n    struct __jmp_buf_tag {\n\t/* NOTE: The machine-dependent definitions of `__sigsetjmp'\n\t   assume that a `jmp_buf' begins with a `__jmp_buf' and that\n\t   `__mask_was_saved' follows it.  Do not move these members\n\t   or add others before it.  */\n\t__jmp_buf __jmpbuf;\t/* Calling environment.  */\n\tint __mask_was_saved;\t/* Saved the signal mask?  */\n\t__sigset_t __saved_mask;\t/* Saved signal mask.  */\n};\n\n__BEGIN_NAMESPACE_STD typedef struct __jmp_buf_tag jmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the signal mask.\n   Return 0.  */\nextern int setjmp(jmp_buf __env) __THROWNL;\n\n__END_NAMESPACE_STD\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.\n   This is the internal name for `sigsetjmp'.  */\nextern int __sigsetjmp(struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;\n\n/* Store the calling environment in ENV, not saving the signal mask.\n   Return 0.  */\nextern int _setjmp(struct __jmp_buf_tag __env[1]) __THROWNL;\n\n/* Do not save the signal mask.  This is equivalent to the `_setjmp'\n   BSD function.  */\n#define setjmp(env)\t_setjmp (env)\n\n__BEGIN_NAMESPACE_STD\n/* Jump to the environment saved in ENV, making the\n   `setjmp' call there return VAL, or 1 if VAL is 0.  */\nextern void longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n\n__END_NAMESPACE_STD\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Same.  Usually `_longjmp' is used with `_setjmp', which does not save\n   the signal mask.  But it is how ENV was saved that determines whether\n   `longjmp' restores the mask; `_longjmp' is just an alias.  */\nextern void _longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\n\n#ifdef\t__USE_POSIX\n/* Use the same type for `jmp_buf' and `sigjmp_buf'.\n   The `__mask_was_saved' flag determines whether\n   or not `longjmp' will restore the signal mask.  */\ntypedef struct __jmp_buf_tag sigjmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.  */\n# define sigsetjmp(env, savemask)\t__sigsetjmp (env, savemask)\n\n/* Jump to the environment saved in ENV, making the\n   sigsetjmp call there return VAL, or 1 if VAL is 0.\n   Restore the signal mask if that sigsetjmp call saved it.\n   This is just an alias `longjmp'.  */\nextern void siglongjmp(sigjmp_buf __env, int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\t\t\t\t/* Use POSIX.  */\n\n/* Define helper functions to catch unsafe code.  */\n#if __USE_FORTIFY_LEVEL > 0\n# include <bits/setjmp2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* setjmp.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/signal.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.14 Signal handling <signal.h>\n */\n\n#ifndef\t_SIGNAL_H\n\n#if !defined __need_sig_atomic_t && !defined __need_sigset_t\n# define _SIGNAL_H\n#endif\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/sigset.h>\t/* __sigset_t, __sig_atomic_t.  */\n/* An integral type that can be modified atomically, without the\n   possibility of a signal arriving in the middle of the operation.  */\n#if defined __need_sig_atomic_t || defined _SIGNAL_H\n# ifndef __sig_atomic_t_defined\n#  define __sig_atomic_t_defined\n__BEGIN_NAMESPACE_STD typedef __sig_atomic_t sig_atomic_t;\n__END_NAMESPACE_STD\n# endif\n# undef __need_sig_atomic_t\n#endif\n#if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)\n# ifndef __sigset_t_defined\n#  define __sigset_t_defined\ntypedef __sigset_t sigset_t;\n# endif\n# undef __need_sigset_t\n#endif\n\n#ifdef _SIGNAL_H\n\n#include <bits/types.h>\n#include <bits/signum.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n#endif\n#ifdef __USE_XOPEN\n# endif\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\t\t\t\t/* Unix98 */\n\n#ifdef __USE_POSIX199309\n/* We need `struct timespec' later on.  */\n# define __need_timespec\n# include <time.h>\n#endif\n\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\n/* Get the `siginfo_t' type plus the needed symbols.  */\n# include <bits/siginfo.h>\n#endif\n\n/* Type of a signal handler.  */\ntypedef void (*__sighandler_t) (int);\n\n/* The X/Open definition of `signal' specifies the SVID semantic.  Use\n   the additional function `sysv_signal' when X/Open compatibility is\n   requested.  */\nextern __sighandler_t __sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#ifdef __USE_GNU\nextern __sighandler_t sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Set the handler for the signal SIG to HANDLER, returning the old\n   handler, or SIG_ERR on error.\n   By default `signal' has the BSD semantic.  */\n__BEGIN_NAMESPACE_STD\n#ifdef __USE_MISC\nextern __sighandler_t signal(int __sig, __sighandler_t __handler) __THROW;\n#else\n/* Make sure the used `signal' implementation is the SVID version. */\n# ifdef __REDIRECT_NTH\nextern __sighandler_t __REDIRECT_NTH(signal, (int __sig, __sighandler_t __handler), __sysv_signal);\n# else\n#  define signal __sysv_signal\n# endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_XOPEN\n/* The X/Open definition of `signal' conflicts with the BSD version.\n   So they defined another function `bsd_signal'.  */\nextern __sighandler_t bsd_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Send signal SIG to process number PID.  If PID is zero,\n   send SIG to all processes in the current process's process group.\n   If PID is < -1, send SIG to all processes in process group - PID.  */\n#ifdef __USE_POSIX\nextern int kill(__pid_t __pid, int __sig) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Send SIG to all processes in process group PGRP.\n   If PGRP is zero, send SIG to all processes in\n   the current process's process group.  */\nextern int killpg(__pid_t __pgrp, int __sig) __THROW;\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n__BEGIN_NAMESPACE_STD\n/* Raise signal SIG, i.e., send SIG to yourself.  */\nextern int raise(int __sig) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* SVID names for the same things.  */\nextern __sighandler_t ssignal(int __sig, __sighandler_t __handler) __THROW;\nextern int gsignal(int __sig) __THROW;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_XOPEN2K8\n/* Print a message describing the meaning of the given signal number.  */\nextern void psignal(int __sig, const char *__s);\n\n/* Print a message describing the meaning of the given signal information.  */\nextern void psiginfo(const siginfo_t * __pinfo, const char *__s);\n#endif\t\t\t\t/* POSIX 2008.  */\n\n/* The `sigpause' function in X/Open defines the argument as the\n   signal number.  This requires redirecting to another function\n   because the default version in glibc uses an old BSD interface.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n#ifdef __USE_XOPEN\n# ifdef __GNUC__\nextern int sigpause(int __sig) __asm__(\"__xpg_sigpause\");\n# else\nextern int __sigpause(int __sig_or_mask, int __is_sig);\n/* Remove a signal from the signal mask and suspend the process.  */\n#  define sigpause(sig) __sigpause ((sig), 1)\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* None of the following functions should be used anymore.  They are here\n   only for compatibility.  A single word (`int') is not guaranteed to be\n   enough to hold a complete signal mask and therefore these functions\n   simply do not work in many situations.  Use `sigprocmask' instead.  */\n\n/* Compute mask for signal SIG.  */\n# define sigmask(sig)\t__sigmask(sig)\n\n/* Block signals in MASK, returning the old mask.  */\nextern int sigblock(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Set the mask of blocked signals to MASK, returning the old mask.  */\nextern int sigsetmask(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Return currently selected signal mask.  */\nextern int siggetmask(void)\n__THROW __attribute_deprecated__;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_MISC\n# define NSIG\t_NSIG\n#endif\n\n#ifdef __USE_GNU\ntypedef __sighandler_t sighandler_t;\n#endif\n\n/* 4.4 BSD uses the name `sig_t' for this.  */\n#ifdef __USE_MISC\ntypedef __sighandler_t sig_t;\n#endif\n\n#ifdef __USE_POSIX\n\n/* Clear all signals from SET.  */\nextern int sigemptyset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Set all signals in SET.  */\nextern int sigfillset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Add SIGNO to SET.  */\nextern int sigaddset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Remove SIGNO from SET.  */\nextern int sigdelset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Return 1 if SIGNO is in SET, 0 if not.  */\nextern int sigismember(const sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n# ifdef __USE_GNU\n/* Return non-empty value is SET is not empty.  */\nextern int sigisemptyset(const sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Build new signal set by combining the two inputs set using logical AND.  */\nextern int sigandset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n\n/* Build new signal set by combining the two inputs set using logical OR.  */\nextern int sigorset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n# endif\t\t\t\t/* GNU */\n\n/* Get the system-specific definitions of `struct sigaction'\n   and the `SA_*' and `SIG_*'. constants.  */\n# include <bits/sigaction.h>\n\n/* Get and/or change the set of blocked signals.  */\nextern int sigprocmask(int __how, const sigset_t * __restrict __set, sigset_t * __restrict __oset) __THROW;\n\n/* Change the set of blocked signals to SET,\n   wait until a signal arrives, and restore the set of blocked signals.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigsuspend(const sigset_t * __set) __nonnull((1));\n\n/* Get and/or set the action for signal SIG.  */\nextern int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __THROW;\n\n/* Put in SET all signals that are blocked and waiting to be delivered.  */\nextern int sigpending(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Select any of pending signals from SET or wait for any to arrive.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwait(const sigset_t * __restrict __set, int *__restrict __sig) __nonnull((1, 2));\n\n# ifdef __USE_POSIX199309\n/* Select any of pending signals from SET and place information in INFO.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwaitinfo(const sigset_t * __restrict __set, siginfo_t * __restrict __info) __nonnull((1));\n\n/* Select any of pending signals from SET and place information in INFO.\n   Wait the time specified by TIMEOUT if no signal is pending.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigtimedwait(const sigset_t * __restrict __set, siginfo_t * __restrict __info, const struct timespec *__restrict __timeout) __nonnull((1));\n\n/* Send signal SIG to the process PID.  Associate data in VAL with the\n   signal.  */\nextern int sigqueue(__pid_t __pid, int __sig, const union sigval __val) __THROW;\n# endif\t\t\t\t/* Use POSIX 199306.  */\n\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n\n/* Names of the signals.  This variable exists only for compatibility.\n   Use `strsignal' instead (see <string.h>).  */\nextern const char *const _sys_siglist[_NSIG];\nextern const char *const sys_siglist[_NSIG];\n\n/* Get machine-dependent `struct sigcontext' and signal subcodes.  */\n# include <bits/sigcontext.h>\n\n/* Restore the state saved in SCP.  */\nextern int sigreturn(struct sigcontext *__scp) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n# define __need_size_t\n# include <stddef.h>\n\n/* If INTERRUPT is nonzero, make signal SIG interrupt system calls\n   (causing them to fail with EINTR); if INTERRUPT is zero, make system\n   calls be restarted after signal SIG.  */\nextern int siginterrupt(int __sig, int __interrupt) __THROW;\n\n# include <bits/sigstack.h>\n# if defined __USE_XOPEN || defined __USE_XOPEN2K8\n/* This will define `ucontext_t' and `mcontext_t'.  */\n#  include <sys/ucontext.h>\n# endif\n\n/* Run signals handlers on the stack specified by SS (if not NULL).\n   If OSS is not NULL, it is filled in with the old signal stack status.\n   This interface is obsolete and on many platform not implemented.  */\nextern int sigstack(struct sigstack *__ss, struct sigstack *__oss)\n__THROW __attribute_deprecated__;\n\n/* Alternate signal handler stack interface.\n   This interface should always be preferred over `sigstack'.  */\nextern int sigaltstack(const struct sigaltstack *__restrict __ss, struct sigaltstack *__restrict __oss) __THROW;\n\n#endif\t\t\t\t/* Use POSIX.1-2008 or X/Open Unix.  */\n\n#ifdef __USE_XOPEN_EXTENDED\n/* Simplified interface for signal management.  */\n\n/* Add SIG to the calling process' signal mask.  */\nextern int sighold(int __sig) __THROW;\n\n/* Remove SIG from the calling process' signal mask.  */\nextern int sigrelse(int __sig) __THROW;\n\n/* Set the disposition of SIG to SIG_IGN.  */\nextern int sigignore(int __sig) __THROW;\n\n/* Set the disposition of SIG.  */\nextern __sighandler_t sigset(int __sig, __sighandler_t __disp) __THROW;\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Some of the functions for handling signals in threaded programs must\n   be defined here.  */\n# include <bits/pthreadtypes.h>\n# include <bits/sigthread.h>\n#endif\t\t\t\t/* use Unix98 */\n\n/* The following functions are used internally in the C library and in\n   other code which need deep insights.  */\n\n/* Return number of available real-time signal with highest priority.  */\nextern int __libc_current_sigrtmin(void) __THROW;\n/* Return number of available real-time signal with lowest priority.  */\nextern int __libc_current_sigrtmax(void) __THROW;\n\n#endif\t\t\t\t/* signal.h  */\n\n__END_DECLS\n#endif\t\t\t\t/* not signal.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/stdc-predef.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STDC_PREDEF_H\n#define\t_STDC_PREDEF_H\t1\n\n/* This header is separate from features.h so that the compiler can\n   include it implicitly at the start of every compilation.  It must\n   not itself include <features.h> or any other header that includes\n   <features.h> because the implicit include comes before any feature\n   test macros that may be defined in a source file before it first\n   explicitly includes a system header.  GCC knows the name of this\n   header in order to preinclude it.  */\n\n/* glibc's intent is to support the IEC 559 math functionality, real\n   and complex.  If the GCC (4.9 and later) predefined macros\n   specifying compiler intent are available, use them to determine\n   whether the overall intent is to support these features; otherwise,\n   presume an older compiler has intent to support these features and\n   define these macros by default.  */\n\n#ifdef __GCC_IEC_559\n# if __GCC_IEC_559 > 0\n#  define __STDC_IEC_559__\t\t1\n# endif\n#else\n# define __STDC_IEC_559__\t\t1\n#endif\n\n#ifdef __GCC_IEC_559_COMPLEX\n# if __GCC_IEC_559_COMPLEX > 0\n#  define __STDC_IEC_559_COMPLEX__\t1\n# endif\n#else\n# define __STDC_IEC_559_COMPLEX__\t1\n#endif\n\n/* wchar_t uses Unicode 7.0.0.  Version 7.0 of the Unicode Standard is\n   synchronized with ISO/IEC 10646:2012, plus Amendments 1 (published\n   on April, 2013) and 2 (not yet published as of February, 2015).\n   Additionally, it includes the accelerated publication of U+20BD\n   RUBLE SIGN.  Therefore Unicode 7.0.0 is between 10646:2012 and\n   10646:2014, and so we use the date ISO/IEC 10646:2012 Amd.1 was\n   published.  */\n#define __STDC_ISO_10646__\t\t201304L\n\n/* We do not support C11 <threads.h>.  */\n#define __STDC_NO_THREADS__\t\t1\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/stdint.h",
    "content": "/* Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.18 Integer types <stdint.h>\n */\n\n#ifndef _STDINT_H\n#define _STDINT_H\t1\n\n#include <features.h>\n#include <bits/wchar.h>\n#include <bits/wordsize.h>\n\n/* Exact integral types.  */\n\n/* Signed.  */\n\n/* There is some amount of overlap with <sys/types.h> as known by inet code */\n#ifndef __int8_t_defined\n# define __int8_t_defined\ntypedef signed char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\n# if __WORDSIZE == 64\ntypedef long int int64_t;\n# else\n__extension__ typedef long long int int64_t;\n# endif\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint8_t;\ntypedef unsigned short int uint16_t;\n#ifndef __uint32_t_defined\ntypedef unsigned int uint32_t;\n# define __uint32_t_defined\n#endif\n#if __WORDSIZE == 64\ntypedef unsigned long int uint64_t;\n#else\n__extension__ typedef unsigned long long int uint64_t;\n#endif\n\n/* Small types.  */\n\n/* Signed.  */\ntypedef signed char int_least8_t;\ntypedef short int int_least16_t;\ntypedef int int_least32_t;\n#if __WORDSIZE == 64\ntypedef long int int_least64_t;\n#else\n__extension__ typedef long long int int_least64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_least8_t;\ntypedef unsigned short int uint_least16_t;\ntypedef unsigned int uint_least32_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_least64_t;\n#else\n__extension__ typedef unsigned long long int uint_least64_t;\n#endif\n\n/* Fast types.  */\n\n/* Signed.  */\ntypedef signed char int_fast8_t;\n#if __WORDSIZE == 64\ntypedef long int int_fast16_t;\ntypedef long int int_fast32_t;\ntypedef long int int_fast64_t;\n#else\ntypedef int int_fast16_t;\ntypedef int int_fast32_t;\n__extension__ typedef long long int int_fast64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_fast8_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_fast16_t;\ntypedef unsigned long int uint_fast32_t;\ntypedef unsigned long int uint_fast64_t;\n#else\ntypedef unsigned int uint_fast16_t;\ntypedef unsigned int uint_fast32_t;\n__extension__ typedef unsigned long long int uint_fast64_t;\n#endif\n\n/* Types for `void *' pointers.  */\n#if __WORDSIZE == 64\n# ifndef __intptr_t_defined\ntypedef long int intptr_t;\n#  define __intptr_t_defined\n# endif\ntypedef unsigned long int uintptr_t;\n#else\n# ifndef __intptr_t_defined\ntypedef int intptr_t;\n#  define __intptr_t_defined\n# endif\ntypedef unsigned int uintptr_t;\n#endif\n\n/* Largest integral types.  */\n#if __WORDSIZE == 64\ntypedef long int intmax_t;\ntypedef unsigned long int uintmax_t;\n#else\n__extension__ typedef long long int intmax_t;\n__extension__ typedef unsigned long long int uintmax_t;\n#endif\n\n# if __WORDSIZE == 64\n#  define __INT64_C(c)\tc ## L\n#  define __UINT64_C(c)\tc ## UL\n# else\n#  define __INT64_C(c)\tc ## LL\n#  define __UINT64_C(c)\tc ## ULL\n# endif\n\n/* Limits of integral types.  */\n\n/* Minimum of signed integral types.  */\n# define INT8_MIN\t\t(-128)\n# define INT16_MIN\t\t(-32767-1)\n# define INT32_MIN\t\t(-2147483647-1)\n# define INT64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types.  */\n# define INT8_MAX\t\t(127)\n# define INT16_MAX\t\t(32767)\n# define INT32_MAX\t\t(2147483647)\n# define INT64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types.  */\n# define UINT8_MAX\t\t(255)\n# define UINT16_MAX\t\t(65535)\n# define UINT32_MAX\t\t(4294967295U)\n# define UINT64_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of signed integral types having a minimum size.  */\n# define INT_LEAST8_MIN\t\t(-128)\n# define INT_LEAST16_MIN\t(-32767-1)\n# define INT_LEAST32_MIN\t(-2147483647-1)\n# define INT_LEAST64_MIN\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types having a minimum size.  */\n# define INT_LEAST8_MAX\t\t(127)\n# define INT_LEAST16_MAX\t(32767)\n# define INT_LEAST32_MAX\t(2147483647)\n# define INT_LEAST64_MAX\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types having a minimum size.  */\n# define UINT_LEAST8_MAX\t(255)\n# define UINT_LEAST16_MAX\t(65535)\n# define UINT_LEAST32_MAX\t(4294967295U)\n# define UINT_LEAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of fast signed integral types having a minimum size.  */\n# define INT_FAST8_MIN\t\t(-128)\n# if __WORDSIZE == 64\n#  define INT_FAST16_MIN\t(-9223372036854775807L-1)\n#  define INT_FAST32_MIN\t(-9223372036854775807L-1)\n# else\n#  define INT_FAST16_MIN\t(-2147483647-1)\n#  define INT_FAST32_MIN\t(-2147483647-1)\n# endif\n# define INT_FAST64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of fast signed integral types having a minimum size.  */\n# define INT_FAST8_MAX\t\t(127)\n# if __WORDSIZE == 64\n#  define INT_FAST16_MAX\t(9223372036854775807L)\n#  define INT_FAST32_MAX\t(9223372036854775807L)\n# else\n#  define INT_FAST16_MAX\t(2147483647)\n#  define INT_FAST32_MAX\t(2147483647)\n# endif\n# define INT_FAST64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of fast unsigned integral types having a minimum size.  */\n# define UINT_FAST8_MAX\t\t(255)\n# if __WORDSIZE == 64\n#  define UINT_FAST16_MAX\t(18446744073709551615UL)\n#  define UINT_FAST32_MAX\t(18446744073709551615UL)\n# else\n#  define UINT_FAST16_MAX\t(4294967295U)\n#  define UINT_FAST32_MAX\t(4294967295U)\n# endif\n# define UINT_FAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Values to test for integral types holding `void *' pointer.  */\n# if __WORDSIZE == 64\n#  define INTPTR_MIN\t\t(-9223372036854775807L-1)\n#  define INTPTR_MAX\t\t(9223372036854775807L)\n#  define UINTPTR_MAX\t\t(18446744073709551615UL)\n# else\n#  define INTPTR_MIN\t\t(-2147483647-1)\n#  define INTPTR_MAX\t\t(2147483647)\n#  define UINTPTR_MAX\t\t(4294967295U)\n# endif\n\n/* Minimum for largest signed integral type.  */\n# define INTMAX_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum for largest signed integral type.  */\n# define INTMAX_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum for largest unsigned integral type.  */\n# define UINTMAX_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Limits of other integer types.  */\n\n/* Limits of `ptrdiff_t' type.  */\n# if __WORDSIZE == 64\n#  define PTRDIFF_MIN\t\t(-9223372036854775807L-1)\n#  define PTRDIFF_MAX\t\t(9223372036854775807L)\n# else\n#  define PTRDIFF_MIN\t\t(-2147483647-1)\n#  define PTRDIFF_MAX\t\t(2147483647)\n# endif\n\n/* Limits of `sig_atomic_t'.  */\n# define SIG_ATOMIC_MIN\t\t(-2147483647-1)\n# define SIG_ATOMIC_MAX\t\t(2147483647)\n\n/* Limit of `size_t' type.  */\n# if __WORDSIZE == 64\n#  define SIZE_MAX\t\t(18446744073709551615UL)\n# else\n#  ifdef __WORDSIZE32_SIZE_ULONG\n#   define SIZE_MAX\t\t(4294967295UL)\n#  else\n#   define SIZE_MAX\t\t(4294967295U)\n#  endif\n# endif\n\n/* Limits of `wchar_t'.  */\n# ifndef WCHAR_MIN\n/* These constants might also be defined in <wchar.h>.  */\n#  define WCHAR_MIN\t\t__WCHAR_MIN\n#  define WCHAR_MAX\t\t__WCHAR_MAX\n# endif\n\n/* Limits of `wint_t'.  */\n# define WINT_MIN\t\t(0u)\n# define WINT_MAX\t\t(4294967295u)\n\n/* Signed.  */\n# define INT8_C(c)\tc\n# define INT16_C(c)\tc\n# define INT32_C(c)\tc\n# if __WORDSIZE == 64\n#  define INT64_C(c)\tc ## L\n# else\n#  define INT64_C(c)\tc ## LL\n# endif\n\n/* Unsigned.  */\n# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc\n# define UINT32_C(c)\tc ## U\n# if __WORDSIZE == 64\n#  define UINT64_C(c)\tc ## UL\n# else\n#  define UINT64_C(c)\tc ## ULL\n# endif\n\n/* Maximal type.  */\n# if __WORDSIZE == 64\n#  define INTMAX_C(c)\tc ## L\n#  define UINTMAX_C(c)\tc ## UL\n# else\n#  define INTMAX_C(c)\tc ## LL\n#  define UINTMAX_C(c)\tc ## ULL\n# endif\n\n#endif\t\t\t\t/* stdint.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/stdio.h",
    "content": "/* Define ISO C stdio on top of C++ iostreams.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.19 Input/output\t<stdio.h>\n */\n\n#ifndef _STDIO_H\n\n#if !defined __need_FILE && !defined __need___FILE\n# define _STDIO_H\t1\n# include <features.h>\n\n__BEGIN_DECLS\n# define __need_size_t\n# define __need_NULL\n# include <stddef.h>\n# include <bits/types.h>\n# define __need_FILE\n# define __need___FILE\n#endif\t\t\t\t/* Don't need FILE.  */\n#if !defined __FILE_defined && defined __need_FILE\n/* Define outside of namespace so the C++ is happy.  */\n    struct _IO_FILE;\n\n__BEGIN_NAMESPACE_STD\n/* The opaque type of streams.  This is the definition used elsewhere.  */\ntypedef struct _IO_FILE FILE;\n__END_NAMESPACE_STD\n#if defined __USE_LARGEFILE64 || defined __USE_POSIX \\\n    || defined __USE_ISOC99 || defined __USE_XOPEN \\\n    || defined __USE_POSIX2\n__USING_NAMESPACE_STD(FILE)\n#endif\n# define __FILE_defined\t1\n#endif\t\t\t\t/* FILE not defined.  */\n#undef\t__need_FILE\n#if !defined ____FILE_defined && defined __need___FILE\n/* The opaque type of streams.  This is the definition used elsewhere.  */\ntypedef struct _IO_FILE __FILE;\n\n# define ____FILE_defined\t1\n#endif\t\t\t\t/* __FILE not defined.  */\n#undef\t__need___FILE\n\n#ifdef\t_STDIO_H\n#define _STDIO_USES_IOSTREAM\n\n#include <libio.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# ifdef __GNUC__\n#  ifndef _VA_LIST_DEFINED\ntypedef _G_va_list va_list;\n#   define _VA_LIST_DEFINED\n#  endif\n# else\n#  include <stdarg.h>\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n# ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n# endif\n\n# ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n# endif\n#endif\n\n/* The type of the second argument to `fgetpos' and `fsetpos'.  */\n__BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\ntypedef _G_fpos_t fpos_t;\n#else\ntypedef _G_fpos64_t fpos_t;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\ntypedef _G_fpos64_t fpos64_t;\n#endif\n\n/* The possibilities for the third argument to `setvbuf'.  */\n#define _IOFBF 0\t\t/* Fully buffered.  */\n#define _IOLBF 1\t\t/* Line buffered.  */\n#define _IONBF 2\t\t/* No buffering.  */\n\n/* Default buffer size.  */\n#ifndef BUFSIZ\n# define BUFSIZ _IO_BUFSIZ\n#endif\n\n/* End of file character.\n   Some things throughout the library rely on this being -1.  */\n#ifndef EOF\n# define EOF (-1)\n#endif\n\n/* The possibilities for the third argument to `fseek'.\n   These values should not be changed.  */\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n#define SEEK_END\t2\t/* Seek from end of file.  */\n#ifdef __USE_GNU\n# define SEEK_DATA\t3\t/* Seek to next data.  */\n# define SEEK_HOLE\t4\t/* Seek to next hole.  */\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Default path prefix for `tempnam' and `tmpnam'.  */\n# define P_tmpdir\t\"/tmp\"\n#endif\n\n/* Get the values:\n   L_tmpnam\tHow long an array of chars must be to be passed to `tmpnam'.\n   TMP_MAX\tThe minimum number of unique filenames generated by tmpnam\n\t\t(and tempnam when it uses tmpnam's name space),\n\t\tor tempnam (the two are separate).\n   L_ctermid\tHow long an array to pass to `ctermid'.\n   L_cuserid\tHow long an array to pass to `cuserid'.\n   FOPEN_MAX\tMinimum number of files that can be open at once.\n   FILENAME_MAX\tMaximum length of a filename.  */\n#include <bits/stdio_lim.h>\n\n/* Standard streams.  */\nextern struct _IO_FILE *stdin;\t/* Standard input stream.  */\nextern struct _IO_FILE *stdout;\t/* Standard output stream.  */\nextern struct _IO_FILE *stderr;\t/* Standard error output stream.  */\n/* C89/C99 say they're macros.  Make them happy.  */\n#define stdin stdin\n#define stdout stdout\n#define stderr stderr\n\n__BEGIN_NAMESPACE_STD\n/* Remove file FILENAME.  */\nextern int remove(const char *__filename) __THROW;\n/* Rename file OLD to NEW.  */\nextern int rename(const char *__old, const char *__new) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ATFILE\n/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */\nextern int renameat(int __oldfd, const char *__old, int __newfd, const char *__new) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Create a temporary file and open it read/write.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern FILE *tmpfile(void) __wur;\n#else\n# ifdef __REDIRECT\nextern FILE *__REDIRECT(tmpfile, (void), tmpfile64) __wur;\n# else\n#  define tmpfile tmpfile64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern FILE *tmpfile64(void) __wur;\n#endif\n\n/* Generate a temporary filename.  */\nextern char *tmpnam(char *__s)\n__THROW __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* This is the reentrant variant of `tmpnam'.  The only difference is\n   that it does not allow S to be NULL.  */\nextern char *tmpnam_r(char *__s)\n__THROW __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Generate a unique temporary filename using up to five characters of PFX\n   if it is not NULL.  The directory to put this file in is searched for\n   as follows: First the environment variable \"TMPDIR\" is checked.\n   If it contains the name of a writable directory, that directory is used.\n   If not and if DIR is not NULL, that value is checked.  If that fails,\n   P_tmpdir is tried and finally \"/tmp\".  The storage for the filename\n   is allocated by `malloc'.  */\nextern char *tempnam(const char *__dir, const char *__pfx)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Close STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fclose(FILE * __stream);\n/* Flush STREAM, or all streams if STREAM is NULL.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fflush(FILE * __stream);\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fflush_unlocked(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Close all streams.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fcloseall(void);\n#endif\n\n__BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\n/* Open a file and create a new stream for it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *fopen(const char *__restrict __filename, const char *__restrict __modes) __wur;\n/* Open a file, replacing an existing stream with it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *freopen(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#else\n# ifdef __REDIRECT\nextern FILE *__REDIRECT(fopen, (const char *__restrict __filename, const char *__restrict __modes), fopen64) __wur;\nextern FILE *__REDIRECT(freopen, (const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream), freopen64) __wur;\n# else\n#  define fopen fopen64\n#  define freopen freopen64\n# endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\nextern FILE *fopen64(const char *__restrict __filename, const char *__restrict __modes) __wur;\nextern FILE *freopen64(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#endif\n\n#ifdef\t__USE_POSIX\n/* Create a new stream that refers to an existing system file descriptor.  */\nextern FILE *fdopen(int __fd, const char *__modes)\n__THROW __wur;\n#endif\n\n#ifdef\t__USE_GNU\n/* Create a new stream that refers to the given magic cookie,\n   and uses the given functions for input and output.  */\nextern FILE *fopencookie(void *__restrict __magic_cookie, const char *__restrict __modes, _IO_cookie_io_functions_t __io_funcs)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Create a new stream that refers to a memory buffer.  */\nextern FILE *fmemopen(void *__s, size_t __len, const char *__modes)\n__THROW __wur;\n\n/* Open a stream that writes into a malloc'd buffer that is expanded as\n   necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location\n   and the number of characters written on fflush or fclose.  */\nextern FILE *open_memstream(char **__bufloc, size_t * __sizeloc)\n__THROW __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use buffer BUF, of size BUFSIZ.  */\nextern void setbuf(FILE * __restrict __stream, char *__restrict __buf) __THROW;\n/* Make STREAM use buffering mode MODE.\n   If BUF is not NULL, use N bytes of it for buffering;\n   else allocate an internal buffer N bytes long.  */\nextern int setvbuf(FILE * __restrict __stream, char *__restrict __buf, int __modes, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use SIZE bytes of BUF for buffering.  */\nextern void setbuffer(FILE * __restrict __stream, char *__restrict __buf, size_t __size) __THROW;\n\n/* Make STREAM line-buffered.  */\nextern void setlinebuf(FILE * __stream) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fprintf(FILE * __restrict __stream, const char *__restrict __format, ...);\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int printf(const char *__restrict __format, ...);\n/* Write formatted output to S.  */\nextern int sprintf(char *__restrict __s, const char *__restrict __format, ...) __THROWNL;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfprintf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vprintf(const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to S from argument list ARG.  */\nextern int vsprintf(char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROWNL;\n__END_NAMESPACE_STD\n#if defined __USE_ISOC99 || defined __USE_UNIX98\n    __BEGIN_NAMESPACE_C99\n/* Maximum chars of output to write in MAXLEN.  */\nextern int snprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 4)));\n\nextern int vsnprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 0)));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Write formatted output to a string dynamically allocated with `malloc'.\n   Store the address of the string in *PTR.  */\nextern int vasprintf(char **__restrict __ptr, const char *__restrict __f, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0))) __wur;\nextern int __asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\nextern int asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Write formatted output to a file descriptor.  */\nextern int vdprintf(int __fd, const char *__restrict __fmt, _G_va_list __arg)\n    __attribute__ ((__format__(__printf__, 2, 0)));\nextern int dprintf(int __fd, const char *__restrict __fmt, ...)\n    __attribute__ ((__format__(__printf__, 2, 3)));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int scanf(const char *__restrict __format, ...) __wur;\n/* Read formatted input from S.  */\nextern int sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n\n#if defined __USE_ISOC99 && !defined __USE_GNU \\\n    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n# ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fscanf, (FILE * __restrict __stream, const char *__restrict __format, ...), __isoc99_fscanf) __wur;\nextern int __REDIRECT(scanf, (const char *__restrict __format, ...), __isoc99_scanf) __wur;\nextern int __REDIRECT_NTH(sscanf, (const char *__restrict __s, const char *__restrict __format, ...), __isoc99_sscanf);\n# else\nextern int __isoc99_fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\nextern int __isoc99_scanf(const char *__restrict __format, ...) __wur;\nextern int __isoc99_sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n#  define fscanf __isoc99_fscanf\n#  define scanf __isoc99_scanf\n#  define sscanf __isoc99_sscanf\n# endif\n#endif\n\n__END_NAMESPACE_STD\n#ifdef\t__USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\n\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vscanf(const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\n\n/* Read formatted input from S into argument list ARG.  */\nextern int vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg)\n__THROW __attribute__ ((__format__(__scanf__, 2, 0)));\n\n# if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(vfscanf, (FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vfscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\nextern int __REDIRECT(vscanf, (const char *__restrict __format, _G_va_list __arg), __isoc99_vscanf)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\nextern int __REDIRECT_NTH(vsscanf, (const char *__restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vsscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0)));\n#  else\nextern int __isoc99_vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vscanf(const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROW;\n#   define vfscanf __isoc99_vfscanf\n#   define vscanf __isoc99_vscanf\n#   define vsscanf __isoc99_vsscanf\n#  endif\n# endif\n\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* Use ISO C9x.  */\n    __BEGIN_NAMESPACE_STD\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int fgetc(FILE * __stream);\nextern int getc(FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getchar(void);\n__END_NAMESPACE_STD\n/* The C standard explicitly says this is a macro, so we always do the\n   optimization for it.  */\n#define getc(_fp) _IO_getc (_fp)\n#ifdef __USE_POSIX\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int getc_unlocked(FILE * __stream);\nextern int getchar_unlocked(void);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetc_unlocked(FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n__BEGIN_NAMESPACE_STD\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.\n\n   These functions is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputc(int __c, FILE * __stream);\nextern int putc(int __c, FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int putchar(int __c);\n__END_NAMESPACE_STD\n/* The C standard explicitly says this can be a macro,\n   so we always do the optimization for it.  */\n#define putc(_ch, _fp) _IO_putc (_ch, _fp)\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputc_unlocked(int __c, FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n#ifdef __USE_POSIX\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int putc_unlocked(int __c, FILE * __stream);\nextern int putchar_unlocked(int __c);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Get a word (int) from STREAM.  */\nextern int getw(FILE * __stream);\n\n/* Write a word (int) to STREAM.  */\nextern int putw(int __w, FILE * __stream);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Get a newline-terminated string of finite length from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *fgets(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n\n#if !defined __USE_ISOC11 \\\n    || (defined __cplusplus && __cplusplus <= 201103L)\n/* Get a newline-terminated string from stdin, removing the newline.\n   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.\n\n   The function has been officially removed in ISO C11.  This opportunity\n   is used to also remove it from the GNU feature list.  It is now only\n   available when explicitly using an old ISO C, Unix, or POSIX standard.\n   GCC defines _GNU_SOURCE when building C++ code and the function is still\n   in C++11, so it is also available for C++.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *gets(char *__s)\n__wur __attribute_deprecated__;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function does the same as `fgets' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern char *fgets_unlocked(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n#endif\n\n#ifdef\t__USE_XOPEN2K8\n/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR\n   (and null-terminate it). *LINEPTR is a pointer returned from malloc (or\n   NULL), pointing to *N characters of space.  It is realloc'd as\n   necessary.  Returns the number of characters read (not including the\n   null terminator), or -1 on error or EOF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t __getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\nextern _IO_ssize_t getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\n\n/* Like `getdelim', but reads up to a newline.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t getline(char **__restrict __lineptr, size_t * __restrict __n, FILE * __restrict __stream) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputs(const char *__restrict __s, FILE * __restrict __stream);\n\n/* Write a string, followed by a newline, to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int puts(const char *__s);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int ungetc(int __c, FILE * __stream);\n\n/* Read chunks of generic data from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fread(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\n/* Write chunks of generic data to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fwrite(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __s);\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function does the same as `fputs' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputs_unlocked(const char *__restrict __s, FILE * __restrict __stream);\n#endif\n\n#ifdef __USE_MISC\n/* Faster versions when locking is not necessary.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern size_t fread_unlocked(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\nextern size_t fwrite_unlocked(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseek(FILE * __stream, long int __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern long int ftell(FILE * __stream) __wur;\n/* Rewind to the beginning of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void rewind(FILE * __stream);\n__END_NAMESPACE_STD\n/* The Single Unix Specification, Version 2, specifies an alternative,\n   more adequate interface for the two functions above which deal with\n   file offset.  `long int' is not the right type.  These definitions\n   are originally defined in the Large File Support API.  */\n#if defined __USE_LARGEFILE || defined __USE_XOPEN2K\n# ifndef __USE_FILE_OFFSET64\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseeko(FILE * __stream, __off_t __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __off_t ftello(FILE * __stream) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(fseeko, (FILE * __stream, __off64_t __off, int __whence), fseeko64);\nextern __off64_t __REDIRECT(ftello, (FILE * __stream), ftello64);\n#  else\n#   define fseeko fseeko64\n#   define ftello ftello64\n#  endif\n# endif\n#endif\n    __BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\n/* Get STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fgetpos(FILE * __restrict __stream, fpos_t * __restrict __pos);\n/* Set STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fsetpos(FILE * __stream, const fpos_t * __pos);\n#else\n# ifdef __REDIRECT\nextern int __REDIRECT(fgetpos, (FILE * __restrict __stream, fpos_t * __restrict __pos), fgetpos64);\nextern int __REDIRECT(fsetpos, (FILE * __stream, const fpos_t * __pos), fsetpos64);\n# else\n#  define fgetpos fgetpos64\n#  define fsetpos fsetpos64\n# endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\nextern int fseeko64(FILE * __stream, __off64_t __off, int __whence);\nextern __off64_t ftello64(FILE * __stream) __wur;\nextern int fgetpos64(FILE * __restrict __stream, fpos64_t * __restrict __pos);\nextern int fsetpos64(FILE * __stream, const fpos64_t * __pos);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Clear the error and EOF indicators for STREAM.  */\nextern void clearerr(FILE * __stream) __THROW;\n/* Return the EOF indicator for STREAM.  */\nextern int feof(FILE * __stream)\n__THROW __wur;\n/* Return the error indicator for STREAM.  */\nextern int ferror(FILE * __stream)\n__THROW __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.  */\nextern void clearerr_unlocked(FILE * __stream) __THROW;\nextern int feof_unlocked(FILE * __stream)\n__THROW __wur;\nextern int ferror_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Print a message describing the meaning of the value of errno.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void perror(const char *__s);\n__END_NAMESPACE_STD\n/* Provide the declarations for `sys_errlist' and `sys_nerr' if they\n   are available on this system.  Even if available, these variables\n   should not be used directly.  The `strerror' function provides\n   all the necessary functionality.  */\n#include <bits/sys_errlist.h>\n#ifdef\t__USE_POSIX\n/* Return the system file descriptor for STREAM.  */\nextern int fileno(FILE * __stream)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not required.  */\nextern int fileno_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n#ifdef __USE_POSIX2\n/* Create a new stream connected to a pipe running the given command.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *popen(const char *__command, const char *__modes) __wur;\n\n/* Close a stream opened by popen and return the status of its child.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int pclose(FILE * __stream);\n#endif\n\n#ifdef\t__USE_POSIX\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_XOPEN\n/* Return the name of the current user.  */\nextern char *cuserid(char *__s);\n#endif\t\t\t\t/* Use X/Open, but not issue 6.  */\n\n#ifdef\t__USE_GNU\nstruct obstack;\t\t\t/* See <obstack.h>.  */\n\n/* Write formatted output to an obstack.  */\nextern int obstack_printf(struct obstack *__restrict __obstack, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3)));\nextern int obstack_vprintf(struct obstack *__restrict __obstack, const char *__restrict __format, _G_va_list __args)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0)));\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_POSIX\n/* These are defined in POSIX.1:1996.  */\n\n/* Acquire ownership of STREAM.  */\nextern void flockfile(FILE * __stream) __THROW;\n\n/* Try to acquire ownership of STREAM but do not block if it is not\n   possible.  */\nextern int ftrylockfile(FILE * __stream)\n__THROW __wur;\n\n/* Relinquish the ownership granted for STREAM.  */\nextern void funlockfile(FILE * __stream) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU\n/* The X/Open standard requires some functions and variables to be\n   declared here which do not belong into this header.  But we have to\n   follow.  In GNU mode we don't do this nonsense.  */\n# define __need_getopt\n# include <getopt.h>\n#endif\t\t\t\t/* X/Open, but not issue 6 and not for GNU.  */\n\n/* If we are compiling with optimizing read this file.  It contains\n   several optimizing inline functions and macros.  */\n#ifdef __USE_EXTERN_INLINES\n# include <bits/stdio.h>\n#endif\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/stdio2.h>\n#endif\n#ifdef __LDBL_COMPAT\n# include <bits/stdio-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* <stdio.h> included.  */\n#endif\t\t\t\t/* !_STDIO_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/stdlib.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.20 General utilities\t<stdlib.h>\n */\n\n#ifndef\t_STDLIB_H\n\n#include <features.h>\n\n/* Get size_t, wchar_t and NULL from <stddef.h>.  */\n#define\t\t__need_size_t\n#ifndef __need_malloc_and_calloc\n# define\t__need_wchar_t\n# define\t__need_NULL\n#endif\n#include <stddef.h>\n\n__BEGIN_DECLS\n#ifndef __need_malloc_and_calloc\n#define\t_STDLIB_H\t1\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H\n/* XPG requires a few symbols from <sys/wait.h> being defined.  */\n# include <bits/waitflags.h>\n# include <bits/waitstatus.h>\n# ifdef __USE_MISC\n/* Lots of hair to allow traditional BSD use of `union wait'\n   as well as POSIX.1 use of `int' for the status word.  */\n#  if defined __GNUC__ && !defined __cplusplus\n#   define __WAIT_INT(status) \\\n  (__extension__ (((union { __typeof(status) __in; int __i; }) \\\n\t\t   { .__in = (status) }).__i))\n#  else\n#   define __WAIT_INT(status)\t(*(int *) &(status))\n#  endif\n/* This is the type of the argument to `wait'.  The funky union\n   causes redeclarations with either `int *' or `union wait *' to be\n   allowed without complaint.  __WAIT_STATUS_DEFN is the type used in\n   the actual function definitions.  */\n#  if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus\n#   define __WAIT_STATUS\tvoid *\n#   define __WAIT_STATUS_DEFN\tvoid *\n#  else\n/* This works in GCC 2.6.1 and later.  */\n    typedef union {\n\tunion wait *__uptr;\n\tint *__iptr;\n} __WAIT_STATUS __attribute__ ((__transparent_union__));\n#   define __WAIT_STATUS_DEFN\tint *\n#  endif\n\n# else\t\t\t\t/* Don't use misc.  */\n#  define __WAIT_INT(status)\t(status)\n#  define __WAIT_STATUS\t\tint *\n#  define __WAIT_STATUS_DEFN\tint *\n# endif\t\t\t\t/* Use misc.  */\n/* Define the macros <sys/wait.h> also would define this way.  */\n# define WEXITSTATUS(status)\t__WEXITSTATUS (__WAIT_INT (status))\n# define WTERMSIG(status)\t__WTERMSIG (__WAIT_INT (status))\n# define WSTOPSIG(status)\t__WSTOPSIG (__WAIT_INT (status))\n# define WIFEXITED(status)\t__WIFEXITED (__WAIT_INT (status))\n# define WIFSIGNALED(status)\t__WIFSIGNALED (__WAIT_INT (status))\n# define WIFSTOPPED(status)\t__WIFSTOPPED (__WAIT_INT (status))\n# ifdef __WIFCONTINUED\n#  define WIFCONTINUED(status)\t__WIFCONTINUED (__WAIT_INT (status))\n# endif\n#endif\t\t\t\t/* X/Open or XPG7 and <sys/wait.h> not included.  */\n    __BEGIN_NAMESPACE_STD\n/* Returned by `div'.  */\n    typedef struct {\n\tint quot;\t\t/* Quotient.  */\n\tint rem;\t\t/* Remainder.  */\n} div_t;\n\n/* Returned by `ldiv'.  */\n#ifndef __ldiv_t_defined\ntypedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} ldiv_t;\n# define __ldiv_t_defined\t1\n#endif\n__END_NAMESPACE_STD\n#if defined __USE_ISOC99 && !defined __lldiv_t_defined\n    __BEGIN_NAMESPACE_C99\n/* Returned by `lldiv'.  */\n    __extension__ typedef struct {\n\tlong long int quot;\t/* Quotient.  */\n\tlong long int rem;\t/* Remainder.  */\n} lldiv_t;\n# define __lldiv_t_defined\t1\n__END_NAMESPACE_C99\n#endif\n/* The largest number rand will return (same as INT_MAX).  */\n#define\tRAND_MAX\t2147483647\n/* We define these the same for all machines.\n   Changes from this to the outside world should be done in `_exit'.  */\n#define\tEXIT_FAILURE\t1\t/* Failing exit status.  */\n#define\tEXIT_SUCCESS\t0\t/* Successful exit status.  */\n/* Maximum length of a multibyte character in the current locale.  */\n#define\tMB_CUR_MAX\t(__ctype_get_mb_cur_max ())\nextern size_t __ctype_get_mb_cur_max(void)\n__THROW __wur;\n\n__BEGIN_NAMESPACE_STD\n/* Convert a string to a floating-point number.  */\nextern double atof(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to an integer.  */\nextern int atoi(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to a long integer.  */\nextern long int atol(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Convert a string to a long long integer.  */\n__extension__ extern long long int atoll(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Convert a string to a floating-point number.  */\nextern double strtod(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef\t__USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float strtof(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n\nextern long double strtold(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Convert a string to a long integer.  */\nextern long int strtol(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned long integer.  */\nextern unsigned long int strtoul(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtouq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoll(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtoull(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* ISO C99 or use MISC.  */\n#ifdef __USE_GNU\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another problem is\n   the implementation of the internationalization handling in the\n   ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which take an additional\n   argument.\n\n   Attention: even though several *_l interfaces are part of POSIX:2008,\n   these are not.  */\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n# include <xlocale.h>\n/* Special versions of the functions above which take the locale to\n   use as an additional parameter.  */\nextern long int strtol_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern unsigned long int strtoul_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern long long int strtoll_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern unsigned long long int strtoull_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern double strtod_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern float strtof_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern long double strtold_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n#endif\t\t\t\t/* GNU */\n\n#ifdef __USE_EXTERN_INLINES\n__BEGIN_NAMESPACE_STD __extern_inline int __NTH(atoi(const char *__nptr))\n{\n\treturn (int)strtol(__nptr, (char **)NULL, 10);\n}\n\n__extern_inline long int __NTH(atol(const char *__nptr))\n{\n\treturn strtol(__nptr, (char **)NULL, 10);\n}\n\n__END_NAMESPACE_STD\n# ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99 __extension__ __extern_inline long long int __NTH(atoll(const char *__nptr))\n{\n\treturn strtoll(__nptr, (char **)NULL, 10);\n}\n\n__END_NAMESPACE_C99\n# endif\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Convert N to base 64 using the digits \"./0-9A-Za-z\", least-significant\n   digit first.  Returns a pointer to static storage overwritten by the\n   next call.  */\nextern char *l64a(long int __n)\n__THROW __wur;\n\n/* Read a number from a string S in base 64 as above.  */\nextern long int a64l(const char *__s)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use misc || extended X/Open.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n# include <sys/types.h>\t\t/* we need int32_t... */\n\n/* These are the functions that actually do things.  The `random', `srandom',\n   `initstate' and `setstate' functions are those from BSD Unices.\n   The `rand' and `srand' functions are required by the ANSI standard.\n   We provide both interfaces to the same random number generator.  */\n/* Return a random long integer between 0 and RAND_MAX inclusive.  */\nextern long int random(void) __THROW;\n\n/* Seed the random number generator with the given number.  */\nextern void srandom(unsigned int __seed) __THROW;\n\n/* Initialize the random number generator to use state buffer STATEBUF,\n   of length STATELEN, and seed it with SEED.  Optimal lengths are 8, 16,\n   32, 64, 128 and 256, the bigger the better; values less than 8 will\n   cause an error and values greater than 256 will be rounded down.  */\nextern char *initstate(unsigned int __seed, char *__statebuf, size_t __statelen)\n__THROW __nonnull((2));\n\n/* Switch the random number generator to state buffer STATEBUF,\n   which should have been previously initialized by `initstate'.  */\nextern char *setstate(char *__statebuf)\n__THROW __nonnull((1));\n\n# ifdef __USE_MISC\n/* Reentrant versions of the `random' family of functions.\n   These functions all use the following data structure to contain\n   state, rather than global state variables.  */\n\nstruct random_data {\n\tint32_t *fptr;\t\t/* Front pointer.  */\n\tint32_t *rptr;\t\t/* Rear pointer.  */\n\tint32_t *state;\t\t/* Array of state values.  */\n\tint rand_type;\t\t/* Type of random number generator.  */\n\tint rand_deg;\t\t/* Degree of random number generator.  */\n\tint rand_sep;\t\t/* Distance between front and rear.  */\n\tint32_t *end_ptr;\t/* Pointer behind state table.  */\n};\n\nextern int random_r(struct random_data *__restrict __buf, int32_t * __restrict __result)\n__THROW __nonnull((1, 2));\n\nextern int srandom_r(unsigned int __seed, struct random_data *__buf)\n__THROW __nonnull((2));\n\nextern int initstate_r(unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf)\n__THROW __nonnull((2, 4));\n\nextern int setstate_r(char *__restrict __statebuf, struct random_data *__restrict __buf)\n__THROW __nonnull((1, 2));\n# endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use extended X/Open || misc. */\n\n__BEGIN_NAMESPACE_STD\n/* Return a random integer between 0 and RAND_MAX inclusive.  */\nextern int rand(void) __THROW;\n/* Seed the random number generator with the given number.  */\nextern void srand(unsigned int __seed) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX\n/* Reentrant interface according to POSIX.1.  */\nextern int rand_r(unsigned int *__seed) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* System V style 48-bit random number generator functions.  */\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern double drand48(void) __THROW;\nextern double erand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern long int lrand48(void) __THROW;\nextern long int nrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern long int mrand48(void) __THROW;\nextern long int jrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Seed random number generator.  */\nextern void srand48(long int __seedval) __THROW;\nextern unsigned short int *seed48(unsigned short int __seed16v[3])\n__THROW __nonnull((1));\nextern void lcong48(unsigned short int __param[7])\n__THROW __nonnull((1));\n\n# ifdef __USE_MISC\n/* Data structure for communication with thread safe versions.  This\n   type is to be regarded as opaque.  It's only exported because users\n   have to allocate objects of this type.  */\nstruct drand48_data {\n\tunsigned short int __x[3];\t/* Current state.  */\n\tunsigned short int __old_x[3];\t/* Old state.  */\n\tunsigned short int __c;\t/* Additive const. in congruential formula.  */\n\tunsigned short int __init;\t/* Flag for initializing.  */\n\t__extension__ unsigned long long int __a;\t/* Factor in congruential\n\t\t\t\t\t\t\t   formula.  */\n};\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern int drand48_r(struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int erand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern int lrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int nrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern int mrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int jrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Seed random number generator.  */\nextern int srand48_r(long int __seedval, struct drand48_data *__buffer)\n__THROW __nonnull((2));\n\nextern int seed48_r(unsigned short int __seed16v[3], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n\nextern int lcong48_r(unsigned short int __param[7], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n# endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n#endif\t\t\t\t/* don't just need malloc and calloc */\n\n#ifndef __malloc_and_calloc_defined\n# define __malloc_and_calloc_defined\n__BEGIN_NAMESPACE_STD\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n__END_NAMESPACE_STD\n#endif\n#ifndef __need_malloc_and_calloc\n    __BEGIN_NAMESPACE_STD\n/* Re-allocate the previously allocated block\n   in PTR, making the new block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* Free a block.  An alias for `free'.\t(Sun Unices).  */\nextern void cfree(void *__ptr) __THROW;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_MISC\n# include <alloca.h>\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n/* Allocate SIZE bytes on a page boundary.  The storage cannot be freed.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT.  */\nextern int posix_memalign(void **__memptr, size_t __alignment, size_t __size)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_ISOC11\n/* ISO C variant of aligned allocation.  */\nextern void *aligned_alloc(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __attribute_alloc_size__((2)) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Abort execution and generate a core-dump.  */\nextern void abort(void)\n__THROW __attribute__ ((__noreturn__));\n\n/* Register a function to be called when `exit' is called.  */\nextern int atexit(void (*__func) (void))\n__THROW __nonnull((1));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Register a function to be called when `quick_exit' is called.  */\n# ifdef __cplusplus\nextern \"C++\" int at_quick_exit(void (*__func) (void))\n__THROW __asm(\"at_quick_exit\") __nonnull((1));\n# else\nextern int at_quick_exit(void (*__func) (void))\n__THROW __nonnull((1));\n# endif\n#endif\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* Register a function to be called with the status\n   given to `exit' and the given argument.  */\nextern int on_exit(void (*__func) (int __status, void *__arg), void *__arg)\n__THROW __nonnull((1));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Call all functions registered with `atexit' and `on_exit',\n   in the reverse of the order in which they were registered,\n   perform stdio cleanup, and terminate program execution with STATUS.  */\nextern void exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Call all functions registered with `at_quick_exit' in the reverse\n   of the order in which they were registered and terminate program\n   execution with STATUS.  */\nextern void quick_exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Terminate the program with STATUS without calling any of the\n   functions registered with `atexit' or `on_exit'.  */\nextern void _Exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Return the value of envariable NAME, or NULL if it doesn't exist.  */\nextern char *getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to the above but returns NULL if the\n   programs is running with SUID or SGID enabled.  */\nextern char *secure_getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* The SVID says this is in <stdio.h>, but this seems a better place.\t*/\n/* Put STRING, which is of the form \"NAME=VALUE\", in the environment.\n   If there is no `=', remove NAME from the environment.  */\nextern int putenv(char *__string)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set NAME to VALUE in the environment.\n   If REPLACE is nonzero, overwrite an existing value.  */\nextern int setenv(const char *__name, const char *__value, int __replace)\n__THROW __nonnull((2));\n\n/* Remove the variable NAME from the environment.  */\nextern int unsetenv(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* The `clearenv' was planned to be added to POSIX.1 but probably\n   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings\n   for Fortran 77) requires this function.  */\nextern int clearenv(void) __THROW;\n#endif\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the file name unique.\n   Always returns TEMPLATE, it's either a temporary file name or a null\n   string if it cannot get a unique file name.  */\nextern char *mktemp(char *__template)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the filename unique.\n   Returns a file descriptor open on the file for reading and writing,\n   or -1 if it cannot create a uniquely-named file.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkstemp(char *__template) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkstemp, (char *__template), mkstemp64) __nonnull((1)) __wur;\n#  else\n#   define mkstemp mkstemp64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkstemp64(char *__template) __nonnull((1)) __wur;\n# endif\n#endif\n\n#ifdef __USE_MISC\n/* Similar to mkstemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkstemps(char *__template, int __suffixlen) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkstemps, (char *__template, int __suffixlen), mkstemps64) __nonnull((1)) __wur;\n#  else\n#   define mkstemps mkstemps64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkstemps64(char *__template, int __suffixlen) __nonnull((1)) __wur;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Create a unique temporary directory from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the directory name unique.\n   Returns TEMPLATE, or a null pointer if it cannot get a unique name.\n   The directory is created mode 700.  */\nextern char *mkdtemp(char *__template)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Generate a unique temporary file name from TEMPLATE similar to\n   mkstemp.  But allow the caller to pass additional flags which are\n   used in the open call to create the file..\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkostemp(char *__template, int __flags) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkostemp, (char *__template, int __flags), mkostemp64) __nonnull((1)) __wur;\n#  else\n#   define mkostemp mkostemp64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkostemp64(char *__template, int __flags) __nonnull((1)) __wur;\n# endif\n\n/* Similar to mkostemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n# ifndef __USE_FILE_OFFSET64\nextern int mkostemps(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(mkostemps, (char *__template, int __suffixlen, int __flags), mkostemps64) __nonnull((1)) __wur;\n#  else\n#   define mkostemps mkostemps64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int mkostemps64(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n# endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Execute the given line as a shell command.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int system(const char *__command) __wur;\n__END_NAMESPACE_STD\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the canonical absolute name of the\n   existing named file.  */\nextern char *canonicalize_file_name(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Return the canonical absolute name of file NAME.  If RESOLVED is\n   null, the result is malloc'd; otherwise, if the canonical name is\n   PATH_MAX chars or more, returns null with `errno' set to\n   ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,\n   returns the name in RESOLVED.  */\nextern char *realpath(const char *__restrict __name, char *__restrict __resolved)\n__THROW __wur;\n#endif\n\n/* Shorthand for type of comparison functions.  */\n#ifndef __COMPAR_FN_T\n# define __COMPAR_FN_T\ntypedef int (*__compar_fn_t) (const void *, const void *);\n\n# ifdef\t__USE_GNU\ntypedef __compar_fn_t comparison_fn_t;\n# endif\n#endif\n#ifdef __USE_GNU\ntypedef int (*__compar_d_fn_t) (const void *, const void *, void *);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Do a binary search for KEY in BASE, which consists of NMEMB elements\n   of SIZE bytes each, using COMPAR to perform the comparisons.  */\nextern void *bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 2, 5)) __wur;\n\n#ifdef __USE_EXTERN_INLINES\n# include <bits/stdlib-bsearch.h>\n#endif\n\n/* Sort NMEMB elements of BASE, of SIZE bytes each,\n   using COMPAR to perform the comparisons.  */\nextern void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 4));\n#ifdef __USE_GNU\nextern void qsort_r(void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg) __nonnull((1, 4));\n#endif\n\n/* Return the absolute value of X.  */\nextern int abs(int __x)\n__THROW __attribute__ ((__const__)) __wur;\nextern long int labs(long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n__extension__ extern long long int llabs(long long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the `div_t', `ldiv_t' or `lldiv_t' representation\n   of the value of NUMER over DENOM. */\n/* GCC may have built-ins for these someday.  */\nextern div_t div(int __numer, int __denom)\n__THROW __attribute__ ((__const__)) __wur;\nextern ldiv_t ldiv(long int __numer, long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99 __extension__ extern lldiv_t lldiv(long long int __numer, long long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_C99\n#endif\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Convert floating point numbers to strings.  The returned values are\n   valid only until another call to the same function.  */\n/* Convert VALUE to a string with NDIGIT digits and return a pointer to\n   this.  Set *DECPT with the position of the decimal character and *SIGN\n   with the sign of the number.  */\nextern char *ecvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* Convert VALUE to a string rounded to NDIGIT decimal digits.  Set *DECPT\n   with the position of the decimal character and *SIGN with the sign of\n   the number.  */\nextern char *fcvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* If possible convert VALUE to a string with NDIGIT significant digits.\n   Otherwise use exponential representation.  The resulting string will\n   be written to BUF.  */\nextern char *gcvt(double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n#endif\n\n#ifdef __USE_MISC\n/* Long double versions of above functions.  */\nextern char *qecvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qfcvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qgcvt(long double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n\n/* Reentrant version of the functions above which provide their own\n   buffers.  */\nextern int ecvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int fcvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n\nextern int qecvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int qfcvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n#endif\t\t\t\t/* misc */\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the multibyte character\n   in S, which is no longer than N.  */\nextern int mblen(const char *__s, size_t __n) __THROW;\n/* Return the length of the given multibyte character,\n   putting its `wchar_t' representation in *PWC.  */\nextern int mbtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n) __THROW;\n/* Put the multibyte character represented\n   by WCHAR in S, returning its length.  */\nextern int wctomb(char *__s, wchar_t __wchar) __THROW;\n\n/* Convert a multibyte string to a wide char string.  */\nextern size_t mbstowcs(wchar_t * __restrict __pwcs, const char *__restrict __s, size_t __n) __THROW;\n/* Convert a wide char string to multibyte string.  */\nextern size_t wcstombs(char *__restrict __s, const wchar_t * __restrict __pwcs, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Determine whether the string value of RESPONSE matches the affirmation\n   or negative response expression as specified by the LC_MESSAGES category\n   in the program's current locale.  Returns 1 if affirmative, 0 if\n   negative, and -1 if not matching.  */\nextern int rpmatch(const char *__response)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Parse comma separated suboption from *OPTIONP and match against\n   strings in TOKENS.  If found return index and set *VALUEP to\n   optional value introduced by an equal sign.  If the suboption is\n   not part of TOKENS return in *VALUEP beginning of unknown\n   suboption.  On exit *OPTIONP is set to the beginning of the next\n   token or at the terminating NUL character.  */\nextern int getsubopt(char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep)\n__THROW __nonnull((1, 2, 3)) __wur;\n#endif\n\n#ifdef __USE_XOPEN\n/* Setup DES tables according KEY.  */\nextern void setkey(const char *__key)\n__THROW __nonnull((1));\n#endif\n\n/* X/Open pseudo terminal handling.  */\n\n#ifdef __USE_XOPEN2KXSI\n/* Return a master pseudo-terminal handle.  */\nextern int posix_openpt(int __oflag) __wur;\n#endif\n\n#ifdef __USE_XOPEN\n/* The next four functions all take a master pseudo-tty fd and\n   perform an operation on the associated slave:  */\n\n/* Chown the slave to the calling user.  */\nextern int grantpt(int __fd) __THROW;\n\n/* Release an internal lock so the slave can be opened.\n   Call after grantpt().  */\nextern int unlockpt(int __fd) __THROW;\n\n/* Return the pathname of the pseudo terminal slave associated with\n   the master FD is open on, or NULL on errors.\n   The returned storage is good until the next call to this function.  */\nextern char *ptsname(int __fd)\n__THROW __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Store at most BUFLEN characters of the pathname of the slave pseudo\n   terminal associated with the master FD is open on in BUF.\n   Return 0 on success, otherwise an error number.  */\nextern int ptsname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Open a master pseudo terminal and return its file descriptor.  */\nextern int getpt(void);\n#endif\n\n#ifdef __USE_MISC\n/* Put the 1 minute, 5 minute and 15 minute load averages into the first\n   NELEM elements of LOADAVG.  Return the number written (never more than\n   three, but may be less than NELEM), or -1 if an error occurred.  */\nextern int getloadavg(double __loadavg[], int __nelem)\n__THROW __nonnull((1));\n#endif\n\n#include <bits/stdlib-float.h>\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/stdlib.h>\n#endif\n#ifdef __LDBL_COMPAT\n# include <bits/stdlib-ldbl.h>\n#endif\n\n#endif\t\t\t\t/* don't just need malloc and calloc */\n#undef __need_malloc_and_calloc\n\n__END_DECLS\n#endif\t\t\t\t/* stdlib.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/string.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.21 String handling\t<string.h>\n */\n\n#ifndef\t_STRING_H\n#define\t_STRING_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get size_t and NULL from <stddef.h>.  */\n#define\t__need_size_t\n#define\t__need_NULL\n#include <stddef.h>\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n# define __CORRECT_ISO_CPP_STRING_H_PROTO\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Copy N bytes of SRC to DEST.  */\nextern void *memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n/* Copy N bytes of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern void *memmove(void *__dest, const void *__src, size_t __n)\n__THROW __nonnull((1, 2));\n__END_NAMESPACE_STD\n/* Copy no more than N bytes of SRC to DEST, stopping when C is found.\n   Return the position in DEST one byte past where C was copied,\n   or NULL if C was not found in the first N bytes of SRC.  */\n#if defined __USE_MISC || defined __USE_XOPEN\nextern void *memccpy(void *__restrict __dest, const void *__restrict __src, int __c, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\t\t\t\t/* Misc || X/Open.  */\n\n__BEGIN_NAMESPACE_STD\n/* Set N bytes of S to C.  */\nextern void *memset(void *__s, int __c, size_t __n)\n__THROW __nonnull((1));\n\n/* Compare N bytes of S1 and S2.  */\nextern int memcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Search N bytes of S for C.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern void *memchr(void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\textern const void *memchr(const void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline void *memchr(void *__s, int __c, size_t __n) __THROW\n{\n\treturn __builtin_memchr(__s, __c, __n);\n} __extern_always_inline const void *memchr(const void *__s, int __c, size_t __n) __THROW {\n\t\treturn __builtin_memchr(__s, __c, __n);\n}\n# endif\n}\n#else\nextern void *memchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* Search in S for C.  This is similar to `memchr' but there is no\n   length limit.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *rawmemchr(void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *rawmemchr(const void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\n# else\nextern void *rawmemchr(const void *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n\n/* Search N bytes of S for the final occurrence of C.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *memrchr(void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\n# else\nextern void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Copy SRC to DEST.  */\nextern char *strcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Copy no more than N characters of SRC to DEST.  */\nextern char *strncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern char *strcat(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Append no more than N characters from SRC onto DEST.  */\nextern char *strncat(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Compare S1 and S2.  */\nextern int strcmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Compare N characters of S1 and S2.  */\nextern int strncmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare the collated forms of S1 and S2.  */\nextern int strcoll(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Put a transformation of SRC into no more than N bytes of DEST.  */\nextern size_t strxfrm(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((2));\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* The following functions are equivalent to the both above but they\n   take the locale they use for the collation as an extra argument.\n   This is not standardsized but something like will come.  */\n# include <xlocale.h>\n/* Compare the collated forms of S1 and S2 using rules from L.  */\nextern int strcoll_l(const char *__s1, const char *__s2, __locale_t __l)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n/* Put a transformation of SRC into no more than N bytes of DEST.  */\nextern size_t strxfrm_l(char *__dest, const char *__src, size_t __n, __locale_t __l)\n__THROW __nonnull((2, 4));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Duplicate S, returning an identical malloc'd string.  */\nextern char *strdup(const char *__s)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n/* Return a malloc'd copy of at most N bytes of STRING.  The\n   resultant string is terminated even if no null terminator\n   appears before STRING[N].  */\n#if defined __USE_XOPEN2K8\nextern char *strndup(const char *__string, size_t __n)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n#if defined __USE_GNU && defined __GNUC__\n/* Duplicate S, returning an identical alloca'd string.  */\n# define strdupa(s)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strlen (__old) + 1;\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len);\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n\n/* Return an alloca'd copy of at most N bytes of string.  */\n# define strndupa(s, n)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strnlen (__old, (n));\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len + 1);\t\t      \\\n      __new[__len] = '\\0';\t\t\t\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Find the first occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strchr(char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strchr(const char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strchr(__s, __c);\n} __extern_always_inline const char *strchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strchr(__s, __c);\n}\n# endif\n}\n#else\nextern char *strchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n/* Find the last occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strrchr(char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strrchr(const char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strrchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strrchr(__s, __c);\n} __extern_always_inline const char *strrchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strrchr(__s, __c);\n}\n# endif\n}\n#else\nextern char *strrchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to `strchr'.  But it returns a pointer to\n   the closing NUL byte in case C is not found in S.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strchrnul(char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const char *strchrnul(const char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\n# else\nextern char *strchrnul(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the initial segment of S which\n   consists entirely of characters not in REJECT.  */\nextern size_t strcspn(const char *__s, const char *__reject)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Return the length of the initial segment of S which\n   consists entirely of characters in ACCEPT.  */\nextern size_t strspn(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Find the first occurrence in S of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strpbrk(char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strpbrk(const char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strpbrk(char *__s, const char *__accept) __THROW\n{\n\treturn __builtin_strpbrk(__s, __accept);\n} __extern_always_inline const char *strpbrk(const char *__s, const char *__accept) __THROW {\n\t\treturn __builtin_strpbrk(__s, __accept);\n}\n# endif\n}\n#else\nextern char *strpbrk(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strstr(char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strstr(const char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\n# ifdef __OPTIMIZE__\n\t__extern_always_inline char *strstr(char *__haystack, const char *__needle) __THROW\n{\n\treturn __builtin_strstr(__haystack, __needle);\n} __extern_always_inline const char *strstr(const char *__haystack, const char *__needle) __THROW {\n\t\treturn __builtin_strstr(__haystack, __needle);\n}\n# endif\n}\n#else\nextern char *strstr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n\n/* Divide S into tokens separated by characters in DELIM.  */\nextern char *strtok(char *__restrict __s, const char *__restrict __delim)\n__THROW __nonnull((2));\n__END_NAMESPACE_STD\n/* Divide S into tokens separated by characters in DELIM.  Information\n   passed between calls are stored in SAVE_PTR.  */\nextern char *__strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#ifdef __USE_POSIX\nextern char *strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#endif\n\n#ifdef __USE_GNU\n/* Similar to `strstr' but this function ignores the case of both strings.  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strcasestr(char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\nextern \"C++\" const char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\n# else\nextern char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n# endif\n#endif\n\n#ifdef __USE_GNU\n/* Find the first occurrence of NEEDLE in HAYSTACK.\n   NEEDLE is NEEDLELEN bytes long;\n   HAYSTACK is HAYSTACKLEN bytes long.  */\nextern void *memmem(const void *__haystack, size_t __haystacklen, const void *__needle, size_t __needlelen)\n__THROW __attribute_pure__ __nonnull((1, 3));\n\n/* Copy N bytes of SRC to DEST, return pointer to bytes after the\n   last written byte.  */\nextern void *__mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern void *mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of S.  */\nextern size_t strlen(const char *__s)\n__THROW __attribute_pure__ __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* Find the length of STRING, but scan at most MAXLEN characters.\n   If no '\\0' terminator is found in that many characters, return MAXLEN.  */\nextern size_t strnlen(const char *__string, size_t __maxlen)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return a string describing the meaning of the `errno' code in ERRNUM.  */\nextern char *strerror(int __errnum) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K\n/* Reentrant version of `strerror'.\n   There are 2 flavors of `strerror_r', GNU which returns the string\n   and may or may not use the supplied temporary buffer and POSIX one\n   which fills the string into the buffer.\n   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L\n   without -D_GNU_SOURCE is needed, otherwise the GNU version is\n   preferred.  */\n# if defined __USE_XOPEN2K && !defined __USE_GNU\n/* Fill BUF with a string describing the meaning of the `errno' code in\n   ERRNUM.  */\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(strerror_r, (int __errnum, char *__buf, size_t __buflen), __xpg_strerror_r) __nonnull((2));\n#  else\nextern int __xpg_strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n#   define strerror_r __xpg_strerror_r\n#  endif\n# else\n/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be\n   used.  */\nextern char *strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Translate error number to string according to the locale L.  */\nextern char *strerror_l(int __errnum, __locale_t __l) __THROW;\n#endif\n\n/* We define this function always since `bzero' is sometimes needed when\n   the namespace rules does not allow this.  */\nextern void __bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */\nextern void bcopy(const void *__src, void *__dest, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Set N bytes of S to 0.  */\nextern void bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n/* Compare N bytes of S1 and S2 (same as memcmp).  */\nextern int bcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Find the first occurrence of C in S (same as strchr).  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *index(char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\textern const char *index(const char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\n#  if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO\n\t__extern_always_inline char *index(char *__s, int __c) __THROW\n{\n\treturn __builtin_index(__s, __c);\n} __extern_always_inline const char *index(const char *__s, int __c) __THROW {\n\t\treturn __builtin_index(__s, __c);\n}\n#  endif\n}\n# else\nextern char *index(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n\n/* Find the last occurrence of C in S (same as strrchr).  */\n# ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *rindex(char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\textern const char *rindex(const char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\n#  if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO\n\t__extern_always_inline char *rindex(char *__s, int __c) __THROW\n{\n\treturn __builtin_rindex(__s, __c);\n} __extern_always_inline const char *rindex(const char *__s, int __c) __THROW {\n\t\treturn __builtin_rindex(__s, __c);\n}\n#endif\n}\n# else\nextern char *rindex(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n# endif\n\n/* Return the position of the first bit set in I, or 0 if none are set.\n   The least-significant bit is position 1, the most-significant 32.  */\nextern int ffs(int __i)\n__THROW __attribute__ ((__const__));\n\n/* The following two functions are non-standard but necessary for non-32 bit\n   platforms.  */\n# ifdef\t__USE_GNU\nextern int ffsl(long int __l)\n__THROW __attribute__ ((__const__));\n__extension__ extern int ffsll(long long int __ll)\n__THROW __attribute__ ((__const__));\n# endif\n\n/* Compare S1 and S2, ignoring case.  */\nextern int strcasecmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int strncasecmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef\t__USE_GNU\n/* Again versions of a few functions which use the given locale instead\n   of the global one.  */\nextern int strcasecmp_l(const char *__s1, const char *__s2, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n\nextern int strncasecmp_l(const char *__s1, const char *__s2, size_t __n, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 4));\n#endif\n\n#ifdef\t__USE_MISC\n/* Return the next DELIM-delimited token from *STRINGP,\n   terminating it with a '\\0', and update *STRINGP to point past it.  */\nextern char *strsep(char **__restrict __stringp, const char *__restrict __delim)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_XOPEN2K8\n/* Return a string describing the meaning of the signal number in SIG.  */\nextern char *strsignal(int __sig) __THROW;\n\n/* Copy SRC to DEST, returning the address of the terminating '\\0' in DEST.  */\nextern char *__stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\nextern char *stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern char *__stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern char *stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_GNU\n/* Compare S1 and S2 as strings holding name & indices/version numbers.  */\nextern int strverscmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Sautee STRING briskly.  */\nextern char *strfry(char *__string)\n__THROW __nonnull((1));\n\n/* Frobnicate N bytes of S.  */\nextern void *memfrob(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n# ifndef basename\n/* Return the file name within directory of FILENAME.  We don't\n   declare the function if the `basename' macro is available (defined\n   in <libgen.h>) which makes the XPG version of this function\n   available.  */\n#  ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *basename(char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\nextern \"C++\" const char *basename(const char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\n#  else\nextern char *basename(const char *__filename)\n__THROW __nonnull((1));\n#  endif\n# endif\n#endif\n\n#if defined __GNUC__ && __GNUC__ >= 2\n# if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \\\n     && !defined __NO_INLINE__ && !defined __cplusplus\n/* When using GNU CC we provide some optimized versions of selected\n   functions from this header.  There are two kinds of optimizations:\n\n   - machine-dependent optimizations, most probably using inline\n     assembler code; these might be quite expensive since the code\n     size can increase significantly.\n     These optimizations are not used unless the symbol\n\t__USE_STRING_INLINES\n     is defined before including this header.\n\n   - machine-independent optimizations which do not increase the\n     code size significantly and which optimize mainly situations\n     where one or more arguments are compile-time constants.\n     These optimizations are used always when the compiler is\n     taught to optimize.\n\n   One can inhibit all optimizations by defining __NO_STRING_INLINES.  */\n\n/* Get the machine-dependent optimizations (if any).  */\n#  include <bits/string.h>\n\n/* These are generic optimizations which do not add too much inline code.  */\n#  include <bits/string2.h>\n# endif\n\n# if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n/* Functions with security checks.  */\n#  include <bits/string3.h>\n# endif\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* string.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/strings.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STRINGS_H\n#define\t_STRINGS_H\t1\n\n/* We don't need and should not read this file if <string.h> was already\n   read. The one exception being that if __USE_MISC isn't defined, then\n   these aren't defined in string.h, so we need to define them here.  */\n#if !defined _STRING_H || !defined __USE_MISC\n\n# include <features.h>\n# define __need_size_t\n# include <stddef.h>\n\n/* Tell the caller that we provide correct C++ prototypes.  */\n# if defined __cplusplus && __GNUC_PREREQ (4, 4)\n#  define __CORRECT_ISO_CPP_STRINGS_H_PROTO\n# endif\n\n__BEGIN_DECLS\n# if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Compare N bytes of S1 and S2 (same as memcmp).  */\nextern int bcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__;\n\n/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */\nextern void bcopy(const void *__src, void *__dest, size_t __n) __THROW;\n\n/* Set N bytes of S to 0.  */\nextern void bzero(void *__s, size_t __n) __THROW;\n\n/* Find the first occurrence of C in S (same as strchr).  */\n#  ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *index(char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\textern const char *index(const char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\n#   if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO\n\t__extern_always_inline char *index(char *__s, int __c) __THROW\n{\n\treturn __builtin_index(__s, __c);\n} __extern_always_inline const char *index(const char *__s, int __c) __THROW {\n\t\treturn __builtin_index(__s, __c);\n}\n#   endif\n}\n#  else\nextern char *index(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#  endif\n\n/* Find the last occurrence of C in S (same as strrchr).  */\n#  ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *rindex(char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\textern const char *rindex(const char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\n#   if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO\n\t__extern_always_inline char *rindex(char *__s, int __c) __THROW\n{\n\treturn __builtin_rindex(__s, __c);\n} __extern_always_inline const char *rindex(const char *__s, int __c) __THROW {\n\t\treturn __builtin_rindex(__s, __c);\n}\n#   endif\n}\n#  else\nextern char *rindex(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#  endif\n# endif\n\n#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI\n/* Return the position of the first bit set in I, or 0 if none are set.\n   The least-significant bit is position 1, the most-significant 32.  */\nextern int ffs(int __i)\n__THROW __attribute__ ((const));\n#endif\n\n/* Compare S1 and S2, ignoring case.  */\nextern int strcasecmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__;\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int strncasecmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__;\n\n#ifdef\t__USE_XOPEN2K8\n/* The following functions are equivalent to the both above but they\n   take the locale they use for the collation as an extra argument.\n   This is not standardsized but something like will come.  */\n# include <xlocale.h>\n\n/* Again versions of a few functions which use the given locale instead\n   of the global one.  */\nextern int strcasecmp_l(const char *__s1, const char *__s2, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n\nextern int strncasecmp_l(const char *__s1, const char *__s2, size_t __n, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 4));\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* string.h  */\n#endif\t\t\t\t/* strings.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/cdefs.h",
    "content": "/* Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_CDEFS_H\n#define\t_SYS_CDEFS_H\t1\n\n/* We are almost always included from features.h. */\n#ifndef _FEATURES_H\n# include <features.h>\n#endif\n\n/* The GNU libc does not support any K&R compilers or the traditional mode\n   of ISO C compilers anymore.  Check for some of the combinations not\n   anymore supported.  */\n#if defined __GNUC__ && !defined __STDC__\n# error \"You need a ISO C conforming compiler to use the glibc headers\"\n#endif\n\n/* Some user header file might have defined this before.  */\n#undef\t__P\n#undef\t__PMT\n\n#ifdef __GNUC__\n\n/* All functions, except those with callbacks or those that\n   synchronize memory, are leaf functions.  */\n# if __GNUC_PREREQ (4, 6) && !defined _LIBC\n#  define __LEAF , __leaf__\n#  define __LEAF_ATTR __attribute__ ((__leaf__))\n# else\n#  define __LEAF\n#  define __LEAF_ATTR\n# endif\n\n/* GCC can always grok prototypes.  For C++ programs we add throw()\n   to help it optimize the function calls.  But this works only with\n   gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions\n   as non-throwing using a function attribute since programs can use\n   the -fexceptions options for C code as well.  */\n# if !defined __cplusplus && __GNUC_PREREQ (3, 3)\n#  define __THROW\t__attribute__ ((__nothrow__ __LEAF))\n#  define __THROWNL\t__attribute__ ((__nothrow__))\n#  define __NTH(fct)\t__attribute__ ((__nothrow__ __LEAF)) fct\n# else\n#  if defined __cplusplus && __GNUC_PREREQ (2,8)\n#   define __THROW\tthrow ()\n#   define __THROWNL\tthrow ()\n#   define __NTH(fct)\t__LEAF_ATTR fct throw ()\n#  else\n#   define __THROW\n#   define __THROWNL\n#   define __NTH(fct)\tfct\n#  endif\n# endif\n\n#else\t\t\t\t/* Not GCC.  */\n\n# define __inline\t\t/* No inline functions.  */\n\n# define __THROW\n# define __THROWNL\n# define __NTH(fct)\tfct\n\n#endif\t\t\t\t/* GCC.  */\n\n/* These two macros are not used in glibc anymore.  They are kept here\n   only because some other projects expect the macros to be defined.  */\n#define __P(args)\targs\n#define __PMT(args)\targs\n\n/* For these things, GCC behaves the ANSI way normally,\n   and the non-ANSI way under -traditional.  */\n\n#define __CONCAT(x,y)\tx ## y\n#define __STRING(x)\t#x\n\n/* This is not a typedef so `const __ptr_t' does the right thing.  */\n#define __ptr_t void *\n#define __long_double_t  long double\n\n/* C++ needs to know that types and declarations are C, not C++.  */\n#ifdef\t__cplusplus\n# define __BEGIN_DECLS\textern \"C\" {\n# define __END_DECLS\t}\n#else\n# define __BEGIN_DECLS\n# define __END_DECLS\n#endif\n\n/* The standard library needs the functions from the ISO C90 standard\n   in the std namespace.  At the same time we want to be safe for\n   future changes and we include the ISO C99 code in the non-standard\n   namespace __c99.  The C++ wrapper header take case of adding the\n   definitions to the global namespace.  */\n#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES\n# define __BEGIN_NAMESPACE_STD\tnamespace std {\n# define __END_NAMESPACE_STD\t}\n# define __USING_NAMESPACE_STD(name) using std::name;\n# define __BEGIN_NAMESPACE_C99\tnamespace __c99 {\n# define __END_NAMESPACE_C99\t}\n# define __USING_NAMESPACE_C99(name) using __c99::name;\n#else\n/* For compatibility we do not add the declarations into any\n   namespace.  They will end up in the global namespace which is what\n   old code expects.  */\n# define __BEGIN_NAMESPACE_STD\n# define __END_NAMESPACE_STD\n# define __USING_NAMESPACE_STD(name)\n# define __BEGIN_NAMESPACE_C99\n# define __END_NAMESPACE_C99\n# define __USING_NAMESPACE_C99(name)\n#endif\n\n/* Fortify support.  */\n#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)\n#define __bos0(ptr) __builtin_object_size (ptr, 0)\n\n#if __GNUC_PREREQ (4,3)\n# define __warndecl(name, msg) \\\n  extern void name (void) __attribute__((__warning__ (msg)))\n# define __warnattr(msg) __attribute__((__warning__ (msg)))\n# define __errordecl(name, msg) \\\n  extern void name (void) __attribute__((__error__ (msg)))\n#else\n# define __warndecl(name, msg) extern void name (void)\n# define __warnattr(msg)\n# define __errordecl(name, msg) extern void name (void)\n#endif\n\n/* Support for flexible arrays.  */\n#if __GNUC_PREREQ (2,97)\n/* GCC 2.97 supports C99 flexible array members.  */\n# define __flexarr\t[]\n#else\n# ifdef __GNUC__\n#  define __flexarr\t[0]\n# else\n#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#   define __flexarr\t[]\n#  else\n/* Some other non-C99 compiler.  Approximate with [1].  */\n#   define __flexarr\t[1]\n#  endif\n# endif\n#endif\n\n/* __asm__ (\"xyz\") is used throughout the headers to rename functions\n   at the assembly language level.  This is wrapped by the __REDIRECT\n   macro, in order to support compilers that can do this some other\n   way.  When compilers don't support asm-names at all, we have to do\n   preprocessor tricks instead (which don't have exactly the right\n   semantics, but it's the best we can do).\n\n   Example:\n   int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */\n\n#if defined __GNUC__ && __GNUC__ >= 2\n\n# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))\n# ifdef __cplusplus\n#  define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __THROW __asm__ (__ASMNAME (#alias))\n#  define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __THROWNL __asm__ (__ASMNAME (#alias))\n# else\n#  define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROW\n#  define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROWNL\n# endif\n# define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n# define __ASMNAME2(prefix, cname) __STRING (prefix) cname\n\n/*\n#elif __SOME_OTHER_COMPILER__\n\n# define __REDIRECT(name, proto, alias) name proto; \\\n\t_Pragma(\"let \" #name \" = \" #alias)\n*/\n#endif\n\n/* GCC has various useful declarations that can be made with the\n   `__attribute__' syntax.  All of the ways we use this do fine if\n   they are omitted for compilers that don't understand it. */\n#if !defined __GNUC__ || __GNUC__ < 2\n# define __attribute__(xyz)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.96 development the `malloc' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n# define __attribute_malloc__ __attribute__ ((__malloc__))\n#else\n# define __attribute_malloc__\t/* Ignore */\n#endif\n\n/* Tell the compiler which arguments to an allocation function\n   indicate the size of the allocation.  */\n#if __GNUC_PREREQ (4, 3)\n# define __attribute_alloc_size__(params) \\\n  __attribute__ ((__alloc_size__ params))\n#else\n# define __attribute_alloc_size__(params)\t/* Ignore.  */\n#endif\n\n/* At some point during the gcc 2.96 development the `pure' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n# define __attribute_pure__ __attribute__ ((__pure__))\n#else\n# define __attribute_pure__\t/* Ignore */\n#endif\n\n/* This declaration tells the compiler that the value is constant.  */\n#if __GNUC_PREREQ (2,5)\n# define __attribute_const__ __attribute__ ((__const__))\n#else\n# define __attribute_const__\t/* Ignore */\n#endif\n\n/* At some point during the gcc 3.1 development the `used' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (3,1)\n# define __attribute_used__ __attribute__ ((__used__))\n# define __attribute_noinline__ __attribute__ ((__noinline__))\n#else\n# define __attribute_used__ __attribute__ ((__unused__))\n# define __attribute_noinline__\t/* Ignore */\n#endif\n\n/* gcc allows marking deprecated functions.  */\n#if __GNUC_PREREQ (3,2)\n# define __attribute_deprecated__ __attribute__ ((__deprecated__))\n#else\n# define __attribute_deprecated__\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.8 development the `format_arg' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.\n   If several `format_arg' attributes are given for the same function, in\n   gcc-3.0 and older, all but the last one are ignored.  In newer gccs,\n   all designated arguments are considered.  */\n#if __GNUC_PREREQ (2,8)\n# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))\n#else\n# define __attribute_format_arg__(x)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.97 development the `strfmon' format\n   attribute for functions was introduced.  We don't want to use it\n   unconditionally (although this would be possible) since it\n   generates warnings.  */\n#if __GNUC_PREREQ (2,97)\n# define __attribute_format_strfmon__(a,b) \\\n  __attribute__ ((__format__ (__strfmon__, a, b)))\n#else\n# define __attribute_format_strfmon__(a,b)\t/* Ignore */\n#endif\n\n/* The nonull function attribute allows to mark pointer parameters which\n   must not be NULL.  */\n#if __GNUC_PREREQ (3,3)\n# define __nonnull(params) __attribute__ ((__nonnull__ params))\n#else\n# define __nonnull(params)\n#endif\n\n/* If fortification mode, we warn about unused results of certain\n   function calls which can lead to problems.  */\n#if __GNUC_PREREQ (3,4)\n# define __attribute_warn_unused_result__ \\\n   __attribute__ ((__warn_unused_result__))\n# if __USE_FORTIFY_LEVEL > 0\n#  define __wur __attribute_warn_unused_result__\n# endif\n#else\n# define __attribute_warn_unused_result__\t/* empty */\n#endif\n#ifndef __wur\n# define __wur\t\t\t/* Ignore */\n#endif\n\n/* Forces a function to be always inlined.  */\n#if __GNUC_PREREQ (3,2)\n# define __always_inline __inline __attribute__ ((__always_inline__))\n#else\n# define __always_inline __inline\n#endif\n\n/* Associate error messages with the source location of the call site rather\n   than with the source location inside the function.  */\n#if __GNUC_PREREQ (4,3)\n# define __attribute_artificial__ __attribute__ ((__artificial__))\n#else\n# define __attribute_artificial__\t/* Ignore */\n#endif\n\n/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99\n   inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__\n   or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions\n   older than 4.3 may define these macros and still not guarantee GNU inlining\n   semantics.\n\n   clang++ identifies itself as gcc-4.2, but has support for GNU inlining\n   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and\n   __GNUC_GNU_INLINE__ macro definitions.  */\n#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \\\n     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \\\n\t\t\t       || defined __GNUC_GNU_INLINE__)))\n# if defined __GNUC_STDC_INLINE__ || defined __cplusplus\n#  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))\n#  define __extern_always_inline \\\n  extern __always_inline __attribute__ ((__gnu_inline__))\n# else\n#  define __extern_inline extern __inline\n#  define __extern_always_inline extern __always_inline\n# endif\n#endif\n\n#ifdef __extern_always_inline\n# define __fortify_function __extern_always_inline __attribute_artificial__\n#endif\n\n/* GCC 4.3 and above allow passing all anonymous arguments of an\n   __extern_always_inline function to some other vararg function.  */\n#if __GNUC_PREREQ (4,3)\n# define __va_arg_pack() __builtin_va_arg_pack ()\n# define __va_arg_pack_len() __builtin_va_arg_pack_len ()\n#endif\n\n/* It is possible to compile containing GCC extensions even if GCC is\n   run in pedantic mode if the uses are carefully marked using the\n   `__extension__' keyword.  But this is not generally available before\n   version 2.8.  */\n#if !__GNUC_PREREQ (2,8)\n# define __extension__\t\t/* Ignore */\n#endif\n\n/* __restrict is known in EGCS 1.2 and above. */\n#if !__GNUC_PREREQ (2,92)\n# define __restrict\t\t/* Ignore */\n#endif\n\n/* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is\n     array_name[restrict]\n   GCC 3.1 supports this.  */\n#if __GNUC_PREREQ (3,1) && !defined __GNUG__\n# define __restrict_arr\t__restrict\n#else\n# ifdef __GNUC__\n#  define __restrict_arr\t/* Not supported in old GCC.  */\n# else\n#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#   define __restrict_arr\trestrict\n#  else\n/* Some other non-C99 compiler.  */\n#   define __restrict_arr\t/* Not supported.  */\n#  endif\n# endif\n#endif\n\n#if __GNUC__ >= 3\n# define __glibc_unlikely(cond)\t__builtin_expect ((cond), 0)\n# define __glibc_likely(cond)\t__builtin_expect ((cond), 1)\n#else\n# define __glibc_unlikely(cond)\t(cond)\n# define __glibc_likely(cond)\t(cond)\n#endif\n\n#if (!defined _Noreturn \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     &&  !__GNUC_PREREQ (4,7))\n# if __GNUC_PREREQ (2,8)\n#  define _Noreturn __attribute__ ((__noreturn__))\n# else\n#  define _Noreturn\n# endif\n#endif\n\n#if (!defined _Static_assert && !defined __cplusplus \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))\n# define _Static_assert(expr, diagnostic) \\\n    extern int (*__Static_assert_function (void)) \\\n      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]\n#endif\n\n#include <bits/wordsize.h>\n\n#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH\n# define __LDBL_COMPAT 1\n# ifdef __REDIRECT\n#  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)\n#  define __LDBL_REDIR(name, proto) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##name)\n#  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)\n#  define __LDBL_REDIR_NTH(name, proto) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)\n#  define __LDBL_REDIR1_DECL(name, alias) \\\n  extern __typeof (name) name __asm (__ASMNAME (#alias));\n#  define __LDBL_REDIR_DECL(name) \\\n  extern __typeof (name) name __asm (__ASMNAME (\"__nldbl_\" #name));\n#  define __REDIRECT_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##alias)\n#  define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)\n# endif\n#endif\n#if !defined __LDBL_COMPAT || !defined __REDIRECT\n# define __LDBL_REDIR1(name, proto, alias) name proto\n# define __LDBL_REDIR(name, proto) name proto\n# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW\n# define __LDBL_REDIR_NTH(name, proto) name proto __THROW\n# define __LDBL_REDIR_DECL(name)\n# ifdef __REDIRECT\n#  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)\n#  define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __REDIRECT_NTH (name, proto, alias)\n# endif\n#endif\n\n#endif\t\t\t\t/* sys/cdefs.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/file.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_FILE_H\n#define\t_SYS_FILE_H\t1\n\n#include <features.h>\n\n#ifndef\t_FCNTL_H\n# include <fcntl.h>\n#endif\n\n__BEGIN_DECLS\n/* Alternate names for values for the WHENCE argument to `lseek'.\n   These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively.  */\n#ifndef L_SET\n# define L_SET\t0\t\t/* Seek from beginning of file.  */\n# define L_INCR\t1\t\t/* Seek from current position.  */\n# define L_XTND\t2\t\t/* Seek from end of file.  */\n#endif\n/* Operations for the `flock' call.  */\n#define\tLOCK_SH\t1\t\t/* Shared lock.  */\n#define\tLOCK_EX\t2\t\t/* Exclusive lock.  */\n#define\tLOCK_UN\t8\t\t/* Unlock.  */\n/* Can be OR'd in to one of the above.  */\n#define\tLOCK_NB\t4\t\t/* Don't block when locking.  */\n/* Apply or remove an advisory lock, according to OPERATION,\n   on the file FD refers to.  */\nextern int flock(int __fd, int __operation) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/file.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/ioctl.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_IOCTL_H\n#define\t_SYS_IOCTL_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get the list of `ioctl' requests and related constants.  */\n#include <bits/ioctls.h>\n/* Define some types used by `ioctl' requests.  */\n#include <bits/ioctl-types.h>\n/* On a Unix system, the system <sys/ioctl.h> probably defines some of\n   the symbols we define in <sys/ttydefaults.h> (usually with the same\n   values).  The code to generate <bits/ioctls.h> has omitted these\n   symbols to avoid the conflict, but a Unix program expects <sys/ioctl.h>\n   to define them, so we must include <sys/ttydefaults.h> here.  */\n#include <sys/ttydefaults.h>\n/* Perform the I/O control operation specified by REQUEST on FD.\n   One argument may follow; its presence and type depend on REQUEST.\n   Return value depends on REQUEST.  Usually -1 indicates error.  */\nextern int ioctl(int __fd, unsigned long int __request, ...) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/ioctl.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/mman.h",
    "content": "/* Definitions for BSD-style memory management.\n   Copyright (C) 1994-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_MMAN_H\n#define\t_SYS_MMAN_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#include <bits/mman.h>\n\n/* Return value of `mmap' in case of an error.  */\n#define MAP_FAILED\t((void *) -1)\n\n__BEGIN_DECLS\n/* Map addresses starting near ADDR and extending for LEN bytes.  from\n   OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR\n   is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is\n   set in FLAGS, the mapping will be at ADDR exactly (which must be\n   page-aligned); otherwise the system chooses a convenient nearby address.\n   The return value is the actual mapping address chosen or MAP_FAILED\n   for errors (in which case `errno' is set).  A successful `mmap' call\n   deallocates any previous mapping for the affected region.  */\n#ifndef __USE_FILE_OFFSET64\nextern void *mmap(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern void *__REDIRECT_NTH(mmap, (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset), mmap64);\n# else\n#  define mmap mmap64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern void *mmap64(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) __THROW;\n#endif\n\n/* Deallocate any mapping for the region starting at ADDR and extending LEN\n   bytes.  Returns 0 if successful, -1 for errors (and sets errno).  */\nextern int munmap(void *__addr, size_t __len) __THROW;\n\n/* Change the memory protection of the region starting at ADDR and\n   extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors\n   (and sets errno).  */\nextern int mprotect(void *__addr, size_t __len, int __prot) __THROW;\n\n/* Synchronize the region starting at ADDR and extending LEN bytes with the\n   file it maps.  Filesystem operations on a file being mapped are\n   unpredictable before this is done.  Flags are from the MS_* set.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int msync(void *__addr, size_t __len, int __flags);\n\n#ifdef __USE_MISC\n/* Advise the system about particular usage patterns the program follows\n   for the region starting at ADDR and extending LEN bytes.  */\nextern int madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n#ifdef __USE_XOPEN2K\n/* This is the POSIX name for this function.  */\nextern int posix_madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n\n/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to\n   be memory resident.  */\nextern int mlock(const void *__addr, size_t __len) __THROW;\n\n/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN).  */\nextern int munlock(const void *__addr, size_t __len) __THROW;\n\n/* Cause all currently mapped pages of the process to be memory resident\n   until unlocked by a call to the `munlockall', until the process exits,\n   or until the process calls `execve'.  */\nextern int mlockall(int __flags) __THROW;\n\n/* All currently mapped pages of the process' address space become\n   unlocked.  */\nextern int munlockall(void) __THROW;\n\n#ifdef __USE_MISC\n/* mincore returns the memory residency status of the pages in the\n   current process's address space specified by [start, start + len).\n   The status is returned in a vector of bytes.  The least significant\n   bit of each byte is 1 if the referenced page is in memory, otherwise\n   it is zero.  */\nextern int mincore(void *__start, size_t __len, unsigned char *__vec) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length\n   NEW_LEN.  If MREMAP_MAYMOVE is set in FLAGS the returned address\n   may differ from ADDR.  If MREMAP_FIXED is set in FLAGS the function\n   takes another parameter which is a fixed address at which the block\n   resides after a successful call.  */\nextern void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...) __THROW;\n\n/* Remap arbitrary pages of a shared backing store within an existing\n   VMA.  */\nextern int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags) __THROW;\n#endif\n\n/* Open shared memory segment.  */\nextern int shm_open(const char *__name, int __oflag, mode_t __mode);\n\n/* Remove shared memory segment.  */\nextern int shm_unlink(const char *__name);\n\n__END_DECLS\n#endif\t\t\t\t/* sys/mman.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/param.h",
    "content": "/* Compatibility header for old-style Unix parameters and limits.\n   Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n#define _SYS_PARAM_H    1\n\n#define __need_NULL\n#include <stddef.h>\n\n#include <sys/types.h>\n#include <limits.h>\n#include <endian.h>\t\t/* Define BYTE_ORDER et al.  */\n#include <signal.h>\t\t/* Define NSIG.  */\n\n/* This file defines some things in system-specific ways.  */\n#include <bits/param.h>\n\n/* BSD names for some <limits.h> values.  */\n\n#define NBBY\t\tCHAR_BIT\n\n#if !defined NGROUPS && defined NGROUPS_MAX\n# define NGROUPS\tNGROUPS_MAX\n#endif\n#if !defined MAXSYMLINKS && defined SYMLOOP_MAX\n# define MAXSYMLINKS\tSYMLOOP_MAX\n#endif\n#if !defined CANBSIZ && defined MAX_CANON\n# define CANBSIZ\tMAX_CANON\n#endif\n#if !defined MAXPATHLEN && defined PATH_MAX\n# define MAXPATHLEN\tPATH_MAX\n#endif\n#if !defined NOFILE && defined OPEN_MAX\n# define NOFILE\t\tOPEN_MAX\n#endif\n#ifndef NCARGS\n# ifdef ARG_MAX\n#  define NCARGS\tARG_MAX\n# else\n/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to\n   compare against some fixed limit.  */\n# define NCARGS\t\tINT_MAX\n# endif\n#endif\n\n/* Magical constants.  */\n#ifndef NOGROUP\n# define NOGROUP\t65535\t/* Marker for empty group set member.  */\n#endif\n#ifndef NODEV\n# define NODEV\t\t((dev_t) -1)\t/* Non-existent device.  */\n#endif\n\n/* Unit of `st_blocks'.  */\n#ifndef DEV_BSIZE\n# define DEV_BSIZE\t512\n#endif\n\n/* Bit map related macros.  */\n#define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))\n#define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))\n#define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))\n#define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)\n\n/* Macros for counting and rounding.  */\n#ifndef howmany\n# define howmany(x, y)  (((x) + ((y) - 1)) / (y))\n#endif\n#ifdef __GNUC__\n# define roundup(x, y)  (__builtin_constant_p (y) && powerof2 (y)             \\\n                         ? (((x) + (y) - 1) & ~((y) - 1))                     \\\n                         : ((((x) + ((y) - 1)) / (y)) * (y)))\n#else\n# define roundup(x, y)  ((((x) + ((y) - 1)) / (y)) * (y))\n#endif\n#define powerof2(x)     ((((x) - 1) & (x)) == 0)\n\n/* Macros for min/max.  */\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#define MAX(a,b) (((a)>(b))?(a):(b))\n\n#endif\t\t\t\t/* sys/param.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/resource.h",
    "content": "/* Copyright (C) 1992-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_RESOURCE_H\n#define\t_SYS_RESOURCE_H\t1\n\n#include <features.h>\n\n/* Get the system-dependent definitions of structures and bit values.  */\n#include <bits/resource.h>\n\n#ifndef __id_t_defined\ntypedef __id_t id_t;\n# define __id_t_defined\n#endif\n\n__BEGIN_DECLS\n/* The X/Open standard defines that all the functions below must use\n   `int' as the type for the first argument.  When we are compiling with\n   GNU extensions we change this slightly to provide better error\n   checking.  */\n#if defined __USE_GNU && !defined __cplusplus\ntypedef enum __rlimit_resource __rlimit_resource_t;\ntypedef enum __rusage_who __rusage_who_t;\ntypedef enum __priority_which __priority_which_t;\n#else\ntypedef int __rlimit_resource_t;\ntypedef int __rusage_who_t;\ntypedef int __priority_which_t;\n#endif\n\n/* Put the soft and hard limits for RESOURCE in *RLIMITS.\n   Returns 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int getrlimit(__rlimit_resource_t __resource, struct rlimit *__rlimits) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(getrlimit, (__rlimit_resource_t __resource, struct rlimit * __rlimits), getrlimit64);\n# else\n#  define getrlimit getrlimit64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int getrlimit64(__rlimit_resource_t __resource, struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Set the soft and hard limits for RESOURCE to *RLIMITS.\n   Only the super-user can increase hard limits.\n   Return 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int setrlimit(__rlimit_resource_t __resource, const struct rlimit *__rlimits) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(setrlimit, (__rlimit_resource_t __resource, const struct rlimit * __rlimits), setrlimit64);\n# else\n#  define setrlimit setrlimit64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int setrlimit64(__rlimit_resource_t __resource, const struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Return resource usage information on process indicated by WHO\n   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */\nextern int getrusage(__rusage_who_t __who, struct rusage *__usage) __THROW;\n\n/* Return the highest priority of any process specified by WHICH and WHO\n   (see above); if WHO is zero, the current process, process group, or user\n   (as specified by WHO) is used.  A lower priority number means higher\n   priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */\nextern int getpriority(__priority_which_t __which, id_t __who) __THROW;\n\n/* Set the priority of all processes specified by WHICH and WHO (see above)\n   to PRIO.  Returns 0 on success, -1 on errors.  */\nextern int setpriority(__priority_which_t __which, id_t __who, int __prio) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/resource.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/select.h",
    "content": "/* `fd_set' type and related macros, and `select'/`pselect' declarations.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\tPOSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h>  */\n\n#ifndef _SYS_SELECT_H\n#define _SYS_SELECT_H\t1\n\n#include <features.h>\n\n/* Get definition of needed basic types.  */\n#include <bits/types.h>\n\n/* Get __FD_* definitions.  */\n#include <bits/select.h>\n\n/* Get __sigset_t.  */\n#include <bits/sigset.h>\n\n#ifndef __sigset_t_defined\n# define __sigset_t_defined\ntypedef __sigset_t sigset_t;\n#endif\n\n/* Get definition of timer specification structures.  */\n#define __need_time_t\n#define __need_timespec\n#include <time.h>\n#define __need_timeval\n#include <bits/time.h>\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n# define __suseconds_t_defined\n#endif\n\n/* The fd_set member is required to be an array of longs.  */\ntypedef long int __fd_mask;\n\n/* Some versions of <linux/posix_types.h> define this macros.  */\n#undef\t__NFDBITS\n/* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */\n#define __NFDBITS\t(8 * (int) sizeof (__fd_mask))\n#define\t__FD_ELT(d)\t((d) / __NFDBITS)\n#define\t__FD_MASK(d)\t((__fd_mask) (1UL << ((d) % __NFDBITS)))\n\n/* fd_set for select and pselect.  */\ntypedef struct {\n\t/* XPG4.2 requires this member name.  Otherwise avoid the name\n\t   from the global namespace.  */\n#ifdef __USE_XOPEN\n\t__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];\n# define __FDS_BITS(set) ((set)->fds_bits)\n#else\n\t__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];\n# define __FDS_BITS(set) ((set)->__fds_bits)\n#endif\n} fd_set;\n\n/* Maximum number of file descriptors in `fd_set'.  */\n#define\tFD_SETSIZE\t\t__FD_SETSIZE\n\n#ifdef __USE_MISC\n/* Sometimes the fd_set member is assumed to have this type.  */\ntypedef __fd_mask fd_mask;\n\n/* Number of bits per word of `fd_set' (some code assumes this is 32).  */\n# define NFDBITS\t\t__NFDBITS\n#endif\n\n/* Access macros for `fd_set'.  */\n#define\tFD_SET(fd, fdsetp)\t__FD_SET (fd, fdsetp)\n#define\tFD_CLR(fd, fdsetp)\t__FD_CLR (fd, fdsetp)\n#define\tFD_ISSET(fd, fdsetp)\t__FD_ISSET (fd, fdsetp)\n#define\tFD_ZERO(fdsetp)\t\t__FD_ZERO (fdsetp)\n\n__BEGIN_DECLS\n/* Check the first NFDS descriptors each in READFDS (if not NULL) for read\n   readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS\n   (if not NULL) for exceptional conditions.  If TIMEOUT is not NULL, time out\n   after waiting the interval specified therein.  Returns the number of ready\n   descriptors, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int select(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, struct timeval *__restrict __timeout);\n\n#ifdef __USE_XOPEN2K\n/* Same as above only that the TIMEOUT value is given with higher\n   resolution and a sigmask which is been set temporarily.  This version\n   should be used.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pselect(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t * __restrict __sigmask);\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__\n# include <bits/select2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/select.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/socket.h",
    "content": "/* Declarations of socket constants, types, and functions.\n   Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_SOCKET_H\n#define\t_SYS_SOCKET_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <sys/uio.h>\n#define\t__need_size_t\n#include <stddef.h>\n#ifdef __USE_GNU\n/* Get the __sigset_t definition.  */\n# include <bits/sigset.h>\n#endif\n/* This operating system-specific header file defines the SOCK_*, PF_*,\n   AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',\n   `struct msghdr', and `struct linger' types.  */\n#include <bits/socket.h>\n#ifdef __USE_MISC\n/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire\n   format in the grotty old 4.3 `talk' protocol.  */\n    struct osockaddr {\n\tunsigned short int sa_family;\n\tunsigned char sa_data[14];\n};\n#endif\n\n/* The following constants should be used for the second parameter of\n   `shutdown'.  */\nenum {\n\tSHUT_RD = 0,\t\t/* No more receptions.  */\n#define SHUT_RD\t\tSHUT_RD\n\tSHUT_WR,\t\t/* No more transmissions.  */\n#define SHUT_WR\t\tSHUT_WR\n\tSHUT_RDWR\t\t/* No more receptions or transmissions.  */\n#define SHUT_RDWR\tSHUT_RDWR\n};\n\n/* This is the type we use for generic socket address arguments.\n\n   With GCC 2.7 and later, the funky union causes redeclarations or\n   uses with any of the listed types to be allowed without complaint.\n   G++ 2.7 does not support transparent unions so there we want the\n   old-style declaration, too.  */\n#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU\n# define __SOCKADDR_ARG\t\tstruct sockaddr *__restrict\n# define __CONST_SOCKADDR_ARG\tconst struct sockaddr *\n#else\n/* Add more `struct sockaddr_AF' types here as necessary.\n   These are all the ones I found on NetBSD and Linux.  */\n# define __SOCKADDR_ALLTYPES \\\n  __SOCKADDR_ONETYPE (sockaddr) \\\n  __SOCKADDR_ONETYPE (sockaddr_at) \\\n  __SOCKADDR_ONETYPE (sockaddr_ax25) \\\n  __SOCKADDR_ONETYPE (sockaddr_dl) \\\n  __SOCKADDR_ONETYPE (sockaddr_eon) \\\n  __SOCKADDR_ONETYPE (sockaddr_in) \\\n  __SOCKADDR_ONETYPE (sockaddr_in6) \\\n  __SOCKADDR_ONETYPE (sockaddr_inarp) \\\n  __SOCKADDR_ONETYPE (sockaddr_ipx) \\\n  __SOCKADDR_ONETYPE (sockaddr_iso) \\\n  __SOCKADDR_ONETYPE (sockaddr_ns) \\\n  __SOCKADDR_ONETYPE (sockaddr_un) \\\n  __SOCKADDR_ONETYPE (sockaddr_x25)\n\n# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __SOCKADDR_ARG __attribute__ ((__transparent_union__));\n# undef __SOCKADDR_ONETYPE\n# define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));\n# undef __SOCKADDR_ONETYPE\n#endif\n\n#ifdef __USE_GNU\n/* For `recvmmsg' and `sendmmsg'.  */\nstruct mmsghdr {\n\tstruct msghdr msg_hdr;\t/* Actual message header.  */\n\tunsigned int msg_len;\t/* Number of received or sent bytes for the\n\t\t\t\t   entry.  */\n};\n#endif\n\n/* Create a new socket of type TYPE in domain DOMAIN, using\n   protocol PROTOCOL.  If PROTOCOL is zero, one is chosen automatically.\n   Returns a file descriptor for the new socket, or -1 for errors.  */\nextern int socket(int __domain, int __type, int __protocol) __THROW;\n\n/* Create two new sockets, of type TYPE in domain DOMAIN and using\n   protocol PROTOCOL, which are connected to each other, and put file\n   descriptors for them in FDS[0] and FDS[1].  If PROTOCOL is zero,\n   one will be chosen automatically.  Returns 0 on success, -1 for errors.  */\nextern int socketpair(int __domain, int __type, int __protocol, int __fds[2]) __THROW;\n\n/* Give the socket FD the local address ADDR (which is LEN bytes long).  */\nextern int bind(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) __THROW;\n\n/* Put the local address of FD into *ADDR and its length in *LEN.  */\nextern int getsockname(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).\n   For connectionless socket types, just set the default address to send to\n   and the only address from which to accept transmissions.\n   Return 0 on success, -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int connect(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);\n\n/* Put the address of the peer connected to socket FD into *ADDR\n   (which is *LEN bytes long), and its actual length into *LEN.  */\nextern int getpeername(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Send N bytes of BUF to socket FD.  Returns the number sent or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t send(int __fd, const void *__buf, size_t __n, int __flags);\n\n/* Read N bytes into BUF from socket FD.\n   Returns the number read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recv(int __fd, void *__buf, size_t __n, int __flags);\n\n/* Send N bytes of BUF on socket FD to peer at address ADDR (which is\n   ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendto(int __fd, const void *__buf, size_t __n, int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);\n\n/* Read N bytes into BUF through socket FD.\n   If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of\n   the sender, and store the actual size of the address in *ADDR_LEN.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvfrom(int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n/* Send a message described MESSAGE on socket FD.\n   Returns the number of bytes sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendmsg(int __fd, const struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Send a VLEN messages as described by VMESSAGES to socket FD.\n   Returns the number of datagrams successfully written or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sendmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags);\n#endif\n\n/* Receive a message as described by MESSAGE from socket FD.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Receive up to VLEN messages as described by VMESSAGES from socket FD.\n   Returns the number of messages received or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int recvmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, struct timespec *__tmo);\n#endif\n\n/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL\n   into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's\n   actual length.  Returns 0 on success, -1 for errors.  */\nextern int getsockopt(int __fd, int __level, int __optname, void *__restrict __optval, socklen_t * __restrict __optlen) __THROW;\n\n/* Set socket FD's option OPTNAME at protocol level LEVEL\n   to *OPTVAL (which is OPTLEN bytes long).\n   Returns 0 on success, -1 for errors.  */\nextern int setsockopt(int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) __THROW;\n\n/* Prepare to accept connections on socket FD.\n   N connection requests will be queued before further requests are refused.\n   Returns 0 on success, -1 for errors.  */\nextern int listen(int __fd, int __n) __THROW;\n\n/* Await a connection on socket FD.\n   When a connection arrives, open a new socket to communicate with it,\n   set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting\n   peer and *ADDR_LEN to the address's actual length, and return the\n   new socket's descriptor, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n#ifdef __USE_GNU\n/* Similar to 'accept' but takes an additional parameter to specify flags.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept4(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len, int __flags);\n#endif\n\n/* Shut down all or part of the connection open on socket FD.\n   HOW determines what to shut down:\n     SHUT_RD   = No more receptions;\n     SHUT_WR   = No more transmissions;\n     SHUT_RDWR = No more receptions or transmissions.\n   Returns 0 on success, -1 for errors.  */\nextern int shutdown(int __fd, int __how) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Determine wheter socket is at a out-of-band mark.  */\nextern int sockatmark(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;\n   returns 1 if FD is open on an object of the indicated type, 0 if not,\n   or -1 for errors (setting errno).  */\nextern int isfdtype(int __fd, int __fdtype) __THROW;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/socket2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/stat.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6 File Characteristics\t<sys/stat.h>\n */\n\n#ifndef\t_SYS_STAT_H\n#define\t_SYS_STAT_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\t\t/* For __mode_t and __dev_t.  */\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K || defined __USE_ATFILE\n# if defined __USE_XOPEN || defined __USE_XOPEN2K\n#  define __need_time_t\n# endif\n# ifdef __USE_ATFILE\n#  define __need_timespec\n# endif\n# include <time.h>\t\t/* For time_t resp. timespec.  */\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n# ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n#  define __dev_t_defined\n# endif\n\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __ino_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#  else\ntypedef __ino64_t ino_t;\n#  endif\n#  define __ino_t_defined\n# endif\n\n# ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#  define __mode_t_defined\n# endif\n\n# ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n#  define __nlink_t_defined\n# endif\n\n# ifndef __off_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#  else\ntypedef __off64_t off_t;\n#  endif\n#  define __off_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n#endif\t\t\t\t/* X/Open */\n\n#ifdef __USE_UNIX98\n# ifndef __blkcnt_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __blkcnt_t blkcnt_t;\n#  else\ntypedef __blkcnt64_t blkcnt_t;\n#  endif\n#  define __blkcnt_t_defined\n# endif\n\n# ifndef __blksize_t_defined\ntypedef __blksize_t blksize_t;\n#  define __blksize_t_defined\n# endif\n#endif\t\t\t\t/* Unix98 */\n\n__BEGIN_DECLS\n#include <bits/stat.h>\n#if defined __USE_MISC || defined __USE_XOPEN\n# define S_IFMT\t\t__S_IFMT\n# define S_IFDIR\t__S_IFDIR\n# define S_IFCHR\t__S_IFCHR\n# define S_IFBLK\t__S_IFBLK\n# define S_IFREG\t__S_IFREG\n# ifdef __S_IFIFO\n#  define S_IFIFO\t__S_IFIFO\n# endif\n# ifdef __S_IFLNK\n#  define S_IFLNK\t__S_IFLNK\n# endif\n# if (defined __USE_MISC || defined __USE_UNIX98) \\\n     && defined __S_IFSOCK\n#  define S_IFSOCK\t__S_IFSOCK\n# endif\n#endif\n/* Test macros for file types.\t*/\n#define\t__S_ISTYPE(mode, mask)\t(((mode) & __S_IFMT) == (mask))\n#define\tS_ISDIR(mode)\t __S_ISTYPE((mode), __S_IFDIR)\n#define\tS_ISCHR(mode)\t __S_ISTYPE((mode), __S_IFCHR)\n#define\tS_ISBLK(mode)\t __S_ISTYPE((mode), __S_IFBLK)\n#define\tS_ISREG(mode)\t __S_ISTYPE((mode), __S_IFREG)\n#ifdef __S_IFIFO\n# define S_ISFIFO(mode)\t __S_ISTYPE((mode), __S_IFIFO)\n#endif\n#ifdef __S_IFLNK\n# define S_ISLNK(mode)\t __S_ISTYPE((mode), __S_IFLNK)\n#endif\n#if defined __USE_MISC && !defined __S_IFLNK\n# define S_ISLNK(mode)  0\n#endif\n#if (defined __USE_UNIX98 || defined __USE_XOPEN2K) \\\n    && defined __S_IFSOCK\n# define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)\n#elif defined __USE_XOPEN2K\n# define S_ISSOCK(mode) 0\n#endif\n/* These are from POSIX.1b.  If the objects are not implemented using separate\n   distinct file types, the macros always will evaluate to zero.  Unlike the\n   other S_* macros the following three take a pointer to a `struct stat'\n   object as the argument.  */\n#ifdef\t__USE_POSIX199309\n# define S_TYPEISMQ(buf) __S_TYPEISMQ(buf)\n# define S_TYPEISSEM(buf) __S_TYPEISSEM(buf)\n# define S_TYPEISSHM(buf) __S_TYPEISSHM(buf)\n#endif\n/* Protection bits.  */\n#define\tS_ISUID __S_ISUID\t/* Set user ID on execution.  */\n#define\tS_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n# define S_ISVTX\t__S_ISVTX\n#endif\n#define\tS_IRUSR\t__S_IREAD\t/* Read by owner.  */\n#define\tS_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n#define\tS_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n#define\tS_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n#ifdef __USE_MISC\n# define S_IREAD\tS_IRUSR\n# define S_IWRITE\tS_IWUSR\n# define S_IEXEC\tS_IXUSR\n#endif\n#define\tS_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n#define\tS_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n#define\tS_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n#define\tS_IRWXG\t(S_IRWXU >> 3)\n#define\tS_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n#define\tS_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n#define\tS_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n#define\tS_IRWXO\t(S_IRWXG >> 3)\n#ifdef\t__USE_MISC\n/* Macros for common mode bit masks.  */\n# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)\t/* 0777 */\n# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\t/* 07777 */\n# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)\t/* 0666 */\n# define S_BLKSIZE\t512\t/* Block size for `st_blocks'.  */\n#endif\n#ifndef __USE_FILE_OFFSET64\n/* Get file attributes for FILE and put them in BUF.  */\nextern int stat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n\n/* Get file attributes for the file, device, pipe, or socket\n   that file descriptor FD is open on and put them in BUF.  */\nextern int fstat(int __fd, struct stat *__buf)\n__THROW __nonnull((2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(stat, (const char *__restrict __file, struct stat * __restrict __buf), stat64) __nonnull((1, 2));\nextern int __REDIRECT_NTH(fstat, (int __fd, struct stat * __buf), fstat64) __nonnull((2));\n# else\n#  define stat stat64\n#  define fstat fstat64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int stat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\nextern int fstat64(int __fd, struct stat64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to stat, get the attributes for FILE and put them in BUF.\n   Relative path names are interpreted relative to FD unless FD is\n   AT_FDCWD.  */\n# ifndef __USE_FILE_OFFSET64\nextern int fstatat(int __fd, const char *__restrict __file, struct stat *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatat, (int __fd, const char *__restrict __file, struct stat * __restrict __buf, int __flag), fstatat64) __nonnull((2, 3));\n#  else\n#   define fstatat fstatat64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\nextern int fstatat64(int __fd, const char *__restrict __file, struct stat64 *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n# endif\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n# ifndef __USE_FILE_OFFSET64\n/* Get file attributes about FILE and put them in BUF.\n   If FILE is a symbolic link, do not follow it.  */\nextern int lstat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(lstat, (const char *__restrict __file, struct stat * __restrict __buf), lstat64) __nonnull((1, 2));\n#  else\n#   define lstat lstat64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lstat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\n# endif\n#endif\n\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects its target instead.  */\nextern int chmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects the link itself\n   rather than its target.  */\nextern int lchmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n#endif\n\n/* Set file access permissions of the file FD is open on to MODE.  */\n#ifdef __USE_POSIX\nextern int fchmod(int __fd, __mode_t __mode) __THROW;\n#endif\n\n#ifdef __USE_ATFILE\n/* Set file access permissions of FILE relative to\n   the directory FD is open on.  */\nextern int fchmodat(int __fd, const char *__file, __mode_t __mode, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use ATFILE.  */\n\n/* Set the file creation mask of the current process to MASK,\n   and return the old creation mask.  */\nextern __mode_t umask(__mode_t __mask) __THROW;\n\n#ifdef\t__USE_GNU\n/* Get the current `umask' value without changing it.\n   This function is only available under the GNU Hurd.  */\nextern __mode_t getumask(void) __THROW;\n#endif\n\n/* Create a new directory named PATH, with permission bits MODE.  */\nextern int mkdir(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkdir, create a new directory with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkdirat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\n/* Create a device file named PATH, with permission and special bits MODE\n   and device number DEV (which can be constructed from major and minor\n   device numbers with the `makedev' macro above).  */\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\nextern int mknod(const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((1));\n\n# ifdef __USE_ATFILE\n/* Like mknod, create a new device file with permission bits MODE and\n   device number DEV.  But interpret relative PATH names relative to\n   the directory associated with FD.  */\nextern int mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((2));\n# endif\n#endif\n\n/* Create a new FIFO named PATH, with permission bits MODE.  */\nextern int mkfifo(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkfifo, create a new FIFO with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkfifoat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\f\n#ifdef __USE_ATFILE\n/* Set file access and modification times relative to directory file\n   descriptor.  */\nextern int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flags)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Set file access and modification times of the file associated with FD.  */\nextern int futimens(int __fd, const struct timespec __times[2]) __THROW;\n#endif\n\f\n/* To allow the `struct stat' structure and the file type `mode_t'\n   bits to vary without changing shared library major version number,\n   the `stat' family of functions and `mknod' are in fact inline\n   wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',\n   which all take a leading version-number argument designating the\n   data structure and bits used.  <bits/stat.h> defines _STAT_VER with\n   the version number corresponding to `struct stat' as defined in\n   that file; and _MKNOD_VER with the version number corresponding to\n   the S_IF* macros defined therein.  It is arranged that when not\n   inlined these function are always statically linked; that way a\n   dynamically-linked executable always encodes the version number\n   corresponding to the data structures it uses, so the `x' functions\n   in the shared library can adapt without needing to recompile all\n   callers.  */\n\n#ifndef _STAT_VER\n# define _STAT_VER\t0\n#endif\n#ifndef _MKNOD_VER\n# define _MKNOD_VER\t0\n#endif\n\n/* Wrappers for stat and mknod system calls.  */\n#ifndef __USE_FILE_OFFSET64\nextern int __fxstat(int __ver, int __fildes, struct stat *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat(int __ver, int __fildes, const char *__filename, struct stat *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(__fxstat, (int __ver, int __fildes, struct stat * __stat_buf), __fxstat64) __nonnull((3));\nextern int __REDIRECT_NTH(__xstat, (int __ver, const char *__filename, struct stat * __stat_buf), __xstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__lxstat, (int __ver, const char *__filename, struct stat * __stat_buf), __lxstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__fxstatat, (int __ver, int __fildes, const char *__filename, struct stat * __stat_buf, int __flag), __fxstatat64) __nonnull((3, 4));\n\n# else\n#  define __fxstat __fxstat64\n#  define __xstat __xstat64\n#  define __lxstat __lxstat64\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int __fxstat64(int __ver, int __fildes, struct stat64 *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat64(int __ver, int __fildes, const char *__filename, struct stat64 *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#endif\nextern int __xmknod(int __ver, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((2, 4));\n\nextern int __xmknodat(int __ver, int __fd, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((3, 5));\n\n#ifdef __USE_EXTERN_INLINES\n/* Inlined versions of the real stat and mknod functions.  */\n\n__extern_inline int __NTH(stat(const char *__path, struct stat *__statbuf))\n{\n\treturn __xstat(_STAT_VER, __path, __statbuf);\n}\n\n# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat(const char *__path, struct stat *__statbuf))\n{\n\treturn __lxstat(_STAT_VER, __path, __statbuf);\n}\n# endif\n\n__extern_inline int __NTH(fstat(int __fd, struct stat *__statbuf))\n{\n\treturn __fxstat(_STAT_VER, __fd, __statbuf);\n}\n\n# ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat(int __fd, const char *__filename, struct stat *__statbuf, int __flag))\n{\n\treturn __fxstatat(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n# endif\n\n# ifdef __USE_MISC\n__extern_inline int __NTH(mknod(const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknod(_MKNOD_VER, __path, __mode, &__dev);\n}\n# endif\n\n# ifdef __USE_ATFILE\n__extern_inline int __NTH(mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknodat(_MKNOD_VER, __fd, __path, __mode, &__dev);\n}\n# endif\n\n# if defined __USE_LARGEFILE64 \\\n  && (! defined __USE_FILE_OFFSET64 \\\n      || (defined __REDIRECT_NTH && defined __OPTIMIZE__))\n__extern_inline int __NTH(stat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __xstat64(_STAT_VER, __path, __statbuf);\n}\n\n#  if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __lxstat64(_STAT_VER, __path, __statbuf);\n}\n#  endif\n\n__extern_inline int __NTH(fstat64(int __fd, struct stat64 *__statbuf))\n{\n\treturn __fxstat64(_STAT_VER, __fd, __statbuf);\n}\n\n#  ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat64(int __fd, const char *__filename, struct stat64 *__statbuf, int __flag))\n{\n\treturn __fxstatat64(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n#  endif\n\n# endif\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/stat.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/statfs.h",
    "content": "/* Definitions for getting information about a filesystem.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_STATFS_H\n#define\t_SYS_STATFS_H\t1\n\n#include <features.h>\n\n/* Get the system-specific definition of `struct statfs'.  */\n#include <bits/statfs.h>\n\n__BEGIN_DECLS\n/* Return information about the filesystem on which FILE resides.  */\n#ifndef __USE_FILE_OFFSET64\nextern int statfs(const char *__file, struct statfs *__buf)\n__THROW __nonnull((1, 2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(statfs, (const char *__file, struct statfs * __buf), statfs64) __nonnull((1, 2));\n# else\n#  define statfs statfs64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int statfs64(const char *__file, struct statfs64 *__buf)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Return information about the filesystem containing the file FILDES\n   refers to.  */\n#ifndef __USE_FILE_OFFSET64\nextern int fstatfs(int __fildes, struct statfs *__buf)\n__THROW __nonnull((2));\n#else\n# ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatfs, (int __fildes, struct statfs * __buf), fstatfs64) __nonnull((2));\n# else\n#  define fstatfs fstatfs64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int fstatfs64(int __fildes, struct statfs64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/statfs.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/sysmacros.h",
    "content": "/* Definitions of macros to access `dev_t' values.\n   Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SYSMACROS_H\n#define _SYS_SYSMACROS_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS __extension__ extern unsigned int gnu_dev_major(unsigned long long int __dev)\n__THROW __attribute_const__;\n__extension__ extern unsigned int gnu_dev_minor(unsigned long long int __dev)\n__THROW __attribute_const__;\n__extension__ extern unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor)\n__THROW __attribute_const__;\n\n#ifdef __USE_EXTERN_INLINES\n__extension__ __extern_inline __attribute_const__ unsigned int __NTH(gnu_dev_major(unsigned long long int __dev))\n{\n\treturn ((__dev >> 8) & 0xfff) | ((unsigned int)(__dev >> 32) & ~0xfff);\n}\n\n__extension__ __extern_inline __attribute_const__ unsigned int __NTH(gnu_dev_minor(unsigned long long int __dev))\n{\n\treturn (__dev & 0xff) | ((unsigned int)(__dev >> 12) & ~0xff);\n}\n\n__extension__ __extern_inline __attribute_const__ unsigned long long int __NTH(gnu_dev_makedev(unsigned int __major, unsigned int __minor))\n{\n\treturn ((__minor & 0xff) | ((__major & 0xfff) << 8)\n\t\t| (((unsigned long long int)(__minor & ~0xff)) << 12)\n\t\t| (((unsigned long long int)(__major & ~0xfff)) << 32));\n}\n#endif\n__END_DECLS\n/* Access the functions with their traditional names.  */\n#define major(dev) gnu_dev_major (dev)\n#define minor(dev) gnu_dev_minor (dev)\n#define makedev(maj, min) gnu_dev_makedev (maj, min)\n#endif\t\t\t\t/* sys/sysmacros.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/time.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_TIME_H\n#define _SYS_TIME_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\n#define __need_time_t\n#include <time.h>\n#define __need_timeval\n#include <bits/time.h>\n\n#include <sys/select.h>\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n# define __suseconds_t_defined\n#endif\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Macros for converting between `struct timeval' and `struct timespec'.  */\n# define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \\\n\t(ts)->tv_sec = (tv)->tv_sec;                                    \\\n\t(ts)->tv_nsec = (tv)->tv_usec * 1000;                           \\\n}\n# define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \\\n\t(tv)->tv_sec = (ts)->tv_sec;                                    \\\n\t(tv)->tv_usec = (ts)->tv_nsec / 1000;                           \\\n}\n#endif\n#ifdef __USE_MISC\n/* Structure crudely representing a timezone.\n   This is obsolete and should never be used.  */\n    struct timezone {\n\tint tz_minuteswest;\t/* Minutes west of GMT.  */\n\tint tz_dsttime;\t\t/* Nonzero if DST is ever in effect.  */\n};\n\ntypedef struct timezone *__restrict __timezone_ptr_t;\n#else\ntypedef void *__restrict __timezone_ptr_t;\n#endif\n\n/* Get the current time of day and timezone information,\n   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.\n   Returns 0 on success, -1 on errors.\n   NOTE: This form of timezone information is obsolete.\n   Use the functions and variables declared in <time.h> instead.  */\nextern int gettimeofday(struct timeval *__restrict __tv, __timezone_ptr_t __tz)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set the current time of day and timezone information.\n   This call is restricted to the super-user.  */\nextern int settimeofday(const struct timeval *__tv, const struct timezone *__tz) __THROW;\n\n/* Adjust the current time of day by the amount in DELTA.\n   If OLDDELTA is not NULL, it is filled in with the amount\n   of time adjustment remaining to be done from the last `adjtime' call.\n   This call is restricted to the super-user.  */\nextern int adjtime(const struct timeval *__delta, struct timeval *__olddelta) __THROW;\n#endif\n\n/* Values for the first argument to `getitimer' and `setitimer'.  */\nenum __itimer_which {\n\t/* Timers run in real time.  */\n\tITIMER_REAL = 0,\n#define ITIMER_REAL ITIMER_REAL\n\t/* Timers run only when the process is executing.  */\n\tITIMER_VIRTUAL = 1,\n#define ITIMER_VIRTUAL ITIMER_VIRTUAL\n\t/* Timers run when the process is executing and when\n\t   the system is executing on behalf of the process.  */\n\tITIMER_PROF = 2\n#define ITIMER_PROF ITIMER_PROF\n};\n\n/* Type of the second argument to `getitimer' and\n   the second and third arguments `setitimer'.  */\nstruct itimerval {\n\t/* Value to put into `it_value' when the timer expires.  */\n\tstruct timeval it_interval;\n\t/* Time to the next timer expiration.  */\n\tstruct timeval it_value;\n};\n\n#if defined __USE_GNU && !defined __cplusplus\n/* Use the nicer parameter type only in GNU mode and not for C++ since the\n   strict C++ rules prevent the automatic promotion.  */\ntypedef enum __itimer_which __itimer_which_t;\n#else\ntypedef int __itimer_which_t;\n#endif\n\n/* Set *VALUE to the current setting of timer WHICH.\n   Return 0 on success, -1 on errors.  */\nextern int getitimer(__itimer_which_t __which, struct itimerval *__value) __THROW;\n\n/* Set the timer WHICH to *NEW.  If OLD is not NULL,\n   set *OLD to the old value of timer WHICH.\n   Returns 0 on success, -1 on errors.  */\nextern int setitimer(__itimer_which_t __which, const struct itimerval *__restrict __new, struct itimerval *__restrict __old) __THROW;\n\n/* Change the access time of FILE to TVP[0] and the modification time of\n   FILE to TVP[1].  If TVP is a null pointer, use the current time instead.\n   Returns 0 on success, -1 on errors.  */\nextern int utimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Same as `utimes', but does not follow symbolic links.  */\nextern int lutimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n/* Same as `utimes', but takes an open file descriptor instead of a name.  */\nextern int futimes(int __fd, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Change the access time of FILE relative to FD to TVP[0] and the\n   modification time of FILE to TVP[1].  If TVP is a null pointer, use\n   the current time instead.  Returns 0 on success, -1 on errors.  */\nextern int futimesat(int __fd, const char *__file, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Convenience macros for operations on timevals.\n   NOTE: `timercmp' does not work for >= or <=.  */\n# define timerisset(tvp)\t((tvp)->tv_sec || (tvp)->tv_usec)\n# define timerclear(tvp)\t((tvp)->tv_sec = (tvp)->tv_usec = 0)\n# define timercmp(a, b, CMP) \t\t\t\t\t\t      \\\n  (((a)->tv_sec == (b)->tv_sec) ? \t\t\t\t\t      \\\n   ((a)->tv_usec CMP (b)->tv_usec) : \t\t\t\t\t      \\\n   ((a)->tv_sec CMP (b)->tv_sec))\n# define timeradd(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec >= 1000000)\t\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t++(result)->tv_sec;\t\t\t\t\t\t      \\\n\t(result)->tv_usec -= 1000000;\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n# define timersub(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec < 0) {\t\t\t\t\t      \\\n      --(result)->tv_sec;\t\t\t\t\t\t      \\\n      (result)->tv_usec += 1000000;\t\t\t\t\t      \\\n    }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n#endif\t\t\t\t/* Misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/time.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/times.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 4.5.2 Process Times\t<sys/times.h>\n */\n\n#ifndef\t_SYS_TIMES_H\n#define\t_SYS_TIMES_H\t1\n\n#include <features.h>\n\n#define\t__need_clock_t\n#include <time.h>\n\n__BEGIN_DECLS\n/* Structure describing CPU time used by a process and its children.  */\n    struct tms {\n\tclock_t tms_utime;\t/* User CPU time.  */\n\tclock_t tms_stime;\t/* System CPU time.  */\n\n\tclock_t tms_cutime;\t/* User CPU time of dead children.  */\n\tclock_t tms_cstime;\t/* System CPU time of dead children.  */\n};\n\n/* Store the CPU time used by this process and all its\n   dead children (and their dead children) in BUFFER.\n   Return the elapsed real time, or (clock_t) -1 for errors.\n   All times are in CLK_TCKths of a second.  */\nextern clock_t times(struct tms *__buffer) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/times.h   */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/ttydefaults.h",
    "content": "/*-\n * Copyright (c) 1982, 1986, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n * (c) UNIX System Laboratories, Inc.\n * All or some portions of this file are derived from material licensed\n * to the University of California by American Telephone and Telegraph\n * Co. or Unix System Laboratories, Inc. and are reproduced herein with\n * the permission of UNIX System Laboratories, Inc.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)ttydefaults.h\t8.4 (Berkeley) 1/21/94\n */\n\n/*\n * System wide defaults for terminal state.  Linux version.\n */\n#ifndef _SYS_TTYDEFAULTS_H_\n#define\t_SYS_TTYDEFAULTS_H_\n\n/*\n * Defaults on \"first\" open.\n */\n#define\tTTYDEF_IFLAG\t(BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)\n#define TTYDEF_OFLAG\t(OPOST | ONLCR | XTABS)\n#define TTYDEF_LFLAG\t(ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)\n#define TTYDEF_CFLAG\t(CREAD | CS7 | PARENB | HUPCL)\n#define TTYDEF_SPEED\t(B9600)\n\n/*\n * Control Character Defaults\n */\n#define CTRL(x)\t(x&037)\n#define\tCEOF\t\tCTRL('d')\n#ifdef _POSIX_VDISABLE\n# define CEOL\t\t_POSIX_VDISABLE\n#else\n# define CEOL\t\t'\\0'\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCERASE\t\t0177\n#define\tCINTR\t\tCTRL('c')\n#ifdef _POSIX_VDISABLE\n# define CSTATUS\t_POSIX_VDISABLE\n#else\n# define CSTATUS\t'\\0'\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCKILL\t\tCTRL('u')\n#define\tCMIN\t\t1\n#define\tCQUIT\t\t034\t/* FS, ^\\ */\n#define\tCSUSP\t\tCTRL('z')\n#define\tCTIME\t\t0\n#define\tCDSUSP\t\tCTRL('y')\n#define\tCSTART\t\tCTRL('q')\n#define\tCSTOP\t\tCTRL('s')\n#define\tCLNEXT\t\tCTRL('v')\n#define\tCDISCARD \tCTRL('o')\n#define\tCWERASE \tCTRL('w')\n#define\tCREPRINT \tCTRL('r')\n#define\tCEOT\t\tCEOF\n/* compat */\n#define\tCBRK\t\tCEOL\n#define CRPRNT\t\tCREPRINT\n#define\tCFLUSH\t\tCDISCARD\n\n/* PROTECTED INCLUSION ENDS HERE */\n#endif\t\t\t\t/* !_SYS_TTYDEFAULTS_H_ */\n\n/*\n * #define TTYDEFCHARS to include an array of default control characters.\n */\n#ifdef TTYDEFCHARS\ncc_t ttydefchars[NCCS] = {\n\tCEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,\n\t_POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,\n\tCDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE\n};\n\n#undef TTYDEFCHARS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/types.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.6 Primitive System Data Types\t<sys/types.h>\n */\n\n#ifndef\t_SYS_TYPES_H\n#define\t_SYS_TYPES_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef\t__USE_MISC\n# ifndef __u_char_defined\ntypedef __u_char u_char;\ntypedef __u_short u_short;\ntypedef __u_int u_int;\ntypedef __u_long u_long;\ntypedef __quad_t quad_t;\ntypedef __u_quad_t u_quad_t;\ntypedef __fsid_t fsid_t;\n#  define __u_char_defined\n# endif\n#endif\n\ntypedef __loff_t loff_t;\n\n#ifndef __ino_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n# else\ntypedef __ino64_t ino_t;\n# endif\n# define __ino_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n# define __ino64_t_defined\n#endif\n\n#ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n# define __dev_t_defined\n#endif\n\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n# define __gid_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n# define __mode_t_defined\n#endif\n\n#ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n# define __nlink_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n# define __uid_t_defined\n#endif\n\n#ifndef __off_t_defined\n# ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n# else\ntypedef __off64_t off_t;\n# endif\n# define __off_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n# define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n# define __pid_t_defined\n#endif\n\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \\\n    && !defined __id_t_defined\ntypedef __id_t id_t;\n# define __id_t_defined\n#endif\n\n#ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n#endif\n\n#ifdef\t__USE_MISC\n# ifndef __daddr_t_defined\ntypedef __daddr_t daddr_t;\ntypedef __caddr_t caddr_t;\n#  define __daddr_t_defined\n# endif\n#endif\n\n#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined\ntypedef __key_t key_t;\n# define __key_t_defined\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# define __need_clock_t\n#endif\n#define\t__need_time_t\n#define __need_timer_t\n#define __need_clockid_t\n#include <time.h>\n\n#ifdef __USE_XOPEN\n# ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#  define __useconds_t_defined\n# endif\n# ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n#  define __suseconds_t_defined\n# endif\n#endif\n\n#define\t__need_size_t\n#include <stddef.h>\n\n#ifdef __USE_MISC\n/* Old compatibility names for C types.  */\ntypedef unsigned long int ulong;\ntypedef unsigned short int ushort;\ntypedef unsigned int uint;\n#endif\n\n/* These size-specific names are used by some of the inet code.  */\n\n#if !__GNUC_PREREQ (2, 7)\n\n/* These types are defined by the ISO C99 header <inttypes.h>. */\n# ifndef __int8_t_defined\n#  define __int8_t_defined\ntypedef char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\n#  if __WORDSIZE == 64\ntypedef long int int64_t;\n#  else\n__extension__ typedef long long int int64_t;\n#  endif\n# endif\n\n/* But these were defined by ISO C without the first `_'.  */\ntypedef unsigned char u_int8_t;\ntypedef unsigned short int u_int16_t;\ntypedef unsigned int u_int32_t;\n# if __WORDSIZE == 64\ntypedef unsigned long int u_int64_t;\n# else\n__extension__ typedef unsigned long long int u_int64_t;\n# endif\n\ntypedef int register_t;\n\n#else\n\n/* For GCC 2.7 and later, we can use specific type-size attributes.  */\n# define __intN_t(N, MODE) \\\n  typedef int int##N##_t __attribute__ ((__mode__ (MODE)))\n# define __u_intN_t(N, MODE) \\\n  typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))\n\n# ifndef __int8_t_defined\n#  define __int8_t_defined\n__intN_t(8, __QI__);\n__intN_t(16, __HI__);\n__intN_t(32, __SI__);\n__intN_t(64, __DI__);\n# endif\n\n__u_intN_t(8, __QI__);\n__u_intN_t(16, __HI__);\n__u_intN_t(32, __SI__);\n__u_intN_t(64, __DI__);\n\ntypedef int register_t __attribute__ ((__mode__(__word__)));\n\n/* Some code from BIND tests this macro to see if the types above are\n   defined.  */\n#endif\n#define __BIT_TYPES_DEFINED__\t1\n\n#ifdef\t__USE_MISC\n/* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */\n# include <endian.h>\n\n/* It also defines `fd_set' and the FD_* macros for `select'.  */\n# include <sys/select.h>\n\n/* BSD defines these symbols, so we follow.  */\n# include <sys/sysmacros.h>\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \\\n    && !defined __blksize_t_defined\ntypedef __blksize_t blksize_t;\n# define __blksize_t_defined\n#endif\n\n/* Types from the Large File Support interface.  */\n#ifndef __USE_FILE_OFFSET64\n# ifndef __blkcnt_t_defined\ntypedef __blkcnt_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#  define __blkcnt_t_defined\n# endif\n# ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#  define __fsblkcnt_t_defined\n# endif\n# ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#  define __fsfilcnt_t_defined\n# endif\n#else\n# ifndef __blkcnt_t_defined\ntypedef __blkcnt64_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#  define __blkcnt_t_defined\n# endif\n# ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt64_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#  define __fsblkcnt_t_defined\n# endif\n# ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt64_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#  define __fsfilcnt_t_defined\n# endif\n#endif\n\n#ifdef __USE_LARGEFILE64\ntypedef __blkcnt64_t blkcnt64_t;\t/* Type to count number of disk blocks. */\ntypedef __fsblkcnt64_t fsblkcnt64_t;\t/* Type to count file system blocks.  */\ntypedef __fsfilcnt64_t fsfilcnt64_t;\t/* Type to count file system inodes.  */\n#endif\n\n/* Now add the thread types.  */\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n# include <bits/pthreadtypes.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/types.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/ucontext.h",
    "content": "/* Copyright (C) 2001-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UCONTEXT_H\n#define _SYS_UCONTEXT_H\t1\n\n#include <features.h>\n#include <signal.h>\n\n/* We need the signal context definitions even if they are not used\n   included in <signal.h>.  */\n#include <bits/sigcontext.h>\n\n#ifdef __x86_64__\n\n/* Type for general register.  */\n__extension__ typedef long long int greg_t;\n\n/* Number of general registers.  */\n#define NGREG\t23\n\n/* Container for all general registers.  */\ntypedef greg_t gregset_t[NGREG];\n\n#ifdef __USE_GNU\n/* Number of each register in the `gregset_t' array.  */\nenum {\n\tREG_R8 = 0,\n# define REG_R8\t\tREG_R8\n\tREG_R9,\n# define REG_R9\t\tREG_R9\n\tREG_R10,\n# define REG_R10\tREG_R10\n\tREG_R11,\n# define REG_R11\tREG_R11\n\tREG_R12,\n# define REG_R12\tREG_R12\n\tREG_R13,\n# define REG_R13\tREG_R13\n\tREG_R14,\n# define REG_R14\tREG_R14\n\tREG_R15,\n# define REG_R15\tREG_R15\n\tREG_RDI,\n# define REG_RDI\tREG_RDI\n\tREG_RSI,\n# define REG_RSI\tREG_RSI\n\tREG_RBP,\n# define REG_RBP\tREG_RBP\n\tREG_RBX,\n# define REG_RBX\tREG_RBX\n\tREG_RDX,\n# define REG_RDX\tREG_RDX\n\tREG_RAX,\n# define REG_RAX\tREG_RAX\n\tREG_RCX,\n# define REG_RCX\tREG_RCX\n\tREG_RSP,\n# define REG_RSP\tREG_RSP\n\tREG_RIP,\n# define REG_RIP\tREG_RIP\n\tREG_EFL,\n# define REG_EFL\tREG_EFL\n\tREG_CSGSFS,\t\t/* Actually short cs, gs, fs, __pad0.  */\n# define REG_CSGSFS\tREG_CSGSFS\n\tREG_ERR,\n# define REG_ERR\tREG_ERR\n\tREG_TRAPNO,\n# define REG_TRAPNO\tREG_TRAPNO\n\tREG_OLDMASK,\n# define REG_OLDMASK\tREG_OLDMASK\n\tREG_CR2\n# define REG_CR2\tREG_CR2\n};\n#endif\n\nstruct _libc_fpxreg {\n\tunsigned short int significand[4];\n\tunsigned short int exponent;\n\tunsigned short int padding[3];\n};\n\nstruct _libc_xmmreg {\n\t__uint32_t element[4];\n};\n\nstruct _libc_fpstate {\n\t/* 64-bit FXSAVE format.  */\n\t__uint16_t cwd;\n\t__uint16_t swd;\n\t__uint16_t ftw;\n\t__uint16_t fop;\n\t__uint64_t rip;\n\t__uint64_t rdp;\n\t__uint32_t mxcsr;\n\t__uint32_t mxcr_mask;\n\tstruct _libc_fpxreg _st[8];\n\tstruct _libc_xmmreg _xmm[16];\n\t__uint32_t padding[24];\n};\n\n/* Structure to describe FPU registers.  */\ntypedef struct _libc_fpstate *fpregset_t;\n\n/* Context to describe whole processor state.  */\ntypedef struct {\n\tgregset_t gregs;\n\t/* Note that fpregs is a pointer.  */\n\tfpregset_t fpregs;\n\t__extension__ unsigned long long __reserved1[8];\n} mcontext_t;\n\n/* Userlevel context.  */\ntypedef struct ucontext {\n\tunsigned long int uc_flags;\n\tstruct ucontext *uc_link;\n\tstack_t uc_stack;\n\tmcontext_t uc_mcontext;\n\t__sigset_t uc_sigmask;\n\tstruct _libc_fpstate __fpregs_mem;\n} ucontext_t;\n\n#else\t\t\t\t/* !__x86_64__ */\n\n/* Type for general register.  */\ntypedef int greg_t;\n\n/* Number of general registers.  */\n#define NGREG\t19\n\n/* Container for all general registers.  */\ntypedef greg_t gregset_t[NGREG];\n\n#ifdef __USE_GNU\n/* Number of each register is the `gregset_t' array.  */\nenum {\n\tREG_GS = 0,\n# define REG_GS\t\tREG_GS\n\tREG_FS,\n# define REG_FS\t\tREG_FS\n\tREG_ES,\n# define REG_ES\t\tREG_ES\n\tREG_DS,\n# define REG_DS\t\tREG_DS\n\tREG_EDI,\n# define REG_EDI\tREG_EDI\n\tREG_ESI,\n# define REG_ESI\tREG_ESI\n\tREG_EBP,\n# define REG_EBP\tREG_EBP\n\tREG_ESP,\n# define REG_ESP\tREG_ESP\n\tREG_EBX,\n# define REG_EBX\tREG_EBX\n\tREG_EDX,\n# define REG_EDX\tREG_EDX\n\tREG_ECX,\n# define REG_ECX\tREG_ECX\n\tREG_EAX,\n# define REG_EAX\tREG_EAX\n\tREG_TRAPNO,\n# define REG_TRAPNO\tREG_TRAPNO\n\tREG_ERR,\n# define REG_ERR\tREG_ERR\n\tREG_EIP,\n# define REG_EIP\tREG_EIP\n\tREG_CS,\n# define REG_CS\t\tREG_CS\n\tREG_EFL,\n# define REG_EFL\tREG_EFL\n\tREG_UESP,\n# define REG_UESP\tREG_UESP\n\tREG_SS\n# define REG_SS\tREG_SS\n};\n#endif\n\n/* Definitions taken from the kernel headers.  */\nstruct _libc_fpreg {\n\tunsigned short int significand[4];\n\tunsigned short int exponent;\n};\n\nstruct _libc_fpstate {\n\tunsigned long int cw;\n\tunsigned long int sw;\n\tunsigned long int tag;\n\tunsigned long int ipoff;\n\tunsigned long int cssel;\n\tunsigned long int dataoff;\n\tunsigned long int datasel;\n\tstruct _libc_fpreg _st[8];\n\tunsigned long int status;\n};\n\n/* Structure to describe FPU registers.  */\ntypedef struct _libc_fpstate *fpregset_t;\n\n/* Context to describe whole processor state.  */\ntypedef struct {\n\tgregset_t gregs;\n\t/* Due to Linux's history we have to use a pointer here.  The SysV/i386\n\t   ABI requires a struct with the values.  */\n\tfpregset_t fpregs;\n\tunsigned long int oldmask;\n\tunsigned long int cr2;\n} mcontext_t;\n\n/* Userlevel context.  */\ntypedef struct ucontext {\n\tunsigned long int uc_flags;\n\tstruct ucontext *uc_link;\n\tstack_t uc_stack;\n\tmcontext_t uc_mcontext;\n\t__sigset_t uc_sigmask;\n\tstruct _libc_fpstate __fpregs_mem;\n} ucontext_t;\n\n#endif\t\t\t\t/* !__x86_64__ */\n\n#endif\t\t\t\t/* sys/ucontext.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/uio.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UIO_H\n#define _SYS_UIO_H\t1\n\n#include <features.h>\n\n#include <sys/types.h>\n\n__BEGIN_DECLS\n/* This file defines `struct iovec'.  */\n#include <bits/uio.h>\n/* Read data from file descriptor FD, and put the result in the\n   buffers described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.\n   Operates just like 'read' (see <unistd.h>) except that data are\n   put in IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t readv(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which\n   is a vector of COUNT 'struct iovec's, to file descriptor FD.\n   The data is written in the order specified.\n   Operates just like 'write' (see <unistd.h>) except that the data\n   are taken from IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t writev(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n#ifdef __USE_MISC\n# ifndef __USE_FILE_OFFSET64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n# else\n#  ifdef __REDIRECT\nextern ssize_t __REDIRECT(preadv, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), preadv64) __wur;\nextern ssize_t __REDIRECT(pwritev, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), pwritev64) __wur;\n#  else\n#   define preadv preadv64\n#   define pwritev pwritev64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n# endif\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/uio.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/un.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_UN_H\n#define\t_SYS_UN_H\t1\n\n#include <sys/cdefs.h>\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n__BEGIN_DECLS\n/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket.  */\n    struct sockaddr_un {\n\t__SOCKADDR_COMMON(sun_);\n\tchar sun_path[108];\t/* Path name.  */\n};\n\n#ifdef __USE_MISC\n# include <string.h>\t\t/* For prototype of `strlen'.  */\n\n/* Evaluate to actual length of the `sockaddr_un' structure.  */\n# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)\t      \\\n\t\t      + strlen ((ptr)->sun_path))\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/un.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/utsname.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 4.4 System Identification\t<sys/utsname.h>\n */\n\n#ifndef\t_SYS_UTSNAME_H\n#define\t_SYS_UTSNAME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/utsname.h>\n#ifndef _UTSNAME_SYSNAME_LENGTH\n# define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_NODENAME_LENGTH\n# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_RELEASE_LENGTH\n# define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_VERSION_LENGTH\n# define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_MACHINE_LENGTH\n# define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH\n#endif\n/* Structure describing the system and machine.  */\n    struct utsname {\n\t/* Name of the implementation of the operating system.  */\n\tchar sysname[_UTSNAME_SYSNAME_LENGTH];\n\n\t/* Name of this node on the network.  */\n\tchar nodename[_UTSNAME_NODENAME_LENGTH];\n\n\t/* Current release level of this implementation.  */\n\tchar release[_UTSNAME_RELEASE_LENGTH];\n\t/* Current version level of this release.  */\n\tchar version[_UTSNAME_VERSION_LENGTH];\n\n\t/* Name of the hardware type the system is running on.  */\n\tchar machine[_UTSNAME_MACHINE_LENGTH];\n\n#if _UTSNAME_DOMAIN_LENGTH - 0\n\t/* Name of the domain of this node on the network.  */\n# ifdef __USE_GNU\n\tchar domainname[_UTSNAME_DOMAIN_LENGTH];\n# else\n\tchar __domainname[_UTSNAME_DOMAIN_LENGTH];\n# endif\n#endif\n};\n\n#ifdef __USE_MISC\n/* Note that SVID assumes all members have the same size.  */\n# define SYS_NMLN  _UTSNAME_LENGTH\n#endif\n\n/* Put information about the system in NAME.  */\nextern int uname(struct utsname *__name) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/utsname.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/sys/wait.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 3.2.1 Wait for Process Termination\t<sys/wait.h>\n */\n\n#ifndef\t_SYS_WAIT_H\n#define\t_SYS_WAIT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <signal.h>\n/* These macros could also be defined in <stdlib.h>.  */\n#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)\n/* This will define the `W*' macros for the flag\n   bits to `waitpid', `wait3', and `wait4'.  */\n# include <bits/waitflags.h>\n# ifdef\t__USE_MISC\n/* Lots of hair to allow traditional BSD use of `union wait'\n   as well as POSIX.1 use of `int' for the status word.  */\n#  if defined __GNUC__ && !defined __cplusplus\n#   define __WAIT_INT(status) \\\n  (__extension__ (((union { __typeof(status) __in; int __i; }) \\\n\t\t   { .__in = (status) }).__i))\n#  else\n#   define __WAIT_INT(status)\t(*(const int *) &(status))\n#  endif\n/* This is the type of the argument to `wait'.  The funky union\n   causes redeclarations with either `int *' or `union wait *' to be\n   allowed without complaint.  __WAIT_STATUS_DEFN is the type used in\n   the actual function definitions.  */\n#  if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus\n#   define __WAIT_STATUS\tvoid *\n#   define __WAIT_STATUS_DEFN\tvoid *\n#  else\n/* This works in GCC 2.6.1 and later.  */\n    typedef union {\n\tunion wait *__uptr;\n\tint *__iptr;\n} __WAIT_STATUS __attribute__ ((__transparent_union__));\n#   define __WAIT_STATUS_DEFN\tint *\n#  endif\n\n# else\t\t\t\t/* Don't use misc.  */\n#  define __WAIT_INT(status)\t(status)\n#  define __WAIT_STATUS\t\tint *\n#  define __WAIT_STATUS_DEFN\tint *\n# endif\t\t\t\t/* Use misc.  */\n/* This will define all the `__W*' macros.  */\n# include <bits/waitstatus.h>\n# define WEXITSTATUS(status)\t__WEXITSTATUS (__WAIT_INT (status))\n# define WTERMSIG(status)\t__WTERMSIG (__WAIT_INT (status))\n# define WSTOPSIG(status)\t__WSTOPSIG (__WAIT_INT (status))\n# define WIFEXITED(status)\t__WIFEXITED (__WAIT_INT (status))\n# define WIFSIGNALED(status)\t__WIFSIGNALED (__WAIT_INT (status))\n# define WIFSTOPPED(status)\t__WIFSTOPPED (__WAIT_INT (status))\n# ifdef __WIFCONTINUED\n#  define WIFCONTINUED(status)\t__WIFCONTINUED (__WAIT_INT (status))\n# endif\n#endif\t\t\t\t/* <stdlib.h> not included.  */\n#ifdef\t__USE_MISC\n# define WCOREFLAG\t\t__WCOREFLAG\n# define WCOREDUMP(status)\t__WCOREDUMP (__WAIT_INT (status))\n# define W_EXITCODE(ret, sig)\t__W_EXITCODE (ret, sig)\n# define W_STOPCODE(sig)\t__W_STOPCODE (sig)\n#endif\n/* The following values are used by the `waitid' function.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n    typedef enum {\n\tP_ALL,\t\t\t/* Wait for any child.  */\n\tP_PID,\t\t\t/* Wait for specified process.  */\n\tP_PGID\t\t\t/* Wait for members of process group.  */\n} idtype_t;\n#endif\n\n/* Wait for a child to die.  When one does, put its status in *STAT_LOC\n   and return its process ID.  For errors, return (pid_t) -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t wait(__WAIT_STATUS __stat_loc);\n\n#ifdef\t__USE_MISC\n/* Special values for the PID argument to `waitpid' and `wait4'.  */\n# define WAIT_ANY\t(-1)\t/* Any process.  */\n# define WAIT_MYPGRP\t0\t/* Any process in my process group.  */\n#endif\n\n/* Wait for a child matching PID to die.\n   If PID is greater than 0, match any process whose process ID is PID.\n   If PID is (pid_t) -1, match any process.\n   If PID is (pid_t) 0, match any process with the\n   same process group as the current process.\n   If PID is less than -1, match any process whose\n   process group is the absolute value of PID.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, return (pid_t) 0.  If successful,\n   return PID and store the dead child's status in STAT_LOC.\n   Return (pid_t) -1 for errors.  If the WUNTRACED bit is\n   set in OPTIONS, return status for stopped children; otherwise don't.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t waitpid(__pid_t __pid, int *__stat_loc, int __options);\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n# ifndef __id_t_defined\n#  include <bits/types.h>\ntypedef __id_t id_t;\n#  define __id_t_defined\n# endif\n\n# define __need_siginfo_t\n# include <bits/siginfo.h>\n\n/* Wait for a childing matching IDTYPE and ID to change the status and\n   place appropriate information in *INFOP.\n   If IDTYPE is P_PID, match any process whose process ID is ID.\n   If IDTYPE is P_PGID, match any process whose process group is ID.\n   If IDTYPE is P_ALL, match any process.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, clear *INFOP and return 0.  If successful, store\n   exit code and status in *INFOP.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int waitid(idtype_t __idtype, __id_t __id, siginfo_t * __infop, int __options);\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* This being here makes the prototypes valid whether or not\n   we have already included <sys/resource.h> to define `struct rusage'.  */\nstruct rusage;\n\n/* Wait for a child to exit.  When one does, put its status in *STAT_LOC and\n   return its process ID.  For errors return (pid_t) -1.  If USAGE is not\n   nil, store information about the child's resource usage there.  If the\n   WUNTRACED bit is set in OPTIONS, return status for stopped children;\n   otherwise don't.  */\nextern __pid_t wait3(__WAIT_STATUS __stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\n\n#ifdef __USE_MISC\n/* PID is like waitpid.  Other args are like wait3.  */\nextern __pid_t wait4(__pid_t __pid, __WAIT_STATUS __stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/wait.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/termios.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 7.1-2 General Terminal Interface\t<termios.h>\n */\n\n#ifndef\t_TERMIOS_H\n#define\t_TERMIOS_H\t1\n\n#include <features.h>\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n/* We need `pid_t'.  */\n# include <bits/types.h>\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n# endif\n#endif\n\n__BEGIN_DECLS\n/* Get the system-dependent definitions of `struct termios', `tcflag_t',\n   `cc_t', `speed_t', and all the macros specifying the flag bits.  */\n#include <bits/termios.h>\n#ifdef __USE_MISC\n/* Compare a character C to a value VAL from the `c_cc' array in a\n   `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */\n# define CCEQ(val, c)\t((c) == (val) && (val) != _POSIX_VDISABLE)\n#endif\n/* Return the output baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetospeed(const struct termios *__termios_p) __THROW;\n\n/* Return the input baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetispeed(const struct termios *__termios_p) __THROW;\n\n/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetospeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n/* Set the input baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetispeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */\nextern int cfsetspeed(struct termios *__termios_p, speed_t __speed) __THROW;\n#endif\n\n/* Put the state of FD into *TERMIOS_P.  */\nextern int tcgetattr(int __fd, struct termios *__termios_p) __THROW;\n\n/* Set the state of FD to *TERMIOS_P.\n   Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>.  */\nextern int tcsetattr(int __fd, int __optional_actions, const struct termios *__termios_p) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set *TERMIOS_P to indicate raw mode.  */\nextern void cfmakeraw(struct termios *__termios_p) __THROW;\n#endif\n\n/* Send zero bits on FD.  */\nextern int tcsendbreak(int __fd, int __duration) __THROW;\n\n/* Wait for pending output to be written on FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int tcdrain(int __fd);\n\n/* Flush pending data on FD.\n   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>.  */\nextern int tcflush(int __fd, int __queue_selector) __THROW;\n\n/* Suspend or restart transmission on FD.\n   Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>.  */\nextern int tcflow(int __fd, int __action) __THROW;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n/* Get process group ID for session leader for controlling terminal FD.  */\nextern __pid_t tcgetsid(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n# include <sys/ttydefaults.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* termios.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/time.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.23 Date and time\t<time.h>\n */\n\n#ifndef\t_TIME_H\n\n#if (! defined __need_time_t && !defined __need_clock_t && \\\n     ! defined __need_timespec)\n# define _TIME_H\t1\n# include <features.h>\n\n__BEGIN_DECLS\n#endif\n#ifdef\t_TIME_H\n/* Get size_t and NULL from <stddef.h>.  */\n# define __need_size_t\n# define __need_NULL\n# include <stddef.h>\n/* This defines CLOCKS_PER_SEC, which is the number of processor clock\n   ticks per second.  */\n# include <bits/time.h>\n/* This is the obsolete POSIX.1-1988 name for the same constant.  */\n# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K\n#  ifndef CLK_TCK\n#   define CLK_TCK\tCLOCKS_PER_SEC\n#  endif\n# endif\n#endif\t\t\t\t/* <time.h> included.  */\n#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t)\n# define __clock_t_defined\t1\n# include <bits/types.h>\n    __BEGIN_NAMESPACE_STD\n/* Returned by `clock'.  */\ntypedef __clock_t clock_t;\n__END_NAMESPACE_STD\n#if defined __USE_XOPEN || defined __USE_POSIX\n__USING_NAMESPACE_STD(clock_t)\n#endif\n#endif\t\t\t\t/* clock_t not defined and <time.h> or need clock_t.  */\n#undef\t__need_clock_t\n#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)\n# define __time_t_defined\t1\n# include <bits/types.h>\n __BEGIN_NAMESPACE_STD\n/* Returned by `time'.  */\ntypedef __time_t time_t;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX\n__USING_NAMESPACE_STD(time_t)\n#endif\n#endif\t\t\t\t/* time_t not defined and <time.h> or need time_t.  */\n#undef\t__need_time_t\n#if !defined __clockid_t_defined && \\\n   ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t)\n# define __clockid_t_defined\t1\n# include <bits/types.h>\n/* Clock ID used in clock and timer functions.  */\ntypedef __clockid_t clockid_t;\n\n#endif\t\t\t\t/* clockid_t not defined and <time.h> or need clockid_t.  */\n#undef\t__clockid_time_t\n\n#if !defined __timer_t_defined && \\\n    ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t)\n# define __timer_t_defined\t1\n\n# include <bits/types.h>\n\n/* Timer ID returned by `timer_create'.  */\ntypedef __timer_t timer_t;\n\n#endif\t\t\t\t/* timer_t not defined and <time.h> or need timer_t.  */\n#undef\t__need_timer_t\n\n#if (!defined __timespec_defined\t\t\t\t\t\\\n     && ((defined _TIME_H\t\t\t\t\t\t\\\n\t  && (defined __USE_POSIX199309\t\t\t\t\t\\\n\t      || defined __USE_ISOC11))\t\t\t\t\t\\\n\t || defined __need_timespec))\n# define __timespec_defined\t1\n\n# include <bits/types.h>\t/* This defines __time_t for us.  */\n\n/* POSIX.1b structure for a time value.  This is like a `struct timeval' but\n   has nanoseconds instead of microseconds.  */\nstruct timespec {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__syscall_slong_t tv_nsec;\t/* Nanoseconds.  */\n};\n\n#endif\t\t\t\t/* timespec not defined and <time.h> or need timespec.  */\n#undef\t__need_timespec\n\n#ifdef\t_TIME_H\n__BEGIN_NAMESPACE_STD\n/* Used by other time functions.  */\nstruct tm {\n\tint tm_sec;\t\t/* Seconds.     [0-60] (1 leap second) */\n\tint tm_min;\t\t/* Minutes.     [0-59] */\n\tint tm_hour;\t\t/* Hours.       [0-23] */\n\tint tm_mday;\t\t/* Day.         [1-31] */\n\tint tm_mon;\t\t/* Month.       [0-11] */\n\tint tm_year;\t\t/* Year - 1900.  */\n\tint tm_wday;\t\t/* Day of week. [0-6] */\n\tint tm_yday;\t\t/* Days in year.[0-365] */\n\tint tm_isdst;\t\t/* DST.         [-1/0/1] */\n\n# ifdef\t__USE_MISC\n\tlong int tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *tm_zone;\t/* Timezone abbreviation.  */\n# else\n\tlong int __tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *__tm_zone;\t/* Timezone abbreviation.  */\n# endif\n};\n__END_NAMESPACE_STD\n#if defined __USE_XOPEN || defined __USE_POSIX\n__USING_NAMESPACE_STD(tm)\n#endif\n# ifdef __USE_POSIX199309\n/* POSIX.1b structure for timer start values and intervals.  */\nstruct itimerspec {\n\tstruct timespec it_interval;\n\tstruct timespec it_value;\n};\n\n/* We can use a simple forward declaration.  */\nstruct sigevent;\n\n# endif\t\t\t\t/* POSIX.1b */\n\n# ifdef __USE_XOPEN2K\n#  ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#   define __pid_t_defined\n#  endif\n# endif\n\n# ifdef __USE_ISOC11\n/* Time base values for timespec_get.  */\n# define TIME_UTC 1\n# endif\n\n__BEGIN_NAMESPACE_STD\n/* Time used by the program so far (user time + system time).\n   The result / CLOCKS_PER_SECOND is program time in seconds.  */\nextern clock_t clock(void) __THROW;\n\n/* Return the current time and put it in *TIMER if TIMER is not NULL.  */\nextern time_t time(time_t * __timer) __THROW;\n\n/* Return the difference between TIME1 and TIME0.  */\nextern double difftime(time_t __time1, time_t __time0)\n__THROW __attribute__ ((__const__));\n\n/* Return the `time_t' representation of TP and normalize TP.  */\nextern time_t mktime(struct tm *__tp) __THROW;\n\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE characters and return the number\n   of characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t strftime(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp) __THROW;\n__END_NAMESPACE_STD\n# ifdef __USE_XOPEN\n/* Parse S according to FORMAT and store binary time information in TP.\n   The return value is a pointer to the first unparsed character in S.  */\nextern char *strptime(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp) __THROW;\n# endif\n\n# ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n# include <xlocale.h>\n\nextern size_t strftime_l(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp, __locale_t __loc) __THROW;\n# endif\n\n# ifdef __USE_GNU\nextern char *strptime_l(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp, __locale_t __loc) __THROW;\n# endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the `struct tm' representation of *TIMER\n   in Universal Coordinated Time (aka Greenwich Mean Time).  */\nextern struct tm *gmtime(const time_t * __timer) __THROW;\n\n/* Return the `struct tm' representation\n   of *TIMER in the local timezone.  */\nextern struct tm *localtime(const time_t * __timer) __THROW;\n__END_NAMESPACE_STD\n# ifdef __USE_POSIX\n/* Return the `struct tm' representation of *TIMER in UTC,\n   using *TP to store the result.  */\nextern struct tm *gmtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n\n/* Return the `struct tm' representation of *TIMER in local time,\n   using *TP to store the result.  */\nextern struct tm *localtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n# endif\t\t\t\t/* POSIX */\n\n__BEGIN_NAMESPACE_STD\n/* Return a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime(const struct tm *__tp) __THROW;\n\n/* Equivalent to `asctime (localtime (timer))'.  */\nextern char *ctime(const time_t * __timer) __THROW;\n__END_NAMESPACE_STD\n# ifdef __USE_POSIX\n/* Reentrant versions of the above functions.  */\n/* Return in BUF a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime_r(const struct tm *__restrict __tp, char *__restrict __buf) __THROW;\n\n/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */\nextern char *ctime_r(const time_t * __restrict __timer, char *__restrict __buf) __THROW;\n# endif\t\t\t\t/* POSIX */\n\n/* Defined in localtime.c.  */\nextern char *__tzname[2];\t/* Current timezone names.  */\nextern int __daylight;\t\t/* If daylight-saving time is ever in use.  */\nextern long int __timezone;\t/* Seconds west of UTC.  */\n\n# ifdef\t__USE_POSIX\n/* Same as above.  */\nextern char *tzname[2];\n\n/* Set time conversion information from the TZ environment variable.\n   If TZ is not defined, a locale-dependent default is used.  */\nextern void tzset(void) __THROW;\n# endif\n\n# if defined __USE_MISC || defined __USE_XOPEN\nextern int daylight;\nextern long int timezone;\n# endif\n\n# ifdef __USE_MISC\n/* Set the system time to *WHEN.\n   This call is restricted to the superuser.  */\nextern int stime(const time_t * __when) __THROW;\n# endif\n\n/* Nonzero if YEAR is a leap year (every 4 years,\n   except every 100th isn't, and every 400th is).  */\n# define __isleap(year)\t\\\n  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))\n\n# ifdef __USE_MISC\n/* Miscellaneous functions many Unices inherited from the public domain\n   localtime package.  These are included only for compatibility.  */\n\n/* Like `mktime', but for TP represents Universal Time, not local time.  */\nextern time_t timegm(struct tm *__tp) __THROW;\n\n/* Another name for `mktime'.  */\nextern time_t timelocal(struct tm *__tp) __THROW;\n\n/* Return the number of days in YEAR.  */\nextern int dysize(int __year)\n__THROW __attribute__ ((__const__));\n# endif\n\n# ifdef __USE_POSIX199309\n/* Pause execution for a number of nanoseconds.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int nanosleep(const struct timespec *__requested_time, struct timespec *__remaining);\n\n/* Get resolution of clock CLOCK_ID.  */\nextern int clock_getres(clockid_t __clock_id, struct timespec *__res) __THROW;\n\n/* Get current value of clock CLOCK_ID and store it in TP.  */\nextern int clock_gettime(clockid_t __clock_id, struct timespec *__tp) __THROW;\n\n/* Set clock CLOCK_ID to value TP.  */\nextern int clock_settime(clockid_t __clock_id, const struct timespec *__tp) __THROW;\n\n#  ifdef __USE_XOPEN2K\n/* High-resolution sleep with the specified clock.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int clock_nanosleep(clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem);\n\n/* Return clock ID for CPU-time clock.  */\nextern int clock_getcpuclockid(pid_t __pid, clockid_t * __clock_id) __THROW;\n#  endif\n\n/* Create new per-process timer using CLOCK_ID.  */\nextern int timer_create(clockid_t __clock_id, struct sigevent *__restrict __evp, timer_t * __restrict __timerid) __THROW;\n\n/* Delete timer TIMERID.  */\nextern int timer_delete(timer_t __timerid) __THROW;\n\n/* Set timer TIMERID to VALUE, returning old value in OVALUE.  */\nextern int timer_settime(timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW;\n\n/* Get current value of timer TIMERID and store it in VALUE.  */\nextern int timer_gettime(timer_t __timerid, struct itimerspec *__value) __THROW;\n\n/* Get expiration overrun for timer TIMERID.  */\nextern int timer_getoverrun(timer_t __timerid) __THROW;\n# endif\n\n# ifdef __USE_ISOC11\n/* Set TS to calendar time based in time base BASE.  */\nextern int timespec_get(struct timespec *__ts, int __base)\n__THROW __nonnull((1));\n# endif\n\n# ifdef __USE_XOPEN_EXTENDED\n/* Set to one of the following values to indicate an error.\n     1  the DATEMSK environment variable is null or undefined,\n     2  the template file cannot be opened for reading,\n     3  failed to get file status information,\n     4  the template file is not a regular file,\n     5  an error is encountered while reading the template file,\n     6  memory allication failed (not enough memory available),\n     7  there is no line in the template that matches the input,\n     8  invalid input specification Example: February 31 or a time is\n\tspecified that can not be represented in a time_t (representing\n\tthe time in seconds since 00:00:00 UTC, January 1, 1970) */\nextern int getdate_err;\n\n/* Parse the given string as a date specification and return a value\n   representing the value.  The templates from the file identified by\n   the environment variable DATEMSK are used.  In case of an error\n   `getdate_err' is set.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct tm *getdate(const char *__string);\n# endif\n\n# ifdef __USE_GNU\n/* Since `getdate' is not reentrant because of the use of `getdate_err'\n   and the static buffer to return the result in, we provide a thread-safe\n   variant.  The functionality is the same.  The result is returned in\n   the buffer pointed to by RESBUFP and in case of an error the return\n   value is != 0 with the same values as given above for `getdate_err'.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getdate_r(const char *__restrict __string, struct tm *__restrict __resbufp);\n# endif\n\n__END_DECLS\n#endif\t\t\t\t/* <time.h> included.  */\n#endif\t\t\t\t/* <time.h> not already included.  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/unistd.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.10 Symbolic Constants\t\t<unistd.h>\n */\n\n#ifndef\t_UNISTD_H\n#define\t_UNISTD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* These may be used to determine what facilities are present at compile time.\n   Their values can be obtained at run time from `sysconf'.  */\n#ifdef __USE_XOPEN2K8\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008.  */\n# define _POSIX_VERSION\t200809L\n#elif defined __USE_XOPEN2K\n/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001.  */\n# define _POSIX_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995.  */\n# define _POSIX_VERSION\t199506L\n#elif defined __USE_POSIX199309\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993.  */\n# define _POSIX_VERSION\t199309L\n#else\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990.  */\n# define _POSIX_VERSION\t199009L\n#endif\n/* These are not #ifdef __USE_POSIX2 because they are\n   in the theoretically application-owned namespace.  */\n#ifdef __USE_XOPEN2K8\n# define __POSIX2_THIS_VERSION\t200809L\n/* The utilities on GNU systems also correspond to this version.  */\n#elif defined __USE_XOPEN2K\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t199506L\n#else\n/* The utilities on GNU systems also correspond to this version.  */\n# define __POSIX2_THIS_VERSION\t199209L\n#endif\n/* The utilities on GNU systems also correspond to this version.  */\n#define _POSIX2_VERSION\t__POSIX2_THIS_VERSION\n/* This symbol was required until the 2001 edition of POSIX.  */\n#define\t_POSIX2_C_VERSION\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Bindings Option.  */\n#define\t_POSIX2_C_BIND\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Development Utilities Option.  */\n#define\t_POSIX2_C_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   Software Development Utilities Option.  */\n#define\t_POSIX2_SW_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   creation of locales with the localedef utility.  */\n#define _POSIX2_LOCALEDEF       __POSIX2_THIS_VERSION\n/* X/Open version number to which the library conforms.  It is selectable.  */\n#ifdef __USE_XOPEN2K8\n# define _XOPEN_VERSION\t700\n#elif defined __USE_XOPEN2K\n# define _XOPEN_VERSION\t600\n#elif defined __USE_UNIX98\n# define _XOPEN_VERSION\t500\n#else\n# define _XOPEN_VERSION\t4\n#endif\n/* Commands and utilities from XPG4 are available.  */\n#define _XOPEN_XCU_VERSION\t4\n/* We are compatible with the old published standards as well.  */\n#define _XOPEN_XPG2\t1\n#define _XOPEN_XPG3\t1\n#define _XOPEN_XPG4\t1\n/* The X/Open Unix extensions are available.  */\n#define _XOPEN_UNIX\t1\n/* Encryption is present.  */\n#define\t_XOPEN_CRYPT\t1\n/* The enhanced internationalization capabilities according to XPG4.2\n   are present.  */\n#define\t_XOPEN_ENH_I18N\t1\n/* The legacy interfaces are also available.  */\n#define _XOPEN_LEGACY\t1\n/* Get values of POSIX options:\n\n   If these symbols are defined, the corresponding features are\n   always available.  If not, they may be available sometimes.\n   The current values can be obtained with `sysconf'.\n\n   _POSIX_JOB_CONTROL\t\tJob control is supported.\n   _POSIX_SAVED_IDS\t\tProcesses have a saved set-user-ID\n\t\t\t\tand a saved set-group-ID.\n   _POSIX_REALTIME_SIGNALS\tReal-time, queued signals are supported.\n   _POSIX_PRIORITY_SCHEDULING\tPriority scheduling is supported.\n   _POSIX_TIMERS\t\tPOSIX.4 clocks and timers are supported.\n   _POSIX_ASYNCHRONOUS_IO\tAsynchronous I/O is supported.\n   _POSIX_PRIORITIZED_IO\tPrioritized asynchronous I/O is supported.\n   _POSIX_SYNCHRONIZED_IO\tSynchronizing file data is supported.\n   _POSIX_FSYNC\t\t\tThe fsync function is present.\n   _POSIX_MAPPED_FILES\t\tMapping of files to memory is supported.\n   _POSIX_MEMLOCK\t\tLocking of all memory is supported.\n   _POSIX_MEMLOCK_RANGE\t\tLocking of ranges of memory is supported.\n   _POSIX_MEMORY_PROTECTION\tSetting of memory protections is supported.\n   _POSIX_MESSAGE_PASSING\tPOSIX.4 message queues are supported.\n   _POSIX_SEMAPHORES\t\tPOSIX.4 counting semaphores are supported.\n   _POSIX_SHARED_MEMORY_OBJECTS\tPOSIX.4 shared memory objects are supported.\n   _POSIX_THREADS\t\tPOSIX.1c pthreads are supported.\n   _POSIX_THREAD_ATTR_STACKADDR\tThread stack address attribute option supported.\n   _POSIX_THREAD_ATTR_STACKSIZE\tThread stack size attribute option supported.\n   _POSIX_THREAD_SAFE_FUNCTIONS\tThread-safe functions are supported.\n   _POSIX_THREAD_PRIORITY_SCHEDULING\n\t\t\t\tPOSIX.1c thread execution scheduling supported.\n   _POSIX_THREAD_PRIO_INHERIT\tThread priority inheritance option supported.\n   _POSIX_THREAD_PRIO_PROTECT\tThread priority protection option supported.\n   _POSIX_THREAD_PROCESS_SHARED\tProcess-shared synchronization supported.\n   _POSIX_PII\t\t\tProtocol-independent interfaces are supported.\n   _POSIX_PII_XTI\t\tXTI protocol-indep. interfaces are supported.\n   _POSIX_PII_SOCKET\t\tSocket protocol-indep. interfaces are supported.\n   _POSIX_PII_INTERNET\t\tInternet family of protocols supported.\n   _POSIX_PII_INTERNET_STREAM\tConnection-mode Internet protocol supported.\n   _POSIX_PII_INTERNET_DGRAM\tConnectionless Internet protocol supported.\n   _POSIX_PII_OSI\t\tISO/OSI family of protocols supported.\n   _POSIX_PII_OSI_COTS\t\tConnection-mode ISO/OSI service supported.\n   _POSIX_PII_OSI_CLTS\t\tConnectionless ISO/OSI service supported.\n   _POSIX_POLL\t\t\tImplementation supports `poll' function.\n   _POSIX_SELECT\t\tImplementation supports `select' and `pselect'.\n\n   _XOPEN_REALTIME\t\tX/Open realtime support is available.\n   _XOPEN_REALTIME_THREADS\tX/Open realtime thread support is available.\n   _XOPEN_SHM\t\t\tShared memory interface according to XPG4.2.\n\n   _XBS5_ILP32_OFF32\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, pointer, and off_t types.\n   _XBS5_ILP32_OFFBIG\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, and pointer and off_t with at least\n\t\t\t\t64 bits.\n   _XBS5_LP64_OFF64\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, and 64-bit long, pointer, and off_t types.\n   _XBS5_LPBIG_OFFBIG\t\tImplementation provides environment with at\n\t\t\t\tleast 32 bits int and long, pointer, and off_t\n\t\t\t\twith at least 64 bits.\n\n   If any of these symbols is defined as -1, the corresponding option is not\n   true for any file.  If any is defined as other than -1, the corresponding\n   option is true for all files.  If a symbol is not defined at all, the value\n   for a specific file can be obtained from `pathconf' and `fpathconf'.\n\n   _POSIX_CHOWN_RESTRICTED\tOnly the super user can use `chown' to change\n\t\t\t\tthe owner of a file.  `chown' can only be used\n\t\t\t\tto change the group ID of a file to a group of\n\t\t\t\twhich the calling process is a member.\n   _POSIX_NO_TRUNC\t\tPathname components longer than\n\t\t\t\tNAME_MAX generate an error.\n   _POSIX_VDISABLE\t\tIf defined, if the value of an element of the\n\t\t\t\t`c_cc' member of `struct termios' is\n\t\t\t\t_POSIX_VDISABLE, no character will have the\n\t\t\t\teffect associated with that element.\n   _POSIX_SYNC_IO\t\tSynchronous I/O may be performed.\n   _POSIX_ASYNC_IO\t\tAsynchronous I/O may be performed.\n   _POSIX_PRIO_IO\t\tPrioritized Asynchronous I/O may be performed.\n\n   Support for the Large File Support interface is not generally available.\n   If it is available the following constants are defined to one.\n   _LFS64_LARGEFILE\t\tLow-level I/O supports large files.\n   _LFS64_STDIO\t\t\tStandard I/O supports large files.\n   */\n#include <bits/posix_opt.h>\n/* Get the environment definitions from Unix98.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n# include <bits/environments.h>\n#endif\n/* Standard file descriptors.  */\n#define\tSTDIN_FILENO\t0\t/* Standard input.  */\n#define\tSTDOUT_FILENO\t1\t/* Standard output.  */\n#define\tSTDERR_FILENO\t2\t/* Standard error output.  */\n/* All functions that are not declared anywhere else.  */\n#include <bits/types.h>\n#ifndef\t__ssize_t_defined\ntypedef __ssize_t ssize_t;\n# define __ssize_t_defined\n#endif\n\n#define\t__need_size_t\n#define __need_NULL\n#include <stddef.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n# ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#  define __gid_t_defined\n# endif\n\n# ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#  define __uid_t_defined\n# endif\n\n# ifndef __off_t_defined\n#  ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#  else\ntypedef __off64_t off_t;\n#  endif\n#  define __off_t_defined\n# endif\n# if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#  define __off64_t_defined\n# endif\n\n# ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#  define __useconds_t_defined\n# endif\n\n# ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#  define __pid_t_defined\n# endif\n#endif\t\t\t\t/* X/Open */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n# ifndef __intptr_t_defined\ntypedef __intptr_t intptr_t;\n#  define __intptr_t_defined\n# endif\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n# ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n#  define __socklen_t_defined\n# endif\n#endif\n\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#define\tR_OK\t4\t\t/* Test for read permission.  */\n#define\tW_OK\t2\t\t/* Test for write permission.  */\n#define\tX_OK\t1\t\t/* Test for execute permission.  */\n#define\tF_OK\t0\t\t/* Test for existence.  */\n\n/* Test for access to NAME using the real UID and real GID.  */\nextern int access(const char *__name, int __type)\n__THROW __nonnull((1));\n\n#ifdef __USE_GNU\n/* Test for access to NAME using the effective UID and GID\n   (as normal file operations use).  */\nextern int euidaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n\n/* An alias for `euidaccess', used by some other systems.  */\nextern int eaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Test for access to FILE relative to the directory FD is open on.\n   If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',\n   otherwise use real IDs like `access'.  */\nextern int faccessat(int __fd, const char *__file, int __type, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Values for the WHENCE argument to lseek.  */\n#ifndef\t_STDIO_H\t\t/* <stdio.h> has the same definitions.  */\n# define SEEK_SET\t0\t/* Seek from beginning of file.  */\n# define SEEK_CUR\t1\t/* Seek from current position.  */\n# define SEEK_END\t2\t/* Seek from end of file.  */\n# ifdef __USE_GNU\n#  define SEEK_DATA\t3\t/* Seek to next data.  */\n#  define SEEK_HOLE\t4\t/* Seek to next hole.  */\n# endif\n#endif\n\n#if defined __USE_MISC && !defined L_SET\n/* Old BSD names for the same constants; just for compatibility.  */\n# define L_SET\t\tSEEK_SET\n# define L_INCR\t\tSEEK_CUR\n# define L_XTND\t\tSEEK_END\n#endif\n\n/* Move FD's file position to OFFSET bytes from the\n   beginning of the file (if WHENCE is SEEK_SET),\n   the current position (if WHENCE is SEEK_CUR),\n   or the end of the file (if WHENCE is SEEK_END).\n   Return the new file position.  */\n#ifndef __USE_FILE_OFFSET64\nextern __off_t lseek(int __fd, __off_t __offset, int __whence) __THROW;\n#else\n# ifdef __REDIRECT_NTH\nextern __off64_t __REDIRECT_NTH(lseek, (int __fd, __off64_t __offset, int __whence), lseek64);\n# else\n#  define lseek lseek64\n# endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern __off64_t lseek64(int __fd, __off64_t __offset, int __whence) __THROW;\n#endif\n\n/* Close the file descriptor FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int close(int __fd);\n\n/* Read NBYTES into BUF from FD.  Return the\n   number read, -1 for errors or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t read(int __fd, void *__buf, size_t __nbytes) __wur;\n\n/* Write N bytes of BUF to FD.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t write(int __fd, const void *__buf, size_t __n) __wur;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n# ifndef __USE_FILE_OFFSET64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pread(int __fd, void *__buf, size_t __nbytes, __off_t __offset) __wur;\n\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwrite(int __fd, const void *__buf, size_t __n, __off_t __offset) __wur;\n# else\n#  ifdef __REDIRECT\nextern ssize_t __REDIRECT(pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), pread64) __wur;\nextern ssize_t __REDIRECT(pwrite, (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset), pwrite64) __wur;\n#  else\n#   define pread pread64\n#   define pwrite pwrite64\n#  endif\n# endif\n\n# ifdef __USE_LARGEFILE64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.  */\nextern ssize_t pread64(int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __wur;\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.  */\nextern ssize_t pwrite64(int __fd, const void *__buf, size_t __n, __off64_t __offset) __wur;\n# endif\n#endif\n\n/* Create a one-way communication channel (pipe).\n   If successful, two file descriptors are stored in PIPEDES;\n   bytes written on PIPEDES[1] can be read from PIPEDES[0].\n   Returns 0 if successful, -1 if not.  */\nextern int pipe(int __pipedes[2])\n__THROW __wur;\n\n#ifdef __USE_GNU\n/* Same as pipe but apply flags passed in FLAGS to the new file\n   descriptors.  */\nextern int pipe2(int __pipedes[2], int __flags)\n__THROW __wur;\n#endif\n\n/* Schedule an alarm.  In SECONDS seconds, the process will get a SIGALRM.\n   If SECONDS is zero, any currently scheduled alarm will be cancelled.\n   The function returns the number of seconds remaining until the last\n   alarm scheduled would have signaled, or zero if there wasn't one.\n   There is no return value to indicate an error, but you can set `errno'\n   to 0 and check its value after calling `alarm', and this might tell you.\n   The signal may come late due to processor scheduling.  */\nextern unsigned int alarm(unsigned int __seconds) __THROW;\n\n/* Make the process sleep for SECONDS seconds, or until a signal arrives\n   and is not ignored.  The function returns the number of seconds less\n   than SECONDS which it actually slept (thus zero if it slept the full time).\n   If a signal handler does a `longjmp' or modifies the handling of the\n   SIGALRM signal while inside `sleep' call, the handling of the SIGALRM\n   signal afterwards is undefined.  There is no return value to indicate\n   error, but if `sleep' returns SECONDS, it probably didn't work.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern unsigned int sleep(unsigned int __seconds);\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Set an alarm to go off (generating a SIGALRM signal) in VALUE\n   microseconds.  If INTERVAL is nonzero, when the alarm goes off, the\n   timer is reset to go off every INTERVAL microseconds thereafter.\n   Returns the number of microseconds remaining before the alarm.  */\nextern __useconds_t ualarm(__useconds_t __value, __useconds_t __interval) __THROW;\n\n/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked\n   or ignored.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int usleep(__useconds_t __useconds);\n#endif\n\n/* Suspend the process until a signal arrives.\n   This always returns -1 and sets `errno' to EINTR.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pause(void);\n\n/* Change the owner and group of FILE.  */\nextern int chown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the owner and group of the file that FD is open on.  */\nextern int fchown(int __fd, __uid_t __owner, __gid_t __group)\n__THROW __wur;\n\n/* Change owner and group of FILE, if it is a symbolic\n   link the ownership of the symbolic link is changed.  */\nextern int lchown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use X/Open Unix.  */\n\n#ifdef __USE_ATFILE\n/* Change the owner and group of FILE relative to the directory FD is open\n   on.  */\nextern int fchownat(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Change the process's working directory to PATH.  */\nextern int chdir(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the process's working directory to the one FD is open on.  */\nextern int fchdir(int __fd)\n__THROW __wur;\n#endif\n\n/* Get the pathname of the current working directory,\n   and put it in SIZE bytes of BUF.  Returns NULL if the\n   directory couldn't be determined or SIZE was too small.\n   If successful, returns BUF.  In GNU, if BUF is NULL,\n   an array is allocated with `malloc'; the array is SIZE\n   bytes long, unless SIZE == 0, in which case it is as\n   big as necessary.  */\nextern char *getcwd(char *__buf, size_t __size)\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the current directory name.\n   If the environment variable `PWD' is set, and its value is correct,\n   that value is used.  */\nextern char *get_current_dir_name(void) __THROW;\n#endif\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Put the absolute pathname of the current working directory in BUF.\n   If successful, return BUF.  If not, put an error message in\n   BUF and return NULL.  BUF should be at least PATH_MAX bytes long.  */\nextern char *getwd(char *__buf)\n__THROW __nonnull((1))\n__attribute_deprecated__ __wur;\n#endif\n\n/* Duplicate FD, returning a new file descriptor on the same file.  */\nextern int dup(int __fd)\n__THROW __wur;\n\n/* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */\nextern int dup2(int __fd, int __fd2) __THROW;\n\n#ifdef __USE_GNU\n/* Duplicate FD to FD2, closing FD2 and making it open on the same\n   file while setting flags according to FLAGS.  */\nextern int dup3(int __fd, int __fd2, int __flags) __THROW;\n#endif\n\n/* NULL-terminated array of \"NAME=VALUE\" environment variables.  */\nextern char **__environ;\n#ifdef __USE_GNU\nextern char **environ;\n#endif\n\n/* Replace the current process, executing PATH with arguments ARGV and\n   environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */\nextern int execve(const char *__path, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_XOPEN2K8\n/* Execute the file FD refers to, overlaying the running program image.\n   ARGV and ENVP are passed to the new program, as for `execve'.  */\nextern int fexecve(int __fd, char *const __argv[], char *const __envp[])\n__THROW __nonnull((2));\n#endif\n\n/* Execute PATH with arguments ARGV and environment from `environ'.  */\nextern int execv(const char *__path, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until a NULL pointer,\n   and the argument after that for environment.  */\nextern int execle(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until\n   a NULL pointer and environment from `environ'.  */\nextern int execl(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvp(const char *__file, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if\n   it contains no slashes, with all arguments after FILE until a\n   NULL pointer and environment from `environ'.  */\nextern int execlp(const char *__file, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_GNU\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvpe(const char *__file, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Add INC to priority of the current process.  */\nextern int nice(int __inc)\n__THROW __wur;\n#endif\n\n/* Terminate program execution with the low-order 8 bits of STATUS.  */\nextern void _exit(int __status) __attribute__ ((__noreturn__));\n\n/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';\n   the `_SC_*' symbols for the NAME argument to `sysconf';\n   and the `_CS_*' symbols for the NAME argument to `confstr'.  */\n#include <bits/confname.h>\n\n/* Get file-specific configuration information about PATH.  */\nextern long int pathconf(const char *__path, int __name)\n__THROW __nonnull((1));\n\n/* Get file-specific configuration about descriptor FD.  */\nextern long int fpathconf(int __fd, int __name) __THROW;\n\n/* Get the value of the system variable NAME.  */\nextern long int sysconf(int __name) __THROW;\n\n#ifdef\t__USE_POSIX2\n/* Get the value of the string-valued system variable NAME.  */\nextern size_t confstr(int __name, char *__buf, size_t __len) __THROW;\n#endif\n\n/* Get the process ID of the calling process.  */\nextern __pid_t getpid(void) __THROW;\n\n/* Get the process ID of the calling process's parent.  */\nextern __pid_t getppid(void) __THROW;\n\n/* Get the process group ID of the calling process.  */\nextern __pid_t getpgrp(void) __THROW;\n\n/* Get the process group ID of process PID.  */\nextern __pid_t __getpgid(__pid_t __pid) __THROW;\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\nextern __pid_t getpgid(__pid_t __pid) __THROW;\n#endif\n\n/* Set the process group ID of the process matching PID to PGID.\n   If PID is zero, the current process's process group ID is set.\n   If PGID is zero, the process ID of the process is used.  */\nextern int setpgid(__pid_t __pid, __pid_t __pgid) __THROW;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Both System V and BSD have `setpgrp' functions, but with different\n   calling conventions.  The BSD function is the same as POSIX.1 `setpgid'\n   (above).  The System V function takes no arguments and puts the calling\n   process in its on group like `setpgid (0, 0)'.\n\n   New programs should always use `setpgid' instead.\n\n   GNU provides the POSIX.1 function.  */\n\n/* Set the process group ID of the calling process to its own PID.\n   This is exactly the same as `setpgid (0, 0)'.  */\nextern int setpgrp(void) __THROW;\n\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n/* Create a new session with the calling process as its leader.\n   The process group IDs of the session and the calling process\n   are set to the process ID of the calling process, which is returned.  */\nextern __pid_t setsid(void) __THROW;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Return the session ID of the given process.  */\nextern __pid_t getsid(__pid_t __pid) __THROW;\n#endif\n\n/* Get the real user ID of the calling process.  */\nextern __uid_t getuid(void) __THROW;\n\n/* Get the effective user ID of the calling process.  */\nextern __uid_t geteuid(void) __THROW;\n\n/* Get the real group ID of the calling process.  */\nextern __gid_t getgid(void) __THROW;\n\n/* Get the effective group ID of the calling process.  */\nextern __gid_t getegid(void) __THROW;\n\n/* If SIZE is zero, return the number of supplementary groups\n   the calling process is in.  Otherwise, fill in the group IDs\n   of its supplementary groups in LIST and return the number written.  */\nextern int getgroups(int __size, __gid_t __list[])\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return nonzero iff the calling process is in group GID.  */\nextern int group_member(__gid_t __gid) __THROW;\n#endif\n\n/* Set the user ID of the calling process to UID.\n   If the calling process is the super-user, set the real\n   and effective user IDs, and the saved set-user-ID to UID;\n   if not, the effective user ID is set to UID.  */\nextern int setuid(__uid_t __uid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real user ID of the calling process to RUID,\n   and the effective user ID of the calling process to EUID.  */\nextern int setreuid(__uid_t __ruid, __uid_t __euid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective user ID of the calling process to UID.  */\nextern int seteuid(__uid_t __uid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n/* Set the group ID of the calling process to GID.\n   If the calling process is the super-user, set the real\n   and effective group IDs, and the saved set-group-ID to GID;\n   if not, the effective group ID is set to GID.  */\nextern int setgid(__gid_t __gid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real group ID of the calling process to RGID,\n   and the effective group ID of the calling process to EGID.  */\nextern int setregid(__gid_t __rgid, __gid_t __egid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective group ID of the calling process to GID.  */\nextern int setegid(__gid_t __gid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_GNU\n/* Fetch the real user ID, effective user ID, and saved-set user ID,\n   of the calling process.  */\nextern int getresuid(__uid_t * __ruid, __uid_t * __euid, __uid_t * __suid) __THROW;\n\n/* Fetch the real group ID, effective group ID, and saved-set group ID,\n   of the calling process.  */\nextern int getresgid(__gid_t * __rgid, __gid_t * __egid, __gid_t * __sgid) __THROW;\n\n/* Set the real user ID, effective user ID, and saved-set user ID,\n   of the calling process to RUID, EUID, and SUID, respectively.  */\nextern int setresuid(__uid_t __ruid, __uid_t __euid, __uid_t __suid)\n__THROW __wur;\n\n/* Set the real group ID, effective group ID, and saved-set group ID,\n   of the calling process to RGID, EGID, and SGID, respectively.  */\nextern int setresgid(__gid_t __rgid, __gid_t __egid, __gid_t __sgid)\n__THROW __wur;\n#endif\n\n/* Clone the calling process, creating an exact copy.\n   Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t fork(void) __THROWNL;\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Clone the calling process, but without copying the whole address space.\n   The calling process is suspended until the new process exits or is\n   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t vfork(void) __THROW;\n#endif\t\t\t\t/* Use misc or XPG < 7. */\n\n/* Return the pathname of the terminal FD is open on, or NULL on errors.\n   The returned storage is good only until the next call to this function.  */\nextern char *ttyname(int __fd) __THROW;\n\n/* Store at most BUFLEN characters of the pathname of the terminal FD is\n   open on in BUF.  Return 0 on success, otherwise an error number.  */\nextern int ttyname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n\n/* Return 1 if FD is a valid descriptor associated\n   with a terminal, zero if not.  */\nextern int isatty(int __fd) __THROW;\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)\n/* Return the index into the active-logins file (utmp) for\n   the controlling terminal.  */\nextern int ttyslot(void) __THROW;\n#endif\n\n/* Make a link to FROM named TO.  */\nextern int link(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n#ifdef __USE_ATFILE\n/* Like link but relative paths in TO and FROM are interpreted relative\n   to FROMFD and TOFD respectively.  */\nextern int linkat(int __fromfd, const char *__from, int __tofd, const char *__to, int __flags)\n__THROW __nonnull((2, 4)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n/* Make a symbolic link to FROM named TO.  */\nextern int symlink(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n/* Read the contents of the symbolic link PATH into no more than\n   LEN bytes of BUF.  The contents are not null-terminated.\n   Returns the number of characters read, or -1 for errors.  */\nextern ssize_t readlink(const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((1, 2)) __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_ATFILE\n/* Like symlink but a relative path in TO is interpreted relative to TOFD.  */\nextern int symlinkat(const char *__from, int __tofd, const char *__to)\n__THROW __nonnull((1, 3)) __wur;\n\n/* Like readlink but a relative PATH is interpreted relative to FD.  */\nextern ssize_t readlinkat(int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((2, 3)) __wur;\n#endif\n\n/* Remove the link NAME.  */\nextern int unlink(const char *__name)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Remove the link NAME relative to FD.  */\nextern int unlinkat(int __fd, const char *__name, int __flag)\n__THROW __nonnull((2));\n#endif\n\n/* Remove the directory PATH.  */\nextern int rmdir(const char *__path)\n__THROW __nonnull((1));\n\n/* Return the foreground process group ID of FD.  */\nextern __pid_t tcgetpgrp(int __fd) __THROW;\n\n/* Set the foreground process group ID of FD set PGRP_ID.  */\nextern int tcsetpgrp(int __fd, __pid_t __pgrp_id) __THROW;\n\n/* Return the login name of the user.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *getlogin(void);\n#if defined __USE_REENTRANT || defined __USE_POSIX199506\n/* Return at most NAME_LEN characters of the login name of the user in NAME.\n   If it cannot be determined or some other error occurred, return the error\n   code.  Otherwise return 0.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getlogin_r(char *__name, size_t __name_len) __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* Set the login name returned by `getlogin'.  */\nextern int setlogin(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_POSIX2\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.  */\n# define __need_getopt\n# include <getopt.h>\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Put the name of the current host in no more than LEN bytes of NAME.\n   The result is null-terminated if LEN is large enough for the full\n   name and the terminator.  */\nextern int gethostname(char *__name, size_t __len)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_MISC\n/* Set the name of the current host to NAME, which is LEN bytes long.\n   This call is restricted to the super-user.  */\nextern int sethostname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Set the current machine's Internet number to ID.\n   This call is restricted to the super-user.  */\nextern int sethostid(long int __id)\n__THROW __wur;\n\n/* Get and set the NIS (aka YP) domain name, if any.\n   Called just like `gethostname' and `sethostname'.\n   The NIS domain name is usually the empty string when not using NIS.  */\nextern int getdomainname(char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\nextern int setdomainname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Revoke access permissions to all processes currently communicating\n   with the control terminal, and then send a SIGHUP signal to the process\n   group of the control terminal.  */\nextern int vhangup(void) __THROW;\n\n/* Revoke the access of all descriptors currently open on FILE.  */\nextern int revoke(const char *__file)\n__THROW __nonnull((1)) __wur;\n\n/* Enable statistical profiling, writing samples of the PC into at most\n   SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling\n   is enabled, the system examines the user PC and increments\n   SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536].  If SCALE is zero,\n   disable profiling.  Returns zero on success, -1 on error.  */\nextern int profil(unsigned short int *__sample_buffer, size_t __size, size_t __offset, unsigned int __scale)\n__THROW __nonnull((1));\n\n/* Turn accounting on if NAME is an existing file.  The system will then write\n   a record for each process as it terminates, to this file.  If NAME is NULL,\n   turn accounting off.  This call is restricted to the super-user.  */\nextern int acct(const char *__name) __THROW;\n\n/* Successive calls return the shells listed in `/etc/shells'.  */\nextern char *getusershell(void) __THROW;\nextern void endusershell(void) __THROW;\t/* Discard cached info.  */\nextern void setusershell(void) __THROW;\t/* Rewind and re-read the file.  */\n\n/* Put the program in the background, and dissociate from the controlling\n   terminal.  If NOCHDIR is zero, do `chdir (\"/\")'.  If NOCLOSE is zero,\n   redirects stdin, stdout, and stderr to /dev/null.  */\nextern int daemon(int __nochdir, int __noclose)\n__THROW __wur;\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Make PATH be the root directory (the starting point for absolute paths).\n   This call is restricted to the super-user.  */\nextern int chroot(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n/* Prompt with PROMPT and read a string from the terminal without echoing.\n   Uses /dev/tty if possible; otherwise stderr and stdin.  */\nextern char *getpass(const char *__prompt) __nonnull((1));\n#endif\t\t\t\t/* Use misc || X/Open.  */\n\n/* Make all changes done to FD actually appear on disk.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fsync(int __fd);\n\n#ifdef __USE_GNU\n/* Make all changes done to all files on the file system associated\n   with FD actually appear on disk.  */\nextern int syncfs(int __fd) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n\n/* Return identifier for the current host.  */\nextern long int gethostid(void);\n\n/* Make all changes done to all files actually appear on disk.  */\nextern void sync(void) __THROW;\n\n# if defined __USE_MISC || !defined __USE_XOPEN2K\n/* Return the number of bytes in a page.  This is the system's page size,\n   which is not necessarily the same as the hardware page size.  */\nextern int getpagesize(void)\n__THROW __attribute__ ((__const__));\n\n/* Return the maximum number of file descriptors\n   the current process could possibly have.  */\nextern int getdtablesize(void) __THROW;\n# endif\n\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n\n/* Truncate FILE to LENGTH bytes.  */\n# ifndef __USE_FILE_OFFSET64\nextern int truncate(const char *__file, __off_t __length)\n__THROW __nonnull((1)) __wur;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(truncate, (const char *__file, __off64_t __length), truncate64) __nonnull((1)) __wur;\n#  else\n#   define truncate truncate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int truncate64(const char *__file, __off64_t __length)\n__THROW __nonnull((1)) __wur;\n# endif\n\n#endif\t\t\t\t/* Use X/Open Unix || POSIX 2008.  */\n\n#if defined __USE_POSIX199309 \\\n    || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n\n/* Truncate the file FD is open on to LENGTH bytes.  */\n# ifndef __USE_FILE_OFFSET64\nextern int ftruncate(int __fd, __off_t __length)\n__THROW __wur;\n# else\n#  ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(ftruncate, (int __fd, __off64_t __length), ftruncate64) __wur;\n#  else\n#   define ftruncate ftruncate64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int ftruncate64(int __fd, __off64_t __length)\n__THROW __wur;\n# endif\n\n#endif\t\t\t\t/* Use POSIX.1b || X/Open Unix || XPG6.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n\n/* Set the end of accessible data space (aka \"the break\") to ADDR.\n   Returns zero on success and -1 for errors (with errno set).  */\nextern int brk(void *__addr)\n__THROW __wur;\n\n/* Increase or decrease the end of accessible data space by DELTA bytes.\n   If successful, returns the address the previous end of data space\n   (i.e. the beginning of the new space, if DELTA > 0);\n   returns (void *) -1 for errors (with errno set).  */\nextern void *sbrk(intptr_t __delta) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Invoke `system call' number SYSNO, passing it the remaining arguments.\n   This is completely system-dependent, and not often useful.\n\n   In Unix, `syscall' sets `errno' for all errors and most calls return -1\n   for errors; in many systems you cannot pass arguments or get return\n   values for all system calls (`pipe', `fork', and `getppid' typically\n   among them).\n\n   In Mach, all system calls take normal arguments and always return an\n   error code (zero for success).  */\nextern long int syscall(long int __sysno, ...) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK\n/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n# define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n# define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n# define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n# define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n# ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, __off_t __len) __wur;\n# else\n#  ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64) __wur;\n#  else\n#   define lockf lockf64\n#  endif\n# endif\n# ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, __off64_t __len) __wur;\n# endif\n#endif\t\t\t\t/* Use misc and F_LOCK not already defined.  */\n\n#ifdef __USE_GNU\n\n/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'\n   set to EINTR.  */\n\n# define TEMP_FAILURE_RETRY(expression) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({ long int __result;\t\t\t\t\t\t      \\\n       do __result = (long int) (expression);\t\t\t\t      \\\n       while (__result == -1L && errno == EINTR);\t\t\t      \\\n       __result; }))\n#endif\n\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n/* Synchronize at least the data part of a file with the underlying\n   media.  */\nextern int fdatasync(int __fildes);\n#endif\t\t\t\t/* Use POSIX199309 */\n\n/* XPG4.2 specifies that prototypes for the encryption functions must\n   be defined here.  */\n#ifdef\t__USE_XOPEN\n/* Encrypt at most 8 characters from KEY using salt to perturb DES.  */\nextern char *crypt(const char *__key, const char *__salt)\n__THROW __nonnull((1, 2));\n\n/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt\n   block in place.  */\nextern void encrypt(char *__glibc_block, int __edflag)\n__THROW __nonnull((1));\n\n/* Swab pairs bytes in the first N bytes of the area pointed to by\n   FROM and copy the result to TO.  The value of TO must not be in the\n   range [FROM - N + 1, FROM - 1].  If N is odd the first byte in FROM\n   is without partner.  */\nextern void swab(const void *__restrict __from, void *__restrict __to, ssize_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n/* The Single Unix specification demands this prototype to be here.\n   It is also found in <stdio.h>.  */\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/unistd.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* unistd.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/utime.h",
    "content": "/* Copyright (C) 1991-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6.6 Set File Access and Modification Times  <utime.h>\n */\n\n#ifndef\t_UTIME_H\n#define\t_UTIME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n# define __need_time_t\n# include <time.h>\n#endif\n/* Structure describing file times.  */\n    struct utimbuf {\n\t__time_t actime;\t/* Access time.  */\n\t__time_t modtime;\t/* Modification time.  */\n};\n\n/* Set the access and modification times of FILE to those given in\n   *FILE_TIMES.  If FILE_TIMES is NULL, set them to the current time.  */\nextern int utime(const char *__file, const struct utimbuf *__file_times)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* utime.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/wchar.h",
    "content": "/* Copyright (C) 1995-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *      ISO C99 Standard: 7.24\n *\tExtended multibyte and wide character utilities\t<wchar.h>\n */\n\n#ifndef _WCHAR_H\n\n#if !defined __need_mbstate_t && !defined __need_wint_t\n# define _WCHAR_H 1\n# include <features.h>\n#endif\n\n#ifdef _WCHAR_H\n/* Get FILE definition.  */\n# define __need___FILE\n# if defined __USE_UNIX98 || defined __USE_XOPEN2K\n#  define __need_FILE\n# endif\n# include <stdio.h>\n/* Get va_list definition.  */\n# define __need___va_list\n# include <stdarg.h>\n\n# include <bits/wchar.h>\n\n/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */\n# define __need_size_t\n# define __need_wchar_t\n# define __need_NULL\n#endif\n#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__\n# undef __need_wint_t\n# define __need_wint_t\n# include <stddef.h>\n\n/* We try to get wint_t from <stddef.h>, but not all GCC versions define it\n   there.  So define it ourselves if it remains undefined.  */\n# ifndef _WINT_T\n/* Integral type unchanged by default argument promotions that can\n   hold any value corresponding to members of the extended character\n   set, as well as at least one value that does not correspond to any\n   member of the extended character set.  */\n#  define _WINT_T\ntypedef unsigned int wint_t;\n# else\n/* Work around problems with the <stddef.h> file which doesn't put\n   wint_t in the std namespace.  */\n#  if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \\\n      && defined __WINT_TYPE__\n__BEGIN_NAMESPACE_STD typedef __WINT_TYPE__ wint_t;\n__END_NAMESPACE_STD\n#  endif\n# endif\n/* Tell the caller that we provide correct C++ prototypes.  */\n# if defined __cplusplus && __GNUC_PREREQ (4, 4)\n#  define __CORRECT_ISO_CPP_WCHAR_H_PROTO\n# endif\n#endif\n#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined\n# define ____mbstate_t_defined\t1\n/* Conversion state information.  */\n    typedef struct {\n\tint __count;\n\tunion {\n# ifdef __WINT_TYPE__\n\t\t__WINT_TYPE__ __wch;\n# else\n\t\twint_t __wch;\n# endif\n\t\tchar __wchb[4];\n\t} __value;\t\t/* Value so far.  */\n} __mbstate_t;\n#endif\n#undef __need_mbstate_t\n\n/* The rest of the file is only used if used if __need_mbstate_t is not\n   defined.  */\n#ifdef _WCHAR_H\n\n# ifndef __mbstate_t_defined\n__BEGIN_NAMESPACE_C99\n/* Public type.  */\ntypedef __mbstate_t mbstate_t;\n__END_NAMESPACE_C99\n#  define __mbstate_t_defined 1\n# endif\n#ifdef __USE_GNU\n__USING_NAMESPACE_C99(mbstate_t)\n#endif\n#ifndef WCHAR_MIN\n/* These constants might also be defined in <inttypes.h>.  */\n# define WCHAR_MIN __WCHAR_MIN\n# define WCHAR_MAX __WCHAR_MAX\n#endif\n#ifndef WEOF\n# define WEOF (0xffffffffu)\n#endif\n/* For XPG4 compliance we have to define the stuff from <wctype.h> here\n   as well.  */\n#if defined __USE_XOPEN && !defined __USE_UNIX98\n# include <wctype.h>\n#endif\n __BEGIN_DECLS __BEGIN_NAMESPACE_STD\n/* This incomplete type is defined in <time.h> but needed here because\n   of `wcsftime'.  */\nstruct tm;\n__END_NAMESPACE_STD\n/* XXX We have to clean this up at some point.  Since tm is in the std\n   namespace but wcsftime is in __c99 the type wouldn't be found\n   without inserting it in the global namespace.  */\n__USING_NAMESPACE_STD(tm)\n\n__BEGIN_NAMESPACE_STD\n/* Copy SRC to DEST.  */\nextern wchar_t *wcscpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N wide-characters of SRC to DEST.  */\nextern wchar_t *wcsncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern wchar_t *wcscat(wchar_t * __restrict __dest, const wchar_t * __restrict __src) __THROW;\n/* Append no more than N wide-characters of SRC onto DEST.  */\nextern wchar_t *wcsncat(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n) __THROW;\n\n/* Compare S1 and S2.  */\nextern int wcscmp(const wchar_t * __s1, const wchar_t * __s2)\n__THROW __attribute_pure__;\n/* Compare N wide-characters of S1 and S2.  */\nextern int wcsncmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* Compare S1 and S2, ignoring case.  */\nextern int wcscasecmp(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int wcsncasecmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n# include <xlocale.h>\n\nextern int wcscasecmp_l(const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) __THROW;\n\nextern int wcsncasecmp_l(const wchar_t * __s1, const wchar_t * __s2, size_t __n, __locale_t __loc) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the current locale.  */\nextern int wcscoll(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the given locale.  */\nextern int wcscoll_l(const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) __THROW;\n\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm_l(wchar_t * __s1, const wchar_t * __s2, size_t __n, __locale_t __loc) __THROW;\n\n/* Duplicate S, returning an identical malloc'd string.  */\nextern wchar_t *wcsdup(const wchar_t * __s)\n__THROW __attribute_malloc__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Find the first occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcschr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\n#else\nextern wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n/* Find the last occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsrchr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\n#else\nextern wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to `wcschr'.  But it returns a pointer to\n   the closing NUL wide character in case C is not found in S.  */\nextern wchar_t *wcschrnul(const wchar_t * __s, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters not in REJECT.  */\nextern size_t wcscspn(const wchar_t * __wcs, const wchar_t * __reject)\n__THROW __attribute_pure__;\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters in  ACCEPT.  */\nextern size_t wcsspn(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n/* Find the first occurrence in WCS of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcspbrk(wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\n#else\nextern wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsstr(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\n#else\nextern wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n#endif\n\n/* Divide WCS into tokens separated by characters in DELIM.  */\nextern wchar_t *wcstok(wchar_t * __restrict __s, const wchar_t * __restrict __delim, wchar_t ** __restrict __ptr) __THROW;\n\n/* Return the number of wide characters in S.  */\nextern size_t wcslen(const wchar_t * __s)\n__THROW __attribute_pure__;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN\n/* Another name for `wcsstr' from XPG4.  */\n# ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcswcs(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\n# else\nextern wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n# endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Return the number of wide characters in S, but at most MAXLEN.  */\nextern size_t wcsnlen(const wchar_t * __s, size_t __maxlen)\n__THROW __attribute_pure__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Search N wide characters of S for C.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wmemchr(wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\n#else\nextern wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __attribute_pure__;\n#endif\n\n/* Compare N wide characters of S1 and S2.  */\nextern int wmemcmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__;\n\n/* Copy N wide characters of SRC to DEST.  */\nextern wchar_t *wmemcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n\n/* Copy N wide characters of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern wchar_t *wmemmove(wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Set N wide characters of S to C.  */\nextern wchar_t *wmemset(wchar_t * __s, wchar_t __c, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* Copy N wide characters of SRC to DEST and return pointer to following\n   wide character.  */\nextern wchar_t *wmempcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Determine whether C constitutes a valid (one-byte) multibyte\n   character.  */\nextern wint_t btowc(int __c) __THROW;\n\n/* Determine whether C corresponds to a member of the extended\n   character set whose multibyte representation is a single byte.  */\nextern int wctob(wint_t __c) __THROW;\n\n/* Determine whether PS points to an object representing the initial\n   state.  */\nextern int mbsinit(const mbstate_t * __ps)\n__THROW __attribute_pure__;\n\n/* Write wide character representation of multibyte character pointed\n   to by S to PWC.  */\nextern size_t mbrtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n, mbstate_t * __restrict __p) __THROW;\n\n/* Write multibyte representation of wide character WC to S.  */\nextern size_t wcrtomb(char *__restrict __s, wchar_t __wc, mbstate_t * __restrict __ps) __THROW;\n\n/* Return number of bytes in multibyte character pointed to by S.  */\nextern size_t __mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\nextern size_t mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_EXTERN_INLINES\n/* Define inline function as optimization.  */\n/* We can use the BTOWC and WCTOB optimizations since we know that all\n   locales must use ASCII encoding for the values in the ASCII range\n   and because the wchar_t encoding is always ISO 10646.  */\nextern wint_t __btowc_alias(int __c) __asm(\"btowc\");\n__extern_inline wint_t __NTH(btowc(int __c))\n{\n\treturn (__builtin_constant_p(__c) && __c >= '\\0' && __c <= '\\x7f' ? (wint_t) __c : __btowc_alias(__c));\n}\n\nextern int __wctob_alias(wint_t __c) __asm(\"wctob\");\n__extern_inline int __NTH(wctob(wint_t __wc))\n{\n\treturn (__builtin_constant_p(__wc) && __wc >= L'\\0' && __wc <= L'\\x7f' ? (int)__wc : __wctob_alias(__wc));\n}\n\n__extern_inline size_t __NTH(mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps))\n{\n\treturn (__ps != NULL ? mbrtowc(NULL, __s, __n, __ps) : __mbrlen(__s, __n, NULL));\n}\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write wide character representation of multibyte character string\n   SRC to DST.  */\nextern size_t mbsrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of wide character string\n   SRC to DST.  */\nextern size_t wcsrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* Write wide character representation of at most NMC bytes of the\n   multibyte character string SRC to DST.  */\nextern size_t mbsnrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __nmc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of at most NWC characters\n   from the wide character string SRC to DST.  */\nextern size_t wcsnrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __nwc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n#endif\t\t\t\t/* use POSIX 2008 */\n\n/* The following functions are extensions found in X/Open CAE.  */\n#ifdef __USE_XOPEN\n/* Determine number of column positions required for C.  */\nextern int wcwidth(wchar_t __c) __THROW;\n\n/* Determine number of column positions required for first N wide\n   characters (or fewer if S ends before this) in S.  */\nextern int wcswidth(const wchar_t * __s, size_t __n) __THROW;\n#endif\t\t\t\t/* Use X/Open.  */\n\n__BEGIN_NAMESPACE_STD\n/* Convert initial portion of the wide string NPTR to `double'\n   representation.  */\nextern double wcstod(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float wcstof(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\nextern long double wcstold(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* C99 */\n    __BEGIN_NAMESPACE_STD\n/* Convert initial portion of wide string NPTR to `long int'\n   representation.  */\nextern long int wcstol(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long int'\n   representation.  */\nextern unsigned long int wcstoul(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoll(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstoull(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* ISO C99.  */\n#ifdef __USE_GNU\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstouq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_GNU\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n# include <xlocale.h>\n\n/* Special versions of the functions above which take the locale to\n   use as an additional parameter.  */\nextern long int wcstol_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\nextern unsigned long int wcstoul_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\n__extension__ extern long long int wcstoll_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\n__extension__ extern unsigned long long int wcstoull_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\nextern double wcstod_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n\nextern float wcstof_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n\nextern long double wcstold_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n#endif\t\t\t\t/* use GNU */\n\n#ifdef __USE_XOPEN2K8\n/* Copy SRC to DEST, returning the address of the terminating L'\\0' in\n   DEST.  */\nextern wchar_t *wcpcpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src) __THROW;\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern wchar_t *wcpncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n) __THROW;\n\n/* Wide character I/O functions.  */\n\n/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces\n   a wide character string.  */\nextern __FILE *open_wmemstream(wchar_t ** __bufloc, size_t * __sizeloc) __THROW;\n#endif\n\n#if defined __USE_ISOC95 || defined __USE_UNIX98\n__BEGIN_NAMESPACE_STD\n/* Select orientation for stream.  */\nextern int fwide(__FILE * __fp, int __mode) __THROW;\n\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwprintf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */ ;\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wprintf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */ ;\n/* Write formatted output of at most N characters to S.  */\nextern int swprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */ ;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwprintf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */ ;\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwprintf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */ ;\n/* Write formatted output of at most N character to S from argument\n   list ARG.  */\nextern int vswprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */ ;\n\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wscanf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\n/* Read formatted input from S.  */\nextern int swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n\n# if defined __USE_ISOC99 && !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fwscanf, (__FILE * __restrict __stream, const wchar_t * __restrict __format, ...), __isoc99_fwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\nextern int __REDIRECT(wscanf, (const wchar_t * __restrict __format, ...), __isoc99_wscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\nextern int __REDIRECT_NTH(swscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...), __isoc99_swscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n#  else\nextern int __isoc99_fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...);\nextern int __isoc99_wscanf(const wchar_t * __restrict __format, ...);\nextern int __isoc99_swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW;\n#   define fwscanf __isoc99_fwscanf\n#   define wscanf __isoc99_wscanf\n#   define swscanf __isoc99_swscanf\n#  endif\n# endif\n\n__END_NAMESPACE_STD\n#endif\t\t\t\t/* Use ISO C95, C99 and Unix98. */\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\n/* Read formatted input from S into argument list ARG.  */\nextern int vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n\n# if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#  ifdef __REDIRECT\nextern int __REDIRECT(vfwscanf, (__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vfwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\nextern int __REDIRECT(vwscanf, (const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\nextern int __REDIRECT_NTH(vswscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vswscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n#  else\nextern int __isoc99_vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW;\n#   define vfwscanf __isoc99_vfwscanf\n#   define vwscanf __isoc99_vwscanf\n#   define vswscanf __isoc99_vswscanf\n#  endif\n# endif\n\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* Use ISO C99. */\n    __BEGIN_NAMESPACE_STD\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fgetwc(__FILE * __stream);\nextern wint_t getwc(__FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t getwchar(void);\n\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fputwc(wchar_t __wc, __FILE * __stream);\nextern wint_t putwc(wchar_t __wc, __FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t putwchar(wchar_t __wc);\n\n/* Get a newline-terminated wide character string of finite length\n   from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wchar_t *fgetws(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputws(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t ungetwc(wint_t __wc, __FILE * __stream);\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t getwc_unlocked(__FILE * __stream);\nextern wint_t getwchar_unlocked(void);\n\n/* This is the wide character version of a GNU extension.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fgetwc_unlocked(__FILE * __stream);\n\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fputwc_unlocked(wchar_t __wc, __FILE * __stream);\n\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t putwc_unlocked(wchar_t __wc, __FILE * __stream);\nextern wint_t putwchar_unlocked(wchar_t __wc);\n\n/* This function does the same as `fgetws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wchar_t *fgetws_unlocked(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* This function does the same as `fputws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputws_unlocked(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n#endif\n\n__BEGIN_NAMESPACE_C99\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE wide characters and return the number\n   of wide characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t wcsftime(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp) __THROW;\n__END_NAMESPACE_C99\n# ifdef __USE_GNU\n# include <xlocale.h>\n/* Similar to `wcsftime' but takes the information from\n   the provided locale and not the global locale.  */\nextern size_t wcsftime_l(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp, __locale_t __loc) __THROW;\n# endif\n\n/* The X/Open standard demands that most of the functions defined in\n   the <wctype.h> header must also appear here.  This is probably\n   because some X/Open members wrote their implementation before the\n   ISO C standard was published and introduced the better solution.\n   We have to provide these definitions for compliance reasons but we\n   do this nonsense only if really necessary.  */\n#if defined __USE_UNIX98 && !defined __USE_GNU\n# define __need_iswxxx\n# include <wctype.h>\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n# include <bits/wchar2.h>\n#endif\n\n#ifdef __LDBL_COMPAT\n# include <bits/wchar-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* _WCHAR_H defined */\n#endif\t\t\t\t/* wchar.h  */\n/* Undefine all __need_* constants in case we are included to get those\n   constants but the whole file was already read.  */\n#undef __need_mbstate_t\n#undef __need_wint_t\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/wctype.h",
    "content": "/* Copyright (C) 1996-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.25\n *\tWide character classification and mapping utilities  <wctype.h>\n */\n\n#ifndef _WCTYPE_H\n\n#include <features.h>\n#include <bits/types.h>\n\n#ifndef __need_iswxxx\n# define _WCTYPE_H\t1\n\n/* Get wint_t from <wchar.h>.  */\n# define __need_wint_t\n# include <wchar.h>\n\n/* Constant expression of type `wint_t' whose value does not correspond\n   to any member of the extended character set.  */\n# ifndef WEOF\n#  define WEOF (0xffffffffu)\n# endif\n#endif\n#undef __need_iswxxx\n\n/* The following part is also used in the <wcsmbs.h> header when compiled\n   in the Unix98 compatibility mode.  */\n#ifndef __iswxxx_defined\n# define __iswxxx_defined\t1\n\n__BEGIN_NAMESPACE_C99\n/* Scalar type that can hold values which represent locale-specific\n   character classifications.  */\ntypedef unsigned long int wctype_t;\n__END_NAMESPACE_C99\n# ifndef _ISwbit\n/* The characteristics are stored always in network byte order (big\n   endian).  We define the bit value interpretations here dependent on the\n   machine's byte order.  */\n#  include <endian.h>\n#  if __BYTE_ORDER == __BIG_ENDIAN\n#   define _ISwbit(bit)\t(1 << (bit))\n#  else\t\t\t\t/* __BYTE_ORDER == __LITTLE_ENDIAN */\n#   define _ISwbit(bit)\t\\\n\t((bit) < 8 ? (int) ((1UL << (bit)) << 24)\t\t\t      \\\n\t : ((bit) < 16 ? (int) ((1UL << (bit)) << 8)\t\t\t      \\\n\t    : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8)\t\t\t      \\\n\t       : (int) ((1UL << (bit)) >> 24))))\n#  endif\n    enum {\n\t__ISwupper = 0,\t\t/* UPPERCASE.  */\n\t__ISwlower = 1,\t\t/* lowercase.  */\n\t__ISwalpha = 2,\t\t/* Alphabetic.  */\n\t__ISwdigit = 3,\t\t/* Numeric.  */\n\t__ISwxdigit = 4,\t/* Hexadecimal numeric.  */\n\t__ISwspace = 5,\t\t/* Whitespace.  */\n\t__ISwprint = 6,\t\t/* Printing.  */\n\t__ISwgraph = 7,\t\t/* Graphical.  */\n\t__ISwblank = 8,\t\t/* Blank (usually SPC and TAB).  */\n\t__ISwcntrl = 9,\t\t/* Control character.  */\n\t__ISwpunct = 10,\t/* Punctuation.  */\n\t__ISwalnum = 11,\t/* Alphanumeric.  */\n\n\t_ISwupper = _ISwbit(__ISwupper),\t/* UPPERCASE.  */\n\t_ISwlower = _ISwbit(__ISwlower),\t/* lowercase.  */\n\t_ISwalpha = _ISwbit(__ISwalpha),\t/* Alphabetic.  */\n\t_ISwdigit = _ISwbit(__ISwdigit),\t/* Numeric.  */\n\t_ISwxdigit = _ISwbit(__ISwxdigit),\t/* Hexadecimal numeric.  */\n\t_ISwspace = _ISwbit(__ISwspace),\t/* Whitespace.  */\n\t_ISwprint = _ISwbit(__ISwprint),\t/* Printing.  */\n\t_ISwgraph = _ISwbit(__ISwgraph),\t/* Graphical.  */\n\t_ISwblank = _ISwbit(__ISwblank),\t/* Blank (usually SPC and TAB).  */\n\t_ISwcntrl = _ISwbit(__ISwcntrl),\t/* Control character.  */\n\t_ISwpunct = _ISwbit(__ISwpunct),\t/* Punctuation.  */\n\t_ISwalnum = _ISwbit(__ISwalnum)\t/* Alphanumeric.  */\n};\n# endif\t\t\t\t/* Not _ISwbit  */\n\n__BEGIN_DECLS __BEGIN_NAMESPACE_C99\n/*\n * Wide-character classification functions: 7.15.2.1.\n */\n/* Test for any wide character for which `iswalpha' or `iswdigit' is\n   true.  */\nextern int iswalnum(wint_t __wc) __THROW;\n\n/* Test for any wide character for which `iswupper' or 'iswlower' is\n   true, or any wide character that is one of a locale-specific set of\n   wide-characters for which none of `iswcntrl', `iswdigit',\n   `iswpunct', or `iswspace' is true.  */\nextern int iswalpha(wint_t __wc) __THROW;\n\n/* Test for any control wide character.  */\nextern int iswcntrl(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to a decimal-digit\n   character.  */\nextern int iswdigit(wint_t __wc) __THROW;\n\n/* Test for any wide character for which `iswprint' is true and\n   `iswspace' is false.  */\nextern int iswgraph(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to a lowercase letter\n   or is one of a locale-specific set of wide characters for which\n   none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */\nextern int iswlower(wint_t __wc) __THROW;\n\n/* Test for any printing wide character.  */\nextern int iswprint(wint_t __wc) __THROW;\n\n/* Test for any printing wide character that is one of a\n   locale-specific et of wide characters for which neither `iswspace'\n   nor `iswalnum' is true.  */\nextern int iswpunct(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to a locale-specific\n   set of wide characters for which none of `iswalnum', `iswgraph', or\n   `iswpunct' is true.  */\nextern int iswspace(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to an uppercase letter\n   or is one of a locale-specific set of wide character for which none\n   of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */\nextern int iswupper(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to a hexadecimal-digit\n   character equivalent to that performed be the functions described\n   in the previous subclause.  */\nextern int iswxdigit(wint_t __wc) __THROW;\n\n/* Test for any wide character that corresponds to a standard blank\n   wide character or a locale-specific set of wide characters for\n   which `iswalnum' is false.  */\n# ifdef __USE_ISOC99\nextern int iswblank(wint_t __wc) __THROW;\n# endif\n\n/*\n * Extensible wide-character classification functions: 7.15.2.2.\n */\n\n/* Construct value that describes a class of wide characters identified\n   by the string argument PROPERTY.  */\nextern wctype_t wctype(const char *__property) __THROW;\n\n/* Determine whether the wide-character WC has the property described by\n   DESC.  */\nextern int iswctype(wint_t __wc, wctype_t __desc) __THROW;\n__END_NAMESPACE_C99\n/*\n * Wide-character case-mapping functions: 7.15.3.1.\n */\n    __BEGIN_NAMESPACE_C99\n/* Scalar type that can hold values which represent locale-specific\n   character mappings.  */\ntypedef const __int32_t *wctrans_t;\n__END_NAMESPACE_C99\n#ifdef __USE_GNU\n__USING_NAMESPACE_C99(wctrans_t)\n#endif\n__BEGIN_NAMESPACE_C99\n/* Converts an uppercase letter to the corresponding lowercase letter.  */\nextern wint_t towlower(wint_t __wc) __THROW;\n\n/* Converts an lowercase letter to the corresponding uppercase letter.  */\nextern wint_t towupper(wint_t __wc) __THROW;\n__END_NAMESPACE_C99 __END_DECLS\n#endif\t\t\t\t/* need iswxxx.  */\n/* The remaining definitions and declarations must not appear in the\n   <wchar.h> header.  */\n#ifdef _WCTYPE_H\n/*\n * Extensible wide-character mapping functions: 7.15.3.2.\n */\n__BEGIN_DECLS __BEGIN_NAMESPACE_C99\n/* Construct value that describes a mapping between wide characters\n   identified by the string argument PROPERTY.  */\nextern wctrans_t wctrans(const char *__property) __THROW;\n\n/* Map the wide character WC using the mapping described by DESC.  */\nextern wint_t towctrans(wint_t __wc, wctrans_t __desc) __THROW;\n__END_NAMESPACE_C99\n# ifdef __USE_XOPEN2K8\n/* Declare the interface to extended locale model.  */\n#  include <xlocale.h>\n/* Test for any wide character for which `iswalpha' or `iswdigit' is\n   true.  */\nextern int iswalnum_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character for which `iswupper' or 'iswlower' is\n   true, or any wide character that is one of a locale-specific set of\n   wide-characters for which none of `iswcntrl', `iswdigit',\n   `iswpunct', or `iswspace' is true.  */\nextern int iswalpha_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any control wide character.  */\nextern int iswcntrl_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to a decimal-digit\n   character.  */\nextern int iswdigit_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character for which `iswprint' is true and\n   `iswspace' is false.  */\nextern int iswgraph_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to a lowercase letter\n   or is one of a locale-specific set of wide characters for which\n   none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */\nextern int iswlower_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any printing wide character.  */\nextern int iswprint_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any printing wide character that is one of a\n   locale-specific et of wide characters for which neither `iswspace'\n   nor `iswalnum' is true.  */\nextern int iswpunct_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to a locale-specific\n   set of wide characters for which none of `iswalnum', `iswgraph', or\n   `iswpunct' is true.  */\nextern int iswspace_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to an uppercase letter\n   or is one of a locale-specific set of wide character for which none\n   of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */\nextern int iswupper_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to a hexadecimal-digit\n   character equivalent to that performed be the functions described\n   in the previous subclause.  */\nextern int iswxdigit_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Test for any wide character that corresponds to a standard blank\n   wide character or a locale-specific set of wide characters for\n   which `iswalnum' is false.  */\nextern int iswblank_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Construct value that describes a class of wide characters identified\n   by the string argument PROPERTY.  */\nextern wctype_t wctype_l(const char *__property, __locale_t __locale) __THROW;\n\n/* Determine whether the wide-character WC has the property described by\n   DESC.  */\nextern int iswctype_l(wint_t __wc, wctype_t __desc, __locale_t __locale) __THROW;\n\n/*\n * Wide-character case-mapping functions.\n */\n\n/* Converts an uppercase letter to the corresponding lowercase letter.  */\nextern wint_t towlower_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Converts an lowercase letter to the corresponding uppercase letter.  */\nextern wint_t towupper_l(wint_t __wc, __locale_t __locale) __THROW;\n\n/* Construct value that describes a mapping between wide characters\n   identified by the string argument PROPERTY.  */\nextern wctrans_t wctrans_l(const char *__property, __locale_t __locale) __THROW;\n\n/* Map the wide character WC using the mapping described by DESC.  */\nextern wint_t towctrans_l(wint_t __wc, wctrans_t __desc, __locale_t __locale) __THROW;\n\n# endif\t\t\t\t/* Use POSIX 2008.  */\n\n__END_DECLS\n#endif\t\t\t\t/* __WCTYPE_H defined.  */\n#endif\t\t\t\t/* wctype.h  */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/xlocale.h",
    "content": "/* Definition of locale datatype.\n   Copyright (C) 1997-2015 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _XLOCALE_H\n#define _XLOCALE_H\t1\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  The file and\n   this data structure is not standardized.  Don't rely on it.  It can\n   go away without warning.  */\ntypedef struct __locale_struct {\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tstruct __locale_data *__locales[13];\t/* 13 = __LC_LAST. */\n\n\t/* To increase the speed of this solution we add some special members.  */\n\tconst unsigned short int *__ctype_b;\n\tconst int *__ctype_tolower;\n\tconst int *__ctype_toupper;\n\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tconst char *__names[13];\n} *__locale_t;\n\n/* POSIX 2008 makes locale_t official.  */\ntypedef __locale_t locale_t;\n\n#endif\t\t\t\t/* xlocale.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2013 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX\t\t\t/* may be set to #if 1 by ./configure */\n#  define Z_PREFIX_SET\n\n/* all linked symbols */\n#  define _dist_code            z__dist_code\n#  define _length_code          z__length_code\n#  define _tr_align             z__tr_align\n#  define _tr_flush_bits        z__tr_flush_bits\n#  define _tr_flush_block       z__tr_flush_block\n#  define _tr_init              z__tr_init\n#  define _tr_stored_block      z__tr_stored_block\n#  define _tr_tally             z__tr_tally\n#  define adler32               z_adler32\n#  define adler32_combine       z_adler32_combine\n#  define adler32_combine64     z_adler32_combine64\n#  ifndef Z_SOLO\n#    define compress              z_compress\n#    define compress2             z_compress2\n#    define compressBound         z_compressBound\n#  endif\n#  define crc32                 z_crc32\n#  define crc32_combine         z_crc32_combine\n#  define crc32_combine64       z_crc32_combine64\n#  define deflate               z_deflate\n#  define deflateBound          z_deflateBound\n#  define deflateCopy           z_deflateCopy\n#  define deflateEnd            z_deflateEnd\n#  define deflateInit2_         z_deflateInit2_\n#  define deflateInit_          z_deflateInit_\n#  define deflateParams         z_deflateParams\n#  define deflatePending        z_deflatePending\n#  define deflatePrime          z_deflatePrime\n#  define deflateReset          z_deflateReset\n#  define deflateResetKeep      z_deflateResetKeep\n#  define deflateSetDictionary  z_deflateSetDictionary\n#  define deflateSetHeader      z_deflateSetHeader\n#  define deflateTune           z_deflateTune\n#  define deflate_copyright     z_deflate_copyright\n#  define get_crc_table         z_get_crc_table\n#  ifndef Z_SOLO\n#    define gz_error              z_gz_error\n#    define gz_intmax             z_gz_intmax\n#    define gz_strwinerror        z_gz_strwinerror\n#    define gzbuffer              z_gzbuffer\n#    define gzclearerr            z_gzclearerr\n#    define gzclose               z_gzclose\n#    define gzclose_r             z_gzclose_r\n#    define gzclose_w             z_gzclose_w\n#    define gzdirect              z_gzdirect\n#    define gzdopen               z_gzdopen\n#    define gzeof                 z_gzeof\n#    define gzerror               z_gzerror\n#    define gzflush               z_gzflush\n#    define gzgetc                z_gzgetc\n#    define gzgetc_               z_gzgetc_\n#    define gzgets                z_gzgets\n#    define gzoffset              z_gzoffset\n#    define gzoffset64            z_gzoffset64\n#    define gzopen                z_gzopen\n#    define gzopen64              z_gzopen64\n#    ifdef _WIN32\n#      define gzopen_w              z_gzopen_w\n#    endif\n#    define gzprintf              z_gzprintf\n#    define gzvprintf             z_gzvprintf\n#    define gzputc                z_gzputc\n#    define gzputs                z_gzputs\n#    define gzread                z_gzread\n#    define gzrewind              z_gzrewind\n#    define gzseek                z_gzseek\n#    define gzseek64              z_gzseek64\n#    define gzsetparams           z_gzsetparams\n#    define gztell                z_gztell\n#    define gztell64              z_gztell64\n#    define gzungetc              z_gzungetc\n#    define gzwrite               z_gzwrite\n#  endif\n#  define inflate               z_inflate\n#  define inflateBack           z_inflateBack\n#  define inflateBackEnd        z_inflateBackEnd\n#  define inflateBackInit_      z_inflateBackInit_\n#  define inflateCopy           z_inflateCopy\n#  define inflateEnd            z_inflateEnd\n#  define inflateGetHeader      z_inflateGetHeader\n#  define inflateInit2_         z_inflateInit2_\n#  define inflateInit_          z_inflateInit_\n#  define inflateMark           z_inflateMark\n#  define inflatePrime          z_inflatePrime\n#  define inflateReset          z_inflateReset\n#  define inflateReset2         z_inflateReset2\n#  define inflateSetDictionary  z_inflateSetDictionary\n#  define inflateGetDictionary  z_inflateGetDictionary\n#  define inflateSync           z_inflateSync\n#  define inflateSyncPoint      z_inflateSyncPoint\n#  define inflateUndermine      z_inflateUndermine\n#  define inflateResetKeep      z_inflateResetKeep\n#  define inflate_copyright     z_inflate_copyright\n#  define inflate_fast          z_inflate_fast\n#  define inflate_table         z_inflate_table\n#  ifndef Z_SOLO\n#    define uncompress            z_uncompress\n#  endif\n#  define zError                z_zError\n#  ifndef Z_SOLO\n#    define zcalloc               z_zcalloc\n#    define zcfree                z_zcfree\n#  endif\n#  define zlibCompileFlags      z_zlibCompileFlags\n#  define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#  define Byte                  z_Byte\n#  define Bytef                 z_Bytef\n#  define alloc_func            z_alloc_func\n#  define charf                 z_charf\n#  define free_func             z_free_func\n#  ifndef Z_SOLO\n#    define gzFile                z_gzFile\n#  endif\n#  define gz_header             z_gz_header\n#  define gz_headerp            z_gz_headerp\n#  define in_func               z_in_func\n#  define intf                  z_intf\n#  define out_func              z_out_func\n#  define uInt                  z_uInt\n#  define uIntf                 z_uIntf\n#  define uLong                 z_uLong\n#  define uLongf                z_uLongf\n#  define voidp                 z_voidp\n#  define voidpc                z_voidpc\n#  define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#  define gz_header_s           z_gz_header_s\n#  define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#  define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#  define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#  ifndef WIN32\n#    define WIN32\n#  endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#  if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#    ifndef SYS16BIT\n#      define SYS16BIT\n#    endif\n#  endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#  define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#  define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#  ifndef STDC\n#    define STDC\n#  endif\n#  if __STDC_VERSION__ >= 199901L\n#    ifndef STDC99\n#      define STDC99\n#    endif\n#  endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#  define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#  define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)\t/* iSeries (formerly AS/400). */\n#  define STDC\n#endif\n\n#ifndef STDC\n#  ifndef const\t\t\t/* cannot use !defined(STDC) && !defined(const) on Mac */\n#    define const\t\t/* note: need a more gentle solution here */\n#  endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#  define z_const const\n#else\n#  define z_const\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#  ifdef MAXSEG_64K\n#    define MAX_MEM_LEVEL 8\n#  else\n#    define MAX_MEM_LEVEL 9\n#  endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#  define MAX_WBITS   15\t/* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n\t\t\t/* Type declarations */\n\n#ifndef OF\t\t\t/* function prototypes */\n#  ifdef STDC\n#    define OF(args)  args\n#  else\n#    define OF(args)  ()\n#  endif\n#endif\n\n#ifndef Z_ARG\t\t\t/* function prototypes for stdarg */\n#  if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#    define Z_ARG(args)  args\n#  else\n#    define Z_ARG(args)  ()\n#  endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#  if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef _MSC_VER\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#  if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#    define SMALL_MEDIUM\n#    ifdef __BORLANDC__\n#      define FAR _far\n#    else\n#      define FAR far\n#    endif\n#  endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#  ifdef ZLIB_DLL\n#    if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#      ifdef ZLIB_INTERNAL\n#        define ZEXTERN extern __declspec(dllexport)\n#      else\n#        define ZEXTERN extern __declspec(dllimport)\n#      endif\n#    endif\n#  endif\t\t\t/* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#  ifdef ZLIB_WINAPI\n#    ifdef FAR\n#      undef FAR\n#    endif\n#    include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#    define ZEXPORT WINAPI\n#    ifdef WIN32\n#      define ZEXPORTVA WINAPIV\n#    else\n#      define ZEXPORTVA FAR CDECL\n#    endif\n#  endif\n#endif\n\n#if defined (__BEOS__)\n#  ifdef ZLIB_DLL\n#    ifdef ZLIB_INTERNAL\n#      define ZEXPORT   __declspec(dllexport)\n#      define ZEXPORTVA __declspec(dllexport)\n#    else\n#      define ZEXPORT   __declspec(dllimport)\n#      define ZEXPORTVA __declspec(dllimport)\n#    endif\n#  endif\n#endif\n\n#ifndef ZEXTERN\n#  define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#  define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#  define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#  define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char Byte;\t/* 8 bits */\n#endif\ntypedef unsigned int uInt;\t/* 16 bits or more */\ntypedef unsigned long uLong;\t/* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#  define Bytef Byte FAR\n#else\ntypedef Byte FAR Bytef;\n#endif\ntypedef char FAR charf;\ntypedef int FAR intf;\ntypedef uInt FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\ntypedef void const *voidpc;\ntypedef void FAR *voidpf;\ntypedef void *voidp;\n#else\ntypedef Byte const *voidpc;\ntypedef Byte FAR *voidpf;\ntypedef Byte *voidp;\n#endif\n\n#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)\n#  include <limits.h>\n#  if (UINT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned\n#  elif (ULONG_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned long\n#  elif (USHRT_MAX == 0xffffffffUL)\n#    define Z_U4 unsigned short\n#  endif\n#endif\n\n#ifdef Z_U4\ntypedef Z_U4 z_crc_t;\n#else\ntypedef unsigned long z_crc_t;\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#  define Z_HAVE_UNISTD_H\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#  define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#  ifndef Z_SOLO\n#    include <sys/types.h>\t/* for off_t */\n#  endif\n#endif\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n#    include <stdarg.h>\t\t/* for va_list */\n#  endif\n#endif\n\n#ifdef _WIN32\n#  ifndef Z_SOLO\n#    include <stddef.h>\t\t/* for wchar_t */\n#  endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1\n#  undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)\n#  define Z_HAVE_UNISTD_H\n#endif\n#ifndef Z_SOLO\n#  if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#    include <unistd.h>\t\t/* for SEEK_*, off_t, and _LFS64_LARGEFILE */\n#    ifdef VMS\n#      include <unixio.h>\t/* for off_t */\n#    endif\n#    ifndef z_off_t\n#      define z_off_t off_t\n#    endif\n#  endif\n#endif\n\n#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0\n#  define Z_LFS64\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)\n#  define Z_LARGE64\n#endif\n\n#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)\n#  define Z_WANT64\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#  define SEEK_SET        0\t/* Seek from beginning of file.  */\n#  define SEEK_CUR        1\t/* Seek from current position.  */\n#  define SEEK_END        2\t/* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#  define z_off_t long\n#endif\n\n#if !defined(_WIN32) && defined(Z_LARGE64)\n#  define z_off64_t off64_t\n#else\n#  if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)\n#    define z_off64_t __int64\n#  else\n#    define z_off64_t z_off_t\n#  endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n#pragma map(deflateInit_,\"DEIN\")\n#pragma map(deflateInit2_,\"DEIN2\")\n#pragma map(deflateEnd,\"DEEND\")\n#pragma map(deflateBound,\"DEBND\")\n#pragma map(inflateInit_,\"ININ\")\n#pragma map(inflateInit2_,\"ININ2\")\n#pragma map(inflateEnd,\"INEND\")\n#pragma map(inflateSync,\"INSY\")\n#pragma map(inflateSetDictionary,\"INSEDI\")\n#pragma map(compressBound,\"CMBND\")\n#pragma map(inflate_table,\"INTABL\")\n#pragma map(inflate_fast,\"INFA\")\n#pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif\t\t\t\t/* ZCONF_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/include/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.8, April 28th, 2013\n\n  Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.8\"\n#define ZLIB_VERNUM 0x1280\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 8\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\n\ttypedef voidpf(*alloc_func) OF((voidpf opaque, uInt items, uInt size));\n\ttypedef void (*free_func) OF((voidpf opaque, voidpf address));\n\n\tstruct internal_state;\n\n\ttypedef struct z_stream_s {\n\t\tz_const Bytef *next_in;\t/* next input byte */\n\t\tuInt avail_in;\t/* number of bytes available at next_in */\n\t\tuLong total_in;\t/* total number of input bytes read so far */\n\n\t\tBytef *next_out;\t/* next output byte should be put there */\n\t\tuInt avail_out;\t/* remaining free space at next_out */\n\t\tuLong total_out;\t/* total number of bytes output so far */\n\n\t\tz_const char *msg;\t/* last error message, NULL if no error */\n\t\tstruct internal_state FAR *state;\t/* not visible by applications */\n\n\t\talloc_func zalloc;\t/* used to allocate the internal state */\n\t\tfree_func zfree;\t/* used to free the internal state */\n\t\tvoidpf opaque;\t/* private data object passed to zalloc and zfree */\n\n\t\tint data_type;\t/* best guess about the data type: binary or text */\n\t\tuLong adler;\t/* adler32 value of the uncompressed data */\n\t\tuLong reserved;\t/* reserved for future use */\n\t} z_stream;\n\n\ttypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\n\ttypedef struct gz_header_s {\n\t\tint text;\t/* true if compressed data believed to be text */\n\t\tuLong time;\t/* modification time */\n\t\tint xflags;\t/* extra flags (not used when writing a gzip file) */\n\t\tint os;\t\t/* operating system */\n\t\tBytef *extra;\t/* pointer to extra field or Z_NULL if none */\n\t\tuInt extra_len;\t/* extra field length (valid if extra != Z_NULL) */\n\t\tuInt extra_max;\t/* space at extra (only when reading header) */\n\t\tBytef *name;\t/* pointer to zero-terminated file name or Z_NULL */\n\t\tuInt name_max;\t/* space at name (only when reading header) */\n\t\tBytef *comment;\t/* pointer to zero-terminated comment or Z_NULL */\n\t\tuInt comm_max;\t/* space at comment (only when reading header) */\n\t\tint hcrc;\t/* true if there was or will be a header crc */\n\t\tint done;\t/* true when done reading gzip header (not used\n\t\t\t\t   when writing a gzip file) */\n\t} gz_header;\n\n\ttypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n\t/* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT\t/* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0\t\t/* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\t/* basic functions */\n\n\tZEXTERN const char *ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  Then deflate is guaranteed to\n  return Z_STREAM_END.  If not enough output space is provided, deflate will\n  not return Z_STREAM_END, and it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\tZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all of the uncompressed data for the\n  operation to complete.  (The size of the uncompressed data may have been\n  saved by the compressor for this purpose.) The use of Z_FINISH is not\n  required to perform an inflation in one step.  However it may be used to\n  inform inflate that a faster approach can be used for the single inflate()\n  call.  Z_FINISH also informs inflate to not maintain a sliding window if the\n  stream completes, which reduces inflate's memory footprint.  If the stream\n  does not complete, either because not all of the stream is provided or not\n  enough output space is provided, then a sliding window will be allocated and\n  inflate() can be called again to continue the operation as if Z_NO_FLUSH had\n  been used.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  producted so far.  The CRC-32 is checked against the gzip trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\tZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\t/* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\n\tZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\n\tZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\n\tZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, unsigned *pending, int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\n\tZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\n\tZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, Bytef * dictionary, uInt * dictLength));\n/*\n     Returns the sliding dictionary being maintained by inflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If inflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurrences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\n\tZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\n\tZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n\tZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\n\ttypedef unsigned (*in_func) OF((void FAR *, z_const unsigned char FAR * FAR *));\n\ttypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\n\tZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR * in_desc, out_func out, void FAR * out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is potentially more efficient than\n   inflate() for file i/o applications, in that it avoids copying between the\n   output and the sliding window by simply making the window itself the output\n   buffer.  inflate() can be faster on modern CPUs when used with large\n   buffers.  inflateBack() trusts the application to not change the output\n   buffer passed by the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\n\tZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\n\tZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n\t/* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\n\tZEXTERN int ZEXPORT compress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\n\tZEXTERN int ZEXPORT compress2 OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen, int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\n\tZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\n\tZEXTERN int ZEXPORT uncompress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\n\t/* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\n\ttypedef struct gzFile_s *gzFile;\t/* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.  The addition of\n   \"x\" when writing will create the file exclusively, which fails if the file\n   already exists.  On systems that support it, the addition of \"e\" when\n   reading or writing will set the flag to close the file on an execve() call.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\n\tZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\n\tZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\n\tZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\n\tZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\n\tZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\n\tZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...))\n#ifdef __GNUC__\n\t    __attribute__ ((__format__(__printf__, 2, 3)))\n#endif\n\t    ;\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\n\tZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\n\tZEXTERN char *ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\n\tZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\n\tZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\n\tZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\n\tZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\n\tZEXTERN int ZEXPORT gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\n\tZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\n\tZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\n\tZEXTERN int ZEXPORT gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\n\tZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\n\tZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\n\tZEXTERN const char *ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\n\tZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n\t/* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\n\tZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef * buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\n\tZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef * buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the crc.  Pre- and post-conditioning (one's complement) is\n   performed within this function so it shouldn't be done by the application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\t/* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\n\tZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR * window, const char *version, int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                      (int)sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                      ZLIB_VERSION, (int)sizeof(z_stream))\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\n\tstruct gzFile_s {\n\t\tunsigned have;\n\t\tunsigned char *next;\n\t\tz_off64_t pos;\n\t};\n\tZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));\t/* backward compatibility */\n#ifdef Z_PREFIX_SET\n#  undef z_gzgetc\n#  define z_gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))\n#else\n#  define gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))\n#endif\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#ifdef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n\tZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)\n#  ifdef Z_PREFIX_SET\n#    define z_gzopen z_gzopen64\n#    define z_gzseek z_gzseek64\n#    define z_gztell z_gztell64\n#    define z_gzoffset z_gzoffset64\n#    define z_adler32_combine z_adler32_combine64\n#    define z_crc32_combine z_crc32_combine64\n#  else\n#    define gzopen gzopen64\n#    define gzseek gzseek64\n#    define gztell gztell64\n#    define gzoffset gzoffset64\n#    define adler32_combine adler32_combine64\n#    define crc32_combine crc32_combine64\n#  endif\n#  ifndef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#  endif\n#else\n\tZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else\t\t\t\t/* Z_SOLO */\n\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n/* undocumented functions */\n\tZEXTERN const char *ZEXPORT zError OF((int));\n\tZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));\n\tZEXTERN const z_crc_t FAR *ZEXPORT get_crc_table OF((void));\n\tZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));\n\tZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));\n\tZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));\n#if defined(_WIN32) && !defined(Z_SOLO)\n\tZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t * path, const char *mode));\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#  ifndef Z_SOLO\n\tZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format, va_list va));\n#  endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* ZLIB_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include/float.h",
    "content": "/* Copyright (C) 2002-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  5.2.4.2.2  Characteristics of floating types <float.h>\n */\n\n#ifndef _FLOAT_H___\n#define _FLOAT_H___\n\n/* Radix of exponent representation, b. */\n#undef FLT_RADIX\n#define FLT_RADIX\t__FLT_RADIX__\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef FLT_MANT_DIG\n#undef DBL_MANT_DIG\n#undef LDBL_MANT_DIG\n#define FLT_MANT_DIG\t__FLT_MANT_DIG__\n#define DBL_MANT_DIG\t__DBL_MANT_DIG__\n#define LDBL_MANT_DIG\t__LDBL_MANT_DIG__\n\n/* Number of decimal digits, q, such that any floating-point number with q\n   decimal digits can be rounded into a floating-point number with p radix b\n   digits and back again without change to the q decimal digits,\n\n\tp * log10(b)\t\t\tif b is a power of 10\n\tfloor((p - 1) * log10(b))\totherwise\n*/\n#undef FLT_DIG\n#undef DBL_DIG\n#undef LDBL_DIG\n#define FLT_DIG\t\t__FLT_DIG__\n#define DBL_DIG\t\t__DBL_DIG__\n#define LDBL_DIG\t__LDBL_DIG__\n\n/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */\n#undef FLT_MIN_EXP\n#undef DBL_MIN_EXP\n#undef LDBL_MIN_EXP\n#define FLT_MIN_EXP\t__FLT_MIN_EXP__\n#define DBL_MIN_EXP\t__DBL_MIN_EXP__\n#define LDBL_MIN_EXP\t__LDBL_MIN_EXP__\n\n/* Minimum negative integer such that 10 raised to that power is in the\n   range of normalized floating-point numbers,\n\n\tceil(log10(b) * (emin - 1))\n*/\n#undef FLT_MIN_10_EXP\n#undef DBL_MIN_10_EXP\n#undef LDBL_MIN_10_EXP\n#define FLT_MIN_10_EXP\t__FLT_MIN_10_EXP__\n#define DBL_MIN_10_EXP\t__DBL_MIN_10_EXP__\n#define LDBL_MIN_10_EXP\t__LDBL_MIN_10_EXP__\n\n/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax.  */\n#undef FLT_MAX_EXP\n#undef DBL_MAX_EXP\n#undef LDBL_MAX_EXP\n#define FLT_MAX_EXP\t__FLT_MAX_EXP__\n#define DBL_MAX_EXP\t__DBL_MAX_EXP__\n#define LDBL_MAX_EXP\t__LDBL_MAX_EXP__\n\n/* Maximum integer such that 10 raised to that power is in the range of\n   representable finite floating-point numbers,\n\n\tfloor(log10((1 - b**-p) * b**emax))\n*/\n#undef FLT_MAX_10_EXP\n#undef DBL_MAX_10_EXP\n#undef LDBL_MAX_10_EXP\n#define FLT_MAX_10_EXP\t__FLT_MAX_10_EXP__\n#define DBL_MAX_10_EXP\t__DBL_MAX_10_EXP__\n#define LDBL_MAX_10_EXP\t__LDBL_MAX_10_EXP__\n\n/* Maximum representable finite floating-point number,\n\n\t(1 - b**-p) * b**emax\n*/\n#undef FLT_MAX\n#undef DBL_MAX\n#undef LDBL_MAX\n#define FLT_MAX\t\t__FLT_MAX__\n#define DBL_MAX\t\t__DBL_MAX__\n#define LDBL_MAX\t__LDBL_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type, b**1-p.  */\n#undef FLT_EPSILON\n#undef DBL_EPSILON\n#undef LDBL_EPSILON\n#define FLT_EPSILON\t__FLT_EPSILON__\n#define DBL_EPSILON\t__DBL_EPSILON__\n#define LDBL_EPSILON\t__LDBL_EPSILON__\n\n/* Minimum normalized positive floating-point number, b**(emin - 1).  */\n#undef FLT_MIN\n#undef DBL_MIN\n#undef LDBL_MIN\n#define FLT_MIN\t\t__FLT_MIN__\n#define DBL_MIN\t\t__DBL_MIN__\n#define LDBL_MIN\t__LDBL_MIN__\n\n/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown.  */\n/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */\n#undef FLT_ROUNDS\n#define FLT_ROUNDS 1\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n/* The floating-point expression evaluation method.\n        -1  indeterminate\n         0  evaluate all operations and constants just to the range and\n            precision of the type\n         1  evaluate operations and constants of type float and double\n            to the range and precision of the double type, evaluate\n            long double operations and constants to the range and\n            precision of the long double type\n         2  evaluate all operations and constants to the range and\n            precision of the long double type\n\n   ??? This ought to change with the setting of the fp control word;\n   the value provided by the compiler assumes the widest setting.  */\n#undef FLT_EVAL_METHOD\n#define FLT_EVAL_METHOD\t__FLT_EVAL_METHOD__\n\n/* Number of decimal digits, n, such that any floating-point number in the\n   widest supported floating type with pmax radix b digits can be rounded\n   to a floating-point number with n decimal digits and back again without\n   change to the value,\n\n\tpmax * log10(b)\t\t\tif b is a power of 10\n\tceil(1 + pmax * log10(b))\totherwise\n*/\n#undef DECIMAL_DIG\n#define DECIMAL_DIG\t__DECIMAL_DIG__\n\n#endif\t\t\t\t/* C99 */\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L\n/* Versions of DECIMAL_DIG for each floating-point type.  */\n#undef FLT_DECIMAL_DIG\n#undef DBL_DECIMAL_DIG\n#undef LDBL_DECIMAL_DIG\n#define FLT_DECIMAL_DIG\t\t__FLT_DECIMAL_DIG__\n#define DBL_DECIMAL_DIG\t\t__DBL_DECIMAL_DIG__\n#define LDBL_DECIMAL_DIG\t__DECIMAL_DIG__\n\n/* Whether types support subnormal numbers.  */\n#undef FLT_HAS_SUBNORM\n#undef DBL_HAS_SUBNORM\n#undef LDBL_HAS_SUBNORM\n#define FLT_HAS_SUBNORM\t\t__FLT_HAS_DENORM__\n#define DBL_HAS_SUBNORM\t\t__DBL_HAS_DENORM__\n#define LDBL_HAS_SUBNORM\t__LDBL_HAS_DENORM__\n\n/* Minimum positive values, including subnormals.  */\n#undef FLT_TRUE_MIN\n#undef DBL_TRUE_MIN\n#undef LDBL_TRUE_MIN\n#if __FLT_HAS_DENORM__\n#define FLT_TRUE_MIN\t__FLT_DENORM_MIN__\n#else\n#define FLT_TRUE_MIN\t__FLT_MIN__\n#endif\n#if __DBL_HAS_DENORM__\n#define DBL_TRUE_MIN\t__DBL_DENORM_MIN__\n#else\n#define DBL_TRUE_MIN\t__DBL_MIN__\n#endif\n#if __LDBL_HAS_DENORM__\n#define LDBL_TRUE_MIN\t__LDBL_DENORM_MIN__\n#else\n#define LDBL_TRUE_MIN\t__LDBL_MIN__\n#endif\n\n#endif\t\t\t\t/* C11 */\n\n#ifdef __STDC_WANT_DEC_FP__\n/* Draft Technical Report 24732, extension for decimal floating-point\n   arithmetic: Characteristic of decimal floating types <float.h>.  */\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef DEC32_MANT_DIG\n#undef DEC64_MANT_DIG\n#undef DEC128_MANT_DIG\n#define DEC32_MANT_DIG\t__DEC32_MANT_DIG__\n#define DEC64_MANT_DIG\t__DEC64_MANT_DIG__\n#define DEC128_MANT_DIG\t__DEC128_MANT_DIG__\n\n/* Minimum exponent. */\n#undef DEC32_MIN_EXP\n#undef DEC64_MIN_EXP\n#undef DEC128_MIN_EXP\n#define DEC32_MIN_EXP\t__DEC32_MIN_EXP__\n#define DEC64_MIN_EXP\t__DEC64_MIN_EXP__\n#define DEC128_MIN_EXP\t__DEC128_MIN_EXP__\n\n/* Maximum exponent. */\n#undef DEC32_MAX_EXP\n#undef DEC64_MAX_EXP\n#undef DEC128_MAX_EXP\n#define DEC32_MAX_EXP\t__DEC32_MAX_EXP__\n#define DEC64_MAX_EXP\t__DEC64_MAX_EXP__\n#define DEC128_MAX_EXP\t__DEC128_MAX_EXP__\n\n/* Maximum representable finite decimal floating-point number\n   (there are 6, 15, and 33 9s after the decimal points respectively). */\n#undef DEC32_MAX\n#undef DEC64_MAX\n#undef DEC128_MAX\n#define DEC32_MAX   __DEC32_MAX__\n#define DEC64_MAX   __DEC64_MAX__\n#define DEC128_MAX  __DEC128_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type. */\n#undef DEC32_EPSILON\n#undef DEC64_EPSILON\n#undef DEC128_EPSILON\n#define DEC32_EPSILON\t__DEC32_EPSILON__\n#define DEC64_EPSILON\t__DEC64_EPSILON__\n#define DEC128_EPSILON\t__DEC128_EPSILON__\n\n/* Minimum normalized positive floating-point number. */\n#undef DEC32_MIN\n#undef DEC64_MIN\n#undef DEC128_MIN\n#define DEC32_MIN\t__DEC32_MIN__\n#define DEC64_MIN\t__DEC64_MIN__\n#define DEC128_MIN\t__DEC128_MIN__\n\n/* Minimum subnormal positive floating-point number. */\n#undef DEC32_SUBNORMAL_MIN\n#undef DEC64_SUBNORMAL_MIN\n#undef DEC128_SUBNORMAL_MIN\n#define DEC32_SUBNORMAL_MIN       __DEC32_SUBNORMAL_MIN__\n#define DEC64_SUBNORMAL_MIN       __DEC64_SUBNORMAL_MIN__\n#define DEC128_SUBNORMAL_MIN      __DEC128_SUBNORMAL_MIN__\n\n/* The floating-point expression evaluation method.\n         -1  indeterminate\n         0  evaluate all operations and constants just to the range and\n            precision of the type\n         1  evaluate operations and constants of type _Decimal32 \n\t    and _Decimal64 to the range and precision of the _Decimal64 \n            type, evaluate _Decimal128 operations and constants to the \n\t    range and precision of the _Decimal128 type;\n\t 2  evaluate all operations and constants to the range and\n\t    precision of the _Decimal128 type.  */\n\n#undef DEC_EVAL_METHOD\n#define DEC_EVAL_METHOD\t__DEC_EVAL_METHOD__\n\n#endif\t\t\t\t/* __STDC_WANT_DEC_FP__ */\n\n#endif\t\t\t\t/* _FLOAT_H___ */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stdarg.h",
    "content": "/* Copyright (C) 1989-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.15  Variable arguments  <stdarg.h>\n */\n\n#ifndef _STDARG_H\n#ifndef _ANSI_STDARG_H_\n#ifndef __need___va_list\n#define _STDARG_H\n#define _ANSI_STDARG_H_\n#endif\t\t\t\t/* not __need___va_list */\n#undef __need___va_list\n\n/* Define __gnuc_va_list.  */\n\n#ifndef __GNUC_VA_LIST\n#define __GNUC_VA_LIST\ntypedef __builtin_va_list __gnuc_va_list;\n#endif\n\n/* Define the standard macros for the user,\n   if this invocation was from the user program.  */\n#ifdef _STDARG_H\n\n#define va_start(v,l)\t__builtin_va_start(v,l)\n#define va_end(v)\t__builtin_va_end(v)\n#define va_arg(v,l)\t__builtin_va_arg(v,l)\n#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L || defined(__GXX_EXPERIMENTAL_CXX0X__)\n#define va_copy(d,s)\t__builtin_va_copy(d,s)\n#endif\n#define __va_copy(d,s)\t__builtin_va_copy(d,s)\n\n/* Define va_list, if desired, from __gnuc_va_list. */\n/* We deliberately do not define va_list when called from\n   stdio.h, because ANSI C says that stdio.h is not supposed to define\n   va_list.  stdio.h needs to have access to that data type, \n   but must not use that name.  It should use the name __gnuc_va_list,\n   which is safe because it is reserved for the implementation.  */\n\n#ifdef _BSD_VA_LIST\n#undef _BSD_VA_LIST\n#endif\n\n#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))\n/* SVR4.2 uses _VA_LIST for an internal alias for va_list,\n   so we must avoid testing it and setting it here.\n   SVR4 uses _VA_LIST as a flag in stdarg.h, but we should\n   have no conflict with that.  */\n#ifndef _VA_LIST_\n#define _VA_LIST_\n#ifdef __i860__\n#ifndef _VA_LIST\n#define _VA_LIST va_list\n#endif\n#endif\t\t\t\t/* __i860__ */\ntypedef __gnuc_va_list va_list;\n#ifdef _SCO_DS\n#define __VA_LIST\n#endif\n#endif\t\t\t\t/* _VA_LIST_ */\n#else\t\t\t\t/* not __svr4__ || _SCO_DS */\n\n/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.\n   But on BSD NET2 we must not test or define or undef it.\n   (Note that the comments in NET 2's ansi.h\n   are incorrect for _VA_LIST_--see stdio.h!)  */\n#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)\n/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */\n#ifndef _VA_LIST_DEFINED\n/* The macro _VA_LIST is used in SCO Unix 3.2.  */\n#ifndef _VA_LIST\n/* The macro _VA_LIST_T_H is used in the Bull dpx2  */\n#ifndef _VA_LIST_T_H\n/* The macro __va_list__ is used by BeOS.  */\n#ifndef __va_list__\ntypedef __gnuc_va_list va_list;\n#endif\t\t\t\t/* not __va_list__ */\n#endif\t\t\t\t/* not _VA_LIST_T_H */\n#endif\t\t\t\t/* not _VA_LIST */\n#endif\t\t\t\t/* not _VA_LIST_DEFINED */\n#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))\n#define _VA_LIST_\n#endif\n#ifndef _VA_LIST\n#define _VA_LIST\n#endif\n#ifndef _VA_LIST_DEFINED\n#define _VA_LIST_DEFINED\n#endif\n#ifndef _VA_LIST_T_H\n#define _VA_LIST_T_H\n#endif\n#ifndef __va_list__\n#define __va_list__\n#endif\n\n#endif\t\t\t\t/* not _VA_LIST_, except on certain systems */\n\n#endif\t\t\t\t/* not __svr4__ */\n\n#endif\t\t\t\t/* _STDARG_H */\n\n#endif\t\t\t\t/* not _ANSI_STDARG_H_ */\n#endif\t\t\t\t/* not _STDARG_H */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stdbool.h",
    "content": "/* Copyright (C) 1998-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.16  Boolean type and values  <stdbool.h>\n */\n\n#ifndef _STDBOOL_H\n#define _STDBOOL_H\n\n#ifndef __cplusplus\n\n#define bool\t_Bool\n#define true\t1\n#define false\t0\n\n#else\t\t\t\t/* __cplusplus */\n\n/* Supporting <stdbool.h> in C++ is a GCC extension.  */\n#define _Bool\tbool\n#define bool\tbool\n#define false\tfalse\n#define true\ttrue\n\n#endif\t\t\t\t/* __cplusplus */\n\n/* Signal that all the definitions are present.  */\n#define __bool_true_false_are_defined\t1\n\n#endif\t\t\t\t/* stdbool.h */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stddef.h",
    "content": "/* Copyright (C) 1989-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.17  Common definitions  <stddef.h>\n */\n#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \\\n     && !defined(__STDDEF_H__)) \\\n    || defined(__need_wchar_t) || defined(__need_size_t) \\\n    || defined(__need_ptrdiff_t) || defined(__need_NULL) \\\n    || defined(__need_wint_t)\n\n/* Any one of these symbols __need_* means that GNU libc\n   wants us just to define one data type.  So don't define\n   the symbols that indicate this file's entire job has been done.  */\n#if (!defined(__need_wchar_t) && !defined(__need_size_t)\t\\\n     && !defined(__need_ptrdiff_t) && !defined(__need_NULL)\t\\\n     && !defined(__need_wint_t))\n#define _STDDEF_H\n#define _STDDEF_H_\n/* snaroff@next.com says the NeXT needs this.  */\n#define _ANSI_STDDEF_H\n#endif\n\n#ifndef __sys_stdtypes_h\n/* This avoids lossage on SunOS but only if stdtypes.h comes first.\n   There's no way to win with the other order!  Sun lossage.  */\n\n/* On 4.3bsd-net2, make sure ansi.h is included, so we have\n   one less case to deal with in the following.  */\n#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)\n#include <machine/ansi.h>\n#endif\n/* On FreeBSD 5, machine/ansi.h does not exist anymore... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#include <sys/_types.h>\n#endif\n\n/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are\n   defined if the corresponding type is *not* defined.\n   FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.\n   NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_)  || defined(_I386_ANSI_H_)\n#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)\n#define _SIZE_T\n#endif\n#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)\n#define _PTRDIFF_T\n#endif\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_. */\n#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)\n#ifndef _BSD_WCHAR_T_\n#define _WCHAR_T\n#endif\n#endif\n/* Undef _FOO_T_ if we are supposed to define foo_t.  */\n#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#if defined (__need_size_t) || defined (_STDDEF_H_)\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#if defined (__need_wchar_t) || defined (_STDDEF_H_)\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */\n\n/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.\n   Just ignore it.  */\n#if defined (__sequent__) && defined (_PTRDIFF_T_)\n#undef _PTRDIFF_T_\n#endif\n\n/* On VxWorks, <type/vxTypesBase.h> may have defined macros like\n   _TYPE_size_t which will typedef size_t.  fixincludes patched the\n   vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is\n   not defined, and so that defining this macro defines _GCC_SIZE_T.\n   If we find that the macros are still defined at this point, we must\n   invoke them so that the type is defined as expected.  */\n#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))\n_TYPE_ptrdiff_t;\n#undef _TYPE_ptrdiff_t\n#endif\n#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))\n_TYPE_size_t;\n#undef _TYPE_size_t\n#endif\n#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))\n_TYPE_wchar_t;\n#undef _TYPE_wchar_t\n#endif\n\n/* In case nobody has defined these types, but we aren't running under\n   GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and\n   __WCHAR_TYPE__ have reasonable values.  This can happen if the\n   parts of GCC is compiled by an older compiler, that actually\n   include gstddef.h, such as collect2.  */\n\n/* Signed type of difference of two pointers.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)\n#ifndef _PTRDIFF_T\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _T_PTRDIFF_\n#ifndef _T_PTRDIFF\n#ifndef __PTRDIFF_T\n#ifndef _PTRDIFF_T_\n#ifndef _BSD_PTRDIFF_T_\n#ifndef ___int_ptrdiff_t_h\n#ifndef _GCC_PTRDIFF_T\n#define _PTRDIFF_T\n#define _T_PTRDIFF_\n#define _T_PTRDIFF\n#define __PTRDIFF_T\n#define _PTRDIFF_T_\n#define _BSD_PTRDIFF_T_\n#define ___int_ptrdiff_t_h\n#define _GCC_PTRDIFF_T\n#ifndef __PTRDIFF_TYPE__\n#define __PTRDIFF_TYPE__ long int\n#endif\ntypedef __PTRDIFF_TYPE__ ptrdiff_t;\n#endif\t\t\t\t/* _GCC_PTRDIFF_T */\n#endif\t\t\t\t/* ___int_ptrdiff_t_h */\n#endif\t\t\t\t/* _BSD_PTRDIFF_T_ */\n#endif\t\t\t\t/* _PTRDIFF_T_ */\n#endif\t\t\t\t/* __PTRDIFF_T */\n#endif\t\t\t\t/* _T_PTRDIFF */\n#endif\t\t\t\t/* _T_PTRDIFF_ */\n#endif\t\t\t\t/* _PTRDIFF_T */\n\n/* If this symbol has done its job, get rid of it.  */\n#undef\t__need_ptrdiff_t\n\n#endif\t\t\t\t/* _STDDEF_H or __need_ptrdiff_t.  */\n\n/* Unsigned type of `sizeof' something.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_size_t)\n#ifndef __size_t__\t\t/* BeOS */\n#ifndef __SIZE_T__\t\t/* Cray Unicos/Mk */\n#ifndef _SIZE_T\t\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _SYS_SIZE_T_H\n#ifndef _T_SIZE_\n#ifndef _T_SIZE\n#ifndef __SIZE_T\n#ifndef _SIZE_T_\n#ifndef _BSD_SIZE_T_\n#ifndef _SIZE_T_DEFINED_\n#ifndef _SIZE_T_DEFINED\n#ifndef _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#ifndef _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#ifndef ___int_size_t_h\n#ifndef _GCC_SIZE_T\n#ifndef _SIZET_\n#ifndef __size_t\n#define __size_t__\t\t/* BeOS */\n#define __SIZE_T__\t\t/* Cray Unicos/Mk */\n#define _SIZE_T\n#define _SYS_SIZE_T_H\n#define _T_SIZE_\n#define _T_SIZE\n#define __SIZE_T\n#define _SIZE_T_\n#define _BSD_SIZE_T_\n#define _SIZE_T_DEFINED_\n#define _SIZE_T_DEFINED\n#define _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#define _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#define ___int_size_t_h\n#define _GCC_SIZE_T\n#define _SIZET_\n#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \\\n  || defined(__FreeBSD_kernel__)\n/* __size_t is a typedef on FreeBSD 5, must not trash it. */\n#elif defined (__VMS__)\n/* __size_t is also a typedef on VMS.  */\n#else\n#define __size_t\n#endif\n#ifndef __SIZE_TYPE__\n#define __SIZE_TYPE__ long unsigned int\n#endif\n#if !(defined (__GNUG__) && defined (size_t))\ntypedef __SIZE_TYPE__ size_t;\n#ifdef __BEOS__\ntypedef long ssize_t;\n#endif\t\t\t\t/* __BEOS__ */\n#endif\t\t\t\t/* !(defined (__GNUG__) && defined (size_t)) */\n#endif\t\t\t\t/* __size_t */\n#endif\t\t\t\t/* _SIZET_ */\n#endif\t\t\t\t/* _GCC_SIZE_T */\n#endif\t\t\t\t/* ___int_size_t_h */\n#endif\t\t\t\t/* _SIZE_T_DECLARED */\n#endif\t\t\t\t/* _BSD_SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _SIZE_T_DEFINED */\n#endif\t\t\t\t/* _SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _BSD_SIZE_T_ */\n#endif\t\t\t\t/* _SIZE_T_ */\n#endif\t\t\t\t/* __SIZE_T */\n#endif\t\t\t\t/* _T_SIZE */\n#endif\t\t\t\t/* _T_SIZE_ */\n#endif\t\t\t\t/* _SYS_SIZE_T_H */\n#endif\t\t\t\t/* _SIZE_T */\n#endif\t\t\t\t/* __SIZE_T__ */\n#endif\t\t\t\t/* __size_t__ */\n#undef\t__need_size_t\n#endif\t\t\t\t/* _STDDEF_H or __need_size_t.  */\n\n/* Wide character type.\n   Locale-writers should change this as necessary to\n   be big enough to hold unique values not between 0 and 127,\n   and not (wchar_t) -1, for each defined multibyte character.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_wchar_t)\n#ifndef __wchar_t__\t\t/* BeOS */\n#ifndef __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#ifndef _WCHAR_T\n#ifndef _T_WCHAR_\n#ifndef _T_WCHAR\n#ifndef __WCHAR_T\n#ifndef _WCHAR_T_\n#ifndef _BSD_WCHAR_T_\n#ifndef _BSD_WCHAR_T_DEFINED_\t/* Darwin */\n#ifndef _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#ifndef _WCHAR_T_DECLARED\t/* FreeBSD 5 */\n#ifndef _WCHAR_T_DEFINED_\n#ifndef _WCHAR_T_DEFINED\n#ifndef _WCHAR_T_H\n#ifndef ___int_wchar_t_h\n#ifndef __INT_WCHAR_T_H\n#ifndef _GCC_WCHAR_T\n#define __wchar_t__\t\t/* BeOS */\n#define __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#define _WCHAR_T\n#define _T_WCHAR_\n#define _T_WCHAR\n#define __WCHAR_T\n#define _WCHAR_T_\n#define _BSD_WCHAR_T_\n#define _WCHAR_T_DEFINED_\n#define _WCHAR_T_DEFINED\n#define _WCHAR_T_H\n#define ___int_wchar_t_h\n#define __INT_WCHAR_T_H\n#define _GCC_WCHAR_T\n#define _WCHAR_T_DECLARED\n\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other\n   symbols in the _FOO_T_ family, stays defined even after its\n   corresponding type is defined).  If we define wchar_t, then we\n   must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if\n   we undef _WCHAR_T_, then we must also define rune_t, since \n   headers like runetype.h assume that if machine/ansi.h is included,\n   and _BSD_WCHAR_T_ is not defined, then rune_t is available.\n   machine/ansi.h says, \"Note that _WCHAR_T_ and _RUNE_T_ must be of\n   the same type.\" */\n#ifdef _BSD_WCHAR_T_\n#undef _BSD_WCHAR_T_\n#ifdef _BSD_RUNE_T_\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\ntypedef _BSD_RUNE_T_ rune_t;\n#define _BSD_WCHAR_T_DEFINED_\n#define _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#if defined (__FreeBSD__) && (__FreeBSD__ < 5)\n/* Why is this file so hard to maintain properly?  In contrast to\n   the comment above regarding BSD/386 1.1, on FreeBSD for as long\n   as the symbol has existed, _BSD_RUNE_T_ must not stay defined or\n   redundant typedefs will occur when stdlib.h is included after this file. */\n#undef _BSD_RUNE_T_\n#endif\n#endif\n#endif\n#endif\n/* FreeBSD 5 can't be handled well using \"traditional\" logic above\n   since it no longer defines _BSD_RUNE_T_ yet still desires to export\n   rune_t in some cases... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\n#if __BSD_VISIBLE\n#ifndef _RUNE_T_DECLARED\ntypedef __rune_t rune_t;\n#define _RUNE_T_DECLARED\n#endif\n#endif\n#endif\n#endif\n\n#ifndef __WCHAR_TYPE__\n#define __WCHAR_TYPE__ int\n#endif\n#ifndef __cplusplus\ntypedef __WCHAR_TYPE__ wchar_t;\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* _WCHAR_T_DECLARED */\n#endif\t\t\t\t/* _BSD_RUNE_T_DEFINED_ */\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* __WCHAR_T__ */\n#endif\t\t\t\t/* __wchar_t__ */\n#undef\t__need_wchar_t\n#endif\t\t\t\t/* _STDDEF_H or __need_wchar_t.  */\n\n#if defined (__need_wint_t)\n#ifndef _WINT_T\n#define _WINT_T\n\n#ifndef __WINT_TYPE__\n#define __WINT_TYPE__ unsigned int\n#endif\ntypedef __WINT_TYPE__ wint_t;\n#endif\n#undef __need_wint_t\n#endif\n\n/*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.\n    are already defined.  */\n/*  BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.  */\n/*  NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here.  */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)\n/*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_\n    are probably typos and should be removed before 2.8 is released.  */\n#ifdef _GCC_PTRDIFF_T_\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T_\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T_\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n/*  The following ones are the real ones.  */\n#ifdef _GCC_PTRDIFF_T\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */\n\n#endif\t\t\t\t/* __sys_stdtypes_h */\n\n/* A null pointer constant.  */\n\n#if defined (_STDDEF_H) || defined (__need_NULL)\n#undef NULL\t\t\t/* in case <stdio.h> has defined it. */\n#ifdef __GNUG__\n#define NULL __null\n#else\t\t\t\t/* G++ */\n#ifndef __cplusplus\n#define NULL ((void *)0)\n#else\t\t\t\t/* C++ */\n#define NULL 0\n#endif\t\t\t\t/* C++ */\n#endif\t\t\t\t/* G++ */\n#endif\t\t\t\t/* NULL not defined and <stddef.h> or need NULL.  */\n#undef\t__need_NULL\n\n#ifdef _STDDEF_H\n\n/* Offset of member MEMBER in a struct of type TYPE. */\n#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)\n\n#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \\\n  || (defined(__cplusplus) && __cplusplus >= 201103L)\n#ifndef _GCC_MAX_ALIGN_T\n#define _GCC_MAX_ALIGN_T\n/* Type whose alignment is supported in every context and is at least\n   as great as that of any standard type not using alignment\n   specifiers.  */\ntypedef struct {\n\tlong long __max_align_ll __attribute__ ((__aligned__(__alignof__(long long))));\n\tlong double __max_align_ld __attribute__ ((__aligned__(__alignof__(long double))));\n} max_align_t;\n#endif\n#endif\t\t\t\t/* C11 or C++11.  */\n\n#if defined(__cplusplus) && __cplusplus >= 201103L\n#ifndef _GXX_NULLPTR_T\n#define _GXX_NULLPTR_T\ntypedef decltype(nullptr) nullptr_t;\n#endif\n#endif\t\t\t\t/* C++11.  */\n\n#endif\t\t\t\t/* _STDDEF_H was defined this time */\n\n#endif\t\t\t\t/* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__\n\t\t\t\t   || __need_XXX was not defined before */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include/stdint.h",
    "content": "#ifndef _GCC_WRAP_STDINT_H\n#if __STDC_HOSTED__\n# if defined __cplusplus && __cplusplus >= 201103L\n#  undef __STDC_LIMIT_MACROS\n#  define __STDC_LIMIT_MACROS\n#  undef __STDC_CONSTANT_MACROS\n#  define __STDC_CONSTANT_MACROS\n# endif\n# include_next <stdint.h>\n#else\n# include \"stdint-gcc.h\"\n#endif\n#define _GCC_WRAP_STDINT_H\n#endif\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed/limits.h",
    "content": "/* Copyright (C) 1992-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/* This administrivia gets added to the beginning of limits.h\n   if the system has its own version of limits.h.  */\n\n/* We use _GCC_LIMITS_H_ because we want this not to match\n   any macros that the system's limits.h uses for its own purposes.  */\n#ifndef _GCC_LIMITS_H_\t\t/* Terminated in limity.h.  */\n#define _GCC_LIMITS_H_\n\n#ifndef _LIBC_LIMITS_H_\n/* Use \"...\" so that we find syslimits.h only in this same directory.  */\n#include \"syslimits.h\"\n#endif\n/* Copyright (C) 1991-2013 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n#ifndef _LIMITS_H___\n#define _LIMITS_H___\n\n/* Number of bits in a `char'.  */\n#undef CHAR_BIT\n#define CHAR_BIT __CHAR_BIT__\n\n/* Maximum length of a multibyte character.  */\n#ifndef MB_LEN_MAX\n#define MB_LEN_MAX 1\n#endif\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#undef SCHAR_MIN\n#define SCHAR_MIN (-SCHAR_MAX - 1)\n#undef SCHAR_MAX\n#define SCHAR_MAX __SCHAR_MAX__\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0).  */\n#undef UCHAR_MAX\n#if __SCHAR_MAX__ == __INT_MAX__\n# define UCHAR_MAX (SCHAR_MAX * 2U + 1U)\n#else\n# define UCHAR_MAX (SCHAR_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `char' can hold.  */\n#ifdef __CHAR_UNSIGNED__\n# undef CHAR_MIN\n# if __SCHAR_MAX__ == __INT_MAX__\n#  define CHAR_MIN 0U\n# else\n#  define CHAR_MIN 0\n# endif\n# undef CHAR_MAX\n# define CHAR_MAX UCHAR_MAX\n#else\n# undef CHAR_MIN\n# define CHAR_MIN SCHAR_MIN\n# undef CHAR_MAX\n# define CHAR_MAX SCHAR_MAX\n#endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#undef SHRT_MIN\n#define SHRT_MIN (-SHRT_MAX - 1)\n#undef SHRT_MAX\n#define SHRT_MAX __SHRT_MAX__\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0).  */\n#undef USHRT_MAX\n#if __SHRT_MAX__ == __INT_MAX__\n# define USHRT_MAX (SHRT_MAX * 2U + 1U)\n#else\n# define USHRT_MAX (SHRT_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#undef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#undef INT_MAX\n#define INT_MAX __INT_MAX__\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */\n#undef UINT_MAX\n#define UINT_MAX (INT_MAX * 2U + 1U)\n\n/* Minimum and maximum values a `signed long int' can hold.\n   (Same as `int').  */\n#undef LONG_MIN\n#define LONG_MIN (-LONG_MAX - 1L)\n#undef LONG_MAX\n#define LONG_MAX __LONG_MAX__\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0).  */\n#undef ULONG_MAX\n#define ULONG_MAX (LONG_MAX * 2UL + 1UL)\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n/* Minimum and maximum values a `signed long long int' can hold.  */\n# undef LLONG_MIN\n# define LLONG_MIN (-LLONG_MAX - 1LL)\n# undef LLONG_MAX\n# define LLONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n# undef ULLONG_MAX\n# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)\n#endif\n\n#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)\n/* Minimum and maximum values a `signed long long int' can hold.  */\n# undef LONG_LONG_MIN\n# define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)\n# undef LONG_LONG_MAX\n# define LONG_LONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n# undef ULONG_LONG_MAX\n# define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)\n#endif\n\n#endif\t\t\t\t/* _LIMITS_H___ */\n/* This administrivia gets added to the end of limits.h\n   if the system has its own version of limits.h.  */\n\n#else\t\t\t\t/* not _GCC_LIMITS_H_ */\n\n#ifdef _GCC_NEXT_LIMITS_H\n#include_next <limits.h>\t/* recurse down to the real one */\n#endif\n\n#endif\t\t\t\t/* not _GCC_LIMITS_H_ */\n"
  },
  {
    "path": "v2/headers/linux_amd64/usr/lib64/gcc/x86_64-suse-linux/4.8/include-fixed/syslimits.h",
    "content": "/* syslimits.h stands for the system's own limits.h file.\n   If we can use it ok unmodified, then we install this text.\n   If fixincludes fixes it, then the fixed version is installed\n   instead of this text.  */\n\n#define _GCC_NEXT_LIMITS_H\t/* tell gcc's limits.h to recurse */\n#include_next <limits.h>\n#undef _GCC_NEXT_LIMITS_H\n"
  },
  {
    "path": "v2/headers/linux_arm/builtin.h",
    "content": "//  Copyright 2018 The CC Authors. All rights reserved.\n//  Use of this source code is governed by a BSD-style\n//  license that can be found in the LICENSE file.\n\n// +build ignore\n\n#ifndef _BUILTIN_H_\n#define _BUILTIN_H_\n\n#include \"predefined.h\"\n\ntypedef struct {\n\tvoid *_[2];\t\t// Go *[]interface{}\n} *__builtin_va_list;\n\ntypedef void *__FILE_TYPE__;\n\n__SIZE_TYPE__ __builtin_strlen(char *__s);\n__UINT64_TYPE__ __builtin_bswap64(__UINT64_TYPE__ x);\nchar *__builtin_strchrnul(char *, int);\nchar *__builtin_strcpy(char *__dest, char *__src);\ndouble __builtin_copysign(double x, double y);\nint __builtin_abs(int j);\nint __builtin_ffs(int i);\nint __builtin_isprint(int);\nint __builtin_memcmp(void *__s1, void *__s2, __SIZE_TYPE__ __n);\nint __builtin_printf(char *__format, ...);\nint __builtin_sprintf(char *__s, char *__format, ...);\nint __builtin_strcmp(char *__s1, char *__s2);\nint __signbit(double x);\nint __signbitf(float x);\nvoid *__builtin_alloca(__SIZE_TYPE__ __size);\nvoid *__builtin_memcpy(void *dest, const void *src, __SIZE_TYPE__ n);\nvoid *__builtin_memset(void *s, int c, __SIZE_TYPE__ n);\n#ifdef __ccgo__\nextern void *__ccgo_va_end;\nextern void *__ccgo_va_start;\n#endif\nvoid __GO__(char*);\nvoid __builtin_abort(void);\nvoid __builtin_exit(int __status);\nvoid __builtin_trap(void);\nvoid __register_stdfiles(void *, void *, void *, void *);\n\n#define __builtin_choose_expr(a, b, c) (a) ? (b) : (c)\n#define __builtin_expect(exp, c) (exp)\n#define __builtin_offsetof(st, m) ((__SIZE_TYPE__)(&((st *)0)->m))\n#define __builtin_prefetch(addr, ...) (void)(addr)\n#define __builtin_signbit(x) (sizeof(x) == sizeof(float) ? __signbitf(x) : sizeof (x) == sizeof(double) ? __signbit(x) : __signbitl(x))\n#define __builtin_types_compatible_p(type1, type2) __builtin_types_compatible__((type1){}, (type2){})\n#define __builtin_va_arg(ap, type) (type)ap\n#define __builtin_va_copy(dest, src) dest = src\n#ifdef __ccgo__\n#define __builtin_va_end(ap) ap = __ccgo_va_end\n#define __builtin_va_start(ap, arg) ap = __ccgo_va_start\n#else\n#define __builtin_va_end(ap) ap = (void*)0\n#define __builtin_va_start(ap, arg) ap = (void*)-1\n#endif\n#define __complex__ _Complex\n#define __const const\n#define __extension__\n#define __typeof__ typeof\n#define __volatile volatile\n\n#endif\t\t\t\t/* _BUILTIN_H_ */\n"
  },
  {
    "path": "v2/headers/linux_arm/paths",
    "content": "/usr/lib/gcc/arm-linux-gnueabihf/6/include\n/usr/local/include\n/usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed\n/usr/include/arm-linux-gnueabihf\n/usr/include\n"
  },
  {
    "path": "v2/headers/linux_arm/predefined.h",
    "content": "// Code generated by $ go generate - DO NOT EDIT.\n\n// +build ignore\n\n#define __DBL_MIN_EXP__ (-1021)\n#define __HQ_FBIT__ 15\n#define __UINT_LEAST16_MAX__ 0xffff\n#define __ARM_SIZEOF_WCHAR_T 4\n#define __ATOMIC_ACQUIRE 2\n#define __SFRACT_IBIT__ 0\n#define __FLT_MIN__ 1.1754943508222875e-38F\n#define __UFRACT_MAX__ 0XFFFFP-16UR\n#define __UINT_LEAST8_TYPE__ unsigned char\n#define __DQ_FBIT__ 63\n#define __INTMAX_C(c) c ## LL\n#define __ARM_FEATURE_SAT 1\n#define __ULFRACT_FBIT__ 32\n#define __SACCUM_EPSILON__ 0x1P-7HK\n#define __CHAR_BIT__ 8\n#define __USQ_IBIT__ 0\n#define __UINT8_MAX__ 0xff\n#define __ACCUM_FBIT__ 15\n#define __WINT_MAX__ 0xffffffffU\n#define __USFRACT_FBIT__ 8\n#define __ORDER_LITTLE_ENDIAN__ 1234\n#define __SIZE_MAX__ 0xffffffffU\n#define __ARM_ARCH_ISA_ARM 1\n#define __WCHAR_MAX__ 0xffffffffU\n#define __LACCUM_IBIT__ 32\n#define __DBL_DENORM_MIN__ ((double)4.9406564584124654e-324L)\n#define __FLT_EVAL_METHOD__ 0\n#define __unix__ 1\n#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK\n#define __FRACT_FBIT__ 15\n#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL\n#define __SIG_ATOMIC_TYPE__ int\n#define __UACCUM_FBIT__ 16\n#define __DBL_MIN_10_EXP__ (-307)\n#define __FINITE_MATH_ONLY__ 0\n#define __ARMEL__ 1\n#define __ARM_FEATURE_UNALIGNED 1\n#define __LFRACT_IBIT__ 0\n#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR\n#define __UINT_FAST8_MAX__ 0xff\n#define __has_include(STR) __has_include__(STR)\n#define __DEC64_MAX_EXP__ 385\n#define __INT8_C(c) c\n#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL\n#define __SA_FBIT__ 15\n#define __SHRT_MAX__ 0x7fff\n#define __LDBL_MAX__ 1.7976931348623157e+308L\n#define __FRACT_MAX__ 0X7FFFP-15R\n#define __UFRACT_FBIT__ 16\n#define __ARM_FP 12\n#define __UFRACT_MIN__ 0.0UR\n#define __UINT_LEAST8_MAX__ 0xff\n#define __UINTMAX_TYPE__ long long unsigned int\n#define __LLFRACT_EPSILON__ 0x1P-63LLR\n#define __linux 1\n#define __DEC32_EPSILON__ 1E-6DF\n#define __CHAR_UNSIGNED__ 1\n#define __UINT32_MAX__ 0xffffffffU\n#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR\n#define __TA_IBIT__ 64\n#define __LDBL_MAX_EXP__ 1024\n#define __WINT_MIN__ 0U\n#define __linux__ 1\n#define __ULLFRACT_MIN__ 0.0ULLR\n#define __SCHAR_MAX__ 0x7f\n#define __WCHAR_MIN__ 0U\n#define __INT64_C(c) c ## LL\n#define __DBL_DIG__ 15\n#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK)\n#define __SIZEOF_INT__ 4\n#define __SIZEOF_POINTER__ 4\n#define __USACCUM_IBIT__ 8\n#define __USER_LABEL_PREFIX__\n#define __STDC_HOSTED__ 1\n#define __LDBL_HAS_INFINITY__ 1\n#define __LFRACT_MIN__ (-0.5LR-0.5LR)\n#define __HA_IBIT__ 8\n#define __TQ_IBIT__ 0\n#define __FLT_EPSILON__ 1.1920928955078125e-7F\n#define __APCS_32__ 1\n#define __USFRACT_IBIT__ 0\n#define __LDBL_MIN__ 2.2250738585072014e-308L\n#define __FRACT_MIN__ (-0.5R-0.5R)\n#define __DEC32_MAX__ 9.999999E96DF\n#define __DA_IBIT__ 32\n#define __ARM_SIZEOF_MINIMAL_ENUM 4\n#define __INT32_MAX__ 0x7fffffff\n#define __UQQ_FBIT__ 8\n#define __SIZEOF_LONG__ 4\n#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK\n#define __STDC_IEC_559__ 1\n#define __STDC_ISO_10646__ 201605L\n#define __UINT16_C(c) c\n#define __DECIMAL_DIG__ 17\n#define __LFRACT_EPSILON__ 0x1P-31LR\n#define __ULFRACT_MIN__ 0.0ULR\n#define __has_include_next(STR) __has_include_next__(STR)\n#define __ARM_PCS_VFP 1\n#define __LDBL_HAS_QUIET_NAN__ 1\n#define __ULACCUM_IBIT__ 32\n#define __UACCUM_EPSILON__ 0x1P-16UK\n#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK\n#define __HQ_IBIT__ 0\n#define __FLT_HAS_DENORM__ 1\n#define __SIZEOF_LONG_DOUBLE__ 8\n#define __BIGGEST_ALIGNMENT__ 8\n#define __DQ_IBIT__ 0\n#define __DBL_MAX__ ((double)1.7976931348623157e+308L)\n#define __ULFRACT_IBIT__ 0\n#define __INT_FAST32_MAX__ 0x7fffffff\n#define __DBL_HAS_INFINITY__ 1\n#define __ACCUM_IBIT__ 16\n#define __DEC32_MIN_EXP__ (-94)\n#define __THUMB_INTERWORK__ 1\n#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK\n#define __INT_FAST16_TYPE__ int\n#define __STRICT_ANSI__ 1\n#define __LDBL_HAS_DENORM__ 1\n#define __ARM_FEATURE_LDREX 4\n#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL\n#define __INT_LEAST32_MAX__ 0x7fffffff\n#define __DEC32_MIN__ 1E-95DF\n#define __ACCUM_MAX__ 0X7FFFFFFFP-15K\n#define __DBL_MAX_EXP__ 1024\n#define __USACCUM_EPSILON__ 0x1P-8UHK\n#define __DEC128_EPSILON__ 1E-33DL\n#define __SFRACT_MAX__ 0X7FP-7HR\n#define __FRACT_IBIT__ 0\n#define __PTRDIFF_MAX__ 0x7fffffff\n#define __UACCUM_MIN__ 0.0UK\n#define __STDC_NO_THREADS__ 1\n#define __UACCUM_IBIT__ 16\n#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL\n#define __SIZEOF_SIZE_T__ 4\n#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK\n#define __SIZEOF_WINT_T__ 4\n#define __SA_IBIT__ 16\n#define __ULLACCUM_MIN__ 0.0ULLK\n#define __GXX_ABI_VERSION 1010\n#define __UTA_FBIT__ 64\n#define __FLT_MIN_EXP__ (-125)\n#define __USFRACT_MAX__ 0XFFP-8UHR\n#define __UFRACT_IBIT__ 0\n#define __ARM_FEATURE_QBIT 1\n#define __INT_FAST64_TYPE__ long long int\n#define __DBL_MIN__ ((double)2.2250738585072014e-308L)\n#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK)\n#define __ULLACCUM_FBIT__ 32\n#define __GXX_TYPEINFO_EQUALITY_INLINE 0\n#define __ULLFRACT_EPSILON__ 0x1P-64ULLR\n#define __DEC128_MIN__ 1E-6143DL\n#define __REGISTER_PREFIX__\n#define __UINT16_MAX__ 0xffff\n#define __DBL_HAS_DENORM__ 1\n#define __ACCUM_MIN__ (-0X1P15K-0X1P15K)\n#define __SQ_IBIT__ 0\n#define __UINT8_TYPE__ unsigned char\n#define __UHA_FBIT__ 8\n#define __NO_INLINE__ 1\n#define __SFRACT_MIN__ (-0.5HR-0.5HR)\n#define __UTQ_FBIT__ 128\n#define __FLT_MANT_DIG__ 24\n#define __VERSION__ \"6.3.0 20170516\"\n#define __UINT64_C(c) c ## ULL\n#define __ULLFRACT_FBIT__ 64\n#define __FRACT_EPSILON__ 0x1P-15R\n#define __ULACCUM_MIN__ 0.0ULK\n#define _STDC_PREDEF_H 1\n#define __UDA_FBIT__ 32\n#define __LLACCUM_EPSILON__ 0x1P-31LLK\n#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __USFRACT_MIN__ 0.0UHR\n#define __UQQ_IBIT__ 0\n#define __STDC_IEC_559_COMPLEX__ 1\n#define __INT32_C(c) c\n#define __DEC64_EPSILON__ 1E-15DD\n#define __ORDER_PDP_ENDIAN__ 3412\n#define __DEC128_MIN_EXP__ (-6142)\n#define __UHQ_FBIT__ 16\n#define __LLACCUM_FBIT__ 31\n#define __INT_FAST32_TYPE__ int\n#define __UINT_LEAST16_TYPE__ short unsigned int\n#define __INT16_MAX__ 0x7fff\n#define __SIZE_TYPE__ unsigned int\n#define __UINT64_MAX__ 0xffffffffffffffffULL\n#define __UDQ_FBIT__ 64\n#define __INT8_TYPE__ signed char\n#define __ELF__ 1\n#define __ULFRACT_EPSILON__ 0x1P-32ULR\n#define __LLFRACT_FBIT__ 63\n#define __FLT_RADIX__ 2\n#define __INT_LEAST16_TYPE__ short int\n#define __LDBL_EPSILON__ 2.2204460492503131e-16L\n#define __UINTMAX_C(c) c ## ULL\n#define __SACCUM_MAX__ 0X7FFFP-7HK\n#define __SIG_ATOMIC_MAX__ 0x7fffffff\n#define __VFP_FP__ 1\n#define __SIZEOF_PTRDIFF_T__ 4\n#define __LACCUM_EPSILON__ 0x1P-31LK\n#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF\n#define __INT_FAST16_MAX__ 0x7fffffff\n#define __ARM_ARCH_6__ 1\n#define __UINT_FAST32_MAX__ 0xffffffffU\n#define __UINT_LEAST64_TYPE__ long long unsigned int\n#define __USACCUM_MAX__ 0XFFFFP-8UHK\n#define __SFRACT_EPSILON__ 0x1P-7HR\n#define __FLT_HAS_QUIET_NAN__ 1\n#define __FLT_MAX_10_EXP__ 38\n#define __LONG_MAX__ 0x7fffffffL\n#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL\n#define __FLT_HAS_INFINITY__ 1\n#define __unix 1\n#define __USA_FBIT__ 16\n#define __UINT_FAST16_TYPE__ unsigned int\n#define __DEC64_MAX__ 9.999999999999999E384DD\n#define __ARM_32BIT_STATE 1\n#define __CHAR16_TYPE__ short unsigned int\n#define __PRAGMA_REDEFINE_EXTNAME 1\n#define __INT_LEAST16_MAX__ 0x7fff\n#define __DEC64_MANT_DIG__ 16\n#define __INT64_MAX__ 0x7fffffffffffffffLL\n#define __UINT_LEAST32_MAX__ 0xffffffffU\n#define __SACCUM_FBIT__ 7\n#define __INT_LEAST64_TYPE__ long long int\n#define __ARM_FEATURE_CLZ 1\n#define __INT16_TYPE__ short int\n#define __INT_LEAST8_TYPE__ signed char\n#define __STDC_VERSION__ 199901L\n#define __SQ_FBIT__ 31\n#define __DEC32_MAX_EXP__ 97\n#define __ARM_ARCH_ISA_THUMB 1\n#define __INT_FAST8_MAX__ 0x7f\n#define __ARM_ARCH 6\n#define __INTPTR_MAX__ 0x7fffffff\n#define __QQ_FBIT__ 7\n#define __UTA_IBIT__ 64\n#define __LDBL_MANT_DIG__ 53\n#define __SFRACT_FBIT__ 7\n#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK)\n#define __DBL_HAS_QUIET_NAN__ 1\n#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)\n#define __INTPTR_TYPE__ int\n#define __UINT16_TYPE__ short unsigned int\n#define __WCHAR_TYPE__ unsigned int\n#define __SIZEOF_FLOAT__ 4\n#define __USQ_FBIT__ 32\n#define __UINTPTR_MAX__ 0xffffffffU\n#define __DEC64_MIN_EXP__ (-382)\n#define __ULLACCUM_IBIT__ 32\n#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL\n#define __FLT_DIG__ 6\n#define __UINT_FAST64_TYPE__ long long unsigned int\n#define __INT_MAX__ 0x7fffffff\n#define __LACCUM_FBIT__ 31\n#define __USACCUM_MIN__ 0.0UHK\n#define __UHA_IBIT__ 8\n#define __INT64_TYPE__ long long int\n#define __FLT_MAX_EXP__ 128\n#define __UTQ_IBIT__ 0\n#define __DBL_MANT_DIG__ 53\n#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL\n#define __DEC64_MIN__ 1E-383DD\n#define __WINT_TYPE__ unsigned int\n#define __UINT_LEAST32_TYPE__ unsigned int\n#define __SIZEOF_SHORT__ 2\n#define __ULLFRACT_IBIT__ 0\n#define __LDBL_MIN_EXP__ (-1021)\n#define __arm__ 1\n#define __UDA_IBIT__ 32\n#define __INT_LEAST8_MAX__ 0x7f\n#define __LFRACT_FBIT__ 31\n#define __LDBL_MAX_10_EXP__ 308\n#define __ATOMIC_RELAXED 0\n#define __DBL_EPSILON__ ((double)2.2204460492503131e-16L)\n#define __ARM_FEATURE_SIMD32 1\n#define __UINT8_C(c) c\n#define __INT_LEAST32_TYPE__ int\n#define __SIZEOF_WCHAR_T__ 4\n#define __UINT64_TYPE__ long long unsigned int\n#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR\n#define __TQ_FBIT__ 127\n#define __INT_FAST8_TYPE__ signed char\n#define __ULLACCUM_EPSILON__ 0x1P-32ULLK\n#define __UHQ_IBIT__ 0\n#define __LLACCUM_IBIT__ 32\n#define __DBL_DECIMAL_DIG__ 17\n#define __DEC_EVAL_METHOD__ 2\n#define __TA_FBIT__ 63\n#define __UDQ_IBIT__ 0\n#define __ORDER_BIG_ENDIAN__ 4321\n#define __ACCUM_EPSILON__ 0x1P-15K\n#define __UINT32_C(c) c ## U\n#define __INTMAX_MAX__ 0x7fffffffffffffffLL\n#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__\n#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F\n#define __LLFRACT_IBIT__ 0\n#define __INT8_MAX__ 0x7f\n#define __UINT_FAST32_TYPE__ unsigned int\n#define __CHAR32_TYPE__ unsigned int\n#define __FLT_MAX__ 3.4028234663852886e+38F\n#define __USACCUM_FBIT__ 8\n#define __INT32_TYPE__ int\n#define __SIZEOF_DOUBLE__ 8\n#define __FLT_MIN_10_EXP__ (-37)\n#define __UFRACT_EPSILON__ 0x1P-16UR\n#define __INTMAX_TYPE__ long long int\n#define __DEC128_MAX_EXP__ 6145\n#define __ATOMIC_CONSUME 1\n#define __UINTMAX_MAX__ 0xffffffffffffffffULL\n#define __DEC32_MANT_DIG__ 7\n#define __HA_FBIT__ 7\n#define __DBL_MAX_10_EXP__ 308\n#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L\n#define __INT16_C(c) c\n#define __STDC__ 1\n#define __PTRDIFF_TYPE__ int\n#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR)\n#define __ATOMIC_SEQ_CST 5\n#define __DA_FBIT__ 31\n#define __UINT32_TYPE__ unsigned int\n#define __UINTPTR_TYPE__ unsigned int\n#define __USA_IBIT__ 16\n#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD\n#define __ARM_EABI__ 1\n#define __DEC128_MANT_DIG__ 34\n#define __LDBL_MIN_10_EXP__ (-307)\n#define __SIZEOF_LONG_LONG__ 8\n#define __ULACCUM_EPSILON__ 0x1P-32ULK\n#define __SACCUM_IBIT__ 8\n#define __LDBL_DIG__ 15\n#define __FLT_DECIMAL_DIG__ 9\n#define __UINT_FAST16_MAX__ 0xffffffffU\n#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR\n#define __UINT_FAST8_TYPE__ unsigned char\n#define __USFRACT_EPSILON__ 0x1P-8UHR\n#define __ULACCUM_FBIT__ 32\n#define __ARM_FEATURE_DSP 1\n#define __QQ_IBIT__ 0\n#define __ATOMIC_ACQ_REL 4\n#define __ATOMIC_RELEASE 3\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/_G_config.h",
    "content": "/* This file is needed by libio to define various configuration parameters.\n   These are always the same in the GNU C library.  */\n\n#ifndef _G_config_h\n#define _G_config_h 1\n\n/* Define types for libio in terms of the standard internal type names.  */\n\n#include <bits/types.h>\n#define __need_size_t\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n#define __need_wchar_t\n#endif\n#define __need_NULL\n#include <stddef.h>\n#define __need_mbstate_t\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n#define __need_wint_t\n#endif\n#include <wchar.h>\ntypedef struct {\n\t__off_t __pos;\n\t__mbstate_t __state;\n} _G_fpos_t;\ntypedef struct {\n\t__off64_t __pos;\n\t__mbstate_t __state;\n} _G_fpos64_t;\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n#include <gconv.h>\ntypedef union {\n\tstruct __gconv_info __cd;\n\tstruct {\n\t\tstruct __gconv_info __cd;\n\t\tstruct __gconv_step_data __data;\n\t} __combined;\n} _G_iconv_t;\n#endif\n\n/* These library features are always available in the GNU C library.  */\n#define _G_va_list __gnuc_va_list\n\n#define _G_HAVE_MMAP 1\n#define _G_HAVE_MREMAP 1\n\n#define _G_IO_IO_FILE_VERSION 0x20001\n\n/* This is defined by <bits/stat.h> if `st_blksize' exists.  */\n#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)\n\n#define _G_BUFSIZ 8192\n\n#endif\t\t\t\t/* _G_config.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/alloca.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ALLOCA_H\n#define\t_ALLOCA_H\t1\n\n#include <features.h>\n\n#define\t__need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS\n/* Remove any previous definitions.  */\n#undef\talloca\n/* Allocate a block that will be freed when the calling function exits.  */\nextern void *alloca(size_t __size) __THROW;\n\n#ifdef\t__GNUC__\n#define alloca(size)\t__builtin_alloca (size)\n#endif\t\t\t\t/* GCC.  */\n\n__END_DECLS\n#endif\t\t\t\t/* alloca.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/errno.h",
    "content": "#include <asm-generic/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/ioctl.h",
    "content": "#include <asm-generic/ioctl.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/ioctls.h",
    "content": "#ifndef __ASM_ARM_IOCTLS_H\n#define __ASM_ARM_IOCTLS_H\n\n#define FIOQSIZE\t0x545E\n\n#include <asm-generic/ioctls.h>\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/param.h",
    "content": "#include <asm-generic/param.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/sigcontext.h",
    "content": "#ifndef _ASMARM_SIGCONTEXT_H\n#define _ASMARM_SIGCONTEXT_H\n\n/*\n * Signal context structure - contains all info to do with the state\n * before the signal handler was invoked.  Note: only add new entries\n * to the end of the structure.\n */\nstruct sigcontext {\n\tunsigned long trap_no;\n\tunsigned long error_code;\n\tunsigned long oldmask;\n\tunsigned long arm_r0;\n\tunsigned long arm_r1;\n\tunsigned long arm_r2;\n\tunsigned long arm_r3;\n\tunsigned long arm_r4;\n\tunsigned long arm_r5;\n\tunsigned long arm_r6;\n\tunsigned long arm_r7;\n\tunsigned long arm_r8;\n\tunsigned long arm_r9;\n\tunsigned long arm_r10;\n\tunsigned long arm_fp;\n\tunsigned long arm_ip;\n\tunsigned long arm_sp;\n\tunsigned long arm_lr;\n\tunsigned long arm_pc;\n\tunsigned long arm_cpsr;\n\tunsigned long fault_address;\n};\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/socket.h",
    "content": "#include <asm-generic/socket.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/asm/sockios.h",
    "content": "#include <asm-generic/sockios.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/byteswap-16.h",
    "content": "/* Macros to swap the order of bytes in 16-bit integer values.\n   Copyright (C) 2012-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_BYTESWAP_H\n#error \"Never use <bits/byteswap-16.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifdef __GNUC__\n#define __bswap_16(x) \\\n    (__extension__\t\t\t\t\t\t\t      \\\n     ({ unsigned short int __bsx = (unsigned short int) (x);\t\t      \\\n       __bswap_constant_16 (__bsx); }))\n#else\nstatic __inline unsigned short int __bswap_16(unsigned short int __bsx)\n{\n\treturn __bswap_constant_16(__bsx);\n}\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/byteswap.h",
    "content": "/* Macros to swap the order of bytes in integer values.\n   Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H\n#error \"Never use <bits/byteswap.h> directly; include <byteswap.h> instead.\"\n#endif\n\n#ifndef _BITS_BYTESWAP_H\n#define _BITS_BYTESWAP_H 1\n\n#include <features.h>\n#include <bits/types.h>\n\n/* Swap bytes in 16 bit value.  */\n#define __bswap_constant_16(x) \\\n\t((unsigned short int)((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))\n\n/* Get __bswap_16.  */\n#include <bits/byteswap-16.h>\n\n/* Swap bytes in 32 bit value.  */\n#define __bswap_constant_32(x) \\\n     ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >>  8) |\t      \\\n      (((x) & 0x0000ff00u) <<  8) | (((x) & 0x000000ffu) << 24))\n\n#ifdef __GNUC__\n#if __GNUC_PREREQ (4, 3)\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __builtin_bswap32(__bsx);\n}\n#else\n#define __bswap_32(x) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ unsigned int __bsx = (x); __bswap_constant_32 (__bsx); }))\n#endif\n#else\nstatic __inline unsigned int __bswap_32(unsigned int __bsx)\n{\n\treturn __bswap_constant_32(__bsx);\n}\n#endif\n\n/* Swap bytes in 64 bit value.  */\n#if __GNUC_PREREQ (2, 0)\n#define __bswap_constant_64(x) \\\n     (__extension__ ((((x) & 0xff00000000000000ull) >> 56)\t\t      \\\n\t\t     | (((x) & 0x00ff000000000000ull) >> 40)\t\t      \\\n\t\t     | (((x) & 0x0000ff0000000000ull) >> 24)\t\t      \\\n\t\t     | (((x) & 0x000000ff00000000ull) >> 8)\t\t      \\\n\t\t     | (((x) & 0x00000000ff000000ull) << 8)\t\t      \\\n\t\t     | (((x) & 0x0000000000ff0000ull) << 24)\t\t      \\\n\t\t     | (((x) & 0x000000000000ff00ull) << 40)\t\t      \\\n\t\t     | (((x) & 0x00000000000000ffull) << 56)))\n\n#if __GNUC_PREREQ (4, 3)\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __builtin_bswap64(__bsx);\n}\n#else\n#define __bswap_64(x) \\\n     (__extension__\t\t\t\t\t\t\t      \\\n      ({ union { __extension__ __uint64_t __ll;\t\t\t\t      \\\n\t\t unsigned int __l[2]; } __w, __r;\t\t\t      \\\n\t if (__builtin_constant_p (x))\t\t\t\t\t      \\\n\t   __r.__ll = __bswap_constant_64 (x);\t\t\t\t      \\\n\t else\t\t\t\t\t\t\t\t      \\\n\t   {\t\t\t\t\t\t\t\t      \\\n\t     __w.__ll = (x);\t\t\t\t\t\t      \\\n\t     __r.__l[0] = __bswap_32 (__w.__l[1]);\t\t\t      \\\n\t     __r.__l[1] = __bswap_32 (__w.__l[0]);\t\t\t      \\\n\t   }\t\t\t\t\t\t\t\t      \\\n\t __r.__ll; }))\n#endif\n#else\n#define __bswap_constant_64(x) \\\n     ((((x) & 0xff00000000000000ull) >> 56)\t\t\t\t      \\\n      | (((x) & 0x00ff000000000000ull) >> 40)\t\t\t\t      \\\n      | (((x) & 0x0000ff0000000000ull) >> 24)\t\t\t\t      \\\n      | (((x) & 0x000000ff00000000ull) >> 8)\t\t\t\t      \\\n      | (((x) & 0x00000000ff000000ull) << 8)\t\t\t\t      \\\n      | (((x) & 0x0000000000ff0000ull) << 24)\t\t\t\t      \\\n      | (((x) & 0x000000000000ff00ull) << 40)\t\t\t\t      \\\n      | (((x) & 0x00000000000000ffull) << 56))\n\nstatic __inline __uint64_t __bswap_64(__uint64_t __bsx)\n{\n\treturn __bswap_constant_64(__bsx);\n}\n#endif\n\n#endif\t\t\t\t/* _BITS_BYTESWAP_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/confname.h",
    "content": "/* `sysconf', `pathconf', and `confstr' NAME values.  Generic version.\n   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n#error \"Never use <bits/confname.h> directly; include <unistd.h> instead.\"\n#endif\n\n/* Values for the NAME argument to `pathconf' and `fpathconf'.  */\nenum {\n\t_PC_LINK_MAX,\n#define\t_PC_LINK_MAX\t\t\t_PC_LINK_MAX\n\t_PC_MAX_CANON,\n#define\t_PC_MAX_CANON\t\t\t_PC_MAX_CANON\n\t_PC_MAX_INPUT,\n#define\t_PC_MAX_INPUT\t\t\t_PC_MAX_INPUT\n\t_PC_NAME_MAX,\n#define\t_PC_NAME_MAX\t\t\t_PC_NAME_MAX\n\t_PC_PATH_MAX,\n#define\t_PC_PATH_MAX\t\t\t_PC_PATH_MAX\n\t_PC_PIPE_BUF,\n#define\t_PC_PIPE_BUF\t\t\t_PC_PIPE_BUF\n\t_PC_CHOWN_RESTRICTED,\n#define\t_PC_CHOWN_RESTRICTED\t\t_PC_CHOWN_RESTRICTED\n\t_PC_NO_TRUNC,\n#define\t_PC_NO_TRUNC\t\t\t_PC_NO_TRUNC\n\t_PC_VDISABLE,\n#define _PC_VDISABLE\t\t\t_PC_VDISABLE\n\t_PC_SYNC_IO,\n#define\t_PC_SYNC_IO\t\t\t_PC_SYNC_IO\n\t_PC_ASYNC_IO,\n#define\t_PC_ASYNC_IO\t\t\t_PC_ASYNC_IO\n\t_PC_PRIO_IO,\n#define\t_PC_PRIO_IO\t\t\t_PC_PRIO_IO\n\t_PC_SOCK_MAXBUF,\n#define\t_PC_SOCK_MAXBUF\t\t\t_PC_SOCK_MAXBUF\n\t_PC_FILESIZEBITS,\n#define _PC_FILESIZEBITS\t\t_PC_FILESIZEBITS\n\t_PC_REC_INCR_XFER_SIZE,\n#define _PC_REC_INCR_XFER_SIZE\t\t_PC_REC_INCR_XFER_SIZE\n\t_PC_REC_MAX_XFER_SIZE,\n#define _PC_REC_MAX_XFER_SIZE\t\t_PC_REC_MAX_XFER_SIZE\n\t_PC_REC_MIN_XFER_SIZE,\n#define _PC_REC_MIN_XFER_SIZE\t\t_PC_REC_MIN_XFER_SIZE\n\t_PC_REC_XFER_ALIGN,\n#define _PC_REC_XFER_ALIGN\t\t_PC_REC_XFER_ALIGN\n\t_PC_ALLOC_SIZE_MIN,\n#define _PC_ALLOC_SIZE_MIN\t\t_PC_ALLOC_SIZE_MIN\n\t_PC_SYMLINK_MAX,\n#define _PC_SYMLINK_MAX\t\t\t_PC_SYMLINK_MAX\n\t_PC_2_SYMLINKS\n#define _PC_2_SYMLINKS\t\t\t_PC_2_SYMLINKS\n};\n\n/* Values for the argument to `sysconf'.  */\nenum {\n\t_SC_ARG_MAX,\n#define\t_SC_ARG_MAX\t\t\t_SC_ARG_MAX\n\t_SC_CHILD_MAX,\n#define\t_SC_CHILD_MAX\t\t\t_SC_CHILD_MAX\n\t_SC_CLK_TCK,\n#define\t_SC_CLK_TCK\t\t\t_SC_CLK_TCK\n\t_SC_NGROUPS_MAX,\n#define\t_SC_NGROUPS_MAX\t\t\t_SC_NGROUPS_MAX\n\t_SC_OPEN_MAX,\n#define\t_SC_OPEN_MAX\t\t\t_SC_OPEN_MAX\n\t_SC_STREAM_MAX,\n#define\t_SC_STREAM_MAX\t\t\t_SC_STREAM_MAX\n\t_SC_TZNAME_MAX,\n#define\t_SC_TZNAME_MAX\t\t\t_SC_TZNAME_MAX\n\t_SC_JOB_CONTROL,\n#define\t_SC_JOB_CONTROL\t\t\t_SC_JOB_CONTROL\n\t_SC_SAVED_IDS,\n#define\t_SC_SAVED_IDS\t\t\t_SC_SAVED_IDS\n\t_SC_REALTIME_SIGNALS,\n#define\t_SC_REALTIME_SIGNALS\t\t_SC_REALTIME_SIGNALS\n\t_SC_PRIORITY_SCHEDULING,\n#define\t_SC_PRIORITY_SCHEDULING\t\t_SC_PRIORITY_SCHEDULING\n\t_SC_TIMERS,\n#define\t_SC_TIMERS\t\t\t_SC_TIMERS\n\t_SC_ASYNCHRONOUS_IO,\n#define\t_SC_ASYNCHRONOUS_IO\t\t_SC_ASYNCHRONOUS_IO\n\t_SC_PRIORITIZED_IO,\n#define\t_SC_PRIORITIZED_IO\t\t_SC_PRIORITIZED_IO\n\t_SC_SYNCHRONIZED_IO,\n#define\t_SC_SYNCHRONIZED_IO\t\t_SC_SYNCHRONIZED_IO\n\t_SC_FSYNC,\n#define\t_SC_FSYNC\t\t\t_SC_FSYNC\n\t_SC_MAPPED_FILES,\n#define\t_SC_MAPPED_FILES\t\t_SC_MAPPED_FILES\n\t_SC_MEMLOCK,\n#define\t_SC_MEMLOCK\t\t\t_SC_MEMLOCK\n\t_SC_MEMLOCK_RANGE,\n#define\t_SC_MEMLOCK_RANGE\t\t_SC_MEMLOCK_RANGE\n\t_SC_MEMORY_PROTECTION,\n#define\t_SC_MEMORY_PROTECTION\t\t_SC_MEMORY_PROTECTION\n\t_SC_MESSAGE_PASSING,\n#define\t_SC_MESSAGE_PASSING\t\t_SC_MESSAGE_PASSING\n\t_SC_SEMAPHORES,\n#define\t_SC_SEMAPHORES\t\t\t_SC_SEMAPHORES\n\t_SC_SHARED_MEMORY_OBJECTS,\n#define\t_SC_SHARED_MEMORY_OBJECTS\t_SC_SHARED_MEMORY_OBJECTS\n\t_SC_AIO_LISTIO_MAX,\n#define\t_SC_AIO_LISTIO_MAX\t\t_SC_AIO_LISTIO_MAX\n\t_SC_AIO_MAX,\n#define\t_SC_AIO_MAX\t\t\t_SC_AIO_MAX\n\t_SC_AIO_PRIO_DELTA_MAX,\n#define\t_SC_AIO_PRIO_DELTA_MAX\t\t_SC_AIO_PRIO_DELTA_MAX\n\t_SC_DELAYTIMER_MAX,\n#define\t_SC_DELAYTIMER_MAX\t\t_SC_DELAYTIMER_MAX\n\t_SC_MQ_OPEN_MAX,\n#define\t_SC_MQ_OPEN_MAX\t\t\t_SC_MQ_OPEN_MAX\n\t_SC_MQ_PRIO_MAX,\n#define\t_SC_MQ_PRIO_MAX\t\t\t_SC_MQ_PRIO_MAX\n\t_SC_VERSION,\n#define\t_SC_VERSION\t\t\t_SC_VERSION\n\t_SC_PAGESIZE,\n#define\t_SC_PAGESIZE\t\t\t_SC_PAGESIZE\n#define\t_SC_PAGE_SIZE\t\t\t_SC_PAGESIZE\n\t_SC_RTSIG_MAX,\n#define\t_SC_RTSIG_MAX\t\t\t_SC_RTSIG_MAX\n\t_SC_SEM_NSEMS_MAX,\n#define\t_SC_SEM_NSEMS_MAX\t\t_SC_SEM_NSEMS_MAX\n\t_SC_SEM_VALUE_MAX,\n#define\t_SC_SEM_VALUE_MAX\t\t_SC_SEM_VALUE_MAX\n\t_SC_SIGQUEUE_MAX,\n#define\t_SC_SIGQUEUE_MAX\t\t_SC_SIGQUEUE_MAX\n\t_SC_TIMER_MAX,\n#define\t_SC_TIMER_MAX\t\t\t_SC_TIMER_MAX\n\n\t/* Values for the argument to `sysconf'\n\t   corresponding to _POSIX2_* symbols.  */\n\t_SC_BC_BASE_MAX,\n#define\t_SC_BC_BASE_MAX\t\t\t_SC_BC_BASE_MAX\n\t_SC_BC_DIM_MAX,\n#define\t_SC_BC_DIM_MAX\t\t\t_SC_BC_DIM_MAX\n\t_SC_BC_SCALE_MAX,\n#define\t_SC_BC_SCALE_MAX\t\t_SC_BC_SCALE_MAX\n\t_SC_BC_STRING_MAX,\n#define\t_SC_BC_STRING_MAX\t\t_SC_BC_STRING_MAX\n\t_SC_COLL_WEIGHTS_MAX,\n#define\t_SC_COLL_WEIGHTS_MAX\t\t_SC_COLL_WEIGHTS_MAX\n\t_SC_EQUIV_CLASS_MAX,\n#define\t_SC_EQUIV_CLASS_MAX\t\t_SC_EQUIV_CLASS_MAX\n\t_SC_EXPR_NEST_MAX,\n#define\t_SC_EXPR_NEST_MAX\t\t_SC_EXPR_NEST_MAX\n\t_SC_LINE_MAX,\n#define\t_SC_LINE_MAX\t\t\t_SC_LINE_MAX\n\t_SC_RE_DUP_MAX,\n#define\t_SC_RE_DUP_MAX\t\t\t_SC_RE_DUP_MAX\n\t_SC_CHARCLASS_NAME_MAX,\n#define\t_SC_CHARCLASS_NAME_MAX\t\t_SC_CHARCLASS_NAME_MAX\n\n\t_SC_2_VERSION,\n#define\t_SC_2_VERSION\t\t\t_SC_2_VERSION\n\t_SC_2_C_BIND,\n#define\t_SC_2_C_BIND\t\t\t_SC_2_C_BIND\n\t_SC_2_C_DEV,\n#define\t_SC_2_C_DEV\t\t\t_SC_2_C_DEV\n\t_SC_2_FORT_DEV,\n#define\t_SC_2_FORT_DEV\t\t\t_SC_2_FORT_DEV\n\t_SC_2_FORT_RUN,\n#define\t_SC_2_FORT_RUN\t\t\t_SC_2_FORT_RUN\n\t_SC_2_SW_DEV,\n#define\t_SC_2_SW_DEV\t\t\t_SC_2_SW_DEV\n\t_SC_2_LOCALEDEF,\n#define\t_SC_2_LOCALEDEF\t\t\t_SC_2_LOCALEDEF\n\n\t_SC_PII,\n#define\t_SC_PII\t\t\t\t_SC_PII\n\t_SC_PII_XTI,\n#define\t_SC_PII_XTI\t\t\t_SC_PII_XTI\n\t_SC_PII_SOCKET,\n#define\t_SC_PII_SOCKET\t\t\t_SC_PII_SOCKET\n\t_SC_PII_INTERNET,\n#define\t_SC_PII_INTERNET\t\t_SC_PII_INTERNET\n\t_SC_PII_OSI,\n#define\t_SC_PII_OSI\t\t\t_SC_PII_OSI\n\t_SC_POLL,\n#define\t_SC_POLL\t\t\t_SC_POLL\n\t_SC_SELECT,\n#define\t_SC_SELECT\t\t\t_SC_SELECT\n\t_SC_UIO_MAXIOV,\n#define\t_SC_UIO_MAXIOV\t\t\t_SC_UIO_MAXIOV\n\t_SC_IOV_MAX = _SC_UIO_MAXIOV,\n#define _SC_IOV_MAX\t\t\t_SC_IOV_MAX\n\t_SC_PII_INTERNET_STREAM,\n#define\t_SC_PII_INTERNET_STREAM\t\t_SC_PII_INTERNET_STREAM\n\t_SC_PII_INTERNET_DGRAM,\n#define\t_SC_PII_INTERNET_DGRAM\t\t_SC_PII_INTERNET_DGRAM\n\t_SC_PII_OSI_COTS,\n#define\t_SC_PII_OSI_COTS\t\t_SC_PII_OSI_COTS\n\t_SC_PII_OSI_CLTS,\n#define\t_SC_PII_OSI_CLTS\t\t_SC_PII_OSI_CLTS\n\t_SC_PII_OSI_M,\n#define\t_SC_PII_OSI_M\t\t\t_SC_PII_OSI_M\n\t_SC_T_IOV_MAX,\n#define\t_SC_T_IOV_MAX\t\t\t_SC_T_IOV_MAX\n\n\t/* Values according to POSIX 1003.1c (POSIX threads).  */\n\t_SC_THREADS,\n#define\t_SC_THREADS\t\t\t_SC_THREADS\n\t_SC_THREAD_SAFE_FUNCTIONS,\n#define _SC_THREAD_SAFE_FUNCTIONS\t_SC_THREAD_SAFE_FUNCTIONS\n\t_SC_GETGR_R_SIZE_MAX,\n#define\t_SC_GETGR_R_SIZE_MAX\t\t_SC_GETGR_R_SIZE_MAX\n\t_SC_GETPW_R_SIZE_MAX,\n#define\t_SC_GETPW_R_SIZE_MAX\t\t_SC_GETPW_R_SIZE_MAX\n\t_SC_LOGIN_NAME_MAX,\n#define\t_SC_LOGIN_NAME_MAX\t\t_SC_LOGIN_NAME_MAX\n\t_SC_TTY_NAME_MAX,\n#define\t_SC_TTY_NAME_MAX\t\t_SC_TTY_NAME_MAX\n\t_SC_THREAD_DESTRUCTOR_ITERATIONS,\n#define\t_SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS\n\t_SC_THREAD_KEYS_MAX,\n#define\t_SC_THREAD_KEYS_MAX\t\t_SC_THREAD_KEYS_MAX\n\t_SC_THREAD_STACK_MIN,\n#define\t_SC_THREAD_STACK_MIN\t\t_SC_THREAD_STACK_MIN\n\t_SC_THREAD_THREADS_MAX,\n#define\t_SC_THREAD_THREADS_MAX\t\t_SC_THREAD_THREADS_MAX\n\t_SC_THREAD_ATTR_STACKADDR,\n#define\t_SC_THREAD_ATTR_STACKADDR\t_SC_THREAD_ATTR_STACKADDR\n\t_SC_THREAD_ATTR_STACKSIZE,\n#define\t_SC_THREAD_ATTR_STACKSIZE\t_SC_THREAD_ATTR_STACKSIZE\n\t_SC_THREAD_PRIORITY_SCHEDULING,\n#define\t_SC_THREAD_PRIORITY_SCHEDULING\t_SC_THREAD_PRIORITY_SCHEDULING\n\t_SC_THREAD_PRIO_INHERIT,\n#define\t_SC_THREAD_PRIO_INHERIT\t\t_SC_THREAD_PRIO_INHERIT\n\t_SC_THREAD_PRIO_PROTECT,\n#define\t_SC_THREAD_PRIO_PROTECT\t\t_SC_THREAD_PRIO_PROTECT\n\t_SC_THREAD_PROCESS_SHARED,\n#define\t_SC_THREAD_PROCESS_SHARED\t_SC_THREAD_PROCESS_SHARED\n\n\t_SC_NPROCESSORS_CONF,\n#define _SC_NPROCESSORS_CONF\t\t_SC_NPROCESSORS_CONF\n\t_SC_NPROCESSORS_ONLN,\n#define _SC_NPROCESSORS_ONLN\t\t_SC_NPROCESSORS_ONLN\n\t_SC_PHYS_PAGES,\n#define _SC_PHYS_PAGES\t\t\t_SC_PHYS_PAGES\n\t_SC_AVPHYS_PAGES,\n#define _SC_AVPHYS_PAGES\t\t_SC_AVPHYS_PAGES\n\t_SC_ATEXIT_MAX,\n#define _SC_ATEXIT_MAX\t\t\t_SC_ATEXIT_MAX\n\t_SC_PASS_MAX,\n#define _SC_PASS_MAX\t\t\t_SC_PASS_MAX\n\n\t_SC_XOPEN_VERSION,\n#define _SC_XOPEN_VERSION\t\t_SC_XOPEN_VERSION\n\t_SC_XOPEN_XCU_VERSION,\n#define _SC_XOPEN_XCU_VERSION\t\t_SC_XOPEN_XCU_VERSION\n\t_SC_XOPEN_UNIX,\n#define _SC_XOPEN_UNIX\t\t\t_SC_XOPEN_UNIX\n\t_SC_XOPEN_CRYPT,\n#define _SC_XOPEN_CRYPT\t\t\t_SC_XOPEN_CRYPT\n\t_SC_XOPEN_ENH_I18N,\n#define _SC_XOPEN_ENH_I18N\t\t_SC_XOPEN_ENH_I18N\n\t_SC_XOPEN_SHM,\n#define _SC_XOPEN_SHM\t\t\t_SC_XOPEN_SHM\n\n\t_SC_2_CHAR_TERM,\n#define _SC_2_CHAR_TERM\t\t\t_SC_2_CHAR_TERM\n\t_SC_2_C_VERSION,\n#define _SC_2_C_VERSION\t\t\t_SC_2_C_VERSION\n\t_SC_2_UPE,\n#define _SC_2_UPE\t\t\t_SC_2_UPE\n\n\t_SC_XOPEN_XPG2,\n#define _SC_XOPEN_XPG2\t\t\t_SC_XOPEN_XPG2\n\t_SC_XOPEN_XPG3,\n#define _SC_XOPEN_XPG3\t\t\t_SC_XOPEN_XPG3\n\t_SC_XOPEN_XPG4,\n#define _SC_XOPEN_XPG4\t\t\t_SC_XOPEN_XPG4\n\n\t_SC_CHAR_BIT,\n#define\t_SC_CHAR_BIT\t\t\t_SC_CHAR_BIT\n\t_SC_CHAR_MAX,\n#define\t_SC_CHAR_MAX\t\t\t_SC_CHAR_MAX\n\t_SC_CHAR_MIN,\n#define\t_SC_CHAR_MIN\t\t\t_SC_CHAR_MIN\n\t_SC_INT_MAX,\n#define\t_SC_INT_MAX\t\t\t_SC_INT_MAX\n\t_SC_INT_MIN,\n#define\t_SC_INT_MIN\t\t\t_SC_INT_MIN\n\t_SC_LONG_BIT,\n#define\t_SC_LONG_BIT\t\t\t_SC_LONG_BIT\n\t_SC_WORD_BIT,\n#define\t_SC_WORD_BIT\t\t\t_SC_WORD_BIT\n\t_SC_MB_LEN_MAX,\n#define\t_SC_MB_LEN_MAX\t\t\t_SC_MB_LEN_MAX\n\t_SC_NZERO,\n#define\t_SC_NZERO\t\t\t_SC_NZERO\n\t_SC_SSIZE_MAX,\n#define\t_SC_SSIZE_MAX\t\t\t_SC_SSIZE_MAX\n\t_SC_SCHAR_MAX,\n#define\t_SC_SCHAR_MAX\t\t\t_SC_SCHAR_MAX\n\t_SC_SCHAR_MIN,\n#define\t_SC_SCHAR_MIN\t\t\t_SC_SCHAR_MIN\n\t_SC_SHRT_MAX,\n#define\t_SC_SHRT_MAX\t\t\t_SC_SHRT_MAX\n\t_SC_SHRT_MIN,\n#define\t_SC_SHRT_MIN\t\t\t_SC_SHRT_MIN\n\t_SC_UCHAR_MAX,\n#define\t_SC_UCHAR_MAX\t\t\t_SC_UCHAR_MAX\n\t_SC_UINT_MAX,\n#define\t_SC_UINT_MAX\t\t\t_SC_UINT_MAX\n\t_SC_ULONG_MAX,\n#define\t_SC_ULONG_MAX\t\t\t_SC_ULONG_MAX\n\t_SC_USHRT_MAX,\n#define\t_SC_USHRT_MAX\t\t\t_SC_USHRT_MAX\n\n\t_SC_NL_ARGMAX,\n#define\t_SC_NL_ARGMAX\t\t\t_SC_NL_ARGMAX\n\t_SC_NL_LANGMAX,\n#define\t_SC_NL_LANGMAX\t\t\t_SC_NL_LANGMAX\n\t_SC_NL_MSGMAX,\n#define\t_SC_NL_MSGMAX\t\t\t_SC_NL_MSGMAX\n\t_SC_NL_NMAX,\n#define\t_SC_NL_NMAX\t\t\t_SC_NL_NMAX\n\t_SC_NL_SETMAX,\n#define\t_SC_NL_SETMAX\t\t\t_SC_NL_SETMAX\n\t_SC_NL_TEXTMAX,\n#define\t_SC_NL_TEXTMAX\t\t\t_SC_NL_TEXTMAX\n\n\t_SC_XBS5_ILP32_OFF32,\n#define _SC_XBS5_ILP32_OFF32\t\t_SC_XBS5_ILP32_OFF32\n\t_SC_XBS5_ILP32_OFFBIG,\n#define _SC_XBS5_ILP32_OFFBIG\t\t_SC_XBS5_ILP32_OFFBIG\n\t_SC_XBS5_LP64_OFF64,\n#define _SC_XBS5_LP64_OFF64\t\t_SC_XBS5_LP64_OFF64\n\t_SC_XBS5_LPBIG_OFFBIG,\n#define _SC_XBS5_LPBIG_OFFBIG\t\t_SC_XBS5_LPBIG_OFFBIG\n\n\t_SC_XOPEN_LEGACY,\n#define _SC_XOPEN_LEGACY\t\t_SC_XOPEN_LEGACY\n\t_SC_XOPEN_REALTIME,\n#define _SC_XOPEN_REALTIME\t\t_SC_XOPEN_REALTIME\n\t_SC_XOPEN_REALTIME_THREADS,\n#define _SC_XOPEN_REALTIME_THREADS\t_SC_XOPEN_REALTIME_THREADS\n\n\t_SC_ADVISORY_INFO,\n#define _SC_ADVISORY_INFO\t\t_SC_ADVISORY_INFO\n\t_SC_BARRIERS,\n#define _SC_BARRIERS\t\t\t_SC_BARRIERS\n\t_SC_BASE,\n#define _SC_BASE\t\t\t_SC_BASE\n\t_SC_C_LANG_SUPPORT,\n#define _SC_C_LANG_SUPPORT\t\t_SC_C_LANG_SUPPORT\n\t_SC_C_LANG_SUPPORT_R,\n#define _SC_C_LANG_SUPPORT_R\t\t_SC_C_LANG_SUPPORT_R\n\t_SC_CLOCK_SELECTION,\n#define _SC_CLOCK_SELECTION\t\t_SC_CLOCK_SELECTION\n\t_SC_CPUTIME,\n#define _SC_CPUTIME\t\t\t_SC_CPUTIME\n\t_SC_THREAD_CPUTIME,\n#define _SC_THREAD_CPUTIME\t\t_SC_THREAD_CPUTIME\n\t_SC_DEVICE_IO,\n#define _SC_DEVICE_IO\t\t\t_SC_DEVICE_IO\n\t_SC_DEVICE_SPECIFIC,\n#define _SC_DEVICE_SPECIFIC\t\t_SC_DEVICE_SPECIFIC\n\t_SC_DEVICE_SPECIFIC_R,\n#define _SC_DEVICE_SPECIFIC_R\t\t_SC_DEVICE_SPECIFIC_R\n\t_SC_FD_MGMT,\n#define _SC_FD_MGMT\t\t\t_SC_FD_MGMT\n\t_SC_FIFO,\n#define _SC_FIFO\t\t\t_SC_FIFO\n\t_SC_PIPE,\n#define _SC_PIPE\t\t\t_SC_PIPE\n\t_SC_FILE_ATTRIBUTES,\n#define _SC_FILE_ATTRIBUTES\t\t_SC_FILE_ATTRIBUTES\n\t_SC_FILE_LOCKING,\n#define _SC_FILE_LOCKING\t\t_SC_FILE_LOCKING\n\t_SC_FILE_SYSTEM,\n#define _SC_FILE_SYSTEM\t\t\t_SC_FILE_SYSTEM\n\t_SC_MONOTONIC_CLOCK,\n#define _SC_MONOTONIC_CLOCK\t\t_SC_MONOTONIC_CLOCK\n\t_SC_MULTI_PROCESS,\n#define _SC_MULTI_PROCESS\t\t_SC_MULTI_PROCESS\n\t_SC_SINGLE_PROCESS,\n#define _SC_SINGLE_PROCESS\t\t_SC_SINGLE_PROCESS\n\t_SC_NETWORKING,\n#define _SC_NETWORKING\t\t\t_SC_NETWORKING\n\t_SC_READER_WRITER_LOCKS,\n#define _SC_READER_WRITER_LOCKS\t\t_SC_READER_WRITER_LOCKS\n\t_SC_SPIN_LOCKS,\n#define _SC_SPIN_LOCKS\t\t\t_SC_SPIN_LOCKS\n\t_SC_REGEXP,\n#define _SC_REGEXP\t\t\t_SC_REGEXP\n\t_SC_REGEX_VERSION,\n#define _SC_REGEX_VERSION\t\t_SC_REGEX_VERSION\n\t_SC_SHELL,\n#define _SC_SHELL\t\t\t_SC_SHELL\n\t_SC_SIGNALS,\n#define _SC_SIGNALS\t\t\t_SC_SIGNALS\n\t_SC_SPAWN,\n#define _SC_SPAWN\t\t\t_SC_SPAWN\n\t_SC_SPORADIC_SERVER,\n#define _SC_SPORADIC_SERVER\t\t_SC_SPORADIC_SERVER\n\t_SC_THREAD_SPORADIC_SERVER,\n#define _SC_THREAD_SPORADIC_SERVER\t_SC_THREAD_SPORADIC_SERVER\n\t_SC_SYSTEM_DATABASE,\n#define _SC_SYSTEM_DATABASE\t\t_SC_SYSTEM_DATABASE\n\t_SC_SYSTEM_DATABASE_R,\n#define _SC_SYSTEM_DATABASE_R\t\t_SC_SYSTEM_DATABASE_R\n\t_SC_TIMEOUTS,\n#define _SC_TIMEOUTS\t\t\t_SC_TIMEOUTS\n\t_SC_TYPED_MEMORY_OBJECTS,\n#define _SC_TYPED_MEMORY_OBJECTS\t_SC_TYPED_MEMORY_OBJECTS\n\t_SC_USER_GROUPS,\n#define _SC_USER_GROUPS\t\t\t_SC_USER_GROUPS\n\t_SC_USER_GROUPS_R,\n#define _SC_USER_GROUPS_R\t\t_SC_USER_GROUPS_R\n\t_SC_2_PBS,\n#define _SC_2_PBS\t\t\t_SC_2_PBS\n\t_SC_2_PBS_ACCOUNTING,\n#define _SC_2_PBS_ACCOUNTING\t\t_SC_2_PBS_ACCOUNTING\n\t_SC_2_PBS_LOCATE,\n#define _SC_2_PBS_LOCATE\t\t_SC_2_PBS_LOCATE\n\t_SC_2_PBS_MESSAGE,\n#define _SC_2_PBS_MESSAGE\t\t_SC_2_PBS_MESSAGE\n\t_SC_2_PBS_TRACK,\n#define _SC_2_PBS_TRACK\t\t\t_SC_2_PBS_TRACK\n\t_SC_SYMLOOP_MAX,\n#define _SC_SYMLOOP_MAX\t\t\t_SC_SYMLOOP_MAX\n\t_SC_STREAMS,\n#define _SC_STREAMS\t\t\t_SC_STREAMS\n\t_SC_2_PBS_CHECKPOINT,\n#define _SC_2_PBS_CHECKPOINT\t\t_SC_2_PBS_CHECKPOINT\n\n\t_SC_V6_ILP32_OFF32,\n#define _SC_V6_ILP32_OFF32\t\t_SC_V6_ILP32_OFF32\n\t_SC_V6_ILP32_OFFBIG,\n#define _SC_V6_ILP32_OFFBIG\t\t_SC_V6_ILP32_OFFBIG\n\t_SC_V6_LP64_OFF64,\n#define _SC_V6_LP64_OFF64\t\t_SC_V6_LP64_OFF64\n\t_SC_V6_LPBIG_OFFBIG,\n#define _SC_V6_LPBIG_OFFBIG\t\t_SC_V6_LPBIG_OFFBIG\n\n\t_SC_HOST_NAME_MAX,\n#define _SC_HOST_NAME_MAX\t\t_SC_HOST_NAME_MAX\n\t_SC_TRACE,\n#define _SC_TRACE\t\t\t_SC_TRACE\n\t_SC_TRACE_EVENT_FILTER,\n#define _SC_TRACE_EVENT_FILTER\t\t_SC_TRACE_EVENT_FILTER\n\t_SC_TRACE_INHERIT,\n#define _SC_TRACE_INHERIT\t\t_SC_TRACE_INHERIT\n\t_SC_TRACE_LOG,\n#define _SC_TRACE_LOG\t\t\t_SC_TRACE_LOG\n\n\t_SC_LEVEL1_ICACHE_SIZE,\n#define _SC_LEVEL1_ICACHE_SIZE\t\t_SC_LEVEL1_ICACHE_SIZE\n\t_SC_LEVEL1_ICACHE_ASSOC,\n#define _SC_LEVEL1_ICACHE_ASSOC\t\t_SC_LEVEL1_ICACHE_ASSOC\n\t_SC_LEVEL1_ICACHE_LINESIZE,\n#define _SC_LEVEL1_ICACHE_LINESIZE\t_SC_LEVEL1_ICACHE_LINESIZE\n\t_SC_LEVEL1_DCACHE_SIZE,\n#define _SC_LEVEL1_DCACHE_SIZE\t\t_SC_LEVEL1_DCACHE_SIZE\n\t_SC_LEVEL1_DCACHE_ASSOC,\n#define _SC_LEVEL1_DCACHE_ASSOC\t\t_SC_LEVEL1_DCACHE_ASSOC\n\t_SC_LEVEL1_DCACHE_LINESIZE,\n#define _SC_LEVEL1_DCACHE_LINESIZE\t_SC_LEVEL1_DCACHE_LINESIZE\n\t_SC_LEVEL2_CACHE_SIZE,\n#define _SC_LEVEL2_CACHE_SIZE\t\t_SC_LEVEL2_CACHE_SIZE\n\t_SC_LEVEL2_CACHE_ASSOC,\n#define _SC_LEVEL2_CACHE_ASSOC\t\t_SC_LEVEL2_CACHE_ASSOC\n\t_SC_LEVEL2_CACHE_LINESIZE,\n#define _SC_LEVEL2_CACHE_LINESIZE\t_SC_LEVEL2_CACHE_LINESIZE\n\t_SC_LEVEL3_CACHE_SIZE,\n#define _SC_LEVEL3_CACHE_SIZE\t\t_SC_LEVEL3_CACHE_SIZE\n\t_SC_LEVEL3_CACHE_ASSOC,\n#define _SC_LEVEL3_CACHE_ASSOC\t\t_SC_LEVEL3_CACHE_ASSOC\n\t_SC_LEVEL3_CACHE_LINESIZE,\n#define _SC_LEVEL3_CACHE_LINESIZE\t_SC_LEVEL3_CACHE_LINESIZE\n\t_SC_LEVEL4_CACHE_SIZE,\n#define _SC_LEVEL4_CACHE_SIZE\t\t_SC_LEVEL4_CACHE_SIZE\n\t_SC_LEVEL4_CACHE_ASSOC,\n#define _SC_LEVEL4_CACHE_ASSOC\t\t_SC_LEVEL4_CACHE_ASSOC\n\t_SC_LEVEL4_CACHE_LINESIZE,\n#define _SC_LEVEL4_CACHE_LINESIZE\t_SC_LEVEL4_CACHE_LINESIZE\n\t/* Leave room here, maybe we need a few more cache levels some day.  */\n\n\t_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,\n#define _SC_IPV6\t\t\t_SC_IPV6\n\t_SC_RAW_SOCKETS,\n#define _SC_RAW_SOCKETS\t\t\t_SC_RAW_SOCKETS\n\n\t_SC_V7_ILP32_OFF32,\n#define _SC_V7_ILP32_OFF32\t\t_SC_V7_ILP32_OFF32\n\t_SC_V7_ILP32_OFFBIG,\n#define _SC_V7_ILP32_OFFBIG\t\t_SC_V7_ILP32_OFFBIG\n\t_SC_V7_LP64_OFF64,\n#define _SC_V7_LP64_OFF64\t\t_SC_V7_LP64_OFF64\n\t_SC_V7_LPBIG_OFFBIG,\n#define _SC_V7_LPBIG_OFFBIG\t\t_SC_V7_LPBIG_OFFBIG\n\n\t_SC_SS_REPL_MAX,\n#define _SC_SS_REPL_MAX\t\t\t_SC_SS_REPL_MAX\n\n\t_SC_TRACE_EVENT_NAME_MAX,\n#define _SC_TRACE_EVENT_NAME_MAX\t_SC_TRACE_EVENT_NAME_MAX\n\t_SC_TRACE_NAME_MAX,\n#define _SC_TRACE_NAME_MAX\t\t_SC_TRACE_NAME_MAX\n\t_SC_TRACE_SYS_MAX,\n#define _SC_TRACE_SYS_MAX\t\t_SC_TRACE_SYS_MAX\n\t_SC_TRACE_USER_EVENT_MAX,\n#define _SC_TRACE_USER_EVENT_MAX\t_SC_TRACE_USER_EVENT_MAX\n\n\t_SC_XOPEN_STREAMS,\n#define _SC_XOPEN_STREAMS\t\t_SC_XOPEN_STREAMS\n\n\t_SC_THREAD_ROBUST_PRIO_INHERIT,\n#define _SC_THREAD_ROBUST_PRIO_INHERIT\t_SC_THREAD_ROBUST_PRIO_INHERIT\n\t_SC_THREAD_ROBUST_PRIO_PROTECT\n#define _SC_THREAD_ROBUST_PRIO_PROTECT\t_SC_THREAD_ROBUST_PRIO_PROTECT\n};\n\n/* Values for the NAME argument to `confstr'.  */\nenum {\n\t_CS_PATH,\t\t/* The default search path.  */\n#define _CS_PATH\t\t_CS_PATH\n\n\t_CS_V6_WIDTH_RESTRICTED_ENVS,\n#define _CS_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS\t_CS_V6_WIDTH_RESTRICTED_ENVS\n\n\t_CS_GNU_LIBC_VERSION,\n#define _CS_GNU_LIBC_VERSION\t_CS_GNU_LIBC_VERSION\n\t_CS_GNU_LIBPTHREAD_VERSION,\n#define _CS_GNU_LIBPTHREAD_VERSION\t_CS_GNU_LIBPTHREAD_VERSION\n\n\t_CS_V5_WIDTH_RESTRICTED_ENVS,\n#define _CS_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS\t_CS_V5_WIDTH_RESTRICTED_ENVS\n\n\t_CS_V7_WIDTH_RESTRICTED_ENVS,\n#define _CS_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS\t_CS_V7_WIDTH_RESTRICTED_ENVS\n\n\t_CS_LFS_CFLAGS = 1000,\n#define _CS_LFS_CFLAGS\t_CS_LFS_CFLAGS\n\t_CS_LFS_LDFLAGS,\n#define _CS_LFS_LDFLAGS\t_CS_LFS_LDFLAGS\n\t_CS_LFS_LIBS,\n#define _CS_LFS_LIBS\t\t_CS_LFS_LIBS\n\t_CS_LFS_LINTFLAGS,\n#define _CS_LFS_LINTFLAGS\t_CS_LFS_LINTFLAGS\n\t_CS_LFS64_CFLAGS,\n#define _CS_LFS64_CFLAGS\t_CS_LFS64_CFLAGS\n\t_CS_LFS64_LDFLAGS,\n#define _CS_LFS64_LDFLAGS\t_CS_LFS64_LDFLAGS\n\t_CS_LFS64_LIBS,\n#define _CS_LFS64_LIBS\t_CS_LFS64_LIBS\n\t_CS_LFS64_LINTFLAGS,\n#define _CS_LFS64_LINTFLAGS\t_CS_LFS64_LINTFLAGS\n\n\t_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,\n#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS\n\t_CS_XBS5_ILP32_OFF32_LDFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS\n\t_CS_XBS5_ILP32_OFF32_LIBS,\n#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS\n\t_CS_XBS5_ILP32_OFF32_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_CFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LDFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS\n\t_CS_XBS5_ILP32_OFFBIG_LIBS,\n#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS\n\t_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS\n\t_CS_XBS5_LP64_OFF64_CFLAGS,\n#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS\n\t_CS_XBS5_LP64_OFF64_LDFLAGS,\n#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS\n\t_CS_XBS5_LP64_OFF64_LIBS,\n#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS\n\t_CS_XBS5_LP64_OFF64_LINTFLAGS,\n#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_CFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS\n\t_CS_XBS5_LPBIG_OFFBIG_LIBS,\n#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS\n\t_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V6_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS\n\t_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V6_LP64_OFF64_LIBS,\n#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS\n\t_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_POSIX_V7_ILP32_OFF32_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFF32_LIBS,\n#define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS\n\t_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LIBS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS\n\t_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_CFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LDFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS\n\t_CS_POSIX_V7_LP64_OFF64_LIBS,\n#define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS\n\t_CS_POSIX_V7_LP64_OFF64_LINTFLAGS,\n#define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS _CS_POSIX_V7_LP64_OFF64_LINTFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LIBS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS\n\t_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,\n#define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS\n\n\t_CS_V6_ENV,\n#define _CS_V6_ENV\t\t\t_CS_V6_ENV\n\t_CS_V7_ENV\n#define _CS_V7_ENV\t\t\t_CS_V7_ENV\n};\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/dirent.h",
    "content": "/* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DIRENT_H\n#error \"Never use <bits/dirent.h> directly; include <dirent.h> instead.\"\n#endif\n\nstruct dirent {\n#ifndef __USE_FILE_OFFSET64\n\t__ino_t d_ino;\n\t__off_t d_off;\n#else\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n#endif\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct dirent64 {\n\t__ino64_t d_ino;\n\t__off64_t d_off;\n\tunsigned short int d_reclen;\n\tunsigned char d_type;\n\tchar d_name[256];\t/* We must not include limits.h! */\n};\n#endif\n\n#define d_fileno\td_ino\t/* Backwards compatibility.  */\n\n#undef  _DIRENT_HAVE_D_NAMLEN\n#define _DIRENT_HAVE_D_RECLEN\n#define _DIRENT_HAVE_D_OFF\n#define _DIRENT_HAVE_D_TYPE\n\n#if defined __OFF_T_MATCHES_OFF64_T && defined __INO_T_MATCHES_INO64_T\n/* Inform libc code that these two types are effectively identical.  */\n#define _DIRENT_MATCHES_DIRENT64\t1\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/dlfcn.h",
    "content": "/* System dependent definitions for run-time dynamic loading.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _DLFCN_H\n#error \"Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead.\"\n#endif\n\n/* The MODE argument to `dlopen' contains one of the following: */\n#define RTLD_LAZY\t0x00001\t/* Lazy function call binding.  */\n#define RTLD_NOW\t0x00002\t/* Immediate function call binding.  */\n#define\tRTLD_BINDING_MASK   0x3\t/* Mask of binding time value.  */\n#define RTLD_NOLOAD\t0x00004\t/* Do not load the object.  */\n#define RTLD_DEEPBIND\t0x00008\t/* Use deep binding.  */\n\n/* If the following bit is set in the MODE argument to `dlopen',\n   the symbols of the loaded object and its dependencies are made\n   visible as if the object were linked directly into the program.  */\n#define RTLD_GLOBAL\t0x00100\n\n/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL.\n   The implementation does this by default and so we can define the\n   value to zero.  */\n#define RTLD_LOCAL\t0\n\n/* Do not delete object when closed.  */\n#define RTLD_NODELETE\t0x01000\n\n#ifdef __USE_GNU\n/* To support profiling of shared objects it is a good idea to call\n   the function found using `dlsym' using the following macro since\n   these calls do not use the PLT.  But this would mean the dynamic\n   loader has no chance to find out when the function is called.  The\n   macro applies the necessary magic so that profiling is possible.\n   Rewrite\n\tfoo = (*fctp) (arg1, arg2);\n   into\n        foo = DL_CALL_FCT (fctp, (arg1, arg2));\n*/\n#define DL_CALL_FCT(fctp, args) \\\n  (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args)\n\n__BEGIN_DECLS\n/* This function calls the profiling functions.  */\nextern void _dl_mcount_wrapper_check(void *__selfpc) __THROW;\n\n__END_DECLS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/endian.h",
    "content": "#ifndef _ENDIAN_H\n#error \"Never use <bits/endian.h> directly; include <endian.h> instead.\"\n#endif\n\n/* ARM can be either big or little endian.  */\n#ifdef __ARMEB__\n#define __BYTE_ORDER __BIG_ENDIAN\n#else\n#define __BYTE_ORDER __LITTLE_ENDIAN\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/environments.h",
    "content": "/* Copyright (C) 1999-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _UNISTD_H\n#error \"Never include this file directly.  Use <unistd.h> instead\"\n#endif\n\n#include <bits/wordsize.h>\n\n/* This header should define the following symbols under the described\n   situations.  A value `1' means that the model is always supported,\n   `-1' means it is never supported.  Undefined means it cannot be\n   statically decided.\n\n   _POSIX_V7_ILP32_OFF32   32bit int, long, pointers, and off_t type\n   _POSIX_V7_ILP32_OFFBIG  32bit int, long, and pointers and larger off_t type\n\n   _POSIX_V7_LP64_OFF32\t   64bit long and pointers and 32bit off_t type\n   _POSIX_V7_LPBIG_OFFBIG  64bit long and pointers and large off_t type\n\n   The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,\n   _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,\n   _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were\n   used in previous versions of the Unix standard and are available\n   only for compatibility.\n*/\n\n#if __WORDSIZE == 64\n\n/* We can never provide environments with 32-bit wide pointers.  */\n#define _POSIX_V7_ILP32_OFF32\t-1\n#define _POSIX_V7_ILP32_OFFBIG\t-1\n#define _POSIX_V6_ILP32_OFF32\t-1\n#define _POSIX_V6_ILP32_OFFBIG\t-1\n#define _XBS5_ILP32_OFF32\t-1\n#define _XBS5_ILP32_OFFBIG\t-1\n/* We also have no use (for now) for an environment with bigger pointers\n   and offsets.  */\n#define _POSIX_V7_LPBIG_OFFBIG\t-1\n#define _POSIX_V6_LPBIG_OFFBIG\t-1\n#define _XBS5_LPBIG_OFFBIG\t-1\n\n/* By default we have 64-bit wide `long int', pointers and `off_t'.  */\n#define _POSIX_V7_LP64_OFF64\t1\n#define _POSIX_V6_LP64_OFF64\t1\n#define _XBS5_LP64_OFF64\t1\n\n#else\t\t\t\t/* __WORDSIZE == 32 */\n\n/* By default we have 32-bit wide `int', `long int', pointers and `off_t'\n   and all platforms support LFS.  */\n#define _POSIX_V7_ILP32_OFF32\t1\n#define _POSIX_V7_ILP32_OFFBIG\t1\n#define _POSIX_V6_ILP32_OFF32\t1\n#define _POSIX_V6_ILP32_OFFBIG\t1\n#define _XBS5_ILP32_OFF32\t1\n#define _XBS5_ILP32_OFFBIG\t1\n\n/* We optionally provide an environment with the above size but an 64-bit\n   side `off_t'.  Therefore we don't define _POSIX_V7_ILP32_OFFBIG.  */\n\n/* We can never provide environments with 64-bit wide pointers.  */\n#define _POSIX_V7_LP64_OFF64\t-1\n#define _POSIX_V7_LPBIG_OFFBIG\t-1\n#define _POSIX_V6_LP64_OFF64\t-1\n#define _POSIX_V6_LPBIG_OFFBIG\t-1\n#define _XBS5_LP64_OFF64\t-1\n#define _XBS5_LPBIG_OFFBIG\t-1\n\n/* CFLAGS.  */\n#define __ILP32_OFFBIG_CFLAGS   \"-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64\"\n\n#endif\t\t\t\t/* __WORDSIZE == 32 */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/errno.h",
    "content": "/* Error constants.  Linux specific version.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifdef _ERRNO_H\n\n#undef EDOM\n#undef EILSEQ\n#undef ERANGE\n#include <linux/errno.h>\n\n/* Linux has no ENOTSUP error code.  */\n#define ENOTSUP EOPNOTSUPP\n\n/* Older Linux versions also had no ECANCELED error code.  */\n#ifndef ECANCELED\n#define ECANCELED\t125\n#endif\n\n/* Support for error codes to support robust mutexes was added later, too.  */\n#ifndef EOWNERDEAD\n#define EOWNERDEAD\t\t130\n#define ENOTRECOVERABLE\t131\n#endif\n\n#ifndef ERFKILL\n#define ERFKILL\t\t132\n#endif\n\n#ifndef EHWPOISON\n#define EHWPOISON\t\t133\n#endif\n\n#ifndef __ASSEMBLER__\n/* Function to get address of global `errno' variable.  */\nextern int *__errno_location(void)\n__THROW __attribute__ ((__const__));\n\n#if !defined _LIBC || defined _LIBC_REENTRANT\n/* When using threads, errno is a per-thread value.  */\n#define errno (*__errno_location ())\n#endif\n#endif\t\t\t\t/* !__ASSEMBLER__ */\n#endif\t\t\t\t/* _ERRNO_H */\n\n#if !defined _ERRNO_H && defined __need_Emath\n/* This is ugly but the kernel header is not clean enough.  We must\n   define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is\n   defined.  */\n#define EDOM\t33\t\t/* Math argument out of domain of function.  */\n#define EILSEQ\t84\t\t/* Illegal byte sequence.  */\n#define ERANGE\t34\t\t/* Math result not representable.  */\n#endif\t\t\t\t/* !_ERRNO_H && __need_Emath */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/fcntl-linux.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux.\n   Copyright (C) 2001-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FCNTL_H\n#error \"Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead.\"\n#endif\n\n/* This file contains shared definitions between Linux architectures\n   and is included by <bits/fcntl.h> to declare them.  The various\n   #ifndef cases allow the architecture specific file to define those\n   values with different values.\n\n   A minimal <bits/fcntl.h> contains just:\n\n   struct flock {...}\n   #ifdef __USE_LARGEFILE64\n   struct flock64 {...}\n   #endif\n   #include <bits/fcntl-linux.h>\n*/\n\n#ifdef __USE_GNU\n#include <bits/uio.h>\n#endif\n\n/* open/fcntl.  */\n#define O_ACCMODE\t   0003\n#define O_RDONLY\t     00\n#define O_WRONLY\t     01\n#define O_RDWR\t\t     02\n#ifndef O_CREAT\n#define O_CREAT\t   0100\t\t/* Not fcntl.  */\n#endif\n#ifndef O_EXCL\n#define O_EXCL\t\t   0200\t/* Not fcntl.  */\n#endif\n#ifndef O_NOCTTY\n#define O_NOCTTY\t   0400\t/* Not fcntl.  */\n#endif\n#ifndef O_TRUNC\n#define O_TRUNC\t  01000\t\t/* Not fcntl.  */\n#endif\n#ifndef O_APPEND\n#define O_APPEND\t  02000\n#endif\n#ifndef O_NONBLOCK\n#define O_NONBLOCK\t  04000\n#endif\n#ifndef O_NDELAY\n#define O_NDELAY\tO_NONBLOCK\n#endif\n#ifndef O_SYNC\n#define O_SYNC\t       04010000\n#endif\n#define O_FSYNC\t\tO_SYNC\n#ifndef O_ASYNC\n#define O_ASYNC\t 020000\n#endif\n#ifndef __O_LARGEFILE\n#define __O_LARGEFILE\t0100000\n#endif\n\n#ifndef __O_DIRECTORY\n#define __O_DIRECTORY  0200000\n#endif\n#ifndef __O_NOFOLLOW\n#define __O_NOFOLLOW\t0400000\n#endif\n#ifndef __O_CLOEXEC\n#define __O_CLOEXEC   02000000\n#endif\n#ifndef __O_DIRECT\n#define __O_DIRECT\t 040000\n#endif\n#ifndef __O_NOATIME\n#define __O_NOATIME   01000000\n#endif\n#ifndef __O_PATH\n#define __O_PATH     010000000\n#endif\n#ifndef __O_DSYNC\n#define __O_DSYNC\t 010000\n#endif\n#ifndef __O_TMPFILE\n#define __O_TMPFILE   (020000000 | __O_DIRECTORY)\n#endif\n\n#ifndef F_GETLK\n#ifndef __USE_FILE_OFFSET64\n#define F_GETLK\t5\t\t/* Get record locking info.  */\n#define F_SETLK\t6\t\t/* Set record locking info (non-blocking).  */\n#define F_SETLKW\t7\t/* Set record locking info (blocking).  */\n#else\n#define F_GETLK\tF_GETLK64\t/* Get record locking info.  */\n#define F_SETLK\tF_SETLK64\t/* Set record locking info (non-blocking). */\n#define F_SETLKW\tF_SETLKW64\t/* Set record locking info (blocking).  */\n#endif\n#endif\n#ifndef F_GETLK64\n#define F_GETLK64\t12\t/* Get record locking info.  */\n#define F_SETLK64\t13\t/* Set record locking info (non-blocking).  */\n#define F_SETLKW64\t14\t/* Set record locking info (blocking).  */\n#endif\n\n/* open file description locks.\n\n   Usually record locks held by a process are released on *any* close and are\n   not inherited across a fork.\n\n   These cmd values will set locks that conflict with process-associated record\n   locks, but are \"owned\" by the opened file description, not the process.\n   This means that they are inherited across fork or clone with CLONE_FILES\n   like BSD (flock) locks, and they are only released automatically when the\n   last reference to the the file description against which they were acquired\n   is put. */\n#ifdef __USE_GNU\n#define F_OFD_GETLK\t36\n#define F_OFD_SETLK\t37\n#define F_OFD_SETLKW\t38\n#endif\n\n#ifdef __USE_LARGEFILE64\n#define O_LARGEFILE __O_LARGEFILE\n#endif\n\n#ifdef __USE_XOPEN2K8\n#define O_DIRECTORY\t__O_DIRECTORY\t/* Must be a directory.  */\n#define O_NOFOLLOW\t__O_NOFOLLOW\t/* Do not follow links.  */\n#define O_CLOEXEC\t__O_CLOEXEC\t/* Set close_on_exec.  */\n#endif\n\n#ifdef __USE_GNU\n#define O_DIRECT\t__O_DIRECT\t/* Direct disk access.  */\n#define O_NOATIME\t__O_NOATIME\t/* Do not set atime.  */\n#define O_PATH\t\t__O_PATH\t/* Resolve pathname but do not open file.  */\n#define O_TMPFILE\t__O_TMPFILE\t/* Atomically create nameless file.  */\n#endif\n\n/* For now, Linux has no separate synchronicitiy options for read\n   operations.  We define O_RSYNC therefore as the same as O_SYNC\n   since this is a superset.  */\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n#define O_DSYNC\t__O_DSYNC\t/* Synchronize data.  */\n#if defined __O_RSYNC\n#define O_RSYNC\t__O_RSYNC\t/* Synchronize read operations.  */\n#else\n#define O_RSYNC\tO_SYNC\t\t/* Synchronize read operations.  */\n#endif\n#endif\n\n/* Values for the second argument to `fcntl'.  */\n#define F_DUPFD\t\t0\t/* Duplicate file descriptor.  */\n#define F_GETFD\t\t1\t/* Get file descriptor flags.  */\n#define F_SETFD\t\t2\t/* Set file descriptor flags.  */\n#define F_GETFL\t\t3\t/* Get file status flags.  */\n#define F_SETFL\t\t4\t/* Set file status flags.  */\n\n#ifndef __F_SETOWN\n#define __F_SETOWN\t8\n#define __F_GETOWN\t9\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n#define F_SETOWN\t__F_SETOWN\t/* Get owner (process receiving SIGIO).  */\n#define F_GETOWN\t__F_GETOWN\t/* Set owner (process receiving SIGIO).  */\n#endif\n\n#ifndef __F_SETSIG\n#define __F_SETSIG\t10\t/* Set number of signal to be sent.  */\n#define __F_GETSIG\t11\t/* Get number of signal to be sent.  */\n#endif\n#ifndef __F_SETOWN_EX\n#define __F_SETOWN_EX\t15\t/* Get owner (thread receiving SIGIO).  */\n#define __F_GETOWN_EX\t16\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n#define F_SETSIG\t__F_SETSIG\t/* Set number of signal to be sent.  */\n#define F_GETSIG\t__F_GETSIG\t/* Get number of signal to be sent.  */\n#define F_SETOWN_EX\t__F_SETOWN_EX\t/* Get owner (thread receiving SIGIO).  */\n#define F_GETOWN_EX\t__F_GETOWN_EX\t/* Set owner (thread receiving SIGIO).  */\n#endif\n\n#ifdef __USE_GNU\n#define F_SETLEASE\t1024\t/* Set a lease.  */\n#define F_GETLEASE\t1025\t/* Enquire what lease is active.  */\n#define F_NOTIFY\t1026\t/* Request notifications on a directory.  */\n#define F_SETPIPE_SZ\t1031\t/* Set pipe page size array.  */\n#define F_GETPIPE_SZ\t1032\t/* Set pipe page size array.  */\n#endif\n#ifdef __USE_XOPEN2K8\n#define F_DUPFD_CLOEXEC 1030\t/* Duplicate file descriptor with\n\t\t\t\t   close-on-exit set.  */\n#endif\n\n/* For F_[GET|SET]FD.  */\n#define FD_CLOEXEC\t1\t/* Actually anything with low bit set goes */\n\n#ifndef F_RDLCK\n/* For posix fcntl() and `l_type' field of a `struct flock' for lockf().  */\n#define F_RDLCK\t\t0\t/* Read lock.  */\n#define F_WRLCK\t\t1\t/* Write lock.  */\n#define F_UNLCK\t\t2\t/* Remove lock.  */\n#endif\n\n/* For old implementation of BSD flock.  */\n#ifndef F_EXLCK\n#define F_EXLCK\t\t4\t/* or 3 */\n#define F_SHLCK\t\t8\t/* or 4 */\n#endif\n\n#ifdef __USE_MISC\n/* Operations for BSD flock, also used by the kernel implementation.  */\n#define LOCK_SH\t1\t\t/* Shared lock.  */\n#define LOCK_EX\t2\t\t/* Exclusive lock.  */\n#define LOCK_NB\t4\t\t/* Or'd with one of the above to prevent\n\t\t\t\t   blocking.  */\n#define LOCK_UN\t8\t\t/* Remove lock.  */\n#endif\n\n#ifdef __USE_GNU\n#define LOCK_MAND\t32\t/* This is a mandatory flock:   */\n#define LOCK_READ\t64\t/* ... which allows concurrent read operations.  */\n#define LOCK_WRITE\t128\t/* ... which allows concurrent write operations.  */\n#define LOCK_RW\t192\t\t/* ... Which allows concurrent read & write operations.  */\n#endif\n\n#ifdef __USE_GNU\n/* Types of directory notifications that may be requested with F_NOTIFY.  */\n#define DN_ACCESS\t0x00000001\t/* File accessed.  */\n#define DN_MODIFY\t0x00000002\t/* File modified.  */\n#define DN_CREATE\t0x00000004\t/* File created.  */\n#define DN_DELETE\t0x00000008\t/* File removed.  */\n#define DN_RENAME\t0x00000010\t/* File renamed.  */\n#define DN_ATTRIB\t0x00000020\t/* File changed attributes.  */\n#define DN_MULTISHOT\t0x80000000\t/* Don't remove notifier.  */\n#endif\n\n#ifdef __USE_GNU\n/* Owner types.  */\nenum __pid_type {\n\tF_OWNER_TID = 0,\t/* Kernel thread.  */\n\tF_OWNER_PID,\t\t/* Process.  */\n\tF_OWNER_PGRP,\t\t/* Process group.  */\n\tF_OWNER_GID = F_OWNER_PGRP\t/* Alternative, obsolete name.  */\n};\n\n/* Structure to use with F_GETOWN_EX and F_SETOWN_EX.  */\nstruct f_owner_ex {\n\tenum __pid_type type;\t/* Owner type of ID.  */\n\t__pid_t pid;\t\t/* ID of owner.  */\n};\n#endif\n\n/* Define some more compatibility macros to be backward compatible with\n   BSD systems which did not managed to hide these kernel macros.  */\n#ifdef\t__USE_MISC\n#define FAPPEND\tO_APPEND\n#define FFSYNC\t\tO_FSYNC\n#define FASYNC\t\tO_ASYNC\n#define FNONBLOCK\tO_NONBLOCK\n#define FNDELAY\tO_NDELAY\n#endif\t\t\t\t/* Use misc.  */\n\n#ifndef __POSIX_FADV_DONTNEED\n#define __POSIX_FADV_DONTNEED\t4\n#define __POSIX_FADV_NOREUSE\t5\n#endif\n/* Advise to `posix_fadvise'.  */\n#ifdef __USE_XOPEN2K\n#define POSIX_FADV_NORMAL\t0\t/* No further special treatment.  */\n#define POSIX_FADV_RANDOM\t1\t/* Expect random page references.  */\n#define POSIX_FADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n#define POSIX_FADV_WILLNEED\t3\t/* Will need these pages.  */\n#define POSIX_FADV_DONTNEED\t__POSIX_FADV_DONTNEED\t/* Don't need these pages.  */\n#define POSIX_FADV_NOREUSE\t__POSIX_FADV_NOREUSE\t/* Data will be accessed once.  */\n#endif\n\n#ifdef __USE_GNU\n/* Flags for SYNC_FILE_RANGE.  */\n#define SYNC_FILE_RANGE_WAIT_BEFORE\t1\t/* Wait upon writeout of all pages\n\t\t\t\t\t\t   in the range before performing the\n\t\t\t\t\t\t   write.  */\n#define SYNC_FILE_RANGE_WRITE\t\t2\t/* Initiate writeout of all those\n\t\t\t\t\t\t   dirty pages in the range which are\n\t\t\t\t\t\t   not presently under writeback.  */\n#define SYNC_FILE_RANGE_WAIT_AFTER\t4\t/* Wait upon writeout of all pages in\n\t\t\t\t\t\t   the range after performing the\n\t\t\t\t\t\t   write.  */\n\n/* Flags for SPLICE and VMSPLICE.  */\n#define SPLICE_F_MOVE\t\t1\t/* Move pages instead of copying.  */\n#define SPLICE_F_NONBLOCK\t2\t/* Don't block on the pipe splicing\n\t\t\t\t\t   (but we may still block on the fd\n\t\t\t\t\t   we splice from/to).  */\n#define SPLICE_F_MORE\t\t4\t/* Expect more data.  */\n#define SPLICE_F_GIFT\t\t8\t/* Pages passed in are a gift.  */\n\n/* Flags for fallocate.  */\n#define FALLOC_FL_KEEP_SIZE\t\t1\t/* Don't extend size of file\n\t\t\t\t\t\t   even if offset + len is\n\t\t\t\t\t\t   greater than file size.  */\n#define FALLOC_FL_PUNCH_HOLE\t\t2\t/* Create a hole in the file.  */\n#define FALLOC_FL_COLLAPSE_RANGE\t8\t/* Remove a range of a file\n\t\t\t\t\t\t   without leaving a\n\t\t\t\t\t\t   hole.  */\n#define FALLOC_FL_ZERO_RANGE\t\t16\t/* Convert a range of a\n\t\t\t\t\t\t   file to zeros.  */\n\n/* File handle structure.  */\nstruct file_handle {\n\tunsigned int handle_bytes;\n\tint handle_type;\n\t/* File identifier.  */\n\tunsigned char f_handle[0];\n};\n\n/* Maximum handle size (for now).  */\n#define MAX_HANDLE_SZ\t128\n#endif\n\n/* Values for `*at' functions.  */\n#ifdef __USE_ATFILE\n#define AT_FDCWD\t\t-100\t/* Special value used to indicate\n\t\t\t\t\t   the *at functions should use the\n\t\t\t\t\t   current working directory. */\n#define AT_SYMLINK_NOFOLLOW\t0x100\t/* Do not follow symbolic links.  */\n#define AT_REMOVEDIR\t\t0x200\t/* Remove directory instead of\n\t\t\t\t\t   unlinking file.  */\n#define AT_SYMLINK_FOLLOW\t0x400\t/* Follow symbolic links.  */\n#ifdef __USE_GNU\n#define AT_NO_AUTOMOUNT\t0x800\t/* Suppress terminal automount\n\t\t\t\t   traversal.  */\n#define AT_EMPTY_PATH\t\t0x1000\t/* Allow empty relative pathname.  */\n#endif\n#define AT_EACCESS\t\t0x200\t/* Test access permitted for\n\t\t\t\t\t   effective IDs, not real IDs.  */\n#endif\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Provide kernel hint to read ahead.  */\nextern ssize_t readahead(int __fd, __off64_t __offset, size_t __count) __THROW;\n\n/* Selective file content synch'ing.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int sync_file_range(int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags);\n\n/* Splice address range into a pipe.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags);\n\n/* Splice two files together.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t splice(int __fdin, __off64_t * __offin, int __fdout, __off64_t * __offout, size_t __len, unsigned int __flags);\n\n/* In-kernel implementation of tee for pipe buffers.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern ssize_t tee(int __fdin, int __fdout, size_t __len, unsigned int __flags);\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int fallocate(int __fd, int __mode, __off_t __offset, __off_t __len);\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(fallocate, (int __fd, int __mode, __off64_t __offset, __off64_t __len), fallocate64);\n#else\n#define fallocate fallocate64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int fallocate64(int __fd, int __mode, __off64_t __offset, __off64_t __len);\n#endif\n\n/* Map file name to file handle.  */\nextern int name_to_handle_at(int __dfd, const char *__name, struct file_handle *__handle, int *__mnt_id, int __flags) __THROW;\n\n/* Open file using the file handle.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int open_by_handle_at(int __mountdirfd, struct file_handle *__handle, int __flags);\n\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/fcntl.h",
    "content": "/* O_*, F_*, FD_* bit values for Linux.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FCNTL_H\n#error \"Never use <bits/fcntl.h> directly; include <fcntl.h> instead.\"\n#endif\n\n#define __O_DIRECTORY\t 040000\t/* Must be a directory.  */\n#define __O_NOFOLLOW\t0100000\t/* Do not follow links.  */\n#define __O_DIRECT\t0200000\t/* Direct disk access.  */\n#define __O_LARGEFILE\t0400000\n\nstruct flock {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n#ifndef __USE_FILE_OFFSET64\n\t__off_t l_start;\t/* Offset where the lock begins.  */\n\t__off_t l_len;\t\t/* Size of the locked area; zero means until EOF.  */\n#else\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n#endif\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n\n#ifdef __USE_LARGEFILE64\nstruct flock64 {\n\tshort int l_type;\t/* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK.  */\n\tshort int l_whence;\t/* Where `l_start' is relative to (like `lseek').  */\n\t__off64_t l_start;\t/* Offset where the lock begins.  */\n\t__off64_t l_len;\t/* Size of the locked area; zero means until EOF.  */\n\t__pid_t l_pid;\t\t/* Process holding the lock.  */\n};\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/fcntl-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/huge_val.h",
    "content": "/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never use <bits/huge_val.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity (-HUGE_VAL is negative infinity).  */\n\n#if __GNUC_PREREQ(3,3)\n#define HUGE_VAL\t(__builtin_huge_val())\n#elif __GNUC_PREREQ(2,96)\n#define HUGE_VAL\t(__extension__ 0x1.0p2047)\n#elif defined __GNUC__\n\n#define HUGE_VAL \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; })   \\\n    { __l: 0x7ff0000000000000ULL }).__d)\n\n#else\t\t\t\t/* not GCC */\n\n#include <endian.h>\n\ntypedef union {\n\tunsigned char __c[8];\n\tdouble __d;\n} __huge_val_t;\n\n#if __BYTE_ORDER == __BIG_ENDIAN\n#define __HUGE_VAL_bytes\t{ 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }\n#endif\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define __HUGE_VAL_bytes\t{ 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }\n#endif\n\nstatic __huge_val_t __huge_val = { __HUGE_VAL_bytes };\n\n#define HUGE_VAL\t(__huge_val.__d)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/huge_valf.h",
    "content": "/* `HUGE_VALF' constant for IEEE 754 machines (where it is infinity).\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never use <bits/huge_valf.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity (-HUGE_VAL is negative infinity).  */\n\n#if __GNUC_PREREQ(3,3)\n#define HUGE_VALF\t(__builtin_huge_valf())\n#elif __GNUC_PREREQ(2,96)\n#define HUGE_VALF\t(__extension__ 0x1.0p255f)\n#elif defined __GNUC__\n\n#define HUGE_VALF \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; })    \\\n    { __l: 0x7f800000UL }).__d)\n\n#else\t\t\t\t/* not GCC */\n\ntypedef union {\n\tunsigned char __c[4];\n\tfloat __f;\n} __huge_valf_t;\n\n#if __BYTE_ORDER == __BIG_ENDIAN\n#define __HUGE_VALF_bytes\t{ 0x7f, 0x80, 0, 0 }\n#endif\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define __HUGE_VALF_bytes\t{ 0, 0, 0x80, 0x7f }\n#endif\n\nstatic __huge_valf_t __huge_valf = { __HUGE_VALF_bytes };\n\n#define HUGE_VALF\t(__huge_valf.__f)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/huge_vall.h",
    "content": "/* Default `HUGE_VALL' constant.\n   Used by <stdlib.h> and <math.h> functions for overflow.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never use <bits/huge_vall.h> directly; include <math.h> instead.\"\n#endif\n\n#if __GNUC_PREREQ(3,3)\n#define HUGE_VALL\t(__builtin_huge_vall())\n#else\n#define HUGE_VALL\t((long double) HUGE_VAL)\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/in.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Linux version.  */\n\n#ifndef _NETINET_IN_H\n#error \"Never use <bits/in.h> directly; include <netinet/in.h> instead.\"\n#endif\n\n/* If the application has already included linux/in6.h from a linux-based\n   kernel then we will not define the IPv6 IPPROTO_* defines, in6_addr (nor the\n   defines), sockaddr_in6, or ipv6_mreq. Same for in6_ptkinfo or ip6_mtuinfo\n   in linux/ipv6.h. The ABI used by the linux-kernel and glibc match exactly.\n   Neither the linux kernel nor glibc should break this ABI without coordination.\n   In upstream kernel 56c176c9 the _UAPI prefix was stripped so we need to check\n   for _LINUX_IN6_H and _IPV6_H now, and keep checking the old versions for\n   maximum backwards compatibility.  */\n#if defined _UAPI_LINUX_IN6_H \\\n    || defined _UAPI_IPV6_H \\\n    || defined _LINUX_IN6_H \\\n    || defined _IPV6_H\n/* This is not quite the same API since the kernel always defines s6_addr16 and\n   s6_addr32. This is not a violation of POSIX since POSIX says \"at least the\n   following member\" and that holds true.  */\n#define __USE_KERNEL_IPV6_DEFS 1\n#else\n#define __USE_KERNEL_IPV6_DEFS 0\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IP level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define        IP_OPTIONS      4\t/* ip_opts; IP per-packet options.  */\n#define        IP_HDRINCL      3\t/* int; Header is included with data.  */\n#define        IP_TOS          1\t/* int; IP type of service and precedence.  */\n#define        IP_TTL          2\t/* int; IP time to live.  */\n#define        IP_RECVOPTS     6\t/* bool; Receive all IP options w/datagram.  */\n/* For BSD compatibility.  */\n#define        IP_RECVRETOPTS  IP_RETOPTS\t/* bool; Receive IP options for response.  */\n#define        IP_RETOPTS      7\t/* ip_opts; Set/get IP per-packet options.  */\n#define IP_MULTICAST_IF 32\t/* in_addr; set/get IP multicast i/f */\n#define IP_MULTICAST_TTL 33\t/* u_char; set/get IP multicast ttl */\n#define IP_MULTICAST_LOOP 34\t/* i_char; set/get IP multicast loopback */\n#define IP_ADD_MEMBERSHIP 35\t/* ip_mreq; add an IP group membership */\n#define IP_DROP_MEMBERSHIP 36\t/* ip_mreq; drop an IP group membership */\n#define IP_UNBLOCK_SOURCE 37\t/* ip_mreq_source: unblock data from source */\n#define IP_BLOCK_SOURCE 38\t/* ip_mreq_source: block data from source */\n#define IP_ADD_SOURCE_MEMBERSHIP 39\t/* ip_mreq_source: join source group */\n#define IP_DROP_SOURCE_MEMBERSHIP 40\t/* ip_mreq_source: leave source group */\n#define IP_MSFILTER 41\n#ifdef __USE_MISC\n#define MCAST_JOIN_GROUP 42\t/* group_req: join any-source group */\n#define MCAST_BLOCK_SOURCE 43\t/* group_source_req: block from given group */\n#define MCAST_UNBLOCK_SOURCE 44\t/* group_source_req: unblock from given group */\n#define MCAST_LEAVE_GROUP 45\t/* group_req: leave any-source group */\n#define MCAST_JOIN_SOURCE_GROUP 46\t/* group_source_req: join source-spec gr */\n#define MCAST_LEAVE_SOURCE_GROUP 47\t/* group_source_req: leave source-spec gr */\n#define MCAST_MSFILTER 48\n#define IP_MULTICAST_ALL 49\n#define IP_UNICAST_IF 50\n\n#define MCAST_EXCLUDE   0\n#define MCAST_INCLUDE   1\n#endif\n\n#define IP_ROUTER_ALERT\t5\t/* bool */\n#define IP_PKTINFO\t8\t/* bool */\n#define IP_PKTOPTIONS\t9\n#define IP_PMTUDISC\t10\t/* obsolete name? */\n#define IP_MTU_DISCOVER\t10\t/* int; see below */\n#define IP_RECVERR\t11\t/* bool */\n#define IP_RECVTTL\t12\t/* bool */\n#define IP_RECVTOS\t13\t/* bool */\n#define IP_MTU\t\t14\t/* int */\n#define IP_FREEBIND\t15\n#define IP_IPSEC_POLICY 16\n#define IP_XFRM_POLICY\t17\n#define IP_PASSSEC\t18\n#define IP_TRANSPARENT\t19\n#define IP_MULTICAST_ALL 49\t/* bool */\n\n/* TProxy original addresses */\n#define IP_ORIGDSTADDR       20\n#define IP_RECVORIGDSTADDR   IP_ORIGDSTADDR\n\n#define IP_MINTTL       21\n#define IP_NODEFRAG     22\n#define IP_CHECKSUM     23\n#define IP_BIND_ADDRESS_NO_PORT 24\n\n/* IP_MTU_DISCOVER arguments.  */\n#define IP_PMTUDISC_DONT   0\t/* Never send DF frames.  */\n#define IP_PMTUDISC_WANT   1\t/* Use per route hints.  */\n#define IP_PMTUDISC_DO     2\t/* Always DF.  */\n#define IP_PMTUDISC_PROBE  3\t/* Ignore dst pmtu.  */\n/* Always use interface mtu (ignores dst pmtu) but don't set DF flag.\n   Also incoming ICMP frag_needed notifications will be ignored on\n   this socket to prevent accepting spoofed ones.  */\n#define IP_PMTUDISC_INTERFACE           4\n/* Like IP_PMTUDISC_INTERFACE but allow packets to be fragmented.  */\n#define IP_PMTUDISC_OMIT\t\t5\n\n#define IP_MULTICAST_IF\t\t\t32\n#define IP_MULTICAST_TTL \t\t33\n#define IP_MULTICAST_LOOP \t\t34\n#define IP_ADD_MEMBERSHIP\t\t35\n#define IP_DROP_MEMBERSHIP\t\t36\n#define IP_UNBLOCK_SOURCE\t\t37\n#define IP_BLOCK_SOURCE\t\t\t38\n#define IP_ADD_SOURCE_MEMBERSHIP\t39\n#define IP_DROP_SOURCE_MEMBERSHIP\t40\n#define IP_MSFILTER\t\t\t41\n#define IP_MULTICAST_ALL\t\t49\n#define IP_UNICAST_IF\t\t\t50\n\n/* To select the IP level.  */\n#define SOL_IP\t0\n\n#define IP_DEFAULT_MULTICAST_TTL        1\n#define IP_DEFAULT_MULTICAST_LOOP       1\n#define IP_MAX_MEMBERSHIPS              20\n\n#ifdef __USE_MISC\n/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS.\n   The `ip_dst' field is used for the first-hop gateway when using a\n   source route (this gets put into the header proper).  */\nstruct ip_opts {\n\tstruct in_addr ip_dst;\t/* First hop; zero without source route.  */\n\tchar ip_opts[40];\t/* Actually variable in size.  */\n};\n\n/* Like `struct ip_mreq' but including interface specification by index.  */\nstruct ip_mreqn {\n\tstruct in_addr imr_multiaddr;\t/* IP multicast address of group */\n\tstruct in_addr imr_address;\t/* local IP address of interface */\n\tint imr_ifindex;\t/* Interface index */\n};\n\n/* Structure used for IP_PKTINFO.  */\nstruct in_pktinfo {\n\tint ipi_ifindex;\t/* Interface index  */\n\tstruct in_addr ipi_spec_dst;\t/* Routing destination address  */\n\tstruct in_addr ipi_addr;\t/* Header destination address  */\n};\n#endif\n\n/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level.\n   The first word in the comment at the right is the data type used;\n   \"bool\" means a boolean value stored in an `int'.  */\n#define IPV6_ADDRFORM\t\t1\n#define IPV6_2292PKTINFO\t2\n#define IPV6_2292HOPOPTS\t3\n#define IPV6_2292DSTOPTS\t4\n#define IPV6_2292RTHDR\t\t5\n#define IPV6_2292PKTOPTIONS\t6\n#define IPV6_CHECKSUM\t\t7\n#define IPV6_2292HOPLIMIT\t8\n\n#define SCM_SRCRT\t\tIPV6_RXSRCRT\n\n#define IPV6_NEXTHOP\t\t9\n#define IPV6_AUTHHDR\t\t10\n#define IPV6_UNICAST_HOPS\t16\n#define IPV6_MULTICAST_IF\t17\n#define IPV6_MULTICAST_HOPS\t18\n#define IPV6_MULTICAST_LOOP\t19\n#define IPV6_JOIN_GROUP\t\t20\n#define IPV6_LEAVE_GROUP\t21\n#define IPV6_ROUTER_ALERT\t22\n#define IPV6_MTU_DISCOVER\t23\n#define IPV6_MTU\t\t24\n#define IPV6_RECVERR\t\t25\n#define IPV6_V6ONLY\t\t26\n#define IPV6_JOIN_ANYCAST\t27\n#define IPV6_LEAVE_ANYCAST\t28\n#define IPV6_IPSEC_POLICY\t34\n#define IPV6_XFRM_POLICY\t35\n#define IPV6_HDRINCL\t\t36\n\n/* Advanced API (RFC3542) (1).  */\n#define IPV6_RECVPKTINFO\t49\n#define IPV6_PKTINFO\t\t50\n#define IPV6_RECVHOPLIMIT\t51\n#define IPV6_HOPLIMIT\t\t52\n#define IPV6_RECVHOPOPTS\t53\n#define IPV6_HOPOPTS\t\t54\n#define IPV6_RTHDRDSTOPTS\t55\n#define IPV6_RECVRTHDR\t\t56\n#define IPV6_RTHDR\t\t57\n#define IPV6_RECVDSTOPTS\t58\n#define IPV6_DSTOPTS\t\t59\n#define IPV6_RECVPATHMTU\t60\n#define IPV6_PATHMTU\t\t61\n#define IPV6_DONTFRAG\t\t62\n\n/* Advanced API (RFC3542) (2).  */\n#define IPV6_RECVTCLASS\t\t66\n#define IPV6_TCLASS\t\t67\n\n/* Obsolete synonyms for the above.  */\n#if !__USE_KERNEL_IPV6_DEFS\n#define IPV6_ADD_MEMBERSHIP\tIPV6_JOIN_GROUP\n#define IPV6_DROP_MEMBERSHIP\tIPV6_LEAVE_GROUP\n#endif\n#define IPV6_RXHOPOPTS\t\tIPV6_HOPOPTS\n#define IPV6_RXDSTOPTS\t\tIPV6_DSTOPTS\n\n/* IPV6_MTU_DISCOVER values.  */\n#define IPV6_PMTUDISC_DONT\t0\t/* Never send DF frames.  */\n#define IPV6_PMTUDISC_WANT\t1\t/* Use per route hints.  */\n#define IPV6_PMTUDISC_DO\t2\t/* Always DF.  */\n#define IPV6_PMTUDISC_PROBE\t3\t/* Ignore dst pmtu.  */\n#define IPV6_PMTUDISC_INTERFACE\t4\t/* See IP_PMTUDISC_INTERFACE.  */\n#define IPV6_PMTUDISC_OMIT\t5\t/* See IP_PMTUDISC_OMIT.  */\n\n/* Socket level values for IPv6.  */\n#define SOL_IPV6        41\n#define SOL_ICMPV6      58\n\n/* Routing header options for IPv6.  */\n#define IPV6_RTHDR_LOOSE\t0\t/* Hop doesn't need to be neighbour. */\n#define IPV6_RTHDR_STRICT\t1\t/* Hop must be a neighbour.  */\n\n#define IPV6_RTHDR_TYPE_0\t0\t/* IPv6 Routing header type 0.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/inf.h",
    "content": "/* `INFINITY' constant for IEEE 754 machines.\n   Copyright (C) 2004-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never use <bits/inf.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE positive infinity.  */\n\n#if __GNUC_PREREQ(3,3)\n#define INFINITY\t(__builtin_inff())\n#else\n#define INFINITY\tHUGE_VALF\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/ioctl-types.h",
    "content": "/* Structure types for pre-termios terminal ioctls.  Linux version.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n#error \"Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Get definition of constants for use with `ioctl'.  */\n#include <asm/ioctls.h>\n\nstruct winsize {\n\tunsigned short int ws_row;\n\tunsigned short int ws_col;\n\tunsigned short int ws_xpixel;\n\tunsigned short int ws_ypixel;\n};\n\n#define NCC 8\nstruct termio {\n\tunsigned short int c_iflag;\t/* input mode flags */\n\tunsigned short int c_oflag;\t/* output mode flags */\n\tunsigned short int c_cflag;\t/* control mode flags */\n\tunsigned short int c_lflag;\t/* local mode flags */\n\tunsigned char c_line;\t/* line discipline */\n\tunsigned char c_cc[NCC];\t/* control characters */\n};\n\n/* modem lines */\n#define TIOCM_LE\t0x001\n#define TIOCM_DTR\t0x002\n#define TIOCM_RTS\t0x004\n#define TIOCM_ST\t0x008\n#define TIOCM_SR\t0x010\n#define TIOCM_CTS\t0x020\n#define TIOCM_CAR\t0x040\n#define TIOCM_RNG\t0x080\n#define TIOCM_DSR\t0x100\n#define TIOCM_CD\tTIOCM_CAR\n#define TIOCM_RI\tTIOCM_RNG\n\n/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */\n\n/* line disciplines */\n#define N_TTY\t\t0\n#define N_SLIP\t\t1\n#define N_MOUSE\t\t2\n#define N_PPP\t\t3\n#define N_STRIP\t\t4\n#define N_AX25\t\t5\n#define N_X25\t\t6\t/* X.25 async  */\n#define N_6PACK\t\t7\n#define N_MASC\t\t8\t/* Mobitex module  */\n#define N_R3964\t\t9\t/* Simatic R3964 module  */\n#define N_PROFIBUS_FDL\t10\t/* Profibus  */\n#define N_IRDA\t\t11\t/* Linux IR  */\n#define N_SMSBLOCK\t12\t/* SMS block mode  */\n#define N_HDLC\t\t13\t/* synchronous HDLC  */\n#define N_SYNC_PPP\t14\t/* synchronous PPP  */\n#define\tN_HCI\t\t15\t/* Bluetooth HCI UART  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/ioctls.h",
    "content": "/* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_IOCTL_H\n#error \"Never use <bits/ioctls.h> directly; include <sys/ioctl.h> instead.\"\n#endif\n\n/* Use the definitions from the kernel header files.  */\n#include <asm/ioctls.h>\n\n/* Routing table calls.  */\n#define SIOCADDRT\t0x890B\t/* add routing table entry      */\n#define SIOCDELRT\t0x890C\t/* delete routing table entry   */\n#define SIOCRTMSG\t0x890D\t/* call to routing system       */\n\n/* Socket configuration controls. */\n#define SIOCGIFNAME\t0x8910\t/* get iface name               */\n#define SIOCSIFLINK\t0x8911\t/* set iface channel            */\n#define SIOCGIFCONF\t0x8912\t/* get iface list               */\n#define SIOCGIFFLAGS\t0x8913\t/* get flags                    */\n#define SIOCSIFFLAGS\t0x8914\t/* set flags                    */\n#define SIOCGIFADDR\t0x8915\t/* get PA address               */\n#define SIOCSIFADDR\t0x8916\t/* set PA address               */\n#define SIOCGIFDSTADDR\t0x8917\t/* get remote PA address        */\n#define SIOCSIFDSTADDR\t0x8918\t/* set remote PA address        */\n#define SIOCGIFBRDADDR\t0x8919\t/* get broadcast PA address     */\n#define SIOCSIFBRDADDR\t0x891a\t/* set broadcast PA address     */\n#define SIOCGIFNETMASK\t0x891b\t/* get network PA mask          */\n#define SIOCSIFNETMASK\t0x891c\t/* set network PA mask          */\n#define SIOCGIFMETRIC\t0x891d\t/* get metric                   */\n#define SIOCSIFMETRIC\t0x891e\t/* set metric                   */\n#define SIOCGIFMEM\t0x891f\t/* get memory address (BSD)     */\n#define SIOCSIFMEM\t0x8920\t/* set memory address (BSD)     */\n#define SIOCGIFMTU\t0x8921\t/* get MTU size                 */\n#define SIOCSIFMTU\t0x8922\t/* set MTU size                 */\n#define SIOCSIFNAME\t0x8923\t/* set interface name           */\n#define\tSIOCSIFHWADDR\t0x8924\t/* set hardware address         */\n#define SIOCGIFENCAP\t0x8925\t/* get/set encapsulations       */\n#define SIOCSIFENCAP\t0x8926\n#define SIOCGIFHWADDR\t0x8927\t/* Get hardware address         */\n#define SIOCGIFSLAVE\t0x8929\t/* Driver slaving support       */\n#define SIOCSIFSLAVE\t0x8930\n#define SIOCADDMULTI\t0x8931\t/* Multicast address lists      */\n#define SIOCDELMULTI\t0x8932\n#define SIOCGIFINDEX\t0x8933\t/* name -> if_index mapping     */\n#define SIOGIFINDEX\tSIOCGIFINDEX\t/* misprint compatibility :-)   */\n#define SIOCSIFPFLAGS\t0x8934\t/* set/get extended flags set   */\n#define SIOCGIFPFLAGS\t0x8935\n#define SIOCDIFADDR\t0x8936\t/* delete PA address            */\n#define\tSIOCSIFHWBROADCAST\t0x8937\t/* set hardware broadcast addr  */\n#define SIOCGIFCOUNT\t0x8938\t/* get number of devices */\n\n#define SIOCGIFBR\t0x8940\t/* Bridging support             */\n#define SIOCSIFBR\t0x8941\t/* Set bridging options         */\n\n#define SIOCGIFTXQLEN\t0x8942\t/* Get the tx queue length      */\n#define SIOCSIFTXQLEN\t0x8943\t/* Set the tx queue length      */\n\n/* ARP cache control calls. */\n\t\t    /*  0x8950 - 0x8952  * obsolete calls, don't re-use */\n#define SIOCDARP\t0x8953\t/* delete ARP table entry       */\n#define SIOCGARP\t0x8954\t/* get ARP table entry          */\n#define SIOCSARP\t0x8955\t/* set ARP table entry          */\n\n/* RARP cache control calls. */\n#define SIOCDRARP\t0x8960\t/* delete RARP table entry      */\n#define SIOCGRARP\t0x8961\t/* get RARP table entry         */\n#define SIOCSRARP\t0x8962\t/* set RARP table entry         */\n\n/* Driver configuration calls */\n\n#define SIOCGIFMAP\t0x8970\t/* Get device parameters        */\n#define SIOCSIFMAP\t0x8971\t/* Set device parameters        */\n\n/* DLCI configuration calls */\n\n#define SIOCADDDLCI\t0x8980\t/* Create new DLCI device       */\n#define SIOCDELDLCI\t0x8981\t/* Delete DLCI device           */\n\n/* Device private ioctl calls.  */\n\n/* These 16 ioctls are available to devices via the do_ioctl() device\n   vector.  Each device should include this file and redefine these\n   names as their own. Because these are device dependent it is a good\n   idea _NOT_ to issue them to random objects and hope.  */\n\n#define SIOCDEVPRIVATE \t\t0x89F0\t/* to 89FF */\n\n/*\n *\tThese 16 ioctl calls are protocol private\n */\n\n#define SIOCPROTOPRIVATE 0x89E0\t/* to 89EF */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/libm-simd-decl-stubs.h",
    "content": "/* Empty definitions required for __MATHCALL_VEC unfolding in mathcalls.h.\n   Copyright (C) 2014-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never include <bits/libm-simd-decl-stubs.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Needed definitions could be generated with:\n   for func in $(grep __MATHCALL_VEC math/bits/mathcalls.h |\\\n\t\t sed -r \"s|__MATHCALL_VEC.?\\(||; s|,.*||\"); do\n     echo \"#define __DECL_SIMD_${func}\";\n     echo \"#define __DECL_SIMD_${func}f\";\n     echo \"#define __DECL_SIMD_${func}l\";\n   done\n */\n\n#ifndef _BITS_LIBM_SIMD_DECL_STUBS_H\n#define _BITS_LIBM_SIMD_DECL_STUBS_H 1\n\n#define __DECL_SIMD_cos\n#define __DECL_SIMD_cosf\n#define __DECL_SIMD_cosl\n\n#define __DECL_SIMD_sin\n#define __DECL_SIMD_sinf\n#define __DECL_SIMD_sinl\n\n#define __DECL_SIMD_sincos\n#define __DECL_SIMD_sincosf\n#define __DECL_SIMD_sincosl\n\n#define __DECL_SIMD_log\n#define __DECL_SIMD_logf\n#define __DECL_SIMD_logl\n\n#define __DECL_SIMD_exp\n#define __DECL_SIMD_expf\n#define __DECL_SIMD_expl\n\n#define __DECL_SIMD_pow\n#define __DECL_SIMD_powf\n#define __DECL_SIMD_powl\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/local_lim.h",
    "content": "/* Minimum guaranteed maximum values for system limits.  Linux version.\n   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n/* The kernel header pollutes the namespace with the NR_OPEN symbol\n   and defines LINK_MAX although filesystems have different maxima.  A\n   similar thing is true for OPEN_MAX: the limit can be changed at\n   runtime and therefore the macro must not be defined.  Remove this\n   after including the header if necessary.  */\n#ifndef NR_OPEN\n#define __undef_NR_OPEN\n#endif\n#ifndef LINK_MAX\n#define __undef_LINK_MAX\n#endif\n#ifndef OPEN_MAX\n#define __undef_OPEN_MAX\n#endif\n#ifndef ARG_MAX\n#define __undef_ARG_MAX\n#endif\n\n/* The kernel sources contain a file with all the needed information.  */\n#include <linux/limits.h>\n\n/* Have to remove NR_OPEN?  */\n#ifdef __undef_NR_OPEN\n#undef NR_OPEN\n#undef __undef_NR_OPEN\n#endif\n/* Have to remove LINK_MAX?  */\n#ifdef __undef_LINK_MAX\n#undef LINK_MAX\n#undef __undef_LINK_MAX\n#endif\n/* Have to remove OPEN_MAX?  */\n#ifdef __undef_OPEN_MAX\n#undef OPEN_MAX\n#undef __undef_OPEN_MAX\n#endif\n/* Have to remove ARG_MAX?  */\n#ifdef __undef_ARG_MAX\n#undef ARG_MAX\n#undef __undef_ARG_MAX\n#endif\n\n/* The number of data keys per process.  */\n#define _POSIX_THREAD_KEYS_MAX\t128\n/* This is the value this implementation supports.  */\n#define PTHREAD_KEYS_MAX\t1024\n\n/* Controlling the iterations of destructors for thread-specific data.  */\n#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS\t4\n/* Number of iterations this implementation does.  */\n#define PTHREAD_DESTRUCTOR_ITERATIONS\t_POSIX_THREAD_DESTRUCTOR_ITERATIONS\n\n/* The number of threads per process.  */\n#define _POSIX_THREAD_THREADS_MAX\t64\n/* We have no predefined limit on the number of threads.  */\n#undef PTHREAD_THREADS_MAX\n\n/* Maximum amount by which a process can descrease its asynchronous I/O\n   priority level.  */\n#define AIO_PRIO_DELTA_MAX\t20\n\n/* Minimum size for a thread.  We are free to choose a reasonable value.  */\n#define PTHREAD_STACK_MIN\t16384\n\n/* Maximum number of timer expiration overruns.  */\n#define DELAYTIMER_MAX\t2147483647\n\n/* Maximum tty name length.  */\n#define TTY_NAME_MAX\t\t32\n\n/* Maximum login name length.  This is arbitrary.  */\n#define LOGIN_NAME_MAX\t\t256\n\n/* Maximum host name length.  */\n#define HOST_NAME_MAX\t\t64\n\n/* Maximum message queue priority level.  */\n#define MQ_PRIO_MAX\t\t32768\n\n/* Maximum value the semaphore can have.  */\n#define SEM_VALUE_MAX   (2147483647)\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/locale.h",
    "content": "/* Definition of locale category symbol values.\n   Copyright (C) 2001-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _LOCALE_H && !defined _LANGINFO_H\n#error \"Never use <bits/locale.h> directly; include <locale.h> instead.\"\n#endif\n\n#ifndef _BITS_LOCALE_H\n#define _BITS_LOCALE_H\t1\n\n#define __LC_CTYPE\t\t 0\n#define __LC_NUMERIC\t\t 1\n#define __LC_TIME\t\t 2\n#define __LC_COLLATE\t\t 3\n#define __LC_MONETARY\t\t 4\n#define __LC_MESSAGES\t\t 5\n#define __LC_ALL\t\t 6\n#define __LC_PAPER\t\t 7\n#define __LC_NAME\t\t 8\n#define __LC_ADDRESS\t\t 9\n#define __LC_TELEPHONE\t\t10\n#define __LC_MEASUREMENT\t11\n#define __LC_IDENTIFICATION\t12\n\n#endif\t\t\t\t/* bits/locale.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/math-vector.h",
    "content": "/* Platform-specific SIMD declarations of math functions.\n   Copyright (C) 2014-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License  published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never include <bits/math-vector.h> directly;\\\n include <math.h> instead.\"\n#endif\n\n/* Get default empty definitions required for __MATHCALL_VEC unfolding.\n   Plaform-specific analogue of this header should redefine them with specific\n   SIMD declarations.  */\n#include <bits/libm-simd-decl-stubs.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/mathcalls.h",
    "content": "/* Prototype declarations for math functions; helper file for <math.h>.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* NOTE: Because of the special way this file is used by <math.h>, this\n   file must NOT be protected from multiple inclusion as header files\n   usually are.\n\n   This file provides prototype declarations for the math functions.\n   Most functions are declared using the macro:\n\n   __MATHCALL (NAME,[_r], (ARGS...));\n\n   This means there is a function `NAME' returning `double' and a function\n   `NAMEf' returning `float'.  Each place `_Mdouble_' appears in the\n   prototype, that is actually `double' in the prototype for `NAME' and\n   `float' in the prototype for `NAMEf'.  Reentrant variant functions are\n   called `NAME_r' and `NAMEf_r'.\n\n   Functions returning other types like `int' are declared using the macro:\n\n   __MATHDECL (TYPE, NAME,[_r], (ARGS...));\n\n   This is just like __MATHCALL but for a function returning `TYPE'\n   instead of `_Mdouble_'.  In all of these cases, there is still\n   both a `NAME' and a `NAMEf' that takes `float' arguments.\n\n   Note that there must be no whitespace before the argument passed for\n   NAME, to make token pasting work with -traditional.  */\n\n#ifndef _MATH_H\n#error \"Never include <bits/mathcalls.h> directly; include <math.h> instead.\"\n#endif\n\n/* Trigonometric functions.  */\n\n_Mdouble_BEGIN_NAMESPACE\n/* Arc cosine of X.  */\n__MATHCALL(acos,, (_Mdouble_ __x));\n/* Arc sine of X.  */\n__MATHCALL(asin,, (_Mdouble_ __x));\n/* Arc tangent of X.  */\n__MATHCALL(atan,, (_Mdouble_ __x));\n/* Arc tangent of Y/X.  */\n__MATHCALL(atan2,, (_Mdouble_ __y, _Mdouble_ __x));\n\n/* Cosine of X.  */\n__MATHCALL_VEC(cos,, (_Mdouble_ __x));\n/* Sine of X.  */\n__MATHCALL_VEC(sin,, (_Mdouble_ __x));\n/* Tangent of X.  */\n__MATHCALL(tan,, (_Mdouble_ __x));\n\n/* Hyperbolic functions.  */\n\n/* Hyperbolic cosine of X.  */\n__MATHCALL(cosh,, (_Mdouble_ __x));\n/* Hyperbolic sine of X.  */\n__MATHCALL(sinh,, (_Mdouble_ __x));\n/* Hyperbolic tangent of X.  */\n__MATHCALL(tanh,, (_Mdouble_ __x));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_GNU\n/* Cosine and sine of X.  */\n__MATHDECL_VEC(void, sincos,, (_Mdouble_ __x, _Mdouble_ * __sinx, _Mdouble_ * __cosx));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Hyperbolic arc cosine of X.  */\n __MATHCALL(acosh,, (_Mdouble_ __x));\n/* Hyperbolic arc sine of X.  */\n__MATHCALL(asinh,, (_Mdouble_ __x));\n/* Hyperbolic arc tangent of X.  */\n__MATHCALL(atanh,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Exponential and logarithmic functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Exponential function of X.  */\n __MATHCALL_VEC(exp,, (_Mdouble_ __x));\n\n/* Break VALUE into a normalized fraction and an integral power of 2.  */\n__MATHCALL(frexp,, (_Mdouble_ __x, int *__exponent));\n\n/* X times (two to the EXP power).  */\n__MATHCALL(ldexp,, (_Mdouble_ __x, int __exponent));\n\n/* Natural logarithm of X.  */\n__MATHCALL_VEC(log,, (_Mdouble_ __x));\n\n/* Base-ten logarithm of X.  */\n__MATHCALL(log10,, (_Mdouble_ __x));\n\n/* Break VALUE into integral and fractional parts.  */\n__MATHCALL(modf,, (_Mdouble_ __x, _Mdouble_ * __iptr)) __nonnull((2));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_GNU\n/* A function missing in all standards: compute exponent to base ten.  */\n__MATHCALL(exp10,, (_Mdouble_ __x));\n/* Another name occasionally used.  */\n__MATHCALL(pow10,, (_Mdouble_ __x));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return exp(X) - 1.  */\n__MATHCALL(expm1,, (_Mdouble_ __x));\n\n/* Return log(1 + X).  */\n__MATHCALL(log1p,, (_Mdouble_ __x));\n\n/* Return the base 2 signed integral exponent of X.  */\n__MATHCALL(logb,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Compute base-2 exponential of X.  */\n__MATHCALL(exp2,, (_Mdouble_ __x));\n\n/* Compute base-2 logarithm of X.  */\n__MATHCALL(log2,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Power functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Return X to the Y power.  */\n__MATHCALL_VEC(pow,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the square root of X.  */\n__MATHCALL(sqrt,, (_Mdouble_ __x));\n_Mdouble_END_NAMESPACE\n#if defined __USE_XOPEN || defined __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return `sqrt(X*X + Y*Y)'.  */\n__MATHCALL(hypot,, (_Mdouble_ __x, _Mdouble_ __y));\n__END_NAMESPACE_C99\n#endif\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return the cube root of X.  */\n__MATHCALL(cbrt,, (_Mdouble_ __x));\n__END_NAMESPACE_C99\n#endif\n/* Nearest integer, absolute value, and remainder functions.  */\n    _Mdouble_BEGIN_NAMESPACE\n/* Smallest integral value not less than X.  */\n__MATHCALLX(ceil,, (_Mdouble_ __x), (__const__));\n\n/* Absolute value of X.  */\n__MATHCALLX(fabs,, (_Mdouble_ __x), (__const__));\n\n/* Largest integer not greater than X.  */\n__MATHCALLX(floor,, (_Mdouble_ __x), (__const__));\n\n/* Floating-point modulo remainder of X/Y.  */\n__MATHCALL(fmod,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, __isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return nonzero if VALUE is finite and not NaN.  */\n__MATHDECL_1(int, __finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n_Mdouble_END_NAMESPACE\n#ifdef __USE_MISC\n#if (!defined __cplusplus \\\n      || __cplusplus < 201103L /* isinf conflicts with C++11.  */ \\\n      || __MATH_DECLARING_DOUBLE == 0)\t/* isinff or isinfl don't.  */\n/* Return 0 if VALUE is finite or NaN, +1 if it\n   is +Infinity, -1 if it is -Infinity.  */\n__MATHDECL_1(int, isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));\n#endif\n\n/* Return nonzero if VALUE is finite and not NaN.  */\n__MATHDECL_1(int, finite,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n/* Return the remainder of X/Y.  */\n__MATHCALL(drem,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return the fractional part of X after dividing out `ilogb (X)'.  */\n__MATHCALL(significand,, (_Mdouble_ __x));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return X with its signed changed to Y's.  */\n__MATHCALLX(copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Return representation of qNaN for double type.  */\n__MATHCALLX(nan,, (const char *__tagb), (__const__));\n__END_NAMESPACE_C99\n#endif\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, __isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n#if (!defined __cplusplus \\\n      || __cplusplus < 201103L /* isnan conflicts with C++11.  */ \\\n      || __MATH_DECLARING_DOUBLE == 0)\t/* isnanf or isnanl don't.  */\n/* Return nonzero if VALUE is not a number.  */\n__MATHDECL_1(int, isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));\n#endif\n#endif\n\n#if defined __USE_MISC || (defined __USE_XOPEN && __MATH_DECLARING_DOUBLE)\n/* Bessel functions.  */\n__MATHCALL(j0,, (_Mdouble_));\n__MATHCALL(j1,, (_Mdouble_));\n__MATHCALL(jn,, (int, _Mdouble_));\n__MATHCALL(y0,, (_Mdouble_));\n__MATHCALL(y1,, (_Mdouble_));\n__MATHCALL(yn,, (int, _Mdouble_));\n#endif\n\n#if defined __USE_XOPEN || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Error and gamma functions.  */\n__MATHCALL(erf,, (_Mdouble_));\n__MATHCALL(erfc,, (_Mdouble_));\n__MATHCALL(lgamma,, (_Mdouble_));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* True gamma function.  */\n__MATHCALL(tgamma,, (_Mdouble_));\n__END_NAMESPACE_C99\n#endif\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Obsolete alias for `lgamma'.  */\n__MATHCALL(gamma,, (_Mdouble_));\n#endif\n\n#ifdef __USE_MISC\n/* Reentrant version of lgamma.  This function uses the global variable\n   `signgam'.  The reentrant version instead takes a pointer and stores\n   the value through it.  */\n__MATHCALL(lgamma, _r, (_Mdouble_, int *__signgamp));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Return the integer nearest X in the direction of the\n   prevailing rounding mode.  */\n__MATHCALL(rint,, (_Mdouble_ __x));\n\n/* Return X + epsilon if X < Y, X - epsilon if X > Y.  */\n__MATHCALLX(nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n#if defined __USE_ISOC99 && !defined __LDBL_COMPAT\n__MATHCALLX(nexttoward,, (_Mdouble_ __x, long double __y), (__const__));\n#endif\n\n#ifdef __USE_GNU\n/* Return X - epsilon.  */\n__MATHCALL(nextdown,, (_Mdouble_ __x));\n/* Return X + epsilon.  */\n__MATHCALL(nextup,, (_Mdouble_ __x));\n#endif\n\n/* Return the remainder of integer divison X / Y with infinite precision.  */\n__MATHCALL(remainder,, (_Mdouble_ __x, _Mdouble_ __y));\n\n#ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbn,, (_Mdouble_ __x, int __n));\n#endif\n\n/* Return the binary exponent of X, which must be nonzero.  */\n__MATHDECL(int, ilogb,, (_Mdouble_ __x));\n#endif\n\n#ifdef __USE_ISOC99\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalbln,, (_Mdouble_ __x, long int __n));\n\n/* Round X to integral value in floating-point format using current\n   rounding direction, but do not raise inexact exception.  */\n__MATHCALL(nearbyint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHCALLX(round,, (_Mdouble_ __x), (__const__));\n\n/* Round X to the integral value in floating-point format nearest but\n   not larger in magnitude.  */\n__MATHCALLX(trunc,, (_Mdouble_ __x), (__const__));\n\n/* Compute remainder of X and Y and put in *QUO a value with sign of x/y\n   and magnitude congruent `mod 2^n' to the magnitude of the integral\n   quotient x/y, with n >= 3.  */\n__MATHCALL(remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));\n\n/* Conversion functions.  */\n\n/* Round X to nearest integral value according to current rounding\n   direction.  */\n__MATHDECL(long int, lrint,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llrint,, (_Mdouble_ __x));\n\n/* Round X to nearest integral value, rounding halfway cases away from\n   zero.  */\n__MATHDECL(long int, lround,, (_Mdouble_ __x));\n__extension__ __MATHDECL(long long int, llround,, (_Mdouble_ __x));\n\n/* Return positive difference between X and Y.  */\n__MATHCALL(fdim,, (_Mdouble_ __x, _Mdouble_ __y));\n\n/* Return maximum numeric value from X and Y.  */\n__MATHCALLX(fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Return minimum numeric value from X and Y.  */\n__MATHCALLX(fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));\n\n/* Classify given number.  */\n__MATHDECL_1(int, __fpclassify,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Test for negative number.  */\n__MATHDECL_1(int, __signbit,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n\n/* Multiply-add function computed as a ternary operation.  */\n__MATHCALL(fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Test for signaling NaN.  */\n__MATHDECL_1(int, __issignaling,, (_Mdouble_ __value))\n    __attribute__ ((__const__));\n#endif\n\n#if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \\\n\t\t\t   && __MATH_DECLARING_DOUBLE\t\\\n\t\t\t   && !defined __USE_XOPEN2K8)\n/* Return X times (2 to the Nth power).  */\n__MATHCALL(scalb,, (_Mdouble_ __x, _Mdouble_ __n));\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/mathdef.h",
    "content": "/* Copyright (C) 1999-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _MATH_H && !defined _COMPLEX_H\n#error \"Never use <bits/mathdef.h> directly; include <math.h> instead\"\n#endif\n\n#if defined  __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF\n#define _MATH_H_MATHDEF\t1\n\n/* GCC does not promote `float' values to `double'.  */\ntypedef float float_t;\t\t/* `float' expressions are evaluated as\n\t\t\t\t   `float'.  */\ntypedef double double_t;\t/* `double' expressions are evaluated as\n\t\t\t\t   `double'.  */\n\n/* The values returned by `ilogb' for 0 and NaN respectively.  */\n#define FP_ILOGB0\t(-2147483647)\n#define FP_ILOGBNAN\t(2147483647)\n\n/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l}\n   builtins are supported.  */\n#ifdef __FP_FAST_FMA\n#define FP_FAST_FMA 1\n#endif\n\n#ifdef __FP_FAST_FMAF\n#define FP_FAST_FMAF 1\n#endif\n\n#ifdef __FP_FAST_FMAL\n#define FP_FAST_FMAL 1\n#endif\n\n#endif\t\t\t\t/* ISO C99 */\n\n#ifndef __NO_LONG_DOUBLE_MATH\n/* Signal that we do not really have a `long double'.  This disables the\n   declaration of all the `long double' function variants.  */\n#define __NO_LONG_DOUBLE_MATH\t1\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/mman-linux.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux generic version.\n   Copyright (C) 2001-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n#error \"Never use <bits/mman-linux.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.\n\n   This file is also used by some non-Linux configurations of the\n   GNU C Library, for other systems that use these same bit values.  */\n\n/* Protections are chosen from these bits, OR'd together.  The\n   implementation does not necessarily support PROT_EXEC or PROT_WRITE\n   without PROT_READ.  The only guarantees are that no writing will be\n   allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */\n\n#define PROT_READ\t0x1\t/* Page can be read.  */\n#define PROT_WRITE\t0x2\t/* Page can be written.  */\n#define PROT_EXEC\t0x4\t/* Page can be executed.  */\n#define PROT_NONE\t0x0\t/* Page can not be accessed.  */\n#define PROT_GROWSDOWN\t0x01000000\t/* Extend change to start of\n\t\t\t\t\t   growsdown vma (mprotect only).  */\n#define PROT_GROWSUP\t0x02000000\t/* Extend change to start of\n\t\t\t\t\t   growsup vma (mprotect only).  */\n\n/* Sharing types (must choose one and only one of these).  */\n#define MAP_SHARED\t0x01\t/* Share changes.  */\n#define MAP_PRIVATE\t0x02\t/* Changes are private.  */\n#ifdef __USE_MISC\n#define MAP_TYPE\t0x0f\t/* Mask for type of mapping.  */\n#endif\n\n/* Other flags.  */\n#define MAP_FIXED\t0x10\t/* Interpret addr exactly.  */\n#ifdef __USE_MISC\n#define MAP_FILE\t0\n#ifdef __MAP_ANONYMOUS\n#define MAP_ANONYMOUS\t__MAP_ANONYMOUS\t/* Don't use a file.  */\n#else\n#define MAP_ANONYMOUS\t0x20\t/* Don't use a file.  */\n#endif\n#define MAP_ANON\tMAP_ANONYMOUS\n/* When MAP_HUGETLB is set bits [26:31] encode the log2 of the huge page size.  */\n#define MAP_HUGE_SHIFT\t26\n#define MAP_HUGE_MASK\t0x3f\n#endif\n\n/* Flags to `msync'.  */\n#define MS_ASYNC\t1\t/* Sync memory asynchronously.  */\n#define MS_SYNC\t\t4\t/* Synchronous memory sync.  */\n#define MS_INVALIDATE\t2\t/* Invalidate the caches.  */\n\n/* Flags for `mremap'.  */\n#ifdef __USE_GNU\n#define MREMAP_MAYMOVE\t1\n#define MREMAP_FIXED\t2\n#endif\n\n/* Advice to `madvise'.  */\n#ifdef __USE_MISC\n#define MADV_NORMAL\t  0\t/* No further special treatment.  */\n#define MADV_RANDOM\t  1\t/* Expect random page references.  */\n#define MADV_SEQUENTIAL  2\t/* Expect sequential page references.  */\n#define MADV_WILLNEED\t  3\t/* Will need these pages.  */\n#define MADV_DONTNEED\t  4\t/* Don't need these pages.  */\n#define MADV_FREE\t  8\t/* Free pages only if memory pressure.  */\n#define MADV_REMOVE\t  9\t/* Remove these pages and resources.  */\n#define MADV_DONTFORK\t  10\t/* Do not inherit across fork.  */\n#define MADV_DOFORK\t  11\t/* Do inherit across fork.  */\n#define MADV_MERGEABLE\t  12\t/* KSM may merge identical pages.  */\n#define MADV_UNMERGEABLE 13\t/* KSM may not merge identical pages.  */\n#define MADV_HUGEPAGE\t  14\t/* Worth backing with hugepages.  */\n#define MADV_NOHUGEPAGE  15\t/* Not worth backing with hugepages.  */\n#define MADV_DONTDUMP\t  16\t/* Explicity exclude from the core dump,\n\t\t\t\t   overrides the coredump filter bits.  */\n#define MADV_DODUMP\t  17\t/* Clear the MADV_DONTDUMP flag.  */\n#define MADV_HWPOISON\t  100\t/* Poison a page for testing.  */\n#endif\n\n/* The POSIX people had to invent similar names for the same things.  */\n#ifdef __USE_XOPEN2K\n#define POSIX_MADV_NORMAL\t0\t/* No further special treatment.  */\n#define POSIX_MADV_RANDOM\t1\t/* Expect random page references.  */\n#define POSIX_MADV_SEQUENTIAL\t2\t/* Expect sequential page references.  */\n#define POSIX_MADV_WILLNEED\t3\t/* Will need these pages.  */\n#define POSIX_MADV_DONTNEED\t4\t/* Don't need these pages.  */\n#endif\n\n/* Flags for `mlockall'.  */\n#ifndef MCL_CURRENT\n#define MCL_CURRENT\t1\t/* Lock all currently mapped pages.  */\n#define MCL_FUTURE\t2\t/* Lock all additions to address\n\t\t\t\t   space.  */\n#define MCL_ONFAULT\t4\t/* Lock all pages that are\n\t\t\t\t   faulted in.  */\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/mman.h",
    "content": "/* Definitions for POSIX memory map interface.  Linux/ARM version.\n   Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_MMAN_H\n#error \"Never use <bits/mman.h> directly; include <sys/mman.h> instead.\"\n#endif\n\n/* The following definitions basically come from the kernel headers.\n   But the kernel header is not namespace clean.  */\n\n/* These are Linux-specific.  */\n#ifdef __USE_MISC\n#define MAP_GROWSDOWN\t0x00100\t/* Stack-like segment.  */\n#define MAP_DENYWRITE\t0x00800\t/* ETXTBSY */\n#define MAP_EXECUTABLE\t0x01000\t/* Mark it as an executable.  */\n#define MAP_LOCKED\t0x02000\t/* Lock the mapping.  */\n#define MAP_NORESERVE\t0x04000\t/* Don't check for reservations.  */\n#define MAP_POPULATE\t0x08000\t/* Populate (prefault) pagetables.  */\n#define MAP_NONBLOCK\t0x10000\t/* Do not block on IO.  */\n#define MAP_STACK\t0x20000\t/* Allocation is for a stack.  */\n#define MAP_HUGETLB\t0x40000\t/* Create huge page mapping.  */\n#endif\n\n/* Include generic Linux declarations.  */\n#include <bits/mman-linux.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/nan.h",
    "content": "/* `NAN' constant for IEEE 754 machines.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MATH_H\n#error \"Never use <bits/nan.h> directly; include <math.h> instead.\"\n#endif\n\n/* IEEE Not A Number.  */\n\n#if __GNUC_PREREQ(3,3)\n\n#define NAN\t(__builtin_nanf (\"\"))\n\n#elif defined __GNUC__\n\n#define NAN \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; })  \\\n    { __l: 0x7fc00000UL }).__d)\n\n#else\n\n#include <endian.h>\n\n#if __BYTE_ORDER == __BIG_ENDIAN\n#define __qnan_bytes\t\t{ 0x7f, 0xc0, 0, 0 }\n#endif\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define __qnan_bytes\t\t{ 0, 0, 0xc0, 0x7f }\n#endif\n\nstatic union {\n\tunsigned char __c[4];\n\tfloat __d;\n} __qnan_union __attribute__ ((__unused__)) = {\n__qnan_bytes};\n\n#define NAN\t(__qnan_union.__d)\n\n#endif\t\t\t\t/* GCC.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/netdb.h",
    "content": "/* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _NETDB_H\n#error \"Never include <bits/netdb.h> directly; use <netdb.h> instead.\"\n#endif\n\n/* Description of data base entry for a single network.  NOTE: here a\n   poor assumption is made.  The network number is expected to fit\n   into an unsigned long int variable.  */\nstruct netent {\n\tchar *n_name;\t\t/* Official name of network.  */\n\tchar **n_aliases;\t/* Alias list.  */\n\tint n_addrtype;\t\t/* Net address type.  */\n\tuint32_t n_net;\t\t/* Network number.  */\n};\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/param.h",
    "content": "/* Old-style Unix parameters and limits.  Linux version.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n#error \"Never use <bits/param.h> directly; include <sys/param.h> instead.\"\n#endif\n\n#ifndef ARG_MAX\n#define __undef_ARG_MAX\n#endif\n\n#include <linux/limits.h>\n#include <linux/param.h>\n\n/* The kernel headers define ARG_MAX.  The value is wrong, though.  */\n#ifdef __undef_ARG_MAX\n#undef ARG_MAX\n#undef __undef_ARG_MAX\n#endif\n\n#define\tMAXSYMLINKS\t20\n\n/* The following are not really correct but it is a value we used for a\n   long time and which seems to be usable.  People should not use NOFILE\n   and NCARGS anyway.  */\n#define NOFILE\t\t256\n#define\tNCARGS\t\t131072\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/posix1_lim.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.9.2 Minimum Values\tAdded to <limits.h>\n *\n *\tNever include this file directly; use <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX1_LIM_H\n#define\t_BITS_POSIX1_LIM_H\t1\n\n/* These are the standard-mandated minimum values.  */\n\n/* Minimum number of operations in one list I/O call.  */\n#define _POSIX_AIO_LISTIO_MAX\t2\n\n/* Minimal number of outstanding asynchronous I/O operations.  */\n#define _POSIX_AIO_MAX\t\t1\n\n/* Maximum length of arguments to `execve', including environment.  */\n#define\t_POSIX_ARG_MAX\t\t4096\n\n/* Maximum simultaneous processes per real user ID.  */\n#ifdef __USE_XOPEN2K\n#define _POSIX_CHILD_MAX\t25\n#else\n#define _POSIX_CHILD_MAX\t6\n#endif\n\n/* Minimal number of timer expiration overruns.  */\n#define _POSIX_DELAYTIMER_MAX\t32\n\n/* Maximum length of a host name (not including the terminating null)\n   as returned from the GETHOSTNAME function.  */\n#define _POSIX_HOST_NAME_MAX\t255\n\n/* Maximum link count of a file.  */\n#define\t_POSIX_LINK_MAX\t\t8\n\n/* Maximum length of login name.  */\n#define\t_POSIX_LOGIN_NAME_MAX\t9\n\n/* Number of bytes in a terminal canonical input queue.  */\n#define\t_POSIX_MAX_CANON\t255\n\n/* Number of bytes for which space will be\n   available in a terminal input queue.  */\n#define\t_POSIX_MAX_INPUT\t255\n\n/* Maximum number of message queues open for a process.  */\n#define _POSIX_MQ_OPEN_MAX\t8\n\n/* Maximum number of supported message priorities.  */\n#define _POSIX_MQ_PRIO_MAX\t32\n\n/* Number of bytes in a filename.  */\n#define\t_POSIX_NAME_MAX\t\t14\n\n/* Number of simultaneous supplementary group IDs per process.  */\n#ifdef __USE_XOPEN2K\n#define _POSIX_NGROUPS_MAX\t8\n#else\n#define _POSIX_NGROUPS_MAX\t0\n#endif\n\n/* Number of files one process can have open at once.  */\n#ifdef __USE_XOPEN2K\n#define _POSIX_OPEN_MAX\t20\n#else\n#define _POSIX_OPEN_MAX\t16\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Number of descriptors that a process may examine with `pselect' or\n   `select'.  */\n#define _POSIX_FD_SETSIZE\t_POSIX_OPEN_MAX\n#endif\n\n/* Number of bytes in a pathname.  */\n#define\t_POSIX_PATH_MAX\t\t256\n\n/* Number of bytes than can be written atomically to a pipe.  */\n#define\t_POSIX_PIPE_BUF\t\t512\n\n/* The number of repeated occurrences of a BRE permitted by the\n   REGEXEC and REGCOMP functions when using the interval notation.  */\n#define _POSIX_RE_DUP_MAX\t255\n\n/* Minimal number of realtime signals reserved for the application.  */\n#define _POSIX_RTSIG_MAX\t8\n\n/* Number of semaphores a process can have.  */\n#define _POSIX_SEM_NSEMS_MAX\t256\n\n/* Maximal value of a semaphore.  */\n#define _POSIX_SEM_VALUE_MAX\t32767\n\n/* Number of pending realtime signals.  */\n#define _POSIX_SIGQUEUE_MAX\t32\n\n/* Largest value of a `ssize_t'.  */\n#define\t_POSIX_SSIZE_MAX\t32767\n\n/* Number of streams a process can have open at once.  */\n#define\t_POSIX_STREAM_MAX\t8\n\n/* The number of bytes in a symbolic link.  */\n#define _POSIX_SYMLINK_MAX\t255\n\n/* The number of symbolic links that can be traversed in the\n   resolution of a pathname in the absence of a loop.  */\n#define _POSIX_SYMLOOP_MAX\t8\n\n/* Number of timer for a process.  */\n#define _POSIX_TIMER_MAX\t32\n\n/* Maximum number of characters in a tty name.  */\n#define\t_POSIX_TTY_NAME_MAX\t9\n\n/* Maximum length of a timezone name (element of `tzname').  */\n#ifdef __USE_XOPEN2K\n#define _POSIX_TZNAME_MAX\t6\n#else\n#define _POSIX_TZNAME_MAX\t3\n#endif\n\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n/* Maximum number of connections that can be queued on a socket.  */\n#define _POSIX_QLIMIT\t\t1\n\n/* Maximum number of bytes that can be buffered on a socket for send\n   or receive.  */\n#define _POSIX_HIWAT\t\t_POSIX_PIPE_BUF\n\n/* Maximum number of elements in an `iovec' array.  */\n#define _POSIX_UIO_MAXIOV\t16\n#endif\n\n/* Maximum clock resolution in nanoseconds.  */\n#define _POSIX_CLOCKRES_MIN\t20000000\n\n/* Get the implementation-specific values for the above.  */\n#include <bits/local_lim.h>\n\n#ifndef\tSSIZE_MAX\n#define SSIZE_MAX\tLONG_MAX\n#endif\n\n/* This value is a guaranteed minimum maximum.\n   The current maximum can be got from `sysconf'.  */\n\n#ifndef\tNGROUPS_MAX\n#define NGROUPS_MAX\t8\n#endif\n\n#endif\t\t\t\t/* bits/posix1_lim.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/posix2_lim.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; include <limits.h> instead.\n */\n\n#ifndef\t_BITS_POSIX2_LIM_H\n#define\t_BITS_POSIX2_LIM_H\t1\n\n/* The maximum `ibase' and `obase' values allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_BASE_MAX\t\t99\n\n/* The maximum number of elements allowed in an array by the `bc' utility.  */\n#define\t_POSIX2_BC_DIM_MAX\t\t2048\n\n/* The maximum `scale' value allowed by the `bc' utility.  */\n#define\t_POSIX2_BC_SCALE_MAX\t\t99\n\n/* The maximum length of a string constant accepted by the `bc' utility.  */\n#define\t_POSIX2_BC_STRING_MAX\t\t1000\n\n/* The maximum number of weights that can be assigned to an entry of\n   the LC_COLLATE `order' keyword in the locale definition file.  */\n#define\t_POSIX2_COLL_WEIGHTS_MAX\t2\n\n/* The maximum number of expressions that can be nested\n   within parentheses by the `expr' utility.  */\n#define\t_POSIX2_EXPR_NEST_MAX\t\t32\n\n/* The maximum length, in bytes, of an input line.  */\n#define\t_POSIX2_LINE_MAX\t\t2048\n\n/* The maximum number of repeated occurrences of a regular expression\n   permitted when using the interval notation `\\{M,N\\}'.  */\n#define\t_POSIX2_RE_DUP_MAX\t\t255\n\n/* The maximum number of bytes in a character class name.  We have no\n   fixed limit, 2048 is a high number.  */\n#define\t_POSIX2_CHARCLASS_NAME_MAX\t14\n\n/* These values are implementation-specific,\n   and may vary within the implementation.\n   Their precise values can be obtained from sysconf.  */\n\n#ifndef\tBC_BASE_MAX\n#define\tBC_BASE_MAX\t\t_POSIX2_BC_BASE_MAX\n#endif\n#ifndef\tBC_DIM_MAX\n#define\tBC_DIM_MAX\t\t_POSIX2_BC_DIM_MAX\n#endif\n#ifndef\tBC_SCALE_MAX\n#define\tBC_SCALE_MAX\t\t_POSIX2_BC_SCALE_MAX\n#endif\n#ifndef\tBC_STRING_MAX\n#define\tBC_STRING_MAX\t\t_POSIX2_BC_STRING_MAX\n#endif\n#ifndef\tCOLL_WEIGHTS_MAX\n#define\tCOLL_WEIGHTS_MAX\t255\n#endif\n#ifndef\tEXPR_NEST_MAX\n#define\tEXPR_NEST_MAX\t\t_POSIX2_EXPR_NEST_MAX\n#endif\n#ifndef\tLINE_MAX\n#define\tLINE_MAX\t\t_POSIX2_LINE_MAX\n#endif\n#ifndef\tCHARCLASS_NAME_MAX\n#define\tCHARCLASS_NAME_MAX\t2048\n#endif\n\n/* This value is defined like this in regex.h.  */\n#define\tRE_DUP_MAX (0x7fff)\n\n#endif\t\t\t\t/* bits/posix2_lim.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/posix_opt.h",
    "content": "/* Define POSIX options for Linux.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_BITS_POSIX_OPT_H\n#define\t_BITS_POSIX_OPT_H\t1\n\n/* Job control is supported.  */\n#define\t_POSIX_JOB_CONTROL\t1\n\n/* Processes have a saved set-user-ID and a saved set-group-ID.  */\n#define\t_POSIX_SAVED_IDS\t1\n\n/* Priority scheduling is supported.  */\n#define\t_POSIX_PRIORITY_SCHEDULING\t200809L\n\n/* Synchronizing file data is supported.  */\n#define\t_POSIX_SYNCHRONIZED_IO\t200809L\n\n/* The fsync function is present.  */\n#define\t_POSIX_FSYNC\t200809L\n\n/* Mapping of files to memory is supported.  */\n#define\t_POSIX_MAPPED_FILES\t200809L\n\n/* Locking of all memory is supported.  */\n#define\t_POSIX_MEMLOCK\t200809L\n\n/* Locking of ranges of memory is supported.  */\n#define\t_POSIX_MEMLOCK_RANGE\t200809L\n\n/* Setting of memory protections is supported.  */\n#define\t_POSIX_MEMORY_PROTECTION\t200809L\n\n/* Some filesystems allow all users to change file ownership.  */\n#define\t_POSIX_CHOWN_RESTRICTED\t0\n\n/* `c_cc' member of 'struct termios' structure can be disabled by\n   using the value _POSIX_VDISABLE.  */\n#define\t_POSIX_VDISABLE\t'\\0'\n\n/* Filenames are not silently truncated.  */\n#define\t_POSIX_NO_TRUNC\t1\n\n/* X/Open realtime support is available.  */\n#define _XOPEN_REALTIME\t1\n\n/* X/Open thread realtime support is available.  */\n#define _XOPEN_REALTIME_THREADS\t1\n\n/* XPG4.2 shared memory is supported.  */\n#define\t_XOPEN_SHM\t1\n\n/* Tell we have POSIX threads.  */\n#define _POSIX_THREADS\t200809L\n\n/* We have the reentrant functions described in POSIX.  */\n#define _POSIX_REENTRANT_FUNCTIONS      1\n#define _POSIX_THREAD_SAFE_FUNCTIONS\t200809L\n\n/* We provide priority scheduling for threads.  */\n#define _POSIX_THREAD_PRIORITY_SCHEDULING\t200809L\n\n/* We support user-defined stack sizes.  */\n#define _POSIX_THREAD_ATTR_STACKSIZE\t200809L\n\n/* We support user-defined stacks.  */\n#define _POSIX_THREAD_ATTR_STACKADDR\t200809L\n\n/* We support priority inheritence.  */\n#define _POSIX_THREAD_PRIO_INHERIT\t200809L\n\n/* We support priority protection, though only for non-robust\n   mutexes.  */\n#define _POSIX_THREAD_PRIO_PROTECT\t200809L\n\n#ifdef __USE_XOPEN2K8\n/* We support priority inheritence for robust mutexes.  */\n#define _POSIX_THREAD_ROBUST_PRIO_INHERIT\t200809L\n\n/* We do not support priority protection for robust mutexes.  */\n#define _POSIX_THREAD_ROBUST_PRIO_PROTECT\t-1\n#endif\n\n/* We support POSIX.1b semaphores.  */\n#define _POSIX_SEMAPHORES\t200809L\n\n/* Real-time signals are supported.  */\n#define _POSIX_REALTIME_SIGNALS\t200809L\n\n/* We support asynchronous I/O.  */\n#define _POSIX_ASYNCHRONOUS_IO\t200809L\n#define _POSIX_ASYNC_IO\t\t1\n/* Alternative name for Unix98.  */\n#define _LFS_ASYNCHRONOUS_IO\t1\n/* Support for prioritization is also available.  */\n#define _POSIX_PRIORITIZED_IO\t200809L\n\n/* The LFS support in asynchronous I/O is also available.  */\n#define _LFS64_ASYNCHRONOUS_IO\t1\n\n/* The rest of the LFS is also available.  */\n#define _LFS_LARGEFILE\t\t1\n#define _LFS64_LARGEFILE\t1\n#define _LFS64_STDIO\t\t1\n\n/* POSIX shared memory objects are implemented.  */\n#define _POSIX_SHARED_MEMORY_OBJECTS\t200809L\n\n/* CPU-time clocks support needs to be checked at runtime.  */\n#define _POSIX_CPUTIME\t0\n\n/* Clock support in threads must be also checked at runtime.  */\n#define _POSIX_THREAD_CPUTIME\t0\n\n/* GNU libc provides regular expression handling.  */\n#define _POSIX_REGEXP\t1\n\n/* Reader/Writer locks are available.  */\n#define _POSIX_READER_WRITER_LOCKS\t200809L\n\n/* We have a POSIX shell.  */\n#define _POSIX_SHELL\t1\n\n/* We support the Timeouts option.  */\n#define _POSIX_TIMEOUTS\t200809L\n\n/* We support spinlocks.  */\n#define _POSIX_SPIN_LOCKS\t200809L\n\n/* The `spawn' function family is supported.  */\n#define _POSIX_SPAWN\t200809L\n\n/* We have POSIX timers.  */\n#define _POSIX_TIMERS\t200809L\n\n/* The barrier functions are available.  */\n#define _POSIX_BARRIERS\t200809L\n\n/* POSIX message queues are available.  */\n#define\t_POSIX_MESSAGE_PASSING\t200809L\n\n/* Thread process-shared synchronization is supported.  */\n#define _POSIX_THREAD_PROCESS_SHARED\t200809L\n\n/* The monotonic clock might be available.  */\n#define _POSIX_MONOTONIC_CLOCK\t0\n\n/* The clock selection interfaces are available.  */\n#define _POSIX_CLOCK_SELECTION\t200809L\n\n/* Advisory information interfaces are available.  */\n#define _POSIX_ADVISORY_INFO\t200809L\n\n/* IPv6 support is available.  */\n#define _POSIX_IPV6\t200809L\n\n/* Raw socket support is available.  */\n#define _POSIX_RAW_SOCKETS\t200809L\n\n/* We have at least one terminal.  */\n#define _POSIX2_CHAR_TERM\t200809L\n\n/* Neither process nor thread sporadic server interfaces is available.  */\n#define _POSIX_SPORADIC_SERVER\t-1\n#define _POSIX_THREAD_SPORADIC_SERVER\t-1\n\n/* trace.h is not available.  */\n#define _POSIX_TRACE\t-1\n#define _POSIX_TRACE_EVENT_FILTER\t-1\n#define _POSIX_TRACE_INHERIT\t-1\n#define _POSIX_TRACE_LOG\t-1\n\n/* Typed memory objects are not available.  */\n#define _POSIX_TYPED_MEMORY_OBJECTS\t-1\n\n#endif\t\t\t\t/* bits/posix_opt.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/pthreadtypes.h",
    "content": "/* Copyright (C) 2002-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_PTHREADTYPES_H\n#define _BITS_PTHREADTYPES_H\t1\n\n#include <endian.h>\n\n#define __SIZEOF_PTHREAD_ATTR_T 36\n#define __SIZEOF_PTHREAD_MUTEX_T 24\n#define __SIZEOF_PTHREAD_MUTEXATTR_T 4\n#define __SIZEOF_PTHREAD_COND_T 48\n#define __SIZEOF_PTHREAD_COND_COMPAT_T 12\n#define __SIZEOF_PTHREAD_CONDATTR_T 4\n#define __SIZEOF_PTHREAD_RWLOCK_T 32\n#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8\n#define __SIZEOF_PTHREAD_BARRIER_T 20\n#define __SIZEOF_PTHREAD_BARRIERATTR_T 4\n\n/* Thread identifiers.  The structure of the attribute type is not\n   exposed on purpose.  */\ntypedef unsigned long int pthread_t;\n\nunion pthread_attr_t {\n\tchar __size[__SIZEOF_PTHREAD_ATTR_T];\n\tlong int __align;\n};\n#ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n#define __have_pthread_attr_t\t1\n#endif\n\ntypedef struct __pthread_internal_slist {\n\tstruct __pthread_internal_slist *__next;\n} __pthread_slist_t;\n\n/* Data structures for mutex handling.  The structure of the attribute\n   type is not exposed on purpose.  */\ntypedef union {\n\tstruct __pthread_mutex_s {\n\t\tint __lock;\n\t\tunsigned int __count;\n\t\tint __owner;\n\t\t/* KIND must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tint __kind;\n\t\tunsigned int __nusers;\n\t\t__extension__ union {\n\t\t\tint __spins;\n\t\t\t__pthread_slist_t __list;\n\t\t};\n\t} __data;\n\tchar __size[__SIZEOF_PTHREAD_MUTEX_T];\n\tlong int __align;\n} pthread_mutex_t;\n\n/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */\n#define __PTHREAD_SPINS 0\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_MUTEXATTR_T];\n\tlong int __align;\n} pthread_mutexattr_t;\n\n/* Data structure for conditional variable handling.  The structure of\n   the attribute type is not exposed on purpose.  */\ntypedef union {\n\tstruct {\n\t\tint __lock;\n\t\tunsigned int __futex;\n\t\t__extension__ unsigned long long int __total_seq;\n\t\t__extension__ unsigned long long int __wakeup_seq;\n\t\t__extension__ unsigned long long int __woken_seq;\n\t\tvoid *__mutex;\n\t\tunsigned int __nwaiters;\n\t\tunsigned int __broadcast_seq;\n\t} __data;\n\tchar __size[__SIZEOF_PTHREAD_COND_T];\n\t__extension__ long long int __align;\n} pthread_cond_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_CONDATTR_T];\n\tlong int __align;\n} pthread_condattr_t;\n\n/* Keys for thread-specific data */\ntypedef unsigned int pthread_key_t;\n\n/* Once-only execution */\ntypedef int pthread_once_t;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Data structure for read-write lock variable handling.  The\n   structure of the attribute type is not exposed on purpose.  */\ntypedef union {\n\tstruct {\n\t\tint __lock;\n\t\tunsigned int __nr_readers;\n\t\tunsigned int __readers_wakeup;\n\t\tunsigned int __writer_wakeup;\n\t\tunsigned int __nr_readers_queued;\n\t\tunsigned int __nr_writers_queued;\n#if __BYTE_ORDER == __BIG_ENDIAN\n\t\tunsigned char __pad1;\n\t\tunsigned char __pad2;\n\t\tunsigned char __shared;\n\t\t/* FLAGS must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tunsigned char __flags;\n#else\n\t\t/* FLAGS must stay at this position in the structure to maintain\n\t\t   binary compatibility.  */\n\t\tunsigned char __flags;\n\t\tunsigned char __shared;\n\t\tunsigned char __pad1;\n\t\tunsigned char __pad2;\n#endif\n\t\tint __writer;\n\t} __data;\n\tchar __size[__SIZEOF_PTHREAD_RWLOCK_T];\n\tlong int __align;\n} pthread_rwlock_t;\n\n#define __PTHREAD_RWLOCK_ELISION_EXTRA 0\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];\n\tlong int __align;\n} pthread_rwlockattr_t;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* POSIX spinlock data type.  */\ntypedef volatile int pthread_spinlock_t;\n\n/* POSIX barriers data type.  The structure of the type is\n   deliberately not exposed.  */\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIER_T];\n\tlong int __align;\n} pthread_barrier_t;\n\ntypedef union {\n\tchar __size[__SIZEOF_PTHREAD_BARRIERATTR_T];\n\tint __align;\n} pthread_barrierattr_t;\n#endif\n\n#endif\t\t\t\t/* bits/pthreadtypes.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/resource.h",
    "content": "/* Bit values & structures for resource limits.  Linux version.\n   Copyright (C) 1994-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_RESOURCE_H\n#error \"Never use <bits/resource.h> directly; include <sys/resource.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\n/* Transmute defines to enumerations.  The macro re-definitions are\n   necessary because some programs want to test for operating system\n   features with #ifdef RUSAGE_SELF.  In ISO C the reflexive\n   definition is a no-op.  */\n\n/* Kinds of resource limit.  */\nenum __rlimit_resource {\n\t/* Per-process CPU limit, in seconds.  */\n\tRLIMIT_CPU = 0,\n#define RLIMIT_CPU RLIMIT_CPU\n\n\t/* Largest file that can be created, in bytes.  */\n\tRLIMIT_FSIZE = 1,\n#define\tRLIMIT_FSIZE RLIMIT_FSIZE\n\n\t/* Maximum size of data segment, in bytes.  */\n\tRLIMIT_DATA = 2,\n#define\tRLIMIT_DATA RLIMIT_DATA\n\n\t/* Maximum size of stack segment, in bytes.  */\n\tRLIMIT_STACK = 3,\n#define\tRLIMIT_STACK RLIMIT_STACK\n\n\t/* Largest core file that can be created, in bytes.  */\n\tRLIMIT_CORE = 4,\n#define\tRLIMIT_CORE RLIMIT_CORE\n\n\t/* Largest resident set size, in bytes.\n\t   This affects swapping; processes that are exceeding their\n\t   resident set size will be more likely to have physical memory\n\t   taken from them.  */\n\t__RLIMIT_RSS = 5,\n#define\tRLIMIT_RSS __RLIMIT_RSS\n\n\t/* Number of open files.  */\n\tRLIMIT_NOFILE = 7,\n\t__RLIMIT_OFILE = RLIMIT_NOFILE,\t/* BSD name for same.  */\n#define RLIMIT_NOFILE RLIMIT_NOFILE\n#define RLIMIT_OFILE __RLIMIT_OFILE\n\n\t/* Address space limit.  */\n\tRLIMIT_AS = 9,\n#define RLIMIT_AS RLIMIT_AS\n\n\t/* Number of processes.  */\n\t__RLIMIT_NPROC = 6,\n#define RLIMIT_NPROC __RLIMIT_NPROC\n\n\t/* Locked-in-memory address space.  */\n\t__RLIMIT_MEMLOCK = 8,\n#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK\n\n\t/* Maximum number of file locks.  */\n\t__RLIMIT_LOCKS = 10,\n#define RLIMIT_LOCKS __RLIMIT_LOCKS\n\n\t/* Maximum number of pending signals.  */\n\t__RLIMIT_SIGPENDING = 11,\n#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING\n\n\t/* Maximum bytes in POSIX message queues.  */\n\t__RLIMIT_MSGQUEUE = 12,\n#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE\n\n\t/* Maximum nice priority allowed to raise to.\n\t   Nice levels 19 .. -20 correspond to 0 .. 39\n\t   values of this resource limit.  */\n\t__RLIMIT_NICE = 13,\n#define RLIMIT_NICE __RLIMIT_NICE\n\n\t/* Maximum realtime priority allowed for non-priviledged\n\t   processes.  */\n\t__RLIMIT_RTPRIO = 14,\n#define RLIMIT_RTPRIO __RLIMIT_RTPRIO\n\n\t/* Maximum CPU time in µs that a process scheduled under a real-time\n\t   scheduling policy may consume without making a blocking system\n\t   call before being forcibly descheduled.  */\n\t__RLIMIT_RTTIME = 15,\n#define RLIMIT_RTTIME __RLIMIT_RTTIME\n\n\t__RLIMIT_NLIMITS = 16,\n\t__RLIM_NLIMITS = __RLIMIT_NLIMITS\n#define RLIMIT_NLIMITS __RLIMIT_NLIMITS\n#define RLIM_NLIMITS __RLIM_NLIMITS\n};\n\n/* Value to indicate that there is no limit.  */\n#ifndef __USE_FILE_OFFSET64\n#define RLIM_INFINITY ((__rlim_t) -1)\n#else\n#define RLIM_INFINITY 0xffffffffffffffffuLL\n#endif\n\n#ifdef __USE_LARGEFILE64\n#define RLIM64_INFINITY 0xffffffffffffffffuLL\n#endif\n\n/* We can represent all limits.  */\n#define RLIM_SAVED_MAX\tRLIM_INFINITY\n#define RLIM_SAVED_CUR\tRLIM_INFINITY\n\n/* Type for resource quantity measurement.  */\n#ifndef __USE_FILE_OFFSET64\ntypedef __rlim_t rlim_t;\n#else\ntypedef __rlim64_t rlim_t;\n#endif\n#ifdef __USE_LARGEFILE64\ntypedef __rlim64_t rlim64_t;\n#endif\n\nstruct rlimit {\n\t/* The current (soft) limit.  */\n\trlim_t rlim_cur;\n\t/* The hard limit.  */\n\trlim_t rlim_max;\n};\n\n#ifdef __USE_LARGEFILE64\nstruct rlimit64 {\n\t/* The current (soft) limit.  */\n\trlim64_t rlim_cur;\n\t/* The hard limit.  */\n\trlim64_t rlim_max;\n};\n#endif\n\n/* Whose usage statistics do you want?  */\nenum __rusage_who {\n\t/* The calling process.  */\n\tRUSAGE_SELF = 0,\n#define RUSAGE_SELF RUSAGE_SELF\n\n\t/* All of its terminated child processes.  */\n\tRUSAGE_CHILDREN = -1\n#define RUSAGE_CHILDREN RUSAGE_CHILDREN\n#ifdef __USE_GNU\n\t    ,\n\t/* The calling thread.  */\n\tRUSAGE_THREAD = 1\n#define RUSAGE_THREAD RUSAGE_THREAD\n\t    /* Name for the same functionality on Solaris.  */\n#define RUSAGE_LWP RUSAGE_THREAD\n#endif\n};\n\n#define __need_timeval\n#include <bits/time.h>\t\t/* For `struct timeval'.  */\n\n/* Structure which says how much of each resource has been used.  */\n\n/* The purpose of all the unions is to have the kernel-compatible layout\n   while keeping the API type as 'long int', and among machines where\n   __syscall_slong_t is not 'long int', this only does the right thing\n   for little-endian ones, like x32.  */\nstruct rusage {\n\t/* Total amount of user time used.  */\n\tstruct timeval ru_utime;\n\t/* Total amount of system time used.  */\n\tstruct timeval ru_stime;\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_maxrss;\n\t\t__syscall_slong_t __ru_maxrss_word;\n\t};\n\t/* Amount of sharing of text segment memory\n\t   with other processes (kilobyte-seconds).  */\n\t/* Maximum resident set size (in kilobytes).  */\n\t__extension__ union {\n\t\tlong int ru_ixrss;\n\t\t__syscall_slong_t __ru_ixrss_word;\n\t};\n\t/* Amount of data segment memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_idrss;\n\t\t__syscall_slong_t __ru_idrss_word;\n\t};\n\t/* Amount of stack memory used (kilobyte-seconds).  */\n\t__extension__ union {\n\t\tlong int ru_isrss;\n\t\t__syscall_slong_t __ru_isrss_word;\n\t};\n\t/* Number of soft page faults (i.e. those serviced by reclaiming\n\t   a page from the list of pages awaiting reallocation.  */\n\t__extension__ union {\n\t\tlong int ru_minflt;\n\t\t__syscall_slong_t __ru_minflt_word;\n\t};\n\t/* Number of hard page faults (i.e. those that required I/O).  */\n\t__extension__ union {\n\t\tlong int ru_majflt;\n\t\t__syscall_slong_t __ru_majflt_word;\n\t};\n\t/* Number of times a process was swapped out of physical memory.  */\n\t__extension__ union {\n\t\tlong int ru_nswap;\n\t\t__syscall_slong_t __ru_nswap_word;\n\t};\n\t/* Number of input operations via the file system.  Note: This\n\t   and `ru_oublock' do not include operations with the cache.  */\n\t__extension__ union {\n\t\tlong int ru_inblock;\n\t\t__syscall_slong_t __ru_inblock_word;\n\t};\n\t/* Number of output operations via the file system.  */\n\t__extension__ union {\n\t\tlong int ru_oublock;\n\t\t__syscall_slong_t __ru_oublock_word;\n\t};\n\t/* Number of IPC messages sent.  */\n\t__extension__ union {\n\t\tlong int ru_msgsnd;\n\t\t__syscall_slong_t __ru_msgsnd_word;\n\t};\n\t/* Number of IPC messages received.  */\n\t__extension__ union {\n\t\tlong int ru_msgrcv;\n\t\t__syscall_slong_t __ru_msgrcv_word;\n\t};\n\t/* Number of signals delivered.  */\n\t__extension__ union {\n\t\tlong int ru_nsignals;\n\t\t__syscall_slong_t __ru_nsignals_word;\n\t};\n\t/* Number of voluntary context switches, i.e. because the process\n\t   gave up the process before it had to (usually to wait for some\n\t   resource to be available).  */\n\t__extension__ union {\n\t\tlong int ru_nvcsw;\n\t\t__syscall_slong_t __ru_nvcsw_word;\n\t};\n\t/* Number of involuntary context switches, i.e. a higher priority process\n\t   became runnable or the current process used up its time slice.  */\n\t__extension__ union {\n\t\tlong int ru_nivcsw;\n\t\t__syscall_slong_t __ru_nivcsw_word;\n\t};\n};\n\n/* Priority limits.  */\n#define PRIO_MIN\t-20\t/* Minimum priority a process can have.  */\n#define PRIO_MAX\t20\t/* Maximum priority a process can have.  */\n\n/* The type of the WHICH argument to `getpriority' and `setpriority',\n   indicating what flavor of entity the WHO argument specifies.  */\nenum __priority_which {\n\tPRIO_PROCESS = 0,\t/* WHO is a process ID.  */\n#define PRIO_PROCESS PRIO_PROCESS\n\tPRIO_PGRP = 1,\t\t/* WHO is a process group ID.  */\n#define PRIO_PGRP PRIO_PGRP\n\tPRIO_USER = 2\t\t/* WHO is a user ID.  */\n#define PRIO_USER PRIO_USER\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Modify and return resource limits of a process atomically.  */\n#ifndef __USE_FILE_OFFSET64\nextern int prlimit(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit *__new_limit, struct rlimit *__old_limit) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(prlimit, (__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit * __new_limit, struct rlimit * __old_limit), prlimit64);\n#else\n#define prlimit prlimit64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int prlimit64(__pid_t __pid, enum __rlimit_resource __resource, const struct rlimit64 *__new_limit, struct rlimit64 *__old_limit) __THROW;\n#endif\n#endif\n\n__END_DECLS\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sched.h",
    "content": "/* Definitions of constants and data structure for POSIX 1003.1b-1993\n   scheduling interface.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __need_schedparam\n\n#ifndef _SCHED_H\n#error \"Never include <bits/sched.h> directly; use <sched.h> instead.\"\n#endif\n\n/* Scheduling algorithms.  */\n#define SCHED_OTHER\t\t0\n#define SCHED_FIFO\t\t1\n#define SCHED_RR\t\t2\n#ifdef __USE_GNU\n#define SCHED_BATCH\t\t3\n#define SCHED_IDLE\t\t5\n\n#define SCHED_RESET_ON_FORK\t0x40000000\n#endif\n\n#ifdef __USE_GNU\n/* Cloning flags.  */\n#define CSIGNAL       0x000000ff\t/* Signal mask to be sent at exit.  */\n#define CLONE_VM      0x00000100\t/* Set if VM shared between processes.  */\n#define CLONE_FS      0x00000200\t/* Set if fs info shared between processes.  */\n#define CLONE_FILES   0x00000400\t/* Set if open files shared between processes.  */\n#define CLONE_SIGHAND 0x00000800\t/* Set if signal handlers shared.  */\n#define CLONE_PTRACE  0x00002000\t/* Set if tracing continues on the child.  */\n#define CLONE_VFORK   0x00004000\t/* Set if the parent wants the child to\n\t\t\t\t\t   wake it up on mm_release.  */\n#define CLONE_PARENT  0x00008000\t/* Set if we want to have the same\n\t\t\t\t\t   parent as the cloner.  */\n#define CLONE_THREAD  0x00010000\t/* Set to add to same thread group.  */\n#define CLONE_NEWNS   0x00020000\t/* Set to create new namespace.  */\n#define CLONE_SYSVSEM 0x00040000\t/* Set to shared SVID SEM_UNDO semantics.  */\n#define CLONE_SETTLS  0x00080000\t/* Set TLS info.  */\n#define CLONE_PARENT_SETTID 0x00100000\t/* Store TID in userlevel buffer\n\t\t\t\t\t   before MM copy.  */\n#define CLONE_CHILD_CLEARTID 0x00200000\t/* Register exit futex and memory\n\t\t\t\t\t   location to clear.  */\n#define CLONE_DETACHED 0x00400000\t/* Create clone detached.  */\n#define CLONE_UNTRACED 0x00800000\t/* Set if the tracing process can't\n\t\t\t\t\t   force CLONE_PTRACE on this clone.  */\n#define CLONE_CHILD_SETTID 0x01000000\t/* Store TID in userlevel buffer in\n\t\t\t\t\t   the child.  */\n#define CLONE_NEWCGROUP    0x02000000\t/* New cgroup namespace.  */\n#define CLONE_NEWUTS\t0x04000000\t/* New utsname group.  */\n#define CLONE_NEWIPC\t0x08000000\t/* New ipcs.  */\n#define CLONE_NEWUSER\t0x10000000\t/* New user namespace.  */\n#define CLONE_NEWPID\t0x20000000\t/* New pid namespace.  */\n#define CLONE_NEWNET\t0x40000000\t/* New network namespace.  */\n#define CLONE_IO\t0x80000000\t/* Clone I/O context.  */\n#endif\n\n/* The official definition.  */\nstruct sched_param {\n\tint __sched_priority;\n};\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Clone current process.  */\nextern int clone(int (*__fn) (void *__arg), void *__child_stack, int __flags, void *__arg, ...) __THROW;\n\n/* Unshare the specified resources.  */\nextern int unshare(int __flags) __THROW;\n\n/* Get index of currently used CPU.  */\nextern int sched_getcpu(void) __THROW;\n\n/* Switch process to namespace of type NSTYPE indicated by FD.  */\nextern int setns(int __fd, int __nstype) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* need schedparam */\n#if !defined __defined_schedparam \\\n    && (defined __need_schedparam || defined _SCHED_H)\n#define __defined_schedparam\t1\n/* Data structure to describe a process' schedulability.  */\nstruct __sched_param {\n\tint __sched_priority;\n};\n#undef __need_schedparam\n#endif\n\n#if defined _SCHED_H && !defined __cpu_set_t_defined\n#define __cpu_set_t_defined\n/* Size definition for CPU sets.  */\n#define __CPU_SETSIZE\t1024\n#define __NCPUBITS\t(8 * sizeof (__cpu_mask))\n\n/* Type for array elements in 'cpu_set_t'.  */\ntypedef __CPU_MASK_TYPE __cpu_mask;\n\n/* Basic access functions.  */\n#define __CPUELT(cpu)\t((cpu) / __NCPUBITS)\n#define __CPUMASK(cpu)\t((__cpu_mask) 1 << ((cpu) % __NCPUBITS))\n\n/* Data structure to describe CPU mask.  */\ntypedef struct {\n\t__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];\n} cpu_set_t;\n\n/* Access functions for CPU masks.  */\n#if __GNUC_PREREQ (2, 91)\n#define __CPU_ZERO_S(setsize, cpusetp) \\\n  do __builtin_memset (cpusetp, '\\0', setsize); while (0)\n#else\n#define __CPU_ZERO_S(setsize, cpusetp) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    size_t __i;\t\t\t\t\t\t\t\t      \\\n    size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n    __cpu_mask *__bits = (cpusetp)->__bits;\t\t\t\t      \\\n    for (__i = 0; __i < __imax; ++__i)\t\t\t\t\t      \\\n      __bits[__i] = 0;\t\t\t\t\t\t\t      \\\n  } while (0)\n#endif\n#define __CPU_SET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t |= __CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n#define __CPU_CLR_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t\t      \\\n\t &= ~__CPUMASK (__cpu))\t\t\t\t\t\t      \\\n      : 0; }))\n#define __CPU_ISSET_S(cpu, setsize, cpusetp) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ size_t __cpu = (cpu);\t\t\t\t\t\t      \\\n      __cpu / 8 < (setsize)\t\t\t\t\t\t      \\\n      ? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]\t      \\\n\t  & __CPUMASK (__cpu))) != 0\t\t\t\t\t      \\\n      : 0; }))\n\n#define __CPU_COUNT_S(setsize, cpusetp) \\\n  __sched_cpucount (setsize, cpusetp)\n\n#if __GNUC_PREREQ (2, 91)\n#define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)\n#else\n#define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (cpusetp2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\tif (__arr1[__i] != __arr2[__i])\t\t\t\t\t      \\\n\t  break;\t\t\t\t\t\t\t      \\\n      __i == __imax; }))\n#endif\n\n#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ cpu_set_t *__dest = (destset);\t\t\t\t\t      \\\n      const __cpu_mask *__arr1 = (srcset1)->__bits;\t\t\t      \\\n      const __cpu_mask *__arr2 = (srcset2)->__bits;\t\t\t      \\\n      size_t __imax = (setsize) / sizeof (__cpu_mask);\t\t\t      \\\n      size_t __i;\t\t\t\t\t\t\t      \\\n      for (__i = 0; __i < __imax; ++__i)\t\t\t\t      \\\n\t((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i];    \\\n      __dest; }))\n\n#define __CPU_ALLOC_SIZE(count) \\\n  ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))\n#define __CPU_ALLOC(count) __sched_cpualloc (count)\n#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)\n\n__BEGIN_DECLS extern int __sched_cpucount(size_t __setsize, const cpu_set_t * __setp) __THROW;\nextern cpu_set_t *__sched_cpualloc(size_t __count)\n__THROW __wur;\nextern void __sched_cpufree(cpu_set_t * __set) __THROW;\n\n__END_DECLS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/select.h",
    "content": "/* Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SELECT_H\n#error \"Never use <bits/select.h> directly; include <sys/select.h> instead.\"\n#endif\n\n/* We don't use `memset' because this would require a prototype and\n   the array isn't too big.  */\n#define __FD_ZERO(s) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    unsigned int __i;\t\t\t\t\t\t\t      \\\n    fd_set *__arr = (s);\t\t\t\t\t\t      \\\n    for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)\t      \\\n      __FDS_BITS (__arr)[__i] = 0;\t\t\t\t\t      \\\n  } while (0)\n#define __FD_SET(d, s) \\\n  ((void) (__FDS_BITS (s)[__FD_ELT(d)] |= __FD_MASK(d)))\n#define __FD_CLR(d, s) \\\n  ((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))\n#define __FD_ISSET(d, s) \\\n  ((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/setjmp.h",
    "content": "/* Copyright (C) 2004-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* Define the machine-dependent type `jmp_buf'.  ARM EABI version.  */\n\n#ifndef _BITS_SETJMP_H\n#define _BITS_SETJMP_H 1\n\n#if !defined _SETJMP_H && !defined _PTHREAD_H\n#error \"Never include <bits/setjmp.h> directly; use <setjmp.h> instead.\"\n#endif\n\n#ifndef __ASSEMBLER__\n/* The exact set of registers saved may depend on the particular core\n   in use, as some coprocessor registers may need to be saved.  The C\n   Library ABI requires that the buffer be 8-byte aligned, and\n   recommends that the buffer contain 64 words.  The first 26 words\n   are occupied by sp, lr, v1-v6, sl, fp, and d8-d15.  */\ntypedef int __jmp_buf[64] __attribute__ ((__aligned__(8)));\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigaction.h",
    "content": "/* The proper definitions for Linux's sigaction.\n   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SIGNAL_H\n#error \"Never include <bits/sigaction.h> directly; use <signal.h> instead.\"\n#endif\n\n/* Structure describing the action to be taken when a signal arrives.  */\nstruct sigaction {\n\t/* Signal handler.  */\n#ifdef __USE_POSIX199309\n\tunion {\n\t\t/* Used if SA_SIGINFO is not set.  */\n\t\t__sighandler_t sa_handler;\n\t\t/* Used if SA_SIGINFO is set.  */\n\t\tvoid (*sa_sigaction) (int, siginfo_t *, void *);\n\t} __sigaction_handler;\n#define sa_handler\t__sigaction_handler.sa_handler\n#define sa_sigaction\t__sigaction_handler.sa_sigaction\n#else\n\t__sighandler_t sa_handler;\n#endif\n\n\t/* Additional set of signals to be blocked.  */\n\t__sigset_t sa_mask;\n\n\t/* Special flags.  */\n\tint sa_flags;\n\n\t/* Restore handler.  */\n\tvoid (*sa_restorer) (void);\n};\n\n/* Bits in `sa_flags'.  */\n#define\tSA_NOCLDSTOP  1\t\t/* Don't send SIGCHLD when children stop.  */\n#define SA_NOCLDWAIT  2\t\t/* Don't create zombie on child death.  */\n#define SA_SIGINFO    4\t\t/* Invoke signal-catching function with\n\t\t\t\t   three arguments instead of one.  */\n#if defined __USE_UNIX98 || defined __USE_MISC\n#define SA_ONSTACK   0x08000000\t/* Use signal stack by using `sa_restorer'. */\n#endif\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n#define SA_RESTART   0x10000000\t/* Restart syscall on signal return.  */\n#define SA_NODEFER   0x40000000\t/* Don't automatically block the signal when\n\t\t\t\t   its handler is being executed.  */\n#define SA_RESETHAND 0x80000000\t/* Reset to SIG_DFL on entry to handler.  */\n#endif\n#ifdef __USE_MISC\n#define SA_INTERRUPT 0x20000000\t/* Historical no-op.  */\n\n/* Some aliases for the SA_ constants.  */\n#define SA_NOMASK    SA_NODEFER\n#define SA_ONESHOT   SA_RESETHAND\n#define SA_STACK     SA_ONSTACK\n#endif\n\n/* Values for the HOW argument to `sigprocmask'.  */\n#define\tSIG_BLOCK     0\t\t/* Block signals.  */\n#define\tSIG_UNBLOCK   1\t\t/* Unblock signals.  */\n#define\tSIG_SETMASK   2\t\t/* Set the set of blocked signals.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigcontext.h",
    "content": "/* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H\n#error \"Never use <bits/sigcontext.h> directly; include <signal.h> instead.\"\n#endif\n\n#ifndef sigcontext_struct\n/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but\n   we need sigcontext.  */\n#define sigcontext_struct sigcontext\n\n#include <asm/sigcontext.h>\n\n/* The Linux kernel headers redefine NULL wrongly, so cleanup afterwards.  */\n#define __need_NULL\n#include <stddef.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/siginfo.h",
    "content": "/* siginfo_t, sigevent and constants.  Linux version.\n   Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SIGNAL_H && !defined __need_siginfo_t \\\n    && !defined __need_sigevent_t\n#error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n#include <bits/wordsize.h>\n\n#if (!defined __have_sigval_t \\\n     && (defined _SIGNAL_H || defined __need_siginfo_t \\\n\t || defined __need_sigevent_t))\n#define __have_sigval_t\t1\n\n/* Type for data associated with a signal.  */\ntypedef union sigval {\n\tint sival_int;\n\tvoid *sival_ptr;\n} sigval_t;\n#endif\n\n#if (!defined __have_siginfo_t \\\n     && (defined _SIGNAL_H || defined __need_siginfo_t))\n#define __have_siginfo_t\t1\n\n#define __SI_MAX_SIZE     128\n#if __WORDSIZE == 64\n#define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)\n#else\n#define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)\n#endif\n\ntypedef struct {\n\tint si_signo;\t\t/* Signal number.  */\n\tint si_errno;\t\t/* If non-zero, an errno value associated with\n\t\t\t\t   this signal, as defined in <errno.h>.  */\n\tint si_code;\t\t/* Signal code.  */\n\n\tunion {\n\t\tint _pad[__SI_PAD_SIZE];\n\n\t\t/* kill().  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t} _kill;\n\n\t\t/* POSIX.1b timers.  */\n\t\tstruct {\n\t\t\tint si_tid;\t/* Timer ID.  */\n\t\t\tint si_overrun;\t/* Overrun count.  */\n\t\t\tsigval_t si_sigval;\t/* Signal value.  */\n\t\t} _timer;\n\n\t\t/* POSIX.1b signals.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Sending process ID.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\tsigval_t si_sigval;\t/* Signal value.  */\n\t\t} _rt;\n\n\t\t/* SIGCHLD.  */\n\t\tstruct {\n\t\t\t__pid_t si_pid;\t/* Which child.  */\n\t\t\t__uid_t si_uid;\t/* Real user ID of sending process.  */\n\t\t\tint si_status;\t/* Exit value or signal.  */\n\t\t\t__clock_t si_utime;\n\t\t\t__clock_t si_stime;\n\t\t} _sigchld;\n\n\t\t/* SIGILL, SIGFPE, SIGSEGV, SIGBUS.  */\n\t\tstruct {\n\t\t\tvoid *si_addr;\t/* Faulting insn/memory ref.  */\n\t\t\tshort int si_addr_lsb;\t/* Valid LSB of the reported address.  */\n\t\t} _sigfault;\n\n\t\t/* SIGPOLL.  */\n\t\tstruct {\n\t\t\tlong int si_band;\t/* Band event for SIGPOLL.  */\n\t\t\tint si_fd;\n\t\t} _sigpoll;\n\n\t\t/* SIGSYS.  */\n\t\tstruct {\n\t\t\tvoid *_call_addr;\t/* Calling user insn.  */\n\t\t\tint _syscall;\t/* Triggering system call number.  */\n\t\t\tunsigned int _arch;\t/* AUDIT_ARCH_* of syscall.  */\n\t\t} _sigsys;\n\t} _sifields;\n} siginfo_t;\n\n/* X/Open requires some more fields with fixed names.  */\n#define si_pid\t\t_sifields._kill.si_pid\n#define si_uid\t\t_sifields._kill.si_uid\n#define si_timerid\t_sifields._timer.si_tid\n#define si_overrun\t_sifields._timer.si_overrun\n#define si_status\t_sifields._sigchld.si_status\n#define si_utime\t_sifields._sigchld.si_utime\n#define si_stime\t_sifields._sigchld.si_stime\n#define si_value\t_sifields._rt.si_sigval\n#define si_int\t\t_sifields._rt.si_sigval.sival_int\n#define si_ptr\t\t_sifields._rt.si_sigval.sival_ptr\n#define si_addr\t_sifields._sigfault.si_addr\n#define si_addr_lsb\t_sifields._sigfault.si_addr_lsb\n#define si_band\t_sifields._sigpoll.si_band\n#define si_fd\t\t_sifields._sigpoll.si_fd\n#define si_call_addr \t_sifields._sigsys._call_addr\n#define si_syscall\t_sifields._sigsys._syscall\n#define si_arch\t_sifields._sigsys._arch\n\n/* Values for `si_code'.  Positive values are reserved for kernel-generated\n   signals.  */\nenum {\n\tSI_ASYNCNL = -60,\t/* Sent by asynch name lookup completion.  */\n#define SI_ASYNCNL\tSI_ASYNCNL\n\tSI_TKILL = -6,\t\t/* Sent by tkill.  */\n#define SI_TKILL\tSI_TKILL\n\tSI_SIGIO,\t\t/* Sent by queued SIGIO. */\n#define SI_SIGIO\tSI_SIGIO\n\tSI_ASYNCIO,\t\t/* Sent by AIO completion.  */\n#define SI_ASYNCIO\tSI_ASYNCIO\n\tSI_MESGQ,\t\t/* Sent by real time mesq state change.  */\n#define SI_MESGQ\tSI_MESGQ\n\tSI_TIMER,\t\t/* Sent by timer expiration.  */\n#define SI_TIMER\tSI_TIMER\n\tSI_QUEUE,\t\t/* Sent by sigqueue.  */\n#define SI_QUEUE\tSI_QUEUE\n\tSI_USER,\t\t/* Sent by kill, sigsend.  */\n#define SI_USER\tSI_USER\n\tSI_KERNEL = 0x80\t/* Send by kernel.  */\n#define SI_KERNEL\tSI_KERNEL\n};\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGILL signal.  */\nenum {\n\tILL_ILLOPC = 1,\t\t/* Illegal opcode.  */\n#define ILL_ILLOPC\tILL_ILLOPC\n\tILL_ILLOPN,\t\t/* Illegal operand.  */\n#define ILL_ILLOPN\tILL_ILLOPN\n\tILL_ILLADR,\t\t/* Illegal addressing mode.  */\n#define ILL_ILLADR\tILL_ILLADR\n\tILL_ILLTRP,\t\t/* Illegal trap. */\n#define ILL_ILLTRP\tILL_ILLTRP\n\tILL_PRVOPC,\t\t/* Privileged opcode.  */\n#define ILL_PRVOPC\tILL_PRVOPC\n\tILL_PRVREG,\t\t/* Privileged register.  */\n#define ILL_PRVREG\tILL_PRVREG\n\tILL_COPROC,\t\t/* Coprocessor error.  */\n#define ILL_COPROC\tILL_COPROC\n\tILL_BADSTK\t\t/* Internal stack error.  */\n#define ILL_BADSTK\tILL_BADSTK\n};\n\n/* `si_code' values for SIGFPE signal.  */\nenum {\n\tFPE_INTDIV = 1,\t\t/* Integer divide by zero.  */\n#define FPE_INTDIV\tFPE_INTDIV\n\tFPE_INTOVF,\t\t/* Integer overflow.  */\n#define FPE_INTOVF\tFPE_INTOVF\n\tFPE_FLTDIV,\t\t/* Floating point divide by zero.  */\n#define FPE_FLTDIV\tFPE_FLTDIV\n\tFPE_FLTOVF,\t\t/* Floating point overflow.  */\n#define FPE_FLTOVF\tFPE_FLTOVF\n\tFPE_FLTUND,\t\t/* Floating point underflow.  */\n#define FPE_FLTUND\tFPE_FLTUND\n\tFPE_FLTRES,\t\t/* Floating point inexact result.  */\n#define FPE_FLTRES\tFPE_FLTRES\n\tFPE_FLTINV,\t\t/* Floating point invalid operation.  */\n#define FPE_FLTINV\tFPE_FLTINV\n\tFPE_FLTSUB\t\t/* Subscript out of range.  */\n#define FPE_FLTSUB\tFPE_FLTSUB\n};\n\n/* `si_code' values for SIGSEGV signal.  */\nenum {\n\tSEGV_MAPERR = 1,\t/* Address not mapped to object.  */\n#define SEGV_MAPERR\tSEGV_MAPERR\n\tSEGV_ACCERR\t\t/* Invalid permissions for mapped object.  */\n#define SEGV_ACCERR\tSEGV_ACCERR\n};\n\n/* `si_code' values for SIGBUS signal.  */\nenum {\n\tBUS_ADRALN = 1,\t\t/* Invalid address alignment.  */\n#define BUS_ADRALN\tBUS_ADRALN\n\tBUS_ADRERR,\t\t/* Non-existant physical address.  */\n#define BUS_ADRERR\tBUS_ADRERR\n\tBUS_OBJERR,\t\t/* Object specific hardware error.  */\n#define BUS_OBJERR\tBUS_OBJERR\n\tBUS_MCEERR_AR,\t\t/* Hardware memory error: action required.  */\n#define BUS_MCEERR_AR\tBUS_MCEERR_AR\n\tBUS_MCEERR_AO\t\t/* Hardware memory error: action optional.  */\n#define BUS_MCEERR_AO\tBUS_MCEERR_AO\n};\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* `si_code' values for SIGTRAP signal.  */\nenum {\n\tTRAP_BRKPT = 1,\t\t/* Process breakpoint.  */\n#define TRAP_BRKPT\tTRAP_BRKPT\n\tTRAP_TRACE\t\t/* Process trace trap.  */\n#define TRAP_TRACE\tTRAP_TRACE\n};\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* `si_code' values for SIGCHLD signal.  */\nenum {\n\tCLD_EXITED = 1,\t\t/* Child has exited.  */\n#define CLD_EXITED\tCLD_EXITED\n\tCLD_KILLED,\t\t/* Child was killed.  */\n#define CLD_KILLED\tCLD_KILLED\n\tCLD_DUMPED,\t\t/* Child terminated abnormally.  */\n#define CLD_DUMPED\tCLD_DUMPED\n\tCLD_TRAPPED,\t\t/* Traced child has trapped.  */\n#define CLD_TRAPPED\tCLD_TRAPPED\n\tCLD_STOPPED,\t\t/* Child has stopped.  */\n#define CLD_STOPPED\tCLD_STOPPED\n\tCLD_CONTINUED\t\t/* Stopped child has continued.  */\n#define CLD_CONTINUED\tCLD_CONTINUED\n};\n\n/* `si_code' values for SIGPOLL signal.  */\nenum {\n\tPOLL_IN = 1,\t\t/* Data input available.  */\n#define POLL_IN\tPOLL_IN\n\tPOLL_OUT,\t\t/* Output buffers available.  */\n#define POLL_OUT\tPOLL_OUT\n\tPOLL_MSG,\t\t/* Input message available.   */\n#define POLL_MSG\tPOLL_MSG\n\tPOLL_ERR,\t\t/* I/O error.  */\n#define POLL_ERR\tPOLL_ERR\n\tPOLL_PRI,\t\t/* High priority input available.  */\n#define POLL_PRI\tPOLL_PRI\n\tPOLL_HUP\t\t/* Device disconnected.  */\n#define POLL_HUP\tPOLL_HUP\n};\n#endif\n\n#undef __need_siginfo_t\n#endif\t\t\t\t/* !have siginfo_t && (have _SIGNAL_H || need siginfo_t).  */\n\n#if (defined _SIGNAL_H || defined __need_sigevent_t) \\\n    && !defined __have_sigevent_t\n#define __have_sigevent_t\t1\n\n/* Structure to transport application-defined values with signals.  */\n#define __SIGEV_MAX_SIZE\t64\n#if __WORDSIZE == 64\n#define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 4)\n#else\n#define __SIGEV_PAD_SIZE\t((__SIGEV_MAX_SIZE / sizeof (int)) - 3)\n#endif\n\n/* Forward declaration.  */\n#ifndef __have_pthread_attr_t\ntypedef union pthread_attr_t pthread_attr_t;\n#define __have_pthread_attr_t\t1\n#endif\n\ntypedef struct sigevent {\n\tsigval_t sigev_value;\n\tint sigev_signo;\n\tint sigev_notify;\n\n\tunion {\n\t\tint _pad[__SIGEV_PAD_SIZE];\n\n\t\t/* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the\n\t\t   thread to receive the signal.  */\n\t\t__pid_t _tid;\n\n\t\tstruct {\n\t\t\tvoid (*_function) (sigval_t);\t/* Function to start.  */\n\t\t\tpthread_attr_t *_attribute;\t/* Thread attributes.  */\n\t\t} _sigev_thread;\n\t} _sigev_un;\n} sigevent_t;\n\n/* POSIX names to access some of the members.  */\n#define sigev_notify_function   _sigev_un._sigev_thread._function\n#define sigev_notify_attributes _sigev_un._sigev_thread._attribute\n\n/* `sigev_notify' values.  */\nenum {\n\tSIGEV_SIGNAL = 0,\t/* Notify via signal.  */\n#define SIGEV_SIGNAL\tSIGEV_SIGNAL\n\tSIGEV_NONE,\t\t/* Other notification: meaningless.  */\n#define SIGEV_NONE\tSIGEV_NONE\n\tSIGEV_THREAD,\t\t/* Deliver via thread creation.  */\n#define SIGEV_THREAD\tSIGEV_THREAD\n\n\tSIGEV_THREAD_ID = 4\t/* Send signal to specific thread.  */\n#define SIGEV_THREAD_ID\tSIGEV_THREAD_ID\n};\n\n#endif\t\t\t\t/* have _SIGNAL_H.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/signum.h",
    "content": "/* Signal number definitions.  Linux version.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifdef\t_SIGNAL_H\n\n/* Fake signal functions.  */\n#define SIG_ERR\t((__sighandler_t) -1)\t/* Error return.  */\n#define SIG_DFL\t((__sighandler_t) 0)\t/* Default action.  */\n#define SIG_IGN\t((__sighandler_t) 1)\t/* Ignore signal.  */\n\n#ifdef __USE_UNIX98\n#define SIG_HOLD\t((__sighandler_t) 2)\t/* Add signal to hold mask.  */\n#endif\n\n/* Signals.  */\n#define\tSIGHUP\t\t1\t/* Hangup (POSIX).  */\n#define\tSIGINT\t\t2\t/* Interrupt (ANSI).  */\n#define\tSIGQUIT\t\t3\t/* Quit (POSIX).  */\n#define\tSIGILL\t\t4\t/* Illegal instruction (ANSI).  */\n#define\tSIGTRAP\t\t5\t/* Trace trap (POSIX).  */\n#define\tSIGABRT\t\t6\t/* Abort (ANSI).  */\n#define\tSIGIOT\t\t6\t/* IOT trap (4.2 BSD).  */\n#define\tSIGBUS\t\t7\t/* BUS error (4.2 BSD).  */\n#define\tSIGFPE\t\t8\t/* Floating-point exception (ANSI).  */\n#define\tSIGKILL\t\t9\t/* Kill, unblockable (POSIX).  */\n#define\tSIGUSR1\t\t10\t/* User-defined signal 1 (POSIX).  */\n#define\tSIGSEGV\t\t11\t/* Segmentation violation (ANSI).  */\n#define\tSIGUSR2\t\t12\t/* User-defined signal 2 (POSIX).  */\n#define\tSIGPIPE\t\t13\t/* Broken pipe (POSIX).  */\n#define\tSIGALRM\t\t14\t/* Alarm clock (POSIX).  */\n#define\tSIGTERM\t\t15\t/* Termination (ANSI).  */\n#define\tSIGSTKFLT\t16\t/* Stack fault.  */\n#define\tSIGCLD\t\tSIGCHLD\t/* Same as SIGCHLD (System V).  */\n#define\tSIGCHLD\t\t17\t/* Child status has changed (POSIX).  */\n#define\tSIGCONT\t\t18\t/* Continue (POSIX).  */\n#define\tSIGSTOP\t\t19\t/* Stop, unblockable (POSIX).  */\n#define\tSIGTSTP\t\t20\t/* Keyboard stop (POSIX).  */\n#define\tSIGTTIN\t\t21\t/* Background read from tty (POSIX).  */\n#define\tSIGTTOU\t\t22\t/* Background write to tty (POSIX).  */\n#define\tSIGURG\t\t23\t/* Urgent condition on socket (4.2 BSD).  */\n#define\tSIGXCPU\t\t24\t/* CPU limit exceeded (4.2 BSD).  */\n#define\tSIGXFSZ\t\t25\t/* File size limit exceeded (4.2 BSD).  */\n#define\tSIGVTALRM\t26\t/* Virtual alarm clock (4.2 BSD).  */\n#define\tSIGPROF\t\t27\t/* Profiling alarm clock (4.2 BSD).  */\n#define\tSIGWINCH\t28\t/* Window size change (4.3 BSD, Sun).  */\n#define\tSIGPOLL\t\tSIGIO\t/* Pollable event occurred (System V).  */\n#define\tSIGIO\t\t29\t/* I/O now possible (4.2 BSD).  */\n#define\tSIGPWR\t\t30\t/* Power failure restart (System V).  */\n#define SIGSYS\t\t31\t/* Bad system call.  */\n#define SIGUNUSED\t31\n\n#define\t_NSIG\t\t65\t/* Biggest signal number + 1\n\t\t\t\t   (including real-time signals).  */\n\n#define SIGRTMIN        (__libc_current_sigrtmin ())\n#define SIGRTMAX        (__libc_current_sigrtmax ())\n\n/* These are the hard limits of the kernel.  These values should not be\n   used directly at user level.  */\n#define __SIGRTMIN\t32\n#define __SIGRTMAX\t(_NSIG - 1)\n\n#endif\t\t\t\t/* <signal.h> included.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigset.h",
    "content": "/* __sig_atomic_t, __sigset_t, and related definitions.  Linux version.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SIGSET_H_types\n#define _SIGSET_H_types\t1\n\ntypedef int __sig_atomic_t;\n\n/* A `sigset_t' has a bit for each signal.  */\n\n#define _SIGSET_NWORDS\t(1024 / (8 * sizeof (unsigned long int)))\ntypedef struct {\n\tunsigned long int __val[_SIGSET_NWORDS];\n} __sigset_t;\n\n#endif\n\n/* We only want to define these functions if <signal.h> was actually\n   included; otherwise we were included just to define the types.  Since we\n   are namespace-clean, it wouldn't hurt to define extra macros.  But\n   trouble can be caused by functions being defined (e.g., any global\n   register vars declared later will cause compilation errors).  */\n\n#if !defined _SIGSET_H_fns && defined _SIGNAL_H\n#define _SIGSET_H_fns 1\n\n#ifndef _EXTERN_INLINE\n#define _EXTERN_INLINE __extern_inline\n#endif\n\n/* Return a mask that includes the bit for SIG only.  */\n#define __sigmask(sig) \\\n  (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))\n\n/* Return the word index for SIG.  */\n#define __sigword(sig)\t(((sig) - 1) / (8 * sizeof (unsigned long int)))\n\n#if defined __GNUC__ && __GNUC__ >= 2\n#define __sigemptyset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__set = (set);\t\t\t\t      \\\n\t\t    while (--__cnt >= 0) __set->__val[__cnt] = 0;\t      \\\n\t\t    0; }))\n#define __sigfillset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__set = (set);\t\t\t\t      \\\n\t\t    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;\t      \\\n\t\t    0; }))\n\n#ifdef __USE_GNU\n/* The POSIX does not specify for handling the whole signal set in one\n   command.  This is often wanted and so we define three more functions\n   here.  */\n#define __sigisemptyset(set) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    const sigset_t *__set = (set);\t\t\t      \\\n\t\t    int __ret = __set->__val[--__cnt];\t\t\t      \\\n\t\t    while (!__ret && --__cnt >= 0)\t\t\t      \\\n\t\t\t__ret = __set->__val[__cnt];\t\t\t      \\\n\t\t    __ret == 0; }))\n#define __sigandset(dest, left, right) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__dest = (dest);\t\t\t\t      \\\n\t\t    const sigset_t *__left = (left);\t\t\t      \\\n\t\t    const sigset_t *__right = (right);\t\t\t      \\\n\t\t    while (--__cnt >= 0)\t\t\t\t      \\\n\t\t      __dest->__val[__cnt] = (__left->__val[__cnt]\t      \\\n\t\t\t\t\t      & __right->__val[__cnt]);\t      \\\n\t\t    0; }))\n#define __sigorset(dest, left, right) \\\n  (__extension__ ({ int __cnt = _SIGSET_NWORDS;\t\t\t\t      \\\n\t\t    sigset_t *__dest = (dest);\t\t\t\t      \\\n\t\t    const sigset_t *__left = (left);\t\t\t      \\\n\t\t    const sigset_t *__right = (right);\t\t\t      \\\n\t\t    while (--__cnt >= 0)\t\t\t\t      \\\n\t\t      __dest->__val[__cnt] = (__left->__val[__cnt]\t      \\\n\t\t\t\t\t      | __right->__val[__cnt]);\t      \\\n\t\t    0; }))\n#endif\n#endif\n\n/* These functions needn't check for a bogus signal number -- error\n   checking is done in the non __ versions.  */\n\nextern int __sigismember(const __sigset_t *, int);\nextern int __sigaddset(__sigset_t *, int);\nextern int __sigdelset(__sigset_t *, int);\n\n#ifdef __USE_EXTERN_INLINES\n#define __SIGSETFN(NAME, BODY, CONST)\t\t\t\t\t      \\\n  _EXTERN_INLINE int\t\t\t\t\t\t\t      \\\n  NAME (CONST __sigset_t *__set, int __sig)\t\t\t\t      \\\n  {\t\t\t\t\t\t\t\t\t      \\\n    unsigned long int __mask = __sigmask (__sig);\t\t\t      \\\n    unsigned long int __word = __sigword (__sig);\t\t\t      \\\n    return BODY;\t\t\t\t\t\t\t      \\\n  }\n\n__SIGSETFN(__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, const) __SIGSETFN(__sigaddset, ((__set->__val[__word] |= __mask), 0),) __SIGSETFN(__sigdelset, ((__set->__val[__word] &= ~__mask), 0),)\n#undef __SIGSETFN\n#endif\n#endif\t\t\t\t/* ! _SIGSET_H_fns.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigstack.h",
    "content": "/* sigstack, sigaltstack definitions.\n   Copyright (C) 1998-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SIGNAL_H\n#error \"Never include this file directly.  Use <signal.h> instead\"\n#endif\n\n/* Structure describing a signal stack (obsolete).  */\nstruct sigstack {\n\tvoid *ss_sp;\t\t/* Signal stack pointer.  */\n\tint ss_onstack;\t\t/* Nonzero if executing on this stack.  */\n};\n\n/* Possible values for `ss_flags.'.  */\nenum {\n\tSS_ONSTACK = 1,\n#define SS_ONSTACK\tSS_ONSTACK\n\tSS_DISABLE\n#define SS_DISABLE\tSS_DISABLE\n};\n\n/* Minimum stack size for a signal handler.  */\n#define MINSIGSTKSZ\t2048\n\n/* System default stack size.  */\n#define SIGSTKSZ\t8192\n\n/* Alternate, preferred interface.  */\ntypedef struct sigaltstack {\n\tvoid *ss_sp;\n\tint ss_flags;\n\tsize_t ss_size;\n} stack_t;\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sigthread.h",
    "content": "/* Signal handling function for threaded programs.\n   Copyright (C) 1998-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public License as\n   published by the Free Software Foundation; either version 2.1 of the\n   License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; see the file COPYING.LIB.  If\n   not, see <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_SIGTHREAD_H\n#define _BITS_SIGTHREAD_H\t1\n\n#if !defined _SIGNAL_H && !defined _PTHREAD_H\n#error \"Never include this file directly.  Use <pthread.h> instead\"\n#endif\n\n/* Functions for handling signals. */\n\n/* Modify the signal mask for the calling thread.  The arguments have\n   the same meaning as for sigprocmask(2). */\nextern int pthread_sigmask(int __how, const __sigset_t * __restrict __newmask, __sigset_t * __restrict __oldmask) __THROW;\n\n/* Send signal SIGNO to the given thread. */\nextern int pthread_kill(pthread_t __threadid, int __signo) __THROW;\n\n#ifdef __USE_GNU\n/* Queue signal and data to a thread.  */\nextern int pthread_sigqueue(pthread_t __threadid, int __signo, const union sigval __value) __THROW;\n#endif\n\n#endif\t\t\t\t/* bits/sigthread.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sockaddr.h",
    "content": "/* Definition of struct sockaddr_* common members and sizes, generic version.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/socket.h> instead.\n */\n\n#ifndef _BITS_SOCKADDR_H\n#define _BITS_SOCKADDR_H\t1\n\n/* POSIX.1g specifies this type name for the `sa_family' member.  */\ntypedef unsigned short int sa_family_t;\n\n/* This macro is used to declare the initial common members\n   of the data types used for socket addresses, `struct sockaddr',\n   `struct sockaddr_in', `struct sockaddr_un', etc.  */\n\n#define\t__SOCKADDR_COMMON(sa_prefix) \\\n  sa_family_t sa_prefix##family\n\n#define __SOCKADDR_COMMON_SIZE\t(sizeof (unsigned short int))\n\n/* Size of struct sockaddr_storage.  */\n#define _SS_SIZE 128\n\n#endif\t\t\t\t/* bits/sockaddr.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/socket.h",
    "content": "/* System-specific socket constants and types.  Linux version.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef __BITS_SOCKET_H\n#define __BITS_SOCKET_H\n\n#ifndef _SYS_SOCKET_H\n#error \"Never include <bits/socket.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n#define __need_size_t\n#include <stddef.h>\n\n#include <sys/types.h>\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n#define __socklen_t_defined\n#endif\n\n/* Get the architecture-dependent definition of enum __socket_type.  */\n#include <bits/socket_type.h>\n\n/* Protocol families.  */\n#define PF_UNSPEC\t0\t/* Unspecified.  */\n#define PF_LOCAL\t1\t/* Local to host (pipes and file-domain).  */\n#define PF_UNIX\t\tPF_LOCAL\t/* POSIX name for PF_LOCAL.  */\n#define PF_FILE\t\tPF_LOCAL\t/* Another non-standard name for PF_LOCAL.  */\n#define PF_INET\t\t2\t/* IP protocol family.  */\n#define PF_AX25\t\t3\t/* Amateur Radio AX.25.  */\n#define PF_IPX\t\t4\t/* Novell Internet Protocol.  */\n#define PF_APPLETALK\t5\t/* Appletalk DDP.  */\n#define PF_NETROM\t6\t/* Amateur radio NetROM.  */\n#define PF_BRIDGE\t7\t/* Multiprotocol bridge.  */\n#define PF_ATMPVC\t8\t/* ATM PVCs.  */\n#define PF_X25\t\t9\t/* Reserved for X.25 project.  */\n#define PF_INET6\t10\t/* IP version 6.  */\n#define PF_ROSE\t\t11\t/* Amateur Radio X.25 PLP.  */\n#define PF_DECnet\t12\t/* Reserved for DECnet project.  */\n#define PF_NETBEUI\t13\t/* Reserved for 802.2LLC project.  */\n#define PF_SECURITY\t14\t/* Security callback pseudo AF.  */\n#define PF_KEY\t\t15\t/* PF_KEY key management API.  */\n#define PF_NETLINK\t16\n#define PF_ROUTE\tPF_NETLINK\t/* Alias to emulate 4.4BSD.  */\n#define PF_PACKET\t17\t/* Packet family.  */\n#define PF_ASH\t\t18\t/* Ash.  */\n#define PF_ECONET\t19\t/* Acorn Econet.  */\n#define PF_ATMSVC\t20\t/* ATM SVCs.  */\n#define PF_RDS\t\t21\t/* RDS sockets.  */\n#define PF_SNA\t\t22\t/* Linux SNA Project */\n#define PF_IRDA\t\t23\t/* IRDA sockets.  */\n#define PF_PPPOX\t24\t/* PPPoX sockets.  */\n#define PF_WANPIPE\t25\t/* Wanpipe API sockets.  */\n#define PF_LLC\t\t26\t/* Linux LLC.  */\n#define PF_IB\t\t27\t/* Native InfiniBand address.  */\n#define PF_MPLS\t\t28\t/* MPLS.  */\n#define PF_CAN\t\t29\t/* Controller Area Network.  */\n#define PF_TIPC\t\t30\t/* TIPC sockets.  */\n#define PF_BLUETOOTH\t31\t/* Bluetooth sockets.  */\n#define PF_IUCV\t\t32\t/* IUCV sockets.  */\n#define PF_RXRPC\t33\t/* RxRPC sockets.  */\n#define PF_ISDN\t\t34\t/* mISDN sockets.  */\n#define PF_PHONET\t35\t/* Phonet sockets.  */\n#define PF_IEEE802154\t36\t/* IEEE 802.15.4 sockets.  */\n#define PF_CAIF\t\t37\t/* CAIF sockets.  */\n#define PF_ALG\t\t38\t/* Algorithm sockets.  */\n#define PF_NFC\t\t39\t/* NFC sockets.  */\n#define PF_VSOCK\t40\t/* vSockets.  */\n#define PF_KCM\t\t41\t/* Kernel Connection Multiplexor.  */\n#define PF_MAX\t\t42\t/* For now..  */\n\n/* Address families.  */\n#define AF_UNSPEC\tPF_UNSPEC\n#define AF_LOCAL\tPF_LOCAL\n#define AF_UNIX\t\tPF_UNIX\n#define AF_FILE\t\tPF_FILE\n#define AF_INET\t\tPF_INET\n#define AF_AX25\t\tPF_AX25\n#define AF_IPX\t\tPF_IPX\n#define AF_APPLETALK\tPF_APPLETALK\n#define AF_NETROM\tPF_NETROM\n#define AF_BRIDGE\tPF_BRIDGE\n#define AF_ATMPVC\tPF_ATMPVC\n#define AF_X25\t\tPF_X25\n#define AF_INET6\tPF_INET6\n#define AF_ROSE\t\tPF_ROSE\n#define AF_DECnet\tPF_DECnet\n#define AF_NETBEUI\tPF_NETBEUI\n#define AF_SECURITY\tPF_SECURITY\n#define AF_KEY\t\tPF_KEY\n#define AF_NETLINK\tPF_NETLINK\n#define AF_ROUTE\tPF_ROUTE\n#define AF_PACKET\tPF_PACKET\n#define AF_ASH\t\tPF_ASH\n#define AF_ECONET\tPF_ECONET\n#define AF_ATMSVC\tPF_ATMSVC\n#define AF_RDS\t\tPF_RDS\n#define AF_SNA\t\tPF_SNA\n#define AF_IRDA\t\tPF_IRDA\n#define AF_PPPOX\tPF_PPPOX\n#define AF_WANPIPE\tPF_WANPIPE\n#define AF_LLC\t\tPF_LLC\n#define AF_IB\t\tPF_IB\n#define AF_MPLS\t\tPF_MPLS\n#define AF_CAN\t\tPF_CAN\n#define AF_TIPC\t\tPF_TIPC\n#define AF_BLUETOOTH\tPF_BLUETOOTH\n#define AF_IUCV\t\tPF_IUCV\n#define AF_RXRPC\tPF_RXRPC\n#define AF_ISDN\t\tPF_ISDN\n#define AF_PHONET\tPF_PHONET\n#define AF_IEEE802154\tPF_IEEE802154\n#define AF_CAIF\t\tPF_CAIF\n#define AF_ALG\t\tPF_ALG\n#define AF_NFC\t\tPF_NFC\n#define AF_VSOCK\tPF_VSOCK\n#define AF_KCM\t\tPF_KCM\n#define AF_MAX\t\tPF_MAX\n\n/* Socket level values.  Others are defined in the appropriate headers.\n\n   XXX These definitions also should go into the appropriate headers as\n   far as they are available.  */\n#define SOL_RAW\t\t255\n#define SOL_DECNET      261\n#define SOL_X25         262\n#define SOL_PACKET\t263\n#define SOL_ATM\t\t264\t/* ATM layer (cell level).  */\n#define SOL_AAL\t\t265\t/* ATM Adaption Layer (packet level).  */\n#define SOL_IRDA\t266\n#define SOL_NETBEUI\t267\n#define SOL_LLC\t\t268\n#define SOL_DCCP\t269\n#define SOL_NETLINK\t270\n#define SOL_TIPC\t271\n#define SOL_RXRPC\t272\n#define SOL_PPPOL2TP\t273\n#define SOL_BLUETOOTH\t274\n#define SOL_PNPIPE\t275\n#define SOL_RDS\t\t276\n#define SOL_IUCV\t277\n#define SOL_CAIF\t278\n#define SOL_ALG\t\t279\n#define SOL_NFC\t\t280\n#define SOL_KCM\t\t281\n\n/* Maximum queue length specifiable by listen.  */\n#define SOMAXCONN\t128\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n/* Structure describing a generic socket address.  */\nstruct sockaddr {\n\t__SOCKADDR_COMMON(sa_);\t/* Common data: address family and length.  */\n\tchar sa_data[14];\t/* Address data.  */\n};\n\n/* Structure large enough to hold any socket address (with the historical\n   exception of AF_UNIX).  */\n#define __ss_aligntype\tunsigned long int\n#define _SS_PADSIZE \\\n  (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))\n\nstruct sockaddr_storage {\n\t__SOCKADDR_COMMON(ss_);\t/* Address family, etc.  */\n\tchar __ss_padding[_SS_PADSIZE];\n\t__ss_aligntype __ss_align;\t/* Force desired alignment.  */\n};\n\n/* Bits in the FLAGS argument to `send', `recv', et al.  */\nenum {\n\tMSG_OOB = 0x01,\t\t/* Process out-of-band data.  */\n#define MSG_OOB\t\tMSG_OOB\n\tMSG_PEEK = 0x02,\t/* Peek at incoming messages.  */\n#define MSG_PEEK\tMSG_PEEK\n\tMSG_DONTROUTE = 0x04,\t/* Don't use local routing.  */\n#define MSG_DONTROUTE\tMSG_DONTROUTE\n#ifdef __USE_GNU\n\t/* DECnet uses a different name.  */\n\tMSG_TRYHARD = MSG_DONTROUTE,\n#define MSG_TRYHARD\tMSG_DONTROUTE\n#endif\n\tMSG_CTRUNC = 0x08,\t/* Control data lost before delivery.  */\n#define MSG_CTRUNC\tMSG_CTRUNC\n\tMSG_PROXY = 0x10,\t/* Supply or ask second address.  */\n#define MSG_PROXY\tMSG_PROXY\n\tMSG_TRUNC = 0x20,\n#define MSG_TRUNC\tMSG_TRUNC\n\tMSG_DONTWAIT = 0x40,\t/* Nonblocking IO.  */\n#define MSG_DONTWAIT\tMSG_DONTWAIT\n\tMSG_EOR = 0x80,\t\t/* End of record.  */\n#define MSG_EOR\t\tMSG_EOR\n\tMSG_WAITALL = 0x100,\t/* Wait for a full request.  */\n#define MSG_WAITALL\tMSG_WAITALL\n\tMSG_FIN = 0x200,\n#define MSG_FIN\t\tMSG_FIN\n\tMSG_SYN = 0x400,\n#define MSG_SYN\t\tMSG_SYN\n\tMSG_CONFIRM = 0x800,\t/* Confirm path validity.  */\n#define MSG_CONFIRM\tMSG_CONFIRM\n\tMSG_RST = 0x1000,\n#define MSG_RST\t\tMSG_RST\n\tMSG_ERRQUEUE = 0x2000,\t/* Fetch message from error queue.  */\n#define MSG_ERRQUEUE\tMSG_ERRQUEUE\n\tMSG_NOSIGNAL = 0x4000,\t/* Do not generate SIGPIPE.  */\n#define MSG_NOSIGNAL\tMSG_NOSIGNAL\n\tMSG_MORE = 0x8000,\t/* Sender will send more.  */\n#define MSG_MORE\tMSG_MORE\n\tMSG_WAITFORONE = 0x10000,\t/* Wait for at least one packet to return. */\n#define MSG_WAITFORONE\tMSG_WAITFORONE\n\tMSG_BATCH = 0x40000,\t/* sendmmsg: more messages coming.  */\n#define MSG_BATCH\tMSG_BATCH\n\tMSG_FASTOPEN = 0x20000000,\t/* Send data in TCP SYN.  */\n#define MSG_FASTOPEN\tMSG_FASTOPEN\n\n\tMSG_CMSG_CLOEXEC = 0x40000000\t/* Set close_on_exit for file\n\t\t\t\t\t   descriptor received through\n\t\t\t\t\t   SCM_RIGHTS.  */\n#define MSG_CMSG_CLOEXEC MSG_CMSG_CLOEXEC\n};\n\n/* Structure describing messages sent by\n   `sendmsg' and received by `recvmsg'.  */\nstruct msghdr {\n\tvoid *msg_name;\t\t/* Address to send to/receive from.  */\n\tsocklen_t msg_namelen;\t/* Length of address data.  */\n\n\tstruct iovec *msg_iov;\t/* Vector of data to send/receive into.  */\n\tsize_t msg_iovlen;\t/* Number of elements in the vector.  */\n\n\tvoid *msg_control;\t/* Ancillary data (eg BSD filedesc passing). */\n\tsize_t msg_controllen;\t/* Ancillary data buffer length.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\n\tint msg_flags;\t\t/* Flags on received message.  */\n};\n\n/* Structure used for storage of ancillary data object information.  */\nstruct cmsghdr {\n\tsize_t cmsg_len;\t/* Length of data in cmsg_data plus length\n\t\t\t\t   of cmsghdr structure.\n\t\t\t\t   !! The type should be socklen_t but the\n\t\t\t\t   definition of the kernel is incompatible\n\t\t\t\t   with this.  */\n\tint cmsg_level;\t\t/* Originating protocol.  */\n\tint cmsg_type;\t\t/* Protocol specific type.  */\n#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L\n\t__extension__ unsigned char __cmsg_data __flexarr;\t/* Ancillary data.  */\n#endif\n};\n\n/* Ancillary data object manipulation macros.  */\n#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L\n#define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)\n#else\n#define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))\n#endif\n#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)\n#define CMSG_FIRSTHDR(mhdr) \\\n  ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr)\t\t      \\\n   ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)\n#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \\\n\t\t\t & (size_t) ~(sizeof (size_t) - 1))\n#define CMSG_SPACE(len) (CMSG_ALIGN (len) \\\n\t\t\t + CMSG_ALIGN (sizeof (struct cmsghdr)))\n#define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))\n\nextern struct cmsghdr *__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW;\n#ifdef __USE_EXTERN_INLINES\n#ifndef _EXTERN_INLINE\n#define _EXTERN_INLINE __extern_inline\n#endif\n_EXTERN_INLINE struct cmsghdr *__NTH(__cmsg_nxthdr(struct msghdr *__mhdr, struct cmsghdr *__cmsg))\n{\n\tif ((size_t) __cmsg->cmsg_len < sizeof(struct cmsghdr))\n\t\t/* The kernel header does this so there may be a reason.  */\n\t\treturn (struct cmsghdr *)0;\n\n\t__cmsg = (struct cmsghdr *)((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len));\n\tif ((unsigned char *)(__cmsg + 1) > ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)\n\t    || ((unsigned char *)__cmsg + CMSG_ALIGN(__cmsg->cmsg_len)\n\t\t> ((unsigned char *)__mhdr->msg_control + __mhdr->msg_controllen)))\n\t\t/* No more entries.  */\n\t\treturn (struct cmsghdr *)0;\n\treturn __cmsg;\n}\n#endif\t\t\t\t/* Use `extern inline'.  */\n\n/* Socket level message types.  This must match the definitions in\n   <linux/socket.h>.  */\nenum {\n\tSCM_RIGHTS = 0x01\t/* Transfer file descriptors.  */\n#define SCM_RIGHTS SCM_RIGHTS\n#ifdef __USE_GNU\n\t    , SCM_CREDENTIALS = 0x02\t/* Credentials passing.  */\n#define SCM_CREDENTIALS SCM_CREDENTIALS\n#endif\n};\n\n#ifdef __USE_GNU\n/* User visible structure for SCM_CREDENTIALS message */\nstruct ucred {\n\tpid_t pid;\t\t/* PID of sending process.  */\n\tuid_t uid;\t\t/* UID of sending process.  */\n\tgid_t gid;\t\t/* GID of sending process.  */\n};\n#endif\n\n/* Ugly workaround for unclean kernel headers.  */\n#ifndef __USE_MISC\n#ifndef FIOGETOWN\n#define __SYS_SOCKET_H_undef_FIOGETOWN\n#endif\n#ifndef FIOSETOWN\n#define __SYS_SOCKET_H_undef_FIOSETOWN\n#endif\n#ifndef SIOCATMARK\n#define __SYS_SOCKET_H_undef_SIOCATMARK\n#endif\n#ifndef SIOCGPGRP\n#define __SYS_SOCKET_H_undef_SIOCGPGRP\n#endif\n#ifndef SIOCGSTAMP\n#define __SYS_SOCKET_H_undef_SIOCGSTAMP\n#endif\n#ifndef SIOCGSTAMPNS\n#define __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#endif\n#ifndef SIOCSPGRP\n#define __SYS_SOCKET_H_undef_SIOCSPGRP\n#endif\n#endif\n\n/* Get socket manipulation related informations from kernel headers.  */\n#include <asm/socket.h>\n\n#ifndef __USE_MISC\n#ifdef __SYS_SOCKET_H_undef_FIOGETOWN\n#undef __SYS_SOCKET_H_undef_FIOGETOWN\n#undef FIOGETOWN\n#endif\n#ifdef __SYS_SOCKET_H_undef_FIOSETOWN\n#undef __SYS_SOCKET_H_undef_FIOSETOWN\n#undef FIOSETOWN\n#endif\n#ifdef __SYS_SOCKET_H_undef_SIOCATMARK\n#undef __SYS_SOCKET_H_undef_SIOCATMARK\n#undef SIOCATMARK\n#endif\n#ifdef __SYS_SOCKET_H_undef_SIOCGPGRP\n#undef __SYS_SOCKET_H_undef_SIOCGPGRP\n#undef SIOCGPGRP\n#endif\n#ifdef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#undef __SYS_SOCKET_H_undef_SIOCGSTAMP\n#undef SIOCGSTAMP\n#endif\n#ifdef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#undef __SYS_SOCKET_H_undef_SIOCGSTAMPNS\n#undef SIOCGSTAMPNS\n#endif\n#ifdef __SYS_SOCKET_H_undef_SIOCSPGRP\n#undef __SYS_SOCKET_H_undef_SIOCSPGRP\n#undef SIOCSPGRP\n#endif\n#endif\n\n/* Structure used to manipulate the SO_LINGER option.  */\nstruct linger {\n\tint l_onoff;\t\t/* Nonzero to linger on close.  */\n\tint l_linger;\t\t/* Time to linger.  */\n};\n\n#endif\t\t\t\t/* bits/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/socket_type.h",
    "content": "/* Define enum __socket_type for generic Linux.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SOCKET_H\n#error \"Never include <bits/socket_type.h> directly; use <sys/socket.h> instead.\"\n#endif\n\n/* Types of sockets.  */\nenum __socket_type {\n\tSOCK_STREAM = 1,\t/* Sequenced, reliable, connection-based\n\t\t\t\t   byte streams.  */\n#define SOCK_STREAM SOCK_STREAM\n\tSOCK_DGRAM = 2,\t\t/* Connectionless, unreliable datagrams\n\t\t\t\t   of fixed maximum length.  */\n#define SOCK_DGRAM SOCK_DGRAM\n\tSOCK_RAW = 3,\t\t/* Raw protocol interface.  */\n#define SOCK_RAW SOCK_RAW\n\tSOCK_RDM = 4,\t\t/* Reliably-delivered messages.  */\n#define SOCK_RDM SOCK_RDM\n\tSOCK_SEQPACKET = 5,\t/* Sequenced, reliable, connection-based,\n\t\t\t\t   datagrams of fixed maximum length.  */\n#define SOCK_SEQPACKET SOCK_SEQPACKET\n\tSOCK_DCCP = 6,\t\t/* Datagram Congestion Control Protocol.  */\n#define SOCK_DCCP SOCK_DCCP\n\tSOCK_PACKET = 10,\t/* Linux specific way of getting packets\n\t\t\t\t   at the dev level.  For writing rarp and\n\t\t\t\t   other similar things on the user level. */\n#define SOCK_PACKET SOCK_PACKET\n\n\t/* Flags to be ORed into the type parameter of socket and socketpair and\n\t   used for the flags parameter of paccept.  */\n\n\tSOCK_CLOEXEC = 02000000,\t/* Atomically set close-on-exec flag for the\n\t\t\t\t\t   new descriptor(s).  */\n#define SOCK_CLOEXEC SOCK_CLOEXEC\n\tSOCK_NONBLOCK = 00004000\t/* Atomically mark descriptor(s) as\n\t\t\t\t\t   non-blocking.  */\n#define SOCK_NONBLOCK SOCK_NONBLOCK\n};\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/stat.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_STAT_H && !defined _FCNTL_H\n#error \"Never include <bits/stat.h> directly; use <sys/stat.h> instead.\"\n#endif\n\n#ifndef _BITS_STAT_H\n#define _BITS_STAT_H\t1\n\n/* Versions of the `struct stat' data structure.  */\n#define _STAT_VER_LINUX_OLD\t1\n#define _STAT_VER_KERNEL\t1\n#define _STAT_VER_SVR4\t\t2\n#define _STAT_VER_LINUX\t\t3\n#define _STAT_VER\t\t_STAT_VER_LINUX\t/* The one defined below.  */\n\n/* Versions of the `xmknod' interface.  */\n#define _MKNOD_VER_LINUX\t1\n#define _MKNOD_VER_SVR4\t\t2\n#define _MKNOD_VER\t\t_MKNOD_VER_LINUX\t/* The bits defined below.  */\n\nstruct stat {\n\t__dev_t st_dev;\t\t/* Device.  */\n\tunsigned short int __pad1;\n#ifndef __USE_FILE_OFFSET64\n\t__ino_t st_ino;\t\t/* File serial number.  */\n#else\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n#endif\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\tunsigned short int __pad2;\n#ifndef __USE_FILE_OFFSET64\n\t__off_t st_size;\t/* Size of file, in bytes.  */\n#else\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n#endif\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n\n#ifndef __USE_FILE_OFFSET64\n\t__blkcnt_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#else\n\t__blkcnt64_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#endif\n#ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n#define st_atime st_atim.tv_sec\t/* Backward compatibility.  */\n#define st_mtime st_mtim.tv_sec\n#define st_ctime st_ctim.tv_sec\n#else\n\t__time_t st_atime;\t/* Time of last access.  */\n\tunsigned long int st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\tunsigned long int st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\tunsigned long int st_ctimensec;\t/* Nsecs of last status change.  */\n#endif\n#ifndef __USE_FILE_OFFSET64\n\tunsigned long int __glibc_reserved4;\n\tunsigned long int __glibc_reserved5;\n#else\n\t__ino64_t st_ino;\t/* File serial number.  */\n#endif\n};\n\n#ifdef __USE_LARGEFILE64\nstruct stat64 {\n\t__dev_t st_dev;\t\t/* Device.  */\n\tunsigned int __pad1;\n\n\t__ino_t __st_ino;\t/* 32bit file serial number.    */\n\t__mode_t st_mode;\t/* File mode.  */\n\t__nlink_t st_nlink;\t/* Link count.  */\n\t__uid_t st_uid;\t\t/* User ID of the file's owner. */\n\t__gid_t st_gid;\t\t/* Group ID of the file's group. */\n\t__dev_t st_rdev;\t/* Device number, if device.  */\n\tunsigned int __pad2;\n\t__off64_t st_size;\t/* Size of file, in bytes.  */\n\t__blksize_t st_blksize;\t/* Optimal block size for I/O.  */\n\n\t__blkcnt64_t st_blocks;\t/* Number 512-byte blocks allocated. */\n#ifdef __USE_XOPEN2K8\n\t/* Nanosecond resolution timestamps are stored in a format\n\t   equivalent to 'struct timespec'.  This is the type used\n\t   whenever possible but the Unix namespace rules do not allow the\n\t   identifier 'timespec' to appear in the <sys/stat.h> header.\n\t   Therefore we have to handle the use of this header in strictly\n\t   standard-compliant sources special.  */\n\tstruct timespec st_atim;\t/* Time of last access.  */\n\tstruct timespec st_mtim;\t/* Time of last modification.  */\n\tstruct timespec st_ctim;\t/* Time of last status change.  */\n#else\n\t__time_t st_atime;\t/* Time of last access.  */\n\tunsigned long int st_atimensec;\t/* Nscecs of last access.  */\n\t__time_t st_mtime;\t/* Time of last modification.  */\n\tunsigned long int st_mtimensec;\t/* Nsecs of last modification.  */\n\t__time_t st_ctime;\t/* Time of last status change.  */\n\tunsigned long int st_ctimensec;\t/* Nsecs of last status change.  */\n#endif\n\t__ino64_t st_ino;\t/* File serial number.          */\n};\n#endif\n\n/* Tell code we have these members.  */\n#define\t_STATBUF_ST_BLKSIZE\n#define _STATBUF_ST_RDEV\n/* Nanosecond resolution time values are supported.  */\n#define _STATBUF_ST_NSEC\n\n/* Encoding of the file mode.  */\n\n#define\t__S_IFMT\t0170000\t/* These bits determine file type.  */\n\n/* File types.  */\n#define\t__S_IFDIR\t0040000\t/* Directory.  */\n#define\t__S_IFCHR\t0020000\t/* Character device.  */\n#define\t__S_IFBLK\t0060000\t/* Block device.  */\n#define\t__S_IFREG\t0100000\t/* Regular file.  */\n#define\t__S_IFIFO\t0010000\t/* FIFO.  */\n#define\t__S_IFLNK\t0120000\t/* Symbolic link.  */\n#define\t__S_IFSOCK\t0140000\t/* Socket.  */\n\n/* POSIX.1b objects.  Note that these macros always evaluate to zero.  But\n   they do it by enforcing the correct use of the macros.  */\n#define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)\n#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)\n\n/* Protection bits.  */\n\n#define\t__S_ISUID\t04000\t/* Set user ID on execution.  */\n#define\t__S_ISGID\t02000\t/* Set group ID on execution.  */\n#define\t__S_ISVTX\t01000\t/* Save swapped text after use (sticky).  */\n#define\t__S_IREAD\t0400\t/* Read by owner.  */\n#define\t__S_IWRITE\t0200\t/* Write by owner.  */\n#define\t__S_IEXEC\t0100\t/* Execute by owner.  */\n\n#ifdef __USE_ATFILE\n#define UTIME_NOW\t((1l << 30) - 1l)\n#define UTIME_OMIT\t((1l << 30) - 2l)\n#endif\n\n#endif\t\t\t\t/* bits/stat.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/statfs.h",
    "content": "/* Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_STATFS_H\n#error \"Never include <bits/statfs.h> directly; use <sys/statfs.h> instead.\"\n#endif\n\n#include <bits/types.h>\n\nstruct statfs {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n#ifndef __USE_FILE_OFFSET64\n\t__fsblkcnt_t f_blocks;\n\t__fsblkcnt_t f_bfree;\n\t__fsblkcnt_t f_bavail;\n\t__fsfilcnt_t f_files;\n\t__fsfilcnt_t f_ffree;\n#else\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n#endif\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n\n#ifdef __USE_LARGEFILE64\nstruct statfs64 {\n\t__fsword_t f_type;\n\t__fsword_t f_bsize;\n\t__fsblkcnt64_t f_blocks;\n\t__fsblkcnt64_t f_bfree;\n\t__fsblkcnt64_t f_bavail;\n\t__fsfilcnt64_t f_files;\n\t__fsfilcnt64_t f_ffree;\n\t__fsid_t f_fsid;\n\t__fsword_t f_namelen;\n\t__fsword_t f_frsize;\n\t__fsword_t f_flags;\n\t__fsword_t f_spare[4];\n};\n#endif\n\n/* Tell code we have these members.  */\n#define _STATFS_F_NAMELEN\n#define _STATFS_F_FRSIZE\n#define _STATFS_F_FLAGS\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/stdio_lim.h",
    "content": "/* Copyright (C) 1994-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _STDIO_H && !defined __need_FOPEN_MAX && !defined __need_IOV_MAX\n#error \"Never include <bits/stdio_lim.h> directly; use <stdio.h> instead.\"\n#endif\n\n#ifdef _STDIO_H\n#define L_tmpnam 20\n#define TMP_MAX 238328\n#define FILENAME_MAX 4096\n\n#ifdef __USE_POSIX\n#define L_ctermid 9\n#if !defined __USE_XOPEN2K || defined __USE_GNU\n#define L_cuserid 9\n#endif\n#endif\n#endif\n\n#if defined __need_FOPEN_MAX || defined _STDIO_H\n#undef  FOPEN_MAX\n#define FOPEN_MAX 16\n#endif\n\n#if defined __need_IOV_MAX && !defined IOV_MAX\n#define IOV_MAX 1024\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/stdlib-float.h",
    "content": "/* Floating-point inline functions for stdlib.h.\n   Copyright (C) 2012-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDLIB_H\n#error \"Never use <bits/stdlib-float.h> directly; include <stdlib.h> instead.\"\n#endif\n\n#ifdef __USE_EXTERN_INLINES\n__BEGIN_NAMESPACE_STD __extern_inline double __NTH(atof(const char *__nptr))\n{\n\treturn strtod(__nptr, (char **)NULL);\n}\n\n__END_NAMESPACE_STD\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/sys_errlist.h",
    "content": "/* Declare sys_errlist and sys_nerr, or don't.  Compatibility (do) version.\n   Copyright (C) 2002-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _STDIO_H\n#error \"Never include <bits/sys_errlist.h> directly; use <stdio.h> instead.\"\n#endif\n\n/* sys_errlist and sys_nerr are deprecated.  Use strerror instead.  */\n\n#ifdef  __USE_MISC\nextern int sys_nerr;\nextern const char *const sys_errlist[];\n#endif\n#ifdef  __USE_GNU\nextern int _sys_nerr;\nextern const char *const _sys_errlist[];\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/termios.h",
    "content": "/* termios type and macro definitions.  Linux version.\n   Copyright (C) 1993-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _TERMIOS_H\n#error \"Never include <bits/termios.h> directly; use <termios.h> instead.\"\n#endif\n\ntypedef unsigned char cc_t;\ntypedef unsigned int speed_t;\ntypedef unsigned int tcflag_t;\n\n#define NCCS 32\nstruct termios {\n\ttcflag_t c_iflag;\t/* input mode flags */\n\ttcflag_t c_oflag;\t/* output mode flags */\n\ttcflag_t c_cflag;\t/* control mode flags */\n\ttcflag_t c_lflag;\t/* local mode flags */\n\tcc_t c_line;\t\t/* line discipline */\n\tcc_t c_cc[NCCS];\t/* control characters */\n\tspeed_t c_ispeed;\t/* input speed */\n\tspeed_t c_ospeed;\t/* output speed */\n#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1\n#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1\n};\n\n/* c_cc characters */\n#define VINTR 0\n#define VQUIT 1\n#define VERASE 2\n#define VKILL 3\n#define VEOF 4\n#define VTIME 5\n#define VMIN 6\n#define VSWTC 7\n#define VSTART 8\n#define VSTOP 9\n#define VSUSP 10\n#define VEOL 11\n#define VREPRINT 12\n#define VDISCARD 13\n#define VWERASE 14\n#define VLNEXT 15\n#define VEOL2 16\n\n/* c_iflag bits */\n#define IGNBRK\t0000001\n#define BRKINT\t0000002\n#define IGNPAR\t0000004\n#define PARMRK\t0000010\n#define INPCK\t0000020\n#define ISTRIP\t0000040\n#define INLCR\t0000100\n#define IGNCR\t0000200\n#define ICRNL\t0000400\n#define IUCLC\t0001000\n#define IXON\t0002000\n#define IXANY\t0004000\n#define IXOFF\t0010000\n#define IMAXBEL\t0020000\n#define IUTF8\t0040000\n\n/* c_oflag bits */\n#define OPOST\t0000001\n#define OLCUC\t0000002\n#define ONLCR\t0000004\n#define OCRNL\t0000010\n#define ONOCR\t0000020\n#define ONLRET\t0000040\n#define OFILL\t0000100\n#define OFDEL\t0000200\n#if defined __USE_MISC || defined __USE_XOPEN\n#define NLDLY\t0000400\n#define   NL0\t0000000\n#define   NL1\t0000400\n#define CRDLY\t0003000\n#define   CR0\t0000000\n#define   CR1\t0001000\n#define   CR2\t0002000\n#define   CR3\t0003000\n#define TABDLY\t0014000\n#define   TAB0\t0000000\n#define   TAB1\t0004000\n#define   TAB2\t0010000\n#define   TAB3\t0014000\n#define BSDLY\t0020000\n#define   BS0\t0000000\n#define   BS1\t0020000\n#define FFDLY\t0100000\n#define   FF0\t0000000\n#define   FF1\t0100000\n#endif\n\n#define VTDLY\t0040000\n#define   VT0\t0000000\n#define   VT1\t0040000\n\n#ifdef __USE_MISC\n#define XTABS\t0014000\n#endif\n\n/* c_cflag bit meaning */\n#ifdef __USE_MISC\n#define CBAUD\t0010017\n#endif\n#define  B0\t0000000\t\t/* hang up */\n#define  B50\t0000001\n#define  B75\t0000002\n#define  B110\t0000003\n#define  B134\t0000004\n#define  B150\t0000005\n#define  B200\t0000006\n#define  B300\t0000007\n#define  B600\t0000010\n#define  B1200\t0000011\n#define  B1800\t0000012\n#define  B2400\t0000013\n#define  B4800\t0000014\n#define  B9600\t0000015\n#define  B19200\t0000016\n#define  B38400\t0000017\n#ifdef __USE_MISC\n#define EXTA B19200\n#define EXTB B38400\n#endif\n#define CSIZE\t0000060\n#define   CS5\t0000000\n#define   CS6\t0000020\n#define   CS7\t0000040\n#define   CS8\t0000060\n#define CSTOPB\t0000100\n#define CREAD\t0000200\n#define PARENB\t0000400\n#define PARODD\t0001000\n#define HUPCL\t0002000\n#define CLOCAL\t0004000\n#ifdef __USE_MISC\n#define CBAUDEX 0010000\n#endif\n#define  B57600   0010001\n#define  B115200  0010002\n#define  B230400  0010003\n#define  B460800  0010004\n#define  B500000  0010005\n#define  B576000  0010006\n#define  B921600  0010007\n#define  B1000000 0010010\n#define  B1152000 0010011\n#define  B1500000 0010012\n#define  B2000000 0010013\n#define  B2500000 0010014\n#define  B3000000 0010015\n#define  B3500000 0010016\n#define  B4000000 0010017\n#define __MAX_BAUD B4000000\n#ifdef __USE_MISC\n#define CIBAUD\t  002003600000\t/* input baud rate (not used) */\n#define CMSPAR   010000000000\t/* mark or space (stick) parity */\n#define CRTSCTS  020000000000\t/* flow control */\n#endif\n\n/* c_lflag bits */\n#define ISIG\t0000001\n#define ICANON\t0000002\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n#define XCASE\t0000004\n#endif\n#define ECHO\t0000010\n#define ECHOE\t0000020\n#define ECHOK\t0000040\n#define ECHONL\t0000100\n#define NOFLSH\t0000200\n#define TOSTOP\t0000400\n#ifdef __USE_MISC\n#define ECHOCTL 0001000\n#define ECHOPRT 0002000\n#define ECHOKE\t 0004000\n#define FLUSHO\t 0010000\n#define PENDIN\t 0040000\n#endif\n#define IEXTEN\t0100000\n#ifdef __USE_MISC\n#define EXTPROC 0200000\n#endif\n\n/* tcflow() and TCXONC use these */\n#define\tTCOOFF\t\t0\n#define\tTCOON\t\t1\n#define\tTCIOFF\t\t2\n#define\tTCION\t\t3\n\n/* tcflush() and TCFLSH use these */\n#define\tTCIFLUSH\t0\n#define\tTCOFLUSH\t1\n#define\tTCIOFLUSH\t2\n\n/* tcsetattr uses these */\n#define\tTCSANOW\t\t0\n#define\tTCSADRAIN\t1\n#define\tTCSAFLUSH\t2\n\n#define _IOT_termios /* Hurd ioctl type field.  */ \\\n  _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/time.h",
    "content": "/* System-dependent timing definitions.  Linux version.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <time.h> instead.\n */\n\n#if defined __need_timeval || defined __USE_GNU\n#ifndef _STRUCT_TIMEVAL\n#define _STRUCT_TIMEVAL\t1\n#include <bits/types.h>\n\n/* A time value that is accurate to the nearest\n   microsecond but also has a range of years.  */\nstruct timeval {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__suseconds_t tv_usec;\t/* Microseconds.  */\n};\n#endif\t\t\t\t/* struct timeval */\n#endif\n\n#ifndef __need_timeval\n#ifndef _BITS_TIME_H\n#define _BITS_TIME_H\t1\n\n/* ISO/IEC 9899:1999 7.23.1: Components of time\n   The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is\n   the number per second of the value returned by the `clock' function.  */\n/* CAE XSH, Issue 4, Version 2: <time.h>\n   The value of CLOCKS_PER_SEC is required to be 1 million on all\n   XSI-conformant systems. */\n#define CLOCKS_PER_SEC  ((clock_t) 1000000)\n\n#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \\\n   && !defined __USE_XOPEN2K\n/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK\n   presents the real value for clock ticks per second for the system.  */\n#include <bits/types.h>\nextern long int __sysconf(int);\n#define CLK_TCK ((__clock_t) __sysconf (2))\t/* 2 is _SC_CLK_TCK */\n#endif\n\n#ifdef __USE_POSIX199309\n/* Identifier for system-wide realtime clock.  */\n#define CLOCK_REALTIME\t\t0\n/* Monotonic system-wide clock.  */\n#define CLOCK_MONOTONIC\t\t1\n/* High-resolution timer from the CPU.  */\n#define CLOCK_PROCESS_CPUTIME_ID\t2\n/* Thread-specific CPU-time clock.  */\n#define CLOCK_THREAD_CPUTIME_ID\t3\n/* Monotonic system-wide clock, not adjusted for frequency scaling.  */\n#define CLOCK_MONOTONIC_RAW\t\t4\n/* Identifier for system-wide realtime clock, updated only on ticks.  */\n#define CLOCK_REALTIME_COARSE\t5\n/* Monotonic system-wide clock, updated only on ticks.  */\n#define CLOCK_MONOTONIC_COARSE\t6\n/* Monotonic system-wide clock that includes time spent in suspension.  */\n#define CLOCK_BOOTTIME\t\t7\n/* Like CLOCK_REALTIME but also wakes suspended system.  */\n#define CLOCK_REALTIME_ALARM\t\t8\n/* Like CLOCK_BOOTTIME but also wakes suspended system.  */\n#define CLOCK_BOOTTIME_ALARM\t\t9\n/* Like CLOCK_REALTIME but in International Atomic Time.  */\n#define CLOCK_TAI\t\t\t11\n\n/* Flag to indicate time is absolute.  */\n#define TIMER_ABSTIME\t\t1\n#endif\n\n#ifdef __USE_GNU\n#include <bits/timex.h>\n\n__BEGIN_DECLS\n/* Tune a POSIX clock.  */\nextern int clock_adjtime(__clockid_t __clock_id, struct timex *__utx) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* use GNU */\n#endif\t\t\t\t/* bits/time.h */\n#endif\n#undef __need_timeval\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/types.h",
    "content": "/* bits/types.h -- definitions of __*_t types underlying *_t types.\n   Copyright (C) 2002-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Never include this file directly; use <sys/types.h> instead.\n */\n\n#ifndef\t_BITS_TYPES_H\n#define\t_BITS_TYPES_H\t1\n\n#include <features.h>\n#include <bits/wordsize.h>\n\n/* Convenience types.  */\ntypedef unsigned char __u_char;\ntypedef unsigned short int __u_short;\ntypedef unsigned int __u_int;\ntypedef unsigned long int __u_long;\n\n/* Fixed-size types, underlying types depend on word size and compiler.  */\ntypedef signed char __int8_t;\ntypedef unsigned char __uint8_t;\ntypedef signed short int __int16_t;\ntypedef unsigned short int __uint16_t;\ntypedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\n#if __WORDSIZE == 64\ntypedef signed long int __int64_t;\ntypedef unsigned long int __uint64_t;\n#else\n__extension__ typedef signed long long int __int64_t;\n__extension__ typedef unsigned long long int __uint64_t;\n#endif\n\n/* quad_t is also 64 bits.  */\n#if __WORDSIZE == 64\ntypedef long int __quad_t;\ntypedef unsigned long int __u_quad_t;\n#else\n__extension__ typedef long long int __quad_t;\n__extension__ typedef unsigned long long int __u_quad_t;\n#endif\n\n/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE\n   macros for each of the OS types we define below.  The definitions\n   of those macros must use the following macros for underlying types.\n   We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned\n   variants of each of the following integer types on this machine.\n\n\t16\t\t-- \"natural\" 16-bit type (always short)\n\t32\t\t-- \"natural\" 32-bit type (always int)\n\t64\t\t-- \"natural\" 64-bit type (long or long long)\n\tLONG32\t\t-- 32-bit type, traditionally long\n\tQUAD\t\t-- 64-bit type, always long long\n\tWORD\t\t-- natural type of __WORDSIZE bits (int or long)\n\tLONGWORD\t-- type of __WORDSIZE bits, traditionally long\n\n   We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the\n   conventional uses of `long' or `long long' type modifiers match the\n   types we define, even when a less-adorned type would be the same size.\n   This matters for (somewhat) portably writing printf/scanf formats for\n   these types, where using the appropriate l or ll format modifiers can\n   make the typedefs and the formats match up across all GNU platforms.  If\n   we used `long' when it's 64 bits where `long long' is expected, then the\n   compiler would warn about the formats not matching the argument types,\n   and the programmer changing them to shut up the compiler would break the\n   program's portability.\n\n   Here we assume what is presently the case in all the GCC configurations\n   we support: long long is always 64 bits, long is always word/address size,\n   and int is always 32 bits.  */\n\n#define\t__S16_TYPE\t\tshort int\n#define __U16_TYPE\t\tunsigned short int\n#define\t__S32_TYPE\t\tint\n#define __U32_TYPE\t\tunsigned int\n#define __SLONGWORD_TYPE\tlong int\n#define __ULONGWORD_TYPE\tunsigned long int\n#if __WORDSIZE == 32\n#define __SQUAD_TYPE\t\t__quad_t\n#define __UQUAD_TYPE\t\t__u_quad_t\n#define __SWORD_TYPE\t\tint\n#define __UWORD_TYPE\t\tunsigned int\n#define __SLONG32_TYPE\t\tlong int\n#define __ULONG32_TYPE\t\tunsigned long int\n#define __S64_TYPE\t\t__quad_t\n#define __U64_TYPE\t\t__u_quad_t\n/* We want __extension__ before typedef's that use nonstandard base types\n   such as `long long' in C89 mode.  */\n#define __STD_TYPE\t\t__extension__ typedef\n#elif __WORDSIZE == 64\n#define __SQUAD_TYPE\t\tlong int\n#define __UQUAD_TYPE\t\tunsigned long int\n#define __SWORD_TYPE\t\tlong int\n#define __UWORD_TYPE\t\tunsigned long int\n#define __SLONG32_TYPE\t\tint\n#define __ULONG32_TYPE\t\tunsigned int\n#define __S64_TYPE\t\tlong int\n#define __U64_TYPE\t\tunsigned long int\n/* No need to mark the typedef with __extension__.   */\n#define __STD_TYPE\t\ttypedef\n#else\n#error\n#endif\n#include <bits/typesizes.h>\t/* Defines __*_T_TYPE macros.  */\n\n__STD_TYPE __DEV_T_TYPE __dev_t;\t/* Type of device numbers.  */\n__STD_TYPE __UID_T_TYPE __uid_t;\t/* Type of user identifications.  */\n__STD_TYPE __GID_T_TYPE __gid_t;\t/* Type of group identifications.  */\n__STD_TYPE __INO_T_TYPE __ino_t;\t/* Type of file serial numbers.  */\n__STD_TYPE __INO64_T_TYPE __ino64_t;\t/* Type of file serial numbers (LFS). */\n__STD_TYPE __MODE_T_TYPE __mode_t;\t/* Type of file attribute bitmasks.  */\n__STD_TYPE __NLINK_T_TYPE __nlink_t;\t/* Type of file link counts.  */\n__STD_TYPE __OFF_T_TYPE __off_t;\t/* Type of file sizes and offsets.  */\n__STD_TYPE __OFF64_T_TYPE __off64_t;\t/* Type of file sizes and offsets (LFS).  */\n__STD_TYPE __PID_T_TYPE __pid_t;\t/* Type of process identifications.  */\n__STD_TYPE __FSID_T_TYPE __fsid_t;\t/* Type of file system IDs.  */\n__STD_TYPE __CLOCK_T_TYPE __clock_t;\t/* Type of CPU usage counts.  */\n__STD_TYPE __RLIM_T_TYPE __rlim_t;\t/* Type for resource measurement.  */\n__STD_TYPE __RLIM64_T_TYPE __rlim64_t;\t/* Type for resource measurement (LFS).  */\n__STD_TYPE __ID_T_TYPE __id_t;\t/* General type for IDs.  */\n__STD_TYPE __TIME_T_TYPE __time_t;\t/* Seconds since the Epoch.  */\n__STD_TYPE __USECONDS_T_TYPE __useconds_t;\t/* Count of microseconds.  */\n__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t;\t/* Signed count of microseconds.  */\n\n__STD_TYPE __DADDR_T_TYPE __daddr_t;\t/* The type of a disk address.  */\n__STD_TYPE __KEY_T_TYPE __key_t;\t/* Type of an IPC key.  */\n\n/* Clock ID used in clock and timer functions.  */\n__STD_TYPE __CLOCKID_T_TYPE __clockid_t;\n\n/* Timer ID returned by `timer_create'.  */\n__STD_TYPE __TIMER_T_TYPE __timer_t;\n\n/* Type to represent block size.  */\n__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;\n\n/* Types from the Large File Support interface.  */\n\n/* Type to count number of disk blocks.  */\n__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;\n__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;\n\n/* Type to count file system blocks.  */\n__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;\n__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;\n\n/* Type to count file system nodes.  */\n__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;\n__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;\n\n/* Type of miscellaneous file system fields.  */\n__STD_TYPE __FSWORD_T_TYPE __fsword_t;\n\n__STD_TYPE __SSIZE_T_TYPE __ssize_t;\t/* Type of a byte count, or error.  */\n\n/* Signed long type used in system calls.  */\n__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;\n/* Unsigned long type used in system calls.  */\n__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;\n\n/* These few don't really vary by system, they always correspond\n   to one of the other defined types.  */\ntypedef __off64_t __loff_t;\t/* Type of file sizes and offsets (LFS).  */\ntypedef __quad_t *__qaddr_t;\ntypedef char *__caddr_t;\n\n/* Duplicates info from stdint.h but this is used in unistd.h.  */\n__STD_TYPE __SWORD_TYPE __intptr_t;\n\n/* Duplicate info from sys/socket.h.  */\n__STD_TYPE __U32_TYPE __socklen_t;\n\n#undef __STD_TYPE\n\n#endif\t\t\t\t/* bits/types.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/typesizes.h",
    "content": "/* bits/typesizes.h -- underlying types for *_t.  Generic version.\n   Copyright (C) 2002-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_TYPES_H\n#error \"Never include <bits/typesizes.h> directly; use <sys/types.h> instead.\"\n#endif\n\n#ifndef\t_BITS_TYPESIZES_H\n#define\t_BITS_TYPESIZES_H\t1\n\n/* See <bits/types.h> for the meaning of these macros.  This file exists so\n   that <bits/types.h> need not vary across different GNU platforms.  */\n\n#define __DEV_T_TYPE\t\t__UQUAD_TYPE\n#define __UID_T_TYPE\t\t__U32_TYPE\n#define __GID_T_TYPE\t\t__U32_TYPE\n#define __INO_T_TYPE\t\t__ULONGWORD_TYPE\n#define __INO64_T_TYPE\t\t__UQUAD_TYPE\n#define __MODE_T_TYPE\t\t__U32_TYPE\n#define __NLINK_T_TYPE\t\t__UWORD_TYPE\n#define __OFF_T_TYPE\t\t__SLONGWORD_TYPE\n#define __OFF64_T_TYPE\t\t__SQUAD_TYPE\n#define __PID_T_TYPE\t\t__S32_TYPE\n#define __RLIM_T_TYPE\t\t__ULONGWORD_TYPE\n#define __RLIM64_T_TYPE\t\t__UQUAD_TYPE\n#define\t__BLKCNT_T_TYPE\t\t__SLONGWORD_TYPE\n#define\t__BLKCNT64_T_TYPE\t__SQUAD_TYPE\n#define\t__FSBLKCNT_T_TYPE\t__ULONGWORD_TYPE\n#define\t__FSBLKCNT64_T_TYPE\t__UQUAD_TYPE\n#define\t__FSFILCNT_T_TYPE\t__ULONGWORD_TYPE\n#define\t__FSFILCNT64_T_TYPE\t__UQUAD_TYPE\n#define\t__FSWORD_T_TYPE\t\t__SWORD_TYPE\n#define\t__ID_T_TYPE\t\t__U32_TYPE\n#define __CLOCK_T_TYPE\t\t__SLONGWORD_TYPE\n#define __TIME_T_TYPE\t\t__SLONGWORD_TYPE\n#define __USECONDS_T_TYPE\t__U32_TYPE\n#define __SUSECONDS_T_TYPE\t__SLONGWORD_TYPE\n#define __DADDR_T_TYPE\t\t__S32_TYPE\n#define __KEY_T_TYPE\t\t__S32_TYPE\n#define __CLOCKID_T_TYPE\t__S32_TYPE\n#define __TIMER_T_TYPE\t\tvoid *\n#define __BLKSIZE_T_TYPE\t__SLONGWORD_TYPE\n#define __FSID_T_TYPE\t\tstruct { int __val[2]; }\n#define __SSIZE_T_TYPE\t\t__SWORD_TYPE\n#define __SYSCALL_SLONG_TYPE\t__SLONGWORD_TYPE\n#define __SYSCALL_ULONG_TYPE\t__ULONGWORD_TYPE\n#define __CPU_MASK_TYPE \t__ULONGWORD_TYPE\n\n#ifdef __LP64__\n/* Tell the libc code that off_t and off64_t are actually the same type\n   for all ABI purposes, even if possibly expressed as different base types\n   for C type-checking purposes.  */\n#define __OFF_T_MATCHES_OFF64_T\t1\n\n/* Same for ino_t and ino64_t.  */\n#define __INO_T_MATCHES_INO64_T\t1\n#endif\n\n/* Number of descriptors that can fit in an `fd_set'.  */\n#define\t__FD_SETSIZE\t\t1024\n\n#endif\t\t\t\t/* bits/typesizes.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/uio.h",
    "content": "/* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_UIO_H && !defined _FCNTL_H\n#error \"Never include <bits/uio.h> directly; use <sys/uio.h> instead.\"\n#endif\n\n#ifndef _BITS_UIO_H\n#define _BITS_UIO_H\t1\n\n#include <sys/types.h>\n\n/* We should normally use the Linux kernel header file to define this\n   type and macros but this calls for trouble because of the header\n   includes other kernel headers.  */\n\n/* Size of object which can be written atomically.\n\n   This macro has different values in different kernel versions.  The\n   latest versions of the kernel use 1024 and this is good choice.  Since\n   the C library implementation of readv/writev is able to emulate the\n   functionality even if the currently running kernel does not support\n   this large value the readv/writev call will not fail because of this.  */\n#define UIO_MAXIOV\t1024\n\n/* Structure for scatter/gather I/O.  */\nstruct iovec {\n\tvoid *iov_base;\t\t/* Pointer to data.  */\n\tsize_t iov_len;\t\t/* Length of data.  */\n};\n\n#endif\n\n#ifdef __USE_GNU\n#if defined _SYS_UIO_H && !defined _BITS_UIO_H_FOR_SYS_UIO_H\n#define _BITS_UIO_H_FOR_SYS_UIO_H 1\n\n__BEGIN_DECLS\n/* Read from another process' address space.  */\nextern ssize_t process_vm_readv(pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt, unsigned long int __flags) __THROW;\n\n/* Write to another process' address space.  */\nextern ssize_t process_vm_writev(pid_t __pid, const struct iovec *__lvec, unsigned long int __liovcnt, const struct iovec *__rvec, unsigned long int __riovcnt, unsigned long int __flags) __THROW;\n\n__END_DECLS\n#endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/utsname.h",
    "content": "/* Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UTSNAME_H\n#error \"Never include <bits/utsname.h> directly; use <sys/utsname.h> instead.\"\n#endif\n\n/* Length of the entries in `struct utsname' is 65.  */\n#define _UTSNAME_LENGTH 65\n\n/* Linux provides as additional information in the `struct utsname'\n   the name of the current domain.  Define _UTSNAME_DOMAIN_LENGTH\n   to a value != 0 to activate this entry.  */\n#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/waitflags.h",
    "content": "/* Definitions of flag bits for `waitpid' et al.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n#error \"Never include <bits/waitflags.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Bits in the third argument to `waitpid'.  */\n#define\tWNOHANG\t\t1\t/* Don't block waiting.  */\n#define\tWUNTRACED\t2\t/* Report status of stopped children.  */\n\n/* Bits in the fourth argument to `waitid'.  */\n#define WSTOPPED\t2\t/* Report stopped child (same as WUNTRACED). */\n#define WEXITED\t\t4\t/* Report dead child.  */\n#define WCONTINUED\t8\t/* Report continued child.  */\n#define WNOWAIT\t\t0x01000000\t/* Don't reap, just poll status.  */\n\n#define __WNOTHREAD     0x20000000\t/* Don't wait on children of other threads\n\t\t\t\t\t   in this group */\n#define __WALL\t\t0x40000000\t/* Wait for any child.  */\n#define __WCLONE\t0x80000000\t/* Wait for cloned process.  */\n\n/* The following values are used by the `waitid' function.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#ifndef __ENUM_IDTYPE_T\n#define __ENUM_IDTYPE_T 1\n\n/* The Linux kernel defines these bare, rather than an enum,\n   which causes a conflict if the include order is reversed. */\n#undef P_ALL\n#undef P_PID\n#undef P_PGID\n\ntypedef enum {\n\tP_ALL,\t\t\t/* Wait for any child.  */\n\tP_PID,\t\t\t/* Wait for specified process.  */\n\tP_PGID\t\t\t/* Wait for members of process group.  */\n} idtype_t;\n#endif\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/waitstatus.h",
    "content": "/* Definitions of status bits for `wait' et al.\n   Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#if !defined _SYS_WAIT_H && !defined _STDLIB_H\n#error \"Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead.\"\n#endif\n\n/* Everything extant so far uses these same bits.  */\n\n/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */\n#define\t__WEXITSTATUS(status)\t(((status) & 0xff00) >> 8)\n\n/* If WIFSIGNALED(STATUS), the terminating signal.  */\n#define\t__WTERMSIG(status)\t((status) & 0x7f)\n\n/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */\n#define\t__WSTOPSIG(status)\t__WEXITSTATUS(status)\n\n/* Nonzero if STATUS indicates normal termination.  */\n#define\t__WIFEXITED(status)\t(__WTERMSIG(status) == 0)\n\n/* Nonzero if STATUS indicates termination by a signal.  */\n#define __WIFSIGNALED(status) \\\n  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)\n\n/* Nonzero if STATUS indicates the child is stopped.  */\n#define\t__WIFSTOPPED(status)\t(((status) & 0xff) == 0x7f)\n\n/* Nonzero if STATUS indicates the child continued after a stop.  We only\n   define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */\n#ifdef WCONTINUED\n#define __WIFCONTINUED(status)\t((status) == __W_CONTINUED)\n#endif\n\n/* Nonzero if STATUS indicates the child dumped core.  */\n#define\t__WCOREDUMP(status)\t((status) & __WCOREFLAG)\n\n/* Macros for constructing status values.  */\n#define\t__W_EXITCODE(ret, sig)\t((ret) << 8 | (sig))\n#define\t__W_STOPCODE(sig)\t((sig) << 8 | 0x7f)\n#define __W_CONTINUED\t\t0xffff\n#define\t__WCOREFLAG\t\t0x80\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/wchar.h",
    "content": "/* wchar_t type related definitions.\n   Copyright (C) 2000-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _BITS_WCHAR_H\n#define _BITS_WCHAR_H\t1\n\n/* The fallback definitions, for when __WCHAR_MAX__ or __WCHAR_MIN__\n   are not defined, give the right value and type as long as both int\n   and wchar_t are 32-bit types.  Adding L'\\0' to a constant value\n   ensures that the type is correct; it is necessary to use (L'\\0' +\n   0) rather than just L'\\0' so that the type in C++ is the promoted\n   version of wchar_t rather than the distinct wchar_t type itself.\n   Because wchar_t in preprocessor #if expressions is treated as\n   intmax_t or uintmax_t, the expression (L'\\0' - 1) would have the\n   wrong value for WCHAR_MAX in such expressions and so cannot be used\n   to define __WCHAR_MAX in the unsigned case.  */\n\n#ifdef __WCHAR_MAX__\n#define __WCHAR_MAX\t__WCHAR_MAX__\n#elif L'\\0' - 1 > 0\n#define __WCHAR_MAX\t(0xffffffffu + L'\\0')\n#else\n#define __WCHAR_MAX\t(0x7fffffff + L'\\0')\n#endif\n\n#ifdef __WCHAR_MIN__\n#define __WCHAR_MIN\t__WCHAR_MIN__\n#elif L'\\0' - 1 > 0\n#define __WCHAR_MIN\t(L'\\0' + 0)\n#else\n#define __WCHAR_MIN\t(-__WCHAR_MAX - 1)\n#endif\n\n#endif\t\t\t\t/* bits/wchar.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/bits/wordsize.h",
    "content": "/* Copyright (C) 1999-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#define __WORDSIZE\t32\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/gnu/stubs-hard.h",
    "content": "/* This file is automatically generated.\n   It defines a symbol `__stub_FUNCTION' for each function\n   in the C library which is a stub, meaning it will fail\n   every time called, usually setting errno to ENOSYS.  */\n\n#ifdef _LIBC\n#error Applications may not define the macro _LIBC\n#endif\n\n#define __stub___compat_create_module\n#define __stub___compat_get_kernel_syms\n#define __stub___compat_query_module\n#define __stub_chflags\n#define __stub_fattach\n#define __stub_fchflags\n#define __stub_fdetach\n#define __stub_getmsg\n#define __stub_getpmsg\n#define __stub_gtty\n#define __stub_lchmod\n#define __stub_putmsg\n#define __stub_putpmsg\n#define __stub_revoke\n#define __stub_setlogin\n#define __stub_sigreturn\n#define __stub_sstk\n#define __stub_stty\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/gnu/stubs.h",
    "content": "/* This file is automatically generated.\n   This file selects the right generated file of `__stub_FUNCTION' macros\n   based on the architecture being compiled for.  */\n\n#if !defined __ARM_PCS_VFP\n#include <gnu/stubs-soft.h>\n#endif\n#if defined __ARM_PCS_VFP\n#include <gnu/stubs-hard.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/cdefs.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_CDEFS_H\n#define\t_SYS_CDEFS_H\t1\n\n/* We are almost always included from features.h. */\n#ifndef _FEATURES_H\n#include <features.h>\n#endif\n\n/* The GNU libc does not support any K&R compilers or the traditional mode\n   of ISO C compilers anymore.  Check for some of the combinations not\n   anymore supported.  */\n#if defined __GNUC__ && !defined __STDC__\n#error \"You need a ISO C conforming compiler to use the glibc headers\"\n#endif\n\n/* Some user header file might have defined this before.  */\n#undef\t__P\n#undef\t__PMT\n\n#ifdef __GNUC__\n\n/* All functions, except those with callbacks or those that\n   synchronize memory, are leaf functions.  */\n#if __GNUC_PREREQ (4, 6) && !defined _LIBC\n#define __LEAF , __leaf__\n#define __LEAF_ATTR __attribute__ ((__leaf__))\n#else\n#define __LEAF\n#define __LEAF_ATTR\n#endif\n\n/* GCC can always grok prototypes.  For C++ programs we add throw()\n   to help it optimize the function calls.  But this works only with\n   gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions\n   as non-throwing using a function attribute since programs can use\n   the -fexceptions options for C code as well.  */\n#if !defined __cplusplus && __GNUC_PREREQ (3, 3)\n#define __THROW\t__attribute__ ((__nothrow__ __LEAF))\n#define __THROWNL\t__attribute__ ((__nothrow__))\n#define __NTH(fct)\t__attribute__ ((__nothrow__ __LEAF)) fct\n#else\n#if defined __cplusplus && __GNUC_PREREQ (2,8)\n#define __THROW\tthrow ()\n#define __THROWNL\tthrow ()\n#define __NTH(fct)\t__LEAF_ATTR fct throw ()\n#else\n#define __THROW\n#define __THROWNL\n#define __NTH(fct)\tfct\n#endif\n#endif\n\n#else\t\t\t\t/* Not GCC.  */\n\n#define __inline\t\t/* No inline functions.  */\n\n#define __THROW\n#define __THROWNL\n#define __NTH(fct)\tfct\n\n#endif\t\t\t\t/* GCC.  */\n\n/* These two macros are not used in glibc anymore.  They are kept here\n   only because some other projects expect the macros to be defined.  */\n#define __P(args)\targs\n#define __PMT(args)\targs\n\n/* For these things, GCC behaves the ANSI way normally,\n   and the non-ANSI way under -traditional.  */\n\n#define __CONCAT(x,y)\tx ## y\n#define __STRING(x)\t#x\n\n/* This is not a typedef so `const __ptr_t' does the right thing.  */\n#define __ptr_t void *\n#define __long_double_t  long double\n\n/* C++ needs to know that types and declarations are C, not C++.  */\n#ifdef\t__cplusplus\n#define __BEGIN_DECLS\textern \"C\" {\n#define __END_DECLS\t}\n#else\n#define __BEGIN_DECLS\n#define __END_DECLS\n#endif\n\n/* The standard library needs the functions from the ISO C90 standard\n   in the std namespace.  At the same time we want to be safe for\n   future changes and we include the ISO C99 code in the non-standard\n   namespace __c99.  The C++ wrapper header take case of adding the\n   definitions to the global namespace.  */\n#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES\n#define __BEGIN_NAMESPACE_STD\tnamespace std {\n#define __END_NAMESPACE_STD\t}\n#define __USING_NAMESPACE_STD(name) using std::name;\n#define __BEGIN_NAMESPACE_C99\tnamespace __c99 {\n#define __END_NAMESPACE_C99\t}\n#define __USING_NAMESPACE_C99(name) using __c99::name;\n#else\n/* For compatibility we do not add the declarations into any\n   namespace.  They will end up in the global namespace which is what\n   old code expects.  */\n#define __BEGIN_NAMESPACE_STD\n#define __END_NAMESPACE_STD\n#define __USING_NAMESPACE_STD(name)\n#define __BEGIN_NAMESPACE_C99\n#define __END_NAMESPACE_C99\n#define __USING_NAMESPACE_C99(name)\n#endif\n\n/* Fortify support.  */\n#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)\n#define __bos0(ptr) __builtin_object_size (ptr, 0)\n\n#if __GNUC_PREREQ (4,3)\n#define __warndecl(name, msg) \\\n  extern void name (void) __attribute__((__warning__ (msg)))\n#define __warnattr(msg) __attribute__((__warning__ (msg)))\n#define __errordecl(name, msg) \\\n  extern void name (void) __attribute__((__error__ (msg)))\n#else\n#define __warndecl(name, msg) extern void name (void)\n#define __warnattr(msg)\n#define __errordecl(name, msg) extern void name (void)\n#endif\n\n/* Support for flexible arrays.  */\n#if __GNUC_PREREQ (2,97)\n/* GCC 2.97 supports C99 flexible array members.  */\n#define __flexarr\t[]\n#else\n#ifdef __GNUC__\n#define __flexarr\t[0]\n#else\n#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#define __flexarr\t[]\n#else\n/* Some other non-C99 compiler.  Approximate with [1].  */\n#define __flexarr\t[1]\n#endif\n#endif\n#endif\n\n/* __asm__ (\"xyz\") is used throughout the headers to rename functions\n   at the assembly language level.  This is wrapped by the __REDIRECT\n   macro, in order to support compilers that can do this some other\n   way.  When compilers don't support asm-names at all, we have to do\n   preprocessor tricks instead (which don't have exactly the right\n   semantics, but it's the best we can do).\n\n   Example:\n   int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */\n\n#if defined __GNUC__ && __GNUC__ >= 2\n\n#define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))\n#ifdef __cplusplus\n#define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __THROW __asm__ (__ASMNAME (#alias))\n#define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __THROWNL __asm__ (__ASMNAME (#alias))\n#else\n#define __REDIRECT_NTH(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROW\n#define __REDIRECT_NTHNL(name, proto, alias) \\\n     name proto __asm__ (__ASMNAME (#alias)) __THROWNL\n#endif\n#define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)\n#define __ASMNAME2(prefix, cname) __STRING (prefix) cname\n\n/*\n#elif __SOME_OTHER_COMPILER__\n\n# define __REDIRECT(name, proto, alias) name proto; \\\n\t_Pragma(\"let \" #name \" = \" #alias)\n*/\n#endif\n\n/* GCC has various useful declarations that can be made with the\n   `__attribute__' syntax.  All of the ways we use this do fine if\n   they are omitted for compilers that don't understand it. */\n#if !defined __GNUC__ || __GNUC__ < 2\n#define __attribute__(xyz)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.96 development the `malloc' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n#define __attribute_malloc__ __attribute__ ((__malloc__))\n#else\n#define __attribute_malloc__\t/* Ignore */\n#endif\n\n/* Tell the compiler which arguments to an allocation function\n   indicate the size of the allocation.  */\n#if __GNUC_PREREQ (4, 3)\n#define __attribute_alloc_size__(params) \\\n  __attribute__ ((__alloc_size__ params))\n#else\n#define __attribute_alloc_size__(params)\t/* Ignore.  */\n#endif\n\n/* At some point during the gcc 2.96 development the `pure' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (2,96)\n#define __attribute_pure__ __attribute__ ((__pure__))\n#else\n#define __attribute_pure__\t/* Ignore */\n#endif\n\n/* This declaration tells the compiler that the value is constant.  */\n#if __GNUC_PREREQ (2,5)\n#define __attribute_const__ __attribute__ ((__const__))\n#else\n#define __attribute_const__\t/* Ignore */\n#endif\n\n/* At some point during the gcc 3.1 development the `used' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.  */\n#if __GNUC_PREREQ (3,1)\n#define __attribute_used__ __attribute__ ((__used__))\n#define __attribute_noinline__ __attribute__ ((__noinline__))\n#else\n#define __attribute_used__ __attribute__ ((__unused__))\n#define __attribute_noinline__\t/* Ignore */\n#endif\n\n/* gcc allows marking deprecated functions.  */\n#if __GNUC_PREREQ (3,2)\n#define __attribute_deprecated__ __attribute__ ((__deprecated__))\n#else\n#define __attribute_deprecated__\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.8 development the `format_arg' attribute\n   for functions was introduced.  We don't want to use it unconditionally\n   (although this would be possible) since it generates warnings.\n   If several `format_arg' attributes are given for the same function, in\n   gcc-3.0 and older, all but the last one are ignored.  In newer gccs,\n   all designated arguments are considered.  */\n#if __GNUC_PREREQ (2,8)\n#define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))\n#else\n#define __attribute_format_arg__(x)\t/* Ignore */\n#endif\n\n/* At some point during the gcc 2.97 development the `strfmon' format\n   attribute for functions was introduced.  We don't want to use it\n   unconditionally (although this would be possible) since it\n   generates warnings.  */\n#if __GNUC_PREREQ (2,97)\n#define __attribute_format_strfmon__(a,b) \\\n  __attribute__ ((__format__ (__strfmon__, a, b)))\n#else\n#define __attribute_format_strfmon__(a,b)\t/* Ignore */\n#endif\n\n/* The nonull function attribute allows to mark pointer parameters which\n   must not be NULL.  */\n#if __GNUC_PREREQ (3,3)\n#define __nonnull(params) __attribute__ ((__nonnull__ params))\n#else\n#define __nonnull(params)\n#endif\n\n/* If fortification mode, we warn about unused results of certain\n   function calls which can lead to problems.  */\n#if __GNUC_PREREQ (3,4)\n#define __attribute_warn_unused_result__ \\\n   __attribute__ ((__warn_unused_result__))\n#if __USE_FORTIFY_LEVEL > 0\n#define __wur __attribute_warn_unused_result__\n#endif\n#else\n#define __attribute_warn_unused_result__\t/* empty */\n#endif\n#ifndef __wur\n#define __wur\t\t\t/* Ignore */\n#endif\n\n/* Forces a function to be always inlined.  */\n#if __GNUC_PREREQ (3,2)\n/* The Linux kernel defines __always_inline in stddef.h (283d7573), and\n   it conflicts with this definition.  Therefore undefine it first to\n   allow either header to be included first.  */\n#undef __always_inline\n#define __always_inline __inline __attribute__ ((__always_inline__))\n#else\n#undef __always_inline\n#define __always_inline __inline\n#endif\n\n/* Associate error messages with the source location of the call site rather\n   than with the source location inside the function.  */\n#if __GNUC_PREREQ (4,3)\n#define __attribute_artificial__ __attribute__ ((__artificial__))\n#else\n#define __attribute_artificial__\t/* Ignore */\n#endif\n\n/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99\n   inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__\n   or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions\n   older than 4.3 may define these macros and still not guarantee GNU inlining\n   semantics.\n\n   clang++ identifies itself as gcc-4.2, but has support for GNU inlining\n   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and\n   __GNUC_GNU_INLINE__ macro definitions.  */\n#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \\\n     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \\\n\t\t\t       || defined __GNUC_GNU_INLINE__)))\n#if defined __GNUC_STDC_INLINE__ || defined __cplusplus\n#define __extern_inline extern __inline __attribute__ ((__gnu_inline__))\n#define __extern_always_inline \\\n  extern __always_inline __attribute__ ((__gnu_inline__))\n#else\n#define __extern_inline extern __inline\n#define __extern_always_inline extern __always_inline\n#endif\n#endif\n\n#ifdef __extern_always_inline\n#define __fortify_function __extern_always_inline __attribute_artificial__\n#endif\n\n/* GCC 4.3 and above allow passing all anonymous arguments of an\n   __extern_always_inline function to some other vararg function.  */\n#if __GNUC_PREREQ (4,3)\n#define __va_arg_pack() __builtin_va_arg_pack ()\n#define __va_arg_pack_len() __builtin_va_arg_pack_len ()\n#endif\n\n/* It is possible to compile containing GCC extensions even if GCC is\n   run in pedantic mode if the uses are carefully marked using the\n   `__extension__' keyword.  But this is not generally available before\n   version 2.8.  */\n#if !__GNUC_PREREQ (2,8)\n#define __extension__\t\t/* Ignore */\n#endif\n\n/* __restrict is known in EGCS 1.2 and above. */\n#if !__GNUC_PREREQ (2,92)\n#define __restrict\t\t/* Ignore */\n#endif\n\n/* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is\n     array_name[restrict]\n   GCC 3.1 supports this.  */\n#if __GNUC_PREREQ (3,1) && !defined __GNUG__\n#define __restrict_arr\t__restrict\n#else\n#ifdef __GNUC__\n#define __restrict_arr\t\t/* Not supported in old GCC.  */\n#else\n#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#define __restrict_arr\trestrict\n#else\n/* Some other non-C99 compiler.  */\n#define __restrict_arr\t\t/* Not supported.  */\n#endif\n#endif\n#endif\n\n#if __GNUC__ >= 3\n#define __glibc_unlikely(cond)\t__builtin_expect ((cond), 0)\n#define __glibc_likely(cond)\t__builtin_expect ((cond), 1)\n#else\n#define __glibc_unlikely(cond)\t(cond)\n#define __glibc_likely(cond)\t(cond)\n#endif\n\n#if (!defined _Noreturn \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     &&  !__GNUC_PREREQ (4,7))\n#if __GNUC_PREREQ (2,8)\n#define _Noreturn __attribute__ ((__noreturn__))\n#else\n#define _Noreturn\n#endif\n#endif\n\n#if (!defined _Static_assert && !defined __cplusplus \\\n     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \\\n     && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))\n#define _Static_assert(expr, diagnostic) \\\n    extern int (*__Static_assert_function (void)) \\\n      [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]\n#endif\n\n#include <bits/wordsize.h>\n\n#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH\n#define __LDBL_COMPAT 1\n#ifdef __REDIRECT\n#define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)\n#define __LDBL_REDIR(name, proto) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##name)\n#define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)\n#define __LDBL_REDIR_NTH(name, proto) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)\n#define __LDBL_REDIR1_DECL(name, alias) \\\n  extern __typeof (name) name __asm (__ASMNAME (#alias));\n#define __LDBL_REDIR_DECL(name) \\\n  extern __typeof (name) name __asm (__ASMNAME (\"__nldbl_\" #name));\n#define __REDIRECT_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1 (name, proto, __nldbl_##alias)\n#define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)\n#endif\n#endif\n#if !defined __LDBL_COMPAT || !defined __REDIRECT\n#define __LDBL_REDIR1(name, proto, alias) name proto\n#define __LDBL_REDIR(name, proto) name proto\n#define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW\n#define __LDBL_REDIR_NTH(name, proto) name proto __THROW\n#define __LDBL_REDIR_DECL(name)\n#ifdef __REDIRECT\n#define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)\n#define __REDIRECT_NTH_LDBL(name, proto, alias) \\\n  __REDIRECT_NTH (name, proto, alias)\n#endif\n#endif\n\n#endif\t\t\t\t/* sys/cdefs.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/file.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_FILE_H\n#define\t_SYS_FILE_H\t1\n\n#include <features.h>\n\n#ifndef\t_FCNTL_H\n#include <fcntl.h>\n#endif\n\n__BEGIN_DECLS\n/* Alternate names for values for the WHENCE argument to `lseek'.\n   These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively.  */\n#ifndef L_SET\n#define L_SET\t0\t\t/* Seek from beginning of file.  */\n#define L_INCR\t1\t\t/* Seek from current position.  */\n#define L_XTND\t2\t\t/* Seek from end of file.  */\n#endif\n/* Operations for the `flock' call.  */\n#define\tLOCK_SH\t1\t\t/* Shared lock.  */\n#define\tLOCK_EX\t2\t\t/* Exclusive lock.  */\n#define\tLOCK_UN\t8\t\t/* Unlock.  */\n#define\t__LOCK_ATOMIC\t16\t/* Atomic update.  */\n/* Can be OR'd in to one of the above.  */\n#define\tLOCK_NB\t4\t\t/* Don't block when locking.  */\n/* Apply or remove an advisory lock, according to OPERATION,\n   on the file FD refers to.  */\nextern int flock(int __fd, int __operation) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/file.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/ioctl.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_IOCTL_H\n#define\t_SYS_IOCTL_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get the list of `ioctl' requests and related constants.  */\n#include <bits/ioctls.h>\n/* Define some types used by `ioctl' requests.  */\n#include <bits/ioctl-types.h>\n/* On a Unix system, the system <sys/ioctl.h> probably defines some of\n   the symbols we define in <sys/ttydefaults.h> (usually with the same\n   values).  The code to generate <bits/ioctls.h> has omitted these\n   symbols to avoid the conflict, but a Unix program expects <sys/ioctl.h>\n   to define them, so we must include <sys/ttydefaults.h> here.  */\n#include <sys/ttydefaults.h>\n/* Perform the I/O control operation specified by REQUEST on FD.\n   One argument may follow; its presence and type depend on REQUEST.\n   Return value depends on REQUEST.  Usually -1 indicates error.  */\nextern int ioctl(int __fd, unsigned long int __request, ...) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/ioctl.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/mman.h",
    "content": "/* Definitions for BSD-style memory management.\n   Copyright (C) 1994-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_MMAN_H\n#define\t_SYS_MMAN_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#define __mode_t_defined\n#endif\n\n#include <bits/mman.h>\n\n/* Return value of `mmap' in case of an error.  */\n#define MAP_FAILED\t((void *) -1)\n\n__BEGIN_DECLS\n/* Map addresses starting near ADDR and extending for LEN bytes.  from\n   OFFSET into the file FD describes according to PROT and FLAGS.  If ADDR\n   is nonzero, it is the desired mapping address.  If the MAP_FIXED bit is\n   set in FLAGS, the mapping will be at ADDR exactly (which must be\n   page-aligned); otherwise the system chooses a convenient nearby address.\n   The return value is the actual mapping address chosen or MAP_FAILED\n   for errors (in which case `errno' is set).  A successful `mmap' call\n   deallocates any previous mapping for the affected region.  */\n#ifndef __USE_FILE_OFFSET64\nextern void *mmap(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off_t __offset) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern void *__REDIRECT_NTH(mmap, (void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset), mmap64);\n#else\n#define mmap mmap64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern void *mmap64(void *__addr, size_t __len, int __prot, int __flags, int __fd, __off64_t __offset) __THROW;\n#endif\n\n/* Deallocate any mapping for the region starting at ADDR and extending LEN\n   bytes.  Returns 0 if successful, -1 for errors (and sets errno).  */\nextern int munmap(void *__addr, size_t __len) __THROW;\n\n/* Change the memory protection of the region starting at ADDR and\n   extending LEN bytes to PROT.  Returns 0 if successful, -1 for errors\n   (and sets errno).  */\nextern int mprotect(void *__addr, size_t __len, int __prot) __THROW;\n\n/* Synchronize the region starting at ADDR and extending LEN bytes with the\n   file it maps.  Filesystem operations on a file being mapped are\n   unpredictable before this is done.  Flags are from the MS_* set.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int msync(void *__addr, size_t __len, int __flags);\n\n#ifdef __USE_MISC\n/* Advise the system about particular usage patterns the program follows\n   for the region starting at ADDR and extending LEN bytes.  */\nextern int madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n#ifdef __USE_XOPEN2K\n/* This is the POSIX name for this function.  */\nextern int posix_madvise(void *__addr, size_t __len, int __advice) __THROW;\n#endif\n\n/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to\n   be memory resident.  */\nextern int mlock(const void *__addr, size_t __len) __THROW;\n\n/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN).  */\nextern int munlock(const void *__addr, size_t __len) __THROW;\n\n/* Cause all currently mapped pages of the process to be memory resident\n   until unlocked by a call to the `munlockall', until the process exits,\n   or until the process calls `execve'.  */\nextern int mlockall(int __flags) __THROW;\n\n/* All currently mapped pages of the process' address space become\n   unlocked.  */\nextern int munlockall(void) __THROW;\n\n#ifdef __USE_MISC\n/* mincore returns the memory residency status of the pages in the\n   current process's address space specified by [start, start + len).\n   The status is returned in a vector of bytes.  The least significant\n   bit of each byte is 1 if the referenced page is in memory, otherwise\n   it is zero.  */\nextern int mincore(void *__start, size_t __len, unsigned char *__vec) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length\n   NEW_LEN.  If MREMAP_MAYMOVE is set in FLAGS the returned address\n   may differ from ADDR.  If MREMAP_FIXED is set in FLAGS the function\n   takes another parameter which is a fixed address at which the block\n   resides after a successful call.  */\nextern void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...) __THROW;\n\n/* Remap arbitrary pages of a shared backing store within an existing\n   VMA.  */\nextern int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags) __THROW;\n#endif\n\n/* Open shared memory segment.  */\nextern int shm_open(const char *__name, int __oflag, mode_t __mode);\n\n/* Remove shared memory segment.  */\nextern int shm_unlink(const char *__name);\n\n__END_DECLS\n#endif\t\t\t\t/* sys/mman.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/param.h",
    "content": "/* Compatibility header for old-style Unix parameters and limits.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_PARAM_H\n#define _SYS_PARAM_H    1\n\n#define __need_NULL\n#include <stddef.h>\n\n#include <sys/types.h>\n#include <limits.h>\n#include <endian.h>\t\t/* Define BYTE_ORDER et al.  */\n#include <signal.h>\t\t/* Define NSIG.  */\n\n/* This file defines some things in system-specific ways.  */\n#include <bits/param.h>\n\n/* BSD names for some <limits.h> values.  */\n\n#define NBBY\t\tCHAR_BIT\n\n#if !defined NGROUPS && defined NGROUPS_MAX\n#define NGROUPS\tNGROUPS_MAX\n#endif\n#if !defined MAXSYMLINKS && defined SYMLOOP_MAX\n#define MAXSYMLINKS\tSYMLOOP_MAX\n#endif\n#if !defined CANBSIZ && defined MAX_CANON\n#define CANBSIZ\tMAX_CANON\n#endif\n#if !defined MAXPATHLEN && defined PATH_MAX\n#define MAXPATHLEN\tPATH_MAX\n#endif\n#if !defined NOFILE && defined OPEN_MAX\n#define NOFILE\t\tOPEN_MAX\n#endif\n#if !defined MAXHOSTNAMELEN && defined HOST_NAME_MAX\n#define MAXHOSTNAMELEN\tHOST_NAME_MAX\n#endif\n#ifndef NCARGS\n#ifdef ARG_MAX\n#define NCARGS\tARG_MAX\n#else\n/* ARG_MAX is unlimited, but we define NCARGS for BSD programs that want to\n   compare against some fixed limit.  */\n#define NCARGS\t\tINT_MAX\n#endif\n#endif\n\n/* Magical constants.  */\n#ifndef NOGROUP\n#define NOGROUP\t65535\t\t/* Marker for empty group set member.  */\n#endif\n#ifndef NODEV\n#define NODEV\t\t((dev_t) -1)\t/* Non-existent device.  */\n#endif\n\n/* Unit of `st_blocks'.  */\n#ifndef DEV_BSIZE\n#define DEV_BSIZE\t512\n#endif\n\n/* Bit map related macros.  */\n#define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))\n#define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))\n#define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))\n#define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)\n\n/* Macros for counting and rounding.  */\n#ifndef howmany\n#define howmany(x, y)  (((x) + ((y) - 1)) / (y))\n#endif\n#ifdef __GNUC__\n#define roundup(x, y)  (__builtin_constant_p (y) && powerof2 (y)             \\\n                         ? (((x) + (y) - 1) & ~((y) - 1))                     \\\n                         : ((((x) + ((y) - 1)) / (y)) * (y)))\n#else\n#define roundup(x, y)  ((((x) + ((y) - 1)) / (y)) * (y))\n#endif\n#define powerof2(x)     ((((x) - 1) & (x)) == 0)\n\n/* Macros for min/max.  */\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#define MAX(a,b) (((a)>(b))?(a):(b))\n\n#endif\t\t\t\t/* sys/param.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/resource.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_RESOURCE_H\n#define\t_SYS_RESOURCE_H\t1\n\n#include <features.h>\n\n/* Get the system-dependent definitions of structures and bit values.  */\n#include <bits/resource.h>\n\n#ifndef __id_t_defined\ntypedef __id_t id_t;\n#define __id_t_defined\n#endif\n\n__BEGIN_DECLS\n/* The X/Open standard defines that all the functions below must use\n   `int' as the type for the first argument.  When we are compiling with\n   GNU extensions we change this slightly to provide better error\n   checking.  */\n#if defined __USE_GNU && !defined __cplusplus\ntypedef enum __rlimit_resource __rlimit_resource_t;\ntypedef enum __rusage_who __rusage_who_t;\ntypedef enum __priority_which __priority_which_t;\n#else\ntypedef int __rlimit_resource_t;\ntypedef int __rusage_who_t;\ntypedef int __priority_which_t;\n#endif\n\n/* Put the soft and hard limits for RESOURCE in *RLIMITS.\n   Returns 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int getrlimit(__rlimit_resource_t __resource, struct rlimit *__rlimits) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(getrlimit, (__rlimit_resource_t __resource, struct rlimit * __rlimits), getrlimit64);\n#else\n#define getrlimit getrlimit64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int getrlimit64(__rlimit_resource_t __resource, struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Set the soft and hard limits for RESOURCE to *RLIMITS.\n   Only the super-user can increase hard limits.\n   Return 0 if successful, -1 if not (and sets errno).  */\n#ifndef __USE_FILE_OFFSET64\nextern int setrlimit(__rlimit_resource_t __resource, const struct rlimit *__rlimits) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(setrlimit, (__rlimit_resource_t __resource, const struct rlimit * __rlimits), setrlimit64);\n#else\n#define setrlimit setrlimit64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int setrlimit64(__rlimit_resource_t __resource, const struct rlimit64 *__rlimits) __THROW;\n#endif\n\n/* Return resource usage information on process indicated by WHO\n   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */\nextern int getrusage(__rusage_who_t __who, struct rusage *__usage) __THROW;\n\n/* Return the highest priority of any process specified by WHICH and WHO\n   (see above); if WHO is zero, the current process, process group, or user\n   (as specified by WHO) is used.  A lower priority number means higher\n   priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */\nextern int getpriority(__priority_which_t __which, id_t __who) __THROW;\n\n/* Set the priority of all processes specified by WHICH and WHO (see above)\n   to PRIO.  Returns 0 on success, -1 on errors.  */\nextern int setpriority(__priority_which_t __which, id_t __who, int __prio) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/resource.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/select.h",
    "content": "/* `fd_set' type and related macros, and `select'/`pselect' declarations.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\tPOSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h>  */\n\n#ifndef _SYS_SELECT_H\n#define _SYS_SELECT_H\t1\n\n#include <features.h>\n\n/* Get definition of needed basic types.  */\n#include <bits/types.h>\n\n/* Get __FD_* definitions.  */\n#include <bits/select.h>\n\n/* Get __sigset_t.  */\n#include <bits/sigset.h>\n\n#ifndef __sigset_t_defined\n#define __sigset_t_defined\ntypedef __sigset_t sigset_t;\n#endif\n\n/* Get definition of timer specification structures.  */\n#define __need_time_t\n#ifdef __USE_XOPEN2K\n#define __need_timespec\n#endif\n#include <time.h>\n#define __need_timeval\n#include <bits/time.h>\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n#define __suseconds_t_defined\n#endif\n\n/* The fd_set member is required to be an array of longs.  */\ntypedef long int __fd_mask;\n\n/* Some versions of <linux/posix_types.h> define this macros.  */\n#undef\t__NFDBITS\n/* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */\n#define __NFDBITS\t(8 * (int) sizeof (__fd_mask))\n#define\t__FD_ELT(d)\t((d) / __NFDBITS)\n#define\t__FD_MASK(d)\t((__fd_mask) (1UL << ((d) % __NFDBITS)))\n\n/* fd_set for select and pselect.  */\ntypedef struct {\n\t/* XPG4.2 requires this member name.  Otherwise avoid the name\n\t   from the global namespace.  */\n#ifdef __USE_XOPEN\n\t__fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];\n#define __FDS_BITS(set) ((set)->fds_bits)\n#else\n\t__fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];\n#define __FDS_BITS(set) ((set)->__fds_bits)\n#endif\n} fd_set;\n\n/* Maximum number of file descriptors in `fd_set'.  */\n#define\tFD_SETSIZE\t\t__FD_SETSIZE\n\n#ifdef __USE_MISC\n/* Sometimes the fd_set member is assumed to have this type.  */\ntypedef __fd_mask fd_mask;\n\n/* Number of bits per word of `fd_set' (some code assumes this is 32).  */\n#define NFDBITS\t\t__NFDBITS\n#endif\n\n/* Access macros for `fd_set'.  */\n#define\tFD_SET(fd, fdsetp)\t__FD_SET (fd, fdsetp)\n#define\tFD_CLR(fd, fdsetp)\t__FD_CLR (fd, fdsetp)\n#define\tFD_ISSET(fd, fdsetp)\t__FD_ISSET (fd, fdsetp)\n#define\tFD_ZERO(fdsetp)\t\t__FD_ZERO (fdsetp)\n\n__BEGIN_DECLS\n/* Check the first NFDS descriptors each in READFDS (if not NULL) for read\n   readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS\n   (if not NULL) for exceptional conditions.  If TIMEOUT is not NULL, time out\n   after waiting the interval specified therein.  Returns the number of ready\n   descriptors, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int select(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, struct timeval *__restrict __timeout);\n\n#ifdef __USE_XOPEN2K\n/* Same as above only that the TIMEOUT value is given with higher\n   resolution and a sigmask which is been set temporarily.  This version\n   should be used.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pselect(int __nfds, fd_set * __restrict __readfds, fd_set * __restrict __writefds, fd_set * __restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t * __restrict __sigmask);\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__\n#include <bits/select2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/select.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/socket.h",
    "content": "/* Declarations of socket constants, types, and functions.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_SOCKET_H\n#define\t_SYS_SOCKET_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <sys/uio.h>\n#define\t__need_size_t\n#include <stddef.h>\n#ifdef __USE_GNU\n/* Get the __sigset_t definition.  */\n#include <bits/sigset.h>\n#endif\n/* This operating system-specific header file defines the SOCK_*, PF_*,\n   AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',\n   `struct msghdr', and `struct linger' types.  */\n#include <bits/socket.h>\n#ifdef __USE_MISC\n/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire\n   format in the grotty old 4.3 `talk' protocol.  */\n    struct osockaddr {\n\tunsigned short int sa_family;\n\tunsigned char sa_data[14];\n};\n#endif\n\n/* The following constants should be used for the second parameter of\n   `shutdown'.  */\nenum {\n\tSHUT_RD = 0,\t\t/* No more receptions.  */\n#define SHUT_RD\t\tSHUT_RD\n\tSHUT_WR,\t\t/* No more transmissions.  */\n#define SHUT_WR\t\tSHUT_WR\n\tSHUT_RDWR\t\t/* No more receptions or transmissions.  */\n#define SHUT_RDWR\tSHUT_RDWR\n};\n\n/* This is the type we use for generic socket address arguments.\n\n   With GCC 2.7 and later, the funky union causes redeclarations or\n   uses with any of the listed types to be allowed without complaint.\n   G++ 2.7 does not support transparent unions so there we want the\n   old-style declaration, too.  */\n#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU\n#define __SOCKADDR_ARG\t\tstruct sockaddr *__restrict\n#define __CONST_SOCKADDR_ARG\tconst struct sockaddr *\n#else\n/* Add more `struct sockaddr_AF' types here as necessary.\n   These are all the ones I found on NetBSD and Linux.  */\n#define __SOCKADDR_ALLTYPES \\\n  __SOCKADDR_ONETYPE (sockaddr) \\\n  __SOCKADDR_ONETYPE (sockaddr_at) \\\n  __SOCKADDR_ONETYPE (sockaddr_ax25) \\\n  __SOCKADDR_ONETYPE (sockaddr_dl) \\\n  __SOCKADDR_ONETYPE (sockaddr_eon) \\\n  __SOCKADDR_ONETYPE (sockaddr_in) \\\n  __SOCKADDR_ONETYPE (sockaddr_in6) \\\n  __SOCKADDR_ONETYPE (sockaddr_inarp) \\\n  __SOCKADDR_ONETYPE (sockaddr_ipx) \\\n  __SOCKADDR_ONETYPE (sockaddr_iso) \\\n  __SOCKADDR_ONETYPE (sockaddr_ns) \\\n  __SOCKADDR_ONETYPE (sockaddr_un) \\\n  __SOCKADDR_ONETYPE (sockaddr_x25)\n\n#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __SOCKADDR_ARG __attribute__ ((__transparent_union__));\n#undef __SOCKADDR_ONETYPE\n#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;\ntypedef union {\n__SOCKADDR_ALLTYPES} __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__));\n#undef __SOCKADDR_ONETYPE\n#endif\n\n#ifdef __USE_GNU\n/* For `recvmmsg' and `sendmmsg'.  */\nstruct mmsghdr {\n\tstruct msghdr msg_hdr;\t/* Actual message header.  */\n\tunsigned int msg_len;\t/* Number of received or sent bytes for the\n\t\t\t\t   entry.  */\n};\n#endif\n\n/* Create a new socket of type TYPE in domain DOMAIN, using\n   protocol PROTOCOL.  If PROTOCOL is zero, one is chosen automatically.\n   Returns a file descriptor for the new socket, or -1 for errors.  */\nextern int socket(int __domain, int __type, int __protocol) __THROW;\n\n/* Create two new sockets, of type TYPE in domain DOMAIN and using\n   protocol PROTOCOL, which are connected to each other, and put file\n   descriptors for them in FDS[0] and FDS[1].  If PROTOCOL is zero,\n   one will be chosen automatically.  Returns 0 on success, -1 for errors.  */\nextern int socketpair(int __domain, int __type, int __protocol, int __fds[2]) __THROW;\n\n/* Give the socket FD the local address ADDR (which is LEN bytes long).  */\nextern int bind(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) __THROW;\n\n/* Put the local address of FD into *ADDR and its length in *LEN.  */\nextern int getsockname(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Open a connection on socket FD to peer at ADDR (which LEN bytes long).\n   For connectionless socket types, just set the default address to send to\n   and the only address from which to accept transmissions.\n   Return 0 on success, -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int connect(int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);\n\n/* Put the address of the peer connected to socket FD into *ADDR\n   (which is *LEN bytes long), and its actual length into *LEN.  */\nextern int getpeername(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __len) __THROW;\n\n/* Send N bytes of BUF to socket FD.  Returns the number sent or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t send(int __fd, const void *__buf, size_t __n, int __flags);\n\n/* Read N bytes into BUF from socket FD.\n   Returns the number read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recv(int __fd, void *__buf, size_t __n, int __flags);\n\n/* Send N bytes of BUF on socket FD to peer at address ADDR (which is\n   ADDR_LEN bytes long).  Returns the number sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendto(int __fd, const void *__buf, size_t __n, int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);\n\n/* Read N bytes into BUF through socket FD.\n   If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of\n   the sender, and store the actual size of the address in *ADDR_LEN.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvfrom(int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n/* Send a message described MESSAGE on socket FD.\n   Returns the number of bytes sent, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t sendmsg(int __fd, const struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Send a VLEN messages as described by VMESSAGES to socket FD.\n   Returns the number of datagrams successfully written or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sendmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags);\n#endif\n\n/* Receive a message as described by MESSAGE from socket FD.\n   Returns the number of bytes read or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t recvmsg(int __fd, struct msghdr *__message, int __flags);\n\n#ifdef __USE_GNU\n/* Receive up to VLEN messages as described by VMESSAGES from socket FD.\n   Returns the number of messages received or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int recvmmsg(int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags, struct timespec *__tmo);\n#endif\n\n/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL\n   into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's\n   actual length.  Returns 0 on success, -1 for errors.  */\nextern int getsockopt(int __fd, int __level, int __optname, void *__restrict __optval, socklen_t * __restrict __optlen) __THROW;\n\n/* Set socket FD's option OPTNAME at protocol level LEVEL\n   to *OPTVAL (which is OPTLEN bytes long).\n   Returns 0 on success, -1 for errors.  */\nextern int setsockopt(int __fd, int __level, int __optname, const void *__optval, socklen_t __optlen) __THROW;\n\n/* Prepare to accept connections on socket FD.\n   N connection requests will be queued before further requests are refused.\n   Returns 0 on success, -1 for errors.  */\nextern int listen(int __fd, int __n) __THROW;\n\n/* Await a connection on socket FD.\n   When a connection arrives, open a new socket to communicate with it,\n   set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting\n   peer and *ADDR_LEN to the address's actual length, and return the\n   new socket's descriptor, or -1 for errors.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);\n\n#ifdef __USE_GNU\n/* Similar to 'accept' but takes an additional parameter to specify flags.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int accept4(int __fd, __SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len, int __flags);\n#endif\n\n/* Shut down all or part of the connection open on socket FD.\n   HOW determines what to shut down:\n     SHUT_RD   = No more receptions;\n     SHUT_WR   = No more transmissions;\n     SHUT_RDWR = No more receptions or transmissions.\n   Returns 0 on success, -1 for errors.  */\nextern int shutdown(int __fd, int __how) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Determine wheter socket is at a out-of-band mark.  */\nextern int sockatmark(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* FDTYPE is S_IFSOCK or another S_IF* macro defined in <sys/stat.h>;\n   returns 1 if FD is open on an object of the indicated type, 0 if not,\n   or -1 for errors (setting errno).  */\nextern int isfdtype(int __fd, int __fdtype) __THROW;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n#include <bits/socket2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/socket.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/stat.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6 File Characteristics\t<sys/stat.h>\n */\n\n#ifndef\t_SYS_STAT_H\n#define\t_SYS_STAT_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\t\t/* For __mode_t and __dev_t.  */\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K || defined __USE_ATFILE\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n#define __need_time_t\n#endif\n#ifdef __USE_ATFILE\n#define __need_timespec\n#endif\n#include <time.h>\t\t/* For time_t resp. timespec.  */\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n#ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n#define __dev_t_defined\n#endif\n\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#define __gid_t_defined\n#endif\n\n#ifndef __ino_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#else\ntypedef __ino64_t ino_t;\n#endif\n#define __ino_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#define __mode_t_defined\n#endif\n\n#ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n#define __nlink_t_defined\n#endif\n\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#define __uid_t_defined\n#endif\n#endif\t\t\t\t/* X/Open */\n\n#ifdef __USE_UNIX98\n#ifndef __blkcnt_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __blkcnt_t blkcnt_t;\n#else\ntypedef __blkcnt64_t blkcnt_t;\n#endif\n#define __blkcnt_t_defined\n#endif\n\n#ifndef __blksize_t_defined\ntypedef __blksize_t blksize_t;\n#define __blksize_t_defined\n#endif\n#endif\t\t\t\t/* Unix98 */\n\n__BEGIN_DECLS\n#include <bits/stat.h>\n#if defined __USE_MISC || defined __USE_XOPEN\n#define S_IFMT\t\t__S_IFMT\n#define S_IFDIR\t__S_IFDIR\n#define S_IFCHR\t__S_IFCHR\n#define S_IFBLK\t__S_IFBLK\n#define S_IFREG\t__S_IFREG\n#ifdef __S_IFIFO\n#define S_IFIFO\t__S_IFIFO\n#endif\n#ifdef __S_IFLNK\n#define S_IFLNK\t__S_IFLNK\n#endif\n#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) \\\n     && defined __S_IFSOCK\n#define S_IFSOCK\t__S_IFSOCK\n#endif\n#endif\n/* Test macros for file types.\t*/\n#define\t__S_ISTYPE(mode, mask)\t(((mode) & __S_IFMT) == (mask))\n#define\tS_ISDIR(mode)\t __S_ISTYPE((mode), __S_IFDIR)\n#define\tS_ISCHR(mode)\t __S_ISTYPE((mode), __S_IFCHR)\n#define\tS_ISBLK(mode)\t __S_ISTYPE((mode), __S_IFBLK)\n#define\tS_ISREG(mode)\t __S_ISTYPE((mode), __S_IFREG)\n#ifdef __S_IFIFO\n#define S_ISFIFO(mode)\t __S_ISTYPE((mode), __S_IFIFO)\n#endif\n#ifdef __S_IFLNK\n#define S_ISLNK(mode)\t __S_ISTYPE((mode), __S_IFLNK)\n#endif\n#if defined __USE_MISC && !defined __S_IFLNK\n#define S_ISLNK(mode)  0\n#endif\n#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K) \\\n    && defined __S_IFSOCK\n#define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK)\n#elif defined __USE_XOPEN2K\n#define S_ISSOCK(mode) 0\n#endif\n/* These are from POSIX.1b.  If the objects are not implemented using separate\n   distinct file types, the macros always will evaluate to zero.  Unlike the\n   other S_* macros the following three take a pointer to a `struct stat'\n   object as the argument.  */\n#ifdef\t__USE_POSIX199309\n#define S_TYPEISMQ(buf) __S_TYPEISMQ(buf)\n#define S_TYPEISSEM(buf) __S_TYPEISSEM(buf)\n#define S_TYPEISSHM(buf) __S_TYPEISSHM(buf)\n#endif\n/* Protection bits.  */\n#define\tS_ISUID __S_ISUID\t/* Set user ID on execution.  */\n#define\tS_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n#define S_ISVTX\t__S_ISVTX\n#endif\n#define\tS_IRUSR\t__S_IREAD\t/* Read by owner.  */\n#define\tS_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n#define\tS_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n#define\tS_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n#ifdef __USE_MISC\n#define S_IREAD\tS_IRUSR\n#define S_IWRITE\tS_IWUSR\n#define S_IEXEC\tS_IXUSR\n#endif\n#define\tS_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n#define\tS_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n#define\tS_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n#define\tS_IRWXG\t(S_IRWXU >> 3)\n#define\tS_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n#define\tS_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n#define\tS_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n#define\tS_IRWXO\t(S_IRWXG >> 3)\n#ifdef\t__USE_MISC\n/* Macros for common mode bit masks.  */\n#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)\t/* 0777 */\n#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)\t/* 07777 */\n#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)\t/* 0666 */\n#define S_BLKSIZE\t512\t/* Block size for `st_blocks'.  */\n#endif\n#ifndef __USE_FILE_OFFSET64\n/* Get file attributes for FILE and put them in BUF.  */\nextern int stat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n\n/* Get file attributes for the file, device, pipe, or socket\n   that file descriptor FD is open on and put them in BUF.  */\nextern int fstat(int __fd, struct stat *__buf)\n__THROW __nonnull((2));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(stat, (const char *__restrict __file, struct stat * __restrict __buf), stat64) __nonnull((1, 2));\nextern int __REDIRECT_NTH(fstat, (int __fd, struct stat * __buf), fstat64) __nonnull((2));\n#else\n#define stat stat64\n#define fstat fstat64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int stat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\nextern int fstat64(int __fd, struct stat64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to stat, get the attributes for FILE and put them in BUF.\n   Relative path names are interpreted relative to FD unless FD is\n   AT_FDCWD.  */\n#ifndef __USE_FILE_OFFSET64\nextern int fstatat(int __fd, const char *__restrict __file, struct stat *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatat, (int __fd, const char *__restrict __file, struct stat * __restrict __buf, int __flag), fstatat64) __nonnull((2, 3));\n#else\n#define fstatat fstatat64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int fstatat64(int __fd, const char *__restrict __file, struct stat64 *__restrict __buf, int __flag)\n__THROW __nonnull((2, 3));\n#endif\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n#ifndef __USE_FILE_OFFSET64\n/* Get file attributes about FILE and put them in BUF.\n   If FILE is a symbolic link, do not follow it.  */\nextern int lstat(const char *__restrict __file, struct stat *__restrict __buf)\n__THROW __nonnull((1, 2));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(lstat, (const char *__restrict __file, struct stat * __restrict __buf), lstat64) __nonnull((1, 2));\n#else\n#define lstat lstat64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int lstat64(const char *__restrict __file, struct stat64 *__restrict __buf)\n__THROW __nonnull((1, 2));\n#endif\n#endif\n\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects its target instead.  */\nextern int chmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set file access permissions for FILE to MODE.\n   If FILE is a symbolic link, this affects the link itself\n   rather than its target.  */\nextern int lchmod(const char *__file, __mode_t __mode)\n__THROW __nonnull((1));\n#endif\n\n/* Set file access permissions of the file FD is open on to MODE.  */\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\nextern int fchmod(int __fd, __mode_t __mode) __THROW;\n#endif\n\n#ifdef __USE_ATFILE\n/* Set file access permissions of FILE relative to\n   the directory FD is open on.  */\nextern int fchmodat(int __fd, const char *__file, __mode_t __mode, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use ATFILE.  */\n\n/* Set the file creation mask of the current process to MASK,\n   and return the old creation mask.  */\nextern __mode_t umask(__mode_t __mask) __THROW;\n\n#ifdef\t__USE_GNU\n/* Get the current `umask' value without changing it.\n   This function is only available under the GNU Hurd.  */\nextern __mode_t getumask(void) __THROW;\n#endif\n\n/* Create a new directory named PATH, with permission bits MODE.  */\nextern int mkdir(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkdir, create a new directory with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkdirat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\n/* Create a device file named PATH, with permission and special bits MODE\n   and device number DEV (which can be constructed from major and minor\n   device numbers with the `makedev' macro above).  */\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\nextern int mknod(const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mknod, create a new device file with permission bits MODE and\n   device number DEV.  But interpret relative PATH names relative to\n   the directory associated with FD.  */\nextern int mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev)\n__THROW __nonnull((2));\n#endif\n#endif\n\n/* Create a new FIFO named PATH, with permission bits MODE.  */\nextern int mkfifo(const char *__path, __mode_t __mode)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Like mkfifo, create a new FIFO with permission bits MODE.  But\n   interpret relative PATH names relative to the directory associated\n   with FD.  */\nextern int mkfifoat(int __fd, const char *__path, __mode_t __mode)\n__THROW __nonnull((2));\n#endif\n\f\n#ifdef __USE_ATFILE\n/* Set file access and modification times relative to directory file\n   descriptor.  */\nextern int utimensat(int __fd, const char *__path, const struct timespec __times[2], int __flags)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Set file access and modification times of the file associated with FD.  */\nextern int futimens(int __fd, const struct timespec __times[2]) __THROW;\n#endif\n\f\n/* To allow the `struct stat' structure and the file type `mode_t'\n   bits to vary without changing shared library major version number,\n   the `stat' family of functions and `mknod' are in fact inline\n   wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',\n   which all take a leading version-number argument designating the\n   data structure and bits used.  <bits/stat.h> defines _STAT_VER with\n   the version number corresponding to `struct stat' as defined in\n   that file; and _MKNOD_VER with the version number corresponding to\n   the S_IF* macros defined therein.  It is arranged that when not\n   inlined these function are always statically linked; that way a\n   dynamically-linked executable always encodes the version number\n   corresponding to the data structures it uses, so the `x' functions\n   in the shared library can adapt without needing to recompile all\n   callers.  */\n\n#ifndef _STAT_VER\n#define _STAT_VER\t0\n#endif\n#ifndef _MKNOD_VER\n#define _MKNOD_VER\t0\n#endif\n\n/* Wrappers for stat and mknod system calls.  */\n#ifndef __USE_FILE_OFFSET64\nextern int __fxstat(int __ver, int __fildes, struct stat *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat(int __ver, const char *__filename, struct stat *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat(int __ver, int __fildes, const char *__filename, struct stat *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(__fxstat, (int __ver, int __fildes, struct stat * __stat_buf), __fxstat64) __nonnull((3));\nextern int __REDIRECT_NTH(__xstat, (int __ver, const char *__filename, struct stat * __stat_buf), __xstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__lxstat, (int __ver, const char *__filename, struct stat * __stat_buf), __lxstat64) __nonnull((2, 3));\nextern int __REDIRECT_NTH(__fxstatat, (int __ver, int __fildes, const char *__filename, struct stat * __stat_buf, int __flag), __fxstatat64) __nonnull((3, 4));\n\n#else\n#define __fxstat __fxstat64\n#define __xstat __xstat64\n#define __lxstat __lxstat64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int __fxstat64(int __ver, int __fildes, struct stat64 *__stat_buf)\n__THROW __nonnull((3));\nextern int __xstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __lxstat64(int __ver, const char *__filename, struct stat64 *__stat_buf)\n__THROW __nonnull((2, 3));\nextern int __fxstatat64(int __ver, int __fildes, const char *__filename, struct stat64 *__stat_buf, int __flag)\n__THROW __nonnull((3, 4));\n#endif\nextern int __xmknod(int __ver, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((2, 4));\n\nextern int __xmknodat(int __ver, int __fd, const char *__path, __mode_t __mode, __dev_t * __dev)\n__THROW __nonnull((3, 5));\n\n#ifdef __USE_EXTERN_INLINES\n/* Inlined versions of the real stat and mknod functions.  */\n\n__extern_inline int __NTH(stat(const char *__path, struct stat *__statbuf))\n{\n\treturn __xstat(_STAT_VER, __path, __statbuf);\n}\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat(const char *__path, struct stat *__statbuf))\n{\n\treturn __lxstat(_STAT_VER, __path, __statbuf);\n}\n#endif\n\n__extern_inline int __NTH(fstat(int __fd, struct stat *__statbuf))\n{\n\treturn __fxstat(_STAT_VER, __fd, __statbuf);\n}\n\n#ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat(int __fd, const char *__filename, struct stat *__statbuf, int __flag))\n{\n\treturn __fxstatat(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n#endif\n\n#ifdef __USE_MISC\n__extern_inline int __NTH(mknod(const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknod(_MKNOD_VER, __path, __mode, &__dev);\n}\n#endif\n\n#ifdef __USE_ATFILE\n__extern_inline int __NTH(mknodat(int __fd, const char *__path, __mode_t __mode, __dev_t __dev))\n{\n\treturn __xmknodat(_MKNOD_VER, __fd, __path, __mode, &__dev);\n}\n#endif\n\n#if defined __USE_LARGEFILE64 \\\n  && (! defined __USE_FILE_OFFSET64 \\\n      || (defined __REDIRECT_NTH && defined __OPTIMIZE__))\n__extern_inline int __NTH(stat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __xstat64(_STAT_VER, __path, __statbuf);\n}\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n__extern_inline int __NTH(lstat64(const char *__path, struct stat64 *__statbuf))\n{\n\treturn __lxstat64(_STAT_VER, __path, __statbuf);\n}\n#endif\n\n__extern_inline int __NTH(fstat64(int __fd, struct stat64 *__statbuf))\n{\n\treturn __fxstat64(_STAT_VER, __fd, __statbuf);\n}\n\n#ifdef __USE_ATFILE\n__extern_inline int __NTH(fstatat64(int __fd, const char *__filename, struct stat64 *__statbuf, int __flag))\n{\n\treturn __fxstatat64(_STAT_VER, __fd, __filename, __statbuf, __flag);\n}\n#endif\n\n#endif\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/stat.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/statfs.h",
    "content": "/* Definitions for getting information about a filesystem.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_STATFS_H\n#define\t_SYS_STATFS_H\t1\n\n#include <features.h>\n\n/* Get the system-specific definition of `struct statfs'.  */\n#include <bits/statfs.h>\n\n__BEGIN_DECLS\n/* Return information about the filesystem on which FILE resides.  */\n#ifndef __USE_FILE_OFFSET64\nextern int statfs(const char *__file, struct statfs *__buf)\n__THROW __nonnull((1, 2));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(statfs, (const char *__file, struct statfs * __buf), statfs64) __nonnull((1, 2));\n#else\n#define statfs statfs64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int statfs64(const char *__file, struct statfs64 *__buf)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Return information about the filesystem containing the file FILDES\n   refers to.  */\n#ifndef __USE_FILE_OFFSET64\nextern int fstatfs(int __fildes, struct statfs *__buf)\n__THROW __nonnull((2));\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(fstatfs, (int __fildes, struct statfs * __buf), fstatfs64) __nonnull((2));\n#else\n#define fstatfs fstatfs64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int fstatfs64(int __fildes, struct statfs64 *__buf)\n__THROW __nonnull((2));\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/statfs.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/sysmacros.h",
    "content": "/* Definitions of macros to access `dev_t' values.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_SYSMACROS_H\n#define _SYS_SYSMACROS_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS __extension__ extern unsigned int gnu_dev_major(unsigned long long int __dev)\n__THROW __attribute_const__;\n__extension__ extern unsigned int gnu_dev_minor(unsigned long long int __dev)\n__THROW __attribute_const__;\n__extension__ extern unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor)\n__THROW __attribute_const__;\n\n#ifdef __USE_EXTERN_INLINES\n__extension__ __extern_inline __attribute_const__ unsigned int __NTH(gnu_dev_major(unsigned long long int __dev))\n{\n\treturn ((__dev >> 8) & 0xfff) | ((unsigned int)(__dev >> 32) & ~0xfff);\n}\n\n__extension__ __extern_inline __attribute_const__ unsigned int __NTH(gnu_dev_minor(unsigned long long int __dev))\n{\n\treturn (__dev & 0xff) | ((unsigned int)(__dev >> 12) & ~0xff);\n}\n\n__extension__ __extern_inline __attribute_const__ unsigned long long int __NTH(gnu_dev_makedev(unsigned int __major, unsigned int __minor))\n{\n\treturn ((__minor & 0xff) | ((__major & 0xfff) << 8)\n\t\t| (((unsigned long long int)(__minor & ~0xff)) << 12)\n\t\t| (((unsigned long long int)(__major & ~0xfff)) << 32));\n}\n#endif\n__END_DECLS\n/* Access the functions with their traditional names.  */\n#define major(dev) gnu_dev_major (dev)\n#define minor(dev) gnu_dev_minor (dev)\n#define makedev(maj, min) gnu_dev_makedev (maj, min)\n#endif\t\t\t\t/* sys/sysmacros.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/time.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_TIME_H\n#define _SYS_TIME_H\t1\n\n#include <features.h>\n\n#include <bits/types.h>\n#define __need_time_t\n#include <time.h>\n#define __need_timeval\n#include <bits/time.h>\n\n#include <sys/select.h>\n\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n#define __suseconds_t_defined\n#endif\n\n__BEGIN_DECLS\n#ifdef __USE_GNU\n/* Macros for converting between `struct timeval' and `struct timespec'.  */\n#define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \\\n\t(ts)->tv_sec = (tv)->tv_sec;                                    \\\n\t(ts)->tv_nsec = (tv)->tv_usec * 1000;                           \\\n}\n#define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \\\n\t(tv)->tv_sec = (ts)->tv_sec;                                    \\\n\t(tv)->tv_usec = (ts)->tv_nsec / 1000;                           \\\n}\n#endif\n#ifdef __USE_MISC\n/* Structure crudely representing a timezone.\n   This is obsolete and should never be used.  */\n    struct timezone {\n\tint tz_minuteswest;\t/* Minutes west of GMT.  */\n\tint tz_dsttime;\t\t/* Nonzero if DST is ever in effect.  */\n};\n\ntypedef struct timezone *__restrict __timezone_ptr_t;\n#else\ntypedef void *__restrict __timezone_ptr_t;\n#endif\n\n/* Get the current time of day and timezone information,\n   putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.\n   Returns 0 on success, -1 on errors.\n   NOTE: This form of timezone information is obsolete.\n   Use the functions and variables declared in <time.h> instead.  */\nextern int gettimeofday(struct timeval *__restrict __tv, __timezone_ptr_t __tz)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Set the current time of day and timezone information.\n   This call is restricted to the super-user.  */\nextern int settimeofday(const struct timeval *__tv, const struct timezone *__tz) __THROW;\n\n/* Adjust the current time of day by the amount in DELTA.\n   If OLDDELTA is not NULL, it is filled in with the amount\n   of time adjustment remaining to be done from the last `adjtime' call.\n   This call is restricted to the super-user.  */\nextern int adjtime(const struct timeval *__delta, struct timeval *__olddelta) __THROW;\n#endif\n\n/* Values for the first argument to `getitimer' and `setitimer'.  */\nenum __itimer_which {\n\t/* Timers run in real time.  */\n\tITIMER_REAL = 0,\n#define ITIMER_REAL ITIMER_REAL\n\t/* Timers run only when the process is executing.  */\n\tITIMER_VIRTUAL = 1,\n#define ITIMER_VIRTUAL ITIMER_VIRTUAL\n\t/* Timers run when the process is executing and when\n\t   the system is executing on behalf of the process.  */\n\tITIMER_PROF = 2\n#define ITIMER_PROF ITIMER_PROF\n};\n\n/* Type of the second argument to `getitimer' and\n   the second and third arguments `setitimer'.  */\nstruct itimerval {\n\t/* Value to put into `it_value' when the timer expires.  */\n\tstruct timeval it_interval;\n\t/* Time to the next timer expiration.  */\n\tstruct timeval it_value;\n};\n\n#if defined __USE_GNU && !defined __cplusplus\n/* Use the nicer parameter type only in GNU mode and not for C++ since the\n   strict C++ rules prevent the automatic promotion.  */\ntypedef enum __itimer_which __itimer_which_t;\n#else\ntypedef int __itimer_which_t;\n#endif\n\n/* Set *VALUE to the current setting of timer WHICH.\n   Return 0 on success, -1 on errors.  */\nextern int getitimer(__itimer_which_t __which, struct itimerval *__value) __THROW;\n\n/* Set the timer WHICH to *NEW.  If OLD is not NULL,\n   set *OLD to the old value of timer WHICH.\n   Returns 0 on success, -1 on errors.  */\nextern int setitimer(__itimer_which_t __which, const struct itimerval *__restrict __new, struct itimerval *__restrict __old) __THROW;\n\n/* Change the access time of FILE to TVP[0] and the modification time of\n   FILE to TVP[1].  If TVP is a null pointer, use the current time instead.\n   Returns 0 on success, -1 on errors.  */\nextern int utimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Same as `utimes', but does not follow symbolic links.  */\nextern int lutimes(const char *__file, const struct timeval __tvp[2])\n__THROW __nonnull((1));\n\n/* Same as `utimes', but takes an open file descriptor instead of a name.  */\nextern int futimes(int __fd, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Change the access time of FILE relative to FD to TVP[0] and the\n   modification time of FILE to TVP[1].  If TVP is a null pointer, use\n   the current time instead.  Returns 0 on success, -1 on errors.  */\nextern int futimesat(int __fd, const char *__file, const struct timeval __tvp[2]) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Convenience macros for operations on timevals.\n   NOTE: `timercmp' does not work for >= or <=.  */\n#define timerisset(tvp)\t((tvp)->tv_sec || (tvp)->tv_usec)\n#define timerclear(tvp)\t((tvp)->tv_sec = (tvp)->tv_usec = 0)\n#define timercmp(a, b, CMP) \t\t\t\t\t\t      \\\n  (((a)->tv_sec == (b)->tv_sec) ? \t\t\t\t\t      \\\n   ((a)->tv_usec CMP (b)->tv_usec) : \t\t\t\t\t      \\\n   ((a)->tv_sec CMP (b)->tv_sec))\n#define timeradd(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec >= 1000000)\t\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t++(result)->tv_sec;\t\t\t\t\t\t      \\\n\t(result)->tv_usec -= 1000000;\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n#define timersub(a, b, result)\t\t\t\t\t\t      \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;\t\t\t      \\\n    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;\t\t\t      \\\n    if ((result)->tv_usec < 0) {\t\t\t\t\t      \\\n      --(result)->tv_sec;\t\t\t\t\t\t      \\\n      (result)->tv_usec += 1000000;\t\t\t\t\t      \\\n    }\t\t\t\t\t\t\t\t\t      \\\n  } while (0)\n#endif\t\t\t\t/* Misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/time.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/ttydefaults.h",
    "content": "/*-\n * Copyright (c) 1982, 1986, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n * (c) UNIX System Laboratories, Inc.\n * All or some portions of this file are derived from material licensed\n * to the University of California by American Telephone and Telegraph\n * Co. or Unix System Laboratories, Inc. and are reproduced herein with\n * the permission of UNIX System Laboratories, Inc.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)ttydefaults.h\t8.4 (Berkeley) 1/21/94\n */\n\n/*\n * System wide defaults for terminal state.  Linux version.\n */\n#ifndef _SYS_TTYDEFAULTS_H_\n#define\t_SYS_TTYDEFAULTS_H_\n\n/*\n * Defaults on \"first\" open.\n */\n#define\tTTYDEF_IFLAG\t(BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)\n#define TTYDEF_OFLAG\t(OPOST | ONLCR | XTABS)\n#define TTYDEF_LFLAG\t(ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)\n#define TTYDEF_CFLAG\t(CREAD | CS7 | PARENB | HUPCL)\n#define TTYDEF_SPEED\t(B9600)\n\n/*\n * Control Character Defaults\n */\n#define CTRL(x)\t(x&037)\n#define\tCEOF\t\tCTRL('d')\n#ifdef _POSIX_VDISABLE\n#define CEOL\t\t_POSIX_VDISABLE\n#else\n#define CEOL\t\t'\\0'\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCERASE\t\t0177\n#define\tCINTR\t\tCTRL('c')\n#ifdef _POSIX_VDISABLE\n#define CSTATUS\t_POSIX_VDISABLE\n#else\n#define CSTATUS\t'\\0'\t\t/* XXX avoid _POSIX_VDISABLE */\n#endif\n#define\tCKILL\t\tCTRL('u')\n#define\tCMIN\t\t1\n#define\tCQUIT\t\t034\t/* FS, ^\\ */\n#define\tCSUSP\t\tCTRL('z')\n#define\tCTIME\t\t0\n#define\tCDSUSP\t\tCTRL('y')\n#define\tCSTART\t\tCTRL('q')\n#define\tCSTOP\t\tCTRL('s')\n#define\tCLNEXT\t\tCTRL('v')\n#define\tCDISCARD \tCTRL('o')\n#define\tCWERASE \tCTRL('w')\n#define\tCREPRINT \tCTRL('r')\n#define\tCEOT\t\tCEOF\n/* compat */\n#define\tCBRK\t\tCEOL\n#define CRPRNT\t\tCREPRINT\n#define\tCFLUSH\t\tCDISCARD\n\n/* PROTECTED INCLUSION ENDS HERE */\n#endif\t\t\t\t/* !_SYS_TTYDEFAULTS_H_ */\n\n/*\n * #define TTYDEFCHARS to include an array of default control characters.\n */\n#ifdef TTYDEFCHARS\ncc_t ttydefchars[NCCS] = {\n\tCEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,\n\t_POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,\n\tCDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE\n};\n\n#undef TTYDEFCHARS\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/types.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.6 Primitive System Data Types\t<sys/types.h>\n */\n\n#ifndef\t_SYS_TYPES_H\n#define\t_SYS_TYPES_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef\t__USE_MISC\n#ifndef __u_char_defined\ntypedef __u_char u_char;\ntypedef __u_short u_short;\ntypedef __u_int u_int;\ntypedef __u_long u_long;\ntypedef __quad_t quad_t;\ntypedef __u_quad_t u_quad_t;\ntypedef __fsid_t fsid_t;\n#define __u_char_defined\n#endif\n#endif\n\ntypedef __loff_t loff_t;\n\n#ifndef __ino_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#else\ntypedef __ino64_t ino_t;\n#endif\n#define __ino_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n#define __ino64_t_defined\n#endif\n\n#ifndef __dev_t_defined\ntypedef __dev_t dev_t;\n#define __dev_t_defined\n#endif\n\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#define __gid_t_defined\n#endif\n\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#define __mode_t_defined\n#endif\n\n#ifndef __nlink_t_defined\ntypedef __nlink_t nlink_t;\n#define __nlink_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#define __uid_t_defined\n#endif\n\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \\\n    && !defined __id_t_defined\ntypedef __id_t id_t;\n#define __id_t_defined\n#endif\n\n#ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n#define __ssize_t_defined\n#endif\n\n#ifdef\t__USE_MISC\n#ifndef __daddr_t_defined\ntypedef __daddr_t daddr_t;\ntypedef __caddr_t caddr_t;\n#define __daddr_t_defined\n#endif\n#endif\n\n#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined\ntypedef __key_t key_t;\n#define __key_t_defined\n#endif\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#define __need_clock_t\n#endif\n#define\t__need_time_t\n#define __need_timer_t\n#define __need_clockid_t\n#include <time.h>\n\n#ifdef __USE_XOPEN\n#ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#define __useconds_t_defined\n#endif\n#ifndef __suseconds_t_defined\ntypedef __suseconds_t suseconds_t;\n#define __suseconds_t_defined\n#endif\n#endif\n\n#define\t__need_size_t\n#include <stddef.h>\n\n#ifdef __USE_MISC\n/* Old compatibility names for C types.  */\ntypedef unsigned long int ulong;\ntypedef unsigned short int ushort;\ntypedef unsigned int uint;\n#endif\n\n/* These size-specific names are used by some of the inet code.  */\n\n#if !__GNUC_PREREQ (2, 7)\n\n/* These types are defined by the ISO C99 header <inttypes.h>. */\n#ifndef __int8_t_defined\n#define __int8_t_defined\ntypedef char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\n#if __WORDSIZE == 64\ntypedef long int int64_t;\n#else\n__extension__ typedef long long int int64_t;\n#endif\n#endif\n\n/* But these were defined by ISO C without the first `_'.  */\ntypedef unsigned char u_int8_t;\ntypedef unsigned short int u_int16_t;\ntypedef unsigned int u_int32_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int u_int64_t;\n#else\n__extension__ typedef unsigned long long int u_int64_t;\n#endif\n\ntypedef int register_t;\n\n#else\n\n/* For GCC 2.7 and later, we can use specific type-size attributes.  */\n#define __intN_t(N, MODE) \\\n  typedef int int##N##_t __attribute__ ((__mode__ (MODE)))\n#define __u_intN_t(N, MODE) \\\n  typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE)))\n\n#ifndef __int8_t_defined\n#define __int8_t_defined\n__intN_t(8, __QI__);\n__intN_t(16, __HI__);\n__intN_t(32, __SI__);\n__intN_t(64, __DI__);\n#endif\n\n__u_intN_t(8, __QI__);\n__u_intN_t(16, __HI__);\n__u_intN_t(32, __SI__);\n__u_intN_t(64, __DI__);\n\ntypedef int register_t __attribute__ ((__mode__(__word__)));\n\n/* Some code from BIND tests this macro to see if the types above are\n   defined.  */\n#endif\n#define __BIT_TYPES_DEFINED__\t1\n\n#ifdef\t__USE_MISC\n/* In BSD <sys/types.h> is expected to define BYTE_ORDER.  */\n#include <endian.h>\n\n/* It also defines `fd_set' and the FD_* macros for `select'.  */\n#include <sys/select.h>\n\n/* BSD defines these symbols, so we follow.  */\n#include <sys/sysmacros.h>\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \\\n    && !defined __blksize_t_defined\ntypedef __blksize_t blksize_t;\n#define __blksize_t_defined\n#endif\n\n/* Types from the Large File Support interface.  */\n#ifndef __USE_FILE_OFFSET64\n#ifndef __blkcnt_t_defined\ntypedef __blkcnt_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#define __blkcnt_t_defined\n#endif\n#ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#define __fsblkcnt_t_defined\n#endif\n#ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#define __fsfilcnt_t_defined\n#endif\n#else\n#ifndef __blkcnt_t_defined\ntypedef __blkcnt64_t blkcnt_t;\t/* Type to count number of disk blocks.  */\n#define __blkcnt_t_defined\n#endif\n#ifndef __fsblkcnt_t_defined\ntypedef __fsblkcnt64_t fsblkcnt_t;\t/* Type to count file system blocks.  */\n#define __fsblkcnt_t_defined\n#endif\n#ifndef __fsfilcnt_t_defined\ntypedef __fsfilcnt64_t fsfilcnt_t;\t/* Type to count file system inodes.  */\n#define __fsfilcnt_t_defined\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\ntypedef __blkcnt64_t blkcnt64_t;\t/* Type to count number of disk blocks. */\ntypedef __fsblkcnt64_t fsblkcnt64_t;\t/* Type to count file system blocks.  */\ntypedef __fsfilcnt64_t fsfilcnt64_t;\t/* Type to count file system inodes.  */\n#endif\n\n/* Now add the thread types.  */\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n#include <bits/pthreadtypes.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/types.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/ucontext.h",
    "content": "/* Copyright (C) 1998-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library.  If not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/* System V/ARM ABI compliant context switching support.  */\n\n#ifndef _SYS_UCONTEXT_H\n#define _SYS_UCONTEXT_H\t1\n\n#include <features.h>\n#include <signal.h>\n\n/* We need the signal context definitions even if they are not used\n   included in <signal.h>.  */\n#include <bits/sigcontext.h>\n\ntypedef int greg_t;\n\n/* Number of general registers.  */\n#define NGREG\t18\n\n/* Container for all general registers.  */\ntypedef greg_t gregset_t[NGREG];\n\n/* Number of each register is the `gregset_t' array.  */\nenum {\n\tREG_R0 = 0,\n#define REG_R0\tREG_R0\n\tREG_R1 = 1,\n#define REG_R1\tREG_R1\n\tREG_R2 = 2,\n#define REG_R2\tREG_R2\n\tREG_R3 = 3,\n#define REG_R3\tREG_R3\n\tREG_R4 = 4,\n#define REG_R4\tREG_R4\n\tREG_R5 = 5,\n#define REG_R5\tREG_R5\n\tREG_R6 = 6,\n#define REG_R6\tREG_R6\n\tREG_R7 = 7,\n#define REG_R7\tREG_R7\n\tREG_R8 = 8,\n#define REG_R8\tREG_R8\n\tREG_R9 = 9,\n#define REG_R9\tREG_R9\n\tREG_R10 = 10,\n#define REG_R10\tREG_R10\n\tREG_R11 = 11,\n#define REG_R11\tREG_R11\n\tREG_R12 = 12,\n#define REG_R12\tREG_R12\n\tREG_R13 = 13,\n#define REG_R13\tREG_R13\n\tREG_R14 = 14,\n#define REG_R14\tREG_R14\n\tREG_R15 = 15\n#define REG_R15\tREG_R15\n};\n\nstruct _libc_fpstate {\n\tstruct {\n\t\tunsigned int sign1:1;\n\t\tunsigned int unused:15;\n\t\tunsigned int sign2:1;\n\t\tunsigned int exponent:14;\n\t\tunsigned int j:1;\n\t\tunsigned int mantissa1:31;\n\t\tunsigned int mantissa0:32;\n\t} fpregs[8];\n\tunsigned int fpsr:32;\n\tunsigned int fpcr:32;\n\tunsigned char ftype[8];\n\tunsigned int init_flag;\n};\n/* Structure to describe FPU registers.  */\ntypedef struct _libc_fpstate fpregset_t;\n\n/* Context to describe whole processor state.  This only describes\n   the core registers; coprocessor registers get saved elsewhere\n   (e.g. in uc_regspace, or somewhere unspecified on the stack\n   during non-RT signal handlers).  */\ntypedef struct sigcontext mcontext_t;\n\n/* Userlevel context.  */\ntypedef struct ucontext {\n\tunsigned long uc_flags;\n\tstruct ucontext *uc_link;\n\tstack_t uc_stack;\n\tmcontext_t uc_mcontext;\n\t__sigset_t uc_sigmask;\n\tunsigned long uc_regspace[128] __attribute__ ((__aligned__(8)));\n} ucontext_t;\n\n#endif\t\t\t\t/* sys/ucontext.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/uio.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _SYS_UIO_H\n#define _SYS_UIO_H\t1\n\n#include <features.h>\n\n#include <sys/types.h>\n\n__BEGIN_DECLS\n/* This file defines `struct iovec'.  */\n#include <bits/uio.h>\n/* Read data from file descriptor FD, and put the result in the\n   buffers described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.\n   Operates just like 'read' (see <unistd.h>) except that data are\n   put in IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t readv(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which\n   is a vector of COUNT 'struct iovec's, to file descriptor FD.\n   The data is written in the order specified.\n   Operates just like 'write' (see <unistd.h>) except that the data\n   are taken from IOVEC instead of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t writev(int __fd, const struct iovec *__iovec, int __count) __wur;\n\n#ifdef __USE_MISC\n#ifndef __USE_FILE_OFFSET64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev(int __fd, const struct iovec *__iovec, int __count, __off_t __offset) __wur;\n#else\n#ifdef __REDIRECT\nextern ssize_t __REDIRECT(preadv, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), preadv64) __wur;\nextern ssize_t __REDIRECT(pwritev, (int __fd, const struct iovec * __iovec, int __count, __off64_t __offset), pwritev64) __wur;\n#else\n#define preadv preadv64\n#define pwritev pwritev64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\n/* Read data from file descriptor FD at the given position OFFSET\n   without change the file pointer, and put the result in the buffers\n   described by IOVEC, which is a vector of COUNT 'struct iovec's.\n   The buffers are filled in the order specified.  Operates just like\n   'pread' (see <unistd.h>) except that data are put in IOVEC instead\n   of a contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t preadv64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n\n/* Write data pointed by the buffers described by IOVEC, which is a\n   vector of COUNT 'struct iovec's, to file descriptor FD at the given\n   position OFFSET without change the file pointer.  The data is\n   written in the order specified.  Operates just like 'pwrite' (see\n   <unistd.h>) except that the data are taken from IOVEC instead of a\n   contiguous buffer.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwritev64(int __fd, const struct iovec *__iovec, int __count, __off64_t __offset) __wur;\n#endif\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/uio.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/un.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SYS_UN_H\n#define\t_SYS_UN_H\t1\n\n#include <sys/cdefs.h>\n\n/* Get the definition of the macro to define the common sockaddr members.  */\n#include <bits/sockaddr.h>\n\n__BEGIN_DECLS\n/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket.  */\n    struct sockaddr_un {\n\t__SOCKADDR_COMMON(sun_);\n\tchar sun_path[108];\t/* Path name.  */\n};\n\n#ifdef __USE_MISC\n#include <string.h>\t\t/* For prototype of `strlen'.  */\n\n/* Evaluate to actual length of the `sockaddr_un' structure.  */\n#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path)\t      \\\n\t\t      + strlen ((ptr)->sun_path))\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sys/un.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/utsname.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 4.4 System Identification\t<sys/utsname.h>\n */\n\n#ifndef\t_SYS_UTSNAME_H\n#define\t_SYS_UTSNAME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/utsname.h>\n#ifndef _UTSNAME_SYSNAME_LENGTH\n#define _UTSNAME_SYSNAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_NODENAME_LENGTH\n#define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_RELEASE_LENGTH\n#define _UTSNAME_RELEASE_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_VERSION_LENGTH\n#define _UTSNAME_VERSION_LENGTH _UTSNAME_LENGTH\n#endif\n#ifndef _UTSNAME_MACHINE_LENGTH\n#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH\n#endif\n/* Structure describing the system and machine.  */\n    struct utsname {\n\t/* Name of the implementation of the operating system.  */\n\tchar sysname[_UTSNAME_SYSNAME_LENGTH];\n\n\t/* Name of this node on the network.  */\n\tchar nodename[_UTSNAME_NODENAME_LENGTH];\n\n\t/* Current release level of this implementation.  */\n\tchar release[_UTSNAME_RELEASE_LENGTH];\n\t/* Current version level of this release.  */\n\tchar version[_UTSNAME_VERSION_LENGTH];\n\n\t/* Name of the hardware type the system is running on.  */\n\tchar machine[_UTSNAME_MACHINE_LENGTH];\n\n#if _UTSNAME_DOMAIN_LENGTH - 0\n\t/* Name of the domain of this node on the network.  */\n#ifdef __USE_GNU\n\tchar domainname[_UTSNAME_DOMAIN_LENGTH];\n#else\n\tchar __domainname[_UTSNAME_DOMAIN_LENGTH];\n#endif\n#endif\n};\n\n#ifdef __USE_MISC\n/* Note that SVID assumes all members have the same size.  */\n#define SYS_NMLN  _UTSNAME_LENGTH\n#endif\n\n/* Put information about the system in NAME.  */\nextern int uname(struct utsname *__name) __THROW;\n\n__END_DECLS\n#endif\t\t\t\t/* sys/utsname.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/wait.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 3.2.1 Wait for Process Termination\t<sys/wait.h>\n */\n\n#ifndef\t_SYS_WAIT_H\n#define\t_SYS_WAIT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <signal.h>\n/* These macros could also be defined in <stdlib.h>.  */\n#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)\n/* This will define the `W*' macros for the flag\n   bits to `waitpid', `wait3', and `wait4'.  */\n#include <bits/waitflags.h>\n/* This will define all the `__W*' macros.  */\n#include <bits/waitstatus.h>\n#define WEXITSTATUS(status)\t__WEXITSTATUS (status)\n#define WTERMSIG(status)\t__WTERMSIG (status)\n#define WSTOPSIG(status)\t__WSTOPSIG (status)\n#define WIFEXITED(status)\t__WIFEXITED (status)\n#define WIFSIGNALED(status)\t__WIFSIGNALED (status)\n#define WIFSTOPPED(status)\t__WIFSTOPPED (status)\n#ifdef __WIFCONTINUED\n#define WIFCONTINUED(status)\t__WIFCONTINUED (status)\n#endif\n#endif\t\t\t\t/* <stdlib.h> not included.  */\n#ifdef\t__USE_MISC\n#define WCOREFLAG\t\t__WCOREFLAG\n#define WCOREDUMP(status)\t__WCOREDUMP (status)\n#define W_EXITCODE(ret, sig)\t__W_EXITCODE (ret, sig)\n#define W_STOPCODE(sig)\t__W_STOPCODE (sig)\n#endif\n/* Wait for a child to die.  When one does, put its status in *STAT_LOC\n   and return its process ID.  For errors, return (pid_t) -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t wait(int *__stat_loc);\n\n#ifdef\t__USE_MISC\n/* Special values for the PID argument to `waitpid' and `wait4'.  */\n#define WAIT_ANY\t(-1)\t/* Any process.  */\n#define WAIT_MYPGRP\t0\t/* Any process in my process group.  */\n#endif\n\n/* Wait for a child matching PID to die.\n   If PID is greater than 0, match any process whose process ID is PID.\n   If PID is (pid_t) -1, match any process.\n   If PID is (pid_t) 0, match any process with the\n   same process group as the current process.\n   If PID is less than -1, match any process whose\n   process group is the absolute value of PID.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, return (pid_t) 0.  If successful,\n   return PID and store the dead child's status in STAT_LOC.\n   Return (pid_t) -1 for errors.  If the WUNTRACED bit is\n   set in OPTIONS, return status for stopped children; otherwise don't.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern __pid_t waitpid(__pid_t __pid, int *__stat_loc, int __options);\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#ifndef __id_t_defined\n#include <bits/types.h>\ntypedef __id_t id_t;\n#define __id_t_defined\n#endif\n\n#define __need_siginfo_t\n#include <bits/siginfo.h>\n\n/* Wait for a childing matching IDTYPE and ID to change the status and\n   place appropriate information in *INFOP.\n   If IDTYPE is P_PID, match any process whose process ID is ID.\n   If IDTYPE is P_PGID, match any process whose process group is ID.\n   If IDTYPE is P_ALL, match any process.\n   If the WNOHANG bit is set in OPTIONS, and that child\n   is not already dead, clear *INFOP and return 0.  If successful, store\n   exit code and status in *INFOP.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int waitid(idtype_t __idtype, __id_t __id, siginfo_t * __infop, int __options);\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* This being here makes the prototypes valid whether or not\n   we have already included <sys/resource.h> to define `struct rusage'.  */\nstruct rusage;\n\n/* Wait for a child to exit.  When one does, put its status in *STAT_LOC and\n   return its process ID.  For errors return (pid_t) -1.  If USAGE is not\n   nil, store information about the child's resource usage there.  If the\n   WUNTRACED bit is set in OPTIONS, return status for stopped children;\n   otherwise don't.  */\nextern __pid_t wait3(int *__stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\n\n#ifdef __USE_MISC\n/* PID is like waitpid.  Other args are like wait3.  */\nextern __pid_t wait4(__pid_t __pid, int *__stat_loc, int __options, struct rusage *__usage) __THROWNL;\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* sys/wait.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/arpa/inet.h",
    "content": "/* Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _ARPA_INET_H\n#define\t_ARPA_INET_H\t1\n\n#include <features.h>\n#include <netinet/in.h>\t\t/* To define `struct in_addr'.  */\n\n/* Type for length arguments in socket calls.  */\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n#define __socklen_t_defined\n#endif\n\n__BEGIN_DECLS\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data in network byte order.  */\nextern in_addr_t inet_addr(const char *__cp) __THROW;\n\n/* Return the local host address part of the Internet address in IN.  */\nextern in_addr_t inet_lnaof(struct in_addr __in) __THROW;\n\n/* Make Internet host address in network byte order by combining the\n   network number NET with the local address HOST.  */\nextern struct in_addr inet_makeaddr(in_addr_t __net, in_addr_t __host) __THROW;\n\n/* Return network number part of the Internet address IN.  */\nextern in_addr_t inet_netof(struct in_addr __in) __THROW;\n\n/* Extract the network number in network byte order from the address\n   in numbers-and-dots natation starting at CP.  */\nextern in_addr_t inet_network(const char *__cp) __THROW;\n\n/* Convert Internet number in IN to ASCII representation.  The return value\n   is a pointer to an internal array containing the string.  */\nextern char *inet_ntoa(struct in_addr __in) __THROW;\n\n/* Convert from presentation format of an Internet number in buffer\n   starting at CP to the binary network format and store result for\n   interface type AF in buffer starting at BUF.  */\nextern int inet_pton(int __af, const char *__restrict __cp, void *__restrict __buf) __THROW;\n\n/* Convert a Internet address in binary network format for interface\n   type AF in buffer starting at CP to presentation form and place\n   result in buffer of length LEN astarting at BUF.  */\nextern const char *inet_ntop(int __af, const void *__restrict __cp, char *__restrict __buf, socklen_t __len) __THROW;\n\n/* The following functions are not part of XNS 5.2.  */\n#ifdef __USE_MISC\n/* Convert Internet host address from numbers-and-dots notation in CP\n   into binary data and store the result in the structure INP.  */\nextern int inet_aton(const char *__cp, struct in_addr *__inp) __THROW;\n\n/* Format a network number NET into presentation format and place result\n   in buffer starting at BUF with length of LEN bytes.  */\nextern char *inet_neta(in_addr_t __net, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF in buffer starting at\n   CP to presentation format.  The result will specifiy BITS bits of\n   the number.  */\nextern char *inet_net_ntop(int __af, const void *__cp, int __bits, char *__buf, size_t __len) __THROW;\n\n/* Convert network number for interface type AF from presentation in\n   buffer starting at CP to network format and store result int\n   buffer starting at BUF of size LEN.  */\nextern int inet_net_pton(int __af, const char *__cp, void *__buf, size_t __len) __THROW;\n\n/* Convert ASCII representation in hexadecimal form of the Internet\n   address to binary form and place result in buffer of length LEN\n   starting at BUF.  */\nextern unsigned int inet_nsap_addr(const char *__cp, unsigned char *__buf, int __len) __THROW;\n\n/* Convert internet address in binary form in LEN bytes starting at CP\n   a presentation form and place result in BUF.  */\nextern char *inet_nsap_ntoa(int __len, const unsigned char *__cp, char *__buf) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* arpa/inet.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/errno-base.h",
    "content": "#ifndef _ASM_GENERIC_ERRNO_BASE_H\n#define _ASM_GENERIC_ERRNO_BASE_H\n\n#define\tEPERM\t\t 1\t/* Operation not permitted */\n#define\tENOENT\t\t 2\t/* No such file or directory */\n#define\tESRCH\t\t 3\t/* No such process */\n#define\tEINTR\t\t 4\t/* Interrupted system call */\n#define\tEIO\t\t 5\t/* I/O error */\n#define\tENXIO\t\t 6\t/* No such device or address */\n#define\tE2BIG\t\t 7\t/* Argument list too long */\n#define\tENOEXEC\t\t 8\t/* Exec format error */\n#define\tEBADF\t\t 9\t/* Bad file number */\n#define\tECHILD\t\t10\t/* No child processes */\n#define\tEAGAIN\t\t11\t/* Try again */\n#define\tENOMEM\t\t12\t/* Out of memory */\n#define\tEACCES\t\t13\t/* Permission denied */\n#define\tEFAULT\t\t14\t/* Bad address */\n#define\tENOTBLK\t\t15\t/* Block device required */\n#define\tEBUSY\t\t16\t/* Device or resource busy */\n#define\tEEXIST\t\t17\t/* File exists */\n#define\tEXDEV\t\t18\t/* Cross-device link */\n#define\tENODEV\t\t19\t/* No such device */\n#define\tENOTDIR\t\t20\t/* Not a directory */\n#define\tEISDIR\t\t21\t/* Is a directory */\n#define\tEINVAL\t\t22\t/* Invalid argument */\n#define\tENFILE\t\t23\t/* File table overflow */\n#define\tEMFILE\t\t24\t/* Too many open files */\n#define\tENOTTY\t\t25\t/* Not a typewriter */\n#define\tETXTBSY\t\t26\t/* Text file busy */\n#define\tEFBIG\t\t27\t/* File too large */\n#define\tENOSPC\t\t28\t/* No space left on device */\n#define\tESPIPE\t\t29\t/* Illegal seek */\n#define\tEROFS\t\t30\t/* Read-only file system */\n#define\tEMLINK\t\t31\t/* Too many links */\n#define\tEPIPE\t\t32\t/* Broken pipe */\n#define\tEDOM\t\t33\t/* Math argument out of domain of func */\n#define\tERANGE\t\t34\t/* Math result not representable */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/errno.h",
    "content": "#ifndef _ASM_GENERIC_ERRNO_H\n#define _ASM_GENERIC_ERRNO_H\n\n#include <asm-generic/errno-base.h>\n\n#define\tEDEADLK\t\t35\t/* Resource deadlock would occur */\n#define\tENAMETOOLONG\t36\t/* File name too long */\n#define\tENOLCK\t\t37\t/* No record locks available */\n\n/*\n * This error code is special: arch syscall entry code will return\n * -ENOSYS if users try to call a syscall that doesn't exist.  To keep\n * failures of syscalls that really do exist distinguishable from\n * failures due to attempts to use a nonexistent syscall, syscall\n * implementations should refrain from returning -ENOSYS.\n */\n#define\tENOSYS\t\t38\t/* Invalid system call number */\n\n#define\tENOTEMPTY\t39\t/* Directory not empty */\n#define\tELOOP\t\t40\t/* Too many symbolic links encountered */\n#define\tEWOULDBLOCK\tEAGAIN\t/* Operation would block */\n#define\tENOMSG\t\t42\t/* No message of desired type */\n#define\tEIDRM\t\t43\t/* Identifier removed */\n#define\tECHRNG\t\t44\t/* Channel number out of range */\n#define\tEL2NSYNC\t45\t/* Level 2 not synchronized */\n#define\tEL3HLT\t\t46\t/* Level 3 halted */\n#define\tEL3RST\t\t47\t/* Level 3 reset */\n#define\tELNRNG\t\t48\t/* Link number out of range */\n#define\tEUNATCH\t\t49\t/* Protocol driver not attached */\n#define\tENOCSI\t\t50\t/* No CSI structure available */\n#define\tEL2HLT\t\t51\t/* Level 2 halted */\n#define\tEBADE\t\t52\t/* Invalid exchange */\n#define\tEBADR\t\t53\t/* Invalid request descriptor */\n#define\tEXFULL\t\t54\t/* Exchange full */\n#define\tENOANO\t\t55\t/* No anode */\n#define\tEBADRQC\t\t56\t/* Invalid request code */\n#define\tEBADSLT\t\t57\t/* Invalid slot */\n\n#define\tEDEADLOCK\tEDEADLK\n\n#define\tEBFONT\t\t59\t/* Bad font file format */\n#define\tENOSTR\t\t60\t/* Device not a stream */\n#define\tENODATA\t\t61\t/* No data available */\n#define\tETIME\t\t62\t/* Timer expired */\n#define\tENOSR\t\t63\t/* Out of streams resources */\n#define\tENONET\t\t64\t/* Machine is not on the network */\n#define\tENOPKG\t\t65\t/* Package not installed */\n#define\tEREMOTE\t\t66\t/* Object is remote */\n#define\tENOLINK\t\t67\t/* Link has been severed */\n#define\tEADV\t\t68\t/* Advertise error */\n#define\tESRMNT\t\t69\t/* Srmount error */\n#define\tECOMM\t\t70\t/* Communication error on send */\n#define\tEPROTO\t\t71\t/* Protocol error */\n#define\tEMULTIHOP\t72\t/* Multihop attempted */\n#define\tEDOTDOT\t\t73\t/* RFS specific error */\n#define\tEBADMSG\t\t74\t/* Not a data message */\n#define\tEOVERFLOW\t75\t/* Value too large for defined data type */\n#define\tENOTUNIQ\t76\t/* Name not unique on network */\n#define\tEBADFD\t\t77\t/* File descriptor in bad state */\n#define\tEREMCHG\t\t78\t/* Remote address changed */\n#define\tELIBACC\t\t79\t/* Can not access a needed shared library */\n#define\tELIBBAD\t\t80\t/* Accessing a corrupted shared library */\n#define\tELIBSCN\t\t81\t/* .lib section in a.out corrupted */\n#define\tELIBMAX\t\t82\t/* Attempting to link in too many shared libraries */\n#define\tELIBEXEC\t83\t/* Cannot exec a shared library directly */\n#define\tEILSEQ\t\t84\t/* Illegal byte sequence */\n#define\tERESTART\t85\t/* Interrupted system call should be restarted */\n#define\tESTRPIPE\t86\t/* Streams pipe error */\n#define\tEUSERS\t\t87\t/* Too many users */\n#define\tENOTSOCK\t88\t/* Socket operation on non-socket */\n#define\tEDESTADDRREQ\t89\t/* Destination address required */\n#define\tEMSGSIZE\t90\t/* Message too long */\n#define\tEPROTOTYPE\t91\t/* Protocol wrong type for socket */\n#define\tENOPROTOOPT\t92\t/* Protocol not available */\n#define\tEPROTONOSUPPORT\t93\t/* Protocol not supported */\n#define\tESOCKTNOSUPPORT\t94\t/* Socket type not supported */\n#define\tEOPNOTSUPP\t95\t/* Operation not supported on transport endpoint */\n#define\tEPFNOSUPPORT\t96\t/* Protocol family not supported */\n#define\tEAFNOSUPPORT\t97\t/* Address family not supported by protocol */\n#define\tEADDRINUSE\t98\t/* Address already in use */\n#define\tEADDRNOTAVAIL\t99\t/* Cannot assign requested address */\n#define\tENETDOWN\t100\t/* Network is down */\n#define\tENETUNREACH\t101\t/* Network is unreachable */\n#define\tENETRESET\t102\t/* Network dropped connection because of reset */\n#define\tECONNABORTED\t103\t/* Software caused connection abort */\n#define\tECONNRESET\t104\t/* Connection reset by peer */\n#define\tENOBUFS\t\t105\t/* No buffer space available */\n#define\tEISCONN\t\t106\t/* Transport endpoint is already connected */\n#define\tENOTCONN\t107\t/* Transport endpoint is not connected */\n#define\tESHUTDOWN\t108\t/* Cannot send after transport endpoint shutdown */\n#define\tETOOMANYREFS\t109\t/* Too many references: cannot splice */\n#define\tETIMEDOUT\t110\t/* Connection timed out */\n#define\tECONNREFUSED\t111\t/* Connection refused */\n#define\tEHOSTDOWN\t112\t/* Host is down */\n#define\tEHOSTUNREACH\t113\t/* No route to host */\n#define\tEALREADY\t114\t/* Operation already in progress */\n#define\tEINPROGRESS\t115\t/* Operation now in progress */\n#define\tESTALE\t\t116\t/* Stale file handle */\n#define\tEUCLEAN\t\t117\t/* Structure needs cleaning */\n#define\tENOTNAM\t\t118\t/* Not a XENIX named type file */\n#define\tENAVAIL\t\t119\t/* No XENIX semaphores available */\n#define\tEISNAM\t\t120\t/* Is a named type file */\n#define\tEREMOTEIO\t121\t/* Remote I/O error */\n#define\tEDQUOT\t\t122\t/* Quota exceeded */\n\n#define\tENOMEDIUM\t123\t/* No medium found */\n#define\tEMEDIUMTYPE\t124\t/* Wrong medium type */\n#define\tECANCELED\t125\t/* Operation Canceled */\n#define\tENOKEY\t\t126\t/* Required key not available */\n#define\tEKEYEXPIRED\t127\t/* Key has expired */\n#define\tEKEYREVOKED\t128\t/* Key has been revoked */\n#define\tEKEYREJECTED\t129\t/* Key was rejected by service */\n\n/* for robust mutexes */\n#define\tEOWNERDEAD\t130\t/* Owner died */\n#define\tENOTRECOVERABLE\t131\t/* State not recoverable */\n\n#define ERFKILL\t\t132\t/* Operation not possible due to RF-kill */\n\n#define EHWPOISON\t133\t/* Memory page has hardware error */\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/ioctl.h",
    "content": "#ifndef _ASM_GENERIC_IOCTL_H\n#define _ASM_GENERIC_IOCTL_H\n\n/* ioctl command encoding: 32 bits total, command in lower 16 bits,\n * size of the parameter structure in the lower 14 bits of the\n * upper 16 bits.\n * Encoding the size of the parameter structure in the ioctl request\n * is useful for catching programs compiled with old versions\n * and to avoid overwriting user space outside the user buffer area.\n * The highest 2 bits are reserved for indicating the ``access mode''.\n * NOTE: This limits the max parameter size to 16kB -1 !\n */\n\n/*\n * The following is for compatibility across the various Linux\n * platforms.  The generic ioctl numbering scheme doesn't really enforce\n * a type field.  De facto, however, the top 8 bits of the lower 16\n * bits are indeed used as a type field, so we might just as well make\n * this explicit here.  Please be sure to use the decoding macros\n * below from now on.\n */\n#define _IOC_NRBITS\t8\n#define _IOC_TYPEBITS\t8\n\n/*\n * Let any architecture override either of the following before\n * including this file.\n */\n\n#ifndef _IOC_SIZEBITS\n#define _IOC_SIZEBITS\t14\n#endif\n\n#ifndef _IOC_DIRBITS\n#define _IOC_DIRBITS\t2\n#endif\n\n#define _IOC_NRMASK\t((1 << _IOC_NRBITS)-1)\n#define _IOC_TYPEMASK\t((1 << _IOC_TYPEBITS)-1)\n#define _IOC_SIZEMASK\t((1 << _IOC_SIZEBITS)-1)\n#define _IOC_DIRMASK\t((1 << _IOC_DIRBITS)-1)\n\n#define _IOC_NRSHIFT\t0\n#define _IOC_TYPESHIFT\t(_IOC_NRSHIFT+_IOC_NRBITS)\n#define _IOC_SIZESHIFT\t(_IOC_TYPESHIFT+_IOC_TYPEBITS)\n#define _IOC_DIRSHIFT\t(_IOC_SIZESHIFT+_IOC_SIZEBITS)\n\n/*\n * Direction bits, which any architecture can choose to override\n * before including this file.\n */\n\n#ifndef _IOC_NONE\n#define _IOC_NONE\t0U\n#endif\n\n#ifndef _IOC_WRITE\n#define _IOC_WRITE\t1U\n#endif\n\n#ifndef _IOC_READ\n#define _IOC_READ\t2U\n#endif\n\n#define _IOC(dir,type,nr,size) \\\n\t(((dir)  << _IOC_DIRSHIFT) | \\\n\t ((type) << _IOC_TYPESHIFT) | \\\n\t ((nr)   << _IOC_NRSHIFT) | \\\n\t ((size) << _IOC_SIZESHIFT))\n\n#define _IOC_TYPECHECK(t) (sizeof(t))\n\n/* used to create numbers */\n#define _IO(type,nr)\t\t_IOC(_IOC_NONE,(type),(nr),0)\n#define _IOR(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOW(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOWR(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))\n#define _IOR_BAD(type,nr,size)\t_IOC(_IOC_READ,(type),(nr),sizeof(size))\n#define _IOW_BAD(type,nr,size)\t_IOC(_IOC_WRITE,(type),(nr),sizeof(size))\n#define _IOWR_BAD(type,nr,size)\t_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))\n\n/* used to decode ioctl numbers.. */\n#define _IOC_DIR(nr)\t\t(((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)\n#define _IOC_TYPE(nr)\t\t(((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)\n#define _IOC_NR(nr)\t\t(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)\n#define _IOC_SIZE(nr)\t\t(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)\n\n/* ...and for the drivers/sound files... */\n\n#define IOC_IN\t\t(_IOC_WRITE << _IOC_DIRSHIFT)\n#define IOC_OUT\t\t(_IOC_READ << _IOC_DIRSHIFT)\n#define IOC_INOUT\t((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)\n#define IOCSIZE_MASK\t(_IOC_SIZEMASK << _IOC_SIZESHIFT)\n#define IOCSIZE_SHIFT\t(_IOC_SIZESHIFT)\n\n#endif\t\t\t\t/* _ASM_GENERIC_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/ioctls.h",
    "content": "#ifndef __ASM_GENERIC_IOCTLS_H\n#define __ASM_GENERIC_IOCTLS_H\n\n#include <linux/ioctl.h>\n\n/*\n * These are the most common definitions for tty ioctl numbers.\n * Most of them do not use the recommended _IOC(), but there is\n * probably some source code out there hardcoding the number,\n * so we might as well use them for all new platforms.\n *\n * The architectures that use different values here typically\n * try to be compatible with some Unix variants for the same\n * architecture.\n */\n\n/* 0x54 is just a magic number to make these relatively unique ('T') */\n\n#define TCGETS\t\t0x5401\n#define TCSETS\t\t0x5402\n#define TCSETSW\t\t0x5403\n#define TCSETSF\t\t0x5404\n#define TCGETA\t\t0x5405\n#define TCSETA\t\t0x5406\n#define TCSETAW\t\t0x5407\n#define TCSETAF\t\t0x5408\n#define TCSBRK\t\t0x5409\n#define TCXONC\t\t0x540A\n#define TCFLSH\t\t0x540B\n#define TIOCEXCL\t0x540C\n#define TIOCNXCL\t0x540D\n#define TIOCSCTTY\t0x540E\n#define TIOCGPGRP\t0x540F\n#define TIOCSPGRP\t0x5410\n#define TIOCOUTQ\t0x5411\n#define TIOCSTI\t\t0x5412\n#define TIOCGWINSZ\t0x5413\n#define TIOCSWINSZ\t0x5414\n#define TIOCMGET\t0x5415\n#define TIOCMBIS\t0x5416\n#define TIOCMBIC\t0x5417\n#define TIOCMSET\t0x5418\n#define TIOCGSOFTCAR\t0x5419\n#define TIOCSSOFTCAR\t0x541A\n#define FIONREAD\t0x541B\n#define TIOCINQ\t\tFIONREAD\n#define TIOCLINUX\t0x541C\n#define TIOCCONS\t0x541D\n#define TIOCGSERIAL\t0x541E\n#define TIOCSSERIAL\t0x541F\n#define TIOCPKT\t\t0x5420\n#define FIONBIO\t\t0x5421\n#define TIOCNOTTY\t0x5422\n#define TIOCSETD\t0x5423\n#define TIOCGETD\t0x5424\n#define TCSBRKP\t\t0x5425\t/* Needed for POSIX tcsendbreak() */\n#define TIOCSBRK\t0x5427\t/* BSD compatibility */\n#define TIOCCBRK\t0x5428\t/* BSD compatibility */\n#define TIOCGSID\t0x5429\t/* Return the session ID of FD */\n#define TCGETS2\t\t_IOR('T', 0x2A, struct termios2)\n#define TCSETS2\t\t_IOW('T', 0x2B, struct termios2)\n#define TCSETSW2\t_IOW('T', 0x2C, struct termios2)\n#define TCSETSF2\t_IOW('T', 0x2D, struct termios2)\n#define TIOCGRS485\t0x542E\n#ifndef TIOCSRS485\n#define TIOCSRS485\t0x542F\n#endif\n#define TIOCGPTN\t_IOR('T', 0x30, unsigned int)\t/* Get Pty Number (of pty-mux device) */\n#define TIOCSPTLCK\t_IOW('T', 0x31, int)\t/* Lock/unlock Pty */\n#define TIOCGDEV\t_IOR('T', 0x32, unsigned int)\t/* Get primary device node of /dev/console */\n#define TCGETX\t\t0x5432\t/* SYS5 TCGETX compatibility */\n#define TCSETX\t\t0x5433\n#define TCSETXF\t\t0x5434\n#define TCSETXW\t\t0x5435\n#define TIOCSIG\t\t_IOW('T', 0x36, int)\t/* pty: generate signal */\n#define TIOCVHANGUP\t0x5437\n#define TIOCGPKT\t_IOR('T', 0x38, int)\t/* Get packet mode state */\n#define TIOCGPTLCK\t_IOR('T', 0x39, int)\t/* Get Pty lock state */\n#define TIOCGEXCL\t_IOR('T', 0x40, int)\t/* Get exclusive mode state */\n\n#define FIONCLEX\t0x5450\n#define FIOCLEX\t\t0x5451\n#define FIOASYNC\t0x5452\n#define TIOCSERCONFIG\t0x5453\n#define TIOCSERGWILD\t0x5454\n#define TIOCSERSWILD\t0x5455\n#define TIOCGLCKTRMIOS\t0x5456\n#define TIOCSLCKTRMIOS\t0x5457\n#define TIOCSERGSTRUCT\t0x5458\t/* For debugging only */\n#define TIOCSERGETLSR   0x5459\t/* Get line status register */\n#define TIOCSERGETMULTI 0x545A\t/* Get multiport config  */\n#define TIOCSERSETMULTI 0x545B\t/* Set multiport config */\n\n#define TIOCMIWAIT\t0x545C\t/* wait for a change on serial input line(s) */\n#define TIOCGICOUNT\t0x545D\t/* read serial port __inline__ interrupt counts */\n\n/*\n * Some arches already define FIOQSIZE due to a historical\n * conflict with a Hayes modem-specific ioctl value.\n */\n#ifndef FIOQSIZE\n#define FIOQSIZE\t0x5460\n#endif\n\n/* Used for packet mode */\n#define TIOCPKT_DATA\t\t 0\n#define TIOCPKT_FLUSHREAD\t 1\n#define TIOCPKT_FLUSHWRITE\t 2\n#define TIOCPKT_STOP\t\t 4\n#define TIOCPKT_START\t\t 8\n#define TIOCPKT_NOSTOP\t\t16\n#define TIOCPKT_DOSTOP\t\t32\n#define TIOCPKT_IOCTL\t\t64\n\n#define TIOCSER_TEMT\t0x01\t/* Transmitter physically empty */\n\n#endif\t\t\t\t/* __ASM_GENERIC_IOCTLS_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/param.h",
    "content": "#ifndef __ASM_GENERIC_PARAM_H\n#define __ASM_GENERIC_PARAM_H\n\n#ifndef HZ\n#define HZ 100\n#endif\n\n#ifndef EXEC_PAGESIZE\n#define EXEC_PAGESIZE\t4096\n#endif\n\n#ifndef NOGROUP\n#define NOGROUP\t\t(-1)\n#endif\n\n#define MAXHOSTNAMELEN\t64\t/* max length of hostname */\n\n#endif\t\t\t\t/* __ASM_GENERIC_PARAM_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/socket.h",
    "content": "#ifndef __ASM_GENERIC_SOCKET_H\n#define __ASM_GENERIC_SOCKET_H\n\n#include <asm/sockios.h>\n\n/* For setsockopt(2) */\n#define SOL_SOCKET\t1\n\n#define SO_DEBUG\t1\n#define SO_REUSEADDR\t2\n#define SO_TYPE\t\t3\n#define SO_ERROR\t4\n#define SO_DONTROUTE\t5\n#define SO_BROADCAST\t6\n#define SO_SNDBUF\t7\n#define SO_RCVBUF\t8\n#define SO_SNDBUFFORCE\t32\n#define SO_RCVBUFFORCE\t33\n#define SO_KEEPALIVE\t9\n#define SO_OOBINLINE\t10\n#define SO_NO_CHECK\t11\n#define SO_PRIORITY\t12\n#define SO_LINGER\t13\n#define SO_BSDCOMPAT\t14\n#define SO_REUSEPORT\t15\n#ifndef SO_PASSCRED\t\t/* powerpc only differs in these */\n#define SO_PASSCRED\t16\n#define SO_PEERCRED\t17\n#define SO_RCVLOWAT\t18\n#define SO_SNDLOWAT\t19\n#define SO_RCVTIMEO\t20\n#define SO_SNDTIMEO\t21\n#endif\n\n/* Security levels - as per NRL IPv6 - don't actually do anything */\n#define SO_SECURITY_AUTHENTICATION\t\t22\n#define SO_SECURITY_ENCRYPTION_TRANSPORT\t23\n#define SO_SECURITY_ENCRYPTION_NETWORK\t\t24\n\n#define SO_BINDTODEVICE\t25\n\n/* Socket filtering */\n#define SO_ATTACH_FILTER\t26\n#define SO_DETACH_FILTER\t27\n#define SO_GET_FILTER\t\tSO_ATTACH_FILTER\n\n#define SO_PEERNAME\t\t28\n#define SO_TIMESTAMP\t\t29\n#define SCM_TIMESTAMP\t\tSO_TIMESTAMP\n\n#define SO_ACCEPTCONN\t\t30\n\n#define SO_PEERSEC\t\t31\n#define SO_PASSSEC\t\t34\n#define SO_TIMESTAMPNS\t\t35\n#define SCM_TIMESTAMPNS\t\tSO_TIMESTAMPNS\n\n#define SO_MARK\t\t\t36\n\n#define SO_TIMESTAMPING\t\t37\n#define SCM_TIMESTAMPING\tSO_TIMESTAMPING\n\n#define SO_PROTOCOL\t\t38\n#define SO_DOMAIN\t\t39\n\n#define SO_RXQ_OVFL             40\n\n#define SO_WIFI_STATUS\t\t41\n#define SCM_WIFI_STATUS\tSO_WIFI_STATUS\n#define SO_PEEK_OFF\t\t42\n\n/* Instruct lower device to use last 4-bytes of skb data as FCS */\n#define SO_NOFCS\t\t43\n\n#define SO_LOCK_FILTER\t\t44\n\n#define SO_SELECT_ERR_QUEUE\t45\n\n#define SO_BUSY_POLL\t\t46\n\n#define SO_MAX_PACING_RATE\t47\n\n#define SO_BPF_EXTENSIONS\t48\n\n#define SO_INCOMING_CPU\t\t49\n\n#define SO_ATTACH_BPF\t\t50\n#define SO_DETACH_BPF\t\tSO_DETACH_FILTER\n\n#define SO_ATTACH_REUSEPORT_CBPF\t51\n#define SO_ATTACH_REUSEPORT_EBPF\t52\n\n#define SO_CNX_ADVICE\t\t53\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKET_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/asm-generic/sockios.h",
    "content": "#ifndef __ASM_GENERIC_SOCKIOS_H\n#define __ASM_GENERIC_SOCKIOS_H\n\n/* Socket-level I/O control calls. */\n#define FIOSETOWN\t0x8901\n#define SIOCSPGRP\t0x8902\n#define FIOGETOWN\t0x8903\n#define SIOCGPGRP\t0x8904\n#define SIOCATMARK\t0x8905\n#define SIOCGSTAMP\t0x8906\t/* Get stamp (timeval) */\n#define SIOCGSTAMPNS\t0x8907\t/* Get stamp (timespec) */\n\n#endif\t\t\t\t/* __ASM_GENERIC_SOCKIOS_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/assert.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.2 Diagnostics\t<assert.h>\n */\n\n#ifdef\t_ASSERT_H\n\n#undef\t_ASSERT_H\n#undef\tassert\n#undef __ASSERT_VOID_CAST\n\n#ifdef\t__USE_GNU\n#undef assert_perror\n#endif\n\n#endif\t\t\t\t/* assert.h      */\n\n#define\t_ASSERT_H\t1\n#include <features.h>\n\n#if defined __cplusplus && __GNUC_PREREQ (2,95)\n#define __ASSERT_VOID_CAST static_cast<void>\n#else\n#define __ASSERT_VOID_CAST (void)\n#endif\n\n/* void assert (int expression);\n\n   If NDEBUG is defined, do nothing.\n   If not, and EXPRESSION is zero, print an error message and abort.  */\n\n#ifdef\tNDEBUG\n\n#define assert(expr)\t\t(__ASSERT_VOID_CAST (0))\n\n/* void assert_perror (int errnum);\n\n   If NDEBUG is defined, do nothing.  If not, and ERRNUM is not zero, print an\n   error message with the error text for ERRNUM and abort.\n   (This is a GNU extension.) */\n\n#ifdef\t__USE_GNU\n#define assert_perror(errnum)\t(__ASSERT_VOID_CAST (0))\n#endif\n\n#else\t\t\t\t/* Not NDEBUG.  */\n\n#ifndef _ASSERT_H_DECLS\n#define _ASSERT_H_DECLS\n__BEGIN_DECLS\n/* This prints an \"Assertion failed\" message and aborts.  */\nextern void __assert_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* Likewise, but prints the error text for ERRNUM.  */\nextern void __assert_perror_fail(int __errnum, const char *__file, unsigned int __line, const char *__function)\n__THROW __attribute__ ((__noreturn__));\n\n/* The following is not at all used here but needed for standard\n   compliance.  */\nextern void __assert(const char *__assertion, const char *__file, int __line)\n__THROW __attribute__ ((__noreturn__));\n\n__END_DECLS\n#endif\t\t\t\t/* Not _ASSERT_H_DECLS */\n#define assert(expr)\t\t\t\t\t\t\t\\\n  ((expr)\t\t\t\t\t\t\t\t\\\n   ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n   : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))\n#ifdef\t__USE_GNU\n#define assert_perror(errnum)\t\t\t\t\t\t\\\n  (!(errnum)\t\t\t\t\t\t\t\t\\\n   ? __ASSERT_VOID_CAST (0)\t\t\t\t\t\t\\\n   : __assert_perror_fail ((errnum), __FILE__, __LINE__, __ASSERT_FUNCTION))\n#endif\n/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'\n   which contains the name of the function currently being defined.\n   This is broken in G++ before version 2.6.\n   C9x has a similar variable called __func__, but prefer the GCC one since\n   it demangles C++ function names.  */\n#if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)\n#define __ASSERT_FUNCTION\t__PRETTY_FUNCTION__\n#else\n#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L\n#define __ASSERT_FUNCTION\t__func__\n#else\n#define __ASSERT_FUNCTION\t((const char *) 0)\n#endif\n#endif\n#endif\t\t\t\t/* NDEBUG.  */\n#if defined __USE_ISOC11 && !defined __cplusplus\n#undef static_assert\n#define static_assert _Static_assert\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/ctype.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard 7.4: Character handling\t<ctype.h>\n */\n\n#ifndef\t_CTYPE_H\n#define\t_CTYPE_H\t1\n\n#include <features.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n#ifndef _ISbit\n/* These are all the characteristics of characters.\n   If there get to be more than 16 distinct characteristics,\n   many things must be changed that use `unsigned short int's.\n\n   The characteristics are stored always in network byte order (big\n   endian).  We define the bit value interpretations here dependent on the\n   machine's byte order.  */\n#include <endian.h>\n#if __BYTE_ORDER == __BIG_ENDIAN\n#define _ISbit(bit)\t(1 << (bit))\n#else\t\t\t\t/* __BYTE_ORDER == __LITTLE_ENDIAN */\n#define _ISbit(bit)\t((bit) < 8 ? ((1 << (bit)) << 8) : ((1 << (bit)) >> 8))\n#endif\n    enum {\n\t_ISupper = _ISbit(0),\t/* UPPERCASE.  */\n\t_ISlower = _ISbit(1),\t/* lowercase.  */\n\t_ISalpha = _ISbit(2),\t/* Alphabetic.  */\n\t_ISdigit = _ISbit(3),\t/* Numeric.  */\n\t_ISxdigit = _ISbit(4),\t/* Hexadecimal numeric.  */\n\t_ISspace = _ISbit(5),\t/* Whitespace.  */\n\t_ISprint = _ISbit(6),\t/* Printing.  */\n\t_ISgraph = _ISbit(7),\t/* Graphical.  */\n\t_ISblank = _ISbit(8),\t/* Blank (usually SPC and TAB).  */\n\t_IScntrl = _ISbit(9),\t/* Control character.  */\n\t_ISpunct = _ISbit(10),\t/* Punctuation.  */\n\t_ISalnum = _ISbit(11)\t/* Alphanumeric.  */\n};\n#endif\t\t\t\t/* ! _ISbit  */\n\n/* These are defined in ctype-info.c.\n   The declarations here must match those in localeinfo.h.\n\n   In the thread-specific locale model (see `uselocale' in <locale.h>)\n   we cannot use global variables for these as was done in the past.\n   Instead, the following accessor functions return the address of\n   each variable, which is local to the current thread if multithreaded.\n\n   These point into arrays of 384, so they can be indexed by any `unsigned\n   char' value [0,255]; by EOF (-1); or by any `signed char' value\n   [-128,-1).  ISO C requires that the ctype functions work for `unsigned\n   char' values and for EOF; we also support negative `signed char' values\n   for broken old programs.  The case conversion arrays are of `int's\n   rather than `unsigned char's because tolower (EOF) must be EOF, which\n   doesn't fit into an `unsigned char'.  But today more important is that\n   the arrays are also used for multi-byte character sets.  */\nextern const unsigned short int **__ctype_b_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_tolower_loc(void)\n__THROW __attribute__ ((__const__));\nextern const __int32_t **__ctype_toupper_loc(void)\n__THROW __attribute__ ((__const__));\n\n#ifndef __cplusplus\n#define __isctype(c, type) \\\n  ((*__ctype_b_loc ())[(int) (c)] & (unsigned short int) type)\n#elif defined __USE_EXTERN_INLINES\n#define __isctype_f(type) \\\n  __extern_inline int\t\t\t\t\t\t\t      \\\n  is##type (int __c) __THROW\t\t\t\t\t\t      \\\n  {\t\t\t\t\t\t\t\t\t      \\\n    return (*__ctype_b_loc ())[(int) (__c)] & (unsigned short int) _IS##type; \\\n  }\n#endif\n\n#define\t__isascii(c)\t(((c) & ~0x7f) == 0)\t/* If C is a 7 bit value.  */\n#define\t__toascii(c)\t((c) & 0x7f)\t/* Mask off high bits.  */\n\n#define\t__exctype(name)\textern int name (int) __THROW\n\n__BEGIN_NAMESPACE_STD\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype(isalnum);\n__exctype(isalpha);\n__exctype(iscntrl);\n__exctype(isdigit);\n__exctype(islower);\n__exctype(isgraph);\n__exctype(isprint);\n__exctype(ispunct);\n__exctype(isspace);\n__exctype(isupper);\n__exctype(isxdigit);\n\n/* Return the lowercase version of C.  */\nextern int tolower(int __c) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int toupper(int __c) __THROW;\n\n__END_NAMESPACE_STD\n/* ISO C99 introduced one new function.  */\n#ifdef\t__USE_ISOC99\n    __BEGIN_NAMESPACE_C99 __exctype(isblank);\n\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Test C for a set of character classes according to MASK.  */\nextern int isctype(int __c, int __mask) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n\n/* Return nonzero iff C is in the ASCII set\n   (i.e., is no more than 7 bits wide).  */\nextern int isascii(int __c) __THROW;\n\n/* Return the part of C that is in the ASCII set\n   (i.e., the low-order 7 bits of C).  */\nextern int toascii(int __c) __THROW;\n\n/* These are the same as `toupper' and `tolower' except that they do not\n   check the argument for being in the range of a `char'.  */\n__exctype(_toupper);\n__exctype(_tolower);\n#endif\t\t\t\t/* Use X/Open or use misc.  */\n\n/* This code is needed for the optimized mapping functions.  */\n#define __tobody(c, f, a, args) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ int __res;\t\t\t\t\t\t\t      \\\n      if (sizeof (c) > 1)\t\t\t\t\t\t      \\\n\t{\t\t\t\t\t\t\t\t      \\\n\t  if (__builtin_constant_p (c))\t\t\t\t\t      \\\n\t    {\t\t\t\t\t\t\t\t      \\\n\t      int __c = (c);\t\t\t\t\t\t      \\\n\t      __res = __c < -128 || __c > 255 ? __c : (a)[__c];\t\t      \\\n\t    }\t\t\t\t\t\t\t\t      \\\n\t  else\t\t\t\t\t\t\t\t      \\\n\t    __res = f args;\t\t\t\t\t\t      \\\n\t}\t\t\t\t\t\t\t\t      \\\n      else\t\t\t\t\t\t\t\t      \\\n\t__res = (a)[(int) (c)];\t\t\t\t\t\t      \\\n      __res; }))\n\n#if !defined __NO_CTYPE\n#ifdef __isctype_f\n__isctype_f(alnum)\n    __isctype_f(alpha)\n    __isctype_f(cntrl)\n    __isctype_f(digit)\n    __isctype_f(lower)\n    __isctype_f(graph)\n    __isctype_f(print)\n    __isctype_f(punct)\n    __isctype_f(space)\n    __isctype_f(upper)\n    __isctype_f(xdigit)\n#ifdef __USE_ISOC99\n    __isctype_f(blank)\n#endif\n#elif defined __isctype\n#define isalnum(c)\t__isctype((c), _ISalnum)\n#define isalpha(c)\t__isctype((c), _ISalpha)\n#define iscntrl(c)\t__isctype((c), _IScntrl)\n#define isdigit(c)\t__isctype((c), _ISdigit)\n#define islower(c)\t__isctype((c), _ISlower)\n#define isgraph(c)\t__isctype((c), _ISgraph)\n#define isprint(c)\t__isctype((c), _ISprint)\n#define ispunct(c)\t__isctype((c), _ISpunct)\n#define isspace(c)\t__isctype((c), _ISspace)\n#define isupper(c)\t__isctype((c), _ISupper)\n#define isxdigit(c)\t__isctype((c), _ISxdigit)\n#ifdef __USE_ISOC99\n#define isblank(c)\t__isctype((c), _ISblank)\n#endif\n#endif\n\n#ifdef __USE_EXTERN_INLINES\n__extern_inline int __NTH(tolower(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_tolower_loc())[__c] : __c;\n}\n\n__extern_inline int __NTH(toupper(int __c))\n{\n\treturn __c >= -128 && __c < 256 ? (*__ctype_toupper_loc())[__c] : __c;\n}\n#endif\n\n#if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#define tolower(c)\t__tobody (c, tolower, *__ctype_tolower_loc (), (c))\n#define toupper(c)\t__tobody (c, toupper, *__ctype_toupper_loc (), (c))\n#endif\t\t\t\t/* Optimizing gcc */\n\n#if defined __USE_MISC || defined __USE_XOPEN\n#define isascii(c)\t__isascii (c)\n#define toascii(c)\t__toascii (c)\n\n#define _tolower(c)\t((int) (*__ctype_tolower_loc ())[(int) (c)])\n#define _toupper(c)\t((int) (*__ctype_toupper_loc ())[(int) (c)])\n#endif\n\n#endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#ifdef __USE_XOPEN2K8\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n#include <xlocale.h>\n\n/* These definitions are similar to the ones above but all functions\n   take as an argument a handle for the locale which shall be used.  */\n#define __isctype_l(c, type, locale) \\\n  ((locale)->__ctype_b[(int) (c)] & (unsigned short int) type)\n\n#define __exctype_l(name) \t\t\t\t\t\t      \\\n  extern int name (int, __locale_t) __THROW\n\n/* The following names are all functions:\n     int isCHARACTERISTIC(int c, locale_t *locale);\n   which return nonzero iff C has CHARACTERISTIC.\n   For the meaning of the characteristic names, see the `enum' above.  */\n__exctype_l(isalnum_l);\n__exctype_l(isalpha_l);\n__exctype_l(iscntrl_l);\n__exctype_l(isdigit_l);\n__exctype_l(islower_l);\n__exctype_l(isgraph_l);\n__exctype_l(isprint_l);\n__exctype_l(ispunct_l);\n__exctype_l(isspace_l);\n__exctype_l(isupper_l);\n__exctype_l(isxdigit_l);\n\n__exctype_l(isblank_l);\n\n/* Return the lowercase version of C in locale L.  */\nextern int __tolower_l(int __c, __locale_t __l) __THROW;\nextern int tolower_l(int __c, __locale_t __l) __THROW;\n\n/* Return the uppercase version of C.  */\nextern int __toupper_l(int __c, __locale_t __l) __THROW;\nextern int toupper_l(int __c, __locale_t __l) __THROW;\n\n#if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus\n#define __tolower_l(c, locale) \\\n  __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale))\n#define __toupper_l(c, locale) \\\n  __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale))\n#define tolower_l(c, locale)\t__tolower_l ((c), (locale))\n#define toupper_l(c, locale)\t__toupper_l ((c), (locale))\n#endif\t\t\t\t/* Optimizing gcc */\n\n#ifndef __NO_CTYPE\n#define __isalnum_l(c,l)\t__isctype_l((c), _ISalnum, (l))\n#define __isalpha_l(c,l)\t__isctype_l((c), _ISalpha, (l))\n#define __iscntrl_l(c,l)\t__isctype_l((c), _IScntrl, (l))\n#define __isdigit_l(c,l)\t__isctype_l((c), _ISdigit, (l))\n#define __islower_l(c,l)\t__isctype_l((c), _ISlower, (l))\n#define __isgraph_l(c,l)\t__isctype_l((c), _ISgraph, (l))\n#define __isprint_l(c,l)\t__isctype_l((c), _ISprint, (l))\n#define __ispunct_l(c,l)\t__isctype_l((c), _ISpunct, (l))\n#define __isspace_l(c,l)\t__isctype_l((c), _ISspace, (l))\n#define __isupper_l(c,l)\t__isctype_l((c), _ISupper, (l))\n#define __isxdigit_l(c,l)\t__isctype_l((c), _ISxdigit, (l))\n\n#define __isblank_l(c,l)\t__isctype_l((c), _ISblank, (l))\n\n#ifdef __USE_MISC\n#define __isascii_l(c,l)\t((l), __isascii (c))\n#define __toascii_l(c,l)\t((l), __toascii (c))\n#endif\n\n#define isalnum_l(c,l)\t__isalnum_l ((c), (l))\n#define isalpha_l(c,l)\t__isalpha_l ((c), (l))\n#define iscntrl_l(c,l)\t__iscntrl_l ((c), (l))\n#define isdigit_l(c,l)\t__isdigit_l ((c), (l))\n#define islower_l(c,l)\t__islower_l ((c), (l))\n#define isgraph_l(c,l)\t__isgraph_l ((c), (l))\n#define isprint_l(c,l)\t__isprint_l ((c), (l))\n#define ispunct_l(c,l)\t__ispunct_l ((c), (l))\n#define isspace_l(c,l)\t__isspace_l ((c), (l))\n#define isupper_l(c,l)\t__isupper_l ((c), (l))\n#define isxdigit_l(c,l)\t__isxdigit_l ((c), (l))\n\n#define isblank_l(c,l)\t__isblank_l ((c), (l))\n\n#ifdef __USE_MISC\n#define isascii_l(c,l)\t__isascii_l ((c), (l))\n#define toascii_l(c,l)\t__toascii_l ((c), (l))\n#endif\n\n#endif\t\t\t\t/* Not __NO_CTYPE.  */\n\n#endif\t\t\t\t/* Use POSIX 2008.  */\n\n__END_DECLS\n#endif\t\t\t\t/* ctype.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/dirent.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.1.2 Directory Operations\t<dirent.h>\n */\n\n#ifndef\t_DIRENT_H\n#define\t_DIRENT_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#ifdef __USE_XOPEN\n#ifndef __ino_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __ino_t ino_t;\n#else\ntypedef __ino64_t ino_t;\n#endif\n#define __ino_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined\ntypedef __ino64_t ino64_t;\n#define __ino64_t_defined\n#endif\n#endif\n\n/* This file defines `struct dirent'.\n\n   It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen'\n   member that gives the length of `d_name'.\n\n   It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen'\n   member that gives the size of the entire directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off'\n   member that gives the file offset of the next directory entry.\n\n   It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type'\n   member that gives the type of the file.\n */\n\n#include <bits/dirent.h>\n\n#if defined __USE_MISC && !defined d_fileno\n#define d_ino\td_fileno\t/* Backward compatibility.  */\n#endif\n\n/* These macros extract size information from a `struct dirent *'.\n   They may evaluate their argument multiple times, so it must not\n   have side effects.  Each of these may involve a relatively costly\n   call to `strlen' on some systems, so these values should be cached.\n\n   _D_EXACT_NAMLEN (DP)\treturns the length of DP->d_name, not including\n   its terminating null character.\n\n   _D_ALLOC_NAMLEN (DP)\treturns a size at least (_D_EXACT_NAMLEN (DP) + 1);\n   that is, the allocation size needed to hold the DP->d_name string.\n   Use this macro when you don't need the exact length, just an upper bound.\n   This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN.\n   */\n\n#ifdef _DIRENT_HAVE_D_NAMLEN\n#define _D_EXACT_NAMLEN(d) ((d)->d_namlen)\n#define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)\n#else\n#define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name))\n#ifdef _DIRENT_HAVE_D_RECLEN\n#define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])\n#else\n#define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \\\n\t\t\t      _D_EXACT_NAMLEN (d) + 1)\n#endif\n#endif\n\n#ifdef __USE_MISC\n/* File types for `d_type'.  */\nenum {\n\tDT_UNKNOWN = 0,\n#define DT_UNKNOWN\tDT_UNKNOWN\n\tDT_FIFO = 1,\n#define DT_FIFO\tDT_FIFO\n\tDT_CHR = 2,\n#define DT_CHR\t\tDT_CHR\n\tDT_DIR = 4,\n#define DT_DIR\t\tDT_DIR\n\tDT_BLK = 6,\n#define DT_BLK\t\tDT_BLK\n\tDT_REG = 8,\n#define DT_REG\t\tDT_REG\n\tDT_LNK = 10,\n#define DT_LNK\t\tDT_LNK\n\tDT_SOCK = 12,\n#define DT_SOCK\tDT_SOCK\n\tDT_WHT = 14\n#define DT_WHT\t\tDT_WHT\n};\n\n/* Convert between stat structure types and directory types.  */\n#define IFTODT(mode)\t(((mode) & 0170000) >> 12)\n#define DTTOIF(dirtype)\t((dirtype) << 12)\n#endif\n\n/* This is the data type of directory stream objects.\n   The actual structure is opaque to users.  */\ntypedef struct __dirstream DIR;\n\n/* Open a directory stream on NAME.\n   Return a DIR stream on the directory, or NULL if it could not be opened.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *opendir(const char *__name) __nonnull((1));\n\n#ifdef __USE_XOPEN2K8\n/* Same as opendir, but open the stream on the file descriptor FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern DIR *fdopendir(int __fd);\n#endif\n\n/* Close the directory stream DIRP.\n   Return 0 if successful, -1 if not.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int closedir(DIR * __dirp) __nonnull((1));\n\n/* Read a directory entry from DIRP.  Return a pointer to a `struct\n   dirent' describing the entry, or NULL for EOF or error.  The\n   storage returned may be overwritten by a later readdir call on the\n   same DIR stream.\n\n   If the Large File Support API is selected we have to use the\n   appropriate interface.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern struct dirent *readdir(DIR * __dirp) __nonnull((1));\n#else\n#ifdef __REDIRECT\nextern struct dirent *__REDIRECT(readdir, (DIR * __dirp), readdir64) __nonnull((1));\n#else\n#define readdir readdir64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern struct dirent64 *readdir64(DIR * __dirp) __nonnull((1));\n#endif\n\n#ifdef __USE_POSIX\n/* Reentrant version of `readdir'.  Return in RESULT a pointer to the\n   next entry.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int readdir_r(DIR * __restrict __dirp, struct dirent *__restrict __entry, struct dirent **__restrict __result) __nonnull((1, 2, 3)) __attribute_deprecated__;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(readdir_r, (DIR * __restrict __dirp, struct dirent * __restrict __entry, struct dirent ** __restrict __result), readdir64_r) __nonnull((1, 2, 3)) __attribute_deprecated__;\n#else\n#define readdir_r readdir64_r\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int readdir64_r(DIR * __restrict __dirp, struct dirent64 *__restrict __entry, struct dirent64 **__restrict __result) __nonnull((1, 2, 3)) __attribute_deprecated__;\n#endif\n#endif\t\t\t\t/* POSIX or misc */\n\n/* Rewind DIRP to the beginning of the directory.  */\nextern void rewinddir(DIR * __dirp)\n__THROW __nonnull((1));\n\n#if defined __USE_MISC || defined __USE_XOPEN\n#include <bits/types.h>\n\n/* Seek to position POS on DIRP.  */\nextern void seekdir(DIR * __dirp, long int __pos)\n__THROW __nonnull((1));\n\n/* Return the current position of DIRP.  */\nextern long int telldir(DIR * __dirp)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K8\n\n/* Return the file descriptor used by DIRP.  */\nextern int dirfd(DIR * __dirp)\n__THROW __nonnull((1));\n\n#if defined __OPTIMIZE__ && defined _DIR_dirfd\n#define dirfd(dirp)\t_DIR_dirfd (dirp)\n#endif\n\n#ifdef __USE_MISC\n#ifndef MAXNAMLEN\n/* Get the definitions of the POSIX.1 limits.  */\n#include <bits/posix1_lim.h>\n\n/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'.  */\n#ifdef NAME_MAX\n#define MAXNAMLEN\tNAME_MAX\n#else\n#define MAXNAMLEN\t255\n#endif\n#endif\n#endif\n\n#define __need_size_t\n#include <stddef.h>\n\n/* Scan the directory DIR, calling SELECTOR on each directory entry.\n   Entries for which SELECT returns nonzero are individually malloc'd,\n   sorted using qsort with CMP, and collected in a malloc'd array in\n   *NAMELIST.  Returns the number of entries selected, or -1 on error.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int scandir(const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((1, 2));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(scandir, (const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandir64) __nonnull((1, 2));\n#else\n#define scandir scandir64\n#endif\n#endif\n\n#if defined __USE_GNU && defined __USE_LARGEFILE64\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandir64(const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((1, 2));\n#endif\n\n#ifdef __USE_GNU\n/* Similar to `scandir' but a relative DIR name is interpreted relative\n   to the directory for which DFD is a descriptor.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int scandirat(int __dfd, const char *__restrict __dir, struct dirent ***__restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)) __nonnull((2, 3));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(scandirat, (int __dfd, const char *__restrict __dir, struct dirent *** __restrict __namelist, int (*__selector) (const struct dirent *), int (*__cmp) (const struct dirent **, const struct dirent **)), scandirat64) __nonnull((2, 3));\n#else\n#define scandirat scandirat64\n#endif\n#endif\n\n/* This function is like `scandir' but it uses the 64bit dirent structure.\n   Please note that the CMP function must now work with struct dirent64 **.  */\nextern int scandirat64(int __dfd, const char *__restrict __dir, struct dirent64 ***__restrict __namelist, int (*__selector) (const struct dirent64 *), int (*__cmp) (const struct dirent64 **, const struct dirent64 **)) __nonnull((2, 3));\n#endif\n\n/* Function to compare two `struct dirent's alphabetically.  */\n#ifndef __USE_FILE_OFFSET64\nextern int alphasort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT_NTH(alphasort, (const struct dirent ** __e1, const struct dirent ** __e2), alphasort64)\n__attribute_pure__ __nonnull((1, 2));\n#else\n#define alphasort alphasort64\n#endif\n#endif\n\n#if defined __USE_GNU && defined __USE_LARGEFILE64\nextern int alphasort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n#endif\t\t\t\t/* Use XPG7.  */\n\n#ifdef __USE_MISC\n/* Read directory entries from FD into BUF, reading at most NBYTES.\n   Reading starts at offset *BASEP, and *BASEP is updated with the new\n   position after reading.  Returns the number of bytes read; zero when at\n   end of directory; or -1 for errors.  */\n#ifndef __USE_FILE_OFFSET64\nextern __ssize_t getdirentries(int __fd, char *__restrict __buf, size_t __nbytes, __off_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n#else\n#ifdef __REDIRECT\nextern __ssize_t __REDIRECT_NTH(getdirentries, (int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep), getdirentries64) __nonnull((2, 4));\n#else\n#define getdirentries getdirentries64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern __ssize_t getdirentries64(int __fd, char *__restrict __buf, size_t __nbytes, __off64_t * __restrict __basep)\n__THROW __nonnull((2, 4));\n#endif\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_GNU\n/* Function to compare two `struct dirent's by name & version.  */\n#ifndef __USE_FILE_OFFSET64\nextern int versionsort(const struct dirent **__e1, const struct dirent **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT_NTH(versionsort, (const struct dirent ** __e1, const struct dirent ** __e2), versionsort64)\n__attribute_pure__ __nonnull((1, 2));\n#else\n#define versionsort versionsort64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\nextern int versionsort64(const struct dirent64 **__e1, const struct dirent64 **__e2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n#endif\t\t\t\t/* Use GNU.  */\n\n__END_DECLS\n#endif\t\t\t\t/* dirent.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/dlfcn.h",
    "content": "/* User functions for run-time dynamic loading.\n   Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_DLFCN_H\n#define\t_DLFCN_H 1\n\n#include <features.h>\n#define __need_size_t\n#include <stddef.h>\n\n/* Collect various system dependent definitions and declarations.  */\n#include <bits/dlfcn.h>\n\n#ifdef __USE_GNU\n/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT\n   the run-time address of the symbol called NAME in the next shared\n   object is returned.  The \"next\" relation is defined by the order\n   the shared objects were loaded.  */\n#define RTLD_NEXT\t((void *) -1l)\n\n/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT\n   the run-time address of the symbol called NAME in the global scope\n   is returned.  */\n#define RTLD_DEFAULT\t((void *) 0)\n\n/* Type for namespace indeces.  */\ntypedef long int Lmid_t;\n\n/* Special namespace ID values.  */\n#define LM_ID_BASE\t0\t/* Initial namespace.  */\n#define LM_ID_NEWLM\t-1\t/* For dlmopen: request new namespace.  */\n#endif\n\n__BEGIN_DECLS\n/* Open the shared object FILE and map it in; return a handle that can be\n   passed to `dlsym' to get symbol values from it.  */\nextern void *dlopen(const char *__file, int __mode) __THROWNL;\n\n/* Unmap and close a shared object opened by `dlopen'.\n   The handle cannot be used again after calling `dlclose'.  */\nextern int dlclose(void *__handle)\n__THROWNL __nonnull((1));\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME.  */\nextern void *dlsym(void *__restrict __handle, const char *__restrict __name)\n__THROW __nonnull((2));\n\n#ifdef __USE_GNU\n/* Like `dlopen', but request object to be allocated in a new namespace.  */\nextern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode) __THROWNL;\n\n/* Find the run-time address in the shared object HANDLE refers to\n   of the symbol called NAME with VERSION.  */\nextern void *dlvsym(void *__restrict __handle, const char *__restrict __name, const char *__restrict __version)\n__THROW __nonnull((2, 3));\n#endif\n\n/* When any of the above functions fails, call this function\n   to return a string describing the error.  Each call resets\n   the error string so that a following call returns null.  */\nextern char *dlerror(void) __THROW;\n\n#ifdef __USE_GNU\n/* Structure containing information about object searched using\n   `dladdr'.  */\ntypedef struct {\n\tconst char *dli_fname;\t/* File name of defining object.  */\n\tvoid *dli_fbase;\t/* Load address of that object.  */\n\tconst char *dli_sname;\t/* Name of nearest symbol.  */\n\tvoid *dli_saddr;\t/* Exact value of nearest symbol.  */\n} Dl_info;\n\n/* Fill in *INFO with the following information about ADDRESS.\n   Returns 0 iff no shared object's segments contain that address.  */\nextern int dladdr(const void *__address, Dl_info * __info)\n__THROW __nonnull((2));\n\n/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS.  */\nextern int dladdr1(const void *__address, Dl_info * __info, void **__extra_info, int __flags)\n__THROW __nonnull((2));\n\n/* These are the possible values for the FLAGS argument to `dladdr1'.\n   This indicates what extra information is stored at *EXTRA_INFO.\n   It may also be zero, in which case the EXTRA_INFO argument is not used.  */\nenum {\n\t/* Matching symbol table entry (const ElfNN_Sym *).  */\n\tRTLD_DL_SYMENT = 1,\n\n\t/* The object containing the address (struct link_map *).  */\n\tRTLD_DL_LINKMAP = 2\n};\n\n/* Get information about the shared object HANDLE refers to.\n   REQUEST is from among the values below, and determines the use of ARG.\n\n   On success, returns zero.  On failure, returns -1 and records an error\n   message to be fetched with `dlerror'.  */\nextern int dlinfo(void *__restrict __handle, int __request, void *__restrict __arg)\n__THROW __nonnull((1, 3));\n\n/* These are the possible values for the REQUEST argument to `dlinfo'.  */\nenum {\n\t/* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there.  */\n\tRTLD_DI_LMID = 1,\n\n\t/* Treat ARG as `struct link_map **';\n\t   store the `struct link_map *' for HANDLE there.  */\n\tRTLD_DI_LINKMAP = 2,\n\n\tRTLD_DI_CONFIGADDR = 3,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the\n\t   directories that will be searched for dependencies of this object.\n\t   RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size'\n\t   entries to indicate the size of the buffer that must be passed to\n\t   RTLD_DI_SERINFO to fill in the full information.  */\n\tRTLD_DI_SERINFO = 4,\n\tRTLD_DI_SERINFOSIZE = 5,\n\n\t/* Treat ARG as `char *', and store there the directory name used to\n\t   expand $ORIGIN in this shared object's dependency file names.  */\n\tRTLD_DI_ORIGIN = 6,\n\n\tRTLD_DI_PROFILENAME = 7,\t/* Unsupported, defined by Solaris.  */\n\tRTLD_DI_PROFILEOUT = 8,\t/* Unsupported, defined by Solaris.  */\n\n\t/* Treat ARG as `size_t *', and store there the TLS module ID\n\t   of this object's PT_TLS segment, as used in TLS relocations;\n\t   store zero if this object does not define a PT_TLS segment.  */\n\tRTLD_DI_TLS_MODID = 9,\n\n\t/* Treat ARG as `void **', and store there a pointer to the calling\n\t   thread's TLS block corresponding to this object's PT_TLS segment.\n\t   Store a null pointer if this object does not define a PT_TLS\n\t   segment, or if the calling thread has not allocated a block for it.  */\n\tRTLD_DI_TLS_DATA = 10,\n\n\tRTLD_DI_MAX = 10\n};\n\n/* This is the type of elements in `Dl_serinfo', below.\n   The `dls_name' member points to space in the buffer passed to `dlinfo'.  */\ntypedef struct {\n\tchar *dls_name;\t\t/* Name of library search path directory.  */\n\tunsigned int dls_flags;\t/* Indicates where this directory came from. */\n} Dl_serpath;\n\n/* This is the structure that must be passed (by reference) to `dlinfo' for\n   the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests.  */\ntypedef struct {\n\tsize_t dls_size;\t/* Size in bytes of the whole buffer.  */\n\tunsigned int dls_cnt;\t/* Number of elements in `dls_serpath'.  */\n\tDl_serpath dls_serpath[1];\t/* Actually longer, dls_cnt elements.  */\n} Dl_serinfo;\n#endif\t\t\t\t/* __USE_GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* dlfcn.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/endian.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_ENDIAN_H\n#define\t_ENDIAN_H\t1\n\n#include <features.h>\n\n/* Definitions for byte order, according to significance of bytes,\n   from low addresses to high addresses.  The value is what you get by\n   putting '4' in the most significant byte, '3' in the second most\n   significant byte, '2' in the second least significant byte, and '1'\n   in the least significant byte, and then writing down one digit for\n   each byte, starting with the byte at the lowest address at the left,\n   and proceeding to the byte with the highest address at the right.  */\n\n#define\t__LITTLE_ENDIAN\t1234\n#define\t__BIG_ENDIAN\t4321\n#define\t__PDP_ENDIAN\t3412\n\n/* This file defines `__BYTE_ORDER' for the particular machine.  */\n#include <bits/endian.h>\n\n/* Some machines may need to use a different endianness for floating point\n   values.  */\n#ifndef __FLOAT_WORD_ORDER\n#define __FLOAT_WORD_ORDER __BYTE_ORDER\n#endif\n\n#ifdef\t__USE_MISC\n#define LITTLE_ENDIAN\t__LITTLE_ENDIAN\n#define BIG_ENDIAN\t__BIG_ENDIAN\n#define PDP_ENDIAN\t__PDP_ENDIAN\n#define BYTE_ORDER\t__BYTE_ORDER\n#endif\n\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define __LONG_LONG_PAIR(HI, LO) LO, HI\n#elif __BYTE_ORDER == __BIG_ENDIAN\n#define __LONG_LONG_PAIR(HI, LO) HI, LO\n#endif\n\n#if defined __USE_MISC && !defined __ASSEMBLER__\n/* Conversion interfaces.  */\n#include <bits/byteswap.h>\n\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define htobe16(x) __bswap_16 (x)\n#define htole16(x) (x)\n#define be16toh(x) __bswap_16 (x)\n#define le16toh(x) (x)\n\n#define htobe32(x) __bswap_32 (x)\n#define htole32(x) (x)\n#define be32toh(x) __bswap_32 (x)\n#define le32toh(x) (x)\n\n#define htobe64(x) __bswap_64 (x)\n#define htole64(x) (x)\n#define be64toh(x) __bswap_64 (x)\n#define le64toh(x) (x)\n\n#else\n#define htobe16(x) (x)\n#define htole16(x) __bswap_16 (x)\n#define be16toh(x) (x)\n#define le16toh(x) __bswap_16 (x)\n\n#define htobe32(x) (x)\n#define htole32(x) __bswap_32 (x)\n#define be32toh(x) (x)\n#define le32toh(x) __bswap_32 (x)\n\n#define htobe64(x) (x)\n#define htole64(x) __bswap_64 (x)\n#define be64toh(x) (x)\n#define le64toh(x) __bswap_64 (x)\n#endif\n#endif\n\n#endif\t\t\t\t/* endian.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/errno.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.5 Errors\t<errno.h>\n */\n\n#ifndef\t_ERRNO_H\n\n/* The includer defined __need_Emath if he wants only the definitions\n   of EDOM and ERANGE, and not everything else.  */\n#ifndef\t__need_Emath\n#define _ERRNO_H\t1\n#include <features.h>\n#endif\n\n__BEGIN_DECLS\n/* Get the error number constants from the system-specific file.\n   This file will test __need_Emath and _ERRNO_H.  */\n#include <bits/errno.h>\n#undef\t__need_Emath\n#ifdef\t_ERRNO_H\n/* Declare the `errno' variable, unless it's defined as a macro by\n   bits/errno.h.  This is the case in GNU, where it is a per-thread\n   variable.  This redeclaration using the macro still works, but it\n   will be a function declaration without a prototype and may trigger\n   a -Wstrict-prototypes warning.  */\n#ifndef\terrno\nextern int errno;\n#endif\n\n#ifdef __USE_GNU\n\n/* The full and simple forms of the name with which the program was\n   invoked.  These variables are set up automatically at startup based on\n   the value of ARGV[0] (this works only if you use GNU ld).  */\nextern char *program_invocation_name, *program_invocation_short_name;\n#endif\t\t\t\t/* __USE_GNU */\n#endif\t\t\t\t/* _ERRNO_H */\n\n__END_DECLS\n#endif\t\t\t\t/* _ERRNO_H */\n/* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so\n   that printing `error_t' values in the debugger shows the names.  We\n   might need this definition sometimes even if this file was included\n   before.  */\n#if defined __USE_GNU || defined __need_error_t\n#ifndef __error_t_defined\ntypedef int error_t;\n#define __error_t_defined\t1\n#endif\n#undef __need_error_t\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/execinfo.h",
    "content": "/* Copyright (C) 1998-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _EXECINFO_H\n#define _EXECINFO_H 1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Store up to SIZE return address of the current program state in\n   ARRAY and return the exact number of values stored.  */\nextern int backtrace(void **__array, int __size) __nonnull((1));\n\n/* Return names of functions from the backtrace list in ARRAY in a newly\n   malloc()ed memory block.  */\nextern char **backtrace_symbols(void *const *__array, int __size)\n__THROW __nonnull((1));\n\n/* This function is similar to backtrace_symbols() but it writes the result\n   immediately to a file.  */\nextern void backtrace_symbols_fd(void *const *__array, int __size, int __fd)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* execinfo.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/fcntl.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 6.5 File Control Operations\t<fcntl.h>\n */\n\n#ifndef\t_FCNTL_H\n#define\t_FCNTL_H\t1\n\n#include <features.h>\n\n/* This must be early so <bits/fcntl.h> can define types winningly.  */\n__BEGIN_DECLS\n/* Get __mode_t, __dev_t and __off_t  .*/\n#include <bits/types.h>\n/* Get the definitions of O_*, F_*, FD_*: all the\n   numbers and flag bits for `open', `fcntl', et al.  */\n#include <bits/fcntl.h>\n/* Detect if open needs mode as a third argument (or for openat as a fourth\n   argument).  */\n#ifdef __O_TMPFILE\n#define __OPEN_NEEDS_MODE(oflag) \\\n  (((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)\n#else\n#define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)\n#endif\n/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.\n   Earlier POSIX standards permitted any type ending in `_t' to be defined\n   by any POSIX header, so we don't conditionalize the definitions here.  */\n#ifndef __mode_t_defined\ntypedef __mode_t mode_t;\n#define __mode_t_defined\n#endif\n\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#define __off64_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n\n/* For XPG all symbols from <sys/stat.h> should also be available.  */\n#ifdef __USE_XOPEN2K8\n#define __need_timespec\n#include <time.h>\n#endif\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#include <bits/stat.h>\n\n#define S_IFMT\t\t__S_IFMT\n#define S_IFDIR\t__S_IFDIR\n#define S_IFCHR\t__S_IFCHR\n#define S_IFBLK\t__S_IFBLK\n#define S_IFREG\t__S_IFREG\n#ifdef __S_IFIFO\n#define S_IFIFO\t__S_IFIFO\n#endif\n#ifdef __S_IFLNK\n#define S_IFLNK\t__S_IFLNK\n#endif\n#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK\n#define S_IFSOCK\t__S_IFSOCK\n#endif\n\n/* Protection bits.  */\n\n#define S_ISUID\t__S_ISUID\t/* Set user ID on execution.  */\n#define S_ISGID\t__S_ISGID\t/* Set group ID on execution.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */\n#define S_ISVTX\t__S_ISVTX\n#endif\n\n#define S_IRUSR\t__S_IREAD\t/* Read by owner.  */\n#define S_IWUSR\t__S_IWRITE\t/* Write by owner.  */\n#define S_IXUSR\t__S_IEXEC\t/* Execute by owner.  */\n/* Read, write, and execute by owner.  */\n#define S_IRWXU\t(__S_IREAD|__S_IWRITE|__S_IEXEC)\n\n#define S_IRGRP\t(S_IRUSR >> 3)\t/* Read by group.  */\n#define S_IWGRP\t(S_IWUSR >> 3)\t/* Write by group.  */\n#define S_IXGRP\t(S_IXUSR >> 3)\t/* Execute by group.  */\n/* Read, write, and execute by group.  */\n#define S_IRWXG\t(S_IRWXU >> 3)\n\n#define S_IROTH\t(S_IRGRP >> 3)\t/* Read by others.  */\n#define S_IWOTH\t(S_IWGRP >> 3)\t/* Write by others.  */\n#define S_IXOTH\t(S_IXGRP >> 3)\t/* Execute by others.  */\n/* Read, write, and execute by others.  */\n#define S_IRWXO\t(S_IRWXG >> 3)\n#endif\n\n#ifdef\t__USE_MISC\n#ifndef R_OK\t\t\t/* Verbatim from <unistd.h>.  Ugh.  */\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#define R_OK\t4\t\t/* Test for read permission.  */\n#define W_OK\t2\t\t/* Test for write permission.  */\n#define X_OK\t1\t\t/* Test for execute permission.  */\n#define F_OK\t0\t\t/* Test for existence.  */\n#endif\n#endif\t\t\t\t/* Use misc.  */\n\n/* XPG wants the following symbols.   <stdio.h> has the same definitions.  */\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n#define SEEK_END\t2\t/* Seek from end of file.  */\n#endif\t\t\t\t/* XPG */\n\n/* Do the file control operation described by CMD on FD.\n   The remaining arguments are interpreted depending on CMD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fcntl(int __fd, int __cmd, ...);\n\n/* Open FILE and return a new file descriptor for it, or -1 on error.\n   OFLAG determines the type of access used.  If O_CREAT or O_TMPFILE is set\n   in OFLAG, the third argument is taken as a `mode_t', the mode of the\n   created file.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int open(const char *__file, int __oflag, ...) __nonnull((1));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(open, (const char *__file, int __oflag, ...), open64) __nonnull((1));\n#else\n#define open open64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int open64(const char *__file, int __oflag, ...) __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Similar to `open' but a relative path name is interpreted relative to\n   the directory for which FD is a descriptor.\n\n   NOTE: some other `openat' implementation support additional functionality\n   through this interface, especially using the O_XATTR flag.  This is not\n   yet supported here.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int openat(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(openat, (int __fd, const char *__file, int __oflag, ...), openat64) __nonnull((2));\n#else\n#define openat openat64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int openat64(int __fd, const char *__file, int __oflag, ...) __nonnull((2));\n#endif\n#endif\n\n/* Create and open FILE, with mode MODE.  This takes an `int' MODE\n   argument because that is what `mode_t' will be widened to.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int creat(const char *__file, mode_t __mode) __nonnull((1));\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(creat, (const char *__file, mode_t __mode), creat64) __nonnull((1));\n#else\n#define creat creat64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int creat64(const char *__file, mode_t __mode) __nonnull((1));\n#endif\n\n#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \\\n\t\t\t\t\t       && !defined __USE_POSIX))\n/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.  */\n\n#define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n#define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n#define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n#define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n#ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, off_t __len);\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64);\n#else\n#define lockf lockf64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, off64_t __len);\n#endif\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Advice the system about the expected behaviour of the application with\n   respect to the file associated with FD.  */\n#ifndef __USE_FILE_OFFSET64\nextern int posix_fadvise(int __fd, off_t __offset, off_t __len, int __advise) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(posix_fadvise, (int __fd, __off64_t __offset, __off64_t __len, int __advise), posix_fadvise64);\n#else\n#define posix_fadvise posix_fadvise64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int posix_fadvise64(int __fd, off64_t __offset, off64_t __len, int __advise) __THROW;\n#endif\n\n/* Reserve storage for the data of the file associated with FD.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int posix_fallocate(int __fd, off_t __offset, off_t __len);\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(posix_fallocate, (int __fd, __off64_t __offset, __off64_t __len), posix_fallocate64);\n#else\n#define posix_fallocate posix_fallocate64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int posix_fallocate64(int __fd, off64_t __offset, off64_t __len);\n#endif\n#endif\n\n/* Define some inlines helping to catch common problems.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \\\n    && defined __va_arg_pack_len\n#include <bits/fcntl2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* fcntl.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/features.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_FEATURES_H\n#define\t_FEATURES_H\t1\n\n/* These are defined by the user (or the compiler)\n   to specify the desired environment:\n\n   __STRICT_ANSI__\tISO Standard C.\n   _ISOC99_SOURCE\tExtensions to ISO C89 from ISO C99.\n   _ISOC11_SOURCE\tExtensions to ISO C99 from ISO C11.\n   _POSIX_SOURCE\tIEEE Std 1003.1.\n   _POSIX_C_SOURCE\tIf ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;\n\t\t\tif >=199309L, add IEEE Std 1003.1b-1993;\n\t\t\tif >=199506L, add IEEE Std 1003.1c-1995;\n\t\t\tif >=200112L, all of IEEE 1003.1-2004\n\t\t\tif >=200809L, all of IEEE 1003.1-2008\n   _XOPEN_SOURCE\tIncludes POSIX and XPG things.  Set to 500 if\n\t\t\tSingle Unix conformance is wanted, to 600 for the\n\t\t\tsixth revision, to 700 for the seventh revision.\n   _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.\n   _LARGEFILE_SOURCE\tSome more functions for correct standard I/O.\n   _LARGEFILE64_SOURCE\tAdditional functionality from LFS for large files.\n   _FILE_OFFSET_BITS=N\tSelect default filesystem interface.\n   _ATFILE_SOURCE\tAdditional *at interfaces.\n   _GNU_SOURCE\t\tAll of the above, plus GNU extensions.\n   _DEFAULT_SOURCE\tThe default set of features (taking precedence over\n\t\t\t__STRICT_ANSI__).\n   _REENTRANT\t\tSelect additionally reentrant object.\n   _THREAD_SAFE\t\tSame as _REENTRANT, often used by other systems.\n   _FORTIFY_SOURCE\tIf set to numeric value > 0 additional security\n\t\t\tmeasures are defined, according to level.\n\n   The `-ansi' switch to the GNU C compiler, and standards conformance\n   options such as `-std=c99', define __STRICT_ANSI__.  If none of\n   these are defined, or if _DEFAULT_SOURCE is defined, the default is\n   to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to\n   200809L, as well as enabling miscellaneous functions from BSD and\n   SVID.  If more than one of these are defined, they accumulate.  For\n   example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together\n   give you ISO C, 1003.1, and 1003.2, but nothing else.\n\n   These are defined by this file and are used by the\n   header files to decide what to declare or define:\n\n   __USE_ISOC11\t\tDefine ISO C11 things.\n   __USE_ISOC99\t\tDefine ISO C99 things.\n   __USE_ISOC95\t\tDefine ISO C90 AMD1 (C95) things.\n   __USE_POSIX\t\tDefine IEEE Std 1003.1 things.\n   __USE_POSIX2\t\tDefine IEEE Std 1003.2 things.\n   __USE_POSIX199309\tDefine IEEE Std 1003.1, and .1b things.\n   __USE_POSIX199506\tDefine IEEE Std 1003.1, .1b, .1c and .1i things.\n   __USE_XOPEN\t\tDefine XPG things.\n   __USE_XOPEN_EXTENDED\tDefine X/Open Unix things.\n   __USE_UNIX98\t\tDefine Single Unix V2 things.\n   __USE_XOPEN2K        Define XPG6 things.\n   __USE_XOPEN2KXSI     Define XPG6 XSI things.\n   __USE_XOPEN2K8       Define XPG7 things.\n   __USE_XOPEN2K8XSI    Define XPG7 XSI things.\n   __USE_LARGEFILE\tDefine correct standard I/O things.\n   __USE_LARGEFILE64\tDefine LFS things with separate names.\n   __USE_FILE_OFFSET64\tDefine 64bit interface as default.\n   __USE_MISC\t\tDefine things from 4.3BSD or System V Unix.\n   __USE_ATFILE\t\tDefine *at interfaces and AT_* constants for them.\n   __USE_GNU\t\tDefine GNU extensions.\n   __USE_REENTRANT\tDefine reentrant/thread-safe *_r functions.\n   __USE_FORTIFY_LEVEL\tAdditional security measures used, according to level.\n\n   The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are\n   defined by this file unconditionally.  `__GNU_LIBRARY__' is provided\n   only for compatibility.  All new code should use the other symbols\n   to test for features.\n\n   All macros listed above as possibly being defined by this file are\n   explicitly undefined if they are not explicitly defined.\n   Feature-test macros that are not defined by the user or compiler\n   but are implied by the other feature-test macros defined (or by the\n   lack of any definitions) are defined by the file.  */\n\n/* Undefine everything, so we get a clean slate.  */\n#undef\t__USE_ISOC11\n#undef\t__USE_ISOC99\n#undef\t__USE_ISOC95\n#undef\t__USE_ISOCXX11\n#undef\t__USE_POSIX\n#undef\t__USE_POSIX2\n#undef\t__USE_POSIX199309\n#undef\t__USE_POSIX199506\n#undef\t__USE_XOPEN\n#undef\t__USE_XOPEN_EXTENDED\n#undef\t__USE_UNIX98\n#undef\t__USE_XOPEN2K\n#undef\t__USE_XOPEN2KXSI\n#undef\t__USE_XOPEN2K8\n#undef\t__USE_XOPEN2K8XSI\n#undef\t__USE_LARGEFILE\n#undef\t__USE_LARGEFILE64\n#undef\t__USE_FILE_OFFSET64\n#undef\t__USE_MISC\n#undef\t__USE_ATFILE\n#undef\t__USE_GNU\n#undef\t__USE_REENTRANT\n#undef\t__USE_FORTIFY_LEVEL\n#undef\t__KERNEL_STRICT_NAMES\n\n/* Suppress kernel-name space pollution unless user expressedly asks\n   for it.  */\n#ifndef _LOOSE_KERNEL_NAMES\n#define __KERNEL_STRICT_NAMES\n#endif\n\n/* Convenience macros to test the versions of glibc and gcc.\n   Use them like this:\n   #if __GNUC_PREREQ (2,8)\n   ... code requiring gcc 2.8 or later ...\n   #endif\n   Note - they won't work for gcc1 or glibc1, since the _MINOR macros\n   were not defined then.  */\n#if defined __GNUC__ && defined __GNUC_MINOR__\n#define __GNUC_PREREQ(maj, min) \\\n\t((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))\n#else\n#define __GNUC_PREREQ(maj, min) 0\n#endif\n\n/* _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for\n   _DEFAULT_SOURCE.  If _DEFAULT_SOURCE is present we do not\n   issue a warning; the expectation is that the source is being\n   transitioned to use the new macro.  */\n#if (defined _BSD_SOURCE || defined _SVID_SOURCE) \\\n    && !defined _DEFAULT_SOURCE\n#warning \"_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE\"\n#undef  _DEFAULT_SOURCE\n#define _DEFAULT_SOURCE\t1\n#endif\n\n/* If _GNU_SOURCE was defined by the user, turn on all the other features.  */\n#ifdef _GNU_SOURCE\n#undef  _ISOC95_SOURCE\n#define _ISOC95_SOURCE\t1\n#undef  _ISOC99_SOURCE\n#define _ISOC99_SOURCE\t1\n#undef  _ISOC11_SOURCE\n#define _ISOC11_SOURCE\t1\n#undef  _POSIX_SOURCE\n#define _POSIX_SOURCE\t1\n#undef  _POSIX_C_SOURCE\n#define _POSIX_C_SOURCE\t200809L\n#undef  _XOPEN_SOURCE\n#define _XOPEN_SOURCE\t700\n#undef  _XOPEN_SOURCE_EXTENDED\n#define _XOPEN_SOURCE_EXTENDED\t1\n#undef\t _LARGEFILE64_SOURCE\n#define _LARGEFILE64_SOURCE\t1\n#undef  _DEFAULT_SOURCE\n#define _DEFAULT_SOURCE\t1\n#undef  _ATFILE_SOURCE\n#define _ATFILE_SOURCE\t1\n#endif\n\n/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,\n   define _DEFAULT_SOURCE.  */\n#if (defined _DEFAULT_SOURCE\t\t\t\t\t\\\n     || (!defined __STRICT_ANSI__\t\t\t\t\\\n\t && !defined _ISOC99_SOURCE\t\t\t\t\\\n\t && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\t\\\n\t && !defined _XOPEN_SOURCE))\n#undef  _DEFAULT_SOURCE\n#define _DEFAULT_SOURCE\t1\n#endif\n\n/* This is to enable the ISO C11 extension.  */\n#if (defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L))\n#define __USE_ISOC11\t1\n#endif\n\n/* This is to enable the ISO C99 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))\n#define __USE_ISOC99\t1\n#endif\n\n/* This is to enable the ISO C90 Amendment 1:1995 extension.  */\n#if (defined _ISOC99_SOURCE || defined _ISOC11_SOURCE \\\n     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L))\n#define __USE_ISOC95\t1\n#endif\n\n/* This is to enable compatibility for ISO C++11.\n\n   So far g++ does not provide a macro.  Check the temporary macro for\n   now, too.  */\n#if ((defined __cplusplus && __cplusplus >= 201103L)\t\t\t      \\\n     || defined __GXX_EXPERIMENTAL_CXX0X__)\n#define __USE_ISOCXX11\t1\n#endif\n\n/* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE\n   is defined, use POSIX.1-2008 (or another version depending on\n   _XOPEN_SOURCE).  */\n#ifdef _DEFAULT_SOURCE\n#if !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE\n#define __USE_POSIX_IMPLICITLY\t1\n#endif\n#undef  _POSIX_SOURCE\n#define _POSIX_SOURCE\t1\n#undef  _POSIX_C_SOURCE\n#define _POSIX_C_SOURCE\t200809L\n#endif\n#if ((!defined __STRICT_ANSI__\t\t\t\t\t\\\n      || (defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 500))\t\\\n     && !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE)\n#define _POSIX_SOURCE\t1\n#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500\n#define _POSIX_C_SOURCE\t2\n#elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 600\n#define _POSIX_C_SOURCE\t199506L\n#elif defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 700\n#define _POSIX_C_SOURCE\t200112L\n#else\n#define _POSIX_C_SOURCE\t200809L\n#endif\n#define __USE_POSIX_IMPLICITLY\t1\n#endif\n\n#if (defined _POSIX_SOURCE\t\t\t\t\t\\\n     || (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1)\t\\\n     || defined _XOPEN_SOURCE)\n#define __USE_POSIX\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE\n#define __USE_POSIX2\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L\n#define __USE_POSIX199309\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L\n#define __USE_POSIX199506\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L\n#define __USE_XOPEN2K\t\t1\n#undef __USE_ISOC95\n#define __USE_ISOC95\t\t1\n#undef __USE_ISOC99\n#define __USE_ISOC99\t\t1\n#endif\n\n#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L\n#define __USE_XOPEN2K8\t\t1\n#undef  _ATFILE_SOURCE\n#define _ATFILE_SOURCE\t1\n#endif\n\n#ifdef\t_XOPEN_SOURCE\n#define __USE_XOPEN\t1\n#if (_XOPEN_SOURCE - 0) >= 500\n#define __USE_XOPEN_EXTENDED\t1\n#define __USE_UNIX98\t1\n#undef _LARGEFILE_SOURCE\n#define _LARGEFILE_SOURCE\t1\n#if (_XOPEN_SOURCE - 0) >= 600\n#if (_XOPEN_SOURCE - 0) >= 700\n#define __USE_XOPEN2K8\t1\n#define __USE_XOPEN2K8XSI\t1\n#endif\n#define __USE_XOPEN2K\t1\n#define __USE_XOPEN2KXSI\t1\n#undef __USE_ISOC95\n#define __USE_ISOC95\t\t1\n#undef __USE_ISOC99\n#define __USE_ISOC99\t\t1\n#endif\n#else\n#ifdef _XOPEN_SOURCE_EXTENDED\n#define __USE_XOPEN_EXTENDED\t1\n#endif\n#endif\n#endif\n\n#ifdef _LARGEFILE_SOURCE\n#define __USE_LARGEFILE\t1\n#endif\n\n#ifdef _LARGEFILE64_SOURCE\n#define __USE_LARGEFILE64\t1\n#endif\n\n#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64\n#define __USE_FILE_OFFSET64\t1\n#endif\n\n#if defined _DEFAULT_SOURCE\n#define __USE_MISC\t1\n#endif\n\n#ifdef\t_ATFILE_SOURCE\n#define __USE_ATFILE\t1\n#endif\n\n#ifdef\t_GNU_SOURCE\n#define __USE_GNU\t1\n#endif\n\n#if defined _REENTRANT || defined _THREAD_SAFE\n#define __USE_REENTRANT\t1\n#endif\n\n#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \\\n    && __GNUC_PREREQ (4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0\n#if _FORTIFY_SOURCE > 1\n#define __USE_FORTIFY_LEVEL 2\n#else\n#define __USE_FORTIFY_LEVEL 1\n#endif\n#else\n#define __USE_FORTIFY_LEVEL 0\n#endif\n\n/* Get definitions of __STDC_* predefined macros, if the compiler has\n   not preincluded this header automatically.  */\n#include <stdc-predef.h>\n\n/* This macro indicates that the installed library is the GNU C Library.\n   For historic reasons the value now is 6 and this will stay from now\n   on.  The use of this variable is deprecated.  Use __GLIBC__ and\n   __GLIBC_MINOR__ now (see below) when you want to test for a specific\n   GNU C library version and use the values in <gnu/lib-names.h> to get\n   the sonames of the shared libraries.  */\n#undef  __GNU_LIBRARY__\n#define __GNU_LIBRARY__ 6\n\n/* Major and minor version number of the GNU C library package.  Use\n   these macros to test for features in specific releases.  */\n#define\t__GLIBC__\t2\n#define\t__GLIBC_MINOR__\t24\n\n#define __GLIBC_PREREQ(maj, min) \\\n\t((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))\n\n/* This is here only because every header file already includes this one.  */\n#ifndef __ASSEMBLER__\n#ifndef _SYS_CDEFS_H\n#include <sys/cdefs.h>\n#endif\n\n/* If we don't have __REDIRECT, prototypes will be missing if\n   __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */\n#if defined __USE_FILE_OFFSET64 && !defined __REDIRECT\n#define __USE_LARGEFILE\t1\n#define __USE_LARGEFILE64\t1\n#endif\n\n#endif\t\t\t\t/* !ASSEMBLER */\n\n/* Decide whether we can define 'extern inline' functions in headers.  */\n#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \\\n    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \\\n    && defined __extern_inline\n#define __USE_EXTERN_INLINES\t1\n#endif\n\n/* This is here only because every header file already includes this one.\n   Get the definitions of all the appropriate `__stub_FUNCTION' symbols.\n   <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub\n   that will always return failure (and set errno to ENOSYS).  */\n#include <gnu/stubs.h>\n\n#endif\t\t\t\t/* features.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/fts.h",
    "content": "/* File tree traversal functions declarations.\n   Copyright (C) 1994-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * Copyright (c) 1989, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 4. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)fts.h\t8.3 (Berkeley) 8/14/94\n */\n\n#ifndef\t_FTS_H\n#define\t_FTS_H 1\n\n#include <features.h>\n#include <sys/types.h>\n\ntypedef struct {\n\tstruct _ftsent *fts_cur;\t/* current node */\n\tstruct _ftsent *fts_child;\t/* linked list of children */\n\tstruct _ftsent **fts_array;\t/* sort array */\n\tdev_t fts_dev;\t\t/* starting device # */\n\tchar *fts_path;\t\t/* path for this descent */\n\tint fts_rfd;\t\t/* fd for root */\n\tint fts_pathlen;\t/* sizeof(path) */\n\tint fts_nitems;\t\t/* elements in the sort array */\n\tint (*fts_compar) (const void *, const void *);\t/* compare fn */\n\n#define\tFTS_COMFOLLOW\t0x0001\t/* follow command line symlinks */\n#define\tFTS_LOGICAL\t0x0002\t/* logical walk */\n#define\tFTS_NOCHDIR\t0x0004\t/* don't change directories */\n#define\tFTS_NOSTAT\t0x0008\t/* don't get stat info */\n#define\tFTS_PHYSICAL\t0x0010\t/* physical walk */\n#define\tFTS_SEEDOT\t0x0020\t/* return dot and dot-dot */\n#define\tFTS_XDEV\t0x0040\t/* don't cross devices */\n#define FTS_WHITEOUT\t0x0080\t/* return whiteout information */\n#define\tFTS_OPTIONMASK\t0x00ff\t/* valid user option mask */\n\n#define\tFTS_NAMEONLY\t0x0100\t/* (private) child names only */\n#define\tFTS_STOP\t0x0200\t/* (private) unrecoverable error */\n\tint fts_options;\t/* fts_open options, global flags */\n} FTS;\n\n#ifdef __USE_LARGEFILE64\ntypedef struct {\n\tstruct _ftsent64 *fts_cur;\t/* current node */\n\tstruct _ftsent64 *fts_child;\t/* linked list of children */\n\tstruct _ftsent64 **fts_array;\t/* sort array */\n\tdev_t fts_dev;\t\t/* starting device # */\n\tchar *fts_path;\t\t/* path for this descent */\n\tint fts_rfd;\t\t/* fd for root */\n\tint fts_pathlen;\t/* sizeof(path) */\n\tint fts_nitems;\t\t/* elements in the sort array */\n\tint (*fts_compar) (const void *, const void *);\t/* compare fn */\n\tint fts_options;\t/* fts_open options, global flags */\n} FTS64;\n#endif\n\ntypedef struct _ftsent {\n\tstruct _ftsent *fts_cycle;\t/* cycle node */\n\tstruct _ftsent *fts_parent;\t/* parent directory */\n\tstruct _ftsent *fts_link;\t/* next file in directory */\n\tlong fts_number;\t/* local numeric value */\n\tvoid *fts_pointer;\t/* local address value */\n\tchar *fts_accpath;\t/* access path */\n\tchar *fts_path;\t\t/* root path */\n\tint fts_errno;\t\t/* errno for this node */\n\tint fts_symfd;\t\t/* fd for symlink */\n\tu_short fts_pathlen;\t/* strlen(fts_path) */\n\tu_short fts_namelen;\t/* strlen(fts_name) */\n\n\tino_t fts_ino;\t\t/* inode */\n\tdev_t fts_dev;\t\t/* device */\n\tnlink_t fts_nlink;\t/* link count */\n\n#define\tFTS_ROOTPARENTLEVEL\t-1\n#define\tFTS_ROOTLEVEL\t\t 0\n\tshort fts_level;\t/* depth (-1 to N) */\n\n#define\tFTS_D\t\t 1\t/* preorder directory */\n#define\tFTS_DC\t\t 2\t/* directory that causes cycles */\n#define\tFTS_DEFAULT\t 3\t/* none of the above */\n#define\tFTS_DNR\t\t 4\t/* unreadable directory */\n#define\tFTS_DOT\t\t 5\t/* dot or dot-dot */\n#define\tFTS_DP\t\t 6\t/* postorder directory */\n#define\tFTS_ERR\t\t 7\t/* error; errno is set */\n#define\tFTS_F\t\t 8\t/* regular file */\n#define\tFTS_INIT\t 9\t/* initialized only */\n#define\tFTS_NS\t\t10\t/* stat(2) failed */\n#define\tFTS_NSOK\t11\t/* no stat(2) requested */\n#define\tFTS_SL\t\t12\t/* symbolic link */\n#define\tFTS_SLNONE\t13\t/* symbolic link without target */\n#define FTS_W\t\t14\t/* whiteout object */\n\tu_short fts_info;\t/* user flags for FTSENT structure */\n\n#define\tFTS_DONTCHDIR\t 0x01\t/* don't chdir .. to the parent */\n#define\tFTS_SYMFOLLOW\t 0x02\t/* followed a symlink to get here */\n\tu_short fts_flags;\t/* private flags for FTSENT structure */\n\n#define\tFTS_AGAIN\t 1\t/* read node again */\n#define\tFTS_FOLLOW\t 2\t/* follow symbolic link */\n#define\tFTS_NOINSTR\t 3\t/* no instructions */\n#define\tFTS_SKIP\t 4\t/* discard node */\n\tu_short fts_instr;\t/* fts_set() instructions */\n\n\tstruct stat *fts_statp;\t/* stat(2) information */\n\tchar fts_name[1];\t/* file name */\n} FTSENT;\n\n#ifdef __USE_LARGEFILE64\ntypedef struct _ftsent64 {\n\tstruct _ftsent64 *fts_cycle;\t/* cycle node */\n\tstruct _ftsent64 *fts_parent;\t/* parent directory */\n\tstruct _ftsent64 *fts_link;\t/* next file in directory */\n\tlong fts_number;\t/* local numeric value */\n\tvoid *fts_pointer;\t/* local address value */\n\tchar *fts_accpath;\t/* access path */\n\tchar *fts_path;\t\t/* root path */\n\tint fts_errno;\t\t/* errno for this node */\n\tint fts_symfd;\t\t/* fd for symlink */\n\tu_short fts_pathlen;\t/* strlen(fts_path) */\n\tu_short fts_namelen;\t/* strlen(fts_name) */\n\n\tino64_t fts_ino;\t/* inode */\n\tdev_t fts_dev;\t\t/* device */\n\tnlink_t fts_nlink;\t/* link count */\n\n\tshort fts_level;\t/* depth (-1 to N) */\n\n\tu_short fts_info;\t/* user flags for FTSENT structure */\n\n\tu_short fts_flags;\t/* private flags for FTSENT structure */\n\n\tu_short fts_instr;\t/* fts_set() instructions */\n\n\tstruct stat64 *fts_statp;\t/* stat(2) information */\n\tchar fts_name[1];\t/* file name */\n} FTSENT64;\n#endif\n\n__BEGIN_DECLS\n#ifndef __USE_FILE_OFFSET64\n    FTSENT * fts_children(FTS *, int);\nint fts_close(FTS *);\nFTS *fts_open(char *const *, int, int (*)(const FTSENT **, const FTSENT **));\nFTSENT *fts_read(FTS *);\nint fts_set(FTS *, FTSENT *, int) __THROW;\n#else\n#ifdef __REDIRECT\n    FTSENT * __REDIRECT(fts_children, (FTS *, int), fts64_children);\nint __REDIRECT(fts_close, (FTS *), fts64_close);\nFTS *__REDIRECT(fts_open, (char *const *, int, int (*)(const FTSENT **, const FTSENT **)), fts64_open);\nFTSENT *__REDIRECT(fts_read, (FTS *), fts64_read);\nint __REDIRECT_NTH(fts_set, (FTS *, FTSENT *, int), fts64_set);\n#else\n#define fts_children fts64_children\n#define fts_close fts64_close\n#define fts_open fts64_open\n#define fts_read fts64_read\n#define fts_set fts64_set\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\n    FTSENT64 * fts64_children(FTS64 *, int);\nint fts64_close(FTS64 *);\nFTS64 *fts64_open(char *const *, int, int (*)(const FTSENT64 **, const FTSENT64 **));\nFTSENT64 *fts64_read(FTS64 *);\nint fts64_set(FTS64 *, FTSENT64 *, int) __THROW;\n#endif\n__END_DECLS\n#endif\t\t\t\t/* fts.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/getopt.h",
    "content": "/* Declarations for getopt.\n   Copyright (C) 1989-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _GETOPT_H\n\n#ifndef __need_getopt\n#define _GETOPT_H 1\n#endif\n\n/* If __GNU_LIBRARY__ is not already defined, either we are being used\n   standalone, or this is the first header included in the source file.\n   If we are being used with glibc, we need to include <features.h>, but\n   that does not exist if we are standalone.  So: if __GNU_LIBRARY__ is\n   not defined, include <ctype.h>, which will pull in <features.h> for us\n   if it's from glibc.  (Why ctype.h?  It's guaranteed to exist and it\n   doesn't flood the namespace with stuff the way some other headers do.)  */\n#if !defined __GNU_LIBRARY__\n#include <ctype.h>\n#endif\n\n#ifndef __THROW\n#ifndef __GNUC_PREREQ\n#define __GNUC_PREREQ(maj, min) (0)\n#endif\n#if defined __cplusplus && __GNUC_PREREQ (2,8)\n#define __THROW\tthrow ()\n#else\n#define __THROW\n#endif\n#endif\n\n#ifdef\t__cplusplus\nextern \"C\" {\n#endif\n\n/* For communication from `getopt' to the caller.\n   When `getopt' finds an option that takes an argument,\n   the argument value is returned here.\n   Also, when `ordering' is RETURN_IN_ORDER,\n   each non-option ARGV-element is returned here.  */\n\n\textern char *optarg;\n\n/* Index in ARGV of the next element to be scanned.\n   This is used for communication to and from the caller\n   and for communication between successive calls to `getopt'.\n\n   On entry to `getopt', zero means this is the first call; initialize.\n\n   When `getopt' returns -1, this is the index of the first of the\n   non-option elements that the caller should itself scan.\n\n   Otherwise, `optind' communicates from one call to the next\n   how much of ARGV has been scanned so far.  */\n\n\textern int optind;\n\n/* Callers store zero here to inhibit the error message `getopt' prints\n   for unrecognized options.  */\n\n\textern int opterr;\n\n/* Set to an option character which was unrecognized.  */\n\n\textern int optopt;\n\n#ifndef __need_getopt\n/* Describe the long-named options requested by the application.\n   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector\n   of `struct option' terminated by an element containing a name which is\n   zero.\n\n   The field `has_arg' is:\n   no_argument\t\t(or 0) if the option does not take an argument,\n   required_argument\t(or 1) if the option requires an argument,\n   optional_argument \t(or 2) if the option takes an optional argument.\n\n   If the field `flag' is not NULL, it points to a variable that is set\n   to the value given in the field `val' when the option is found, but\n   left unchanged if the option is not found.\n\n   To have a long-named option do something other than set an `int' to\n   a compiled-in constant, such as set a value from `optarg', set the\n   option's `flag' field to zero and its `val' field to a nonzero\n   value (the equivalent single-letter option character, if there is\n   one).  For long options that have a zero `flag' field, `getopt'\n   returns the contents of the `val' field.  */\n\n\tstruct option {\n\t\tconst char *name;\n\t\t/* has_arg can't be an enum because some compilers complain about\n\t\t   type mismatches in all the code that assumes it is an int.  */\n\t\tint has_arg;\n\t\tint *flag;\n\t\tint val;\n\t};\n\n/* Names for the values of the `has_arg' field of `struct option'.  */\n\n#define no_argument\t\t0\n#define required_argument\t1\n#define optional_argument\t2\n#endif\t\t\t\t/* need getopt */\n\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.\n\n   Return the option character from OPTS just read.  Return -1 when\n   there are no more options.  For unrecognized options, or options\n   missing arguments, `optopt' is set to the option letter, and '?' is\n   returned.\n\n   The OPTS string is a list of characters which are recognized option\n   letters, optionally followed by colons, specifying that that letter\n   takes an argument, to be placed in `optarg'.\n\n   If a letter in OPTS is followed by two colons, its argument is\n   optional.  This behavior is specific to the GNU `getopt'.\n\n   The argument `--' causes premature termination of argument\n   scanning, explicitly telling `getopt' that there are no more\n   options.\n\n   If OPTS begins with `--', then non-option arguments are treated as\n   arguments to the option '\\0'.  This behavior is specific to the GNU\n   `getopt'.  */\n\n#ifdef __GNU_LIBRARY__\n/* Many other libraries have conflicting prototypes for getopt, with\n   differences in the consts, in stdlib.h.  To avoid compilation\n   errors, only prototype getopt for the GNU C library.  */\n\textern int getopt(int ___argc, char *const *___argv, const char *__shortopts)\n\t __THROW;\n\n#if defined __need_getopt && defined __USE_POSIX2 \\\n  && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU\n/* The GNU getopt has more functionality than the standard version.  The\n   additional functionality can be disable at runtime.  This redirection\n   helps to also do this at runtime.  */\n#ifdef __REDIRECT\n\textern int __REDIRECT_NTH(getopt, (int ___argc, char *const *___argv, const char *__shortopts), __posix_getopt);\n#else\n\textern int __posix_getopt(int ___argc, char *const *___argv, const char *__shortopts) __THROW;\n#define getopt __posix_getopt\n#endif\n#endif\n#else\t\t\t\t/* not __GNU_LIBRARY__ */\n\textern int getopt();\n#endif\t\t\t\t/* __GNU_LIBRARY__ */\n\n#ifndef __need_getopt\n\textern int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n\t __THROW;\n\textern int getopt_long_only(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)\n\t __THROW;\n\n#endif\n\n#ifdef\t__cplusplus\n}\n#endif\n/* Make sure we later can get all the definitions and declarations.  */\n#undef __need_getopt\n#endif\t\t\t\t/* getopt.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/grp.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.1 Group Database Access\t<grp.h>\n */\n\n#ifndef\t_GRP_H\n#define\t_GRP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n/* For the Single Unix specification we must define this type here.  */\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined\ntypedef __gid_t gid_t;\n#define __gid_t_defined\n#endif\n\n/* The group structure.\t */\nstruct group {\n\tchar *gr_name;\t\t/* Group name.  */\n\tchar *gr_passwd;\t/* Password.    */\n\t__gid_t gr_gid;\t\t/* Group ID.    */\n\tchar **gr_mem;\t\t/* Member list. */\n};\n\n#ifdef __USE_MISC\n#define __need_FILE\n#include <stdio.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setgrent(void);\n\n/* Close the group-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endgrent(void);\n\n/* Read an entry from the group-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read a group entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct group *fgetgrent(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putgrent(const struct group *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrgid(__gid_t __gid);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct group *getgrnam(const char *__name);\n\n#ifdef __USE_POSIX\n\n#ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#define NSS_BUFLEN_GROUP\t1024\n#endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getgrent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\n\n#ifdef __USE_GNU\nextern int getgrent_r(struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n#endif\n\n/* Search for an entry with a matching group ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrgid_r(__gid_t __gid, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n/* Search for an entry with a matching group name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getgrnam_r(const char *__restrict __name, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n\n#ifdef\t__USE_MISC\n/* Read a group entry from STREAM.  This function is not standardized\n   an probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetgrent_r(FILE * __restrict __stream, struct group *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct group **__restrict __result);\n#endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef\t__USE_MISC\n\n#define __need_size_t\n#include <stddef.h>\n\n/* Set the group set for the current user to GROUPS (N of them).  */\nextern int setgroups(size_t __n, const __gid_t * __groups) __THROW;\n\n/* Store at most *NGROUPS members of the group set for USER into\n   *GROUPS.  Also include GROUP.  The actual number of groups found is\n   returned in *NGROUPS.  Return -1 if the if *NGROUPS is too small.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getgrouplist(const char *__user, __gid_t __group, __gid_t * __groups, int *__ngroups);\n\n/* Initialize the group set for the current user\n   by reading the group database and using all groups\n   of which USER is a member.  Also include GROUP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int initgroups(const char *__user, __gid_t __group);\n\n#endif\t\t\t\t/* Use misc.  */\n\n__END_DECLS\n#endif\t\t\t\t/* grp.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/inttypes.h",
    "content": "/* Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.8 Format conversion of integer types\t<inttypes.h>\n */\n\n#ifndef _INTTYPES_H\n#define _INTTYPES_H\t1\n\n#include <features.h>\n/* Get the type definitions.  */\n#include <stdint.h>\n\n/* Get a definition for wchar_t.  But we must not define wchar_t itself.  */\n#ifndef ____gwchar_t_defined\n#ifdef __cplusplus\n#define __gwchar_t wchar_t\n#elif defined __WCHAR_TYPE__\ntypedef __WCHAR_TYPE__ __gwchar_t;\n#else\n#define __need_wchar_t\n#include <stddef.h>\ntypedef wchar_t __gwchar_t;\n#endif\n#define ____gwchar_t_defined\t1\n#endif\n\n#if __WORDSIZE == 64\n#define __PRI64_PREFIX\t\"l\"\n#define __PRIPTR_PREFIX\t\"l\"\n#else\n#define __PRI64_PREFIX\t\"ll\"\n#define __PRIPTR_PREFIX\n#endif\n\n/* Macros for printing format specifiers.  */\n\n/* Decimal notation.  */\n#define PRId8\t\t\"d\"\n#define PRId16\t\t\"d\"\n#define PRId32\t\t\"d\"\n#define PRId64\t\t__PRI64_PREFIX \"d\"\n\n#define PRIdLEAST8\t\"d\"\n#define PRIdLEAST16\t\"d\"\n#define PRIdLEAST32\t\"d\"\n#define PRIdLEAST64\t__PRI64_PREFIX \"d\"\n\n#define PRIdFAST8\t\"d\"\n#define PRIdFAST16\t__PRIPTR_PREFIX \"d\"\n#define PRIdFAST32\t__PRIPTR_PREFIX \"d\"\n#define PRIdFAST64\t__PRI64_PREFIX \"d\"\n\n#define PRIi8\t\t\"i\"\n#define PRIi16\t\t\"i\"\n#define PRIi32\t\t\"i\"\n#define PRIi64\t\t__PRI64_PREFIX \"i\"\n\n#define PRIiLEAST8\t\"i\"\n#define PRIiLEAST16\t\"i\"\n#define PRIiLEAST32\t\"i\"\n#define PRIiLEAST64\t__PRI64_PREFIX \"i\"\n\n#define PRIiFAST8\t\"i\"\n#define PRIiFAST16\t__PRIPTR_PREFIX \"i\"\n#define PRIiFAST32\t__PRIPTR_PREFIX \"i\"\n#define PRIiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Octal notation.  */\n#define PRIo8\t\t\"o\"\n#define PRIo16\t\t\"o\"\n#define PRIo32\t\t\"o\"\n#define PRIo64\t\t__PRI64_PREFIX \"o\"\n\n#define PRIoLEAST8\t\"o\"\n#define PRIoLEAST16\t\"o\"\n#define PRIoLEAST32\t\"o\"\n#define PRIoLEAST64\t__PRI64_PREFIX \"o\"\n\n#define PRIoFAST8\t\"o\"\n#define PRIoFAST16\t__PRIPTR_PREFIX \"o\"\n#define PRIoFAST32\t__PRIPTR_PREFIX \"o\"\n#define PRIoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Unsigned integers.  */\n#define PRIu8\t\t\"u\"\n#define PRIu16\t\t\"u\"\n#define PRIu32\t\t\"u\"\n#define PRIu64\t\t__PRI64_PREFIX \"u\"\n\n#define PRIuLEAST8\t\"u\"\n#define PRIuLEAST16\t\"u\"\n#define PRIuLEAST32\t\"u\"\n#define PRIuLEAST64\t__PRI64_PREFIX \"u\"\n\n#define PRIuFAST8\t\"u\"\n#define PRIuFAST16\t__PRIPTR_PREFIX \"u\"\n#define PRIuFAST32\t__PRIPTR_PREFIX \"u\"\n#define PRIuFAST64\t__PRI64_PREFIX \"u\"\n\n/* lowercase hexadecimal notation.  */\n#define PRIx8\t\t\"x\"\n#define PRIx16\t\t\"x\"\n#define PRIx32\t\t\"x\"\n#define PRIx64\t\t__PRI64_PREFIX \"x\"\n\n#define PRIxLEAST8\t\"x\"\n#define PRIxLEAST16\t\"x\"\n#define PRIxLEAST32\t\"x\"\n#define PRIxLEAST64\t__PRI64_PREFIX \"x\"\n\n#define PRIxFAST8\t\"x\"\n#define PRIxFAST16\t__PRIPTR_PREFIX \"x\"\n#define PRIxFAST32\t__PRIPTR_PREFIX \"x\"\n#define PRIxFAST64\t__PRI64_PREFIX \"x\"\n\n/* UPPERCASE hexadecimal notation.  */\n#define PRIX8\t\t\"X\"\n#define PRIX16\t\t\"X\"\n#define PRIX32\t\t\"X\"\n#define PRIX64\t\t__PRI64_PREFIX \"X\"\n\n#define PRIXLEAST8\t\"X\"\n#define PRIXLEAST16\t\"X\"\n#define PRIXLEAST32\t\"X\"\n#define PRIXLEAST64\t__PRI64_PREFIX \"X\"\n\n#define PRIXFAST8\t\"X\"\n#define PRIXFAST16\t__PRIPTR_PREFIX \"X\"\n#define PRIXFAST32\t__PRIPTR_PREFIX \"X\"\n#define PRIXFAST64\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intmax_t' and `uintmax_t'.  */\n#define PRIdMAX\t__PRI64_PREFIX \"d\"\n#define PRIiMAX\t__PRI64_PREFIX \"i\"\n#define PRIoMAX\t__PRI64_PREFIX \"o\"\n#define PRIuMAX\t__PRI64_PREFIX \"u\"\n#define PRIxMAX\t__PRI64_PREFIX \"x\"\n#define PRIXMAX\t__PRI64_PREFIX \"X\"\n\n/* Macros for printing `intptr_t' and `uintptr_t'.  */\n#define PRIdPTR\t__PRIPTR_PREFIX \"d\"\n#define PRIiPTR\t__PRIPTR_PREFIX \"i\"\n#define PRIoPTR\t__PRIPTR_PREFIX \"o\"\n#define PRIuPTR\t__PRIPTR_PREFIX \"u\"\n#define PRIxPTR\t__PRIPTR_PREFIX \"x\"\n#define PRIXPTR\t__PRIPTR_PREFIX \"X\"\n\n/* Macros for scanning format specifiers.  */\n\n/* Signed decimal notation.  */\n#define SCNd8\t\t\"hhd\"\n#define SCNd16\t\t\"hd\"\n#define SCNd32\t\t\"d\"\n#define SCNd64\t\t__PRI64_PREFIX \"d\"\n\n#define SCNdLEAST8\t\"hhd\"\n#define SCNdLEAST16\t\"hd\"\n#define SCNdLEAST32\t\"d\"\n#define SCNdLEAST64\t__PRI64_PREFIX \"d\"\n\n#define SCNdFAST8\t\"hhd\"\n#define SCNdFAST16\t__PRIPTR_PREFIX \"d\"\n#define SCNdFAST32\t__PRIPTR_PREFIX \"d\"\n#define SCNdFAST64\t__PRI64_PREFIX \"d\"\n\n/* Signed decimal notation.  */\n#define SCNi8\t\t\"hhi\"\n#define SCNi16\t\t\"hi\"\n#define SCNi32\t\t\"i\"\n#define SCNi64\t\t__PRI64_PREFIX \"i\"\n\n#define SCNiLEAST8\t\"hhi\"\n#define SCNiLEAST16\t\"hi\"\n#define SCNiLEAST32\t\"i\"\n#define SCNiLEAST64\t__PRI64_PREFIX \"i\"\n\n#define SCNiFAST8\t\"hhi\"\n#define SCNiFAST16\t__PRIPTR_PREFIX \"i\"\n#define SCNiFAST32\t__PRIPTR_PREFIX \"i\"\n#define SCNiFAST64\t__PRI64_PREFIX \"i\"\n\n/* Unsigned decimal notation.  */\n#define SCNu8\t\t\"hhu\"\n#define SCNu16\t\t\"hu\"\n#define SCNu32\t\t\"u\"\n#define SCNu64\t\t__PRI64_PREFIX \"u\"\n\n#define SCNuLEAST8\t\"hhu\"\n#define SCNuLEAST16\t\"hu\"\n#define SCNuLEAST32\t\"u\"\n#define SCNuLEAST64\t__PRI64_PREFIX \"u\"\n\n#define SCNuFAST8\t\"hhu\"\n#define SCNuFAST16\t__PRIPTR_PREFIX \"u\"\n#define SCNuFAST32\t__PRIPTR_PREFIX \"u\"\n#define SCNuFAST64\t__PRI64_PREFIX \"u\"\n\n/* Octal notation.  */\n#define SCNo8\t\t\"hho\"\n#define SCNo16\t\t\"ho\"\n#define SCNo32\t\t\"o\"\n#define SCNo64\t\t__PRI64_PREFIX \"o\"\n\n#define SCNoLEAST8\t\"hho\"\n#define SCNoLEAST16\t\"ho\"\n#define SCNoLEAST32\t\"o\"\n#define SCNoLEAST64\t__PRI64_PREFIX \"o\"\n\n#define SCNoFAST8\t\"hho\"\n#define SCNoFAST16\t__PRIPTR_PREFIX \"o\"\n#define SCNoFAST32\t__PRIPTR_PREFIX \"o\"\n#define SCNoFAST64\t__PRI64_PREFIX \"o\"\n\n/* Hexadecimal notation.  */\n#define SCNx8\t\t\"hhx\"\n#define SCNx16\t\t\"hx\"\n#define SCNx32\t\t\"x\"\n#define SCNx64\t\t__PRI64_PREFIX \"x\"\n\n#define SCNxLEAST8\t\"hhx\"\n#define SCNxLEAST16\t\"hx\"\n#define SCNxLEAST32\t\"x\"\n#define SCNxLEAST64\t__PRI64_PREFIX \"x\"\n\n#define SCNxFAST8\t\"hhx\"\n#define SCNxFAST16\t__PRIPTR_PREFIX \"x\"\n#define SCNxFAST32\t__PRIPTR_PREFIX \"x\"\n#define SCNxFAST64\t__PRI64_PREFIX \"x\"\n\n/* Macros for scanning `intmax_t' and `uintmax_t'.  */\n#define SCNdMAX\t__PRI64_PREFIX \"d\"\n#define SCNiMAX\t__PRI64_PREFIX \"i\"\n#define SCNoMAX\t__PRI64_PREFIX \"o\"\n#define SCNuMAX\t__PRI64_PREFIX \"u\"\n#define SCNxMAX\t__PRI64_PREFIX \"x\"\n\n/* Macros for scaning `intptr_t' and `uintptr_t'.  */\n#define SCNdPTR\t__PRIPTR_PREFIX \"d\"\n#define SCNiPTR\t__PRIPTR_PREFIX \"i\"\n#define SCNoPTR\t__PRIPTR_PREFIX \"o\"\n#define SCNuPTR\t__PRIPTR_PREFIX \"u\"\n#define SCNxPTR\t__PRIPTR_PREFIX \"x\"\n\n__BEGIN_DECLS\n#if __WORDSIZE == 64\n/* We have to define the `uintmax_t' type using `ldiv_t'.  */\n    typedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} imaxdiv_t;\n\n#else\n/* We have to define the `uintmax_t' type using `lldiv_t'.  */\n    typedef struct {\n\t__extension__ long long int quot;\t/* Quotient.  */\n\t__extension__ long long int rem;\t/* Remainder.  */\n} imaxdiv_t;\n\n#endif\n\n/* Compute absolute value of N.  */\nextern intmax_t imaxabs(intmax_t __n)\n__THROW __attribute__ ((__const__));\n\n/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */\nextern imaxdiv_t imaxdiv(intmax_t __numer, intmax_t __denom)\n__THROW __attribute__ ((__const__));\n\n/* Like `strtol' but convert to `intmax_t'.  */\nextern intmax_t strtoimax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `strtoul' but convert to `uintmax_t'.  */\nextern uintmax_t strtoumax(const char *__restrict __nptr, char **__restrict __endptr, int __base) __THROW;\n\n/* Like `wcstol' but convert to `intmax_t'.  */\nextern intmax_t wcstoimax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Like `wcstoul' but convert to `uintmax_t'.  */\nextern uintmax_t wcstoumax(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n\n#if __WORDSIZE == 64\n\nextern long int __strtol_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __strtoul_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoul_internal(nptr, endptr, base, 0);\n}\n\nextern long int __wcstol_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstol_internal(nptr, endptr, base, 0);\n}\n\nextern unsigned long int __wcstoul_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoul_internal(nptr, endptr, base, 0);\n}\n\n#else\t\t\t\t/* __WORDSIZE == 32 */\n\n__extension__ extern long long int __strtoll_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(strtoimax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __strtoull_internal(const char *__restrict __nptr, char **__restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `strtoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(strtoumax(const char *__restrict nptr, char **__restrict endptr, int base))\n{\n\treturn __strtoull_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern long long int __wcstoll_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstol' but convert to `intmax_t'.  */\n__extern_inline intmax_t __NTH(wcstoimax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoll_internal(nptr, endptr, base, 0);\n}\n\n__extension__ extern unsigned long long int __wcstoull_internal(const __gwchar_t * __restrict __nptr, __gwchar_t ** __restrict __endptr, int __base, int __group)\n__THROW __nonnull((1)) __wur;\n/* Like `wcstoul' but convert to `uintmax_t'.  */\n__extern_inline uintmax_t __NTH(wcstoumax(const __gwchar_t * __restrict nptr, __gwchar_t ** __restrict endptr, int base))\n{\n\treturn __wcstoull_internal(nptr, endptr, base, 0);\n}\n\n#endif\t\t\t\t/* __WORDSIZE == 32     */\n#endif\t\t\t\t/* Use extern inlines.  */\n\n__END_DECLS\n#endif\t\t\t\t/* inttypes.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/libio.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Written by Per Bothner <bothner@cygnus.com>.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.\n\n   As a special exception, if you link the code in this file with\n   files compiled with a GNU compiler to produce an executable,\n   that does not cause the resulting executable to be covered by\n   the GNU Lesser General Public License.  This exception does not\n   however invalidate any other reasons why the executable file\n   might be covered by the GNU Lesser General Public License.\n   This exception applies to code released by its copyright holders\n   in files containing the exception.  */\n\n#ifndef _IO_STDIO_H\n#define _IO_STDIO_H\n\n#include <_G_config.h>\n/* ALL of these should be defined in _G_config.h */\n#define _IO_fpos_t _G_fpos_t\n#define _IO_fpos64_t _G_fpos64_t\n#define _IO_size_t size_t\n#define _IO_ssize_t __ssize_t\n#define _IO_off_t __off_t\n#define _IO_off64_t __off64_t\n#define _IO_pid_t __pid_t\n#define _IO_uid_t __uid_t\n#define _IO_iconv_t _G_iconv_t\n#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE\n#define _IO_BUFSIZ _G_BUFSIZ\n#define _IO_va_list _G_va_list\n#define _IO_wint_t wint_t\n\n/* This define avoids name pollution if we're using GNU stdarg.h */\n#define __need___va_list\n#include <stdarg.h>\n#ifdef __GNUC_VA_LIST\n#undef _IO_va_list\n#define _IO_va_list __gnuc_va_list\n#endif\t\t\t\t/* __GNUC_VA_LIST */\n\n#ifndef __P\n#include <sys/cdefs.h>\n#endif\t\t\t\t/*!__P */\n\n#define _IO_UNIFIED_JUMPTABLES 1\n\n#ifndef EOF\n#define EOF (-1)\n#endif\n#ifndef NULL\n#if defined __GNUG__ && \\\n    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))\n#define NULL (__null)\n#else\n#if !defined(__cplusplus)\n#define NULL ((void*)0)\n#else\n#define NULL (0)\n#endif\n#endif\n#endif\n\n#define _IOS_INPUT\t1\n#define _IOS_OUTPUT\t2\n#define _IOS_ATEND\t4\n#define _IOS_APPEND\t8\n#define _IOS_TRUNC\t16\n#define _IOS_NOCREATE\t32\n#define _IOS_NOREPLACE\t64\n#define _IOS_BIN\t128\n\n/* Magic numbers and bits for the _flags field.\n   The magic numbers use the high-order bits of _flags;\n   the remaining bits are available for variable flags.\n   Note: The magic numbers must all be negative if stdio\n   emulation is desired. */\n\n#define _IO_MAGIC 0xFBAD0000\t/* Magic number */\n#define _OLD_STDIO_MAGIC 0xFABC0000\t/* Emulate old stdio. */\n#define _IO_MAGIC_MASK 0xFFFF0000\n#define _IO_USER_BUF 1\t\t/* User owns buffer; don't delete it on close. */\n#define _IO_UNBUFFERED 2\n#define _IO_NO_READS 4\t\t/* Reading not allowed */\n#define _IO_NO_WRITES 8\t\t/* Writing not allowd */\n#define _IO_EOF_SEEN 0x10\n#define _IO_ERR_SEEN 0x20\n#define _IO_DELETE_DONT_CLOSE 0x40\t/* Don't call close(_fileno) on cleanup. */\n#define _IO_LINKED 0x80\t\t/* Set if linked (using _chain) to streambuf::_list_all. */\n#define _IO_IN_BACKUP 0x100\n#define _IO_LINE_BUF 0x200\n#define _IO_TIED_PUT_GET 0x400\t/* Set if put and get pointer logicly tied. */\n#define _IO_CURRENTLY_PUTTING 0x800\n#define _IO_IS_APPENDING 0x1000\n#define _IO_IS_FILEBUF 0x2000\n#define _IO_BAD_SEEN 0x4000\n#define _IO_USER_LOCK 0x8000\n\n#define _IO_FLAGS2_MMAP 1\n#define _IO_FLAGS2_NOTCANCEL 2\n#ifdef _LIBC\n#define _IO_FLAGS2_FORTIFY 4\n#endif\n#define _IO_FLAGS2_USER_WBUF 8\n#ifdef _LIBC\n#define _IO_FLAGS2_SCANF_STD 16\n#define _IO_FLAGS2_NOCLOSE 32\n#define _IO_FLAGS2_CLOEXEC 64\n#endif\n\n/* These are \"formatting flags\" matching the iostream fmtflags enum values. */\n#define _IO_SKIPWS 01\n#define _IO_LEFT 02\n#define _IO_RIGHT 04\n#define _IO_INTERNAL 010\n#define _IO_DEC 020\n#define _IO_OCT 040\n#define _IO_HEX 0100\n#define _IO_SHOWBASE 0200\n#define _IO_SHOWPOINT 0400\n#define _IO_UPPERCASE 01000\n#define _IO_SHOWPOS 02000\n#define _IO_SCIENTIFIC 04000\n#define _IO_FIXED 010000\n#define _IO_UNITBUF 020000\n#define _IO_STDIO 040000\n#define _IO_DONT_CLOSE 0100000\n#define _IO_BOOLALPHA 0200000\n\nstruct _IO_jump_t;\nstruct _IO_FILE;\n\n/* Handle lock.  */\n#ifdef _IO_MTSAFE_IO\n/* _IO_lock_t defined in internal headers during the glibc build.  */\n#else\ntypedef void _IO_lock_t;\n#endif\n\n/* A streammarker remembers a position in a buffer. */\n\nstruct _IO_marker {\n\tstruct _IO_marker *_next;\n\tstruct _IO_FILE *_sbuf;\n\t/* If _pos >= 0\n\t   it points to _buf->Gbase()+_pos. FIXME comment */\n\t/* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */\n\tint _pos;\n#if 0\n\tvoid set_streampos(streampos sp) {\n\t\t_spos = sp;\n\t} void set_offset(int offset) {\n\t\t_pos = offset;\n\t\t_spos = (streampos) (-2);\n\t}\n public:\n\tstreammarker(streambuf * sb);\n\t~streammarker();\n\tint saving() {\n\t\treturn _spos == -2;\n\t}\n\tint delta(streammarker &);\n\tint delta();\n#endif\n};\n\n/* This is the structure from the libstdc++ codecvt class.  */\nenum __codecvt_result {\n\t__codecvt_ok,\n\t__codecvt_partial,\n\t__codecvt_error,\n\t__codecvt_noconv\n};\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n/* The order of the elements in the following struct must match the order\n   of the virtual functions in the libstdc++ codecvt class.  */\nstruct _IO_codecvt {\n\tvoid (*__codecvt_destr) (struct _IO_codecvt *);\n\tenum __codecvt_result (*__codecvt_do_out) (struct _IO_codecvt *, __mbstate_t *, const wchar_t *, const wchar_t *, const wchar_t **, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_unshift) (struct _IO_codecvt *, __mbstate_t *, char *, char *, char **);\n\tenum __codecvt_result (*__codecvt_do_in) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, const char **, wchar_t *, wchar_t *, wchar_t **);\n\tint (*__codecvt_do_encoding) (struct _IO_codecvt *);\n\tint (*__codecvt_do_always_noconv) (struct _IO_codecvt *);\n\tint (*__codecvt_do_length) (struct _IO_codecvt *, __mbstate_t *, const char *, const char *, _IO_size_t);\n\tint (*__codecvt_do_max_length) (struct _IO_codecvt *);\n\n\t_IO_iconv_t __cd_in;\n\t_IO_iconv_t __cd_out;\n};\n\n/* Extra data for wide character streams.  */\nstruct _IO_wide_data {\n\twchar_t *_IO_read_ptr;\t/* Current read pointer */\n\twchar_t *_IO_read_end;\t/* End of get area. */\n\twchar_t *_IO_read_base;\t/* Start of putback+get area. */\n\twchar_t *_IO_write_base;\t/* Start of put area. */\n\twchar_t *_IO_write_ptr;\t/* Current put pointer. */\n\twchar_t *_IO_write_end;\t/* End of put area. */\n\twchar_t *_IO_buf_base;\t/* Start of reserve area. */\n\twchar_t *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\twchar_t *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\twchar_t *_IO_backup_base;\t/* Pointer to first valid character of\n\t\t\t\t\t   backup area */\n\twchar_t *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\t__mbstate_t _IO_state;\n\t__mbstate_t _IO_last_state;\n\tstruct _IO_codecvt _codecvt;\n\n\twchar_t _shortbuf[1];\n\n\tconst struct _IO_jump_t *_wide_vtable;\n};\n#endif\n\nstruct _IO_FILE {\n\tint _flags;\t\t/* High-order word is _IO_MAGIC; rest is flags. */\n#define _IO_file_flags _flags\n\n\t/* The following pointers correspond to the C++ streambuf protocol. */\n\t/* Note:  Tk uses the _IO_read_ptr and _IO_read_end fields directly. */\n\tchar *_IO_read_ptr;\t/* Current read pointer */\n\tchar *_IO_read_end;\t/* End of get area. */\n\tchar *_IO_read_base;\t/* Start of putback+get area. */\n\tchar *_IO_write_base;\t/* Start of put area. */\n\tchar *_IO_write_ptr;\t/* Current put pointer. */\n\tchar *_IO_write_end;\t/* End of put area. */\n\tchar *_IO_buf_base;\t/* Start of reserve area. */\n\tchar *_IO_buf_end;\t/* End of reserve area. */\n\t/* The following fields are used to support backing up and undo. */\n\tchar *_IO_save_base;\t/* Pointer to start of non-current get area. */\n\tchar *_IO_backup_base;\t/* Pointer to first valid character of backup area */\n\tchar *_IO_save_end;\t/* Pointer to end of non-current get area. */\n\n\tstruct _IO_marker *_markers;\n\n\tstruct _IO_FILE *_chain;\n\n\tint _fileno;\n#if 0\n\tint _blksize;\n#else\n\tint _flags2;\n#endif\n\t_IO_off_t _old_offset;\t/* This used to be _offset but it's too small.  */\n\n#define __HAVE_COLUMN\t\t/* temporary */\n\t/* 1+column number of pbase(); 0 is unknown. */\n\tunsigned short _cur_column;\n\tsigned char _vtable_offset;\n\tchar _shortbuf[1];\n\n\t/*  char* _save_gptr;  char* _save_egptr; */\n\n\t_IO_lock_t *_lock;\n#ifdef _IO_USE_OLD_IO_FILE\n};\n\nstruct _IO_FILE_complete {\n\tstruct _IO_FILE _file;\n#endif\n#if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001\n\t_IO_off64_t _offset;\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\t/* Wide character stream stuff.  */\n\tstruct _IO_codecvt *_codecvt;\n\tstruct _IO_wide_data *_wide_data;\n\tstruct _IO_FILE *_freeres_list;\n\tvoid *_freeres_buf;\n#else\n\tvoid *__pad1;\n\tvoid *__pad2;\n\tvoid *__pad3;\n\tvoid *__pad4;\n#endif\n\tsize_t __pad5;\n\tint _mode;\n\t/* Make sure we don't get into trouble again.  */\n\tchar _unused2[15 * sizeof(int) - 4 * sizeof(void *) - sizeof(size_t)];\n#endif\n};\n\n#ifndef __cplusplus\ntypedef struct _IO_FILE _IO_FILE;\n#endif\n\nstruct _IO_FILE_plus;\n\nextern struct _IO_FILE_plus _IO_2_1_stdin_;\nextern struct _IO_FILE_plus _IO_2_1_stdout_;\nextern struct _IO_FILE_plus _IO_2_1_stderr_;\n#ifndef _LIBC\n#define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))\n#define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))\n#define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))\n#else\nextern _IO_FILE *_IO_stdin attribute_hidden;\nextern _IO_FILE *_IO_stdout attribute_hidden;\nextern _IO_FILE *_IO_stderr attribute_hidden;\n#endif\n\n/* Functions to do I/O and file management for a stream.  */\n\n/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.\n   Return number of bytes read.  */\ntypedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __nbytes);\n\n/* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes\n   unless there is an error.  Return number of bytes written.  If\n   there is an error, return 0 and do not write anything.  If the file\n   has been opened for append (__mode.__append set), then set the file\n   pointer to the end of the file and then do the write; if not, just\n   write at the current file pointer.  */\ntypedef __ssize_t __io_write_fn(void *__cookie, const char *__buf, size_t __n);\n\n/* Move COOKIE's file position to *POS bytes from the\n   beginning of the file (if W is SEEK_SET),\n   the current position (if W is SEEK_CUR),\n   or the end of the file (if W is SEEK_END).\n   Set *POS to the new file position.\n   Returns zero if successful, nonzero if not.  */\ntypedef int __io_seek_fn(void *__cookie, _IO_off64_t * __pos, int __w);\n\n/* Close COOKIE.  */\ntypedef int __io_close_fn(void *__cookie);\n\n#ifdef _GNU_SOURCE\n/* User-visible names for the above.  */\ntypedef __io_read_fn cookie_read_function_t;\ntypedef __io_write_fn cookie_write_function_t;\ntypedef __io_seek_fn cookie_seek_function_t;\ntypedef __io_close_fn cookie_close_function_t;\n\n/* The structure with the cookie function pointers.  */\ntypedef struct {\n\t__io_read_fn *read;\t/* Read bytes.  */\n\t__io_write_fn *write;\t/* Write bytes.  */\n\t__io_seek_fn *seek;\t/* Seek/tell file position.  */\n\t__io_close_fn *close;\t/* Close file.  */\n} _IO_cookie_io_functions_t;\ntypedef _IO_cookie_io_functions_t cookie_io_functions_t;\n\nstruct _IO_cookie_file;\n\n/* Initialize one of those.  */\nextern void _IO_cookie_init(struct _IO_cookie_file *__cfile, int __read_write, void *__cookie, _IO_cookie_io_functions_t __fns);\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\textern int __underflow(_IO_FILE *);\n\textern int __uflow(_IO_FILE *);\n\textern int __overflow(_IO_FILE *, int);\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t __wunderflow(_IO_FILE *);\n\textern _IO_wint_t __wuflow(_IO_FILE *);\n\textern _IO_wint_t __woverflow(_IO_FILE *, _IO_wint_t);\n#endif\n\n#if  __GNUC__ >= 3\n#define _IO_BE(expr, res) __builtin_expect ((expr), res)\n#else\n#define _IO_BE(expr, res) (expr)\n#endif\n\n#define _IO_getc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)\n#define _IO_peekc_unlocked(_fp) \\\n       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \\\n\t  && __underflow (_fp) == EOF ? EOF \\\n\t: *(unsigned char *) (_fp)->_IO_read_ptr)\n#define _IO_putc_unlocked(_ch, _fp) \\\n   (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \\\n    ? __overflow (_fp, (unsigned char) (_ch)) \\\n    : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n#define _IO_getwc_unlocked(_fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_read_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_read_end), 0)\t\t\t\\\n   ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)\n#define _IO_putwc_unlocked(_wch, _fp) \\\n  (_IO_BE ((_fp)->_wide_data == NULL\t\t\t\t\t\\\n\t   || ((_fp)->_wide_data->_IO_write_ptr\t\t\t\t\\\n\t       >= (_fp)->_wide_data->_IO_write_end), 0)\t\t\t\\\n   ? __woverflow (_fp, _wch)\t\t\t\t\t\t\\\n   : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))\n#endif\n\n#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)\n#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)\n\n\textern int _IO_getc(_IO_FILE * __fp);\n\textern int _IO_putc(int __c, _IO_FILE * __fp);\n\textern int _IO_feof(_IO_FILE * __fp) __THROW;\n\textern int _IO_ferror(_IO_FILE * __fp) __THROW;\n\n\textern int _IO_peekc_locked(_IO_FILE * __fp);\n\n/* This one is for Emacs. */\n#define _IO_PENDING_OUTPUT_COUNT(_fp)\t\\\n\t((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)\n\n\textern void _IO_flockfile(_IO_FILE *) __THROW;\n\textern void _IO_funlockfile(_IO_FILE *) __THROW;\n\textern int _IO_ftrylockfile(_IO_FILE *) __THROW;\n\n#ifdef _IO_MTSAFE_IO\n#define _IO_peekc(_fp) _IO_peekc_locked (_fp)\n#define _IO_flockfile(_fp) \\\n  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)\n#define _IO_funlockfile(_fp) \\\n  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)\n#else\n#define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)\n#define _IO_flockfile(_fp) /**/\n#define _IO_funlockfile(_fp) /**/\n#define _IO_ftrylockfile(_fp) /**/\n#define _IO_cleanup_region_start(_fct, _fp) /**/\n#define _IO_cleanup_region_end(_Doit) /**/\n#endif\t\t\t\t/* !_IO_MTSAFE_IO */\n\textern int _IO_vfscanf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfprintf(_IO_FILE * __restrict, const char *__restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_padn(_IO_FILE *, int, _IO_ssize_t);\n\textern _IO_size_t _IO_sgetn(_IO_FILE *, void *, _IO_size_t);\n\n\textern _IO_off64_t _IO_seekoff(_IO_FILE *, _IO_off64_t, int, int);\n\textern _IO_off64_t _IO_seekpos(_IO_FILE *, _IO_off64_t, int);\n\n\textern void _IO_free_backup_area(_IO_FILE *) __THROW;\n\n#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T\n\textern _IO_wint_t _IO_getwc(_IO_FILE * __fp);\n\textern _IO_wint_t _IO_putwc(wchar_t __wc, _IO_FILE * __fp);\n\textern int _IO_fwide(_IO_FILE * __fp, int __mode) __THROW;\n#if __GNUC__ >= 2\n/* While compiling glibc we have to handle compatibility with very old\n   versions.  */\n#if defined _LIBC && defined SHARED\n#include <shlib-compat.h>\n#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)\n#define _IO_fwide_maybe_incompatible \\\n  (__builtin_expect (&_IO_stdin_used == NULL, 0))\n\textern const int _IO_stdin_used;\n\t weak_extern(_IO_stdin_used);\n#endif\n#endif\n#ifndef _IO_fwide_maybe_incompatible\n#define _IO_fwide_maybe_incompatible (0)\n#endif\n/* A special optimized version of the function above.  It optimizes the\n   case of initializing an unoriented byte stream.  */\n#define _IO_fwide(__fp, __mode) \\\n  ({ int __result = (__mode);\t\t\t\t\t\t      \\\n     if (__result < 0 && ! _IO_fwide_maybe_incompatible)\t\t      \\\n       {\t\t\t\t\t\t\t\t      \\\n\t if ((__fp)->_mode == 0)\t\t\t\t\t      \\\n\t   /* We know that all we have to do is to set the flag.  */\t      \\\n\t   (__fp)->_mode = -1;\t\t\t\t\t\t      \\\n\t __result = (__fp)->_mode;\t\t\t\t\t      \\\n       }\t\t\t\t\t\t\t\t      \\\n     else if (__builtin_constant_p (__mode) && (__mode) == 0)\t\t      \\\n       __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode;\t      \\\n     else\t\t\t\t\t\t\t\t      \\\n       __result = _IO_fwide (__fp, __result);\t\t\t\t      \\\n     __result; })\n#endif\n\n\textern int _IO_vfwscanf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list, int *__restrict);\n\textern int _IO_vfwprintf(_IO_FILE * __restrict, const wchar_t * __restrict, _IO_va_list);\n\textern _IO_ssize_t _IO_wpadn(_IO_FILE *, wint_t, _IO_ssize_t);\n\textern void _IO_free_wbackup_area(_IO_FILE *) __THROW;\n#endif\n\n#ifdef __LDBL_COMPAT\n#include <bits/libio-ldbl.h>\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* _IO_STDIO_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/limits.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types\t<limits.h>\n */\n\n#ifndef _LIBC_LIMITS_H_\n#define _LIBC_LIMITS_H_\t1\n\n#include <features.h>\n\n/* Maximum length of any multibyte character in any locale.\n   We define this value here since the gcc header does not define\n   the correct value.  */\n#define MB_LEN_MAX\t16\n\n/* If we are not using GNU CC we have to define all the symbols ourself.\n   Otherwise use gcc's definitions (see below).  */\n#if !defined __GNUC__ || __GNUC__ < 2\n\n/* We only protect from multiple inclusion here, because all the other\n   #include's protect themselves, and in GCC 2 we may #include_next through\n   multiple copies of this file before we get to GCC's.  */\n#ifndef _LIMITS_H\n#define _LIMITS_H\t1\n\n#include <bits/wordsize.h>\n\n/* We don't have #include_next.\n   Define ANSI <limits.h> for standard 32-bit words.  */\n\n/* These assume 8-bit `char's, 16-bit `short int's,\n   and 32-bit `int's and `long int's.  */\n\n/* Number of bits in a `char'.\t*/\n#define CHAR_BIT\t8\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#define SCHAR_MIN\t(-128)\n#define SCHAR_MAX\t127\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0.)  */\n#define UCHAR_MAX\t255\n\n/* Minimum and maximum values a `char' can hold.  */\n#ifdef __CHAR_UNSIGNED__\n#define CHAR_MIN\t0\n#define CHAR_MAX\tUCHAR_MAX\n#else\n#define CHAR_MIN\tSCHAR_MIN\n#define CHAR_MAX\tSCHAR_MAX\n#endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#define SHRT_MIN\t(-32768)\n#define SHRT_MAX\t32767\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0.)  */\n#define USHRT_MAX\t65535\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#define INT_MIN\t(-INT_MAX - 1)\n#define INT_MAX\t2147483647\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0.)  */\n#define UINT_MAX\t4294967295U\n\n/* Minimum and maximum values a `signed long int' can hold.  */\n#if __WORDSIZE == 64\n#define LONG_MAX\t9223372036854775807L\n#else\n#define LONG_MAX\t2147483647L\n#endif\n#define LONG_MIN\t(-LONG_MAX - 1L)\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0.)  */\n#if __WORDSIZE == 64\n#define ULONG_MAX\t18446744073709551615UL\n#else\n#define ULONG_MAX\t4294967295UL\n#endif\n\n#ifdef __USE_ISOC99\n\n/* Minimum and maximum values a `signed long long int' can hold.  */\n#define LLONG_MAX\t9223372036854775807LL\n#define LLONG_MIN\t(-LLONG_MAX - 1LL)\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0.)  */\n#define ULLONG_MAX\t18446744073709551615ULL\n\n#endif\t\t\t\t/* ISO C99 */\n\n#endif\t\t\t\t/* limits.h  */\n#endif\t\t\t\t/* GCC 2.  */\n\n#endif\t\t\t\t/* !_LIBC_LIMITS_H_ */\n\n /* Get the compiler's limits.h, which defines almost all the ISO constants.\n\n    We put this #include_next outside the double inclusion check because\n    it should be possible to include this file more than once and still get\n    the definitions from gcc's header.  */\n#if defined __GNUC__ && !defined _GCC_LIMITS_H_\n/* `_GCC_LIMITS_H_' is what GCC's file defines.  */\n#include_next <limits.h>\n#endif\n\n/* The <limits.h> files in some gcc versions don't define LLONG_MIN,\n   LLONG_MAX, and ULLONG_MAX.  Instead only the values gcc defined for\n   ages are available.  */\n#if defined __USE_ISOC99 && defined __GNUC__\n#ifndef LLONG_MIN\n#define LLONG_MIN\t(-LLONG_MAX-1)\n#endif\n#ifndef LLONG_MAX\n#define LLONG_MAX\t__LONG_LONG_MAX__\n#endif\n#ifndef ULLONG_MAX\n#define ULLONG_MAX\t(LLONG_MAX * 2ULL + 1)\n#endif\n#endif\n\n#ifdef\t__USE_POSIX\n/* POSIX adds things to <limits.h>.  */\n#include <bits/posix1_lim.h>\n#endif\n\n#ifdef\t__USE_POSIX2\n#include <bits/posix2_lim.h>\n#endif\n\n#ifdef\t__USE_XOPEN\n#include <bits/xopen_lim.h>\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/linux/errno.h",
    "content": "#include <asm/errno.h>\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/linux/ioctl.h",
    "content": "#ifndef _LINUX_IOCTL_H\n#define _LINUX_IOCTL_H\n\n#include <asm/ioctl.h>\n\n#endif\t\t\t\t/* _LINUX_IOCTL_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/linux/limits.h",
    "content": "#ifndef _LINUX_LIMITS_H\n#define _LINUX_LIMITS_H\n\n#define NR_OPEN\t        1024\n\n#define NGROUPS_MAX    65536\t/* supplemental group IDs are available */\n#define ARG_MAX       131072\t/* # bytes of args + environ for exec() */\n#define LINK_MAX         127\t/* # links a file may have */\n#define MAX_CANON        255\t/* size of the canonical input queue */\n#define MAX_INPUT        255\t/* size of the type-ahead buffer */\n#define NAME_MAX         255\t/* # chars in a file name */\n#define PATH_MAX        4096\t/* # chars in a path name including nul */\n#define PIPE_BUF        4096\t/* # bytes in atomic write to a pipe */\n#define XATTR_NAME_MAX   255\t/* # chars in an extended attribute name */\n#define XATTR_SIZE_MAX 65536\t/* size of an extended attribute value (64k) */\n#define XATTR_LIST_MAX 65536\t/* size of extended attribute namelist (64k) */\n\n#define RTSIG_MAX\t  32\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/linux/param.h",
    "content": "#ifndef _LINUX_PARAM_H\n#define _LINUX_PARAM_H\n\n#include <asm/param.h>\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/locale.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.11 Localization\t<locale.h>\n */\n\n#ifndef\t_LOCALE_H\n#define\t_LOCALE_H\t1\n\n#include <features.h>\n\n#define __need_NULL\n#include <stddef.h>\n#include <bits/locale.h>\n\n__BEGIN_DECLS\n/* These are the possibilities for the first argument to setlocale.\n   The code assumes that the lowest LC_* symbol has the value zero.  */\n#define LC_CTYPE          __LC_CTYPE\n#define LC_NUMERIC        __LC_NUMERIC\n#define LC_TIME           __LC_TIME\n#define LC_COLLATE        __LC_COLLATE\n#define LC_MONETARY       __LC_MONETARY\n#define LC_MESSAGES       __LC_MESSAGES\n#define\tLC_ALL\t\t  __LC_ALL\n#define LC_PAPER\t  __LC_PAPER\n#define LC_NAME\t\t  __LC_NAME\n#define LC_ADDRESS\t  __LC_ADDRESS\n#define LC_TELEPHONE\t  __LC_TELEPHONE\n#define LC_MEASUREMENT\t  __LC_MEASUREMENT\n#define LC_IDENTIFICATION __LC_IDENTIFICATION\n    __BEGIN_NAMESPACE_STD\n/* Structure giving information about numeric and monetary notation.  */\n    struct lconv {\n\t/* Numeric (non-monetary) information.  */\n\n\tchar *decimal_point;\t/* Decimal point character.  */\n\tchar *thousands_sep;\t/* Thousands separator.  */\n\t/* Each element is the number of digits in each group;\n\t   elements with higher indices are farther left.\n\t   An element with value CHAR_MAX means that no further grouping is done.\n\t   An element with value 0 means that the previous element is used\n\t   for all groups farther left.  */\n\tchar *grouping;\n\n\t/* Monetary information.  */\n\n\t/* First three chars are a currency symbol from ISO 4217.\n\t   Fourth char is the separator.  Fifth char is '\\0'.  */\n\tchar *int_curr_symbol;\n\tchar *currency_symbol;\t/* Local currency symbol.  */\n\tchar *mon_decimal_point;\t/* Decimal point character.  */\n\tchar *mon_thousands_sep;\t/* Thousands separator.  */\n\tchar *mon_grouping;\t/* Like `grouping' element (above).  */\n\tchar *positive_sign;\t/* Sign for positive values.  */\n\tchar *negative_sign;\t/* Sign for negative values.  */\n\tchar int_frac_digits;\t/* Int'l fractional digits.  */\n\tchar frac_digits;\t/* Local fractional digits.  */\n\t/* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */\n\tchar p_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a positive value.  */\n\tchar p_sep_by_space;\n\t/* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */\n\tchar n_cs_precedes;\n\t/* 1 iff a space separates currency_symbol from a negative value.  */\n\tchar n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and currency_symbol.\n\t   1 The sign string precedes the quantity and currency_symbol.\n\t   2 The sign string follows the quantity and currency_symbol.\n\t   3 The sign string immediately precedes the currency_symbol.\n\t   4 The sign string immediately follows the currency_symbol.  */\n\tchar p_sign_posn;\n\tchar n_sign_posn;\n#ifdef __USE_ISOC99\n\t/* 1 if int_curr_symbol precedes a positive value, 0 if succeeds.  */\n\tchar int_p_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a positive value.  */\n\tchar int_p_sep_by_space;\n\t/* 1 if int_curr_symbol precedes a negative value, 0 if succeeds.  */\n\tchar int_n_cs_precedes;\n\t/* 1 iff a space separates int_curr_symbol from a negative value.  */\n\tchar int_n_sep_by_space;\n\t/* Positive and negative sign positions:\n\t   0 Parentheses surround the quantity and int_curr_symbol.\n\t   1 The sign string precedes the quantity and int_curr_symbol.\n\t   2 The sign string follows the quantity and int_curr_symbol.\n\t   3 The sign string immediately precedes the int_curr_symbol.\n\t   4 The sign string immediately follows the int_curr_symbol.  */\n\tchar int_p_sign_posn;\n\tchar int_n_sign_posn;\n#else\n\tchar __int_p_cs_precedes;\n\tchar __int_p_sep_by_space;\n\tchar __int_n_cs_precedes;\n\tchar __int_n_sep_by_space;\n\tchar __int_p_sign_posn;\n\tchar __int_n_sign_posn;\n#endif\n};\n\n/* Set and/or return the current locale.  */\nextern char *setlocale(int __category, const char *__locale) __THROW;\n\n/* Return the numeric/monetary information for the current locale.  */\nextern struct lconv *localeconv(void) __THROW;\n\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n/* Get locale datatype definition.  */\n#include <xlocale.h>\n/* Return a reference to a data structure representing a set of locale\n   datasets.  Unlike for the CATEGORY parameter for `setlocale' the\n   CATEGORY_MASK parameter here uses a single bit for each category,\n   made by OR'ing together LC_*_MASK bits above.  */\nextern __locale_t newlocale(int __category_mask, const char *__locale, __locale_t __base) __THROW;\n\n/* These are the bits that can be set in the CATEGORY_MASK argument to\n   `newlocale'.  In the GNU implementation, LC_FOO_MASK has the value\n   of (1 << LC_FOO), but this is not a part of the interface that\n   callers can assume will be true.  */\n#define LC_CTYPE_MASK\t\t(1 << __LC_CTYPE)\n#define LC_NUMERIC_MASK\t(1 << __LC_NUMERIC)\n#define LC_TIME_MASK\t\t(1 << __LC_TIME)\n#define LC_COLLATE_MASK\t(1 << __LC_COLLATE)\n#define LC_MONETARY_MASK\t(1 << __LC_MONETARY)\n#define LC_MESSAGES_MASK\t(1 << __LC_MESSAGES)\n#define LC_PAPER_MASK\t\t(1 << __LC_PAPER)\n#define LC_NAME_MASK\t\t(1 << __LC_NAME)\n#define LC_ADDRESS_MASK\t(1 << __LC_ADDRESS)\n#define LC_TELEPHONE_MASK\t(1 << __LC_TELEPHONE)\n#define LC_MEASUREMENT_MASK\t(1 << __LC_MEASUREMENT)\n#define LC_IDENTIFICATION_MASK\t(1 << __LC_IDENTIFICATION)\n#define LC_ALL_MASK\t\t(LC_CTYPE_MASK \\\n\t\t\t\t | LC_NUMERIC_MASK \\\n\t\t\t\t | LC_TIME_MASK \\\n\t\t\t\t | LC_COLLATE_MASK \\\n\t\t\t\t | LC_MONETARY_MASK \\\n\t\t\t\t | LC_MESSAGES_MASK \\\n\t\t\t\t | LC_PAPER_MASK \\\n\t\t\t\t | LC_NAME_MASK \\\n\t\t\t\t | LC_ADDRESS_MASK \\\n\t\t\t\t | LC_TELEPHONE_MASK \\\n\t\t\t\t | LC_MEASUREMENT_MASK \\\n\t\t\t\t | LC_IDENTIFICATION_MASK \\\n\t\t\t\t )\n\n/* Return a duplicate of the set of locale in DATASET.  All usage\n   counters are increased if necessary.  */\nextern __locale_t duplocale(__locale_t __dataset) __THROW;\n\n/* Free the data associated with a locale dataset previously returned\n   by a call to `setlocale_r'.  */\nextern void freelocale(__locale_t __dataset) __THROW;\n\n/* Switch the current thread's locale to DATASET.\n   If DATASET is null, instead just return the current setting.\n   The special value LC_GLOBAL_LOCALE is the initial setting\n   for all threads and can also be installed any time, meaning\n   the thread uses the global settings controlled by `setlocale'.  */\nextern __locale_t uselocale(__locale_t __dataset) __THROW;\n\n/* This value can be passed to `uselocale' and may be returned by it.\n   Passing this value to any other function has undefined behavior.  */\n#define LC_GLOBAL_LOCALE\t((__locale_t) -1L)\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* locale.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/malloc.h",
    "content": "/* Prototypes and definition for malloc implementation.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _MALLOC_H\n#define _MALLOC_H 1\n\n#include <features.h>\n#include <stddef.h>\n#include <stdio.h>\n\n#ifdef _LIBC\n#define __MALLOC_HOOK_VOLATILE\n#define __MALLOC_DEPRECATED\n#else\n#define __MALLOC_HOOK_VOLATILE volatile\n#define __MALLOC_DEPRECATED __attribute_deprecated__\n#endif\n\n__BEGIN_DECLS\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Re-allocate the previously allocated block in __ptr, making the new\n   block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n\n/* Free a block allocated by `calloc'. */\nextern void cfree(void *__ptr) __THROW;\n\n/* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */\nextern void *memalign(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Allocate SIZE bytes on a page boundary.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up\n   __size to nearest pagesize. */\nextern void *pvalloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n\n/* Underlying allocation function; successive calls should return\n   contiguous pieces of memory.  */\nextern void *(*__morecore) (ptrdiff_t __size);\n\n/* Default value of `__morecore'.  */\nextern void *__default_morecore(ptrdiff_t __size)\n__THROW __attribute_malloc__;\n\n/* SVID2/XPG mallinfo structure */\n\nstruct mallinfo {\n\tint arena;\t\t/* non-mmapped space allocated from system */\n\tint ordblks;\t\t/* number of free chunks */\n\tint smblks;\t\t/* number of fastbin blocks */\n\tint hblks;\t\t/* number of mmapped regions */\n\tint hblkhd;\t\t/* space in mmapped regions */\n\tint usmblks;\t\t/* always 0, preserved for backwards compatibility */\n\tint fsmblks;\t\t/* space available in freed fastbin blocks */\n\tint uordblks;\t\t/* total allocated space */\n\tint fordblks;\t\t/* total free space */\n\tint keepcost;\t\t/* top-most, releasable (via malloc_trim) space */\n};\n\n/* Returns a copy of the updated current mallinfo. */\nextern struct mallinfo mallinfo(void) __THROW;\n\n/* SVID2/XPG mallopt options */\n#ifndef M_MXFAST\n#define M_MXFAST  1\t\t/* maximum request size for \"fastbins\" */\n#endif\n#ifndef M_NLBLKS\n#define M_NLBLKS  2\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_GRAIN\n#define M_GRAIN   3\t\t/* UNUSED in this malloc */\n#endif\n#ifndef M_KEEP\n#define M_KEEP    4\t\t/* UNUSED in this malloc */\n#endif\n\n/* mallopt options that actually do something */\n#define M_TRIM_THRESHOLD    -1\n#define M_TOP_PAD           -2\n#define M_MMAP_THRESHOLD    -3\n#define M_MMAP_MAX          -4\n#define M_CHECK_ACTION      -5\n#define M_PERTURB           -6\n#define M_ARENA_TEST        -7\n#define M_ARENA_MAX         -8\n\n/* General SVID/XPG interface to tunable parameters. */\nextern int mallopt(int __param, int __val) __THROW;\n\n/* Release all but __pad bytes of freed top-most memory back to the\n   system. Return 1 if successful, else 0. */\nextern int malloc_trim(size_t __pad) __THROW;\n\n/* Report the number of usable allocated bytes associated with allocated\n   chunk __ptr. */\nextern size_t malloc_usable_size(void *__ptr) __THROW;\n\n/* Prints brief summary statistics on stderr. */\nextern void malloc_stats(void) __THROW;\n\n/* Output information about state of allocator to stream FP.  */\nextern int malloc_info(int __options, FILE * __fp) __THROW;\n\n/* Record the state of all malloc variables in an opaque data structure. */\nextern void *malloc_get_state(void) __THROW;\n\n/* Restore the state of all malloc variables from data obtained with\n   malloc_get_state(). */\nextern int malloc_set_state(void *__ptr) __THROW;\n\n/* Hooks for debugging and user-defined versions. */\nextern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment, size_t __size, const void *)__MALLOC_DEPRECATED;\nextern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);\n\n/* Activate a standard set of debugging hooks. */\nextern void __malloc_check_init(void)\n__THROW __MALLOC_DEPRECATED;\n\n__END_DECLS\n#endif\t\t\t\t/* malloc.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/math.h",
    "content": "/* Declarations for math functions.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.12 Mathematics\t<math.h>\n */\n\n#ifndef\t_MATH_H\n#define\t_MATH_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get machine-dependent vector math functions declarations.  */\n#include <bits/math-vector.h>\n/* Get machine-dependent HUGE_VAL value (returned on overflow).\n   On all IEEE754 machines, this is +Infinity.  */\n#include <bits/huge_val.h>\n#ifdef __USE_ISOC99\n#include <bits/huge_valf.h>\n#include <bits/huge_vall.h>\n/* Get machine-dependent INFINITY value.  */\n#include <bits/inf.h>\n/* Get machine-dependent NAN value (returned for some domain errors).  */\n#include <bits/nan.h>\n#endif\t\t\t\t/* __USE_ISOC99 */\n/* Get general and ISO C99 specific information.  */\n#include <bits/mathdef.h>\n/* The file <bits/mathcalls.h> contains the prototypes for all the\n   actual math functions.  These macros are used for those prototypes,\n   so we can easily declare each function as both `name' and `__name',\n   and can declare the float versions `namef' and `__namef'.  */\n#define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)\n#define __MATHCALL_VEC(function, suffix, args) \t\\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHCALL (function, suffix, args)\n#define __MATHDECL_VEC(type, function,suffix, args) \\\n  __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \\\n  __MATHDECL(type, function,suffix, args)\n#define __MATHCALL(function,suffix, args)\t\\\n  __MATHDECL (_Mdouble_,function,suffix, args)\n#define __MATHDECL(type, function,suffix, args) \\\n  __MATHDECL_1(type, function,suffix, args); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args)\n#define __MATHCALLX(function,suffix, args, attrib)\t\\\n  __MATHDECLX (_Mdouble_,function,suffix, args, attrib)\n#define __MATHDECLX(type, function,suffix, args, attrib) \\\n  __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \\\n  __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)\n#define __MATHDECL_1(type, function,suffix, args) \\\n  extern type __MATH_PRECNAME(function,suffix) args __THROW\n#define _Mdouble_\t\tdouble\n#define __MATH_PRECNAME(name,r)\t__CONCAT(name,r)\n#define __MATH_DECLARING_DOUBLE  1\n#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD\n#define _Mdouble_END_NAMESPACE   __END_NAMESPACE_STD\n#include <bits/mathcalls.h>\n#undef\t_Mdouble_\n#undef _Mdouble_BEGIN_NAMESPACE\n#undef _Mdouble_END_NAMESPACE\n#undef\t__MATH_PRECNAME\n#undef __MATH_DECLARING_DOUBLE\n#ifdef __USE_ISOC99\n/* Include the file of declarations again, this time using `float'\n   instead of `double' and appending f to each function name.  */\n#ifndef _Mfloat_\n#define _Mfloat_\t\tfloat\n#endif\n#define _Mdouble_\t\t_Mfloat_\n#define __MATH_PRECNAME(name,r) name##f##r\n#define __MATH_DECLARING_DOUBLE  0\n#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99\n#define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99\n#include <bits/mathcalls.h>\n#undef\t_Mdouble_\n#undef _Mdouble_BEGIN_NAMESPACE\n#undef _Mdouble_END_NAMESPACE\n#undef\t__MATH_PRECNAME\n#undef __MATH_DECLARING_DOUBLE\n#if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \\\n     || defined __LDBL_COMPAT \\\n     || defined _LIBC_TEST\n#ifdef __LDBL_COMPAT\n#ifdef __USE_ISOC99\nextern float __nldbl_nexttowardf(float __x, long double __y)\n__THROW __attribute__ ((__const__));\n#ifdef __REDIRECT_NTH\nextern float __REDIRECT_NTH(nexttowardf, (float __x, long double __y), __nldbl_nexttowardf)\n    __attribute__ ((__const__));\nextern double __REDIRECT_NTH(nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__));\nextern long double __REDIRECT_NTH(nexttowardl, (long double __x, long double __y), nextafter) __attribute__ ((__const__));\n#endif\n#endif\n\n#undef __MATHDECL_1\n#define __MATHDECL_2(type, function,suffix, args, alias) \\\n  extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \\\n\t\t\t     args, alias)\n#define __MATHDECL_1(type, function,suffix, args) \\\n  __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))\n#endif\n\n/* Include the file of declarations again, this time using `long double'\n   instead of `double' and appending l to each function name.  */\n\n#ifndef _Mlong_double_\n#define _Mlong_double_\tlong double\n#endif\n#define _Mdouble_\t\t_Mlong_double_\n#define __MATH_PRECNAME(name,r) name##l##r\n#define __MATH_DECLARING_DOUBLE  0\n#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99\n#define _Mdouble_END_NAMESPACE   __END_NAMESPACE_C99\n#define __MATH_DECLARE_LDOUBLE   1\n#include <bits/mathcalls.h>\n#undef _Mdouble_\n#undef _Mdouble_BEGIN_NAMESPACE\n#undef _Mdouble_END_NAMESPACE\n#undef __MATH_PRECNAME\n#undef __MATH_DECLARING_DOUBLE\n\n#endif\t\t\t\t/* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */\n\n#endif\t\t\t\t/* Use ISO C99.  */\n#undef\t__MATHDECL_1\n#undef\t__MATHDECL\n#undef\t__MATHCALL\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* This variable is used by `gamma' and `lgamma'.  */\nextern int signgam;\n#endif\n\n/* ISO C99 defines some generic macros which work on any data type.  */\n#ifdef __USE_ISOC99\n\n/* Get the architecture specific values describing the floating-point\n   evaluation.  The following symbols will get defined:\n\n    float_t\tfloating-point type at least as wide as `float' used\n\t\tto evaluate `float' expressions\n    double_t\tfloating-point type at least as wide as `double' used\n\t\tto evaluate `double' expressions\n\n    FLT_EVAL_METHOD\n\t\tDefined to\n\t\t  0\tif `float_t' is `float' and `double_t' is `double'\n\t\t  1\tif `float_t' and `double_t' are `double'\n\t\t  2\tif `float_t' and `double_t' are `long double'\n\t\t  else\t`float_t' and `double_t' are unspecified\n\n    INFINITY\trepresentation of the infinity value of type `float'\n\n    FP_FAST_FMA\n    FP_FAST_FMAF\n    FP_FAST_FMAL\n\t\tIf defined it indicates that the `fma' function\n\t\tgenerally executes about as fast as a multiply and an add.\n\t\tThis macro is defined only iff the `fma' function is\n\t\timplemented directly with a hardware multiply-add instructions.\n\n    FP_ILOGB0\tExpands to a value returned by `ilogb (0.0)'.\n    FP_ILOGBNAN\tExpands to a value returned by `ilogb (NAN)'.\n\n    DECIMAL_DIG\tNumber of decimal digits supported by conversion between\n\t\tdecimal and all internal floating-point formats.\n\n*/\n\n/* All floating-point numbers can be put in one of these categories.  */\nenum {\n\tFP_NAN =\n#define FP_NAN 0\n\t    FP_NAN,\n\tFP_INFINITE =\n#define FP_INFINITE 1\n\t    FP_INFINITE,\n\tFP_ZERO =\n#define FP_ZERO 2\n\t    FP_ZERO,\n\tFP_SUBNORMAL =\n#define FP_SUBNORMAL 3\n\t    FP_SUBNORMAL,\n\tFP_NORMAL =\n#define FP_NORMAL 4\n\tFP_NORMAL\n};\n\n/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,\n   so disable builtins if this is enabled.  When fixed in a newer GCC,\n   the __SUPPORT_SNAN__ check may be skipped for those versions.  */\n\n/* Return number of classification appropriate for X.  */\n#if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\t\t\t      \\\n     && !defined __OPTIMIZE_SIZE__\n#define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,\t      \\\n     FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)\n#elif defined __NO_LONG_DOUBLE_MATH\n#define fpclassify(x) \\\n     (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))\n#else\n#define fpclassify(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __fpclassifyf (x)\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __fpclassify (x) : __fpclassifyl (x))\n#endif\n\n/* Return nonzero value if sign of X is negative.  */\n#if __GNUC_PREREQ (4,0)\n#define signbit(x) \\\n     (sizeof (x) == sizeof (float)                                            \\\n      ? __builtin_signbitf (x)                                                        \\\n      : sizeof (x) == sizeof (double)                                         \\\n      ? __builtin_signbit (x) : __builtin_signbitl (x))\n#else\n#ifdef __NO_LONG_DOUBLE_MATH\n#define signbit(x) \\\n     (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))\n#else\n#define signbit(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __signbitf (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __signbit (x) : __signbitl (x))\n#endif\n#endif\n\n/* Return nonzero value if X is not +-Inf or NaN.  */\n#if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#define isfinite(x) __builtin_isfinite (x)\n#elif defined __NO_LONG_DOUBLE_MATH\n#define isfinite(x) \\\n     (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))\n#else\n#define isfinite(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __finitef (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __finite (x) : __finitel (x))\n#endif\n\n/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */\n#if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#define isnormal(x) __builtin_isnormal (x)\n#else\n#define isnormal(x) (fpclassify (x) == FP_NORMAL)\n#endif\n\n/* Return nonzero value if X is a NaN.  We could use `fpclassify' but\n   we already have this functions `__isnan' and it is faster.  */\n#if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#define isnan(x) __builtin_isnan (x)\n#elif defined __NO_LONG_DOUBLE_MATH\n#define isnan(x) \\\n     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))\n#else\n#define isnan(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __isnanf (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __isnan (x) : __isnanl (x))\n#endif\n\n/* Return nonzero value if X is positive or negative infinity.  */\n#if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__\n#define isinf(x) __builtin_isinf_sign (x)\n#elif defined __NO_LONG_DOUBLE_MATH\n#define isinf(x) \\\n     (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))\n#else\n#define isinf(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __isinff (x)\t\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __isinf (x) : __isinfl (x))\n#endif\n\n/* Bitmasks for the math_errhandling macro.  */\n#define MATH_ERRNO\t1\t/* errno set by math functions.  */\n#define MATH_ERREXCEPT\t2\t/* Exceptions raised by math functions.  */\n\n/* By default all functions support both errno and exception handling.\n   In gcc's fast math mode and if inline functions are defined this\n   might not be true.  */\n#ifndef __FAST_MATH__\n#define math_errhandling\t(MATH_ERRNO | MATH_ERREXCEPT)\n#endif\n\n#endif\t\t\t\t/* Use ISO C99.  */\n\n#ifdef __USE_GNU\n/* Return nonzero value if X is a signaling NaN.  */\n#ifdef __NO_LONG_DOUBLE_MATH\n#define issignaling(x) \\\n     (sizeof (x) == sizeof (float) ? __issignalingf (x) : __issignaling (x))\n#else\n#define issignaling(x) \\\n     (sizeof (x) == sizeof (float)\t\t\t\t\t      \\\n      ? __issignalingf (x)\t\t\t\t\t\t      \\\n      : sizeof (x) == sizeof (double)\t\t\t\t\t      \\\n      ? __issignaling (x) : __issignalingl (x))\n#endif\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef\t__USE_MISC\n/* Support for various different standard error handling behaviors.  */\ntypedef enum {\n\t_IEEE_ = -1,\t\t/* According to IEEE 754/IEEE 854.  */\n\t_SVID_,\t\t\t/* According to System V, release 4.  */\n\t_XOPEN_,\t\t/* Nowadays also Unix98.  */\n\t_POSIX_,\n\t_ISOC_\t\t\t/* Actually this is ISO C99.  */\n} _LIB_VERSION_TYPE;\n\n/* This variable can be changed at run-time to any of the values above to\n   affect floating point error handling behavior (it may also be necessary\n   to change the hardware FPU exception settings).  */\nextern _LIB_VERSION_TYPE _LIB_VERSION;\n#endif\n\n#ifdef __USE_MISC\n/* In SVID error handling, `matherr' is called with this description\n   of the exceptional condition.\n\n   We have a problem when using C++ since `exception' is a reserved\n   name in C++.  */\n#ifdef __cplusplus\nstruct __exception\n#else\nstruct exception\n#endif\n{\n\tint type;\n\tchar *name;\n\tdouble arg1;\n\tdouble arg2;\n\tdouble retval;\n};\n\n#ifdef __cplusplus\nextern int matherr(struct __exception *__exc) throw();\n#else\nextern int matherr(struct exception *__exc);\n#endif\n\n#define X_TLOSS\t1.41484755040568800000e+16\n\n/* Types of exceptions in the `type' field.  */\n#define DOMAIN\t\t1\n#define SING\t\t2\n#define OVERFLOW\t3\n#define UNDERFLOW\t4\n#define TLOSS\t\t5\n#define PLOSS\t\t6\n\n/* SVID mode specifies returning this large value instead of infinity.  */\n#define HUGE\t\t3.40282347e+38F\n\n#else\t\t\t\t/* !Misc.  */\n\n#ifdef __USE_XOPEN\n/* X/Open wants another strange constant.  */\n#define MAXFLOAT\t3.40282347e+38F\n#endif\n\n#endif\t\t\t\t/* Misc.  */\n\n/* Some useful constants.  */\n#if defined __USE_MISC || defined __USE_XOPEN\n#define M_E\t\t2.7182818284590452354\t/* e */\n#define M_LOG2E\t1.4426950408889634074\t/* log_2 e */\n#define M_LOG10E\t0.43429448190325182765\t/* log_10 e */\n#define M_LN2\t\t0.69314718055994530942\t/* log_e 2 */\n#define M_LN10\t\t2.30258509299404568402\t/* log_e 10 */\n#define M_PI\t\t3.14159265358979323846\t/* pi */\n#define M_PI_2\t\t1.57079632679489661923\t/* pi/2 */\n#define M_PI_4\t\t0.78539816339744830962\t/* pi/4 */\n#define M_1_PI\t\t0.31830988618379067154\t/* 1/pi */\n#define M_2_PI\t\t0.63661977236758134308\t/* 2/pi */\n#define M_2_SQRTPI\t1.12837916709551257390\t/* 2/sqrt(pi) */\n#define M_SQRT2\t1.41421356237309504880\t/* sqrt(2) */\n#define M_SQRT1_2\t0.70710678118654752440\t/* 1/sqrt(2) */\n#endif\n\n/* The above constants are not adequate for computation using `long double's.\n   Therefore we provide as an extension constants with similar names as a\n   GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */\n#ifdef __USE_GNU\n#define M_El\t\t2.718281828459045235360287471352662498L\t/* e */\n#define M_LOG2El\t1.442695040888963407359924681001892137L\t/* log_2 e */\n#define M_LOG10El\t0.434294481903251827651128918916605082L\t/* log_10 e */\n#define M_LN2l\t\t0.693147180559945309417232121458176568L\t/* log_e 2 */\n#define M_LN10l\t2.302585092994045684017991454684364208L\t/* log_e 10 */\n#define M_PIl\t\t3.141592653589793238462643383279502884L\t/* pi */\n#define M_PI_2l\t1.570796326794896619231321691639751442L\t/* pi/2 */\n#define M_PI_4l\t0.785398163397448309615660845819875721L\t/* pi/4 */\n#define M_1_PIl\t0.318309886183790671537767526745028724L\t/* 1/pi */\n#define M_2_PIl\t0.636619772367581343075535053490057448L\t/* 2/pi */\n#define M_2_SQRTPIl\t1.128379167095512573896158903121545172L\t/* 2/sqrt(pi) */\n#define M_SQRT2l\t1.414213562373095048801688724209698079L\t/* sqrt(2) */\n#define M_SQRT1_2l\t0.707106781186547524400844362104849039L\t/* 1/sqrt(2) */\n#endif\n\n/* When compiling in strict ISO C compatible mode we must not use the\n   inline functions since they, among other things, do not set the\n   `errno' variable correctly.  */\n#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES\n#define __NO_MATH_INLINES\t1\n#endif\n\n#if defined __USE_ISOC99 && __GNUC_PREREQ(2,97)\n/* ISO C99 defines some macros to compare number while taking care for\n   unordered numbers.  Many FPUs provide special instructions to support\n   these operations.  Generic support in GCC for these as builtins went\n   in before 3.0.0, but not all cpus added their patterns.  We define\n   versions that use the builtins here, and <bits/mathinline.h> will\n   undef/redefine as appropriate for the specific GCC version in use.  */\n#define isgreater(x, y)\t__builtin_isgreater(x, y)\n#define isgreaterequal(x, y)\t__builtin_isgreaterequal(x, y)\n#define isless(x, y)\t\t__builtin_isless(x, y)\n#define islessequal(x, y)\t__builtin_islessequal(x, y)\n#define islessgreater(x, y)\t__builtin_islessgreater(x, y)\n#define isunordered(u, v)\t__builtin_isunordered(u, v)\n#endif\n\n/* Get machine-dependent inline versions (if there are any).  */\n#ifdef __USE_EXTERN_INLINES\n#include <bits/mathinline.h>\n#endif\n\n/* Define special entry points to use when the compiler got told to\n   only expect finite results.  */\n#if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0\n#include <bits/math-finite.h>\n#endif\n\n#ifdef __USE_ISOC99\n/* If we've still got undefined comparison macros, provide defaults.  */\n\n/* Return nonzero value if X is greater than Y.  */\n#ifndef isgreater\n#define isgreater(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x > __y; }))\n#endif\n\n/* Return nonzero value if X is greater than or equal to Y.  */\n#ifndef isgreaterequal\n#define isgreaterequal(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x >= __y; }))\n#endif\n\n/* Return nonzero value if X is less than Y.  */\n#ifndef isless\n#define isless(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x < __y; }))\n#endif\n\n/* Return nonzero value if X is less than or equal to Y.  */\n#ifndef islessequal\n#define islessequal(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && __x <= __y; }))\n#endif\n\n/* Return nonzero value if either X is less than Y or Y is less than X.  */\n#ifndef islessgreater\n#define islessgreater(x, y) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);\t\t\t      \\\n      !isunordered (__x, __y) && (__x < __y || __y < __x); }))\n#endif\n\n/* Return nonzero value if arguments are unordered.  */\n#ifndef isunordered\n#define isunordered(u, v) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v);\t\t\t      \\\n      fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))\n#endif\n\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* math.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/memory.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n * SVID\n */\n\n#ifndef\t_MEMORY_H\n#define\t_MEMORY_H\t1\n\n#include <features.h>\n\n#ifndef\t_STRING_H\n#include <string.h>\n#endif\t\t\t\t/* string.h  */\n\n#endif\t\t\t\t/* memory.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/netdb.h",
    "content": "  /* Copyright (C) 1996-2016 Free Software Foundation, Inc.\n     This file is part of the GNU C Library.\n\n     The GNU C Library is free software; you can redistribute it and/or\n     modify it under the terms of the GNU Lesser General Public\n     License as published by the Free Software Foundation; either\n     version 2.1 of the License, or (at your option) any later version.\n\n     The GNU C Library is distributed in the hope that it will be useful,\n     but WITHOUT ANY WARRANTY; without even the implied warranty of\n     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n     Lesser General Public License for more details.\n\n     You should have received a copy of the GNU Lesser General Public\n     License along with the GNU C Library; if not, see\n     <http://www.gnu.org/licenses/>.  */\n\n/* All data returned by the network data base library are supplied in\n   host order and returned in network order (suitable for use in\n   system calls).  */\n\n#ifndef\t_NETDB_H\n#define\t_NETDB_H\t1\n\n#include <features.h>\n\n#include <netinet/in.h>\n#include <stdint.h>\n#ifdef __USE_MISC\n/* This is necessary to make this include file properly replace the\n   Sun version.  */\n#include <rpc/netdb.h>\n#endif\n\n#ifdef __USE_GNU\n#define __need_sigevent_t\n#include <bits/siginfo.h>\n#define __need_timespec\n#include <time.h>\n#endif\n\n#include <bits/netdb.h>\n\n/* Absolute file name for network data base files.  */\n#define\t_PATH_HEQUIV\t\t\"/etc/hosts.equiv\"\n#define\t_PATH_HOSTS\t\t\"/etc/hosts\"\n#define\t_PATH_NETWORKS\t\t\"/etc/networks\"\n#define\t_PATH_NSSWITCH_CONF\t\"/etc/nsswitch.conf\"\n#define\t_PATH_PROTOCOLS\t\t\"/etc/protocols\"\n#define\t_PATH_SERVICES\t\t\"/etc/services\"\n\n__BEGIN_DECLS\n#if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Error status for non-reentrant lookup functions.\n   We use a macro to access always the thread-specific `h_errno' variable.  */\n#define h_errno (*__h_errno_location ())\n/* Function to get address of global `h_errno' variable.  */\nextern int *__h_errno_location(void)\n__THROW __attribute__ ((__const__));\n\n/* Possible values left in `h_errno'.  */\n#define HOST_NOT_FOUND\t1\t/* Authoritative Answer Host not found.  */\n#define TRY_AGAIN\t2\t/* Non-Authoritative Host not found,\n\t\t\t\t   or SERVERFAIL.  */\n#define NO_RECOVERY\t3\t/* Non recoverable errors, FORMERR, REFUSED,\n\t\t\t\t   NOTIMP.  */\n#define NO_DATA\t4\t\t/* Valid name, no data record of requested\n\t\t\t\t   type.  */\n#endif\n#ifdef __USE_MISC\n#define NETDB_INTERNAL\t-1\t/* See errno.  */\n#define NETDB_SUCCESS\t0\t/* No problem.  */\n#define NO_ADDRESS\tNO_DATA\t/* No address, look for MX record.  */\n#endif\n\n#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED\n/* Highest reserved Internet port number.  */\n#define IPPORT_RESERVED\t1024\n#endif\n\n#ifdef __USE_GNU\n/* Scope delimiter for getaddrinfo(), getnameinfo().  */\n#define SCOPE_DELIMITER\t'%'\n#endif\n\n#ifdef __USE_MISC\n/* Print error indicated by `h_errno' variable on standard error.  STR\n   if non-null is printed before the error string.  */\nextern void herror(const char *__str) __THROW;\n\n/* Return string associated with error ERR_NUM.  */\nextern const char *hstrerror(int __err_num) __THROW;\n#endif\n\n/* Description of data base entry for a single host.  */\nstruct hostent {\n\tchar *h_name;\t\t/* Official name of host.  */\n\tchar **h_aliases;\t/* Alias list.  */\n\tint h_addrtype;\t\t/* Host address type.  */\n\tint h_length;\t\t/* Length of address.  */\n\tchar **h_addr_list;\t/* List of addresses from name server.  */\n#ifdef __USE_MISC\n#define\th_addr\th_addr_list[0]\t/* Address, for backward compatibility. */\n#endif\n};\n\n/* Open host data base files and mark them as staying open even after\n   a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void sethostent(int __stay_open);\n\n/* Close host data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endhostent(void);\n\n/* Get next entry from host data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostent(void);\n\n/* Return entry from host data base which address match ADDR with\n   length LEN and type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyaddr(const void *__addr, __socklen_t __len, int __type);\n\n/* Return entry from host data base for host with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct hostent *gethostbyname(const char *__name);\n\n#ifdef __USE_MISC\n/* Return entry from host data base for host with NAME.  AF must be\n   set to the address type which is `AF_INET' for IPv4 or `AF_INET6'\n   for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct hostent *gethostbyname2(const char *__name, int __af);\n\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int gethostent_r(struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyaddr_r(const void *__restrict __addr, __socklen_t __len, int __type, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname_r(const char *__restrict __name, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n\nextern int gethostbyname2_r(const char *__restrict __name, int __af, struct hostent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct hostent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Open network data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setnetent(int __stay_open);\n\n/* Close network data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endnetent(void);\n\n/* Get next entry from network data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetent(void);\n\n/* Return entry from network data base which address match NET and\n   type TYPE.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyaddr(uint32_t __net, int __type);\n\n/* Return entry from network data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct netent *getnetbyname(const char *__name);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.  The last\n   argument is a pointer to a variable which gets the value which\n   would be stored in the global variable `herrno' by the\n   non-reentrant functions.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getnetent_r(struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyaddr_r(uint32_t __net, int __type, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n\nextern int getnetbyname_r(const char *__restrict __name, struct netent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct netent **__restrict __result, int *__restrict __h_errnop);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct servent {\n\tchar *s_name;\t\t/* Official service name.  */\n\tchar **s_aliases;\t/* Alias list.  */\n\tint s_port;\t\t/* Port number.  */\n\tchar *s_proto;\t\t/* Protocol to use.  */\n};\n\n/* Open service data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setservent(int __stay_open);\n\n/* Close service data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endservent(void);\n\n/* Get next entry from service data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservent(void);\n\n/* Return entry from network data base for network with NAME and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyname(const char *__name, const char *__proto);\n\n/* Return entry from service data base which matches port PORT and\n   protocol PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct servent *getservbyport(int __port, const char *__proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getservent_r(struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyname_r(const char *__restrict __name, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n\nextern int getservbyport_r(int __port, const char *__restrict __proto, struct servent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct servent **__restrict __result);\n#endif\t\t\t\t/* misc */\n\n/* Description of data base entry for a single service.  */\nstruct protoent {\n\tchar *p_name;\t\t/* Official protocol name.  */\n\tchar **p_aliases;\t/* Alias list.  */\n\tint p_proto;\t\t/* Protocol number.  */\n};\n\n/* Open protocol data base files and mark them as staying open even\n   after a later search if STAY_OPEN is non-zero.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setprotoent(int __stay_open);\n\n/* Close protocol data base files and clear `stay open' flag.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endprotoent(void);\n\n/* Get next entry from protocol data base file.  Open data base if\n   necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotoent(void);\n\n/* Return entry from protocol data base for network with NAME.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobyname(const char *__name);\n\n/* Return entry from protocol data base which number is PROTO.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct protoent *getprotobynumber(int __proto);\n\n#ifdef\t__USE_MISC\n/* Reentrant versions of the functions above.  The additional\n   arguments specify a buffer of BUFLEN starting at BUF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern int getprotoent_r(struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobyname_r(const char *__restrict __name, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\nextern int getprotobynumber_r(int __proto, struct protoent *__restrict __result_buf, char *__restrict __buf, size_t __buflen, struct protoent **__restrict __result);\n\n/* Establish network group NETGROUP for enumeration.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int setnetgrent(const char *__netgroup);\n\n/* Free all space allocated by previous `setnetgrent' call.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern void endnetgrent(void);\n\n/* Get next member of netgroup established by last `setnetgrent' call\n   and return pointers to elements in HOSTP, USERP, and DOMAINP.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp);\n\n/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int innetgr(const char *__netgroup, const char *__host, const char *__user, const char *__domain);\n\n/* Reentrant version of `getnetgrent' where result is placed in BUFFER.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getnetgrent_r(char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp, char *__restrict __buffer, size_t __buflen);\n#endif\t\t\t\t/* misc */\n\n#ifdef __USE_MISC\n/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.\n   The local user is LOCUSER, on the remote machine the command is\n   executed as REMUSER.  In *FD2P the descriptor to the socket for the\n   connection is returned.  The caller must have the right to use a\n   reserved port.  When the function returns *AHOST contains the\n   official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rcmd_af(char **__restrict __ahost, unsigned short int __rport, const char *__restrict __locuser, const char *__restrict __remuser, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Call `rexecd' at port RPORT on remote machine *AHOST to execute\n   CMD.  The process runs at the remote machine using the ID of user\n   NAME whose cleartext password is PASSWD.  In *FD2P the descriptor\n   to the socket for the connection is returned.  When the function\n   returns *AHOST contains the official host name.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rexec_af(char **__restrict __ahost, int __rport, const char *__restrict __name, const char *__restrict __pass, const char *__restrict __cmd, int *__restrict __fd2p, sa_family_t __af);\n\n/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.\n   If SUSER is not zero the user tries to become superuser.  Return 0 if\n   it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok(const char *__rhost, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int ruserok_af(const char *__rhost, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Check whether user REMUSER on system indicated by IPv4 address\n   RADDR is allowed to login as LOCUSER.  Non-IPv4 (e.g., IPv6) are\n   not supported.  If SUSER is not zero the user tries to become\n   superuser.  Return 0 if it is possible.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok(uint32_t __raddr, int __suser, const char *__remuser, const char *__locuser);\n\n/* This is the equivalent function where the pfamiliy if the address\n   pointed to by RADDR is determined by the value of AF.  It therefore\n   can be used for IPv6\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int iruserok_af(const void *__raddr, int __suser, const char *__remuser, const char *__locuser, sa_family_t __af);\n\n/* Try to allocate reserved port, returning a descriptor for a socket opened\n   at this port or -1 if unsuccessful.  The search for an available port\n   will start at ALPORT and continues with lower numbers.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport(int *__alport);\n\n/* This is the equivalent function where the protocol can be selected\n   and which therefore can be used for IPv6.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int rresvport_af(int *__alport, sa_family_t __af);\n#endif\n\n/* Extension from POSIX.1:2001.  */\n#ifdef __USE_XOPEN2K\n/* Structure to contain information about address of a service provider.  */\nstruct addrinfo {\n\tint ai_flags;\t\t/* Input flags.  */\n\tint ai_family;\t\t/* Protocol family for socket.  */\n\tint ai_socktype;\t/* Socket type.  */\n\tint ai_protocol;\t/* Protocol for socket.  */\n\tsocklen_t ai_addrlen;\t/* Length of socket address.  */\n\tstruct sockaddr *ai_addr;\t/* Socket address for socket.  */\n\tchar *ai_canonname;\t/* Canonical name for service location.  */\n\tstruct addrinfo *ai_next;\t/* Pointer to next in list.  */\n};\n\n#ifdef __USE_GNU\n/* Structure used as control block for asynchronous lookup.  */\nstruct gaicb {\n\tconst char *ar_name;\t/* Name to look up.  */\n\tconst char *ar_service;\t/* Service name.  */\n\tconst struct addrinfo *ar_request;\t/* Additional request specification.  */\n\tstruct addrinfo *ar_result;\t/* Pointer to result.  */\n\t/* The following are internal elements.  */\n\tint __return;\n\tint __glibc_reserved[5];\n};\n\n/* Lookup mode.  */\n#define GAI_WAIT\t0\n#define GAI_NOWAIT\t1\n#endif\n\n/* Possible values for `ai_flags' field in `addrinfo' structure.  */\n#define AI_PASSIVE\t0x0001\t/* Socket address is intended for `bind'.  */\n#define AI_CANONNAME\t0x0002\t/* Request for canonical name.  */\n#define AI_NUMERICHOST\t0x0004\t/* Don't use name resolution.  */\n#define AI_V4MAPPED\t0x0008\t/* IPv4 mapped addresses are acceptable.  */\n#define AI_ALL\t\t0x0010\t/* Return IPv4 mapped and IPv6 addresses.  */\n#define AI_ADDRCONFIG\t0x0020\t/* Use configuration of this host to choose\n\t\t\t\t   returned address type..  */\n#ifdef __USE_GNU\n#define AI_IDN\t0x0040\t\t/* IDN encode input (assuming it is encoded\n\t\t\t\t   in the current locale's character set)\n\t\t\t\t   before looking it up. */\n#define AI_CANONIDN\t0x0080\t/* Translate canonical name from IDN format. */\n#define AI_IDN_ALLOW_UNASSIGNED 0x0100\t/* Don't reject unassigned Unicode\n\t\t\t\t\t   code points.  */\n#define AI_IDN_USE_STD3_ASCII_RULES 0x0200\t/* Validate strings according to\n\t\t\t\t\t\t   STD3 rules.  */\n#endif\n#define AI_NUMERICSERV\t0x0400\t/* Don't use name resolution.  */\n\n/* Error values for `getaddrinfo' function.  */\n#define EAI_BADFLAGS\t  -1\t/* Invalid value for `ai_flags' field.  */\n#define EAI_NONAME\t  -2\t/* NAME or SERVICE is unknown.  */\n#define EAI_AGAIN\t  -3\t/* Temporary failure in name resolution.  */\n#define EAI_FAIL\t  -4\t/* Non-recoverable failure in name res.  */\n#define EAI_FAMILY\t  -6\t/* `ai_family' not supported.  */\n#define EAI_SOCKTYPE\t  -7\t/* `ai_socktype' not supported.  */\n#define EAI_SERVICE\t  -8\t/* SERVICE not supported for `ai_socktype'.  */\n#define EAI_MEMORY\t  -10\t/* Memory allocation failure.  */\n#define EAI_SYSTEM\t  -11\t/* System error returned in `errno'.  */\n#define EAI_OVERFLOW\t  -12\t/* Argument buffer overflow.  */\n#ifdef __USE_GNU\n#define EAI_NODATA\t  -5\t/* No address associated with NAME.  */\n#define EAI_ADDRFAMILY  -9\t/* Address family for NAME not supported.  */\n#define EAI_INPROGRESS  -100\t/* Processing request in progress.  */\n#define EAI_CANCELED\t  -101\t/* Request canceled.  */\n#define EAI_NOTCANCELED -102\t/* Request not canceled.  */\n#define EAI_ALLDONE\t  -103\t/* All requests done.  */\n#define EAI_INTR\t  -104\t/* Interrupted by a signal.  */\n#define EAI_IDN_ENCODE  -105\t/* IDN encoding failed.  */\n#endif\n\n#ifdef __USE_MISC\n#define NI_MAXHOST      1025\n#define NI_MAXSERV      32\n#endif\n\n#define NI_NUMERICHOST\t1\t/* Don't try to look up hostname.  */\n#define NI_NUMERICSERV 2\t/* Don't convert port number to name.  */\n#define NI_NOFQDN\t4\t/* Only return nodename portion.  */\n#define NI_NAMEREQD\t8\t/* Don't return numeric addresses.  */\n#define NI_DGRAM\t16\t/* Look up UDP service rather than TCP.  */\n#ifdef __USE_GNU\n#define NI_IDN\t32\t\t/* Convert name from IDN format.  */\n#define NI_IDN_ALLOW_UNASSIGNED 64\t/* Don't reject unassigned Unicode\n\t\t\t\t\t   code points.  */\n#define NI_IDN_USE_STD3_ASCII_RULES 128\t/* Validate strings according to\n\t\t\t\t\t   STD3 rules.  */\n#endif\n\n/* Translate name of a service location and/or a service name to set of\n   socket addresses.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getaddrinfo(const char *__restrict __name, const char *__restrict __service, const struct addrinfo *__restrict __req, struct addrinfo **__restrict __pai);\n\n/* Free `addrinfo' structure AI including associated storage.  */\nextern void freeaddrinfo(struct addrinfo *__ai) __THROW;\n\n/* Convert error return from getaddrinfo() to a string.  */\nextern const char *gai_strerror(int __ecode) __THROW;\n\n/* Translate a socket address to a location and service name.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getnameinfo(const struct sockaddr *__restrict __sa, socklen_t __salen, char *__restrict __host, socklen_t __hostlen, char *__restrict __serv, socklen_t __servlen, int __flags);\n#endif\t\t\t\t/* POSIX */\n\n#ifdef __USE_GNU\n/* Enqueue ENT requests from the LIST.  If MODE is GAI_WAIT wait until all\n   requests are handled.  If WAIT is GAI_NOWAIT return immediately after\n   queueing the requests and signal completion according to SIG.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getaddrinfo_a(int __mode, struct gaicb *__list[__restrict_arr], int __ent, struct sigevent *__restrict __sig);\n\n/* Suspend execution of the thread until at least one of the ENT requests\n   in LIST is handled.  If TIMEOUT is not a null pointer it specifies the\n   longest time the function keeps waiting before returning with an error.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int gai_suspend(const struct gaicb *const __list[], int __ent, const struct timespec *__timeout);\n\n/* Get the error status of the request REQ.  */\nextern int gai_error(struct gaicb *__req) __THROW;\n\n/* Cancel the requests associated with GAICBP.  */\nextern int gai_cancel(struct gaicb *__gaicbp) __THROW;\n#endif\t\t\t\t/* GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/netinet/in.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_NETINET_IN_H\n#define\t_NETINET_IN_H\t1\n\n#include <features.h>\n#include <stdint.h>\n#include <sys/socket.h>\n#include <bits/types.h>\n\n__BEGIN_DECLS\n/* Internet address.  */\ntypedef uint32_t in_addr_t;\nstruct in_addr {\n\tin_addr_t s_addr;\n};\n\n/* Get system-specific definitions.  */\n#include <bits/in.h>\n\n/* Standard well-defined IP protocols.  */\nenum {\n\tIPPROTO_IP = 0,\t\t/* Dummy protocol for TCP.  */\n#define IPPROTO_IP\t\tIPPROTO_IP\n\tIPPROTO_ICMP = 1,\t/* Internet Control Message Protocol.  */\n#define IPPROTO_ICMP\t\tIPPROTO_ICMP\n\tIPPROTO_IGMP = 2,\t/* Internet Group Management Protocol. */\n#define IPPROTO_IGMP\t\tIPPROTO_IGMP\n\tIPPROTO_IPIP = 4,\t/* IPIP tunnels (older KA9Q tunnels use 94).  */\n#define IPPROTO_IPIP\t\tIPPROTO_IPIP\n\tIPPROTO_TCP = 6,\t/* Transmission Control Protocol.  */\n#define IPPROTO_TCP\t\tIPPROTO_TCP\n\tIPPROTO_EGP = 8,\t/* Exterior Gateway Protocol.  */\n#define IPPROTO_EGP\t\tIPPROTO_EGP\n\tIPPROTO_PUP = 12,\t/* PUP protocol.  */\n#define IPPROTO_PUP\t\tIPPROTO_PUP\n\tIPPROTO_UDP = 17,\t/* User Datagram Protocol.  */\n#define IPPROTO_UDP\t\tIPPROTO_UDP\n\tIPPROTO_IDP = 22,\t/* XNS IDP protocol.  */\n#define IPPROTO_IDP\t\tIPPROTO_IDP\n\tIPPROTO_TP = 29,\t/* SO Transport Protocol Class 4.  */\n#define IPPROTO_TP\t\tIPPROTO_TP\n\tIPPROTO_DCCP = 33,\t/* Datagram Congestion Control Protocol.  */\n#define IPPROTO_DCCP\t\tIPPROTO_DCCP\n\tIPPROTO_IPV6 = 41,\t/* IPv6 header.  */\n#define IPPROTO_IPV6\t\tIPPROTO_IPV6\n\tIPPROTO_RSVP = 46,\t/* Reservation Protocol.  */\n#define IPPROTO_RSVP\t\tIPPROTO_RSVP\n\tIPPROTO_GRE = 47,\t/* General Routing Encapsulation.  */\n#define IPPROTO_GRE\t\tIPPROTO_GRE\n\tIPPROTO_ESP = 50,\t/* encapsulating security payload.  */\n#define IPPROTO_ESP\t\tIPPROTO_ESP\n\tIPPROTO_AH = 51,\t/* authentication header.  */\n#define IPPROTO_AH\t\tIPPROTO_AH\n\tIPPROTO_MTP = 92,\t/* Multicast Transport Protocol.  */\n#define IPPROTO_MTP\t\tIPPROTO_MTP\n\tIPPROTO_BEETPH = 94,\t/* IP option pseudo header for BEET.  */\n#define IPPROTO_BEETPH\t\tIPPROTO_BEETPH\n\tIPPROTO_ENCAP = 98,\t/* Encapsulation Header.  */\n#define IPPROTO_ENCAP\t\tIPPROTO_ENCAP\n\tIPPROTO_PIM = 103,\t/* Protocol Independent Multicast.  */\n#define IPPROTO_PIM\t\tIPPROTO_PIM\n\tIPPROTO_COMP = 108,\t/* Compression Header Protocol.  */\n#define IPPROTO_COMP\t\tIPPROTO_COMP\n\tIPPROTO_SCTP = 132,\t/* Stream Control Transmission Protocol.  */\n#define IPPROTO_SCTP\t\tIPPROTO_SCTP\n\tIPPROTO_UDPLITE = 136,\t/* UDP-Lite protocol.  */\n#define IPPROTO_UDPLITE\t\tIPPROTO_UDPLITE\n\tIPPROTO_MPLS = 137,\t/* MPLS in IP.  */\n#define IPPROTO_MPLS\t\tIPPROTO_MPLS\n\tIPPROTO_RAW = 255,\t/* Raw IP packets.  */\n#define IPPROTO_RAW\t\tIPPROTO_RAW\n\tIPPROTO_MAX\n};\n\n/* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel\n   network headers first and we should use those ABI-identical definitions\n   instead of our own, otherwise 0.  */\n#if !__USE_KERNEL_IPV6_DEFS\nenum {\n\tIPPROTO_HOPOPTS = 0,\t/* IPv6 Hop-by-Hop options.  */\n#define IPPROTO_HOPOPTS\t\tIPPROTO_HOPOPTS\n\tIPPROTO_ROUTING = 43,\t/* IPv6 routing header.  */\n#define IPPROTO_ROUTING\t\tIPPROTO_ROUTING\n\tIPPROTO_FRAGMENT = 44,\t/* IPv6 fragmentation header.  */\n#define IPPROTO_FRAGMENT\tIPPROTO_FRAGMENT\n\tIPPROTO_ICMPV6 = 58,\t/* ICMPv6.  */\n#define IPPROTO_ICMPV6\t\tIPPROTO_ICMPV6\n\tIPPROTO_NONE = 59,\t/* IPv6 no next header.  */\n#define IPPROTO_NONE\t\tIPPROTO_NONE\n\tIPPROTO_DSTOPTS = 60,\t/* IPv6 destination options.  */\n#define IPPROTO_DSTOPTS\t\tIPPROTO_DSTOPTS\n\tIPPROTO_MH = 135\t/* IPv6 mobility header.  */\n#define IPPROTO_MH\t\tIPPROTO_MH\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Type to represent a port.  */\ntypedef uint16_t in_port_t;\n\n/* Standard well-known ports.  */\nenum {\n\tIPPORT_ECHO = 7,\t/* Echo service.  */\n\tIPPORT_DISCARD = 9,\t/* Discard transmissions service.  */\n\tIPPORT_SYSTAT = 11,\t/* System status service.  */\n\tIPPORT_DAYTIME = 13,\t/* Time of day service.  */\n\tIPPORT_NETSTAT = 15,\t/* Network status service.  */\n\tIPPORT_FTP = 21,\t/* File Transfer Protocol.  */\n\tIPPORT_TELNET = 23,\t/* Telnet protocol.  */\n\tIPPORT_SMTP = 25,\t/* Simple Mail Transfer Protocol.  */\n\tIPPORT_TIMESERVER = 37,\t/* Timeserver service.  */\n\tIPPORT_NAMESERVER = 42,\t/* Domain Name Service.  */\n\tIPPORT_WHOIS = 43,\t/* Internet Whois service.  */\n\tIPPORT_MTP = 57,\n\n\tIPPORT_TFTP = 69,\t/* Trivial File Transfer Protocol.  */\n\tIPPORT_RJE = 77,\n\tIPPORT_FINGER = 79,\t/* Finger service.  */\n\tIPPORT_TTYLINK = 87,\n\tIPPORT_SUPDUP = 95,\t/* SUPDUP protocol.  */\n\n\tIPPORT_EXECSERVER = 512,\t/* execd service.  */\n\tIPPORT_LOGINSERVER = 513,\t/* rlogind service.  */\n\tIPPORT_CMDSERVER = 514,\n\tIPPORT_EFSSERVER = 520,\n\n\t/* UDP ports.  */\n\tIPPORT_BIFFUDP = 512,\n\tIPPORT_WHOSERVER = 513,\n\tIPPORT_ROUTESERVER = 520,\n\n\t/* Ports less than this value are reserved for privileged processes.  */\n\tIPPORT_RESERVED = 1024,\n\n\t/* Ports greater this value are reserved for (non-privileged) servers.  */\n\tIPPORT_USERRESERVED = 5000\n};\n\n/* Definitions of the bits in an Internet address integer.\n\n   On subnets, host and network parts are found according to\n   the subnet mask, not these masks.  */\n\n#define\tIN_CLASSA(a)\t\t((((in_addr_t)(a)) & 0x80000000) == 0)\n#define\tIN_CLASSA_NET\t\t0xff000000\n#define\tIN_CLASSA_NSHIFT\t24\n#define\tIN_CLASSA_HOST\t\t(0xffffffff & ~IN_CLASSA_NET)\n#define\tIN_CLASSA_MAX\t\t128\n\n#define\tIN_CLASSB(a)\t\t((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)\n#define\tIN_CLASSB_NET\t\t0xffff0000\n#define\tIN_CLASSB_NSHIFT\t16\n#define\tIN_CLASSB_HOST\t\t(0xffffffff & ~IN_CLASSB_NET)\n#define\tIN_CLASSB_MAX\t\t65536\n\n#define\tIN_CLASSC(a)\t\t((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)\n#define\tIN_CLASSC_NET\t\t0xffffff00\n#define\tIN_CLASSC_NSHIFT\t8\n#define\tIN_CLASSC_HOST\t\t(0xffffffff & ~IN_CLASSC_NET)\n\n#define\tIN_CLASSD(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)\n#define\tIN_MULTICAST(a)\t\tIN_CLASSD(a)\n\n#define\tIN_EXPERIMENTAL(a)\t((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)\n#define\tIN_BADCLASS(a)\t\t((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)\n\n/* Address to accept any incoming messages.  */\n#define\tINADDR_ANY\t\t((in_addr_t) 0x00000000)\n/* Address to send to all hosts.  */\n#define\tINADDR_BROADCAST\t((in_addr_t) 0xffffffff)\n/* Address indicating an error return.  */\n#define\tINADDR_NONE\t\t((in_addr_t) 0xffffffff)\n\n/* Network number for local host loopback.  */\n#define\tIN_LOOPBACKNET\t\t127\n/* Address to loopback in software to local host.  */\n#ifndef INADDR_LOOPBACK\n#define INADDR_LOOPBACK\t((in_addr_t) 0x7f000001)\t/* Inet 127.0.0.1.  */\n#endif\n\n/* Defines for Multicast INADDR.  */\n#define INADDR_UNSPEC_GROUP\t((in_addr_t) 0xe0000000)\t/* 224.0.0.0 */\n#define INADDR_ALLHOSTS_GROUP\t((in_addr_t) 0xe0000001)\t/* 224.0.0.1 */\n#define INADDR_ALLRTRS_GROUP    ((in_addr_t) 0xe0000002)\t/* 224.0.0.2 */\n#define INADDR_MAX_LOCAL_GROUP  ((in_addr_t) 0xe00000ff)\t/* 224.0.0.255 */\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* IPv6 address */\nstruct in6_addr {\n\tunion {\n\t\tuint8_t __u6_addr8[16];\n#ifdef __USE_MISC\n\t\tuint16_t __u6_addr16[8];\n\t\tuint32_t __u6_addr32[4];\n#endif\n\t} __in6_u;\n#define s6_addr\t\t\t__in6_u.__u6_addr8\n#ifdef __USE_MISC\n#define s6_addr16\t\t__in6_u.__u6_addr16\n#define s6_addr32\t\t__in6_u.__u6_addr32\n#endif\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\nextern const struct in6_addr in6addr_any;\t/* :: */\nextern const struct in6_addr in6addr_loopback;\t/* ::1 */\n#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }\n#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }\n\n#define INET_ADDRSTRLEN 16\n#define INET6_ADDRSTRLEN 46\n\n/* Structure describing an Internet socket address.  */\nstruct sockaddr_in {\n\t__SOCKADDR_COMMON(sin_);\n\tin_port_t sin_port;\t/* Port number.  */\n\tstruct in_addr sin_addr;\t/* Internet address.  */\n\n\t/* Pad to size of `struct sockaddr'.  */\n\tunsigned char sin_zero[sizeof(struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof(in_port_t) - sizeof(struct in_addr)];\n};\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* Ditto, for IPv6.  */\nstruct sockaddr_in6 {\n\t__SOCKADDR_COMMON(sin6_);\n\tin_port_t sin6_port;\t/* Transport layer port # */\n\tuint32_t sin6_flowinfo;\t/* IPv6 flow information */\n\tstruct in6_addr sin6_addr;\t/* IPv6 address */\n\tuint32_t sin6_scope_id;\t/* IPv6 scope-id */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* IPv4 multicast request.  */\nstruct ip_mreq {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imr_interface;\n};\n\nstruct ip_mreq_source {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imr_multiaddr;\n\n\t/* IP address of source.  */\n\tstruct in_addr imr_interface;\n\n\t/* IP address of interface.  */\n\tstruct in_addr imr_sourceaddr;\n};\n#endif\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* Likewise, for IPv6.  */\nstruct ipv6_mreq {\n\t/* IPv6 multicast address of group */\n\tstruct in6_addr ipv6mr_multiaddr;\n\n\t/* local interface */\n\tunsigned int ipv6mr_interface;\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n#ifdef __USE_MISC\n/* Multicast group request.  */\nstruct group_req {\n\t/* Interface index.  */\n\tuint32_t gr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gr_group;\n};\n\nstruct group_source_req {\n\t/* Interface index.  */\n\tuint32_t gsr_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gsr_group;\n\n\t/* Source address.  */\n\tstruct sockaddr_storage gsr_source;\n};\n\n/* Full-state filter operations.  */\nstruct ip_msfilter {\n\t/* IP multicast address of group.  */\n\tstruct in_addr imsf_multiaddr;\n\n\t/* Local IP address of interface.  */\n\tstruct in_addr imsf_interface;\n\n\t/* Filter mode.  */\n\tuint32_t imsf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t imsf_numsrc;\n\t/* Source addresses.  */\n\tstruct in_addr imsf_slist[1];\n};\n\n#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \\\n\t\t\t\t  - sizeof (struct in_addr)\t\t      \\\n\t\t\t\t  + (numsrc) * sizeof (struct in_addr))\n\nstruct group_filter {\n\t/* Interface index.  */\n\tuint32_t gf_interface;\n\n\t/* Group address.  */\n\tstruct sockaddr_storage gf_group;\n\n\t/* Filter mode.  */\n\tuint32_t gf_fmode;\n\n\t/* Number of source addresses.  */\n\tuint32_t gf_numsrc;\n\t/* Source addresses.  */\n\tstruct sockaddr_storage gf_slist[1];\n};\n\n#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \\\n\t\t\t\t   - sizeof (struct sockaddr_storage)\t      \\\n\t\t\t\t   + ((numsrc)\t\t\t\t      \\\n\t\t\t\t      * sizeof (struct sockaddr_storage)))\n#endif\n\n/* Functions to convert between host and network byte order.\n\n   Please note that these functions normally take `unsigned long int' or\n   `unsigned short int' values as arguments and also return them.  But\n   this was a short-sighted decision since on different systems the types\n   may have different representations but the values are always the same.  */\n\nextern uint32_t ntohl(uint32_t __netlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t ntohs(uint16_t __netshort)\n__THROW __attribute__ ((__const__));\nextern uint32_t htonl(uint32_t __hostlong)\n__THROW __attribute__ ((__const__));\nextern uint16_t htons(uint16_t __hostshort)\n__THROW __attribute__ ((__const__));\n\n#include <endian.h>\n\n/* Get machine dependent optimized versions of byte swapping functions.  */\n#include <bits/byteswap.h>\n\n#ifdef __OPTIMIZE__\n/* We can optimize calls to the conversion functions.  Either nothing has\n   to be done or we are using directly the byte-swapping functions which\n   often can be inlined.  */\n#if __BYTE_ORDER == __BIG_ENDIAN\n/* The host byte order is the same as network byte order,\n   so these functions are all just identity.  */\n#define ntohl(x)\t(x)\n#define ntohs(x)\t(x)\n#define htonl(x)\t(x)\n#define htons(x)\t(x)\n#else\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define ntohl(x)\t__bswap_32 (x)\n#define ntohs(x)\t__bswap_16 (x)\n#define htonl(x)\t__bswap_32 (x)\n#define htons(x)\t__bswap_16 (x)\n#endif\n#endif\n#endif\n\n#ifdef __GNUC__\n#define IN6_IS_ADDR_UNSPECIFIED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[3] == 0; }))\n\n#define IN6_IS_ADDR_LOOPBACK(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[3] == htonl (1); }))\n\n#define IN6_IS_ADDR_LINKLOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); }))\n\n#define IN6_IS_ADDR_SITELOCAL(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      (__a->s6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); }))\n\n#define IN6_IS_ADDR_V4MAPPED(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == htonl (0xffff); }))\n\n#define IN6_IS_ADDR_V4COMPAT(a) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      __a->s6_addr32[0] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[1] == 0\t\t\t\t\t\t      \\\n      && __a->s6_addr32[2] == 0\t\t\t\t\t\t      \\\n      && ntohl (__a->s6_addr32[3]) > 1; }))\n\n#define IN6_ARE_ADDR_EQUAL(a,b) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n   ({ const struct in6_addr *__a = (const struct in6_addr *) (a);\t      \\\n      const struct in6_addr *__b = (const struct in6_addr *) (b);\t      \\\n      __a->s6_addr32[0] == __b->s6_addr32[0]\t\t\t\t      \\\n      && __a->s6_addr32[1] == __b->s6_addr32[1]\t\t\t\t      \\\n      && __a->s6_addr32[2] == __b->s6_addr32[2]\t\t\t\t      \\\n      && __a->s6_addr32[3] == __b->s6_addr32[3]; }))\n#else\n#define IN6_IS_ADDR_UNSPECIFIED(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == 0)\n\n#define IN6_IS_ADDR_LOOPBACK(a) \\\n\t(((const uint32_t *) (a))[0] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[1] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[2] == 0\t\t\t\t      \\\n\t && ((const uint32_t *) (a))[3] == htonl (1))\n\n#define IN6_IS_ADDR_LINKLOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfe800000))\n\n#define IN6_IS_ADDR_SITELOCAL(a) \\\n\t((((const uint32_t *) (a))[0] & htonl (0xffc00000))\t\t      \\\n\t == htonl (0xfec00000))\n\n#define IN6_IS_ADDR_V4MAPPED(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == htonl (0xffff)))\n\n#define IN6_IS_ADDR_V4COMPAT(a) \\\n\t((((const uint32_t *) (a))[0] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[1] == 0)\t\t\t\t      \\\n\t && (((const uint32_t *) (a))[2] == 0)\t\t\t\t      \\\n\t && (ntohl (((const uint32_t *) (a))[3]) > 1))\n\n#define IN6_ARE_ADDR_EQUAL(a,b) \\\n\t((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0])\t      \\\n\t && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1])      \\\n\t && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2])      \\\n\t && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3]))\n#endif\n\n#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)\n\n#ifdef __USE_MISC\n/* Bind socket to a privileged IP port.  */\nextern int bindresvport(int __sockfd, struct sockaddr_in *__sock_in) __THROW;\n\n/* The IPv6 version of this function.  */\nextern int bindresvport6(int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;\n#endif\n\n#define IN6_IS_ADDR_MC_NODELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x1))\n\n#define IN6_IS_ADDR_MC_LINKLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x2))\n\n#define IN6_IS_ADDR_MC_SITELOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x5))\n\n#define IN6_IS_ADDR_MC_ORGLOCAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0x8))\n\n#define IN6_IS_ADDR_MC_GLOBAL(a) \\\n\t(IN6_IS_ADDR_MULTICAST(a)\t\t\t\t\t      \\\n\t && ((((const uint8_t *) (a))[1] & 0xf) == 0xe))\n\n#ifdef __USE_GNU\nstruct cmsghdr;\t\t\t/* Forward declaration.  */\n\n#if !__USE_KERNEL_IPV6_DEFS\n/* IPv6 packet information.  */\nstruct in6_pktinfo {\n\tstruct in6_addr ipi6_addr;\t/* src/dst IPv6 address */\n\tunsigned int ipi6_ifindex;\t/* send/recv interface index */\n};\n\n/* IPv6 MTU information.  */\nstruct ip6_mtuinfo {\n\tstruct sockaddr_in6 ip6m_addr;\t/* dst address including zone ID */\n\tuint32_t ip6m_mtu;\t/* path MTU in host byte order */\n};\n#endif\t\t\t\t/* !__USE_KERNEL_IPV6_DEFS */\n\n/* Obsolete hop-by-hop and Destination Options Processing (RFC 2292).  */\nextern int inet6_option_space(int __nbytes)\n__THROW __attribute_deprecated__;\nextern int inet6_option_init(void *__bp, struct cmsghdr **__cmsgp, int __type)\n__THROW __attribute_deprecated__;\nextern int inet6_option_append(struct cmsghdr *__cmsg, const uint8_t * __typep, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern uint8_t *inet6_option_alloc(struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy)\n__THROW __attribute_deprecated__;\nextern int inet6_option_next(const struct cmsghdr *__cmsg, uint8_t ** __tptrp)\n__THROW __attribute_deprecated__;\nextern int inet6_option_find(const struct cmsghdr *__cmsg, uint8_t ** __tptrp, int __type)\n__THROW __attribute_deprecated__;\n\n/* Hop-by-Hop and Destination Options Processing (RFC 3542).  */\nextern int inet6_opt_init(void *__extbuf, socklen_t __extlen) __THROW;\nextern int inet6_opt_append(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;\nextern int inet6_opt_finish(void *__extbuf, socklen_t __extlen, int __offset) __THROW;\nextern int inet6_opt_set_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\nextern int inet6_opt_next(void *__extbuf, socklen_t __extlen, int __offset, uint8_t * __typep, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_find(void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t * __lenp, void **__databufp) __THROW;\nextern int inet6_opt_get_val(void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW;\n\n/* Routing Header Option (RFC 3542).  */\nextern socklen_t inet6_rth_space(int __type, int __segments) __THROW;\nextern void *inet6_rth_init(void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW;\nextern int inet6_rth_add(void *__bp, const struct in6_addr *__addr) __THROW;\nextern int inet6_rth_reverse(const void *__in, void *__out) __THROW;\nextern int inet6_rth_segments(const void *__bp) __THROW;\nextern struct in6_addr *inet6_rth_getaddr(const void *__bp, int __index) __THROW;\n\n/* Multicast source filter support.  */\n\n/* Get IPv4 source filter.  */\nextern int getipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t * __fmode, uint32_t * __numsrc, struct in_addr *__slist) __THROW;\n\n/* Set IPv4 source filter.  */\nextern int setipv4sourcefilter(int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t __fmode, uint32_t __numsrc, const struct in_addr *__slist) __THROW;\n\n/* Get source filter.  */\nextern int getsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t * __fmode, uint32_t * __numsrc, struct sockaddr_storage *__slist) __THROW;\n\n/* Set source filter.  */\nextern int setsourcefilter(int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t __fmode, uint32_t __numsrc, const struct sockaddr_storage *__slist) __THROW;\n#endif\t\t\t\t/* use GNU */\n\n__END_DECLS\n#endif\t\t\t\t/* netinet/in.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/pthread.h",
    "content": "/* Copyright (C) 2002-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _PTHREAD_H\n#define _PTHREAD_H\t1\n\n#include <features.h>\n#include <endian.h>\n#include <sched.h>\n#include <time.h>\n\n#include <bits/pthreadtypes.h>\n#include <bits/setjmp.h>\n#include <bits/wordsize.h>\n\n/* Detach state.  */\nenum {\n\tPTHREAD_CREATE_JOINABLE,\n#define PTHREAD_CREATE_JOINABLE\tPTHREAD_CREATE_JOINABLE\n\tPTHREAD_CREATE_DETACHED\n#define PTHREAD_CREATE_DETACHED\tPTHREAD_CREATE_DETACHED\n};\n\n/* Mutex types.  */\nenum {\n\tPTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_ADAPTIVE_NP\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n\t    ,\n\tPTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,\n\tPTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,\n\tPTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,\n\tPTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL\n#endif\n#ifdef __USE_GNU\n\t    /* For compatibility.  */\n\t    , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP\n#endif\n};\n\n#ifdef __USE_XOPEN2K\n/* Robust mutex or not flags.  */\nenum {\n\tPTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,\n\tPTHREAD_MUTEX_ROBUST,\n\tPTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST\n};\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Mutex protocols.  */\nenum {\n\tPTHREAD_PRIO_NONE,\n\tPTHREAD_PRIO_INHERIT,\n\tPTHREAD_PRIO_PROTECT\n};\n#endif\n\n#ifdef __PTHREAD_MUTEX_HAVE_PREV\n#define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }\n#ifdef __USE_GNU\n#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }\n#define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }\n\n#endif\n#else\n#define PTHREAD_MUTEX_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }\n#ifdef __USE_GNU\n#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }\n#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }\n#define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\\n  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }\n\n#endif\n#endif\n\n/* Read-write lock types.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\nenum {\n\tPTHREAD_RWLOCK_PREFER_READER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NP,\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\n\tPTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP\n};\n\n/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t\n   has the shared field.  All 64-bit architectures have the shared field\n   in pthread_rwlock_t.  */\n#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n#if __WORDSIZE == 64\n#define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1\n#endif\n#endif\n\n/* Read-write lock initializers.  */\n#define PTHREAD_RWLOCK_INITIALIZER \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n#ifdef __USE_GNU\n#ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED\n#define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0,\t\t\t\t\t      \\\n\tPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }\n#else\n#if __BYTE_ORDER == __LITTLE_ENDIAN\n#define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \\\n      0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }\n#else\n#define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\\n  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\\\n      0 } }\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* Unix98 or XOpen2K */\n\n/* Scheduler inheritance.  */\nenum {\n\tPTHREAD_INHERIT_SCHED,\n#define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED\n\tPTHREAD_EXPLICIT_SCHED\n#define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED\n};\n\n/* Scope handling.  */\nenum {\n\tPTHREAD_SCOPE_SYSTEM,\n#define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM\n\tPTHREAD_SCOPE_PROCESS\n#define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS\n};\n\n/* Process shared or private flag.  */\nenum {\n\tPTHREAD_PROCESS_PRIVATE,\n#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE\n\tPTHREAD_PROCESS_SHARED\n#define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED\n};\n\n/* Conditional variable handling.  */\n#define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }\n\n/* Cleanup buffers */\nstruct _pthread_cleanup_buffer {\n\tvoid (*__routine) (void *);\t/* Function to call.  */\n\tvoid *__arg;\t\t/* Its argument.  */\n\tint __canceltype;\t/* Saved cancellation type. */\n\tstruct _pthread_cleanup_buffer *__prev;\t/* Chaining of cleanup functions.  */\n};\n\n/* Cancellation */\nenum {\n\tPTHREAD_CANCEL_ENABLE,\n#define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE\n\tPTHREAD_CANCEL_DISABLE\n#define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE\n};\nenum {\n\tPTHREAD_CANCEL_DEFERRED,\n#define PTHREAD_CANCEL_DEFERRED\tPTHREAD_CANCEL_DEFERRED\n\tPTHREAD_CANCEL_ASYNCHRONOUS\n#define PTHREAD_CANCEL_ASYNCHRONOUS\tPTHREAD_CANCEL_ASYNCHRONOUS\n};\n#define PTHREAD_CANCELED ((void *) -1)\n\n/* Single execution handling.  */\n#define PTHREAD_ONCE_INIT 0\n\n#ifdef __USE_XOPEN2K\n/* Value returned by 'pthread_barrier_wait' for one of the threads after\n   the required number of threads have called this function.\n   -1 is distinct from 0 and all errno constants */\n#define PTHREAD_BARRIER_SERIAL_THREAD -1\n#endif\n\n__BEGIN_DECLS\n/* Create a new thread, starting with execution of START-ROUTINE\n   getting passed ARG.  Creation attributed come from ATTR.  The new\n   handle is stored in *NEWTHREAD.  */\nextern int pthread_create(pthread_t * __restrict __newthread, const pthread_attr_t * __restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg)\n__THROWNL __nonnull((1, 3));\n\n/* Terminate calling thread.\n\n   The registered cleanup handlers are called via exception handling\n   so we cannot mark this function with __THROW.*/\nextern void pthread_exit(void *__retval) __attribute__ ((__noreturn__));\n\n/* Make calling thread wait for termination of the thread TH.  The\n   exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN\n   is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_join(pthread_t __th, void **__thread_return);\n\n#ifdef __USE_GNU\n/* Check whether thread TH has terminated.  If yes return the status of\n   the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */\nextern int pthread_tryjoin_np(pthread_t __th, void **__thread_return) __THROW;\n\n/* Make calling thread wait for termination of the thread TH, but only\n   until TIMEOUT.  The exit status of the thread is stored in\n   *THREAD_RETURN, if THREAD_RETURN is not NULL.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_timedjoin_np(pthread_t __th, void **__thread_return, const struct timespec *__abstime);\n#endif\n\n/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.\n   The resources of TH will therefore be freed immediately when it\n   terminates, instead of waiting for another thread to perform PTHREAD_JOIN\n   on it.  */\nextern int pthread_detach(pthread_t __th) __THROW;\n\n/* Obtain the identifier of the current thread.  */\nextern pthread_t pthread_self(void)\n__THROW __attribute__ ((__const__));\n\n/* Compare two thread identifiers.  */\nextern int pthread_equal(pthread_t __thread1, pthread_t __thread2)\n__THROW __attribute__ ((__const__));\n\n/* Thread attribute handling.  */\n\n/* Initialize thread attribute *ATTR with default attributes\n   (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,\n    no user-provided stack).  */\nextern int pthread_attr_init(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy thread attribute *ATTR.  */\nextern int pthread_attr_destroy(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get detach state attribute.  */\nextern int pthread_attr_getdetachstate(const pthread_attr_t * __attr, int *__detachstate)\n__THROW __nonnull((1, 2));\n\n/* Set detach state attribute.  */\nextern int pthread_attr_setdetachstate(pthread_attr_t * __attr, int __detachstate)\n__THROW __nonnull((1));\n\n/* Get the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_getguardsize(const pthread_attr_t * __attr, size_t * __guardsize)\n__THROW __nonnull((1, 2));\n\n/* Set the size of the guard area created for stack overflow protection.  */\nextern int pthread_attr_setguardsize(pthread_attr_t * __attr, size_t __guardsize)\n__THROW __nonnull((1));\n\n/* Return in *PARAM the scheduling parameters of *ATTR.  */\nextern int pthread_attr_getschedparam(const pthread_attr_t * __restrict __attr, struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */\nextern int pthread_attr_setschedparam(pthread_attr_t * __restrict __attr, const struct sched_param *__restrict __param)\n__THROW __nonnull((1, 2));\n\n/* Return in *POLICY the scheduling policy of *ATTR.  */\nextern int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict __attr, int *__restrict __policy)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling policy in *ATTR according to POLICY.  */\nextern int pthread_attr_setschedpolicy(pthread_attr_t * __attr, int __policy)\n__THROW __nonnull((1));\n\n/* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */\nextern int pthread_attr_getinheritsched(const pthread_attr_t * __restrict __attr, int *__restrict __inherit)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling inheritance mode in *ATTR according to INHERIT.  */\nextern int pthread_attr_setinheritsched(pthread_attr_t * __attr, int __inherit)\n__THROW __nonnull((1));\n\n/* Return in *SCOPE the scheduling contention scope of *ATTR.  */\nextern int pthread_attr_getscope(const pthread_attr_t * __restrict __attr, int *__restrict __scope)\n__THROW __nonnull((1, 2));\n\n/* Set scheduling contention scope in *ATTR according to SCOPE.  */\nextern int pthread_attr_setscope(pthread_attr_t * __attr, int __scope)\n__THROW __nonnull((1));\n\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstackaddr(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr)\n__THROW __nonnull((1, 2)) __attribute_deprecated__;\n\n/* Set the starting address of the stack of the thread to be created.\n   Depending on whether the stack grows up or down the value must either\n   be higher or lower than all the address in the memory block.  The\n   minimal size of the block must be PTHREAD_STACK_MIN.  */\nextern int pthread_attr_setstackaddr(pthread_attr_t * __attr, void *__stackaddr)\n__THROW __nonnull((1)) __attribute_deprecated__;\n\n/* Return the currently used minimal stack size.  */\nextern int pthread_attr_getstacksize(const pthread_attr_t * __restrict __attr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2));\n\n/* Add information about the minimum stack size needed for the thread\n   to be started.  This size must never be less than PTHREAD_STACK_MIN\n   and must also not exceed the system limits.  */\nextern int pthread_attr_setstacksize(pthread_attr_t * __attr, size_t __stacksize)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Return the previously set address for the stack.  */\nextern int pthread_attr_getstack(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr, size_t * __restrict __stacksize)\n__THROW __nonnull((1, 2, 3));\n\n/* The following two interfaces are intended to replace the last two.  They\n   require setting the address as well as the size since only setting the\n   address will make the implementation on some architectures impossible.  */\nextern int pthread_attr_setstack(pthread_attr_t * __attr, void *__stackaddr, size_t __stacksize)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_GNU\n/* Thread created with attribute ATTR will be limited to run only on\n   the processors represented in CPUSET.  */\nextern int pthread_attr_setaffinity_np(pthread_attr_t * __attr, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get bit set in CPUSET representing the processors threads created with\n   ATTR can run on.  */\nextern int pthread_attr_getaffinity_np(const pthread_attr_t * __attr, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((1, 3));\n\n/* Get the default attributes used by pthread_create in this process.  */\nextern int pthread_getattr_default_np(pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Set the default attributes to be used by pthread_create in this\n   process.  */\nextern int pthread_setattr_default_np(const pthread_attr_t * __attr)\n__THROW __nonnull((1));\n\n/* Initialize thread attribute *ATTR with attributes corresponding to the\n   already running thread TH.  It shall be called on uninitialized ATTR\n   and destroyed with pthread_attr_destroy when no longer needed.  */\nextern int pthread_getattr_np(pthread_t __th, pthread_attr_t * __attr)\n__THROW __nonnull((2));\n#endif\n\n/* Functions for scheduling control.  */\n\n/* Set the scheduling parameters for TARGET_THREAD according to POLICY\n   and *PARAM.  */\nextern int pthread_setschedparam(pthread_t __target_thread, int __policy, const struct sched_param *__param)\n__THROW __nonnull((3));\n\n/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */\nextern int pthread_getschedparam(pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param)\n__THROW __nonnull((2, 3));\n\n/* Set the scheduling priority for TARGET_THREAD.  */\nextern int pthread_setschedprio(pthread_t __target_thread, int __prio) __THROW;\n\n#ifdef __USE_GNU\n/* Get thread name visible in the kernel and its interfaces.  */\nextern int pthread_getname_np(pthread_t __target_thread, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Set thread name visible in the kernel and its interfaces.  */\nextern int pthread_setname_np(pthread_t __target_thread, const char *__name)\n__THROW __nonnull((2));\n#endif\n\n#ifdef __USE_UNIX98\n/* Determine level of concurrency.  */\nextern int pthread_getconcurrency(void) __THROW;\n\n/* Set new concurrency level to LEVEL.  */\nextern int pthread_setconcurrency(int __level) __THROW;\n#endif\n\n#ifdef __USE_GNU\n/* Yield the processor to another thread or process.\n   This function is similar to the POSIX `sched_yield' function but\n   might be differently implemented in the case of a m-on-n thread\n   implementation.  */\nextern int pthread_yield(void) __THROW;\n\n/* Limit specified thread TH to run only on the processors represented\n   in CPUSET.  */\nextern int pthread_setaffinity_np(pthread_t __th, size_t __cpusetsize, const cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n\n/* Get bit set in CPUSET representing the processors TH can run on.  */\nextern int pthread_getaffinity_np(pthread_t __th, size_t __cpusetsize, cpu_set_t * __cpuset)\n__THROW __nonnull((3));\n#endif\n\n/* Functions for handling initialization.  */\n\n/* Guarantee that the initialization function INIT_ROUTINE will be called\n   only once, even if pthread_once is executed several times with the\n   same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or\n   extern variable initialized to PTHREAD_ONCE_INIT.\n\n   The initialization functions might throw exception which is why\n   this function is not marked with __THROW.  */\nextern int pthread_once(pthread_once_t * __once_control, void (*__init_routine) (void)) __nonnull((1, 2));\n\n/* Functions for handling cancellation.\n\n   Note that these functions are explicitly not marked to not throw an\n   exception in C++ code.  If cancellation is implemented by unwinding\n   this is necessary to have the compiler generate the unwind information.  */\n\n/* Set cancelability state of current thread to STATE, returning old\n   state in *OLDSTATE if OLDSTATE is not NULL.  */\nextern int pthread_setcancelstate(int __state, int *__oldstate);\n\n/* Set cancellation state of current thread to TYPE, returning the old\n   type in *OLDTYPE if OLDTYPE is not NULL.  */\nextern int pthread_setcanceltype(int __type, int *__oldtype);\n\n/* Cancel THREAD immediately or at the next possibility.  */\nextern int pthread_cancel(pthread_t __th);\n\n/* Test for pending cancellation for the current thread and terminate\n   the thread as per pthread_exit(PTHREAD_CANCELED) if it has been\n   cancelled.  */\nextern void pthread_testcancel(void);\n\n/* Cancellation handling with integration into exception handling.  */\n\ntypedef struct {\n\tstruct {\n\t\t__jmp_buf __cancel_jmp_buf;\n\t\tint __mask_was_saved;\n\t} __cancel_jmp_buf[1];\n\tvoid *__pad[4];\n} __pthread_unwind_buf_t __attribute__ ((__aligned__));\n\n/* No special attributes by default.  */\n#ifndef __cleanup_fct_attribute\n#define __cleanup_fct_attribute\n#endif\n\n/* Structure to hold the cleanup handler information.  */\nstruct __pthread_cleanup_frame {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n};\n\n#if defined __GNUC__ && defined __EXCEPTIONS\n#ifdef __cplusplus\n/* Class to handle cancellation handler invocation.  */\nclass __pthread_cleanup_class {\n\tvoid (*__cancel_routine) (void *);\n\tvoid *__cancel_arg;\n\tint __do_it;\n\tint __cancel_type;\n\n public:\n\t__pthread_cleanup_class(void (*__fct) (void *), void *__arg)\n\t:__cancel_routine(__fct), __cancel_arg(__arg), __do_it(1)\n{\n} ~__pthread_cleanup_class() {\n\t\tif (__do_it)\n\t\t\t__cancel_routine(__cancel_arg);\n}\nvoid __setdoit(int __newval) {\n\t__do_it = __newval;\n}\nvoid __defer() {\n\tpthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &__cancel_type);\n}\nvoid __restore() const {\n\tpthread_setcanceltype(__cancel_type, 0);\n}};\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg)\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#define pthread_cleanup_pop(execute) \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_cleanup_class __clframe (routine, arg);\t\t\t      \\\n    __clframe.__defer ()\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#define pthread_cleanup_pop_restore_np(execute) \\\n    __clframe.__restore ();\t\t\t\t\t\t      \\\n    __clframe.__setdoit (execute);\t\t\t\t\t      \\\n  } while (0)\n#endif\n#else\n/* Function called to call the cleanup handler.  As an extern inline\n   function the compiler is free to decide inlining the change when\n   needed or fall back on the copy which must exist somewhere\n   else.  */\n__extern_inline void __pthread_cleanup_routine(struct __pthread_cleanup_frame *__frame)\n{\n\tif (__frame->__do_it)\n\t\t__frame->__cancel_routine(__frame->__cancel_arg);\n}\n\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t \t      \\\n\t  .__do_it = 1 };\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#define pthread_cleanup_pop(execute) \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n\n#ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    struct __pthread_cleanup_frame __clframe\t\t\t\t      \\\n      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))\t\t      \\\n      = { .__cancel_routine = (routine), .__cancel_arg = (arg),\t\t      \\\n\t  .__do_it = 1 };\t\t\t\t\t\t      \\\n    (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,\t\t      \\\n\t\t\t\t  &__clframe.__cancel_type)\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#define pthread_cleanup_pop_restore_np(execute) \\\n    (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);\t      \\\n    __clframe.__do_it = (execute);\t\t\t\t\t      \\\n  } while (0)\n#endif\n#endif\n#else\n/* Install a cleanup handler: ROUTINE will be called with arguments ARG\n   when the thread is canceled or calls pthread_exit.  ROUTINE will also\n   be called with arguments ARG when the matching pthread_cleanup_pop\n   is executed with non-zero EXECUTE argument.\n\n   pthread_cleanup_push and pthread_cleanup_pop are macros and must always\n   be used in matching pairs at the same nesting level of braces.  */\n#define pthread_cleanup_push(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel (&__cancel_buf);\t\t\t\t      \\\n    do {\nextern void __pthread_register_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler installed by the matching pthread_cleanup_push.\n   If EXECUTE is non-zero, the handler function is called. */\n#define pthread_cleanup_pop(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel (&__cancel_buf);\t\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n#ifdef __USE_GNU\n/* Install a cleanup handler as pthread_cleanup_push does, but also\n   saves the current cancellation type and sets it to deferred\n   cancellation.  */\n#define pthread_cleanup_push_defer_np(routine, arg) \\\n  do {\t\t\t\t\t\t\t\t\t      \\\n    __pthread_unwind_buf_t __cancel_buf;\t\t\t\t      \\\n    void (*__cancel_routine) (void *) = (routine);\t\t\t      \\\n    void *__cancel_arg = (arg);\t\t\t\t\t\t      \\\n    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \\\n\t\t\t\t\t__cancel_buf.__cancel_jmp_buf, 0);    \\\n    if (__glibc_unlikely (__not_first_call))\t\t\t\t      \\\n      {\t\t\t\t\t\t\t\t\t      \\\n\t__cancel_routine (__cancel_arg);\t\t\t\t      \\\n\t__pthread_unwind_next (&__cancel_buf);\t\t\t\t      \\\n\t/* NOTREACHED */\t\t\t\t\t\t      \\\n      }\t\t\t\t\t\t\t\t\t      \\\n\t\t\t\t\t\t\t\t\t      \\\n    __pthread_register_cancel_defer (&__cancel_buf);\t\t\t      \\\n    do {\nextern void __pthread_register_cancel_defer(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n\n/* Remove a cleanup handler as pthread_cleanup_pop does, but also\n   restores the cancellation type that was in effect when the matching\n   pthread_cleanup_push_defer was called.  */\n#define pthread_cleanup_pop_restore_np(execute) \\\n      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\\\n    } while (0);\t\t\t\t\t\t\t      \\\n    __pthread_unregister_cancel_restore (&__cancel_buf);\t\t      \\\n    if (execute)\t\t\t\t\t\t\t      \\\n      __cancel_routine (__cancel_arg);\t\t\t\t\t      \\\n  } while (0)\nextern void __pthread_unregister_cancel_restore(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;\n#endif\n\n/* Internal interface to initiate cleanup.  */\nextern void __pthread_unwind_next(__pthread_unwind_buf_t * __buf)\n__cleanup_fct_attribute __attribute__ ((__noreturn__))\n#ifndef SHARED\n    __attribute__ ((__weak__))\n#endif\n    ;\n#endif\n\n/* Function used in the macros.  */\nstruct __jmp_buf_tag;\nextern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask) __THROWNL;\n\n/* Mutex handling.  */\n\n/* Initialize a mutex.  */\nextern int pthread_mutex_init(pthread_mutex_t * __mutex, const pthread_mutexattr_t * __mutexattr)\n__THROW __nonnull((1));\n\n/* Destroy a mutex.  */\nextern int pthread_mutex_destroy(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n\n/* Try locking a mutex.  */\nextern int pthread_mutex_trylock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Lock a mutex.  */\nextern int pthread_mutex_lock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Wait until lock becomes available, or specified time passes. */\nextern int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n#endif\n\n/* Unlock a mutex.  */\nextern int pthread_mutex_unlock(pthread_mutex_t * __mutex)\n__THROWNL __nonnull((1));\n\n/* Get the priority ceiling of MUTEX.  */\nextern int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the priority ceiling of MUTEX to PRIOCEILING, return old\n   priority ceiling value in *OLD_CEILING.  */\nextern int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict __mutex, int __prioceiling, int *__restrict __old_ceiling)\n__THROW __nonnull((1, 3));\n\n#ifdef __USE_XOPEN2K8\n/* Declare the state protected by MUTEX as consistent.  */\nextern int pthread_mutex_consistent(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n#ifdef __USE_GNU\nextern int pthread_mutex_consistent_np(pthread_mutex_t * __mutex)\n__THROW __nonnull((1));\n#endif\n#endif\n\n/* Functions for handling mutex attributes.  */\n\n/* Initialize mutex attribute object ATTR with default attributes\n   (kind is PTHREAD_MUTEX_TIMED_NP).  */\nextern int pthread_mutexattr_init(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy mutex attribute object ATTR.  */\nextern int pthread_mutexattr_destroy(pthread_mutexattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setpshared(pthread_mutexattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n/* Return in *KIND the mutex kind attribute in *ATTR.  */\nextern int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict __attr, int *__restrict __kind)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,\n   PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or\n   PTHREAD_MUTEX_DEFAULT).  */\nextern int pthread_mutexattr_settype(pthread_mutexattr_t * __attr, int __kind)\n__THROW __nonnull((1));\n#endif\n\n/* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */\nextern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either\n   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */\nextern int pthread_mutexattr_setprotocol(pthread_mutexattr_t * __attr, int __protocol)\n__THROW __nonnull((1));\n\n/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */\nextern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling)\n__THROW __nonnull((1, 2));\n\n/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */\nextern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t * __attr, int __prioceiling)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_getrobust(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n#ifdef __USE_GNU\nextern int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t * __attr, int *__robustness)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Set the robustness flag of the mutex attribute ATTR.  */\nextern int pthread_mutexattr_setrobust(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n#ifdef __USE_GNU\nextern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t * __attr, int __robustness)\n__THROW __nonnull((1));\n#endif\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n/* Functions for handling read-write locks.  */\n\n/* Initialize read-write lock RWLOCK using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, const pthread_rwlockattr_t * __restrict __attr)\n__THROW __nonnull((1));\n\n/* Destroy read-write lock RWLOCK.  */\nextern int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock)\n__THROW __nonnull((1));\n\n/* Acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire read lock for RWLOCK.  */\nextern int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Try to acquire read lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n#endif\n\n/* Acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Try to acquire write lock for RWLOCK.  */\nextern int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Try to acquire write lock for RWLOCK or return after specfied time.  */\nextern int pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)\n__THROWNL __nonnull((1, 2));\n#endif\n\n/* Unlock RWLOCK.  */\nextern int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock)\n__THROWNL __nonnull((1));\n\n/* Functions for handling read-write lock attributes.  */\n\n/* Initialize attribute object ATTR with default values.  */\nextern int pthread_rwlockattr_init(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy attribute object ATTR.  */\nextern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Return current setting of process-shared attribute of ATTR in PSHARED.  */\nextern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set process-shared attribute of ATTR to PSHARED.  */\nextern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n/* Return current setting of reader/writer preference.  */\nextern int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref)\n__THROW __nonnull((1, 2));\n\n/* Set reader/write preference.  */\nextern int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t * __attr, int __pref)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling conditional variables.  */\n\n/* Initialize condition variable COND using attributes ATTR, or use\n   the default values if later is NULL.  */\nextern int pthread_cond_init(pthread_cond_t * __restrict __cond, const pthread_condattr_t * __restrict __cond_attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable COND.  */\nextern int pthread_cond_destroy(pthread_cond_t * __cond)\n__THROW __nonnull((1));\n\n/* Wake up one thread waiting for condition variable COND.  */\nextern int pthread_cond_signal(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wake up all threads waiting for condition variables COND.  */\nextern int pthread_cond_broadcast(pthread_cond_t * __cond)\n__THROWNL __nonnull((1));\n\n/* Wait for condition variable COND to be signaled or broadcast.\n   MUTEX is assumed to be locked before.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_wait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex) __nonnull((1, 2));\n\n/* Wait for condition variable COND to be signaled or broadcast until\n   ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an\n   absolute time specification; zero is the beginning of the epoch\n   (00:00:00 GMT, January 1, 1970).\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pthread_cond_timedwait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime) __nonnull((1, 2, 3));\n\n/* Functions for handling condition variable attributes.  */\n\n/* Initialize condition variable attribute ATTR.  */\nextern int pthread_condattr_init(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy condition variable attribute ATTR.  */\nextern int pthread_condattr_destroy(pthread_condattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_getpshared(const pthread_condattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the condition variable attribute ATTR.  */\nextern int pthread_condattr_setpshared(pthread_condattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n\n#ifdef __USE_XOPEN2K\n/* Get the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_getclock(const pthread_condattr_t * __restrict __attr, __clockid_t * __restrict __clock_id)\n__THROW __nonnull((1, 2));\n\n/* Set the clock selected for the condition variable attribute ATTR.  */\nextern int pthread_condattr_setclock(pthread_condattr_t * __attr, __clockid_t __clock_id)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Functions to handle spinlocks.  */\n\n/* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can\n   be shared between different processes.  */\nextern int pthread_spin_init(pthread_spinlock_t * __lock, int __pshared)\n__THROW __nonnull((1));\n\n/* Destroy the spinlock LOCK.  */\nextern int pthread_spin_destroy(pthread_spinlock_t * __lock)\n__THROW __nonnull((1));\n\n/* Wait until spinlock LOCK is retrieved.  */\nextern int pthread_spin_lock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Try to lock spinlock LOCK.  */\nextern int pthread_spin_trylock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Release spinlock LOCK.  */\nextern int pthread_spin_unlock(pthread_spinlock_t * __lock)\n__THROWNL __nonnull((1));\n\n/* Functions to handle barriers.  */\n\n/* Initialize BARRIER with the attributes in ATTR.  The barrier is\n   opened when COUNT waiters arrived.  */\nextern int pthread_barrier_init(pthread_barrier_t * __restrict __barrier, const pthread_barrierattr_t * __restrict __attr, unsigned int __count)\n__THROW __nonnull((1));\n\n/* Destroy a previously dynamically initialized barrier BARRIER.  */\nextern int pthread_barrier_destroy(pthread_barrier_t * __barrier)\n__THROW __nonnull((1));\n\n/* Wait on barrier BARRIER.  */\nextern int pthread_barrier_wait(pthread_barrier_t * __barrier)\n__THROWNL __nonnull((1));\n\n/* Initialize barrier attribute ATTR.  */\nextern int pthread_barrierattr_init(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Destroy previously dynamically initialized barrier attribute ATTR.  */\nextern int pthread_barrierattr_destroy(pthread_barrierattr_t * __attr)\n__THROW __nonnull((1));\n\n/* Get the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared)\n__THROW __nonnull((1, 2));\n\n/* Set the process-shared flag of the barrier attribute ATTR.  */\nextern int pthread_barrierattr_setpshared(pthread_barrierattr_t * __attr, int __pshared)\n__THROW __nonnull((1));\n#endif\n\n/* Functions for handling thread-specific data.  */\n\n/* Create a key value identifying a location in the thread-specific\n   data area.  Each thread maintains a distinct thread-specific data\n   area.  DESTR_FUNCTION, if non-NULL, is called with the value\n   associated to that key when the key is destroyed.\n   DESTR_FUNCTION is not called if the value associated is NULL when\n   the key is destroyed.  */\nextern int pthread_key_create(pthread_key_t * __key, void (*__destr_function) (void *))\n__THROW __nonnull((1));\n\n/* Destroy KEY.  */\nextern int pthread_key_delete(pthread_key_t __key) __THROW;\n\n/* Return current value of the thread-specific data slot identified by KEY.  */\nextern void *pthread_getspecific(pthread_key_t __key) __THROW;\n\n/* Store POINTER in the thread-specific data slot identified by KEY. */\nextern int pthread_setspecific(pthread_key_t __key, const void *__pointer) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* Get ID of CPU-time clock for thread THREAD_ID.  */\nextern int pthread_getcpuclockid(pthread_t __thread_id, __clockid_t * __clock_id)\n__THROW __nonnull((2));\n#endif\n\n/* Install handlers to be called when a new process is created with FORK.\n   The PREPARE handler is called in the parent process just before performing\n   FORK. The PARENT handler is called in the parent process just after FORK.\n   The CHILD handler is called in the child process.  Each of the three\n   handlers can be NULL, meaning that no handler needs to be called at that\n   point.\n   PTHREAD_ATFORK can be called several times, in which case the PREPARE\n   handlers are called in LIFO order (last added with PTHREAD_ATFORK,\n   first called before FORK), and the PARENT and CHILD handlers are called\n   in FIFO (first added, first called).  */\n\nextern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;\n\n#ifdef __USE_EXTERN_INLINES\n/* Optimizations.  */\n__extern_inline int __NTH(pthread_equal(pthread_t __thread1, pthread_t __thread2))\n{\n\treturn __thread1 == __thread2;\n}\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pthread.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/pwd.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 9.2.2 User Database Access\t<pwd.h>\n */\n\n#ifndef\t_PWD_H\n#define\t_PWD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#define __need_size_t\n#include <stddef.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#define __gid_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#define __uid_t_defined\n#endif\n#endif\n\n/* The passwd structure.  */\nstruct passwd {\n\tchar *pw_name;\t\t/* Username.  */\n\tchar *pw_passwd;\t/* Password.  */\n\t__uid_t pw_uid;\t\t/* User ID.  */\n\t__gid_t pw_gid;\t\t/* Group ID.  */\n\tchar *pw_gecos;\t\t/* Real name.  */\n\tchar *pw_dir;\t\t/* Home directory.  */\n\tchar *pw_shell;\t\t/* Shell program.  */\n};\n\n#ifdef __USE_MISC\n#define __need_FILE\n#include <stdio.h>\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Rewind the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void setpwent(void);\n\n/* Close the password-file stream.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void endpwent(void);\n\n/* Read an entry from the password-file stream, opening it if necessary.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwent(void);\n#endif\n\n#ifdef\t__USE_MISC\n/* Read an entry from STREAM.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern struct passwd *fgetpwent(FILE * __stream) __nonnull((1));\n\n/* Write the given entry onto the given stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int putpwent(const struct passwd *__restrict __p, FILE * __restrict __f);\n#endif\n\n/* Search for an entry with a matching user ID.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwuid(__uid_t __uid);\n\n/* Search for an entry with a matching username.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct passwd *getpwnam(const char *__name) __nonnull((1));\n\n#ifdef __USE_POSIX\n\n#ifdef __USE_MISC\n/* Reasonable value for the buffer sized used in the reentrant\n   functions below.  But better use `sysconf'.  */\n#define NSS_BUFLEN_PASSWD\t1024\n#endif\n\n/* Reentrant versions of some of the functions above.\n\n   PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.\n   The interface may change in later versions of this library.  But\n   the interface is designed following the principals used for the\n   other reentrant functions so the chances are good this is what the\n   POSIX people would choose.  */\n\n#ifdef __USE_MISC\n/* This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpwent_r(struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 4));\n#endif\n\nextern int getpwuid_r(__uid_t __uid, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((2, 3, 5));\n\nextern int getpwnam_r(const char *__restrict __name, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n\n#ifdef\t__USE_MISC\n/* Read an entry from STREAM.  This function is not standardized and\n   probably never will.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetpwent_r(FILE * __restrict __stream, struct passwd *__restrict __resultbuf, char *__restrict __buffer, size_t __buflen, struct passwd **__restrict __result) __nonnull((1, 2, 3, 5));\n#endif\n\n#endif\t\t\t\t/* POSIX or reentrant */\n\n#ifdef __USE_GNU\n/* Re-construct the password-file line for the given uid\n   in the given buffer.  This knows the format that the caller\n   will expect, but this need not be the format of the password file.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getpw(__uid_t __uid, char *__buffer);\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* pwd.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/rpc/netdb.h",
    "content": "/* @(#)netdb.h\t2.1 88/07/29 3.9 RPCSRC */\n/*\n * Copyright (c) 2010, Oracle America, Inc.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n *     * Redistributions of source code must retain the above copyright\n *       notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n *       copyright notice, this list of conditions and the following\n *       disclaimer in the documentation and/or other materials\n *       provided with the distribution.\n *     * Neither the name of the \"Oracle America, Inc.\" nor the names of its\n *       contributors may be used to endorse or promote products derived\n *       from this software without specific prior written permission.\n *\n *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Cleaned up for GNU C library roland@gnu.ai.mit.edu:\n   added multiple inclusion protection and use of <sys/cdefs.h>.\n   In GNU this file is #include'd by <netdb.h>.  */\n\n#ifndef _RPC_NETDB_H\n#define _RPC_NETDB_H\t1\n\n#include <features.h>\n\n#define __need_size_t\n#include <stddef.h>\n\n__BEGIN_DECLS struct rpcent {\n\tchar *r_name;\t\t/* Name of server for this rpc program.  */\n\tchar **r_aliases;\t/* Alias list.  */\n\tint r_number;\t\t/* RPC program number.  */\n};\n\nextern void setrpcent(int __stayopen) __THROW;\nextern void endrpcent(void) __THROW;\nextern struct rpcent *getrpcbyname(const char *__name) __THROW;\nextern struct rpcent *getrpcbynumber(int __number) __THROW;\nextern struct rpcent *getrpcent(void) __THROW;\n\n#ifdef __USE_MISC\nextern int getrpcbyname_r(const char *__name, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcbynumber_r(int __number, struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n\nextern int getrpcent_r(struct rpcent *__result_buf, char *__buffer, size_t __buflen, struct rpcent **__result) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* rpc/netdb.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/sched.h",
    "content": "/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.\n   Copyright (C) 1996-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_SCHED_H\n#define\t_SCHED_H\t1\n\n#include <features.h>\n\n/* Get type definitions.  */\n#include <bits/types.h>\n\n#define __need_size_t\n#include <stddef.h>\n\n#ifdef __USE_XOPEN2K\n#define __need_time_t\n#define __need_timespec\n#endif\n#include <time.h>\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n\n/* Get system specific constant and data structure definitions.  */\n#include <bits/sched.h>\n/* Define the real names for the elements of `struct sched_param'.  */\n#define sched_priority\t__sched_priority\n\n__BEGIN_DECLS\n/* Set scheduling parameters for a process.  */\nextern int sched_setparam(__pid_t __pid, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling parameters for a particular process.  */\nextern int sched_getparam(__pid_t __pid, struct sched_param *__param) __THROW;\n\n/* Set scheduling algorithm and/or parameters for a process.  */\nextern int sched_setscheduler(__pid_t __pid, int __policy, const struct sched_param *__param) __THROW;\n\n/* Retrieve scheduling algorithm for a particular purpose.  */\nextern int sched_getscheduler(__pid_t __pid) __THROW;\n\n/* Yield the processor.  */\nextern int sched_yield(void) __THROW;\n\n/* Get maximum priority value for a scheduler.  */\nextern int sched_get_priority_max(int __algorithm) __THROW;\n\n/* Get minimum priority value for a scheduler.  */\nextern int sched_get_priority_min(int __algorithm) __THROW;\n\n/* Get the SCHED_RR interval for the named process.  */\nextern int sched_rr_get_interval(__pid_t __pid, struct timespec *__t) __THROW;\n\n#ifdef __USE_GNU\n/* Access macros for `cpu_set'.  */\n#define CPU_SETSIZE __CPU_SETSIZE\n#define CPU_SET(cpu, cpusetp)\t __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)\n#define CPU_CLR(cpu, cpusetp)\t __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)\n#define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \\\n\t\t\t\t\t\tcpusetp)\n#define CPU_ZERO(cpusetp)\t __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)\n#define CPU_COUNT(cpusetp)\t __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)\n\n#define CPU_SET_S(cpu, setsize, cpusetp)   __CPU_SET_S (cpu, setsize, cpusetp)\n#define CPU_CLR_S(cpu, setsize, cpusetp)   __CPU_CLR_S (cpu, setsize, cpusetp)\n#define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \\\n\t\t\t\t\t\t\t   cpusetp)\n#define CPU_ZERO_S(setsize, cpusetp)\t    __CPU_ZERO_S (setsize, cpusetp)\n#define CPU_COUNT_S(setsize, cpusetp)\t    __CPU_COUNT_S (setsize, cpusetp)\n\n#define CPU_EQUAL(cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)\n#define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \\\n  __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)\n\n#define CPU_AND(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)\n#define CPU_OR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)\n#define CPU_XOR(destset, srcset1, srcset2) \\\n  __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)\n#define CPU_AND_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, &)\n#define CPU_OR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, |)\n#define CPU_XOR_S(setsize, destset, srcset1, srcset2) \\\n  __CPU_OP_S (setsize, destset, srcset1, srcset2, ^)\n\n#define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)\n#define CPU_ALLOC(count) __CPU_ALLOC (count)\n#define CPU_FREE(cpuset) __CPU_FREE (cpuset)\n\n/* Set the CPU affinity for a task */\nextern int sched_setaffinity(__pid_t __pid, size_t __cpusetsize, const cpu_set_t * __cpuset) __THROW;\n\n/* Get the CPU affinity for a task */\nextern int sched_getaffinity(__pid_t __pid, size_t __cpusetsize, cpu_set_t * __cpuset) __THROW;\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* sched.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/setjmp.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.13 Nonlocal jumps\t<setjmp.h>\n */\n\n#ifndef\t_SETJMP_H\n#define\t_SETJMP_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/setjmp.h>\t/* Get `__jmp_buf'.  */\n#include <bits/sigset.h>\t/* Get `__sigset_t'.  */\n/* Calling environment, plus possibly a saved signal mask.  */\n    struct __jmp_buf_tag {\n\t/* NOTE: The machine-dependent definitions of `__sigsetjmp'\n\t   assume that a `jmp_buf' begins with a `__jmp_buf' and that\n\t   `__mask_was_saved' follows it.  Do not move these members\n\t   or add others before it.  */\n\t__jmp_buf __jmpbuf;\t/* Calling environment.  */\n\tint __mask_was_saved;\t/* Saved the signal mask?  */\n\t__sigset_t __saved_mask;\t/* Saved signal mask.  */\n};\n\n__BEGIN_NAMESPACE_STD typedef struct __jmp_buf_tag jmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the signal mask.\n   Return 0.  */\nextern int setjmp(jmp_buf __env) __THROWNL;\n\n__END_NAMESPACE_STD\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.\n   This is the internal name for `sigsetjmp'.  */\nextern int __sigsetjmp(struct __jmp_buf_tag __env[1], int __savemask) __THROWNL;\n\n/* Store the calling environment in ENV, not saving the signal mask.\n   Return 0.  */\nextern int _setjmp(struct __jmp_buf_tag __env[1]) __THROWNL;\n\n/* Do not save the signal mask.  This is equivalent to the `_setjmp'\n   BSD function.  */\n#define setjmp(env)\t_setjmp (env)\n\n__BEGIN_NAMESPACE_STD\n/* Jump to the environment saved in ENV, making the\n   `setjmp' call there return VAL, or 1 if VAL is 0.  */\nextern void longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n\n__END_NAMESPACE_STD\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Same.  Usually `_longjmp' is used with `_setjmp', which does not save\n   the signal mask.  But it is how ENV was saved that determines whether\n   `longjmp' restores the mask; `_longjmp' is just an alias.  */\nextern void _longjmp(struct __jmp_buf_tag __env[1], int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\n\n#ifdef\t__USE_POSIX\n/* Use the same type for `jmp_buf' and `sigjmp_buf'.\n   The `__mask_was_saved' flag determines whether\n   or not `longjmp' will restore the signal mask.  */\ntypedef struct __jmp_buf_tag sigjmp_buf[1];\n\n/* Store the calling environment in ENV, also saving the\n   signal mask if SAVEMASK is nonzero.  Return 0.  */\n#define sigsetjmp(env, savemask)\t__sigsetjmp (env, savemask)\n\n/* Jump to the environment saved in ENV, making the\n   sigsetjmp call there return VAL, or 1 if VAL is 0.\n   Restore the signal mask if that sigsetjmp call saved it.\n   This is just an alias `longjmp'.  */\nextern void siglongjmp(sigjmp_buf __env, int __val)\n__THROWNL __attribute__ ((__noreturn__));\n#endif\t\t\t\t/* Use POSIX.  */\n\n/* Define helper functions to catch unsafe code.  */\n#if __USE_FORTIFY_LEVEL > 0\n#include <bits/setjmp2.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* setjmp.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/signal.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.14 Signal handling <signal.h>\n */\n\n#ifndef\t_SIGNAL_H\n\n#if !defined __need_sig_atomic_t && !defined __need_sigset_t\n#define _SIGNAL_H\n#endif\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/sigset.h>\t/* __sigset_t, __sig_atomic_t.  */\n/* An integral type that can be modified atomically, without the\n   possibility of a signal arriving in the middle of the operation.  */\n#if defined __need_sig_atomic_t || defined _SIGNAL_H\n#ifndef __sig_atomic_t_defined\n#define __sig_atomic_t_defined\n__BEGIN_NAMESPACE_STD typedef __sig_atomic_t sig_atomic_t;\n__END_NAMESPACE_STD\n#endif\n#undef __need_sig_atomic_t\n#endif\n#if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)\n#ifndef __sigset_t_defined\n#define __sigset_t_defined\ntypedef __sigset_t sigset_t;\n#endif\n#undef __need_sigset_t\n#endif\n\n#ifdef _SIGNAL_H\n\n#include <bits/types.h>\n#include <bits/signum.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n#ifdef __USE_XOPEN\n#endif\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#define __uid_t_defined\n#endif\n#endif\t\t\t\t/* Unix98 */\n\n#ifdef __USE_POSIX199309\n/* We need `struct timespec' later on.  */\n#define __need_timespec\n#include <time.h>\n#endif\n\n#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED\n/* Get the `siginfo_t' type plus the needed symbols.  */\n#include <bits/siginfo.h>\n#endif\n\n/* Type of a signal handler.  */\ntypedef void (*__sighandler_t) (int);\n\n/* The X/Open definition of `signal' specifies the SVID semantic.  Use\n   the additional function `sysv_signal' when X/Open compatibility is\n   requested.  */\nextern __sighandler_t __sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#ifdef __USE_GNU\nextern __sighandler_t sysv_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Set the handler for the signal SIG to HANDLER, returning the old\n   handler, or SIG_ERR on error.\n   By default `signal' has the BSD semantic.  */\n__BEGIN_NAMESPACE_STD\n#ifdef __USE_MISC\nextern __sighandler_t signal(int __sig, __sighandler_t __handler) __THROW;\n#else\n/* Make sure the used `signal' implementation is the SVID version. */\n#ifdef __REDIRECT_NTH\nextern __sighandler_t __REDIRECT_NTH(signal, (int __sig, __sighandler_t __handler), __sysv_signal);\n#else\n#define signal __sysv_signal\n#endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_XOPEN\n/* The X/Open definition of `signal' conflicts with the BSD version.\n   So they defined another function `bsd_signal'.  */\nextern __sighandler_t bsd_signal(int __sig, __sighandler_t __handler) __THROW;\n#endif\n\n/* Send signal SIG to process number PID.  If PID is zero,\n   send SIG to all processes in the current process's process group.\n   If PID is < -1, send SIG to all processes in process group - PID.  */\n#ifdef __USE_POSIX\nextern int kill(__pid_t __pid, int __sig) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Send SIG to all processes in process group PGRP.\n   If PGRP is zero, send SIG to all processes in\n   the current process's process group.  */\nextern int killpg(__pid_t __pgrp, int __sig) __THROW;\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n__BEGIN_NAMESPACE_STD\n/* Raise signal SIG, i.e., send SIG to yourself.  */\nextern int raise(int __sig) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* SVID names for the same things.  */\nextern __sighandler_t ssignal(int __sig, __sighandler_t __handler) __THROW;\nextern int gsignal(int __sig) __THROW;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_XOPEN2K8\n/* Print a message describing the meaning of the given signal number.  */\nextern void psignal(int __sig, const char *__s);\n\n/* Print a message describing the meaning of the given signal information.  */\nextern void psiginfo(const siginfo_t * __pinfo, const char *__s);\n#endif\t\t\t\t/* POSIX 2008.  */\n\n/* The `sigpause' function in X/Open defines the argument as the\n   signal number.  This requires redirecting to another function\n   because the default version in glibc uses an old BSD interface.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n#ifdef __USE_XOPEN\n#ifdef __GNUC__\nextern int sigpause(int __sig) __asm__(\"__xpg_sigpause\");\n#else\nextern int __sigpause(int __sig_or_mask, int __is_sig);\n/* Remove a signal from the signal mask and suspend the process.  */\n#define sigpause(sig) __sigpause ((sig), 1)\n#endif\n#endif\n\n#ifdef __USE_MISC\n/* None of the following functions should be used anymore.  They are here\n   only for compatibility.  A single word (`int') is not guaranteed to be\n   enough to hold a complete signal mask and therefore these functions\n   simply do not work in many situations.  Use `sigprocmask' instead.  */\n\n/* Compute mask for signal SIG.  */\n#define sigmask(sig)\t__sigmask(sig)\n\n/* Block signals in MASK, returning the old mask.  */\nextern int sigblock(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Set the mask of blocked signals to MASK, returning the old mask.  */\nextern int sigsetmask(int __mask)\n__THROW __attribute_deprecated__;\n\n/* Return currently selected signal mask.  */\nextern int siggetmask(void)\n__THROW __attribute_deprecated__;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_MISC\n#define NSIG\t_NSIG\n#endif\n\n#ifdef __USE_GNU\ntypedef __sighandler_t sighandler_t;\n#endif\n\n/* 4.4 BSD uses the name `sig_t' for this.  */\n#ifdef __USE_MISC\ntypedef __sighandler_t sig_t;\n#endif\n\n#ifdef __USE_POSIX\n\n/* Clear all signals from SET.  */\nextern int sigemptyset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Set all signals in SET.  */\nextern int sigfillset(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Add SIGNO to SET.  */\nextern int sigaddset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Remove SIGNO from SET.  */\nextern int sigdelset(sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n/* Return 1 if SIGNO is in SET, 0 if not.  */\nextern int sigismember(const sigset_t * __set, int __signo)\n__THROW __nonnull((1));\n\n#ifdef __USE_GNU\n/* Return non-empty value is SET is not empty.  */\nextern int sigisemptyset(const sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Build new signal set by combining the two inputs set using logical AND.  */\nextern int sigandset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n\n/* Build new signal set by combining the two inputs set using logical OR.  */\nextern int sigorset(sigset_t * __set, const sigset_t * __left, const sigset_t * __right)\n__THROW __nonnull((1, 2, 3));\n#endif\t\t\t\t/* GNU */\n\n/* Get the system-specific definitions of `struct sigaction'\n   and the `SA_*' and `SIG_*'. constants.  */\n#include <bits/sigaction.h>\n\n/* Get and/or change the set of blocked signals.  */\nextern int sigprocmask(int __how, const sigset_t * __restrict __set, sigset_t * __restrict __oset) __THROW;\n\n/* Change the set of blocked signals to SET,\n   wait until a signal arrives, and restore the set of blocked signals.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigsuspend(const sigset_t * __set) __nonnull((1));\n\n/* Get and/or set the action for signal SIG.  */\nextern int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __THROW;\n\n/* Put in SET all signals that are blocked and waiting to be delivered.  */\nextern int sigpending(sigset_t * __set)\n__THROW __nonnull((1));\n\n/* Select any of pending signals from SET or wait for any to arrive.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwait(const sigset_t * __restrict __set, int *__restrict __sig) __nonnull((1, 2));\n\n#ifdef __USE_POSIX199309\n/* Select any of pending signals from SET and place information in INFO.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigwaitinfo(const sigset_t * __restrict __set, siginfo_t * __restrict __info) __nonnull((1));\n\n/* Select any of pending signals from SET and place information in INFO.\n   Wait the time specified by TIMEOUT if no signal is pending.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int sigtimedwait(const sigset_t * __restrict __set, siginfo_t * __restrict __info, const struct timespec *__restrict __timeout) __nonnull((1));\n\n/* Send signal SIG to the process PID.  Associate data in VAL with the\n   signal.  */\nextern int sigqueue(__pid_t __pid, int __sig, const union sigval __val) __THROW;\n#endif\t\t\t\t/* Use POSIX 199306.  */\n\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n\n/* Names of the signals.  This variable exists only for compatibility.\n   Use `strsignal' instead (see <string.h>).  */\nextern const char *const _sys_siglist[_NSIG];\nextern const char *const sys_siglist[_NSIG];\n\n/* Get machine-dependent `struct sigcontext' and signal subcodes.  */\n#include <bits/sigcontext.h>\n\n/* Restore the state saved in SCP.  */\nextern int sigreturn(struct sigcontext *__scp) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n#define __need_size_t\n#include <stddef.h>\n\n/* If INTERRUPT is nonzero, make signal SIG interrupt system calls\n   (causing them to fail with EINTR); if INTERRUPT is zero, make system\n   calls be restarted after signal SIG.  */\nextern int siginterrupt(int __sig, int __interrupt) __THROW;\n\n#include <bits/sigstack.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n/* This will define `ucontext_t' and `mcontext_t'.  */\n#include <sys/ucontext.h>\n#endif\n\n/* Run signals handlers on the stack specified by SS (if not NULL).\n   If OSS is not NULL, it is filled in with the old signal stack status.\n   This interface is obsolete and on many platform not implemented.  */\nextern int sigstack(struct sigstack *__ss, struct sigstack *__oss)\n__THROW __attribute_deprecated__;\n\n/* Alternate signal handler stack interface.\n   This interface should always be preferred over `sigstack'.  */\nextern int sigaltstack(const struct sigaltstack *__restrict __ss, struct sigaltstack *__restrict __oss) __THROW;\n\n#endif\t\t\t\t/* Use POSIX.1-2008 or X/Open Unix.  */\n\n#ifdef __USE_XOPEN_EXTENDED\n/* Simplified interface for signal management.  */\n\n/* Add SIG to the calling process' signal mask.  */\nextern int sighold(int __sig) __THROW;\n\n/* Remove SIG from the calling process' signal mask.  */\nextern int sigrelse(int __sig) __THROW;\n\n/* Set the disposition of SIG to SIG_IGN.  */\nextern int sigignore(int __sig) __THROW;\n\n/* Set the disposition of SIG.  */\nextern __sighandler_t sigset(int __sig, __sighandler_t __disp) __THROW;\n#endif\n\n#if defined __USE_POSIX199506 || defined __USE_UNIX98\n/* Some of the functions for handling signals in threaded programs must\n   be defined here.  */\n#include <bits/pthreadtypes.h>\n#include <bits/sigthread.h>\n#endif\t\t\t\t/* use Unix98 */\n\n/* The following functions are used internally in the C library and in\n   other code which need deep insights.  */\n\n/* Return number of available real-time signal with highest priority.  */\nextern int __libc_current_sigrtmin(void) __THROW;\n/* Return number of available real-time signal with lowest priority.  */\nextern int __libc_current_sigrtmax(void) __THROW;\n\n#endif\t\t\t\t/* signal.h  */\n\n__END_DECLS\n#endif\t\t\t\t/* not signal.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/stdc-predef.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STDC_PREDEF_H\n#define\t_STDC_PREDEF_H\t1\n\n/* This header is separate from features.h so that the compiler can\n   include it implicitly at the start of every compilation.  It must\n   not itself include <features.h> or any other header that includes\n   <features.h> because the implicit include comes before any feature\n   test macros that may be defined in a source file before it first\n   explicitly includes a system header.  GCC knows the name of this\n   header in order to preinclude it.  */\n\n/* glibc's intent is to support the IEC 559 math functionality, real\n   and complex.  If the GCC (4.9 and later) predefined macros\n   specifying compiler intent are available, use them to determine\n   whether the overall intent is to support these features; otherwise,\n   presume an older compiler has intent to support these features and\n   define these macros by default.  */\n\n#ifdef __GCC_IEC_559\n#if __GCC_IEC_559 > 0\n#define __STDC_IEC_559__\t\t1\n#endif\n#else\n#define __STDC_IEC_559__\t\t1\n#endif\n\n#ifdef __GCC_IEC_559_COMPLEX\n#if __GCC_IEC_559_COMPLEX > 0\n#define __STDC_IEC_559_COMPLEX__\t1\n#endif\n#else\n#define __STDC_IEC_559_COMPLEX__\t1\n#endif\n\n/* wchar_t uses Unicode 9.0.0.  Version 9.0 of the Unicode Standard is\n   synchronized with ISO/IEC 10646:2014, fourth edition, plus\n   Amd. 1  and Amd. 2 and 273 characters from forthcoming  10646, fifth edition.\n   (Amd. 2 was published 2016-05-01,\n   see https://www.iso.org/obp/ui/#iso:std:iso-iec:10646:ed-4:v1:amd:2:v1:en) */\n#define __STDC_ISO_10646__\t\t201605L\n\n/* We do not support C11 <threads.h>.  */\n#define __STDC_NO_THREADS__\t\t1\n\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/stdint.h",
    "content": "/* Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99: 7.18 Integer types <stdint.h>\n */\n\n#ifndef _STDINT_H\n#define _STDINT_H\t1\n\n#include <features.h>\n#include <bits/wchar.h>\n#include <bits/wordsize.h>\n\n/* Exact integral types.  */\n\n/* Signed.  */\n\n/* There is some amount of overlap with <sys/types.h> as known by inet code */\n#ifndef __int8_t_defined\n#define __int8_t_defined\ntypedef signed char int8_t;\ntypedef short int int16_t;\ntypedef int int32_t;\n#if __WORDSIZE == 64\ntypedef long int int64_t;\n#else\n__extension__ typedef long long int int64_t;\n#endif\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint8_t;\ntypedef unsigned short int uint16_t;\n#ifndef __uint32_t_defined\ntypedef unsigned int uint32_t;\n#define __uint32_t_defined\n#endif\n#if __WORDSIZE == 64\ntypedef unsigned long int uint64_t;\n#else\n__extension__ typedef unsigned long long int uint64_t;\n#endif\n\n/* Small types.  */\n\n/* Signed.  */\ntypedef signed char int_least8_t;\ntypedef short int int_least16_t;\ntypedef int int_least32_t;\n#if __WORDSIZE == 64\ntypedef long int int_least64_t;\n#else\n__extension__ typedef long long int int_least64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_least8_t;\ntypedef unsigned short int uint_least16_t;\ntypedef unsigned int uint_least32_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_least64_t;\n#else\n__extension__ typedef unsigned long long int uint_least64_t;\n#endif\n\n/* Fast types.  */\n\n/* Signed.  */\ntypedef signed char int_fast8_t;\n#if __WORDSIZE == 64\ntypedef long int int_fast16_t;\ntypedef long int int_fast32_t;\ntypedef long int int_fast64_t;\n#else\ntypedef int int_fast16_t;\ntypedef int int_fast32_t;\n__extension__ typedef long long int int_fast64_t;\n#endif\n\n/* Unsigned.  */\ntypedef unsigned char uint_fast8_t;\n#if __WORDSIZE == 64\ntypedef unsigned long int uint_fast16_t;\ntypedef unsigned long int uint_fast32_t;\ntypedef unsigned long int uint_fast64_t;\n#else\ntypedef unsigned int uint_fast16_t;\ntypedef unsigned int uint_fast32_t;\n__extension__ typedef unsigned long long int uint_fast64_t;\n#endif\n\n/* Types for `void *' pointers.  */\n#if __WORDSIZE == 64\n#ifndef __intptr_t_defined\ntypedef long int intptr_t;\n#define __intptr_t_defined\n#endif\ntypedef unsigned long int uintptr_t;\n#else\n#ifndef __intptr_t_defined\ntypedef int intptr_t;\n#define __intptr_t_defined\n#endif\ntypedef unsigned int uintptr_t;\n#endif\n\n/* Largest integral types.  */\n#if __WORDSIZE == 64\ntypedef long int intmax_t;\ntypedef unsigned long int uintmax_t;\n#else\n__extension__ typedef long long int intmax_t;\n__extension__ typedef unsigned long long int uintmax_t;\n#endif\n\n#if __WORDSIZE == 64\n#define __INT64_C(c)\tc ## L\n#define __UINT64_C(c)\tc ## UL\n#else\n#define __INT64_C(c)\tc ## LL\n#define __UINT64_C(c)\tc ## ULL\n#endif\n\n/* Limits of integral types.  */\n\n/* Minimum of signed integral types.  */\n#define INT8_MIN\t\t(-128)\n#define INT16_MIN\t\t(-32767-1)\n#define INT32_MIN\t\t(-2147483647-1)\n#define INT64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types.  */\n#define INT8_MAX\t\t(127)\n#define INT16_MAX\t\t(32767)\n#define INT32_MAX\t\t(2147483647)\n#define INT64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types.  */\n#define UINT8_MAX\t\t(255)\n#define UINT16_MAX\t\t(65535)\n#define UINT32_MAX\t\t(4294967295U)\n#define UINT64_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of signed integral types having a minimum size.  */\n#define INT_LEAST8_MIN\t\t(-128)\n#define INT_LEAST16_MIN\t(-32767-1)\n#define INT_LEAST32_MIN\t(-2147483647-1)\n#define INT_LEAST64_MIN\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of signed integral types having a minimum size.  */\n#define INT_LEAST8_MAX\t\t(127)\n#define INT_LEAST16_MAX\t(32767)\n#define INT_LEAST32_MAX\t(2147483647)\n#define INT_LEAST64_MAX\t(__INT64_C(9223372036854775807))\n\n/* Maximum of unsigned integral types having a minimum size.  */\n#define UINT_LEAST8_MAX\t(255)\n#define UINT_LEAST16_MAX\t(65535)\n#define UINT_LEAST32_MAX\t(4294967295U)\n#define UINT_LEAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Minimum of fast signed integral types having a minimum size.  */\n#define INT_FAST8_MIN\t\t(-128)\n#if __WORDSIZE == 64\n#define INT_FAST16_MIN\t(-9223372036854775807L-1)\n#define INT_FAST32_MIN\t(-9223372036854775807L-1)\n#else\n#define INT_FAST16_MIN\t(-2147483647-1)\n#define INT_FAST32_MIN\t(-2147483647-1)\n#endif\n#define INT_FAST64_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum of fast signed integral types having a minimum size.  */\n#define INT_FAST8_MAX\t\t(127)\n#if __WORDSIZE == 64\n#define INT_FAST16_MAX\t(9223372036854775807L)\n#define INT_FAST32_MAX\t(9223372036854775807L)\n#else\n#define INT_FAST16_MAX\t(2147483647)\n#define INT_FAST32_MAX\t(2147483647)\n#endif\n#define INT_FAST64_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum of fast unsigned integral types having a minimum size.  */\n#define UINT_FAST8_MAX\t\t(255)\n#if __WORDSIZE == 64\n#define UINT_FAST16_MAX\t(18446744073709551615UL)\n#define UINT_FAST32_MAX\t(18446744073709551615UL)\n#else\n#define UINT_FAST16_MAX\t(4294967295U)\n#define UINT_FAST32_MAX\t(4294967295U)\n#endif\n#define UINT_FAST64_MAX\t(__UINT64_C(18446744073709551615))\n\n/* Values to test for integral types holding `void *' pointer.  */\n#if __WORDSIZE == 64\n#define INTPTR_MIN\t\t(-9223372036854775807L-1)\n#define INTPTR_MAX\t\t(9223372036854775807L)\n#define UINTPTR_MAX\t\t(18446744073709551615UL)\n#else\n#define INTPTR_MIN\t\t(-2147483647-1)\n#define INTPTR_MAX\t\t(2147483647)\n#define UINTPTR_MAX\t\t(4294967295U)\n#endif\n\n/* Minimum for largest signed integral type.  */\n#define INTMAX_MIN\t\t(-__INT64_C(9223372036854775807)-1)\n/* Maximum for largest signed integral type.  */\n#define INTMAX_MAX\t\t(__INT64_C(9223372036854775807))\n\n/* Maximum for largest unsigned integral type.  */\n#define UINTMAX_MAX\t\t(__UINT64_C(18446744073709551615))\n\n/* Limits of other integer types.  */\n\n/* Limits of `ptrdiff_t' type.  */\n#if __WORDSIZE == 64\n#define PTRDIFF_MIN\t\t(-9223372036854775807L-1)\n#define PTRDIFF_MAX\t\t(9223372036854775807L)\n#else\n#define PTRDIFF_MIN\t\t(-2147483647-1)\n#define PTRDIFF_MAX\t\t(2147483647)\n#endif\n\n/* Limits of `sig_atomic_t'.  */\n#define SIG_ATOMIC_MIN\t\t(-2147483647-1)\n#define SIG_ATOMIC_MAX\t\t(2147483647)\n\n/* Limit of `size_t' type.  */\n#if __WORDSIZE == 64\n#define SIZE_MAX\t\t(18446744073709551615UL)\n#else\n#ifdef __WORDSIZE32_SIZE_ULONG\n#define SIZE_MAX\t\t(4294967295UL)\n#else\n#define SIZE_MAX\t\t(4294967295U)\n#endif\n#endif\n\n/* Limits of `wchar_t'.  */\n#ifndef WCHAR_MIN\n/* These constants might also be defined in <wchar.h>.  */\n#define WCHAR_MIN\t\t__WCHAR_MIN\n#define WCHAR_MAX\t\t__WCHAR_MAX\n#endif\n\n/* Limits of `wint_t'.  */\n#define WINT_MIN\t\t(0u)\n#define WINT_MAX\t\t(4294967295u)\n\n/* Signed.  */\n#define INT8_C(c)\tc\n#define INT16_C(c)\tc\n#define INT32_C(c)\tc\n#if __WORDSIZE == 64\n#define INT64_C(c)\tc ## L\n#else\n#define INT64_C(c)\tc ## LL\n#endif\n\n/* Unsigned.  */\n#define UINT8_C(c)\tc\n#define UINT16_C(c)\tc\n#define UINT32_C(c)\tc ## U\n#if __WORDSIZE == 64\n#define UINT64_C(c)\tc ## UL\n#else\n#define UINT64_C(c)\tc ## ULL\n#endif\n\n/* Maximal type.  */\n#if __WORDSIZE == 64\n#define INTMAX_C(c)\tc ## L\n#define UINTMAX_C(c)\tc ## UL\n#else\n#define INTMAX_C(c)\tc ## LL\n#define UINTMAX_C(c)\tc ## ULL\n#endif\n\n#endif\t\t\t\t/* stdint.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/stdio.h",
    "content": "/* Define ISO C stdio on top of C++ iostreams.\n   Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.19 Input/output\t<stdio.h>\n */\n\n#ifndef _STDIO_H\n\n#if !defined __need_FILE && !defined __need___FILE\n#define _STDIO_H\t1\n#include <features.h>\n\n__BEGIN_DECLS\n#define __need_size_t\n#define __need_NULL\n#include <stddef.h>\n#include <bits/types.h>\n#define __need_FILE\n#define __need___FILE\n#endif\t\t\t\t/* Don't need FILE.  */\n#if !defined __FILE_defined && defined __need_FILE\n/* Define outside of namespace so the C++ is happy.  */\n    struct _IO_FILE;\n\n__BEGIN_NAMESPACE_STD\n/* The opaque type of streams.  This is the definition used elsewhere.  */\ntypedef struct _IO_FILE FILE;\n__END_NAMESPACE_STD\n#if defined __USE_LARGEFILE64 || defined __USE_POSIX \\\n    || defined __USE_ISOC99 || defined __USE_XOPEN \\\n    || defined __USE_POSIX2\n__USING_NAMESPACE_STD(FILE)\n#endif\n#define __FILE_defined\t1\n#endif\t\t\t\t/* FILE not defined.  */\n#undef\t__need_FILE\n#if !defined ____FILE_defined && defined __need___FILE\n/* The opaque type of streams.  This is the definition used elsewhere.  */\ntypedef struct _IO_FILE __FILE;\n\n#define ____FILE_defined\t1\n#endif\t\t\t\t/* __FILE not defined.  */\n#undef\t__need___FILE\n\n#ifdef\t_STDIO_H\n#define _STDIO_USES_IOSTREAM\n\n#include <libio.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K8\n#ifdef __GNUC__\n#ifndef _VA_LIST_DEFINED\ntypedef _G_va_list va_list;\n#define _VA_LIST_DEFINED\n#endif\n#else\n#include <stdarg.h>\n#endif\n#endif\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#define __off64_t_defined\n#endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n#ifndef __ssize_t_defined\ntypedef __ssize_t ssize_t;\n#define __ssize_t_defined\n#endif\n#endif\n\n/* The type of the second argument to `fgetpos' and `fsetpos'.  */\n__BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\ntypedef _G_fpos_t fpos_t;\n#else\ntypedef _G_fpos64_t fpos_t;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\ntypedef _G_fpos64_t fpos64_t;\n#endif\n\n/* The possibilities for the third argument to `setvbuf'.  */\n#define _IOFBF 0\t\t/* Fully buffered.  */\n#define _IOLBF 1\t\t/* Line buffered.  */\n#define _IONBF 2\t\t/* No buffering.  */\n\n/* Default buffer size.  */\n#ifndef BUFSIZ\n#define BUFSIZ _IO_BUFSIZ\n#endif\n\n/* End of file character.\n   Some things throughout the library rely on this being -1.  */\n#ifndef EOF\n#define EOF (-1)\n#endif\n\n/* The possibilities for the third argument to `fseek'.\n   These values should not be changed.  */\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n#define SEEK_END\t2\t/* Seek from end of file.  */\n#ifdef __USE_GNU\n#define SEEK_DATA\t3\t/* Seek to next data.  */\n#define SEEK_HOLE\t4\t/* Seek to next hole.  */\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Default path prefix for `tempnam' and `tmpnam'.  */\n#define P_tmpdir\t\"/tmp\"\n#endif\n\n/* Get the values:\n   L_tmpnam\tHow long an array of chars must be to be passed to `tmpnam'.\n   TMP_MAX\tThe minimum number of unique filenames generated by tmpnam\n\t\t(and tempnam when it uses tmpnam's name space),\n\t\tor tempnam (the two are separate).\n   L_ctermid\tHow long an array to pass to `ctermid'.\n   L_cuserid\tHow long an array to pass to `cuserid'.\n   FOPEN_MAX\tMinimum number of files that can be open at once.\n   FILENAME_MAX\tMaximum length of a filename.  */\n#include <bits/stdio_lim.h>\n\n/* Standard streams.  */\nextern struct _IO_FILE *stdin;\t/* Standard input stream.  */\nextern struct _IO_FILE *stdout;\t/* Standard output stream.  */\nextern struct _IO_FILE *stderr;\t/* Standard error output stream.  */\n/* C89/C99 say they're macros.  Make them happy.  */\n#define stdin stdin\n#define stdout stdout\n#define stderr stderr\n\n__BEGIN_NAMESPACE_STD\n/* Remove file FILENAME.  */\nextern int remove(const char *__filename) __THROW;\n/* Rename file OLD to NEW.  */\nextern int rename(const char *__old, const char *__new) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ATFILE\n/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */\nextern int renameat(int __oldfd, const char *__old, int __newfd, const char *__new) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Create a temporary file and open it read/write.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern FILE *tmpfile(void) __wur;\n#else\n#ifdef __REDIRECT\nextern FILE *__REDIRECT(tmpfile, (void), tmpfile64) __wur;\n#else\n#define tmpfile tmpfile64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern FILE *tmpfile64(void) __wur;\n#endif\n\n/* Generate a temporary filename.  */\nextern char *tmpnam(char *__s)\n__THROW __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* This is the reentrant variant of `tmpnam'.  The only difference is\n   that it does not allow S to be NULL.  */\nextern char *tmpnam_r(char *__s)\n__THROW __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Generate a unique temporary filename using up to five characters of PFX\n   if it is not NULL.  The directory to put this file in is searched for\n   as follows: First the environment variable \"TMPDIR\" is checked.\n   If it contains the name of a writable directory, that directory is used.\n   If not and if DIR is not NULL, that value is checked.  If that fails,\n   P_tmpdir is tried and finally \"/tmp\".  The storage for the filename\n   is allocated by `malloc'.  */\nextern char *tempnam(const char *__dir, const char *__pfx)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Close STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fclose(FILE * __stream);\n/* Flush STREAM, or all streams if STREAM is NULL.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fflush(FILE * __stream);\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fflush_unlocked(FILE * __stream);\n#endif\n\n#ifdef __USE_GNU\n/* Close all streams.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fcloseall(void);\n#endif\n\n__BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\n/* Open a file and create a new stream for it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *fopen(const char *__restrict __filename, const char *__restrict __modes) __wur;\n/* Open a file, replacing an existing stream with it.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *freopen(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#else\n#ifdef __REDIRECT\nextern FILE *__REDIRECT(fopen, (const char *__restrict __filename, const char *__restrict __modes), fopen64) __wur;\nextern FILE *__REDIRECT(freopen, (const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream), freopen64) __wur;\n#else\n#define fopen fopen64\n#define freopen freopen64\n#endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\nextern FILE *fopen64(const char *__restrict __filename, const char *__restrict __modes) __wur;\nextern FILE *freopen64(const char *__restrict __filename, const char *__restrict __modes, FILE * __restrict __stream) __wur;\n#endif\n\n#ifdef\t__USE_POSIX\n/* Create a new stream that refers to an existing system file descriptor.  */\nextern FILE *fdopen(int __fd, const char *__modes)\n__THROW __wur;\n#endif\n\n#ifdef\t__USE_GNU\n/* Create a new stream that refers to the given magic cookie,\n   and uses the given functions for input and output.  */\nextern FILE *fopencookie(void *__restrict __magic_cookie, const char *__restrict __modes, _IO_cookie_io_functions_t __io_funcs)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Create a new stream that refers to a memory buffer.  */\nextern FILE *fmemopen(void *__s, size_t __len, const char *__modes)\n__THROW __wur;\n\n/* Open a stream that writes into a malloc'd buffer that is expanded as\n   necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location\n   and the number of characters written on fflush or fclose.  */\nextern FILE *open_memstream(char **__bufloc, size_t * __sizeloc)\n__THROW __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use buffer BUF, of size BUFSIZ.  */\nextern void setbuf(FILE * __restrict __stream, char *__restrict __buf) __THROW;\n/* Make STREAM use buffering mode MODE.\n   If BUF is not NULL, use N bytes of it for buffering;\n   else allocate an internal buffer N bytes long.  */\nextern int setvbuf(FILE * __restrict __stream, char *__restrict __buf, int __modes, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* If BUF is NULL, make STREAM unbuffered.\n   Else make it use SIZE bytes of BUF for buffering.  */\nextern void setbuffer(FILE * __restrict __stream, char *__restrict __buf, size_t __size) __THROW;\n\n/* Make STREAM line-buffered.  */\nextern void setlinebuf(FILE * __stream) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fprintf(FILE * __restrict __stream, const char *__restrict __format, ...);\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int printf(const char *__restrict __format, ...);\n/* Write formatted output to S.  */\nextern int sprintf(char *__restrict __s, const char *__restrict __format, ...) __THROWNL;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfprintf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vprintf(const char *__restrict __format, _G_va_list __arg);\n/* Write formatted output to S from argument list ARG.  */\nextern int vsprintf(char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROWNL;\n__END_NAMESPACE_STD\n#if defined __USE_ISOC99 || defined __USE_UNIX98\n    __BEGIN_NAMESPACE_C99\n/* Maximum chars of output to write in MAXLEN.  */\nextern int snprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 4)));\n\nextern int vsnprintf(char *__restrict __s, size_t __maxlen, const char *__restrict __format, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 3, 0)));\n__END_NAMESPACE_C99\n#endif\n#ifdef __USE_GNU\n/* Write formatted output to a string dynamically allocated with `malloc'.\n   Store the address of the string in *PTR.  */\nextern int vasprintf(char **__restrict __ptr, const char *__restrict __f, _G_va_list __arg)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0))) __wur;\nextern int __asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\nextern int asprintf(char **__restrict __ptr, const char *__restrict __fmt, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3))) __wur;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Write formatted output to a file descriptor.  */\nextern int vdprintf(int __fd, const char *__restrict __fmt, _G_va_list __arg)\n    __attribute__ ((__format__(__printf__, 2, 0)));\nextern int dprintf(int __fd, const char *__restrict __fmt, ...)\n    __attribute__ ((__format__(__printf__, 2, 3)));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int scanf(const char *__restrict __format, ...) __wur;\n/* Read formatted input from S.  */\nextern int sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n\n#if defined __USE_ISOC99 && !defined __USE_GNU \\\n    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fscanf, (FILE * __restrict __stream, const char *__restrict __format, ...), __isoc99_fscanf) __wur;\nextern int __REDIRECT(scanf, (const char *__restrict __format, ...), __isoc99_scanf) __wur;\nextern int __REDIRECT_NTH(sscanf, (const char *__restrict __s, const char *__restrict __format, ...), __isoc99_sscanf);\n#else\nextern int __isoc99_fscanf(FILE * __restrict __stream, const char *__restrict __format, ...) __wur;\nextern int __isoc99_scanf(const char *__restrict __format, ...) __wur;\nextern int __isoc99_sscanf(const char *__restrict __s, const char *__restrict __format, ...) __THROW;\n#define fscanf __isoc99_fscanf\n#define scanf __isoc99_scanf\n#define sscanf __isoc99_sscanf\n#endif\n#endif\n\n__END_NAMESPACE_STD\n#ifdef\t__USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\n\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vscanf(const char *__restrict __format, _G_va_list __arg)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\n\n/* Read formatted input from S into argument list ARG.  */\nextern int vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg)\n__THROW __attribute__ ((__format__(__scanf__, 2, 0)));\n\n#if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(vfscanf, (FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vfscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0))) __wur;\nextern int __REDIRECT(vscanf, (const char *__restrict __format, _G_va_list __arg), __isoc99_vscanf)\n    __attribute__ ((__format__(__scanf__, 1, 0))) __wur;\nextern int __REDIRECT_NTH(vsscanf, (const char *__restrict __s, const char *__restrict __format, _G_va_list __arg), __isoc99_vsscanf)\n    __attribute__ ((__format__(__scanf__, 2, 0)));\n#else\nextern int __isoc99_vfscanf(FILE * __restrict __s, const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vscanf(const char *__restrict __format, _G_va_list __arg) __wur;\nextern int __isoc99_vsscanf(const char *__restrict __s, const char *__restrict __format, _G_va_list __arg) __THROW;\n#define vfscanf __isoc99_vfscanf\n#define vscanf __isoc99_vscanf\n#define vsscanf __isoc99_vsscanf\n#endif\n#endif\n\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* Use ISO C9x.  */\n    __BEGIN_NAMESPACE_STD\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int fgetc(FILE * __stream);\nextern int getc(FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getchar(void);\n__END_NAMESPACE_STD\n/* The C standard explicitly says this is a macro, so we always do the\n   optimization for it.  */\n#define getc(_fp) _IO_getc (_fp)\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int getc_unlocked(FILE * __stream);\nextern int getchar_unlocked(void);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fgetc_unlocked(FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n__BEGIN_NAMESPACE_STD\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.\n\n   These functions is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputc(int __c, FILE * __stream);\nextern int putc(int __c, FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int putchar(int __c);\n__END_NAMESPACE_STD\n/* The C standard explicitly says this can be a macro,\n   so we always do the optimization for it.  */\n#define putc(_ch, _fp) _IO_putc (_ch, _fp)\n#ifdef __USE_MISC\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputc_unlocked(int __c, FILE * __stream);\n#endif\t\t\t\t/* Use MISC.  */\n\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern int putc_unlocked(int __c, FILE * __stream);\nextern int putchar_unlocked(int __c);\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Get a word (int) from STREAM.  */\nextern int getw(FILE * __stream);\n\n/* Write a word (int) to STREAM.  */\nextern int putw(int __w, FILE * __stream);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Get a newline-terminated string of finite length from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *fgets(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n\n#if !defined __USE_ISOC11 \\\n    || (defined __cplusplus && __cplusplus <= 201103L)\n/* Get a newline-terminated string from stdin, removing the newline.\n   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.\n\n   The function has been officially removed in ISO C11.  This opportunity\n   is used to also remove it from the GNU feature list.  It is now only\n   available when explicitly using an old ISO C, Unix, or POSIX standard.\n   GCC defines _GNU_SOURCE when building C++ code and the function is still\n   in C++11, so it is also available for C++.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *gets(char *__s)\n__wur __attribute_deprecated__;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function does the same as `fgets' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern char *fgets_unlocked(char *__restrict __s, int __n, FILE * __restrict __stream) __wur;\n#endif\n\n#ifdef\t__USE_XOPEN2K8\n/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR\n   (and null-terminate it). *LINEPTR is a pointer returned from malloc (or\n   NULL), pointing to *N characters of space.  It is realloc'd as\n   necessary.  Returns the number of characters read (not including the\n   null terminator), or -1 on error or EOF.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t __getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\nextern _IO_ssize_t getdelim(char **__restrict __lineptr, size_t * __restrict __n, int __delimiter, FILE * __restrict __stream) __wur;\n\n/* Like `getdelim', but reads up to a newline.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern _IO_ssize_t getline(char **__restrict __lineptr, size_t * __restrict __n, FILE * __restrict __stream) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputs(const char *__restrict __s, FILE * __restrict __stream);\n\n/* Write a string, followed by a newline, to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int puts(const char *__s);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int ungetc(int __c, FILE * __stream);\n\n/* Read chunks of generic data from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fread(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\n/* Write chunks of generic data to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern size_t fwrite(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __s);\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function does the same as `fputs' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputs_unlocked(const char *__restrict __s, FILE * __restrict __stream);\n#endif\n\n#ifdef __USE_MISC\n/* Faster versions when locking is not necessary.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern size_t fread_unlocked(void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream) __wur;\nextern size_t fwrite_unlocked(const void *__restrict __ptr, size_t __size, size_t __n, FILE * __restrict __stream);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseek(FILE * __stream, long int __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern long int ftell(FILE * __stream) __wur;\n/* Rewind to the beginning of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void rewind(FILE * __stream);\n__END_NAMESPACE_STD\n/* The Single Unix Specification, Version 2, specifies an alternative,\n   more adequate interface for the two functions above which deal with\n   file offset.  `long int' is not the right type.  These definitions\n   are originally defined in the Large File Support API.  */\n#if defined __USE_LARGEFILE || defined __USE_XOPEN2K\n#ifndef __USE_FILE_OFFSET64\n/* Seek to a certain position on STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fseeko(FILE * __stream, __off_t __off, int __whence);\n/* Return the current position of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern __off_t ftello(FILE * __stream) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(fseeko, (FILE * __stream, __off64_t __off, int __whence), fseeko64);\nextern __off64_t __REDIRECT(ftello, (FILE * __stream), ftello64);\n#else\n#define fseeko fseeko64\n#define ftello ftello64\n#endif\n#endif\n#endif\n    __BEGIN_NAMESPACE_STD\n#ifndef __USE_FILE_OFFSET64\n/* Get STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fgetpos(FILE * __restrict __stream, fpos_t * __restrict __pos);\n/* Set STREAM's position.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fsetpos(FILE * __stream, const fpos_t * __pos);\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(fgetpos, (FILE * __restrict __stream, fpos_t * __restrict __pos), fgetpos64);\nextern int __REDIRECT(fsetpos, (FILE * __stream, const fpos_t * __pos), fsetpos64);\n#else\n#define fgetpos fgetpos64\n#define fsetpos fsetpos64\n#endif\n#endif\n    __END_NAMESPACE_STD\n#ifdef __USE_LARGEFILE64\nextern int fseeko64(FILE * __stream, __off64_t __off, int __whence);\nextern __off64_t ftello64(FILE * __stream) __wur;\nextern int fgetpos64(FILE * __restrict __stream, fpos64_t * __restrict __pos);\nextern int fsetpos64(FILE * __stream, const fpos64_t * __pos);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Clear the error and EOF indicators for STREAM.  */\nextern void clearerr(FILE * __stream) __THROW;\n/* Return the EOF indicator for STREAM.  */\nextern int feof(FILE * __stream)\n__THROW __wur;\n/* Return the error indicator for STREAM.  */\nextern int ferror(FILE * __stream)\n__THROW __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Faster versions when locking is not required.  */\nextern void clearerr_unlocked(FILE * __stream) __THROW;\nextern int feof_unlocked(FILE * __stream)\n__THROW __wur;\nextern int ferror_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Print a message describing the meaning of the value of errno.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern void perror(const char *__s);\n__END_NAMESPACE_STD\n/* Provide the declarations for `sys_errlist' and `sys_nerr' if they\n   are available on this system.  Even if available, these variables\n   should not be used directly.  The `strerror' function provides\n   all the necessary functionality.  */\n#include <bits/sys_errlist.h>\n#ifdef\t__USE_POSIX\n/* Return the system file descriptor for STREAM.  */\nextern int fileno(FILE * __stream)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#ifdef __USE_MISC\n/* Faster version when locking is not required.  */\nextern int fileno_unlocked(FILE * __stream)\n__THROW __wur;\n#endif\n\n#ifdef __USE_POSIX2\n/* Create a new stream connected to a pipe running the given command.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern FILE *popen(const char *__command, const char *__modes) __wur;\n\n/* Close a stream opened by popen and return the status of its child.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int pclose(FILE * __stream);\n#endif\n\n#ifdef\t__USE_POSIX\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n#endif\t\t\t\t/* Use POSIX.  */\n\n#if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU\n/* Return the name of the current user.  */\nextern char *cuserid(char *__s);\n#endif\t\t\t\t/* Use X/Open, but not issue 6.  */\n\n#ifdef\t__USE_GNU\nstruct obstack;\t\t\t/* See <obstack.h>.  */\n\n/* Write formatted output to an obstack.  */\nextern int obstack_printf(struct obstack *__restrict __obstack, const char *__restrict __format, ...)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 3)));\nextern int obstack_vprintf(struct obstack *__restrict __obstack, const char *__restrict __format, _G_va_list __args)\n__THROWNL __attribute__ ((__format__(__printf__, 2, 0)));\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_POSIX199506\n/* These are defined in POSIX.1:1996.  */\n\n/* Acquire ownership of STREAM.  */\nextern void flockfile(FILE * __stream) __THROW;\n\n/* Try to acquire ownership of STREAM but do not block if it is not\n   possible.  */\nextern int ftrylockfile(FILE * __stream)\n__THROW __wur;\n\n/* Relinquish the ownership granted for STREAM.  */\nextern void funlockfile(FILE * __stream) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU\n/* The X/Open standard requires some functions and variables to be\n   declared here which do not belong into this header.  But we have to\n   follow.  In GNU mode we don't do this nonsense.  */\n#define __need_getopt\n#include <getopt.h>\n#endif\t\t\t\t/* X/Open, but not issue 6 and not for GNU.  */\n\n/* If we are compiling with optimizing read this file.  It contains\n   several optimizing inline functions and macros.  */\n#ifdef __USE_EXTERN_INLINES\n#include <bits/stdio.h>\n#endif\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n#include <bits/stdio2.h>\n#endif\n#ifdef __LDBL_COMPAT\n#include <bits/stdio-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* <stdio.h> included.  */\n#endif\t\t\t\t/* !_STDIO_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/stdlib.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.20 General utilities\t<stdlib.h>\n */\n\n#ifndef\t_STDLIB_H\n\n#include <features.h>\n\n/* Get size_t, wchar_t and NULL from <stddef.h>.  */\n#define\t\t__need_size_t\n#ifndef __need_malloc_and_calloc\n#define\t__need_wchar_t\n#define\t__need_NULL\n#endif\n#include <stddef.h>\n\n__BEGIN_DECLS\n#ifndef __need_malloc_and_calloc\n#define\t_STDLIB_H\t1\n#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H\n/* XPG requires a few symbols from <sys/wait.h> being defined.  */\n#include <bits/waitflags.h>\n#include <bits/waitstatus.h>\n/* Define the macros <sys/wait.h> also would define this way.  */\n#define WEXITSTATUS(status)\t__WEXITSTATUS (status)\n#define WTERMSIG(status)\t__WTERMSIG (status)\n#define WSTOPSIG(status)\t__WSTOPSIG (status)\n#define WIFEXITED(status)\t__WIFEXITED (status)\n#define WIFSIGNALED(status)\t__WIFSIGNALED (status)\n#define WIFSTOPPED(status)\t__WIFSTOPPED (status)\n#ifdef __WIFCONTINUED\n#define WIFCONTINUED(status)\t__WIFCONTINUED (status)\n#endif\n#endif\t\t\t\t/* X/Open or XPG7 and <sys/wait.h> not included.  */\n    __BEGIN_NAMESPACE_STD\n/* Returned by `div'.  */\n    typedef struct {\n\tint quot;\t\t/* Quotient.  */\n\tint rem;\t\t/* Remainder.  */\n} div_t;\n\n/* Returned by `ldiv'.  */\n#ifndef __ldiv_t_defined\ntypedef struct {\n\tlong int quot;\t\t/* Quotient.  */\n\tlong int rem;\t\t/* Remainder.  */\n} ldiv_t;\n#define __ldiv_t_defined\t1\n#endif\n__END_NAMESPACE_STD\n#if defined __USE_ISOC99 && !defined __lldiv_t_defined\n    __BEGIN_NAMESPACE_C99\n/* Returned by `lldiv'.  */\n    __extension__ typedef struct {\n\tlong long int quot;\t/* Quotient.  */\n\tlong long int rem;\t/* Remainder.  */\n} lldiv_t;\n#define __lldiv_t_defined\t1\n__END_NAMESPACE_C99\n#endif\n/* The largest number rand will return (same as INT_MAX).  */\n#define\tRAND_MAX\t2147483647\n/* We define these the same for all machines.\n   Changes from this to the outside world should be done in `_exit'.  */\n#define\tEXIT_FAILURE\t1\t/* Failing exit status.  */\n#define\tEXIT_SUCCESS\t0\t/* Successful exit status.  */\n/* Maximum length of a multibyte character in the current locale.  */\n#define\tMB_CUR_MAX\t(__ctype_get_mb_cur_max ())\nextern size_t __ctype_get_mb_cur_max(void)\n__THROW __wur;\n\n__BEGIN_NAMESPACE_STD\n/* Convert a string to a floating-point number.  */\nextern double atof(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to an integer.  */\nextern int atoi(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n/* Convert a string to a long integer.  */\nextern long int atol(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Convert a string to a long long integer.  */\n__extension__ extern long long int atoll(const char *__nptr)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Convert a string to a floating-point number.  */\nextern double strtod(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef\t__USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float strtof(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n\nextern long double strtold(const char *__restrict __nptr, char **__restrict __endptr)\n__THROW __nonnull((1));\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Convert a string to a long integer.  */\nextern long int strtol(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned long integer.  */\nextern unsigned long int strtoul(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtouq(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99\n/* Convert a string to a quadword integer.  */\n__extension__ extern long long int strtoll(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n/* Convert a string to an unsigned quadword integer.  */\n__extension__ extern unsigned long long int strtoull(const char *__restrict __nptr, char **__restrict __endptr, int __base)\n__THROW __nonnull((1));\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* ISO C99 or use MISC.  */\n#ifdef __USE_GNU\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another problem is\n   the implementation of the internationalization handling in the\n   ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which take an additional\n   argument.\n\n   Attention: even though several *_l interfaces are part of POSIX:2008,\n   these are not.  */\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n#include <xlocale.h>\n/* Special versions of the functions above which take the locale to\n   use as an additional parameter.  */\nextern long int strtol_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern unsigned long int strtoul_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern long long int strtoll_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\n__extension__ extern unsigned long long int strtoull_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, __locale_t __loc)\n__THROW __nonnull((1, 4));\n\nextern double strtod_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern float strtof_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n\nextern long double strtold_l(const char *__restrict __nptr, char **__restrict __endptr, __locale_t __loc)\n__THROW __nonnull((1, 3));\n#endif\t\t\t\t/* GNU */\n\n#ifdef __USE_EXTERN_INLINES\n__BEGIN_NAMESPACE_STD __extern_inline int __NTH(atoi(const char *__nptr))\n{\n\treturn (int)strtol(__nptr, (char **)NULL, 10);\n}\n\n__extern_inline long int __NTH(atol(const char *__nptr))\n{\n\treturn strtol(__nptr, (char **)NULL, 10);\n}\n\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99 __extension__ __extern_inline long long int __NTH(atoll(const char *__nptr))\n{\n\treturn strtoll(__nptr, (char **)NULL, 10);\n}\n\n__END_NAMESPACE_C99\n#endif\n#endif\t\t\t\t/* Optimizing and Inlining.  */\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Convert N to base 64 using the digits \"./0-9A-Za-z\", least-significant\n   digit first.  Returns a pointer to static storage overwritten by the\n   next call.  */\nextern char *l64a(long int __n)\n__THROW __wur;\n\n/* Read a number from a string S in base 64 as above.  */\nextern long int a64l(const char *__s)\n__THROW __attribute_pure__ __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use misc || extended X/Open.  */\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n#include <sys/types.h>\t\t/* we need int32_t... */\n\n/* These are the functions that actually do things.  The `random', `srandom',\n   `initstate' and `setstate' functions are those from BSD Unices.\n   The `rand' and `srand' functions are required by the ANSI standard.\n   We provide both interfaces to the same random number generator.  */\n/* Return a random long integer between 0 and RAND_MAX inclusive.  */\nextern long int random(void) __THROW;\n\n/* Seed the random number generator with the given number.  */\nextern void srandom(unsigned int __seed) __THROW;\n\n/* Initialize the random number generator to use state buffer STATEBUF,\n   of length STATELEN, and seed it with SEED.  Optimal lengths are 8, 16,\n   32, 64, 128 and 256, the bigger the better; values less than 8 will\n   cause an error and values greater than 256 will be rounded down.  */\nextern char *initstate(unsigned int __seed, char *__statebuf, size_t __statelen)\n__THROW __nonnull((2));\n\n/* Switch the random number generator to state buffer STATEBUF,\n   which should have been previously initialized by `initstate'.  */\nextern char *setstate(char *__statebuf)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Reentrant versions of the `random' family of functions.\n   These functions all use the following data structure to contain\n   state, rather than global state variables.  */\n\nstruct random_data {\n\tint32_t *fptr;\t\t/* Front pointer.  */\n\tint32_t *rptr;\t\t/* Rear pointer.  */\n\tint32_t *state;\t\t/* Array of state values.  */\n\tint rand_type;\t\t/* Type of random number generator.  */\n\tint rand_deg;\t\t/* Degree of random number generator.  */\n\tint rand_sep;\t\t/* Distance between front and rear.  */\n\tint32_t *end_ptr;\t/* Pointer behind state table.  */\n};\n\nextern int random_r(struct random_data *__restrict __buf, int32_t * __restrict __result)\n__THROW __nonnull((1, 2));\n\nextern int srandom_r(unsigned int __seed, struct random_data *__buf)\n__THROW __nonnull((2));\n\nextern int initstate_r(unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf)\n__THROW __nonnull((2, 4));\n\nextern int setstate_r(char *__restrict __statebuf, struct random_data *__restrict __buf)\n__THROW __nonnull((1, 2));\n#endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use extended X/Open || misc. */\n\n__BEGIN_NAMESPACE_STD\n/* Return a random integer between 0 and RAND_MAX inclusive.  */\nextern int rand(void) __THROW;\n/* Seed the random number generator with the given number.  */\nextern void srand(unsigned int __seed) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX199506\n/* Reentrant interface according to POSIX.1.  */\nextern int rand_r(unsigned int *__seed) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* System V style 48-bit random number generator functions.  */\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern double drand48(void) __THROW;\nextern double erand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern long int lrand48(void) __THROW;\nextern long int nrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern long int mrand48(void) __THROW;\nextern long int jrand48(unsigned short int __xsubi[3])\n__THROW __nonnull((1));\n\n/* Seed random number generator.  */\nextern void srand48(long int __seedval) __THROW;\nextern unsigned short int *seed48(unsigned short int __seed16v[3])\n__THROW __nonnull((1));\nextern void lcong48(unsigned short int __param[7])\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Data structure for communication with thread safe versions.  This\n   type is to be regarded as opaque.  It's only exported because users\n   have to allocate objects of this type.  */\nstruct drand48_data {\n\tunsigned short int __x[3];\t/* Current state.  */\n\tunsigned short int __old_x[3];\t/* Old state.  */\n\tunsigned short int __c;\t/* Additive const. in congruential formula.  */\n\tunsigned short int __init;\t/* Flag for initializing.  */\n\t__extension__ unsigned long long int __a;\t/* Factor in congruential\n\t\t\t\t\t\t\t   formula.  */\n};\n\n/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */\nextern int drand48_r(struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int erand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return non-negative, long integer in [0,2^31).  */\nextern int lrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int nrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Return signed, long integers in [-2^31,2^31).  */\nextern int mrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\nextern int jrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result)\n__THROW __nonnull((1, 2));\n\n/* Seed random number generator.  */\nextern int srand48_r(long int __seedval, struct drand48_data *__buffer)\n__THROW __nonnull((2));\n\nextern int seed48_r(unsigned short int __seed16v[3], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n\nextern int lcong48_r(unsigned short int __param[7], struct drand48_data *__buffer)\n__THROW __nonnull((1, 2));\n#endif\t\t\t\t/* Use misc.  */\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n#endif\t\t\t\t/* don't just need malloc and calloc */\n\n#ifndef __malloc_and_calloc_defined\n#define __malloc_and_calloc_defined\n__BEGIN_NAMESPACE_STD\n/* Allocate SIZE bytes of memory.  */\nextern void *malloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */\nextern void *calloc(size_t __nmemb, size_t __size)\n__THROW __attribute_malloc__ __wur;\n__END_NAMESPACE_STD\n#endif\n#ifndef __need_malloc_and_calloc\n    __BEGIN_NAMESPACE_STD\n/* Re-allocate the previously allocated block\n   in PTR, making the new block SIZE bytes long.  */\n/* __attribute_malloc__ is not used, because if realloc returns\n   the same pointer that was passed to it, aliasing needs to be allowed\n   between objects pointed by the old and new pointers.  */\nextern void *realloc(void *__ptr, size_t __size)\n__THROW __attribute_warn_unused_result__;\n/* Free a block allocated by `malloc', `realloc' or `calloc'.  */\nextern void free(void *__ptr) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* Free a block.  An alias for `free'.\t(Sun Unices).  */\nextern void cfree(void *__ptr) __THROW;\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef __USE_MISC\n#include <alloca.h>\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n/* Allocate SIZE bytes on a page boundary.  The storage cannot be freed.  */\nextern void *valloc(size_t __size)\n__THROW __attribute_malloc__ __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT.  */\nextern int posix_memalign(void **__memptr, size_t __alignment, size_t __size)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_ISOC11\n/* ISO C variant of aligned allocation.  */\nextern void *aligned_alloc(size_t __alignment, size_t __size)\n__THROW __attribute_malloc__ __attribute_alloc_size__((2)) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Abort execution and generate a core-dump.  */\nextern void abort(void)\n__THROW __attribute__ ((__noreturn__));\n\n/* Register a function to be called when `exit' is called.  */\nextern int atexit(void (*__func) (void))\n__THROW __nonnull((1));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Register a function to be called when `quick_exit' is called.  */\n#ifdef __cplusplus\nextern \"C++\" int at_quick_exit(void (*__func) (void))\n__THROW __asm(\"at_quick_exit\") __nonnull((1));\n#else\nextern int at_quick_exit(void (*__func) (void))\n__THROW __nonnull((1));\n#endif\n#endif\n__END_NAMESPACE_STD\n#ifdef\t__USE_MISC\n/* Register a function to be called with the status\n   given to `exit' and the given argument.  */\nextern int on_exit(void (*__func) (int __status, void *__arg), void *__arg)\n__THROW __nonnull((1));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Call all functions registered with `atexit' and `on_exit',\n   in the reverse of the order in which they were registered,\n   perform stdio cleanup, and terminate program execution with STATUS.  */\nextern void exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n\n#if defined __USE_ISOC11 || defined __USE_ISOCXX11\n/* Call all functions registered with `at_quick_exit' in the reverse\n   of the order in which they were registered and terminate program\n   execution with STATUS.  */\nextern void quick_exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Terminate the program with STATUS without calling any of the\n   functions registered with `atexit' or `on_exit'.  */\nextern void _Exit(int __status)\n__THROW __attribute__ ((__noreturn__));\n__END_NAMESPACE_C99\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Return the value of envariable NAME, or NULL if it doesn't exist.  */\nextern char *getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to the above but returns NULL if the\n   programs is running with SUID or SGID enabled.  */\nextern char *secure_getenv(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* The SVID says this is in <stdio.h>, but this seems a better place.\t*/\n/* Put STRING, which is of the form \"NAME=VALUE\", in the environment.\n   If there is no `=', remove NAME from the environment.  */\nextern int putenv(char *__string)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set NAME to VALUE in the environment.\n   If REPLACE is nonzero, overwrite an existing value.  */\nextern int setenv(const char *__name, const char *__value, int __replace)\n__THROW __nonnull((2));\n\n/* Remove the variable NAME from the environment.  */\nextern int unsetenv(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* The `clearenv' was planned to be added to POSIX.1 but probably\n   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings\n   for Fortran 77) requires this function.  */\nextern int clearenv(void) __THROW;\n#endif\n\n#if defined __USE_MISC \\\n    || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8)\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the file name unique.\n   Always returns TEMPLATE, it's either a temporary file name or a null\n   string if it cannot get a unique file name.  */\nextern char *mktemp(char *__template)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Generate a unique temporary file name from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the filename unique.\n   Returns a file descriptor open on the file for reading and writing,\n   or -1 if it cannot create a uniquely-named file.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int mkstemp(char *__template) __nonnull((1)) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(mkstemp, (char *__template), mkstemp64) __nonnull((1)) __wur;\n#else\n#define mkstemp mkstemp64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int mkstemp64(char *__template) __nonnull((1)) __wur;\n#endif\n#endif\n\n#ifdef __USE_MISC\n/* Similar to mkstemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int mkstemps(char *__template, int __suffixlen) __nonnull((1)) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(mkstemps, (char *__template, int __suffixlen), mkstemps64) __nonnull((1)) __wur;\n#else\n#define mkstemps mkstemps64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int mkstemps64(char *__template, int __suffixlen) __nonnull((1)) __wur;\n#endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Create a unique temporary directory from TEMPLATE.\n   The last six characters of TEMPLATE must be \"XXXXXX\";\n   they are replaced with a string that makes the directory name unique.\n   Returns TEMPLATE, or a null pointer if it cannot get a unique name.\n   The directory is created mode 700.  */\nextern char *mkdtemp(char *__template)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Generate a unique temporary file name from TEMPLATE similar to\n   mkstemp.  But allow the caller to pass additional flags which are\n   used in the open call to create the file..\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int mkostemp(char *__template, int __flags) __nonnull((1)) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(mkostemp, (char *__template, int __flags), mkostemp64) __nonnull((1)) __wur;\n#else\n#define mkostemp mkostemp64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int mkostemp64(char *__template, int __flags) __nonnull((1)) __wur;\n#endif\n\n/* Similar to mkostemp, but the template can have a suffix after the\n   XXXXXX.  The length of the suffix is specified in the second\n   parameter.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\n#ifndef __USE_FILE_OFFSET64\nextern int mkostemps(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(mkostemps, (char *__template, int __suffixlen, int __flags), mkostemps64) __nonnull((1)) __wur;\n#else\n#define mkostemps mkostemps64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int mkostemps64(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur;\n#endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Execute the given line as a shell command.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int system(const char *__command) __wur;\n__END_NAMESPACE_STD\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the canonical absolute name of the\n   existing named file.  */\nextern char *canonicalize_file_name(const char *__name)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Return the canonical absolute name of file NAME.  If RESOLVED is\n   null, the result is malloc'd; otherwise, if the canonical name is\n   PATH_MAX chars or more, returns null with `errno' set to\n   ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,\n   returns the name in RESOLVED.  */\nextern char *realpath(const char *__restrict __name, char *__restrict __resolved)\n__THROW __wur;\n#endif\n\n/* Shorthand for type of comparison functions.  */\n#ifndef __COMPAR_FN_T\n#define __COMPAR_FN_T\ntypedef int (*__compar_fn_t) (const void *, const void *);\n\n#ifdef\t__USE_GNU\ntypedef __compar_fn_t comparison_fn_t;\n#endif\n#endif\n#ifdef __USE_GNU\ntypedef int (*__compar_d_fn_t) (const void *, const void *, void *);\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Do a binary search for KEY in BASE, which consists of NMEMB elements\n   of SIZE bytes each, using COMPAR to perform the comparisons.  */\nextern void *bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 2, 5)) __wur;\n\n#ifdef __USE_EXTERN_INLINES\n#include <bits/stdlib-bsearch.h>\n#endif\n\n/* Sort NMEMB elements of BASE, of SIZE bytes each,\n   using COMPAR to perform the comparisons.  */\nextern void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 4));\n#ifdef __USE_GNU\nextern void qsort_r(void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg) __nonnull((1, 4));\n#endif\n\n/* Return the absolute value of X.  */\nextern int abs(int __x)\n__THROW __attribute__ ((__const__)) __wur;\nextern long int labs(long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n__extension__ extern long long int llabs(long long int __x)\n__THROW __attribute__ ((__const__)) __wur;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the `div_t', `ldiv_t' or `lldiv_t' representation\n   of the value of NUMER over DENOM. */\n/* GCC may have built-ins for these someday.  */\nextern div_t div(int __numer, int __denom)\n__THROW __attribute__ ((__const__)) __wur;\nextern ldiv_t ldiv(long int __numer, long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n__BEGIN_NAMESPACE_C99 __extension__ extern lldiv_t lldiv(long long int __numer, long long int __denom)\n__THROW __attribute__ ((__const__)) __wur;\n__END_NAMESPACE_C99\n#endif\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Convert floating point numbers to strings.  The returned values are\n   valid only until another call to the same function.  */\n/* Convert VALUE to a string with NDIGIT digits and return a pointer to\n   this.  Set *DECPT with the position of the decimal character and *SIGN\n   with the sign of the number.  */\nextern char *ecvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* Convert VALUE to a string rounded to NDIGIT decimal digits.  Set *DECPT\n   with the position of the decimal character and *SIGN with the sign of\n   the number.  */\nextern char *fcvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\n\n/* If possible convert VALUE to a string with NDIGIT significant digits.\n   Otherwise use exponential representation.  The resulting string will\n   be written to BUF.  */\nextern char *gcvt(double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n#endif\n\n#ifdef __USE_MISC\n/* Long double versions of above functions.  */\nextern char *qecvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qfcvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign)\n__THROW __nonnull((3, 4)) __wur;\nextern char *qgcvt(long double __value, int __ndigit, char *__buf)\n__THROW __nonnull((3)) __wur;\n\n/* Reentrant version of the functions above which provide their own\n   buffers.  */\nextern int ecvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int fcvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n\nextern int qecvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\nextern int qfcvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len)\n__THROW __nonnull((3, 4, 5));\n#endif\t\t\t\t/* misc */\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the multibyte character\n   in S, which is no longer than N.  */\nextern int mblen(const char *__s, size_t __n) __THROW;\n/* Return the length of the given multibyte character,\n   putting its `wchar_t' representation in *PWC.  */\nextern int mbtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n) __THROW;\n/* Put the multibyte character represented\n   by WCHAR in S, returning its length.  */\nextern int wctomb(char *__s, wchar_t __wchar) __THROW;\n\n/* Convert a multibyte string to a wide char string.  */\nextern size_t mbstowcs(wchar_t * __restrict __pwcs, const char *__restrict __s, size_t __n) __THROW;\n/* Convert a wide char string to multibyte string.  */\nextern size_t wcstombs(char *__restrict __s, const wchar_t * __restrict __pwcs, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_MISC\n/* Determine whether the string value of RESPONSE matches the affirmation\n   or negative response expression as specified by the LC_MESSAGES category\n   in the program's current locale.  Returns 1 if affirmative, 0 if\n   negative, and -1 if not matching.  */\nextern int rpmatch(const char *__response)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Parse comma separated suboption from *OPTIONP and match against\n   strings in TOKENS.  If found return index and set *VALUEP to\n   optional value introduced by an equal sign.  If the suboption is\n   not part of TOKENS return in *VALUEP beginning of unknown\n   suboption.  On exit *OPTIONP is set to the beginning of the next\n   token or at the terminating NUL character.  */\nextern int getsubopt(char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep)\n__THROW __nonnull((1, 2, 3)) __wur;\n#endif\n\n#ifdef __USE_XOPEN\n/* Setup DES tables according KEY.  */\nextern void setkey(const char *__key)\n__THROW __nonnull((1));\n#endif\n\n/* X/Open pseudo terminal handling.  */\n\n#ifdef __USE_XOPEN2KXSI\n/* Return a master pseudo-terminal handle.  */\nextern int posix_openpt(int __oflag) __wur;\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* The next four functions all take a master pseudo-tty fd and\n   perform an operation on the associated slave:  */\n\n/* Chown the slave to the calling user.  */\nextern int grantpt(int __fd) __THROW;\n\n/* Release an internal lock so the slave can be opened.\n   Call after grantpt().  */\nextern int unlockpt(int __fd) __THROW;\n\n/* Return the pathname of the pseudo terminal slave associated with\n   the master FD is open on, or NULL on errors.\n   The returned storage is good until the next call to this function.  */\nextern char *ptsname(int __fd)\n__THROW __wur;\n#endif\n\n#ifdef __USE_GNU\n/* Store at most BUFLEN characters of the pathname of the slave pseudo\n   terminal associated with the master FD is open on in BUF.\n   Return 0 on success, otherwise an error number.  */\nextern int ptsname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n\n/* Open a master pseudo terminal and return its file descriptor.  */\nextern int getpt(void);\n#endif\n\n#ifdef __USE_MISC\n/* Put the 1 minute, 5 minute and 15 minute load averages into the first\n   NELEM elements of LOADAVG.  Return the number written (never more than\n   three, but may be less than NELEM), or -1 if an error occurred.  */\nextern int getloadavg(double __loadavg[], int __nelem)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K\n/* Return the index into the active-logins file (utmp) for\n   the controlling terminal.  */\nextern int ttyslot(void) __THROW;\n#endif\n\n#include <bits/stdlib-float.h>\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n#include <bits/stdlib.h>\n#endif\n#ifdef __LDBL_COMPAT\n#include <bits/stdlib-ldbl.h>\n#endif\n\n#endif\t\t\t\t/* don't just need malloc and calloc */\n#undef __need_malloc_and_calloc\n\n__END_DECLS\n#endif\t\t\t\t/* stdlib.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/string.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.21 String handling\t<string.h>\n */\n\n#ifndef\t_STRING_H\n#define\t_STRING_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* Get size_t and NULL from <stddef.h>.  */\n#define\t__need_size_t\n#define\t__need_NULL\n#include <stddef.h>\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n#define __CORRECT_ISO_CPP_STRING_H_PROTO\n#endif\n    __BEGIN_NAMESPACE_STD\n/* Copy N bytes of SRC to DEST.  */\nextern void *memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n/* Copy N bytes of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern void *memmove(void *__dest, const void *__src, size_t __n)\n__THROW __nonnull((1, 2));\n__END_NAMESPACE_STD\n/* Copy no more than N bytes of SRC to DEST, stopping when C is found.\n   Return the position in DEST one byte past where C was copied,\n   or NULL if C was not found in the first N bytes of SRC.  */\n#if defined __USE_MISC || defined __USE_XOPEN\nextern void *memccpy(void *__restrict __dest, const void *__restrict __src, int __c, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\t\t\t\t/* Misc || X/Open.  */\n\n__BEGIN_NAMESPACE_STD\n/* Set N bytes of S to C.  */\nextern void *memset(void *__s, int __c, size_t __n)\n__THROW __nonnull((1));\n\n/* Compare N bytes of S1 and S2.  */\nextern int memcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Search N bytes of S for C.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern void *memchr(void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\textern const void *memchr(const void *__s, int __c, size_t __n)\n\t__THROW __asm(\"memchr\") __attribute_pure__ __nonnull((1));\n\n#ifdef __OPTIMIZE__\n\t__extern_always_inline void *memchr(void *__s, int __c, size_t __n) __THROW\n{\n\treturn __builtin_memchr(__s, __c, __n);\n}\n\t__extern_always_inline const void *memchr(const void *__s, int __c, size_t __n) __THROW {\n\t\treturn __builtin_memchr(__s, __c, __n);\n\t}\n#endif\n}\n#else\nextern void *memchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* Search in S for C.  This is similar to `memchr' but there is no\n   length limit.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *rawmemchr(void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *rawmemchr(const void *__s, int __c)\n__THROW __asm(\"rawmemchr\")\n__attribute_pure__ __nonnull((1));\n#else\nextern void *rawmemchr(const void *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n/* Search N bytes of S for the final occurrence of C.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" void *memrchr(void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __asm(\"memrchr\")\n__attribute_pure__ __nonnull((1));\n#else\nextern void *memrchr(const void *__s, int __c, size_t __n)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Copy SRC to DEST.  */\nextern char *strcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Copy no more than N characters of SRC to DEST.  */\nextern char *strncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern char *strcat(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n/* Append no more than N characters from SRC onto DEST.  */\nextern char *strncat(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Compare S1 and S2.  */\nextern int strcmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Compare N characters of S1 and S2.  */\nextern int strncmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare the collated forms of S1 and S2.  */\nextern int strcoll(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Put a transformation of SRC into no more than N bytes of DEST.  */\nextern size_t strxfrm(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((2));\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* The following functions are equivalent to the both above but they\n   take the locale they use for the collation as an extra argument.\n   This is not standardsized but something like will come.  */\n#include <xlocale.h>\n/* Compare the collated forms of S1 and S2 using rules from L.  */\nextern int strcoll_l(const char *__s1, const char *__s2, __locale_t __l)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n/* Put a transformation of SRC into no more than N bytes of DEST.  */\nextern size_t strxfrm_l(char *__dest, const char *__src, size_t __n, __locale_t __l)\n__THROW __nonnull((2, 4));\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Duplicate S, returning an identical malloc'd string.  */\nextern char *strdup(const char *__s)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n/* Return a malloc'd copy of at most N bytes of STRING.  The\n   resultant string is terminated even if no null terminator\n   appears before STRING[N].  */\n#if defined __USE_XOPEN2K8\nextern char *strndup(const char *__string, size_t __n)\n__THROW __attribute_malloc__ __nonnull((1));\n#endif\n\n#if defined __USE_GNU && defined __GNUC__\n/* Duplicate S, returning an identical alloca'd string.  */\n#define strdupa(s)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strlen (__old) + 1;\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len);\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n\n/* Return an alloca'd copy of at most N bytes of string.  */\n#define strndupa(s, n)\t\t\t\t\t\t\t      \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({\t\t\t\t\t\t\t\t\t      \\\n      const char *__old = (s);\t\t\t\t\t\t      \\\n      size_t __len = strnlen (__old, (n));\t\t\t\t      \\\n      char *__new = (char *) __builtin_alloca (__len + 1);\t\t      \\\n      __new[__len] = '\\0';\t\t\t\t\t\t      \\\n      (char *) memcpy (__new, __old, __len);\t\t\t\t      \\\n    }))\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Find the first occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strchr(char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strchr(const char *__s, int __c)\n\t__THROW __asm(\"strchr\") __attribute_pure__ __nonnull((1));\n\n#ifdef __OPTIMIZE__\n\t__extern_always_inline char *strchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strchr(__s, __c);\n}\n\t__extern_always_inline const char *strchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strchr(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *strchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n/* Find the last occurrence of C in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strrchr(char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\textern const char *strrchr(const char *__s, int __c)\n\t__THROW __asm(\"strrchr\") __attribute_pure__ __nonnull((1));\n\n#ifdef __OPTIMIZE__\n\t__extern_always_inline char *strrchr(char *__s, int __c) __THROW\n{\n\treturn __builtin_strrchr(__s, __c);\n}\n\t__extern_always_inline const char *strrchr(const char *__s, int __c) __THROW {\n\t\treturn __builtin_strrchr(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *strrchr(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to `strchr'.  But it returns a pointer to\n   the closing NUL byte in case C is not found in S.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strchrnul(char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\nextern \"C++\" const char *strchrnul(const char *__s, int __c)\n__THROW __asm(\"strchrnul\")\n__attribute_pure__ __nonnull((1));\n#else\nextern char *strchrnul(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the initial segment of S which\n   consists entirely of characters not in REJECT.  */\nextern size_t strcspn(const char *__s, const char *__reject)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Return the length of the initial segment of S which\n   consists entirely of characters in ACCEPT.  */\nextern size_t strspn(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Find the first occurrence in S of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strpbrk(char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strpbrk(const char *__s, const char *__accept)\n\t__THROW __asm(\"strpbrk\") __attribute_pure__ __nonnull((1, 2));\n\n#ifdef __OPTIMIZE__\n\t__extern_always_inline char *strpbrk(char *__s, const char *__accept) __THROW\n{\n\treturn __builtin_strpbrk(__s, __accept);\n}\n\t__extern_always_inline const char *strpbrk(const char *__s, const char *__accept) __THROW {\n\t\treturn __builtin_strpbrk(__s, __accept);\n\t}\n#endif\n}\n#else\nextern char *strpbrk(const char *__s, const char *__accept)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *strstr(char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\textern const char *strstr(const char *__haystack, const char *__needle)\n\t__THROW __asm(\"strstr\") __attribute_pure__ __nonnull((1, 2));\n\n#ifdef __OPTIMIZE__\n\t__extern_always_inline char *strstr(char *__haystack, const char *__needle) __THROW\n{\n\treturn __builtin_strstr(__haystack, __needle);\n}\n\t__extern_always_inline const char *strstr(const char *__haystack, const char *__needle) __THROW {\n\t\treturn __builtin_strstr(__haystack, __needle);\n\t}\n#endif\n}\n#else\nextern char *strstr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n\n/* Divide S into tokens separated by characters in DELIM.  */\nextern char *strtok(char *__restrict __s, const char *__restrict __delim)\n__THROW __nonnull((2));\n__END_NAMESPACE_STD\n/* Divide S into tokens separated by characters in DELIM.  Information\n   passed between calls are stored in SAVE_PTR.  */\nextern char *__strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#ifdef __USE_POSIX\nextern char *strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __save_ptr)\n__THROW __nonnull((2, 3));\n#endif\n\n#ifdef __USE_GNU\n/* Similar to `strstr' but this function ignores the case of both strings.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *strcasestr(char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\nextern \"C++\" const char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __asm(\"strcasestr\")\n__attribute_pure__ __nonnull((1, 2));\n#else\nextern char *strcasestr(const char *__haystack, const char *__needle)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\n#endif\n\n#ifdef __USE_GNU\n/* Find the first occurrence of NEEDLE in HAYSTACK.\n   NEEDLE is NEEDLELEN bytes long;\n   HAYSTACK is HAYSTACKLEN bytes long.  */\nextern void *memmem(const void *__haystack, size_t __haystacklen, const void *__needle, size_t __needlelen)\n__THROW __attribute_pure__ __nonnull((1, 3));\n\n/* Copy N bytes of SRC to DEST, return pointer to bytes after the\n   last written byte.  */\nextern void *__mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern void *mempcpy(void *__restrict __dest, const void *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of S.  */\nextern size_t strlen(const char *__s)\n__THROW __attribute_pure__ __nonnull((1));\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* Find the length of STRING, but scan at most MAXLEN characters.\n   If no '\\0' terminator is found in that many characters, return MAXLEN.  */\nextern size_t strnlen(const char *__string, size_t __maxlen)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return a string describing the meaning of the `errno' code in ERRNUM.  */\nextern char *strerror(int __errnum) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K\n/* Reentrant version of `strerror'.\n   There are 2 flavors of `strerror_r', GNU which returns the string\n   and may or may not use the supplied temporary buffer and POSIX one\n   which fills the string into the buffer.\n   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L\n   without -D_GNU_SOURCE is needed, otherwise the GNU version is\n   preferred.  */\n#if defined __USE_XOPEN2K && !defined __USE_GNU\n/* Fill BUF with a string describing the meaning of the `errno' code in\n   ERRNUM.  */\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(strerror_r, (int __errnum, char *__buf, size_t __buflen), __xpg_strerror_r) __nonnull((2));\n#else\nextern int __xpg_strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2));\n#define strerror_r __xpg_strerror_r\n#endif\n#else\n/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be\n   used.  */\nextern char *strerror_r(int __errnum, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n#endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Translate error number to string according to the locale L.  */\nextern char *strerror_l(int __errnum, __locale_t __l) __THROW;\n#endif\n\n/* We define this function always since `bzero' is sometimes needed when\n   the namespace rules does not allow this.  */\nextern void __bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n#ifdef __USE_MISC\n/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */\nextern void bcopy(const void *__src, void *__dest, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Set N bytes of S to 0.  */\nextern void bzero(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n/* Compare N bytes of S1 and S2 (same as memcmp).  */\nextern int bcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Find the first occurrence of C in S (same as strchr).  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *index(char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\textern const char *index(const char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\n#if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO\n\t__extern_always_inline char *index(char *__s, int __c) __THROW\n{\n\treturn __builtin_index(__s, __c);\n}\n\t__extern_always_inline const char *index(const char *__s, int __c) __THROW {\n\t\treturn __builtin_index(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *index(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n/* Find the last occurrence of C in S (same as strrchr).  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" {\n\textern char *rindex(char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\textern const char *rindex(const char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\n#if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRINGS_H_PROTO\n\t__extern_always_inline char *rindex(char *__s, int __c) __THROW\n{\n\treturn __builtin_rindex(__s, __c);\n}\n\t__extern_always_inline const char *rindex(const char *__s, int __c) __THROW {\n\t\treturn __builtin_rindex(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *rindex(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n/* Return the position of the first bit set in I, or 0 if none are set.\n   The least-significant bit is position 1, the most-significant 32.  */\nextern int ffs(int __i)\n__THROW __attribute__ ((__const__));\n\n/* The following two functions are non-standard but necessary for non-32 bit\n   platforms.  */\n#ifdef\t__USE_GNU\nextern int ffsl(long int __l)\n__THROW __attribute__ ((__const__));\n__extension__ extern int ffsll(long long int __ll)\n__THROW __attribute__ ((__const__));\n#endif\n\n/* Compare S1 and S2, ignoring case.  */\nextern int strcasecmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int strncasecmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n#endif\t\t\t\t/* Use misc.  */\n\n#ifdef\t__USE_GNU\n/* Again versions of a few functions which use the given locale instead\n   of the global one.  */\nextern int strcasecmp_l(const char *__s1, const char *__s2, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n\nextern int strncasecmp_l(const char *__s1, const char *__s2, size_t __n, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 4));\n#endif\n\n#ifdef\t__USE_MISC\n/* Return the next DELIM-delimited token from *STRINGP,\n   terminating it with a '\\0', and update *STRINGP to point past it.  */\nextern char *strsep(char **__restrict __stringp, const char *__restrict __delim)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_XOPEN2K8\n/* Return a string describing the meaning of the signal number in SIG.  */\nextern char *strsignal(int __sig) __THROW;\n\n/* Copy SRC to DEST, returning the address of the terminating '\\0' in DEST.  */\nextern char *__stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\nextern char *stpcpy(char *__restrict __dest, const char *__restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern char *__stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\nextern char *stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n#ifdef\t__USE_GNU\n/* Compare S1 and S2 as strings holding name & indices/version numbers.  */\nextern int strverscmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n\n/* Sautee STRING briskly.  */\nextern char *strfry(char *__string)\n__THROW __nonnull((1));\n\n/* Frobnicate N bytes of S.  */\nextern void *memfrob(void *__s, size_t __n)\n__THROW __nonnull((1));\n\n#ifndef basename\n/* Return the file name within directory of FILENAME.  We don't\n   declare the function if the `basename' macro is available (defined\n   in <libgen.h>) which makes the XPG version of this function\n   available.  */\n#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO\nextern \"C++\" char *basename(char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\nextern \"C++\" const char *basename(const char *__filename)\n__THROW __asm(\"basename\") __nonnull((1));\n#else\nextern char *basename(const char *__filename)\n__THROW __nonnull((1));\n#endif\n#endif\n#endif\n\n#if __GNUC_PREREQ (3,4)\n#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \\\n     && !defined __NO_INLINE__ && !defined __cplusplus\n/* When using GNU CC we provide some optimized versions of selected\n   functions from this header.  There are two kinds of optimizations:\n\n   - machine-dependent optimizations, most probably using inline\n     assembler code; these might be quite expensive since the code\n     size can increase significantly.\n     These optimizations are not used unless the symbol\n\t__USE_STRING_INLINES\n     is defined before including this header.\n\n   - machine-independent optimizations which do not increase the\n     code size significantly and which optimize mainly situations\n     where one or more arguments are compile-time constants.\n     These optimizations are used always when the compiler is\n     taught to optimize.\n\n   One can inhibit all optimizations by defining __NO_STRING_INLINES.  */\n\n/* Get the machine-dependent optimizations (if any).  */\n#include <bits/string.h>\n\n/* These are generic optimizations which do not add too much inline code.  */\n#include <bits/string2.h>\n#endif\n\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n/* Functions with security checks.  */\n#include <bits/string3.h>\n#endif\n#endif\n\n#if defined __USE_GNU && defined __OPTIMIZE__ \\\n    && defined __extern_always_inline && __GNUC_PREREQ (3,2)\n#if !defined _FORCE_INLINES && !defined _HAVE_STRING_ARCH_mempcpy\n\n#define mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)\n#define __mempcpy(dest, src, n) __mempcpy_inline (dest, src, n)\n\n__extern_always_inline void *__mempcpy_inline(void *__restrict __dest, const void *__restrict __src, size_t __n)\n{\n\treturn (char *)memcpy(__dest, __src, __n) + __n;\n}\n\n#endif\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* string.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/strings.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef\t_STRINGS_H\n#define\t_STRINGS_H\t1\n\n/* We don't need and should not read this file if <string.h> was already\n   read. The one exception being that if __USE_MISC isn't defined, then\n   these aren't defined in string.h, so we need to define them here.  */\n#if !defined _STRING_H || !defined __USE_MISC\n\n#include <features.h>\n#define __need_size_t\n#include <stddef.h>\n\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n#define __CORRECT_ISO_CPP_STRINGS_H_PROTO\n#endif\n\n__BEGIN_DECLS\n#if defined __USE_MISC || !defined __USE_XOPEN2K8\n/* Compare N bytes of S1 and S2 (same as memcmp).  */\nextern int bcmp(const void *__s1, const void *__s2, size_t __n)\n__THROW __attribute_pure__;\n\n/* Copy N bytes of SRC to DEST (like memmove, but args reversed).  */\nextern void bcopy(const void *__src, void *__dest, size_t __n) __THROW;\n\n/* Set N bytes of S to 0.  */\nextern void bzero(void *__s, size_t __n) __THROW;\n\n/* Find the first occurrence of C in S (same as strchr).  */\n#ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *index(char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\textern const char *index(const char *__s, int __c)\n\t__THROW __asm(\"index\") __attribute_pure__ __nonnull((1));\n\n#if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO\n\t__extern_always_inline char *index(char *__s, int __c) __THROW\n{\n\treturn __builtin_index(__s, __c);\n}\n\t__extern_always_inline const char *index(const char *__s, int __c) __THROW {\n\t\treturn __builtin_index(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *index(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n\n/* Find the last occurrence of C in S (same as strrchr).  */\n#ifdef __CORRECT_ISO_CPP_STRINGS_H_PROTO\nextern \"C++\" {\n\textern char *rindex(char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\textern const char *rindex(const char *__s, int __c)\n\t__THROW __asm(\"rindex\") __attribute_pure__ __nonnull((1));\n\n#if defined __OPTIMIZE__ && !defined __CORRECT_ISO_CPP_STRING_H_PROTO\n\t__extern_always_inline char *rindex(char *__s, int __c) __THROW\n{\n\treturn __builtin_rindex(__s, __c);\n}\n\t__extern_always_inline const char *rindex(const char *__s, int __c) __THROW {\n\t\treturn __builtin_rindex(__s, __c);\n\t}\n#endif\n}\n#else\nextern char *rindex(const char *__s, int __c)\n__THROW __attribute_pure__ __nonnull((1));\n#endif\n#endif\n\n#if defined __USE_MISC || !defined __USE_XOPEN2K8 || defined __USE_XOPEN2K8XSI\n/* Return the position of the first bit set in I, or 0 if none are set.\n   The least-significant bit is position 1, the most-significant 32.  */\nextern int ffs(int __i)\n__THROW __attribute__ ((const));\n#endif\n\n/* Compare S1 and S2, ignoring case.  */\nextern int strcasecmp(const char *__s1, const char *__s2)\n__THROW __attribute_pure__;\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int strncasecmp(const char *__s1, const char *__s2, size_t __n)\n__THROW __attribute_pure__;\n\n#ifdef\t__USE_XOPEN2K8\n/* The following functions are equivalent to the both above but they\n   take the locale they use for the collation as an extra argument.\n   This is not standardsized but something like will come.  */\n#include <xlocale.h>\n\n/* Again versions of a few functions which use the given locale instead\n   of the global one.  */\nextern int strcasecmp_l(const char *__s1, const char *__s2, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 3));\n\nextern int strncasecmp_l(const char *__s1, const char *__s2, size_t __n, __locale_t __loc)\n__THROW __attribute_pure__ __nonnull((1, 2, 4));\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* string.h  */\n#endif\t\t\t\t/* strings.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/termios.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 7.1-2 General Terminal Interface\t<termios.h>\n */\n\n#ifndef\t_TERMIOS_H\n#define\t_TERMIOS_H\t1\n\n#include <features.h>\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* We need `pid_t'.  */\n#include <bits/types.h>\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n#endif\n\n__BEGIN_DECLS\n/* Get the system-dependent definitions of `struct termios', `tcflag_t',\n   `cc_t', `speed_t', and all the macros specifying the flag bits.  */\n#include <bits/termios.h>\n#ifdef __USE_MISC\n/* Compare a character C to a value VAL from the `c_cc' array in a\n   `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */\n#define CCEQ(val, c)\t((c) == (val) && (val) != _POSIX_VDISABLE)\n#endif\n/* Return the output baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetospeed(const struct termios *__termios_p) __THROW;\n\n/* Return the input baud rate stored in *TERMIOS_P.  */\nextern speed_t cfgetispeed(const struct termios *__termios_p) __THROW;\n\n/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetospeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n/* Set the input baud rate stored in *TERMIOS_P to SPEED.  */\nextern int cfsetispeed(struct termios *__termios_p, speed_t __speed) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */\nextern int cfsetspeed(struct termios *__termios_p, speed_t __speed) __THROW;\n#endif\n\n/* Put the state of FD into *TERMIOS_P.  */\nextern int tcgetattr(int __fd, struct termios *__termios_p) __THROW;\n\n/* Set the state of FD to *TERMIOS_P.\n   Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>.  */\nextern int tcsetattr(int __fd, int __optional_actions, const struct termios *__termios_p) __THROW;\n\n#ifdef\t__USE_MISC\n/* Set *TERMIOS_P to indicate raw mode.  */\nextern void cfmakeraw(struct termios *__termios_p) __THROW;\n#endif\n\n/* Send zero bits on FD.  */\nextern int tcsendbreak(int __fd, int __duration) __THROW;\n\n/* Wait for pending output to be written on FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int tcdrain(int __fd);\n\n/* Flush pending data on FD.\n   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>.  */\nextern int tcflush(int __fd, int __queue_selector) __THROW;\n\n/* Suspend or restart transmission on FD.\n   Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>.  */\nextern int tcflow(int __fd, int __action) __THROW;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Get process group ID for session leader for controlling terminal FD.  */\nextern __pid_t tcgetsid(int __fd) __THROW;\n#endif\n\n#ifdef __USE_MISC\n#include <sys/ttydefaults.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* termios.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/time.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tISO C99 Standard: 7.23 Date and time\t<time.h>\n */\n\n#ifndef\t_TIME_H\n\n#if (! defined __need_time_t && !defined __need_clock_t && \\\n     ! defined __need_timespec)\n#define _TIME_H\t1\n#include <features.h>\n\n__BEGIN_DECLS\n#endif\n#ifdef\t_TIME_H\n/* Get size_t and NULL from <stddef.h>.  */\n#define __need_size_t\n#define __need_NULL\n#include <stddef.h>\n/* This defines CLOCKS_PER_SEC, which is the number of processor clock\n   ticks per second.  */\n#include <bits/time.h>\n/* This is the obsolete POSIX.1-1988 name for the same constant.  */\n#if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K\n#ifndef CLK_TCK\n#define CLK_TCK\tCLOCKS_PER_SEC\n#endif\n#endif\n#endif\t\t\t\t/* <time.h> included.  */\n#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t)\n#define __clock_t_defined\t1\n#include <bits/types.h>\n    __BEGIN_NAMESPACE_STD\n/* Returned by `clock'.  */\ntypedef __clock_t clock_t;\n__END_NAMESPACE_STD\n#if defined __USE_XOPEN || defined __USE_POSIX\n__USING_NAMESPACE_STD(clock_t)\n#endif\n#endif\t\t\t\t/* clock_t not defined and <time.h> or need clock_t.  */\n#undef\t__need_clock_t\n#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t)\n#define __time_t_defined\t1\n#include <bits/types.h>\n__BEGIN_NAMESPACE_STD\n/* Returned by `time'.  */\ntypedef __time_t time_t;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX\n__USING_NAMESPACE_STD(time_t)\n#endif\n#endif\t\t\t\t/* time_t not defined and <time.h> or need time_t.  */\n#undef\t__need_time_t\n#if !defined __clockid_t_defined && \\\n   ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t)\n#define __clockid_t_defined\t1\n#include <bits/types.h>\n/* Clock ID used in clock and timer functions.  */\ntypedef __clockid_t clockid_t;\n\n#endif\t\t\t\t/* clockid_t not defined and <time.h> or need clockid_t.  */\n#undef\t__clockid_time_t\n\n#if !defined __timer_t_defined && \\\n    ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t)\n#define __timer_t_defined\t1\n\n#include <bits/types.h>\n\n/* Timer ID returned by `timer_create'.  */\ntypedef __timer_t timer_t;\n\n#endif\t\t\t\t/* timer_t not defined and <time.h> or need timer_t.  */\n#undef\t__need_timer_t\n\n#if (!defined __timespec_defined\t\t\t\t\t\\\n     && ((defined _TIME_H\t\t\t\t\t\t\\\n\t  && (defined __USE_POSIX199309\t\t\t\t\t\\\n\t      || defined __USE_ISOC11))\t\t\t\t\t\\\n\t || defined __need_timespec))\n#define __timespec_defined\t1\n\n#include <bits/types.h>\t\t/* This defines __time_t for us.  */\n\n/* POSIX.1b structure for a time value.  This is like a `struct timeval' but\n   has nanoseconds instead of microseconds.  */\nstruct timespec {\n\t__time_t tv_sec;\t/* Seconds.  */\n\t__syscall_slong_t tv_nsec;\t/* Nanoseconds.  */\n};\n\n#endif\t\t\t\t/* timespec not defined and <time.h> or need timespec.  */\n#undef\t__need_timespec\n\n#ifdef\t_TIME_H\n__BEGIN_NAMESPACE_STD\n/* Used by other time functions.  */\nstruct tm {\n\tint tm_sec;\t\t/* Seconds.     [0-60] (1 leap second) */\n\tint tm_min;\t\t/* Minutes.     [0-59] */\n\tint tm_hour;\t\t/* Hours.       [0-23] */\n\tint tm_mday;\t\t/* Day.         [1-31] */\n\tint tm_mon;\t\t/* Month.       [0-11] */\n\tint tm_year;\t\t/* Year - 1900.  */\n\tint tm_wday;\t\t/* Day of week. [0-6] */\n\tint tm_yday;\t\t/* Days in year.[0-365] */\n\tint tm_isdst;\t\t/* DST.         [-1/0/1] */\n\n#ifdef\t__USE_MISC\n\tlong int tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *tm_zone;\t/* Timezone abbreviation.  */\n#else\n\tlong int __tm_gmtoff;\t/* Seconds east of UTC.  */\n\tconst char *__tm_zone;\t/* Timezone abbreviation.  */\n#endif\n};\n__END_NAMESPACE_STD\n#if defined __USE_XOPEN || defined __USE_POSIX\n__USING_NAMESPACE_STD(tm)\n#endif\n#ifdef __USE_POSIX199309\n/* POSIX.1b structure for timer start values and intervals.  */\nstruct itimerspec {\n\tstruct timespec it_interval;\n\tstruct timespec it_value;\n};\n\n/* We can use a simple forward declaration.  */\nstruct sigevent;\n\n#endif\t\t\t\t/* POSIX.1b */\n\n#ifdef __USE_XOPEN2K\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n#endif\n\n#ifdef __USE_ISOC11\n/* Time base values for timespec_get.  */\n#define TIME_UTC 1\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Time used by the program so far (user time + system time).\n   The result / CLOCKS_PER_SECOND is program time in seconds.  */\nextern clock_t clock(void) __THROW;\n\n/* Return the current time and put it in *TIMER if TIMER is not NULL.  */\nextern time_t time(time_t * __timer) __THROW;\n\n/* Return the difference between TIME1 and TIME0.  */\nextern double difftime(time_t __time1, time_t __time0)\n__THROW __attribute__ ((__const__));\n\n/* Return the `time_t' representation of TP and normalize TP.  */\nextern time_t mktime(struct tm *__tp) __THROW;\n\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE characters and return the number\n   of characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t strftime(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN\n/* Parse S according to FORMAT and store binary time information in TP.\n   The return value is a pointer to the first unparsed character in S.  */\nextern char *strptime(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp) __THROW;\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n#include <xlocale.h>\n\nextern size_t strftime_l(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp, __locale_t __loc) __THROW;\n#endif\n\n#ifdef __USE_GNU\nextern char *strptime_l(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp, __locale_t __loc) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the `struct tm' representation of *TIMER\n   in Universal Coordinated Time (aka Greenwich Mean Time).  */\nextern struct tm *gmtime(const time_t * __timer) __THROW;\n\n/* Return the `struct tm' representation\n   of *TIMER in the local timezone.  */\nextern struct tm *localtime(const time_t * __timer) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX\n/* Return the `struct tm' representation of *TIMER in UTC,\n   using *TP to store the result.  */\nextern struct tm *gmtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n\n/* Return the `struct tm' representation of *TIMER in local time,\n   using *TP to store the result.  */\nextern struct tm *localtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n__BEGIN_NAMESPACE_STD\n/* Return a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime(const struct tm *__tp) __THROW;\n\n/* Equivalent to `asctime (localtime (timer))'.  */\nextern char *ctime(const time_t * __timer) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_POSIX\n/* Reentrant versions of the above functions.  */\n/* Return in BUF a string of the form \"Day Mon dd hh:mm:ss yyyy\\n\"\n   that is the representation of TP in this format.  */\nextern char *asctime_r(const struct tm *__restrict __tp, char *__restrict __buf) __THROW;\n\n/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */\nextern char *ctime_r(const time_t * __restrict __timer, char *__restrict __buf) __THROW;\n#endif\t\t\t\t/* POSIX */\n\n/* Defined in localtime.c.  */\nextern char *__tzname[2];\t/* Current timezone names.  */\nextern int __daylight;\t\t/* If daylight-saving time is ever in use.  */\nextern long int __timezone;\t/* Seconds west of UTC.  */\n\n#ifdef\t__USE_POSIX\n/* Same as above.  */\nextern char *tzname[2];\n\n/* Set time conversion information from the TZ environment variable.\n   If TZ is not defined, a locale-dependent default is used.  */\nextern void tzset(void) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\nextern int daylight;\nextern long int timezone;\n#endif\n\n#ifdef __USE_MISC\n/* Set the system time to *WHEN.\n   This call is restricted to the superuser.  */\nextern int stime(const time_t * __when) __THROW;\n#endif\n\n/* Nonzero if YEAR is a leap year (every 4 years,\n   except every 100th isn't, and every 400th is).  */\n#define __isleap(year)\t\\\n  ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))\n\n#ifdef __USE_MISC\n/* Miscellaneous functions many Unices inherited from the public domain\n   localtime package.  These are included only for compatibility.  */\n\n/* Like `mktime', but for TP represents Universal Time, not local time.  */\nextern time_t timegm(struct tm *__tp) __THROW;\n\n/* Another name for `mktime'.  */\nextern time_t timelocal(struct tm *__tp) __THROW;\n\n/* Return the number of days in YEAR.  */\nextern int dysize(int __year)\n__THROW __attribute__ ((__const__));\n#endif\n\n#ifdef __USE_POSIX199309\n/* Pause execution for a number of nanoseconds.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int nanosleep(const struct timespec *__requested_time, struct timespec *__remaining);\n\n/* Get resolution of clock CLOCK_ID.  */\nextern int clock_getres(clockid_t __clock_id, struct timespec *__res) __THROW;\n\n/* Get current value of clock CLOCK_ID and store it in TP.  */\nextern int clock_gettime(clockid_t __clock_id, struct timespec *__tp) __THROW;\n\n/* Set clock CLOCK_ID to value TP.  */\nextern int clock_settime(clockid_t __clock_id, const struct timespec *__tp) __THROW;\n\n#ifdef __USE_XOPEN2K\n/* High-resolution sleep with the specified clock.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int clock_nanosleep(clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem);\n\n/* Return clock ID for CPU-time clock.  */\nextern int clock_getcpuclockid(pid_t __pid, clockid_t * __clock_id) __THROW;\n#endif\n\n/* Create new per-process timer using CLOCK_ID.  */\nextern int timer_create(clockid_t __clock_id, struct sigevent *__restrict __evp, timer_t * __restrict __timerid) __THROW;\n\n/* Delete timer TIMERID.  */\nextern int timer_delete(timer_t __timerid) __THROW;\n\n/* Set timer TIMERID to VALUE, returning old value in OVALUE.  */\nextern int timer_settime(timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW;\n\n/* Get current value of timer TIMERID and store it in VALUE.  */\nextern int timer_gettime(timer_t __timerid, struct itimerspec *__value) __THROW;\n\n/* Get expiration overrun for timer TIMERID.  */\nextern int timer_getoverrun(timer_t __timerid) __THROW;\n#endif\n\n#ifdef __USE_ISOC11\n/* Set TS to calendar time based in time base BASE.  */\nextern int timespec_get(struct timespec *__ts, int __base)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_XOPEN_EXTENDED\n/* Set to one of the following values to indicate an error.\n     1  the DATEMSK environment variable is null or undefined,\n     2  the template file cannot be opened for reading,\n     3  failed to get file status information,\n     4  the template file is not a regular file,\n     5  an error is encountered while reading the template file,\n     6  memory allication failed (not enough memory available),\n     7  there is no line in the template that matches the input,\n     8  invalid input specification Example: February 31 or a time is\n\tspecified that can not be represented in a time_t (representing\n\tthe time in seconds since 00:00:00 UTC, January 1, 1970) */\nextern int getdate_err;\n\n/* Parse the given string as a date specification and return a value\n   representing the value.  The templates from the file identified by\n   the environment variable DATEMSK are used.  In case of an error\n   `getdate_err' is set.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern struct tm *getdate(const char *__string);\n#endif\n\n#ifdef __USE_GNU\n/* Since `getdate' is not reentrant because of the use of `getdate_err'\n   and the static buffer to return the result in, we provide a thread-safe\n   variant.  The functionality is the same.  The result is returned in\n   the buffer pointed to by RESBUFP and in case of an error the return\n   value is != 0 with the same values as given above for `getdate_err'.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int getdate_r(const char *__restrict __string, struct tm *__restrict __resbufp);\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* <time.h> included.  */\n#endif\t\t\t\t/* <time.h> not already included.  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/unistd.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 2.10 Symbolic Constants\t\t<unistd.h>\n */\n\n#ifndef\t_UNISTD_H\n#define\t_UNISTD_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n/* These may be used to determine what facilities are present at compile time.\n   Their values can be obtained at run time from `sysconf'.  */\n#ifdef __USE_XOPEN2K8\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008.  */\n#define _POSIX_VERSION\t200809L\n#elif defined __USE_XOPEN2K\n/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001.  */\n#define _POSIX_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995.  */\n#define _POSIX_VERSION\t199506L\n#elif defined __USE_POSIX199309\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993.  */\n#define _POSIX_VERSION\t199309L\n#else\n/* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990.  */\n#define _POSIX_VERSION\t199009L\n#endif\n/* These are not #ifdef __USE_POSIX2 because they are\n   in the theoretically application-owned namespace.  */\n#ifdef __USE_XOPEN2K8\n#define __POSIX2_THIS_VERSION\t200809L\n/* The utilities on GNU systems also correspond to this version.  */\n#elif defined __USE_XOPEN2K\n/* The utilities on GNU systems also correspond to this version.  */\n#define __POSIX2_THIS_VERSION\t200112L\n#elif defined __USE_POSIX199506\n/* The utilities on GNU systems also correspond to this version.  */\n#define __POSIX2_THIS_VERSION\t199506L\n#else\n/* The utilities on GNU systems also correspond to this version.  */\n#define __POSIX2_THIS_VERSION\t199209L\n#endif\n/* The utilities on GNU systems also correspond to this version.  */\n#define _POSIX2_VERSION\t__POSIX2_THIS_VERSION\n/* This symbol was required until the 2001 edition of POSIX.  */\n#define\t_POSIX2_C_VERSION\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Bindings Option.  */\n#define\t_POSIX2_C_BIND\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   C Language Development Utilities Option.  */\n#define\t_POSIX2_C_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   Software Development Utilities Option.  */\n#define\t_POSIX2_SW_DEV\t__POSIX2_THIS_VERSION\n/* If defined, the implementation supports the\n   creation of locales with the localedef utility.  */\n#define _POSIX2_LOCALEDEF       __POSIX2_THIS_VERSION\n/* X/Open version number to which the library conforms.  It is selectable.  */\n#ifdef __USE_XOPEN2K8\n#define _XOPEN_VERSION\t700\n#elif defined __USE_XOPEN2K\n#define _XOPEN_VERSION\t600\n#elif defined __USE_UNIX98\n#define _XOPEN_VERSION\t500\n#else\n#define _XOPEN_VERSION\t4\n#endif\n/* Commands and utilities from XPG4 are available.  */\n#define _XOPEN_XCU_VERSION\t4\n/* We are compatible with the old published standards as well.  */\n#define _XOPEN_XPG2\t1\n#define _XOPEN_XPG3\t1\n#define _XOPEN_XPG4\t1\n/* The X/Open Unix extensions are available.  */\n#define _XOPEN_UNIX\t1\n/* Encryption is present.  */\n#define\t_XOPEN_CRYPT\t1\n/* The enhanced internationalization capabilities according to XPG4.2\n   are present.  */\n#define\t_XOPEN_ENH_I18N\t1\n/* The legacy interfaces are also available.  */\n#define _XOPEN_LEGACY\t1\n/* Get values of POSIX options:\n\n   If these symbols are defined, the corresponding features are\n   always available.  If not, they may be available sometimes.\n   The current values can be obtained with `sysconf'.\n\n   _POSIX_JOB_CONTROL\t\tJob control is supported.\n   _POSIX_SAVED_IDS\t\tProcesses have a saved set-user-ID\n\t\t\t\tand a saved set-group-ID.\n   _POSIX_REALTIME_SIGNALS\tReal-time, queued signals are supported.\n   _POSIX_PRIORITY_SCHEDULING\tPriority scheduling is supported.\n   _POSIX_TIMERS\t\tPOSIX.4 clocks and timers are supported.\n   _POSIX_ASYNCHRONOUS_IO\tAsynchronous I/O is supported.\n   _POSIX_PRIORITIZED_IO\tPrioritized asynchronous I/O is supported.\n   _POSIX_SYNCHRONIZED_IO\tSynchronizing file data is supported.\n   _POSIX_FSYNC\t\t\tThe fsync function is present.\n   _POSIX_MAPPED_FILES\t\tMapping of files to memory is supported.\n   _POSIX_MEMLOCK\t\tLocking of all memory is supported.\n   _POSIX_MEMLOCK_RANGE\t\tLocking of ranges of memory is supported.\n   _POSIX_MEMORY_PROTECTION\tSetting of memory protections is supported.\n   _POSIX_MESSAGE_PASSING\tPOSIX.4 message queues are supported.\n   _POSIX_SEMAPHORES\t\tPOSIX.4 counting semaphores are supported.\n   _POSIX_SHARED_MEMORY_OBJECTS\tPOSIX.4 shared memory objects are supported.\n   _POSIX_THREADS\t\tPOSIX.1c pthreads are supported.\n   _POSIX_THREAD_ATTR_STACKADDR\tThread stack address attribute option supported.\n   _POSIX_THREAD_ATTR_STACKSIZE\tThread stack size attribute option supported.\n   _POSIX_THREAD_SAFE_FUNCTIONS\tThread-safe functions are supported.\n   _POSIX_THREAD_PRIORITY_SCHEDULING\n\t\t\t\tPOSIX.1c thread execution scheduling supported.\n   _POSIX_THREAD_PRIO_INHERIT\tThread priority inheritance option supported.\n   _POSIX_THREAD_PRIO_PROTECT\tThread priority protection option supported.\n   _POSIX_THREAD_PROCESS_SHARED\tProcess-shared synchronization supported.\n   _POSIX_PII\t\t\tProtocol-independent interfaces are supported.\n   _POSIX_PII_XTI\t\tXTI protocol-indep. interfaces are supported.\n   _POSIX_PII_SOCKET\t\tSocket protocol-indep. interfaces are supported.\n   _POSIX_PII_INTERNET\t\tInternet family of protocols supported.\n   _POSIX_PII_INTERNET_STREAM\tConnection-mode Internet protocol supported.\n   _POSIX_PII_INTERNET_DGRAM\tConnectionless Internet protocol supported.\n   _POSIX_PII_OSI\t\tISO/OSI family of protocols supported.\n   _POSIX_PII_OSI_COTS\t\tConnection-mode ISO/OSI service supported.\n   _POSIX_PII_OSI_CLTS\t\tConnectionless ISO/OSI service supported.\n   _POSIX_POLL\t\t\tImplementation supports `poll' function.\n   _POSIX_SELECT\t\tImplementation supports `select' and `pselect'.\n\n   _XOPEN_REALTIME\t\tX/Open realtime support is available.\n   _XOPEN_REALTIME_THREADS\tX/Open realtime thread support is available.\n   _XOPEN_SHM\t\t\tShared memory interface according to XPG4.2.\n\n   _XBS5_ILP32_OFF32\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, pointer, and off_t types.\n   _XBS5_ILP32_OFFBIG\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, long, and pointer and off_t with at least\n\t\t\t\t64 bits.\n   _XBS5_LP64_OFF64\t\tImplementation provides environment with 32-bit\n\t\t\t\tint, and 64-bit long, pointer, and off_t types.\n   _XBS5_LPBIG_OFFBIG\t\tImplementation provides environment with at\n\t\t\t\tleast 32 bits int and long, pointer, and off_t\n\t\t\t\twith at least 64 bits.\n\n   If any of these symbols is defined as -1, the corresponding option is not\n   true for any file.  If any is defined as other than -1, the corresponding\n   option is true for all files.  If a symbol is not defined at all, the value\n   for a specific file can be obtained from `pathconf' and `fpathconf'.\n\n   _POSIX_CHOWN_RESTRICTED\tOnly the super user can use `chown' to change\n\t\t\t\tthe owner of a file.  `chown' can only be used\n\t\t\t\tto change the group ID of a file to a group of\n\t\t\t\twhich the calling process is a member.\n   _POSIX_NO_TRUNC\t\tPathname components longer than\n\t\t\t\tNAME_MAX generate an error.\n   _POSIX_VDISABLE\t\tIf defined, if the value of an element of the\n\t\t\t\t`c_cc' member of `struct termios' is\n\t\t\t\t_POSIX_VDISABLE, no character will have the\n\t\t\t\teffect associated with that element.\n   _POSIX_SYNC_IO\t\tSynchronous I/O may be performed.\n   _POSIX_ASYNC_IO\t\tAsynchronous I/O may be performed.\n   _POSIX_PRIO_IO\t\tPrioritized Asynchronous I/O may be performed.\n\n   Support for the Large File Support interface is not generally available.\n   If it is available the following constants are defined to one.\n   _LFS64_LARGEFILE\t\tLow-level I/O supports large files.\n   _LFS64_STDIO\t\t\tStandard I/O supports large files.\n   */\n#include <bits/posix_opt.h>\n/* Get the environment definitions from Unix98.  */\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n#include <bits/environments.h>\n#endif\n/* Standard file descriptors.  */\n#define\tSTDIN_FILENO\t0\t/* Standard input.  */\n#define\tSTDOUT_FILENO\t1\t/* Standard output.  */\n#define\tSTDERR_FILENO\t2\t/* Standard error output.  */\n/* All functions that are not declared anywhere else.  */\n#include <bits/types.h>\n#ifndef\t__ssize_t_defined\ntypedef __ssize_t ssize_t;\n#define __ssize_t_defined\n#endif\n\n#define\t__need_size_t\n#define __need_NULL\n#include <stddef.h>\n\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n/* The Single Unix specification says that some more types are\n   available here.  */\n#ifndef __gid_t_defined\ntypedef __gid_t gid_t;\n#define __gid_t_defined\n#endif\n\n#ifndef __uid_t_defined\ntypedef __uid_t uid_t;\n#define __uid_t_defined\n#endif\n\n#ifndef __off_t_defined\n#ifndef __USE_FILE_OFFSET64\ntypedef __off_t off_t;\n#else\ntypedef __off64_t off_t;\n#endif\n#define __off_t_defined\n#endif\n#if defined __USE_LARGEFILE64 && !defined __off64_t_defined\ntypedef __off64_t off64_t;\n#define __off64_t_defined\n#endif\n\n#ifndef __useconds_t_defined\ntypedef __useconds_t useconds_t;\n#define __useconds_t_defined\n#endif\n\n#ifndef __pid_t_defined\ntypedef __pid_t pid_t;\n#define __pid_t_defined\n#endif\n#endif\t\t\t\t/* X/Open */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n#ifndef __intptr_t_defined\ntypedef __intptr_t intptr_t;\n#define __intptr_t_defined\n#endif\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n#ifndef __socklen_t_defined\ntypedef __socklen_t socklen_t;\n#define __socklen_t_defined\n#endif\n#endif\n\n/* Values for the second argument to access.\n   These may be OR'd together.  */\n#define\tR_OK\t4\t\t/* Test for read permission.  */\n#define\tW_OK\t2\t\t/* Test for write permission.  */\n#define\tX_OK\t1\t\t/* Test for execute permission.  */\n#define\tF_OK\t0\t\t/* Test for existence.  */\n\n/* Test for access to NAME using the real UID and real GID.  */\nextern int access(const char *__name, int __type)\n__THROW __nonnull((1));\n\n#ifdef __USE_GNU\n/* Test for access to NAME using the effective UID and GID\n   (as normal file operations use).  */\nextern int euidaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n\n/* An alias for `euidaccess', used by some other systems.  */\nextern int eaccess(const char *__name, int __type)\n__THROW __nonnull((1));\n#endif\n\n#ifdef __USE_ATFILE\n/* Test for access to FILE relative to the directory FD is open on.\n   If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess',\n   otherwise use real IDs like `access'.  */\nextern int faccessat(int __fd, const char *__file, int __type, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Values for the WHENCE argument to lseek.  */\n#ifndef\t_STDIO_H\t\t/* <stdio.h> has the same definitions.  */\n#define SEEK_SET\t0\t/* Seek from beginning of file.  */\n#define SEEK_CUR\t1\t/* Seek from current position.  */\n#define SEEK_END\t2\t/* Seek from end of file.  */\n#ifdef __USE_GNU\n#define SEEK_DATA\t3\t/* Seek to next data.  */\n#define SEEK_HOLE\t4\t/* Seek to next hole.  */\n#endif\n#endif\n\n#if defined __USE_MISC && !defined L_SET\n/* Old BSD names for the same constants; just for compatibility.  */\n#define L_SET\t\tSEEK_SET\n#define L_INCR\t\tSEEK_CUR\n#define L_XTND\t\tSEEK_END\n#endif\n\n/* Move FD's file position to OFFSET bytes from the\n   beginning of the file (if WHENCE is SEEK_SET),\n   the current position (if WHENCE is SEEK_CUR),\n   or the end of the file (if WHENCE is SEEK_END).\n   Return the new file position.  */\n#ifndef __USE_FILE_OFFSET64\nextern __off_t lseek(int __fd, __off_t __offset, int __whence) __THROW;\n#else\n#ifdef __REDIRECT_NTH\nextern __off64_t __REDIRECT_NTH(lseek, (int __fd, __off64_t __offset, int __whence), lseek64);\n#else\n#define lseek lseek64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern __off64_t lseek64(int __fd, __off64_t __offset, int __whence) __THROW;\n#endif\n\n/* Close the file descriptor FD.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int close(int __fd);\n\n/* Read NBYTES into BUF from FD.  Return the\n   number read, -1 for errors or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t read(int __fd, void *__buf, size_t __nbytes) __wur;\n\n/* Write N bytes of BUF to FD.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t write(int __fd, const void *__buf, size_t __n) __wur;\n\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K8\n#ifndef __USE_FILE_OFFSET64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pread(int __fd, void *__buf, size_t __nbytes, __off_t __offset) __wur;\n\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern ssize_t pwrite(int __fd, const void *__buf, size_t __n, __off_t __offset) __wur;\n#else\n#ifdef __REDIRECT\nextern ssize_t __REDIRECT(pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), pread64) __wur;\nextern ssize_t __REDIRECT(pwrite, (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset), pwrite64) __wur;\n#else\n#define pread pread64\n#define pwrite pwrite64\n#endif\n#endif\n\n#ifdef __USE_LARGEFILE64\n/* Read NBYTES into BUF from FD at the given position OFFSET without\n   changing the file pointer.  Return the number read, -1 for errors\n   or 0 for EOF.  */\nextern ssize_t pread64(int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __wur;\n/* Write N bytes of BUF to FD at the given position OFFSET without\n   changing the file pointer.  Return the number written, or -1.  */\nextern ssize_t pwrite64(int __fd, const void *__buf, size_t __n, __off64_t __offset) __wur;\n#endif\n#endif\n\n/* Create a one-way communication channel (pipe).\n   If successful, two file descriptors are stored in PIPEDES;\n   bytes written on PIPEDES[1] can be read from PIPEDES[0].\n   Returns 0 if successful, -1 if not.  */\nextern int pipe(int __pipedes[2])\n__THROW __wur;\n\n#ifdef __USE_GNU\n/* Same as pipe but apply flags passed in FLAGS to the new file\n   descriptors.  */\nextern int pipe2(int __pipedes[2], int __flags)\n__THROW __wur;\n#endif\n\n/* Schedule an alarm.  In SECONDS seconds, the process will get a SIGALRM.\n   If SECONDS is zero, any currently scheduled alarm will be cancelled.\n   The function returns the number of seconds remaining until the last\n   alarm scheduled would have signaled, or zero if there wasn't one.\n   There is no return value to indicate an error, but you can set `errno'\n   to 0 and check its value after calling `alarm', and this might tell you.\n   The signal may come late due to processor scheduling.  */\nextern unsigned int alarm(unsigned int __seconds) __THROW;\n\n/* Make the process sleep for SECONDS seconds, or until a signal arrives\n   and is not ignored.  The function returns the number of seconds less\n   than SECONDS which it actually slept (thus zero if it slept the full time).\n   If a signal handler does a `longjmp' or modifies the handling of the\n   SIGALRM signal while inside `sleep' call, the handling of the SIGALRM\n   signal afterwards is undefined.  There is no return value to indicate\n   error, but if `sleep' returns SECONDS, it probably didn't work.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern unsigned int sleep(unsigned int __seconds);\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Set an alarm to go off (generating a SIGALRM signal) in VALUE\n   microseconds.  If INTERVAL is nonzero, when the alarm goes off, the\n   timer is reset to go off every INTERVAL microseconds thereafter.\n   Returns the number of microseconds remaining before the alarm.  */\nextern __useconds_t ualarm(__useconds_t __value, __useconds_t __interval) __THROW;\n\n/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked\n   or ignored.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int usleep(__useconds_t __useconds);\n#endif\n\n/* Suspend the process until a signal arrives.\n   This always returns -1 and sets `errno' to EINTR.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int pause(void);\n\n/* Change the owner and group of FILE.  */\nextern int chown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the owner and group of the file that FD is open on.  */\nextern int fchown(int __fd, __uid_t __owner, __gid_t __group)\n__THROW __wur;\n\n/* Change owner and group of FILE, if it is a symbolic\n   link the ownership of the symbolic link is changed.  */\nextern int lchown(const char *__file, __uid_t __owner, __gid_t __group)\n__THROW __nonnull((1)) __wur;\n\n#endif\t\t\t\t/* Use X/Open Unix.  */\n\n#ifdef __USE_ATFILE\n/* Change the owner and group of FILE relative to the directory FD is open\n   on.  */\nextern int fchownat(int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag)\n__THROW __nonnull((2)) __wur;\n#endif\t\t\t\t/* Use GNU.  */\n\n/* Change the process's working directory to PATH.  */\nextern int chdir(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Change the process's working directory to the one FD is open on.  */\nextern int fchdir(int __fd)\n__THROW __wur;\n#endif\n\n/* Get the pathname of the current working directory,\n   and put it in SIZE bytes of BUF.  Returns NULL if the\n   directory couldn't be determined or SIZE was too small.\n   If successful, returns BUF.  In GNU, if BUF is NULL,\n   an array is allocated with `malloc'; the array is SIZE\n   bytes long, unless SIZE == 0, in which case it is as\n   big as necessary.  */\nextern char *getcwd(char *__buf, size_t __size)\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return a malloc'd string containing the current directory name.\n   If the environment variable `PWD' is set, and its value is correct,\n   that value is used.  */\nextern char *get_current_dir_name(void) __THROW;\n#endif\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Put the absolute pathname of the current working directory in BUF.\n   If successful, return BUF.  If not, put an error message in\n   BUF and return NULL.  BUF should be at least PATH_MAX bytes long.  */\nextern char *getwd(char *__buf)\n__THROW __nonnull((1))\n__attribute_deprecated__ __wur;\n#endif\n\n/* Duplicate FD, returning a new file descriptor on the same file.  */\nextern int dup(int __fd)\n__THROW __wur;\n\n/* Duplicate FD to FD2, closing FD2 and making it open on the same file.  */\nextern int dup2(int __fd, int __fd2) __THROW;\n\n#ifdef __USE_GNU\n/* Duplicate FD to FD2, closing FD2 and making it open on the same\n   file while setting flags according to FLAGS.  */\nextern int dup3(int __fd, int __fd2, int __flags) __THROW;\n#endif\n\n/* NULL-terminated array of \"NAME=VALUE\" environment variables.  */\nextern char **__environ;\n#ifdef __USE_GNU\nextern char **environ;\n#endif\n\n/* Replace the current process, executing PATH with arguments ARGV and\n   environment ENVP.  ARGV and ENVP are terminated by NULL pointers.  */\nextern int execve(const char *__path, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_XOPEN2K8\n/* Execute the file FD refers to, overlaying the running program image.\n   ARGV and ENVP are passed to the new program, as for `execve'.  */\nextern int fexecve(int __fd, char *const __argv[], char *const __envp[])\n__THROW __nonnull((2));\n#endif\n\n/* Execute PATH with arguments ARGV and environment from `environ'.  */\nextern int execv(const char *__path, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until a NULL pointer,\n   and the argument after that for environment.  */\nextern int execle(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute PATH with all arguments after PATH until\n   a NULL pointer and environment from `environ'.  */\nextern int execl(const char *__path, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvp(const char *__file, char *const __argv[])\n__THROW __nonnull((1, 2));\n\n/* Execute FILE, searching in the `PATH' environment variable if\n   it contains no slashes, with all arguments after FILE until a\n   NULL pointer and environment from `environ'.  */\nextern int execlp(const char *__file, const char *__arg, ...)\n__THROW __nonnull((1, 2));\n\n#ifdef __USE_GNU\n/* Execute FILE, searching in the `PATH' environment variable if it contains\n   no slashes, with arguments ARGV and environment from `environ'.  */\nextern int execvpe(const char *__file, char *const __argv[], char *const __envp[])\n__THROW __nonnull((1, 2));\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN\n/* Add INC to priority of the current process.  */\nextern int nice(int __inc)\n__THROW __wur;\n#endif\n\n/* Terminate program execution with the low-order 8 bits of STATUS.  */\nextern void _exit(int __status) __attribute__ ((__noreturn__));\n\n/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf';\n   the `_SC_*' symbols for the NAME argument to `sysconf';\n   and the `_CS_*' symbols for the NAME argument to `confstr'.  */\n#include <bits/confname.h>\n\n/* Get file-specific configuration information about PATH.  */\nextern long int pathconf(const char *__path, int __name)\n__THROW __nonnull((1));\n\n/* Get file-specific configuration about descriptor FD.  */\nextern long int fpathconf(int __fd, int __name) __THROW;\n\n/* Get the value of the system variable NAME.  */\nextern long int sysconf(int __name) __THROW;\n\n#ifdef\t__USE_POSIX2\n/* Get the value of the string-valued system variable NAME.  */\nextern size_t confstr(int __name, char *__buf, size_t __len) __THROW;\n#endif\n\n/* Get the process ID of the calling process.  */\nextern __pid_t getpid(void) __THROW;\n\n/* Get the process ID of the calling process's parent.  */\nextern __pid_t getppid(void) __THROW;\n\n/* Get the process group ID of the calling process.  */\nextern __pid_t getpgrp(void) __THROW;\n\n/* Get the process group ID of process PID.  */\nextern __pid_t __getpgid(__pid_t __pid) __THROW;\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\nextern __pid_t getpgid(__pid_t __pid) __THROW;\n#endif\n\n/* Set the process group ID of the process matching PID to PGID.\n   If PID is zero, the current process's process group ID is set.\n   If PGID is zero, the process ID of the process is used.  */\nextern int setpgid(__pid_t __pid, __pid_t __pgid) __THROW;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Both System V and BSD have `setpgrp' functions, but with different\n   calling conventions.  The BSD function is the same as POSIX.1 `setpgid'\n   (above).  The System V function takes no arguments and puts the calling\n   process in its on group like `setpgid (0, 0)'.\n\n   New programs should always use `setpgid' instead.\n\n   GNU provides the POSIX.1 function.  */\n\n/* Set the process group ID of the calling process to its own PID.\n   This is exactly the same as `setpgid (0, 0)'.  */\nextern int setpgrp(void) __THROW;\n\n#endif\t\t\t\t/* Use misc or X/Open.  */\n\n/* Create a new session with the calling process as its leader.\n   The process group IDs of the session and the calling process\n   are set to the process ID of the calling process, which is returned.  */\nextern __pid_t setsid(void) __THROW;\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n/* Return the session ID of the given process.  */\nextern __pid_t getsid(__pid_t __pid) __THROW;\n#endif\n\n/* Get the real user ID of the calling process.  */\nextern __uid_t getuid(void) __THROW;\n\n/* Get the effective user ID of the calling process.  */\nextern __uid_t geteuid(void) __THROW;\n\n/* Get the real group ID of the calling process.  */\nextern __gid_t getgid(void) __THROW;\n\n/* Get the effective group ID of the calling process.  */\nextern __gid_t getegid(void) __THROW;\n\n/* If SIZE is zero, return the number of supplementary groups\n   the calling process is in.  Otherwise, fill in the group IDs\n   of its supplementary groups in LIST and return the number written.  */\nextern int getgroups(int __size, __gid_t __list[])\n__THROW __wur;\n\n#ifdef\t__USE_GNU\n/* Return nonzero iff the calling process is in group GID.  */\nextern int group_member(__gid_t __gid) __THROW;\n#endif\n\n/* Set the user ID of the calling process to UID.\n   If the calling process is the super-user, set the real\n   and effective user IDs, and the saved set-user-ID to UID;\n   if not, the effective user ID is set to UID.  */\nextern int setuid(__uid_t __uid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real user ID of the calling process to RUID,\n   and the effective user ID of the calling process to EUID.  */\nextern int setreuid(__uid_t __ruid, __uid_t __euid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective user ID of the calling process to UID.  */\nextern int seteuid(__uid_t __uid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n/* Set the group ID of the calling process to GID.\n   If the calling process is the super-user, set the real\n   and effective group IDs, and the saved set-group-ID to GID;\n   if not, the effective group ID is set to GID.  */\nextern int setgid(__gid_t __gid)\n__THROW __wur;\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n/* Set the real group ID of the calling process to RGID,\n   and the effective group ID of the calling process to EGID.  */\nextern int setregid(__gid_t __rgid, __gid_t __egid)\n__THROW __wur;\n#endif\n\n#ifdef __USE_XOPEN2K\n/* Set the effective group ID of the calling process to GID.  */\nextern int setegid(__gid_t __gid)\n__THROW __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_GNU\n/* Fetch the real user ID, effective user ID, and saved-set user ID,\n   of the calling process.  */\nextern int getresuid(__uid_t * __ruid, __uid_t * __euid, __uid_t * __suid) __THROW;\n\n/* Fetch the real group ID, effective group ID, and saved-set group ID,\n   of the calling process.  */\nextern int getresgid(__gid_t * __rgid, __gid_t * __egid, __gid_t * __sgid) __THROW;\n\n/* Set the real user ID, effective user ID, and saved-set user ID,\n   of the calling process to RUID, EUID, and SUID, respectively.  */\nextern int setresuid(__uid_t __ruid, __uid_t __euid, __uid_t __suid)\n__THROW __wur;\n\n/* Set the real group ID, effective group ID, and saved-set group ID,\n   of the calling process to RGID, EGID, and SGID, respectively.  */\nextern int setresgid(__gid_t __rgid, __gid_t __egid, __gid_t __sgid)\n__THROW __wur;\n#endif\n\n/* Clone the calling process, creating an exact copy.\n   Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t fork(void) __THROWNL;\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \\\n    || defined __USE_MISC\n/* Clone the calling process, but without copying the whole address space.\n   The calling process is suspended until the new process exits or is\n   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,\n   and the process ID of the new process to the old process.  */\nextern __pid_t vfork(void) __THROW;\n#endif\t\t\t\t/* Use misc or XPG < 7. */\n\n/* Return the pathname of the terminal FD is open on, or NULL on errors.\n   The returned storage is good only until the next call to this function.  */\nextern char *ttyname(int __fd) __THROW;\n\n/* Store at most BUFLEN characters of the pathname of the terminal FD is\n   open on in BUF.  Return 0 on success, otherwise an error number.  */\nextern int ttyname_r(int __fd, char *__buf, size_t __buflen)\n__THROW __nonnull((2)) __wur;\n\n/* Return 1 if FD is a valid descriptor associated\n   with a terminal, zero if not.  */\nextern int isatty(int __fd) __THROW;\n\n#ifdef __USE_MISC\n/* Return the index into the active-logins file (utmp) for\n   the controlling terminal.  */\nextern int ttyslot(void) __THROW;\n#endif\n\n/* Make a link to FROM named TO.  */\nextern int link(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n#ifdef __USE_ATFILE\n/* Like link but relative paths in TO and FROM are interpreted relative\n   to FROMFD and TOFD respectively.  */\nextern int linkat(int __fromfd, const char *__from, int __tofd, const char *__to, int __flags)\n__THROW __nonnull((2, 4)) __wur;\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n/* Make a symbolic link to FROM named TO.  */\nextern int symlink(const char *__from, const char *__to)\n__THROW __nonnull((1, 2)) __wur;\n\n/* Read the contents of the symbolic link PATH into no more than\n   LEN bytes of BUF.  The contents are not null-terminated.\n   Returns the number of characters read, or -1 for errors.  */\nextern ssize_t readlink(const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((1, 2)) __wur;\n#endif\t\t\t\t/* Use POSIX.1-2001.  */\n\n#ifdef __USE_ATFILE\n/* Like symlink but a relative path in TO is interpreted relative to TOFD.  */\nextern int symlinkat(const char *__from, int __tofd, const char *__to)\n__THROW __nonnull((1, 3)) __wur;\n\n/* Like readlink but a relative PATH is interpreted relative to FD.  */\nextern ssize_t readlinkat(int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len)\n__THROW __nonnull((2, 3)) __wur;\n#endif\n\n/* Remove the link NAME.  */\nextern int unlink(const char *__name)\n__THROW __nonnull((1));\n\n#ifdef __USE_ATFILE\n/* Remove the link NAME relative to FD.  */\nextern int unlinkat(int __fd, const char *__name, int __flag)\n__THROW __nonnull((2));\n#endif\n\n/* Remove the directory PATH.  */\nextern int rmdir(const char *__path)\n__THROW __nonnull((1));\n\n/* Return the foreground process group ID of FD.  */\nextern __pid_t tcgetpgrp(int __fd) __THROW;\n\n/* Set the foreground process group ID of FD set PGRP_ID.  */\nextern int tcsetpgrp(int __fd, __pid_t __pgrp_id) __THROW;\n\n/* Return the login name of the user.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern char *getlogin(void);\n#if defined __USE_REENTRANT || defined __USE_POSIX199506\n/* Return at most NAME_LEN characters of the login name of the user in NAME.\n   If it cannot be determined or some other error occurred, return the error\n   code.  Otherwise return 0.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int getlogin_r(char *__name, size_t __name_len) __nonnull((1));\n#endif\n\n#ifdef\t__USE_MISC\n/* Set the login name returned by `getlogin'.  */\nextern int setlogin(const char *__name)\n__THROW __nonnull((1));\n#endif\n\n#ifdef\t__USE_POSIX2\n/* Get definitions and prototypes for functions to process the\n   arguments in ARGV (ARGC of them, minus the program name) for\n   options given in OPTS.  */\n#define __need_getopt\n#include <getopt.h>\n#endif\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n/* Put the name of the current host in no more than LEN bytes of NAME.\n   The result is null-terminated if LEN is large enough for the full\n   name and the terminator.  */\nextern int gethostname(char *__name, size_t __len)\n__THROW __nonnull((1));\n#endif\n\n#if defined __USE_MISC\n/* Set the name of the current host to NAME, which is LEN bytes long.\n   This call is restricted to the super-user.  */\nextern int sethostname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Set the current machine's Internet number to ID.\n   This call is restricted to the super-user.  */\nextern int sethostid(long int __id)\n__THROW __wur;\n\n/* Get and set the NIS (aka YP) domain name, if any.\n   Called just like `gethostname' and `sethostname'.\n   The NIS domain name is usually the empty string when not using NIS.  */\nextern int getdomainname(char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\nextern int setdomainname(const char *__name, size_t __len)\n__THROW __nonnull((1)) __wur;\n\n/* Revoke access permissions to all processes currently communicating\n   with the control terminal, and then send a SIGHUP signal to the process\n   group of the control terminal.  */\nextern int vhangup(void) __THROW;\n\n/* Revoke the access of all descriptors currently open on FILE.  */\nextern int revoke(const char *__file)\n__THROW __nonnull((1)) __wur;\n\n/* Enable statistical profiling, writing samples of the PC into at most\n   SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling\n   is enabled, the system examines the user PC and increments\n   SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536].  If SCALE is zero,\n   disable profiling.  Returns zero on success, -1 on error.  */\nextern int profil(unsigned short int *__sample_buffer, size_t __size, size_t __offset, unsigned int __scale)\n__THROW __nonnull((1));\n\n/* Turn accounting on if NAME is an existing file.  The system will then write\n   a record for each process as it terminates, to this file.  If NAME is NULL,\n   turn accounting off.  This call is restricted to the super-user.  */\nextern int acct(const char *__name) __THROW;\n\n/* Successive calls return the shells listed in `/etc/shells'.  */\nextern char *getusershell(void) __THROW;\nextern void endusershell(void) __THROW;\t/* Discard cached info.  */\nextern void setusershell(void) __THROW;\t/* Rewind and re-read the file.  */\n\n/* Put the program in the background, and dissociate from the controlling\n   terminal.  If NOCHDIR is zero, do `chdir (\"/\")'.  If NOCLOSE is zero,\n   redirects stdin, stdout, and stderr to /dev/null.  */\nextern int daemon(int __nochdir, int __noclose)\n__THROW __wur;\n#endif\t\t\t\t/* Use misc.  */\n\n#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)\n/* Make PATH be the root directory (the starting point for absolute paths).\n   This call is restricted to the super-user.  */\nextern int chroot(const char *__path)\n__THROW __nonnull((1)) __wur;\n\n/* Prompt with PROMPT and read a string from the terminal without echoing.\n   Uses /dev/tty if possible; otherwise stderr and stdin.  */\nextern char *getpass(const char *__prompt) __nonnull((1));\n#endif\t\t\t\t/* Use misc || X/Open.  */\n\n/* Make all changes done to FD actually appear on disk.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\nextern int fsync(int __fd);\n\n#ifdef __USE_GNU\n/* Make all changes done to all files on the file system associated\n   with FD actually appear on disk.  */\nextern int syncfs(int __fd) __THROW;\n#endif\n\n#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED\n\n/* Return identifier for the current host.  */\nextern long int gethostid(void);\n\n/* Make all changes done to all files actually appear on disk.  */\nextern void sync(void) __THROW;\n\n#if defined __USE_MISC || !defined __USE_XOPEN2K\n/* Return the number of bytes in a page.  This is the system's page size,\n   which is not necessarily the same as the hardware page size.  */\nextern int getpagesize(void)\n__THROW __attribute__ ((__const__));\n\n/* Return the maximum number of file descriptors\n   the current process could possibly have.  */\nextern int getdtablesize(void) __THROW;\n#endif\n\n#endif\t\t\t\t/* Use misc || X/Open Unix.  */\n\n#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8\n\n/* Truncate FILE to LENGTH bytes.  */\n#ifndef __USE_FILE_OFFSET64\nextern int truncate(const char *__file, __off_t __length)\n__THROW __nonnull((1)) __wur;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(truncate, (const char *__file, __off64_t __length), truncate64) __nonnull((1)) __wur;\n#else\n#define truncate truncate64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int truncate64(const char *__file, __off64_t __length)\n__THROW __nonnull((1)) __wur;\n#endif\n\n#endif\t\t\t\t/* Use X/Open Unix || POSIX 2008.  */\n\n#if defined __USE_POSIX199309 \\\n    || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K\n\n/* Truncate the file FD is open on to LENGTH bytes.  */\n#ifndef __USE_FILE_OFFSET64\nextern int ftruncate(int __fd, __off_t __length)\n__THROW __wur;\n#else\n#ifdef __REDIRECT_NTH\nextern int __REDIRECT_NTH(ftruncate, (int __fd, __off64_t __length), ftruncate64) __wur;\n#else\n#define ftruncate ftruncate64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int ftruncate64(int __fd, __off64_t __length)\n__THROW __wur;\n#endif\n\n#endif\t\t\t\t/* Use POSIX.1b || X/Open Unix || XPG6.  */\n\n#if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \\\n    || defined __USE_MISC\n\n/* Set the end of accessible data space (aka \"the break\") to ADDR.\n   Returns zero on success and -1 for errors (with errno set).  */\nextern int brk(void *__addr)\n__THROW __wur;\n\n/* Increase or decrease the end of accessible data space by DELTA bytes.\n   If successful, returns the address the previous end of data space\n   (i.e. the beginning of the new space, if DELTA > 0);\n   returns (void *) -1 for errors (with errno set).  */\nextern void *sbrk(intptr_t __delta) __THROW;\n#endif\n\n#ifdef __USE_MISC\n/* Invoke `system call' number SYSNO, passing it the remaining arguments.\n   This is completely system-dependent, and not often useful.\n\n   In Unix, `syscall' sets `errno' for all errors and most calls return -1\n   for errors; in many systems you cannot pass arguments or get return\n   values for all system calls (`pipe', `fork', and `getppid' typically\n   among them).\n\n   In Mach, all system calls take normal arguments and always return an\n   error code (zero for success).  */\nextern long int syscall(long int __sysno, ...) __THROW;\n\n#endif\t\t\t\t/* Use misc.  */\n\n#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK\n/* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both\n   files consistent.  Some systems have them there and some here, and some\n   software depends on the macros being defined without including both.  */\n\n/* `lockf' is a simpler interface to the locking facilities of `fcntl'.\n   LEN is always relative to the current file position.\n   The CMD argument is one of the following.\n\n   This function is a cancellation point and therefore not marked with\n   __THROW.  */\n\n#define F_ULOCK 0\t\t/* Unlock a previously locked region.  */\n#define F_LOCK  1\t\t/* Lock a region for exclusive use.  */\n#define F_TLOCK 2\t\t/* Test and lock a region for exclusive use.  */\n#define F_TEST  3\t\t/* Test a region for other processes locks.  */\n\n#ifndef __USE_FILE_OFFSET64\nextern int lockf(int __fd, int __cmd, __off_t __len) __wur;\n#else\n#ifdef __REDIRECT\nextern int __REDIRECT(lockf, (int __fd, int __cmd, __off64_t __len), lockf64) __wur;\n#else\n#define lockf lockf64\n#endif\n#endif\n#ifdef __USE_LARGEFILE64\nextern int lockf64(int __fd, int __cmd, __off64_t __len) __wur;\n#endif\n#endif\t\t\t\t/* Use misc and F_LOCK not already defined.  */\n\n#ifdef __USE_GNU\n\n/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'\n   set to EINTR.  */\n\n#define TEMP_FAILURE_RETRY(expression) \\\n  (__extension__\t\t\t\t\t\t\t      \\\n    ({ long int __result;\t\t\t\t\t\t      \\\n       do __result = (long int) (expression);\t\t\t\t      \\\n       while (__result == -1L && errno == EINTR);\t\t\t      \\\n       __result; }))\n#endif\n\n#if defined __USE_POSIX199309 || defined __USE_UNIX98\n/* Synchronize at least the data part of a file with the underlying\n   media.  */\nextern int fdatasync(int __fildes);\n#endif\t\t\t\t/* Use POSIX199309 */\n\n/* XPG4.2 specifies that prototypes for the encryption functions must\n   be defined here.  */\n#ifdef\t__USE_XOPEN\n/* Encrypt at most 8 characters from KEY using salt to perturb DES.  */\nextern char *crypt(const char *__key, const char *__salt)\n__THROW __nonnull((1, 2));\n\n/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt\n   block in place.  */\nextern void encrypt(char *__glibc_block, int __edflag)\n__THROW __nonnull((1));\n\n/* Swab pairs bytes in the first N bytes of the area pointed to by\n   FROM and copy the result to TO.  The value of TO must not be in the\n   range [FROM - N + 1, FROM - 1].  If N is odd the first byte in FROM\n   is without partner.  */\nextern void swab(const void *__restrict __from, void *__restrict __to, ssize_t __n)\n__THROW __nonnull((1, 2));\n#endif\n\n/* Prior to Issue 6, the Single Unix Specification required these\n   prototypes to appear in this header.  They are also found in\n   <stdio.h>.  */\n#if defined __USE_XOPEN && !defined __USE_XOPEN2K\n/* Return the name of the controlling terminal.  */\nextern char *ctermid(char *__s) __THROW;\n\n/* Return the name of the current user.  */\nextern char *cuserid(char *__s);\n#endif\n\n/* Unix98 requires this function to be declared here.  In other\n   standards it is in <pthread.h>.  */\n#if defined __USE_UNIX98 && !defined __USE_XOPEN2K\nextern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n#include <bits/unistd.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* unistd.h  */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/utime.h",
    "content": "/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *\tPOSIX Standard: 5.6.6 Set File Access and Modification Times  <utime.h>\n */\n\n#ifndef\t_UTIME_H\n#define\t_UTIME_H\t1\n\n#include <features.h>\n\n__BEGIN_DECLS\n#include <bits/types.h>\n#if defined __USE_XOPEN || defined __USE_XOPEN2K\n#define __need_time_t\n#include <time.h>\n#endif\n/* Structure describing file times.  */\n    struct utimbuf {\n\t__time_t actime;\t/* Access time.  */\n\t__time_t modtime;\t/* Modification time.  */\n};\n\n/* Set the access and modification times of FILE to those given in\n   *FILE_TIMES.  If FILE_TIMES is NULL, set them to the current time.  */\nextern int utime(const char *__file, const struct utimbuf *__file_times)\n__THROW __nonnull((1));\n\n__END_DECLS\n#endif\t\t\t\t/* utime.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/wchar.h",
    "content": "/* Copyright (C) 1995-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n/*\n *      ISO C99 Standard: 7.24\n *\tExtended multibyte and wide character utilities\t<wchar.h>\n */\n\n#ifndef _WCHAR_H\n\n#if !defined __need_mbstate_t && !defined __need_wint_t\n#define _WCHAR_H 1\n#include <features.h>\n#endif\n\n#ifdef _WCHAR_H\n/* Get FILE definition.  */\n#define __need___FILE\n#if defined __USE_UNIX98 || defined __USE_XOPEN2K\n#define __need_FILE\n#endif\n#include <stdio.h>\n/* Get va_list definition.  */\n#define __need___va_list\n#include <stdarg.h>\n\n#include <bits/wchar.h>\n\n/* Get size_t, wchar_t, wint_t and NULL from <stddef.h>.  */\n#define __need_size_t\n#define __need_wchar_t\n#define __need_NULL\n#endif\n#if defined _WCHAR_H || defined __need_wint_t || !defined __WINT_TYPE__\n#undef __need_wint_t\n#define __need_wint_t\n#include <stddef.h>\n\n/* We try to get wint_t from <stddef.h>, but not all GCC versions define it\n   there.  So define it ourselves if it remains undefined.  */\n#ifndef _WINT_T\n/* Integral type unchanged by default argument promotions that can\n   hold any value corresponding to members of the extended character\n   set, as well as at least one value that does not correspond to any\n   member of the extended character set.  */\n#define _WINT_T\ntypedef unsigned int wint_t;\n#else\n/* Work around problems with the <stddef.h> file which doesn't put\n   wint_t in the std namespace.  */\n#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \\\n      && defined __WINT_TYPE__\n__BEGIN_NAMESPACE_STD typedef __WINT_TYPE__ wint_t;\n__END_NAMESPACE_STD\n#endif\n#endif\n/* Tell the caller that we provide correct C++ prototypes.  */\n#if defined __cplusplus && __GNUC_PREREQ (4, 4)\n#define __CORRECT_ISO_CPP_WCHAR_H_PROTO\n#endif\n#endif\n#if (defined _WCHAR_H || defined __need_mbstate_t) && !defined ____mbstate_t_defined\n#define ____mbstate_t_defined\t1\n/* Conversion state information.  */\n    typedef struct {\n\tint __count;\n\tunion {\n#ifdef __WINT_TYPE__\n\t\t__WINT_TYPE__ __wch;\n#else\n\t\twint_t __wch;\n#endif\n\t\tchar __wchb[4];\n\t} __value;\t\t/* Value so far.  */\n} __mbstate_t;\n#endif\n#undef __need_mbstate_t\n\n/* The rest of the file is only used if used if __need_mbstate_t is not\n   defined.  */\n#ifdef _WCHAR_H\n\n#ifndef __mbstate_t_defined\n__BEGIN_NAMESPACE_C99\n/* Public type.  */\ntypedef __mbstate_t mbstate_t;\n__END_NAMESPACE_C99\n#define __mbstate_t_defined 1\n#endif\n#ifdef __USE_GNU\n__USING_NAMESPACE_C99(mbstate_t)\n#endif\n#ifndef WCHAR_MIN\n/* These constants might also be defined in <inttypes.h>.  */\n#define WCHAR_MIN __WCHAR_MIN\n#define WCHAR_MAX __WCHAR_MAX\n#endif\n#ifndef WEOF\n#define WEOF (0xffffffffu)\n#endif\n/* For XPG4 compliance we have to define the stuff from <wctype.h> here\n   as well.  */\n#if defined __USE_XOPEN && !defined __USE_UNIX98\n#include <wctype.h>\n#endif\n__BEGIN_DECLS __BEGIN_NAMESPACE_STD\n/* This incomplete type is defined in <time.h> but needed here because\n   of `wcsftime'.  */\nstruct tm;\n__END_NAMESPACE_STD\n/* XXX We have to clean this up at some point.  Since tm is in the std\n   namespace but wcsftime is in __c99 the type wouldn't be found\n   without inserting it in the global namespace.  */\n__USING_NAMESPACE_STD(tm)\n\n__BEGIN_NAMESPACE_STD\n/* Copy SRC to DEST.  */\nextern wchar_t *wcscpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src)\n__THROW __nonnull((1, 2));\n\n/* Copy no more than N wide-characters of SRC to DEST.  */\nextern wchar_t *wcsncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Append SRC onto DEST.  */\nextern wchar_t *wcscat(wchar_t * __restrict __dest, const wchar_t * __restrict __src)\n__THROW __nonnull((1, 2));\n/* Append no more than N wide-characters of SRC onto DEST.  */\nextern wchar_t *wcsncat(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n)\n__THROW __nonnull((1, 2));\n\n/* Compare S1 and S2.  */\nextern int wcscmp(const wchar_t * __s1, const wchar_t * __s2)\n__THROW __attribute_pure__ __nonnull((1, 2));\n/* Compare N wide-characters of S1 and S2.  */\nextern int wcsncmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__ __nonnull((1, 2));\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* Compare S1 and S2, ignoring case.  */\nextern int wcscasecmp(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n\n/* Compare no more than N chars of S1 and S2, ignoring case.  */\nextern int wcsncasecmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n#include <xlocale.h>\n\nextern int wcscasecmp_l(const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) __THROW;\n\nextern int wcsncasecmp_l(const wchar_t * __s1, const wchar_t * __s2, size_t __n, __locale_t __loc) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the current locale.  */\nextern int wcscoll(const wchar_t * __s1, const wchar_t * __s2) __THROW;\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN2K8\n/* Similar to the two functions above but take the information from\n   the provided locale and not the global locale.  */\n/* Compare S1 and S2, both interpreted as appropriate to the\n   LC_COLLATE category of the given locale.  */\nextern int wcscoll_l(const wchar_t * __s1, const wchar_t * __s2, __locale_t __loc) __THROW;\n\n/* Transform S2 into array pointed to by S1 such that if wcscmp is\n   applied to two transformed strings the result is the as applying\n   `wcscoll' to the original strings.  */\nextern size_t wcsxfrm_l(wchar_t * __s1, const wchar_t * __s2, size_t __n, __locale_t __loc) __THROW;\n\n/* Duplicate S, returning an identical malloc'd string.  */\nextern wchar_t *wcsdup(const wchar_t * __s)\n__THROW __attribute_malloc__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Find the first occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcschr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcschr\") __attribute_pure__;\n#else\nextern wchar_t *wcschr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n/* Find the last occurrence of WC in WCS.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsrchr(wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __asm(\"wcsrchr\") __attribute_pure__;\n#else\nextern wchar_t *wcsrchr(const wchar_t * __wcs, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* This function is similar to `wcschr'.  But it returns a pointer to\n   the closing NUL wide character in case C is not found in S.  */\nextern wchar_t *wcschrnul(const wchar_t * __s, wchar_t __wc)\n__THROW __attribute_pure__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters not in REJECT.  */\nextern size_t wcscspn(const wchar_t * __wcs, const wchar_t * __reject)\n__THROW __attribute_pure__;\n/* Return the length of the initial segmet of WCS which\n   consists entirely of wide characters in  ACCEPT.  */\nextern size_t wcsspn(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n/* Find the first occurrence in WCS of any character in ACCEPT.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcspbrk(wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __asm(\"wcspbrk\") __attribute_pure__;\n#else\nextern wchar_t *wcspbrk(const wchar_t * __wcs, const wchar_t * __accept)\n__THROW __attribute_pure__;\n#endif\n/* Find the first occurrence of NEEDLE in HAYSTACK.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcsstr(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcsstr\") __attribute_pure__;\n#else\nextern wchar_t *wcsstr(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n#endif\n\n/* Divide WCS into tokens separated by characters in DELIM.  */\nextern wchar_t *wcstok(wchar_t * __restrict __s, const wchar_t * __restrict __delim, wchar_t ** __restrict __ptr) __THROW;\n\n/* Return the number of wide characters in S.  */\nextern size_t wcslen(const wchar_t * __s)\n__THROW __attribute_pure__;\n__END_NAMESPACE_STD\n#ifdef __USE_XOPEN\n/* Another name for `wcsstr' from XPG4.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wcswcs(wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\nextern \"C++\" const wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __asm(\"wcswcs\") __attribute_pure__;\n#else\nextern wchar_t *wcswcs(const wchar_t * __haystack, const wchar_t * __needle)\n__THROW __attribute_pure__;\n#endif\n#endif\n\n#ifdef __USE_XOPEN2K8\n/* Return the number of wide characters in S, but at most MAXLEN.  */\nextern size_t wcsnlen(const wchar_t * __s, size_t __maxlen)\n__THROW __attribute_pure__;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Search N wide characters of S for C.  */\n#ifdef __CORRECT_ISO_CPP_WCHAR_H_PROTO\nextern \"C++\" wchar_t * wmemchr(wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\nextern \"C++\" const wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __asm(\"wmemchr\") __attribute_pure__;\n#else\nextern wchar_t *wmemchr(const wchar_t * __s, wchar_t __c, size_t __n)\n__THROW __attribute_pure__;\n#endif\n\n/* Compare N wide characters of S1 and S2.  */\nextern int wmemcmp(const wchar_t * __s1, const wchar_t * __s2, size_t __n)\n__THROW __attribute_pure__;\n\n/* Copy N wide characters of SRC to DEST.  */\nextern wchar_t *wmemcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n\n/* Copy N wide characters of SRC to DEST, guaranteeing\n   correct behavior for overlapping strings.  */\nextern wchar_t *wmemmove(wchar_t * __s1, const wchar_t * __s2, size_t __n) __THROW;\n\n/* Set N wide characters of S to C.  */\nextern wchar_t *wmemset(wchar_t * __s, wchar_t __c, size_t __n) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* Copy N wide characters of SRC to DEST and return pointer to following\n   wide character.  */\nextern wchar_t *wmempcpy(wchar_t * __restrict __s1, const wchar_t * __restrict __s2, size_t __n) __THROW;\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Determine whether C constitutes a valid (one-byte) multibyte\n   character.  */\nextern wint_t btowc(int __c) __THROW;\n\n/* Determine whether C corresponds to a member of the extended\n   character set whose multibyte representation is a single byte.  */\nextern int wctob(wint_t __c) __THROW;\n\n/* Determine whether PS points to an object representing the initial\n   state.  */\nextern int mbsinit(const mbstate_t * __ps)\n__THROW __attribute_pure__;\n\n/* Write wide character representation of multibyte character pointed\n   to by S to PWC.  */\nextern size_t mbrtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n, mbstate_t * __restrict __p) __THROW;\n\n/* Write multibyte representation of wide character WC to S.  */\nextern size_t wcrtomb(char *__restrict __s, wchar_t __wc, mbstate_t * __restrict __ps) __THROW;\n\n/* Return number of bytes in multibyte character pointed to by S.  */\nextern size_t __mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\nextern size_t mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_EXTERN_INLINES\n/* Define inline function as optimization.  */\n/* We can use the BTOWC and WCTOB optimizations since we know that all\n   locales must use ASCII encoding for the values in the ASCII range\n   and because the wchar_t encoding is always ISO 10646.  */\nextern wint_t __btowc_alias(int __c) __asm(\"btowc\");\n__extern_inline wint_t __NTH(btowc(int __c))\n{\n\treturn (__builtin_constant_p(__c) && __c >= '\\0' && __c <= '\\x7f' ? (wint_t) __c : __btowc_alias(__c));\n}\n\nextern int __wctob_alias(wint_t __c) __asm(\"wctob\");\n__extern_inline int __NTH(wctob(wint_t __wc))\n{\n\treturn (__builtin_constant_p(__wc) && __wc >= L'\\0' && __wc <= L'\\x7f' ? (int)__wc : __wctob_alias(__wc));\n}\n\n__extern_inline size_t __NTH(mbrlen(const char *__restrict __s, size_t __n, mbstate_t * __restrict __ps))\n{\n\treturn (__ps != NULL ? mbrtowc(NULL, __s, __n, __ps) : __mbrlen(__s, __n, NULL));\n}\n#endif\n\n__BEGIN_NAMESPACE_STD\n/* Write wide character representation of multibyte character string\n   SRC to DST.  */\nextern size_t mbsrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of wide character string\n   SRC to DST.  */\nextern size_t wcsrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __len, mbstate_t * __restrict __ps) __THROW;\n__END_NAMESPACE_STD\n#ifdef\t__USE_XOPEN2K8\n/* Write wide character representation of at most NMC bytes of the\n   multibyte character string SRC to DST.  */\nextern size_t mbsnrtowcs(wchar_t * __restrict __dst, const char **__restrict __src, size_t __nmc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n\n/* Write multibyte character representation of at most NWC characters\n   from the wide character string SRC to DST.  */\nextern size_t wcsnrtombs(char *__restrict __dst, const wchar_t ** __restrict __src, size_t __nwc, size_t __len, mbstate_t * __restrict __ps) __THROW;\n#endif\t\t\t\t/* use POSIX 2008 */\n\n/* The following functions are extensions found in X/Open CAE.  */\n#ifdef __USE_XOPEN\n/* Determine number of column positions required for C.  */\nextern int wcwidth(wchar_t __c) __THROW;\n\n/* Determine number of column positions required for first N wide\n   characters (or fewer if S ends before this) in S.  */\nextern int wcswidth(const wchar_t * __s, size_t __n) __THROW;\n#endif\t\t\t\t/* Use X/Open.  */\n\n__BEGIN_NAMESPACE_STD\n/* Convert initial portion of the wide string NPTR to `double'\n   representation.  */\nextern double wcstod(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Likewise for `float' and `long double' sizes of floating-point numbers.  */\nextern float wcstof(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\nextern long double wcstold(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr) __THROW;\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* C99 */\n    __BEGIN_NAMESPACE_STD\n/* Convert initial portion of wide string NPTR to `long int'\n   representation.  */\nextern long int wcstol(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long int'\n   representation.  */\nextern unsigned long int wcstoul(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n__END_NAMESPACE_STD\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoll(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstoull(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* ISO C99.  */\n#ifdef __USE_GNU\n/* Convert initial portion of wide string NPTR to `long long int'\n   representation.  */\n__extension__ extern long long int wcstoq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n\n/* Convert initial portion of wide string NPTR to `unsigned long long int'\n   representation.  */\n__extension__ extern unsigned long long int wcstouq(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base) __THROW;\n#endif\t\t\t\t/* Use GNU.  */\n\n#ifdef __USE_GNU\n/* The concept of one static locale per category is not very well\n   thought out.  Many applications will need to process its data using\n   information from several different locales.  Another application is\n   the implementation of the internationalization handling in the\n   upcoming ISO C++ standard library.  To support this another set of\n   the functions using locale data exist which have an additional\n   argument.\n\n   Attention: all these functions are *not* standardized in any form.\n   This is a proof-of-concept implementation.  */\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  */\n#include <xlocale.h>\n\n/* Special versions of the functions above which take the locale to\n   use as an additional parameter.  */\nextern long int wcstol_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\nextern unsigned long int wcstoul_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\n__extension__ extern long long int wcstoll_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\n__extension__ extern unsigned long long int wcstoull_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, int __base, __locale_t __loc) __THROW;\n\nextern double wcstod_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n\nextern float wcstof_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n\nextern long double wcstold_l(const wchar_t * __restrict __nptr, wchar_t ** __restrict __endptr, __locale_t __loc) __THROW;\n#endif\t\t\t\t/* use GNU */\n\n#ifdef __USE_XOPEN2K8\n/* Copy SRC to DEST, returning the address of the terminating L'\\0' in\n   DEST.  */\nextern wchar_t *wcpcpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src) __THROW;\n\n/* Copy no more than N characters of SRC to DEST, returning the address of\n   the last character written into DEST.  */\nextern wchar_t *wcpncpy(wchar_t * __restrict __dest, const wchar_t * __restrict __src, size_t __n) __THROW;\n\n/* Wide character I/O functions.  */\n\n/* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces\n   a wide character string.  */\nextern __FILE *open_wmemstream(wchar_t ** __bufloc, size_t * __sizeloc) __THROW;\n#endif\n\n#if defined __USE_ISOC95 || defined __USE_UNIX98\n__BEGIN_NAMESPACE_STD\n/* Select orientation for stream.  */\nextern int fwide(__FILE * __fp, int __mode) __THROW;\n\n/* Write formatted output to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwprintf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */ ;\n/* Write formatted output to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wprintf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */ ;\n/* Write formatted output of at most N characters to S.  */\nextern int swprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */ ;\n\n/* Write formatted output to S from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwprintf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */ ;\n/* Write formatted output to stdout from argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwprintf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */ ;\n/* Write formatted output of at most N character to S from argument\n   list ARG.  */\nextern int vswprintf(wchar_t * __restrict __s, size_t __n, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */ ;\n\n/* Read formatted input from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n/* Read formatted input from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int wscanf(const wchar_t * __restrict __format, ...)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\n/* Read formatted input from S.  */\nextern int swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n\n#if defined __USE_ISOC99 && !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#ifdef __REDIRECT\n/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[\n   GNU extension which conflicts with valid %a followed by letter\n   s, S or [.  */\nextern int __REDIRECT(fwscanf, (__FILE * __restrict __stream, const wchar_t * __restrict __format, ...), __isoc99_fwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\nextern int __REDIRECT(wscanf, (const wchar_t * __restrict __format, ...), __isoc99_wscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */ ;\nextern int __REDIRECT_NTH(swscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...), __isoc99_swscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */ ;\n#else\nextern int __isoc99_fwscanf(__FILE * __restrict __stream, const wchar_t * __restrict __format, ...);\nextern int __isoc99_wscanf(const wchar_t * __restrict __format, ...);\nextern int __isoc99_swscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, ...) __THROW;\n#define fwscanf __isoc99_fwscanf\n#define wscanf __isoc99_wscanf\n#define swscanf __isoc99_swscanf\n#endif\n#endif\n\n__END_NAMESPACE_STD\n#endif\t\t\t\t/* Use ISO C95, C99 and Unix98. */\n#ifdef __USE_ISOC99\n    __BEGIN_NAMESPACE_C99\n/* Read formatted input from S into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n/* Read formatted input from stdin into argument list ARG.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\n/* Read formatted input from S into argument list ARG.  */\nextern int vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n\n#if !defined __USE_GNU \\\n     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \\\n     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)\n#ifdef __REDIRECT\nextern int __REDIRECT(vfwscanf, (__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vfwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\nextern int __REDIRECT(vwscanf, (const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vwscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */ ;\nextern int __REDIRECT_NTH(vswscanf, (const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg), __isoc99_vswscanf)\n     /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */ ;\n#else\nextern int __isoc99_vfwscanf(__FILE * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vwscanf(const wchar_t * __restrict __format, __gnuc_va_list __arg);\nextern int __isoc99_vswscanf(const wchar_t * __restrict __s, const wchar_t * __restrict __format, __gnuc_va_list __arg) __THROW;\n#define vfwscanf __isoc99_vfwscanf\n#define vwscanf __isoc99_vwscanf\n#define vswscanf __isoc99_vswscanf\n#endif\n#endif\n\n__END_NAMESPACE_C99\n#endif\t\t\t\t/* Use ISO C99. */\n    __BEGIN_NAMESPACE_STD\n/* Read a character from STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fgetwc(__FILE * __stream);\nextern wint_t getwc(__FILE * __stream);\n\n/* Read a character from stdin.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t getwchar(void);\n\n/* Write a character to STREAM.\n\n   These functions are possible cancellation points and therefore not\n   marked with __THROW.  */\nextern wint_t fputwc(wchar_t __wc, __FILE * __stream);\nextern wint_t putwc(wchar_t __wc, __FILE * __stream);\n\n/* Write a character to stdout.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t putwchar(wchar_t __wc);\n\n/* Get a newline-terminated wide character string of finite length\n   from STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wchar_t *fgetws(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* Write a string to STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern int fputws(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n\n/* Push a character back onto the input buffer of STREAM.\n\n   This function is a possible cancellation point and therefore not\n   marked with __THROW.  */\nextern wint_t ungetwc(wint_t __wc, __FILE * __stream);\n__END_NAMESPACE_STD\n#ifdef __USE_GNU\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t getwc_unlocked(__FILE * __stream);\nextern wint_t getwchar_unlocked(void);\n\n/* This is the wide character version of a GNU extension.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fgetwc_unlocked(__FILE * __stream);\n\n/* Faster version when locking is not necessary.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wint_t fputwc_unlocked(wchar_t __wc, __FILE * __stream);\n\n/* These are defined to be equivalent to the `char' functions defined\n   in POSIX.1:1996.\n\n   These functions are not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation they are cancellation points and\n   therefore not marked with __THROW.  */\nextern wint_t putwc_unlocked(wchar_t __wc, __FILE * __stream);\nextern wint_t putwchar_unlocked(wchar_t __wc);\n\n/* This function does the same as `fgetws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern wchar_t *fgetws_unlocked(wchar_t * __restrict __ws, int __n, __FILE * __restrict __stream);\n\n/* This function does the same as `fputws' but does not lock the stream.\n\n   This function is not part of POSIX and therefore no official\n   cancellation point.  But due to similarity with an POSIX interface\n   or due to the implementation it is a cancellation point and\n   therefore not marked with __THROW.  */\nextern int fputws_unlocked(const wchar_t * __restrict __ws, __FILE * __restrict __stream);\n#endif\n\n__BEGIN_NAMESPACE_C99\n/* Format TP into S according to FORMAT.\n   Write no more than MAXSIZE wide characters and return the number\n   of wide characters written, or 0 if it would exceed MAXSIZE.  */\nextern size_t wcsftime(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp) __THROW;\n__END_NAMESPACE_C99\n#ifdef __USE_GNU\n#include <xlocale.h>\n/* Similar to `wcsftime' but takes the information from\n   the provided locale and not the global locale.  */\nextern size_t wcsftime_l(wchar_t * __restrict __s, size_t __maxsize, const wchar_t * __restrict __format, const struct tm *__restrict __tp, __locale_t __loc) __THROW;\n#endif\n\n/* The X/Open standard demands that most of the functions defined in\n   the <wctype.h> header must also appear here.  This is probably\n   because some X/Open members wrote their implementation before the\n   ISO C standard was published and introduced the better solution.\n   We have to provide these definitions for compliance reasons but we\n   do this nonsense only if really necessary.  */\n#if defined __USE_UNIX98 && !defined __USE_GNU\n#define __need_iswxxx\n#include <wctype.h>\n#endif\n\n/* Define some macros helping to catch buffer overflows.  */\n#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function\n#include <bits/wchar2.h>\n#endif\n\n#ifdef __LDBL_COMPAT\n#include <bits/wchar-ldbl.h>\n#endif\n\n__END_DECLS\n#endif\t\t\t\t/* _WCHAR_H defined */\n#endif\t\t\t\t/* wchar.h  */\n/* Undefine all __need_* constants in case we are included to get those\n   constants but the whole file was already read.  */\n#undef __need_mbstate_t\n#undef __need_wint_t\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/xlocale.h",
    "content": "/* Definition of locale datatype.\n   Copyright (C) 1997-2016 Free Software Foundation, Inc.\n   This file is part of the GNU C Library.\n   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.\n\n   The GNU C Library is free software; you can redistribute it and/or\n   modify it under the terms of the GNU Lesser General Public\n   License as published by the Free Software Foundation; either\n   version 2.1 of the License, or (at your option) any later version.\n\n   The GNU C Library is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   Lesser General Public License for more details.\n\n   You should have received a copy of the GNU Lesser General Public\n   License along with the GNU C Library; if not, see\n   <http://www.gnu.org/licenses/>.  */\n\n#ifndef _XLOCALE_H\n#define _XLOCALE_H\t1\n\n/* Structure for reentrant locale using functions.  This is an\n   (almost) opaque type for the user level programs.  The file and\n   this data structure is not standardized.  Don't rely on it.  It can\n   go away without warning.  */\ntypedef struct __locale_struct {\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tstruct __locale_data *__locales[13];\t/* 13 = __LC_LAST. */\n\n\t/* To increase the speed of this solution we add some special members.  */\n\tconst unsigned short int *__ctype_b;\n\tconst int *__ctype_tolower;\n\tconst int *__ctype_toupper;\n\n\t/* Note: LC_ALL is not a valid index into this array.  */\n\tconst char *__names[13];\n} *__locale_t;\n\n/* POSIX 2008 makes locale_t official.  */\ntypedef __locale_t locale_t;\n\n#endif\t\t\t\t/* xlocale.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/zconf.h",
    "content": "/* zconf.h -- configuration of the zlib compression library\n * Copyright (C) 1995-2013 Jean-loup Gailly.\n * For conditions of distribution and use, see copyright notice in zlib.h\n */\n\n/* @(#) $Id$ */\n\n#ifndef ZCONF_H\n#define ZCONF_H\n\n/*\n * If you *really* need a unique prefix for all types and library functions,\n * compile with -DZ_PREFIX. The \"standard\" zlib should be compiled without it.\n * Even better than compiling with -DZ_PREFIX would be to use configure to set\n * this permanently in zconf.h using \"./configure --zprefix\".\n */\n#ifdef Z_PREFIX\t\t\t/* may be set to #if 1 by ./configure */\n#define Z_PREFIX_SET\n\n/* all linked symbols */\n#define _dist_code            z__dist_code\n#define _length_code          z__length_code\n#define _tr_align             z__tr_align\n#define _tr_flush_bits        z__tr_flush_bits\n#define _tr_flush_block       z__tr_flush_block\n#define _tr_init              z__tr_init\n#define _tr_stored_block      z__tr_stored_block\n#define _tr_tally             z__tr_tally\n#define adler32               z_adler32\n#define adler32_combine       z_adler32_combine\n#define adler32_combine64     z_adler32_combine64\n#ifndef Z_SOLO\n#define compress              z_compress\n#define compress2             z_compress2\n#define compressBound         z_compressBound\n#endif\n#define crc32                 z_crc32\n#define crc32_combine         z_crc32_combine\n#define crc32_combine64       z_crc32_combine64\n#define deflate               z_deflate\n#define deflateBound          z_deflateBound\n#define deflateCopy           z_deflateCopy\n#define deflateEnd            z_deflateEnd\n#define deflateInit2_         z_deflateInit2_\n#define deflateInit_          z_deflateInit_\n#define deflateParams         z_deflateParams\n#define deflatePending        z_deflatePending\n#define deflatePrime          z_deflatePrime\n#define deflateReset          z_deflateReset\n#define deflateResetKeep      z_deflateResetKeep\n#define deflateSetDictionary  z_deflateSetDictionary\n#define deflateSetHeader      z_deflateSetHeader\n#define deflateTune           z_deflateTune\n#define deflate_copyright     z_deflate_copyright\n#define get_crc_table         z_get_crc_table\n#ifndef Z_SOLO\n#define gz_error              z_gz_error\n#define gz_intmax             z_gz_intmax\n#define gz_strwinerror        z_gz_strwinerror\n#define gzbuffer              z_gzbuffer\n#define gzclearerr            z_gzclearerr\n#define gzclose               z_gzclose\n#define gzclose_r             z_gzclose_r\n#define gzclose_w             z_gzclose_w\n#define gzdirect              z_gzdirect\n#define gzdopen               z_gzdopen\n#define gzeof                 z_gzeof\n#define gzerror               z_gzerror\n#define gzflush               z_gzflush\n#define gzgetc                z_gzgetc\n#define gzgetc_               z_gzgetc_\n#define gzgets                z_gzgets\n#define gzoffset              z_gzoffset\n#define gzoffset64            z_gzoffset64\n#define gzopen                z_gzopen\n#define gzopen64              z_gzopen64\n#ifdef _WIN32\n#define gzopen_w              z_gzopen_w\n#endif\n#define gzprintf              z_gzprintf\n#define gzvprintf             z_gzvprintf\n#define gzputc                z_gzputc\n#define gzputs                z_gzputs\n#define gzread                z_gzread\n#define gzrewind              z_gzrewind\n#define gzseek                z_gzseek\n#define gzseek64              z_gzseek64\n#define gzsetparams           z_gzsetparams\n#define gztell                z_gztell\n#define gztell64              z_gztell64\n#define gzungetc              z_gzungetc\n#define gzwrite               z_gzwrite\n#endif\n#define inflate               z_inflate\n#define inflateBack           z_inflateBack\n#define inflateBackEnd        z_inflateBackEnd\n#define inflateBackInit_      z_inflateBackInit_\n#define inflateCopy           z_inflateCopy\n#define inflateEnd            z_inflateEnd\n#define inflateGetHeader      z_inflateGetHeader\n#define inflateInit2_         z_inflateInit2_\n#define inflateInit_          z_inflateInit_\n#define inflateMark           z_inflateMark\n#define inflatePrime          z_inflatePrime\n#define inflateReset          z_inflateReset\n#define inflateReset2         z_inflateReset2\n#define inflateSetDictionary  z_inflateSetDictionary\n#define inflateGetDictionary  z_inflateGetDictionary\n#define inflateSync           z_inflateSync\n#define inflateSyncPoint      z_inflateSyncPoint\n#define inflateUndermine      z_inflateUndermine\n#define inflateResetKeep      z_inflateResetKeep\n#define inflate_copyright     z_inflate_copyright\n#define inflate_fast          z_inflate_fast\n#define inflate_table         z_inflate_table\n#ifndef Z_SOLO\n#define uncompress            z_uncompress\n#endif\n#define zError                z_zError\n#ifndef Z_SOLO\n#define zcalloc               z_zcalloc\n#define zcfree                z_zcfree\n#endif\n#define zlibCompileFlags      z_zlibCompileFlags\n#define zlibVersion           z_zlibVersion\n\n/* all zlib typedefs in zlib.h and zconf.h */\n#define Byte                  z_Byte\n#define Bytef                 z_Bytef\n#define alloc_func            z_alloc_func\n#define charf                 z_charf\n#define free_func             z_free_func\n#ifndef Z_SOLO\n#define gzFile                z_gzFile\n#endif\n#define gz_header             z_gz_header\n#define gz_headerp            z_gz_headerp\n#define in_func               z_in_func\n#define intf                  z_intf\n#define out_func              z_out_func\n#define uInt                  z_uInt\n#define uIntf                 z_uIntf\n#define uLong                 z_uLong\n#define uLongf                z_uLongf\n#define voidp                 z_voidp\n#define voidpc                z_voidpc\n#define voidpf                z_voidpf\n\n/* all zlib structs in zlib.h and zconf.h */\n#define gz_header_s           z_gz_header_s\n#define internal_state        z_internal_state\n\n#endif\n\n#if defined(__MSDOS__) && !defined(MSDOS)\n#define MSDOS\n#endif\n#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)\n#define OS2\n#endif\n#if defined(_WINDOWS) && !defined(WINDOWS)\n#define WINDOWS\n#endif\n#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)\n#ifndef WIN32\n#define WIN32\n#endif\n#endif\n#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)\n#if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)\n#ifndef SYS16BIT\n#define SYS16BIT\n#endif\n#endif\n#endif\n\n/*\n * Compile with -DMAXSEG_64K if the alloc function cannot allocate more\n * than 64k bytes at a time (needed on systems with 16-bit int).\n */\n#ifdef SYS16BIT\n#define MAXSEG_64K\n#endif\n#ifdef MSDOS\n#define UNALIGNED_OK\n#endif\n\n#ifdef __STDC_VERSION__\n#ifndef STDC\n#define STDC\n#endif\n#if __STDC_VERSION__ >= 199901L\n#ifndef STDC99\n#define STDC99\n#endif\n#endif\n#endif\n#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))\n#define STDC\n#endif\n#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))\n#define STDC\n#endif\n#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))\n#define STDC\n#endif\n#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))\n#define STDC\n#endif\n\n#if defined(__OS400__) && !defined(STDC)\t/* iSeries (formerly AS/400). */\n#define STDC\n#endif\n\n#ifndef STDC\n#ifndef const\t\t\t/* cannot use !defined(STDC) && !defined(const) on Mac */\n#define const\t\t\t/* note: need a more gentle solution here */\n#endif\n#endif\n\n#if defined(ZLIB_CONST) && !defined(z_const)\n#define z_const const\n#else\n#define z_const\n#endif\n\n/* Some Mac compilers merge all .h files incorrectly: */\n#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)\n#define NO_DUMMY_DECL\n#endif\n\n/* Maximum value for memLevel in deflateInit2 */\n#ifndef MAX_MEM_LEVEL\n#ifdef MAXSEG_64K\n#define MAX_MEM_LEVEL 8\n#else\n#define MAX_MEM_LEVEL 9\n#endif\n#endif\n\n/* Maximum value for windowBits in deflateInit2 and inflateInit2.\n * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files\n * created by gzip. (Files created by minigzip can still be extracted by\n * gzip.)\n */\n#ifndef MAX_WBITS\n#define MAX_WBITS   15\t\t/* 32K LZ77 window */\n#endif\n\n/* The memory requirements for deflate are (in bytes):\n            (1 << (windowBits+2)) +  (1 << (memLevel+9))\n that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)\n plus a few kilobytes for small objects. For example, if you want to reduce\n the default memory requirements from 256K to 128K, compile with\n     make CFLAGS=\"-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7\"\n Of course this will generally degrade compression (there's no free lunch).\n\n   The memory requirements for inflate are (in bytes) 1 << windowBits\n that is, 32K for windowBits=15 (default value) plus a few kilobytes\n for small objects.\n*/\n\n\t\t\t/* Type declarations */\n\n#ifndef OF\t\t\t/* function prototypes */\n#ifdef STDC\n#define OF(args)  args\n#else\n#define OF(args)  ()\n#endif\n#endif\n\n#ifndef Z_ARG\t\t\t/* function prototypes for stdarg */\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#define Z_ARG(args)  args\n#else\n#define Z_ARG(args)  ()\n#endif\n#endif\n\n/* The following definitions for FAR are needed only for MSDOS mixed\n * model programming (small or medium model with some far allocations).\n * This was tested only with MSC; for other MSDOS compilers you may have\n * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,\n * just define FAR to be empty.\n */\n#ifdef SYS16BIT\n#if defined(M_I86SM) || defined(M_I86MM)\n     /* MSC small or medium model */\n#define SMALL_MEDIUM\n#ifdef _MSC_VER\n#define FAR _far\n#else\n#define FAR far\n#endif\n#endif\n#if (defined(__SMALL__) || defined(__MEDIUM__))\n     /* Turbo C small or medium model */\n#define SMALL_MEDIUM\n#ifdef __BORLANDC__\n#define FAR _far\n#else\n#define FAR far\n#endif\n#endif\n#endif\n\n#if defined(WINDOWS) || defined(WIN32)\n   /* If building or using zlib as a DLL, define ZLIB_DLL.\n    * This is not mandatory, but it offers a little performance increase.\n    */\n#ifdef ZLIB_DLL\n#if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))\n#ifdef ZLIB_INTERNAL\n#define ZEXTERN extern __declspec(dllexport)\n#else\n#define ZEXTERN extern __declspec(dllimport)\n#endif\n#endif\n#endif\t\t\t\t/* ZLIB_DLL */\n   /* If building or using zlib with the WINAPI/WINAPIV calling convention,\n    * define ZLIB_WINAPI.\n    * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.\n    */\n#ifdef ZLIB_WINAPI\n#ifdef FAR\n#undef FAR\n#endif\n#include <windows.h>\n     /* No need for _export, use ZLIB.DEF instead. */\n     /* For complete Windows compatibility, use WINAPI, not __stdcall. */\n#define ZEXPORT WINAPI\n#ifdef WIN32\n#define ZEXPORTVA WINAPIV\n#else\n#define ZEXPORTVA FAR CDECL\n#endif\n#endif\n#endif\n\n#if defined (__BEOS__)\n#ifdef ZLIB_DLL\n#ifdef ZLIB_INTERNAL\n#define ZEXPORT   __declspec(dllexport)\n#define ZEXPORTVA __declspec(dllexport)\n#else\n#define ZEXPORT   __declspec(dllimport)\n#define ZEXPORTVA __declspec(dllimport)\n#endif\n#endif\n#endif\n\n#ifndef ZEXTERN\n#define ZEXTERN extern\n#endif\n#ifndef ZEXPORT\n#define ZEXPORT\n#endif\n#ifndef ZEXPORTVA\n#define ZEXPORTVA\n#endif\n\n#ifndef FAR\n#define FAR\n#endif\n\n#if !defined(__MACTYPES__)\ntypedef unsigned char Byte;\t/* 8 bits */\n#endif\ntypedef unsigned int uInt;\t/* 16 bits or more */\ntypedef unsigned long uLong;\t/* 32 bits or more */\n\n#ifdef SMALL_MEDIUM\n   /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */\n#define Bytef Byte FAR\n#else\ntypedef Byte FAR Bytef;\n#endif\ntypedef char FAR charf;\ntypedef int FAR intf;\ntypedef uInt FAR uIntf;\ntypedef uLong FAR uLongf;\n\n#ifdef STDC\ntypedef void const *voidpc;\ntypedef void FAR *voidpf;\ntypedef void *voidp;\n#else\ntypedef Byte const *voidpc;\ntypedef Byte FAR *voidpf;\ntypedef Byte *voidp;\n#endif\n\n#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)\n#include <limits.h>\n#if (UINT_MAX == 0xffffffffUL)\n#define Z_U4 unsigned\n#elif (ULONG_MAX == 0xffffffffUL)\n#define Z_U4 unsigned long\n#elif (USHRT_MAX == 0xffffffffUL)\n#define Z_U4 unsigned short\n#endif\n#endif\n\n#ifdef Z_U4\ntypedef Z_U4 z_crc_t;\n#else\ntypedef unsigned long z_crc_t;\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#define Z_HAVE_UNISTD_H\n#endif\n\n#if 1\t\t\t\t/* was set to #if 1 by ./configure */\n#define Z_HAVE_STDARG_H\n#endif\n\n#ifdef STDC\n#ifndef Z_SOLO\n#include <sys/types.h>\t\t/* for off_t */\n#endif\n#endif\n\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#ifndef Z_SOLO\n#include <stdarg.h>\t\t/* for va_list */\n#endif\n#endif\n\n#ifdef _WIN32\n#ifndef Z_SOLO\n#include <stddef.h>\t\t/* for wchar_t */\n#endif\n#endif\n\n/* a little trick to accommodate both \"#define _LARGEFILE64_SOURCE\" and\n * \"#define _LARGEFILE64_SOURCE 1\" as requesting 64-bit operations, (even\n * though the former does not conform to the LFS document), but considering\n * both \"#undef _LARGEFILE64_SOURCE\" and \"#define _LARGEFILE64_SOURCE 0\" as\n * equivalently requesting no 64-bit operations\n */\n#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1\n#undef _LARGEFILE64_SOURCE\n#endif\n\n#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)\n#define Z_HAVE_UNISTD_H\n#endif\n#ifndef Z_SOLO\n#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)\n#include <unistd.h>\t\t/* for SEEK_*, off_t, and _LFS64_LARGEFILE */\n#ifdef VMS\n#include <unixio.h>\t\t/* for off_t */\n#endif\n#ifndef z_off_t\n#define z_off_t off_t\n#endif\n#endif\n#endif\n\n#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0\n#define Z_LFS64\n#endif\n\n#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)\n#define Z_LARGE64\n#endif\n\n#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)\n#define Z_WANT64\n#endif\n\n#if !defined(SEEK_SET) && !defined(Z_SOLO)\n#define SEEK_SET        0\t/* Seek from beginning of file.  */\n#define SEEK_CUR        1\t/* Seek from current position.  */\n#define SEEK_END        2\t/* Set file pointer to EOF plus \"offset\" */\n#endif\n\n#ifndef z_off_t\n#define z_off_t long\n#endif\n\n#if !defined(_WIN32) && defined(Z_LARGE64)\n#define z_off64_t off64_t\n#else\n#if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)\n#define z_off64_t __int64\n#else\n#define z_off64_t z_off_t\n#endif\n#endif\n\n/* MVS linker does not support external names larger than 8 bytes */\n#if defined(__MVS__)\n#pragma map(deflateInit_,\"DEIN\")\n#pragma map(deflateInit2_,\"DEIN2\")\n#pragma map(deflateEnd,\"DEEND\")\n#pragma map(deflateBound,\"DEBND\")\n#pragma map(inflateInit_,\"ININ\")\n#pragma map(inflateInit2_,\"ININ2\")\n#pragma map(inflateEnd,\"INEND\")\n#pragma map(inflateSync,\"INSY\")\n#pragma map(inflateSetDictionary,\"INSEDI\")\n#pragma map(compressBound,\"CMBND\")\n#pragma map(inflate_table,\"INTABL\")\n#pragma map(inflate_fast,\"INFA\")\n#pragma map(inflate_copyright,\"INCOPY\")\n#endif\n\n#endif\t\t\t\t/* ZCONF_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/include/zlib.h",
    "content": "/* zlib.h -- interface of the 'zlib' general purpose compression library\n  version 1.2.8, April 28th, 2013\n\n  Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler\n\n  This software is provided 'as-is', without any express or implied\n  warranty.  In no event will the authors be held liable for any damages\n  arising from the use of this software.\n\n  Permission is granted to anyone to use this software for any purpose,\n  including commercial applications, and to alter it and redistribute it\n  freely, subject to the following restrictions:\n\n  1. The origin of this software must not be misrepresented; you must not\n     claim that you wrote the original software. If you use this software\n     in a product, an acknowledgment in the product documentation would be\n     appreciated but is not required.\n  2. Altered source versions must be plainly marked as such, and must not be\n     misrepresented as being the original software.\n  3. This notice may not be removed or altered from any source distribution.\n\n  Jean-loup Gailly        Mark Adler\n  jloup@gzip.org          madler@alumni.caltech.edu\n\n  The data format used by the zlib library is described by RFCs (Request for\n  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950\n  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).\n*/\n\n#ifndef ZLIB_H\n#define ZLIB_H\n\n#include \"zconf.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define ZLIB_VERSION \"1.2.8\"\n#define ZLIB_VERNUM 0x1280\n#define ZLIB_VER_MAJOR 1\n#define ZLIB_VER_MINOR 2\n#define ZLIB_VER_REVISION 8\n#define ZLIB_VER_SUBREVISION 0\n\n/*\n    The 'zlib' compression library provides in-memory compression and\n  decompression functions, including integrity checks of the uncompressed data.\n  This version of the library supports only one compression method (deflation)\n  but other algorithms will be added later and will have the same stream\n  interface.\n\n    Compression can be done in a single step if the buffers are large enough,\n  or can be done by repeated calls of the compression function.  In the latter\n  case, the application must provide more input and/or consume the output\n  (providing more output space) before each call.\n\n    The compressed data format used by default by the in-memory functions is\n  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped\n  around a deflate stream, which is itself documented in RFC 1951.\n\n    The library also supports reading and writing files in gzip (.gz) format\n  with an interface similar to that of stdio using the functions that start\n  with \"gz\".  The gzip format is different from the zlib format.  gzip is a\n  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.\n\n    This library can optionally read and write gzip streams in memory as well.\n\n    The zlib format was designed to be compact and fast for use in memory\n  and on communications channels.  The gzip format was designed for single-\n  file compression on file systems, has a larger header than zlib to maintain\n  directory information, and uses a different, slower check method than zlib.\n\n    The library does not install any signal handler.  The decoder checks\n  the consistency of the compressed data, so the library should never crash\n  even in case of corrupted input.\n*/\n\n\ttypedef voidpf(*alloc_func) OF((voidpf opaque, uInt items, uInt size));\n\ttypedef void (*free_func) OF((voidpf opaque, voidpf address));\n\n\tstruct internal_state;\n\n\ttypedef struct z_stream_s {\n\t\tz_const Bytef *next_in;\t/* next input byte */\n\t\tuInt avail_in;\t/* number of bytes available at next_in */\n\t\tuLong total_in;\t/* total number of input bytes read so far */\n\n\t\tBytef *next_out;\t/* next output byte should be put there */\n\t\tuInt avail_out;\t/* remaining free space at next_out */\n\t\tuLong total_out;\t/* total number of bytes output so far */\n\n\t\tz_const char *msg;\t/* last error message, NULL if no error */\n\t\tstruct internal_state FAR *state;\t/* not visible by applications */\n\n\t\talloc_func zalloc;\t/* used to allocate the internal state */\n\t\tfree_func zfree;\t/* used to free the internal state */\n\t\tvoidpf opaque;\t/* private data object passed to zalloc and zfree */\n\n\t\tint data_type;\t/* best guess about the data type: binary or text */\n\t\tuLong adler;\t/* adler32 value of the uncompressed data */\n\t\tuLong reserved;\t/* reserved for future use */\n\t} z_stream;\n\n\ttypedef z_stream FAR *z_streamp;\n\n/*\n     gzip header information passed to and from zlib routines.  See RFC 1952\n  for more details on the meanings of these fields.\n*/\n\ttypedef struct gz_header_s {\n\t\tint text;\t/* true if compressed data believed to be text */\n\t\tuLong time;\t/* modification time */\n\t\tint xflags;\t/* extra flags (not used when writing a gzip file) */\n\t\tint os;\t\t/* operating system */\n\t\tBytef *extra;\t/* pointer to extra field or Z_NULL if none */\n\t\tuInt extra_len;\t/* extra field length (valid if extra != Z_NULL) */\n\t\tuInt extra_max;\t/* space at extra (only when reading header) */\n\t\tBytef *name;\t/* pointer to zero-terminated file name or Z_NULL */\n\t\tuInt name_max;\t/* space at name (only when reading header) */\n\t\tBytef *comment;\t/* pointer to zero-terminated comment or Z_NULL */\n\t\tuInt comm_max;\t/* space at comment (only when reading header) */\n\t\tint hcrc;\t/* true if there was or will be a header crc */\n\t\tint done;\t/* true when done reading gzip header (not used\n\t\t\t\t   when writing a gzip file) */\n\t} gz_header;\n\n\ttypedef gz_header FAR *gz_headerp;\n\n/*\n     The application must update next_in and avail_in when avail_in has dropped\n   to zero.  It must update next_out and avail_out when avail_out has dropped\n   to zero.  The application must initialize zalloc, zfree and opaque before\n   calling the init function.  All other fields are set by the compression\n   library and must not be updated by the application.\n\n     The opaque value provided by the application will be passed as the first\n   parameter for calls of zalloc and zfree.  This can be useful for custom\n   memory management.  The compression library attaches no meaning to the\n   opaque value.\n\n     zalloc must return Z_NULL if there is not enough memory for the object.\n   If zlib is used in a multi-threaded application, zalloc and zfree must be\n   thread safe.\n\n     On 16-bit systems, the functions zalloc and zfree must be able to allocate\n   exactly 65536 bytes, but will not be required to allocate more than this if\n   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers\n   returned by zalloc for objects of exactly 65536 bytes *must* have their\n   offset normalized to zero.  The default allocation function provided by this\n   library ensures this (see zutil.c).  To reduce memory requirements and avoid\n   any allocation of 64K objects, at the expense of compression ratio, compile\n   the library with -DMAX_WBITS=14 (see zconf.h).\n\n     The fields total_in and total_out can be used for statistics or progress\n   reports.  After compression, total_in holds the total size of the\n   uncompressed data and may be saved for use in the decompressor (particularly\n   if the decompressor wants to decompress everything in a single step).\n*/\n\n\t/* constants */\n\n#define Z_NO_FLUSH      0\n#define Z_PARTIAL_FLUSH 1\n#define Z_SYNC_FLUSH    2\n#define Z_FULL_FLUSH    3\n#define Z_FINISH        4\n#define Z_BLOCK         5\n#define Z_TREES         6\n/* Allowed flush values; see deflate() and inflate() below for details */\n\n#define Z_OK            0\n#define Z_STREAM_END    1\n#define Z_NEED_DICT     2\n#define Z_ERRNO        (-1)\n#define Z_STREAM_ERROR (-2)\n#define Z_DATA_ERROR   (-3)\n#define Z_MEM_ERROR    (-4)\n#define Z_BUF_ERROR    (-5)\n#define Z_VERSION_ERROR (-6)\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\n\n#define Z_NO_COMPRESSION         0\n#define Z_BEST_SPEED             1\n#define Z_BEST_COMPRESSION       9\n#define Z_DEFAULT_COMPRESSION  (-1)\n/* compression levels */\n\n#define Z_FILTERED            1\n#define Z_HUFFMAN_ONLY        2\n#define Z_RLE                 3\n#define Z_FIXED               4\n#define Z_DEFAULT_STRATEGY    0\n/* compression strategy; see deflateInit2() below for details */\n\n#define Z_BINARY   0\n#define Z_TEXT     1\n#define Z_ASCII    Z_TEXT\t/* for compatibility with 1.2.2 and earlier */\n#define Z_UNKNOWN  2\n/* Possible values of the data_type field (though see inflate()) */\n\n#define Z_DEFLATED   8\n/* The deflate compression method (the only one supported in this version) */\n\n#define Z_NULL  0\t\t/* for initializing zalloc, zfree, opaque */\n\n#define zlib_version zlibVersion()\n/* for compatibility with versions < 1.0.2 */\n\n\t/* basic functions */\n\n\tZEXTERN const char *ZEXPORT zlibVersion OF((void));\n/* The application can compare zlibVersion and ZLIB_VERSION for consistency.\n   If the first character differs, the library code actually used is not\n   compatible with the zlib.h header file used by the application.  This check\n   is automatically made by deflateInit and inflateInit.\n */\n\n/*\nZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));\n\n     Initializes the internal stream state for compression.  The fields\n   zalloc, zfree and opaque must be initialized before by the caller.  If\n   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default\n   allocation functions.\n\n     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:\n   1 gives best speed, 9 gives best compression, 0 gives no compression at all\n   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION\n   requests a default compromise between speed and compression (currently\n   equivalent to level 6).\n\n     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if level is not a valid compression level, or\n   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible\n   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null\n   if there is no error message.  deflateInit does not perform any compression:\n   this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));\n/*\n    deflate compresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n    The detailed semantics are as follows.  deflate performs one or both of the\n  following actions:\n\n  - Compress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in and avail_in are updated and\n    processing will resume at this point for the next call of deflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  This action is forced if the parameter flush is non zero.\n    Forcing flush frequently degrades the compression ratio, so this parameter\n    should be set only when necessary (in interactive applications).  Some\n    output may be provided even if flush is not set.\n\n    Before the call of deflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating avail_in or avail_out accordingly; avail_out should\n  never be zero before the call.  The application can consume the compressed\n  output when it wants, for example when the output buffer is full (avail_out\n  == 0), or after each call of deflate().  If deflate returns Z_OK and with\n  zero avail_out, it must be called again after making room in the output\n  buffer because there might be more output pending.\n\n    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to\n  decide how much data to accumulate before producing output, in order to\n  maximize compression.\n\n    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is\n  flushed to the output buffer and the output is aligned on a byte boundary, so\n  that the decompressor can get all input data available so far.  (In\n  particular avail_in is zero after the call if enough output space has been\n  provided before the call.) Flushing may degrade compression for some\n  compression algorithms and so it should be used only when necessary.  This\n  completes the current deflate block and follows it with an empty stored block\n  that is three bits plus filler bits to the next byte, followed by four bytes\n  (00 00 ff ff).\n\n    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the\n  output buffer, but the output is not aligned to a byte boundary.  All of the\n  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.\n  This completes the current deflate block and follows it with an empty fixed\n  codes block that is 10 bits long.  This assures that enough bytes are output\n  in order for the decompressor to finish the block before the empty fixed code\n  block.\n\n    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as\n  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to\n  seven bits of the current block are held to be written as the next byte after\n  the next deflate block is completed.  In this case, the decompressor may not\n  be provided enough bits at this point in order to complete decompression of\n  the data provided so far to the compressor.  It may need to wait for the next\n  block to be emitted.  This is for advanced applications that need to control\n  the emission of deflate blocks.\n\n    If flush is set to Z_FULL_FLUSH, all output is flushed as with\n  Z_SYNC_FLUSH, and the compression state is reset so that decompression can\n  restart from this point if previous compressed data has been damaged or if\n  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade\n  compression.\n\n    If deflate returns with avail_out == 0, this function must be called again\n  with the same value of the flush parameter and more output space (updated\n  avail_out), until the flush is complete (deflate returns with non-zero\n  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that\n  avail_out is greater than six to avoid repeated flush markers due to\n  avail_out == 0 on return.\n\n    If the parameter flush is set to Z_FINISH, pending input is processed,\n  pending output is flushed and deflate returns with Z_STREAM_END if there was\n  enough output space; if deflate returns with Z_OK, this function must be\n  called again with Z_FINISH and more output space (updated avail_out) but no\n  more input data, until it returns with Z_STREAM_END or an error.  After\n  deflate has returned Z_STREAM_END, the only possible operations on the stream\n  are deflateReset or deflateEnd.\n\n    Z_FINISH can be used immediately after deflateInit if all the compression\n  is to be done in a single step.  In this case, avail_out must be at least the\n  value returned by deflateBound (see below).  Then deflate is guaranteed to\n  return Z_STREAM_END.  If not enough output space is provided, deflate will\n  not return Z_STREAM_END, and it must be called again as described above.\n\n    deflate() sets strm->adler to the adler32 checksum of all input read\n  so far (that is, total_in bytes).\n\n    deflate() may update strm->data_type if it can make a good guess about\n  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered\n  binary.  This field is only for information purposes and does not affect the\n  compression algorithm in any manner.\n\n    deflate() returns Z_OK if some progress has been made (more input\n  processed or more output produced), Z_STREAM_END if all input has been\n  consumed and all output has been produced (only when flush is set to\n  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example\n  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible\n  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not\n  fatal, and deflate() can be called again with more input and more output\n  space to continue compressing.\n*/\n\n\tZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the\n   stream state was inconsistent, Z_DATA_ERROR if the stream was freed\n   prematurely (some input or output was discarded).  In the error case, msg\n   may be set but then points to a static string (which must not be\n   deallocated).\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));\n\n     Initializes the internal stream state for decompression.  The fields\n   next_in, avail_in, zalloc, zfree and opaque must be initialized before by\n   the caller.  If next_in is not Z_NULL and avail_in is large enough (the\n   exact value depends on the compression method), inflateInit determines the\n   compression method from the zlib header and allocates all data structures\n   accordingly; otherwise the allocation will be deferred to the first call of\n   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to\n   use default allocation functions.\n\n     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit() does not process any header information -- that is deferred\n   until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));\n/*\n    inflate decompresses as much data as possible, and stops when the input\n  buffer becomes empty or the output buffer becomes full.  It may introduce\n  some output latency (reading input without producing any output) except when\n  forced to flush.\n\n  The detailed semantics are as follows.  inflate performs one or both of the\n  following actions:\n\n  - Decompress more input starting at next_in and update next_in and avail_in\n    accordingly.  If not all input can be processed (because there is not\n    enough room in the output buffer), next_in is updated and processing will\n    resume at this point for the next call of inflate().\n\n  - Provide more output starting at next_out and update next_out and avail_out\n    accordingly.  inflate() provides as much output as possible, until there is\n    no more input data or no more space in the output buffer (see below about\n    the flush parameter).\n\n    Before the call of inflate(), the application should ensure that at least\n  one of the actions is possible, by providing more input and/or consuming more\n  output, and updating the next_* and avail_* values accordingly.  The\n  application can consume the uncompressed output when it wants, for example\n  when the output buffer is full (avail_out == 0), or after each call of\n  inflate().  If inflate returns Z_OK and with zero avail_out, it must be\n  called again after making room in the output buffer because there might be\n  more output pending.\n\n    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,\n  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much\n  output as possible to the output buffer.  Z_BLOCK requests that inflate()\n  stop if and when it gets to the next deflate block boundary.  When decoding\n  the zlib or gzip format, this will cause inflate() to return immediately\n  after the header and before the first block.  When doing a raw inflate,\n  inflate() will go ahead and process the first block, and will return when it\n  gets to the end of that block, or when it runs out of data.\n\n    The Z_BLOCK option assists in appending to or combining deflate streams.\n  Also to assist in this, on return inflate() will set strm->data_type to the\n  number of unused bits in the last byte taken from strm->next_in, plus 64 if\n  inflate() is currently decoding the last block in the deflate stream, plus\n  128 if inflate() returned immediately after decoding an end-of-block code or\n  decoding the complete header up to just before the first byte of the deflate\n  stream.  The end-of-block will not be indicated until all of the uncompressed\n  data from that block has been written to strm->next_out.  The number of\n  unused bits may in general be greater than seven, except when bit 7 of\n  data_type is set, in which case the number of unused bits will be less than\n  eight.  data_type is set as noted here every time inflate() returns for all\n  flush options, and so can be used to determine the amount of currently\n  consumed input in bits.\n\n    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the\n  end of each deflate block header is reached, before any actual data in that\n  block is decoded.  This allows the caller to determine the length of the\n  deflate block header for later use in random access within a deflate block.\n  256 is added to the value of strm->data_type when inflate() returns\n  immediately after reaching the end of the deflate block header.\n\n    inflate() should normally be called until it returns Z_STREAM_END or an\n  error.  However if all decompression is to be performed in a single step (a\n  single call of inflate), the parameter flush should be set to Z_FINISH.  In\n  this case all pending input is processed and all pending output is flushed;\n  avail_out must be large enough to hold all of the uncompressed data for the\n  operation to complete.  (The size of the uncompressed data may have been\n  saved by the compressor for this purpose.) The use of Z_FINISH is not\n  required to perform an inflation in one step.  However it may be used to\n  inform inflate that a faster approach can be used for the single inflate()\n  call.  Z_FINISH also informs inflate to not maintain a sliding window if the\n  stream completes, which reduces inflate's memory footprint.  If the stream\n  does not complete, either because not all of the stream is provided or not\n  enough output space is provided, then a sliding window will be allocated and\n  inflate() can be called again to continue the operation as if Z_NO_FLUSH had\n  been used.\n\n     In this implementation, inflate() always flushes as much output as\n  possible to the output buffer, and always uses the faster approach on the\n  first call.  So the effects of the flush parameter in this implementation are\n  on the return value of inflate() as noted below, when inflate() returns early\n  when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of\n  memory for a sliding window when Z_FINISH is used.\n\n     If a preset dictionary is needed after this call (see inflateSetDictionary\n  below), inflate sets strm->adler to the Adler-32 checksum of the dictionary\n  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets\n  strm->adler to the Adler-32 checksum of all output produced so far (that is,\n  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described\n  below.  At the end of the stream, inflate() checks that its computed adler32\n  checksum is equal to that saved by the compressor and returns Z_STREAM_END\n  only if the checksum is correct.\n\n    inflate() can decompress and check either zlib-wrapped or gzip-wrapped\n  deflate data.  The header type is detected automatically, if requested when\n  initializing with inflateInit2().  Any information contained in the gzip\n  header is not retained, so applications that need that information should\n  instead use raw inflate, see inflateInit2() below, or inflateBack() and\n  perform their own processing of the gzip header and trailer.  When processing\n  gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output\n  producted so far.  The CRC-32 is checked against the gzip trailer.\n\n    inflate() returns Z_OK if some progress has been made (more input processed\n  or more output produced), Z_STREAM_END if the end of the compressed data has\n  been reached and all uncompressed output has been produced, Z_NEED_DICT if a\n  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was\n  corrupted (input stream not conforming to the zlib format or incorrect check\n  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example\n  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,\n  Z_BUF_ERROR if no progress is possible or if there was not enough room in the\n  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and\n  inflate() can be called again with more input and more output space to\n  continue decompressing.  If Z_DATA_ERROR is returned, the application may\n  then call inflateSync() to look for a good compression block if a partial\n  recovery of the data is desired.\n*/\n\n\tZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));\n/*\n     All dynamically allocated data structures for this stream are freed.\n   This function discards any unprocessed input and does not flush any pending\n   output.\n\n     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state\n   was inconsistent.  In the error case, msg may be set but then points to a\n   static string (which must not be deallocated).\n*/\n\n\t/* Advanced functions */\n\n/*\n    The following functions are needed only in some special applications.\n*/\n\n/*\nZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,\n                                     int  level,\n                                     int  method,\n                                     int  windowBits,\n                                     int  memLevel,\n                                     int  strategy));\n\n     This is another version of deflateInit with more compression options.  The\n   fields next_in, zalloc, zfree and opaque must be initialized before by the\n   caller.\n\n     The method parameter is the compression method.  It must be Z_DEFLATED in\n   this version of the library.\n\n     The windowBits parameter is the base two logarithm of the window size\n   (the size of the history buffer).  It should be in the range 8..15 for this\n   version of the library.  Larger values of this parameter result in better\n   compression at the expense of memory usage.  The default value is 15 if\n   deflateInit is used instead.\n\n     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits\n   determines the window size.  deflate() will then generate raw deflate data\n   with no zlib header or trailer, and will not compute an adler32 check value.\n\n     windowBits can also be greater than 15 for optional gzip encoding.  Add\n   16 to windowBits to write a simple gzip header and trailer around the\n   compressed data instead of a zlib wrapper.  The gzip header will have no\n   file name, no extra data, no comment, no modification time (set to zero), no\n   header crc, and the operating system will be set to 255 (unknown).  If a\n   gzip stream is being written, strm->adler is a crc32 instead of an adler32.\n\n     The memLevel parameter specifies how much memory should be allocated\n   for the internal compression state.  memLevel=1 uses minimum memory but is\n   slow and reduces compression ratio; memLevel=9 uses maximum memory for\n   optimal speed.  The default value is 8.  See zconf.h for total memory usage\n   as a function of windowBits and memLevel.\n\n     The strategy parameter is used to tune the compression algorithm.  Use the\n   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a\n   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no\n   string match), or Z_RLE to limit match distances to one (run-length\n   encoding).  Filtered data consists mostly of small values with a somewhat\n   random distribution.  In this case, the compression algorithm is tuned to\n   compress them better.  The effect of Z_FILTERED is to force more Huffman\n   coding and less string matching; it is somewhat intermediate between\n   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as\n   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The\n   strategy parameter only affects the compression ratio but not the\n   correctness of the compressed output even if it is not set appropriately.\n   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler\n   decoder for special applications.\n\n     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid\n   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is\n   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is\n   set to null if there is no error message.  deflateInit2 does not perform any\n   compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the compression dictionary from the given byte sequence\n   without producing any compressed output.  When using the zlib format, this\n   function must be called immediately after deflateInit, deflateInit2 or\n   deflateReset, and before any call of deflate.  When doing raw deflate, this\n   function must be called either before any call of deflate, or immediately\n   after the completion of a deflate block, i.e. after all input has been\n   consumed and all output has been delivered when using any of the flush\n   options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH.  The\n   compressor and decompressor must use exactly the same dictionary (see\n   inflateSetDictionary).\n\n     The dictionary should consist of strings (byte sequences) that are likely\n   to be encountered later in the data to be compressed, with the most commonly\n   used strings preferably put towards the end of the dictionary.  Using a\n   dictionary is most useful when the data to be compressed is short and can be\n   predicted with good accuracy; the data can then be compressed better than\n   with the default empty dictionary.\n\n     Depending on the size of the compression data structures selected by\n   deflateInit or deflateInit2, a part of the dictionary may in effect be\n   discarded, for example if the dictionary is larger than the window size\n   provided in deflateInit or deflateInit2.  Thus the strings most likely to be\n   useful should be put at the end of the dictionary, not at the front.  In\n   addition, the current implementation of deflate will use at most the window\n   size minus 262 bytes of the provided dictionary.\n\n     Upon return of this function, strm->adler is set to the adler32 value\n   of the dictionary; the decompressor may later use this value to determine\n   which dictionary has been used by the compressor.  (The adler32 value\n   applies to the whole dictionary even if only a subset of the dictionary is\n   actually used by the compressor.) If a raw deflate was requested, then the\n   adler32 value is not computed and strm->adler is not set.\n\n     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent (for example if deflate has already been called for this stream\n   or if not at a block boundary for raw deflate).  deflateSetDictionary does\n   not perform any compression: this will be done by deflate().\n*/\n\n\tZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when several compression strategies will be\n   tried, for example when there are several ways of pre-processing the input\n   data with a filter.  The streams that will be discarded should then be freed\n   by calling deflateEnd.  Note that deflateCopy duplicates the internal\n   compression state which can be quite large, so this strategy is slow and can\n   consume lots of memory.\n\n     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to deflateEnd followed by deflateInit,\n   but does not free and reallocate all the internal compression state.  The\n   stream will keep the same compression level and any other attributes that\n   may have been set by deflateInit2.\n\n     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy));\n/*\n     Dynamically update the compression level and compression strategy.  The\n   interpretation of level and strategy is as in deflateInit2.  This can be\n   used to switch between compression and straight copy of the input data, or\n   to switch to a different kind of input data requiring a different strategy.\n   If the compression level is changed, the input available so far is\n   compressed with the old level (and may be flushed); the new level will take\n   effect only at the next call of deflate().\n\n     Before the call of deflateParams, the stream state must be set as for\n   a call of deflate(), since the currently available input may have to be\n   compressed and flushed.  In particular, strm->avail_out must be non-zero.\n\n     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source\n   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if\n   strm->avail_out was zero.\n*/\n\n\tZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain));\n/*\n     Fine tune deflate's internal compression parameters.  This should only be\n   used by someone who understands the algorithm used by zlib's deflate for\n   searching for the best matching string, and even then only by the most\n   fanatic optimizer trying to squeeze out the last compressed bit for their\n   specific input data.  Read the deflate.c source code for the meaning of the\n   max_lazy, good_length, nice_length, and max_chain parameters.\n\n     deflateTune() can be called after deflateInit() or deflateInit2(), and\n   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.\n */\n\n\tZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen));\n/*\n     deflateBound() returns an upper bound on the compressed size after\n   deflation of sourceLen bytes.  It must be called after deflateInit() or\n   deflateInit2(), and after deflateSetHeader(), if used.  This would be used\n   to allocate an output buffer for deflation in a single pass, and so would be\n   called before deflate().  If that first deflate() call is provided the\n   sourceLen input bytes, an output buffer allocated to the size returned by\n   deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed\n   to return Z_STREAM_END.  Note that it is possible for the compressed size to\n   be larger than the value returned by deflateBound() if flush options other\n   than Z_FINISH or Z_NO_FLUSH are used.\n*/\n\n\tZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, unsigned *pending, int *bits));\n/*\n     deflatePending() returns the number of bytes and bits of output that have\n   been generated, but not yet provided in the available output.  The bytes not\n   provided would be due to the available output space having being consumed.\n   The number of bits of output not provided are between 0 and 7, where they\n   await more bits to join them in order to fill out a full byte.  If pending\n   or bits are Z_NULL, then those values are not set.\n\n     deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n */\n\n\tZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     deflatePrime() inserts bits in the deflate output stream.  The intent\n   is that this function is used to start off the deflate output with the bits\n   leftover from a previous deflate stream when appending to it.  As such, this\n   function can only be used for raw deflate, and must be used before the first\n   deflate() call after a deflateInit2() or deflateReset().  bits must be less\n   than or equal to 16, and that many of the least significant bits of value\n   will be inserted in the output.\n\n     deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough\n   room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     deflateSetHeader() provides gzip header information for when a gzip\n   stream is requested by deflateInit2().  deflateSetHeader() may be called\n   after deflateInit2() or deflateReset() and before the first call of\n   deflate().  The text, time, os, extra field, name, and comment information\n   in the provided gz_header structure are written to the gzip header (xflag is\n   ignored -- the extra flags are set according to the compression level).  The\n   caller must assure that, if not Z_NULL, name and comment are terminated with\n   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are\n   available there.  If hcrc is true, a gzip header crc is included.  Note that\n   the current versions of the command-line version of gzip (up through version\n   1.3.x) do not support header crc's, and will report that it is a \"multi-part\n   gzip file\" and give up.\n\n     If deflateSetHeader is not used, the default gzip header has text false,\n   the time set to zero, and os set to 255, with no extra, name, or comment\n   fields.  The gzip header is returned to the default state by deflateReset().\n\n     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,\n                                     int  windowBits));\n\n     This is another version of inflateInit with an extra parameter.  The\n   fields next_in, avail_in, zalloc, zfree and opaque must be initialized\n   before by the caller.\n\n     The windowBits parameter is the base two logarithm of the maximum window\n   size (the size of the history buffer).  It should be in the range 8..15 for\n   this version of the library.  The default value is 15 if inflateInit is used\n   instead.  windowBits must be greater than or equal to the windowBits value\n   provided to deflateInit2() while compressing, or it must be equal to 15 if\n   deflateInit2() was not used.  If a compressed stream with a larger window\n   size is given as input, inflate() will return with the error code\n   Z_DATA_ERROR instead of trying to allocate a larger window.\n\n     windowBits can also be zero to request that inflate use the window size in\n   the zlib header of the compressed stream.\n\n     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits\n   determines the window size.  inflate() will then process raw deflate data,\n   not looking for a zlib or gzip header, not generating a check value, and not\n   looking for any check values for comparison at the end of the stream.  This\n   is for use with other formats that use the deflate compressed data format\n   such as zip.  Those formats provide their own check values.  If a custom\n   format is developed using the raw deflate format for compressed data, it is\n   recommended that a check value such as an adler32 or a crc32 be applied to\n   the uncompressed data as is done in the zlib, gzip, and zip formats.  For\n   most applications, the zlib format should be used as is.  Note that comments\n   above on the use in deflateInit2() applies to the magnitude of windowBits.\n\n     windowBits can also be greater than 15 for optional gzip decoding.  Add\n   32 to windowBits to enable zlib and gzip decoding with automatic header\n   detection, or add 16 to decode only the gzip format (the zlib format will\n   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a\n   crc32 instead of an adler32.\n\n     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the\n   version assumed by the caller, or Z_STREAM_ERROR if the parameters are\n   invalid, such as a null pointer to the structure.  msg is set to null if\n   there is no error message.  inflateInit2 does not perform any decompression\n   apart from possibly reading the zlib header if present: actual decompression\n   will be done by inflate().  (So next_in and avail_in may be modified, but\n   next_out and avail_out are unused and unchanged.) The current implementation\n   of inflateInit2() does not process any header information -- that is\n   deferred until inflate() is called.\n*/\n\n\tZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef * dictionary, uInt dictLength));\n/*\n     Initializes the decompression dictionary from the given uncompressed byte\n   sequence.  This function must be called immediately after a call of inflate,\n   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor\n   can be determined from the adler32 value returned by that call of inflate.\n   The compressor and decompressor must use exactly the same dictionary (see\n   deflateSetDictionary).  For raw inflate, this function can be called at any\n   time to set the dictionary.  If the provided dictionary is smaller than the\n   window and there is already data in the window, then the provided dictionary\n   will amend what's there.  The application must insure that the dictionary\n   that was used for compression is provided.\n\n     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a\n   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is\n   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the\n   expected one (incorrect adler32 value).  inflateSetDictionary does not\n   perform any decompression: this will be done by subsequent calls of\n   inflate().\n*/\n\n\tZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, Bytef * dictionary, uInt * dictLength));\n/*\n     Returns the sliding dictionary being maintained by inflate.  dictLength is\n   set to the number of bytes in the dictionary, and that many bytes are copied\n   to dictionary.  dictionary must have enough space, where 32768 bytes is\n   always enough.  If inflateGetDictionary() is called with dictionary equal to\n   Z_NULL, then only the dictionary length is returned, and nothing is copied.\n   Similary, if dictLength is Z_NULL, then it is not set.\n\n     inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the\n   stream state is inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));\n/*\n     Skips invalid compressed data until a possible full flush point (see above\n   for the description of deflate with Z_FULL_FLUSH) can be found, or until all\n   available input is skipped.  No output is provided.\n\n     inflateSync searches for a 00 00 FF FF pattern in the compressed data.\n   All full flush points have this pattern, but not all occurrences of this\n   pattern are full flush points.\n\n     inflateSync returns Z_OK if a possible full flush point has been found,\n   Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point\n   has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.\n   In the success case, the application may save the current current value of\n   total_in which indicates where valid compressed data was found.  In the\n   error case, the application may repeatedly call inflateSync, providing more\n   input each time, until success or end of the input data.\n*/\n\n\tZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source));\n/*\n     Sets the destination stream as a complete copy of the source stream.\n\n     This function can be useful when randomly accessing a large stream.  The\n   first pass through the stream can periodically record the inflate state,\n   allowing restarting inflate at those points when randomly accessing the\n   stream.\n\n     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent\n   (such as zalloc being Z_NULL).  msg is left unchanged in both source and\n   destination.\n*/\n\n\tZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));\n/*\n     This function is equivalent to inflateEnd followed by inflateInit,\n   but does not free and reallocate all the internal decompression state.  The\n   stream will keep attributes that may have been set by inflateInit2.\n\n     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL).\n*/\n\n\tZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, int windowBits));\n/*\n     This function is the same as inflateReset, but it also permits changing\n   the wrap and window size requests.  The windowBits parameter is interpreted\n   the same as it is for inflateInit2.\n\n     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent (such as zalloc or state being Z_NULL), or if\n   the windowBits parameter is invalid.\n*/\n\n\tZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value));\n/*\n     This function inserts bits in the inflate input stream.  The intent is\n   that this function is used to start inflating at a bit position in the\n   middle of a byte.  The provided bits will be used before any bytes are used\n   from next_in.  This function should only be used with raw inflate, and\n   should be used before the first inflate() call after inflateInit2() or\n   inflateReset().  bits must be less than or equal to 16, and that many of the\n   least significant bits of value will be inserted in the input.\n\n     If bits is negative, then the input stream bit buffer is emptied.  Then\n   inflatePrime() can be called again to put bits in the buffer.  This is used\n   to clear out bits leftover after feeding inflate a block description prior\n   to feeding inflate codes.\n\n     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n\tZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));\n/*\n     This function returns two values, one in the lower 16 bits of the return\n   value, and the other in the remaining upper bits, obtained by shifting the\n   return value down 16 bits.  If the upper value is -1 and the lower value is\n   zero, then inflate() is currently decoding information outside of a block.\n   If the upper value is -1 and the lower value is non-zero, then inflate is in\n   the middle of a stored block, with the lower value equaling the number of\n   bytes from the input remaining to copy.  If the upper value is not -1, then\n   it is the number of bits back from the current bit position in the input of\n   the code (literal or length/distance pair) currently being processed.  In\n   that case the lower value is the number of bytes already emitted for that\n   code.\n\n     A code is being processed if inflate is waiting for more input to complete\n   decoding of the code, or if it has completed decoding but is waiting for\n   more output space to write the literal or match data.\n\n     inflateMark() is used to mark locations in the input data for random\n   access, which may be at bit positions, and to note those cases where the\n   output of a code may span boundaries of random access blocks.  The current\n   location in the input stream can be determined from avail_in and data_type\n   as noted in the description for the Z_BLOCK flush parameter for inflate.\n\n     inflateMark returns the value noted above or -1 << 16 if the provided\n   source stream state was inconsistent.\n*/\n\n\tZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head));\n/*\n     inflateGetHeader() requests that gzip header information be stored in the\n   provided gz_header structure.  inflateGetHeader() may be called after\n   inflateInit2() or inflateReset(), and before the first call of inflate().\n   As inflate() processes the gzip stream, head->done is zero until the header\n   is completed, at which time head->done is set to one.  If a zlib stream is\n   being decoded, then head->done is set to -1 to indicate that there will be\n   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be\n   used to force inflate() to return immediately after header processing is\n   complete and before any actual data is decompressed.\n\n     The text, time, xflags, and os fields are filled in with the gzip header\n   contents.  hcrc is set to true if there is a header CRC.  (The header CRC\n   was valid if done is set to one.) If extra is not Z_NULL, then extra_max\n   contains the maximum number of bytes to write to extra.  Once done is true,\n   extra_len contains the actual extra field length, and extra contains the\n   extra field, or that field truncated if extra_max is less than extra_len.\n   If name is not Z_NULL, then up to name_max characters are written there,\n   terminated with a zero unless the length is greater than name_max.  If\n   comment is not Z_NULL, then up to comm_max characters are written there,\n   terminated with a zero unless the length is greater than comm_max.  When any\n   of extra, name, or comment are not Z_NULL and the respective field is not\n   present in the header, then that field is set to Z_NULL to signal its\n   absence.  This allows the use of deflateSetHeader() with the returned\n   structure to duplicate the header.  However if those fields are set to\n   allocated memory, then the application will need to save those pointers\n   elsewhere so that they can be eventually freed.\n\n     If inflateGetHeader is not used, then the header information is simply\n   discarded.  The header is always checked for validity, including the header\n   CRC if present.  inflateReset() will reset the process to discard the header\n   information.  The application would need to call inflateGetHeader() again to\n   retrieve the header from the next gzip stream.\n\n     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source\n   stream state was inconsistent.\n*/\n\n/*\nZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,\n                                        unsigned char FAR *window));\n\n     Initialize the internal stream state for decompression using inflateBack()\n   calls.  The fields zalloc, zfree and opaque in strm must be initialized\n   before the call.  If zalloc and zfree are Z_NULL, then the default library-\n   derived memory allocation routines are used.  windowBits is the base two\n   logarithm of the window size, in the range 8..15.  window is a caller\n   supplied buffer of that size.  Except for special applications where it is\n   assured that deflate was used with small window sizes, windowBits must be 15\n   and a 32K byte window must be supplied to be able to decompress general\n   deflate streams.\n\n     See inflateBack() for the usage of these routines.\n\n     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of\n   the parameters are invalid, Z_MEM_ERROR if the internal state could not be\n   allocated, or Z_VERSION_ERROR if the version of the library does not match\n   the version of the header file.\n*/\n\n\ttypedef unsigned (*in_func) OF((void FAR *, z_const unsigned char FAR * FAR *));\n\ttypedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));\n\n\tZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void FAR * in_desc, out_func out, void FAR * out_desc));\n/*\n     inflateBack() does a raw inflate with a single call using a call-back\n   interface for input and output.  This is potentially more efficient than\n   inflate() for file i/o applications, in that it avoids copying between the\n   output and the sliding window by simply making the window itself the output\n   buffer.  inflate() can be faster on modern CPUs when used with large\n   buffers.  inflateBack() trusts the application to not change the output\n   buffer passed by the output function, at least until inflateBack() returns.\n\n     inflateBackInit() must be called first to allocate the internal state\n   and to initialize the state with the user-provided window buffer.\n   inflateBack() may then be used multiple times to inflate a complete, raw\n   deflate stream with each call.  inflateBackEnd() is then called to free the\n   allocated state.\n\n     A raw deflate stream is one with no zlib or gzip header or trailer.\n   This routine would normally be used in a utility that reads zip or gzip\n   files and writes out uncompressed files.  The utility would decode the\n   header and process the trailer on its own, hence this routine expects only\n   the raw deflate stream to decompress.  This is different from the normal\n   behavior of inflate(), which expects either a zlib or gzip header and\n   trailer around the deflate stream.\n\n     inflateBack() uses two subroutines supplied by the caller that are then\n   called by inflateBack() for input and output.  inflateBack() calls those\n   routines until it reads a complete deflate stream and writes out all of the\n   uncompressed data, or until it encounters an error.  The function's\n   parameters and return types are defined above in the in_func and out_func\n   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the\n   number of bytes of provided input, and a pointer to that input in buf.  If\n   there is no input available, in() must return zero--buf is ignored in that\n   case--and inflateBack() will return a buffer error.  inflateBack() will call\n   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()\n   should return zero on success, or non-zero on failure.  If out() returns\n   non-zero, inflateBack() will return with an error.  Neither in() nor out()\n   are permitted to change the contents of the window provided to\n   inflateBackInit(), which is also the buffer that out() uses to write from.\n   The length written by out() will be at most the window size.  Any non-zero\n   amount of input may be provided by in().\n\n     For convenience, inflateBack() can be provided input on the first call by\n   setting strm->next_in and strm->avail_in.  If that input is exhausted, then\n   in() will be called.  Therefore strm->next_in must be initialized before\n   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called\n   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in\n   must also be initialized, and then if strm->avail_in is not zero, input will\n   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].\n\n     The in_desc and out_desc parameters of inflateBack() is passed as the\n   first parameter of in() and out() respectively when they are called.  These\n   descriptors can be optionally used to pass any information that the caller-\n   supplied in() and out() functions need to do their job.\n\n     On return, inflateBack() will set strm->next_in and strm->avail_in to\n   pass back any unused input that was provided by the last in() call.  The\n   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR\n   if in() or out() returned an error, Z_DATA_ERROR if there was a format error\n   in the deflate stream (in which case strm->msg is set to indicate the nature\n   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.\n   In the case of Z_BUF_ERROR, an input or output error can be distinguished\n   using strm->next_in which will be Z_NULL only if in() returned an error.  If\n   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning\n   non-zero.  (in() will always be called before out(), so strm->next_in is\n   assured to be defined if out() returns non-zero.) Note that inflateBack()\n   cannot return Z_OK.\n*/\n\n\tZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));\n/*\n     All memory allocated by inflateBackInit() is freed.\n\n     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream\n   state was inconsistent.\n*/\n\n\tZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));\n/* Return flags indicating compile-time options.\n\n    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:\n     1.0: size of uInt\n     3.2: size of uLong\n     5.4: size of voidpf (pointer)\n     7.6: size of z_off_t\n\n    Compiler, assembler, and debug options:\n     8: DEBUG\n     9: ASMV or ASMINF -- use ASM code\n     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention\n     11: 0 (reserved)\n\n    One-time table building (smaller code, but not thread-safe if true):\n     12: BUILDFIXED -- build static block decoding tables when needed\n     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed\n     14,15: 0 (reserved)\n\n    Library content (indicates missing functionality):\n     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking\n                          deflate code when not needed)\n     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect\n                    and decode gzip streams (to avoid linking crc code)\n     18-19: 0 (reserved)\n\n    Operation variations (changes in library functionality):\n     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate\n     21: FASTEST -- deflate algorithm with only one, lowest compression level\n     22,23: 0 (reserved)\n\n    The sprintf variant used by gzprintf (zero is best):\n     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format\n     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!\n     26: 0 = returns value, 1 = void -- 1 means inferred string length returned\n\n    Remainder:\n     27-31: 0 (reserved)\n */\n\n#ifndef Z_SOLO\n\n\t/* utility functions */\n\n/*\n     The following utility functions are implemented on top of the basic\n   stream-oriented functions.  To simplify the interface, some default options\n   are assumed (compression level and memory usage, standard memory allocation\n   functions).  The source code of these utility functions can be modified if\n   you need special options.\n*/\n\n\tZEXTERN int ZEXPORT compress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Compresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer.\n*/\n\n\tZEXTERN int ZEXPORT compress2 OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen, int level));\n/*\n     Compresses the source buffer into the destination buffer.  The level\n   parameter has the same meaning as in deflateInit.  sourceLen is the byte\n   length of the source buffer.  Upon entry, destLen is the total size of the\n   destination buffer, which must be at least the value returned by\n   compressBound(sourceLen).  Upon exit, destLen is the actual size of the\n   compressed buffer.\n\n     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough\n   memory, Z_BUF_ERROR if there was not enough room in the output buffer,\n   Z_STREAM_ERROR if the level parameter is invalid.\n*/\n\n\tZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));\n/*\n     compressBound() returns an upper bound on the compressed size after\n   compress() or compress2() on sourceLen bytes.  It would be used before a\n   compress() or compress2() call to allocate the destination buffer.\n*/\n\n\tZEXTERN int ZEXPORT uncompress OF((Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen));\n/*\n     Decompresses the source buffer into the destination buffer.  sourceLen is\n   the byte length of the source buffer.  Upon entry, destLen is the total size\n   of the destination buffer, which must be large enough to hold the entire\n   uncompressed data.  (The size of the uncompressed data must have been saved\n   previously by the compressor and transmitted to the decompressor by some\n   mechanism outside the scope of this compression library.) Upon exit, destLen\n   is the actual size of the uncompressed buffer.\n\n     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\n   enough memory, Z_BUF_ERROR if there was not enough room in the output\n   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.  In\n   the case where there is not enough room, uncompress() will fill the output\n   buffer with the uncompressed data up to that point.\n*/\n\n\t/* gzip file access functions */\n\n/*\n     This library supports reading and writing files in gzip (.gz) format with\n   an interface similar to that of stdio, using the functions that start with\n   \"gz\".  The gzip format is different from the zlib format.  gzip is a gzip\n   wrapper, documented in RFC 1952, wrapped around a deflate stream.\n*/\n\n\ttypedef struct gzFile_s *gzFile;\t/* semi-opaque gzip file descriptor */\n\n/*\nZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));\n\n     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as\n   in fopen (\"rb\" or \"wb\") but can also include a compression level (\"wb9\") or\n   a strategy: 'f' for filtered data as in \"wb6f\", 'h' for Huffman-only\n   compression as in \"wb1h\", 'R' for run-length encoding as in \"wb1R\", or 'F'\n   for fixed code compression as in \"wb9F\".  (See the description of\n   deflateInit2 for more information about the strategy parameter.)  'T' will\n   request transparent writing or appending with no compression and not using\n   the gzip format.\n\n     \"a\" can be used instead of \"w\" to request that the gzip stream that will\n   be written be appended to the file.  \"+\" will result in an error, since\n   reading and writing to the same gzip file is not supported.  The addition of\n   \"x\" when writing will create the file exclusively, which fails if the file\n   already exists.  On systems that support it, the addition of \"e\" when\n   reading or writing will set the flag to close the file on an execve() call.\n\n     These functions, as well as gzip, will read and decode a sequence of gzip\n   streams in a file.  The append function of gzopen() can be used to create\n   such a file.  (Also see gzflush() for another way to do this.)  When\n   appending, gzopen does not test whether the file begins with a gzip stream,\n   nor does it look for the end of the gzip streams to begin appending.  gzopen\n   will simply append a gzip stream to the existing file.\n\n     gzopen can be used to read a file which is not in gzip format; in this\n   case gzread will directly read from the file without decompression.  When\n   reading, this will be detected automatically by looking for the magic two-\n   byte gzip header.\n\n     gzopen returns NULL if the file could not be opened, if there was\n   insufficient memory to allocate the gzFile state, or if an invalid mode was\n   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).\n   errno can be checked to determine if the reason gzopen failed was that the\n   file could not be opened.\n*/\n\n\tZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));\n/*\n     gzdopen associates a gzFile with the file descriptor fd.  File descriptors\n   are obtained from calls like open, dup, creat, pipe or fileno (if the file\n   has been previously opened with fopen).  The mode parameter is as in gzopen.\n\n     The next call of gzclose on the returned gzFile will also close the file\n   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor\n   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,\n   mode);.  The duplicated descriptor should be saved to avoid a leak, since\n   gzdopen does not close fd if it fails.  If you are using fileno() to get the\n   file descriptor from a FILE *, then you will have to use dup() to avoid\n   double-close()ing the file descriptor.  Both gzclose() and fclose() will\n   close the associated file descriptor, so they need to have different file\n   descriptors.\n\n     gzdopen returns NULL if there was insufficient memory to allocate the\n   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not\n   provided, or '+' was provided), or if fd is -1.  The file descriptor is not\n   used until the next gz* read, write, seek, or close operation, so gzdopen\n   will not detect if fd is invalid (unless fd is -1).\n*/\n\n\tZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));\n/*\n     Set the internal buffer size used by this library's functions.  The\n   default buffer size is 8192 bytes.  This function must be called after\n   gzopen() or gzdopen(), and before any other calls that read or write the\n   file.  The buffer memory allocation is always deferred to the first read or\n   write.  Two buffers are allocated, either both of the specified size when\n   writing, or one of the specified size and the other twice that size when\n   reading.  A larger buffer size of, for example, 64K or 128K bytes will\n   noticeably increase the speed of decompression (reading).\n\n     The new buffer size also affects the maximum length for gzprintf().\n\n     gzbuffer() returns 0 on success, or -1 on failure, such as being called\n   too late.\n*/\n\n\tZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));\n/*\n     Dynamically update the compression level or strategy.  See the description\n   of deflateInit2 for the meaning of these parameters.\n\n     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not\n   opened for writing.\n*/\n\n\tZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));\n/*\n     Reads the given number of uncompressed bytes from the compressed file.  If\n   the input file is not in gzip format, gzread copies the given number of\n   bytes into the buffer directly from the file.\n\n     After reaching the end of a gzip stream in the input, gzread will continue\n   to read, looking for another gzip stream.  Any number of gzip streams may be\n   concatenated in the input file, and will all be decompressed by gzread().\n   If something other than a gzip stream is encountered after a gzip stream,\n   that remaining trailing garbage is ignored (and no error is returned).\n\n     gzread can be used to read a gzip file that is being concurrently written.\n   Upon reaching the end of the input, gzread will return with the available\n   data.  If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then\n   gzclearerr can be used to clear the end of file indicator in order to permit\n   gzread to be tried again.  Z_OK indicates that a gzip stream was completed\n   on the last gzread.  Z_BUF_ERROR indicates that the input file ended in the\n   middle of a gzip stream.  Note that gzread does not return -1 in the event\n   of an incomplete gzip stream.  This error is deferred until gzclose(), which\n   will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip\n   stream.  Alternatively, gzerror can be used before gzclose to detect this\n   case.\n\n     gzread returns the number of uncompressed bytes actually read, less than\n   len for end of file, or -1 for error.\n*/\n\n\tZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));\n/*\n     Writes the given number of uncompressed bytes into the compressed file.\n   gzwrite returns the number of uncompressed bytes written or 0 in case of\n   error.\n*/\n\n\tZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));\n/*\n     Converts, formats, and writes the arguments to the compressed file under\n   control of the format string, as in fprintf.  gzprintf returns the number of\n   uncompressed bytes actually written, or 0 in case of error.  The number of\n   uncompressed bytes written is limited to 8191, or one less than the buffer\n   size given to gzbuffer().  The caller should assure that this limit is not\n   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with\n   nothing written.  In this case, there may also be a buffer overflow with\n   unpredictable consequences, which is possible only if zlib was compiled with\n   the insecure functions sprintf() or vsprintf() because the secure snprintf()\n   or vsnprintf() functions were not available.  This can be determined using\n   zlibCompileFlags().\n*/\n\n\tZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));\n/*\n     Writes the given null-terminated string to the compressed file, excluding\n   the terminating null character.\n\n     gzputs returns the number of characters written, or -1 in case of error.\n*/\n\n\tZEXTERN char *ZEXPORT gzgets OF((gzFile file, char *buf, int len));\n/*\n     Reads bytes from the compressed file until len-1 characters are read, or a\n   newline character is read and transferred to buf, or an end-of-file\n   condition is encountered.  If any characters are read or if len == 1, the\n   string is terminated with a null character.  If no characters are read due\n   to an end-of-file or len < 1, then the buffer is left untouched.\n\n     gzgets returns buf which is a null-terminated string, or it returns NULL\n   for end-of-file or in case of error.  If there was an error, the contents at\n   buf are indeterminate.\n*/\n\n\tZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));\n/*\n     Writes c, converted to an unsigned char, into the compressed file.  gzputc\n   returns the value that was written, or -1 in case of error.\n*/\n\n\tZEXTERN int ZEXPORT gzgetc OF((gzFile file));\n/*\n     Reads one byte from the compressed file.  gzgetc returns this byte or -1\n   in case of end of file or error.  This is implemented as a macro for speed.\n   As such, it does not do all of the checking the other functions do.  I.e.\n   it does not check to see if file is NULL, nor whether the structure file\n   points to has been clobbered or not.\n*/\n\n\tZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));\n/*\n     Push one character back onto the stream to be read as the first character\n   on the next read.  At least one character of push-back is allowed.\n   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will\n   fail if c is -1, and may fail if a character has been pushed but not read\n   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the\n   output buffer size of pushed characters is allowed.  (See gzbuffer above.)\n   The pushed character will be discarded if the stream is repositioned with\n   gzseek() or gzrewind().\n*/\n\n\tZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));\n/*\n     Flushes all pending output into the compressed file.  The parameter flush\n   is as in the deflate() function.  The return value is the zlib error number\n   (see function gzerror below).  gzflush is only permitted when writing.\n\n     If the flush parameter is Z_FINISH, the remaining data is written and the\n   gzip stream is completed in the output.  If gzwrite() is called again, a new\n   gzip stream will be started in the output.  gzread() is able to read such\n   concatented gzip streams.\n\n     gzflush should be called only when strictly necessary because it will\n   degrade compression if called too often.\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,\n                                   z_off_t offset, int whence));\n\n     Sets the starting position for the next gzread or gzwrite on the given\n   compressed file.  The offset represents a number of bytes in the\n   uncompressed data stream.  The whence parameter is defined as in lseek(2);\n   the value SEEK_END is not supported.\n\n     If the file is opened for reading, this function is emulated but can be\n   extremely slow.  If the file is opened for writing, only forward seeks are\n   supported; gzseek then compresses a sequence of zeroes up to the new\n   starting position.\n\n     gzseek returns the resulting offset location as measured in bytes from\n   the beginning of the uncompressed stream, or -1 in case of error, in\n   particular if the file is opened for writing and the new starting position\n   would be before the current position.\n*/\n\n\tZEXTERN int ZEXPORT gzrewind OF((gzFile file));\n/*\n     Rewinds the given file. This function is supported only for reading.\n\n     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));\n\n     Returns the starting position for the next gzread or gzwrite on the given\n   compressed file.  This position represents a number of bytes in the\n   uncompressed data stream, and is zero when starting, even if appending or\n   reading a gzip stream from the middle of a file using gzdopen().\n\n     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)\n*/\n\n/*\nZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));\n\n     Returns the current offset in the file being read or written.  This offset\n   includes the count of bytes that precede the gzip stream, for example when\n   appending or when using gzdopen() for reading.  When reading, the offset\n   does not include as yet unused buffered input.  This information can be used\n   for a progress indicator.  On error, gzoffset() returns -1.\n*/\n\n\tZEXTERN int ZEXPORT gzeof OF((gzFile file));\n/*\n     Returns true (1) if the end-of-file indicator has been set while reading,\n   false (0) otherwise.  Note that the end-of-file indicator is set only if the\n   read tried to go past the end of the input, but came up short.  Therefore,\n   just like feof(), gzeof() may return false even if there is no more data to\n   read, in the event that the last read request was for the exact number of\n   bytes remaining in the input file.  This will happen if the input file size\n   is an exact multiple of the buffer size.\n\n     If gzeof() returns true, then the read functions will return no more data,\n   unless the end-of-file indicator is reset by gzclearerr() and the input file\n   has grown since the previous end of file was detected.\n*/\n\n\tZEXTERN int ZEXPORT gzdirect OF((gzFile file));\n/*\n     Returns true (1) if file is being copied directly while reading, or false\n   (0) if file is a gzip stream being decompressed.\n\n     If the input file is empty, gzdirect() will return true, since the input\n   does not contain a gzip stream.\n\n     If gzdirect() is used immediately after gzopen() or gzdopen() it will\n   cause buffers to be allocated to allow reading the file to determine if it\n   is a gzip file.  Therefore if gzbuffer() is used, it should be called before\n   gzdirect().\n\n     When writing, gzdirect() returns true (1) if transparent writing was\n   requested (\"wT\" for the gzopen() mode), or false (0) otherwise.  (Note:\n   gzdirect() is not needed when writing.  Transparent writing must be\n   explicitly requested, so the application already knows the answer.  When\n   linking statically, using gzdirect() will include all of the zlib code for\n   gzip file reading and decompression, which may not be desired.)\n*/\n\n\tZEXTERN int ZEXPORT gzclose OF((gzFile file));\n/*\n     Flushes all pending output if necessary, closes the compressed file and\n   deallocates the (de)compression state.  Note that once file is closed, you\n   cannot call gzerror with file, since its structures have been deallocated.\n   gzclose must not be called more than once on the same file, just as free\n   must not be called more than once on the same allocation.\n\n     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a\n   file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the\n   last read ended in the middle of a gzip stream, or Z_OK on success.\n*/\n\n\tZEXTERN int ZEXPORT gzclose_r OF((gzFile file));\n\tZEXTERN int ZEXPORT gzclose_w OF((gzFile file));\n/*\n     Same as gzclose(), but gzclose_r() is only for use when reading, and\n   gzclose_w() is only for use when writing or appending.  The advantage to\n   using these instead of gzclose() is that they avoid linking in zlib\n   compression or decompression code that is not used when only reading or only\n   writing respectively.  If gzclose() is used, then both compression and\n   decompression code will be included the application when linking to a static\n   zlib library.\n*/\n\n\tZEXTERN const char *ZEXPORT gzerror OF((gzFile file, int *errnum));\n/*\n     Returns the error message for the last error which occurred on the given\n   compressed file.  errnum is set to zlib error number.  If an error occurred\n   in the file system and not in the compression library, errnum is set to\n   Z_ERRNO and the application may consult errno to get the exact error code.\n\n     The application must not modify the returned string.  Future calls to\n   this function may invalidate the previously returned string.  If file is\n   closed, then the string previously returned by gzerror will no longer be\n   available.\n\n     gzerror() should be used to distinguish errors from end-of-file for those\n   functions above that do not distinguish those cases in their return values.\n*/\n\n\tZEXTERN void ZEXPORT gzclearerr OF((gzFile file));\n/*\n     Clears the error and end-of-file flags for file.  This is analogous to the\n   clearerr() function in stdio.  This is useful for continuing to read a gzip\n   file that is being written concurrently.\n*/\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n\t/* checksum functions */\n\n/*\n     These functions are not related to compression but are exported\n   anyway because they might be useful in applications using the compression\n   library.\n*/\n\n\tZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef * buf, uInt len));\n/*\n     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\n   return the updated checksum.  If buf is Z_NULL, this function returns the\n   required initial value for the checksum.\n\n     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\n   much faster.\n\n   Usage example:\n\n     uLong adler = adler32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       adler = adler32(adler, buffer, length);\n     }\n     if (adler != original_adler) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,\n                                          z_off_t len2));\n\n     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1\n   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for\n   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of\n   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.  Note\n   that the z_off_t type (like off_t) is a signed integer.  If len2 is\n   negative, the result has no meaning or utility.\n*/\n\n\tZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef * buf, uInt len));\n/*\n     Update a running CRC-32 with the bytes buf[0..len-1] and return the\n   updated CRC-32.  If buf is Z_NULL, this function returns the required\n   initial value for the crc.  Pre- and post-conditioning (one's complement) is\n   performed within this function so it shouldn't be done by the application.\n\n   Usage example:\n\n     uLong crc = crc32(0L, Z_NULL, 0);\n\n     while (read_buffer(buffer, length) != EOF) {\n       crc = crc32(crc, buffer, length);\n     }\n     if (crc != original_crc) error();\n*/\n\n/*\nZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));\n\n     Combine two CRC-32 check values into one.  For two sequences of bytes,\n   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were\n   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32\n   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and\n   len2.\n*/\n\n\t/* various hacks, don't look :) */\n\n/* deflateInit and inflateInit are macros to allow checking the zlib version\n * and the compiler's view of z_stream:\n */\n\tZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size));\n\tZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char FAR * window, const char *version, int stream_size));\n#define deflateInit(strm, level) \\\n        deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit(strm) \\\n        inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))\n#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \\\n        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\\\n                      (strategy), ZLIB_VERSION, (int)sizeof(z_stream))\n#define inflateInit2(strm, windowBits) \\\n        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \\\n                      (int)sizeof(z_stream))\n#define inflateBackInit(strm, windowBits, window) \\\n        inflateBackInit_((strm), (windowBits), (window), \\\n                      ZLIB_VERSION, (int)sizeof(z_stream))\n\n#ifndef Z_SOLO\n\n/* gzgetc() macro and its supporting function and exposed data structure.  Note\n * that the real internal state is much larger than the exposed structure.\n * This abbreviated structure exposes just enough for the gzgetc() macro.  The\n * user should not mess with these exposed elements, since their names or\n * behavior could change in the future, perhaps even capriciously.  They can\n * only be used by the gzgetc() macro.  You have been warned.\n */\n\tstruct gzFile_s {\n\t\tunsigned have;\n\t\tunsigned char *next;\n\t\tz_off64_t pos;\n\t};\n\tZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));\t/* backward compatibility */\n#ifdef Z_PREFIX_SET\n#undef z_gzgetc\n#define z_gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))\n#else\n#define gzgetc(g) \\\n          ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))\n#endif\n\n/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or\n * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if\n * both are true, the application gets the *64 functions, and the regular\n * functions are changed to 64 bits) -- in case these are set on systems\n * without large file support, _LFS64_LARGEFILE must also be true\n */\n#ifdef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));\n\tZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));\n#endif\n\n#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)\n#ifdef Z_PREFIX_SET\n#define z_gzopen z_gzopen64\n#define z_gzseek z_gzseek64\n#define z_gztell z_gztell64\n#define z_gzoffset z_gzoffset64\n#define z_adler32_combine z_adler32_combine64\n#define z_crc32_combine z_crc32_combine64\n#else\n#define gzopen gzopen64\n#define gzseek gzseek64\n#define gztell gztell64\n#define gzoffset gzoffset64\n#define adler32_combine adler32_combine64\n#define crc32_combine crc32_combine64\n#endif\n#ifndef Z_LARGE64\n\tZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));\n#endif\n#else\n\tZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));\n\tZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));\n\tZEXTERN z_off_t ZEXPORT gztell OF((gzFile));\n\tZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n#endif\n\n#else\t\t\t\t/* Z_SOLO */\n\n\tZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));\n\tZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));\n\n#endif\t\t\t\t/* !Z_SOLO */\n\n/* hack for buggy compilers */\n#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)\n\tstruct internal_state {\n\t\tint dummy;\n\t};\n#endif\n\n/* undocumented functions */\n\tZEXTERN const char *ZEXPORT zError OF((int));\n\tZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));\n\tZEXTERN const z_crc_t FAR *ZEXPORT get_crc_table OF((void));\n\tZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));\n\tZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));\n\tZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));\n#if defined(_WIN32) && !defined(Z_SOLO)\n\tZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t * path, const char *mode));\n#endif\n#if defined(STDC) || defined(Z_HAVE_STDARG_H)\n#ifndef Z_SOLO\n\tZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, const char *format, va_list va));\n#endif\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n#endif\t\t\t\t/* ZLIB_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include/float.h",
    "content": "/* Copyright (C) 2002-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  5.2.4.2.2  Characteristics of floating types <float.h>\n */\n\n#ifndef _FLOAT_H___\n#define _FLOAT_H___\n\n/* Radix of exponent representation, b. */\n#undef FLT_RADIX\n#define FLT_RADIX\t__FLT_RADIX__\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef FLT_MANT_DIG\n#undef DBL_MANT_DIG\n#undef LDBL_MANT_DIG\n#define FLT_MANT_DIG\t__FLT_MANT_DIG__\n#define DBL_MANT_DIG\t__DBL_MANT_DIG__\n#define LDBL_MANT_DIG\t__LDBL_MANT_DIG__\n\n/* Number of decimal digits, q, such that any floating-point number with q\n   decimal digits can be rounded into a floating-point number with p radix b\n   digits and back again without change to the q decimal digits,\n\n\tp * log10(b)\t\t\tif b is a power of 10\n\tfloor((p - 1) * log10(b))\totherwise\n*/\n#undef FLT_DIG\n#undef DBL_DIG\n#undef LDBL_DIG\n#define FLT_DIG\t\t__FLT_DIG__\n#define DBL_DIG\t\t__DBL_DIG__\n#define LDBL_DIG\t__LDBL_DIG__\n\n/* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */\n#undef FLT_MIN_EXP\n#undef DBL_MIN_EXP\n#undef LDBL_MIN_EXP\n#define FLT_MIN_EXP\t__FLT_MIN_EXP__\n#define DBL_MIN_EXP\t__DBL_MIN_EXP__\n#define LDBL_MIN_EXP\t__LDBL_MIN_EXP__\n\n/* Minimum negative integer such that 10 raised to that power is in the\n   range of normalized floating-point numbers,\n\n\tceil(log10(b) * (emin - 1))\n*/\n#undef FLT_MIN_10_EXP\n#undef DBL_MIN_10_EXP\n#undef LDBL_MIN_10_EXP\n#define FLT_MIN_10_EXP\t__FLT_MIN_10_EXP__\n#define DBL_MIN_10_EXP\t__DBL_MIN_10_EXP__\n#define LDBL_MIN_10_EXP\t__LDBL_MIN_10_EXP__\n\n/* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax.  */\n#undef FLT_MAX_EXP\n#undef DBL_MAX_EXP\n#undef LDBL_MAX_EXP\n#define FLT_MAX_EXP\t__FLT_MAX_EXP__\n#define DBL_MAX_EXP\t__DBL_MAX_EXP__\n#define LDBL_MAX_EXP\t__LDBL_MAX_EXP__\n\n/* Maximum integer such that 10 raised to that power is in the range of\n   representable finite floating-point numbers,\n\n\tfloor(log10((1 - b**-p) * b**emax))\n*/\n#undef FLT_MAX_10_EXP\n#undef DBL_MAX_10_EXP\n#undef LDBL_MAX_10_EXP\n#define FLT_MAX_10_EXP\t__FLT_MAX_10_EXP__\n#define DBL_MAX_10_EXP\t__DBL_MAX_10_EXP__\n#define LDBL_MAX_10_EXP\t__LDBL_MAX_10_EXP__\n\n/* Maximum representable finite floating-point number,\n\n\t(1 - b**-p) * b**emax\n*/\n#undef FLT_MAX\n#undef DBL_MAX\n#undef LDBL_MAX\n#define FLT_MAX\t\t__FLT_MAX__\n#define DBL_MAX\t\t__DBL_MAX__\n#define LDBL_MAX\t__LDBL_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type, b**1-p.  */\n#undef FLT_EPSILON\n#undef DBL_EPSILON\n#undef LDBL_EPSILON\n#define FLT_EPSILON\t__FLT_EPSILON__\n#define DBL_EPSILON\t__DBL_EPSILON__\n#define LDBL_EPSILON\t__LDBL_EPSILON__\n\n/* Minimum normalized positive floating-point number, b**(emin - 1).  */\n#undef FLT_MIN\n#undef DBL_MIN\n#undef LDBL_MIN\n#define FLT_MIN\t\t__FLT_MIN__\n#define DBL_MIN\t\t__DBL_MIN__\n#define LDBL_MIN\t__LDBL_MIN__\n\n/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown.  */\n/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */\n#undef FLT_ROUNDS\n#define FLT_ROUNDS 1\n\n#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \\\n     || (defined (__cplusplus) && __cplusplus >= 201103L)\n/* The floating-point expression evaluation method.\n        -1  indeterminate\n         0  evaluate all operations and constants just to the range and\n            precision of the type\n         1  evaluate operations and constants of type float and double\n            to the range and precision of the double type, evaluate\n            long double operations and constants to the range and\n            precision of the long double type\n         2  evaluate all operations and constants to the range and\n            precision of the long double type\n\n   ??? This ought to change with the setting of the fp control word;\n   the value provided by the compiler assumes the widest setting.  */\n#undef FLT_EVAL_METHOD\n#define FLT_EVAL_METHOD\t__FLT_EVAL_METHOD__\n\n/* Number of decimal digits, n, such that any floating-point number in the\n   widest supported floating type with pmax radix b digits can be rounded\n   to a floating-point number with n decimal digits and back again without\n   change to the value,\n\n\tpmax * log10(b)\t\t\tif b is a power of 10\n\tceil(1 + pmax * log10(b))\totherwise\n*/\n#undef DECIMAL_DIG\n#define DECIMAL_DIG\t__DECIMAL_DIG__\n\n#endif\t\t\t\t/* C99 */\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L\n/* Versions of DECIMAL_DIG for each floating-point type.  */\n#undef FLT_DECIMAL_DIG\n#undef DBL_DECIMAL_DIG\n#undef LDBL_DECIMAL_DIG\n#define FLT_DECIMAL_DIG\t\t__FLT_DECIMAL_DIG__\n#define DBL_DECIMAL_DIG\t\t__DBL_DECIMAL_DIG__\n#define LDBL_DECIMAL_DIG\t__DECIMAL_DIG__\n\n/* Whether types support subnormal numbers.  */\n#undef FLT_HAS_SUBNORM\n#undef DBL_HAS_SUBNORM\n#undef LDBL_HAS_SUBNORM\n#define FLT_HAS_SUBNORM\t\t__FLT_HAS_DENORM__\n#define DBL_HAS_SUBNORM\t\t__DBL_HAS_DENORM__\n#define LDBL_HAS_SUBNORM\t__LDBL_HAS_DENORM__\n\n/* Minimum positive values, including subnormals.  */\n#undef FLT_TRUE_MIN\n#undef DBL_TRUE_MIN\n#undef LDBL_TRUE_MIN\n#define FLT_TRUE_MIN\t__FLT_DENORM_MIN__\n#define DBL_TRUE_MIN\t__DBL_DENORM_MIN__\n#define LDBL_TRUE_MIN\t__LDBL_DENORM_MIN__\n\n#endif\t\t\t\t/* C11 */\n\n#ifdef __STDC_WANT_DEC_FP__\n/* Draft Technical Report 24732, extension for decimal floating-point\n   arithmetic: Characteristic of decimal floating types <float.h>.  */\n\n/* Number of base-FLT_RADIX digits in the significand, p.  */\n#undef DEC32_MANT_DIG\n#undef DEC64_MANT_DIG\n#undef DEC128_MANT_DIG\n#define DEC32_MANT_DIG\t__DEC32_MANT_DIG__\n#define DEC64_MANT_DIG\t__DEC64_MANT_DIG__\n#define DEC128_MANT_DIG\t__DEC128_MANT_DIG__\n\n/* Minimum exponent. */\n#undef DEC32_MIN_EXP\n#undef DEC64_MIN_EXP\n#undef DEC128_MIN_EXP\n#define DEC32_MIN_EXP\t__DEC32_MIN_EXP__\n#define DEC64_MIN_EXP\t__DEC64_MIN_EXP__\n#define DEC128_MIN_EXP\t__DEC128_MIN_EXP__\n\n/* Maximum exponent. */\n#undef DEC32_MAX_EXP\n#undef DEC64_MAX_EXP\n#undef DEC128_MAX_EXP\n#define DEC32_MAX_EXP\t__DEC32_MAX_EXP__\n#define DEC64_MAX_EXP\t__DEC64_MAX_EXP__\n#define DEC128_MAX_EXP\t__DEC128_MAX_EXP__\n\n/* Maximum representable finite decimal floating-point number\n   (there are 6, 15, and 33 9s after the decimal points respectively). */\n#undef DEC32_MAX\n#undef DEC64_MAX\n#undef DEC128_MAX\n#define DEC32_MAX   __DEC32_MAX__\n#define DEC64_MAX   __DEC64_MAX__\n#define DEC128_MAX  __DEC128_MAX__\n\n/* The difference between 1 and the least value greater than 1 that is\n   representable in the given floating point type. */\n#undef DEC32_EPSILON\n#undef DEC64_EPSILON\n#undef DEC128_EPSILON\n#define DEC32_EPSILON\t__DEC32_EPSILON__\n#define DEC64_EPSILON\t__DEC64_EPSILON__\n#define DEC128_EPSILON\t__DEC128_EPSILON__\n\n/* Minimum normalized positive floating-point number. */\n#undef DEC32_MIN\n#undef DEC64_MIN\n#undef DEC128_MIN\n#define DEC32_MIN\t__DEC32_MIN__\n#define DEC64_MIN\t__DEC64_MIN__\n#define DEC128_MIN\t__DEC128_MIN__\n\n/* Minimum subnormal positive floating-point number. */\n#undef DEC32_SUBNORMAL_MIN\n#undef DEC64_SUBNORMAL_MIN\n#undef DEC128_SUBNORMAL_MIN\n#define DEC32_SUBNORMAL_MIN       __DEC32_SUBNORMAL_MIN__\n#define DEC64_SUBNORMAL_MIN       __DEC64_SUBNORMAL_MIN__\n#define DEC128_SUBNORMAL_MIN      __DEC128_SUBNORMAL_MIN__\n\n/* The floating-point expression evaluation method.\n         -1  indeterminate\n         0  evaluate all operations and constants just to the range and\n            precision of the type\n         1  evaluate operations and constants of type _Decimal32 \n\t    and _Decimal64 to the range and precision of the _Decimal64 \n            type, evaluate _Decimal128 operations and constants to the \n\t    range and precision of the _Decimal128 type;\n\t 2  evaluate all operations and constants to the range and\n\t    precision of the _Decimal128 type.  */\n\n#undef DEC_EVAL_METHOD\n#define DEC_EVAL_METHOD\t__DEC_EVAL_METHOD__\n\n#endif\t\t\t\t/* __STDC_WANT_DEC_FP__ */\n\n#endif\t\t\t\t/* _FLOAT_H___ */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include/stdarg.h",
    "content": "/* Copyright (C) 1989-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.15  Variable arguments  <stdarg.h>\n */\n\n#ifndef _STDARG_H\n#ifndef _ANSI_STDARG_H_\n#ifndef __need___va_list\n#define _STDARG_H\n#define _ANSI_STDARG_H_\n#endif\t\t\t\t/* not __need___va_list */\n#undef __need___va_list\n\n/* Define __gnuc_va_list.  */\n\n#ifndef __GNUC_VA_LIST\n#define __GNUC_VA_LIST\ntypedef __builtin_va_list __gnuc_va_list;\n#endif\n\n/* Define the standard macros for the user,\n   if this invocation was from the user program.  */\n#ifdef _STDARG_H\n\n#define va_start(v,l)\t__builtin_va_start(v,l)\n#define va_end(v)\t__builtin_va_end(v)\n#define va_arg(v,l)\t__builtin_va_arg(v,l)\n#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L \\\n    || __cplusplus + 0 >= 201103L\n#define va_copy(d,s)\t__builtin_va_copy(d,s)\n#endif\n#define __va_copy(d,s)\t__builtin_va_copy(d,s)\n\n/* Define va_list, if desired, from __gnuc_va_list. */\n/* We deliberately do not define va_list when called from\n   stdio.h, because ANSI C says that stdio.h is not supposed to define\n   va_list.  stdio.h needs to have access to that data type, \n   but must not use that name.  It should use the name __gnuc_va_list,\n   which is safe because it is reserved for the implementation.  */\n\n#ifdef _BSD_VA_LIST\n#undef _BSD_VA_LIST\n#endif\n\n#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))\n/* SVR4.2 uses _VA_LIST for an internal alias for va_list,\n   so we must avoid testing it and setting it here.\n   SVR4 uses _VA_LIST as a flag in stdarg.h, but we should\n   have no conflict with that.  */\n#ifndef _VA_LIST_\n#define _VA_LIST_\n#ifdef __i860__\n#ifndef _VA_LIST\n#define _VA_LIST va_list\n#endif\n#endif\t\t\t\t/* __i860__ */\ntypedef __gnuc_va_list va_list;\n#ifdef _SCO_DS\n#define __VA_LIST\n#endif\n#endif\t\t\t\t/* _VA_LIST_ */\n#else\t\t\t\t/* not __svr4__ || _SCO_DS */\n\n/* The macro _VA_LIST_ is the same thing used by this file in Ultrix.\n   But on BSD NET2 we must not test or define or undef it.\n   (Note that the comments in NET 2's ansi.h\n   are incorrect for _VA_LIST_--see stdio.h!)  */\n#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)\n/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5  */\n#ifndef _VA_LIST_DEFINED\n/* The macro _VA_LIST is used in SCO Unix 3.2.  */\n#ifndef _VA_LIST\n/* The macro _VA_LIST_T_H is used in the Bull dpx2  */\n#ifndef _VA_LIST_T_H\n/* The macro __va_list__ is used by BeOS.  */\n#ifndef __va_list__\ntypedef __gnuc_va_list va_list;\n#endif\t\t\t\t/* not __va_list__ */\n#endif\t\t\t\t/* not _VA_LIST_T_H */\n#endif\t\t\t\t/* not _VA_LIST */\n#endif\t\t\t\t/* not _VA_LIST_DEFINED */\n#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))\n#define _VA_LIST_\n#endif\n#ifndef _VA_LIST\n#define _VA_LIST\n#endif\n#ifndef _VA_LIST_DEFINED\n#define _VA_LIST_DEFINED\n#endif\n#ifndef _VA_LIST_T_H\n#define _VA_LIST_T_H\n#endif\n#ifndef __va_list__\n#define __va_list__\n#endif\n\n#endif\t\t\t\t/* not _VA_LIST_, except on certain systems */\n\n#endif\t\t\t\t/* not __svr4__ */\n\n#endif\t\t\t\t/* _STDARG_H */\n\n#endif\t\t\t\t/* not _ANSI_STDARG_H_ */\n#endif\t\t\t\t/* not _STDARG_H */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include/stdbool.h",
    "content": "/* Copyright (C) 1998-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.16  Boolean type and values  <stdbool.h>\n */\n\n#ifndef _STDBOOL_H\n#define _STDBOOL_H\n\n#ifndef __cplusplus\n\n#define bool\t_Bool\n#define true\t1\n#define false\t0\n\n#else\t\t\t\t/* __cplusplus */\n\n/* Supporting _Bool in C++ is a GCC extension.  */\n#define _Bool\tbool\n\n#if __cplusplus < 201103L\n/* Defining these macros in C++98 is a GCC extension.  */\n#define bool\tbool\n#define false\tfalse\n#define true\ttrue\n#endif\n\n#endif\t\t\t\t/* __cplusplus */\n\n/* Signal that all the definitions are present.  */\n#define __bool_true_false_are_defined\t1\n\n#endif\t\t\t\t/* stdbool.h */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include/stddef.h",
    "content": "/* Copyright (C) 1989-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 3, or (at your option)\nany later version.\n\nGCC is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/*\n * ISO C Standard:  7.17  Common definitions  <stddef.h>\n */\n#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \\\n     && !defined(__STDDEF_H__)) \\\n    || defined(__need_wchar_t) || defined(__need_size_t) \\\n    || defined(__need_ptrdiff_t) || defined(__need_NULL) \\\n    || defined(__need_wint_t)\n\n/* Any one of these symbols __need_* means that GNU libc\n   wants us just to define one data type.  So don't define\n   the symbols that indicate this file's entire job has been done.  */\n#if (!defined(__need_wchar_t) && !defined(__need_size_t)\t\\\n     && !defined(__need_ptrdiff_t) && !defined(__need_NULL)\t\\\n     && !defined(__need_wint_t))\n#define _STDDEF_H\n#define _STDDEF_H_\n/* snaroff@next.com says the NeXT needs this.  */\n#define _ANSI_STDDEF_H\n#endif\n\n#ifndef __sys_stdtypes_h\n/* This avoids lossage on SunOS but only if stdtypes.h comes first.\n   There's no way to win with the other order!  Sun lossage.  */\n\n/* On 4.3bsd-net2, make sure ansi.h is included, so we have\n   one less case to deal with in the following.  */\n#if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__)\n#include <machine/ansi.h>\n#endif\n/* On FreeBSD 5, machine/ansi.h does not exist anymore... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#include <sys/_types.h>\n#endif\n\n/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are\n   defined if the corresponding type is *not* defined.\n   FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_.\n   NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_)  || defined(_I386_ANSI_H_)\n#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)\n#define _SIZE_T\n#endif\n#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)\n#define _PTRDIFF_T\n#endif\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_. */\n#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)\n#ifndef _BSD_WCHAR_T_\n#define _WCHAR_T\n#endif\n#endif\n/* Undef _FOO_T_ if we are supposed to define foo_t.  */\n#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#if defined (__need_size_t) || defined (_STDDEF_H_)\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#if defined (__need_wchar_t) || defined (_STDDEF_H_)\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_) */\n\n/* Sequent's header files use _PTRDIFF_T_ in some conflicting way.\n   Just ignore it.  */\n#if defined (__sequent__) && defined (_PTRDIFF_T_)\n#undef _PTRDIFF_T_\n#endif\n\n/* On VxWorks, <type/vxTypesBase.h> may have defined macros like\n   _TYPE_size_t which will typedef size_t.  fixincludes patched the\n   vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is\n   not defined, and so that defining this macro defines _GCC_SIZE_T.\n   If we find that the macros are still defined at this point, we must\n   invoke them so that the type is defined as expected.  */\n#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))\n_TYPE_ptrdiff_t;\n#undef _TYPE_ptrdiff_t\n#endif\n#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))\n_TYPE_size_t;\n#undef _TYPE_size_t\n#endif\n#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))\n_TYPE_wchar_t;\n#undef _TYPE_wchar_t\n#endif\n\n/* In case nobody has defined these types, but we aren't running under\n   GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and\n   __WCHAR_TYPE__ have reasonable values.  This can happen if the\n   parts of GCC is compiled by an older compiler, that actually\n   include gstddef.h, such as collect2.  */\n\n/* Signed type of difference of two pointers.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_ptrdiff_t)\n#ifndef _PTRDIFF_T\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _T_PTRDIFF_\n#ifndef _T_PTRDIFF\n#ifndef __PTRDIFF_T\n#ifndef _PTRDIFF_T_\n#ifndef _BSD_PTRDIFF_T_\n#ifndef ___int_ptrdiff_t_h\n#ifndef _GCC_PTRDIFF_T\n#ifndef _PTRDIFF_T_DECLARED\t/* DragonFly */\n#define _PTRDIFF_T\n#define _T_PTRDIFF_\n#define _T_PTRDIFF\n#define __PTRDIFF_T\n#define _PTRDIFF_T_\n#define _BSD_PTRDIFF_T_\n#define ___int_ptrdiff_t_h\n#define _GCC_PTRDIFF_T\n#define _PTRDIFF_T_DECLARED\n#ifndef __PTRDIFF_TYPE__\n#define __PTRDIFF_TYPE__ long int\n#endif\ntypedef __PTRDIFF_TYPE__ ptrdiff_t;\n#endif\t\t\t\t/* _PTRDIFF_T_DECLARED */\n#endif\t\t\t\t/* _GCC_PTRDIFF_T */\n#endif\t\t\t\t/* ___int_ptrdiff_t_h */\n#endif\t\t\t\t/* _BSD_PTRDIFF_T_ */\n#endif\t\t\t\t/* _PTRDIFF_T_ */\n#endif\t\t\t\t/* __PTRDIFF_T */\n#endif\t\t\t\t/* _T_PTRDIFF */\n#endif\t\t\t\t/* _T_PTRDIFF_ */\n#endif\t\t\t\t/* _PTRDIFF_T */\n\n/* If this symbol has done its job, get rid of it.  */\n#undef\t__need_ptrdiff_t\n\n#endif\t\t\t\t/* _STDDEF_H or __need_ptrdiff_t.  */\n\n/* Unsigned type of `sizeof' something.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_size_t)\n#ifndef __size_t__\t\t/* BeOS */\n#ifndef __SIZE_T__\t\t/* Cray Unicos/Mk */\n#ifndef _SIZE_T\t\t\t/* in case <sys/types.h> has defined it. */\n#ifndef _SYS_SIZE_T_H\n#ifndef _T_SIZE_\n#ifndef _T_SIZE\n#ifndef __SIZE_T\n#ifndef _SIZE_T_\n#ifndef _BSD_SIZE_T_\n#ifndef _SIZE_T_DEFINED_\n#ifndef _SIZE_T_DEFINED\n#ifndef _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#ifndef _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#ifndef ___int_size_t_h\n#ifndef _GCC_SIZE_T\n#ifndef _SIZET_\n#ifndef __size_t\n#define __size_t__\t\t/* BeOS */\n#define __SIZE_T__\t\t/* Cray Unicos/Mk */\n#define _SIZE_T\n#define _SYS_SIZE_T_H\n#define _T_SIZE_\n#define _T_SIZE\n#define __SIZE_T\n#define _SIZE_T_\n#define _BSD_SIZE_T_\n#define _SIZE_T_DEFINED_\n#define _SIZE_T_DEFINED\n#define _BSD_SIZE_T_DEFINED_\t/* Darwin */\n#define _SIZE_T_DECLARED\t/* FreeBSD 5 */\n#define ___int_size_t_h\n#define _GCC_SIZE_T\n#define _SIZET_\n#if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \\\n  || defined(__DragonFly__) \\\n  || defined(__FreeBSD_kernel__)\n/* __size_t is a typedef on FreeBSD 5, must not trash it. */\n#elif defined (__VMS__)\n/* __size_t is also a typedef on VMS.  */\n#else\n#define __size_t\n#endif\n#ifndef __SIZE_TYPE__\n#define __SIZE_TYPE__ long unsigned int\n#endif\n#if !(defined (__GNUG__) && defined (size_t))\ntypedef __SIZE_TYPE__ size_t;\n#ifdef __BEOS__\ntypedef long ssize_t;\n#endif\t\t\t\t/* __BEOS__ */\n#endif\t\t\t\t/* !(defined (__GNUG__) && defined (size_t)) */\n#endif\t\t\t\t/* __size_t */\n#endif\t\t\t\t/* _SIZET_ */\n#endif\t\t\t\t/* _GCC_SIZE_T */\n#endif\t\t\t\t/* ___int_size_t_h */\n#endif\t\t\t\t/* _SIZE_T_DECLARED */\n#endif\t\t\t\t/* _BSD_SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _SIZE_T_DEFINED */\n#endif\t\t\t\t/* _SIZE_T_DEFINED_ */\n#endif\t\t\t\t/* _BSD_SIZE_T_ */\n#endif\t\t\t\t/* _SIZE_T_ */\n#endif\t\t\t\t/* __SIZE_T */\n#endif\t\t\t\t/* _T_SIZE */\n#endif\t\t\t\t/* _T_SIZE_ */\n#endif\t\t\t\t/* _SYS_SIZE_T_H */\n#endif\t\t\t\t/* _SIZE_T */\n#endif\t\t\t\t/* __SIZE_T__ */\n#endif\t\t\t\t/* __size_t__ */\n#undef\t__need_size_t\n#endif\t\t\t\t/* _STDDEF_H or __need_size_t.  */\n\n/* Wide character type.\n   Locale-writers should change this as necessary to\n   be big enough to hold unique values not between 0 and 127,\n   and not (wchar_t) -1, for each defined multibyte character.  */\n\n/* Define this type if we are doing the whole job,\n   or if we want this type in particular.  */\n#if defined (_STDDEF_H) || defined (__need_wchar_t)\n#ifndef __wchar_t__\t\t/* BeOS */\n#ifndef __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#ifndef _WCHAR_T\n#ifndef _T_WCHAR_\n#ifndef _T_WCHAR\n#ifndef __WCHAR_T\n#ifndef _WCHAR_T_\n#ifndef _BSD_WCHAR_T_\n#ifndef _BSD_WCHAR_T_DEFINED_\t/* Darwin */\n#ifndef _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#ifndef _WCHAR_T_DECLARED\t/* FreeBSD 5 */\n#ifndef _WCHAR_T_DEFINED_\n#ifndef _WCHAR_T_DEFINED\n#ifndef _WCHAR_T_H\n#ifndef ___int_wchar_t_h\n#ifndef __INT_WCHAR_T_H\n#ifndef _GCC_WCHAR_T\n#define __wchar_t__\t\t/* BeOS */\n#define __WCHAR_T__\t\t/* Cray Unicos/Mk */\n#define _WCHAR_T\n#define _T_WCHAR_\n#define _T_WCHAR\n#define __WCHAR_T\n#define _WCHAR_T_\n#define _BSD_WCHAR_T_\n#define _WCHAR_T_DEFINED_\n#define _WCHAR_T_DEFINED\n#define _WCHAR_T_H\n#define ___int_wchar_t_h\n#define __INT_WCHAR_T_H\n#define _GCC_WCHAR_T\n#define _WCHAR_T_DECLARED\n\n/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_\n   instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other\n   symbols in the _FOO_T_ family, stays defined even after its\n   corresponding type is defined).  If we define wchar_t, then we\n   must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if\n   we undef _WCHAR_T_, then we must also define rune_t, since \n   headers like runetype.h assume that if machine/ansi.h is included,\n   and _BSD_WCHAR_T_ is not defined, then rune_t is available.\n   machine/ansi.h says, \"Note that _WCHAR_T_ and _RUNE_T_ must be of\n   the same type.\" */\n#ifdef _BSD_WCHAR_T_\n#undef _BSD_WCHAR_T_\n#ifdef _BSD_RUNE_T_\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\ntypedef _BSD_RUNE_T_ rune_t;\n#define _BSD_WCHAR_T_DEFINED_\n#define _BSD_RUNE_T_DEFINED_\t/* Darwin */\n#if defined (__FreeBSD__) && (__FreeBSD__ < 5)\n/* Why is this file so hard to maintain properly?  In contrast to\n   the comment above regarding BSD/386 1.1, on FreeBSD for as long\n   as the symbol has existed, _BSD_RUNE_T_ must not stay defined or\n   redundant typedefs will occur when stdlib.h is included after this file. */\n#undef _BSD_RUNE_T_\n#endif\n#endif\n#endif\n#endif\n/* FreeBSD 5 can't be handled well using \"traditional\" logic above\n   since it no longer defines _BSD_RUNE_T_ yet still desires to export\n   rune_t in some cases... */\n#if defined (__FreeBSD__) && (__FreeBSD__ >= 5)\n#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)\n#if __BSD_VISIBLE\n#ifndef _RUNE_T_DECLARED\ntypedef __rune_t rune_t;\n#define _RUNE_T_DECLARED\n#endif\n#endif\n#endif\n#endif\n\n#ifndef __WCHAR_TYPE__\n#define __WCHAR_TYPE__ int\n#endif\n#ifndef __cplusplus\ntypedef __WCHAR_TYPE__ wchar_t;\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* _WCHAR_T_DECLARED */\n#endif\t\t\t\t/* _BSD_RUNE_T_DEFINED_ */\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\n#endif\t\t\t\t/* __WCHAR_T__ */\n#endif\t\t\t\t/* __wchar_t__ */\n#undef\t__need_wchar_t\n#endif\t\t\t\t/* _STDDEF_H or __need_wchar_t.  */\n\n#if defined (__need_wint_t)\n#ifndef _WINT_T\n#define _WINT_T\n\n#ifndef __WINT_TYPE__\n#define __WINT_TYPE__ unsigned int\n#endif\ntypedef __WINT_TYPE__ wint_t;\n#endif\n#undef __need_wint_t\n#endif\n\n/*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.\n    are already defined.  */\n/*  BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.  */\n/*  NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here.  */\n#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || defined(_X86_64_ANSI_H_) || defined(_I386_ANSI_H_)\n/*  The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_\n    are probably typos and should be removed before 2.8 is released.  */\n#ifdef _GCC_PTRDIFF_T_\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T_\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T_\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n/*  The following ones are the real ones.  */\n#ifdef _GCC_PTRDIFF_T\n#undef _PTRDIFF_T_\n#undef _BSD_PTRDIFF_T_\n#endif\n#ifdef _GCC_SIZE_T\n#undef _SIZE_T_\n#undef _BSD_SIZE_T_\n#endif\n#ifdef _GCC_WCHAR_T\n#undef _WCHAR_T_\n#undef _BSD_WCHAR_T_\n#endif\n#endif\t\t\t\t/* _ANSI_H_ || _MACHINE_ANSI_H_ || _X86_64_ANSI_H_ || _I386_ANSI_H_ */\n\n#endif\t\t\t\t/* __sys_stdtypes_h */\n\n/* A null pointer constant.  */\n\n#if defined (_STDDEF_H) || defined (__need_NULL)\n#undef NULL\t\t\t/* in case <stdio.h> has defined it. */\n#ifdef __GNUG__\n#define NULL __null\n#else\t\t\t\t/* G++ */\n#ifndef __cplusplus\n#define NULL ((void *)0)\n#else\t\t\t\t/* C++ */\n#define NULL 0\n#endif\t\t\t\t/* C++ */\n#endif\t\t\t\t/* G++ */\n#endif\t\t\t\t/* NULL not defined and <stddef.h> or need NULL.  */\n#undef\t__need_NULL\n\n#ifdef _STDDEF_H\n\n/* Offset of member MEMBER in a struct of type TYPE. */\n#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)\n\n#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) \\\n  || (defined(__cplusplus) && __cplusplus >= 201103L)\n#ifndef _GCC_MAX_ALIGN_T\n#define _GCC_MAX_ALIGN_T\n/* Type whose alignment is supported in every context and is at least\n   as great as that of any standard type not using alignment\n   specifiers.  */\ntypedef struct {\n\tlong long __max_align_ll __attribute__ ((__aligned__(__alignof__(long long))));\n\tlong double __max_align_ld __attribute__ ((__aligned__(__alignof__(long double))));\n} max_align_t;\n#endif\n#endif\t\t\t\t/* C11 or C++11.  */\n\n#if defined(__cplusplus) && __cplusplus >= 201103L\n#ifndef _GXX_NULLPTR_T\n#define _GXX_NULLPTR_T\ntypedef decltype(nullptr) nullptr_t;\n#endif\n#endif\t\t\t\t/* C++11.  */\n\n#endif\t\t\t\t/* _STDDEF_H was defined this time */\n\n#endif\t\t\t\t/* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__\n\t\t\t\t   || __need_XXX was not defined before */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include/stdint.h",
    "content": "#ifndef _GCC_WRAP_STDINT_H\n#if __STDC_HOSTED__\n#if defined __cplusplus && __cplusplus >= 201103L\n#undef __STDC_LIMIT_MACROS\n#define __STDC_LIMIT_MACROS\n#undef __STDC_CONSTANT_MACROS\n#define __STDC_CONSTANT_MACROS\n#endif\n#include_next <stdint.h>\n#else\n#include \"stdint-gcc.h\"\n#endif\n#define _GCC_WRAP_STDINT_H\n#endif\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed/limits.h",
    "content": "/* Copyright (C) 1992-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n/* This administrivia gets added to the beginning of limits.h\n   if the system has its own version of limits.h.  */\n\n/* We use _GCC_LIMITS_H_ because we want this not to match\n   any macros that the system's limits.h uses for its own purposes.  */\n#ifndef _GCC_LIMITS_H_\t\t/* Terminated in limity.h.  */\n#define _GCC_LIMITS_H_\n\n#ifndef _LIBC_LIMITS_H_\n/* Use \"...\" so that we find syslimits.h only in this same directory.  */\n#include \"syslimits.h\"\n#endif\n/* Copyright (C) 1991-2016 Free Software Foundation, Inc.\n\nThis file is part of GCC.\n\nGCC is free software; you can redistribute it and/or modify it under\nthe terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 3, or (at your option) any later\nversion.\n\nGCC is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nUnder Section 7 of GPL version 3, you are granted additional\npermissions described in the GCC Runtime Library Exception, version\n3.1, as published by the Free Software Foundation.\n\nYou should have received a copy of the GNU General Public License and\na copy of the GCC Runtime Library Exception along with this program;\nsee the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n<http://www.gnu.org/licenses/>.  */\n\n#ifndef _LIMITS_H___\n#define _LIMITS_H___\n\n/* Number of bits in a `char'.  */\n#undef CHAR_BIT\n#define CHAR_BIT __CHAR_BIT__\n\n/* Maximum length of a multibyte character.  */\n#ifndef MB_LEN_MAX\n#define MB_LEN_MAX 1\n#endif\n\n/* Minimum and maximum values a `signed char' can hold.  */\n#undef SCHAR_MIN\n#define SCHAR_MIN (-SCHAR_MAX - 1)\n#undef SCHAR_MAX\n#define SCHAR_MAX __SCHAR_MAX__\n\n/* Maximum value an `unsigned char' can hold.  (Minimum is 0).  */\n#undef UCHAR_MAX\n#if __SCHAR_MAX__ == __INT_MAX__\n#define UCHAR_MAX (SCHAR_MAX * 2U + 1U)\n#else\n#define UCHAR_MAX (SCHAR_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `char' can hold.  */\n#ifdef __CHAR_UNSIGNED__\n#undef CHAR_MIN\n#if __SCHAR_MAX__ == __INT_MAX__\n#define CHAR_MIN 0U\n#else\n#define CHAR_MIN 0\n#endif\n#undef CHAR_MAX\n#define CHAR_MAX UCHAR_MAX\n#else\n#undef CHAR_MIN\n#define CHAR_MIN SCHAR_MIN\n#undef CHAR_MAX\n#define CHAR_MAX SCHAR_MAX\n#endif\n\n/* Minimum and maximum values a `signed short int' can hold.  */\n#undef SHRT_MIN\n#define SHRT_MIN (-SHRT_MAX - 1)\n#undef SHRT_MAX\n#define SHRT_MAX __SHRT_MAX__\n\n/* Maximum value an `unsigned short int' can hold.  (Minimum is 0).  */\n#undef USHRT_MAX\n#if __SHRT_MAX__ == __INT_MAX__\n#define USHRT_MAX (SHRT_MAX * 2U + 1U)\n#else\n#define USHRT_MAX (SHRT_MAX * 2 + 1)\n#endif\n\n/* Minimum and maximum values a `signed int' can hold.  */\n#undef INT_MIN\n#define INT_MIN (-INT_MAX - 1)\n#undef INT_MAX\n#define INT_MAX __INT_MAX__\n\n/* Maximum value an `unsigned int' can hold.  (Minimum is 0).  */\n#undef UINT_MAX\n#define UINT_MAX (INT_MAX * 2U + 1U)\n\n/* Minimum and maximum values a `signed long int' can hold.\n   (Same as `int').  */\n#undef LONG_MIN\n#define LONG_MIN (-LONG_MAX - 1L)\n#undef LONG_MAX\n#define LONG_MAX __LONG_MAX__\n\n/* Maximum value an `unsigned long int' can hold.  (Minimum is 0).  */\n#undef ULONG_MAX\n#define ULONG_MAX (LONG_MAX * 2UL + 1UL)\n\n#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n/* Minimum and maximum values a `signed long long int' can hold.  */\n#undef LLONG_MIN\n#define LLONG_MIN (-LLONG_MAX - 1LL)\n#undef LLONG_MAX\n#define LLONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n#undef ULLONG_MAX\n#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)\n#endif\n\n#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)\n/* Minimum and maximum values a `signed long long int' can hold.  */\n#undef LONG_LONG_MIN\n#define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)\n#undef LONG_LONG_MAX\n#define LONG_LONG_MAX __LONG_LONG_MAX__\n\n/* Maximum value an `unsigned long long int' can hold.  (Minimum is 0).  */\n#undef ULONG_LONG_MAX\n#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)\n#endif\n\n#endif\t\t\t\t/* _LIMITS_H___ */\n/* This administrivia gets added to the end of limits.h\n   if the system has its own version of limits.h.  */\n\n#else\t\t\t\t/* not _GCC_LIMITS_H_ */\n\n#ifdef _GCC_NEXT_LIMITS_H\n#include_next <limits.h>\t/* recurse down to the real one */\n#endif\n\n#endif\t\t\t\t/* not _GCC_LIMITS_H_ */\n"
  },
  {
    "path": "v2/headers/linux_arm/usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed/syslimits.h",
    "content": "/* syslimits.h stands for the system's own limits.h file.\n   If we can use it ok unmodified, then we install this text.\n   If fixincludes fixes it, then the fixed version is installed\n   instead of this text.  */\n\n#define _GCC_NEXT_LIMITS_H\t/* tell gcc's limits.h to recurse */\n#include_next <limits.h>\n#undef _GCC_NEXT_LIMITS_H\n"
  },
  {
    "path": "v2/lexer.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"go/token\"\n\t\"io\"\n\n\t\"github.com/cznic/golex/lex\"\n\t\"github.com/cznic/mathutil\"\n\t\"github.com/cznic/xc\"\n)\n\nvar (\n\tnoTypedefNameAfter = map[int]struct{}{\n\t\t'*':          {},\n\t\t'.':          {},\n\t\tARROW:        {},\n\t\tBOOL:         {},\n\t\tCHAR:         {},\n\t\tCOMPLEX:      {},\n\t\tDOUBLE:       {},\n\t\tENUM:         {},\n\t\tFLOAT:        {},\n\t\tGOTO:         {},\n\t\tIDENTIFIER:   {},\n\t\tINT:          {},\n\t\tLONG:         {},\n\t\tSHORT:        {},\n\t\tSIGNED:       {},\n\t\tSTRUCT:       {},\n\t\tTYPEDEF_NAME: {},\n\t\tUNION:        {},\n\t\tUNSIGNED:     {},\n\t\tVOID:         {},\n\t}\n)\n\nconst (\n\tintBits  = mathutil.IntBits\n\tbitShift = intBits>>6 + 5\n\tbitMask  = intBits - 1\n\n\tscINITIAL = 0 // Start condition (shared value).\n)\n\nconst (\n\t// Character class is an 8 bit encoding of an Unicode rune for the\n\t// golex generated FSM.\n\t//\n\t// Every ASCII rune is its own class.  DO NOT change any of the\n\t// existing values. Adding new classes is OK.\n\tccEOF         = iota + 0x80\n\t_             // ccError\n\tccOther       // Any other rune.\n\tccUCNDigit    // [0], Annex D, Universal character names for identifiers - digits.\n\tccUCNNonDigit // [0], Annex D, Universal character names for identifiers - non digits.\n)\n\ntype trigraphs struct {\n\t*lex.Lexer\n\tpos token.Pos\n\tr   *bufio.Reader\n\tsc  int\n}\n\nfunc newTrigraphs(ctx *context, file *token.File, r io.Reader) (*trigraphs, error) {\n\tsc := scINITIAL\n\tif ctx.tweaks.EnableTrigraphs {\n\t\tsc = scTRIGRAPHS\n\t}\n\tt := &trigraphs{\n\t\tpos: file.Pos(0),\n\t\tr:   bufio.NewReader(r),\n\t\tsc:  sc,\n\t}\n\tlx, err := lex.New(\n\t\tfile,\n\t\tt,\n\t\tlex.ErrorFunc(func(pos token.Pos, msg string) { ctx.errPos(pos, msg) }),\n\t\tlex.RuneClass(func(r rune) int { return int(r) }),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tt.Lexer = lx\n\treturn t, nil\n}\n\nfunc (t *trigraphs) ReadRune() (rune, int, error) { panic(\"internal error 9\") }\n\nfunc (t *trigraphs) ReadChar() (c lex.Char, size int, err error) {\n\tsize = 1\n\tb, err := t.r.ReadByte()\n\tif err != nil {\n\t\treturn lex.NewChar(t.pos, rune(b)), 0, err\n\t}\n\n\tc = lex.NewChar(t.pos, rune(b))\n\tt.pos++\n\treturn c, 1, nil\n}\n\ntype ungetBuffer []cppToken\n\nfunc (u *ungetBuffer) unget(t cppToken) { *u = append(*u, t) }\n\nfunc (u *ungetBuffer) read() (t cppToken) {\n\ts := *u\n\tn := len(s) - 1\n\tt = s[n]\n\t*u = s[:n]\n\treturn t\n}\n\nfunc (u *ungetBuffer) ungets(toks ...cppToken) {\n\ts := *u\n\tfor i := len(toks) - 1; i >= 0; i-- {\n\t\ts = append(s, toks[i])\n\t}\n\t*u = s\n}\n\ntype lexer struct {\n\t*context\n\t*lex.Lexer\n\tast         Node\n\tattr        [][]xc.Token\n\tattr2       [][]xc.Token\n\tcommentPos0 token.Pos\n\tcurrFn      int // [0]6.4.2.2\n\tlast        lex.Char\n\tmode        int // CONSTANT_EXPRESSION, TRANSLATION_UNIT\n\tprev        int // Most recent result returned by Lex\n\tsc          int\n\tt           *trigraphs\n\ttc          *tokenPipe\n\n\tnoTypedefName bool // Do not consider next token a TYPEDEF_NAME\n\ttypedef       bool // Prev token returned was TYPEDEF_NAME\n\n\tungetBuffer\n}\n\nfunc newLexer(ctx *context, nm string, sz int, r io.Reader) (*lexer, error) {\n\tfile := fset.AddFile(nm, -1, sz)\n\tt, err := newTrigraphs(ctx, file, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tl := &lexer{\n\t\tcontext: ctx,\n\t\tt:       t,\n\t}\n\n\tlx, err := lex.New(\n\t\tfile,\n\t\tl,\n\t\tlex.ErrorFunc(func(pos token.Pos, msg string) { l.errPos(pos, msg) }),\n\t\tlex.RuneClass(rune2class),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tl.Lexer = lx\n\treturn l, nil\n}\n\nfunc (l *lexer) Error(msg string)             { l.err(l.First, \"%v\", msg) }\nfunc (l *lexer) ReadRune() (rune, int, error) { panic(\"internal error 10\") }\nfunc (l *lexer) comment(general bool)         { /*TODO*/ }\nfunc (l *lexer) parseExpr() bool              { return l.parse(CONSTANT_EXPRESSION) }\n\nfunc (l *lexer) Lex(lval *yySymType) (r int) {\nmore:\n\t//TODO use follow set to recover from errors.\n\tl.lex(lval)\n\tlval.Token.Rune = l.toC(lval.Token.Rune, lval.Token.Val)\n\ttypedef := l.typedef\n\tl.typedef = false\n\tnoTypedefName := l.noTypedefName\n\tl.noTypedefName = false\n\tswitch lval.Token.Rune {\n\tcase NON_REPL:\n\t\tlval.Token.Rune = IDENTIFIER\n\t\tfallthrough\n\tcase IDENTIFIER:\n\t\tif lval.Token.Val == idAttribute {\n\t\t\tif len(l.attr) != 0 {\n\t\t\t\tpanic(fmt.Errorf(\"%v:\", l.position(lval.Token)))\n\t\t\t}\n\n\t\t\tl.attr = nil\n\t\t\tl.parseAttr(lval)\n\t\t\tgoto more\n\t\t}\n\n\t\tif noTypedefName || typedef || !followSetHasTypedefName[lval.yys] {\n\t\t\tbreak\n\t\t}\n\n\t\tif _, ok := noTypedefNameAfter[l.prev]; ok {\n\t\t\tbreak\n\t\t}\n\n\t\tif l.scope.isTypedef(lval.Token.Val) {\n\t\t\t// https://en.wikipedia.org/wiki/The_lexer_hack\n\t\t\tlval.Token.Rune = TYPEDEF_NAME\n\t\t\tl.typedef = true\n\t\t}\n\tcase PPNUMBER:\n\t\tlval.Token.Rune = INTCONST\n\t\tval := dict.S(lval.Token.Val)\n\t\tif !(len(val) > 1 && val[0] == '0' && (val[1] == 'x' || val[1] == 'X')) {\n\t\t\tfor _, v := range val {\n\t\t\t\tswitch v {\n\t\t\t\tcase '.', '+', '-', 'e', 'E', 'p', 'P':\n\t\t\t\t\tlval.Token.Rune = FLOATCONST\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tcase ccEOF:\n\t\tlval.Token.Rune = lex.RuneEOF\n\t\tlval.Token.Val = 0\n\t}\n\n\tif l.prev == FOR {\n\t\tl.newScope()\n\t}\n\tl.prev = int(lval.Token.Rune)\n\treturn l.prev\n}\n\nfunc (l *lexer) attrs() (r [][]xc.Token) {\n\tl.attr, r = nil, l.attr\n\treturn r\n}\n\nfunc (l *lexer) parseAttr(lval *yySymType) {\n\tl.lex(lval)\n\tif lval.Token.Rune != '(' {\n\t\tpanic(\"TODO\")\n\t}\n\n\tl.lex(lval)\n\tif lval.Token.Rune != '(' {\n\t\tpanic(\"TODO\")\n\t}\n\n\tl.parseAttrList(lval)\n\tl.lex(lval)\n\tif lval.Token.Rune != ')' {\n\t\tpanic(\"TODO\")\n\t}\n\n\tl.lex(lval)\n\tif lval.Token.Rune != ')' {\n\t\tpanic(\"TODO\")\n\t}\n}\n\nfunc (l *lexer) parseAttrList(lval *yySymType) {\n\tfor {\n\t\tl.lex(lval)\n\t\tswitch t := lval.Token; t.Rune {\n\t\tcase IDENTIFIER:\n\t\t\tl.attr = append(l.attr, []xc.Token{t})\n\t\tcase ')':\n\t\t\tl.unget(cppToken{Token: t})\n\t\t\treturn\n\t\tcase '(':\n\t\t\tl.parseAttrParams(lval)\n\t\tcase ',':\n\t\t\t// ok\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v\", l.position(lval.Token), PrettyString(lval.Token)))\n\t\t}\n\t}\n}\n\nfunc (l *lexer) parseAttrParams(lval *yySymType) {\n\tfor {\n\t\tl.lex(lval)\n\t\tswitch t := lval.Token; t.Rune {\n\t\tcase STRINGLITERAL:\n\t\t\tn := len(l.attr)\n\t\t\tl.attr[n-1] = append(l.attr[n-1], t)\n\t\tcase ')':\n\t\t\treturn\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %v\", l.position(lval.Token), PrettyString(lval.Token)))\n\t\t}\n\t}\n}\n\nfunc (l *lexer) ReadChar() (c lex.Char, size int, err error) {\n\tif c = l.t.Lookahead(); c.Rune == lex.RuneEOF {\n\t\treturn c, 0, io.EOF\n\t}\n\n\tch := l.t.scan()\n\treturn lex.NewChar(l.t.First.Pos(), rune(ch)), 1, nil\n}\n\nfunc (l *lexer) Reduced(rule, state int, lval *yySymType) (stop bool) {\n\tif rule != l.exampleRule {\n\t\treturn false\n\t}\n\n\tswitch x := lval.node.(type) {\n\tcase interface {\n\t\tfragment() interface{}\n\t}:\n\t\tl.exampleAST = x.fragment()\n\tdefault:\n\t\tl.exampleAST = x\n\t}\n\treturn true\n}\n\nfunc (l *lexer) cppScan() lex.Char {\nagain:\n\tr := l.scan()\n\tif r == ' ' && l.last.Rune == ' ' {\n\t\tgoto again\n\t}\n\n\tl.last = lex.NewChar(l.First.Pos(), rune(r))\n\treturn l.last\n}\n\nfunc (l *lexer) lex(lval *yySymType) {\n\tif len(l.ungetBuffer) != 0 {\n\t\tlval.Token = l.ungetBuffer.read().Token\n\t\treturn\n\t}\n\n\tif l.tc != nil {\n\t\tlval.Token = l.tc.read().Token\n\t\tl.First = lval.Token.Char\n\t\treturn\n\t}\n\n\tch := l.scanChar()\n\tlval.Token = xc.Token{Char: ch}\n\tif _, ok := tokHasVal[ch.Rune]; ok {\n\t\tlval.Token = xc.Token{Char: ch, Val: dict.ID(l.TokenBytes(nil))}\n\t}\n}\n\n// static const char __func__[] = \"function-name\"; // [0], 6.4.2.2.\nfunc (l *lexer) declareFuncName() {\n\tpos := l.First.Pos() // '{'\n\tl.ungets(\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, STATIC), Val: idStatic}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, CONST), Val: idConst}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, CHAR), Val: idChar}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, IDENTIFIER), Val: idFuncName}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, '[')}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, ']')}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, '=')}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, STRINGLITERAL), Val: dict.SID(`\"` + string(dict.S(l.currFn)) + `\"`)}},\n\t\tcppToken{Token: xc.Token{Char: lex.NewChar(pos, ';')}},\n\t)\n}\n\nfunc (l *lexer) parse(mode int) bool {\n\tvar tok xc.Token\n\ttok.Rune = rune(mode)\n\tl.ungetBuffer = append(l.ungetBuffer, cppToken{Token: tok})\n\tl.mode = mode\n\tl.last.Rune = '\\n'\n\treturn yyParse(l) == 0\n}\n\nfunc (l *lexer) scanChar() (c lex.Char) {\nagain:\n\tr := l.scan()\n\tif r == ' ' {\n\t\tgoto again\n\t}\n\n\tl.last = lex.NewChar(l.First.Pos(), rune(r))\n\tswitch r {\n\tcase CONSTANT_EXPRESSION, TRANSLATION_UNIT:\n\t\tl.mode = r\n\t}\n\treturn l.last\n}\n"
  },
  {
    "path": "v2/model.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\n\t\"github.com/cznic/ir\"\n\t\"github.com/cznic/mathutil\"\n)\n\n// Model describes properties of scalar Types.\ntype Model map[TypeKind]ModelItem\n\n// ModelItem describers properties of a particular Type.\ntype ModelItem struct {\n\tSize        int\n\tAlign       int\n\tStructAlign int\n}\n\n// NewModel returns the model appropriate for the current OS and architecture\n// or according to the environment variables GOOS and GOARCH, if set.\nfunc NewModel() (m Model, err error) {\n\tswitch arch := env(\"GOARCH\", runtime.GOARCH); arch {\n\tcase \"arm\":\n\t\treturn Model{\n\t\t\tBool:      {1, 1, 1},\n\t\t\tChar:      {1, 1, 1},\n\t\t\tInt:       {4, 4, 4},\n\t\t\tLong:      {4, 4, 4},\n\t\t\tLongLong:  {8, 4, 4},\n\t\t\tSChar:     {1, 1, 1},\n\t\t\tShort:     {2, 2, 2},\n\t\t\tUChar:     {1, 1, 1},\n\t\t\tUInt:      {4, 4, 4},\n\t\t\tULong:     {4, 4, 4},\n\t\t\tULongLong: {8, 4, 4},\n\t\t\tUShort:    {2, 2, 2},\n\n\t\t\tFloat:      {4, 4, 4},\n\t\t\tDouble:     {8, 4, 4},\n\t\t\tLongDouble: {8, 4, 4},\n\n\t\t\tFloatComplex:      {8, 4, 4},\n\t\t\tDoubleComplex:     {16, 4, 4},\n\t\t\tLongDoubleComplex: {16, 4, 4},\n\n\t\t\tVoid: {1, 1, 1},\n\t\t\tPtr:  {4, 4, 4},\n\t\t}, nil\n\tcase \"386\":\n\t\treturn Model{\n\t\t\tBool:      {1, 1, 1},\n\t\t\tChar:      {1, 1, 1},\n\t\t\tInt:       {4, 4, 4},\n\t\t\tLong:      {4, 4, 4},\n\t\t\tLongLong:  {8, 8, 4},\n\t\t\tSChar:     {1, 1, 1},\n\t\t\tShort:     {2, 2, 2},\n\t\t\tUChar:     {1, 1, 1},\n\t\t\tUInt:      {4, 4, 4},\n\t\t\tULong:     {4, 4, 4},\n\t\t\tULongLong: {8, 8, 4},\n\t\t\tUShort:    {2, 2, 2},\n\n\t\t\tFloat:      {4, 4, 4},\n\t\t\tDouble:     {8, 8, 4},\n\t\t\tLongDouble: {8, 8, 4},\n\n\t\t\tFloatComplex:      {8, 8, 4},\n\t\t\tDoubleComplex:     {16, 8, 4},\n\t\t\tLongDoubleComplex: {16, 8, 4},\n\n\t\t\tVoid: {1, 1, 1},\n\t\t\tPtr:  {4, 4, 4},\n\t\t}, nil\n\tcase \"amd64\":\n\t\tvar longLength = 8\n\t\tif env(\"GOOS\", runtime.GOOS) == \"windows\" {\n\t\t\tlongLength = 4\n\t\t}\n\n\t\tmodel := Model{\n\t\t\tBool:      {1, 1, 1},\n\t\t\tChar:      {1, 1, 1},\n\t\t\tInt:       {4, 4, 4},\n\t\t\tLong:      {longLength, longLength, longLength},\n\t\t\tLongLong:  {8, 8, 8},\n\t\t\tSChar:     {1, 1, 1},\n\t\t\tShort:     {2, 2, 2},\n\t\t\tUChar:     {1, 1, 1},\n\t\t\tUInt:      {4, 4, 4},\n\t\t\tULong:     {longLength, longLength, longLength},\n\t\t\tULongLong: {8, 8, 8},\n\t\t\tUShort:    {2, 2, 2},\n\n\t\t\tFloat:      {4, 4, 4},\n\t\t\tDouble:     {8, 8, 8},\n\t\t\tLongDouble: {8, 8, 8},\n\n\t\t\tFloatComplex:      {8, 8, 4},\n\t\t\tDoubleComplex:     {16, 8, 4},\n\t\t\tLongDoubleComplex: {16, 8, 4},\n\n\t\t\tVoid: {1, 1, 1},\n\t\t\tPtr:  {8, 8, 8},\n\t\t}\n\n\t\treturn model, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown/unsupported architecture %s\", arch)\n\t}\n}\n\n// Equal returns whether m equals n.\nfunc (m Model) Equal(n Model) bool {\n\tif len(m) != len(n) {\n\t\treturn false\n\t}\n\n\tfor k, v := range m {\n\t\tif v != n[k] {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\n// Sizeof returns the size in bytes of a variable of type t.\nfunc (m Model) Sizeof(t Type) int64 {\n\tswitch x := UnderlyingType(t).(type) {\n\tcase *ArrayType:\n\t\tif x.Size.Type == nil && x.Size.Value == nil { // T[], but not T[i+2]\n\t\t\treturn int64(m[Ptr].Size)\n\t\t}\n\n\t\treturn m.Sizeof(x.Item) * x.Size.Value.(*ir.Int64Value).Value\n\tcase *EnumType:\n\t\treturn m.Sizeof(x.Enums[0].Operand.Type)\n\tcase *NamedType:\n\t\treturn m.Sizeof(x.Type)\n\tcase *PointerType:\n\t\treturn int64(m[Ptr].Size)\n\tcase *StructType:\n\t\tlayout := m.Layout(x)\n\t\tif len(layout) == 0 {\n\t\t\treturn 0\n\t\t}\n\n\t\tlf := layout[len(layout)-1]\n\t\treturn lf.Offset + lf.Size + int64(lf.Padding)\n\tcase *TaggedStructType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn m.Sizeof(u)\n\tcase TypeKind:\n\t\treturn int64(m[x].Size)\n\tcase *UnionType:\n\t\tvar sz int64\n\t\tfor _, v := range m.Layout(x) {\n\t\t\tif v.Size > sz {\n\t\t\t\tsz = v.Size\n\t\t\t}\n\t\t}\n\t\treturn roundup(sz, int64(m.Alignof(x)))\n\tcase nil:\n\t\tpanic(\"internal error\")\n\tdefault:\n\t\tpanic(x)\n\t}\n}\n\n// FieldProperties describe a struct/union field.\ntype FieldProperties struct {\n\tBitoff     int // Zero based bit number of a bitfield\n\tBits       int // Width of a bit field or zero otherwise.\n\tDeclarator *Declarator\n\tOffset     int64 // Byte offset relative to start of the struct/union.\n\tPackedType Type  // Bits != 0: Storage type holding the bit field.\n\tPadding    int   // Adjustment to enforce proper alignment.\n\tSize       int64 // Field size for copying.\n\tType       Type\n\n\tAnonymous bool\n}\n\n// Mask returns the bit mask of bit field described by f.\nfunc (f *FieldProperties) Mask() uint64 {\n\tif f.Bits == 0 {\n\t\treturn 1<<64 - 1\n\t}\n\n\treturn (1<<uint(f.Bits) - 1) << uint(f.Bitoff)\n}\n\n// Layout computes the memory layout of t.\nfunc (m Model) Layout(t Type) (r []FieldProperties) {\n\t//TODO memoize\n\tswitch x := UnderlyingType(t).(type) {\n\tcase *StructType:\n\t\tif len(x.Fields) == 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tif x.layout != nil {\n\t\t\treturn x.layout\n\t\t}\n\n\t\tdefer func() { x.layout = r }()\n\n\t\tr = make([]FieldProperties, len(x.Fields))\n\t\tvar off int64\n\t\tbitoff := 0\n\t\tzeroFix := false\n\t\tfor i, v := range x.Fields {\n\t\t\tswitch {\n\t\t\tcase v.Bits != 0:\n\t\t\t\tswitch {\n\t\t\t\tcase bitoff == 0 && v.Bits > 0:\n\t\t\t\t\tr[i] = FieldProperties{Offset: off, Bitoff: bitoff, Bits: v.Bits, Declarator: v.Declarator, Type: v.Type}\n\t\t\t\t\tbitoff = v.Bits\n\t\t\t\tdefault:\n\t\t\t\t\tif v.Bits < 0 {\n\t\t\t\t\t\tif n := m.packBits(bitoff, i-1, off, r); bitoff != 0 {\n\t\t\t\t\t\t\toff = n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tr[i] = FieldProperties{Offset: off, Bits: -1, Declarator: v.Declarator, Type: v.Type}\n\t\t\t\t\t\tbitoff = 0\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tn := bitoff + v.Bits\n\t\t\t\t\tif n > 32 {\n\t\t\t\t\t\toff = m.packBits(bitoff, i-1, off, r)\n\t\t\t\t\t\tr[i] = FieldProperties{Offset: off, Bits: v.Bits, Declarator: v.Declarator, Type: v.Type}\n\t\t\t\t\t\tbitoff = v.Bits\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tr[i] = FieldProperties{Offset: off, Bitoff: bitoff, Bits: v.Bits, Declarator: v.Declarator, Type: v.Type}\n\t\t\t\t\tbitoff = n\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif bitoff != 0 {\n\t\t\t\t\toff = m.packBits(bitoff, i-1, off, r)\n\t\t\t\t\tbitoff = 0\n\t\t\t\t}\n\t\t\t\tsz := m.Sizeof(v.Type)\n\t\t\t\ta := m.StructAlignof(v.Type)\n\t\t\t\tz := off\n\t\t\t\tif a != 0 {\n\t\t\t\t\toff = roundup(off, int64(a))\n\t\t\t\t}\n\t\t\t\tif off != z {\n\t\t\t\t\tr[i-1].Padding = int(off - z)\n\t\t\t\t}\n\t\t\t\tr[i] = FieldProperties{Offset: off, Size: sz, Declarator: v.Declarator, Type: v.Type, Anonymous: v.Anonymous}\n\t\t\t\tif sz == 0 && i == len(x.Fields)-1 {\n\t\t\t\t\tsz = 1\n\t\t\t\t\tzeroFix = true\n\t\t\t\t}\n\t\t\t\toff += sz\n\t\t\t}\n\t\t}\n\t\ti := len(r) - 1\n\t\tif bitoff != 0 {\n\t\t\toff = m.packBits(bitoff, i, off, r)\n\t\t}\n\t\tfor i, v := range r {\n\t\t\tif v.Bits > 0 {\n\t\t\t\tx.Fields[i].PackedType = v.PackedType\n\t\t\t}\n\t\t}\n\t\talign := 0\n\t\tfor i, v := range x.Fields {\n\t\t\tif r[i].Bits < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tt := v.Type\n\t\t\tif v.PackedType != nil {\n\t\t\t\tt = v.PackedType\n\t\t\t}\n\t\t\talign = mathutil.Max(align, m.StructAlignof(t))\n\t\t}\n\t\tz := off\n\t\toff = roundup(off, int64(align))\n\t\tif zeroFix {\n\t\t\tz--\n\t\t}\n\t\tif off != z {\n\t\t\tr[len(r)-1].Padding = int(off - z)\n\t\t}\n\t\treturn r\n\tcase *UnionType:\n\t\tif len(x.Fields) == 0 {\n\t\t\treturn nil\n\t\t}\n\n\t\tif x.layout != nil {\n\t\t\treturn x.layout\n\t\t}\n\n\t\tdefer func() { x.layout = r }()\n\n\t\tr = make([]FieldProperties, len(x.Fields))\n\t\tfor i, v := range x.Fields {\n\t\t\tswitch {\n\t\t\tcase v.Bits < 0:\n\t\t\t\tm.packBits(v.Bits, i, 0, r)\n\t\t\tcase v.Bits > 0:\n\t\t\t\tr[i] = FieldProperties{Bits: v.Bits, Declarator: v.Declarator, Type: v.Type}\n\t\t\t\tm.packBits(v.Bits, i, 0, r)\n\t\t\t\tx.Fields[i].PackedType = r[i].PackedType\n\t\t\tdefault:\n\t\t\t\tsz := m.Sizeof(v.Type)\n\t\t\t\tr[i] = FieldProperties{Size: sz, Bits: v.Bits, Declarator: v.Declarator, Type: v.Type}\n\t\t\t}\n\t\t}\n\t\tfor i, v := range r {\n\t\t\tif v.Bits != 0 {\n\t\t\t\tx.Fields[i].PackedType = v.PackedType\n\t\t\t}\n\t\t}\n\t\treturn r\n\tcase nil:\n\t\tpanic(\"internal error\")\n\tdefault:\n\t\tpanic(x)\n\t}\n}\n\nfunc (m *Model) packBits(bitoff, i int, off int64, r []FieldProperties) int64 {\n\tvar t Type\n\tswitch {\n\tcase bitoff <= 8:\n\t\tt = UChar\n\tcase bitoff <= 16:\n\t\tt = UShort\n\tcase bitoff <= 32:\n\t\tt = UInt\n\tcase bitoff <= 64:\n\t\tt = ULongLong\n\tdefault:\n\t\tpanic(\"internal error\")\n\t}\n\tsz := m.Sizeof(t)\n\ta := m.StructAlignof(t)\n\tz := off\n\tif a != 0 {\n\t\toff = roundup(off, int64(a))\n\t}\n\tvar first int\n\tfor first = i; first >= 0 && r[first].Bits > 0 && r[first].PackedType == nil; first-- {\n\t}\n\tfirst++\n\tif off != z {\n\t\tr[first-1].Padding = int(off - z)\n\t}\n\tfor j := first; j <= i; j++ {\n\t\tr[j].Offset = off\n\t\tr[j].Size = sz\n\t\tr[j].PackedType = t\n\t}\n\treturn off + sz\n}\n\n// Alignof computes the memory alignment requirements of t. One is returned\n// for a struct/union type with no fields.\nfunc (m Model) Alignof(t Type) int {\n\tswitch x := t.(type) {\n\tcase *ArrayType:\n\t\tif x.Size.Value != nil {\n\t\t\treturn m.Alignof(x.Item)\n\t\t}\n\n\t\treturn m[Ptr].Align\n\tcase *EnumType:\n\t\treturn m.Alignof(x.Enums[0].Operand.Type)\n\tcase *NamedType:\n\t\treturn m.Alignof(x.Type)\n\tcase *PointerType:\n\t\treturn m[Ptr].Align\n\tcase *StructType:\n\t\tm.Layout(x)\n\t\tr := 1\n\t\tfor _, v := range x.Fields {\n\t\t\tt := v.Type\n\t\t\tif v.Bits < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif v.Bits > 0 {\n\t\t\t\tt = v.PackedType\n\t\t\t}\n\t\t\tif a := m.StructAlignof(t); a > r {\n\t\t\t\tr = a\n\t\t\t}\n\t\t}\n\t\treturn r\n\tcase *TaggedEnumType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.Alignof(u)\n\tcase *TaggedStructType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.Alignof(u)\n\tcase *TaggedUnionType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.Alignof(u)\n\tcase TypeKind:\n\t\treturn m[x].Align\n\tcase *UnionType:\n\t\tm.Layout(x)\n\t\tr := 1\n\t\tfor _, v := range x.Fields {\n\t\t\tt := v.Type\n\t\t\tif v.Bits < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif v.Bits > 0 {\n\t\t\t\tt = v.PackedType\n\t\t\t}\n\t\t\tif a := m.StructAlignof(t); a > r {\n\t\t\t\tr = a\n\t\t\t}\n\t\t}\n\t\treturn r\n\tcase nil:\n\t\tpanic(\"internal error\")\n\tdefault:\n\t\tpanic(x)\n\t}\n}\n\n// StructAlignof computes the memory alignment requirements of t when its\n// instance is a struct field. One is returned for a struct/union type with no\n// fields.\nfunc (m Model) StructAlignof(t Type) int {\n\tswitch x := t.(type) {\n\tcase *ArrayType:\n\t\tif x.Size.Value != nil {\n\t\t\treturn m.StructAlignof(x.Item)\n\t\t}\n\n\t\treturn m[Ptr].StructAlign\n\tcase *EnumType:\n\t\treturn m.StructAlignof(x.Enums[0].Operand.Type)\n\tcase *NamedType:\n\t\treturn m.StructAlignof(x.Type)\n\tcase *PointerType:\n\t\treturn m[Ptr].StructAlign\n\tcase *StructType:\n\t\tm.Layout(x)\n\t\tr := 1\n\t\tfor _, v := range x.Fields {\n\t\t\tt := v.Type\n\t\t\tif v.Bits < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif v.Bits > 0 {\n\t\t\t\tt = v.PackedType\n\t\t\t}\n\t\t\tif a := m.StructAlignof(t); a > r {\n\t\t\t\tr = a\n\t\t\t}\n\t\t}\n\t\treturn r\n\tcase *TaggedEnumType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.StructAlignof(u)\n\tcase *TaggedStructType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.StructAlignof(u)\n\tcase *TaggedUnionType:\n\t\tu := x.getType()\n\t\tif u == x {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\treturn m.StructAlignof(u)\n\tcase TypeKind:\n\t\treturn m[x].StructAlign\n\tcase *UnionType:\n\t\tm.Layout(x)\n\t\tr := 1\n\t\tfor _, v := range x.Fields {\n\t\t\tt := v.Type\n\t\t\tif v.Bits < 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif v.Bits > 0 {\n\t\t\t\tt = v.PackedType\n\t\t\t}\n\t\t\tif a := m.StructAlignof(t); a > r {\n\t\t\t\tr = a\n\t\t\t}\n\t\t}\n\t\treturn r\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\nfunc roundup(n, to int64) int64 {\n\tif r := n % to; r != 0 {\n\t\treturn n + to - r\n\t}\n\n\treturn n\n}\n\nfunc (m Model) defaultArgumentPromotion(op Operand) (r Operand) {\n\tu := op.Type\n\tfor {\n\t\tswitch x := u.(type) {\n\t\tcase *EnumType:\n\t\t\tu = x.Enums[0].Operand.Type\n\t\tcase *NamedType:\n\t\t\tu = x.Type\n\t\tcase\n\t\t\t*PointerType,\n\t\t\t*StructType,\n\t\t\t*TaggedStructType,\n\t\t\t*TaggedUnionType,\n\t\t\t*UnionType:\n\n\t\t\top.Type = x\n\t\t\treturn op\n\t\tcase *TaggedEnumType:\n\t\t\tu = x.getType()\n\t\tcase TypeKind:\n\t\t\top.Type = x\n\t\t\tswitch x {\n\t\t\tcase Float:\n\t\t\t\treturn op.ConvertTo(m, Double)\n\t\t\tcase\n\t\t\t\tDouble,\n\t\t\t\tLongDouble:\n\n\t\t\t\treturn op\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongLong,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort:\n\n\t\t\t\treturn op.integerPromotion(m)\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "v2/operand.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\nimport (\n\t\"fmt\"\n\t\"math\"\n\t\"math/bits\"\n\n\t\"github.com/cznic/ir\"\n)\n\nvar (\n\t// [0]6.3.1.1-1\n\t//\n\t// Every integer type has an integer conversion rank defined as\n\t// follows:\n\tintConvRank = [maxTypeKind]int{\n\t\tBool:      1,\n\t\tChar:      2,\n\t\tSChar:     2,\n\t\tUChar:     2,\n\t\tShort:     3,\n\t\tUShort:    3,\n\t\tInt:       4,\n\t\tUInt:      4,\n\t\tLong:      5,\n\t\tULong:     5,\n\t\tLongLong:  6,\n\t\tULongLong: 6,\n\t}\n\n\tisSigned = [maxTypeKind]bool{\n\t\tBool:     true,\n\t\tChar:     true,\n\t\tSChar:    true,\n\t\tShort:    true,\n\t\tInt:      true,\n\t\tLong:     true,\n\t\tLongLong: true,\n\t}\n\n\tisArithmeticType = [maxTypeKind]bool{\n\t\tBool:      true,\n\t\tChar:      true,\n\t\tEnum:      true,\n\t\tInt:       true,\n\t\tLong:      true,\n\t\tLongLong:  true,\n\t\tSChar:     true,\n\t\tShort:     true,\n\t\tUChar:     true,\n\t\tUInt:      true,\n\t\tULong:     true,\n\t\tULongLong: true,\n\t\tUShort:    true,\n\n\t\tFloat:      true,\n\t\tDouble:     true,\n\t\tLongDouble: true,\n\n\t\tFloatComplex:      true,\n\t\tDoubleComplex:     true,\n\t\tLongDoubleComplex: true,\n\t}\n)\n\n// Address represents the address of a variable.\ntype Address struct { //TODO-\n\tDeclarator *Declarator\n\tOffset     uintptr\n}\n\nfunc (a *Address) String() string {\n\treturn fmt.Sprintf(\"(%s+%d, %s)\", dict.S(a.Declarator.Name()), a.Offset, a.Declarator.Linkage)\n}\n\n// UsualArithmeticConversions performs transformations of operands of a binary\n// operation. The function panics if either of the operands is not an\n// artithmetic type.\n//\n// [0]6.3.1.8\n//\n// Many operators that expect operands of arithmetic type cause conversions and\n// yield result types in a similar way. The purpose is to determine a common\n// real type for the operands and result. For the specified operands, each\n// operand is converted, without change of type domain, to a type whose\n// corresponding real type is the common real type. Unless explicitly stated\n// otherwise, the common real type is also the corresponding real type of the\n// result, whose type domain is the type domain of the operands if they are the\n// same, and complex otherwise. This pattern is called the usual arithmetic\n// conversions:\nfunc UsualArithmeticConversions(m Model, a, b Operand) (Operand, Operand) {\n\tif !a.isArithmeticType() || !b.isArithmeticType() {\n\t\tpanic(fmt.Sprint(a, b))\n\t}\n\n\ta = a.normalize(m)\n\tb = b.normalize(m)\n\t// First, if the corresponding real type of either operand is long\n\t// double, the other operand is converted, without change of type\n\t// domain, to a type whose corresponding real type is long double.\n\tif a.Type.Kind() == LongDoubleComplex || b.Type.Kind() == LongDoubleComplex {\n\t\treturn a.ConvertTo(m, LongDoubleComplex), b.ConvertTo(m, LongDoubleComplex)\n\t}\n\n\tif a.Type.Kind() == LongDouble || b.Type.Kind() == LongDouble {\n\t\treturn a.ConvertTo(m, LongDouble), b.ConvertTo(m, LongDouble)\n\t}\n\n\t// Otherwise, if the corresponding real type of either operand is\n\t// double, the other operand is converted, without change of type\n\t// domain, to a type whose corresponding real type is double.\n\tif a.Type.Kind() == DoubleComplex || b.Type.Kind() == DoubleComplex {\n\t\treturn a.ConvertTo(m, DoubleComplex), b.ConvertTo(m, DoubleComplex)\n\t}\n\n\tif a.Type.Kind() == Double || b.Type.Kind() == Double {\n\t\treturn a.ConvertTo(m, Double), b.ConvertTo(m, Double)\n\t}\n\n\t// Otherwise, if the corresponding real type of either operand is\n\t// float, the other operand is converted, without change of type\n\t// domain, to a type whose corresponding real type is float.)\n\tif a.Type.Kind() == FloatComplex || b.Type.Kind() == FloatComplex {\n\t\treturn a.ConvertTo(m, FloatComplex), b.ConvertTo(m, FloatComplex)\n\t}\n\n\tif a.Type.Kind() == Float || b.Type.Kind() == Float {\n\t\treturn a.ConvertTo(m, Float), b.ConvertTo(m, Float)\n\t}\n\n\t// Otherwise, the integer promotions are performed on both operands.\n\t// Then the following rules are applied to the promoted operands:\n\tif !a.isIntegerType() || !b.isIntegerType() {\n\t\t//dbg(\"\", a)\n\t\t//dbg(\"\", b)\n\t\tpanic(\"TODO\")\n\t}\n\n\ta = a.integerPromotion(m)\n\tb = b.integerPromotion(m)\n\n\t// If both operands have the same type, then no further conversion is\n\t// needed.\n\tif a.Type.Equal(b.Type) {\n\t\treturn a, b\n\t}\n\n\t// Otherwise, if both operands have signed integer types or both have\n\t// unsigned integer types, the operand with the type of lesser integer\n\t// conversion rank is converted to the type of the operand with greater\n\t// rank.\n\tif a.isSigned() == b.isSigned() {\n\t\tt := a.Type\n\t\tif intConvRank[b.Type.Kind()] > intConvRank[a.Type.Kind()] {\n\t\t\tt = b.Type\n\t\t}\n\t\treturn a.ConvertTo(m, t), b.ConvertTo(m, t)\n\t}\n\n\t// Otherwise, if the operand that has unsigned integer type has rank\n\t// greater or equal to the rank of the type of the other operand, then\n\t// the operand with signed integer type is converted to the type of the\n\t// operand with unsigned integer type.\n\tswitch {\n\tcase a.isSigned(): // b is unsigned\n\t\tif intConvRank[b.Type.Kind()] >= intConvRank[a.Type.Kind()] {\n\t\t\treturn a.ConvertTo(m, b.Type), b\n\t\t}\n\tcase b.isSigned(): // a is unsigned\n\t\tif intConvRank[a.Type.Kind()] >= intConvRank[b.Type.Kind()] {\n\t\t\treturn a, b.ConvertTo(m, a.Type)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %v %v\", a, b))\n\t}\n\n\tvar signed Type\n\t// Otherwise, if the type of the operand with signed integer type can\n\t// represent all of the values of the type of the operand with unsigned\n\t// integer type, then the operand with unsigned integer type is\n\t// converted to the type of the operand with signed integer type.\n\tswitch {\n\tcase a.isSigned(): // b is unsigned\n\t\tsigned = a.Type\n\t\tif m.Sizeof(a.Type) > m.Sizeof(b.Type) {\n\t\t\treturn a, b.ConvertTo(m, a.Type)\n\t\t}\n\tcase b.isSigned(): // a is unsigned\n\t\tsigned = b.Type\n\t\tif m.Sizeof(b.Type) > m.Sizeof(a.Type) {\n\t\t\treturn a.ConvertTo(m, b.Type), b\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %v %v\", a, b))\n\t}\n\n\t// Otherwise, both operands are converted to the unsigned integer type\n\t// corresponding to the type of the operand with signed integer type.\n\tswitch signed.Kind() {\n\tcase Int:\n\t\tif a.IsEnumConst || b.IsEnumConst {\n\t\t\treturn a, b\n\t\t}\n\n\t\treturn a.ConvertTo(m, UInt), b.ConvertTo(m, UInt)\n\tcase Long:\n\t\treturn a.ConvertTo(m, ULong), b.ConvertTo(m, ULong)\n\tcase LongLong:\n\t\treturn a.ConvertTo(m, ULongLong), b.ConvertTo(m, ULongLong)\n\tdefault:\n\t\tpanic(signed)\n\t}\n}\n\n// Operand represents the type and optionally the value of an expression.\ntype Operand struct {\n\tType Type\n\tir.Value\n\tFieldProperties *FieldProperties\n\n\tIsEnumConst bool // Blocks int -> unsigned int promotions. See [0]6.4.4.3/2\n}\n\n// Bits return the width of a bit field operand or zero othewise\nfunc (o *Operand) Bits() int {\n\tif fp := o.FieldProperties; fp != nil {\n\t\treturn fp.Bits\n\t}\n\n\treturn 0\n}\n\nfunc newIntConst(ctx *context, n Node, v uint64, t ...TypeKind) (r Operand) {\n\tb := bits.Len64(v)\n\tfor _, t := range t {\n\t\tsign := 1\n\t\tif t.IsUnsigned() {\n\t\t\tsign = 0\n\t\t}\n\t\tif ctx.model[t].Size*8 >= b+sign {\n\t\t\treturn Operand{Type: t, Value: &ir.Int64Value{Value: int64(v)}}.normalize(ctx.model)\n\t\t}\n\t}\n\n\tlast := t[len(t)-1]\n\tif ctx.model[last].Size*8 == b {\n\t\treturn Operand{Type: last, Value: &ir.Int64Value{Value: int64(v)}}.normalize(ctx.model)\n\t}\n\n\tctx.err(n, \"invalid integer constant\")\n\treturn Operand{Type: Int}.normalize(ctx.model)\n}\n\nfunc (o Operand) String() string {\n\treturn fmt.Sprintf(\"(type %v, value %v, fieldProps %+v)\", o.Type, o.Value, o.FieldProperties)\n}\n\nfunc (o Operand) isArithmeticType() bool { return o.Type.IsArithmeticType() }\nfunc (o Operand) isIntegerType() bool    { return o.Type.IsIntegerType() }\nfunc (o Operand) isPointerType() bool    { return o.Type.IsPointerType() }\nfunc (o Operand) isScalarType() bool     { return o.Type.IsScalarType() } // [0]6.2.5-21\nfunc (o Operand) isSigned() bool         { return isSigned[o.Type.Kind()] }\n\nfunc (o Operand) add(ctx *context, p Operand) (r Operand) {\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif p.IsZero() {\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tif o.Value == nil || p.Value == nil {\n\t\to.Value = nil\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value + p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tcase *ir.Float64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float64Value{Value: x.Value + p.Value.(*ir.Float64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T %v %v\", x, o, p))\n\t}\n}\n\nfunc (o Operand) and(ctx *context, p Operand) (r Operand) {\n\tif !o.isIntegerType() || !p.isIntegerType() {\n\t\tpanic(fmt.Errorf(\"TODO %v & %v\", o.Type, p.Type))\n\t}\n\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif o.IsZero() || p.IsZero() {\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: 0}}.normalize(ctx.model)\n\t}\n\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value & p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\n// ConvertTo converts o to type t.\nfunc (o Operand) ConvertTo(m Model, t Type) (r Operand) {\n\tif o.Type.Equal(t) {\n\t\treturn o.normalize(m)\n\t}\n\n\tswitch x := t.(type) {\n\tcase\n\t\t*EnumType,\n\t\t*PointerType,\n\t\t*TaggedEnumType,\n\t\t*TaggedUnionType:\n\n\t\t// ok\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tBool,\n\t\t\tChar,\n\t\t\tDouble,\n\t\t\tDoubleComplex,\n\t\t\tFloat,\n\t\t\tFloatComplex,\n\t\t\tInt,\n\t\t\tLong,\n\t\t\tLongDouble,\n\t\t\tLongDoubleComplex,\n\t\t\tLongLong,\n\t\t\tSChar,\n\t\t\tShort,\n\t\t\tUChar,\n\t\t\tUInt,\n\t\t\tULong,\n\t\t\tULongLong,\n\t\t\tUShort:\n\n\t\t\t// ok\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tcase *NamedType:\n\t\treturn o.ConvertTo(m, x.Type)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n\n\tif o.Value == nil {\n\t\to.Type = t\n\t\treturn o.normalize(m)\n\t}\n\n\tif o.isIntegerType() {\n\t\tv := *o.Value.(*ir.Int64Value)\n\t\tif t.IsIntegerType() {\n\t\t\treturn Operand{Type: t, Value: &v}.normalize(m)\n\t\t}\n\n\t\tif t.IsPointerType() {\n\t\t\t// [0]6.3.2.3\n\t\t\tif o.IsZero() {\n\t\t\t\t// 3. An integer constant expression with the\n\t\t\t\t// value 0, or such an expression cast to type\n\t\t\t\t// void *, is called a null pointer constant.\n\t\t\t\t// If a null pointer constant is converted to a\n\t\t\t\t// pointer type, the resulting pointer, called\n\t\t\t\t// a null pointer, is guaranteed to compare\n\t\t\t\t// unequal to a pointer to any object or\n\t\t\t\t// function.\n\t\t\t\treturn Operand{Type: t, Value: Null}\n\t\t\t}\n\n\t\t\treturn Operand{Type: t, Value: &v}.normalize(m)\n\t\t}\n\n\t\tif t.Kind() == Union {\n\t\t\tif v.Value != 0 {\n\t\t\t\tpanic(\"TODO\")\n\t\t\t}\n\n\t\t\treturn Operand{Type: t}\n\t\t}\n\n\t\tswitch {\n\t\tcase o.Type.IsUnsigned():\n\t\t\tval := uint64(v.Value)\n\t\t\tswitch t.Kind() {\n\t\t\tcase Double, LongDouble:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float64Value{Value: float64(val)}}.normalize(m)\n\t\t\tcase DoubleComplex:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Complex128Value{Value: complex(float64(val), 0)}}.normalize(m)\n\t\t\tcase Float:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float32Value{Value: float32(val)}}.normalize(m)\n\t\t\tcase FloatComplex:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Complex64Value{Value: complex(float32(val), 0)}}.normalize(m)\n\t\t\tdefault:\n\t\t\t\tpanic(t)\n\t\t\t}\n\t\tdefault:\n\t\t\tval := v.Value\n\t\t\tswitch t.Kind() {\n\t\t\tcase Double, LongDouble:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float64Value{Value: float64(val)}}.normalize(m)\n\t\t\tcase DoubleComplex:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Complex128Value{Value: complex(float64(val), 0)}}.normalize(m)\n\t\t\tcase Float:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float32Value{Value: float32(val)}}.normalize(m)\n\t\t\tcase FloatComplex:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Complex64Value{Value: complex(float32(val), 0)}}.normalize(m)\n\t\t\tdefault:\n\t\t\t\tpanic(t)\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Type.Kind() == Double {\n\t\tv := o.Value.(*ir.Float64Value).Value\n\t\tif t.IsIntegerType() {\n\t\t\treturn Operand{Type: t, Value: &ir.Int64Value{Value: ConvertFloat64(v, t, m)}}.normalize(m)\n\t\t}\n\n\t\tswitch x := t.(type) {\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase Float:\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float32Value{Value: float32(o.Value.(*ir.Float64Value).Value)}}.normalize(m)\n\t\t\tcase LongDouble:\n\t\t\t\tv := *o.Value.(*ir.Float64Value)\n\t\t\t\treturn Operand{Type: t, Value: &v}.normalize(m)\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\t}\n\n\tif o.Type.Kind() == Float {\n\t\tv := o.Value.(*ir.Float32Value).Value\n\t\tif t.IsIntegerType() {\n\t\t\treturn Operand{Type: t, Value: &ir.Int64Value{Value: ConvertFloat64(float64(v), t, m)}}.normalize(m)\n\t\t}\n\n\t\tswitch x := t.(type) {\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tDouble,\n\t\t\t\tLongDouble:\n\n\t\t\t\treturn Operand{Type: t, Value: &ir.Float64Value{Value: float64(v)}}.normalize(m)\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\t}\n\n\tif o.isPointerType() && t.IsPointerType() {\n\t\to.Type = t\n\t\treturn o.normalize(m)\n\t}\n\n\tif o.isPointerType() && t.IsIntegerType() {\n\t\to.Type = t\n\t\tswitch x := o.Value.(type) {\n\t\tcase *ir.AddressValue:\n\t\t\tif x.NameID != 0 {\n\t\t\t\to.Value = nil\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\to.Value = &ir.Int64Value{Value: int64(x.Offset)}\n\t\tcase *ir.Int64Value:\n\t\t\t// nop\n\t\tdefault:\n\t\t\t//fmt.Printf(\"TODO405 %T %v -> %v\\n\", x, o, t) //TODO-\n\t\t\tpanic(fmt.Errorf(\"%T %v -> %v\", x, o, t))\n\t\t}\n\t\treturn o.normalize(m)\n\t}\n\n\tpanic(fmt.Errorf(\"%T(%v) -> %T(%v)\", o.Type, o, t, t))\n}\n\nfunc (o Operand) cpl(ctx *context) Operand {\n\tif o.isIntegerType() {\n\t\to = o.integerPromotion(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase nil:\n\t\treturn o\n\tcase *ir.Int64Value:\n\t\to.Value = &ir.Int64Value{Value: ^o.Value.(*ir.Int64Value).Value}\n\t\treturn o.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) div(ctx *context, n Node, p Operand) (r Operand) {\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif o.Value == nil || p.Value == nil {\n\t\to.Value = nil\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tif p.IsZero() {\n\t\t\tctx.err(n, \"division by zero\")\n\t\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t\t}\n\n\t\tswitch {\n\t\tcase o.Type.IsUnsigned():\n\t\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: int64(uint64(x.Value) / uint64(p.Value.(*ir.Int64Value).Value))}}.normalize(ctx.model)\n\t\tdefault:\n\t\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value / p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\t\t}\n\tcase *ir.Float32Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float32Value{Value: x.Value / p.Value.(*ir.Float32Value).Value}}.normalize(ctx.model)\n\tcase *ir.Float64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float64Value{Value: x.Value / p.Value.(*ir.Float64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) eq(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tif x.Value == p.Value.(*ir.Int64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value == p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\nfunc (o Operand) ge(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tswitch {\n\t\tcase o.isSigned():\n\t\t\tif x.Value >= p.Value.(*ir.Int64Value).Value {\n\t\t\t\tval = 1\n\t\t\t}\n\t\tdefault:\n\t\t\tif uint64(x.Value) >= uint64(p.Value.(*ir.Int64Value).Value) {\n\t\t\t\tval = 1\n\t\t\t}\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value >= p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\nfunc (o Operand) gt(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tswitch {\n\t\tcase o.isSigned():\n\t\t\tif x.Value > p.Value.(*ir.Int64Value).Value {\n\t\t\t\tval = 1\n\t\t\t}\n\t\tdefault:\n\t\t\tif uint64(x.Value) > uint64(p.Value.(*ir.Int64Value).Value) {\n\t\t\t\tval = 1\n\t\t\t}\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value > p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\n// integerPromotion computes the integer promotion of o.\n//\n// [0]6.3.1.1-2\n//\n// If an int can represent all values of the original type, the value is\n// converted to an int; otherwise, it is converted to an unsigned int. These\n// are called the integer promotions. All other types are unchanged by the\n// integer promotions.\nfunc (o Operand) integerPromotion(m Model) Operand {\n\tt := o.Type\n\tfor {\n\t\tswitch x := t.(type) {\n\t\tcase *EnumType:\n\t\t\tt = x.Enums[0].Operand.Type\n\t\tcase *NamedType:\n\t\t\tt = x.Type\n\t\tcase *TaggedEnumType:\n\t\t\tt = x.getType().(*EnumType).Enums[0].Operand.Type\n\t\tcase TypeKind:\n\t\t\t// github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c\n\t\t\t//\n\t\t\t// This test checks promotion of bitfields.  Bitfields\n\t\t\t// should be promoted very much like chars and shorts:\n\t\t\t//\n\t\t\t// Bitfields (signed or unsigned) should be promoted to\n\t\t\t// signed int if their value will fit in a signed int,\n\t\t\t// otherwise to an unsigned int if their value will fit\n\t\t\t// in an unsigned int, otherwise we don't promote them\n\t\t\t// (ANSI/ISO does not specify the behavior of bitfields\n\t\t\t// larger than an unsigned int).\n\t\t\tif x.IsIntegerType() && o.Bits() != 0 {\n\t\t\t\tbits := m[Int].Size * 8\n\t\t\t\tswitch {\n\t\t\t\tcase x.IsUnsigned():\n\t\t\t\t\tif o.Bits() < bits {\n\t\t\t\t\t\treturn o.ConvertTo(m, Int)\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tif o.Bits() < bits-1 {\n\t\t\t\t\t\treturn o.ConvertTo(m, Int)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tDouble,\n\t\t\t\tFloat,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDouble,\n\t\t\t\tLongLong,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong:\n\n\t\t\t\treturn o\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUShort:\n\n\t\t\t\treturn o.ConvertTo(m, Int)\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\t}\n}\n\n// IsNonZero returns true when the value of o is known to be non-zero.\nfunc (o Operand) IsNonZero() bool {\n\tswitch x := o.Value.(type) {\n\tcase nil:\n\t\treturn false\n\tcase *ir.Float32Value:\n\t\treturn x.Value != 0\n\tcase *ir.Float64Value:\n\t\treturn x.Value != 0\n\tcase *ir.Int64Value:\n\t\treturn x.Value != 0\n\tcase *ir.StringValue:\n\t\treturn true\n\tcase *ir.AddressValue:\n\t\treturn x != Null\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\n// IsZero returns true when the value of o is known to be zero.\nfunc (o Operand) IsZero() bool {\n\tswitch x := o.Value.(type) {\n\tcase nil:\n\t\treturn false\n\tcase *ir.Complex128Value:\n\t\treturn x.Value == 0\n\tcase *ir.Float32Value:\n\t\treturn x.Value == 0\n\tcase *ir.Float64Value:\n\t\treturn x.Value == 0\n\tcase *ir.Int64Value:\n\t\treturn x.Value == 0\n\tcase\n\t\t*ir.StringValue,\n\t\t*ir.WideStringValue:\n\n\t\treturn false\n\tcase *ir.AddressValue:\n\t\treturn x == Null\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) isNullPtrConst() bool {\n\treturn o.isIntegerType() && o.IsZero() || o.Value == Null\n}\n\nfunc (o Operand) le(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tswitch {\n\t\tcase o.isSigned():\n\t\t\tif x.Value <= p.Value.(*ir.Int64Value).Value {\n\t\t\t\tval = 1\n\t\t\t}\n\t\tdefault:\n\t\t\tif uint64(x.Value) <= uint64(p.Value.(*ir.Int64Value).Value) {\n\t\t\t\tval = 1\n\t\t\t}\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value <= p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\nfunc (o Operand) lsh(ctx *context, p Operand) (r Operand) { // [0]6.5.7\n\t// 2. Each of the operands shall have integer type.\n\tif !o.isIntegerType() || !p.isIntegerType() {\n\t\tpanic(\"TODO\")\n\t}\n\n\t// 3. The integer promotions are performed on each of the operands. The\n\t// type of the result is that of the promoted left operand. If the\n\t// value of the right operand is negative or is greater than or equal\n\t// to the width of the promoted left operand, the behavior is\n\t// undefined.\n\to = o.integerPromotion(ctx.model)\n\tp = p.integerPromotion(ctx.model)\n\tif o.IsZero() {\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tm := uint64(32)\n\tif ctx.model.Sizeof(o.Type) > 4 {\n\t\tm = 64\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value << (uint64(p.Value.(*ir.Int64Value).Value) % m)}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) lt(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tswitch {\n\t\tcase o.isSigned():\n\t\t\tif x.Value < p.Value.(*ir.Int64Value).Value {\n\t\t\t\tval = 1\n\t\t\t}\n\t\tdefault:\n\t\t\tif uint64(x.Value) < uint64(p.Value.(*ir.Int64Value).Value) {\n\t\t\t\tval = 1\n\t\t\t}\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value < p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\nfunc (o Operand) mod(ctx *context, n Node, p Operand) (r Operand) {\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif p.IsZero() {\n\t\tctx.err(n, \"division by zero\")\n\t\treturn p.normalize(ctx.model)\n\t}\n\n\tif o.IsZero() { // 0 % x == 0\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tif y, ok := p.Value.(*ir.Int64Value); ok && (y.Value == 1 || y.Value == -1) {\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: 0}}.normalize(ctx.model) //  y % {1,-1} == 0\n\t}\n\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value % p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) mul(ctx *context, p Operand) (r Operand) {\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif o.IsZero() || p.IsZero() {\n\t\tswitch x := UnderlyingType(o.Type).(type) {\n\t\tcase TypeKind:\n\t\t\tif x.IsIntegerType() {\n\t\t\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: 0}}.normalize(ctx.model)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t\t}\n\t}\n\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value * p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tcase *ir.Float32Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float32Value{Value: x.Value * p.Value.(*ir.Float32Value).Value}}\n\tcase *ir.Float64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float64Value{Value: x.Value * p.Value.(*ir.Float64Value).Value}}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) ne(ctx *context, p Operand) (r Operand) {\n\tr = Operand{Type: Int}\n\tif o.isArithmeticType() && p.isArithmeticType() {\n\t\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn r.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tvar val int64\n\t\tif x.Value != p.Value.(*ir.Int64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float32Value:\n\t\tvar val int64\n\t\tif x.Value != p.Value.(*ir.Float32Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tcase *ir.Float64Value:\n\t\tvar val int64\n\t\tif x.Value != p.Value.(*ir.Float64Value).Value {\n\t\t\tval = 1\n\t\t}\n\t\tr.Value = &ir.Int64Value{Value: val}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn r.normalize(ctx.model)\n}\n\n// ConvertFloat64 converts v to t, which must be an integer type.\nfunc ConvertFloat64(v float64, t Type, m Model) int64 {\n\tif !t.IsIntegerType() {\n\t\tpanic(fmt.Errorf(\"ConvertFloat64: %T\", t))\n\t}\n\n\tswitch sz := m.Sizeof(t); {\n\tcase t.IsUnsigned():\n\t\tswitch sz {\n\t\tcase 1:\n\t\t\tif v > math.Nextafter(math.MaxUint8, 0) {\n\t\t\t\treturn math.MaxUint8\n\t\t\t}\n\n\t\t\tif v <= 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\tcase 2:\n\t\t\tif v > math.Nextafter(math.MaxUint16, 0) {\n\t\t\t\treturn math.MaxUint16\n\t\t\t}\n\n\t\t\tif v <= 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\tcase 4:\n\t\t\tif v > math.Nextafter(math.MaxUint32, 0) {\n\t\t\t\treturn math.MaxUint32\n\t\t\t}\n\n\t\t\tif v <= 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\tcase 8:\n\t\t\tif v > math.Nextafter(math.MaxUint64, 0) {\n\t\t\t\treturn -1 // int64(math,MaxUint64)\n\t\t\t}\n\n\t\t\tif v <= 0 {\n\t\t\t\treturn 0\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(sz)\n\t\t}\n\tdefault:\n\t\tswitch sz {\n\t\tcase 1:\n\t\t\tif v > math.Nextafter(math.MaxInt8, 0) {\n\t\t\t\treturn math.MaxInt8\n\t\t\t}\n\n\t\t\tif v < math.Nextafter(math.MinInt8, 0) {\n\t\t\t\treturn math.MinInt8\n\t\t\t}\n\t\tcase 2:\n\t\t\tif v > math.Nextafter(math.MaxInt16, 0) {\n\t\t\t\treturn math.MaxInt16\n\t\t\t}\n\n\t\t\tif v < math.Nextafter(math.MinInt16, 0) {\n\t\t\t\treturn math.MinInt16\n\t\t\t}\n\t\tcase 4:\n\t\t\tif v > math.Nextafter(math.MaxInt32, 0) {\n\t\t\t\treturn math.MaxInt32\n\t\t\t}\n\n\t\t\tif v < math.Nextafter(math.MinInt32, 0) {\n\t\t\t\treturn math.MinInt32\n\t\t\t}\n\t\tcase 8:\n\t\t\tif v > math.Nextafter(math.MaxInt64, 0) {\n\t\t\t\treturn math.MaxInt64\n\t\t\t}\n\n\t\t\tif v < math.Nextafter(math.MinInt64, 0) {\n\t\t\t\treturn math.MinInt64\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(sz)\n\t\t}\n\t}\n\treturn int64(v)\n}\n\n// ConvertInt64 converts n to t, which must be an integer or enum type, doing\n// masking and/or sign extending as appropriate.\nfunc ConvertInt64(n int64, t Type, m Model) int64 {\n\tswitch x := UnderlyingType(t).(type) {\n\tcase *EnumType:\n\t\tt = x.Enums[0].Operand.Type\n\t}\n\tsigned := !t.IsUnsigned()\n\tswitch sz := m[UnderlyingType(t).Kind()].Size; sz {\n\tcase 1:\n\t\tswitch {\n\t\tcase signed:\n\t\t\tswitch {\n\t\t\tcase int8(n) < 0:\n\t\t\t\treturn n | ^math.MaxUint8\n\t\t\tdefault:\n\t\t\t\treturn n & math.MaxUint8\n\t\t\t}\n\t\tdefault:\n\t\t\treturn n & math.MaxUint8\n\t\t}\n\tcase 2:\n\t\tswitch {\n\t\tcase signed:\n\t\t\tswitch {\n\t\t\tcase int16(n) < 0:\n\t\t\t\treturn n | ^math.MaxUint16\n\t\t\tdefault:\n\t\t\t\treturn n & math.MaxUint16\n\t\t\t}\n\t\tdefault:\n\t\t\treturn n & math.MaxUint16\n\t\t}\n\tcase 4:\n\t\tswitch {\n\t\tcase signed:\n\t\t\tswitch {\n\t\t\tcase int32(n) < 0:\n\t\t\t\treturn n | ^math.MaxUint32\n\t\t\tdefault:\n\t\t\t\treturn n & math.MaxUint32\n\t\t\t}\n\t\tdefault:\n\t\t\treturn n & math.MaxUint32\n\t\t}\n\tcase 8:\n\t\treturn n\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %v %T %v\", sz, t, t))\n\t}\n}\nfunc (o Operand) normalize(m Model) (r Operand) {\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tif v := ConvertInt64(x.Value, o.Type, m); v != x.Value {\n\t\t\tn := *x\n\t\t\tn.Value = v\n\t\t\tx = &n\n\t\t\to.Value = x\n\t\t}\n\tcase nil:\n\t\t// nop\n\tcase\n\t\t*ir.AddressValue,\n\t\t*ir.Complex128Value,\n\t\t*ir.Complex64Value,\n\t\t*ir.Float32Value,\n\t\t*ir.Float64Value,\n\t\t*ir.StringValue,\n\t\t*ir.WideStringValue:\n\n\t\t// nop\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n\treturn o\n}\n\nfunc (o Operand) or(ctx *context, p Operand) (r Operand) {\n\tif !o.isIntegerType() || !p.isIntegerType() {\n\t\tpanic(\"TODO\")\n\t}\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tr.Type = o.Type\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value | p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) rsh(ctx *context, p Operand) (r Operand) { // [0]6.5.7\n\t// 2. Each of the operands shall have integer type.\n\tif !o.isIntegerType() || !p.isIntegerType() {\n\t\tpanic(\"TODO\")\n\t}\n\n\t// 3. The integer promotions are performed on each of the operands. The\n\t// type of the result is that of the promoted left operand. If the\n\t// value of the right operand is negative or is greater than or equal\n\t// to the width of the promoted left operand, the behavior is\n\t// undefined.\n\to = o.integerPromotion(ctx.model)\n\tp = p.integerPromotion(ctx.model)\n\tr.Type = o.Type\n\tm := uint64(32)\n\tif ctx.model.Sizeof(o.Type) > 4 {\n\t\tm = 64\n\t}\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\tswitch {\n\t\tcase o.isSigned():\n\t\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value >> (uint64(p.Value.(*ir.Int64Value).Value) % m)}}.normalize(ctx.model)\n\t\tdefault:\n\t\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: int64(uint64(x.Value) >> (uint64(p.Value.(*ir.Int64Value).Value) % m))}}.normalize(ctx.model)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) sub(ctx *context, p Operand) (r Operand) {\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif p.IsZero() {\n\t\treturn o.normalize(ctx.model)\n\t}\n\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}.normalize(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value - p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tcase *ir.Float32Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float32Value{Value: x.Value - p.Value.(*ir.Float32Value).Value}}.normalize(ctx.model)\n\tcase *ir.Float64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float64Value{Value: x.Value - p.Value.(*ir.Float64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) unaryMinus(ctx *context) Operand {\n\tif o.isIntegerType() {\n\t\to = o.integerPromotion(ctx.model)\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase nil:\n\t\treturn o\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: -x.Value}}.normalize(ctx.model)\n\tcase *ir.Float32Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float32Value{Value: -x.Value}}\n\tcase *ir.Float64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Float64Value{Value: -x.Value}}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n\nfunc (o Operand) xor(ctx *context, p Operand) (r Operand) {\n\tif !o.isIntegerType() || !p.isIntegerType() {\n\t\tpanic(\"TODO\")\n\t}\n\to, p = UsualArithmeticConversions(ctx.model, o, p)\n\tif o.Value == nil || p.Value == nil {\n\t\treturn Operand{Type: o.Type}\n\t}\n\n\tswitch x := o.Value.(type) {\n\tcase *ir.Int64Value:\n\t\treturn Operand{Type: o.Type, Value: &ir.Int64Value{Value: x.Value ^ p.Value.(*ir.Int64Value).Value}}.normalize(ctx.model)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"TODO %T\", x))\n\t}\n}\n"
  },
  {
    "path": "v2/parser.go",
    "content": "// Code generated by goyacc - DO NOT EDIT.\n\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.5-6.10. Substantial portions of expression AST size\n// optimizations are from [1], license of which follows.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n// [1]: https://github.com/rsc/c2go/blob/fc8cbfad5a47373828c81c7a56cccab8b221d310/cc/cc.y\n\n// ----------------------------------------------------------------------------\n\n// Copyright 2013 The Go Authors.  All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// This grammar is derived from the C grammar in the 'ansitize'\n// program, which carried this notice:\n//\n// Copyright (c) 2006 Russ Cox,\n// \tMassachusetts Institute of Technology\n//\n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall\n// be included in all copies or substantial portions of the\n// Software.\n//\n// The software is provided \"as is\", without warranty of any\n// kind, express or implied, including but not limited to the\n// warranties of merchantability, fitness for a particular\n// purpose and noninfringement.  In no event shall the authors\n// or copyright holders be liable for any claim, damages or\n// other liability, whether in an action of contract, tort or\n// otherwise, arising from, out of or in connection with the\n// software or the use or other dealings in the software.\n\npackage cc\n\nimport __yyfmt__ \"fmt\"\nimport __sync__ \"sync\"\n\nimport (\n\t\"github.com/cznic/xc\"\n)\n\nvar yyPool = __sync__.Pool{New: func() interface{} { s := make([]yySymType, 200); return &s }}\n\ntype yySymType struct {\n\tyys   int\n\tToken xc.Token\n\tnode  Node\n}\n\ntype yyXError struct {\n\tstate, xsym int\n}\n\nconst (\n\tyyDefault           = 57432\n\tyyEofCode           = 57344\n\tADDASSIGN           = 57346\n\tALIGNOF             = 57347\n\tANDAND              = 57348\n\tANDASSIGN           = 57349\n\tARROW               = 57350\n\tAUTO                = 57351\n\tBOOL                = 57352\n\tBREAK               = 57353\n\tCASE                = 57354\n\tCAST                = 57355\n\tCHAR                = 57356\n\tCHARCONST           = 57357\n\tCOMPLEX             = 57358\n\tCONST               = 57359\n\tCONSTANT_EXPRESSION = 1048576\n\tCONTINUE            = 57360\n\tDDD                 = 57361\n\tDEC                 = 57362\n\tDEFAULT             = 57363\n\tDIRECTIVE           = 57364\n\tDIVASSIGN           = 57365\n\tDO                  = 57366\n\tDOUBLE              = 57367\n\tELSE                = 57368\n\tENUM                = 57369\n\tEQ                  = 57370\n\tEXTERN              = 57371\n\tFLOAT               = 57372\n\tFLOATCONST          = 57373\n\tFOR                 = 57374\n\tGEQ                 = 57375\n\tGOTO                = 57376\n\tIDENTIFIER          = 57377\n\tIF                  = 57378\n\tINC                 = 57379\n\tINLINE              = 57380\n\tINT                 = 57381\n\tINTCONST            = 57382\n\tLEQ                 = 57383\n\tLONG                = 57384\n\tLONGCHARCONST       = 57385\n\tLONGSTRINGLITERAL   = 57386\n\tLSH                 = 57387\n\tLSHASSIGN           = 57388\n\tMODASSIGN           = 57389\n\tMULASSIGN           = 57390\n\tNEQ                 = 57391\n\tNOELSE              = 57392\n\tNON_REPL            = 57393\n\tNOSEMI              = 57394\n\tORASSIGN            = 57395\n\tOROR                = 57396\n\tPPNUMBER            = 57397\n\tPPPASTE             = 57398\n\tREGISTER            = 57399\n\tRESTRICT            = 57400\n\tRETURN              = 57401\n\tRSH                 = 57402\n\tRSHASSIGN           = 57403\n\tSHORT               = 57404\n\tSIGNED              = 57405\n\tSIZEOF              = 57406\n\tSTATIC              = 57407\n\tSTRINGLITERAL       = 57408\n\tSTRUCT              = 57409\n\tSUBASSIGN           = 57410\n\tSWITCH              = 57411\n\tTRANSLATION_UNIT    = 1048577\n\tTYPEDEF             = 57412\n\tTYPEDEF_NAME        = 57413\n\tTYPEOF              = 57414\n\tUNARY               = 57415\n\tUNION               = 57416\n\tUNSIGNED            = 57417\n\tVOID                = 57418\n\tVOLATILE            = 57419\n\tWHILE               = 57420\n\tXORASSIGN           = 57421\n\tyyErrCode           = 57345\n\n\tyyMaxDepth = 200\n\tyyTabOfs   = -247\n)\n\nvar (\n\tyyPrec = map[int]int{\n\t\tNOSEMI:    0,\n\t\t';':       1,\n\t\tNOELSE:    2,\n\t\tELSE:      3,\n\t\t'=':       4,\n\t\tADDASSIGN: 4,\n\t\tANDASSIGN: 4,\n\t\tDIVASSIGN: 4,\n\t\tLSHASSIGN: 4,\n\t\tMODASSIGN: 4,\n\t\tMULASSIGN: 4,\n\t\tORASSIGN:  4,\n\t\tRSHASSIGN: 4,\n\t\tSUBASSIGN: 4,\n\t\tXORASSIGN: 4,\n\t\t':':       5,\n\t\t'?':       5,\n\t\tOROR:      6,\n\t\tANDAND:    7,\n\t\t'|':       8,\n\t\t'^':       9,\n\t\t'&':       10,\n\t\tEQ:        11,\n\t\tNEQ:       11,\n\t\t'<':       12,\n\t\t'>':       12,\n\t\tGEQ:       12,\n\t\tLEQ:       12,\n\t\tLSH:       13,\n\t\tRSH:       13,\n\t\t'+':       14,\n\t\t'-':       14,\n\t\t'%':       15,\n\t\t'*':       15,\n\t\t'/':       15,\n\t\tCAST:      16,\n\t\t'!':       17,\n\t\t'~':       17,\n\t\tALIGNOF:   17,\n\t\tSIZEOF:    17,\n\t\tUNARY:     17,\n\t\t'(':       18,\n\t\t'.':       18,\n\t\t'[':       18,\n\t\tARROW:     18,\n\t\tDEC:       18,\n\t\tINC:       18,\n\t}\n\n\tyyFollow = [][]int{\n\t\t{1048576, 57490, 1048577}, // state 0\n\t\t{57344},                   // state 1\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57442, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                                                                // state 2\n\t\t{40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57443, 57446, 57448, 57369, 57371, 57456, 57465, 57466, 57372, 57468, 57469, 57377, 57380, 57381, 57384, 57485, 57486, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 3\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57443, 57446, 57448, 57369, 57371, 57456, 57465, 57372, 57468, 57469, 57377, 57380, 57381, 57384, 57485, 57486, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 4\n\t\t{40, 42, 59, 57448, 57377, 57473, 57474, 57475, 57485, 57486}, // state 5\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57446, 57447, 57369, 57371, 57456, 57372, 57469, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 6\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57446, 57447, 57369, 57371, 57456, 57372, 57469, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 7\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57446, 57447, 57369, 57371, 57456, 57372, 57469, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 8\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57446, 57447, 57369, 57371, 57456, 57372, 57469, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 9\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 10\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 11\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 12\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 13\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 14\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 15\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 16\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 17\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 18\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 19\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 20\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 21\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 22\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 23\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 24\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 25\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 26\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 27\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                            // state 28\n\t\t{40},                // state 29\n\t\t{123, 57377, 57472}, // state 30\n\t\t{123, 57377},        // state 31\n\t\t{123, 57377},        // state 32\n\t\t{123, 57377, 57472}, // state 33\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 58, 59, 91, 93, 126, 57347, 57351, 57352, 57356, 57357, 57358, 57359, 57362, 57367, 57369, 57371, 57372, 57373, 57377, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57404, 57405, 57406, 57407, 57408, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 34\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 58, 59, 91, 93, 126, 57347, 57351, 57352, 57356, 57357, 57358, 57359, 57362, 57367, 57369, 57371, 57372, 57373, 57377, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57404, 57405, 57406, 57407, 57408, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 35\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 58, 59, 91, 93, 126, 57347, 57351, 57352, 57356, 57357, 57358, 57359, 57362, 57367, 57369, 57371, 57372, 57373, 57377, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57404, 57405, 57406, 57407, 57408, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 36\n\t\t{40, 41, 42, 44, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                    // state 37\n\t\t{40, 57455, 57377}, // state 38\n\t\t{40, 41, 42, 44, 91, 57359, 57377, 57400, 57500, 57501, 57502, 57419}, // state 39\n\t\t{40, 57377}, // state 40\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                             // state 41\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                             // state 42\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                             // state 43\n\t\t{57431, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                       // state 44\n\t\t{123, 57351, 57352, 57356, 57358, 57359, 57367, 57443, 57444, 57445, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 45\n\t\t{40, 42, 59, 57448, 57377, 57473, 57474, 57475, 57485, 57486}, // state 46\n\t\t{57423, 123, 57467}, // state 47\n\t\t{123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 48\n\t\t{123, 57351, 57352, 57356, 57358, 57359, 57367, 57443, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 49\n\t\t{123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                // state 50\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                               // state 51\n\t\t{123, 57441}, // state 52\n\t\t{57429, 33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},                                                                                                                                                    // state 53\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                                                                                                                                                                                                                                                          // state 54\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57437, 57438, 57439, 57354, 57356, 57357, 57358, 57359, 57360, 57441, 57362, 57363, 57366, 57367, 57443, 57446, 57369, 57371, 57456, 57460, 57461, 57462, 57464, 57372, 57373, 57374, 57469, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57478, 57479, 57384, 57385, 57386, 57480, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57487, 57491, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419, 57420}, // state 55\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 56\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 57\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 58\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 59\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 60\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 61\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57352, 57356, 57357, 57358, 57359, 57441, 57362, 57367, 57369, 57456, 57460, 57461, 57372, 57373, 57377, 57379, 57381, 57382, 57384, 57385, 57386, 57400, 57404, 57405, 57406, 57408, 57409, 57488, 57497, 57498, 57413, 57414, 57499, 57500, 57503, 57416, 57417, 57418, 57419}, // state 62\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 63\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 64\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 65\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 66\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 67\n\t\t{37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},             // state 68\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 69\n\t\t{37, 38, 40, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                     // state 70\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 71\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 72\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 73\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 74\n\t\t{41, 44, 59}, // state 75\n\t\t{40, 42, 58, 59, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                                                                                                      // state 76\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 77\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 78\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 79\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 80\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 81\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 82\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57442, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 83\n\t\t{58},  // state 84\n\t\t{125}, // state 85\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},                                                                                                                                             // state 86\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57437, 57354, 57356, 57357, 57358, 57359, 57360, 57441, 57362, 57363, 57366, 57367, 57443, 57446, 57369, 57371, 57456, 57460, 57461, 57462, 57464, 57372, 57373, 57374, 57469, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57478, 57479, 57384, 57385, 57386, 57480, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57487, 57491, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419, 57420}, // state 87\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},                                                                                                                                             // state 88\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},                                                                                                                                             // state 89\n\t\t{59}, // state 90\n\t\t{40}, // state 91\n\t\t{40}, // state 92\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420}, // state 93\n\t\t{40},    // state 94\n\t\t{40},    // state 95\n\t\t{59},    // state 96\n\t\t{59},    // state 97\n\t\t{57377}, // state 98\n\t\t{33, 38, 40, 42, 43, 45, 59, 126, 57347, 57357, 57362, 57460, 57461, 57462, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                              // state 99\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 100\n\t\t{59}, // state 101\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 102\n\t\t{59}, // state 103\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 104\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 105\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 106\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 107\n\t\t{41, 44}, // state 108\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                                             // state 109\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420}, // state 110\n\t\t{58}, // state 111\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 112\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 113\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 114\n\t\t{37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                                        // state 115\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 116\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 117\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 118\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 119\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 120\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 121\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 122\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 123\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 124\n\t\t{57377}, // state 125\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 126\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 127\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 128\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 129\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 130\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 131\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 132\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 133\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 134\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 135\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 136\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 137\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 138\n\t\t{33, 38, 40, 41, 42, 43, 45, 126, 57347, 57435, 57436, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 139\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 140\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 141\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                   // state 142\n\t\t{57377}, // state 143\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 144\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 145\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 146\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 147\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                         // state 148\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                         // state 149\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 150\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 151\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 152\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 153\n\t\t{44, 93}, // state 154\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 155\n\t\t{44, 58}, // state 156\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                // state 157\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 158\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 159\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 160\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 161\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 162\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 163\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 164\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 165\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 166\n\t\t{37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 60, 61, 62, 63, 91, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                         // state 167\n\t\t{41, 44}, // state 168\n\t\t{41},     // state 169\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 170\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                                                                                                                                                 // state 171\n\t\t{37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 60, 61, 62, 63, 91, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                                          // state 172\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 173\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 174\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 175\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 176\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 177\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 178\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 179\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 180\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 181\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 182\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 183\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 184\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 185\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 186\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 187\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 188\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 189\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 190\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 191\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 192\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                  // state 193\n\t\t{33, 38, 40, 42, 43, 45, 59, 126, 57347, 57351, 57352, 57356, 57357, 57358, 57359, 57362, 57367, 57443, 57446, 57369, 57371, 57456, 57460, 57461, 57462, 57372, 57373, 57469, 57377, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57404, 57405, 57406, 57407, 57408, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 194\n\t\t{33, 38, 40, 42, 43, 45, 59, 126, 57347, 57357, 57362, 57460, 57461, 57462, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                                                                                                                                               // state 195\n\t\t{59}, // state 196\n\t\t{33, 38, 40, 42, 43, 45, 59, 126, 57347, 57357, 57362, 57460, 57461, 57462, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 197\n\t\t{59}, // state 198\n\t\t{33, 38, 40, 41, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57462, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 199\n\t\t{41}, // state 200\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 201\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 202\n\t\t{59}, // state 203\n\t\t{33, 38, 40, 41, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57462, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 204\n\t\t{41}, // state 205\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 206\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 207\n\t\t{57420}, // state 208\n\t\t{40},    // state 209\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 210\n\t\t{41, 44}, // state 211\n\t\t{59},     // state 212\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 213\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 214\n\t\t{41, 44}, // state 215\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 216\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 217\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57461, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 218\n\t\t{41, 44}, // state 219\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                                          // state 220\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},            // state 221\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                                          // state 222\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},            // state 223\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},            // state 224\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},                   // state 225\n\t\t{57344, 33, 38, 40, 41, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 226\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                                          // state 227\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420},            // state 228\n\t\t{57344, 37, 38, 40, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                                           // state 229\n\t\t{58}, // state 230\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 231\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 232\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 126, 57347, 57353, 57354, 57357, 57360, 57441, 57362, 57363, 57366, 57460, 57461, 57462, 57464, 57373, 57374, 57376, 57377, 57378, 57379, 57382, 57478, 57479, 57385, 57386, 57480, 57401, 57406, 57408, 57411, 57487, 57491, 57413, 57420},                                                                                                               // state 233\n\t\t{33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57368, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 234\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                            // state 235\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                            // state 236\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                            // state 237\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                                                                            // state 238\n\t\t{41},     // state 239\n\t\t{41, 44}, // state 240\n\t\t{41},     // state 241\n\t\t{40, 41, 42, 58, 59, 91, 57352, 57356, 57358, 57359, 57367, 57369, 57456, 57372, 57377, 57381, 57384, 57400, 57404, 57405, 57409, 57488, 57489, 57497, 57498, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 242\n\t\t{40, 41, 42, 58, 59, 91, 57352, 57356, 57358, 57359, 57367, 57369, 57456, 57372, 57377, 57381, 57384, 57400, 57404, 57405, 57409, 57488, 57489, 57497, 57498, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 243\n\t\t{40, 41, 42, 91, 57433, 57434, 57485, 57486}, // state 244\n\t\t{40, 41, 44, 91, 57377},                      // state 245\n\t\t{41},                                         // state 246\n\t\t{40, 91, 57453, 57454},                       // state 247\n\t\t{41, 44},                                     // state 248\n\t\t{40, 41, 44, 91},                             // state 249\n\t\t{40, 41, 42, 91, 57351, 57433, 57352, 57356, 57358, 57359, 57367, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57481, 57482, 57483, 57484, 57485, 57486, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 250\n\t\t{91}, // state 251\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57359, 57362, 57460, 57463, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57500, 57501, 57419},                                               // state 252\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                // state 253\n\t\t{37, 38, 40, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 254\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 91, 93, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57419},                                                               // state 255\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57359, 57362, 57460, 57463, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57500, 57419},                                                      // state 256\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57408, 57500, 57501, 57502, 57419},                                                                 // state 257\n\t\t{93},             // state 258\n\t\t{40, 41, 44, 91}, // state 259\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 91, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57408, 57500, 57419},                                                                   // state 260\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                    // state 261\n\t\t{37, 38, 40, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 262\n\t\t{40, 41, 44, 91}, // state 263\n\t\t{33, 38, 40, 41, 42, 43, 44, 45, 91, 93, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57419}, // state 264\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                      // state 265\n\t\t{93},             // state 266\n\t\t{40, 41, 44, 91}, // state 267\n\t\t{37, 38, 40, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 268\n\t\t{40, 41, 44, 91}, // state 269\n\t\t{40, 41, 44, 91}, // state 270\n\t\t{41, 44},         // state 271\n\t\t{41},             // state 272\n\t\t{41, 44},         // state 273\n\t\t{40, 41, 42, 44, 91, 57433, 57434, 57448, 57377, 57485, 57486}, // state 274\n\t\t{41},                                 // state 275\n\t\t{41},                                 // state 276\n\t\t{40, 41, 44, 91},                     // state 277\n\t\t{40, 41, 44, 91},                     // state 278\n\t\t{40, 91, 57453, 57454, 57455, 57377}, // state 279\n\t\t{41, 44},                             // state 280\n\t\t{41, 44},                             // state 281\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                       // state 282\n\t\t{40, 41, 42, 91, 57351, 57433, 57352, 57356, 57358, 57359, 57367, 57446, 57448, 57369, 57371, 57456, 57372, 57469, 57377, 57380, 57381, 57384, 57481, 57482, 57483, 57484, 57485, 57486, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 283\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                       // state 284\n\t\t{41}, // state 285\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 286\n\t\t{57427, 57428, 41, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},         // state 287\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57500, 57501, 57502, 57419},                                                  // state 288\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57408, 57500, 57501, 57502, 57419},                                                             // state 289\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57359, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57400, 57406, 57407, 57408, 57500, 57419},                                                                // state 290\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57362, 57460, 57463, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                     // state 291\n\t\t{33, 38, 40, 42, 43, 45, 93, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                            // state 292\n\t\t{93}, // state 293\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},     // state 294\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},     // state 295\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                    // state 296\n\t\t{37, 38, 40, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 297\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},     // state 298\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                    // state 299\n\t\t{37, 38, 40, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 93, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 300\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},     // state 301\n\t\t{41, 57377, 57470, 57471}, // state 302\n\t\t{57351, 57352, 57356, 57358, 57359, 57367, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57481, 57482, 57483, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 303\n\t\t{41}, // state 304\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 305\n\t\t{41},     // state 306\n\t\t{41, 44}, // state 307\n\t\t{41, 44}, // state 308\n\t\t{57377},  // state 309\n\t\t{41, 44}, // state 310\n\t\t{40, 41, 44, 58, 59, 61, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                      // state 311\n\t\t{57351, 57352, 57356, 57358, 57359, 57361, 57367, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57481, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 312\n\t\t{41},     // state 313\n\t\t{41, 44}, // state 314\n\t\t{41, 57351, 57352, 57356, 57358, 57359, 57367, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57481, 57482, 57483, 57484, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 315\n\t\t{41},                            // state 316\n\t\t{40, 41, 44, 91},                // state 317\n\t\t{40, 41, 42, 58, 59, 91, 57377}, // state 318\n\t\t{40, 41, 42, 58, 59, 91, 57377}, // state 319\n\t\t{40, 41, 42, 58, 59, 91, 57377}, // state 320\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408},                                                                                                                           // state 321\n\t\t{33, 38, 40, 42, 43, 44, 45, 46, 91, 123, 125, 126, 57347, 57357, 57362, 57450, 57451, 57452, 57460, 57373, 57377, 57379, 57382, 57476, 57477, 57385, 57386, 57406, 57408},                                                                       // state 322\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 323\n\t\t{44, 125, 57440}, // state 324\n\t\t{37, 38, 40, 42, 43, 44, 45, 46, 47, 59, 60, 61, 62, 63, 91, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421}, // state 325\n\t\t{33, 38, 40, 42, 43, 44, 45, 46, 91, 123, 125, 126, 57347, 57357, 57362, 57450, 57451, 57452, 57460, 57373, 57377, 57379, 57382, 57476, 57477, 57385, 57386, 57406, 57408},                                                    // state 326\n\t\t{44, 125}, // state 327\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57476, 57385, 57386, 57406, 57408}, // state 328\n\t\t{46, 61, 91, 57451}, // state 329\n\t\t{46, 61, 91},        // state 330\n\t\t{57377},             // state 331\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57442, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 332\n\t\t{93},         // state 333\n\t\t{46, 61, 91}, // state 334\n\t\t{46, 61, 91}, // state 335\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57357, 57362, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 336\n\t\t{46, 61, 91},     // state 337\n\t\t{44, 125},        // state 338\n\t\t{44, 125, 57440}, // state 339\n\t\t{33, 38, 40, 42, 43, 45, 46, 91, 123, 125, 126, 57347, 57357, 57362, 57450, 57451, 57452, 57460, 57373, 57377, 57379, 57382, 57476, 57385, 57386, 57406, 57408}, // state 340\n\t\t{125},         // state 341\n\t\t{44, 59, 125}, // state 342\n\t\t{44, 125},     // state 343\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57476, 57385, 57386, 57406, 57408}, // state 344\n\t\t{44, 125}, // state 345\n\t\t{125},     // state 346\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 347\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 348\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 349\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 350\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 351\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57352, 57356, 57357, 57358, 57359, 57441, 57362, 57367, 57369, 57456, 57460, 57461, 57372, 57373, 57377, 57379, 57381, 57382, 57384, 57385, 57386, 57400, 57404, 57405, 57406, 57408, 57409, 57488, 57497, 57498, 57413, 57414, 57499, 57500, 57503, 57416, 57417, 57418, 57419}, // state 352\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                           // state 353\n\t\t{41}, // state 354\n\t\t{57344, 33, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 123, 124, 125, 126, 57346, 57347, 57348, 57349, 57350, 57357, 57362, 57365, 57370, 57460, 57373, 57375, 57377, 57379, 57382, 57383, 57385, 57386, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57406, 57408, 57410, 57421}, // state 355\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57352, 57356, 57357, 57358, 57359, 57441, 57362, 57367, 57369, 57456, 57460, 57461, 57372, 57373, 57377, 57379, 57381, 57382, 57384, 57385, 57386, 57400, 57404, 57405, 57406, 57408, 57409, 57488, 57497, 57498, 57413, 57414, 57499, 57500, 57503, 57416, 57417, 57418, 57419},           // state 356\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                     // state 357\n\t\t{41}, // state 358\n\t\t{57344, 33, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 123, 124, 125, 126, 57346, 57347, 57348, 57349, 57350, 57357, 57362, 57365, 57370, 57460, 57373, 57375, 57377, 57379, 57382, 57383, 57385, 57386, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57406, 57408, 57410, 57421}, // state 359\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                     // state 360\n\t\t{57344, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 58, 59, 60, 61, 62, 63, 91, 93, 94, 124, 125, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                     // state 361\n\t\t{57422, 59},  // state 362\n\t\t{44, 59},     // state 363\n\t\t{44, 59},     // state 364\n\t\t{44, 59, 61}, // state 365\n\t\t{33, 38, 40, 42, 43, 45, 123, 126, 57347, 57357, 57362, 57460, 57373, 57377, 57379, 57382, 57476, 57385, 57386, 57406, 57408}, // state 366\n\t\t{44, 59}, // state 367\n\t\t{40, 42, 57448, 57377, 57473, 57485, 57486}, // state 368\n\t\t{44, 59}, // state 369\n\t\t{59},     // state 370\n\t\t{57344, 33, 38, 40, 42, 43, 45, 59, 123, 125, 126, 57347, 57351, 57352, 57353, 57354, 57356, 57357, 57358, 57359, 57360, 57362, 57363, 57366, 57367, 57369, 57371, 57372, 57373, 57374, 57376, 57377, 57378, 57379, 57380, 57381, 57382, 57384, 57385, 57386, 57399, 57400, 57401, 57404, 57405, 57406, 57407, 57408, 57409, 57411, 57412, 57413, 57414, 57416, 57417, 57418, 57419, 57420}, // state 371\n\t\t{40, 41, 42, 44, 91, 57377, 57485},   // state 372\n\t\t{40, 41, 44, 91, 57377},              // state 373\n\t\t{40, 42, 57448, 57377, 57485, 57486}, // state 374\n\t\t{40, 41, 42, 44, 58, 59, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 375\n\t\t{123},                        // state 376\n\t\t{57457, 57458, 57459, 57377}, // state 377\n\t\t{44, 61, 125},                // state 378\n\t\t{44, 125, 57440},             // state 379\n\t\t{44, 125},                    // state 380\n\t\t{44, 61, 125},                // state 381\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57442, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 382\n\t\t{44, 125},                  // state 383\n\t\t{125, 57457, 57458, 57377}, // state 384\n\t\t{125},                      // state 385\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 386\n\t\t{44, 125}, // state 387\n\t\t{40, 41, 42, 44, 58, 59, 91, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 388\n\t\t{123}, // state 389\n\t\t{57424, 57425, 125, 57352, 57356, 57358, 57359, 57367, 57369, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57413, 57414, 57416, 57417, 57418, 57419}, // state 390\n\t\t{125}, // state 391\n\t\t{57352, 57356, 57358, 57359, 57367, 57369, 57456, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57488, 57493, 57494, 57497, 57498, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419},      // state 392\n\t\t{57426, 125, 57352, 57356, 57358, 57359, 57367, 57369, 57456, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57488, 57493, 57497, 57498, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 393\n\t\t{125, 57352, 57356, 57358, 57359, 57367, 57369, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57413, 57414, 57416, 57417, 57418, 57419},                                                         // state 394\n\t\t{40, 42, 58, 59, 57448, 57449, 57377, 57485, 57486, 57495, 57496}, // state 395\n\t\t{44, 59}, // state 396\n\t\t{125, 57352, 57356, 57358, 57359, 57367, 57369, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57413, 57414, 57416, 57417, 57418, 57419}, // state 397\n\t\t{44, 59},     // state 398\n\t\t{44, 58, 59}, // state 399\n\t\t{58},         // state 400\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57357, 57442, 57362, 57460, 57373, 57377, 57379, 57382, 57385, 57386, 57406, 57408}, // state 401\n\t\t{44, 59}, // state 402\n\t\t{125, 57352, 57356, 57358, 57359, 57367, 57369, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57413, 57414, 57416, 57417, 57418, 57419}, // state 403\n\t\t{40, 42, 58, 57448, 57449, 57377, 57485, 57486, 57495}, // state 404\n\t\t{44, 59}, // state 405\n\t\t{125},    // state 406\n\t\t{125, 57352, 57356, 57358, 57359, 57367, 57369, 57372, 57381, 57384, 57400, 57404, 57405, 57409, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                                                                                              // state 407\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                      // state 408\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                                                      // state 409\n\t\t{33, 38, 40, 42, 43, 45, 126, 57347, 57352, 57356, 57357, 57358, 57359, 57362, 57367, 57369, 57456, 57460, 57372, 57373, 57377, 57379, 57381, 57382, 57384, 57385, 57386, 57400, 57404, 57405, 57406, 57408, 57409, 57488, 57497, 57498, 57413, 57414, 57499, 57500, 57503, 57416, 57417, 57418, 57419}, // state 410\n\t\t{37, 38, 40, 41, 42, 43, 45, 46, 47, 60, 61, 62, 63, 91, 94, 124, 57346, 57348, 57349, 57350, 57362, 57365, 57370, 57375, 57379, 57383, 57387, 57388, 57389, 57390, 57391, 57395, 57396, 57402, 57403, 57410, 57421},                                                                                    // state 411\n\t\t{41}, // state 412\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 413\n\t\t{40, 41, 42, 44, 58, 59, 91, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 414\n\t\t{40, 41, 42, 44, 59, 91, 57377}, // state 415\n\t\t{40, 41, 42, 44, 59, 91, 57377}, // state 416\n\t\t{40, 41, 42, 44, 59, 91, 57377}, // state 417\n\t\t{40, 41, 42, 44, 59, 91, 57377}, // state 418\n\t\t{40, 41, 42, 44, 59, 91, 57377}, // state 419\n\t\t{57430, 44, 59, 61, 123, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419},                                                           // state 420\n\t\t{123, 57351, 57352, 57356, 57358, 57359, 57367, 57443, 57444, 57445, 57446, 57369, 57371, 57456, 57372, 57469, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57492, 57497, 57498, 57412, 57413, 57414, 57500, 57503, 57416, 57417, 57418, 57419}, // state 421\n\t\t{57423, 123, 57467}, // state 422\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 423\n\t\t{57344, 40, 42, 57351, 57352, 57356, 57358, 57359, 57367, 57369, 57371, 57372, 57377, 57380, 57381, 57384, 57399, 57400, 57404, 57405, 57407, 57409, 57412, 57413, 57414, 57416, 57417, 57418, 57419}, // state 424\n\t\t{57344}, // state 425\n\t}\n\n\tyyXLAT = map[int]int{\n\t\t40:      0,   // '(' (298x)\n\t\t42:      1,   // '*' (268x)\n\t\t57377:   2,   // IDENTIFIER (214x)\n\t\t38:      3,   // '&' (205x)\n\t\t43:      4,   // '+' (205x)\n\t\t45:      5,   // '-' (205x)\n\t\t57362:   6,   // DEC (205x)\n\t\t57379:   7,   // INC (205x)\n\t\t59:      8,   // ';' (191x)\n\t\t41:      9,   // ')' (177x)\n\t\t44:      10,  // ',' (175x)\n\t\t91:      11,  // '[' (156x)\n\t\t33:      12,  // '!' (135x)\n\t\t126:     13,  // '~' (135x)\n\t\t57347:   14,  // ALIGNOF (135x)\n\t\t57357:   15,  // CHARCONST (135x)\n\t\t57373:   16,  // FLOATCONST (135x)\n\t\t57382:   17,  // INTCONST (135x)\n\t\t57385:   18,  // LONGCHARCONST (135x)\n\t\t57386:   19,  // LONGSTRINGLITERAL (135x)\n\t\t57406:   20,  // SIZEOF (135x)\n\t\t57408:   21,  // STRINGLITERAL (135x)\n\t\t57413:   22,  // TYPEDEF_NAME (122x)\n\t\t125:     23,  // '}' (121x)\n\t\t57359:   24,  // CONST (121x)\n\t\t57400:   25,  // RESTRICT (121x)\n\t\t57419:   26,  // VOLATILE (121x)\n\t\t57352:   27,  // BOOL (111x)\n\t\t57356:   28,  // CHAR (111x)\n\t\t57358:   29,  // COMPLEX (111x)\n\t\t57367:   30,  // DOUBLE (111x)\n\t\t57369:   31,  // ENUM (111x)\n\t\t57372:   32,  // FLOAT (111x)\n\t\t57381:   33,  // INT (111x)\n\t\t57384:   34,  // LONG (111x)\n\t\t57404:   35,  // SHORT (111x)\n\t\t57405:   36,  // SIGNED (111x)\n\t\t57409:   37,  // STRUCT (111x)\n\t\t57414:   38,  // TYPEOF (111x)\n\t\t57416:   39,  // UNION (111x)\n\t\t57417:   40,  // UNSIGNED (111x)\n\t\t57418:   41,  // VOID (111x)\n\t\t58:      42,  // ':' (110x)\n\t\t57407:   43,  // STATIC (104x)\n\t\t57351:   44,  // AUTO (98x)\n\t\t57371:   45,  // EXTERN (98x)\n\t\t57380:   46,  // INLINE (98x)\n\t\t57399:   47,  // REGISTER (98x)\n\t\t57412:   48,  // TYPEDEF (98x)\n\t\t57460:   49,  // Expr (95x)\n\t\t61:      50,  // '=' (90x)\n\t\t93:      51,  // ']' (84x)\n\t\t123:     52,  // '{' (82x)\n\t\t46:      53,  // '.' (80x)\n\t\t57344:   54,  // $end (72x)\n\t\t37:      55,  // '%' (72x)\n\t\t47:      56,  // '/' (72x)\n\t\t60:      57,  // '<' (72x)\n\t\t62:      58,  // '>' (72x)\n\t\t63:      59,  // '?' (72x)\n\t\t94:      60,  // '^' (72x)\n\t\t124:     61,  // '|' (72x)\n\t\t57346:   62,  // ADDASSIGN (72x)\n\t\t57348:   63,  // ANDAND (72x)\n\t\t57349:   64,  // ANDASSIGN (72x)\n\t\t57350:   65,  // ARROW (72x)\n\t\t57365:   66,  // DIVASSIGN (72x)\n\t\t57370:   67,  // EQ (72x)\n\t\t57375:   68,  // GEQ (72x)\n\t\t57383:   69,  // LEQ (72x)\n\t\t57387:   70,  // LSH (72x)\n\t\t57388:   71,  // LSHASSIGN (72x)\n\t\t57389:   72,  // MODASSIGN (72x)\n\t\t57390:   73,  // MULASSIGN (72x)\n\t\t57391:   74,  // NEQ (72x)\n\t\t57395:   75,  // ORASSIGN (72x)\n\t\t57396:   76,  // OROR (72x)\n\t\t57402:   77,  // RSH (72x)\n\t\t57403:   78,  // RSHASSIGN (72x)\n\t\t57410:   79,  // SUBASSIGN (72x)\n\t\t57421:   80,  // XORASSIGN (72x)\n\t\t57420:   81,  // WHILE (43x)\n\t\t57353:   82,  // BREAK (42x)\n\t\t57354:   83,  // CASE (42x)\n\t\t57360:   84,  // CONTINUE (42x)\n\t\t57363:   85,  // DEFAULT (42x)\n\t\t57366:   86,  // DO (42x)\n\t\t57374:   87,  // FOR (42x)\n\t\t57376:   88,  // GOTO (42x)\n\t\t57378:   89,  // IF (42x)\n\t\t57401:   90,  // RETURN (42x)\n\t\t57411:   91,  // SWITCH (42x)\n\t\t57500:   92,  // TypeQualifier (33x)\n\t\t57461:   93,  // ExprList (28x)\n\t\t57456:   94,  // EnumSpecifier (25x)\n\t\t57497:   95,  // StructOrUnion (25x)\n\t\t57498:   96,  // StructOrUnionSpecifier (25x)\n\t\t57503:   97,  // TypeSpecifier (25x)\n\t\t57368:   98,  // ELSE (23x)\n\t\t57462:   99,  // ExprListOpt (19x)\n\t\t57441:   100, // CompoundStmt (17x)\n\t\t57446:   101, // DeclarationSpecifiers (17x)\n\t\t57469:   102, // FunctionSpecifier (17x)\n\t\t57492:   103, // StorageClassSpecifier (17x)\n\t\t57464:   104, // ExprStmt (13x)\n\t\t57478:   105, // IterationStmt (13x)\n\t\t57479:   106, // JumpStmt (13x)\n\t\t57480:   107, // LabeledStmt (13x)\n\t\t57485:   108, // Pointer (13x)\n\t\t57487:   109, // SelectionStmt (13x)\n\t\t57491:   110, // Stmt (13x)\n\t\t57486:   111, // PointerOpt (12x)\n\t\t57448:   112, // Declarator (10x)\n\t\t57443:   113, // Declaration (8x)\n\t\t57488:   114, // SpecifierQualifierList (8x)\n\t\t57476:   115, // Initializer (6x)\n\t\t57442:   116, // ConstExpr (5x)\n\t\t57481:   117, // ParameterDeclaration (5x)\n\t\t57501:   118, // TypeQualifierList (5x)\n\t\t57433:   119, // AbstractDeclarator (4x)\n\t\t57447:   120, // DeclarationSpecifiersOpt (4x)\n\t\t57451:   121, // Designator (4x)\n\t\t57482:   122, // ParameterList (4x)\n\t\t57483:   123, // ParameterTypeList (4x)\n\t\t57499:   124, // TypeName (4x)\n\t\t57502:   125, // TypeQualifierListOpt (4x)\n\t\t57440:   126, // CommaOpt (3x)\n\t\t57450:   127, // Designation (3x)\n\t\t57452:   128, // DesignatorList (3x)\n\t\t57463:   129, // ExprOpt (3x)\n\t\t57473:   130, // InitDeclarator (3x)\n\t\t57484:   131, // ParameterTypeListOpt (3x)\n\t\t57423:   132, // $@10 (2x)\n\t\t57434:   133, // AbstractDeclaratorOpt (2x)\n\t\t57437:   134, // BlockItem (2x)\n\t\t57444:   135, // DeclarationList (2x)\n\t\t57445:   136, // DeclarationListOpt (2x)\n\t\t57449:   137, // DeclaratorOpt (2x)\n\t\t57453:   138, // DirectAbstractDeclarator (2x)\n\t\t57454:   139, // DirectAbstractDeclaratorOpt (2x)\n\t\t57455:   140, // DirectDeclarator (2x)\n\t\t57457:   141, // EnumerationConstant (2x)\n\t\t57458:   142, // Enumerator (2x)\n\t\t57465:   143, // ExternalDeclaration (2x)\n\t\t57467:   144, // FunctionBody (2x)\n\t\t57468:   145, // FunctionDefinition (2x)\n\t\t57472:   146, // IdentifierOpt (2x)\n\t\t57474:   147, // InitDeclaratorList (2x)\n\t\t57475:   148, // InitDeclaratorListOpt (2x)\n\t\t57477:   149, // InitializerList (2x)\n\t\t57489:   150, // SpecifierQualifierListOpt (2x)\n\t\t57493:   151, // StructDeclaration (2x)\n\t\t57495:   152, // StructDeclarator (2x)\n\t\t57422:   153, // $@1 (1x)\n\t\t57424:   154, // $@2 (1x)\n\t\t57425:   155, // $@3 (1x)\n\t\t57426:   156, // $@4 (1x)\n\t\t57427:   157, // $@5 (1x)\n\t\t57428:   158, // $@6 (1x)\n\t\t57429:   159, // $@7 (1x)\n\t\t57430:   160, // $@8 (1x)\n\t\t57431:   161, // $@9 (1x)\n\t\t57435:   162, // ArgumentExprList (1x)\n\t\t57436:   163, // ArgumentExprListOpt (1x)\n\t\t57438:   164, // BlockItemList (1x)\n\t\t57439:   165, // BlockItemListOpt (1x)\n\t\t1048576: 166, // CONSTANT_EXPRESSION (1x)\n\t\t57361:   167, // DDD (1x)\n\t\t57459:   168, // EnumeratorList (1x)\n\t\t57466:   169, // ExternalDeclarationList (1x)\n\t\t57470:   170, // IdentifierList (1x)\n\t\t57471:   171, // IdentifierListOpt (1x)\n\t\t57490:   172, // Start (1x)\n\t\t57494:   173, // StructDeclarationList (1x)\n\t\t57496:   174, // StructDeclaratorList (1x)\n\t\t1048577: 175, // TRANSLATION_UNIT (1x)\n\t\t57432:   176, // $default (0x)\n\t\t57355:   177, // CAST (0x)\n\t\t57364:   178, // DIRECTIVE (0x)\n\t\t57345:   179, // error (0x)\n\t\t57392:   180, // NOELSE (0x)\n\t\t57393:   181, // NON_REPL (0x)\n\t\t57394:   182, // NOSEMI (0x)\n\t\t57397:   183, // PPNUMBER (0x)\n\t\t57398:   184, // PPPASTE (0x)\n\t\t57415:   185, // UNARY (0x)\n\t\t57504:   186, // VolatileOpt (0x)\n\t}\n\n\tyySymNames = []string{\n\t\t\"'('\",\n\t\t\"'*'\",\n\t\t\"IDENTIFIER\",\n\t\t\"'&'\",\n\t\t\"'+'\",\n\t\t\"'-'\",\n\t\t\"DEC\",\n\t\t\"INC\",\n\t\t\"';'\",\n\t\t\"')'\",\n\t\t\"','\",\n\t\t\"'['\",\n\t\t\"'!'\",\n\t\t\"'~'\",\n\t\t\"ALIGNOF\",\n\t\t\"CHARCONST\",\n\t\t\"FLOATCONST\",\n\t\t\"INTCONST\",\n\t\t\"LONGCHARCONST\",\n\t\t\"LONGSTRINGLITERAL\",\n\t\t\"SIZEOF\",\n\t\t\"STRINGLITERAL\",\n\t\t\"TYPEDEF_NAME\",\n\t\t\"'}'\",\n\t\t\"CONST\",\n\t\t\"RESTRICT\",\n\t\t\"VOLATILE\",\n\t\t\"BOOL\",\n\t\t\"CHAR\",\n\t\t\"COMPLEX\",\n\t\t\"DOUBLE\",\n\t\t\"ENUM\",\n\t\t\"FLOAT\",\n\t\t\"INT\",\n\t\t\"LONG\",\n\t\t\"SHORT\",\n\t\t\"SIGNED\",\n\t\t\"STRUCT\",\n\t\t\"TYPEOF\",\n\t\t\"UNION\",\n\t\t\"UNSIGNED\",\n\t\t\"VOID\",\n\t\t\"':'\",\n\t\t\"STATIC\",\n\t\t\"AUTO\",\n\t\t\"EXTERN\",\n\t\t\"INLINE\",\n\t\t\"REGISTER\",\n\t\t\"TYPEDEF\",\n\t\t\"Expr\",\n\t\t\"'='\",\n\t\t\"']'\",\n\t\t\"'{'\",\n\t\t\"'.'\",\n\t\t\"$end\",\n\t\t\"'%'\",\n\t\t\"'/'\",\n\t\t\"'<'\",\n\t\t\"'>'\",\n\t\t\"'?'\",\n\t\t\"'^'\",\n\t\t\"'|'\",\n\t\t\"ADDASSIGN\",\n\t\t\"ANDAND\",\n\t\t\"ANDASSIGN\",\n\t\t\"ARROW\",\n\t\t\"DIVASSIGN\",\n\t\t\"EQ\",\n\t\t\"GEQ\",\n\t\t\"LEQ\",\n\t\t\"LSH\",\n\t\t\"LSHASSIGN\",\n\t\t\"MODASSIGN\",\n\t\t\"MULASSIGN\",\n\t\t\"NEQ\",\n\t\t\"ORASSIGN\",\n\t\t\"OROR\",\n\t\t\"RSH\",\n\t\t\"RSHASSIGN\",\n\t\t\"SUBASSIGN\",\n\t\t\"XORASSIGN\",\n\t\t\"WHILE\",\n\t\t\"BREAK\",\n\t\t\"CASE\",\n\t\t\"CONTINUE\",\n\t\t\"DEFAULT\",\n\t\t\"DO\",\n\t\t\"FOR\",\n\t\t\"GOTO\",\n\t\t\"IF\",\n\t\t\"RETURN\",\n\t\t\"SWITCH\",\n\t\t\"TypeQualifier\",\n\t\t\"ExprList\",\n\t\t\"EnumSpecifier\",\n\t\t\"StructOrUnion\",\n\t\t\"StructOrUnionSpecifier\",\n\t\t\"TypeSpecifier\",\n\t\t\"ELSE\",\n\t\t\"ExprListOpt\",\n\t\t\"CompoundStmt\",\n\t\t\"DeclarationSpecifiers\",\n\t\t\"FunctionSpecifier\",\n\t\t\"StorageClassSpecifier\",\n\t\t\"ExprStmt\",\n\t\t\"IterationStmt\",\n\t\t\"JumpStmt\",\n\t\t\"LabeledStmt\",\n\t\t\"Pointer\",\n\t\t\"SelectionStmt\",\n\t\t\"Stmt\",\n\t\t\"PointerOpt\",\n\t\t\"Declarator\",\n\t\t\"Declaration\",\n\t\t\"SpecifierQualifierList\",\n\t\t\"Initializer\",\n\t\t\"ConstExpr\",\n\t\t\"ParameterDeclaration\",\n\t\t\"TypeQualifierList\",\n\t\t\"AbstractDeclarator\",\n\t\t\"DeclarationSpecifiersOpt\",\n\t\t\"Designator\",\n\t\t\"ParameterList\",\n\t\t\"ParameterTypeList\",\n\t\t\"TypeName\",\n\t\t\"TypeQualifierListOpt\",\n\t\t\"CommaOpt\",\n\t\t\"Designation\",\n\t\t\"DesignatorList\",\n\t\t\"ExprOpt\",\n\t\t\"InitDeclarator\",\n\t\t\"ParameterTypeListOpt\",\n\t\t\"$@10\",\n\t\t\"AbstractDeclaratorOpt\",\n\t\t\"BlockItem\",\n\t\t\"DeclarationList\",\n\t\t\"DeclarationListOpt\",\n\t\t\"DeclaratorOpt\",\n\t\t\"DirectAbstractDeclarator\",\n\t\t\"DirectAbstractDeclaratorOpt\",\n\t\t\"DirectDeclarator\",\n\t\t\"EnumerationConstant\",\n\t\t\"Enumerator\",\n\t\t\"ExternalDeclaration\",\n\t\t\"FunctionBody\",\n\t\t\"FunctionDefinition\",\n\t\t\"IdentifierOpt\",\n\t\t\"InitDeclaratorList\",\n\t\t\"InitDeclaratorListOpt\",\n\t\t\"InitializerList\",\n\t\t\"SpecifierQualifierListOpt\",\n\t\t\"StructDeclaration\",\n\t\t\"StructDeclarator\",\n\t\t\"$@1\",\n\t\t\"$@2\",\n\t\t\"$@3\",\n\t\t\"$@4\",\n\t\t\"$@5\",\n\t\t\"$@6\",\n\t\t\"$@7\",\n\t\t\"$@8\",\n\t\t\"$@9\",\n\t\t\"ArgumentExprList\",\n\t\t\"ArgumentExprListOpt\",\n\t\t\"BlockItemList\",\n\t\t\"BlockItemListOpt\",\n\t\t\"CONSTANT_EXPRESSION\",\n\t\t\"DDD\",\n\t\t\"EnumeratorList\",\n\t\t\"ExternalDeclarationList\",\n\t\t\"IdentifierList\",\n\t\t\"IdentifierListOpt\",\n\t\t\"Start\",\n\t\t\"StructDeclarationList\",\n\t\t\"StructDeclaratorList\",\n\t\t\"TRANSLATION_UNIT\",\n\t\t\"$default\",\n\t\t\"CAST\",\n\t\t\"DIRECTIVE\",\n\t\t\"error\",\n\t\t\"NOELSE\",\n\t\t\"NON_REPL\",\n\t\t\"NOSEMI\",\n\t\t\"PPNUMBER\",\n\t\t\"PPPASTE\",\n\t\t\"UNARY\",\n\t\t\"VolatileOpt\",\n\t}\n\n\tyyTokenLiteralStrings = map[int]string{\n\t\t57377:   \"identifier\",\n\t\t57362:   \"--\",\n\t\t57379:   \"++\",\n\t\t57347:   \"__alignof__\",\n\t\t57357:   \"character constant\",\n\t\t57373:   \"floating-point constant\",\n\t\t57382:   \"integer constant\",\n\t\t57385:   \"long character constant\",\n\t\t57386:   \"long string constant\",\n\t\t57406:   \"sizeof\",\n\t\t57408:   \"string literal\",\n\t\t57413:   \"typedef name\",\n\t\t57359:   \"const\",\n\t\t57400:   \"restrict\",\n\t\t57419:   \"volatile\",\n\t\t57352:   \"_Bool\",\n\t\t57356:   \"char\",\n\t\t57358:   \"_Complex\",\n\t\t57367:   \"double\",\n\t\t57369:   \"enum\",\n\t\t57372:   \"float\",\n\t\t57381:   \"int\",\n\t\t57384:   \"long\",\n\t\t57404:   \"short\",\n\t\t57405:   \"signed\",\n\t\t57409:   \"struct\",\n\t\t57414:   \"typeof\",\n\t\t57416:   \"union\",\n\t\t57417:   \"unsigned\",\n\t\t57418:   \"void\",\n\t\t57407:   \"static\",\n\t\t57351:   \"auto\",\n\t\t57371:   \"extern\",\n\t\t57380:   \"inline\",\n\t\t57399:   \"register\",\n\t\t57412:   \"typedef\",\n\t\t57346:   \"+=\",\n\t\t57348:   \"&&\",\n\t\t57349:   \"&=\",\n\t\t57350:   \"->\",\n\t\t57365:   \"/=\",\n\t\t57370:   \"==\",\n\t\t57375:   \">=\",\n\t\t57383:   \"<=\",\n\t\t57387:   \"<<\",\n\t\t57388:   \"<<=\",\n\t\t57389:   \"%=\",\n\t\t57390:   \"*=\",\n\t\t57391:   \"!=\",\n\t\t57395:   \"|=\",\n\t\t57396:   \"||\",\n\t\t57402:   \">>\",\n\t\t57403:   \">>=\",\n\t\t57410:   \"-=\",\n\t\t57421:   \"^=\",\n\t\t57420:   \"while\",\n\t\t57353:   \"break\",\n\t\t57354:   \"case\",\n\t\t57360:   \"continue\",\n\t\t57363:   \"default\",\n\t\t57366:   \"do\",\n\t\t57374:   \"for\",\n\t\t57376:   \"goto\",\n\t\t57378:   \"if\",\n\t\t57401:   \"return\",\n\t\t57411:   \"switch\",\n\t\t57368:   \"else\",\n\t\t1048576: \"constant expression prefix\",\n\t\t57361:   \"...\",\n\t\t1048577: \"translation unit prefix\",\n\t\t57397:   \"preprocessing number\",\n\t\t57398:   \"##\",\n\t}\n\n\tyyReductions = map[int]struct{ xsym, components int }{\n\t\t0:   {0, 1},\n\t\t1:   {172, 2},\n\t\t2:   {172, 2},\n\t\t3:   {141, 1},\n\t\t4:   {162, 1},\n\t\t5:   {162, 3},\n\t\t6:   {163, 0},\n\t\t7:   {163, 1},\n\t\t8:   {49, 2},\n\t\t9:   {49, 2},\n\t\t10:  {49, 4},\n\t\t11:  {49, 2},\n\t\t12:  {49, 4},\n\t\t13:  {49, 2},\n\t\t14:  {49, 2},\n\t\t15:  {49, 2},\n\t\t16:  {49, 3},\n\t\t17:  {49, 3},\n\t\t18:  {49, 7},\n\t\t19:  {49, 4},\n\t\t20:  {49, 2},\n\t\t21:  {49, 2},\n\t\t22:  {49, 2},\n\t\t23:  {49, 2},\n\t\t24:  {49, 1},\n\t\t25:  {49, 3},\n\t\t26:  {49, 3},\n\t\t27:  {49, 3},\n\t\t28:  {49, 3},\n\t\t29:  {49, 3},\n\t\t30:  {49, 2},\n\t\t31:  {49, 3},\n\t\t32:  {49, 2},\n\t\t33:  {49, 3},\n\t\t34:  {49, 3},\n\t\t35:  {49, 3},\n\t\t36:  {49, 3},\n\t\t37:  {49, 3},\n\t\t38:  {49, 3},\n\t\t39:  {49, 3},\n\t\t40:  {49, 3},\n\t\t41:  {49, 3},\n\t\t42:  {49, 3},\n\t\t43:  {49, 3},\n\t\t44:  {49, 3},\n\t\t45:  {49, 3},\n\t\t46:  {49, 3},\n\t\t47:  {49, 3},\n\t\t48:  {49, 4},\n\t\t49:  {49, 3},\n\t\t50:  {49, 3},\n\t\t51:  {49, 3},\n\t\t52:  {49, 3},\n\t\t53:  {49, 3},\n\t\t54:  {49, 3},\n\t\t55:  {49, 3},\n\t\t56:  {49, 3},\n\t\t57:  {49, 5},\n\t\t58:  {49, 4},\n\t\t59:  {49, 3},\n\t\t60:  {49, 3},\n\t\t61:  {49, 1},\n\t\t62:  {49, 1},\n\t\t63:  {49, 1},\n\t\t64:  {49, 1},\n\t\t65:  {49, 1},\n\t\t66:  {49, 1},\n\t\t67:  {129, 0},\n\t\t68:  {129, 1},\n\t\t69:  {93, 1},\n\t\t70:  {93, 3},\n\t\t71:  {99, 0},\n\t\t72:  {99, 1},\n\t\t73:  {116, 1},\n\t\t74:  {153, 0},\n\t\t75:  {113, 4},\n\t\t76:  {101, 2},\n\t\t77:  {101, 2},\n\t\t78:  {101, 2},\n\t\t79:  {101, 2},\n\t\t80:  {120, 0},\n\t\t81:  {120, 1},\n\t\t82:  {147, 1},\n\t\t83:  {147, 3},\n\t\t84:  {148, 0},\n\t\t85:  {148, 1},\n\t\t86:  {130, 1},\n\t\t87:  {130, 3},\n\t\t88:  {103, 1},\n\t\t89:  {103, 1},\n\t\t90:  {103, 1},\n\t\t91:  {103, 1},\n\t\t92:  {103, 1},\n\t\t93:  {97, 1},\n\t\t94:  {97, 1},\n\t\t95:  {97, 1},\n\t\t96:  {97, 1},\n\t\t97:  {97, 1},\n\t\t98:  {97, 1},\n\t\t99:  {97, 1},\n\t\t100: {97, 1},\n\t\t101: {97, 1},\n\t\t102: {97, 1},\n\t\t103: {97, 1},\n\t\t104: {97, 1},\n\t\t105: {97, 1},\n\t\t106: {97, 1},\n\t\t107: {97, 4},\n\t\t108: {97, 4},\n\t\t109: {96, 2},\n\t\t110: {154, 0},\n\t\t111: {96, 5},\n\t\t112: {155, 0},\n\t\t113: {156, 0},\n\t\t114: {96, 7},\n\t\t115: {95, 1},\n\t\t116: {95, 1},\n\t\t117: {173, 1},\n\t\t118: {173, 2},\n\t\t119: {151, 3},\n\t\t120: {151, 2},\n\t\t121: {114, 2},\n\t\t122: {114, 2},\n\t\t123: {150, 0},\n\t\t124: {150, 1},\n\t\t125: {174, 1},\n\t\t126: {174, 3},\n\t\t127: {152, 1},\n\t\t128: {152, 3},\n\t\t129: {126, 0},\n\t\t130: {126, 1},\n\t\t131: {94, 2},\n\t\t132: {94, 6},\n\t\t133: {168, 1},\n\t\t134: {168, 3},\n\t\t135: {142, 1},\n\t\t136: {142, 3},\n\t\t137: {92, 1},\n\t\t138: {92, 1},\n\t\t139: {92, 1},\n\t\t140: {102, 1},\n\t\t141: {112, 2},\n\t\t142: {137, 0},\n\t\t143: {137, 1},\n\t\t144: {140, 3},\n\t\t145: {157, 0},\n\t\t146: {140, 5},\n\t\t147: {158, 0},\n\t\t148: {140, 5},\n\t\t149: {140, 6},\n\t\t150: {140, 6},\n\t\t151: {140, 5},\n\t\t152: {140, 5},\n\t\t153: {140, 1},\n\t\t154: {108, 2},\n\t\t155: {108, 3},\n\t\t156: {111, 0},\n\t\t157: {111, 1},\n\t\t158: {118, 1},\n\t\t159: {118, 2},\n\t\t160: {125, 0},\n\t\t161: {125, 1},\n\t\t162: {123, 1},\n\t\t163: {123, 3},\n\t\t164: {131, 0},\n\t\t165: {131, 1},\n\t\t166: {122, 1},\n\t\t167: {122, 3},\n\t\t168: {117, 2},\n\t\t169: {117, 2},\n\t\t170: {170, 1},\n\t\t171: {170, 3},\n\t\t172: {171, 0},\n\t\t173: {171, 1},\n\t\t174: {146, 0},\n\t\t175: {146, 1},\n\t\t176: {124, 2},\n\t\t177: {119, 1},\n\t\t178: {119, 2},\n\t\t179: {133, 0},\n\t\t180: {133, 1},\n\t\t181: {138, 3},\n\t\t182: {138, 3},\n\t\t183: {138, 4},\n\t\t184: {138, 6},\n\t\t185: {138, 4},\n\t\t186: {138, 4},\n\t\t187: {138, 6},\n\t\t188: {138, 5},\n\t\t189: {139, 0},\n\t\t190: {139, 1},\n\t\t191: {115, 4},\n\t\t192: {115, 1},\n\t\t193: {149, 0},\n\t\t194: {149, 1},\n\t\t195: {149, 2},\n\t\t196: {149, 3},\n\t\t197: {149, 4},\n\t\t198: {127, 2},\n\t\t199: {128, 1},\n\t\t200: {128, 2},\n\t\t201: {121, 2},\n\t\t202: {121, 3},\n\t\t203: {110, 1},\n\t\t204: {110, 1},\n\t\t205: {110, 1},\n\t\t206: {110, 1},\n\t\t207: {110, 1},\n\t\t208: {110, 1},\n\t\t209: {107, 4},\n\t\t210: {107, 3},\n\t\t211: {107, 3},\n\t\t212: {107, 3},\n\t\t213: {159, 0},\n\t\t214: {100, 4},\n\t\t215: {164, 1},\n\t\t216: {164, 2},\n\t\t217: {165, 0},\n\t\t218: {165, 1},\n\t\t219: {134, 1},\n\t\t220: {134, 1},\n\t\t221: {104, 2},\n\t\t222: {109, 7},\n\t\t223: {109, 5},\n\t\t224: {109, 5},\n\t\t225: {105, 7},\n\t\t226: {105, 8},\n\t\t227: {105, 9},\n\t\t228: {105, 5},\n\t\t229: {106, 2},\n\t\t230: {106, 2},\n\t\t231: {106, 3},\n\t\t232: {106, 3},\n\t\t233: {169, 1},\n\t\t234: {169, 2},\n\t\t235: {143, 1},\n\t\t236: {143, 1},\n\t\t237: {160, 0},\n\t\t238: {145, 5},\n\t\t239: {161, 0},\n\t\t240: {145, 4},\n\t\t241: {132, 0},\n\t\t242: {144, 2},\n\t\t243: {135, 1},\n\t\t244: {135, 2},\n\t\t245: {136, 0},\n\t\t246: {136, 1},\n\t\t247: {186, 0},\n\t\t248: {186, 1},\n\t}\n\n\tyyXErrors = map[yyXError]string{\n\t\t{0, 54}:   \"invalid empty input\",\n\t\t{1, -1}:   \"expected $end\",\n\t\t{425, -1}: \"expected $end\",\n\t\t{29, -1}:  \"expected '('\",\n\t\t{91, -1}:  \"expected '('\",\n\t\t{92, -1}:  \"expected '('\",\n\t\t{94, -1}:  \"expected '('\",\n\t\t{95, -1}:  \"expected '('\",\n\t\t{209, -1}: \"expected '('\",\n\t\t{169, -1}: \"expected ')'\",\n\t\t{200, -1}: \"expected ')'\",\n\t\t{205, -1}: \"expected ')'\",\n\t\t{239, -1}: \"expected ')'\",\n\t\t{241, -1}: \"expected ')'\",\n\t\t{246, -1}: \"expected ')'\",\n\t\t{272, -1}: \"expected ')'\",\n\t\t{275, -1}: \"expected ')'\",\n\t\t{276, -1}: \"expected ')'\",\n\t\t{285, -1}: \"expected ')'\",\n\t\t{304, -1}: \"expected ')'\",\n\t\t{306, -1}: \"expected ')'\",\n\t\t{313, -1}: \"expected ')'\",\n\t\t{316, -1}: \"expected ')'\",\n\t\t{354, -1}: \"expected ')'\",\n\t\t{358, -1}: \"expected ')'\",\n\t\t{412, -1}: \"expected ')'\",\n\t\t{84, -1}:  \"expected ':'\",\n\t\t{111, -1}: \"expected ':'\",\n\t\t{230, -1}: \"expected ':'\",\n\t\t{400, -1}: \"expected ':'\",\n\t\t{90, -1}:  \"expected ';'\",\n\t\t{96, -1}:  \"expected ';'\",\n\t\t{97, -1}:  \"expected ';'\",\n\t\t{101, -1}: \"expected ';'\",\n\t\t{103, -1}: \"expected ';'\",\n\t\t{196, -1}: \"expected ';'\",\n\t\t{198, -1}: \"expected ';'\",\n\t\t{203, -1}: \"expected ';'\",\n\t\t{212, -1}: \"expected ';'\",\n\t\t{362, -1}: \"expected ';'\",\n\t\t{370, -1}: \"expected ';'\",\n\t\t{251, -1}: \"expected '['\",\n\t\t{258, -1}: \"expected ']'\",\n\t\t{266, -1}: \"expected ']'\",\n\t\t{293, -1}: \"expected ']'\",\n\t\t{333, -1}: \"expected ']'\",\n\t\t{376, -1}: \"expected '{'\",\n\t\t{389, -1}: \"expected '{'\",\n\t\t{85, -1}:  \"expected '}'\",\n\t\t{341, -1}: \"expected '}'\",\n\t\t{346, -1}: \"expected '}'\",\n\t\t{385, -1}: \"expected '}'\",\n\t\t{391, -1}: \"expected '}'\",\n\t\t{406, -1}: \"expected '}'\",\n\t\t{0, -1}:   \"expected Start or one of [constant expression prefix, translation unit prefix]\",\n\t\t{283, -1}: \"expected abstract declarator or declarator or optional parameter type list or one of ['(', ')', '*', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{250, -1}: \"expected abstract declarator or optional parameter type list or one of ['(', ')', '*', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{87, -1}:  \"expected block item or one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{52, -1}:  \"expected compound statement or '{'\",\n\t\t{62, -1}:  \"expected compound statement or expression list or type name or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Bool, _Complex, __alignof__, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{352, -1}: \"expected compound statement or expression list or type name or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Bool, _Complex, __alignof__, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{356, -1}: \"expected compound statement or expression list or type name or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, _Bool, _Complex, __alignof__, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{2, -1}:   \"expected constant expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{83, -1}:  \"expected constant expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{332, -1}: \"expected constant expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{382, -1}: \"expected constant expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{401, -1}: \"expected constant expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{49, -1}:  \"expected declaration or one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{194, -1}: \"expected declaration or optional expression list or one of ['!', '&', '(', '*', '+', '-', ';', '~', ++, --, _Bool, _Complex, __alignof__, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{374, -1}: \"expected declarator or one of ['(', '*', identifier]\",\n\t\t{274, -1}: \"expected declarator or optional abstract declarator or one of ['(', ')', '*', ',', '[', identifier]\",\n\t\t{5, -1}:   \"expected declarator or optional init declarator list or one of ['(', '*', ';', identifier]\",\n\t\t{340, -1}: \"expected designation or initializer or one of ['!', '&', '(', '*', '+', '-', '.', '[', '{', '}', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{329, -1}: \"expected designator or one of ['.', '=', '[']\",\n\t\t{279, -1}: \"expected direct abstract declarator or direct declarator or one of ['(', '[', identifier]\",\n\t\t{247, -1}: \"expected direct abstract declarator or one of ['(', '[']\",\n\t\t{38, -1}:  \"expected direct declarator or one of ['(', identifier]\",\n\t\t{377, -1}: \"expected enumerator list or identifier\",\n\t\t{384, -1}: \"expected enumerator or one of ['}', identifier]\",\n\t\t{107, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{148, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{149, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{210, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{214, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{218, -1}: \"expected expression list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{355, -1}: \"expected expression or one of [!=, $end, %=, &&, &=, '!', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '{', '|', '}', '~', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal, |=, ||]\",\n\t\t{359, -1}: \"expected expression or one of [!=, $end, %=, &&, &=, '!', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '{', '|', '}', '~', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal, |=, ||]\",\n\t\t{253, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{292, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{321, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{56, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{57, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{58, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{59, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{60, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{61, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{63, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{64, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{65, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{66, -1}:  \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{109, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{116, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{117, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{118, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{119, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{120, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{122, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{124, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{126, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{127, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{128, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{129, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{130, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{131, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{132, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{133, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{134, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{135, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{136, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{137, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{138, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{140, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{141, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{142, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{144, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{145, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{146, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{147, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{150, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{151, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{157, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{171, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{261, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{265, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{296, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{299, -1}: \"expected expression or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{257, -1}: \"expected expression or optional type qualifier list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{289, -1}: \"expected expression or optional type qualifier list or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{410, -1}: \"expected expression or type name or one of ['!', '&', '(', '*', '+', '-', '~', ++, --, _Bool, _Complex, __alignof__, char, character constant, const, double, enum, float, floating-point constant, identifier, int, integer constant, long, long character constant, long string constant, restrict, short, signed, sizeof, string literal, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{3, -1}:   \"expected external declaration list or one of ['(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{4, -1}:   \"expected external declaration or one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{47, -1}:  \"expected function body or '{'\",\n\t\t{422, -1}: \"expected function body or '{'\",\n\t\t{420, -1}: \"expected function body or optional declaration list or one of [',', ';', '=', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{44, -1}:  \"expected function body or optional declaration list or one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{45, -1}:  \"expected function body or optional declaration list or one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{421, -1}: \"expected function body or optional declaration list or one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{98, -1}:  \"expected identifier\",\n\t\t{125, -1}: \"expected identifier\",\n\t\t{143, -1}: \"expected identifier\",\n\t\t{309, -1}: \"expected identifier\",\n\t\t{331, -1}: \"expected identifier\",\n\t\t{368, -1}: \"expected init declarator or one of ['(', '*', identifier]\",\n\t\t{322, -1}: \"expected initializer list or optional comma or one of ['!', '&', '(', '*', '+', ',', '-', '.', '[', '{', '}', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{326, -1}: \"expected initializer list or optional comma or one of ['!', '&', '(', '*', '+', ',', '-', '.', '[', '{', '}', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{328, -1}: \"expected initializer or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{344, -1}: \"expected initializer or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{366, -1}: \"expected initializer or one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{67, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{69, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{71, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{72, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{73, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{74, -1}:  \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{100, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{121, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{123, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{152, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{153, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{155, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{158, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{159, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{160, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{161, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{162, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{163, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{164, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{165, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{166, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{170, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{173, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{174, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{175, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{176, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{177, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{178, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{179, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{180, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{181, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{182, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{183, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{184, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{185, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{186, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{187, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{188, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{189, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{190, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{191, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{192, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{193, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{235, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{236, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{237, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{238, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{323, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{347, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{348, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{349, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{350, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{351, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{353, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{357, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{360, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{361, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{229, -1}: \"expected one of [!=, $end, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{68, -1}:  \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{115, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{167, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{172, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{411, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', ')', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{70, -1}:  \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '[', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{325, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', ',', '-', '.', '/', ';', '<', '=', '>', '?', '[', '^', '|', '}', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{254, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{262, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{268, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{297, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{300, -1}: \"expected one of [!=, %=, &&, &=, '%', '&', '(', '*', '+', '-', '.', '/', '<', '=', '>', '?', '[', ']', '^', '|', *=, ++, +=, --, -=, ->, /=, <<, <<=, <=, ==, >=, >>, >>=, ^=, |=, ||]\",\n\t\t{226, -1}: \"expected one of [$end, '!', '&', '(', ')', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{371, -1}: \"expected one of [$end, '!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{41, -1}:  \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{42, -1}:  \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{43, -1}:  \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{51, -1}:  \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{54, -1}:  \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{423, -1}: \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{424, -1}: \"expected one of [$end, '(', '*', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{34, -1}:  \"expected one of ['!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Bool, _Complex, __alignof__, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{35, -1}:  \"expected one of ['!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Bool, _Complex, __alignof__, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{36, -1}:  \"expected one of ['!', '&', '(', ')', '*', '+', ',', '-', ':', ';', '[', ']', '~', ++, --, _Bool, _Complex, __alignof__, auto, char, character constant, const, double, enum, extern, float, floating-point constant, identifier, inline, int, integer constant, long, long character constant, long string constant, register, restrict, short, signed, sizeof, static, string literal, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{255, -1}: \"expected one of ['!', '&', '(', ')', '*', '+', ',', '-', '[', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{264, -1}: \"expected one of ['!', '&', '(', ')', '*', '+', ',', '-', '[', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{77, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{78, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{79, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{80, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{81, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{82, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{102, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{104, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{105, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{106, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{112, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{114, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{202, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{207, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{213, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{217, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{221, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{223, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{224, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{228, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{232, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{234, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, else, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{86, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{88, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{89, -1}:  \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{225, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{336, -1}: \"expected one of ['!', '&', '(', '*', '+', '-', '{', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{375, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{388, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{15, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{16, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{17, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{18, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{19, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{20, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{21, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{22, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{23, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{24, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{25, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{26, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{27, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{28, -1}:  \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{386, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{408, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{409, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{413, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{414, -1}: \"expected one of ['(', ')', '*', ',', ':', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{10, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{11, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{12, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{13, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{14, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{37, -1}:  \"expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{415, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{416, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{417, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{418, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{419, -1}: \"expected one of ['(', ')', '*', ',', ';', '[', identifier]\",\n\t\t{318, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{319, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{320, -1}: \"expected one of ['(', ')', '*', ':', ';', '[', identifier]\",\n\t\t{282, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{284, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{286, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{294, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{295, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{298, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{301, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{305, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{311, -1}: \"expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{245, -1}: \"expected one of ['(', ')', ',', '[', identifier]\",\n\t\t{373, -1}: \"expected one of ['(', ')', ',', '[', identifier]\",\n\t\t{249, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{259, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{263, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{267, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{269, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{270, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{277, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{278, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{317, -1}: \"expected one of ['(', ')', ',', '[']\",\n\t\t{76, -1}:  \"expected one of ['(', '*', ':', ';', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{40, -1}:  \"expected one of ['(', identifier]\",\n\t\t{75, -1}:  \"expected one of [')', ',', ';']\",\n\t\t{108, -1}: \"expected one of [')', ',']\",\n\t\t{168, -1}: \"expected one of [')', ',']\",\n\t\t{211, -1}: \"expected one of [')', ',']\",\n\t\t{215, -1}: \"expected one of [')', ',']\",\n\t\t{219, -1}: \"expected one of [')', ',']\",\n\t\t{240, -1}: \"expected one of [')', ',']\",\n\t\t{248, -1}: \"expected one of [')', ',']\",\n\t\t{271, -1}: \"expected one of [')', ',']\",\n\t\t{273, -1}: \"expected one of [')', ',']\",\n\t\t{280, -1}: \"expected one of [')', ',']\",\n\t\t{281, -1}: \"expected one of [')', ',']\",\n\t\t{307, -1}: \"expected one of [')', ',']\",\n\t\t{308, -1}: \"expected one of [')', ',']\",\n\t\t{310, -1}: \"expected one of [')', ',']\",\n\t\t{314, -1}: \"expected one of [')', ',']\",\n\t\t{399, -1}: \"expected one of [',', ':', ';']\",\n\t\t{156, -1}: \"expected one of [',', ':']\",\n\t\t{365, -1}: \"expected one of [',', ';', '=']\",\n\t\t{342, -1}: \"expected one of [',', ';', '}']\",\n\t\t{363, -1}: \"expected one of [',', ';']\",\n\t\t{364, -1}: \"expected one of [',', ';']\",\n\t\t{367, -1}: \"expected one of [',', ';']\",\n\t\t{369, -1}: \"expected one of [',', ';']\",\n\t\t{396, -1}: \"expected one of [',', ';']\",\n\t\t{398, -1}: \"expected one of [',', ';']\",\n\t\t{402, -1}: \"expected one of [',', ';']\",\n\t\t{405, -1}: \"expected one of [',', ';']\",\n\t\t{378, -1}: \"expected one of [',', '=', '}']\",\n\t\t{381, -1}: \"expected one of [',', '=', '}']\",\n\t\t{154, -1}: \"expected one of [',', ']']\",\n\t\t{327, -1}: \"expected one of [',', '}']\",\n\t\t{338, -1}: \"expected one of [',', '}']\",\n\t\t{343, -1}: \"expected one of [',', '}']\",\n\t\t{345, -1}: \"expected one of [',', '}']\",\n\t\t{380, -1}: \"expected one of [',', '}']\",\n\t\t{383, -1}: \"expected one of [',', '}']\",\n\t\t{387, -1}: \"expected one of [',', '}']\",\n\t\t{330, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{334, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{335, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{337, -1}: \"expected one of ['.', '=', '[']\",\n\t\t{48, -1}:  \"expected one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{50, -1}:  \"expected one of ['{', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{31, -1}:  \"expected one of ['{', identifier]\",\n\t\t{32, -1}:  \"expected one of ['{', identifier]\",\n\t\t{394, -1}: \"expected one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{397, -1}: \"expected one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{403, -1}: \"expected one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{407, -1}: \"expected one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{244, -1}: \"expected optional abstract declarator or one of ['(', ')', '*', '[']\",\n\t\t{139, -1}: \"expected optional argument expression list or one of ['!', '&', '(', ')', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{53, -1}:  \"expected optional block item list or one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{55, -1}:  \"expected optional block item list or one of ['!', '&', '(', '*', '+', '-', ';', '{', '}', '~', ++, --, _Bool, _Complex, __alignof__, auto, break, case, char, character constant, const, continue, default, do, double, enum, extern, float, floating-point constant, for, goto, identifier, if, inline, int, integer constant, long, long character constant, long string constant, register, restrict, return, short, signed, sizeof, static, string literal, struct, switch, typedef, typedef name, typeof, union, unsigned, void, volatile, while]\",\n\t\t{324, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{339, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{379, -1}: \"expected optional comma or one of [',', '}']\",\n\t\t{6, -1}:   \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{7, -1}:   \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{8, -1}:   \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{9, -1}:   \"expected optional declaration specifiers or one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{199, -1}: \"expected optional expression list or one of ['!', '&', '(', ')', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{204, -1}: \"expected optional expression list or one of ['!', '&', '(', ')', '*', '+', '-', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{99, -1}:  \"expected optional expression list or one of ['!', '&', '(', '*', '+', '-', ';', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{195, -1}: \"expected optional expression list or one of ['!', '&', '(', '*', '+', '-', ';', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{197, -1}: \"expected optional expression list or one of ['!', '&', '(', '*', '+', '-', ';', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{291, -1}: \"expected optional expression or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, floating-point constant, identifier, integer constant, long character constant, long string constant, sizeof, string literal]\",\n\t\t{288, -1}: \"expected optional expression or optional type qualifier list or type qualifier list or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{252, -1}: \"expected optional expression or type qualifier list or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{256, -1}: \"expected optional expression or type qualifier or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{302, -1}: \"expected optional identifier list or one of [')', identifier]\",\n\t\t{287, -1}: \"expected optional identifier list or parameter type list or one of [')', _Bool, _Complex, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{30, -1}:  \"expected optional identifier or one of ['{', identifier]\",\n\t\t{33, -1}:  \"expected optional identifier or one of ['{', identifier]\",\n\t\t{46, -1}:  \"expected optional init declarator list or one of ['(', '*', ';', identifier]\",\n\t\t{315, -1}: \"expected optional parameter type list or one of [')', _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{242, -1}: \"expected optional specifier qualifier list or one of ['(', ')', '*', ':', ';', '[', _Bool, _Complex, char, const, double, enum, float, identifier, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{243, -1}: \"expected optional specifier qualifier list or one of ['(', ')', '*', ':', ';', '[', _Bool, _Complex, char, const, double, enum, float, identifier, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{39, -1}:  \"expected optional type qualifier list or pointer or one of ['(', ')', '*', ',', '[', const, identifier, restrict, volatile]\",\n\t\t{312, -1}: \"expected parameter declaration or one of [..., _Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{303, -1}: \"expected parameter type list or one of [_Bool, _Complex, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{372, -1}: \"expected pointer or one of ['(', ')', '*', ',', '[', identifier]\",\n\t\t{93, -1}:  \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{110, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{113, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{201, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{206, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{216, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{220, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{222, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{227, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{231, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{233, -1}: \"expected statement or one of ['!', '&', '(', '*', '+', '-', ';', '{', '~', ++, --, __alignof__, break, case, character constant, continue, default, do, floating-point constant, for, goto, identifier, if, integer constant, long character constant, long string constant, return, sizeof, string literal, switch, typedef name, while]\",\n\t\t{390, -1}: \"expected struct declaration list or one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{392, -1}: \"expected struct declaration list or one of [_Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{393, -1}: \"expected struct declaration or one of ['}', _Bool, _Complex, char, const, double, enum, float, int, long, restrict, short, signed, struct, typedef name, typeof, union, unsigned, void, volatile]\",\n\t\t{395, -1}: \"expected struct declarator list or one of ['(', '*', ':', ';', identifier]\",\n\t\t{404, -1}: \"expected struct declarator or one of ['(', '*', ':', identifier]\",\n\t\t{260, -1}: \"expected type qualifier or one of ['!', '&', '(', ')', '*', '+', ',', '-', '[', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, string literal, volatile]\",\n\t\t{290, -1}: \"expected type qualifier or one of ['!', '&', '(', '*', '+', '-', ']', '~', ++, --, __alignof__, character constant, const, floating-point constant, identifier, integer constant, long character constant, long string constant, restrict, sizeof, static, string literal, volatile]\",\n\t\t{208, -1}: \"expected while\",\n\t}\n\n\tyyParseTab = [426][]uint16{\n\t\t// 0\n\t\t{166: 249, 172: 248, 175: 250},\n\t\t{54: 247},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 476, 116: 672},\n\t\t{91, 286, 91, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 252, 253, 254, 108: 287, 111: 285, 291, 289, 143: 288, 145: 290, 169: 251},\n\t\t{91, 286, 91, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 54: 245, 92: 255, 94: 273, 277, 274, 256, 101: 252, 253, 254, 108: 287, 111: 285, 291, 289, 143: 671, 145: 290},\n\t\t// 5\n\t\t{91, 286, 91, 8: 163, 108: 287, 111: 285, 667, 130: 610, 147: 611, 609},\n\t\t{167, 167, 167, 8: 167, 167, 167, 167, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 663, 253, 254, 120: 666},\n\t\t{167, 167, 167, 8: 167, 167, 167, 167, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 663, 253, 254, 120: 665},\n\t\t{167, 167, 167, 8: 167, 167, 167, 167, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 663, 253, 254, 120: 664},\n\t\t{167, 167, 167, 8: 167, 167, 167, 167, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 663, 253, 254, 120: 662},\n\t\t// 10\n\t\t{159, 159, 159, 8: 159, 159, 159, 159, 22: 159, 24: 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 43: 159, 159, 159, 159, 159, 159},\n\t\t{158, 158, 158, 8: 158, 158, 158, 158, 22: 158, 24: 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, 43: 158, 158, 158, 158, 158, 158},\n\t\t{157, 157, 157, 8: 157, 157, 157, 157, 22: 157, 24: 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 43: 157, 157, 157, 157, 157, 157},\n\t\t{156, 156, 156, 8: 156, 156, 156, 156, 22: 156, 24: 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 156, 43: 156, 156, 156, 156, 156, 156},\n\t\t{155, 155, 155, 8: 155, 155, 155, 155, 22: 155, 24: 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 43: 155, 155, 155, 155, 155, 155},\n\t\t// 15\n\t\t{154, 154, 154, 8: 154, 154, 154, 154, 22: 154, 24: 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154},\n\t\t{153, 153, 153, 8: 153, 153, 153, 153, 22: 153, 24: 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153},\n\t\t{152, 152, 152, 8: 152, 152, 152, 152, 22: 152, 24: 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152},\n\t\t{151, 151, 151, 8: 151, 151, 151, 151, 22: 151, 24: 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151},\n\t\t{150, 150, 150, 8: 150, 150, 150, 150, 22: 150, 24: 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150},\n\t\t// 20\n\t\t{149, 149, 149, 8: 149, 149, 149, 149, 22: 149, 24: 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149},\n\t\t{148, 148, 148, 8: 148, 148, 148, 148, 22: 148, 24: 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148},\n\t\t{147, 147, 147, 8: 147, 147, 147, 147, 22: 147, 24: 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147},\n\t\t{146, 146, 146, 8: 146, 146, 146, 146, 22: 146, 24: 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146, 146},\n\t\t{145, 145, 145, 8: 145, 145, 145, 145, 22: 145, 24: 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145},\n\t\t// 25\n\t\t{144, 144, 144, 8: 144, 144, 144, 144, 22: 144, 24: 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144},\n\t\t{143, 143, 143, 8: 143, 143, 143, 143, 22: 143, 24: 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143},\n\t\t{142, 142, 142, 8: 142, 142, 142, 142, 22: 142, 24: 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142},\n\t\t{141, 141, 141, 8: 141, 141, 141, 141, 22: 141, 24: 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141},\n\t\t{657},\n\t\t// 30\n\t\t{2: 635, 52: 73, 146: 636},\n\t\t{2: 132, 52: 132},\n\t\t{2: 131, 52: 131},\n\t\t{2: 622, 52: 73, 146: 623},\n\t\t{110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 24: 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 51: 110},\n\t\t// 35\n\t\t{109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 24: 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 51: 109},\n\t\t{108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 24: 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 51: 108},\n\t\t{107, 107, 107, 8: 107, 107, 107, 107, 22: 107, 24: 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 43: 107, 107, 107, 107, 107, 107},\n\t\t{621, 2: 531, 140: 529},\n\t\t{87, 87, 87, 9: 87, 87, 87, 24: 281, 282, 283, 92: 502, 118: 507, 125: 619},\n\t\t// 40\n\t\t{90, 2: 90},\n\t\t{14, 14, 14, 22: 14, 24: 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 43: 14, 14, 14, 14, 14, 14, 54: 14},\n\t\t{12, 12, 12, 22: 12, 24: 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 43: 12, 12, 12, 12, 12, 12, 54: 12},\n\t\t{11, 11, 11, 22: 11, 24: 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 43: 11, 11, 11, 11, 11, 11, 54: 11},\n\t\t{22: 8, 24: 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 43: 8, 8, 8, 8, 8, 8, 52: 8, 161: 292},\n\t\t// 45\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 52: 2, 92: 255, 94: 273, 277, 274, 256, 101: 293, 253, 254, 113: 295, 135: 296, 294},\n\t\t{91, 286, 91, 8: 163, 108: 287, 111: 285, 612, 130: 610, 147: 611, 609},\n\t\t{52: 6, 132: 299, 144: 298},\n\t\t{22: 4, 24: 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 43: 4, 4, 4, 4, 4, 4, 52: 4},\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 52: 1, 92: 255, 94: 273, 277, 274, 256, 101: 293, 253, 254, 113: 297},\n\t\t// 50\n\t\t{22: 3, 24: 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 43: 3, 3, 3, 3, 3, 3, 52: 3},\n\t\t{7, 7, 7, 22: 7, 24: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 43: 7, 7, 7, 7, 7, 7, 54: 7},\n\t\t{52: 300, 100: 301},\n\t\t{34, 34, 34, 34, 34, 34, 34, 34, 34, 12: 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 43: 34, 34, 34, 34, 34, 34, 52: 34, 81: 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 159: 302},\n\t\t{5, 5, 5, 22: 5, 24: 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 43: 5, 5, 5, 5, 5, 5, 54: 5},\n\t\t// 55\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 323, 30, 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 255, 322, 273, 277, 274, 256, 99: 337, 324, 293, 253, 254, 325, 326, 327, 328, 109: 329, 336, 113: 335, 134: 333, 164: 334, 332},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 608},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 607},\n\t\t{603, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 604},\n\t\t{599, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 600},\n\t\t// 60\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 598},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 597},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 49: 315, 52: 300, 92: 489, 487, 273, 277, 274, 490, 100: 486, 114: 491, 124: 488},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 485},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 484},\n\t\t// 65\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 483},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 482},\n\t\t{223, 223, 3: 223, 223, 223, 223, 223, 223, 223, 223, 223, 23: 223, 42: 223, 50: 223, 223, 53: 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 178, 178, 178, 396, 42: 178, 50: 393, 178, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{186, 186, 3: 186, 186, 186, 186, 186, 186, 186, 186, 186, 23: 186, 42: 186, 50: 186, 186, 53: 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186},\n\t\t// 70\n\t\t{185, 185, 3: 185, 185, 185, 185, 185, 185, 10: 185, 185, 42: 480, 50: 185, 53: 185, 55: 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185},\n\t\t{184, 184, 3: 184, 184, 184, 184, 184, 184, 184, 184, 184, 23: 184, 42: 184, 50: 184, 184, 53: 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184},\n\t\t{183, 183, 3: 183, 183, 183, 183, 183, 183, 183, 183, 183, 23: 183, 42: 183, 50: 183, 183, 53: 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183},\n\t\t{182, 182, 3: 182, 182, 182, 182, 182, 182, 182, 182, 182, 23: 182, 42: 182, 50: 182, 182, 53: 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182},\n\t\t{181, 181, 3: 181, 181, 181, 181, 181, 181, 181, 181, 181, 23: 181, 42: 181, 50: 181, 181, 53: 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181, 181},\n\t\t// 75\n\t\t{8: 175, 175, 356},\n\t\t{141, 141, 141, 8: 141, 22: 141, 24: 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 141, 360, 141, 141, 141, 141, 141, 141},\n\t\t{44, 44, 44, 44, 44, 44, 44, 44, 44, 12: 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43: 44, 44, 44, 44, 44, 44, 52: 44, 81: 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 98: 44},\n\t\t{43, 43, 43, 43, 43, 43, 43, 43, 43, 12: 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43: 43, 43, 43, 43, 43, 43, 52: 43, 81: 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 98: 43},\n\t\t{42, 42, 42, 42, 42, 42, 42, 42, 42, 12: 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43: 42, 42, 42, 42, 42, 42, 52: 42, 81: 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 98: 42},\n\t\t// 80\n\t\t{41, 41, 41, 41, 41, 41, 41, 41, 41, 12: 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 43: 41, 41, 41, 41, 41, 41, 52: 41, 81: 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 98: 41},\n\t\t{40, 40, 40, 40, 40, 40, 40, 40, 40, 12: 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43: 40, 40, 40, 40, 40, 40, 52: 40, 81: 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 98: 40},\n\t\t{39, 39, 39, 39, 39, 39, 39, 39, 39, 12: 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 43: 39, 39, 39, 39, 39, 39, 52: 39, 81: 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 98: 39},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 476, 116: 477},\n\t\t{42: 474},\n\t\t// 85\n\t\t{23: 473},\n\t\t{32, 32, 32, 32, 32, 32, 32, 32, 32, 12: 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 43: 32, 32, 32, 32, 32, 32, 52: 32, 81: 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 323, 29, 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 255, 322, 273, 277, 274, 256, 99: 337, 324, 293, 253, 254, 325, 326, 327, 328, 109: 329, 336, 113: 335, 134: 472},\n\t\t{28, 28, 28, 28, 28, 28, 28, 28, 28, 12: 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 43: 28, 28, 28, 28, 28, 28, 52: 28, 81: 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28},\n\t\t{27, 27, 27, 27, 27, 27, 27, 27, 27, 12: 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 43: 27, 27, 27, 27, 27, 27, 52: 27, 81: 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27},\n\t\t// 90\n\t\t{8: 471},\n\t\t{465},\n\t\t{461},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 455},\n\t\t{441},\n\t\t// 95\n\t\t{354},\n\t\t{8: 353},\n\t\t{8: 352},\n\t\t{2: 350},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 322, 99: 348},\n\t\t// 100\n\t\t{185, 185, 3: 185, 185, 185, 185, 185, 185, 185, 185, 185, 23: 185, 42: 185, 50: 185, 185, 53: 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185},\n\t\t{8: 349},\n\t\t{15, 15, 15, 15, 15, 15, 15, 15, 15, 12: 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 43: 15, 15, 15, 15, 15, 15, 52: 15, 81: 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 98: 15},\n\t\t{8: 351},\n\t\t{16, 16, 16, 16, 16, 16, 16, 16, 16, 12: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 43: 16, 16, 16, 16, 16, 16, 52: 16, 81: 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 98: 16},\n\t\t// 105\n\t\t{17, 17, 17, 17, 17, 17, 17, 17, 17, 12: 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 43: 17, 17, 17, 17, 17, 17, 52: 17, 81: 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 98: 17},\n\t\t{18, 18, 18, 18, 18, 18, 18, 18, 18, 12: 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 43: 18, 18, 18, 18, 18, 18, 52: 18, 81: 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 98: 18},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 355},\n\t\t{9: 357, 356},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 362},\n\t\t// 110\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 359},\n\t\t{42: 360},\n\t\t{19, 19, 19, 19, 19, 19, 19, 19, 19, 12: 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 43: 19, 19, 19, 19, 19, 19, 52: 19, 81: 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 98: 19},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 361},\n\t\t{35, 35, 35, 35, 35, 35, 35, 35, 35, 12: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 43: 35, 35, 35, 35, 35, 35, 52: 35, 81: 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 98: 35},\n\t\t// 115\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 177, 177, 177, 396, 42: 177, 50: 393, 177, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 440},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 439},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 438},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 437},\n\t\t// 120\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 436},\n\t\t{217, 217, 3: 217, 217, 217, 217, 217, 217, 217, 217, 217, 23: 217, 42: 217, 50: 217, 217, 53: 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 435},\n\t\t{215, 215, 3: 215, 215, 215, 215, 215, 215, 215, 215, 215, 23: 215, 42: 215, 50: 215, 215, 53: 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 434},\n\t\t// 125\n\t\t{2: 433},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 432},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 431},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 430},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 429},\n\t\t// 130\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 428},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 427},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 426},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 425},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 424},\n\t\t// 135\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 423},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 422},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 421},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 420},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 9: 241, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 414, 162: 415, 416},\n\t\t// 140\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 413},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 412},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 411},\n\t\t{2: 410},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 409},\n\t\t// 145\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 408},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 407},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 406},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 403},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 401},\n\t\t// 150\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 400},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 399},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 187, 187, 187, 396, 23: 187, 42: 187, 50: 187, 187, 53: 390, 187, 384, 391, 392, 394, 187, 397, 187, 187, 187, 187, 372, 187, 377, 378, 376, 374, 187, 187, 187, 363, 187, 187, 379, 187, 187, 187},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 188, 188, 188, 396, 23: 188, 42: 188, 50: 188, 188, 53: 390, 188, 384, 391, 392, 394, 188, 188, 188, 188, 188, 188, 372, 188, 377, 378, 376, 374, 188, 188, 188, 363, 188, 188, 379, 188, 188, 188},\n\t\t{10: 356, 51: 402},\n\t\t// 155\n\t\t{189, 189, 3: 189, 189, 189, 189, 189, 189, 189, 189, 189, 23: 189, 42: 189, 50: 189, 189, 53: 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189},\n\t\t{10: 356, 42: 404},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 405},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 190, 190, 190, 396, 23: 190, 42: 190, 50: 190, 190, 53: 390, 190, 384, 391, 392, 394, 395, 397, 398, 190, 365, 190, 372, 190, 377, 378, 376, 374, 190, 190, 190, 363, 190, 383, 379, 190, 190, 190},\n\t\t{386, 387, 3: 191, 388, 389, 370, 368, 191, 191, 191, 396, 23: 191, 42: 191, 50: 191, 191, 53: 390, 191, 384, 391, 191, 191, 191, 191, 191, 191, 191, 191, 372, 191, 191, 191, 191, 374, 191, 191, 191, 191, 191, 191, 379, 191, 191, 191},\n\t\t// 160\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 192, 192, 192, 396, 23: 192, 42: 192, 50: 393, 192, 53: 390, 192, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 193, 388, 389, 370, 368, 193, 193, 193, 396, 23: 193, 42: 193, 50: 193, 193, 53: 390, 193, 384, 391, 193, 193, 193, 193, 193, 193, 193, 193, 372, 193, 193, 193, 193, 374, 193, 193, 193, 193, 193, 193, 379, 193, 193, 193},\n\t\t{386, 194, 3: 194, 194, 194, 370, 368, 194, 194, 194, 396, 23: 194, 42: 194, 50: 194, 194, 53: 390, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 372, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, 194},\n\t\t{195, 195, 3: 195, 195, 195, 195, 195, 195, 195, 195, 195, 23: 195, 42: 195, 50: 195, 195, 53: 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195},\n\t\t{386, 387, 3: 196, 196, 196, 370, 368, 196, 196, 196, 396, 23: 196, 42: 196, 50: 196, 196, 53: 390, 196, 384, 391, 196, 196, 196, 196, 196, 196, 196, 196, 372, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196},\n\t\t// 165\n\t\t{386, 387, 3: 197, 197, 197, 370, 368, 197, 197, 197, 396, 23: 197, 42: 197, 50: 197, 197, 53: 390, 197, 384, 391, 197, 197, 197, 197, 197, 197, 197, 197, 372, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, 197},\n\t\t{386, 198, 3: 198, 198, 198, 370, 368, 198, 198, 198, 396, 23: 198, 42: 198, 50: 198, 198, 53: 390, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 372, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, 198},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 9: 243, 243, 396, 50: 393, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{9: 240, 418},\n\t\t{9: 417},\n\t\t// 170\n\t\t{199, 199, 3: 199, 199, 199, 199, 199, 199, 199, 199, 199, 23: 199, 42: 199, 50: 199, 199, 53: 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199, 199},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 419},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 9: 242, 242, 396, 50: 393, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 200, 388, 389, 370, 368, 200, 200, 200, 396, 23: 200, 42: 200, 50: 200, 200, 53: 390, 200, 384, 391, 392, 394, 200, 200, 200, 200, 200, 200, 372, 200, 377, 378, 376, 374, 200, 200, 200, 363, 200, 200, 379, 200, 200, 200},\n\t\t{386, 201, 3: 201, 201, 201, 370, 368, 201, 201, 201, 396, 23: 201, 42: 201, 50: 201, 201, 53: 390, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 372, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, 201},\n\t\t// 175\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 202, 202, 202, 396, 23: 202, 42: 202, 50: 202, 202, 53: 390, 202, 384, 391, 392, 394, 202, 397, 398, 202, 365, 202, 372, 202, 377, 378, 376, 374, 202, 202, 202, 363, 202, 202, 379, 202, 202, 202},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 203, 203, 203, 396, 23: 203, 42: 203, 50: 393, 203, 53: 390, 203, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 204, 204, 204, 396, 23: 204, 42: 204, 50: 393, 204, 53: 390, 204, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 205, 205, 205, 396, 23: 205, 42: 205, 50: 393, 205, 53: 390, 205, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 206, 388, 389, 370, 368, 206, 206, 206, 396, 23: 206, 42: 206, 50: 206, 206, 53: 390, 206, 384, 391, 206, 206, 206, 206, 206, 206, 206, 206, 372, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, 206},\n\t\t// 180\n\t\t{386, 387, 3: 207, 388, 389, 370, 368, 207, 207, 207, 396, 23: 207, 42: 207, 50: 207, 207, 53: 390, 207, 384, 391, 207, 207, 207, 207, 207, 207, 207, 207, 372, 207, 207, 207, 207, 374, 207, 207, 207, 207, 207, 207, 379, 207, 207, 207},\n\t\t{386, 387, 3: 208, 388, 389, 370, 368, 208, 208, 208, 396, 23: 208, 42: 208, 50: 208, 208, 53: 390, 208, 384, 391, 392, 394, 208, 208, 208, 208, 208, 208, 372, 208, 208, 378, 376, 374, 208, 208, 208, 208, 208, 208, 379, 208, 208, 208},\n\t\t{386, 387, 3: 209, 388, 389, 370, 368, 209, 209, 209, 396, 23: 209, 42: 209, 50: 209, 209, 53: 390, 209, 384, 391, 209, 209, 209, 209, 209, 209, 209, 209, 372, 209, 209, 209, 209, 374, 209, 209, 209, 209, 209, 209, 379, 209, 209, 209},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 210, 210, 210, 396, 23: 210, 42: 210, 50: 393, 210, 53: 390, 210, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 211, 388, 389, 370, 368, 211, 211, 211, 396, 23: 211, 42: 211, 50: 211, 211, 53: 390, 211, 384, 391, 211, 211, 211, 211, 211, 211, 211, 211, 372, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211, 211},\n\t\t// 185\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 212, 212, 212, 396, 23: 212, 42: 212, 50: 393, 212, 53: 390, 212, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{213, 213, 3: 213, 213, 213, 213, 213, 213, 213, 213, 213, 23: 213, 42: 213, 50: 213, 213, 53: 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213, 213},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 214, 214, 214, 396, 23: 214, 42: 214, 50: 393, 214, 53: 390, 214, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 216, 216, 216, 396, 23: 216, 42: 216, 50: 393, 216, 53: 390, 216, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 218, 218, 218, 396, 23: 218, 42: 218, 50: 393, 218, 53: 390, 218, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t// 190\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 219, 219, 219, 396, 23: 219, 42: 219, 50: 393, 219, 53: 390, 219, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 220, 220, 220, 396, 23: 220, 42: 220, 50: 220, 220, 53: 390, 220, 384, 391, 392, 394, 220, 397, 398, 220, 220, 220, 372, 220, 377, 378, 376, 374, 220, 220, 220, 363, 220, 220, 379, 220, 220, 220},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 221, 221, 221, 396, 23: 221, 42: 221, 50: 393, 221, 53: 390, 221, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{386, 387, 3: 222, 388, 389, 370, 368, 222, 222, 222, 396, 23: 222, 42: 222, 50: 222, 222, 53: 390, 222, 384, 391, 392, 394, 222, 222, 222, 222, 222, 222, 372, 222, 222, 378, 376, 374, 222, 222, 222, 222, 222, 222, 379, 222, 222, 222},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 315, 92: 255, 322, 273, 277, 274, 256, 99: 443, 101: 293, 253, 254, 113: 442},\n\t\t// 195\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 322, 99: 450},\n\t\t{8: 444},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 322, 99: 445},\n\t\t{8: 446},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 9: 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 322, 99: 447},\n\t\t// 200\n\t\t{9: 448},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 449},\n\t\t{20, 20, 20, 20, 20, 20, 20, 20, 20, 12: 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 43: 20, 20, 20, 20, 20, 20, 52: 20, 81: 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 98: 20},\n\t\t{8: 451},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 9: 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 322, 99: 452},\n\t\t// 205\n\t\t{9: 453},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 454},\n\t\t{21, 21, 21, 21, 21, 21, 21, 21, 21, 12: 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 43: 21, 21, 21, 21, 21, 21, 52: 21, 81: 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 98: 21},\n\t\t{81: 456},\n\t\t{457},\n\t\t// 210\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 458},\n\t\t{9: 459, 356},\n\t\t{8: 460},\n\t\t{22, 22, 22, 22, 22, 22, 22, 22, 22, 12: 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 43: 22, 22, 22, 22, 22, 22, 52: 22, 81: 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 98: 22},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 462},\n\t\t// 215\n\t\t{9: 463, 356},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 464},\n\t\t{23, 23, 23, 23, 23, 23, 23, 23, 23, 12: 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 43: 23, 23, 23, 23, 23, 23, 52: 23, 81: 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 98: 23},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 315, 93: 466},\n\t\t{9: 467, 356},\n\t\t// 220\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 468},\n\t\t{24, 24, 24, 24, 24, 24, 24, 24, 24, 12: 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 43: 24, 24, 24, 24, 24, 24, 52: 24, 81: 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 98: 469},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 470},\n\t\t{25, 25, 25, 25, 25, 25, 25, 25, 25, 12: 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 43: 25, 25, 25, 25, 25, 25, 52: 25, 81: 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 98: 25},\n\t\t{26, 26, 26, 26, 26, 26, 26, 26, 26, 12: 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 43: 26, 26, 26, 26, 26, 26, 52: 26, 81: 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 98: 26},\n\t\t// 225\n\t\t{31, 31, 31, 31, 31, 31, 31, 31, 31, 12: 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 43: 31, 31, 31, 31, 31, 31, 52: 31, 81: 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31},\n\t\t{33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 12: 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 43: 33, 33, 33, 33, 33, 33, 52: 33, 54: 33, 81: 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 98: 33},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 475},\n\t\t{37, 37, 37, 37, 37, 37, 37, 37, 37, 12: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 43: 37, 37, 37, 37, 37, 37, 52: 37, 81: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 98: 37},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 174, 10: 174, 396, 23: 174, 42: 174, 50: 393, 174, 53: 390, 174, 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t// 230\n\t\t{42: 478},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 479},\n\t\t{38, 38, 38, 38, 38, 38, 38, 38, 38, 12: 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 43: 38, 38, 38, 38, 38, 38, 52: 38, 81: 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 98: 38},\n\t\t{309, 310, 317, 308, 311, 312, 304, 303, 176, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 358, 49: 315, 52: 300, 81: 342, 343, 330, 344, 331, 340, 341, 345, 338, 346, 339, 93: 322, 99: 337, 324, 104: 325, 326, 327, 328, 109: 329, 481},\n\t\t{36, 36, 36, 36, 36, 36, 36, 36, 36, 12: 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 43: 36, 36, 36, 36, 36, 36, 52: 36, 81: 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 98: 36},\n\t\t// 235\n\t\t{386, 224, 3: 224, 224, 224, 370, 368, 224, 224, 224, 396, 23: 224, 42: 224, 50: 224, 224, 53: 390, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 372, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224},\n\t\t{386, 225, 3: 225, 225, 225, 370, 368, 225, 225, 225, 396, 23: 225, 42: 225, 50: 225, 225, 53: 390, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 372, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225},\n\t\t{386, 226, 3: 226, 226, 226, 370, 368, 226, 226, 226, 396, 23: 226, 42: 226, 50: 226, 226, 53: 390, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 372, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226, 226},\n\t\t{386, 227, 3: 227, 227, 227, 370, 368, 227, 227, 227, 396, 23: 227, 42: 227, 50: 227, 227, 53: 390, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 372, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, 227},\n\t\t{9: 596},\n\t\t// 240\n\t\t{9: 595, 356},\n\t\t{9: 568},\n\t\t{124, 124, 124, 8: 124, 124, 11: 124, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 124, 92: 489, 94: 273, 277, 274, 490, 114: 566, 150: 567},\n\t\t{124, 124, 124, 8: 124, 124, 11: 124, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 124, 92: 489, 94: 273, 277, 274, 490, 114: 566, 150: 565},\n\t\t{91, 286, 9: 68, 11: 91, 108: 492, 111: 494, 119: 495, 133: 493},\n\t\t// 245\n\t\t{90, 2: 90, 9: 70, 70, 90},\n\t\t{9: 71},\n\t\t{497, 11: 58, 138: 496, 498},\n\t\t{9: 67, 67},\n\t\t{562, 9: 69, 69, 57},\n\t\t// 250\n\t\t{91, 286, 9: 83, 11: 91, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 521, 253, 254, 108: 492, 111: 494, 117: 520, 119: 522, 122: 518, 519, 131: 523},\n\t\t{11: 499},\n\t\t{309, 500, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 24: 281, 282, 283, 43: 504, 49: 501, 51: 180, 92: 502, 118: 503, 129: 505},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 485, 51: 517},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 11: 396, 50: 393, 179, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t// 255\n\t\t{89, 89, 89, 89, 89, 89, 89, 89, 9: 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 24: 89, 89, 89, 43: 89, 51: 89},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 24: 281, 282, 283, 43: 512, 49: 501, 51: 180, 92: 511, 129: 513},\n\t\t{87, 87, 87, 87, 87, 87, 87, 87, 12: 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 24: 281, 282, 283, 92: 502, 118: 507, 125: 508},\n\t\t{51: 506},\n\t\t{61, 9: 61, 61, 61},\n\t\t// 260\n\t\t{86, 86, 86, 86, 86, 86, 86, 86, 9: 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 24: 281, 282, 283, 92: 511},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 509},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 11: 396, 50: 393, 510, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{63, 9: 63, 63, 63},\n\t\t{88, 88, 88, 88, 88, 88, 88, 88, 9: 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 24: 88, 88, 88, 43: 88, 51: 88},\n\t\t// 265\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 515},\n\t\t{51: 514},\n\t\t{59, 9: 59, 59, 59},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 11: 396, 50: 393, 516, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{60, 9: 60, 60, 60},\n\t\t// 270\n\t\t{62, 9: 62, 62, 62},\n\t\t{9: 85, 559},\n\t\t{9: 82},\n\t\t{9: 81, 81},\n\t\t{91, 286, 91, 9: 68, 68, 91, 108: 492, 111: 526, 528, 119: 495, 133: 527},\n\t\t// 275\n\t\t{9: 525},\n\t\t{9: 524},\n\t\t{65, 9: 65, 65, 65},\n\t\t{66, 9: 66, 66, 66},\n\t\t{530, 2: 531, 11: 58, 138: 496, 498, 529},\n\t\t// 280\n\t\t{9: 79, 79},\n\t\t{9: 78, 78},\n\t\t{534, 8: 106, 106, 106, 535, 22: 106, 24: 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 50: 106, 52: 106},\n\t\t{91, 286, 91, 9: 83, 11: 91, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 521, 253, 254, 108: 492, 111: 526, 532, 117: 520, 119: 522, 122: 518, 519, 131: 523},\n\t\t{94, 8: 94, 94, 94, 94, 22: 94, 24: 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 50: 94, 52: 94},\n\t\t// 285\n\t\t{9: 533},\n\t\t{103, 8: 103, 103, 103, 103, 22: 103, 24: 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 50: 103, 52: 103},\n\t\t{2: 102, 9: 102, 22: 100, 24: 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 43: 100, 100, 100, 100, 100, 100, 157: 549, 550},\n\t\t{87, 87, 87, 87, 87, 87, 87, 87, 12: 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 24: 281, 282, 283, 43: 536, 51: 87, 92: 502, 118: 537, 125: 538},\n\t\t{87, 87, 87, 87, 87, 87, 87, 87, 12: 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 24: 281, 282, 283, 92: 502, 118: 507, 125: 546},\n\t\t// 290\n\t\t{86, 86, 86, 86, 86, 86, 86, 86, 12: 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 24: 281, 282, 283, 43: 543, 51: 86, 92: 511},\n\t\t{309, 539, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 501, 51: 180, 129: 540},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 485, 51: 542},\n\t\t{51: 541},\n\t\t{95, 8: 95, 95, 95, 95, 22: 95, 24: 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 50: 95, 52: 95},\n\t\t// 295\n\t\t{96, 8: 96, 96, 96, 96, 22: 96, 24: 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 50: 96, 52: 96},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 544},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 11: 396, 50: 393, 545, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{97, 8: 97, 97, 97, 97, 22: 97, 24: 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 50: 97, 52: 97},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 547},\n\t\t// 300\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 11: 396, 50: 393, 548, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{98, 8: 98, 98, 98, 98, 22: 98, 24: 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 50: 98, 52: 98},\n\t\t{2: 554, 9: 75, 170: 555, 553},\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 521, 253, 254, 117: 520, 122: 518, 551},\n\t\t{9: 552},\n\t\t// 305\n\t\t{99, 8: 99, 99, 99, 99, 22: 99, 24: 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 50: 99, 52: 99},\n\t\t{9: 558},\n\t\t{9: 77, 77},\n\t\t{9: 74, 556},\n\t\t{2: 557},\n\t\t// 310\n\t\t{9: 76, 76},\n\t\t{101, 8: 101, 101, 101, 101, 22: 101, 24: 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 50: 101, 52: 101},\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 521, 253, 254, 117: 561, 167: 560},\n\t\t{9: 84},\n\t\t{9: 80, 80},\n\t\t// 315\n\t\t{9: 83, 22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 92: 255, 94: 273, 277, 274, 256, 101: 521, 253, 254, 117: 520, 122: 518, 519, 131: 563},\n\t\t{9: 564},\n\t\t{64, 9: 64, 64, 64},\n\t\t{125, 125, 125, 8: 125, 125, 11: 125, 42: 125},\n\t\t{123, 123, 123, 8: 123, 123, 11: 123, 42: 123},\n\t\t// 320\n\t\t{126, 126, 126, 8: 126, 126, 11: 126, 42: 126},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 570, 52: 569},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 10: 54, 579, 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 23: 54, 49: 572, 52: 573, 578, 115: 574, 121: 577, 127: 575, 576, 149: 571},\n\t\t{386, 228, 3: 228, 228, 228, 370, 368, 228, 228, 228, 396, 23: 228, 42: 228, 50: 228, 228, 53: 390, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 372, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, 228},\n\t\t{10: 587, 23: 118, 126: 593},\n\t\t// 325\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 55, 10: 55, 396, 23: 55, 50: 393, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 10: 54, 579, 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 23: 54, 49: 572, 52: 573, 578, 115: 574, 121: 577, 127: 575, 576, 149: 586},\n\t\t{10: 53, 23: 53},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 572, 52: 573, 115: 585},\n\t\t{11: 579, 50: 583, 53: 578, 121: 584},\n\t\t// 330\n\t\t{11: 48, 50: 48, 53: 48},\n\t\t{2: 582},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 476, 116: 580},\n\t\t{51: 581},\n\t\t{11: 45, 50: 45, 53: 45},\n\t\t// 335\n\t\t{11: 46, 50: 46, 53: 46},\n\t\t{49, 49, 49, 49, 49, 49, 49, 49, 12: 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 52: 49},\n\t\t{11: 47, 50: 47, 53: 47},\n\t\t{10: 52, 23: 52},\n\t\t{10: 587, 23: 118, 126: 588},\n\t\t// 340\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 11: 579, 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 23: 117, 49: 572, 52: 573, 578, 115: 590, 121: 577, 127: 591, 576},\n\t\t{23: 589},\n\t\t{8: 56, 10: 56, 23: 56},\n\t\t{10: 51, 23: 51},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 572, 52: 573, 115: 592},\n\t\t// 345\n\t\t{10: 50, 23: 50},\n\t\t{23: 594},\n\t\t{229, 229, 3: 229, 229, 229, 229, 229, 229, 229, 229, 229, 23: 229, 42: 229, 50: 229, 229, 53: 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, 229},\n\t\t{230, 230, 3: 230, 230, 230, 230, 230, 230, 230, 230, 230, 23: 230, 42: 230, 50: 230, 230, 53: 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230},\n\t\t{231, 231, 3: 231, 231, 231, 231, 231, 231, 231, 231, 231, 23: 231, 42: 231, 50: 231, 231, 53: 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, 231},\n\t\t// 350\n\t\t{386, 232, 3: 232, 232, 232, 370, 368, 232, 232, 232, 396, 23: 232, 42: 232, 50: 232, 232, 53: 390, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 372, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232},\n\t\t{386, 233, 3: 233, 233, 233, 370, 368, 233, 233, 233, 396, 23: 233, 42: 233, 50: 233, 233, 53: 390, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 372, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233, 233},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 49: 315, 52: 300, 92: 489, 487, 273, 277, 274, 490, 100: 486, 114: 491, 124: 601},\n\t\t{386, 234, 3: 234, 234, 234, 370, 368, 234, 234, 234, 396, 23: 234, 42: 234, 50: 234, 234, 53: 390, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 372, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234},\n\t\t{9: 602},\n\t\t// 355\n\t\t{309, 235, 347, 235, 235, 235, 304, 303, 235, 235, 235, 235, 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 23: 235, 42: 235, 49: 570, 235, 235, 569, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, 235},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 49: 315, 52: 300, 92: 489, 487, 273, 277, 274, 490, 100: 486, 114: 491, 124: 605},\n\t\t{386, 236, 3: 236, 236, 236, 370, 368, 236, 236, 236, 396, 23: 236, 42: 236, 50: 236, 236, 53: 390, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 372, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236, 236},\n\t\t{9: 606},\n\t\t{309, 237, 347, 237, 237, 237, 304, 303, 237, 237, 237, 237, 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 23: 237, 42: 237, 49: 570, 237, 237, 569, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237, 237},\n\t\t// 360\n\t\t{386, 238, 3: 238, 238, 238, 370, 368, 238, 238, 238, 396, 23: 238, 42: 238, 50: 238, 238, 53: 390, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 372, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238},\n\t\t{386, 239, 3: 239, 239, 239, 370, 368, 239, 239, 239, 396, 23: 239, 42: 239, 50: 239, 239, 53: 390, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 372, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239, 239},\n\t\t{8: 173, 153: 617},\n\t\t{8: 165, 10: 165},\n\t\t{8: 162, 10: 615},\n\t\t// 365\n\t\t{8: 161, 10: 161, 50: 613},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 572, 52: 573, 115: 614},\n\t\t{8: 160, 10: 160},\n\t\t{91, 286, 91, 108: 287, 111: 285, 612, 130: 616},\n\t\t{8: 164, 10: 164},\n\t\t// 370\n\t\t{8: 618},\n\t\t{172, 172, 172, 172, 172, 172, 172, 172, 172, 12: 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 43: 172, 172, 172, 172, 172, 172, 52: 172, 54: 172, 81: 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172},\n\t\t{93, 286, 93, 9: 93, 93, 93, 108: 620},\n\t\t{92, 2: 92, 9: 92, 92, 92},\n\t\t{91, 286, 91, 108: 287, 111: 285, 532},\n\t\t// 375\n\t\t{116, 116, 116, 8: 116, 116, 116, 116, 22: 116, 24: 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 52: 72},\n\t\t{52: 624},\n\t\t{2: 625, 141: 628, 627, 168: 626},\n\t\t{10: 244, 23: 244, 50: 244},\n\t\t{10: 631, 23: 118, 126: 632},\n\t\t// 380\n\t\t{10: 114, 23: 114},\n\t\t{10: 112, 23: 112, 50: 629},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 476, 116: 630},\n\t\t{10: 111, 23: 111},\n\t\t{2: 625, 23: 117, 141: 628, 634},\n\t\t// 385\n\t\t{23: 633},\n\t\t{115, 115, 115, 8: 115, 115, 115, 115, 22: 115, 24: 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115},\n\t\t{10: 113, 23: 113},\n\t\t{138, 138, 138, 8: 138, 138, 138, 138, 22: 138, 24: 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 138, 52: 72},\n\t\t{52: 637},\n\t\t// 390\n\t\t{22: 135, 137, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 135, 154: 638, 639},\n\t\t{23: 656},\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 92: 489, 94: 273, 277, 274, 490, 114: 642, 151: 641, 173: 640},\n\t\t{22: 275, 134, 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 92: 489, 94: 273, 277, 274, 490, 114: 642, 151: 654, 156: 653},\n\t\t{22: 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130},\n\t\t// 395\n\t\t{91, 286, 91, 8: 644, 42: 105, 108: 287, 111: 285, 646, 137: 647, 152: 645, 174: 643},\n\t\t{8: 650, 10: 651},\n\t\t{22: 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127},\n\t\t{8: 122, 10: 122},\n\t\t{8: 120, 10: 120, 42: 104},\n\t\t// 400\n\t\t{42: 648},\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 49: 476, 116: 649},\n\t\t{8: 119, 10: 119},\n\t\t{22: 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},\n\t\t{91, 286, 91, 42: 105, 108: 287, 111: 285, 646, 137: 647, 152: 652},\n\t\t// 405\n\t\t{8: 121, 10: 121},\n\t\t{23: 655},\n\t\t{22: 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129},\n\t\t{133, 133, 133, 8: 133, 133, 133, 133, 22: 133, 24: 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133},\n\t\t{136, 136, 136, 8: 136, 136, 136, 136, 22: 136, 24: 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, 136},\n\t\t// 410\n\t\t{309, 310, 347, 308, 311, 312, 304, 303, 12: 307, 313, 305, 314, 316, 318, 319, 320, 306, 321, 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 49: 658, 92: 489, 94: 273, 277, 274, 490, 114: 491, 124: 659},\n\t\t{386, 387, 3: 385, 388, 389, 370, 368, 9: 661, 11: 396, 50: 393, 53: 390, 55: 384, 391, 392, 394, 395, 397, 398, 369, 365, 366, 372, 373, 377, 378, 376, 374, 375, 364, 367, 363, 382, 383, 379, 380, 371, 381},\n\t\t{9: 660},\n\t\t{139, 139, 139, 8: 139, 139, 139, 139, 22: 139, 24: 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139},\n\t\t{140, 140, 140, 8: 140, 140, 140, 140, 22: 140, 24: 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140},\n\t\t// 415\n\t\t{168, 168, 168, 8: 168, 168, 168, 168},\n\t\t{166, 166, 166, 8: 166, 166, 166, 166},\n\t\t{169, 169, 169, 8: 169, 169, 169, 169},\n\t\t{170, 170, 170, 8: 170, 170, 170, 170},\n\t\t{171, 171, 171, 8: 171, 171, 171, 171},\n\t\t// 420\n\t\t{8: 161, 10: 161, 22: 10, 24: 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 43: 10, 10, 10, 10, 10, 10, 50: 613, 52: 10, 160: 668},\n\t\t{22: 275, 24: 281, 282, 283, 262, 264, 263, 265, 280, 266, 267, 268, 269, 270, 278, 276, 279, 271, 272, 43: 260, 257, 258, 284, 259, 261, 52: 2, 92: 255, 94: 273, 277, 274, 256, 101: 293, 253, 254, 113: 295, 135: 296, 669},\n\t\t{52: 6, 132: 299, 144: 670},\n\t\t{9, 9, 9, 22: 9, 24: 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 43: 9, 9, 9, 9, 9, 9, 54: 9},\n\t\t{13, 13, 13, 22: 13, 24: 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 43: 13, 13, 13, 13, 13, 13, 54: 13},\n\t\t// 425\n\t\t{54: 246},\n\t}\n)\n\nvar yyDebug = 0\n\ntype yyLexer interface {\n\tLex(lval *yySymType) int\n\tError(s string)\n}\n\ntype yyLexerEx interface {\n\tyyLexer\n\tReduced(rule, state int, lval *yySymType) bool\n}\n\nfunc yySymName(c int) (s string) {\n\tx, ok := yyXLAT[c]\n\tif ok {\n\t\treturn yySymNames[x]\n\t}\n\n\tif c < 0x7f {\n\t\treturn __yyfmt__.Sprintf(\"%q\", c)\n\t}\n\n\treturn __yyfmt__.Sprintf(\"%d\", c)\n}\n\nfunc yylex1(yylex yyLexer, lval *yySymType) (n int) {\n\tn = yylex.Lex(lval)\n\tif n <= 0 {\n\t\tn = yyEofCode\n\t}\n\tif yyDebug >= 3 {\n\t\t__yyfmt__.Printf(\"\\nlex %s(%#x %d), PrettyString(lval.Token): %v\\n\", yySymName(n), n, n, PrettyString(lval.Token))\n\t}\n\treturn n\n}\n\nfunc yyParse(yylex yyLexer) int {\n\tconst yyError = 179\n\n\tyyEx, _ := yylex.(yyLexerEx)\n\tvar yyn int\n\tvar yylval yySymType\n\tvar yyVAL yySymType\n\tp := yyPool.Get().(*[]yySymType)\n\tyyS := *p\n\n\tdefer func() {\n\t\tvar v yySymType\n\t\tfor i := range yyS {\n\t\t\tyyS[i] = v\n\t\t}\n\t\tyyPool.Put(p)\n\t}()\n\n\tNerrs := 0   /* number of errors */\n\tErrflag := 0 /* error recovery flag */\n\tyyerrok := func() {\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Printf(\"yyerrok()\\n\")\n\t\t}\n\t\tErrflag = 0\n\t}\n\t_ = yyerrok\n\tyystate := 0\n\tyychar := -1\n\tvar yyxchar int\n\tvar yyshift int\n\tyyp := -1\n\tgoto yystack\n\nret0:\n\treturn 0\n\nret1:\n\treturn 1\n\nyystack:\n\t/* put a state and value onto the stack */\n\tyyp++\n\tif yyp >= len(yyS) {\n\t\tnyys := make([]yySymType, len(yyS)*2)\n\t\tcopy(nyys, yyS)\n\t\tyyS = nyys\n\t}\n\tyyS[yyp] = yyVAL\n\tyyS[yyp].yys = yystate\n\nyynewstate:\n\tif yychar < 0 {\n\t\tyylval.yys = yystate\n\t\tyychar = yylex1(yylex, &yylval)\n\t\tvar ok bool\n\t\tif yyxchar, ok = yyXLAT[yychar]; !ok {\n\t\t\tyyxchar = len(yySymNames) // > tab width\n\t\t}\n\t}\n\tif yyDebug >= 4 {\n\t\tvar a []int\n\t\tfor _, v := range yyS[:yyp+1] {\n\t\t\ta = append(a, v.yys)\n\t\t}\n\t\t__yyfmt__.Printf(\"state stack %v\\n\", a)\n\t}\n\trow := yyParseTab[yystate]\n\tyyn = 0\n\tif yyxchar < len(row) {\n\t\tif yyn = int(row[yyxchar]); yyn != 0 {\n\t\t\tyyn += yyTabOfs\n\t\t}\n\t}\n\tswitch {\n\tcase yyn > 0: // shift\n\t\tyychar = -1\n\t\tyyVAL = yylval\n\t\tyystate = yyn\n\t\tyyshift = yyn\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Printf(\"shift, and goto state %d\\n\", yystate)\n\t\t}\n\t\tif Errflag > 0 {\n\t\t\tErrflag--\n\t\t}\n\t\tgoto yystack\n\tcase yyn < 0: // reduce\n\tcase yystate == 1: // accept\n\t\tif yyDebug >= 2 {\n\t\t\t__yyfmt__.Println(\"accept\")\n\t\t}\n\t\tgoto ret0\n\t}\n\n\tif yyn == 0 {\n\t\t/* error ... attempt to resume parsing */\n\t\tswitch Errflag {\n\t\tcase 0: /* brand new error */\n\t\t\tif yyDebug >= 1 {\n\t\t\t\t__yyfmt__.Printf(\"no action for %s in state %d\\n\", yySymName(yychar), yystate)\n\t\t\t}\n\t\t\tmsg, ok := yyXErrors[yyXError{yystate, yyxchar}]\n\t\t\tif !ok {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yystate, -1}]\n\t\t\t}\n\t\t\tif !ok && yyshift != 0 {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yyshift, yyxchar}]\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\tmsg, ok = yyXErrors[yyXError{yyshift, -1}]\n\t\t\t}\n\t\t\tif yychar > 0 {\n\t\t\t\tls := yyTokenLiteralStrings[yychar]\n\t\t\t\tif ls == \"\" {\n\t\t\t\t\tls = yySymName(yychar)\n\t\t\t\t}\n\t\t\t\tif ls != \"\" {\n\t\t\t\t\tswitch {\n\t\t\t\t\tcase msg == \"\":\n\t\t\t\t\t\tmsg = __yyfmt__.Sprintf(\"unexpected %s\", ls)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tmsg = __yyfmt__.Sprintf(\"unexpected %s, %s\", ls, msg)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif msg == \"\" {\n\t\t\t\tmsg = \"syntax error\"\n\t\t\t}\n\t\t\tyylex.Error(msg)\n\t\t\tNerrs++\n\t\t\tfallthrough\n\n\t\tcase 1, 2: /* incompletely recovered error ... try again */\n\t\t\tErrflag = 3\n\n\t\t\t/* find a state where \"error\" is a legal shift action */\n\t\t\tfor yyp >= 0 {\n\t\t\t\trow := yyParseTab[yyS[yyp].yys]\n\t\t\t\tif yyError < len(row) {\n\t\t\t\t\tyyn = int(row[yyError]) + yyTabOfs\n\t\t\t\t\tif yyn > 0 { // hit\n\t\t\t\t\t\tif yyDebug >= 2 {\n\t\t\t\t\t\t\t__yyfmt__.Printf(\"error recovery found error shift in state %d\\n\", yyS[yyp].yys)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyystate = yyn /* simulate a shift of \"error\" */\n\t\t\t\t\t\tgoto yystack\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* the current p has no shift on \"error\", pop stack */\n\t\t\t\tif yyDebug >= 2 {\n\t\t\t\t\t__yyfmt__.Printf(\"error recovery pops state %d\\n\", yyS[yyp].yys)\n\t\t\t\t}\n\t\t\t\tyyp--\n\t\t\t}\n\t\t\t/* there is no state on the stack with an error shift ... abort */\n\t\t\tif yyDebug >= 2 {\n\t\t\t\t__yyfmt__.Printf(\"error recovery failed\\n\")\n\t\t\t}\n\t\t\tgoto ret1\n\n\t\tcase 3: /* no shift yet; clobber input char */\n\t\t\tif yyDebug >= 2 {\n\t\t\t\t__yyfmt__.Printf(\"error recovery discards %s\\n\", yySymName(yychar))\n\t\t\t}\n\t\t\tif yychar == yyEofCode {\n\t\t\t\tgoto ret1\n\t\t\t}\n\n\t\t\tyychar = -1\n\t\t\tgoto yynewstate /* try again in the same state */\n\t\t}\n\t}\n\n\tr := -yyn\n\tx0 := yyReductions[r]\n\tx, n := x0.xsym, x0.components\n\tyypt := yyp\n\t_ = yypt // guard against \"declared and not used\"\n\n\tyyp -= n\n\tif yyp+1 >= len(yyS) {\n\t\tnyys := make([]yySymType, len(yyS)*2)\n\t\tcopy(nyys, yyS)\n\t\tyyS = nyys\n\t}\n\tyyVAL = yyS[yyp+1]\n\n\t/* consult goto table to find next state */\n\texState := yystate\n\tyystate = int(yyParseTab[yyS[yyp].yys][x]) + yyTabOfs\n\t/* reduction by production r */\n\tif yyDebug >= 2 {\n\t\t__yyfmt__.Printf(\"reduce using rule %v (%s), and goto state %d\\n\", r, yySymNames[x], yystate)\n\t}\n\n\tswitch r {\n\tcase 1:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.ast = yyS[yypt-0].node\n\t\t}\n\tcase 2:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.ast = &TranslationUnit{\n\t\t\t\tExternalDeclarationList: yyS[yypt-0].node.(*ExternalDeclarationList).reverse(),\n\t\t\t\tFileScope:               lx.scope,\n\t\t\t\tFileSet:                 fset,\n\t\t\t\tModel:                   lx.model,\n\t\t\t}\n\t\t}\n\tcase 3:\n\t\t{\n\t\t\tyyVAL.node = &EnumerationConstant{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 4:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExprList{\n\t\t\t\tExpr: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 5:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExprList{\n\t\t\t\tCase:             1,\n\t\t\t\tArgumentExprList: yyS[yypt-2].node.(*ArgumentExprList),\n\t\t\t\tToken:            yyS[yypt-1].Token,\n\t\t\t\tExpr:             yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 6:\n\t\t{\n\t\t\tyyVAL.node = (*ArgumentExprListOpt)(nil)\n\t\t}\n\tcase 7:\n\t\t{\n\t\t\tyyVAL.node = &ArgumentExprListOpt{\n\t\t\t\tArgumentExprList: yyS[yypt-0].node.(*ArgumentExprList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 8:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprPreInc,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 9:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprPreDec,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 10:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprAlignofType,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 11:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAlignofExpr,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 12:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprSizeofType,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 13:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprSizeofExpr,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 14:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprNot,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 15:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAddrof,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 16:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:         ExprStatement,\n\t\t\t\tToken:        yyS[yypt-2].Token,\n\t\t\t\tCompoundStmt: yyS[yypt-1].node.(*CompoundStmt),\n\t\t\t\tToken2:       yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 17:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprPExprList,\n\t\t\t\tToken:    yyS[yypt-2].Token,\n\t\t\t\tExprList: yyS[yypt-1].node.(*ExprList).reverse(),\n\t\t\t\tToken2:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 18:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expr{\n\t\t\t\tCase:            ExprCompLit,\n\t\t\t\tToken:           yyS[yypt-6].Token,\n\t\t\t\tTypeName:        yyS[yypt-5].node.(*TypeName),\n\t\t\t\tToken2:          yyS[yypt-4].Token,\n\t\t\t\tToken3:          yyS[yypt-3].Token,\n\t\t\t\tInitializerList: yyS[yypt-2].node.(*InitializerList).reverse(),\n\t\t\t\tCommaOpt:        yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken4:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Scope = lx.scope\n\t\t}\n\tcase 19:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprCast,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tTypeName: yyS[yypt-2].node.(*TypeName),\n\t\t\t\tToken2:   yyS[yypt-1].Token,\n\t\t\t\tExpr:     yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 20:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprDeref,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 21:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprUnaryPlus,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 22:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprUnaryMinus,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 23:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprCpl,\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr:  yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 24:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprChar,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 25:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprNe,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 26:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprModAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 27:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLAnd,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 28:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAndAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 29:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprMulAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 30:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprPostInc,\n\t\t\t\tExpr:  yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 31:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAddAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 32:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprPostDec,\n\t\t\t\tExpr:  yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 33:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprSubAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 34:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:   ExprPSelect,\n\t\t\t\tExpr:   yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 35:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprDivAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 36:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLsh,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 37:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLshAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 38:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLe,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 39:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprEq,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 40:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprGe,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 41:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprRsh,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 42:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprRshAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 43:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprXorAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 44:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprOrAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 45:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLOr,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 46:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprMod,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 47:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAnd,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 48:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:                ExprCall,\n\t\t\t\tExpr:                yyS[yypt-3].node.(*Expr),\n\t\t\t\tToken:               yyS[yypt-2].Token,\n\t\t\t\tArgumentExprListOpt: yyS[yypt-1].node.(*ArgumentExprListOpt),\n\t\t\t\tToken2:              yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 49:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprMul,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 50:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAdd,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 51:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprSub,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 52:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:   ExprSelect,\n\t\t\t\tExpr:   yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 53:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprDiv,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 54:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLt,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 55:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprAssign,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 56:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprGt,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 57:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprCond,\n\t\t\t\tExpr:     yyS[yypt-4].node.(*Expr),\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList).reverse(),\n\t\t\t\tToken2:   yyS[yypt-1].Token,\n\t\t\t\tExpr2:    yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 58:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:     ExprIndex,\n\t\t\t\tExpr:     yyS[yypt-3].node.(*Expr),\n\t\t\t\tToken:    yyS[yypt-2].Token,\n\t\t\t\tExprList: yyS[yypt-1].node.(*ExprList).reverse(),\n\t\t\t\tToken2:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 59:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprXor,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 60:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprOr,\n\t\t\t\tExpr:  yyS[yypt-2].node.(*Expr),\n\t\t\t\tToken: yyS[yypt-1].Token,\n\t\t\t\tExpr2: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 61:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprFloat,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 62:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Expr{\n\t\t\t\tCase:  ExprIdent,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Scope = lx.scope\n\t\t}\n\tcase 63:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprInt,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 64:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLChar,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 65:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprLString,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 66:\n\t\t{\n\t\t\tyyVAL.node = &Expr{\n\t\t\t\tCase:  ExprString,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 67:\n\t\t{\n\t\t\tyyVAL.node = (*ExprOpt)(nil)\n\t\t}\n\tcase 68:\n\t\t{\n\t\t\tyyVAL.node = &ExprOpt{\n\t\t\t\tExpr: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 69:\n\t\t{\n\t\t\tyyVAL.node = &ExprList{\n\t\t\t\tExpr: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 70:\n\t\t{\n\t\t\tyyVAL.node = &ExprList{\n\t\t\t\tCase:     1,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList),\n\t\t\t\tToken:    yyS[yypt-1].Token,\n\t\t\t\tExpr:     yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 71:\n\t\t{\n\t\t\tyyVAL.node = (*ExprListOpt)(nil)\n\t\t}\n\tcase 72:\n\t\t{\n\t\t\tyyVAL.node = &ExprListOpt{\n\t\t\t\tExprList: yyS[yypt-0].node.(*ExprList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 73:\n\t\t{\n\t\t\tyyVAL.node = &ConstExpr{\n\t\t\t\tExpr: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 74:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.attr2 = lx.attr\n\t\t}\n\tcase 75:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Declaration{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-3].node.(*DeclarationSpecifiers),\n\t\t\t\tInitDeclaratorListOpt: yyS[yypt-2].node.(*InitDeclaratorListOpt),\n\t\t\t\tToken:                 yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Scope = lx.scope\n\t\t\tif len(lx.attr2) != 0 {\n\t\t\t\tlhs.Attributes = lx.attrs()\n\t\t\t}\n\t\t\tlx.scope.typedef = false\n\t\t}\n\tcase 76:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationSpecifiers{\n\t\t\t\tCase:                     DeclarationSpecifiersFunc,\n\t\t\t\tFunctionSpecifier:        yyS[yypt-1].node.(*FunctionSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t}\n\tcase 77:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationSpecifiers{\n\t\t\t\tCase:                     DeclarationSpecifiersStorage,\n\t\t\t\tStorageClassSpecifier:    yyS[yypt-1].node.(*StorageClassSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t}\n\tcase 78:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationSpecifiers{\n\t\t\t\tCase:                     DeclarationSpecifiersQualifier,\n\t\t\t\tTypeQualifier:            yyS[yypt-1].node.(*TypeQualifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t}\n\tcase 79:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationSpecifiers{\n\t\t\t\tCase:                     DeclarationSpecifiersSpecifier,\n\t\t\t\tTypeSpecifier:            yyS[yypt-1].node.(*TypeSpecifier),\n\t\t\t\tDeclarationSpecifiersOpt: yyS[yypt-0].node.(*DeclarationSpecifiersOpt),\n\t\t\t}\n\t\t}\n\tcase 80:\n\t\t{\n\t\t\tyyVAL.node = (*DeclarationSpecifiersOpt)(nil)\n\t\t}\n\tcase 81:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationSpecifiersOpt{\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-0].node.(*DeclarationSpecifiers),\n\t\t\t}\n\t\t}\n\tcase 82:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorList{\n\t\t\t\tInitDeclarator: yyS[yypt-0].node.(*InitDeclarator),\n\t\t\t}\n\t\t}\n\tcase 83:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorList{\n\t\t\t\tCase:               1,\n\t\t\t\tInitDeclaratorList: yyS[yypt-2].node.(*InitDeclaratorList),\n\t\t\t\tToken:              yyS[yypt-1].Token,\n\t\t\t\tInitDeclarator:     yyS[yypt-0].node.(*InitDeclarator),\n\t\t\t}\n\t\t}\n\tcase 84:\n\t\t{\n\t\t\tyyVAL.node = (*InitDeclaratorListOpt)(nil)\n\t\t}\n\tcase 85:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclaratorListOpt{\n\t\t\t\tInitDeclaratorList: yyS[yypt-0].node.(*InitDeclaratorList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 86:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclarator{\n\t\t\t\tCase:       InitDeclaratorBase,\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t}\n\tcase 87:\n\t\t{\n\t\t\tyyVAL.node = &InitDeclarator{\n\t\t\t\tCase:        InitDeclaratorInit,\n\t\t\t\tDeclarator:  yyS[yypt-2].node.(*Declarator),\n\t\t\t\tToken:       yyS[yypt-1].Token,\n\t\t\t\tInitializer: yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 88:\n\t\t{\n\t\t\tyyVAL.node = &StorageClassSpecifier{\n\t\t\t\tCase:  StorageClassSpecifierAuto,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 89:\n\t\t{\n\t\t\tyyVAL.node = &StorageClassSpecifier{\n\t\t\t\tCase:  StorageClassSpecifierExtern,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 90:\n\t\t{\n\t\t\tyyVAL.node = &StorageClassSpecifier{\n\t\t\t\tCase:  StorageClassSpecifierRegister,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 91:\n\t\t{\n\t\t\tyyVAL.node = &StorageClassSpecifier{\n\t\t\t\tCase:  StorageClassSpecifierStatic,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 92:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &StorageClassSpecifier{\n\t\t\t\tCase:  StorageClassSpecifierTypedef,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tlx.scope.typedef = true\n\t\t}\n\tcase 93:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierBool,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 94:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierComplex,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 95:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierChar,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 96:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierDouble,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 97:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierFloat,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 98:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierInt,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 99:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierLong,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 100:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierShort,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 101:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierSigned,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 102:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierUnsigned,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 103:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierVoid,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 104:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:          TypeSpecifierEnum,\n\t\t\t\tEnumSpecifier: yyS[yypt-0].node.(*EnumSpecifier),\n\t\t\t}\n\t\t}\n\tcase 105:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:                   TypeSpecifierStruct,\n\t\t\t\tStructOrUnionSpecifier: yyS[yypt-0].node.(*StructOrUnionSpecifier),\n\t\t\t}\n\t\t}\n\tcase 106:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &TypeSpecifier{\n\t\t\t\tCase:  TypeSpecifierName,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 107:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:   TypeSpecifierTypeofExpr,\n\t\t\t\tToken:  yyS[yypt-3].Token,\n\t\t\t\tToken2: yyS[yypt-2].Token,\n\t\t\t\tExpr:   yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 108:\n\t\t{\n\t\t\tyyVAL.node = &TypeSpecifier{\n\t\t\t\tCase:     TypeSpecifierTypeof,\n\t\t\t\tToken:    yyS[yypt-3].Token,\n\t\t\t\tToken2:   yyS[yypt-2].Token,\n\t\t\t\tTypeName: yyS[yypt-1].node.(*TypeName),\n\t\t\t\tToken3:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 109:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructOrUnionSpecifier{\n\t\t\t\tCase:          StructOrUnionSpecifierTag,\n\t\t\t\tStructOrUnion: yyS[yypt-1].node.(*StructOrUnion),\n\t\t\t\tToken:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 110:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.noTypedefName = true // https://github.com/cznic/sqlite2go/issues/9\n\t\t}\n\tcase 111:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &StructOrUnionSpecifier{\n\t\t\t\tCase:          StructOrUnionSpecifierEmpty,\n\t\t\t\tStructOrUnion: yyS[yypt-4].node.(*StructOrUnion),\n\t\t\t\tIdentifierOpt: yyS[yypt-3].node.(*IdentifierOpt),\n\t\t\t\tToken:         yyS[yypt-2].Token,\n\t\t\t\tToken2:        yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tif !lx.tweaks.EnableEmptyStructs {\n\t\t\t\tlx.err(yyS[yypt-4].node, \"empty structs/unions not allowed\")\n\t\t\t}\n\t\t}\n\tcase 112:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.newStructScope()\n\t\t}\n\tcase 113:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.noTypedefName = true // https://github.com/cznic/sqlite2go/issues/9\n\t\t}\n\tcase 114:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &StructOrUnionSpecifier{\n\t\t\t\tCase:                  StructOrUnionSpecifierDefine,\n\t\t\t\tStructOrUnion:         yyS[yypt-6].node.(*StructOrUnion),\n\t\t\t\tIdentifierOpt:         yyS[yypt-5].node.(*IdentifierOpt),\n\t\t\t\tToken:                 yyS[yypt-4].Token,\n\t\t\t\tStructDeclarationList: yyS[yypt-2].node.(*StructDeclarationList).reverse(),\n\t\t\t\tToken2:                yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope, _ = lx.popScope()\n\t\t}\n\tcase 115:\n\t\t{\n\t\t\tyyVAL.node = &StructOrUnion{\n\t\t\t\tCase:  StructOrUnionStruct,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 116:\n\t\t{\n\t\t\tyyVAL.node = &StructOrUnion{\n\t\t\t\tCase:  StructOrUnionUnion,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 117:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarationList{\n\t\t\t\tStructDeclaration: yyS[yypt-0].node.(*StructDeclaration),\n\t\t\t}\n\t\t}\n\tcase 118:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarationList{\n\t\t\t\tCase:                  1,\n\t\t\t\tStructDeclarationList: yyS[yypt-1].node.(*StructDeclarationList),\n\t\t\t\tStructDeclaration:     yyS[yypt-0].node.(*StructDeclaration),\n\t\t\t}\n\t\t}\n\tcase 119:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaration{\n\t\t\t\tCase:                   StructDeclarationBase,\n\t\t\t\tSpecifierQualifierList: yyS[yypt-2].node.(*SpecifierQualifierList),\n\t\t\t\tStructDeclaratorList:   yyS[yypt-1].node.(*StructDeclaratorList).reverse(),\n\t\t\t\tToken:                  yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 120:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &StructDeclaration{\n\t\t\t\tCase:                   StructDeclarationAnon,\n\t\t\t\tSpecifierQualifierList: yyS[yypt-1].node.(*SpecifierQualifierList),\n\t\t\t\tToken:                  yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tif !lx.tweaks.EnableAnonymousStructFields {\n\t\t\t\tlx.err(yyS[yypt-1].node, \"anonymous structs/unions members not allowed\")\n\t\t\t}\n\t\t}\n\tcase 121:\n\t\t{\n\t\t\tyyVAL.node = &SpecifierQualifierList{\n\t\t\t\tCase:                      SpecifierQualifierListQualifier,\n\t\t\t\tTypeQualifier:             yyS[yypt-1].node.(*TypeQualifier),\n\t\t\t\tSpecifierQualifierListOpt: yyS[yypt-0].node.(*SpecifierQualifierListOpt),\n\t\t\t}\n\t\t}\n\tcase 122:\n\t\t{\n\t\t\tyyVAL.node = &SpecifierQualifierList{\n\t\t\t\tCase:                      SpecifierQualifierListSpecifier,\n\t\t\t\tTypeSpecifier:             yyS[yypt-1].node.(*TypeSpecifier),\n\t\t\t\tSpecifierQualifierListOpt: yyS[yypt-0].node.(*SpecifierQualifierListOpt),\n\t\t\t}\n\t\t}\n\tcase 123:\n\t\t{\n\t\t\tyyVAL.node = (*SpecifierQualifierListOpt)(nil)\n\t\t}\n\tcase 124:\n\t\t{\n\t\t\tyyVAL.node = &SpecifierQualifierListOpt{\n\t\t\t\tSpecifierQualifierList: yyS[yypt-0].node.(*SpecifierQualifierList),\n\t\t\t}\n\t\t}\n\tcase 125:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaratorList{\n\t\t\t\tStructDeclarator: yyS[yypt-0].node.(*StructDeclarator),\n\t\t\t}\n\t\t}\n\tcase 126:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclaratorList{\n\t\t\t\tCase:                 1,\n\t\t\t\tStructDeclaratorList: yyS[yypt-2].node.(*StructDeclaratorList),\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tStructDeclarator:     yyS[yypt-0].node.(*StructDeclarator),\n\t\t\t}\n\t\t}\n\tcase 127:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarator{\n\t\t\t\tCase:       StructDeclaratorBase,\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t}\n\tcase 128:\n\t\t{\n\t\t\tyyVAL.node = &StructDeclarator{\n\t\t\t\tCase:          StructDeclaratorBits,\n\t\t\t\tDeclaratorOpt: yyS[yypt-2].node.(*DeclaratorOpt),\n\t\t\t\tToken:         yyS[yypt-1].Token,\n\t\t\t\tConstExpr:     yyS[yypt-0].node.(*ConstExpr),\n\t\t\t}\n\t\t}\n\tcase 129:\n\t\t{\n\t\t\tyyVAL.node = (*CommaOpt)(nil)\n\t\t}\n\tcase 130:\n\t\t{\n\t\t\tyyVAL.node = &CommaOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 131:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &EnumSpecifier{\n\t\t\t\tCase:   EnumSpecifierTag,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 132:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &EnumSpecifier{\n\t\t\t\tCase:           EnumSpecifierDefine,\n\t\t\t\tToken:          yyS[yypt-5].Token,\n\t\t\t\tIdentifierOpt:  yyS[yypt-4].node.(*IdentifierOpt),\n\t\t\t\tToken2:         yyS[yypt-3].Token,\n\t\t\t\tEnumeratorList: yyS[yypt-2].node.(*EnumeratorList).reverse(),\n\t\t\t\tCommaOpt:       yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken3:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 133:\n\t\t{\n\t\t\tyyVAL.node = &EnumeratorList{\n\t\t\t\tEnumerator: yyS[yypt-0].node.(*Enumerator),\n\t\t\t}\n\t\t}\n\tcase 134:\n\t\t{\n\t\t\tyyVAL.node = &EnumeratorList{\n\t\t\t\tCase:           1,\n\t\t\t\tEnumeratorList: yyS[yypt-2].node.(*EnumeratorList),\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tEnumerator:     yyS[yypt-0].node.(*Enumerator),\n\t\t\t}\n\t\t}\n\tcase 135:\n\t\t{\n\t\t\tyyVAL.node = &Enumerator{\n\t\t\t\tCase:                EnumeratorBase,\n\t\t\t\tEnumerationConstant: yyS[yypt-0].node.(*EnumerationConstant),\n\t\t\t}\n\t\t}\n\tcase 136:\n\t\t{\n\t\t\tyyVAL.node = &Enumerator{\n\t\t\t\tCase:                EnumeratorInit,\n\t\t\t\tEnumerationConstant: yyS[yypt-2].node.(*EnumerationConstant),\n\t\t\t\tToken:               yyS[yypt-1].Token,\n\t\t\t\tConstExpr:           yyS[yypt-0].node.(*ConstExpr),\n\t\t\t}\n\t\t}\n\tcase 137:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifier{\n\t\t\t\tCase:  TypeQualifierConst,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 138:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifier{\n\t\t\t\tCase:  TypeQualifierRestrict,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 139:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifier{\n\t\t\t\tCase:  TypeQualifierVolatile,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 140:\n\t\t{\n\t\t\tyyVAL.node = &FunctionSpecifier{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 141:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &Declarator{\n\t\t\t\tPointerOpt:       yyS[yypt-1].node.(*PointerOpt),\n\t\t\t\tDirectDeclarator: yyS[yypt-0].node.(*DirectDeclarator),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Attributes = lx.attrs()\n\t\t\tlhs.Scope = lx.scope\n\t\t\tif lx.scope.typedef {\n\t\t\t\tdelete(lx.scope.Idents, lhs.DirectDeclarator.nm())\n\t\t\t\tlx.scope.insertTypedef(lx.context, lhs)\n\t\t\t}\n\t\t}\n\tcase 142:\n\t\t{\n\t\t\tyyVAL.node = (*DeclaratorOpt)(nil)\n\t\t}\n\tcase 143:\n\t\t{\n\t\t\tyyVAL.node = &DeclaratorOpt{\n\t\t\t\tDeclarator: yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t}\n\tcase 144:\n\t\t{\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:       DirectDeclaratorParen,\n\t\t\t\tToken:      yyS[yypt-2].Token,\n\t\t\t\tDeclarator: yyS[yypt-1].node.(*Declarator),\n\t\t\t\tToken2:     yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.Embedded = true\n\t\t}\n\tcase 145:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.newScope()\n\t\t}\n\tcase 146:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:              DirectDeclaratorIdentList,\n\t\t\t\tDirectDeclarator:  yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-3].Token,\n\t\t\t\tIdentifierListOpt: yyS[yypt-1].node.(*IdentifierListOpt),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramScope, _ = lx.popScope()\n\t\t}\n\tcase 147:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.newScope()\n\t\t}\n\tcase 148:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &DirectDeclarator{\n\t\t\t\tCase:              DirectDeclaratorParamList,\n\t\t\t\tDirectDeclarator:  yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-3].Token,\n\t\t\t\tParameterTypeList: yyS[yypt-1].node.(*ParameterTypeList),\n\t\t\t\tToken2:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.paramScope, _ = lx.popScope()\n\t\t}\n\tcase 149:\n\t\t{\n\t\t\tyyVAL.node = &DirectDeclarator{\n\t\t\t\tCase:                 DirectDeclaratorArraySize,\n\t\t\t\tDirectDeclarator:     yyS[yypt-5].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-4].Token,\n\t\t\t\tToken2:               yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExpr:                 yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken3:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 150:\n\t\t{\n\t\t\tyyVAL.node = &DirectDeclarator{\n\t\t\t\tCase:              DirectDeclaratorArraySize2,\n\t\t\t\tDirectDeclarator:  yyS[yypt-5].node.(*DirectDeclarator),\n\t\t\t\tToken:             yyS[yypt-4].Token,\n\t\t\t\tTypeQualifierList: yyS[yypt-3].node.(*TypeQualifierList).reverse(),\n\t\t\t\tToken2:            yyS[yypt-2].Token,\n\t\t\t\tExpr:              yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken3:            yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 151:\n\t\t{\n\t\t\tyyVAL.node = &DirectDeclarator{\n\t\t\t\tCase:                 DirectDeclaratorArrayVar,\n\t\t\t\tDirectDeclarator:     yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tToken2:               yyS[yypt-1].Token,\n\t\t\t\tToken3:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 152:\n\t\t{\n\t\t\tyyVAL.node = &DirectDeclarator{\n\t\t\t\tCase:                 DirectDeclaratorArray,\n\t\t\t\tDirectDeclarator:     yyS[yypt-4].node.(*DirectDeclarator),\n\t\t\t\tToken:                yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExprOpt:              yyS[yypt-1].node.(*ExprOpt),\n\t\t\t\tToken2:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 153:\n\t\t{\n\t\t\tyyVAL.node = &DirectDeclarator{\n\t\t\t\tCase:  DirectDeclaratorIdent,\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 154:\n\t\t{\n\t\t\tyyVAL.node = &Pointer{\n\t\t\t\tCase:                 PointerBase,\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-0].node.(*TypeQualifierListOpt),\n\t\t\t}\n\t\t}\n\tcase 155:\n\t\t{\n\t\t\tyyVAL.node = &Pointer{\n\t\t\t\tCase:                 PointerPtr,\n\t\t\t\tToken:                yyS[yypt-2].Token,\n\t\t\t\tTypeQualifierListOpt: yyS[yypt-1].node.(*TypeQualifierListOpt),\n\t\t\t\tPointer:              yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t}\n\tcase 156:\n\t\t{\n\t\t\tyyVAL.node = (*PointerOpt)(nil)\n\t\t}\n\tcase 157:\n\t\t{\n\t\t\tyyVAL.node = &PointerOpt{\n\t\t\t\tPointer: yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t}\n\tcase 158:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifierList{\n\t\t\t\tTypeQualifier: yyS[yypt-0].node.(*TypeQualifier),\n\t\t\t}\n\t\t}\n\tcase 159:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifierList{\n\t\t\t\tCase:              1,\n\t\t\t\tTypeQualifierList: yyS[yypt-1].node.(*TypeQualifierList),\n\t\t\t\tTypeQualifier:     yyS[yypt-0].node.(*TypeQualifier),\n\t\t\t}\n\t\t}\n\tcase 160:\n\t\t{\n\t\t\tyyVAL.node = (*TypeQualifierListOpt)(nil)\n\t\t}\n\tcase 161:\n\t\t{\n\t\t\tyyVAL.node = &TypeQualifierListOpt{\n\t\t\t\tTypeQualifierList: yyS[yypt-0].node.(*TypeQualifierList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 162:\n\t\t{\n\t\t\tyyVAL.node = &ParameterTypeList{\n\t\t\t\tCase:          ParameterTypeListBase,\n\t\t\t\tParameterList: yyS[yypt-0].node.(*ParameterList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 163:\n\t\t{\n\t\t\tyyVAL.node = &ParameterTypeList{\n\t\t\t\tCase:          ParameterTypeListDots,\n\t\t\t\tParameterList: yyS[yypt-2].node.(*ParameterList).reverse(),\n\t\t\t\tToken:         yyS[yypt-1].Token,\n\t\t\t\tToken2:        yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 164:\n\t\t{\n\t\t\tyyVAL.node = (*ParameterTypeListOpt)(nil)\n\t\t}\n\tcase 165:\n\t\t{\n\t\t\tyyVAL.node = &ParameterTypeListOpt{\n\t\t\t\tParameterTypeList: yyS[yypt-0].node.(*ParameterTypeList),\n\t\t\t}\n\t\t}\n\tcase 166:\n\t\t{\n\t\t\tyyVAL.node = &ParameterList{\n\t\t\t\tParameterDeclaration: yyS[yypt-0].node.(*ParameterDeclaration),\n\t\t\t}\n\t\t}\n\tcase 167:\n\t\t{\n\t\t\tyyVAL.node = &ParameterList{\n\t\t\t\tCase:                 1,\n\t\t\t\tParameterList:        yyS[yypt-2].node.(*ParameterList),\n\t\t\t\tToken:                yyS[yypt-1].Token,\n\t\t\t\tParameterDeclaration: yyS[yypt-0].node.(*ParameterDeclaration),\n\t\t\t}\n\t\t}\n\tcase 168:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &ParameterDeclaration{\n\t\t\t\tCase:                  ParameterDeclarationAbstract,\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-1].node.(*DeclarationSpecifiers),\n\t\t\t\tAbstractDeclaratorOpt: yyS[yypt-0].node.(*AbstractDeclaratorOpt),\n\t\t\t}\n\t\t\tlx.scope.typedef = false\n\t\t}\n\tcase 169:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &ParameterDeclaration{\n\t\t\t\tCase:                  ParameterDeclarationDeclarator,\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-1].node.(*DeclarationSpecifiers),\n\t\t\t\tDeclarator:            yyS[yypt-0].node.(*Declarator),\n\t\t\t}\n\t\t\tlx.scope.typedef = false\n\t\t}\n\tcase 170:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierList{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 171:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierList{\n\t\t\t\tCase:           1,\n\t\t\t\tIdentifierList: yyS[yypt-2].node.(*IdentifierList),\n\t\t\t\tToken:          yyS[yypt-1].Token,\n\t\t\t\tToken2:         yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 172:\n\t\t{\n\t\t\tyyVAL.node = (*IdentifierListOpt)(nil)\n\t\t}\n\tcase 173:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierListOpt{\n\t\t\t\tIdentifierList: yyS[yypt-0].node.(*IdentifierList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 174:\n\t\t{\n\t\t\tyyVAL.node = (*IdentifierOpt)(nil)\n\t\t}\n\tcase 175:\n\t\t{\n\t\t\tyyVAL.node = &IdentifierOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 176:\n\t\t{\n\t\t\tyyVAL.node = &TypeName{\n\t\t\t\tSpecifierQualifierList: yyS[yypt-1].node.(*SpecifierQualifierList),\n\t\t\t\tAbstractDeclaratorOpt:  yyS[yypt-0].node.(*AbstractDeclaratorOpt),\n\t\t\t}\n\t\t}\n\tcase 177:\n\t\t{\n\t\t\tyyVAL.node = &AbstractDeclarator{\n\t\t\t\tCase:    AbstractDeclaratorPointer,\n\t\t\t\tPointer: yyS[yypt-0].node.(*Pointer),\n\t\t\t}\n\t\t}\n\tcase 178:\n\t\t{\n\t\t\tyyVAL.node = &AbstractDeclarator{\n\t\t\t\tCase:                     AbstractDeclaratorAbstract,\n\t\t\t\tPointerOpt:               yyS[yypt-1].node.(*PointerOpt),\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-0].node.(*DirectAbstractDeclarator),\n\t\t\t}\n\t\t}\n\tcase 179:\n\t\t{\n\t\t\tyyVAL.node = (*AbstractDeclaratorOpt)(nil)\n\t\t}\n\tcase 180:\n\t\t{\n\t\t\tyyVAL.node = &AbstractDeclaratorOpt{\n\t\t\t\tAbstractDeclarator: yyS[yypt-0].node.(*AbstractDeclarator),\n\t\t\t}\n\t\t}\n\tcase 181:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:               DirectAbstractDeclaratorAbstract,\n\t\t\t\tToken:              yyS[yypt-2].Token,\n\t\t\t\tAbstractDeclarator: yyS[yypt-1].node.(*AbstractDeclarator),\n\t\t\t\tToken2:             yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 182:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                 DirectAbstractDeclaratorParamList,\n\t\t\t\tToken:                yyS[yypt-2].Token,\n\t\t\t\tParameterTypeListOpt: yyS[yypt-1].node.(*ParameterTypeListOpt),\n\t\t\t\tToken2:               yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 183:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                     DirectAbstractDeclaratorDFn,\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-3].node.(*DirectAbstractDeclarator),\n\t\t\t\tToken:                    yyS[yypt-2].Token,\n\t\t\t\tParameterTypeListOpt:     yyS[yypt-1].node.(*ParameterTypeListOpt),\n\t\t\t\tToken2:                   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 184:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                        DirectAbstractDeclaratorDArrSize,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-5].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                       yyS[yypt-4].Token,\n\t\t\t\tToken2:                      yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierListOpt:        yyS[yypt-2].node.(*TypeQualifierListOpt),\n\t\t\t\tExpr:                        yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken3:                      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 185:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                        DirectAbstractDeclaratorDArrVL,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-3].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                       yyS[yypt-2].Token,\n\t\t\t\tToken2:                      yyS[yypt-1].Token,\n\t\t\t\tToken3:                      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 186:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                        DirectAbstractDeclaratorDArr,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-3].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                       yyS[yypt-2].Token,\n\t\t\t\tExprOpt:                     yyS[yypt-1].node.(*ExprOpt),\n\t\t\t\tToken2:                      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 187:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                        DirectAbstractDeclaratorDArrSize2,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-5].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                       yyS[yypt-4].Token,\n\t\t\t\tTypeQualifierList:           yyS[yypt-3].node.(*TypeQualifierList).reverse(),\n\t\t\t\tToken2:                      yyS[yypt-2].Token,\n\t\t\t\tExpr:                        yyS[yypt-1].node.(*Expr),\n\t\t\t\tToken3:                      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 188:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclarator{\n\t\t\t\tCase:                        DirectAbstractDeclaratorDArr2,\n\t\t\t\tDirectAbstractDeclaratorOpt: yyS[yypt-4].node.(*DirectAbstractDeclaratorOpt),\n\t\t\t\tToken:                       yyS[yypt-3].Token,\n\t\t\t\tTypeQualifierList:           yyS[yypt-2].node.(*TypeQualifierList).reverse(),\n\t\t\t\tExprOpt:                     yyS[yypt-1].node.(*ExprOpt),\n\t\t\t\tToken2:                      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 189:\n\t\t{\n\t\t\tyyVAL.node = (*DirectAbstractDeclaratorOpt)(nil)\n\t\t}\n\tcase 190:\n\t\t{\n\t\t\tyyVAL.node = &DirectAbstractDeclaratorOpt{\n\t\t\t\tDirectAbstractDeclarator: yyS[yypt-0].node.(*DirectAbstractDeclarator),\n\t\t\t}\n\t\t}\n\tcase 191:\n\t\t{\n\t\t\tyyVAL.node = &Initializer{\n\t\t\t\tCase:            InitializerCompLit,\n\t\t\t\tToken:           yyS[yypt-3].Token,\n\t\t\t\tInitializerList: yyS[yypt-2].node.(*InitializerList).reverse(),\n\t\t\t\tCommaOpt:        yyS[yypt-1].node.(*CommaOpt),\n\t\t\t\tToken2:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 192:\n\t\t{\n\t\t\tyyVAL.node = &Initializer{\n\t\t\t\tCase: InitializerExpr,\n\t\t\t\tExpr: yyS[yypt-0].node.(*Expr),\n\t\t\t}\n\t\t}\n\tcase 193:\n\t\t{\n\t\t\tyyVAL.node = (*InitializerList)(nil)\n\t\t}\n\tcase 194:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tCase:        1,\n\t\t\t\tInitializer: yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 195:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tCase:        2,\n\t\t\t\tDesignation: yyS[yypt-1].node.(*Designation),\n\t\t\t\tInitializer: yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 196:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tCase:            3,\n\t\t\t\tInitializerList: yyS[yypt-2].node.(*InitializerList),\n\t\t\t\tToken:           yyS[yypt-1].Token,\n\t\t\t\tInitializer:     yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 197:\n\t\t{\n\t\t\tyyVAL.node = &InitializerList{\n\t\t\t\tCase:            4,\n\t\t\t\tInitializerList: yyS[yypt-3].node.(*InitializerList),\n\t\t\t\tToken:           yyS[yypt-2].Token,\n\t\t\t\tDesignation:     yyS[yypt-1].node.(*Designation),\n\t\t\t\tInitializer:     yyS[yypt-0].node.(*Initializer),\n\t\t\t}\n\t\t}\n\tcase 198:\n\t\t{\n\t\t\tyyVAL.node = &Designation{\n\t\t\t\tDesignatorList: yyS[yypt-1].node.(*DesignatorList).reverse(),\n\t\t\t\tToken:          yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 199:\n\t\t{\n\t\t\tyyVAL.node = &DesignatorList{\n\t\t\t\tDesignator: yyS[yypt-0].node.(*Designator),\n\t\t\t}\n\t\t}\n\tcase 200:\n\t\t{\n\t\t\tyyVAL.node = &DesignatorList{\n\t\t\t\tCase:           1,\n\t\t\t\tDesignatorList: yyS[yypt-1].node.(*DesignatorList),\n\t\t\t\tDesignator:     yyS[yypt-0].node.(*Designator),\n\t\t\t}\n\t\t}\n\tcase 201:\n\t\t{\n\t\t\tyyVAL.node = &Designator{\n\t\t\t\tCase:   DesignatorField,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 202:\n\t\t{\n\t\t\tyyVAL.node = &Designator{\n\t\t\t\tCase:      DesignatorIndex,\n\t\t\t\tToken:     yyS[yypt-2].Token,\n\t\t\t\tConstExpr: yyS[yypt-1].node.(*ConstExpr),\n\t\t\t\tToken2:    yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 203:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:         StmtBlock,\n\t\t\t\tCompoundStmt: yyS[yypt-0].node.(*CompoundStmt),\n\t\t\t}\n\t\t}\n\tcase 204:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:     StmtExpr,\n\t\t\t\tExprStmt: yyS[yypt-0].node.(*ExprStmt),\n\t\t\t}\n\t\t}\n\tcase 205:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:          StmtIter,\n\t\t\t\tIterationStmt: yyS[yypt-0].node.(*IterationStmt),\n\t\t\t}\n\t\t}\n\tcase 206:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:     StmtJump,\n\t\t\t\tJumpStmt: yyS[yypt-0].node.(*JumpStmt),\n\t\t\t}\n\t\t}\n\tcase 207:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:        StmtLabeled,\n\t\t\t\tLabeledStmt: yyS[yypt-0].node.(*LabeledStmt),\n\t\t\t}\n\t\t}\n\tcase 208:\n\t\t{\n\t\t\tyyVAL.node = &Stmt{\n\t\t\t\tCase:          StmtSelect,\n\t\t\t\tSelectionStmt: yyS[yypt-0].node.(*SelectionStmt),\n\t\t\t}\n\t\t}\n\tcase 209:\n\t\t{\n\t\t\tyyVAL.node = &LabeledStmt{\n\t\t\t\tCase:      LabeledStmtSwitchCase,\n\t\t\t\tToken:     yyS[yypt-3].Token,\n\t\t\t\tConstExpr: yyS[yypt-2].node.(*ConstExpr),\n\t\t\t\tToken2:    yyS[yypt-1].Token,\n\t\t\t\tStmt:      yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 210:\n\t\t{\n\t\t\tyyVAL.node = &LabeledStmt{\n\t\t\t\tCase:   LabeledStmtDefault,\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tStmt:   yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 211:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &LabeledStmt{\n\t\t\t\tCase:   LabeledStmtLabel,\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tStmt:   yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.insertLabel(lx.context, lhs)\n\t\t}\n\tcase 212:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &LabeledStmt{\n\t\t\t\tCase:   LabeledStmtLabel2,\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tStmt:   yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlx.scope.insertLabel(lx.context, lhs)\n\t\t}\n\tcase 213:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.newScope()\n\t\t}\n\tcase 214:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &CompoundStmt{\n\t\t\t\tToken:            yyS[yypt-3].Token,\n\t\t\t\tBlockItemListOpt: yyS[yypt-1].node.(*BlockItemListOpt),\n\t\t\t\tToken2:           yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope, _ = lx.popScope()\n\t\t}\n\tcase 215:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemList{\n\t\t\t\tBlockItem: yyS[yypt-0].node.(*BlockItem),\n\t\t\t}\n\t\t}\n\tcase 216:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemList{\n\t\t\t\tCase:          1,\n\t\t\t\tBlockItemList: yyS[yypt-1].node.(*BlockItemList),\n\t\t\t\tBlockItem:     yyS[yypt-0].node.(*BlockItem),\n\t\t\t}\n\t\t}\n\tcase 217:\n\t\t{\n\t\t\tyyVAL.node = (*BlockItemListOpt)(nil)\n\t\t}\n\tcase 218:\n\t\t{\n\t\t\tyyVAL.node = &BlockItemListOpt{\n\t\t\t\tBlockItemList: yyS[yypt-0].node.(*BlockItemList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 219:\n\t\t{\n\t\t\tyyVAL.node = &BlockItem{\n\t\t\t\tCase:        BlockItemDecl,\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 220:\n\t\t{\n\t\t\tyyVAL.node = &BlockItem{\n\t\t\t\tCase: BlockItemStmt,\n\t\t\t\tStmt: yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 221:\n\t\t{\n\t\t\tyyVAL.node = &ExprStmt{\n\t\t\t\tExprListOpt: yyS[yypt-1].node.(*ExprListOpt),\n\t\t\t\tToken:       yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 222:\n\t\t{\n\t\t\tyyVAL.node = &SelectionStmt{\n\t\t\t\tCase:     SelectionStmtIfElse,\n\t\t\t\tToken:    yyS[yypt-6].Token,\n\t\t\t\tToken2:   yyS[yypt-5].Token,\n\t\t\t\tExprList: yyS[yypt-4].node.(*ExprList).reverse(),\n\t\t\t\tToken3:   yyS[yypt-3].Token,\n\t\t\t\tStmt:     yyS[yypt-2].node.(*Stmt),\n\t\t\t\tToken4:   yyS[yypt-1].Token,\n\t\t\t\tStmt2:    yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 223:\n\t\t{\n\t\t\tyyVAL.node = &SelectionStmt{\n\t\t\t\tCase:     SelectionStmtIf,\n\t\t\t\tToken:    yyS[yypt-4].Token,\n\t\t\t\tToken2:   yyS[yypt-3].Token,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList).reverse(),\n\t\t\t\tToken3:   yyS[yypt-1].Token,\n\t\t\t\tStmt:     yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 224:\n\t\t{\n\t\t\tyyVAL.node = &SelectionStmt{\n\t\t\t\tCase:     SelectionStmtSwitch,\n\t\t\t\tToken:    yyS[yypt-4].Token,\n\t\t\t\tToken2:   yyS[yypt-3].Token,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList).reverse(),\n\t\t\t\tToken3:   yyS[yypt-1].Token,\n\t\t\t\tStmt:     yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 225:\n\t\t{\n\t\t\tyyVAL.node = &IterationStmt{\n\t\t\t\tCase:     IterationStmtDo,\n\t\t\t\tToken:    yyS[yypt-6].Token,\n\t\t\t\tStmt:     yyS[yypt-5].node.(*Stmt),\n\t\t\t\tToken2:   yyS[yypt-4].Token,\n\t\t\t\tToken3:   yyS[yypt-3].Token,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList).reverse(),\n\t\t\t\tToken4:   yyS[yypt-1].Token,\n\t\t\t\tToken5:   yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 226:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &IterationStmt{\n\t\t\t\tCase:         IterationStmtForDecl,\n\t\t\t\tToken:        yyS[yypt-7].Token,\n\t\t\t\tToken2:       yyS[yypt-6].Token,\n\t\t\t\tDeclaration:  yyS[yypt-5].node.(*Declaration),\n\t\t\t\tExprListOpt:  yyS[yypt-4].node.(*ExprListOpt),\n\t\t\t\tToken3:       yyS[yypt-3].Token,\n\t\t\t\tExprListOpt2: yyS[yypt-2].node.(*ExprListOpt),\n\t\t\t\tToken4:       yyS[yypt-1].Token,\n\t\t\t\tStmt:         yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t\tlx.popScope()\n\t\t}\n\tcase 227:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tyyVAL.node = &IterationStmt{\n\t\t\t\tCase:         IterationStmtFor,\n\t\t\t\tToken:        yyS[yypt-8].Token,\n\t\t\t\tToken2:       yyS[yypt-7].Token,\n\t\t\t\tExprListOpt:  yyS[yypt-6].node.(*ExprListOpt),\n\t\t\t\tToken3:       yyS[yypt-5].Token,\n\t\t\t\tExprListOpt2: yyS[yypt-4].node.(*ExprListOpt),\n\t\t\t\tToken4:       yyS[yypt-3].Token,\n\t\t\t\tExprListOpt3: yyS[yypt-2].node.(*ExprListOpt),\n\t\t\t\tToken5:       yyS[yypt-1].Token,\n\t\t\t\tStmt:         yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t\tlx.popScope()\n\t\t}\n\tcase 228:\n\t\t{\n\t\t\tyyVAL.node = &IterationStmt{\n\t\t\t\tCase:     IterationStmtWhile,\n\t\t\t\tToken:    yyS[yypt-4].Token,\n\t\t\t\tToken2:   yyS[yypt-3].Token,\n\t\t\t\tExprList: yyS[yypt-2].node.(*ExprList).reverse(),\n\t\t\t\tToken3:   yyS[yypt-1].Token,\n\t\t\t\tStmt:     yyS[yypt-0].node.(*Stmt),\n\t\t\t}\n\t\t}\n\tcase 229:\n\t\t{\n\t\t\tyyVAL.node = &JumpStmt{\n\t\t\t\tCase:   JumpStmtBreak,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 230:\n\t\t{\n\t\t\tyyVAL.node = &JumpStmt{\n\t\t\t\tCase:   JumpStmtContinue,\n\t\t\t\tToken:  yyS[yypt-1].Token,\n\t\t\t\tToken2: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 231:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &JumpStmt{\n\t\t\t\tCase:   JumpStmtGoto,\n\t\t\t\tToken:  yyS[yypt-2].Token,\n\t\t\t\tToken2: yyS[yypt-1].Token,\n\t\t\t\tToken3: yyS[yypt-0].Token,\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.scope = lx.scope\n\t\t}\n\tcase 232:\n\t\t{\n\t\t\tyyVAL.node = &JumpStmt{\n\t\t\t\tCase:        JumpStmtReturn,\n\t\t\t\tToken:       yyS[yypt-2].Token,\n\t\t\t\tExprListOpt: yyS[yypt-1].node.(*ExprListOpt),\n\t\t\t\tToken2:      yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\tcase 233:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclarationList{\n\t\t\t\tExternalDeclaration: yyS[yypt-0].node.(*ExternalDeclaration),\n\t\t\t}\n\t\t}\n\tcase 234:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclarationList{\n\t\t\t\tCase:                    1,\n\t\t\t\tExternalDeclarationList: yyS[yypt-1].node.(*ExternalDeclarationList),\n\t\t\t\tExternalDeclaration:     yyS[yypt-0].node.(*ExternalDeclaration),\n\t\t\t}\n\t\t}\n\tcase 235:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclaration{\n\t\t\t\tCase:        ExternalDeclarationDecl,\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 236:\n\t\t{\n\t\t\tyyVAL.node = &ExternalDeclaration{\n\t\t\t\tCase:               ExternalDeclarationFunc,\n\t\t\t\tFunctionDefinition: yyS[yypt-0].node.(*FunctionDefinition),\n\t\t\t}\n\t\t}\n\tcase 237:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.scope.typedef = false\n\t\t\tlx.currFn = yyS[yypt-0].node.(*Declarator).Name()\n\t\t}\n\tcase 238:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &FunctionDefinition{\n\t\t\t\tCase:                  FunctionDefinitionSpec,\n\t\t\t\tDeclarationSpecifiers: yyS[yypt-4].node.(*DeclarationSpecifiers),\n\t\t\t\tDeclarator:            yyS[yypt-3].node.(*Declarator),\n\t\t\t\tDeclarationListOpt:    yyS[yypt-1].node.(*DeclarationListOpt),\n\t\t\t\tFunctionBody:          yyS[yypt-0].node.(*FunctionBody),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.FunctionDefinition = lhs\n\t\t\tif lx.scope.Parent != nil {\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\t\t}\n\tcase 239:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tif !lx.tweaks.EnableOmitFuncDeclSpec {\n\t\t\t\tlx.err(yyS[yypt-0].node, \"omitting function declaration specifiers not allowed\")\n\t\t\t}\n\t\t\tlx.scope.typedef = false\n\t\t\tlx.currFn = yyS[yypt-0].node.(*Declarator).Name()\n\t\t}\n\tcase 240:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlhs := &FunctionDefinition{\n\t\t\t\tCase:               FunctionDefinitionInt,\n\t\t\t\tDeclarator:         yyS[yypt-3].node.(*Declarator),\n\t\t\t\tDeclarationListOpt: yyS[yypt-1].node.(*DeclarationListOpt),\n\t\t\t\tFunctionBody:       yyS[yypt-0].node.(*FunctionBody),\n\t\t\t}\n\t\t\tyyVAL.node = lhs\n\t\t\tlhs.Declarator.FunctionDefinition = lhs\n\t\t\tif lx.scope.Parent != nil {\n\t\t\t\tpanic(\"internal error\")\n\t\t\t}\n\t\t}\n\tcase 241:\n\t\t{\n\t\t\tlx := yylex.(*lexer)\n\t\t\tlx.declareFuncName() // [0], 6.4.2.2.\n\t\t}\n\tcase 242:\n\t\t{\n\t\t\tyyVAL.node = &FunctionBody{\n\t\t\t\tCompoundStmt: yyS[yypt-0].node.(*CompoundStmt),\n\t\t\t}\n\t\t}\n\tcase 243:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationList{\n\t\t\t\tDeclaration: yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 244:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationList{\n\t\t\t\tCase:            1,\n\t\t\t\tDeclarationList: yyS[yypt-1].node.(*DeclarationList),\n\t\t\t\tDeclaration:     yyS[yypt-0].node.(*Declaration),\n\t\t\t}\n\t\t}\n\tcase 245:\n\t\t{\n\t\t\tyyVAL.node = (*DeclarationListOpt)(nil)\n\t\t}\n\tcase 246:\n\t\t{\n\t\t\tyyVAL.node = &DeclarationListOpt{\n\t\t\t\tDeclarationList: yyS[yypt-0].node.(*DeclarationList).reverse(),\n\t\t\t}\n\t\t}\n\tcase 247:\n\t\t{\n\t\t\tyyVAL.node = (*VolatileOpt)(nil)\n\t\t}\n\tcase 248:\n\t\t{\n\t\t\tyyVAL.node = &VolatileOpt{\n\t\t\t\tToken: yyS[yypt-0].Token,\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif yyEx != nil && yyEx.Reduced(r, exState, &yyVAL) {\n\t\treturn -1\n\t}\n\tgoto yystack /* stack new state and value */\n}\n"
  },
  {
    "path": "v2/parser.yy",
    "content": "%{\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.5-6.10. Substantial portions of expression AST size\n// optimizations are from [1], license of which follows.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n// [1]: https://github.com/rsc/c2go/blob/fc8cbfad5a47373828c81c7a56cccab8b221d310/cc/cc.y\n\n// ----------------------------------------------------------------------------\n\n// Copyright 2013 The Go Authors.  All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// This grammar is derived from the C grammar in the 'ansitize'\n// program, which carried this notice:\n// \n// Copyright (c) 2006 Russ Cox, \n// \tMassachusetts Institute of Technology\n// \n// Permission is hereby granted, free of charge, to any person\n// obtaining a copy of this software and associated\n// documentation files (the \"Software\"), to deal in the\n// Software without restriction, including without limitation\n// the rights to use, copy, modify, merge, publish, distribute,\n// sublicense, and/or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so,\n// subject to the following conditions:\n// \n// The above copyright notice and this permission notice shall\n// be included in all copies or substantial portions of the\n// Software.\n// \n// The software is provided \"as is\", without warranty of any\n// kind, express or implied, including but not limited to the\n// warranties of merchantability, fitness for a particular\n// purpose and noninfringement.  In no event shall the authors\n// or copyright holders be liable for any claim, damages or\n// other liability, whether in an action of contract, tort or\n// otherwise, arising from, out of or in connection with the\n// software or the use or other dealings in the software.\n\npackage cc\n\nimport (\n\t\"github.com/cznic/xc\"\n)\n%}\n\n%union {\n\tToken\t\t\txc.Token // Must be exported\n\tnode\t\t\tNode\n}\n\n%token\n\t/*yy:token \"'%c'\"            */ CHARCONST\t\t\"character constant\"\n\t/*yy:token \"1.%d\"            */ FLOATCONST\t\t\"floating-point constant\"\n\t/*yy:token \"%c\"              */ IDENTIFIER\t\t\"identifier\"\n\t/*yy:token \"%d\"              */ INTCONST\t\t\"integer constant\"\n\t/*yy:token \"L'%c'\"           */ LONGCHARCONST\t\t\"long character constant\"\n\t/*yy:token \"L\\\"%c\\\"\"         */ LONGSTRINGLITERAL\t\"long string constant\"\n\t/*yy:token \"%d\"              */ PPNUMBER\t\t\"preprocessing number\"\n\t/*yy:token \"\\\"%c\\\"\"          */ STRINGLITERAL\t\t\"string literal\"\n\n\t/*yy:token \"\\U00100000\"      */\tCONSTANT_EXPRESSION\t1048576\t\"constant expression prefix\"\t// 0x100000 = 1048576\n\t/*yy:token \"\\U00100001\"      */\tTRANSLATION_UNIT\t1048577\t\"translation unit prefix\"\n\n\tADDASSIGN\t\t\t\"+=\"\n\tANDAND\t\t\t\t\"&&\"\n\tANDASSIGN\t\t\t\"&=\"\n\tARROW\t\t\t\t\"->\"\n\tALIGNOF\t\t\t\t\"__alignof__\"\n\tAUTO\t\t\t\t\"auto\"\n\tBOOL\t\t\t\t\"_Bool\"\n\tBREAK\t\t\t\t\"break\"\n\tCASE\t\t\t\t\"case\"\n\tCHAR\t\t\t\t\"char\"\n\tCOMPLEX\t\t\t\t\"_Complex\"\n\tCONST\t\t\t\t\"const\"\n\tCONTINUE\t\t\t\"continue\"\n\tDDD\t\t\t\t\"...\"\n\tDEC\t\t\t\t\"--\"\n\tDEFAULT\t\t\t\t\"default\"\n\tDIRECTIVE\t\t\t// # when it's the first non white token on a line.\n\tDIVASSIGN\t\t\t\"/=\"\n\tDO\t\t\t\t\"do\"\n\tDOUBLE\t\t\t\t\"double\"\n\tELSE\t\t\t\t\"else\"\n\tENUM\t\t\t\t\"enum\"\n\tEQ\t\t\t\t\"==\"\n\tEXTERN\t\t\t\t\"extern\"\n\tFLOAT\t\t\t\t\"float\"\n\tFOR\t\t\t\t\"for\"\n\tGEQ\t\t\t\t\">=\"\n\tGOTO\t\t\t\t\"goto\"\n\tIF\t\t\t\t\"if\"\n\tINC\t\t\t\t\"++\"\n\tINLINE\t\t\t\t\"inline\"\n\tINT\t\t\t\t\"int\"\n\tLEQ\t\t\t\t\"<=\"\n\tLONG\t\t\t\t\"long\"\n\tLSH\t\t\t\t\"<<\"\n\tLSHASSIGN\t\t\t\"<<=\"\n\tMODASSIGN\t\t\t\"%=\"\n\tMULASSIGN\t\t\t\"*=\"\n\tNEQ\t\t\t\t\"!=\"\n\tNON_REPL\t\t\t// [0]6.10.3.4-2\n\tORASSIGN\t\t\t\"|=\"\n\tOROR\t\t\t\t\"||\"\n\tPPPASTE\t\t\t\t\"##\"\n\tREGISTER\t\t\t\"register\"\n\tRESTRICT\t\t\t\"restrict\"\n\tRETURN\t\t\t\t\"return\"\n\tRSH\t\t\t\t\">>\"\n\tRSHASSIGN\t\t\t\">>=\"\n\tSHORT\t\t\t\t\"short\"\n\tSIGNED\t\t\t\t\"signed\"\n\tSIZEOF\t\t\t\t\"sizeof\"\n\tSTATIC\t\t\t\t\"static\"\n\tSTRUCT\t\t\t\t\"struct\"\n\tSUBASSIGN\t\t\t\"-=\"\n\tSWITCH\t\t\t\t\"switch\"\n\tTYPEDEF\t\t\t\t\"typedef\"\n\tTYPEDEF_NAME\t\t\t\"typedef name\"\n\tTYPEOF\t\t\t\t\"typeof\"\n\tUNION\t\t\t\t\"union\"\n\tUNSIGNED\t\t\t\"unsigned\"\n\tVOID\t\t\t\t\"void\"\n\tVOLATILE\t\t\t\"volatile\"\n\tWHILE\t\t\t\t\"while\"\n\tXORASSIGN\t\t\t\"^=\"\n\n%type\t<node>\n\tAbstractDeclarator\t\t\"abstract declarator\"\n\tAbstractDeclaratorOpt\t\t\"optional abstract declarator\"\n\tArgumentExprList\t\t\"argument expression list\"\n\tArgumentExprListOpt\t\t\"optional argument expression list\"\n\tBlockItem\t\t\t\"block item\"\n\tBlockItemList\t\t\t\"block item list\"\n\tBlockItemListOpt\t\t\"optional block item list\"\n\tCommaOpt\t\t\t\"optional comma\"\n\tCompoundStmt\t\t\t\"compound statement\"\n\tConstExpr\t\t\t\"constant expression\"\n\tDeclaration\t\t\t\"declaration\"\n\tDeclarationList\t\t\t\"declaration list\"\n\tDeclarationListOpt\t\t\"optional declaration list\"\n\tDeclarationSpecifiers\t\t\"declaration specifiers\"\n\tDeclarationSpecifiersOpt\t\"optional declaration specifiers\"\n\tDeclarator\t\t\t\"declarator\"\n\tDeclaratorOpt\t\t\t\"optional declarator\"\n\tDesignation\t\t\t\"designation\"\n\tDesignator\t\t\t\"designator\"\n\tDesignatorList\t\t\t\"designator list\"\n\tDirectAbstractDeclarator\t\"direct abstract declarator\"\n\tDirectAbstractDeclaratorOpt\t\"optional direct abstract declarator\"\n\tDirectDeclarator\t\t\"direct declarator\"\n\tEnumSpecifier\t\t\t\"enum specifier\"\n\tEnumerationConstant\t\t\"enumearation constant\"\n\tEnumerator\t\t\t\"enumerator\"\n\tEnumeratorList\t\t\t\"enumerator list\"\n\tExpr\t\t\t\t\"expression\"\n\tExprList\t\t\t\"expression list\"\n\tExprListOpt\t\t\t\"optional expression list\"\n\tExprOpt\t\t\t\t\"optional expression\"\n\tExprStmt\t\t\t\"expression statement\"\n\tExternalDeclaration\t\t\"external declaration\"\n\tExternalDeclarationList\t\t\"external declaration list\"\n\tFunctionBody\t\t\t\"function body\"\n\tFunctionDefinition\t\t\"function definition\"\n\tFunctionSpecifier\t\t\"function specifier\"\n\tIdentifierList\t\t\t\"identifier list\"\n\tIdentifierListOpt\t\t\"optional identifier list\"\n\tIdentifierOpt\t\t\t\"optional identifier\"\n\tInitDeclarator\t\t\t\"init declarator\"\n\tInitDeclaratorList\t\t\"init declarator list\"\n\tInitDeclaratorListOpt\t\t\"optional init declarator list\"\n\tInitializer\t\t\t\"initializer\"\n\tInitializerList\t\t\t\"initializer list\"\n\tIterationStmt\t\t\t\"iteration statement\"\n\tJumpStmt\t\t\t\"jump statement\"\n\tLabeledStmt\t\t\t\"labeled statement\"\n\tParameterDeclaration\t\t\"parameter declaration\"\n\tParameterList\t\t\t\"parameter list\"\n\tParameterTypeList\t\t\"parameter type list\"\n\tParameterTypeListOpt\t\t\"optional parameter type list\"\n\tPointer\t\t\t\t\"pointer\"\n\tPointerOpt\t\t\t\"optional pointer\"\n\tSelectionStmt\t\t\t\"selection statement\"\n\tSpecifierQualifierList\t\t\"specifier qualifier list\"\n\tSpecifierQualifierListOpt\t\"optional specifier qualifier list\"\n\tStmt\t\t\t\t\"statement\"\n\tStorageClassSpecifier\t\t\"storage class specifier\"\n\tStructDeclaration\t\t\"struct declaration\"\n\tStructDeclarationList\t\t\"struct declaration list\"\n\tStructDeclarator\t\t\"struct declarator\"\n\tStructDeclaratorList\t\t\"struct declarator list\"\n\tStructOrUnion\t\t\t\"struct-or-union\"\n\tStructOrUnionSpecifier\t\t\"struct-or-union specifier\"\n\tTypeName\t\t\t\"type name\"\n\tTypeQualifier\t\t\t\"type qualifier\"\n\tTypeQualifierList\t\t\"type qualifier list\"\n\tTypeQualifierListOpt\t\t\"optional type qualifier list\"\n\tTypeSpecifier\t\t\t\"type specifier\"\n\tVolatileOpt\t\t\t\"optional volatile\"\n\n\n%precedence\tNOSEMI\n%precedence\t';'\n\n%precedence\tNOELSE\n%precedence\tELSE\n\n%right\t\t'=' ADDASSIGN ANDASSIGN DIVASSIGN LSHASSIGN MODASSIGN MULASSIGN\n\t\tORASSIGN RSHASSIGN SUBASSIGN XORASSIGN\n\t\t\n%right\t\t':' '?'\n%left\t\tOROR\n%left\t\tANDAND\n%left\t\t'|'\n%left\t\t'^'\n%left\t\t'&'\n%left\t\tEQ NEQ\n%left\t\t'<' '>' GEQ LEQ\n%left\t\tLSH RSH\n%left\t\t'+' '-' \n%left\t\t'%' '*' '/'\n%precedence\tCAST\n%left\t\t'!' '~' ALIGNOF SIZEOF UNARY\n%right\t\t'(' '.' '[' ARROW DEC INC\n\n%%\n\n                        /*yy:ignore */\n                        Start:\n                        \tCONSTANT_EXPRESSION ConstExpr\n\t\t\t\t{\n\t\t\t\t\tlx.ast = $2\n\t\t\t\t}\n                        |\tTRANSLATION_UNIT ExternalDeclarationList\n\t\t\t\t{\n\t\t\t\t\tlx.ast = &TranslationUnit{\n\t\t\t\t\t\tExternalDeclarationList: $2.(*ExternalDeclarationList).reverse(), \n\t\t\t\t\t\tFileScope: lx.scope,\n\t\t\t\t\t\tFileSet: fset,\n\t\t\t\t\t\tModel: lx.model,\n\t\t\t\t\t}\n\t\t\t\t}\n\n                        // [0]6.4.4.3\n\t\t\t//yy:field\tOperand\tOperand\n                        EnumerationConstant:\n                        \tIDENTIFIER\n\n                        // [0]6.5.2\n                        ArgumentExprList:\n                        \tExpr\n                        |\tArgumentExprList ',' Expr\n\n                        ArgumentExprListOpt:\n                        \t/* empty */ {}\n                        |\tArgumentExprList\n\n                        // [0]6.5.16\n\t\t\t//yy:field\tCallArgs\t[]Operand\t// Promoted arguments of Call.\n\t\t\t//yy:field\tDeclarator\t*Declarator\t// Case Ident.\n\t\t\t//yy:field\tOperand\t\tOperand\n\t\t\t//yy:field\tScope\t\t*Scope\t\t// Case Ident, CompLit.\n\t\t\t//yy:field\tenum\t\t*EnumType\n\t\t\t//yy:field\tAssignedTo\tbool\t\t// Expression appears at the left side of assignment.\n/*yy:case PreInc     */ Expr:\n                        \t\"++\" Expr\n/*yy:case PreDec     */ |\t\"--\" Expr\n/*yy:case AlignofType*/ |\t\"__alignof__\" '(' TypeName ')' %prec ALIGNOF\n/*yy:case AlignofExpr*/ |\t\"__alignof__\" Expr\n/*yy:case SizeofType */ |\t\"sizeof\" '(' TypeName ')' %prec SIZEOF\n/*yy:case SizeofExpr */ |\t\"sizeof\" Expr\n/*yy:case Not        */ |\t'!' Expr\n/*yy:case Addrof     */ |\t'&' Expr %prec UNARY\n/*yy:case Statement  */ |\t'(' CompoundStmt ')'\n/*yy:case PExprList  */ |\t'(' ExprList ')'\n/*yy:case CompLit    */ |\t'(' TypeName ')' '{' InitializerList CommaOpt '}'\n\t\t\t\t{\n\t\t\t\t\tlhs.Scope = lx.scope\n\t\t\t\t}\n/*yy:case Cast       */ |\t'(' TypeName ')' Expr %prec CAST\n/*yy:case Deref      */ |\t'*' Expr %prec UNARY\n/*yy:case UnaryPlus  */ |\t'+' Expr %prec UNARY\n/*yy:case UnaryMinus */ |\t'-' Expr %prec UNARY\n/*yy:case Cpl        */ |\t'~' Expr\n/*yy:case Char       */ |\tCHARCONST\n/*yy:case Ne         */ |\tExpr \"!=\" Expr\n/*yy:case ModAssign  */ |\tExpr \"%=\" Expr\n/*yy:case LAnd       */ |\tExpr \"&&\" Expr\n/*yy:case AndAssign  */ |\tExpr \"&=\" Expr\n/*yy:case MulAssign  */ |\tExpr \"*=\" Expr\n/*yy:case PostInc    */ |\tExpr \"++\"\n/*yy:case AddAssign  */ |\tExpr \"+=\" Expr\n/*yy:case PostDec    */ |\tExpr \"--\"\n/*yy:case SubAssign  */ |\tExpr \"-=\" Expr\n/*yy:case PSelect    */ |\tExpr \"->\" IDENTIFIER\n/*yy:case DivAssign  */ |\tExpr \"/=\" Expr\n/*yy:case Lsh        */ |\tExpr \"<<\" Expr\n/*yy:case LshAssign  */ |\tExpr \"<<=\" Expr\n/*yy:case Le         */ |\tExpr \"<=\" Expr\n/*yy:case Eq         */ |\tExpr \"==\" Expr\n/*yy:case Ge         */ |\tExpr \">=\" Expr\n/*yy:case Rsh        */ |\tExpr \">>\" Expr\n/*yy:case RshAssign  */ |\tExpr \">>=\" Expr\n/*yy:case XorAssign  */ |\tExpr \"^=\" Expr\n/*yy:case OrAssign   */ |\tExpr \"|=\" Expr\n/*yy:case LOr        */ |\tExpr \"||\" Expr\n/*yy:case Mod        */ |\tExpr '%' Expr\n/*yy:case And        */ |\tExpr '&' Expr\n/*yy:case Call       */ |\tExpr '(' ArgumentExprListOpt ')'\n/*yy:case Mul        */ |\tExpr '*' Expr\n/*yy:case Add        */ |\tExpr '+' Expr\n/*yy:case Sub        */ |\tExpr '-' Expr\n/*yy:case Select     */ |\tExpr '.' IDENTIFIER\n/*yy:case Div        */ |\tExpr '/' Expr\n/*yy:case Lt         */ |\tExpr '<' Expr\n/*yy:case Assign     */ |\tExpr '=' Expr\n/*yy:case Gt         */ |\tExpr '>' Expr\n/*yy:case Cond       */ |\tExpr '?' ExprList ':' Expr\n/*yy:case Index      */ |\tExpr '[' ExprList ']'\n/*yy:case Xor        */ |\tExpr '^' Expr\n/*yy:case Or         */ |\tExpr '|' Expr\n/*yy:case Float      */ |\tFLOATCONST\n/*yy:case Ident      */ |\tIDENTIFIER %prec NOSEMI\n\t\t\t\t{\n\t\t\t\t\tlhs.Scope = lx.scope\n\t\t\t\t}\n/*yy:case Int        */ |\tINTCONST\n/*yy:case LChar      */ |\tLONGCHARCONST\n/*yy:case LString    */ |\tLONGSTRINGLITERAL\n/*yy:case String     */ |\tSTRINGLITERAL\n\n                        ExprOpt:\n                        \t/* empty */ {}\n                        |\tExpr\n\n                        // [0]6.5.17\n                        //yy:list\n\t\t\t//yy:field\tOperand\tOperand\n                        ExprList:\n                        \tExpr\n                        |\tExprList ',' Expr\n\n                        ExprListOpt:\n                        \t/* empty */ {}\n                        |\tExprList\n\n                        // [0]6.6\n\t\t\t//yy:field\tOperand\tOperand\n                        ConstExpr:\n                        \tExpr\n\n                        // [0]6.7\n\t\t\t//yy:field\tAttributes\t[][]xc.Token\n\t\t\t//yy:field\tScope\t\t*Scope\n\t\t\tDeclaration:\n                        \tDeclarationSpecifiers InitDeclaratorListOpt\n\t\t\t\t{\n\t\t\t\t\tlx.attr2 = lx.attr\n\t\t\t\t}\n\t\t\t\t';'\n\t\t\t\t{\n\t\t\t\t\tlhs.Scope = lx.scope\n\t\t\t\t\tif len(lx.attr2) != 0 {\n\t\t\t\t\t\tlhs.Attributes = lx.attrs()\n\t\t\t\t\t}\n\t\t\t\t\tlx.scope.typedef = false\n\t\t\t\t}\n\n                        // [0]6.7\n/*yy:case Func       */ DeclarationSpecifiers:\n                        \tFunctionSpecifier DeclarationSpecifiersOpt\n/*yy:case Storage    */ |\tStorageClassSpecifier DeclarationSpecifiersOpt\n/*yy:case Qualifier  */ |\tTypeQualifier DeclarationSpecifiersOpt\n/*yy:case Specifier  */ |\tTypeSpecifier DeclarationSpecifiersOpt\n\n                        DeclarationSpecifiersOpt:\n                        \t/* empty */ {}\n                        |\tDeclarationSpecifiers\n\n                        // [0]6.7\n                        InitDeclaratorList:\n                        \tInitDeclarator\n                        |\tInitDeclaratorList ',' InitDeclarator\n\n                        InitDeclaratorListOpt:\n                        \t/* empty */ {}\n                        |\tInitDeclaratorList\n\n                        // [0]6.7\n/*yy:case Base       */ InitDeclarator:\n                        \tDeclarator\n/*yy:case Init       */ |\tDeclarator '=' Initializer\n\n                        // [0]6.7.1\n/*yy:case Auto       */ StorageClassSpecifier:\n                        \t\"auto\"\n/*yy:case Extern     */ |\t\"extern\"\n/*yy:case Register   */ |\t\"register\"\n/*yy:case Static     */ |\t\"static\"\n/*yy:case Typedef    */ |\t\"typedef\"\n\t\t\t\t{\n\t\t\t\t\tlx.scope.typedef = true\n\t\t\t\t}\n\n                        // [0]6.7.2\n\t\t\t//yy:field\tscope\t*Scope\n\t\t\t//yy:field\ttyp\tType\t// typeof\n/*yy:case Bool       */ TypeSpecifier:\n                        \t\"_Bool\"\n/*yy:case Complex    */ |\t\"_Complex\"\n/*yy:case Char       */ |\t\"char\"\n/*yy:case Double     */ |\t\"double\"\n/*yy:case Float      */ |\t\"float\"\n/*yy:case Int        */ |\t\"int\"\n/*yy:case Long       */ |\t\"long\"\n/*yy:case Short      */ |\t\"short\"\n/*yy:case Signed     */ |\t\"signed\"\n/*yy:case Unsigned   */ |\t\"unsigned\"\n/*yy:case Void       */ |\t\"void\"\n/*yy:case Enum       */ |\tEnumSpecifier\n/*yy:case Struct     */ |\tStructOrUnionSpecifier\n/*yy:example \"\\U00100001 typedef int foo; foo bar;\" */\n/*yy:case Name       */ |\tTYPEDEF_NAME\n\t\t\t\t{\n\t\t\t\t\tlhs.scope = lx.scope\n\t\t\t\t}\n/*yy:case TypeofExpr */\t|\t\"typeof\" '(' Expr ')'\n/*yy:case Typeof     */\t|\t\"typeof\" '(' TypeName ')'\n\n                        // [0]6.7.2.1\n\t\t\t//yy:field\tscope\t*Scope\t// Declare the struct tag in scope.parent.\n\t\t\t//yy:field\ttyp\tType\n/*yy:case Tag        */ StructOrUnionSpecifier:\n                        \tStructOrUnion IDENTIFIER\n\t\t\t\t{\n\t\t\t\t\tlhs.scope = lx.scope\n\t\t\t\t}\n/*yy:case Empty      */ |\tStructOrUnion IdentifierOpt '{'\n\t\t\t\t{\n\t\t\t\t\tlx.noTypedefName = true // https://github.com/cznic/sqlite2go/issues/9\n\t\t\t\t}\n\t\t\t\t'}'\n\t\t\t\t{\n\t\t\t\t\tif !lx.tweaks.EnableEmptyStructs {\n\t\t\t\t\t\tlx.err($1, \"empty structs/unions not allowed\")\n\t\t\t\t\t}\n\t\t\t\t}\n/*yy:case Define     */ |\tStructOrUnion IdentifierOpt '{'\n\t\t\t\t{\n\t\t\t\t\tlx.newStructScope()\n\t\t\t\t}\n\t\t\t\tStructDeclarationList\n\t\t\t\t{\n\t\t\t\t\tlx.noTypedefName = true // https://github.com/cznic/sqlite2go/issues/9\n\t\t\t\t}\n\t\t\t\t'}'\n\t\t\t\t{\n\t\t\t\t\tlhs.scope, _ = lx.popScope()\n\t\t\t\t}\n\n                        // [0]6.7.2.1\n/*yy:case Struct     */ StructOrUnion:\n                        \t\"struct\"\n/*yy:case Union      */ |\t\"union\"\n\n                        // [0]6.7.2.1\n                        StructDeclarationList:\n                        \tStructDeclaration\n                        |\tStructDeclarationList StructDeclaration\n\n                        // [0]6.7.2.1\n/*yy:case Base       */ StructDeclaration:\n\t\t\t\tSpecifierQualifierList StructDeclaratorList ';'\n/*yy:case Anon       */\t|\tSpecifierQualifierList ';'\n\t\t\t\t{\n\t\t\t\t\tif !lx.tweaks.EnableAnonymousStructFields {\n\t\t\t\t\t\tlx.err($1, \"anonymous structs/unions members not allowed\")\n\t\t\t\t\t}\n\t\t\t\t}\n\n                        // [0]6.7.2.1\n/*yy:case Qualifier  */ SpecifierQualifierList:\n                        \tTypeQualifier SpecifierQualifierListOpt\n/*yy:case Specifier  */ |\tTypeSpecifier SpecifierQualifierListOpt\n\n                        SpecifierQualifierListOpt:\n                        \t/* empty */ {}\n                        |\tSpecifierQualifierList\n\n                        // [0]6.7.2.1\n                        StructDeclaratorList:\n                        \tStructDeclarator\n                        |\tStructDeclaratorList ',' StructDeclarator\n\n                        // [0]6.7.2.1\n\t\t\t//yy:field\tBits\tint\n/*yy:case Base       */ StructDeclarator:\n                        \tDeclarator\n/*yy:case Bits       */ |\tDeclaratorOpt ':' ConstExpr\n\n                        CommaOpt:\n                        \t/* empty */ {}\n                        |\t','\n\n                        // [0]6.7.2.2\n\t\t\t//yy:field\tTag\tint\n\t\t\t//yy:field\tscope\t*Scope\t// Where to declare enumeration constants.\n\t\t\t//yy:field\ttyp\tType\n/*yy:case Tag        */ EnumSpecifier:\n                        \t\"enum\" IDENTIFIER\n\t\t\t\t{\n\t\t\t\t\tlhs.scope = lx.scope\n\t\t\t\t}\n/*yy:case Define     */ |\t\"enum\" IdentifierOpt '{' EnumeratorList  CommaOpt '}'\n\t\t\t\t{\n\t\t\t\t\tlhs.scope = lx.scope\n\t\t\t\t}\n\n                        // [0]6.7.2.2\n                        EnumeratorList:\n                        \tEnumerator\n                        |\tEnumeratorList ',' Enumerator\n\n                        // [0]6.7.2.2\n/*yy:case Base       */ Enumerator:\n                        \tEnumerationConstant\n/*yy:case Init       */ |\tEnumerationConstant '=' ConstExpr\n\n                        // [0]6.7.3\n/*yy:case Const      */ TypeQualifier:\n                        \t\"const\"\n/*yy:case Restrict   */ |\t\"restrict\"\n/*yy:case Volatile   */ |\t\"volatile\"\n\n                        // [0]6.7.4\n\t\t\tFunctionSpecifier:\n\t\t\t\t\"inline\"\n\n                        // [0]6.7.5\n\t\t\t//yy:field\tAssignedTo\t\tint\t\t\t// Declarator appears at the left side of assignment.\n\t\t\t//yy:field\tAttributes\t\t[][]xc.Token\n\t\t\t//yy:field\tBits\t\t\tint\t\t\t// StructDeclarator: bit width when a bit field.\n\t\t\t//yy:field\tDeclarationSpecifier\t*DeclarationSpecifier\t// Nil for embedded declarators.\n\t\t\t//yy:field\tDefinition\t\t*Declarator\t\t// Declaration -> definition.\n\t\t\t//yy:field\tField\t\t\tint\t\t\t// Declaration order# if struct field declarator.\n\t\t\t//yy:field\tFunctionDefinition\t*FunctionDefinition\t// When the declarator defines a function.\n\t\t\t//yy:field\tInitializer\t\t*Initializer\t\t// Only when part of an InitDeclarator.\n\t\t\t//yy:field\tLinkage\t\t\tLinkage\t\t\t// Linkage of the declared name, [0]6.2.2.\n\t\t\t//yy:field\tParameters\t\t[]*Declarator\t\t// Of the function declarator.\n\t\t\t//yy:field\tReferenced\t\tint\n\t\t\t//yy:field\tScope\t\t\t*Scope\t\t\t// Declaration scope.\n\t\t\t//yy:field\tScopeNum\t\tint\t\t\t// Sequential scope number within function body.\n\t\t\t//yy:field\tStorageDuration\t\tStorageDuration\t\t// Storage duration of the declared name, [0]6.2.4.\n\t\t\t//yy:field\tType\t\t\tType\t\t\t// Declared type.\n\t\t\t//yy:field\tTypeQualifiers\t\t[]*TypeQualifier\t// From the PointerOpt production, if any.\n\t\t\t//yy:field\tunnamed\t\t\tint\n\t\t\t//yy:field\tvars\t\t\t[]*Declarator\t\t// Function declarator only.\n\t\t\t//yy:field\tAddressTaken\t\tbool\n\t\t\t//yy:field\tAlloca\t\t\tbool\t\t\t// Function declarator: Body calls __builtin_alloca\n\t\t\t//yy:field\tEmbedded\t\tbool\t\t\t// [0]6.7.5-3: Not a full declarator.\n\t\t\t//yy:field\tIsField\t\t\tbool\n\t\t\t//yy:field\tIsFunctionParameter\tbool\n\t\t\t//yy:field\tIsBuiltin\t\tbool\n                        Declarator:\n                        \tPointerOpt DirectDeclarator\n\t\t\t\t{\n\t\t\t\t\tlhs.Attributes = lx.attrs()\n\t\t\t\t\tlhs.Scope = lx.scope\n\t\t\t\t\tif lx.scope.typedef {\n\t\t\t\t\t\tdelete(lx.scope.Idents, lhs.DirectDeclarator.nm())\n\t\t\t\t\t\tlx.scope.insertTypedef(lx.context, lhs)\n\t\t\t\t\t}\n\t\t\t\t}\n\n                        DeclaratorOpt:\n                        \t/* empty */ {}\n                        |\tDeclarator\n\n                        // [0]6.7.5\n\t\t\t//yy:field\tparamScope\t*Scope\n/*yy:case Paren      */ DirectDeclarator:\n                        \t'(' Declarator ')'\n\t\t\t\t{\n\t\t\t\t\tlhs.Declarator.Embedded = true\n\t\t\t\t}\n/*yy:case IdentList  */ |\tDirectDeclarator '('\n\t\t\t\t{\n\t\t\t\t\tlx.newScope()\n\t\t\t\t}\n\t\t\t\tIdentifierListOpt ')'\n\t\t\t\t{\n\t\t\t\t\tlhs.paramScope, _ = lx.popScope()\n\t\t\t\t}\n/*yy:case ParamList  */ |\tDirectDeclarator '('\n\t\t\t\t{\n\t\t\t\t\tlx.newScope()\n\t\t\t\t}\n\t\t\t\tParameterTypeList ')'\n\t\t\t\t{\n\t\t\t\t\tlhs.paramScope, _ = lx.popScope()\n\t\t\t\t}\n/*yy:case ArraySize  */ |\tDirectDeclarator '[' \"static\" TypeQualifierListOpt Expr ']'\n/*yy:case ArraySize2 */ |\tDirectDeclarator '[' TypeQualifierList \"static\" Expr ']'\n/*yy:case ArrayVar   */ |\tDirectDeclarator '[' TypeQualifierListOpt '*' ']'\n/*yy:case Array      */ |\tDirectDeclarator '[' TypeQualifierListOpt ExprOpt ']'\n/*yy:case Ident      */ |\tIDENTIFIER\n\n                        // [0]6.7.5\n/*yy:case Base       */ Pointer:\n                        \t'*' TypeQualifierListOpt\n/*yy:case Ptr        */ |\t'*' TypeQualifierListOpt Pointer\n\n                        PointerOpt:\n                        \t/* empty */ {}\n                        |\tPointer\n\n                        // [0]6.7.5\n                        TypeQualifierList:\n                        \tTypeQualifier\n                        |\tTypeQualifierList TypeQualifier\n\n                        TypeQualifierListOpt:\n                        \t/* empty */ {}\n                        |\tTypeQualifierList\n\n                        // [0]6.7.5\n/*yy:case Base       */ ParameterTypeList:\n                        \tParameterList\n/*yy:case Dots       */ |\tParameterList ',' \"...\"\n\n                        ParameterTypeListOpt:\n                        \t/* empty */ {}\n                        |\tParameterTypeList\n\n                        // [0]6.7.5\n                        ParameterList:\n                        \tParameterDeclaration\n                        |\tParameterList ',' ParameterDeclaration\n\n                        // [0]6.7.5\n/*yy:case Abstract   */ ParameterDeclaration:\n                        \tDeclarationSpecifiers AbstractDeclaratorOpt\n\t\t\t\t{\n\t\t\t\t\tlx.scope.typedef = false\n\t\t\t\t}\n/*yy:case Declarator */ |\tDeclarationSpecifiers Declarator\n\t\t\t\t{\n\t\t\t\t\tlx.scope.typedef = false\n\t\t\t\t}\n\n                        // [0]6.7.5\n                        IdentifierList:\n                        \tIDENTIFIER\n                        |\tIdentifierList ',' IDENTIFIER\n\n                        IdentifierListOpt:\n                        \t/* empty */ {}\n                        |\tIdentifierList\n\n                        IdentifierOpt:\n                        \t/* empty */ {}\n                        |\tIDENTIFIER\n\n                        // [0]6.7.6\n\t\t\t//yy:field\tType\t\t\tType\n                        TypeName:\n                        \tSpecifierQualifierList AbstractDeclaratorOpt\n\n                        // [0]6.7.6\n\t\t\t//yy:field\tDeclarationSpecifier\t*DeclarationSpecifier\n\t\t\t//yy:field\tType\t\t\tType\n\t\t\t//yy:field\tTypeQualifiers\t\t[]*TypeQualifier\t// From the PointerOpt production, if any.\n/*yy:case Pointer    */ AbstractDeclarator:\n                        \tPointer\n/*yy:case Abstract   */ |\tPointerOpt DirectAbstractDeclarator\n\n                        AbstractDeclaratorOpt:\n                        \t/* empty */ {}\n                        |\tAbstractDeclarator\n\n                        // [0]6.7.6\n/*yy:case Abstract   */ DirectAbstractDeclarator:\n                        \t'(' AbstractDeclarator ')'\n/*yy:case ParamList  */ |\t'(' ParameterTypeListOpt ')'\n/*yy:case DFn        */ |\tDirectAbstractDeclarator '(' ParameterTypeListOpt ')'\n/*yy:case DArrSize   */ |\tDirectAbstractDeclaratorOpt '[' \"static\" TypeQualifierListOpt Expr ']'\n/*yy:case DArrVL     */ |\tDirectAbstractDeclaratorOpt '[' '*' ']'\n/*yy:case DArr       */ |\tDirectAbstractDeclaratorOpt '[' ExprOpt ']'\n/*yy:case DArrSize2  */ |\tDirectAbstractDeclaratorOpt '[' TypeQualifierList \"static\" Expr ']'\n/*yy:case DArr2      */ |\tDirectAbstractDeclaratorOpt '[' TypeQualifierList ExprOpt ']'\n\n                        DirectAbstractDeclaratorOpt:\n                        \t/* empty */ {}\n                        |\tDirectAbstractDeclarator\n\n                        // [0]6.7.8\n/*yy:case CompLit    */ Initializer:\n                        \t'{' InitializerList CommaOpt '}'\n/*yy:case Expr       */ |\tExpr\n\n                        // [0]6.7.8\n\t\t\t//yy:field\tOperand\tOperand\t//TODO-\n\t\t\t//yy:field\tLen\tint\n                        InitializerList:\n                        \t/* empty */ {}\n                        |\tInitializer\n                        |\tDesignation Initializer\n                        |\tInitializerList ',' Initializer\n                        |\tInitializerList ',' Designation Initializer\n\n                        // [0]6.7.8\n\t\t\t//yy:field\tList\t[]int64\n                        Designation:\n                        \tDesignatorList '='\n\n                        // [0]6.7.8\n                        DesignatorList:\n                        \tDesignator\n                        |\tDesignatorList Designator\n\n                        // [0]6.7.8\n/*yy:case Field      */ Designator:\n                        \t'.' IDENTIFIER\n/*yy:case Index      */ |\t'[' ConstExpr ']'\n\n                        // [0]6.8\n/*yy:case Block      */ Stmt:\n\t\t\t\tCompoundStmt\n/*yy:case Expr       */ |\tExprStmt\n/*yy:case Iter       */ |\tIterationStmt\n/*yy:case Jump       */ |\tJumpStmt\n/*yy:case Labeled    */ |\tLabeledStmt\n/*yy:case Select     */ |\tSelectionStmt\n\n                        // [0]6.8.1\n/*yy:case SwitchCase */ LabeledStmt:\n                        \t\"case\" ConstExpr ':' Stmt\n/*yy:case Default    */ |\t\"default\" ':' Stmt\n/*yy:case Label      */ |\tIDENTIFIER ':' Stmt\n\t\t\t\t{\n\t\t\t\t\tlx.scope.insertLabel(lx.context, lhs)\n\t\t\t\t}\n/*yy:case Label2      */ |\tTYPEDEF_NAME ':' Stmt\n\t\t\t\t{\n\t\t\t\t\tlx.scope.insertLabel(lx.context, lhs)\n\t\t\t\t}\n\n                        // [0]6.8.2\n\t\t\t//yy:field\tscope\t*Scope\n                        CompoundStmt:\n\t\t\t\t'{'\n\t\t\t\t{\n\t\t\t\t\tlx.newScope()\n\t\t\t\t}\n\t\t\t\tBlockItemListOpt '}'\n\t\t\t\t{\n\t\t\t\t\tlhs.scope, _ = lx.popScope()\n\t\t\t\t}\n\n                        // [0]6.8.2\n                        BlockItemList:\n                        \tBlockItem\n                        |\tBlockItemList BlockItem\n\n                        BlockItemListOpt:\n                        \t/* empty */ {}\n                        |\tBlockItemList\n\n                        // [0]6.8.2\n/*yy:case Decl       */ BlockItem:\n                        \tDeclaration\n/*yy:case Stmt       */ |\tStmt\n\n                        // [0]6.8.3\n                        ExprStmt:\n                        \tExprListOpt ';'\n\n                        // [0]6.8.4\n\t\t\t//yy:field\tCases\t\t[]*LabeledStmt\n\t\t\t//yy:field\tSwitchOp\tOperand\t// Promoted switch operand\n/*yy:case IfElse     */ SelectionStmt:\n                        \t\"if\" '(' ExprList ')' Stmt \"else\" Stmt\n/*yy:case If         */ |\t\"if\" '(' ExprList ')' Stmt %prec NOELSE\n/*yy:case Switch     */ |\t\"switch\" '(' ExprList ')' Stmt\n\n                        // [0]6.8.5\n/*yy:case Do         */ IterationStmt:\n                        \t\"do\" Stmt \"while\" '(' ExprList ')' ';'\n/*yy:case ForDecl    */ |\t\"for\" '(' Declaration ExprListOpt ';' ExprListOpt ')' Stmt\n\t\t\t\t{\n\t\t\t\t\tlx.popScope()\n\t\t\t\t}\n/*yy:case For        */ |\t\"for\" '(' ExprListOpt ';' ExprListOpt ';' ExprListOpt ')' Stmt\n\t\t\t\t{\n\t\t\t\t\tlx.popScope()\n\t\t\t\t}\n/*yy:case While      */ |\t\"while\" '(' ExprList ')' Stmt\n\n                        // [0]6.8.6\n\t\t\t//yy:field\tReturnOperand\tOperand\n\t\t\t//yy:field\tscope\t\t*Scope\n/*yy:case Break      */ JumpStmt:\n                        \t\"break\" ';'\n/*yy:case Continue   */ |\t\"continue\" ';'\n/*yy:case Goto       */ |\t\"goto\" IDENTIFIER ';'\n\t\t\t\t{\n\t\t\t\t\tlhs.scope = lx.scope\n\t\t\t\t}\n/*yy:case Return     */ |\t\"return\" ExprListOpt ';'\n\n                        // [0]6.9\n                        //yy:list\n                        ExternalDeclarationList:\n                        \tExternalDeclaration\n                        |\tExternalDeclarationList ExternalDeclaration\n\n                        // [0]6.9\n/*yy:case Decl       */ ExternalDeclaration:\n\t\t\t\tDeclaration\n/*yy:case Func       */ |\tFunctionDefinition\n\n                        // [0]6.9.1\n/*yy:case Spec       */\tFunctionDefinition:\n                                DeclarationSpecifiers Declarator\n\t\t\t\t{\n\t\t\t\t\tlx.scope.typedef = false\n\t\t\t\t\tlx.currFn = $2.(*Declarator).Name()\n\t\t\t\t}\n\t\t\t\tDeclarationListOpt FunctionBody\n\t\t\t\t{\n\t\t\t\t\tlhs.Declarator.FunctionDefinition = lhs\n\t\t\t\t\tif lx.scope.Parent != nil {\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\t}\n\t\t\t\t}\n/*yy:case Int        */ |\tDeclarator\n\t\t\t\t{\n\t\t\t\t\tif !lx.tweaks.EnableOmitFuncDeclSpec {\n\t\t\t\t\t\tlx.err($1, \"omitting function declaration specifiers not allowed\")\n\t\t\t\t\t}\n\t\t\t\t\tlx.scope.typedef = false\n\t\t\t\t\tlx.currFn = $1.(*Declarator).Name()\n\t\t\t\t}\n\t\t\t\tDeclarationListOpt FunctionBody\n\t\t\t\t{\n\t\t\t\t\tlhs.Declarator.FunctionDefinition = lhs\n\t\t\t\t\tif lx.scope.Parent != nil {\n\t\t\t\t\t\tpanic(\"internal error\")\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tFunctionBody:\n\t\t\t\t{\n\t\t\t\t\tlx.declareFuncName() // [0], 6.4.2.2.\n\t\t\t\t}\n\t\t\t\tCompoundStmt\n\n                        // [0]6.9.1\n                        DeclarationList:\n                        \tDeclaration\n                        |\tDeclarationList Declaration\n\n                        DeclarationListOpt:\n                        \t/* empty */ {}\n                        |\tDeclarationList\n\n                        VolatileOpt:\n                        \t/* empty */ {}\n                        |\t\"volatile\"\n"
  },
  {
    "path": "v2/scanner.go",
    "content": "// Code generated by golex. DO NOT EDIT.\n\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\npackage cc\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cznic/golex/lex\"\n)\n\nconst (\n\t_         = iota\n\tscCOMMENT // [`/*`, `*/`]\n)\n\nfunc (l *lexer) scan() (r int) {\n\tc := l.Enter()\n\nyystate0:\n\tyyrule := -1\n\t_ = yyrule\n\tc = l.Rule0()\n\n\tswitch yyt := l.sc; yyt {\n\tdefault:\n\t\tpanic(fmt.Errorf(`invalid start condition %d`, yyt))\n\tcase 0: // start condition: INITIAL\n\t\tgoto yystart1\n\tcase 1: // start condition: COMMENT\n\t\tgoto yystart123\n\t}\n\n\tgoto yystate0 // silence unused label error\n\tgoto yyAction // silence unused label error\nyyAction:\n\tswitch yyrule {\n\tcase 1:\n\t\tgoto yyrule1\n\tcase 2:\n\t\tgoto yyrule2\n\tcase 3:\n\t\tgoto yyrule3\n\tcase 4:\n\t\tgoto yyrule4\n\tcase 5:\n\t\tgoto yyrule5\n\tcase 6:\n\t\tgoto yyrule6\n\tcase 7:\n\t\tgoto yyrule7\n\tcase 8:\n\t\tgoto yyrule8\n\tcase 9:\n\t\tgoto yyrule9\n\tcase 10:\n\t\tgoto yyrule10\n\tcase 11:\n\t\tgoto yyrule11\n\tcase 12:\n\t\tgoto yyrule12\n\tcase 13:\n\t\tgoto yyrule13\n\tcase 14:\n\t\tgoto yyrule14\n\tcase 15:\n\t\tgoto yyrule15\n\tcase 16:\n\t\tgoto yyrule16\n\tcase 17:\n\t\tgoto yyrule17\n\tcase 18:\n\t\tgoto yyrule18\n\tcase 19:\n\t\tgoto yyrule19\n\tcase 20:\n\t\tgoto yyrule20\n\tcase 21:\n\t\tgoto yyrule21\n\tcase 22:\n\t\tgoto yyrule22\n\tcase 23:\n\t\tgoto yyrule23\n\tcase 24:\n\t\tgoto yyrule24\n\tcase 25:\n\t\tgoto yyrule25\n\tcase 26:\n\t\tgoto yyrule26\n\tcase 27:\n\t\tgoto yyrule27\n\tcase 28:\n\t\tgoto yyrule28\n\tcase 29:\n\t\tgoto yyrule29\n\tcase 30:\n\t\tgoto yyrule30\n\tcase 31:\n\t\tgoto yyrule31\n\tcase 32:\n\t\tgoto yyrule32\n\tcase 33:\n\t\tgoto yyrule33\n\tcase 34:\n\t\tgoto yyrule34\n\tcase 35:\n\t\tgoto yyrule35\n\tcase 36:\n\t\tgoto yyrule36\n\tcase 37:\n\t\tgoto yyrule37\n\tcase 38:\n\t\tgoto yyrule38\n\tcase 39:\n\t\tgoto yyrule39\n\tcase 40:\n\t\tgoto yyrule40\n\tcase 41:\n\t\tgoto yyrule41\n\tcase 42:\n\t\tgoto yyrule42\n\tcase 43:\n\t\tgoto yyrule43\n\t}\n\tgoto yystate1 // silence unused label error\nyystate1:\n\tc = l.Next()\nyystart1:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate3\n\tcase c == '\"':\n\t\tgoto yystate5\n\tcase c == '#':\n\t\tgoto yystate16\n\tcase c == '%':\n\t\tgoto yystate20\n\tcase c == '&':\n\t\tgoto yystate27\n\tcase c == '*':\n\t\tgoto yystate42\n\tcase c == '+':\n\t\tgoto yystate44\n\tcase c == '-':\n\t\tgoto yystate47\n\tcase c == '.':\n\t\tgoto yystate51\n\tcase c == '/':\n\t\tgoto yystate65\n\tcase c == ':':\n\t\tgoto yystate69\n\tcase c == '<':\n\t\tgoto yystate71\n\tcase c == '=':\n\t\tgoto yystate77\n\tcase c == '>':\n\t\tgoto yystate79\n\tcase c == 'L':\n\t\tgoto yystate93\n\tcase c == '\\'':\n\t\tgoto yystate30\n\tcase c == '\\\\':\n\t\tgoto yystate84\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\tcase c == '\\u0080':\n\t\tgoto yystate122\n\tcase c == '^':\n\t\tgoto yystate117\n\tcase c == '|':\n\t\tgoto yystate119\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate54\n\tcase c >= 'A' && c <= 'K' || c >= 'M' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate83\n\t}\n\nyystate2:\n\tc = l.Next()\n\tyyrule = 1\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule1\n\tcase c == '\\t' || c == '\\v' || c == '\\f' || c == ' ':\n\t\tgoto yystate2\n\t}\n\nyystate3:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate4\n\t}\n\nyystate4:\n\tc = l.Next()\n\tyyrule = 7\n\tl.Mark()\n\tgoto yyrule7\n\nyystate5:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate7\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate5\n\t}\n\nyystate6:\n\tc = l.Next()\n\tyyrule = 43\n\tl.Mark()\n\tgoto yyrule43\n\nyystate7:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate5\n\tcase c == 'U':\n\t\tgoto yystate8\n\tcase c == 'u':\n\t\tgoto yystate12\n\tcase c == 'x':\n\t\tgoto yystate15\n\t}\n\nyystate8:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate9\n\t}\n\nyystate9:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate10\n\t}\n\nyystate10:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate11\n\t}\n\nyystate11:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate12\n\t}\n\nyystate12:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate13\n\t}\n\nyystate13:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate14\n\t}\n\nyystate14:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate15\n\t}\n\nyystate15:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate5\n\t}\n\nyystate16:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '#':\n\t\tgoto yystate17\n\tcase c == '%':\n\t\tgoto yystate18\n\t}\n\nyystate17:\n\tc = l.Next()\n\tyyrule = 34\n\tl.Mark()\n\tgoto yyrule34\n\nyystate18:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate19\n\t}\n\nyystate19:\n\tc = l.Next()\n\tyyrule = 35\n\tl.Mark()\n\tgoto yyrule35\n\nyystate20:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate21\n\tcase c == '=':\n\t\tgoto yystate25\n\tcase c == '>':\n\t\tgoto yystate26\n\t}\n\nyystate21:\n\tc = l.Next()\n\tyyrule = 8\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule8\n\tcase c == '#':\n\t\tgoto yystate22\n\tcase c == '%':\n\t\tgoto yystate23\n\t}\n\nyystate22:\n\tc = l.Next()\n\tyyrule = 36\n\tl.Mark()\n\tgoto yyrule36\n\nyystate23:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == ':':\n\t\tgoto yystate24\n\t}\n\nyystate24:\n\tc = l.Next()\n\tyyrule = 37\n\tl.Mark()\n\tgoto yyrule37\n\nyystate25:\n\tc = l.Next()\n\tyyrule = 9\n\tl.Mark()\n\tgoto yyrule9\n\nyystate26:\n\tc = l.Next()\n\tyyrule = 10\n\tl.Mark()\n\tgoto yyrule10\n\nyystate27:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '&':\n\t\tgoto yystate28\n\tcase c == '=':\n\t\tgoto yystate29\n\t}\n\nyystate28:\n\tc = l.Next()\n\tyyrule = 11\n\tl.Mark()\n\tgoto yyrule11\n\nyystate29:\n\tc = l.Next()\n\tyyrule = 12\n\tl.Mark()\n\tgoto yyrule12\n\nyystate30:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate33\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate31\n\t}\n\nyystate31:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\'':\n\t\tgoto yystate32\n\tcase c == '\\\\':\n\t\tgoto yystate33\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate31\n\t}\n\nyystate32:\n\tc = l.Next()\n\tyyrule = 40\n\tl.Mark()\n\tgoto yyrule40\n\nyystate33:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate31\n\tcase c == 'U':\n\t\tgoto yystate34\n\tcase c == 'u':\n\t\tgoto yystate38\n\tcase c == 'x':\n\t\tgoto yystate41\n\t}\n\nyystate34:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate35\n\t}\n\nyystate35:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate36\n\t}\n\nyystate36:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate37\n\t}\n\nyystate37:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate38\n\t}\n\nyystate38:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate39\n\t}\n\nyystate39:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate40\n\t}\n\nyystate40:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate41\n\t}\n\nyystate41:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate31\n\t}\n\nyystate42:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate43\n\t}\n\nyystate43:\n\tc = l.Next()\n\tyyrule = 13\n\tl.Mark()\n\tgoto yyrule13\n\nyystate44:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '+':\n\t\tgoto yystate45\n\tcase c == '=':\n\t\tgoto yystate46\n\t}\n\nyystate45:\n\tc = l.Next()\n\tyyrule = 14\n\tl.Mark()\n\tgoto yyrule14\n\nyystate46:\n\tc = l.Next()\n\tyyrule = 15\n\tl.Mark()\n\tgoto yyrule15\n\nyystate47:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '-':\n\t\tgoto yystate48\n\tcase c == '=':\n\t\tgoto yystate49\n\tcase c == '>':\n\t\tgoto yystate50\n\t}\n\nyystate48:\n\tc = l.Next()\n\tyyrule = 16\n\tl.Mark()\n\tgoto yyrule16\n\nyystate49:\n\tc = l.Next()\n\tyyrule = 17\n\tl.Mark()\n\tgoto yyrule17\n\nyystate50:\n\tc = l.Next()\n\tyyrule = 18\n\tl.Mark()\n\tgoto yyrule18\n\nyystate51:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '.':\n\t\tgoto yystate52\n\tcase c >= '0' && c <= '9':\n\t\tgoto yystate54\n\t}\n\nyystate52:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '.':\n\t\tgoto yystate53\n\t}\n\nyystate53:\n\tc = l.Next()\n\tyyrule = 19\n\tl.Mark()\n\tgoto yyrule19\n\nyystate54:\n\tc = l.Next()\n\tyyrule = 42\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule42\n\tcase c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate54\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate55\n\tcase c == '\\\\':\n\t\tgoto yystate56\n\t}\n\nyystate55:\n\tc = l.Next()\n\tyyrule = 42\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule42\n\tcase c == '+' || c == '-' || c == '.' || c >= '0' && c <= '9' || c >= 'A' && c <= 'D' || c >= 'F' && c <= 'O' || c >= 'Q' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'd' || c >= 'f' && c <= 'o' || c >= 'q' && c <= 'z' || c == '\\u0084':\n\t\tgoto yystate54\n\tcase c == 'E' || c == 'P' || c == 'e' || c == 'p':\n\t\tgoto yystate55\n\tcase c == '\\\\':\n\t\tgoto yystate56\n\t}\n\nyystate56:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == 'U':\n\t\tgoto yystate57\n\tcase c == 'u':\n\t\tgoto yystate61\n\t}\n\nyystate57:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate58\n\t}\n\nyystate58:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate59\n\t}\n\nyystate59:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate60\n\t}\n\nyystate60:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate61\n\t}\n\nyystate61:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate62\n\t}\n\nyystate62:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate63\n\t}\n\nyystate63:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate64\n\t}\n\nyystate64:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate54\n\t}\n\nyystate65:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate66\n\tcase c == '/':\n\t\tgoto yystate67\n\tcase c == '=':\n\t\tgoto yystate68\n\t}\n\nyystate66:\n\tc = l.Next()\n\tyyrule = 3\n\tl.Mark()\n\tgoto yyrule3\n\nyystate67:\n\tc = l.Next()\n\tyyrule = 2\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule2\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate67\n\t}\n\nyystate68:\n\tc = l.Next()\n\tyyrule = 20\n\tl.Mark()\n\tgoto yyrule20\n\nyystate69:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '>':\n\t\tgoto yystate70\n\t}\n\nyystate70:\n\tc = l.Next()\n\tyyrule = 21\n\tl.Mark()\n\tgoto yyrule21\n\nyystate71:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '%':\n\t\tgoto yystate72\n\tcase c == ':':\n\t\tgoto yystate73\n\tcase c == '<':\n\t\tgoto yystate74\n\tcase c == '=':\n\t\tgoto yystate76\n\t}\n\nyystate72:\n\tc = l.Next()\n\tyyrule = 22\n\tl.Mark()\n\tgoto yyrule22\n\nyystate73:\n\tc = l.Next()\n\tyyrule = 23\n\tl.Mark()\n\tgoto yyrule23\n\nyystate74:\n\tc = l.Next()\n\tyyrule = 24\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule24\n\tcase c == '=':\n\t\tgoto yystate75\n\t}\n\nyystate75:\n\tc = l.Next()\n\tyyrule = 25\n\tl.Mark()\n\tgoto yyrule25\n\nyystate76:\n\tc = l.Next()\n\tyyrule = 26\n\tl.Mark()\n\tgoto yyrule26\n\nyystate77:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate78\n\t}\n\nyystate78:\n\tc = l.Next()\n\tyyrule = 27\n\tl.Mark()\n\tgoto yyrule27\n\nyystate79:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate80\n\tcase c == '>':\n\t\tgoto yystate81\n\t}\n\nyystate80:\n\tc = l.Next()\n\tyyrule = 28\n\tl.Mark()\n\tgoto yyrule28\n\nyystate81:\n\tc = l.Next()\n\tyyrule = 29\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule29\n\tcase c == '=':\n\t\tgoto yystate82\n\t}\n\nyystate82:\n\tc = l.Next()\n\tyyrule = 30\n\tl.Mark()\n\tgoto yyrule30\n\nyystate83:\n\tc = l.Next()\n\tyyrule = 41\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule41\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate83\n\tcase c == '\\\\':\n\t\tgoto yystate84\n\t}\n\nyystate84:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == 'U':\n\t\tgoto yystate85\n\tcase c == 'u':\n\t\tgoto yystate89\n\t}\n\nyystate85:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate86\n\t}\n\nyystate86:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate87\n\t}\n\nyystate87:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate88\n\t}\n\nyystate88:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate89\n\t}\n\nyystate89:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate90\n\t}\n\nyystate90:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate91\n\t}\n\nyystate91:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate92\n\t}\n\nyystate92:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate83\n\t}\n\nyystate93:\n\tc = l.Next()\n\tyyrule = 41\n\tl.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule41\n\tcase c == '\"':\n\t\tgoto yystate94\n\tcase c == '$' || c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c == '_' || c >= 'a' && c <= 'z' || c == '\\u0083' || c == '\\u0084':\n\t\tgoto yystate83\n\tcase c == '\\'':\n\t\tgoto yystate105\n\tcase c == '\\\\':\n\t\tgoto yystate84\n\t}\n\nyystate94:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"':\n\t\tgoto yystate95\n\tcase c == '\\\\':\n\t\tgoto yystate96\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '!' || c >= '#' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate94\n\t}\n\nyystate95:\n\tc = l.Next()\n\tyyrule = 39\n\tl.Mark()\n\tgoto yyrule39\n\nyystate96:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate94\n\tcase c == 'U':\n\t\tgoto yystate97\n\tcase c == 'u':\n\t\tgoto yystate101\n\tcase c == 'x':\n\t\tgoto yystate104\n\t}\n\nyystate97:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate98\n\t}\n\nyystate98:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate99\n\t}\n\nyystate99:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate100\n\t}\n\nyystate100:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate101\n\t}\n\nyystate101:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate102\n\t}\n\nyystate102:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate103\n\t}\n\nyystate103:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate104\n\t}\n\nyystate104:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate94\n\t}\n\nyystate105:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate106\n\t}\n\nyystate106:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\'':\n\t\tgoto yystate107\n\tcase c == '\\\\':\n\t\tgoto yystate108\n\tcase c >= '\\x01' && c <= '\\t' || c >= '\\v' && c <= '&' || c >= '(' && c <= '[' || c >= ']' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate106\n\t}\n\nyystate107:\n\tc = l.Next()\n\tyyrule = 38\n\tl.Mark()\n\tgoto yyrule38\n\nyystate108:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\"' || c == '\\'' || c >= '0' && c <= '7' || c == '?' || c == '\\\\' || c == 'a' || c == 'b' || c == 'f' || c == 'n' || c == 'r' || c == 't' || c == 'v':\n\t\tgoto yystate106\n\tcase c == 'U':\n\t\tgoto yystate109\n\tcase c == 'u':\n\t\tgoto yystate113\n\tcase c == 'x':\n\t\tgoto yystate116\n\t}\n\nyystate109:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate110\n\t}\n\nyystate110:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate111\n\t}\n\nyystate111:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate112\n\t}\n\nyystate112:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate113\n\t}\n\nyystate113:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate114\n\t}\n\nyystate114:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate115\n\t}\n\nyystate115:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate116\n\t}\n\nyystate116:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f':\n\t\tgoto yystate106\n\t}\n\nyystate117:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate118\n\t}\n\nyystate118:\n\tc = l.Next()\n\tyyrule = 31\n\tl.Mark()\n\tgoto yyrule31\n\nyystate119:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '=':\n\t\tgoto yystate120\n\tcase c == '|':\n\t\tgoto yystate121\n\t}\n\nyystate120:\n\tc = l.Next()\n\tyyrule = 32\n\tl.Mark()\n\tgoto yyrule32\n\nyystate121:\n\tc = l.Next()\n\tyyrule = 33\n\tl.Mark()\n\tgoto yyrule33\n\nyystate122:\n\tc = l.Next()\n\tyyrule = 6\n\tl.Mark()\n\tgoto yyrule6\n\n\tgoto yystate123 // silence unused label error\nyystate123:\n\tc = l.Next()\nyystart123:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate125\n\tcase c == '\\u0080':\n\t\tgoto yystate127\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate124\n\t}\n\nyystate124:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate125\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate124\n\t}\n\nyystate125:\n\tc = l.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '*':\n\t\tgoto yystate125\n\tcase c == '/':\n\t\tgoto yystate126\n\tcase c >= '\\x01' && c <= ')' || c >= '+' && c <= '.' || c >= '0' && c <= '\\u007f' || c >= '\\u0081' && c <= 'ÿ':\n\t\tgoto yystate124\n\t}\n\nyystate126:\n\tc = l.Next()\n\tyyrule = 4\n\tl.Mark()\n\tgoto yyrule4\n\nyystate127:\n\tc = l.Next()\n\tyyrule = 5\n\tl.Mark()\n\tgoto yyrule5\n\nyyrule1: // [ \\t\\f\\v]+\n\t{\n\t\treturn ' '\n\t}\nyyrule2: // \"//\"[^\\x80\\n]*\n\t{\n\t\tl.comment(false)\n\t\treturn ' '\n\t}\nyyrule3: // \"/*\"\n\t{\n\t\tl.commentPos0 = l.First.Pos()\n\t\tl.sc = scCOMMENT\n\t\tgoto yystate0\n\t}\nyyrule4: // {comment-close}\n\t{\n\t\tl.sc = scINITIAL\n\t\tl.First = lex.NewChar(l.commentPos0, l.First.Rune)\n\t\tl.comment(true)\n\t\treturn ' '\n\t}\nyyrule5: // {eof}\n\t{\n\t\tl.errPos(l.commentPos0, \"unterminated comment\")\n\t\tl.sc = scINITIAL\n\t\treturn rune2class(lex.RuneEOF)\n\t}\nyyrule6: // {eof}\n\t{\n\t\treturn rune2class(lex.RuneEOF)\n\t}\nyyrule7: // \"!=\"\n\t{\n\t\treturn NEQ\n\t}\nyyrule8: // \"%:\"\n\t{\n\t\treturn '#'\n\t}\nyyrule9: // \"%=\"\n\t{\n\t\treturn MODASSIGN\n\t}\nyyrule10: // \"%>\"\n\t{\n\t\treturn '}'\n\t}\nyyrule11: // \"&&\"\n\t{\n\t\treturn ANDAND\n\t}\nyyrule12: // \"&=\"\n\t{\n\t\treturn ANDASSIGN\n\t}\nyyrule13: // \"*=\"\n\t{\n\t\treturn MULASSIGN\n\t}\nyyrule14: // \"++\"\n\t{\n\t\treturn INC\n\t}\nyyrule15: // \"+=\"\n\t{\n\t\treturn ADDASSIGN\n\t}\nyyrule16: // \"--\"\n\t{\n\t\treturn DEC\n\t}\nyyrule17: // \"-=\"\n\t{\n\t\treturn SUBASSIGN\n\t}\nyyrule18: // \"->\"\n\t{\n\t\treturn ARROW\n\t}\nyyrule19: // \"...\"\n\t{\n\t\treturn DDD\n\t}\nyyrule20: // \"/=\"\n\t{\n\t\treturn DIVASSIGN\n\t}\nyyrule21: // \":>\"\n\t{\n\t\treturn ']'\n\t}\nyyrule22: // \"<%\"\n\t{\n\t\treturn '{'\n\t}\nyyrule23: // \"<:\"\n\t{\n\t\treturn '['\n\t}\nyyrule24: // \"<<\"\n\t{\n\t\treturn LSH\n\t}\nyyrule25: // \"<<=\"\n\t{\n\t\treturn LSHASSIGN\n\t}\nyyrule26: // \"<=\"\n\t{\n\t\treturn LEQ\n\t}\nyyrule27: // \"==\"\n\t{\n\t\treturn EQ\n\t}\nyyrule28: // \">=\"\n\t{\n\t\treturn GEQ\n\t}\nyyrule29: // \">>\"\n\t{\n\t\treturn RSH\n\t}\nyyrule30: // \">>=\"\n\t{\n\t\treturn RSHASSIGN\n\t}\nyyrule31: // \"^=\"\n\t{\n\t\treturn XORASSIGN\n\t}\nyyrule32: // \"|=\"\n\t{\n\t\treturn ORASSIGN\n\t}\nyyrule33: // \"||\"\n\t{\n\t\treturn OROR\n\t}\nyyrule34: // \"##\"\nyyrule35: // \"#%:\"\nyyrule36: // \"%:#\"\nyyrule37: // \"%:%:\"\n\t{\n\t\treturn PPPASTE\n\t}\nyyrule38: // L{character-constant}\n\t{\n\t\treturn LONGCHARCONST\n\t}\nyyrule39: // L{string-literal}\n\t{\n\t\treturn LONGSTRINGLITERAL\n\t}\nyyrule40: // {character-constant}\n\t{\n\t\treturn CHARCONST\n\t}\nyyrule41: // {identifier}\n\t{\n\t\treturn IDENTIFIER\n\t}\nyyrule42: // {pp-number}\n\t{\n\t\treturn PPNUMBER\n\t}\nyyrule43: // {string-literal}\n\t{\n\t\treturn STRINGLITERAL\n\t}\n\tpanic(\"unreachable\")\n\n\tgoto yyabort // silence unused label error\n\nyyabort: // no lexem recognized\n\tif c, ok := l.Abort(); ok {\n\t\treturn c\n\t}\n\n\tgoto yyAction\n}\n"
  },
  {
    "path": "v2/scanner.l",
    "content": "%{\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n%}\n\n%yyc c\n%yyn c = l.Next()\n%yym l.Mark()\n%yyt l.sc\n\n%x COMMENT\n\n%{\npackage cc\n\nimport (\n        \"fmt\"\n\n        \"github.com/cznic/golex/lex\"\n)\n\nconst (\n        _ = iota\n        scCOMMENT       // [`/*`, `*/`]\n)\n\nfunc (l *lexer) scan() (r int) {\n        c := l.Enter()\n%}\n\nbinary-constant                 {binary-prefix}{binary-digit}+\nbinary-digit                    [01]\nbinary-exponent-part            [pP]{sign}?{digit-sequence}\nbinary-prefix                   0[bB]\nc-char                          [^'\\n\\x80\\\\]|{escape-sequence}\nc-char-sequence                 {c-char}+\ncharacter-constant              '{c-char-sequence}'\ncomment-close                   ([^*\\x80]|\\*+[^*/\\x80])*\\*+\\/\ndecimal-constant                {nonzero-digit}{digit}*\ndigit                           [0-9]\ndigit-sequence                  {digit}+\neof                             \\x80\nescape-sequence                 {simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}\nexponent-part                   [eE]{sign}?{digit-sequence}\nfractional-constant             {digit-sequence}?\\.{digit-sequence}|{digit-sequence}\\.\nh-char                          [^>\\n\\x80]\nh-char-sequence                 {h-char}+\nhex-quad                        {hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}\nhexadecimal-constant            {hexadecimal-prefix}{hexadecimal-digit}+\nhexadecimal-digit               [0-9a-fA-F]\nhexadecimal-digit-sequence      {hexadecimal-digit}+\nhexadecimal-escape-sequence     \\\\x{hexadecimal-digit}+\nhexadecimal-prefix              0[xX]\nidentifier                      {identifier-nondigit}({identifier-nondigit}|{digit}|{ucn-digit}|\"$\")*\nidentifier-nondigit             {nondigit}|{universal-character-name}|{ucn-nondigit}\nnondigit                        [_a-zA-Z]\nnonzero-digit                   [1-9]\noctal-constant                  0{octal-digit}*\noctal-digit                     [0-7]\noctal-escape-sequence           \\\\{octal-digit}{octal-digit}?{octal-digit}?\npp-number                       ({digit}|\\.{digit})({digit}|{identifier-nondigit}|[eEpP]{sign}|\\.)*\nq-char                          [^\\n\\x22\\x80]\nq-char-sequence                 {q-char}+\ns-char                          [^\\x22\\n\\x80\\\\]|{escape-sequence}\ns-char-sequence                 {s-char}+\nsign                            [-+]\nsimple-sequence                 \\\\['\\x22?\\\\abfnrtv]\nstring-literal                  \\x22{s-char-sequence}?\\x22\nucn-digit                       \\x83\nucn-nondigit                    \\x84\nuniversal-character-name        \\\\u{hex-quad}|\\\\U{hex-quad}{hex-quad}\nunsigned-suffix                 [uU]\n\n%%\n                                c = l.Rule0()\n\n[ \\t\\f\\v]+\t\t\treturn ' '\n\n\"//\"[^\\x80\\n]*\t\t\tl.comment(false)\n\t\t\t\treturn ' '\n\n\"/*\"\t\t\t\tl.commentPos0 = l.First.Pos()\n                                l.sc = scCOMMENT\n\n<COMMENT>{comment-close}        l.sc = scINITIAL\n\t\t\t\tl.First = lex.NewChar(l.commentPos0, l.First.Rune)\n\t\t\t\tl.comment(true)\n\t\t\t\treturn ' '\n\n<COMMENT>{eof}                  l.errPos(l.commentPos0, \"unterminated comment\")\n                                l.sc = scINITIAL\n                                return rune2class(lex.RuneEOF)\n\n<*>{eof}                        return rune2class(lex.RuneEOF)\n\n\"!=\"                            return NEQ\n\"%:\"                            return '#'\n\"%=\"                            return MODASSIGN\n\"%>\"                            return '}'\n\"&&\"                            return ANDAND\n\"&=\"                            return ANDASSIGN\n\"*=\"                            return MULASSIGN\n\"++\"                            return INC\n\"+=\"                            return ADDASSIGN\n\"--\"                            return DEC\n\"-=\"                            return SUBASSIGN\n\"->\"                            return ARROW\n\"...\"                           return DDD\n\"/=\"                            return DIVASSIGN\n\":>\"                            return ']'\n\"<%\"                            return '{'\n\"<:\"                            return '['\n\"<<\"                            return LSH\n\"<<=\"                           return LSHASSIGN\n\"<=\"                            return LEQ\n\"==\"                            return EQ\n\">=\"                            return GEQ\n\">>\"                            return RSH\n\">>=\"                           return RSHASSIGN\n\"^=\"                            return XORASSIGN\n\"|=\"                            return ORASSIGN\n\"||\"                            return OROR\n\n\"##\"                            |\n\"#%:\"                           |\n\"%:#\"                           |\n\"%:%:\"                          return PPPASTE\n\nL{character-constant}           return LONGCHARCONST\nL{string-literal}               return LONGSTRINGLITERAL\n{character-constant}            return CHARCONST\n{identifier}                    return IDENTIFIER\n{pp-number}                     return PPNUMBER\n{string-literal}                return STRINGLITERAL\n\n%%\n        if c, ok := l.Abort(); ok {\n                return c\n        }\n        \n        goto yyAction\n}\n"
  },
  {
    "path": "v2/stringer.go",
    "content": "// Code generated by \"stringer -output stringer.go -type=cond,Linkage,StorageDuration enum.go\"; DO NOT EDIT.\n\npackage cc\n\nimport \"strconv\"\n\nconst _cond_name = \"condZerocondIfOffcondIfOncondIfSkipmaxCond\"\n\nvar _cond_index = [...]uint8{0, 8, 17, 25, 35, 42}\n\nfunc (i cond) String() string {\n\tif i < 0 || i >= cond(len(_cond_index)-1) {\n\t\treturn \"cond(\" + strconv.FormatInt(int64(i), 10) + \")\"\n\t}\n\treturn _cond_name[_cond_index[i]:_cond_index[i+1]]\n}\n\nconst _Linkage_name = \"LinkageNoneLinkageExternalLinkageInternal\"\n\nvar _Linkage_index = [...]uint8{0, 11, 26, 41}\n\nfunc (i Linkage) String() string {\n\tif i < 0 || i >= Linkage(len(_Linkage_index)-1) {\n\t\treturn \"Linkage(\" + strconv.FormatInt(int64(i), 10) + \")\"\n\t}\n\treturn _Linkage_name[_Linkage_index[i]:_Linkage_index[i+1]]\n}\n\nconst _StorageDuration_name = \"StorageDurationAutomaticStorageDurationStatic\"\n\nvar _StorageDuration_index = [...]uint8{0, 24, 45}\n\nfunc (i StorageDuration) String() string {\n\tif i < 0 || i >= StorageDuration(len(_StorageDuration_index)-1) {\n\t\treturn \"StorageDuration(\" + strconv.FormatInt(int64(i), 10) + \")\"\n\t}\n\treturn _StorageDuration_name[_StorageDuration_index[i]:_StorageDuration_index[i+1]]\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/LICENSE",
    "content": "SQLite Is Public Domain\n\nAll of the code and documentation in SQLite has been dedicated to the public\ndomain by the authors. All code authors, and representatives of the companies\nthey work for, have signed affidavits dedicating their contributions to the\npublic domain and originals of those signed affidavits are stored in a firesafe\nat the main offices of Hwaci. Anyone is free to copy, modify, publish, use,\ncompile, sell, or distribute the original SQLite code, either in source code\nform or as a compiled binary, for any purpose, commercial or non-commercial,\nand by any means.\n\nThe previous paragraph applies to the deliverable code and documentation in\nSQLite - those parts of the SQLite library that you actually bundle and ship\nwith a larger application. Some scripts used as part of the build process (for\nexample the \"configure\" scripts generated by autoconf) might fall under other\nopen-source licenses. Nothing from these build scripts ever reaches the final\ndeliverable SQLite library, however, and so the licenses associated with those\nscripts should not be a factor in assessing your rights to copy and use the\nSQLite library.\n\nAll of the deliverable code in SQLite has been written from scratch. No code\nhas been taken from other projects or from the open internet. Every line of\ncode can be traced back to its original author, and all of those authors have\npublic domain dedications on file. So the SQLite code base is clean and is\nuncontaminated with licensed code from other projects.\n\nsrc: https://sqlite.org/copyright.html\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/README.md",
    "content": "## Loadable Extensions\n\nVarious [loadable extensions](https://www.sqlite.org/loadext.html) for\nSQLite are found in subfolders.\n\nMost subfolders are dedicated to a single loadable extension (for\nexample FTS5, or RTREE).  But the misc/ subfolder contains a collection\nof smaller single-file extensions.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/async/README.txt",
    "content": "NOTE (2012-11-29):\n\nThe functionality implemented by this extension has been superseded\nby WAL-mode.  This module is no longer supported or maintained.  The\ncode is retained for historical reference only.\n\n------------------------------------------------------------------------------\n\nNormally, when SQLite writes to a database file, it waits until the write\noperation is finished before returning control to the calling application.\nSince writing to the file-system is usually very slow compared with CPU\nbound operations, this can be a performance bottleneck. This directory\ncontains an extension that causes SQLite to perform all write requests\nusing a separate thread running in the background. Although this does not\nreduce the overall system resources (CPU, disk bandwidth etc.) at all, it\nallows SQLite to return control to the caller quickly even when writing to\nthe database, eliminating the bottleneck.\n\n  1. Functionality\n\n    1.1 How it Works\n    1.2 Limitations\n    1.3 Locking and Concurrency\n\n  2. Compilation and Usage\n\n  3. Porting\n\n\n\n1. FUNCTIONALITY\n\n  With asynchronous I/O, write requests are handled by a separate thread\n  running in the background.  This means that the thread that initiates\n  a database write does not have to wait for (sometimes slow) disk I/O\n  to occur.  The write seems to happen very quickly, though in reality\n  it is happening at its usual slow pace in the background.\n\n  Asynchronous I/O appears to give better responsiveness, but at a price.\n  You lose the Durable property.  With the default I/O backend of SQLite,\n  once a write completes, you know that the information you wrote is\n  safely on disk.  With the asynchronous I/O, this is not the case.  If\n  your program crashes or if a power loss occurs after the database\n  write but before the asynchronous write thread has completed, then the\n  database change might never make it to disk and the next user of the\n  database might not see your change.\n\n  You lose Durability with asynchronous I/O, but you still retain the\n  other parts of ACID:  Atomic,  Consistent, and Isolated.  Many\n  appliations get along fine without the Durablity.\n\n  1.1 How it Works\n\n    Asynchronous I/O works by creating a special SQLite \"vfs\" structure\n    and registering it with sqlite3_vfs_register(). When files opened via \n    this vfs are written to (using the vfs xWrite() method), the data is not \n    written directly to disk, but is placed in the \"write-queue\" to be\n    handled by the background thread.\n\n    When files opened with the asynchronous vfs are read from \n    (using the vfs xRead() method), the data is read from the file on \n    disk and the write-queue, so that from the point of view of\n    the vfs reader the xWrite() appears to have already completed.\n\n    The special vfs is registered (and unregistered) by calls to the \n    API functions sqlite3async_initialize() and sqlite3async_shutdown().\n    See section \"Compilation and Usage\" below for details.\n\n  1.2 Limitations\n\n    In order to gain experience with the main ideas surrounding asynchronous \n    IO, this implementation is deliberately kept simple. Additional \n    capabilities may be added in the future.\n\n    For example, as currently implemented, if writes are happening at a \n    steady stream that exceeds the I/O capability of the background writer\n    thread, the queue of pending write operations will grow without bound.\n    If this goes on for long enough, the host system could run out of memory. \n    A more sophisticated module could to keep track of the quantity of \n    pending writes and stop accepting new write requests when the queue of \n    pending writes grows too large.\n\n  1.3 Locking and Concurrency\n\n    Multiple connections from within a single process that use this\n    implementation of asynchronous IO may access a single database\n    file concurrently. From the point of view of the user, if all\n    connections are from within a single process, there is no difference\n    between the concurrency offered by \"normal\" SQLite and SQLite\n    using the asynchronous backend.\n\n    If file-locking is enabled (it is enabled by default), then connections\n    from multiple processes may also read and write the database file.\n    However concurrency is reduced as follows:\n\n      * When a connection using asynchronous IO begins a database\n        transaction, the database is locked immediately. However the\n        lock is not released until after all relevant operations\n        in the write-queue have been flushed to disk. This means\n        (for example) that the database may remain locked for some \n        time after a \"COMMIT\" or \"ROLLBACK\" is issued.\n\n      * If an application using asynchronous IO executes transactions\n        in quick succession, other database users may be effectively\n        locked out of the database. This is because when a BEGIN\n        is executed, a database lock is established immediately. But\n        when the corresponding COMMIT or ROLLBACK occurs, the lock\n        is not released until the relevant part of the write-queue \n        has been flushed through. As a result, if a COMMIT is followed\n        by a BEGIN before the write-queue is flushed through, the database \n        is never unlocked,preventing other processes from accessing \n        the database.\n\n    File-locking may be disabled at runtime using the sqlite3async_control()\n    API (see below). This may improve performance when an NFS or other \n    network file-system, as the synchronous round-trips to the server be \n    required to establish file locks are avoided. However, if multiple \n    connections attempt to access the same database file when file-locking\n    is disabled, application crashes and database corruption is a likely\n    outcome.\n\n\n2. COMPILATION AND USAGE\n\n  The asynchronous IO extension consists of a single file of C code\n  (sqlite3async.c), and a header file (sqlite3async.h) that defines the \n  C API used by applications to activate and control the modules \n  functionality.\n\n  To use the asynchronous IO extension, compile sqlite3async.c as\n  part of the application that uses SQLite. Then use the API defined\n  in sqlite3async.h to initialize and configure the module.\n\n  The asynchronous IO VFS API is described in detail in comments in \n  sqlite3async.h. Using the API usually consists of the following steps:\n\n    1. Register the asynchronous IO VFS with SQLite by calling the\n       sqlite3async_initialize() function.\n\n    2. Create a background thread to perform write operations and call\n       sqlite3async_run().\n\n    3. Use the normal SQLite API to read and write to databases via \n       the asynchronous IO VFS.\n\n  Refer to sqlite3async.h for details.\n\n\n3. PORTING\n\n  Currently the asynchronous IO extension is compatible with win32 systems\n  and systems that support the pthreads interface, including Mac OSX, Linux, \n  and other varieties of Unix. \n\n  To port the asynchronous IO extension to another platform, the user must\n  implement mutex and condition variable primitives for the new platform.\n  Currently there is no externally available interface to allow this, but\n  modifying the code within sqlite3async.c to include the new platforms\n  concurrency primitives is relatively easy. Search within sqlite3async.c\n  for the comment string \"PORTING FUNCTIONS\" for details. Then implement\n  new versions of each of the following:\n\n    static void async_mutex_enter(int eMutex);\n    static void async_mutex_leave(int eMutex);\n    static void async_cond_wait(int eCond, int eMutex);\n    static void async_cond_signal(int eCond);\n    static void async_sched_yield(void);\n\n  The functionality required of each of the above functions is described\n  in comments in sqlite3async.c.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/async/sqlite3async.c",
    "content": "/*\n** 2005 December 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** $Id: sqlite3async.c,v 1.7 2009/07/18 11:52:04 danielk1977 Exp $\n**\n** This file contains the implementation of an asynchronous IO backend \n** for SQLite.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ASYNCIO)\n\n#include \"sqlite3async.h\"\n#include \"sqlite3.h\"\n#include <stdarg.h>\n#include <string.h>\n#include <assert.h>\n\n/* Useful macros used in several places */\n#define MIN(x,y) ((x)<(y)?(x):(y))\n#define MAX(x,y) ((x)>(y)?(x):(y))\n\n#ifndef SQLITE_AMALGAMATION\n/* Macro to mark parameters as unused and silence compiler warnings. */\n#define UNUSED_PARAMETER(x) (void)(x)\n#endif\n\n/* Forward references */\ntypedef struct AsyncWrite AsyncWrite;\ntypedef struct AsyncFile AsyncFile;\ntypedef struct AsyncFileData AsyncFileData;\ntypedef struct AsyncFileLock AsyncFileLock;\ntypedef struct AsyncLock AsyncLock;\n\n/* Enable for debugging */\n#ifndef NDEBUG\n#include <stdio.h>\nstatic int sqlite3async_trace = 0;\n# define ASYNC_TRACE(X) if( sqlite3async_trace ) asyncTrace X\nstatic void asyncTrace(const char *zFormat, ...){\n  char *z;\n  va_list ap;\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  fprintf(stderr, \"[%d] %s\", 0 /* (int)pthread_self() */, z);\n  sqlite3_free(z);\n}\n#else\n# define ASYNC_TRACE(X)\n#endif\n\n/*\n** THREAD SAFETY NOTES\n**\n** Basic rules:\n**\n**     * Both read and write access to the global write-op queue must be \n**       protected by the async.queueMutex. As are the async.ioError and\n**       async.nFile variables.\n**\n**     * The async.pLock list and all AsyncLock and AsyncFileLock\n**       structures must be protected by the async.lockMutex mutex.\n**\n**     * The file handles from the underlying system are not assumed to \n**       be thread safe.\n**\n**     * See the last two paragraphs under \"The Writer Thread\" for\n**       an assumption to do with file-handle synchronization by the Os.\n**\n** Deadlock prevention:\n**\n**     There are three mutex used by the system: the \"writer\" mutex, \n**     the \"queue\" mutex and the \"lock\" mutex. Rules are:\n**\n**     * It is illegal to block on the writer mutex when any other mutex\n**       are held, and \n**\n**     * It is illegal to block on the queue mutex when the lock mutex\n**       is held.\n**\n**     i.e. mutex's must be grabbed in the order \"writer\", \"queue\", \"lock\".\n**\n** File system operations (invoked by SQLite thread):\n**\n**     xOpen\n**     xDelete\n**     xFileExists\n**\n** File handle operations (invoked by SQLite thread):\n**\n**         asyncWrite, asyncClose, asyncTruncate, asyncSync \n**    \n**     The operations above add an entry to the global write-op list. They\n**     prepare the entry, acquire the async.queueMutex momentarily while\n**     list pointers are  manipulated to insert the new entry, then release\n**     the mutex and signal the writer thread to wake up in case it happens\n**     to be asleep.\n**\n**    \n**         asyncRead, asyncFileSize.\n**\n**     Read operations. Both of these read from both the underlying file\n**     first then adjust their result based on pending writes in the \n**     write-op queue.   So async.queueMutex is held for the duration\n**     of these operations to prevent other threads from changing the\n**     queue in mid operation.\n**    \n**\n**         asyncLock, asyncUnlock, asyncCheckReservedLock\n**    \n**     These primitives implement in-process locking using a hash table\n**     on the file name.  Files are locked correctly for connections coming\n**     from the same process.  But other processes cannot see these locks\n**     and will therefore not honor them.\n**\n**\n** The writer thread:\n**\n**     The async.writerMutex is used to make sure only there is only\n**     a single writer thread running at a time.\n**\n**     Inside the writer thread is a loop that works like this:\n**\n**         WHILE (write-op list is not empty)\n**             Do IO operation at head of write-op list\n**             Remove entry from head of write-op list\n**         END WHILE\n**\n**     The async.queueMutex is always held during the <write-op list is \n**     not empty> test, and when the entry is removed from the head\n**     of the write-op list. Sometimes it is held for the interim\n**     period (while the IO is performed), and sometimes it is\n**     relinquished. It is relinquished if (a) the IO op is an\n**     ASYNC_CLOSE or (b) when the file handle was opened, two of\n**     the underlying systems handles were opened on the same\n**     file-system entry.\n**\n**     If condition (b) above is true, then one file-handle \n**     (AsyncFile.pBaseRead) is used exclusively by sqlite threads to read the\n**     file, the other (AsyncFile.pBaseWrite) by sqlite3_async_flush() \n**     threads to perform write() operations. This means that read \n**     operations are not blocked by asynchronous writes (although \n**     asynchronous writes may still be blocked by reads).\n**\n**     This assumes that the OS keeps two handles open on the same file\n**     properly in sync. That is, any read operation that starts after a\n**     write operation on the same file system entry has completed returns\n**     data consistent with the write. We also assume that if one thread \n**     reads a file while another is writing it all bytes other than the\n**     ones actually being written contain valid data.\n**\n**     If the above assumptions are not true, set the preprocessor symbol\n**     SQLITE_ASYNC_TWO_FILEHANDLES to 0.\n*/\n\n\n#ifndef NDEBUG\n# define TESTONLY( X ) X\n#else\n# define TESTONLY( X )\n#endif\n\n/*\n** PORTING FUNCTIONS\n**\n** There are two definitions of the following functions. One for pthreads\n** compatible systems and one for Win32. These functions isolate the OS\n** specific code required by each platform.\n**\n** The system uses three mutexes and a single condition variable. To\n** block on a mutex, async_mutex_enter() is called. The parameter passed\n** to async_mutex_enter(), which must be one of ASYNC_MUTEX_LOCK,\n** ASYNC_MUTEX_QUEUE or ASYNC_MUTEX_WRITER, identifies which of the three\n** mutexes to lock. Similarly, to unlock a mutex, async_mutex_leave() is\n** called with a parameter identifying the mutex being unlocked. Mutexes\n** are not recursive - it is an error to call async_mutex_enter() to\n** lock a mutex that is already locked, or to call async_mutex_leave()\n** to unlock a mutex that is not currently locked.\n**\n** The async_cond_wait() and async_cond_signal() functions are modelled\n** on the pthreads functions with similar names. The first parameter to\n** both functions is always ASYNC_COND_QUEUE. When async_cond_wait()\n** is called the mutex identified by the second parameter must be held.\n** The mutex is unlocked, and the calling thread simultaneously begins \n** waiting for the condition variable to be signalled by another thread.\n** After another thread signals the condition variable, the calling\n** thread stops waiting, locks mutex eMutex and returns. The \n** async_cond_signal() function is used to signal the condition variable. \n** It is assumed that the mutex used by the thread calling async_cond_wait() \n** is held by the caller of async_cond_signal() (otherwise there would be \n** a race condition).\n**\n** It is guaranteed that no other thread will call async_cond_wait() when\n** there is already a thread waiting on the condition variable.\n**\n** The async_sched_yield() function is called to suggest to the operating\n** system that it would be a good time to shift the current thread off the\n** CPU. The system will still work if this function is not implemented\n** (it is not currently implemented for win32), but it might be marginally\n** more efficient if it is.\n*/\nstatic void async_mutex_enter(int eMutex);\nstatic void async_mutex_leave(int eMutex);\nstatic void async_cond_wait(int eCond, int eMutex);\nstatic void async_cond_signal(int eCond);\nstatic void async_sched_yield(void);\n\n/*\n** There are also two definitions of the following. async_os_initialize()\n** is called when the asynchronous VFS is first installed, and os_shutdown()\n** is called when it is uninstalled (from within sqlite3async_shutdown()).\n**\n** For pthreads builds, both of these functions are no-ops. For win32,\n** they provide an opportunity to initialize and finalize the required\n** mutex and condition variables.\n**\n** If async_os_initialize() returns other than zero, then the initialization\n** fails and SQLITE_ERROR is returned to the user.\n*/\nstatic int async_os_initialize(void);\nstatic void async_os_shutdown(void);\n\n/* Values for use as the 'eMutex' argument of the above functions. The\n** integer values assigned to these constants are important for assert()\n** statements that verify that mutexes are locked in the correct order.\n** Specifically, it is unsafe to try to lock mutex N while holding a lock \n** on mutex M if (M<=N).\n*/\n#define ASYNC_MUTEX_LOCK    0\n#define ASYNC_MUTEX_QUEUE   1\n#define ASYNC_MUTEX_WRITER  2\n\n/* Values for use as the 'eCond' argument of the above functions. */\n#define ASYNC_COND_QUEUE    0\n\n/*************************************************************************\n** Start of OS specific code.\n*/\n#if SQLITE_OS_WIN || defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)\n\n#include <windows.h>\n\n/* The following block contains the win32 specific code. */\n\n#define mutex_held(X) (GetCurrentThreadId()==primitives.aHolder[X])\n\nstatic struct AsyncPrimitives {\n  int isInit;\n  DWORD aHolder[3];\n  CRITICAL_SECTION aMutex[3];\n  HANDLE aCond[1];\n} primitives = { 0 };\n\nstatic int async_os_initialize(void){\n  if( !primitives.isInit ){\n    primitives.aCond[0] = CreateEvent(NULL, TRUE, FALSE, 0);\n    if( primitives.aCond[0]==NULL ){\n      return 1;\n    }\n    InitializeCriticalSection(&primitives.aMutex[0]);\n    InitializeCriticalSection(&primitives.aMutex[1]);\n    InitializeCriticalSection(&primitives.aMutex[2]);\n    primitives.isInit = 1;\n  }\n  return 0;\n}\nstatic void async_os_shutdown(void){\n  if( primitives.isInit ){\n    DeleteCriticalSection(&primitives.aMutex[0]);\n    DeleteCriticalSection(&primitives.aMutex[1]);\n    DeleteCriticalSection(&primitives.aMutex[2]);\n    CloseHandle(primitives.aCond[0]);\n    primitives.isInit = 0;\n  }\n}\n\n/* The following block contains the Win32 specific code. */\nstatic void async_mutex_enter(int eMutex){\n  assert( eMutex==0 || eMutex==1 || eMutex==2 );\n  assert( eMutex!=2 || (!mutex_held(0) && !mutex_held(1) && !mutex_held(2)) );\n  assert( eMutex!=1 || (!mutex_held(0) && !mutex_held(1)) );\n  assert( eMutex!=0 || (!mutex_held(0)) );\n  EnterCriticalSection(&primitives.aMutex[eMutex]);\n  TESTONLY( primitives.aHolder[eMutex] = GetCurrentThreadId(); )\n}\nstatic void async_mutex_leave(int eMutex){\n  assert( eMutex==0 || eMutex==1 || eMutex==2 );\n  assert( mutex_held(eMutex) );\n  TESTONLY( primitives.aHolder[eMutex] = 0; )\n  LeaveCriticalSection(&primitives.aMutex[eMutex]);\n}\nstatic void async_cond_wait(int eCond, int eMutex){\n  ResetEvent(primitives.aCond[eCond]);\n  async_mutex_leave(eMutex);\n  WaitForSingleObject(primitives.aCond[eCond], INFINITE);\n  async_mutex_enter(eMutex);\n}\nstatic void async_cond_signal(int eCond){\n  assert( mutex_held(ASYNC_MUTEX_QUEUE) );\n  SetEvent(primitives.aCond[eCond]);\n}\nstatic void async_sched_yield(void){\n  Sleep(0);\n}\n#else\n\n/* The following block contains the pthreads specific code. */\n#include <pthread.h>\n#include <sched.h>\n\n#define mutex_held(X) pthread_equal(primitives.aHolder[X], pthread_self())\n\nstatic int  async_os_initialize(void) {return 0;}\nstatic void async_os_shutdown(void) {}\n\nstatic struct AsyncPrimitives {\n  pthread_mutex_t aMutex[3];\n  pthread_cond_t aCond[1];\n  pthread_t aHolder[3];\n} primitives = {\n  { PTHREAD_MUTEX_INITIALIZER, \n    PTHREAD_MUTEX_INITIALIZER, \n    PTHREAD_MUTEX_INITIALIZER\n  } , {\n    PTHREAD_COND_INITIALIZER\n  } , { 0, 0, 0 }\n};\n\nstatic void async_mutex_enter(int eMutex){\n  assert( eMutex==0 || eMutex==1 || eMutex==2 );\n  assert( eMutex!=2 || (!mutex_held(0) && !mutex_held(1) && !mutex_held(2)) );\n  assert( eMutex!=1 || (!mutex_held(0) && !mutex_held(1)) );\n  assert( eMutex!=0 || (!mutex_held(0)) );\n  pthread_mutex_lock(&primitives.aMutex[eMutex]);\n  TESTONLY( primitives.aHolder[eMutex] = pthread_self(); )\n}\nstatic void async_mutex_leave(int eMutex){\n  assert( eMutex==0 || eMutex==1 || eMutex==2 );\n  assert( mutex_held(eMutex) );\n  TESTONLY( primitives.aHolder[eMutex] = 0; )\n  pthread_mutex_unlock(&primitives.aMutex[eMutex]);\n}\nstatic void async_cond_wait(int eCond, int eMutex){\n  assert( eMutex==0 || eMutex==1 || eMutex==2 );\n  assert( mutex_held(eMutex) );\n  TESTONLY( primitives.aHolder[eMutex] = 0; )\n  pthread_cond_wait(&primitives.aCond[eCond], &primitives.aMutex[eMutex]);\n  TESTONLY( primitives.aHolder[eMutex] = pthread_self(); )\n}\nstatic void async_cond_signal(int eCond){\n  assert( mutex_held(ASYNC_MUTEX_QUEUE) );\n  pthread_cond_signal(&primitives.aCond[eCond]);\n}\nstatic void async_sched_yield(void){\n  sched_yield();\n}\n#endif\n/*\n** End of OS specific code.\n*************************************************************************/\n\n#define assert_mutex_is_held(X) assert( mutex_held(X) )\n\n\n#ifndef SQLITE_ASYNC_TWO_FILEHANDLES\n/* #define SQLITE_ASYNC_TWO_FILEHANDLES 0 */\n#define SQLITE_ASYNC_TWO_FILEHANDLES 1\n#endif\n\n/*\n** State information is held in the static variable \"async\" defined\n** as the following structure.\n**\n** Both async.ioError and async.nFile are protected by async.queueMutex.\n*/\nstatic struct TestAsyncStaticData {\n  AsyncWrite *pQueueFirst;     /* Next write operation to be processed */\n  AsyncWrite *pQueueLast;      /* Last write operation on the list */\n  AsyncLock *pLock;            /* Linked list of all AsyncLock structures */\n  volatile int ioDelay;        /* Extra delay between write operations */\n  volatile int eHalt;          /* One of the SQLITEASYNC_HALT_XXX values */\n  volatile int bLockFiles;     /* Current value of \"lockfiles\" parameter */\n  int ioError;                 /* True if an IO error has occurred */\n  int nFile;                   /* Number of open files (from sqlite pov) */\n} async = { 0,0,0,0,0,1,0,0 };\n\n/* Possible values of AsyncWrite.op */\n#define ASYNC_NOOP          0\n#define ASYNC_WRITE         1\n#define ASYNC_SYNC          2\n#define ASYNC_TRUNCATE      3\n#define ASYNC_CLOSE         4\n#define ASYNC_DELETE        5\n#define ASYNC_OPENEXCLUSIVE 6\n#define ASYNC_UNLOCK        7\n\n/* Names of opcodes.  Used for debugging only.\n** Make sure these stay in sync with the macros above!\n*/\nstatic const char *azOpcodeName[] = {\n  \"NOOP\", \"WRITE\", \"SYNC\", \"TRUNCATE\", \"CLOSE\", \"DELETE\", \"OPENEX\", \"UNLOCK\"\n};\n\n/*\n** Entries on the write-op queue are instances of the AsyncWrite\n** structure, defined here.\n**\n** The interpretation of the iOffset and nByte variables varies depending \n** on the value of AsyncWrite.op:\n**\n** ASYNC_NOOP:\n**     No values used.\n**\n** ASYNC_WRITE:\n**     iOffset -> Offset in file to write to.\n**     nByte   -> Number of bytes of data to write (pointed to by zBuf).\n**\n** ASYNC_SYNC:\n**     nByte   -> flags to pass to sqlite3OsSync().\n**\n** ASYNC_TRUNCATE:\n**     iOffset -> Size to truncate file to.\n**     nByte   -> Unused.\n**\n** ASYNC_CLOSE:\n**     iOffset -> Unused.\n**     nByte   -> Unused.\n**\n** ASYNC_DELETE:\n**     iOffset -> Contains the \"syncDir\" flag.\n**     nByte   -> Number of bytes of zBuf points to (file name).\n**\n** ASYNC_OPENEXCLUSIVE:\n**     iOffset -> Value of \"delflag\".\n**     nByte   -> Number of bytes of zBuf points to (file name).\n**\n** ASYNC_UNLOCK:\n**     nByte   -> Argument to sqlite3OsUnlock().\n**\n**\n** For an ASYNC_WRITE operation, zBuf points to the data to write to the file. \n** This space is sqlite3_malloc()d along with the AsyncWrite structure in a\n** single blob, so is deleted when sqlite3_free() is called on the parent \n** structure.\n*/\nstruct AsyncWrite {\n  AsyncFileData *pFileData;    /* File to write data to or sync */\n  int op;                      /* One of ASYNC_xxx etc. */\n  sqlite_int64 iOffset;        /* See above */\n  int nByte;          /* See above */\n  char *zBuf;         /* Data to write to file (or NULL if op!=ASYNC_WRITE) */\n  AsyncWrite *pNext;  /* Next write operation (to any file) */\n};\n\n/*\n** An instance of this structure is created for each distinct open file \n** (i.e. if two handles are opened on the one file, only one of these\n** structures is allocated) and stored in the async.aLock hash table. The\n** keys for async.aLock are the full pathnames of the opened files.\n**\n** AsyncLock.pList points to the head of a linked list of AsyncFileLock\n** structures, one for each handle currently open on the file.\n**\n** If the opened file is not a main-database (the SQLITE_OPEN_MAIN_DB is\n** not passed to the sqlite3OsOpen() call), or if async.bLockFiles is \n** false, variables AsyncLock.pFile and AsyncLock.eLock are never used. \n** Otherwise, pFile is a file handle opened on the file in question and \n** used to obtain the file-system locks required by database connections \n** within this process.\n**\n** See comments above the asyncLock() function for more details on \n** the implementation of database locking used by this backend.\n*/\nstruct AsyncLock {\n  char *zFile;\n  int nFile;\n  sqlite3_file *pFile;\n  int eLock;\n  AsyncFileLock *pList;\n  AsyncLock *pNext;           /* Next in linked list headed by async.pLock */\n};\n\n/*\n** An instance of the following structure is allocated along with each\n** AsyncFileData structure (see AsyncFileData.lock), but is only used if the\n** file was opened with the SQLITE_OPEN_MAIN_DB.\n*/\nstruct AsyncFileLock {\n  int eLock;                /* Internally visible lock state (sqlite pov) */\n  int eAsyncLock;           /* Lock-state with write-queue unlock */\n  AsyncFileLock *pNext;\n};\n\n/* \n** The AsyncFile structure is a subclass of sqlite3_file used for \n** asynchronous IO. \n**\n** All of the actual data for the structure is stored in the structure\n** pointed to by AsyncFile.pData, which is allocated as part of the\n** sqlite3OsOpen() using sqlite3_malloc(). The reason for this is that the\n** lifetime of the AsyncFile structure is ended by the caller after OsClose()\n** is called, but the data in AsyncFileData may be required by the\n** writer thread after that point.\n*/\nstruct AsyncFile {\n  sqlite3_io_methods *pMethod;\n  AsyncFileData *pData;\n};\nstruct AsyncFileData {\n  char *zName;               /* Underlying OS filename - used for debugging */\n  int nName;                 /* Number of characters in zName */\n  sqlite3_file *pBaseRead;   /* Read handle to the underlying Os file */\n  sqlite3_file *pBaseWrite;  /* Write handle to the underlying Os file */\n  AsyncFileLock lock;        /* Lock state for this handle */\n  AsyncLock *pLock;          /* AsyncLock object for this file system entry */\n  AsyncWrite closeOp;        /* Preallocated close operation */\n};\n\n/*\n** Add an entry to the end of the global write-op list. pWrite should point \n** to an AsyncWrite structure allocated using sqlite3_malloc().  The writer\n** thread will call sqlite3_free() to free the structure after the specified\n** operation has been completed.\n**\n** Once an AsyncWrite structure has been added to the list, it becomes the\n** property of the writer thread and must not be read or modified by the\n** caller.  \n*/\nstatic void addAsyncWrite(AsyncWrite *pWrite){\n  /* We must hold the queue mutex in order to modify the queue pointers */\n  if( pWrite->op!=ASYNC_UNLOCK ){\n    async_mutex_enter(ASYNC_MUTEX_QUEUE);\n  }\n\n  /* Add the record to the end of the write-op queue */\n  assert( !pWrite->pNext );\n  if( async.pQueueLast ){\n    assert( async.pQueueFirst );\n    async.pQueueLast->pNext = pWrite;\n  }else{\n    async.pQueueFirst = pWrite;\n  }\n  async.pQueueLast = pWrite;\n  ASYNC_TRACE((\"PUSH %p (%s %s %d)\\n\", pWrite, azOpcodeName[pWrite->op],\n         pWrite->pFileData ? pWrite->pFileData->zName : \"-\", pWrite->iOffset));\n\n  if( pWrite->op==ASYNC_CLOSE ){\n    async.nFile--;\n  }\n\n  /* The writer thread might have been idle because there was nothing\n  ** on the write-op queue for it to do.  So wake it up. */\n  async_cond_signal(ASYNC_COND_QUEUE);\n\n  /* Drop the queue mutex */\n  if( pWrite->op!=ASYNC_UNLOCK ){\n    async_mutex_leave(ASYNC_MUTEX_QUEUE);\n  }\n}\n\n/*\n** Increment async.nFile in a thread-safe manner.\n*/\nstatic void incrOpenFileCount(void){\n  /* We must hold the queue mutex in order to modify async.nFile */\n  async_mutex_enter(ASYNC_MUTEX_QUEUE);\n  if( async.nFile==0 ){\n    async.ioError = SQLITE_OK;\n  }\n  async.nFile++;\n  async_mutex_leave(ASYNC_MUTEX_QUEUE);\n}\n\n/*\n** This is a utility function to allocate and populate a new AsyncWrite\n** structure and insert it (via addAsyncWrite() ) into the global list.\n*/\nstatic int addNewAsyncWrite(\n  AsyncFileData *pFileData, \n  int op, \n  sqlite3_int64 iOffset, \n  int nByte,\n  const char *zByte\n){\n  AsyncWrite *p;\n  if( op!=ASYNC_CLOSE && async.ioError ){\n    return async.ioError;\n  }\n  p = sqlite3_malloc(sizeof(AsyncWrite) + (zByte?nByte:0));\n  if( !p ){\n    /* The upper layer does not expect operations like OsWrite() to\n    ** return SQLITE_NOMEM. This is partly because under normal conditions\n    ** SQLite is required to do rollback without calling malloc(). So\n    ** if malloc() fails here, treat it as an I/O error. The above\n    ** layer knows how to handle that.\n    */\n    return SQLITE_IOERR;\n  }\n  p->op = op;\n  p->iOffset = iOffset;\n  p->nByte = nByte;\n  p->pFileData = pFileData;\n  p->pNext = 0;\n  if( zByte ){\n    p->zBuf = (char *)&p[1];\n    memcpy(p->zBuf, zByte, nByte);\n  }else{\n    p->zBuf = 0;\n  }\n  addAsyncWrite(p);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file. This just adds an entry to the write-op list, the file is\n** not actually closed.\n*/\nstatic int asyncClose(sqlite3_file *pFile){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n\n  /* Unlock the file, if it is locked */\n  async_mutex_enter(ASYNC_MUTEX_LOCK);\n  p->lock.eLock = 0;\n  async_mutex_leave(ASYNC_MUTEX_LOCK);\n\n  addAsyncWrite(&p->closeOp);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of sqlite3OsWrite() for asynchronous files. Instead of \n** writing to the underlying file, this function adds an entry to the end of\n** the global AsyncWrite list. Either SQLITE_OK or SQLITE_NOMEM may be\n** returned.\n*/\nstatic int asyncWrite(\n  sqlite3_file *pFile, \n  const void *pBuf, \n  int amt, \n  sqlite3_int64 iOff\n){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  return addNewAsyncWrite(p, ASYNC_WRITE, iOff, amt, pBuf);\n}\n\n/*\n** Read data from the file. First we read from the filesystem, then adjust \n** the contents of the buffer based on ASYNC_WRITE operations in the \n** write-op queue.\n**\n** This method holds the mutex from start to finish.\n*/\nstatic int asyncRead(\n  sqlite3_file *pFile, \n  void *zOut, \n  int iAmt, \n  sqlite3_int64 iOffset\n){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  int rc = SQLITE_OK;\n  sqlite3_int64 filesize = 0;\n  sqlite3_file *pBase = p->pBaseRead;\n  sqlite3_int64 iAmt64 = (sqlite3_int64)iAmt;\n\n  /* Grab the write queue mutex for the duration of the call */\n  async_mutex_enter(ASYNC_MUTEX_QUEUE);\n\n  /* If an I/O error has previously occurred in this virtual file \n  ** system, then all subsequent operations fail.\n  */\n  if( async.ioError!=SQLITE_OK ){\n    rc = async.ioError;\n    goto asyncread_out;\n  }\n\n  if( pBase->pMethods ){\n    sqlite3_int64 nRead;\n    rc = pBase->pMethods->xFileSize(pBase, &filesize);\n    if( rc!=SQLITE_OK ){\n      goto asyncread_out;\n    }\n    nRead = MIN(filesize - iOffset, iAmt64);\n    if( nRead>0 ){\n      rc = pBase->pMethods->xRead(pBase, zOut, (int)nRead, iOffset);\n      ASYNC_TRACE((\"READ %s %d bytes at %d\\n\", p->zName, nRead, iOffset));\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    AsyncWrite *pWrite;\n    char *zName = p->zName;\n\n    for(pWrite=async.pQueueFirst; pWrite; pWrite = pWrite->pNext){\n      if( pWrite->op==ASYNC_WRITE && (\n        (pWrite->pFileData==p) ||\n        (zName && pWrite->pFileData->zName==zName)\n      )){\n        sqlite3_int64 nCopy;\n        sqlite3_int64 nByte64 = (sqlite3_int64)pWrite->nByte;\n\n        /* Set variable iBeginIn to the offset in buffer pWrite->zBuf[] from\n        ** which data should be copied. Set iBeginOut to the offset within\n        ** the output buffer to which data should be copied. If either of\n        ** these offsets is a negative number, set them to 0.\n        */\n        sqlite3_int64 iBeginOut = (pWrite->iOffset-iOffset);\n        sqlite3_int64 iBeginIn = -iBeginOut;\n        if( iBeginIn<0 ) iBeginIn = 0;\n        if( iBeginOut<0 ) iBeginOut = 0;\n\n        filesize = MAX(filesize, pWrite->iOffset+nByte64);\n\n        nCopy = MIN(nByte64-iBeginIn, iAmt64-iBeginOut);\n        if( nCopy>0 ){\n          memcpy(&((char *)zOut)[iBeginOut], &pWrite->zBuf[iBeginIn], (size_t)nCopy);\n          ASYNC_TRACE((\"OVERREAD %d bytes at %d\\n\", nCopy, iBeginOut+iOffset));\n        }\n      }\n    }\n  }\n\nasyncread_out:\n  async_mutex_leave(ASYNC_MUTEX_QUEUE);\n  if( rc==SQLITE_OK && filesize<(iOffset+iAmt) ){\n    rc = SQLITE_IOERR_SHORT_READ;\n  }\n  return rc;\n}\n\n/*\n** Truncate the file to nByte bytes in length. This just adds an entry to \n** the write-op list, no IO actually takes place.\n*/\nstatic int asyncTruncate(sqlite3_file *pFile, sqlite3_int64 nByte){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  return addNewAsyncWrite(p, ASYNC_TRUNCATE, nByte, 0, 0);\n}\n\n/*\n** Sync the file. This just adds an entry to the write-op list, the \n** sync() is done later by sqlite3_async_flush().\n*/\nstatic int asyncSync(sqlite3_file *pFile, int flags){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  return addNewAsyncWrite(p, ASYNC_SYNC, 0, flags, 0);\n}\n\n/*\n** Read the size of the file. First we read the size of the file system \n** entry, then adjust for any ASYNC_WRITE or ASYNC_TRUNCATE operations \n** currently in the write-op list. \n**\n** This method holds the mutex from start to finish.\n*/\nint asyncFileSize(sqlite3_file *pFile, sqlite3_int64 *piSize){\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  int rc = SQLITE_OK;\n  sqlite3_int64 s = 0;\n  sqlite3_file *pBase;\n\n  async_mutex_enter(ASYNC_MUTEX_QUEUE);\n\n  /* Read the filesystem size from the base file. If pMethods is NULL, this\n  ** means the file hasn't been opened yet. In this case all relevant data \n  ** must be in the write-op queue anyway, so we can omit reading from the\n  ** file-system.\n  */\n  pBase = p->pBaseRead;\n  if( pBase->pMethods ){\n    rc = pBase->pMethods->xFileSize(pBase, &s);\n  }\n\n  if( rc==SQLITE_OK ){\n    AsyncWrite *pWrite;\n    for(pWrite=async.pQueueFirst; pWrite; pWrite = pWrite->pNext){\n      if( pWrite->op==ASYNC_DELETE \n       && p->zName \n       && strcmp(p->zName, pWrite->zBuf)==0 \n      ){\n        s = 0;\n      }else if( pWrite->pFileData && (\n          (pWrite->pFileData==p) \n       || (p->zName && pWrite->pFileData->zName==p->zName) \n      )){\n        switch( pWrite->op ){\n          case ASYNC_WRITE:\n            s = MAX(pWrite->iOffset + (sqlite3_int64)(pWrite->nByte), s);\n            break;\n          case ASYNC_TRUNCATE:\n            s = MIN(s, pWrite->iOffset);\n            break;\n        }\n      }\n    }\n    *piSize = s;\n  }\n  async_mutex_leave(ASYNC_MUTEX_QUEUE);\n  return rc;\n}\n\n/*\n** Lock or unlock the actual file-system entry.\n*/\nstatic int getFileLock(AsyncLock *pLock){\n  int rc = SQLITE_OK;\n  AsyncFileLock *pIter;\n  int eRequired = 0;\n\n  if( pLock->pFile ){\n    for(pIter=pLock->pList; pIter; pIter=pIter->pNext){\n      assert(pIter->eAsyncLock>=pIter->eLock);\n      if( pIter->eAsyncLock>eRequired ){\n        eRequired = pIter->eAsyncLock;\n        assert(eRequired>=0 && eRequired<=SQLITE_LOCK_EXCLUSIVE);\n      }\n    }\n\n    if( eRequired>pLock->eLock ){\n      rc = pLock->pFile->pMethods->xLock(pLock->pFile, eRequired);\n      if( rc==SQLITE_OK ){\n        pLock->eLock = eRequired;\n      }\n    }\n    else if( eRequired<pLock->eLock && eRequired<=SQLITE_LOCK_SHARED ){\n      rc = pLock->pFile->pMethods->xUnlock(pLock->pFile, eRequired);\n      if( rc==SQLITE_OK ){\n        pLock->eLock = eRequired;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return the AsyncLock structure from the global async.pLock list \n** associated with the file-system entry identified by path zName \n** (a string of nName bytes). If no such structure exists, return 0.\n*/\nstatic AsyncLock *findLock(const char *zName, int nName){\n  AsyncLock *p = async.pLock;\n  while( p && (p->nFile!=nName || memcmp(p->zFile, zName, nName)) ){\n    p = p->pNext;\n  }\n  return p;\n}\n\n/*\n** The following two methods - asyncLock() and asyncUnlock() - are used\n** to obtain and release locks on database files opened with the\n** asynchronous backend.\n*/\nstatic int asyncLock(sqlite3_file *pFile, int eLock){\n  int rc = SQLITE_OK;\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n\n  if( p->zName ){\n    async_mutex_enter(ASYNC_MUTEX_LOCK);\n    if( p->lock.eLock<eLock ){\n      AsyncLock *pLock = p->pLock;\n      AsyncFileLock *pIter;\n      assert(pLock && pLock->pList);\n      for(pIter=pLock->pList; pIter; pIter=pIter->pNext){\n        if( pIter!=&p->lock && (\n          (eLock==SQLITE_LOCK_EXCLUSIVE && pIter->eLock>=SQLITE_LOCK_SHARED) ||\n          (eLock==SQLITE_LOCK_PENDING && pIter->eLock>=SQLITE_LOCK_RESERVED) ||\n          (eLock==SQLITE_LOCK_RESERVED && pIter->eLock>=SQLITE_LOCK_RESERVED) ||\n          (eLock==SQLITE_LOCK_SHARED && pIter->eLock>=SQLITE_LOCK_PENDING)\n        )){\n          rc = SQLITE_BUSY;\n        }\n      }\n      if( rc==SQLITE_OK ){\n        p->lock.eLock = eLock;\n        p->lock.eAsyncLock = MAX(p->lock.eAsyncLock, eLock);\n      }\n      assert(p->lock.eAsyncLock>=p->lock.eLock);\n      if( rc==SQLITE_OK ){\n        rc = getFileLock(pLock);\n      }\n    }\n    async_mutex_leave(ASYNC_MUTEX_LOCK);\n  }\n\n  ASYNC_TRACE((\"LOCK %d (%s) rc=%d\\n\", eLock, p->zName, rc));\n  return rc;\n}\nstatic int asyncUnlock(sqlite3_file *pFile, int eLock){\n  int rc = SQLITE_OK;\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n  if( p->zName ){\n    AsyncFileLock *pLock = &p->lock;\n    async_mutex_enter(ASYNC_MUTEX_QUEUE);\n    async_mutex_enter(ASYNC_MUTEX_LOCK);\n    pLock->eLock = MIN(pLock->eLock, eLock);\n    rc = addNewAsyncWrite(p, ASYNC_UNLOCK, 0, eLock, 0);\n    async_mutex_leave(ASYNC_MUTEX_LOCK);\n    async_mutex_leave(ASYNC_MUTEX_QUEUE);\n  }\n  return rc;\n}\n\n/*\n** This function is called when the pager layer first opens a database file\n** and is checking for a hot-journal.\n*/\nstatic int asyncCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  int ret = 0;\n  AsyncFileLock *pIter;\n  AsyncFileData *p = ((AsyncFile *)pFile)->pData;\n\n  async_mutex_enter(ASYNC_MUTEX_LOCK);\n  for(pIter=p->pLock->pList; pIter; pIter=pIter->pNext){\n    if( pIter->eLock>=SQLITE_LOCK_RESERVED ){\n      ret = 1;\n      break;\n    }\n  }\n  async_mutex_leave(ASYNC_MUTEX_LOCK);\n\n  ASYNC_TRACE((\"CHECK-LOCK %d (%s)\\n\", ret, p->zName));\n  *pResOut = ret;\n  return SQLITE_OK;\n}\n\n/* \n** sqlite3_file_control() implementation.\n*/\nstatic int asyncFileControl(sqlite3_file *id, int op, void *pArg){\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      async_mutex_enter(ASYNC_MUTEX_LOCK);\n      *(int*)pArg = ((AsyncFile*)id)->pData->lock.eLock;\n      async_mutex_leave(ASYNC_MUTEX_LOCK);\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_NOTFOUND;\n}\n\n/* \n** Return the device characteristics and sector-size of the device. It\n** is tricky to implement these correctly, as this backend might \n** not have an open file handle at this point.\n*/\nstatic int asyncSectorSize(sqlite3_file *pFile){\n  UNUSED_PARAMETER(pFile);\n  return 512;\n}\nstatic int asyncDeviceCharacteristics(sqlite3_file *pFile){\n  UNUSED_PARAMETER(pFile);\n  return 0;\n}\n\nstatic int unlinkAsyncFile(AsyncFileData *pData){\n  AsyncFileLock **ppIter;\n  int rc = SQLITE_OK;\n\n  if( pData->zName ){\n    AsyncLock *pLock = pData->pLock;\n    for(ppIter=&pLock->pList; *ppIter; ppIter=&((*ppIter)->pNext)){\n      if( (*ppIter)==&pData->lock ){\n        *ppIter = pData->lock.pNext;\n        break;\n      }\n    }\n    if( !pLock->pList ){\n      AsyncLock **pp;\n      if( pLock->pFile ){\n        pLock->pFile->pMethods->xClose(pLock->pFile);\n      }\n      for(pp=&async.pLock; *pp!=pLock; pp=&((*pp)->pNext));\n      *pp = pLock->pNext;\n      sqlite3_free(pLock);\n    }else{\n      rc = getFileLock(pLock);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The parameter passed to this function is a copy of a 'flags' parameter\n** passed to this modules xOpen() method. This function returns true\n** if the file should be opened asynchronously, or false if it should\n** be opened immediately.\n**\n** If the file is to be opened asynchronously, then asyncOpen() will add\n** an entry to the event queue and the file will not actually be opened\n** until the event is processed. Otherwise, the file is opened directly\n** by the caller.\n*/\nstatic int doAsynchronousOpen(int flags){\n  return (flags&SQLITE_OPEN_CREATE) && (\n      (flags&SQLITE_OPEN_MAIN_JOURNAL) ||\n      (flags&SQLITE_OPEN_TEMP_JOURNAL) ||\n      (flags&SQLITE_OPEN_DELETEONCLOSE)\n  );\n}\n\n/*\n** Open a file.\n*/\nstatic int asyncOpen(\n  sqlite3_vfs *pAsyncVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  static sqlite3_io_methods async_methods = {\n    1,                               /* iVersion */\n    asyncClose,                      /* xClose */\n    asyncRead,                       /* xRead */\n    asyncWrite,                      /* xWrite */\n    asyncTruncate,                   /* xTruncate */\n    asyncSync,                       /* xSync */\n    asyncFileSize,                   /* xFileSize */\n    asyncLock,                       /* xLock */\n    asyncUnlock,                     /* xUnlock */\n    asyncCheckReservedLock,          /* xCheckReservedLock */\n    asyncFileControl,                /* xFileControl */\n    asyncSectorSize,                 /* xSectorSize */\n    asyncDeviceCharacteristics       /* xDeviceCharacteristics */\n  };\n\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  AsyncFile *p = (AsyncFile *)pFile;\n  int nName = 0;\n  int rc = SQLITE_OK;\n  int nByte;\n  AsyncFileData *pData;\n  AsyncLock *pLock = 0;\n  char *z;\n  int isAsyncOpen = doAsynchronousOpen(flags);\n\n  /* If zName is NULL, then the upper layer is requesting an anonymous file.\n  ** Otherwise, allocate enough space to make a copy of the file name (along\n  ** with the second nul-terminator byte required by xOpen).\n  */\n  if( zName ){\n    nName = (int)strlen(zName);\n  }\n\n  nByte = (\n    sizeof(AsyncFileData) +        /* AsyncFileData structure */\n    2 * pVfs->szOsFile +           /* AsyncFileData.pBaseRead and pBaseWrite */\n    nName + 2                      /* AsyncFileData.zName */\n  ); \n  z = sqlite3_malloc(nByte);\n  if( !z ){\n    return SQLITE_NOMEM;\n  }\n  memset(z, 0, nByte);\n  pData = (AsyncFileData*)z;\n  z += sizeof(pData[0]);\n  pData->pBaseRead = (sqlite3_file*)z;\n  z += pVfs->szOsFile;\n  pData->pBaseWrite = (sqlite3_file*)z;\n  pData->closeOp.pFileData = pData;\n  pData->closeOp.op = ASYNC_CLOSE;\n\n  if( zName ){\n    z += pVfs->szOsFile;\n    pData->zName = z;\n    pData->nName = nName;\n    memcpy(pData->zName, zName, nName);\n  }\n\n  if( !isAsyncOpen ){\n    int flagsout;\n    rc = pVfs->xOpen(pVfs, pData->zName, pData->pBaseRead, flags, &flagsout);\n    if( rc==SQLITE_OK \n     && (flagsout&SQLITE_OPEN_READWRITE) \n     && (flags&SQLITE_OPEN_EXCLUSIVE)==0\n    ){\n      rc = pVfs->xOpen(pVfs, pData->zName, pData->pBaseWrite, flags, 0);\n    }\n    if( pOutFlags ){\n      *pOutFlags = flagsout;\n    }\n  }\n\n  async_mutex_enter(ASYNC_MUTEX_LOCK);\n\n  if( zName && rc==SQLITE_OK ){\n    pLock = findLock(pData->zName, pData->nName);\n    if( !pLock ){\n      int nByte = pVfs->szOsFile + sizeof(AsyncLock) + pData->nName + 1; \n      pLock = (AsyncLock *)sqlite3_malloc(nByte);\n      if( pLock ){\n        memset(pLock, 0, nByte);\n        if( async.bLockFiles && (flags&SQLITE_OPEN_MAIN_DB) ){\n          pLock->pFile = (sqlite3_file *)&pLock[1];\n          rc = pVfs->xOpen(pVfs, pData->zName, pLock->pFile, flags, 0);\n          if( rc!=SQLITE_OK ){\n            sqlite3_free(pLock);\n            pLock = 0;\n          }\n        }\n        if( pLock ){\n          pLock->nFile = pData->nName;\n          pLock->zFile = &((char *)(&pLock[1]))[pVfs->szOsFile];\n          memcpy(pLock->zFile, pData->zName, pLock->nFile);\n          pLock->pNext = async.pLock;\n          async.pLock = pLock;\n        }\n      }else{\n        rc = SQLITE_NOMEM;\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    p->pMethod = &async_methods;\n    p->pData = pData;\n\n    /* Link AsyncFileData.lock into the linked list of \n    ** AsyncFileLock structures for this file.\n    */\n    if( zName ){\n      pData->lock.pNext = pLock->pList;\n      pLock->pList = &pData->lock;\n      pData->zName = pLock->zFile;\n    }\n  }else{\n    if( pData->pBaseRead->pMethods ){\n      pData->pBaseRead->pMethods->xClose(pData->pBaseRead);\n    }\n    if( pData->pBaseWrite->pMethods ){\n      pData->pBaseWrite->pMethods->xClose(pData->pBaseWrite);\n    }\n    sqlite3_free(pData);\n  }\n\n  async_mutex_leave(ASYNC_MUTEX_LOCK);\n\n  if( rc==SQLITE_OK ){\n    pData->pLock = pLock;\n  }\n\n  if( rc==SQLITE_OK && isAsyncOpen ){\n    rc = addNewAsyncWrite(pData, ASYNC_OPENEXCLUSIVE, (sqlite3_int64)flags,0,0);\n    if( rc==SQLITE_OK ){\n      if( pOutFlags ) *pOutFlags = flags;\n    }else{\n      async_mutex_enter(ASYNC_MUTEX_LOCK);\n      unlinkAsyncFile(pData);\n      async_mutex_leave(ASYNC_MUTEX_LOCK);\n      sqlite3_free(pData);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    p->pMethod = 0;\n  }else{\n    incrOpenFileCount();\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of sqlite3OsDelete. Add an entry to the end of the \n** write-op queue to perform the delete.\n*/\nstatic int asyncDelete(sqlite3_vfs *pAsyncVfs, const char *z, int syncDir){\n  UNUSED_PARAMETER(pAsyncVfs);\n  return addNewAsyncWrite(0, ASYNC_DELETE, syncDir, (int)strlen(z)+1, z);\n}\n\n/*\n** Implementation of sqlite3OsAccess. This method holds the mutex from\n** start to finish.\n*/\nstatic int asyncAccess(\n  sqlite3_vfs *pAsyncVfs, \n  const char *zName, \n  int flags,\n  int *pResOut\n){\n  int rc;\n  int ret;\n  AsyncWrite *p;\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n\n  assert(flags==SQLITE_ACCESS_READWRITE \n      || flags==SQLITE_ACCESS_READ \n      || flags==SQLITE_ACCESS_EXISTS \n  );\n\n  async_mutex_enter(ASYNC_MUTEX_QUEUE);\n  rc = pVfs->xAccess(pVfs, zName, flags, &ret);\n  if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){\n    for(p=async.pQueueFirst; p; p = p->pNext){\n      if( p->op==ASYNC_DELETE && 0==strcmp(p->zBuf, zName) ){\n        ret = 0;\n      }else if( p->op==ASYNC_OPENEXCLUSIVE \n             && p->pFileData->zName\n             && 0==strcmp(p->pFileData->zName, zName) \n      ){\n        ret = 1;\n      }\n    }\n  }\n  ASYNC_TRACE((\"ACCESS(%s): %s = %d\\n\", \n    flags==SQLITE_ACCESS_READWRITE?\"read-write\":\n    flags==SQLITE_ACCESS_READ?\"read\":\"exists\"\n    , zName, ret)\n  );\n  async_mutex_leave(ASYNC_MUTEX_QUEUE);\n  *pResOut = ret;\n  return rc;\n}\n\n/*\n** Fill in zPathOut with the full path to the file identified by zPath.\n*/\nstatic int asyncFullPathname(\n  sqlite3_vfs *pAsyncVfs, \n  const char *zPath, \n  int nPathOut,\n  char *zPathOut\n){\n  int rc;\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  rc = pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n\n  /* Because of the way intra-process file locking works, this backend\n  ** needs to return a canonical path. The following block assumes the\n  ** file-system uses unix style paths. \n  */\n  if( rc==SQLITE_OK ){\n    int i, j;\n    char *z = zPathOut;\n    int n = (int)strlen(z);\n    while( n>1 && z[n-1]=='/' ){ n--; }\n    for(i=j=0; i<n; i++){\n      if( z[i]=='/' ){\n        if( z[i+1]=='/' ) continue;\n        if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){\n          i += 1;\n          continue;\n        }\n        if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){\n          while( j>0 && z[j-1]!='/' ){ j--; }\n          if( j>0 ){ j--; }\n          i += 2;\n          continue;\n        }\n      }\n      z[j++] = z[i];\n    }\n    z[j] = 0;\n  }\n\n  return rc;\n}\nstatic void *asyncDlOpen(sqlite3_vfs *pAsyncVfs, const char *zPath){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nstatic void asyncDlError(sqlite3_vfs *pAsyncVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  pVfs->xDlError(pVfs, nByte, zErrMsg);\n}\nstatic void (*asyncDlSym(\n  sqlite3_vfs *pAsyncVfs, \n  void *pHandle, \n  const char *zSymbol\n))(void){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  return pVfs->xDlSym(pVfs, pHandle, zSymbol);\n}\nstatic void asyncDlClose(sqlite3_vfs *pAsyncVfs, void *pHandle){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  pVfs->xDlClose(pVfs, pHandle);\n}\nstatic int asyncRandomness(sqlite3_vfs *pAsyncVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nstatic int asyncSleep(sqlite3_vfs *pAsyncVfs, int nMicro){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  return pVfs->xSleep(pVfs, nMicro);\n}\nstatic int asyncCurrentTime(sqlite3_vfs *pAsyncVfs, double *pTimeOut){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pAsyncVfs->pAppData;\n  return pVfs->xCurrentTime(pVfs, pTimeOut);\n}\n\nstatic sqlite3_vfs async_vfs = {\n  1,                    /* iVersion */\n  sizeof(AsyncFile),    /* szOsFile */\n  0,                    /* mxPathname */\n  0,                    /* pNext */\n  SQLITEASYNC_VFSNAME,  /* zName */\n  0,                    /* pAppData */\n  asyncOpen,            /* xOpen */\n  asyncDelete,          /* xDelete */\n  asyncAccess,          /* xAccess */\n  asyncFullPathname,    /* xFullPathname */\n  asyncDlOpen,          /* xDlOpen */\n  asyncDlError,         /* xDlError */\n  asyncDlSym,           /* xDlSym */\n  asyncDlClose,         /* xDlClose */\n  asyncRandomness,      /* xDlError */\n  asyncSleep,           /* xDlSym */\n  asyncCurrentTime      /* xDlClose */\n};\n\n/* \n** This procedure runs in a separate thread, reading messages off of the\n** write queue and processing them one by one.  \n**\n** If async.writerHaltNow is true, then this procedure exits\n** after processing a single message.\n**\n** If async.writerHaltWhenIdle is true, then this procedure exits when\n** the write queue is empty.\n**\n** If both of the above variables are false, this procedure runs\n** indefinately, waiting for operations to be added to the write queue\n** and processing them in the order in which they arrive.\n**\n** An artifical delay of async.ioDelay milliseconds is inserted before\n** each write operation in order to simulate the effect of a slow disk.\n**\n** Only one instance of this procedure may be running at a time.\n*/\nstatic void asyncWriterThread(void){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)(async_vfs.pAppData);\n  AsyncWrite *p = 0;\n  int rc = SQLITE_OK;\n  int holdingMutex = 0;\n\n  async_mutex_enter(ASYNC_MUTEX_WRITER);\n\n  while( async.eHalt!=SQLITEASYNC_HALT_NOW ){\n    int doNotFree = 0;\n    sqlite3_file *pBase = 0;\n\n    if( !holdingMutex ){\n      async_mutex_enter(ASYNC_MUTEX_QUEUE);\n    }\n    while( (p = async.pQueueFirst)==0 ){\n      if( async.eHalt!=SQLITEASYNC_HALT_NEVER ){\n        async_mutex_leave(ASYNC_MUTEX_QUEUE);\n        break;\n      }else{\n        ASYNC_TRACE((\"IDLE\\n\"));\n        async_cond_wait(ASYNC_COND_QUEUE, ASYNC_MUTEX_QUEUE);\n        ASYNC_TRACE((\"WAKEUP\\n\"));\n      }\n    }\n    if( p==0 ) break;\n    holdingMutex = 1;\n\n    /* Right now this thread is holding the mutex on the write-op queue.\n    ** Variable 'p' points to the first entry in the write-op queue. In\n    ** the general case, we hold on to the mutex for the entire body of\n    ** the loop. \n    **\n    ** However in the cases enumerated below, we relinquish the mutex,\n    ** perform the IO, and then re-request the mutex before removing 'p' from\n    ** the head of the write-op queue. The idea is to increase concurrency with\n    ** sqlite threads.\n    **\n    **     * An ASYNC_CLOSE operation.\n    **     * An ASYNC_OPENEXCLUSIVE operation. For this one, we relinquish \n    **       the mutex, call the underlying xOpenExclusive() function, then\n    **       re-aquire the mutex before seting the AsyncFile.pBaseRead \n    **       variable.\n    **     * ASYNC_SYNC and ASYNC_WRITE operations, if \n    **       SQLITE_ASYNC_TWO_FILEHANDLES was set at compile time and two\n    **       file-handles are open for the particular file being \"synced\".\n    */\n    if( async.ioError!=SQLITE_OK && p->op!=ASYNC_CLOSE ){\n      p->op = ASYNC_NOOP;\n    }\n    if( p->pFileData ){\n      pBase = p->pFileData->pBaseWrite;\n      if( \n        p->op==ASYNC_CLOSE || \n        p->op==ASYNC_OPENEXCLUSIVE ||\n        (pBase->pMethods && (p->op==ASYNC_SYNC || p->op==ASYNC_WRITE) ) \n      ){\n        async_mutex_leave(ASYNC_MUTEX_QUEUE);\n        holdingMutex = 0;\n      }\n      if( !pBase->pMethods ){\n        pBase = p->pFileData->pBaseRead;\n      }\n    }\n\n    switch( p->op ){\n      case ASYNC_NOOP:\n        break;\n\n      case ASYNC_WRITE:\n        assert( pBase );\n        ASYNC_TRACE((\"WRITE %s %d bytes at %d\\n\",\n                p->pFileData->zName, p->nByte, p->iOffset));\n        rc = pBase->pMethods->xWrite(pBase, (void *)(p->zBuf), p->nByte, p->iOffset);\n        break;\n\n      case ASYNC_SYNC:\n        assert( pBase );\n        ASYNC_TRACE((\"SYNC %s\\n\", p->pFileData->zName));\n        rc = pBase->pMethods->xSync(pBase, p->nByte);\n        break;\n\n      case ASYNC_TRUNCATE:\n        assert( pBase );\n        ASYNC_TRACE((\"TRUNCATE %s to %d bytes\\n\", \n                p->pFileData->zName, p->iOffset));\n        rc = pBase->pMethods->xTruncate(pBase, p->iOffset);\n        break;\n\n      case ASYNC_CLOSE: {\n        AsyncFileData *pData = p->pFileData;\n        ASYNC_TRACE((\"CLOSE %s\\n\", p->pFileData->zName));\n        if( pData->pBaseWrite->pMethods ){\n          pData->pBaseWrite->pMethods->xClose(pData->pBaseWrite);\n        }\n        if( pData->pBaseRead->pMethods ){\n          pData->pBaseRead->pMethods->xClose(pData->pBaseRead);\n        }\n\n        /* Unlink AsyncFileData.lock from the linked list of AsyncFileLock \n        ** structures for this file. Obtain the async.lockMutex mutex \n        ** before doing so.\n        */\n        async_mutex_enter(ASYNC_MUTEX_LOCK);\n        rc = unlinkAsyncFile(pData);\n        async_mutex_leave(ASYNC_MUTEX_LOCK);\n\n        if( !holdingMutex ){\n          async_mutex_enter(ASYNC_MUTEX_QUEUE);\n          holdingMutex = 1;\n        }\n        assert_mutex_is_held(ASYNC_MUTEX_QUEUE);\n        async.pQueueFirst = p->pNext;\n        sqlite3_free(pData);\n        doNotFree = 1;\n        break;\n      }\n\n      case ASYNC_UNLOCK: {\n        AsyncWrite *pIter;\n        AsyncFileData *pData = p->pFileData;\n        int eLock = p->nByte;\n\n        /* When a file is locked by SQLite using the async backend, it is \n        ** locked within the 'real' file-system synchronously. When it is\n        ** unlocked, an ASYNC_UNLOCK event is added to the write-queue to\n        ** unlock the file asynchronously. The design of the async backend\n        ** requires that the 'real' file-system file be locked from the\n        ** time that SQLite first locks it (and probably reads from it)\n        ** until all asynchronous write events that were scheduled before\n        ** SQLite unlocked the file have been processed.\n        **\n        ** This is more complex if SQLite locks and unlocks the file multiple\n        ** times in quick succession. For example, if SQLite does: \n        ** \n        **   lock, write, unlock, lock, write, unlock\n        **\n        ** Each \"lock\" operation locks the file immediately. Each \"write\" \n        ** and \"unlock\" operation adds an event to the event queue. If the\n        ** second \"lock\" operation is performed before the first \"unlock\"\n        ** operation has been processed asynchronously, then the first\n        ** \"unlock\" cannot be safely processed as is, since this would mean\n        ** the file was unlocked when the second \"write\" operation is\n        ** processed. To work around this, when processing an ASYNC_UNLOCK\n        ** operation, SQLite:\n        **\n        **   1) Unlocks the file to the minimum of the argument passed to\n        **      the xUnlock() call and the current lock from SQLite's point\n        **      of view, and\n        **\n        **   2) Only unlocks the file at all if this event is the last\n        **      ASYNC_UNLOCK event on this file in the write-queue.\n        */ \n        assert( holdingMutex==1 );\n        assert( async.pQueueFirst==p );\n        for(pIter=async.pQueueFirst->pNext; pIter; pIter=pIter->pNext){\n          if( pIter->pFileData==pData && pIter->op==ASYNC_UNLOCK ) break;\n        }\n        if( !pIter ){\n          async_mutex_enter(ASYNC_MUTEX_LOCK);\n          pData->lock.eAsyncLock = MIN(\n              pData->lock.eAsyncLock, MAX(pData->lock.eLock, eLock)\n          );\n          assert(pData->lock.eAsyncLock>=pData->lock.eLock);\n          rc = getFileLock(pData->pLock);\n          async_mutex_leave(ASYNC_MUTEX_LOCK);\n        }\n        break;\n      }\n\n      case ASYNC_DELETE:\n        ASYNC_TRACE((\"DELETE %s\\n\", p->zBuf));\n        rc = pVfs->xDelete(pVfs, p->zBuf, (int)p->iOffset);\n        if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;\n        break;\n\n      case ASYNC_OPENEXCLUSIVE: {\n        int flags = (int)p->iOffset;\n        AsyncFileData *pData = p->pFileData;\n        ASYNC_TRACE((\"OPEN %s flags=%d\\n\", p->zBuf, (int)p->iOffset));\n        assert(pData->pBaseRead->pMethods==0 && pData->pBaseWrite->pMethods==0);\n        rc = pVfs->xOpen(pVfs, pData->zName, pData->pBaseRead, flags, 0);\n        assert( holdingMutex==0 );\n        async_mutex_enter(ASYNC_MUTEX_QUEUE);\n        holdingMutex = 1;\n        break;\n      }\n\n      default: assert(!\"Illegal value for AsyncWrite.op\");\n    }\n\n    /* If we didn't hang on to the mutex during the IO op, obtain it now\n    ** so that the AsyncWrite structure can be safely removed from the \n    ** global write-op queue.\n    */\n    if( !holdingMutex ){\n      async_mutex_enter(ASYNC_MUTEX_QUEUE);\n      holdingMutex = 1;\n    }\n    /* ASYNC_TRACE((\"UNLINK %p\\n\", p)); */\n    if( p==async.pQueueLast ){\n      async.pQueueLast = 0;\n    }\n    if( !doNotFree ){\n      assert_mutex_is_held(ASYNC_MUTEX_QUEUE);\n      async.pQueueFirst = p->pNext;\n      sqlite3_free(p);\n    }\n    assert( holdingMutex );\n\n    /* An IO error has occurred. We cannot report the error back to the\n    ** connection that requested the I/O since the error happened \n    ** asynchronously.  The connection has already moved on.  There \n    ** really is nobody to report the error to.\n    **\n    ** The file for which the error occurred may have been a database or\n    ** journal file. Regardless, none of the currently queued operations\n    ** associated with the same database should now be performed. Nor should\n    ** any subsequently requested IO on either a database or journal file \n    ** handle for the same database be accepted until the main database\n    ** file handle has been closed and reopened.\n    **\n    ** Furthermore, no further IO should be queued or performed on any file\n    ** handle associated with a database that may have been part of a \n    ** multi-file transaction that included the database associated with \n    ** the IO error (i.e. a database ATTACHed to the same handle at some \n    ** point in time).\n    */\n    if( rc!=SQLITE_OK ){\n      async.ioError = rc;\n    }\n\n    if( async.ioError && !async.pQueueFirst ){\n      async_mutex_enter(ASYNC_MUTEX_LOCK);\n      if( 0==async.pLock ){\n        async.ioError = SQLITE_OK;\n      }\n      async_mutex_leave(ASYNC_MUTEX_LOCK);\n    }\n\n    /* Drop the queue mutex before continuing to the next write operation\n    ** in order to give other threads a chance to work with the write queue.\n    */\n    if( !async.pQueueFirst || !async.ioError ){\n      async_mutex_leave(ASYNC_MUTEX_QUEUE);\n      holdingMutex = 0;\n      if( async.ioDelay>0 ){\n        pVfs->xSleep(pVfs, async.ioDelay*1000);\n      }else{\n        async_sched_yield();\n      }\n    }\n  }\n  \n  async_mutex_leave(ASYNC_MUTEX_WRITER);\n  return;\n}\n\n/*\n** Install the asynchronous VFS.\n*/ \nint sqlite3async_initialize(const char *zParent, int isDefault){\n  int rc = SQLITE_OK;\n  if( async_vfs.pAppData==0 ){\n    sqlite3_vfs *pParent = sqlite3_vfs_find(zParent);\n    if( !pParent || async_os_initialize() ){\n      rc = SQLITE_ERROR;\n    }else if( SQLITE_OK!=(rc = sqlite3_vfs_register(&async_vfs, isDefault)) ){\n      async_os_shutdown();\n    }else{\n      async_vfs.pAppData = (void *)pParent;\n      async_vfs.mxPathname = ((sqlite3_vfs *)async_vfs.pAppData)->mxPathname;\n    }\n  }\n  return rc;\n}\n\n/*\n** Uninstall the asynchronous VFS.\n*/\nvoid sqlite3async_shutdown(void){\n  if( async_vfs.pAppData ){\n    async_os_shutdown();\n    sqlite3_vfs_unregister((sqlite3_vfs *)&async_vfs);\n    async_vfs.pAppData = 0;\n  }\n}\n\n/*\n** Process events on the write-queue.\n*/\nvoid sqlite3async_run(void){\n  asyncWriterThread();\n}\n\n/*\n** Control/configure the asynchronous IO system.\n*/\nint sqlite3async_control(int op, ...){\n  int rc = SQLITE_OK;\n  va_list ap;\n  va_start(ap, op);\n  switch( op ){\n    case SQLITEASYNC_HALT: {\n      int eWhen = va_arg(ap, int);\n      if( eWhen!=SQLITEASYNC_HALT_NEVER\n       && eWhen!=SQLITEASYNC_HALT_NOW\n       && eWhen!=SQLITEASYNC_HALT_IDLE\n      ){\n        rc = SQLITE_MISUSE;\n        break;\n      }\n      async.eHalt = eWhen;\n      async_mutex_enter(ASYNC_MUTEX_QUEUE);\n      async_cond_signal(ASYNC_COND_QUEUE);\n      async_mutex_leave(ASYNC_MUTEX_QUEUE);\n      break;\n    }\n\n    case SQLITEASYNC_DELAY: {\n      int iDelay = va_arg(ap, int);\n      if( iDelay<0 ){\n        rc = SQLITE_MISUSE;\n        break;\n      }\n      async.ioDelay = iDelay;\n      break;\n    }\n\n    case SQLITEASYNC_LOCKFILES: {\n      int bLock = va_arg(ap, int);\n      async_mutex_enter(ASYNC_MUTEX_QUEUE);\n      if( async.nFile || async.pQueueFirst ){\n        async_mutex_leave(ASYNC_MUTEX_QUEUE);\n        rc = SQLITE_MISUSE;\n        break;\n      }\n      async.bLockFiles = bLock;\n      async_mutex_leave(ASYNC_MUTEX_QUEUE);\n      break;\n    }\n      \n    case SQLITEASYNC_GET_HALT: {\n      int *peWhen = va_arg(ap, int *);\n      *peWhen = async.eHalt;\n      break;\n    }\n    case SQLITEASYNC_GET_DELAY: {\n      int *piDelay = va_arg(ap, int *);\n      *piDelay = async.ioDelay;\n      break;\n    }\n    case SQLITEASYNC_GET_LOCKFILES: {\n      int *piDelay = va_arg(ap, int *);\n      *piDelay = async.bLockFiles;\n      break;\n    }\n\n    default:\n      rc = SQLITE_ERROR;\n      break;\n  }\n  va_end(ap);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ASYNCIO) */\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/async/sqlite3async.h",
    "content": "\n#ifndef __SQLITEASYNC_H_\n#define __SQLITEASYNC_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define SQLITEASYNC_VFSNAME \"sqlite3async\"\n\n/*\n** THREAD SAFETY NOTES:\n**\n** Of the four API functions in this file, the following are not threadsafe:\n**\n**   sqlite3async_initialize()\n**   sqlite3async_shutdown()\n**\n** Care must be taken that neither of these functions is called while \n** another thread may be calling either any sqlite3async_XXX() function\n** or an sqlite3_XXX() API function related to a database handle that\n** is using the asynchronous IO VFS.\n**\n** These functions:\n**\n**   sqlite3async_run()\n**   sqlite3async_control()\n**\n** are threadsafe. It is quite safe to call either of these functions even\n** if another thread may also be calling one of them or an sqlite3_XXX()\n** function related to a database handle that uses the asynchronous IO VFS.\n*/\n\n/*\n** Initialize the asynchronous IO VFS and register it with SQLite using\n** sqlite3_vfs_register(). If the asynchronous VFS is already initialized\n** and registered, this function is a no-op. The asynchronous IO VFS\n** is registered as \"sqlite3async\".\n**\n** The asynchronous IO VFS does not make operating system IO requests \n** directly. Instead, it uses an existing VFS implementation for all\n** required file-system operations. If the first parameter to this function\n** is NULL, then the current default VFS is used for IO. If it is not\n** NULL, then it must be the name of an existing VFS. In other words, the\n** first argument to this function is passed to sqlite3_vfs_find() to\n** locate the VFS to use for all real IO operations. This VFS is known\n** as the \"parent VFS\".\n**\n** If the second parameter to this function is non-zero, then the \n** asynchronous IO VFS is registered as the default VFS for all SQLite \n** database connections within the process. Otherwise, the asynchronous IO\n** VFS is only used by connections opened using sqlite3_open_v2() that\n** specifically request VFS \"sqlite3async\".\n**\n** If a parent VFS cannot be located, then SQLITE_ERROR is returned.\n** In the unlikely event that operating system specific initialization\n** fails (win32 systems create the required critical section and event \n** objects within this function), then SQLITE_ERROR is also returned.\n** Finally, if the call to sqlite3_vfs_register() returns an error, then \n** the error code is returned to the user by this function. In all three\n** of these cases, intialization has failed and the asynchronous IO VFS\n** is not registered with SQLite.\n**\n** Otherwise, if no error occurs, SQLITE_OK is returned.\n*/ \nint sqlite3async_initialize(const char *zParent, int isDefault);\n\n/*\n** This function unregisters the asynchronous IO VFS using \n** sqlite3_vfs_unregister().\n**\n** On win32 platforms, this function also releases the small number of \n** critical section and event objects created by sqlite3async_initialize().\n*/ \nvoid sqlite3async_shutdown(void);\n\n/*\n** This function may only be called when the asynchronous IO VFS is \n** installed (after a call to sqlite3async_initialize()). It processes\n** zero or more queued write operations before returning. It is expected\n** (but not required) that this function will be called by a different \n** thread than those threads that use SQLite. The \"background thread\"\n** that performs IO.\n**\n** How many queued write operations are performed before returning \n** depends on the global setting configured by passing the SQLITEASYNC_HALT\n** verb to sqlite3async_control() (see below for details). By default\n** this function never returns - it processes all pending operations and \n** then blocks waiting for new ones.\n**\n** If multiple simultaneous calls are made to sqlite3async_run() from two\n** or more threads, then the calls are serialized internally.\n*/\nvoid sqlite3async_run(void);\n\n/*\n** This function may only be called when the asynchronous IO VFS is \n** installed (after a call to sqlite3async_initialize()). It is used \n** to query or configure various parameters that affect the operation \n** of the asynchronous IO VFS. At present there are three parameters \n** supported:\n**\n**   * The \"halt\" parameter, which configures the circumstances under\n**     which the sqlite3async_run() parameter is configured.\n**\n**   * The \"delay\" parameter. Setting the delay parameter to a non-zero\n**     value causes the sqlite3async_run() function to sleep for the\n**     configured number of milliseconds between each queued write \n**     operation.\n**\n**   * The \"lockfiles\" parameter. This parameter determines whether or \n**     not the asynchronous IO VFS locks the database files it operates\n**     on. Disabling file locking can improve throughput.\n**\n** This function is always passed two arguments. When setting the value\n** of a parameter, the first argument must be one of SQLITEASYNC_HALT,\n** SQLITEASYNC_DELAY or SQLITEASYNC_LOCKFILES. The second argument must\n** be passed the new value for the parameter as type \"int\".\n**\n** When querying the current value of a paramter, the first argument must\n** be one of SQLITEASYNC_GET_HALT, GET_DELAY or GET_LOCKFILES. The second \n** argument to this function must be of type (int *). The current value\n** of the queried parameter is copied to the memory pointed to by the\n** second argument. For example:\n**\n**   int eCurrentHalt;\n**   int eNewHalt = SQLITEASYNC_HALT_IDLE;\n**\n**   sqlite3async_control(SQLITEASYNC_HALT, eNewHalt);\n**   sqlite3async_control(SQLITEASYNC_GET_HALT, &eCurrentHalt);\n**   assert( eNewHalt==eCurrentHalt );\n**\n** See below for more detail on each configuration parameter.\n**\n** SQLITEASYNC_HALT:\n**\n**   This is used to set the value of the \"halt\" parameter. The second\n**   argument must be one of the SQLITEASYNC_HALT_XXX symbols defined\n**   below (either NEVER, IDLE and NOW).\n**\n**   If the parameter is set to NEVER, then calls to sqlite3async_run()\n**   never return. This is the default setting. If the parameter is set\n**   to IDLE, then calls to sqlite3async_run() return as soon as the\n**   queue of pending write operations is empty. If the parameter is set\n**   to NOW, then calls to sqlite3async_run() return as quickly as \n**   possible, without processing any pending write requests.\n**\n**   If an attempt is made to set this parameter to an integer value other\n**   than SQLITEASYNC_HALT_NEVER, IDLE or NOW, then sqlite3async_control() \n**   returns SQLITE_MISUSE and the current value of the parameter is not \n**   modified.\n**\n**   Modifying the \"halt\" parameter affects calls to sqlite3async_run() \n**   made by other threads that are currently in progress.\n**\n** SQLITEASYNC_DELAY:\n**\n**   This is used to set the value of the \"delay\" parameter. If set to\n**   a non-zero value, then after completing a pending write request, the\n**   sqlite3async_run() function sleeps for the configured number of \n**   milliseconds.\n**\n**   If an attempt is made to set this parameter to a negative value,\n**   sqlite3async_control() returns SQLITE_MISUSE and the current value\n**   of the parameter is not modified.\n**\n**   Modifying the \"delay\" parameter affects calls to sqlite3async_run() \n**   made by other threads that are currently in progress.\n**\n** SQLITEASYNC_LOCKFILES:\n**\n**   This is used to set the value of the \"lockfiles\" parameter. This\n**   parameter must be set to either 0 or 1. If set to 1, then the\n**   asynchronous IO VFS uses the xLock() and xUnlock() methods of the\n**   parent VFS to lock database files being read and/or written. If\n**   the parameter is set to 0, then these locks are omitted.\n**\n**   This parameter may only be set when there are no open database\n**   connections using the VFS and the queue of pending write requests\n**   is empty. Attempting to set it when this is not true, or to set it \n**   to a value other than 0 or 1 causes sqlite3async_control() to return\n**   SQLITE_MISUSE and the value of the parameter to remain unchanged.\n**\n**   If this parameter is set to zero, then it is only safe to access the\n**   database via the asynchronous IO VFS from within a single process. If\n**   while writing to the database via the asynchronous IO VFS the database\n**   is also read or written from within another process, or via another\n**   connection that does not use the asynchronous IO VFS within the same\n**   process, the results are undefined (and may include crashes or database\n**   corruption).\n**\n**   Alternatively, if this parameter is set to 1, then it is safe to access\n**   the database from multiple connections within multiple processes using\n**   either the asynchronous IO VFS or the parent VFS directly.\n*/\nint sqlite3async_control(int op, ...);\n\n/*\n** Values that can be used as the first argument to sqlite3async_control().\n*/\n#define SQLITEASYNC_HALT          1\n#define SQLITEASYNC_GET_HALT      2\n#define SQLITEASYNC_DELAY         3\n#define SQLITEASYNC_GET_DELAY     4\n#define SQLITEASYNC_LOCKFILES     5\n#define SQLITEASYNC_GET_LOCKFILES 6\n\n/*\n** If the first argument to sqlite3async_control() is SQLITEASYNC_HALT,\n** the second argument should be one of the following.\n*/\n#define SQLITEASYNC_HALT_NEVER 0       /* Never halt (default value) */\n#define SQLITEASYNC_HALT_NOW   1       /* Halt as soon as possible */\n#define SQLITEASYNC_HALT_IDLE  2       /* Halt when write-queue is empty */\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif        /* ifndef __SQLITEASYNC_H_ */\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/README.txt",
    "content": "This folder contains source code to the first full-text search\nextension for SQLite.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/ft_hash.c",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n#include <assert.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"ft_hash.h\"\n\nvoid *malloc_and_zero(int n){\n  void *p = malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants HASH_INT, HASH_POINTER,\n** HASH_BINARY, or HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.  CopyKey only makes\n** sense for HASH_STRING and HASH_BINARY and is ignored\n** for other key classes.\n*/\nvoid HashInit(Hash *pNew, int keyClass, int copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=HASH_STRING && keyClass<=HASH_BINARY );\n  pNew->keyClass = keyClass;\n#if 0\n  if( keyClass==HASH_POINTER || keyClass==HASH_INT ) copyKey = 0;\n#endif\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n  pNew->xMalloc = malloc_and_zero;\n  pNew->xFree = free;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nvoid HashClear(Hash *pH){\n  HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  if( pH->ht ) pH->xFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      pH->xFree(elem->pKey);\n    }\n    pH->xFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n#if 0 /* NOT USED */\n/*\n** Hash and comparison functions when the mode is HASH_INT\n*/\nstatic int intHash(const void *pKey, int nKey){\n  return nKey ^ (nKey<<8) ^ (nKey>>8);\n}\nstatic int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  return n2 - n1;\n}\n#endif\n\n#if 0 /* NOT USED */\n/*\n** Hash and comparison functions when the mode is HASH_POINTER\n*/\nstatic int ptrHash(const void *pKey, int nKey){\n  uptr x = Addr(pKey);\n  return x ^ (x<<8) ^ (x>>8);\n}\nstatic int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( pKey1==pKey2 ) return 0;\n  if( pKey1<pKey2 ) return -1;\n  return 1;\n}\n#endif\n\n/*\n** Hash and comparison functions when the mode is HASH_STRING\n*/\nstatic int strHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  int h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return h & 0x7fffffff;\n}\nstatic int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is HASH_BINARY\n*/\nstatic int binHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"hashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of hashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of hashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*hashFunction(int keyClass))(const void*,int){\n#if 0  /* HASH_INT and HASH_POINTER are never used */\n  switch( keyClass ){\n    case HASH_INT:     return &intHash;\n    case HASH_POINTER: return &ptrHash;\n    case HASH_STRING:  return &strHash;\n    case HASH_BINARY:  return &binHash;;\n    default: break;\n  }\n  return 0;\n#else\n  if( keyClass==HASH_STRING ){\n    return &strHash;\n  }else{\n    assert( keyClass==HASH_BINARY );\n    return &binHash;\n  }\n#endif\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*compareFunction(int keyClass))(const void*,int,const void*,int){\n#if 0 /* HASH_INT and HASH_POINTER are never used */\n  switch( keyClass ){\n    case HASH_INT:     return &intCompare;\n    case HASH_POINTER: return &ptrCompare;\n    case HASH_STRING:  return &strCompare;\n    case HASH_BINARY:  return &binCompare;\n    default: break;\n  }\n  return 0;\n#else\n  if( keyClass==HASH_STRING ){\n    return &strCompare;\n  }else{\n    assert( keyClass==HASH_BINARY );\n    return &binCompare;\n  }\n#endif\n}\n\n/* Link an element into the hash table\n*/\nstatic void insertElement(\n  Hash *pH,              /* The complete hash table */\n  struct _ht *pEntry,    /* The entry into which pNew is inserted */\n  HashElem *pNew         /* The element to be inserted */\n){\n  HashElem *pHead;       /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n*/\nstatic void rehash(Hash *pH, int new_size){\n  struct _ht *new_ht;            /* The new hash table */\n  HashElem *elem, *next_elem;    /* For looping over existing elements */\n  int (*xHash)(const void*,int); /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _ht *)pH->xMalloc( new_size*sizeof(struct _ht) );\n  if( new_ht==0 ) return;\n  if( pH->ht ) pH->xFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = hashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic HashElem *findElementGivenHash(\n  const Hash *pH,     /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  HashElem *elem;                /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = compareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  Hash *pH,         /* The pH containing \"elem\" */\n  HashElem* elem,   /* The element to be removed from the pH */\n  int h             /* Hash value for the element */\n){\n  struct _ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    pH->xFree(elem->pKey);\n  }\n  pH->xFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nvoid *HashFind(const Hash *pH, const void *pKey, int nKey){\n  int h;             /* A hash on key */\n  HashElem *elem;    /* The element that matches key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1));\n  return elem ? elem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nvoid *HashInsert(Hash *pH, const void *pKey, int nKey, void *data){\n  int hraw;             /* Raw hash value of the key */\n  int h;                /* the hash of the key modulo hash table size */\n  HashElem *elem;       /* Used to loop thru the element list */\n  HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = findElementGivenHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (HashElem*)pH->xMalloc( sizeof(HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = pH->xMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      pH->xFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  if( pH->htsize==0 ){\n    rehash(pH,8);\n    if( pH->htsize==0 ){\n      pH->count = 0;\n      pH->xFree(new_elem);\n      return data;\n    }\n  }\n  if( pH->count > pH->htsize ){\n    rehash(pH,pH->htsize*2);\n  }\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  insertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/ft_hash.h",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _HASH_H_\n#define _HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Hash Hash;\ntypedef struct HashElem HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  HashElem *first;        /* The first element of the array */\n  void *(*xMalloc)(int);  /* malloc() function to use */\n  void (*xFree)(void *);  /* free() function to use */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _ht {            /* the hash table */\n    int count;               /* Number of entries with this hash */\n    HashElem *chain;         /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct HashElem {\n  HashElem *next, *prev;   /* Next and previous elements in the table */\n  void *data;              /* Data associated with this element */\n  void *pKey; int nKey;    /* Key associated with this element */\n};\n\n/*\n** There are 4 different modes of operation for a hash table:\n**\n**   HASH_INT         nKey is used as the key and pKey is ignored.\n**\n**   HASH_POINTER     pKey is used as the key and nKey is ignored.\n**\n**   HASH_STRING      pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   HASH_BINARY      pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made for HASH_STRING and HASH_BINARY\n** if the copyKey parameter to HashInit is 1.  \n*/\n/* #define HASH_INT       1 // NOT USED */\n/* #define HASH_POINTER   2 // NOT USED */\n#define HASH_STRING    3\n#define HASH_BINARY    4\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nvoid HashInit(Hash*, int keytype, int copyKey);\nvoid *HashInsert(Hash*, const void *pKey, int nKey, void *pData);\nvoid *HashFind(const Hash*, const void *pKey, int nKey);\nvoid HashClear(Hash*);\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Hash h;\n**   HashElem *p;\n**   ...\n**   for(p=HashFirst(&h); p; p=HashNext(p)){\n**     SomeStructure *pData = HashData(p);\n**     // do something with pData\n**   }\n*/\n#define HashFirst(H)  ((H)->first)\n#define HashNext(E)   ((E)->next)\n#define HashData(E)   ((E)->data)\n#define HashKey(E)    ((E)->pKey)\n#define HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define HashCount(H)  ((H)->count)\n\n#endif /* _HASH_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1.c",
    "content": "/* fts1 has a design flaw which can lead to database corruption (see\n** below).  It is recommended not to use it any longer, instead use\n** fts3 (or higher).  If you believe that your use of fts1 is safe,\n** add -DSQLITE_ENABLE_BROKEN_FTS1=1 to your CFLAGS.\n*/\n#if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1)) \\\n        && !defined(SQLITE_ENABLE_BROKEN_FTS1)\n#error fts1 has a design flaw and has been deprecated.\n#endif\n/* The flaw is that fts1 uses the content table's unaliased rowid as\n** the unique docid.  fts1 embeds the rowid in the index it builds,\n** and expects the rowid to not change.  The SQLite VACUUM operation\n** will renumber such rowids, thereby breaking fts1.  If you are using\n** fts1 in a system which has disabled VACUUM, then you can continue\n** to use it safely.  Note that PRAGMA auto_vacuum does NOT disable\n** VACUUM, though systems using auto_vacuum are unlikely to invoke\n** VACUUM.\n**\n** fts1 should be safe even across VACUUM if you only insert documents\n** and never delete.\n*/\n\n/* The author disclaims copyright to this source code.\n *\n * This is an SQLite module implementing full-text search.\n */\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS1 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS1 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS1 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1)\n\n#if defined(SQLITE_ENABLE_FTS1) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"fts1.h\"\n#include \"fts1_hash.h\"\n#include \"fts1_tokenizer.h\"\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n\n#if 0\n# define TRACE(A)  printf A; fflush(stdout)\n#else\n# define TRACE(A)\n#endif\n\n/* utility functions */\n\ntypedef struct StringBuffer {\n  int len;      /* length, not including null terminator */\n  int alloced;  /* Space allocated for s[] */ \n  char *s;      /* Content of the string */\n} StringBuffer;\n\nstatic void initStringBuffer(StringBuffer *sb){\n  sb->len = 0;\n  sb->alloced = 100;\n  sb->s = malloc(100);\n  sb->s[0] = '\\0';\n}\n\nstatic void nappend(StringBuffer *sb, const char *zFrom, int nFrom){\n  if( sb->len + nFrom >= sb->alloced ){\n    sb->alloced = sb->len + nFrom + 100;\n    sb->s = realloc(sb->s, sb->alloced+1);\n    if( sb->s==0 ){\n      initStringBuffer(sb);\n      return;\n    }\n  }\n  memcpy(sb->s + sb->len, zFrom, nFrom);\n  sb->len += nFrom;\n  sb->s[sb->len] = 0;\n}\nstatic void append(StringBuffer *sb, const char *zFrom){\n  nappend(sb, zFrom, strlen(zFrom));\n}\n\n/* We encode variable-length integers in little-endian order using seven bits\n * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n*/\n\n/* We may need up to VARINT_MAX bytes to store an encoded 64-bit integer. */\n#define VARINT_MAX 10\n\n/* Write a 64-bit variable-length integer to memory starting at p[0].\n * The length of data written will be between 1 and VARINT_MAX bytes.\n * The number of bytes written is returned. */\nstatic int putVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n/* Read a 64-bit variable-length integer from memory starting at p[0].\n * Return the number of bytes read, or 0 on error.\n * The value is stored in *v. */\nstatic int getVarint(const char *p, sqlite_int64 *v){\n  const unsigned char *q = (const unsigned char *) p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q & 0x80) == 0x80 ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n    if( q - (unsigned char *)p >= VARINT_MAX ){  /* bad data */\n      assert( 0 );\n      return 0;\n    }\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\nstatic int getVarint32(const char *p, int *pi){\n sqlite_int64 i;\n int ret = getVarint(p, &i);\n *pi = (int) i;\n assert( *pi==i );\n return ret;\n}\n\n/*** Document lists ***\n *\n * A document list holds a sorted list of varint-encoded document IDs.\n *\n * A doclist with type DL_POSITIONS_OFFSETS is stored like this:\n *\n * array {\n *   varint docid;\n *   array {\n *     varint position;     (delta from previous position plus POS_BASE)\n *     varint startOffset;  (delta from previous startOffset)\n *     varint endOffset;    (delta from startOffset)\n *   }\n * }\n *\n * Here, array { X } means zero or more occurrences of X, adjacent in memory.\n *\n * A position list may hold positions for text in multiple columns.  A position\n * POS_COLUMN is followed by a varint containing the index of the column for\n * following positions in the list.  Any positions appearing before any\n * occurrences of POS_COLUMN are for column 0.\n *\n * A doclist with type DL_POSITIONS is like the above, but holds only docids\n * and positions without offset information.\n *\n * A doclist with type DL_DOCIDS is like the above, but holds only docids\n * without positions or offset information.\n *\n * On disk, every document list has positions and offsets, so we don't bother\n * to serialize a doclist's type.\n * \n * We don't yet delta-encode document IDs; doing so will probably be a\n * modest win.\n *\n * NOTE(shess) I've thought of a slightly (1%) better offset encoding.\n * After the first offset, estimate the next offset by using the\n * current token position and the previous token position and offset,\n * offset to handle some variance.  So the estimate would be\n * (iPosition*w->iStartOffset/w->iPosition-64), which is delta-encoded\n * as normal.  Offsets more than 64 chars from the estimate are\n * encoded as the delta to the previous start offset + 128.  An\n * additional tiny increment can be gained by using the end offset of\n * the previous token to make the estimate a tiny bit more precise.\n*/\n\n/* It is not safe to call isspace(), tolower(), or isalnum() on\n** hi-bit-set characters.  This is the same solution used in the\n** tokenizer.\n*/\n/* TODO(shess) The snippet-generation code should be using the\n** tokenizer-generated tokens rather than doing its own local\n** tokenization.\n*/\n/* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */\nstatic int safe_isspace(char c){\n  return (c&0x80)==0 ? isspace((unsigned char)c) : 0;\n}\nstatic int safe_tolower(char c){\n  return (c&0x80)==0 ? tolower((unsigned char)c) : c;\n}\nstatic int safe_isalnum(char c){\n  return (c&0x80)==0 ? isalnum((unsigned char)c) : 0;\n}\n\ntypedef enum DocListType {\n  DL_DOCIDS,              /* docids only */\n  DL_POSITIONS,           /* docids + positions */\n  DL_POSITIONS_OFFSETS    /* docids + positions + offsets */\n} DocListType;\n\n/*\n** By default, only positions and not offsets are stored in the doclists.\n** To change this so that offsets are stored too, compile with\n**\n**          -DDL_DEFAULT=DL_POSITIONS_OFFSETS\n**\n*/\n#ifndef DL_DEFAULT\n# define DL_DEFAULT DL_POSITIONS\n#endif\n\ntypedef struct DocList {\n  char *pData;\n  int nData;\n  DocListType iType;\n  int iLastColumn;    /* the last column written */\n  int iLastPos;       /* the last position written */\n  int iLastOffset;    /* the last start offset written */\n} DocList;\n\nenum {\n  POS_END = 0,        /* end of this position list */\n  POS_COLUMN,         /* followed by new column number */\n  POS_BASE\n};\n\n/* Initialize a new DocList to hold the given data. */\nstatic void docListInit(DocList *d, DocListType iType,\n                        const char *pData, int nData){\n  d->nData = nData;\n  if( nData>0 ){\n    d->pData = malloc(nData);\n    memcpy(d->pData, pData, nData);\n  } else {\n    d->pData = NULL;\n  }\n  d->iType = iType;\n  d->iLastColumn = 0;\n  d->iLastPos = d->iLastOffset = 0;\n}\n\n/* Create a new dynamically-allocated DocList. */\nstatic DocList *docListNew(DocListType iType){\n  DocList *d = (DocList *) malloc(sizeof(DocList));\n  docListInit(d, iType, 0, 0);\n  return d;\n}\n\nstatic void docListDestroy(DocList *d){\n  free(d->pData);\n#ifndef NDEBUG\n  memset(d, 0x55, sizeof(*d));\n#endif\n}\n\nstatic void docListDelete(DocList *d){\n  docListDestroy(d);\n  free(d);\n}\n\nstatic char *docListEnd(DocList *d){\n  return d->pData + d->nData;\n}\n\n/* Append a varint to a DocList's data. */\nstatic void appendVarint(DocList *d, sqlite_int64 i){\n  char c[VARINT_MAX];\n  int n = putVarint(c, i);\n  d->pData = realloc(d->pData, d->nData + n);\n  memcpy(d->pData + d->nData, c, n);\n  d->nData += n;\n}\n\nstatic void docListAddDocid(DocList *d, sqlite_int64 iDocid){\n  appendVarint(d, iDocid);\n  if( d->iType>=DL_POSITIONS ){\n    appendVarint(d, POS_END);  /* initially empty position list */\n    d->iLastColumn = 0;\n    d->iLastPos = d->iLastOffset = 0;\n  }\n}\n\n/* helper function for docListAddPos and docListAddPosOffset */\nstatic void addPos(DocList *d, int iColumn, int iPos){\n  assert( d->nData>0 );\n  --d->nData;  /* remove previous terminator */\n  if( iColumn!=d->iLastColumn ){\n    assert( iColumn>d->iLastColumn );\n    appendVarint(d, POS_COLUMN);\n    appendVarint(d, iColumn);\n    d->iLastColumn = iColumn;\n    d->iLastPos = d->iLastOffset = 0;\n  }\n  assert( iPos>=d->iLastPos );\n  appendVarint(d, iPos-d->iLastPos+POS_BASE);\n  d->iLastPos = iPos;\n}\n\n/* Add a position to the last position list in a doclist. */\nstatic void docListAddPos(DocList *d, int iColumn, int iPos){\n  assert( d->iType==DL_POSITIONS );\n  addPos(d, iColumn, iPos);\n  appendVarint(d, POS_END);  /* add new terminator */\n}\n\n/*\n** Add a position and starting and ending offsets to a doclist.\n**\n** If the doclist is setup to handle only positions, then insert\n** the position only and ignore the offsets.\n*/\nstatic void docListAddPosOffset(\n  DocList *d,             /* Doclist under construction */\n  int iColumn,            /* Column the inserted term is part of */\n  int iPos,               /* Position of the inserted term */\n  int iStartOffset,       /* Starting offset of inserted term */\n  int iEndOffset          /* Ending offset of inserted term */\n){\n  assert( d->iType>=DL_POSITIONS );\n  addPos(d, iColumn, iPos);\n  if( d->iType==DL_POSITIONS_OFFSETS ){\n    assert( iStartOffset>=d->iLastOffset );\n    appendVarint(d, iStartOffset-d->iLastOffset);\n    d->iLastOffset = iStartOffset;\n    assert( iEndOffset>=iStartOffset );\n    appendVarint(d, iEndOffset-iStartOffset);\n  }\n  appendVarint(d, POS_END);  /* add new terminator */\n}\n\n/*\n** A DocListReader object is a cursor into a doclist.  Initialize\n** the cursor to the beginning of the doclist by calling readerInit().\n** Then use routines\n**\n**      peekDocid()\n**      readDocid()\n**      readPosition()\n**      skipPositionList()\n**      and so forth...\n**\n** to read information out of the doclist.  When we reach the end\n** of the doclist, atEnd() returns TRUE.\n*/\ntypedef struct DocListReader {\n  DocList *pDoclist;  /* The document list we are stepping through */\n  char *p;            /* Pointer to next unread byte in the doclist */\n  int iLastColumn;\n  int iLastPos;  /* the last position read, or -1 when not in a position list */\n} DocListReader;\n\n/*\n** Initialize the DocListReader r to point to the beginning of pDoclist.\n*/\nstatic void readerInit(DocListReader *r, DocList *pDoclist){\n  r->pDoclist = pDoclist;\n  if( pDoclist!=NULL ){\n    r->p = pDoclist->pData;\n  }\n  r->iLastColumn = -1;\n  r->iLastPos = -1;\n}\n\n/*\n** Return TRUE if we have reached then end of pReader and there is\n** nothing else left to read.\n*/\nstatic int atEnd(DocListReader *pReader){\n  return pReader->pDoclist==0 || (pReader->p >= docListEnd(pReader->pDoclist));\n}\n\n/* Peek at the next docid without advancing the read pointer. \n*/\nstatic sqlite_int64 peekDocid(DocListReader *pReader){\n  sqlite_int64 ret;\n  assert( !atEnd(pReader) );\n  assert( pReader->iLastPos==-1 );\n  getVarint(pReader->p, &ret);\n  return ret;\n}\n\n/* Read the next docid.   See also nextDocid().\n*/\nstatic sqlite_int64 readDocid(DocListReader *pReader){\n  sqlite_int64 ret;\n  assert( !atEnd(pReader) );\n  assert( pReader->iLastPos==-1 );\n  pReader->p += getVarint(pReader->p, &ret);\n  if( pReader->pDoclist->iType>=DL_POSITIONS ){\n    pReader->iLastColumn = 0;\n    pReader->iLastPos = 0;\n  }\n  return ret;\n}\n\n/* Read the next position and column index from a position list.\n * Returns the position, or -1 at the end of the list. */\nstatic int readPosition(DocListReader *pReader, int *iColumn){\n  int i;\n  int iType = pReader->pDoclist->iType;\n\n  if( pReader->iLastPos==-1 ){\n    return -1;\n  }\n  assert( !atEnd(pReader) );\n\n  if( iType<DL_POSITIONS ){\n    return -1;\n  }\n  pReader->p += getVarint32(pReader->p, &i);\n  if( i==POS_END ){\n    pReader->iLastColumn = pReader->iLastPos = -1;\n    *iColumn = -1;\n    return -1;\n  }\n  if( i==POS_COLUMN ){\n    pReader->p += getVarint32(pReader->p, &pReader->iLastColumn);\n    pReader->iLastPos = 0;\n    pReader->p += getVarint32(pReader->p, &i);\n    assert( i>=POS_BASE );\n  }\n  pReader->iLastPos += ((int) i)-POS_BASE;\n  if( iType>=DL_POSITIONS_OFFSETS ){\n    /* Skip over offsets, ignoring them for now. */\n    int iStart, iEnd;\n    pReader->p += getVarint32(pReader->p, &iStart);\n    pReader->p += getVarint32(pReader->p, &iEnd);\n  }\n  *iColumn = pReader->iLastColumn;\n  return pReader->iLastPos;\n}\n\n/* Skip past the end of a position list. */\nstatic void skipPositionList(DocListReader *pReader){\n  DocList *p = pReader->pDoclist;\n  if( p && p->iType>=DL_POSITIONS ){\n    int iColumn;\n    while( readPosition(pReader, &iColumn)!=-1 ){}\n  }\n}\n\n/* Skip over a docid, including its position list if the doclist has\n * positions. */\nstatic void skipDocument(DocListReader *pReader){\n  readDocid(pReader);\n  skipPositionList(pReader);\n}\n\n/* Skip past all docids which are less than [iDocid].  Returns 1 if a docid\n * matching [iDocid] was found.  */\nstatic int skipToDocid(DocListReader *pReader, sqlite_int64 iDocid){\n  sqlite_int64 d = 0;\n  while( !atEnd(pReader) && (d=peekDocid(pReader))<iDocid ){\n    skipDocument(pReader);\n  }\n  return !atEnd(pReader) && d==iDocid;\n}\n\n/* Return the first document in a document list.\n*/\nstatic sqlite_int64 firstDocid(DocList *d){\n  DocListReader r;\n  readerInit(&r, d);\n  return readDocid(&r);\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This routine is used for debugging purpose only.\n**\n** Write the content of a doclist to standard output.\n*/\nstatic void printDoclist(DocList *p){\n  DocListReader r;\n  const char *zSep = \"\";\n\n  readerInit(&r, p);\n  while( !atEnd(&r) ){\n    sqlite_int64 docid = readDocid(&r);\n    if( docid==0 ){\n      skipPositionList(&r);\n      continue;\n    }\n    printf(\"%s%lld\", zSep, docid);\n    zSep =  \",\";\n    if( p->iType>=DL_POSITIONS ){\n      int iPos, iCol;\n      const char *zDiv = \"\";\n      printf(\"(\");\n      while( (iPos = readPosition(&r, &iCol))>=0 ){\n        printf(\"%s%d:%d\", zDiv, iCol, iPos);\n        zDiv = \":\";\n      }\n      printf(\")\");\n    }\n  }\n  printf(\"\\n\");\n  fflush(stdout);\n}\n#endif /* SQLITE_DEBUG */\n\n/* Trim the given doclist to contain only positions in column\n * [iRestrictColumn]. */\nstatic void docListRestrictColumn(DocList *in, int iRestrictColumn){\n  DocListReader r;\n  DocList out;\n\n  assert( in->iType>=DL_POSITIONS );\n  readerInit(&r, in);\n  docListInit(&out, DL_POSITIONS, NULL, 0);\n\n  while( !atEnd(&r) ){\n    sqlite_int64 iDocid = readDocid(&r);\n    int iPos, iColumn;\n\n    docListAddDocid(&out, iDocid);\n    while( (iPos = readPosition(&r, &iColumn)) != -1 ){\n      if( iColumn==iRestrictColumn ){\n        docListAddPos(&out, iColumn, iPos);\n      }\n    }\n  }\n\n  docListDestroy(in);\n  *in = out;\n}\n\n/* Trim the given doclist by discarding any docids without any remaining\n * positions. */\nstatic void docListDiscardEmpty(DocList *in) {\n  DocListReader r;\n  DocList out;\n\n  /* TODO: It would be nice to implement this operation in place; that\n   * could save a significant amount of memory in queries with long doclists. */\n  assert( in->iType>=DL_POSITIONS );\n  readerInit(&r, in);\n  docListInit(&out, DL_POSITIONS, NULL, 0);\n\n  while( !atEnd(&r) ){\n    sqlite_int64 iDocid = readDocid(&r);\n    int match = 0;\n    int iPos, iColumn;\n    while( (iPos = readPosition(&r, &iColumn)) != -1 ){\n      if( !match ){\n        docListAddDocid(&out, iDocid);\n        match = 1;\n      }\n      docListAddPos(&out, iColumn, iPos);\n    }\n  }\n\n  docListDestroy(in);\n  *in = out;\n}\n\n/* Helper function for docListUpdate() and docListAccumulate().\n** Splices a doclist element into the doclist represented by r,\n** leaving r pointing after the newly spliced element.\n*/\nstatic void docListSpliceElement(DocListReader *r, sqlite_int64 iDocid,\n                                 const char *pSource, int nSource){\n  DocList *d = r->pDoclist;\n  char *pTarget;\n  int nTarget, found;\n\n  found = skipToDocid(r, iDocid);\n\n  /* Describe slice in d to place pSource/nSource. */\n  pTarget = r->p;\n  if( found ){\n    skipDocument(r);\n    nTarget = r->p-pTarget;\n  }else{\n    nTarget = 0;\n  }\n\n  /* The sense of the following is that there are three possibilities.\n  ** If nTarget==nSource, we should not move any memory nor realloc.\n  ** If nTarget>nSource, trim target and realloc.\n  ** If nTarget<nSource, realloc then expand target.\n  */\n  if( nTarget>nSource ){\n    memmove(pTarget+nSource, pTarget+nTarget, docListEnd(d)-(pTarget+nTarget));\n  }\n  if( nTarget!=nSource ){\n    int iDoclist = pTarget-d->pData;\n    d->pData = realloc(d->pData, d->nData+nSource-nTarget);\n    pTarget = d->pData+iDoclist;\n  }\n  if( nTarget<nSource ){\n    memmove(pTarget+nSource, pTarget+nTarget, docListEnd(d)-(pTarget+nTarget));\n  }\n\n  memcpy(pTarget, pSource, nSource);\n  d->nData += nSource-nTarget;\n  r->p = pTarget+nSource;\n}\n\n/* Insert/update pUpdate into the doclist. */\nstatic void docListUpdate(DocList *d, DocList *pUpdate){\n  DocListReader reader;\n\n  assert( d!=NULL && pUpdate!=NULL );\n  assert( d->iType==pUpdate->iType);\n\n  readerInit(&reader, d);\n  docListSpliceElement(&reader, firstDocid(pUpdate),\n                       pUpdate->pData, pUpdate->nData);\n}\n\n/* Propagate elements from pUpdate to pAcc, overwriting elements with\n** matching docids.\n*/\nstatic void docListAccumulate(DocList *pAcc, DocList *pUpdate){\n  DocListReader accReader, updateReader;\n\n  /* Handle edge cases where one doclist is empty. */\n  assert( pAcc!=NULL );\n  if( pUpdate==NULL || pUpdate->nData==0 ) return;\n  if( pAcc->nData==0 ){\n    pAcc->pData = malloc(pUpdate->nData);\n    memcpy(pAcc->pData, pUpdate->pData, pUpdate->nData);\n    pAcc->nData = pUpdate->nData;\n    return;\n  }\n\n  readerInit(&accReader, pAcc);\n  readerInit(&updateReader, pUpdate);\n\n  while( !atEnd(&updateReader) ){\n    char *pSource = updateReader.p;\n    sqlite_int64 iDocid = readDocid(&updateReader);\n    skipPositionList(&updateReader);\n    docListSpliceElement(&accReader, iDocid, pSource, updateReader.p-pSource);\n  }\n}\n\n/*\n** Read the next docid off of pIn.  Return 0 if we reach the end.\n*\n* TODO: This assumes that docids are never 0, but they may actually be 0 since\n* users can choose docids when inserting into a full-text table.  Fix this.\n*/\nstatic sqlite_int64 nextDocid(DocListReader *pIn){\n  skipPositionList(pIn);\n  return atEnd(pIn) ? 0 : readDocid(pIn);\n}\n\n/*\n** pLeft and pRight are two DocListReaders that are pointing to\n** positions lists of the same document: iDocid. \n**\n** If there are no instances in pLeft or pRight where the position\n** of pLeft is one less than the position of pRight, then this\n** routine adds nothing to pOut.\n**\n** If there are one or more instances where positions from pLeft\n** are exactly one less than positions from pRight, then add a new\n** document record to pOut.  If pOut wants to hold positions, then\n** include the positions from pRight that are one more than a\n** position in pLeft.  In other words:  pRight.iPos==pLeft.iPos+1.\n**\n** pLeft and pRight are left pointing at the next document record.\n*/\nstatic void mergePosList(\n  DocListReader *pLeft,    /* Left position list */\n  DocListReader *pRight,   /* Right position list */\n  sqlite_int64 iDocid,     /* The docid from pLeft and pRight */\n  DocList *pOut            /* Write the merged document record here */\n){\n  int iLeftCol, iLeftPos = readPosition(pLeft, &iLeftCol);\n  int iRightCol, iRightPos = readPosition(pRight, &iRightCol);\n  int match = 0;\n\n  /* Loop until we've reached the end of both position lists. */\n  while( iLeftPos!=-1 && iRightPos!=-1 ){\n    if( iLeftCol==iRightCol && iLeftPos+1==iRightPos ){\n      if( !match ){\n        docListAddDocid(pOut, iDocid);\n        match = 1;\n      }\n      if( pOut->iType>=DL_POSITIONS ){\n        docListAddPos(pOut, iRightCol, iRightPos);\n      }\n      iLeftPos = readPosition(pLeft, &iLeftCol);\n      iRightPos = readPosition(pRight, &iRightCol);\n    }else if( iRightCol<iLeftCol ||\n              (iRightCol==iLeftCol && iRightPos<iLeftPos+1) ){\n      iRightPos = readPosition(pRight, &iRightCol);\n    }else{\n      iLeftPos = readPosition(pLeft, &iLeftCol);\n    }\n  }\n  if( iLeftPos>=0 ) skipPositionList(pLeft);\n  if( iRightPos>=0 ) skipPositionList(pRight);\n}\n\n/* We have two doclists:  pLeft and pRight.\n** Write the phrase intersection of these two doclists into pOut.\n**\n** A phrase intersection means that two documents only match\n** if pLeft.iPos+1==pRight.iPos.\n**\n** The output pOut may or may not contain positions.  If pOut\n** does contain positions, they are the positions of pRight.\n*/\nstatic void docListPhraseMerge(\n  DocList *pLeft,    /* Doclist resulting from the words on the left */\n  DocList *pRight,   /* Doclist for the next word to the right */\n  DocList *pOut      /* Write the combined doclist here */\n){\n  DocListReader left, right;\n  sqlite_int64 docidLeft, docidRight;\n\n  readerInit(&left, pLeft);\n  readerInit(&right, pRight);\n  docidLeft = nextDocid(&left);\n  docidRight = nextDocid(&right);\n\n  while( docidLeft>0 && docidRight>0 ){\n    if( docidLeft<docidRight ){\n      docidLeft = nextDocid(&left);\n    }else if( docidRight<docidLeft ){\n      docidRight = nextDocid(&right);\n    }else{\n      mergePosList(&left, &right, docidLeft, pOut);\n      docidLeft = nextDocid(&left);\n      docidRight = nextDocid(&right);\n    }\n  }\n}\n\n/* We have two doclists:  pLeft and pRight.\n** Write the intersection of these two doclists into pOut.\n** Only docids are matched.  Position information is ignored.\n**\n** The output pOut never holds positions.\n*/\nstatic void docListAndMerge(\n  DocList *pLeft,    /* Doclist resulting from the words on the left */\n  DocList *pRight,   /* Doclist for the next word to the right */\n  DocList *pOut      /* Write the combined doclist here */\n){\n  DocListReader left, right;\n  sqlite_int64 docidLeft, docidRight;\n\n  assert( pOut->iType<DL_POSITIONS );\n\n  readerInit(&left, pLeft);\n  readerInit(&right, pRight);\n  docidLeft = nextDocid(&left);\n  docidRight = nextDocid(&right);\n\n  while( docidLeft>0 && docidRight>0 ){\n    if( docidLeft<docidRight ){\n      docidLeft = nextDocid(&left);\n    }else if( docidRight<docidLeft ){\n      docidRight = nextDocid(&right);\n    }else{\n      docListAddDocid(pOut, docidLeft);\n      docidLeft = nextDocid(&left);\n      docidRight = nextDocid(&right);\n    }\n  }\n}\n\n/* We have two doclists:  pLeft and pRight.\n** Write the union of these two doclists into pOut.\n** Only docids are matched.  Position information is ignored.\n**\n** The output pOut never holds positions.\n*/\nstatic void docListOrMerge(\n  DocList *pLeft,    /* Doclist resulting from the words on the left */\n  DocList *pRight,   /* Doclist for the next word to the right */\n  DocList *pOut      /* Write the combined doclist here */\n){\n  DocListReader left, right;\n  sqlite_int64 docidLeft, docidRight, priorLeft;\n\n  readerInit(&left, pLeft);\n  readerInit(&right, pRight);\n  docidLeft = nextDocid(&left);\n  docidRight = nextDocid(&right);\n\n  while( docidLeft>0 && docidRight>0 ){\n    if( docidLeft<=docidRight ){\n      docListAddDocid(pOut, docidLeft);\n    }else{\n      docListAddDocid(pOut, docidRight);\n    }\n    priorLeft = docidLeft;\n    if( docidLeft<=docidRight ){\n      docidLeft = nextDocid(&left);\n    }\n    if( docidRight>0 && docidRight<=priorLeft ){\n      docidRight = nextDocid(&right);\n    }\n  }\n  while( docidLeft>0 ){\n    docListAddDocid(pOut, docidLeft);\n    docidLeft = nextDocid(&left);\n  }\n  while( docidRight>0 ){\n    docListAddDocid(pOut, docidRight);\n    docidRight = nextDocid(&right);\n  }\n}\n\n/* We have two doclists:  pLeft and pRight.\n** Write into pOut all documents that occur in pLeft but not\n** in pRight.\n**\n** Only docids are matched.  Position information is ignored.\n**\n** The output pOut never holds positions.\n*/\nstatic void docListExceptMerge(\n  DocList *pLeft,    /* Doclist resulting from the words on the left */\n  DocList *pRight,   /* Doclist for the next word to the right */\n  DocList *pOut      /* Write the combined doclist here */\n){\n  DocListReader left, right;\n  sqlite_int64 docidLeft, docidRight, priorLeft;\n\n  readerInit(&left, pLeft);\n  readerInit(&right, pRight);\n  docidLeft = nextDocid(&left);\n  docidRight = nextDocid(&right);\n\n  while( docidLeft>0 && docidRight>0 ){\n    priorLeft = docidLeft;\n    if( docidLeft<docidRight ){\n      docListAddDocid(pOut, docidLeft);\n    }\n    if( docidLeft<=docidRight ){\n      docidLeft = nextDocid(&left);\n    }\n    if( docidRight>0 && docidRight<=priorLeft ){\n      docidRight = nextDocid(&right);\n    }\n  }\n  while( docidLeft>0 ){\n    docListAddDocid(pOut, docidLeft);\n    docidLeft = nextDocid(&left);\n  }\n}\n\nstatic char *string_dup_n(const char *s, int n){\n  char *str = malloc(n + 1);\n  memcpy(str, s, n);\n  str[n] = '\\0';\n  return str;\n}\n\n/* Duplicate a string; the caller must free() the returned string.\n * (We don't use strdup() since it is not part of the standard C library and\n * may not be available everywhere.) */\nstatic char *string_dup(const char *s){\n  return string_dup_n(s, strlen(s));\n}\n\n/* Format a string, replacing each occurrence of the % character with\n * zDb.zName.  This may be more convenient than sqlite_mprintf()\n * when one string is used repeatedly in a format string.\n * The caller must free() the returned string. */\nstatic char *string_format(const char *zFormat,\n                           const char *zDb, const char *zName){\n  const char *p;\n  size_t len = 0;\n  size_t nDb = strlen(zDb);\n  size_t nName = strlen(zName);\n  size_t nFullTableName = nDb+1+nName;\n  char *result;\n  char *r;\n\n  /* first compute length needed */\n  for(p = zFormat ; *p ; ++p){\n    len += (*p=='%' ? nFullTableName : 1);\n  }\n  len += 1;  /* for null terminator */\n\n  r = result = malloc(len);\n  for(p = zFormat; *p; ++p){\n    if( *p=='%' ){\n      memcpy(r, zDb, nDb);\n      r += nDb;\n      *r++ = '.';\n      memcpy(r, zName, nName);\n      r += nName;\n    } else {\n      *r++ = *p;\n    }\n  }\n  *r++ = '\\0';\n  assert( r == result + len );\n  return result;\n}\n\nstatic int sql_exec(sqlite3 *db, const char *zDb, const char *zName,\n                    const char *zFormat){\n  char *zCommand = string_format(zFormat, zDb, zName);\n  int rc;\n  TRACE((\"FTS1 sql: %s\\n\", zCommand));\n  rc = sqlite3_exec(db, zCommand, NULL, 0, NULL);\n  free(zCommand);\n  return rc;\n}\n\nstatic int sql_prepare(sqlite3 *db, const char *zDb, const char *zName,\n                       sqlite3_stmt **ppStmt, const char *zFormat){\n  char *zCommand = string_format(zFormat, zDb, zName);\n  int rc;\n  TRACE((\"FTS1 prepare: %s\\n\", zCommand));\n  rc = sqlite3_prepare(db, zCommand, -1, ppStmt, NULL);\n  free(zCommand);\n  return rc;\n}\n\n/* end utility functions */\n\n/* Forward reference */\ntypedef struct fulltext_vtab fulltext_vtab;\n\n/* A single term in a query is represented by an instances of\n** the following structure.\n*/\ntypedef struct QueryTerm {\n  short int nPhrase; /* How many following terms are part of the same phrase */\n  short int iPhrase; /* This is the i-th term of a phrase. */\n  short int iColumn; /* Column of the index that must match this term */\n  signed char isOr;  /* this term is preceded by \"OR\" */\n  signed char isNot; /* this term is preceded by \"-\" */\n  char *pTerm;       /* text of the term.  '\\000' terminated.  malloced */\n  int nTerm;         /* Number of bytes in pTerm[] */\n} QueryTerm;\n\n\n/* A query string is parsed into a Query structure.\n *\n * We could, in theory, allow query strings to be complicated\n * nested expressions with precedence determined by parentheses.\n * But none of the major search engines do this.  (Perhaps the\n * feeling is that an parenthesized expression is two complex of\n * an idea for the average user to grasp.)  Taking our lead from\n * the major search engines, we will allow queries to be a list\n * of terms (with an implied AND operator) or phrases in double-quotes,\n * with a single optional \"-\" before each non-phrase term to designate\n * negation and an optional OR connector.\n *\n * OR binds more tightly than the implied AND, which is what the\n * major search engines seem to do.  So, for example:\n * \n *    [one two OR three]     ==>    one AND (two OR three)\n *    [one OR two three]     ==>    (one OR two) AND three\n *\n * A \"-\" before a term matches all entries that lack that term.\n * The \"-\" must occur immediately before the term with in intervening\n * space.  This is how the search engines do it.\n *\n * A NOT term cannot be the right-hand operand of an OR.  If this\n * occurs in the query string, the NOT is ignored:\n *\n *    [one OR -two]          ==>    one OR two\n *\n */\ntypedef struct Query {\n  fulltext_vtab *pFts;  /* The full text index */\n  int nTerms;           /* Number of terms in the query */\n  QueryTerm *pTerms;    /* Array of terms.  Space obtained from malloc() */\n  int nextIsOr;         /* Set the isOr flag on the next inserted term */\n  int nextColumn;       /* Next word parsed must be in this column */\n  int dfltColumn;       /* The default column */\n} Query;\n\n\n/*\n** An instance of the following structure keeps track of generated\n** matching-word offset information and snippets.\n*/\ntypedef struct Snippet {\n  int nMatch;     /* Total number of matches */\n  int nAlloc;     /* Space allocated for aMatch[] */\n  struct snippetMatch { /* One entry for each matching term */\n    char snStatus;       /* Status flag for use while constructing snippets */\n    short int iCol;      /* The column that contains the match */\n    short int iTerm;     /* The index in Query.pTerms[] of the matching term */\n    short int nByte;     /* Number of bytes in the term */\n    int iStart;          /* The offset to the first character of the term */\n  } *aMatch;      /* Points to space obtained from malloc */\n  char *zOffset;  /* Text rendering of aMatch[] */\n  int nOffset;    /* strlen(zOffset) */\n  char *zSnippet; /* Snippet text */\n  int nSnippet;   /* strlen(zSnippet) */\n} Snippet;\n\n\ntypedef enum QueryType {\n  QUERY_GENERIC,   /* table scan */\n  QUERY_ROWID,     /* lookup by rowid */\n  QUERY_FULLTEXT   /* QUERY_FULLTEXT + [i] is a full-text search for column i*/\n} QueryType;\n\n/* TODO(shess) CHUNK_MAX controls how much data we allow in segment 0\n** before we start aggregating into larger segments.  Lower CHUNK_MAX\n** means that for a given input we have more individual segments per\n** term, which means more rows in the table and a bigger index (due to\n** both more rows and bigger rowids).  But it also reduces the average\n** cost of adding new elements to the segment 0 doclist, and it seems\n** to reduce the number of pages read and written during inserts.  256\n** was chosen by measuring insertion times for a certain input (first\n** 10k documents of Enron corpus), though including query performance\n** in the decision may argue for a larger value.\n*/\n#define CHUNK_MAX 256\n\ntypedef enum fulltext_statement {\n  CONTENT_INSERT_STMT,\n  CONTENT_SELECT_STMT,\n  CONTENT_UPDATE_STMT,\n  CONTENT_DELETE_STMT,\n\n  TERM_SELECT_STMT,\n  TERM_SELECT_ALL_STMT,\n  TERM_INSERT_STMT,\n  TERM_UPDATE_STMT,\n  TERM_DELETE_STMT,\n\n  MAX_STMT                     /* Always at end! */\n} fulltext_statement;\n\n/* These must exactly match the enum above. */\n/* TODO(adam): Is there some risk that a statement (in particular,\n** pTermSelectStmt) will be used in two cursors at once, e.g.  if a\n** query joins a virtual table to itself?  If so perhaps we should\n** move some of these to the cursor object.\n*/\nstatic const char *const fulltext_zStatement[MAX_STMT] = {\n  /* CONTENT_INSERT */ NULL,  /* generated in contentInsertStatement() */\n  /* CONTENT_SELECT */ \"select * from %_content where rowid = ?\",\n  /* CONTENT_UPDATE */ NULL,  /* generated in contentUpdateStatement() */\n  /* CONTENT_DELETE */ \"delete from %_content where rowid = ?\",\n\n  /* TERM_SELECT */\n  \"select rowid, doclist from %_term where term = ? and segment = ?\",\n  /* TERM_SELECT_ALL */\n  \"select doclist from %_term where term = ? order by segment\",\n  /* TERM_INSERT */\n  \"insert into %_term (rowid, term, segment, doclist) values (?, ?, ?, ?)\",\n  /* TERM_UPDATE */ \"update %_term set doclist = ? where rowid = ?\",\n  /* TERM_DELETE */ \"delete from %_term where rowid = ?\",\n};\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure.  The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct fulltext_vtab {\n  sqlite3_vtab base;               /* Base class used by SQLite core */\n  sqlite3 *db;                     /* The database connection */\n  const char *zDb;                 /* logical database name */\n  const char *zName;               /* virtual table name */\n  int nColumn;                     /* number of columns in virtual table */\n  char **azColumn;                 /* column names.  malloced */\n  char **azContentColumn;          /* column names in content table; malloced */\n  sqlite3_tokenizer *pTokenizer;   /* tokenizer for inserts and queries */\n\n  /* Precompiled statements which we keep as long as the table is\n  ** open.\n  */\n  sqlite3_stmt *pFulltextStatements[MAX_STMT];\n};\n\n/*\n** When the core wants to do a query, it create a cursor using a\n** call to xOpen.  This structure is an instance of a cursor.  It\n** is destroyed by xClose.\n*/\ntypedef struct fulltext_cursor {\n  sqlite3_vtab_cursor base;        /* Base class used by SQLite core */\n  QueryType iCursorType;           /* Copy of sqlite3_index_info.idxNum */\n  sqlite3_stmt *pStmt;             /* Prepared statement in use by the cursor */\n  int eof;                         /* True if at End Of Results */\n  Query q;                         /* Parsed query string */\n  Snippet snippet;                 /* Cached snippet for the current row */\n  int iColumn;                     /* Column being searched */\n  DocListReader result;  /* used when iCursorType == QUERY_FULLTEXT */ \n} fulltext_cursor;\n\nstatic struct fulltext_vtab *cursor_vtab(fulltext_cursor *c){\n  return (fulltext_vtab *) c->base.pVtab;\n}\n\nstatic const sqlite3_module fulltextModule;   /* forward declaration */\n\n/* Append a list of strings separated by commas to a StringBuffer. */\nstatic void appendList(StringBuffer *sb, int nString, char **azString){\n  int i;\n  for(i=0; i<nString; ++i){\n    if( i>0 ) append(sb, \", \");\n    append(sb, azString[i]);\n  }\n}\n\n/* Return a dynamically generated statement of the form\n *   insert into %_content (rowid, ...) values (?, ...)\n */\nstatic const char *contentInsertStatement(fulltext_vtab *v){\n  StringBuffer sb;\n  int i;\n\n  initStringBuffer(&sb);\n  append(&sb, \"insert into %_content (rowid, \");\n  appendList(&sb, v->nColumn, v->azContentColumn);\n  append(&sb, \") values (?\");\n  for(i=0; i<v->nColumn; ++i)\n    append(&sb, \", ?\");\n  append(&sb, \")\");\n  return sb.s;\n}\n\n/* Return a dynamically generated statement of the form\n *   update %_content set [col_0] = ?, [col_1] = ?, ...\n *                    where rowid = ?\n */\nstatic const char *contentUpdateStatement(fulltext_vtab *v){\n  StringBuffer sb;\n  int i;\n\n  initStringBuffer(&sb);\n  append(&sb, \"update %_content set \");\n  for(i=0; i<v->nColumn; ++i) {\n    if( i>0 ){\n      append(&sb, \", \");\n    }\n    append(&sb, v->azContentColumn[i]);\n    append(&sb, \" = ?\");\n  }\n  append(&sb, \" where rowid = ?\");\n  return sb.s;\n}\n\n/* Puts a freshly-prepared statement determined by iStmt in *ppStmt.\n** If the indicated statement has never been prepared, it is prepared\n** and cached, otherwise the cached version is reset.\n*/\nstatic int sql_get_statement(fulltext_vtab *v, fulltext_statement iStmt,\n                             sqlite3_stmt **ppStmt){\n  assert( iStmt<MAX_STMT );\n  if( v->pFulltextStatements[iStmt]==NULL ){\n    const char *zStmt;\n    int rc;\n    switch( iStmt ){\n      case CONTENT_INSERT_STMT:\n        zStmt = contentInsertStatement(v); break;\n      case CONTENT_UPDATE_STMT:\n        zStmt = contentUpdateStatement(v); break;\n      default:\n        zStmt = fulltext_zStatement[iStmt];\n    }\n    rc = sql_prepare(v->db, v->zDb, v->zName, &v->pFulltextStatements[iStmt],\n                         zStmt);\n    if( zStmt != fulltext_zStatement[iStmt]) free((void *) zStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  } else {\n    int rc = sqlite3_reset(v->pFulltextStatements[iStmt]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  *ppStmt = v->pFulltextStatements[iStmt];\n  return SQLITE_OK;\n}\n\n/* Step the indicated statement, handling errors SQLITE_BUSY (by\n** retrying) and SQLITE_SCHEMA (by re-preparing and transferring\n** bindings to the new statement).\n** TODO(adam): We should extend this function so that it can work with\n** statements declared locally, not only globally cached statements.\n*/\nstatic int sql_step_statement(fulltext_vtab *v, fulltext_statement iStmt,\n                              sqlite3_stmt **ppStmt){\n  int rc;\n  sqlite3_stmt *s = *ppStmt;\n  assert( iStmt<MAX_STMT );\n  assert( s==v->pFulltextStatements[iStmt] );\n\n  while( (rc=sqlite3_step(s))!=SQLITE_DONE && rc!=SQLITE_ROW ){\n    if( rc==SQLITE_BUSY ) continue;\n    if( rc!=SQLITE_ERROR ) return rc;\n\n    /* If an SQLITE_SCHEMA error has occurred, then finalizing this\n     * statement is going to delete the fulltext_vtab structure. If\n     * the statement just executed is in the pFulltextStatements[]\n     * array, it will be finalized twice. So remove it before\n     * calling sqlite3_finalize().\n     */\n    v->pFulltextStatements[iStmt] = NULL;\n    rc = sqlite3_finalize(s);\n    break;\n  }\n  return rc;\n\n err:\n  sqlite3_finalize(s);\n  return rc;\n}\n\n/* Like sql_step_statement(), but convert SQLITE_DONE to SQLITE_OK.\n** Useful for statements like UPDATE, where we expect no results.\n*/\nstatic int sql_single_step_statement(fulltext_vtab *v,\n                                     fulltext_statement iStmt,\n                                     sqlite3_stmt **ppStmt){\n  int rc = sql_step_statement(v, iStmt, ppStmt);\n  return (rc==SQLITE_DONE) ? SQLITE_OK : rc;\n}\n\n/* insert into %_content (rowid, ...) values ([rowid], [pValues]) */\nstatic int content_insert(fulltext_vtab *v, sqlite3_value *rowid,\n                          sqlite3_value **pValues){\n  sqlite3_stmt *s;\n  int i;\n  int rc = sql_get_statement(v, CONTENT_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_value(s, 1, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i=0; i<v->nColumn; ++i){\n    rc = sqlite3_bind_value(s, 2+i, pValues[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  return sql_single_step_statement(v, CONTENT_INSERT_STMT, &s);\n}\n\n/* update %_content set col0 = pValues[0], col1 = pValues[1], ...\n *                  where rowid = [iRowid] */\nstatic int content_update(fulltext_vtab *v, sqlite3_value **pValues,\n                          sqlite_int64 iRowid){\n  sqlite3_stmt *s;\n  int i;\n  int rc = sql_get_statement(v, CONTENT_UPDATE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i=0; i<v->nColumn; ++i){\n    rc = sqlite3_bind_value(s, 1+i, pValues[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  rc = sqlite3_bind_int64(s, 1+v->nColumn, iRowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, CONTENT_UPDATE_STMT, &s);\n}\n\nstatic void freeStringArray(int nString, const char **pString){\n  int i;\n\n  for (i=0 ; i < nString ; ++i) {\n    if( pString[i]!=NULL ) free((void *) pString[i]);\n  }\n  free((void *) pString);\n}\n\n/* select * from %_content where rowid = [iRow]\n * The caller must delete the returned array and all strings in it.\n * null fields will be NULL in the returned array.\n *\n * TODO: Perhaps we should return pointer/length strings here for consistency\n * with other code which uses pointer/length. */\nstatic int content_select(fulltext_vtab *v, sqlite_int64 iRow,\n                          const char ***pValues){\n  sqlite3_stmt *s;\n  const char **values;\n  int i;\n  int rc;\n\n  *pValues = NULL;\n\n  rc = sql_get_statement(v, CONTENT_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_step_statement(v, CONTENT_SELECT_STMT, &s);\n  if( rc!=SQLITE_ROW ) return rc;\n\n  values = (const char **) malloc(v->nColumn * sizeof(const char *));\n  for(i=0; i<v->nColumn; ++i){\n    if( sqlite3_column_type(s, i)==SQLITE_NULL ){\n      values[i] = NULL;\n    }else{\n      values[i] = string_dup((char*)sqlite3_column_text(s, i));\n    }\n  }\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ){\n    *pValues = values;\n    return SQLITE_OK;\n  }\n\n  freeStringArray(v->nColumn, values);\n  return rc;\n}\n\n/* delete from %_content where rowid = [iRow ] */\nstatic int content_delete(fulltext_vtab *v, sqlite_int64 iRow){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, CONTENT_DELETE_STMT, &s);\n}\n\n/* select rowid, doclist from %_term\n *  where term = [pTerm] and segment = [iSegment]\n * If found, returns SQLITE_ROW; the caller must free the\n * returned doclist.  If no rows found, returns SQLITE_DONE. */\nstatic int term_select(fulltext_vtab *v, const char *pTerm, int nTerm,\n                       int iSegment,\n                       sqlite_int64 *rowid, DocList *out){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 1, pTerm, nTerm, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 2, iSegment);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_step_statement(v, TERM_SELECT_STMT, &s);\n  if( rc!=SQLITE_ROW ) return rc;\n\n  *rowid = sqlite3_column_int64(s, 0);\n  docListInit(out, DL_DEFAULT,\n              sqlite3_column_blob(s, 1), sqlite3_column_bytes(s, 1));\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  return rc==SQLITE_DONE ? SQLITE_ROW : rc;\n}\n\n/* Load the segment doclists for term pTerm and merge them in\n** appropriate order into out.  Returns SQLITE_OK if successful.  If\n** there are no segments for pTerm, successfully returns an empty\n** doclist in out.\n**\n** Each document consists of 1 or more \"columns\".  The number of\n** columns is v->nColumn.  If iColumn==v->nColumn, then return\n** position information about all columns.  If iColumn<v->nColumn,\n** then only return position information about the iColumn-th column\n** (where the first column is 0).\n*/\nstatic int term_select_all(\n  fulltext_vtab *v,     /* The fulltext index we are querying against */\n  int iColumn,          /* If <nColumn, only look at the iColumn-th column */\n  const char *pTerm,    /* The term whose posting lists we want */\n  int nTerm,            /* Number of bytes in pTerm */\n  DocList *out          /* Write the resulting doclist here */\n){\n  DocList doclist;\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_SELECT_ALL_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 1, pTerm, nTerm, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  docListInit(&doclist, DL_DEFAULT, 0, 0);\n\n  /* TODO(shess) Handle schema and busy errors. */\n  while( (rc=sql_step_statement(v, TERM_SELECT_ALL_STMT, &s))==SQLITE_ROW ){\n    DocList old;\n\n    /* TODO(shess) If we processed doclists from oldest to newest, we\n    ** could skip the malloc() involved with the following call.  For\n    ** now, I'd rather keep this logic similar to index_insert_term().\n    ** We could additionally drop elements when we see deletes, but\n    ** that would require a distinct version of docListAccumulate().\n    */\n    docListInit(&old, DL_DEFAULT,\n                sqlite3_column_blob(s, 0), sqlite3_column_bytes(s, 0));\n\n    if( iColumn<v->nColumn ){   /* querying a single column */\n      docListRestrictColumn(&old, iColumn);\n    }\n\n    /* doclist contains the newer data, so write it over old.  Then\n    ** steal accumulated result for doclist.\n    */\n    docListAccumulate(&old, &doclist);\n    docListDestroy(&doclist);\n    doclist = old;\n  }\n  if( rc!=SQLITE_DONE ){\n    docListDestroy(&doclist);\n    return rc;\n  }\n\n  docListDiscardEmpty(&doclist);\n  *out = doclist;\n  return SQLITE_OK;\n}\n\n/* insert into %_term (rowid, term, segment, doclist)\n               values ([piRowid], [pTerm], [iSegment], [doclist])\n** Lets sqlite select rowid if piRowid is NULL, else uses *piRowid.\n**\n** NOTE(shess) piRowid is IN, with values of \"space of int64\" plus\n** null, it is not used to pass data back to the caller.\n*/\nstatic int term_insert(fulltext_vtab *v, sqlite_int64 *piRowid,\n                       const char *pTerm, int nTerm,\n                       int iSegment, DocList *doclist){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( piRowid==NULL ){\n    rc = sqlite3_bind_null(s, 1);\n  }else{\n    rc = sqlite3_bind_int64(s, 1, *piRowid);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 2, pTerm, nTerm, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 3, iSegment);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 4, doclist->pData, doclist->nData, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_INSERT_STMT, &s);\n}\n\n/* update %_term set doclist = [doclist] where rowid = [rowid] */\nstatic int term_update(fulltext_vtab *v, sqlite_int64 rowid,\n                       DocList *doclist){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_UPDATE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 1, doclist->pData, doclist->nData, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_UPDATE_STMT, &s);\n}\n\nstatic int term_delete(fulltext_vtab *v, sqlite_int64 rowid){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_DELETE_STMT, &s);\n}\n\n/*\n** Free the memory used to contain a fulltext_vtab structure.\n*/\nstatic void fulltext_vtab_destroy(fulltext_vtab *v){\n  int iStmt, i;\n\n  TRACE((\"FTS1 Destroy %p\\n\", v));\n  for( iStmt=0; iStmt<MAX_STMT; iStmt++ ){\n    if( v->pFulltextStatements[iStmt]!=NULL ){\n      sqlite3_finalize(v->pFulltextStatements[iStmt]);\n      v->pFulltextStatements[iStmt] = NULL;\n    }\n  }\n\n  if( v->pTokenizer!=NULL ){\n    v->pTokenizer->pModule->xDestroy(v->pTokenizer);\n    v->pTokenizer = NULL;\n  }\n  \n  free(v->azColumn);\n  for(i = 0; i < v->nColumn; ++i) {\n    sqlite3_free(v->azContentColumn[i]);\n  }\n  free(v->azContentColumn);\n  free(v);\n}\n\n/*\n** Token types for parsing the arguments to xConnect or xCreate.\n*/\n#define TOKEN_EOF         0    /* End of file */\n#define TOKEN_SPACE       1    /* Any kind of whitespace */\n#define TOKEN_ID          2    /* An identifier */\n#define TOKEN_STRING      3    /* A string literal */\n#define TOKEN_PUNCT       4    /* A single punctuation character */\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identfiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\nstatic const char isIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define IdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))\n\n\n/*\n** Return the length of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nstatic int getToken(const char *z, int *tokenType){\n  int i, c;\n  switch( *z ){\n    case 0: {\n      *tokenType = TOKEN_EOF;\n      return 0;\n    }\n    case ' ': case '\\t': case '\\n': case '\\f': case '\\r': {\n      for(i=1; safe_isspace(z[i]); i++){}\n      *tokenType = TOKEN_SPACE;\n      return i;\n    }\n    case '`':\n    case '\\'':\n    case '\"': {\n      int delim = z[0];\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      *tokenType = TOKEN_STRING;\n      return i + (c!=0);\n    }\n    case '[': {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = TOKEN_ID;\n      return i;\n    }\n    default: {\n      if( !IdChar(*z) ){\n        break;\n      }\n      for(i=1; IdChar(z[i]); i++){}\n      *tokenType = TOKEN_ID;\n      return i;\n    }\n  }\n  *tokenType = TOKEN_PUNCT;\n  return 1;\n}\n\n/*\n** A token extracted from a string is an instance of the following\n** structure.\n*/\ntypedef struct Token {\n  const char *z;       /* Pointer to token text.  Not '\\000' terminated */\n  short int n;         /* Length of the token text in bytes. */\n} Token;\n\n/*\n** Given a input string (which is really one of the argv[] parameters\n** passed into xConnect or xCreate) split the string up into tokens.\n** Return an array of pointers to '\\000' terminated strings, one string\n** for each non-whitespace token.\n**\n** The returned array is terminated by a single NULL pointer.\n**\n** Space to hold the returned array is obtained from a single\n** malloc and should be freed by passing the return value to free().\n** The individual strings within the token list are all a part of\n** the single memory allocation and will all be freed at once.\n*/\nstatic char **tokenizeString(const char *z, int *pnToken){\n  int nToken = 0;\n  Token *aToken = malloc( strlen(z) * sizeof(aToken[0]) );\n  int n = 1;\n  int e, i;\n  int totalSize = 0;\n  char **azToken;\n  char *zCopy;\n  while( n>0 ){\n    n = getToken(z, &e);\n    if( e!=TOKEN_SPACE ){\n      aToken[nToken].z = z;\n      aToken[nToken].n = n;\n      nToken++;\n      totalSize += n+1;\n    }\n    z += n;\n  }\n  azToken = (char**)malloc( nToken*sizeof(char*) + totalSize );\n  zCopy = (char*)&azToken[nToken];\n  nToken--;\n  for(i=0; i<nToken; i++){\n    azToken[i] = zCopy;\n    n = aToken[i].n;\n    memcpy(zCopy, aToken[i].z, n);\n    zCopy[n] = 0;\n    zCopy += n+1;\n  }\n  azToken[nToken] = 0;\n  free(aToken);\n  *pnToken = nToken;\n  return azToken;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic void dequoteString(char *z){\n  int quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  switch( quote ){\n    case '\\'':  break;\n    case '\"':   break;\n    case '`':   break;                /* For MySQL compatibility */\n    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */\n    default:    return;\n  }\n  for(i=1, j=0; z[i]; i++){\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        z[j++] = 0;\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n}\n\n/*\n** The input azIn is a NULL-terminated list of tokens.  Remove the first\n** token and all punctuation tokens.  Remove the quotes from\n** around string literal tokens.\n**\n** Example:\n**\n**     input:      tokenize chinese ( 'simplifed' , 'mixed' )\n**     output:     chinese simplifed mixed\n**\n** Another example:\n**\n**     input:      delimiters ( '[' , ']' , '...' )\n**     output:     [ ] ...\n*/\nstatic void tokenListToIdList(char **azIn){\n  int i, j;\n  if( azIn ){\n    for(i=0, j=-1; azIn[i]; i++){\n      if( safe_isalnum(azIn[i][0]) || azIn[i][1] ){\n        dequoteString(azIn[i]);\n        if( j>=0 ){\n          azIn[j] = azIn[i];\n        }\n        j++;\n      }\n    }\n    azIn[j] = 0;\n  }\n}\n\n\n/*\n** Find the first alphanumeric token in the string zIn.  Null-terminate\n** this token.  Remove any quotation marks.  And return a pointer to\n** the result.\n*/\nstatic char *firstToken(char *zIn, char **pzTail){\n  int n, ttype;\n  while(1){\n    n = getToken(zIn, &ttype);\n    if( ttype==TOKEN_SPACE ){\n      zIn += n;\n    }else if( ttype==TOKEN_EOF ){\n      *pzTail = zIn;\n      return 0;\n    }else{\n      zIn[n] = 0;\n      *pzTail = &zIn[1];\n      dequoteString(zIn);\n      return zIn;\n    }\n  }\n  /*NOTREACHED*/\n}\n\n/* Return true if...\n**\n**   *  s begins with the string t, ignoring case\n**   *  s is longer than t\n**   *  The first character of s beyond t is not a alphanumeric\n** \n** Ignore leading space in *s.\n**\n** To put it another way, return true if the first token of\n** s[] is t[].\n*/\nstatic int startsWith(const char *s, const char *t){\n  while( safe_isspace(*s) ){ s++; }\n  while( *t ){\n    if( safe_tolower(*s++)!=safe_tolower(*t++) ) return 0;\n  }\n  return *s!='_' && !safe_isalnum(*s);\n}\n\n/*\n** An instance of this structure defines the \"spec\" of a\n** full text index.  This structure is populated by parseSpec\n** and use by fulltextConnect and fulltextCreate.\n*/\ntypedef struct TableSpec {\n  const char *zDb;         /* Logical database name */\n  const char *zName;       /* Name of the full-text index */\n  int nColumn;             /* Number of columns to be indexed */\n  char **azColumn;         /* Original names of columns to be indexed */\n  char **azContentColumn;  /* Column names for %_content */\n  char **azTokenizer;      /* Name of tokenizer and its arguments */\n} TableSpec;\n\n/*\n** Reclaim all of the memory used by a TableSpec\n*/\nstatic void clearTableSpec(TableSpec *p) {\n  free(p->azColumn);\n  free(p->azContentColumn);\n  free(p->azTokenizer);\n}\n\n/* Parse a CREATE VIRTUAL TABLE statement, which looks like this:\n *\n * CREATE VIRTUAL TABLE email\n *        USING fts1(subject, body, tokenize mytokenizer(myarg))\n *\n * We return parsed information in a TableSpec structure.\n * \n */\nstatic int parseSpec(TableSpec *pSpec, int argc, const char *const*argv,\n                     char**pzErr){\n  int i, n;\n  char *z, *zDummy;\n  char **azArg;\n  const char *zTokenizer = 0;    /* argv[] entry describing the tokenizer */\n\n  assert( argc>=3 );\n  /* Current interface:\n  ** argv[0] - module name\n  ** argv[1] - database name\n  ** argv[2] - table name\n  ** argv[3..] - columns, optionally followed by tokenizer specification\n  **             and snippet delimiters specification.\n  */\n\n  /* Make a copy of the complete argv[][] array in a single allocation.\n  ** The argv[][] array is read-only and transient.  We can write to the\n  ** copy in order to modify things and the copy is persistent.\n  */\n  memset(pSpec, 0, sizeof(*pSpec));\n  for(i=n=0; i<argc; i++){\n    n += strlen(argv[i]) + 1;\n  }\n  azArg = malloc( sizeof(char*)*argc + n );\n  if( azArg==0 ){\n    return SQLITE_NOMEM;\n  }\n  z = (char*)&azArg[argc];\n  for(i=0; i<argc; i++){\n    azArg[i] = z;\n    strcpy(z, argv[i]);\n    z += strlen(z)+1;\n  }\n\n  /* Identify the column names and the tokenizer and delimiter arguments\n  ** in the argv[][] array.\n  */\n  pSpec->zDb = azArg[1];\n  pSpec->zName = azArg[2];\n  pSpec->nColumn = 0;\n  pSpec->azColumn = azArg;\n  zTokenizer = \"tokenize simple\";\n  for(i=3; i<argc; ++i){\n    if( startsWith(azArg[i],\"tokenize\") ){\n      zTokenizer = azArg[i];\n    }else{\n      z = azArg[pSpec->nColumn] = firstToken(azArg[i], &zDummy);\n      pSpec->nColumn++;\n    }\n  }\n  if( pSpec->nColumn==0 ){\n    azArg[0] = \"content\";\n    pSpec->nColumn = 1;\n  }\n\n  /*\n  ** Construct the list of content column names.\n  **\n  ** Each content column name will be of the form cNNAAAA\n  ** where NN is the column number and AAAA is the sanitized\n  ** column name.  \"sanitized\" means that special characters are\n  ** converted to \"_\".  The cNN prefix guarantees that all column\n  ** names are unique.\n  **\n  ** The AAAA suffix is not strictly necessary.  It is included\n  ** for the convenience of people who might examine the generated\n  ** %_content table and wonder what the columns are used for.\n  */\n  pSpec->azContentColumn = malloc( pSpec->nColumn * sizeof(char *) );\n  if( pSpec->azContentColumn==0 ){\n    clearTableSpec(pSpec);\n    return SQLITE_NOMEM;\n  }\n  for(i=0; i<pSpec->nColumn; i++){\n    char *p;\n    pSpec->azContentColumn[i] = sqlite3_mprintf(\"c%d%s\", i, azArg[i]);\n    for (p = pSpec->azContentColumn[i]; *p ; ++p) {\n      if( !safe_isalnum(*p) ) *p = '_';\n    }\n  }\n\n  /*\n  ** Parse the tokenizer specification string.\n  */\n  pSpec->azTokenizer = tokenizeString(zTokenizer, &n);\n  tokenListToIdList(pSpec->azTokenizer);\n\n  return SQLITE_OK;\n}\n\n/*\n** Generate a CREATE TABLE statement that describes the schema of\n** the virtual table.  Return a pointer to this schema string.\n**\n** Space is obtained from sqlite3_mprintf() and should be freed\n** using sqlite3_free().\n*/\nstatic char *fulltextSchema(\n  int nColumn,                  /* Number of columns */\n  const char *const* azColumn,  /* List of columns */\n  const char *zTableName        /* Name of the table */\n){\n  int i;\n  char *zSchema, *zNext;\n  const char *zSep = \"(\";\n  zSchema = sqlite3_mprintf(\"CREATE TABLE x\");\n  for(i=0; i<nColumn; i++){\n    zNext = sqlite3_mprintf(\"%s%s%Q\", zSchema, zSep, azColumn[i]);\n    sqlite3_free(zSchema);\n    zSchema = zNext;\n    zSep = \",\";\n  }\n  zNext = sqlite3_mprintf(\"%s,%Q)\", zSchema, zTableName);\n  sqlite3_free(zSchema);\n  return zNext;\n}\n\n/*\n** Build a new sqlite3_vtab structure that will describe the\n** fulltext index defined by spec.\n*/\nstatic int constructVtab(\n  sqlite3 *db,              /* The SQLite database connection */\n  TableSpec *spec,          /* Parsed spec information from parseSpec() */\n  sqlite3_vtab **ppVTab,    /* Write the resulting vtab structure here */\n  char **pzErr              /* Write any error message here */\n){\n  int rc;\n  int n;\n  fulltext_vtab *v = 0;\n  const sqlite3_tokenizer_module *m = NULL;\n  char *schema;\n\n  v = (fulltext_vtab *) malloc(sizeof(fulltext_vtab));\n  if( v==0 ) return SQLITE_NOMEM;\n  memset(v, 0, sizeof(*v));\n  /* sqlite will initialize v->base */\n  v->db = db;\n  v->zDb = spec->zDb;       /* Freed when azColumn is freed */\n  v->zName = spec->zName;   /* Freed when azColumn is freed */\n  v->nColumn = spec->nColumn;\n  v->azContentColumn = spec->azContentColumn;\n  spec->azContentColumn = 0;\n  v->azColumn = spec->azColumn;\n  spec->azColumn = 0;\n\n  if( spec->azTokenizer==0 ){\n    return SQLITE_NOMEM;\n  }\n  /* TODO(shess) For now, add new tokenizers as else if clauses. */\n  if( spec->azTokenizer[0]==0 || startsWith(spec->azTokenizer[0], \"simple\") ){\n    sqlite3Fts1SimpleTokenizerModule(&m);\n  }else if( startsWith(spec->azTokenizer[0], \"porter\") ){\n    sqlite3Fts1PorterTokenizerModule(&m);\n  }else{\n    *pzErr = sqlite3_mprintf(\"unknown tokenizer: %s\", spec->azTokenizer[0]);\n    rc = SQLITE_ERROR;\n    goto err;\n  }\n  for(n=0; spec->azTokenizer[n]; n++){}\n  if( n ){\n    rc = m->xCreate(n-1, (const char*const*)&spec->azTokenizer[1],\n                    &v->pTokenizer);\n  }else{\n    rc = m->xCreate(0, 0, &v->pTokenizer);\n  }\n  if( rc!=SQLITE_OK ) goto err;\n  v->pTokenizer->pModule = m;\n\n  /* TODO: verify the existence of backing tables foo_content, foo_term */\n\n  schema = fulltextSchema(v->nColumn, (const char*const*)v->azColumn,\n                          spec->zName);\n  rc = sqlite3_declare_vtab(db, schema);\n  sqlite3_free(schema);\n  if( rc!=SQLITE_OK ) goto err;\n\n  memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements));\n\n  *ppVTab = &v->base;\n  TRACE((\"FTS1 Connect %p\\n\", v));\n\n  return rc;\n\nerr:\n  fulltext_vtab_destroy(v);\n  return rc;\n}\n\nstatic int fulltextConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  TableSpec spec;\n  int rc = parseSpec(&spec, argc, argv, pzErr);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = constructVtab(db, &spec, ppVTab, pzErr);\n  clearTableSpec(&spec);\n  return rc;\n}\n\n  /* The %_content table holds the text of each document, with\n  ** the rowid used as the docid.\n  **\n  ** The %_term table maps each term to a document list blob\n  ** containing elements sorted by ascending docid, each element\n  ** encoded as:\n  **\n  **   docid varint-encoded\n  **   token elements:\n  **     position+1 varint-encoded as delta from previous position\n  **     start offset varint-encoded as delta from previous start offset\n  **     end offset varint-encoded as delta from start offset\n  **\n  ** The sentinel position of 0 indicates the end of the token list.\n  **\n  ** Additionally, doclist blobs are chunked into multiple segments,\n  ** using segment to order the segments.  New elements are added to\n  ** the segment at segment 0, until it exceeds CHUNK_MAX.  Then\n  ** segment 0 is deleted, and the doclist is inserted at segment 1.\n  ** If there is already a doclist at segment 1, the segment 0 doclist\n  ** is merged with it, the segment 1 doclist is deleted, and the\n  ** merged doclist is inserted at segment 2, repeating those\n  ** operations until an insert succeeds.\n  **\n  ** Since this structure doesn't allow us to update elements in place\n  ** in case of deletion or update, these are simply written to\n  ** segment 0 (with an empty token list in case of deletion), with\n  ** docListAccumulate() taking care to retain lower-segment\n  ** information in preference to higher-segment information.\n  */\n  /* TODO(shess) Provide a VACUUM type operation which both removes\n  ** deleted elements which are no longer necessary, and duplicated\n  ** elements.  I suspect this will probably not be necessary in\n  ** practice, though.\n  */\nstatic int fulltextCreate(sqlite3 *db, void *pAux,\n                          int argc, const char * const *argv,\n                          sqlite3_vtab **ppVTab, char **pzErr){\n  int rc;\n  TableSpec spec;\n  StringBuffer schema;\n  TRACE((\"FTS1 Create\\n\"));\n\n  rc = parseSpec(&spec, argc, argv, pzErr);\n  if( rc!=SQLITE_OK ) return rc;\n\n  initStringBuffer(&schema);\n  append(&schema, \"CREATE TABLE %_content(\");\n  appendList(&schema, spec.nColumn, spec.azContentColumn);\n  append(&schema, \")\");\n  rc = sql_exec(db, spec.zDb, spec.zName, schema.s);\n  free(schema.s);\n  if( rc!=SQLITE_OK ) goto out;\n\n  rc = sql_exec(db, spec.zDb, spec.zName,\n    \"create table %_term(term text, segment integer, doclist blob, \"\n                        \"primary key(term, segment));\");\n  if( rc!=SQLITE_OK ) goto out;\n\n  rc = constructVtab(db, &spec, ppVTab, pzErr);\n\nout:\n  clearTableSpec(&spec);\n  return rc;\n}\n\n/* Decide how to handle an SQL query. */\nstatic int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  int i;\n  TRACE((\"FTS1 BestIndex\\n\"));\n\n  for(i=0; i<pInfo->nConstraint; ++i){\n    const struct sqlite3_index_constraint *pConstraint;\n    pConstraint = &pInfo->aConstraint[i];\n    if( pConstraint->usable ) {\n      if( pConstraint->iColumn==-1 &&\n          pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n        pInfo->idxNum = QUERY_ROWID;      /* lookup by rowid */\n        TRACE((\"FTS1 QUERY_ROWID\\n\"));\n      } else if( pConstraint->iColumn>=0 &&\n                 pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n        /* full-text search */\n        pInfo->idxNum = QUERY_FULLTEXT + pConstraint->iColumn;\n        TRACE((\"FTS1 QUERY_FULLTEXT %d\\n\", pConstraint->iColumn));\n      } else continue;\n\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n\n      /* An arbitrary value for now.\n       * TODO: Perhaps rowid matches should be considered cheaper than\n       * full-text searches. */\n      pInfo->estimatedCost = 1.0;   \n\n      return SQLITE_OK;\n    }\n  }\n  pInfo->idxNum = QUERY_GENERIC;\n  return SQLITE_OK;\n}\n\nstatic int fulltextDisconnect(sqlite3_vtab *pVTab){\n  TRACE((\"FTS1 Disconnect %p\\n\", pVTab));\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextDestroy(sqlite3_vtab *pVTab){\n  fulltext_vtab *v = (fulltext_vtab *)pVTab;\n  int rc;\n\n  TRACE((\"FTS1 Destroy %p\\n\", pVTab));\n  rc = sql_exec(v->db, v->zDb, v->zName,\n                \"drop table if exists %_content;\"\n                \"drop table if exists %_term;\"\n                );\n  if( rc!=SQLITE_OK ) return rc;\n\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  fulltext_cursor *c;\n\n  c = (fulltext_cursor *) calloc(sizeof(fulltext_cursor), 1);\n  /* sqlite will initialize c->base */\n  *ppCursor = &c->base;\n  TRACE((\"FTS1 Open %p: %p\\n\", pVTab, c));\n\n  return SQLITE_OK;\n}\n\n\n/* Free all of the dynamically allocated memory held by *q\n*/\nstatic void queryClear(Query *q){\n  int i;\n  for(i = 0; i < q->nTerms; ++i){\n    free(q->pTerms[i].pTerm);\n  }\n  free(q->pTerms);\n  memset(q, 0, sizeof(*q));\n}\n\n/* Free all of the dynamically allocated memory held by the\n** Snippet\n*/\nstatic void snippetClear(Snippet *p){\n  free(p->aMatch);\n  free(p->zOffset);\n  free(p->zSnippet);\n  memset(p, 0, sizeof(*p));\n}\n/*\n** Append a single entry to the p->aMatch[] log.\n*/\nstatic void snippetAppendMatch(\n  Snippet *p,               /* Append the entry to this snippet */\n  int iCol, int iTerm,      /* The column and query term */\n  int iStart, int nByte     /* Offset and size of the match */\n){\n  int i;\n  struct snippetMatch *pMatch;\n  if( p->nMatch+1>=p->nAlloc ){\n    p->nAlloc = p->nAlloc*2 + 10;\n    p->aMatch = realloc(p->aMatch, p->nAlloc*sizeof(p->aMatch[0]) );\n    if( p->aMatch==0 ){\n      p->nMatch = 0;\n      p->nAlloc = 0;\n      return;\n    }\n  }\n  i = p->nMatch++;\n  pMatch = &p->aMatch[i];\n  pMatch->iCol = iCol;\n  pMatch->iTerm = iTerm;\n  pMatch->iStart = iStart;\n  pMatch->nByte = nByte;\n}\n\n/*\n** Sizing information for the circular buffer used in snippetOffsetsOfColumn()\n*/\n#define FTS1_ROTOR_SZ   (32)\n#define FTS1_ROTOR_MASK (FTS1_ROTOR_SZ-1)\n\n/*\n** Add entries to pSnippet->aMatch[] for every match that occurs against\n** document zDoc[0..nDoc-1] which is stored in column iColumn.\n*/\nstatic void snippetOffsetsOfColumn(\n  Query *pQuery,\n  Snippet *pSnippet,\n  int iColumn,\n  const char *zDoc,\n  int nDoc\n){\n  const sqlite3_tokenizer_module *pTModule;  /* The tokenizer module */\n  sqlite3_tokenizer *pTokenizer;             /* The specific tokenizer */\n  sqlite3_tokenizer_cursor *pTCursor;        /* Tokenizer cursor */\n  fulltext_vtab *pVtab;                /* The full text index */\n  int nColumn;                         /* Number of columns in the index */\n  const QueryTerm *aTerm;              /* Query string terms */\n  int nTerm;                           /* Number of query string terms */  \n  int i, j;                            /* Loop counters */\n  int rc;                              /* Return code */\n  unsigned int match, prevMatch;       /* Phrase search bitmasks */\n  const char *zToken;                  /* Next token from the tokenizer */\n  int nToken;                          /* Size of zToken */\n  int iBegin, iEnd, iPos;              /* Offsets of beginning and end */\n\n  /* The following variables keep a circular buffer of the last\n  ** few tokens */\n  unsigned int iRotor = 0;             /* Index of current token */\n  int iRotorBegin[FTS1_ROTOR_SZ];      /* Beginning offset of token */\n  int iRotorLen[FTS1_ROTOR_SZ];        /* Length of token */\n\n  pVtab = pQuery->pFts;\n  nColumn = pVtab->nColumn;\n  pTokenizer = pVtab->pTokenizer;\n  pTModule = pTokenizer->pModule;\n  rc = pTModule->xOpen(pTokenizer, zDoc, nDoc, &pTCursor);\n  if( rc ) return;\n  pTCursor->pTokenizer = pTokenizer;\n  aTerm = pQuery->pTerms;\n  nTerm = pQuery->nTerms;\n  if( nTerm>=FTS1_ROTOR_SZ ){\n    nTerm = FTS1_ROTOR_SZ - 1;\n  }\n  prevMatch = 0;\n  while(1){\n    rc = pTModule->xNext(pTCursor, &zToken, &nToken, &iBegin, &iEnd, &iPos);\n    if( rc ) break;\n    iRotorBegin[iRotor&FTS1_ROTOR_MASK] = iBegin;\n    iRotorLen[iRotor&FTS1_ROTOR_MASK] = iEnd-iBegin;\n    match = 0;\n    for(i=0; i<nTerm; i++){\n      int iCol;\n      iCol = aTerm[i].iColumn;\n      if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;\n      if( aTerm[i].nTerm!=nToken ) continue;\n      if( memcmp(aTerm[i].pTerm, zToken, nToken) ) continue;\n      if( aTerm[i].iPhrase>1 && (prevMatch & (1<<i))==0 ) continue;\n      match |= 1<<i;\n      if( i==nTerm-1 || aTerm[i+1].iPhrase==1 ){\n        for(j=aTerm[i].iPhrase-1; j>=0; j--){\n          int k = (iRotor-j) & FTS1_ROTOR_MASK;\n          snippetAppendMatch(pSnippet, iColumn, i-j,\n                iRotorBegin[k], iRotorLen[k]);\n        }\n      }\n    }\n    prevMatch = match<<1;\n    iRotor++;\n  }\n  pTModule->xClose(pTCursor);  \n}\n\n\n/*\n** Compute all offsets for the current row of the query.  \n** If the offsets have already been computed, this routine is a no-op.\n*/\nstatic void snippetAllOffsets(fulltext_cursor *p){\n  int nColumn;\n  int iColumn, i;\n  int iFirst, iLast;\n  fulltext_vtab *pFts;\n\n  if( p->snippet.nMatch ) return;\n  if( p->q.nTerms==0 ) return;\n  pFts = p->q.pFts;\n  nColumn = pFts->nColumn;\n  iColumn = p->iCursorType - QUERY_FULLTEXT;\n  if( iColumn<0 || iColumn>=nColumn ){\n    iFirst = 0;\n    iLast = nColumn-1;\n  }else{\n    iFirst = iColumn;\n    iLast = iColumn;\n  }\n  for(i=iFirst; i<=iLast; i++){\n    const char *zDoc;\n    int nDoc;\n    zDoc = (const char*)sqlite3_column_text(p->pStmt, i+1);\n    nDoc = sqlite3_column_bytes(p->pStmt, i+1);\n    snippetOffsetsOfColumn(&p->q, &p->snippet, i, zDoc, nDoc);\n  }\n}\n\n/*\n** Convert the information in the aMatch[] array of the snippet\n** into the string zOffset[0..nOffset-1].\n*/\nstatic void snippetOffsetText(Snippet *p){\n  int i;\n  int cnt = 0;\n  StringBuffer sb;\n  char zBuf[200];\n  if( p->zOffset ) return;\n  initStringBuffer(&sb);\n  for(i=0; i<p->nMatch; i++){\n    struct snippetMatch *pMatch = &p->aMatch[i];\n    zBuf[0] = ' ';\n    sqlite3_snprintf(sizeof(zBuf)-1, &zBuf[cnt>0], \"%d %d %d %d\",\n        pMatch->iCol, pMatch->iTerm, pMatch->iStart, pMatch->nByte);\n    append(&sb, zBuf);\n    cnt++;\n  }\n  p->zOffset = sb.s;\n  p->nOffset = sb.len;\n}\n\n/*\n** zDoc[0..nDoc-1] is phrase of text.  aMatch[0..nMatch-1] are a set\n** of matching words some of which might be in zDoc.  zDoc is column\n** number iCol.\n**\n** iBreak is suggested spot in zDoc where we could begin or end an\n** excerpt.  Return a value similar to iBreak but possibly adjusted\n** to be a little left or right so that the break point is better.\n*/\nstatic int wordBoundary(\n  int iBreak,                   /* The suggested break point */\n  const char *zDoc,             /* Document text */\n  int nDoc,                     /* Number of bytes in zDoc[] */\n  struct snippetMatch *aMatch,  /* Matching words */\n  int nMatch,                   /* Number of entries in aMatch[] */\n  int iCol                      /* The column number for zDoc[] */\n){\n  int i;\n  if( iBreak<=10 ){\n    return 0;\n  }\n  if( iBreak>=nDoc-10 ){\n    return nDoc;\n  }\n  for(i=0; i<nMatch && aMatch[i].iCol<iCol; i++){}\n  while( i<nMatch && aMatch[i].iStart+aMatch[i].nByte<iBreak ){ i++; }\n  if( i<nMatch ){\n    if( aMatch[i].iStart<iBreak+10 ){\n      return aMatch[i].iStart;\n    }\n    if( i>0 && aMatch[i-1].iStart+aMatch[i-1].nByte>=iBreak ){\n      return aMatch[i-1].iStart;\n    }\n  }\n  for(i=1; i<=10; i++){\n    if( safe_isspace(zDoc[iBreak-i]) ){\n      return iBreak - i + 1;\n    }\n    if( safe_isspace(zDoc[iBreak+i]) ){\n      return iBreak + i + 1;\n    }\n  }\n  return iBreak;\n}\n\n/*\n** If the StringBuffer does not end in white space, add a single\n** space character to the end.\n*/\nstatic void appendWhiteSpace(StringBuffer *p){\n  if( p->len==0 ) return;\n  if( safe_isspace(p->s[p->len-1]) ) return;\n  append(p, \" \");\n}\n\n/*\n** Remove white space from teh end of the StringBuffer\n*/\nstatic void trimWhiteSpace(StringBuffer *p){\n  while( p->len>0 && safe_isspace(p->s[p->len-1]) ){\n    p->len--;\n  }\n}\n\n\n\n/*\n** Allowed values for Snippet.aMatch[].snStatus\n*/\n#define SNIPPET_IGNORE  0   /* It is ok to omit this match from the snippet */\n#define SNIPPET_DESIRED 1   /* We want to include this match in the snippet */\n\n/*\n** Generate the text of a snippet.\n*/\nstatic void snippetText(\n  fulltext_cursor *pCursor,   /* The cursor we need the snippet for */\n  const char *zStartMark,     /* Markup to appear before each match */\n  const char *zEndMark,       /* Markup to appear after each match */\n  const char *zEllipsis       /* Ellipsis mark */\n){\n  int i, j;\n  struct snippetMatch *aMatch;\n  int nMatch;\n  int nDesired;\n  StringBuffer sb;\n  int tailCol;\n  int tailOffset;\n  int iCol;\n  int nDoc;\n  const char *zDoc;\n  int iStart, iEnd;\n  int tailEllipsis = 0;\n  int iMatch;\n  \n\n  free(pCursor->snippet.zSnippet);\n  pCursor->snippet.zSnippet = 0;\n  aMatch = pCursor->snippet.aMatch;\n  nMatch = pCursor->snippet.nMatch;\n  initStringBuffer(&sb);\n\n  for(i=0; i<nMatch; i++){\n    aMatch[i].snStatus = SNIPPET_IGNORE;\n  }\n  nDesired = 0;\n  for(i=0; i<pCursor->q.nTerms; i++){\n    for(j=0; j<nMatch; j++){\n      if( aMatch[j].iTerm==i ){\n        aMatch[j].snStatus = SNIPPET_DESIRED;\n        nDesired++;\n        break;\n      }\n    }\n  }\n\n  iMatch = 0;\n  tailCol = -1;\n  tailOffset = 0;\n  for(i=0; i<nMatch && nDesired>0; i++){\n    if( aMatch[i].snStatus!=SNIPPET_DESIRED ) continue;\n    nDesired--;\n    iCol = aMatch[i].iCol;\n    zDoc = (const char*)sqlite3_column_text(pCursor->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCursor->pStmt, iCol+1);\n    iStart = aMatch[i].iStart - 40;\n    iStart = wordBoundary(iStart, zDoc, nDoc, aMatch, nMatch, iCol);\n    if( iStart<=10 ){\n      iStart = 0;\n    }\n    if( iCol==tailCol && iStart<=tailOffset+20 ){\n      iStart = tailOffset;\n    }\n    if( (iCol!=tailCol && tailCol>=0) || iStart!=tailOffset ){\n      trimWhiteSpace(&sb);\n      appendWhiteSpace(&sb);\n      append(&sb, zEllipsis);\n      appendWhiteSpace(&sb);\n    }\n    iEnd = aMatch[i].iStart + aMatch[i].nByte + 40;\n    iEnd = wordBoundary(iEnd, zDoc, nDoc, aMatch, nMatch, iCol);\n    if( iEnd>=nDoc-10 ){\n      iEnd = nDoc;\n      tailEllipsis = 0;\n    }else{\n      tailEllipsis = 1;\n    }\n    while( iMatch<nMatch && aMatch[iMatch].iCol<iCol ){ iMatch++; }\n    while( iStart<iEnd ){\n      while( iMatch<nMatch && aMatch[iMatch].iStart<iStart\n             && aMatch[iMatch].iCol<=iCol ){\n        iMatch++;\n      }\n      if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd\n             && aMatch[iMatch].iCol==iCol ){\n        nappend(&sb, &zDoc[iStart], aMatch[iMatch].iStart - iStart);\n        iStart = aMatch[iMatch].iStart;\n        append(&sb, zStartMark);\n        nappend(&sb, &zDoc[iStart], aMatch[iMatch].nByte);\n        append(&sb, zEndMark);\n        iStart += aMatch[iMatch].nByte;\n        for(j=iMatch+1; j<nMatch; j++){\n          if( aMatch[j].iTerm==aMatch[iMatch].iTerm\n              && aMatch[j].snStatus==SNIPPET_DESIRED ){\n            nDesired--;\n            aMatch[j].snStatus = SNIPPET_IGNORE;\n          }\n        }\n      }else{\n        nappend(&sb, &zDoc[iStart], iEnd - iStart);\n        iStart = iEnd;\n      }\n    }\n    tailCol = iCol;\n    tailOffset = iEnd;\n  }\n  trimWhiteSpace(&sb);\n  if( tailEllipsis ){\n    appendWhiteSpace(&sb);\n    append(&sb, zEllipsis);\n  }\n  pCursor->snippet.zSnippet = sb.s;\n  pCursor->snippet.nSnippet = sb.len;  \n}\n\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fulltextClose(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  TRACE((\"FTS1 Close %p\\n\", c));\n  sqlite3_finalize(c->pStmt);\n  queryClear(&c->q);\n  snippetClear(&c->snippet);\n  if( c->result.pDoclist!=NULL ){\n    docListDelete(c->result.pDoclist);\n  }\n  free(c);\n  return SQLITE_OK;\n}\n\nstatic int fulltextNext(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  sqlite_int64 iDocid;\n  int rc;\n\n  TRACE((\"FTS1 Next %p\\n\", pCursor));\n  snippetClear(&c->snippet);\n  if( c->iCursorType < QUERY_FULLTEXT ){\n    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n    rc = sqlite3_step(c->pStmt);\n    switch( rc ){\n      case SQLITE_ROW:\n        c->eof = 0;\n        return SQLITE_OK;\n      case SQLITE_DONE:\n        c->eof = 1;\n        return SQLITE_OK;\n      default:\n        c->eof = 1;\n        return rc;\n    }\n  } else {  /* full-text query */\n    rc = sqlite3_reset(c->pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n\n    iDocid = nextDocid(&c->result);\n    if( iDocid==0 ){\n      c->eof = 1;\n      return SQLITE_OK;\n    }\n    rc = sqlite3_bind_int64(c->pStmt, 1, iDocid);\n    if( rc!=SQLITE_OK ) return rc;\n    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n    rc = sqlite3_step(c->pStmt);\n    if( rc==SQLITE_ROW ){   /* the case we expect */\n      c->eof = 0;\n      return SQLITE_OK;\n    }\n    /* an error occurred; abort */\n    return rc==SQLITE_DONE ? SQLITE_ERROR : rc;\n  }\n}\n\n\n/* Return a DocList corresponding to the query term *pTerm.  If *pTerm\n** is the first term of a phrase query, go ahead and evaluate the phrase\n** query and return the doclist for the entire phrase query.\n**\n** The result is stored in pTerm->doclist.\n*/\nstatic int docListOfTerm(\n  fulltext_vtab *v,     /* The full text index */\n  int iColumn,          /* column to restrict to.  No restrition if >=nColumn */\n  QueryTerm *pQTerm,    /* Term we are looking for, or 1st term of a phrase */\n  DocList **ppResult    /* Write the result here */\n){\n  DocList *pLeft, *pRight, *pNew;\n  int i, rc;\n\n  pLeft = docListNew(DL_POSITIONS);\n  rc = term_select_all(v, iColumn, pQTerm->pTerm, pQTerm->nTerm, pLeft);\n  if( rc ){\n    docListDelete(pLeft);\n    return rc;\n  }\n  for(i=1; i<=pQTerm->nPhrase; i++){\n    pRight = docListNew(DL_POSITIONS);\n    rc = term_select_all(v, iColumn, pQTerm[i].pTerm, pQTerm[i].nTerm, pRight);\n    if( rc ){\n      docListDelete(pLeft);\n      return rc;\n    }\n    pNew = docListNew(i<pQTerm->nPhrase ? DL_POSITIONS : DL_DOCIDS);\n    docListPhraseMerge(pLeft, pRight, pNew);\n    docListDelete(pLeft);\n    docListDelete(pRight);\n    pLeft = pNew;\n  }\n  *ppResult = pLeft;\n  return SQLITE_OK;\n}\n\n/* Add a new term pTerm[0..nTerm-1] to the query *q.\n*/\nstatic void queryAdd(Query *q, const char *pTerm, int nTerm){\n  QueryTerm *t;\n  ++q->nTerms;\n  q->pTerms = realloc(q->pTerms, q->nTerms * sizeof(q->pTerms[0]));\n  if( q->pTerms==0 ){\n    q->nTerms = 0;\n    return;\n  }\n  t = &q->pTerms[q->nTerms - 1];\n  memset(t, 0, sizeof(*t));\n  t->pTerm = malloc(nTerm+1);\n  memcpy(t->pTerm, pTerm, nTerm);\n  t->pTerm[nTerm] = 0;\n  t->nTerm = nTerm;\n  t->isOr = q->nextIsOr;\n  q->nextIsOr = 0;\n  t->iColumn = q->nextColumn;\n  q->nextColumn = q->dfltColumn;\n}\n\n/*\n** Check to see if the string zToken[0...nToken-1] matches any\n** column name in the virtual table.   If it does,\n** return the zero-indexed column number.  If not, return -1.\n*/\nstatic int checkColumnSpecifier(\n  fulltext_vtab *pVtab,    /* The virtual table */\n  const char *zToken,      /* Text of the token */\n  int nToken               /* Number of characters in the token */\n){\n  int i;\n  for(i=0; i<pVtab->nColumn; i++){\n    if( memcmp(pVtab->azColumn[i], zToken, nToken)==0\n        && pVtab->azColumn[i][nToken]==0 ){\n      return i;\n    }\n  }\n  return -1;\n}\n\n/*\n** Parse the text at pSegment[0..nSegment-1].  Add additional terms\n** to the query being assemblied in pQuery.\n**\n** inPhrase is true if pSegment[0..nSegement-1] is contained within\n** double-quotes.  If inPhrase is true, then the first term\n** is marked with the number of terms in the phrase less one and\n** OR and \"-\" syntax is ignored.  If inPhrase is false, then every\n** term found is marked with nPhrase=0 and OR and \"-\" syntax is significant.\n*/\nstatic int tokenizeSegment(\n  sqlite3_tokenizer *pTokenizer,          /* The tokenizer to use */\n  const char *pSegment, int nSegment,     /* Query expression being parsed */\n  int inPhrase,                           /* True if within \"...\" */\n  Query *pQuery                           /* Append results here */\n){\n  const sqlite3_tokenizer_module *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCursor;\n  int firstIndex = pQuery->nTerms;\n  int iCol;\n  int nTerm = 1;\n  \n  int rc = pModule->xOpen(pTokenizer, pSegment, nSegment, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n  pCursor->pTokenizer = pTokenizer;\n\n  while( 1 ){\n    const char *pToken;\n    int nToken, iBegin, iEnd, iPos;\n\n    rc = pModule->xNext(pCursor,\n                        &pToken, &nToken,\n                        &iBegin, &iEnd, &iPos);\n    if( rc!=SQLITE_OK ) break;\n    if( !inPhrase &&\n        pSegment[iEnd]==':' &&\n         (iCol = checkColumnSpecifier(pQuery->pFts, pToken, nToken))>=0 ){\n      pQuery->nextColumn = iCol;\n      continue;\n    }\n    if( !inPhrase && pQuery->nTerms>0 && nToken==2\n         && pSegment[iBegin]=='O' && pSegment[iBegin+1]=='R' ){\n      pQuery->nextIsOr = 1;\n      continue;\n    }\n    queryAdd(pQuery, pToken, nToken);\n    if( !inPhrase && iBegin>0 && pSegment[iBegin-1]=='-' ){\n      pQuery->pTerms[pQuery->nTerms-1].isNot = 1;\n    }\n    pQuery->pTerms[pQuery->nTerms-1].iPhrase = nTerm;\n    if( inPhrase ){\n      nTerm++;\n    }\n  }\n\n  if( inPhrase && pQuery->nTerms>firstIndex ){\n    pQuery->pTerms[firstIndex].nPhrase = pQuery->nTerms - firstIndex - 1;\n  }\n\n  return pModule->xClose(pCursor);\n}\n\n/* Parse a query string, yielding a Query object pQuery.\n**\n** The calling function will need to queryClear() to clean up\n** the dynamically allocated memory held by pQuery.\n*/\nstatic int parseQuery(\n  fulltext_vtab *v,        /* The fulltext index */\n  const char *zInput,      /* Input text of the query string */\n  int nInput,              /* Size of the input text */\n  int dfltColumn,          /* Default column of the index to match against */\n  Query *pQuery            /* Write the parse results here. */\n){\n  int iInput, inPhrase = 0;\n\n  if( zInput==0 ) nInput = 0;\n  if( nInput<0 ) nInput = strlen(zInput);\n  pQuery->nTerms = 0;\n  pQuery->pTerms = NULL;\n  pQuery->nextIsOr = 0;\n  pQuery->nextColumn = dfltColumn;\n  pQuery->dfltColumn = dfltColumn;\n  pQuery->pFts = v;\n\n  for(iInput=0; iInput<nInput; ++iInput){\n    int i;\n    for(i=iInput; i<nInput && zInput[i]!='\"'; ++i){}\n    if( i>iInput ){\n      tokenizeSegment(v->pTokenizer, zInput+iInput, i-iInput, inPhrase,\n                       pQuery);\n    }\n    iInput = i;\n    if( i<nInput ){\n      assert( zInput[i]=='\"' );\n      inPhrase = !inPhrase;\n    }\n  }\n\n  if( inPhrase ){\n    /* unmatched quote */\n    queryClear(pQuery);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/* Perform a full-text query using the search expression in\n** zInput[0..nInput-1].  Return a list of matching documents\n** in pResult.\n**\n** Queries must match column iColumn.  Or if iColumn>=nColumn\n** they are allowed to match against any column.\n*/\nstatic int fulltextQuery(\n  fulltext_vtab *v,      /* The full text index */\n  int iColumn,           /* Match against this column by default */\n  const char *zInput,    /* The query string */\n  int nInput,            /* Number of bytes in zInput[] */\n  DocList **pResult,     /* Write the result doclist here */\n  Query *pQuery          /* Put parsed query string here */\n){\n  int i, iNext, rc;\n  DocList *pLeft = NULL;\n  DocList *pRight, *pNew, *pOr;\n  int nNot = 0;\n  QueryTerm *aTerm;\n\n  rc = parseQuery(v, zInput, nInput, iColumn, pQuery);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Merge AND terms. */\n  aTerm = pQuery->pTerms;\n  for(i = 0; i<pQuery->nTerms; i=iNext){\n    if( aTerm[i].isNot ){\n      /* Handle all NOT terms in a separate pass */\n      nNot++;\n      iNext = i + aTerm[i].nPhrase+1;\n      continue;\n    }\n    iNext = i + aTerm[i].nPhrase + 1;\n    rc = docListOfTerm(v, aTerm[i].iColumn, &aTerm[i], &pRight);\n    if( rc ){\n      queryClear(pQuery);\n      return rc;\n    }\n    while( iNext<pQuery->nTerms && aTerm[iNext].isOr ){\n      rc = docListOfTerm(v, aTerm[iNext].iColumn, &aTerm[iNext], &pOr);\n      iNext += aTerm[iNext].nPhrase + 1;\n      if( rc ){\n        queryClear(pQuery);\n        return rc;\n      }\n      pNew = docListNew(DL_DOCIDS);\n      docListOrMerge(pRight, pOr, pNew);\n      docListDelete(pRight);\n      docListDelete(pOr);\n      pRight = pNew;\n    }\n    if( pLeft==0 ){\n      pLeft = pRight;\n    }else{\n      pNew = docListNew(DL_DOCIDS);\n      docListAndMerge(pLeft, pRight, pNew);\n      docListDelete(pRight);\n      docListDelete(pLeft);\n      pLeft = pNew;\n    }\n  }\n\n  if( nNot && pLeft==0 ){\n    /* We do not yet know how to handle a query of only NOT terms */\n    return SQLITE_ERROR;\n  }\n\n  /* Do the EXCEPT terms */\n  for(i=0; i<pQuery->nTerms;  i += aTerm[i].nPhrase + 1){\n    if( !aTerm[i].isNot ) continue;\n    rc = docListOfTerm(v, aTerm[i].iColumn, &aTerm[i], &pRight);\n    if( rc ){\n      queryClear(pQuery);\n      docListDelete(pLeft);\n      return rc;\n    }\n    pNew = docListNew(DL_DOCIDS);\n    docListExceptMerge(pLeft, pRight, pNew);\n    docListDelete(pRight);\n    docListDelete(pLeft);\n    pLeft = pNew;\n  }\n\n  *pResult = pLeft;\n  return rc;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==QUERY_GENERIC then do a full table scan against\n** the %_content table.\n**\n** If idxNum==QUERY_ROWID then do a rowid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=QUERY_FULLTEXT then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-QUERY_FULLTEXT, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\n/* TODO(shess) Upgrade the cursor initialization and destruction to\n** account for fulltextFilter() being called multiple times on the\n** same cursor.  The current solution is very fragile.  Apply fix to\n** fts2 as appropriate.\n*/\nstatic int fulltextFilter(\n  sqlite3_vtab_cursor *pCursor,     /* The cursor used for this query */\n  int idxNum, const char *idxStr,   /* Which indexing scheme to use */\n  int argc, sqlite3_value **argv    /* Arguments for the indexing scheme */\n){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  fulltext_vtab *v = cursor_vtab(c);\n  int rc;\n  char *zSql;\n\n  TRACE((\"FTS1 Filter %p\\n\",pCursor));\n\n  zSql = sqlite3_mprintf(\"select rowid, * from %%_content %s\",\n                          idxNum==QUERY_GENERIC ? \"\" : \"where rowid=?\");\n  sqlite3_finalize(c->pStmt);\n  rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt, zSql);\n  sqlite3_free(zSql);\n  if( rc!=SQLITE_OK ) return rc;\n\n  c->iCursorType = idxNum;\n  switch( idxNum ){\n    case QUERY_GENERIC:\n      break;\n\n    case QUERY_ROWID:\n      rc = sqlite3_bind_int64(c->pStmt, 1, sqlite3_value_int64(argv[0]));\n      if( rc!=SQLITE_OK ) return rc;\n      break;\n\n    default:   /* full-text search */\n    {\n      const char *zQuery = (const char *)sqlite3_value_text(argv[0]);\n      DocList *pResult;\n      assert( idxNum<=QUERY_FULLTEXT+v->nColumn);\n      assert( argc==1 );\n      queryClear(&c->q);\n      rc = fulltextQuery(v, idxNum-QUERY_FULLTEXT, zQuery, -1, &pResult, &c->q);\n      if( rc!=SQLITE_OK ) return rc;\n      if( c->result.pDoclist!=NULL ) docListDelete(c->result.pDoclist);\n      readerInit(&c->result, pResult);\n      break;\n    }\n  }\n\n  return fulltextNext(pCursor);\n}\n\n/* This is the xEof method of the virtual table.  The SQLite core\n** calls this routine to find out if it has reached the end of\n** a query's results set.\n*/\nstatic int fulltextEof(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  return c->eof;\n}\n\n/* This is the xColumn method of the virtual table.  The SQLite\n** core calls this method during a query when it needs the value\n** of a column from the virtual table.  This method needs to use\n** one of the sqlite3_result_*() routines to store the requested\n** value back in the pContext.\n*/\nstatic int fulltextColumn(sqlite3_vtab_cursor *pCursor,\n                          sqlite3_context *pContext, int idxCol){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  fulltext_vtab *v = cursor_vtab(c);\n\n  if( idxCol<v->nColumn ){\n    sqlite3_value *pVal = sqlite3_column_value(c->pStmt, idxCol+1);\n    sqlite3_result_value(pContext, pVal);\n  }else if( idxCol==v->nColumn ){\n    /* The extra column whose name is the same as the table.\n    ** Return a blob which is a pointer to the cursor\n    */\n    sqlite3_result_blob(pContext, &c, sizeof(c), SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\n/* This is the xRowid method.  The SQLite core calls this routine to\n** retrive the rowid for the current row of the result set.  The\n** rowid should be written to *pRowid.\n*/\nstatic int fulltextRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n\n  *pRowid = sqlite3_column_int64(c->pStmt, 0);\n  return SQLITE_OK;\n}\n\n/* Add all terms in [zText] to the given hash table.  If [iColumn] > 0,\n * we also store positions and offsets in the hash table using the given\n * column number. */\nstatic int buildTerms(fulltext_vtab *v, fts1Hash *terms, sqlite_int64 iDocid,\n                      const char *zText, int iColumn){\n  sqlite3_tokenizer *pTokenizer = v->pTokenizer;\n  sqlite3_tokenizer_cursor *pCursor;\n  const char *pToken;\n  int nTokenBytes;\n  int iStartOffset, iEndOffset, iPosition;\n  int rc;\n\n  rc = pTokenizer->pModule->xOpen(pTokenizer, zText, -1, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pCursor->pTokenizer = pTokenizer;\n  while( SQLITE_OK==pTokenizer->pModule->xNext(pCursor,\n                                               &pToken, &nTokenBytes,\n                                               &iStartOffset, &iEndOffset,\n                                               &iPosition) ){\n    DocList *p;\n\n    /* Positions can't be negative; we use -1 as a terminator internally. */\n    if( iPosition<0 ){\n      pTokenizer->pModule->xClose(pCursor);\n      return SQLITE_ERROR;\n    }\n\n    p = fts1HashFind(terms, pToken, nTokenBytes);\n    if( p==NULL ){\n      p = docListNew(DL_DEFAULT);\n      docListAddDocid(p, iDocid);\n      fts1HashInsert(terms, pToken, nTokenBytes, p);\n    }\n    if( iColumn>=0 ){\n      docListAddPosOffset(p, iColumn, iPosition, iStartOffset, iEndOffset);\n    }\n  }\n\n  /* TODO(shess) Check return?  Should this be able to cause errors at\n  ** this point?  Actually, same question about sqlite3_finalize(),\n  ** though one could argue that failure there means that the data is\n  ** not durable.  *ponder*\n  */\n  pTokenizer->pModule->xClose(pCursor);\n  return rc;\n}\n\n/* Update the %_terms table to map the term [pTerm] to the given rowid. */\nstatic int index_insert_term(fulltext_vtab *v, const char *pTerm, int nTerm,\n                             DocList *d){\n  sqlite_int64 iIndexRow;\n  DocList doclist;\n  int iSegment = 0, rc;\n\n  rc = term_select(v, pTerm, nTerm, iSegment, &iIndexRow, &doclist);\n  if( rc==SQLITE_DONE ){\n    docListInit(&doclist, DL_DEFAULT, 0, 0);\n    docListUpdate(&doclist, d);\n    /* TODO(shess) Consider length(doclist)>CHUNK_MAX? */\n    rc = term_insert(v, NULL, pTerm, nTerm, iSegment, &doclist);\n    goto err;\n  }\n  if( rc!=SQLITE_ROW ) return SQLITE_ERROR;\n\n  docListUpdate(&doclist, d);\n  if( doclist.nData<=CHUNK_MAX ){\n    rc = term_update(v, iIndexRow, &doclist);\n    goto err;\n  }\n\n  /* Doclist doesn't fit, delete what's there, and accumulate\n  ** forward.\n  */\n  rc = term_delete(v, iIndexRow);\n  if( rc!=SQLITE_OK ) goto err;\n\n  /* Try to insert the doclist into a higher segment bucket.  On\n  ** failure, accumulate existing doclist with the doclist from that\n  ** bucket, and put results in the next bucket.\n  */\n  iSegment++;\n  while( (rc=term_insert(v, &iIndexRow, pTerm, nTerm, iSegment,\n                         &doclist))!=SQLITE_OK ){\n    sqlite_int64 iSegmentRow;\n    DocList old;\n    int rc2;\n\n    /* Retain old error in case the term_insert() error was really an\n    ** error rather than a bounced insert.\n    */\n    rc2 = term_select(v, pTerm, nTerm, iSegment, &iSegmentRow, &old);\n    if( rc2!=SQLITE_ROW ) goto err;\n\n    rc = term_delete(v, iSegmentRow);\n    if( rc!=SQLITE_OK ) goto err;\n\n    /* Reusing lowest-number deleted row keeps the index smaller. */\n    if( iSegmentRow<iIndexRow ) iIndexRow = iSegmentRow;\n\n    /* doclist contains the newer data, so accumulate it over old.\n    ** Then steal accumulated data for doclist.\n    */\n    docListAccumulate(&old, &doclist);\n    docListDestroy(&doclist);\n    doclist = old;\n\n    iSegment++;\n  }\n\n err:\n  docListDestroy(&doclist);\n  return rc;\n}\n\n/* Add doclists for all terms in [pValues] to the hash table [terms]. */\nstatic int insertTerms(fulltext_vtab *v, fts1Hash *terms, sqlite_int64 iRowid,\n                sqlite3_value **pValues){\n  int i;\n  for(i = 0; i < v->nColumn ; ++i){\n    char *zText = (char*)sqlite3_value_text(pValues[i]);\n    int rc = buildTerms(v, terms, iRowid, zText, i);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  return SQLITE_OK;\n}\n\n/* Add empty doclists for all terms in the given row's content to the hash\n * table [pTerms]. */\nstatic int deleteTerms(fulltext_vtab *v, fts1Hash *pTerms, sqlite_int64 iRowid){\n  const char **pValues;\n  int i;\n\n  int rc = content_select(v, iRowid, &pValues);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i = 0 ; i < v->nColumn; ++i) {\n    rc = buildTerms(v, pTerms, iRowid, pValues[i], -1);\n    if( rc!=SQLITE_OK ) break;\n  }\n\n  freeStringArray(v->nColumn, pValues);\n  return SQLITE_OK;\n}\n\n/* Insert a row into the %_content table; set *piRowid to be the ID of the\n * new row.  Fill [pTerms] with new doclists for the %_term table. */\nstatic int index_insert(fulltext_vtab *v, sqlite3_value *pRequestRowid,\n                        sqlite3_value **pValues,\n                        sqlite_int64 *piRowid, fts1Hash *pTerms){\n  int rc;\n\n  rc = content_insert(v, pRequestRowid, pValues);  /* execute an SQL INSERT */\n  if( rc!=SQLITE_OK ) return rc;\n  *piRowid = sqlite3_last_insert_rowid(v->db);\n  return insertTerms(v, pTerms, *piRowid, pValues);\n}\n\n/* Delete a row from the %_content table; fill [pTerms] with empty doclists\n * to be written to the %_term table. */\nstatic int index_delete(fulltext_vtab *v, sqlite_int64 iRow, fts1Hash *pTerms){\n  int rc = deleteTerms(v, pTerms, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n  return content_delete(v, iRow);  /* execute an SQL DELETE */\n}\n\n/* Update a row in the %_content table; fill [pTerms] with new doclists for the\n * %_term table. */\nstatic int index_update(fulltext_vtab *v, sqlite_int64 iRow,\n                        sqlite3_value **pValues, fts1Hash *pTerms){\n  /* Generate an empty doclist for each term that previously appeared in this\n   * row. */\n  int rc = deleteTerms(v, pTerms, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = content_update(v, pValues, iRow);  /* execute an SQL UPDATE */\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Now add positions for terms which appear in the updated row. */\n  return insertTerms(v, pTerms, iRow, pValues);\n}\n\n/* This function implements the xUpdate callback; it is the top-level entry\n * point for inserting, deleting or updating a row in a full-text table. */\nstatic int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,\n                   sqlite_int64 *pRowid){\n  fulltext_vtab *v = (fulltext_vtab *) pVtab;\n  fts1Hash terms;   /* maps term string -> PosList */\n  int rc;\n  fts1HashElem *e;\n\n  TRACE((\"FTS1 Update %p\\n\", pVtab));\n  \n  fts1HashInit(&terms, FTS1_HASH_STRING, 1);\n\n  if( nArg<2 ){\n    rc = index_delete(v, sqlite3_value_int64(ppArg[0]), &terms);\n  } else if( sqlite3_value_type(ppArg[0]) != SQLITE_NULL ){\n    /* An update:\n     * ppArg[0] = old rowid\n     * ppArg[1] = new rowid\n     * ppArg[2..2+v->nColumn-1] = values\n     * ppArg[2+v->nColumn] = value for magic column (we ignore this)\n     */\n    sqlite_int64 rowid = sqlite3_value_int64(ppArg[0]);\n    if( sqlite3_value_type(ppArg[1]) != SQLITE_INTEGER ||\n      sqlite3_value_int64(ppArg[1]) != rowid ){\n      rc = SQLITE_ERROR;  /* we don't allow changing the rowid */\n    } else {\n      assert( nArg==2+v->nColumn+1);\n      rc = index_update(v, rowid, &ppArg[2], &terms);\n    }\n  } else {\n    /* An insert:\n     * ppArg[1] = requested rowid\n     * ppArg[2..2+v->nColumn-1] = values\n     * ppArg[2+v->nColumn] = value for magic column (we ignore this)\n     */\n    assert( nArg==2+v->nColumn+1);\n    rc = index_insert(v, ppArg[1], &ppArg[2], pRowid, &terms);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* Write updated doclists to disk. */\n    for(e=fts1HashFirst(&terms); e; e=fts1HashNext(e)){\n      DocList *p = fts1HashData(e);\n      rc = index_insert_term(v, fts1HashKey(e), fts1HashKeysize(e), p);\n      if( rc!=SQLITE_OK ) break;\n    }\n  }\n\n  /* clean up */\n  for(e=fts1HashFirst(&terms); e; e=fts1HashNext(e)){\n    DocList *p = fts1HashData(e);\n    docListDelete(p);\n  }\n  fts1HashClear(&terms);\n\n  return rc;\n}\n\n/*\n** Implementation of the snippet() function for FTS1\n*/\nstatic void snippetFunc(\n  sqlite3_context *pContext,\n  int argc,\n  sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc<1 ) return;\n  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    sqlite3_result_error(pContext, \"illegal first argument to html_snippet\",-1);\n  }else{\n    const char *zStart = \"<b>\";\n    const char *zEnd = \"</b>\";\n    const char *zEllipsis = \"<b>...</b>\";\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    if( argc>=2 ){\n      zStart = (const char*)sqlite3_value_text(argv[1]);\n      if( argc>=3 ){\n        zEnd = (const char*)sqlite3_value_text(argv[2]);\n        if( argc>=4 ){\n          zEllipsis = (const char*)sqlite3_value_text(argv[3]);\n        }\n      }\n    }\n    snippetAllOffsets(pCursor);\n    snippetText(pCursor, zStart, zEnd, zEllipsis);\n    sqlite3_result_text(pContext, pCursor->snippet.zSnippet,\n                        pCursor->snippet.nSnippet, SQLITE_STATIC);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS1\n*/\nstatic void snippetOffsetsFunc(\n  sqlite3_context *pContext,\n  int argc,\n  sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc<1 ) return;\n  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    sqlite3_result_error(pContext, \"illegal first argument to offsets\",-1);\n  }else{\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    snippetAllOffsets(pCursor);\n    snippetOffsetText(&pCursor->snippet);\n    sqlite3_result_text(pContext,\n                        pCursor->snippet.zOffset, pCursor->snippet.nOffset,\n                        SQLITE_STATIC);\n  }\n}\n\n/*\n** This routine implements the xFindFunction method for the FTS1\n** virtual table.\n*/\nstatic int fulltextFindFunction(\n  sqlite3_vtab *pVtab,\n  int nArg,\n  const char *zName,\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n  void **ppArg\n){\n  if( strcmp(zName,\"snippet\")==0 ){\n    *pxFunc = snippetFunc;\n    return 1;\n  }else if( strcmp(zName,\"offsets\")==0 ){\n    *pxFunc = snippetOffsetsFunc;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Rename an fts1 table.\n*/\nstatic int fulltextRename(\n  sqlite3_vtab *pVtab,\n  const char *zName\n){\n  fulltext_vtab *p = (fulltext_vtab *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\"\n    \"ALTER TABLE %Q.'%q_term' RENAME TO '%q_term';\"\n    , p->zDb, p->zName, zName\n    , p->zDb, p->zName, zName\n  );\n  if( zSql ){\n    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\nstatic const sqlite3_module fulltextModule = {\n  /* iVersion      */ 0,\n  /* xCreate       */ fulltextCreate,\n  /* xConnect      */ fulltextConnect,\n  /* xBestIndex    */ fulltextBestIndex,\n  /* xDisconnect   */ fulltextDisconnect,\n  /* xDestroy      */ fulltextDestroy,\n  /* xOpen         */ fulltextOpen,\n  /* xClose        */ fulltextClose,\n  /* xFilter       */ fulltextFilter,\n  /* xNext         */ fulltextNext,\n  /* xEof          */ fulltextEof,\n  /* xColumn       */ fulltextColumn,\n  /* xRowid        */ fulltextRowid,\n  /* xUpdate       */ fulltextUpdate,\n  /* xBegin        */ 0, \n  /* xSync         */ 0,\n  /* xCommit       */ 0,\n  /* xRollback     */ 0,\n  /* xFindFunction */ fulltextFindFunction,\n  /* xRename       */ fulltextRename,\n};\n\nint sqlite3Fts1Init(sqlite3 *db){\n  sqlite3_overload_function(db, \"snippet\", -1);\n  sqlite3_overload_function(db, \"offsets\", -1);\n  return sqlite3_create_module(db, \"fts1\", &fulltextModule, 0);\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fts1_init(sqlite3 *db, char **pzErrMsg,\n                      const sqlite3_api_routines *pApi){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts1Init(db);\n}\n#endif\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1.h",
    "content": "#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint sqlite3Fts1Init(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1_hash.c",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n#include <assert.h>\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS1 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS1 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS1 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1)\n\n\n#include \"fts1_hash.h\"\n\nstatic void *malloc_and_zero(int n){\n  void *p = malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS1_HASH_BINARY or FTS1_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nvoid sqlite3Fts1HashInit(fts1Hash *pNew, int keyClass, int copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS1_HASH_STRING && keyClass<=FTS1_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n  pNew->xMalloc = malloc_and_zero;\n  pNew->xFree = free;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nvoid sqlite3Fts1HashClear(fts1Hash *pH){\n  fts1HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  if( pH->ht ) pH->xFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    fts1HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      pH->xFree(elem->pKey);\n    }\n    pH->xFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS1_HASH_STRING\n*/\nstatic int strHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  int h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return h & 0x7fffffff;\n}\nstatic int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS1_HASH_BINARY\n*/\nstatic int binHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"hashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of hashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of hashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*hashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS1_HASH_STRING ){\n    return &strHash;\n  }else{\n    assert( keyClass==FTS1_HASH_BINARY );\n    return &binHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*compareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS1_HASH_STRING ){\n    return &strCompare;\n  }else{\n    assert( keyClass==FTS1_HASH_BINARY );\n    return &binCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void insertElement(\n  fts1Hash *pH,            /* The complete hash table */\n  struct _fts1ht *pEntry,  /* The entry into which pNew is inserted */\n  fts1HashElem *pNew       /* The element to be inserted */\n){\n  fts1HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n*/\nstatic void rehash(fts1Hash *pH, int new_size){\n  struct _fts1ht *new_ht;          /* The new hash table */\n  fts1HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts1ht *)pH->xMalloc( new_size*sizeof(struct _fts1ht) );\n  if( new_ht==0 ) return;\n  if( pH->ht ) pH->xFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = hashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic fts1HashElem *findElementGivenHash(\n  const fts1Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  fts1HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts1ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = compareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  fts1Hash *pH,         /* The pH containing \"elem\" */\n  fts1HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts1ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    pH->xFree(elem->pKey);\n  }\n  pH->xFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts1HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nvoid *sqlite3Fts1HashFind(const fts1Hash *pH, const void *pKey, int nKey){\n  int h;                 /* A hash on key */\n  fts1HashElem *elem;    /* The element that matches key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1));\n  return elem ? elem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nvoid *sqlite3Fts1HashInsert(\n  fts1Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  fts1HashElem *elem;       /* Used to loop thru the element list */\n  fts1HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = findElementGivenHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (fts1HashElem*)pH->xMalloc( sizeof(fts1HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = pH->xMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      pH->xFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  if( pH->htsize==0 ){\n    rehash(pH,8);\n    if( pH->htsize==0 ){\n      pH->count = 0;\n      pH->xFree(new_elem);\n      return data;\n    }\n  }\n  if( pH->count > pH->htsize ){\n    rehash(pH,pH->htsize*2);\n  }\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  insertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1_hash.h",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS1_HASH_H_\n#define _FTS1_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct fts1Hash fts1Hash;\ntypedef struct fts1HashElem fts1HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct fts1Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  fts1HashElem *first;    /* The first element of the array */\n  void *(*xMalloc)(int);  /* malloc() function to use */\n  void (*xFree)(void *);  /* free() function to use */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts1ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    fts1HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct fts1HashElem {\n  fts1HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS1_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS1_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts1HashInit is 1.  \n*/\n#define FTS1_HASH_STRING    1\n#define FTS1_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nvoid sqlite3Fts1HashInit(fts1Hash*, int keytype, int copyKey);\nvoid *sqlite3Fts1HashInsert(fts1Hash*, const void *pKey, int nKey, void *pData);\nvoid *sqlite3Fts1HashFind(const fts1Hash*, const void *pKey, int nKey);\nvoid sqlite3Fts1HashClear(fts1Hash*);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts1HashInit   sqlite3Fts1HashInit\n#define fts1HashInsert sqlite3Fts1HashInsert\n#define fts1HashFind   sqlite3Fts1HashFind\n#define fts1HashClear  sqlite3Fts1HashClear\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   fts1Hash h;\n**   fts1HashElem *p;\n**   ...\n**   for(p=fts1HashFirst(&h); p; p=fts1HashNext(p)){\n**     SomeStructure *pData = fts1HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts1HashFirst(H)  ((H)->first)\n#define fts1HashNext(E)   ((E)->next)\n#define fts1HashData(E)   ((E)->data)\n#define fts1HashKey(E)    ((E)->pKey)\n#define fts1HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts1HashCount(H)  ((H)->count)\n\n#endif /* _FTS1_HASH_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1_porter.c",
    "content": "/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS1 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS1 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS1 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1)\n\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"fts1_tokenizer.h\"\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlit3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/* Forward declaration */\nstatic const sqlite3_tokenizer_module porterTokenizerModule;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n  t = (porter_tokenizer *) calloc(sizeof(*t), 1);\n  if( t==NULL ) return SQLITE_NOMEM;\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  c = (porter_tokenizer_cursor *) malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  free(c->zToken);\n  free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1] && isConsonant(z+1);\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    z[0]!=0 && isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    z[1]!=0 && isVowel(z+1) &&\n    z[2]!=0 && isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    int c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j, c;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     stem(&z, \"lanoita\", \"ate\", m_gt_0) ||\n     stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     break;\n   case 'c':\n     stem(&z, \"icne\", \"ence\", m_gt_0) ||\n     stem(&z, \"icna\", \"ance\", m_gt_0);\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"ilb\", \"ble\", m_gt_0) ||\n     stem(&z, \"illa\", \"al\", m_gt_0) ||\n     stem(&z, \"iltne\", \"ent\", m_gt_0) ||\n     stem(&z, \"ile\", \"e\", m_gt_0) ||\n     stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     break;\n   case 'o':\n     stem(&z, \"noitazi\", \"ize\", m_gt_0) ||\n     stem(&z, \"noita\", \"ate\", m_gt_0) ||\n     stem(&z, \"rota\", \"ate\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"msila\", \"al\", m_gt_0) ||\n     stem(&z, \"ssenevi\", \"ive\", m_gt_0) ||\n     stem(&z, \"ssenluf\", \"ful\", m_gt_0) ||\n     stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     break;\n   case 't':\n     stem(&z, \"itila\", \"al\", m_gt_0) ||\n     stem(&z, \"itivi\", \"ive\", m_gt_0) ||\n     stem(&z, \"itilib\", \"ble\", m_gt_0);\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     stem(&z, \"etaci\", \"ic\", m_gt_0) ||\n     stem(&z, \"evita\", \"\", m_gt_0)   ||\n     stem(&z, \"ezila\", \"al\", m_gt_0);\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"laci\", \"ic\", m_gt_0) ||\n     stem(&z, \"luf\", \"\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         stem(&z, \"tneme\", \"\", m_gt_1) ||\n         stem(&z, \"tnem\", \"\", m_gt_1) ||\n         stem(&z, \"tne\", \"\", m_gt_1);\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     stem(&z, \"eta\", \"\", m_gt_1) ||\n     stem(&z, \"iti\", \"\", m_gt_1);\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char isIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define idChar(C)  (((ch=C)&0x80)!=0 || (ch>0x2f && isIdChar[ch-0x30]))\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !isIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        c->nAllocated = n+20;\n        c->zToken = realloc(c->zToken, c->nAllocated);\n        if( c->zToken==NULL ) return SQLITE_NOMEM;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts1PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1_tokenizer.h",
    "content": "/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS1_TOKENIZER_H_\n#define _FTS1_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Structures used by the tokenizer interface.\n*/\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\n\nstruct sqlite3_tokenizer_module {\n  int iVersion;                  /* currently 0 */\n\n  /*\n  ** Create and destroy a tokenizer.  argc/argv are passed down from\n  ** the fulltext virtual table creation to allow customization.\n  */\n  int (*xCreate)(int argc, const char *const*argv,\n                 sqlite3_tokenizer **ppTokenizer);\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Tokenize a particular input.  Call xOpen() to prepare to\n  ** tokenize, xNext() repeatedly until it returns SQLITE_DONE, then\n  ** xClose() to free any internal state.  The pInput passed to\n  ** xOpen() must exist until the cursor is closed.  The ppToken\n  ** result from xNext() is only valid until the next call to xNext()\n  ** or until xClose() is called.\n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xOpen)(sqlite3_tokenizer *pTokenizer,\n               const char *pInput, int nBytes,\n               sqlite3_tokenizer_cursor **ppCursor);\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n               const char **ppToken, int *pnBytes,\n               int *piStartOffset, int *piEndOffset, int *piPosition);\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\n/*\n** Get the module for a tokenizer which generates tokens based on a\n** set of non-token characters.  The default is to break tokens at any\n** non-alnum character, though the set of delimiters can also be\n** specified by the first argv argument to xCreate().\n*/\n/* TODO(shess) This doesn't belong here.  Need some sort of\n** registration process.\n*/\nvoid sqlite3Fts1SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nvoid sqlite3Fts1PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n#endif /* _FTS1_TOKENIZER_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fts1_tokenizer1.c",
    "content": "/*\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS1 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS1 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS1 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1)\n\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"fts1_tokenizer.h\"\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\n/* Forward declaration */\nstatic const sqlite3_tokenizer_module simpleTokenizerModule;\n\nstatic int isDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) calloc(sizeof(*t), 1);\n  if( t==NULL ) return SQLITE_NOMEM;\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !isalnum(i);\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  c = (simple_tokenizer_cursor *) malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  free(c->pToken);\n  free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && isDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !isDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        c->nTokenAllocated = n+20;\n        c->pToken = realloc(c->pToken, c->nTokenAllocated);\n        if( c->pToken==NULL ) return SQLITE_NOMEM;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = ch<0x80 ? tolower(ch) : ch;\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts1SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS1) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fulltext.c",
    "content": "/* The author disclaims copyright to this source code.\n *\n * This is an SQLite module implementing full-text search.\n */\n\n#include <assert.h>\n#if !defined(__APPLE__)\n#include <malloc.h>\n#else\n#include <stdlib.h>\n#endif\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"fulltext.h\"\n#include \"ft_hash.h\"\n#include \"tokenizer.h\"\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n/* utility functions */\n\n/* We encode variable-length integers in little-endian order using seven bits\n * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n*/\n\n/* We may need up to VARINT_MAX bytes to store an encoded 64-bit integer. */\n#define VARINT_MAX 10\n\n/* Write a 64-bit variable-length integer to memory starting at p[0].\n * The length of data written will be between 1 and VARINT_MAX bytes.\n * The number of bytes written is returned. */\nstatic int putVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n/* Read a 64-bit variable-length integer from memory starting at p[0].\n * Return the number of bytes read, or 0 on error.\n * The value is stored in *v. */\nstatic int getVarint(const char *p, sqlite_int64 *v){\n  const unsigned char *q = (const unsigned char *) p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q & 0x80) == 0x80 ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n    if( q - (unsigned char *)p >= VARINT_MAX ){  /* bad data */\n      assert( 0 );\n      return 0;\n    }\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\nstatic int getVarint32(const char *p, int *pi){\n sqlite_int64 i;\n int ret = getVarint(p, &i);\n *pi = (int) i;\n assert( *pi==i );\n return ret;\n}\n\n/*** Document lists ***\n *\n * A document list holds a sorted list of varint-encoded document IDs.\n *\n * A doclist with type DL_POSITIONS_OFFSETS is stored like this:\n *\n * array {\n *   varint docid;\n *   array {\n *     varint position;     (delta from previous position plus 1, or 0 for end)\n *     varint startOffset;  (delta from previous startOffset)\n *     varint endOffset;    (delta from startOffset)\n *   }\n * }\n *\n * Here, array { X } means zero or more occurrences of X, adjacent in memory.\n *\n * A doclist with type DL_POSITIONS is like the above, but holds only docids\n * and positions without offset information.\n *\n * A doclist with type DL_DOCIDS is like the above, but holds only docids\n * without positions or offset information.\n *\n * On disk, every document list has positions and offsets, so we don't bother\n * to serialize a doclist's type.\n * \n * We don't yet delta-encode document IDs; doing so will probably be a\n * modest win.\n *\n * NOTE(shess) I've thought of a slightly (1%) better offset encoding.\n * After the first offset, estimate the next offset by using the\n * current token position and the previous token position and offset,\n * offset to handle some variance.  So the estimate would be\n * (iPosition*w->iStartOffset/w->iPosition-64), which is delta-encoded\n * as normal.  Offsets more than 64 chars from the estimate are\n * encoded as the delta to the previous start offset + 128.  An\n * additional tiny increment can be gained by using the end offset of\n * the previous token to make the estimate a tiny bit more precise.\n*/\n\ntypedef enum DocListType {\n  DL_DOCIDS,              /* docids only */\n  DL_POSITIONS,           /* docids + positions */\n  DL_POSITIONS_OFFSETS    /* docids + positions + offsets */\n} DocListType;\n\ntypedef struct DocList {\n  char *pData;\n  int nData;\n  DocListType iType;\n  int iLastPos;       /* the last position written */\n  int iLastOffset;    /* the last start offset written */\n} DocList;\n\n/* Initialize a new DocList to hold the given data. */\nstatic void docListInit(DocList *d, DocListType iType,\n                        const char *pData, int nData){\n  d->nData = nData;\n  if( nData>0 ){\n    d->pData = malloc(nData);\n    memcpy(d->pData, pData, nData);\n  } else {\n    d->pData = NULL;\n  }\n  d->iType = iType;\n  d->iLastPos = 0;\n  d->iLastOffset = 0;\n}\n\n/* Create a new dynamically-allocated DocList. */\nstatic DocList *docListNew(DocListType iType){\n  DocList *d = (DocList *) malloc(sizeof(DocList));\n  docListInit(d, iType, 0, 0);\n  return d;\n}\n\nstatic void docListDestroy(DocList *d){\n  free(d->pData);\n#ifndef NDEBUG\n  memset(d, 0x55, sizeof(*d));\n#endif\n}\n\nstatic void docListDelete(DocList *d){\n  docListDestroy(d);\n  free(d);\n}\n\nstatic char *docListEnd(DocList *d){\n  return d->pData + d->nData;\n}\n\n/* Append a varint to a DocList's data. */\nstatic void appendVarint(DocList *d, sqlite_int64 i){\n  char c[VARINT_MAX];\n  int n = putVarint(c, i);\n  d->pData = realloc(d->pData, d->nData + n);\n  memcpy(d->pData + d->nData, c, n);\n  d->nData += n;\n}\n\nstatic void docListAddDocid(DocList *d, sqlite_int64 iDocid){\n  appendVarint(d, iDocid);\n  d->iLastPos = 0;\n}\n\n/* Add a position to the last position list in a doclist. */\nstatic void docListAddPos(DocList *d, int iPos){\n  assert( d->iType>=DL_POSITIONS );\n  appendVarint(d, iPos-d->iLastPos+1);\n  d->iLastPos = iPos;\n}\n\nstatic void docListAddPosOffset(DocList *d, int iPos,\n                                int iStartOffset, int iEndOffset){\n  assert( d->iType==DL_POSITIONS_OFFSETS );\n  docListAddPos(d, iPos);\n  appendVarint(d, iStartOffset-d->iLastOffset);\n  d->iLastOffset = iStartOffset;\n  appendVarint(d, iEndOffset-iStartOffset);\n}\n\n/* Terminate the last position list in the given doclist. */\nstatic void docListAddEndPos(DocList *d){\n  appendVarint(d, 0);\n}\n\ntypedef struct DocListReader {\n  DocList *pDoclist;\n  char *p;\n  int iLastPos;    /* the last position read */\n} DocListReader;\n\nstatic void readerInit(DocListReader *r, DocList *pDoclist){\n  r->pDoclist = pDoclist;\n  if( pDoclist!=NULL ){\n    r->p = pDoclist->pData;\n  }\n  r->iLastPos = 0;\n}\n\nstatic int readerAtEnd(DocListReader *pReader){\n  return pReader->p >= docListEnd(pReader->pDoclist);\n}\n\n/* Peek at the next docid without advancing the read pointer. */\nstatic sqlite_int64 peekDocid(DocListReader *pReader){\n  sqlite_int64 ret;\n  assert( !readerAtEnd(pReader) );\n  getVarint(pReader->p, &ret);\n  return ret;\n}\n\n/* Read the next docid. */\nstatic sqlite_int64 readDocid(DocListReader *pReader){\n  sqlite_int64 ret;\n  assert( !readerAtEnd(pReader) );\n  pReader->p += getVarint(pReader->p, &ret);\n  pReader->iLastPos = 0;\n  return ret;\n}\n\n/* Read the next position from a position list.\n * Returns the position, or -1 at the end of the list. */\nstatic int readPosition(DocListReader *pReader){\n  int i;\n  int iType = pReader->pDoclist->iType;\n  assert( iType>=DL_POSITIONS );\n  assert( !readerAtEnd(pReader) );\n\n  pReader->p += getVarint32(pReader->p, &i);\n  if( i==0 ){\n    pReader->iLastPos = -1;\n    return -1;\n  }\n  pReader->iLastPos += ((int) i)-1;\n  if( iType>=DL_POSITIONS_OFFSETS ){\n    /* Skip over offsets, ignoring them for now. */\n    int iStart, iEnd;\n    pReader->p += getVarint32(pReader->p, &iStart);\n    pReader->p += getVarint32(pReader->p, &iEnd);\n  }\n  return pReader->iLastPos;\n}\n\n/* Skip past the end of a position list. */\nstatic void skipPositionList(DocListReader *pReader){\n  while( readPosition(pReader)!=-1 )\n    ;\n}\n\n/* Skip over a docid, including its position list if the doclist has\n * positions. */\nstatic void skipDocument(DocListReader *pReader){\n  readDocid(pReader);\n  if( pReader->pDoclist->iType >= DL_POSITIONS ){\n    skipPositionList(pReader);\n  }\n}\n\nstatic sqlite_int64 firstDocid(DocList *d){\n  DocListReader r;\n  readerInit(&r, d);\n  return readDocid(&r);\n}\n\n/* Doclist multi-tool.  Pass pUpdate==NULL to delete the indicated docid;\n * otherwise pUpdate, which must contain only the single docid [iDocid], is\n * inserted (if not present) or updated (if already present). */\nstatic int docListUpdate(DocList *d, sqlite_int64 iDocid, DocList *pUpdate){\n  int modified = 0;\n  DocListReader reader;\n  char *p;\n\n  if( pUpdate!=NULL ){\n    assert( d->iType==pUpdate->iType);\n    assert( iDocid==firstDocid(pUpdate) );\n  }\n\n  readerInit(&reader, d);\n  while( !readerAtEnd(&reader) && peekDocid(&reader)<iDocid ){\n    skipDocument(&reader);\n  }\n\n  p = reader.p;\n  /* Delete if there is a matching element. */\n  if( !readerAtEnd(&reader) && iDocid==peekDocid(&reader) ){\n    skipDocument(&reader);\n    memmove(p, reader.p, docListEnd(d) - reader.p);\n    d->nData -= (reader.p - p);\n    modified = 1;\n  }\n\n  /* Insert if indicated. */\n  if( pUpdate!=NULL ){\n    int iDoclist = p-d->pData;\n    docListAddEndPos(pUpdate);\n\n    d->pData = realloc(d->pData, d->nData+pUpdate->nData);\n    p = d->pData + iDoclist;\n\n    memmove(p+pUpdate->nData, p, docListEnd(d) - p);\n    memcpy(p, pUpdate->pData, pUpdate->nData);\n    d->nData += pUpdate->nData;\n    modified = 1;\n  }\n\n  return modified;\n}\n\n/* Split the second half of doclist d into a separate doclist d2.  Returns 1\n * if successful, or 0 if d contains a single document and hence can't be\n * split. */\nstatic int docListSplit(DocList *d, DocList *d2){\n  const char *pSplitPoint = d->pData + d->nData / 2;\n  DocListReader reader;\n\n  readerInit(&reader, d);\n  while( reader.p<pSplitPoint ){\n    skipDocument(&reader);\n  }\n  if( readerAtEnd(&reader) ) return 0;\n  docListInit(d2, d->iType, reader.p, docListEnd(d) - reader.p);\n  d->nData = reader.p - d->pData;\n  d->pData = realloc(d->pData, d->nData);\n  return 1;\n}\n\n/* A DocListMerge computes the AND of an in-memory DocList [in] and a chunked\n * on-disk doclist, resulting in another in-memory DocList [out].  [in]\n * and [out] may or may not store position information according to the\n * caller's wishes.  The on-disk doclist always comes with positions.\n *\n * The caller must read each chunk of the on-disk doclist in succession and\n * pass it to mergeBlock().\n *\n * If [in] has positions, then the merge output contains only documents with\n * matching positions in the two input doclists.  If [in] does not have\n * positions, then the merge output contains all documents common to the two\n * input doclists.\n *\n * If [in] is NULL, then the on-disk doclist is copied to [out] directly.\n *\n * A merge is performed using an integer [iOffset] provided by the caller.\n * [iOffset] is subtracted from each position in the on-disk doclist for the\n * purpose of position comparison; this is helpful in implementing phrase\n * searches.\n *\n * A DocListMerge is not yet able to propagate offsets through query\n * processing; we should add that capability soon.\n*/\ntypedef struct DocListMerge {\n  DocListReader in;\n  DocList *pOut;\n  int iOffset;\n} DocListMerge;\n\nstatic void mergeInit(DocListMerge *m,\n                      DocList *pIn, int iOffset, DocList *pOut){\n  readerInit(&m->in, pIn);\n  m->pOut = pOut;\n  m->iOffset = iOffset;\n\n  /* can't handle offsets yet */\n  assert( pIn==NULL || pIn->iType <= DL_POSITIONS );\n  assert( pOut->iType <= DL_POSITIONS );\n}\n\n/* A helper function for mergeBlock(), below.  Merge the position lists\n * pointed to by m->in and pBlockReader.\n * If the merge matches, write [iDocid] to m->pOut; if m->pOut\n * has positions then write all matching positions as well. */\nstatic void mergePosList(DocListMerge *m, sqlite_int64 iDocid,\n                  DocListReader *pBlockReader){\n  int block_pos = readPosition(pBlockReader);\n  int in_pos = readPosition(&m->in);\n  int match = 0;\n  while( block_pos!=-1 || in_pos!=-1 ){\n    if( block_pos-m->iOffset==in_pos ){\n      if( !match ){\n        docListAddDocid(m->pOut, iDocid);\n        match = 1;\n      }\n      if( m->pOut->iType >= DL_POSITIONS ){\n        docListAddPos(m->pOut, in_pos);\n      }\n      block_pos = readPosition(pBlockReader);\n      in_pos = readPosition(&m->in);\n    } else if( in_pos==-1 || (block_pos!=-1 && block_pos-m->iOffset<in_pos) ){\n      block_pos = readPosition(pBlockReader);\n    } else {\n      in_pos = readPosition(&m->in);\n    }\n  }\n  if( m->pOut->iType >= DL_POSITIONS && match ){\n    docListAddEndPos(m->pOut);\n  }\n}\n\n/* Merge one block of an on-disk doclist into a DocListMerge. */\nstatic void mergeBlock(DocListMerge *m, DocList *pBlock){\n  DocListReader blockReader;\n  assert( pBlock->iType >= DL_POSITIONS );\n  readerInit(&blockReader, pBlock);\n  while( !readerAtEnd(&blockReader) ){\n    sqlite_int64 iDocid = readDocid(&blockReader);\n    if( m->in.pDoclist!=NULL ){\n      while( 1 ){\n        if( readerAtEnd(&m->in) ) return;  /* nothing more to merge */\n        if( peekDocid(&m->in)>=iDocid ) break;\n        skipDocument(&m->in);\n      }\n      if( peekDocid(&m->in)>iDocid ){  /* [pIn] has no match with iDocid */\n        skipPositionList(&blockReader);  /* skip this docid in the block */\n        continue;\n      }\n      readDocid(&m->in);\n    }\n    /* We have a document match. */\n    if( m->in.pDoclist==NULL || m->in.pDoclist->iType < DL_POSITIONS ){\n      /* We don't need to do a poslist merge. */\n      docListAddDocid(m->pOut, iDocid);\n      if( m->pOut->iType >= DL_POSITIONS ){\n        /* Copy all positions to the output doclist. */\n        while( 1 ){\n          int pos = readPosition(&blockReader);\n          if( pos==-1 ) break;\n          docListAddPos(m->pOut, pos);\n        }\n        docListAddEndPos(m->pOut);\n      } else skipPositionList(&blockReader);\n      continue;\n    }\n    mergePosList(m, iDocid, &blockReader);\n  }\n}\n\nstatic char *string_dup_n(const char *s, int n){\n  char *str = malloc(n + 1);\n  memcpy(str, s, n);\n  str[n] = '\\0';\n  return str;\n}\n\n/* Duplicate a string; the caller must free() the returned string.\n * (We don't use strdup() since it's not part of the standard C library and\n * may not be available everywhere.) */\nstatic char *string_dup(const char *s){\n  return string_dup_n(s, strlen(s));\n}\n\n/* Format a string, replacing each occurrence of the % character with\n * zName.  This may be more convenient than sqlite_mprintf()\n * when one string is used repeatedly in a format string.\n * The caller must free() the returned string. */\nstatic char *string_format(const char *zFormat, const char *zName){\n  const char *p;\n  size_t len = 0;\n  size_t nName = strlen(zName);\n  char *result;\n  char *r;\n\n  /* first compute length needed */\n  for(p = zFormat ; *p ; ++p){\n    len += (*p=='%' ? nName : 1);\n  }\n  len += 1;  /* for null terminator */\n\n  r = result = malloc(len);\n  for(p = zFormat; *p; ++p){\n    if( *p=='%' ){\n      memcpy(r, zName, nName);\n      r += nName;\n    } else {\n      *r++ = *p;\n    }\n  }\n  *r++ = '\\0';\n  assert( r == result + len );\n  return result;\n}\n\nstatic int sql_exec(sqlite3 *db, const char *zName, const char *zFormat){\n  char *zCommand = string_format(zFormat, zName);\n  int rc = sqlite3_exec(db, zCommand, NULL, 0, NULL);\n  free(zCommand);\n  return rc;\n}\n\nstatic int sql_prepare(sqlite3 *db, const char *zName, sqlite3_stmt **ppStmt,\n                const char *zFormat){\n  char *zCommand = string_format(zFormat, zName);\n  int rc = sqlite3_prepare(db, zCommand, -1, ppStmt, NULL);\n  free(zCommand);\n  return rc;\n}\n\n/* end utility functions */\n\n#define QUERY_GENERIC 0\n#define QUERY_FULLTEXT 1\n\n#define CHUNK_MAX 1024\n\ntypedef enum fulltext_statement {\n  CONTENT_INSERT_STMT,\n  CONTENT_SELECT_STMT,\n  CONTENT_DELETE_STMT,\n\n  TERM_SELECT_STMT,\n  TERM_CHUNK_SELECT_STMT,\n  TERM_INSERT_STMT,\n  TERM_UPDATE_STMT,\n  TERM_DELETE_STMT,\n\n  MAX_STMT                     /* Always at end! */\n} fulltext_statement;\n\n/* These must exactly match the enum above. */\n/* TODO(adam): Is there some risk that a statement (in particular,\n** pTermSelectStmt) will be used in two cursors at once, e.g.  if a\n** query joins a virtual table to itself?  If so perhaps we should\n** move some of these to the cursor object.\n*/\nstatic const char *fulltext_zStatement[MAX_STMT] = {\n  /* CONTENT_INSERT */ \"insert into %_content (rowid, content) values (?, ?)\",\n  /* CONTENT_SELECT */ \"select content from %_content where rowid = ?\",\n  /* CONTENT_DELETE */ \"delete from %_content where rowid = ?\",\n\n  /* TERM_SELECT */\n  \"select rowid, doclist from %_term where term = ? and first = ?\",\n  /* TERM_CHUNK_SELECT */\n  \"select max(first) from %_term where term = ? and first <= ?\",\n  /* TERM_INSERT */\n  \"insert into %_term (term, first, doclist) values (?, ?, ?)\",\n  /* TERM_UPDATE */ \"update %_term set doclist = ? where rowid = ?\",\n  /* TERM_DELETE */ \"delete from %_term where rowid = ?\",\n};\n\ntypedef struct fulltext_vtab {\n  sqlite3_vtab base;\n  sqlite3 *db;\n  const char *zName;               /* virtual table name */\n  sqlite3_tokenizer *pTokenizer;   /* tokenizer for inserts and queries */\n\n  /* Precompiled statements which we keep as long as the table is\n  ** open.\n  */\n  sqlite3_stmt *pFulltextStatements[MAX_STMT];\n} fulltext_vtab;\n\ntypedef struct fulltext_cursor {\n  sqlite3_vtab_cursor base;\n  int iCursorType;  /* QUERY_GENERIC or QUERY_FULLTEXT */\n\n  sqlite3_stmt *pStmt;\n\n  int eof;\n\n  /* The following is used only when iCursorType == QUERY_FULLTEXT. */\n  DocListReader result;\n} fulltext_cursor;\n\nstatic struct fulltext_vtab *cursor_vtab(fulltext_cursor *c){\n  return (fulltext_vtab *) c->base.pVtab;\n}\n\nstatic sqlite3_module fulltextModule;   /* forward declaration */\n\n/* Puts a freshly-prepared statement determined by iStmt in *ppStmt.\n** If the indicated statement has never been prepared, it is prepared\n** and cached, otherwise the cached version is reset.\n*/\nstatic int sql_get_statement(fulltext_vtab *v, fulltext_statement iStmt,\n                             sqlite3_stmt **ppStmt){\n  assert( iStmt<MAX_STMT );\n  if( v->pFulltextStatements[iStmt]==NULL ){\n    int rc = sql_prepare(v->db, v->zName, &v->pFulltextStatements[iStmt],\n                         fulltext_zStatement[iStmt]);\n    if( rc!=SQLITE_OK ) return rc;\n  } else {\n    int rc = sqlite3_reset(v->pFulltextStatements[iStmt]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  *ppStmt = v->pFulltextStatements[iStmt];\n  return SQLITE_OK;\n}\n\n/* Step the indicated statement, handling errors SQLITE_BUSY (by\n** retrying) and SQLITE_SCHEMA (by re-preparing and transferring\n** bindings to the new statement).\n** TODO(adam): We should extend this function so that it can work with\n** statements declared locally, not only globally cached statements.\n*/\nstatic int sql_step_statement(fulltext_vtab *v, fulltext_statement iStmt,\n                              sqlite3_stmt **ppStmt){\n  int rc;\n  sqlite3_stmt *s = *ppStmt;\n  assert( iStmt<MAX_STMT );\n  assert( s==v->pFulltextStatements[iStmt] );\n\n  while( (rc=sqlite3_step(s))!=SQLITE_DONE && rc!=SQLITE_ROW ){\n    sqlite3_stmt *pNewStmt;\n\n    if( rc==SQLITE_BUSY ) continue;\n    if( rc!=SQLITE_ERROR ) return rc;\n\n    rc = sqlite3_reset(s);\n    if( rc!=SQLITE_SCHEMA ) return SQLITE_ERROR;\n\n    v->pFulltextStatements[iStmt] = NULL;   /* Still in s */\n    rc = sql_get_statement(v, iStmt, &pNewStmt);\n    if( rc!=SQLITE_OK ) goto err;\n    *ppStmt = pNewStmt;\n\n    rc = sqlite3_transfer_bindings(s, pNewStmt);\n    if( rc!=SQLITE_OK ) goto err;\n\n    rc = sqlite3_finalize(s);\n    if( rc!=SQLITE_OK ) return rc;\n    s = pNewStmt;\n  }\n  return rc;\n\n err:\n  sqlite3_finalize(s);\n  return rc;\n}\n\n/* Like sql_step_statement(), but convert SQLITE_DONE to SQLITE_OK.\n** Useful for statements like UPDATE, where we expect no results.\n*/\nstatic int sql_single_step_statement(fulltext_vtab *v,\n                                     fulltext_statement iStmt,\n                                     sqlite3_stmt **ppStmt){\n  int rc = sql_step_statement(v, iStmt, ppStmt);\n  return (rc==SQLITE_DONE) ? SQLITE_OK : rc;\n}\n\n/* insert into %_content (rowid, content) values ([rowid], [zContent]) */\nstatic int content_insert(fulltext_vtab *v, sqlite3_value *rowid,\n                          const char *zContent, int nContent){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_value(s, 1, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 2, zContent, nContent, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, CONTENT_INSERT_STMT, &s);\n}\n\n/* select content from %_content where rowid = [iRow]\n * The caller must delete the returned string. */\nstatic int content_select(fulltext_vtab *v, sqlite_int64 iRow,\n                          char **pzContent){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_step_statement(v, CONTENT_SELECT_STMT, &s);\n  if( rc!=SQLITE_ROW ) return rc;\n\n  *pzContent = string_dup((const char *)sqlite3_column_text(s, 0));\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ) return SQLITE_OK;\n\n  free(*pzContent);\n  return rc;\n}\n\n/* delete from %_content where rowid = [iRow ] */\nstatic int content_delete(fulltext_vtab *v, sqlite_int64 iRow){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, CONTENT_DELETE_STMT, &s);\n}\n\n/* select rowid, doclist from %_term where term = [zTerm] and first = [iFirst]\n * If found, returns SQLITE_OK; the caller must free the returned doclist.\n * If no rows found, returns SQLITE_ERROR. */\nstatic int term_select(fulltext_vtab *v, const char *zTerm, int nTerm,\n                       sqlite_int64 iFirst,\n                       sqlite_int64 *rowid,\n                       DocList *out){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 1, zTerm, nTerm, SQLITE_TRANSIENT);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, iFirst);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_step_statement(v, TERM_SELECT_STMT, &s);\n  if( rc!=SQLITE_ROW ) return rc==SQLITE_DONE ? SQLITE_ERROR : rc;\n\n  *rowid = sqlite3_column_int64(s, 0);\n  docListInit(out, DL_POSITIONS_OFFSETS,\n              sqlite3_column_blob(s, 1), sqlite3_column_bytes(s, 1));\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  return rc==SQLITE_DONE ? SQLITE_OK : rc;\n}\n\n/* select max(first) from %_term where term = [zTerm] and first <= [iFirst]\n * If found, returns SQLITE_ROW and result in *piResult; if the query returns\n * NULL (meaning no row found) returns SQLITE_DONE.\n */\nstatic int term_chunk_select(fulltext_vtab *v, const char *zTerm, int nTerm,\n                           sqlite_int64 iFirst, sqlite_int64 *piResult){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_CHUNK_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 1, zTerm, nTerm, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, iFirst);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_step_statement(v, TERM_CHUNK_SELECT_STMT, &s);\n  if( rc!=SQLITE_ROW ) return rc==SQLITE_DONE ? SQLITE_ERROR : rc;\n\n  switch( sqlite3_column_type(s, 0) ){\n    case SQLITE_NULL:\n      rc = SQLITE_DONE;\n      break;\n    case SQLITE_INTEGER:\n     *piResult = sqlite3_column_int64(s, 0);\n     break;\n    default:\n      return SQLITE_ERROR;\n  }\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  if( sqlite3_step(s) != SQLITE_DONE ) return SQLITE_ERROR;\n  return rc;\n}\n\n/* insert into %_term (term, first, doclist)\n               values ([zTerm], [iFirst], [doclist]) */\nstatic int term_insert(fulltext_vtab *v, const char *zTerm, int nTerm,\n                       sqlite_int64 iFirst, DocList *doclist){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(s, 1, zTerm, nTerm, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, iFirst);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 3, doclist->pData, doclist->nData, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_INSERT_STMT, &s);\n}\n\n/* update %_term set doclist = [doclist] where rowid = [rowid] */\nstatic int term_update(fulltext_vtab *v, sqlite_int64 rowid,\n                       DocList *doclist){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_UPDATE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 1, doclist->pData, doclist->nData,\n                         SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_UPDATE_STMT, &s);\n}\n\nstatic int term_delete(fulltext_vtab *v, sqlite_int64 rowid){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, TERM_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step_statement(v, TERM_DELETE_STMT, &s);\n}\n\nstatic void fulltext_vtab_destroy(fulltext_vtab *v){\n  int iStmt;\n\n  for( iStmt=0; iStmt<MAX_STMT; iStmt++ ){\n    if( v->pFulltextStatements[iStmt]!=NULL ){\n      sqlite3_finalize(v->pFulltextStatements[iStmt]);\n      v->pFulltextStatements[iStmt] = NULL;\n    }\n  }\n\n  if( v->pTokenizer!=NULL ){\n    v->pTokenizer->pModule->xDestroy(v->pTokenizer);\n    v->pTokenizer = NULL;\n  }\n\n  free((void *) v->zName);\n  free(v);\n}\n\n/* Current interface:\n** argv[0] - module name\n** argv[1] - database name\n** argv[2] - table name\n** argv[3] - tokenizer name (optional, a sensible default is provided)\n** argv[4..] - passed to tokenizer (optional based on tokenizer)\n**/\nstatic int fulltextConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc,\n  const char * const *argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  int rc;\n  fulltext_vtab *v;\n  sqlite3_tokenizer_module *m = NULL;\n\n  assert( argc>=3 );\n  v = (fulltext_vtab *) malloc(sizeof(fulltext_vtab));\n  /* sqlite will initialize v->base */\n  v->db = db;\n  v->zName = string_dup(argv[2]);\n  v->pTokenizer = NULL;\n\n  if( argc==3 ){\n    get_simple_tokenizer_module(&m);\n  } else {\n    /* TODO(shess) For now, add new tokenizers as else if clauses. */\n    if( !strcmp(argv[3], \"simple\") ){\n      get_simple_tokenizer_module(&m);\n    } else {\n      assert( \"unrecognized tokenizer\"==NULL );\n    }\n  }\n\n  /* TODO(shess) Since tokenization impacts the index, the parameters\n  ** to the tokenizer need to be identical when a persistent virtual\n  ** table is re-created.  One solution would be a meta-table to track\n  ** such information in the database.  Then we could verify that the\n  ** information is identical on subsequent creates.\n  */\n  /* TODO(shess) Why isn't argv already (const char **)? */\n  rc = m->xCreate(argc-3, (const char **) (argv+3), &v->pTokenizer);\n  if( rc!=SQLITE_OK ) return rc;\n  v->pTokenizer->pModule = m;\n\n  /* TODO: verify the existence of backing tables foo_content, foo_term */\n\n  rc = sqlite3_declare_vtab(db, \"create table x(content text)\");\n  if( rc!=SQLITE_OK ) return rc;\n\n  memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements));\n\n  *ppVTab = &v->base;\n  return SQLITE_OK;\n}\n\nstatic int fulltextCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc,\n  const char * const *argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  int rc;\n  assert( argc>=3 );\n\n  /* The %_content table holds the text of each full-text item, with\n  ** the rowid used as the docid.\n  **\n  ** The %_term table maps each term to a document list blob\n  ** containing elements sorted by ascending docid, each element\n  ** encoded as:\n  **\n  **   docid varint-encoded\n  **   token count varint-encoded\n  **   \"count\" token elements (poslist):\n  **     position varint-encoded as delta from previous position\n  **     start offset varint-encoded as delta from previous start offset\n  **     end offset varint-encoded as delta from start offset\n  **\n  ** Additionally, doclist blobs can be chunked into multiple rows,\n  ** using \"first\" to order the blobs.  \"first\" is simply the first\n  ** docid in the blob.\n  */\n  /*\n  ** NOTE(shess) That last sentence is incorrect in the face of\n  ** deletion, which can leave a doclist that doesn't contain the\n  ** first from that row.  I _believe_ this does not matter to the\n  ** operation of the system, but it might be reasonable to update\n  ** appropriately in case this assumption becomes more important.\n  */\n  rc = sql_exec(db, argv[2],\n    \"create table %_content(content text);\"\n    \"create table %_term(term text, first integer, doclist blob);\"\n    \"create index %_index on %_term(term, first)\");\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fulltextConnect(db, pAux, argc, argv, ppVTab, pzErr);\n}\n\n/* Decide how to handle an SQL query.\n * At the moment, MATCH queries can include implicit boolean ANDs; we\n * haven't implemented phrase searches or OR yet. */\nstatic int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  int i;\n\n  for(i=0; i<pInfo->nConstraint; ++i){\n    const struct sqlite3_index_constraint *pConstraint;\n    pConstraint = &pInfo->aConstraint[i];\n    if( pConstraint->iColumn==0 &&\n        pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH &&\n        pConstraint->usable ){   /* a full-text search */\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->idxNum = QUERY_FULLTEXT;\n      pInfo->estimatedCost = 1.0;   /* an arbitrary value for now */\n      return SQLITE_OK;\n    }\n  }\n  pInfo->idxNum = QUERY_GENERIC;\n  return SQLITE_OK;\n}\n\nstatic int fulltextDisconnect(sqlite3_vtab *pVTab){\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextDestroy(sqlite3_vtab *pVTab){\n  fulltext_vtab *v = (fulltext_vtab *)pVTab;\n\n  int rc = sql_exec(v->db, v->zName,\n                    \"drop table %_content; drop table %_term\");\n  if( rc!=SQLITE_OK ) return rc;\n\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  fulltext_cursor *c;\n\n  c = (fulltext_cursor *) calloc(sizeof(fulltext_cursor), 1);\n  /* sqlite will initialize c->base */\n  *ppCursor = &c->base;\n\n  return SQLITE_OK;\n}\n\nstatic int fulltextClose(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  sqlite3_finalize(c->pStmt);\n  if( c->result.pDoclist!=NULL ){\n    docListDelete(c->result.pDoclist);\n  }\n  free(c);\n  return SQLITE_OK;\n}\n\nstatic int fulltextNext(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  sqlite_int64 iDocid;\n  int rc;\n\n  switch( c->iCursorType ){\n    case QUERY_GENERIC:\n      /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n      rc = sqlite3_step(c->pStmt);\n      switch( rc ){\n        case SQLITE_ROW:\n          c->eof = 0;\n          return SQLITE_OK;\n        case SQLITE_DONE:\n          c->eof = 1;\n          return SQLITE_OK;\n        default:\n          c->eof = 1;\n          return rc;\n      }\n    case QUERY_FULLTEXT:\n      rc = sqlite3_reset(c->pStmt);\n      if( rc!=SQLITE_OK ) return rc;\n\n      if( readerAtEnd(&c->result)){\n        c->eof = 1;\n        return SQLITE_OK;\n      }\n      iDocid = readDocid(&c->result);\n      rc = sqlite3_bind_int64(c->pStmt, 1, iDocid);\n      if( rc!=SQLITE_OK ) return rc;\n      /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n      rc = sqlite3_step(c->pStmt);\n      if( rc==SQLITE_ROW ){   /* the case we expect */\n        c->eof = 0;\n        return SQLITE_OK;\n      }\n      /* an error occurred; abort */\n      return rc==SQLITE_DONE ? SQLITE_ERROR : rc;\n    default:\n      assert( 0 );\n      return SQLITE_ERROR;  /* not reached */\n  }\n}\n\nstatic int term_select_doclist(fulltext_vtab *v, const char *pTerm, int nTerm,\n                               sqlite3_stmt **ppStmt){\n  int rc;\n  if( *ppStmt ){\n    rc = sqlite3_reset(*ppStmt);\n  } else {\n    rc = sql_prepare(v->db, v->zName, ppStmt,\n      \"select doclist from %_term where term = ? order by first\");\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_text(*ppStmt, 1, pTerm, nTerm, SQLITE_TRANSIENT);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sqlite3_step(*ppStmt);   /* TODO(adamd): handle schema error */\n}\n\n/* Read the posting list for [zTerm]; AND it with the doclist [in] to\n * produce the doclist [out], using the given offset [iOffset] for phrase\n * matching.\n * (*pSelect) is used to hold an SQLite statement used inside this function;\n * the caller should initialize *pSelect to NULL before the first call.\n */\nstatic int query_merge(fulltext_vtab *v, sqlite3_stmt **pSelect,\n                       const char *zTerm,\n                       DocList *pIn, int iOffset, DocList *out){\n  int rc;\n  DocListMerge merge;\n\n  if( pIn!=NULL && !pIn->nData ){\n    /* If [pIn] is already empty, there's no point in reading the\n     * posting list to AND it in; return immediately. */\n      return SQLITE_OK;\n  }\n\n  rc = term_select_doclist(v, zTerm, -1, pSelect);\n  if( rc!=SQLITE_ROW && rc!=SQLITE_DONE ) return rc;\n\n  mergeInit(&merge, pIn, iOffset, out);\n  while( rc==SQLITE_ROW ){\n    DocList block;\n    docListInit(&block, DL_POSITIONS_OFFSETS,\n                sqlite3_column_blob(*pSelect, 0),\n                sqlite3_column_bytes(*pSelect, 0));\n    mergeBlock(&merge, &block);\n    docListDestroy(&block);\n\n    rc = sqlite3_step(*pSelect);\n    if( rc!=SQLITE_ROW && rc!=SQLITE_DONE ){\n      return rc;\n    }\n  }\n  \n  return SQLITE_OK;\n}\n\ntypedef struct QueryTerm {\n  int is_phrase;    /* true if this term begins a new phrase */\n  const char *zTerm;\n} QueryTerm;\n\n/* A parsed query.\n *\n * As an example, parsing the query [\"four score\" years \"new nation\"] will\n * yield a Query with 5 terms:\n *   \"four\",   is_phrase = 1\n *   \"score\",  is_phrase = 0\n *   \"years\",  is_phrase = 1\n *   \"new\",    is_phrase = 1\n *   \"nation\", is_phrase = 0\n */\ntypedef struct Query {\n  int nTerms;\n  QueryTerm *pTerm;\n} Query;\n\nstatic void query_add(Query *q, int is_phrase, const char *zTerm){\n  QueryTerm *t;\n  ++q->nTerms;\n  q->pTerm = realloc(q->pTerm, q->nTerms * sizeof(q->pTerm[0]));\n  t = &q->pTerm[q->nTerms - 1];\n  t->is_phrase = is_phrase;\n  t->zTerm = zTerm;\n}\n    \nstatic void query_free(Query *q){\n  int i;\n  for(i = 0; i < q->nTerms; ++i){\n    free((void *) q->pTerm[i].zTerm);\n  }\n  free(q->pTerm);\n}\n\nstatic int tokenize_segment(sqlite3_tokenizer *pTokenizer,\n                            const char *zQuery, int in_phrase,\n                            Query *pQuery){\n  sqlite3_tokenizer_module *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCursor;\n  int is_first = 1;\n  \n  int rc = pModule->xOpen(pTokenizer, zQuery, -1, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n  pCursor->pTokenizer = pTokenizer;\n\n  while( 1 ){\n    const char *zToken;\n    int nToken, iStartOffset, iEndOffset, dummy_pos;\n\n    rc = pModule->xNext(pCursor,\n                        &zToken, &nToken,\n                        &iStartOffset, &iEndOffset,\n                        &dummy_pos);\n    if( rc!=SQLITE_OK ) break;\n    query_add(pQuery, !in_phrase || is_first, string_dup_n(zToken, nToken));\n    is_first = 0;\n  }\n\n  return pModule->xClose(pCursor);\n}\n\n/* Parse a query string, yielding a Query object. */\nstatic int parse_query(fulltext_vtab *v, const char *zQuery, Query *pQuery){\n  char *zQuery1 = string_dup(zQuery);\n  int in_phrase = 0;\n  char *s = zQuery1;\n  pQuery->nTerms = 0;\n  pQuery->pTerm = NULL;\n\n  while( *s ){\n    char *t = s;\n    while( *t ){\n      if( *t=='\"' ){\n        *t++ = '\\0';\n        break;\n      }\n      ++t;\n    }\n    if( *s ){\n      tokenize_segment(v->pTokenizer, s, in_phrase, pQuery);\n    }\n    s = t;\n    in_phrase = !in_phrase;\n  }\n  \n  free(zQuery1);\n  return SQLITE_OK;\n}\n\n/* Perform a full-text query; return a list of documents in [pResult]. */\nstatic int fulltext_query(fulltext_vtab *v, const char *zQuery,\n                          DocList **pResult){\n  Query q;\n  int phrase_start = -1;\n  int i;\n  sqlite3_stmt *pSelect = NULL;\n  DocList *d = NULL;\n\n  int rc = parse_query(v, zQuery, &q);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Merge terms. */\n  for(i = 0 ; i < q.nTerms ; ++i){\n    /* In each merge step, we need to generate positions whenever we're\n     * processing a phrase which hasn't ended yet. */\n    int need_positions = i<q.nTerms-1 && !q.pTerm[i+1].is_phrase;\n    DocList *next = docListNew(need_positions ? DL_POSITIONS : DL_DOCIDS);\n    if( q.pTerm[i].is_phrase ){\n      phrase_start = i;\n    }\n    rc = query_merge(v, &pSelect, q.pTerm[i].zTerm, d, i - phrase_start, next);\n    if( rc!=SQLITE_OK ) break;\n    if( d!=NULL ){\n      docListDelete(d);\n    }\n    d = next;\n  }\n\n  sqlite3_finalize(pSelect);\n  query_free(&q);\n  *pResult = d;\n  return rc;\n}\n\nstatic int fulltextFilter(sqlite3_vtab_cursor *pCursor,\n                          int idxNum, const char *idxStr,\n                          int argc, sqlite3_value **argv){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  fulltext_vtab *v = cursor_vtab(c);\n  int rc;\n  const char *zStatement;\n\n  c->iCursorType = idxNum;\n  switch( idxNum ){\n    case QUERY_GENERIC:\n      zStatement = \"select rowid, content from %_content\";\n      break;\n\n    case QUERY_FULLTEXT:   /* full-text search */\n    {\n      const char *zQuery = (const char *)sqlite3_value_text(argv[0]);\n      DocList *pResult;\n      assert( argc==1 );\n      rc = fulltext_query(v, zQuery, &pResult);\n      if( rc!=SQLITE_OK ) return rc;\n      readerInit(&c->result, pResult);\n      zStatement = \"select rowid, content from %_content where rowid = ?\";\n      break;\n    }\n\n    default:\n      assert( 0 );\n  }\n\n  rc = sql_prepare(v->db, v->zName, &c->pStmt, zStatement);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fulltextNext(pCursor);\n}\n\nstatic int fulltextEof(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  return c->eof;\n}\n\nstatic int fulltextColumn(sqlite3_vtab_cursor *pCursor,\n                          sqlite3_context *pContext, int idxCol){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  const char *s;\n\n  assert( idxCol==0 );\n  s = (const char *) sqlite3_column_text(c->pStmt, 1);\n  sqlite3_result_text(pContext, s, -1, SQLITE_TRANSIENT);\n\n  return SQLITE_OK;\n}\n\nstatic int fulltextRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n\n  *pRowid = sqlite3_column_int64(c->pStmt, 0);\n  return SQLITE_OK;\n}\n\n/* Build a hash table containing all terms in zText. */\nstatic int build_terms(Hash *terms, sqlite3_tokenizer *pTokenizer,\n                       const char *zText, sqlite_int64 iDocid){\n  sqlite3_tokenizer_cursor *pCursor;\n  const char *pToken;\n  int nTokenBytes;\n  int iStartOffset, iEndOffset, iPosition;\n\n  int rc = pTokenizer->pModule->xOpen(pTokenizer, zText, -1, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pCursor->pTokenizer = pTokenizer;\n  HashInit(terms, HASH_STRING, 1);\n  while( SQLITE_OK==pTokenizer->pModule->xNext(pCursor,\n                                               &pToken, &nTokenBytes,\n                                               &iStartOffset, &iEndOffset,\n                                               &iPosition) ){\n    DocList *p;\n\n    /* Positions can't be negative; we use -1 as a terminator internally. */\n    if( iPosition<0 ) {\n      rc = SQLITE_ERROR;  \n      goto err;\n    }\n\n    p = HashFind(terms, pToken, nTokenBytes);\n    if( p==NULL ){\n      p = docListNew(DL_POSITIONS_OFFSETS);\n      docListAddDocid(p, iDocid);\n      HashInsert(terms, pToken, nTokenBytes, p);\n    }\n    docListAddPosOffset(p, iPosition, iStartOffset, iEndOffset);\n  }\n\nerr:\n  /* TODO(shess) Check return?  Should this be able to cause errors at\n  ** this point?  Actually, same question about sqlite3_finalize(),\n  ** though one could argue that failure there means that the data is\n  ** not durable.  *ponder*\n  */\n  pTokenizer->pModule->xClose(pCursor);\n  return rc;\n}\n/* Update the %_terms table to map the term [zTerm] to the given rowid. */\nstatic int index_insert_term(fulltext_vtab *v, const char *zTerm, int nTerm,\n                             sqlite_int64 iDocid, DocList *p){\n  sqlite_int64 iFirst;\n  sqlite_int64 iIndexRow;\n  DocList doclist;\n\n  int rc = term_chunk_select(v, zTerm, nTerm, iDocid, &iFirst);\n  if( rc==SQLITE_DONE ){\n    docListInit(&doclist, DL_POSITIONS_OFFSETS, 0, 0);\n    if( docListUpdate(&doclist, iDocid, p) ){\n      rc = term_insert(v, zTerm, nTerm, iDocid, &doclist);\n      docListDestroy(&doclist);\n      return rc;\n    }\n    return SQLITE_OK;\n  }\n  if( rc!=SQLITE_ROW ) return SQLITE_ERROR;\n\n  /* This word is in the index; add this document ID to its blob. */\n\n  rc = term_select(v, zTerm, nTerm, iFirst, &iIndexRow, &doclist);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( docListUpdate(&doclist, iDocid, p) ){\n    /* If the blob is too big, split it in half. */\n    if( doclist.nData>CHUNK_MAX ){\n      DocList half;\n      if( docListSplit(&doclist, &half) ){\n        rc = term_insert(v, zTerm, nTerm, firstDocid(&half), &half);\n        docListDestroy(&half);\n        if( rc!=SQLITE_OK ) goto err;\n      }\n    }\n    rc = term_update(v, iIndexRow, &doclist);\n  }\n\nerr:\n  docListDestroy(&doclist);\n  return rc;\n}\n\n/* Insert a row into the full-text index; set *piRowid to be the ID of the\n * new row. */\nstatic int index_insert(fulltext_vtab *v,\n                        sqlite3_value *pRequestRowid, const char *zText,\n                        sqlite_int64 *piRowid){\n  Hash terms;  /* maps term string -> PosList */\n  HashElem *e;\n\n  int rc = content_insert(v, pRequestRowid, zText, -1);\n  if( rc!=SQLITE_OK ) return rc;\n  *piRowid = sqlite3_last_insert_rowid(v->db);\n\n  if( !zText ) return SQLITE_OK;   /* nothing to index */\n\n  rc = build_terms(&terms, v->pTokenizer, zText, *piRowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(e=HashFirst(&terms); e; e=HashNext(e)){\n    DocList *p = HashData(e);\n    rc = index_insert_term(v, HashKey(e), HashKeysize(e), *piRowid, p);\n    if( rc!=SQLITE_OK ) break;\n  }\n\n  for(e=HashFirst(&terms); e; e=HashNext(e)){\n    DocList *p = HashData(e);\n    docListDelete(p);\n  }\n  HashClear(&terms);\n  return rc;\n}\n\nstatic int index_delete_term(fulltext_vtab *v, const char *zTerm, int nTerm,\n                             sqlite_int64 iDocid){\n  sqlite_int64 iFirst;\n  sqlite_int64 iIndexRow;\n  DocList doclist;\n\n  int rc = term_chunk_select(v, zTerm, nTerm, iDocid, &iFirst);\n  if( rc!=SQLITE_ROW ) return SQLITE_ERROR;\n\n  rc = term_select(v, zTerm, nTerm, iFirst, &iIndexRow, &doclist);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( docListUpdate(&doclist, iDocid, NULL) ){\n    if( doclist.nData>0 ){\n      rc = term_update(v, iIndexRow, &doclist);\n    } else {  /* empty posting list */\n      rc = term_delete(v, iIndexRow);\n    }\n  }\n  docListDestroy(&doclist);\n  return rc;\n}\n\n/* Delete a row from the full-text index. */\nstatic int index_delete(fulltext_vtab *v, sqlite_int64 iRow){\n  char *zText;\n  Hash terms;\n  HashElem *e;\n\n  int rc = content_select(v, iRow, &zText);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = build_terms(&terms, v->pTokenizer, zText, iRow);\n  free(zText);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(e=HashFirst(&terms); e; e=HashNext(e)){\n    rc = index_delete_term(v, HashKey(e), HashKeysize(e), iRow);\n    if( rc!=SQLITE_OK ) break;\n  }\n  for(e=HashFirst(&terms); e; e=HashNext(e)){\n    DocList *p = HashData(e);\n    docListDelete(p);\n  }\n  HashClear(&terms);\n\n  return content_delete(v, iRow);\n}\n\nstatic int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,\n                   sqlite_int64 *pRowid){\n  fulltext_vtab *v = (fulltext_vtab *) pVtab;\n\n  if( nArg<2 ){\n    return index_delete(v, sqlite3_value_int64(ppArg[0]));\n  }\n\n  if( sqlite3_value_type(ppArg[0]) != SQLITE_NULL ){\n    return SQLITE_ERROR;   /* an update; not yet supported */\n  }\n\n  assert( nArg==3 );    /* ppArg[1] = rowid, ppArg[2] = content */\n  return index_insert(v, ppArg[1],\n                      (const char *)sqlite3_value_text(ppArg[2]), pRowid);\n}\n\nstatic sqlite3_module fulltextModule = {\n  0,\n  fulltextCreate,\n  fulltextConnect,\n  fulltextBestIndex,\n  fulltextDisconnect,\n  fulltextDestroy,\n  fulltextOpen,\n  fulltextClose,\n  fulltextFilter,\n  fulltextNext,\n  fulltextEof,\n  fulltextColumn,\n  fulltextRowid,\n  fulltextUpdate\n};\n\nint fulltext_init(sqlite3 *db){\n return sqlite3_create_module(db, \"fulltext\", &fulltextModule, 0);\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fulltext_init(sqlite3 *db, char **pzErrMsg,\n                          const sqlite3_api_routines *pApi){\n SQLITE_EXTENSION_INIT2(pApi)\n return fulltext_init(db);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/fulltext.h",
    "content": "#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint fulltext_init(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/simple_tokenizer.c",
    "content": "/*\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n#include <assert.h>\n#if !defined(__APPLE__)\n#include <malloc.h>\n#else\n#include <stdlib.h>\n#endif\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n\n#include \"tokenizer.h\"\n\n/* Duplicate a string; the caller must free() the returned string.\n * (We don't use strdup() since it's not part of the standard C library and\n * may not be available everywhere.) */\n/* TODO(shess) Copied from fulltext.c, consider util.c for such\n** things. */\nstatic char *string_dup(const char *s){\n  char *str = malloc(strlen(s) + 1);\n  strcpy(str, s);\n  return str;\n}\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  const char *zDelim;          /* token delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  const char *pCurrent;        /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nTokenBytes;             /* actual size of current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\nstatic sqlite3_tokenizer_module simpleTokenizerModule;/* forward declaration */\n\nstatic int simpleCreate(\n  int argc, const char **argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) malloc(sizeof(simple_tokenizer));\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    t->zDelim = string_dup(argv[1]);\n  } else {\n    /* Build a string excluding alphanumeric ASCII characters */\n    char zDelim[0x80];               /* nul-terminated, so nul not a member */\n    int i, j;\n    for(i=1, j=0; i<0x80; i++){\n      if( !isalnum(i) ){\n        zDelim[j++] = i;\n      }\n    }\n    zDelim[j++] = '\\0';\n    assert( j<=sizeof(zDelim) );\n    t->zDelim = string_dup(zDelim);\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  simple_tokenizer *t = (simple_tokenizer *) pTokenizer;\n\n  free((void *) t->zDelim);\n  free(t);\n\n  return SQLITE_OK;\n}\n\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,\n  const char *pInput, int nBytes,\n  sqlite3_tokenizer_cursor **ppCursor\n){\n  simple_tokenizer_cursor *c;\n\n  c = (simple_tokenizer_cursor *) malloc(sizeof(simple_tokenizer_cursor));\n  c->pInput = pInput;\n  c->nBytes = nBytes<0 ? (int) strlen(pInput) : nBytes;\n  c->pCurrent = c->pInput;        /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nTokenBytes = 0;\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n\n  if( NULL!=c->zToken ){\n    free(c->zToken);\n  }\n  free(c);\n\n  return SQLITE_OK;\n}\n\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,\n  const char **ppToken, int *pnBytes,\n  int *piStartOffset, int *piEndOffset, int *piPosition\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  int ii;\n\n  while( c->pCurrent-c->pInput<c->nBytes ){\n    int n = (int) strcspn(c->pCurrent, t->zDelim);\n    if( n>0 ){\n      if( n+1>c->nTokenAllocated ){\n        c->zToken = realloc(c->zToken, n+1);\n      }\n      for(ii=0; ii<n; ii++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        char ch = c->pCurrent[ii];\n        c->zToken[ii] = (unsigned char)ch<0x80 ? tolower((unsigned char)ch):ch;\n      }\n      c->zToken[n] = '\\0';\n      *ppToken = c->zToken;\n      *pnBytes = n;\n      *piStartOffset = (int) (c->pCurrent-c->pInput);\n      *piEndOffset = *piStartOffset+n;\n      *piPosition = c->iToken++;\n      c->pCurrent += n + 1;\n\n      return SQLITE_OK;\n    }\n    c->pCurrent += n + 1;\n    /* TODO(shess) could strspn() to skip delimiters en masse.  Needs\n    ** to happen in two places, though, which is annoying.\n    */\n  }\n  return SQLITE_DONE;\n}\n\nstatic sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n};\n\nvoid get_simple_tokenizer_module(\n  sqlite3_tokenizer_module **ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts1/tokenizer.h",
    "content": "/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _TOKENIZER_H_\n#define _TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Structures used by the tokenizer interface.\n*/\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\n\nstruct sqlite3_tokenizer_module {\n  int iVersion;                  /* currently 0 */\n\n  /*\n  ** Create and destroy a tokenizer.  argc/argv are passed down from\n  ** the fulltext virtual table creation to allow customization.\n  */\n  int (*xCreate)(int argc, const char **argv,\n                 sqlite3_tokenizer **ppTokenizer);\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Tokenize a particular input.  Call xOpen() to prepare to\n  ** tokenize, xNext() repeatedly until it returns SQLITE_DONE, then\n  ** xClose() to free any internal state.  The pInput passed to\n  ** xOpen() must exist until the cursor is closed.  The ppToken\n  ** result from xNext() is only valid until the next call to xNext()\n  ** or until xClose() is called.\n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xOpen)(sqlite3_tokenizer *pTokenizer,\n               const char *pInput, int nBytes,\n               sqlite3_tokenizer_cursor **ppCursor);\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n               const char **ppToken, int *pnBytes,\n               int *piStartOffset, int *piEndOffset, int *piPosition);\n};\n\nstruct sqlite3_tokenizer {\n  sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\n/*\n** Get the module for a tokenizer which generates tokens based on a\n** set of non-token characters.  The default is to break tokens at any\n** non-alnum character, though the set of delimiters can also be\n** specified by the first argv argument to xCreate().\n*/\n/* TODO(shess) This doesn't belong here.  Need some sort of\n** registration process.\n*/\nvoid get_simple_tokenizer_module(sqlite3_tokenizer_module **ppModule);\n\n#endif /* _TOKENIZER_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/README.tokenizers",
    "content": "\n1. FTS2 Tokenizers\n\n  When creating a new full-text table, FTS2 allows the user to select\n  the text tokenizer implementation to be used when indexing text\n  by specifying a \"tokenizer\" clause as part of the CREATE VIRTUAL TABLE\n  statement:\n\n    CREATE VIRTUAL TABLE <table-name> USING fts2(\n      <columns ...> [, tokenizer <tokenizer-name> [<tokenizer-args>]]\n    );\n\n  The built-in tokenizers (valid values to pass as <tokenizer name>) are\n  \"simple\" and \"porter\".\n\n  <tokenizer-args> should consist of zero or more white-space separated\n  arguments to pass to the selected tokenizer implementation. The \n  interpretation of the arguments, if any, depends on the individual \n  tokenizer.\n\n2. Custom Tokenizers\n\n  FTS2 allows users to provide custom tokenizer implementations. The \n  interface used to create a new tokenizer is defined and described in \n  the fts2_tokenizer.h source file.\n\n  Registering a new FTS2 tokenizer is similar to registering a new \n  virtual table module with SQLite. The user passes a pointer to a\n  structure containing pointers to various callback functions that\n  make up the implementation of the new tokenizer type. For tokenizers,\n  the structure (defined in fts2_tokenizer.h) is called\n  \"sqlite3_tokenizer_module\".\n\n  FTS2 does not expose a C-function that users call to register new\n  tokenizer types with a database handle. Instead, the pointer must\n  be encoded as an SQL blob value and passed to FTS2 through the SQL\n  engine by evaluating a special scalar function, \"fts2_tokenizer()\".\n  The fts2_tokenizer() function may be called with one or two arguments,\n  as follows:\n\n    SELECT fts2_tokenizer(<tokenizer-name>);\n    SELECT fts2_tokenizer(<tokenizer-name>, <sqlite3_tokenizer_module ptr>);\n  \n  Where <tokenizer-name> is a string identifying the tokenizer and\n  <sqlite3_tokenizer_module ptr> is a pointer to an sqlite3_tokenizer_module\n  structure encoded as an SQL blob. If the second argument is present,\n  it is registered as tokenizer <tokenizer-name> and a copy of it\n  returned. If only one argument is passed, a pointer to the tokenizer\n  implementation currently registered as <tokenizer-name> is returned,\n  encoded as a blob. Or, if no such tokenizer exists, an SQL exception\n  (error) is raised.\n\n  SECURITY: If the fts2 extension is used in an environment where potentially\n    malicious users may execute arbitrary SQL (i.e. gears), they should be\n    prevented from invoking the fts2_tokenizer() function, possibly using the\n    authorisation callback.\n\n  See \"Sample code\" below for an example of calling the fts2_tokenizer()\n  function from C code.\n\n3. ICU Library Tokenizers\n\n  If this extension is compiled with the SQLITE_ENABLE_ICU pre-processor \n  symbol defined, then there exists a built-in tokenizer named \"icu\" \n  implemented using the ICU library. The first argument passed to the\n  xCreate() method (see fts2_tokenizer.h) of this tokenizer may be\n  an ICU locale identifier. For example \"tr_TR\" for Turkish as used\n  in Turkey, or \"en_AU\" for English as used in Australia. For example:\n\n    \"CREATE VIRTUAL TABLE thai_text USING fts2(text, tokenizer icu th_TH)\"\n\n  The ICU tokenizer implementation is very simple. It splits the input\n  text according to the ICU rules for finding word boundaries and discards\n  any tokens that consist entirely of white-space. This may be suitable\n  for some applications in some locales, but not all. If more complex\n  processing is required, for example to implement stemming or \n  discard punctuation, this can be done by creating a tokenizer \n  implementation that uses the ICU tokenizer as part of its implementation.\n\n  When using the ICU tokenizer this way, it is safe to overwrite the\n  contents of the strings returned by the xNext() method (see\n  fts2_tokenizer.h).\n\n4. Sample code.\n\n  The following two code samples illustrate the way C code should invoke\n  the fts2_tokenizer() scalar function:\n\n      int registerTokenizer(\n        sqlite3 *db, \n        char *zName, \n        const sqlite3_tokenizer_module *p\n      ){\n        int rc;\n        sqlite3_stmt *pStmt;\n        const char zSql[] = \"SELECT fts2_tokenizer(?, ?)\";\n      \n        rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      \n        sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n        sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n        sqlite3_step(pStmt);\n      \n        return sqlite3_finalize(pStmt);\n      }\n      \n      int queryTokenizer(\n        sqlite3 *db, \n        char *zName,  \n        const sqlite3_tokenizer_module **pp\n      ){\n        int rc;\n        sqlite3_stmt *pStmt;\n        const char zSql[] = \"SELECT fts2_tokenizer(?)\";\n      \n        *pp = 0;\n        rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      \n        sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n            memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n          }\n        }\n      \n        return sqlite3_finalize(pStmt);\n      }\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/README.txt",
    "content": "This folder contains source code to the second full-text search\nextension for SQLite.  While the API is the same, this version uses a\nsubstantially different storage schema from fts1, so tables will need\nto be rebuilt.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2.c",
    "content": "/* fts2 has a design flaw which can lead to database corruption (see\n** below).  It is recommended not to use it any longer, instead use\n** fts3 (or higher).  If you believe that your use of fts2 is safe,\n** add -DSQLITE_ENABLE_BROKEN_FTS2=1 to your CFLAGS.\n*/\n#if (!defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)) \\\n        && !defined(SQLITE_ENABLE_BROKEN_FTS2)\n#error fts2 has a design flaw and has been deprecated.\n#endif\n/* The flaw is that fts2 uses the content table's unaliased rowid as\n** the unique docid.  fts2 embeds the rowid in the index it builds,\n** and expects the rowid to not change.  The SQLite VACUUM operation\n** will renumber such rowids, thereby breaking fts2.  If you are using\n** fts2 in a system which has disabled VACUUM, then you can continue\n** to use it safely.  Note that PRAGMA auto_vacuum does NOT disable\n** VACUUM, though systems using auto_vacuum are unlikely to invoke\n** VACUUM.\n**\n** Unlike fts1, which is safe across VACUUM if you never delete\n** documents, fts2 has a second exposure to this flaw, in the segments\n** table.  So fts2 should be considered unsafe across VACUUM in all\n** cases.\n*/\n\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS2 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS2 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS2 is defined).\n*/\n\n/* TODO(shess) Consider exporting this comment to an HTML file or the\n** wiki.\n*/\n/* The full-text index is stored in a series of b+tree (-like)\n** structures called segments which map terms to doclists.  The\n** structures are like b+trees in layout, but are constructed from the\n** bottom up in optimal fashion and are not updatable.  Since trees\n** are built from the bottom up, things will be described from the\n** bottom up.\n**\n**\n**** Varints ****\n** The basic unit of encoding is a variable-length integer called a\n** varint.  We encode variable-length integers in little-endian order\n** using seven bits * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n**\n** This is identical to how sqlite encodes varints (see util.c).\n**\n**\n**** Document lists ****\n** A doclist (document list) holds a docid-sorted list of hits for a\n** given term.  Doclists hold docids, and can optionally associate\n** token positions and offsets with docids.\n**\n** A DL_POSITIONS_OFFSETS doclist is stored like this:\n**\n** array {\n**   varint docid;\n**   array {                (position list for column 0)\n**     varint position;     (delta from previous position plus POS_BASE)\n**     varint startOffset;  (delta from previous startOffset)\n**     varint endOffset;    (delta from startOffset)\n**   }\n**   array {\n**     varint POS_COLUMN;   (marks start of position list for new column)\n**     varint column;       (index of new column)\n**     array {\n**       varint position;   (delta from previous position plus POS_BASE)\n**       varint startOffset;(delta from previous startOffset)\n**       varint endOffset;  (delta from startOffset)\n**     }\n**   }\n**   varint POS_END;        (marks end of positions for this document.\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.  A \"position\" is an index of a token in the token stream\n** generated by the tokenizer, while an \"offset\" is a byte offset,\n** both based at 0.  Note that POS_END and POS_COLUMN occur in the\n** same logical place as the position element, and act as sentinals\n** ending a position list array.\n**\n** A DL_POSITIONS doclist omits the startOffset and endOffset\n** information.  A DL_DOCIDS doclist omits both the position and\n** offset information, becoming an array of varint-encoded docids.\n**\n** On-disk data is stored as type DL_DEFAULT, so we don't serialize\n** the type.  Due to how deletion is implemented in the segmentation\n** system, on-disk doclists MUST store at least positions.\n**\n**\n**** Segment leaf nodes ****\n** Segment leaf nodes store terms and doclists, ordered by term.  Leaf\n** nodes are written using LeafWriter, and read using LeafReader (to\n** iterate through a single leaf node's data) and LeavesReader (to\n** iterate through a segment's entire leaf layer).  Leaf nodes have\n** the format:\n**\n** varint iHeight;             (height from leaf level, always 0)\n** varint nTerm;               (length of first term)\n** char pTerm[nTerm];          (content of first term)\n** varint nDoclist;            (length of term's associated doclist)\n** char pDoclist[nDoclist];    (content of doclist)\n** array {\n**                             (further terms are delta-encoded)\n**   varint nPrefix;           (length of prefix shared with previous term)\n**   varint nSuffix;           (length of unshared suffix)\n**   char pTermSuffix[nSuffix];(unshared suffix of next term)\n**   varint nDoclist;          (length of term's associated doclist)\n**   char pDoclist[nDoclist];  (content of doclist)\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.\n**\n** Leaf nodes are broken into blocks which are stored contiguously in\n** the %_segments table in sorted order.  This means that when the end\n** of a node is reached, the next term is in the node with the next\n** greater node id.\n**\n** New data is spilled to a new leaf node when the current node\n** exceeds LEAF_MAX bytes (default 2048).  New data which itself is\n** larger than STANDALONE_MIN (default 1024) is placed in a standalone\n** node (a leaf node with a single term and doclist).  The goal of\n** these settings is to pack together groups of small doclists while\n** making it efficient to directly access large doclists.  The\n** assumption is that large doclists represent terms which are more\n** likely to be query targets.\n**\n** TODO(shess) It may be useful for blocking decisions to be more\n** dynamic.  For instance, it may make more sense to have a 2.5k leaf\n** node rather than splitting into 2k and .5k nodes.  My intuition is\n** that this might extend through 2x or 4x the pagesize.\n**\n**\n**** Segment interior nodes ****\n** Segment interior nodes store blockids for subtree nodes and terms\n** to describe what data is stored by the each subtree.  Interior\n** nodes are written using InteriorWriter, and read using\n** InteriorReader.  InteriorWriters are created as needed when\n** SegmentWriter creates new leaf nodes, or when an interior node\n** itself grows too big and must be split.  The format of interior\n** nodes:\n**\n** varint iHeight;           (height from leaf level, always >0)\n** varint iBlockid;          (block id of node's leftmost subtree)\n** optional {\n**   varint nTerm;           (length of first term)\n**   char pTerm[nTerm];      (content of first term)\n**   array {\n**                                (further terms are delta-encoded)\n**     varint nPrefix;            (length of shared prefix with previous term)\n**     varint nSuffix;            (length of unshared suffix)\n**     char pTermSuffix[nSuffix]; (unshared suffix of next term)\n**   }\n** }\n**\n** Here, optional { X } means an optional element, while array { X }\n** means zero or more occurrences of X, adjacent in memory.\n**\n** An interior node encodes n terms separating n+1 subtrees.  The\n** subtree blocks are contiguous, so only the first subtree's blockid\n** is encoded.  The subtree at iBlockid will contain all terms less\n** than the first term encoded (or all terms if no term is encoded).\n** Otherwise, for terms greater than or equal to pTerm[i] but less\n** than pTerm[i+1], the subtree for that term will be rooted at\n** iBlockid+i.  Interior nodes only store enough term data to\n** distinguish adjacent children (if the rightmost term of the left\n** child is \"something\", and the leftmost term of the right child is\n** \"wicked\", only \"w\" is stored).\n**\n** New data is spilled to a new interior node at the same height when\n** the current node exceeds INTERIOR_MAX bytes (default 2048).\n** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing\n** interior nodes and making the tree too skinny.  The interior nodes\n** at a given height are naturally tracked by interior nodes at\n** height+1, and so on.\n**\n**\n**** Segment directory ****\n** The segment directory in table %_segdir stores meta-information for\n** merging and deleting segments, and also the root node of the\n** segment's tree.\n**\n** The root node is the top node of the segment's tree after encoding\n** the entire segment, restricted to ROOT_MAX bytes (default 1024).\n** This could be either a leaf node or an interior node.  If the top\n** node requires more than ROOT_MAX bytes, it is flushed to %_segments\n** and a new root interior node is generated (which should always fit\n** within ROOT_MAX because it only needs space for 2 varints, the\n** height and the blockid of the previous root).\n**\n** The meta-information in the segment directory is:\n**   level               - segment level (see below)\n**   idx                 - index within level\n**                       - (level,idx uniquely identify a segment)\n**   start_block         - first leaf node\n**   leaves_end_block    - last leaf node\n**   end_block           - last block (including interior nodes)\n**   root                - contents of root node\n**\n** If the root node is a leaf node, then start_block,\n** leaves_end_block, and end_block are all 0.\n**\n**\n**** Segment merging ****\n** To amortize update costs, segments are groups into levels and\n** merged in matches.  Each increase in level represents exponentially\n** more documents.\n**\n** New documents (actually, document updates) are tokenized and\n** written individually (using LeafWriter) to a level 0 segment, with\n** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all\n** level 0 segments are merged into a single level 1 segment.  Level 1\n** is populated like level 0, and eventually MERGE_COUNT level 1\n** segments are merged to a single level 2 segment (representing\n** MERGE_COUNT^2 updates), and so on.\n**\n** A segment merge traverses all segments at a given level in\n** parallel, performing a straightforward sorted merge.  Since segment\n** leaf nodes are written in to the %_segments table in order, this\n** merge traverses the underlying sqlite disk structures efficiently.\n** After the merge, all segment blocks from the merged level are\n** deleted.\n**\n** MERGE_COUNT controls how often we merge segments.  16 seems to be\n** somewhat of a sweet spot for insertion performance.  32 and 64 show\n** very similar performance numbers to 16 on insertion, though they're\n** a tiny bit slower (perhaps due to more overhead in merge-time\n** sorting).  8 is about 20% slower than 16, 4 about 50% slower than\n** 16, 2 about 66% slower than 16.\n**\n** At query time, high MERGE_COUNT increases the number of segments\n** which need to be scanned and merged.  For instance, with 100k docs\n** inserted:\n**\n**    MERGE_COUNT   segments\n**       16           25\n**        8           12\n**        4           10\n**        2            6\n**\n** This appears to have only a moderate impact on queries for very\n** frequent terms (which are somewhat dominated by segment merge\n** costs), and infrequent and non-existent terms still seem to be fast\n** even with many segments.\n**\n** TODO(shess) That said, it would be nice to have a better query-side\n** argument for MERGE_COUNT of 16.  Also, it is possible/likely that\n** optimizations to things like doclist merging will swing the sweet\n** spot around.\n**\n**\n**\n**** Handling of deletions and updates ****\n** Since we're using a segmented structure, with no docid-oriented\n** index into the term index, we clearly cannot simply update the term\n** index when a document is deleted or updated.  For deletions, we\n** write an empty doclist (varint(docid) varint(POS_END)), for updates\n** we simply write the new doclist.  Segment merges overwrite older\n** data for a particular docid with newer data, so deletes or updates\n** will eventually overtake the earlier data and knock it out.  The\n** query logic likewise merges doclists so that newer data knocks out\n** older data.\n**\n** TODO(shess) Provide a VACUUM type operation to clear out all\n** deletions and duplications.  This would basically be a forced merge\n** into a single segment.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n\n#if defined(SQLITE_ENABLE_FTS2) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include \"fts2.h\"\n#include \"fts2_hash.h\"\n#include \"fts2_tokenizer.h\"\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n\n/* TODO(shess) MAN, this thing needs some refactoring.  At minimum, it\n** would be nice to order the file better, perhaps something along the\n** lines of:\n**\n**  - utility functions\n**  - table setup functions\n**  - table update functions\n**  - table query functions\n**\n** Put the query functions last because they're likely to reference\n** typedefs or functions from the table update section.\n*/\n\n#if 0\n# define TRACE(A)  printf A; fflush(stdout)\n#else\n# define TRACE(A)\n#endif\n\n/* It is not safe to call isspace(), tolower(), or isalnum() on\n** hi-bit-set characters.  This is the same solution used in the\n** tokenizer.\n*/\n/* TODO(shess) The snippet-generation code should be using the\n** tokenizer-generated tokens rather than doing its own local\n** tokenization.\n*/\n/* TODO(shess) Is __isascii() a portable version of (c&0x80)==0? */\nstatic int safe_isspace(char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\nstatic int safe_tolower(char c){\n  return (c>='A' && c<='Z') ? (c - 'A' + 'a') : c;\n}\nstatic int safe_isalnum(char c){\n  return (c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z');\n}\n\ntypedef enum DocListType {\n  DL_DOCIDS,              /* docids only */\n  DL_POSITIONS,           /* docids + positions */\n  DL_POSITIONS_OFFSETS    /* docids + positions + offsets */\n} DocListType;\n\n/*\n** By default, only positions and not offsets are stored in the doclists.\n** To change this so that offsets are stored too, compile with\n**\n**          -DDL_DEFAULT=DL_POSITIONS_OFFSETS\n**\n** If DL_DEFAULT is set to DL_DOCIDS, your table can only be inserted\n** into (no deletes or updates).\n*/\n#ifndef DL_DEFAULT\n# define DL_DEFAULT DL_POSITIONS\n#endif\n\nenum {\n  POS_END = 0,        /* end of this position list */\n  POS_COLUMN,         /* followed by new column number */\n  POS_BASE\n};\n\n/* MERGE_COUNT controls how often we merge segments (see comment at\n** top of file).\n*/\n#define MERGE_COUNT 16\n\n/* utility functions */\n\n/* CLEAR() and SCRAMBLE() abstract memset() on a pointer to a single\n** record to prevent errors of the form:\n**\n** my_function(SomeType *b){\n**   memset(b, '\\0', sizeof(b));  // sizeof(b)!=sizeof(*b)\n** }\n*/\n/* TODO(shess) Obvious candidates for a header file. */\n#define CLEAR(b) memset(b, '\\0', sizeof(*(b)))\n\n#ifndef NDEBUG\n#  define SCRAMBLE(b) memset(b, 0x55, sizeof(*(b)))\n#else\n#  define SCRAMBLE(b)\n#endif\n\n/* We may need up to VARINT_MAX bytes to store an encoded 64-bit integer. */\n#define VARINT_MAX 10\n\n/* Write a 64-bit variable-length integer to memory starting at p[0].\n * The length of data written will be between 1 and VARINT_MAX bytes.\n * The number of bytes written is returned. */\nstatic int putVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n/* Read a 64-bit variable-length integer from memory starting at p[0].\n * Return the number of bytes read, or 0 on error.\n * The value is stored in *v. */\nstatic int getVarint(const char *p, sqlite_int64 *v){\n  const unsigned char *q = (const unsigned char *) p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q & 0x80) == 0x80 ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n    if( q - (unsigned char *)p >= VARINT_MAX ){  /* bad data */\n      assert( 0 );\n      return 0;\n    }\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\nstatic int getVarint32(const char *p, int *pi){\n sqlite_int64 i;\n int ret = getVarint(p, &i);\n *pi = (int) i;\n assert( *pi==i );\n return ret;\n}\n\n/*******************************************************************/\n/* DataBuffer is used to collect data into a buffer in piecemeal\n** fashion.  It implements the usual distinction between amount of\n** data currently stored (nData) and buffer capacity (nCapacity).\n**\n** dataBufferInit - create a buffer with given initial capacity.\n** dataBufferReset - forget buffer's data, retaining capacity.\n** dataBufferDestroy - free buffer's data.\n** dataBufferSwap - swap contents of two buffers.\n** dataBufferExpand - expand capacity without adding data.\n** dataBufferAppend - append data.\n** dataBufferAppend2 - append two pieces of data at once.\n** dataBufferReplace - replace buffer's data.\n*/\ntypedef struct DataBuffer {\n  char *pData;          /* Pointer to malloc'ed buffer. */\n  int nCapacity;        /* Size of pData buffer. */\n  int nData;            /* End of data loaded into pData. */\n} DataBuffer;\n\nstatic void dataBufferInit(DataBuffer *pBuffer, int nCapacity){\n  assert( nCapacity>=0 );\n  pBuffer->nData = 0;\n  pBuffer->nCapacity = nCapacity;\n  pBuffer->pData = nCapacity==0 ? NULL : sqlite3_malloc(nCapacity);\n}\nstatic void dataBufferReset(DataBuffer *pBuffer){\n  pBuffer->nData = 0;\n}\nstatic void dataBufferDestroy(DataBuffer *pBuffer){\n  if( pBuffer->pData!=NULL ) sqlite3_free(pBuffer->pData);\n  SCRAMBLE(pBuffer);\n}\nstatic void dataBufferSwap(DataBuffer *pBuffer1, DataBuffer *pBuffer2){\n  DataBuffer tmp = *pBuffer1;\n  *pBuffer1 = *pBuffer2;\n  *pBuffer2 = tmp;\n}\nstatic void dataBufferExpand(DataBuffer *pBuffer, int nAddCapacity){\n  assert( nAddCapacity>0 );\n  /* TODO(shess) Consider expanding more aggressively.  Note that the\n  ** underlying malloc implementation may take care of such things for\n  ** us already.\n  */\n  if( pBuffer->nData+nAddCapacity>pBuffer->nCapacity ){\n    pBuffer->nCapacity = pBuffer->nData+nAddCapacity;\n    pBuffer->pData = sqlite3_realloc(pBuffer->pData, pBuffer->nCapacity);\n  }\n}\nstatic void dataBufferAppend(DataBuffer *pBuffer,\n                             const char *pSource, int nSource){\n  assert( nSource>0 && pSource!=NULL );\n  dataBufferExpand(pBuffer, nSource);\n  memcpy(pBuffer->pData+pBuffer->nData, pSource, nSource);\n  pBuffer->nData += nSource;\n}\nstatic void dataBufferAppend2(DataBuffer *pBuffer,\n                              const char *pSource1, int nSource1,\n                              const char *pSource2, int nSource2){\n  assert( nSource1>0 && pSource1!=NULL );\n  assert( nSource2>0 && pSource2!=NULL );\n  dataBufferExpand(pBuffer, nSource1+nSource2);\n  memcpy(pBuffer->pData+pBuffer->nData, pSource1, nSource1);\n  memcpy(pBuffer->pData+pBuffer->nData+nSource1, pSource2, nSource2);\n  pBuffer->nData += nSource1+nSource2;\n}\nstatic void dataBufferReplace(DataBuffer *pBuffer,\n                              const char *pSource, int nSource){\n  dataBufferReset(pBuffer);\n  dataBufferAppend(pBuffer, pSource, nSource);\n}\n\n/* StringBuffer is a null-terminated version of DataBuffer. */\ntypedef struct StringBuffer {\n  DataBuffer b;            /* Includes null terminator. */\n} StringBuffer;\n\nstatic void initStringBuffer(StringBuffer *sb){\n  dataBufferInit(&sb->b, 100);\n  dataBufferReplace(&sb->b, \"\", 1);\n}\nstatic int stringBufferLength(StringBuffer *sb){\n  return sb->b.nData-1;\n}\nstatic char *stringBufferData(StringBuffer *sb){\n  return sb->b.pData;\n}\nstatic void stringBufferDestroy(StringBuffer *sb){\n  dataBufferDestroy(&sb->b);\n}\n\nstatic void nappend(StringBuffer *sb, const char *zFrom, int nFrom){\n  assert( sb->b.nData>0 );\n  if( nFrom>0 ){\n    sb->b.nData--;\n    dataBufferAppend2(&sb->b, zFrom, nFrom, \"\", 1);\n  }\n}\nstatic void append(StringBuffer *sb, const char *zFrom){\n  nappend(sb, zFrom, strlen(zFrom));\n}\n\n/* Append a list of strings separated by commas. */\nstatic void appendList(StringBuffer *sb, int nString, char **azString){\n  int i;\n  for(i=0; i<nString; ++i){\n    if( i>0 ) append(sb, \", \");\n    append(sb, azString[i]);\n  }\n}\n\nstatic int endsInWhiteSpace(StringBuffer *p){\n  return stringBufferLength(p)>0 &&\n    safe_isspace(stringBufferData(p)[stringBufferLength(p)-1]);\n}\n\n/* If the StringBuffer ends in something other than white space, add a\n** single space character to the end.\n*/\nstatic void appendWhiteSpace(StringBuffer *p){\n  if( stringBufferLength(p)==0 ) return;\n  if( !endsInWhiteSpace(p) ) append(p, \" \");\n}\n\n/* Remove white space from the end of the StringBuffer */\nstatic void trimWhiteSpace(StringBuffer *p){\n  while( endsInWhiteSpace(p) ){\n    p->b.pData[--p->b.nData-1] = '\\0';\n  }\n}\n\n/*******************************************************************/\n/* DLReader is used to read document elements from a doclist.  The\n** current docid is cached, so dlrDocid() is fast.  DLReader does not\n** own the doclist buffer.\n**\n** dlrAtEnd - true if there's no more data to read.\n** dlrDocid - docid of current document.\n** dlrDocData - doclist data for current document (including docid).\n** dlrDocDataBytes - length of same.\n** dlrAllDataBytes - length of all remaining data.\n** dlrPosData - position data for current document.\n** dlrPosDataLen - length of pos data for current document (incl POS_END).\n** dlrStep - step to current document.\n** dlrInit - initial for doclist of given type against given data.\n** dlrDestroy - clean up.\n**\n** Expected usage is something like:\n**\n**   DLReader reader;\n**   dlrInit(&reader, pData, nData);\n**   while( !dlrAtEnd(&reader) ){\n**     // calls to dlrDocid() and kin.\n**     dlrStep(&reader);\n**   }\n**   dlrDestroy(&reader);\n*/\ntypedef struct DLReader {\n  DocListType iType;\n  const char *pData;\n  int nData;\n\n  sqlite_int64 iDocid;\n  int nElement;\n} DLReader;\n\nstatic int dlrAtEnd(DLReader *pReader){\n  assert( pReader->nData>=0 );\n  return pReader->nData==0;\n}\nstatic sqlite_int64 dlrDocid(DLReader *pReader){\n  assert( !dlrAtEnd(pReader) );\n  return pReader->iDocid;\n}\nstatic const char *dlrDocData(DLReader *pReader){\n  assert( !dlrAtEnd(pReader) );\n  return pReader->pData;\n}\nstatic int dlrDocDataBytes(DLReader *pReader){\n  assert( !dlrAtEnd(pReader) );\n  return pReader->nElement;\n}\nstatic int dlrAllDataBytes(DLReader *pReader){\n  assert( !dlrAtEnd(pReader) );\n  return pReader->nData;\n}\n/* TODO(shess) Consider adding a field to track iDocid varint length\n** to make these two functions faster.  This might matter (a tiny bit)\n** for queries.\n*/\nstatic const char *dlrPosData(DLReader *pReader){\n  sqlite_int64 iDummy;\n  int n = getVarint(pReader->pData, &iDummy);\n  assert( !dlrAtEnd(pReader) );\n  return pReader->pData+n;\n}\nstatic int dlrPosDataLen(DLReader *pReader){\n  sqlite_int64 iDummy;\n  int n = getVarint(pReader->pData, &iDummy);\n  assert( !dlrAtEnd(pReader) );\n  return pReader->nElement-n;\n}\nstatic void dlrStep(DLReader *pReader){\n  assert( !dlrAtEnd(pReader) );\n\n  /* Skip past current doclist element. */\n  assert( pReader->nElement<=pReader->nData );\n  pReader->pData += pReader->nElement;\n  pReader->nData -= pReader->nElement;\n\n  /* If there is more data, read the next doclist element. */\n  if( pReader->nData!=0 ){\n    sqlite_int64 iDocidDelta;\n    int iDummy, n = getVarint(pReader->pData, &iDocidDelta);\n    pReader->iDocid += iDocidDelta;\n    if( pReader->iType>=DL_POSITIONS ){\n      assert( n<pReader->nData );\n      while( 1 ){\n        n += getVarint32(pReader->pData+n, &iDummy);\n        assert( n<=pReader->nData );\n        if( iDummy==POS_END ) break;\n        if( iDummy==POS_COLUMN ){\n          n += getVarint32(pReader->pData+n, &iDummy);\n          assert( n<pReader->nData );\n        }else if( pReader->iType==DL_POSITIONS_OFFSETS ){\n          n += getVarint32(pReader->pData+n, &iDummy);\n          n += getVarint32(pReader->pData+n, &iDummy);\n          assert( n<pReader->nData );\n        }\n      }\n    }\n    pReader->nElement = n;\n    assert( pReader->nElement<=pReader->nData );\n  }\n}\nstatic void dlrInit(DLReader *pReader, DocListType iType,\n                    const char *pData, int nData){\n  assert( pData!=NULL && nData!=0 );\n  pReader->iType = iType;\n  pReader->pData = pData;\n  pReader->nData = nData;\n  pReader->nElement = 0;\n  pReader->iDocid = 0;\n\n  /* Load the first element's data.  There must be a first element. */\n  dlrStep(pReader);\n}\nstatic void dlrDestroy(DLReader *pReader){\n  SCRAMBLE(pReader);\n}\n\n#ifndef NDEBUG\n/* Verify that the doclist can be validly decoded.  Also returns the\n** last docid found because it is convenient in other assertions for\n** DLWriter.\n*/\nstatic void docListValidate(DocListType iType, const char *pData, int nData,\n                            sqlite_int64 *pLastDocid){\n  sqlite_int64 iPrevDocid = 0;\n  assert( nData>0 );\n  assert( pData!=0 );\n  assert( pData+nData>pData );\n  while( nData!=0 ){\n    sqlite_int64 iDocidDelta;\n    int n = getVarint(pData, &iDocidDelta);\n    iPrevDocid += iDocidDelta;\n    if( iType>DL_DOCIDS ){\n      int iDummy;\n      while( 1 ){\n        n += getVarint32(pData+n, &iDummy);\n        if( iDummy==POS_END ) break;\n        if( iDummy==POS_COLUMN ){\n          n += getVarint32(pData+n, &iDummy);\n        }else if( iType>DL_POSITIONS ){\n          n += getVarint32(pData+n, &iDummy);\n          n += getVarint32(pData+n, &iDummy);\n        }\n        assert( n<=nData );\n      }\n    }\n    assert( n<=nData );\n    pData += n;\n    nData -= n;\n  }\n  if( pLastDocid ) *pLastDocid = iPrevDocid;\n}\n#define ASSERT_VALID_DOCLIST(i, p, n, o) docListValidate(i, p, n, o)\n#else\n#define ASSERT_VALID_DOCLIST(i, p, n, o) assert( 1 )\n#endif\n\n/*******************************************************************/\n/* DLWriter is used to write doclist data to a DataBuffer.  DLWriter\n** always appends to the buffer and does not own it.\n**\n** dlwInit - initialize to write a given type doclistto a buffer.\n** dlwDestroy - clear the writer's memory.  Does not free buffer.\n** dlwAppend - append raw doclist data to buffer.\n** dlwCopy - copy next doclist from reader to writer.\n** dlwAdd - construct doclist element and append to buffer.\n**    Only apply dlwAdd() to DL_DOCIDS doclists (else use PLWriter).\n*/\ntypedef struct DLWriter {\n  DocListType iType;\n  DataBuffer *b;\n  sqlite_int64 iPrevDocid;\n#ifndef NDEBUG\n  int has_iPrevDocid;\n#endif\n} DLWriter;\n\nstatic void dlwInit(DLWriter *pWriter, DocListType iType, DataBuffer *b){\n  pWriter->b = b;\n  pWriter->iType = iType;\n  pWriter->iPrevDocid = 0;\n#ifndef NDEBUG\n  pWriter->has_iPrevDocid = 0;\n#endif\n}\nstatic void dlwDestroy(DLWriter *pWriter){\n  SCRAMBLE(pWriter);\n}\n/* iFirstDocid is the first docid in the doclist in pData.  It is\n** needed because pData may point within a larger doclist, in which\n** case the first item would be delta-encoded.\n**\n** iLastDocid is the final docid in the doclist in pData.  It is\n** needed to create the new iPrevDocid for future delta-encoding.  The\n** code could decode the passed doclist to recreate iLastDocid, but\n** the only current user (docListMerge) already has decoded this\n** information.\n*/\n/* TODO(shess) This has become just a helper for docListMerge.\n** Consider a refactor to make this cleaner.\n*/\nstatic void dlwAppend(DLWriter *pWriter,\n                      const char *pData, int nData,\n                      sqlite_int64 iFirstDocid, sqlite_int64 iLastDocid){\n  sqlite_int64 iDocid = 0;\n  char c[VARINT_MAX];\n  int nFirstOld, nFirstNew;     /* Old and new varint len of first docid. */\n#ifndef NDEBUG\n  sqlite_int64 iLastDocidDelta;\n#endif\n\n  /* Recode the initial docid as delta from iPrevDocid. */\n  nFirstOld = getVarint(pData, &iDocid);\n  assert( nFirstOld<nData || (nFirstOld==nData && pWriter->iType==DL_DOCIDS) );\n  nFirstNew = putVarint(c, iFirstDocid-pWriter->iPrevDocid);\n\n  /* Verify that the incoming doclist is valid AND that it ends with\n  ** the expected docid.  This is essential because we'll trust this\n  ** docid in future delta-encoding.\n  */\n  ASSERT_VALID_DOCLIST(pWriter->iType, pData, nData, &iLastDocidDelta);\n  assert( iLastDocid==iFirstDocid-iDocid+iLastDocidDelta );\n\n  /* Append recoded initial docid and everything else.  Rest of docids\n  ** should have been delta-encoded from previous initial docid.\n  */\n  if( nFirstOld<nData ){\n    dataBufferAppend2(pWriter->b, c, nFirstNew,\n                      pData+nFirstOld, nData-nFirstOld);\n  }else{\n    dataBufferAppend(pWriter->b, c, nFirstNew);\n  }\n  pWriter->iPrevDocid = iLastDocid;\n}\nstatic void dlwCopy(DLWriter *pWriter, DLReader *pReader){\n  dlwAppend(pWriter, dlrDocData(pReader), dlrDocDataBytes(pReader),\n            dlrDocid(pReader), dlrDocid(pReader));\n}\nstatic void dlwAdd(DLWriter *pWriter, sqlite_int64 iDocid){\n  char c[VARINT_MAX];\n  int n = putVarint(c, iDocid-pWriter->iPrevDocid);\n\n  /* Docids must ascend. */\n  assert( !pWriter->has_iPrevDocid || iDocid>pWriter->iPrevDocid );\n  assert( pWriter->iType==DL_DOCIDS );\n\n  dataBufferAppend(pWriter->b, c, n);\n  pWriter->iPrevDocid = iDocid;\n#ifndef NDEBUG\n  pWriter->has_iPrevDocid = 1;\n#endif\n}\n\n/*******************************************************************/\n/* PLReader is used to read data from a document's position list.  As\n** the caller steps through the list, data is cached so that varints\n** only need to be decoded once.\n**\n** plrInit, plrDestroy - create/destroy a reader.\n** plrColumn, plrPosition, plrStartOffset, plrEndOffset - accessors\n** plrAtEnd - at end of stream, only call plrDestroy once true.\n** plrStep - step to the next element.\n*/\ntypedef struct PLReader {\n  /* These refer to the next position's data.  nData will reach 0 when\n  ** reading the last position, so plrStep() signals EOF by setting\n  ** pData to NULL.\n  */\n  const char *pData;\n  int nData;\n\n  DocListType iType;\n  int iColumn;         /* the last column read */\n  int iPosition;       /* the last position read */\n  int iStartOffset;    /* the last start offset read */\n  int iEndOffset;      /* the last end offset read */\n} PLReader;\n\nstatic int plrAtEnd(PLReader *pReader){\n  return pReader->pData==NULL;\n}\nstatic int plrColumn(PLReader *pReader){\n  assert( !plrAtEnd(pReader) );\n  return pReader->iColumn;\n}\nstatic int plrPosition(PLReader *pReader){\n  assert( !plrAtEnd(pReader) );\n  return pReader->iPosition;\n}\nstatic int plrStartOffset(PLReader *pReader){\n  assert( !plrAtEnd(pReader) );\n  return pReader->iStartOffset;\n}\nstatic int plrEndOffset(PLReader *pReader){\n  assert( !plrAtEnd(pReader) );\n  return pReader->iEndOffset;\n}\nstatic void plrStep(PLReader *pReader){\n  int i, n;\n\n  assert( !plrAtEnd(pReader) );\n\n  if( pReader->nData==0 ){\n    pReader->pData = NULL;\n    return;\n  }\n\n  n = getVarint32(pReader->pData, &i);\n  if( i==POS_COLUMN ){\n    n += getVarint32(pReader->pData+n, &pReader->iColumn);\n    pReader->iPosition = 0;\n    pReader->iStartOffset = 0;\n    n += getVarint32(pReader->pData+n, &i);\n  }\n  /* Should never see adjacent column changes. */\n  assert( i!=POS_COLUMN );\n\n  if( i==POS_END ){\n    pReader->nData = 0;\n    pReader->pData = NULL;\n    return;\n  }\n\n  pReader->iPosition += i-POS_BASE;\n  if( pReader->iType==DL_POSITIONS_OFFSETS ){\n    n += getVarint32(pReader->pData+n, &i);\n    pReader->iStartOffset += i;\n    n += getVarint32(pReader->pData+n, &i);\n    pReader->iEndOffset = pReader->iStartOffset+i;\n  }\n  assert( n<=pReader->nData );\n  pReader->pData += n;\n  pReader->nData -= n;\n}\n\nstatic void plrInit(PLReader *pReader, DLReader *pDLReader){\n  pReader->pData = dlrPosData(pDLReader);\n  pReader->nData = dlrPosDataLen(pDLReader);\n  pReader->iType = pDLReader->iType;\n  pReader->iColumn = 0;\n  pReader->iPosition = 0;\n  pReader->iStartOffset = 0;\n  pReader->iEndOffset = 0;\n  plrStep(pReader);\n}\nstatic void plrDestroy(PLReader *pReader){\n  SCRAMBLE(pReader);\n}\n\n/*******************************************************************/\n/* PLWriter is used in constructing a document's position list.  As a\n** convenience, if iType is DL_DOCIDS, PLWriter becomes a no-op.\n** PLWriter writes to the associated DLWriter's buffer.\n**\n** plwInit - init for writing a document's poslist.\n** plwDestroy - clear a writer.\n** plwAdd - append position and offset information.\n** plwCopy - copy next position's data from reader to writer.\n** plwTerminate - add any necessary doclist terminator.\n**\n** Calling plwAdd() after plwTerminate() may result in a corrupt\n** doclist.\n*/\n/* TODO(shess) Until we've written the second item, we can cache the\n** first item's information.  Then we'd have three states:\n**\n** - initialized with docid, no positions.\n** - docid and one position.\n** - docid and multiple positions.\n**\n** Only the last state needs to actually write to dlw->b, which would\n** be an improvement in the DLCollector case.\n*/\ntypedef struct PLWriter {\n  DLWriter *dlw;\n\n  int iColumn;    /* the last column written */\n  int iPos;       /* the last position written */\n  int iOffset;    /* the last start offset written */\n} PLWriter;\n\n/* TODO(shess) In the case where the parent is reading these values\n** from a PLReader, we could optimize to a copy if that PLReader has\n** the same type as pWriter.\n*/\nstatic void plwAdd(PLWriter *pWriter, int iColumn, int iPos,\n                   int iStartOffset, int iEndOffset){\n  /* Worst-case space for POS_COLUMN, iColumn, iPosDelta,\n  ** iStartOffsetDelta, and iEndOffsetDelta.\n  */\n  char c[5*VARINT_MAX];\n  int n = 0;\n\n  /* Ban plwAdd() after plwTerminate(). */\n  assert( pWriter->iPos!=-1 );\n\n  if( pWriter->dlw->iType==DL_DOCIDS ) return;\n\n  if( iColumn!=pWriter->iColumn ){\n    n += putVarint(c+n, POS_COLUMN);\n    n += putVarint(c+n, iColumn);\n    pWriter->iColumn = iColumn;\n    pWriter->iPos = 0;\n    pWriter->iOffset = 0;\n  }\n  assert( iPos>=pWriter->iPos );\n  n += putVarint(c+n, POS_BASE+(iPos-pWriter->iPos));\n  pWriter->iPos = iPos;\n  if( pWriter->dlw->iType==DL_POSITIONS_OFFSETS ){\n    assert( iStartOffset>=pWriter->iOffset );\n    n += putVarint(c+n, iStartOffset-pWriter->iOffset);\n    pWriter->iOffset = iStartOffset;\n    assert( iEndOffset>=iStartOffset );\n    n += putVarint(c+n, iEndOffset-iStartOffset);\n  }\n  dataBufferAppend(pWriter->dlw->b, c, n);\n}\nstatic void plwCopy(PLWriter *pWriter, PLReader *pReader){\n  plwAdd(pWriter, plrColumn(pReader), plrPosition(pReader),\n         plrStartOffset(pReader), plrEndOffset(pReader));\n}\nstatic void plwInit(PLWriter *pWriter, DLWriter *dlw, sqlite_int64 iDocid){\n  char c[VARINT_MAX];\n  int n;\n\n  pWriter->dlw = dlw;\n\n  /* Docids must ascend. */\n  assert( !pWriter->dlw->has_iPrevDocid || iDocid>pWriter->dlw->iPrevDocid );\n  n = putVarint(c, iDocid-pWriter->dlw->iPrevDocid);\n  dataBufferAppend(pWriter->dlw->b, c, n);\n  pWriter->dlw->iPrevDocid = iDocid;\n#ifndef NDEBUG\n  pWriter->dlw->has_iPrevDocid = 1;\n#endif\n\n  pWriter->iColumn = 0;\n  pWriter->iPos = 0;\n  pWriter->iOffset = 0;\n}\n/* TODO(shess) Should plwDestroy() also terminate the doclist?  But\n** then plwDestroy() would no longer be just a destructor, it would\n** also be doing work, which isn't consistent with the overall idiom.\n** Another option would be for plwAdd() to always append any necessary\n** terminator, so that the output is always correct.  But that would\n** add incremental work to the common case with the only benefit being\n** API elegance.  Punt for now.\n*/\nstatic void plwTerminate(PLWriter *pWriter){\n  if( pWriter->dlw->iType>DL_DOCIDS ){\n    char c[VARINT_MAX];\n    int n = putVarint(c, POS_END);\n    dataBufferAppend(pWriter->dlw->b, c, n);\n  }\n#ifndef NDEBUG\n  /* Mark as terminated for assert in plwAdd(). */\n  pWriter->iPos = -1;\n#endif\n}\nstatic void plwDestroy(PLWriter *pWriter){\n  SCRAMBLE(pWriter);\n}\n\n/*******************************************************************/\n/* DLCollector wraps PLWriter and DLWriter to provide a\n** dynamically-allocated doclist area to use during tokenization.\n**\n** dlcNew - malloc up and initialize a collector.\n** dlcDelete - destroy a collector and all contained items.\n** dlcAddPos - append position and offset information.\n** dlcAddDoclist - add the collected doclist to the given buffer.\n** dlcNext - terminate the current document and open another.\n*/\ntypedef struct DLCollector {\n  DataBuffer b;\n  DLWriter dlw;\n  PLWriter plw;\n} DLCollector;\n\n/* TODO(shess) This could also be done by calling plwTerminate() and\n** dataBufferAppend().  I tried that, expecting nominal performance\n** differences, but it seemed to pretty reliably be worth 1% to code\n** it this way.  I suspect it is the incremental malloc overhead (some\n** percentage of the plwTerminate() calls will cause a realloc), so\n** this might be worth revisiting if the DataBuffer implementation\n** changes.\n*/\nstatic void dlcAddDoclist(DLCollector *pCollector, DataBuffer *b){\n  if( pCollector->dlw.iType>DL_DOCIDS ){\n    char c[VARINT_MAX];\n    int n = putVarint(c, POS_END);\n    dataBufferAppend2(b, pCollector->b.pData, pCollector->b.nData, c, n);\n  }else{\n    dataBufferAppend(b, pCollector->b.pData, pCollector->b.nData);\n  }\n}\nstatic void dlcNext(DLCollector *pCollector, sqlite_int64 iDocid){\n  plwTerminate(&pCollector->plw);\n  plwDestroy(&pCollector->plw);\n  plwInit(&pCollector->plw, &pCollector->dlw, iDocid);\n}\nstatic void dlcAddPos(DLCollector *pCollector, int iColumn, int iPos,\n                      int iStartOffset, int iEndOffset){\n  plwAdd(&pCollector->plw, iColumn, iPos, iStartOffset, iEndOffset);\n}\n\nstatic DLCollector *dlcNew(sqlite_int64 iDocid, DocListType iType){\n  DLCollector *pCollector = sqlite3_malloc(sizeof(DLCollector));\n  dataBufferInit(&pCollector->b, 0);\n  dlwInit(&pCollector->dlw, iType, &pCollector->b);\n  plwInit(&pCollector->plw, &pCollector->dlw, iDocid);\n  return pCollector;\n}\nstatic void dlcDelete(DLCollector *pCollector){\n  plwDestroy(&pCollector->plw);\n  dlwDestroy(&pCollector->dlw);\n  dataBufferDestroy(&pCollector->b);\n  SCRAMBLE(pCollector);\n  sqlite3_free(pCollector);\n}\n\n\n/* Copy the doclist data of iType in pData/nData into *out, trimming\n** unnecessary data as we go.  Only columns matching iColumn are\n** copied, all columns copied if iColumn is -1.  Elements with no\n** matching columns are dropped.  The output is an iOutType doclist.\n*/\n/* NOTE(shess) This code is only valid after all doclists are merged.\n** If this is run before merges, then doclist items which represent\n** deletion will be trimmed, and will thus not effect a deletion\n** during the merge.\n*/\nstatic void docListTrim(DocListType iType, const char *pData, int nData,\n                        int iColumn, DocListType iOutType, DataBuffer *out){\n  DLReader dlReader;\n  DLWriter dlWriter;\n\n  assert( iOutType<=iType );\n\n  dlrInit(&dlReader, iType, pData, nData);\n  dlwInit(&dlWriter, iOutType, out);\n\n  while( !dlrAtEnd(&dlReader) ){\n    PLReader plReader;\n    PLWriter plWriter;\n    int match = 0;\n\n    plrInit(&plReader, &dlReader);\n\n    while( !plrAtEnd(&plReader) ){\n      if( iColumn==-1 || plrColumn(&plReader)==iColumn ){\n        if( !match ){\n          plwInit(&plWriter, &dlWriter, dlrDocid(&dlReader));\n          match = 1;\n        }\n        plwAdd(&plWriter, plrColumn(&plReader), plrPosition(&plReader),\n               plrStartOffset(&plReader), plrEndOffset(&plReader));\n      }\n      plrStep(&plReader);\n    }\n    if( match ){\n      plwTerminate(&plWriter);\n      plwDestroy(&plWriter);\n    }\n\n    plrDestroy(&plReader);\n    dlrStep(&dlReader);\n  }\n  dlwDestroy(&dlWriter);\n  dlrDestroy(&dlReader);\n}\n\n/* Used by docListMerge() to keep doclists in the ascending order by\n** docid, then ascending order by age (so the newest comes first).\n*/\ntypedef struct OrderedDLReader {\n  DLReader *pReader;\n\n  /* TODO(shess) If we assume that docListMerge pReaders is ordered by\n  ** age (which we do), then we could use pReader comparisons to break\n  ** ties.\n  */\n  int idx;\n} OrderedDLReader;\n\n/* Order eof to end, then by docid asc, idx desc. */\nstatic int orderedDLReaderCmp(OrderedDLReader *r1, OrderedDLReader *r2){\n  if( dlrAtEnd(r1->pReader) ){\n    if( dlrAtEnd(r2->pReader) ) return 0;  /* Both atEnd(). */\n    return 1;                              /* Only r1 atEnd(). */\n  }\n  if( dlrAtEnd(r2->pReader) ) return -1;   /* Only r2 atEnd(). */\n\n  if( dlrDocid(r1->pReader)<dlrDocid(r2->pReader) ) return -1;\n  if( dlrDocid(r1->pReader)>dlrDocid(r2->pReader) ) return 1;\n\n  /* Descending on idx. */\n  return r2->idx-r1->idx;\n}\n\n/* Bubble p[0] to appropriate place in p[1..n-1].  Assumes that\n** p[1..n-1] is already sorted.\n*/\n/* TODO(shess) Is this frequent enough to warrant a binary search?\n** Before implementing that, instrument the code to check.  In most\n** current usage, I expect that p[0] will be less than p[1] a very\n** high proportion of the time.\n*/\nstatic void orderedDLReaderReorder(OrderedDLReader *p, int n){\n  while( n>1 && orderedDLReaderCmp(p, p+1)>0 ){\n    OrderedDLReader tmp = p[0];\n    p[0] = p[1];\n    p[1] = tmp;\n    n--;\n    p++;\n  }\n}\n\n/* Given an array of doclist readers, merge their doclist elements\n** into out in sorted order (by docid), dropping elements from older\n** readers when there is a duplicate docid.  pReaders is assumed to be\n** ordered by age, oldest first.\n*/\n/* TODO(shess) nReaders must be <= MERGE_COUNT.  This should probably\n** be fixed.\n*/\nstatic void docListMerge(DataBuffer *out,\n                         DLReader *pReaders, int nReaders){\n  OrderedDLReader readers[MERGE_COUNT];\n  DLWriter writer;\n  int i, n;\n  const char *pStart = 0;\n  int nStart = 0;\n  sqlite_int64 iFirstDocid = 0, iLastDocid = 0;\n\n  assert( nReaders>0 );\n  if( nReaders==1 ){\n    dataBufferAppend(out, dlrDocData(pReaders), dlrAllDataBytes(pReaders));\n    return;\n  }\n\n  assert( nReaders<=MERGE_COUNT );\n  n = 0;\n  for(i=0; i<nReaders; i++){\n    assert( pReaders[i].iType==pReaders[0].iType );\n    readers[i].pReader = pReaders+i;\n    readers[i].idx = i;\n    n += dlrAllDataBytes(&pReaders[i]);\n  }\n  /* Conservatively size output to sum of inputs.  Output should end\n  ** up strictly smaller than input.\n  */\n  dataBufferExpand(out, n);\n\n  /* Get the readers into sorted order. */\n  while( i-->0 ){\n    orderedDLReaderReorder(readers+i, nReaders-i);\n  }\n\n  dlwInit(&writer, pReaders[0].iType, out);\n  while( !dlrAtEnd(readers[0].pReader) ){\n    sqlite_int64 iDocid = dlrDocid(readers[0].pReader);\n\n    /* If this is a continuation of the current buffer to copy, extend\n    ** that buffer.  memcpy() seems to be more efficient if it has a\n    ** lots of data to copy.\n    */\n    if( dlrDocData(readers[0].pReader)==pStart+nStart ){\n      nStart += dlrDocDataBytes(readers[0].pReader);\n    }else{\n      if( pStart!=0 ){\n        dlwAppend(&writer, pStart, nStart, iFirstDocid, iLastDocid);\n      }\n      pStart = dlrDocData(readers[0].pReader);\n      nStart = dlrDocDataBytes(readers[0].pReader);\n      iFirstDocid = iDocid;\n    }\n    iLastDocid = iDocid;\n    dlrStep(readers[0].pReader);\n\n    /* Drop all of the older elements with the same docid. */\n    for(i=1; i<nReaders &&\n             !dlrAtEnd(readers[i].pReader) &&\n             dlrDocid(readers[i].pReader)==iDocid; i++){\n      dlrStep(readers[i].pReader);\n    }\n\n    /* Get the readers back into order. */\n    while( i-->0 ){\n      orderedDLReaderReorder(readers+i, nReaders-i);\n    }\n  }\n\n  /* Copy over any remaining elements. */\n  if( nStart>0 ) dlwAppend(&writer, pStart, nStart, iFirstDocid, iLastDocid);\n  dlwDestroy(&writer);\n}\n\n/* Helper function for posListUnion().  Compares the current position\n** between left and right, returning as standard C idiom of <0 if\n** left<right, >0 if left>right, and 0 if left==right.  \"End\" always\n** compares greater.\n*/\nstatic int posListCmp(PLReader *pLeft, PLReader *pRight){\n  assert( pLeft->iType==pRight->iType );\n  if( pLeft->iType==DL_DOCIDS ) return 0;\n\n  if( plrAtEnd(pLeft) ) return plrAtEnd(pRight) ? 0 : 1;\n  if( plrAtEnd(pRight) ) return -1;\n\n  if( plrColumn(pLeft)<plrColumn(pRight) ) return -1;\n  if( plrColumn(pLeft)>plrColumn(pRight) ) return 1;\n\n  if( plrPosition(pLeft)<plrPosition(pRight) ) return -1;\n  if( plrPosition(pLeft)>plrPosition(pRight) ) return 1;\n  if( pLeft->iType==DL_POSITIONS ) return 0;\n\n  if( plrStartOffset(pLeft)<plrStartOffset(pRight) ) return -1;\n  if( plrStartOffset(pLeft)>plrStartOffset(pRight) ) return 1;\n\n  if( plrEndOffset(pLeft)<plrEndOffset(pRight) ) return -1;\n  if( plrEndOffset(pLeft)>plrEndOffset(pRight) ) return 1;\n\n  return 0;\n}\n\n/* Write the union of position lists in pLeft and pRight to pOut.\n** \"Union\" in this case meaning \"All unique position tuples\".  Should\n** work with any doclist type, though both inputs and the output\n** should be the same type.\n*/\nstatic void posListUnion(DLReader *pLeft, DLReader *pRight, DLWriter *pOut){\n  PLReader left, right;\n  PLWriter writer;\n\n  assert( dlrDocid(pLeft)==dlrDocid(pRight) );\n  assert( pLeft->iType==pRight->iType );\n  assert( pLeft->iType==pOut->iType );\n\n  plrInit(&left, pLeft);\n  plrInit(&right, pRight);\n  plwInit(&writer, pOut, dlrDocid(pLeft));\n\n  while( !plrAtEnd(&left) || !plrAtEnd(&right) ){\n    int c = posListCmp(&left, &right);\n    if( c<0 ){\n      plwCopy(&writer, &left);\n      plrStep(&left);\n    }else if( c>0 ){\n      plwCopy(&writer, &right);\n      plrStep(&right);\n    }else{\n      plwCopy(&writer, &left);\n      plrStep(&left);\n      plrStep(&right);\n    }\n  }\n\n  plwTerminate(&writer);\n  plwDestroy(&writer);\n  plrDestroy(&left);\n  plrDestroy(&right);\n}\n\n/* Write the union of doclists in pLeft and pRight to pOut.  For\n** docids in common between the inputs, the union of the position\n** lists is written.  Inputs and outputs are always type DL_DEFAULT.\n*/\nstatic void docListUnion(\n  const char *pLeft, int nLeft,\n  const char *pRight, int nRight,\n  DataBuffer *pOut      /* Write the combined doclist here */\n){\n  DLReader left, right;\n  DLWriter writer;\n\n  if( nLeft==0 ){\n    if( nRight!=0) dataBufferAppend(pOut, pRight, nRight);\n    return;\n  }\n  if( nRight==0 ){\n    dataBufferAppend(pOut, pLeft, nLeft);\n    return;\n  }\n\n  dlrInit(&left, DL_DEFAULT, pLeft, nLeft);\n  dlrInit(&right, DL_DEFAULT, pRight, nRight);\n  dlwInit(&writer, DL_DEFAULT, pOut);\n\n  while( !dlrAtEnd(&left) || !dlrAtEnd(&right) ){\n    if( dlrAtEnd(&right) ){\n      dlwCopy(&writer, &left);\n      dlrStep(&left);\n    }else if( dlrAtEnd(&left) ){\n      dlwCopy(&writer, &right);\n      dlrStep(&right);\n    }else if( dlrDocid(&left)<dlrDocid(&right) ){\n      dlwCopy(&writer, &left);\n      dlrStep(&left);\n    }else if( dlrDocid(&left)>dlrDocid(&right) ){\n      dlwCopy(&writer, &right);\n      dlrStep(&right);\n    }else{\n      posListUnion(&left, &right, &writer);\n      dlrStep(&left);\n      dlrStep(&right);\n    }\n  }\n\n  dlrDestroy(&left);\n  dlrDestroy(&right);\n  dlwDestroy(&writer);\n}\n\n/* pLeft and pRight are DLReaders positioned to the same docid.\n**\n** If there are no instances in pLeft or pRight where the position\n** of pLeft is one less than the position of pRight, then this\n** routine adds nothing to pOut.\n**\n** If there are one or more instances where positions from pLeft\n** are exactly one less than positions from pRight, then add a new\n** document record to pOut.  If pOut wants to hold positions, then\n** include the positions from pRight that are one more than a\n** position in pLeft.  In other words:  pRight.iPos==pLeft.iPos+1.\n*/\nstatic void posListPhraseMerge(DLReader *pLeft, DLReader *pRight,\n                               DLWriter *pOut){\n  PLReader left, right;\n  PLWriter writer;\n  int match = 0;\n\n  assert( dlrDocid(pLeft)==dlrDocid(pRight) );\n  assert( pOut->iType!=DL_POSITIONS_OFFSETS );\n\n  plrInit(&left, pLeft);\n  plrInit(&right, pRight);\n\n  while( !plrAtEnd(&left) && !plrAtEnd(&right) ){\n    if( plrColumn(&left)<plrColumn(&right) ){\n      plrStep(&left);\n    }else if( plrColumn(&left)>plrColumn(&right) ){\n      plrStep(&right);\n    }else if( plrPosition(&left)+1<plrPosition(&right) ){\n      plrStep(&left);\n    }else if( plrPosition(&left)+1>plrPosition(&right) ){\n      plrStep(&right);\n    }else{\n      if( !match ){\n        plwInit(&writer, pOut, dlrDocid(pLeft));\n        match = 1;\n      }\n      plwAdd(&writer, plrColumn(&right), plrPosition(&right), 0, 0);\n      plrStep(&left);\n      plrStep(&right);\n    }\n  }\n\n  if( match ){\n    plwTerminate(&writer);\n    plwDestroy(&writer);\n  }\n\n  plrDestroy(&left);\n  plrDestroy(&right);\n}\n\n/* We have two doclists with positions:  pLeft and pRight.\n** Write the phrase intersection of these two doclists into pOut.\n**\n** A phrase intersection means that two documents only match\n** if pLeft.iPos+1==pRight.iPos.\n**\n** iType controls the type of data written to pOut.  If iType is\n** DL_POSITIONS, the positions are those from pRight.\n*/\nstatic void docListPhraseMerge(\n  const char *pLeft, int nLeft,\n  const char *pRight, int nRight,\n  DocListType iType,\n  DataBuffer *pOut      /* Write the combined doclist here */\n){\n  DLReader left, right;\n  DLWriter writer;\n\n  if( nLeft==0 || nRight==0 ) return;\n\n  assert( iType!=DL_POSITIONS_OFFSETS );\n\n  dlrInit(&left, DL_POSITIONS, pLeft, nLeft);\n  dlrInit(&right, DL_POSITIONS, pRight, nRight);\n  dlwInit(&writer, iType, pOut);\n\n  while( !dlrAtEnd(&left) && !dlrAtEnd(&right) ){\n    if( dlrDocid(&left)<dlrDocid(&right) ){\n      dlrStep(&left);\n    }else if( dlrDocid(&right)<dlrDocid(&left) ){\n      dlrStep(&right);\n    }else{\n      posListPhraseMerge(&left, &right, &writer);\n      dlrStep(&left);\n      dlrStep(&right);\n    }\n  }\n\n  dlrDestroy(&left);\n  dlrDestroy(&right);\n  dlwDestroy(&writer);\n}\n\n/* We have two DL_DOCIDS doclists:  pLeft and pRight.\n** Write the intersection of these two doclists into pOut as a\n** DL_DOCIDS doclist.\n*/\nstatic void docListAndMerge(\n  const char *pLeft, int nLeft,\n  const char *pRight, int nRight,\n  DataBuffer *pOut      /* Write the combined doclist here */\n){\n  DLReader left, right;\n  DLWriter writer;\n\n  if( nLeft==0 || nRight==0 ) return;\n\n  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);\n  dlrInit(&right, DL_DOCIDS, pRight, nRight);\n  dlwInit(&writer, DL_DOCIDS, pOut);\n\n  while( !dlrAtEnd(&left) && !dlrAtEnd(&right) ){\n    if( dlrDocid(&left)<dlrDocid(&right) ){\n      dlrStep(&left);\n    }else if( dlrDocid(&right)<dlrDocid(&left) ){\n      dlrStep(&right);\n    }else{\n      dlwAdd(&writer, dlrDocid(&left));\n      dlrStep(&left);\n      dlrStep(&right);\n    }\n  }\n\n  dlrDestroy(&left);\n  dlrDestroy(&right);\n  dlwDestroy(&writer);\n}\n\n/* We have two DL_DOCIDS doclists:  pLeft and pRight.\n** Write the union of these two doclists into pOut as a\n** DL_DOCIDS doclist.\n*/\nstatic void docListOrMerge(\n  const char *pLeft, int nLeft,\n  const char *pRight, int nRight,\n  DataBuffer *pOut      /* Write the combined doclist here */\n){\n  DLReader left, right;\n  DLWriter writer;\n\n  if( nLeft==0 ){\n    if( nRight!=0 ) dataBufferAppend(pOut, pRight, nRight);\n    return;\n  }\n  if( nRight==0 ){\n    dataBufferAppend(pOut, pLeft, nLeft);\n    return;\n  }\n\n  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);\n  dlrInit(&right, DL_DOCIDS, pRight, nRight);\n  dlwInit(&writer, DL_DOCIDS, pOut);\n\n  while( !dlrAtEnd(&left) || !dlrAtEnd(&right) ){\n    if( dlrAtEnd(&right) ){\n      dlwAdd(&writer, dlrDocid(&left));\n      dlrStep(&left);\n    }else if( dlrAtEnd(&left) ){\n      dlwAdd(&writer, dlrDocid(&right));\n      dlrStep(&right);\n    }else if( dlrDocid(&left)<dlrDocid(&right) ){\n      dlwAdd(&writer, dlrDocid(&left));\n      dlrStep(&left);\n    }else if( dlrDocid(&right)<dlrDocid(&left) ){\n      dlwAdd(&writer, dlrDocid(&right));\n      dlrStep(&right);\n    }else{\n      dlwAdd(&writer, dlrDocid(&left));\n      dlrStep(&left);\n      dlrStep(&right);\n    }\n  }\n\n  dlrDestroy(&left);\n  dlrDestroy(&right);\n  dlwDestroy(&writer);\n}\n\n/* We have two DL_DOCIDS doclists:  pLeft and pRight.\n** Write into pOut as DL_DOCIDS doclist containing all documents that\n** occur in pLeft but not in pRight.\n*/\nstatic void docListExceptMerge(\n  const char *pLeft, int nLeft,\n  const char *pRight, int nRight,\n  DataBuffer *pOut      /* Write the combined doclist here */\n){\n  DLReader left, right;\n  DLWriter writer;\n\n  if( nLeft==0 ) return;\n  if( nRight==0 ){\n    dataBufferAppend(pOut, pLeft, nLeft);\n    return;\n  }\n\n  dlrInit(&left, DL_DOCIDS, pLeft, nLeft);\n  dlrInit(&right, DL_DOCIDS, pRight, nRight);\n  dlwInit(&writer, DL_DOCIDS, pOut);\n\n  while( !dlrAtEnd(&left) ){\n    while( !dlrAtEnd(&right) && dlrDocid(&right)<dlrDocid(&left) ){\n      dlrStep(&right);\n    }\n    if( dlrAtEnd(&right) || dlrDocid(&left)<dlrDocid(&right) ){\n      dlwAdd(&writer, dlrDocid(&left));\n    }\n    dlrStep(&left);\n  }\n\n  dlrDestroy(&left);\n  dlrDestroy(&right);\n  dlwDestroy(&writer);\n}\n\nstatic char *string_dup_n(const char *s, int n){\n  char *str = sqlite3_malloc(n + 1);\n  memcpy(str, s, n);\n  str[n] = '\\0';\n  return str;\n}\n\n/* Duplicate a string; the caller must free() the returned string.\n * (We don't use strdup() since it is not part of the standard C library and\n * may not be available everywhere.) */\nstatic char *string_dup(const char *s){\n  return string_dup_n(s, strlen(s));\n}\n\n/* Format a string, replacing each occurrence of the % character with\n * zDb.zName.  This may be more convenient than sqlite_mprintf()\n * when one string is used repeatedly in a format string.\n * The caller must free() the returned string. */\nstatic char *string_format(const char *zFormat,\n                           const char *zDb, const char *zName){\n  const char *p;\n  size_t len = 0;\n  size_t nDb = strlen(zDb);\n  size_t nName = strlen(zName);\n  size_t nFullTableName = nDb+1+nName;\n  char *result;\n  char *r;\n\n  /* first compute length needed */\n  for(p = zFormat ; *p ; ++p){\n    len += (*p=='%' ? nFullTableName : 1);\n  }\n  len += 1;  /* for null terminator */\n\n  r = result = sqlite3_malloc(len);\n  for(p = zFormat; *p; ++p){\n    if( *p=='%' ){\n      memcpy(r, zDb, nDb);\n      r += nDb;\n      *r++ = '.';\n      memcpy(r, zName, nName);\n      r += nName;\n    } else {\n      *r++ = *p;\n    }\n  }\n  *r++ = '\\0';\n  assert( r == result + len );\n  return result;\n}\n\nstatic int sql_exec(sqlite3 *db, const char *zDb, const char *zName,\n                    const char *zFormat){\n  char *zCommand = string_format(zFormat, zDb, zName);\n  int rc;\n  TRACE((\"FTS2 sql: %s\\n\", zCommand));\n  rc = sqlite3_exec(db, zCommand, NULL, 0, NULL);\n  sqlite3_free(zCommand);\n  return rc;\n}\n\nstatic int sql_prepare(sqlite3 *db, const char *zDb, const char *zName,\n                       sqlite3_stmt **ppStmt, const char *zFormat){\n  char *zCommand = string_format(zFormat, zDb, zName);\n  int rc;\n  TRACE((\"FTS2 prepare: %s\\n\", zCommand));\n  rc = sqlite3_prepare_v2(db, zCommand, -1, ppStmt, NULL);\n  sqlite3_free(zCommand);\n  return rc;\n}\n\n/* end utility functions */\n\n/* Forward reference */\ntypedef struct fulltext_vtab fulltext_vtab;\n\n/* A single term in a query is represented by an instances of\n** the following structure.\n*/\ntypedef struct QueryTerm {\n  short int nPhrase; /* How many following terms are part of the same phrase */\n  short int iPhrase; /* This is the i-th term of a phrase. */\n  short int iColumn; /* Column of the index that must match this term */\n  signed char isOr;  /* this term is preceded by \"OR\" */\n  signed char isNot; /* this term is preceded by \"-\" */\n  signed char isPrefix; /* this term is followed by \"*\" */\n  char *pTerm;       /* text of the term.  '\\000' terminated.  malloced */\n  int nTerm;         /* Number of bytes in pTerm[] */\n} QueryTerm;\n\n\n/* A query string is parsed into a Query structure.\n *\n * We could, in theory, allow query strings to be complicated\n * nested expressions with precedence determined by parentheses.\n * But none of the major search engines do this.  (Perhaps the\n * feeling is that an parenthesized expression is two complex of\n * an idea for the average user to grasp.)  Taking our lead from\n * the major search engines, we will allow queries to be a list\n * of terms (with an implied AND operator) or phrases in double-quotes,\n * with a single optional \"-\" before each non-phrase term to designate\n * negation and an optional OR connector.\n *\n * OR binds more tightly than the implied AND, which is what the\n * major search engines seem to do.  So, for example:\n * \n *    [one two OR three]     ==>    one AND (two OR three)\n *    [one OR two three]     ==>    (one OR two) AND three\n *\n * A \"-\" before a term matches all entries that lack that term.\n * The \"-\" must occur immediately before the term with in intervening\n * space.  This is how the search engines do it.\n *\n * A NOT term cannot be the right-hand operand of an OR.  If this\n * occurs in the query string, the NOT is ignored:\n *\n *    [one OR -two]          ==>    one OR two\n *\n */\ntypedef struct Query {\n  fulltext_vtab *pFts;  /* The full text index */\n  int nTerms;           /* Number of terms in the query */\n  QueryTerm *pTerms;    /* Array of terms.  Space obtained from malloc() */\n  int nextIsOr;         /* Set the isOr flag on the next inserted term */\n  int nextColumn;       /* Next word parsed must be in this column */\n  int dfltColumn;       /* The default column */\n} Query;\n\n\n/*\n** An instance of the following structure keeps track of generated\n** matching-word offset information and snippets.\n*/\ntypedef struct Snippet {\n  int nMatch;     /* Total number of matches */\n  int nAlloc;     /* Space allocated for aMatch[] */\n  struct snippetMatch { /* One entry for each matching term */\n    char snStatus;       /* Status flag for use while constructing snippets */\n    short int iCol;      /* The column that contains the match */\n    short int iTerm;     /* The index in Query.pTerms[] of the matching term */\n    short int nByte;     /* Number of bytes in the term */\n    int iStart;          /* The offset to the first character of the term */\n  } *aMatch;      /* Points to space obtained from malloc */\n  char *zOffset;  /* Text rendering of aMatch[] */\n  int nOffset;    /* strlen(zOffset) */\n  char *zSnippet; /* Snippet text */\n  int nSnippet;   /* strlen(zSnippet) */\n} Snippet;\n\n\ntypedef enum QueryType {\n  QUERY_GENERIC,   /* table scan */\n  QUERY_ROWID,     /* lookup by rowid */\n  QUERY_FULLTEXT   /* QUERY_FULLTEXT + [i] is a full-text search for column i*/\n} QueryType;\n\ntypedef enum fulltext_statement {\n  CONTENT_INSERT_STMT,\n  CONTENT_SELECT_STMT,\n  CONTENT_UPDATE_STMT,\n  CONTENT_DELETE_STMT,\n  CONTENT_EXISTS_STMT,\n\n  BLOCK_INSERT_STMT,\n  BLOCK_SELECT_STMT,\n  BLOCK_DELETE_STMT,\n  BLOCK_DELETE_ALL_STMT,\n\n  SEGDIR_MAX_INDEX_STMT,\n  SEGDIR_SET_STMT,\n  SEGDIR_SELECT_LEVEL_STMT,\n  SEGDIR_SPAN_STMT,\n  SEGDIR_DELETE_STMT,\n  SEGDIR_SELECT_SEGMENT_STMT,\n  SEGDIR_SELECT_ALL_STMT,\n  SEGDIR_DELETE_ALL_STMT,\n  SEGDIR_COUNT_STMT,\n\n  MAX_STMT                     /* Always at end! */\n} fulltext_statement;\n\n/* These must exactly match the enum above. */\n/* TODO(shess): Is there some risk that a statement will be used in two\n** cursors at once, e.g.  if a query joins a virtual table to itself?\n** If so perhaps we should move some of these to the cursor object.\n*/\nstatic const char *const fulltext_zStatement[MAX_STMT] = {\n  /* CONTENT_INSERT */ NULL,  /* generated in contentInsertStatement() */\n  /* CONTENT_SELECT */ \"select * from %_content where rowid = ?\",\n  /* CONTENT_UPDATE */ NULL,  /* generated in contentUpdateStatement() */\n  /* CONTENT_DELETE */ \"delete from %_content where rowid = ?\",\n  /* CONTENT_EXISTS */ \"select rowid from %_content limit 1\",\n\n  /* BLOCK_INSERT */ \"insert into %_segments values (?)\",\n  /* BLOCK_SELECT */ \"select block from %_segments where rowid = ?\",\n  /* BLOCK_DELETE */ \"delete from %_segments where rowid between ? and ?\",\n  /* BLOCK_DELETE_ALL */ \"delete from %_segments\",\n\n  /* SEGDIR_MAX_INDEX */ \"select max(idx) from %_segdir where level = ?\",\n  /* SEGDIR_SET */ \"insert into %_segdir values (?, ?, ?, ?, ?, ?)\",\n  /* SEGDIR_SELECT_LEVEL */\n  \"select start_block, leaves_end_block, root from %_segdir \"\n  \" where level = ? order by idx\",\n  /* SEGDIR_SPAN */\n  \"select min(start_block), max(end_block) from %_segdir \"\n  \" where level = ? and start_block <> 0\",\n  /* SEGDIR_DELETE */ \"delete from %_segdir where level = ?\",\n\n  /* NOTE(shess): The first three results of the following two\n  ** statements must match.\n  */\n  /* SEGDIR_SELECT_SEGMENT */\n  \"select start_block, leaves_end_block, root from %_segdir \"\n  \" where level = ? and idx = ?\",\n  /* SEGDIR_SELECT_ALL */\n  \"select start_block, leaves_end_block, root from %_segdir \"\n  \" order by level desc, idx asc\",\n  /* SEGDIR_DELETE_ALL */ \"delete from %_segdir\",\n  /* SEGDIR_COUNT */ \"select count(*), ifnull(max(level),0) from %_segdir\",\n};\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure.  The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct fulltext_vtab {\n  sqlite3_vtab base;               /* Base class used by SQLite core */\n  sqlite3 *db;                     /* The database connection */\n  const char *zDb;                 /* logical database name */\n  const char *zName;               /* virtual table name */\n  int nColumn;                     /* number of columns in virtual table */\n  char **azColumn;                 /* column names.  malloced */\n  char **azContentColumn;          /* column names in content table; malloced */\n  sqlite3_tokenizer *pTokenizer;   /* tokenizer for inserts and queries */\n\n  /* Precompiled statements which we keep as long as the table is\n  ** open.\n  */\n  sqlite3_stmt *pFulltextStatements[MAX_STMT];\n\n  /* Precompiled statements used for segment merges.  We run a\n  ** separate select across the leaf level of each tree being merged.\n  */\n  sqlite3_stmt *pLeafSelectStmts[MERGE_COUNT];\n  /* The statement used to prepare pLeafSelectStmts. */\n#define LEAF_SELECT \\\n  \"select block from %_segments where rowid between ? and ? order by rowid\"\n\n  /* These buffer pending index updates during transactions.\n  ** nPendingData estimates the memory size of the pending data.  It\n  ** doesn't include the hash-bucket overhead, nor any malloc\n  ** overhead.  When nPendingData exceeds kPendingThreshold, the\n  ** buffer is flushed even before the transaction closes.\n  ** pendingTerms stores the data, and is only valid when nPendingData\n  ** is >=0 (nPendingData<0 means pendingTerms has not been\n  ** initialized).  iPrevDocid is the last docid written, used to make\n  ** certain we're inserting in sorted order.\n  */\n  int nPendingData;\n#define kPendingThreshold (1*1024*1024)\n  sqlite_int64 iPrevDocid;\n  fts2Hash pendingTerms;\n};\n\n/*\n** When the core wants to do a query, it create a cursor using a\n** call to xOpen.  This structure is an instance of a cursor.  It\n** is destroyed by xClose.\n*/\ntypedef struct fulltext_cursor {\n  sqlite3_vtab_cursor base;        /* Base class used by SQLite core */\n  QueryType iCursorType;           /* Copy of sqlite3_index_info.idxNum */\n  sqlite3_stmt *pStmt;             /* Prepared statement in use by the cursor */\n  int eof;                         /* True if at End Of Results */\n  Query q;                         /* Parsed query string */\n  Snippet snippet;                 /* Cached snippet for the current row */\n  int iColumn;                     /* Column being searched */\n  DataBuffer result;               /* Doclist results from fulltextQuery */\n  DLReader reader;                 /* Result reader if result not empty */\n} fulltext_cursor;\n\nstatic struct fulltext_vtab *cursor_vtab(fulltext_cursor *c){\n  return (fulltext_vtab *) c->base.pVtab;\n}\n\nstatic const sqlite3_module fts2Module;   /* forward declaration */\n\n/* Return a dynamically generated statement of the form\n *   insert into %_content (rowid, ...) values (?, ...)\n */\nstatic const char *contentInsertStatement(fulltext_vtab *v){\n  StringBuffer sb;\n  int i;\n\n  initStringBuffer(&sb);\n  append(&sb, \"insert into %_content (rowid, \");\n  appendList(&sb, v->nColumn, v->azContentColumn);\n  append(&sb, \") values (?\");\n  for(i=0; i<v->nColumn; ++i)\n    append(&sb, \", ?\");\n  append(&sb, \")\");\n  return stringBufferData(&sb);\n}\n\n/* Return a dynamically generated statement of the form\n *   update %_content set [col_0] = ?, [col_1] = ?, ...\n *                    where rowid = ?\n */\nstatic const char *contentUpdateStatement(fulltext_vtab *v){\n  StringBuffer sb;\n  int i;\n\n  initStringBuffer(&sb);\n  append(&sb, \"update %_content set \");\n  for(i=0; i<v->nColumn; ++i) {\n    if( i>0 ){\n      append(&sb, \", \");\n    }\n    append(&sb, v->azContentColumn[i]);\n    append(&sb, \" = ?\");\n  }\n  append(&sb, \" where rowid = ?\");\n  return stringBufferData(&sb);\n}\n\n/* Puts a freshly-prepared statement determined by iStmt in *ppStmt.\n** If the indicated statement has never been prepared, it is prepared\n** and cached, otherwise the cached version is reset.\n*/\nstatic int sql_get_statement(fulltext_vtab *v, fulltext_statement iStmt,\n                             sqlite3_stmt **ppStmt){\n  assert( iStmt<MAX_STMT );\n  if( v->pFulltextStatements[iStmt]==NULL ){\n    const char *zStmt;\n    int rc;\n    switch( iStmt ){\n      case CONTENT_INSERT_STMT:\n        zStmt = contentInsertStatement(v); break;\n      case CONTENT_UPDATE_STMT:\n        zStmt = contentUpdateStatement(v); break;\n      default:\n        zStmt = fulltext_zStatement[iStmt];\n    }\n    rc = sql_prepare(v->db, v->zDb, v->zName, &v->pFulltextStatements[iStmt],\n                         zStmt);\n    if( zStmt != fulltext_zStatement[iStmt]) sqlite3_free((void *) zStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  } else {\n    int rc = sqlite3_reset(v->pFulltextStatements[iStmt]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  *ppStmt = v->pFulltextStatements[iStmt];\n  return SQLITE_OK;\n}\n\n/* Like sqlite3_step(), but convert SQLITE_DONE to SQLITE_OK and\n** SQLITE_ROW to SQLITE_ERROR.  Useful for statements like UPDATE,\n** where we expect no results.\n*/\nstatic int sql_single_step(sqlite3_stmt *s){\n  int rc = sqlite3_step(s);\n  return (rc==SQLITE_DONE) ? SQLITE_OK : rc;\n}\n\n/* Like sql_get_statement(), but for special replicated LEAF_SELECT\n** statements.  idx -1 is a special case for an uncached version of\n** the statement (used in the optimize implementation).\n*/\n/* TODO(shess) Write version for generic statements and then share\n** that between the cached-statement functions.\n*/\nstatic int sql_get_leaf_statement(fulltext_vtab *v, int idx,\n                                  sqlite3_stmt **ppStmt){\n  assert( idx>=-1 && idx<MERGE_COUNT );\n  if( idx==-1 ){\n    return sql_prepare(v->db, v->zDb, v->zName, ppStmt, LEAF_SELECT);\n  }else if( v->pLeafSelectStmts[idx]==NULL ){\n    int rc = sql_prepare(v->db, v->zDb, v->zName, &v->pLeafSelectStmts[idx],\n                         LEAF_SELECT);\n    if( rc!=SQLITE_OK ) return rc;\n  }else{\n    int rc = sqlite3_reset(v->pLeafSelectStmts[idx]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  *ppStmt = v->pLeafSelectStmts[idx];\n  return SQLITE_OK;\n}\n\n/* insert into %_content (rowid, ...) values ([rowid], [pValues]) */\nstatic int content_insert(fulltext_vtab *v, sqlite3_value *rowid,\n                          sqlite3_value **pValues){\n  sqlite3_stmt *s;\n  int i;\n  int rc = sql_get_statement(v, CONTENT_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_value(s, 1, rowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i=0; i<v->nColumn; ++i){\n    rc = sqlite3_bind_value(s, 2+i, pValues[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  return sql_single_step(s);\n}\n\n/* update %_content set col0 = pValues[0], col1 = pValues[1], ...\n *                  where rowid = [iRowid] */\nstatic int content_update(fulltext_vtab *v, sqlite3_value **pValues,\n                          sqlite_int64 iRowid){\n  sqlite3_stmt *s;\n  int i;\n  int rc = sql_get_statement(v, CONTENT_UPDATE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i=0; i<v->nColumn; ++i){\n    rc = sqlite3_bind_value(s, 1+i, pValues[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  rc = sqlite3_bind_int64(s, 1+v->nColumn, iRowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\nstatic void freeStringArray(int nString, const char **pString){\n  int i;\n\n  for (i=0 ; i < nString ; ++i) {\n    if( pString[i]!=NULL ) sqlite3_free((void *) pString[i]);\n  }\n  sqlite3_free((void *) pString);\n}\n\n/* select * from %_content where rowid = [iRow]\n * The caller must delete the returned array and all strings in it.\n * null fields will be NULL in the returned array.\n *\n * TODO: Perhaps we should return pointer/length strings here for consistency\n * with other code which uses pointer/length. */\nstatic int content_select(fulltext_vtab *v, sqlite_int64 iRow,\n                          const char ***pValues){\n  sqlite3_stmt *s;\n  const char **values;\n  int i;\n  int rc;\n\n  *pValues = NULL;\n\n  rc = sql_get_statement(v, CONTENT_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  if( rc!=SQLITE_ROW ) return rc;\n\n  values = (const char **) sqlite3_malloc(v->nColumn * sizeof(const char *));\n  for(i=0; i<v->nColumn; ++i){\n    if( sqlite3_column_type(s, i)==SQLITE_NULL ){\n      values[i] = NULL;\n    }else{\n      values[i] = string_dup((char*)sqlite3_column_text(s, i));\n    }\n  }\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ){\n    *pValues = values;\n    return SQLITE_OK;\n  }\n\n  freeStringArray(v->nColumn, values);\n  return rc;\n}\n\n/* delete from %_content where rowid = [iRow ] */\nstatic int content_delete(fulltext_vtab *v, sqlite_int64 iRow){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\n/* Returns SQLITE_ROW if any rows exist in %_content, SQLITE_DONE if\n** no rows exist, and any error in case of failure.\n*/\nstatic int content_exists(fulltext_vtab *v){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, CONTENT_EXISTS_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  if( rc!=SQLITE_ROW ) return rc;\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ) return SQLITE_ROW;\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  return rc;\n}\n\n/* insert into %_segments values ([pData])\n**   returns assigned rowid in *piBlockid\n*/\nstatic int block_insert(fulltext_vtab *v, const char *pData, int nData,\n                        sqlite_int64 *piBlockid){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, BLOCK_INSERT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 1, pData, nData, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  if( rc!=SQLITE_DONE ) return rc;\n\n  *piBlockid = sqlite3_last_insert_rowid(v->db);\n  return SQLITE_OK;\n}\n\n/* delete from %_segments\n**   where rowid between [iStartBlockid] and [iEndBlockid]\n**\n** Deletes the range of blocks, inclusive, used to delete the blocks\n** which form a segment.\n*/\nstatic int block_delete(fulltext_vtab *v,\n                        sqlite_int64 iStartBlockid, sqlite_int64 iEndBlockid){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, BLOCK_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iStartBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 2, iEndBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\n/* Returns SQLITE_ROW with *pidx set to the maximum segment idx found\n** at iLevel.  Returns SQLITE_DONE if there are no segments at\n** iLevel.  Otherwise returns an error.\n*/\nstatic int segdir_max_index(fulltext_vtab *v, int iLevel, int *pidx){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_MAX_INDEX_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 1, iLevel);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  /* Should always get at least one row due to how max() works. */\n  if( rc==SQLITE_DONE ) return SQLITE_DONE;\n  if( rc!=SQLITE_ROW ) return rc;\n\n  /* NULL means that there were no inputs to max(). */\n  if( SQLITE_NULL==sqlite3_column_type(s, 0) ){\n    rc = sqlite3_step(s);\n    if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n    return rc;\n  }\n\n  *pidx = sqlite3_column_int(s, 0);\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  if( rc!=SQLITE_DONE ) return rc;\n  return SQLITE_ROW;\n}\n\n/* insert into %_segdir values (\n**   [iLevel], [idx],\n**   [iStartBlockid], [iLeavesEndBlockid], [iEndBlockid],\n**   [pRootData]\n** )\n*/\nstatic int segdir_set(fulltext_vtab *v, int iLevel, int idx,\n                      sqlite_int64 iStartBlockid,\n                      sqlite_int64 iLeavesEndBlockid,\n                      sqlite_int64 iEndBlockid,\n                      const char *pRootData, int nRootData){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_SET_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 1, iLevel);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 2, idx);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 3, iStartBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 4, iLeavesEndBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 5, iEndBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_blob(s, 6, pRootData, nRootData, SQLITE_STATIC);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\n/* Queries %_segdir for the block span of the segments in level\n** iLevel.  Returns SQLITE_DONE if there are no blocks for iLevel,\n** SQLITE_ROW if there are blocks, else an error.\n*/\nstatic int segdir_span(fulltext_vtab *v, int iLevel,\n                       sqlite_int64 *piStartBlockid,\n                       sqlite_int64 *piEndBlockid){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_SPAN_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 1, iLevel);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ) return SQLITE_DONE;  /* Should never happen */\n  if( rc!=SQLITE_ROW ) return rc;\n\n  /* This happens if all segments at this level are entirely inline. */\n  if( SQLITE_NULL==sqlite3_column_type(s, 0) ){\n    /* We expect only one row.  We must execute another sqlite3_step()\n     * to complete the iteration; otherwise the table will remain locked. */\n    int rc2 = sqlite3_step(s);\n    if( rc2==SQLITE_ROW ) return SQLITE_ERROR;\n    return rc2;\n  }\n\n  *piStartBlockid = sqlite3_column_int64(s, 0);\n  *piEndBlockid = sqlite3_column_int64(s, 1);\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  if( rc!=SQLITE_DONE ) return rc;\n  return SQLITE_ROW;\n}\n\n/* Delete the segment blocks and segment directory records for all\n** segments at iLevel.\n*/\nstatic int segdir_delete(fulltext_vtab *v, int iLevel){\n  sqlite3_stmt *s;\n  sqlite_int64 iStartBlockid, iEndBlockid;\n  int rc = segdir_span(v, iLevel, &iStartBlockid, &iEndBlockid);\n  if( rc!=SQLITE_ROW && rc!=SQLITE_DONE ) return rc;\n\n  if( rc==SQLITE_ROW ){\n    rc = block_delete(v, iStartBlockid, iEndBlockid);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* Delete the segment directory itself. */\n  rc = sql_get_statement(v, SEGDIR_DELETE_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iLevel);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\n/* Delete entire fts index, SQLITE_OK on success, relevant error on\n** failure.\n*/\nstatic int segdir_delete_all(fulltext_vtab *v){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_DELETE_ALL_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_single_step(s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sql_get_statement(v, BLOCK_DELETE_ALL_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return sql_single_step(s);\n}\n\n/* Returns SQLITE_OK with *pnSegments set to the number of entries in\n** %_segdir and *piMaxLevel set to the highest level which has a\n** segment.  Otherwise returns the SQLite error which caused failure.\n*/\nstatic int segdir_count(fulltext_vtab *v, int *pnSegments, int *piMaxLevel){\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_COUNT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  /* TODO(shess): This case should not be possible?  Should stronger\n  ** measures be taken if it happens?\n  */\n  if( rc==SQLITE_DONE ){\n    *pnSegments = 0;\n    *piMaxLevel = 0;\n    return SQLITE_OK;\n  }\n  if( rc!=SQLITE_ROW ) return rc;\n\n  *pnSegments = sqlite3_column_int(s, 0);\n  *piMaxLevel = sqlite3_column_int(s, 1);\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ) return SQLITE_OK;\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  return rc;\n}\n\n/* TODO(shess) clearPendingTerms() is far down the file because\n** writeZeroSegment() is far down the file because LeafWriter is far\n** down the file.  Consider refactoring the code to move the non-vtab\n** code above the vtab code so that we don't need this forward\n** reference.\n*/\nstatic int clearPendingTerms(fulltext_vtab *v);\n\n/*\n** Free the memory used to contain a fulltext_vtab structure.\n*/\nstatic void fulltext_vtab_destroy(fulltext_vtab *v){\n  int iStmt, i;\n\n  TRACE((\"FTS2 Destroy %p\\n\", v));\n  for( iStmt=0; iStmt<MAX_STMT; iStmt++ ){\n    if( v->pFulltextStatements[iStmt]!=NULL ){\n      sqlite3_finalize(v->pFulltextStatements[iStmt]);\n      v->pFulltextStatements[iStmt] = NULL;\n    }\n  }\n\n  for( i=0; i<MERGE_COUNT; i++ ){\n    if( v->pLeafSelectStmts[i]!=NULL ){\n      sqlite3_finalize(v->pLeafSelectStmts[i]);\n      v->pLeafSelectStmts[i] = NULL;\n    }\n  }\n\n  if( v->pTokenizer!=NULL ){\n    v->pTokenizer->pModule->xDestroy(v->pTokenizer);\n    v->pTokenizer = NULL;\n  }\n\n  clearPendingTerms(v);\n\n  sqlite3_free(v->azColumn);\n  for(i = 0; i < v->nColumn; ++i) {\n    sqlite3_free(v->azContentColumn[i]);\n  }\n  sqlite3_free(v->azContentColumn);\n  sqlite3_free(v);\n}\n\n/*\n** Token types for parsing the arguments to xConnect or xCreate.\n*/\n#define TOKEN_EOF         0    /* End of file */\n#define TOKEN_SPACE       1    /* Any kind of whitespace */\n#define TOKEN_ID          2    /* An identifier */\n#define TOKEN_STRING      3    /* A string literal */\n#define TOKEN_PUNCT       4    /* A single punctuation character */\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identfiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\nstatic const char isIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define IdChar(C)  (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))\n\n\n/*\n** Return the length of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nstatic int getToken(const char *z, int *tokenType){\n  int i, c;\n  switch( *z ){\n    case 0: {\n      *tokenType = TOKEN_EOF;\n      return 0;\n    }\n    case ' ': case '\\t': case '\\n': case '\\f': case '\\r': {\n      for(i=1; safe_isspace(z[i]); i++){}\n      *tokenType = TOKEN_SPACE;\n      return i;\n    }\n    case '`':\n    case '\\'':\n    case '\"': {\n      int delim = z[0];\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      *tokenType = TOKEN_STRING;\n      return i + (c!=0);\n    }\n    case '[': {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = TOKEN_ID;\n      return i;\n    }\n    default: {\n      if( !IdChar(*z) ){\n        break;\n      }\n      for(i=1; IdChar(z[i]); i++){}\n      *tokenType = TOKEN_ID;\n      return i;\n    }\n  }\n  *tokenType = TOKEN_PUNCT;\n  return 1;\n}\n\n/*\n** A token extracted from a string is an instance of the following\n** structure.\n*/\ntypedef struct Token {\n  const char *z;       /* Pointer to token text.  Not '\\000' terminated */\n  short int n;         /* Length of the token text in bytes. */\n} Token;\n\n/*\n** Given a input string (which is really one of the argv[] parameters\n** passed into xConnect or xCreate) split the string up into tokens.\n** Return an array of pointers to '\\000' terminated strings, one string\n** for each non-whitespace token.\n**\n** The returned array is terminated by a single NULL pointer.\n**\n** Space to hold the returned array is obtained from a single\n** malloc and should be freed by passing the return value to free().\n** The individual strings within the token list are all a part of\n** the single memory allocation and will all be freed at once.\n*/\nstatic char **tokenizeString(const char *z, int *pnToken){\n  int nToken = 0;\n  Token *aToken = sqlite3_malloc( strlen(z) * sizeof(aToken[0]) );\n  int n = 1;\n  int e, i;\n  int totalSize = 0;\n  char **azToken;\n  char *zCopy;\n  while( n>0 ){\n    n = getToken(z, &e);\n    if( e!=TOKEN_SPACE ){\n      aToken[nToken].z = z;\n      aToken[nToken].n = n;\n      nToken++;\n      totalSize += n+1;\n    }\n    z += n;\n  }\n  azToken = (char**)sqlite3_malloc( nToken*sizeof(char*) + totalSize );\n  zCopy = (char*)&azToken[nToken];\n  nToken--;\n  for(i=0; i<nToken; i++){\n    azToken[i] = zCopy;\n    n = aToken[i].n;\n    memcpy(zCopy, aToken[i].z, n);\n    zCopy[n] = 0;\n    zCopy += n+1;\n  }\n  azToken[nToken] = 0;\n  sqlite3_free(aToken);\n  *pnToken = nToken;\n  return azToken;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic void dequoteString(char *z){\n  int quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  switch( quote ){\n    case '\\'':  break;\n    case '\"':   break;\n    case '`':   break;                /* For MySQL compatibility */\n    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */\n    default:    return;\n  }\n  for(i=1, j=0; z[i]; i++){\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        z[j++] = 0;\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n}\n\n/*\n** The input azIn is a NULL-terminated list of tokens.  Remove the first\n** token and all punctuation tokens.  Remove the quotes from\n** around string literal tokens.\n**\n** Example:\n**\n**     input:      tokenize chinese ( 'simplifed' , 'mixed' )\n**     output:     chinese simplifed mixed\n**\n** Another example:\n**\n**     input:      delimiters ( '[' , ']' , '...' )\n**     output:     [ ] ...\n*/\nstatic void tokenListToIdList(char **azIn){\n  int i, j;\n  if( azIn ){\n    for(i=0, j=-1; azIn[i]; i++){\n      if( safe_isalnum(azIn[i][0]) || azIn[i][1] ){\n        dequoteString(azIn[i]);\n        if( j>=0 ){\n          azIn[j] = azIn[i];\n        }\n        j++;\n      }\n    }\n    azIn[j] = 0;\n  }\n}\n\n\n/*\n** Find the first alphanumeric token in the string zIn.  Null-terminate\n** this token.  Remove any quotation marks.  And return a pointer to\n** the result.\n*/\nstatic char *firstToken(char *zIn, char **pzTail){\n  int n, ttype;\n  while(1){\n    n = getToken(zIn, &ttype);\n    if( ttype==TOKEN_SPACE ){\n      zIn += n;\n    }else if( ttype==TOKEN_EOF ){\n      *pzTail = zIn;\n      return 0;\n    }else{\n      zIn[n] = 0;\n      *pzTail = &zIn[1];\n      dequoteString(zIn);\n      return zIn;\n    }\n  }\n  /*NOTREACHED*/\n}\n\n/* Return true if...\n**\n**   *  s begins with the string t, ignoring case\n**   *  s is longer than t\n**   *  The first character of s beyond t is not a alphanumeric\n** \n** Ignore leading space in *s.\n**\n** To put it another way, return true if the first token of\n** s[] is t[].\n*/\nstatic int startsWith(const char *s, const char *t){\n  while( safe_isspace(*s) ){ s++; }\n  while( *t ){\n    if( safe_tolower(*s++)!=safe_tolower(*t++) ) return 0;\n  }\n  return *s!='_' && !safe_isalnum(*s);\n}\n\n/*\n** An instance of this structure defines the \"spec\" of a\n** full text index.  This structure is populated by parseSpec\n** and use by fulltextConnect and fulltextCreate.\n*/\ntypedef struct TableSpec {\n  const char *zDb;         /* Logical database name */\n  const char *zName;       /* Name of the full-text index */\n  int nColumn;             /* Number of columns to be indexed */\n  char **azColumn;         /* Original names of columns to be indexed */\n  char **azContentColumn;  /* Column names for %_content */\n  char **azTokenizer;      /* Name of tokenizer and its arguments */\n} TableSpec;\n\n/*\n** Reclaim all of the memory used by a TableSpec\n*/\nstatic void clearTableSpec(TableSpec *p) {\n  sqlite3_free(p->azColumn);\n  sqlite3_free(p->azContentColumn);\n  sqlite3_free(p->azTokenizer);\n}\n\n/* Parse a CREATE VIRTUAL TABLE statement, which looks like this:\n *\n * CREATE VIRTUAL TABLE email\n *        USING fts2(subject, body, tokenize mytokenizer(myarg))\n *\n * We return parsed information in a TableSpec structure.\n * \n */\nstatic int parseSpec(TableSpec *pSpec, int argc, const char *const*argv,\n                     char**pzErr){\n  int i, n;\n  char *z, *zDummy;\n  char **azArg;\n  const char *zTokenizer = 0;    /* argv[] entry describing the tokenizer */\n\n  assert( argc>=3 );\n  /* Current interface:\n  ** argv[0] - module name\n  ** argv[1] - database name\n  ** argv[2] - table name\n  ** argv[3..] - columns, optionally followed by tokenizer specification\n  **             and snippet delimiters specification.\n  */\n\n  /* Make a copy of the complete argv[][] array in a single allocation.\n  ** The argv[][] array is read-only and transient.  We can write to the\n  ** copy in order to modify things and the copy is persistent.\n  */\n  CLEAR(pSpec);\n  for(i=n=0; i<argc; i++){\n    n += strlen(argv[i]) + 1;\n  }\n  azArg = sqlite3_malloc( sizeof(char*)*argc + n );\n  if( azArg==0 ){\n    return SQLITE_NOMEM;\n  }\n  z = (char*)&azArg[argc];\n  for(i=0; i<argc; i++){\n    azArg[i] = z;\n    strcpy(z, argv[i]);\n    z += strlen(z)+1;\n  }\n\n  /* Identify the column names and the tokenizer and delimiter arguments\n  ** in the argv[][] array.\n  */\n  pSpec->zDb = azArg[1];\n  pSpec->zName = azArg[2];\n  pSpec->nColumn = 0;\n  pSpec->azColumn = azArg;\n  zTokenizer = \"tokenize simple\";\n  for(i=3; i<argc; ++i){\n    if( startsWith(azArg[i],\"tokenize\") ){\n      zTokenizer = azArg[i];\n    }else{\n      z = azArg[pSpec->nColumn] = firstToken(azArg[i], &zDummy);\n      pSpec->nColumn++;\n    }\n  }\n  if( pSpec->nColumn==0 ){\n    azArg[0] = \"content\";\n    pSpec->nColumn = 1;\n  }\n\n  /*\n  ** Construct the list of content column names.\n  **\n  ** Each content column name will be of the form cNNAAAA\n  ** where NN is the column number and AAAA is the sanitized\n  ** column name.  \"sanitized\" means that special characters are\n  ** converted to \"_\".  The cNN prefix guarantees that all column\n  ** names are unique.\n  **\n  ** The AAAA suffix is not strictly necessary.  It is included\n  ** for the convenience of people who might examine the generated\n  ** %_content table and wonder what the columns are used for.\n  */\n  pSpec->azContentColumn = sqlite3_malloc( pSpec->nColumn * sizeof(char *) );\n  if( pSpec->azContentColumn==0 ){\n    clearTableSpec(pSpec);\n    return SQLITE_NOMEM;\n  }\n  for(i=0; i<pSpec->nColumn; i++){\n    char *p;\n    pSpec->azContentColumn[i] = sqlite3_mprintf(\"c%d%s\", i, azArg[i]);\n    for (p = pSpec->azContentColumn[i]; *p ; ++p) {\n      if( !safe_isalnum(*p) ) *p = '_';\n    }\n  }\n\n  /*\n  ** Parse the tokenizer specification string.\n  */\n  pSpec->azTokenizer = tokenizeString(zTokenizer, &n);\n  tokenListToIdList(pSpec->azTokenizer);\n\n  return SQLITE_OK;\n}\n\n/*\n** Generate a CREATE TABLE statement that describes the schema of\n** the virtual table.  Return a pointer to this schema string.\n**\n** Space is obtained from sqlite3_mprintf() and should be freed\n** using sqlite3_free().\n*/\nstatic char *fulltextSchema(\n  int nColumn,                  /* Number of columns */\n  const char *const* azColumn,  /* List of columns */\n  const char *zTableName        /* Name of the table */\n){\n  int i;\n  char *zSchema, *zNext;\n  const char *zSep = \"(\";\n  zSchema = sqlite3_mprintf(\"CREATE TABLE x\");\n  for(i=0; i<nColumn; i++){\n    zNext = sqlite3_mprintf(\"%s%s%Q\", zSchema, zSep, azColumn[i]);\n    sqlite3_free(zSchema);\n    zSchema = zNext;\n    zSep = \",\";\n  }\n  zNext = sqlite3_mprintf(\"%s,%Q)\", zSchema, zTableName);\n  sqlite3_free(zSchema);\n  return zNext;\n}\n\n/*\n** Build a new sqlite3_vtab structure that will describe the\n** fulltext index defined by spec.\n*/\nstatic int constructVtab(\n  sqlite3 *db,              /* The SQLite database connection */\n  fts2Hash *pHash,          /* Hash table containing tokenizers */\n  TableSpec *spec,          /* Parsed spec information from parseSpec() */\n  sqlite3_vtab **ppVTab,    /* Write the resulting vtab structure here */\n  char **pzErr              /* Write any error message here */\n){\n  int rc;\n  int n;\n  fulltext_vtab *v = 0;\n  const sqlite3_tokenizer_module *m = NULL;\n  char *schema;\n\n  char const *zTok;         /* Name of tokenizer to use for this fts table */\n  int nTok;                 /* Length of zTok, including nul terminator */\n\n  v = (fulltext_vtab *) sqlite3_malloc(sizeof(fulltext_vtab));\n  if( v==0 ) return SQLITE_NOMEM;\n  CLEAR(v);\n  /* sqlite will initialize v->base */\n  v->db = db;\n  v->zDb = spec->zDb;       /* Freed when azColumn is freed */\n  v->zName = spec->zName;   /* Freed when azColumn is freed */\n  v->nColumn = spec->nColumn;\n  v->azContentColumn = spec->azContentColumn;\n  spec->azContentColumn = 0;\n  v->azColumn = spec->azColumn;\n  spec->azColumn = 0;\n\n  if( spec->azTokenizer==0 ){\n    return SQLITE_NOMEM;\n  }\n\n  zTok = spec->azTokenizer[0]; \n  if( !zTok ){\n    zTok = \"simple\";\n  }\n  nTok = strlen(zTok)+1;\n\n  m = (sqlite3_tokenizer_module *)sqlite3Fts2HashFind(pHash, zTok, nTok);\n  if( !m ){\n    *pzErr = sqlite3_mprintf(\"unknown tokenizer: %s\", spec->azTokenizer[0]);\n    rc = SQLITE_ERROR;\n    goto err;\n  }\n\n  for(n=0; spec->azTokenizer[n]; n++){}\n  if( n ){\n    rc = m->xCreate(n-1, (const char*const*)&spec->azTokenizer[1],\n                    &v->pTokenizer);\n  }else{\n    rc = m->xCreate(0, 0, &v->pTokenizer);\n  }\n  if( rc!=SQLITE_OK ) goto err;\n  v->pTokenizer->pModule = m;\n\n  /* TODO: verify the existence of backing tables foo_content, foo_term */\n\n  schema = fulltextSchema(v->nColumn, (const char*const*)v->azColumn,\n                          spec->zName);\n  rc = sqlite3_declare_vtab(db, schema);\n  sqlite3_free(schema);\n  if( rc!=SQLITE_OK ) goto err;\n\n  memset(v->pFulltextStatements, 0, sizeof(v->pFulltextStatements));\n\n  /* Indicate that the buffer is not live. */\n  v->nPendingData = -1;\n\n  *ppVTab = &v->base;\n  TRACE((\"FTS2 Connect %p\\n\", v));\n\n  return rc;\n\nerr:\n  fulltext_vtab_destroy(v);\n  return rc;\n}\n\nstatic int fulltextConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  TableSpec spec;\n  int rc = parseSpec(&spec, argc, argv, pzErr);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = constructVtab(db, (fts2Hash *)pAux, &spec, ppVTab, pzErr);\n  clearTableSpec(&spec);\n  return rc;\n}\n\n/* The %_content table holds the text of each document, with\n** the rowid used as the docid.\n*/\n/* TODO(shess) This comment needs elaboration to match the updated\n** code.  Work it into the top-of-file comment at that time.\n*/\nstatic int fulltextCreate(sqlite3 *db, void *pAux,\n                          int argc, const char * const *argv,\n                          sqlite3_vtab **ppVTab, char **pzErr){\n  int rc;\n  TableSpec spec;\n  StringBuffer schema;\n  TRACE((\"FTS2 Create\\n\"));\n\n  rc = parseSpec(&spec, argc, argv, pzErr);\n  if( rc!=SQLITE_OK ) return rc;\n\n  initStringBuffer(&schema);\n  append(&schema, \"CREATE TABLE %_content(\");\n  appendList(&schema, spec.nColumn, spec.azContentColumn);\n  append(&schema, \")\");\n  rc = sql_exec(db, spec.zDb, spec.zName, stringBufferData(&schema));\n  stringBufferDestroy(&schema);\n  if( rc!=SQLITE_OK ) goto out;\n\n  rc = sql_exec(db, spec.zDb, spec.zName,\n                \"create table %_segments(block blob);\");\n  if( rc!=SQLITE_OK ) goto out;\n\n  rc = sql_exec(db, spec.zDb, spec.zName,\n                \"create table %_segdir(\"\n                \"  level integer,\"\n                \"  idx integer,\"\n                \"  start_block integer,\"\n                \"  leaves_end_block integer,\"\n                \"  end_block integer,\"\n                \"  root blob,\"\n                \"  primary key(level, idx)\"\n                \");\");\n  if( rc!=SQLITE_OK ) goto out;\n\n  rc = constructVtab(db, (fts2Hash *)pAux, &spec, ppVTab, pzErr);\n\nout:\n  clearTableSpec(&spec);\n  return rc;\n}\n\n/* Decide how to handle an SQL query. */\nstatic int fulltextBestIndex(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  int i;\n  TRACE((\"FTS2 BestIndex\\n\"));\n\n  for(i=0; i<pInfo->nConstraint; ++i){\n    const struct sqlite3_index_constraint *pConstraint;\n    pConstraint = &pInfo->aConstraint[i];\n    if( pConstraint->usable ) {\n      if( pConstraint->iColumn==-1 &&\n          pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n        pInfo->idxNum = QUERY_ROWID;      /* lookup by rowid */\n        TRACE((\"FTS2 QUERY_ROWID\\n\"));\n      } else if( pConstraint->iColumn>=0 &&\n                 pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n        /* full-text search */\n        pInfo->idxNum = QUERY_FULLTEXT + pConstraint->iColumn;\n        TRACE((\"FTS2 QUERY_FULLTEXT %d\\n\", pConstraint->iColumn));\n      } else continue;\n\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n\n      /* An arbitrary value for now.\n       * TODO: Perhaps rowid matches should be considered cheaper than\n       * full-text searches. */\n      pInfo->estimatedCost = 1.0;   \n\n      return SQLITE_OK;\n    }\n  }\n  pInfo->idxNum = QUERY_GENERIC;\n  return SQLITE_OK;\n}\n\nstatic int fulltextDisconnect(sqlite3_vtab *pVTab){\n  TRACE((\"FTS2 Disconnect %p\\n\", pVTab));\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextDestroy(sqlite3_vtab *pVTab){\n  fulltext_vtab *v = (fulltext_vtab *)pVTab;\n  int rc;\n\n  TRACE((\"FTS2 Destroy %p\\n\", pVTab));\n  rc = sql_exec(v->db, v->zDb, v->zName,\n                \"drop table if exists %_content;\"\n                \"drop table if exists %_segments;\"\n                \"drop table if exists %_segdir;\"\n                );\n  if( rc!=SQLITE_OK ) return rc;\n\n  fulltext_vtab_destroy((fulltext_vtab *)pVTab);\n  return SQLITE_OK;\n}\n\nstatic int fulltextOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  fulltext_cursor *c;\n\n  c = (fulltext_cursor *) sqlite3_malloc(sizeof(fulltext_cursor));\n  if( c ){\n    memset(c, 0, sizeof(fulltext_cursor));\n    /* sqlite will initialize c->base */\n    *ppCursor = &c->base;\n    TRACE((\"FTS2 Open %p: %p\\n\", pVTab, c));\n    return SQLITE_OK;\n  }else{\n    return SQLITE_NOMEM;\n  }\n}\n\n\n/* Free all of the dynamically allocated memory held by *q\n*/\nstatic void queryClear(Query *q){\n  int i;\n  for(i = 0; i < q->nTerms; ++i){\n    sqlite3_free(q->pTerms[i].pTerm);\n  }\n  sqlite3_free(q->pTerms);\n  CLEAR(q);\n}\n\n/* Free all of the dynamically allocated memory held by the\n** Snippet\n*/\nstatic void snippetClear(Snippet *p){\n  sqlite3_free(p->aMatch);\n  sqlite3_free(p->zOffset);\n  sqlite3_free(p->zSnippet);\n  CLEAR(p);\n}\n/*\n** Append a single entry to the p->aMatch[] log.\n*/\nstatic void snippetAppendMatch(\n  Snippet *p,               /* Append the entry to this snippet */\n  int iCol, int iTerm,      /* The column and query term */\n  int iStart, int nByte     /* Offset and size of the match */\n){\n  int i;\n  struct snippetMatch *pMatch;\n  if( p->nMatch+1>=p->nAlloc ){\n    p->nAlloc = p->nAlloc*2 + 10;\n    p->aMatch = sqlite3_realloc(p->aMatch, p->nAlloc*sizeof(p->aMatch[0]) );\n    if( p->aMatch==0 ){\n      p->nMatch = 0;\n      p->nAlloc = 0;\n      return;\n    }\n  }\n  i = p->nMatch++;\n  pMatch = &p->aMatch[i];\n  pMatch->iCol = iCol;\n  pMatch->iTerm = iTerm;\n  pMatch->iStart = iStart;\n  pMatch->nByte = nByte;\n}\n\n/*\n** Sizing information for the circular buffer used in snippetOffsetsOfColumn()\n*/\n#define FTS2_ROTOR_SZ   (32)\n#define FTS2_ROTOR_MASK (FTS2_ROTOR_SZ-1)\n\n/*\n** Add entries to pSnippet->aMatch[] for every match that occurs against\n** document zDoc[0..nDoc-1] which is stored in column iColumn.\n*/\nstatic void snippetOffsetsOfColumn(\n  Query *pQuery,\n  Snippet *pSnippet,\n  int iColumn,\n  const char *zDoc,\n  int nDoc\n){\n  const sqlite3_tokenizer_module *pTModule;  /* The tokenizer module */\n  sqlite3_tokenizer *pTokenizer;             /* The specific tokenizer */\n  sqlite3_tokenizer_cursor *pTCursor;        /* Tokenizer cursor */\n  fulltext_vtab *pVtab;                /* The full text index */\n  int nColumn;                         /* Number of columns in the index */\n  const QueryTerm *aTerm;              /* Query string terms */\n  int nTerm;                           /* Number of query string terms */  \n  int i, j;                            /* Loop counters */\n  int rc;                              /* Return code */\n  unsigned int match, prevMatch;       /* Phrase search bitmasks */\n  const char *zToken;                  /* Next token from the tokenizer */\n  int nToken;                          /* Size of zToken */\n  int iBegin, iEnd, iPos;              /* Offsets of beginning and end */\n\n  /* The following variables keep a circular buffer of the last\n  ** few tokens */\n  unsigned int iRotor = 0;             /* Index of current token */\n  int iRotorBegin[FTS2_ROTOR_SZ];      /* Beginning offset of token */\n  int iRotorLen[FTS2_ROTOR_SZ];        /* Length of token */\n\n  pVtab = pQuery->pFts;\n  nColumn = pVtab->nColumn;\n  pTokenizer = pVtab->pTokenizer;\n  pTModule = pTokenizer->pModule;\n  rc = pTModule->xOpen(pTokenizer, zDoc, nDoc, &pTCursor);\n  if( rc ) return;\n  pTCursor->pTokenizer = pTokenizer;\n  aTerm = pQuery->pTerms;\n  nTerm = pQuery->nTerms;\n  if( nTerm>=FTS2_ROTOR_SZ ){\n    nTerm = FTS2_ROTOR_SZ - 1;\n  }\n  prevMatch = 0;\n  while(1){\n    rc = pTModule->xNext(pTCursor, &zToken, &nToken, &iBegin, &iEnd, &iPos);\n    if( rc ) break;\n    iRotorBegin[iRotor&FTS2_ROTOR_MASK] = iBegin;\n    iRotorLen[iRotor&FTS2_ROTOR_MASK] = iEnd-iBegin;\n    match = 0;\n    for(i=0; i<nTerm; i++){\n      int iCol;\n      iCol = aTerm[i].iColumn;\n      if( iCol>=0 && iCol<nColumn && iCol!=iColumn ) continue;\n      if( aTerm[i].nTerm>nToken ) continue;\n      if( !aTerm[i].isPrefix && aTerm[i].nTerm<nToken ) continue;\n      assert( aTerm[i].nTerm<=nToken );\n      if( memcmp(aTerm[i].pTerm, zToken, aTerm[i].nTerm) ) continue;\n      if( aTerm[i].iPhrase>1 && (prevMatch & (1<<i))==0 ) continue;\n      match |= 1<<i;\n      if( i==nTerm-1 || aTerm[i+1].iPhrase==1 ){\n        for(j=aTerm[i].iPhrase-1; j>=0; j--){\n          int k = (iRotor-j) & FTS2_ROTOR_MASK;\n          snippetAppendMatch(pSnippet, iColumn, i-j,\n                iRotorBegin[k], iRotorLen[k]);\n        }\n      }\n    }\n    prevMatch = match<<1;\n    iRotor++;\n  }\n  pTModule->xClose(pTCursor);  \n}\n\n\n/*\n** Compute all offsets for the current row of the query.  \n** If the offsets have already been computed, this routine is a no-op.\n*/\nstatic void snippetAllOffsets(fulltext_cursor *p){\n  int nColumn;\n  int iColumn, i;\n  int iFirst, iLast;\n  fulltext_vtab *pFts;\n\n  if( p->snippet.nMatch ) return;\n  if( p->q.nTerms==0 ) return;\n  pFts = p->q.pFts;\n  nColumn = pFts->nColumn;\n  iColumn = (p->iCursorType - QUERY_FULLTEXT);\n  if( iColumn<0 || iColumn>=nColumn ){\n    iFirst = 0;\n    iLast = nColumn-1;\n  }else{\n    iFirst = iColumn;\n    iLast = iColumn;\n  }\n  for(i=iFirst; i<=iLast; i++){\n    const char *zDoc;\n    int nDoc;\n    zDoc = (const char*)sqlite3_column_text(p->pStmt, i+1);\n    nDoc = sqlite3_column_bytes(p->pStmt, i+1);\n    snippetOffsetsOfColumn(&p->q, &p->snippet, i, zDoc, nDoc);\n  }\n}\n\n/*\n** Convert the information in the aMatch[] array of the snippet\n** into the string zOffset[0..nOffset-1].\n*/\nstatic void snippetOffsetText(Snippet *p){\n  int i;\n  int cnt = 0;\n  StringBuffer sb;\n  char zBuf[200];\n  if( p->zOffset ) return;\n  initStringBuffer(&sb);\n  for(i=0; i<p->nMatch; i++){\n    struct snippetMatch *pMatch = &p->aMatch[i];\n    zBuf[0] = ' ';\n    sqlite3_snprintf(sizeof(zBuf)-1, &zBuf[cnt>0], \"%d %d %d %d\",\n        pMatch->iCol, pMatch->iTerm, pMatch->iStart, pMatch->nByte);\n    append(&sb, zBuf);\n    cnt++;\n  }\n  p->zOffset = stringBufferData(&sb);\n  p->nOffset = stringBufferLength(&sb);\n}\n\n/*\n** zDoc[0..nDoc-1] is phrase of text.  aMatch[0..nMatch-1] are a set\n** of matching words some of which might be in zDoc.  zDoc is column\n** number iCol.\n**\n** iBreak is suggested spot in zDoc where we could begin or end an\n** excerpt.  Return a value similar to iBreak but possibly adjusted\n** to be a little left or right so that the break point is better.\n*/\nstatic int wordBoundary(\n  int iBreak,                   /* The suggested break point */\n  const char *zDoc,             /* Document text */\n  int nDoc,                     /* Number of bytes in zDoc[] */\n  struct snippetMatch *aMatch,  /* Matching words */\n  int nMatch,                   /* Number of entries in aMatch[] */\n  int iCol                      /* The column number for zDoc[] */\n){\n  int i;\n  if( iBreak<=10 ){\n    return 0;\n  }\n  if( iBreak>=nDoc-10 ){\n    return nDoc;\n  }\n  for(i=0; i<nMatch && aMatch[i].iCol<iCol; i++){}\n  while( i<nMatch && aMatch[i].iStart+aMatch[i].nByte<iBreak ){ i++; }\n  if( i<nMatch ){\n    if( aMatch[i].iStart<iBreak+10 ){\n      return aMatch[i].iStart;\n    }\n    if( i>0 && aMatch[i-1].iStart+aMatch[i-1].nByte>=iBreak ){\n      return aMatch[i-1].iStart;\n    }\n  }\n  for(i=1; i<=10; i++){\n    if( safe_isspace(zDoc[iBreak-i]) ){\n      return iBreak - i + 1;\n    }\n    if( safe_isspace(zDoc[iBreak+i]) ){\n      return iBreak + i + 1;\n    }\n  }\n  return iBreak;\n}\n\n\n\n/*\n** Allowed values for Snippet.aMatch[].snStatus\n*/\n#define SNIPPET_IGNORE  0   /* It is ok to omit this match from the snippet */\n#define SNIPPET_DESIRED 1   /* We want to include this match in the snippet */\n\n/*\n** Generate the text of a snippet.\n*/\nstatic void snippetText(\n  fulltext_cursor *pCursor,   /* The cursor we need the snippet for */\n  const char *zStartMark,     /* Markup to appear before each match */\n  const char *zEndMark,       /* Markup to appear after each match */\n  const char *zEllipsis       /* Ellipsis mark */\n){\n  int i, j;\n  struct snippetMatch *aMatch;\n  int nMatch;\n  int nDesired;\n  StringBuffer sb;\n  int tailCol;\n  int tailOffset;\n  int iCol;\n  int nDoc;\n  const char *zDoc;\n  int iStart, iEnd;\n  int tailEllipsis = 0;\n  int iMatch;\n  \n\n  sqlite3_free(pCursor->snippet.zSnippet);\n  pCursor->snippet.zSnippet = 0;\n  aMatch = pCursor->snippet.aMatch;\n  nMatch = pCursor->snippet.nMatch;\n  initStringBuffer(&sb);\n\n  for(i=0; i<nMatch; i++){\n    aMatch[i].snStatus = SNIPPET_IGNORE;\n  }\n  nDesired = 0;\n  for(i=0; i<pCursor->q.nTerms; i++){\n    for(j=0; j<nMatch; j++){\n      if( aMatch[j].iTerm==i ){\n        aMatch[j].snStatus = SNIPPET_DESIRED;\n        nDesired++;\n        break;\n      }\n    }\n  }\n\n  iMatch = 0;\n  tailCol = -1;\n  tailOffset = 0;\n  for(i=0; i<nMatch && nDesired>0; i++){\n    if( aMatch[i].snStatus!=SNIPPET_DESIRED ) continue;\n    nDesired--;\n    iCol = aMatch[i].iCol;\n    zDoc = (const char*)sqlite3_column_text(pCursor->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCursor->pStmt, iCol+1);\n    iStart = aMatch[i].iStart - 40;\n    iStart = wordBoundary(iStart, zDoc, nDoc, aMatch, nMatch, iCol);\n    if( iStart<=10 ){\n      iStart = 0;\n    }\n    if( iCol==tailCol && iStart<=tailOffset+20 ){\n      iStart = tailOffset;\n    }\n    if( (iCol!=tailCol && tailCol>=0) || iStart!=tailOffset ){\n      trimWhiteSpace(&sb);\n      appendWhiteSpace(&sb);\n      append(&sb, zEllipsis);\n      appendWhiteSpace(&sb);\n    }\n    iEnd = aMatch[i].iStart + aMatch[i].nByte + 40;\n    iEnd = wordBoundary(iEnd, zDoc, nDoc, aMatch, nMatch, iCol);\n    if( iEnd>=nDoc-10 ){\n      iEnd = nDoc;\n      tailEllipsis = 0;\n    }else{\n      tailEllipsis = 1;\n    }\n    while( iMatch<nMatch && aMatch[iMatch].iCol<iCol ){ iMatch++; }\n    while( iStart<iEnd ){\n      while( iMatch<nMatch && aMatch[iMatch].iStart<iStart\n             && aMatch[iMatch].iCol<=iCol ){\n        iMatch++;\n      }\n      if( iMatch<nMatch && aMatch[iMatch].iStart<iEnd\n             && aMatch[iMatch].iCol==iCol ){\n        nappend(&sb, &zDoc[iStart], aMatch[iMatch].iStart - iStart);\n        iStart = aMatch[iMatch].iStart;\n        append(&sb, zStartMark);\n        nappend(&sb, &zDoc[iStart], aMatch[iMatch].nByte);\n        append(&sb, zEndMark);\n        iStart += aMatch[iMatch].nByte;\n        for(j=iMatch+1; j<nMatch; j++){\n          if( aMatch[j].iTerm==aMatch[iMatch].iTerm\n              && aMatch[j].snStatus==SNIPPET_DESIRED ){\n            nDesired--;\n            aMatch[j].snStatus = SNIPPET_IGNORE;\n          }\n        }\n      }else{\n        nappend(&sb, &zDoc[iStart], iEnd - iStart);\n        iStart = iEnd;\n      }\n    }\n    tailCol = iCol;\n    tailOffset = iEnd;\n  }\n  trimWhiteSpace(&sb);\n  if( tailEllipsis ){\n    appendWhiteSpace(&sb);\n    append(&sb, zEllipsis);\n  }\n  pCursor->snippet.zSnippet = stringBufferData(&sb);\n  pCursor->snippet.nSnippet = stringBufferLength(&sb);\n}\n\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fulltextClose(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  TRACE((\"FTS2 Close %p\\n\", c));\n  sqlite3_finalize(c->pStmt);\n  queryClear(&c->q);\n  snippetClear(&c->snippet);\n  if( c->result.nData!=0 ) dlrDestroy(&c->reader);\n  dataBufferDestroy(&c->result);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\nstatic int fulltextNext(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  int rc;\n\n  TRACE((\"FTS2 Next %p\\n\", pCursor));\n  snippetClear(&c->snippet);\n  if( c->iCursorType < QUERY_FULLTEXT ){\n    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n    rc = sqlite3_step(c->pStmt);\n    switch( rc ){\n      case SQLITE_ROW:\n        c->eof = 0;\n        return SQLITE_OK;\n      case SQLITE_DONE:\n        c->eof = 1;\n        return SQLITE_OK;\n      default:\n        c->eof = 1;\n        return rc;\n    }\n  } else {  /* full-text query */\n    rc = sqlite3_reset(c->pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n\n    if( c->result.nData==0 || dlrAtEnd(&c->reader) ){\n      c->eof = 1;\n      return SQLITE_OK;\n    }\n    rc = sqlite3_bind_int64(c->pStmt, 1, dlrDocid(&c->reader));\n    dlrStep(&c->reader);\n    if( rc!=SQLITE_OK ) return rc;\n    /* TODO(shess) Handle SQLITE_SCHEMA AND SQLITE_BUSY. */\n    rc = sqlite3_step(c->pStmt);\n    if( rc==SQLITE_ROW ){   /* the case we expect */\n      c->eof = 0;\n      return SQLITE_OK;\n    }\n    /* an error occurred; abort */\n    return rc==SQLITE_DONE ? SQLITE_ERROR : rc;\n  }\n}\n\n\n/* TODO(shess) If we pushed LeafReader to the top of the file, or to\n** another file, term_select() could be pushed above\n** docListOfTerm().\n*/\nstatic int termSelect(fulltext_vtab *v, int iColumn,\n                      const char *pTerm, int nTerm, int isPrefix,\n                      DocListType iType, DataBuffer *out);\n\n/* Return a DocList corresponding to the query term *pTerm.  If *pTerm\n** is the first term of a phrase query, go ahead and evaluate the phrase\n** query and return the doclist for the entire phrase query.\n**\n** The resulting DL_DOCIDS doclist is stored in pResult, which is\n** overwritten.\n*/\nstatic int docListOfTerm(\n  fulltext_vtab *v,   /* The full text index */\n  int iColumn,        /* column to restrict to.  No restriction if >=nColumn */\n  QueryTerm *pQTerm,  /* Term we are looking for, or 1st term of a phrase */\n  DataBuffer *pResult /* Write the result here */\n){\n  DataBuffer left, right, new;\n  int i, rc;\n\n  /* No phrase search if no position info. */\n  assert( pQTerm->nPhrase==0 || DL_DEFAULT!=DL_DOCIDS );\n\n  /* This code should never be called with buffered updates. */\n  assert( v->nPendingData<0 );\n\n  dataBufferInit(&left, 0);\n  rc = termSelect(v, iColumn, pQTerm->pTerm, pQTerm->nTerm, pQTerm->isPrefix,\n                  0<pQTerm->nPhrase ? DL_POSITIONS : DL_DOCIDS, &left);\n  if( rc ) return rc;\n  for(i=1; i<=pQTerm->nPhrase && left.nData>0; i++){\n    dataBufferInit(&right, 0);\n    rc = termSelect(v, iColumn, pQTerm[i].pTerm, pQTerm[i].nTerm,\n                    pQTerm[i].isPrefix, DL_POSITIONS, &right);\n    if( rc ){\n      dataBufferDestroy(&left);\n      return rc;\n    }\n    dataBufferInit(&new, 0);\n    docListPhraseMerge(left.pData, left.nData, right.pData, right.nData,\n                       i<pQTerm->nPhrase ? DL_POSITIONS : DL_DOCIDS, &new);\n    dataBufferDestroy(&left);\n    dataBufferDestroy(&right);\n    left = new;\n  }\n  *pResult = left;\n  return SQLITE_OK;\n}\n\n/* Add a new term pTerm[0..nTerm-1] to the query *q.\n*/\nstatic void queryAdd(Query *q, const char *pTerm, int nTerm){\n  QueryTerm *t;\n  ++q->nTerms;\n  q->pTerms = sqlite3_realloc(q->pTerms, q->nTerms * sizeof(q->pTerms[0]));\n  if( q->pTerms==0 ){\n    q->nTerms = 0;\n    return;\n  }\n  t = &q->pTerms[q->nTerms - 1];\n  CLEAR(t);\n  t->pTerm = sqlite3_malloc(nTerm+1);\n  memcpy(t->pTerm, pTerm, nTerm);\n  t->pTerm[nTerm] = 0;\n  t->nTerm = nTerm;\n  t->isOr = q->nextIsOr;\n  t->isPrefix = 0;\n  q->nextIsOr = 0;\n  t->iColumn = q->nextColumn;\n  q->nextColumn = q->dfltColumn;\n}\n\n/*\n** Check to see if the string zToken[0...nToken-1] matches any\n** column name in the virtual table.   If it does,\n** return the zero-indexed column number.  If not, return -1.\n*/\nstatic int checkColumnSpecifier(\n  fulltext_vtab *pVtab,    /* The virtual table */\n  const char *zToken,      /* Text of the token */\n  int nToken               /* Number of characters in the token */\n){\n  int i;\n  for(i=0; i<pVtab->nColumn; i++){\n    if( memcmp(pVtab->azColumn[i], zToken, nToken)==0\n        && pVtab->azColumn[i][nToken]==0 ){\n      return i;\n    }\n  }\n  return -1;\n}\n\n/*\n** Parse the text at pSegment[0..nSegment-1].  Add additional terms\n** to the query being assemblied in pQuery.\n**\n** inPhrase is true if pSegment[0..nSegement-1] is contained within\n** double-quotes.  If inPhrase is true, then the first term\n** is marked with the number of terms in the phrase less one and\n** OR and \"-\" syntax is ignored.  If inPhrase is false, then every\n** term found is marked with nPhrase=0 and OR and \"-\" syntax is significant.\n*/\nstatic int tokenizeSegment(\n  sqlite3_tokenizer *pTokenizer,          /* The tokenizer to use */\n  const char *pSegment, int nSegment,     /* Query expression being parsed */\n  int inPhrase,                           /* True if within \"...\" */\n  Query *pQuery                           /* Append results here */\n){\n  const sqlite3_tokenizer_module *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCursor;\n  int firstIndex = pQuery->nTerms;\n  int iCol;\n  int nTerm = 1;\n  \n  int rc = pModule->xOpen(pTokenizer, pSegment, nSegment, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n  pCursor->pTokenizer = pTokenizer;\n\n  while( 1 ){\n    const char *pToken;\n    int nToken, iBegin, iEnd, iPos;\n\n    rc = pModule->xNext(pCursor,\n                        &pToken, &nToken,\n                        &iBegin, &iEnd, &iPos);\n    if( rc!=SQLITE_OK ) break;\n    if( !inPhrase &&\n        pSegment[iEnd]==':' &&\n         (iCol = checkColumnSpecifier(pQuery->pFts, pToken, nToken))>=0 ){\n      pQuery->nextColumn = iCol;\n      continue;\n    }\n    if( !inPhrase && pQuery->nTerms>0 && nToken==2\n         && pSegment[iBegin]=='O' && pSegment[iBegin+1]=='R' ){\n      pQuery->nextIsOr = 1;\n      continue;\n    }\n    queryAdd(pQuery, pToken, nToken);\n    if( !inPhrase && iBegin>0 && pSegment[iBegin-1]=='-' ){\n      pQuery->pTerms[pQuery->nTerms-1].isNot = 1;\n    }\n    if( iEnd<nSegment && pSegment[iEnd]=='*' ){\n      pQuery->pTerms[pQuery->nTerms-1].isPrefix = 1;\n    }\n    pQuery->pTerms[pQuery->nTerms-1].iPhrase = nTerm;\n    if( inPhrase ){\n      nTerm++;\n    }\n  }\n\n  if( inPhrase && pQuery->nTerms>firstIndex ){\n    pQuery->pTerms[firstIndex].nPhrase = pQuery->nTerms - firstIndex - 1;\n  }\n\n  return pModule->xClose(pCursor);\n}\n\n/* Parse a query string, yielding a Query object pQuery.\n**\n** The calling function will need to queryClear() to clean up\n** the dynamically allocated memory held by pQuery.\n*/\nstatic int parseQuery(\n  fulltext_vtab *v,        /* The fulltext index */\n  const char *zInput,      /* Input text of the query string */\n  int nInput,              /* Size of the input text */\n  int dfltColumn,          /* Default column of the index to match against */\n  Query *pQuery            /* Write the parse results here. */\n){\n  int iInput, inPhrase = 0;\n\n  if( zInput==0 ) nInput = 0;\n  if( nInput<0 ) nInput = strlen(zInput);\n  pQuery->nTerms = 0;\n  pQuery->pTerms = NULL;\n  pQuery->nextIsOr = 0;\n  pQuery->nextColumn = dfltColumn;\n  pQuery->dfltColumn = dfltColumn;\n  pQuery->pFts = v;\n\n  for(iInput=0; iInput<nInput; ++iInput){\n    int i;\n    for(i=iInput; i<nInput && zInput[i]!='\"'; ++i){}\n    if( i>iInput ){\n      tokenizeSegment(v->pTokenizer, zInput+iInput, i-iInput, inPhrase,\n                       pQuery);\n    }\n    iInput = i;\n    if( i<nInput ){\n      assert( zInput[i]=='\"' );\n      inPhrase = !inPhrase;\n    }\n  }\n\n  if( inPhrase ){\n    /* unmatched quote */\n    queryClear(pQuery);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/* TODO(shess) Refactor the code to remove this forward decl. */\nstatic int flushPendingTerms(fulltext_vtab *v);\n\n/* Perform a full-text query using the search expression in\n** zInput[0..nInput-1].  Return a list of matching documents\n** in pResult.\n**\n** Queries must match column iColumn.  Or if iColumn>=nColumn\n** they are allowed to match against any column.\n*/\nstatic int fulltextQuery(\n  fulltext_vtab *v,      /* The full text index */\n  int iColumn,           /* Match against this column by default */\n  const char *zInput,    /* The query string */\n  int nInput,            /* Number of bytes in zInput[] */\n  DataBuffer *pResult,   /* Write the result doclist here */\n  Query *pQuery          /* Put parsed query string here */\n){\n  int i, iNext, rc;\n  DataBuffer left, right, or, new;\n  int nNot = 0;\n  QueryTerm *aTerm;\n\n  /* TODO(shess) Instead of flushing pendingTerms, we could query for\n  ** the relevant term and merge the doclist into what we receive from\n  ** the database.  Wait and see if this is a common issue, first.\n  **\n  ** A good reason not to flush is to not generate update-related\n  ** error codes from here.\n  */\n\n  /* Flush any buffered updates before executing the query. */\n  rc = flushPendingTerms(v);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* TODO(shess) I think that the queryClear() calls below are not\n  ** necessary, because fulltextClose() already clears the query.\n  */\n  rc = parseQuery(v, zInput, nInput, iColumn, pQuery);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Empty or NULL queries return no results. */\n  if( pQuery->nTerms==0 ){\n    dataBufferInit(pResult, 0);\n    return SQLITE_OK;\n  }\n\n  /* Merge AND terms. */\n  /* TODO(shess) I think we can early-exit if( i>nNot && left.nData==0 ). */\n  aTerm = pQuery->pTerms;\n  for(i = 0; i<pQuery->nTerms; i=iNext){\n    if( aTerm[i].isNot ){\n      /* Handle all NOT terms in a separate pass */\n      nNot++;\n      iNext = i + aTerm[i].nPhrase+1;\n      continue;\n    }\n    iNext = i + aTerm[i].nPhrase + 1;\n    rc = docListOfTerm(v, aTerm[i].iColumn, &aTerm[i], &right);\n    if( rc ){\n      if( i!=nNot ) dataBufferDestroy(&left);\n      queryClear(pQuery);\n      return rc;\n    }\n    while( iNext<pQuery->nTerms && aTerm[iNext].isOr ){\n      rc = docListOfTerm(v, aTerm[iNext].iColumn, &aTerm[iNext], &or);\n      iNext += aTerm[iNext].nPhrase + 1;\n      if( rc ){\n        if( i!=nNot ) dataBufferDestroy(&left);\n        dataBufferDestroy(&right);\n        queryClear(pQuery);\n        return rc;\n      }\n      dataBufferInit(&new, 0);\n      docListOrMerge(right.pData, right.nData, or.pData, or.nData, &new);\n      dataBufferDestroy(&right);\n      dataBufferDestroy(&or);\n      right = new;\n    }\n    if( i==nNot ){           /* first term processed. */\n      left = right;\n    }else{\n      dataBufferInit(&new, 0);\n      docListAndMerge(left.pData, left.nData, right.pData, right.nData, &new);\n      dataBufferDestroy(&right);\n      dataBufferDestroy(&left);\n      left = new;\n    }\n  }\n\n  if( nNot==pQuery->nTerms ){\n    /* We do not yet know how to handle a query of only NOT terms */\n    return SQLITE_ERROR;\n  }\n\n  /* Do the EXCEPT terms */\n  for(i=0; i<pQuery->nTerms;  i += aTerm[i].nPhrase + 1){\n    if( !aTerm[i].isNot ) continue;\n    rc = docListOfTerm(v, aTerm[i].iColumn, &aTerm[i], &right);\n    if( rc ){\n      queryClear(pQuery);\n      dataBufferDestroy(&left);\n      return rc;\n    }\n    dataBufferInit(&new, 0);\n    docListExceptMerge(left.pData, left.nData, right.pData, right.nData, &new);\n    dataBufferDestroy(&right);\n    dataBufferDestroy(&left);\n    left = new;\n  }\n\n  *pResult = left;\n  return rc;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==QUERY_GENERIC then do a full table scan against\n** the %_content table.\n**\n** If idxNum==QUERY_ROWID then do a rowid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=QUERY_FULLTEXT then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-QUERY_FULLTEXT, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\n/* TODO(shess) Upgrade the cursor initialization and destruction to\n** account for fulltextFilter() being called multiple times on the\n** same cursor.  The current solution is very fragile.  Apply fix to\n** fts2 as appropriate.\n*/\nstatic int fulltextFilter(\n  sqlite3_vtab_cursor *pCursor,     /* The cursor used for this query */\n  int idxNum, const char *idxStr,   /* Which indexing scheme to use */\n  int argc, sqlite3_value **argv    /* Arguments for the indexing scheme */\n){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  fulltext_vtab *v = cursor_vtab(c);\n  int rc;\n\n  TRACE((\"FTS2 Filter %p\\n\",pCursor));\n\n  /* If the cursor has a statement that was not prepared according to\n  ** idxNum, clear it.  I believe all calls to fulltextFilter with a\n  ** given cursor will have the same idxNum , but in this case it's\n  ** easy to be safe.\n  */\n  if( c->pStmt && c->iCursorType!=idxNum ){\n    sqlite3_finalize(c->pStmt);\n    c->pStmt = NULL;\n  }\n\n  /* Get a fresh statement appropriate to idxNum. */\n  /* TODO(shess): Add a prepared-statement cache in the vt structure.\n  ** The cache must handle multiple open cursors.  Easier to cache the\n  ** statement variants at the vt to reduce malloc/realloc/free here.\n  ** Or we could have a StringBuffer variant which allowed stack\n  ** construction for small values.\n  */\n  if( !c->pStmt ){\n    char *zSql = sqlite3_mprintf(\"select rowid, * from %%_content %s\",\n                                 idxNum==QUERY_GENERIC ? \"\" : \"where rowid=?\");\n    rc = sql_prepare(v->db, v->zDb, v->zName, &c->pStmt, zSql);\n    sqlite3_free(zSql);\n    if( rc!=SQLITE_OK ) return rc;\n    c->iCursorType = idxNum;\n  }else{\n    sqlite3_reset(c->pStmt);\n    assert( c->iCursorType==idxNum );\n  }\n\n  switch( idxNum ){\n    case QUERY_GENERIC:\n      break;\n\n    case QUERY_ROWID:\n      rc = sqlite3_bind_int64(c->pStmt, 1, sqlite3_value_int64(argv[0]));\n      if( rc!=SQLITE_OK ) return rc;\n      break;\n\n    default:   /* full-text search */\n    {\n      const char *zQuery = (const char *)sqlite3_value_text(argv[0]);\n      assert( idxNum<=QUERY_FULLTEXT+v->nColumn);\n      assert( argc==1 );\n      queryClear(&c->q);\n      if( c->result.nData!=0 ){\n        /* This case happens if the same cursor is used repeatedly. */\n        dlrDestroy(&c->reader);\n        dataBufferReset(&c->result);\n      }else{\n        dataBufferInit(&c->result, 0);\n      }\n      rc = fulltextQuery(v, idxNum-QUERY_FULLTEXT, zQuery, -1, &c->result, &c->q);\n      if( rc!=SQLITE_OK ) return rc;\n      if( c->result.nData!=0 ){\n        dlrInit(&c->reader, DL_DOCIDS, c->result.pData, c->result.nData);\n      }\n      break;\n    }\n  }\n\n  return fulltextNext(pCursor);\n}\n\n/* This is the xEof method of the virtual table.  The SQLite core\n** calls this routine to find out if it has reached the end of\n** a query's results set.\n*/\nstatic int fulltextEof(sqlite3_vtab_cursor *pCursor){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  return c->eof;\n}\n\n/* This is the xColumn method of the virtual table.  The SQLite\n** core calls this method during a query when it needs the value\n** of a column from the virtual table.  This method needs to use\n** one of the sqlite3_result_*() routines to store the requested\n** value back in the pContext.\n*/\nstatic int fulltextColumn(sqlite3_vtab_cursor *pCursor,\n                          sqlite3_context *pContext, int idxCol){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n  fulltext_vtab *v = cursor_vtab(c);\n\n  if( idxCol<v->nColumn ){\n    sqlite3_value *pVal = sqlite3_column_value(c->pStmt, idxCol+1);\n    sqlite3_result_value(pContext, pVal);\n  }else if( idxCol==v->nColumn ){\n    /* The extra column whose name is the same as the table.\n    ** Return a blob which is a pointer to the cursor\n    */\n    sqlite3_result_blob(pContext, &c, sizeof(c), SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\n/* This is the xRowid method.  The SQLite core calls this routine to\n** retrive the rowid for the current row of the result set.  The\n** rowid should be written to *pRowid.\n*/\nstatic int fulltextRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  fulltext_cursor *c = (fulltext_cursor *) pCursor;\n\n  *pRowid = sqlite3_column_int64(c->pStmt, 0);\n  return SQLITE_OK;\n}\n\n/* Add all terms in [zText] to pendingTerms table.  If [iColumn] > 0,\n** we also store positions and offsets in the hash table using that\n** column number.\n*/\nstatic int buildTerms(fulltext_vtab *v, sqlite_int64 iDocid,\n                      const char *zText, int iColumn){\n  sqlite3_tokenizer *pTokenizer = v->pTokenizer;\n  sqlite3_tokenizer_cursor *pCursor;\n  const char *pToken;\n  int nTokenBytes;\n  int iStartOffset, iEndOffset, iPosition;\n  int rc;\n\n  rc = pTokenizer->pModule->xOpen(pTokenizer, zText, -1, &pCursor);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pCursor->pTokenizer = pTokenizer;\n  while( SQLITE_OK==(rc=pTokenizer->pModule->xNext(pCursor,\n                                                   &pToken, &nTokenBytes,\n                                                   &iStartOffset, &iEndOffset,\n                                                   &iPosition)) ){\n    DLCollector *p;\n    int nData;                   /* Size of doclist before our update. */\n\n    /* Positions can't be negative; we use -1 as a terminator\n     * internally.  Token can't be NULL or empty. */\n    if( iPosition<0 || pToken == NULL || nTokenBytes == 0 ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    p = fts2HashFind(&v->pendingTerms, pToken, nTokenBytes);\n    if( p==NULL ){\n      nData = 0;\n      p = dlcNew(iDocid, DL_DEFAULT);\n      fts2HashInsert(&v->pendingTerms, pToken, nTokenBytes, p);\n\n      /* Overhead for our hash table entry, the key, and the value. */\n      v->nPendingData += sizeof(struct fts2HashElem)+sizeof(*p)+nTokenBytes;\n    }else{\n      nData = p->b.nData;\n      if( p->dlw.iPrevDocid!=iDocid ) dlcNext(p, iDocid);\n    }\n    if( iColumn>=0 ){\n      dlcAddPos(p, iColumn, iPosition, iStartOffset, iEndOffset);\n    }\n\n    /* Accumulate data added by dlcNew or dlcNext, and dlcAddPos. */\n    v->nPendingData += p->b.nData-nData;\n  }\n\n  /* TODO(shess) Check return?  Should this be able to cause errors at\n  ** this point?  Actually, same question about sqlite3_finalize(),\n  ** though one could argue that failure there means that the data is\n  ** not durable.  *ponder*\n  */\n  pTokenizer->pModule->xClose(pCursor);\n  if( SQLITE_DONE == rc ) return SQLITE_OK;\n  return rc;\n}\n\n/* Add doclists for all terms in [pValues] to pendingTerms table. */\nstatic int insertTerms(fulltext_vtab *v, sqlite_int64 iRowid,\n                       sqlite3_value **pValues){\n  int i;\n  for(i = 0; i < v->nColumn ; ++i){\n    char *zText = (char*)sqlite3_value_text(pValues[i]);\n    int rc = buildTerms(v, iRowid, zText, i);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  return SQLITE_OK;\n}\n\n/* Add empty doclists for all terms in the given row's content to\n** pendingTerms.\n*/\nstatic int deleteTerms(fulltext_vtab *v, sqlite_int64 iRowid){\n  const char **pValues;\n  int i, rc;\n\n  /* TODO(shess) Should we allow such tables at all? */\n  if( DL_DEFAULT==DL_DOCIDS ) return SQLITE_ERROR;\n\n  rc = content_select(v, iRowid, &pValues);\n  if( rc!=SQLITE_OK ) return rc;\n\n  for(i = 0 ; i < v->nColumn; ++i) {\n    rc = buildTerms(v, iRowid, pValues[i], -1);\n    if( rc!=SQLITE_OK ) break;\n  }\n\n  freeStringArray(v->nColumn, pValues);\n  return SQLITE_OK;\n}\n\n/* TODO(shess) Refactor the code to remove this forward decl. */\nstatic int initPendingTerms(fulltext_vtab *v, sqlite_int64 iDocid);\n\n/* Insert a row into the %_content table; set *piRowid to be the ID of the\n** new row.  Add doclists for terms to pendingTerms.\n*/\nstatic int index_insert(fulltext_vtab *v, sqlite3_value *pRequestRowid,\n                        sqlite3_value **pValues, sqlite_int64 *piRowid){\n  int rc;\n\n  rc = content_insert(v, pRequestRowid, pValues);  /* execute an SQL INSERT */\n  if( rc!=SQLITE_OK ) return rc;\n\n  *piRowid = sqlite3_last_insert_rowid(v->db);\n  rc = initPendingTerms(v, *piRowid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return insertTerms(v, *piRowid, pValues);\n}\n\n/* Delete a row from the %_content table; add empty doclists for terms\n** to pendingTerms.\n*/\nstatic int index_delete(fulltext_vtab *v, sqlite_int64 iRow){\n  int rc = initPendingTerms(v, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = deleteTerms(v, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  return content_delete(v, iRow);  /* execute an SQL DELETE */\n}\n\n/* Update a row in the %_content table; add delete doclists to\n** pendingTerms for old terms not in the new data, add insert doclists\n** to pendingTerms for terms in the new data.\n*/\nstatic int index_update(fulltext_vtab *v, sqlite_int64 iRow,\n                        sqlite3_value **pValues){\n  int rc = initPendingTerms(v, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Generate an empty doclist for each term that previously appeared in this\n   * row. */\n  rc = deleteTerms(v, iRow);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = content_update(v, pValues, iRow);  /* execute an SQL UPDATE */\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Now add positions for terms which appear in the updated row. */\n  return insertTerms(v, iRow, pValues);\n}\n\n/*******************************************************************/\n/* InteriorWriter is used to collect terms and block references into\n** interior nodes in %_segments.  See commentary at top of file for\n** format.\n*/\n\n/* How large interior nodes can grow. */\n#define INTERIOR_MAX 2048\n\n/* Minimum number of terms per interior node (except the root). This\n** prevents large terms from making the tree too skinny - must be >0\n** so that the tree always makes progress.  Note that the min tree\n** fanout will be INTERIOR_MIN_TERMS+1.\n*/\n#define INTERIOR_MIN_TERMS 7\n#if INTERIOR_MIN_TERMS<1\n# error INTERIOR_MIN_TERMS must be greater than 0.\n#endif\n\n/* ROOT_MAX controls how much data is stored inline in the segment\n** directory.\n*/\n/* TODO(shess) Push ROOT_MAX down to whoever is writing things.  It's\n** only here so that interiorWriterRootInfo() and leafWriterRootInfo()\n** can both see it, but if the caller passed it in, we wouldn't even\n** need a define.\n*/\n#define ROOT_MAX 1024\n#if ROOT_MAX<VARINT_MAX*2\n# error ROOT_MAX must have enough space for a header.\n#endif\n\n/* InteriorBlock stores a linked-list of interior blocks while a lower\n** layer is being constructed.\n*/\ntypedef struct InteriorBlock {\n  DataBuffer term;           /* Leftmost term in block's subtree. */\n  DataBuffer data;           /* Accumulated data for the block. */\n  struct InteriorBlock *next;\n} InteriorBlock;\n\nstatic InteriorBlock *interiorBlockNew(int iHeight, sqlite_int64 iChildBlock,\n                                       const char *pTerm, int nTerm){\n  InteriorBlock *block = sqlite3_malloc(sizeof(InteriorBlock));\n  char c[VARINT_MAX+VARINT_MAX];\n  int n;\n\n  if( block ){\n    memset(block, 0, sizeof(*block));\n    dataBufferInit(&block->term, 0);\n    dataBufferReplace(&block->term, pTerm, nTerm);\n\n    n = putVarint(c, iHeight);\n    n += putVarint(c+n, iChildBlock);\n    dataBufferInit(&block->data, INTERIOR_MAX);\n    dataBufferReplace(&block->data, c, n);\n  }\n  return block;\n}\n\n#ifndef NDEBUG\n/* Verify that the data is readable as an interior node. */\nstatic void interiorBlockValidate(InteriorBlock *pBlock){\n  const char *pData = pBlock->data.pData;\n  int nData = pBlock->data.nData;\n  int n, iDummy;\n  sqlite_int64 iBlockid;\n\n  assert( nData>0 );\n  assert( pData!=0 );\n  assert( pData+nData>pData );\n\n  /* Must lead with height of node as a varint(n), n>0 */\n  n = getVarint32(pData, &iDummy);\n  assert( n>0 );\n  assert( iDummy>0 );\n  assert( n<nData );\n  pData += n;\n  nData -= n;\n\n  /* Must contain iBlockid. */\n  n = getVarint(pData, &iBlockid);\n  assert( n>0 );\n  assert( n<=nData );\n  pData += n;\n  nData -= n;\n\n  /* Zero or more terms of positive length */\n  if( nData!=0 ){\n    /* First term is not delta-encoded. */\n    n = getVarint32(pData, &iDummy);\n    assert( n>0 );\n    assert( iDummy>0 );\n    assert( n+iDummy>0);\n    assert( n+iDummy<=nData );\n    pData += n+iDummy;\n    nData -= n+iDummy;\n\n    /* Following terms delta-encoded. */\n    while( nData!=0 ){\n      /* Length of shared prefix. */\n      n = getVarint32(pData, &iDummy);\n      assert( n>0 );\n      assert( iDummy>=0 );\n      assert( n<nData );\n      pData += n;\n      nData -= n;\n\n      /* Length and data of distinct suffix. */\n      n = getVarint32(pData, &iDummy);\n      assert( n>0 );\n      assert( iDummy>0 );\n      assert( n+iDummy>0);\n      assert( n+iDummy<=nData );\n      pData += n+iDummy;\n      nData -= n+iDummy;\n    }\n  }\n}\n#define ASSERT_VALID_INTERIOR_BLOCK(x) interiorBlockValidate(x)\n#else\n#define ASSERT_VALID_INTERIOR_BLOCK(x) assert( 1 )\n#endif\n\ntypedef struct InteriorWriter {\n  int iHeight;                   /* from 0 at leaves. */\n  InteriorBlock *first, *last;\n  struct InteriorWriter *parentWriter;\n\n  DataBuffer term;               /* Last term written to block \"last\". */\n  sqlite_int64 iOpeningChildBlock; /* First child block in block \"last\". */\n#ifndef NDEBUG\n  sqlite_int64 iLastChildBlock;  /* for consistency checks. */\n#endif\n} InteriorWriter;\n\n/* Initialize an interior node where pTerm[nTerm] marks the leftmost\n** term in the tree.  iChildBlock is the leftmost child block at the\n** next level down the tree.\n*/\nstatic void interiorWriterInit(int iHeight, const char *pTerm, int nTerm,\n                               sqlite_int64 iChildBlock,\n                               InteriorWriter *pWriter){\n  InteriorBlock *block;\n  assert( iHeight>0 );\n  CLEAR(pWriter);\n\n  pWriter->iHeight = iHeight;\n  pWriter->iOpeningChildBlock = iChildBlock;\n#ifndef NDEBUG\n  pWriter->iLastChildBlock = iChildBlock;\n#endif\n  block = interiorBlockNew(iHeight, iChildBlock, pTerm, nTerm);\n  pWriter->last = pWriter->first = block;\n  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);\n  dataBufferInit(&pWriter->term, 0);\n}\n\n/* Append the child node rooted at iChildBlock to the interior node,\n** with pTerm[nTerm] as the leftmost term in iChildBlock's subtree.\n*/\nstatic void interiorWriterAppend(InteriorWriter *pWriter,\n                                 const char *pTerm, int nTerm,\n                                 sqlite_int64 iChildBlock){\n  char c[VARINT_MAX+VARINT_MAX];\n  int n, nPrefix = 0;\n\n  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);\n\n  /* The first term written into an interior node is actually\n  ** associated with the second child added (the first child was added\n  ** in interiorWriterInit, or in the if clause at the bottom of this\n  ** function).  That term gets encoded straight up, with nPrefix left\n  ** at 0.\n  */\n  if( pWriter->term.nData==0 ){\n    n = putVarint(c, nTerm);\n  }else{\n    while( nPrefix<pWriter->term.nData &&\n           pTerm[nPrefix]==pWriter->term.pData[nPrefix] ){\n      nPrefix++;\n    }\n\n    n = putVarint(c, nPrefix);\n    n += putVarint(c+n, nTerm-nPrefix);\n  }\n\n#ifndef NDEBUG\n  pWriter->iLastChildBlock++;\n#endif\n  assert( pWriter->iLastChildBlock==iChildBlock );\n\n  /* Overflow to a new block if the new term makes the current block\n  ** too big, and the current block already has enough terms.\n  */\n  if( pWriter->last->data.nData+n+nTerm-nPrefix>INTERIOR_MAX &&\n      iChildBlock-pWriter->iOpeningChildBlock>INTERIOR_MIN_TERMS ){\n    pWriter->last->next = interiorBlockNew(pWriter->iHeight, iChildBlock,\n                                           pTerm, nTerm);\n    pWriter->last = pWriter->last->next;\n    pWriter->iOpeningChildBlock = iChildBlock;\n    dataBufferReset(&pWriter->term);\n  }else{\n    dataBufferAppend2(&pWriter->last->data, c, n,\n                      pTerm+nPrefix, nTerm-nPrefix);\n    dataBufferReplace(&pWriter->term, pTerm, nTerm);\n  }\n  ASSERT_VALID_INTERIOR_BLOCK(pWriter->last);\n}\n\n/* Free the space used by pWriter, including the linked-list of\n** InteriorBlocks, and parentWriter, if present.\n*/\nstatic int interiorWriterDestroy(InteriorWriter *pWriter){\n  InteriorBlock *block = pWriter->first;\n\n  while( block!=NULL ){\n    InteriorBlock *b = block;\n    block = block->next;\n    dataBufferDestroy(&b->term);\n    dataBufferDestroy(&b->data);\n    sqlite3_free(b);\n  }\n  if( pWriter->parentWriter!=NULL ){\n    interiorWriterDestroy(pWriter->parentWriter);\n    sqlite3_free(pWriter->parentWriter);\n  }\n  dataBufferDestroy(&pWriter->term);\n  SCRAMBLE(pWriter);\n  return SQLITE_OK;\n}\n\n/* If pWriter can fit entirely in ROOT_MAX, return it as the root info\n** directly, leaving *piEndBlockid unchanged.  Otherwise, flush\n** pWriter to %_segments, building a new layer of interior nodes, and\n** recursively ask for their root into.\n*/\nstatic int interiorWriterRootInfo(fulltext_vtab *v, InteriorWriter *pWriter,\n                                  char **ppRootInfo, int *pnRootInfo,\n                                  sqlite_int64 *piEndBlockid){\n  InteriorBlock *block = pWriter->first;\n  sqlite_int64 iBlockid = 0;\n  int rc;\n\n  /* If we can fit the segment inline */\n  if( block==pWriter->last && block->data.nData<ROOT_MAX ){\n    *ppRootInfo = block->data.pData;\n    *pnRootInfo = block->data.nData;\n    return SQLITE_OK;\n  }\n\n  /* Flush the first block to %_segments, and create a new level of\n  ** interior node.\n  */\n  ASSERT_VALID_INTERIOR_BLOCK(block);\n  rc = block_insert(v, block->data.pData, block->data.nData, &iBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n  *piEndBlockid = iBlockid;\n\n  pWriter->parentWriter = sqlite3_malloc(sizeof(*pWriter->parentWriter));\n  interiorWriterInit(pWriter->iHeight+1,\n                     block->term.pData, block->term.nData,\n                     iBlockid, pWriter->parentWriter);\n\n  /* Flush additional blocks and append to the higher interior\n  ** node.\n  */\n  for(block=block->next; block!=NULL; block=block->next){\n    ASSERT_VALID_INTERIOR_BLOCK(block);\n    rc = block_insert(v, block->data.pData, block->data.nData, &iBlockid);\n    if( rc!=SQLITE_OK ) return rc;\n    *piEndBlockid = iBlockid;\n\n    interiorWriterAppend(pWriter->parentWriter,\n                         block->term.pData, block->term.nData, iBlockid);\n  }\n\n  /* Parent node gets the chance to be the root. */\n  return interiorWriterRootInfo(v, pWriter->parentWriter,\n                                ppRootInfo, pnRootInfo, piEndBlockid);\n}\n\n/****************************************************************/\n/* InteriorReader is used to read off the data from an interior node\n** (see comment at top of file for the format).\n*/\ntypedef struct InteriorReader {\n  const char *pData;\n  int nData;\n\n  DataBuffer term;          /* previous term, for decoding term delta. */\n\n  sqlite_int64 iBlockid;\n} InteriorReader;\n\nstatic void interiorReaderDestroy(InteriorReader *pReader){\n  dataBufferDestroy(&pReader->term);\n  SCRAMBLE(pReader);\n}\n\n/* TODO(shess) The assertions are great, but what if we're in NDEBUG\n** and the blob is empty or otherwise contains suspect data?\n*/\nstatic void interiorReaderInit(const char *pData, int nData,\n                               InteriorReader *pReader){\n  int n, nTerm;\n\n  /* Require at least the leading flag byte */\n  assert( nData>0 );\n  assert( pData[0]!='\\0' );\n\n  CLEAR(pReader);\n\n  /* Decode the base blockid, and set the cursor to the first term. */\n  n = getVarint(pData+1, &pReader->iBlockid);\n  assert( 1+n<=nData );\n  pReader->pData = pData+1+n;\n  pReader->nData = nData-(1+n);\n\n  /* A single-child interior node (such as when a leaf node was too\n  ** large for the segment directory) won't have any terms.\n  ** Otherwise, decode the first term.\n  */\n  if( pReader->nData==0 ){\n    dataBufferInit(&pReader->term, 0);\n  }else{\n    n = getVarint32(pReader->pData, &nTerm);\n    dataBufferInit(&pReader->term, nTerm);\n    dataBufferReplace(&pReader->term, pReader->pData+n, nTerm);\n    assert( n+nTerm<=pReader->nData );\n    pReader->pData += n+nTerm;\n    pReader->nData -= n+nTerm;\n  }\n}\n\nstatic int interiorReaderAtEnd(InteriorReader *pReader){\n  return pReader->term.nData==0;\n}\n\nstatic sqlite_int64 interiorReaderCurrentBlockid(InteriorReader *pReader){\n  return pReader->iBlockid;\n}\n\nstatic int interiorReaderTermBytes(InteriorReader *pReader){\n  assert( !interiorReaderAtEnd(pReader) );\n  return pReader->term.nData;\n}\nstatic const char *interiorReaderTerm(InteriorReader *pReader){\n  assert( !interiorReaderAtEnd(pReader) );\n  return pReader->term.pData;\n}\n\n/* Step forward to the next term in the node. */\nstatic void interiorReaderStep(InteriorReader *pReader){\n  assert( !interiorReaderAtEnd(pReader) );\n\n  /* If the last term has been read, signal eof, else construct the\n  ** next term.\n  */\n  if( pReader->nData==0 ){\n    dataBufferReset(&pReader->term);\n  }else{\n    int n, nPrefix, nSuffix;\n\n    n = getVarint32(pReader->pData, &nPrefix);\n    n += getVarint32(pReader->pData+n, &nSuffix);\n\n    /* Truncate the current term and append suffix data. */\n    pReader->term.nData = nPrefix;\n    dataBufferAppend(&pReader->term, pReader->pData+n, nSuffix);\n\n    assert( n+nSuffix<=pReader->nData );\n    pReader->pData += n+nSuffix;\n    pReader->nData -= n+nSuffix;\n  }\n  pReader->iBlockid++;\n}\n\n/* Compare the current term to pTerm[nTerm], returning strcmp-style\n** results.  If isPrefix, equality means equal through nTerm bytes.\n*/\nstatic int interiorReaderTermCmp(InteriorReader *pReader,\n                                 const char *pTerm, int nTerm, int isPrefix){\n  const char *pReaderTerm = interiorReaderTerm(pReader);\n  int nReaderTerm = interiorReaderTermBytes(pReader);\n  int c, n = nReaderTerm<nTerm ? nReaderTerm : nTerm;\n\n  if( n==0 ){\n    if( nReaderTerm>0 ) return -1;\n    if( nTerm>0 ) return 1;\n    return 0;\n  }\n\n  c = memcmp(pReaderTerm, pTerm, n);\n  if( c!=0 ) return c;\n  if( isPrefix && n==nTerm ) return 0;\n  return nReaderTerm - nTerm;\n}\n\n/****************************************************************/\n/* LeafWriter is used to collect terms and associated doclist data\n** into leaf blocks in %_segments (see top of file for format info).\n** Expected usage is:\n**\n** LeafWriter writer;\n** leafWriterInit(0, 0, &writer);\n** while( sorted_terms_left_to_process ){\n**   // data is doclist data for that term.\n**   rc = leafWriterStep(v, &writer, pTerm, nTerm, pData, nData);\n**   if( rc!=SQLITE_OK ) goto err;\n** }\n** rc = leafWriterFinalize(v, &writer);\n**err:\n** leafWriterDestroy(&writer);\n** return rc;\n**\n** leafWriterStep() may write a collected leaf out to %_segments.\n** leafWriterFinalize() finishes writing any buffered data and stores\n** a root node in %_segdir.  leafWriterDestroy() frees all buffers and\n** InteriorWriters allocated as part of writing this segment.\n**\n** TODO(shess) Document leafWriterStepMerge().\n*/\n\n/* Put terms with data this big in their own block. */\n#define STANDALONE_MIN 1024\n\n/* Keep leaf blocks below this size. */\n#define LEAF_MAX 2048\n\ntypedef struct LeafWriter {\n  int iLevel;\n  int idx;\n  sqlite_int64 iStartBlockid;     /* needed to create the root info */\n  sqlite_int64 iEndBlockid;       /* when we're done writing. */\n\n  DataBuffer term;                /* previous encoded term */\n  DataBuffer data;                /* encoding buffer */\n\n  /* bytes of first term in the current node which distinguishes that\n  ** term from the last term of the previous node.\n  */\n  int nTermDistinct;\n\n  InteriorWriter parentWriter;    /* if we overflow */\n  int has_parent;\n} LeafWriter;\n\nstatic void leafWriterInit(int iLevel, int idx, LeafWriter *pWriter){\n  CLEAR(pWriter);\n  pWriter->iLevel = iLevel;\n  pWriter->idx = idx;\n\n  dataBufferInit(&pWriter->term, 32);\n\n  /* Start out with a reasonably sized block, though it can grow. */\n  dataBufferInit(&pWriter->data, LEAF_MAX);\n}\n\n#ifndef NDEBUG\n/* Verify that the data is readable as a leaf node. */\nstatic void leafNodeValidate(const char *pData, int nData){\n  int n, iDummy;\n\n  if( nData==0 ) return;\n  assert( nData>0 );\n  assert( pData!=0 );\n  assert( pData+nData>pData );\n\n  /* Must lead with a varint(0) */\n  n = getVarint32(pData, &iDummy);\n  assert( iDummy==0 );\n  assert( n>0 );\n  assert( n<nData );\n  pData += n;\n  nData -= n;\n\n  /* Leading term length and data must fit in buffer. */\n  n = getVarint32(pData, &iDummy);\n  assert( n>0 );\n  assert( iDummy>0 );\n  assert( n+iDummy>0 );\n  assert( n+iDummy<nData );\n  pData += n+iDummy;\n  nData -= n+iDummy;\n\n  /* Leading term's doclist length and data must fit. */\n  n = getVarint32(pData, &iDummy);\n  assert( n>0 );\n  assert( iDummy>0 );\n  assert( n+iDummy>0 );\n  assert( n+iDummy<=nData );\n  ASSERT_VALID_DOCLIST(DL_DEFAULT, pData+n, iDummy, NULL);\n  pData += n+iDummy;\n  nData -= n+iDummy;\n\n  /* Verify that trailing terms and doclists also are readable. */\n  while( nData!=0 ){\n    n = getVarint32(pData, &iDummy);\n    assert( n>0 );\n    assert( iDummy>=0 );\n    assert( n<nData );\n    pData += n;\n    nData -= n;\n    n = getVarint32(pData, &iDummy);\n    assert( n>0 );\n    assert( iDummy>0 );\n    assert( n+iDummy>0 );\n    assert( n+iDummy<nData );\n    pData += n+iDummy;\n    nData -= n+iDummy;\n\n    n = getVarint32(pData, &iDummy);\n    assert( n>0 );\n    assert( iDummy>0 );\n    assert( n+iDummy>0 );\n    assert( n+iDummy<=nData );\n    ASSERT_VALID_DOCLIST(DL_DEFAULT, pData+n, iDummy, NULL);\n    pData += n+iDummy;\n    nData -= n+iDummy;\n  }\n}\n#define ASSERT_VALID_LEAF_NODE(p, n) leafNodeValidate(p, n)\n#else\n#define ASSERT_VALID_LEAF_NODE(p, n) assert( 1 )\n#endif\n\n/* Flush the current leaf node to %_segments, and adding the resulting\n** blockid and the starting term to the interior node which will\n** contain it.\n*/\nstatic int leafWriterInternalFlush(fulltext_vtab *v, LeafWriter *pWriter,\n                                   int iData, int nData){\n  sqlite_int64 iBlockid = 0;\n  const char *pStartingTerm;\n  int nStartingTerm, rc, n;\n\n  /* Must have the leading varint(0) flag, plus at least some\n  ** valid-looking data.\n  */\n  assert( nData>2 );\n  assert( iData>=0 );\n  assert( iData+nData<=pWriter->data.nData );\n  ASSERT_VALID_LEAF_NODE(pWriter->data.pData+iData, nData);\n\n  rc = block_insert(v, pWriter->data.pData+iData, nData, &iBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n  assert( iBlockid!=0 );\n\n  /* Reconstruct the first term in the leaf for purposes of building\n  ** the interior node.\n  */\n  n = getVarint32(pWriter->data.pData+iData+1, &nStartingTerm);\n  pStartingTerm = pWriter->data.pData+iData+1+n;\n  assert( pWriter->data.nData>iData+1+n+nStartingTerm );\n  assert( pWriter->nTermDistinct>0 );\n  assert( pWriter->nTermDistinct<=nStartingTerm );\n  nStartingTerm = pWriter->nTermDistinct;\n\n  if( pWriter->has_parent ){\n    interiorWriterAppend(&pWriter->parentWriter,\n                         pStartingTerm, nStartingTerm, iBlockid);\n  }else{\n    interiorWriterInit(1, pStartingTerm, nStartingTerm, iBlockid,\n                       &pWriter->parentWriter);\n    pWriter->has_parent = 1;\n  }\n\n  /* Track the span of this segment's leaf nodes. */\n  if( pWriter->iEndBlockid==0 ){\n    pWriter->iEndBlockid = pWriter->iStartBlockid = iBlockid;\n  }else{\n    pWriter->iEndBlockid++;\n    assert( iBlockid==pWriter->iEndBlockid );\n  }\n\n  return SQLITE_OK;\n}\nstatic int leafWriterFlush(fulltext_vtab *v, LeafWriter *pWriter){\n  int rc = leafWriterInternalFlush(v, pWriter, 0, pWriter->data.nData);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Re-initialize the output buffer. */\n  dataBufferReset(&pWriter->data);\n\n  return SQLITE_OK;\n}\n\n/* Fetch the root info for the segment.  If the entire leaf fits\n** within ROOT_MAX, then it will be returned directly, otherwise it\n** will be flushed and the root info will be returned from the\n** interior node.  *piEndBlockid is set to the blockid of the last\n** interior or leaf node written to disk (0 if none are written at\n** all).\n*/\nstatic int leafWriterRootInfo(fulltext_vtab *v, LeafWriter *pWriter,\n                              char **ppRootInfo, int *pnRootInfo,\n                              sqlite_int64 *piEndBlockid){\n  /* we can fit the segment entirely inline */\n  if( !pWriter->has_parent && pWriter->data.nData<ROOT_MAX ){\n    *ppRootInfo = pWriter->data.pData;\n    *pnRootInfo = pWriter->data.nData;\n    *piEndBlockid = 0;\n    return SQLITE_OK;\n  }\n\n  /* Flush remaining leaf data. */\n  if( pWriter->data.nData>0 ){\n    int rc = leafWriterFlush(v, pWriter);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* We must have flushed a leaf at some point. */\n  assert( pWriter->has_parent );\n\n  /* Tenatively set the end leaf blockid as the end blockid.  If the\n  ** interior node can be returned inline, this will be the final\n  ** blockid, otherwise it will be overwritten by\n  ** interiorWriterRootInfo().\n  */\n  *piEndBlockid = pWriter->iEndBlockid;\n\n  return interiorWriterRootInfo(v, &pWriter->parentWriter,\n                                ppRootInfo, pnRootInfo, piEndBlockid);\n}\n\n/* Collect the rootInfo data and store it into the segment directory.\n** This has the effect of flushing the segment's leaf data to\n** %_segments, and also flushing any interior nodes to %_segments.\n*/\nstatic int leafWriterFinalize(fulltext_vtab *v, LeafWriter *pWriter){\n  sqlite_int64 iEndBlockid;\n  char *pRootInfo;\n  int rc, nRootInfo;\n\n  rc = leafWriterRootInfo(v, pWriter, &pRootInfo, &nRootInfo, &iEndBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Don't bother storing an entirely empty segment. */\n  if( iEndBlockid==0 && nRootInfo==0 ) return SQLITE_OK;\n\n  return segdir_set(v, pWriter->iLevel, pWriter->idx,\n                    pWriter->iStartBlockid, pWriter->iEndBlockid,\n                    iEndBlockid, pRootInfo, nRootInfo);\n}\n\nstatic void leafWriterDestroy(LeafWriter *pWriter){\n  if( pWriter->has_parent ) interiorWriterDestroy(&pWriter->parentWriter);\n  dataBufferDestroy(&pWriter->term);\n  dataBufferDestroy(&pWriter->data);\n}\n\n/* Encode a term into the leafWriter, delta-encoding as appropriate.\n** Returns the length of the new term which distinguishes it from the\n** previous term, which can be used to set nTermDistinct when a node\n** boundary is crossed.\n*/\nstatic int leafWriterEncodeTerm(LeafWriter *pWriter,\n                                const char *pTerm, int nTerm){\n  char c[VARINT_MAX+VARINT_MAX];\n  int n, nPrefix = 0;\n\n  assert( nTerm>0 );\n  while( nPrefix<pWriter->term.nData &&\n         pTerm[nPrefix]==pWriter->term.pData[nPrefix] ){\n    nPrefix++;\n    /* Failing this implies that the terms weren't in order. */\n    assert( nPrefix<nTerm );\n  }\n\n  if( pWriter->data.nData==0 ){\n    /* Encode the node header and leading term as:\n    **  varint(0)\n    **  varint(nTerm)\n    **  char pTerm[nTerm]\n    */\n    n = putVarint(c, '\\0');\n    n += putVarint(c+n, nTerm);\n    dataBufferAppend2(&pWriter->data, c, n, pTerm, nTerm);\n  }else{\n    /* Delta-encode the term as:\n    **  varint(nPrefix)\n    **  varint(nSuffix)\n    **  char pTermSuffix[nSuffix]\n    */\n    n = putVarint(c, nPrefix);\n    n += putVarint(c+n, nTerm-nPrefix);\n    dataBufferAppend2(&pWriter->data, c, n, pTerm+nPrefix, nTerm-nPrefix);\n  }\n  dataBufferReplace(&pWriter->term, pTerm, nTerm);\n\n  return nPrefix+1;\n}\n\n/* Used to avoid a memmove when a large amount of doclist data is in\n** the buffer.  This constructs a node and term header before\n** iDoclistData and flushes the resulting complete node using\n** leafWriterInternalFlush().\n*/\nstatic int leafWriterInlineFlush(fulltext_vtab *v, LeafWriter *pWriter,\n                                 const char *pTerm, int nTerm,\n                                 int iDoclistData){\n  char c[VARINT_MAX+VARINT_MAX];\n  int iData, n = putVarint(c, 0);\n  n += putVarint(c+n, nTerm);\n\n  /* There should always be room for the header.  Even if pTerm shared\n  ** a substantial prefix with the previous term, the entire prefix\n  ** could be constructed from earlier data in the doclist, so there\n  ** should be room.\n  */\n  assert( iDoclistData>=n+nTerm );\n\n  iData = iDoclistData-(n+nTerm);\n  memcpy(pWriter->data.pData+iData, c, n);\n  memcpy(pWriter->data.pData+iData+n, pTerm, nTerm);\n\n  return leafWriterInternalFlush(v, pWriter, iData, pWriter->data.nData-iData);\n}\n\n/* Push pTerm[nTerm] along with the doclist data to the leaf layer of\n** %_segments.\n*/\nstatic int leafWriterStepMerge(fulltext_vtab *v, LeafWriter *pWriter,\n                               const char *pTerm, int nTerm,\n                               DLReader *pReaders, int nReaders){\n  char c[VARINT_MAX+VARINT_MAX];\n  int iTermData = pWriter->data.nData, iDoclistData;\n  int i, nData, n, nActualData, nActual, rc, nTermDistinct;\n\n  ASSERT_VALID_LEAF_NODE(pWriter->data.pData, pWriter->data.nData);\n  nTermDistinct = leafWriterEncodeTerm(pWriter, pTerm, nTerm);\n\n  /* Remember nTermDistinct if opening a new node. */\n  if( iTermData==0 ) pWriter->nTermDistinct = nTermDistinct;\n\n  iDoclistData = pWriter->data.nData;\n\n  /* Estimate the length of the merged doclist so we can leave space\n  ** to encode it.\n  */\n  for(i=0, nData=0; i<nReaders; i++){\n    nData += dlrAllDataBytes(&pReaders[i]);\n  }\n  n = putVarint(c, nData);\n  dataBufferAppend(&pWriter->data, c, n);\n\n  docListMerge(&pWriter->data, pReaders, nReaders);\n  ASSERT_VALID_DOCLIST(DL_DEFAULT,\n                       pWriter->data.pData+iDoclistData+n,\n                       pWriter->data.nData-iDoclistData-n, NULL);\n\n  /* The actual amount of doclist data at this point could be smaller\n  ** than the length we encoded.  Additionally, the space required to\n  ** encode this length could be smaller.  For small doclists, this is\n  ** not a big deal, we can just use memmove() to adjust things.\n  */\n  nActualData = pWriter->data.nData-(iDoclistData+n);\n  nActual = putVarint(c, nActualData);\n  assert( nActualData<=nData );\n  assert( nActual<=n );\n\n  /* If the new doclist is big enough for force a standalone leaf\n  ** node, we can immediately flush it inline without doing the\n  ** memmove().\n  */\n  /* TODO(shess) This test matches leafWriterStep(), which does this\n  ** test before it knows the cost to varint-encode the term and\n  ** doclist lengths.  At some point, change to\n  ** pWriter->data.nData-iTermData>STANDALONE_MIN.\n  */\n  if( nTerm+nActualData>STANDALONE_MIN ){\n    /* Push leaf node from before this term. */\n    if( iTermData>0 ){\n      rc = leafWriterInternalFlush(v, pWriter, 0, iTermData);\n      if( rc!=SQLITE_OK ) return rc;\n\n      pWriter->nTermDistinct = nTermDistinct;\n    }\n\n    /* Fix the encoded doclist length. */\n    iDoclistData += n - nActual;\n    memcpy(pWriter->data.pData+iDoclistData, c, nActual);\n\n    /* Push the standalone leaf node. */\n    rc = leafWriterInlineFlush(v, pWriter, pTerm, nTerm, iDoclistData);\n    if( rc!=SQLITE_OK ) return rc;\n\n    /* Leave the node empty. */\n    dataBufferReset(&pWriter->data);\n\n    return rc;\n  }\n\n  /* At this point, we know that the doclist was small, so do the\n  ** memmove if indicated.\n  */\n  if( nActual<n ){\n    memmove(pWriter->data.pData+iDoclistData+nActual,\n            pWriter->data.pData+iDoclistData+n,\n            pWriter->data.nData-(iDoclistData+n));\n    pWriter->data.nData -= n-nActual;\n  }\n\n  /* Replace written length with actual length. */\n  memcpy(pWriter->data.pData+iDoclistData, c, nActual);\n\n  /* If the node is too large, break things up. */\n  /* TODO(shess) This test matches leafWriterStep(), which does this\n  ** test before it knows the cost to varint-encode the term and\n  ** doclist lengths.  At some point, change to\n  ** pWriter->data.nData>LEAF_MAX.\n  */\n  if( iTermData+nTerm+nActualData>LEAF_MAX ){\n    /* Flush out the leading data as a node */\n    rc = leafWriterInternalFlush(v, pWriter, 0, iTermData);\n    if( rc!=SQLITE_OK ) return rc;\n\n    pWriter->nTermDistinct = nTermDistinct;\n\n    /* Rebuild header using the current term */\n    n = putVarint(pWriter->data.pData, 0);\n    n += putVarint(pWriter->data.pData+n, nTerm);\n    memcpy(pWriter->data.pData+n, pTerm, nTerm);\n    n += nTerm;\n\n    /* There should always be room, because the previous encoding\n    ** included all data necessary to construct the term.\n    */\n    assert( n<iDoclistData );\n    /* So long as STANDALONE_MIN is half or less of LEAF_MAX, the\n    ** following memcpy() is safe (as opposed to needing a memmove).\n    */\n    assert( 2*STANDALONE_MIN<=LEAF_MAX );\n    assert( n+pWriter->data.nData-iDoclistData<iDoclistData );\n    memcpy(pWriter->data.pData+n,\n           pWriter->data.pData+iDoclistData,\n           pWriter->data.nData-iDoclistData);\n    pWriter->data.nData -= iDoclistData-n;\n  }\n  ASSERT_VALID_LEAF_NODE(pWriter->data.pData, pWriter->data.nData);\n\n  return SQLITE_OK;\n}\n\n/* Push pTerm[nTerm] along with the doclist data to the leaf layer of\n** %_segments.\n*/\n/* TODO(shess) Revise writeZeroSegment() so that doclists are\n** constructed directly in pWriter->data.\n*/\nstatic int leafWriterStep(fulltext_vtab *v, LeafWriter *pWriter,\n                          const char *pTerm, int nTerm,\n                          const char *pData, int nData){\n  int rc;\n  DLReader reader;\n\n  dlrInit(&reader, DL_DEFAULT, pData, nData);\n  rc = leafWriterStepMerge(v, pWriter, pTerm, nTerm, &reader, 1);\n  dlrDestroy(&reader);\n\n  return rc;\n}\n\n\n/****************************************************************/\n/* LeafReader is used to iterate over an individual leaf node. */\ntypedef struct LeafReader {\n  DataBuffer term;          /* copy of current term. */\n\n  const char *pData;        /* data for current term. */\n  int nData;\n} LeafReader;\n\nstatic void leafReaderDestroy(LeafReader *pReader){\n  dataBufferDestroy(&pReader->term);\n  SCRAMBLE(pReader);\n}\n\nstatic int leafReaderAtEnd(LeafReader *pReader){\n  return pReader->nData<=0;\n}\n\n/* Access the current term. */\nstatic int leafReaderTermBytes(LeafReader *pReader){\n  return pReader->term.nData;\n}\nstatic const char *leafReaderTerm(LeafReader *pReader){\n  assert( pReader->term.nData>0 );\n  return pReader->term.pData;\n}\n\n/* Access the doclist data for the current term. */\nstatic int leafReaderDataBytes(LeafReader *pReader){\n  int nData;\n  assert( pReader->term.nData>0 );\n  getVarint32(pReader->pData, &nData);\n  return nData;\n}\nstatic const char *leafReaderData(LeafReader *pReader){\n  int n, nData;\n  assert( pReader->term.nData>0 );\n  n = getVarint32(pReader->pData, &nData);\n  return pReader->pData+n;\n}\n\nstatic void leafReaderInit(const char *pData, int nData,\n                           LeafReader *pReader){\n  int nTerm, n;\n\n  assert( nData>0 );\n  assert( pData[0]=='\\0' );\n\n  CLEAR(pReader);\n\n  /* Read the first term, skipping the header byte. */\n  n = getVarint32(pData+1, &nTerm);\n  dataBufferInit(&pReader->term, nTerm);\n  dataBufferReplace(&pReader->term, pData+1+n, nTerm);\n\n  /* Position after the first term. */\n  assert( 1+n+nTerm<nData );\n  pReader->pData = pData+1+n+nTerm;\n  pReader->nData = nData-1-n-nTerm;\n}\n\n/* Step the reader forward to the next term. */\nstatic void leafReaderStep(LeafReader *pReader){\n  int n, nData, nPrefix, nSuffix;\n  assert( !leafReaderAtEnd(pReader) );\n\n  /* Skip previous entry's data block. */\n  n = getVarint32(pReader->pData, &nData);\n  assert( n+nData<=pReader->nData );\n  pReader->pData += n+nData;\n  pReader->nData -= n+nData;\n\n  if( !leafReaderAtEnd(pReader) ){\n    /* Construct the new term using a prefix from the old term plus a\n    ** suffix from the leaf data.\n    */\n    n = getVarint32(pReader->pData, &nPrefix);\n    n += getVarint32(pReader->pData+n, &nSuffix);\n    assert( n+nSuffix<pReader->nData );\n    pReader->term.nData = nPrefix;\n    dataBufferAppend(&pReader->term, pReader->pData+n, nSuffix);\n\n    pReader->pData += n+nSuffix;\n    pReader->nData -= n+nSuffix;\n  }\n}\n\n/* strcmp-style comparison of pReader's current term against pTerm.\n** If isPrefix, equality means equal through nTerm bytes.\n*/\nstatic int leafReaderTermCmp(LeafReader *pReader,\n                             const char *pTerm, int nTerm, int isPrefix){\n  int c, n = pReader->term.nData<nTerm ? pReader->term.nData : nTerm;\n  if( n==0 ){\n    if( pReader->term.nData>0 ) return -1;\n    if(nTerm>0 ) return 1;\n    return 0;\n  }\n\n  c = memcmp(pReader->term.pData, pTerm, n);\n  if( c!=0 ) return c;\n  if( isPrefix && n==nTerm ) return 0;\n  return pReader->term.nData - nTerm;\n}\n\n\n/****************************************************************/\n/* LeavesReader wraps LeafReader to allow iterating over the entire\n** leaf layer of the tree.\n*/\ntypedef struct LeavesReader {\n  int idx;                  /* Index within the segment. */\n\n  sqlite3_stmt *pStmt;      /* Statement we're streaming leaves from. */\n  int eof;                  /* we've seen SQLITE_DONE from pStmt. */\n\n  LeafReader leafReader;    /* reader for the current leaf. */\n  DataBuffer rootData;      /* root data for inline. */\n} LeavesReader;\n\n/* Access the current term. */\nstatic int leavesReaderTermBytes(LeavesReader *pReader){\n  assert( !pReader->eof );\n  return leafReaderTermBytes(&pReader->leafReader);\n}\nstatic const char *leavesReaderTerm(LeavesReader *pReader){\n  assert( !pReader->eof );\n  return leafReaderTerm(&pReader->leafReader);\n}\n\n/* Access the doclist data for the current term. */\nstatic int leavesReaderDataBytes(LeavesReader *pReader){\n  assert( !pReader->eof );\n  return leafReaderDataBytes(&pReader->leafReader);\n}\nstatic const char *leavesReaderData(LeavesReader *pReader){\n  assert( !pReader->eof );\n  return leafReaderData(&pReader->leafReader);\n}\n\nstatic int leavesReaderAtEnd(LeavesReader *pReader){\n  return pReader->eof;\n}\n\n/* loadSegmentLeaves() may not read all the way to SQLITE_DONE, thus\n** leaving the statement handle open, which locks the table.\n*/\n/* TODO(shess) This \"solution\" is not satisfactory.  Really, there\n** should be check-in function for all statement handles which\n** arranges to call sqlite3_reset().  This most likely will require\n** modification to control flow all over the place, though, so for now\n** just punt.\n**\n** Note the current system assumes that segment merges will run to\n** completion, which is why this particular probably hasn't arisen in\n** this case.  Probably a brittle assumption.\n*/\nstatic int leavesReaderReset(LeavesReader *pReader){\n  return sqlite3_reset(pReader->pStmt);\n}\n\nstatic void leavesReaderDestroy(LeavesReader *pReader){\n  /* If idx is -1, that means we're using a non-cached statement\n  ** handle in the optimize() case, so we need to release it.\n  */\n  if( pReader->pStmt!=NULL && pReader->idx==-1 ){\n    sqlite3_finalize(pReader->pStmt);\n  }\n  leafReaderDestroy(&pReader->leafReader);\n  dataBufferDestroy(&pReader->rootData);\n  SCRAMBLE(pReader);\n}\n\n/* Initialize pReader with the given root data (if iStartBlockid==0\n** the leaf data was entirely contained in the root), or from the\n** stream of blocks between iStartBlockid and iEndBlockid, inclusive.\n*/\nstatic int leavesReaderInit(fulltext_vtab *v,\n                            int idx,\n                            sqlite_int64 iStartBlockid,\n                            sqlite_int64 iEndBlockid,\n                            const char *pRootData, int nRootData,\n                            LeavesReader *pReader){\n  CLEAR(pReader);\n  pReader->idx = idx;\n\n  dataBufferInit(&pReader->rootData, 0);\n  if( iStartBlockid==0 ){\n    /* Entire leaf level fit in root data. */\n    dataBufferReplace(&pReader->rootData, pRootData, nRootData);\n    leafReaderInit(pReader->rootData.pData, pReader->rootData.nData,\n                   &pReader->leafReader);\n  }else{\n    sqlite3_stmt *s;\n    int rc = sql_get_leaf_statement(v, idx, &s);\n    if( rc!=SQLITE_OK ) return rc;\n\n    rc = sqlite3_bind_int64(s, 1, iStartBlockid);\n    if( rc!=SQLITE_OK ) return rc;\n\n    rc = sqlite3_bind_int64(s, 2, iEndBlockid);\n    if( rc!=SQLITE_OK ) return rc;\n\n    rc = sqlite3_step(s);\n    if( rc==SQLITE_DONE ){\n      pReader->eof = 1;\n      return SQLITE_OK;\n    }\n    if( rc!=SQLITE_ROW ) return rc;\n\n    pReader->pStmt = s;\n    leafReaderInit(sqlite3_column_blob(pReader->pStmt, 0),\n                   sqlite3_column_bytes(pReader->pStmt, 0),\n                   &pReader->leafReader);\n  }\n  return SQLITE_OK;\n}\n\n/* Step the current leaf forward to the next term.  If we reach the\n** end of the current leaf, step forward to the next leaf block.\n*/\nstatic int leavesReaderStep(fulltext_vtab *v, LeavesReader *pReader){\n  assert( !leavesReaderAtEnd(pReader) );\n  leafReaderStep(&pReader->leafReader);\n\n  if( leafReaderAtEnd(&pReader->leafReader) ){\n    int rc;\n    if( pReader->rootData.pData ){\n      pReader->eof = 1;\n      return SQLITE_OK;\n    }\n    rc = sqlite3_step(pReader->pStmt);\n    if( rc!=SQLITE_ROW ){\n      pReader->eof = 1;\n      return rc==SQLITE_DONE ? SQLITE_OK : rc;\n    }\n    leafReaderDestroy(&pReader->leafReader);\n    leafReaderInit(sqlite3_column_blob(pReader->pStmt, 0),\n                   sqlite3_column_bytes(pReader->pStmt, 0),\n                   &pReader->leafReader);\n  }\n  return SQLITE_OK;\n}\n\n/* Order LeavesReaders by their term, ignoring idx.  Readers at eof\n** always sort to the end.\n*/\nstatic int leavesReaderTermCmp(LeavesReader *lr1, LeavesReader *lr2){\n  if( leavesReaderAtEnd(lr1) ){\n    if( leavesReaderAtEnd(lr2) ) return 0;\n    return 1;\n  }\n  if( leavesReaderAtEnd(lr2) ) return -1;\n\n  return leafReaderTermCmp(&lr1->leafReader,\n                           leavesReaderTerm(lr2), leavesReaderTermBytes(lr2),\n                           0);\n}\n\n/* Similar to leavesReaderTermCmp(), with additional ordering by idx\n** so that older segments sort before newer segments.\n*/\nstatic int leavesReaderCmp(LeavesReader *lr1, LeavesReader *lr2){\n  int c = leavesReaderTermCmp(lr1, lr2);\n  if( c!=0 ) return c;\n  return lr1->idx-lr2->idx;\n}\n\n/* Assume that pLr[1]..pLr[nLr] are sorted.  Bubble pLr[0] into its\n** sorted position.\n*/\nstatic void leavesReaderReorder(LeavesReader *pLr, int nLr){\n  while( nLr>1 && leavesReaderCmp(pLr, pLr+1)>0 ){\n    LeavesReader tmp = pLr[0];\n    pLr[0] = pLr[1];\n    pLr[1] = tmp;\n    nLr--;\n    pLr++;\n  }\n}\n\n/* Initializes pReaders with the segments from level iLevel, returning\n** the number of segments in *piReaders.  Leaves pReaders in sorted\n** order.\n*/\nstatic int leavesReadersInit(fulltext_vtab *v, int iLevel,\n                             LeavesReader *pReaders, int *piReaders){\n  sqlite3_stmt *s;\n  int i, rc = sql_get_statement(v, SEGDIR_SELECT_LEVEL_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int(s, 1, iLevel);\n  if( rc!=SQLITE_OK ) return rc;\n\n  i = 0;\n  while( (rc = sqlite3_step(s))==SQLITE_ROW ){\n    sqlite_int64 iStart = sqlite3_column_int64(s, 0);\n    sqlite_int64 iEnd = sqlite3_column_int64(s, 1);\n    const char *pRootData = sqlite3_column_blob(s, 2);\n    int nRootData = sqlite3_column_bytes(s, 2);\n\n    assert( i<MERGE_COUNT );\n    rc = leavesReaderInit(v, i, iStart, iEnd, pRootData, nRootData,\n                          &pReaders[i]);\n    if( rc!=SQLITE_OK ) break;\n\n    i++;\n  }\n  if( rc!=SQLITE_DONE ){\n    while( i-->0 ){\n      leavesReaderDestroy(&pReaders[i]);\n    }\n    return rc;\n  }\n\n  *piReaders = i;\n\n  /* Leave our results sorted by term, then age. */\n  while( i-- ){\n    leavesReaderReorder(pReaders+i, *piReaders-i);\n  }\n  return SQLITE_OK;\n}\n\n/* Merge doclists from pReaders[nReaders] into a single doclist, which\n** is written to pWriter.  Assumes pReaders is ordered oldest to\n** newest.\n*/\n/* TODO(shess) Consider putting this inline in segmentMerge(). */\nstatic int leavesReadersMerge(fulltext_vtab *v,\n                              LeavesReader *pReaders, int nReaders,\n                              LeafWriter *pWriter){\n  DLReader dlReaders[MERGE_COUNT];\n  const char *pTerm = leavesReaderTerm(pReaders);\n  int i, nTerm = leavesReaderTermBytes(pReaders);\n\n  assert( nReaders<=MERGE_COUNT );\n\n  for(i=0; i<nReaders; i++){\n    dlrInit(&dlReaders[i], DL_DEFAULT,\n            leavesReaderData(pReaders+i),\n            leavesReaderDataBytes(pReaders+i));\n  }\n\n  return leafWriterStepMerge(v, pWriter, pTerm, nTerm, dlReaders, nReaders);\n}\n\n/* Forward ref due to mutual recursion with segdirNextIndex(). */\nstatic int segmentMerge(fulltext_vtab *v, int iLevel);\n\n/* Put the next available index at iLevel into *pidx.  If iLevel\n** already has MERGE_COUNT segments, they are merged to a higher\n** level to make room.\n*/\nstatic int segdirNextIndex(fulltext_vtab *v, int iLevel, int *pidx){\n  int rc = segdir_max_index(v, iLevel, pidx);\n  if( rc==SQLITE_DONE ){              /* No segments at iLevel. */\n    *pidx = 0;\n  }else if( rc==SQLITE_ROW ){\n    if( *pidx==(MERGE_COUNT-1) ){\n      rc = segmentMerge(v, iLevel);\n      if( rc!=SQLITE_OK ) return rc;\n      *pidx = 0;\n    }else{\n      (*pidx)++;\n    }\n  }else{\n    return rc;\n  }\n  return SQLITE_OK;\n}\n\n/* Merge MERGE_COUNT segments at iLevel into a new segment at\n** iLevel+1.  If iLevel+1 is already full of segments, those will be\n** merged to make room.\n*/\nstatic int segmentMerge(fulltext_vtab *v, int iLevel){\n  LeafWriter writer;\n  LeavesReader lrs[MERGE_COUNT];\n  int i, rc, idx = 0;\n\n  /* Determine the next available segment index at the next level,\n  ** merging as necessary.\n  */\n  rc = segdirNextIndex(v, iLevel+1, &idx);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* TODO(shess) This assumes that we'll always see exactly\n  ** MERGE_COUNT segments to merge at a given level.  That will be\n  ** broken if we allow the developer to request preemptive or\n  ** deferred merging.\n  */\n  memset(&lrs, '\\0', sizeof(lrs));\n  rc = leavesReadersInit(v, iLevel, lrs, &i);\n  if( rc!=SQLITE_OK ) return rc;\n  assert( i==MERGE_COUNT );\n\n  leafWriterInit(iLevel+1, idx, &writer);\n\n  /* Since leavesReaderReorder() pushes readers at eof to the end,\n  ** when the first reader is empty, all will be empty.\n  */\n  while( !leavesReaderAtEnd(lrs) ){\n    /* Figure out how many readers share their next term. */\n    for(i=1; i<MERGE_COUNT && !leavesReaderAtEnd(lrs+i); i++){\n      if( 0!=leavesReaderTermCmp(lrs, lrs+i) ) break;\n    }\n\n    rc = leavesReadersMerge(v, lrs, i, &writer);\n    if( rc!=SQLITE_OK ) goto err;\n\n    /* Step forward those that were merged. */\n    while( i-->0 ){\n      rc = leavesReaderStep(v, lrs+i);\n      if( rc!=SQLITE_OK ) goto err;\n\n      /* Reorder by term, then by age. */\n      leavesReaderReorder(lrs+i, MERGE_COUNT-i);\n    }\n  }\n\n  for(i=0; i<MERGE_COUNT; i++){\n    leavesReaderDestroy(&lrs[i]);\n  }\n\n  rc = leafWriterFinalize(v, &writer);\n  leafWriterDestroy(&writer);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Delete the merged segment data. */\n  return segdir_delete(v, iLevel);\n\n err:\n  for(i=0; i<MERGE_COUNT; i++){\n    leavesReaderDestroy(&lrs[i]);\n  }\n  leafWriterDestroy(&writer);\n  return rc;\n}\n\n/* Accumulate the union of *acc and *pData into *acc. */\nstatic void docListAccumulateUnion(DataBuffer *acc,\n                                   const char *pData, int nData) {\n  DataBuffer tmp = *acc;\n  dataBufferInit(acc, tmp.nData+nData);\n  docListUnion(tmp.pData, tmp.nData, pData, nData, acc);\n  dataBufferDestroy(&tmp);\n}\n\n/* TODO(shess) It might be interesting to explore different merge\n** strategies, here.  For instance, since this is a sorted merge, we\n** could easily merge many doclists in parallel.  With some\n** comprehension of the storage format, we could merge all of the\n** doclists within a leaf node directly from the leaf node's storage.\n** It may be worthwhile to merge smaller doclists before larger\n** doclists, since they can be traversed more quickly - but the\n** results may have less overlap, making them more expensive in a\n** different way.\n*/\n\n/* Scan pReader for pTerm/nTerm, and merge the term's doclist over\n** *out (any doclists with duplicate docids overwrite those in *out).\n** Internal function for loadSegmentLeaf().\n*/\nstatic int loadSegmentLeavesInt(fulltext_vtab *v, LeavesReader *pReader,\n                                const char *pTerm, int nTerm, int isPrefix,\n                                DataBuffer *out){\n  /* doclist data is accumulated into pBuffers similar to how one does\n  ** increment in binary arithmetic.  If index 0 is empty, the data is\n  ** stored there.  If there is data there, it is merged and the\n  ** results carried into position 1, with further merge-and-carry\n  ** until an empty position is found.\n  */\n  DataBuffer *pBuffers = NULL;\n  int nBuffers = 0, nMaxBuffers = 0, rc;\n\n  assert( nTerm>0 );\n\n  for(rc=SQLITE_OK; rc==SQLITE_OK && !leavesReaderAtEnd(pReader);\n      rc=leavesReaderStep(v, pReader)){\n    /* TODO(shess) Really want leavesReaderTermCmp(), but that name is\n    ** already taken to compare the terms of two LeavesReaders.  Think\n    ** on a better name.  [Meanwhile, break encapsulation rather than\n    ** use a confusing name.]\n    */\n    int c = leafReaderTermCmp(&pReader->leafReader, pTerm, nTerm, isPrefix);\n    if( c>0 ) break;      /* Past any possible matches. */\n    if( c==0 ){\n      const char *pData = leavesReaderData(pReader);\n      int iBuffer, nData = leavesReaderDataBytes(pReader);\n\n      /* Find the first empty buffer. */\n      for(iBuffer=0; iBuffer<nBuffers; ++iBuffer){\n        if( 0==pBuffers[iBuffer].nData ) break;\n      }\n\n      /* Out of buffers, add an empty one. */\n      if( iBuffer==nBuffers ){\n        if( nBuffers==nMaxBuffers ){\n          DataBuffer *p;\n          nMaxBuffers += 20;\n\n          /* Manual realloc so we can handle NULL appropriately. */\n          p = sqlite3_malloc(nMaxBuffers*sizeof(*pBuffers));\n          if( p==NULL ){\n            rc = SQLITE_NOMEM;\n            break;\n          }\n\n          if( nBuffers>0 ){\n            assert(pBuffers!=NULL);\n            memcpy(p, pBuffers, nBuffers*sizeof(*pBuffers));\n            sqlite3_free(pBuffers);\n          }\n          pBuffers = p;\n        }\n        dataBufferInit(&(pBuffers[nBuffers]), 0);\n        nBuffers++;\n      }\n\n      /* At this point, must have an empty at iBuffer. */\n      assert(iBuffer<nBuffers && pBuffers[iBuffer].nData==0);\n\n      /* If empty was first buffer, no need for merge logic. */\n      if( iBuffer==0 ){\n        dataBufferReplace(&(pBuffers[0]), pData, nData);\n      }else{\n        /* pAcc is the empty buffer the merged data will end up in. */\n        DataBuffer *pAcc = &(pBuffers[iBuffer]);\n        DataBuffer *p = &(pBuffers[0]);\n\n        /* Handle position 0 specially to avoid need to prime pAcc\n        ** with pData/nData.\n        */\n        dataBufferSwap(p, pAcc);\n        docListAccumulateUnion(pAcc, pData, nData);\n\n        /* Accumulate remaining doclists into pAcc. */\n        for(++p; p<pAcc; ++p){\n          docListAccumulateUnion(pAcc, p->pData, p->nData);\n\n          /* dataBufferReset() could allow a large doclist to blow up\n          ** our memory requirements.\n          */\n          if( p->nCapacity<1024 ){\n            dataBufferReset(p);\n          }else{\n            dataBufferDestroy(p);\n            dataBufferInit(p, 0);\n          }\n        }\n      }\n    }\n  }\n\n  /* Union all the doclists together into *out. */\n  /* TODO(shess) What if *out is big?  Sigh. */\n  if( rc==SQLITE_OK && nBuffers>0 ){\n    int iBuffer;\n    for(iBuffer=0; iBuffer<nBuffers; ++iBuffer){\n      if( pBuffers[iBuffer].nData>0 ){\n        if( out->nData==0 ){\n          dataBufferSwap(out, &(pBuffers[iBuffer]));\n        }else{\n          docListAccumulateUnion(out, pBuffers[iBuffer].pData,\n                                 pBuffers[iBuffer].nData);\n        }\n      }\n    }\n  }\n\n  while( nBuffers-- ){\n    dataBufferDestroy(&(pBuffers[nBuffers]));\n  }\n  if( pBuffers!=NULL ) sqlite3_free(pBuffers);\n\n  return rc;\n}\n\n/* Call loadSegmentLeavesInt() with pData/nData as input. */\nstatic int loadSegmentLeaf(fulltext_vtab *v, const char *pData, int nData,\n                           const char *pTerm, int nTerm, int isPrefix,\n                           DataBuffer *out){\n  LeavesReader reader;\n  int rc;\n\n  assert( nData>1 );\n  assert( *pData=='\\0' );\n  rc = leavesReaderInit(v, 0, 0, 0, pData, nData, &reader);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = loadSegmentLeavesInt(v, &reader, pTerm, nTerm, isPrefix, out);\n  leavesReaderReset(&reader);\n  leavesReaderDestroy(&reader);\n  return rc;\n}\n\n/* Call loadSegmentLeavesInt() with the leaf nodes from iStartLeaf to\n** iEndLeaf (inclusive) as input, and merge the resulting doclist into\n** out.\n*/\nstatic int loadSegmentLeaves(fulltext_vtab *v,\n                             sqlite_int64 iStartLeaf, sqlite_int64 iEndLeaf,\n                             const char *pTerm, int nTerm, int isPrefix,\n                             DataBuffer *out){\n  int rc;\n  LeavesReader reader;\n\n  assert( iStartLeaf<=iEndLeaf );\n  rc = leavesReaderInit(v, 0, iStartLeaf, iEndLeaf, NULL, 0, &reader);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = loadSegmentLeavesInt(v, &reader, pTerm, nTerm, isPrefix, out);\n  leavesReaderReset(&reader);\n  leavesReaderDestroy(&reader);\n  return rc;\n}\n\n/* Taking pData/nData as an interior node, find the sequence of child\n** nodes which could include pTerm/nTerm/isPrefix.  Note that the\n** interior node terms logically come between the blocks, so there is\n** one more blockid than there are terms (that block contains terms >=\n** the last interior-node term).\n*/\n/* TODO(shess) The calling code may already know that the end child is\n** not worth calculating, because the end may be in a later sibling\n** node.  Consider whether breaking symmetry is worthwhile.  I suspect\n** it is not worthwhile.\n*/\nstatic void getChildrenContaining(const char *pData, int nData,\n                                  const char *pTerm, int nTerm, int isPrefix,\n                                  sqlite_int64 *piStartChild,\n                                  sqlite_int64 *piEndChild){\n  InteriorReader reader;\n\n  assert( nData>1 );\n  assert( *pData!='\\0' );\n  interiorReaderInit(pData, nData, &reader);\n\n  /* Scan for the first child which could contain pTerm/nTerm. */\n  while( !interiorReaderAtEnd(&reader) ){\n    if( interiorReaderTermCmp(&reader, pTerm, nTerm, 0)>0 ) break;\n    interiorReaderStep(&reader);\n  }\n  *piStartChild = interiorReaderCurrentBlockid(&reader);\n\n  /* Keep scanning to find a term greater than our term, using prefix\n  ** comparison if indicated.  If isPrefix is false, this will be the\n  ** same blockid as the starting block.\n  */\n  while( !interiorReaderAtEnd(&reader) ){\n    if( interiorReaderTermCmp(&reader, pTerm, nTerm, isPrefix)>0 ) break;\n    interiorReaderStep(&reader);\n  }\n  *piEndChild = interiorReaderCurrentBlockid(&reader);\n\n  interiorReaderDestroy(&reader);\n\n  /* Children must ascend, and if !prefix, both must be the same. */\n  assert( *piEndChild>=*piStartChild );\n  assert( isPrefix || *piStartChild==*piEndChild );\n}\n\n/* Read block at iBlockid and pass it with other params to\n** getChildrenContaining().\n*/\nstatic int loadAndGetChildrenContaining(\n  fulltext_vtab *v,\n  sqlite_int64 iBlockid,\n  const char *pTerm, int nTerm, int isPrefix,\n  sqlite_int64 *piStartChild, sqlite_int64 *piEndChild\n){\n  sqlite3_stmt *s = NULL;\n  int rc;\n\n  assert( iBlockid!=0 );\n  assert( pTerm!=NULL );\n  assert( nTerm!=0 );        /* TODO(shess) Why not allow this? */\n  assert( piStartChild!=NULL );\n  assert( piEndChild!=NULL );\n\n  rc = sql_get_statement(v, BLOCK_SELECT_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_bind_int64(s, 1, iBlockid);\n  if( rc!=SQLITE_OK ) return rc;\n\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_DONE ) return SQLITE_ERROR;\n  if( rc!=SQLITE_ROW ) return rc;\n\n  getChildrenContaining(sqlite3_column_blob(s, 0), sqlite3_column_bytes(s, 0),\n                        pTerm, nTerm, isPrefix, piStartChild, piEndChild);\n\n  /* We expect only one row.  We must execute another sqlite3_step()\n   * to complete the iteration; otherwise the table will remain\n   * locked. */\n  rc = sqlite3_step(s);\n  if( rc==SQLITE_ROW ) return SQLITE_ERROR;\n  if( rc!=SQLITE_DONE ) return rc;\n\n  return SQLITE_OK;\n}\n\n/* Traverse the tree represented by pData[nData] looking for\n** pTerm[nTerm], placing its doclist into *out.  This is internal to\n** loadSegment() to make error-handling cleaner.\n*/\nstatic int loadSegmentInt(fulltext_vtab *v, const char *pData, int nData,\n                          sqlite_int64 iLeavesEnd,\n                          const char *pTerm, int nTerm, int isPrefix,\n                          DataBuffer *out){\n  /* Special case where root is a leaf. */\n  if( *pData=='\\0' ){\n    return loadSegmentLeaf(v, pData, nData, pTerm, nTerm, isPrefix, out);\n  }else{\n    int rc;\n    sqlite_int64 iStartChild, iEndChild;\n\n    /* Process pData as an interior node, then loop down the tree\n    ** until we find the set of leaf nodes to scan for the term.\n    */\n    getChildrenContaining(pData, nData, pTerm, nTerm, isPrefix,\n                          &iStartChild, &iEndChild);\n    while( iStartChild>iLeavesEnd ){\n      sqlite_int64 iNextStart, iNextEnd;\n      rc = loadAndGetChildrenContaining(v, iStartChild, pTerm, nTerm, isPrefix,\n                                        &iNextStart, &iNextEnd);\n      if( rc!=SQLITE_OK ) return rc;\n\n      /* If we've branched, follow the end branch, too. */\n      if( iStartChild!=iEndChild ){\n        sqlite_int64 iDummy;\n        rc = loadAndGetChildrenContaining(v, iEndChild, pTerm, nTerm, isPrefix,\n                                          &iDummy, &iNextEnd);\n        if( rc!=SQLITE_OK ) return rc;\n      }\n\n      assert( iNextStart<=iNextEnd );\n      iStartChild = iNextStart;\n      iEndChild = iNextEnd;\n    }\n    assert( iStartChild<=iLeavesEnd );\n    assert( iEndChild<=iLeavesEnd );\n\n    /* Scan through the leaf segments for doclists. */\n    return loadSegmentLeaves(v, iStartChild, iEndChild,\n                             pTerm, nTerm, isPrefix, out);\n  }\n}\n\n/* Call loadSegmentInt() to collect the doclist for pTerm/nTerm, then\n** merge its doclist over *out (any duplicate doclists read from the\n** segment rooted at pData will overwrite those in *out).\n*/\n/* TODO(shess) Consider changing this to determine the depth of the\n** leaves using either the first characters of interior nodes (when\n** ==1, we're one level above the leaves), or the first character of\n** the root (which will describe the height of the tree directly).\n** Either feels somewhat tricky to me.\n*/\n/* TODO(shess) The current merge is likely to be slow for large\n** doclists (though it should process from newest/smallest to\n** oldest/largest, so it may not be that bad).  It might be useful to\n** modify things to allow for N-way merging.  This could either be\n** within a segment, with pairwise merges across segments, or across\n** all segments at once.\n*/\nstatic int loadSegment(fulltext_vtab *v, const char *pData, int nData,\n                       sqlite_int64 iLeavesEnd,\n                       const char *pTerm, int nTerm, int isPrefix,\n                       DataBuffer *out){\n  DataBuffer result;\n  int rc;\n\n  assert( nData>1 );\n\n  /* This code should never be called with buffered updates. */\n  assert( v->nPendingData<0 );\n\n  dataBufferInit(&result, 0);\n  rc = loadSegmentInt(v, pData, nData, iLeavesEnd,\n                      pTerm, nTerm, isPrefix, &result);\n  if( rc==SQLITE_OK && result.nData>0 ){\n    if( out->nData==0 ){\n      DataBuffer tmp = *out;\n      *out = result;\n      result = tmp;\n    }else{\n      DataBuffer merged;\n      DLReader readers[2];\n\n      dlrInit(&readers[0], DL_DEFAULT, out->pData, out->nData);\n      dlrInit(&readers[1], DL_DEFAULT, result.pData, result.nData);\n      dataBufferInit(&merged, out->nData+result.nData);\n      docListMerge(&merged, readers, 2);\n      dataBufferDestroy(out);\n      *out = merged;\n      dlrDestroy(&readers[0]);\n      dlrDestroy(&readers[1]);\n    }\n  }\n  dataBufferDestroy(&result);\n  return rc;\n}\n\n/* Scan the database and merge together the posting lists for the term\n** into *out.\n*/\nstatic int termSelect(fulltext_vtab *v, int iColumn,\n                      const char *pTerm, int nTerm, int isPrefix,\n                      DocListType iType, DataBuffer *out){\n  DataBuffer doclist;\n  sqlite3_stmt *s;\n  int rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* This code should never be called with buffered updates. */\n  assert( v->nPendingData<0 );\n\n  dataBufferInit(&doclist, 0);\n\n  /* Traverse the segments from oldest to newest so that newer doclist\n  ** elements for given docids overwrite older elements.\n  */\n  while( (rc = sqlite3_step(s))==SQLITE_ROW ){\n    const char *pData = sqlite3_column_blob(s, 2);\n    const int nData = sqlite3_column_bytes(s, 2);\n    const sqlite_int64 iLeavesEnd = sqlite3_column_int64(s, 1);\n    rc = loadSegment(v, pData, nData, iLeavesEnd, pTerm, nTerm, isPrefix,\n                     &doclist);\n    if( rc!=SQLITE_OK ) goto err;\n  }\n  if( rc==SQLITE_DONE ){\n    if( doclist.nData!=0 ){\n      /* TODO(shess) The old term_select_all() code applied the column\n      ** restrict as we merged segments, leading to smaller buffers.\n      ** This is probably worthwhile to bring back, once the new storage\n      ** system is checked in.\n      */\n      if( iColumn==v->nColumn) iColumn = -1;\n      docListTrim(DL_DEFAULT, doclist.pData, doclist.nData,\n                  iColumn, iType, out);\n    }\n    rc = SQLITE_OK;\n  }\n\n err:\n  dataBufferDestroy(&doclist);\n  return rc;\n}\n\n/****************************************************************/\n/* Used to hold hashtable data for sorting. */\ntypedef struct TermData {\n  const char *pTerm;\n  int nTerm;\n  DLCollector *pCollector;\n} TermData;\n\n/* Orders TermData elements in strcmp fashion ( <0 for less-than, 0\n** for equal, >0 for greater-than).\n*/\nstatic int termDataCmp(const void *av, const void *bv){\n  const TermData *a = (const TermData *)av;\n  const TermData *b = (const TermData *)bv;\n  int n = a->nTerm<b->nTerm ? a->nTerm : b->nTerm;\n  int c = memcmp(a->pTerm, b->pTerm, n);\n  if( c!=0 ) return c;\n  return a->nTerm-b->nTerm;\n}\n\n/* Order pTerms data by term, then write a new level 0 segment using\n** LeafWriter.\n*/\nstatic int writeZeroSegment(fulltext_vtab *v, fts2Hash *pTerms){\n  fts2HashElem *e;\n  int idx, rc, i, n;\n  TermData *pData;\n  LeafWriter writer;\n  DataBuffer dl;\n\n  /* Determine the next index at level 0, merging as necessary. */\n  rc = segdirNextIndex(v, 0, &idx);\n  if( rc!=SQLITE_OK ) return rc;\n\n  n = fts2HashCount(pTerms);\n  pData = sqlite3_malloc(n*sizeof(TermData));\n\n  for(i = 0, e = fts2HashFirst(pTerms); e; i++, e = fts2HashNext(e)){\n    assert( i<n );\n    pData[i].pTerm = fts2HashKey(e);\n    pData[i].nTerm = fts2HashKeysize(e);\n    pData[i].pCollector = fts2HashData(e);\n  }\n  assert( i==n );\n\n  /* TODO(shess) Should we allow user-defined collation sequences,\n  ** here?  I think we only need that once we support prefix searches.\n  */\n  if( n>1 ) qsort(pData, n, sizeof(*pData), termDataCmp);\n\n  /* TODO(shess) Refactor so that we can write directly to the segment\n  ** DataBuffer, as happens for segment merges.\n  */\n  leafWriterInit(0, idx, &writer);\n  dataBufferInit(&dl, 0);\n  for(i=0; i<n; i++){\n    dataBufferReset(&dl);\n    dlcAddDoclist(pData[i].pCollector, &dl);\n    rc = leafWriterStep(v, &writer,\n                        pData[i].pTerm, pData[i].nTerm, dl.pData, dl.nData);\n    if( rc!=SQLITE_OK ) goto err;\n  }\n  rc = leafWriterFinalize(v, &writer);\n\n err:\n  dataBufferDestroy(&dl);\n  sqlite3_free(pData);\n  leafWriterDestroy(&writer);\n  return rc;\n}\n\n/* If pendingTerms has data, free it. */\nstatic int clearPendingTerms(fulltext_vtab *v){\n  if( v->nPendingData>=0 ){\n    fts2HashElem *e;\n    for(e=fts2HashFirst(&v->pendingTerms); e; e=fts2HashNext(e)){\n      dlcDelete(fts2HashData(e));\n    }\n    fts2HashClear(&v->pendingTerms);\n    v->nPendingData = -1;\n  }\n  return SQLITE_OK;\n}\n\n/* If pendingTerms has data, flush it to a level-zero segment, and\n** free it.\n*/\nstatic int flushPendingTerms(fulltext_vtab *v){\n  if( v->nPendingData>=0 ){\n    int rc = writeZeroSegment(v, &v->pendingTerms);\n    if( rc==SQLITE_OK ) clearPendingTerms(v);\n    return rc;\n  }\n  return SQLITE_OK;\n}\n\n/* If pendingTerms is \"too big\", or docid is out of order, flush it.\n** Regardless, be certain that pendingTerms is initialized for use.\n*/\nstatic int initPendingTerms(fulltext_vtab *v, sqlite_int64 iDocid){\n  /* TODO(shess) Explore whether partially flushing the buffer on\n  ** forced-flush would provide better performance.  I suspect that if\n  ** we ordered the doclists by size and flushed the largest until the\n  ** buffer was half empty, that would let the less frequent terms\n  ** generate longer doclists.\n  */\n  if( iDocid<=v->iPrevDocid || v->nPendingData>kPendingThreshold ){\n    int rc = flushPendingTerms(v);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  if( v->nPendingData<0 ){\n    fts2HashInit(&v->pendingTerms, FTS2_HASH_STRING, 1);\n    v->nPendingData = 0;\n  }\n  v->iPrevDocid = iDocid;\n  return SQLITE_OK;\n}\n\n/* This function implements the xUpdate callback; it is the top-level entry\n * point for inserting, deleting or updating a row in a full-text table. */\nstatic int fulltextUpdate(sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg,\n                   sqlite_int64 *pRowid){\n  fulltext_vtab *v = (fulltext_vtab *) pVtab;\n  int rc;\n\n  TRACE((\"FTS2 Update %p\\n\", pVtab));\n\n  if( nArg<2 ){\n    rc = index_delete(v, sqlite3_value_int64(ppArg[0]));\n    if( rc==SQLITE_OK ){\n      /* If we just deleted the last row in the table, clear out the\n      ** index data.\n      */\n      rc = content_exists(v);\n      if( rc==SQLITE_ROW ){\n        rc = SQLITE_OK;\n      }else if( rc==SQLITE_DONE ){\n        /* Clear the pending terms so we don't flush a useless level-0\n        ** segment when the transaction closes.\n        */\n        rc = clearPendingTerms(v);\n        if( rc==SQLITE_OK ){\n          rc = segdir_delete_all(v);\n        }\n      }\n    }\n  } else if( sqlite3_value_type(ppArg[0]) != SQLITE_NULL ){\n    /* An update:\n     * ppArg[0] = old rowid\n     * ppArg[1] = new rowid\n     * ppArg[2..2+v->nColumn-1] = values\n     * ppArg[2+v->nColumn] = value for magic column (we ignore this)\n     */\n    sqlite_int64 rowid = sqlite3_value_int64(ppArg[0]);\n    if( sqlite3_value_type(ppArg[1]) != SQLITE_INTEGER ||\n      sqlite3_value_int64(ppArg[1]) != rowid ){\n      rc = SQLITE_ERROR;  /* we don't allow changing the rowid */\n    } else {\n      assert( nArg==2+v->nColumn+1);\n      rc = index_update(v, rowid, &ppArg[2]);\n    }\n  } else {\n    /* An insert:\n     * ppArg[1] = requested rowid\n     * ppArg[2..2+v->nColumn-1] = values\n     * ppArg[2+v->nColumn] = value for magic column (we ignore this)\n     */\n    assert( nArg==2+v->nColumn+1);\n    rc = index_insert(v, ppArg[1], &ppArg[2], pRowid);\n  }\n\n  return rc;\n}\n\nstatic int fulltextSync(sqlite3_vtab *pVtab){\n  TRACE((\"FTS2 xSync()\\n\"));\n  return flushPendingTerms((fulltext_vtab *)pVtab);\n}\n\nstatic int fulltextBegin(sqlite3_vtab *pVtab){\n  fulltext_vtab *v = (fulltext_vtab *) pVtab;\n  TRACE((\"FTS2 xBegin()\\n\"));\n\n  /* Any buffered updates should have been cleared by the previous\n  ** transaction.\n  */\n  assert( v->nPendingData<0 );\n  return clearPendingTerms(v);\n}\n\nstatic int fulltextCommit(sqlite3_vtab *pVtab){\n  fulltext_vtab *v = (fulltext_vtab *) pVtab;\n  TRACE((\"FTS2 xCommit()\\n\"));\n\n  /* Buffered updates should have been cleared by fulltextSync(). */\n  assert( v->nPendingData<0 );\n  return clearPendingTerms(v);\n}\n\nstatic int fulltextRollback(sqlite3_vtab *pVtab){\n  TRACE((\"FTS2 xRollback()\\n\"));\n  return clearPendingTerms((fulltext_vtab *)pVtab);\n}\n\n/*\n** Implementation of the snippet() function for FTS2\n*/\nstatic void snippetFunc(\n  sqlite3_context *pContext,\n  int argc,\n  sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc<1 ) return;\n  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    sqlite3_result_error(pContext, \"illegal first argument to html_snippet\",-1);\n  }else{\n    const char *zStart = \"<b>\";\n    const char *zEnd = \"</b>\";\n    const char *zEllipsis = \"<b>...</b>\";\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    if( argc>=2 ){\n      zStart = (const char*)sqlite3_value_text(argv[1]);\n      if( argc>=3 ){\n        zEnd = (const char*)sqlite3_value_text(argv[2]);\n        if( argc>=4 ){\n          zEllipsis = (const char*)sqlite3_value_text(argv[3]);\n        }\n      }\n    }\n    snippetAllOffsets(pCursor);\n    snippetText(pCursor, zStart, zEnd, zEllipsis);\n    sqlite3_result_text(pContext, pCursor->snippet.zSnippet,\n                        pCursor->snippet.nSnippet, SQLITE_STATIC);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS2\n*/\nstatic void snippetOffsetsFunc(\n  sqlite3_context *pContext,\n  int argc,\n  sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc<1 ) return;\n  if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n      sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    sqlite3_result_error(pContext, \"illegal first argument to offsets\",-1);\n  }else{\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    snippetAllOffsets(pCursor);\n    snippetOffsetText(&pCursor->snippet);\n    sqlite3_result_text(pContext,\n                        pCursor->snippet.zOffset, pCursor->snippet.nOffset,\n                        SQLITE_STATIC);\n  }\n}\n\n/* OptLeavesReader is nearly identical to LeavesReader, except that\n** where LeavesReader is geared towards the merging of complete\n** segment levels (with exactly MERGE_COUNT segments), OptLeavesReader\n** is geared towards implementation of the optimize() function, and\n** can merge all segments simultaneously.  This version may be\n** somewhat less efficient than LeavesReader because it merges into an\n** accumulator rather than doing an N-way merge, but since segment\n** size grows exponentially (so segment count logrithmically) this is\n** probably not an immediate problem.\n*/\n/* TODO(shess): Prove that assertion, or extend the merge code to\n** merge tree fashion (like the prefix-searching code does).\n*/\n/* TODO(shess): OptLeavesReader and LeavesReader could probably be\n** merged with little or no loss of performance for LeavesReader.  The\n** merged code would need to handle >MERGE_COUNT segments, and would\n** also need to be able to optionally optimize away deletes.\n*/\ntypedef struct OptLeavesReader {\n  /* Segment number, to order readers by age. */\n  int segment;\n  LeavesReader reader;\n} OptLeavesReader;\n\nstatic int optLeavesReaderAtEnd(OptLeavesReader *pReader){\n  return leavesReaderAtEnd(&pReader->reader);\n}\nstatic int optLeavesReaderTermBytes(OptLeavesReader *pReader){\n  return leavesReaderTermBytes(&pReader->reader);\n}\nstatic const char *optLeavesReaderData(OptLeavesReader *pReader){\n  return leavesReaderData(&pReader->reader);\n}\nstatic int optLeavesReaderDataBytes(OptLeavesReader *pReader){\n  return leavesReaderDataBytes(&pReader->reader);\n}\nstatic const char *optLeavesReaderTerm(OptLeavesReader *pReader){\n  return leavesReaderTerm(&pReader->reader);\n}\nstatic int optLeavesReaderStep(fulltext_vtab *v, OptLeavesReader *pReader){\n  return leavesReaderStep(v, &pReader->reader);\n}\nstatic int optLeavesReaderTermCmp(OptLeavesReader *lr1, OptLeavesReader *lr2){\n  return leavesReaderTermCmp(&lr1->reader, &lr2->reader);\n}\n/* Order by term ascending, segment ascending (oldest to newest), with\n** exhausted readers to the end.\n*/\nstatic int optLeavesReaderCmp(OptLeavesReader *lr1, OptLeavesReader *lr2){\n  int c = optLeavesReaderTermCmp(lr1, lr2);\n  if( c!=0 ) return c;\n  return lr1->segment-lr2->segment;\n}\n/* Bubble pLr[0] to appropriate place in pLr[1..nLr-1].  Assumes that\n** pLr[1..nLr-1] is already sorted.\n*/\nstatic void optLeavesReaderReorder(OptLeavesReader *pLr, int nLr){\n  while( nLr>1 && optLeavesReaderCmp(pLr, pLr+1)>0 ){\n    OptLeavesReader tmp = pLr[0];\n    pLr[0] = pLr[1];\n    pLr[1] = tmp;\n    nLr--;\n    pLr++;\n  }\n}\n\n/* optimize() helper function.  Put the readers in order and iterate\n** through them, merging doclists for matching terms into pWriter.\n** Returns SQLITE_OK on success, or the SQLite error code which\n** prevented success.\n*/\nstatic int optimizeInternal(fulltext_vtab *v,\n                            OptLeavesReader *readers, int nReaders,\n                            LeafWriter *pWriter){\n  int i, rc = SQLITE_OK;\n  DataBuffer doclist, merged, tmp;\n\n  /* Order the readers. */\n  i = nReaders;\n  while( i-- > 0 ){\n    optLeavesReaderReorder(&readers[i], nReaders-i);\n  }\n\n  dataBufferInit(&doclist, LEAF_MAX);\n  dataBufferInit(&merged, LEAF_MAX);\n\n  /* Exhausted readers bubble to the end, so when the first reader is\n  ** at eof, all are at eof.\n  */\n  while( !optLeavesReaderAtEnd(&readers[0]) ){\n\n    /* Figure out how many readers share the next term. */\n    for(i=1; i<nReaders && !optLeavesReaderAtEnd(&readers[i]); i++){\n      if( 0!=optLeavesReaderTermCmp(&readers[0], &readers[i]) ) break;\n    }\n\n    /* Special-case for no merge. */\n    if( i==1 ){\n      /* Trim deletions from the doclist. */\n      dataBufferReset(&merged);\n      docListTrim(DL_DEFAULT,\n                  optLeavesReaderData(&readers[0]),\n                  optLeavesReaderDataBytes(&readers[0]),\n                  -1, DL_DEFAULT, &merged);\n    }else{\n      DLReader dlReaders[MERGE_COUNT];\n      int iReader, nReaders;\n\n      /* Prime the pipeline with the first reader's doclist.  After\n      ** one pass index 0 will reference the accumulated doclist.\n      */\n      dlrInit(&dlReaders[0], DL_DEFAULT,\n              optLeavesReaderData(&readers[0]),\n              optLeavesReaderDataBytes(&readers[0]));\n      iReader = 1;\n\n      assert( iReader<i );  /* Must execute the loop at least once. */\n      while( iReader<i ){\n        /* Merge 16 inputs per pass. */\n        for( nReaders=1; iReader<i && nReaders<MERGE_COUNT;\n             iReader++, nReaders++ ){\n          dlrInit(&dlReaders[nReaders], DL_DEFAULT,\n                  optLeavesReaderData(&readers[iReader]),\n                  optLeavesReaderDataBytes(&readers[iReader]));\n        }\n\n        /* Merge doclists and swap result into accumulator. */\n        dataBufferReset(&merged);\n        docListMerge(&merged, dlReaders, nReaders);\n        tmp = merged;\n        merged = doclist;\n        doclist = tmp;\n\n        while( nReaders-- > 0 ){\n          dlrDestroy(&dlReaders[nReaders]);\n        }\n\n        /* Accumulated doclist to reader 0 for next pass. */\n        dlrInit(&dlReaders[0], DL_DEFAULT, doclist.pData, doclist.nData);\n      }\n\n      /* Destroy reader that was left in the pipeline. */\n      dlrDestroy(&dlReaders[0]);\n\n      /* Trim deletions from the doclist. */\n      dataBufferReset(&merged);\n      docListTrim(DL_DEFAULT, doclist.pData, doclist.nData,\n                  -1, DL_DEFAULT, &merged);\n    }\n\n    /* Only pass doclists with hits (skip if all hits deleted). */\n    if( merged.nData>0 ){\n      rc = leafWriterStep(v, pWriter,\n                          optLeavesReaderTerm(&readers[0]),\n                          optLeavesReaderTermBytes(&readers[0]),\n                          merged.pData, merged.nData);\n      if( rc!=SQLITE_OK ) goto err;\n    }\n\n    /* Step merged readers to next term and reorder. */\n    while( i-- > 0 ){\n      rc = optLeavesReaderStep(v, &readers[i]);\n      if( rc!=SQLITE_OK ) goto err;\n\n      optLeavesReaderReorder(&readers[i], nReaders-i);\n    }\n  }\n\n err:\n  dataBufferDestroy(&doclist);\n  dataBufferDestroy(&merged);\n  return rc;\n}\n\n/* Implement optimize() function for FTS3.  optimize(t) merges all\n** segments in the fts index into a single segment.  't' is the magic\n** table-named column.\n*/\nstatic void optimizeFunc(sqlite3_context *pContext,\n                         int argc, sqlite3_value **argv){\n  fulltext_cursor *pCursor;\n  if( argc>1 ){\n    sqlite3_result_error(pContext, \"excess arguments to optimize()\",-1);\n  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    sqlite3_result_error(pContext, \"illegal first argument to optimize\",-1);\n  }else{\n    fulltext_vtab *v;\n    int i, rc, iMaxLevel;\n    OptLeavesReader *readers;\n    int nReaders;\n    LeafWriter writer;\n    sqlite3_stmt *s;\n\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    v = cursor_vtab(pCursor);\n\n    /* Flush any buffered updates before optimizing. */\n    rc = flushPendingTerms(v);\n    if( rc!=SQLITE_OK ) goto err;\n\n    rc = segdir_count(v, &nReaders, &iMaxLevel);\n    if( rc!=SQLITE_OK ) goto err;\n    if( nReaders==0 || nReaders==1 ){\n      sqlite3_result_text(pContext, \"Index already optimal\", -1,\n                          SQLITE_STATIC);\n      return;\n    }\n\n    rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);\n    if( rc!=SQLITE_OK ) goto err;\n\n    readers = sqlite3_malloc(nReaders*sizeof(readers[0]));\n    if( readers==NULL ) goto err;\n\n    /* Note that there will already be a segment at this position\n    ** until we call segdir_delete() on iMaxLevel.\n    */\n    leafWriterInit(iMaxLevel, 0, &writer);\n\n    i = 0;\n    while( (rc = sqlite3_step(s))==SQLITE_ROW ){\n      sqlite_int64 iStart = sqlite3_column_int64(s, 0);\n      sqlite_int64 iEnd = sqlite3_column_int64(s, 1);\n      const char *pRootData = sqlite3_column_blob(s, 2);\n      int nRootData = sqlite3_column_bytes(s, 2);\n\n      assert( i<nReaders );\n      rc = leavesReaderInit(v, -1, iStart, iEnd, pRootData, nRootData,\n                            &readers[i].reader);\n      if( rc!=SQLITE_OK ) break;\n\n      readers[i].segment = i;\n      i++;\n    }\n\n    /* If we managed to successfully read them all, optimize them. */\n    if( rc==SQLITE_DONE ){\n      assert( i==nReaders );\n      rc = optimizeInternal(v, readers, nReaders, &writer);\n    }\n\n    while( i-- > 0 ){\n      leavesReaderDestroy(&readers[i].reader);\n    }\n    sqlite3_free(readers);\n\n    /* If we've successfully gotten to here, delete the old segments\n    ** and flush the interior structure of the new segment.\n    */\n    if( rc==SQLITE_OK ){\n      for( i=0; i<=iMaxLevel; i++ ){\n        rc = segdir_delete(v, i);\n        if( rc!=SQLITE_OK ) break;\n      }\n\n      if( rc==SQLITE_OK ) rc = leafWriterFinalize(v, &writer);\n    }\n\n    leafWriterDestroy(&writer);\n\n    if( rc!=SQLITE_OK ) goto err;\n\n    sqlite3_result_text(pContext, \"Index optimized\", -1, SQLITE_STATIC);\n    return;\n\n    /* TODO(shess): Error-handling needs to be improved along the\n    ** lines of the dump_ functions.\n    */\n err:\n    {\n      char buf[512];\n      sqlite3_snprintf(sizeof(buf), buf, \"Error in optimize: %s\",\n                       sqlite3_errmsg(sqlite3_context_db_handle(pContext)));\n      sqlite3_result_error(pContext, buf, -1);\n    }\n  }\n}\n\n#ifdef SQLITE_TEST\n/* Generate an error of the form \"<prefix>: <msg>\".  If msg is NULL,\n** pull the error from the context's db handle.\n*/\nstatic void generateError(sqlite3_context *pContext,\n                          const char *prefix, const char *msg){\n  char buf[512];\n  if( msg==NULL ) msg = sqlite3_errmsg(sqlite3_context_db_handle(pContext));\n  sqlite3_snprintf(sizeof(buf), buf, \"%s: %s\", prefix, msg);\n  sqlite3_result_error(pContext, buf, -1);\n}\n\n/* Helper function to collect the set of terms in the segment into\n** pTerms.  The segment is defined by the leaf nodes between\n** iStartBlockid and iEndBlockid, inclusive, or by the contents of\n** pRootData if iStartBlockid is 0 (in which case the entire segment\n** fit in a leaf).\n*/\nstatic int collectSegmentTerms(fulltext_vtab *v, sqlite3_stmt *s,\n                               fts2Hash *pTerms){\n  const sqlite_int64 iStartBlockid = sqlite3_column_int64(s, 0);\n  const sqlite_int64 iEndBlockid = sqlite3_column_int64(s, 1);\n  const char *pRootData = sqlite3_column_blob(s, 2);\n  const int nRootData = sqlite3_column_bytes(s, 2);\n  LeavesReader reader;\n  int rc = leavesReaderInit(v, 0, iStartBlockid, iEndBlockid,\n                            pRootData, nRootData, &reader);\n  if( rc!=SQLITE_OK ) return rc;\n\n  while( rc==SQLITE_OK && !leavesReaderAtEnd(&reader) ){\n    const char *pTerm = leavesReaderTerm(&reader);\n    const int nTerm = leavesReaderTermBytes(&reader);\n    void *oldValue = sqlite3Fts2HashFind(pTerms, pTerm, nTerm);\n    void *newValue = (void *)((char *)oldValue+1);\n\n    /* From the comment before sqlite3Fts2HashInsert in fts2_hash.c,\n    ** the data value passed is returned in case of malloc failure.\n    */\n    if( newValue==sqlite3Fts2HashInsert(pTerms, pTerm, nTerm, newValue) ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = leavesReaderStep(v, &reader);\n    }\n  }\n\n  leavesReaderDestroy(&reader);\n  return rc;\n}\n\n/* Helper function to build the result string for dump_terms(). */\nstatic int generateTermsResult(sqlite3_context *pContext, fts2Hash *pTerms){\n  int iTerm, nTerms, nResultBytes, iByte;\n  char *result;\n  TermData *pData;\n  fts2HashElem *e;\n\n  /* Iterate pTerms to generate an array of terms in pData for\n  ** sorting.\n  */\n  nTerms = fts2HashCount(pTerms);\n  assert( nTerms>0 );\n  pData = sqlite3_malloc(nTerms*sizeof(TermData));\n  if( pData==NULL ) return SQLITE_NOMEM;\n\n  nResultBytes = 0;\n  for(iTerm = 0, e = fts2HashFirst(pTerms); e; iTerm++, e = fts2HashNext(e)){\n    nResultBytes += fts2HashKeysize(e)+1;   /* Term plus trailing space */\n    assert( iTerm<nTerms );\n    pData[iTerm].pTerm = fts2HashKey(e);\n    pData[iTerm].nTerm = fts2HashKeysize(e);\n    pData[iTerm].pCollector = fts2HashData(e);  /* unused */\n  }\n  assert( iTerm==nTerms );\n\n  assert( nResultBytes>0 );   /* nTerms>0, nResultsBytes must be, too. */\n  result = sqlite3_malloc(nResultBytes);\n  if( result==NULL ){\n    sqlite3_free(pData);\n    return SQLITE_NOMEM;\n  }\n\n  if( nTerms>1 ) qsort(pData, nTerms, sizeof(*pData), termDataCmp);\n\n  /* Read the terms in order to build the result. */\n  iByte = 0;\n  for(iTerm=0; iTerm<nTerms; ++iTerm){\n    memcpy(result+iByte, pData[iTerm].pTerm, pData[iTerm].nTerm);\n    iByte += pData[iTerm].nTerm;\n    result[iByte++] = ' ';\n  }\n  assert( iByte==nResultBytes );\n  assert( result[nResultBytes-1]==' ' );\n  result[nResultBytes-1] = '\\0';\n\n  /* Passes away ownership of result. */\n  sqlite3_result_text(pContext, result, nResultBytes-1, sqlite3_free);\n  sqlite3_free(pData);\n  return SQLITE_OK;\n}\n\n/* Implements dump_terms() for use in inspecting the fts2 index from\n** tests.  TEXT result containing the ordered list of terms joined by\n** spaces.  dump_terms(t, level, idx) dumps the terms for the segment\n** specified by level, idx (in %_segdir), while dump_terms(t) dumps\n** all terms in the index.  In both cases t is the fts table's magic\n** table-named column.\n*/\nstatic void dumpTermsFunc(\n  sqlite3_context *pContext,\n  int argc, sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc!=3 && argc!=1 ){\n    generateError(pContext, \"dump_terms\", \"incorrect arguments\");\n  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    generateError(pContext, \"dump_terms\", \"illegal first argument\");\n  }else{\n    fulltext_vtab *v;\n    fts2Hash terms;\n    sqlite3_stmt *s = NULL;\n    int rc;\n\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    v = cursor_vtab(pCursor);\n\n    /* If passed only the cursor column, get all segments.  Otherwise\n    ** get the segment described by the following two arguments.\n    */\n    if( argc==1 ){\n      rc = sql_get_statement(v, SEGDIR_SELECT_ALL_STMT, &s);\n    }else{\n      rc = sql_get_statement(v, SEGDIR_SELECT_SEGMENT_STMT, &s);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_bind_int(s, 1, sqlite3_value_int(argv[1]));\n        if( rc==SQLITE_OK ){\n          rc = sqlite3_bind_int(s, 2, sqlite3_value_int(argv[2]));\n        }\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      generateError(pContext, \"dump_terms\", NULL);\n      return;\n    }\n\n    /* Collect the terms for each segment. */\n    sqlite3Fts2HashInit(&terms, FTS2_HASH_STRING, 1);\n    while( (rc = sqlite3_step(s))==SQLITE_ROW ){\n      rc = collectSegmentTerms(v, s, &terms);\n      if( rc!=SQLITE_OK ) break;\n    }\n\n    if( rc!=SQLITE_DONE ){\n      sqlite3_reset(s);\n      generateError(pContext, \"dump_terms\", NULL);\n    }else{\n      const int nTerms = fts2HashCount(&terms);\n      if( nTerms>0 ){\n        rc = generateTermsResult(pContext, &terms);\n        if( rc==SQLITE_NOMEM ){\n          generateError(pContext, \"dump_terms\", \"out of memory\");\n        }else{\n          assert( rc==SQLITE_OK );\n        }\n      }else if( argc==3 ){\n        /* The specific segment asked for could not be found. */\n        generateError(pContext, \"dump_terms\", \"segment not found\");\n      }else{\n        /* No segments found. */\n        /* TODO(shess): It should be impossible to reach this.  This\n        ** case can only happen for an empty table, in which case\n        ** SQLite has no rows to call this function on.\n        */\n        sqlite3_result_null(pContext);\n      }\n    }\n    sqlite3Fts2HashClear(&terms);\n  }\n}\n\n/* Expand the DL_DEFAULT doclist in pData into a text result in\n** pContext.\n*/\nstatic void createDoclistResult(sqlite3_context *pContext,\n                                const char *pData, int nData){\n  DataBuffer dump;\n  DLReader dlReader;\n\n  assert( pData!=NULL && nData>0 );\n\n  dataBufferInit(&dump, 0);\n  dlrInit(&dlReader, DL_DEFAULT, pData, nData);\n  for( ; !dlrAtEnd(&dlReader); dlrStep(&dlReader) ){\n    char buf[256];\n    PLReader plReader;\n\n    plrInit(&plReader, &dlReader);\n    if( DL_DEFAULT==DL_DOCIDS || plrAtEnd(&plReader) ){\n      sqlite3_snprintf(sizeof(buf), buf, \"[%lld] \", dlrDocid(&dlReader));\n      dataBufferAppend(&dump, buf, strlen(buf));\n    }else{\n      int iColumn = plrColumn(&plReader);\n\n      sqlite3_snprintf(sizeof(buf), buf, \"[%lld %d[\",\n                       dlrDocid(&dlReader), iColumn);\n      dataBufferAppend(&dump, buf, strlen(buf));\n\n      for( ; !plrAtEnd(&plReader); plrStep(&plReader) ){\n        if( plrColumn(&plReader)!=iColumn ){\n          iColumn = plrColumn(&plReader);\n          sqlite3_snprintf(sizeof(buf), buf, \"] %d[\", iColumn);\n          assert( dump.nData>0 );\n          dump.nData--;                     /* Overwrite trailing space. */\n          assert( dump.pData[dump.nData]==' ');\n          dataBufferAppend(&dump, buf, strlen(buf));\n        }\n        if( DL_DEFAULT==DL_POSITIONS_OFFSETS ){\n          sqlite3_snprintf(sizeof(buf), buf, \"%d,%d,%d \",\n                           plrPosition(&plReader),\n                           plrStartOffset(&plReader), plrEndOffset(&plReader));\n        }else if( DL_DEFAULT==DL_POSITIONS ){\n          sqlite3_snprintf(sizeof(buf), buf, \"%d \", plrPosition(&plReader));\n        }else{\n          assert( NULL==\"Unhandled DL_DEFAULT value\");\n        }\n        dataBufferAppend(&dump, buf, strlen(buf));\n      }\n      plrDestroy(&plReader);\n\n      assert( dump.nData>0 );\n      dump.nData--;                     /* Overwrite trailing space. */\n      assert( dump.pData[dump.nData]==' ');\n      dataBufferAppend(&dump, \"]] \", 3);\n    }\n  }\n  dlrDestroy(&dlReader);\n\n  assert( dump.nData>0 );\n  dump.nData--;                     /* Overwrite trailing space. */\n  assert( dump.pData[dump.nData]==' ');\n  dump.pData[dump.nData] = '\\0';\n  assert( dump.nData>0 );\n\n  /* Passes ownership of dump's buffer to pContext. */\n  sqlite3_result_text(pContext, dump.pData, dump.nData, sqlite3_free);\n  dump.pData = NULL;\n  dump.nData = dump.nCapacity = 0;\n}\n\n/* Implements dump_doclist() for use in inspecting the fts2 index from\n** tests.  TEXT result containing a string representation of the\n** doclist for the indicated term.  dump_doclist(t, term, level, idx)\n** dumps the doclist for term from the segment specified by level, idx\n** (in %_segdir), while dump_doclist(t, term) dumps the logical\n** doclist for the term across all segments.  The per-segment doclist\n** can contain deletions, while the full-index doclist will not\n** (deletions are omitted).\n**\n** Result formats differ with the setting of DL_DEFAULTS.  Examples:\n**\n** DL_DOCIDS: [1] [3] [7]\n** DL_POSITIONS: [1 0[0 4] 1[17]] [3 1[5]]\n** DL_POSITIONS_OFFSETS: [1 0[0,0,3 4,23,26] 1[17,102,105]] [3 1[5,20,23]]\n**\n** In each case the number after the outer '[' is the docid.  In the\n** latter two cases, the number before the inner '[' is the column\n** associated with the values within.  For DL_POSITIONS the numbers\n** within are the positions, for DL_POSITIONS_OFFSETS they are the\n** position, the start offset, and the end offset.\n*/\nstatic void dumpDoclistFunc(\n  sqlite3_context *pContext,\n  int argc, sqlite3_value **argv\n){\n  fulltext_cursor *pCursor;\n  if( argc!=2 && argc!=4 ){\n    generateError(pContext, \"dump_doclist\", \"incorrect arguments\");\n  }else if( sqlite3_value_type(argv[0])!=SQLITE_BLOB ||\n            sqlite3_value_bytes(argv[0])!=sizeof(pCursor) ){\n    generateError(pContext, \"dump_doclist\", \"illegal first argument\");\n  }else if( sqlite3_value_text(argv[1])==NULL ||\n            sqlite3_value_text(argv[1])[0]=='\\0' ){\n    generateError(pContext, \"dump_doclist\", \"empty second argument\");\n  }else{\n    const char *pTerm = (const char *)sqlite3_value_text(argv[1]);\n    const int nTerm = strlen(pTerm);\n    fulltext_vtab *v;\n    int rc;\n    DataBuffer doclist;\n\n    memcpy(&pCursor, sqlite3_value_blob(argv[0]), sizeof(pCursor));\n    v = cursor_vtab(pCursor);\n\n    dataBufferInit(&doclist, 0);\n\n    /* termSelect() yields the same logical doclist that queries are\n    ** run against.\n    */\n    if( argc==2 ){\n      rc = termSelect(v, v->nColumn, pTerm, nTerm, 0, DL_DEFAULT, &doclist);\n    }else{\n      sqlite3_stmt *s = NULL;\n\n      /* Get our specific segment's information. */\n      rc = sql_get_statement(v, SEGDIR_SELECT_SEGMENT_STMT, &s);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_bind_int(s, 1, sqlite3_value_int(argv[2]));\n        if( rc==SQLITE_OK ){\n          rc = sqlite3_bind_int(s, 2, sqlite3_value_int(argv[3]));\n        }\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_step(s);\n\n        if( rc==SQLITE_DONE ){\n          dataBufferDestroy(&doclist);\n          generateError(pContext, \"dump_doclist\", \"segment not found\");\n          return;\n        }\n\n        /* Found a segment, load it into doclist. */\n        if( rc==SQLITE_ROW ){\n          const sqlite_int64 iLeavesEnd = sqlite3_column_int64(s, 1);\n          const char *pData = sqlite3_column_blob(s, 2);\n          const int nData = sqlite3_column_bytes(s, 2);\n\n          /* loadSegment() is used by termSelect() to load each\n          ** segment's data.\n          */\n          rc = loadSegment(v, pData, nData, iLeavesEnd, pTerm, nTerm, 0,\n                           &doclist);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3_step(s);\n\n            /* Should not have more than one matching segment. */\n            if( rc!=SQLITE_DONE ){\n              sqlite3_reset(s);\n              dataBufferDestroy(&doclist);\n              generateError(pContext, \"dump_doclist\", \"invalid segdir\");\n              return;\n            }\n            rc = SQLITE_OK;\n          }\n        }\n      }\n\n      sqlite3_reset(s);\n    }\n\n    if( rc==SQLITE_OK ){\n      if( doclist.nData>0 ){\n        createDoclistResult(pContext, doclist.pData, doclist.nData);\n      }else{\n        /* TODO(shess): This can happen if the term is not present, or\n        ** if all instances of the term have been deleted and this is\n        ** an all-index dump.  It may be interesting to distinguish\n        ** these cases.\n        */\n        sqlite3_result_text(pContext, \"\", 0, SQLITE_STATIC);\n      }\n    }else if( rc==SQLITE_NOMEM ){\n      /* Handle out-of-memory cases specially because if they are\n      ** generated in fts2 code they may not be reflected in the db\n      ** handle.\n      */\n      /* TODO(shess): Handle this more comprehensively.\n      ** sqlite3ErrStr() has what I need, but is internal.\n      */\n      generateError(pContext, \"dump_doclist\", \"out of memory\");\n    }else{\n      generateError(pContext, \"dump_doclist\", NULL);\n    }\n\n    dataBufferDestroy(&doclist);\n  }\n}\n#endif\n\n/*\n** This routine implements the xFindFunction method for the FTS2\n** virtual table.\n*/\nstatic int fulltextFindFunction(\n  sqlite3_vtab *pVtab,\n  int nArg,\n  const char *zName,\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n  void **ppArg\n){\n  if( strcmp(zName,\"snippet\")==0 ){\n    *pxFunc = snippetFunc;\n    return 1;\n  }else if( strcmp(zName,\"offsets\")==0 ){\n    *pxFunc = snippetOffsetsFunc;\n    return 1;\n  }else if( strcmp(zName,\"optimize\")==0 ){\n    *pxFunc = optimizeFunc;\n    return 1;\n#ifdef SQLITE_TEST\n    /* NOTE(shess): These functions are present only for testing\n    ** purposes.  No particular effort is made to optimize their\n    ** execution or how they build their results.\n    */\n  }else if( strcmp(zName,\"dump_terms\")==0 ){\n    /* fprintf(stderr, \"Found dump_terms\\n\"); */\n    *pxFunc = dumpTermsFunc;\n    return 1;\n  }else if( strcmp(zName,\"dump_doclist\")==0 ){\n    /* fprintf(stderr, \"Found dump_doclist\\n\"); */\n    *pxFunc = dumpDoclistFunc;\n    return 1;\n#endif\n  }\n  return 0;\n}\n\n/*\n** Rename an fts2 table.\n*/\nstatic int fulltextRename(\n  sqlite3_vtab *pVtab,\n  const char *zName\n){\n  fulltext_vtab *p = (fulltext_vtab *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\"\n    \"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';\"\n    \"ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';\"\n    , p->zDb, p->zName, zName \n    , p->zDb, p->zName, zName \n    , p->zDb, p->zName, zName\n  );\n  if( zSql ){\n    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\nstatic const sqlite3_module fts2Module = {\n  /* iVersion      */ 0,\n  /* xCreate       */ fulltextCreate,\n  /* xConnect      */ fulltextConnect,\n  /* xBestIndex    */ fulltextBestIndex,\n  /* xDisconnect   */ fulltextDisconnect,\n  /* xDestroy      */ fulltextDestroy,\n  /* xOpen         */ fulltextOpen,\n  /* xClose        */ fulltextClose,\n  /* xFilter       */ fulltextFilter,\n  /* xNext         */ fulltextNext,\n  /* xEof          */ fulltextEof,\n  /* xColumn       */ fulltextColumn,\n  /* xRowid        */ fulltextRowid,\n  /* xUpdate       */ fulltextUpdate,\n  /* xBegin        */ fulltextBegin,\n  /* xSync         */ fulltextSync,\n  /* xCommit       */ fulltextCommit,\n  /* xRollback     */ fulltextRollback,\n  /* xFindFunction */ fulltextFindFunction,\n  /* xRename */       fulltextRename,\n};\n\nstatic void hashDestroy(void *p){\n  fts2Hash *pHash = (fts2Hash *)p;\n  sqlite3Fts2HashClear(pHash);\n  sqlite3_free(pHash);\n}\n\n/*\n** The fts2 built-in tokenizers - \"simple\" and \"porter\" - are implemented\n** in files fts2_tokenizer1.c and fts2_porter.c respectively. The following\n** two forward declarations are for functions declared in these files\n** used to retrieve the respective implementations.\n**\n** Calling sqlite3Fts2SimpleTokenizerModule() sets the value pointed\n** to by the argument to point a the \"simple\" tokenizer implementation.\n** Function ...PorterTokenizerModule() sets *pModule to point to the\n** porter tokenizer/stemmer implementation.\n*/\nvoid sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nvoid sqlite3Fts2PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nvoid sqlite3Fts2IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\nint sqlite3Fts2InitHashTable(sqlite3 *, fts2Hash *, const char *);\n\n/*\n** Initialize the fts2 extension. If this extension is built as part\n** of the sqlite library, then this function is called directly by\n** SQLite. If fts2 is built as a dynamically loadable extension, this\n** function is called by the sqlite3_extension_init() entry point.\n*/\nint sqlite3Fts2Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  fts2Hash *pHash = 0;\n  const sqlite3_tokenizer_module *pSimple = 0;\n  const sqlite3_tokenizer_module *pPorter = 0;\n  const sqlite3_tokenizer_module *pIcu = 0;\n\n  sqlite3Fts2SimpleTokenizerModule(&pSimple);\n  sqlite3Fts2PorterTokenizerModule(&pPorter);\n#ifdef SQLITE_ENABLE_ICU\n  sqlite3Fts2IcuTokenizerModule(&pIcu);\n#endif\n\n  /* Allocate and initialize the hash-table used to store tokenizers. */\n  pHash = sqlite3_malloc(sizeof(fts2Hash));\n  if( !pHash ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1);\n  }\n\n  /* Load the built-in tokenizers into the hash table */\n  if( rc==SQLITE_OK ){\n    if( sqlite3Fts2HashInsert(pHash, \"simple\", 7, (void *)pSimple)\n     || sqlite3Fts2HashInsert(pHash, \"porter\", 7, (void *)pPorter) \n     || (pIcu && sqlite3Fts2HashInsert(pHash, \"icu\", 4, (void *)pIcu))\n    ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  /* Create the virtual table wrapper around the hash-table and overload \n  ** the two scalar functions. If this is successful, register the\n  ** module with sqlite.\n  */\n  if( SQLITE_OK==rc \n   && SQLITE_OK==(rc = sqlite3Fts2InitHashTable(db, pHash, \"fts2_tokenizer\"))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"snippet\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"offsets\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"optimize\", -1))\n#ifdef SQLITE_TEST\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"dump_terms\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"dump_doclist\", -1))\n#endif\n  ){\n    return sqlite3_create_module_v2(\n        db, \"fts2\", &fts2Module, (void *)pHash, hashDestroy\n    );\n  }\n\n  /* An error has occurred. Delete the hash table and return the error code. */\n  assert( rc!=SQLITE_OK );\n  if( pHash ){\n    sqlite3Fts2HashClear(pHash);\n    sqlite3_free(pHash);\n  }\n  return rc;\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fts2_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts2Init(db);\n}\n#endif\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2.h",
    "content": "/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** FTS2 library.  All it does is declare the sqlite3Fts2Init() interface.\n*/\n#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint sqlite3Fts2Init(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_hash.c",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS2 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS2 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS2 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n\n#include <assert.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT3\n#include \"fts2_hash.h\"\n\n/*\n** Malloc and Free functions\n*/\nstatic void *fts2HashMalloc(int n){\n  void *p = sqlite3_malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\nstatic void fts2HashFree(void *p){\n  sqlite3_free(p);\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS2_HASH_BINARY or FTS2_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nvoid sqlite3Fts2HashInit(fts2Hash *pNew, int keyClass, int copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS2_HASH_STRING && keyClass<=FTS2_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nvoid sqlite3Fts2HashClear(fts2Hash *pH){\n  fts2HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  fts2HashFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    fts2HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      fts2HashFree(elem->pKey);\n    }\n    fts2HashFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS2_HASH_STRING\n*/\nstatic int strHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  int h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return h & 0x7fffffff;\n}\nstatic int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS2_HASH_BINARY\n*/\nstatic int binHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"hashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of hashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of hashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*hashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS2_HASH_STRING ){\n    return &strHash;\n  }else{\n    assert( keyClass==FTS2_HASH_BINARY );\n    return &binHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*compareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS2_HASH_STRING ){\n    return &strCompare;\n  }else{\n    assert( keyClass==FTS2_HASH_BINARY );\n    return &binCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void insertElement(\n  fts2Hash *pH,            /* The complete hash table */\n  struct _fts2ht *pEntry,  /* The entry into which pNew is inserted */\n  fts2HashElem *pNew       /* The element to be inserted */\n){\n  fts2HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n*/\nstatic void rehash(fts2Hash *pH, int new_size){\n  struct _fts2ht *new_ht;          /* The new hash table */\n  fts2HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts2ht *)fts2HashMalloc( new_size*sizeof(struct _fts2ht) );\n  if( new_ht==0 ) return;\n  fts2HashFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = hashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic fts2HashElem *findElementGivenHash(\n  const fts2Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  fts2HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts2ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = compareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  fts2Hash *pH,         /* The pH containing \"elem\" */\n  fts2HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts2ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    fts2HashFree(elem->pKey);\n  }\n  fts2HashFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts2HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nvoid *sqlite3Fts2HashFind(const fts2Hash *pH, const void *pKey, int nKey){\n  int h;                 /* A hash on key */\n  fts2HashElem *elem;    /* The element that matches key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1));\n  return elem ? elem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nvoid *sqlite3Fts2HashInsert(\n  fts2Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  fts2HashElem *elem;       /* Used to loop thru the element list */\n  fts2HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = hashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = findElementGivenHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (fts2HashElem*)fts2HashMalloc( sizeof(fts2HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = fts2HashMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      fts2HashFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  if( pH->htsize==0 ){\n    rehash(pH,8);\n    if( pH->htsize==0 ){\n      pH->count = 0;\n      fts2HashFree(new_elem);\n      return data;\n    }\n  }\n  if( pH->count > pH->htsize ){\n    rehash(pH,pH->htsize*2);\n  }\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  insertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_hash.h",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS2_HASH_H_\n#define _FTS2_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct fts2Hash fts2Hash;\ntypedef struct fts2HashElem fts2HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct fts2Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  fts2HashElem *first;    /* The first element of the array */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts2ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    fts2HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct fts2HashElem {\n  fts2HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS2_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS2_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts2HashInit is 1.  \n*/\n#define FTS2_HASH_STRING    1\n#define FTS2_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nvoid sqlite3Fts2HashInit(fts2Hash*, int keytype, int copyKey);\nvoid *sqlite3Fts2HashInsert(fts2Hash*, const void *pKey, int nKey, void *pData);\nvoid *sqlite3Fts2HashFind(const fts2Hash*, const void *pKey, int nKey);\nvoid sqlite3Fts2HashClear(fts2Hash*);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts2HashInit   sqlite3Fts2HashInit\n#define fts2HashInsert sqlite3Fts2HashInsert\n#define fts2HashFind   sqlite3Fts2HashFind\n#define fts2HashClear  sqlite3Fts2HashClear\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   fts2Hash h;\n**   fts2HashElem *p;\n**   ...\n**   for(p=fts2HashFirst(&h); p; p=fts2HashNext(p)){\n**     SomeStructure *pData = fts2HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts2HashFirst(H)  ((H)->first)\n#define fts2HashNext(E)   ((E)->next)\n#define fts2HashData(E)   ((E)->data)\n#define fts2HashKey(E)    ((E)->pKey)\n#define fts2HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts2HashCount(H)  ((H)->count)\n\n#endif /* _FTS2_HASH_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_icu.c",
    "content": "/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a tokenizer for fts2 based on the ICU library.\n** \n** $Id: fts2_icu.c,v 1.3 2008/12/18 05:30:26 danielk1977 Exp $\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n#ifdef SQLITE_ENABLE_ICU\n\n#include <assert.h>\n#include <string.h>\n#include \"fts2_tokenizer.h\"\n\n#include <unicode/ubrk.h>\n#include <unicode/ucol.h>\n#include <unicode/ustring.h>\n#include <unicode/utf16.h>\n\ntypedef struct IcuTokenizer IcuTokenizer;\ntypedef struct IcuCursor IcuCursor;\n\nstruct IcuTokenizer {\n  sqlite3_tokenizer base;\n  char *zLocale;\n};\n\nstruct IcuCursor {\n  sqlite3_tokenizer_cursor base;\n\n  UBreakIterator *pIter;      /* ICU break-iterator object */\n  int nChar;                  /* Number of UChar elements in pInput */\n  UChar *aChar;               /* Copy of input using utf-16 encoding */\n  int *aOffset;               /* Offsets of each character in utf-8 input */\n\n  int nBuffer;\n  char *zBuffer;\n\n  int iToken;\n};\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int icuCreate(\n  int argc,                            /* Number of entries in argv[] */\n  const char * const *argv,            /* Tokenizer creation arguments */\n  sqlite3_tokenizer **ppTokenizer      /* OUT: Created tokenizer */\n){\n  IcuTokenizer *p;\n  int n = 0;\n\n  if( argc>0 ){\n    n = strlen(argv[0])+1;\n  }\n  p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(IcuTokenizer));\n\n  if( n ){\n    p->zLocale = (char *)&p[1];\n    memcpy(p->zLocale, argv[0], n);\n  }\n\n  *ppTokenizer = (sqlite3_tokenizer *)p;\n\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int icuDestroy(sqlite3_tokenizer *pTokenizer){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int icuOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput,                    /* Input string */\n  int nInput,                            /* Length of zInput in bytes */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  IcuCursor *pCsr;\n\n  const int32_t opt = U_FOLD_CASE_DEFAULT;\n  UErrorCode status = U_ZERO_ERROR;\n  int nChar;\n\n  UChar32 c;\n  int iInput = 0;\n  int iOut = 0;\n\n  *ppCursor = 0;\n\n  if( nInput<0 ){\n    nInput = strlen(zInput);\n  }\n  nChar = nInput+1;\n  pCsr = (IcuCursor *)sqlite3_malloc(\n      sizeof(IcuCursor) +                /* IcuCursor */\n      ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */\n      (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */\n  );\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(IcuCursor));\n  pCsr->aChar = (UChar *)&pCsr[1];\n  pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];\n\n  pCsr->aOffset[iOut] = iInput;\n  U8_NEXT(zInput, iInput, nInput, c); \n  while( c>0 ){\n    int isError = 0;\n    c = u_foldCase(c, opt);\n    U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);\n    if( isError ){\n      sqlite3_free(pCsr);\n      return SQLITE_ERROR;\n    }\n    pCsr->aOffset[iOut] = iInput;\n\n    if( iInput<nInput ){\n      U8_NEXT(zInput, iInput, nInput, c);\n    }else{\n      c = 0;\n    }\n  }\n\n  pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);\n  if( !U_SUCCESS(status) ){\n    sqlite3_free(pCsr);\n    return SQLITE_ERROR;\n  }\n  pCsr->nChar = iOut;\n\n  ubrk_first(pCsr->pIter);\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to icuOpen().\n*/\nstatic int icuClose(sqlite3_tokenizer_cursor *pCursor){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n  ubrk_close(pCsr->pIter);\n  sqlite3_free(pCsr->zBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.\n*/\nstatic int icuNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n\n  int iStart = 0;\n  int iEnd = 0;\n  int nByte = 0;\n\n  while( iStart==iEnd ){\n    UChar32 c;\n\n    iStart = ubrk_current(pCsr->pIter);\n    iEnd = ubrk_next(pCsr->pIter);\n    if( iEnd==UBRK_DONE ){\n      return SQLITE_DONE;\n    }\n\n    while( iStart<iEnd ){\n      int iWhite = iStart;\n      U8_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);\n      if( u_isspace(c) ){\n        iStart = iWhite;\n      }else{\n        break;\n      }\n    }\n    assert(iStart<=iEnd);\n  }\n\n  do {\n    UErrorCode status = U_ZERO_ERROR;\n    if( nByte ){\n      char *zNew = sqlite3_realloc(pCsr->zBuffer, nByte);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pCsr->zBuffer = zNew;\n      pCsr->nBuffer = nByte;\n    }\n\n    u_strToUTF8(\n        pCsr->zBuffer, pCsr->nBuffer, &nByte,    /* Output vars */\n        &pCsr->aChar[iStart], iEnd-iStart,       /* Input vars */\n        &status                                  /* Output success/failure */\n    );\n  } while( nByte>pCsr->nBuffer );\n\n  *ppToken = pCsr->zBuffer;\n  *pnBytes = nByte;\n  *piStartOffset = pCsr->aOffset[iStart];\n  *piEndOffset = pCsr->aOffset[iEnd];\n  *piPosition = pCsr->iToken++;\n\n  return SQLITE_OK;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module icuTokenizerModule = {\n  0,                           /* iVersion */\n  icuCreate,                   /* xCreate  */\n  icuDestroy,                  /* xCreate  */\n  icuOpen,                     /* xOpen    */\n  icuClose,                    /* xClose   */\n  icuNext,                     /* xNext    */\n};\n\n/*\n** Set *ppModule to point at the implementation of the ICU tokenizer.\n*/\nvoid sqlite3Fts2IcuTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &icuTokenizerModule;\n}\n\n#endif /* defined(SQLITE_ENABLE_ICU) */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_porter.c",
    "content": "/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS2 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS2 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS2 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT3\n#include \"fts2_tokenizer.h\"\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlit3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/* Forward declaration */\nstatic const sqlite3_tokenizer_module porterTokenizerModule;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n  t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->zToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1] && isConsonant(z+1);\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    z[0]!=0 && isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    z[1]!=0 && isVowel(z+1) &&\n    z[2]!=0 && isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    int c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j, c;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     stem(&z, \"lanoita\", \"ate\", m_gt_0) ||\n     stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     break;\n   case 'c':\n     stem(&z, \"icne\", \"ence\", m_gt_0) ||\n     stem(&z, \"icna\", \"ance\", m_gt_0);\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"ilb\", \"ble\", m_gt_0) ||\n     stem(&z, \"illa\", \"al\", m_gt_0) ||\n     stem(&z, \"iltne\", \"ent\", m_gt_0) ||\n     stem(&z, \"ile\", \"e\", m_gt_0) ||\n     stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     break;\n   case 'o':\n     stem(&z, \"noitazi\", \"ize\", m_gt_0) ||\n     stem(&z, \"noita\", \"ate\", m_gt_0) ||\n     stem(&z, \"rota\", \"ate\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"msila\", \"al\", m_gt_0) ||\n     stem(&z, \"ssenevi\", \"ive\", m_gt_0) ||\n     stem(&z, \"ssenluf\", \"ful\", m_gt_0) ||\n     stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     break;\n   case 't':\n     stem(&z, \"itila\", \"al\", m_gt_0) ||\n     stem(&z, \"itivi\", \"ive\", m_gt_0) ||\n     stem(&z, \"itilib\", \"ble\", m_gt_0);\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     stem(&z, \"etaci\", \"ic\", m_gt_0) ||\n     stem(&z, \"evita\", \"\", m_gt_0)   ||\n     stem(&z, \"ezila\", \"al\", m_gt_0);\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     stem(&z, \"laci\", \"ic\", m_gt_0) ||\n     stem(&z, \"luf\", \"\", m_gt_0);\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         stem(&z, \"tneme\", \"\", m_gt_1) ||\n         stem(&z, \"tnem\", \"\", m_gt_1) ||\n         stem(&z, \"tne\", \"\", m_gt_1);\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     stem(&z, \"eta\", \"\", m_gt_1) ||\n     stem(&z, \"iti\", \"\", m_gt_1);\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char porterIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !porterIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        c->nAllocated = n+20;\n        c->zToken = sqlite3_realloc(c->zToken, c->nAllocated);\n        if( c->zToken==NULL ) return SQLITE_NOMEM;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts2PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_tokenizer.c",
    "content": "/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is part of an SQLite module implementing full-text search.\n** This particular file implements the generic tokenizer interface.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS2 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS2 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS2 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n\n\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT3\n\n#include \"fts2_hash.h\"\n#include \"fts2_tokenizer.h\"\n#include <assert.h>\n\n/*\n** Implementation of the SQL scalar function for accessing the underlying \n** hash table. This function may be called as follows:\n**\n**   SELECT <function-name>(<key-name>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts2InitHashTable() function (e.g. 'fts2_tokenizer').\n**\n** If the <pointer> argument is specified, it must be a blob value\n** containing a pointer to be stored as the hash data corresponding\n** to the string <key-name>. If <pointer> is not specified, then\n** the string <key-name> must already exist in the has table. Otherwise,\n** an error is returned.\n**\n** Whether or not the <pointer> argument is specified, the value returned\n** is a blob containing the pointer stored as the hash data corresponding\n** to string <key-name> (after the hash-table is updated, if applicable).\n*/\nstatic void scalarFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  fts2Hash *pHash;\n  void *pPtr = 0;\n  const unsigned char *zName;\n  int nName;\n\n  assert( argc==1 || argc==2 );\n\n  pHash = (fts2Hash *)sqlite3_user_data(context);\n\n  zName = sqlite3_value_text(argv[0]);\n  nName = sqlite3_value_bytes(argv[0])+1;\n\n  if( argc==2 ){\n    void *pOld;\n    int n = sqlite3_value_bytes(argv[1]);\n    if( n!=sizeof(pPtr) ){\n      sqlite3_result_error(context, \"argument type mismatch\", -1);\n      return;\n    }\n    pPtr = *(void **)sqlite3_value_blob(argv[1]);\n    pOld = sqlite3Fts2HashInsert(pHash, (void *)zName, nName, pPtr);\n    if( pOld==pPtr ){\n      sqlite3_result_error(context, \"out of memory\", -1);\n      return;\n    }\n  }else{\n    pPtr = sqlite3Fts2HashFind(pHash, zName, nName);\n    if( !pPtr ){\n      char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n  }\n\n  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);\n}\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <string.h>\n\n/*\n** Implementation of a special SQL scalar function for testing tokenizers \n** designed to be used in concert with the Tcl testing framework. This\n** function must be called with two arguments:\n**\n**   SELECT <function-name>(<key-name>, <input-string>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts2InitHashTable() function (e.g. 'fts2_tokenizer')\n** concatenated with the string '_test' (e.g. 'fts2_tokenizer_test').\n**\n** The return value is a string that may be interpreted as a Tcl\n** list. For each token in the <input-string>, three elements are\n** added to the returned list. The first is the token position, the \n** second is the token text (folded, stemmed, etc.) and the third is the\n** substring of <input-string> associated with the token. For example, \n** using the built-in \"simple\" tokenizer:\n**\n**   SELECT fts_tokenizer_test('simple', 'I don't see how');\n**\n** will return the string:\n**\n**   \"{0 i I 1 dont don't 2 see see 3 how how}\"\n**   \n*/\nstatic void testFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  fts2Hash *pHash;\n  sqlite3_tokenizer_module *p;\n  sqlite3_tokenizer *pTokenizer = 0;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n\n  const char *zErr = 0;\n\n  const char *zName;\n  int nName;\n  const char *zInput;\n  int nInput;\n\n  const char *zArg = 0;\n\n  const char *zToken;\n  int nToken;\n  int iStart;\n  int iEnd;\n  int iPos;\n\n  Tcl_Obj *pRet;\n\n  assert( argc==2 || argc==3 );\n\n  nName = sqlite3_value_bytes(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[0]);\n  nInput = sqlite3_value_bytes(argv[argc-1]);\n  zInput = (const char *)sqlite3_value_text(argv[argc-1]);\n\n  if( argc==3 ){\n    zArg = (const char *)sqlite3_value_text(argv[1]);\n  }\n\n  pHash = (fts2Hash *)sqlite3_user_data(context);\n  p = (sqlite3_tokenizer_module *)sqlite3Fts2HashFind(pHash, zName, nName+1);\n\n  if( !p ){\n    char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  if( SQLITE_OK!=p->xCreate(zArg ? 1 : 0, &zArg, &pTokenizer) ){\n    zErr = \"error in xCreate()\";\n    goto finish;\n  }\n  pTokenizer->pModule = p;\n  if( SQLITE_OK!=p->xOpen(pTokenizer, zInput, nInput, &pCsr) ){\n    zErr = \"error in xOpen()\";\n    goto finish;\n  }\n  pCsr->pTokenizer = pTokenizer;\n\n  while( SQLITE_OK==p->xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos) ){\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(iPos));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n    zToken = &zInput[iStart];\n    nToken = iEnd-iStart;\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n  }\n\n  if( SQLITE_OK!=p->xClose(pCsr) ){\n    zErr = \"error in xClose()\";\n    goto finish;\n  }\n  if( SQLITE_OK!=p->xDestroy(pTokenizer) ){\n    zErr = \"error in xDestroy()\";\n    goto finish;\n  }\n\nfinish:\n  if( zErr ){\n    sqlite3_result_error(context, zErr, -1);\n  }else{\n    sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  }\n  Tcl_DecrRefCount(pRet);\n}\n\nstatic\nint registerTokenizer(\n  sqlite3 *db, \n  char *zName, \n  const sqlite3_tokenizer_module *p\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts2_tokenizer(?, ?)\";\n\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n  sqlite3_step(pStmt);\n\n  return sqlite3_finalize(pStmt);\n}\n\nstatic\nint queryFts2Tokenizer(\n  sqlite3 *db, \n  char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts2_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\nvoid sqlite3Fts2SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n/*\n** Implementation of the scalar function fts2_tokenizer_internal_test().\n** This function is used for testing only, it is not included in the\n** build unless SQLITE_TEST is defined.\n**\n** The purpose of this is to test that the fts2_tokenizer() function\n** can be used as designed by the C-code in the queryFts2Tokenizer and\n** registerTokenizer() functions above. These two functions are repeated\n** in the README.tokenizer file as an example, so it is important to\n** test them.\n**\n** To run the tests, evaluate the fts2_tokenizer_internal_test() scalar\n** function with no arguments. An assert() will fail if a problem is\n** detected. i.e.:\n**\n**     SELECT fts2_tokenizer_internal_test();\n**\n*/\nstatic void intTestFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc;\n  const sqlite3_tokenizer_module *p1;\n  const sqlite3_tokenizer_module *p2;\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);\n\n  /* Test the query function */\n  sqlite3Fts2SimpleTokenizerModule(&p1);\n  rc = queryFts2Tokenizer(db, \"simple\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p1==p2 );\n  rc = queryFts2Tokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_ERROR );\n  assert( p2==0 );\n  assert( 0==strcmp(sqlite3_errmsg(db), \"unknown tokenizer: nosuchtokenizer\") );\n\n  /* Test the storage function */\n  rc = registerTokenizer(db, \"nosuchtokenizer\", p1);\n  assert( rc==SQLITE_OK );\n  rc = queryFts2Tokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p2==p1 );\n\n  sqlite3_result_text(context, \"ok\", -1, SQLITE_STATIC);\n}\n\n#endif\n\n/*\n** Set up SQL objects in database db used to access the contents of\n** the hash table pointed to by argument pHash. The hash table must\n** been initialized to use string keys, and to take a private copy \n** of the key when a value is inserted. i.e. by a call similar to:\n**\n**    sqlite3Fts2HashInit(pHash, FTS2_HASH_STRING, 1);\n**\n** This function adds a scalar function (see header comment above\n** scalarFunc() in this file for details) and, if ENABLE_TABLE is\n** defined at compilation time, a temporary virtual table (see header \n** comment above struct HashTableVtab) to the database schema. Both \n** provide read/write access to the contents of *pHash.\n**\n** The third argument to this function, zName, is used as the name\n** of both the scalar and, if created, the virtual table.\n*/\nint sqlite3Fts2InitHashTable(\n  sqlite3 *db, \n  fts2Hash *pHash, \n  const char *zName\n){\n  int rc = SQLITE_OK;\n  void *p = (void *)pHash;\n  const int any = SQLITE_ANY;\n  char *zTest = 0;\n  char *zTest2 = 0;\n\n#ifdef SQLITE_TEST\n  void *pdb = (void *)db;\n  zTest = sqlite3_mprintf(\"%s_test\", zName);\n  zTest2 = sqlite3_mprintf(\"%s_internal_test\", zName);\n  if( !zTest || !zTest2 ){\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( rc!=SQLITE_OK\n   || (rc = sqlite3_create_function(db, zName, 1, any, p, scalarFunc, 0, 0))\n   || (rc = sqlite3_create_function(db, zName, 2, any, p, scalarFunc, 0, 0))\n#ifdef SQLITE_TEST\n   || (rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))\n   || (rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))\n   || (rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))\n#endif\n  );\n\n  sqlite3_free(zTest);\n  sqlite3_free(zTest2);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_tokenizer.h",
    "content": "/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS2_TOKENIZER_H_\n#define _FTS2_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts2 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts2 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts2 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts2( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialized by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts2 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts2 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\n#endif /* _FTS2_TOKENIZER_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/fts2_tokenizer1.c",
    "content": "/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS2 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS2 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS2 is defined).\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2)\n\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"sqlite3.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT3\n#include \"fts2_tokenizer.h\"\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\n/* Forward declaration */\nstatic const sqlite3_tokenizer_module simpleTokenizerModule;\n\nstatic int simpleDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        sqlite3_free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !((i>='0' && i<='9') || (i>='A' && i<='Z') ||\n                      (i>='a' && i<='z'));\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->pToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        c->nTokenAllocated = n+20;\n        c->pToken = sqlite3_realloc(c->pToken, c->nTokenAllocated);\n        if( c->pToken==NULL ) return SQLITE_NOMEM;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = (ch>='A' && ch<='Z') ? (ch - 'A' + 'a') : ch;\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts2SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS2) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts2/mkfts2amal.tcl",
    "content": "#!/usr/bin/tclsh\n#\n# This script builds a single C code file holding all of FTS2 code.\n# The name of the output file is fts2amal.c.  To build this file,\n# first do:\n#\n#      make target_source\n#\n# The make target above moves all of the source code files into\n# a subdirectory named \"tsrc\".  (This script expects to find the files\n# there and will not work if they are not found.)\n#\n# After the \"tsrc\" directory has been created and populated, run\n# this script:\n#\n#      tclsh mkfts2amal.tcl\n#\n# The amalgamated FTS2 code will be written into fts2amal.c\n#\n\n# Open the output file and write a header comment at the beginning\n# of the file.\n#\nset out [open fts2amal.c w]\nset today [clock format [clock seconds] -format \"%Y-%m-%d %H:%M:%S UTC\" -gmt 1]\nputs $out [subst \\\n{/******************************************************************************\n** This file is an amalgamation of separate C source files from the SQLite\n** Full Text Search extension 2 (fts2).  By combining all the individual C \n** code  files into this single large file, the entire code can be compiled \n** as a one translation unit.  This allows many compilers to do optimizations\n** that would not be possible if the files were compiled separately.  It also\n** makes the code easier to import into other projects.\n**\n** This amalgamation was generated on $today.\n*/}]\n\n# These are the header files used by FTS2.  The first time any of these \n# files are seen in a #include statement in the C code, include the complete\n# text of the file in-line.  The file only needs to be included once.\n#\nforeach hdr {\n   fts2.h\n   fts2_hash.h\n   fts2_tokenizer.h\n   sqlite3.h\n   sqlite3ext.h\n} {\n  set available_hdr($hdr) 1\n}\n\n# 78 stars used for comment formatting.\nset s78 \\\n{*****************************************************************************}\n\n# Insert a comment into the code\n#\nproc section_comment {text} {\n  global out s78\n  set n [string length $text]\n  set nstar [expr {60 - $n}]\n  set stars [string range $s78 0 $nstar]\n  puts $out \"/************** $text $stars/\"\n}\n\n# Read the source file named $filename and write it into the\n# sqlite3.c output file.  If any #include statements are seen,\n# process them approprately.\n#\nproc copy_file {filename} {\n  global seen_hdr available_hdr out\n  set tail [file tail $filename]\n  section_comment \"Begin file $tail\"\n  set in [open $filename r]\n  while {![eof $in]} {\n    set line [gets $in]\n    if {[regexp {^#\\s*include\\s+[\"<]([^\">]+)[\">]} $line all hdr]} {\n      if {[info exists available_hdr($hdr)]} {\n        if {$available_hdr($hdr)} {\n          section_comment \"Include $hdr in the middle of $tail\"\n          copy_file tsrc/$hdr\n          section_comment \"Continuing where we left off in $tail\"\n        }\n      } elseif {![info exists seen_hdr($hdr)]} {\n        set seen_hdr($hdr) 1\n        puts $out $line\n      }\n    } elseif {[regexp {^#ifdef __cplusplus} $line]} {\n      puts $out \"#if 0\"\n    } elseif {[regexp {^#line} $line]} {\n      # Skip #line directives.\n    } else {\n      puts $out $line\n    }\n  }\n  close $in\n  section_comment \"End of $tail\"\n}\n\n\n# Process the source files.  Process files containing commonly\n# used subroutines first in order to help the compiler find\n# inlining opportunities.\n#\nforeach file {\n   fts2.c\n   fts2_hash.c\n   fts2_porter.c\n   fts2_tokenizer.c\n   fts2_tokenizer1.c\n   fts2_icu.c\n} {\n  copy_file tsrc/$file\n}\n\nclose $out\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/README.content",
    "content": "\nFTS4 CONTENT OPTION\n\n  Normally, in order to create a full-text index on a dataset, the FTS4 \n  module stores a copy of all indexed documents in a specially created \n  database table.\n\n  As of SQLite version 3.7.9, FTS4 supports a new option - \"content\" -\n  designed to extend FTS4 to support the creation of full-text indexes where:\n\n    * The indexed documents are not stored within the SQLite database \n      at all (a \"contentless\" FTS4 table), or\n\n    * The indexed documents are stored in a database table created and\n      managed by the user (an \"external content\" FTS4 table).\n\n  Because the indexed documents themselves are usually much larger than \n  the full-text index, the content option can sometimes be used to achieve \n  significant space savings.\n\nCONTENTLESS FTS4 TABLES\n\n  In order to create an FTS4 table that does not store a copy of the indexed\n  documents at all, the content option should be set to an empty string.\n  For example, the following SQL creates such an FTS4 table with three\n  columns - \"a\", \"b\", and \"c\":\n\n    CREATE VIRTUAL TABLE t1 USING fts4(content=\"\", a, b, c);\n\n  Data can be inserted into such an FTS4 table using an INSERT statements.\n  However, unlike ordinary FTS4 tables, the user must supply an explicit\n  integer docid value. For example:\n\n    -- This statement is Ok:\n    INSERT INTO t1(docid, a, b, c) VALUES(1, 'a b c', 'd e f', 'g h i');\n\n    -- This statement causes an error, as no docid value has been provided:\n    INSERT INTO t1(a, b, c) VALUES('j k l', 'm n o', 'p q r');\n\n  It is not possible to UPDATE or DELETE a row stored in a contentless FTS4\n  table. Attempting to do so is an error.\n\n  Contentless FTS4 tables also support SELECT statements. However, it is\n  an error to attempt to retrieve the value of any table column other than\n  the docid column. The auxiliary function matchinfo() may be used, but\n  snippet() and offsets() may not. For example:\n\n    -- The following statements are Ok:\n    SELECT docid FROM t1 WHERE t1 MATCH 'xxx';\n    SELECT docid FROM t1 WHERE a MATCH 'xxx';\n    SELECT matchinfo(t1) FROM t1 WHERE t1 MATCH 'xxx';\n\n    -- The following statements all cause errors, as the value of columns\n    -- other than docid are required to evaluate them.\n    SELECT * FROM t1;\n    SELECT a, b FROM t1 WHERE t1 MATCH 'xxx';\n    SELECT docid FROM t1 WHERE a LIKE 'xxx%';\n    SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'xxx';\n\n  Errors related to attempting to retrieve column values other than docid\n  are runtime errors that occur within sqlite3_step(). In some cases, for\n  example if the MATCH expression in a SELECT query matches zero rows, there\n  may be no error at all even if a statement does refer to column values \n  other than docid.\n\nEXTERNAL CONTENT FTS4 TABLES\n\n  An \"external content\" FTS4 table is similar to a contentless table, except\n  that if evaluation of a query requires the value of a column other than \n  docid, FTS4 attempts to retrieve that value from a table (or view, or \n  virtual table) nominated by the user (hereafter referred to as the \"content\n  table\"). The FTS4 module never writes to the content table, and writing\n  to the content table does not affect the full-text index. It is the\n  responsibility of the user to ensure that the content table and the \n  full-text index are consistent.\n\n  An external content FTS4 table is created by setting the content option\n  to the name of a table (or view, or virtual table) that may be queried by\n  FTS4 to retrieve column values when required. If the nominated table does\n  not exist, then an external content table behaves in the same way as\n  a contentless table. For example:\n\n    CREATE TABLE t2(id INTEGER PRIMARY KEY, a, b, c);\n    CREATE VIRTUAL TABLE t3 USING fts4(content=\"t2\", a, c);\n\n  Assuming the nominated table does exist, then its columns must be the same \n  as or a superset of those defined for the FTS table.\n\n  When a users query on the FTS table requires a column value other than\n  docid, FTS attempts to read this value from the corresponding column of\n  the row in the content table with a rowid value equal to the current FTS\n  docid. Or, if such a row cannot be found in the content table, a NULL\n  value is used instead. For example:\n\n    CREATE TABLE t2(id INTEGER PRIMARY KEY, a, b, c, d);\n    CREATE VIRTUAL TABLE t3 USING fts4(content=\"t2\", b, c);\n  \n    INSERT INTO t2 VALUES(2, 'a b', 'c d', 'e f');\n    INSERT INTO t2 VALUES(3, 'g h', 'i j', 'k l');\n    INSERT INTO t3(docid, b, c) SELECT id, b, c FROM t2;\n\n    -- The following query returns a single row with two columns containing\n    -- the text values \"i j\" and \"k l\".\n    --\n    -- The query uses the full-text index to discover that the MATCH \n    -- term matches the row with docid=3. It then retrieves the values\n    -- of columns b and c from the row with rowid=3 in the content table\n    -- to return.\n    --\n    SELECT * FROM t3 WHERE t3 MATCH 'k';\n\n    -- Following the UPDATE, the query still returns a single row, this\n    -- time containing the text values \"xxx\" and \"yyy\". This is because the\n    -- full-text index still indicates that the row with docid=3 matches\n    -- the FTS4 query 'k', even though the documents stored in the content\n    -- table have been modified.\n    --\n    UPDATE t2 SET b = 'xxx', c = 'yyy' WHERE rowid = 3;\n    SELECT * FROM t3 WHERE t3 MATCH 'k';\n\n    -- Following the DELETE below, the query returns one row containing two\n    -- NULL values. NULL values are returned because FTS is unable to find\n    -- a row with rowid=3 within the content table.\n    --\n    DELETE FROM t2;\n    SELECT * FROM t3 WHERE t3 MATCH 'k';\n\n  When a row is deleted from an external content FTS4 table, FTS4 needs to\n  retrieve the column values of the row being deleted from the content table.\n  This is so that FTS4 can update the full-text index entries for each token\n  that occurs within the deleted row to indicate that that row has been \n  deleted. If the content table row cannot be found, or if it contains values\n  inconsistent with the contents of the FTS index, the results can be difficult\n  to predict. The FTS index may be left containing entries corresponding to the\n  deleted row, which can lead to seemingly nonsensical results being returned\n  by subsequent SELECT queries. The same applies when a row is updated, as\n  internally an UPDATE is the same as a DELETE followed by an INSERT.\n  \n  Instead of writing separately to the full-text index and the content table,\n  some users may wish to use database triggers to keep the full-text index\n  up to date with respect to the set of documents stored in the content table.\n  For example, using the tables from earlier examples:\n\n    CREATE TRIGGER t2_bu BEFORE UPDATE ON t2 BEGIN\n      DELETE FROM t3 WHERE docid=old.rowid;\n    END;\n    CREATE TRIGGER t2_bd BEFORE DELETE ON t2 BEGIN\n      DELETE FROM t3 WHERE docid=old.rowid;\n    END;\n\n    CREATE TRIGGER t2_bu AFTER UPDATE ON t2 BEGIN\n      INSERT INTO t3(docid, b, c) VALUES(new.rowid, new.b, new.c);\n    END;\n    CREATE TRIGGER t2_bd AFTER INSERT ON t2 BEGIN\n      INSERT INTO t3(docid, b, c) VALUES(new.rowid, new.b, new.c);\n    END;\n\n  The DELETE trigger must be fired before the actual delete takes place\n  on the content table. This is so that FTS4 can still retrieve the original\n  values in order to update the full-text index. And the INSERT trigger must\n  be fired after the new row is inserted, so as to handle the case where the\n  rowid is assigned automatically within the system. The UPDATE trigger must\n  be split into two parts, one fired before and one after the update of the\n  content table, for the same reasons.\n\n  FTS4 features a special command similar to the 'optimize' command that\n  deletes the entire full-text index and rebuilds it based on the current\n  set of documents in the content table. Assuming again that \"t3\" is the\n  name of the external content FTS4 table, the command is:\n\n    INSERT INTO t3(t3) VALUES('rebuild');\n\n  This command may also be used with ordinary FTS4 tables, although it may\n  only be useful if the full-text index has somehow become corrupt. It is an\n  error to attempt to rebuild the full-text index maintained by a contentless\n  FTS4 table.\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/README.syntax",
    "content": "\n1. OVERVIEW\n\n  This README file describes the syntax of the arguments that may be passed to\n  the FTS3 MATCH operator used for full-text queries. For example, if table \n  \"t1\" is an Fts3 virtual table, the following SQL query:\n\n    SELECT * FROM t1 WHERE <col> MATCH <full-text query>\n\n  may be used to retrieve all rows that match a specified for full-text query. \n  The text \"<col>\" should be replaced by either the name of the fts3 table \n  (in this case \"t1\"), or by the name of one of the columns of the fts3 \n  table. <full-text-query> should be replaced by an SQL expression that \n  computes to a string containing an Fts3 query.\n\n  If the left-hand-side of the MATCH operator is set to the name of the\n  fts3 table, then by default the query may be matched against any column\n  of the table. If it is set to a column name, then by default the query\n  may only match the specified column. In both cases this may be overriden\n  as part of the query text (see sections 2 and 3 below).\n\n  As of SQLite version 3.6.8, Fts3 supports two slightly different query \n  formats; the standard syntax, which is used by default, and the enhanced\n  query syntax which can be selected by compiling with the pre-processor\n  symbol SQLITE_ENABLE_FTS3_PARENTHESIS defined.\n\n    -DSQLITE_ENABLE_FTS3_PARENTHESIS\n\n2. STANDARD QUERY SYNTAX\n\n  When using the standard Fts3 query syntax, a query usually consists of a \n  list of terms (words) separated by white-space characters. To match a\n  query, a row (or column) of an Fts3 table must contain each of the specified\n  terms. For example, the following query:\n\n    <col> MATCH 'hello world'\n\n  matches rows (or columns, if <col> is the name of a column name) that \n  contain at least one instance of the token \"hello\", and at least one \n  instance of the token \"world\". Tokens may be grouped into phrases using\n  quotation marks. In this case, a matching row or column must contain each\n  of the tokens in the phrase in the order specified, with no intervening\n  tokens. For example, the query:\n\n    <col> MATCH '\"hello world\" joe\"\n\n  matches the first of the following two documents, but not the second or\n  third:\n\n    \"'Hello world', said Joe.\"\n    \"One should always greet the world with a cheery hello, thought Joe.\"\n    \"How many hello world programs could their be?\"\n\n  As well as grouping tokens together by phrase, the binary NEAR operator \n  may be used to search for rows that contain two or more specified tokens \n  or phrases within a specified proximity of each other. The NEAR operator\n  must always be specified in upper case. The word \"near\" in lower or mixed\n  case is treated as an ordinary token. For example, the following query:\n\n    <col> MATCH 'engineering NEAR consultancy'\n\n  matches rows that contain both the \"engineering\" and \"consultancy\" tokens\n  in the same column with not more than 10 other words between them. It does\n  not matter which of the two terms occurs first in the document, only that\n  they be seperated by only 10 tokens or less. The user may also specify\n  a different required proximity by adding \"/N\" immediately after the NEAR\n  operator, where N is an integer. For example:\n\n    <col> MATCH 'engineering NEAR/5 consultancy'\n\n  searches for a row containing an instance of each specified token seperated\n  by not more than 5 other tokens. More than one NEAR operator can be used\n  in as sequence. For example this query:\n\n    <col> MATCH 'reliable NEAR/2 engineering NEAR/5 consultancy'\n\n  searches for a row that contains an instance of the token \"reliable\" \n  seperated by not more than two tokens from an instance of \"engineering\",\n  which is in turn separated by not more than 5 other tokens from an\n  instance of the term \"consultancy\". Phrases enclosed in quotes may\n  also be used as arguments to the NEAR operator.\n\n  Similar to the NEAR operator, one or more tokens or phrases may be \n  separated by OR operators. In this case, only one of the specified tokens\n  or phrases must appear in the document. For example, the query:\n\n    <col> MATCH 'hello OR world'\n\n  matches rows that contain either the term \"hello\", or the term \"world\",\n  or both. Note that unlike in many programming languages, the OR operator\n  has a higher precedence than the AND operators implied between white-space\n  separated tokens. The following query matches documents that contain the\n  term 'sqlite' and at least one of the terms 'fantastic' or 'impressive',\n  not those that contain both 'sqlite' and 'fantastic' or 'impressive':\n\n    <col> MATCH 'sqlite fantastic OR impressive'\n\n  Any token that is part of an Fts3 query expression, whether or not it is\n  part of a phrase enclosed in quotes, may have a '*' character appended to\n  it. In this case, the token matches all terms that begin with the characters\n  of the token, not just those that exactly match it. For example, the \n  following query:\n\n    <col> MATCH 'sql*'\n\n  matches all rows that contain the term \"SQLite\", as well as those that\n  contain \"SQL\".\n\n  A token that is not part of a quoted phrase may be preceded by a '-'\n  character, which indicates that matching rows must not contain the \n  specified term. For example, the following:\n\n    <col> MATCH '\"database engine\" -sqlite'\n\n  matches rows that contain the phrase \"database engine\" but do not contain\n  the term \"sqlite\". If the '-' character occurs inside a quoted phrase,\n  it is ignored. It is possible to use both the '-' prefix and the '*' postfix\n  on a single term. At this time, all Fts3 queries must contain at least\n  one term or phrase that is not preceded by the '-' prefix.\n\n  Regardless of whether or not a table name or column name is used on the \n  left hand side of the MATCH operator, a specific column of the fts3 table\n  may be associated with each token in a query by preceding a token with\n  a column name followed by a ':' character. For example, regardless of what\n  is specified for <col>, the following query requires that column \"col1\"\n  of the table contains the term \"hello\", and that column \"col2\" of the\n  table contains the term \"world\". If the table does not contain columns\n  named \"col1\" and \"col2\", then an error is returned and the query is\n  not run.\n\n    <col> MATCH 'col1:hello col2:world'\n\n  It is not possible to associate a specific table column with a quoted \n  phrase or a term preceded by a '-' operator. A '*' character may be\n  appended to a term associated with a specific column for prefix matching.\n\n3. ENHANCED QUERY SYNTAX\n\n  The enhanced query syntax is quite similar to the standard query syntax,\n  with the following four differences:\n\n  1) Parenthesis are supported. When using the enhanced query syntax,\n     parenthesis may be used to overcome the built-in precedence of the\n     supplied binary operators. For example, the following query:\n\n       <col> MATCH '(hello world) OR (simple example)'\n\n     matches documents that contain both \"hello\" and \"world\", and documents\n     that contain both \"simple\" and \"example\". It is not possible to forumlate\n     such a query using the standard syntax.\n\n  2) Instead of separating tokens and phrases by whitespace, an AND operator\n     may be explicitly specified. This does not change query processing at\n     all, but may be used to improve readability. For example, the following\n     query is handled identically to the one above:\n\n       <col> MATCH '(hello AND world) OR (simple AND example)'\n\n     As with the OR and NEAR operators, the AND operator must be specified\n     in upper case. The word \"and\" specified in lower or mixed case is \n     handled as a regular token.\n\n  3) The '-' token prefix is not supported. Instead, a new binary operator,\n     NOT, is included. The NOT operator requires that the query specified\n     as its left-hand operator matches, but that the query specified as the\n     right-hand operator does not. For example, to query for all rows that\n     contain the term \"example\" but not the term \"simple\", the following\n     query could be used:\n\n       <col> MATCH 'example NOT simple'\n\n     As for all other operators, the NOT operator must be specified in\n     upper case. Otherwise it will be treated as a regular token.\n\n  4) Unlike in the standard syntax, where the OR operator has a higher\n     precedence than the implicit AND operator, when using the enhanced\n     syntax implicit and explict AND operators have a higher precedence\n     than OR operators. Using the enhanced syntax, the following two\n     queries are equivalent:\n\n       <col> MATCH 'sqlite fantastic OR impressive'\n       <col> MATCH '(sqlite AND fantastic) OR impressive'\n\n     however, when using the standard syntax, the query:\n\n       <col> MATCH 'sqlite fantastic OR impressive'\n\n     is equivalent to the enhanced syntax query:\n\n       <col> MATCH 'sqlite AND (fantastic OR impressive)'\n\n     The precedence of all enhanced syntax operators, in order from highest\n     to lowest, is:\n\n       NEAR       (highest precedence, tightest grouping)\n       NOT\n       AND\n       OR         (lowest precedence, loosest grouping)\n\n  Using the advanced syntax, it is possible to specify expressions enclosed\n  in parenthesis as operands to the NOT, AND and OR operators. However both\n  the left and right hand side operands of NEAR operators must be either\n  tokens or phrases. Attempting the following query will return an error:\n\n    <col> MATCH 'sqlite NEAR (fantastic OR impressive)'\n\n  Queries of this form must be re-written as:\n\n    <col> MATCH 'sqlite NEAR fantastic OR sqlite NEAR impressive'\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/README.tokenizers",
    "content": "\n1. FTS3 Tokenizers\n\n  When creating a new full-text table, FTS3 allows the user to select\n  the text tokenizer implementation to be used when indexing text\n  by specifying a \"tokenize\" clause as part of the CREATE VIRTUAL TABLE\n  statement:\n\n    CREATE VIRTUAL TABLE <table-name> USING fts3(\n      <columns ...> [, tokenize <tokenizer-name> [<tokenizer-args>]]\n    );\n\n  The built-in tokenizers (valid values to pass as <tokenizer name>) are\n  \"simple\", \"porter\" and \"unicode\".\n\n  <tokenizer-args> should consist of zero or more white-space separated\n  arguments to pass to the selected tokenizer implementation. The \n  interpretation of the arguments, if any, depends on the individual \n  tokenizer.\n\n2. Custom Tokenizers\n\n  FTS3 allows users to provide custom tokenizer implementations. The \n  interface used to create a new tokenizer is defined and described in \n  the fts3_tokenizer.h source file.\n\n  Registering a new FTS3 tokenizer is similar to registering a new \n  virtual table module with SQLite. The user passes a pointer to a\n  structure containing pointers to various callback functions that\n  make up the implementation of the new tokenizer type. For tokenizers,\n  the structure (defined in fts3_tokenizer.h) is called\n  \"sqlite3_tokenizer_module\".\n\n  FTS3 does not expose a C-function that users call to register new\n  tokenizer types with a database handle. Instead, the pointer must\n  be encoded as an SQL blob value and passed to FTS3 through the SQL\n  engine by evaluating a special scalar function, \"fts3_tokenizer()\".\n  The fts3_tokenizer() function may be called with one or two arguments,\n  as follows:\n\n    SELECT fts3_tokenizer(<tokenizer-name>);\n    SELECT fts3_tokenizer(<tokenizer-name>, <sqlite3_tokenizer_module ptr>);\n  \n  Where <tokenizer-name> is a string identifying the tokenizer and\n  <sqlite3_tokenizer_module ptr> is a pointer to an sqlite3_tokenizer_module\n  structure encoded as an SQL blob. If the second argument is present,\n  it is registered as tokenizer <tokenizer-name> and a copy of it\n  returned. If only one argument is passed, a pointer to the tokenizer\n  implementation currently registered as <tokenizer-name> is returned,\n  encoded as a blob. Or, if no such tokenizer exists, an SQL exception\n  (error) is raised.\n\n  SECURITY: If the fts3 extension is used in an environment where potentially\n    malicious users may execute arbitrary SQL (i.e. gears), they should be\n    prevented from invoking the fts3_tokenizer() function, possibly using the\n    authorisation callback.\n\n  See \"Sample code\" below for an example of calling the fts3_tokenizer()\n  function from C code.\n\n3. ICU Library Tokenizers\n\n  If this extension is compiled with the SQLITE_ENABLE_ICU pre-processor \n  symbol defined, then there exists a built-in tokenizer named \"icu\" \n  implemented using the ICU library. The first argument passed to the\n  xCreate() method (see fts3_tokenizer.h) of this tokenizer may be\n  an ICU locale identifier. For example \"tr_TR\" for Turkish as used\n  in Turkey, or \"en_AU\" for English as used in Australia. For example:\n\n    \"CREATE VIRTUAL TABLE thai_text USING fts3(text, tokenizer icu th_TH)\"\n\n  The ICU tokenizer implementation is very simple. It splits the input\n  text according to the ICU rules for finding word boundaries and discards\n  any tokens that consist entirely of white-space. This may be suitable\n  for some applications in some locales, but not all. If more complex\n  processing is required, for example to implement stemming or \n  discard punctuation, this can be done by creating a tokenizer \n  implementation that uses the ICU tokenizer as part of its implementation.\n\n  When using the ICU tokenizer this way, it is safe to overwrite the\n  contents of the strings returned by the xNext() method (see\n  fts3_tokenizer.h).\n\n4. Sample code.\n\n  The following two code samples illustrate the way C code should invoke\n  the fts3_tokenizer() scalar function:\n\n      int registerTokenizer(\n        sqlite3 *db, \n        char *zName, \n        const sqlite3_tokenizer_module *p\n      ){\n        int rc;\n        sqlite3_stmt *pStmt;\n        const char zSql[] = \"SELECT fts3_tokenizer(?, ?)\";\n      \n        rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      \n        sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n        sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n        sqlite3_step(pStmt);\n      \n        return sqlite3_finalize(pStmt);\n      }\n      \n      int queryTokenizer(\n        sqlite3 *db, \n        char *zName,  \n        const sqlite3_tokenizer_module **pp\n      ){\n        int rc;\n        sqlite3_stmt *pStmt;\n        const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n      \n        *pp = 0;\n        rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      \n        sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n            memcpy(pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n          }\n        }\n      \n        return sqlite3_finalize(pStmt);\n      }\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/README.txt",
    "content": "This folder contains source code to the second full-text search\nextension for SQLite.  While the API is the same, this version uses a\nsubstantially different storage schema from fts1, so tables will need\nto be rebuilt.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3.c",
    "content": "/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n\n/* The full-text index is stored in a series of b+tree (-like)\n** structures called segments which map terms to doclists.  The\n** structures are like b+trees in layout, but are constructed from the\n** bottom up in optimal fashion and are not updatable.  Since trees\n** are built from the bottom up, things will be described from the\n** bottom up.\n**\n**\n**** Varints ****\n** The basic unit of encoding is a variable-length integer called a\n** varint.  We encode variable-length integers in little-endian order\n** using seven bits * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n**\n** This is similar in concept to how sqlite encodes \"varints\" but\n** the encoding is not the same.  SQLite varints are big-endian\n** are are limited to 9 bytes in length whereas FTS3 varints are\n** little-endian and can be up to 10 bytes in length (in theory).\n**\n** Example encodings:\n**\n**     1:    0x01\n**   127:    0x7f\n**   128:    0x81 0x00\n**\n**\n**** Document lists ****\n** A doclist (document list) holds a docid-sorted list of hits for a\n** given term.  Doclists hold docids and associated token positions.\n** A docid is the unique integer identifier for a single document.\n** A position is the index of a word within the document.  The first \n** word of the document has a position of 0.\n**\n** FTS3 used to optionally store character offsets using a compile-time\n** option.  But that functionality is no longer supported.\n**\n** A doclist is stored like this:\n**\n** array {\n**   varint docid;          (delta from previous doclist)\n**   array {                (position list for column 0)\n**     varint position;     (2 more than the delta from previous position)\n**   }\n**   array {\n**     varint POS_COLUMN;   (marks start of position list for new column)\n**     varint column;       (index of new column)\n**     array {\n**       varint position;   (2 more than the delta from previous position)\n**     }\n**   }\n**   varint POS_END;        (marks end of positions for this document.\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.  A \"position\" is an index of a token in the token stream\n** generated by the tokenizer. Note that POS_END and POS_COLUMN occur \n** in the same logical place as the position element, and act as sentinals\n** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.\n** The positions numbers are not stored literally but rather as two more\n** than the difference from the prior position, or the just the position plus\n** 2 for the first position.  Example:\n**\n**   label:       A B C D E  F  G H   I  J K\n**   value:     123 5 9 1 1 14 35 0 234 72 0\n**\n** The 123 value is the first docid.  For column zero in this document\n** there are two matches at positions 3 and 10 (5-2 and 9-2+3).  The 1\n** at D signals the start of a new column; the 1 at E indicates that the\n** new column is column number 1.  There are two positions at 12 and 45\n** (14-2 and 35-2+12).  The 0 at H indicate the end-of-document.  The\n** 234 at I is the delta to next docid (357).  It has one position 70\n** (72-2) and then terminates with the 0 at K.\n**\n** A \"position-list\" is the list of positions for multiple columns for\n** a single docid.  A \"column-list\" is the set of positions for a single\n** column.  Hence, a position-list consists of one or more column-lists,\n** a document record consists of a docid followed by a position-list and\n** a doclist consists of one or more document records.\n**\n** A bare doclist omits the position information, becoming an \n** array of varint-encoded docids.\n**\n**** Segment leaf nodes ****\n** Segment leaf nodes store terms and doclists, ordered by term.  Leaf\n** nodes are written using LeafWriter, and read using LeafReader (to\n** iterate through a single leaf node's data) and LeavesReader (to\n** iterate through a segment's entire leaf layer).  Leaf nodes have\n** the format:\n**\n** varint iHeight;             (height from leaf level, always 0)\n** varint nTerm;               (length of first term)\n** char pTerm[nTerm];          (content of first term)\n** varint nDoclist;            (length of term's associated doclist)\n** char pDoclist[nDoclist];    (content of doclist)\n** array {\n**                             (further terms are delta-encoded)\n**   varint nPrefix;           (length of prefix shared with previous term)\n**   varint nSuffix;           (length of unshared suffix)\n**   char pTermSuffix[nSuffix];(unshared suffix of next term)\n**   varint nDoclist;          (length of term's associated doclist)\n**   char pDoclist[nDoclist];  (content of doclist)\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.\n**\n** Leaf nodes are broken into blocks which are stored contiguously in\n** the %_segments table in sorted order.  This means that when the end\n** of a node is reached, the next term is in the node with the next\n** greater node id.\n**\n** New data is spilled to a new leaf node when the current node\n** exceeds LEAF_MAX bytes (default 2048).  New data which itself is\n** larger than STANDALONE_MIN (default 1024) is placed in a standalone\n** node (a leaf node with a single term and doclist).  The goal of\n** these settings is to pack together groups of small doclists while\n** making it efficient to directly access large doclists.  The\n** assumption is that large doclists represent terms which are more\n** likely to be query targets.\n**\n** TODO(shess) It may be useful for blocking decisions to be more\n** dynamic.  For instance, it may make more sense to have a 2.5k leaf\n** node rather than splitting into 2k and .5k nodes.  My intuition is\n** that this might extend through 2x or 4x the pagesize.\n**\n**\n**** Segment interior nodes ****\n** Segment interior nodes store blockids for subtree nodes and terms\n** to describe what data is stored by the each subtree.  Interior\n** nodes are written using InteriorWriter, and read using\n** InteriorReader.  InteriorWriters are created as needed when\n** SegmentWriter creates new leaf nodes, or when an interior node\n** itself grows too big and must be split.  The format of interior\n** nodes:\n**\n** varint iHeight;           (height from leaf level, always >0)\n** varint iBlockid;          (block id of node's leftmost subtree)\n** optional {\n**   varint nTerm;           (length of first term)\n**   char pTerm[nTerm];      (content of first term)\n**   array {\n**                                (further terms are delta-encoded)\n**     varint nPrefix;            (length of shared prefix with previous term)\n**     varint nSuffix;            (length of unshared suffix)\n**     char pTermSuffix[nSuffix]; (unshared suffix of next term)\n**   }\n** }\n**\n** Here, optional { X } means an optional element, while array { X }\n** means zero or more occurrences of X, adjacent in memory.\n**\n** An interior node encodes n terms separating n+1 subtrees.  The\n** subtree blocks are contiguous, so only the first subtree's blockid\n** is encoded.  The subtree at iBlockid will contain all terms less\n** than the first term encoded (or all terms if no term is encoded).\n** Otherwise, for terms greater than or equal to pTerm[i] but less\n** than pTerm[i+1], the subtree for that term will be rooted at\n** iBlockid+i.  Interior nodes only store enough term data to\n** distinguish adjacent children (if the rightmost term of the left\n** child is \"something\", and the leftmost term of the right child is\n** \"wicked\", only \"w\" is stored).\n**\n** New data is spilled to a new interior node at the same height when\n** the current node exceeds INTERIOR_MAX bytes (default 2048).\n** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing\n** interior nodes and making the tree too skinny.  The interior nodes\n** at a given height are naturally tracked by interior nodes at\n** height+1, and so on.\n**\n**\n**** Segment directory ****\n** The segment directory in table %_segdir stores meta-information for\n** merging and deleting segments, and also the root node of the\n** segment's tree.\n**\n** The root node is the top node of the segment's tree after encoding\n** the entire segment, restricted to ROOT_MAX bytes (default 1024).\n** This could be either a leaf node or an interior node.  If the top\n** node requires more than ROOT_MAX bytes, it is flushed to %_segments\n** and a new root interior node is generated (which should always fit\n** within ROOT_MAX because it only needs space for 2 varints, the\n** height and the blockid of the previous root).\n**\n** The meta-information in the segment directory is:\n**   level               - segment level (see below)\n**   idx                 - index within level\n**                       - (level,idx uniquely identify a segment)\n**   start_block         - first leaf node\n**   leaves_end_block    - last leaf node\n**   end_block           - last block (including interior nodes)\n**   root                - contents of root node\n**\n** If the root node is a leaf node, then start_block,\n** leaves_end_block, and end_block are all 0.\n**\n**\n**** Segment merging ****\n** To amortize update costs, segments are grouped into levels and\n** merged in batches.  Each increase in level represents exponentially\n** more documents.\n**\n** New documents (actually, document updates) are tokenized and\n** written individually (using LeafWriter) to a level 0 segment, with\n** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all\n** level 0 segments are merged into a single level 1 segment.  Level 1\n** is populated like level 0, and eventually MERGE_COUNT level 1\n** segments are merged to a single level 2 segment (representing\n** MERGE_COUNT^2 updates), and so on.\n**\n** A segment merge traverses all segments at a given level in\n** parallel, performing a straightforward sorted merge.  Since segment\n** leaf nodes are written in to the %_segments table in order, this\n** merge traverses the underlying sqlite disk structures efficiently.\n** After the merge, all segment blocks from the merged level are\n** deleted.\n**\n** MERGE_COUNT controls how often we merge segments.  16 seems to be\n** somewhat of a sweet spot for insertion performance.  32 and 64 show\n** very similar performance numbers to 16 on insertion, though they're\n** a tiny bit slower (perhaps due to more overhead in merge-time\n** sorting).  8 is about 20% slower than 16, 4 about 50% slower than\n** 16, 2 about 66% slower than 16.\n**\n** At query time, high MERGE_COUNT increases the number of segments\n** which need to be scanned and merged.  For instance, with 100k docs\n** inserted:\n**\n**    MERGE_COUNT   segments\n**       16           25\n**        8           12\n**        4           10\n**        2            6\n**\n** This appears to have only a moderate impact on queries for very\n** frequent terms (which are somewhat dominated by segment merge\n** costs), and infrequent and non-existent terms still seem to be fast\n** even with many segments.\n**\n** TODO(shess) That said, it would be nice to have a better query-side\n** argument for MERGE_COUNT of 16.  Also, it is possible/likely that\n** optimizations to things like doclist merging will swing the sweet\n** spot around.\n**\n**\n**\n**** Handling of deletions and updates ****\n** Since we're using a segmented structure, with no docid-oriented\n** index into the term index, we clearly cannot simply update the term\n** index when a document is deleted or updated.  For deletions, we\n** write an empty doclist (varint(docid) varint(POS_END)), for updates\n** we simply write the new doclist.  Segment merges overwrite older\n** data for a particular docid with newer data, so deletes or updates\n** will eventually overtake the earlier data and knock it out.  The\n** query logic likewise merges doclists so that newer data knocks out\n** older data.\n*/\n\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stddef.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n\n#include \"fts3.h\"\n#ifndef SQLITE_CORE \n# include \"sqlite3ext.h\"\n  SQLITE_EXTENSION_INIT1\n#endif\n\nstatic int fts3EvalNext(Fts3Cursor *pCsr);\nstatic int fts3EvalStart(Fts3Cursor *pCsr);\nstatic int fts3TermSegReaderCursor(\n    Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);\n\n#ifndef SQLITE_AMALGAMATION\n# if defined(SQLITE_DEBUG)\nint sqlite3Fts3Always(int b) { assert( b ); return b; }\nint sqlite3Fts3Never(int b)  { assert( !b ); return b; }\n# endif\n#endif\n\n/* \n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.\n** The number of bytes written is returned.\n*/\nint sqlite3Fts3PutVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (v & mask1) | ( (*ptr++) << shift );                    \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (*ptr++);                                               \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n\n/* \n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read, or 0 on error.\n** The value is stored in *v.\n*/\nint sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){\n  const unsigned char *p = (const unsigned char*)pBuf;\n  const unsigned char *pStart = p;\n  u32 a;\n  u64 b;\n  int shift;\n\n  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *v, 1);\n  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *v, 2);\n  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *v, 3);\n  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);\n  b = (a & 0x0FFFFFFF );\n\n  for(shift=28; shift<=63; shift+=7){\n    u64 c = *p++;\n    b += (c&0x7F) << shift;\n    if( (c & 0x80)==0 ) break;\n  }\n  *v = b;\n  return (int)(p - pStart);\n}\n\n/*\n** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to \n** a non-negative 32-bit integer before it is returned.\n*/\nint sqlite3Fts3GetVarint32(const char *p, int *pi){\n  u32 a;\n\n#ifndef fts3GetVarint32\n  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *pi, 1);\n#else\n  a = (*p++);\n  assert( a & 0x80 );\n#endif\n\n  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *pi, 2);\n  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *pi, 3);\n  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);\n  a = (a & 0x0FFFFFFF );\n  *pi = (int)(a | ((u32)(*p & 0x07) << 28));\n  assert( 0==(a & 0x80000000) );\n  assert( *pi>=0 );\n  return 5;\n}\n\n/*\n** Return the number of bytes required to encode v as a varint\n*/\nint sqlite3Fts3VarintLen(sqlite3_uint64 v){\n  int i = 0;\n  do{\n    i++;\n    v >>= 7;\n  }while( v!=0 );\n  return i;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n**\n*/\nvoid sqlite3Fts3Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    int iIn = 1;                  /* Index of next byte to read from input */\n    int iOut = 0;                 /* Index of next byte to write to output */\n\n    /* If the first byte was a '[', then the close-quote character is a ']' */\n    if( quote=='[' ) quote = ']';  \n\n    while( z[iIn] ){\n      if( z[iIn]==quote ){\n        if( z[iIn+1]!=quote ) break;\n        z[iOut++] = quote;\n        iIn += 2;\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** Read a single varint from the doclist at *pp and advance *pp to point\n** to the first byte past the end of the varint.  Add the value of the varint\n** to *pVal.\n*/\nstatic void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){\n  sqlite3_int64 iVal;\n  *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n  *pVal += iVal;\n}\n\n/*\n** When this function is called, *pp points to the first byte following a\n** varint that is part of a doclist (or position-list, or any other list\n** of varints). This function moves *pp to point to the start of that varint,\n** and sets *pVal by the varint value.\n**\n** Argument pStart points to the first byte of the doclist that the\n** varint is part of.\n*/\nstatic void fts3GetReverseVarint(\n  char **pp, \n  char *pStart, \n  sqlite3_int64 *pVal\n){\n  sqlite3_int64 iVal;\n  char *p;\n\n  /* Pointer p now points at the first byte past the varint we are \n  ** interested in. So, unless the doclist is corrupt, the 0x80 bit is\n  ** clear on character p[-1]. */\n  for(p = (*pp)-2; p>=pStart && *p&0x80; p--);\n  p++;\n  *pp = p;\n\n  sqlite3Fts3GetVarint(p, &iVal);\n  *pVal = iVal;\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts3DisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int i;\n\n  assert( p->nPendingData==0 );\n  assert( p->pSegments==0 );\n\n  /* Free any prepared statements held */\n  sqlite3_finalize(p->pSeekStmt);\n  for(i=0; i<SizeofArray(p->aStmt); i++){\n    sqlite3_finalize(p->aStmt[i]);\n  }\n  sqlite3_free(p->zSegmentsTbl);\n  sqlite3_free(p->zReadExprlist);\n  sqlite3_free(p->zWriteExprlist);\n  sqlite3_free(p->zContentTbl);\n  sqlite3_free(p->zLanguageid);\n\n  /* Invoke the tokenizer destructor to free the tokenizer. */\n  p->pTokenizer->pModule->xDestroy(p->pTokenizer);\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into *pzErr\n*/\nvoid sqlite3Fts3ErrMsg(char **pzErr, const char *zFormat, ...){\n  va_list ap;\n  sqlite3_free(*pzErr);\n  va_start(ap, zFormat);\n  *pzErr = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Construct one or more SQL statements from the format string given\n** and then evaluate those statements. The success code is written\n** into *pRc.\n**\n** If *pRc is initially non-zero then this routine is a no-op.\n*/\nstatic void fts3DbExec(\n  int *pRc,              /* Success code */\n  sqlite3 *db,           /* Database in which to run SQL */\n  const char *zFormat,   /* Format string for SQL */\n  ...                    /* Arguments to the format string */\n){\n  va_list ap;\n  char *zSql;\n  if( *pRc ) return;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    *pRc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts3DestroyMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;              /* Return code */\n  const char *zDb = p->zDb;        /* Name of database (e.g. \"main\", \"temp\") */\n  sqlite3 *db = p->db;             /* Database handle */\n\n  /* Drop the shadow tables */\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_content'\", zDb, p->zName);\n  }\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segments'\", zDb,p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segdir'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_docsize'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_stat'\", zDb, p->zName);\n\n  /* If everything has worked, invoke fts3DisconnectMethod() to free the\n  ** memory associated with the Fts3Table structure and return SQLITE_OK.\n  ** Otherwise, return an SQLite error code.\n  */\n  return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);\n}\n\n\n/*\n** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table\n** passed as the first argument. This is done as part of the xConnect()\n** and xCreate() methods.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DeclareVtab(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int i;                        /* Iterator variable */\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL statement passed to declare_vtab() */\n    char *zCols;                  /* List of user defined columns */\n    const char *zLanguageid;\n\n    zLanguageid = (p->zLanguageid ? p->zLanguageid : \"__langid\");\n    sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n    /* Create a list of user columns for the virtual table */\n    zCols = sqlite3_mprintf(\"%Q, \", p->azColumn[0]);\n    for(i=1; zCols && i<p->nColumn; i++){\n      zCols = sqlite3_mprintf(\"%z%Q, \", zCols, p->azColumn[i]);\n    }\n\n    /* Create the whole \"CREATE TABLE\" statement to pass to SQLite */\n    zSql = sqlite3_mprintf(\n        \"CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)\", \n        zCols, p->zName, zLanguageid\n    );\n    if( !zCols || !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_declare_vtab(p->db, zSql);\n    }\n\n    sqlite3_free(zSql);\n    sqlite3_free(zCols);\n    *pRc = rc;\n  }\n}\n\n/*\n** Create the %_stat table if it does not already exist.\n*/\nvoid sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){\n  fts3DbExec(pRc, p->db, \n      \"CREATE TABLE IF NOT EXISTS %Q.'%q_stat'\"\n          \"(id INTEGER PRIMARY KEY, value BLOB);\",\n      p->zDb, p->zName\n  );\n  if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;\n}\n\n/*\n** Create the backing store tables (%_content, %_segments and %_segdir)\n** required by the FTS3 table passed as the only argument. This is done\n** as part of the vtab xCreate() method.\n**\n** If the p->bHasDocsize boolean is true (indicating that this is an\n** FTS4 table, not an FTS3 table) then also create the %_docsize and\n** %_stat tables required by FTS4.\n*/\nstatic int fts3CreateTables(Fts3Table *p){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  sqlite3 *db = p->db;            /* The database connection */\n\n  if( p->zContentTbl==0 ){\n    const char *zLanguageid = p->zLanguageid;\n    char *zContentCols;           /* Columns of %_content table */\n\n    /* Create a list of user columns for the content table */\n    zContentCols = sqlite3_mprintf(\"docid INTEGER PRIMARY KEY\");\n    for(i=0; zContentCols && i<p->nColumn; i++){\n      char *z = p->azColumn[i];\n      zContentCols = sqlite3_mprintf(\"%z, 'c%d%q'\", zContentCols, i, z);\n    }\n    if( zLanguageid && zContentCols ){\n      zContentCols = sqlite3_mprintf(\"%z, langid\", zContentCols, zLanguageid);\n    }\n    if( zContentCols==0 ) rc = SQLITE_NOMEM;\n  \n    /* Create the content table */\n    fts3DbExec(&rc, db, \n       \"CREATE TABLE %Q.'%q_content'(%s)\",\n       p->zDb, p->zName, zContentCols\n    );\n    sqlite3_free(zContentCols);\n  }\n\n  /* Create other tables */\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);\",\n      p->zDb, p->zName\n  );\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segdir'(\"\n        \"level INTEGER,\"\n        \"idx INTEGER,\"\n        \"start_block INTEGER,\"\n        \"leaves_end_block INTEGER,\"\n        \"end_block INTEGER,\"\n        \"root BLOB,\"\n        \"PRIMARY KEY(level, idx)\"\n      \");\",\n      p->zDb, p->zName\n  );\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db, \n        \"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);\",\n        p->zDb, p->zName\n    );\n  }\n  assert( p->bHasStat==p->bFts4 );\n  if( p->bHasStat ){\n    sqlite3Fts3CreateStatTable(&rc, p);\n  }\n  return rc;\n}\n\n/*\n** Store the current database page-size in bytes in p->nPgsz.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DatabasePageSize(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL text \"PRAGMA %Q.page_size\" */\n    sqlite3_stmt *pStmt;          /* Compiled \"PRAGMA %Q.page_size\" statement */\n  \n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", p->zDb);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_step(pStmt);\n        p->nPgsz = sqlite3_column_int(pStmt, 0);\n        rc = sqlite3_finalize(pStmt);\n      }else if( rc==SQLITE_AUTH ){\n        p->nPgsz = 1024;\n        rc = SQLITE_OK;\n      }\n    }\n    assert( p->nPgsz>0 || rc!=SQLITE_OK );\n    sqlite3_free(zSql);\n    *pRc = rc;\n  }\n}\n\n/*\n** \"Special\" FTS4 arguments are column specifications of the following form:\n**\n**   <key> = <value>\n**\n** There may not be whitespace surrounding the \"=\" character. The <value> \n** term may be quoted, but the <key> may not.\n*/\nstatic int fts3IsSpecialColumn(\n  const char *z, \n  int *pnKey,\n  char **pzValue\n){\n  char *zValue;\n  const char *zCsr = z;\n\n  while( *zCsr!='=' ){\n    if( *zCsr=='\\0' ) return 0;\n    zCsr++;\n  }\n\n  *pnKey = (int)(zCsr-z);\n  zValue = sqlite3_mprintf(\"%s\", &zCsr[1]);\n  if( zValue ){\n    sqlite3Fts3Dequote(zValue);\n  }\n  *pzValue = zValue;\n  return 1;\n}\n\n/*\n** Append the output of a printf() style formatting to an existing string.\n*/\nstatic void fts3Appendf(\n  int *pRc,                       /* IN/OUT: Error code */\n  char **pz,                      /* IN/OUT: Pointer to string buffer */\n  const char *zFormat,            /* Printf format string to append */\n  ...                             /* Arguments for printf format string */\n){\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    char *z;\n    va_start(ap, zFormat);\n    z = sqlite3_vmprintf(zFormat, ap);\n    va_end(ap);\n    if( z && *pz ){\n      char *z2 = sqlite3_mprintf(\"%s%s\", *pz, z);\n      sqlite3_free(z);\n      z = z2;\n    }\n    if( z==0 ) *pRc = SQLITE_NOMEM;\n    sqlite3_free(*pz);\n    *pz = z;\n  }\n}\n\n/*\n** Return a copy of input string zInput enclosed in double-quotes (\") and\n** with all double quote characters escaped. For example:\n**\n**     fts3QuoteId(\"un \\\"zip\\\"\")   ->    \"un \\\"\\\"zip\\\"\\\"\"\n**\n** The pointer returned points to memory obtained from sqlite3_malloc(). It\n** is the callers responsibility to call sqlite3_free() to release this\n** memory.\n*/\nstatic char *fts3QuoteId(char const *zInput){\n  int nRet;\n  char *zRet;\n  nRet = 2 + (int)strlen(zInput)*2 + 1;\n  zRet = sqlite3_malloc(nRet);\n  if( zRet ){\n    int i;\n    char *z = zRet;\n    *(z++) = '\"';\n    for(i=0; zInput[i]; i++){\n      if( zInput[i]=='\"' ) *(z++) = '\"';\n      *(z++) = zInput[i];\n    }\n    *(z++) = '\"';\n    *(z++) = '\\0';\n  }\n  return zRet;\n}\n\n/*\n** Return a list of comma separated SQL expressions and a FROM clause that \n** could be used in a SELECT statement such as the following:\n**\n**     SELECT <list of expressions> FROM %_content AS x ...\n**\n** to return the docid, followed by each column of text data in order\n** from left to write. If parameter zFunc is not NULL, then instead of\n** being returned directly each column of text data is passed to an SQL\n** function named zFunc first. For example, if zFunc is \"unzip\" and the\n** table has the three user-defined columns \"a\", \"b\", and \"c\", the following\n** string is returned:\n**\n**     \"docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c') FROM %_content AS x\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3ReadExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( p->zContentTbl==0 ){\n    if( !zFunc ){\n      zFunction = \"\";\n    }else{\n      zFree = zFunction = fts3QuoteId(zFunc);\n    }\n    fts3Appendf(pRc, &zRet, \"docid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \",%s(x.'c%d%q')\", zFunction, i, p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", \"langid\");\n    }\n    sqlite3_free(zFree);\n  }else{\n    fts3Appendf(pRc, &zRet, \"rowid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \", x.'%q'\", p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", p->zLanguageid);\n    }\n  }\n  fts3Appendf(pRc, &zRet, \" FROM '%q'.'%q%s' AS x\", \n      p->zDb,\n      (p->zContentTbl ? p->zContentTbl : p->zName),\n      (p->zContentTbl ? \"\" : \"_content\")\n  );\n  return zRet;\n}\n\n/*\n** Return a list of N comma separated question marks, where N is the number\n** of columns in the %_content table (one for the docid plus one for each\n** user-defined text column).\n**\n** If argument zFunc is not NULL, then all but the first question mark\n** is preceded by zFunc and an open bracket, and followed by a closed\n** bracket. For example, if zFunc is \"zip\" and the FTS3 table has three \n** user-defined text columns, the following string is returned:\n**\n**     \"?, zip(?), zip(?), zip(?)\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( !zFunc ){\n    zFunction = \"\";\n  }else{\n    zFree = zFunction = fts3QuoteId(zFunc);\n  }\n  fts3Appendf(pRc, &zRet, \"?\");\n  for(i=0; i<p->nColumn; i++){\n    fts3Appendf(pRc, &zRet, \",%s(?)\", zFunction);\n  }\n  if( p->zLanguageid ){\n    fts3Appendf(pRc, &zRet, \", ?\");\n  }\n  sqlite3_free(zFree);\n  return zRet;\n}\n\n/*\n** This function interprets the string at (*pp) as a non-negative integer\n** value. It reads the integer and sets *pnOut to the value read, then \n** sets *pp to point to the byte immediately following the last byte of\n** the integer value.\n**\n** Only decimal digits ('0'..'9') may be part of an integer value. \n**\n** If *pp does not being with a decimal digit SQLITE_ERROR is returned and\n** the output value undefined. Otherwise SQLITE_OK is returned.\n**\n** This function is used when parsing the \"prefix=\" FTS4 parameter.\n*/\nstatic int fts3GobbleInt(const char **pp, int *pnOut){\n  const int MAX_NPREFIX = 10000000;\n  const char *p;                  /* Iterator pointer */\n  int nInt = 0;                   /* Output value */\n\n  for(p=*pp; p[0]>='0' && p[0]<='9'; p++){\n    nInt = nInt * 10 + (p[0] - '0');\n    if( nInt>MAX_NPREFIX ){\n      nInt = 0;\n      break;\n    }\n  }\n  if( p==*pp ) return SQLITE_ERROR;\n  *pnOut = nInt;\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called to allocate an array of Fts3Index structures\n** representing the indexes maintained by the current FTS table. FTS tables\n** always maintain the main \"terms\" index, but may also maintain one or\n** more \"prefix\" indexes, depending on the value of the \"prefix=\" parameter\n** (if any) specified as part of the CREATE VIRTUAL TABLE statement.\n**\n** Argument zParam is passed the value of the \"prefix=\" option if one was\n** specified, or NULL otherwise.\n**\n** If no error occurs, SQLITE_OK is returned and *apIndex set to point to\n** the allocated array. *pnIndex is set to the number of elements in the\n** array. If an error does occur, an SQLite error code is returned.\n**\n** Regardless of whether or not an error is returned, it is the responsibility\n** of the caller to call sqlite3_free() on the output array to free it.\n*/\nstatic int fts3PrefixParameter(\n  const char *zParam,             /* ABC in prefix=ABC parameter to parse */\n  int *pnIndex,                   /* OUT: size of *apIndex[] array */\n  struct Fts3Index **apIndex      /* OUT: Array of indexes for this table */\n){\n  struct Fts3Index *aIndex;       /* Allocated array */\n  int nIndex = 1;                 /* Number of entries in array */\n\n  if( zParam && zParam[0] ){\n    const char *p;\n    nIndex++;\n    for(p=zParam; *p; p++){\n      if( *p==',' ) nIndex++;\n    }\n  }\n\n  aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);\n  *apIndex = aIndex;\n  if( !aIndex ){\n    return SQLITE_NOMEM;\n  }\n\n  memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);\n  if( zParam ){\n    const char *p = zParam;\n    int i;\n    for(i=1; i<nIndex; i++){\n      int nPrefix = 0;\n      if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;\n      assert( nPrefix>=0 );\n      if( nPrefix==0 ){\n        nIndex--;\n        i--;\n      }else{\n        aIndex[i].nPrefix = nPrefix;\n      }\n      p++;\n    }\n  }\n\n  *pnIndex = nIndex;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called when initializing an FTS4 table that uses the\n** content=xxx option. It determines the number of and names of the columns\n** of the new FTS4 table.\n**\n** The third argument passed to this function is the value passed to the\n** config=xxx option (i.e. \"xxx\"). This function queries the database for\n** a table of that name. If found, the output variables are populated\n** as follows:\n**\n**   *pnCol:   Set to the number of columns table xxx has,\n**\n**   *pnStr:   Set to the total amount of space required to store a copy\n**             of each columns name, including the nul-terminator.\n**\n**   *pazCol:  Set to point to an array of *pnCol strings. Each string is\n**             the name of the corresponding column in table xxx. The array\n**             and its contents are allocated using a single allocation. It\n**             is the responsibility of the caller to free this allocation\n**             by eventually passing the *pazCol value to sqlite3_free().\n**\n** If the table cannot be found, an error code is returned and the output\n** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is\n** returned (and the output variables are undefined).\n*/\nstatic int fts3ContentColumns(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (i.e. \"main\", \"temp\" etc.) */\n  const char *zTbl,               /* Name of content table */\n  const char ***pazCol,           /* OUT: Malloc'd array of column names */\n  int *pnCol,                     /* OUT: Size of array *pazCol */\n  int *pnStr,                     /* OUT: Bytes of string content */\n  char **pzErr                    /* OUT: error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* \"SELECT *\" statement on zTbl */  \n  sqlite3_stmt *pStmt = 0;        /* Compiled version of zSql */\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", zDb, zTbl);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"%s\", sqlite3_errmsg(db));\n    }\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    const char **azCol;           /* Output array */\n    int nStr = 0;                 /* Size of all column names (incl. 0x00) */\n    int nCol;                     /* Number of table columns */\n    int i;                        /* Used to iterate through columns */\n\n    /* Loop through the returned columns. Set nStr to the number of bytes of\n    ** space required to store a copy of each column name, including the\n    ** nul-terminator byte.  */\n    nCol = sqlite3_column_count(pStmt);\n    for(i=0; i<nCol; i++){\n      const char *zCol = sqlite3_column_name(pStmt, i);\n      nStr += (int)strlen(zCol) + 1;\n    }\n\n    /* Allocate and populate the array to return. */\n    azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);\n    if( azCol==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *p = (char *)&azCol[nCol];\n      for(i=0; i<nCol; i++){\n        const char *zCol = sqlite3_column_name(pStmt, i);\n        int n = (int)strlen(zCol)+1;\n        memcpy(p, zCol, n);\n        azCol[i] = p;\n        p += n;\n      }\n    }\n    sqlite3_finalize(pStmt);\n\n    /* Set the output variables. */\n    *pnCol = nCol;\n    *pnStr = nStr;\n    *pazCol = azCol;\n  }\n\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts3\" or \"fts4\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts3InitVtab(\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts3Hash *pHash = (Fts3Hash *)pAux;\n  Fts3Table *p = 0;               /* Pointer to allocated vtab */\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  int nByte;                      /* Size of allocation used for *p */\n  int iCol;                       /* Column index */\n  int nString = 0;                /* Bytes required to hold all column names */\n  int nCol = 0;                   /* Number of columns in the FTS table */\n  char *zCsr;                     /* Space for holding column names */\n  int nDb;                        /* Bytes required to hold database name */\n  int nName;                      /* Bytes required to hold table name */\n  int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */\n  const char **aCol;              /* Array of column names */\n  sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */\n\n  int nIndex = 0;                 /* Size of aIndex[] array */\n  struct Fts3Index *aIndex = 0;   /* Array of indexes for this table */\n\n  /* The results of parsing supported FTS4 key=value options: */\n  int bNoDocsize = 0;             /* True to omit %_docsize table */\n  int bDescIdx = 0;               /* True to store descending indexes */\n  char *zPrefix = 0;              /* Prefix parameter value (or NULL) */\n  char *zCompress = 0;            /* compress=? parameter (or NULL) */\n  char *zUncompress = 0;          /* uncompress=? parameter (or NULL) */\n  char *zContent = 0;             /* content=? parameter (or NULL) */\n  char *zLanguageid = 0;          /* languageid=? parameter (or NULL) */\n  char **azNotindexed = 0;        /* The set of notindexed= columns */\n  int nNotindexed = 0;            /* Size of azNotindexed[] array */\n\n  assert( strlen(argv[0])==4 );\n  assert( (sqlite3_strnicmp(argv[0], \"fts4\", 4)==0 && isFts4)\n       || (sqlite3_strnicmp(argv[0], \"fts3\", 4)==0 && !isFts4)\n  );\n\n  nDb = (int)strlen(argv[1]) + 1;\n  nName = (int)strlen(argv[2]) + 1;\n\n  nByte = sizeof(const char *) * (argc-2);\n  aCol = (const char **)sqlite3_malloc(nByte);\n  if( aCol ){\n    memset((void*)aCol, 0, nByte);\n    azNotindexed = (char **)sqlite3_malloc(nByte);\n  }\n  if( azNotindexed ){\n    memset(azNotindexed, 0, nByte);\n  }\n  if( !aCol || !azNotindexed ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n\n  /* Loop through all of the arguments passed by the user to the FTS3/4\n  ** module (i.e. all the column names and special arguments). This loop\n  ** does the following:\n  **\n  **   + Figures out the number of columns the FTSX table will have, and\n  **     the number of bytes of space that must be allocated to store copies\n  **     of the column names.\n  **\n  **   + If there is a tokenizer specification included in the arguments,\n  **     initializes the tokenizer pTokenizer.\n  */\n  for(i=3; rc==SQLITE_OK && i<argc; i++){\n    char const *z = argv[i];\n    int nKey;\n    char *zVal;\n\n    /* Check if this is a tokenizer specification */\n    if( !pTokenizer \n     && strlen(z)>8\n     && 0==sqlite3_strnicmp(z, \"tokenize\", 8) \n     && 0==sqlite3Fts3IsIdChar(z[8])\n    ){\n      rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);\n    }\n\n    /* Check if it is an FTS4 special argument. */\n    else if( isFts4 && fts3IsSpecialColumn(z, &nKey, &zVal) ){\n      struct Fts4Option {\n        const char *zOpt;\n        int nOpt;\n      } aFts4Opt[] = {\n        { \"matchinfo\",   9 },     /* 0 -> MATCHINFO */\n        { \"prefix\",      6 },     /* 1 -> PREFIX */\n        { \"compress\",    8 },     /* 2 -> COMPRESS */\n        { \"uncompress\", 10 },     /* 3 -> UNCOMPRESS */\n        { \"order\",       5 },     /* 4 -> ORDER */\n        { \"content\",     7 },     /* 5 -> CONTENT */\n        { \"languageid\", 10 },     /* 6 -> LANGUAGEID */\n        { \"notindexed\", 10 }      /* 7 -> NOTINDEXED */\n      };\n\n      int iOpt;\n      if( !zVal ){\n        rc = SQLITE_NOMEM;\n      }else{\n        for(iOpt=0; iOpt<SizeofArray(aFts4Opt); iOpt++){\n          struct Fts4Option *pOp = &aFts4Opt[iOpt];\n          if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){\n            break;\n          }\n        }\n        switch( iOpt ){\n          case 0:               /* MATCHINFO */\n            if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"fts3\", 4) ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bNoDocsize = 1;\n            break;\n\n          case 1:               /* PREFIX */\n            sqlite3_free(zPrefix);\n            zPrefix = zVal;\n            zVal = 0;\n            break;\n\n          case 2:               /* COMPRESS */\n            sqlite3_free(zCompress);\n            zCompress = zVal;\n            zVal = 0;\n            break;\n\n          case 3:               /* UNCOMPRESS */\n            sqlite3_free(zUncompress);\n            zUncompress = zVal;\n            zVal = 0;\n            break;\n\n          case 4:               /* ORDER */\n            if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, \"asc\", 3)) \n             && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"desc\", 4)) \n            ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized order: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bDescIdx = (zVal[0]=='d' || zVal[0]=='D');\n            break;\n\n          case 5:              /* CONTENT */\n            sqlite3_free(zContent);\n            zContent = zVal;\n            zVal = 0;\n            break;\n\n          case 6:              /* LANGUAGEID */\n            assert( iOpt==6 );\n            sqlite3_free(zLanguageid);\n            zLanguageid = zVal;\n            zVal = 0;\n            break;\n\n          case 7:              /* NOTINDEXED */\n            azNotindexed[nNotindexed++] = zVal;\n            zVal = 0;\n            break;\n\n          default:\n            assert( iOpt==SizeofArray(aFts4Opt) );\n            sqlite3Fts3ErrMsg(pzErr, \"unrecognized parameter: %s\", z);\n            rc = SQLITE_ERROR;\n            break;\n        }\n        sqlite3_free(zVal);\n      }\n    }\n\n    /* Otherwise, the argument is a column name. */\n    else {\n      nString += (int)(strlen(z) + 1);\n      aCol[nCol++] = z;\n    }\n  }\n\n  /* If a content=xxx option was specified, the following:\n  **\n  **   1. Ignore any compress= and uncompress= options.\n  **\n  **   2. If no column names were specified as part of the CREATE VIRTUAL\n  **      TABLE statement, use all columns from the content table.\n  */\n  if( rc==SQLITE_OK && zContent ){\n    sqlite3_free(zCompress); \n    sqlite3_free(zUncompress); \n    zCompress = 0;\n    zUncompress = 0;\n    if( nCol==0 ){\n      sqlite3_free((void*)aCol); \n      aCol = 0;\n      rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);\n\n      /* If a languageid= option was specified, remove the language id\n      ** column from the aCol[] array. */ \n      if( rc==SQLITE_OK && zLanguageid ){\n        int j;\n        for(j=0; j<nCol; j++){\n          if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){\n            int k;\n            for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];\n            nCol--;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  if( nCol==0 ){\n    assert( nString==0 );\n    aCol[0] = \"content\";\n    nString = 8;\n    nCol = 1;\n  }\n\n  if( pTokenizer==0 ){\n    rc = sqlite3Fts3InitTokenizer(pHash, \"simple\", &pTokenizer, pzErr);\n    if( rc!=SQLITE_OK ) goto fts3_init_out;\n  }\n  assert( pTokenizer );\n\n  rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);\n  if( rc==SQLITE_ERROR ){\n    assert( zPrefix );\n    sqlite3Fts3ErrMsg(pzErr, \"error parsing prefix parameter: %s\", zPrefix);\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* Allocate and populate the Fts3Table structure. */\n  nByte = sizeof(Fts3Table) +                  /* Fts3Table */\n          nCol * sizeof(char *) +              /* azColumn */\n          nIndex * sizeof(struct Fts3Index) +  /* aIndex */\n          nCol * sizeof(u8) +                  /* abNotindexed */\n          nName +                              /* zName */\n          nDb +                                /* zDb */\n          nString;                             /* Space for azColumn strings */\n  p = (Fts3Table*)sqlite3_malloc(nByte);\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n  memset(p, 0, nByte);\n  p->db = db;\n  p->nColumn = nCol;\n  p->nPendingData = 0;\n  p->azColumn = (char **)&p[1];\n  p->pTokenizer = pTokenizer;\n  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;\n  p->bHasDocsize = (isFts4 && bNoDocsize==0);\n  p->bHasStat = (u8)isFts4;\n  p->bFts4 = (u8)isFts4;\n  p->bDescIdx = (u8)bDescIdx;\n  p->nAutoincrmerge = 0xff;   /* 0xff means setting unknown */\n  p->zContentTbl = zContent;\n  p->zLanguageid = zLanguageid;\n  zContent = 0;\n  zLanguageid = 0;\n  TESTONLY( p->inTransaction = -1 );\n  TESTONLY( p->mxSavepoint = -1 );\n\n  p->aIndex = (struct Fts3Index *)&p->azColumn[nCol];\n  memcpy(p->aIndex, aIndex, sizeof(struct Fts3Index) * nIndex);\n  p->nIndex = nIndex;\n  for(i=0; i<nIndex; i++){\n    fts3HashInit(&p->aIndex[i].hPending, FTS3_HASH_STRING, 1);\n  }\n  p->abNotindexed = (u8 *)&p->aIndex[nIndex];\n\n  /* Fill in the zName and zDb fields of the vtab structure. */\n  zCsr = (char *)&p->abNotindexed[nCol];\n  p->zName = zCsr;\n  memcpy(zCsr, argv[2], nName);\n  zCsr += nName;\n  p->zDb = zCsr;\n  memcpy(zCsr, argv[1], nDb);\n  zCsr += nDb;\n\n  /* Fill in the azColumn array */\n  for(iCol=0; iCol<nCol; iCol++){\n    char *z; \n    int n = 0;\n    z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);\n    if( n>0 ){\n      memcpy(zCsr, z, n);\n    }\n    zCsr[n] = '\\0';\n    sqlite3Fts3Dequote(zCsr);\n    p->azColumn[iCol] = zCsr;\n    zCsr += n+1;\n    assert( zCsr <= &((char *)p)[nByte] );\n  }\n\n  /* Fill in the abNotindexed array */\n  for(iCol=0; iCol<nCol; iCol++){\n    int n = (int)strlen(p->azColumn[iCol]);\n    for(i=0; i<nNotindexed; i++){\n      char *zNot = azNotindexed[i];\n      if( zNot && n==(int)strlen(zNot)\n       && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) \n      ){\n        p->abNotindexed[iCol] = 1;\n        sqlite3_free(zNot);\n        azNotindexed[i] = 0;\n      }\n    }\n  }\n  for(i=0; i<nNotindexed; i++){\n    if( azNotindexed[i] ){\n      sqlite3Fts3ErrMsg(pzErr, \"no such column: %s\", azNotindexed[i]);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){\n    char const *zMiss = (zCompress==0 ? \"compress\" : \"uncompress\");\n    rc = SQLITE_ERROR;\n    sqlite3Fts3ErrMsg(pzErr, \"missing %s parameter in fts4 constructor\", zMiss);\n  }\n  p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);\n  p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* If this is an xCreate call, create the underlying tables in the \n  ** database. TODO: For xConnect(), it could verify that said tables exist.\n  */\n  if( isCreate ){\n    rc = fts3CreateTables(p);\n  }\n\n  /* Check to see if a legacy fts3 table has been \"upgraded\" by the\n  ** addition of a %_stat table so that it can use incremental merge.\n  */\n  if( !isFts4 && !isCreate ){\n    p->bHasStat = 2;\n  }\n\n  /* Figure out the page-size for the database. This is required in order to\n  ** estimate the cost of loading large doclists from the database.  */\n  fts3DatabasePageSize(&rc, p);\n  p->nNodeSize = p->nPgsz-35;\n\n  /* Declare the table schema to SQLite. */\n  fts3DeclareVtab(&rc, p);\n\nfts3_init_out:\n  sqlite3_free(zPrefix);\n  sqlite3_free(aIndex);\n  sqlite3_free(zCompress);\n  sqlite3_free(zUncompress);\n  sqlite3_free(zContent);\n  sqlite3_free(zLanguageid);\n  for(i=0; i<nNotindexed; i++) sqlite3_free(azNotindexed[i]);\n  sqlite3_free((void *)aCol);\n  sqlite3_free((void *)azNotindexed);\n  if( rc!=SQLITE_OK ){\n    if( p ){\n      fts3DisconnectMethod((sqlite3_vtab *)p);\n    }else if( pTokenizer ){\n      pTokenizer->pModule->xDestroy(pTokenizer);\n    }\n  }else{\n    assert( p->pSegments==0 );\n    *ppVTab = &p->base;\n  }\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts3InitVtab().\n*/\nstatic int fts3ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts3CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** Set the pIdxInfo->estimatedRows variable to nRow. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support estimatedRows. In that case this function is a no-op.\n*/\nstatic void fts3SetEstimatedRows(sqlite3_index_info *pIdxInfo, i64 nRow){\n#if SQLITE_VERSION_NUMBER>=3008002\n  if( sqlite3_libversion_number()>=3008002 ){\n    pIdxInfo->estimatedRows = nRow;\n  }\n#endif\n}\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts3SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n  if( sqlite3_libversion_number()>=3008012 ){\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/* \n** Implementation of the xBestIndex method for FTS3 tables. There\n** are three possible strategies, in order of preference:\n**\n**   1. Direct lookup by rowid or docid. \n**   2. Full-text search using a MATCH operator on a non-docid column.\n**   3. Linear scan of %_content table.\n*/\nstatic int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts3Table *p = (Fts3Table *)pVTab;\n  int i;                          /* Iterator variable */\n  int iCons = -1;                 /* Index of constraint to use */\n\n  int iLangidCons = -1;           /* Index of langid=x constraint, if present */\n  int iDocidGe = -1;              /* Index of docid>=x constraint, if present */\n  int iDocidLe = -1;              /* Index of docid<=x constraint, if present */\n  int iIdx;\n\n  /* By default use a full table scan. This is an expensive option,\n  ** so search through the constraints to see if a more efficient \n  ** strategy is possible.\n  */\n  pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n  pInfo->estimatedCost = 5000000;\n  for(i=0; i<pInfo->nConstraint; i++){\n    int bDocid;                 /* True if this constraint is on docid */\n    struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];\n    if( pCons->usable==0 ){\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n        /* There exists an unusable MATCH constraint. This means that if\n        ** the planner does elect to use the results of this call as part\n        ** of the overall query plan the user will see an \"unable to use\n        ** function MATCH in the requested context\" error. To discourage\n        ** this, return a very high cost here.  */\n        pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n        pInfo->estimatedCost = 1e50;\n        fts3SetEstimatedRows(pInfo, ((sqlite3_int64)1) << 50);\n        return SQLITE_OK;\n      }\n      continue;\n    }\n\n    bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);\n\n    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */\n    if( iCons<0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && bDocid ){\n      pInfo->idxNum = FTS3_DOCID_SEARCH;\n      pInfo->estimatedCost = 1.0;\n      iCons = i;\n    }\n\n    /* A MATCH constraint. Use a full-text search.\n    **\n    ** If there is more than one MATCH constraint available, use the first\n    ** one encountered. If there is both a MATCH constraint and a direct\n    ** rowid/docid lookup, prefer the MATCH strategy. This is done even \n    ** though the rowid/docid lookup is faster than a MATCH query, selecting\n    ** it would lead to an \"unable to use function MATCH in the requested \n    ** context\" error.\n    */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH \n     && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn\n    ){\n      pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;\n      pInfo->estimatedCost = 2.0;\n      iCons = i;\n    }\n\n    /* Equality constraint on the langid column */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ \n     && pCons->iColumn==p->nColumn + 2\n    ){\n      iLangidCons = i;\n    }\n\n    if( bDocid ){\n      switch( pCons->op ){\n        case SQLITE_INDEX_CONSTRAINT_GE:\n        case SQLITE_INDEX_CONSTRAINT_GT:\n          iDocidGe = i;\n          break;\n\n        case SQLITE_INDEX_CONSTRAINT_LE:\n        case SQLITE_INDEX_CONSTRAINT_LT:\n          iDocidLe = i;\n          break;\n      }\n    }\n  }\n\n  /* If using a docid=? or rowid=? strategy, set the UNIQUE flag. */\n  if( pInfo->idxNum==FTS3_DOCID_SEARCH ) fts3SetUniqueFlag(pInfo);\n\n  iIdx = 1;\n  if( iCons>=0 ){\n    pInfo->aConstraintUsage[iCons].argvIndex = iIdx++;\n    pInfo->aConstraintUsage[iCons].omit = 1;\n  } \n  if( iLangidCons>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_LANGID;\n    pInfo->aConstraintUsage[iLangidCons].argvIndex = iIdx++;\n  } \n  if( iDocidGe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_GE;\n    pInfo->aConstraintUsage[iDocidGe].argvIndex = iIdx++;\n  } \n  if( iDocidLe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_LE;\n    pInfo->aConstraintUsage[iDocidLe].argvIndex = iIdx++;\n  } \n\n  /* Regardless of the strategy selected, FTS can deliver rows in rowid (or\n  ** docid) order. Both ascending and descending are possible. \n  */\n  if( pInfo->nOrderBy==1 ){\n    struct sqlite3_index_orderby *pOrder = &pInfo->aOrderBy[0];\n    if( pOrder->iColumn<0 || pOrder->iColumn==p->nColumn+1 ){\n      if( pOrder->desc ){\n        pInfo->idxStr = \"DESC\";\n      }else{\n        pInfo->idxStr = \"ASC\";\n      }\n      pInfo->orderByConsumed = 1;\n    }\n  }\n\n  assert( p->pSegments==0 );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts3OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  sqlite3_vtab_cursor *pCsr;               /* Allocated cursor */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* Allocate a buffer large enough for an Fts3Cursor structure. If the\n  ** allocation succeeds, zero it and return SQLITE_OK. Otherwise, \n  ** if the allocation fails, return SQLITE_NOMEM.\n  */\n  *ppCsr = pCsr = (sqlite3_vtab_cursor *)sqlite3_malloc(sizeof(Fts3Cursor));\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3Cursor));\n  return SQLITE_OK;\n}\n\n/*\n** Finalize the statement handle at pCsr->pStmt.\n**\n** Or, if that statement handle is one created by fts3CursorSeekStmt(),\n** and the Fts3Table.pSeekStmt slot is currently NULL, save the statement\n** pointer there instead of finalizing it.\n*/\nstatic void fts3CursorFinalizeStmt(Fts3Cursor *pCsr){\n  if( pCsr->bSeekStmt ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    if( p->pSeekStmt==0 ){\n      p->pSeekStmt = pCsr->pStmt;\n      sqlite3_reset(pCsr->pStmt);\n      pCsr->pStmt = 0;\n    }\n    pCsr->bSeekStmt = 0;\n  }\n  sqlite3_finalize(pCsr->pStmt);\n}\n\n/*\n** Free all resources currently held by the cursor passed as the only\n** argument.\n*/\nstatic void fts3ClearCursor(Fts3Cursor *pCsr){\n  fts3CursorFinalizeStmt(pCsr);\n  sqlite3Fts3FreeDeferredTokens(pCsr);\n  sqlite3_free(pCsr->aDoclist);\n  sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n  sqlite3Fts3ExprFree(pCsr->pExpr);\n  memset(&(&pCsr->base)[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  fts3ClearCursor(pCsr);\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** If pCsr->pStmt has not been prepared (i.e. if pCsr->pStmt==0), then\n** compose and prepare an SQL statement of the form:\n**\n**    \"SELECT <columns> FROM %_content WHERE rowid = ?\"\n**\n** (or the equivalent for a content=xxx table) and set pCsr->pStmt to\n** it. If an error occurs, return an SQLite error code.\n*/\nstatic int fts3CursorSeekStmt(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->pStmt==0 ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    char *zSql;\n    if( p->pSeekStmt ){\n      pCsr->pStmt = p->pSeekStmt;\n      p->pSeekStmt = 0;\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s WHERE rowid = ?\", p->zReadExprlist);\n      if( !zSql ) return SQLITE_NOMEM;\n      rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }\n    if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;\n  }\n  return rc;\n}\n\n/*\n** Position the pCsr->pStmt statement so that it is on the row\n** of the %_content table that contains the last match.  Return\n** SQLITE_OK on success.  \n*/\nstatic int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->isRequireSeek ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);\n      pCsr->isRequireSeek = 0;\n      if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){\n        return SQLITE_OK;\n      }else{\n        rc = sqlite3_reset(pCsr->pStmt);\n        if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){\n          /* If no row was found and no error has occurred, then the %_content\n          ** table is missing a row that is present in the full-text index.\n          ** The data structures are corrupt.  */\n          rc = FTS_CORRUPT_VTAB;\n          pCsr->isEof = 1;\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK && pContext ){\n    sqlite3_result_error_code(pContext, rc);\n  }\n  return rc;\n}\n\n/*\n** This function is used to process a single interior node when searching\n** a b-tree for a term or term prefix. The node data is passed to this \n** function via the zNode/nNode parameters. The term to search for is\n** passed in zTerm/nTerm.\n**\n** If piFirst is not NULL, then this function sets *piFirst to the blockid\n** of the child node that heads the sub-tree that may contain the term.\n**\n** If piLast is not NULL, then *piLast is set to the right-most child node\n** that heads a sub-tree that may contain a term for which zTerm/nTerm is\n** a prefix.\n**\n** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3ScanInteriorNode(\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piFirst,         /* OUT: Selected child node */\n  sqlite3_int64 *piLast           /* OUT: Selected child node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *zCsr = zNode;       /* Cursor to iterate through node */\n  const char *zEnd = &zCsr[nNode];/* End of interior node buffer */\n  char *zBuffer = 0;              /* Buffer to load terms into */\n  int nAlloc = 0;                 /* Size of allocated buffer */\n  int isFirstTerm = 1;            /* True when processing first term on page */\n  sqlite3_int64 iChild;           /* Block id of child node to descend to */\n\n  /* Skip over the 'height' varint that occurs at the start of every \n  ** interior node. Then load the blockid of the left-child of the b-tree\n  ** node into variable iChild.  \n  **\n  ** Even if the data structure on disk is corrupted, this (reading two\n  ** varints from the buffer) does not risk an overread. If zNode is a\n  ** root node, then the buffer comes from a SELECT statement. SQLite does\n  ** not make this guarantee explicitly, but in practice there are always\n  ** either more than 20 bytes of allocated space following the nNode bytes of\n  ** contents, or two zero bytes. Or, if the node is read from the %_segments\n  ** table, then there are always 20 bytes of zeroed padding following the\n  ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).\n  */\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  if( zCsr>zEnd ){\n    return FTS_CORRUPT_VTAB;\n  }\n  \n  while( zCsr<zEnd && (piFirst || piLast) ){\n    int cmp;                      /* memcmp() result */\n    int nSuffix;                  /* Size of term suffix */\n    int nPrefix = 0;              /* Size of term prefix */\n    int nBuffer;                  /* Total term size */\n  \n    /* Load the next term on the node into zBuffer. Use realloc() to expand\n    ** the size of zBuffer if required.  */\n    if( !isFirstTerm ){\n      zCsr += fts3GetVarint32(zCsr, &nPrefix);\n    }\n    isFirstTerm = 0;\n    zCsr += fts3GetVarint32(zCsr, &nSuffix);\n    \n    assert( nPrefix>=0 && nSuffix>=0 );\n    if( &zCsr[nSuffix]>zEnd ){\n      rc = FTS_CORRUPT_VTAB;\n      goto finish_scan;\n    }\n    if( nPrefix+nSuffix>nAlloc ){\n      char *zNew;\n      nAlloc = (nPrefix+nSuffix) * 2;\n      zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);\n      if( !zNew ){\n        rc = SQLITE_NOMEM;\n        goto finish_scan;\n      }\n      zBuffer = zNew;\n    }\n    assert( zBuffer );\n    memcpy(&zBuffer[nPrefix], zCsr, nSuffix);\n    nBuffer = nPrefix + nSuffix;\n    zCsr += nSuffix;\n\n    /* Compare the term we are searching for with the term just loaded from\n    ** the interior node. If the specified term is greater than or equal\n    ** to the term from the interior node, then all terms on the sub-tree \n    ** headed by node iChild are smaller than zTerm. No need to search \n    ** iChild.\n    **\n    ** If the interior node term is larger than the specified term, then\n    ** the tree headed by iChild may contain the specified term.\n    */\n    cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));\n    if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){\n      *piFirst = iChild;\n      piFirst = 0;\n    }\n\n    if( piLast && cmp<0 ){\n      *piLast = iChild;\n      piLast = 0;\n    }\n\n    iChild++;\n  };\n\n  if( piFirst ) *piFirst = iChild;\n  if( piLast ) *piLast = iChild;\n\n finish_scan:\n  sqlite3_free(zBuffer);\n  return rc;\n}\n\n\n/*\n** The buffer pointed to by argument zNode (size nNode bytes) contains an\n** interior node of a b-tree segment. The zTerm buffer (size nTerm bytes)\n** contains a term. This function searches the sub-tree headed by the zNode\n** node for the range of leaf nodes that may contain the specified term\n** or terms for which the specified term is a prefix.\n**\n** If piLeaf is not NULL, then *piLeaf is set to the blockid of the \n** left-most leaf node in the tree that may contain the specified term.\n** If piLeaf2 is not NULL, then *piLeaf2 is set to the blockid of the\n** right-most leaf node that may contain a term for which the specified\n** term is a prefix.\n**\n** It is possible that the range of returned leaf nodes does not contain \n** the specified term or any terms for which it is a prefix. However, if the \n** segment does contain any such terms, they are stored within the identified\n** range. Because this function only inspects interior segment nodes (and\n** never loads leaf nodes into memory), it is not possible to be sure.\n**\n** If an error occurs, an error code other than SQLITE_OK is returned.\n*/ \nstatic int fts3SelectLeaf(\n  Fts3Table *p,                   /* Virtual table handle */\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piLeaf,          /* Selected leaf node */\n  sqlite3_int64 *piLeaf2          /* Selected leaf node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int iHeight;                    /* Height of this node in tree */\n\n  assert( piLeaf || piLeaf2 );\n\n  fts3GetVarint32(zNode, &iHeight);\n  rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);\n  assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );\n\n  if( rc==SQLITE_OK && iHeight>1 ){\n    char *zBlob = 0;              /* Blob read from %_segments table */\n    int nBlob = 0;                /* Size of zBlob in bytes */\n\n    if( piLeaf && piLeaf2 && (*piLeaf!=*piLeaf2) ){\n      rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);\n      if( rc==SQLITE_OK ){\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, 0);\n      }\n      sqlite3_free(zBlob);\n      piLeaf = 0;\n      zBlob = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);\n    }\n    sqlite3_free(zBlob);\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to create delta-encoded serialized lists of FTS3 \n** varints. Each call to this function appends a single varint to a list.\n*/\nstatic void fts3PutDeltaVarint(\n  char **pp,                      /* IN/OUT: Output pointer */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );\n  *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);\n  *piPrev = iVal;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a position-list. After it returns, *ppPoslist points to the\n** first byte after the position-list.\n**\n** A position list is list of positions (delta encoded) and columns for \n** a single document record of a doclist.  So, in other words, this\n** routine advances *ppPoslist so that it points to the next docid in\n** the doclist, or to the first byte past the end of the doclist.\n**\n** If pp is not NULL, then the contents of the position list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.\n*/\nstatic void fts3PoslistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* The end of a position list is marked by a zero encoded as an FTS3 \n  ** varint. A single POS_END (0) byte. Except, if the 0 byte is preceded by\n  ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail\n  ** of some other, multi-byte, value.\n  **\n  ** The following while-loop moves pEnd to point to the first byte that is not \n  ** immediately preceded by a byte with the 0x80 bit set. Then increments\n  ** pEnd once more so that it points to the byte immediately following the\n  ** last byte in the position-list.\n  */\n  while( *pEnd | c ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && (*pEnd)==0 );\n  }\n  pEnd++;  /* Advance past the POS_END terminator byte */\n\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a column-list. After it returns, *ppPoslist points to the\n** to the terminator (POS_COLUMN or POS_END) byte of the column-list.\n**\n** A column-list is list of delta-encoded positions for a single column\n** within a single document within a doclist.\n**\n** The column-list is terminated either by a POS_COLUMN varint (1) or\n** a POS_END varint (0).  This routine leaves *ppPoslist pointing to\n** the POS_COLUMN or POS_END that terminates the column-list.\n**\n** If pp is not NULL, then the contents of the column-list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.  The POS_COLUMN or POS_END terminator\n** is not copied into *pp.\n*/\nstatic void fts3ColumnlistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00 byte that is\n  ** not part of a multi-byte varint.\n  */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && ((*pEnd)&0xfe)==0 );\n  }\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** Value used to signify the end of an position-list. This is safe because\n** it is not possible to have a document with 2^31 terms.\n*/\n#define POSITION_LIST_END 0x7fffffff\n\n/*\n** This function is used to help parse position-lists. When this function is\n** called, *pp may point to the start of the next varint in the position-list\n** being parsed, or it may point to 1 byte past the end of the position-list\n** (in which case **pp will be a terminator bytes POS_END (0) or\n** (1)).\n**\n** If *pp points past the end of the current position-list, set *pi to \n** POSITION_LIST_END and return. Otherwise, read the next varint from *pp,\n** increment the current value of *pi by the value read, and set *pp to\n** point to the next value before returning.\n**\n** Before calling this routine *pi must be initialized to the value of\n** the previous position, or zero if we are reading the first position\n** in the position-list.  Because positions are delta-encoded, the value\n** of the previous position is needed in order to compute the value of\n** the next position.\n*/\nstatic void fts3ReadNextPos(\n  char **pp,                    /* IN/OUT: Pointer into position-list buffer */\n  sqlite3_int64 *pi             /* IN/OUT: Value read from position-list */\n){\n  if( (**pp)&0xFE ){\n    fts3GetDeltaVarint(pp, pi);\n    *pi -= 2;\n  }else{\n    *pi = POSITION_LIST_END;\n  }\n}\n\n/*\n** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by\n** the value of iCol encoded as a varint to *pp.   This will start a new\n** column list.\n**\n** Set *pp to point to the byte just after the last byte written before \n** returning (do not modify it if iCol==0). Return the total number of bytes\n** written (0 if iCol==0).\n*/\nstatic int fts3PutColNumber(char **pp, int iCol){\n  int n = 0;                      /* Number of bytes written */\n  if( iCol ){\n    char *p = *pp;                /* Output pointer */\n    n = 1 + sqlite3Fts3PutVarint(&p[1], iCol);\n    *p = 0x01;\n    *pp = &p[n];\n  }\n  return n;\n}\n\n/*\n** Compute the union of two position lists.  The output written\n** into *pp contains all positions of both *pp1 and *pp2 in sorted\n** order and with any duplicates removed.  All pointers are\n** updated appropriately.   The caller is responsible for insuring\n** that there is enough space in *pp to hold the complete output.\n*/\nstatic void fts3PoslistMerge(\n  char **pp,                      /* Output buffer */\n  char **pp1,                     /* Left input list */\n  char **pp2                      /* Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  while( *p1 || *p2 ){\n    int iCol1;         /* The current column index in pp1 */\n    int iCol2;         /* The current column index in pp2 */\n\n    if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);\n    else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;\n    else iCol1 = 0;\n\n    if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);\n    else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;\n    else iCol2 = 0;\n\n    if( iCol1==iCol2 ){\n      sqlite3_int64 i1 = 0;       /* Last position from pp1 */\n      sqlite3_int64 i2 = 0;       /* Last position from pp2 */\n      sqlite3_int64 iPrev = 0;\n      int n = fts3PutColNumber(&p, iCol1);\n      p1 += n;\n      p2 += n;\n\n      /* At this point, both p1 and p2 point to the start of column-lists\n      ** for the same column (the column with index iCol1 and iCol2).\n      ** A column-list is a list of non-negative delta-encoded varints, each \n      ** incremented by 2 before being stored. Each list is terminated by a\n      ** POS_END (0) or POS_COLUMN (1). The following block merges the two lists\n      ** and writes the results to buffer p. p is left pointing to the byte\n      ** after the list written. No terminator (POS_END or POS_COLUMN) is\n      ** written to the output.\n      */\n      fts3GetDeltaVarint(&p1, &i1);\n      fts3GetDeltaVarint(&p2, &i2);\n      do {\n        fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2); \n        iPrev -= 2;\n        if( i1==i2 ){\n          fts3ReadNextPos(&p1, &i1);\n          fts3ReadNextPos(&p2, &i2);\n        }else if( i1<i2 ){\n          fts3ReadNextPos(&p1, &i1);\n        }else{\n          fts3ReadNextPos(&p2, &i2);\n        }\n      }while( i1!=POSITION_LIST_END || i2!=POSITION_LIST_END );\n    }else if( iCol1<iCol2 ){\n      p1 += fts3PutColNumber(&p, iCol1);\n      fts3ColumnlistCopy(&p, &p1);\n    }else{\n      p2 += fts3PutColNumber(&p, iCol2);\n      fts3ColumnlistCopy(&p, &p2);\n    }\n  }\n\n  *p++ = POS_END;\n  *pp = p;\n  *pp1 = p1 + 1;\n  *pp2 = p2 + 1;\n}\n\n/*\n** This function is used to merge two position lists into one. When it is\n** called, *pp1 and *pp2 must both point to position lists. A position-list is\n** the part of a doclist that follows each document id. For example, if a row\n** contains:\n**\n**     'a b c'|'x y z'|'a b b a'\n**\n** Then the position list for this row for token 'b' would consist of:\n**\n**     0x02 0x01 0x02 0x03 0x03 0x00\n**\n** When this function returns, both *pp1 and *pp2 are left pointing to the\n** byte following the 0x00 terminator of their respective position lists.\n**\n** If isSaveLeft is 0, an entry is added to the output position list for \n** each position in *pp2 for which there exists one or more positions in\n** *pp1 so that (pos(*pp2)>pos(*pp1) && pos(*pp2)-pos(*pp1)<=nToken). i.e.\n** when the *pp1 token appears before the *pp2 token, but not more than nToken\n** slots before it.\n**\n** e.g. nToken==1 searches for adjacent positions.\n*/\nstatic int fts3PoslistPhraseMerge(\n  char **pp,                      /* IN/OUT: Preallocated output buffer */\n  int nToken,                     /* Maximum difference in token positions */\n  int isSaveLeft,                 /* Save the left position */\n  int isExact,                    /* If *pp1 is exactly nTokens before *pp2 */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n  int iCol1 = 0;\n  int iCol2 = 0;\n\n  /* Never set both isSaveLeft and isExact for the same invocation. */\n  assert( isSaveLeft==0 || isExact==0 );\n\n  assert( p!=0 && *p1!=0 && *p2!=0 );\n  if( *p1==POS_COLUMN ){ \n    p1++;\n    p1 += fts3GetVarint32(p1, &iCol1);\n  }\n  if( *p2==POS_COLUMN ){ \n    p2++;\n    p2 += fts3GetVarint32(p2, &iCol2);\n  }\n\n  while( 1 ){\n    if( iCol1==iCol2 ){\n      char *pSave = p;\n      sqlite3_int64 iPrev = 0;\n      sqlite3_int64 iPos1 = 0;\n      sqlite3_int64 iPos2 = 0;\n\n      if( iCol1 ){\n        *p++ = POS_COLUMN;\n        p += sqlite3Fts3PutVarint(p, iCol1);\n      }\n\n      assert( *p1!=POS_END && *p1!=POS_COLUMN );\n      assert( *p2!=POS_END && *p2!=POS_COLUMN );\n      fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n      fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n\n      while( 1 ){\n        if( iPos2==iPos1+nToken \n         || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) \n        ){\n          sqlite3_int64 iSave;\n          iSave = isSaveLeft ? iPos1 : iPos2;\n          fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2;\n          pSave = 0;\n          assert( p );\n        }\n        if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){\n          if( (*p2&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n        }else{\n          if( (*p1&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n        }\n      }\n\n      if( pSave ){\n        assert( pp && p );\n        p = pSave;\n      }\n\n      fts3ColumnlistCopy(0, &p1);\n      fts3ColumnlistCopy(0, &p2);\n      assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );\n      if( 0==*p1 || 0==*p2 ) break;\n\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n\n    /* Advance pointer p1 or p2 (whichever corresponds to the smaller of\n    ** iCol1 and iCol2) so that it points to either the 0x00 that marks the\n    ** end of the position list, or the 0x01 that precedes the next \n    ** column-number in the position list. \n    */\n    else if( iCol1<iCol2 ){\n      fts3ColumnlistCopy(0, &p1);\n      if( 0==*p1 ) break;\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n    }else{\n      fts3ColumnlistCopy(0, &p2);\n      if( 0==*p2 ) break;\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n  }\n\n  fts3PoslistCopy(0, &p2);\n  fts3PoslistCopy(0, &p1);\n  *pp1 = p1;\n  *pp2 = p2;\n  if( *pp==p ){\n    return 0;\n  }\n  *p++ = 0x00;\n  *pp = p;\n  return 1;\n}\n\n/*\n** Merge two position-lists as required by the NEAR operator. The argument\n** position lists correspond to the left and right phrases of an expression \n** like:\n**\n**     \"phrase 1\" NEAR \"phrase number 2\"\n**\n** Position list *pp1 corresponds to the left-hand side of the NEAR \n** expression and *pp2 to the right. As usual, the indexes in the position \n** lists are the offsets of the last token in each phrase (tokens \"1\" and \"2\" \n** in the example above).\n**\n** The output position list - written to *pp - is a copy of *pp2 with those\n** entries that are not sufficiently NEAR entries in *pp1 removed.\n*/\nstatic int fts3PoslistNearMerge(\n  char **pp,                      /* Output buffer */\n  char *aTmp,                     /* Temporary buffer space */\n  int nRight,                     /* Maximum difference in token positions */\n  int nLeft,                      /* Maximum difference in token positions */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  char *pTmp1 = aTmp;\n  char *pTmp2;\n  char *aTmp2;\n  int res = 1;\n\n  fts3PoslistPhraseMerge(&pTmp1, nRight, 0, 0, pp1, pp2);\n  aTmp2 = pTmp2 = pTmp1;\n  *pp1 = p1;\n  *pp2 = p2;\n  fts3PoslistPhraseMerge(&pTmp2, nLeft, 1, 0, pp2, pp1);\n  if( pTmp1!=aTmp && pTmp2!=aTmp2 ){\n    fts3PoslistMerge(pp, &aTmp, &aTmp2);\n  }else if( pTmp1!=aTmp ){\n    fts3PoslistCopy(pp, &aTmp);\n  }else if( pTmp2!=aTmp2 ){\n    fts3PoslistCopy(pp, &aTmp2);\n  }else{\n    res = 0;\n  }\n\n  return res;\n}\n\n/* \n** An instance of this function is used to merge together the (potentially\n** large number of) doclists for each term that matches a prefix query.\n** See function fts3TermSelectMerge() for details.\n*/\ntypedef struct TermSelect TermSelect;\nstruct TermSelect {\n  char *aaOutput[16];             /* Malloc'd output buffers */\n  int anOutput[16];               /* Size each output buffer in bytes */\n};\n\n/*\n** This function is used to read a single varint from a buffer. Parameter\n** pEnd points 1 byte past the end of the buffer. When this function is\n** called, if *pp points to pEnd or greater, then the end of the buffer\n** has been reached. In this case *pp is set to 0 and the function returns.\n**\n** If *pp does not point to or past pEnd, then a single varint is read\n** from *pp. *pp is then set to point 1 byte past the end of the read varint.\n**\n** If bDescIdx is false, the value read is added to *pVal before returning.\n** If it is true, the value read is subtracted from *pVal before this \n** function returns.\n*/\nstatic void fts3GetDeltaVarint3(\n  char **pp,                      /* IN/OUT: Point to read varint from */\n  char *pEnd,                     /* End of buffer */\n  int bDescIdx,                   /* True if docids are descending */\n  sqlite3_int64 *pVal             /* IN/OUT: Integer value */\n){\n  if( *pp>=pEnd ){\n    *pp = 0;\n  }else{\n    sqlite3_int64 iVal;\n    *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n    if( bDescIdx ){\n      *pVal -= iVal;\n    }else{\n      *pVal += iVal;\n    }\n  }\n}\n\n/*\n** This function is used to write a single varint to a buffer. The varint\n** is written to *pp. Before returning, *pp is set to point 1 byte past the\n** end of the value written.\n**\n** If *pbFirst is zero when this function is called, the value written to\n** the buffer is that of parameter iVal. \n**\n** If *pbFirst is non-zero when this function is called, then the value \n** written is either (iVal-*piPrev) (if bDescIdx is zero) or (*piPrev-iVal)\n** (if bDescIdx is non-zero).\n**\n** Before returning, this function always sets *pbFirst to 1 and *piPrev\n** to the value of parameter iVal.\n*/\nstatic void fts3PutDeltaVarint3(\n  char **pp,                      /* IN/OUT: Output pointer */\n  int bDescIdx,                   /* True for descending docids */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  int *pbFirst,                   /* IN/OUT: True after first int written */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  sqlite3_int64 iWrite;\n  if( bDescIdx==0 || *pbFirst==0 ){\n    iWrite = iVal - *piPrev;\n  }else{\n    iWrite = *piPrev - iVal;\n  }\n  assert( *pbFirst || *piPrev==0 );\n  assert( *pbFirst==0 || iWrite>0 );\n  *pp += sqlite3Fts3PutVarint(*pp, iWrite);\n  *piPrev = iVal;\n  *pbFirst = 1;\n}\n\n\n/*\n** This macro is used by various functions that merge doclists. The two\n** arguments are 64-bit docid values. If the value of the stack variable\n** bDescDoclist is 0 when this macro is invoked, then it returns (i1-i2). \n** Otherwise, (i2-i1).\n**\n** Using this makes it easier to write code that can merge doclists that are\n** sorted in either ascending or descending order.\n*/\n#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))\n\n/*\n** This function does an \"OR\" merge of two doclists (output contains all\n** positions contained in either argument doclist). If the docids in the \n** input doclists are sorted in ascending order, parameter bDescDoclist\n** should be false. If they are sorted in ascending order, it should be\n** passed a non-zero value.\n**\n** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer\n** containing the output doclist and SQLITE_OK is returned. In this case\n** *pnOut is set to the number of bytes in the output doclist.\n**\n** If an error occurs, an SQLite error code is returned. The output values\n** are undefined in this case.\n*/\nstatic int fts3DoclistOrMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  char *a1, int n1,               /* First doclist */\n  char *a2, int n2,               /* Second doclist */\n  char **paOut, int *pnOut        /* OUT: Malloc'd doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *pEnd1 = &a1[n1];\n  char *pEnd2 = &a2[n2];\n  char *p1 = a1;\n  char *p2 = a2;\n  char *p;\n  char *aOut;\n  int bFirstOut = 0;\n\n  *paOut = 0;\n  *pnOut = 0;\n\n  /* Allocate space for the output. Both the input and output doclists\n  ** are delta encoded. If they are in ascending order (bDescDoclist==0),\n  ** then the first docid in each list is simply encoded as a varint. For\n  ** each subsequent docid, the varint stored is the difference between the\n  ** current and previous docid (a positive number - since the list is in\n  ** ascending order).\n  **\n  ** The first docid written to the output is therefore encoded using the \n  ** same number of bytes as it is in whichever of the input lists it is\n  ** read from. And each subsequent docid read from the same input list \n  ** consumes either the same or less bytes as it did in the input (since\n  ** the difference between it and the previous value in the output must\n  ** be a positive value less than or equal to the delta value read from \n  ** the input list). The same argument applies to all but the first docid\n  ** read from the 'other' list. And to the contents of all position lists\n  ** that will be copied and merged from the input to the output.\n  **\n  ** However, if the first docid copied to the output is a negative number,\n  ** then the encoding of the first docid from the 'other' input list may\n  ** be larger in the output than it was in the input (since the delta value\n  ** may be a larger positive integer than the actual docid).\n  **\n  ** The space required to store the output is therefore the sum of the\n  ** sizes of the two inputs, plus enough space for exactly one of the input\n  ** docids to grow. \n  **\n  ** A symetric argument may be made if the doclists are in descending \n  ** order.\n  */\n  aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);\n  if( !aOut ) return SQLITE_NOMEM;\n\n  p = aOut;\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n  while( p1 || p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n\n    if( p2 && p1 && iDiff==0 ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistMerge(&p, &p1, &p2);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( !p2 || (p1 && iDiff<0) ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistCopy(&p, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i2);\n      fts3PoslistCopy(&p, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *paOut = aOut;\n  *pnOut = (int)(p-aOut);\n  assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );\n  return SQLITE_OK;\n}\n\n/*\n** This function does a \"phrase\" merge of two doclists. In a phrase merge,\n** the output contains a copy of each position from the right-hand input\n** doclist for which there is a position in the left-hand input doclist\n** exactly nDist tokens before it.\n**\n** If the docids in the input doclists are sorted in ascending order,\n** parameter bDescDoclist should be false. If they are sorted in ascending \n** order, it should be passed a non-zero value.\n**\n** The right-hand input doclist is overwritten by this function.\n*/\nstatic int fts3DoclistPhraseMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  int nDist,                      /* Distance from left to right (1=adjacent) */\n  char *aLeft, int nLeft,         /* Left doclist */\n  char **paRight, int *pnRight    /* IN/OUT: Right/output doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *aRight = *paRight;\n  char *pEnd1 = &aLeft[nLeft];\n  char *pEnd2 = &aRight[*pnRight];\n  char *p1 = aLeft;\n  char *p2 = aRight;\n  char *p;\n  int bFirstOut = 0;\n  char *aOut;\n\n  assert( nDist>0 );\n  if( bDescDoclist ){\n    aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);\n    if( aOut==0 ) return SQLITE_NOMEM;\n  }else{\n    aOut = aRight;\n  }\n  p = aOut;\n\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n\n  while( p1 && p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n    if( iDiff==0 ){\n      char *pSave = p;\n      sqlite3_int64 iPrevSave = iPrev;\n      int bFirstOutSave = bFirstOut;\n\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      if( 0==fts3PoslistPhraseMerge(&p, nDist, 0, 1, &p1, &p2) ){\n        p = pSave;\n        iPrev = iPrevSave;\n        bFirstOut = bFirstOutSave;\n      }\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( iDiff<0 ){\n      fts3PoslistCopy(0, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PoslistCopy(0, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *pnRight = (int)(p - aOut);\n  if( bDescDoclist ){\n    sqlite3_free(aRight);\n    *paRight = aOut;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Argument pList points to a position list nList bytes in size. This\n** function checks to see if the position list contains any entries for\n** a token in position 0 (of any column). If so, it writes argument iDelta\n** to the output buffer pOut, followed by a position list consisting only\n** of the entries from pList at position 0, and terminated by an 0x00 byte.\n** The value returned is the number of bytes written to pOut (if any).\n*/\nint sqlite3Fts3FirstFilter(\n  sqlite3_int64 iDelta,           /* Varint that may be written to pOut */\n  char *pList,                    /* Position list (no 0x00 term) */\n  int nList,                      /* Size of pList in bytes */\n  char *pOut                      /* Write output here */\n){\n  int nOut = 0;\n  int bWritten = 0;               /* True once iDelta has been written */\n  char *p = pList;\n  char *pEnd = &pList[nList];\n\n  if( *p!=0x01 ){\n    if( *p==0x02 ){\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n      pOut[nOut++] = 0x02;\n      bWritten = 1;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n\n  while( p<pEnd ){\n    sqlite3_int64 iCol;\n    p++;\n    p += sqlite3Fts3GetVarint(p, &iCol);\n    if( *p==0x02 ){\n      if( bWritten==0 ){\n        nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n        bWritten = 1;\n      }\n      pOut[nOut++] = 0x01;\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iCol);\n      pOut[nOut++] = 0x02;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n  if( bWritten ){\n    pOut[nOut++] = 0x00;\n  }\n\n  return nOut;\n}\n\n\n/*\n** Merge all doclists in the TermSelect.aaOutput[] array into a single\n** doclist stored in TermSelect.aaOutput[0]. If successful, delete all\n** other doclists (except the aaOutput[0] one) and return SQLITE_OK.\n**\n** If an OOM error occurs, return SQLITE_NOMEM. In this case it is\n** the responsibility of the caller to free any doclists left in the\n** TermSelect.aaOutput[] array.\n*/\nstatic int fts3TermSelectFinishMerge(Fts3Table *p, TermSelect *pTS){\n  char *aOut = 0;\n  int nOut = 0;\n  int i;\n\n  /* Loop through the doclists in the aaOutput[] array. Merge them all\n  ** into a single doclist.\n  */\n  for(i=0; i<SizeofArray(pTS->aaOutput); i++){\n    if( pTS->aaOutput[i] ){\n      if( !aOut ){\n        aOut = pTS->aaOutput[i];\n        nOut = pTS->anOutput[i];\n        pTS->aaOutput[i] = 0;\n      }else{\n        int nNew;\n        char *aNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, \n            pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut, &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aOut);\n          return rc;\n        }\n\n        sqlite3_free(pTS->aaOutput[i]);\n        sqlite3_free(aOut);\n        pTS->aaOutput[i] = 0;\n        aOut = aNew;\n        nOut = nNew;\n      }\n    }\n  }\n\n  pTS->aaOutput[0] = aOut;\n  pTS->anOutput[0] = nOut;\n  return SQLITE_OK;\n}\n\n/*\n** Merge the doclist aDoclist/nDoclist into the TermSelect object passed\n** as the first argument. The merge is an \"OR\" merge (see function\n** fts3DoclistOrMerge() for details).\n**\n** This function is called with the doclist for each term that matches\n** a queried prefix. It merges all these doclists into one, the doclist\n** for the specified prefix. Since there can be a very large number of\n** doclists to merge, the merging is done pair-wise using the TermSelect\n** object.\n**\n** This function returns SQLITE_OK if the merge is successful, or an\n** SQLite error code (SQLITE_NOMEM) if an error occurs.\n*/\nstatic int fts3TermSelectMerge(\n  Fts3Table *p,                   /* FTS table handle */\n  TermSelect *pTS,                /* TermSelect object to merge into */\n  char *aDoclist,                 /* Pointer to doclist */\n  int nDoclist                    /* Size of aDoclist in bytes */\n){\n  if( pTS->aaOutput[0]==0 ){\n    /* If this is the first term selected, copy the doclist to the output\n    ** buffer using memcpy(). \n    **\n    ** Add FTS3_VARINT_MAX bytes of unused space to the end of the \n    ** allocation. This is so as to ensure that the buffer is big enough\n    ** to hold the current doclist AND'd with any other doclist. If the\n    ** doclists are stored in order=ASC order, this padding would not be\n    ** required (since the size of [doclistA AND doclistB] is always less\n    ** than or equal to the size of [doclistA] in that case). But this is\n    ** not true for order=DESC. For example, a doclist containing (1, -1) \n    ** may be smaller than (-1), as in the first example the -1 may be stored\n    ** as a single-byte delta, whereas in the second it must be stored as a\n    ** FTS3_VARINT_MAX byte varint.\n    **\n    ** Similar padding is added in the fts3DoclistOrMerge() function.\n    */\n    pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);\n    pTS->anOutput[0] = nDoclist;\n    if( pTS->aaOutput[0] ){\n      memcpy(pTS->aaOutput[0], aDoclist, nDoclist);\n    }else{\n      return SQLITE_NOMEM;\n    }\n  }else{\n    char *aMerge = aDoclist;\n    int nMerge = nDoclist;\n    int iOut;\n\n    for(iOut=0; iOut<SizeofArray(pTS->aaOutput); iOut++){\n      if( pTS->aaOutput[iOut]==0 ){\n        assert( iOut>0 );\n        pTS->aaOutput[iOut] = aMerge;\n        pTS->anOutput[iOut] = nMerge;\n        break;\n      }else{\n        char *aNew;\n        int nNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, aMerge, nMerge, \n            pTS->aaOutput[iOut], pTS->anOutput[iOut], &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n          return rc;\n        }\n\n        if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n        sqlite3_free(pTS->aaOutput[iOut]);\n        pTS->aaOutput[iOut] = 0;\n  \n        aMerge = aNew;\n        nMerge = nNew;\n        if( (iOut+1)==SizeofArray(pTS->aaOutput) ){\n          pTS->aaOutput[iOut] = aMerge;\n          pTS->anOutput[iOut] = nMerge;\n        }\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Append SegReader object pNew to the end of the pCsr->apSegment[] array.\n*/\nstatic int fts3SegReaderCursorAppend(\n  Fts3MultiSegReader *pCsr, \n  Fts3SegReader *pNew\n){\n  if( (pCsr->nSegment%16)==0 ){\n    Fts3SegReader **apNew;\n    int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);\n    apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);\n    if( !apNew ){\n      sqlite3Fts3SegReaderFree(pNew);\n      return SQLITE_NOMEM;\n    }\n    pCsr->apSegment = apNew;\n  }\n  pCsr->apSegment[pCsr->nSegment++] = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add seg-reader objects to the Fts3MultiSegReader object passed as the\n** 8th argument.\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nstatic int fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc = SQLITE_OK;             /* Error code */\n  sqlite3_stmt *pStmt = 0;        /* Statement to iterate through segments */\n  int rc2;                        /* Result of sqlite3_reset() */\n\n  /* If iLevel is less than 0 and this is not a scan, include a seg-reader \n  ** for the pending-terms. If this is a scan, then this call must be being\n  ** made by an fts4aux module, not an FTS table. In this case calling\n  ** Fts3SegReaderPending might segfault, as the data structures used by \n  ** fts4aux are not completely populated. So it's easiest to filter these\n  ** calls out here.  */\n  if( iLevel<0 && p->aIndex ){\n    Fts3SegReader *pSeg = 0;\n    rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);\n    if( rc==SQLITE_OK && pSeg ){\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3AllSegdirs(p, iLangid, iIndex, iLevel, &pStmt);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n      Fts3SegReader *pSeg = 0;\n\n      /* Read the values returned by the SELECT into local variables. */\n      sqlite3_int64 iStartBlock = sqlite3_column_int64(pStmt, 1);\n      sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);\n      int nRoot = sqlite3_column_bytes(pStmt, 4);\n      char const *zRoot = sqlite3_column_blob(pStmt, 4);\n\n      /* If zTerm is not NULL, and this segment is not stored entirely on its\n      ** root node, the range of leaves scanned can be reduced. Do this. */\n      if( iStartBlock && zTerm ){\n        sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);\n        if( rc!=SQLITE_OK ) goto finished;\n        if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;\n      }\n \n      rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, \n          (isPrefix==0 && isScan==0),\n          iStartBlock, iLeavesEndBlock, \n          iEndBlock, zRoot, nRoot, &pSeg\n      );\n      if( rc!=SQLITE_OK ) goto finished;\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n finished:\n  rc2 = sqlite3_reset(pStmt);\n  if( rc==SQLITE_DONE ) rc = rc2;\n\n  return rc;\n}\n\n/*\n** Set up a cursor object for iterating through a full-text index or a \n** single level therein.\n*/\nint sqlite3Fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language-id to search */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr       /* Cursor object to populate */\n){\n  assert( iIndex>=0 && iIndex<p->nIndex );\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n      ||  iLevel==FTS3_SEGCURSOR_PENDING \n      ||  iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );\n  assert( isPrefix==0 || isScan==0 );\n\n  memset(pCsr, 0, sizeof(Fts3MultiSegReader));\n  return fts3SegReaderCursor(\n      p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr\n  );\n}\n\n/*\n** In addition to its current configuration, have the Fts3MultiSegReader\n** passed as the 4th argument also scan the doclist for term zTerm/nTerm.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3SegReaderCursorAddZero(\n  Fts3Table *p,                   /* FTS virtual table handle */\n  int iLangid,\n  const char *zTerm,              /* Term to scan doclist of */\n  int nTerm,                      /* Number of bytes in zTerm */\n  Fts3MultiSegReader *pCsr        /* Fts3MultiSegReader to modify */\n){\n  return fts3SegReaderCursor(p, \n      iLangid, 0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0,pCsr\n  );\n}\n\n/*\n** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,\n** if isPrefix is true, to scan the doclist for all terms for which \n** zTerm/nTerm is a prefix. If successful, return SQLITE_OK and write\n** a pointer to the new Fts3MultiSegReader to *ppSegcsr. Otherwise, return\n** an SQLite error code.\n**\n** It is the responsibility of the caller to free this object by eventually\n** passing it to fts3SegReaderCursorFree() \n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n** Output parameter *ppSegcsr is set to 0 if an error occurs.\n*/\nstatic int fts3TermSegReaderCursor(\n  Fts3Cursor *pCsr,               /* Virtual table cursor handle */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  Fts3MultiSegReader **ppSegcsr   /* OUT: Allocated seg-reader cursor */\n){\n  Fts3MultiSegReader *pSegcsr;    /* Object to allocate and return */\n  int rc = SQLITE_NOMEM;          /* Return code */\n\n  pSegcsr = sqlite3_malloc(sizeof(Fts3MultiSegReader));\n  if( pSegcsr ){\n    int i;\n    int bFound = 0;               /* True once an index has been found */\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n\n    if( isPrefix ){\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0, pSegcsr\n          );\n          pSegcsr->bLookup = 1;\n        }\n      }\n\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm+1 ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 1, 0, pSegcsr\n          );\n          if( rc==SQLITE_OK ){\n            rc = fts3SegReaderCursorAddZero(\n                p, pCsr->iLangid, zTerm, nTerm, pSegcsr\n            );\n          }\n        }\n      }\n    }\n\n    if( bFound==0 ){\n      rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n          0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, isPrefix, 0, pSegcsr\n      );\n      pSegcsr->bLookup = !isPrefix;\n    }\n  }\n\n  *ppSegcsr = pSegcsr;\n  return rc;\n}\n\n/*\n** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().\n*/\nstatic void fts3SegReaderCursorFree(Fts3MultiSegReader *pSegcsr){\n  sqlite3Fts3SegReaderFinish(pSegcsr);\n  sqlite3_free(pSegcsr);\n}\n\n/*\n** This function retrieves the doclist for the specified term (or term\n** prefix) from the database.\n*/\nstatic int fts3TermSelect(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3PhraseToken *pTok,          /* Token to query for */\n  int iColumn,                    /* Column to query (or -ve for all columns) */\n  int *pnOut,                     /* OUT: Size of buffer at *ppOut */\n  char **ppOut                    /* OUT: Malloced result buffer */\n){\n  int rc;                         /* Return code */\n  Fts3MultiSegReader *pSegcsr;    /* Seg-reader cursor for this term */\n  TermSelect tsc;                 /* Object for pair-wise doclist merging */\n  Fts3SegFilter filter;           /* Segment term filter configuration */\n\n  pSegcsr = pTok->pSegcsr;\n  memset(&tsc, 0, sizeof(TermSelect));\n\n  filter.flags = FTS3_SEGMENT_IGNORE_EMPTY | FTS3_SEGMENT_REQUIRE_POS\n        | (pTok->isPrefix ? FTS3_SEGMENT_PREFIX : 0)\n        | (pTok->bFirst ? FTS3_SEGMENT_FIRST : 0)\n        | (iColumn<p->nColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0);\n  filter.iCol = iColumn;\n  filter.zTerm = pTok->z;\n  filter.nTerm = pTok->n;\n\n  rc = sqlite3Fts3SegReaderStart(p, pSegcsr, &filter);\n  while( SQLITE_OK==rc\n      && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pSegcsr)) \n  ){\n    rc = fts3TermSelectMerge(p, &tsc, pSegcsr->aDoclist, pSegcsr->nDoclist);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3TermSelectFinishMerge(p, &tsc);\n  }\n  if( rc==SQLITE_OK ){\n    *ppOut = tsc.aaOutput[0];\n    *pnOut = tsc.anOutput[0];\n  }else{\n    int i;\n    for(i=0; i<SizeofArray(tsc.aaOutput); i++){\n      sqlite3_free(tsc.aaOutput[i]);\n    }\n  }\n\n  fts3SegReaderCursorFree(pSegcsr);\n  pTok->pSegcsr = 0;\n  return rc;\n}\n\n/*\n** This function counts the total number of docids in the doclist stored\n** in buffer aList[], size nList bytes.\n**\n** If the isPoslist argument is true, then it is assumed that the doclist\n** contains a position-list following each docid. Otherwise, it is assumed\n** that the doclist is simply a list of docids stored as delta encoded \n** varints.\n*/\nstatic int fts3DoclistCountDocids(char *aList, int nList){\n  int nDoc = 0;                   /* Return value */\n  if( aList ){\n    char *aEnd = &aList[nList];   /* Pointer to one byte after EOF */\n    char *p = aList;              /* Cursor */\n    while( p<aEnd ){\n      nDoc++;\n      while( (*p++)&0x80 );     /* Skip docid varint */\n      fts3PoslistCopy(0, &p);   /* Skip over position list */\n    }\n  }\n\n  return nDoc;\n}\n\n/*\n** Advance the cursor to the next row in the %_content table that\n** matches the search criteria.  For a MATCH search, this will be\n** the next row that matches. For a full-table scan, this will be\n** simply the next row in the %_content table.  For a docid lookup,\n** this routine simply sets the EOF flag.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts3EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts3NextMethod(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){\n      pCsr->isEof = 1;\n      rc = sqlite3_reset(pCsr->pStmt);\n    }else{\n      pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);\n      rc = SQLITE_OK;\n    }\n  }else{\n    rc = fts3EvalNext((Fts3Cursor *)pCursor);\n  }\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/*\n** The following are copied from sqliteInt.h.\n**\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** If the numeric type of argument pVal is \"integer\", then return it\n** converted to a 64-bit signed integer. Otherwise, return a copy of\n** the second parameter, iDefault.\n*/\nstatic sqlite3_int64 fts3DocidRange(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against\n** the %_content table.\n**\n** If idxNum==FTS3_DOCID_SEARCH then do a docid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-FTS3_FULLTEXT_SEARCH, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\nstatic int fts3FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_OK;\n  char *zSql;                     /* SQL statement used to access %_content */\n  int eSearch;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n\n  sqlite3_value *pCons = 0;       /* The MATCH or rowid constraint, if any */\n  sqlite3_value *pLangid = 0;     /* The \"langid = ?\" constraint, if any */\n  sqlite3_value *pDocidGe = 0;    /* The \"docid >= ?\" constraint, if any */\n  sqlite3_value *pDocidLe = 0;    /* The \"docid <= ?\" constraint, if any */\n  int iIdx;\n\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  eSearch = (idxNum & 0x0000FFFF);\n  assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );\n  assert( p->pSegments==0 );\n\n  /* Collect arguments into local variables */\n  iIdx = 0;\n  if( eSearch!=FTS3_FULLSCAN_SEARCH ) pCons = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_LANGID ) pLangid = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];\n  assert( iIdx==nVal );\n\n  /* In case the cursor has been used before, clear it now. */\n  fts3ClearCursor(pCsr);\n\n  /* Set the lower and upper bounds on docids to return */\n  pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);\n  pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);\n\n  if( idxStr ){\n    pCsr->bDesc = (idxStr[0]=='D');\n  }else{\n    pCsr->bDesc = p->bDescIdx;\n  }\n  pCsr->eSearch = (i16)eSearch;\n\n  if( eSearch!=FTS3_DOCID_SEARCH && eSearch!=FTS3_FULLSCAN_SEARCH ){\n    int iCol = eSearch-FTS3_FULLTEXT_SEARCH;\n    const char *zQuery = (const char *)sqlite3_value_text(pCons);\n\n    if( zQuery==0 && sqlite3_value_type(pCons)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n\n    pCsr->iLangid = 0;\n    if( pLangid ) pCsr->iLangid = sqlite3_value_int(pLangid);\n\n    assert( p->base.zErrMsg==0 );\n    rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,\n        p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr, \n        &p->base.zErrMsg\n    );\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    rc = fts3EvalStart(pCsr);\n    sqlite3Fts3SegmentsClose(p);\n    if( rc!=SQLITE_OK ) return rc;\n    pCsr->pNextId = pCsr->aDoclist;\n    pCsr->iPrevId = 0;\n  }\n\n  /* Compile a SELECT statement for this cursor. For a full-table-scan, the\n  ** statement loops through all rows of the %_content table. For a\n  ** full-text query or docid lookup, the statement retrieves a single\n  ** row by docid.\n  */\n  if( eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( pDocidGe || pDocidLe ){\n      zSql = sqlite3_mprintf(\n          \"SELECT %s WHERE rowid BETWEEN %lld AND %lld ORDER BY rowid %s\",\n          p->zReadExprlist, pCsr->iMinDocid, pCsr->iMaxDocid,\n          (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s ORDER BY rowid %s\", \n          p->zReadExprlist, (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }\n    if( zSql ){\n      rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }else if( eSearch==FTS3_DOCID_SEARCH ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons);\n    }\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fts3NextMethod(pCursor);\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts3EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor*)pCursor;\n  if( pCsr->isEof ){\n    fts3ClearCursor(pCsr);\n    pCsr->isEof = 1;\n  }\n  return pCsr->isEof;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts3\n** exposes %_content.docid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts3RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  *pRowid = pCsr->iPrevId;\n  return SQLITE_OK;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n**\n** If:\n**\n**   (iCol <  p->nColumn)   -> The value of the iCol'th user column.\n**   (iCol == p->nColumn)   -> Magic column with the same name as the table.\n**   (iCol == p->nColumn+1) -> Docid column\n**   (iCol == p->nColumn+2) -> Langid column\n*/\nstatic int fts3ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n\n  /* The column value supplied by SQLite must be in range. */\n  assert( iCol>=0 && iCol<=p->nColumn+2 );\n\n  switch( iCol-p->nColumn ){\n    case 0:\n      /* The special 'table-name' column */\n      sqlite3_result_pointer(pCtx, pCsr, \"fts3cursor\", 0);\n      break;\n\n    case 1:\n      /* The docid column */\n      sqlite3_result_int64(pCtx, pCsr->iPrevId);\n      break;\n\n    case 2:\n      if( pCsr->pExpr ){\n        sqlite3_result_int64(pCtx, pCsr->iLangid);\n        break;\n      }else if( p->zLanguageid==0 ){\n        sqlite3_result_int(pCtx, 0);\n        break;\n      }else{\n        iCol = p->nColumn;\n        /* fall-through */\n      }\n\n    default:\n      /* A user column. Or, if this is a full-table scan, possibly the\n      ** language-id column. Seek the cursor. */\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){\n        sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n      }\n      break;\n  }\n\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n*/\nstatic int fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  return sqlite3Fts3UpdateMethod(pVtab, nArg, apVal, pRowid);\n}\n\n/*\n** Implementation of xSync() method. Flush the contents of the pending-terms\n** hash-table to the database.\n*/\nstatic int fts3SyncMethod(sqlite3_vtab *pVtab){\n\n  /* Following an incremental-merge operation, assuming that the input\n  ** segments are not completely consumed (the usual case), they are updated\n  ** in place to remove the entries that have already been merged. This\n  ** involves updating the leaf block that contains the smallest unmerged\n  ** entry and each block (if any) between the leaf and the root node. So\n  ** if the height of the input segment b-trees is N, and input segments\n  ** are merged eight at a time, updating the input segments at the end\n  ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually\n  ** small - often between 0 and 2. So the overhead of the incremental\n  ** merge is somewhere between 8 and 24 blocks. To avoid this overhead\n  ** dwarfing the actual productive work accomplished, the incremental merge\n  ** is only attempted if it will write at least 64 leaf blocks. Hence\n  ** nMinMerge.\n  **\n  ** Of course, updating the input segments also involves deleting a bunch\n  ** of blocks from the segments table. But this is not considered overhead\n  ** as it would also be required by a crisis-merge that used the same input \n  ** segments.\n  */\n  const u32 nMinMerge = 64;       /* Minimum amount of incr-merge work to do */\n\n  Fts3Table *p = (Fts3Table*)pVtab;\n  int rc;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->db);\n\n  rc = sqlite3Fts3PendingTermsFlush(p);\n  if( rc==SQLITE_OK \n   && p->nLeafAdd>(nMinMerge/16) \n   && p->nAutoincrmerge && p->nAutoincrmerge!=0xff\n  ){\n    int mxLevel = 0;              /* Maximum relative level value in db */\n    int A;                        /* Incr-merge parameter A */\n\n    rc = sqlite3Fts3MaxLevel(p, &mxLevel);\n    assert( rc==SQLITE_OK || mxLevel==0 );\n    A = p->nLeafAdd * mxLevel;\n    A += (A/2);\n    if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);\n  }\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3_set_last_insert_rowid(p->db, iLastRowid);\n  return rc;\n}\n\n/*\n** If it is currently unknown whether or not the FTS table has an %_stat\n** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat\n** to 0 or 1). Return SQLITE_OK if successful, or an SQLite error code\n** if an error occurs.\n*/\nstatic int fts3SetHasStat(Fts3Table *p){\n  int rc = SQLITE_OK;\n  if( p->bHasStat==2 ){\n    char *zTbl = sqlite3_mprintf(\"%s_stat\", p->zName);\n    if( zTbl ){\n      int res = sqlite3_table_column_metadata(p->db, p->zDb, zTbl, 0,0,0,0,0,0);\n      sqlite3_free(zTbl);\n      p->bHasStat = (res==SQLITE_OK);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts3BeginMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(pVtab);\n  assert( p->pSegments==0 );\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=1 );\n  TESTONLY( p->inTransaction = 1 );\n  TESTONLY( p->mxSavepoint = -1; );\n  p->nLeafAdd = 0;\n  return fts3SetHasStat(p);\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts3SyncMethod().\n*/\nstatic int fts3CommitMethod(sqlite3_vtab *pVtab){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(pVtab);\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=0 );\n  assert( p->pSegments==0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts3RollbackMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  sqlite3Fts3PendingTermsClear(p);\n  assert( p->inTransaction!=0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** When called, *ppPoslist must point to the byte immediately following the\n** end of a position-list. i.e. ( (*ppPoslist)[-1]==POS_END ). This function\n** moves *ppPoslist so that it instead points to the first byte of the\n** same position list.\n*/\nstatic void fts3ReversePoslist(char *pStart, char **ppPoslist){\n  char *p = &(*ppPoslist)[-2];\n  char c = 0;\n\n  /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */\n  while( p>pStart && (c=*p--)==0 );\n\n  /* Search backwards for a varint with value zero (the end of the previous \n  ** poslist). This is an 0x00 byte preceded by some byte that does not\n  ** have the 0x80 bit set.  */\n  while( p>pStart && (*p & 0x80) | c ){ \n    c = *p--; \n  }\n  assert( p==pStart || c==0 );\n\n  /* At this point p points to that preceding byte without the 0x80 bit\n  ** set. So to find the start of the poslist, skip forward 2 bytes then\n  ** over a varint. \n  **\n  ** Normally. The other case is that p==pStart and the poslist to return\n  ** is the first in the doclist. In this case do not skip forward 2 bytes.\n  ** The second part of the if condition (c==0 && *ppPoslist>&p[2])\n  ** is required for cases where the first byte of a doclist and the\n  ** doclist is empty. For example, if the first docid is 10, a doclist\n  ** that begins with:\n  **\n  **   0x0A 0x00 <next docid delta varint>\n  */\n  if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; }\n  while( *p++&0x80 );\n  *ppPoslist = p;\n}\n\n/*\n** Helper function used by the implementation of the overloaded snippet(),\n** offsets() and optimize() SQL functions.\n**\n** If the value passed as the third argument is a blob of size\n** sizeof(Fts3Cursor*), then the blob contents are copied to the \n** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error\n** message is written to context pContext and SQLITE_ERROR returned. The\n** string passed via zFunc is used as part of the error message.\n*/\nstatic int fts3FunctionArg(\n  sqlite3_context *pContext,      /* SQL function call context */\n  const char *zFunc,              /* Function name */\n  sqlite3_value *pVal,            /* argv[0] passed to function */\n  Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */\n){\n  int rc;\n  *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, \"fts3cursor\");\n  if( (*ppCsr)!=0 ){\n    rc = SQLITE_OK;\n  }else{\n    char *zErr = sqlite3_mprintf(\"illegal first argument to %s\", zFunc);\n    sqlite3_result_error(pContext, zErr, -1);\n    sqlite3_free(zErr);\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the snippet() function for FTS3\n*/\nstatic void fts3SnippetFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of apVal[] array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  const char *zStart = \"<b>\";\n  const char *zEnd = \"</b>\";\n  const char *zEllipsis = \"<b>...</b>\";\n  int iCol = -1;\n  int nToken = 15;                /* Default number of tokens in snippet */\n\n  /* There must be at least one argument passed to this function (otherwise\n  ** the non-overloaded version would have been called instead of this one).\n  */\n  assert( nVal>=1 );\n\n  if( nVal>6 ){\n    sqlite3_result_error(pContext, \n        \"wrong number of arguments to function snippet()\", -1);\n    return;\n  }\n  if( fts3FunctionArg(pContext, \"snippet\", apVal[0], &pCsr) ) return;\n\n  switch( nVal ){\n    case 6: nToken = sqlite3_value_int(apVal[5]);\n    case 5: iCol = sqlite3_value_int(apVal[4]);\n    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);\n    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);\n    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);\n  }\n  if( !zEllipsis || !zEnd || !zStart ){\n    sqlite3_result_error_nomem(pContext);\n  }else if( nToken==0 ){\n    sqlite3_result_text(pContext, \"\", -1, SQLITE_STATIC);\n  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS3\n*/\nstatic void fts3OffsetsFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"offsets\", apVal[0], &pCsr) ) return;\n  assert( pCsr );\n  if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Offsets(pContext, pCsr);\n  }\n}\n\n/* \n** Implementation of the special optimize() function for FTS3. This \n** function merges all segments in the database to a single segment.\n** Example usage is:\n**\n**   SELECT optimize(t) FROM t LIMIT 1;\n**\n** where 't' is the name of an FTS3 table.\n*/\nstatic void fts3OptimizeFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  int rc;                         /* Return code */\n  Fts3Table *p;                   /* Virtual table handle */\n  Fts3Cursor *pCursor;            /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"optimize\", apVal[0], &pCursor) ) return;\n  p = (Fts3Table *)pCursor->base.pVtab;\n  assert( p );\n\n  rc = sqlite3Fts3Optimize(p);\n\n  switch( rc ){\n    case SQLITE_OK:\n      sqlite3_result_text(pContext, \"Index optimized\", -1, SQLITE_STATIC);\n      break;\n    case SQLITE_DONE:\n      sqlite3_result_text(pContext, \"Index already optimal\", -1, SQLITE_STATIC);\n      break;\n    default:\n      sqlite3_result_error_code(pContext, rc);\n      break;\n  }\n}\n\n/*\n** Implementation of the matchinfo() function for FTS3\n*/\nstatic void fts3MatchinfoFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  assert( nVal==1 || nVal==2 );\n  if( SQLITE_OK==fts3FunctionArg(pContext, \"matchinfo\", apVal[0], &pCsr) ){\n    const char *zArg = 0;\n    if( nVal>1 ){\n      zArg = (const char *)sqlite3_value_text(apVal[1]);\n    }\n    sqlite3Fts3Matchinfo(pContext, pCsr, zArg);\n  }\n}\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts3FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* Unused */\n){\n  struct Overloaded {\n    const char *zName;\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aOverload[] = {\n    { \"snippet\", fts3SnippetFunc },\n    { \"offsets\", fts3OffsetsFunc },\n    { \"optimize\", fts3OptimizeFunc },\n    { \"matchinfo\", fts3MatchinfoFunc },\n  };\n  int i;                          /* Iterator variable */\n\n  UNUSED_PARAMETER(pVtab);\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(ppArg);\n\n  for(i=0; i<SizeofArray(aOverload); i++){\n    if( strcmp(zName, aOverload[i].zName)==0 ){\n      *pxFunc = aOverload[i].xFunc;\n      return 1;\n    }\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS3 xRename method. Rename an fts3 table.\n*/\nstatic int fts3RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  sqlite3 *db = p->db;            /* Database connection */\n  int rc;                         /* Return Code */\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  rc = fts3SetHasStat(p);\n  \n  /* As it happens, the pending terms table is always empty here. This is\n  ** because an \"ALTER TABLE RENAME TABLE\" statement inside a transaction \n  ** always opens a savepoint transaction. And the xSavepoint() method \n  ** flushes the pending terms table. But leave the (no-op) call to\n  ** PendingTermsFlush() in in case that changes.\n  */\n  assert( p->nPendingData==0 );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3PendingTermsFlush(p);\n  }\n\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\",\n      p->zDb, p->zName, zName\n    );\n  }\n\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_docsize'  RENAME TO '%q_docsize';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  if( p->bHasStat ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_stat'  RENAME TO '%q_stat';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';\",\n    p->zDb, p->zName, zName\n  );\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';\",\n    p->zDb, p->zName, zName\n  );\n  return rc;\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( ((Fts3Table *)pVtab)->inTransaction );\n  assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );\n  TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );\n  if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){\n    rc = fts3SyncMethod(pVtab);\n  }\n  return rc;\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(iSavepoint);\n  UNUSED_PARAMETER(pVtab);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint-1 );\n  return SQLITE_OK;\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint );\n  sqlite3Fts3PendingTermsClear(p);\n  return SQLITE_OK;\n}\n\nstatic const sqlite3_module fts3Module = {\n  /* iVersion      */ 2,\n  /* xCreate       */ fts3CreateMethod,\n  /* xConnect      */ fts3ConnectMethod,\n  /* xBestIndex    */ fts3BestIndexMethod,\n  /* xDisconnect   */ fts3DisconnectMethod,\n  /* xDestroy      */ fts3DestroyMethod,\n  /* xOpen         */ fts3OpenMethod,\n  /* xClose        */ fts3CloseMethod,\n  /* xFilter       */ fts3FilterMethod,\n  /* xNext         */ fts3NextMethod,\n  /* xEof          */ fts3EofMethod,\n  /* xColumn       */ fts3ColumnMethod,\n  /* xRowid        */ fts3RowidMethod,\n  /* xUpdate       */ fts3UpdateMethod,\n  /* xBegin        */ fts3BeginMethod,\n  /* xSync         */ fts3SyncMethod,\n  /* xCommit       */ fts3CommitMethod,\n  /* xRollback     */ fts3RollbackMethod,\n  /* xFindFunction */ fts3FindFunctionMethod,\n  /* xRename */       fts3RenameMethod,\n  /* xSavepoint    */ fts3SavepointMethod,\n  /* xRelease      */ fts3ReleaseMethod,\n  /* xRollbackTo   */ fts3RollbackToMethod,\n};\n\n/*\n** This function is registered as the module destructor (called when an\n** FTS3 enabled database connection is closed). It frees the memory\n** allocated for the tokenizer hash table.\n*/\nstatic void hashDestroy(void *p){\n  Fts3Hash *pHash = (Fts3Hash *)p;\n  sqlite3Fts3HashClear(pHash);\n  sqlite3_free(pHash);\n}\n\n/*\n** The fts3 built-in tokenizers - \"simple\", \"porter\" and \"icu\"- are \n** implemented in files fts3_tokenizer1.c, fts3_porter.c and fts3_icu.c\n** respectively. The following three forward declarations are for functions\n** declared in these files used to retrieve the respective implementations.\n**\n** Calling sqlite3Fts3SimpleTokenizerModule() sets the value pointed\n** to by the argument to point to the \"simple\" tokenizer implementation.\n** And so on.\n*/\nvoid sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nvoid sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nvoid sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule);\n#endif\n#ifdef SQLITE_ENABLE_ICU\nvoid sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#endif\n\n/*\n** Initialize the fts3 extension. If this extension is built as part\n** of the sqlite library, then this function is called directly by\n** SQLite. If fts3 is built as a dynamically loadable extension, this\n** function is called by the sqlite3_extension_init() entry point.\n*/\nint sqlite3Fts3Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  Fts3Hash *pHash = 0;\n  const sqlite3_tokenizer_module *pSimple = 0;\n  const sqlite3_tokenizer_module *pPorter = 0;\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  const sqlite3_tokenizer_module *pUnicode = 0;\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  const sqlite3_tokenizer_module *pIcu = 0;\n  sqlite3Fts3IcuTokenizerModule(&pIcu);\n#endif\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  sqlite3Fts3UnicodeTokenizer(&pUnicode);\n#endif\n\n#ifdef SQLITE_TEST\n  rc = sqlite3Fts3InitTerm(db);\n  if( rc!=SQLITE_OK ) return rc;\n#endif\n\n  rc = sqlite3Fts3InitAux(db);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3Fts3SimpleTokenizerModule(&pSimple);\n  sqlite3Fts3PorterTokenizerModule(&pPorter);\n\n  /* Allocate and initialize the hash-table used to store tokenizers. */\n  pHash = sqlite3_malloc(sizeof(Fts3Hash));\n  if( !pHash ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n  }\n\n  /* Load the built-in tokenizers into the hash table */\n  if( rc==SQLITE_OK ){\n    if( sqlite3Fts3HashInsert(pHash, \"simple\", 7, (void *)pSimple)\n     || sqlite3Fts3HashInsert(pHash, \"porter\", 7, (void *)pPorter) \n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n     || sqlite3Fts3HashInsert(pHash, \"unicode61\", 10, (void *)pUnicode) \n#endif\n#ifdef SQLITE_ENABLE_ICU\n     || (pIcu && sqlite3Fts3HashInsert(pHash, \"icu\", 4, (void *)pIcu))\n#endif\n    ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3ExprInitTestInterface(db);\n  }\n#endif\n\n  /* Create the virtual table wrapper around the hash-table and overload \n  ** the four scalar functions. If this is successful, register the\n  ** module with sqlite.\n  */\n  if( SQLITE_OK==rc \n   && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, \"fts3_tokenizer\"))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"snippet\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"offsets\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 2))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"optimize\", 1))\n  ){\n    rc = sqlite3_create_module_v2(\n        db, \"fts3\", &fts3Module, (void *)pHash, hashDestroy\n    );\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_module_v2(\n          db, \"fts4\", &fts3Module, (void *)pHash, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3InitTok(db, (void *)pHash);\n    }\n    return rc;\n  }\n\n\n  /* An error has occurred. Delete the hash table and return the error code. */\n  assert( rc!=SQLITE_OK );\n  if( pHash ){\n    sqlite3Fts3HashClear(pHash);\n    sqlite3_free(pHash);\n  }\n  return rc;\n}\n\n/*\n** Allocate an Fts3MultiSegReader for each token in the expression headed\n** by pExpr. \n**\n** An Fts3SegReader object is a cursor that can seek or scan a range of\n** entries within a single segment b-tree. An Fts3MultiSegReader uses multiple\n** Fts3SegReader objects internally to provide an interface to seek or scan\n** within the union of all segments of a b-tree. Hence the name.\n**\n** If the allocated Fts3MultiSegReader just seeks to a single entry in a\n** segment b-tree (if the term is not a prefix or it is a prefix for which\n** there exists prefix b-tree of the right length) then it may be traversed\n** and merged incrementally. Otherwise, it has to be merged into an in-memory \n** doclist and then traversed.\n*/\nstatic void fts3EvalAllocateReaders(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Allocate readers for this expression */\n  int *pnToken,                   /* OUT: Total number of tokens in phrase. */\n  int *pnOr,                      /* OUT: Total number of OR nodes in expr. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int i;\n      int nToken = pExpr->pPhrase->nToken;\n      *pnToken += nToken;\n      for(i=0; i<nToken; i++){\n        Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];\n        int rc = fts3TermSegReaderCursor(pCsr, \n            pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr\n        );\n        if( rc!=SQLITE_OK ){\n          *pRc = rc;\n          return;\n        }\n      }\n      assert( pExpr->pPhrase->iDoclistToken==0 );\n      pExpr->pPhrase->iDoclistToken = -1;\n    }else{\n      *pnOr += (pExpr->eType==FTSQUERY_OR);\n      fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);\n      fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);\n    }\n  }\n}\n\n/*\n** Arguments pList/nList contain the doclist for token iToken of phrase p.\n** It is merged into the main doclist stored in p->doclist.aAll/nAll.\n**\n** This function assumes that pList points to a buffer allocated using\n** sqlite3_malloc(). This function takes responsibility for eventually\n** freeing the buffer.\n**\n** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.\n*/\nstatic int fts3EvalPhraseMergeToken(\n  Fts3Table *pTab,                /* FTS Table pointer */\n  Fts3Phrase *p,                  /* Phrase to merge pList/nList into */\n  int iToken,                     /* Token pList/nList corresponds to */\n  char *pList,                    /* Pointer to doclist */\n  int nList                       /* Number of bytes in pList */\n){\n  int rc = SQLITE_OK;\n  assert( iToken!=p->iDoclistToken );\n\n  if( pList==0 ){\n    sqlite3_free(p->doclist.aAll);\n    p->doclist.aAll = 0;\n    p->doclist.nAll = 0;\n  }\n\n  else if( p->iDoclistToken<0 ){\n    p->doclist.aAll = pList;\n    p->doclist.nAll = nList;\n  }\n\n  else if( p->doclist.aAll==0 ){\n    sqlite3_free(pList);\n  }\n\n  else {\n    char *pLeft;\n    char *pRight;\n    int nLeft;\n    int nRight;\n    int nDiff;\n\n    if( p->iDoclistToken<iToken ){\n      pLeft = p->doclist.aAll;\n      nLeft = p->doclist.nAll;\n      pRight = pList;\n      nRight = nList;\n      nDiff = iToken - p->iDoclistToken;\n    }else{\n      pRight = p->doclist.aAll;\n      nRight = p->doclist.nAll;\n      pLeft = pList;\n      nLeft = nList;\n      nDiff = p->iDoclistToken - iToken;\n    }\n\n    rc = fts3DoclistPhraseMerge(\n        pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight\n    );\n    sqlite3_free(pLeft);\n    p->doclist.aAll = pRight;\n    p->doclist.nAll = nRight;\n  }\n\n  if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;\n  return rc;\n}\n\n/*\n** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist\n** does not take deferred tokens into account.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseLoad(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p                   /* Phrase object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int iToken;\n  int rc = SQLITE_OK;\n\n  for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){\n    Fts3PhraseToken *pToken = &p->aToken[iToken];\n    assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );\n\n    if( pToken->pSegcsr ){\n      int nThis = 0;\n      char *pThis = 0;\n      rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);\n      }\n    }\n    assert( pToken->pSegcsr==0 );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called on each phrase after the position lists for\n** any deferred tokens have been loaded into memory. It updates the phrases\n** current position list to include only those positions that are really\n** instances of the phrase (after considering deferred tokens). If this\n** means that the phrase does not appear in the current row, doclist.pList\n** and doclist.nList are both zeroed.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){\n  int iToken;                     /* Used to iterate through phrase tokens */\n  char *aPoslist = 0;             /* Position list for deferred tokens */\n  int nPoslist = 0;               /* Number of bytes in aPoslist */\n  int iPrev = -1;                 /* Token number of previous deferred token */\n\n  assert( pPhrase->doclist.bFreeList==0 );\n\n  for(iToken=0; iToken<pPhrase->nToken; iToken++){\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    Fts3DeferredToken *pDeferred = pToken->pDeferred;\n\n    if( pDeferred ){\n      char *pList;\n      int nList;\n      int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList);\n      if( rc!=SQLITE_OK ) return rc;\n\n      if( pList==0 ){\n        sqlite3_free(aPoslist);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n        return SQLITE_OK;\n\n      }else if( aPoslist==0 ){\n        aPoslist = pList;\n        nPoslist = nList;\n\n      }else{\n        char *aOut = pList;\n        char *p1 = aPoslist;\n        char *p2 = aOut;\n\n        assert( iPrev>=0 );\n        fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);\n        sqlite3_free(aPoslist);\n        aPoslist = pList;\n        nPoslist = (int)(aOut - aPoslist);\n        if( nPoslist==0 ){\n          sqlite3_free(aPoslist);\n          pPhrase->doclist.pList = 0;\n          pPhrase->doclist.nList = 0;\n          return SQLITE_OK;\n        }\n      }\n      iPrev = iToken;\n    }\n  }\n\n  if( iPrev>=0 ){\n    int nMaxUndeferred = pPhrase->iDoclistToken;\n    if( nMaxUndeferred<0 ){\n      pPhrase->doclist.pList = aPoslist;\n      pPhrase->doclist.nList = nPoslist;\n      pPhrase->doclist.iDocid = pCsr->iPrevId;\n      pPhrase->doclist.bFreeList = 1;\n    }else{\n      int nDistance;\n      char *p1;\n      char *p2;\n      char *aOut;\n\n      if( nMaxUndeferred>iPrev ){\n        p1 = aPoslist;\n        p2 = pPhrase->doclist.pList;\n        nDistance = nMaxUndeferred - iPrev;\n      }else{\n        p1 = pPhrase->doclist.pList;\n        p2 = aPoslist;\n        nDistance = iPrev - nMaxUndeferred;\n      }\n\n      aOut = (char *)sqlite3_malloc(nPoslist+8);\n      if( !aOut ){\n        sqlite3_free(aPoslist);\n        return SQLITE_NOMEM;\n      }\n      \n      pPhrase->doclist.pList = aOut;\n      if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){\n        pPhrase->doclist.bFreeList = 1;\n        pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);\n      }else{\n        sqlite3_free(aOut);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n      }\n      sqlite3_free(aPoslist);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Maximum number of tokens a phrase may have to be considered for the\n** incremental doclists strategy.\n*/\n#define MAX_INCR_PHRASE_TOKENS 4\n\n/*\n** This function is called for each Fts3Phrase in a full-text query \n** expression to initialize the mechanism for returning rows. Once this\n** function has been called successfully on an Fts3Phrase, it may be\n** used with fts3EvalPhraseNext() to iterate through the matching docids.\n**\n** If parameter bOptOk is true, then the phrase may (or may not) use the\n** incremental loading strategy. Otherwise, the entire doclist is loaded into\n** memory within this call.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;             /* Error code */\n  int i;\n\n  /* Determine if doclists may be loaded from disk incrementally. This is\n  ** possible if the bOptOk argument is true, the FTS doclists will be\n  ** scanned in forward order, and the phrase consists of \n  ** MAX_INCR_PHRASE_TOKENS or fewer tokens, none of which are are \"^first\"\n  ** tokens or prefix tokens that cannot use a prefix-index.  */\n  int bHaveIncr = 0;\n  int bIncrOk = (bOptOk \n   && pCsr->bDesc==pTab->bDescIdx \n   && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0\n#ifdef SQLITE_TEST\n   && pTab->bNoIncrDoclist==0\n#endif\n  );\n  for(i=0; bIncrOk==1 && i<p->nToken; i++){\n    Fts3PhraseToken *pToken = &p->aToken[i];\n    if( pToken->bFirst || (pToken->pSegcsr!=0 && !pToken->pSegcsr->bLookup) ){\n      bIncrOk = 0;\n    }\n    if( pToken->pSegcsr ) bHaveIncr = 1;\n  }\n\n  if( bIncrOk && bHaveIncr ){\n    /* Use the incremental approach. */\n    int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);\n    for(i=0; rc==SQLITE_OK && i<p->nToken; i++){\n      Fts3PhraseToken *pToken = &p->aToken[i];\n      Fts3MultiSegReader *pSegcsr = pToken->pSegcsr;\n      if( pSegcsr ){\n        rc = sqlite3Fts3MsrIncrStart(pTab, pSegcsr, iCol, pToken->z, pToken->n);\n      }\n    }\n    p->bIncr = 1;\n  }else{\n    /* Load the full doclist for the phrase into memory. */\n    rc = fts3EvalPhraseLoad(pCsr, p);\n    p->bIncr = 0;\n  }\n\n  assert( rc!=SQLITE_OK || p->nToken<1 || p->aToken[0].pSegcsr==0 || p->bIncr );\n  return rc;\n}\n\n/*\n** This function is used to iterate backwards (from the end to start) \n** through doclists. It is used by this module to iterate through phrase\n** doclists in reverse and by the fts3_write.c module to iterate through\n** pending-terms lists when writing to databases with \"order=desc\".\n**\n** The doclist may be sorted in ascending (parameter bDescIdx==0) or \n** descending (parameter bDescIdx==1) order of docid. Regardless, this\n** function iterates from the end of the doclist to the beginning.\n*/\nvoid sqlite3Fts3DoclistPrev(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  int *pnList,                    /* OUT: List length pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    sqlite3_int64 iDocid = 0;\n    char *pNext = 0;\n    char *pDocid = aDoclist;\n    char *pEnd = &aDoclist[nDoclist];\n    int iMul = 1;\n\n    while( pDocid<pEnd ){\n      sqlite3_int64 iDelta;\n      pDocid += sqlite3Fts3GetVarint(pDocid, &iDelta);\n      iDocid += (iMul * iDelta);\n      pNext = pDocid;\n      fts3PoslistCopy(0, &pDocid);\n      while( pDocid<pEnd && *pDocid==0 ) pDocid++;\n      iMul = (bDescIdx ? -1 : 1);\n    }\n\n    *pnList = (int)(pEnd - pNext);\n    *ppIter = pNext;\n    *piDocid = iDocid;\n  }else{\n    int iMul = (bDescIdx ? -1 : 1);\n    sqlite3_int64 iDelta;\n    fts3GetReverseVarint(&p, aDoclist, &iDelta);\n    *piDocid -= (iMul * iDelta);\n\n    if( p==aDoclist ){\n      *pbEof = 1;\n    }else{\n      char *pSave = p;\n      fts3ReversePoslist(aDoclist, &p);\n      *pnList = (int)(pSave - p);\n    }\n    *ppIter = p;\n  }\n}\n\n/*\n** Iterate forwards through a doclist.\n*/\nvoid sqlite3Fts3DoclistNext(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    p = aDoclist;\n    p += sqlite3Fts3GetVarint(p, piDocid);\n  }else{\n    fts3PoslistCopy(0, &p);\n    while( p<&aDoclist[nDoclist] && *p==0 ) p++; \n    if( p>=&aDoclist[nDoclist] ){\n      *pbEof = 1;\n    }else{\n      sqlite3_int64 iVar;\n      p += sqlite3Fts3GetVarint(p, &iVar);\n      *piDocid += ((bDescIdx ? -1 : 1) * iVar);\n    }\n  }\n\n  *ppIter = p;\n}\n\n/*\n** Advance the iterator pDL to the next entry in pDL->aAll/nAll. Set *pbEof\n** to true if EOF is reached.\n*/\nstatic void fts3EvalDlPhraseNext(\n  Fts3Table *pTab,\n  Fts3Doclist *pDL,\n  u8 *pbEof\n){\n  char *pIter;                            /* Used to iterate through aAll */\n  char *pEnd = &pDL->aAll[pDL->nAll];     /* 1 byte past end of aAll */\n \n  if( pDL->pNextDocid ){\n    pIter = pDL->pNextDocid;\n  }else{\n    pIter = pDL->aAll;\n  }\n\n  if( pIter>=pEnd ){\n    /* We have already reached the end of this doclist. EOF. */\n    *pbEof = 1;\n  }else{\n    sqlite3_int64 iDelta;\n    pIter += sqlite3Fts3GetVarint(pIter, &iDelta);\n    if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){\n      pDL->iDocid += iDelta;\n    }else{\n      pDL->iDocid -= iDelta;\n    }\n    pDL->pList = pIter;\n    fts3PoslistCopy(0, &pIter);\n    pDL->nList = (int)(pIter - pDL->pList);\n\n    /* pIter now points just past the 0x00 that terminates the position-\n    ** list for document pDL->iDocid. However, if this position-list was\n    ** edited in place by fts3EvalNearTrim(), then pIter may not actually\n    ** point to the start of the next docid value. The following line deals\n    ** with this case by advancing pIter past the zero-padding added by\n    ** fts3EvalNearTrim().  */\n    while( pIter<pEnd && *pIter==0 ) pIter++;\n\n    pDL->pNextDocid = pIter;\n    assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );\n    *pbEof = 0;\n  }\n}\n\n/*\n** Helper type used by fts3EvalIncrPhraseNext() and incrPhraseTokenNext().\n*/\ntypedef struct TokenDoclist TokenDoclist;\nstruct TokenDoclist {\n  int bIgnore;\n  sqlite3_int64 iDocid;\n  char *pList;\n  int nList;\n};\n\n/*\n** Token pToken is an incrementally loaded token that is part of a \n** multi-token phrase. Advance it to the next matching document in the\n** database and populate output variable *p with the details of the new\n** entry. Or, if the iterator has reached EOF, set *pbEof to true.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int incrPhraseTokenNext(\n  Fts3Table *pTab,                /* Virtual table handle */\n  Fts3Phrase *pPhrase,            /* Phrase to advance token of */\n  int iToken,                     /* Specific token to advance */\n  TokenDoclist *p,                /* OUT: Docid and doclist for new entry */\n  u8 *pbEof                       /* OUT: True if iterator is at EOF */\n){\n  int rc = SQLITE_OK;\n\n  if( pPhrase->iDoclistToken==iToken ){\n    assert( p->bIgnore==0 );\n    assert( pPhrase->aToken[iToken].pSegcsr==0 );\n    fts3EvalDlPhraseNext(pTab, &pPhrase->doclist, pbEof);\n    p->pList = pPhrase->doclist.pList;\n    p->nList = pPhrase->doclist.nList;\n    p->iDocid = pPhrase->doclist.iDocid;\n  }else{\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    assert( pToken->pDeferred==0 );\n    assert( pToken->pSegcsr || pPhrase->iDoclistToken>=0 );\n    if( pToken->pSegcsr ){\n      assert( p->bIgnore==0 );\n      rc = sqlite3Fts3MsrIncrNext(\n          pTab, pToken->pSegcsr, &p->iDocid, &p->pList, &p->nList\n      );\n      if( p->pList==0 ) *pbEof = 1;\n    }else{\n      p->bIgnore = 1;\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** The phrase iterator passed as the second argument:\n**\n**   * features at least one token that uses an incremental doclist, and \n**\n**   * does not contain any deferred tokens.\n**\n** Advance it to the next matching documnent in the database and populate\n** the Fts3Doclist.pList and nList fields. \n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int fts3EvalIncrPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  u8 bEof = 0;\n\n  /* This is only called if it is guaranteed that the phrase has at least\n  ** one incremental token. In which case the bIncr flag is set. */\n  assert( p->bIncr==1 );\n\n  if( p->nToken==1 ){\n    rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, \n        &pDL->iDocid, &pDL->pList, &pDL->nList\n    );\n    if( pDL->pList==0 ) bEof = 1;\n  }else{\n    int bDescDoclist = pCsr->bDesc;\n    struct TokenDoclist a[MAX_INCR_PHRASE_TOKENS];\n\n    memset(a, 0, sizeof(a));\n    assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );\n    assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );\n\n    while( bEof==0 ){\n      int bMaxSet = 0;\n      sqlite3_int64 iMax = 0;     /* Largest docid for all iterators */\n      int i;                      /* Used to iterate through tokens */\n\n      /* Advance the iterator for each token in the phrase once. */\n      for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){\n        rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n        if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){\n          iMax = a[i].iDocid;\n          bMaxSet = 1;\n        }\n      }\n      assert( rc!=SQLITE_OK || (p->nToken>=1 && a[p->nToken-1].bIgnore==0) );\n      assert( rc!=SQLITE_OK || bMaxSet );\n\n      /* Keep advancing iterators until they all point to the same document */\n      for(i=0; i<p->nToken; i++){\n        while( rc==SQLITE_OK && bEof==0 \n            && a[i].bIgnore==0 && DOCID_CMP(a[i].iDocid, iMax)<0 \n        ){\n          rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n          if( DOCID_CMP(a[i].iDocid, iMax)>0 ){\n            iMax = a[i].iDocid;\n            i = 0;\n          }\n        }\n      }\n\n      /* Check if the current entries really are a phrase match */\n      if( bEof==0 ){\n        int nList = 0;\n        int nByte = a[p->nToken-1].nList;\n        char *aDoclist = sqlite3_malloc(nByte+1);\n        if( !aDoclist ) return SQLITE_NOMEM;\n        memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);\n\n        for(i=0; i<(p->nToken-1); i++){\n          if( a[i].bIgnore==0 ){\n            char *pL = a[i].pList;\n            char *pR = aDoclist;\n            char *pOut = aDoclist;\n            int nDist = p->nToken-1-i;\n            int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);\n            if( res==0 ) break;\n            nList = (int)(pOut - aDoclist);\n          }\n        }\n        if( i==(p->nToken-1) ){\n          pDL->iDocid = iMax;\n          pDL->pList = aDoclist;\n          pDL->nList = nList;\n          pDL->bFreeList = 1;\n          break;\n        }\n        sqlite3_free(aDoclist);\n      }\n    }\n  }\n\n  *pbEof = bEof;\n  return rc;\n}\n\n/*\n** Attempt to move the phrase iterator to point to the next matching docid. \n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n*/\nstatic int fts3EvalPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n\n  if( p->bIncr ){\n    rc = fts3EvalIncrPhraseNext(pCsr, p, pbEof);\n  }else if( pCsr->bDesc!=pTab->bDescIdx && pDL->nAll ){\n    sqlite3Fts3DoclistPrev(pTab->bDescIdx, pDL->aAll, pDL->nAll, \n        &pDL->pNextDocid, &pDL->iDocid, &pDL->nList, pbEof\n    );\n    pDL->pList = pDL->pNextDocid;\n  }else{\n    fts3EvalDlPhraseNext(pTab, pDL, pbEof);\n  }\n\n  return rc;\n}\n\n/*\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, fts3EvalPhraseStart() is called on all phrases within the\n** expression. Also the Fts3Expr.bDeferred variable is set to true for any\n** expressions for which all descendent tokens are deferred.\n**\n** If parameter bOptOk is zero, then it is guaranteed that the\n** Fts3Phrase.doclist.aAll/nAll variables contain the entire doclist for\n** each phrase in the expression (subject to deferred token processing).\n** Or, if bOptOk is non-zero, then one or more tokens within the expression\n** may be loaded incrementally, meaning doclist.aAll/nAll is not available.\n**\n** If an error occurs within this function, *pRc is set to an SQLite error\n** code before returning.\n*/\nstatic void fts3EvalStartReaders(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expression to initialize phrases in */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int nToken = pExpr->pPhrase->nToken;\n      if( nToken ){\n        int i;\n        for(i=0; i<nToken; i++){\n          if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;\n        }\n        pExpr->bDeferred = (i==nToken);\n      }\n      *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);\n    }else{\n      fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);\n      fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);\n      pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);\n    }\n  }\n}\n\n/*\n** An array of the following structures is assembled as part of the process\n** of selecting tokens to defer before the query starts executing (as part\n** of the xFilter() method). There is one element in the array for each\n** token in the FTS expression.\n**\n** Tokens are divided into AND/NEAR clusters. All tokens in a cluster belong\n** to phrases that are connected only by AND and NEAR operators (not OR or\n** NOT). When determining tokens to defer, each AND/NEAR cluster is considered\n** separately. The root of a tokens AND/NEAR cluster is stored in \n** Fts3TokenAndCost.pRoot.\n*/\ntypedef struct Fts3TokenAndCost Fts3TokenAndCost;\nstruct Fts3TokenAndCost {\n  Fts3Phrase *pPhrase;            /* The phrase the token belongs to */\n  int iToken;                     /* Position of token in phrase */\n  Fts3PhraseToken *pToken;        /* The token itself */\n  Fts3Expr *pRoot;                /* Root of NEAR/AND cluster */\n  int nOvfl;                      /* Number of overflow pages to load doclist */\n  int iCol;                       /* The column the token must match */\n};\n\n/*\n** This function is used to populate an allocated Fts3TokenAndCost array.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if an error occurs during execution, *pRc is set to an\n** SQLite error code.\n*/\nstatic void fts3EvalTokenCosts(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Root of current AND/NEAR cluster */\n  Fts3Expr *pExpr,                /* Expression to consider */\n  Fts3TokenAndCost **ppTC,        /* Write new entries to *(*ppTC)++ */\n  Fts3Expr ***ppOr,               /* Write new OR root to *(*ppOr)++ */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){\n        Fts3TokenAndCost *pTC = (*ppTC)++;\n        pTC->pPhrase = pPhrase;\n        pTC->iToken = i;\n        pTC->pRoot = pRoot;\n        pTC->pToken = &pPhrase->aToken[i];\n        pTC->iCol = pPhrase->iColumn;\n        *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);\n      }\n    }else if( pExpr->eType!=FTSQUERY_NOT ){\n      assert( pExpr->eType==FTSQUERY_OR\n           || pExpr->eType==FTSQUERY_AND\n           || pExpr->eType==FTSQUERY_NEAR\n      );\n      assert( pExpr->pLeft && pExpr->pRight );\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pLeft;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pRight;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);\n    }\n  }\n}\n\n/*\n** Determine the average document (row) size in pages. If successful,\n** write this value to *pnPage and return SQLITE_OK. Otherwise, return\n** an SQLite error code.\n**\n** The average document size in pages is calculated by first calculating \n** determining the average size in bytes, B. If B is less than the amount\n** of data that will fit on a single leaf page of an intkey table in\n** this database, then the average docsize is 1. Otherwise, it is 1 plus\n** the number of overflow pages consumed by a record B bytes in size.\n*/\nstatic int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){\n  int rc = SQLITE_OK;\n  if( pCsr->nRowAvg==0 ){\n    /* The average document size, which is required to calculate the cost\n    ** of each doclist, has not yet been determined. Read the required \n    ** data from the %_stat table to calculate it.\n    **\n    ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3 \n    ** varints, where nCol is the number of columns in the FTS3 table.\n    ** The first varint is the number of documents currently stored in\n    ** the table. The following nCol varints contain the total amount of\n    ** data stored in all rows of each column of the table, from left\n    ** to right.\n    */\n    Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n    sqlite3_stmt *pStmt;\n    sqlite3_int64 nDoc = 0;\n    sqlite3_int64 nByte = 0;\n    const char *pEnd;\n    const char *a;\n\n    rc = sqlite3Fts3SelectDoctotal(p, &pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n    a = sqlite3_column_blob(pStmt, 0);\n    assert( a );\n\n    pEnd = &a[sqlite3_column_bytes(pStmt, 0)];\n    a += sqlite3Fts3GetVarint(a, &nDoc);\n    while( a<pEnd ){\n      a += sqlite3Fts3GetVarint(a, &nByte);\n    }\n    if( nDoc==0 || nByte==0 ){\n      sqlite3_reset(pStmt);\n      return FTS_CORRUPT_VTAB;\n    }\n\n    pCsr->nDoc = nDoc;\n    pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz);\n    assert( pCsr->nRowAvg>0 ); \n    rc = sqlite3_reset(pStmt);\n  }\n\n  *pnPage = pCsr->nRowAvg;\n  return rc;\n}\n\n/*\n** This function is called to select the tokens (if any) that will be \n** deferred. The array aTC[] has already been populated when this is\n** called.\n**\n** This function is called once for each AND/NEAR cluster in the \n** expression. Each invocation determines which tokens to defer within\n** the cluster with root node pRoot. See comments above the definition\n** of struct Fts3TokenAndCost for more details.\n**\n** If no error occurs, SQLITE_OK is returned and sqlite3Fts3DeferToken()\n** called on each token to defer. Otherwise, an SQLite error code is\n** returned.\n*/\nstatic int fts3EvalSelectDeferred(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Consider tokens with this root node */\n  Fts3TokenAndCost *aTC,          /* Array of expression tokens and costs */\n  int nTC                         /* Number of entries in aTC[] */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int nDocSize = 0;               /* Number of pages per doc loaded */\n  int rc = SQLITE_OK;             /* Return code */\n  int ii;                         /* Iterator variable for various purposes */\n  int nOvfl = 0;                  /* Total overflow pages used by doclists */\n  int nToken = 0;                 /* Total number of tokens in cluster */\n\n  int nMinEst = 0;                /* The minimum count for any phrase so far. */\n  int nLoad4 = 1;                 /* (Phrases that will be loaded)^4. */\n\n  /* Tokens are never deferred for FTS tables created using the content=xxx\n  ** option. The reason being that it is not guaranteed that the content\n  ** table actually contains the same data as the index. To prevent this from\n  ** causing any problems, the deferred token optimization is completely\n  ** disabled for content=xxx tables. */\n  if( pTab->zContentTbl ){\n    return SQLITE_OK;\n  }\n\n  /* Count the tokens in this AND/NEAR cluster. If none of the doclists\n  ** associated with the tokens spill onto overflow pages, or if there is\n  ** only 1 token, exit early. No tokens to defer in this case. */\n  for(ii=0; ii<nTC; ii++){\n    if( aTC[ii].pRoot==pRoot ){\n      nOvfl += aTC[ii].nOvfl;\n      nToken++;\n    }\n  }\n  if( nOvfl==0 || nToken<2 ) return SQLITE_OK;\n\n  /* Obtain the average docsize (in pages). */\n  rc = fts3EvalAverageDocsize(pCsr, &nDocSize);\n  assert( rc!=SQLITE_OK || nDocSize>0 );\n\n\n  /* Iterate through all tokens in this AND/NEAR cluster, in ascending order \n  ** of the number of overflow pages that will be loaded by the pager layer \n  ** to retrieve the entire doclist for the token from the full-text index.\n  ** Load the doclists for tokens that are either:\n  **\n  **   a. The cheapest token in the entire query (i.e. the one visited by the\n  **      first iteration of this loop), or\n  **\n  **   b. Part of a multi-token phrase.\n  **\n  ** After each token doclist is loaded, merge it with the others from the\n  ** same phrase and count the number of documents that the merged doclist\n  ** contains. Set variable \"nMinEst\" to the smallest number of documents in \n  ** any phrase doclist for which 1 or more token doclists have been loaded.\n  ** Let nOther be the number of other phrases for which it is certain that\n  ** one or more tokens will not be deferred.\n  **\n  ** Then, for each token, defer it if loading the doclist would result in\n  ** loading N or more overflow pages into memory, where N is computed as:\n  **\n  **    (nMinEst + 4^nOther - 1) / (4^nOther)\n  */\n  for(ii=0; ii<nToken && rc==SQLITE_OK; ii++){\n    int iTC;                      /* Used to iterate through aTC[] array. */\n    Fts3TokenAndCost *pTC = 0;    /* Set to cheapest remaining token. */\n\n    /* Set pTC to point to the cheapest remaining token. */\n    for(iTC=0; iTC<nTC; iTC++){\n      if( aTC[iTC].pToken && aTC[iTC].pRoot==pRoot \n       && (!pTC || aTC[iTC].nOvfl<pTC->nOvfl) \n      ){\n        pTC = &aTC[iTC];\n      }\n    }\n    assert( pTC );\n\n    if( ii && pTC->nOvfl>=((nMinEst+(nLoad4/4)-1)/(nLoad4/4))*nDocSize ){\n      /* The number of overflow pages to load for this (and therefore all\n      ** subsequent) tokens is greater than the estimated number of pages \n      ** that will be loaded if all subsequent tokens are deferred.\n      */\n      Fts3PhraseToken *pToken = pTC->pToken;\n      rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);\n      fts3SegReaderCursorFree(pToken->pSegcsr);\n      pToken->pSegcsr = 0;\n    }else{\n      /* Set nLoad4 to the value of (4^nOther) for the next iteration of the\n      ** for-loop. Except, limit the value to 2^24 to prevent it from \n      ** overflowing the 32-bit integer it is stored in. */\n      if( ii<12 ) nLoad4 = nLoad4*4;\n\n      if( ii==0 || (pTC->pPhrase->nToken>1 && ii!=nToken-1) ){\n        /* Either this is the cheapest token in the entire query, or it is\n        ** part of a multi-token phrase. Either way, the entire doclist will\n        ** (eventually) be loaded into memory. It may as well be now. */\n        Fts3PhraseToken *pToken = pTC->pToken;\n        int nList = 0;\n        char *pList = 0;\n        rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);\n        assert( rc==SQLITE_OK || pList==0 );\n        if( rc==SQLITE_OK ){\n          rc = fts3EvalPhraseMergeToken(\n              pTab, pTC->pPhrase, pTC->iToken,pList,nList\n          );\n        }\n        if( rc==SQLITE_OK ){\n          int nCount;\n          nCount = fts3DoclistCountDocids(\n              pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll\n          );\n          if( ii==0 || nCount<nMinEst ) nMinEst = nCount;\n        }\n      }\n    }\n    pTC->pToken = 0;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called from within the xFilter method. It initializes\n** the full-text query currently stored in pCsr->pExpr. To iterate through\n** the results of a query, the caller does:\n**\n**    fts3EvalStart(pCsr);\n**    while( 1 ){\n**      fts3EvalNext(pCsr);\n**      if( pCsr->bEof ) break;\n**      ... return row pCsr->iPrevId to the caller ...\n**    }\n*/\nstatic int fts3EvalStart(Fts3Cursor *pCsr){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int nToken = 0;\n  int nOr = 0;\n\n  /* Allocate a MultiSegReader for each token in the expression. */\n  fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);\n\n  /* Determine which, if any, tokens in the expression should be deferred. */\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n  if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){\n    Fts3TokenAndCost *aTC;\n    Fts3Expr **apOr;\n    aTC = (Fts3TokenAndCost *)sqlite3_malloc(\n        sizeof(Fts3TokenAndCost) * nToken\n      + sizeof(Fts3Expr *) * nOr * 2\n    );\n    apOr = (Fts3Expr **)&aTC[nToken];\n\n    if( !aTC ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int ii;\n      Fts3TokenAndCost *pTC = aTC;\n      Fts3Expr **ppOr = apOr;\n\n      fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);\n      nToken = (int)(pTC-aTC);\n      nOr = (int)(ppOr-apOr);\n\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);\n        for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){\n          rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);\n        }\n      }\n\n      sqlite3_free(aTC);\n    }\n  }\n#endif\n\n  fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);\n  return rc;\n}\n\n/*\n** Invalidate the current position list for phrase pPhrase.\n*/\nstatic void fts3EvalInvalidatePoslist(Fts3Phrase *pPhrase){\n  if( pPhrase->doclist.bFreeList ){\n    sqlite3_free(pPhrase->doclist.pList);\n  }\n  pPhrase->doclist.pList = 0;\n  pPhrase->doclist.nList = 0;\n  pPhrase->doclist.bFreeList = 0;\n}\n\n/*\n** This function is called to edit the position list associated with\n** the phrase object passed as the fifth argument according to a NEAR\n** condition. For example:\n**\n**     abc NEAR/5 \"def ghi\"\n**\n** Parameter nNear is passed the NEAR distance of the expression (5 in\n** the example above). When this function is called, *paPoslist points to\n** the position list, and *pnToken is the number of phrase tokens in, the\n** phrase on the other side of the NEAR operator to pPhrase. For example,\n** if pPhrase refers to the \"def ghi\" phrase, then *paPoslist points to\n** the position list associated with phrase \"abc\".\n**\n** All positions in the pPhrase position list that are not sufficiently\n** close to a position in the *paPoslist position list are removed. If this\n** leaves 0 positions, zero is returned. Otherwise, non-zero.\n**\n** Before returning, *paPoslist is set to point to the position lsit \n** associated with pPhrase. And *pnToken is set to the number of tokens in\n** pPhrase.\n*/\nstatic int fts3EvalNearTrim(\n  int nNear,                      /* NEAR distance. As in \"NEAR/nNear\". */\n  char *aTmp,                     /* Temporary space to use */\n  char **paPoslist,               /* IN/OUT: Position list */\n  int *pnToken,                   /* IN/OUT: Tokens in phrase of *paPoslist */\n  Fts3Phrase *pPhrase             /* The phrase object to trim the doclist of */\n){\n  int nParam1 = nNear + pPhrase->nToken;\n  int nParam2 = nNear + *pnToken;\n  int nNew;\n  char *p2; \n  char *pOut; \n  int res;\n\n  assert( pPhrase->doclist.pList );\n\n  p2 = pOut = pPhrase->doclist.pList;\n  res = fts3PoslistNearMerge(\n    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2\n  );\n  if( res ){\n    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;\n    assert( pPhrase->doclist.pList[nNew]=='\\0' );\n    assert( nNew<=pPhrase->doclist.nList && nNew>0 );\n    memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);\n    pPhrase->doclist.nList = nNew;\n    *paPoslist = pPhrase->doclist.pList;\n    *pnToken = pPhrase->nToken;\n  }\n\n  return res;\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is called.\n** Otherwise, it advances the expression passed as the second argument to\n** point to the next matching row in the database. Expressions iterate through\n** matching rows in docid order. Ascending order if Fts3Cursor.bDesc is zero,\n** or descending if it is non-zero.\n**\n** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if\n** successful, the following variables in pExpr are set:\n**\n**   Fts3Expr.bEof                (non-zero if EOF - there is no next row)\n**   Fts3Expr.iDocid              (valid if bEof==0. The docid of the next row)\n**\n** If the expression is of type FTSQUERY_PHRASE, and the expression is not\n** at EOF, then the following variables are populated with the position list\n** for the phrase for the visited row:\n**\n**   FTs3Expr.pPhrase->doclist.nList        (length of pList in bytes)\n**   FTs3Expr.pPhrase->doclist.pList        (pointer to position list)\n**\n** It says above that this function advances the expression to the next\n** matching row. This is usually true, but there are the following exceptions:\n**\n**   1. Deferred tokens are not taken into account. If a phrase consists\n**      entirely of deferred tokens, it is assumed to match every row in\n**      the db. In this case the position-list is not populated at all. \n**\n**      Or, if a phrase contains one or more deferred tokens and one or\n**      more non-deferred tokens, then the expression is advanced to the \n**      next possible match, considering only non-deferred tokens. In other\n**      words, if the phrase is \"A B C\", and \"B\" is deferred, the expression\n**      is advanced to the next row that contains an instance of \"A * C\", \n**      where \"*\" may match any single token. The position list in this case\n**      is populated as for \"A * C\" before returning.\n**\n**   2. NEAR is treated as AND. If the expression is \"x NEAR y\", it is \n**      advanced to point to the next row that matches \"x AND y\".\n** \n** See sqlite3Fts3EvalTestDeferred() for details on testing if a row is\n** really a match, taking into account deferred tokens and NEAR operators.\n*/\nstatic void fts3EvalNextRow(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expr. to advance to next matching row */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int bDescDoclist = pCsr->bDesc;         /* Used by DOCID_CMP() macro */\n    assert( pExpr->bEof==0 );\n    pExpr->bStart = 1;\n\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        assert( !pLeft->bDeferred || !pRight->bDeferred );\n\n        if( pLeft->bDeferred ){\n          /* LHS is entirely deferred. So we assume it matches every row.\n          ** Advance the RHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          pExpr->iDocid = pRight->iDocid;\n          pExpr->bEof = pRight->bEof;\n        }else if( pRight->bDeferred ){\n          /* RHS is entirely deferred. So we assume it matches every row.\n          ** Advance the LHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = pLeft->bEof;\n        }else{\n          /* Neither the RHS or LHS are deferred. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          while( !pLeft->bEof && !pRight->bEof && *pRc==SQLITE_OK ){\n            sqlite3_int64 iDiff = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n            if( iDiff==0 ) break;\n            if( iDiff<0 ){\n              fts3EvalNextRow(pCsr, pLeft, pRc);\n            }else{\n              fts3EvalNextRow(pCsr, pRight, pRc);\n            }\n          }\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = (pLeft->bEof || pRight->bEof);\n          if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){\n            assert( pRight->eType==FTSQUERY_PHRASE );\n            if( pRight->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pRight->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pRight->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pRight, pRc);\n              }\n            }\n            if( pLeft->pPhrase && pLeft->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pLeft->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pLeft->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pLeft, pRc);\n              }\n            }\n          }\n        }\n        break;\n      }\n  \n      case FTSQUERY_OR: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n\n        assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid );\n        assert( pRight->bStart || pLeft->iDocid==pRight->iDocid );\n\n        if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n        }else if( pLeft->bEof || iCmp>0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }else{\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }\n\n        pExpr->bEof = (pLeft->bEof && pRight->bEof);\n        iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n        if( pRight->bEof || (pLeft->bEof==0 &&  iCmp<0) ){\n          pExpr->iDocid = pLeft->iDocid;\n        }else{\n          pExpr->iDocid = pRight->iDocid;\n        }\n\n        break;\n      }\n\n      case FTSQUERY_NOT: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n\n        if( pRight->bStart==0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          assert( *pRc!=SQLITE_OK || pRight->bStart );\n        }\n\n        fts3EvalNextRow(pCsr, pLeft, pRc);\n        if( pLeft->bEof==0 ){\n          while( !*pRc \n              && !pRight->bEof \n              && DOCID_CMP(pLeft->iDocid, pRight->iDocid)>0 \n          ){\n            fts3EvalNextRow(pCsr, pRight, pRc);\n          }\n        }\n        pExpr->iDocid = pLeft->iDocid;\n        pExpr->bEof = pLeft->bEof;\n        break;\n      }\n\n      default: {\n        Fts3Phrase *pPhrase = pExpr->pPhrase;\n        fts3EvalInvalidatePoslist(pPhrase);\n        *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);\n        pExpr->iDocid = pPhrase->doclist.iDocid;\n        break;\n      }\n    }\n  }\n}\n\n/*\n** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR\n** cluster, then this function returns 1 immediately.\n**\n** Otherwise, it checks if the current row really does match the NEAR \n** expression, using the data currently stored in the position lists \n** (Fts3Expr->pPhrase.doclist.pList/nList) for each phrase in the expression. \n**\n** If the current row is a match, the position list associated with each\n** phrase in the NEAR expression is edited in place to contain only those\n** phrase instances sufficiently close to their peers to satisfy all NEAR\n** constraints. In this case it returns 1. If the NEAR expression does not \n** match the current row, 0 is returned. The position lists may or may not\n** be edited if 0 is returned.\n*/\nstatic int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){\n  int res = 1;\n\n  /* The following block runs if pExpr is the root of a NEAR query.\n  ** For example, the query:\n  **\n  **         \"w\" NEAR \"x\" NEAR \"y\" NEAR \"z\"\n  **\n  ** which is represented in tree form as:\n  **\n  **                               |\n  **                          +--NEAR--+      <-- root of NEAR query\n  **                          |        |\n  **                     +--NEAR--+   \"z\"\n  **                     |        |\n  **                +--NEAR--+   \"y\"\n  **                |        |\n  **               \"w\"      \"x\"\n  **\n  ** The right-hand child of a NEAR node is always a phrase. The \n  ** left-hand child may be either a phrase or a NEAR node. There are\n  ** no exceptions to this - it's the way the parser in fts3_expr.c works.\n  */\n  if( *pRc==SQLITE_OK \n   && pExpr->eType==FTSQUERY_NEAR \n   && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n  ){\n    Fts3Expr *p; \n    int nTmp = 0;                 /* Bytes of temp space */\n    char *aTmp;                   /* Temp space for PoslistNearMerge() */\n\n    /* Allocate temporary working space. */\n    for(p=pExpr; p->pLeft; p=p->pLeft){\n      assert( p->pRight->pPhrase->doclist.nList>0 );\n      nTmp += p->pRight->pPhrase->doclist.nList;\n    }\n    nTmp += p->pPhrase->doclist.nList;\n    aTmp = sqlite3_malloc(nTmp*2);\n    if( !aTmp ){\n      *pRc = SQLITE_NOMEM;\n      res = 0;\n    }else{\n      char *aPoslist = p->pPhrase->doclist.pList;\n      int nToken = p->pPhrase->nToken;\n\n      for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){\n        Fts3Phrase *pPhrase = p->pRight->pPhrase;\n        int nNear = p->nNear;\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n\n      aPoslist = pExpr->pRight->pPhrase->doclist.pList;\n      nToken = pExpr->pRight->pPhrase->nToken;\n      for(p=pExpr->pLeft; p && res; p=p->pLeft){\n        int nNear;\n        Fts3Phrase *pPhrase;\n        assert( p->pParent && p->pParent->pLeft==p );\n        nNear = p->pParent->nNear;\n        pPhrase = (\n            p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase\n        );\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n    }\n\n    sqlite3_free(aTmp);\n  }\n\n  return res;\n}\n\n/*\n** This function is a helper function for sqlite3Fts3EvalTestDeferred().\n** Assuming no error occurs or has occurred, It returns non-zero if the\n** expression passed as the second argument matches the row that pCsr \n** currently points to, or zero if it does not.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** If an error occurs during execution of this function, *pRc is set to \n** the appropriate SQLite error code. In this case the returned value is \n** undefined.\n*/\nstatic int fts3EvalTestExpr(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Expr to test. May or may not be root. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int bHit = 1;                   /* Return value */\n  if( *pRc==SQLITE_OK ){\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n         && fts3EvalNearTest(pExpr, pRc)\n        );\n\n        /* If the NEAR expression does not match any rows, zero the doclist for \n        ** all phrases involved in the NEAR. This is because the snippet(),\n        ** offsets() and matchinfo() functions are not supposed to recognize \n        ** any instances of phrases that are part of unmatched NEAR queries. \n        ** For example if this expression:\n        **\n        **    ... MATCH 'a OR (b NEAR c)'\n        **\n        ** is matched against a row containing:\n        **\n        **        'a b d e'\n        **\n        ** then any snippet() should ony highlight the \"a\" term, not the \"b\"\n        ** (as \"b\" is part of a non-matching NEAR clause).\n        */\n        if( bHit==0 \n         && pExpr->eType==FTSQUERY_NEAR \n         && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n        ){\n          Fts3Expr *p;\n          for(p=pExpr; p->pPhrase==0; p=p->pLeft){\n            if( p->pRight->iDocid==pCsr->iPrevId ){\n              fts3EvalInvalidatePoslist(p->pRight->pPhrase);\n            }\n          }\n          if( p->iDocid==pCsr->iPrevId ){\n            fts3EvalInvalidatePoslist(p->pPhrase);\n          }\n        }\n\n        break;\n\n      case FTSQUERY_OR: {\n        int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);\n        int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);\n        bHit = bHit1 || bHit2;\n        break;\n      }\n\n      case FTSQUERY_NOT:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n        );\n        break;\n\n      default: {\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n        if( pCsr->pDeferred \n         && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)\n        ){\n          Fts3Phrase *pPhrase = pExpr->pPhrase;\n          assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );\n          if( pExpr->bDeferred ){\n            fts3EvalInvalidatePoslist(pPhrase);\n          }\n          *pRc = fts3EvalDeferredPhrase(pCsr, pPhrase);\n          bHit = (pPhrase->doclist.pList!=0);\n          pExpr->iDocid = pCsr->iPrevId;\n        }else\n#endif\n        {\n          bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);\n        }\n        break;\n      }\n    }\n  }\n  return bHit;\n}\n\n/*\n** This function is called as the second part of each xNext operation when\n** iterating through the results of a full-text query. At this point the\n** cursor points to a row that matches the query expression, with the\n** following caveats:\n**\n**   * Up until this point, \"NEAR\" operators in the expression have been\n**     treated as \"AND\".\n**\n**   * Deferred tokens have not yet been considered.\n**\n** If *pRc is not SQLITE_OK when this function is called, it immediately\n** returns 0. Otherwise, it tests whether or not after considering NEAR\n** operators and deferred tokens the current row is still a match for the\n** expression. It returns 1 if both of the following are true:\n**\n**   1. *pRc is SQLITE_OK when this function returns, and\n**\n**   2. After scanning the current FTS table row for the deferred tokens,\n**      it is determined that the row does *not* match the query.\n**\n** Or, if no error occurs and it seems the current row does match the FTS\n** query, return 0.\n*/\nint sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc){\n  int rc = *pRc;\n  int bMiss = 0;\n  if( rc==SQLITE_OK ){\n\n    /* If there are one or more deferred tokens, load the current row into\n    ** memory and scan it to determine the position list for each deferred\n    ** token. Then, see if this row is really a match, considering deferred\n    ** tokens and NEAR operators (neither of which were taken into account\n    ** earlier, by fts3EvalNextRow()). \n    */\n    if( pCsr->pDeferred ){\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts3CacheDeferredDoclists(pCsr);\n      }\n    }\n    bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));\n\n    /* Free the position-lists accumulated for each deferred token above. */\n    sqlite3Fts3FreeDeferredDoclists(pCsr);\n    *pRc = rc;\n  }\n  return (rc==SQLITE_OK && bMiss);\n}\n\n/*\n** Advance to the next document that matches the FTS expression in\n** Fts3Cursor.pExpr.\n*/\nstatic int fts3EvalNext(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Expr *pExpr = pCsr->pExpr;\n  assert( pCsr->isEof==0 );\n  if( pExpr==0 ){\n    pCsr->isEof = 1;\n  }else{\n    do {\n      if( pCsr->isRequireSeek==0 ){\n        sqlite3_reset(pCsr->pStmt);\n      }\n      assert( sqlite3_data_count(pCsr->pStmt)==0 );\n      fts3EvalNextRow(pCsr, pExpr, &rc);\n      pCsr->isEof = pExpr->bEof;\n      pCsr->isRequireSeek = 1;\n      pCsr->isMatchinfoNeeded = 1;\n      pCsr->iPrevId = pExpr->iDocid;\n    }while( pCsr->isEof==0 && sqlite3Fts3EvalTestDeferred(pCsr, &rc) );\n  }\n\n  /* Check if the cursor is past the end of the docid range specified\n  ** by Fts3Cursor.iMinDocid/iMaxDocid. If so, set the EOF flag.  */\n  if( rc==SQLITE_OK && (\n        (pCsr->bDesc==0 && pCsr->iPrevId>pCsr->iMaxDocid)\n     || (pCsr->bDesc!=0 && pCsr->iPrevId<pCsr->iMinDocid)\n  )){\n    pCsr->isEof = 1;\n  }\n\n  return rc;\n}\n\n/*\n** Restart interation for expression pExpr so that the next call to\n** fts3EvalNext() visits the first row. Do not allow incremental \n** loading or merging of phrase doclists for this iteration.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op. If an error occurs within this function, *pRc is set to an\n** SQLite error code before returning.\n*/\nstatic void fts3EvalRestart(\n  Fts3Cursor *pCsr,\n  Fts3Expr *pExpr,\n  int *pRc\n){\n  if( pExpr && *pRc==SQLITE_OK ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n\n    if( pPhrase ){\n      fts3EvalInvalidatePoslist(pPhrase);\n      if( pPhrase->bIncr ){\n        int i;\n        for(i=0; i<pPhrase->nToken; i++){\n          Fts3PhraseToken *pToken = &pPhrase->aToken[i];\n          assert( pToken->pDeferred==0 );\n          if( pToken->pSegcsr ){\n            sqlite3Fts3MsrIncrRestart(pToken->pSegcsr);\n          }\n        }\n        *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);\n      }\n      pPhrase->doclist.pNextDocid = 0;\n      pPhrase->doclist.iDocid = 0;\n      pPhrase->pOrPoslist = 0;\n    }\n\n    pExpr->iDocid = 0;\n    pExpr->bEof = 0;\n    pExpr->bStart = 0;\n\n    fts3EvalRestart(pCsr, pExpr->pLeft, pRc);\n    fts3EvalRestart(pCsr, pExpr->pRight, pRc);\n  }\n}\n\n/*\n** After allocating the Fts3Expr.aMI[] array for each phrase in the \n** expression rooted at pExpr, the cursor iterates through all rows matched\n** by pExpr, calling this function for each row. This function increments\n** the values in Fts3Expr.aMI[] according to the position-list currently\n** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase \n** expression nodes.\n*/\nstatic void fts3EvalUpdateCounts(Fts3Expr *pExpr){\n  if( pExpr ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n    if( pPhrase && pPhrase->doclist.pList ){\n      int iCol = 0;\n      char *p = pPhrase->doclist.pList;\n\n      assert( *p );\n      while( 1 ){\n        u8 c = 0;\n        int iCnt = 0;\n        while( 0xFE & (*p | c) ){\n          if( (c&0x80)==0 ) iCnt++;\n          c = *p++ & 0x80;\n        }\n\n        /* aMI[iCol*3 + 1] = Number of occurrences\n        ** aMI[iCol*3 + 2] = Number of rows containing at least one instance\n        */\n        pExpr->aMI[iCol*3 + 1] += iCnt;\n        pExpr->aMI[iCol*3 + 2] += (iCnt>0);\n        if( *p==0x00 ) break;\n        p++;\n        p += fts3GetVarint32(p, &iCol);\n      }\n    }\n\n    fts3EvalUpdateCounts(pExpr->pLeft);\n    fts3EvalUpdateCounts(pExpr->pRight);\n  }\n}\n\n/*\n** Expression pExpr must be of type FTSQUERY_PHRASE.\n**\n** If it is not already allocated and populated, this function allocates and\n** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part\n** of a NEAR expression, then it also allocates and populates the same array\n** for all other phrases that are part of the NEAR expression.\n**\n** SQLITE_OK is returned if the aMI[] array is successfully allocated and\n** populated. Otherwise, if an error occurs, an SQLite error code is returned.\n*/\nstatic int fts3EvalGatherStats(\n  Fts3Cursor *pCsr,               /* Cursor object */\n  Fts3Expr *pExpr                 /* FTSQUERY_PHRASE expression */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pExpr->eType==FTSQUERY_PHRASE );\n  if( pExpr->aMI==0 ){\n    Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n    Fts3Expr *pRoot;                /* Root of NEAR expression */\n    Fts3Expr *p;                    /* Iterator used for several purposes */\n\n    sqlite3_int64 iPrevId = pCsr->iPrevId;\n    sqlite3_int64 iDocid;\n    u8 bEof;\n\n    /* Find the root of the NEAR expression */\n    pRoot = pExpr;\n    while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){\n      pRoot = pRoot->pParent;\n    }\n    iDocid = pRoot->iDocid;\n    bEof = pRoot->bEof;\n    assert( pRoot->bStart );\n\n    /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */\n    for(p=pRoot; p; p=p->pLeft){\n      Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);\n      assert( pE->aMI==0 );\n      pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));\n      if( !pE->aMI ) return SQLITE_NOMEM;\n      memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));\n    }\n\n    fts3EvalRestart(pCsr, pRoot, &rc);\n\n    while( pCsr->isEof==0 && rc==SQLITE_OK ){\n\n      do {\n        /* Ensure the %_content statement is reset. */\n        if( pCsr->isRequireSeek==0 ) sqlite3_reset(pCsr->pStmt);\n        assert( sqlite3_data_count(pCsr->pStmt)==0 );\n\n        /* Advance to the next document */\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        pCsr->isEof = pRoot->bEof;\n        pCsr->isRequireSeek = 1;\n        pCsr->isMatchinfoNeeded = 1;\n        pCsr->iPrevId = pRoot->iDocid;\n      }while( pCsr->isEof==0 \n           && pRoot->eType==FTSQUERY_NEAR \n           && sqlite3Fts3EvalTestDeferred(pCsr, &rc) \n      );\n\n      if( rc==SQLITE_OK && pCsr->isEof==0 ){\n        fts3EvalUpdateCounts(pRoot);\n      }\n    }\n\n    pCsr->isEof = 0;\n    pCsr->iPrevId = iPrevId;\n\n    if( bEof ){\n      pRoot->bEof = bEof;\n    }else{\n      /* Caution: pRoot may iterate through docids in ascending or descending\n      ** order. For this reason, even though it seems more defensive, the \n      ** do loop can not be written:\n      **\n      **   do {...} while( pRoot->iDocid<iDocid && rc==SQLITE_OK );\n      */\n      fts3EvalRestart(pCsr, pRoot, &rc);\n      do {\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        assert( pRoot->bEof==0 );\n      }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used by the matchinfo() module to query a phrase \n** expression node for the following information:\n**\n**   1. The total number of occurrences of the phrase in each column of \n**      the FTS table (considering all rows), and\n**\n**   2. For each column, the number of rows in the table for which the\n**      column contains at least one instance of the phrase.\n**\n** If no error occurs, SQLITE_OK is returned and the values for each column\n** written into the array aiOut as follows:\n**\n**   aiOut[iCol*3 + 1] = Number of occurrences\n**   aiOut[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** Caveats:\n**\n**   * If a phrase consists entirely of deferred tokens, then all output \n**     values are set to the number of documents in the table. In other\n**     words we assume that very common tokens occur exactly once in each \n**     column of each row of the table.\n**\n**   * If a phrase contains some deferred tokens (and some non-deferred \n**     tokens), count the potential occurrence identified by considering\n**     the non-deferred tokens instead of actual phrase occurrences.\n**\n**   * If the phrase is part of a NEAR expression, then only phrase instances\n**     that meet the NEAR constraint are included in the counts.\n*/\nint sqlite3Fts3EvalPhraseStats(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Phrase expression */\n  u32 *aiOut                      /* Array to write results into (see above) */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int iCol;\n\n  if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){\n    assert( pCsr->nDoc>0 );\n    for(iCol=0; iCol<pTab->nColumn; iCol++){\n      aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;\n      aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;\n    }\n  }else{\n    rc = fts3EvalGatherStats(pCsr, pExpr);\n    if( rc==SQLITE_OK ){\n      assert( pExpr->aMI );\n      for(iCol=0; iCol<pTab->nColumn; iCol++){\n        aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];\n        aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The expression pExpr passed as the second argument to this function\n** must be of type FTSQUERY_PHRASE. \n**\n** The returned value is either NULL or a pointer to a buffer containing\n** a position-list indicating the occurrences of the phrase in column iCol\n** of the current row. \n**\n** More specifically, the returned buffer contains 1 varint for each \n** occurrence of the phrase in the column, stored using the normal (delta+2) \n** compression and is terminated by either an 0x01 or 0x00 byte. For example,\n** if the requested column contains \"a b X c d X X\" and the position-list\n** for 'X' is requested, the buffer returned may contain:\n**\n**     0x04 0x05 0x03 0x01   or   0x04 0x05 0x03 0x00\n**\n** This function works regardless of whether or not the phrase is deferred,\n** incremental, or neither.\n*/\nint sqlite3Fts3EvalPhrasePoslist(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  Fts3Expr *pExpr,                /* Phrase to return doclist for */\n  int iCol,                       /* Column to return position list for */\n  char **ppOut                    /* OUT: Pointer to position list */\n){\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  char *pIter;\n  int iThis;\n  sqlite3_int64 iDocid;\n\n  /* If this phrase is applies specifically to some column other than \n  ** column iCol, return a NULL pointer.  */\n  *ppOut = 0;\n  assert( iCol>=0 && iCol<pTab->nColumn );\n  if( (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol) ){\n    return SQLITE_OK;\n  }\n\n  iDocid = pExpr->iDocid;\n  pIter = pPhrase->doclist.pList;\n  if( iDocid!=pCsr->iPrevId || pExpr->bEof ){\n    int rc = SQLITE_OK;\n    int bDescDoclist = pTab->bDescIdx;      /* For DOCID_CMP macro */\n    int bOr = 0;\n    u8 bTreeEof = 0;\n    Fts3Expr *p;                  /* Used to iterate from pExpr to root */\n    Fts3Expr *pNear;              /* Most senior NEAR ancestor (or pExpr) */\n    int bMatch;\n\n    /* Check if this phrase descends from an OR expression node. If not, \n    ** return NULL. Otherwise, the entry that corresponds to docid \n    ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the\n    ** tree that the node is part of has been marked as EOF, but the node\n    ** itself is not EOF, then it may point to an earlier entry. */\n    pNear = pExpr;\n    for(p=pExpr->pParent; p; p=p->pParent){\n      if( p->eType==FTSQUERY_OR ) bOr = 1;\n      if( p->eType==FTSQUERY_NEAR ) pNear = p;\n      if( p->bEof ) bTreeEof = 1;\n    }\n    if( bOr==0 ) return SQLITE_OK;\n\n    /* This is the descendent of an OR node. In this case we cannot use\n    ** an incremental phrase. Load the entire doclist for the phrase\n    ** into memory in this case.  */\n    if( pPhrase->bIncr ){\n      int bEofSave = pNear->bEof;\n      fts3EvalRestart(pCsr, pNear, &rc);\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n        if( bEofSave==0 && pNear->iDocid==iDocid ) break;\n      }\n      assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );\n    }\n    if( bTreeEof ){\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n      }\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    bMatch = 1;\n    for(p=pNear; p; p=p->pLeft){\n      u8 bEof = 0;\n      Fts3Expr *pTest = p;\n      Fts3Phrase *pPh;\n      assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE );\n      if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight;\n      assert( pTest->eType==FTSQUERY_PHRASE );\n      pPh = pTest->pPhrase;\n\n      pIter = pPh->pOrPoslist;\n      iDocid = pPh->iOrDocid;\n      if( pCsr->bDesc==bDescDoclist ){\n        bEof = !pPh->doclist.nAll ||\n          (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){\n          sqlite3Fts3DoclistNext(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &bEof\n          );\n        }\n      }else{\n        bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){\n          int dummy;\n          sqlite3Fts3DoclistPrev(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &dummy, &bEof\n              );\n        }\n      }\n      pPh->pOrPoslist = pIter;\n      pPh->iOrDocid = iDocid;\n      if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0;\n    }\n\n    if( bMatch ){\n      pIter = pPhrase->pOrPoslist;\n    }else{\n      pIter = 0;\n    }\n  }\n  if( pIter==0 ) return SQLITE_OK;\n\n  if( *pIter==0x01 ){\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }else{\n    iThis = 0;\n  }\n  while( iThis<iCol ){\n    fts3ColumnlistCopy(0, &pIter);\n    if( *pIter==0x00 ) return SQLITE_OK;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }\n  if( *pIter==0x00 ){\n    pIter = 0;\n  }\n\n  *ppOut = ((iCol==iThis)?pIter:0);\n  return SQLITE_OK;\n}\n\n/*\n** Free all components of the Fts3Phrase structure that were allocated by\n** the eval module. Specifically, this means to free:\n**\n**   * the contents of pPhrase->doclist, and\n**   * any Fts3MultiSegReader objects held by phrase tokens.\n*/\nvoid sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    sqlite3_free(pPhrase->doclist.aAll);\n    fts3EvalInvalidatePoslist(pPhrase);\n    memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));\n    for(i=0; i<pPhrase->nToken; i++){\n      fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);\n      pPhrase->aToken[i].pSegcsr = 0;\n    }\n  }\n}\n\n\n/*\n** Return SQLITE_CORRUPT_VTAB.\n*/\n#ifdef SQLITE_DEBUG\nint sqlite3Fts3Corrupt(){\n  return SQLITE_CORRUPT_VTAB;\n}\n#endif\n\n#if !SQLITE_CORE\n/*\n** Initialize API pointer table, if required.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fts3_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts3Init(db);\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3.h",
    "content": "/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** FTS3 library.  All it does is declare the sqlite3Fts3Init() interface.\n*/\n#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint sqlite3Fts3Init(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3Int.h",
    "content": "/*\n** 2009 Nov 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTSINT_H\n#define _FTSINT_H\n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/* FTS3/FTS4 require virtual tables */\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all\n** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3\n#endif\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* If not building as part of the core, include sqlite3ext.h. */\n#ifndef SQLITE_CORE\n# include \"sqlite3ext.h\" \nSQLITE_EXTENSION_INIT3\n#endif\n\n#include \"sqlite3.h\"\n#include \"fts3_tokenizer.h\"\n#include \"fts3_hash.h\"\n\n/*\n** This constant determines the maximum depth of an FTS expression tree\n** that the library will create and use. FTS uses recursion to perform \n** various operations on the query tree, so the disadvantage of a large\n** limit is that it may allow very large queries to use large amounts\n** of stack space (perhaps causing a stack overflow).\n*/\n#ifndef SQLITE_FTS3_MAX_EXPR_DEPTH\n# define SQLITE_FTS3_MAX_EXPR_DEPTH 12\n#endif\n\n\n/*\n** This constant controls how often segments are merged. Once there are\n** FTS3_MERGE_COUNT segments of level N, they are merged into a single\n** segment of level N+1.\n*/\n#define FTS3_MERGE_COUNT 16\n\n/*\n** This is the maximum amount of data (in bytes) to store in the \n** Fts3Table.pendingTerms hash table. Normally, the hash table is\n** populated as documents are inserted/updated/deleted in a transaction\n** and used to create a new segment when the transaction is committed.\n** However if this limit is reached midway through a transaction, a new \n** segment is created and the hash table cleared immediately.\n*/\n#define FTS3_MAX_PENDING_DATA (1*1024*1024)\n\n/*\n** Macro to return the number of elements in an array. SQLite has a\n** similar macro called ArraySize(). Use a different name to avoid\n** a collision when building an amalgamation with built-in FTS3.\n*/\n#define SizeofArray(X) ((int)(sizeof(X)/sizeof(X[0])))\n\n\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n#ifndef MAX\n# define MAX(x,y) ((x)>(y)?(x):(y))\n#endif\n\n/*\n** Maximum length of a varint encoded integer. The varint format is different\n** from that used by SQLite, so the maximum length is 10, not 9.\n*/\n#define FTS3_VARINT_MAX 10\n\n/*\n** FTS4 virtual tables may maintain multiple indexes - one index of all terms\n** in the document set and zero or more prefix indexes. All indexes are stored\n** as one or more b+-trees in the %_segments and %_segdir tables. \n**\n** It is possible to determine which index a b+-tree belongs to based on the\n** value stored in the \"%_segdir.level\" column. Given this value L, the index\n** that the b+-tree belongs to is (L<<10). In other words, all b+-trees with\n** level values between 0 and 1023 (inclusive) belong to index 0, all levels\n** between 1024 and 2047 to index 1, and so on.\n**\n** It is considered impossible for an index to use more than 1024 levels. In \n** theory though this may happen, but only after at least \n** (FTS3_MERGE_COUNT^1024) separate flushes of the pending-terms tables.\n*/\n#define FTS3_SEGDIR_MAXLEVEL      1024\n#define FTS3_SEGDIR_MAXLEVEL_STR \"1024\"\n\n/*\n** The testcase() macro is only used by the amalgamation.  If undefined,\n** make it a no-op.\n*/\n#ifndef testcase\n# define testcase(X)\n#endif\n\n/*\n** Terminator values for position-lists and column-lists.\n*/\n#define POS_COLUMN  (1)     /* Column-list terminator */\n#define POS_END     (0)     /* Position-list terminator */ \n\n/*\n** This section provides definitions to allow the\n** FTS3 extension to be compiled outside of the \n** amalgamation.\n*/\n#ifndef SQLITE_AMALGAMATION\n/*\n** Macros indicating that conditional expressions are always true or\n** false.\n*/\n#ifdef SQLITE_COVERAGE_TEST\n# define ALWAYS(x) (1)\n# define NEVER(X)  (0)\n#elif defined(SQLITE_DEBUG)\n# define ALWAYS(x) sqlite3Fts3Always((x)!=0)\n# define NEVER(x) sqlite3Fts3Never((x)!=0)\nint sqlite3Fts3Always(int b);\nint sqlite3Fts3Never(int b);\n#else\n# define ALWAYS(x) (x)\n# define NEVER(x)  (x)\n#endif\n\n/*\n** Internal types used by SQLite.\n*/\ntypedef unsigned char u8;         /* 1-byte (or larger) unsigned integer */\ntypedef short int i16;            /* 2-byte (or larger) signed integer */\ntypedef unsigned int u32;         /* 4-byte unsigned integer */\ntypedef sqlite3_uint64 u64;       /* 8-byte unsigned integer */\ntypedef sqlite3_int64 i64;        /* 8-byte signed integer */\n\n/*\n** Macro used to suppress compiler warnings for unused parameters.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** Activate assert() only if SQLITE_TEST is enabled.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n#endif /* SQLITE_AMALGAMATION */\n\n#ifdef SQLITE_DEBUG\nint sqlite3Fts3Corrupt(void);\n# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()\n#else\n# define FTS_CORRUPT_VTAB SQLITE_CORRUPT_VTAB\n#endif\n\ntypedef struct Fts3Table Fts3Table;\ntypedef struct Fts3Cursor Fts3Cursor;\ntypedef struct Fts3Expr Fts3Expr;\ntypedef struct Fts3Phrase Fts3Phrase;\ntypedef struct Fts3PhraseToken Fts3PhraseToken;\n\ntypedef struct Fts3Doclist Fts3Doclist;\ntypedef struct Fts3SegFilter Fts3SegFilter;\ntypedef struct Fts3DeferredToken Fts3DeferredToken;\ntypedef struct Fts3SegReader Fts3SegReader;\ntypedef struct Fts3MultiSegReader Fts3MultiSegReader;\n\ntypedef struct MatchinfoBuffer MatchinfoBuffer;\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure. The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct Fts3Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  sqlite3 *db;                    /* The database connection */\n  const char *zDb;                /* logical database name */\n  const char *zName;              /* virtual table name */\n  int nColumn;                    /* number of named columns in virtual table */\n  char **azColumn;                /* column names.  malloced */\n  u8 *abNotindexed;               /* True for 'notindexed' columns */\n  sqlite3_tokenizer *pTokenizer;  /* tokenizer for inserts and queries */\n  char *zContentTbl;              /* content=xxx option, or NULL */\n  char *zLanguageid;              /* languageid=xxx option, or NULL */\n  int nAutoincrmerge;             /* Value configured by 'automerge' */\n  u32 nLeafAdd;                   /* Number of leaf blocks added this trans */\n\n  /* Precompiled statements used by the implementation. Each of these \n  ** statements is run and reset within a single virtual table API call. \n  */\n  sqlite3_stmt *aStmt[40];\n  sqlite3_stmt *pSeekStmt;        /* Cache for fts3CursorSeekStmt() */\n\n  char *zReadExprlist;\n  char *zWriteExprlist;\n\n  int nNodeSize;                  /* Soft limit for node size */\n  u8 bFts4;                       /* True for FTS4, false for FTS3 */\n  u8 bHasStat;                    /* True if %_stat table exists (2==unknown) */\n  u8 bHasDocsize;                 /* True if %_docsize table exists */\n  u8 bDescIdx;                    /* True if doclists are in reverse order */\n  u8 bIgnoreSavepoint;            /* True to ignore xSavepoint invocations */\n  int nPgsz;                      /* Page size for host database */\n  char *zSegmentsTbl;             /* Name of %_segments table */\n  sqlite3_blob *pSegments;        /* Blob handle open on %_segments table */\n\n  /* \n  ** The following array of hash tables is used to buffer pending index \n  ** updates during transactions. All pending updates buffered at any one\n  ** time must share a common language-id (see the FTS4 langid= feature).\n  ** The current language id is stored in variable iPrevLangid.\n  **\n  ** A single FTS4 table may have multiple full-text indexes. For each index\n  ** there is an entry in the aIndex[] array. Index 0 is an index of all the\n  ** terms that appear in the document set. Each subsequent index in aIndex[]\n  ** is an index of prefixes of a specific length.\n  **\n  ** Variable nPendingData contains an estimate the memory consumed by the \n  ** pending data structures, including hash table overhead, but not including\n  ** malloc overhead.  When nPendingData exceeds nMaxPendingData, all hash\n  ** tables are flushed to disk. Variable iPrevDocid is the docid of the most \n  ** recently inserted record.\n  */\n  int nIndex;                     /* Size of aIndex[] */\n  struct Fts3Index {\n    int nPrefix;                  /* Prefix length (0 for main terms index) */\n    Fts3Hash hPending;            /* Pending terms table for this index */\n  } *aIndex;\n  int nMaxPendingData;            /* Max pending data before flush to disk */\n  int nPendingData;               /* Current bytes of pending data */\n  sqlite_int64 iPrevDocid;        /* Docid of most recently inserted document */\n  int iPrevLangid;                /* Langid of recently inserted document */\n  int bPrevDelete;                /* True if last operation was a delete */\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n  /* State variables used for validating that the transaction control\n  ** methods of the virtual table are called at appropriate times.  These\n  ** values do not contribute to FTS functionality; they are used for\n  ** verifying the operation of the SQLite core.\n  */\n  int inTransaction;     /* True after xBegin but before xCommit/xRollback */\n  int mxSavepoint;       /* Largest valid xSavepoint integer */\n#endif\n\n#ifdef SQLITE_TEST\n  /* True to disable the incremental doclist optimization. This is controled\n  ** by special insert command 'test-no-incr-doclist'.  */\n  int bNoIncrDoclist;\n#endif\n};\n\n/*\n** When the core wants to read from the virtual table, it creates a\n** virtual table cursor (an instance of the following structure) using\n** the xOpen method. Cursors are destroyed using the xClose method.\n*/\nstruct Fts3Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  i16 eSearch;                    /* Search strategy (see below) */\n  u8 isEof;                       /* True if at End Of Results */\n  u8 isRequireSeek;               /* True if must seek pStmt to %_content row */\n  u8 bSeekStmt;                   /* True if pStmt is a seek */\n  sqlite3_stmt *pStmt;            /* Prepared statement in use by the cursor */\n  Fts3Expr *pExpr;                /* Parsed MATCH query string */\n  int iLangid;                    /* Language being queried for */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  Fts3DeferredToken *pDeferred;   /* Deferred search tokens, if any */\n  sqlite3_int64 iPrevId;          /* Previous id read from aDoclist */\n  char *pNextId;                  /* Pointer into the body of aDoclist */\n  char *aDoclist;                 /* List of docids for full-text queries */\n  int nDoclist;                   /* Size of buffer at aDoclist */\n  u8 bDesc;                       /* True to sort in descending order */\n  int eEvalmode;                  /* An FTS3_EVAL_XX constant */\n  int nRowAvg;                    /* Average size of database rows, in pages */\n  sqlite3_int64 nDoc;             /* Documents in table */\n  i64 iMinDocid;                  /* Minimum docid to return */\n  i64 iMaxDocid;                  /* Maximum docid to return */\n  int isMatchinfoNeeded;          /* True when aMatchinfo[] needs filling in */\n  MatchinfoBuffer *pMIBuffer;     /* Buffer for matchinfo data */\n};\n\n#define FTS3_EVAL_FILTER    0\n#define FTS3_EVAL_NEXT      1\n#define FTS3_EVAL_MATCHINFO 2\n\n/*\n** The Fts3Cursor.eSearch member is always set to one of the following.\n** Actualy, Fts3Cursor.eSearch can be greater than or equal to\n** FTS3_FULLTEXT_SEARCH.  If so, then Fts3Cursor.eSearch - 2 is the index\n** of the column to be searched.  For example, in\n**\n**     CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);\n**     SELECT docid FROM ex1 WHERE b MATCH 'one two three';\n** \n** Because the LHS of the MATCH operator is 2nd column \"b\",\n** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1.  (+0 for a,\n** +1 for b, +2 for c, +3 for d.)  If the LHS of MATCH were \"ex1\" \n** indicating that all columns should be searched,\n** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.\n*/\n#define FTS3_FULLSCAN_SEARCH 0    /* Linear scan of %_content table */\n#define FTS3_DOCID_SEARCH    1    /* Lookup by rowid on %_content table */\n#define FTS3_FULLTEXT_SEARCH 2    /* Full-text index search */\n\n/*\n** The lower 16-bits of the sqlite3_index_info.idxNum value set by\n** the xBestIndex() method contains the Fts3Cursor.eSearch value described\n** above. The upper 16-bits contain a combination of the following\n** bits, used to describe extra constraints on full-text searches.\n*/\n#define FTS3_HAVE_LANGID    0x00010000      /* languageid=? */\n#define FTS3_HAVE_DOCID_GE  0x00020000      /* docid>=? */\n#define FTS3_HAVE_DOCID_LE  0x00040000      /* docid<=? */\n\nstruct Fts3Doclist {\n  char *aAll;                    /* Array containing doclist (or NULL) */\n  int nAll;                      /* Size of a[] in bytes */\n  char *pNextDocid;              /* Pointer to next docid */\n\n  sqlite3_int64 iDocid;          /* Current docid (if pList!=0) */\n  int bFreeList;                 /* True if pList should be sqlite3_free()d */\n  char *pList;                   /* Pointer to position list following iDocid */\n  int nList;                     /* Length of position list */\n};\n\n/*\n** A \"phrase\" is a sequence of one or more tokens that must match in\n** sequence.  A single token is the base case and the most common case.\n** For a sequence of tokens contained in double-quotes (i.e. \"one two three\")\n** nToken will be the number of tokens in the string.\n*/\nstruct Fts3PhraseToken {\n  char *z;                        /* Text of the token */\n  int n;                          /* Number of bytes in buffer z */\n  int isPrefix;                   /* True if token ends with a \"*\" character */\n  int bFirst;                     /* True if token must appear at position 0 */\n\n  /* Variables above this point are populated when the expression is\n  ** parsed (by code in fts3_expr.c). Below this point the variables are\n  ** used when evaluating the expression. */\n  Fts3DeferredToken *pDeferred;   /* Deferred token object for this token */\n  Fts3MultiSegReader *pSegcsr;    /* Segment-reader for this token */\n};\n\nstruct Fts3Phrase {\n  /* Cache of doclist for this phrase. */\n  Fts3Doclist doclist;\n  int bIncr;                 /* True if doclist is loaded incrementally */\n  int iDoclistToken;\n\n  /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an\n  ** OR condition.  */\n  char *pOrPoslist;\n  i64 iOrDocid;\n\n  /* Variables below this point are populated by fts3_expr.c when parsing \n  ** a MATCH expression. Everything above is part of the evaluation phase. \n  */\n  int nToken;                /* Number of tokens in the phrase */\n  int iColumn;               /* Index of column this phrase must match */\n  Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */\n};\n\n/*\n** A tree of these objects forms the RHS of a MATCH operator.\n**\n** If Fts3Expr.eType is FTSQUERY_PHRASE and isLoaded is true, then aDoclist \n** points to a malloced buffer, size nDoclist bytes, containing the results \n** of this phrase query in FTS3 doclist format. As usual, the initial \n** \"Length\" field found in doclists stored on disk is omitted from this \n** buffer.\n**\n** Variable aMI is used only for FTSQUERY_NEAR nodes to store the global\n** matchinfo data. If it is not NULL, it points to an array of size nCol*3,\n** where nCol is the number of columns in the queried FTS table. The array\n** is populated as follows:\n**\n**   aMI[iCol*3 + 0] = Undefined\n**   aMI[iCol*3 + 1] = Number of occurrences\n**   aMI[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** The aMI array is allocated using sqlite3_malloc(). It should be freed \n** when the expression node is.\n*/\nstruct Fts3Expr {\n  int eType;                 /* One of the FTSQUERY_XXX values defined below */\n  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */\n  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */\n  Fts3Expr *pLeft;           /* Left operand */\n  Fts3Expr *pRight;          /* Right operand */\n  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */\n\n  /* The following are used by the fts3_eval.c module. */\n  sqlite3_int64 iDocid;      /* Current docid */\n  u8 bEof;                   /* True this expression is at EOF already */\n  u8 bStart;                 /* True if iDocid is valid */\n  u8 bDeferred;              /* True if this expression is entirely deferred */\n\n  /* The following are used by the fts3_snippet.c module. */\n  int iPhrase;               /* Index of this phrase in matchinfo() results */\n  u32 *aMI;                  /* See above */\n};\n\n/*\n** Candidate values for Fts3Query.eType. Note that the order of the first\n** four values is in order of precedence when parsing expressions. For \n** example, the following:\n**\n**   \"a OR b AND c NOT d NEAR e\"\n**\n** is equivalent to:\n**\n**   \"a OR (b AND (c NOT (d NEAR e)))\"\n*/\n#define FTSQUERY_NEAR   1\n#define FTSQUERY_NOT    2\n#define FTSQUERY_AND    3\n#define FTSQUERY_OR     4\n#define FTSQUERY_PHRASE 5\n\n\n/* fts3_write.c */\nint sqlite3Fts3UpdateMethod(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);\nint sqlite3Fts3PendingTermsFlush(Fts3Table *);\nvoid sqlite3Fts3PendingTermsClear(Fts3Table *);\nint sqlite3Fts3Optimize(Fts3Table *);\nint sqlite3Fts3SegReaderNew(int, int, sqlite3_int64,\n  sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);\nint sqlite3Fts3SegReaderPending(\n  Fts3Table*,int,const char*,int,int,Fts3SegReader**);\nvoid sqlite3Fts3SegReaderFree(Fts3SegReader *);\nint sqlite3Fts3AllSegdirs(Fts3Table*, int, int, int, sqlite3_stmt **);\nint sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*, int*);\n\nint sqlite3Fts3SelectDoctotal(Fts3Table *, sqlite3_stmt **);\nint sqlite3Fts3SelectDocsize(Fts3Table *, sqlite3_int64, sqlite3_stmt **);\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\nvoid sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);\nint sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);\nint sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);\nvoid sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);\nint sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);\n#else\n# define sqlite3Fts3FreeDeferredTokens(x)\n# define sqlite3Fts3DeferToken(x,y,z) SQLITE_OK\n# define sqlite3Fts3CacheDeferredDoclists(x) SQLITE_OK\n# define sqlite3Fts3FreeDeferredDoclists(x)\n# define sqlite3Fts3DeferredTokenList(x,y,z) SQLITE_OK\n#endif\n\nvoid sqlite3Fts3SegmentsClose(Fts3Table *);\nint sqlite3Fts3MaxLevel(Fts3Table *, int *);\n\n/* Special values interpreted by sqlite3SegReaderCursor() */\n#define FTS3_SEGCURSOR_PENDING        -1\n#define FTS3_SEGCURSOR_ALL            -2\n\nint sqlite3Fts3SegReaderStart(Fts3Table*, Fts3MultiSegReader*, Fts3SegFilter*);\nint sqlite3Fts3SegReaderStep(Fts3Table *, Fts3MultiSegReader *);\nvoid sqlite3Fts3SegReaderFinish(Fts3MultiSegReader *);\n\nint sqlite3Fts3SegReaderCursor(Fts3Table *, \n    int, int, int, const char *, int, int, int, Fts3MultiSegReader *);\n\n/* Flags allowed as part of the 4th argument to SegmentReaderIterate() */\n#define FTS3_SEGMENT_REQUIRE_POS   0x00000001\n#define FTS3_SEGMENT_IGNORE_EMPTY  0x00000002\n#define FTS3_SEGMENT_COLUMN_FILTER 0x00000004\n#define FTS3_SEGMENT_PREFIX        0x00000008\n#define FTS3_SEGMENT_SCAN          0x00000010\n#define FTS3_SEGMENT_FIRST         0x00000020\n\n/* Type passed as 4th argument to SegmentReaderIterate() */\nstruct Fts3SegFilter {\n  const char *zTerm;\n  int nTerm;\n  int iCol;\n  int flags;\n};\n\nstruct Fts3MultiSegReader {\n  /* Used internally by sqlite3Fts3SegReaderXXX() calls */\n  Fts3SegReader **apSegment;      /* Array of Fts3SegReader objects */\n  int nSegment;                   /* Size of apSegment array */\n  int nAdvance;                   /* How many seg-readers to advance */\n  Fts3SegFilter *pFilter;         /* Pointer to filter object */\n  char *aBuffer;                  /* Buffer to merge doclists in */\n  int nBuffer;                    /* Allocated size of aBuffer[] in bytes */\n\n  int iColFilter;                 /* If >=0, filter for this column */\n  int bRestart;\n\n  /* Used by fts3.c only. */\n  int nCost;                      /* Cost of running iterator */\n  int bLookup;                    /* True if a lookup of a single entry. */\n\n  /* Output values. Valid only after Fts3SegReaderStep() returns SQLITE_ROW. */\n  char *zTerm;                    /* Pointer to term buffer */\n  int nTerm;                      /* Size of zTerm in bytes */\n  char *aDoclist;                 /* Pointer to doclist buffer */\n  int nDoclist;                   /* Size of aDoclist[] in bytes */\n};\n\nint sqlite3Fts3Incrmerge(Fts3Table*,int,int);\n\n#define fts3GetVarint32(p, piVal) (                                           \\\n  (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \\\n)\n\n/* fts3.c */\nvoid sqlite3Fts3ErrMsg(char**,const char*,...);\nint sqlite3Fts3PutVarint(char *, sqlite3_int64);\nint sqlite3Fts3GetVarint(const char *, sqlite_int64 *);\nint sqlite3Fts3GetVarint32(const char *, int *);\nint sqlite3Fts3VarintLen(sqlite3_uint64);\nvoid sqlite3Fts3Dequote(char *);\nvoid sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);\nint sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);\nint sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);\nvoid sqlite3Fts3CreateStatTable(int*, Fts3Table*);\nint sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc);\n\n/* fts3_tokenizer.c */\nconst char *sqlite3Fts3NextToken(const char *, int *);\nint sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);\nint sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, \n    sqlite3_tokenizer **, char **\n);\nint sqlite3Fts3IsIdChar(char);\n\n/* fts3_snippet.c */\nvoid sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);\nvoid sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *,\n  const char *, const char *, int, int\n);\nvoid sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);\nvoid sqlite3Fts3MIBufferFree(MatchinfoBuffer *p);\n\n/* fts3_expr.c */\nint sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,\n  char **, int, int, int, const char *, int, Fts3Expr **, char **\n);\nvoid sqlite3Fts3ExprFree(Fts3Expr *);\n#ifdef SQLITE_TEST\nint sqlite3Fts3ExprInitTestInterface(sqlite3 *db);\nint sqlite3Fts3InitTerm(sqlite3 *db);\n#endif\n\nint sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int,\n  sqlite3_tokenizer_cursor **\n);\n\n/* fts3_aux.c */\nint sqlite3Fts3InitAux(sqlite3 *db);\n\nvoid sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *);\n\nint sqlite3Fts3MsrIncrStart(\n    Fts3Table*, Fts3MultiSegReader*, int, const char*, int);\nint sqlite3Fts3MsrIncrNext(\n    Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);\nint sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **); \nint sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);\nint sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);\n\n/* fts3_tokenize_vtab.c */\nint sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);\n\n/* fts3_unicode2.c (functions generated by parsing unicode text files) */\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nint sqlite3FtsUnicodeFold(int, int);\nint sqlite3FtsUnicodeIsalnum(int);\nint sqlite3FtsUnicodeIsdiacritic(int);\n#endif\n\n#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */\n#endif /* _FTSINT_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_aux.c",
    "content": "/*\n** 2011 Jan 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <string.h>\n#include <assert.h>\n\ntypedef struct Fts3auxTable Fts3auxTable;\ntypedef struct Fts3auxCursor Fts3auxCursor;\n\nstruct Fts3auxTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts3Table *pFts3Tab;\n};\n\nstruct Fts3auxCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts3MultiSegReader csr;        /* Must be right after \"base\" */\n  Fts3SegFilter filter;\n  char *zStop;\n  int nStop;                      /* Byte-length of string zStop */\n  int iLangid;                    /* Language id to query */\n  int isEof;                      /* True if cursor is at EOF */\n  sqlite3_int64 iRowid;           /* Current rowid */\n\n  int iCol;                       /* Current value of 'col' column */\n  int nStat;                      /* Size of aStat[] array */\n  struct Fts3auxColstats {\n    sqlite3_int64 nDoc;           /* 'documents' values for current csr row */\n    sqlite3_int64 nOcc;           /* 'occurrences' values for current csr row */\n  } *aStat;\n};\n\n/*\n** Schema of the terms table.\n*/\n#define FTS3_AUX_SCHEMA \\\n  \"CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n*/\nstatic int fts3auxConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pUnused,                  /* Unused */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  char const *zDb;                /* Name of database (e.g. \"main\") */\n  char const *zFts3;              /* Name of fts3 table */\n  int nDb;                        /* Result of strlen(zDb) */\n  int nFts3;                      /* Result of strlen(zFts3) */\n  int nByte;                      /* Bytes of space to allocate here */\n  int rc;                         /* value returned by declare_vtab() */\n  Fts3auxTable *p;                /* Virtual table object to return */\n\n  UNUSED_PARAMETER(pUnused);\n\n  /* The user should invoke this in one of two forms:\n  **\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);\n  */\n  if( argc!=4 && argc!=5 ) goto bad_args;\n\n  zDb = argv[1]; \n  nDb = (int)strlen(zDb);\n  if( argc==5 ){\n    if( nDb==4 && 0==sqlite3_strnicmp(\"temp\", zDb, 4) ){\n      zDb = argv[3]; \n      nDb = (int)strlen(zDb);\n      zFts3 = argv[4];\n    }else{\n      goto bad_args;\n    }\n  }else{\n    zFts3 = argv[3];\n  }\n  nFts3 = (int)strlen(zFts3);\n\n  rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;\n  p = (Fts3auxTable *)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFts3Tab = (Fts3Table *)&p[1];\n  p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];\n  p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];\n  p->pFts3Tab->db = db;\n  p->pFts3Tab->nIndex = 1;\n\n  memcpy((char *)p->pFts3Tab->zDb, zDb, nDb);\n  memcpy((char *)p->pFts3Tab->zName, zFts3, nFts3);\n  sqlite3Fts3Dequote((char *)p->pFts3Tab->zName);\n\n  *ppVtab = (sqlite3_vtab *)p;\n  return SQLITE_OK;\n\n bad_args:\n  sqlite3Fts3ErrMsg(pzErr, \"invalid arguments to fts4aux constructor\");\n  return SQLITE_ERROR;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3auxDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3auxTable *p = (Fts3auxTable *)pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int i;\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(pFts3->aStmt); i++){\n    sqlite3_finalize(pFts3->aStmt[i]);\n  }\n  sqlite3_free(pFts3->zSegmentsTbl);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n#define FTS4AUX_EQ_CONSTRAINT 1\n#define FTS4AUX_GE_CONSTRAINT 2\n#define FTS4AUX_LE_CONSTRAINT 4\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3auxBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iEq = -1;\n  int iGe = -1;\n  int iLe = -1;\n  int iLangid = -1;\n  int iNext = 1;                  /* Next free argvIndex value */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* This vtab delivers always results in \"ORDER BY term ASC\" order. */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  /* Search for equality and range constraints on the \"term\" column. \n  ** And equality constraints on the hidden \"languageid\" column. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable ){\n      int op = pInfo->aConstraint[i].op;\n      int iCol = pInfo->aConstraint[i].iColumn;\n\n      if( iCol==0 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;\n      }\n      if( iCol==4 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;\n      }\n    }\n  }\n\n  if( iEq>=0 ){\n    pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;\n    pInfo->aConstraintUsage[iEq].argvIndex = iNext++;\n    pInfo->estimatedCost = 5;\n  }else{\n    pInfo->idxNum = 0;\n    pInfo->estimatedCost = 20000;\n    if( iGe>=0 ){\n      pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;\n      pInfo->aConstraintUsage[iGe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n    if( iLe>=0 ){\n      pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;\n      pInfo->aConstraintUsage[iLe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n  }\n  if( iLangid>=0 ){\n    pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;\n    pInfo->estimatedCost--;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3auxOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3auxCursor *pCsr;            /* Pointer to cursor object to return */\n\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3auxCursor *)sqlite3_malloc(sizeof(Fts3auxCursor));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(Fts3auxCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n\n  sqlite3Fts3SegmentsClose(pFts3);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->zStop);\n  sqlite3_free(pCsr->aStat);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){\n  if( nSize>pCsr->nStat ){\n    struct Fts3auxColstats *aNew;\n    aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat, \n        sizeof(struct Fts3auxColstats) * nSize\n    );\n    if( aNew==0 ) return SQLITE_NOMEM;\n    memset(&aNew[pCsr->nStat], 0, \n        sizeof(struct Fts3auxColstats) * (nSize - pCsr->nStat)\n    );\n    pCsr->aStat = aNew;\n    pCsr->nStat = nSize;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n\n  /* Increment our pretend rowid value. */\n  pCsr->iRowid++;\n\n  for(pCsr->iCol++; pCsr->iCol<pCsr->nStat; pCsr->iCol++){\n    if( pCsr->aStat[pCsr->iCol].nDoc>0 ) return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);\n  if( rc==SQLITE_ROW ){\n    int i = 0;\n    int nDoclist = pCsr->csr.nDoclist;\n    char *aDoclist = pCsr->csr.aDoclist;\n    int iCol;\n\n    int eState = 0;\n\n    if( pCsr->zStop ){\n      int n = (pCsr->nStop<pCsr->csr.nTerm) ? pCsr->nStop : pCsr->csr.nTerm;\n      int mc = memcmp(pCsr->zStop, pCsr->csr.zTerm, n);\n      if( mc<0 || (mc==0 && pCsr->csr.nTerm>pCsr->nStop) ){\n        pCsr->isEof = 1;\n        return SQLITE_OK;\n      }\n    }\n\n    if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM;\n    memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat);\n    iCol = 0;\n\n    while( i<nDoclist ){\n      sqlite3_int64 v = 0;\n\n      i += sqlite3Fts3GetVarint(&aDoclist[i], &v);\n      switch( eState ){\n        /* State 0. In this state the integer just read was a docid. */\n        case 0:\n          pCsr->aStat[0].nDoc++;\n          eState = 1;\n          iCol = 0;\n          break;\n\n        /* State 1. In this state we are expecting either a 1, indicating\n        ** that the following integer will be a column number, or the\n        ** start of a position list for column 0.  \n        ** \n        ** The only difference between state 1 and state 2 is that if the\n        ** integer encountered in state 1 is not 0 or 1, then we need to\n        ** increment the column 0 \"nDoc\" count for this term.\n        */\n        case 1:\n          assert( iCol==0 );\n          if( v>1 ){\n            pCsr->aStat[1].nDoc++;\n          }\n          eState = 2;\n          /* fall through */\n\n        case 2:\n          if( v==0 ){       /* 0x00. Next integer will be a docid. */\n            eState = 0;\n          }else if( v==1 ){ /* 0x01. Next integer will be a column number. */\n            eState = 3;\n          }else{            /* 2 or greater. A position. */\n            pCsr->aStat[iCol+1].nOcc++;\n            pCsr->aStat[0].nOcc++;\n          }\n          break;\n\n        /* State 3. The integer just read is a column number. */\n        default: assert( eState==3 );\n          iCol = (int)v;\n          if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM;\n          pCsr->aStat[iCol+1].nDoc++;\n          eState = 2;\n          break;\n      }\n    }\n\n    pCsr->iCol = 0;\n    rc = SQLITE_OK;\n  }else{\n    pCsr->isEof = 1;\n  }\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3auxFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n  int isScan = 0;\n  int iLangVal = 0;               /* Language id to query */\n\n  int iEq = -1;                   /* Index of term=? value in apVal */\n  int iGe = -1;                   /* Index of term>=? value in apVal */\n  int iLe = -1;                   /* Index of term<=? value in apVal */\n  int iLangid = -1;               /* Index of languageid=? value in apVal */\n  int iNext = 0;\n\n  UNUSED_PARAMETER(nVal);\n  UNUSED_PARAMETER(idxStr);\n\n  assert( idxStr==0 );\n  assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0\n       || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT\n       || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)\n  );\n\n  if( idxNum==FTS4AUX_EQ_CONSTRAINT ){\n    iEq = iNext++;\n  }else{\n    isScan = 1;\n    if( idxNum & FTS4AUX_GE_CONSTRAINT ){\n      iGe = iNext++;\n    }\n    if( idxNum & FTS4AUX_LE_CONSTRAINT ){\n      iLe = iNext++;\n    }\n  }\n  if( iNext<nVal ){\n    iLangid = iNext++;\n  }\n\n  /* In case this cursor is being reused, close and zero it. */\n  testcase(pCsr->filter.zTerm);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->aStat);\n  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);\n\n  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;\n\n  if( iEq>=0 || iGe>=0 ){\n    const unsigned char *zStr = sqlite3_value_text(apVal[0]);\n    assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );\n    if( zStr ){\n      pCsr->filter.zTerm = sqlite3_mprintf(\"%s\", zStr);\n      pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);\n      if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;\n    }\n  }\n\n  if( iLe>=0 ){\n    pCsr->zStop = sqlite3_mprintf(\"%s\", sqlite3_value_text(apVal[iLe]));\n    pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);\n    if( pCsr->zStop==0 ) return SQLITE_NOMEM;\n  }\n  \n  if( iLangid>=0 ){\n    iLangVal = sqlite3_value_int(apVal[iLangid]);\n\n    /* If the user specified a negative value for the languageid, use zero\n    ** instead. This works, as the \"languageid=?\" constraint will also\n    ** be tested by the VDBE layer. The test will always be false (since\n    ** this module will not return a row with a negative languageid), and\n    ** so the overall query will return zero rows.  */\n    if( iLangVal<0 ) iLangVal = 0;\n  }\n  pCsr->iLangid = iLangVal;\n\n  rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,\n      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);\n  }\n\n  if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);\n  return rc;\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3auxEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  return pCsr->isEof;\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3auxColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3auxCursor *p = (Fts3auxCursor *)pCursor;\n\n  assert( p->isEof==0 );\n  switch( iCol ){\n    case 0: /* term */\n      sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);\n      break;\n\n    case 1: /* col */\n      if( p->iCol ){\n        sqlite3_result_int(pCtx, p->iCol-1);\n      }else{\n        sqlite3_result_text(pCtx, \"*\", -1, SQLITE_STATIC);\n      }\n      break;\n\n    case 2: /* documents */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);\n      break;\n\n    case 3: /* occurrences */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);\n      break;\n\n    default: /* languageid */\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, p->iLangid);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3auxRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3aux module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nint sqlite3Fts3InitAux(sqlite3 *db){\n  static const sqlite3_module fts3aux_module = {\n     0,                           /* iVersion      */\n     fts3auxConnectMethod,        /* xCreate       */\n     fts3auxConnectMethod,        /* xConnect      */\n     fts3auxBestIndexMethod,      /* xBestIndex    */\n     fts3auxDisconnectMethod,     /* xDisconnect   */\n     fts3auxDisconnectMethod,     /* xDestroy      */\n     fts3auxOpenMethod,           /* xOpen         */\n     fts3auxCloseMethod,          /* xClose        */\n     fts3auxFilterMethod,         /* xFilter       */\n     fts3auxNextMethod,           /* xNext         */\n     fts3auxEofMethod,            /* xEof          */\n     fts3auxColumnMethod,         /* xColumn       */\n     fts3auxRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts4aux\", &fts3aux_module, 0);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_expr.c",
    "content": "/*\n** 2008 Nov 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This module contains code that implements a parser for fts3 query strings\n** (the right-hand argument to the MATCH operator). Because the supported \n** syntax is relatively simple, the whole tokenizer/parser system is\n** hand-coded. \n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/*\n** By default, this module parses the legacy syntax that has been \n** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined, then it uses the new syntax. The differences between\n** the new and the old syntaxes are:\n**\n**  a) The new syntax supports parenthesis. The old does not.\n**\n**  b) The new syntax supports the AND and NOT operators. The old does not.\n**\n**  c) The old syntax supports the \"-\" token qualifier. This is not \n**     supported by the new syntax (it is replaced by the NOT operator).\n**\n**  d) When using the old syntax, the OR operator has a greater precedence\n**     than an implicit AND. When using the new, both implicity and explicit\n**     AND operators have a higher precedence than OR.\n**\n** If compiled with SQLITE_TEST defined, then this module exports the\n** symbol \"int sqlite3_fts3_enable_parentheses\". Setting this variable\n** to zero causes the module to use the old syntax. If it is set to \n** non-zero the new syntax is activated. This is so both syntaxes can\n** be tested using a single build of testfixture.\n**\n** The following describes the syntax supported by the fts3 MATCH\n** operator in a similar format to that used by the lemon parser\n** generator. This module does not use actually lemon, it uses a\n** custom parser.\n**\n**   query ::= andexpr (OR andexpr)*.\n**\n**   andexpr ::= notexpr (AND? notexpr)*.\n**\n**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.\n**   notexpr ::= LP query RP.\n**\n**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.\n**\n**   distance_opt ::= .\n**   distance_opt ::= / INTEGER.\n**\n**   phrase ::= TOKEN.\n**   phrase ::= COLUMN:TOKEN.\n**   phrase ::= \"TOKEN TOKEN TOKEN...\".\n*/\n\n#ifdef SQLITE_TEST\nint sqlite3_fts3_enable_parentheses = 0;\n#else\n# ifdef SQLITE_ENABLE_FTS3_PARENTHESIS \n#  define sqlite3_fts3_enable_parentheses 1\n# else\n#  define sqlite3_fts3_enable_parentheses 0\n# endif\n#endif\n\n/*\n** Default span for NEAR operators.\n*/\n#define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10\n\n#include <string.h>\n#include <assert.h>\n\n/*\n** isNot:\n**   This variable is used by function getNextNode(). When getNextNode() is\n**   called, it sets ParseContext.isNot to true if the 'next node' is a \n**   FTSQUERY_PHRASE with a unary \"-\" attached to it. i.e. \"mysql\" in the\n**   FTS3 query \"sqlite -mysql\". Otherwise, ParseContext.isNot is set to\n**   zero.\n*/\ntypedef struct ParseContext ParseContext;\nstruct ParseContext {\n  sqlite3_tokenizer *pTokenizer;      /* Tokenizer module */\n  int iLangid;                        /* Language id used with tokenizer */\n  const char **azCol;                 /* Array of column names for fts3 table */\n  int bFts4;                          /* True to allow FTS4-only syntax */\n  int nCol;                           /* Number of entries in azCol[] */\n  int iDefaultCol;                    /* Default column to query */\n  int isNot;                          /* True if getNextNode() sees a unary - */\n  sqlite3_context *pCtx;              /* Write error message here */\n  int nNest;                          /* Number of nested brackets */\n};\n\n/*\n** This function is equivalent to the standard isspace() function. \n**\n** The standard isspace() can be awkward to use safely, because although it\n** is defined to accept an argument of type int, its behavior when passed\n** an integer that falls outside of the range of the unsigned char type\n** is undefined (and sometimes, \"undefined\" means segfault). This wrapper\n** is defined to accept an argument of type char, and always returns 0 for\n** any values that fall outside of the range of the unsigned char type (i.e.\n** negative values).\n*/\nstatic int fts3isspace(char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\n\n/*\n** Allocate nByte bytes of memory using sqlite3_malloc(). If successful,\n** zero the memory before returning a pointer to it. If unsuccessful, \n** return NULL.\n*/\nstatic void *fts3MallocZero(int nByte){\n  void *pRet = sqlite3_malloc(nByte);\n  if( pRet ) memset(pRet, 0, nByte);\n  return pRet;\n}\n\nint sqlite3Fts3OpenTokenizer(\n  sqlite3_tokenizer *pTokenizer,\n  int iLangid,\n  const char *z,\n  int n,\n  sqlite3_tokenizer_cursor **ppCsr\n){\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n  int rc;\n\n  rc = pModule->xOpen(pTokenizer, z, n, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( rc==SQLITE_OK ){\n    pCsr->pTokenizer = pTokenizer;\n    if( pModule->iVersion>=1 ){\n      rc = pModule->xLanguageid(pCsr, iLangid);\n      if( rc!=SQLITE_OK ){\n        pModule->xClose(pCsr);\n        pCsr = 0;\n      }\n    }\n  }\n  *ppCsr = pCsr;\n  return rc;\n}\n\n/*\n** Function getNextNode(), which is called by fts3ExprParse(), may itself\n** call fts3ExprParse(). So this forward declaration is required.\n*/\nstatic int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *);\n\n/*\n** Extract the next token from buffer z (length n) using the tokenizer\n** and other information (column names etc.) in pParse. Create an Fts3Expr\n** structure of type FTSQUERY_PHRASE containing a phrase consisting of this\n** single token and set *ppExpr to point to it. If the end of the buffer is\n** reached before a token is found, set *ppExpr to zero. It is the\n** responsibility of the caller to eventually deallocate the allocated \n** Fts3Expr structure (if any) by passing it to sqlite3_free().\n**\n** Return SQLITE_OK if successful, or SQLITE_NOMEM if a memory allocation\n** fails.\n*/\nstatic int getNextToken(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  int iCol,                               /* Value for Fts3Phrase.iColumn */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  sqlite3_tokenizer_cursor *pCursor;\n  Fts3Expr *pRet = 0;\n  int i = 0;\n\n  /* Set variable i to the maximum number of bytes of input to tokenize. */\n  for(i=0; i<n; i++){\n    if( sqlite3_fts3_enable_parentheses && (z[i]=='(' || z[i]==')') ) break;\n    if( z[i]=='\"' ) break;\n  }\n\n  *pnConsumed = i;\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor);\n  if( rc==SQLITE_OK ){\n    const char *zToken;\n    int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;\n    int nByte;                               /* total space to allocate */\n\n    rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);\n    if( rc==SQLITE_OK ){\n      nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;\n      pRet = (Fts3Expr *)fts3MallocZero(nByte);\n      if( !pRet ){\n        rc = SQLITE_NOMEM;\n      }else{\n        pRet->eType = FTSQUERY_PHRASE;\n        pRet->pPhrase = (Fts3Phrase *)&pRet[1];\n        pRet->pPhrase->nToken = 1;\n        pRet->pPhrase->iColumn = iCol;\n        pRet->pPhrase->aToken[0].n = nToken;\n        pRet->pPhrase->aToken[0].z = (char *)&pRet->pPhrase[1];\n        memcpy(pRet->pPhrase->aToken[0].z, zToken, nToken);\n\n        if( iEnd<n && z[iEnd]=='*' ){\n          pRet->pPhrase->aToken[0].isPrefix = 1;\n          iEnd++;\n        }\n\n        while( 1 ){\n          if( !sqlite3_fts3_enable_parentheses \n           && iStart>0 && z[iStart-1]=='-' \n          ){\n            pParse->isNot = 1;\n            iStart--;\n          }else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){\n            pRet->pPhrase->aToken[0].bFirst = 1;\n            iStart--;\n          }else{\n            break;\n          }\n        }\n\n      }\n      *pnConsumed = iEnd;\n    }else if( i && rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pModule->xClose(pCursor);\n  }\n  \n  *ppExpr = pRet;\n  return rc;\n}\n\n\n/*\n** Enlarge a memory allocation.  If an out-of-memory allocation occurs,\n** then free the old allocation.\n*/\nstatic void *fts3ReallocOrFree(void *pOrig, int nNew){\n  void *pRet = sqlite3_realloc(pOrig, nNew);\n  if( !pRet ){\n    sqlite3_free(pOrig);\n  }\n  return pRet;\n}\n\n/*\n** Buffer zInput, length nInput, contains the contents of a quoted string\n** that appeared as part of an fts3 query expression. Neither quote character\n** is included in the buffer. This function attempts to tokenize the entire\n** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE \n** containing the results.\n**\n** If successful, SQLITE_OK is returned and *ppExpr set to point at the\n** allocated Fts3Expr structure. Otherwise, either SQLITE_NOMEM (out of memory\n** error) or SQLITE_ERROR (tokenization error) is returned and *ppExpr set\n** to 0.\n*/\nstatic int getNextString(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *zInput, int nInput,         /* Input string */\n  Fts3Expr **ppExpr                       /* OUT: expression */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  Fts3Expr *p = 0;\n  sqlite3_tokenizer_cursor *pCursor = 0;\n  char *zTemp = 0;\n  int nTemp = 0;\n\n  const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);\n  int nToken = 0;\n\n  /* The final Fts3Expr data structure, including the Fts3Phrase,\n  ** Fts3PhraseToken structures token buffers are all stored as a single \n  ** allocation so that the expression can be freed with a single call to\n  ** sqlite3_free(). Setting this up requires a two pass approach.\n  **\n  ** The first pass, in the block below, uses a tokenizer cursor to iterate\n  ** through the tokens in the expression. This pass uses fts3ReallocOrFree()\n  ** to assemble data in two dynamic buffers:\n  **\n  **   Buffer p: Points to the Fts3Expr structure, followed by the Fts3Phrase\n  **             structure, followed by the array of Fts3PhraseToken \n  **             structures. This pass only populates the Fts3PhraseToken array.\n  **\n  **   Buffer zTemp: Contains copies of all tokens.\n  **\n  ** The second pass, in the block that begins \"if( rc==SQLITE_DONE )\" below,\n  ** appends buffer zTemp to buffer p, and fills in the Fts3Expr and Fts3Phrase\n  ** structures.\n  */\n  rc = sqlite3Fts3OpenTokenizer(\n      pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);\n  if( rc==SQLITE_OK ){\n    int ii;\n    for(ii=0; rc==SQLITE_OK; ii++){\n      const char *zByte;\n      int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;\n      rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);\n      if( rc==SQLITE_OK ){\n        Fts3PhraseToken *pToken;\n\n        p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));\n        if( !p ) goto no_mem;\n\n        zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);\n        if( !zTemp ) goto no_mem;\n\n        assert( nToken==ii );\n        pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];\n        memset(pToken, 0, sizeof(Fts3PhraseToken));\n\n        memcpy(&zTemp[nTemp], zByte, nByte);\n        nTemp += nByte;\n\n        pToken->n = nByte;\n        pToken->isPrefix = (iEnd<nInput && zInput[iEnd]=='*');\n        pToken->bFirst = (iBegin>0 && zInput[iBegin-1]=='^');\n        nToken = ii+1;\n      }\n    }\n\n    pModule->xClose(pCursor);\n    pCursor = 0;\n  }\n\n  if( rc==SQLITE_DONE ){\n    int jj;\n    char *zBuf = 0;\n\n    p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);\n    if( !p ) goto no_mem;\n    memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);\n    p->eType = FTSQUERY_PHRASE;\n    p->pPhrase = (Fts3Phrase *)&p[1];\n    p->pPhrase->iColumn = pParse->iDefaultCol;\n    p->pPhrase->nToken = nToken;\n\n    zBuf = (char *)&p->pPhrase->aToken[nToken];\n    if( zTemp ){\n      memcpy(zBuf, zTemp, nTemp);\n      sqlite3_free(zTemp);\n    }else{\n      assert( nTemp==0 );\n    }\n\n    for(jj=0; jj<p->pPhrase->nToken; jj++){\n      p->pPhrase->aToken[jj].z = zBuf;\n      zBuf += p->pPhrase->aToken[jj].n;\n    }\n    rc = SQLITE_OK;\n  }\n\n  *ppExpr = p;\n  return rc;\nno_mem:\n\n  if( pCursor ){\n    pModule->xClose(pCursor);\n  }\n  sqlite3_free(zTemp);\n  sqlite3_free(p);\n  *ppExpr = 0;\n  return SQLITE_NOMEM;\n}\n\n/*\n** The output variable *ppExpr is populated with an allocated Fts3Expr \n** structure, or set to 0 if the end of the input buffer is reached.\n**\n** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM\n** if a malloc failure occurs, or SQLITE_ERROR if a parse error is encountered.\n** If SQLITE_ERROR is returned, pContext is populated with an error message.\n*/\nstatic int getNextNode(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  static const struct Fts3Keyword {\n    char *z;                              /* Keyword text */\n    unsigned char n;                      /* Length of the keyword */\n    unsigned char parenOnly;              /* Only valid in paren mode */\n    unsigned char eType;                  /* Keyword code */\n  } aKeyword[] = {\n    { \"OR\" ,  2, 0, FTSQUERY_OR   },\n    { \"AND\",  3, 1, FTSQUERY_AND  },\n    { \"NOT\",  3, 1, FTSQUERY_NOT  },\n    { \"NEAR\", 4, 0, FTSQUERY_NEAR }\n  };\n  int ii;\n  int iCol;\n  int iColLen;\n  int rc;\n  Fts3Expr *pRet = 0;\n\n  const char *zInput = z;\n  int nInput = n;\n\n  pParse->isNot = 0;\n\n  /* Skip over any whitespace before checking for a keyword, an open or\n  ** close bracket, or a quoted string. \n  */\n  while( nInput>0 && fts3isspace(*zInput) ){\n    nInput--;\n    zInput++;\n  }\n  if( nInput==0 ){\n    return SQLITE_DONE;\n  }\n\n  /* See if we are dealing with a keyword. */\n  for(ii=0; ii<(int)(sizeof(aKeyword)/sizeof(struct Fts3Keyword)); ii++){\n    const struct Fts3Keyword *pKey = &aKeyword[ii];\n\n    if( (pKey->parenOnly & ~sqlite3_fts3_enable_parentheses)!=0 ){\n      continue;\n    }\n\n    if( nInput>=pKey->n && 0==memcmp(zInput, pKey->z, pKey->n) ){\n      int nNear = SQLITE_FTS3_DEFAULT_NEAR_PARAM;\n      int nKey = pKey->n;\n      char cNext;\n\n      /* If this is a \"NEAR\" keyword, check for an explicit nearness. */\n      if( pKey->eType==FTSQUERY_NEAR ){\n        assert( nKey==4 );\n        if( zInput[4]=='/' && zInput[5]>='0' && zInput[5]<='9' ){\n          nNear = 0;\n          for(nKey=5; zInput[nKey]>='0' && zInput[nKey]<='9'; nKey++){\n            nNear = nNear * 10 + (zInput[nKey] - '0');\n          }\n        }\n      }\n\n      /* At this point this is probably a keyword. But for that to be true,\n      ** the next byte must contain either whitespace, an open or close\n      ** parenthesis, a quote character, or EOF. \n      */\n      cNext = zInput[nKey];\n      if( fts3isspace(cNext) \n       || cNext=='\"' || cNext=='(' || cNext==')' || cNext==0\n      ){\n        pRet = (Fts3Expr *)fts3MallocZero(sizeof(Fts3Expr));\n        if( !pRet ){\n          return SQLITE_NOMEM;\n        }\n        pRet->eType = pKey->eType;\n        pRet->nNear = nNear;\n        *ppExpr = pRet;\n        *pnConsumed = (int)((zInput - z) + nKey);\n        return SQLITE_OK;\n      }\n\n      /* Turns out that wasn't a keyword after all. This happens if the\n      ** user has supplied a token such as \"ORacle\". Continue.\n      */\n    }\n  }\n\n  /* See if we are dealing with a quoted phrase. If this is the case, then\n  ** search for the closing quote and pass the whole string to getNextString()\n  ** for processing. This is easy to do, as fts3 has no syntax for escaping\n  ** a quote character embedded in a string.\n  */\n  if( *zInput=='\"' ){\n    for(ii=1; ii<nInput && zInput[ii]!='\"'; ii++);\n    *pnConsumed = (int)((zInput - z) + ii + 1);\n    if( ii==nInput ){\n      return SQLITE_ERROR;\n    }\n    return getNextString(pParse, &zInput[1], ii-1, ppExpr);\n  }\n\n  if( sqlite3_fts3_enable_parentheses ){\n    if( *zInput=='(' ){\n      int nConsumed = 0;\n      pParse->nNest++;\n      rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);\n      if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; }\n      *pnConsumed = (int)(zInput - z) + 1 + nConsumed;\n      return rc;\n    }else if( *zInput==')' ){\n      pParse->nNest--;\n      *pnConsumed = (int)((zInput - z) + 1);\n      *ppExpr = 0;\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If control flows to this point, this must be a regular token, or \n  ** the end of the input. Read a regular token using the sqlite3_tokenizer\n  ** interface. Before doing so, figure out if there is an explicit\n  ** column specifier for the token. \n  **\n  ** TODO: Strangely, it is not possible to associate a column specifier\n  ** with a quoted phrase, only with a single token. Not sure if this was\n  ** an implementation artifact or an intentional decision when fts3 was\n  ** first implemented. Whichever it was, this module duplicates the \n  ** limitation.\n  */\n  iCol = pParse->iDefaultCol;\n  iColLen = 0;\n  for(ii=0; ii<pParse->nCol; ii++){\n    const char *zStr = pParse->azCol[ii];\n    int nStr = (int)strlen(zStr);\n    if( nInput>nStr && zInput[nStr]==':' \n     && sqlite3_strnicmp(zStr, zInput, nStr)==0 \n    ){\n      iCol = ii;\n      iColLen = (int)((zInput - z) + nStr + 1);\n      break;\n    }\n  }\n  rc = getNextToken(pParse, iCol, &z[iColLen], n-iColLen, ppExpr, pnConsumed);\n  *pnConsumed += iColLen;\n  return rc;\n}\n\n/*\n** The argument is an Fts3Expr structure for a binary operator (any type\n** except an FTSQUERY_PHRASE). Return an integer value representing the\n** precedence of the operator. Lower values have a higher precedence (i.e.\n** group more tightly). For example, in the C language, the == operator\n** groups more tightly than ||, and would therefore have a higher precedence.\n**\n** When using the new fts3 query syntax (when SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined), the order of the operators in precedence from highest to\n** lowest is:\n**\n**   NEAR\n**   NOT\n**   AND (including implicit ANDs)\n**   OR\n**\n** Note that when using the old query syntax, the OR operator has a higher\n** precedence than the AND operator.\n*/\nstatic int opPrecedence(Fts3Expr *p){\n  assert( p->eType!=FTSQUERY_PHRASE );\n  if( sqlite3_fts3_enable_parentheses ){\n    return p->eType;\n  }else if( p->eType==FTSQUERY_NEAR ){\n    return 1;\n  }else if( p->eType==FTSQUERY_OR ){\n    return 2;\n  }\n  assert( p->eType==FTSQUERY_AND );\n  return 3;\n}\n\n/*\n** Argument ppHead contains a pointer to the current head of a query \n** expression tree being parsed. pPrev is the expression node most recently\n** inserted into the tree. This function adds pNew, which is always a binary\n** operator node, into the expression tree based on the relative precedence\n** of pNew and the existing nodes of the tree. This may result in the head\n** of the tree changing, in which case *ppHead is set to the new root node.\n*/\nstatic void insertBinaryOperator(\n  Fts3Expr **ppHead,       /* Pointer to the root node of a tree */\n  Fts3Expr *pPrev,         /* Node most recently inserted into the tree */\n  Fts3Expr *pNew           /* New binary node to insert into expression tree */\n){\n  Fts3Expr *pSplit = pPrev;\n  while( pSplit->pParent && opPrecedence(pSplit->pParent)<=opPrecedence(pNew) ){\n    pSplit = pSplit->pParent;\n  }\n\n  if( pSplit->pParent ){\n    assert( pSplit->pParent->pRight==pSplit );\n    pSplit->pParent->pRight = pNew;\n    pNew->pParent = pSplit->pParent;\n  }else{\n    *ppHead = pNew;\n  }\n  pNew->pLeft = pSplit;\n  pSplit->pParent = pNew;\n}\n\n/*\n** Parse the fts3 query expression found in buffer z, length n. This function\n** returns either when the end of the buffer is reached or an unmatched \n** closing bracket - ')' - is encountered.\n**\n** If successful, SQLITE_OK is returned, *ppExpr is set to point to the\n** parsed form of the expression and *pnConsumed is set to the number of\n** bytes read from buffer z. Otherwise, *ppExpr is set to 0 and SQLITE_NOMEM\n** (out of memory error) or SQLITE_ERROR (parse error) is returned.\n*/\nstatic int fts3ExprParse(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Text of MATCH query */\n  Fts3Expr **ppExpr,                      /* OUT: Parsed query structure */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  Fts3Expr *pRet = 0;\n  Fts3Expr *pPrev = 0;\n  Fts3Expr *pNotBranch = 0;               /* Only used in legacy parse mode */\n  int nIn = n;\n  const char *zIn = z;\n  int rc = SQLITE_OK;\n  int isRequirePhrase = 1;\n\n  while( rc==SQLITE_OK ){\n    Fts3Expr *p = 0;\n    int nByte = 0;\n\n    rc = getNextNode(pParse, zIn, nIn, &p, &nByte);\n    assert( nByte>0 || (rc!=SQLITE_OK && p==0) );\n    if( rc==SQLITE_OK ){\n      if( p ){\n        int isPhrase;\n\n        if( !sqlite3_fts3_enable_parentheses \n            && p->eType==FTSQUERY_PHRASE && pParse->isNot \n        ){\n          /* Create an implicit NOT operator. */\n          Fts3Expr *pNot = fts3MallocZero(sizeof(Fts3Expr));\n          if( !pNot ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_NOMEM;\n            goto exprparse_out;\n          }\n          pNot->eType = FTSQUERY_NOT;\n          pNot->pRight = p;\n          p->pParent = pNot;\n          if( pNotBranch ){\n            pNot->pLeft = pNotBranch;\n            pNotBranch->pParent = pNot;\n          }\n          pNotBranch = pNot;\n          p = pPrev;\n        }else{\n          int eType = p->eType;\n          isPhrase = (eType==FTSQUERY_PHRASE || p->pLeft);\n\n          /* The isRequirePhrase variable is set to true if a phrase or\n          ** an expression contained in parenthesis is required. If a\n          ** binary operator (AND, OR, NOT or NEAR) is encounted when\n          ** isRequirePhrase is set, this is a syntax error.\n          */\n          if( !isPhrase && isRequirePhrase ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase && !isRequirePhrase ){\n            /* Insert an implicit AND operator. */\n            Fts3Expr *pAnd;\n            assert( pRet && pPrev );\n            pAnd = fts3MallocZero(sizeof(Fts3Expr));\n            if( !pAnd ){\n              sqlite3Fts3ExprFree(p);\n              rc = SQLITE_NOMEM;\n              goto exprparse_out;\n            }\n            pAnd->eType = FTSQUERY_AND;\n            insertBinaryOperator(&pRet, pPrev, pAnd);\n            pPrev = pAnd;\n          }\n\n          /* This test catches attempts to make either operand of a NEAR\n           ** operator something other than a phrase. For example, either of\n           ** the following:\n           **\n           **    (bracketed expression) NEAR phrase\n           **    phrase NEAR (bracketed expression)\n           **\n           ** Return an error in either case.\n           */\n          if( pPrev && (\n            (eType==FTSQUERY_NEAR && !isPhrase && pPrev->eType!=FTSQUERY_PHRASE)\n         || (eType!=FTSQUERY_PHRASE && isPhrase && pPrev->eType==FTSQUERY_NEAR)\n          )){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase ){\n            if( pRet ){\n              assert( pPrev && pPrev->pLeft && pPrev->pRight==0 );\n              pPrev->pRight = p;\n              p->pParent = pPrev;\n            }else{\n              pRet = p;\n            }\n          }else{\n            insertBinaryOperator(&pRet, pPrev, p);\n          }\n          isRequirePhrase = !isPhrase;\n        }\n        pPrev = p;\n      }\n      assert( nByte>0 );\n    }\n    assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) );\n    nIn -= nByte;\n    zIn += nByte;\n  }\n\n  if( rc==SQLITE_DONE && pRet && isRequirePhrase ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    if( !sqlite3_fts3_enable_parentheses && pNotBranch ){\n      if( !pRet ){\n        rc = SQLITE_ERROR;\n      }else{\n        Fts3Expr *pIter = pNotBranch;\n        while( pIter->pLeft ){\n          pIter = pIter->pLeft;\n        }\n        pIter->pLeft = pRet;\n        pRet->pParent = pIter;\n        pRet = pNotBranch;\n      }\n    }\n  }\n  *pnConsumed = n - nIn;\n\nexprparse_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRet);\n    sqlite3Fts3ExprFree(pNotBranch);\n    pRet = 0;\n  }\n  *ppExpr = pRet;\n  return rc;\n}\n\n/*\n** Return SQLITE_ERROR if the maximum depth of the expression tree passed \n** as the only argument is more than nMaxDepth.\n*/\nstatic int fts3ExprCheckDepth(Fts3Expr *p, int nMaxDepth){\n  int rc = SQLITE_OK;\n  if( p ){\n    if( nMaxDepth<0 ){ \n      rc = SQLITE_TOOBIG;\n    }else{\n      rc = fts3ExprCheckDepth(p->pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprCheckDepth(p->pRight, nMaxDepth-1);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** This function attempts to transform the expression tree at (*pp) to\n** an equivalent but more balanced form. The tree is modified in place.\n** If successful, SQLITE_OK is returned and (*pp) set to point to the \n** new root expression node. \n**\n** nMaxDepth is the maximum allowable depth of the balanced sub-tree.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and \n** expression (*pp) freed.\n*/\nstatic int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts3Expr *pRoot = *pp;          /* Initial root node */\n  Fts3Expr *pFree = 0;            /* List of free nodes. Linked by pParent. */\n  int eType = pRoot->eType;       /* Type of node in this tree */\n\n  if( nMaxDepth==0 ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){\n      Fts3Expr **apLeaf;\n      apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);\n      if( 0==apLeaf ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(apLeaf, 0, sizeof(Fts3Expr *) * nMaxDepth);\n      }\n\n      if( rc==SQLITE_OK ){\n        int i;\n        Fts3Expr *p;\n\n        /* Set $p to point to the left-most leaf in the tree of eType nodes. */\n        for(p=pRoot; p->eType==eType; p=p->pLeft){\n          assert( p->pParent==0 || p->pParent->pLeft==p );\n          assert( p->pLeft && p->pRight );\n        }\n\n        /* This loop runs once for each leaf in the tree of eType nodes. */\n        while( 1 ){\n          int iLvl;\n          Fts3Expr *pParent = p->pParent;     /* Current parent of p */\n\n          assert( pParent==0 || pParent->pLeft==p );\n          p->pParent = 0;\n          if( pParent ){\n            pParent->pLeft = 0;\n          }else{\n            pRoot = 0;\n          }\n          rc = fts3ExprBalance(&p, nMaxDepth-1);\n          if( rc!=SQLITE_OK ) break;\n\n          for(iLvl=0; p && iLvl<nMaxDepth; iLvl++){\n            if( apLeaf[iLvl]==0 ){\n              apLeaf[iLvl] = p;\n              p = 0;\n            }else{\n              assert( pFree );\n              pFree->pLeft = apLeaf[iLvl];\n              pFree->pRight = p;\n              pFree->pLeft->pParent = pFree;\n              pFree->pRight->pParent = pFree;\n\n              p = pFree;\n              pFree = pFree->pParent;\n              p->pParent = 0;\n              apLeaf[iLvl] = 0;\n            }\n          }\n          if( p ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_TOOBIG;\n            break;\n          }\n\n          /* If that was the last leaf node, break out of the loop */\n          if( pParent==0 ) break;\n\n          /* Set $p to point to the next leaf in the tree of eType nodes */\n          for(p=pParent->pRight; p->eType==eType; p=p->pLeft);\n\n          /* Remove pParent from the original tree. */\n          assert( pParent->pParent==0 || pParent->pParent->pLeft==pParent );\n          pParent->pRight->pParent = pParent->pParent;\n          if( pParent->pParent ){\n            pParent->pParent->pLeft = pParent->pRight;\n          }else{\n            assert( pParent==pRoot );\n            pRoot = pParent->pRight;\n          }\n\n          /* Link pParent into the free node list. It will be used as an\n          ** internal node of the new tree.  */\n          pParent->pParent = pFree;\n          pFree = pParent;\n        }\n\n        if( rc==SQLITE_OK ){\n          p = 0;\n          for(i=0; i<nMaxDepth; i++){\n            if( apLeaf[i] ){\n              if( p==0 ){\n                p = apLeaf[i];\n                p->pParent = 0;\n              }else{\n                assert( pFree!=0 );\n                pFree->pRight = p;\n                pFree->pLeft = apLeaf[i];\n                pFree->pLeft->pParent = pFree;\n                pFree->pRight->pParent = pFree;\n\n                p = pFree;\n                pFree = pFree->pParent;\n                p->pParent = 0;\n              }\n            }\n          }\n          pRoot = p;\n        }else{\n          /* An error occurred. Delete the contents of the apLeaf[] array \n          ** and pFree list. Everything else is cleaned up by the call to\n          ** sqlite3Fts3ExprFree(pRoot) below.  */\n          Fts3Expr *pDel;\n          for(i=0; i<nMaxDepth; i++){\n            sqlite3Fts3ExprFree(apLeaf[i]);\n          }\n          while( (pDel=pFree)!=0 ){\n            pFree = pDel->pParent;\n            sqlite3_free(pDel);\n          }\n        }\n\n        assert( pFree==0 );\n        sqlite3_free( apLeaf );\n      }\n    }else if( eType==FTSQUERY_NOT ){\n      Fts3Expr *pLeft = pRoot->pLeft;\n      Fts3Expr *pRight = pRoot->pRight;\n\n      pRoot->pLeft = 0;\n      pRoot->pRight = 0;\n      pLeft->pParent = 0;\n      pRight->pParent = 0;\n\n      rc = fts3ExprBalance(&pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprBalance(&pRight, nMaxDepth-1);\n      }\n\n      if( rc!=SQLITE_OK ){\n        sqlite3Fts3ExprFree(pRight);\n        sqlite3Fts3ExprFree(pLeft);\n      }else{\n        assert( pLeft && pRight );\n        pRoot->pLeft = pLeft;\n        pLeft->pParent = pRoot;\n        pRoot->pRight = pRight;\n        pRight->pParent = pRoot;\n      }\n    }\n  }\n  \n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRoot);\n    pRoot = 0;\n  }\n  *pp = pRoot;\n  return rc;\n}\n\n/*\n** This function is similar to sqlite3Fts3ExprParse(), with the following\n** differences:\n**\n**   1. It does not do expression rebalancing.\n**   2. It does not check that the expression does not exceed the \n**      maximum allowable depth.\n**   3. Even if it fails, *ppExpr may still be set to point to an \n**      expression tree. It should be deleted using sqlite3Fts3ExprFree()\n**      in this case.\n*/\nstatic int fts3ExprParseUnbalanced(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr                   /* OUT: Parsed query structure */\n){\n  int nParsed;\n  int rc;\n  ParseContext sParse;\n\n  memset(&sParse, 0, sizeof(ParseContext));\n  sParse.pTokenizer = pTokenizer;\n  sParse.iLangid = iLangid;\n  sParse.azCol = (const char **)azCol;\n  sParse.nCol = nCol;\n  sParse.iDefaultCol = iDefaultCol;\n  sParse.bFts4 = bFts4;\n  if( z==0 ){\n    *ppExpr = 0;\n    return SQLITE_OK;\n  }\n  if( n<0 ){\n    n = (int)strlen(z);\n  }\n  rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);\n  assert( rc==SQLITE_OK || *ppExpr==0 );\n\n  /* Check for mismatched parenthesis */\n  if( rc==SQLITE_OK && sParse.nNest ){\n    rc = SQLITE_ERROR;\n  }\n  \n  return rc;\n}\n\n/*\n** Parameters z and n contain a pointer to and length of a buffer containing\n** an fts3 query expression, respectively. This function attempts to parse the\n** query expression and create a tree of Fts3Expr structures representing the\n** parsed expression. If successful, *ppExpr is set to point to the head\n** of the parsed expression tree and SQLITE_OK is returned. If an error\n** occurs, either SQLITE_NOMEM (out-of-memory error) or SQLITE_ERROR (parse\n** error) is returned and *ppExpr is set to 0.\n**\n** If parameter n is a negative number, then z is assumed to point to a\n** nul-terminated string and the length is determined using strlen().\n**\n** The first parameter, pTokenizer, is passed the fts3 tokenizer module to\n** use to normalize query tokens while parsing the expression. The azCol[]\n** array, which is assumed to contain nCol entries, should contain the names\n** of each column in the target fts3 table, in order from left to right. \n** Column names must be nul-terminated strings.\n**\n** The iDefaultCol parameter should be passed the index of the table column\n** that appears on the left-hand-side of the MATCH operator (the default\n** column to match against for tokens for which a column name is not explicitly\n** specified as part of the query string), or -1 if tokens may by default\n** match any table column.\n*/\nint sqlite3Fts3ExprParse(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr,                  /* OUT: Parsed query structure */\n  char **pzErr                        /* OUT: Error message (sqlite3_malloc) */\n){\n  int rc = fts3ExprParseUnbalanced(\n      pTokenizer, iLangid, azCol, bFts4, nCol, iDefaultCol, z, n, ppExpr\n  );\n  \n  /* Rebalance the expression. And check that its depth does not exceed\n  ** SQLITE_FTS3_MAX_EXPR_DEPTH.  */\n  if( rc==SQLITE_OK && *ppExpr ){\n    rc = fts3ExprBalance(ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    if( rc==SQLITE_OK ){\n      rc = fts3ExprCheckDepth(*ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(*ppExpr);\n    *ppExpr = 0;\n    if( rc==SQLITE_TOOBIG ){\n      sqlite3Fts3ErrMsg(pzErr,\n          \"FTS expression tree is too large (maximum depth %d)\", \n          SQLITE_FTS3_MAX_EXPR_DEPTH\n      );\n      rc = SQLITE_ERROR;\n    }else if( rc==SQLITE_ERROR ){\n      sqlite3Fts3ErrMsg(pzErr, \"malformed MATCH expression: [%s]\", z);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free a single node of an expression tree.\n*/\nstatic void fts3FreeExprNode(Fts3Expr *p){\n  assert( p->eType==FTSQUERY_PHRASE || p->pPhrase==0 );\n  sqlite3Fts3EvalPhraseCleanup(p->pPhrase);\n  sqlite3_free(p->aMI);\n  sqlite3_free(p);\n}\n\n/*\n** Free a parsed fts3 query expression allocated by sqlite3Fts3ExprParse().\n**\n** This function would be simpler if it recursively called itself. But\n** that would mean passing a sufficiently large expression to ExprParse()\n** could cause a stack overflow.\n*/\nvoid sqlite3Fts3ExprFree(Fts3Expr *pDel){\n  Fts3Expr *p;\n  assert( pDel==0 || pDel->pParent==0 );\n  for(p=pDel; p && (p->pLeft||p->pRight); p=(p->pLeft ? p->pLeft : p->pRight)){\n    assert( p->pParent==0 || p==p->pParent->pRight || p==p->pParent->pLeft );\n  }\n  while( p ){\n    Fts3Expr *pParent = p->pParent;\n    fts3FreeExprNode(p);\n    if( pParent && p==pParent->pLeft && pParent->pRight ){\n      p = pParent->pRight;\n      while( p && (p->pLeft || p->pRight) ){\n        assert( p==p->pParent->pRight || p==p->pParent->pLeft );\n        p = (p->pLeft ? p->pLeft : p->pRight);\n      }\n    }else{\n      p = pParent;\n    }\n  }\n}\n\n/****************************************************************************\n*****************************************************************************\n** Everything after this point is just test code.\n*/\n\n#ifdef SQLITE_TEST\n\n#include <stdio.h>\n\n/*\n** Function to query the hash-table of tokenizers (see README.tokenizers).\n*/\nstatic int queryTestTokenizer(\n  sqlite3 *db, \n  const char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\n/*\n** Return a pointer to a buffer containing a text representation of the\n** expression passed as the first argument. The buffer is obtained from\n** sqlite3_malloc(). It is the responsibility of the caller to use \n** sqlite3_free() to release the memory. If an OOM condition is encountered,\n** NULL is returned.\n**\n** If the second argument is not NULL, then its contents are prepended to \n** the returned expression text and then freed using sqlite3_free().\n*/\nstatic char *exprToString(Fts3Expr *pExpr, char *zBuf){\n  if( pExpr==0 ){\n    return sqlite3_mprintf(\"\");\n  }\n  switch( pExpr->eType ){\n    case FTSQUERY_PHRASE: {\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      zBuf = sqlite3_mprintf(\n          \"%zPHRASE %d 0\", zBuf, pPhrase->iColumn);\n      for(i=0; zBuf && i<pPhrase->nToken; i++){\n        zBuf = sqlite3_mprintf(\"%z %.*s%s\", zBuf, \n            pPhrase->aToken[i].n, pPhrase->aToken[i].z,\n            (pPhrase->aToken[i].isPrefix?\"+\":\"\")\n        );\n      }\n      return zBuf;\n    }\n\n    case FTSQUERY_NEAR:\n      zBuf = sqlite3_mprintf(\"%zNEAR/%d \", zBuf, pExpr->nNear);\n      break;\n    case FTSQUERY_NOT:\n      zBuf = sqlite3_mprintf(\"%zNOT \", zBuf);\n      break;\n    case FTSQUERY_AND:\n      zBuf = sqlite3_mprintf(\"%zAND \", zBuf);\n      break;\n    case FTSQUERY_OR:\n      zBuf = sqlite3_mprintf(\"%zOR \", zBuf);\n      break;\n  }\n\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z{\", zBuf);\n  if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z} {\", zBuf);\n\n  if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z}\", zBuf);\n\n  return zBuf;\n}\n\n/*\n** This is the implementation of a scalar SQL function used to test the \n** expression parser. It should be called as follows:\n**\n**   fts3_exprtest(<tokenizer>, <expr>, <column 1>, ...);\n**\n** The first argument, <tokenizer>, is the name of the fts3 tokenizer used\n** to parse the query expression (see README.tokenizers). The second argument\n** is the query expression to parse. Each subsequent argument is the name\n** of a column of the fts3 table that the query expression may refer to.\n** For example:\n**\n**   SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');\n*/\nstatic void fts3ExprTest(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_tokenizer_module const *pModule = 0;\n  sqlite3_tokenizer *pTokenizer = 0;\n  int rc;\n  char **azCol = 0;\n  const char *zExpr;\n  int nExpr;\n  int nCol;\n  int ii;\n  Fts3Expr *pExpr;\n  char *zBuf = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc<3 ){\n    sqlite3_result_error(context, \n        \"Usage: fts3_exprtest(tokenizer, expr, col1, ...\", -1\n    );\n    return;\n  }\n\n  rc = queryTestTokenizer(db,\n                          (const char *)sqlite3_value_text(argv[0]), &pModule);\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }else if( !pModule ){\n    sqlite3_result_error(context, \"No such tokenizer module\", -1);\n    goto exprtest_out;\n  }\n\n  rc = pModule->xCreate(0, 0, &pTokenizer);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  pTokenizer->pModule = pModule;\n\n  zExpr = (const char *)sqlite3_value_text(argv[1]);\n  nExpr = sqlite3_value_bytes(argv[1]);\n  nCol = argc-2;\n  azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));\n  if( !azCol ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  for(ii=0; ii<nCol; ii++){\n    azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);\n  }\n\n  if( sqlite3_user_data(context) ){\n    char *zDummy = 0;\n    rc = sqlite3Fts3ExprParse(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy\n    );\n    assert( rc==SQLITE_OK || pExpr==0 );\n    sqlite3_free(zDummy);\n  }else{\n    rc = fts3ExprParseUnbalanced(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr\n    );\n  }\n\n  if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){\n    sqlite3Fts3ExprFree(pExpr);\n    sqlite3_result_error(context, \"Error parsing expression\", -1);\n  }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n    sqlite3_free(zBuf);\n  }\n\n  sqlite3Fts3ExprFree(pExpr);\n\nexprtest_out:\n  if( pModule && pTokenizer ){\n    rc = pModule->xDestroy(pTokenizer);\n  }\n  sqlite3_free(azCol);\n}\n\n/*\n** Register the query expression parser test function fts3_exprtest() \n** with database connection db. \n*/\nint sqlite3Fts3ExprInitTestInterface(sqlite3* db){\n  int rc = sqlite3_create_function(\n      db, \"fts3_exprtest\", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"fts3_exprtest_rebalance\", \n        -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0\n    );\n  }\n  return rc;\n}\n\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_hash.c",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <assert.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"fts3_hash.h\"\n\n/*\n** Malloc and Free functions\n*/\nstatic void *fts3HashMalloc(int n){\n  void *p = sqlite3_malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\nstatic void fts3HashFree(void *p){\n  sqlite3_free(p);\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS3_HASH_BINARY or FTS3_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nvoid sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nvoid sqlite3Fts3HashClear(Fts3Hash *pH){\n  Fts3HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  fts3HashFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    Fts3HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      fts3HashFree(elem->pKey);\n    }\n    fts3HashFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_STRING\n*/\nstatic int fts3StrHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  unsigned h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return (int)(h & 0x7fffffff);\n}\nstatic int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_BINARY\n*/\nstatic int fts3BinHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int fts3BinCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"ftsHashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of ftsHashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of ftsHashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*ftsHashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrHash;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*ftsCompareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrCompare;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void fts3HashInsertElement(\n  Fts3Hash *pH,            /* The complete hash table */\n  struct _fts3ht *pEntry,  /* The entry into which pNew is inserted */\n  Fts3HashElem *pNew       /* The element to be inserted */\n){\n  Fts3HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n**\n** Return non-zero if a memory allocation error occurs.\n*/\nstatic int fts3Rehash(Fts3Hash *pH, int new_size){\n  struct _fts3ht *new_ht;          /* The new hash table */\n  Fts3HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts3ht *)fts3HashMalloc( new_size*sizeof(struct _fts3ht) );\n  if( new_ht==0 ) return 1;\n  fts3HashFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = ftsHashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    fts3HashInsertElement(pH, &new_ht[h], elem);\n  }\n  return 0;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic Fts3HashElem *fts3FindElementByHash(\n  const Fts3Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  Fts3HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts3ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = ftsCompareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void fts3RemoveElementByHash(\n  Fts3Hash *pH,         /* The pH containing \"elem\" */\n  Fts3HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts3ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    fts3HashFree(elem->pKey);\n  }\n  fts3HashFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts3HashClear(pH);\n  }\n}\n\nFts3HashElem *sqlite3Fts3HashFindElem(\n  const Fts3Hash *pH, \n  const void *pKey, \n  int nKey\n){\n  int h;                          /* A hash on key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));\n}\n\n/* \n** Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nvoid *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){\n  Fts3HashElem *pElem;            /* The element that matches key (if any) */\n\n  pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);\n  return pElem ? pElem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nvoid *sqlite3Fts3HashInsert(\n  Fts3Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  Fts3HashElem *elem;       /* Used to loop thru the element list */\n  Fts3HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = fts3FindElementByHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      fts3RemoveElementByHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  if( (pH->htsize==0 && fts3Rehash(pH,8))\n   || (pH->count>=pH->htsize && fts3Rehash(pH, pH->htsize*2))\n  ){\n    pH->count = 0;\n    return data;\n  }\n  assert( pH->htsize>0 );\n  new_elem = (Fts3HashElem*)fts3HashMalloc( sizeof(Fts3HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = fts3HashMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      fts3HashFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  fts3HashInsertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_hash.h",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS3_HASH_H_\n#define _FTS3_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Fts3Hash Fts3Hash;\ntypedef struct Fts3HashElem Fts3HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct Fts3Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  Fts3HashElem *first;    /* The first element of the array */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts3ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    Fts3HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct Fts3HashElem {\n  Fts3HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS3_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS3_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts3HashInit is 1.  \n*/\n#define FTS3_HASH_STRING    1\n#define FTS3_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nvoid sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);\nvoid *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);\nvoid *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);\nvoid sqlite3Fts3HashClear(Fts3Hash*);\nFts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts3HashInit     sqlite3Fts3HashInit\n#define fts3HashInsert   sqlite3Fts3HashInsert\n#define fts3HashFind     sqlite3Fts3HashFind\n#define fts3HashClear    sqlite3Fts3HashClear\n#define fts3HashFindElem sqlite3Fts3HashFindElem\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Fts3Hash h;\n**   Fts3HashElem *p;\n**   ...\n**   for(p=fts3HashFirst(&h); p; p=fts3HashNext(p)){\n**     SomeStructure *pData = fts3HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts3HashFirst(H)  ((H)->first)\n#define fts3HashNext(E)   ((E)->next)\n#define fts3HashData(E)   ((E)->data)\n#define fts3HashKey(E)    ((E)->pKey)\n#define fts3HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts3HashCount(H)  ((H)->count)\n\n#endif /* _FTS3_HASH_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_icu.c",
    "content": "/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a tokenizer for fts3 based on the ICU library.\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n#ifdef SQLITE_ENABLE_ICU\n\n#include <assert.h>\n#include <string.h>\n#include \"fts3_tokenizer.h\"\n\n#include <unicode/ubrk.h>\n#include <unicode/ucol.h>\n#include <unicode/ustring.h>\n#include <unicode/utf16.h>\n\ntypedef struct IcuTokenizer IcuTokenizer;\ntypedef struct IcuCursor IcuCursor;\n\nstruct IcuTokenizer {\n  sqlite3_tokenizer base;\n  char *zLocale;\n};\n\nstruct IcuCursor {\n  sqlite3_tokenizer_cursor base;\n\n  UBreakIterator *pIter;      /* ICU break-iterator object */\n  int nChar;                  /* Number of UChar elements in pInput */\n  UChar *aChar;               /* Copy of input using utf-16 encoding */\n  int *aOffset;               /* Offsets of each character in utf-8 input */\n\n  int nBuffer;\n  char *zBuffer;\n\n  int iToken;\n};\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int icuCreate(\n  int argc,                            /* Number of entries in argv[] */\n  const char * const *argv,            /* Tokenizer creation arguments */\n  sqlite3_tokenizer **ppTokenizer      /* OUT: Created tokenizer */\n){\n  IcuTokenizer *p;\n  int n = 0;\n\n  if( argc>0 ){\n    n = strlen(argv[0])+1;\n  }\n  p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(IcuTokenizer));\n\n  if( n ){\n    p->zLocale = (char *)&p[1];\n    memcpy(p->zLocale, argv[0], n);\n  }\n\n  *ppTokenizer = (sqlite3_tokenizer *)p;\n\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int icuDestroy(sqlite3_tokenizer *pTokenizer){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int icuOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput,                    /* Input string */\n  int nInput,                            /* Length of zInput in bytes */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  IcuCursor *pCsr;\n\n  const int32_t opt = U_FOLD_CASE_DEFAULT;\n  UErrorCode status = U_ZERO_ERROR;\n  int nChar;\n\n  UChar32 c;\n  int iInput = 0;\n  int iOut = 0;\n\n  *ppCursor = 0;\n\n  if( zInput==0 ){\n    nInput = 0;\n    zInput = \"\";\n  }else if( nInput<0 ){\n    nInput = strlen(zInput);\n  }\n  nChar = nInput+1;\n  pCsr = (IcuCursor *)sqlite3_malloc(\n      sizeof(IcuCursor) +                /* IcuCursor */\n      ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */\n      (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */\n  );\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(IcuCursor));\n  pCsr->aChar = (UChar *)&pCsr[1];\n  pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];\n\n  pCsr->aOffset[iOut] = iInput;\n  U8_NEXT(zInput, iInput, nInput, c); \n  while( c>0 ){\n    int isError = 0;\n    c = u_foldCase(c, opt);\n    U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);\n    if( isError ){\n      sqlite3_free(pCsr);\n      return SQLITE_ERROR;\n    }\n    pCsr->aOffset[iOut] = iInput;\n\n    if( iInput<nInput ){\n      U8_NEXT(zInput, iInput, nInput, c);\n    }else{\n      c = 0;\n    }\n  }\n\n  pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);\n  if( !U_SUCCESS(status) ){\n    sqlite3_free(pCsr);\n    return SQLITE_ERROR;\n  }\n  pCsr->nChar = iOut;\n\n  ubrk_first(pCsr->pIter);\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to icuOpen().\n*/\nstatic int icuClose(sqlite3_tokenizer_cursor *pCursor){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n  ubrk_close(pCsr->pIter);\n  sqlite3_free(pCsr->zBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.\n*/\nstatic int icuNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n\n  int iStart = 0;\n  int iEnd = 0;\n  int nByte = 0;\n\n  while( iStart==iEnd ){\n    UChar32 c;\n\n    iStart = ubrk_current(pCsr->pIter);\n    iEnd = ubrk_next(pCsr->pIter);\n    if( iEnd==UBRK_DONE ){\n      return SQLITE_DONE;\n    }\n\n    while( iStart<iEnd ){\n      int iWhite = iStart;\n      U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);\n      if( u_isspace(c) ){\n        iStart = iWhite;\n      }else{\n        break;\n      }\n    }\n    assert(iStart<=iEnd);\n  }\n\n  do {\n    UErrorCode status = U_ZERO_ERROR;\n    if( nByte ){\n      char *zNew = sqlite3_realloc(pCsr->zBuffer, nByte);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pCsr->zBuffer = zNew;\n      pCsr->nBuffer = nByte;\n    }\n\n    u_strToUTF8(\n        pCsr->zBuffer, pCsr->nBuffer, &nByte,    /* Output vars */\n        &pCsr->aChar[iStart], iEnd-iStart,       /* Input vars */\n        &status                                  /* Output success/failure */\n    );\n  } while( nByte>pCsr->nBuffer );\n\n  *ppToken = pCsr->zBuffer;\n  *pnBytes = nByte;\n  *piStartOffset = pCsr->aOffset[iStart];\n  *piEndOffset = pCsr->aOffset[iEnd];\n  *piPosition = pCsr->iToken++;\n\n  return SQLITE_OK;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module icuTokenizerModule = {\n  0,                           /* iVersion    */\n  icuCreate,                   /* xCreate     */\n  icuDestroy,                  /* xCreate     */\n  icuOpen,                     /* xOpen       */\n  icuClose,                    /* xClose      */\n  icuNext,                     /* xNext       */\n  0,                           /* xLanguageid */\n};\n\n/*\n** Set *ppModule to point at the implementation of the ICU tokenizer.\n*/\nvoid sqlite3Fts3IcuTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &icuTokenizerModule;\n}\n\n#endif /* defined(SQLITE_ENABLE_ICU) */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_porter.c",
    "content": "/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"fts3_tokenizer.h\"\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlite3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->zToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1];\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    isVowel(z+1) &&\n    isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=(int)sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     if( !stem(&z, \"lanoita\", \"ate\", m_gt_0) ){\n       stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     }\n     break;\n   case 'c':\n     if( !stem(&z, \"icne\", \"ence\", m_gt_0) ){\n       stem(&z, \"icna\", \"ance\", m_gt_0);\n     }\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"ilb\", \"ble\", m_gt_0) \n      && !stem(&z, \"illa\", \"al\", m_gt_0)\n      && !stem(&z, \"iltne\", \"ent\", m_gt_0)\n      && !stem(&z, \"ile\", \"e\", m_gt_0)\n     ){\n       stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 'o':\n     if( !stem(&z, \"noitazi\", \"ize\", m_gt_0)\n      && !stem(&z, \"noita\", \"ate\", m_gt_0)\n     ){\n       stem(&z, \"rota\", \"ate\", m_gt_0);\n     }\n     break;\n   case 's':\n     if( !stem(&z, \"msila\", \"al\", m_gt_0)\n      && !stem(&z, \"ssenevi\", \"ive\", m_gt_0)\n      && !stem(&z, \"ssenluf\", \"ful\", m_gt_0)\n     ){\n       stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"itila\", \"al\", m_gt_0)\n      && !stem(&z, \"itivi\", \"ive\", m_gt_0)\n     ){\n       stem(&z, \"itilib\", \"ble\", m_gt_0);\n     }\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     if( !stem(&z, \"etaci\", \"ic\", m_gt_0)\n      && !stem(&z, \"evita\", \"\", m_gt_0)\n     ){\n       stem(&z, \"ezila\", \"al\", m_gt_0);\n     }\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"laci\", \"ic\", m_gt_0) ){\n       stem(&z, \"luf\", \"\", m_gt_0);\n     }\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         if( !stem(&z, \"tneme\", \"\", m_gt_1)\n          && !stem(&z, \"tnem\", \"\", m_gt_1)\n         ){\n           stem(&z, \"tne\", \"\", m_gt_1);\n         }\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"eta\", \"\", m_gt_1) ){\n       stem(&z, \"iti\", \"\", m_gt_1);\n     }\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = (int)strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char porterIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !porterIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        char *pNew;\n        c->nAllocated = n+20;\n        pNew = sqlite3_realloc(c->zToken, c->nAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->zToken = pNew;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n  0\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts3PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_snippet.c",
    "content": "/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <string.h>\n#include <assert.h>\n\n/*\n** Characters that may appear in the second argument to matchinfo().\n*/\n#define FTS3_MATCHINFO_NPHRASE   'p'        /* 1 value */\n#define FTS3_MATCHINFO_NCOL      'c'        /* 1 value */\n#define FTS3_MATCHINFO_NDOC      'n'        /* 1 value */\n#define FTS3_MATCHINFO_AVGLENGTH 'a'        /* nCol values */\n#define FTS3_MATCHINFO_LENGTH    'l'        /* nCol values */\n#define FTS3_MATCHINFO_LCS       's'        /* nCol values */\n#define FTS3_MATCHINFO_HITS      'x'        /* 3*nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS     'y'        /* nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS_BM  'b'        /* nCol*nPhrase values */\n\n/*\n** The default value for the second argument to matchinfo(). \n*/\n#define FTS3_MATCHINFO_DEFAULT   \"pcx\"\n\n\n/*\n** Used as an fts3ExprIterate() context when loading phrase doclists to\n** Fts3Expr.aDoclist[]/nDoclist.\n*/\ntypedef struct LoadDoclistCtx LoadDoclistCtx;\nstruct LoadDoclistCtx {\n  Fts3Cursor *pCsr;               /* FTS3 Cursor */\n  int nPhrase;                    /* Number of phrases seen so far */\n  int nToken;                     /* Number of tokens seen so far */\n};\n\n/*\n** The following types are used as part of the implementation of the \n** fts3BestSnippet() routine.\n*/\ntypedef struct SnippetIter SnippetIter;\ntypedef struct SnippetPhrase SnippetPhrase;\ntypedef struct SnippetFragment SnippetFragment;\n\nstruct SnippetIter {\n  Fts3Cursor *pCsr;               /* Cursor snippet is being generated from */\n  int iCol;                       /* Extract snippet from this column */\n  int nSnippet;                   /* Requested snippet length (in tokens) */\n  int nPhrase;                    /* Number of phrases in query */\n  SnippetPhrase *aPhrase;         /* Array of size nPhrase */\n  int iCurrent;                   /* First token of current snippet */\n};\n\nstruct SnippetPhrase {\n  int nToken;                     /* Number of tokens in phrase */\n  char *pList;                    /* Pointer to start of phrase position list */\n  int iHead;                      /* Next value in position list */\n  char *pHead;                    /* Position list data following iHead */\n  int iTail;                      /* Next value in trailing position list */\n  char *pTail;                    /* Position list data following iTail */\n};\n\nstruct SnippetFragment {\n  int iCol;                       /* Column snippet is extracted from */\n  int iPos;                       /* Index of first token in snippet */\n  u64 covered;                    /* Mask of query phrases covered */\n  u64 hlmask;                     /* Mask of snippet terms to highlight */\n};\n\n/*\n** This type is used as an fts3ExprIterate() context object while \n** accumulating the data returned by the matchinfo() function.\n*/\ntypedef struct MatchInfo MatchInfo;\nstruct MatchInfo {\n  Fts3Cursor *pCursor;            /* FTS3 Cursor */\n  int nCol;                       /* Number of columns in table */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  sqlite3_int64 nDoc;             /* Number of docs in database */\n  char flag;\n  u32 *aMatchinfo;                /* Pre-allocated buffer */\n};\n\n/*\n** An instance of this structure is used to manage a pair of buffers, each\n** (nElem * sizeof(u32)) bytes in size. See the MatchinfoBuffer code below\n** for details.\n*/\nstruct MatchinfoBuffer {\n  u8 aRef[3];\n  int nElem;\n  int bGlobal;                    /* Set if global data is loaded */\n  char *zMatchinfo;\n  u32 aMatchinfo[1];\n};\n\n\n/*\n** The snippet() and offsets() functions both return text values. An instance\n** of the following structure is used to accumulate those values while the\n** functions are running. See fts3StringAppend() for details.\n*/\ntypedef struct StrBuffer StrBuffer;\nstruct StrBuffer {\n  char *z;                        /* Pointer to buffer containing string */\n  int n;                          /* Length of z in bytes (excl. nul-term) */\n  int nAlloc;                     /* Allocated size of buffer z in bytes */\n};\n\n\n/*************************************************************************\n** Start of MatchinfoBuffer code.\n*/\n\n/*\n** Allocate a two-slot MatchinfoBuffer object.\n*/\nstatic MatchinfoBuffer *fts3MIBufferNew(int nElem, const char *zMatchinfo){\n  MatchinfoBuffer *pRet;\n  int nByte = sizeof(u32) * (2*nElem + 1) + sizeof(MatchinfoBuffer);\n  int nStr = (int)strlen(zMatchinfo);\n\n  pRet = sqlite3_malloc(nByte + nStr+1);\n  if( pRet ){\n    memset(pRet, 0, nByte);\n    pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet;\n    pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] + sizeof(u32)*(nElem+1);\n    pRet->nElem = nElem;\n    pRet->zMatchinfo = ((char*)pRet) + nByte;\n    memcpy(pRet->zMatchinfo, zMatchinfo, nStr+1);\n    pRet->aRef[0] = 1;\n  }\n\n  return pRet;\n}\n\nstatic void fts3MIBufferFree(void *p){\n  MatchinfoBuffer *pBuf = (MatchinfoBuffer*)((u8*)p - ((u32*)p)[-1]);\n\n  assert( (u32*)p==&pBuf->aMatchinfo[1] \n       || (u32*)p==&pBuf->aMatchinfo[pBuf->nElem+2] \n  );\n  if( (u32*)p==&pBuf->aMatchinfo[1] ){\n    pBuf->aRef[1] = 0;\n  }else{\n    pBuf->aRef[2] = 0;\n  }\n\n  if( pBuf->aRef[0]==0 && pBuf->aRef[1]==0 && pBuf->aRef[2]==0 ){\n    sqlite3_free(pBuf);\n  }\n}\n\nstatic void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){\n  void (*xRet)(void*) = 0;\n  u32 *aOut = 0;\n\n  if( p->aRef[1]==0 ){\n    p->aRef[1] = 1;\n    aOut = &p->aMatchinfo[1];\n    xRet = fts3MIBufferFree;\n  }\n  else if( p->aRef[2]==0 ){\n    p->aRef[2] = 1;\n    aOut = &p->aMatchinfo[p->nElem+2];\n    xRet = fts3MIBufferFree;\n  }else{\n    aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32));\n    if( aOut ){\n      xRet = sqlite3_free;\n      if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));\n    }\n  }\n\n  *paOut = aOut;\n  return xRet;\n}\n\nstatic void fts3MIBufferSetGlobal(MatchinfoBuffer *p){\n  p->bGlobal = 1;\n  memcpy(&p->aMatchinfo[2+p->nElem], &p->aMatchinfo[1], p->nElem*sizeof(u32));\n}\n\n/*\n** Free a MatchinfoBuffer object allocated using fts3MIBufferNew()\n*/\nvoid sqlite3Fts3MIBufferFree(MatchinfoBuffer *p){\n  if( p ){\n    assert( p->aRef[0]==1 );\n    p->aRef[0] = 0;\n    if( p->aRef[0]==0 && p->aRef[1]==0 && p->aRef[2]==0 ){\n      sqlite3_free(p);\n    }\n  }\n}\n\n/* \n** End of MatchinfoBuffer code.\n*************************************************************************/\n\n\n/*\n** This function is used to help iterate through a position-list. A position\n** list is a list of unique integers, sorted from smallest to largest. Each\n** element of the list is represented by an FTS3 varint that takes the value\n** of the difference between the current element and the previous one plus\n** two. For example, to store the position-list:\n**\n**     4 9 113\n**\n** the three varints:\n**\n**     6 7 106\n**\n** are encoded.\n**\n** When this function is called, *pp points to the start of an element of\n** the list. *piPos contains the value of the previous entry in the list.\n** After it returns, *piPos contains the value of the next element of the\n** list and *pp is advanced to the following varint.\n*/\nstatic void fts3GetDeltaPosition(char **pp, int *piPos){\n  int iVal;\n  *pp += fts3GetVarint32(*pp, &iVal);\n  *piPos += (iVal-2);\n}\n\n/*\n** Helper function for fts3ExprIterate() (see below).\n*/\nstatic int fts3ExprIterate2(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int *piPhrase,                  /* Pointer to phrase counter */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int rc;                         /* Return code */\n  int eType = pExpr->eType;     /* Type of expression node pExpr */\n\n  if( eType!=FTSQUERY_PHRASE ){\n    assert( pExpr->pLeft && pExpr->pRight );\n    rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);\n    if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){\n      rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);\n    }\n  }else{\n    rc = x(pExpr, *piPhrase, pCtx);\n    (*piPhrase)++;\n  }\n  return rc;\n}\n\n/*\n** Iterate through all phrase nodes in an FTS3 query, except those that\n** are part of a sub-tree that is the right-hand-side of a NOT operator.\n** For each phrase node found, the supplied callback function is invoked.\n**\n** If the callback function returns anything other than SQLITE_OK, \n** the iteration is abandoned and the error code returned immediately.\n** Otherwise, SQLITE_OK is returned after a callback has been made for\n** all eligible phrase nodes.\n*/\nstatic int fts3ExprIterate(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int iPhrase = 0;                /* Variable used as the phrase counter */\n  return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);\n}\n\n\n/*\n** This is an fts3ExprIterate() callback used while loading the doclists\n** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also\n** fts3ExprLoadDoclists().\n*/\nstatic int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  int rc = SQLITE_OK;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;\n\n  UNUSED_PARAMETER(iPhrase);\n\n  p->nPhrase++;\n  p->nToken += pPhrase->nToken;\n\n  return rc;\n}\n\n/*\n** Load the doclists for each phrase in the query associated with FTS3 cursor\n** pCsr. \n**\n** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable \n** phrases in the expression (all phrases except those directly or \n** indirectly descended from the right-hand-side of a NOT operator). If \n** pnToken is not NULL, then it is set to the number of tokens in all\n** matchable phrases of the expression.\n*/\nstatic int fts3ExprLoadDoclists(\n  Fts3Cursor *pCsr,               /* Fts3 cursor for current query */\n  int *pnPhrase,                  /* OUT: Number of phrases in query */\n  int *pnToken                    /* OUT: Number of tokens in query */\n){\n  int rc;                         /* Return Code */\n  LoadDoclistCtx sCtx = {0,0,0};  /* Context for fts3ExprIterate() */\n  sCtx.pCsr = pCsr;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);\n  if( pnPhrase ) *pnPhrase = sCtx.nPhrase;\n  if( pnToken ) *pnToken = sCtx.nToken;\n  return rc;\n}\n\nstatic int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  (*(int *)ctx)++;\n  pExpr->iPhrase = iPhrase;\n  return SQLITE_OK;\n}\nstatic int fts3ExprPhraseCount(Fts3Expr *pExpr){\n  int nPhrase = 0;\n  (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);\n  return nPhrase;\n}\n\n/*\n** Advance the position list iterator specified by the first two \n** arguments so that it points to the first element with a value greater\n** than or equal to parameter iNext.\n*/\nstatic void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){\n  char *pIter = *ppIter;\n  if( pIter ){\n    int iIter = *piIter;\n\n    while( iIter<iNext ){\n      if( 0==(*pIter & 0xFE) ){\n        iIter = -1;\n        pIter = 0;\n        break;\n      }\n      fts3GetDeltaPosition(&pIter, &iIter);\n    }\n\n    *piIter = iIter;\n    *ppIter = pIter;\n  }\n}\n\n/*\n** Advance the snippet iterator to the next candidate snippet.\n*/\nstatic int fts3SnippetNextCandidate(SnippetIter *pIter){\n  int i;                          /* Loop counter */\n\n  if( pIter->iCurrent<0 ){\n    /* The SnippetIter object has just been initialized. The first snippet\n    ** candidate always starts at offset 0 (even if this candidate has a\n    ** score of 0.0).\n    */\n    pIter->iCurrent = 0;\n\n    /* Advance the 'head' iterator of each phrase to the first offset that\n    ** is greater than or equal to (iNext+nSnippet).\n    */\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, pIter->nSnippet);\n    }\n  }else{\n    int iStart;\n    int iEnd = 0x7FFFFFFF;\n\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      if( pPhrase->pHead && pPhrase->iHead<iEnd ){\n        iEnd = pPhrase->iHead;\n      }\n    }\n    if( iEnd==0x7FFFFFFF ){\n      return 1;\n    }\n\n    pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);\n      fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Retrieve information about the current candidate snippet of snippet \n** iterator pIter.\n*/\nstatic void fts3SnippetDetails(\n  SnippetIter *pIter,             /* Snippet iterator */\n  u64 mCovered,                   /* Bitmask of phrases already covered */\n  int *piToken,                   /* OUT: First token of proposed snippet */\n  int *piScore,                   /* OUT: \"Score\" for this snippet */\n  u64 *pmCover,                   /* OUT: Bitmask of phrases covered */\n  u64 *pmHighlight                /* OUT: Bitmask of terms to highlight */\n){\n  int iStart = pIter->iCurrent;   /* First token of snippet */\n  int iScore = 0;                 /* Score of this snippet */\n  int i;                          /* Loop counter */\n  u64 mCover = 0;                 /* Mask of phrases covered by this snippet */\n  u64 mHighlight = 0;             /* Mask of tokens to highlight in snippet */\n\n  for(i=0; i<pIter->nPhrase; i++){\n    SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n    if( pPhrase->pTail ){\n      char *pCsr = pPhrase->pTail;\n      int iCsr = pPhrase->iTail;\n\n      while( iCsr<(iStart+pIter->nSnippet) ){\n        int j;\n        u64 mPhrase = (u64)1 << i;\n        u64 mPos = (u64)1 << (iCsr - iStart);\n        assert( iCsr>=iStart );\n        if( (mCover|mCovered)&mPhrase ){\n          iScore++;\n        }else{\n          iScore += 1000;\n        }\n        mCover |= mPhrase;\n\n        for(j=0; j<pPhrase->nToken; j++){\n          mHighlight |= (mPos>>j);\n        }\n\n        if( 0==(*pCsr & 0x0FE) ) break;\n        fts3GetDeltaPosition(&pCsr, &iCsr);\n      }\n    }\n  }\n\n  /* Set the output variables before returning. */\n  *piToken = iStart;\n  *piScore = iScore;\n  *pmCover = mCover;\n  *pmHighlight = mHighlight;\n}\n\n/*\n** This function is an fts3ExprIterate() callback used by fts3BestSnippet().\n** Each invocation populates an element of the SnippetIter.aPhrase[] array.\n*/\nstatic int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  SnippetIter *p = (SnippetIter *)ctx;\n  SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];\n  char *pCsr;\n  int rc;\n\n  pPhrase->nToken = pExpr->pPhrase->nToken;\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( pCsr ){\n    int iFirst = 0;\n    pPhrase->pList = pCsr;\n    fts3GetDeltaPosition(&pCsr, &iFirst);\n    assert( iFirst>=0 );\n    pPhrase->pHead = pCsr;\n    pPhrase->pTail = pCsr;\n    pPhrase->iHead = iFirst;\n    pPhrase->iTail = iFirst;\n  }else{\n    assert( rc!=SQLITE_OK || (\n       pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 \n    ));\n  }\n\n  return rc;\n}\n\n/*\n** Select the fragment of text consisting of nFragment contiguous tokens \n** from column iCol that represent the \"best\" snippet. The best snippet\n** is the snippet with the highest score, where scores are calculated\n** by adding:\n**\n**   (a) +1 point for each occurrence of a matchable phrase in the snippet.\n**\n**   (b) +1000 points for the first occurrence of each matchable phrase in \n**       the snippet for which the corresponding mCovered bit is not set.\n**\n** The selected snippet parameters are stored in structure *pFragment before\n** returning. The score of the selected snippet is stored in *piScore\n** before returning.\n*/\nstatic int fts3BestSnippet(\n  int nSnippet,                   /* Desired snippet length */\n  Fts3Cursor *pCsr,               /* Cursor to create snippet for */\n  int iCol,                       /* Index of column to create snippet from */\n  u64 mCovered,                   /* Mask of phrases already covered */\n  u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */\n  SnippetFragment *pFragment,     /* OUT: Best snippet found */\n  int *piScore                    /* OUT: Score of snippet pFragment */\n){\n  int rc;                         /* Return Code */\n  int nList;                      /* Number of phrases in expression */\n  SnippetIter sIter;              /* Iterates through snippet candidates */\n  int nByte;                      /* Number of bytes of space to allocate */\n  int iBestScore = -1;            /* Best snippet score found so far */\n  int i;                          /* Loop counter */\n\n  memset(&sIter, 0, sizeof(sIter));\n\n  /* Iterate through the phrases in the expression to count them. The same\n  ** callback makes sure the doclists are loaded for each phrase.\n  */\n  rc = fts3ExprLoadDoclists(pCsr, &nList, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Now that it is known how many phrases there are, allocate and zero\n  ** the required space using malloc().\n  */\n  nByte = sizeof(SnippetPhrase) * nList;\n  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);\n  if( !sIter.aPhrase ){\n    return SQLITE_NOMEM;\n  }\n  memset(sIter.aPhrase, 0, nByte);\n\n  /* Initialize the contents of the SnippetIter object. Then iterate through\n  ** the set of phrases in the expression to populate the aPhrase[] array.\n  */\n  sIter.pCsr = pCsr;\n  sIter.iCol = iCol;\n  sIter.nSnippet = nSnippet;\n  sIter.nPhrase = nList;\n  sIter.iCurrent = -1;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);\n  if( rc==SQLITE_OK ){\n\n    /* Set the *pmSeen output variable. */\n    for(i=0; i<nList; i++){\n      if( sIter.aPhrase[i].pHead ){\n        *pmSeen |= (u64)1 << i;\n      }\n    }\n\n    /* Loop through all candidate snippets. Store the best snippet in \n     ** *pFragment. Store its associated 'score' in iBestScore.\n     */\n    pFragment->iCol = iCol;\n    while( !fts3SnippetNextCandidate(&sIter) ){\n      int iPos;\n      int iScore;\n      u64 mCover;\n      u64 mHighlite;\n      fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover,&mHighlite);\n      assert( iScore>=0 );\n      if( iScore>iBestScore ){\n        pFragment->iPos = iPos;\n        pFragment->hlmask = mHighlite;\n        pFragment->covered = mCover;\n        iBestScore = iScore;\n      }\n    }\n\n    *piScore = iBestScore;\n  }\n  sqlite3_free(sIter.aPhrase);\n  return rc;\n}\n\n\n/*\n** Append a string to the string-buffer passed as the first argument.\n**\n** If nAppend is negative, then the length of the string zAppend is\n** determined using strlen().\n*/\nstatic int fts3StringAppend(\n  StrBuffer *pStr,                /* Buffer to append to */\n  const char *zAppend,            /* Pointer to data to append to buffer */\n  int nAppend                     /* Size of zAppend in bytes (or -1) */\n){\n  if( nAppend<0 ){\n    nAppend = (int)strlen(zAppend);\n  }\n\n  /* If there is insufficient space allocated at StrBuffer.z, use realloc()\n  ** to grow the buffer until so that it is big enough to accomadate the\n  ** appended data.\n  */\n  if( pStr->n+nAppend+1>=pStr->nAlloc ){\n    int nAlloc = pStr->nAlloc+nAppend+100;\n    char *zNew = sqlite3_realloc(pStr->z, nAlloc);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pStr->z = zNew;\n    pStr->nAlloc = nAlloc;\n  }\n  assert( pStr->z!=0 && (pStr->nAlloc >= pStr->n+nAppend+1) );\n\n  /* Append the data to the string buffer. */\n  memcpy(&pStr->z[pStr->n], zAppend, nAppend);\n  pStr->n += nAppend;\n  pStr->z[pStr->n] = '\\0';\n\n  return SQLITE_OK;\n}\n\n/*\n** The fts3BestSnippet() function often selects snippets that end with a\n** query term. That is, the final term of the snippet is always a term\n** that requires highlighting. For example, if 'X' is a highlighted term\n** and '.' is a non-highlighted term, BestSnippet() may select:\n**\n**     ........X.....X\n**\n** This function \"shifts\" the beginning of the snippet forward in the \n** document so that there are approximately the same number of \n** non-highlighted terms to the right of the final highlighted term as there\n** are to the left of the first highlighted term. For example, to this:\n**\n**     ....X.....X....\n**\n** This is done as part of extracting the snippet text, not when selecting\n** the snippet. Snippet selection is done based on doclists only, so there\n** is no way for fts3BestSnippet() to know whether or not the document \n** actually contains terms that follow the final highlighted term. \n*/\nstatic int fts3SnippetShift(\n  Fts3Table *pTab,                /* FTS3 table snippet comes from */\n  int iLangid,                    /* Language id to use in tokenizing */\n  int nSnippet,                   /* Number of tokens desired for snippet */\n  const char *zDoc,               /* Document text to extract snippet from */\n  int nDoc,                       /* Size of buffer zDoc in bytes */\n  int *piPos,                     /* IN/OUT: First token of snippet */\n  u64 *pHlmask                    /* IN/OUT: Mask of tokens to highlight */\n){\n  u64 hlmask = *pHlmask;          /* Local copy of initial highlight-mask */\n\n  if( hlmask ){\n    int nLeft;                    /* Tokens to the left of first highlight */\n    int nRight;                   /* Tokens to the right of last highlight */\n    int nDesired;                 /* Ideal number of tokens to shift forward */\n\n    for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);\n    for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);\n    nDesired = (nLeft-nRight)/2;\n\n    /* Ideally, the start of the snippet should be pushed forward in the\n    ** document nDesired tokens. This block checks if there are actually\n    ** nDesired tokens to the right of the snippet. If so, *piPos and\n    ** *pHlMask are updated to shift the snippet nDesired tokens to the\n    ** right. Otherwise, the snippet is shifted by the number of tokens\n    ** available.\n    */\n    if( nDesired>0 ){\n      int nShift;                 /* Number of tokens to shift snippet by */\n      int iCurrent = 0;           /* Token counter */\n      int rc;                     /* Return Code */\n      sqlite3_tokenizer_module *pMod;\n      sqlite3_tokenizer_cursor *pC;\n      pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n\n      /* Open a cursor on zDoc/nDoc. Check if there are (nSnippet+nDesired)\n      ** or more tokens in zDoc/nDoc.\n      */\n      rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){\n        const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;\n        rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);\n      }\n      pMod->xClose(pC);\n      if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }\n\n      nShift = (rc==SQLITE_DONE)+iCurrent-nSnippet;\n      assert( nShift<=nDesired );\n      if( nShift>0 ){\n        *piPos += nShift;\n        *pHlmask = hlmask >> nShift;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Extract the snippet text for fragment pFragment from cursor pCsr and\n** append it to string buffer pOut.\n*/\nstatic int fts3SnippetText(\n  Fts3Cursor *pCsr,               /* FTS3 Cursor */\n  SnippetFragment *pFragment,     /* Snippet to extract */\n  int iFragment,                  /* Fragment number */\n  int isLast,                     /* True for final fragment in snippet */\n  int nSnippet,                   /* Number of tokens in extracted snippet */\n  const char *zOpen,              /* String inserted before highlighted term */\n  const char *zClose,             /* String inserted after highlighted term */\n  const char *zEllipsis,          /* String inserted between snippets */\n  StrBuffer *pOut                 /* Write output here */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc;                         /* Return code */\n  const char *zDoc;               /* Document text to extract snippet from */\n  int nDoc;                       /* Size of zDoc in bytes */\n  int iCurrent = 0;               /* Current token number of document */\n  int iEnd = 0;                   /* Byte offset of end of current token */\n  int isShiftDone = 0;            /* True after snippet is shifted */\n  int iPos = pFragment->iPos;     /* First token of snippet */\n  u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */\n  int iCol = pFragment->iCol+1;   /* Query column to extract text from */\n  sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */\n  sqlite3_tokenizer_cursor *pC;   /* Tokenizer cursor open on zDoc/nDoc */\n  \n  zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);\n  if( zDoc==0 ){\n    if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n    return SQLITE_OK;\n  }\n  nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol);\n\n  /* Open a token cursor on the document. */\n  pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n  rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid, zDoc,nDoc,&pC);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  while( rc==SQLITE_OK ){\n    const char *ZDUMMY;           /* Dummy argument used with tokenizer */\n    int DUMMY1 = -1;              /* Dummy argument used with tokenizer */\n    int iBegin = 0;               /* Offset in zDoc of start of token */\n    int iFin = 0;                 /* Offset in zDoc of end of token */\n    int isHighlight = 0;          /* True for highlighted terms */\n\n    /* Variable DUMMY1 is initialized to a negative value above. Elsewhere\n    ** in the FTS code the variable that the third argument to xNext points to\n    ** is initialized to zero before the first (*but not necessarily\n    ** subsequent*) call to xNext(). This is done for a particular application\n    ** that needs to know whether or not the tokenizer is being used for\n    ** snippet generation or for some other purpose.\n    **\n    ** Extreme care is required when writing code to depend on this\n    ** initialization. It is not a documented part of the tokenizer interface.\n    ** If a tokenizer is used directly by any code outside of FTS, this\n    ** convention might not be respected.  */\n    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);\n    if( rc!=SQLITE_OK ){\n      if( rc==SQLITE_DONE ){\n        /* Special case - the last token of the snippet is also the last token\n        ** of the column. Append any punctuation that occurred between the end\n        ** of the previous token and the end of the document to the output. \n        ** Then break out of the loop. */\n        rc = fts3StringAppend(pOut, &zDoc[iEnd], -1);\n      }\n      break;\n    }\n    if( iCurrent<iPos ){ continue; }\n\n    if( !isShiftDone ){\n      int n = nDoc - iBegin;\n      rc = fts3SnippetShift(\n          pTab, pCsr->iLangid, nSnippet, &zDoc[iBegin], n, &iPos, &hlmask\n      );\n      isShiftDone = 1;\n\n      /* Now that the shift has been done, check if the initial \"...\" are\n      ** required. They are required if (a) this is not the first fragment,\n      ** or (b) this fragment does not begin at position 0 of its column. \n      */\n      if( rc==SQLITE_OK ){\n        if( iPos>0 || iFragment>0 ){\n          rc = fts3StringAppend(pOut, zEllipsis, -1);\n        }else if( iBegin ){\n          rc = fts3StringAppend(pOut, zDoc, iBegin);\n        }\n      }\n      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;\n    }\n\n    if( iCurrent>=(iPos+nSnippet) ){\n      if( isLast ){\n        rc = fts3StringAppend(pOut, zEllipsis, -1);\n      }\n      break;\n    }\n\n    /* Set isHighlight to true if this term should be highlighted. */\n    isHighlight = (hlmask & ((u64)1 << (iCurrent-iPos)))!=0;\n\n    if( iCurrent>iPos ) rc = fts3StringAppend(pOut, &zDoc[iEnd], iBegin-iEnd);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zOpen, -1);\n    if( rc==SQLITE_OK ) rc = fts3StringAppend(pOut, &zDoc[iBegin], iFin-iBegin);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zClose, -1);\n\n    iEnd = iFin;\n  }\n\n  pMod->xClose(pC);\n  return rc;\n}\n\n\n/*\n** This function is used to count the entries in a column-list (a \n** delta-encoded list of term offsets within a single column of a single \n** row). When this function is called, *ppCollist should point to the\n** beginning of the first varint in the column-list (the varint that\n** contains the position of the first matching term in the column data).\n** Before returning, *ppCollist is set to point to the first byte after\n** the last varint in the column-list (either the 0x00 signifying the end\n** of the position-list, or the 0x01 that precedes the column number of\n** the next column in the position-list).\n**\n** The number of elements in the column-list is returned.\n*/\nstatic int fts3ColumnlistCount(char **ppCollist){\n  char *pEnd = *ppCollist;\n  char c = 0;\n  int nEntry = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00. */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    if( !c ) nEntry++;\n  }\n\n  *ppCollist = pEnd;\n  return nEntry;\n}\n\n/*\n** This function gathers 'y' or 'b' data for a single phrase.\n*/\nstatic void fts3ExprLHits(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  MatchInfo *p                    /* Matchinfo context */\n){\n  Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;\n  int iStart;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  char *pIter = pPhrase->doclist.pList;\n  int iCol = 0;\n\n  assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS );\n  if( p->flag==FTS3_MATCHINFO_LHITS ){\n    iStart = pExpr->iPhrase * p->nCol;\n  }else{\n    iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);\n  }\n\n  while( 1 ){\n    int nHit = fts3ColumnlistCount(&pIter);\n    if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){\n      if( p->flag==FTS3_MATCHINFO_LHITS ){\n        p->aMatchinfo[iStart + iCol] = (u32)nHit;\n      }else if( nHit ){\n        p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));\n      }\n    }\n    assert( *pIter==0x00 || *pIter==0x01 );\n    if( *pIter!=0x01 ) break;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iCol);\n  }\n}\n\n/*\n** Gather the results for matchinfo directives 'y' and 'b'.\n*/\nstatic void fts3ExprLHitGather(\n  Fts3Expr *pExpr,\n  MatchInfo *p\n){\n  assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );\n  if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){\n    if( pExpr->pLeft ){\n      fts3ExprLHitGather(pExpr->pLeft, p);\n      fts3ExprLHitGather(pExpr->pRight, p);\n    }else{\n      fts3ExprLHits(pExpr, p);\n    }\n  }\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"global\" matchinfo stats\n** for a single query. \n**\n** fts3ExprIterate() callback to load the 'global' elements of a\n** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements \n** of the matchinfo array that are constant for all rows returned by the \n** current query.\n**\n** Argument pCtx is actually a pointer to a struct of type MatchInfo. This\n** function populates Matchinfo.aMatchinfo[] as follows:\n**\n**   for(iCol=0; iCol<nCol; iCol++){\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 1] = X;\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 2] = Y;\n**   }\n**\n** where X is the number of matches for phrase iPhrase is column iCol of all\n** rows of the table. Y is the number of rows for which column iCol contains\n** at least one instance of phrase iPhrase.\n**\n** If the phrase pExpr consists entirely of deferred tokens, then all X and\n** Y values are set to nDoc, where nDoc is the number of documents in the \n** file system. This is done because the full-text index doclist is required\n** to calculate these values properly, and the full-text index doclist is\n** not available for deferred tokens.\n*/\nstatic int fts3ExprGlobalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  MatchInfo *p = (MatchInfo *)pCtx;\n  return sqlite3Fts3EvalPhraseStats(\n      p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]\n  );\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"local\" part of the\n** FTS3_MATCHINFO_HITS array. The local stats are those elements of the \n** array that are different for each row returned by the query.\n*/\nstatic int fts3ExprLocalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  int rc = SQLITE_OK;\n  MatchInfo *p = (MatchInfo *)pCtx;\n  int iStart = iPhrase * p->nCol * 3;\n  int i;\n\n  for(i=0; i<p->nCol && rc==SQLITE_OK; i++){\n    char *pCsr;\n    rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);\n    if( pCsr ){\n      p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);\n    }else{\n      p->aMatchinfo[iStart+i*3] = 0;\n    }\n  }\n\n  return rc;\n}\n\nstatic int fts3MatchinfoCheck(\n  Fts3Table *pTab, \n  char cArg,\n  char **pzErr\n){\n  if( (cArg==FTS3_MATCHINFO_NPHRASE)\n   || (cArg==FTS3_MATCHINFO_NCOL)\n   || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)\n   || (cArg==FTS3_MATCHINFO_LCS)\n   || (cArg==FTS3_MATCHINFO_HITS)\n   || (cArg==FTS3_MATCHINFO_LHITS)\n   || (cArg==FTS3_MATCHINFO_LHITS_BM)\n  ){\n    return SQLITE_OK;\n  }\n  sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo request: %c\", cArg);\n  return SQLITE_ERROR;\n}\n\nstatic int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){\n  int nVal;                       /* Number of integers output by cArg */\n\n  switch( cArg ){\n    case FTS3_MATCHINFO_NDOC:\n    case FTS3_MATCHINFO_NPHRASE: \n    case FTS3_MATCHINFO_NCOL: \n      nVal = 1;\n      break;\n\n    case FTS3_MATCHINFO_AVGLENGTH:\n    case FTS3_MATCHINFO_LENGTH:\n    case FTS3_MATCHINFO_LCS:\n      nVal = pInfo->nCol;\n      break;\n\n    case FTS3_MATCHINFO_LHITS:\n      nVal = pInfo->nCol * pInfo->nPhrase;\n      break;\n\n    case FTS3_MATCHINFO_LHITS_BM:\n      nVal = pInfo->nPhrase * ((pInfo->nCol + 31) / 32);\n      break;\n\n    default:\n      assert( cArg==FTS3_MATCHINFO_HITS );\n      nVal = pInfo->nCol * pInfo->nPhrase * 3;\n      break;\n  }\n\n  return nVal;\n}\n\nstatic int fts3MatchinfoSelectDoctotal(\n  Fts3Table *pTab,\n  sqlite3_stmt **ppStmt,\n  sqlite3_int64 *pnDoc,\n  const char **paLen\n){\n  sqlite3_stmt *pStmt;\n  const char *a;\n  sqlite3_int64 nDoc;\n\n  if( !*ppStmt ){\n    int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  pStmt = *ppStmt;\n  assert( sqlite3_data_count(pStmt)==1 );\n\n  a = sqlite3_column_blob(pStmt, 0);\n  a += sqlite3Fts3GetVarint(a, &nDoc);\n  if( nDoc==0 ) return FTS_CORRUPT_VTAB;\n  *pnDoc = (u32)nDoc;\n\n  if( paLen ) *paLen = a;\n  return SQLITE_OK;\n}\n\n/*\n** An instance of the following structure is used to store state while \n** iterating through a multi-column position-list corresponding to the\n** hits for a single phrase on a single row in order to calculate the\n** values for a matchinfo() FTS3_MATCHINFO_LCS request.\n*/\ntypedef struct LcsIterator LcsIterator;\nstruct LcsIterator {\n  Fts3Expr *pExpr;                /* Pointer to phrase expression */\n  int iPosOffset;                 /* Tokens count up to end of this phrase */\n  char *pRead;                    /* Cursor used to iterate through aDoclist */\n  int iPos;                       /* Current position */\n};\n\n/* \n** If LcsIterator.iCol is set to the following value, the iterator has\n** finished iterating through all offsets for all columns.\n*/\n#define LCS_ITERATOR_FINISHED 0x7FFFFFFF;\n\nstatic int fts3MatchinfoLcsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  LcsIterator *aIter = (LcsIterator *)pCtx;\n  aIter[iPhrase].pExpr = pExpr;\n  return SQLITE_OK;\n}\n\n/*\n** Advance the iterator passed as an argument to the next position. Return\n** 1 if the iterator is at EOF or if it now points to the start of the\n** position list for the next column.\n*/\nstatic int fts3LcsIteratorAdvance(LcsIterator *pIter){\n  char *pRead = pIter->pRead;\n  sqlite3_int64 iRead;\n  int rc = 0;\n\n  pRead += sqlite3Fts3GetVarint(pRead, &iRead);\n  if( iRead==0 || iRead==1 ){\n    pRead = 0;\n    rc = 1;\n  }else{\n    pIter->iPos += (int)(iRead-2);\n  }\n\n  pIter->pRead = pRead;\n  return rc;\n}\n  \n/*\n** This function implements the FTS3_MATCHINFO_LCS matchinfo() flag. \n**\n** If the call is successful, the longest-common-substring lengths for each\n** column are written into the first nCol elements of the pInfo->aMatchinfo[] \n** array before returning. SQLITE_OK is returned in this case.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and the\n** data written to the first nCol elements of pInfo->aMatchinfo[] is \n** undefined.\n*/\nstatic int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){\n  LcsIterator *aIter;\n  int i;\n  int iCol;\n  int nToken = 0;\n\n  /* Allocate and populate the array of LcsIterator objects. The array\n  ** contains one element for each matchable phrase in the query.\n  **/\n  aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);\n  if( !aIter ) return SQLITE_NOMEM;\n  memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);\n  (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);\n\n  for(i=0; i<pInfo->nPhrase; i++){\n    LcsIterator *pIter = &aIter[i];\n    nToken -= pIter->pExpr->pPhrase->nToken;\n    pIter->iPosOffset = nToken;\n  }\n\n  for(iCol=0; iCol<pInfo->nCol; iCol++){\n    int nLcs = 0;                 /* LCS value for this column */\n    int nLive = 0;                /* Number of iterators in aIter not at EOF */\n\n    for(i=0; i<pInfo->nPhrase; i++){\n      int rc;\n      LcsIterator *pIt = &aIter[i];\n      rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);\n      if( rc!=SQLITE_OK ) return rc;\n      if( pIt->pRead ){\n        pIt->iPos = pIt->iPosOffset;\n        fts3LcsIteratorAdvance(&aIter[i]);\n        nLive++;\n      }\n    }\n\n    while( nLive>0 ){\n      LcsIterator *pAdv = 0;      /* The iterator to advance by one position */\n      int nThisLcs = 0;           /* LCS for the current iterator positions */\n\n      for(i=0; i<pInfo->nPhrase; i++){\n        LcsIterator *pIter = &aIter[i];\n        if( pIter->pRead==0 ){\n          /* This iterator is already at EOF for this column. */\n          nThisLcs = 0;\n        }else{\n          if( pAdv==0 || pIter->iPos<pAdv->iPos ){\n            pAdv = pIter;\n          }\n          if( nThisLcs==0 || pIter->iPos==pIter[-1].iPos ){\n            nThisLcs++;\n          }else{\n            nThisLcs = 1;\n          }\n          if( nThisLcs>nLcs ) nLcs = nThisLcs;\n        }\n      }\n      if( fts3LcsIteratorAdvance(pAdv) ) nLive--;\n    }\n\n    pInfo->aMatchinfo[iCol] = nLcs;\n  }\n\n  sqlite3_free(aIter);\n  return SQLITE_OK;\n}\n\n/*\n** Populate the buffer pInfo->aMatchinfo[] with an array of integers to\n** be returned by the matchinfo() function. Argument zArg contains the \n** format string passed as the second argument to matchinfo (or the\n** default value \"pcx\" if no second argument was specified). The format\n** string has already been validated and the pInfo->aMatchinfo[] array\n** is guaranteed to be large enough for the output.\n**\n** If bGlobal is true, then populate all fields of the matchinfo() output.\n** If it is false, then assume that those fields that do not change between\n** rows (i.e. FTS3_MATCHINFO_NPHRASE, NCOL, NDOC, AVGLENGTH and part of HITS)\n** have already been populated.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error \n** occurs. If a value other than SQLITE_OK is returned, the state the\n** pInfo->aMatchinfo[] buffer is left in is undefined.\n*/\nstatic int fts3MatchinfoValues(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  int bGlobal,                    /* True to grab the global stats */\n  MatchInfo *pInfo,               /* Matchinfo context object */\n  const char *zArg                /* Matchinfo format string */\n){\n  int rc = SQLITE_OK;\n  int i;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_stmt *pSelect = 0;\n\n  for(i=0; rc==SQLITE_OK && zArg[i]; i++){\n    pInfo->flag = zArg[i];\n    switch( zArg[i] ){\n      case FTS3_MATCHINFO_NPHRASE:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nPhrase;\n        break;\n\n      case FTS3_MATCHINFO_NCOL:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;\n        break;\n        \n      case FTS3_MATCHINFO_NDOC:\n        if( bGlobal ){\n          sqlite3_int64 nDoc = 0;\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);\n          pInfo->aMatchinfo[0] = (u32)nDoc;\n        }\n        break;\n\n      case FTS3_MATCHINFO_AVGLENGTH: \n        if( bGlobal ){\n          sqlite3_int64 nDoc;     /* Number of rows in table */\n          const char *a;          /* Aggregate column length array */\n\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);\n          if( rc==SQLITE_OK ){\n            int iCol;\n            for(iCol=0; iCol<pInfo->nCol; iCol++){\n              u32 iVal;\n              sqlite3_int64 nToken;\n              a += sqlite3Fts3GetVarint(a, &nToken);\n              iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);\n              pInfo->aMatchinfo[iCol] = iVal;\n            }\n          }\n        }\n        break;\n\n      case FTS3_MATCHINFO_LENGTH: {\n        sqlite3_stmt *pSelectDocsize = 0;\n        rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);\n        if( rc==SQLITE_OK ){\n          int iCol;\n          const char *a = sqlite3_column_blob(pSelectDocsize, 0);\n          for(iCol=0; iCol<pInfo->nCol; iCol++){\n            sqlite3_int64 nToken;\n            a += sqlite3Fts3GetVarint(a, &nToken);\n            pInfo->aMatchinfo[iCol] = (u32)nToken;\n          }\n        }\n        sqlite3_reset(pSelectDocsize);\n        break;\n      }\n\n      case FTS3_MATCHINFO_LCS:\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc==SQLITE_OK ){\n          rc = fts3MatchinfoLcs(pCsr, pInfo);\n        }\n        break;\n\n      case FTS3_MATCHINFO_LHITS_BM:\n      case FTS3_MATCHINFO_LHITS: {\n        int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);\n        memset(pInfo->aMatchinfo, 0, nZero);\n        fts3ExprLHitGather(pCsr->pExpr, pInfo);\n        break;\n      }\n\n      default: {\n        Fts3Expr *pExpr;\n        assert( zArg[i]==FTS3_MATCHINFO_HITS );\n        pExpr = pCsr->pExpr;\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( bGlobal ){\n          if( pCsr->pDeferred ){\n            rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);\n            if( rc!=SQLITE_OK ) break;\n          }\n          rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);\n          sqlite3Fts3EvalTestDeferred(pCsr, &rc);\n          if( rc!=SQLITE_OK ) break;\n        }\n        (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);\n        break;\n      }\n    }\n\n    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);\n  }\n\n  sqlite3_reset(pSelect);\n  return rc;\n}\n\n\n/*\n** Populate pCsr->aMatchinfo[] with data for the current row. The \n** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).\n*/\nstatic void fts3GetMatchinfo(\n  sqlite3_context *pCtx,        /* Return results here */\n  Fts3Cursor *pCsr,               /* FTS3 Cursor object */\n  const char *zArg                /* Second argument to matchinfo() function */\n){\n  MatchInfo sInfo;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int bGlobal = 0;                /* Collect 'global' stats as well as local */\n\n  u32 *aOut = 0;\n  void (*xDestroyOut)(void*) = 0;\n\n  memset(&sInfo, 0, sizeof(MatchInfo));\n  sInfo.pCursor = pCsr;\n  sInfo.nCol = pTab->nColumn;\n\n  /* If there is cached matchinfo() data, but the format string for the \n  ** cache does not match the format string for this request, discard \n  ** the cached data. */\n  if( pCsr->pMIBuffer && strcmp(pCsr->pMIBuffer->zMatchinfo, zArg) ){\n    sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n    pCsr->pMIBuffer = 0;\n  }\n\n  /* If Fts3Cursor.pMIBuffer is NULL, then this is the first time the\n  ** matchinfo function has been called for this query. In this case \n  ** allocate the array used to accumulate the matchinfo data and\n  ** initialize those elements that are constant for every row.\n  */\n  if( pCsr->pMIBuffer==0 ){\n    int nMatchinfo = 0;           /* Number of u32 elements in match-info */\n    int i;                        /* Used to iterate through zArg */\n\n    /* Determine the number of phrases in the query */\n    pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);\n    sInfo.nPhrase = pCsr->nPhrase;\n\n    /* Determine the number of integers in the buffer returned by this call. */\n    for(i=0; zArg[i]; i++){\n      char *zErr = 0;\n      if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){\n        sqlite3_result_error(pCtx, zErr, -1);\n        sqlite3_free(zErr);\n        return;\n      }\n      nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);\n    }\n\n    /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */\n    pCsr->pMIBuffer = fts3MIBufferNew(nMatchinfo, zArg);\n    if( !pCsr->pMIBuffer ) rc = SQLITE_NOMEM;\n\n    pCsr->isMatchinfoNeeded = 1;\n    bGlobal = 1;\n  }\n\n  if( rc==SQLITE_OK ){\n    xDestroyOut = fts3MIBufferAlloc(pCsr->pMIBuffer, &aOut);\n    if( xDestroyOut==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sInfo.aMatchinfo = aOut;\n    sInfo.nPhrase = pCsr->nPhrase;\n    rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg);\n    if( bGlobal ){\n      fts3MIBufferSetGlobal(pCsr->pMIBuffer);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    if( xDestroyOut ) xDestroyOut(aOut);\n  }else{\n    int n = pCsr->pMIBuffer->nElem * sizeof(u32);\n    sqlite3_result_blob(pCtx, aOut, n, xDestroyOut);\n  }\n}\n\n/*\n** Implementation of snippet() function.\n*/\nvoid sqlite3Fts3Snippet(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr,               /* Cursor object */\n  const char *zStart,             /* Snippet start text - \"<b>\" */\n  const char *zEnd,               /* Snippet end text - \"</b>\" */\n  const char *zEllipsis,          /* Snippet ellipsis text - \"<b>...</b>\" */\n  int iCol,                       /* Extract snippet from this column */\n  int nToken                      /* Approximate number of tokens in snippet */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int i;\n  StrBuffer res = {0, 0, 0};\n\n  /* The returned text includes up to four fragments of text extracted from\n  ** the data in the current row. The first iteration of the for(...) loop\n  ** below attempts to locate a single fragment of text nToken tokens in \n  ** size that contains at least one instance of all phrases in the query\n  ** expression that appear in the current row. If such a fragment of text\n  ** cannot be found, the second iteration of the loop attempts to locate\n  ** a pair of fragments, and so on.\n  */\n  int nSnippet = 0;               /* Number of fragments in this snippet */\n  SnippetFragment aSnippet[4];    /* Maximum of 4 fragments per snippet */\n  int nFToken = -1;               /* Number of tokens in each fragment */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(nSnippet=1; 1; nSnippet++){\n\n    int iSnip;                    /* Loop counter 0..nSnippet-1 */\n    u64 mCovered = 0;             /* Bitmask of phrases covered by snippet */\n    u64 mSeen = 0;                /* Bitmask of phrases seen by BestSnippet() */\n\n    if( nToken>=0 ){\n      nFToken = (nToken+nSnippet-1) / nSnippet;\n    }else{\n      nFToken = -1 * nToken;\n    }\n\n    for(iSnip=0; iSnip<nSnippet; iSnip++){\n      int iBestScore = -1;        /* Best score of columns checked so far */\n      int iRead;                  /* Used to iterate through columns */\n      SnippetFragment *pFragment = &aSnippet[iSnip];\n\n      memset(pFragment, 0, sizeof(*pFragment));\n\n      /* Loop through all columns of the table being considered for snippets.\n      ** If the iCol argument to this function was negative, this means all\n      ** columns of the FTS3 table. Otherwise, only column iCol is considered.\n      */\n      for(iRead=0; iRead<pTab->nColumn; iRead++){\n        SnippetFragment sF = {0, 0, 0, 0};\n        int iS = 0;\n        if( iCol>=0 && iRead!=iCol ) continue;\n\n        /* Find the best snippet of nFToken tokens in column iRead. */\n        rc = fts3BestSnippet(nFToken, pCsr, iRead, mCovered, &mSeen, &sF, &iS);\n        if( rc!=SQLITE_OK ){\n          goto snippet_out;\n        }\n        if( iS>iBestScore ){\n          *pFragment = sF;\n          iBestScore = iS;\n        }\n      }\n\n      mCovered |= pFragment->covered;\n    }\n\n    /* If all query phrases seen by fts3BestSnippet() are present in at least\n    ** one of the nSnippet snippet fragments, break out of the loop.\n    */\n    assert( (mCovered&mSeen)==mCovered );\n    if( mSeen==mCovered || nSnippet==SizeofArray(aSnippet) ) break;\n  }\n\n  assert( nFToken>0 );\n\n  for(i=0; i<nSnippet && rc==SQLITE_OK; i++){\n    rc = fts3SnippetText(pCsr, &aSnippet[i], \n        i, (i==nSnippet-1), nFToken, zStart, zEnd, zEllipsis, &res\n    );\n  }\n\n snippet_out:\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, -1, sqlite3_free);\n  }\n}\n\n\ntypedef struct TermOffset TermOffset;\ntypedef struct TermOffsetCtx TermOffsetCtx;\n\nstruct TermOffset {\n  char *pList;                    /* Position-list */\n  int iPos;                       /* Position just read from pList */\n  int iOff;                       /* Offset of this term from read positions */\n};\n\nstruct TermOffsetCtx {\n  Fts3Cursor *pCsr;\n  int iCol;                       /* Column of table to populate aTerm for */\n  int iTerm;\n  sqlite3_int64 iDocid;\n  TermOffset *aTerm;\n};\n\n/*\n** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().\n*/\nstatic int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  TermOffsetCtx *p = (TermOffsetCtx *)ctx;\n  int nTerm;                      /* Number of tokens in phrase */\n  int iTerm;                      /* For looping through nTerm phrase terms */\n  char *pList;                    /* Pointer to position list for phrase */\n  int iPos = 0;                   /* First position in position-list */\n  int rc;\n\n  UNUSED_PARAMETER(iPhrase);\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);\n  nTerm = pExpr->pPhrase->nToken;\n  if( pList ){\n    fts3GetDeltaPosition(&pList, &iPos);\n    assert( iPos>=0 );\n  }\n\n  for(iTerm=0; iTerm<nTerm; iTerm++){\n    TermOffset *pT = &p->aTerm[p->iTerm++];\n    pT->iOff = nTerm-iTerm-1;\n    pT->pList = pList;\n    pT->iPos = iPos;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of offsets() function.\n*/\nvoid sqlite3Fts3Offsets(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr                /* Cursor object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;\n  int rc;                         /* Return Code */\n  int nToken;                     /* Number of tokens in query */\n  int iCol;                       /* Column currently being processed */\n  StrBuffer res = {0, 0, 0};      /* Result string */\n  TermOffsetCtx sCtx;             /* Context for fts3ExprTermOffsetInit() */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  memset(&sCtx, 0, sizeof(sCtx));\n  assert( pCsr->isRequireSeek==0 );\n\n  /* Count the number of terms in the query */\n  rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);\n  if( rc!=SQLITE_OK ) goto offsets_out;\n\n  /* Allocate the array of TermOffset iterators. */\n  sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);\n  if( 0==sCtx.aTerm ){\n    rc = SQLITE_NOMEM;\n    goto offsets_out;\n  }\n  sCtx.iDocid = pCsr->iPrevId;\n  sCtx.pCsr = pCsr;\n\n  /* Loop through the table columns, appending offset information to \n  ** string-buffer res for each column.\n  */\n  for(iCol=0; iCol<pTab->nColumn; iCol++){\n    sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */\n    const char *ZDUMMY;           /* Dummy argument used with xNext() */\n    int NDUMMY = 0;               /* Dummy argument used with xNext() */\n    int iStart = 0;\n    int iEnd = 0;\n    int iCurrent = 0;\n    const char *zDoc;\n    int nDoc;\n\n    /* Initialize the contents of sCtx.aTerm[] for column iCol. There is \n    ** no way that this operation can fail, so the return code from\n    ** fts3ExprIterate() can be discarded.\n    */\n    sCtx.iCol = iCol;\n    sCtx.iTerm = 0;\n    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);\n\n    /* Retreive the text stored in column iCol. If an SQL NULL is stored \n    ** in column iCol, jump immediately to the next iteration of the loop.\n    ** If an OOM occurs while retrieving the data (this can happen if SQLite\n    ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM \n    ** to the caller. \n    */\n    zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    if( zDoc==0 ){\n      if( sqlite3_column_type(pCsr->pStmt, iCol+1)==SQLITE_NULL ){\n        continue;\n      }\n      rc = SQLITE_NOMEM;\n      goto offsets_out;\n    }\n\n    /* Initialize a tokenizer iterator to iterate through column iCol. */\n    rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid,\n        zDoc, nDoc, &pC\n    );\n    if( rc!=SQLITE_OK ) goto offsets_out;\n\n    rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n    while( rc==SQLITE_OK ){\n      int i;                      /* Used to loop through terms */\n      int iMinPos = 0x7FFFFFFF;   /* Position of next token */\n      TermOffset *pTerm = 0;      /* TermOffset associated with next token */\n\n      for(i=0; i<nToken; i++){\n        TermOffset *pT = &sCtx.aTerm[i];\n        if( pT->pList && (pT->iPos-pT->iOff)<iMinPos ){\n          iMinPos = pT->iPos-pT->iOff;\n          pTerm = pT;\n        }\n      }\n\n      if( !pTerm ){\n        /* All offsets for this column have been gathered. */\n        rc = SQLITE_DONE;\n      }else{\n        assert( iCurrent<=iMinPos );\n        if( 0==(0xFE&*pTerm->pList) ){\n          pTerm->pList = 0;\n        }else{\n          fts3GetDeltaPosition(&pTerm->pList, &pTerm->iPos);\n        }\n        while( rc==SQLITE_OK && iCurrent<iMinPos ){\n          rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n        }\n        if( rc==SQLITE_OK ){\n          char aBuffer[64];\n          sqlite3_snprintf(sizeof(aBuffer), aBuffer, \n              \"%d %d %d %d \", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart\n          );\n          rc = fts3StringAppend(&res, aBuffer, -1);\n        }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){\n          rc = FTS_CORRUPT_VTAB;\n        }\n      }\n    }\n    if( rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pMod->xClose(pC);\n    if( rc!=SQLITE_OK ) goto offsets_out;\n  }\n\n offsets_out:\n  sqlite3_free(sCtx.aTerm);\n  assert( rc!=SQLITE_DONE );\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx,  rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, res.n-1, sqlite3_free);\n  }\n  return;\n}\n\n/*\n** Implementation of matchinfo() function.\n*/\nvoid sqlite3Fts3Matchinfo(\n  sqlite3_context *pContext,      /* Function call context */\n  Fts3Cursor *pCsr,               /* FTS3 table cursor */\n  const char *zArg                /* Second arg to matchinfo() function */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  const char *zFormat;\n\n  if( zArg ){\n    zFormat = zArg;\n  }else{\n    zFormat = FTS3_MATCHINFO_DEFAULT;\n  }\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_blob(pContext, \"\", 0, SQLITE_STATIC);\n    return;\n  }else{\n    /* Retrieve matchinfo() data. */\n    fts3GetMatchinfo(pContext, pCsr, zFormat);\n    sqlite3Fts3SegmentsClose(pTab);\n  }\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_term.c",
    "content": "/*\n** 2011 Jan 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is not part of the production FTS code. It is only used for\n** testing. It contains a virtual table implementation that provides direct \n** access to the full-text index of an FTS table. \n*/\n\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n#ifdef SQLITE_TEST\n\n#include <string.h>\n#include <assert.h>\n#include <stdlib.h>\n\ntypedef struct Fts3termTable Fts3termTable;\ntypedef struct Fts3termCursor Fts3termCursor;\n\nstruct Fts3termTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  int iIndex;                     /* Index for Fts3Table.aIndex[] */\n  Fts3Table *pFts3Tab;\n};\n\nstruct Fts3termCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts3MultiSegReader csr;        /* Must be right after \"base\" */\n  Fts3SegFilter filter;\n\n  int isEof;                      /* True if cursor is at EOF */\n  char *pNext;\n\n  sqlite3_int64 iRowid;           /* Current 'rowid' value */\n  sqlite3_int64 iDocid;           /* Current 'docid' value */\n  int iCol;                       /* Current 'col' value */\n  int iPos;                       /* Current 'pos' value */\n};\n\n/*\n** Schema of the terms table.\n*/\n#define FTS3_TERMS_SCHEMA \"CREATE TABLE x(term, docid, col, pos)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n*/\nstatic int fts3termConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pCtx,                     /* Non-zero for an fts4prefix table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  char const *zDb;                /* Name of database (e.g. \"main\") */\n  char const *zFts3;              /* Name of fts3 table */\n  int nDb;                        /* Result of strlen(zDb) */\n  int nFts3;                      /* Result of strlen(zFts3) */\n  int nByte;                      /* Bytes of space to allocate here */\n  int rc;                         /* value returned by declare_vtab() */\n  Fts3termTable *p;                /* Virtual table object to return */\n  int iIndex = 0;\n\n  UNUSED_PARAMETER(pCtx);\n  if( argc==5 ){\n    iIndex = atoi(argv[4]);\n    argc--;\n  }\n\n  /* The user should specify a single argument - the name of an fts3 table. */\n  if( argc!=4 ){\n    sqlite3Fts3ErrMsg(pzErr,\n        \"wrong number of arguments to fts4term constructor\"\n    );\n    return SQLITE_ERROR;\n  }\n\n  zDb = argv[1]; \n  nDb = (int)strlen(zDb);\n  zFts3 = argv[3];\n  nFts3 = (int)strlen(zFts3);\n\n  rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = sizeof(Fts3termTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;\n  p = (Fts3termTable *)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFts3Tab = (Fts3Table *)&p[1];\n  p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];\n  p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];\n  p->pFts3Tab->db = db;\n  p->pFts3Tab->nIndex = iIndex+1;\n  p->iIndex = iIndex;\n\n  memcpy((char *)p->pFts3Tab->zDb, zDb, nDb);\n  memcpy((char *)p->pFts3Tab->zName, zFts3, nFts3);\n  sqlite3Fts3Dequote((char *)p->pFts3Tab->zName);\n\n  *ppVtab = (sqlite3_vtab *)p;\n  return SQLITE_OK;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3termDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3termTable *p = (Fts3termTable *)pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int i;\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(pFts3->aStmt); i++){\n    sqlite3_finalize(pFts3->aStmt[i]);\n  }\n  sqlite3_free(pFts3->zSegmentsTbl);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n#define FTS4AUX_EQ_CONSTRAINT 1\n#define FTS4AUX_GE_CONSTRAINT 2\n#define FTS4AUX_LE_CONSTRAINT 4\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3termBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  UNUSED_PARAMETER(pVTab);\n\n  /* This vtab naturally does \"ORDER BY term, docid, col, pos\".  */\n  if( pInfo->nOrderBy ){\n    int i;\n    for(i=0; i<pInfo->nOrderBy; i++){\n      if( pInfo->aOrderBy[i].iColumn!=i || pInfo->aOrderBy[i].desc ) break;\n    }\n    if( i==pInfo->nOrderBy ){\n      pInfo->orderByConsumed = 1;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3termOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3termCursor *pCsr;            /* Pointer to cursor object to return */\n\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3termCursor *)sqlite3_malloc(sizeof(Fts3termCursor));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(Fts3termCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3termCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Table *pFts3 = ((Fts3termTable *)pCursor->pVtab)->pFts3Tab;\n  Fts3termCursor *pCsr = (Fts3termCursor *)pCursor;\n\n  sqlite3Fts3SegmentsClose(pFts3);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3termNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3termCursor *pCsr = (Fts3termCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3termTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n  sqlite3_int64 v;\n\n  /* Increment our pretend rowid value. */\n  pCsr->iRowid++;\n\n  /* Advance to the next term in the full-text index. */\n  if( pCsr->csr.aDoclist==0 \n   || pCsr->pNext>=&pCsr->csr.aDoclist[pCsr->csr.nDoclist-1]\n  ){\n    rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);\n    if( rc!=SQLITE_ROW ){\n      pCsr->isEof = 1;\n      return rc;\n    }\n\n    pCsr->iCol = 0;\n    pCsr->iPos = 0;\n    pCsr->iDocid = 0;\n    pCsr->pNext = pCsr->csr.aDoclist;\n\n    /* Read docid */\n    pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &pCsr->iDocid);\n  }\n\n  pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &v);\n  if( v==0 ){\n    pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &v);\n    pCsr->iDocid += v;\n    pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &v);\n    pCsr->iCol = 0;\n    pCsr->iPos = 0;\n  }\n\n  if( v==1 ){\n    pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &v);\n    pCsr->iCol += (int)v;\n    pCsr->iPos = 0;\n    pCsr->pNext += sqlite3Fts3GetVarint(pCsr->pNext, &v);\n  }\n\n  pCsr->iPos += (int)(v - 2);\n\n  return SQLITE_OK;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3termFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts3termCursor *pCsr = (Fts3termCursor *)pCursor;\n  Fts3termTable *p = (Fts3termTable *)pCursor->pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int rc;\n\n  UNUSED_PARAMETER(nVal);\n  UNUSED_PARAMETER(idxNum);\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(apVal);\n\n  assert( idxStr==0 && idxNum==0 );\n\n  /* In case this cursor is being reused, close and zero it. */\n  testcase(pCsr->filter.zTerm);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);\n\n  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  pCsr->filter.flags |= FTS3_SEGMENT_SCAN;\n\n  rc = sqlite3Fts3SegReaderCursor(pFts3, 0, p->iIndex, FTS3_SEGCURSOR_ALL,\n      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, 1, &pCsr->csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);\n  }\n  if( rc==SQLITE_OK ){\n    rc = fts3termNextMethod(pCursor);\n  }\n  return rc;\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3termEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3termCursor *pCsr = (Fts3termCursor *)pCursor;\n  return pCsr->isEof;\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3termColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3termCursor *p = (Fts3termCursor *)pCursor;\n\n  assert( iCol>=0 && iCol<=3 );\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_int64(pCtx, p->iDocid);\n      break;\n    case 2:\n      sqlite3_result_int64(pCtx, p->iCol);\n      break;\n    default:\n      sqlite3_result_int64(pCtx, p->iPos);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3termRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3termCursor *pCsr = (Fts3termCursor *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3term module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nint sqlite3Fts3InitTerm(sqlite3 *db){\n  static const sqlite3_module fts3term_module = {\n     0,                           /* iVersion      */\n     fts3termConnectMethod,       /* xCreate       */\n     fts3termConnectMethod,       /* xConnect      */\n     fts3termBestIndexMethod,     /* xBestIndex    */\n     fts3termDisconnectMethod,    /* xDisconnect   */\n     fts3termDisconnectMethod,    /* xDestroy      */\n     fts3termOpenMethod,          /* xOpen         */\n     fts3termCloseMethod,         /* xClose        */\n     fts3termFilterMethod,        /* xFilter       */\n     fts3termNextMethod,          /* xNext         */\n     fts3termEofMethod,           /* xEof          */\n     fts3termColumnMethod,        /* xColumn       */\n     fts3termRowidMethod,         /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts4term\", &fts3term_module, 0);\n  return rc;\n}\n\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_test.c",
    "content": "/*\n** 2011 Jun 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is not part of the production FTS code. It is only used for\n** testing. It contains a Tcl command that can be used to test if a document\n** matches an FTS NEAR expression.\n**\n** As of March 2012, it also contains a version 1 tokenizer used for testing\n** that the sqlite3_tokenizer_module.xLanguage() method is invoked correctly.\n*/\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n#include <string.h>\n#include <assert.h>\n\n#if defined(SQLITE_TEST)\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n\n/* Required so that the \"ifdef SQLITE_ENABLE_FTS3\" below works */\n#include \"fts3Int.h\"\n\n#define NM_MAX_TOKEN 12\n\ntypedef struct NearPhrase NearPhrase;\ntypedef struct NearDocument NearDocument;\ntypedef struct NearToken NearToken;\n\nstruct NearDocument {\n  int nToken;                     /* Length of token in bytes */\n  NearToken *aToken;              /* Token array */\n};\n\nstruct NearToken {\n  int n;                          /* Length of token in bytes */\n  const char *z;                  /* Pointer to token string */\n};\n\nstruct NearPhrase {\n  int nNear;                      /* Preceding NEAR value */\n  int nToken;                     /* Number of tokens in this phrase */\n  NearToken aToken[NM_MAX_TOKEN]; /* Array of tokens in this phrase */\n};\n\nstatic int nm_phrase_match(\n  NearPhrase *p,\n  NearToken *aToken\n){\n  int ii;\n\n  for(ii=0; ii<p->nToken; ii++){\n    NearToken *pToken = &p->aToken[ii];\n    if( pToken->n>0 && pToken->z[pToken->n-1]=='*' ){\n      if( aToken[ii].n<(pToken->n-1) ) return 0;\n      if( memcmp(aToken[ii].z, pToken->z, pToken->n-1) ) return 0;\n    }else{\n      if( aToken[ii].n!=pToken->n ) return 0;\n      if( memcmp(aToken[ii].z, pToken->z, pToken->n) ) return 0;\n    }\n  }\n\n  return 1;\n}\n\nstatic int nm_near_chain(\n  int iDir,                       /* Direction to iterate through aPhrase[] */\n  NearDocument *pDoc,             /* Document to match against */\n  int iPos,                       /* Position at which iPhrase was found */\n  int nPhrase,                    /* Size of phrase array */\n  NearPhrase *aPhrase,            /* Phrase array */\n  int iPhrase                     /* Index of phrase found */\n){\n  int iStart;\n  int iStop;\n  int ii;\n  int nNear;\n  int iPhrase2;\n  NearPhrase *p;\n  NearPhrase *pPrev;\n\n  assert( iDir==1 || iDir==-1 );\n\n  if( iDir==1 ){\n    if( (iPhrase+1)==nPhrase ) return 1;\n    nNear = aPhrase[iPhrase+1].nNear;\n  }else{\n    if( iPhrase==0 ) return 1;\n    nNear = aPhrase[iPhrase].nNear;\n  }\n  pPrev = &aPhrase[iPhrase];\n  iPhrase2 = iPhrase+iDir;\n  p = &aPhrase[iPhrase2];\n\n  iStart = iPos - nNear - p->nToken;\n  iStop = iPos + nNear + pPrev->nToken;\n\n  if( iStart<0 ) iStart = 0;\n  if( iStop > pDoc->nToken - p->nToken ) iStop = pDoc->nToken - p->nToken;\n\n  for(ii=iStart; ii<=iStop; ii++){\n    if( nm_phrase_match(p, &pDoc->aToken[ii]) ){\n      if( nm_near_chain(iDir, pDoc, ii, nPhrase, aPhrase, iPhrase2) ) return 1;\n    }\n  }\n\n  return 0;\n}\n\nstatic int nm_match_count(\n  NearDocument *pDoc,             /* Document to match against */\n  int nPhrase,                    /* Size of phrase array */\n  NearPhrase *aPhrase,            /* Phrase array */\n  int iPhrase                     /* Index of phrase to count matches for */\n){\n  int nOcc = 0;\n  int ii;\n  NearPhrase *p = &aPhrase[iPhrase];\n\n  for(ii=0; ii<(pDoc->nToken + 1 - p->nToken); ii++){\n    if( nm_phrase_match(p, &pDoc->aToken[ii]) ){\n      /* Test forward NEAR chain (i>iPhrase) */\n      if( 0==nm_near_chain(1, pDoc, ii, nPhrase, aPhrase, iPhrase) ) continue;\n\n      /* Test reverse NEAR chain (i<iPhrase) */\n      if( 0==nm_near_chain(-1, pDoc, ii, nPhrase, aPhrase, iPhrase) ) continue;\n\n      /* This is a real match. Increment the counter. */\n      nOcc++;\n    }\n  } \n\n  return nOcc;\n}\n\n/*\n** Tclcmd: fts3_near_match DOCUMENT EXPR ?OPTIONS?\n*/\nstatic int SQLITE_TCLAPI fts3_near_match_cmd(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nTotal = 0;\n  int rc;\n  int ii;\n  int nPhrase;\n  NearPhrase *aPhrase = 0;\n  NearDocument doc = {0, 0};\n  Tcl_Obj **apDocToken;\n  Tcl_Obj *pRet;\n  Tcl_Obj *pPhrasecount = 0;\n  \n  Tcl_Obj **apExprToken;\n  int nExprToken;\n\n  UNUSED_PARAMETER(clientData);\n\n  /* Must have 3 or more arguments. */\n  if( objc<3 || (objc%2)==0 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DOCUMENT EXPR ?OPTION VALUE?...\");\n    rc = TCL_ERROR;\n    goto near_match_out;\n  }\n\n  for(ii=3; ii<objc; ii+=2){\n    enum NM_enum { NM_PHRASECOUNTS };\n    struct TestnmSubcmd {\n      char *zName;\n      enum NM_enum eOpt;\n    } aOpt[] = {\n      { \"-phrasecountvar\", NM_PHRASECOUNTS },\n      { 0, 0 }\n    };\n    int iOpt;\n    if( Tcl_GetIndexFromObjStruct(\n        interp, objv[ii], aOpt, sizeof(aOpt[0]), \"option\", 0, &iOpt) \n    ){\n      return TCL_ERROR;\n    }\n\n    switch( aOpt[iOpt].eOpt ){\n      case NM_PHRASECOUNTS:\n        pPhrasecount = objv[ii+1];\n        break;\n    }\n  }\n\n  rc = Tcl_ListObjGetElements(interp, objv[1], &doc.nToken, &apDocToken);\n  if( rc!=TCL_OK ) goto near_match_out;\n  doc.aToken = (NearToken *)ckalloc(doc.nToken*sizeof(NearToken));\n  for(ii=0; ii<doc.nToken; ii++){\n    doc.aToken[ii].z = Tcl_GetStringFromObj(apDocToken[ii], &doc.aToken[ii].n);\n  }\n\n  rc = Tcl_ListObjGetElements(interp, objv[2], &nExprToken, &apExprToken);\n  if( rc!=TCL_OK ) goto near_match_out;\n\n  nPhrase = (nExprToken + 1) / 2;\n  aPhrase = (NearPhrase *)ckalloc(nPhrase * sizeof(NearPhrase));\n  memset(aPhrase, 0, nPhrase * sizeof(NearPhrase));\n  for(ii=0; ii<nPhrase; ii++){\n    Tcl_Obj *pPhrase = apExprToken[ii*2];\n    Tcl_Obj **apToken;\n    int nToken;\n    int jj;\n\n    rc = Tcl_ListObjGetElements(interp, pPhrase, &nToken, &apToken);\n    if( rc!=TCL_OK ) goto near_match_out;\n    if( nToken>NM_MAX_TOKEN ){\n      Tcl_AppendResult(interp, \"Too many tokens in phrase\", 0);\n      rc = TCL_ERROR;\n      goto near_match_out;\n    }\n    for(jj=0; jj<nToken; jj++){\n      NearToken *pT = &aPhrase[ii].aToken[jj];\n      pT->z = Tcl_GetStringFromObj(apToken[jj], &pT->n);\n    }\n    aPhrase[ii].nToken = nToken;\n  }\n  for(ii=1; ii<nPhrase; ii++){\n    Tcl_Obj *pNear = apExprToken[2*ii-1];\n    int nNear;\n    rc = Tcl_GetIntFromObj(interp, pNear, &nNear);\n    if( rc!=TCL_OK ) goto near_match_out;\n    aPhrase[ii].nNear = nNear;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n  for(ii=0; ii<nPhrase; ii++){\n    int nOcc = nm_match_count(&doc, nPhrase, aPhrase, ii);\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nOcc));\n    nTotal += nOcc;\n  }\n  if( pPhrasecount ){\n    Tcl_ObjSetVar2(interp, pPhrasecount, 0, pRet, 0);\n  }\n  Tcl_DecrRefCount(pRet);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(nTotal>0));\n\n near_match_out: \n  ckfree((char *)aPhrase);\n  ckfree((char *)doc.aToken);\n  return rc;\n}\n\n/*\n**   Tclcmd: fts3_configure_incr_load ?CHUNKSIZE THRESHOLD?\n**\n** Normally, FTS uses hard-coded values to determine the minimum doclist\n** size eligible for incremental loading, and the size of the chunks loaded\n** when a doclist is incrementally loaded. This command allows the built-in\n** values to be overridden for testing purposes.\n**\n** If present, the first argument is the chunksize in bytes to load doclists\n** in. The second argument is the minimum doclist size in bytes to use\n** incremental loading with.\n**\n** Whether or not the arguments are present, this command returns a list of\n** two integers - the initial chunksize and threshold when the command is\n** invoked. This can be used to restore the default behavior after running\n** tests. For example:\n**\n**    # Override incr-load settings for testing:\n**    set cfg [fts3_configure_incr_load $new_chunksize $new_threshold]\n**\n**    .... run tests ....\n**\n**    # Restore initial incr-load settings:\n**    eval fts3_configure_incr_load $cfg\n*/\nstatic int SQLITE_TCLAPI fts3_configure_incr_load_cmd(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifdef SQLITE_ENABLE_FTS3\n  extern int test_fts3_node_chunksize;\n  extern int test_fts3_node_chunk_threshold;\n  Tcl_Obj *pRet;\n\n  if( objc!=1 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?CHUNKSIZE THRESHOLD?\");\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n  Tcl_ListObjAppendElement(\n      interp, pRet, Tcl_NewIntObj(test_fts3_node_chunksize));\n  Tcl_ListObjAppendElement(\n      interp, pRet, Tcl_NewIntObj(test_fts3_node_chunk_threshold));\n\n  if( objc==3 ){\n    int iArg1;\n    int iArg2;\n    if( Tcl_GetIntFromObj(interp, objv[1], &iArg1)\n     || Tcl_GetIntFromObj(interp, objv[2], &iArg2)\n    ){\n      Tcl_DecrRefCount(pRet);\n      return TCL_ERROR;\n    }\n    test_fts3_node_chunksize = iArg1;\n    test_fts3_node_chunk_threshold = iArg2;\n  }\n\n  Tcl_SetObjResult(interp, pRet);\n  Tcl_DecrRefCount(pRet);\n#endif\n  UNUSED_PARAMETER(clientData);\n  return TCL_OK;\n}\n\n#ifdef SQLITE_ENABLE_FTS3\n/**************************************************************************\n** Beginning of test tokenizer code.\n**\n** For language 0, this tokenizer is similar to the default 'simple' \n** tokenizer. For other languages L, the following:\n**\n**   * Odd numbered languages are case-sensitive. Even numbered \n**     languages are not.\n**\n**   * Language ids 100 or greater are considered an error.\n**\n** The implementation assumes that the input contains only ASCII characters\n** (i.e. those that may be encoded in UTF-8 using a single byte).\n*/\ntypedef struct test_tokenizer {\n  sqlite3_tokenizer base;\n} test_tokenizer;\n\ntypedef struct test_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *aInput;          /* Input being tokenized */\n  int nInput;                  /* Size of the input in bytes */\n  int iInput;                  /* Current offset in aInput */\n  int iToken;                  /* Index of next token to be returned */\n  char *aBuffer;               /* Buffer containing current token */\n  int nBuffer;                 /* Number of bytes allocated at pToken */\n  int iLangid;                 /* Configured language id */\n} test_tokenizer_cursor;\n\nstatic int testTokenizerCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  test_tokenizer *pNew;\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  pNew = sqlite3_malloc(sizeof(test_tokenizer));\n  if( !pNew ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(test_tokenizer));\n\n  *ppTokenizer = (sqlite3_tokenizer *)pNew;\n  return SQLITE_OK;\n}\n\nstatic int testTokenizerDestroy(sqlite3_tokenizer *pTokenizer){\n  test_tokenizer *p = (test_tokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\nstatic int testTokenizerOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  int rc = SQLITE_OK;                    /* Return code */\n  test_tokenizer_cursor *pCsr;           /* New cursor object */\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  pCsr = (test_tokenizer_cursor *)sqlite3_malloc(sizeof(test_tokenizer_cursor));\n  if( pCsr==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pCsr, 0, sizeof(test_tokenizer_cursor));\n    pCsr->aInput = pInput;\n    if( nBytes<0 ){\n      pCsr->nInput = (int)strlen(pInput);\n    }else{\n      pCsr->nInput = nBytes;\n    }\n  }\n\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return rc;\n}\n\nstatic int testTokenizerClose(sqlite3_tokenizer_cursor *pCursor){\n  test_tokenizer_cursor *pCsr = (test_tokenizer_cursor *)pCursor;\n  sqlite3_free(pCsr->aBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int testIsTokenChar(char c){\n  return (c>='a' && c<='z') || (c>='A' && c<='Z');\n}\nstatic int testTolower(char c){\n  char ret = c;\n  if( ret>='A' && ret<='Z') ret = ret - ('A'-'a');\n  return ret;\n}\n\nstatic int testTokenizerNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by testTokenizerOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  test_tokenizer_cursor *pCsr = (test_tokenizer_cursor *)pCursor;\n  int rc = SQLITE_OK;\n  const char *p;\n  const char *pEnd;\n\n  p = &pCsr->aInput[pCsr->iInput];\n  pEnd = &pCsr->aInput[pCsr->nInput];\n\n  /* Skip past any white-space */\n  assert( p<=pEnd );\n  while( p<pEnd && testIsTokenChar(*p)==0 ) p++;\n\n  if( p==pEnd ){\n    rc = SQLITE_DONE;\n  }else{\n    /* Advance to the end of the token */\n    const char *pToken = p;\n    int nToken;\n    while( p<pEnd && testIsTokenChar(*p) ) p++;\n    nToken = (int)(p-pToken);\n\n    /* Copy the token into the buffer */\n    if( nToken>pCsr->nBuffer ){\n      sqlite3_free(pCsr->aBuffer);\n      pCsr->aBuffer = sqlite3_malloc(nToken);\n    }\n    if( pCsr->aBuffer==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int i;\n\n      if( pCsr->iLangid & 0x00000001 ){\n        for(i=0; i<nToken; i++) pCsr->aBuffer[i] = pToken[i];\n      }else{\n        for(i=0; i<nToken; i++) pCsr->aBuffer[i] = (char)testTolower(pToken[i]);\n      }\n      pCsr->iToken++;\n      pCsr->iInput = (int)(p - pCsr->aInput);\n\n      *ppToken = pCsr->aBuffer;\n      *pnBytes = nToken;\n      *piStartOffset = (int)(pToken - pCsr->aInput);\n      *piEndOffset = (int)(p - pCsr->aInput);\n      *piPosition = pCsr->iToken;\n    }\n  }\n\n  return rc;\n}\n\nstatic int testTokenizerLanguage(\n  sqlite3_tokenizer_cursor *pCursor,\n  int iLangid\n){\n  int rc = SQLITE_OK;\n  test_tokenizer_cursor *pCsr = (test_tokenizer_cursor *)pCursor;\n  pCsr->iLangid = iLangid;\n  if( pCsr->iLangid>=100 ){\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n#endif\n\nstatic int SQLITE_TCLAPI fts3_test_tokenizer_cmd(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifdef SQLITE_ENABLE_FTS3\n  static const sqlite3_tokenizer_module testTokenizerModule = {\n    1,\n    testTokenizerCreate,\n    testTokenizerDestroy,\n    testTokenizerOpen,\n    testTokenizerClose,\n    testTokenizerNext,\n    testTokenizerLanguage\n  };\n  const sqlite3_tokenizer_module *pPtr = &testTokenizerModule;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(\n    (const unsigned char *)&pPtr, sizeof(sqlite3_tokenizer_module *)\n  ));\n#endif\n  UNUSED_PARAMETER(clientData);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI fts3_test_varint_cmd(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifdef SQLITE_ENABLE_FTS3\n  char aBuf[24];\n  int rc;\n  Tcl_WideInt w;\n  sqlite3_int64 w2;\n  int nByte, nByte2;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"INTEGER\");\n    return TCL_ERROR;\n  }\n\n  rc = Tcl_GetWideIntFromObj(interp, objv[1], &w);\n  if( rc!=TCL_OK ) return rc;\n\n  nByte = sqlite3Fts3PutVarint(aBuf, w);\n  nByte2 = sqlite3Fts3GetVarint(aBuf, &w2);\n  if( w!=w2 || nByte!=nByte2 ){\n    char *zErr = sqlite3_mprintf(\"error testing %lld\", w);\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, zErr, 0);\n    return TCL_ERROR;\n  }\n\n  if( w<=2147483647 && w>=0 ){\n    int i;\n    nByte2 = fts3GetVarint32(aBuf, &i);\n    if( (int)w!=i || nByte!=nByte2 ){\n      char *zErr = sqlite3_mprintf(\"error testing %lld (32-bit)\", w);\n      Tcl_ResetResult(interp);\n      Tcl_AppendResult(interp, zErr, 0);\n      return TCL_ERROR;\n    }\n  }\n\n#endif\n  UNUSED_PARAMETER(clientData);\n  return TCL_OK;\n}\n\n/* \n** End of tokenizer code.\n**************************************************************************/ \n\nint Sqlitetestfts3_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"fts3_near_match\", fts3_near_match_cmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \n      \"fts3_configure_incr_load\", fts3_configure_incr_load_cmd, 0, 0\n  );\n  Tcl_CreateObjCommand(\n      interp, \"fts3_test_tokenizer\", fts3_test_tokenizer_cmd, 0, 0\n  );\n\n  Tcl_CreateObjCommand(\n      interp, \"fts3_test_varint\", fts3_test_varint_cmd, 0, 0\n  );\n  return TCL_OK;\n}\n#endif                  /* SQLITE_ENABLE_FTS3 || SQLITE_ENABLE_FTS4 */\n#endif                  /* ifdef SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_tokenize_vtab.c",
    "content": "/*\n** 2013 Apr 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for the \"fts3tokenize\" virtual table module.\n** An fts3tokenize virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(\n**       <tokenizer-name>, <arg-1>, ...\n**   );\n**\n** The table created has the following schema:\n**\n**   CREATE TABLE <tbl>(input, token, start, end, position)\n**\n** When queried, the query must include a WHERE clause of type:\n**\n**   input = <string>\n**\n** The virtual table module tokenizes this <string>, using the FTS3 \n** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE \n** statement and returns one row for each token in the result. With\n** fields set as follows:\n**\n**   input:   Always set to a copy of <string>\n**   token:   A token from the input.\n**   start:   Byte offset of the token within the input <string>.\n**   end:     Byte offset of the byte immediately following the end of the\n**            token within the input string.\n**   pos:     Token offset of token within input.\n**\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <string.h>\n#include <assert.h>\n\ntypedef struct Fts3tokTable Fts3tokTable;\ntypedef struct Fts3tokCursor Fts3tokCursor;\n\n/*\n** Virtual table structure.\n*/\nstruct Fts3tokTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  const sqlite3_tokenizer_module *pMod;\n  sqlite3_tokenizer *pTok;\n};\n\n/*\n** Virtual table cursor structure.\n*/\nstruct Fts3tokCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  char *zInput;                   /* Input string */\n  sqlite3_tokenizer_cursor *pCsr; /* Cursor to iterate through zInput */\n  int iRowid;                     /* Current 'rowid' value */\n  const char *zToken;             /* Current 'token' value */\n  int nToken;                     /* Size of zToken in bytes */\n  int iStart;                     /* Current 'start' value */\n  int iEnd;                       /* Current 'end' value */\n  int iPos;                       /* Current 'pos' value */\n};\n\n/*\n** Query FTS for the tokenizer implementation named zName.\n*/\nstatic int fts3tokQueryTokenizer(\n  Fts3Hash *pHash,\n  const char *zName,\n  const sqlite3_tokenizer_module **pp,\n  char **pzErr\n){\n  sqlite3_tokenizer_module *p;\n  int nName = (int)strlen(zName);\n\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n  if( !p ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", zName);\n    return SQLITE_ERROR;\n  }\n\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** The second argument, argv[], is an array of pointers to nul-terminated\n** strings. This function makes a copy of the array and strings into a \n** single block of memory. It then dequotes any of the strings that appear\n** to be quoted.\n**\n** If successful, output parameter *pazDequote is set to point at the\n** array of dequoted strings and SQLITE_OK is returned. The caller is\n** responsible for eventually calling sqlite3_free() to free the array\n** in this case. Or, if an error occurs, an SQLite error code is returned.\n** The final value of *pazDequote is undefined in this case.\n*/\nstatic int fts3tokDequoteArray(\n  int argc,                       /* Number of elements in argv[] */\n  const char * const *argv,       /* Input array */\n  char ***pazDequote              /* Output array */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( argc==0 ){\n    *pazDequote = 0;\n  }else{\n    int i;\n    int nByte = 0;\n    char **azDequote;\n\n    for(i=0; i<argc; i++){\n      nByte += (int)(strlen(argv[i]) + 1);\n    }\n\n    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);\n    if( azDequote==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *pSpace = (char *)&azDequote[argc];\n      for(i=0; i<argc; i++){\n        int n = (int)strlen(argv[i]);\n        azDequote[i] = pSpace;\n        memcpy(pSpace, argv[i], n+1);\n        sqlite3Fts3Dequote(pSpace);\n        pSpace += (n+1);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Schema of the tokenizer table.\n*/\n#define FTS3_TOK_SCHEMA \"CREATE TABLE x(input, token, start, end, position)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n**\n**   argv[0]: module name\n**   argv[1]: database name \n**   argv[2]: table name\n**   argv[3]: first argument (tokenizer name)\n*/\nstatic int fts3tokConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pHash,                    /* Hash table of tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  Fts3tokTable *pTab = 0;\n  const sqlite3_tokenizer_module *pMod = 0;\n  sqlite3_tokenizer *pTok = 0;\n  int rc;\n  char **azDequote = 0;\n  int nDequote;\n\n  rc = sqlite3_declare_vtab(db, FTS3_TOK_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nDequote = argc-3;\n  rc = fts3tokDequoteArray(nDequote, &argv[3], &azDequote);\n\n  if( rc==SQLITE_OK ){\n    const char *zModule;\n    if( nDequote<1 ){\n      zModule = \"simple\";\n    }else{\n      zModule = azDequote[0];\n    }\n    rc = fts3tokQueryTokenizer((Fts3Hash*)pHash, zModule, &pMod, pzErr);\n  }\n\n  assert( (rc==SQLITE_OK)==(pMod!=0) );\n  if( rc==SQLITE_OK ){\n    const char * const *azArg = (const char * const *)&azDequote[1];\n    rc = pMod->xCreate((nDequote>1 ? nDequote-1 : 0), azArg, &pTok);\n  }\n\n  if( rc==SQLITE_OK ){\n    pTab = (Fts3tokTable *)sqlite3_malloc(sizeof(Fts3tokTable));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(Fts3tokTable));\n    pTab->pMod = pMod;\n    pTab->pTok = pTok;\n    *ppVtab = &pTab->base;\n  }else{\n    if( pTok ){\n      pMod->xDestroy(pTok);\n    }\n  }\n\n  sqlite3_free(azDequote);\n  return rc;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3tokDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3tokTable *pTab = (Fts3tokTable *)pVtab;\n\n  pTab->pMod->xDestroy(pTab->pTok);\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3tokBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  UNUSED_PARAMETER(pVTab);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable \n     && pInfo->aConstraint[i].iColumn==0 \n     && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      pInfo->idxNum = 1;\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->estimatedCost = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  pInfo->idxNum = 0;\n  assert( pInfo->estimatedCost>1000000.0 );\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3tokCursor *pCsr;\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3tokCursor *)sqlite3_malloc(sizeof(Fts3tokCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3tokCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the tokenizer cursor passed as the only argument. As if it had\n** just been returned by fts3tokOpenMethod().\n*/\nstatic void fts3tokResetCursor(Fts3tokCursor *pCsr){\n  if( pCsr->pCsr ){\n    Fts3tokTable *pTab = (Fts3tokTable *)(pCsr->base.pVtab);\n    pTab->pMod->xClose(pCsr->pCsr);\n    pCsr->pCsr = 0;\n  }\n  sqlite3_free(pCsr->zInput);\n  pCsr->zInput = 0;\n  pCsr->zToken = 0;\n  pCsr->nToken = 0;\n  pCsr->iStart = 0;\n  pCsr->iEnd = 0;\n  pCsr->iPos = 0;\n  pCsr->iRowid = 0;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3tokCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  fts3tokResetCursor(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3tokNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  int rc;                         /* Return code */\n\n  pCsr->iRowid++;\n  rc = pTab->pMod->xNext(pCsr->pCsr,\n      &pCsr->zToken, &pCsr->nToken,\n      &pCsr->iStart, &pCsr->iEnd, &pCsr->iPos\n  );\n\n  if( rc!=SQLITE_OK ){\n    fts3tokResetCursor(pCsr);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3tokFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_ERROR;\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  fts3tokResetCursor(pCsr);\n  if( idxNum==1 ){\n    const char *zByte = (const char *)sqlite3_value_text(apVal[0]);\n    int nByte = sqlite3_value_bytes(apVal[0]);\n    pCsr->zInput = sqlite3_malloc(nByte+1);\n    if( pCsr->zInput==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memcpy(pCsr->zInput, zByte, nByte);\n      pCsr->zInput[nByte] = 0;\n      rc = pTab->pMod->xOpen(pTab->pTok, pCsr->zInput, nByte, &pCsr->pCsr);\n      if( rc==SQLITE_OK ){\n        pCsr->pCsr->pTokenizer = pTab->pTok;\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ) return rc;\n  return fts3tokNextMethod(pCursor);\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3tokEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  return (pCsr->zToken==0);\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3tokColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  /* CREATE TABLE x(input, token, start, end, position) */\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_text(pCtx, pCsr->zToken, pCsr->nToken, SQLITE_TRANSIENT);\n      break;\n    case 2:\n      sqlite3_result_int(pCtx, pCsr->iStart);\n      break;\n    case 3:\n      sqlite3_result_int(pCtx, pCsr->iEnd);\n      break;\n    default:\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, pCsr->iPos);\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3tokRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  *pRowid = (sqlite3_int64)pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3tok module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nint sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){\n  static const sqlite3_module fts3tok_module = {\n     0,                           /* iVersion      */\n     fts3tokConnectMethod,        /* xCreate       */\n     fts3tokConnectMethod,        /* xConnect      */\n     fts3tokBestIndexMethod,      /* xBestIndex    */\n     fts3tokDisconnectMethod,     /* xDisconnect   */\n     fts3tokDisconnectMethod,     /* xDestroy      */\n     fts3tokOpenMethod,           /* xOpen         */\n     fts3tokCloseMethod,          /* xClose        */\n     fts3tokFilterMethod,         /* xFilter       */\n     fts3tokNextMethod,           /* xNext         */\n     fts3tokEofMethod,            /* xEof          */\n     fts3tokColumnMethod,         /* xColumn       */\n     fts3tokRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts3tokenize\", &fts3tok_module, (void*)pHash);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_tokenizer.c",
    "content": "/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is part of an SQLite module implementing full-text search.\n** This particular file implements the generic tokenizer interface.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <assert.h>\n#include <string.h>\n\n/*\n** Return true if the two-argument version of fts3_tokenizer()\n** has been activated via a prior call to sqlite3_db_config(db,\n** SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, 0);\n*/\nstatic int fts3TokenizerEnabled(sqlite3_context *context){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int isEnabled = 0;\n  sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,-1,&isEnabled);\n  return isEnabled;\n}\n\n/*\n** Implementation of the SQL scalar function for accessing the underlying \n** hash table. This function may be called as follows:\n**\n**   SELECT <function-name>(<key-name>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer').\n**\n** If the <pointer> argument is specified, it must be a blob value\n** containing a pointer to be stored as the hash data corresponding\n** to the string <key-name>. If <pointer> is not specified, then\n** the string <key-name> must already exist in the has table. Otherwise,\n** an error is returned.\n**\n** Whether or not the <pointer> argument is specified, the value returned\n** is a blob containing the pointer stored as the hash data corresponding\n** to string <key-name> (after the hash-table is updated, if applicable).\n*/\nstatic void fts3TokenizerFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  void *pPtr = 0;\n  const unsigned char *zName;\n  int nName;\n\n  assert( argc==1 || argc==2 );\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n\n  zName = sqlite3_value_text(argv[0]);\n  nName = sqlite3_value_bytes(argv[0])+1;\n\n  if( argc==2 ){\n    if( fts3TokenizerEnabled(context) ){\n      void *pOld;\n      int n = sqlite3_value_bytes(argv[1]);\n      if( zName==0 || n!=sizeof(pPtr) ){\n        sqlite3_result_error(context, \"argument type mismatch\", -1);\n        return;\n      }\n      pPtr = *(void **)sqlite3_value_blob(argv[1]);\n      pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);\n      if( pOld==pPtr ){\n        sqlite3_result_error(context, \"out of memory\", -1);\n      }\n    }else{\n      sqlite3_result_error(context, \"fts3tokenize disabled\", -1);\n      return;\n    }\n  }else{\n    if( zName ){\n      pPtr = sqlite3Fts3HashFind(pHash, zName, nName);\n    }\n    if( !pPtr ){\n      char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n  }\n  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);\n}\n\nint sqlite3Fts3IsIdChar(char c){\n  static const char isFtsIdChar[] = {\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */\n      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n  };\n  return (c&0x80 || isFtsIdChar[(int)(c)]);\n}\n\nconst char *sqlite3Fts3NextToken(const char *zStr, int *pn){\n  const char *z1;\n  const char *z2 = 0;\n\n  /* Find the start of the next token. */\n  z1 = zStr;\n  while( z2==0 ){\n    char c = *z1;\n    switch( c ){\n      case '\\0': return 0;        /* No more tokens here */\n      case '\\'':\n      case '\"':\n      case '`': {\n        z2 = z1;\n        while( *++z2 && (*z2!=c || *++z2==c) );\n        break;\n      }\n      case '[':\n        z2 = &z1[1];\n        while( *z2 && z2[0]!=']' ) z2++;\n        if( *z2 ) z2++;\n        break;\n\n      default:\n        if( sqlite3Fts3IsIdChar(*z1) ){\n          z2 = &z1[1];\n          while( sqlite3Fts3IsIdChar(*z2) ) z2++;\n        }else{\n          z1++;\n        }\n    }\n  }\n\n  *pn = (int)(z2-z1);\n  return z1;\n}\n\nint sqlite3Fts3InitTokenizer(\n  Fts3Hash *pHash,                /* Tokenizer hash table */\n  const char *zArg,               /* Tokenizer name */\n  sqlite3_tokenizer **ppTok,      /* OUT: Tokenizer (if applicable) */\n  char **pzErr                    /* OUT: Set to malloced error message */\n){\n  int rc;\n  char *z = (char *)zArg;\n  int n = 0;\n  char *zCopy;\n  char *zEnd;                     /* Pointer to nul-term of zCopy */\n  sqlite3_tokenizer_module *m;\n\n  zCopy = sqlite3_mprintf(\"%s\", zArg);\n  if( !zCopy ) return SQLITE_NOMEM;\n  zEnd = &zCopy[strlen(zCopy)];\n\n  z = (char *)sqlite3Fts3NextToken(zCopy, &n);\n  if( z==0 ){\n    assert( n==0 );\n    z = zCopy;\n  }\n  z[n] = '\\0';\n  sqlite3Fts3Dequote(z);\n\n  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);\n  if( !m ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", z);\n    rc = SQLITE_ERROR;\n  }else{\n    char const **aArg = 0;\n    int iArg = 0;\n    z = &z[n+1];\n    while( z<zEnd && (NULL!=(z = (char *)sqlite3Fts3NextToken(z, &n))) ){\n      int nNew = sizeof(char *)*(iArg+1);\n      char const **aNew = (const char **)sqlite3_realloc((void *)aArg, nNew);\n      if( !aNew ){\n        sqlite3_free(zCopy);\n        sqlite3_free((void *)aArg);\n        return SQLITE_NOMEM;\n      }\n      aArg = aNew;\n      aArg[iArg++] = z;\n      z[n] = '\\0';\n      sqlite3Fts3Dequote(z);\n      z = &z[n+1];\n    }\n    rc = m->xCreate(iArg, aArg, ppTok);\n    assert( rc!=SQLITE_OK || *ppTok );\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer\");\n    }else{\n      (*ppTok)->pModule = m; \n    }\n    sqlite3_free((void *)aArg);\n  }\n\n  sqlite3_free(zCopy);\n  return rc;\n}\n\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <string.h>\n\n/*\n** Implementation of a special SQL scalar function for testing tokenizers \n** designed to be used in concert with the Tcl testing framework. This\n** function must be called with two or more arguments:\n**\n**   SELECT <function-name>(<key-name>, ..., <input-string>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer')\n** concatenated with the string '_test' (e.g. 'fts3_tokenizer_test').\n**\n** The return value is a string that may be interpreted as a Tcl\n** list. For each token in the <input-string>, three elements are\n** added to the returned list. The first is the token position, the \n** second is the token text (folded, stemmed, etc.) and the third is the\n** substring of <input-string> associated with the token. For example, \n** using the built-in \"simple\" tokenizer:\n**\n**   SELECT fts_tokenizer_test('simple', 'I don't see how');\n**\n** will return the string:\n**\n**   \"{0 i I 1 dont don't 2 see see 3 how how}\"\n**   \n*/\nstatic void testFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  sqlite3_tokenizer_module *p;\n  sqlite3_tokenizer *pTokenizer = 0;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n\n  const char *zErr = 0;\n\n  const char *zName;\n  int nName;\n  const char *zInput;\n  int nInput;\n\n  const char *azArg[64];\n\n  const char *zToken;\n  int nToken = 0;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int i;\n\n  Tcl_Obj *pRet;\n\n  if( argc<2 ){\n    sqlite3_result_error(context, \"insufficient arguments\", -1);\n    return;\n  }\n\n  nName = sqlite3_value_bytes(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[0]);\n  nInput = sqlite3_value_bytes(argv[argc-1]);\n  zInput = (const char *)sqlite3_value_text(argv[argc-1]);\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n\n  if( !p ){\n    char *zErr2 = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    sqlite3_result_error(context, zErr2, -1);\n    sqlite3_free(zErr2);\n    return;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  for(i=1; i<argc-1; i++){\n    azArg[i-1] = (const char *)sqlite3_value_text(argv[i]);\n  }\n\n  if( SQLITE_OK!=p->xCreate(argc-2, azArg, &pTokenizer) ){\n    zErr = \"error in xCreate()\";\n    goto finish;\n  }\n  pTokenizer->pModule = p;\n  if( sqlite3Fts3OpenTokenizer(pTokenizer, 0, zInput, nInput, &pCsr) ){\n    zErr = \"error in xOpen()\";\n    goto finish;\n  }\n\n  while( SQLITE_OK==p->xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos) ){\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(iPos));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n    zToken = &zInput[iStart];\n    nToken = iEnd-iStart;\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n  }\n\n  if( SQLITE_OK!=p->xClose(pCsr) ){\n    zErr = \"error in xClose()\";\n    goto finish;\n  }\n  if( SQLITE_OK!=p->xDestroy(pTokenizer) ){\n    zErr = \"error in xDestroy()\";\n    goto finish;\n  }\n\nfinish:\n  if( zErr ){\n    sqlite3_result_error(context, zErr, -1);\n  }else{\n    sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  }\n  Tcl_DecrRefCount(pRet);\n}\n\nstatic\nint registerTokenizer(\n  sqlite3 *db, \n  char *zName, \n  const sqlite3_tokenizer_module *p\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?, ?)\";\n\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n  sqlite3_step(pStmt);\n\n  return sqlite3_finalize(pStmt);\n}\n\n\nstatic\nint queryTokenizer(\n  sqlite3 *db, \n  char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\nvoid sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n/*\n** Implementation of the scalar function fts3_tokenizer_internal_test().\n** This function is used for testing only, it is not included in the\n** build unless SQLITE_TEST is defined.\n**\n** The purpose of this is to test that the fts3_tokenizer() function\n** can be used as designed by the C-code in the queryTokenizer and\n** registerTokenizer() functions above. These two functions are repeated\n** in the README.tokenizer file as an example, so it is important to\n** test them.\n**\n** To run the tests, evaluate the fts3_tokenizer_internal_test() scalar\n** function with no arguments. An assert() will fail if a problem is\n** detected. i.e.:\n**\n**     SELECT fts3_tokenizer_internal_test();\n**\n*/\nstatic void intTestFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc;\n  const sqlite3_tokenizer_module *p1;\n  const sqlite3_tokenizer_module *p2;\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  /* Test the query function */\n  sqlite3Fts3SimpleTokenizerModule(&p1);\n  rc = queryTokenizer(db, \"simple\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p1==p2 );\n  rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_ERROR );\n  assert( p2==0 );\n  assert( 0==strcmp(sqlite3_errmsg(db), \"unknown tokenizer: nosuchtokenizer\") );\n\n  /* Test the storage function */\n  if( fts3TokenizerEnabled(context) ){\n    rc = registerTokenizer(db, \"nosuchtokenizer\", p1);\n    assert( rc==SQLITE_OK );\n    rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n    assert( rc==SQLITE_OK );\n    assert( p2==p1 );\n  }\n\n  sqlite3_result_text(context, \"ok\", -1, SQLITE_STATIC);\n}\n\n#endif\n\n/*\n** Set up SQL objects in database db used to access the contents of\n** the hash table pointed to by argument pHash. The hash table must\n** been initialized to use string keys, and to take a private copy \n** of the key when a value is inserted. i.e. by a call similar to:\n**\n**    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n**\n** This function adds a scalar function (see header comment above\n** fts3TokenizerFunc() in this file for details) and, if ENABLE_TABLE is\n** defined at compilation time, a temporary virtual table (see header \n** comment above struct HashTableVtab) to the database schema. Both \n** provide read/write access to the contents of *pHash.\n**\n** The third argument to this function, zName, is used as the name\n** of both the scalar and, if created, the virtual table.\n*/\nint sqlite3Fts3InitHashTable(\n  sqlite3 *db, \n  Fts3Hash *pHash, \n  const char *zName\n){\n  int rc = SQLITE_OK;\n  void *p = (void *)pHash;\n  const int any = SQLITE_ANY;\n\n#ifdef SQLITE_TEST\n  char *zTest = 0;\n  char *zTest2 = 0;\n  void *pdb = (void *)db;\n  zTest = sqlite3_mprintf(\"%s_test\", zName);\n  zTest2 = sqlite3_mprintf(\"%s_internal_test\", zName);\n  if( !zTest || !zTest2 ){\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 1, any, p, fts3TokenizerFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 2, any, p, fts3TokenizerFunc, 0, 0);\n  }\n#ifdef SQLITE_TEST\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0);\n  }\n#endif\n\n#ifdef SQLITE_TEST\n  sqlite3_free(zTest);\n  sqlite3_free(zTest2);\n#endif\n\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_tokenizer.h",
    "content": "/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS3_TOKENIZER_H_\n#define _FTS3_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts3 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts3 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0 or 1.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts3 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialized by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts3 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts3 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset. *piStartOffset should be set to the index of the first\n  ** byte of the token in the input buffer. *piEndOffset should be set\n  ** to the index of the first byte just past the end of the token in\n  ** the input buffer.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n\n  /***********************************************************************\n  ** Methods below this point are only available if iVersion>=1.\n  */\n\n  /* \n  ** Configure the language id of a tokenizer cursor.\n  */\n  int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid);\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nint fts3_global_term_cnt(int iTerm, int iCol);\nint fts3_term_cnt(int iTerm, int iCol);\n\n\n#endif /* _FTS3_TOKENIZER_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_tokenizer1.c",
    "content": "/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"fts3_tokenizer.h\"\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\nstatic int simpleDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\nstatic int fts3_isalnum(int x){\n  return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = (int)strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        sqlite3_free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !fts3_isalnum(i) ? -1 : 0;\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->pToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        char *pNew;\n        c->nTokenAllocated = n+20;\n        pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->pToken = pNew;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = (char)((ch>='A' && ch<='Z') ? ch-'A'+'a' : ch);\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n  0,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nvoid sqlite3Fts3SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_unicode.c",
    "content": "/*\n** 2012 May 24\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"unicode\" full-text-search tokenizer.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <assert.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"fts3_tokenizer.h\"\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct unicode_tokenizer unicode_tokenizer;\ntypedef struct unicode_cursor unicode_cursor;\n\nstruct unicode_tokenizer {\n  sqlite3_tokenizer base;\n  int bRemoveDiacritic;\n  int nException;\n  int *aiException;\n};\n\nstruct unicode_cursor {\n  sqlite3_tokenizer_cursor base;\n  const unsigned char *aInput;    /* Input text being tokenized */\n  int nInput;                     /* Size of aInput[] in bytes */\n  int iOff;                       /* Current offset within aInput[] */\n  int iToken;                     /* Index of next token to be returned */\n  char *zToken;                   /* storage for current token */\n  int nAlloc;                     /* space allocated at zToken */\n};\n\n\n/*\n** Destroy a tokenizer allocated by unicodeCreate().\n*/\nstatic int unicodeDestroy(sqlite3_tokenizer *pTokenizer){\n  if( pTokenizer ){\n    unicode_tokenizer *p = (unicode_tokenizer *)pTokenizer;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE\n** statement has specified that the tokenizer for this table shall consider\n** all characters in string zIn/nIn to be separators (if bAlnum==0) or\n** token characters (if bAlnum==1).\n**\n** For each codepoint in the zIn/nIn string, this function checks if the\n** sqlite3FtsUnicodeIsalnum() function already returns the desired result.\n** If so, no action is taken. Otherwise, the codepoint is added to the \n** unicode_tokenizer.aiException[] array. For the purposes of tokenization,\n** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all\n** codepoints in the aiException[] array.\n**\n** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic()\n** identifies as a diacritic) occurs in the zIn/nIn string it is ignored.\n** It is not possible to change the behavior of the tokenizer with respect\n** to these codepoints.\n*/\nstatic int unicodeAddExceptions(\n  unicode_tokenizer *p,           /* Tokenizer to add exceptions to */\n  int bAlnum,                     /* Replace Isalnum() return value with this */\n  const char *zIn,                /* Array of characters to make exceptions */\n  int nIn                         /* Length of z in bytes */\n){\n  const unsigned char *z = (const unsigned char *)zIn;\n  const unsigned char *zTerm = &z[nIn];\n  unsigned int iCode;\n  int nEntry = 0;\n\n  assert( bAlnum==0 || bAlnum==1 );\n\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    assert( (sqlite3FtsUnicodeIsalnum((int)iCode) & 0xFFFFFFFE)==0 );\n    if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n     && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0 \n    ){\n      nEntry++;\n    }\n  }\n\n  if( nEntry ){\n    int *aNew;                    /* New aiException[] array */\n    int nNew;                     /* Number of valid entries in array aNew[] */\n\n    aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    nNew = p->nException;\n\n    z = (const unsigned char *)zIn;\n    while( z<zTerm ){\n      READ_UTF8(z, zTerm, iCode);\n      if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n       && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0\n      ){\n        int i, j;\n        for(i=0; i<nNew && aNew[i]<(int)iCode; i++);\n        for(j=nNew; j>i; j--) aNew[j] = aNew[j-1];\n        aNew[i] = (int)iCode;\n        nNew++;\n      }\n    }\n    p->aiException = aNew;\n    p->nException = nNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int unicodeIsException(unicode_tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Return true if, for the purposes of tokenization, codepoint iCode is\n** considered a token character (not a separator).\n*/\nstatic int unicodeIsAlnum(unicode_tokenizer *p, int iCode){\n  assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3FtsUnicodeIsalnum(iCode) ^ unicodeIsException(p, iCode);\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int unicodeCreate(\n  int nArg,                       /* Size of array argv[] */\n  const char * const *azArg,      /* Tokenizer creation arguments */\n  sqlite3_tokenizer **pp          /* OUT: New tokenizer handle */\n){\n  unicode_tokenizer *pNew;        /* New tokenizer object */\n  int i;\n  int rc = SQLITE_OK;\n\n  pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));\n  if( pNew==NULL ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(unicode_tokenizer));\n  pNew->bRemoveDiacritic = 1;\n\n  for(i=0; rc==SQLITE_OK && i<nArg; i++){\n    const char *z = azArg[i];\n    int n = (int)strlen(z);\n\n    if( n==19 && memcmp(\"remove_diacritics=1\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 1;\n    }\n    else if( n==19 && memcmp(\"remove_diacritics=0\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 0;\n    }\n    else if( n>=11 && memcmp(\"tokenchars=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);\n    }\n    else if( n>=11 && memcmp(\"separators=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 0, &z[11], n-11);\n    }\n    else{\n      /* Unrecognized argument */\n      rc  = SQLITE_ERROR;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    unicodeDestroy((sqlite3_tokenizer *)pNew);\n    pNew = 0;\n  }\n  *pp = (sqlite3_tokenizer *)pNew;\n  return rc;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int unicodeOpen(\n  sqlite3_tokenizer *p,           /* The tokenizer */\n  const char *aInput,             /* Input string */\n  int nInput,                     /* Size of string aInput in bytes */\n  sqlite3_tokenizer_cursor **pp   /* OUT: New cursor object */\n){\n  unicode_cursor *pCsr;\n\n  pCsr = (unicode_cursor *)sqlite3_malloc(sizeof(unicode_cursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(unicode_cursor));\n\n  pCsr->aInput = (const unsigned char *)aInput;\n  if( aInput==0 ){\n    pCsr->nInput = 0;\n  }else if( nInput<0 ){\n    pCsr->nInput = (int)strlen(aInput);\n  }else{\n    pCsr->nInput = nInput;\n  }\n\n  *pp = &pCsr->base;\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int unicodeClose(sqlite3_tokenizer_cursor *pCursor){\n  unicode_cursor *pCsr = (unicode_cursor *) pCursor;\n  sqlite3_free(pCsr->zToken);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int unicodeNext(\n  sqlite3_tokenizer_cursor *pC,   /* Cursor returned by simpleOpen */\n  const char **paToken,           /* OUT: Token text */\n  int *pnToken,                   /* OUT: Number of bytes at *paToken */\n  int *piStart,                   /* OUT: Starting offset of token */\n  int *piEnd,                     /* OUT: Ending offset of token */\n  int *piPos                      /* OUT: Position integer of token */\n){\n  unicode_cursor *pCsr = (unicode_cursor *)pC;\n  unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer);\n  unsigned int iCode = 0;\n  char *zOut;\n  const unsigned char *z = &pCsr->aInput[pCsr->iOff];\n  const unsigned char *zStart = z;\n  const unsigned char *zEnd;\n  const unsigned char *zTerm = &pCsr->aInput[pCsr->nInput];\n\n  /* Scan past any delimiter characters before the start of the next token.\n  ** Return SQLITE_DONE early if this takes us all the way to the end of \n  ** the input.  */\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    if( unicodeIsAlnum(p, (int)iCode) ) break;\n    zStart = z;\n  }\n  if( zStart>=zTerm ) return SQLITE_DONE;\n\n  zOut = pCsr->zToken;\n  do {\n    int iOut;\n\n    /* Grow the output buffer if required. */\n    if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){\n      char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);\n      if( !zNew ) return SQLITE_NOMEM;\n      zOut = &zNew[zOut - pCsr->zToken];\n      pCsr->zToken = zNew;\n      pCsr->nAlloc += 64;\n    }\n\n    /* Write the folded case of the last character read to the output */\n    zEnd = z;\n    iOut = sqlite3FtsUnicodeFold((int)iCode, p->bRemoveDiacritic);\n    if( iOut ){\n      WRITE_UTF8(zOut, iOut);\n    }\n\n    /* If the cursor is not at EOF, read the next character */\n    if( z>=zTerm ) break;\n    READ_UTF8(z, zTerm, iCode);\n  }while( unicodeIsAlnum(p, (int)iCode) \n       || sqlite3FtsUnicodeIsdiacritic((int)iCode)\n  );\n\n  /* Set the output variables and return. */\n  pCsr->iOff = (int)(z - pCsr->aInput);\n  *paToken = pCsr->zToken;\n  *pnToken = (int)(zOut - pCsr->zToken);\n  *piStart = (int)(zStart - pCsr->aInput);\n  *piEnd = (int)(zEnd - pCsr->aInput);\n  *piPos = pCsr->iToken++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppModule to a pointer to the sqlite3_tokenizer_module \n** structure for the unicode tokenizer.\n*/\nvoid sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const **ppModule){\n  static const sqlite3_tokenizer_module module = {\n    0,\n    unicodeCreate,\n    unicodeDestroy,\n    unicodeOpen,\n    unicodeClose,\n    unicodeNext,\n    0,\n  };\n  *ppModule = &module;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n#endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_unicode2.c",
    "content": "/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n\n#include <assert.h>\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nint sqlite3FtsUnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  static const unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,\n    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,\n    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,\n    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,\n    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,\n    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,\n    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,\n    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,\n    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,\n    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,\n    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,\n    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,\n    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,\n    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,\n    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,\n    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,\n    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,\n    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,\n    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,\n    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,\n    0x380400F0,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int remove_diacritic(int c){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3896,  3912,  3928, \n     3968,  4008,  4040,  4106,  4138,  4170,  4202,  4234, \n     4266,  4296,  4312,  4344,  4408,  4424,  4472,  4504, \n     6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529, \n    61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, \n    61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, \n    62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, \n    62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, \n    62924, 63050, 63082, 63274, 63390, \n  };\n  char aChar[] = {\n    '\\0', 'a',  'c',  'e',  'i',  'n',  'o',  'u',  'y',  'y',  'a',  'c',  \n    'd',  'e',  'e',  'g',  'h',  'i',  'j',  'k',  'l',  'n',  'o',  'r',  \n    's',  't',  'u',  'u',  'w',  'y',  'z',  'o',  'u',  'a',  'i',  'o',  \n    'u',  'g',  'k',  'o',  'j',  'g',  'n',  'a',  'e',  'i',  'o',  'r',  \n    'u',  's',  't',  'h',  'a',  'e',  'o',  'y',  '\\0', '\\0', '\\0', '\\0', \n    '\\0', '\\0', '\\0', '\\0', 'a',  'b',  'd',  'd',  'e',  'f',  'g',  'h',  \n    'h',  'i',  'k',  'l',  'l',  'm',  'n',  'p',  'r',  'r',  's',  't',  \n    'u',  'v',  'w',  'w',  'x',  'y',  'z',  'h',  't',  'w',  'y',  'a',  \n    'e',  'i',  'o',  'u',  'y',  \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nint sqlite3FtsUnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & (1 << (c-768))) :\n      (mask1 & (1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nint sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( bRemoveDiacritic ) ret = remove_diacritic(ret);\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */\n#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3_write.c",
    "content": "/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is part of the SQLite FTS3 extension module. Specifically,\n** this file contains code to insert, update and delete rows from FTS3\n** tables. It also contains code to merge FTS3 b-tree segments. Some\n** of the sub-routines used to merge segments are also used by the query \n** code in fts3.c.\n*/\n\n#include \"fts3Int.h\"\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#include <string.h>\n#include <assert.h>\n#include <stdlib.h>\n\n\n#define FTS_MAX_APPENDABLE_HEIGHT 16\n\n/*\n** When full-text index nodes are loaded from disk, the buffer that they\n** are loaded into has the following number of bytes of padding at the end \n** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer\n** of 920 bytes is allocated for it.\n**\n** This means that if we have a pointer into a buffer containing node data,\n** it is always safe to read up to two varints from it without risking an\n** overread, even if the node data is corrupted.\n*/\n#define FTS3_NODE_PADDING (FTS3_VARINT_MAX*2)\n\n/*\n** Under certain circumstances, b-tree nodes (doclists) can be loaded into\n** memory incrementally instead of all at once. This can be a big performance\n** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()\n** method before retrieving all query results (as may happen, for example,\n** if a query has a LIMIT clause).\n**\n** Incremental loading is used for b-tree nodes FTS3_NODE_CHUNK_THRESHOLD \n** bytes and larger. Nodes are loaded in chunks of FTS3_NODE_CHUNKSIZE bytes.\n** The code is written so that the hard lower-limit for each of these values \n** is 1. Clearly such small values would be inefficient, but can be useful \n** for testing purposes.\n**\n** If this module is built with SQLITE_TEST defined, these constants may\n** be overridden at runtime for testing purposes. File fts3_test.c contains\n** a Tcl interface to read and write the values.\n*/\n#ifdef SQLITE_TEST\nint test_fts3_node_chunksize = (4*1024);\nint test_fts3_node_chunk_threshold = (4*1024)*4;\n# define FTS3_NODE_CHUNKSIZE       test_fts3_node_chunksize\n# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold\n#else\n# define FTS3_NODE_CHUNKSIZE (4*1024) \n# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)\n#endif\n\n/*\n** The two values that may be meaningfully bound to the :1 parameter in\n** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.\n*/\n#define FTS_STAT_DOCTOTAL      0\n#define FTS_STAT_INCRMERGEHINT 1\n#define FTS_STAT_AUTOINCRMERGE 2\n\n/*\n** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic\n** and incremental merge operation that takes place. This is used for \n** debugging FTS only, it should not usually be turned on in production\n** systems.\n*/\n#ifdef FTS3_LOG_MERGES\nstatic void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){\n  sqlite3_log(SQLITE_OK, \"%d-way merge from level %d\", nMerge, (int)iAbsLevel);\n}\n#else\n#define fts3LogMerge(x, y)\n#endif\n\n\ntypedef struct PendingList PendingList;\ntypedef struct SegmentNode SegmentNode;\ntypedef struct SegmentWriter SegmentWriter;\n\n/*\n** An instance of the following data structure is used to build doclists\n** incrementally. See function fts3PendingListAppend() for details.\n*/\nstruct PendingList {\n  int nData;\n  char *aData;\n  int nSpace;\n  sqlite3_int64 iLastDocid;\n  sqlite3_int64 iLastCol;\n  sqlite3_int64 iLastPos;\n};\n\n\n/*\n** Each cursor has a (possibly empty) linked list of the following objects.\n*/\nstruct Fts3DeferredToken {\n  Fts3PhraseToken *pToken;        /* Pointer to corresponding expr token */\n  int iCol;                       /* Column token must occur in */\n  Fts3DeferredToken *pNext;       /* Next in list of deferred tokens */\n  PendingList *pList;             /* Doclist is assembled here */\n};\n\n/*\n** An instance of this structure is used to iterate through the terms on\n** a contiguous set of segment b-tree leaf nodes. Although the details of\n** this structure are only manipulated by code in this file, opaque handles\n** of type Fts3SegReader* are also used by code in fts3.c to iterate through\n** terms when querying the full-text index. See functions:\n**\n**   sqlite3Fts3SegReaderNew()\n**   sqlite3Fts3SegReaderFree()\n**   sqlite3Fts3SegReaderIterate()\n**\n** Methods used to manipulate Fts3SegReader structures:\n**\n**   fts3SegReaderNext()\n**   fts3SegReaderFirstDocid()\n**   fts3SegReaderNextDocid()\n*/\nstruct Fts3SegReader {\n  int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */\n  u8 bLookup;                     /* True for a lookup only */\n  u8 rootOnly;                    /* True for a root-only reader */\n\n  sqlite3_int64 iStartBlock;      /* Rowid of first leaf block to traverse */\n  sqlite3_int64 iLeafEndBlock;    /* Rowid of final leaf block to traverse */\n  sqlite3_int64 iEndBlock;        /* Rowid of final block in segment (or 0) */\n  sqlite3_int64 iCurrentBlock;    /* Current leaf block (or 0) */\n\n  char *aNode;                    /* Pointer to node data (or NULL) */\n  int nNode;                      /* Size of buffer at aNode (or 0) */\n  int nPopulate;                  /* If >0, bytes of buffer aNode[] loaded */\n  sqlite3_blob *pBlob;            /* If not NULL, blob handle to read node */\n\n  Fts3HashElem **ppNextElem;\n\n  /* Variables set by fts3SegReaderNext(). These may be read directly\n  ** by the caller. They are valid from the time SegmentReaderNew() returns\n  ** until SegmentReaderNext() returns something other than SQLITE_OK\n  ** (i.e. SQLITE_DONE).\n  */\n  int nTerm;                      /* Number of bytes in current term */\n  char *zTerm;                    /* Pointer to current term */\n  int nTermAlloc;                 /* Allocated size of zTerm buffer */\n  char *aDoclist;                 /* Pointer to doclist of current entry */\n  int nDoclist;                   /* Size of doclist in current entry */\n\n  /* The following variables are used by fts3SegReaderNextDocid() to iterate \n  ** through the current doclist (aDoclist/nDoclist).\n  */\n  char *pOffsetList;\n  int nOffsetList;                /* For descending pending seg-readers only */\n  sqlite3_int64 iDocid;\n};\n\n#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)\n#define fts3SegReaderIsRootOnly(p) ((p)->rootOnly!=0)\n\n/*\n** An instance of this structure is used to create a segment b-tree in the\n** database. The internal details of this type are only accessed by the\n** following functions:\n**\n**   fts3SegWriterAdd()\n**   fts3SegWriterFlush()\n**   fts3SegWriterFree()\n*/\nstruct SegmentWriter {\n  SegmentNode *pTree;             /* Pointer to interior tree structure */\n  sqlite3_int64 iFirst;           /* First slot in %_segments written */\n  sqlite3_int64 iFree;            /* Next free slot in %_segments */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nSize;                      /* Size of allocation at aData */\n  int nData;                      /* Bytes of data in aData */\n  char *aData;                    /* Pointer to block from malloc() */\n  i64 nLeafData;                  /* Number of bytes of leaf data written */\n};\n\n/*\n** Type SegmentNode is used by the following three functions to create\n** the interior part of the segment b+-tree structures (everything except\n** the leaf nodes). These functions and type are only ever used by code\n** within the fts3SegWriterXXX() family of functions described above.\n**\n**   fts3NodeAddTerm()\n**   fts3NodeWrite()\n**   fts3NodeFree()\n**\n** When a b+tree is written to the database (either as a result of a merge\n** or the pending-terms table being flushed), leaves are written into the \n** database file as soon as they are completely populated. The interior of\n** the tree is assembled in memory and written out only once all leaves have\n** been populated and stored. This is Ok, as the b+-tree fanout is usually\n** very large, meaning that the interior of the tree consumes relatively \n** little memory.\n*/\nstruct SegmentNode {\n  SegmentNode *pParent;           /* Parent node (or NULL for root node) */\n  SegmentNode *pRight;            /* Pointer to right-sibling */\n  SegmentNode *pLeftmost;         /* Pointer to left-most node of this depth */\n  int nEntry;                     /* Number of terms written to node so far */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nData;                      /* Bytes of valid data so far */\n  char *aData;                    /* Node data */\n};\n\n/*\n** Valid values for the second argument to fts3SqlStmt().\n*/\n#define SQL_DELETE_CONTENT             0\n#define SQL_IS_EMPTY                   1\n#define SQL_DELETE_ALL_CONTENT         2 \n#define SQL_DELETE_ALL_SEGMENTS        3\n#define SQL_DELETE_ALL_SEGDIR          4\n#define SQL_DELETE_ALL_DOCSIZE         5\n#define SQL_DELETE_ALL_STAT            6\n#define SQL_SELECT_CONTENT_BY_ROWID    7\n#define SQL_NEXT_SEGMENT_INDEX         8\n#define SQL_INSERT_SEGMENTS            9\n#define SQL_NEXT_SEGMENTS_ID          10\n#define SQL_INSERT_SEGDIR             11\n#define SQL_SELECT_LEVEL              12\n#define SQL_SELECT_LEVEL_RANGE        13\n#define SQL_SELECT_LEVEL_COUNT        14\n#define SQL_SELECT_SEGDIR_MAX_LEVEL   15\n#define SQL_DELETE_SEGDIR_LEVEL       16\n#define SQL_DELETE_SEGMENTS_RANGE     17\n#define SQL_CONTENT_INSERT            18\n#define SQL_DELETE_DOCSIZE            19\n#define SQL_REPLACE_DOCSIZE           20\n#define SQL_SELECT_DOCSIZE            21\n#define SQL_SELECT_STAT               22\n#define SQL_REPLACE_STAT              23\n\n#define SQL_SELECT_ALL_PREFIX_LEVEL   24\n#define SQL_DELETE_ALL_TERMS_SEGDIR   25\n#define SQL_DELETE_SEGDIR_RANGE       26\n#define SQL_SELECT_ALL_LANGID         27\n#define SQL_FIND_MERGE_LEVEL          28\n#define SQL_MAX_LEAF_NODE_ESTIMATE    29\n#define SQL_DELETE_SEGDIR_ENTRY       30\n#define SQL_SHIFT_SEGDIR_ENTRY        31\n#define SQL_SELECT_SEGDIR             32\n#define SQL_CHOMP_SEGDIR              33\n#define SQL_SEGMENT_IS_APPENDABLE     34\n#define SQL_SELECT_INDEXES            35\n#define SQL_SELECT_MXLEVEL            36\n\n#define SQL_SELECT_LEVEL_RANGE2       37\n#define SQL_UPDATE_LEVEL_IDX          38\n#define SQL_UPDATE_LEVEL              39\n\n/*\n** This function is used to obtain an SQLite prepared statement handle\n** for the statement identified by the second argument. If successful,\n** *pp is set to the requested statement handle and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned and *pp is set to 0.\n**\n** If argument apVal is not NULL, then it must point to an array with\n** at least as many entries as the requested statement has bound \n** parameters. The values are bound to the statements parameters before\n** returning.\n*/\nstatic int fts3SqlStmt(\n  Fts3Table *p,                   /* Virtual table handle */\n  int eStmt,                      /* One of the SQL_XXX constants above */\n  sqlite3_stmt **pp,              /* OUT: Statement handle */\n  sqlite3_value **apVal           /* Values to bind to statement */\n){\n  const char *azSql[] = {\n/* 0  */  \"DELETE FROM %Q.'%q_content' WHERE rowid = ?\",\n/* 1  */  \"SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)\",\n/* 2  */  \"DELETE FROM %Q.'%q_content'\",\n/* 3  */  \"DELETE FROM %Q.'%q_segments'\",\n/* 4  */  \"DELETE FROM %Q.'%q_segdir'\",\n/* 5  */  \"DELETE FROM %Q.'%q_docsize'\",\n/* 6  */  \"DELETE FROM %Q.'%q_stat'\",\n/* 7  */  \"SELECT %s WHERE rowid=?\",\n/* 8  */  \"SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1\",\n/* 9  */  \"REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)\",\n/* 10 */  \"SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)\",\n/* 11 */  \"REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 12 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC\",\n/* 13 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\"\n            \"ORDER BY level DESC, idx ASC\",\n\n/* 14 */  \"SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 15 */  \"SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n\n/* 16 */  \"DELETE FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 17 */  \"DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?\",\n/* 18 */  \"INSERT INTO %Q.'%q_content' VALUES(%s)\",\n/* 19 */  \"DELETE FROM %Q.'%q_docsize' WHERE docid = ?\",\n/* 20 */  \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",\n/* 21 */  \"SELECT size FROM %Q.'%q_docsize' WHERE docid=?\",\n/* 22 */  \"SELECT value FROM %Q.'%q_stat' WHERE id=?\",\n/* 23 */  \"REPLACE INTO %Q.'%q_stat' VALUES(?,?)\",\n/* 24 */  \"\",\n/* 25 */  \"\",\n\n/* 26 */ \"DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n/* 27 */ \"SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'\",\n\n/* This statement is used to determine which level to read the input from\n** when performing an incremental merge. It returns the absolute level number\n** of the oldest level in the db that contains at least ? segments. Or,\n** if no level in the FTS index contains more than ? segments, the statement\n** returns zero rows.  */\n/* 28 */ \"SELECT level, count(*) AS cnt FROM %Q.'%q_segdir' \"\n         \"  GROUP BY level HAVING cnt>=?\"\n         \"  ORDER BY (level %% 1024) ASC LIMIT 1\",\n\n/* Estimate the upper limit on the number of leaf nodes in a new segment\n** created by merging the oldest :2 segments from absolute level :1. See \n** function sqlite3Fts3Incrmerge() for details.  */\n/* 29 */ \"SELECT 2 * total(1 + leaves_end_block - start_block) \"\n         \"  FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?\",\n\n/* SQL_DELETE_SEGDIR_ENTRY\n**   Delete the %_segdir entry on absolute level :1 with index :2.  */\n/* 30 */ \"DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_SHIFT_SEGDIR_ENTRY\n**   Modify the idx value for the segment with idx=:3 on absolute level :2\n**   to :1.  */\n/* 31 */ \"UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?\",\n\n/* SQL_SELECT_SEGDIR\n**   Read a single entry from the %_segdir table. The entry from absolute \n**   level :1 with index value :2.  */\n/* 32 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_CHOMP_SEGDIR\n**   Update the start_block (:1) and root (:2) fields of the %_segdir\n**   entry located on absolute level :3 with index :4.  */\n/* 33 */  \"UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?\"\n            \"WHERE level = ? AND idx = ?\",\n\n/* SQL_SEGMENT_IS_APPENDABLE\n**   Return a single row if the segment with end_block=? is appendable. Or\n**   no rows otherwise.  */\n/* 34 */  \"SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL\",\n\n/* SQL_SELECT_INDEXES\n**   Return the list of valid segment indexes for absolute level ?  */\n/* 35 */  \"SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC\",\n\n/* SQL_SELECT_MXLEVEL\n**   Return the largest relative level in the FTS index or indexes.  */\n/* 36 */  \"SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 37 */  \"SELECT level, idx, end_block \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ? \"\n            \"ORDER BY level DESC, idx ASC\",\n\n          /* Update statements used while promoting segments */\n/* 38 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=-1,idx=? \"\n            \"WHERE level=? AND idx=?\",\n/* 39 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=? WHERE level=-1\"\n\n  };\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt;\n\n  assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );\n  assert( eStmt<SizeofArray(azSql) && eStmt>=0 );\n  \n  pStmt = p->aStmt[eStmt];\n  if( !pStmt ){\n    char *zSql;\n    if( eStmt==SQL_CONTENT_INSERT ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);\n    }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);\n    }else{\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);\n    }\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,\n                              &pStmt, NULL);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pStmt==0 );\n      p->aStmt[eStmt] = pStmt;\n    }\n  }\n  if( apVal ){\n    int i;\n    int nParam = sqlite3_bind_parameter_count(pStmt);\n    for(i=0; rc==SQLITE_OK && i<nParam; i++){\n      rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);\n    }\n  }\n  *pp = pStmt;\n  return rc;\n}\n\n\nstatic int fts3SelectDocsize(\n  Fts3Table *pTab,                /* FTS3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to bind for SQL_SELECT_DOCSIZE */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;        /* Statement requested from fts3SqlStmt() */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iDocid);\n    rc = sqlite3_step(pStmt);\n    if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n\n  *ppStmt = pStmt;\n  return rc;\n}\n\nint sqlite3Fts3SelectDoctotal(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n    if( sqlite3_step(pStmt)!=SQLITE_ROW\n     || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB\n    ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\nint sqlite3Fts3SelectDocsize(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to read size data for */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  return fts3SelectDocsize(pTab, iDocid, ppStmt);\n}\n\n/*\n** Similar to fts3SqlStmt(). Except, after binding the parameters in\n** array apVal[] to the SQL statement identified by eStmt, the statement\n** is executed.\n**\n** Returns SQLITE_OK if the statement is successfully executed, or an\n** SQLite error code otherwise.\n*/\nstatic void fts3SqlExec(\n  int *pRC,                /* Result code */\n  Fts3Table *p,            /* The FTS3 table */\n  int eStmt,               /* Index of statement to evaluate */\n  sqlite3_value **apVal    /* Parameters to bind */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, eStmt, &pStmt, apVal); \n  if( rc==SQLITE_OK ){\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  *pRC = rc;\n}\n\n\n/*\n** This function ensures that the caller has obtained an exclusive \n** shared-cache table-lock on the %_segdir table. This is required before \n** writing data to the fts3 table. If this lock is not acquired first, then\n** the caller may end up attempting to take this lock as part of committing\n** a transaction, causing SQLite to return SQLITE_LOCKED or \n** LOCKED_SHAREDCACHEto a COMMIT command.\n**\n** It is best to avoid this because if FTS3 returns any error when \n** committing a transaction, the whole transaction will be rolled back. \n** And this is not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. \n** It can still happen if the user locks the underlying tables directly \n** instead of accessing them via FTS.\n*/\nstatic int fts3Writelock(Fts3Table *p){\n  int rc = SQLITE_OK;\n  \n  if( p->nPendingData==0 ){\n    sqlite3_stmt *pStmt;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pStmt, 1);\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** FTS maintains a separate indexes for each language-id (a 32-bit integer).\n** Within each language id, a separate index is maintained to store the\n** document terms, and each configured prefix size (configured the FTS \n** \"prefix=\" option). And each index consists of multiple levels (\"relative\n** levels\").\n**\n** All three of these values (the language id, the specific index and the\n** level within the index) are encoded in 64-bit integer values stored\n** in the %_segdir table on disk. This function is used to convert three\n** separate component values into the single 64-bit integer value that\n** can be used to query the %_segdir table.\n**\n** Specifically, each language-id/index combination is allocated 1024 \n** 64-bit integer level values (\"absolute levels\"). The main terms index\n** for language-id 0 is allocate values 0-1023. The first prefix index\n** (if any) for language-id 0 is allocated values 1024-2047. And so on.\n** Language 1 indexes are allocated immediately following language 0.\n**\n** So, for a system with nPrefix prefix indexes configured, the block of\n** absolute levels that corresponds to language-id iLangid and index \n** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).\n*/\nstatic sqlite3_int64 getAbsoluteLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index in p->aIndex[] */\n  int iLevel                      /* Level of segments */\n){\n  sqlite3_int64 iBase;            /* First absolute level for iLangid/iIndex */\n  assert( iLangid>=0 );\n  assert( p->nIndex>0 );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;\n  return iBase + iLevel;\n}\n\n/*\n** Set *ppStmt to a statement handle that may be used to iterate through\n** all rows in the %_segdir table, from oldest to newest. If successful,\n** return SQLITE_OK. If an error occurs while preparing the statement, \n** return an SQLite error code.\n**\n** There is only ever one instance of this SQL statement compiled for\n** each FTS3 table.\n**\n** The statement returns the following columns from the %_segdir table:\n**\n**   0: idx\n**   1: start_block\n**   2: leaves_end_block\n**   3: end_block\n**   4: root\n*/\nint sqlite3Fts3AllSegdirs(\n  Fts3Table *p,                   /* FTS3 table */\n  int iLangid,                    /* Language being queried */\n  int iIndex,                     /* Index for p->aIndex[] */\n  int iLevel,                     /* Level to select (relative level) */\n  sqlite3_stmt **ppStmt           /* OUT: Compiled statement */\n){\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL || iLevel>=0 );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  if( iLevel<0 ){\n    /* \"SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pStmt, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    /* \"SELECT * FROM %_segdir WHERE level = ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\n\n/*\n** Append a single varint to a PendingList buffer. SQLITE_OK is returned\n** if successful, or an SQLite error code otherwise.\n**\n** This function also serves to allocate the PendingList structure itself.\n** For example, to create a new PendingList structure containing two\n** varints:\n**\n**   PendingList *p = 0;\n**   fts3PendingListAppendVarint(&p, 1);\n**   fts3PendingListAppendVarint(&p, 2);\n*/\nstatic int fts3PendingListAppendVarint(\n  PendingList **pp,               /* IN/OUT: Pointer to PendingList struct */\n  sqlite3_int64 i                 /* Value to append to data */\n){\n  PendingList *p = *pp;\n\n  /* Allocate or grow the PendingList as required. */\n  if( !p ){\n    p = sqlite3_malloc(sizeof(*p) + 100);\n    if( !p ){\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = 100;\n    p->aData = (char *)&p[1];\n    p->nData = 0;\n  }\n  else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){\n    int nNew = p->nSpace * 2;\n    p = sqlite3_realloc(p, sizeof(*p) + nNew);\n    if( !p ){\n      sqlite3_free(*pp);\n      *pp = 0;\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = nNew;\n    p->aData = (char *)&p[1];\n  }\n\n  /* Append the new serialized varint to the end of the list. */\n  p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i);\n  p->aData[p->nData] = '\\0';\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** Add a docid/column/position entry to a PendingList structure. Non-zero\n** is returned if the structure is sqlite3_realloced as part of adding\n** the entry. Otherwise, zero.\n**\n** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.\n** Zero is always returned in this case. Otherwise, if no OOM error occurs,\n** it is set to SQLITE_OK.\n*/\nstatic int fts3PendingListAppend(\n  PendingList **pp,               /* IN/OUT: PendingList structure */\n  sqlite3_int64 iDocid,           /* Docid for entry to add */\n  sqlite3_int64 iCol,             /* Column for entry to add */\n  sqlite3_int64 iPos,             /* Position of term for entry to add */\n  int *pRc                        /* OUT: Return code */\n){\n  PendingList *p = *pp;\n  int rc = SQLITE_OK;\n\n  assert( !p || p->iLastDocid<=iDocid );\n\n  if( !p || p->iLastDocid!=iDocid ){\n    sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);\n    if( p ){\n      assert( p->nData<p->nSpace );\n      assert( p->aData[p->nData]==0 );\n      p->nData++;\n    }\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = -1;\n    p->iLastPos = 0;\n    p->iLastDocid = iDocid;\n  }\n  if( iCol>0 && p->iLastCol!=iCol ){\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))\n     || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))\n    ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = iCol;\n    p->iLastPos = 0;\n  }\n  if( iCol>=0 ){\n    assert( iPos>p->iLastPos || (iPos==0 && p->iLastPos==0) );\n    rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);\n    if( rc==SQLITE_OK ){\n      p->iLastPos = iPos;\n    }\n  }\n\n pendinglistappend_out:\n  *pRc = rc;\n  if( p!=*pp ){\n    *pp = p;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Free a PendingList object allocated by fts3PendingListAppend().\n*/\nstatic void fts3PendingListDelete(PendingList *pList){\n  sqlite3_free(pList);\n}\n\n/*\n** Add an entry to one of the pending-terms hash tables.\n*/\nstatic int fts3PendingTermsAddOne(\n  Fts3Table *p,\n  int iCol,\n  int iPos,\n  Fts3Hash *pHash,                /* Pending terms hash table to add entry to */\n  const char *zToken,\n  int nToken\n){\n  PendingList *pList;\n  int rc = SQLITE_OK;\n\n  pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);\n  if( pList ){\n    p->nPendingData -= (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){\n    if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){\n      /* Malloc failed while inserting the new entry. This can only \n      ** happen if there was no previous entry for this token.\n      */\n      assert( 0==fts3HashFind(pHash, zToken, nToken) );\n      sqlite3_free(pList);\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    p->nPendingData += (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  return rc;\n}\n\n/*\n** Tokenize the nul-terminated string zText and add all tokens to the\n** pending-terms hash-table. The docid used is that currently stored in\n** p->iPrevDocid, and the column is specified by argument iCol.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3PendingTermsAdd(\n  Fts3Table *p,                   /* Table into which text will be inserted */\n  int iLangid,                    /* Language id to use */\n  const char *zText,              /* Text of document to be inserted */\n  int iCol,                       /* Column into which text is being inserted */\n  u32 *pnWord                     /* IN/OUT: Incr. by number tokens inserted */\n){\n  int rc;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int nWord = 0;\n\n  char const *zToken;\n  int nToken = 0;\n\n  sqlite3_tokenizer *pTokenizer = p->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr;\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n      const char**,int*,int*,int*,int*);\n\n  assert( pTokenizer && pModule );\n\n  /* If the user has inserted a NULL value, this function may be called with\n  ** zText==0. In this case, add zero token entries to the hash table and \n  ** return early. */\n  if( zText==0 ){\n    *pnWord = 0;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, iLangid, zText, -1, &pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  xNext = pModule->xNext;\n  while( SQLITE_OK==rc\n      && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))\n  ){\n    int i;\n    if( iPos>=nWord ) nWord = iPos+1;\n\n    /* Positions cannot be negative; we use -1 as a terminator internally.\n    ** Tokens must have a non-zero length.\n    */\n    if( iPos<0 || !zToken || nToken<=0 ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    /* Add the term to the terms index */\n    rc = fts3PendingTermsAddOne(\n        p, iCol, iPos, &p->aIndex[0].hPending, zToken, nToken\n    );\n    \n    /* Add the term to each of the prefix indexes that it is not too \n    ** short for. */\n    for(i=1; rc==SQLITE_OK && i<p->nIndex; i++){\n      struct Fts3Index *pIndex = &p->aIndex[i];\n      if( nToken<pIndex->nPrefix ) continue;\n      rc = fts3PendingTermsAddOne(\n          p, iCol, iPos, &pIndex->hPending, zToken, pIndex->nPrefix\n      );\n    }\n  }\n\n  pModule->xClose(pCsr);\n  *pnWord += nWord;\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/* \n** Calling this function indicates that subsequent calls to \n** fts3PendingTermsAdd() are to add term/position-list pairs for the\n** contents of the document with docid iDocid.\n*/\nstatic int fts3PendingTermsDocid(\n  Fts3Table *p,                   /* Full-text table handle */\n  int bDelete,                    /* True if this op is a delete */\n  int iLangid,                    /* Language id of row being written */\n  sqlite_int64 iDocid             /* Docid of row being written */\n){\n  assert( iLangid>=0 );\n  assert( bDelete==1 || bDelete==0 );\n\n  /* TODO(shess) Explore whether partially flushing the buffer on\n  ** forced-flush would provide better performance.  I suspect that if\n  ** we ordered the doclists by size and flushed the largest until the\n  ** buffer was half empty, that would let the less frequent terms\n  ** generate longer doclists.\n  */\n  if( iDocid<p->iPrevDocid \n   || (iDocid==p->iPrevDocid && p->bPrevDelete==0)\n   || p->iPrevLangid!=iLangid\n   || p->nPendingData>p->nMaxPendingData \n  ){\n    int rc = sqlite3Fts3PendingTermsFlush(p);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  p->iPrevDocid = iDocid;\n  p->iPrevLangid = iLangid;\n  p->bPrevDelete = bDelete;\n  return SQLITE_OK;\n}\n\n/*\n** Discard the contents of the pending-terms hash tables. \n*/\nvoid sqlite3Fts3PendingTermsClear(Fts3Table *p){\n  int i;\n  for(i=0; i<p->nIndex; i++){\n    Fts3HashElem *pElem;\n    Fts3Hash *pHash = &p->aIndex[i].hPending;\n    for(pElem=fts3HashFirst(pHash); pElem; pElem=fts3HashNext(pElem)){\n      PendingList *pList = (PendingList *)fts3HashData(pElem);\n      fts3PendingListDelete(pList);\n    }\n    fts3HashClear(pHash);\n  }\n  p->nPendingData = 0;\n}\n\n/*\n** This function is called by the xUpdate() method as part of an INSERT\n** operation. It adds entries for each term in the new record to the\n** pendingTerms hash table.\n**\n** Argument apVal is the same as the similarly named argument passed to\n** fts3InsertData(). Parameter iDocid is the docid of the new row.\n*/\nstatic int fts3InsertTerms(\n  Fts3Table *p, \n  int iLangid, \n  sqlite3_value **apVal, \n  u32 *aSz\n){\n  int i;                          /* Iterator variable */\n  for(i=2; i<p->nColumn+2; i++){\n    int iCol = i-2;\n    if( p->abNotindexed[iCol]==0 ){\n      const char *zText = (const char *)sqlite3_value_text(apVal[i]);\n      int rc = fts3PendingTermsAdd(p, iLangid, zText, iCol, &aSz[iCol]);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is called by the xUpdate() method for an INSERT operation.\n** The apVal parameter is passed a copy of the apVal argument passed by\n** SQLite to the xUpdate() method. i.e:\n**\n**   apVal[0]                Not used for INSERT.\n**   apVal[1]                rowid\n**   apVal[2]                Left-most user-defined column\n**   ...\n**   apVal[p->nColumn+1]     Right-most user-defined column\n**   apVal[p->nColumn+2]     Hidden column with same name as table\n**   apVal[p->nColumn+3]     Hidden \"docid\" column (alias for rowid)\n**   apVal[p->nColumn+4]     Hidden languageid column\n*/\nstatic int fts3InsertData(\n  Fts3Table *p,                   /* Full-text table */\n  sqlite3_value **apVal,          /* Array of values to insert */\n  sqlite3_int64 *piDocid          /* OUT: Docid for row just inserted */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pContentInsert;   /* INSERT INTO %_content VALUES(...) */\n\n  if( p->zContentTbl ){\n    sqlite3_value *pRowid = apVal[p->nColumn+3];\n    if( sqlite3_value_type(pRowid)==SQLITE_NULL ){\n      pRowid = apVal[1];\n    }\n    if( sqlite3_value_type(pRowid)!=SQLITE_INTEGER ){\n      return SQLITE_CONSTRAINT;\n    }\n    *piDocid = sqlite3_value_int64(pRowid);\n    return SQLITE_OK;\n  }\n\n  /* Locate the statement handle used to insert data into the %_content\n  ** table. The SQL for this statement is:\n  **\n  **   INSERT INTO %_content VALUES(?, ?, ?, ...)\n  **\n  ** The statement features N '?' variables, where N is the number of user\n  ** defined columns in the FTS3 table, plus one for the docid field.\n  */\n  rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);\n  if( rc==SQLITE_OK && p->zLanguageid ){\n    rc = sqlite3_bind_int(\n        pContentInsert, p->nColumn+2, \n        sqlite3_value_int(apVal[p->nColumn+4])\n    );\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* There is a quirk here. The users INSERT statement may have specified\n  ** a value for the \"rowid\" field, for the \"docid\" field, or for both.\n  ** Which is a problem, since \"rowid\" and \"docid\" are aliases for the\n  ** same value. For example:\n  **\n  **   INSERT INTO fts3tbl(rowid, docid) VALUES(1, 2);\n  **\n  ** In FTS3, this is an error. It is an error to specify non-NULL values\n  ** for both docid and some other rowid alias.\n  */\n  if( SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) ){\n    if( SQLITE_NULL==sqlite3_value_type(apVal[0])\n     && SQLITE_NULL!=sqlite3_value_type(apVal[1])\n    ){\n      /* A rowid/docid conflict. */\n      return SQLITE_ERROR;\n    }\n    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* Execute the statement to insert the record. Set *piDocid to the \n  ** new docid value. \n  */\n  sqlite3_step(pContentInsert);\n  rc = sqlite3_reset(pContentInsert);\n\n  *piDocid = sqlite3_last_insert_rowid(p->db);\n  return rc;\n}\n\n\n\n/*\n** Remove all data from the FTS3 table. Clear the hash table containing\n** pending terms.\n*/\nstatic int fts3DeleteAll(Fts3Table *p, int bContent){\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* Discard the contents of the pending-terms hash table. */\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Delete everything from the shadow tables. Except, leave %_content as\n  ** is if bContent is false.  */\n  assert( p->zContentTbl==0 || bContent==0 );\n  if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0);\n  if( p->bHasDocsize ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_DOCSIZE, 0);\n  }\n  if( p->bHasStat ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_STAT, 0);\n  }\n  return rc;\n}\n\n/*\n**\n*/\nstatic int langidFromSelect(Fts3Table *p, sqlite3_stmt *pSelect){\n  int iLangid = 0;\n  if( p->zLanguageid ) iLangid = sqlite3_column_int(pSelect, p->nColumn+1);\n  return iLangid;\n}\n\n/*\n** The first element in the apVal[] array is assumed to contain the docid\n** (an integer) of a row about to be deleted. Remove all terms from the\n** full-text index.\n*/\nstatic void fts3DeleteTerms( \n  int *pRC,               /* Result code */\n  Fts3Table *p,           /* The FTS table to delete from */\n  sqlite3_value *pRowid,  /* The docid to be deleted */\n  u32 *aSz,               /* Sizes of deleted document written here */\n  int *pbFound            /* OUT: Set to true if row really does exist */\n){\n  int rc;\n  sqlite3_stmt *pSelect;\n\n  assert( *pbFound==0 );\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      int i;\n      int iLangid = langidFromSelect(p, pSelect);\n      i64 iDocid = sqlite3_column_int64(pSelect, 0);\n      rc = fts3PendingTermsDocid(p, 1, iLangid, iDocid);\n      for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){\n        int iCol = i-1;\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pSelect, i);\n          rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_reset(pSelect);\n        *pRC = rc;\n        return;\n      }\n      *pbFound = 1;\n    }\n    rc = sqlite3_reset(pSelect);\n  }else{\n    sqlite3_reset(pSelect);\n  }\n  *pRC = rc;\n}\n\n/*\n** Forward declaration to account for the circular dependency between\n** functions fts3SegmentMerge() and fts3AllocateSegdirIdx().\n*/\nstatic int fts3SegmentMerge(Fts3Table *, int, int, int);\n\n/* \n** This function allocates a new level iLevel index in the segdir table.\n** Usually, indexes are allocated within a level sequentially starting\n** with 0, so the allocated index is one greater than the value returned\n** by:\n**\n**   SELECT max(idx) FROM %_segdir WHERE level = :iLevel\n**\n** However, if there are already FTS3_MERGE_COUNT indexes at the requested\n** level, they are merged into a single level (iLevel+1) segment and the \n** allocated index is 0.\n**\n** If successful, *piIdx is set to the allocated index slot and SQLITE_OK\n** returned. Otherwise, an SQLite error code is returned.\n*/\nstatic int fts3AllocateSegdirIdx(\n  Fts3Table *p, \n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel, \n  int *piIdx\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pNextIdx;         /* Query for next idx at level iLevel */\n  int iNext = 0;                  /* Result of query pNextIdx */\n\n  assert( iLangid>=0 );\n  assert( p->nIndex>=1 );\n\n  /* Set variable iNext to the next available segdir index at level iLevel. */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(\n        pNextIdx, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n    );\n    if( SQLITE_ROW==sqlite3_step(pNextIdx) ){\n      iNext = sqlite3_column_int(pNextIdx, 0);\n    }\n    rc = sqlite3_reset(pNextIdx);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already\n    ** full, merge all segments in level iLevel into a single iLevel+1\n    ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,\n    ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.\n    */\n    if( iNext>=FTS3_MERGE_COUNT ){\n      fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));\n      rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);\n      *piIdx = 0;\n    }else{\n      *piIdx = iNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The %_segments table is declared as follows:\n**\n**   CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)\n**\n** This function reads data from a single row of the %_segments table. The\n** specific row is identified by the iBlockid parameter. If paBlob is not\n** NULL, then a buffer is allocated using sqlite3_malloc() and populated\n** with the contents of the blob stored in the \"block\" column of the \n** identified table row is. Whether or not paBlob is NULL, *pnBlob is set\n** to the size of the blob in bytes before returning.\n**\n** If an error occurs, or the table does not contain the specified row,\n** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If\n** paBlob is non-NULL, then it is the responsibility of the caller to\n** eventually free the returned buffer.\n**\n** This function may leave an open sqlite3_blob* handle in the\n** Fts3Table.pSegments variable. This handle is reused by subsequent calls\n** to this function. The handle may be closed by calling the\n** sqlite3Fts3SegmentsClose() function. Reusing a blob handle is a handy\n** performance improvement, but the blob handle should always be closed\n** before control is returned to the user (to prevent a lock being held\n** on the database file for longer than necessary). Thus, any virtual table\n** method (xFilter etc.) that may directly or indirectly call this function\n** must call sqlite3Fts3SegmentsClose() before returning.\n*/\nint sqlite3Fts3ReadBlock(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iBlockid,         /* Access the row with blockid=$iBlockid */\n  char **paBlob,                  /* OUT: Blob data in malloc'd buffer */\n  int *pnBlob,                    /* OUT: Size of blob data */\n  int *pnLoad                     /* OUT: Bytes actually loaded */\n){\n  int rc;                         /* Return code */\n\n  /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */\n  assert( pnBlob );\n\n  if( p->pSegments ){\n    rc = sqlite3_blob_reopen(p->pSegments, iBlockid);\n  }else{\n    if( 0==p->zSegmentsTbl ){\n      p->zSegmentsTbl = sqlite3_mprintf(\"%s_segments\", p->zName);\n      if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM;\n    }\n    rc = sqlite3_blob_open(\n       p->db, p->zDb, p->zSegmentsTbl, \"block\", iBlockid, 0, &p->pSegments\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = sqlite3_blob_bytes(p->pSegments);\n    *pnBlob = nByte;\n    if( paBlob ){\n      char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING);\n      if( !aByte ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){\n          nByte = FTS3_NODE_CHUNKSIZE;\n          *pnLoad = nByte;\n        }\n        rc = sqlite3_blob_read(p->pSegments, aByte, nByte, 0);\n        memset(&aByte[nByte], 0, FTS3_NODE_PADDING);\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aByte);\n          aByte = 0;\n        }\n      }\n      *paBlob = aByte;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Close the blob handle at p->pSegments, if it is open. See comments above\n** the sqlite3Fts3ReadBlock() function for details.\n*/\nvoid sqlite3Fts3SegmentsClose(Fts3Table *p){\n  sqlite3_blob_close(p->pSegments);\n  p->pSegments = 0;\n}\n    \nstatic int fts3SegReaderIncrRead(Fts3SegReader *pReader){\n  int nRead;                      /* Number of bytes to read */\n  int rc;                         /* Return code */\n\n  nRead = MIN(pReader->nNode - pReader->nPopulate, FTS3_NODE_CHUNKSIZE);\n  rc = sqlite3_blob_read(\n      pReader->pBlob, \n      &pReader->aNode[pReader->nPopulate],\n      nRead,\n      pReader->nPopulate\n  );\n\n  if( rc==SQLITE_OK ){\n    pReader->nPopulate += nRead;\n    memset(&pReader->aNode[pReader->nPopulate], 0, FTS3_NODE_PADDING);\n    if( pReader->nPopulate==pReader->nNode ){\n      sqlite3_blob_close(pReader->pBlob);\n      pReader->pBlob = 0;\n      pReader->nPopulate = 0;\n    }\n  }\n  return rc;\n}\n\nstatic int fts3SegReaderRequire(Fts3SegReader *pReader, char *pFrom, int nByte){\n  int rc = SQLITE_OK;\n  assert( !pReader->pBlob \n       || (pFrom>=pReader->aNode && pFrom<&pReader->aNode[pReader->nNode])\n  );\n  while( pReader->pBlob && rc==SQLITE_OK \n     &&  (pFrom - pReader->aNode + nByte)>pReader->nPopulate\n  ){\n    rc = fts3SegReaderIncrRead(pReader);\n  }\n  return rc;\n}\n\n/*\n** Set an Fts3SegReader cursor to point at EOF.\n*/\nstatic void fts3SegReaderSetEof(Fts3SegReader *pSeg){\n  if( !fts3SegReaderIsRootOnly(pSeg) ){\n    sqlite3_free(pSeg->aNode);\n    sqlite3_blob_close(pSeg->pBlob);\n    pSeg->pBlob = 0;\n  }\n  pSeg->aNode = 0;\n}\n\n/*\n** Move the iterator passed as the first argument to the next term in the\n** segment. If successful, SQLITE_OK is returned. If there is no next term,\n** SQLITE_DONE. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegReaderNext(\n  Fts3Table *p, \n  Fts3SegReader *pReader,\n  int bIncr\n){\n  int rc;                         /* Return code of various sub-routines */\n  char *pNext;                    /* Cursor variable */\n  int nPrefix;                    /* Number of bytes in term prefix */\n  int nSuffix;                    /* Number of bytes in term suffix */\n\n  if( !pReader->aDoclist ){\n    pNext = pReader->aNode;\n  }else{\n    pNext = &pReader->aDoclist[pReader->nDoclist];\n  }\n\n  if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){\n\n    if( fts3SegReaderIsPending(pReader) ){\n      Fts3HashElem *pElem = *(pReader->ppNextElem);\n      sqlite3_free(pReader->aNode);\n      pReader->aNode = 0;\n      if( pElem ){\n        char *aCopy;\n        PendingList *pList = (PendingList *)fts3HashData(pElem);\n        int nCopy = pList->nData+1;\n        pReader->zTerm = (char *)fts3HashKey(pElem);\n        pReader->nTerm = fts3HashKeysize(pElem);\n        aCopy = (char*)sqlite3_malloc(nCopy);\n        if( !aCopy ) return SQLITE_NOMEM;\n        memcpy(aCopy, pList->aData, nCopy);\n        pReader->nNode = pReader->nDoclist = nCopy;\n        pReader->aNode = pReader->aDoclist = aCopy;\n        pReader->ppNextElem++;\n        assert( pReader->aNode );\n      }\n      return SQLITE_OK;\n    }\n\n    fts3SegReaderSetEof(pReader);\n\n    /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf \n    ** blocks have already been traversed.  */\n    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock );\n    if( pReader->iCurrentBlock>=pReader->iLeafEndBlock ){\n      return SQLITE_OK;\n    }\n\n    rc = sqlite3Fts3ReadBlock(\n        p, ++pReader->iCurrentBlock, &pReader->aNode, &pReader->nNode, \n        (bIncr ? &pReader->nPopulate : 0)\n    );\n    if( rc!=SQLITE_OK ) return rc;\n    assert( pReader->pBlob==0 );\n    if( bIncr && pReader->nPopulate<pReader->nNode ){\n      pReader->pBlob = p->pSegments;\n      p->pSegments = 0;\n    }\n    pNext = pReader->aNode;\n  }\n\n  assert( !fts3SegReaderIsPending(pReader) );\n\n  rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);\n  if( rc!=SQLITE_OK ) return rc;\n  \n  /* Because of the FTS3_NODE_PADDING bytes of padding, the following is \n  ** safe (no risk of overread) even if the node data is corrupted. */\n  pNext += fts3GetVarint32(pNext, &nPrefix);\n  pNext += fts3GetVarint32(pNext, &nSuffix);\n  if( nPrefix<0 || nSuffix<=0 \n   || &pNext[nSuffix]>&pReader->aNode[pReader->nNode] \n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n\n  if( nPrefix+nSuffix>pReader->nTermAlloc ){\n    int nNew = (nPrefix+nSuffix)*2;\n    char *zNew = sqlite3_realloc(pReader->zTerm, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pReader->zTerm = zNew;\n    pReader->nTermAlloc = nNew;\n  }\n\n  rc = fts3SegReaderRequire(pReader, pNext, nSuffix+FTS3_VARINT_MAX);\n  if( rc!=SQLITE_OK ) return rc;\n\n  memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);\n  pReader->nTerm = nPrefix+nSuffix;\n  pNext += nSuffix;\n  pNext += fts3GetVarint32(pNext, &pReader->nDoclist);\n  pReader->aDoclist = pNext;\n  pReader->pOffsetList = 0;\n\n  /* Check that the doclist does not appear to extend past the end of the\n  ** b-tree node. And that the final byte of the doclist is 0x00. If either \n  ** of these statements is untrue, then the data structure is corrupt.\n  */\n  if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode] \n   || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])\n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set the SegReader to point to the first docid in the doclist associated\n** with the current term.\n*/\nstatic int fts3SegReaderFirstDocid(Fts3Table *pTab, Fts3SegReader *pReader){\n  int rc = SQLITE_OK;\n  assert( pReader->aDoclist );\n  assert( !pReader->pOffsetList );\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    u8 bEof = 0;\n    pReader->iDocid = 0;\n    pReader->nOffsetList = 0;\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &pReader->pOffsetList, \n        &pReader->iDocid, &pReader->nOffsetList, &bEof\n    );\n  }else{\n    rc = fts3SegReaderRequire(pReader, pReader->aDoclist, FTS3_VARINT_MAX);\n    if( rc==SQLITE_OK ){\n      int n = sqlite3Fts3GetVarint(pReader->aDoclist, &pReader->iDocid);\n      pReader->pOffsetList = &pReader->aDoclist[n];\n    }\n  }\n  return rc;\n}\n\n/*\n** Advance the SegReader to point to the next docid in the doclist\n** associated with the current term.\n** \n** If arguments ppOffsetList and pnOffsetList are not NULL, then \n** *ppOffsetList is set to point to the first column-offset list\n** in the doclist entry (i.e. immediately past the docid varint).\n** *pnOffsetList is set to the length of the set of column-offset\n** lists, not including the nul-terminator byte. For example:\n*/\nstatic int fts3SegReaderNextDocid(\n  Fts3Table *pTab,\n  Fts3SegReader *pReader,         /* Reader to advance to next docid */\n  char **ppOffsetList,            /* OUT: Pointer to current position-list */\n  int *pnOffsetList               /* OUT: Length of *ppOffsetList in bytes */\n){\n  int rc = SQLITE_OK;\n  char *p = pReader->pOffsetList;\n  char c = 0;\n\n  assert( p );\n\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    /* A pending-terms seg-reader for an FTS4 table that uses order=desc.\n    ** Pending-terms doclists are always built up in ascending order, so\n    ** we have to iterate through them backwards here. */\n    u8 bEof = 0;\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = pReader->nOffsetList - 1;\n    }\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &p, &pReader->iDocid,\n        &pReader->nOffsetList, &bEof\n    );\n    if( bEof ){\n      pReader->pOffsetList = 0;\n    }else{\n      pReader->pOffsetList = p;\n    }\n  }else{\n    char *pEnd = &pReader->aDoclist[pReader->nDoclist];\n\n    /* Pointer p currently points at the first byte of an offset list. The\n    ** following block advances it to point one byte past the end of\n    ** the same offset list. */\n    while( 1 ){\n  \n      /* The following line of code (and the \"p++\" below the while() loop) is\n      ** normally all that is required to move pointer p to the desired \n      ** position. The exception is if this node is being loaded from disk\n      ** incrementally and pointer \"p\" now points to the first byte past\n      ** the populated part of pReader->aNode[].\n      */\n      while( *p | c ) c = *p++ & 0x80;\n      assert( *p==0 );\n  \n      if( pReader->pBlob==0 || p<&pReader->aNode[pReader->nPopulate] ) break;\n      rc = fts3SegReaderIncrRead(pReader);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    p++;\n  \n    /* If required, populate the output variables with a pointer to and the\n    ** size of the previous offset-list.\n    */\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = (int)(p - pReader->pOffsetList - 1);\n    }\n\n    /* List may have been edited in place by fts3EvalNearTrim() */\n    while( p<pEnd && *p==0 ) p++;\n  \n    /* If there are no more entries in the doclist, set pOffsetList to\n    ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and\n    ** Fts3SegReader.pOffsetList to point to the next offset list before\n    ** returning.\n    */\n    if( p>=pEnd ){\n      pReader->pOffsetList = 0;\n    }else{\n      rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);\n      if( rc==SQLITE_OK ){\n        sqlite3_int64 iDelta;\n        pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);\n        if( pTab->bDescIdx ){\n          pReader->iDocid -= iDelta;\n        }else{\n          pReader->iDocid += iDelta;\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n\nint sqlite3Fts3MsrOvfl(\n  Fts3Cursor *pCsr, \n  Fts3MultiSegReader *pMsr,\n  int *pnOvfl\n){\n  Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n  int nOvfl = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int pgsz = p->nPgsz;\n\n  assert( p->bFts4 );\n  assert( pgsz>0 );\n\n  for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){\n    Fts3SegReader *pReader = pMsr->apSegment[ii];\n    if( !fts3SegReaderIsPending(pReader) \n     && !fts3SegReaderIsRootOnly(pReader) \n    ){\n      sqlite3_int64 jj;\n      for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){\n        int nBlob;\n        rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( (nBlob+35)>pgsz ){\n          nOvfl += (nBlob + 34)/pgsz;\n        }\n      }\n    }\n  }\n  *pnOvfl = nOvfl;\n  return rc;\n}\n\n/*\n** Free all allocations associated with the iterator passed as the \n** second argument.\n*/\nvoid sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){\n  if( pReader ){\n    if( !fts3SegReaderIsPending(pReader) ){\n      sqlite3_free(pReader->zTerm);\n    }\n    if( !fts3SegReaderIsRootOnly(pReader) ){\n      sqlite3_free(pReader->aNode);\n    }\n    sqlite3_blob_close(pReader->pBlob);\n  }\n  sqlite3_free(pReader);\n}\n\n/*\n** Allocate a new SegReader object.\n*/\nint sqlite3Fts3SegReaderNew(\n  int iAge,                       /* Segment \"age\". */\n  int bLookup,                    /* True for a lookup only */\n  sqlite3_int64 iStartLeaf,       /* First leaf to traverse */\n  sqlite3_int64 iEndLeaf,         /* Final leaf to traverse */\n  sqlite3_int64 iEndBlock,        /* Final block of segment */\n  const char *zRoot,              /* Buffer containing root node */\n  int nRoot,                      /* Size of buffer containing root node */\n  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */\n){\n  Fts3SegReader *pReader;         /* Newly allocated SegReader object */\n  int nExtra = 0;                 /* Bytes to allocate segment root node */\n\n  assert( iStartLeaf<=iEndLeaf );\n  if( iStartLeaf==0 ){\n    nExtra = nRoot + FTS3_NODE_PADDING;\n  }\n\n  pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);\n  if( !pReader ){\n    return SQLITE_NOMEM;\n  }\n  memset(pReader, 0, sizeof(Fts3SegReader));\n  pReader->iIdx = iAge;\n  pReader->bLookup = bLookup!=0;\n  pReader->iStartBlock = iStartLeaf;\n  pReader->iLeafEndBlock = iEndLeaf;\n  pReader->iEndBlock = iEndBlock;\n\n  if( nExtra ){\n    /* The entire segment is stored in the root node. */\n    pReader->aNode = (char *)&pReader[1];\n    pReader->rootOnly = 1;\n    pReader->nNode = nRoot;\n    memcpy(pReader->aNode, zRoot, nRoot);\n    memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);\n  }else{\n    pReader->iCurrentBlock = iStartLeaf-1;\n  }\n  *ppReader = pReader;\n  return SQLITE_OK;\n}\n\n/*\n** This is a comparison function used as a qsort() callback when sorting\n** an array of pending terms by term. This occurs as part of flushing\n** the contents of the pending-terms hash table to the database.\n*/\nstatic int SQLITE_CDECL fts3CompareElemByTerm(\n  const void *lhs,\n  const void *rhs\n){\n  char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);\n  char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);\n  int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);\n  int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);\n\n  int n = (n1<n2 ? n1 : n2);\n  int c = memcmp(z1, z2, n);\n  if( c==0 ){\n    c = n1 - n2;\n  }\n  return c;\n}\n\n/*\n** This function is used to allocate an Fts3SegReader that iterates through\n** a subset of the terms stored in the Fts3Table.pendingTerms array.\n**\n** If the isPrefixIter parameter is zero, then the returned SegReader iterates\n** through each term in the pending-terms table. Or, if isPrefixIter is\n** non-zero, it iterates through each term and its prefixes. For example, if\n** the pending terms hash table contains the terms \"sqlite\", \"mysql\" and\n** \"firebird\", then the iterator visits the following 'terms' (in the order\n** shown):\n**\n**   f fi fir fire fireb firebi firebir firebird\n**   m my mys mysq mysql\n**   s sq sql sqli sqlit sqlite\n**\n** Whereas if isPrefixIter is zero, the terms visited are:\n**\n**   firebird mysql sqlite\n*/\nint sqlite3Fts3SegReaderPending(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iIndex,                     /* Index for p->aIndex */\n  const char *zTerm,              /* Term to search for */\n  int nTerm,                      /* Size of buffer zTerm */\n  int bPrefix,                    /* True for a prefix iterator */\n  Fts3SegReader **ppReader        /* OUT: SegReader for pending-terms */\n){\n  Fts3SegReader *pReader = 0;     /* Fts3SegReader object to return */\n  Fts3HashElem *pE;               /* Iterator variable */\n  Fts3HashElem **aElem = 0;       /* Array of term hash entries to scan */\n  int nElem = 0;                  /* Size of array at aElem */\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Hash *pHash;\n\n  pHash = &p->aIndex[iIndex].hPending;\n  if( bPrefix ){\n    int nAlloc = 0;               /* Size of allocated array at aElem */\n\n    for(pE=fts3HashFirst(pHash); pE; pE=fts3HashNext(pE)){\n      char *zKey = (char *)fts3HashKey(pE);\n      int nKey = fts3HashKeysize(pE);\n      if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){\n        if( nElem==nAlloc ){\n          Fts3HashElem **aElem2;\n          nAlloc += 16;\n          aElem2 = (Fts3HashElem **)sqlite3_realloc(\n              aElem, nAlloc*sizeof(Fts3HashElem *)\n          );\n          if( !aElem2 ){\n            rc = SQLITE_NOMEM;\n            nElem = 0;\n            break;\n          }\n          aElem = aElem2;\n        }\n\n        aElem[nElem++] = pE;\n      }\n    }\n\n    /* If more than one term matches the prefix, sort the Fts3HashElem\n    ** objects in term order using qsort(). This uses the same comparison\n    ** callback as is used when flushing terms to disk.\n    */\n    if( nElem>1 ){\n      qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);\n    }\n\n  }else{\n    /* The query is a simple term lookup that matches at most one term in\n    ** the index. All that is required is a straight hash-lookup. \n    **\n    ** Because the stack address of pE may be accessed via the aElem pointer\n    ** below, the \"Fts3HashElem *pE\" must be declared so that it is valid\n    ** within this entire function, not just this \"else{...}\" block.\n    */\n    pE = fts3HashFindElem(pHash, zTerm, nTerm);\n    if( pE ){\n      aElem = &pE;\n      nElem = 1;\n    }\n  }\n\n  if( nElem>0 ){\n    int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);\n    pReader = (Fts3SegReader *)sqlite3_malloc(nByte);\n    if( !pReader ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pReader, 0, nByte);\n      pReader->iIdx = 0x7FFFFFFF;\n      pReader->ppNextElem = (Fts3HashElem **)&pReader[1];\n      memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));\n    }\n  }\n\n  if( bPrefix ){\n    sqlite3_free(aElem);\n  }\n  *ppReader = pReader;\n  return rc;\n}\n\n/*\n** Compare the entries pointed to by two Fts3SegReader structures. \n** Comparison is as follows:\n**\n**   1) EOF is greater than not EOF.\n**\n**   2) The current terms (if any) are compared using memcmp(). If one\n**      term is a prefix of another, the longer term is considered the\n**      larger.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc;\n  if( pLhs->aNode && pRhs->aNode ){\n    int rc2 = pLhs->nTerm - pRhs->nTerm;\n    if( rc2<0 ){\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);\n    }else{\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);\n    }\n    if( rc==0 ){\n      rc = rc2;\n    }\n  }else{\n    rc = (pLhs->aNode==0) - (pRhs->aNode==0);\n  }\n  if( rc==0 ){\n    rc = pRhs->iIdx - pLhs->iIdx;\n  }\n  assert( rc!=0 );\n  return rc;\n}\n\n/*\n** A different comparison function for SegReader structures. In this\n** version, it is assumed that each SegReader points to an entry in\n** a doclist for identical terms. Comparison is made as follows:\n**\n**   1) EOF (end of doclist in this case) is greater than not EOF.\n**\n**   2) By current docid.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderDoclistCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\nstatic int fts3SegReaderDoclistCmpRev(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid < pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\n\n/*\n** Compare the term that the Fts3SegReader object passed as the first argument\n** points to with the term specified by arguments zTerm and nTerm. \n**\n** If the pSeg iterator is already at EOF, return 0. Otherwise, return\n** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are\n** equal, or +ve if the pSeg term is greater than zTerm/nTerm.\n*/\nstatic int fts3SegReaderTermCmp(\n  Fts3SegReader *pSeg,            /* Segment reader object */\n  const char *zTerm,              /* Term to compare to */\n  int nTerm                       /* Size of term zTerm in bytes */\n){\n  int res = 0;\n  if( pSeg->aNode ){\n    if( pSeg->nTerm>nTerm ){\n      res = memcmp(pSeg->zTerm, zTerm, nTerm);\n    }else{\n      res = memcmp(pSeg->zTerm, zTerm, pSeg->nTerm);\n    }\n    if( res==0 ){\n      res = pSeg->nTerm-nTerm;\n    }\n  }\n  return res;\n}\n\n/*\n** Argument apSegment is an array of nSegment elements. It is known that\n** the final (nSegment-nSuspect) members are already in sorted order\n** (according to the comparison function provided). This function shuffles\n** the array around until all entries are in sorted order.\n*/\nstatic void fts3SegReaderSort(\n  Fts3SegReader **apSegment,                     /* Array to sort entries of */\n  int nSegment,                                  /* Size of apSegment array */\n  int nSuspect,                                  /* Unsorted entry count */\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *)  /* Comparison function */\n){\n  int i;                          /* Iterator variable */\n\n  assert( nSuspect<=nSegment );\n\n  if( nSuspect==nSegment ) nSuspect--;\n  for(i=nSuspect-1; i>=0; i--){\n    int j;\n    for(j=i; j<(nSegment-1); j++){\n      Fts3SegReader *pTmp;\n      if( xCmp(apSegment[j], apSegment[j+1])<0 ) break;\n      pTmp = apSegment[j+1];\n      apSegment[j+1] = apSegment[j];\n      apSegment[j] = pTmp;\n    }\n  }\n\n#ifndef NDEBUG\n  /* Check that the list really is sorted now. */\n  for(i=0; i<(nSuspect-1); i++){\n    assert( xCmp(apSegment[i], apSegment[i+1])<0 );\n  }\n#endif\n}\n\n/* \n** Insert a record into the %_segments table.\n*/\nstatic int fts3WriteSegment(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iBlock,           /* Block id for new block */\n  char *z,                        /* Pointer to buffer containing block data */\n  int n                           /* Size of buffer z in bytes */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iBlock);\n    sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Find the largest relative level number in the table. If successful, set\n** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,\n** set *pnMax to zero and return an SQLite error code.\n*/\nint sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){\n  int rc;\n  int mxLevel = 0;\n  sqlite3_stmt *pStmt = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      mxLevel = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_reset(pStmt);\n  }\n  *pnMax = mxLevel;\n  return rc;\n}\n\n/* \n** Insert a record into the %_segdir table.\n*/\nstatic int fts3WriteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iLevel,           /* Value for \"level\" field (absolute level) */\n  int iIdx,                       /* Value for \"idx\" field */\n  sqlite3_int64 iStartBlock,      /* Value for \"start_block\" field */\n  sqlite3_int64 iLeafEndBlock,    /* Value for \"leaves_end_block\" field */\n  sqlite3_int64 iEndBlock,        /* Value for \"end_block\" field */\n  sqlite3_int64 nLeafData,        /* Bytes of leaf data in segment */\n  char *zRoot,                    /* Blob value for \"root\" field */\n  int nRoot                       /* Number of bytes in buffer zRoot */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iLevel);\n    sqlite3_bind_int(pStmt, 2, iIdx);\n    sqlite3_bind_int64(pStmt, 3, iStartBlock);\n    sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);\n    if( nLeafData==0 ){\n      sqlite3_bind_int64(pStmt, 5, iEndBlock);\n    }else{\n      char *zEnd = sqlite3_mprintf(\"%lld %lld\", iEndBlock, nLeafData);\n      if( !zEnd ) return SQLITE_NOMEM;\n      sqlite3_bind_text(pStmt, 5, zEnd, -1, sqlite3_free);\n    }\n    sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Return the size of the common prefix (if any) shared by zPrev and\n** zNext, in bytes. For example, \n**\n**   fts3PrefixCompress(\"abc\", 3, \"abcdef\", 6)   // returns 3\n**   fts3PrefixCompress(\"abX\", 3, \"abcdef\", 6)   // returns 2\n**   fts3PrefixCompress(\"abX\", 3, \"Xbcdef\", 6)   // returns 0\n*/\nstatic int fts3PrefixCompress(\n  const char *zPrev,              /* Buffer containing previous term */\n  int nPrev,                      /* Size of buffer zPrev in bytes */\n  const char *zNext,              /* Buffer containing next term */\n  int nNext                       /* Size of buffer zNext in bytes */\n){\n  int n;\n  UNUSED_PARAMETER(nNext);\n  for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);\n  return n;\n}\n\n/*\n** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger\n** (according to memcmp) than the previous term.\n*/\nstatic int fts3NodeAddTerm(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode **ppTree,           /* IN/OUT: SegmentNode handle */ \n  int isCopyTerm,                 /* True if zTerm/nTerm is transient */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm                       /* Size of term in bytes */\n){\n  SegmentNode *pTree = *ppTree;\n  int rc;\n  SegmentNode *pNew;\n\n  /* First try to append the term to the current node. Return early if \n  ** this is possible.\n  */\n  if( pTree ){\n    int nData = pTree->nData;     /* Current size of node in bytes */\n    int nReq = nData;             /* Required space after adding zTerm */\n    int nPrefix;                  /* Number of bytes of prefix compression */\n    int nSuffix;                  /* Suffix length */\n\n    nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);\n    nSuffix = nTerm-nPrefix;\n\n    nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;\n    if( nReq<=p->nNodeSize || !pTree->zTerm ){\n\n      if( nReq>p->nNodeSize ){\n        /* An unusual case: this is the first term to be added to the node\n        ** and the static node buffer (p->nNodeSize bytes) is not large\n        ** enough. Use a separately malloced buffer instead This wastes\n        ** p->nNodeSize bytes, but since this scenario only comes about when\n        ** the database contain two terms that share a prefix of almost 2KB, \n        ** this is not expected to be a serious problem. \n        */\n        assert( pTree->aData==(char *)&pTree[1] );\n        pTree->aData = (char *)sqlite3_malloc(nReq);\n        if( !pTree->aData ){\n          return SQLITE_NOMEM;\n        }\n      }\n\n      if( pTree->zTerm ){\n        /* There is no prefix-length field for first term in a node */\n        nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nPrefix);\n      }\n\n      nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nSuffix);\n      memcpy(&pTree->aData[nData], &zTerm[nPrefix], nSuffix);\n      pTree->nData = nData + nSuffix;\n      pTree->nEntry++;\n\n      if( isCopyTerm ){\n        if( pTree->nMalloc<nTerm ){\n          char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2);\n          if( !zNew ){\n            return SQLITE_NOMEM;\n          }\n          pTree->nMalloc = nTerm*2;\n          pTree->zMalloc = zNew;\n        }\n        pTree->zTerm = pTree->zMalloc;\n        memcpy(pTree->zTerm, zTerm, nTerm);\n        pTree->nTerm = nTerm;\n      }else{\n        pTree->zTerm = (char *)zTerm;\n        pTree->nTerm = nTerm;\n      }\n      return SQLITE_OK;\n    }\n  }\n\n  /* If control flows to here, it was not possible to append zTerm to the\n  ** current node. Create a new node (a right-sibling of the current node).\n  ** If this is the first node in the tree, the term is added to it.\n  **\n  ** Otherwise, the term is not added to the new node, it is left empty for\n  ** now. Instead, the term is inserted into the parent of pTree. If pTree \n  ** has no parent, one is created here.\n  */\n  pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize);\n  if( !pNew ){\n    return SQLITE_NOMEM;\n  }\n  memset(pNew, 0, sizeof(SegmentNode));\n  pNew->nData = 1 + FTS3_VARINT_MAX;\n  pNew->aData = (char *)&pNew[1];\n\n  if( pTree ){\n    SegmentNode *pParent = pTree->pParent;\n    rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);\n    if( pTree->pParent==0 ){\n      pTree->pParent = pParent;\n    }\n    pTree->pRight = pNew;\n    pNew->pLeftmost = pTree->pLeftmost;\n    pNew->pParent = pParent;\n    pNew->zMalloc = pTree->zMalloc;\n    pNew->nMalloc = pTree->nMalloc;\n    pTree->zMalloc = 0;\n  }else{\n    pNew->pLeftmost = pNew;\n    rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm); \n  }\n\n  *ppTree = pNew;\n  return rc;\n}\n\n/*\n** Helper function for fts3NodeWrite().\n*/\nstatic int fts3TreeFinishNode(\n  SegmentNode *pTree, \n  int iHeight, \n  sqlite3_int64 iLeftChild\n){\n  int nStart;\n  assert( iHeight>=1 && iHeight<128 );\n  nStart = FTS3_VARINT_MAX - sqlite3Fts3VarintLen(iLeftChild);\n  pTree->aData[nStart] = (char)iHeight;\n  sqlite3Fts3PutVarint(&pTree->aData[nStart+1], iLeftChild);\n  return nStart;\n}\n\n/*\n** Write the buffer for the segment node pTree and all of its peers to the\n** database. Then call this function recursively to write the parent of \n** pTree and its peers to the database. \n**\n** Except, if pTree is a root node, do not write it to the database. Instead,\n** set output variables *paRoot and *pnRoot to contain the root node.\n**\n** If successful, SQLITE_OK is returned and output variable *piLast is\n** set to the largest blockid written to the database (or zero if no\n** blocks were written to the db). Otherwise, an SQLite error code is \n** returned.\n*/\nstatic int fts3NodeWrite(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode *pTree,             /* SegmentNode handle */\n  int iHeight,                    /* Height of this node in tree */\n  sqlite3_int64 iLeaf,            /* Block id of first leaf node */\n  sqlite3_int64 iFree,            /* Block id of next free slot in %_segments */\n  sqlite3_int64 *piLast,          /* OUT: Block id of last entry written */\n  char **paRoot,                  /* OUT: Data for root node */\n  int *pnRoot                     /* OUT: Size of root node in bytes */\n){\n  int rc = SQLITE_OK;\n\n  if( !pTree->pParent ){\n    /* Root node of the tree. */\n    int nStart = fts3TreeFinishNode(pTree, iHeight, iLeaf);\n    *piLast = iFree-1;\n    *pnRoot = pTree->nData - nStart;\n    *paRoot = &pTree->aData[nStart];\n  }else{\n    SegmentNode *pIter;\n    sqlite3_int64 iNextFree = iFree;\n    sqlite3_int64 iNextLeaf = iLeaf;\n    for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){\n      int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);\n      int nWrite = pIter->nData - nStart;\n  \n      rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);\n      iNextFree++;\n      iNextLeaf += (pIter->nEntry+1);\n    }\n    if( rc==SQLITE_OK ){\n      assert( iNextLeaf==iFree );\n      rc = fts3NodeWrite(\n          p, pTree->pParent, iHeight+1, iFree, iNextFree, piLast, paRoot, pnRoot\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free all memory allocations associated with the tree pTree.\n*/\nstatic void fts3NodeFree(SegmentNode *pTree){\n  if( pTree ){\n    SegmentNode *p = pTree->pLeftmost;\n    fts3NodeFree(p->pParent);\n    while( p ){\n      SegmentNode *pRight = p->pRight;\n      if( p->aData!=(char *)&p[1] ){\n        sqlite3_free(p->aData);\n      }\n      assert( pRight==0 || p->zMalloc==0 );\n      sqlite3_free(p->zMalloc);\n      sqlite3_free(p);\n      p = pRight;\n    }\n  }\n}\n\n/*\n** Add a term to the segment being constructed by the SegmentWriter object\n** *ppWriter. When adding the first term to a segment, *ppWriter should\n** be passed NULL. This function will allocate a new SegmentWriter object\n** and return it via the input/output variable *ppWriter in this case.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterAdd(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter **ppWriter,       /* IN/OUT: SegmentWriter handle */ \n  int isCopyTerm,                 /* True if buffer zTerm must be copied */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of term in bytes */\n  const char *aDoclist,           /* Pointer to buffer containing doclist */\n  int nDoclist                    /* Size of doclist in bytes */\n){\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n  int nReq;                       /* Number of bytes required on leaf page */\n  int nData;\n  SegmentWriter *pWriter = *ppWriter;\n\n  if( !pWriter ){\n    int rc;\n    sqlite3_stmt *pStmt;\n\n    /* Allocate the SegmentWriter structure */\n    pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));\n    if( !pWriter ) return SQLITE_NOMEM;\n    memset(pWriter, 0, sizeof(SegmentWriter));\n    *ppWriter = pWriter;\n\n    /* Allocate a buffer in which to accumulate data */\n    pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);\n    if( !pWriter->aData ) return SQLITE_NOMEM;\n    pWriter->nSize = p->nNodeSize;\n\n    /* Find the next free blockid in the %_segments table */\n    rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      pWriter->iFree = sqlite3_column_int64(pStmt, 0);\n      pWriter->iFirst = pWriter->iFree;\n    }\n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nData = pWriter->nData;\n\n  nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);\n  nSuffix = nTerm-nPrefix;\n\n  /* Figure out how many bytes are required by this new entry */\n  nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */\n    sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */\n    nSuffix +                               /* Term suffix */\n    sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */\n    nDoclist;                               /* Doclist data */\n\n  if( nData>0 && nData+nReq>p->nNodeSize ){\n    int rc;\n\n    /* The current leaf node is full. Write it out to the database. */\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);\n    if( rc!=SQLITE_OK ) return rc;\n    p->nLeafAdd++;\n\n    /* Add the current term to the interior node tree. The term added to\n    ** the interior tree must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pWriter->zTerm), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    assert( nPrefix<nTerm );\n    rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);\n    if( rc!=SQLITE_OK ) return rc;\n\n    nData = 0;\n    pWriter->nTerm = 0;\n\n    nPrefix = 0;\n    nSuffix = nTerm;\n    nReq = 1 +                              /* varint containing prefix size */\n      sqlite3Fts3VarintLen(nTerm) +         /* varint containing suffix size */\n      nTerm +                               /* Term suffix */\n      sqlite3Fts3VarintLen(nDoclist) +      /* Size of doclist */\n      nDoclist;                             /* Doclist data */\n  }\n\n  /* Increase the total number of bytes written to account for the new entry. */\n  pWriter->nLeafData += nReq;\n\n  /* If the buffer currently allocated is too small for this entry, realloc\n  ** the buffer to make it large enough.\n  */\n  if( nReq>pWriter->nSize ){\n    char *aNew = sqlite3_realloc(pWriter->aData, nReq);\n    if( !aNew ) return SQLITE_NOMEM;\n    pWriter->aData = aNew;\n    pWriter->nSize = nReq;\n  }\n  assert( nData+nReq<=pWriter->nSize );\n\n  /* Append the prefix-compressed term and doclist to the buffer. */\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);\n  memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);\n  nData += nSuffix;\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);\n  memcpy(&pWriter->aData[nData], aDoclist, nDoclist);\n  pWriter->nData = nData + nDoclist;\n\n  /* Save the current term so that it can be used to prefix-compress the next.\n  ** If the isCopyTerm parameter is true, then the buffer pointed to by\n  ** zTerm is transient, so take a copy of the term data. Otherwise, just\n  ** store a copy of the pointer.\n  */\n  if( isCopyTerm ){\n    if( nTerm>pWriter->nMalloc ){\n      char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pWriter->nMalloc = nTerm*2;\n      pWriter->zMalloc = zNew;\n      pWriter->zTerm = zNew;\n    }\n    assert( pWriter->zTerm==pWriter->zMalloc );\n    memcpy(pWriter->zTerm, zTerm, nTerm);\n  }else{\n    pWriter->zTerm = (char *)zTerm;\n  }\n  pWriter->nTerm = nTerm;\n\n  return SQLITE_OK;\n}\n\n/*\n** Flush all data associated with the SegmentWriter object pWriter to the\n** database. This function must be called after all terms have been added\n** to the segment using fts3SegWriterAdd(). If successful, SQLITE_OK is\n** returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterFlush(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter *pWriter,         /* SegmentWriter to flush to the db */\n  sqlite3_int64 iLevel,           /* Value for 'level' column of %_segdir */\n  int iIdx                        /* Value for 'idx' column of %_segdir */\n){\n  int rc;                         /* Return code */\n  if( pWriter->pTree ){\n    sqlite3_int64 iLast = 0;      /* Largest block id written to database */\n    sqlite3_int64 iLastLeaf;      /* Largest leaf block id written to db */\n    char *zRoot = NULL;           /* Pointer to buffer containing root node */\n    int nRoot = 0;                /* Size of buffer zRoot */\n\n    iLastLeaf = pWriter->iFree;\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);\n    if( rc==SQLITE_OK ){\n      rc = fts3NodeWrite(p, pWriter->pTree, 1,\n          pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegdir(p, iLevel, iIdx, \n          pWriter->iFirst, iLastLeaf, iLast, pWriter->nLeafData, zRoot, nRoot);\n    }\n  }else{\n    /* The entire tree fits on the root node. Write it to the segdir table. */\n    rc = fts3WriteSegdir(p, iLevel, iIdx, \n        0, 0, 0, pWriter->nLeafData, pWriter->aData, pWriter->nData);\n  }\n  p->nLeafAdd++;\n  return rc;\n}\n\n/*\n** Release all memory held by the SegmentWriter object passed as the \n** first argument.\n*/\nstatic void fts3SegWriterFree(SegmentWriter *pWriter){\n  if( pWriter ){\n    sqlite3_free(pWriter->aData);\n    sqlite3_free(pWriter->zMalloc);\n    fts3NodeFree(pWriter->pTree);\n    sqlite3_free(pWriter);\n  }\n}\n\n/*\n** The first value in the apVal[] array is assumed to contain an integer.\n** This function tests if there exist any documents with docid values that\n** are different from that integer. i.e. if deleting the document with docid\n** pRowid would mean the FTS3 table were empty.\n**\n** If successful, *pisEmpty is set to true if the table is empty except for\n** document pRowid, or false otherwise, and SQLITE_OK is returned. If an\n** error occurs, an SQLite error code is returned.\n*/\nstatic int fts3IsEmpty(Fts3Table *p, sqlite3_value *pRowid, int *pisEmpty){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( p->zContentTbl ){\n    /* If using the content=xxx option, assume the table is never empty */\n    *pisEmpty = 0;\n    rc = SQLITE_OK;\n  }else{\n    rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *pisEmpty = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Set *pnMax to the largest segment level in the database for the index\n** iIndex.\n**\n** Segment levels are stored in the 'level' column of the %_segdir table.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if not.\n*/\nstatic int fts3SegmentMaxLevel(\n  Fts3Table *p, \n  int iLangid,\n  int iIndex, \n  sqlite3_int64 *pnMax\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n  sqlite3_bind_int64(pStmt, 2, \n      getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n  );\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pnMax = sqlite3_column_int64(pStmt, 0);\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** iAbsLevel is an absolute level that may be assumed to exist within\n** the database. This function checks if it is the largest level number\n** within its index. Assuming no error occurs, *pbMax is set to 1 if\n** iAbsLevel is indeed the largest level, or 0 otherwise, and SQLITE_OK\n** is returned. If an error occurs, an error code is returned and the\n** final value of *pbMax is undefined.\n*/\nstatic int fts3SegmentIsMaxLevel(Fts3Table *p, i64 iAbsLevel, int *pbMax){\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, iAbsLevel+1);\n  sqlite3_bind_int64(pStmt, 2, \n      ((iAbsLevel/FTS3_SEGDIR_MAXLEVEL)+1) * FTS3_SEGDIR_MAXLEVEL\n  );\n\n  *pbMax = 0;\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pbMax = sqlite3_column_type(pStmt, 0)==SQLITE_NULL;\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** Delete all entries in the %_segments table associated with the segment\n** opened with seg-reader pSeg. This function does not affect the contents\n** of the %_segdir table.\n*/\nstatic int fts3DeleteSegment(\n  Fts3Table *p,                   /* FTS table handle */\n  Fts3SegReader *pSeg             /* Segment to delete */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pSeg->iStartBlock ){\n    sqlite3_stmt *pDelete;        /* SQL statement to delete rows */\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);\n      sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);\n      sqlite3_step(pDelete);\n      rc = sqlite3_reset(pDelete);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used after merging multiple segments into a single large\n** segment to delete the old, now redundant, segment b-trees. Specifically,\n** it:\n** \n**   1) Deletes all %_segments entries for the segments associated with \n**      each of the SegReader objects in the array passed as the third \n**      argument, and\n**\n**   2) deletes all %_segdir entries with level iLevel, or all %_segdir\n**      entries regardless of level if (iLevel<0).\n**\n** SQLITE_OK is returned if successful, otherwise an SQLite error code.\n*/\nstatic int fts3DeleteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel,                     /* Level of %_segdir entries to delete */\n  Fts3SegReader **apSegment,      /* Array of SegReader objects */\n  int nReader                     /* Size of array apSegment */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pDelete = 0;      /* SQL statement to delete rows */\n\n  for(i=0; rc==SQLITE_OK && i<nReader; i++){\n    rc = fts3DeleteSegment(p, apSegment[i]);\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pDelete, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(\n          pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** When this function is called, buffer *ppList (size *pnList bytes) contains \n** a position list that may (or may not) feature multiple columns. This\n** function adjusts the pointer *ppList and the length *pnList so that they\n** identify the subset of the position list that corresponds to column iCol.\n**\n** If there are no entries in the input position list for column iCol, then\n** *pnList is set to zero before returning.\n**\n** If parameter bZero is non-zero, then any part of the input list following\n** the end of the output list is zeroed before returning.\n*/\nstatic void fts3ColumnFilter(\n  int iCol,                       /* Column to filter on */\n  int bZero,                      /* Zero out anything following *ppList */\n  char **ppList,                  /* IN/OUT: Pointer to position list */\n  int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */\n){\n  char *pList = *ppList;\n  int nList = *pnList;\n  char *pEnd = &pList[nList];\n  int iCurrent = 0;\n  char *p = pList;\n\n  assert( iCol>=0 );\n  while( 1 ){\n    char c = 0;\n    while( p<pEnd && (c | *p)&0xFE ) c = *p++ & 0x80;\n  \n    if( iCol==iCurrent ){\n      nList = (int)(p - pList);\n      break;\n    }\n\n    nList -= (int)(p - pList);\n    pList = p;\n    if( nList==0 ){\n      break;\n    }\n    p = &pList[1];\n    p += fts3GetVarint32(p, &iCurrent);\n  }\n\n  if( bZero && &pList[nList]!=pEnd ){\n    memset(&pList[nList], 0, pEnd - &pList[nList]);\n  }\n  *ppList = pList;\n  *pnList = nList;\n}\n\n/*\n** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any\n** existing data). Grow the buffer if required.\n**\n** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered\n** trying to resize the buffer, return SQLITE_NOMEM.\n*/\nstatic int fts3MsrBufferData(\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  char *pList,\n  int nList\n){\n  if( nList>pMsr->nBuffer ){\n    char *pNew;\n    pMsr->nBuffer = nList*2;\n    pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);\n    if( !pNew ) return SQLITE_NOMEM;\n    pMsr->aBuffer = pNew;\n  }\n\n  memcpy(pMsr->aBuffer, pList, nList);\n  return SQLITE_OK;\n}\n\nint sqlite3Fts3MsrIncrNext(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  sqlite3_int64 *piDocid,         /* OUT: Docid value */\n  char **paPoslist,               /* OUT: Pointer to position list */\n  int *pnPoslist                  /* OUT: Size of position list in bytes */\n){\n  int nMerge = pMsr->nAdvance;\n  Fts3SegReader **apSegment = pMsr->apSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( nMerge==0 ){\n    *paPoslist = 0;\n    return SQLITE_OK;\n  }\n\n  while( 1 ){\n    Fts3SegReader *pSeg;\n    pSeg = pMsr->apSegment[0];\n\n    if( pSeg->pOffsetList==0 ){\n      *paPoslist = 0;\n      break;\n    }else{\n      int rc;\n      char *pList;\n      int nList;\n      int j;\n      sqlite3_int64 iDocid = apSegment[0]->iDocid;\n\n      rc = fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n      j = 1;\n      while( rc==SQLITE_OK \n        && j<nMerge\n        && apSegment[j]->pOffsetList\n        && apSegment[j]->iDocid==iDocid\n      ){\n        rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n        j++;\n      }\n      if( rc!=SQLITE_OK ) return rc;\n      fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp);\n\n      if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pMsr, pList, nList+1);\n        if( rc!=SQLITE_OK ) return rc;\n        assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );\n        pList = pMsr->aBuffer;\n      }\n\n      if( pMsr->iColFilter>=0 ){\n        fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList);\n      }\n\n      if( nList>0 ){\n        *paPoslist = pList;\n        *piDocid = iDocid;\n        *pnPoslist = nList;\n        break;\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  const char *zTerm,              /* Term searched for (or NULL) */\n  int nTerm                       /* Length of zTerm in bytes */\n){\n  int i;\n  int nSeg = pCsr->nSegment;\n\n  /* If the Fts3SegFilter defines a specific term (or term prefix) to search \n  ** for, then advance each segment iterator until it points to a term of\n  ** equal or greater value than the specified term. This prevents many\n  ** unnecessary merge/sort operations for the case where single segment\n  ** b-tree leaf nodes contain more than one term.\n  */\n  for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){\n    int res = 0;\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    do {\n      int rc = fts3SegReaderNext(p, pSeg, 0);\n      if( rc!=SQLITE_OK ) return rc;\n    }while( zTerm && (res = fts3SegReaderTermCmp(pSeg, zTerm, nTerm))<0 );\n\n    if( pSeg->bLookup && res!=0 ){\n      fts3SegReaderSetEof(pSeg);\n    }\n  }\n  fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);\n\n  return SQLITE_OK;\n}\n\nint sqlite3Fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  Fts3SegFilter *pFilter          /* Restrictions on range of iteration */\n){\n  pCsr->pFilter = pFilter;\n  return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);\n}\n\nint sqlite3Fts3MsrIncrStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  int iCol,                       /* Column to match on. */\n  const char *zTerm,              /* Term to iterate through a doclist for */\n  int nTerm                       /* Number of bytes in zTerm */\n){\n  int i;\n  int rc;\n  int nSegment = pCsr->nSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  assert( pCsr->pFilter==0 );\n  assert( zTerm && nTerm>0 );\n\n  /* Advance each segment iterator until it points to the term zTerm/nTerm. */\n  rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Determine how many of the segments actually point to zTerm/nTerm. */\n  for(i=0; i<nSegment; i++){\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){\n      break;\n    }\n  }\n  pCsr->nAdvance = i;\n\n  /* Advance each of the segments to point to the first docid. */\n  for(i=0; i<pCsr->nAdvance; i++){\n    rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);\n\n  assert( iCol<0 || iCol<p->nColumn );\n  pCsr->iColFilter = iCol;\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called on a MultiSegReader that has been started using\n** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also\n** have been made. Calling this function puts the MultiSegReader in such\n** a state that if the next two calls are:\n**\n**   sqlite3Fts3SegReaderStart()\n**   sqlite3Fts3SegReaderStep()\n**\n** then the entire doclist for the term is available in \n** MultiSegReader.aDoclist/nDoclist.\n*/\nint sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){\n  int i;                          /* Used to iterate through segment-readers */\n\n  assert( pCsr->zTerm==0 );\n  assert( pCsr->nTerm==0 );\n  assert( pCsr->aDoclist==0 );\n  assert( pCsr->nDoclist==0 );\n\n  pCsr->nAdvance = 0;\n  pCsr->bRestart = 1;\n  for(i=0; i<pCsr->nSegment; i++){\n    pCsr->apSegment[i]->pOffsetList = 0;\n    pCsr->apSegment[i]->nOffsetList = 0;\n    pCsr->apSegment[i]->iDocid = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n\nint sqlite3Fts3SegReaderStep(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr        /* Cursor object */\n){\n  int rc = SQLITE_OK;\n\n  int isIgnoreEmpty =  (pCsr->pFilter->flags & FTS3_SEGMENT_IGNORE_EMPTY);\n  int isRequirePos =   (pCsr->pFilter->flags & FTS3_SEGMENT_REQUIRE_POS);\n  int isColFilter =    (pCsr->pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER);\n  int isPrefix =       (pCsr->pFilter->flags & FTS3_SEGMENT_PREFIX);\n  int isScan =         (pCsr->pFilter->flags & FTS3_SEGMENT_SCAN);\n  int isFirst =        (pCsr->pFilter->flags & FTS3_SEGMENT_FIRST);\n\n  Fts3SegReader **apSegment = pCsr->apSegment;\n  int nSegment = pCsr->nSegment;\n  Fts3SegFilter *pFilter = pCsr->pFilter;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( pCsr->nSegment==0 ) return SQLITE_OK;\n\n  do {\n    int nMerge;\n    int i;\n  \n    /* Advance the first pCsr->nAdvance entries in the apSegment[] array\n    ** forward. Then sort the list in order of current term again.  \n    */\n    for(i=0; i<pCsr->nAdvance; i++){\n      Fts3SegReader *pSeg = apSegment[i];\n      if( pSeg->bLookup ){\n        fts3SegReaderSetEof(pSeg);\n      }else{\n        rc = fts3SegReaderNext(p, pSeg, 0);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    fts3SegReaderSort(apSegment, nSegment, pCsr->nAdvance, fts3SegReaderCmp);\n    pCsr->nAdvance = 0;\n\n    /* If all the seg-readers are at EOF, we're finished. return SQLITE_OK. */\n    assert( rc==SQLITE_OK );\n    if( apSegment[0]->aNode==0 ) break;\n\n    pCsr->nTerm = apSegment[0]->nTerm;\n    pCsr->zTerm = apSegment[0]->zTerm;\n\n    /* If this is a prefix-search, and if the term that apSegment[0] points\n    ** to does not share a suffix with pFilter->zTerm/nTerm, then all \n    ** required callbacks have been made. In this case exit early.\n    **\n    ** Similarly, if this is a search for an exact match, and the first term\n    ** of segment apSegment[0] is not a match, exit early.\n    */\n    if( pFilter->zTerm && !isScan ){\n      if( pCsr->nTerm<pFilter->nTerm \n       || (!isPrefix && pCsr->nTerm>pFilter->nTerm)\n       || memcmp(pCsr->zTerm, pFilter->zTerm, pFilter->nTerm) \n      ){\n        break;\n      }\n    }\n\n    nMerge = 1;\n    while( nMerge<nSegment \n        && apSegment[nMerge]->aNode\n        && apSegment[nMerge]->nTerm==pCsr->nTerm \n        && 0==memcmp(pCsr->zTerm, apSegment[nMerge]->zTerm, pCsr->nTerm)\n    ){\n      nMerge++;\n    }\n\n    assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );\n    if( nMerge==1 \n     && !isIgnoreEmpty \n     && !isFirst \n     && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)\n    ){\n      pCsr->nDoclist = apSegment[0]->nDoclist;\n      if( fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);\n        pCsr->aDoclist = pCsr->aBuffer;\n      }else{\n        pCsr->aDoclist = apSegment[0]->aDoclist;\n      }\n      if( rc==SQLITE_OK ) rc = SQLITE_ROW;\n    }else{\n      int nDoclist = 0;           /* Size of doclist */\n      sqlite3_int64 iPrev = 0;    /* Previous docid stored in doclist */\n\n      /* The current term of the first nMerge entries in the array\n      ** of Fts3SegReader objects is the same. The doclists must be merged\n      ** and a single term returned with the merged doclist.\n      */\n      for(i=0; i<nMerge; i++){\n        fts3SegReaderFirstDocid(p, apSegment[i]);\n      }\n      fts3SegReaderSort(apSegment, nMerge, nMerge, xCmp);\n      while( apSegment[0]->pOffsetList ){\n        int j;                    /* Number of segments that share a docid */\n        char *pList = 0;\n        int nList = 0;\n        int nByte;\n        sqlite3_int64 iDocid = apSegment[0]->iDocid;\n        fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n        j = 1;\n        while( j<nMerge\n            && apSegment[j]->pOffsetList\n            && apSegment[j]->iDocid==iDocid\n        ){\n          fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n          j++;\n        }\n\n        if( isColFilter ){\n          fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList);\n        }\n\n        if( !isIgnoreEmpty || nList>0 ){\n\n          /* Calculate the 'docid' delta value to write into the merged \n          ** doclist. */\n          sqlite3_int64 iDelta;\n          if( p->bDescIdx && nDoclist>0 ){\n            iDelta = iPrev - iDocid;\n          }else{\n            iDelta = iDocid - iPrev;\n          }\n          assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );\n          assert( nDoclist>0 || iDelta==iDocid );\n\n          nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);\n          if( nDoclist+nByte>pCsr->nBuffer ){\n            char *aNew;\n            pCsr->nBuffer = (nDoclist+nByte)*2;\n            aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);\n            if( !aNew ){\n              return SQLITE_NOMEM;\n            }\n            pCsr->aBuffer = aNew;\n          }\n\n          if( isFirst ){\n            char *a = &pCsr->aBuffer[nDoclist];\n            int nWrite;\n           \n            nWrite = sqlite3Fts3FirstFilter(iDelta, pList, nList, a);\n            if( nWrite ){\n              iPrev = iDocid;\n              nDoclist += nWrite;\n            }\n          }else{\n            nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta);\n            iPrev = iDocid;\n            if( isRequirePos ){\n              memcpy(&pCsr->aBuffer[nDoclist], pList, nList);\n              nDoclist += nList;\n              pCsr->aBuffer[nDoclist++] = '\\0';\n            }\n          }\n        }\n\n        fts3SegReaderSort(apSegment, nMerge, j, xCmp);\n      }\n      if( nDoclist>0 ){\n        pCsr->aDoclist = pCsr->aBuffer;\n        pCsr->nDoclist = nDoclist;\n        rc = SQLITE_ROW;\n      }\n    }\n    pCsr->nAdvance = nMerge;\n  }while( rc==SQLITE_OK );\n\n  return rc;\n}\n\n\nvoid sqlite3Fts3SegReaderFinish(\n  Fts3MultiSegReader *pCsr       /* Cursor object */\n){\n  if( pCsr ){\n    int i;\n    for(i=0; i<pCsr->nSegment; i++){\n      sqlite3Fts3SegReaderFree(pCsr->apSegment[i]);\n    }\n    sqlite3_free(pCsr->apSegment);\n    sqlite3_free(pCsr->aBuffer);\n\n    pCsr->nSegment = 0;\n    pCsr->apSegment = 0;\n    pCsr->aBuffer = 0;\n  }\n}\n\n/*\n** Decode the \"end_block\" field, selected by column iCol of the SELECT \n** statement passed as the first argument. \n**\n** The \"end_block\" field may contain either an integer, or a text field\n** containing the text representation of two non-negative integers separated \n** by one or more space (0x20) characters. In the first case, set *piEndBlock \n** to the integer value and *pnByte to zero before returning. In the second, \n** set *piEndBlock to the first value and *pnByte to the second.\n*/\nstatic void fts3ReadEndBlockField(\n  sqlite3_stmt *pStmt, \n  int iCol, \n  i64 *piEndBlock,\n  i64 *pnByte\n){\n  const unsigned char *zText = sqlite3_column_text(pStmt, iCol);\n  if( zText ){\n    int i;\n    int iMul = 1;\n    i64 iVal = 0;\n    for(i=0; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *piEndBlock = iVal;\n    while( zText[i]==' ' ) i++;\n    iVal = 0;\n    if( zText[i]=='-' ){\n      i++;\n      iMul = -1;\n    }\n    for(/* no-op */; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *pnByte = (iVal * (i64)iMul);\n  }\n}\n\n\n/*\n** A segment of size nByte bytes has just been written to absolute level\n** iAbsLevel. Promote any segments that should be promoted as a result.\n*/\nstatic int fts3PromoteSegments(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level just updated */\n  sqlite3_int64 nByte             /* Size of new segment at iAbsLevel */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pRange;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE2, &pRange, 0);\n\n  if( rc==SQLITE_OK ){\n    int bOk = 0;\n    i64 iLast = (iAbsLevel/FTS3_SEGDIR_MAXLEVEL + 1) * FTS3_SEGDIR_MAXLEVEL - 1;\n    i64 nLimit = (nByte*3)/2;\n\n    /* Loop through all entries in the %_segdir table corresponding to \n    ** segments in this index on levels greater than iAbsLevel. If there is\n    ** at least one such segment, and it is possible to determine that all \n    ** such segments are smaller than nLimit bytes in size, they will be \n    ** promoted to level iAbsLevel.  */\n    sqlite3_bind_int64(pRange, 1, iAbsLevel+1);\n    sqlite3_bind_int64(pRange, 2, iLast);\n    while( SQLITE_ROW==sqlite3_step(pRange) ){\n      i64 nSize = 0, dummy;\n      fts3ReadEndBlockField(pRange, 2, &dummy, &nSize);\n      if( nSize<=0 || nSize>nLimit ){\n        /* If nSize==0, then the %_segdir.end_block field does not not \n        ** contain a size value. This happens if it was written by an\n        ** old version of FTS. In this case it is not possible to determine\n        ** the size of the segment, and so segment promotion does not\n        ** take place.  */\n        bOk = 0;\n        break;\n      }\n      bOk = 1;\n    }\n    rc = sqlite3_reset(pRange);\n\n    if( bOk ){\n      int iIdx = 0;\n      sqlite3_stmt *pUpdate1 = 0;\n      sqlite3_stmt *pUpdate2 = 0;\n\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL_IDX, &pUpdate1, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL, &pUpdate2, 0);\n      }\n\n      if( rc==SQLITE_OK ){\n\n        /* Loop through all %_segdir entries for segments in this index with\n        ** levels equal to or greater than iAbsLevel. As each entry is visited,\n        ** updated it to set (level = -1) and (idx = N), where N is 0 for the\n        ** oldest segment in the range, 1 for the next oldest, and so on.\n        **\n        ** In other words, move all segments being promoted to level -1,\n        ** setting the \"idx\" fields as appropriate to keep them in the same\n        ** order. The contents of level -1 (which is never used, except\n        ** transiently here), will be moved back to level iAbsLevel below.  */\n        sqlite3_bind_int64(pRange, 1, iAbsLevel);\n        while( SQLITE_ROW==sqlite3_step(pRange) ){\n          sqlite3_bind_int(pUpdate1, 1, iIdx++);\n          sqlite3_bind_int(pUpdate1, 2, sqlite3_column_int(pRange, 0));\n          sqlite3_bind_int(pUpdate1, 3, sqlite3_column_int(pRange, 1));\n          sqlite3_step(pUpdate1);\n          rc = sqlite3_reset(pUpdate1);\n          if( rc!=SQLITE_OK ){\n            sqlite3_reset(pRange);\n            break;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_reset(pRange);\n      }\n\n      /* Move level -1 to level iAbsLevel */\n      if( rc==SQLITE_OK ){\n        sqlite3_bind_int64(pUpdate2, 1, iAbsLevel);\n        sqlite3_step(pUpdate2);\n        rc = sqlite3_reset(pUpdate2);\n      }\n    }\n  }\n\n\n  return rc;\n}\n\n/*\n** Merge all level iLevel segments in the database into a single \n** iLevel+1 segment. Or, if iLevel<0, merge all segments into a\n** single segment with a level equal to the numerically largest level \n** currently present in the database.\n**\n** If this function is called with iLevel<0, but there is only one\n** segment in the database, SQLITE_DONE is returned immediately. \n** Otherwise, if successful, SQLITE_OK is returned. If an error occurs, \n** an SQLite error code is returned.\n*/\nstatic int fts3SegmentMerge(\n  Fts3Table *p, \n  int iLangid,                    /* Language id to merge */\n  int iIndex,                     /* Index in p->aIndex[] to merge */\n  int iLevel                      /* Level to merge */\n){\n  int rc;                         /* Return code */\n  int iIdx = 0;                   /* Index of new segment */\n  sqlite3_int64 iNewLevel = 0;    /* Level/index to create new segment at */\n  SegmentWriter *pWriter = 0;     /* Used to write the new, merged, segment */\n  Fts3SegFilter filter;           /* Segment term filter condition */\n  Fts3MultiSegReader csr;         /* Cursor to iterate through level(s) */\n  int bIgnoreEmpty = 0;           /* True to ignore empty segments */\n  i64 iMaxLevel = 0;              /* Max level number for this index/langid */\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n       || iLevel==FTS3_SEGCURSOR_PENDING\n       || iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);\n  if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iMaxLevel);\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    /* This call is to merge all segments in the database to a single\n    ** segment. The level of the new segment is equal to the numerically\n    ** greatest segment level currently present in the database for this\n    ** index. The idx of the new segment is always 0.  */\n    if( csr.nSegment==1 && 0==fts3SegReaderIsPending(csr.apSegment[0]) ){\n      rc = SQLITE_DONE;\n      goto finished;\n    }\n    iNewLevel = iMaxLevel;\n    bIgnoreEmpty = 1;\n\n  }else{\n    /* This call is to merge all segments at level iLevel. find the next\n    ** available segment index at level iLevel+1. The call to\n    ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to \n    ** a single iLevel+2 segment if necessary.  */\n    assert( FTS3_SEGCURSOR_PENDING==-1 );\n    iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, iLevel+1);\n    rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);\n    bIgnoreEmpty = (iLevel!=FTS3_SEGCURSOR_PENDING) && (iNewLevel>iMaxLevel);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n\n  assert( csr.nSegment>0 );\n  assert( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );\n  assert( iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) );\n\n  memset(&filter, 0, sizeof(Fts3SegFilter));\n  filter.flags = FTS3_SEGMENT_REQUIRE_POS;\n  filter.flags |= (bIgnoreEmpty ? FTS3_SEGMENT_IGNORE_EMPTY : 0);\n\n  rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  while( SQLITE_OK==rc ){\n    rc = sqlite3Fts3SegReaderStep(p, &csr);\n    if( rc!=SQLITE_ROW ) break;\n    rc = fts3SegWriterAdd(p, &pWriter, 1, \n        csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n  assert( pWriter || bIgnoreEmpty );\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3DeleteSegdir(\n        p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment\n    );\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n  if( pWriter ){\n    rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);\n    if( rc==SQLITE_OK ){\n      if( iLevel==FTS3_SEGCURSOR_PENDING || iNewLevel<iMaxLevel ){\n        rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);\n      }\n    }\n  }\n\n finished:\n  fts3SegWriterFree(pWriter);\n  sqlite3Fts3SegReaderFinish(&csr);\n  return rc;\n}\n\n\n/* \n** Flush the contents of pendingTerms to level 0 segments. \n*/\nint sqlite3Fts3PendingTermsFlush(Fts3Table *p){\n  int rc = SQLITE_OK;\n  int i;\n        \n  for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n    rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Determine the auto-incr-merge setting if unknown.  If enabled,\n  ** estimate the number of leaf blocks of content to be written\n  */\n  if( rc==SQLITE_OK && p->bHasStat\n   && p->nAutoincrmerge==0xff && p->nLeafAdd>0\n  ){\n    sqlite3_stmt *pStmt = 0;\n    rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n      rc = sqlite3_step(pStmt);\n      if( rc==SQLITE_ROW ){\n        p->nAutoincrmerge = sqlite3_column_int(pStmt, 0);\n        if( p->nAutoincrmerge==1 ) p->nAutoincrmerge = 8;\n      }else if( rc==SQLITE_DONE ){\n        p->nAutoincrmerge = 0;\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Encode N integers as varints into a blob.\n*/\nstatic void fts3EncodeIntArray(\n  int N,             /* The number of integers to encode */\n  u32 *a,            /* The integer values */\n  char *zBuf,        /* Write the BLOB here */\n  int *pNBuf         /* Write number of bytes if zBuf[] used here */\n){\n  int i, j;\n  for(i=j=0; i<N; i++){\n    j += sqlite3Fts3PutVarint(&zBuf[j], (sqlite3_int64)a[i]);\n  }\n  *pNBuf = j;\n}\n\n/*\n** Decode a blob of varints into N integers\n*/\nstatic void fts3DecodeIntArray(\n  int N,             /* The number of integers to decode */\n  u32 *a,            /* Write the integer values */\n  const char *zBuf,  /* The BLOB containing the varints */\n  int nBuf           /* size of the BLOB */\n){\n  int i, j;\n  UNUSED_PARAMETER(nBuf);\n  for(i=j=0; i<N; i++){\n    sqlite3_int64 x;\n    j += sqlite3Fts3GetVarint(&zBuf[j], &x);\n    assert(j<=nBuf);\n    a[i] = (u32)(x & 0xffffffff);\n  }\n}\n\n/*\n** Insert the sizes (in tokens) for each column of the document\n** with docid equal to p->iPrevDocid.  The sizes are encoded as\n** a blob of varints.\n*/\nstatic void fts3InsertDocsize(\n  int *pRC,                       /* Result code */\n  Fts3Table *p,                   /* Table into which to insert */\n  u32 *aSz                        /* Sizes of each column, in tokens */\n){\n  char *pBlob;             /* The BLOB encoding of the document size */\n  int nBlob;               /* Number of bytes in the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement used to insert the encoding */\n  int rc;                  /* Result code from subfunctions */\n\n  if( *pRC ) return;\n  pBlob = sqlite3_malloc( 10*p->nColumn );\n  if( pBlob==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  fts3EncodeIntArray(p->nColumn, aSz, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_DOCSIZE, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(pBlob);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int64(pStmt, 1, p->iPrevDocid);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, sqlite3_free);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n}\n\n/*\n** Record 0 of the %_stat table contains a blob consisting of N varints,\n** where N is the number of user defined columns in the fts3 table plus\n** two. If nCol is the number of user defined columns, then values of the \n** varints are set as follows:\n**\n**   Varint 0:       Total number of rows in the table.\n**\n**   Varint 1..nCol: For each column, the total number of tokens stored in\n**                   the column for all rows of the table.\n**\n**   Varint 1+nCol:  The total size, in bytes, of all text values in all\n**                   columns of all rows of the table.\n**\n*/\nstatic void fts3UpdateDocTotals(\n  int *pRC,                       /* The result code */\n  Fts3Table *p,                   /* Table being updated */\n  u32 *aSzIns,                    /* Size increases */\n  u32 *aSzDel,                    /* Size decreases */\n  int nChng                       /* Change in the number of documents */\n){\n  char *pBlob;             /* Storage for BLOB written into %_stat */\n  int nBlob;               /* Size of BLOB written into %_stat */\n  u32 *a;                  /* Array of integers that becomes the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement for reading and writing */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subfunctions */\n\n  const int nStat = p->nColumn+2;\n\n  if( *pRC ) return;\n  a = sqlite3_malloc( (sizeof(u32)+10)*nStat );\n  if( a==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  pBlob = (char*)&a[nStat];\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    fts3DecodeIntArray(nStat, a,\n         sqlite3_column_blob(pStmt, 0),\n         sqlite3_column_bytes(pStmt, 0));\n  }else{\n    memset(a, 0, sizeof(u32)*(nStat) );\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  if( nChng<0 && a[0]<(u32)(-nChng) ){\n    a[0] = 0;\n  }else{\n    a[0] += nChng;\n  }\n  for(i=0; i<p->nColumn+1; i++){\n    u32 x = a[i+1];\n    if( x+aSzIns[i] < aSzDel[i] ){\n      x = 0;\n    }else{\n      x = x + aSzIns[i] - aSzDel[i];\n    }\n    a[i+1] = x;\n  }\n  fts3EncodeIntArray(nStat, a, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n  sqlite3_free(a);\n}\n\n/*\n** Merge the entire database so that there is one segment for each \n** iIndex/iLangid combination.\n*/\nstatic int fts3DoOptimize(Fts3Table *p, int bReturnDone){\n  int bSeenDone = 0;\n  int rc;\n  sqlite3_stmt *pAllLangid = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int i;\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n        rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);\n        if( rc==SQLITE_DONE ){\n          bSeenDone = 1;\n          rc = SQLITE_OK;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3Fts3PendingTermsClear(p);\n\n  return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;\n}\n\n/*\n** This function is called when the user executes the following statement:\n**\n**     INSERT INTO <tbl>(<tbl>) VALUES('rebuild');\n**\n** The entire FTS index is discarded and rebuilt. If the table is one \n** created using the content=xxx option, then the new index is based on\n** the current contents of the xxx table. Otherwise, it is rebuilt based\n** on the contents of the %_content table.\n*/\nstatic int fts3DoRebuild(Fts3Table *p){\n  int rc;                         /* Return Code */\n\n  rc = fts3DeleteAll(p, 0);\n  if( rc==SQLITE_OK ){\n    u32 *aSz = 0;\n    u32 *aSzIns = 0;\n    u32 *aSzDel = 0;\n    sqlite3_stmt *pStmt = 0;\n    int nEntry = 0;\n\n    /* Compose and prepare an SQL statement to loop through the content table */\n    char *zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    if( rc==SQLITE_OK ){\n      int nByte = sizeof(u32) * (p->nColumn+1)*3;\n      aSz = (u32 *)sqlite3_malloc(nByte);\n      if( aSz==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(aSz, 0, nByte);\n        aSzIns = &aSz[p->nColumn+1];\n        aSzDel = &aSzIns[p->nColumn+1];\n      }\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      int iCol;\n      int iLangid = langidFromSelect(p, pStmt);\n      rc = fts3PendingTermsDocid(p, 0, iLangid, sqlite3_column_int64(pStmt, 0));\n      memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);\n          rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);\n        }\n      }\n      if( p->bHasDocsize ){\n        fts3InsertDocsize(&rc, p, aSz);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_finalize(pStmt);\n        pStmt = 0;\n      }else{\n        nEntry++;\n        for(iCol=0; iCol<=p->nColumn; iCol++){\n          aSzIns[iCol] += aSz[iCol];\n        }\n      }\n    }\n    if( p->bFts4 ){\n      fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);\n    }\n    sqlite3_free(aSz);\n\n    if( pStmt ){\n      int rc2 = sqlite3_finalize(pStmt);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** This function opens a cursor used to read the input data for an \n** incremental merge operation. Specifically, it opens a cursor to scan\n** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute \n** level iAbsLevel.\n*/\nstatic int fts3IncrmergeCsr(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to open */\n  int nSeg,                       /* Number of segments to merge */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  \n  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */\n\n  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */\n  memset(pCsr, 0, sizeof(*pCsr));\n  nByte = sizeof(Fts3SegReader *) * nSeg;\n  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);\n\n  if( pCsr->apSegment==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pCsr->apSegment, 0, nByte);\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n  }\n  if( rc==SQLITE_OK ){\n    int i;\n    int rc2;\n    sqlite3_bind_int64(pStmt, 1, iAbsLevel);\n    assert( pCsr->nSegment==0 );\n    for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){\n      rc = sqlite3Fts3SegReaderNew(i, 0,\n          sqlite3_column_int64(pStmt, 1),        /* segdir.start_block */\n          sqlite3_column_int64(pStmt, 2),        /* segdir.leaves_end_block */\n          sqlite3_column_int64(pStmt, 3),        /* segdir.end_block */\n          sqlite3_column_blob(pStmt, 4),         /* segdir.root */\n          sqlite3_column_bytes(pStmt, 4),        /* segdir.root */\n          &pCsr->apSegment[i]\n      );\n      pCsr->nSegment++;\n    }\n    rc2 = sqlite3_reset(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\ntypedef struct IncrmergeWriter IncrmergeWriter;\ntypedef struct NodeWriter NodeWriter;\ntypedef struct Blob Blob;\ntypedef struct NodeReader NodeReader;\n\n/*\n** An instance of the following structure is used as a dynamic buffer\n** to build up nodes or other blobs of data in.\n**\n** The function blobGrowBuffer() is used to extend the allocation.\n*/\nstruct Blob {\n  char *a;                        /* Pointer to allocation */\n  int n;                          /* Number of valid bytes of data in a[] */\n  int nAlloc;                     /* Allocated size of a[] (nAlloc>=n) */\n};\n\n/*\n** This structure is used to build up buffers containing segment b-tree \n** nodes (blocks).\n*/\nstruct NodeWriter {\n  sqlite3_int64 iBlock;           /* Current block id */\n  Blob key;                       /* Last key written to the current block */\n  Blob block;                     /* Current block image */\n};\n\n/*\n** An object of this type contains the state required to create or append\n** to an appendable b-tree segment.\n*/\nstruct IncrmergeWriter {\n  int nLeafEst;                   /* Space allocated for leaf blocks */\n  int nWork;                      /* Number of leaf pages flushed */\n  sqlite3_int64 iAbsLevel;        /* Absolute level of input segments */\n  int iIdx;                       /* Index of *output* segment in iAbsLevel+1 */\n  sqlite3_int64 iStart;           /* Block number of first allocated block */\n  sqlite3_int64 iEnd;             /* Block number of last allocated block */\n  sqlite3_int64 nLeafData;        /* Bytes of leaf page data so far */\n  u8 bNoLeafData;                 /* If true, store 0 for segment size */\n  NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];\n};\n\n/*\n** An object of the following type is used to read data from a single\n** FTS segment node. See the following functions:\n**\n**     nodeReaderInit()\n**     nodeReaderNext()\n**     nodeReaderRelease()\n*/\nstruct NodeReader {\n  const char *aNode;\n  int nNode;\n  int iOff;                       /* Current offset within aNode[] */\n\n  /* Output variables. Containing the current node entry. */\n  sqlite3_int64 iChild;           /* Pointer to child node */\n  Blob term;                      /* Current term */\n  const char *aDoclist;           /* Pointer to doclist */\n  int nDoclist;                   /* Size of doclist in bytes */\n};\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if the allocation at pBlob->a is not already at least nMin\n** bytes in size, extend (realloc) it to be so.\n**\n** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a\n** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc\n** to reflect the new size of the pBlob->a[] buffer.\n*/\nstatic void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){\n  if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){\n    int nAlloc = nMin;\n    char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);\n    if( a ){\n      pBlob->nAlloc = nAlloc;\n      pBlob->a = a;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Attempt to advance the node-reader object passed as the first argument to\n** the next entry on the node. \n**\n** Return an error code if an error occurs (SQLITE_NOMEM is possible). \n** Otherwise return SQLITE_OK. If there is no next entry on the node\n** (e.g. because the current entry is the last) set NodeReader->aNode to\n** NULL to indicate EOF. Otherwise, populate the NodeReader structure output \n** variables for the new entry.\n*/\nstatic int nodeReaderNext(NodeReader *p){\n  int bFirst = (p->term.n==0);    /* True for first term on the node */\n  int nPrefix = 0;                /* Bytes to copy from previous term */\n  int nSuffix = 0;                /* Bytes to append to the prefix */\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( p->aNode );\n  if( p->iChild && bFirst==0 ) p->iChild++;\n  if( p->iOff>=p->nNode ){\n    /* EOF */\n    p->aNode = 0;\n  }else{\n    if( bFirst==0 ){\n      p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);\n    }\n    p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);\n\n    blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);\n    if( rc==SQLITE_OK ){\n      memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);\n      p->term.n = nPrefix+nSuffix;\n      p->iOff += nSuffix;\n      if( p->iChild==0 ){\n        p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);\n        p->aDoclist = &p->aNode[p->iOff];\n        p->iOff += p->nDoclist;\n      }\n    }\n  }\n\n  assert( p->iOff<=p->nNode );\n\n  return rc;\n}\n\n/*\n** Release all dynamic resources held by node-reader object *p.\n*/\nstatic void nodeReaderRelease(NodeReader *p){\n  sqlite3_free(p->term.a);\n}\n\n/*\n** Initialize a node-reader object to read the node in buffer aNode/nNode.\n**\n** If successful, SQLITE_OK is returned and the NodeReader object set to \n** point to the first entry on the node (if any). Otherwise, an SQLite\n** error code is returned.\n*/\nstatic int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){\n  memset(p, 0, sizeof(NodeReader));\n  p->aNode = aNode;\n  p->nNode = nNode;\n\n  /* Figure out if this is a leaf or an internal node. */\n  if( p->aNode[0] ){\n    /* An internal node. */\n    p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);\n  }else{\n    p->iOff = 1;\n  }\n\n  return nodeReaderNext(p);\n}\n\n/*\n** This function is called while writing an FTS segment each time a leaf o\n** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed\n** to be greater than the largest key on the node just written, but smaller\n** than or equal to the first key that will be written to the next leaf\n** node.\n**\n** The block id of the leaf node just written to disk may be found in\n** (pWriter->aNodeWriter[0].iBlock) when this function is called.\n*/\nstatic int fts3IncrmergePush(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  const char *zTerm,              /* Term to write to internal node */\n  int nTerm                       /* Bytes at zTerm */\n){\n  sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;\n  int iLayer;\n\n  assert( nTerm>0 );\n  for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){\n    sqlite3_int64 iNextPtr = 0;\n    NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];\n    int rc = SQLITE_OK;\n    int nPrefix;\n    int nSuffix;\n    int nSpace;\n\n    /* Figure out how much space the key will consume if it is written to\n    ** the current node of layer iLayer. Due to the prefix compression, \n    ** the space required changes depending on which node the key is to\n    ** be added to.  */\n    nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);\n    nSuffix = nTerm - nPrefix;\n    nSpace  = sqlite3Fts3VarintLen(nPrefix);\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n\n    if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){ \n      /* If the current node of layer iLayer contains zero keys, or if adding\n      ** the key to it will not cause it to grow to larger than nNodeSize \n      ** bytes in size, write the key here.  */\n\n      Blob *pBlk = &pNode->block;\n      if( pBlk->n==0 ){\n        blobGrowBuffer(pBlk, p->nNodeSize, &rc);\n        if( rc==SQLITE_OK ){\n          pBlk->a[0] = (char)iLayer;\n          pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);\n        }\n      }\n      blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);\n      blobGrowBuffer(&pNode->key, nTerm, &rc);\n\n      if( rc==SQLITE_OK ){\n        if( pNode->key.n ){\n          pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);\n        }\n        pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);\n        memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);\n        pBlk->n += nSuffix;\n\n        memcpy(pNode->key.a, zTerm, nTerm);\n        pNode->key.n = nTerm;\n      }\n    }else{\n      /* Otherwise, flush the current node of layer iLayer to disk.\n      ** Then allocate a new, empty sibling node. The key will be written\n      ** into the parent of this node. */\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n\n      assert( pNode->block.nAlloc>=p->nNodeSize );\n      pNode->block.a[0] = (char)iLayer;\n      pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);\n\n      iNextPtr = pNode->iBlock;\n      pNode->iBlock++;\n      pNode->key.n = 0;\n    }\n\n    if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;\n    iPtr = iNextPtr;\n  }\n\n  assert( 0 );\n  return 0;\n}\n\n/*\n** Append a term and (optionally) doclist to the FTS segment node currently\n** stored in blob *pNode. The node need not contain any terms, but the\n** header must be written before this function is called.\n**\n** A node header is a single 0x00 byte for a leaf node, or a height varint\n** followed by the left-hand-child varint for an internal node.\n**\n** The term to be appended is passed via arguments zTerm/nTerm. For a \n** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal\n** node, both aDoclist and nDoclist must be passed 0.\n**\n** If the size of the value in blob pPrev is zero, then this is the first\n** term written to the node. Otherwise, pPrev contains a copy of the \n** previous term. Before this function returns, it is updated to contain a\n** copy of zTerm/nTerm.\n**\n** It is assumed that the buffer associated with pNode is already large\n** enough to accommodate the new entry. The buffer associated with pPrev\n** is extended by this function if requrired.\n**\n** If an error (i.e. OOM condition) occurs, an SQLite error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3AppendToNode(\n  Blob *pNode,                    /* Current node image to append to */\n  Blob *pPrev,                    /* Buffer containing previous term written */\n  const char *zTerm,              /* New term to write */\n  int nTerm,                      /* Size of zTerm in bytes */\n  const char *aDoclist,           /* Doclist (or NULL) to write */\n  int nDoclist                    /* Size of aDoclist in bytes */ \n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFirst = (pPrev->n==0);     /* True if this is the first term written */\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n\n  /* Node must have already been started. There must be a doclist for a\n  ** leaf node, and there must not be a doclist for an internal node.  */\n  assert( pNode->n>0 );\n  assert( (pNode->a[0]=='\\0')==(aDoclist!=0) );\n\n  blobGrowBuffer(pPrev, nTerm, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n  memcpy(pPrev->a, zTerm, nTerm);\n  pPrev->n = nTerm;\n\n  if( bFirst==0 ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);\n  }\n  pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);\n  memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);\n  pNode->n += nSuffix;\n\n  if( aDoclist ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);\n    memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);\n    pNode->n += nDoclist;\n  }\n\n  assert( pNode->n<=pNode->nAlloc );\n\n  return SQLITE_OK;\n}\n\n/*\n** Append the current term and doclist pointed to by cursor pCsr to the\n** appendable b-tree segment opened for writing by pWriter.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int fts3IncrmergeAppend(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  Fts3MultiSegReader *pCsr        /* Cursor containing term and doclist */\n){\n  const char *zTerm = pCsr->zTerm;\n  int nTerm = pCsr->nTerm;\n  const char *aDoclist = pCsr->aDoclist;\n  int nDoclist = pCsr->nDoclist;\n  int rc = SQLITE_OK;           /* Return code */\n  int nSpace;                   /* Total space in bytes required on leaf */\n  int nPrefix;                  /* Size of prefix shared with previous term */\n  int nSuffix;                  /* Size of suffix (nTerm - nPrefix) */\n  NodeWriter *pLeaf;            /* Object used to write leaf nodes */\n\n  pLeaf = &pWriter->aNodeWriter[0];\n  nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n\n  nSpace  = sqlite3Fts3VarintLen(nPrefix);\n  nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n  nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n\n  /* If the current block is not empty, and if adding this term/doclist\n  ** to the current block would make it larger than Fts3Table.nNodeSize\n  ** bytes, write this block out to the database. */\n  if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){\n    rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);\n    pWriter->nWork++;\n\n    /* Add the current term to the parent node. The term added to the \n    ** parent must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pLeaf->key), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);\n    }\n\n    /* Advance to the next output block */\n    pLeaf->iBlock++;\n    pLeaf->key.n = 0;\n    pLeaf->block.n = 0;\n\n    nSuffix = nTerm;\n    nSpace  = 1;\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n    nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n  }\n\n  pWriter->nLeafData += nSpace;\n  blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);\n  if( rc==SQLITE_OK ){\n    if( pLeaf->block.n==0 ){\n      pLeaf->block.n = 1;\n      pLeaf->block.a[0] = '\\0';\n    }\n    rc = fts3AppendToNode(\n        &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist\n    );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to release all dynamic resources held by the\n** merge-writer object pWriter, and if no error has occurred, to flush\n** all outstanding node buffers held by pWriter to disk.\n**\n** If *pRc is not SQLITE_OK when this function is called, then no attempt\n** is made to write any data to disk. Instead, this function serves only\n** to release outstanding resources.\n**\n** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while\n** flushing buffers to disk, *pRc is set to an SQLite error code before\n** returning.\n*/\nstatic void fts3IncrmergeRelease(\n  Fts3Table *p,                   /* FTS3 table handle */\n  IncrmergeWriter *pWriter,       /* Merge-writer object */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;                          /* Used to iterate through non-root layers */\n  int iRoot;                      /* Index of root in pWriter->aNodeWriter */\n  NodeWriter *pRoot;              /* NodeWriter for root node */\n  int rc = *pRc;                  /* Error code */\n\n  /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment \n  ** root node. If the segment fits entirely on a single leaf node, iRoot\n  ** will be set to 0. If the root node is the parent of the leaves, iRoot\n  ** will be 1. And so on.  */\n  for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){\n    NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];\n    if( pNode->block.n>0 ) break;\n    assert( *pRc || pNode->block.nAlloc==0 );\n    assert( *pRc || pNode->key.nAlloc==0 );\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Empty output segment. This is a no-op. */\n  if( iRoot<0 ) return;\n\n  /* The entire output segment fits on a single node. Normally, this means\n  ** the node would be stored as a blob in the \"root\" column of the %_segdir\n  ** table. However, this is not permitted in this case. The problem is that \n  ** space has already been reserved in the %_segments table, and so the \n  ** start_block and end_block fields of the %_segdir table must be populated. \n  ** And, by design or by accident, released versions of FTS cannot handle \n  ** segments that fit entirely on the root node with start_block!=0.\n  **\n  ** Instead, create a synthetic root node that contains nothing but a \n  ** pointer to the single content node. So that the segment consists of a\n  ** single leaf and a single interior (root) node.\n  **\n  ** Todo: Better might be to defer allocating space in the %_segments \n  ** table until we are sure it is needed.\n  */\n  if( iRoot==0 ){\n    Blob *pBlock = &pWriter->aNodeWriter[1].block;\n    blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);\n    if( rc==SQLITE_OK ){\n      pBlock->a[0] = 0x01;\n      pBlock->n = 1 + sqlite3Fts3PutVarint(\n          &pBlock->a[1], pWriter->aNodeWriter[0].iBlock\n      );\n    }\n    iRoot = 1;\n  }\n  pRoot = &pWriter->aNodeWriter[iRoot];\n\n  /* Flush all currently outstanding nodes to disk. */\n  for(i=0; i<iRoot; i++){\n    NodeWriter *pNode = &pWriter->aNodeWriter[i];\n    if( pNode->block.n>0 && rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n    }\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Write the %_segdir record. */\n  if( rc==SQLITE_OK ){\n    rc = fts3WriteSegdir(p, \n        pWriter->iAbsLevel+1,               /* level */\n        pWriter->iIdx,                      /* idx */\n        pWriter->iStart,                    /* start_block */\n        pWriter->aNodeWriter[0].iBlock,     /* leaves_end_block */\n        pWriter->iEnd,                      /* end_block */\n        (pWriter->bNoLeafData==0 ? pWriter->nLeafData : 0),   /* end_block */\n        pRoot->block.a, pRoot->block.n      /* root */\n    );\n  }\n  sqlite3_free(pRoot->block.a);\n  sqlite3_free(pRoot->key.a);\n\n  *pRc = rc;\n}\n\n/*\n** Compare the term in buffer zLhs (size in bytes nLhs) with that in\n** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of\n** the other, it is considered to be smaller than the other.\n**\n** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve\n** if it is greater.\n*/\nstatic int fts3TermCmp(\n  const char *zLhs, int nLhs,     /* LHS of comparison */\n  const char *zRhs, int nRhs      /* RHS of comparison */\n){\n  int nCmp = MIN(nLhs, nRhs);\n  int res;\n\n  res = memcmp(zLhs, zRhs, nCmp);\n  if( res==0 ) res = nLhs - nRhs;\n\n  return res;\n}\n\n\n/*\n** Query to see if the entry in the %_segments table with blockid iEnd is \n** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before\n** returning. Otherwise, set *pbRes to 0. \n**\n** Or, if an error occurs while querying the database, return an SQLite \n** error code. The final value of *pbRes is undefined in this case.\n**\n** This is used to test if a segment is an \"appendable\" segment. If it\n** is, then a NULL entry has been inserted into the %_segments table\n** with blockid %_segdir.end_block.\n*/\nstatic int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){\n  int bRes = 0;                   /* Result to set *pbRes to */\n  sqlite3_stmt *pCheck = 0;       /* Statement to query database with */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pCheck, 1, iEnd);\n    if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;\n    rc = sqlite3_reset(pCheck);\n  }\n  \n  *pbRes = bRes;\n  return rc;\n}\n\n/*\n** This function is called when initializing an incremental-merge operation.\n** It checks if the existing segment with index value iIdx at absolute level \n** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the\n** merge-writer object *pWriter is initialized to write to it.\n**\n** An existing segment can be appended to by an incremental merge if:\n**\n**   * It was initially created as an appendable segment (with all required\n**     space pre-allocated), and\n**\n**   * The first key read from the input (arguments zKey and nKey) is \n**     greater than the largest key currently stored in the potential\n**     output segment.\n*/\nstatic int fts3IncrmergeLoad(\n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of candidate output segment */\n  const char *zKey,               /* First key to write */\n  int nKey,                       /* Number of bytes in nKey */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSelect = 0;      /* SELECT to read %_segdir entry */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_int64 iStart = 0;     /* Value of %_segdir.start_block */\n    sqlite3_int64 iLeafEnd = 0;   /* Value of %_segdir.leaves_end_block */\n    sqlite3_int64 iEnd = 0;       /* Value of %_segdir.end_block */\n    const char *aRoot = 0;        /* Pointer to %_segdir.root buffer */\n    int nRoot = 0;                /* Size of aRoot[] in bytes */\n    int rc2;                      /* Return code from sqlite3_reset() */\n    int bAppendable = 0;          /* Set to true if segment is appendable */\n\n    /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);\n    sqlite3_bind_int(pSelect, 2, iIdx);\n    if( sqlite3_step(pSelect)==SQLITE_ROW ){\n      iStart = sqlite3_column_int64(pSelect, 1);\n      iLeafEnd = sqlite3_column_int64(pSelect, 2);\n      fts3ReadEndBlockField(pSelect, 3, &iEnd, &pWriter->nLeafData);\n      if( pWriter->nLeafData<0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      pWriter->bNoLeafData = (pWriter->nLeafData==0);\n      nRoot = sqlite3_column_bytes(pSelect, 4);\n      aRoot = sqlite3_column_blob(pSelect, 4);\n    }else{\n      return sqlite3_reset(pSelect);\n    }\n\n    /* Check for the zero-length marker in the %_segments table */\n    rc = fts3IsAppendable(p, iEnd, &bAppendable);\n\n    /* Check that zKey/nKey is larger than the largest key the candidate */\n    if( rc==SQLITE_OK && bAppendable ){\n      char *aLeaf = 0;\n      int nLeaf = 0;\n\n      rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);\n      if( rc==SQLITE_OK ){\n        NodeReader reader;\n        for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);\n            rc==SQLITE_OK && reader.aNode;\n            rc = nodeReaderNext(&reader)\n        ){\n          assert( reader.aNode );\n        }\n        if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){\n          bAppendable = 0;\n        }\n        nodeReaderRelease(&reader);\n      }\n      sqlite3_free(aLeaf);\n    }\n\n    if( rc==SQLITE_OK && bAppendable ){\n      /* It is possible to append to this segment. Set up the IncrmergeWriter\n      ** object to do so.  */\n      int i;\n      int nHeight = (int)aRoot[0];\n      NodeWriter *pNode;\n\n      pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;\n      pWriter->iStart = iStart;\n      pWriter->iEnd = iEnd;\n      pWriter->iAbsLevel = iAbsLevel;\n      pWriter->iIdx = iIdx;\n\n      for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n        pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n      }\n\n      pNode = &pWriter->aNodeWriter[nHeight];\n      pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;\n      blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);\n      if( rc==SQLITE_OK ){\n        memcpy(pNode->block.a, aRoot, nRoot);\n        pNode->block.n = nRoot;\n      }\n\n      for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){\n        NodeReader reader;\n        pNode = &pWriter->aNodeWriter[i];\n\n        rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);\n        while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);\n        blobGrowBuffer(&pNode->key, reader.term.n, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pNode->key.a, reader.term.a, reader.term.n);\n          pNode->key.n = reader.term.n;\n          if( i>0 ){\n            char *aBlock = 0;\n            int nBlock = 0;\n            pNode = &pWriter->aNodeWriter[i-1];\n            pNode->iBlock = reader.iChild;\n            rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);\n            blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);\n            if( rc==SQLITE_OK ){\n              memcpy(pNode->block.a, aBlock, nBlock);\n              pNode->block.n = nBlock;\n            }\n            sqlite3_free(aBlock);\n          }\n        }\n        nodeReaderRelease(&reader);\n      }\n    }\n\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** Determine the largest segment index value that exists within absolute\n** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus\n** one before returning SQLITE_OK. Or, if there are no segments at all \n** within level iAbsLevel, set *piIdx to zero.\n**\n** If an error occurs, return an SQLite error code. The final value of\n** *piIdx is undefined in this case.\n*/\nstatic int fts3IncrmergeOutputIdx( \n  Fts3Table *p,                   /* FTS Table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute index of input segments */\n  int *piIdx                      /* OUT: Next free index at iAbsLevel+1 */\n){\n  int rc;\n  sqlite3_stmt *pOutputIdx = 0;   /* SQL used to find output index */\n\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);\n    sqlite3_step(pOutputIdx);\n    *piIdx = sqlite3_column_int(pOutputIdx, 0);\n    rc = sqlite3_reset(pOutputIdx);\n  }\n\n  return rc;\n}\n\n/* \n** Allocate an appendable output segment on absolute level iAbsLevel+1\n** with idx value iIdx.\n**\n** In the %_segdir table, a segment is defined by the values in three\n** columns:\n**\n**     start_block\n**     leaves_end_block\n**     end_block\n**\n** When an appendable segment is allocated, it is estimated that the\n** maximum number of leaf blocks that may be required is the sum of the\n** number of leaf blocks consumed by the input segments, plus the number\n** of input segments, multiplied by two. This value is stored in stack \n** variable nLeafEst.\n**\n** A total of 16*nLeafEst blocks are allocated when an appendable segment\n** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous\n** array of leaf nodes starts at the first block allocated. The array\n** of interior nodes that are parents of the leaf nodes start at block\n** (start_block + (1 + end_block - start_block) / 16). And so on.\n**\n** In the actual code below, the value \"16\" is replaced with the \n** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.\n*/\nstatic int fts3IncrmergeWriter( \n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of new output segment */\n  Fts3MultiSegReader *pCsr,       /* Cursor that data will be read from */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return Code */\n  int i;                          /* Iterator variable */\n  int nLeafEst = 0;               /* Blocks allocated for leaf nodes */\n  sqlite3_stmt *pLeafEst = 0;     /* SQL used to determine nLeafEst */\n  sqlite3_stmt *pFirstBlock = 0;  /* SQL used to determine first block */\n\n  /* Calculate nLeafEst. */\n  rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);\n    sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);\n    if( SQLITE_ROW==sqlite3_step(pLeafEst) ){\n      nLeafEst = sqlite3_column_int(pLeafEst, 0);\n    }\n    rc = sqlite3_reset(pLeafEst);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Calculate the first block to use in the output segment */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){\n      pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);\n      pWriter->iEnd = pWriter->iStart - 1;\n      pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;\n    }\n    rc = sqlite3_reset(pFirstBlock);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Insert the marker in the %_segments table to make sure nobody tries\n  ** to steal the space just allocated. This is also used to identify \n  ** appendable segments.  */\n  rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pWriter->iAbsLevel = iAbsLevel;\n  pWriter->nLeafEst = nLeafEst;\n  pWriter->iIdx = iIdx;\n\n  /* Set up the array of NodeWriter objects */\n  for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n    pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Remove an entry from the %_segdir table. This involves running the \n** following two statements:\n**\n**   DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx\n**   UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx\n**\n** The DELETE statement removes the specific %_segdir level. The UPDATE \n** statement ensures that the remaining segments have contiguously allocated\n** idx values.\n*/\nstatic int fts3RemoveSegdirEntry(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to delete from */\n  int iIdx                        /* Index of %_segdir entry to delete */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pDelete = 0;      /* DELETE statement */\n\n  rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pDelete, 1, iAbsLevel);\n    sqlite3_bind_int(pDelete, 2, iIdx);\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** One or more segments have just been removed from absolute level iAbsLevel.\n** Update the 'idx' values of the remaining segments in the level so that\n** the idx values are a contiguous sequence starting from 0.\n*/\nstatic int fts3RepackSegdirLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel         /* Absolute level to repack */\n){\n  int rc;                         /* Return code */\n  int *aIdx = 0;                  /* Array of remaining idx values */\n  int nIdx = 0;                   /* Valid entries in aIdx[] */\n  int nAlloc = 0;                 /* Allocated size of aIdx[] */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pSelect = 0;      /* Select statement to read idx values */\n  sqlite3_stmt *pUpdate = 0;      /* Update statement to modify idx values */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel);\n    while( SQLITE_ROW==sqlite3_step(pSelect) ){\n      if( nIdx>=nAlloc ){\n        int *aNew;\n        nAlloc += 16;\n        aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));\n        if( !aNew ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        aIdx = aNew;\n      }\n      aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pUpdate, 2, iAbsLevel);\n  }\n\n  assert( p->bIgnoreSavepoint==0 );\n  p->bIgnoreSavepoint = 1;\n  for(i=0; rc==SQLITE_OK && i<nIdx; i++){\n    if( aIdx[i]!=i ){\n      sqlite3_bind_int(pUpdate, 3, aIdx[i]);\n      sqlite3_bind_int(pUpdate, 1, i);\n      sqlite3_step(pUpdate);\n      rc = sqlite3_reset(pUpdate);\n    }\n  }\n  p->bIgnoreSavepoint = 0;\n\n  sqlite3_free(aIdx);\n  return rc;\n}\n\nstatic void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){\n  pNode->a[0] = (char)iHeight;\n  if( iChild ){\n    assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );\n    pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);\n  }else{\n    assert( pNode->nAlloc>=1 );\n    pNode->n = 1;\n  }\n}\n\n/*\n** The first two arguments are a pointer to and the size of a segment b-tree\n** node. The node may be a leaf or an internal node.\n**\n** This function creates a new node image in blob object *pNew by copying\n** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)\n** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.\n*/\nstatic int fts3TruncateNode(\n  const char *aNode,              /* Current node image */\n  int nNode,                      /* Size of aNode in bytes */\n  Blob *pNew,                     /* OUT: Write new node image here */\n  const char *zTerm,              /* Omit all terms smaller than this */\n  int nTerm,                      /* Size of zTerm in bytes */\n  sqlite3_int64 *piBlock          /* OUT: Block number in next layer down */\n){\n  NodeReader reader;              /* Reader object */\n  Blob prev = {0, 0, 0};          /* Previous term written to new node */\n  int rc = SQLITE_OK;             /* Return code */\n  int bLeaf = aNode[0]=='\\0';     /* True for a leaf node */\n\n  /* Allocate required output space */\n  blobGrowBuffer(pNew, nNode, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n  pNew->n = 0;\n\n  /* Populate new node buffer */\n  for(rc = nodeReaderInit(&reader, aNode, nNode); \n      rc==SQLITE_OK && reader.aNode; \n      rc = nodeReaderNext(&reader)\n  ){\n    if( pNew->n==0 ){\n      int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);\n      if( res<0 || (bLeaf==0 && res==0) ) continue;\n      fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n      *piBlock = reader.iChild;\n    }\n    rc = fts3AppendToNode(\n        pNew, &prev, reader.term.a, reader.term.n,\n        reader.aDoclist, reader.nDoclist\n    );\n    if( rc!=SQLITE_OK ) break;\n  }\n  if( pNew->n==0 ){\n    fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n    *piBlock = reader.iChild;\n  }\n  assert( pNew->n<=pNew->nAlloc );\n\n  nodeReaderRelease(&reader);\n  sqlite3_free(prev.a);\n  return rc;\n}\n\n/*\n** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute \n** level iAbsLevel. This may involve deleting entries from the %_segments\n** table, and modifying existing entries in both the %_segments and %_segdir\n** tables.\n**\n** SQLITE_OK is returned if the segment is updated successfully. Or an\n** SQLite error code otherwise.\n*/\nstatic int fts3TruncateSegment(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of segment to modify */\n  int iIdx,                       /* Index within level of segment to modify */\n  const char *zTerm,              /* Remove terms smaller than this */\n  int nTerm                      /* Number of bytes in buffer zTerm */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Blob root = {0,0,0};            /* New root page image */\n  Blob block = {0,0,0};           /* Buffer used for any other block */\n  sqlite3_int64 iBlock = 0;       /* Block id */\n  sqlite3_int64 iNewStart = 0;    /* New value for iStartBlock */\n  sqlite3_int64 iOldStart = 0;    /* Old value for iStartBlock */\n  sqlite3_stmt *pFetch = 0;       /* Statement used to fetch segdir */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;                      /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pFetch, 1, iAbsLevel);\n    sqlite3_bind_int(pFetch, 2, iIdx);\n    if( SQLITE_ROW==sqlite3_step(pFetch) ){\n      const char *aRoot = sqlite3_column_blob(pFetch, 4);\n      int nRoot = sqlite3_column_bytes(pFetch, 4);\n      iOldStart = sqlite3_column_int64(pFetch, 1);\n      rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);\n    }\n    rc2 = sqlite3_reset(pFetch);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  while( rc==SQLITE_OK && iBlock ){\n    char *aBlock = 0;\n    int nBlock = 0;\n    iNewStart = iBlock;\n\n    rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);\n    if( rc==SQLITE_OK ){\n      rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, iNewStart, block.a, block.n);\n    }\n    sqlite3_free(aBlock);\n  }\n\n  /* Variable iNewStart now contains the first valid leaf node. */\n  if( rc==SQLITE_OK && iNewStart ){\n    sqlite3_stmt *pDel = 0;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iOldStart);\n      sqlite3_bind_int64(pDel, 2, iNewStart-1);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_stmt *pChomp = 0;\n    rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pChomp, 1, iNewStart);\n      sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);\n      sqlite3_bind_int64(pChomp, 3, iAbsLevel);\n      sqlite3_bind_int(pChomp, 4, iIdx);\n      sqlite3_step(pChomp);\n      rc = sqlite3_reset(pChomp);\n    }\n  }\n\n  sqlite3_free(root.a);\n  sqlite3_free(block.a);\n  return rc;\n}\n\n/*\n** This function is called after an incrmental-merge operation has run to\n** merge (or partially merge) two or more segments from absolute level\n** iAbsLevel.\n**\n** Each input segment is either removed from the db completely (if all of\n** its data was copied to the output segment by the incrmerge operation)\n** or modified in place so that it no longer contains those entries that\n** have been duplicated in the output segment.\n*/\nstatic int fts3IncrmergeChomp(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level containing segments */\n  Fts3MultiSegReader *pCsr,       /* Chomp all segments opened by this cursor */\n  int *pnRem                      /* Number of segments not deleted */\n){\n  int i;\n  int nRem = 0;\n  int rc = SQLITE_OK;\n\n  for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){\n    Fts3SegReader *pSeg = 0;\n    int j;\n\n    /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding\n    ** somewhere in the pCsr->apSegment[] array.  */\n    for(j=0; ALWAYS(j<pCsr->nSegment); j++){\n      pSeg = pCsr->apSegment[j];\n      if( pSeg->iIdx==i ) break;\n    }\n    assert( j<pCsr->nSegment && pSeg->iIdx==i );\n\n    if( pSeg->aNode==0 ){\n      /* Seg-reader is at EOF. Remove the entire input segment. */\n      rc = fts3DeleteSegment(p, pSeg);\n      if( rc==SQLITE_OK ){\n        rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);\n      }\n      *pnRem = 0;\n    }else{\n      /* The incremental merge did not copy all the data from this \n      ** segment to the upper level. The segment is modified in place\n      ** so that it contains no keys smaller than zTerm/nTerm. */ \n      const char *zTerm = pSeg->zTerm;\n      int nTerm = pSeg->nTerm;\n      rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);\n      nRem++;\n    }\n  }\n\n  if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){\n    rc = fts3RepackSegdirLevel(p, iAbsLevel);\n  }\n\n  *pnRem = nRem;\n  return rc;\n}\n\n/*\n** Store an incr-merge hint in the database.\n*/\nstatic int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pReplace = 0;\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);\n    sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n  }\n\n  return rc;\n}\n\n/*\n** Load an incr-merge hint from the database. The incr-merge hint, if one \n** exists, is stored in the rowid==1 row of the %_stat table.\n**\n** If successful, populate blob *pHint with the value read from the %_stat\n** table and return SQLITE_OK. Otherwise, if an error occurs, return an\n** SQLite error code.\n*/\nstatic int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pSelect = 0;\n  int rc;\n\n  pHint->n = 0;\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      const char *aHint = sqlite3_column_blob(pSelect, 0);\n      int nHint = sqlite3_column_bytes(pSelect, 0);\n      if( aHint ){\n        blobGrowBuffer(pHint, nHint, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pHint->a, aHint, nHint);\n          pHint->n = nHint;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, append an entry to the hint stored in blob *pHint. Each entry\n** consists of two varints, the absolute level number of the input segments \n** and the number of input segments.\n**\n** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,\n** set *pRc to an SQLite error code before returning.\n*/\nstatic void fts3IncrmergeHintPush(\n  Blob *pHint,                    /* Hint blob to append to */\n  i64 iAbsLevel,                  /* First varint to store in hint */\n  int nInput,                     /* Second varint to store in hint */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);\n  if( *pRc==SQLITE_OK ){\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);\n  }\n}\n\n/*\n** Read the last entry (most recently pushed) from the hint blob *pHint\n** and then remove the entry. Write the two values read to *piAbsLevel and \n** *pnInput before returning.\n**\n** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does\n** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.\n*/\nstatic int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){\n  const int nHint = pHint->n;\n  int i;\n\n  i = pHint->n-2;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n\n  pHint->n = i;\n  i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);\n  i += fts3GetVarint32(&pHint->a[i], pnInput);\n  if( i!=nHint ) return FTS_CORRUPT_VTAB;\n\n  return SQLITE_OK;\n}\n\n\n/*\n** Attempt an incremental merge that writes nMerge leaf blocks.\n**\n** Incremental merges happen nMin segments at a time. The segments \n** to be merged are the nMin oldest segments (the ones with the smallest \n** values for the _segdir.idx field) in the highest level that contains \n** at least nMin segments. Multiple merges might occur in an attempt to \n** write the quota of nMerge leaf blocks.\n*/\nint sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){\n  int rc;                         /* Return code */\n  int nRem = nMerge;              /* Number of leaf pages yet to  be written */\n  Fts3MultiSegReader *pCsr;       /* Cursor used to read input data */\n  Fts3SegFilter *pFilter;         /* Filter used with cursor pCsr */\n  IncrmergeWriter *pWriter;       /* Writer object */\n  int nSeg = 0;                   /* Number of input segments */\n  sqlite3_int64 iAbsLevel = 0;    /* Absolute level number to work on */\n  Blob hint = {0, 0, 0};          /* Hint read from %_stat table */\n  int bDirtyHint = 0;             /* True if blob 'hint' has been modified */\n\n  /* Allocate space for the cursor, filter and writer objects */\n  const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);\n  pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);\n  if( !pWriter ) return SQLITE_NOMEM;\n  pFilter = (Fts3SegFilter *)&pWriter[1];\n  pCsr = (Fts3MultiSegReader *)&pFilter[1];\n\n  rc = fts3IncrmergeHintLoad(p, &hint);\n  while( rc==SQLITE_OK && nRem>0 ){\n    const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;\n    sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */\n    int bUseHint = 0;             /* True if attempting to append */\n    int iIdx = 0;                 /* Largest idx in level (iAbsLevel+1) */\n\n    /* Search the %_segdir table for the absolute level with the smallest\n    ** relative level number that contains at least nMin segments, if any.\n    ** If one is found, set iAbsLevel to the absolute level number and\n    ** nSeg to nMin. If no level with at least nMin segments can be found, \n    ** set nSeg to -1.\n    */\n    rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);\n    sqlite3_bind_int(pFindLevel, 1, MAX(2, nMin));\n    if( sqlite3_step(pFindLevel)==SQLITE_ROW ){\n      iAbsLevel = sqlite3_column_int64(pFindLevel, 0);\n      nSeg = sqlite3_column_int(pFindLevel, 1);\n      assert( nSeg>=2 );\n    }else{\n      nSeg = -1;\n    }\n    rc = sqlite3_reset(pFindLevel);\n\n    /* If the hint read from the %_stat table is not empty, check if the\n    ** last entry in it specifies a relative level smaller than or equal\n    ** to the level identified by the block above (if any). If so, this \n    ** iteration of the loop will work on merging at the hinted level.\n    */\n    if( rc==SQLITE_OK && hint.n ){\n      int nHint = hint.n;\n      sqlite3_int64 iHintAbsLevel = 0;      /* Hint level */\n      int nHintSeg = 0;                     /* Hint number of segments */\n\n      rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);\n      if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){\n        iAbsLevel = iHintAbsLevel;\n        nSeg = nHintSeg;\n        bUseHint = 1;\n        bDirtyHint = 1;\n      }else{\n        /* This undoes the effect of the HintPop() above - so that no entry\n        ** is removed from the hint blob.  */\n        hint.n = nHint;\n      }\n    }\n\n    /* If nSeg is less that zero, then there is no level with at least\n    ** nMin segments and no hint in the %_stat table. No work to do.\n    ** Exit early in this case.  */\n    if( nSeg<0 ) break;\n\n    /* Open a cursor to iterate through the contents of the oldest nSeg \n    ** indexes of absolute level iAbsLevel. If this cursor is opened using \n    ** the 'hint' parameters, it is possible that there are less than nSeg\n    ** segments available in level iAbsLevel. In this case, no work is\n    ** done on iAbsLevel - fall through to the next iteration of the loop \n    ** to start work on some other level.  */\n    memset(pWriter, 0, nAlloc);\n    pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);\n      assert( bUseHint==1 || bUseHint==0 );\n      if( iIdx==0 || (bUseHint && iIdx==1) ){\n        int bIgnore = 0;\n        rc = fts3SegmentIsMaxLevel(p, iAbsLevel+1, &bIgnore);\n        if( bIgnore ){\n          pFilter->flags |= FTS3_SEGMENT_IGNORE_EMPTY;\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);\n    }\n    if( SQLITE_OK==rc && pCsr->nSegment==nSeg\n     && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))\n     && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))\n    ){\n      if( bUseHint && iIdx>0 ){\n        const char *zKey = pCsr->zTerm;\n        int nKey = pCsr->nTerm;\n        rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);\n      }else{\n        rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);\n      }\n\n      if( rc==SQLITE_OK && pWriter->nLeafEst ){\n        fts3LogMerge(nSeg, iAbsLevel);\n        do {\n          rc = fts3IncrmergeAppend(p, pWriter, pCsr);\n          if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);\n          if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;\n        }while( rc==SQLITE_ROW );\n\n        /* Update or delete the input segments */\n        if( rc==SQLITE_OK ){\n          nRem -= (1 + pWriter->nWork);\n          rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);\n          if( nSeg!=0 ){\n            bDirtyHint = 1;\n            fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);\n          }\n        }\n      }\n\n      if( nSeg!=0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      fts3IncrmergeRelease(p, pWriter, &rc);\n      if( nSeg==0 && pWriter->bNoLeafData==0 ){\n        fts3PromoteSegments(p, iAbsLevel+1, pWriter->nLeafData);\n      }\n    }\n\n    sqlite3Fts3SegReaderFinish(pCsr);\n  }\n\n  /* Write the hint values into the %_stat table for the next incr-merger */\n  if( bDirtyHint && rc==SQLITE_OK ){\n    rc = fts3IncrmergeHintStore(p, &hint);\n  }\n\n  sqlite3_free(pWriter);\n  sqlite3_free(hint.a);\n  return rc;\n}\n\n/*\n** Convert the text beginning at *pz into an integer and return\n** its value.  Advance *pz to point to the first character past\n** the integer.\n**\n** This function used for parameters to merge= and incrmerge=\n** commands. \n*/\nstatic int fts3Getint(const char **pz){\n  const char *z = *pz;\n  int i = 0;\n  while( (*z)>='0' && (*z)<='9' && i<214748363 ) i = 10*i + *(z++) - '0';\n  *pz = z;\n  return i;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('merge=A,B');\n**\n** A and B are integers that decode to be the number of leaf pages\n** written for the merge, and the minimum number of segments on a level\n** before it will be selected for a merge, respectively.\n*/\nstatic int fts3DoIncrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing \"A,B\" */\n){\n  int rc;\n  int nMin = (FTS3_MERGE_COUNT / 2);\n  int nMerge = 0;\n  const char *z = zParam;\n\n  /* Read the first integer value */\n  nMerge = fts3Getint(&z);\n\n  /* If the first integer value is followed by a ',',  read the second\n  ** integer value. */\n  if( z[0]==',' && z[1]!='\\0' ){\n    z++;\n    nMin = fts3Getint(&z);\n  }\n\n  if( z[0]!='\\0' || nMin<2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = SQLITE_OK;\n    if( !p->bHasStat ){\n      assert( p->bFts4==0 );\n      sqlite3Fts3CreateStatTable(&rc, p);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);\n    }\n    sqlite3Fts3SegmentsClose(p);\n  }\n  return rc;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('automerge=X');\n**\n** where X is an integer.  X==0 means to turn automerge off.  X!=0 means\n** turn it on.  The setting is persistent.\n*/\nstatic int fts3DoAutoincrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing boolean */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  p->nAutoincrmerge = fts3Getint(&zParam);\n  if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){\n    p->nAutoincrmerge = 8;\n  }\n  if( !p->bHasStat ){\n    assert( p->bFts4==0 );\n    sqlite3Fts3CreateStatTable(&rc, p);\n    if( rc ) return rc;\n  }\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ) return rc;\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n  sqlite3_bind_int(pStmt, 2, p->nAutoincrmerge);\n  sqlite3_step(pStmt);\n  rc = sqlite3_reset(pStmt);\n  return rc;\n}\n\n/*\n** Return a 64-bit checksum for the FTS index entry specified by the\n** arguments to this function.\n*/\nstatic u64 fts3ChecksumEntry(\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int iLangid,                    /* Language id for current row */\n  int iIndex,                     /* Index (0..Fts3Table.nIndex-1) */\n  i64 iDocid,                     /* Docid for current row. */\n  int iCol,                       /* Column number */\n  int iPos                        /* Position */\n){\n  int i;\n  u64 ret = (u64)iDocid;\n\n  ret += (ret<<3) + iLangid;\n  ret += (ret<<3) + iIndex;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];\n\n  return ret;\n}\n\n/*\n** Return a checksum of all entries in the FTS index that correspond to\n** language id iLangid. The checksum is calculated by XORing the checksums\n** of each individual entry (see fts3ChecksumEntry()) together.\n**\n** If successful, the checksum value is returned and *pRc set to SQLITE_OK.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The\n** return value is undefined in this case.\n*/\nstatic u64 fts3ChecksumIndex(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id to return cksum for */\n  int iIndex,                     /* Index to cksum (0..p->nIndex-1) */\n  int *pRc                        /* OUT: Return code */\n){\n  Fts3SegFilter filter;\n  Fts3MultiSegReader csr;\n  int rc;\n  u64 cksum = 0;\n\n  assert( *pRc==SQLITE_OK );\n\n  memset(&filter, 0, sizeof(filter));\n  memset(&csr, 0, sizeof(csr));\n  filter.flags =  FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  filter.flags |= FTS3_SEGMENT_SCAN;\n\n  rc = sqlite3Fts3SegReaderCursor(\n      p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  }\n\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){\n      char *pCsr = csr.aDoclist;\n      char *pEnd = &pCsr[csr.nDoclist];\n\n      i64 iDocid = 0;\n      i64 iCol = 0;\n      i64 iPos = 0;\n\n      pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);\n      while( pCsr<pEnd ){\n        i64 iVal = 0;\n        pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n        if( pCsr<pEnd ){\n          if( iVal==0 || iVal==1 ){\n            iCol = 0;\n            iPos = 0;\n            if( iVal ){\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);\n            }else{\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n              iDocid += iVal;\n            }\n          }else{\n            iPos += (iVal - 2);\n            cksum = cksum ^ fts3ChecksumEntry(\n                csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,\n                (int)iCol, (int)iPos\n            );\n          }\n        }\n      }\n    }\n  }\n  sqlite3Fts3SegReaderFinish(&csr);\n\n  *pRc = rc;\n  return cksum;\n}\n\n/*\n** Check if the contents of the FTS index match the current contents of the\n** content table. If no error occurs and the contents do match, set *pbOk\n** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk\n** to false before returning.\n**\n** If an error occurs (e.g. an OOM or IO error), return an SQLite error \n** code. The final value of *pbOk is undefined in this case.\n*/\nstatic int fts3IntegrityCheck(Fts3Table *p, int *pbOk){\n  int rc = SQLITE_OK;             /* Return code */\n  u64 cksum1 = 0;                 /* Checksum based on FTS index contents */\n  u64 cksum2 = 0;                 /* Checksum based on %_content contents */\n  sqlite3_stmt *pAllLangid = 0;   /* Statement to return all language-ids */\n\n  /* This block calculates the checksum according to the FTS index. */\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      int i;\n      for(i=0; i<p->nIndex; i++){\n        cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* This block calculates the checksum according to the %_content table */\n  if( rc==SQLITE_OK ){\n    sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;\n    sqlite3_stmt *pStmt = 0;\n    char *zSql;\n   \n    zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      i64 iDocid = sqlite3_column_int64(pStmt, 0);\n      int iLang = langidFromSelect(p, pStmt);\n      int iCol;\n\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);\n          int nText = sqlite3_column_bytes(pStmt, iCol+1);\n          sqlite3_tokenizer_cursor *pT = 0;\n\n          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);\n          while( rc==SQLITE_OK ){\n            char const *zToken;       /* Buffer containing token */\n            int nToken = 0;           /* Number of bytes in token */\n            int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n            int iPos = 0;             /* Position of token in zText */\n\n            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n            if( rc==SQLITE_OK ){\n              int i;\n              cksum2 = cksum2 ^ fts3ChecksumEntry(\n                  zToken, nToken, iLang, 0, iDocid, iCol, iPos\n              );\n              for(i=1; i<p->nIndex; i++){\n                if( p->aIndex[i].nPrefix<=nToken ){\n                  cksum2 = cksum2 ^ fts3ChecksumEntry(\n                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos\n                  );\n                }\n              }\n            }\n          }\n          if( pT ) pModule->xClose(pT);\n          if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        }\n      }\n    }\n\n    sqlite3_finalize(pStmt);\n  }\n\n  *pbOk = (cksum1==cksum2);\n  return rc;\n}\n\n/*\n** Run the integrity-check. If no error occurs and the current contents of\n** the FTS index are correct, return SQLITE_OK. Or, if the contents of the\n** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.\n**\n** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite \n** error code.\n**\n** The integrity-check works as follows. For each token and indexed token\n** prefix in the document set, a 64-bit checksum is calculated (by code\n** in fts3ChecksumEntry()) based on the following:\n**\n**     + The index number (0 for the main index, 1 for the first prefix\n**       index etc.),\n**     + The token (or token prefix) text itself, \n**     + The language-id of the row it appears in,\n**     + The docid of the row it appears in,\n**     + The column it appears in, and\n**     + The tokens position within that column.\n**\n** The checksums for all entries in the index are XORed together to create\n** a single checksum for the entire index.\n**\n** The integrity-check code calculates the same checksum in two ways:\n**\n**     1. By scanning the contents of the FTS index, and \n**     2. By scanning and tokenizing the content table.\n**\n** If the two checksums are identical, the integrity-check is deemed to have\n** passed.\n*/\nstatic int fts3DoIntegrityCheck(\n  Fts3Table *p                    /* FTS3 table handle */\n){\n  int rc;\n  int bOk = 0;\n  rc = fts3IntegrityCheck(p, &bOk);\n  if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;\n  return rc;\n}\n\n/*\n** Handle a 'special' INSERT of the form:\n**\n**   \"INSERT INTO tbl(tbl) VALUES(<expr>)\"\n**\n** Argument pVal contains the result of <expr>. Currently the only \n** meaningful value to insert is the text 'optimize'.\n*/\nstatic int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){\n  int rc;                         /* Return Code */\n  const char *zVal = (const char *)sqlite3_value_text(pVal);\n  int nVal = sqlite3_value_bytes(pVal);\n\n  if( !zVal ){\n    return SQLITE_NOMEM;\n  }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, \"optimize\", 8) ){\n    rc = fts3DoOptimize(p, 0);\n  }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, \"rebuild\", 7) ){\n    rc = fts3DoRebuild(p);\n  }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, \"integrity-check\", 15) ){\n    rc = fts3DoIntegrityCheck(p);\n  }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, \"merge=\", 6) ){\n    rc = fts3DoIncrmerge(p, &zVal[6]);\n  }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, \"automerge=\", 10) ){\n    rc = fts3DoAutoincrmerge(p, &zVal[10]);\n#ifdef SQLITE_TEST\n  }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, \"nodesize=\", 9) ){\n    p->nNodeSize = atoi(&zVal[9]);\n    rc = SQLITE_OK;\n  }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, \"maxpending=\", 9) ){\n    p->nMaxPendingData = atoi(&zVal[11]);\n    rc = SQLITE_OK;\n  }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, \"test-no-incr-doclist=\", 21) ){\n    p->bNoIncrDoclist = atoi(&zVal[21]);\n    rc = SQLITE_OK;\n#endif\n  }else{\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n/*\n** Delete all cached deferred doclists. Deferred doclists are cached\n** (allocated) by the sqlite3Fts3CacheDeferredDoclists() function.\n*/\nvoid sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pDef->pNext){\n    fts3PendingListDelete(pDef->pList);\n    pDef->pList = 0;\n  }\n}\n\n/*\n** Free all entries in the pCsr->pDeffered list. Entries are added to \n** this list using sqlite3Fts3DeferToken().\n*/\nvoid sqlite3Fts3FreeDeferredTokens(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  Fts3DeferredToken *pNext;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pNext){\n    pNext = pDef->pNext;\n    fts3PendingListDelete(pDef->pList);\n    sqlite3_free(pDef);\n  }\n  pCsr->pDeferred = 0;\n}\n\n/*\n** Generate deferred-doclists for all tokens in the pCsr->pDeferred list\n** based on the row that pCsr currently points to.\n**\n** A deferred-doclist is like any other doclist with position information\n** included, except that it only contains entries for a single row of the\n** table, not for all rows.\n*/\nint sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pCsr->pDeferred ){\n    int i;                        /* Used to iterate through table columns */\n    sqlite3_int64 iDocid;         /* Docid of the row pCsr points to */\n    Fts3DeferredToken *pDef;      /* Used to iterate through deferred tokens */\n  \n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    sqlite3_tokenizer *pT = p->pTokenizer;\n    sqlite3_tokenizer_module const *pModule = pT->pModule;\n   \n    assert( pCsr->isRequireSeek==0 );\n    iDocid = sqlite3_column_int64(pCsr->pStmt, 0);\n  \n    for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){\n      if( p->abNotindexed[i]==0 ){\n        const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);\n        sqlite3_tokenizer_cursor *pTC = 0;\n\n        rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);\n        while( rc==SQLITE_OK ){\n          char const *zToken;       /* Buffer containing token */\n          int nToken = 0;           /* Number of bytes in token */\n          int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n          int iPos = 0;             /* Position of token in zText */\n\n          rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n          for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n            Fts3PhraseToken *pPT = pDef->pToken;\n            if( (pDef->iCol>=p->nColumn || pDef->iCol==i)\n                && (pPT->bFirst==0 || iPos==0)\n                && (pPT->n==nToken || (pPT->isPrefix && pPT->n<nToken))\n                && (0==memcmp(zToken, pPT->z, pPT->n))\n              ){\n              fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);\n            }\n          }\n        }\n        if( pTC ) pModule->xClose(pTC);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n      }\n    }\n\n    for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n      if( pDef->pList ){\n        rc = fts3PendingListAppendVarint(&pDef->pList, 0);\n      }\n    }\n  }\n\n  return rc;\n}\n\nint sqlite3Fts3DeferredTokenList(\n  Fts3DeferredToken *p, \n  char **ppData, \n  int *pnData\n){\n  char *pRet;\n  int nSkip;\n  sqlite3_int64 dummy;\n\n  *ppData = 0;\n  *pnData = 0;\n\n  if( p->pList==0 ){\n    return SQLITE_OK;\n  }\n\n  pRet = (char *)sqlite3_malloc(p->pList->nData);\n  if( !pRet ) return SQLITE_NOMEM;\n\n  nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy);\n  *pnData = p->pList->nData - nSkip;\n  *ppData = pRet;\n  \n  memcpy(pRet, &p->pList->aData[nSkip], *pnData);\n  return SQLITE_OK;\n}\n\n/*\n** Add an entry for token pToken to the pCsr->pDeferred list.\n*/\nint sqlite3Fts3DeferToken(\n  Fts3Cursor *pCsr,               /* Fts3 table cursor */\n  Fts3PhraseToken *pToken,        /* Token to defer */\n  int iCol                        /* Column that token must appear in (or -1) */\n){\n  Fts3DeferredToken *pDeferred;\n  pDeferred = sqlite3_malloc(sizeof(*pDeferred));\n  if( !pDeferred ){\n    return SQLITE_NOMEM;\n  }\n  memset(pDeferred, 0, sizeof(*pDeferred));\n  pDeferred->pToken = pToken;\n  pDeferred->pNext = pCsr->pDeferred; \n  pDeferred->iCol = iCol;\n  pCsr->pDeferred = pDeferred;\n\n  assert( pToken->pDeferred==0 );\n  pToken->pDeferred = pDeferred;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** SQLite value pRowid contains the rowid of a row that may or may not be\n** present in the FTS3 table. If it is, delete it and adjust the contents\n** of subsiduary data structures accordingly.\n*/\nstatic int fts3DeleteByRowid(\n  Fts3Table *p, \n  sqlite3_value *pRowid, \n  int *pnChng,                    /* IN/OUT: Decrement if row is deleted */\n  u32 *aSzDel\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFound = 0;                 /* True if *pRowid really is in the table */\n\n  fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);\n  if( bFound && rc==SQLITE_OK ){\n    int isEmpty = 0;              /* Deleting *pRowid leaves the table empty */\n    rc = fts3IsEmpty(p, pRowid, &isEmpty);\n    if( rc==SQLITE_OK ){\n      if( isEmpty ){\n        /* Deleting this row means the whole table is empty. In this case\n        ** delete the contents of all three tables and throw away any\n        ** data in the pendingTerms hash table.  */\n        rc = fts3DeleteAll(p, 1);\n        *pnChng = 0;\n        memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);\n      }else{\n        *pnChng = *pnChng - 1;\n        if( p->zContentTbl==0 ){\n          fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);\n        }\n        if( p->bHasDocsize ){\n          fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function does the work for the xUpdate method of FTS3 virtual\n** tables. The schema of the virtual table being:\n**\n**     CREATE TABLE <table name>( \n**       <user columns>,\n**       <table name> HIDDEN, \n**       docid HIDDEN, \n**       <langid> HIDDEN\n**     );\n**\n** \n*/\nint sqlite3Fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* FTS3 vtab object */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;             /* Return Code */\n  int isRemove = 0;               /* True for an UPDATE or DELETE */\n  u32 *aSzIns = 0;                /* Sizes of inserted documents */\n  u32 *aSzDel = 0;                /* Sizes of deleted documents */\n  int nChng = 0;                  /* Net change in number of documents */\n  int bInsertDone = 0;\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  assert( p->bHasStat==0 || p->bHasStat==1 );\n\n  assert( p->pSegments==0 );\n  assert( \n      nArg==1                     /* DELETE operations */\n   || nArg==(2 + p->nColumn + 3)  /* INSERT or UPDATE operations */\n  );\n\n  /* Check for a \"special\" INSERT operation. One of the form:\n  **\n  **   INSERT INTO xyz(xyz) VALUES('command');\n  */\n  if( nArg>1 \n   && sqlite3_value_type(apVal[0])==SQLITE_NULL \n   && sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL \n  ){\n    rc = fts3SpecialInsert(p, apVal[p->nColumn+2]);\n    goto update_out;\n  }\n\n  if( nArg>1 && sqlite3_value_int(apVal[2 + p->nColumn + 2])<0 ){\n    rc = SQLITE_CONSTRAINT;\n    goto update_out;\n  }\n\n  /* Allocate space to hold the change in document sizes */\n  aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );\n  if( aSzDel==0 ){\n    rc = SQLITE_NOMEM;\n    goto update_out;\n  }\n  aSzIns = &aSzDel[p->nColumn+1];\n  memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);\n\n  rc = fts3Writelock(p);\n  if( rc!=SQLITE_OK ) goto update_out;\n\n  /* If this is an INSERT operation, or an UPDATE that modifies the rowid\n  ** value, then this operation requires constraint handling.\n  **\n  ** If the on-conflict mode is REPLACE, this means that the existing row\n  ** should be deleted from the database before inserting the new row. Or,\n  ** if the on-conflict mode is other than REPLACE, then this method must\n  ** detect the conflict and return SQLITE_CONSTRAINT before beginning to\n  ** modify the database file.\n  */\n  if( nArg>1 && p->zContentTbl==0 ){\n    /* Find the value object that holds the new rowid value. */\n    sqlite3_value *pNewRowid = apVal[3+p->nColumn];\n    if( sqlite3_value_type(pNewRowid)==SQLITE_NULL ){\n      pNewRowid = apVal[1];\n    }\n\n    if( sqlite3_value_type(pNewRowid)!=SQLITE_NULL && ( \n        sqlite3_value_type(apVal[0])==SQLITE_NULL\n     || sqlite3_value_int64(apVal[0])!=sqlite3_value_int64(pNewRowid)\n    )){\n      /* The new rowid is not NULL (in this case the rowid will be\n      ** automatically assigned and there is no chance of a conflict), and \n      ** the statement is either an INSERT or an UPDATE that modifies the\n      ** rowid column. So if the conflict mode is REPLACE, then delete any\n      ** existing row with rowid=pNewRowid. \n      **\n      ** Or, if the conflict mode is not REPLACE, insert the new record into \n      ** the %_content table. If we hit the duplicate rowid constraint (or any\n      ** other error) while doing so, return immediately.\n      **\n      ** This branch may also run if pNewRowid contains a value that cannot\n      ** be losslessly converted to an integer. In this case, the eventual \n      ** call to fts3InsertData() (either just below or further on in this\n      ** function) will return SQLITE_MISMATCH. If fts3DeleteByRowid is \n      ** invoked, it will delete zero rows (since no row will have\n      ** docid=$pNewRowid if $pNewRowid is not an integer value).\n      */\n      if( sqlite3_vtab_on_conflict(p->db)==SQLITE_REPLACE ){\n        rc = fts3DeleteByRowid(p, pNewRowid, &nChng, aSzDel);\n      }else{\n        rc = fts3InsertData(p, apVal, pRowid);\n        bInsertDone = 1;\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    goto update_out;\n  }\n\n  /* If this is a DELETE or UPDATE operation, remove the old record. */\n  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){\n    assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER );\n    rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel);\n    isRemove = 1;\n  }\n  \n  /* If this is an INSERT or UPDATE operation, insert the new record. */\n  if( nArg>1 && rc==SQLITE_OK ){\n    int iLangid = sqlite3_value_int(apVal[2 + p->nColumn + 2]);\n    if( bInsertDone==0 ){\n      rc = fts3InsertData(p, apVal, pRowid);\n      if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){\n        rc = FTS_CORRUPT_VTAB;\n      }\n    }\n    if( rc==SQLITE_OK && (!isRemove || *pRowid!=p->iPrevDocid ) ){\n      rc = fts3PendingTermsDocid(p, 0, iLangid, *pRowid);\n    }\n    if( rc==SQLITE_OK ){\n      assert( p->iPrevDocid==*pRowid );\n      rc = fts3InsertTerms(p, iLangid, apVal, aSzIns);\n    }\n    if( p->bHasDocsize ){\n      fts3InsertDocsize(&rc, p, aSzIns);\n    }\n    nChng++;\n  }\n\n  if( p->bFts4 ){\n    fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);\n  }\n\n update_out:\n  sqlite3_free(aSzDel);\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n/* \n** Flush any data in the pending-terms hash table to disk. If successful,\n** merge all segments in the database (including the new segment, if \n** there was any data to flush) into a single segment. \n*/\nint sqlite3Fts3Optimize(Fts3Table *p){\n  int rc;\n  rc = sqlite3_exec(p->db, \"SAVEPOINT fts3\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = fts3DoOptimize(p, 1);\n    if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n      int rc2 = sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n      if( rc2!=SQLITE_OK ) rc = rc2;\n    }else{\n      sqlite3_exec(p->db, \"ROLLBACK TO fts3\", 0, 0, 0);\n      sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n    }\n  }\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/fts3speed.tcl",
    "content": "\n\n#--------------------------------------------------------------------------\n# This script contains several sub-programs used to test FTS3/FTS4 \n# performance. It does not run the queries directly, but generates SQL\n# scripts that can be run using the shell tool.\n#\n# The following cases are tested:\n#\n#   1. Inserting documents into an FTS3 table.\n#   2. Optimizing an FTS3 table (i.e. \"INSERT INTO t1 VALUES('optimize')\").\n#   3. Deleting documents from an FTS3 table.\n#   4. Querying FTS3 tables.\n#\n\n# Number of tokens in vocabulary. And number of tokens in each document.\n#\nset VOCAB_SIZE  2000\nset DOC_SIZE     100\n\nset NUM_INSERTS 100000\nset NUM_SELECTS 1000\n\n# Force everything in this script to be deterministic.\n#\nexpr {srand(0)}\n\nproc usage {} {\n  puts stderr \"Usage: $::argv0 <rows> <selects>\"\n  exit -1\n}\n\nproc sql {sql} {\n  puts $::fd $sql\n}\n\n\n# Return a list of $nWord randomly generated tokens each between 2 and 10\n# characters in length.\n#\nproc build_vocab {nWord} {\n  set ret [list]\n  set chars [list a b c d e f g h i j k l m n o p q r s t u v w x y z]\n  for {set i 0} {$i<$nWord} {incr i} {\n    set len [expr {int((rand()*9.0)+2)}]\n    set term \"\"\n    for {set j 0} {$j<$len} {incr j} {\n      append term [lindex $chars [expr {int(rand()*[llength $chars])}]]\n    }\n    lappend ret $term\n  }\n  set ret\n}\n\nproc select_term {} {\n  set n [llength $::vocab]\n  set t [expr int(rand()*$n*3)]\n  if {$t>=2*$n} { set t [expr {($t-2*$n)/100}] }\n  if {$t>=$n} { set t [expr {($t-$n)/10}] }\n  lindex $::vocab $t\n}\n\nproc select_doc {nTerm} {\n  set ret [list]\n  for {set i 0} {$i<$nTerm} {incr i} {\n    lappend ret [select_term]\n  }\n  set ret\n}\n\nproc test_1 {nInsert} {\n  sql \"PRAGMA synchronous = OFF;\"\n  sql \"DROP TABLE IF EXISTS t1;\"\n  sql \"CREATE VIRTUAL TABLE t1 USING fts4;\"\n  for {set i 0} {$i < $nInsert} {incr i} {\n    set doc [select_doc $::DOC_SIZE]\n    sql \"INSERT INTO t1 VALUES('$doc');\"\n  }\n}\n\nproc test_2 {} {\n  sql \"INSERT INTO t1(t1) VALUES('optimize');\"\n}\n\nproc test_3 {nSelect} {\n  for {set i 0} {$i < $nSelect} {incr i} {\n    sql \"SELECT count(*) FROM t1 WHERE t1 MATCH '[select_term]';\"\n  }\n}\n\nproc test_4 {nSelect} {\n  for {set i 0} {$i < $nSelect} {incr i} {\n    sql \"SELECT count(*) FROM t1 WHERE t1 MATCH '[select_term] [select_term]';\"\n  }\n}\n\nif {[llength $argv]!=0} usage\n\nset ::vocab [build_vocab $::VOCAB_SIZE]\n\nset ::fd [open fts3speed_insert.sql w]\ntest_1 $NUM_INSERTS\nclose $::fd\n\nset ::fd [open fts3speed_select.sql w]\ntest_3 $NUM_SELECTS\nclose $::fd\n\nset ::fd [open fts3speed_select2.sql w]\ntest_4 $NUM_SELECTS\nclose $::fd\n\nset ::fd [open fts3speed_optimize.sql w]\ntest_2\nclose $::fd\n\nputs \"Success. Created files:\"\nputs \"  fts3speed_insert.sql\"\nputs \"  fts3speed_select.sql\"\nputs \"  fts3speed_select2.sql\"\nputs \"  fts3speed_optimize.sql\"\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/mkfts3amal.tcl",
    "content": "#!/usr/bin/tclsh\n#\n# This script builds a single C code file holding all of FTS3 code.\n# The name of the output file is fts3amal.c.  To build this file,\n# first do:\n#\n#      make target_source\n#\n# The make target above moves all of the source code files into\n# a subdirectory named \"tsrc\".  (This script expects to find the files\n# there and will not work if they are not found.)\n#\n# After the \"tsrc\" directory has been created and populated, run\n# this script:\n#\n#      tclsh mkfts3amal.tcl\n#\n# The amalgamated FTS3 code will be written into fts3amal.c\n#\n\n# Open the output file and write a header comment at the beginning\n# of the file.\n#\nset out [open fts3amal.c w]\nset today [clock format [clock seconds] -format \"%Y-%m-%d %H:%M:%S UTC\" -gmt 1]\nputs $out [subst \\\n{/******************************************************************************\n** This file is an amalgamation of separate C source files from the SQLite\n** Full Text Search extension 2 (fts3).  By combining all the individual C \n** code  files into this single large file, the entire code can be compiled \n** as a one translation unit.  This allows many compilers to do optimizations\n** that would not be possible if the files were compiled separately.  It also\n** makes the code easier to import into other projects.\n**\n** This amalgamation was generated on $today.\n*/}]\n\n# These are the header files used by FTS3.  The first time any of these \n# files are seen in a #include statement in the C code, include the complete\n# text of the file in-line.  The file only needs to be included once.\n#\nforeach hdr {\n   fts3.h\n   fts3_hash.h\n   fts3_tokenizer.h\n   sqlite3.h\n   sqlite3ext.h\n} {\n  set available_hdr($hdr) 1\n}\n\n# 78 stars used for comment formatting.\nset s78 \\\n{*****************************************************************************}\n\n# Insert a comment into the code\n#\nproc section_comment {text} {\n  global out s78\n  set n [string length $text]\n  set nstar [expr {60 - $n}]\n  set stars [string range $s78 0 $nstar]\n  puts $out \"/************** $text $stars/\"\n}\n\n# Read the source file named $filename and write it into the\n# sqlite3.c output file.  If any #include statements are seen,\n# process them approprately.\n#\nproc copy_file {filename} {\n  global seen_hdr available_hdr out\n  set tail [file tail $filename]\n  section_comment \"Begin file $tail\"\n  set in [open $filename r]\n  while {![eof $in]} {\n    set line [gets $in]\n    if {[regexp {^#\\s*include\\s+[\"<]([^\">]+)[\">]} $line all hdr]} {\n      if {[info exists available_hdr($hdr)]} {\n        if {$available_hdr($hdr)} {\n          section_comment \"Include $hdr in the middle of $tail\"\n          copy_file tsrc/$hdr\n          section_comment \"Continuing where we left off in $tail\"\n        }\n      } elseif {![info exists seen_hdr($hdr)]} {\n        set seen_hdr($hdr) 1\n        puts $out $line\n      }\n    } elseif {[regexp {^#ifdef __cplusplus} $line]} {\n      puts $out \"#if 0\"\n    } elseif {[regexp {^#line} $line]} {\n      # Skip #line directives.\n    } else {\n      puts $out $line\n    }\n  }\n  close $in\n  section_comment \"End of $tail\"\n}\n\n\n# Process the source files.  Process files containing commonly\n# used subroutines first in order to help the compiler find\n# inlining opportunities.\n#\nforeach file {\n   fts3.c\n   fts3_hash.c\n   fts3_porter.c\n   fts3_tokenizer.c\n   fts3_tokenizer1.c\n} {\n  copy_file tsrc/$file\n}\n\nclose $out\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/tool/fts3cov.sh",
    "content": "#!/bin/sh\n\nset -e\n\nsrcdir=`dirname $(dirname $(dirname $(dirname $0)))`\n./testfixture $srcdir/test/fts3.test --output=fts3cov-out.txt\n\necho \"\"\n\nfor f in `ls $srcdir/ext/fts3/*.c` \ndo\n  f=`basename $f`\n  echo -ne \"$f: \"\n  gcov -b $f | grep Taken | sed 's/Taken at least once://'\ndone\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/tool/fts3view.c",
    "content": "/*\n** This program is a debugging and analysis utility that displays\n** information about an FTS3 or FTS4 index.\n**\n** Link this program against the SQLite3 amalgamation with the\n** SQLITE_ENABLE_FTS4 compile-time option.  Then run it as:\n**\n**    fts3view DATABASE\n**\n** to get a list of all FTS3/4 tables in DATABASE, or do\n**\n**    fts3view DATABASE TABLE COMMAND ....\n**\n** to see various aspects of the TABLE table.  Type fts3view with no\n** arguments for a list of available COMMANDs.\n*/\n#include <stdio.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <string.h>\n#include <ctype.h>\n#include \"sqlite3.h\"\n\n/*\n** Extra command-line arguments:\n*/\nint nExtra;\nchar **azExtra;\n\n/*\n** Look for a command-line argument.\n*/\nconst char *findOption(const char *zName, int hasArg, const char *zDefault){\n  int i;\n  const char *zResult = zDefault;\n  for(i=0; i<nExtra; i++){\n    const char *z = azExtra[i];\n    while( z[0]=='-' ) z++;\n    if( strcmp(z, zName)==0 ){\n      int j = 1;\n      if( hasArg==0 || i==nExtra-1 ) j = 0;\n      zResult = azExtra[i+j];\n      while( i+j<nExtra ){\n        azExtra[i] = azExtra[i+j+1];\n        i++;\n      }\n      break;\n    }\n  }\n  return zResult;       \n}\n\n\n/*\n** Prepare an SQL query\n*/\nstatic sqlite3_stmt *prepare(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc ){\n    fprintf(stderr, \"Error: %s\\nSQL: %s\\n\", sqlite3_errmsg(db), zSql);\n    exit(1);\n  }\n  sqlite3_free(zSql);\n  return pStmt;\n}\n\n/*\n** Run an SQL statement\n*/\nstatic int runSql(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  int rc;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  rc = sqlite3_exec(db, zSql, 0, 0, 0);\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Show the table schema\n*/\nstatic void showSchema(sqlite3 *db, const char *zTab){\n  sqlite3_stmt *pStmt;\n  pStmt = prepare(db,\n            \"SELECT sql FROM sqlite_master\"\n            \" WHERE name LIKE '%q%%'\"\n            \" ORDER BY 1\",\n            zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"%s;\\n\", sqlite3_column_text(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db, \"PRAGMA page_size\");\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"PRAGMA page_size=%s;\\n\", sqlite3_column_text(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db, \"PRAGMA journal_mode\");\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"PRAGMA journal_mode=%s;\\n\", sqlite3_column_text(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db, \"PRAGMA auto_vacuum\");\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    const char *zType = \"???\";\n    switch( sqlite3_column_int(pStmt, 0) ){\n      case 0:  zType = \"OFF\";         break;\n      case 1:  zType = \"FULL\";        break;\n      case 2:  zType = \"INCREMENTAL\"; break;\n    }\n    printf(\"PRAGMA auto_vacuum=%s;\\n\", zType);\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db, \"PRAGMA encoding\");\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"PRAGMA encoding=%s;\\n\", sqlite3_column_text(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n}\n\n/* \n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read, or 0 on error.\n** The value is stored in *v.\n*/\nint getVarint(const unsigned char *p, sqlite_int64 *v){\n  const unsigned char *q = p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q&0x80)==0x80 && q-(unsigned char *)p<9 ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\n\n/* Show the content of the %_stat table\n*/\nstatic void showStat(sqlite3 *db, const char *zTab){\n  sqlite3_stmt *pStmt;\n  pStmt = prepare(db, \"SELECT id, value FROM '%q_stat'\", zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"stat[%d] =\", sqlite3_column_int(pStmt, 0));\n    switch( sqlite3_column_type(pStmt, 1) ){\n      case SQLITE_INTEGER: {\n        printf(\" %d\\n\", sqlite3_column_int(pStmt, 1));\n        break;\n      }\n      case SQLITE_BLOB: {\n        unsigned char *x = (unsigned char*)sqlite3_column_blob(pStmt, 1);\n        int len = sqlite3_column_bytes(pStmt, 1);\n        int i = 0;\n        sqlite3_int64 v;\n        while( i<len ){\n          i += getVarint(x, &v);\n          printf(\" %lld\", v);\n        }\n        printf(\"\\n\");\n        break;\n      }\n    }\n  }\n  sqlite3_finalize(pStmt);\n}\n\n/*\n** Report on the vocabulary.  This creates an fts4aux table with a random\n** name, but deletes it in the end.\n*/\nstatic void showVocabulary(sqlite3 *db, const char *zTab){\n  char *zAux;\n  sqlite3_uint64 r;\n  sqlite3_stmt *pStmt;\n  int nDoc = 0;\n  int nToken = 0;\n  int nOccurrence = 0;\n  int nTop;\n  int n, i;\n\n  sqlite3_randomness(sizeof(r), &r);\n  zAux = sqlite3_mprintf(\"viewer_%llx\", zTab, r);\n  runSql(db, \"BEGIN\");\n  pStmt = prepare(db, \"SELECT count(*) FROM %Q\", zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    nDoc = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  printf(\"Number of documents...................... %9d\\n\", nDoc);\n\n  runSql(db, \"CREATE VIRTUAL TABLE %s USING fts4aux(%Q)\", zAux, zTab);\n  pStmt = prepare(db, \n             \"SELECT count(*), sum(occurrences) FROM %s WHERE col='*'\",\n             zAux);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    nToken = sqlite3_column_int(pStmt, 0);\n    nOccurrence = sqlite3_column_int(pStmt, 1);\n  }\n  sqlite3_finalize(pStmt);\n  printf(\"Total tokens in all documents............ %9d\\n\", nOccurrence);\n  printf(\"Total number of distinct tokens.......... %9d\\n\", nToken);\n  if( nToken==0 ) goto end_vocab;\n\n  n = 0;\n  pStmt = prepare(db, \"SELECT count(*) FROM %s\"\n                      \" WHERE col='*' AND occurrences==1\", zAux);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    n = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  printf(\"Tokens used exactly once................. %9d %5.2f%%\\n\",\n          n, n*100.0/nToken);\n\n  n = 0;\n  pStmt = prepare(db, \"SELECT count(*) FROM %s\"\n                      \" WHERE col='*' AND documents==1\", zAux);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    n = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  printf(\"Tokens used in only one document......... %9d %5.2f%%\\n\",\n          n, n*100.0/nToken);\n\n  if( nDoc>=2000 ){\n    n = 0;\n    pStmt = prepare(db, \"SELECT count(*) FROM %s\"\n                        \" WHERE col='*' AND occurrences<=%d\", zAux, nDoc/1000);\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      n = sqlite3_column_int(pStmt, 0);\n    }\n    sqlite3_finalize(pStmt);\n    printf(\"Tokens used in 0.1%% or less of docs...... %9d %5.2f%%\\n\",\n            n, n*100.0/nToken);\n  }\n\n  if( nDoc>=200 ){\n    n = 0;\n    pStmt = prepare(db, \"SELECT count(*) FROM %s\"\n                        \" WHERE col='*' AND occurrences<=%d\", zAux, nDoc/100);\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      n = sqlite3_column_int(pStmt, 0);\n    }\n    sqlite3_finalize(pStmt);\n    printf(\"Tokens used in 1%% or less of docs........ %9d %5.2f%%\\n\",\n            n, n*100.0/nToken);\n  }\n\n  nTop = atoi(findOption(\"top\", 1, \"25\"));\n  printf(\"The %d most common tokens:\\n\", nTop);\n  pStmt = prepare(db,\n            \"SELECT term, documents FROM %s\"\n            \" WHERE col='*'\"\n            \" ORDER BY documents DESC, term\"\n            \" LIMIT %d\", zAux, nTop);\n  i = 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    i++;\n    n = sqlite3_column_int(pStmt, 1);\n    printf(\"  %2d. %-30s %9d docs %5.2f%%\\n\", i,\n      sqlite3_column_text(pStmt, 0), n, n*100.0/nDoc);\n  }\n  sqlite3_finalize(pStmt);\n\nend_vocab:\n  runSql(db, \"ROLLBACK\");\n  sqlite3_free(zAux);\n}\n\n/*\n** Report on the number and sizes of segments\n*/\nstatic void showSegmentStats(sqlite3 *db, const char *zTab){\n  sqlite3_stmt *pStmt;\n  int nSeg = 0;\n  sqlite3_int64 szSeg = 0, mxSeg = 0;\n  int nIdx = 0;\n  sqlite3_int64 szIdx = 0, mxIdx = 0;\n  int nRoot = 0;\n  sqlite3_int64 szRoot = 0, mxRoot = 0;\n  sqlite3_int64 mx;\n  int nLeaf;\n  int n;\n  int pgsz;\n  int mxLevel;\n  int i;\n\n  pStmt = prepare(db,\n                  \"SELECT count(*), sum(length(block)), max(length(block))\"\n                  \" FROM '%q_segments'\",\n                  zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    nSeg = sqlite3_column_int(pStmt, 0);\n    szSeg = sqlite3_column_int64(pStmt, 1);\n    mxSeg = sqlite3_column_int64(pStmt, 2);\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db,\n            \"SELECT count(*), sum(length(block)), max(length(block))\"\n            \"  FROM '%q_segments' a JOIN '%q_segdir' b\"\n            \" WHERE a.blockid BETWEEN b.leaves_end_block+1 AND b.end_block\",\n            zTab, zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    nIdx = sqlite3_column_int(pStmt, 0);\n    szIdx = sqlite3_column_int64(pStmt, 1);\n    mxIdx = sqlite3_column_int64(pStmt, 2);\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = prepare(db,\n            \"SELECT count(*), sum(length(root)), max(length(root))\"\n            \"  FROM '%q_segdir'\",\n            zTab);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    nRoot = sqlite3_column_int(pStmt, 0);\n    szRoot = sqlite3_column_int64(pStmt, 1);\n    mxRoot = sqlite3_column_int64(pStmt, 2);\n  }\n  sqlite3_finalize(pStmt);\n\n  printf(\"Number of segments....................... %9d\\n\", nSeg+nRoot);\n  printf(\"Number of leaf segments.................. %9d\\n\", nSeg-nIdx);\n  printf(\"Number of index segments................. %9d\\n\", nIdx);\n  printf(\"Number of root segments.................. %9d\\n\", nRoot);\n  printf(\"Total size of all segments............... %9lld\\n\", szSeg+szRoot);\n  printf(\"Total size of all leaf segments.......... %9lld\\n\", szSeg-szIdx);\n  printf(\"Total size of all index segments......... %9lld\\n\", szIdx);\n  printf(\"Total size of all root segments.......... %9lld\\n\", szRoot);\n  if( nSeg>0 ){\n    printf(\"Average size of all segments............. %11.1f\\n\",\n            (double)(szSeg+szRoot)/(double)(nSeg+nRoot));\n    printf(\"Average size of leaf segments............ %11.1f\\n\",\n            (double)(szSeg-szIdx)/(double)(nSeg-nIdx));\n  }\n  if( nIdx>0 ){\n    printf(\"Average size of index segments........... %11.1f\\n\",\n            (double)szIdx/(double)nIdx);\n  }\n  if( nRoot>0 ){\n    printf(\"Average size of root segments............ %11.1f\\n\",\n            (double)szRoot/(double)nRoot);\n  }\n  mx = mxSeg;\n  if( mx<mxRoot ) mx = mxRoot;\n  printf(\"Maximum segment size..................... %9lld\\n\", mx);\n  printf(\"Maximum index segment size............... %9lld\\n\", mxIdx);\n  printf(\"Maximum root segment size................ %9lld\\n\", mxRoot);\n\n  pStmt = prepare(db, \"PRAGMA page_size\");\n  pgsz = 1024;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    pgsz = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  printf(\"Database page size....................... %9d\\n\", pgsz);\n  pStmt = prepare(db,\n            \"SELECT count(*)\"\n            \"  FROM '%q_segments' a JOIN '%q_segdir' b\"\n            \" WHERE a.blockid BETWEEN b.start_block AND b.leaves_end_block\"\n            \"   AND length(a.block)>%d\",\n            zTab, zTab, pgsz-45);\n  n = 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    n = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  nLeaf = nSeg - nIdx;\n  printf(\"Leaf segments larger than %5d bytes.... %9d   %5.2f%%\\n\",\n         pgsz-45, n, nLeaf>0 ? n*100.0/nLeaf : 0.0);\n\n  pStmt = prepare(db, \"SELECT max(level%%1024) FROM '%q_segdir'\", zTab);\n  mxLevel = 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    mxLevel = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n\n  for(i=0; i<=mxLevel; i++){\n    pStmt = prepare(db,\n           \"SELECT count(*), sum(len), avg(len), max(len), sum(len>%d),\"\n           \"       count(distinct idx)\"\n           \"  FROM (SELECT length(a.block) AS len, idx\"\n           \"          FROM '%q_segments' a JOIN '%q_segdir' b\"\n           \"         WHERE (a.blockid BETWEEN b.start_block\"\n                                       \" AND b.leaves_end_block)\"\n           \"           AND (b.level%%1024)==%d)\",\n           pgsz-45, zTab, zTab, i);\n    if( sqlite3_step(pStmt)==SQLITE_ROW\n     && (nLeaf = sqlite3_column_int(pStmt, 0))>0\n    ){\n      sqlite3_int64 sz;\n      nIdx = sqlite3_column_int(pStmt, 5);\n      printf(\"For level %d:\\n\", i);\n      printf(\"  Number of indexes...................... %9d\\n\", nIdx);\n      printf(\"  Number of leaf segments................ %9d\\n\", nLeaf);\n      if( nIdx>1 ){\n        printf(\"  Average leaf segments per index........ %11.1f\\n\",\n               (double)nLeaf/(double)nIdx);\n      }\n      printf(\"  Total size of all leaf segments........ %9lld\\n\",\n             (sz = sqlite3_column_int64(pStmt, 1)));\n      printf(\"  Average size of leaf segments.......... %11.1f\\n\",\n             sqlite3_column_double(pStmt, 2));\n      if( nIdx>1 ){\n        printf(\"  Average leaf segment size per index.... %11.1f\\n\",\n               (double)sz/(double)nIdx);\n      }\n      printf(\"  Maximum leaf segment size.............. %9lld\\n\",\n             sqlite3_column_int64(pStmt, 3));\n      n = sqlite3_column_int(pStmt, 4);\n      printf(\"  Leaf segments larger than %5d bytes.. %9d   %5.2f%%\\n\",\n             pgsz-45, n, n*100.0/nLeaf);\n    }\n    sqlite3_finalize(pStmt);\n  }\n}\n\n/*\n** Print a single \"tree\" line of the segdir map output.\n*/\nstatic void printTreeLine(sqlite3_int64 iLower, sqlite3_int64 iUpper){\n  printf(\"                 tree   %9lld\", iLower);\n  if( iUpper>iLower ){\n    printf(\" thru %9lld  (%lld blocks)\", iUpper, iUpper-iLower+1);\n  }\n  printf(\"\\n\");\n}\n\n/*\n** Check to see if the block of a %_segments entry is NULL.\n*/\nstatic int isNullSegment(sqlite3 *db, const char *zTab, sqlite3_int64 iBlockId){\n  sqlite3_stmt *pStmt;\n  int rc = 1;\n\n  pStmt = prepare(db, \"SELECT block IS NULL FROM '%q_segments'\"\n                      \" WHERE blockid=%lld\", zTab, iBlockId);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    rc = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** Show a map of segments derived from the %_segdir table.\n*/\nstatic void showSegdirMap(sqlite3 *db, const char *zTab){\n  int mxIndex, iIndex;\n  sqlite3_stmt *pStmt = 0;\n  sqlite3_stmt *pStmt2 = 0;\n  int prevLevel;\n\n  pStmt = prepare(db, \"SELECT max(level/1024) FROM '%q_segdir'\", zTab);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    mxIndex = sqlite3_column_int(pStmt, 0);\n  }else{\n    mxIndex = 0;\n  }\n  sqlite3_finalize(pStmt);\n\n  printf(\"Number of inverted indices............... %3d\\n\", mxIndex+1);\n  pStmt = prepare(db,\n    \"SELECT level, idx, start_block, leaves_end_block, end_block, rowid\"\n    \"  FROM '%q_segdir'\"\n    \" WHERE level/1024==?\"\n    \" ORDER BY level DESC, idx\",\n    zTab);\n  pStmt2 = prepare(db,\n    \"SELECT blockid FROM '%q_segments'\"\n    \" WHERE blockid BETWEEN ? AND ? ORDER BY blockid\",\n    zTab);\n  for(iIndex=0; iIndex<=mxIndex; iIndex++){\n    if( mxIndex>0 ){\n      printf(\"**************************** Index %d \"\n             \"****************************\\n\", iIndex);\n    }\n    sqlite3_bind_int(pStmt, 1, iIndex);\n    prevLevel = -1;\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      int iLevel = sqlite3_column_int(pStmt, 0)%1024;\n      int iIdx = sqlite3_column_int(pStmt, 1);\n      sqlite3_int64 iStart = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iLEnd = sqlite3_column_int64(pStmt, 3);\n      sqlite3_int64 iEnd = sqlite3_column_int64(pStmt, 4);\n      char rtag[20];\n      if( iLevel!=prevLevel ){\n        printf(\"level %2d idx %2d\", iLevel, iIdx);\n        prevLevel = iLevel;\n      }else{\n        printf(\"         idx %2d\", iIdx);\n      }\n      sqlite3_snprintf(sizeof(rtag), rtag, \"r%lld\",\n                       sqlite3_column_int64(pStmt,5));\n      printf(\"  root   %9s\\n\", rtag);\n      if( iLEnd>iStart ){\n        sqlite3_int64 iLower, iPrev = 0, iX;\n        if( iLEnd+1<=iEnd ){\n          sqlite3_bind_int64(pStmt2, 1, iLEnd+1);\n          sqlite3_bind_int64(pStmt2, 2, iEnd);\n          iLower = -1;        \n          while( sqlite3_step(pStmt2)==SQLITE_ROW ){\n            iX = sqlite3_column_int64(pStmt2, 0);\n            if( iLower<0 ){\n              iLower = iPrev = iX;\n            }else if( iX==iPrev+1 ){\n              iPrev = iX;\n            }else{\n              printTreeLine(iLower, iPrev);\n              iLower = iPrev = iX;\n            }\n          }\n          sqlite3_reset(pStmt2);\n          if( iLower>=0 ){\n            if( iLower==iPrev && iLower==iEnd\n             && isNullSegment(db,zTab,iLower)\n            ){\n              printf(\"                 null   %9lld\\n\", iLower);\n            }else{\n              printTreeLine(iLower, iPrev);\n            }\n          }\n        }\n        printf(\"                 leaves %9lld thru %9lld  (%lld blocks)\\n\",\n               iStart, iLEnd, iLEnd - iStart + 1);\n      }\n    }\n    sqlite3_reset(pStmt);\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_finalize(pStmt2);\n}\n\n/*\n** Decode a single segment block and display the results on stdout.\n*/\nstatic void decodeSegment(\n  const unsigned char *aData,   /* Content to print */\n  int nData                     /* Number of bytes of content */\n){\n  sqlite3_int64 iChild = 0;\n  sqlite3_int64 iPrefix;\n  sqlite3_int64 nTerm;\n  sqlite3_int64 n;\n  sqlite3_int64 iDocsz;\n  int iHeight;\n  sqlite3_int64 i = 0;\n  int cnt = 0;\n  char zTerm[1000];\n\n  i += getVarint(aData, &n);\n  iHeight = (int)n;\n  printf(\"height: %d\\n\", iHeight);\n  if( iHeight>0 ){\n    i += getVarint(aData+i, &iChild);\n    printf(\"left-child: %lld\\n\", iChild);\n  }\n  while( i<nData ){\n    if( (cnt++)>0 ){\n      i += getVarint(aData+i, &iPrefix);\n    }else{\n      iPrefix = 0;\n    }\n    i += getVarint(aData+i, &nTerm);\n    if( iPrefix+nTerm+1 >= sizeof(zTerm) ){\n      fprintf(stderr, \"term to long\\n\");\n      exit(1);\n    }\n    memcpy(zTerm+iPrefix, aData+i, (size_t)nTerm);\n    zTerm[iPrefix+nTerm] = 0;\n    i += nTerm;\n    if( iHeight==0 ){\n      i += getVarint(aData+i, &iDocsz);\n      printf(\"term: %-25s doclist %7lld bytes offset %lld\\n\", zTerm, iDocsz, i);\n      i += iDocsz;\n    }else{\n      printf(\"term: %-25s child %lld\\n\", zTerm, ++iChild);\n    }\n  }\n}\n  \n  \n/*\n** Print a a blob as hex and ascii.\n*/\nstatic void printBlob(\n  const unsigned char *aData,   /* Content to print */\n  int nData                     /* Number of bytes of content */\n){\n  int i, j;\n  const char *zOfstFmt;\n  const int perLine = 16;\n\n  if( (nData&~0xfff)==0 ){\n    zOfstFmt = \" %03x: \";\n  }else if( (nData&~0xffff)==0 ){\n    zOfstFmt = \" %04x: \";\n  }else if( (nData&~0xfffff)==0 ){\n    zOfstFmt = \" %05x: \";\n  }else if( (nData&~0xffffff)==0 ){\n    zOfstFmt = \" %06x: \";\n  }else{\n    zOfstFmt = \" %08x: \";\n  }\n\n  for(i=0; i<nData; i += perLine){\n    fprintf(stdout, zOfstFmt, i);\n    for(j=0; j<perLine; j++){\n      if( i+j>nData ){\n        fprintf(stdout, \"   \");\n      }else{\n        fprintf(stdout,\"%02x \", aData[i+j]);\n      }\n    }\n    for(j=0; j<perLine; j++){\n      if( i+j>nData ){\n        fprintf(stdout, \" \");\n      }else{\n        fprintf(stdout,\"%c\", isprint(aData[i+j]) ? aData[i+j] : '.');\n      }\n    }\n    fprintf(stdout,\"\\n\");\n  }\n}\n\n/*\n** Convert text to a 64-bit integer\n*/\nstatic sqlite3_int64 atoi64(const char *z){\n  sqlite3_int64 v = 0;\n  while( z[0]>='0' && z[0]<='9' ){\n     v = v*10 + z[0] - '0';\n     z++;\n  }\n  return v;\n}\n\n/*\n** Return a prepared statement which, when stepped, will return in its\n** first column the blob associated with segment zId.  If zId begins with\n** 'r' then it is a rowid of a %_segdir entry.  Otherwise it is a\n** %_segment entry.\n*/\nstatic sqlite3_stmt *prepareToGetSegment(\n  sqlite3 *db,         /* The database */\n  const char *zTab,    /* The FTS3/4 table name */\n  const char *zId      /* ID of the segment to open */\n){\n  sqlite3_stmt *pStmt;\n  if( zId[0]=='r' ){\n    pStmt = prepare(db, \"SELECT root FROM '%q_segdir' WHERE rowid=%lld\",\n                    zTab, atoi64(zId+1));\n  }else{\n    pStmt = prepare(db, \"SELECT block FROM '%q_segments' WHERE blockid=%lld\",\n                    zTab, atoi64(zId));\n  }\n  return pStmt;\n}\n\n/*\n** Print the content of a segment or of the root of a segdir.  The segment\n** or root is identified by azExtra[0].  If the first character of azExtra[0]\n** is 'r' then the remainder is the integer rowid of the %_segdir entry.\n** If the first character of azExtra[0] is not 'r' then, then all of\n** azExtra[0] is an integer which is the block number.\n**\n** If the --raw option is present in azExtra, then a hex dump is provided.\n** Otherwise a decoding is shown.\n*/\nstatic void showSegment(sqlite3 *db, const char *zTab){\n  const unsigned char *aData;\n  int nData;\n  sqlite3_stmt *pStmt;\n\n  pStmt = prepareToGetSegment(db, zTab, azExtra[0]);\n  if( sqlite3_step(pStmt)!=SQLITE_ROW ){\n    sqlite3_finalize(pStmt);\n    return;\n  }\n  nData = sqlite3_column_bytes(pStmt, 0);\n  aData = sqlite3_column_blob(pStmt, 0);\n  printf(\"Segment %s of size %d bytes:\\n\", azExtra[0], nData);\n  if( findOption(\"raw\", 0, 0)!=0 ){\n    printBlob(aData, nData);\n  }else{\n    decodeSegment(aData, nData);\n  }\n  sqlite3_finalize(pStmt);\n}\n\n/*\n** Decode a single doclist and display the results on stdout.\n*/\nstatic void decodeDoclist(\n  const unsigned char *aData,   /* Content to print */\n  int nData                     /* Number of bytes of content */\n){\n  sqlite3_int64 iPrevDocid = 0;\n  sqlite3_int64 iDocid;\n  sqlite3_int64 iPos;\n  sqlite3_int64 iPrevPos = 0;\n  sqlite3_int64 iCol;\n  int i = 0;\n\n  while( i<nData ){\n    i += getVarint(aData+i, &iDocid);\n    printf(\"docid %lld col0\", iDocid+iPrevDocid);\n    iPrevDocid += iDocid;\n    iPrevPos = 0;\n    while( 1 ){\n      i += getVarint(aData+i, &iPos);\n      if( iPos==1 ){\n        i += getVarint(aData+i, &iCol);\n        printf(\" col%lld\", iCol);\n        iPrevPos = 0;\n      }else if( iPos==0 ){\n        printf(\"\\n\");\n        break;\n      }else{\n        iPrevPos += iPos - 2;\n        printf(\" %lld\", iPrevPos);\n      }\n    }\n  }\n}\n  \n\n/*\n** Print the content of a doclist.  The segment or segdir-root is\n** identified by azExtra[0].  If the first character of azExtra[0]\n** is 'r' then the remainder is the integer rowid of the %_segdir entry.\n** If the first character of azExtra[0] is not 'r' then, then all of\n** azExtra[0] is an integer which is the block number.  The offset\n** into the segment is identified by azExtra[1].  The size of the doclist\n** is azExtra[2].\n**\n** If the --raw option is present in azExtra, then a hex dump is provided.\n** Otherwise a decoding is shown.\n*/\nstatic void showDoclist(sqlite3 *db, const char *zTab){\n  const unsigned char *aData;\n  sqlite3_int64 offset;\n  int nData;\n  sqlite3_stmt *pStmt;\n\n  offset = atoi64(azExtra[1]);\n  nData = atoi(azExtra[2]);\n  pStmt = prepareToGetSegment(db, zTab, azExtra[0]);\n  if( sqlite3_step(pStmt)!=SQLITE_ROW ){\n    sqlite3_finalize(pStmt);\n    return;\n  }\n  aData = sqlite3_column_blob(pStmt, 0);\n  printf(\"Doclist at %s offset %lld of size %d bytes:\\n\",\n         azExtra[0], offset, nData);\n  if( findOption(\"raw\", 0, 0)!=0 ){\n    printBlob(aData+offset, nData);\n  }else{\n    decodeDoclist(aData+offset, nData);\n  }\n  sqlite3_finalize(pStmt);\n}\n\n/*\n** Show the top N largest segments\n*/\nstatic void listBigSegments(sqlite3 *db, const char *zTab){\n  int nTop, i;\n  sqlite3_stmt *pStmt;\n  sqlite3_int64 sz;\n  sqlite3_int64 id;\n\n  nTop = atoi(findOption(\"top\", 1, \"25\"));\n  printf(\"The %d largest segments:\\n\", nTop);\n  pStmt = prepare(db,\n            \"SELECT blockid, length(block) AS len FROM '%q_segments'\"\n            \" ORDER BY 2 DESC, 1\"\n            \" LIMIT %d\", zTab, nTop);\n  i = 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    i++;\n    id = sqlite3_column_int64(pStmt, 0);\n    sz = sqlite3_column_int64(pStmt, 1);\n    printf(\"  %2d. %9lld size %lld\\n\", i, id, sz);\n  }\n  sqlite3_finalize(pStmt);\n}\n\n\n\nstatic void usage(const char *argv0){\n  fprintf(stderr, \"Usage: %s DATABASE\\n\"\n                  \"   or: %s DATABASE FTS3TABLE ARGS...\\n\", argv0, argv0);\n  fprintf(stderr,\n    \"ARGS:\\n\"\n    \"  big-segments [--top N]                    show the largest segments\\n\"\n    \"  doclist BLOCKID OFFSET SIZE [--raw]       Decode a doclist\\n\"\n    \"  schema                                    FTS table schema\\n\"\n    \"  segdir                                    directory of segments\\n\"\n    \"  segment BLOCKID [--raw]                   content of a segment\\n\"\n    \"  segment-stats                             info on segment sizes\\n\"\n    \"  stat                                      the %%_stat table\\n\"\n    \"  vocabulary [--top N]                      document vocabulary\\n\"\n  );\n  exit(1);\n}\n\nint main(int argc, char **argv){\n  sqlite3 *db;\n  int rc;\n  const char *zTab;\n  const char *zCmd;\n\n  if( argc<2 ) usage(argv[0]);\n  rc = sqlite3_open(argv[1], &db);\n  if( rc ){\n    fprintf(stderr, \"Cannot open %s\\n\", argv[1]);\n    exit(1);\n  }\n  if( argc==2 ){\n    sqlite3_stmt *pStmt;\n    int cnt = 0;\n    pStmt = prepare(db, \"SELECT b.sql\"\n                        \"  FROM sqlite_master a, sqlite_master b\"\n                        \" WHERE a.name GLOB '*_segdir'\"\n                        \"   AND b.name=substr(a.name,1,length(a.name)-7)\"\n                        \" ORDER BY 1\");\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      cnt++;\n      printf(\"%s;\\n\", sqlite3_column_text(pStmt, 0));\n    }\n    sqlite3_finalize(pStmt);\n    if( cnt==0 ){\n      printf(\"/* No FTS3/4 tables found in database %s */\\n\", argv[1]);\n    }\n    return 0;\n  }\n  if( argc<4 ) usage(argv[0]);\n  zTab = argv[2];\n  zCmd = argv[3];\n  nExtra = argc-4;\n  azExtra = argv+4;\n  if( strcmp(zCmd,\"big-segments\")==0 ){\n    listBigSegments(db, zTab);\n  }else if( strcmp(zCmd,\"doclist\")==0 ){\n    if( argc<7 ) usage(argv[0]);\n    showDoclist(db, zTab);\n  }else if( strcmp(zCmd,\"schema\")==0 ){\n    showSchema(db, zTab);\n  }else if( strcmp(zCmd,\"segdir\")==0 ){\n    showSegdirMap(db, zTab);\n  }else if( strcmp(zCmd,\"segment\")==0 ){\n    if( argc<5 ) usage(argv[0]);\n    showSegment(db, zTab);\n  }else if( strcmp(zCmd,\"segment-stats\")==0 ){\n    showSegmentStats(db, zTab);\n  }else if( strcmp(zCmd,\"stat\")==0 ){\n    showStat(db, zTab);\n  }else if( strcmp(zCmd,\"vocabulary\")==0 ){\n    showVocabulary(db, zTab);\n  }else{\n    usage(argv[0]);\n  }\n  return 0; \n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/unicode/CaseFolding.txt",
    "content": "# CaseFolding-6.1.0.txt\n# Date: 2011-07-25, 21:21:56 GMT [MD]\n#\n# Unicode Character Database\n# Copyright (c) 1991-2011 Unicode, Inc.\n# For terms of use, see http://www.unicode.org/terms_of_use.html\n# For documentation, see http://www.unicode.org/reports/tr44/\n#\n# Case Folding Properties\n#\n# This file is a supplement to the UnicodeData file.\n# It provides a case folding mapping generated from the Unicode Character Database.\n# If all characters are mapped according to the full mapping below, then\n# case differences (according to UnicodeData.txt and SpecialCasing.txt)\n# are eliminated.\n#\n# The data supports both implementations that require simple case foldings\n# (where string lengths don't change), and implementations that allow full case folding\n# (where string lengths may grow). Note that where they can be supported, the\n# full case foldings are superior: for example, they allow \"MASSE\" and \"Maße\" to match.\n#\n# All code points not listed in this file map to themselves.\n#\n# NOTE: case folding does not preserve normalization formats!\n#\n# For information on case folding, including how to have case folding \n# preserve normalization formats, see Section 3.13 Default Case Algorithms in\n# The Unicode Standard, Version 5.0.\n#\n# ================================================================================\n# Format\n# ================================================================================\n# The entries in this file are in the following machine-readable format:\n#\n# <code>; <status>; <mapping>; # <name>\n#\n# The status field is:\n# C: common case folding, common mappings shared by both simple and full mappings.\n# F: full case folding, mappings that cause strings to grow in length. Multiple characters are separated by spaces.\n# S: simple case folding, mappings to single characters where different from F.\n# T: special case for uppercase I and dotted uppercase I\n#    - For non-Turkic languages, this mapping is normally not used.\n#    - For Turkic languages (tr, az), this mapping can be used instead of the normal mapping for these characters.\n#      Note that the Turkic mappings do not maintain canonical equivalence without additional processing.\n#      See the discussions of case mapping in the Unicode Standard for more information.\n#\n# Usage:\n#  A. To do a simple case folding, use the mappings with status C + S.\n#  B. To do a full case folding, use the mappings with status C + F.\n#\n#    The mappings with status T can be used or omitted depending on the desired case-folding\n#    behavior. (The default option is to exclude them.)\n#\n# =================================================================\n\n# Property: Case_Folding\n\n#  All code points not explicitly listed for Case_Folding\n#  have the value C for the status field, and the code point itself for the mapping field.\n\n# @missing: 0000..10FFFF; C; <code point>\n\n# =================================================================\n0041; C; 0061; # LATIN CAPITAL LETTER A\n0042; C; 0062; # LATIN CAPITAL LETTER B\n0043; C; 0063; # LATIN CAPITAL LETTER C\n0044; C; 0064; # LATIN CAPITAL LETTER D\n0045; C; 0065; # LATIN CAPITAL LETTER E\n0046; C; 0066; # LATIN CAPITAL LETTER F\n0047; C; 0067; # LATIN CAPITAL LETTER G\n0048; C; 0068; # LATIN CAPITAL LETTER H\n0049; C; 0069; # LATIN CAPITAL LETTER I\n0049; T; 0131; # LATIN CAPITAL LETTER I\n004A; C; 006A; # LATIN CAPITAL LETTER J\n004B; C; 006B; # LATIN CAPITAL LETTER K\n004C; C; 006C; # LATIN CAPITAL LETTER L\n004D; C; 006D; # LATIN CAPITAL LETTER M\n004E; C; 006E; # LATIN CAPITAL LETTER N\n004F; C; 006F; # LATIN CAPITAL LETTER O\n0050; C; 0070; # LATIN CAPITAL LETTER P\n0051; C; 0071; # LATIN CAPITAL LETTER Q\n0052; C; 0072; # LATIN CAPITAL LETTER R\n0053; C; 0073; # LATIN CAPITAL LETTER S\n0054; C; 0074; # LATIN CAPITAL LETTER T\n0055; C; 0075; # LATIN CAPITAL LETTER U\n0056; C; 0076; # LATIN CAPITAL LETTER V\n0057; C; 0077; # LATIN CAPITAL LETTER W\n0058; C; 0078; # LATIN CAPITAL LETTER X\n0059; C; 0079; # LATIN CAPITAL LETTER Y\n005A; C; 007A; # LATIN CAPITAL LETTER Z\n00B5; C; 03BC; # MICRO SIGN\n00C0; C; 00E0; # LATIN CAPITAL LETTER A WITH GRAVE\n00C1; C; 00E1; # LATIN CAPITAL LETTER A WITH ACUTE\n00C2; C; 00E2; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX\n00C3; C; 00E3; # LATIN CAPITAL LETTER A WITH TILDE\n00C4; C; 00E4; # LATIN CAPITAL LETTER A WITH DIAERESIS\n00C5; C; 00E5; # LATIN CAPITAL LETTER A WITH RING ABOVE\n00C6; C; 00E6; # LATIN CAPITAL LETTER AE\n00C7; C; 00E7; # LATIN CAPITAL LETTER C WITH CEDILLA\n00C8; C; 00E8; # LATIN CAPITAL LETTER E WITH GRAVE\n00C9; C; 00E9; # LATIN CAPITAL LETTER E WITH ACUTE\n00CA; C; 00EA; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX\n00CB; C; 00EB; # LATIN CAPITAL LETTER E WITH DIAERESIS\n00CC; C; 00EC; # LATIN CAPITAL LETTER I WITH GRAVE\n00CD; C; 00ED; # LATIN CAPITAL LETTER I WITH ACUTE\n00CE; C; 00EE; # LATIN CAPITAL LETTER I WITH CIRCUMFLEX\n00CF; C; 00EF; # LATIN CAPITAL LETTER I WITH DIAERESIS\n00D0; C; 00F0; # LATIN CAPITAL LETTER ETH\n00D1; C; 00F1; # LATIN CAPITAL LETTER N WITH TILDE\n00D2; C; 00F2; # LATIN CAPITAL LETTER O WITH GRAVE\n00D3; C; 00F3; # LATIN CAPITAL LETTER O WITH ACUTE\n00D4; C; 00F4; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX\n00D5; C; 00F5; # LATIN CAPITAL LETTER O WITH TILDE\n00D6; C; 00F6; # LATIN CAPITAL LETTER O WITH DIAERESIS\n00D8; C; 00F8; # LATIN CAPITAL LETTER O WITH STROKE\n00D9; C; 00F9; # LATIN CAPITAL LETTER U WITH GRAVE\n00DA; C; 00FA; # LATIN CAPITAL LETTER U WITH ACUTE\n00DB; C; 00FB; # LATIN CAPITAL LETTER U WITH CIRCUMFLEX\n00DC; C; 00FC; # LATIN CAPITAL LETTER U WITH DIAERESIS\n00DD; C; 00FD; # LATIN CAPITAL LETTER Y WITH ACUTE\n00DE; C; 00FE; # LATIN CAPITAL LETTER THORN\n00DF; F; 0073 0073; # LATIN SMALL LETTER SHARP S\n0100; C; 0101; # LATIN CAPITAL LETTER A WITH MACRON\n0102; C; 0103; # LATIN CAPITAL LETTER A WITH BREVE\n0104; C; 0105; # LATIN CAPITAL LETTER A WITH OGONEK\n0106; C; 0107; # LATIN CAPITAL LETTER C WITH ACUTE\n0108; C; 0109; # LATIN CAPITAL LETTER C WITH CIRCUMFLEX\n010A; C; 010B; # LATIN CAPITAL LETTER C WITH DOT ABOVE\n010C; C; 010D; # LATIN CAPITAL LETTER C WITH CARON\n010E; C; 010F; # LATIN CAPITAL LETTER D WITH CARON\n0110; C; 0111; # LATIN CAPITAL LETTER D WITH STROKE\n0112; C; 0113; # LATIN CAPITAL LETTER E WITH MACRON\n0114; C; 0115; # LATIN CAPITAL LETTER E WITH BREVE\n0116; C; 0117; # LATIN CAPITAL LETTER E WITH DOT ABOVE\n0118; C; 0119; # LATIN CAPITAL LETTER E WITH OGONEK\n011A; C; 011B; # LATIN CAPITAL LETTER E WITH CARON\n011C; C; 011D; # LATIN CAPITAL LETTER G WITH CIRCUMFLEX\n011E; C; 011F; # LATIN CAPITAL LETTER G WITH BREVE\n0120; C; 0121; # LATIN CAPITAL LETTER G WITH DOT ABOVE\n0122; C; 0123; # LATIN CAPITAL LETTER G WITH CEDILLA\n0124; C; 0125; # LATIN CAPITAL LETTER H WITH CIRCUMFLEX\n0126; C; 0127; # LATIN CAPITAL LETTER H WITH STROKE\n0128; C; 0129; # LATIN CAPITAL LETTER I WITH TILDE\n012A; C; 012B; # LATIN CAPITAL LETTER I WITH MACRON\n012C; C; 012D; # LATIN CAPITAL LETTER I WITH BREVE\n012E; C; 012F; # LATIN CAPITAL LETTER I WITH OGONEK\n0130; F; 0069 0307; # LATIN CAPITAL LETTER I WITH DOT ABOVE\n0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE\n0132; C; 0133; # LATIN CAPITAL LIGATURE IJ\n0134; C; 0135; # LATIN CAPITAL LETTER J WITH CIRCUMFLEX\n0136; C; 0137; # LATIN CAPITAL LETTER K WITH CEDILLA\n0139; C; 013A; # LATIN CAPITAL LETTER L WITH ACUTE\n013B; C; 013C; # LATIN CAPITAL LETTER L WITH CEDILLA\n013D; C; 013E; # LATIN CAPITAL LETTER L WITH CARON\n013F; C; 0140; # LATIN CAPITAL LETTER L WITH MIDDLE DOT\n0141; C; 0142; # LATIN CAPITAL LETTER L WITH STROKE\n0143; C; 0144; # LATIN CAPITAL LETTER N WITH ACUTE\n0145; C; 0146; # LATIN CAPITAL LETTER N WITH CEDILLA\n0147; C; 0148; # LATIN CAPITAL LETTER N WITH CARON\n0149; F; 02BC 006E; # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE\n014A; C; 014B; # LATIN CAPITAL LETTER ENG\n014C; C; 014D; # LATIN CAPITAL LETTER O WITH MACRON\n014E; C; 014F; # LATIN CAPITAL LETTER O WITH BREVE\n0150; C; 0151; # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE\n0152; C; 0153; # LATIN CAPITAL LIGATURE OE\n0154; C; 0155; # LATIN CAPITAL LETTER R WITH ACUTE\n0156; C; 0157; # LATIN CAPITAL LETTER R WITH CEDILLA\n0158; C; 0159; # LATIN CAPITAL LETTER R WITH CARON\n015A; C; 015B; # LATIN CAPITAL LETTER S WITH ACUTE\n015C; C; 015D; # LATIN CAPITAL LETTER S WITH CIRCUMFLEX\n015E; C; 015F; # LATIN CAPITAL LETTER S WITH CEDILLA\n0160; C; 0161; # LATIN CAPITAL LETTER S WITH CARON\n0162; C; 0163; # LATIN CAPITAL LETTER T WITH CEDILLA\n0164; C; 0165; # LATIN CAPITAL LETTER T WITH CARON\n0166; C; 0167; # LATIN CAPITAL LETTER T WITH STROKE\n0168; C; 0169; # LATIN CAPITAL LETTER U WITH TILDE\n016A; C; 016B; # LATIN CAPITAL LETTER U WITH MACRON\n016C; C; 016D; # LATIN CAPITAL LETTER U WITH BREVE\n016E; C; 016F; # LATIN CAPITAL LETTER U WITH RING ABOVE\n0170; C; 0171; # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE\n0172; C; 0173; # LATIN CAPITAL LETTER U WITH OGONEK\n0174; C; 0175; # LATIN CAPITAL LETTER W WITH CIRCUMFLEX\n0176; C; 0177; # LATIN CAPITAL LETTER Y WITH CIRCUMFLEX\n0178; C; 00FF; # LATIN CAPITAL LETTER Y WITH DIAERESIS\n0179; C; 017A; # LATIN CAPITAL LETTER Z WITH ACUTE\n017B; C; 017C; # LATIN CAPITAL LETTER Z WITH DOT ABOVE\n017D; C; 017E; # LATIN CAPITAL LETTER Z WITH CARON\n017F; C; 0073; # LATIN SMALL LETTER LONG S\n0181; C; 0253; # LATIN CAPITAL LETTER B WITH HOOK\n0182; C; 0183; # LATIN CAPITAL LETTER B WITH TOPBAR\n0184; C; 0185; # LATIN CAPITAL LETTER TONE SIX\n0186; C; 0254; # LATIN CAPITAL LETTER OPEN O\n0187; C; 0188; # LATIN CAPITAL LETTER C WITH HOOK\n0189; C; 0256; # LATIN CAPITAL LETTER AFRICAN D\n018A; C; 0257; # LATIN CAPITAL LETTER D WITH HOOK\n018B; C; 018C; # LATIN CAPITAL LETTER D WITH TOPBAR\n018E; C; 01DD; # LATIN CAPITAL LETTER REVERSED E\n018F; C; 0259; # LATIN CAPITAL LETTER SCHWA\n0190; C; 025B; # LATIN CAPITAL LETTER OPEN E\n0191; C; 0192; # LATIN CAPITAL LETTER F WITH HOOK\n0193; C; 0260; # LATIN CAPITAL LETTER G WITH HOOK\n0194; C; 0263; # LATIN CAPITAL LETTER GAMMA\n0196; C; 0269; # LATIN CAPITAL LETTER IOTA\n0197; C; 0268; # LATIN CAPITAL LETTER I WITH STROKE\n0198; C; 0199; # LATIN CAPITAL LETTER K WITH HOOK\n019C; C; 026F; # LATIN CAPITAL LETTER TURNED M\n019D; C; 0272; # LATIN CAPITAL LETTER N WITH LEFT HOOK\n019F; C; 0275; # LATIN CAPITAL LETTER O WITH MIDDLE TILDE\n01A0; C; 01A1; # LATIN CAPITAL LETTER O WITH HORN\n01A2; C; 01A3; # LATIN CAPITAL LETTER OI\n01A4; C; 01A5; # LATIN CAPITAL LETTER P WITH HOOK\n01A6; C; 0280; # LATIN LETTER YR\n01A7; C; 01A8; # LATIN CAPITAL LETTER TONE TWO\n01A9; C; 0283; # LATIN CAPITAL LETTER ESH\n01AC; C; 01AD; # LATIN CAPITAL LETTER T WITH HOOK\n01AE; C; 0288; # LATIN CAPITAL LETTER T WITH RETROFLEX HOOK\n01AF; C; 01B0; # LATIN CAPITAL LETTER U WITH HORN\n01B1; C; 028A; # LATIN CAPITAL LETTER UPSILON\n01B2; C; 028B; # LATIN CAPITAL LETTER V WITH HOOK\n01B3; C; 01B4; # LATIN CAPITAL LETTER Y WITH HOOK\n01B5; C; 01B6; # LATIN CAPITAL LETTER Z WITH STROKE\n01B7; C; 0292; # LATIN CAPITAL LETTER EZH\n01B8; C; 01B9; # LATIN CAPITAL LETTER EZH REVERSED\n01BC; C; 01BD; # LATIN CAPITAL LETTER TONE FIVE\n01C4; C; 01C6; # LATIN CAPITAL LETTER DZ WITH CARON\n01C5; C; 01C6; # LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON\n01C7; C; 01C9; # LATIN CAPITAL LETTER LJ\n01C8; C; 01C9; # LATIN CAPITAL LETTER L WITH SMALL LETTER J\n01CA; C; 01CC; # LATIN CAPITAL LETTER NJ\n01CB; C; 01CC; # LATIN CAPITAL LETTER N WITH SMALL LETTER J\n01CD; C; 01CE; # LATIN CAPITAL LETTER A WITH CARON\n01CF; C; 01D0; # LATIN CAPITAL LETTER I WITH CARON\n01D1; C; 01D2; # LATIN CAPITAL LETTER O WITH CARON\n01D3; C; 01D4; # LATIN CAPITAL LETTER U WITH CARON\n01D5; C; 01D6; # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON\n01D7; C; 01D8; # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE\n01D9; C; 01DA; # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON\n01DB; C; 01DC; # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE\n01DE; C; 01DF; # LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON\n01E0; C; 01E1; # LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON\n01E2; C; 01E3; # LATIN CAPITAL LETTER AE WITH MACRON\n01E4; C; 01E5; # LATIN CAPITAL LETTER G WITH STROKE\n01E6; C; 01E7; # LATIN CAPITAL LETTER G WITH CARON\n01E8; C; 01E9; # LATIN CAPITAL LETTER K WITH CARON\n01EA; C; 01EB; # LATIN CAPITAL LETTER O WITH OGONEK\n01EC; C; 01ED; # LATIN CAPITAL LETTER O WITH OGONEK AND MACRON\n01EE; C; 01EF; # LATIN CAPITAL LETTER EZH WITH CARON\n01F0; F; 006A 030C; # LATIN SMALL LETTER J WITH CARON\n01F1; C; 01F3; # LATIN CAPITAL LETTER DZ\n01F2; C; 01F3; # LATIN CAPITAL LETTER D WITH SMALL LETTER Z\n01F4; C; 01F5; # LATIN CAPITAL LETTER G WITH ACUTE\n01F6; C; 0195; # LATIN CAPITAL LETTER HWAIR\n01F7; C; 01BF; # LATIN CAPITAL LETTER WYNN\n01F8; C; 01F9; # LATIN CAPITAL LETTER N WITH GRAVE\n01FA; C; 01FB; # LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE\n01FC; C; 01FD; # LATIN CAPITAL LETTER AE WITH ACUTE\n01FE; C; 01FF; # LATIN CAPITAL LETTER O WITH STROKE AND ACUTE\n0200; C; 0201; # LATIN CAPITAL LETTER A WITH DOUBLE GRAVE\n0202; C; 0203; # LATIN CAPITAL LETTER A WITH INVERTED BREVE\n0204; C; 0205; # LATIN CAPITAL LETTER E WITH DOUBLE GRAVE\n0206; C; 0207; # LATIN CAPITAL LETTER E WITH INVERTED BREVE\n0208; C; 0209; # LATIN CAPITAL LETTER I WITH DOUBLE GRAVE\n020A; C; 020B; # LATIN CAPITAL LETTER I WITH INVERTED BREVE\n020C; C; 020D; # LATIN CAPITAL LETTER O WITH DOUBLE GRAVE\n020E; C; 020F; # LATIN CAPITAL LETTER O WITH INVERTED BREVE\n0210; C; 0211; # LATIN CAPITAL LETTER R WITH DOUBLE GRAVE\n0212; C; 0213; # LATIN CAPITAL LETTER R WITH INVERTED BREVE\n0214; C; 0215; # LATIN CAPITAL LETTER U WITH DOUBLE GRAVE\n0216; C; 0217; # LATIN CAPITAL LETTER U WITH INVERTED BREVE\n0218; C; 0219; # LATIN CAPITAL LETTER S WITH COMMA BELOW\n021A; C; 021B; # LATIN CAPITAL LETTER T WITH COMMA BELOW\n021C; C; 021D; # LATIN CAPITAL LETTER YOGH\n021E; C; 021F; # LATIN CAPITAL LETTER H WITH CARON\n0220; C; 019E; # LATIN CAPITAL LETTER N WITH LONG RIGHT LEG\n0222; C; 0223; # LATIN CAPITAL LETTER OU\n0224; C; 0225; # LATIN CAPITAL LETTER Z WITH HOOK\n0226; C; 0227; # LATIN CAPITAL LETTER A WITH DOT ABOVE\n0228; C; 0229; # LATIN CAPITAL LETTER E WITH CEDILLA\n022A; C; 022B; # LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON\n022C; C; 022D; # LATIN CAPITAL LETTER O WITH TILDE AND MACRON\n022E; C; 022F; # LATIN CAPITAL LETTER O WITH DOT ABOVE\n0230; C; 0231; # LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON\n0232; C; 0233; # LATIN CAPITAL LETTER Y WITH MACRON\n023A; C; 2C65; # LATIN CAPITAL LETTER A WITH STROKE\n023B; C; 023C; # LATIN CAPITAL LETTER C WITH STROKE\n023D; C; 019A; # LATIN CAPITAL LETTER L WITH BAR\n023E; C; 2C66; # LATIN CAPITAL LETTER T WITH DIAGONAL STROKE\n0241; C; 0242; # LATIN CAPITAL LETTER GLOTTAL STOP\n0243; C; 0180; # LATIN CAPITAL LETTER B WITH STROKE\n0244; C; 0289; # LATIN CAPITAL LETTER U BAR\n0245; C; 028C; # LATIN CAPITAL LETTER TURNED V\n0246; C; 0247; # LATIN CAPITAL LETTER E WITH STROKE\n0248; C; 0249; # LATIN CAPITAL LETTER J WITH STROKE\n024A; C; 024B; # LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL\n024C; C; 024D; # LATIN CAPITAL LETTER R WITH STROKE\n024E; C; 024F; # LATIN CAPITAL LETTER Y WITH STROKE\n0345; C; 03B9; # COMBINING GREEK YPOGEGRAMMENI\n0370; C; 0371; # GREEK CAPITAL LETTER HETA\n0372; C; 0373; # GREEK CAPITAL LETTER ARCHAIC SAMPI\n0376; C; 0377; # GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA\n0386; C; 03AC; # GREEK CAPITAL LETTER ALPHA WITH TONOS\n0388; C; 03AD; # GREEK CAPITAL LETTER EPSILON WITH TONOS\n0389; C; 03AE; # GREEK CAPITAL LETTER ETA WITH TONOS\n038A; C; 03AF; # GREEK CAPITAL LETTER IOTA WITH TONOS\n038C; C; 03CC; # GREEK CAPITAL LETTER OMICRON WITH TONOS\n038E; C; 03CD; # GREEK CAPITAL LETTER UPSILON WITH TONOS\n038F; C; 03CE; # GREEK CAPITAL LETTER OMEGA WITH TONOS\n0390; F; 03B9 0308 0301; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS\n0391; C; 03B1; # GREEK CAPITAL LETTER ALPHA\n0392; C; 03B2; # GREEK CAPITAL LETTER BETA\n0393; C; 03B3; # GREEK CAPITAL LETTER GAMMA\n0394; C; 03B4; # GREEK CAPITAL LETTER DELTA\n0395; C; 03B5; # GREEK CAPITAL LETTER EPSILON\n0396; C; 03B6; # GREEK CAPITAL LETTER ZETA\n0397; C; 03B7; # GREEK CAPITAL LETTER ETA\n0398; C; 03B8; # GREEK CAPITAL LETTER THETA\n0399; C; 03B9; # GREEK CAPITAL LETTER IOTA\n039A; C; 03BA; # GREEK CAPITAL LETTER KAPPA\n039B; C; 03BB; # GREEK CAPITAL LETTER LAMDA\n039C; C; 03BC; # GREEK CAPITAL LETTER MU\n039D; C; 03BD; # GREEK CAPITAL LETTER NU\n039E; C; 03BE; # GREEK CAPITAL LETTER XI\n039F; C; 03BF; # GREEK CAPITAL LETTER OMICRON\n03A0; C; 03C0; # GREEK CAPITAL LETTER PI\n03A1; C; 03C1; # GREEK CAPITAL LETTER RHO\n03A3; C; 03C3; # GREEK CAPITAL LETTER SIGMA\n03A4; C; 03C4; # GREEK CAPITAL LETTER TAU\n03A5; C; 03C5; # GREEK CAPITAL LETTER UPSILON\n03A6; C; 03C6; # GREEK CAPITAL LETTER PHI\n03A7; C; 03C7; # GREEK CAPITAL LETTER CHI\n03A8; C; 03C8; # GREEK CAPITAL LETTER PSI\n03A9; C; 03C9; # GREEK CAPITAL LETTER OMEGA\n03AA; C; 03CA; # GREEK CAPITAL LETTER IOTA WITH DIALYTIKA\n03AB; C; 03CB; # GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA\n03B0; F; 03C5 0308 0301; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS\n03C2; C; 03C3; # GREEK SMALL LETTER FINAL SIGMA\n03CF; C; 03D7; # GREEK CAPITAL KAI SYMBOL\n03D0; C; 03B2; # GREEK BETA SYMBOL\n03D1; C; 03B8; # GREEK THETA SYMBOL\n03D5; C; 03C6; # GREEK PHI SYMBOL\n03D6; C; 03C0; # GREEK PI SYMBOL\n03D8; C; 03D9; # GREEK LETTER ARCHAIC KOPPA\n03DA; C; 03DB; # GREEK LETTER STIGMA\n03DC; C; 03DD; # GREEK LETTER DIGAMMA\n03DE; C; 03DF; # GREEK LETTER KOPPA\n03E0; C; 03E1; # GREEK LETTER SAMPI\n03E2; C; 03E3; # COPTIC CAPITAL LETTER SHEI\n03E4; C; 03E5; # COPTIC CAPITAL LETTER FEI\n03E6; C; 03E7; # COPTIC CAPITAL LETTER KHEI\n03E8; C; 03E9; # COPTIC CAPITAL LETTER HORI\n03EA; C; 03EB; # COPTIC CAPITAL LETTER GANGIA\n03EC; C; 03ED; # COPTIC CAPITAL LETTER SHIMA\n03EE; C; 03EF; # COPTIC CAPITAL LETTER DEI\n03F0; C; 03BA; # GREEK KAPPA SYMBOL\n03F1; C; 03C1; # GREEK RHO SYMBOL\n03F4; C; 03B8; # GREEK CAPITAL THETA SYMBOL\n03F5; C; 03B5; # GREEK LUNATE EPSILON SYMBOL\n03F7; C; 03F8; # GREEK CAPITAL LETTER SHO\n03F9; C; 03F2; # GREEK CAPITAL LUNATE SIGMA SYMBOL\n03FA; C; 03FB; # GREEK CAPITAL LETTER SAN\n03FD; C; 037B; # GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL\n03FE; C; 037C; # GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL\n03FF; C; 037D; # GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL\n0400; C; 0450; # CYRILLIC CAPITAL LETTER IE WITH GRAVE\n0401; C; 0451; # CYRILLIC CAPITAL LETTER IO\n0402; C; 0452; # CYRILLIC CAPITAL LETTER DJE\n0403; C; 0453; # CYRILLIC CAPITAL LETTER GJE\n0404; C; 0454; # CYRILLIC CAPITAL LETTER UKRAINIAN IE\n0405; C; 0455; # CYRILLIC CAPITAL LETTER DZE\n0406; C; 0456; # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I\n0407; C; 0457; # CYRILLIC CAPITAL LETTER YI\n0408; C; 0458; # CYRILLIC CAPITAL LETTER JE\n0409; C; 0459; # CYRILLIC CAPITAL LETTER LJE\n040A; C; 045A; # CYRILLIC CAPITAL LETTER NJE\n040B; C; 045B; # CYRILLIC CAPITAL LETTER TSHE\n040C; C; 045C; # CYRILLIC CAPITAL LETTER KJE\n040D; C; 045D; # CYRILLIC CAPITAL LETTER I WITH GRAVE\n040E; C; 045E; # CYRILLIC CAPITAL LETTER SHORT U\n040F; C; 045F; # CYRILLIC CAPITAL LETTER DZHE\n0410; C; 0430; # CYRILLIC CAPITAL LETTER A\n0411; C; 0431; # CYRILLIC CAPITAL LETTER BE\n0412; C; 0432; # CYRILLIC CAPITAL LETTER VE\n0413; C; 0433; # CYRILLIC CAPITAL LETTER GHE\n0414; C; 0434; # CYRILLIC CAPITAL LETTER DE\n0415; C; 0435; # CYRILLIC CAPITAL LETTER IE\n0416; C; 0436; # CYRILLIC CAPITAL LETTER ZHE\n0417; C; 0437; # CYRILLIC CAPITAL LETTER ZE\n0418; C; 0438; # CYRILLIC CAPITAL LETTER I\n0419; C; 0439; # CYRILLIC CAPITAL LETTER SHORT I\n041A; C; 043A; # CYRILLIC CAPITAL LETTER KA\n041B; C; 043B; # CYRILLIC CAPITAL LETTER EL\n041C; C; 043C; # CYRILLIC CAPITAL LETTER EM\n041D; C; 043D; # CYRILLIC CAPITAL LETTER EN\n041E; C; 043E; # CYRILLIC CAPITAL LETTER O\n041F; C; 043F; # CYRILLIC CAPITAL LETTER PE\n0420; C; 0440; # CYRILLIC CAPITAL LETTER ER\n0421; C; 0441; # CYRILLIC CAPITAL LETTER ES\n0422; C; 0442; # CYRILLIC CAPITAL LETTER TE\n0423; C; 0443; # CYRILLIC CAPITAL LETTER U\n0424; C; 0444; # CYRILLIC CAPITAL LETTER EF\n0425; C; 0445; # CYRILLIC CAPITAL LETTER HA\n0426; C; 0446; # CYRILLIC CAPITAL LETTER TSE\n0427; C; 0447; # CYRILLIC CAPITAL LETTER CHE\n0428; C; 0448; # CYRILLIC CAPITAL LETTER SHA\n0429; C; 0449; # CYRILLIC CAPITAL LETTER SHCHA\n042A; C; 044A; # CYRILLIC CAPITAL LETTER HARD SIGN\n042B; C; 044B; # CYRILLIC CAPITAL LETTER YERU\n042C; C; 044C; # CYRILLIC CAPITAL LETTER SOFT SIGN\n042D; C; 044D; # CYRILLIC CAPITAL LETTER E\n042E; C; 044E; # CYRILLIC CAPITAL LETTER YU\n042F; C; 044F; # CYRILLIC CAPITAL LETTER YA\n0460; C; 0461; # CYRILLIC CAPITAL LETTER OMEGA\n0462; C; 0463; # CYRILLIC CAPITAL LETTER YAT\n0464; C; 0465; # CYRILLIC CAPITAL LETTER IOTIFIED E\n0466; C; 0467; # CYRILLIC CAPITAL LETTER LITTLE YUS\n0468; C; 0469; # CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS\n046A; C; 046B; # CYRILLIC CAPITAL LETTER BIG YUS\n046C; C; 046D; # CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS\n046E; C; 046F; # CYRILLIC CAPITAL LETTER KSI\n0470; C; 0471; # CYRILLIC CAPITAL LETTER PSI\n0472; C; 0473; # CYRILLIC CAPITAL LETTER FITA\n0474; C; 0475; # CYRILLIC CAPITAL LETTER IZHITSA\n0476; C; 0477; # CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT\n0478; C; 0479; # CYRILLIC CAPITAL LETTER UK\n047A; C; 047B; # CYRILLIC CAPITAL LETTER ROUND OMEGA\n047C; C; 047D; # CYRILLIC CAPITAL LETTER OMEGA WITH TITLO\n047E; C; 047F; # CYRILLIC CAPITAL LETTER OT\n0480; C; 0481; # CYRILLIC CAPITAL LETTER KOPPA\n048A; C; 048B; # CYRILLIC CAPITAL LETTER SHORT I WITH TAIL\n048C; C; 048D; # CYRILLIC CAPITAL LETTER SEMISOFT SIGN\n048E; C; 048F; # CYRILLIC CAPITAL LETTER ER WITH TICK\n0490; C; 0491; # CYRILLIC CAPITAL LETTER GHE WITH UPTURN\n0492; C; 0493; # CYRILLIC CAPITAL LETTER GHE WITH STROKE\n0494; C; 0495; # CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK\n0496; C; 0497; # CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER\n0498; C; 0499; # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER\n049A; C; 049B; # CYRILLIC CAPITAL LETTER KA WITH DESCENDER\n049C; C; 049D; # CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE\n049E; C; 049F; # CYRILLIC CAPITAL LETTER KA WITH STROKE\n04A0; C; 04A1; # CYRILLIC CAPITAL LETTER BASHKIR KA\n04A2; C; 04A3; # CYRILLIC CAPITAL LETTER EN WITH DESCENDER\n04A4; C; 04A5; # CYRILLIC CAPITAL LIGATURE EN GHE\n04A6; C; 04A7; # CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK\n04A8; C; 04A9; # CYRILLIC CAPITAL LETTER ABKHASIAN HA\n04AA; C; 04AB; # CYRILLIC CAPITAL LETTER ES WITH DESCENDER\n04AC; C; 04AD; # CYRILLIC CAPITAL LETTER TE WITH DESCENDER\n04AE; C; 04AF; # CYRILLIC CAPITAL LETTER STRAIGHT U\n04B0; C; 04B1; # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE\n04B2; C; 04B3; # CYRILLIC CAPITAL LETTER HA WITH DESCENDER\n04B4; C; 04B5; # CYRILLIC CAPITAL LIGATURE TE TSE\n04B6; C; 04B7; # CYRILLIC CAPITAL LETTER CHE WITH DESCENDER\n04B8; C; 04B9; # CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE\n04BA; C; 04BB; # CYRILLIC CAPITAL LETTER SHHA\n04BC; C; 04BD; # CYRILLIC CAPITAL LETTER ABKHASIAN CHE\n04BE; C; 04BF; # CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER\n04C0; C; 04CF; # CYRILLIC LETTER PALOCHKA\n04C1; C; 04C2; # CYRILLIC CAPITAL LETTER ZHE WITH BREVE\n04C3; C; 04C4; # CYRILLIC CAPITAL LETTER KA WITH HOOK\n04C5; C; 04C6; # CYRILLIC CAPITAL LETTER EL WITH TAIL\n04C7; C; 04C8; # CYRILLIC CAPITAL LETTER EN WITH HOOK\n04C9; C; 04CA; # CYRILLIC CAPITAL LETTER EN WITH TAIL\n04CB; C; 04CC; # CYRILLIC CAPITAL LETTER KHAKASSIAN CHE\n04CD; C; 04CE; # CYRILLIC CAPITAL LETTER EM WITH TAIL\n04D0; C; 04D1; # CYRILLIC CAPITAL LETTER A WITH BREVE\n04D2; C; 04D3; # CYRILLIC CAPITAL LETTER A WITH DIAERESIS\n04D4; C; 04D5; # CYRILLIC CAPITAL LIGATURE A IE\n04D6; C; 04D7; # CYRILLIC CAPITAL LETTER IE WITH BREVE\n04D8; C; 04D9; # CYRILLIC CAPITAL LETTER SCHWA\n04DA; C; 04DB; # CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS\n04DC; C; 04DD; # CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS\n04DE; C; 04DF; # CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS\n04E0; C; 04E1; # CYRILLIC CAPITAL LETTER ABKHASIAN DZE\n04E2; C; 04E3; # CYRILLIC CAPITAL LETTER I WITH MACRON\n04E4; C; 04E5; # CYRILLIC CAPITAL LETTER I WITH DIAERESIS\n04E6; C; 04E7; # CYRILLIC CAPITAL LETTER O WITH DIAERESIS\n04E8; C; 04E9; # CYRILLIC CAPITAL LETTER BARRED O\n04EA; C; 04EB; # CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS\n04EC; C; 04ED; # CYRILLIC CAPITAL LETTER E WITH DIAERESIS\n04EE; C; 04EF; # CYRILLIC CAPITAL LETTER U WITH MACRON\n04F0; C; 04F1; # CYRILLIC CAPITAL LETTER U WITH DIAERESIS\n04F2; C; 04F3; # CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE\n04F4; C; 04F5; # CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS\n04F6; C; 04F7; # CYRILLIC CAPITAL LETTER GHE WITH DESCENDER\n04F8; C; 04F9; # CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS\n04FA; C; 04FB; # CYRILLIC CAPITAL LETTER GHE WITH STROKE AND HOOK\n04FC; C; 04FD; # CYRILLIC CAPITAL LETTER HA WITH HOOK\n04FE; C; 04FF; # CYRILLIC CAPITAL LETTER HA WITH STROKE\n0500; C; 0501; # CYRILLIC CAPITAL LETTER KOMI DE\n0502; C; 0503; # CYRILLIC CAPITAL LETTER KOMI DJE\n0504; C; 0505; # CYRILLIC CAPITAL LETTER KOMI ZJE\n0506; C; 0507; # CYRILLIC CAPITAL LETTER KOMI DZJE\n0508; C; 0509; # CYRILLIC CAPITAL LETTER KOMI LJE\n050A; C; 050B; # CYRILLIC CAPITAL LETTER KOMI NJE\n050C; C; 050D; # CYRILLIC CAPITAL LETTER KOMI SJE\n050E; C; 050F; # CYRILLIC CAPITAL LETTER KOMI TJE\n0510; C; 0511; # CYRILLIC CAPITAL LETTER REVERSED ZE\n0512; C; 0513; # CYRILLIC CAPITAL LETTER EL WITH HOOK\n0514; C; 0515; # CYRILLIC CAPITAL LETTER LHA\n0516; C; 0517; # CYRILLIC CAPITAL LETTER RHA\n0518; C; 0519; # CYRILLIC CAPITAL LETTER YAE\n051A; C; 051B; # CYRILLIC CAPITAL LETTER QA\n051C; C; 051D; # CYRILLIC CAPITAL LETTER WE\n051E; C; 051F; # CYRILLIC CAPITAL LETTER ALEUT KA\n0520; C; 0521; # CYRILLIC CAPITAL LETTER EL WITH MIDDLE HOOK\n0522; C; 0523; # CYRILLIC CAPITAL LETTER EN WITH MIDDLE HOOK\n0524; C; 0525; # CYRILLIC CAPITAL LETTER PE WITH DESCENDER\n0526; C; 0527; # CYRILLIC CAPITAL LETTER SHHA WITH DESCENDER\n0531; C; 0561; # ARMENIAN CAPITAL LETTER AYB\n0532; C; 0562; # ARMENIAN CAPITAL LETTER BEN\n0533; C; 0563; # ARMENIAN CAPITAL LETTER GIM\n0534; C; 0564; # ARMENIAN CAPITAL LETTER DA\n0535; C; 0565; # ARMENIAN CAPITAL LETTER ECH\n0536; C; 0566; # ARMENIAN CAPITAL LETTER ZA\n0537; C; 0567; # ARMENIAN CAPITAL LETTER EH\n0538; C; 0568; # ARMENIAN CAPITAL LETTER ET\n0539; C; 0569; # ARMENIAN CAPITAL LETTER TO\n053A; C; 056A; # ARMENIAN CAPITAL LETTER ZHE\n053B; C; 056B; # ARMENIAN CAPITAL LETTER INI\n053C; C; 056C; # ARMENIAN CAPITAL LETTER LIWN\n053D; C; 056D; # ARMENIAN CAPITAL LETTER XEH\n053E; C; 056E; # ARMENIAN CAPITAL LETTER CA\n053F; C; 056F; # ARMENIAN CAPITAL LETTER KEN\n0540; C; 0570; # ARMENIAN CAPITAL LETTER HO\n0541; C; 0571; # ARMENIAN CAPITAL LETTER JA\n0542; C; 0572; # ARMENIAN CAPITAL LETTER GHAD\n0543; C; 0573; # ARMENIAN CAPITAL LETTER CHEH\n0544; C; 0574; # ARMENIAN CAPITAL LETTER MEN\n0545; C; 0575; # ARMENIAN CAPITAL LETTER YI\n0546; C; 0576; # ARMENIAN CAPITAL LETTER NOW\n0547; C; 0577; # ARMENIAN CAPITAL LETTER SHA\n0548; C; 0578; # ARMENIAN CAPITAL LETTER VO\n0549; C; 0579; # ARMENIAN CAPITAL LETTER CHA\n054A; C; 057A; # ARMENIAN CAPITAL LETTER PEH\n054B; C; 057B; # ARMENIAN CAPITAL LETTER JHEH\n054C; C; 057C; # ARMENIAN CAPITAL LETTER RA\n054D; C; 057D; # ARMENIAN CAPITAL LETTER SEH\n054E; C; 057E; # ARMENIAN CAPITAL LETTER VEW\n054F; C; 057F; # ARMENIAN CAPITAL LETTER TIWN\n0550; C; 0580; # ARMENIAN CAPITAL LETTER REH\n0551; C; 0581; # ARMENIAN CAPITAL LETTER CO\n0552; C; 0582; # ARMENIAN CAPITAL LETTER YIWN\n0553; C; 0583; # ARMENIAN CAPITAL LETTER PIWR\n0554; C; 0584; # ARMENIAN CAPITAL LETTER KEH\n0555; C; 0585; # ARMENIAN CAPITAL LETTER OH\n0556; C; 0586; # ARMENIAN CAPITAL LETTER FEH\n0587; F; 0565 0582; # ARMENIAN SMALL LIGATURE ECH YIWN\n10A0; C; 2D00; # GEORGIAN CAPITAL LETTER AN\n10A1; C; 2D01; # GEORGIAN CAPITAL LETTER BAN\n10A2; C; 2D02; # GEORGIAN CAPITAL LETTER GAN\n10A3; C; 2D03; # GEORGIAN CAPITAL LETTER DON\n10A4; C; 2D04; # GEORGIAN CAPITAL LETTER EN\n10A5; C; 2D05; # GEORGIAN CAPITAL LETTER VIN\n10A6; C; 2D06; # GEORGIAN CAPITAL LETTER ZEN\n10A7; C; 2D07; # GEORGIAN CAPITAL LETTER TAN\n10A8; C; 2D08; # GEORGIAN CAPITAL LETTER IN\n10A9; C; 2D09; # GEORGIAN CAPITAL LETTER KAN\n10AA; C; 2D0A; # GEORGIAN CAPITAL LETTER LAS\n10AB; C; 2D0B; # GEORGIAN CAPITAL LETTER MAN\n10AC; C; 2D0C; # GEORGIAN CAPITAL LETTER NAR\n10AD; C; 2D0D; # GEORGIAN CAPITAL LETTER ON\n10AE; C; 2D0E; # GEORGIAN CAPITAL LETTER PAR\n10AF; C; 2D0F; # GEORGIAN CAPITAL LETTER ZHAR\n10B0; C; 2D10; # GEORGIAN CAPITAL LETTER RAE\n10B1; C; 2D11; # GEORGIAN CAPITAL LETTER SAN\n10B2; C; 2D12; # GEORGIAN CAPITAL LETTER TAR\n10B3; C; 2D13; # GEORGIAN CAPITAL LETTER UN\n10B4; C; 2D14; # GEORGIAN CAPITAL LETTER PHAR\n10B5; C; 2D15; # GEORGIAN CAPITAL LETTER KHAR\n10B6; C; 2D16; # GEORGIAN CAPITAL LETTER GHAN\n10B7; C; 2D17; # GEORGIAN CAPITAL LETTER QAR\n10B8; C; 2D18; # GEORGIAN CAPITAL LETTER SHIN\n10B9; C; 2D19; # GEORGIAN CAPITAL LETTER CHIN\n10BA; C; 2D1A; # GEORGIAN CAPITAL LETTER CAN\n10BB; C; 2D1B; # GEORGIAN CAPITAL LETTER JIL\n10BC; C; 2D1C; # GEORGIAN CAPITAL LETTER CIL\n10BD; C; 2D1D; # GEORGIAN CAPITAL LETTER CHAR\n10BE; C; 2D1E; # GEORGIAN CAPITAL LETTER XAN\n10BF; C; 2D1F; # GEORGIAN CAPITAL LETTER JHAN\n10C0; C; 2D20; # GEORGIAN CAPITAL LETTER HAE\n10C1; C; 2D21; # GEORGIAN CAPITAL LETTER HE\n10C2; C; 2D22; # GEORGIAN CAPITAL LETTER HIE\n10C3; C; 2D23; # GEORGIAN CAPITAL LETTER WE\n10C4; C; 2D24; # GEORGIAN CAPITAL LETTER HAR\n10C5; C; 2D25; # GEORGIAN CAPITAL LETTER HOE\n10C7; C; 2D27; # GEORGIAN CAPITAL LETTER YN\n10CD; C; 2D2D; # GEORGIAN CAPITAL LETTER AEN\n1E00; C; 1E01; # LATIN CAPITAL LETTER A WITH RING BELOW\n1E02; C; 1E03; # LATIN CAPITAL LETTER B WITH DOT ABOVE\n1E04; C; 1E05; # LATIN CAPITAL LETTER B WITH DOT BELOW\n1E06; C; 1E07; # LATIN CAPITAL LETTER B WITH LINE BELOW\n1E08; C; 1E09; # LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE\n1E0A; C; 1E0B; # LATIN CAPITAL LETTER D WITH DOT ABOVE\n1E0C; C; 1E0D; # LATIN CAPITAL LETTER D WITH DOT BELOW\n1E0E; C; 1E0F; # LATIN CAPITAL LETTER D WITH LINE BELOW\n1E10; C; 1E11; # LATIN CAPITAL LETTER D WITH CEDILLA\n1E12; C; 1E13; # LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW\n1E14; C; 1E15; # LATIN CAPITAL LETTER E WITH MACRON AND GRAVE\n1E16; C; 1E17; # LATIN CAPITAL LETTER E WITH MACRON AND ACUTE\n1E18; C; 1E19; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW\n1E1A; C; 1E1B; # LATIN CAPITAL LETTER E WITH TILDE BELOW\n1E1C; C; 1E1D; # LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE\n1E1E; C; 1E1F; # LATIN CAPITAL LETTER F WITH DOT ABOVE\n1E20; C; 1E21; # LATIN CAPITAL LETTER G WITH MACRON\n1E22; C; 1E23; # LATIN CAPITAL LETTER H WITH DOT ABOVE\n1E24; C; 1E25; # LATIN CAPITAL LETTER H WITH DOT BELOW\n1E26; C; 1E27; # LATIN CAPITAL LETTER H WITH DIAERESIS\n1E28; C; 1E29; # LATIN CAPITAL LETTER H WITH CEDILLA\n1E2A; C; 1E2B; # LATIN CAPITAL LETTER H WITH BREVE BELOW\n1E2C; C; 1E2D; # LATIN CAPITAL LETTER I WITH TILDE BELOW\n1E2E; C; 1E2F; # LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE\n1E30; C; 1E31; # LATIN CAPITAL LETTER K WITH ACUTE\n1E32; C; 1E33; # LATIN CAPITAL LETTER K WITH DOT BELOW\n1E34; C; 1E35; # LATIN CAPITAL LETTER K WITH LINE BELOW\n1E36; C; 1E37; # LATIN CAPITAL LETTER L WITH DOT BELOW\n1E38; C; 1E39; # LATIN CAPITAL LETTER L WITH DOT BELOW AND MACRON\n1E3A; C; 1E3B; # LATIN CAPITAL LETTER L WITH LINE BELOW\n1E3C; C; 1E3D; # LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW\n1E3E; C; 1E3F; # LATIN CAPITAL LETTER M WITH ACUTE\n1E40; C; 1E41; # LATIN CAPITAL LETTER M WITH DOT ABOVE\n1E42; C; 1E43; # LATIN CAPITAL LETTER M WITH DOT BELOW\n1E44; C; 1E45; # LATIN CAPITAL LETTER N WITH DOT ABOVE\n1E46; C; 1E47; # LATIN CAPITAL LETTER N WITH DOT BELOW\n1E48; C; 1E49; # LATIN CAPITAL LETTER N WITH LINE BELOW\n1E4A; C; 1E4B; # LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW\n1E4C; C; 1E4D; # LATIN CAPITAL LETTER O WITH TILDE AND ACUTE\n1E4E; C; 1E4F; # LATIN CAPITAL LETTER O WITH TILDE AND DIAERESIS\n1E50; C; 1E51; # LATIN CAPITAL LETTER O WITH MACRON AND GRAVE\n1E52; C; 1E53; # LATIN CAPITAL LETTER O WITH MACRON AND ACUTE\n1E54; C; 1E55; # LATIN CAPITAL LETTER P WITH ACUTE\n1E56; C; 1E57; # LATIN CAPITAL LETTER P WITH DOT ABOVE\n1E58; C; 1E59; # LATIN CAPITAL LETTER R WITH DOT ABOVE\n1E5A; C; 1E5B; # LATIN CAPITAL LETTER R WITH DOT BELOW\n1E5C; C; 1E5D; # LATIN CAPITAL LETTER R WITH DOT BELOW AND MACRON\n1E5E; C; 1E5F; # LATIN CAPITAL LETTER R WITH LINE BELOW\n1E60; C; 1E61; # LATIN CAPITAL LETTER S WITH DOT ABOVE\n1E62; C; 1E63; # LATIN CAPITAL LETTER S WITH DOT BELOW\n1E64; C; 1E65; # LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE\n1E66; C; 1E67; # LATIN CAPITAL LETTER S WITH CARON AND DOT ABOVE\n1E68; C; 1E69; # LATIN CAPITAL LETTER S WITH DOT BELOW AND DOT ABOVE\n1E6A; C; 1E6B; # LATIN CAPITAL LETTER T WITH DOT ABOVE\n1E6C; C; 1E6D; # LATIN CAPITAL LETTER T WITH DOT BELOW\n1E6E; C; 1E6F; # LATIN CAPITAL LETTER T WITH LINE BELOW\n1E70; C; 1E71; # LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW\n1E72; C; 1E73; # LATIN CAPITAL LETTER U WITH DIAERESIS BELOW\n1E74; C; 1E75; # LATIN CAPITAL LETTER U WITH TILDE BELOW\n1E76; C; 1E77; # LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW\n1E78; C; 1E79; # LATIN CAPITAL LETTER U WITH TILDE AND ACUTE\n1E7A; C; 1E7B; # LATIN CAPITAL LETTER U WITH MACRON AND DIAERESIS\n1E7C; C; 1E7D; # LATIN CAPITAL LETTER V WITH TILDE\n1E7E; C; 1E7F; # LATIN CAPITAL LETTER V WITH DOT BELOW\n1E80; C; 1E81; # LATIN CAPITAL LETTER W WITH GRAVE\n1E82; C; 1E83; # LATIN CAPITAL LETTER W WITH ACUTE\n1E84; C; 1E85; # LATIN CAPITAL LETTER W WITH DIAERESIS\n1E86; C; 1E87; # LATIN CAPITAL LETTER W WITH DOT ABOVE\n1E88; C; 1E89; # LATIN CAPITAL LETTER W WITH DOT BELOW\n1E8A; C; 1E8B; # LATIN CAPITAL LETTER X WITH DOT ABOVE\n1E8C; C; 1E8D; # LATIN CAPITAL LETTER X WITH DIAERESIS\n1E8E; C; 1E8F; # LATIN CAPITAL LETTER Y WITH DOT ABOVE\n1E90; C; 1E91; # LATIN CAPITAL LETTER Z WITH CIRCUMFLEX\n1E92; C; 1E93; # LATIN CAPITAL LETTER Z WITH DOT BELOW\n1E94; C; 1E95; # LATIN CAPITAL LETTER Z WITH LINE BELOW\n1E96; F; 0068 0331; # LATIN SMALL LETTER H WITH LINE BELOW\n1E97; F; 0074 0308; # LATIN SMALL LETTER T WITH DIAERESIS\n1E98; F; 0077 030A; # LATIN SMALL LETTER W WITH RING ABOVE\n1E99; F; 0079 030A; # LATIN SMALL LETTER Y WITH RING ABOVE\n1E9A; F; 0061 02BE; # LATIN SMALL LETTER A WITH RIGHT HALF RING\n1E9B; C; 1E61; # LATIN SMALL LETTER LONG S WITH DOT ABOVE\n1E9E; F; 0073 0073; # LATIN CAPITAL LETTER SHARP S\n1E9E; S; 00DF; # LATIN CAPITAL LETTER SHARP S\n1EA0; C; 1EA1; # LATIN CAPITAL LETTER A WITH DOT BELOW\n1EA2; C; 1EA3; # LATIN CAPITAL LETTER A WITH HOOK ABOVE\n1EA4; C; 1EA5; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE\n1EA6; C; 1EA7; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE\n1EA8; C; 1EA9; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE\n1EAA; C; 1EAB; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE\n1EAC; C; 1EAD; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW\n1EAE; C; 1EAF; # LATIN CAPITAL LETTER A WITH BREVE AND ACUTE\n1EB0; C; 1EB1; # LATIN CAPITAL LETTER A WITH BREVE AND GRAVE\n1EB2; C; 1EB3; # LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE\n1EB4; C; 1EB5; # LATIN CAPITAL LETTER A WITH BREVE AND TILDE\n1EB6; C; 1EB7; # LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW\n1EB8; C; 1EB9; # LATIN CAPITAL LETTER E WITH DOT BELOW\n1EBA; C; 1EBB; # LATIN CAPITAL LETTER E WITH HOOK ABOVE\n1EBC; C; 1EBD; # LATIN CAPITAL LETTER E WITH TILDE\n1EBE; C; 1EBF; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE\n1EC0; C; 1EC1; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE\n1EC2; C; 1EC3; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE\n1EC4; C; 1EC5; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE\n1EC6; C; 1EC7; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW\n1EC8; C; 1EC9; # LATIN CAPITAL LETTER I WITH HOOK ABOVE\n1ECA; C; 1ECB; # LATIN CAPITAL LETTER I WITH DOT BELOW\n1ECC; C; 1ECD; # LATIN CAPITAL LETTER O WITH DOT BELOW\n1ECE; C; 1ECF; # LATIN CAPITAL LETTER O WITH HOOK ABOVE\n1ED0; C; 1ED1; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE\n1ED2; C; 1ED3; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE\n1ED4; C; 1ED5; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE\n1ED6; C; 1ED7; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE\n1ED8; C; 1ED9; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW\n1EDA; C; 1EDB; # LATIN CAPITAL LETTER O WITH HORN AND ACUTE\n1EDC; C; 1EDD; # LATIN CAPITAL LETTER O WITH HORN AND GRAVE\n1EDE; C; 1EDF; # LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE\n1EE0; C; 1EE1; # LATIN CAPITAL LETTER O WITH HORN AND TILDE\n1EE2; C; 1EE3; # LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW\n1EE4; C; 1EE5; # LATIN CAPITAL LETTER U WITH DOT BELOW\n1EE6; C; 1EE7; # LATIN CAPITAL LETTER U WITH HOOK ABOVE\n1EE8; C; 1EE9; # LATIN CAPITAL LETTER U WITH HORN AND ACUTE\n1EEA; C; 1EEB; # LATIN CAPITAL LETTER U WITH HORN AND GRAVE\n1EEC; C; 1EED; # LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE\n1EEE; C; 1EEF; # LATIN CAPITAL LETTER U WITH HORN AND TILDE\n1EF0; C; 1EF1; # LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW\n1EF2; C; 1EF3; # LATIN CAPITAL LETTER Y WITH GRAVE\n1EF4; C; 1EF5; # LATIN CAPITAL LETTER Y WITH DOT BELOW\n1EF6; C; 1EF7; # LATIN CAPITAL LETTER Y WITH HOOK ABOVE\n1EF8; C; 1EF9; # LATIN CAPITAL LETTER Y WITH TILDE\n1EFA; C; 1EFB; # LATIN CAPITAL LETTER MIDDLE-WELSH LL\n1EFC; C; 1EFD; # LATIN CAPITAL LETTER MIDDLE-WELSH V\n1EFE; C; 1EFF; # LATIN CAPITAL LETTER Y WITH LOOP\n1F08; C; 1F00; # GREEK CAPITAL LETTER ALPHA WITH PSILI\n1F09; C; 1F01; # GREEK CAPITAL LETTER ALPHA WITH DASIA\n1F0A; C; 1F02; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA\n1F0B; C; 1F03; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA\n1F0C; C; 1F04; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA\n1F0D; C; 1F05; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA\n1F0E; C; 1F06; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI\n1F0F; C; 1F07; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI\n1F18; C; 1F10; # GREEK CAPITAL LETTER EPSILON WITH PSILI\n1F19; C; 1F11; # GREEK CAPITAL LETTER EPSILON WITH DASIA\n1F1A; C; 1F12; # GREEK CAPITAL LETTER EPSILON WITH PSILI AND VARIA\n1F1B; C; 1F13; # GREEK CAPITAL LETTER EPSILON WITH DASIA AND VARIA\n1F1C; C; 1F14; # GREEK CAPITAL LETTER EPSILON WITH PSILI AND OXIA\n1F1D; C; 1F15; # GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA\n1F28; C; 1F20; # GREEK CAPITAL LETTER ETA WITH PSILI\n1F29; C; 1F21; # GREEK CAPITAL LETTER ETA WITH DASIA\n1F2A; C; 1F22; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA\n1F2B; C; 1F23; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA\n1F2C; C; 1F24; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA\n1F2D; C; 1F25; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA\n1F2E; C; 1F26; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI\n1F2F; C; 1F27; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI\n1F38; C; 1F30; # GREEK CAPITAL LETTER IOTA WITH PSILI\n1F39; C; 1F31; # GREEK CAPITAL LETTER IOTA WITH DASIA\n1F3A; C; 1F32; # GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA\n1F3B; C; 1F33; # GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA\n1F3C; C; 1F34; # GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA\n1F3D; C; 1F35; # GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA\n1F3E; C; 1F36; # GREEK CAPITAL LETTER IOTA WITH PSILI AND PERISPOMENI\n1F3F; C; 1F37; # GREEK CAPITAL LETTER IOTA WITH DASIA AND PERISPOMENI\n1F48; C; 1F40; # GREEK CAPITAL LETTER OMICRON WITH PSILI\n1F49; C; 1F41; # GREEK CAPITAL LETTER OMICRON WITH DASIA\n1F4A; C; 1F42; # GREEK CAPITAL LETTER OMICRON WITH PSILI AND VARIA\n1F4B; C; 1F43; # GREEK CAPITAL LETTER OMICRON WITH DASIA AND VARIA\n1F4C; C; 1F44; # GREEK CAPITAL LETTER OMICRON WITH PSILI AND OXIA\n1F4D; C; 1F45; # GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA\n1F50; F; 03C5 0313; # GREEK SMALL LETTER UPSILON WITH PSILI\n1F52; F; 03C5 0313 0300; # GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA\n1F54; F; 03C5 0313 0301; # GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA\n1F56; F; 03C5 0313 0342; # GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI\n1F59; C; 1F51; # GREEK CAPITAL LETTER UPSILON WITH DASIA\n1F5B; C; 1F53; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA\n1F5D; C; 1F55; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA\n1F5F; C; 1F57; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI\n1F68; C; 1F60; # GREEK CAPITAL LETTER OMEGA WITH PSILI\n1F69; C; 1F61; # GREEK CAPITAL LETTER OMEGA WITH DASIA\n1F6A; C; 1F62; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA\n1F6B; C; 1F63; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA\n1F6C; C; 1F64; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA\n1F6D; C; 1F65; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA\n1F6E; C; 1F66; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI\n1F6F; C; 1F67; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI\n1F80; F; 1F00 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI\n1F81; F; 1F01 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI\n1F82; F; 1F02 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI\n1F83; F; 1F03 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI\n1F84; F; 1F04 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI\n1F85; F; 1F05 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI\n1F86; F; 1F06 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI\n1F87; F; 1F07 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI\n1F88; F; 1F00 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI\n1F88; S; 1F80; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI\n1F89; F; 1F01 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI\n1F89; S; 1F81; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI\n1F8A; F; 1F02 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1F8A; S; 1F82; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1F8B; F; 1F03 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1F8B; S; 1F83; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1F8C; F; 1F04 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1F8C; S; 1F84; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1F8D; F; 1F05 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1F8D; S; 1F85; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1F8E; F; 1F06 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1F8E; S; 1F86; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1F8F; F; 1F07 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1F8F; S; 1F87; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1F90; F; 1F20 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI\n1F91; F; 1F21 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI\n1F92; F; 1F22 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI\n1F93; F; 1F23 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI\n1F94; F; 1F24 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI\n1F95; F; 1F25 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI\n1F96; F; 1F26 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI\n1F97; F; 1F27 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI\n1F98; F; 1F20 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI\n1F98; S; 1F90; # GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI\n1F99; F; 1F21 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI\n1F99; S; 1F91; # GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI\n1F9A; F; 1F22 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1F9A; S; 1F92; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1F9B; F; 1F23 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1F9B; S; 1F93; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1F9C; F; 1F24 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1F9C; S; 1F94; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1F9D; F; 1F25 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1F9D; S; 1F95; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1F9E; F; 1F26 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1F9E; S; 1F96; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1F9F; F; 1F27 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1F9F; S; 1F97; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1FA0; F; 1F60 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI\n1FA1; F; 1F61 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI\n1FA2; F; 1F62 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI\n1FA3; F; 1F63 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI\n1FA4; F; 1F64 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI\n1FA5; F; 1F65 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI\n1FA6; F; 1F66 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI\n1FA7; F; 1F67 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI\n1FA8; F; 1F60 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI\n1FA8; S; 1FA0; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI\n1FA9; F; 1F61 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI\n1FA9; S; 1FA1; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI\n1FAA; F; 1F62 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1FAA; S; 1FA2; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI\n1FAB; F; 1F63 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1FAB; S; 1FA3; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI\n1FAC; F; 1F64 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1FAC; S; 1FA4; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI\n1FAD; F; 1F65 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1FAD; S; 1FA5; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI\n1FAE; F; 1F66 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1FAE; S; 1FA6; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI\n1FAF; F; 1F67 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1FAF; S; 1FA7; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI\n1FB2; F; 1F70 03B9; # GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI\n1FB3; F; 03B1 03B9; # GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI\n1FB4; F; 03AC 03B9; # GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI\n1FB6; F; 03B1 0342; # GREEK SMALL LETTER ALPHA WITH PERISPOMENI\n1FB7; F; 03B1 0342 03B9; # GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI\n1FB8; C; 1FB0; # GREEK CAPITAL LETTER ALPHA WITH VRACHY\n1FB9; C; 1FB1; # GREEK CAPITAL LETTER ALPHA WITH MACRON\n1FBA; C; 1F70; # GREEK CAPITAL LETTER ALPHA WITH VARIA\n1FBB; C; 1F71; # GREEK CAPITAL LETTER ALPHA WITH OXIA\n1FBC; F; 03B1 03B9; # GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI\n1FBC; S; 1FB3; # GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI\n1FBE; C; 03B9; # GREEK PROSGEGRAMMENI\n1FC2; F; 1F74 03B9; # GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI\n1FC3; F; 03B7 03B9; # GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI\n1FC4; F; 03AE 03B9; # GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI\n1FC6; F; 03B7 0342; # GREEK SMALL LETTER ETA WITH PERISPOMENI\n1FC7; F; 03B7 0342 03B9; # GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI\n1FC8; C; 1F72; # GREEK CAPITAL LETTER EPSILON WITH VARIA\n1FC9; C; 1F73; # GREEK CAPITAL LETTER EPSILON WITH OXIA\n1FCA; C; 1F74; # GREEK CAPITAL LETTER ETA WITH VARIA\n1FCB; C; 1F75; # GREEK CAPITAL LETTER ETA WITH OXIA\n1FCC; F; 03B7 03B9; # GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI\n1FCC; S; 1FC3; # GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI\n1FD2; F; 03B9 0308 0300; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA\n1FD3; F; 03B9 0308 0301; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA\n1FD6; F; 03B9 0342; # GREEK SMALL LETTER IOTA WITH PERISPOMENI\n1FD7; F; 03B9 0308 0342; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI\n1FD8; C; 1FD0; # GREEK CAPITAL LETTER IOTA WITH VRACHY\n1FD9; C; 1FD1; # GREEK CAPITAL LETTER IOTA WITH MACRON\n1FDA; C; 1F76; # GREEK CAPITAL LETTER IOTA WITH VARIA\n1FDB; C; 1F77; # GREEK CAPITAL LETTER IOTA WITH OXIA\n1FE2; F; 03C5 0308 0300; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA\n1FE3; F; 03C5 0308 0301; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA\n1FE4; F; 03C1 0313; # GREEK SMALL LETTER RHO WITH PSILI\n1FE6; F; 03C5 0342; # GREEK SMALL LETTER UPSILON WITH PERISPOMENI\n1FE7; F; 03C5 0308 0342; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI\n1FE8; C; 1FE0; # GREEK CAPITAL LETTER UPSILON WITH VRACHY\n1FE9; C; 1FE1; # GREEK CAPITAL LETTER UPSILON WITH MACRON\n1FEA; C; 1F7A; # GREEK CAPITAL LETTER UPSILON WITH VARIA\n1FEB; C; 1F7B; # GREEK CAPITAL LETTER UPSILON WITH OXIA\n1FEC; C; 1FE5; # GREEK CAPITAL LETTER RHO WITH DASIA\n1FF2; F; 1F7C 03B9; # GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI\n1FF3; F; 03C9 03B9; # GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI\n1FF4; F; 03CE 03B9; # GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI\n1FF6; F; 03C9 0342; # GREEK SMALL LETTER OMEGA WITH PERISPOMENI\n1FF7; F; 03C9 0342 03B9; # GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI\n1FF8; C; 1F78; # GREEK CAPITAL LETTER OMICRON WITH VARIA\n1FF9; C; 1F79; # GREEK CAPITAL LETTER OMICRON WITH OXIA\n1FFA; C; 1F7C; # GREEK CAPITAL LETTER OMEGA WITH VARIA\n1FFB; C; 1F7D; # GREEK CAPITAL LETTER OMEGA WITH OXIA\n1FFC; F; 03C9 03B9; # GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI\n1FFC; S; 1FF3; # GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI\n2126; C; 03C9; # OHM SIGN\n212A; C; 006B; # KELVIN SIGN\n212B; C; 00E5; # ANGSTROM SIGN\n2132; C; 214E; # TURNED CAPITAL F\n2160; C; 2170; # ROMAN NUMERAL ONE\n2161; C; 2171; # ROMAN NUMERAL TWO\n2162; C; 2172; # ROMAN NUMERAL THREE\n2163; C; 2173; # ROMAN NUMERAL FOUR\n2164; C; 2174; # ROMAN NUMERAL FIVE\n2165; C; 2175; # ROMAN NUMERAL SIX\n2166; C; 2176; # ROMAN NUMERAL SEVEN\n2167; C; 2177; # ROMAN NUMERAL EIGHT\n2168; C; 2178; # ROMAN NUMERAL NINE\n2169; C; 2179; # ROMAN NUMERAL TEN\n216A; C; 217A; # ROMAN NUMERAL ELEVEN\n216B; C; 217B; # ROMAN NUMERAL TWELVE\n216C; C; 217C; # ROMAN NUMERAL FIFTY\n216D; C; 217D; # ROMAN NUMERAL ONE HUNDRED\n216E; C; 217E; # ROMAN NUMERAL FIVE HUNDRED\n216F; C; 217F; # ROMAN NUMERAL ONE THOUSAND\n2183; C; 2184; # ROMAN NUMERAL REVERSED ONE HUNDRED\n24B6; C; 24D0; # CIRCLED LATIN CAPITAL LETTER A\n24B7; C; 24D1; # CIRCLED LATIN CAPITAL LETTER B\n24B8; C; 24D2; # CIRCLED LATIN CAPITAL LETTER C\n24B9; C; 24D3; # CIRCLED LATIN CAPITAL LETTER D\n24BA; C; 24D4; # CIRCLED LATIN CAPITAL LETTER E\n24BB; C; 24D5; # CIRCLED LATIN CAPITAL LETTER F\n24BC; C; 24D6; # CIRCLED LATIN CAPITAL LETTER G\n24BD; C; 24D7; # CIRCLED LATIN CAPITAL LETTER H\n24BE; C; 24D8; # CIRCLED LATIN CAPITAL LETTER I\n24BF; C; 24D9; # CIRCLED LATIN CAPITAL LETTER J\n24C0; C; 24DA; # CIRCLED LATIN CAPITAL LETTER K\n24C1; C; 24DB; # CIRCLED LATIN CAPITAL LETTER L\n24C2; C; 24DC; # CIRCLED LATIN CAPITAL LETTER M\n24C3; C; 24DD; # CIRCLED LATIN CAPITAL LETTER N\n24C4; C; 24DE; # CIRCLED LATIN CAPITAL LETTER O\n24C5; C; 24DF; # CIRCLED LATIN CAPITAL LETTER P\n24C6; C; 24E0; # CIRCLED LATIN CAPITAL LETTER Q\n24C7; C; 24E1; # CIRCLED LATIN CAPITAL LETTER R\n24C8; C; 24E2; # CIRCLED LATIN CAPITAL LETTER S\n24C9; C; 24E3; # CIRCLED LATIN CAPITAL LETTER T\n24CA; C; 24E4; # CIRCLED LATIN CAPITAL LETTER U\n24CB; C; 24E5; # CIRCLED LATIN CAPITAL LETTER V\n24CC; C; 24E6; # CIRCLED LATIN CAPITAL LETTER W\n24CD; C; 24E7; # CIRCLED LATIN CAPITAL LETTER X\n24CE; C; 24E8; # CIRCLED LATIN CAPITAL LETTER Y\n24CF; C; 24E9; # CIRCLED LATIN CAPITAL LETTER Z\n2C00; C; 2C30; # GLAGOLITIC CAPITAL LETTER AZU\n2C01; C; 2C31; # GLAGOLITIC CAPITAL LETTER BUKY\n2C02; C; 2C32; # GLAGOLITIC CAPITAL LETTER VEDE\n2C03; C; 2C33; # GLAGOLITIC CAPITAL LETTER GLAGOLI\n2C04; C; 2C34; # GLAGOLITIC CAPITAL LETTER DOBRO\n2C05; C; 2C35; # GLAGOLITIC CAPITAL LETTER YESTU\n2C06; C; 2C36; # GLAGOLITIC CAPITAL LETTER ZHIVETE\n2C07; C; 2C37; # GLAGOLITIC CAPITAL LETTER DZELO\n2C08; C; 2C38; # GLAGOLITIC CAPITAL LETTER ZEMLJA\n2C09; C; 2C39; # GLAGOLITIC CAPITAL LETTER IZHE\n2C0A; C; 2C3A; # GLAGOLITIC CAPITAL LETTER INITIAL IZHE\n2C0B; C; 2C3B; # GLAGOLITIC CAPITAL LETTER I\n2C0C; C; 2C3C; # GLAGOLITIC CAPITAL LETTER DJERVI\n2C0D; C; 2C3D; # GLAGOLITIC CAPITAL LETTER KAKO\n2C0E; C; 2C3E; # GLAGOLITIC CAPITAL LETTER LJUDIJE\n2C0F; C; 2C3F; # GLAGOLITIC CAPITAL LETTER MYSLITE\n2C10; C; 2C40; # GLAGOLITIC CAPITAL LETTER NASHI\n2C11; C; 2C41; # GLAGOLITIC CAPITAL LETTER ONU\n2C12; C; 2C42; # GLAGOLITIC CAPITAL LETTER POKOJI\n2C13; C; 2C43; # GLAGOLITIC CAPITAL LETTER RITSI\n2C14; C; 2C44; # GLAGOLITIC CAPITAL LETTER SLOVO\n2C15; C; 2C45; # GLAGOLITIC CAPITAL LETTER TVRIDO\n2C16; C; 2C46; # GLAGOLITIC CAPITAL LETTER UKU\n2C17; C; 2C47; # GLAGOLITIC CAPITAL LETTER FRITU\n2C18; C; 2C48; # GLAGOLITIC CAPITAL LETTER HERU\n2C19; C; 2C49; # GLAGOLITIC CAPITAL LETTER OTU\n2C1A; C; 2C4A; # GLAGOLITIC CAPITAL LETTER PE\n2C1B; C; 2C4B; # GLAGOLITIC CAPITAL LETTER SHTA\n2C1C; C; 2C4C; # GLAGOLITIC CAPITAL LETTER TSI\n2C1D; C; 2C4D; # GLAGOLITIC CAPITAL LETTER CHRIVI\n2C1E; C; 2C4E; # GLAGOLITIC CAPITAL LETTER SHA\n2C1F; C; 2C4F; # GLAGOLITIC CAPITAL LETTER YERU\n2C20; C; 2C50; # GLAGOLITIC CAPITAL LETTER YERI\n2C21; C; 2C51; # GLAGOLITIC CAPITAL LETTER YATI\n2C22; C; 2C52; # GLAGOLITIC CAPITAL LETTER SPIDERY HA\n2C23; C; 2C53; # GLAGOLITIC CAPITAL LETTER YU\n2C24; C; 2C54; # GLAGOLITIC CAPITAL LETTER SMALL YUS\n2C25; C; 2C55; # GLAGOLITIC CAPITAL LETTER SMALL YUS WITH TAIL\n2C26; C; 2C56; # GLAGOLITIC CAPITAL LETTER YO\n2C27; C; 2C57; # GLAGOLITIC CAPITAL LETTER IOTATED SMALL YUS\n2C28; C; 2C58; # GLAGOLITIC CAPITAL LETTER BIG YUS\n2C29; C; 2C59; # GLAGOLITIC CAPITAL LETTER IOTATED BIG YUS\n2C2A; C; 2C5A; # GLAGOLITIC CAPITAL LETTER FITA\n2C2B; C; 2C5B; # GLAGOLITIC CAPITAL LETTER IZHITSA\n2C2C; C; 2C5C; # GLAGOLITIC CAPITAL LETTER SHTAPIC\n2C2D; C; 2C5D; # GLAGOLITIC CAPITAL LETTER TROKUTASTI A\n2C2E; C; 2C5E; # GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE\n2C60; C; 2C61; # LATIN CAPITAL LETTER L WITH DOUBLE BAR\n2C62; C; 026B; # LATIN CAPITAL LETTER L WITH MIDDLE TILDE\n2C63; C; 1D7D; # LATIN CAPITAL LETTER P WITH STROKE\n2C64; C; 027D; # LATIN CAPITAL LETTER R WITH TAIL\n2C67; C; 2C68; # LATIN CAPITAL LETTER H WITH DESCENDER\n2C69; C; 2C6A; # LATIN CAPITAL LETTER K WITH DESCENDER\n2C6B; C; 2C6C; # LATIN CAPITAL LETTER Z WITH DESCENDER\n2C6D; C; 0251; # LATIN CAPITAL LETTER ALPHA\n2C6E; C; 0271; # LATIN CAPITAL LETTER M WITH HOOK\n2C6F; C; 0250; # LATIN CAPITAL LETTER TURNED A\n2C70; C; 0252; # LATIN CAPITAL LETTER TURNED ALPHA\n2C72; C; 2C73; # LATIN CAPITAL LETTER W WITH HOOK\n2C75; C; 2C76; # LATIN CAPITAL LETTER HALF H\n2C7E; C; 023F; # LATIN CAPITAL LETTER S WITH SWASH TAIL\n2C7F; C; 0240; # LATIN CAPITAL LETTER Z WITH SWASH TAIL\n2C80; C; 2C81; # COPTIC CAPITAL LETTER ALFA\n2C82; C; 2C83; # COPTIC CAPITAL LETTER VIDA\n2C84; C; 2C85; # COPTIC CAPITAL LETTER GAMMA\n2C86; C; 2C87; # COPTIC CAPITAL LETTER DALDA\n2C88; C; 2C89; # COPTIC CAPITAL LETTER EIE\n2C8A; C; 2C8B; # COPTIC CAPITAL LETTER SOU\n2C8C; C; 2C8D; # COPTIC CAPITAL LETTER ZATA\n2C8E; C; 2C8F; # COPTIC CAPITAL LETTER HATE\n2C90; C; 2C91; # COPTIC CAPITAL LETTER THETHE\n2C92; C; 2C93; # COPTIC CAPITAL LETTER IAUDA\n2C94; C; 2C95; # COPTIC CAPITAL LETTER KAPA\n2C96; C; 2C97; # COPTIC CAPITAL LETTER LAULA\n2C98; C; 2C99; # COPTIC CAPITAL LETTER MI\n2C9A; C; 2C9B; # COPTIC CAPITAL LETTER NI\n2C9C; C; 2C9D; # COPTIC CAPITAL LETTER KSI\n2C9E; C; 2C9F; # COPTIC CAPITAL LETTER O\n2CA0; C; 2CA1; # COPTIC CAPITAL LETTER PI\n2CA2; C; 2CA3; # COPTIC CAPITAL LETTER RO\n2CA4; C; 2CA5; # COPTIC CAPITAL LETTER SIMA\n2CA6; C; 2CA7; # COPTIC CAPITAL LETTER TAU\n2CA8; C; 2CA9; # COPTIC CAPITAL LETTER UA\n2CAA; C; 2CAB; # COPTIC CAPITAL LETTER FI\n2CAC; C; 2CAD; # COPTIC CAPITAL LETTER KHI\n2CAE; C; 2CAF; # COPTIC CAPITAL LETTER PSI\n2CB0; C; 2CB1; # COPTIC CAPITAL LETTER OOU\n2CB2; C; 2CB3; # COPTIC CAPITAL LETTER DIALECT-P ALEF\n2CB4; C; 2CB5; # COPTIC CAPITAL LETTER OLD COPTIC AIN\n2CB6; C; 2CB7; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE\n2CB8; C; 2CB9; # COPTIC CAPITAL LETTER DIALECT-P KAPA\n2CBA; C; 2CBB; # COPTIC CAPITAL LETTER DIALECT-P NI\n2CBC; C; 2CBD; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI\n2CBE; C; 2CBF; # COPTIC CAPITAL LETTER OLD COPTIC OOU\n2CC0; C; 2CC1; # COPTIC CAPITAL LETTER SAMPI\n2CC2; C; 2CC3; # COPTIC CAPITAL LETTER CROSSED SHEI\n2CC4; C; 2CC5; # COPTIC CAPITAL LETTER OLD COPTIC SHEI\n2CC6; C; 2CC7; # COPTIC CAPITAL LETTER OLD COPTIC ESH\n2CC8; C; 2CC9; # COPTIC CAPITAL LETTER AKHMIMIC KHEI\n2CCA; C; 2CCB; # COPTIC CAPITAL LETTER DIALECT-P HORI\n2CCC; C; 2CCD; # COPTIC CAPITAL LETTER OLD COPTIC HORI\n2CCE; C; 2CCF; # COPTIC CAPITAL LETTER OLD COPTIC HA\n2CD0; C; 2CD1; # COPTIC CAPITAL LETTER L-SHAPED HA\n2CD2; C; 2CD3; # COPTIC CAPITAL LETTER OLD COPTIC HEI\n2CD4; C; 2CD5; # COPTIC CAPITAL LETTER OLD COPTIC HAT\n2CD6; C; 2CD7; # COPTIC CAPITAL LETTER OLD COPTIC GANGIA\n2CD8; C; 2CD9; # COPTIC CAPITAL LETTER OLD COPTIC DJA\n2CDA; C; 2CDB; # COPTIC CAPITAL LETTER OLD COPTIC SHIMA\n2CDC; C; 2CDD; # COPTIC CAPITAL LETTER OLD NUBIAN SHIMA\n2CDE; C; 2CDF; # COPTIC CAPITAL LETTER OLD NUBIAN NGI\n2CE0; C; 2CE1; # COPTIC CAPITAL LETTER OLD NUBIAN NYI\n2CE2; C; 2CE3; # COPTIC CAPITAL LETTER OLD NUBIAN WAU\n2CEB; C; 2CEC; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC SHEI\n2CED; C; 2CEE; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC GANGIA\n2CF2; C; 2CF3; # COPTIC CAPITAL LETTER BOHAIRIC KHEI\nA640; C; A641; # CYRILLIC CAPITAL LETTER ZEMLYA\nA642; C; A643; # CYRILLIC CAPITAL LETTER DZELO\nA644; C; A645; # CYRILLIC CAPITAL LETTER REVERSED DZE\nA646; C; A647; # CYRILLIC CAPITAL LETTER IOTA\nA648; C; A649; # CYRILLIC CAPITAL LETTER DJERV\nA64A; C; A64B; # CYRILLIC CAPITAL LETTER MONOGRAPH UK\nA64C; C; A64D; # CYRILLIC CAPITAL LETTER BROAD OMEGA\nA64E; C; A64F; # CYRILLIC CAPITAL LETTER NEUTRAL YER\nA650; C; A651; # CYRILLIC CAPITAL LETTER YERU WITH BACK YER\nA652; C; A653; # CYRILLIC CAPITAL LETTER IOTIFIED YAT\nA654; C; A655; # CYRILLIC CAPITAL LETTER REVERSED YU\nA656; C; A657; # CYRILLIC CAPITAL LETTER IOTIFIED A\nA658; C; A659; # CYRILLIC CAPITAL LETTER CLOSED LITTLE YUS\nA65A; C; A65B; # CYRILLIC CAPITAL LETTER BLENDED YUS\nA65C; C; A65D; # CYRILLIC CAPITAL LETTER IOTIFIED CLOSED LITTLE YUS\nA65E; C; A65F; # CYRILLIC CAPITAL LETTER YN\nA660; C; A661; # CYRILLIC CAPITAL LETTER REVERSED TSE\nA662; C; A663; # CYRILLIC CAPITAL LETTER SOFT DE\nA664; C; A665; # CYRILLIC CAPITAL LETTER SOFT EL\nA666; C; A667; # CYRILLIC CAPITAL LETTER SOFT EM\nA668; C; A669; # CYRILLIC CAPITAL LETTER MONOCULAR O\nA66A; C; A66B; # CYRILLIC CAPITAL LETTER BINOCULAR O\nA66C; C; A66D; # CYRILLIC CAPITAL LETTER DOUBLE MONOCULAR O\nA680; C; A681; # CYRILLIC CAPITAL LETTER DWE\nA682; C; A683; # CYRILLIC CAPITAL LETTER DZWE\nA684; C; A685; # CYRILLIC CAPITAL LETTER ZHWE\nA686; C; A687; # CYRILLIC CAPITAL LETTER CCHE\nA688; C; A689; # CYRILLIC CAPITAL LETTER DZZE\nA68A; C; A68B; # CYRILLIC CAPITAL LETTER TE WITH MIDDLE HOOK\nA68C; C; A68D; # CYRILLIC CAPITAL LETTER TWE\nA68E; C; A68F; # CYRILLIC CAPITAL LETTER TSWE\nA690; C; A691; # CYRILLIC CAPITAL LETTER TSSE\nA692; C; A693; # CYRILLIC CAPITAL LETTER TCHE\nA694; C; A695; # CYRILLIC CAPITAL LETTER HWE\nA696; C; A697; # CYRILLIC CAPITAL LETTER SHWE\nA722; C; A723; # LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF\nA724; C; A725; # LATIN CAPITAL LETTER EGYPTOLOGICAL AIN\nA726; C; A727; # LATIN CAPITAL LETTER HENG\nA728; C; A729; # LATIN CAPITAL LETTER TZ\nA72A; C; A72B; # LATIN CAPITAL LETTER TRESILLO\nA72C; C; A72D; # LATIN CAPITAL LETTER CUATRILLO\nA72E; C; A72F; # LATIN CAPITAL LETTER CUATRILLO WITH COMMA\nA732; C; A733; # LATIN CAPITAL LETTER AA\nA734; C; A735; # LATIN CAPITAL LETTER AO\nA736; C; A737; # LATIN CAPITAL LETTER AU\nA738; C; A739; # LATIN CAPITAL LETTER AV\nA73A; C; A73B; # LATIN CAPITAL LETTER AV WITH HORIZONTAL BAR\nA73C; C; A73D; # LATIN CAPITAL LETTER AY\nA73E; C; A73F; # LATIN CAPITAL LETTER REVERSED C WITH DOT\nA740; C; A741; # LATIN CAPITAL LETTER K WITH STROKE\nA742; C; A743; # LATIN CAPITAL LETTER K WITH DIAGONAL STROKE\nA744; C; A745; # LATIN CAPITAL LETTER K WITH STROKE AND DIAGONAL STROKE\nA746; C; A747; # LATIN CAPITAL LETTER BROKEN L\nA748; C; A749; # LATIN CAPITAL LETTER L WITH HIGH STROKE\nA74A; C; A74B; # LATIN CAPITAL LETTER O WITH LONG STROKE OVERLAY\nA74C; C; A74D; # LATIN CAPITAL LETTER O WITH LOOP\nA74E; C; A74F; # LATIN CAPITAL LETTER OO\nA750; C; A751; # LATIN CAPITAL LETTER P WITH STROKE THROUGH DESCENDER\nA752; C; A753; # LATIN CAPITAL LETTER P WITH FLOURISH\nA754; C; A755; # LATIN CAPITAL LETTER P WITH SQUIRREL TAIL\nA756; C; A757; # LATIN CAPITAL LETTER Q WITH STROKE THROUGH DESCENDER\nA758; C; A759; # LATIN CAPITAL LETTER Q WITH DIAGONAL STROKE\nA75A; C; A75B; # LATIN CAPITAL LETTER R ROTUNDA\nA75C; C; A75D; # LATIN CAPITAL LETTER RUM ROTUNDA\nA75E; C; A75F; # LATIN CAPITAL LETTER V WITH DIAGONAL STROKE\nA760; C; A761; # LATIN CAPITAL LETTER VY\nA762; C; A763; # LATIN CAPITAL LETTER VISIGOTHIC Z\nA764; C; A765; # LATIN CAPITAL LETTER THORN WITH STROKE\nA766; C; A767; # LATIN CAPITAL LETTER THORN WITH STROKE THROUGH DESCENDER\nA768; C; A769; # LATIN CAPITAL LETTER VEND\nA76A; C; A76B; # LATIN CAPITAL LETTER ET\nA76C; C; A76D; # LATIN CAPITAL LETTER IS\nA76E; C; A76F; # LATIN CAPITAL LETTER CON\nA779; C; A77A; # LATIN CAPITAL LETTER INSULAR D\nA77B; C; A77C; # LATIN CAPITAL LETTER INSULAR F\nA77D; C; 1D79; # LATIN CAPITAL LETTER INSULAR G\nA77E; C; A77F; # LATIN CAPITAL LETTER TURNED INSULAR G\nA780; C; A781; # LATIN CAPITAL LETTER TURNED L\nA782; C; A783; # LATIN CAPITAL LETTER INSULAR R\nA784; C; A785; # LATIN CAPITAL LETTER INSULAR S\nA786; C; A787; # LATIN CAPITAL LETTER INSULAR T\nA78B; C; A78C; # LATIN CAPITAL LETTER SALTILLO\nA78D; C; 0265; # LATIN CAPITAL LETTER TURNED H\nA790; C; A791; # LATIN CAPITAL LETTER N WITH DESCENDER\nA792; C; A793; # LATIN CAPITAL LETTER C WITH BAR\nA7A0; C; A7A1; # LATIN CAPITAL LETTER G WITH OBLIQUE STROKE\nA7A2; C; A7A3; # LATIN CAPITAL LETTER K WITH OBLIQUE STROKE\nA7A4; C; A7A5; # LATIN CAPITAL LETTER N WITH OBLIQUE STROKE\nA7A6; C; A7A7; # LATIN CAPITAL LETTER R WITH OBLIQUE STROKE\nA7A8; C; A7A9; # LATIN CAPITAL LETTER S WITH OBLIQUE STROKE\nA7AA; C; 0266; # LATIN CAPITAL LETTER H WITH HOOK\nFB00; F; 0066 0066; # LATIN SMALL LIGATURE FF\nFB01; F; 0066 0069; # LATIN SMALL LIGATURE FI\nFB02; F; 0066 006C; # LATIN SMALL LIGATURE FL\nFB03; F; 0066 0066 0069; # LATIN SMALL LIGATURE FFI\nFB04; F; 0066 0066 006C; # LATIN SMALL LIGATURE FFL\nFB05; F; 0073 0074; # LATIN SMALL LIGATURE LONG S T\nFB06; F; 0073 0074; # LATIN SMALL LIGATURE ST\nFB13; F; 0574 0576; # ARMENIAN SMALL LIGATURE MEN NOW\nFB14; F; 0574 0565; # ARMENIAN SMALL LIGATURE MEN ECH\nFB15; F; 0574 056B; # ARMENIAN SMALL LIGATURE MEN INI\nFB16; F; 057E 0576; # ARMENIAN SMALL LIGATURE VEW NOW\nFB17; F; 0574 056D; # ARMENIAN SMALL LIGATURE MEN XEH\nFF21; C; FF41; # FULLWIDTH LATIN CAPITAL LETTER A\nFF22; C; FF42; # FULLWIDTH LATIN CAPITAL LETTER B\nFF23; C; FF43; # FULLWIDTH LATIN CAPITAL LETTER C\nFF24; C; FF44; # FULLWIDTH LATIN CAPITAL LETTER D\nFF25; C; FF45; # FULLWIDTH LATIN CAPITAL LETTER E\nFF26; C; FF46; # FULLWIDTH LATIN CAPITAL LETTER F\nFF27; C; FF47; # FULLWIDTH LATIN CAPITAL LETTER G\nFF28; C; FF48; # FULLWIDTH LATIN CAPITAL LETTER H\nFF29; C; FF49; # FULLWIDTH LATIN CAPITAL LETTER I\nFF2A; C; FF4A; # FULLWIDTH LATIN CAPITAL LETTER J\nFF2B; C; FF4B; # FULLWIDTH LATIN CAPITAL LETTER K\nFF2C; C; FF4C; # FULLWIDTH LATIN CAPITAL LETTER L\nFF2D; C; FF4D; # FULLWIDTH LATIN CAPITAL LETTER M\nFF2E; C; FF4E; # FULLWIDTH LATIN CAPITAL LETTER N\nFF2F; C; FF4F; # FULLWIDTH LATIN CAPITAL LETTER O\nFF30; C; FF50; # FULLWIDTH LATIN CAPITAL LETTER P\nFF31; C; FF51; # FULLWIDTH LATIN CAPITAL LETTER Q\nFF32; C; FF52; # FULLWIDTH LATIN CAPITAL LETTER R\nFF33; C; FF53; # FULLWIDTH LATIN CAPITAL LETTER S\nFF34; C; FF54; # FULLWIDTH LATIN CAPITAL LETTER T\nFF35; C; FF55; # FULLWIDTH LATIN CAPITAL LETTER U\nFF36; C; FF56; # FULLWIDTH LATIN CAPITAL LETTER V\nFF37; C; FF57; # FULLWIDTH LATIN CAPITAL LETTER W\nFF38; C; FF58; # FULLWIDTH LATIN CAPITAL LETTER X\nFF39; C; FF59; # FULLWIDTH LATIN CAPITAL LETTER Y\nFF3A; C; FF5A; # FULLWIDTH LATIN CAPITAL LETTER Z\n10400; C; 10428; # DESERET CAPITAL LETTER LONG I\n10401; C; 10429; # DESERET CAPITAL LETTER LONG E\n10402; C; 1042A; # DESERET CAPITAL LETTER LONG A\n10403; C; 1042B; # DESERET CAPITAL LETTER LONG AH\n10404; C; 1042C; # DESERET CAPITAL LETTER LONG O\n10405; C; 1042D; # DESERET CAPITAL LETTER LONG OO\n10406; C; 1042E; # DESERET CAPITAL LETTER SHORT I\n10407; C; 1042F; # DESERET CAPITAL LETTER SHORT E\n10408; C; 10430; # DESERET CAPITAL LETTER SHORT A\n10409; C; 10431; # DESERET CAPITAL LETTER SHORT AH\n1040A; C; 10432; # DESERET CAPITAL LETTER SHORT O\n1040B; C; 10433; # DESERET CAPITAL LETTER SHORT OO\n1040C; C; 10434; # DESERET CAPITAL LETTER AY\n1040D; C; 10435; # DESERET CAPITAL LETTER OW\n1040E; C; 10436; # DESERET CAPITAL LETTER WU\n1040F; C; 10437; # DESERET CAPITAL LETTER YEE\n10410; C; 10438; # DESERET CAPITAL LETTER H\n10411; C; 10439; # DESERET CAPITAL LETTER PEE\n10412; C; 1043A; # DESERET CAPITAL LETTER BEE\n10413; C; 1043B; # DESERET CAPITAL LETTER TEE\n10414; C; 1043C; # DESERET CAPITAL LETTER DEE\n10415; C; 1043D; # DESERET CAPITAL LETTER CHEE\n10416; C; 1043E; # DESERET CAPITAL LETTER JEE\n10417; C; 1043F; # DESERET CAPITAL LETTER KAY\n10418; C; 10440; # DESERET CAPITAL LETTER GAY\n10419; C; 10441; # DESERET CAPITAL LETTER EF\n1041A; C; 10442; # DESERET CAPITAL LETTER VEE\n1041B; C; 10443; # DESERET CAPITAL LETTER ETH\n1041C; C; 10444; # DESERET CAPITAL LETTER THEE\n1041D; C; 10445; # DESERET CAPITAL LETTER ES\n1041E; C; 10446; # DESERET CAPITAL LETTER ZEE\n1041F; C; 10447; # DESERET CAPITAL LETTER ESH\n10420; C; 10448; # DESERET CAPITAL LETTER ZHEE\n10421; C; 10449; # DESERET CAPITAL LETTER ER\n10422; C; 1044A; # DESERET CAPITAL LETTER EL\n10423; C; 1044B; # DESERET CAPITAL LETTER EM\n10424; C; 1044C; # DESERET CAPITAL LETTER EN\n10425; C; 1044D; # DESERET CAPITAL LETTER ENG\n10426; C; 1044E; # DESERET CAPITAL LETTER OI\n10427; C; 1044F; # DESERET CAPITAL LETTER EW\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/unicode/UnicodeData.txt",
    "content": "0000;<control>;Cc;0;BN;;;;;N;NULL;;;;\n0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;;\n0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;;\n0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;;\n0004;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSION;;;;\n0005;<control>;Cc;0;BN;;;;;N;ENQUIRY;;;;\n0006;<control>;Cc;0;BN;;;;;N;ACKNOWLEDGE;;;;\n0007;<control>;Cc;0;BN;;;;;N;BELL;;;;\n0008;<control>;Cc;0;BN;;;;;N;BACKSPACE;;;;\n0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULATION;;;;\n000A;<control>;Cc;0;B;;;;;N;LINE FEED (LF);;;;\n000B;<control>;Cc;0;S;;;;;N;LINE TABULATION;;;;\n000C;<control>;Cc;0;WS;;;;;N;FORM FEED (FF);;;;\n000D;<control>;Cc;0;B;;;;;N;CARRIAGE RETURN (CR);;;;\n000E;<control>;Cc;0;BN;;;;;N;SHIFT OUT;;;;\n000F;<control>;Cc;0;BN;;;;;N;SHIFT IN;;;;\n0010;<control>;Cc;0;BN;;;;;N;DATA LINK ESCAPE;;;;\n0011;<control>;Cc;0;BN;;;;;N;DEVICE CONTROL ONE;;;;\n0012;<control>;Cc;0;BN;;;;;N;DEVICE CONTROL TWO;;;;\n0013;<control>;Cc;0;BN;;;;;N;DEVICE CONTROL THREE;;;;\n0014;<control>;Cc;0;BN;;;;;N;DEVICE CONTROL FOUR;;;;\n0015;<control>;Cc;0;BN;;;;;N;NEGATIVE ACKNOWLEDGE;;;;\n0016;<control>;Cc;0;BN;;;;;N;SYNCHRONOUS IDLE;;;;\n0017;<control>;Cc;0;BN;;;;;N;END OF TRANSMISSION BLOCK;;;;\n0018;<control>;Cc;0;BN;;;;;N;CANCEL;;;;\n0019;<control>;Cc;0;BN;;;;;N;END OF MEDIUM;;;;\n001A;<control>;Cc;0;BN;;;;;N;SUBSTITUTE;;;;\n001B;<control>;Cc;0;BN;;;;;N;ESCAPE;;;;\n001C;<control>;Cc;0;B;;;;;N;INFORMATION SEPARATOR FOUR;;;;\n001D;<control>;Cc;0;B;;;;;N;INFORMATION SEPARATOR THREE;;;;\n001E;<control>;Cc;0;B;;;;;N;INFORMATION SEPARATOR TWO;;;;\n001F;<control>;Cc;0;S;;;;;N;INFORMATION SEPARATOR ONE;;;;\n0020;SPACE;Zs;0;WS;;;;;N;;;;;\n0021;EXCLAMATION MARK;Po;0;ON;;;;;N;;;;;\n0022;QUOTATION MARK;Po;0;ON;;;;;N;;;;;\n0023;NUMBER SIGN;Po;0;ET;;;;;N;;;;;\n0024;DOLLAR SIGN;Sc;0;ET;;;;;N;;;;;\n0025;PERCENT SIGN;Po;0;ET;;;;;N;;;;;\n0026;AMPERSAND;Po;0;ON;;;;;N;;;;;\n0027;APOSTROPHE;Po;0;ON;;;;;N;APOSTROPHE-QUOTE;;;;\n0028;LEFT PARENTHESIS;Ps;0;ON;;;;;Y;OPENING PARENTHESIS;;;;\n0029;RIGHT PARENTHESIS;Pe;0;ON;;;;;Y;CLOSING PARENTHESIS;;;;\n002A;ASTERISK;Po;0;ON;;;;;N;;;;;\n002B;PLUS SIGN;Sm;0;ES;;;;;N;;;;;\n002C;COMMA;Po;0;CS;;;;;N;;;;;\n002D;HYPHEN-MINUS;Pd;0;ES;;;;;N;;;;;\n002E;FULL STOP;Po;0;CS;;;;;N;PERIOD;;;;\n002F;SOLIDUS;Po;0;CS;;;;;N;SLASH;;;;\n0030;DIGIT ZERO;Nd;0;EN;;0;0;0;N;;;;;\n0031;DIGIT ONE;Nd;0;EN;;1;1;1;N;;;;;\n0032;DIGIT TWO;Nd;0;EN;;2;2;2;N;;;;;\n0033;DIGIT THREE;Nd;0;EN;;3;3;3;N;;;;;\n0034;DIGIT FOUR;Nd;0;EN;;4;4;4;N;;;;;\n0035;DIGIT FIVE;Nd;0;EN;;5;5;5;N;;;;;\n0036;DIGIT SIX;Nd;0;EN;;6;6;6;N;;;;;\n0037;DIGIT SEVEN;Nd;0;EN;;7;7;7;N;;;;;\n0038;DIGIT EIGHT;Nd;0;EN;;8;8;8;N;;;;;\n0039;DIGIT NINE;Nd;0;EN;;9;9;9;N;;;;;\n003A;COLON;Po;0;CS;;;;;N;;;;;\n003B;SEMICOLON;Po;0;ON;;;;;N;;;;;\n003C;LESS-THAN SIGN;Sm;0;ON;;;;;Y;;;;;\n003D;EQUALS SIGN;Sm;0;ON;;;;;N;;;;;\n003E;GREATER-THAN SIGN;Sm;0;ON;;;;;Y;;;;;\n003F;QUESTION MARK;Po;0;ON;;;;;N;;;;;\n0040;COMMERCIAL AT;Po;0;ON;;;;;N;;;;;\n0041;LATIN CAPITAL LETTER A;Lu;0;L;;;;;N;;;;0061;\n0042;LATIN CAPITAL LETTER B;Lu;0;L;;;;;N;;;;0062;\n0043;LATIN CAPITAL LETTER C;Lu;0;L;;;;;N;;;;0063;\n0044;LATIN CAPITAL LETTER D;Lu;0;L;;;;;N;;;;0064;\n0045;LATIN CAPITAL LETTER E;Lu;0;L;;;;;N;;;;0065;\n0046;LATIN CAPITAL LETTER F;Lu;0;L;;;;;N;;;;0066;\n0047;LATIN CAPITAL LETTER G;Lu;0;L;;;;;N;;;;0067;\n0048;LATIN CAPITAL LETTER H;Lu;0;L;;;;;N;;;;0068;\n0049;LATIN CAPITAL LETTER I;Lu;0;L;;;;;N;;;;0069;\n004A;LATIN CAPITAL LETTER J;Lu;0;L;;;;;N;;;;006A;\n004B;LATIN CAPITAL LETTER K;Lu;0;L;;;;;N;;;;006B;\n004C;LATIN CAPITAL LETTER L;Lu;0;L;;;;;N;;;;006C;\n004D;LATIN CAPITAL LETTER M;Lu;0;L;;;;;N;;;;006D;\n004E;LATIN CAPITAL LETTER N;Lu;0;L;;;;;N;;;;006E;\n004F;LATIN CAPITAL LETTER O;Lu;0;L;;;;;N;;;;006F;\n0050;LATIN CAPITAL LETTER P;Lu;0;L;;;;;N;;;;0070;\n0051;LATIN CAPITAL LETTER Q;Lu;0;L;;;;;N;;;;0071;\n0052;LATIN CAPITAL LETTER R;Lu;0;L;;;;;N;;;;0072;\n0053;LATIN CAPITAL LETTER S;Lu;0;L;;;;;N;;;;0073;\n0054;LATIN CAPITAL LETTER T;Lu;0;L;;;;;N;;;;0074;\n0055;LATIN CAPITAL LETTER U;Lu;0;L;;;;;N;;;;0075;\n0056;LATIN CAPITAL LETTER V;Lu;0;L;;;;;N;;;;0076;\n0057;LATIN CAPITAL LETTER W;Lu;0;L;;;;;N;;;;0077;\n0058;LATIN CAPITAL LETTER X;Lu;0;L;;;;;N;;;;0078;\n0059;LATIN CAPITAL LETTER Y;Lu;0;L;;;;;N;;;;0079;\n005A;LATIN CAPITAL LETTER Z;Lu;0;L;;;;;N;;;;007A;\n005B;LEFT SQUARE BRACKET;Ps;0;ON;;;;;Y;OPENING SQUARE BRACKET;;;;\n005C;REVERSE SOLIDUS;Po;0;ON;;;;;N;BACKSLASH;;;;\n005D;RIGHT SQUARE BRACKET;Pe;0;ON;;;;;Y;CLOSING SQUARE BRACKET;;;;\n005E;CIRCUMFLEX ACCENT;Sk;0;ON;;;;;N;SPACING CIRCUMFLEX;;;;\n005F;LOW LINE;Pc;0;ON;;;;;N;SPACING UNDERSCORE;;;;\n0060;GRAVE ACCENT;Sk;0;ON;;;;;N;SPACING GRAVE;;;;\n0061;LATIN SMALL LETTER A;Ll;0;L;;;;;N;;;0041;;0041\n0062;LATIN SMALL LETTER B;Ll;0;L;;;;;N;;;0042;;0042\n0063;LATIN SMALL LETTER C;Ll;0;L;;;;;N;;;0043;;0043\n0064;LATIN SMALL LETTER D;Ll;0;L;;;;;N;;;0044;;0044\n0065;LATIN SMALL LETTER E;Ll;0;L;;;;;N;;;0045;;0045\n0066;LATIN SMALL LETTER F;Ll;0;L;;;;;N;;;0046;;0046\n0067;LATIN SMALL LETTER G;Ll;0;L;;;;;N;;;0047;;0047\n0068;LATIN SMALL LETTER H;Ll;0;L;;;;;N;;;0048;;0048\n0069;LATIN SMALL LETTER I;Ll;0;L;;;;;N;;;0049;;0049\n006A;LATIN SMALL LETTER J;Ll;0;L;;;;;N;;;004A;;004A\n006B;LATIN SMALL LETTER K;Ll;0;L;;;;;N;;;004B;;004B\n006C;LATIN SMALL LETTER L;Ll;0;L;;;;;N;;;004C;;004C\n006D;LATIN SMALL LETTER M;Ll;0;L;;;;;N;;;004D;;004D\n006E;LATIN SMALL LETTER N;Ll;0;L;;;;;N;;;004E;;004E\n006F;LATIN SMALL LETTER O;Ll;0;L;;;;;N;;;004F;;004F\n0070;LATIN SMALL LETTER P;Ll;0;L;;;;;N;;;0050;;0050\n0071;LATIN SMALL LETTER Q;Ll;0;L;;;;;N;;;0051;;0051\n0072;LATIN SMALL LETTER R;Ll;0;L;;;;;N;;;0052;;0052\n0073;LATIN SMALL LETTER S;Ll;0;L;;;;;N;;;0053;;0053\n0074;LATIN SMALL LETTER T;Ll;0;L;;;;;N;;;0054;;0054\n0075;LATIN SMALL LETTER U;Ll;0;L;;;;;N;;;0055;;0055\n0076;LATIN SMALL LETTER V;Ll;0;L;;;;;N;;;0056;;0056\n0077;LATIN SMALL LETTER W;Ll;0;L;;;;;N;;;0057;;0057\n0078;LATIN SMALL LETTER X;Ll;0;L;;;;;N;;;0058;;0058\n0079;LATIN SMALL LETTER Y;Ll;0;L;;;;;N;;;0059;;0059\n007A;LATIN SMALL LETTER Z;Ll;0;L;;;;;N;;;005A;;005A\n007B;LEFT CURLY BRACKET;Ps;0;ON;;;;;Y;OPENING CURLY BRACKET;;;;\n007C;VERTICAL LINE;Sm;0;ON;;;;;N;VERTICAL BAR;;;;\n007D;RIGHT CURLY BRACKET;Pe;0;ON;;;;;Y;CLOSING CURLY BRACKET;;;;\n007E;TILDE;Sm;0;ON;;;;;N;;;;;\n007F;<control>;Cc;0;BN;;;;;N;DELETE;;;;\n0080;<control>;Cc;0;BN;;;;;N;;;;;\n0081;<control>;Cc;0;BN;;;;;N;;;;;\n0082;<control>;Cc;0;BN;;;;;N;BREAK PERMITTED HERE;;;;\n0083;<control>;Cc;0;BN;;;;;N;NO BREAK HERE;;;;\n0084;<control>;Cc;0;BN;;;;;N;;;;;\n0085;<control>;Cc;0;B;;;;;N;NEXT LINE (NEL);;;;\n0086;<control>;Cc;0;BN;;;;;N;START OF SELECTED AREA;;;;\n0087;<control>;Cc;0;BN;;;;;N;END OF SELECTED AREA;;;;\n0088;<control>;Cc;0;BN;;;;;N;CHARACTER TABULATION SET;;;;\n0089;<control>;Cc;0;BN;;;;;N;CHARACTER TABULATION WITH JUSTIFICATION;;;;\n008A;<control>;Cc;0;BN;;;;;N;LINE TABULATION SET;;;;\n008B;<control>;Cc;0;BN;;;;;N;PARTIAL LINE FORWARD;;;;\n008C;<control>;Cc;0;BN;;;;;N;PARTIAL LINE BACKWARD;;;;\n008D;<control>;Cc;0;BN;;;;;N;REVERSE LINE FEED;;;;\n008E;<control>;Cc;0;BN;;;;;N;SINGLE SHIFT TWO;;;;\n008F;<control>;Cc;0;BN;;;;;N;SINGLE SHIFT THREE;;;;\n0090;<control>;Cc;0;BN;;;;;N;DEVICE CONTROL STRING;;;;\n0091;<control>;Cc;0;BN;;;;;N;PRIVATE USE ONE;;;;\n0092;<control>;Cc;0;BN;;;;;N;PRIVATE USE TWO;;;;\n0093;<control>;Cc;0;BN;;;;;N;SET TRANSMIT STATE;;;;\n0094;<control>;Cc;0;BN;;;;;N;CANCEL CHARACTER;;;;\n0095;<control>;Cc;0;BN;;;;;N;MESSAGE WAITING;;;;\n0096;<control>;Cc;0;BN;;;;;N;START OF GUARDED AREA;;;;\n0097;<control>;Cc;0;BN;;;;;N;END OF GUARDED AREA;;;;\n0098;<control>;Cc;0;BN;;;;;N;START OF STRING;;;;\n0099;<control>;Cc;0;BN;;;;;N;;;;;\n009A;<control>;Cc;0;BN;;;;;N;SINGLE CHARACTER INTRODUCER;;;;\n009B;<control>;Cc;0;BN;;;;;N;CONTROL SEQUENCE INTRODUCER;;;;\n009C;<control>;Cc;0;BN;;;;;N;STRING TERMINATOR;;;;\n009D;<control>;Cc;0;BN;;;;;N;OPERATING SYSTEM COMMAND;;;;\n009E;<control>;Cc;0;BN;;;;;N;PRIVACY MESSAGE;;;;\n009F;<control>;Cc;0;BN;;;;;N;APPLICATION PROGRAM COMMAND;;;;\n00A0;NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;NON-BREAKING SPACE;;;;\n00A1;INVERTED EXCLAMATION MARK;Po;0;ON;;;;;N;;;;;\n00A2;CENT SIGN;Sc;0;ET;;;;;N;;;;;\n00A3;POUND SIGN;Sc;0;ET;;;;;N;;;;;\n00A4;CURRENCY SIGN;Sc;0;ET;;;;;N;;;;;\n00A5;YEN SIGN;Sc;0;ET;;;;;N;;;;;\n00A6;BROKEN BAR;So;0;ON;;;;;N;BROKEN VERTICAL BAR;;;;\n00A7;SECTION SIGN;Po;0;ON;;;;;N;;;;;\n00A8;DIAERESIS;Sk;0;ON;<compat> 0020 0308;;;;N;SPACING DIAERESIS;;;;\n00A9;COPYRIGHT SIGN;So;0;ON;;;;;N;;;;;\n00AA;FEMININE ORDINAL INDICATOR;Lo;0;L;<super> 0061;;;;N;;;;;\n00AB;LEFT-POINTING DOUBLE ANGLE QUOTATION MARK;Pi;0;ON;;;;;Y;LEFT POINTING GUILLEMET;;;;\n00AC;NOT SIGN;Sm;0;ON;;;;;N;;;;;\n00AD;SOFT HYPHEN;Cf;0;BN;;;;;N;;;;;\n00AE;REGISTERED SIGN;So;0;ON;;;;;N;REGISTERED TRADE MARK SIGN;;;;\n00AF;MACRON;Sk;0;ON;<compat> 0020 0304;;;;N;SPACING MACRON;;;;\n00B0;DEGREE SIGN;So;0;ET;;;;;N;;;;;\n00B1;PLUS-MINUS SIGN;Sm;0;ET;;;;;N;PLUS-OR-MINUS SIGN;;;;\n00B2;SUPERSCRIPT TWO;No;0;EN;<super> 0032;;2;2;N;SUPERSCRIPT DIGIT TWO;;;;\n00B3;SUPERSCRIPT THREE;No;0;EN;<super> 0033;;3;3;N;SUPERSCRIPT DIGIT THREE;;;;\n00B4;ACUTE ACCENT;Sk;0;ON;<compat> 0020 0301;;;;N;SPACING ACUTE;;;;\n00B5;MICRO SIGN;Ll;0;L;<compat> 03BC;;;;N;;;039C;;039C\n00B6;PILCROW SIGN;Po;0;ON;;;;;N;PARAGRAPH SIGN;;;;\n00B7;MIDDLE DOT;Po;0;ON;;;;;N;;;;;\n00B8;CEDILLA;Sk;0;ON;<compat> 0020 0327;;;;N;SPACING CEDILLA;;;;\n00B9;SUPERSCRIPT ONE;No;0;EN;<super> 0031;;1;1;N;SUPERSCRIPT DIGIT ONE;;;;\n00BA;MASCULINE ORDINAL INDICATOR;Lo;0;L;<super> 006F;;;;N;;;;;\n00BB;RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK;Pf;0;ON;;;;;Y;RIGHT POINTING GUILLEMET;;;;\n00BC;VULGAR FRACTION ONE QUARTER;No;0;ON;<fraction> 0031 2044 0034;;;1/4;N;FRACTION ONE QUARTER;;;;\n00BD;VULGAR FRACTION ONE HALF;No;0;ON;<fraction> 0031 2044 0032;;;1/2;N;FRACTION ONE HALF;;;;\n00BE;VULGAR FRACTION THREE QUARTERS;No;0;ON;<fraction> 0033 2044 0034;;;3/4;N;FRACTION THREE QUARTERS;;;;\n00BF;INVERTED QUESTION MARK;Po;0;ON;;;;;N;;;;;\n00C0;LATIN CAPITAL LETTER A WITH GRAVE;Lu;0;L;0041 0300;;;;N;LATIN CAPITAL LETTER A GRAVE;;;00E0;\n00C1;LATIN CAPITAL LETTER A WITH ACUTE;Lu;0;L;0041 0301;;;;N;LATIN CAPITAL LETTER A ACUTE;;;00E1;\n00C2;LATIN CAPITAL LETTER A WITH CIRCUMFLEX;Lu;0;L;0041 0302;;;;N;LATIN CAPITAL LETTER A CIRCUMFLEX;;;00E2;\n00C3;LATIN CAPITAL LETTER A WITH TILDE;Lu;0;L;0041 0303;;;;N;LATIN CAPITAL LETTER A TILDE;;;00E3;\n00C4;LATIN CAPITAL LETTER A WITH DIAERESIS;Lu;0;L;0041 0308;;;;N;LATIN CAPITAL LETTER A DIAERESIS;;;00E4;\n00C5;LATIN CAPITAL LETTER A WITH RING ABOVE;Lu;0;L;0041 030A;;;;N;LATIN CAPITAL LETTER A RING;;;00E5;\n00C6;LATIN CAPITAL LETTER AE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER A E;;;00E6;\n00C7;LATIN CAPITAL LETTER C WITH CEDILLA;Lu;0;L;0043 0327;;;;N;LATIN CAPITAL LETTER C CEDILLA;;;00E7;\n00C8;LATIN CAPITAL LETTER E WITH GRAVE;Lu;0;L;0045 0300;;;;N;LATIN CAPITAL LETTER E GRAVE;;;00E8;\n00C9;LATIN CAPITAL LETTER E WITH ACUTE;Lu;0;L;0045 0301;;;;N;LATIN CAPITAL LETTER E ACUTE;;;00E9;\n00CA;LATIN CAPITAL LETTER E WITH CIRCUMFLEX;Lu;0;L;0045 0302;;;;N;LATIN CAPITAL LETTER E CIRCUMFLEX;;;00EA;\n00CB;LATIN CAPITAL LETTER E WITH DIAERESIS;Lu;0;L;0045 0308;;;;N;LATIN CAPITAL LETTER E DIAERESIS;;;00EB;\n00CC;LATIN CAPITAL LETTER I WITH GRAVE;Lu;0;L;0049 0300;;;;N;LATIN CAPITAL LETTER I GRAVE;;;00EC;\n00CD;LATIN CAPITAL LETTER I WITH ACUTE;Lu;0;L;0049 0301;;;;N;LATIN CAPITAL LETTER I ACUTE;;;00ED;\n00CE;LATIN CAPITAL LETTER I WITH CIRCUMFLEX;Lu;0;L;0049 0302;;;;N;LATIN CAPITAL LETTER I CIRCUMFLEX;;;00EE;\n00CF;LATIN CAPITAL LETTER I WITH DIAERESIS;Lu;0;L;0049 0308;;;;N;LATIN CAPITAL LETTER I DIAERESIS;;;00EF;\n00D0;LATIN CAPITAL LETTER ETH;Lu;0;L;;;;;N;;;;00F0;\n00D1;LATIN CAPITAL LETTER N WITH TILDE;Lu;0;L;004E 0303;;;;N;LATIN CAPITAL LETTER N TILDE;;;00F1;\n00D2;LATIN CAPITAL LETTER O WITH GRAVE;Lu;0;L;004F 0300;;;;N;LATIN CAPITAL LETTER O GRAVE;;;00F2;\n00D3;LATIN CAPITAL LETTER O WITH ACUTE;Lu;0;L;004F 0301;;;;N;LATIN CAPITAL LETTER O ACUTE;;;00F3;\n00D4;LATIN CAPITAL LETTER O WITH CIRCUMFLEX;Lu;0;L;004F 0302;;;;N;LATIN CAPITAL LETTER O CIRCUMFLEX;;;00F4;\n00D5;LATIN CAPITAL LETTER O WITH TILDE;Lu;0;L;004F 0303;;;;N;LATIN CAPITAL LETTER O TILDE;;;00F5;\n00D6;LATIN CAPITAL LETTER O WITH DIAERESIS;Lu;0;L;004F 0308;;;;N;LATIN CAPITAL LETTER O DIAERESIS;;;00F6;\n00D7;MULTIPLICATION SIGN;Sm;0;ON;;;;;N;;;;;\n00D8;LATIN CAPITAL LETTER O WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER O SLASH;;;00F8;\n00D9;LATIN CAPITAL LETTER U WITH GRAVE;Lu;0;L;0055 0300;;;;N;LATIN CAPITAL LETTER U GRAVE;;;00F9;\n00DA;LATIN CAPITAL LETTER U WITH ACUTE;Lu;0;L;0055 0301;;;;N;LATIN CAPITAL LETTER U ACUTE;;;00FA;\n00DB;LATIN CAPITAL LETTER U WITH CIRCUMFLEX;Lu;0;L;0055 0302;;;;N;LATIN CAPITAL LETTER U CIRCUMFLEX;;;00FB;\n00DC;LATIN CAPITAL LETTER U WITH DIAERESIS;Lu;0;L;0055 0308;;;;N;LATIN CAPITAL LETTER U DIAERESIS;;;00FC;\n00DD;LATIN CAPITAL LETTER Y WITH ACUTE;Lu;0;L;0059 0301;;;;N;LATIN CAPITAL LETTER Y ACUTE;;;00FD;\n00DE;LATIN CAPITAL LETTER THORN;Lu;0;L;;;;;N;;;;00FE;\n00DF;LATIN SMALL LETTER SHARP S;Ll;0;L;;;;;N;;;;;\n00E0;LATIN SMALL LETTER A WITH GRAVE;Ll;0;L;0061 0300;;;;N;LATIN SMALL LETTER A GRAVE;;00C0;;00C0\n00E1;LATIN SMALL LETTER A WITH ACUTE;Ll;0;L;0061 0301;;;;N;LATIN SMALL LETTER A ACUTE;;00C1;;00C1\n00E2;LATIN SMALL LETTER A WITH CIRCUMFLEX;Ll;0;L;0061 0302;;;;N;LATIN SMALL LETTER A CIRCUMFLEX;;00C2;;00C2\n00E3;LATIN SMALL LETTER A WITH TILDE;Ll;0;L;0061 0303;;;;N;LATIN SMALL LETTER A TILDE;;00C3;;00C3\n00E4;LATIN SMALL LETTER A WITH DIAERESIS;Ll;0;L;0061 0308;;;;N;LATIN SMALL LETTER A DIAERESIS;;00C4;;00C4\n00E5;LATIN SMALL LETTER A WITH RING ABOVE;Ll;0;L;0061 030A;;;;N;LATIN SMALL LETTER A RING;;00C5;;00C5\n00E6;LATIN SMALL LETTER AE;Ll;0;L;;;;;N;LATIN SMALL LETTER A E;;00C6;;00C6\n00E7;LATIN SMALL LETTER C WITH CEDILLA;Ll;0;L;0063 0327;;;;N;LATIN SMALL LETTER C CEDILLA;;00C7;;00C7\n00E8;LATIN SMALL LETTER E WITH GRAVE;Ll;0;L;0065 0300;;;;N;LATIN SMALL LETTER E GRAVE;;00C8;;00C8\n00E9;LATIN SMALL LETTER E WITH ACUTE;Ll;0;L;0065 0301;;;;N;LATIN SMALL LETTER E ACUTE;;00C9;;00C9\n00EA;LATIN SMALL LETTER E WITH CIRCUMFLEX;Ll;0;L;0065 0302;;;;N;LATIN SMALL LETTER E CIRCUMFLEX;;00CA;;00CA\n00EB;LATIN SMALL LETTER E WITH DIAERESIS;Ll;0;L;0065 0308;;;;N;LATIN SMALL LETTER E DIAERESIS;;00CB;;00CB\n00EC;LATIN SMALL LETTER I WITH GRAVE;Ll;0;L;0069 0300;;;;N;LATIN SMALL LETTER I GRAVE;;00CC;;00CC\n00ED;LATIN SMALL LETTER I WITH ACUTE;Ll;0;L;0069 0301;;;;N;LATIN SMALL LETTER I ACUTE;;00CD;;00CD\n00EE;LATIN SMALL LETTER I WITH CIRCUMFLEX;Ll;0;L;0069 0302;;;;N;LATIN SMALL LETTER I CIRCUMFLEX;;00CE;;00CE\n00EF;LATIN SMALL LETTER I WITH DIAERESIS;Ll;0;L;0069 0308;;;;N;LATIN SMALL LETTER I DIAERESIS;;00CF;;00CF\n00F0;LATIN SMALL LETTER ETH;Ll;0;L;;;;;N;;;00D0;;00D0\n00F1;LATIN SMALL LETTER N WITH TILDE;Ll;0;L;006E 0303;;;;N;LATIN SMALL LETTER N TILDE;;00D1;;00D1\n00F2;LATIN SMALL LETTER O WITH GRAVE;Ll;0;L;006F 0300;;;;N;LATIN SMALL LETTER O GRAVE;;00D2;;00D2\n00F3;LATIN SMALL LETTER O WITH ACUTE;Ll;0;L;006F 0301;;;;N;LATIN SMALL LETTER O ACUTE;;00D3;;00D3\n00F4;LATIN SMALL LETTER O WITH CIRCUMFLEX;Ll;0;L;006F 0302;;;;N;LATIN SMALL LETTER O CIRCUMFLEX;;00D4;;00D4\n00F5;LATIN SMALL LETTER O WITH TILDE;Ll;0;L;006F 0303;;;;N;LATIN SMALL LETTER O TILDE;;00D5;;00D5\n00F6;LATIN SMALL LETTER O WITH DIAERESIS;Ll;0;L;006F 0308;;;;N;LATIN SMALL LETTER O DIAERESIS;;00D6;;00D6\n00F7;DIVISION SIGN;Sm;0;ON;;;;;N;;;;;\n00F8;LATIN SMALL LETTER O WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER O SLASH;;00D8;;00D8\n00F9;LATIN SMALL LETTER U WITH GRAVE;Ll;0;L;0075 0300;;;;N;LATIN SMALL LETTER U GRAVE;;00D9;;00D9\n00FA;LATIN SMALL LETTER U WITH ACUTE;Ll;0;L;0075 0301;;;;N;LATIN SMALL LETTER U ACUTE;;00DA;;00DA\n00FB;LATIN SMALL LETTER U WITH CIRCUMFLEX;Ll;0;L;0075 0302;;;;N;LATIN SMALL LETTER U CIRCUMFLEX;;00DB;;00DB\n00FC;LATIN SMALL LETTER U WITH DIAERESIS;Ll;0;L;0075 0308;;;;N;LATIN SMALL LETTER U DIAERESIS;;00DC;;00DC\n00FD;LATIN SMALL LETTER Y WITH ACUTE;Ll;0;L;0079 0301;;;;N;LATIN SMALL LETTER Y ACUTE;;00DD;;00DD\n00FE;LATIN SMALL LETTER THORN;Ll;0;L;;;;;N;;;00DE;;00DE\n00FF;LATIN SMALL LETTER Y WITH DIAERESIS;Ll;0;L;0079 0308;;;;N;LATIN SMALL LETTER Y DIAERESIS;;0178;;0178\n0100;LATIN CAPITAL LETTER A WITH MACRON;Lu;0;L;0041 0304;;;;N;LATIN CAPITAL LETTER A MACRON;;;0101;\n0101;LATIN SMALL LETTER A WITH MACRON;Ll;0;L;0061 0304;;;;N;LATIN SMALL LETTER A MACRON;;0100;;0100\n0102;LATIN CAPITAL LETTER A WITH BREVE;Lu;0;L;0041 0306;;;;N;LATIN CAPITAL LETTER A BREVE;;;0103;\n0103;LATIN SMALL LETTER A WITH BREVE;Ll;0;L;0061 0306;;;;N;LATIN SMALL LETTER A BREVE;;0102;;0102\n0104;LATIN CAPITAL LETTER A WITH OGONEK;Lu;0;L;0041 0328;;;;N;LATIN CAPITAL LETTER A OGONEK;;;0105;\n0105;LATIN SMALL LETTER A WITH OGONEK;Ll;0;L;0061 0328;;;;N;LATIN SMALL LETTER A OGONEK;;0104;;0104\n0106;LATIN CAPITAL LETTER C WITH ACUTE;Lu;0;L;0043 0301;;;;N;LATIN CAPITAL LETTER C ACUTE;;;0107;\n0107;LATIN SMALL LETTER C WITH ACUTE;Ll;0;L;0063 0301;;;;N;LATIN SMALL LETTER C ACUTE;;0106;;0106\n0108;LATIN CAPITAL LETTER C WITH CIRCUMFLEX;Lu;0;L;0043 0302;;;;N;LATIN CAPITAL LETTER C CIRCUMFLEX;;;0109;\n0109;LATIN SMALL LETTER C WITH CIRCUMFLEX;Ll;0;L;0063 0302;;;;N;LATIN SMALL LETTER C CIRCUMFLEX;;0108;;0108\n010A;LATIN CAPITAL LETTER C WITH DOT ABOVE;Lu;0;L;0043 0307;;;;N;LATIN CAPITAL LETTER C DOT;;;010B;\n010B;LATIN SMALL LETTER C WITH DOT ABOVE;Ll;0;L;0063 0307;;;;N;LATIN SMALL LETTER C DOT;;010A;;010A\n010C;LATIN CAPITAL LETTER C WITH CARON;Lu;0;L;0043 030C;;;;N;LATIN CAPITAL LETTER C HACEK;;;010D;\n010D;LATIN SMALL LETTER C WITH CARON;Ll;0;L;0063 030C;;;;N;LATIN SMALL LETTER C HACEK;;010C;;010C\n010E;LATIN CAPITAL LETTER D WITH CARON;Lu;0;L;0044 030C;;;;N;LATIN CAPITAL LETTER D HACEK;;;010F;\n010F;LATIN SMALL LETTER D WITH CARON;Ll;0;L;0064 030C;;;;N;LATIN SMALL LETTER D HACEK;;010E;;010E\n0110;LATIN CAPITAL LETTER D WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER D BAR;;;0111;\n0111;LATIN SMALL LETTER D WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER D BAR;;0110;;0110\n0112;LATIN CAPITAL LETTER E WITH MACRON;Lu;0;L;0045 0304;;;;N;LATIN CAPITAL LETTER E MACRON;;;0113;\n0113;LATIN SMALL LETTER E WITH MACRON;Ll;0;L;0065 0304;;;;N;LATIN SMALL LETTER E MACRON;;0112;;0112\n0114;LATIN CAPITAL LETTER E WITH BREVE;Lu;0;L;0045 0306;;;;N;LATIN CAPITAL LETTER E BREVE;;;0115;\n0115;LATIN SMALL LETTER E WITH BREVE;Ll;0;L;0065 0306;;;;N;LATIN SMALL LETTER E BREVE;;0114;;0114\n0116;LATIN CAPITAL LETTER E WITH DOT ABOVE;Lu;0;L;0045 0307;;;;N;LATIN CAPITAL LETTER E DOT;;;0117;\n0117;LATIN SMALL LETTER E WITH DOT ABOVE;Ll;0;L;0065 0307;;;;N;LATIN SMALL LETTER E DOT;;0116;;0116\n0118;LATIN CAPITAL LETTER E WITH OGONEK;Lu;0;L;0045 0328;;;;N;LATIN CAPITAL LETTER E OGONEK;;;0119;\n0119;LATIN SMALL LETTER E WITH OGONEK;Ll;0;L;0065 0328;;;;N;LATIN SMALL LETTER E OGONEK;;0118;;0118\n011A;LATIN CAPITAL LETTER E WITH CARON;Lu;0;L;0045 030C;;;;N;LATIN CAPITAL LETTER E HACEK;;;011B;\n011B;LATIN SMALL LETTER E WITH CARON;Ll;0;L;0065 030C;;;;N;LATIN SMALL LETTER E HACEK;;011A;;011A\n011C;LATIN CAPITAL LETTER G WITH CIRCUMFLEX;Lu;0;L;0047 0302;;;;N;LATIN CAPITAL LETTER G CIRCUMFLEX;;;011D;\n011D;LATIN SMALL LETTER G WITH CIRCUMFLEX;Ll;0;L;0067 0302;;;;N;LATIN SMALL LETTER G CIRCUMFLEX;;011C;;011C\n011E;LATIN CAPITAL LETTER G WITH BREVE;Lu;0;L;0047 0306;;;;N;LATIN CAPITAL LETTER G BREVE;;;011F;\n011F;LATIN SMALL LETTER G WITH BREVE;Ll;0;L;0067 0306;;;;N;LATIN SMALL LETTER G BREVE;;011E;;011E\n0120;LATIN CAPITAL LETTER G WITH DOT ABOVE;Lu;0;L;0047 0307;;;;N;LATIN CAPITAL LETTER G DOT;;;0121;\n0121;LATIN SMALL LETTER G WITH DOT ABOVE;Ll;0;L;0067 0307;;;;N;LATIN SMALL LETTER G DOT;;0120;;0120\n0122;LATIN CAPITAL LETTER G WITH CEDILLA;Lu;0;L;0047 0327;;;;N;LATIN CAPITAL LETTER G CEDILLA;;;0123;\n0123;LATIN SMALL LETTER G WITH CEDILLA;Ll;0;L;0067 0327;;;;N;LATIN SMALL LETTER G CEDILLA;;0122;;0122\n0124;LATIN CAPITAL LETTER H WITH CIRCUMFLEX;Lu;0;L;0048 0302;;;;N;LATIN CAPITAL LETTER H CIRCUMFLEX;;;0125;\n0125;LATIN SMALL LETTER H WITH CIRCUMFLEX;Ll;0;L;0068 0302;;;;N;LATIN SMALL LETTER H CIRCUMFLEX;;0124;;0124\n0126;LATIN CAPITAL LETTER H WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER H BAR;;;0127;\n0127;LATIN SMALL LETTER H WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER H BAR;;0126;;0126\n0128;LATIN CAPITAL LETTER I WITH TILDE;Lu;0;L;0049 0303;;;;N;LATIN CAPITAL LETTER I TILDE;;;0129;\n0129;LATIN SMALL LETTER I WITH TILDE;Ll;0;L;0069 0303;;;;N;LATIN SMALL LETTER I TILDE;;0128;;0128\n012A;LATIN CAPITAL LETTER I WITH MACRON;Lu;0;L;0049 0304;;;;N;LATIN CAPITAL LETTER I MACRON;;;012B;\n012B;LATIN SMALL LETTER I WITH MACRON;Ll;0;L;0069 0304;;;;N;LATIN SMALL LETTER I MACRON;;012A;;012A\n012C;LATIN CAPITAL LETTER I WITH BREVE;Lu;0;L;0049 0306;;;;N;LATIN CAPITAL LETTER I BREVE;;;012D;\n012D;LATIN SMALL LETTER I WITH BREVE;Ll;0;L;0069 0306;;;;N;LATIN SMALL LETTER I BREVE;;012C;;012C\n012E;LATIN CAPITAL LETTER I WITH OGONEK;Lu;0;L;0049 0328;;;;N;LATIN CAPITAL LETTER I OGONEK;;;012F;\n012F;LATIN SMALL LETTER I WITH OGONEK;Ll;0;L;0069 0328;;;;N;LATIN SMALL LETTER I OGONEK;;012E;;012E\n0130;LATIN CAPITAL LETTER I WITH DOT ABOVE;Lu;0;L;0049 0307;;;;N;LATIN CAPITAL LETTER I DOT;;;0069;\n0131;LATIN SMALL LETTER DOTLESS I;Ll;0;L;;;;;N;;;0049;;0049\n0132;LATIN CAPITAL LIGATURE IJ;Lu;0;L;<compat> 0049 004A;;;;N;LATIN CAPITAL LETTER I J;;;0133;\n0133;LATIN SMALL LIGATURE IJ;Ll;0;L;<compat> 0069 006A;;;;N;LATIN SMALL LETTER I J;;0132;;0132\n0134;LATIN CAPITAL LETTER J WITH CIRCUMFLEX;Lu;0;L;004A 0302;;;;N;LATIN CAPITAL LETTER J CIRCUMFLEX;;;0135;\n0135;LATIN SMALL LETTER J WITH CIRCUMFLEX;Ll;0;L;006A 0302;;;;N;LATIN SMALL LETTER J CIRCUMFLEX;;0134;;0134\n0136;LATIN CAPITAL LETTER K WITH CEDILLA;Lu;0;L;004B 0327;;;;N;LATIN CAPITAL LETTER K CEDILLA;;;0137;\n0137;LATIN SMALL LETTER K WITH CEDILLA;Ll;0;L;006B 0327;;;;N;LATIN SMALL LETTER K CEDILLA;;0136;;0136\n0138;LATIN SMALL LETTER KRA;Ll;0;L;;;;;N;;;;;\n0139;LATIN CAPITAL LETTER L WITH ACUTE;Lu;0;L;004C 0301;;;;N;LATIN CAPITAL LETTER L ACUTE;;;013A;\n013A;LATIN SMALL LETTER L WITH ACUTE;Ll;0;L;006C 0301;;;;N;LATIN SMALL LETTER L ACUTE;;0139;;0139\n013B;LATIN CAPITAL LETTER L WITH CEDILLA;Lu;0;L;004C 0327;;;;N;LATIN CAPITAL LETTER L CEDILLA;;;013C;\n013C;LATIN SMALL LETTER L WITH CEDILLA;Ll;0;L;006C 0327;;;;N;LATIN SMALL LETTER L CEDILLA;;013B;;013B\n013D;LATIN CAPITAL LETTER L WITH CARON;Lu;0;L;004C 030C;;;;N;LATIN CAPITAL LETTER L HACEK;;;013E;\n013E;LATIN SMALL LETTER L WITH CARON;Ll;0;L;006C 030C;;;;N;LATIN SMALL LETTER L HACEK;;013D;;013D\n013F;LATIN CAPITAL LETTER L WITH MIDDLE DOT;Lu;0;L;<compat> 004C 00B7;;;;N;;;;0140;\n0140;LATIN SMALL LETTER L WITH MIDDLE DOT;Ll;0;L;<compat> 006C 00B7;;;;N;;;013F;;013F\n0141;LATIN CAPITAL LETTER L WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER L SLASH;;;0142;\n0142;LATIN SMALL LETTER L WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER L SLASH;;0141;;0141\n0143;LATIN CAPITAL LETTER N WITH ACUTE;Lu;0;L;004E 0301;;;;N;LATIN CAPITAL LETTER N ACUTE;;;0144;\n0144;LATIN SMALL LETTER N WITH ACUTE;Ll;0;L;006E 0301;;;;N;LATIN SMALL LETTER N ACUTE;;0143;;0143\n0145;LATIN CAPITAL LETTER N WITH CEDILLA;Lu;0;L;004E 0327;;;;N;LATIN CAPITAL LETTER N CEDILLA;;;0146;\n0146;LATIN SMALL LETTER N WITH CEDILLA;Ll;0;L;006E 0327;;;;N;LATIN SMALL LETTER N CEDILLA;;0145;;0145\n0147;LATIN CAPITAL LETTER N WITH CARON;Lu;0;L;004E 030C;;;;N;LATIN CAPITAL LETTER N HACEK;;;0148;\n0148;LATIN SMALL LETTER N WITH CARON;Ll;0;L;006E 030C;;;;N;LATIN SMALL LETTER N HACEK;;0147;;0147\n0149;LATIN SMALL LETTER N PRECEDED BY APOSTROPHE;Ll;0;L;<compat> 02BC 006E;;;;N;LATIN SMALL LETTER APOSTROPHE N;;;;\n014A;LATIN CAPITAL LETTER ENG;Lu;0;L;;;;;N;;;;014B;\n014B;LATIN SMALL LETTER ENG;Ll;0;L;;;;;N;;;014A;;014A\n014C;LATIN CAPITAL LETTER O WITH MACRON;Lu;0;L;004F 0304;;;;N;LATIN CAPITAL LETTER O MACRON;;;014D;\n014D;LATIN SMALL LETTER O WITH MACRON;Ll;0;L;006F 0304;;;;N;LATIN SMALL LETTER O MACRON;;014C;;014C\n014E;LATIN CAPITAL LETTER O WITH BREVE;Lu;0;L;004F 0306;;;;N;LATIN CAPITAL LETTER O BREVE;;;014F;\n014F;LATIN SMALL LETTER O WITH BREVE;Ll;0;L;006F 0306;;;;N;LATIN SMALL LETTER O BREVE;;014E;;014E\n0150;LATIN CAPITAL LETTER O WITH DOUBLE ACUTE;Lu;0;L;004F 030B;;;;N;LATIN CAPITAL LETTER O DOUBLE ACUTE;;;0151;\n0151;LATIN SMALL LETTER O WITH DOUBLE ACUTE;Ll;0;L;006F 030B;;;;N;LATIN SMALL LETTER O DOUBLE ACUTE;;0150;;0150\n0152;LATIN CAPITAL LIGATURE OE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER O E;;;0153;\n0153;LATIN SMALL LIGATURE OE;Ll;0;L;;;;;N;LATIN SMALL LETTER O E;;0152;;0152\n0154;LATIN CAPITAL LETTER R WITH ACUTE;Lu;0;L;0052 0301;;;;N;LATIN CAPITAL LETTER R ACUTE;;;0155;\n0155;LATIN SMALL LETTER R WITH ACUTE;Ll;0;L;0072 0301;;;;N;LATIN SMALL LETTER R ACUTE;;0154;;0154\n0156;LATIN CAPITAL LETTER R WITH CEDILLA;Lu;0;L;0052 0327;;;;N;LATIN CAPITAL LETTER R CEDILLA;;;0157;\n0157;LATIN SMALL LETTER R WITH CEDILLA;Ll;0;L;0072 0327;;;;N;LATIN SMALL LETTER R CEDILLA;;0156;;0156\n0158;LATIN CAPITAL LETTER R WITH CARON;Lu;0;L;0052 030C;;;;N;LATIN CAPITAL LETTER R HACEK;;;0159;\n0159;LATIN SMALL LETTER R WITH CARON;Ll;0;L;0072 030C;;;;N;LATIN SMALL LETTER R HACEK;;0158;;0158\n015A;LATIN CAPITAL LETTER S WITH ACUTE;Lu;0;L;0053 0301;;;;N;LATIN CAPITAL LETTER S ACUTE;;;015B;\n015B;LATIN SMALL LETTER S WITH ACUTE;Ll;0;L;0073 0301;;;;N;LATIN SMALL LETTER S ACUTE;;015A;;015A\n015C;LATIN CAPITAL LETTER S WITH CIRCUMFLEX;Lu;0;L;0053 0302;;;;N;LATIN CAPITAL LETTER S CIRCUMFLEX;;;015D;\n015D;LATIN SMALL LETTER S WITH CIRCUMFLEX;Ll;0;L;0073 0302;;;;N;LATIN SMALL LETTER S CIRCUMFLEX;;015C;;015C\n015E;LATIN CAPITAL LETTER S WITH CEDILLA;Lu;0;L;0053 0327;;;;N;LATIN CAPITAL LETTER S CEDILLA;;;015F;\n015F;LATIN SMALL LETTER S WITH CEDILLA;Ll;0;L;0073 0327;;;;N;LATIN SMALL LETTER S CEDILLA;;015E;;015E\n0160;LATIN CAPITAL LETTER S WITH CARON;Lu;0;L;0053 030C;;;;N;LATIN CAPITAL LETTER S HACEK;;;0161;\n0161;LATIN SMALL LETTER S WITH CARON;Ll;0;L;0073 030C;;;;N;LATIN SMALL LETTER S HACEK;;0160;;0160\n0162;LATIN CAPITAL LETTER T WITH CEDILLA;Lu;0;L;0054 0327;;;;N;LATIN CAPITAL LETTER T CEDILLA;;;0163;\n0163;LATIN SMALL LETTER T WITH CEDILLA;Ll;0;L;0074 0327;;;;N;LATIN SMALL LETTER T CEDILLA;;0162;;0162\n0164;LATIN CAPITAL LETTER T WITH CARON;Lu;0;L;0054 030C;;;;N;LATIN CAPITAL LETTER T HACEK;;;0165;\n0165;LATIN SMALL LETTER T WITH CARON;Ll;0;L;0074 030C;;;;N;LATIN SMALL LETTER T HACEK;;0164;;0164\n0166;LATIN CAPITAL LETTER T WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER T BAR;;;0167;\n0167;LATIN SMALL LETTER T WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER T BAR;;0166;;0166\n0168;LATIN CAPITAL LETTER U WITH TILDE;Lu;0;L;0055 0303;;;;N;LATIN CAPITAL LETTER U TILDE;;;0169;\n0169;LATIN SMALL LETTER U WITH TILDE;Ll;0;L;0075 0303;;;;N;LATIN SMALL LETTER U TILDE;;0168;;0168\n016A;LATIN CAPITAL LETTER U WITH MACRON;Lu;0;L;0055 0304;;;;N;LATIN CAPITAL LETTER U MACRON;;;016B;\n016B;LATIN SMALL LETTER U WITH MACRON;Ll;0;L;0075 0304;;;;N;LATIN SMALL LETTER U MACRON;;016A;;016A\n016C;LATIN CAPITAL LETTER U WITH BREVE;Lu;0;L;0055 0306;;;;N;LATIN CAPITAL LETTER U BREVE;;;016D;\n016D;LATIN SMALL LETTER U WITH BREVE;Ll;0;L;0075 0306;;;;N;LATIN SMALL LETTER U BREVE;;016C;;016C\n016E;LATIN CAPITAL LETTER U WITH RING ABOVE;Lu;0;L;0055 030A;;;;N;LATIN CAPITAL LETTER U RING;;;016F;\n016F;LATIN SMALL LETTER U WITH RING ABOVE;Ll;0;L;0075 030A;;;;N;LATIN SMALL LETTER U RING;;016E;;016E\n0170;LATIN CAPITAL LETTER U WITH DOUBLE ACUTE;Lu;0;L;0055 030B;;;;N;LATIN CAPITAL LETTER U DOUBLE ACUTE;;;0171;\n0171;LATIN SMALL LETTER U WITH DOUBLE ACUTE;Ll;0;L;0075 030B;;;;N;LATIN SMALL LETTER U DOUBLE ACUTE;;0170;;0170\n0172;LATIN CAPITAL LETTER U WITH OGONEK;Lu;0;L;0055 0328;;;;N;LATIN CAPITAL LETTER U OGONEK;;;0173;\n0173;LATIN SMALL LETTER U WITH OGONEK;Ll;0;L;0075 0328;;;;N;LATIN SMALL LETTER U OGONEK;;0172;;0172\n0174;LATIN CAPITAL LETTER W WITH CIRCUMFLEX;Lu;0;L;0057 0302;;;;N;LATIN CAPITAL LETTER W CIRCUMFLEX;;;0175;\n0175;LATIN SMALL LETTER W WITH CIRCUMFLEX;Ll;0;L;0077 0302;;;;N;LATIN SMALL LETTER W CIRCUMFLEX;;0174;;0174\n0176;LATIN CAPITAL LETTER Y WITH CIRCUMFLEX;Lu;0;L;0059 0302;;;;N;LATIN CAPITAL LETTER Y CIRCUMFLEX;;;0177;\n0177;LATIN SMALL LETTER Y WITH CIRCUMFLEX;Ll;0;L;0079 0302;;;;N;LATIN SMALL LETTER Y CIRCUMFLEX;;0176;;0176\n0178;LATIN CAPITAL LETTER Y WITH DIAERESIS;Lu;0;L;0059 0308;;;;N;LATIN CAPITAL LETTER Y DIAERESIS;;;00FF;\n0179;LATIN CAPITAL LETTER Z WITH ACUTE;Lu;0;L;005A 0301;;;;N;LATIN CAPITAL LETTER Z ACUTE;;;017A;\n017A;LATIN SMALL LETTER Z WITH ACUTE;Ll;0;L;007A 0301;;;;N;LATIN SMALL LETTER Z ACUTE;;0179;;0179\n017B;LATIN CAPITAL LETTER Z WITH DOT ABOVE;Lu;0;L;005A 0307;;;;N;LATIN CAPITAL LETTER Z DOT;;;017C;\n017C;LATIN SMALL LETTER Z WITH DOT ABOVE;Ll;0;L;007A 0307;;;;N;LATIN SMALL LETTER Z DOT;;017B;;017B\n017D;LATIN CAPITAL LETTER Z WITH CARON;Lu;0;L;005A 030C;;;;N;LATIN CAPITAL LETTER Z HACEK;;;017E;\n017E;LATIN SMALL LETTER Z WITH CARON;Ll;0;L;007A 030C;;;;N;LATIN SMALL LETTER Z HACEK;;017D;;017D\n017F;LATIN SMALL LETTER LONG S;Ll;0;L;<compat> 0073;;;;N;;;0053;;0053\n0180;LATIN SMALL LETTER B WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER B BAR;;0243;;0243\n0181;LATIN CAPITAL LETTER B WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER B HOOK;;;0253;\n0182;LATIN CAPITAL LETTER B WITH TOPBAR;Lu;0;L;;;;;N;LATIN CAPITAL LETTER B TOPBAR;;;0183;\n0183;LATIN SMALL LETTER B WITH TOPBAR;Ll;0;L;;;;;N;LATIN SMALL LETTER B TOPBAR;;0182;;0182\n0184;LATIN CAPITAL LETTER TONE SIX;Lu;0;L;;;;;N;;;;0185;\n0185;LATIN SMALL LETTER TONE SIX;Ll;0;L;;;;;N;;;0184;;0184\n0186;LATIN CAPITAL LETTER OPEN O;Lu;0;L;;;;;N;;;;0254;\n0187;LATIN CAPITAL LETTER C WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER C HOOK;;;0188;\n0188;LATIN SMALL LETTER C WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER C HOOK;;0187;;0187\n0189;LATIN CAPITAL LETTER AFRICAN D;Lu;0;L;;;;;N;;;;0256;\n018A;LATIN CAPITAL LETTER D WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER D HOOK;;;0257;\n018B;LATIN CAPITAL LETTER D WITH TOPBAR;Lu;0;L;;;;;N;LATIN CAPITAL LETTER D TOPBAR;;;018C;\n018C;LATIN SMALL LETTER D WITH TOPBAR;Ll;0;L;;;;;N;LATIN SMALL LETTER D TOPBAR;;018B;;018B\n018D;LATIN SMALL LETTER TURNED DELTA;Ll;0;L;;;;;N;;;;;\n018E;LATIN CAPITAL LETTER REVERSED E;Lu;0;L;;;;;N;LATIN CAPITAL LETTER TURNED E;;;01DD;\n018F;LATIN CAPITAL LETTER SCHWA;Lu;0;L;;;;;N;;;;0259;\n0190;LATIN CAPITAL LETTER OPEN E;Lu;0;L;;;;;N;LATIN CAPITAL LETTER EPSILON;;;025B;\n0191;LATIN CAPITAL LETTER F WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER F HOOK;;;0192;\n0192;LATIN SMALL LETTER F WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER SCRIPT F;;0191;;0191\n0193;LATIN CAPITAL LETTER G WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER G HOOK;;;0260;\n0194;LATIN CAPITAL LETTER GAMMA;Lu;0;L;;;;;N;;;;0263;\n0195;LATIN SMALL LETTER HV;Ll;0;L;;;;;N;LATIN SMALL LETTER H V;;01F6;;01F6\n0196;LATIN CAPITAL LETTER IOTA;Lu;0;L;;;;;N;;;;0269;\n0197;LATIN CAPITAL LETTER I WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER BARRED I;;;0268;\n0198;LATIN CAPITAL LETTER K WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER K HOOK;;;0199;\n0199;LATIN SMALL LETTER K WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER K HOOK;;0198;;0198\n019A;LATIN SMALL LETTER L WITH BAR;Ll;0;L;;;;;N;LATIN SMALL LETTER BARRED L;;023D;;023D\n019B;LATIN SMALL LETTER LAMBDA WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER BARRED LAMBDA;;;;\n019C;LATIN CAPITAL LETTER TURNED M;Lu;0;L;;;;;N;;;;026F;\n019D;LATIN CAPITAL LETTER N WITH LEFT HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER N HOOK;;;0272;\n019E;LATIN SMALL LETTER N WITH LONG RIGHT LEG;Ll;0;L;;;;;N;;;0220;;0220\n019F;LATIN CAPITAL LETTER O WITH MIDDLE TILDE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER BARRED O;;;0275;\n01A0;LATIN CAPITAL LETTER O WITH HORN;Lu;0;L;004F 031B;;;;N;LATIN CAPITAL LETTER O HORN;;;01A1;\n01A1;LATIN SMALL LETTER O WITH HORN;Ll;0;L;006F 031B;;;;N;LATIN SMALL LETTER O HORN;;01A0;;01A0\n01A2;LATIN CAPITAL LETTER OI;Lu;0;L;;;;;N;LATIN CAPITAL LETTER O I;;;01A3;\n01A3;LATIN SMALL LETTER OI;Ll;0;L;;;;;N;LATIN SMALL LETTER O I;;01A2;;01A2\n01A4;LATIN CAPITAL LETTER P WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER P HOOK;;;01A5;\n01A5;LATIN SMALL LETTER P WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER P HOOK;;01A4;;01A4\n01A6;LATIN LETTER YR;Lu;0;L;;;;;N;LATIN LETTER Y R;;;0280;\n01A7;LATIN CAPITAL LETTER TONE TWO;Lu;0;L;;;;;N;;;;01A8;\n01A8;LATIN SMALL LETTER TONE TWO;Ll;0;L;;;;;N;;;01A7;;01A7\n01A9;LATIN CAPITAL LETTER ESH;Lu;0;L;;;;;N;;;;0283;\n01AA;LATIN LETTER REVERSED ESH LOOP;Ll;0;L;;;;;N;;;;;\n01AB;LATIN SMALL LETTER T WITH PALATAL HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER T PALATAL HOOK;;;;\n01AC;LATIN CAPITAL LETTER T WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER T HOOK;;;01AD;\n01AD;LATIN SMALL LETTER T WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER T HOOK;;01AC;;01AC\n01AE;LATIN CAPITAL LETTER T WITH RETROFLEX HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER T RETROFLEX HOOK;;;0288;\n01AF;LATIN CAPITAL LETTER U WITH HORN;Lu;0;L;0055 031B;;;;N;LATIN CAPITAL LETTER U HORN;;;01B0;\n01B0;LATIN SMALL LETTER U WITH HORN;Ll;0;L;0075 031B;;;;N;LATIN SMALL LETTER U HORN;;01AF;;01AF\n01B1;LATIN CAPITAL LETTER UPSILON;Lu;0;L;;;;;N;;;;028A;\n01B2;LATIN CAPITAL LETTER V WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER SCRIPT V;;;028B;\n01B3;LATIN CAPITAL LETTER Y WITH HOOK;Lu;0;L;;;;;N;LATIN CAPITAL LETTER Y HOOK;;;01B4;\n01B4;LATIN SMALL LETTER Y WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER Y HOOK;;01B3;;01B3\n01B5;LATIN CAPITAL LETTER Z WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER Z BAR;;;01B6;\n01B6;LATIN SMALL LETTER Z WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER Z BAR;;01B5;;01B5\n01B7;LATIN CAPITAL LETTER EZH;Lu;0;L;;;;;N;LATIN CAPITAL LETTER YOGH;;;0292;\n01B8;LATIN CAPITAL LETTER EZH REVERSED;Lu;0;L;;;;;N;LATIN CAPITAL LETTER REVERSED YOGH;;;01B9;\n01B9;LATIN SMALL LETTER EZH REVERSED;Ll;0;L;;;;;N;LATIN SMALL LETTER REVERSED YOGH;;01B8;;01B8\n01BA;LATIN SMALL LETTER EZH WITH TAIL;Ll;0;L;;;;;N;LATIN SMALL LETTER YOGH WITH TAIL;;;;\n01BB;LATIN LETTER TWO WITH STROKE;Lo;0;L;;;;;N;LATIN LETTER TWO BAR;;;;\n01BC;LATIN CAPITAL LETTER TONE FIVE;Lu;0;L;;;;;N;;;;01BD;\n01BD;LATIN SMALL LETTER TONE FIVE;Ll;0;L;;;;;N;;;01BC;;01BC\n01BE;LATIN LETTER INVERTED GLOTTAL STOP WITH STROKE;Ll;0;L;;;;;N;LATIN LETTER INVERTED GLOTTAL STOP BAR;;;;\n01BF;LATIN LETTER WYNN;Ll;0;L;;;;;N;;;01F7;;01F7\n01C0;LATIN LETTER DENTAL CLICK;Lo;0;L;;;;;N;LATIN LETTER PIPE;;;;\n01C1;LATIN LETTER LATERAL CLICK;Lo;0;L;;;;;N;LATIN LETTER DOUBLE PIPE;;;;\n01C2;LATIN LETTER ALVEOLAR CLICK;Lo;0;L;;;;;N;LATIN LETTER PIPE DOUBLE BAR;;;;\n01C3;LATIN LETTER RETROFLEX CLICK;Lo;0;L;;;;;N;LATIN LETTER EXCLAMATION MARK;;;;\n01C4;LATIN CAPITAL LETTER DZ WITH CARON;Lu;0;L;<compat> 0044 017D;;;;N;LATIN CAPITAL LETTER D Z HACEK;;;01C6;01C5\n01C5;LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON;Lt;0;L;<compat> 0044 017E;;;;N;LATIN LETTER CAPITAL D SMALL Z HACEK;;01C4;01C6;01C5\n01C6;LATIN SMALL LETTER DZ WITH CARON;Ll;0;L;<compat> 0064 017E;;;;N;LATIN SMALL LETTER D Z HACEK;;01C4;;01C5\n01C7;LATIN CAPITAL LETTER LJ;Lu;0;L;<compat> 004C 004A;;;;N;LATIN CAPITAL LETTER L J;;;01C9;01C8\n01C8;LATIN CAPITAL LETTER L WITH SMALL LETTER J;Lt;0;L;<compat> 004C 006A;;;;N;LATIN LETTER CAPITAL L SMALL J;;01C7;01C9;01C8\n01C9;LATIN SMALL LETTER LJ;Ll;0;L;<compat> 006C 006A;;;;N;LATIN SMALL LETTER L J;;01C7;;01C8\n01CA;LATIN CAPITAL LETTER NJ;Lu;0;L;<compat> 004E 004A;;;;N;LATIN CAPITAL LETTER N J;;;01CC;01CB\n01CB;LATIN CAPITAL LETTER N WITH SMALL LETTER J;Lt;0;L;<compat> 004E 006A;;;;N;LATIN LETTER CAPITAL N SMALL J;;01CA;01CC;01CB\n01CC;LATIN SMALL LETTER NJ;Ll;0;L;<compat> 006E 006A;;;;N;LATIN SMALL LETTER N J;;01CA;;01CB\n01CD;LATIN CAPITAL LETTER A WITH CARON;Lu;0;L;0041 030C;;;;N;LATIN CAPITAL LETTER A HACEK;;;01CE;\n01CE;LATIN SMALL LETTER A WITH CARON;Ll;0;L;0061 030C;;;;N;LATIN SMALL LETTER A HACEK;;01CD;;01CD\n01CF;LATIN CAPITAL LETTER I WITH CARON;Lu;0;L;0049 030C;;;;N;LATIN CAPITAL LETTER I HACEK;;;01D0;\n01D0;LATIN SMALL LETTER I WITH CARON;Ll;0;L;0069 030C;;;;N;LATIN SMALL LETTER I HACEK;;01CF;;01CF\n01D1;LATIN CAPITAL LETTER O WITH CARON;Lu;0;L;004F 030C;;;;N;LATIN CAPITAL LETTER O HACEK;;;01D2;\n01D2;LATIN SMALL LETTER O WITH CARON;Ll;0;L;006F 030C;;;;N;LATIN SMALL LETTER O HACEK;;01D1;;01D1\n01D3;LATIN CAPITAL LETTER U WITH CARON;Lu;0;L;0055 030C;;;;N;LATIN CAPITAL LETTER U HACEK;;;01D4;\n01D4;LATIN SMALL LETTER U WITH CARON;Ll;0;L;0075 030C;;;;N;LATIN SMALL LETTER U HACEK;;01D3;;01D3\n01D5;LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON;Lu;0;L;00DC 0304;;;;N;LATIN CAPITAL LETTER U DIAERESIS MACRON;;;01D6;\n01D6;LATIN SMALL LETTER U WITH DIAERESIS AND MACRON;Ll;0;L;00FC 0304;;;;N;LATIN SMALL LETTER U DIAERESIS MACRON;;01D5;;01D5\n01D7;LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE;Lu;0;L;00DC 0301;;;;N;LATIN CAPITAL LETTER U DIAERESIS ACUTE;;;01D8;\n01D8;LATIN SMALL LETTER U WITH DIAERESIS AND ACUTE;Ll;0;L;00FC 0301;;;;N;LATIN SMALL LETTER U DIAERESIS ACUTE;;01D7;;01D7\n01D9;LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON;Lu;0;L;00DC 030C;;;;N;LATIN CAPITAL LETTER U DIAERESIS HACEK;;;01DA;\n01DA;LATIN SMALL LETTER U WITH DIAERESIS AND CARON;Ll;0;L;00FC 030C;;;;N;LATIN SMALL LETTER U DIAERESIS HACEK;;01D9;;01D9\n01DB;LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE;Lu;0;L;00DC 0300;;;;N;LATIN CAPITAL LETTER U DIAERESIS GRAVE;;;01DC;\n01DC;LATIN SMALL LETTER U WITH DIAERESIS AND GRAVE;Ll;0;L;00FC 0300;;;;N;LATIN SMALL LETTER U DIAERESIS GRAVE;;01DB;;01DB\n01DD;LATIN SMALL LETTER TURNED E;Ll;0;L;;;;;N;;;018E;;018E\n01DE;LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON;Lu;0;L;00C4 0304;;;;N;LATIN CAPITAL LETTER A DIAERESIS MACRON;;;01DF;\n01DF;LATIN SMALL LETTER A WITH DIAERESIS AND MACRON;Ll;0;L;00E4 0304;;;;N;LATIN SMALL LETTER A DIAERESIS MACRON;;01DE;;01DE\n01E0;LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON;Lu;0;L;0226 0304;;;;N;LATIN CAPITAL LETTER A DOT MACRON;;;01E1;\n01E1;LATIN SMALL LETTER A WITH DOT ABOVE AND MACRON;Ll;0;L;0227 0304;;;;N;LATIN SMALL LETTER A DOT MACRON;;01E0;;01E0\n01E2;LATIN CAPITAL LETTER AE WITH MACRON;Lu;0;L;00C6 0304;;;;N;LATIN CAPITAL LETTER A E MACRON;;;01E3;\n01E3;LATIN SMALL LETTER AE WITH MACRON;Ll;0;L;00E6 0304;;;;N;LATIN SMALL LETTER A E MACRON;;01E2;;01E2\n01E4;LATIN CAPITAL LETTER G WITH STROKE;Lu;0;L;;;;;N;LATIN CAPITAL LETTER G BAR;;;01E5;\n01E5;LATIN SMALL LETTER G WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER G BAR;;01E4;;01E4\n01E6;LATIN CAPITAL LETTER G WITH CARON;Lu;0;L;0047 030C;;;;N;LATIN CAPITAL LETTER G HACEK;;;01E7;\n01E7;LATIN SMALL LETTER G WITH CARON;Ll;0;L;0067 030C;;;;N;LATIN SMALL LETTER G HACEK;;01E6;;01E6\n01E8;LATIN CAPITAL LETTER K WITH CARON;Lu;0;L;004B 030C;;;;N;LATIN CAPITAL LETTER K HACEK;;;01E9;\n01E9;LATIN SMALL LETTER K WITH CARON;Ll;0;L;006B 030C;;;;N;LATIN SMALL LETTER K HACEK;;01E8;;01E8\n01EA;LATIN CAPITAL LETTER O WITH OGONEK;Lu;0;L;004F 0328;;;;N;LATIN CAPITAL LETTER O OGONEK;;;01EB;\n01EB;LATIN SMALL LETTER O WITH OGONEK;Ll;0;L;006F 0328;;;;N;LATIN SMALL LETTER O OGONEK;;01EA;;01EA\n01EC;LATIN CAPITAL LETTER O WITH OGONEK AND MACRON;Lu;0;L;01EA 0304;;;;N;LATIN CAPITAL LETTER O OGONEK MACRON;;;01ED;\n01ED;LATIN SMALL LETTER O WITH OGONEK AND MACRON;Ll;0;L;01EB 0304;;;;N;LATIN SMALL LETTER O OGONEK MACRON;;01EC;;01EC\n01EE;LATIN CAPITAL LETTER EZH WITH CARON;Lu;0;L;01B7 030C;;;;N;LATIN CAPITAL LETTER YOGH HACEK;;;01EF;\n01EF;LATIN SMALL LETTER EZH WITH CARON;Ll;0;L;0292 030C;;;;N;LATIN SMALL LETTER YOGH HACEK;;01EE;;01EE\n01F0;LATIN SMALL LETTER J WITH CARON;Ll;0;L;006A 030C;;;;N;LATIN SMALL LETTER J HACEK;;;;\n01F1;LATIN CAPITAL LETTER DZ;Lu;0;L;<compat> 0044 005A;;;;N;;;;01F3;01F2\n01F2;LATIN CAPITAL LETTER D WITH SMALL LETTER Z;Lt;0;L;<compat> 0044 007A;;;;N;;;01F1;01F3;01F2\n01F3;LATIN SMALL LETTER DZ;Ll;0;L;<compat> 0064 007A;;;;N;;;01F1;;01F2\n01F4;LATIN CAPITAL LETTER G WITH ACUTE;Lu;0;L;0047 0301;;;;N;;;;01F5;\n01F5;LATIN SMALL LETTER G WITH ACUTE;Ll;0;L;0067 0301;;;;N;;;01F4;;01F4\n01F6;LATIN CAPITAL LETTER HWAIR;Lu;0;L;;;;;N;;;;0195;\n01F7;LATIN CAPITAL LETTER WYNN;Lu;0;L;;;;;N;;;;01BF;\n01F8;LATIN CAPITAL LETTER N WITH GRAVE;Lu;0;L;004E 0300;;;;N;;;;01F9;\n01F9;LATIN SMALL LETTER N WITH GRAVE;Ll;0;L;006E 0300;;;;N;;;01F8;;01F8\n01FA;LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE;Lu;0;L;00C5 0301;;;;N;;;;01FB;\n01FB;LATIN SMALL LETTER A WITH RING ABOVE AND ACUTE;Ll;0;L;00E5 0301;;;;N;;;01FA;;01FA\n01FC;LATIN CAPITAL LETTER AE WITH ACUTE;Lu;0;L;00C6 0301;;;;N;;;;01FD;\n01FD;LATIN SMALL LETTER AE WITH ACUTE;Ll;0;L;00E6 0301;;;;N;;;01FC;;01FC\n01FE;LATIN CAPITAL LETTER O WITH STROKE AND ACUTE;Lu;0;L;00D8 0301;;;;N;;;;01FF;\n01FF;LATIN SMALL LETTER O WITH STROKE AND ACUTE;Ll;0;L;00F8 0301;;;;N;;;01FE;;01FE\n0200;LATIN CAPITAL LETTER A WITH DOUBLE GRAVE;Lu;0;L;0041 030F;;;;N;;;;0201;\n0201;LATIN SMALL LETTER A WITH DOUBLE GRAVE;Ll;0;L;0061 030F;;;;N;;;0200;;0200\n0202;LATIN CAPITAL LETTER A WITH INVERTED BREVE;Lu;0;L;0041 0311;;;;N;;;;0203;\n0203;LATIN SMALL LETTER A WITH INVERTED BREVE;Ll;0;L;0061 0311;;;;N;;;0202;;0202\n0204;LATIN CAPITAL LETTER E WITH DOUBLE GRAVE;Lu;0;L;0045 030F;;;;N;;;;0205;\n0205;LATIN SMALL LETTER E WITH DOUBLE GRAVE;Ll;0;L;0065 030F;;;;N;;;0204;;0204\n0206;LATIN CAPITAL LETTER E WITH INVERTED BREVE;Lu;0;L;0045 0311;;;;N;;;;0207;\n0207;LATIN SMALL LETTER E WITH INVERTED BREVE;Ll;0;L;0065 0311;;;;N;;;0206;;0206\n0208;LATIN CAPITAL LETTER I WITH DOUBLE GRAVE;Lu;0;L;0049 030F;;;;N;;;;0209;\n0209;LATIN SMALL LETTER I WITH DOUBLE GRAVE;Ll;0;L;0069 030F;;;;N;;;0208;;0208\n020A;LATIN CAPITAL LETTER I WITH INVERTED BREVE;Lu;0;L;0049 0311;;;;N;;;;020B;\n020B;LATIN SMALL LETTER I WITH INVERTED BREVE;Ll;0;L;0069 0311;;;;N;;;020A;;020A\n020C;LATIN CAPITAL LETTER O WITH DOUBLE GRAVE;Lu;0;L;004F 030F;;;;N;;;;020D;\n020D;LATIN SMALL LETTER O WITH DOUBLE GRAVE;Ll;0;L;006F 030F;;;;N;;;020C;;020C\n020E;LATIN CAPITAL LETTER O WITH INVERTED BREVE;Lu;0;L;004F 0311;;;;N;;;;020F;\n020F;LATIN SMALL LETTER O WITH INVERTED BREVE;Ll;0;L;006F 0311;;;;N;;;020E;;020E\n0210;LATIN CAPITAL LETTER R WITH DOUBLE GRAVE;Lu;0;L;0052 030F;;;;N;;;;0211;\n0211;LATIN SMALL LETTER R WITH DOUBLE GRAVE;Ll;0;L;0072 030F;;;;N;;;0210;;0210\n0212;LATIN CAPITAL LETTER R WITH INVERTED BREVE;Lu;0;L;0052 0311;;;;N;;;;0213;\n0213;LATIN SMALL LETTER R WITH INVERTED BREVE;Ll;0;L;0072 0311;;;;N;;;0212;;0212\n0214;LATIN CAPITAL LETTER U WITH DOUBLE GRAVE;Lu;0;L;0055 030F;;;;N;;;;0215;\n0215;LATIN SMALL LETTER U WITH DOUBLE GRAVE;Ll;0;L;0075 030F;;;;N;;;0214;;0214\n0216;LATIN CAPITAL LETTER U WITH INVERTED BREVE;Lu;0;L;0055 0311;;;;N;;;;0217;\n0217;LATIN SMALL LETTER U WITH INVERTED BREVE;Ll;0;L;0075 0311;;;;N;;;0216;;0216\n0218;LATIN CAPITAL LETTER S WITH COMMA BELOW;Lu;0;L;0053 0326;;;;N;;;;0219;\n0219;LATIN SMALL LETTER S WITH COMMA BELOW;Ll;0;L;0073 0326;;;;N;;;0218;;0218\n021A;LATIN CAPITAL LETTER T WITH COMMA BELOW;Lu;0;L;0054 0326;;;;N;;;;021B;\n021B;LATIN SMALL LETTER T WITH COMMA BELOW;Ll;0;L;0074 0326;;;;N;;;021A;;021A\n021C;LATIN CAPITAL LETTER YOGH;Lu;0;L;;;;;N;;;;021D;\n021D;LATIN SMALL LETTER YOGH;Ll;0;L;;;;;N;;;021C;;021C\n021E;LATIN CAPITAL LETTER H WITH CARON;Lu;0;L;0048 030C;;;;N;;;;021F;\n021F;LATIN SMALL LETTER H WITH CARON;Ll;0;L;0068 030C;;;;N;;;021E;;021E\n0220;LATIN CAPITAL LETTER N WITH LONG RIGHT LEG;Lu;0;L;;;;;N;;;;019E;\n0221;LATIN SMALL LETTER D WITH CURL;Ll;0;L;;;;;N;;;;;\n0222;LATIN CAPITAL LETTER OU;Lu;0;L;;;;;N;;;;0223;\n0223;LATIN SMALL LETTER OU;Ll;0;L;;;;;N;;;0222;;0222\n0224;LATIN CAPITAL LETTER Z WITH HOOK;Lu;0;L;;;;;N;;;;0225;\n0225;LATIN SMALL LETTER Z WITH HOOK;Ll;0;L;;;;;N;;;0224;;0224\n0226;LATIN CAPITAL LETTER A WITH DOT ABOVE;Lu;0;L;0041 0307;;;;N;;;;0227;\n0227;LATIN SMALL LETTER A WITH DOT ABOVE;Ll;0;L;0061 0307;;;;N;;;0226;;0226\n0228;LATIN CAPITAL LETTER E WITH CEDILLA;Lu;0;L;0045 0327;;;;N;;;;0229;\n0229;LATIN SMALL LETTER E WITH CEDILLA;Ll;0;L;0065 0327;;;;N;;;0228;;0228\n022A;LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON;Lu;0;L;00D6 0304;;;;N;;;;022B;\n022B;LATIN SMALL LETTER O WITH DIAERESIS AND MACRON;Ll;0;L;00F6 0304;;;;N;;;022A;;022A\n022C;LATIN CAPITAL LETTER O WITH TILDE AND MACRON;Lu;0;L;00D5 0304;;;;N;;;;022D;\n022D;LATIN SMALL LETTER O WITH TILDE AND MACRON;Ll;0;L;00F5 0304;;;;N;;;022C;;022C\n022E;LATIN CAPITAL LETTER O WITH DOT ABOVE;Lu;0;L;004F 0307;;;;N;;;;022F;\n022F;LATIN SMALL LETTER O WITH DOT ABOVE;Ll;0;L;006F 0307;;;;N;;;022E;;022E\n0230;LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON;Lu;0;L;022E 0304;;;;N;;;;0231;\n0231;LATIN SMALL LETTER O WITH DOT ABOVE AND MACRON;Ll;0;L;022F 0304;;;;N;;;0230;;0230\n0232;LATIN CAPITAL LETTER Y WITH MACRON;Lu;0;L;0059 0304;;;;N;;;;0233;\n0233;LATIN SMALL LETTER Y WITH MACRON;Ll;0;L;0079 0304;;;;N;;;0232;;0232\n0234;LATIN SMALL LETTER L WITH CURL;Ll;0;L;;;;;N;;;;;\n0235;LATIN SMALL LETTER N WITH CURL;Ll;0;L;;;;;N;;;;;\n0236;LATIN SMALL LETTER T WITH CURL;Ll;0;L;;;;;N;;;;;\n0237;LATIN SMALL LETTER DOTLESS J;Ll;0;L;;;;;N;;;;;\n0238;LATIN SMALL LETTER DB DIGRAPH;Ll;0;L;;;;;N;;;;;\n0239;LATIN SMALL LETTER QP DIGRAPH;Ll;0;L;;;;;N;;;;;\n023A;LATIN CAPITAL LETTER A WITH STROKE;Lu;0;L;;;;;N;;;;2C65;\n023B;LATIN CAPITAL LETTER C WITH STROKE;Lu;0;L;;;;;N;;;;023C;\n023C;LATIN SMALL LETTER C WITH STROKE;Ll;0;L;;;;;N;;;023B;;023B\n023D;LATIN CAPITAL LETTER L WITH BAR;Lu;0;L;;;;;N;;;;019A;\n023E;LATIN CAPITAL LETTER T WITH DIAGONAL STROKE;Lu;0;L;;;;;N;;;;2C66;\n023F;LATIN SMALL LETTER S WITH SWASH TAIL;Ll;0;L;;;;;N;;;2C7E;;2C7E\n0240;LATIN SMALL LETTER Z WITH SWASH TAIL;Ll;0;L;;;;;N;;;2C7F;;2C7F\n0241;LATIN CAPITAL LETTER GLOTTAL STOP;Lu;0;L;;;;;N;;;;0242;\n0242;LATIN SMALL LETTER GLOTTAL STOP;Ll;0;L;;;;;N;;;0241;;0241\n0243;LATIN CAPITAL LETTER B WITH STROKE;Lu;0;L;;;;;N;;;;0180;\n0244;LATIN CAPITAL LETTER U BAR;Lu;0;L;;;;;N;;;;0289;\n0245;LATIN CAPITAL LETTER TURNED V;Lu;0;L;;;;;N;;;;028C;\n0246;LATIN CAPITAL LETTER E WITH STROKE;Lu;0;L;;;;;N;;;;0247;\n0247;LATIN SMALL LETTER E WITH STROKE;Ll;0;L;;;;;N;;;0246;;0246\n0248;LATIN CAPITAL LETTER J WITH STROKE;Lu;0;L;;;;;N;;;;0249;\n0249;LATIN SMALL LETTER J WITH STROKE;Ll;0;L;;;;;N;;;0248;;0248\n024A;LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL;Lu;0;L;;;;;N;;;;024B;\n024B;LATIN SMALL LETTER Q WITH HOOK TAIL;Ll;0;L;;;;;N;;;024A;;024A\n024C;LATIN CAPITAL LETTER R WITH STROKE;Lu;0;L;;;;;N;;;;024D;\n024D;LATIN SMALL LETTER R WITH STROKE;Ll;0;L;;;;;N;;;024C;;024C\n024E;LATIN CAPITAL LETTER Y WITH STROKE;Lu;0;L;;;;;N;;;;024F;\n024F;LATIN SMALL LETTER Y WITH STROKE;Ll;0;L;;;;;N;;;024E;;024E\n0250;LATIN SMALL LETTER TURNED A;Ll;0;L;;;;;N;;;2C6F;;2C6F\n0251;LATIN SMALL LETTER ALPHA;Ll;0;L;;;;;N;LATIN SMALL LETTER SCRIPT A;;2C6D;;2C6D\n0252;LATIN SMALL LETTER TURNED ALPHA;Ll;0;L;;;;;N;LATIN SMALL LETTER TURNED SCRIPT A;;2C70;;2C70\n0253;LATIN SMALL LETTER B WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER B HOOK;;0181;;0181\n0254;LATIN SMALL LETTER OPEN O;Ll;0;L;;;;;N;;;0186;;0186\n0255;LATIN SMALL LETTER C WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER C CURL;;;;\n0256;LATIN SMALL LETTER D WITH TAIL;Ll;0;L;;;;;N;LATIN SMALL LETTER D RETROFLEX HOOK;;0189;;0189\n0257;LATIN SMALL LETTER D WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER D HOOK;;018A;;018A\n0258;LATIN SMALL LETTER REVERSED E;Ll;0;L;;;;;N;;;;;\n0259;LATIN SMALL LETTER SCHWA;Ll;0;L;;;;;N;;;018F;;018F\n025A;LATIN SMALL LETTER SCHWA WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER SCHWA HOOK;;;;\n025B;LATIN SMALL LETTER OPEN E;Ll;0;L;;;;;N;LATIN SMALL LETTER EPSILON;;0190;;0190\n025C;LATIN SMALL LETTER REVERSED OPEN E;Ll;0;L;;;;;N;LATIN SMALL LETTER REVERSED EPSILON;;;;\n025D;LATIN SMALL LETTER REVERSED OPEN E WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER REVERSED EPSILON HOOK;;;;\n025E;LATIN SMALL LETTER CLOSED REVERSED OPEN E;Ll;0;L;;;;;N;LATIN SMALL LETTER CLOSED REVERSED EPSILON;;;;\n025F;LATIN SMALL LETTER DOTLESS J WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER DOTLESS J BAR;;;;\n0260;LATIN SMALL LETTER G WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER G HOOK;;0193;;0193\n0261;LATIN SMALL LETTER SCRIPT G;Ll;0;L;;;;;N;;;;;\n0262;LATIN LETTER SMALL CAPITAL G;Ll;0;L;;;;;N;;;;;\n0263;LATIN SMALL LETTER GAMMA;Ll;0;L;;;;;N;;;0194;;0194\n0264;LATIN SMALL LETTER RAMS HORN;Ll;0;L;;;;;N;LATIN SMALL LETTER BABY GAMMA;;;;\n0265;LATIN SMALL LETTER TURNED H;Ll;0;L;;;;;N;;;A78D;;A78D\n0266;LATIN SMALL LETTER H WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER H HOOK;;A7AA;;A7AA\n0267;LATIN SMALL LETTER HENG WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER HENG HOOK;;;;\n0268;LATIN SMALL LETTER I WITH STROKE;Ll;0;L;;;;;N;LATIN SMALL LETTER BARRED I;;0197;;0197\n0269;LATIN SMALL LETTER IOTA;Ll;0;L;;;;;N;;;0196;;0196\n026A;LATIN LETTER SMALL CAPITAL I;Ll;0;L;;;;;N;;;;;\n026B;LATIN SMALL LETTER L WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;2C62;;2C62\n026C;LATIN SMALL LETTER L WITH BELT;Ll;0;L;;;;;N;LATIN SMALL LETTER L BELT;;;;\n026D;LATIN SMALL LETTER L WITH RETROFLEX HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER L RETROFLEX HOOK;;;;\n026E;LATIN SMALL LETTER LEZH;Ll;0;L;;;;;N;LATIN SMALL LETTER L YOGH;;;;\n026F;LATIN SMALL LETTER TURNED M;Ll;0;L;;;;;N;;;019C;;019C\n0270;LATIN SMALL LETTER TURNED M WITH LONG LEG;Ll;0;L;;;;;N;;;;;\n0271;LATIN SMALL LETTER M WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER M HOOK;;2C6E;;2C6E\n0272;LATIN SMALL LETTER N WITH LEFT HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER N HOOK;;019D;;019D\n0273;LATIN SMALL LETTER N WITH RETROFLEX HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER N RETROFLEX HOOK;;;;\n0274;LATIN LETTER SMALL CAPITAL N;Ll;0;L;;;;;N;;;;;\n0275;LATIN SMALL LETTER BARRED O;Ll;0;L;;;;;N;;;019F;;019F\n0276;LATIN LETTER SMALL CAPITAL OE;Ll;0;L;;;;;N;LATIN LETTER SMALL CAPITAL O E;;;;\n0277;LATIN SMALL LETTER CLOSED OMEGA;Ll;0;L;;;;;N;;;;;\n0278;LATIN SMALL LETTER PHI;Ll;0;L;;;;;N;;;;;\n0279;LATIN SMALL LETTER TURNED R;Ll;0;L;;;;;N;;;;;\n027A;LATIN SMALL LETTER TURNED R WITH LONG LEG;Ll;0;L;;;;;N;;;;;\n027B;LATIN SMALL LETTER TURNED R WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER TURNED R HOOK;;;;\n027C;LATIN SMALL LETTER R WITH LONG LEG;Ll;0;L;;;;;N;;;;;\n027D;LATIN SMALL LETTER R WITH TAIL;Ll;0;L;;;;;N;LATIN SMALL LETTER R HOOK;;2C64;;2C64\n027E;LATIN SMALL LETTER R WITH FISHHOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER FISHHOOK R;;;;\n027F;LATIN SMALL LETTER REVERSED R WITH FISHHOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER REVERSED FISHHOOK R;;;;\n0280;LATIN LETTER SMALL CAPITAL R;Ll;0;L;;;;;N;;;01A6;;01A6\n0281;LATIN LETTER SMALL CAPITAL INVERTED R;Ll;0;L;;;;;N;;;;;\n0282;LATIN SMALL LETTER S WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER S HOOK;;;;\n0283;LATIN SMALL LETTER ESH;Ll;0;L;;;;;N;;;01A9;;01A9\n0284;LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER DOTLESS J BAR HOOK;;;;\n0285;LATIN SMALL LETTER SQUAT REVERSED ESH;Ll;0;L;;;;;N;;;;;\n0286;LATIN SMALL LETTER ESH WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER ESH CURL;;;;\n0287;LATIN SMALL LETTER TURNED T;Ll;0;L;;;;;N;;;;;\n0288;LATIN SMALL LETTER T WITH RETROFLEX HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER T RETROFLEX HOOK;;01AE;;01AE\n0289;LATIN SMALL LETTER U BAR;Ll;0;L;;;;;N;;;0244;;0244\n028A;LATIN SMALL LETTER UPSILON;Ll;0;L;;;;;N;;;01B1;;01B1\n028B;LATIN SMALL LETTER V WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER SCRIPT V;;01B2;;01B2\n028C;LATIN SMALL LETTER TURNED V;Ll;0;L;;;;;N;;;0245;;0245\n028D;LATIN SMALL LETTER TURNED W;Ll;0;L;;;;;N;;;;;\n028E;LATIN SMALL LETTER TURNED Y;Ll;0;L;;;;;N;;;;;\n028F;LATIN LETTER SMALL CAPITAL Y;Ll;0;L;;;;;N;;;;;\n0290;LATIN SMALL LETTER Z WITH RETROFLEX HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER Z RETROFLEX HOOK;;;;\n0291;LATIN SMALL LETTER Z WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER Z CURL;;;;\n0292;LATIN SMALL LETTER EZH;Ll;0;L;;;;;N;LATIN SMALL LETTER YOGH;;01B7;;01B7\n0293;LATIN SMALL LETTER EZH WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER YOGH CURL;;;;\n0294;LATIN LETTER GLOTTAL STOP;Lo;0;L;;;;;N;;;;;\n0295;LATIN LETTER PHARYNGEAL VOICED FRICATIVE;Ll;0;L;;;;;N;LATIN LETTER REVERSED GLOTTAL STOP;;;;\n0296;LATIN LETTER INVERTED GLOTTAL STOP;Ll;0;L;;;;;N;;;;;\n0297;LATIN LETTER STRETCHED C;Ll;0;L;;;;;N;;;;;\n0298;LATIN LETTER BILABIAL CLICK;Ll;0;L;;;;;N;LATIN LETTER BULLSEYE;;;;\n0299;LATIN LETTER SMALL CAPITAL B;Ll;0;L;;;;;N;;;;;\n029A;LATIN SMALL LETTER CLOSED OPEN E;Ll;0;L;;;;;N;LATIN SMALL LETTER CLOSED EPSILON;;;;\n029B;LATIN LETTER SMALL CAPITAL G WITH HOOK;Ll;0;L;;;;;N;LATIN LETTER SMALL CAPITAL G HOOK;;;;\n029C;LATIN LETTER SMALL CAPITAL H;Ll;0;L;;;;;N;;;;;\n029D;LATIN SMALL LETTER J WITH CROSSED-TAIL;Ll;0;L;;;;;N;LATIN SMALL LETTER CROSSED-TAIL J;;;;\n029E;LATIN SMALL LETTER TURNED K;Ll;0;L;;;;;N;;;;;\n029F;LATIN LETTER SMALL CAPITAL L;Ll;0;L;;;;;N;;;;;\n02A0;LATIN SMALL LETTER Q WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER Q HOOK;;;;\n02A1;LATIN LETTER GLOTTAL STOP WITH STROKE;Ll;0;L;;;;;N;LATIN LETTER GLOTTAL STOP BAR;;;;\n02A2;LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE;Ll;0;L;;;;;N;LATIN LETTER REVERSED GLOTTAL STOP BAR;;;;\n02A3;LATIN SMALL LETTER DZ DIGRAPH;Ll;0;L;;;;;N;LATIN SMALL LETTER D Z;;;;\n02A4;LATIN SMALL LETTER DEZH DIGRAPH;Ll;0;L;;;;;N;LATIN SMALL LETTER D YOGH;;;;\n02A5;LATIN SMALL LETTER DZ DIGRAPH WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER D Z CURL;;;;\n02A6;LATIN SMALL LETTER TS DIGRAPH;Ll;0;L;;;;;N;LATIN SMALL LETTER T S;;;;\n02A7;LATIN SMALL LETTER TESH DIGRAPH;Ll;0;L;;;;;N;LATIN SMALL LETTER T ESH;;;;\n02A8;LATIN SMALL LETTER TC DIGRAPH WITH CURL;Ll;0;L;;;;;N;LATIN SMALL LETTER T C CURL;;;;\n02A9;LATIN SMALL LETTER FENG DIGRAPH;Ll;0;L;;;;;N;;;;;\n02AA;LATIN SMALL LETTER LS DIGRAPH;Ll;0;L;;;;;N;;;;;\n02AB;LATIN SMALL LETTER LZ DIGRAPH;Ll;0;L;;;;;N;;;;;\n02AC;LATIN LETTER BILABIAL PERCUSSIVE;Ll;0;L;;;;;N;;;;;\n02AD;LATIN LETTER BIDENTAL PERCUSSIVE;Ll;0;L;;;;;N;;;;;\n02AE;LATIN SMALL LETTER TURNED H WITH FISHHOOK;Ll;0;L;;;;;N;;;;;\n02AF;LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL;Ll;0;L;;;;;N;;;;;\n02B0;MODIFIER LETTER SMALL H;Lm;0;L;<super> 0068;;;;N;;;;;\n02B1;MODIFIER LETTER SMALL H WITH HOOK;Lm;0;L;<super> 0266;;;;N;MODIFIER LETTER SMALL H HOOK;;;;\n02B2;MODIFIER LETTER SMALL J;Lm;0;L;<super> 006A;;;;N;;;;;\n02B3;MODIFIER LETTER SMALL R;Lm;0;L;<super> 0072;;;;N;;;;;\n02B4;MODIFIER LETTER SMALL TURNED R;Lm;0;L;<super> 0279;;;;N;;;;;\n02B5;MODIFIER LETTER SMALL TURNED R WITH HOOK;Lm;0;L;<super> 027B;;;;N;MODIFIER LETTER SMALL TURNED R HOOK;;;;\n02B6;MODIFIER LETTER SMALL CAPITAL INVERTED R;Lm;0;L;<super> 0281;;;;N;;;;;\n02B7;MODIFIER LETTER SMALL W;Lm;0;L;<super> 0077;;;;N;;;;;\n02B8;MODIFIER LETTER SMALL Y;Lm;0;L;<super> 0079;;;;N;;;;;\n02B9;MODIFIER LETTER PRIME;Lm;0;ON;;;;;N;;;;;\n02BA;MODIFIER LETTER DOUBLE PRIME;Lm;0;ON;;;;;N;;;;;\n02BB;MODIFIER LETTER TURNED COMMA;Lm;0;L;;;;;N;;;;;\n02BC;MODIFIER LETTER APOSTROPHE;Lm;0;L;;;;;N;;;;;\n02BD;MODIFIER LETTER REVERSED COMMA;Lm;0;L;;;;;N;;;;;\n02BE;MODIFIER LETTER RIGHT HALF RING;Lm;0;L;;;;;N;;;;;\n02BF;MODIFIER LETTER LEFT HALF RING;Lm;0;L;;;;;N;;;;;\n02C0;MODIFIER LETTER GLOTTAL STOP;Lm;0;L;;;;;N;;;;;\n02C1;MODIFIER LETTER REVERSED GLOTTAL STOP;Lm;0;L;;;;;N;;;;;\n02C2;MODIFIER LETTER LEFT ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02C3;MODIFIER LETTER RIGHT ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02C4;MODIFIER LETTER UP ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02C5;MODIFIER LETTER DOWN ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02C6;MODIFIER LETTER CIRCUMFLEX ACCENT;Lm;0;ON;;;;;N;MODIFIER LETTER CIRCUMFLEX;;;;\n02C7;CARON;Lm;0;ON;;;;;N;MODIFIER LETTER HACEK;;;;\n02C8;MODIFIER LETTER VERTICAL LINE;Lm;0;ON;;;;;N;;;;;\n02C9;MODIFIER LETTER MACRON;Lm;0;ON;;;;;N;;;;;\n02CA;MODIFIER LETTER ACUTE ACCENT;Lm;0;ON;;;;;N;MODIFIER LETTER ACUTE;;;;\n02CB;MODIFIER LETTER GRAVE ACCENT;Lm;0;ON;;;;;N;MODIFIER LETTER GRAVE;;;;\n02CC;MODIFIER LETTER LOW VERTICAL LINE;Lm;0;ON;;;;;N;;;;;\n02CD;MODIFIER LETTER LOW MACRON;Lm;0;ON;;;;;N;;;;;\n02CE;MODIFIER LETTER LOW GRAVE ACCENT;Lm;0;ON;;;;;N;MODIFIER LETTER LOW GRAVE;;;;\n02CF;MODIFIER LETTER LOW ACUTE ACCENT;Lm;0;ON;;;;;N;MODIFIER LETTER LOW ACUTE;;;;\n02D0;MODIFIER LETTER TRIANGULAR COLON;Lm;0;L;;;;;N;;;;;\n02D1;MODIFIER LETTER HALF TRIANGULAR COLON;Lm;0;L;;;;;N;;;;;\n02D2;MODIFIER LETTER CENTRED RIGHT HALF RING;Sk;0;ON;;;;;N;MODIFIER LETTER CENTERED RIGHT HALF RING;;;;\n02D3;MODIFIER LETTER CENTRED LEFT HALF RING;Sk;0;ON;;;;;N;MODIFIER LETTER CENTERED LEFT HALF RING;;;;\n02D4;MODIFIER LETTER UP TACK;Sk;0;ON;;;;;N;;;;;\n02D5;MODIFIER LETTER DOWN TACK;Sk;0;ON;;;;;N;;;;;\n02D6;MODIFIER LETTER PLUS SIGN;Sk;0;ON;;;;;N;;;;;\n02D7;MODIFIER LETTER MINUS SIGN;Sk;0;ON;;;;;N;;;;;\n02D8;BREVE;Sk;0;ON;<compat> 0020 0306;;;;N;SPACING BREVE;;;;\n02D9;DOT ABOVE;Sk;0;ON;<compat> 0020 0307;;;;N;SPACING DOT ABOVE;;;;\n02DA;RING ABOVE;Sk;0;ON;<compat> 0020 030A;;;;N;SPACING RING ABOVE;;;;\n02DB;OGONEK;Sk;0;ON;<compat> 0020 0328;;;;N;SPACING OGONEK;;;;\n02DC;SMALL TILDE;Sk;0;ON;<compat> 0020 0303;;;;N;SPACING TILDE;;;;\n02DD;DOUBLE ACUTE ACCENT;Sk;0;ON;<compat> 0020 030B;;;;N;SPACING DOUBLE ACUTE;;;;\n02DE;MODIFIER LETTER RHOTIC HOOK;Sk;0;ON;;;;;N;;;;;\n02DF;MODIFIER LETTER CROSS ACCENT;Sk;0;ON;;;;;N;;;;;\n02E0;MODIFIER LETTER SMALL GAMMA;Lm;0;L;<super> 0263;;;;N;;;;;\n02E1;MODIFIER LETTER SMALL L;Lm;0;L;<super> 006C;;;;N;;;;;\n02E2;MODIFIER LETTER SMALL S;Lm;0;L;<super> 0073;;;;N;;;;;\n02E3;MODIFIER LETTER SMALL X;Lm;0;L;<super> 0078;;;;N;;;;;\n02E4;MODIFIER LETTER SMALL REVERSED GLOTTAL STOP;Lm;0;L;<super> 0295;;;;N;;;;;\n02E5;MODIFIER LETTER EXTRA-HIGH TONE BAR;Sk;0;ON;;;;;N;;;;;\n02E6;MODIFIER LETTER HIGH TONE BAR;Sk;0;ON;;;;;N;;;;;\n02E7;MODIFIER LETTER MID TONE BAR;Sk;0;ON;;;;;N;;;;;\n02E8;MODIFIER LETTER LOW TONE BAR;Sk;0;ON;;;;;N;;;;;\n02E9;MODIFIER LETTER EXTRA-LOW TONE BAR;Sk;0;ON;;;;;N;;;;;\n02EA;MODIFIER LETTER YIN DEPARTING TONE MARK;Sk;0;ON;;;;;N;;;;;\n02EB;MODIFIER LETTER YANG DEPARTING TONE MARK;Sk;0;ON;;;;;N;;;;;\n02EC;MODIFIER LETTER VOICING;Lm;0;ON;;;;;N;;;;;\n02ED;MODIFIER LETTER UNASPIRATED;Sk;0;ON;;;;;N;;;;;\n02EE;MODIFIER LETTER DOUBLE APOSTROPHE;Lm;0;L;;;;;N;;;;;\n02EF;MODIFIER LETTER LOW DOWN ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02F0;MODIFIER LETTER LOW UP ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02F1;MODIFIER LETTER LOW LEFT ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02F2;MODIFIER LETTER LOW RIGHT ARROWHEAD;Sk;0;ON;;;;;N;;;;;\n02F3;MODIFIER LETTER LOW RING;Sk;0;ON;;;;;N;;;;;\n02F4;MODIFIER LETTER MIDDLE GRAVE ACCENT;Sk;0;ON;;;;;N;;;;;\n02F5;MODIFIER LETTER MIDDLE DOUBLE GRAVE ACCENT;Sk;0;ON;;;;;N;;;;;\n02F6;MODIFIER LETTER MIDDLE DOUBLE ACUTE ACCENT;Sk;0;ON;;;;;N;;;;;\n02F7;MODIFIER LETTER LOW TILDE;Sk;0;ON;;;;;N;;;;;\n02F8;MODIFIER LETTER RAISED COLON;Sk;0;ON;;;;;N;;;;;\n02F9;MODIFIER LETTER BEGIN HIGH TONE;Sk;0;ON;;;;;N;;;;;\n02FA;MODIFIER LETTER END HIGH TONE;Sk;0;ON;;;;;N;;;;;\n02FB;MODIFIER LETTER BEGIN LOW TONE;Sk;0;ON;;;;;N;;;;;\n02FC;MODIFIER LETTER END LOW TONE;Sk;0;ON;;;;;N;;;;;\n02FD;MODIFIER LETTER SHELF;Sk;0;ON;;;;;N;;;;;\n02FE;MODIFIER LETTER OPEN SHELF;Sk;0;ON;;;;;N;;;;;\n02FF;MODIFIER LETTER LOW LEFT ARROW;Sk;0;ON;;;;;N;;;;;\n0300;COMBINING GRAVE ACCENT;Mn;230;NSM;;;;;N;NON-SPACING GRAVE;;;;\n0301;COMBINING ACUTE ACCENT;Mn;230;NSM;;;;;N;NON-SPACING ACUTE;;;;\n0302;COMBINING CIRCUMFLEX ACCENT;Mn;230;NSM;;;;;N;NON-SPACING CIRCUMFLEX;;;;\n0303;COMBINING TILDE;Mn;230;NSM;;;;;N;NON-SPACING TILDE;;;;\n0304;COMBINING MACRON;Mn;230;NSM;;;;;N;NON-SPACING MACRON;;;;\n0305;COMBINING OVERLINE;Mn;230;NSM;;;;;N;NON-SPACING OVERSCORE;;;;\n0306;COMBINING BREVE;Mn;230;NSM;;;;;N;NON-SPACING BREVE;;;;\n0307;COMBINING DOT ABOVE;Mn;230;NSM;;;;;N;NON-SPACING DOT ABOVE;;;;\n0308;COMBINING DIAERESIS;Mn;230;NSM;;;;;N;NON-SPACING DIAERESIS;;;;\n0309;COMBINING HOOK ABOVE;Mn;230;NSM;;;;;N;NON-SPACING HOOK ABOVE;;;;\n030A;COMBINING RING ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RING ABOVE;;;;\n030B;COMBINING DOUBLE ACUTE ACCENT;Mn;230;NSM;;;;;N;NON-SPACING DOUBLE ACUTE;;;;\n030C;COMBINING CARON;Mn;230;NSM;;;;;N;NON-SPACING HACEK;;;;\n030D;COMBINING VERTICAL LINE ABOVE;Mn;230;NSM;;;;;N;NON-SPACING VERTICAL LINE ABOVE;;;;\n030E;COMBINING DOUBLE VERTICAL LINE ABOVE;Mn;230;NSM;;;;;N;NON-SPACING DOUBLE VERTICAL LINE ABOVE;;;;\n030F;COMBINING DOUBLE GRAVE ACCENT;Mn;230;NSM;;;;;N;NON-SPACING DOUBLE GRAVE;;;;\n0310;COMBINING CANDRABINDU;Mn;230;NSM;;;;;N;NON-SPACING CANDRABINDU;;;;\n0311;COMBINING INVERTED BREVE;Mn;230;NSM;;;;;N;NON-SPACING INVERTED BREVE;;;;\n0312;COMBINING TURNED COMMA ABOVE;Mn;230;NSM;;;;;N;NON-SPACING TURNED COMMA ABOVE;;;;\n0313;COMBINING COMMA ABOVE;Mn;230;NSM;;;;;N;NON-SPACING COMMA ABOVE;;;;\n0314;COMBINING REVERSED COMMA ABOVE;Mn;230;NSM;;;;;N;NON-SPACING REVERSED COMMA ABOVE;;;;\n0315;COMBINING COMMA ABOVE RIGHT;Mn;232;NSM;;;;;N;NON-SPACING COMMA ABOVE RIGHT;;;;\n0316;COMBINING GRAVE ACCENT BELOW;Mn;220;NSM;;;;;N;NON-SPACING GRAVE BELOW;;;;\n0317;COMBINING ACUTE ACCENT BELOW;Mn;220;NSM;;;;;N;NON-SPACING ACUTE BELOW;;;;\n0318;COMBINING LEFT TACK BELOW;Mn;220;NSM;;;;;N;NON-SPACING LEFT TACK BELOW;;;;\n0319;COMBINING RIGHT TACK BELOW;Mn;220;NSM;;;;;N;NON-SPACING RIGHT TACK BELOW;;;;\n031A;COMBINING LEFT ANGLE ABOVE;Mn;232;NSM;;;;;N;NON-SPACING LEFT ANGLE ABOVE;;;;\n031B;COMBINING HORN;Mn;216;NSM;;;;;N;NON-SPACING HORN;;;;\n031C;COMBINING LEFT HALF RING BELOW;Mn;220;NSM;;;;;N;NON-SPACING LEFT HALF RING BELOW;;;;\n031D;COMBINING UP TACK BELOW;Mn;220;NSM;;;;;N;NON-SPACING UP TACK BELOW;;;;\n031E;COMBINING DOWN TACK BELOW;Mn;220;NSM;;;;;N;NON-SPACING DOWN TACK BELOW;;;;\n031F;COMBINING PLUS SIGN BELOW;Mn;220;NSM;;;;;N;NON-SPACING PLUS SIGN BELOW;;;;\n0320;COMBINING MINUS SIGN BELOW;Mn;220;NSM;;;;;N;NON-SPACING MINUS SIGN BELOW;;;;\n0321;COMBINING PALATALIZED HOOK BELOW;Mn;202;NSM;;;;;N;NON-SPACING PALATALIZED HOOK BELOW;;;;\n0322;COMBINING RETROFLEX HOOK BELOW;Mn;202;NSM;;;;;N;NON-SPACING RETROFLEX HOOK BELOW;;;;\n0323;COMBINING DOT BELOW;Mn;220;NSM;;;;;N;NON-SPACING DOT BELOW;;;;\n0324;COMBINING DIAERESIS BELOW;Mn;220;NSM;;;;;N;NON-SPACING DOUBLE DOT BELOW;;;;\n0325;COMBINING RING BELOW;Mn;220;NSM;;;;;N;NON-SPACING RING BELOW;;;;\n0326;COMBINING COMMA BELOW;Mn;220;NSM;;;;;N;NON-SPACING COMMA BELOW;;;;\n0327;COMBINING CEDILLA;Mn;202;NSM;;;;;N;NON-SPACING CEDILLA;;;;\n0328;COMBINING OGONEK;Mn;202;NSM;;;;;N;NON-SPACING OGONEK;;;;\n0329;COMBINING VERTICAL LINE BELOW;Mn;220;NSM;;;;;N;NON-SPACING VERTICAL LINE BELOW;;;;\n032A;COMBINING BRIDGE BELOW;Mn;220;NSM;;;;;N;NON-SPACING BRIDGE BELOW;;;;\n032B;COMBINING INVERTED DOUBLE ARCH BELOW;Mn;220;NSM;;;;;N;NON-SPACING INVERTED DOUBLE ARCH BELOW;;;;\n032C;COMBINING CARON BELOW;Mn;220;NSM;;;;;N;NON-SPACING HACEK BELOW;;;;\n032D;COMBINING CIRCUMFLEX ACCENT BELOW;Mn;220;NSM;;;;;N;NON-SPACING CIRCUMFLEX BELOW;;;;\n032E;COMBINING BREVE BELOW;Mn;220;NSM;;;;;N;NON-SPACING BREVE BELOW;;;;\n032F;COMBINING INVERTED BREVE BELOW;Mn;220;NSM;;;;;N;NON-SPACING INVERTED BREVE BELOW;;;;\n0330;COMBINING TILDE BELOW;Mn;220;NSM;;;;;N;NON-SPACING TILDE BELOW;;;;\n0331;COMBINING MACRON BELOW;Mn;220;NSM;;;;;N;NON-SPACING MACRON BELOW;;;;\n0332;COMBINING LOW LINE;Mn;220;NSM;;;;;N;NON-SPACING UNDERSCORE;;;;\n0333;COMBINING DOUBLE LOW LINE;Mn;220;NSM;;;;;N;NON-SPACING DOUBLE UNDERSCORE;;;;\n0334;COMBINING TILDE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING TILDE OVERLAY;;;;\n0335;COMBINING SHORT STROKE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING SHORT BAR OVERLAY;;;;\n0336;COMBINING LONG STROKE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG BAR OVERLAY;;;;\n0337;COMBINING SHORT SOLIDUS OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING SHORT SLASH OVERLAY;;;;\n0338;COMBINING LONG SOLIDUS OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG SLASH OVERLAY;;;;\n0339;COMBINING RIGHT HALF RING BELOW;Mn;220;NSM;;;;;N;NON-SPACING RIGHT HALF RING BELOW;;;;\n033A;COMBINING INVERTED BRIDGE BELOW;Mn;220;NSM;;;;;N;NON-SPACING INVERTED BRIDGE BELOW;;;;\n033B;COMBINING SQUARE BELOW;Mn;220;NSM;;;;;N;NON-SPACING SQUARE BELOW;;;;\n033C;COMBINING SEAGULL BELOW;Mn;220;NSM;;;;;N;NON-SPACING SEAGULL BELOW;;;;\n033D;COMBINING X ABOVE;Mn;230;NSM;;;;;N;NON-SPACING X ABOVE;;;;\n033E;COMBINING VERTICAL TILDE;Mn;230;NSM;;;;;N;NON-SPACING VERTICAL TILDE;;;;\n033F;COMBINING DOUBLE OVERLINE;Mn;230;NSM;;;;;N;NON-SPACING DOUBLE OVERSCORE;;;;\n0340;COMBINING GRAVE TONE MARK;Mn;230;NSM;0300;;;;N;NON-SPACING GRAVE TONE MARK;;;;\n0341;COMBINING ACUTE TONE MARK;Mn;230;NSM;0301;;;;N;NON-SPACING ACUTE TONE MARK;;;;\n0342;COMBINING GREEK PERISPOMENI;Mn;230;NSM;;;;;N;;;;;\n0343;COMBINING GREEK KORONIS;Mn;230;NSM;0313;;;;N;;;;;\n0344;COMBINING GREEK DIALYTIKA TONOS;Mn;230;NSM;0308 0301;;;;N;GREEK NON-SPACING DIAERESIS TONOS;;;;\n0345;COMBINING GREEK YPOGEGRAMMENI;Mn;240;NSM;;;;;N;GREEK NON-SPACING IOTA BELOW;;0399;;0399\n0346;COMBINING BRIDGE ABOVE;Mn;230;NSM;;;;;N;;;;;\n0347;COMBINING EQUALS SIGN BELOW;Mn;220;NSM;;;;;N;;;;;\n0348;COMBINING DOUBLE VERTICAL LINE BELOW;Mn;220;NSM;;;;;N;;;;;\n0349;COMBINING LEFT ANGLE BELOW;Mn;220;NSM;;;;;N;;;;;\n034A;COMBINING NOT TILDE ABOVE;Mn;230;NSM;;;;;N;;;;;\n034B;COMBINING HOMOTHETIC ABOVE;Mn;230;NSM;;;;;N;;;;;\n034C;COMBINING ALMOST EQUAL TO ABOVE;Mn;230;NSM;;;;;N;;;;;\n034D;COMBINING LEFT RIGHT ARROW BELOW;Mn;220;NSM;;;;;N;;;;;\n034E;COMBINING UPWARDS ARROW BELOW;Mn;220;NSM;;;;;N;;;;;\n034F;COMBINING GRAPHEME JOINER;Mn;0;NSM;;;;;N;;;;;\n0350;COMBINING RIGHT ARROWHEAD ABOVE;Mn;230;NSM;;;;;N;;;;;\n0351;COMBINING LEFT HALF RING ABOVE;Mn;230;NSM;;;;;N;;;;;\n0352;COMBINING FERMATA;Mn;230;NSM;;;;;N;;;;;\n0353;COMBINING X BELOW;Mn;220;NSM;;;;;N;;;;;\n0354;COMBINING LEFT ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n0355;COMBINING RIGHT ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n0356;COMBINING RIGHT ARROWHEAD AND UP ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n0357;COMBINING RIGHT HALF RING ABOVE;Mn;230;NSM;;;;;N;;;;;\n0358;COMBINING DOT ABOVE RIGHT;Mn;232;NSM;;;;;N;;;;;\n0359;COMBINING ASTERISK BELOW;Mn;220;NSM;;;;;N;;;;;\n035A;COMBINING DOUBLE RING BELOW;Mn;220;NSM;;;;;N;;;;;\n035B;COMBINING ZIGZAG ABOVE;Mn;230;NSM;;;;;N;;;;;\n035C;COMBINING DOUBLE BREVE BELOW;Mn;233;NSM;;;;;N;;;;;\n035D;COMBINING DOUBLE BREVE;Mn;234;NSM;;;;;N;;;;;\n035E;COMBINING DOUBLE MACRON;Mn;234;NSM;;;;;N;;;;;\n035F;COMBINING DOUBLE MACRON BELOW;Mn;233;NSM;;;;;N;;;;;\n0360;COMBINING DOUBLE TILDE;Mn;234;NSM;;;;;N;;;;;\n0361;COMBINING DOUBLE INVERTED BREVE;Mn;234;NSM;;;;;N;;;;;\n0362;COMBINING DOUBLE RIGHTWARDS ARROW BELOW;Mn;233;NSM;;;;;N;;;;;\n0363;COMBINING LATIN SMALL LETTER A;Mn;230;NSM;;;;;N;;;;;\n0364;COMBINING LATIN SMALL LETTER E;Mn;230;NSM;;;;;N;;;;;\n0365;COMBINING LATIN SMALL LETTER I;Mn;230;NSM;;;;;N;;;;;\n0366;COMBINING LATIN SMALL LETTER O;Mn;230;NSM;;;;;N;;;;;\n0367;COMBINING LATIN SMALL LETTER U;Mn;230;NSM;;;;;N;;;;;\n0368;COMBINING LATIN SMALL LETTER C;Mn;230;NSM;;;;;N;;;;;\n0369;COMBINING LATIN SMALL LETTER D;Mn;230;NSM;;;;;N;;;;;\n036A;COMBINING LATIN SMALL LETTER H;Mn;230;NSM;;;;;N;;;;;\n036B;COMBINING LATIN SMALL LETTER M;Mn;230;NSM;;;;;N;;;;;\n036C;COMBINING LATIN SMALL LETTER R;Mn;230;NSM;;;;;N;;;;;\n036D;COMBINING LATIN SMALL LETTER T;Mn;230;NSM;;;;;N;;;;;\n036E;COMBINING LATIN SMALL LETTER V;Mn;230;NSM;;;;;N;;;;;\n036F;COMBINING LATIN SMALL LETTER X;Mn;230;NSM;;;;;N;;;;;\n0370;GREEK CAPITAL LETTER HETA;Lu;0;L;;;;;N;;;;0371;\n0371;GREEK SMALL LETTER HETA;Ll;0;L;;;;;N;;;0370;;0370\n0372;GREEK CAPITAL LETTER ARCHAIC SAMPI;Lu;0;L;;;;;N;;;;0373;\n0373;GREEK SMALL LETTER ARCHAIC SAMPI;Ll;0;L;;;;;N;;;0372;;0372\n0374;GREEK NUMERAL SIGN;Lm;0;ON;02B9;;;;N;GREEK UPPER NUMERAL SIGN;;;;\n0375;GREEK LOWER NUMERAL SIGN;Sk;0;ON;;;;;N;;;;;\n0376;GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA;Lu;0;L;;;;;N;;;;0377;\n0377;GREEK SMALL LETTER PAMPHYLIAN DIGAMMA;Ll;0;L;;;;;N;;;0376;;0376\n037A;GREEK YPOGEGRAMMENI;Lm;0;L;<compat> 0020 0345;;;;N;GREEK SPACING IOTA BELOW;;;;\n037B;GREEK SMALL REVERSED LUNATE SIGMA SYMBOL;Ll;0;L;;;;;N;;;03FD;;03FD\n037C;GREEK SMALL DOTTED LUNATE SIGMA SYMBOL;Ll;0;L;;;;;N;;;03FE;;03FE\n037D;GREEK SMALL REVERSED DOTTED LUNATE SIGMA SYMBOL;Ll;0;L;;;;;N;;;03FF;;03FF\n037E;GREEK QUESTION MARK;Po;0;ON;003B;;;;N;;;;;\n0384;GREEK TONOS;Sk;0;ON;<compat> 0020 0301;;;;N;GREEK SPACING TONOS;;;;\n0385;GREEK DIALYTIKA TONOS;Sk;0;ON;00A8 0301;;;;N;GREEK SPACING DIAERESIS TONOS;;;;\n0386;GREEK CAPITAL LETTER ALPHA WITH TONOS;Lu;0;L;0391 0301;;;;N;GREEK CAPITAL LETTER ALPHA TONOS;;;03AC;\n0387;GREEK ANO TELEIA;Po;0;ON;00B7;;;;N;;;;;\n0388;GREEK CAPITAL LETTER EPSILON WITH TONOS;Lu;0;L;0395 0301;;;;N;GREEK CAPITAL LETTER EPSILON TONOS;;;03AD;\n0389;GREEK CAPITAL LETTER ETA WITH TONOS;Lu;0;L;0397 0301;;;;N;GREEK CAPITAL LETTER ETA TONOS;;;03AE;\n038A;GREEK CAPITAL LETTER IOTA WITH TONOS;Lu;0;L;0399 0301;;;;N;GREEK CAPITAL LETTER IOTA TONOS;;;03AF;\n038C;GREEK CAPITAL LETTER OMICRON WITH TONOS;Lu;0;L;039F 0301;;;;N;GREEK CAPITAL LETTER OMICRON TONOS;;;03CC;\n038E;GREEK CAPITAL LETTER UPSILON WITH TONOS;Lu;0;L;03A5 0301;;;;N;GREEK CAPITAL LETTER UPSILON TONOS;;;03CD;\n038F;GREEK CAPITAL LETTER OMEGA WITH TONOS;Lu;0;L;03A9 0301;;;;N;GREEK CAPITAL LETTER OMEGA TONOS;;;03CE;\n0390;GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS;Ll;0;L;03CA 0301;;;;N;GREEK SMALL LETTER IOTA DIAERESIS TONOS;;;;\n0391;GREEK CAPITAL LETTER ALPHA;Lu;0;L;;;;;N;;;;03B1;\n0392;GREEK CAPITAL LETTER BETA;Lu;0;L;;;;;N;;;;03B2;\n0393;GREEK CAPITAL LETTER GAMMA;Lu;0;L;;;;;N;;;;03B3;\n0394;GREEK CAPITAL LETTER DELTA;Lu;0;L;;;;;N;;;;03B4;\n0395;GREEK CAPITAL LETTER EPSILON;Lu;0;L;;;;;N;;;;03B5;\n0396;GREEK CAPITAL LETTER ZETA;Lu;0;L;;;;;N;;;;03B6;\n0397;GREEK CAPITAL LETTER ETA;Lu;0;L;;;;;N;;;;03B7;\n0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;\n0399;GREEK CAPITAL LETTER IOTA;Lu;0;L;;;;;N;;;;03B9;\n039A;GREEK CAPITAL LETTER KAPPA;Lu;0;L;;;;;N;;;;03BA;\n039B;GREEK CAPITAL LETTER LAMDA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER LAMBDA;;;03BB;\n039C;GREEK CAPITAL LETTER MU;Lu;0;L;;;;;N;;;;03BC;\n039D;GREEK CAPITAL LETTER NU;Lu;0;L;;;;;N;;;;03BD;\n039E;GREEK CAPITAL LETTER XI;Lu;0;L;;;;;N;;;;03BE;\n039F;GREEK CAPITAL LETTER OMICRON;Lu;0;L;;;;;N;;;;03BF;\n03A0;GREEK CAPITAL LETTER PI;Lu;0;L;;;;;N;;;;03C0;\n03A1;GREEK CAPITAL LETTER RHO;Lu;0;L;;;;;N;;;;03C1;\n03A3;GREEK CAPITAL LETTER SIGMA;Lu;0;L;;;;;N;;;;03C3;\n03A4;GREEK CAPITAL LETTER TAU;Lu;0;L;;;;;N;;;;03C4;\n03A5;GREEK CAPITAL LETTER UPSILON;Lu;0;L;;;;;N;;;;03C5;\n03A6;GREEK CAPITAL LETTER PHI;Lu;0;L;;;;;N;;;;03C6;\n03A7;GREEK CAPITAL LETTER CHI;Lu;0;L;;;;;N;;;;03C7;\n03A8;GREEK CAPITAL LETTER PSI;Lu;0;L;;;;;N;;;;03C8;\n03A9;GREEK CAPITAL LETTER OMEGA;Lu;0;L;;;;;N;;;;03C9;\n03AA;GREEK CAPITAL LETTER IOTA WITH DIALYTIKA;Lu;0;L;0399 0308;;;;N;GREEK CAPITAL LETTER IOTA DIAERESIS;;;03CA;\n03AB;GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA;Lu;0;L;03A5 0308;;;;N;GREEK CAPITAL LETTER UPSILON DIAERESIS;;;03CB;\n03AC;GREEK SMALL LETTER ALPHA WITH TONOS;Ll;0;L;03B1 0301;;;;N;GREEK SMALL LETTER ALPHA TONOS;;0386;;0386\n03AD;GREEK SMALL LETTER EPSILON WITH TONOS;Ll;0;L;03B5 0301;;;;N;GREEK SMALL LETTER EPSILON TONOS;;0388;;0388\n03AE;GREEK SMALL LETTER ETA WITH TONOS;Ll;0;L;03B7 0301;;;;N;GREEK SMALL LETTER ETA TONOS;;0389;;0389\n03AF;GREEK SMALL LETTER IOTA WITH TONOS;Ll;0;L;03B9 0301;;;;N;GREEK SMALL LETTER IOTA TONOS;;038A;;038A\n03B0;GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS;Ll;0;L;03CB 0301;;;;N;GREEK SMALL LETTER UPSILON DIAERESIS TONOS;;;;\n03B1;GREEK SMALL LETTER ALPHA;Ll;0;L;;;;;N;;;0391;;0391\n03B2;GREEK SMALL LETTER BETA;Ll;0;L;;;;;N;;;0392;;0392\n03B3;GREEK SMALL LETTER GAMMA;Ll;0;L;;;;;N;;;0393;;0393\n03B4;GREEK SMALL LETTER DELTA;Ll;0;L;;;;;N;;;0394;;0394\n03B5;GREEK SMALL LETTER EPSILON;Ll;0;L;;;;;N;;;0395;;0395\n03B6;GREEK SMALL LETTER ZETA;Ll;0;L;;;;;N;;;0396;;0396\n03B7;GREEK SMALL LETTER ETA;Ll;0;L;;;;;N;;;0397;;0397\n03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398\n03B9;GREEK SMALL LETTER IOTA;Ll;0;L;;;;;N;;;0399;;0399\n03BA;GREEK SMALL LETTER KAPPA;Ll;0;L;;;;;N;;;039A;;039A\n03BB;GREEK SMALL LETTER LAMDA;Ll;0;L;;;;;N;GREEK SMALL LETTER LAMBDA;;039B;;039B\n03BC;GREEK SMALL LETTER MU;Ll;0;L;;;;;N;;;039C;;039C\n03BD;GREEK SMALL LETTER NU;Ll;0;L;;;;;N;;;039D;;039D\n03BE;GREEK SMALL LETTER XI;Ll;0;L;;;;;N;;;039E;;039E\n03BF;GREEK SMALL LETTER OMICRON;Ll;0;L;;;;;N;;;039F;;039F\n03C0;GREEK SMALL LETTER PI;Ll;0;L;;;;;N;;;03A0;;03A0\n03C1;GREEK SMALL LETTER RHO;Ll;0;L;;;;;N;;;03A1;;03A1\n03C2;GREEK SMALL LETTER FINAL SIGMA;Ll;0;L;;;;;N;;;03A3;;03A3\n03C3;GREEK SMALL LETTER SIGMA;Ll;0;L;;;;;N;;;03A3;;03A3\n03C4;GREEK SMALL LETTER TAU;Ll;0;L;;;;;N;;;03A4;;03A4\n03C5;GREEK SMALL LETTER UPSILON;Ll;0;L;;;;;N;;;03A5;;03A5\n03C6;GREEK SMALL LETTER PHI;Ll;0;L;;;;;N;;;03A6;;03A6\n03C7;GREEK SMALL LETTER CHI;Ll;0;L;;;;;N;;;03A7;;03A7\n03C8;GREEK SMALL LETTER PSI;Ll;0;L;;;;;N;;;03A8;;03A8\n03C9;GREEK SMALL LETTER OMEGA;Ll;0;L;;;;;N;;;03A9;;03A9\n03CA;GREEK SMALL LETTER IOTA WITH DIALYTIKA;Ll;0;L;03B9 0308;;;;N;GREEK SMALL LETTER IOTA DIAERESIS;;03AA;;03AA\n03CB;GREEK SMALL LETTER UPSILON WITH DIALYTIKA;Ll;0;L;03C5 0308;;;;N;GREEK SMALL LETTER UPSILON DIAERESIS;;03AB;;03AB\n03CC;GREEK SMALL LETTER OMICRON WITH TONOS;Ll;0;L;03BF 0301;;;;N;GREEK SMALL LETTER OMICRON TONOS;;038C;;038C\n03CD;GREEK SMALL LETTER UPSILON WITH TONOS;Ll;0;L;03C5 0301;;;;N;GREEK SMALL LETTER UPSILON TONOS;;038E;;038E\n03CE;GREEK SMALL LETTER OMEGA WITH TONOS;Ll;0;L;03C9 0301;;;;N;GREEK SMALL LETTER OMEGA TONOS;;038F;;038F\n03CF;GREEK CAPITAL KAI SYMBOL;Lu;0;L;;;;;N;;;;03D7;\n03D0;GREEK BETA SYMBOL;Ll;0;L;<compat> 03B2;;;;N;GREEK SMALL LETTER CURLED BETA;;0392;;0392\n03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398\n03D2;GREEK UPSILON WITH HOOK SYMBOL;Lu;0;L;<compat> 03A5;;;;N;GREEK CAPITAL LETTER UPSILON HOOK;;;;\n03D3;GREEK UPSILON WITH ACUTE AND HOOK SYMBOL;Lu;0;L;03D2 0301;;;;N;GREEK CAPITAL LETTER UPSILON HOOK TONOS;;;;\n03D4;GREEK UPSILON WITH DIAERESIS AND HOOK SYMBOL;Lu;0;L;03D2 0308;;;;N;GREEK CAPITAL LETTER UPSILON HOOK DIAERESIS;;;;\n03D5;GREEK PHI SYMBOL;Ll;0;L;<compat> 03C6;;;;N;GREEK SMALL LETTER SCRIPT PHI;;03A6;;03A6\n03D6;GREEK PI SYMBOL;Ll;0;L;<compat> 03C0;;;;N;GREEK SMALL LETTER OMEGA PI;;03A0;;03A0\n03D7;GREEK KAI SYMBOL;Ll;0;L;;;;;N;;;03CF;;03CF\n03D8;GREEK LETTER ARCHAIC KOPPA;Lu;0;L;;;;;N;;;;03D9;\n03D9;GREEK SMALL LETTER ARCHAIC KOPPA;Ll;0;L;;;;;N;;;03D8;;03D8\n03DA;GREEK LETTER STIGMA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER STIGMA;;;03DB;\n03DB;GREEK SMALL LETTER STIGMA;Ll;0;L;;;;;N;;;03DA;;03DA\n03DC;GREEK LETTER DIGAMMA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER DIGAMMA;;;03DD;\n03DD;GREEK SMALL LETTER DIGAMMA;Ll;0;L;;;;;N;;;03DC;;03DC\n03DE;GREEK LETTER KOPPA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER KOPPA;;;03DF;\n03DF;GREEK SMALL LETTER KOPPA;Ll;0;L;;;;;N;;;03DE;;03DE\n03E0;GREEK LETTER SAMPI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER SAMPI;;;03E1;\n03E1;GREEK SMALL LETTER SAMPI;Ll;0;L;;;;;N;;;03E0;;03E0\n03E2;COPTIC CAPITAL LETTER SHEI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER SHEI;;;03E3;\n03E3;COPTIC SMALL LETTER SHEI;Ll;0;L;;;;;N;GREEK SMALL LETTER SHEI;;03E2;;03E2\n03E4;COPTIC CAPITAL LETTER FEI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER FEI;;;03E5;\n03E5;COPTIC SMALL LETTER FEI;Ll;0;L;;;;;N;GREEK SMALL LETTER FEI;;03E4;;03E4\n03E6;COPTIC CAPITAL LETTER KHEI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER KHEI;;;03E7;\n03E7;COPTIC SMALL LETTER KHEI;Ll;0;L;;;;;N;GREEK SMALL LETTER KHEI;;03E6;;03E6\n03E8;COPTIC CAPITAL LETTER HORI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER HORI;;;03E9;\n03E9;COPTIC SMALL LETTER HORI;Ll;0;L;;;;;N;GREEK SMALL LETTER HORI;;03E8;;03E8\n03EA;COPTIC CAPITAL LETTER GANGIA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER GANGIA;;;03EB;\n03EB;COPTIC SMALL LETTER GANGIA;Ll;0;L;;;;;N;GREEK SMALL LETTER GANGIA;;03EA;;03EA\n03EC;COPTIC CAPITAL LETTER SHIMA;Lu;0;L;;;;;N;GREEK CAPITAL LETTER SHIMA;;;03ED;\n03ED;COPTIC SMALL LETTER SHIMA;Ll;0;L;;;;;N;GREEK SMALL LETTER SHIMA;;03EC;;03EC\n03EE;COPTIC CAPITAL LETTER DEI;Lu;0;L;;;;;N;GREEK CAPITAL LETTER DEI;;;03EF;\n03EF;COPTIC SMALL LETTER DEI;Ll;0;L;;;;;N;GREEK SMALL LETTER DEI;;03EE;;03EE\n03F0;GREEK KAPPA SYMBOL;Ll;0;L;<compat> 03BA;;;;N;GREEK SMALL LETTER SCRIPT KAPPA;;039A;;039A\n03F1;GREEK RHO SYMBOL;Ll;0;L;<compat> 03C1;;;;N;GREEK SMALL LETTER TAILED RHO;;03A1;;03A1\n03F2;GREEK LUNATE SIGMA SYMBOL;Ll;0;L;<compat> 03C2;;;;N;GREEK SMALL LETTER LUNATE SIGMA;;03F9;;03F9\n03F3;GREEK LETTER YOT;Ll;0;L;;;;;N;;;;;\n03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8;\n03F5;GREEK LUNATE EPSILON SYMBOL;Ll;0;L;<compat> 03B5;;;;N;;;0395;;0395\n03F6;GREEK REVERSED LUNATE EPSILON SYMBOL;Sm;0;ON;;;;;N;;;;;\n03F7;GREEK CAPITAL LETTER SHO;Lu;0;L;;;;;N;;;;03F8;\n03F8;GREEK SMALL LETTER SHO;Ll;0;L;;;;;N;;;03F7;;03F7\n03F9;GREEK CAPITAL LUNATE SIGMA SYMBOL;Lu;0;L;<compat> 03A3;;;;N;;;;03F2;\n03FA;GREEK CAPITAL LETTER SAN;Lu;0;L;;;;;N;;;;03FB;\n03FB;GREEK SMALL LETTER SAN;Ll;0;L;;;;;N;;;03FA;;03FA\n03FC;GREEK RHO WITH STROKE SYMBOL;Ll;0;L;;;;;N;;;;;\n03FD;GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL;Lu;0;L;;;;;N;;;;037B;\n03FE;GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL;Lu;0;L;;;;;N;;;;037C;\n03FF;GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL;Lu;0;L;;;;;N;;;;037D;\n0400;CYRILLIC CAPITAL LETTER IE WITH GRAVE;Lu;0;L;0415 0300;;;;N;;;;0450;\n0401;CYRILLIC CAPITAL LETTER IO;Lu;0;L;0415 0308;;;;N;;;;0451;\n0402;CYRILLIC CAPITAL LETTER DJE;Lu;0;L;;;;;N;;;;0452;\n0403;CYRILLIC CAPITAL LETTER GJE;Lu;0;L;0413 0301;;;;N;;;;0453;\n0404;CYRILLIC CAPITAL LETTER UKRAINIAN IE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER E;;;0454;\n0405;CYRILLIC CAPITAL LETTER DZE;Lu;0;L;;;;;N;;;;0455;\n0406;CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER I;;;0456;\n0407;CYRILLIC CAPITAL LETTER YI;Lu;0;L;0406 0308;;;;N;;;;0457;\n0408;CYRILLIC CAPITAL LETTER JE;Lu;0;L;;;;;N;;;;0458;\n0409;CYRILLIC CAPITAL LETTER LJE;Lu;0;L;;;;;N;;;;0459;\n040A;CYRILLIC CAPITAL LETTER NJE;Lu;0;L;;;;;N;;;;045A;\n040B;CYRILLIC CAPITAL LETTER TSHE;Lu;0;L;;;;;N;;;;045B;\n040C;CYRILLIC CAPITAL LETTER KJE;Lu;0;L;041A 0301;;;;N;;;;045C;\n040D;CYRILLIC CAPITAL LETTER I WITH GRAVE;Lu;0;L;0418 0300;;;;N;;;;045D;\n040E;CYRILLIC CAPITAL LETTER SHORT U;Lu;0;L;0423 0306;;;;N;;;;045E;\n040F;CYRILLIC CAPITAL LETTER DZHE;Lu;0;L;;;;;N;;;;045F;\n0410;CYRILLIC CAPITAL LETTER A;Lu;0;L;;;;;N;;;;0430;\n0411;CYRILLIC CAPITAL LETTER BE;Lu;0;L;;;;;N;;;;0431;\n0412;CYRILLIC CAPITAL LETTER VE;Lu;0;L;;;;;N;;;;0432;\n0413;CYRILLIC CAPITAL LETTER GHE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER GE;;;0433;\n0414;CYRILLIC CAPITAL LETTER DE;Lu;0;L;;;;;N;;;;0434;\n0415;CYRILLIC CAPITAL LETTER IE;Lu;0;L;;;;;N;;;;0435;\n0416;CYRILLIC CAPITAL LETTER ZHE;Lu;0;L;;;;;N;;;;0436;\n0417;CYRILLIC CAPITAL LETTER ZE;Lu;0;L;;;;;N;;;;0437;\n0418;CYRILLIC CAPITAL LETTER I;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER II;;;0438;\n0419;CYRILLIC CAPITAL LETTER SHORT I;Lu;0;L;0418 0306;;;;N;CYRILLIC CAPITAL LETTER SHORT II;;;0439;\n041A;CYRILLIC CAPITAL LETTER KA;Lu;0;L;;;;;N;;;;043A;\n041B;CYRILLIC CAPITAL LETTER EL;Lu;0;L;;;;;N;;;;043B;\n041C;CYRILLIC CAPITAL LETTER EM;Lu;0;L;;;;;N;;;;043C;\n041D;CYRILLIC CAPITAL LETTER EN;Lu;0;L;;;;;N;;;;043D;\n041E;CYRILLIC CAPITAL LETTER O;Lu;0;L;;;;;N;;;;043E;\n041F;CYRILLIC CAPITAL LETTER PE;Lu;0;L;;;;;N;;;;043F;\n0420;CYRILLIC CAPITAL LETTER ER;Lu;0;L;;;;;N;;;;0440;\n0421;CYRILLIC CAPITAL LETTER ES;Lu;0;L;;;;;N;;;;0441;\n0422;CYRILLIC CAPITAL LETTER TE;Lu;0;L;;;;;N;;;;0442;\n0423;CYRILLIC CAPITAL LETTER U;Lu;0;L;;;;;N;;;;0443;\n0424;CYRILLIC CAPITAL LETTER EF;Lu;0;L;;;;;N;;;;0444;\n0425;CYRILLIC CAPITAL LETTER HA;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KHA;;;0445;\n0426;CYRILLIC CAPITAL LETTER TSE;Lu;0;L;;;;;N;;;;0446;\n0427;CYRILLIC CAPITAL LETTER CHE;Lu;0;L;;;;;N;;;;0447;\n0428;CYRILLIC CAPITAL LETTER SHA;Lu;0;L;;;;;N;;;;0448;\n0429;CYRILLIC CAPITAL LETTER SHCHA;Lu;0;L;;;;;N;;;;0449;\n042A;CYRILLIC CAPITAL LETTER HARD SIGN;Lu;0;L;;;;;N;;;;044A;\n042B;CYRILLIC CAPITAL LETTER YERU;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER YERI;;;044B;\n042C;CYRILLIC CAPITAL LETTER SOFT SIGN;Lu;0;L;;;;;N;;;;044C;\n042D;CYRILLIC CAPITAL LETTER E;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER REVERSED E;;;044D;\n042E;CYRILLIC CAPITAL LETTER YU;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER IU;;;044E;\n042F;CYRILLIC CAPITAL LETTER YA;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER IA;;;044F;\n0430;CYRILLIC SMALL LETTER A;Ll;0;L;;;;;N;;;0410;;0410\n0431;CYRILLIC SMALL LETTER BE;Ll;0;L;;;;;N;;;0411;;0411\n0432;CYRILLIC SMALL LETTER VE;Ll;0;L;;;;;N;;;0412;;0412\n0433;CYRILLIC SMALL LETTER GHE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER GE;;0413;;0413\n0434;CYRILLIC SMALL LETTER DE;Ll;0;L;;;;;N;;;0414;;0414\n0435;CYRILLIC SMALL LETTER IE;Ll;0;L;;;;;N;;;0415;;0415\n0436;CYRILLIC SMALL LETTER ZHE;Ll;0;L;;;;;N;;;0416;;0416\n0437;CYRILLIC SMALL LETTER ZE;Ll;0;L;;;;;N;;;0417;;0417\n0438;CYRILLIC SMALL LETTER I;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER II;;0418;;0418\n0439;CYRILLIC SMALL LETTER SHORT I;Ll;0;L;0438 0306;;;;N;CYRILLIC SMALL LETTER SHORT II;;0419;;0419\n043A;CYRILLIC SMALL LETTER KA;Ll;0;L;;;;;N;;;041A;;041A\n043B;CYRILLIC SMALL LETTER EL;Ll;0;L;;;;;N;;;041B;;041B\n043C;CYRILLIC SMALL LETTER EM;Ll;0;L;;;;;N;;;041C;;041C\n043D;CYRILLIC SMALL LETTER EN;Ll;0;L;;;;;N;;;041D;;041D\n043E;CYRILLIC SMALL LETTER O;Ll;0;L;;;;;N;;;041E;;041E\n043F;CYRILLIC SMALL LETTER PE;Ll;0;L;;;;;N;;;041F;;041F\n0440;CYRILLIC SMALL LETTER ER;Ll;0;L;;;;;N;;;0420;;0420\n0441;CYRILLIC SMALL LETTER ES;Ll;0;L;;;;;N;;;0421;;0421\n0442;CYRILLIC SMALL LETTER TE;Ll;0;L;;;;;N;;;0422;;0422\n0443;CYRILLIC SMALL LETTER U;Ll;0;L;;;;;N;;;0423;;0423\n0444;CYRILLIC SMALL LETTER EF;Ll;0;L;;;;;N;;;0424;;0424\n0445;CYRILLIC SMALL LETTER HA;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KHA;;0425;;0425\n0446;CYRILLIC SMALL LETTER TSE;Ll;0;L;;;;;N;;;0426;;0426\n0447;CYRILLIC SMALL LETTER CHE;Ll;0;L;;;;;N;;;0427;;0427\n0448;CYRILLIC SMALL LETTER SHA;Ll;0;L;;;;;N;;;0428;;0428\n0449;CYRILLIC SMALL LETTER SHCHA;Ll;0;L;;;;;N;;;0429;;0429\n044A;CYRILLIC SMALL LETTER HARD SIGN;Ll;0;L;;;;;N;;;042A;;042A\n044B;CYRILLIC SMALL LETTER YERU;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER YERI;;042B;;042B\n044C;CYRILLIC SMALL LETTER SOFT SIGN;Ll;0;L;;;;;N;;;042C;;042C\n044D;CYRILLIC SMALL LETTER E;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER REVERSED E;;042D;;042D\n044E;CYRILLIC SMALL LETTER YU;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER IU;;042E;;042E\n044F;CYRILLIC SMALL LETTER YA;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER IA;;042F;;042F\n0450;CYRILLIC SMALL LETTER IE WITH GRAVE;Ll;0;L;0435 0300;;;;N;;;0400;;0400\n0451;CYRILLIC SMALL LETTER IO;Ll;0;L;0435 0308;;;;N;;;0401;;0401\n0452;CYRILLIC SMALL LETTER DJE;Ll;0;L;;;;;N;;;0402;;0402\n0453;CYRILLIC SMALL LETTER GJE;Ll;0;L;0433 0301;;;;N;;;0403;;0403\n0454;CYRILLIC SMALL LETTER UKRAINIAN IE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER E;;0404;;0404\n0455;CYRILLIC SMALL LETTER DZE;Ll;0;L;;;;;N;;;0405;;0405\n0456;CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER I;;0406;;0406\n0457;CYRILLIC SMALL LETTER YI;Ll;0;L;0456 0308;;;;N;;;0407;;0407\n0458;CYRILLIC SMALL LETTER JE;Ll;0;L;;;;;N;;;0408;;0408\n0459;CYRILLIC SMALL LETTER LJE;Ll;0;L;;;;;N;;;0409;;0409\n045A;CYRILLIC SMALL LETTER NJE;Ll;0;L;;;;;N;;;040A;;040A\n045B;CYRILLIC SMALL LETTER TSHE;Ll;0;L;;;;;N;;;040B;;040B\n045C;CYRILLIC SMALL LETTER KJE;Ll;0;L;043A 0301;;;;N;;;040C;;040C\n045D;CYRILLIC SMALL LETTER I WITH GRAVE;Ll;0;L;0438 0300;;;;N;;;040D;;040D\n045E;CYRILLIC SMALL LETTER SHORT U;Ll;0;L;0443 0306;;;;N;;;040E;;040E\n045F;CYRILLIC SMALL LETTER DZHE;Ll;0;L;;;;;N;;;040F;;040F\n0460;CYRILLIC CAPITAL LETTER OMEGA;Lu;0;L;;;;;N;;;;0461;\n0461;CYRILLIC SMALL LETTER OMEGA;Ll;0;L;;;;;N;;;0460;;0460\n0462;CYRILLIC CAPITAL LETTER YAT;Lu;0;L;;;;;N;;;;0463;\n0463;CYRILLIC SMALL LETTER YAT;Ll;0;L;;;;;N;;;0462;;0462\n0464;CYRILLIC CAPITAL LETTER IOTIFIED E;Lu;0;L;;;;;N;;;;0465;\n0465;CYRILLIC SMALL LETTER IOTIFIED E;Ll;0;L;;;;;N;;;0464;;0464\n0466;CYRILLIC CAPITAL LETTER LITTLE YUS;Lu;0;L;;;;;N;;;;0467;\n0467;CYRILLIC SMALL LETTER LITTLE YUS;Ll;0;L;;;;;N;;;0466;;0466\n0468;CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS;Lu;0;L;;;;;N;;;;0469;\n0469;CYRILLIC SMALL LETTER IOTIFIED LITTLE YUS;Ll;0;L;;;;;N;;;0468;;0468\n046A;CYRILLIC CAPITAL LETTER BIG YUS;Lu;0;L;;;;;N;;;;046B;\n046B;CYRILLIC SMALL LETTER BIG YUS;Ll;0;L;;;;;N;;;046A;;046A\n046C;CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS;Lu;0;L;;;;;N;;;;046D;\n046D;CYRILLIC SMALL LETTER IOTIFIED BIG YUS;Ll;0;L;;;;;N;;;046C;;046C\n046E;CYRILLIC CAPITAL LETTER KSI;Lu;0;L;;;;;N;;;;046F;\n046F;CYRILLIC SMALL LETTER KSI;Ll;0;L;;;;;N;;;046E;;046E\n0470;CYRILLIC CAPITAL LETTER PSI;Lu;0;L;;;;;N;;;;0471;\n0471;CYRILLIC SMALL LETTER PSI;Ll;0;L;;;;;N;;;0470;;0470\n0472;CYRILLIC CAPITAL LETTER FITA;Lu;0;L;;;;;N;;;;0473;\n0473;CYRILLIC SMALL LETTER FITA;Ll;0;L;;;;;N;;;0472;;0472\n0474;CYRILLIC CAPITAL LETTER IZHITSA;Lu;0;L;;;;;N;;;;0475;\n0475;CYRILLIC SMALL LETTER IZHITSA;Ll;0;L;;;;;N;;;0474;;0474\n0476;CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT;Lu;0;L;0474 030F;;;;N;CYRILLIC CAPITAL LETTER IZHITSA DOUBLE GRAVE;;;0477;\n0477;CYRILLIC SMALL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT;Ll;0;L;0475 030F;;;;N;CYRILLIC SMALL LETTER IZHITSA DOUBLE GRAVE;;0476;;0476\n0478;CYRILLIC CAPITAL LETTER UK;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER UK DIGRAPH;;;0479;\n0479;CYRILLIC SMALL LETTER UK;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER UK DIGRAPH;;0478;;0478\n047A;CYRILLIC CAPITAL LETTER ROUND OMEGA;Lu;0;L;;;;;N;;;;047B;\n047B;CYRILLIC SMALL LETTER ROUND OMEGA;Ll;0;L;;;;;N;;;047A;;047A\n047C;CYRILLIC CAPITAL LETTER OMEGA WITH TITLO;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER OMEGA TITLO;;;047D;\n047D;CYRILLIC SMALL LETTER OMEGA WITH TITLO;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER OMEGA TITLO;;047C;;047C\n047E;CYRILLIC CAPITAL LETTER OT;Lu;0;L;;;;;N;;;;047F;\n047F;CYRILLIC SMALL LETTER OT;Ll;0;L;;;;;N;;;047E;;047E\n0480;CYRILLIC CAPITAL LETTER KOPPA;Lu;0;L;;;;;N;;;;0481;\n0481;CYRILLIC SMALL LETTER KOPPA;Ll;0;L;;;;;N;;;0480;;0480\n0482;CYRILLIC THOUSANDS SIGN;So;0;L;;;;;N;;;;;\n0483;COMBINING CYRILLIC TITLO;Mn;230;NSM;;;;;N;CYRILLIC NON-SPACING TITLO;;;;\n0484;COMBINING CYRILLIC PALATALIZATION;Mn;230;NSM;;;;;N;CYRILLIC NON-SPACING PALATALIZATION;;;;\n0485;COMBINING CYRILLIC DASIA PNEUMATA;Mn;230;NSM;;;;;N;CYRILLIC NON-SPACING DASIA PNEUMATA;;;;\n0486;COMBINING CYRILLIC PSILI PNEUMATA;Mn;230;NSM;;;;;N;CYRILLIC NON-SPACING PSILI PNEUMATA;;;;\n0487;COMBINING CYRILLIC POKRYTIE;Mn;230;NSM;;;;;N;;;;;\n0488;COMBINING CYRILLIC HUNDRED THOUSANDS SIGN;Me;0;NSM;;;;;N;;;;;\n0489;COMBINING CYRILLIC MILLIONS SIGN;Me;0;NSM;;;;;N;;;;;\n048A;CYRILLIC CAPITAL LETTER SHORT I WITH TAIL;Lu;0;L;;;;;N;;;;048B;\n048B;CYRILLIC SMALL LETTER SHORT I WITH TAIL;Ll;0;L;;;;;N;;;048A;;048A\n048C;CYRILLIC CAPITAL LETTER SEMISOFT SIGN;Lu;0;L;;;;;N;;;;048D;\n048D;CYRILLIC SMALL LETTER SEMISOFT SIGN;Ll;0;L;;;;;N;;;048C;;048C\n048E;CYRILLIC CAPITAL LETTER ER WITH TICK;Lu;0;L;;;;;N;;;;048F;\n048F;CYRILLIC SMALL LETTER ER WITH TICK;Ll;0;L;;;;;N;;;048E;;048E\n0490;CYRILLIC CAPITAL LETTER GHE WITH UPTURN;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER GE WITH UPTURN;;;0491;\n0491;CYRILLIC SMALL LETTER GHE WITH UPTURN;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER GE WITH UPTURN;;0490;;0490\n0492;CYRILLIC CAPITAL LETTER GHE WITH STROKE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER GE BAR;;;0493;\n0493;CYRILLIC SMALL LETTER GHE WITH STROKE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER GE BAR;;0492;;0492\n0494;CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER GE HOOK;;;0495;\n0495;CYRILLIC SMALL LETTER GHE WITH MIDDLE HOOK;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER GE HOOK;;0494;;0494\n0496;CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER ZHE WITH RIGHT DESCENDER;;;0497;\n0497;CYRILLIC SMALL LETTER ZHE WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER ZHE WITH RIGHT DESCENDER;;0496;;0496\n0498;CYRILLIC CAPITAL LETTER ZE WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER ZE CEDILLA;;;0499;\n0499;CYRILLIC SMALL LETTER ZE WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER ZE CEDILLA;;0498;;0498\n049A;CYRILLIC CAPITAL LETTER KA WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KA WITH RIGHT DESCENDER;;;049B;\n049B;CYRILLIC SMALL LETTER KA WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KA WITH RIGHT DESCENDER;;049A;;049A\n049C;CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KA VERTICAL BAR;;;049D;\n049D;CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KA VERTICAL BAR;;049C;;049C\n049E;CYRILLIC CAPITAL LETTER KA WITH STROKE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KA BAR;;;049F;\n049F;CYRILLIC SMALL LETTER KA WITH STROKE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KA BAR;;049E;;049E\n04A0;CYRILLIC CAPITAL LETTER BASHKIR KA;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER REVERSED GE KA;;;04A1;\n04A1;CYRILLIC SMALL LETTER BASHKIR KA;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER REVERSED GE KA;;04A0;;04A0\n04A2;CYRILLIC CAPITAL LETTER EN WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER EN WITH RIGHT DESCENDER;;;04A3;\n04A3;CYRILLIC SMALL LETTER EN WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER EN WITH RIGHT DESCENDER;;04A2;;04A2\n04A4;CYRILLIC CAPITAL LIGATURE EN GHE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER EN GE;;;04A5;\n04A5;CYRILLIC SMALL LIGATURE EN GHE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER EN GE;;04A4;;04A4\n04A6;CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER PE HOOK;;;04A7;\n04A7;CYRILLIC SMALL LETTER PE WITH MIDDLE HOOK;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER PE HOOK;;04A6;;04A6\n04A8;CYRILLIC CAPITAL LETTER ABKHASIAN HA;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER O HOOK;;;04A9;\n04A9;CYRILLIC SMALL LETTER ABKHASIAN HA;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER O HOOK;;04A8;;04A8\n04AA;CYRILLIC CAPITAL LETTER ES WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER ES CEDILLA;;;04AB;\n04AB;CYRILLIC SMALL LETTER ES WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER ES CEDILLA;;04AA;;04AA\n04AC;CYRILLIC CAPITAL LETTER TE WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER TE WITH RIGHT DESCENDER;;;04AD;\n04AD;CYRILLIC SMALL LETTER TE WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER TE WITH RIGHT DESCENDER;;04AC;;04AC\n04AE;CYRILLIC CAPITAL LETTER STRAIGHT U;Lu;0;L;;;;;N;;;;04AF;\n04AF;CYRILLIC SMALL LETTER STRAIGHT U;Ll;0;L;;;;;N;;;04AE;;04AE\n04B0;CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER STRAIGHT U BAR;;;04B1;\n04B1;CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER STRAIGHT U BAR;;04B0;;04B0\n04B2;CYRILLIC CAPITAL LETTER HA WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KHA WITH RIGHT DESCENDER;;;04B3;\n04B3;CYRILLIC SMALL LETTER HA WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KHA WITH RIGHT DESCENDER;;04B2;;04B2\n04B4;CYRILLIC CAPITAL LIGATURE TE TSE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER TE TSE;;;04B5;\n04B5;CYRILLIC SMALL LIGATURE TE TSE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER TE TSE;;04B4;;04B4\n04B6;CYRILLIC CAPITAL LETTER CHE WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER CHE WITH RIGHT DESCENDER;;;04B7;\n04B7;CYRILLIC SMALL LETTER CHE WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER CHE WITH RIGHT DESCENDER;;04B6;;04B6\n04B8;CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER CHE VERTICAL BAR;;;04B9;\n04B9;CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER CHE VERTICAL BAR;;04B8;;04B8\n04BA;CYRILLIC CAPITAL LETTER SHHA;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER H;;;04BB;\n04BB;CYRILLIC SMALL LETTER SHHA;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER H;;04BA;;04BA\n04BC;CYRILLIC CAPITAL LETTER ABKHASIAN CHE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER IE HOOK;;;04BD;\n04BD;CYRILLIC SMALL LETTER ABKHASIAN CHE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER IE HOOK;;04BC;;04BC\n04BE;CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER IE HOOK OGONEK;;;04BF;\n04BF;CYRILLIC SMALL LETTER ABKHASIAN CHE WITH DESCENDER;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER IE HOOK OGONEK;;04BE;;04BE\n04C0;CYRILLIC LETTER PALOCHKA;Lu;0;L;;;;;N;CYRILLIC LETTER I;;;04CF;\n04C1;CYRILLIC CAPITAL LETTER ZHE WITH BREVE;Lu;0;L;0416 0306;;;;N;CYRILLIC CAPITAL LETTER SHORT ZHE;;;04C2;\n04C2;CYRILLIC SMALL LETTER ZHE WITH BREVE;Ll;0;L;0436 0306;;;;N;CYRILLIC SMALL LETTER SHORT ZHE;;04C1;;04C1\n04C3;CYRILLIC CAPITAL LETTER KA WITH HOOK;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER KA HOOK;;;04C4;\n04C4;CYRILLIC SMALL LETTER KA WITH HOOK;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER KA HOOK;;04C3;;04C3\n04C5;CYRILLIC CAPITAL LETTER EL WITH TAIL;Lu;0;L;;;;;N;;;;04C6;\n04C6;CYRILLIC SMALL LETTER EL WITH TAIL;Ll;0;L;;;;;N;;;04C5;;04C5\n04C7;CYRILLIC CAPITAL LETTER EN WITH HOOK;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER EN HOOK;;;04C8;\n04C8;CYRILLIC SMALL LETTER EN WITH HOOK;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER EN HOOK;;04C7;;04C7\n04C9;CYRILLIC CAPITAL LETTER EN WITH TAIL;Lu;0;L;;;;;N;;;;04CA;\n04CA;CYRILLIC SMALL LETTER EN WITH TAIL;Ll;0;L;;;;;N;;;04C9;;04C9\n04CB;CYRILLIC CAPITAL LETTER KHAKASSIAN CHE;Lu;0;L;;;;;N;CYRILLIC CAPITAL LETTER CHE WITH LEFT DESCENDER;;;04CC;\n04CC;CYRILLIC SMALL LETTER KHAKASSIAN CHE;Ll;0;L;;;;;N;CYRILLIC SMALL LETTER CHE WITH LEFT DESCENDER;;04CB;;04CB\n04CD;CYRILLIC CAPITAL LETTER EM WITH TAIL;Lu;0;L;;;;;N;;;;04CE;\n04CE;CYRILLIC SMALL LETTER EM WITH TAIL;Ll;0;L;;;;;N;;;04CD;;04CD\n04CF;CYRILLIC SMALL LETTER PALOCHKA;Ll;0;L;;;;;N;;;04C0;;04C0\n04D0;CYRILLIC CAPITAL LETTER A WITH BREVE;Lu;0;L;0410 0306;;;;N;;;;04D1;\n04D1;CYRILLIC SMALL LETTER A WITH BREVE;Ll;0;L;0430 0306;;;;N;;;04D0;;04D0\n04D2;CYRILLIC CAPITAL LETTER A WITH DIAERESIS;Lu;0;L;0410 0308;;;;N;;;;04D3;\n04D3;CYRILLIC SMALL LETTER A WITH DIAERESIS;Ll;0;L;0430 0308;;;;N;;;04D2;;04D2\n04D4;CYRILLIC CAPITAL LIGATURE A IE;Lu;0;L;;;;;N;;;;04D5;\n04D5;CYRILLIC SMALL LIGATURE A IE;Ll;0;L;;;;;N;;;04D4;;04D4\n04D6;CYRILLIC CAPITAL LETTER IE WITH BREVE;Lu;0;L;0415 0306;;;;N;;;;04D7;\n04D7;CYRILLIC SMALL LETTER IE WITH BREVE;Ll;0;L;0435 0306;;;;N;;;04D6;;04D6\n04D8;CYRILLIC CAPITAL LETTER SCHWA;Lu;0;L;;;;;N;;;;04D9;\n04D9;CYRILLIC SMALL LETTER SCHWA;Ll;0;L;;;;;N;;;04D8;;04D8\n04DA;CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS;Lu;0;L;04D8 0308;;;;N;;;;04DB;\n04DB;CYRILLIC SMALL LETTER SCHWA WITH DIAERESIS;Ll;0;L;04D9 0308;;;;N;;;04DA;;04DA\n04DC;CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS;Lu;0;L;0416 0308;;;;N;;;;04DD;\n04DD;CYRILLIC SMALL LETTER ZHE WITH DIAERESIS;Ll;0;L;0436 0308;;;;N;;;04DC;;04DC\n04DE;CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS;Lu;0;L;0417 0308;;;;N;;;;04DF;\n04DF;CYRILLIC SMALL LETTER ZE WITH DIAERESIS;Ll;0;L;0437 0308;;;;N;;;04DE;;04DE\n04E0;CYRILLIC CAPITAL LETTER ABKHASIAN DZE;Lu;0;L;;;;;N;;;;04E1;\n04E1;CYRILLIC SMALL LETTER ABKHASIAN DZE;Ll;0;L;;;;;N;;;04E0;;04E0\n04E2;CYRILLIC CAPITAL LETTER I WITH MACRON;Lu;0;L;0418 0304;;;;N;;;;04E3;\n04E3;CYRILLIC SMALL LETTER I WITH MACRON;Ll;0;L;0438 0304;;;;N;;;04E2;;04E2\n04E4;CYRILLIC CAPITAL LETTER I WITH DIAERESIS;Lu;0;L;0418 0308;;;;N;;;;04E5;\n04E5;CYRILLIC SMALL LETTER I WITH DIAERESIS;Ll;0;L;0438 0308;;;;N;;;04E4;;04E4\n04E6;CYRILLIC CAPITAL LETTER O WITH DIAERESIS;Lu;0;L;041E 0308;;;;N;;;;04E7;\n04E7;CYRILLIC SMALL LETTER O WITH DIAERESIS;Ll;0;L;043E 0308;;;;N;;;04E6;;04E6\n04E8;CYRILLIC CAPITAL LETTER BARRED O;Lu;0;L;;;;;N;;;;04E9;\n04E9;CYRILLIC SMALL LETTER BARRED O;Ll;0;L;;;;;N;;;04E8;;04E8\n04EA;CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS;Lu;0;L;04E8 0308;;;;N;;;;04EB;\n04EB;CYRILLIC SMALL LETTER BARRED O WITH DIAERESIS;Ll;0;L;04E9 0308;;;;N;;;04EA;;04EA\n04EC;CYRILLIC CAPITAL LETTER E WITH DIAERESIS;Lu;0;L;042D 0308;;;;N;;;;04ED;\n04ED;CYRILLIC SMALL LETTER E WITH DIAERESIS;Ll;0;L;044D 0308;;;;N;;;04EC;;04EC\n04EE;CYRILLIC CAPITAL LETTER U WITH MACRON;Lu;0;L;0423 0304;;;;N;;;;04EF;\n04EF;CYRILLIC SMALL LETTER U WITH MACRON;Ll;0;L;0443 0304;;;;N;;;04EE;;04EE\n04F0;CYRILLIC CAPITAL LETTER U WITH DIAERESIS;Lu;0;L;0423 0308;;;;N;;;;04F1;\n04F1;CYRILLIC SMALL LETTER U WITH DIAERESIS;Ll;0;L;0443 0308;;;;N;;;04F0;;04F0\n04F2;CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE;Lu;0;L;0423 030B;;;;N;;;;04F3;\n04F3;CYRILLIC SMALL LETTER U WITH DOUBLE ACUTE;Ll;0;L;0443 030B;;;;N;;;04F2;;04F2\n04F4;CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS;Lu;0;L;0427 0308;;;;N;;;;04F5;\n04F5;CYRILLIC SMALL LETTER CHE WITH DIAERESIS;Ll;0;L;0447 0308;;;;N;;;04F4;;04F4\n04F6;CYRILLIC CAPITAL LETTER GHE WITH DESCENDER;Lu;0;L;;;;;N;;;;04F7;\n04F7;CYRILLIC SMALL LETTER GHE WITH DESCENDER;Ll;0;L;;;;;N;;;04F6;;04F6\n04F8;CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS;Lu;0;L;042B 0308;;;;N;;;;04F9;\n04F9;CYRILLIC SMALL LETTER YERU WITH DIAERESIS;Ll;0;L;044B 0308;;;;N;;;04F8;;04F8\n04FA;CYRILLIC CAPITAL LETTER GHE WITH STROKE AND HOOK;Lu;0;L;;;;;N;;;;04FB;\n04FB;CYRILLIC SMALL LETTER GHE WITH STROKE AND HOOK;Ll;0;L;;;;;N;;;04FA;;04FA\n04FC;CYRILLIC CAPITAL LETTER HA WITH HOOK;Lu;0;L;;;;;N;;;;04FD;\n04FD;CYRILLIC SMALL LETTER HA WITH HOOK;Ll;0;L;;;;;N;;;04FC;;04FC\n04FE;CYRILLIC CAPITAL LETTER HA WITH STROKE;Lu;0;L;;;;;N;;;;04FF;\n04FF;CYRILLIC SMALL LETTER HA WITH STROKE;Ll;0;L;;;;;N;;;04FE;;04FE\n0500;CYRILLIC CAPITAL LETTER KOMI DE;Lu;0;L;;;;;N;;;;0501;\n0501;CYRILLIC SMALL LETTER KOMI DE;Ll;0;L;;;;;N;;;0500;;0500\n0502;CYRILLIC CAPITAL LETTER KOMI DJE;Lu;0;L;;;;;N;;;;0503;\n0503;CYRILLIC SMALL LETTER KOMI DJE;Ll;0;L;;;;;N;;;0502;;0502\n0504;CYRILLIC CAPITAL LETTER KOMI ZJE;Lu;0;L;;;;;N;;;;0505;\n0505;CYRILLIC SMALL LETTER KOMI ZJE;Ll;0;L;;;;;N;;;0504;;0504\n0506;CYRILLIC CAPITAL LETTER KOMI DZJE;Lu;0;L;;;;;N;;;;0507;\n0507;CYRILLIC SMALL LETTER KOMI DZJE;Ll;0;L;;;;;N;;;0506;;0506\n0508;CYRILLIC CAPITAL LETTER KOMI LJE;Lu;0;L;;;;;N;;;;0509;\n0509;CYRILLIC SMALL LETTER KOMI LJE;Ll;0;L;;;;;N;;;0508;;0508\n050A;CYRILLIC CAPITAL LETTER KOMI NJE;Lu;0;L;;;;;N;;;;050B;\n050B;CYRILLIC SMALL LETTER KOMI NJE;Ll;0;L;;;;;N;;;050A;;050A\n050C;CYRILLIC CAPITAL LETTER KOMI SJE;Lu;0;L;;;;;N;;;;050D;\n050D;CYRILLIC SMALL LETTER KOMI SJE;Ll;0;L;;;;;N;;;050C;;050C\n050E;CYRILLIC CAPITAL LETTER KOMI TJE;Lu;0;L;;;;;N;;;;050F;\n050F;CYRILLIC SMALL LETTER KOMI TJE;Ll;0;L;;;;;N;;;050E;;050E\n0510;CYRILLIC CAPITAL LETTER REVERSED ZE;Lu;0;L;;;;;N;;;;0511;\n0511;CYRILLIC SMALL LETTER REVERSED ZE;Ll;0;L;;;;;N;;;0510;;0510\n0512;CYRILLIC CAPITAL LETTER EL WITH HOOK;Lu;0;L;;;;;N;;;;0513;\n0513;CYRILLIC SMALL LETTER EL WITH HOOK;Ll;0;L;;;;;N;;;0512;;0512\n0514;CYRILLIC CAPITAL LETTER LHA;Lu;0;L;;;;;N;;;;0515;\n0515;CYRILLIC SMALL LETTER LHA;Ll;0;L;;;;;N;;;0514;;0514\n0516;CYRILLIC CAPITAL LETTER RHA;Lu;0;L;;;;;N;;;;0517;\n0517;CYRILLIC SMALL LETTER RHA;Ll;0;L;;;;;N;;;0516;;0516\n0518;CYRILLIC CAPITAL LETTER YAE;Lu;0;L;;;;;N;;;;0519;\n0519;CYRILLIC SMALL LETTER YAE;Ll;0;L;;;;;N;;;0518;;0518\n051A;CYRILLIC CAPITAL LETTER QA;Lu;0;L;;;;;N;;;;051B;\n051B;CYRILLIC SMALL LETTER QA;Ll;0;L;;;;;N;;;051A;;051A\n051C;CYRILLIC CAPITAL LETTER WE;Lu;0;L;;;;;N;;;;051D;\n051D;CYRILLIC SMALL LETTER WE;Ll;0;L;;;;;N;;;051C;;051C\n051E;CYRILLIC CAPITAL LETTER ALEUT KA;Lu;0;L;;;;;N;;;;051F;\n051F;CYRILLIC SMALL LETTER ALEUT KA;Ll;0;L;;;;;N;;;051E;;051E\n0520;CYRILLIC CAPITAL LETTER EL WITH MIDDLE HOOK;Lu;0;L;;;;;N;;;;0521;\n0521;CYRILLIC SMALL LETTER EL WITH MIDDLE HOOK;Ll;0;L;;;;;N;;;0520;;0520\n0522;CYRILLIC CAPITAL LETTER EN WITH MIDDLE HOOK;Lu;0;L;;;;;N;;;;0523;\n0523;CYRILLIC SMALL LETTER EN WITH MIDDLE HOOK;Ll;0;L;;;;;N;;;0522;;0522\n0524;CYRILLIC CAPITAL LETTER PE WITH DESCENDER;Lu;0;L;;;;;N;;;;0525;\n0525;CYRILLIC SMALL LETTER PE WITH DESCENDER;Ll;0;L;;;;;N;;;0524;;0524\n0526;CYRILLIC CAPITAL LETTER SHHA WITH DESCENDER;Lu;0;L;;;;;N;;;;0527;\n0527;CYRILLIC SMALL LETTER SHHA WITH DESCENDER;Ll;0;L;;;;;N;;;0526;;0526\n0531;ARMENIAN CAPITAL LETTER AYB;Lu;0;L;;;;;N;;;;0561;\n0532;ARMENIAN CAPITAL LETTER BEN;Lu;0;L;;;;;N;;;;0562;\n0533;ARMENIAN CAPITAL LETTER GIM;Lu;0;L;;;;;N;;;;0563;\n0534;ARMENIAN CAPITAL LETTER DA;Lu;0;L;;;;;N;;;;0564;\n0535;ARMENIAN CAPITAL LETTER ECH;Lu;0;L;;;;;N;;;;0565;\n0536;ARMENIAN CAPITAL LETTER ZA;Lu;0;L;;;;;N;;;;0566;\n0537;ARMENIAN CAPITAL LETTER EH;Lu;0;L;;;;;N;;;;0567;\n0538;ARMENIAN CAPITAL LETTER ET;Lu;0;L;;;;;N;;;;0568;\n0539;ARMENIAN CAPITAL LETTER TO;Lu;0;L;;;;;N;;;;0569;\n053A;ARMENIAN CAPITAL LETTER ZHE;Lu;0;L;;;;;N;;;;056A;\n053B;ARMENIAN CAPITAL LETTER INI;Lu;0;L;;;;;N;;;;056B;\n053C;ARMENIAN CAPITAL LETTER LIWN;Lu;0;L;;;;;N;;;;056C;\n053D;ARMENIAN CAPITAL LETTER XEH;Lu;0;L;;;;;N;;;;056D;\n053E;ARMENIAN CAPITAL LETTER CA;Lu;0;L;;;;;N;;;;056E;\n053F;ARMENIAN CAPITAL LETTER KEN;Lu;0;L;;;;;N;;;;056F;\n0540;ARMENIAN CAPITAL LETTER HO;Lu;0;L;;;;;N;;;;0570;\n0541;ARMENIAN CAPITAL LETTER JA;Lu;0;L;;;;;N;;;;0571;\n0542;ARMENIAN CAPITAL LETTER GHAD;Lu;0;L;;;;;N;ARMENIAN CAPITAL LETTER LAD;;;0572;\n0543;ARMENIAN CAPITAL LETTER CHEH;Lu;0;L;;;;;N;;;;0573;\n0544;ARMENIAN CAPITAL LETTER MEN;Lu;0;L;;;;;N;;;;0574;\n0545;ARMENIAN CAPITAL LETTER YI;Lu;0;L;;;;;N;;;;0575;\n0546;ARMENIAN CAPITAL LETTER NOW;Lu;0;L;;;;;N;;;;0576;\n0547;ARMENIAN CAPITAL LETTER SHA;Lu;0;L;;;;;N;;;;0577;\n0548;ARMENIAN CAPITAL LETTER VO;Lu;0;L;;;;;N;;;;0578;\n0549;ARMENIAN CAPITAL LETTER CHA;Lu;0;L;;;;;N;;;;0579;\n054A;ARMENIAN CAPITAL LETTER PEH;Lu;0;L;;;;;N;;;;057A;\n054B;ARMENIAN CAPITAL LETTER JHEH;Lu;0;L;;;;;N;;;;057B;\n054C;ARMENIAN CAPITAL LETTER RA;Lu;0;L;;;;;N;;;;057C;\n054D;ARMENIAN CAPITAL LETTER SEH;Lu;0;L;;;;;N;;;;057D;\n054E;ARMENIAN CAPITAL LETTER VEW;Lu;0;L;;;;;N;;;;057E;\n054F;ARMENIAN CAPITAL LETTER TIWN;Lu;0;L;;;;;N;;;;057F;\n0550;ARMENIAN CAPITAL LETTER REH;Lu;0;L;;;;;N;;;;0580;\n0551;ARMENIAN CAPITAL LETTER CO;Lu;0;L;;;;;N;;;;0581;\n0552;ARMENIAN CAPITAL LETTER YIWN;Lu;0;L;;;;;N;;;;0582;\n0553;ARMENIAN CAPITAL LETTER PIWR;Lu;0;L;;;;;N;;;;0583;\n0554;ARMENIAN CAPITAL LETTER KEH;Lu;0;L;;;;;N;;;;0584;\n0555;ARMENIAN CAPITAL LETTER OH;Lu;0;L;;;;;N;;;;0585;\n0556;ARMENIAN CAPITAL LETTER FEH;Lu;0;L;;;;;N;;;;0586;\n0559;ARMENIAN MODIFIER LETTER LEFT HALF RING;Lm;0;L;;;;;N;;;;;\n055A;ARMENIAN APOSTROPHE;Po;0;L;;;;;N;ARMENIAN MODIFIER LETTER RIGHT HALF RING;;;;\n055B;ARMENIAN EMPHASIS MARK;Po;0;L;;;;;N;;;;;\n055C;ARMENIAN EXCLAMATION MARK;Po;0;L;;;;;N;;;;;\n055D;ARMENIAN COMMA;Po;0;L;;;;;N;;;;;\n055E;ARMENIAN QUESTION MARK;Po;0;L;;;;;N;;;;;\n055F;ARMENIAN ABBREVIATION MARK;Po;0;L;;;;;N;;;;;\n0561;ARMENIAN SMALL LETTER AYB;Ll;0;L;;;;;N;;;0531;;0531\n0562;ARMENIAN SMALL LETTER BEN;Ll;0;L;;;;;N;;;0532;;0532\n0563;ARMENIAN SMALL LETTER GIM;Ll;0;L;;;;;N;;;0533;;0533\n0564;ARMENIAN SMALL LETTER DA;Ll;0;L;;;;;N;;;0534;;0534\n0565;ARMENIAN SMALL LETTER ECH;Ll;0;L;;;;;N;;;0535;;0535\n0566;ARMENIAN SMALL LETTER ZA;Ll;0;L;;;;;N;;;0536;;0536\n0567;ARMENIAN SMALL LETTER EH;Ll;0;L;;;;;N;;;0537;;0537\n0568;ARMENIAN SMALL LETTER ET;Ll;0;L;;;;;N;;;0538;;0538\n0569;ARMENIAN SMALL LETTER TO;Ll;0;L;;;;;N;;;0539;;0539\n056A;ARMENIAN SMALL LETTER ZHE;Ll;0;L;;;;;N;;;053A;;053A\n056B;ARMENIAN SMALL LETTER INI;Ll;0;L;;;;;N;;;053B;;053B\n056C;ARMENIAN SMALL LETTER LIWN;Ll;0;L;;;;;N;;;053C;;053C\n056D;ARMENIAN SMALL LETTER XEH;Ll;0;L;;;;;N;;;053D;;053D\n056E;ARMENIAN SMALL LETTER CA;Ll;0;L;;;;;N;;;053E;;053E\n056F;ARMENIAN SMALL LETTER KEN;Ll;0;L;;;;;N;;;053F;;053F\n0570;ARMENIAN SMALL LETTER HO;Ll;0;L;;;;;N;;;0540;;0540\n0571;ARMENIAN SMALL LETTER JA;Ll;0;L;;;;;N;;;0541;;0541\n0572;ARMENIAN SMALL LETTER GHAD;Ll;0;L;;;;;N;ARMENIAN SMALL LETTER LAD;;0542;;0542\n0573;ARMENIAN SMALL LETTER CHEH;Ll;0;L;;;;;N;;;0543;;0543\n0574;ARMENIAN SMALL LETTER MEN;Ll;0;L;;;;;N;;;0544;;0544\n0575;ARMENIAN SMALL LETTER YI;Ll;0;L;;;;;N;;;0545;;0545\n0576;ARMENIAN SMALL LETTER NOW;Ll;0;L;;;;;N;;;0546;;0546\n0577;ARMENIAN SMALL LETTER SHA;Ll;0;L;;;;;N;;;0547;;0547\n0578;ARMENIAN SMALL LETTER VO;Ll;0;L;;;;;N;;;0548;;0548\n0579;ARMENIAN SMALL LETTER CHA;Ll;0;L;;;;;N;;;0549;;0549\n057A;ARMENIAN SMALL LETTER PEH;Ll;0;L;;;;;N;;;054A;;054A\n057B;ARMENIAN SMALL LETTER JHEH;Ll;0;L;;;;;N;;;054B;;054B\n057C;ARMENIAN SMALL LETTER RA;Ll;0;L;;;;;N;;;054C;;054C\n057D;ARMENIAN SMALL LETTER SEH;Ll;0;L;;;;;N;;;054D;;054D\n057E;ARMENIAN SMALL LETTER VEW;Ll;0;L;;;;;N;;;054E;;054E\n057F;ARMENIAN SMALL LETTER TIWN;Ll;0;L;;;;;N;;;054F;;054F\n0580;ARMENIAN SMALL LETTER REH;Ll;0;L;;;;;N;;;0550;;0550\n0581;ARMENIAN SMALL LETTER CO;Ll;0;L;;;;;N;;;0551;;0551\n0582;ARMENIAN SMALL LETTER YIWN;Ll;0;L;;;;;N;;;0552;;0552\n0583;ARMENIAN SMALL LETTER PIWR;Ll;0;L;;;;;N;;;0553;;0553\n0584;ARMENIAN SMALL LETTER KEH;Ll;0;L;;;;;N;;;0554;;0554\n0585;ARMENIAN SMALL LETTER OH;Ll;0;L;;;;;N;;;0555;;0555\n0586;ARMENIAN SMALL LETTER FEH;Ll;0;L;;;;;N;;;0556;;0556\n0587;ARMENIAN SMALL LIGATURE ECH YIWN;Ll;0;L;<compat> 0565 0582;;;;N;;;;;\n0589;ARMENIAN FULL STOP;Po;0;L;;;;;N;ARMENIAN PERIOD;;;;\n058A;ARMENIAN HYPHEN;Pd;0;ON;;;;;N;;;;;\n058F;ARMENIAN DRAM SIGN;Sc;0;ET;;;;;N;;;;;\n0591;HEBREW ACCENT ETNAHTA;Mn;220;NSM;;;;;N;;;;;\n0592;HEBREW ACCENT SEGOL;Mn;230;NSM;;;;;N;;;;;\n0593;HEBREW ACCENT SHALSHELET;Mn;230;NSM;;;;;N;;;;;\n0594;HEBREW ACCENT ZAQEF QATAN;Mn;230;NSM;;;;;N;;;;;\n0595;HEBREW ACCENT ZAQEF GADOL;Mn;230;NSM;;;;;N;;;;;\n0596;HEBREW ACCENT TIPEHA;Mn;220;NSM;;;;;N;;;;;\n0597;HEBREW ACCENT REVIA;Mn;230;NSM;;;;;N;;;;;\n0598;HEBREW ACCENT ZARQA;Mn;230;NSM;;;;;N;;;;;\n0599;HEBREW ACCENT PASHTA;Mn;230;NSM;;;;;N;;;;;\n059A;HEBREW ACCENT YETIV;Mn;222;NSM;;;;;N;;;;;\n059B;HEBREW ACCENT TEVIR;Mn;220;NSM;;;;;N;;;;;\n059C;HEBREW ACCENT GERESH;Mn;230;NSM;;;;;N;;;;;\n059D;HEBREW ACCENT GERESH MUQDAM;Mn;230;NSM;;;;;N;;;;;\n059E;HEBREW ACCENT GERSHAYIM;Mn;230;NSM;;;;;N;;;;;\n059F;HEBREW ACCENT QARNEY PARA;Mn;230;NSM;;;;;N;;;;;\n05A0;HEBREW ACCENT TELISHA GEDOLA;Mn;230;NSM;;;;;N;;;;;\n05A1;HEBREW ACCENT PAZER;Mn;230;NSM;;;;;N;;;;;\n05A2;HEBREW ACCENT ATNAH HAFUKH;Mn;220;NSM;;;;;N;;;;;\n05A3;HEBREW ACCENT MUNAH;Mn;220;NSM;;;;;N;;;;;\n05A4;HEBREW ACCENT MAHAPAKH;Mn;220;NSM;;;;;N;;;;;\n05A5;HEBREW ACCENT MERKHA;Mn;220;NSM;;;;;N;;;;;\n05A6;HEBREW ACCENT MERKHA KEFULA;Mn;220;NSM;;;;;N;;;;;\n05A7;HEBREW ACCENT DARGA;Mn;220;NSM;;;;;N;;;;;\n05A8;HEBREW ACCENT QADMA;Mn;230;NSM;;;;;N;;;;;\n05A9;HEBREW ACCENT TELISHA QETANA;Mn;230;NSM;;;;;N;;;;;\n05AA;HEBREW ACCENT YERAH BEN YOMO;Mn;220;NSM;;;;;N;;;;;\n05AB;HEBREW ACCENT OLE;Mn;230;NSM;;;;;N;;;;;\n05AC;HEBREW ACCENT ILUY;Mn;230;NSM;;;;;N;;;;;\n05AD;HEBREW ACCENT DEHI;Mn;222;NSM;;;;;N;;;;;\n05AE;HEBREW ACCENT ZINOR;Mn;228;NSM;;;;;N;;;;;\n05AF;HEBREW MARK MASORA CIRCLE;Mn;230;NSM;;;;;N;;;;;\n05B0;HEBREW POINT SHEVA;Mn;10;NSM;;;;;N;;;;;\n05B1;HEBREW POINT HATAF SEGOL;Mn;11;NSM;;;;;N;;;;;\n05B2;HEBREW POINT HATAF PATAH;Mn;12;NSM;;;;;N;;;;;\n05B3;HEBREW POINT HATAF QAMATS;Mn;13;NSM;;;;;N;;;;;\n05B4;HEBREW POINT HIRIQ;Mn;14;NSM;;;;;N;;;;;\n05B5;HEBREW POINT TSERE;Mn;15;NSM;;;;;N;;;;;\n05B6;HEBREW POINT SEGOL;Mn;16;NSM;;;;;N;;;;;\n05B7;HEBREW POINT PATAH;Mn;17;NSM;;;;;N;;;;;\n05B8;HEBREW POINT QAMATS;Mn;18;NSM;;;;;N;;;;;\n05B9;HEBREW POINT HOLAM;Mn;19;NSM;;;;;N;;;;;\n05BA;HEBREW POINT HOLAM HASER FOR VAV;Mn;19;NSM;;;;;N;;;;;\n05BB;HEBREW POINT QUBUTS;Mn;20;NSM;;;;;N;;;;;\n05BC;HEBREW POINT DAGESH OR MAPIQ;Mn;21;NSM;;;;;N;HEBREW POINT DAGESH;;;;\n05BD;HEBREW POINT METEG;Mn;22;NSM;;;;;N;;;;;\n05BE;HEBREW PUNCTUATION MAQAF;Pd;0;R;;;;;N;;;;;\n05BF;HEBREW POINT RAFE;Mn;23;NSM;;;;;N;;;;;\n05C0;HEBREW PUNCTUATION PASEQ;Po;0;R;;;;;N;HEBREW POINT PASEQ;;;;\n05C1;HEBREW POINT SHIN DOT;Mn;24;NSM;;;;;N;;;;;\n05C2;HEBREW POINT SIN DOT;Mn;25;NSM;;;;;N;;;;;\n05C3;HEBREW PUNCTUATION SOF PASUQ;Po;0;R;;;;;N;;;;;\n05C4;HEBREW MARK UPPER DOT;Mn;230;NSM;;;;;N;;;;;\n05C5;HEBREW MARK LOWER DOT;Mn;220;NSM;;;;;N;;;;;\n05C6;HEBREW PUNCTUATION NUN HAFUKHA;Po;0;R;;;;;N;;;;;\n05C7;HEBREW POINT QAMATS QATAN;Mn;18;NSM;;;;;N;;;;;\n05D0;HEBREW LETTER ALEF;Lo;0;R;;;;;N;;;;;\n05D1;HEBREW LETTER BET;Lo;0;R;;;;;N;;;;;\n05D2;HEBREW LETTER GIMEL;Lo;0;R;;;;;N;;;;;\n05D3;HEBREW LETTER DALET;Lo;0;R;;;;;N;;;;;\n05D4;HEBREW LETTER HE;Lo;0;R;;;;;N;;;;;\n05D5;HEBREW LETTER VAV;Lo;0;R;;;;;N;;;;;\n05D6;HEBREW LETTER ZAYIN;Lo;0;R;;;;;N;;;;;\n05D7;HEBREW LETTER HET;Lo;0;R;;;;;N;;;;;\n05D8;HEBREW LETTER TET;Lo;0;R;;;;;N;;;;;\n05D9;HEBREW LETTER YOD;Lo;0;R;;;;;N;;;;;\n05DA;HEBREW LETTER FINAL KAF;Lo;0;R;;;;;N;;;;;\n05DB;HEBREW LETTER KAF;Lo;0;R;;;;;N;;;;;\n05DC;HEBREW LETTER LAMED;Lo;0;R;;;;;N;;;;;\n05DD;HEBREW LETTER FINAL MEM;Lo;0;R;;;;;N;;;;;\n05DE;HEBREW LETTER MEM;Lo;0;R;;;;;N;;;;;\n05DF;HEBREW LETTER FINAL NUN;Lo;0;R;;;;;N;;;;;\n05E0;HEBREW LETTER NUN;Lo;0;R;;;;;N;;;;;\n05E1;HEBREW LETTER SAMEKH;Lo;0;R;;;;;N;;;;;\n05E2;HEBREW LETTER AYIN;Lo;0;R;;;;;N;;;;;\n05E3;HEBREW LETTER FINAL PE;Lo;0;R;;;;;N;;;;;\n05E4;HEBREW LETTER PE;Lo;0;R;;;;;N;;;;;\n05E5;HEBREW LETTER FINAL TSADI;Lo;0;R;;;;;N;;;;;\n05E6;HEBREW LETTER TSADI;Lo;0;R;;;;;N;;;;;\n05E7;HEBREW LETTER QOF;Lo;0;R;;;;;N;;;;;\n05E8;HEBREW LETTER RESH;Lo;0;R;;;;;N;;;;;\n05E9;HEBREW LETTER SHIN;Lo;0;R;;;;;N;;;;;\n05EA;HEBREW LETTER TAV;Lo;0;R;;;;;N;;;;;\n05F0;HEBREW LIGATURE YIDDISH DOUBLE VAV;Lo;0;R;;;;;N;HEBREW LETTER DOUBLE VAV;;;;\n05F1;HEBREW LIGATURE YIDDISH VAV YOD;Lo;0;R;;;;;N;HEBREW LETTER VAV YOD;;;;\n05F2;HEBREW LIGATURE YIDDISH DOUBLE YOD;Lo;0;R;;;;;N;HEBREW LETTER DOUBLE YOD;;;;\n05F3;HEBREW PUNCTUATION GERESH;Po;0;R;;;;;N;;;;;\n05F4;HEBREW PUNCTUATION GERSHAYIM;Po;0;R;;;;;N;;;;;\n0600;ARABIC NUMBER SIGN;Cf;0;AN;;;;;N;;;;;\n0601;ARABIC SIGN SANAH;Cf;0;AN;;;;;N;;;;;\n0602;ARABIC FOOTNOTE MARKER;Cf;0;AN;;;;;N;;;;;\n0603;ARABIC SIGN SAFHA;Cf;0;AN;;;;;N;;;;;\n0604;ARABIC SIGN SAMVAT;Cf;0;AN;;;;;N;;;;;\n0606;ARABIC-INDIC CUBE ROOT;Sm;0;ON;;;;;N;;;;;\n0607;ARABIC-INDIC FOURTH ROOT;Sm;0;ON;;;;;N;;;;;\n0608;ARABIC RAY;Sm;0;AL;;;;;N;;;;;\n0609;ARABIC-INDIC PER MILLE SIGN;Po;0;ET;;;;;N;;;;;\n060A;ARABIC-INDIC PER TEN THOUSAND SIGN;Po;0;ET;;;;;N;;;;;\n060B;AFGHANI SIGN;Sc;0;AL;;;;;N;;;;;\n060C;ARABIC COMMA;Po;0;CS;;;;;N;;;;;\n060D;ARABIC DATE SEPARATOR;Po;0;AL;;;;;N;;;;;\n060E;ARABIC POETIC VERSE SIGN;So;0;ON;;;;;N;;;;;\n060F;ARABIC SIGN MISRA;So;0;ON;;;;;N;;;;;\n0610;ARABIC SIGN SALLALLAHOU ALAYHE WASSALLAM;Mn;230;NSM;;;;;N;;;;;\n0611;ARABIC SIGN ALAYHE ASSALLAM;Mn;230;NSM;;;;;N;;;;;\n0612;ARABIC SIGN RAHMATULLAH ALAYHE;Mn;230;NSM;;;;;N;;;;;\n0613;ARABIC SIGN RADI ALLAHOU ANHU;Mn;230;NSM;;;;;N;;;;;\n0614;ARABIC SIGN TAKHALLUS;Mn;230;NSM;;;;;N;;;;;\n0615;ARABIC SMALL HIGH TAH;Mn;230;NSM;;;;;N;;;;;\n0616;ARABIC SMALL HIGH LIGATURE ALEF WITH LAM WITH YEH;Mn;230;NSM;;;;;N;;;;;\n0617;ARABIC SMALL HIGH ZAIN;Mn;230;NSM;;;;;N;;;;;\n0618;ARABIC SMALL FATHA;Mn;30;NSM;;;;;N;;;;;\n0619;ARABIC SMALL DAMMA;Mn;31;NSM;;;;;N;;;;;\n061A;ARABIC SMALL KASRA;Mn;32;NSM;;;;;N;;;;;\n061B;ARABIC SEMICOLON;Po;0;AL;;;;;N;;;;;\n061E;ARABIC TRIPLE DOT PUNCTUATION MARK;Po;0;AL;;;;;N;;;;;\n061F;ARABIC QUESTION MARK;Po;0;AL;;;;;N;;;;;\n0620;ARABIC LETTER KASHMIRI YEH;Lo;0;AL;;;;;N;;;;;\n0621;ARABIC LETTER HAMZA;Lo;0;AL;;;;;N;ARABIC LETTER HAMZAH;;;;\n0622;ARABIC LETTER ALEF WITH MADDA ABOVE;Lo;0;AL;0627 0653;;;;N;ARABIC LETTER MADDAH ON ALEF;;;;\n0623;ARABIC LETTER ALEF WITH HAMZA ABOVE;Lo;0;AL;0627 0654;;;;N;ARABIC LETTER HAMZAH ON ALEF;;;;\n0624;ARABIC LETTER WAW WITH HAMZA ABOVE;Lo;0;AL;0648 0654;;;;N;ARABIC LETTER HAMZAH ON WAW;;;;\n0625;ARABIC LETTER ALEF WITH HAMZA BELOW;Lo;0;AL;0627 0655;;;;N;ARABIC LETTER HAMZAH UNDER ALEF;;;;\n0626;ARABIC LETTER YEH WITH HAMZA ABOVE;Lo;0;AL;064A 0654;;;;N;ARABIC LETTER HAMZAH ON YA;;;;\n0627;ARABIC LETTER ALEF;Lo;0;AL;;;;;N;;;;;\n0628;ARABIC LETTER BEH;Lo;0;AL;;;;;N;ARABIC LETTER BAA;;;;\n0629;ARABIC LETTER TEH MARBUTA;Lo;0;AL;;;;;N;ARABIC LETTER TAA MARBUTAH;;;;\n062A;ARABIC LETTER TEH;Lo;0;AL;;;;;N;ARABIC LETTER TAA;;;;\n062B;ARABIC LETTER THEH;Lo;0;AL;;;;;N;ARABIC LETTER THAA;;;;\n062C;ARABIC LETTER JEEM;Lo;0;AL;;;;;N;;;;;\n062D;ARABIC LETTER HAH;Lo;0;AL;;;;;N;ARABIC LETTER HAA;;;;\n062E;ARABIC LETTER KHAH;Lo;0;AL;;;;;N;ARABIC LETTER KHAA;;;;\n062F;ARABIC LETTER DAL;Lo;0;AL;;;;;N;;;;;\n0630;ARABIC LETTER THAL;Lo;0;AL;;;;;N;;;;;\n0631;ARABIC LETTER REH;Lo;0;AL;;;;;N;ARABIC LETTER RA;;;;\n0632;ARABIC LETTER ZAIN;Lo;0;AL;;;;;N;;;;;\n0633;ARABIC LETTER SEEN;Lo;0;AL;;;;;N;;;;;\n0634;ARABIC LETTER SHEEN;Lo;0;AL;;;;;N;;;;;\n0635;ARABIC LETTER SAD;Lo;0;AL;;;;;N;;;;;\n0636;ARABIC LETTER DAD;Lo;0;AL;;;;;N;;;;;\n0637;ARABIC LETTER TAH;Lo;0;AL;;;;;N;;;;;\n0638;ARABIC LETTER ZAH;Lo;0;AL;;;;;N;ARABIC LETTER DHAH;;;;\n0639;ARABIC LETTER AIN;Lo;0;AL;;;;;N;;;;;\n063A;ARABIC LETTER GHAIN;Lo;0;AL;;;;;N;;;;;\n063B;ARABIC LETTER KEHEH WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n063C;ARABIC LETTER KEHEH WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n063D;ARABIC LETTER FARSI YEH WITH INVERTED V;Lo;0;AL;;;;;N;;;;;\n063E;ARABIC LETTER FARSI YEH WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n063F;ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0640;ARABIC TATWEEL;Lm;0;AL;;;;;N;;;;;\n0641;ARABIC LETTER FEH;Lo;0;AL;;;;;N;ARABIC LETTER FA;;;;\n0642;ARABIC LETTER QAF;Lo;0;AL;;;;;N;;;;;\n0643;ARABIC LETTER KAF;Lo;0;AL;;;;;N;ARABIC LETTER CAF;;;;\n0644;ARABIC LETTER LAM;Lo;0;AL;;;;;N;;;;;\n0645;ARABIC LETTER MEEM;Lo;0;AL;;;;;N;;;;;\n0646;ARABIC LETTER NOON;Lo;0;AL;;;;;N;;;;;\n0647;ARABIC LETTER HEH;Lo;0;AL;;;;;N;ARABIC LETTER HA;;;;\n0648;ARABIC LETTER WAW;Lo;0;AL;;;;;N;;;;;\n0649;ARABIC LETTER ALEF MAKSURA;Lo;0;AL;;;;;N;ARABIC LETTER ALEF MAQSURAH;;;;\n064A;ARABIC LETTER YEH;Lo;0;AL;;;;;N;ARABIC LETTER YA;;;;\n064B;ARABIC FATHATAN;Mn;27;NSM;;;;;N;;;;;\n064C;ARABIC DAMMATAN;Mn;28;NSM;;;;;N;;;;;\n064D;ARABIC KASRATAN;Mn;29;NSM;;;;;N;;;;;\n064E;ARABIC FATHA;Mn;30;NSM;;;;;N;ARABIC FATHAH;;;;\n064F;ARABIC DAMMA;Mn;31;NSM;;;;;N;ARABIC DAMMAH;;;;\n0650;ARABIC KASRA;Mn;32;NSM;;;;;N;ARABIC KASRAH;;;;\n0651;ARABIC SHADDA;Mn;33;NSM;;;;;N;ARABIC SHADDAH;;;;\n0652;ARABIC SUKUN;Mn;34;NSM;;;;;N;;;;;\n0653;ARABIC MADDAH ABOVE;Mn;230;NSM;;;;;N;;;;;\n0654;ARABIC HAMZA ABOVE;Mn;230;NSM;;;;;N;;;;;\n0655;ARABIC HAMZA BELOW;Mn;220;NSM;;;;;N;;;;;\n0656;ARABIC SUBSCRIPT ALEF;Mn;220;NSM;;;;;N;;;;;\n0657;ARABIC INVERTED DAMMA;Mn;230;NSM;;;;;N;;;;;\n0658;ARABIC MARK NOON GHUNNA;Mn;230;NSM;;;;;N;;;;;\n0659;ARABIC ZWARAKAY;Mn;230;NSM;;;;;N;;;;;\n065A;ARABIC VOWEL SIGN SMALL V ABOVE;Mn;230;NSM;;;;;N;;;;;\n065B;ARABIC VOWEL SIGN INVERTED SMALL V ABOVE;Mn;230;NSM;;;;;N;;;;;\n065C;ARABIC VOWEL SIGN DOT BELOW;Mn;220;NSM;;;;;N;;;;;\n065D;ARABIC REVERSED DAMMA;Mn;230;NSM;;;;;N;;;;;\n065E;ARABIC FATHA WITH TWO DOTS;Mn;230;NSM;;;;;N;;;;;\n065F;ARABIC WAVY HAMZA BELOW;Mn;220;NSM;;;;;N;;;;;\n0660;ARABIC-INDIC DIGIT ZERO;Nd;0;AN;;0;0;0;N;;;;;\n0661;ARABIC-INDIC DIGIT ONE;Nd;0;AN;;1;1;1;N;;;;;\n0662;ARABIC-INDIC DIGIT TWO;Nd;0;AN;;2;2;2;N;;;;;\n0663;ARABIC-INDIC DIGIT THREE;Nd;0;AN;;3;3;3;N;;;;;\n0664;ARABIC-INDIC DIGIT FOUR;Nd;0;AN;;4;4;4;N;;;;;\n0665;ARABIC-INDIC DIGIT FIVE;Nd;0;AN;;5;5;5;N;;;;;\n0666;ARABIC-INDIC DIGIT SIX;Nd;0;AN;;6;6;6;N;;;;;\n0667;ARABIC-INDIC DIGIT SEVEN;Nd;0;AN;;7;7;7;N;;;;;\n0668;ARABIC-INDIC DIGIT EIGHT;Nd;0;AN;;8;8;8;N;;;;;\n0669;ARABIC-INDIC DIGIT NINE;Nd;0;AN;;9;9;9;N;;;;;\n066A;ARABIC PERCENT SIGN;Po;0;ET;;;;;N;;;;;\n066B;ARABIC DECIMAL SEPARATOR;Po;0;AN;;;;;N;;;;;\n066C;ARABIC THOUSANDS SEPARATOR;Po;0;AN;;;;;N;;;;;\n066D;ARABIC FIVE POINTED STAR;Po;0;AL;;;;;N;;;;;\n066E;ARABIC LETTER DOTLESS BEH;Lo;0;AL;;;;;N;;;;;\n066F;ARABIC LETTER DOTLESS QAF;Lo;0;AL;;;;;N;;;;;\n0670;ARABIC LETTER SUPERSCRIPT ALEF;Mn;35;NSM;;;;;N;ARABIC ALEF ABOVE;;;;\n0671;ARABIC LETTER ALEF WASLA;Lo;0;AL;;;;;N;ARABIC LETTER HAMZAT WASL ON ALEF;;;;\n0672;ARABIC LETTER ALEF WITH WAVY HAMZA ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER WAVY HAMZAH ON ALEF;;;;\n0673;ARABIC LETTER ALEF WITH WAVY HAMZA BELOW;Lo;0;AL;;;;;N;ARABIC LETTER WAVY HAMZAH UNDER ALEF;;;;\n0674;ARABIC LETTER HIGH HAMZA;Lo;0;AL;;;;;N;ARABIC LETTER HIGH HAMZAH;;;;\n0675;ARABIC LETTER HIGH HAMZA ALEF;Lo;0;AL;<compat> 0627 0674;;;;N;ARABIC LETTER HIGH HAMZAH ALEF;;;;\n0676;ARABIC LETTER HIGH HAMZA WAW;Lo;0;AL;<compat> 0648 0674;;;;N;ARABIC LETTER HIGH HAMZAH WAW;;;;\n0677;ARABIC LETTER U WITH HAMZA ABOVE;Lo;0;AL;<compat> 06C7 0674;;;;N;ARABIC LETTER HIGH HAMZAH WAW WITH DAMMAH;;;;\n0678;ARABIC LETTER HIGH HAMZA YEH;Lo;0;AL;<compat> 064A 0674;;;;N;ARABIC LETTER HIGH HAMZAH YA;;;;\n0679;ARABIC LETTER TTEH;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH SMALL TAH;;;;\n067A;ARABIC LETTER TTEHEH;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH TWO DOTS VERTICAL ABOVE;;;;\n067B;ARABIC LETTER BEEH;Lo;0;AL;;;;;N;ARABIC LETTER BAA WITH TWO DOTS VERTICAL BELOW;;;;\n067C;ARABIC LETTER TEH WITH RING;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH RING;;;;\n067D;ARABIC LETTER TEH WITH THREE DOTS ABOVE DOWNWARDS;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH THREE DOTS ABOVE DOWNWARD;;;;\n067E;ARABIC LETTER PEH;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH THREE DOTS BELOW;;;;\n067F;ARABIC LETTER TEHEH;Lo;0;AL;;;;;N;ARABIC LETTER TAA WITH FOUR DOTS ABOVE;;;;\n0680;ARABIC LETTER BEHEH;Lo;0;AL;;;;;N;ARABIC LETTER BAA WITH FOUR DOTS BELOW;;;;\n0681;ARABIC LETTER HAH WITH HAMZA ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER HAMZAH ON HAA;;;;\n0682;ARABIC LETTER HAH WITH TWO DOTS VERTICAL ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH TWO DOTS VERTICAL ABOVE;;;;\n0683;ARABIC LETTER NYEH;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH MIDDLE TWO DOTS;;;;\n0684;ARABIC LETTER DYEH;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH MIDDLE TWO DOTS VERTICAL;;;;\n0685;ARABIC LETTER HAH WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH THREE DOTS ABOVE;;;;\n0686;ARABIC LETTER TCHEH;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH MIDDLE THREE DOTS DOWNWARD;;;;\n0687;ARABIC LETTER TCHEHEH;Lo;0;AL;;;;;N;ARABIC LETTER HAA WITH MIDDLE FOUR DOTS;;;;\n0688;ARABIC LETTER DDAL;Lo;0;AL;;;;;N;ARABIC LETTER DAL WITH SMALL TAH;;;;\n0689;ARABIC LETTER DAL WITH RING;Lo;0;AL;;;;;N;;;;;\n068A;ARABIC LETTER DAL WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n068B;ARABIC LETTER DAL WITH DOT BELOW AND SMALL TAH;Lo;0;AL;;;;;N;;;;;\n068C;ARABIC LETTER DAHAL;Lo;0;AL;;;;;N;ARABIC LETTER DAL WITH TWO DOTS ABOVE;;;;\n068D;ARABIC LETTER DDAHAL;Lo;0;AL;;;;;N;ARABIC LETTER DAL WITH TWO DOTS BELOW;;;;\n068E;ARABIC LETTER DUL;Lo;0;AL;;;;;N;ARABIC LETTER DAL WITH THREE DOTS ABOVE;;;;\n068F;ARABIC LETTER DAL WITH THREE DOTS ABOVE DOWNWARDS;Lo;0;AL;;;;;N;ARABIC LETTER DAL WITH THREE DOTS ABOVE DOWNWARD;;;;\n0690;ARABIC LETTER DAL WITH FOUR DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0691;ARABIC LETTER RREH;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH SMALL TAH;;;;\n0692;ARABIC LETTER REH WITH SMALL V;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH SMALL V;;;;\n0693;ARABIC LETTER REH WITH RING;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH RING;;;;\n0694;ARABIC LETTER REH WITH DOT BELOW;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH DOT BELOW;;;;\n0695;ARABIC LETTER REH WITH SMALL V BELOW;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH SMALL V BELOW;;;;\n0696;ARABIC LETTER REH WITH DOT BELOW AND DOT ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH DOT BELOW AND DOT ABOVE;;;;\n0697;ARABIC LETTER REH WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH TWO DOTS ABOVE;;;;\n0698;ARABIC LETTER JEH;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH THREE DOTS ABOVE;;;;\n0699;ARABIC LETTER REH WITH FOUR DOTS ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER RA WITH FOUR DOTS ABOVE;;;;\n069A;ARABIC LETTER SEEN WITH DOT BELOW AND DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n069B;ARABIC LETTER SEEN WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n069C;ARABIC LETTER SEEN WITH THREE DOTS BELOW AND THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n069D;ARABIC LETTER SAD WITH TWO DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n069E;ARABIC LETTER SAD WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n069F;ARABIC LETTER TAH WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06A0;ARABIC LETTER AIN WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06A1;ARABIC LETTER DOTLESS FEH;Lo;0;AL;;;;;N;ARABIC LETTER DOTLESS FA;;;;\n06A2;ARABIC LETTER FEH WITH DOT MOVED BELOW;Lo;0;AL;;;;;N;ARABIC LETTER FA WITH DOT MOVED BELOW;;;;\n06A3;ARABIC LETTER FEH WITH DOT BELOW;Lo;0;AL;;;;;N;ARABIC LETTER FA WITH DOT BELOW;;;;\n06A4;ARABIC LETTER VEH;Lo;0;AL;;;;;N;ARABIC LETTER FA WITH THREE DOTS ABOVE;;;;\n06A5;ARABIC LETTER FEH WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;ARABIC LETTER FA WITH THREE DOTS BELOW;;;;\n06A6;ARABIC LETTER PEHEH;Lo;0;AL;;;;;N;ARABIC LETTER FA WITH FOUR DOTS ABOVE;;;;\n06A7;ARABIC LETTER QAF WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n06A8;ARABIC LETTER QAF WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06A9;ARABIC LETTER KEHEH;Lo;0;AL;;;;;N;ARABIC LETTER OPEN CAF;;;;\n06AA;ARABIC LETTER SWASH KAF;Lo;0;AL;;;;;N;ARABIC LETTER SWASH CAF;;;;\n06AB;ARABIC LETTER KAF WITH RING;Lo;0;AL;;;;;N;ARABIC LETTER CAF WITH RING;;;;\n06AC;ARABIC LETTER KAF WITH DOT ABOVE;Lo;0;AL;;;;;N;ARABIC LETTER CAF WITH DOT ABOVE;;;;\n06AD;ARABIC LETTER NG;Lo;0;AL;;;;;N;ARABIC LETTER CAF WITH THREE DOTS ABOVE;;;;\n06AE;ARABIC LETTER KAF WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;ARABIC LETTER CAF WITH THREE DOTS BELOW;;;;\n06AF;ARABIC LETTER GAF;Lo;0;AL;;;;;N;;;;;\n06B0;ARABIC LETTER GAF WITH RING;Lo;0;AL;;;;;N;;;;;\n06B1;ARABIC LETTER NGOEH;Lo;0;AL;;;;;N;ARABIC LETTER GAF WITH TWO DOTS ABOVE;;;;\n06B2;ARABIC LETTER GAF WITH TWO DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n06B3;ARABIC LETTER GUEH;Lo;0;AL;;;;;N;ARABIC LETTER GAF WITH TWO DOTS VERTICAL BELOW;;;;\n06B4;ARABIC LETTER GAF WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06B5;ARABIC LETTER LAM WITH SMALL V;Lo;0;AL;;;;;N;;;;;\n06B6;ARABIC LETTER LAM WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n06B7;ARABIC LETTER LAM WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06B8;ARABIC LETTER LAM WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n06B9;ARABIC LETTER NOON WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n06BA;ARABIC LETTER NOON GHUNNA;Lo;0;AL;;;;;N;ARABIC LETTER DOTLESS NOON;;;;\n06BB;ARABIC LETTER RNOON;Lo;0;AL;;;;;N;ARABIC LETTER DOTLESS NOON WITH SMALL TAH;;;;\n06BC;ARABIC LETTER NOON WITH RING;Lo;0;AL;;;;;N;;;;;\n06BD;ARABIC LETTER NOON WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06BE;ARABIC LETTER HEH DOACHASHMEE;Lo;0;AL;;;;;N;ARABIC LETTER KNOTTED HA;;;;\n06BF;ARABIC LETTER TCHEH WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n06C0;ARABIC LETTER HEH WITH YEH ABOVE;Lo;0;AL;06D5 0654;;;;N;ARABIC LETTER HAMZAH ON HA;;;;\n06C1;ARABIC LETTER HEH GOAL;Lo;0;AL;;;;;N;ARABIC LETTER HA GOAL;;;;\n06C2;ARABIC LETTER HEH GOAL WITH HAMZA ABOVE;Lo;0;AL;06C1 0654;;;;N;ARABIC LETTER HAMZAH ON HA GOAL;;;;\n06C3;ARABIC LETTER TEH MARBUTA GOAL;Lo;0;AL;;;;;N;ARABIC LETTER TAA MARBUTAH GOAL;;;;\n06C4;ARABIC LETTER WAW WITH RING;Lo;0;AL;;;;;N;;;;;\n06C5;ARABIC LETTER KIRGHIZ OE;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH BAR;;;;\n06C6;ARABIC LETTER OE;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH SMALL V;;;;\n06C7;ARABIC LETTER U;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH DAMMAH;;;;\n06C8;ARABIC LETTER YU;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH ALEF ABOVE;;;;\n06C9;ARABIC LETTER KIRGHIZ YU;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH INVERTED SMALL V;;;;\n06CA;ARABIC LETTER WAW WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n06CB;ARABIC LETTER VE;Lo;0;AL;;;;;N;ARABIC LETTER WAW WITH THREE DOTS ABOVE;;;;\n06CC;ARABIC LETTER FARSI YEH;Lo;0;AL;;;;;N;ARABIC LETTER DOTLESS YA;;;;\n06CD;ARABIC LETTER YEH WITH TAIL;Lo;0;AL;;;;;N;ARABIC LETTER YA WITH TAIL;;;;\n06CE;ARABIC LETTER YEH WITH SMALL V;Lo;0;AL;;;;;N;ARABIC LETTER YA WITH SMALL V;;;;\n06CF;ARABIC LETTER WAW WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n06D0;ARABIC LETTER E;Lo;0;AL;;;;;N;ARABIC LETTER YA WITH TWO DOTS VERTICAL BELOW;;;;\n06D1;ARABIC LETTER YEH WITH THREE DOTS BELOW;Lo;0;AL;;;;;N;ARABIC LETTER YA WITH THREE DOTS BELOW;;;;\n06D2;ARABIC LETTER YEH BARREE;Lo;0;AL;;;;;N;ARABIC LETTER YA BARREE;;;;\n06D3;ARABIC LETTER YEH BARREE WITH HAMZA ABOVE;Lo;0;AL;06D2 0654;;;;N;ARABIC LETTER HAMZAH ON YA BARREE;;;;\n06D4;ARABIC FULL STOP;Po;0;AL;;;;;N;ARABIC PERIOD;;;;\n06D5;ARABIC LETTER AE;Lo;0;AL;;;;;N;;;;;\n06D6;ARABIC SMALL HIGH LIGATURE SAD WITH LAM WITH ALEF MAKSURA;Mn;230;NSM;;;;;N;;;;;\n06D7;ARABIC SMALL HIGH LIGATURE QAF WITH LAM WITH ALEF MAKSURA;Mn;230;NSM;;;;;N;;;;;\n06D8;ARABIC SMALL HIGH MEEM INITIAL FORM;Mn;230;NSM;;;;;N;;;;;\n06D9;ARABIC SMALL HIGH LAM ALEF;Mn;230;NSM;;;;;N;;;;;\n06DA;ARABIC SMALL HIGH JEEM;Mn;230;NSM;;;;;N;;;;;\n06DB;ARABIC SMALL HIGH THREE DOTS;Mn;230;NSM;;;;;N;;;;;\n06DC;ARABIC SMALL HIGH SEEN;Mn;230;NSM;;;;;N;;;;;\n06DD;ARABIC END OF AYAH;Cf;0;AN;;;;;N;;;;;\n06DE;ARABIC START OF RUB EL HIZB;So;0;ON;;;;;N;;;;;\n06DF;ARABIC SMALL HIGH ROUNDED ZERO;Mn;230;NSM;;;;;N;;;;;\n06E0;ARABIC SMALL HIGH UPRIGHT RECTANGULAR ZERO;Mn;230;NSM;;;;;N;;;;;\n06E1;ARABIC SMALL HIGH DOTLESS HEAD OF KHAH;Mn;230;NSM;;;;;N;;;;;\n06E2;ARABIC SMALL HIGH MEEM ISOLATED FORM;Mn;230;NSM;;;;;N;;;;;\n06E3;ARABIC SMALL LOW SEEN;Mn;220;NSM;;;;;N;;;;;\n06E4;ARABIC SMALL HIGH MADDA;Mn;230;NSM;;;;;N;;;;;\n06E5;ARABIC SMALL WAW;Lm;0;AL;;;;;N;;;;;\n06E6;ARABIC SMALL YEH;Lm;0;AL;;;;;N;;;;;\n06E7;ARABIC SMALL HIGH YEH;Mn;230;NSM;;;;;N;;;;;\n06E8;ARABIC SMALL HIGH NOON;Mn;230;NSM;;;;;N;;;;;\n06E9;ARABIC PLACE OF SAJDAH;So;0;ON;;;;;N;;;;;\n06EA;ARABIC EMPTY CENTRE LOW STOP;Mn;220;NSM;;;;;N;;;;;\n06EB;ARABIC EMPTY CENTRE HIGH STOP;Mn;230;NSM;;;;;N;;;;;\n06EC;ARABIC ROUNDED HIGH STOP WITH FILLED CENTRE;Mn;230;NSM;;;;;N;;;;;\n06ED;ARABIC SMALL LOW MEEM;Mn;220;NSM;;;;;N;;;;;\n06EE;ARABIC LETTER DAL WITH INVERTED V;Lo;0;AL;;;;;N;;;;;\n06EF;ARABIC LETTER REH WITH INVERTED V;Lo;0;AL;;;;;N;;;;;\n06F0;EXTENDED ARABIC-INDIC DIGIT ZERO;Nd;0;EN;;0;0;0;N;EASTERN ARABIC-INDIC DIGIT ZERO;;;;\n06F1;EXTENDED ARABIC-INDIC DIGIT ONE;Nd;0;EN;;1;1;1;N;EASTERN ARABIC-INDIC DIGIT ONE;;;;\n06F2;EXTENDED ARABIC-INDIC DIGIT TWO;Nd;0;EN;;2;2;2;N;EASTERN ARABIC-INDIC DIGIT TWO;;;;\n06F3;EXTENDED ARABIC-INDIC DIGIT THREE;Nd;0;EN;;3;3;3;N;EASTERN ARABIC-INDIC DIGIT THREE;;;;\n06F4;EXTENDED ARABIC-INDIC DIGIT FOUR;Nd;0;EN;;4;4;4;N;EASTERN ARABIC-INDIC DIGIT FOUR;;;;\n06F5;EXTENDED ARABIC-INDIC DIGIT FIVE;Nd;0;EN;;5;5;5;N;EASTERN ARABIC-INDIC DIGIT FIVE;;;;\n06F6;EXTENDED ARABIC-INDIC DIGIT SIX;Nd;0;EN;;6;6;6;N;EASTERN ARABIC-INDIC DIGIT SIX;;;;\n06F7;EXTENDED ARABIC-INDIC DIGIT SEVEN;Nd;0;EN;;7;7;7;N;EASTERN ARABIC-INDIC DIGIT SEVEN;;;;\n06F8;EXTENDED ARABIC-INDIC DIGIT EIGHT;Nd;0;EN;;8;8;8;N;EASTERN ARABIC-INDIC DIGIT EIGHT;;;;\n06F9;EXTENDED ARABIC-INDIC DIGIT NINE;Nd;0;EN;;9;9;9;N;EASTERN ARABIC-INDIC DIGIT NINE;;;;\n06FA;ARABIC LETTER SHEEN WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n06FB;ARABIC LETTER DAD WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n06FC;ARABIC LETTER GHAIN WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n06FD;ARABIC SIGN SINDHI AMPERSAND;So;0;AL;;;;;N;;;;;\n06FE;ARABIC SIGN SINDHI POSTPOSITION MEN;So;0;AL;;;;;N;;;;;\n06FF;ARABIC LETTER HEH WITH INVERTED V;Lo;0;AL;;;;;N;;;;;\n0700;SYRIAC END OF PARAGRAPH;Po;0;AL;;;;;N;;;;;\n0701;SYRIAC SUPRALINEAR FULL STOP;Po;0;AL;;;;;N;;;;;\n0702;SYRIAC SUBLINEAR FULL STOP;Po;0;AL;;;;;N;;;;;\n0703;SYRIAC SUPRALINEAR COLON;Po;0;AL;;;;;N;;;;;\n0704;SYRIAC SUBLINEAR COLON;Po;0;AL;;;;;N;;;;;\n0705;SYRIAC HORIZONTAL COLON;Po;0;AL;;;;;N;;;;;\n0706;SYRIAC COLON SKEWED LEFT;Po;0;AL;;;;;N;;;;;\n0707;SYRIAC COLON SKEWED RIGHT;Po;0;AL;;;;;N;;;;;\n0708;SYRIAC SUPRALINEAR COLON SKEWED LEFT;Po;0;AL;;;;;N;;;;;\n0709;SYRIAC SUBLINEAR COLON SKEWED RIGHT;Po;0;AL;;;;;N;;;;;\n070A;SYRIAC CONTRACTION;Po;0;AL;;;;;N;;;;;\n070B;SYRIAC HARKLEAN OBELUS;Po;0;AL;;;;;N;;;;;\n070C;SYRIAC HARKLEAN METOBELUS;Po;0;AL;;;;;N;;;;;\n070D;SYRIAC HARKLEAN ASTERISCUS;Po;0;AL;;;;;N;;;;;\n070F;SYRIAC ABBREVIATION MARK;Cf;0;AL;;;;;N;;;;;\n0710;SYRIAC LETTER ALAPH;Lo;0;AL;;;;;N;;;;;\n0711;SYRIAC LETTER SUPERSCRIPT ALAPH;Mn;36;NSM;;;;;N;;;;;\n0712;SYRIAC LETTER BETH;Lo;0;AL;;;;;N;;;;;\n0713;SYRIAC LETTER GAMAL;Lo;0;AL;;;;;N;;;;;\n0714;SYRIAC LETTER GAMAL GARSHUNI;Lo;0;AL;;;;;N;;;;;\n0715;SYRIAC LETTER DALATH;Lo;0;AL;;;;;N;;;;;\n0716;SYRIAC LETTER DOTLESS DALATH RISH;Lo;0;AL;;;;;N;;;;;\n0717;SYRIAC LETTER HE;Lo;0;AL;;;;;N;;;;;\n0718;SYRIAC LETTER WAW;Lo;0;AL;;;;;N;;;;;\n0719;SYRIAC LETTER ZAIN;Lo;0;AL;;;;;N;;;;;\n071A;SYRIAC LETTER HETH;Lo;0;AL;;;;;N;;;;;\n071B;SYRIAC LETTER TETH;Lo;0;AL;;;;;N;;;;;\n071C;SYRIAC LETTER TETH GARSHUNI;Lo;0;AL;;;;;N;;;;;\n071D;SYRIAC LETTER YUDH;Lo;0;AL;;;;;N;;;;;\n071E;SYRIAC LETTER YUDH HE;Lo;0;AL;;;;;N;;;;;\n071F;SYRIAC LETTER KAPH;Lo;0;AL;;;;;N;;;;;\n0720;SYRIAC LETTER LAMADH;Lo;0;AL;;;;;N;;;;;\n0721;SYRIAC LETTER MIM;Lo;0;AL;;;;;N;;;;;\n0722;SYRIAC LETTER NUN;Lo;0;AL;;;;;N;;;;;\n0723;SYRIAC LETTER SEMKATH;Lo;0;AL;;;;;N;;;;;\n0724;SYRIAC LETTER FINAL SEMKATH;Lo;0;AL;;;;;N;;;;;\n0725;SYRIAC LETTER E;Lo;0;AL;;;;;N;;;;;\n0726;SYRIAC LETTER PE;Lo;0;AL;;;;;N;;;;;\n0727;SYRIAC LETTER REVERSED PE;Lo;0;AL;;;;;N;;;;;\n0728;SYRIAC LETTER SADHE;Lo;0;AL;;;;;N;;;;;\n0729;SYRIAC LETTER QAPH;Lo;0;AL;;;;;N;;;;;\n072A;SYRIAC LETTER RISH;Lo;0;AL;;;;;N;;;;;\n072B;SYRIAC LETTER SHIN;Lo;0;AL;;;;;N;;;;;\n072C;SYRIAC LETTER TAW;Lo;0;AL;;;;;N;;;;;\n072D;SYRIAC LETTER PERSIAN BHETH;Lo;0;AL;;;;;N;;;;;\n072E;SYRIAC LETTER PERSIAN GHAMAL;Lo;0;AL;;;;;N;;;;;\n072F;SYRIAC LETTER PERSIAN DHALATH;Lo;0;AL;;;;;N;;;;;\n0730;SYRIAC PTHAHA ABOVE;Mn;230;NSM;;;;;N;;;;;\n0731;SYRIAC PTHAHA BELOW;Mn;220;NSM;;;;;N;;;;;\n0732;SYRIAC PTHAHA DOTTED;Mn;230;NSM;;;;;N;;;;;\n0733;SYRIAC ZQAPHA ABOVE;Mn;230;NSM;;;;;N;;;;;\n0734;SYRIAC ZQAPHA BELOW;Mn;220;NSM;;;;;N;;;;;\n0735;SYRIAC ZQAPHA DOTTED;Mn;230;NSM;;;;;N;;;;;\n0736;SYRIAC RBASA ABOVE;Mn;230;NSM;;;;;N;;;;;\n0737;SYRIAC RBASA BELOW;Mn;220;NSM;;;;;N;;;;;\n0738;SYRIAC DOTTED ZLAMA HORIZONTAL;Mn;220;NSM;;;;;N;;;;;\n0739;SYRIAC DOTTED ZLAMA ANGULAR;Mn;220;NSM;;;;;N;;;;;\n073A;SYRIAC HBASA ABOVE;Mn;230;NSM;;;;;N;;;;;\n073B;SYRIAC HBASA BELOW;Mn;220;NSM;;;;;N;;;;;\n073C;SYRIAC HBASA-ESASA DOTTED;Mn;220;NSM;;;;;N;;;;;\n073D;SYRIAC ESASA ABOVE;Mn;230;NSM;;;;;N;;;;;\n073E;SYRIAC ESASA BELOW;Mn;220;NSM;;;;;N;;;;;\n073F;SYRIAC RWAHA;Mn;230;NSM;;;;;N;;;;;\n0740;SYRIAC FEMININE DOT;Mn;230;NSM;;;;;N;;;;;\n0741;SYRIAC QUSHSHAYA;Mn;230;NSM;;;;;N;;;;;\n0742;SYRIAC RUKKAKHA;Mn;220;NSM;;;;;N;;;;;\n0743;SYRIAC TWO VERTICAL DOTS ABOVE;Mn;230;NSM;;;;;N;;;;;\n0744;SYRIAC TWO VERTICAL DOTS BELOW;Mn;220;NSM;;;;;N;;;;;\n0745;SYRIAC THREE DOTS ABOVE;Mn;230;NSM;;;;;N;;;;;\n0746;SYRIAC THREE DOTS BELOW;Mn;220;NSM;;;;;N;;;;;\n0747;SYRIAC OBLIQUE LINE ABOVE;Mn;230;NSM;;;;;N;;;;;\n0748;SYRIAC OBLIQUE LINE BELOW;Mn;220;NSM;;;;;N;;;;;\n0749;SYRIAC MUSIC;Mn;230;NSM;;;;;N;;;;;\n074A;SYRIAC BARREKH;Mn;230;NSM;;;;;N;;;;;\n074D;SYRIAC LETTER SOGDIAN ZHAIN;Lo;0;AL;;;;;N;;;;;\n074E;SYRIAC LETTER SOGDIAN KHAPH;Lo;0;AL;;;;;N;;;;;\n074F;SYRIAC LETTER SOGDIAN FE;Lo;0;AL;;;;;N;;;;;\n0750;ARABIC LETTER BEH WITH THREE DOTS HORIZONTALLY BELOW;Lo;0;AL;;;;;N;;;;;\n0751;ARABIC LETTER BEH WITH DOT BELOW AND THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0752;ARABIC LETTER BEH WITH THREE DOTS POINTING UPWARDS BELOW;Lo;0;AL;;;;;N;;;;;\n0753;ARABIC LETTER BEH WITH THREE DOTS POINTING UPWARDS BELOW AND TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0754;ARABIC LETTER BEH WITH TWO DOTS BELOW AND DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n0755;ARABIC LETTER BEH WITH INVERTED SMALL V BELOW;Lo;0;AL;;;;;N;;;;;\n0756;ARABIC LETTER BEH WITH SMALL V;Lo;0;AL;;;;;N;;;;;\n0757;ARABIC LETTER HAH WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0758;ARABIC LETTER HAH WITH THREE DOTS POINTING UPWARDS BELOW;Lo;0;AL;;;;;N;;;;;\n0759;ARABIC LETTER DAL WITH TWO DOTS VERTICALLY BELOW AND SMALL TAH;Lo;0;AL;;;;;N;;;;;\n075A;ARABIC LETTER DAL WITH INVERTED SMALL V BELOW;Lo;0;AL;;;;;N;;;;;\n075B;ARABIC LETTER REH WITH STROKE;Lo;0;AL;;;;;N;;;;;\n075C;ARABIC LETTER SEEN WITH FOUR DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n075D;ARABIC LETTER AIN WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n075E;ARABIC LETTER AIN WITH THREE DOTS POINTING DOWNWARDS ABOVE;Lo;0;AL;;;;;N;;;;;\n075F;ARABIC LETTER AIN WITH TWO DOTS VERTICALLY ABOVE;Lo;0;AL;;;;;N;;;;;\n0760;ARABIC LETTER FEH WITH TWO DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n0761;ARABIC LETTER FEH WITH THREE DOTS POINTING UPWARDS BELOW;Lo;0;AL;;;;;N;;;;;\n0762;ARABIC LETTER KEHEH WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n0763;ARABIC LETTER KEHEH WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0764;ARABIC LETTER KEHEH WITH THREE DOTS POINTING UPWARDS BELOW;Lo;0;AL;;;;;N;;;;;\n0765;ARABIC LETTER MEEM WITH DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n0766;ARABIC LETTER MEEM WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n0767;ARABIC LETTER NOON WITH TWO DOTS BELOW;Lo;0;AL;;;;;N;;;;;\n0768;ARABIC LETTER NOON WITH SMALL TAH;Lo;0;AL;;;;;N;;;;;\n0769;ARABIC LETTER NOON WITH SMALL V;Lo;0;AL;;;;;N;;;;;\n076A;ARABIC LETTER LAM WITH BAR;Lo;0;AL;;;;;N;;;;;\n076B;ARABIC LETTER REH WITH TWO DOTS VERTICALLY ABOVE;Lo;0;AL;;;;;N;;;;;\n076C;ARABIC LETTER REH WITH HAMZA ABOVE;Lo;0;AL;;;;;N;;;;;\n076D;ARABIC LETTER SEEN WITH TWO DOTS VERTICALLY ABOVE;Lo;0;AL;;;;;N;;;;;\n076E;ARABIC LETTER HAH WITH SMALL ARABIC LETTER TAH BELOW;Lo;0;AL;;;;;N;;;;;\n076F;ARABIC LETTER HAH WITH SMALL ARABIC LETTER TAH AND TWO DOTS;Lo;0;AL;;;;;N;;;;;\n0770;ARABIC LETTER SEEN WITH SMALL ARABIC LETTER TAH AND TWO DOTS;Lo;0;AL;;;;;N;;;;;\n0771;ARABIC LETTER REH WITH SMALL ARABIC LETTER TAH AND TWO DOTS;Lo;0;AL;;;;;N;;;;;\n0772;ARABIC LETTER HAH WITH SMALL ARABIC LETTER TAH ABOVE;Lo;0;AL;;;;;N;;;;;\n0773;ARABIC LETTER ALEF WITH EXTENDED ARABIC-INDIC DIGIT TWO ABOVE;Lo;0;AL;;;;;N;;;;;\n0774;ARABIC LETTER ALEF WITH EXTENDED ARABIC-INDIC DIGIT THREE ABOVE;Lo;0;AL;;;;;N;;;;;\n0775;ARABIC LETTER FARSI YEH WITH EXTENDED ARABIC-INDIC DIGIT TWO ABOVE;Lo;0;AL;;;;;N;;;;;\n0776;ARABIC LETTER FARSI YEH WITH EXTENDED ARABIC-INDIC DIGIT THREE ABOVE;Lo;0;AL;;;;;N;;;;;\n0777;ARABIC LETTER FARSI YEH WITH EXTENDED ARABIC-INDIC DIGIT FOUR BELOW;Lo;0;AL;;;;;N;;;;;\n0778;ARABIC LETTER WAW WITH EXTENDED ARABIC-INDIC DIGIT TWO ABOVE;Lo;0;AL;;;;;N;;;;;\n0779;ARABIC LETTER WAW WITH EXTENDED ARABIC-INDIC DIGIT THREE ABOVE;Lo;0;AL;;;;;N;;;;;\n077A;ARABIC LETTER YEH BARREE WITH EXTENDED ARABIC-INDIC DIGIT TWO ABOVE;Lo;0;AL;;;;;N;;;;;\n077B;ARABIC LETTER YEH BARREE WITH EXTENDED ARABIC-INDIC DIGIT THREE ABOVE;Lo;0;AL;;;;;N;;;;;\n077C;ARABIC LETTER HAH WITH EXTENDED ARABIC-INDIC DIGIT FOUR BELOW;Lo;0;AL;;;;;N;;;;;\n077D;ARABIC LETTER SEEN WITH EXTENDED ARABIC-INDIC DIGIT FOUR ABOVE;Lo;0;AL;;;;;N;;;;;\n077E;ARABIC LETTER SEEN WITH INVERTED V;Lo;0;AL;;;;;N;;;;;\n077F;ARABIC LETTER KAF WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n0780;THAANA LETTER HAA;Lo;0;AL;;;;;N;;;;;\n0781;THAANA LETTER SHAVIYANI;Lo;0;AL;;;;;N;;;;;\n0782;THAANA LETTER NOONU;Lo;0;AL;;;;;N;;;;;\n0783;THAANA LETTER RAA;Lo;0;AL;;;;;N;;;;;\n0784;THAANA LETTER BAA;Lo;0;AL;;;;;N;;;;;\n0785;THAANA LETTER LHAVIYANI;Lo;0;AL;;;;;N;;;;;\n0786;THAANA LETTER KAAFU;Lo;0;AL;;;;;N;;;;;\n0787;THAANA LETTER ALIFU;Lo;0;AL;;;;;N;;;;;\n0788;THAANA LETTER VAAVU;Lo;0;AL;;;;;N;;;;;\n0789;THAANA LETTER MEEMU;Lo;0;AL;;;;;N;;;;;\n078A;THAANA LETTER FAAFU;Lo;0;AL;;;;;N;;;;;\n078B;THAANA LETTER DHAALU;Lo;0;AL;;;;;N;;;;;\n078C;THAANA LETTER THAA;Lo;0;AL;;;;;N;;;;;\n078D;THAANA LETTER LAAMU;Lo;0;AL;;;;;N;;;;;\n078E;THAANA LETTER GAAFU;Lo;0;AL;;;;;N;;;;;\n078F;THAANA LETTER GNAVIYANI;Lo;0;AL;;;;;N;;;;;\n0790;THAANA LETTER SEENU;Lo;0;AL;;;;;N;;;;;\n0791;THAANA LETTER DAVIYANI;Lo;0;AL;;;;;N;;;;;\n0792;THAANA LETTER ZAVIYANI;Lo;0;AL;;;;;N;;;;;\n0793;THAANA LETTER TAVIYANI;Lo;0;AL;;;;;N;;;;;\n0794;THAANA LETTER YAA;Lo;0;AL;;;;;N;;;;;\n0795;THAANA LETTER PAVIYANI;Lo;0;AL;;;;;N;;;;;\n0796;THAANA LETTER JAVIYANI;Lo;0;AL;;;;;N;;;;;\n0797;THAANA LETTER CHAVIYANI;Lo;0;AL;;;;;N;;;;;\n0798;THAANA LETTER TTAA;Lo;0;AL;;;;;N;;;;;\n0799;THAANA LETTER HHAA;Lo;0;AL;;;;;N;;;;;\n079A;THAANA LETTER KHAA;Lo;0;AL;;;;;N;;;;;\n079B;THAANA LETTER THAALU;Lo;0;AL;;;;;N;;;;;\n079C;THAANA LETTER ZAA;Lo;0;AL;;;;;N;;;;;\n079D;THAANA LETTER SHEENU;Lo;0;AL;;;;;N;;;;;\n079E;THAANA LETTER SAADHU;Lo;0;AL;;;;;N;;;;;\n079F;THAANA LETTER DAADHU;Lo;0;AL;;;;;N;;;;;\n07A0;THAANA LETTER TO;Lo;0;AL;;;;;N;;;;;\n07A1;THAANA LETTER ZO;Lo;0;AL;;;;;N;;;;;\n07A2;THAANA LETTER AINU;Lo;0;AL;;;;;N;;;;;\n07A3;THAANA LETTER GHAINU;Lo;0;AL;;;;;N;;;;;\n07A4;THAANA LETTER QAAFU;Lo;0;AL;;;;;N;;;;;\n07A5;THAANA LETTER WAAVU;Lo;0;AL;;;;;N;;;;;\n07A6;THAANA ABAFILI;Mn;0;NSM;;;;;N;;;;;\n07A7;THAANA AABAAFILI;Mn;0;NSM;;;;;N;;;;;\n07A8;THAANA IBIFILI;Mn;0;NSM;;;;;N;;;;;\n07A9;THAANA EEBEEFILI;Mn;0;NSM;;;;;N;;;;;\n07AA;THAANA UBUFILI;Mn;0;NSM;;;;;N;;;;;\n07AB;THAANA OOBOOFILI;Mn;0;NSM;;;;;N;;;;;\n07AC;THAANA EBEFILI;Mn;0;NSM;;;;;N;;;;;\n07AD;THAANA EYBEYFILI;Mn;0;NSM;;;;;N;;;;;\n07AE;THAANA OBOFILI;Mn;0;NSM;;;;;N;;;;;\n07AF;THAANA OABOAFILI;Mn;0;NSM;;;;;N;;;;;\n07B0;THAANA SUKUN;Mn;0;NSM;;;;;N;;;;;\n07B1;THAANA LETTER NAA;Lo;0;AL;;;;;N;;;;;\n07C0;NKO DIGIT ZERO;Nd;0;R;;0;0;0;N;;;;;\n07C1;NKO DIGIT ONE;Nd;0;R;;1;1;1;N;;;;;\n07C2;NKO DIGIT TWO;Nd;0;R;;2;2;2;N;;;;;\n07C3;NKO DIGIT THREE;Nd;0;R;;3;3;3;N;;;;;\n07C4;NKO DIGIT FOUR;Nd;0;R;;4;4;4;N;;;;;\n07C5;NKO DIGIT FIVE;Nd;0;R;;5;5;5;N;;;;;\n07C6;NKO DIGIT SIX;Nd;0;R;;6;6;6;N;;;;;\n07C7;NKO DIGIT SEVEN;Nd;0;R;;7;7;7;N;;;;;\n07C8;NKO DIGIT EIGHT;Nd;0;R;;8;8;8;N;;;;;\n07C9;NKO DIGIT NINE;Nd;0;R;;9;9;9;N;;;;;\n07CA;NKO LETTER A;Lo;0;R;;;;;N;;;;;\n07CB;NKO LETTER EE;Lo;0;R;;;;;N;;;;;\n07CC;NKO LETTER I;Lo;0;R;;;;;N;;;;;\n07CD;NKO LETTER E;Lo;0;R;;;;;N;;;;;\n07CE;NKO LETTER U;Lo;0;R;;;;;N;;;;;\n07CF;NKO LETTER OO;Lo;0;R;;;;;N;;;;;\n07D0;NKO LETTER O;Lo;0;R;;;;;N;;;;;\n07D1;NKO LETTER DAGBASINNA;Lo;0;R;;;;;N;;;;;\n07D2;NKO LETTER N;Lo;0;R;;;;;N;;;;;\n07D3;NKO LETTER BA;Lo;0;R;;;;;N;;;;;\n07D4;NKO LETTER PA;Lo;0;R;;;;;N;;;;;\n07D5;NKO LETTER TA;Lo;0;R;;;;;N;;;;;\n07D6;NKO LETTER JA;Lo;0;R;;;;;N;;;;;\n07D7;NKO LETTER CHA;Lo;0;R;;;;;N;;;;;\n07D8;NKO LETTER DA;Lo;0;R;;;;;N;;;;;\n07D9;NKO LETTER RA;Lo;0;R;;;;;N;;;;;\n07DA;NKO LETTER RRA;Lo;0;R;;;;;N;;;;;\n07DB;NKO LETTER SA;Lo;0;R;;;;;N;;;;;\n07DC;NKO LETTER GBA;Lo;0;R;;;;;N;;;;;\n07DD;NKO LETTER FA;Lo;0;R;;;;;N;;;;;\n07DE;NKO LETTER KA;Lo;0;R;;;;;N;;;;;\n07DF;NKO LETTER LA;Lo;0;R;;;;;N;;;;;\n07E0;NKO LETTER NA WOLOSO;Lo;0;R;;;;;N;;;;;\n07E1;NKO LETTER MA;Lo;0;R;;;;;N;;;;;\n07E2;NKO LETTER NYA;Lo;0;R;;;;;N;;;;;\n07E3;NKO LETTER NA;Lo;0;R;;;;;N;;;;;\n07E4;NKO LETTER HA;Lo;0;R;;;;;N;;;;;\n07E5;NKO LETTER WA;Lo;0;R;;;;;N;;;;;\n07E6;NKO LETTER YA;Lo;0;R;;;;;N;;;;;\n07E7;NKO LETTER NYA WOLOSO;Lo;0;R;;;;;N;;;;;\n07E8;NKO LETTER JONA JA;Lo;0;R;;;;;N;;;;;\n07E9;NKO LETTER JONA CHA;Lo;0;R;;;;;N;;;;;\n07EA;NKO LETTER JONA RA;Lo;0;R;;;;;N;;;;;\n07EB;NKO COMBINING SHORT HIGH TONE;Mn;230;NSM;;;;;N;;;;;\n07EC;NKO COMBINING SHORT LOW TONE;Mn;230;NSM;;;;;N;;;;;\n07ED;NKO COMBINING SHORT RISING TONE;Mn;230;NSM;;;;;N;;;;;\n07EE;NKO COMBINING LONG DESCENDING TONE;Mn;230;NSM;;;;;N;;;;;\n07EF;NKO COMBINING LONG HIGH TONE;Mn;230;NSM;;;;;N;;;;;\n07F0;NKO COMBINING LONG LOW TONE;Mn;230;NSM;;;;;N;;;;;\n07F1;NKO COMBINING LONG RISING TONE;Mn;230;NSM;;;;;N;;;;;\n07F2;NKO COMBINING NASALIZATION MARK;Mn;220;NSM;;;;;N;;;;;\n07F3;NKO COMBINING DOUBLE DOT ABOVE;Mn;230;NSM;;;;;N;;;;;\n07F4;NKO HIGH TONE APOSTROPHE;Lm;0;R;;;;;N;;;;;\n07F5;NKO LOW TONE APOSTROPHE;Lm;0;R;;;;;N;;;;;\n07F6;NKO SYMBOL OO DENNEN;So;0;ON;;;;;N;;;;;\n07F7;NKO SYMBOL GBAKURUNEN;Po;0;ON;;;;;N;;;;;\n07F8;NKO COMMA;Po;0;ON;;;;;N;;;;;\n07F9;NKO EXCLAMATION MARK;Po;0;ON;;;;;N;;;;;\n07FA;NKO LAJANYALAN;Lm;0;R;;;;;N;;;;;\n0800;SAMARITAN LETTER ALAF;Lo;0;R;;;;;N;;;;;\n0801;SAMARITAN LETTER BIT;Lo;0;R;;;;;N;;;;;\n0802;SAMARITAN LETTER GAMAN;Lo;0;R;;;;;N;;;;;\n0803;SAMARITAN LETTER DALAT;Lo;0;R;;;;;N;;;;;\n0804;SAMARITAN LETTER IY;Lo;0;R;;;;;N;;;;;\n0805;SAMARITAN LETTER BAA;Lo;0;R;;;;;N;;;;;\n0806;SAMARITAN LETTER ZEN;Lo;0;R;;;;;N;;;;;\n0807;SAMARITAN LETTER IT;Lo;0;R;;;;;N;;;;;\n0808;SAMARITAN LETTER TIT;Lo;0;R;;;;;N;;;;;\n0809;SAMARITAN LETTER YUT;Lo;0;R;;;;;N;;;;;\n080A;SAMARITAN LETTER KAAF;Lo;0;R;;;;;N;;;;;\n080B;SAMARITAN LETTER LABAT;Lo;0;R;;;;;N;;;;;\n080C;SAMARITAN LETTER MIM;Lo;0;R;;;;;N;;;;;\n080D;SAMARITAN LETTER NUN;Lo;0;R;;;;;N;;;;;\n080E;SAMARITAN LETTER SINGAAT;Lo;0;R;;;;;N;;;;;\n080F;SAMARITAN LETTER IN;Lo;0;R;;;;;N;;;;;\n0810;SAMARITAN LETTER FI;Lo;0;R;;;;;N;;;;;\n0811;SAMARITAN LETTER TSAADIY;Lo;0;R;;;;;N;;;;;\n0812;SAMARITAN LETTER QUF;Lo;0;R;;;;;N;;;;;\n0813;SAMARITAN LETTER RISH;Lo;0;R;;;;;N;;;;;\n0814;SAMARITAN LETTER SHAN;Lo;0;R;;;;;N;;;;;\n0815;SAMARITAN LETTER TAAF;Lo;0;R;;;;;N;;;;;\n0816;SAMARITAN MARK IN;Mn;230;NSM;;;;;N;;;;;\n0817;SAMARITAN MARK IN-ALAF;Mn;230;NSM;;;;;N;;;;;\n0818;SAMARITAN MARK OCCLUSION;Mn;230;NSM;;;;;N;;;;;\n0819;SAMARITAN MARK DAGESH;Mn;230;NSM;;;;;N;;;;;\n081A;SAMARITAN MODIFIER LETTER EPENTHETIC YUT;Lm;0;R;;;;;N;;;;;\n081B;SAMARITAN MARK EPENTHETIC YUT;Mn;230;NSM;;;;;N;;;;;\n081C;SAMARITAN VOWEL SIGN LONG E;Mn;230;NSM;;;;;N;;;;;\n081D;SAMARITAN VOWEL SIGN E;Mn;230;NSM;;;;;N;;;;;\n081E;SAMARITAN VOWEL SIGN OVERLONG AA;Mn;230;NSM;;;;;N;;;;;\n081F;SAMARITAN VOWEL SIGN LONG AA;Mn;230;NSM;;;;;N;;;;;\n0820;SAMARITAN VOWEL SIGN AA;Mn;230;NSM;;;;;N;;;;;\n0821;SAMARITAN VOWEL SIGN OVERLONG A;Mn;230;NSM;;;;;N;;;;;\n0822;SAMARITAN VOWEL SIGN LONG A;Mn;230;NSM;;;;;N;;;;;\n0823;SAMARITAN VOWEL SIGN A;Mn;230;NSM;;;;;N;;;;;\n0824;SAMARITAN MODIFIER LETTER SHORT A;Lm;0;R;;;;;N;;;;;\n0825;SAMARITAN VOWEL SIGN SHORT A;Mn;230;NSM;;;;;N;;;;;\n0826;SAMARITAN VOWEL SIGN LONG U;Mn;230;NSM;;;;;N;;;;;\n0827;SAMARITAN VOWEL SIGN U;Mn;230;NSM;;;;;N;;;;;\n0828;SAMARITAN MODIFIER LETTER I;Lm;0;R;;;;;N;;;;;\n0829;SAMARITAN VOWEL SIGN LONG I;Mn;230;NSM;;;;;N;;;;;\n082A;SAMARITAN VOWEL SIGN I;Mn;230;NSM;;;;;N;;;;;\n082B;SAMARITAN VOWEL SIGN O;Mn;230;NSM;;;;;N;;;;;\n082C;SAMARITAN VOWEL SIGN SUKUN;Mn;230;NSM;;;;;N;;;;;\n082D;SAMARITAN MARK NEQUDAA;Mn;230;NSM;;;;;N;;;;;\n0830;SAMARITAN PUNCTUATION NEQUDAA;Po;0;R;;;;;N;;;;;\n0831;SAMARITAN PUNCTUATION AFSAAQ;Po;0;R;;;;;N;;;;;\n0832;SAMARITAN PUNCTUATION ANGED;Po;0;R;;;;;N;;;;;\n0833;SAMARITAN PUNCTUATION BAU;Po;0;R;;;;;N;;;;;\n0834;SAMARITAN PUNCTUATION ATMAAU;Po;0;R;;;;;N;;;;;\n0835;SAMARITAN PUNCTUATION SHIYYAALAA;Po;0;R;;;;;N;;;;;\n0836;SAMARITAN ABBREVIATION MARK;Po;0;R;;;;;N;;;;;\n0837;SAMARITAN PUNCTUATION MELODIC QITSA;Po;0;R;;;;;N;;;;;\n0838;SAMARITAN PUNCTUATION ZIQAA;Po;0;R;;;;;N;;;;;\n0839;SAMARITAN PUNCTUATION QITSA;Po;0;R;;;;;N;;;;;\n083A;SAMARITAN PUNCTUATION ZAEF;Po;0;R;;;;;N;;;;;\n083B;SAMARITAN PUNCTUATION TURU;Po;0;R;;;;;N;;;;;\n083C;SAMARITAN PUNCTUATION ARKAANU;Po;0;R;;;;;N;;;;;\n083D;SAMARITAN PUNCTUATION SOF MASHFAAT;Po;0;R;;;;;N;;;;;\n083E;SAMARITAN PUNCTUATION ANNAAU;Po;0;R;;;;;N;;;;;\n0840;MANDAIC LETTER HALQA;Lo;0;R;;;;;N;;;;;\n0841;MANDAIC LETTER AB;Lo;0;R;;;;;N;;;;;\n0842;MANDAIC LETTER AG;Lo;0;R;;;;;N;;;;;\n0843;MANDAIC LETTER AD;Lo;0;R;;;;;N;;;;;\n0844;MANDAIC LETTER AH;Lo;0;R;;;;;N;;;;;\n0845;MANDAIC LETTER USHENNA;Lo;0;R;;;;;N;;;;;\n0846;MANDAIC LETTER AZ;Lo;0;R;;;;;N;;;;;\n0847;MANDAIC LETTER IT;Lo;0;R;;;;;N;;;;;\n0848;MANDAIC LETTER ATT;Lo;0;R;;;;;N;;;;;\n0849;MANDAIC LETTER AKSA;Lo;0;R;;;;;N;;;;;\n084A;MANDAIC LETTER AK;Lo;0;R;;;;;N;;;;;\n084B;MANDAIC LETTER AL;Lo;0;R;;;;;N;;;;;\n084C;MANDAIC LETTER AM;Lo;0;R;;;;;N;;;;;\n084D;MANDAIC LETTER AN;Lo;0;R;;;;;N;;;;;\n084E;MANDAIC LETTER AS;Lo;0;R;;;;;N;;;;;\n084F;MANDAIC LETTER IN;Lo;0;R;;;;;N;;;;;\n0850;MANDAIC LETTER AP;Lo;0;R;;;;;N;;;;;\n0851;MANDAIC LETTER ASZ;Lo;0;R;;;;;N;;;;;\n0852;MANDAIC LETTER AQ;Lo;0;R;;;;;N;;;;;\n0853;MANDAIC LETTER AR;Lo;0;R;;;;;N;;;;;\n0854;MANDAIC LETTER ASH;Lo;0;R;;;;;N;;;;;\n0855;MANDAIC LETTER AT;Lo;0;R;;;;;N;;;;;\n0856;MANDAIC LETTER DUSHENNA;Lo;0;R;;;;;N;;;;;\n0857;MANDAIC LETTER KAD;Lo;0;R;;;;;N;;;;;\n0858;MANDAIC LETTER AIN;Lo;0;R;;;;;N;;;;;\n0859;MANDAIC AFFRICATION MARK;Mn;220;NSM;;;;;N;;;;;\n085A;MANDAIC VOCALIZATION MARK;Mn;220;NSM;;;;;N;;;;;\n085B;MANDAIC GEMINATION MARK;Mn;220;NSM;;;;;N;;;;;\n085E;MANDAIC PUNCTUATION;Po;0;R;;;;;N;;;;;\n08A0;ARABIC LETTER BEH WITH SMALL V BELOW;Lo;0;AL;;;;;N;;;;;\n08A2;ARABIC LETTER JEEM WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n08A3;ARABIC LETTER TAH WITH TWO DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n08A4;ARABIC LETTER FEH WITH DOT BELOW AND THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n08A5;ARABIC LETTER QAF WITH DOT BELOW;Lo;0;AL;;;;;N;;;;;\n08A6;ARABIC LETTER LAM WITH DOUBLE BAR;Lo;0;AL;;;;;N;;;;;\n08A7;ARABIC LETTER MEEM WITH THREE DOTS ABOVE;Lo;0;AL;;;;;N;;;;;\n08A8;ARABIC LETTER YEH WITH TWO DOTS BELOW AND HAMZA ABOVE;Lo;0;AL;;;;;N;;;;;\n08A9;ARABIC LETTER YEH WITH TWO DOTS BELOW AND DOT ABOVE;Lo;0;AL;;;;;N;;;;;\n08AA;ARABIC LETTER REH WITH LOOP;Lo;0;AL;;;;;N;;;;;\n08AB;ARABIC LETTER WAW WITH DOT WITHIN;Lo;0;AL;;;;;N;;;;;\n08AC;ARABIC LETTER ROHINGYA YEH;Lo;0;AL;;;;;N;;;;;\n08E4;ARABIC CURLY FATHA;Mn;230;NSM;;;;;N;;;;;\n08E5;ARABIC CURLY DAMMA;Mn;230;NSM;;;;;N;;;;;\n08E6;ARABIC CURLY KASRA;Mn;220;NSM;;;;;N;;;;;\n08E7;ARABIC CURLY FATHATAN;Mn;230;NSM;;;;;N;;;;;\n08E8;ARABIC CURLY DAMMATAN;Mn;230;NSM;;;;;N;;;;;\n08E9;ARABIC CURLY KASRATAN;Mn;220;NSM;;;;;N;;;;;\n08EA;ARABIC TONE ONE DOT ABOVE;Mn;230;NSM;;;;;N;;;;;\n08EB;ARABIC TONE TWO DOTS ABOVE;Mn;230;NSM;;;;;N;;;;;\n08EC;ARABIC TONE LOOP ABOVE;Mn;230;NSM;;;;;N;;;;;\n08ED;ARABIC TONE ONE DOT BELOW;Mn;220;NSM;;;;;N;;;;;\n08EE;ARABIC TONE TWO DOTS BELOW;Mn;220;NSM;;;;;N;;;;;\n08EF;ARABIC TONE LOOP BELOW;Mn;220;NSM;;;;;N;;;;;\n08F0;ARABIC OPEN FATHATAN;Mn;27;NSM;;;;;N;;;;;\n08F1;ARABIC OPEN DAMMATAN;Mn;28;NSM;;;;;N;;;;;\n08F2;ARABIC OPEN KASRATAN;Mn;29;NSM;;;;;N;;;;;\n08F3;ARABIC SMALL HIGH WAW;Mn;230;NSM;;;;;N;;;;;\n08F4;ARABIC FATHA WITH RING;Mn;230;NSM;;;;;N;;;;;\n08F5;ARABIC FATHA WITH DOT ABOVE;Mn;230;NSM;;;;;N;;;;;\n08F6;ARABIC KASRA WITH DOT BELOW;Mn;220;NSM;;;;;N;;;;;\n08F7;ARABIC LEFT ARROWHEAD ABOVE;Mn;230;NSM;;;;;N;;;;;\n08F8;ARABIC RIGHT ARROWHEAD ABOVE;Mn;230;NSM;;;;;N;;;;;\n08F9;ARABIC LEFT ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n08FA;ARABIC RIGHT ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n08FB;ARABIC DOUBLE RIGHT ARROWHEAD ABOVE;Mn;230;NSM;;;;;N;;;;;\n08FC;ARABIC DOUBLE RIGHT ARROWHEAD ABOVE WITH DOT;Mn;230;NSM;;;;;N;;;;;\n08FD;ARABIC RIGHT ARROWHEAD ABOVE WITH DOT;Mn;230;NSM;;;;;N;;;;;\n08FE;ARABIC DAMMA WITH DOT;Mn;230;NSM;;;;;N;;;;;\n0900;DEVANAGARI SIGN INVERTED CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n0901;DEVANAGARI SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n0902;DEVANAGARI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n0903;DEVANAGARI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0904;DEVANAGARI LETTER SHORT A;Lo;0;L;;;;;N;;;;;\n0905;DEVANAGARI LETTER A;Lo;0;L;;;;;N;;;;;\n0906;DEVANAGARI LETTER AA;Lo;0;L;;;;;N;;;;;\n0907;DEVANAGARI LETTER I;Lo;0;L;;;;;N;;;;;\n0908;DEVANAGARI LETTER II;Lo;0;L;;;;;N;;;;;\n0909;DEVANAGARI LETTER U;Lo;0;L;;;;;N;;;;;\n090A;DEVANAGARI LETTER UU;Lo;0;L;;;;;N;;;;;\n090B;DEVANAGARI LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n090C;DEVANAGARI LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n090D;DEVANAGARI LETTER CANDRA E;Lo;0;L;;;;;N;;;;;\n090E;DEVANAGARI LETTER SHORT E;Lo;0;L;;;;;N;;;;;\n090F;DEVANAGARI LETTER E;Lo;0;L;;;;;N;;;;;\n0910;DEVANAGARI LETTER AI;Lo;0;L;;;;;N;;;;;\n0911;DEVANAGARI LETTER CANDRA O;Lo;0;L;;;;;N;;;;;\n0912;DEVANAGARI LETTER SHORT O;Lo;0;L;;;;;N;;;;;\n0913;DEVANAGARI LETTER O;Lo;0;L;;;;;N;;;;;\n0914;DEVANAGARI LETTER AU;Lo;0;L;;;;;N;;;;;\n0915;DEVANAGARI LETTER KA;Lo;0;L;;;;;N;;;;;\n0916;DEVANAGARI LETTER KHA;Lo;0;L;;;;;N;;;;;\n0917;DEVANAGARI LETTER GA;Lo;0;L;;;;;N;;;;;\n0918;DEVANAGARI LETTER GHA;Lo;0;L;;;;;N;;;;;\n0919;DEVANAGARI LETTER NGA;Lo;0;L;;;;;N;;;;;\n091A;DEVANAGARI LETTER CA;Lo;0;L;;;;;N;;;;;\n091B;DEVANAGARI LETTER CHA;Lo;0;L;;;;;N;;;;;\n091C;DEVANAGARI LETTER JA;Lo;0;L;;;;;N;;;;;\n091D;DEVANAGARI LETTER JHA;Lo;0;L;;;;;N;;;;;\n091E;DEVANAGARI LETTER NYA;Lo;0;L;;;;;N;;;;;\n091F;DEVANAGARI LETTER TTA;Lo;0;L;;;;;N;;;;;\n0920;DEVANAGARI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0921;DEVANAGARI LETTER DDA;Lo;0;L;;;;;N;;;;;\n0922;DEVANAGARI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0923;DEVANAGARI LETTER NNA;Lo;0;L;;;;;N;;;;;\n0924;DEVANAGARI LETTER TA;Lo;0;L;;;;;N;;;;;\n0925;DEVANAGARI LETTER THA;Lo;0;L;;;;;N;;;;;\n0926;DEVANAGARI LETTER DA;Lo;0;L;;;;;N;;;;;\n0927;DEVANAGARI LETTER DHA;Lo;0;L;;;;;N;;;;;\n0928;DEVANAGARI LETTER NA;Lo;0;L;;;;;N;;;;;\n0929;DEVANAGARI LETTER NNNA;Lo;0;L;0928 093C;;;;N;;;;;\n092A;DEVANAGARI LETTER PA;Lo;0;L;;;;;N;;;;;\n092B;DEVANAGARI LETTER PHA;Lo;0;L;;;;;N;;;;;\n092C;DEVANAGARI LETTER BA;Lo;0;L;;;;;N;;;;;\n092D;DEVANAGARI LETTER BHA;Lo;0;L;;;;;N;;;;;\n092E;DEVANAGARI LETTER MA;Lo;0;L;;;;;N;;;;;\n092F;DEVANAGARI LETTER YA;Lo;0;L;;;;;N;;;;;\n0930;DEVANAGARI LETTER RA;Lo;0;L;;;;;N;;;;;\n0931;DEVANAGARI LETTER RRA;Lo;0;L;0930 093C;;;;N;;;;;\n0932;DEVANAGARI LETTER LA;Lo;0;L;;;;;N;;;;;\n0933;DEVANAGARI LETTER LLA;Lo;0;L;;;;;N;;;;;\n0934;DEVANAGARI LETTER LLLA;Lo;0;L;0933 093C;;;;N;;;;;\n0935;DEVANAGARI LETTER VA;Lo;0;L;;;;;N;;;;;\n0936;DEVANAGARI LETTER SHA;Lo;0;L;;;;;N;;;;;\n0937;DEVANAGARI LETTER SSA;Lo;0;L;;;;;N;;;;;\n0938;DEVANAGARI LETTER SA;Lo;0;L;;;;;N;;;;;\n0939;DEVANAGARI LETTER HA;Lo;0;L;;;;;N;;;;;\n093A;DEVANAGARI VOWEL SIGN OE;Mn;0;NSM;;;;;N;;;;;\n093B;DEVANAGARI VOWEL SIGN OOE;Mc;0;L;;;;;N;;;;;\n093C;DEVANAGARI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n093D;DEVANAGARI SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n093E;DEVANAGARI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n093F;DEVANAGARI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n0940;DEVANAGARI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n0941;DEVANAGARI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n0942;DEVANAGARI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n0943;DEVANAGARI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n0944;DEVANAGARI VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n0945;DEVANAGARI VOWEL SIGN CANDRA E;Mn;0;NSM;;;;;N;;;;;\n0946;DEVANAGARI VOWEL SIGN SHORT E;Mn;0;NSM;;;;;N;;;;;\n0947;DEVANAGARI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n0948;DEVANAGARI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n0949;DEVANAGARI VOWEL SIGN CANDRA O;Mc;0;L;;;;;N;;;;;\n094A;DEVANAGARI VOWEL SIGN SHORT O;Mc;0;L;;;;;N;;;;;\n094B;DEVANAGARI VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n094C;DEVANAGARI VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n094D;DEVANAGARI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n094E;DEVANAGARI VOWEL SIGN PRISHTHAMATRA E;Mc;0;L;;;;;N;;;;;\n094F;DEVANAGARI VOWEL SIGN AW;Mc;0;L;;;;;N;;;;;\n0950;DEVANAGARI OM;Lo;0;L;;;;;N;;;;;\n0951;DEVANAGARI STRESS SIGN UDATTA;Mn;230;NSM;;;;;N;;;;;\n0952;DEVANAGARI STRESS SIGN ANUDATTA;Mn;220;NSM;;;;;N;;;;;\n0953;DEVANAGARI GRAVE ACCENT;Mn;230;NSM;;;;;N;;;;;\n0954;DEVANAGARI ACUTE ACCENT;Mn;230;NSM;;;;;N;;;;;\n0955;DEVANAGARI VOWEL SIGN CANDRA LONG E;Mn;0;NSM;;;;;N;;;;;\n0956;DEVANAGARI VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;;\n0957;DEVANAGARI VOWEL SIGN UUE;Mn;0;NSM;;;;;N;;;;;\n0958;DEVANAGARI LETTER QA;Lo;0;L;0915 093C;;;;N;;;;;\n0959;DEVANAGARI LETTER KHHA;Lo;0;L;0916 093C;;;;N;;;;;\n095A;DEVANAGARI LETTER GHHA;Lo;0;L;0917 093C;;;;N;;;;;\n095B;DEVANAGARI LETTER ZA;Lo;0;L;091C 093C;;;;N;;;;;\n095C;DEVANAGARI LETTER DDDHA;Lo;0;L;0921 093C;;;;N;;;;;\n095D;DEVANAGARI LETTER RHA;Lo;0;L;0922 093C;;;;N;;;;;\n095E;DEVANAGARI LETTER FA;Lo;0;L;092B 093C;;;;N;;;;;\n095F;DEVANAGARI LETTER YYA;Lo;0;L;092F 093C;;;;N;;;;;\n0960;DEVANAGARI LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0961;DEVANAGARI LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0962;DEVANAGARI VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0963;DEVANAGARI VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0964;DEVANAGARI DANDA;Po;0;L;;;;;N;;;;;\n0965;DEVANAGARI DOUBLE DANDA;Po;0;L;;;;;N;;;;;\n0966;DEVANAGARI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0967;DEVANAGARI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0968;DEVANAGARI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0969;DEVANAGARI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n096A;DEVANAGARI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n096B;DEVANAGARI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n096C;DEVANAGARI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n096D;DEVANAGARI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n096E;DEVANAGARI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n096F;DEVANAGARI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0970;DEVANAGARI ABBREVIATION SIGN;Po;0;L;;;;;N;;;;;\n0971;DEVANAGARI SIGN HIGH SPACING DOT;Lm;0;L;;;;;N;;;;;\n0972;DEVANAGARI LETTER CANDRA A;Lo;0;L;;;;;N;;;;;\n0973;DEVANAGARI LETTER OE;Lo;0;L;;;;;N;;;;;\n0974;DEVANAGARI LETTER OOE;Lo;0;L;;;;;N;;;;;\n0975;DEVANAGARI LETTER AW;Lo;0;L;;;;;N;;;;;\n0976;DEVANAGARI LETTER UE;Lo;0;L;;;;;N;;;;;\n0977;DEVANAGARI LETTER UUE;Lo;0;L;;;;;N;;;;;\n0979;DEVANAGARI LETTER ZHA;Lo;0;L;;;;;N;;;;;\n097A;DEVANAGARI LETTER HEAVY YA;Lo;0;L;;;;;N;;;;;\n097B;DEVANAGARI LETTER GGA;Lo;0;L;;;;;N;;;;;\n097C;DEVANAGARI LETTER JJA;Lo;0;L;;;;;N;;;;;\n097D;DEVANAGARI LETTER GLOTTAL STOP;Lo;0;L;;;;;N;;;;;\n097E;DEVANAGARI LETTER DDDA;Lo;0;L;;;;;N;;;;;\n097F;DEVANAGARI LETTER BBA;Lo;0;L;;;;;N;;;;;\n0981;BENGALI SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n0982;BENGALI SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\n0983;BENGALI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0985;BENGALI LETTER A;Lo;0;L;;;;;N;;;;;\n0986;BENGALI LETTER AA;Lo;0;L;;;;;N;;;;;\n0987;BENGALI LETTER I;Lo;0;L;;;;;N;;;;;\n0988;BENGALI LETTER II;Lo;0;L;;;;;N;;;;;\n0989;BENGALI LETTER U;Lo;0;L;;;;;N;;;;;\n098A;BENGALI LETTER UU;Lo;0;L;;;;;N;;;;;\n098B;BENGALI LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n098C;BENGALI LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n098F;BENGALI LETTER E;Lo;0;L;;;;;N;;;;;\n0990;BENGALI LETTER AI;Lo;0;L;;;;;N;;;;;\n0993;BENGALI LETTER O;Lo;0;L;;;;;N;;;;;\n0994;BENGALI LETTER AU;Lo;0;L;;;;;N;;;;;\n0995;BENGALI LETTER KA;Lo;0;L;;;;;N;;;;;\n0996;BENGALI LETTER KHA;Lo;0;L;;;;;N;;;;;\n0997;BENGALI LETTER GA;Lo;0;L;;;;;N;;;;;\n0998;BENGALI LETTER GHA;Lo;0;L;;;;;N;;;;;\n0999;BENGALI LETTER NGA;Lo;0;L;;;;;N;;;;;\n099A;BENGALI LETTER CA;Lo;0;L;;;;;N;;;;;\n099B;BENGALI LETTER CHA;Lo;0;L;;;;;N;;;;;\n099C;BENGALI LETTER JA;Lo;0;L;;;;;N;;;;;\n099D;BENGALI LETTER JHA;Lo;0;L;;;;;N;;;;;\n099E;BENGALI LETTER NYA;Lo;0;L;;;;;N;;;;;\n099F;BENGALI LETTER TTA;Lo;0;L;;;;;N;;;;;\n09A0;BENGALI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n09A1;BENGALI LETTER DDA;Lo;0;L;;;;;N;;;;;\n09A2;BENGALI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n09A3;BENGALI LETTER NNA;Lo;0;L;;;;;N;;;;;\n09A4;BENGALI LETTER TA;Lo;0;L;;;;;N;;;;;\n09A5;BENGALI LETTER THA;Lo;0;L;;;;;N;;;;;\n09A6;BENGALI LETTER DA;Lo;0;L;;;;;N;;;;;\n09A7;BENGALI LETTER DHA;Lo;0;L;;;;;N;;;;;\n09A8;BENGALI LETTER NA;Lo;0;L;;;;;N;;;;;\n09AA;BENGALI LETTER PA;Lo;0;L;;;;;N;;;;;\n09AB;BENGALI LETTER PHA;Lo;0;L;;;;;N;;;;;\n09AC;BENGALI LETTER BA;Lo;0;L;;;;;N;;;;;\n09AD;BENGALI LETTER BHA;Lo;0;L;;;;;N;;;;;\n09AE;BENGALI LETTER MA;Lo;0;L;;;;;N;;;;;\n09AF;BENGALI LETTER YA;Lo;0;L;;;;;N;;;;;\n09B0;BENGALI LETTER RA;Lo;0;L;;;;;N;;;;;\n09B2;BENGALI LETTER LA;Lo;0;L;;;;;N;;;;;\n09B6;BENGALI LETTER SHA;Lo;0;L;;;;;N;;;;;\n09B7;BENGALI LETTER SSA;Lo;0;L;;;;;N;;;;;\n09B8;BENGALI LETTER SA;Lo;0;L;;;;;N;;;;;\n09B9;BENGALI LETTER HA;Lo;0;L;;;;;N;;;;;\n09BC;BENGALI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n09BD;BENGALI SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n09BE;BENGALI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n09BF;BENGALI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n09C0;BENGALI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n09C1;BENGALI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n09C2;BENGALI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n09C3;BENGALI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n09C4;BENGALI VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n09C7;BENGALI VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n09C8;BENGALI VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n09CB;BENGALI VOWEL SIGN O;Mc;0;L;09C7 09BE;;;;N;;;;;\n09CC;BENGALI VOWEL SIGN AU;Mc;0;L;09C7 09D7;;;;N;;;;;\n09CD;BENGALI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n09CE;BENGALI LETTER KHANDA TA;Lo;0;L;;;;;N;;;;;\n09D7;BENGALI AU LENGTH MARK;Mc;0;L;;;;;N;;;;;\n09DC;BENGALI LETTER RRA;Lo;0;L;09A1 09BC;;;;N;;;;;\n09DD;BENGALI LETTER RHA;Lo;0;L;09A2 09BC;;;;N;;;;;\n09DF;BENGALI LETTER YYA;Lo;0;L;09AF 09BC;;;;N;;;;;\n09E0;BENGALI LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n09E1;BENGALI LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n09E2;BENGALI VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n09E3;BENGALI VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n09E6;BENGALI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n09E7;BENGALI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n09E8;BENGALI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n09E9;BENGALI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n09EA;BENGALI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n09EB;BENGALI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n09EC;BENGALI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n09ED;BENGALI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n09EE;BENGALI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n09EF;BENGALI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n09F0;BENGALI LETTER RA WITH MIDDLE DIAGONAL;Lo;0;L;;;;;N;;;;;\n09F1;BENGALI LETTER RA WITH LOWER DIAGONAL;Lo;0;L;;;;;N;BENGALI LETTER VA WITH LOWER DIAGONAL;;;;\n09F2;BENGALI RUPEE MARK;Sc;0;ET;;;;;N;;;;;\n09F3;BENGALI RUPEE SIGN;Sc;0;ET;;;;;N;;;;;\n09F4;BENGALI CURRENCY NUMERATOR ONE;No;0;L;;;;1/16;N;;;;;\n09F5;BENGALI CURRENCY NUMERATOR TWO;No;0;L;;;;1/8;N;;;;;\n09F6;BENGALI CURRENCY NUMERATOR THREE;No;0;L;;;;3/16;N;;;;;\n09F7;BENGALI CURRENCY NUMERATOR FOUR;No;0;L;;;;1/4;N;;;;;\n09F8;BENGALI CURRENCY NUMERATOR ONE LESS THAN THE DENOMINATOR;No;0;L;;;;3/4;N;;;;;\n09F9;BENGALI CURRENCY DENOMINATOR SIXTEEN;No;0;L;;;;16;N;;;;;\n09FA;BENGALI ISSHAR;So;0;L;;;;;N;;;;;\n09FB;BENGALI GANDA MARK;Sc;0;ET;;;;;N;;;;;\n0A01;GURMUKHI SIGN ADAK BINDI;Mn;0;NSM;;;;;N;;;;;\n0A02;GURMUKHI SIGN BINDI;Mn;0;NSM;;;;;N;;;;;\n0A03;GURMUKHI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0A05;GURMUKHI LETTER A;Lo;0;L;;;;;N;;;;;\n0A06;GURMUKHI LETTER AA;Lo;0;L;;;;;N;;;;;\n0A07;GURMUKHI LETTER I;Lo;0;L;;;;;N;;;;;\n0A08;GURMUKHI LETTER II;Lo;0;L;;;;;N;;;;;\n0A09;GURMUKHI LETTER U;Lo;0;L;;;;;N;;;;;\n0A0A;GURMUKHI LETTER UU;Lo;0;L;;;;;N;;;;;\n0A0F;GURMUKHI LETTER EE;Lo;0;L;;;;;N;;;;;\n0A10;GURMUKHI LETTER AI;Lo;0;L;;;;;N;;;;;\n0A13;GURMUKHI LETTER OO;Lo;0;L;;;;;N;;;;;\n0A14;GURMUKHI LETTER AU;Lo;0;L;;;;;N;;;;;\n0A15;GURMUKHI LETTER KA;Lo;0;L;;;;;N;;;;;\n0A16;GURMUKHI LETTER KHA;Lo;0;L;;;;;N;;;;;\n0A17;GURMUKHI LETTER GA;Lo;0;L;;;;;N;;;;;\n0A18;GURMUKHI LETTER GHA;Lo;0;L;;;;;N;;;;;\n0A19;GURMUKHI LETTER NGA;Lo;0;L;;;;;N;;;;;\n0A1A;GURMUKHI LETTER CA;Lo;0;L;;;;;N;;;;;\n0A1B;GURMUKHI LETTER CHA;Lo;0;L;;;;;N;;;;;\n0A1C;GURMUKHI LETTER JA;Lo;0;L;;;;;N;;;;;\n0A1D;GURMUKHI LETTER JHA;Lo;0;L;;;;;N;;;;;\n0A1E;GURMUKHI LETTER NYA;Lo;0;L;;;;;N;;;;;\n0A1F;GURMUKHI LETTER TTA;Lo;0;L;;;;;N;;;;;\n0A20;GURMUKHI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0A21;GURMUKHI LETTER DDA;Lo;0;L;;;;;N;;;;;\n0A22;GURMUKHI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0A23;GURMUKHI LETTER NNA;Lo;0;L;;;;;N;;;;;\n0A24;GURMUKHI LETTER TA;Lo;0;L;;;;;N;;;;;\n0A25;GURMUKHI LETTER THA;Lo;0;L;;;;;N;;;;;\n0A26;GURMUKHI LETTER DA;Lo;0;L;;;;;N;;;;;\n0A27;GURMUKHI LETTER DHA;Lo;0;L;;;;;N;;;;;\n0A28;GURMUKHI LETTER NA;Lo;0;L;;;;;N;;;;;\n0A2A;GURMUKHI LETTER PA;Lo;0;L;;;;;N;;;;;\n0A2B;GURMUKHI LETTER PHA;Lo;0;L;;;;;N;;;;;\n0A2C;GURMUKHI LETTER BA;Lo;0;L;;;;;N;;;;;\n0A2D;GURMUKHI LETTER BHA;Lo;0;L;;;;;N;;;;;\n0A2E;GURMUKHI LETTER MA;Lo;0;L;;;;;N;;;;;\n0A2F;GURMUKHI LETTER YA;Lo;0;L;;;;;N;;;;;\n0A30;GURMUKHI LETTER RA;Lo;0;L;;;;;N;;;;;\n0A32;GURMUKHI LETTER LA;Lo;0;L;;;;;N;;;;;\n0A33;GURMUKHI LETTER LLA;Lo;0;L;0A32 0A3C;;;;N;;;;;\n0A35;GURMUKHI LETTER VA;Lo;0;L;;;;;N;;;;;\n0A36;GURMUKHI LETTER SHA;Lo;0;L;0A38 0A3C;;;;N;;;;;\n0A38;GURMUKHI LETTER SA;Lo;0;L;;;;;N;;;;;\n0A39;GURMUKHI LETTER HA;Lo;0;L;;;;;N;;;;;\n0A3C;GURMUKHI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n0A3E;GURMUKHI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0A3F;GURMUKHI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n0A40;GURMUKHI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n0A41;GURMUKHI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n0A42;GURMUKHI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n0A47;GURMUKHI VOWEL SIGN EE;Mn;0;NSM;;;;;N;;;;;\n0A48;GURMUKHI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n0A4B;GURMUKHI VOWEL SIGN OO;Mn;0;NSM;;;;;N;;;;;\n0A4C;GURMUKHI VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\n0A4D;GURMUKHI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0A51;GURMUKHI SIGN UDAAT;Mn;0;NSM;;;;;N;;;;;\n0A59;GURMUKHI LETTER KHHA;Lo;0;L;0A16 0A3C;;;;N;;;;;\n0A5A;GURMUKHI LETTER GHHA;Lo;0;L;0A17 0A3C;;;;N;;;;;\n0A5B;GURMUKHI LETTER ZA;Lo;0;L;0A1C 0A3C;;;;N;;;;;\n0A5C;GURMUKHI LETTER RRA;Lo;0;L;;;;;N;;;;;\n0A5E;GURMUKHI LETTER FA;Lo;0;L;0A2B 0A3C;;;;N;;;;;\n0A66;GURMUKHI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0A67;GURMUKHI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0A68;GURMUKHI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0A69;GURMUKHI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0A6A;GURMUKHI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0A6B;GURMUKHI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0A6C;GURMUKHI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0A6D;GURMUKHI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0A6E;GURMUKHI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0A6F;GURMUKHI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0A70;GURMUKHI TIPPI;Mn;0;NSM;;;;;N;;;;;\n0A71;GURMUKHI ADDAK;Mn;0;NSM;;;;;N;;;;;\n0A72;GURMUKHI IRI;Lo;0;L;;;;;N;;;;;\n0A73;GURMUKHI URA;Lo;0;L;;;;;N;;;;;\n0A74;GURMUKHI EK ONKAR;Lo;0;L;;;;;N;;;;;\n0A75;GURMUKHI SIGN YAKASH;Mn;0;NSM;;;;;N;;;;;\n0A81;GUJARATI SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n0A82;GUJARATI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n0A83;GUJARATI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0A85;GUJARATI LETTER A;Lo;0;L;;;;;N;;;;;\n0A86;GUJARATI LETTER AA;Lo;0;L;;;;;N;;;;;\n0A87;GUJARATI LETTER I;Lo;0;L;;;;;N;;;;;\n0A88;GUJARATI LETTER II;Lo;0;L;;;;;N;;;;;\n0A89;GUJARATI LETTER U;Lo;0;L;;;;;N;;;;;\n0A8A;GUJARATI LETTER UU;Lo;0;L;;;;;N;;;;;\n0A8B;GUJARATI LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n0A8C;GUJARATI LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n0A8D;GUJARATI VOWEL CANDRA E;Lo;0;L;;;;;N;;;;;\n0A8F;GUJARATI LETTER E;Lo;0;L;;;;;N;;;;;\n0A90;GUJARATI LETTER AI;Lo;0;L;;;;;N;;;;;\n0A91;GUJARATI VOWEL CANDRA O;Lo;0;L;;;;;N;;;;;\n0A93;GUJARATI LETTER O;Lo;0;L;;;;;N;;;;;\n0A94;GUJARATI LETTER AU;Lo;0;L;;;;;N;;;;;\n0A95;GUJARATI LETTER KA;Lo;0;L;;;;;N;;;;;\n0A96;GUJARATI LETTER KHA;Lo;0;L;;;;;N;;;;;\n0A97;GUJARATI LETTER GA;Lo;0;L;;;;;N;;;;;\n0A98;GUJARATI LETTER GHA;Lo;0;L;;;;;N;;;;;\n0A99;GUJARATI LETTER NGA;Lo;0;L;;;;;N;;;;;\n0A9A;GUJARATI LETTER CA;Lo;0;L;;;;;N;;;;;\n0A9B;GUJARATI LETTER CHA;Lo;0;L;;;;;N;;;;;\n0A9C;GUJARATI LETTER JA;Lo;0;L;;;;;N;;;;;\n0A9D;GUJARATI LETTER JHA;Lo;0;L;;;;;N;;;;;\n0A9E;GUJARATI LETTER NYA;Lo;0;L;;;;;N;;;;;\n0A9F;GUJARATI LETTER TTA;Lo;0;L;;;;;N;;;;;\n0AA0;GUJARATI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0AA1;GUJARATI LETTER DDA;Lo;0;L;;;;;N;;;;;\n0AA2;GUJARATI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0AA3;GUJARATI LETTER NNA;Lo;0;L;;;;;N;;;;;\n0AA4;GUJARATI LETTER TA;Lo;0;L;;;;;N;;;;;\n0AA5;GUJARATI LETTER THA;Lo;0;L;;;;;N;;;;;\n0AA6;GUJARATI LETTER DA;Lo;0;L;;;;;N;;;;;\n0AA7;GUJARATI LETTER DHA;Lo;0;L;;;;;N;;;;;\n0AA8;GUJARATI LETTER NA;Lo;0;L;;;;;N;;;;;\n0AAA;GUJARATI LETTER PA;Lo;0;L;;;;;N;;;;;\n0AAB;GUJARATI LETTER PHA;Lo;0;L;;;;;N;;;;;\n0AAC;GUJARATI LETTER BA;Lo;0;L;;;;;N;;;;;\n0AAD;GUJARATI LETTER BHA;Lo;0;L;;;;;N;;;;;\n0AAE;GUJARATI LETTER MA;Lo;0;L;;;;;N;;;;;\n0AAF;GUJARATI LETTER YA;Lo;0;L;;;;;N;;;;;\n0AB0;GUJARATI LETTER RA;Lo;0;L;;;;;N;;;;;\n0AB2;GUJARATI LETTER LA;Lo;0;L;;;;;N;;;;;\n0AB3;GUJARATI LETTER LLA;Lo;0;L;;;;;N;;;;;\n0AB5;GUJARATI LETTER VA;Lo;0;L;;;;;N;;;;;\n0AB6;GUJARATI LETTER SHA;Lo;0;L;;;;;N;;;;;\n0AB7;GUJARATI LETTER SSA;Lo;0;L;;;;;N;;;;;\n0AB8;GUJARATI LETTER SA;Lo;0;L;;;;;N;;;;;\n0AB9;GUJARATI LETTER HA;Lo;0;L;;;;;N;;;;;\n0ABC;GUJARATI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n0ABD;GUJARATI SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n0ABE;GUJARATI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0ABF;GUJARATI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n0AC0;GUJARATI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n0AC1;GUJARATI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n0AC2;GUJARATI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n0AC3;GUJARATI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n0AC4;GUJARATI VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n0AC5;GUJARATI VOWEL SIGN CANDRA E;Mn;0;NSM;;;;;N;;;;;\n0AC7;GUJARATI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n0AC8;GUJARATI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n0AC9;GUJARATI VOWEL SIGN CANDRA O;Mc;0;L;;;;;N;;;;;\n0ACB;GUJARATI VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n0ACC;GUJARATI VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n0ACD;GUJARATI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0AD0;GUJARATI OM;Lo;0;L;;;;;N;;;;;\n0AE0;GUJARATI LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0AE1;GUJARATI LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0AE2;GUJARATI VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0AE3;GUJARATI VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0AE6;GUJARATI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0AE7;GUJARATI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0AE8;GUJARATI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0AE9;GUJARATI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0AEA;GUJARATI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0AEB;GUJARATI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0AEC;GUJARATI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0AED;GUJARATI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0AEE;GUJARATI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0AEF;GUJARATI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0AF0;GUJARATI ABBREVIATION SIGN;Po;0;L;;;;;N;;;;;\n0AF1;GUJARATI RUPEE SIGN;Sc;0;ET;;;;;N;;;;;\n0B01;ORIYA SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n0B02;ORIYA SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\n0B03;ORIYA SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0B05;ORIYA LETTER A;Lo;0;L;;;;;N;;;;;\n0B06;ORIYA LETTER AA;Lo;0;L;;;;;N;;;;;\n0B07;ORIYA LETTER I;Lo;0;L;;;;;N;;;;;\n0B08;ORIYA LETTER II;Lo;0;L;;;;;N;;;;;\n0B09;ORIYA LETTER U;Lo;0;L;;;;;N;;;;;\n0B0A;ORIYA LETTER UU;Lo;0;L;;;;;N;;;;;\n0B0B;ORIYA LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n0B0C;ORIYA LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n0B0F;ORIYA LETTER E;Lo;0;L;;;;;N;;;;;\n0B10;ORIYA LETTER AI;Lo;0;L;;;;;N;;;;;\n0B13;ORIYA LETTER O;Lo;0;L;;;;;N;;;;;\n0B14;ORIYA LETTER AU;Lo;0;L;;;;;N;;;;;\n0B15;ORIYA LETTER KA;Lo;0;L;;;;;N;;;;;\n0B16;ORIYA LETTER KHA;Lo;0;L;;;;;N;;;;;\n0B17;ORIYA LETTER GA;Lo;0;L;;;;;N;;;;;\n0B18;ORIYA LETTER GHA;Lo;0;L;;;;;N;;;;;\n0B19;ORIYA LETTER NGA;Lo;0;L;;;;;N;;;;;\n0B1A;ORIYA LETTER CA;Lo;0;L;;;;;N;;;;;\n0B1B;ORIYA LETTER CHA;Lo;0;L;;;;;N;;;;;\n0B1C;ORIYA LETTER JA;Lo;0;L;;;;;N;;;;;\n0B1D;ORIYA LETTER JHA;Lo;0;L;;;;;N;;;;;\n0B1E;ORIYA LETTER NYA;Lo;0;L;;;;;N;;;;;\n0B1F;ORIYA LETTER TTA;Lo;0;L;;;;;N;;;;;\n0B20;ORIYA LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0B21;ORIYA LETTER DDA;Lo;0;L;;;;;N;;;;;\n0B22;ORIYA LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0B23;ORIYA LETTER NNA;Lo;0;L;;;;;N;;;;;\n0B24;ORIYA LETTER TA;Lo;0;L;;;;;N;;;;;\n0B25;ORIYA LETTER THA;Lo;0;L;;;;;N;;;;;\n0B26;ORIYA LETTER DA;Lo;0;L;;;;;N;;;;;\n0B27;ORIYA LETTER DHA;Lo;0;L;;;;;N;;;;;\n0B28;ORIYA LETTER NA;Lo;0;L;;;;;N;;;;;\n0B2A;ORIYA LETTER PA;Lo;0;L;;;;;N;;;;;\n0B2B;ORIYA LETTER PHA;Lo;0;L;;;;;N;;;;;\n0B2C;ORIYA LETTER BA;Lo;0;L;;;;;N;;;;;\n0B2D;ORIYA LETTER BHA;Lo;0;L;;;;;N;;;;;\n0B2E;ORIYA LETTER MA;Lo;0;L;;;;;N;;;;;\n0B2F;ORIYA LETTER YA;Lo;0;L;;;;;N;;;;;\n0B30;ORIYA LETTER RA;Lo;0;L;;;;;N;;;;;\n0B32;ORIYA LETTER LA;Lo;0;L;;;;;N;;;;;\n0B33;ORIYA LETTER LLA;Lo;0;L;;;;;N;;;;;\n0B35;ORIYA LETTER VA;Lo;0;L;;;;;N;;;;;\n0B36;ORIYA LETTER SHA;Lo;0;L;;;;;N;;;;;\n0B37;ORIYA LETTER SSA;Lo;0;L;;;;;N;;;;;\n0B38;ORIYA LETTER SA;Lo;0;L;;;;;N;;;;;\n0B39;ORIYA LETTER HA;Lo;0;L;;;;;N;;;;;\n0B3C;ORIYA SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n0B3D;ORIYA SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n0B3E;ORIYA VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0B3F;ORIYA VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n0B40;ORIYA VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n0B41;ORIYA VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n0B42;ORIYA VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n0B43;ORIYA VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n0B44;ORIYA VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n0B47;ORIYA VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n0B48;ORIYA VOWEL SIGN AI;Mc;0;L;0B47 0B56;;;;N;;;;;\n0B4B;ORIYA VOWEL SIGN O;Mc;0;L;0B47 0B3E;;;;N;;;;;\n0B4C;ORIYA VOWEL SIGN AU;Mc;0;L;0B47 0B57;;;;N;;;;;\n0B4D;ORIYA SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0B56;ORIYA AI LENGTH MARK;Mn;0;NSM;;;;;N;;;;;\n0B57;ORIYA AU LENGTH MARK;Mc;0;L;;;;;N;;;;;\n0B5C;ORIYA LETTER RRA;Lo;0;L;0B21 0B3C;;;;N;;;;;\n0B5D;ORIYA LETTER RHA;Lo;0;L;0B22 0B3C;;;;N;;;;;\n0B5F;ORIYA LETTER YYA;Lo;0;L;;;;;N;;;;;\n0B60;ORIYA LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0B61;ORIYA LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0B62;ORIYA VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0B63;ORIYA VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0B66;ORIYA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0B67;ORIYA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0B68;ORIYA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0B69;ORIYA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0B6A;ORIYA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0B6B;ORIYA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0B6C;ORIYA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0B6D;ORIYA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0B6E;ORIYA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0B6F;ORIYA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0B70;ORIYA ISSHAR;So;0;L;;;;;N;;;;;\n0B71;ORIYA LETTER WA;Lo;0;L;;;;;N;;;;;\n0B72;ORIYA FRACTION ONE QUARTER;No;0;L;;;;1/4;N;;;;;\n0B73;ORIYA FRACTION ONE HALF;No;0;L;;;;1/2;N;;;;;\n0B74;ORIYA FRACTION THREE QUARTERS;No;0;L;;;;3/4;N;;;;;\n0B75;ORIYA FRACTION ONE SIXTEENTH;No;0;L;;;;1/16;N;;;;;\n0B76;ORIYA FRACTION ONE EIGHTH;No;0;L;;;;1/8;N;;;;;\n0B77;ORIYA FRACTION THREE SIXTEENTHS;No;0;L;;;;3/16;N;;;;;\n0B82;TAMIL SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n0B83;TAMIL SIGN VISARGA;Lo;0;L;;;;;N;;;;;\n0B85;TAMIL LETTER A;Lo;0;L;;;;;N;;;;;\n0B86;TAMIL LETTER AA;Lo;0;L;;;;;N;;;;;\n0B87;TAMIL LETTER I;Lo;0;L;;;;;N;;;;;\n0B88;TAMIL LETTER II;Lo;0;L;;;;;N;;;;;\n0B89;TAMIL LETTER U;Lo;0;L;;;;;N;;;;;\n0B8A;TAMIL LETTER UU;Lo;0;L;;;;;N;;;;;\n0B8E;TAMIL LETTER E;Lo;0;L;;;;;N;;;;;\n0B8F;TAMIL LETTER EE;Lo;0;L;;;;;N;;;;;\n0B90;TAMIL LETTER AI;Lo;0;L;;;;;N;;;;;\n0B92;TAMIL LETTER O;Lo;0;L;;;;;N;;;;;\n0B93;TAMIL LETTER OO;Lo;0;L;;;;;N;;;;;\n0B94;TAMIL LETTER AU;Lo;0;L;0B92 0BD7;;;;N;;;;;\n0B95;TAMIL LETTER KA;Lo;0;L;;;;;N;;;;;\n0B99;TAMIL LETTER NGA;Lo;0;L;;;;;N;;;;;\n0B9A;TAMIL LETTER CA;Lo;0;L;;;;;N;;;;;\n0B9C;TAMIL LETTER JA;Lo;0;L;;;;;N;;;;;\n0B9E;TAMIL LETTER NYA;Lo;0;L;;;;;N;;;;;\n0B9F;TAMIL LETTER TTA;Lo;0;L;;;;;N;;;;;\n0BA3;TAMIL LETTER NNA;Lo;0;L;;;;;N;;;;;\n0BA4;TAMIL LETTER TA;Lo;0;L;;;;;N;;;;;\n0BA8;TAMIL LETTER NA;Lo;0;L;;;;;N;;;;;\n0BA9;TAMIL LETTER NNNA;Lo;0;L;;;;;N;;;;;\n0BAA;TAMIL LETTER PA;Lo;0;L;;;;;N;;;;;\n0BAE;TAMIL LETTER MA;Lo;0;L;;;;;N;;;;;\n0BAF;TAMIL LETTER YA;Lo;0;L;;;;;N;;;;;\n0BB0;TAMIL LETTER RA;Lo;0;L;;;;;N;;;;;\n0BB1;TAMIL LETTER RRA;Lo;0;L;;;;;N;;;;;\n0BB2;TAMIL LETTER LA;Lo;0;L;;;;;N;;;;;\n0BB3;TAMIL LETTER LLA;Lo;0;L;;;;;N;;;;;\n0BB4;TAMIL LETTER LLLA;Lo;0;L;;;;;N;;;;;\n0BB5;TAMIL LETTER VA;Lo;0;L;;;;;N;;;;;\n0BB6;TAMIL LETTER SHA;Lo;0;L;;;;;N;;;;;\n0BB7;TAMIL LETTER SSA;Lo;0;L;;;;;N;;;;;\n0BB8;TAMIL LETTER SA;Lo;0;L;;;;;N;;;;;\n0BB9;TAMIL LETTER HA;Lo;0;L;;;;;N;;;;;\n0BBE;TAMIL VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0BBF;TAMIL VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n0BC0;TAMIL VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n0BC1;TAMIL VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n0BC2;TAMIL VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n0BC6;TAMIL VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n0BC7;TAMIL VOWEL SIGN EE;Mc;0;L;;;;;N;;;;;\n0BC8;TAMIL VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n0BCA;TAMIL VOWEL SIGN O;Mc;0;L;0BC6 0BBE;;;;N;;;;;\n0BCB;TAMIL VOWEL SIGN OO;Mc;0;L;0BC7 0BBE;;;;N;;;;;\n0BCC;TAMIL VOWEL SIGN AU;Mc;0;L;0BC6 0BD7;;;;N;;;;;\n0BCD;TAMIL SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0BD0;TAMIL OM;Lo;0;L;;;;;N;;;;;\n0BD7;TAMIL AU LENGTH MARK;Mc;0;L;;;;;N;;;;;\n0BE6;TAMIL DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0BE7;TAMIL DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0BE8;TAMIL DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0BE9;TAMIL DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0BEA;TAMIL DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0BEB;TAMIL DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0BEC;TAMIL DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0BED;TAMIL DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0BEE;TAMIL DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0BEF;TAMIL DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0BF0;TAMIL NUMBER TEN;No;0;L;;;;10;N;;;;;\n0BF1;TAMIL NUMBER ONE HUNDRED;No;0;L;;;;100;N;;;;;\n0BF2;TAMIL NUMBER ONE THOUSAND;No;0;L;;;;1000;N;;;;;\n0BF3;TAMIL DAY SIGN;So;0;ON;;;;;N;;;;;\n0BF4;TAMIL MONTH SIGN;So;0;ON;;;;;N;;;;;\n0BF5;TAMIL YEAR SIGN;So;0;ON;;;;;N;;;;;\n0BF6;TAMIL DEBIT SIGN;So;0;ON;;;;;N;;;;;\n0BF7;TAMIL CREDIT SIGN;So;0;ON;;;;;N;;;;;\n0BF8;TAMIL AS ABOVE SIGN;So;0;ON;;;;;N;;;;;\n0BF9;TAMIL RUPEE SIGN;Sc;0;ET;;;;;N;;;;;\n0BFA;TAMIL NUMBER SIGN;So;0;ON;;;;;N;;;;;\n0C01;TELUGU SIGN CANDRABINDU;Mc;0;L;;;;;N;;;;;\n0C02;TELUGU SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\n0C03;TELUGU SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0C05;TELUGU LETTER A;Lo;0;L;;;;;N;;;;;\n0C06;TELUGU LETTER AA;Lo;0;L;;;;;N;;;;;\n0C07;TELUGU LETTER I;Lo;0;L;;;;;N;;;;;\n0C08;TELUGU LETTER II;Lo;0;L;;;;;N;;;;;\n0C09;TELUGU LETTER U;Lo;0;L;;;;;N;;;;;\n0C0A;TELUGU LETTER UU;Lo;0;L;;;;;N;;;;;\n0C0B;TELUGU LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n0C0C;TELUGU LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n0C0E;TELUGU LETTER E;Lo;0;L;;;;;N;;;;;\n0C0F;TELUGU LETTER EE;Lo;0;L;;;;;N;;;;;\n0C10;TELUGU LETTER AI;Lo;0;L;;;;;N;;;;;\n0C12;TELUGU LETTER O;Lo;0;L;;;;;N;;;;;\n0C13;TELUGU LETTER OO;Lo;0;L;;;;;N;;;;;\n0C14;TELUGU LETTER AU;Lo;0;L;;;;;N;;;;;\n0C15;TELUGU LETTER KA;Lo;0;L;;;;;N;;;;;\n0C16;TELUGU LETTER KHA;Lo;0;L;;;;;N;;;;;\n0C17;TELUGU LETTER GA;Lo;0;L;;;;;N;;;;;\n0C18;TELUGU LETTER GHA;Lo;0;L;;;;;N;;;;;\n0C19;TELUGU LETTER NGA;Lo;0;L;;;;;N;;;;;\n0C1A;TELUGU LETTER CA;Lo;0;L;;;;;N;;;;;\n0C1B;TELUGU LETTER CHA;Lo;0;L;;;;;N;;;;;\n0C1C;TELUGU LETTER JA;Lo;0;L;;;;;N;;;;;\n0C1D;TELUGU LETTER JHA;Lo;0;L;;;;;N;;;;;\n0C1E;TELUGU LETTER NYA;Lo;0;L;;;;;N;;;;;\n0C1F;TELUGU LETTER TTA;Lo;0;L;;;;;N;;;;;\n0C20;TELUGU LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0C21;TELUGU LETTER DDA;Lo;0;L;;;;;N;;;;;\n0C22;TELUGU LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0C23;TELUGU LETTER NNA;Lo;0;L;;;;;N;;;;;\n0C24;TELUGU LETTER TA;Lo;0;L;;;;;N;;;;;\n0C25;TELUGU LETTER THA;Lo;0;L;;;;;N;;;;;\n0C26;TELUGU LETTER DA;Lo;0;L;;;;;N;;;;;\n0C27;TELUGU LETTER DHA;Lo;0;L;;;;;N;;;;;\n0C28;TELUGU LETTER NA;Lo;0;L;;;;;N;;;;;\n0C2A;TELUGU LETTER PA;Lo;0;L;;;;;N;;;;;\n0C2B;TELUGU LETTER PHA;Lo;0;L;;;;;N;;;;;\n0C2C;TELUGU LETTER BA;Lo;0;L;;;;;N;;;;;\n0C2D;TELUGU LETTER BHA;Lo;0;L;;;;;N;;;;;\n0C2E;TELUGU LETTER MA;Lo;0;L;;;;;N;;;;;\n0C2F;TELUGU LETTER YA;Lo;0;L;;;;;N;;;;;\n0C30;TELUGU LETTER RA;Lo;0;L;;;;;N;;;;;\n0C31;TELUGU LETTER RRA;Lo;0;L;;;;;N;;;;;\n0C32;TELUGU LETTER LA;Lo;0;L;;;;;N;;;;;\n0C33;TELUGU LETTER LLA;Lo;0;L;;;;;N;;;;;\n0C35;TELUGU LETTER VA;Lo;0;L;;;;;N;;;;;\n0C36;TELUGU LETTER SHA;Lo;0;L;;;;;N;;;;;\n0C37;TELUGU LETTER SSA;Lo;0;L;;;;;N;;;;;\n0C38;TELUGU LETTER SA;Lo;0;L;;;;;N;;;;;\n0C39;TELUGU LETTER HA;Lo;0;L;;;;;N;;;;;\n0C3D;TELUGU SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n0C3E;TELUGU VOWEL SIGN AA;Mn;0;NSM;;;;;N;;;;;\n0C3F;TELUGU VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n0C40;TELUGU VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n0C41;TELUGU VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n0C42;TELUGU VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n0C43;TELUGU VOWEL SIGN VOCALIC R;Mc;0;L;;;;;N;;;;;\n0C44;TELUGU VOWEL SIGN VOCALIC RR;Mc;0;L;;;;;N;;;;;\n0C46;TELUGU VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n0C47;TELUGU VOWEL SIGN EE;Mn;0;NSM;;;;;N;;;;;\n0C48;TELUGU VOWEL SIGN AI;Mn;0;NSM;0C46 0C56;;;;N;;;;;\n0C4A;TELUGU VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n0C4B;TELUGU VOWEL SIGN OO;Mn;0;NSM;;;;;N;;;;;\n0C4C;TELUGU VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\n0C4D;TELUGU SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0C55;TELUGU LENGTH MARK;Mn;84;NSM;;;;;N;;;;;\n0C56;TELUGU AI LENGTH MARK;Mn;91;NSM;;;;;N;;;;;\n0C58;TELUGU LETTER TSA;Lo;0;L;;;;;N;;;;;\n0C59;TELUGU LETTER DZA;Lo;0;L;;;;;N;;;;;\n0C60;TELUGU LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0C61;TELUGU LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0C62;TELUGU VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0C63;TELUGU VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0C66;TELUGU DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0C67;TELUGU DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0C68;TELUGU DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0C69;TELUGU DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0C6A;TELUGU DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0C6B;TELUGU DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0C6C;TELUGU DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0C6D;TELUGU DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0C6E;TELUGU DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0C6F;TELUGU DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0C78;TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF FOUR;No;0;ON;;;;0;N;;;;;\n0C79;TELUGU FRACTION DIGIT ONE FOR ODD POWERS OF FOUR;No;0;ON;;;;1;N;;;;;\n0C7A;TELUGU FRACTION DIGIT TWO FOR ODD POWERS OF FOUR;No;0;ON;;;;2;N;;;;;\n0C7B;TELUGU FRACTION DIGIT THREE FOR ODD POWERS OF FOUR;No;0;ON;;;;3;N;;;;;\n0C7C;TELUGU FRACTION DIGIT ONE FOR EVEN POWERS OF FOUR;No;0;ON;;;;1;N;;;;;\n0C7D;TELUGU FRACTION DIGIT TWO FOR EVEN POWERS OF FOUR;No;0;ON;;;;2;N;;;;;\n0C7E;TELUGU FRACTION DIGIT THREE FOR EVEN POWERS OF FOUR;No;0;ON;;;;3;N;;;;;\n0C7F;TELUGU SIGN TUUMU;So;0;L;;;;;N;;;;;\n0C82;KANNADA SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\n0C83;KANNADA SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0C85;KANNADA LETTER A;Lo;0;L;;;;;N;;;;;\n0C86;KANNADA LETTER AA;Lo;0;L;;;;;N;;;;;\n0C87;KANNADA LETTER I;Lo;0;L;;;;;N;;;;;\n0C88;KANNADA LETTER II;Lo;0;L;;;;;N;;;;;\n0C89;KANNADA LETTER U;Lo;0;L;;;;;N;;;;;\n0C8A;KANNADA LETTER UU;Lo;0;L;;;;;N;;;;;\n0C8B;KANNADA LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n0C8C;KANNADA LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n0C8E;KANNADA LETTER E;Lo;0;L;;;;;N;;;;;\n0C8F;KANNADA LETTER EE;Lo;0;L;;;;;N;;;;;\n0C90;KANNADA LETTER AI;Lo;0;L;;;;;N;;;;;\n0C92;KANNADA LETTER O;Lo;0;L;;;;;N;;;;;\n0C93;KANNADA LETTER OO;Lo;0;L;;;;;N;;;;;\n0C94;KANNADA LETTER AU;Lo;0;L;;;;;N;;;;;\n0C95;KANNADA LETTER KA;Lo;0;L;;;;;N;;;;;\n0C96;KANNADA LETTER KHA;Lo;0;L;;;;;N;;;;;\n0C97;KANNADA LETTER GA;Lo;0;L;;;;;N;;;;;\n0C98;KANNADA LETTER GHA;Lo;0;L;;;;;N;;;;;\n0C99;KANNADA LETTER NGA;Lo;0;L;;;;;N;;;;;\n0C9A;KANNADA LETTER CA;Lo;0;L;;;;;N;;;;;\n0C9B;KANNADA LETTER CHA;Lo;0;L;;;;;N;;;;;\n0C9C;KANNADA LETTER JA;Lo;0;L;;;;;N;;;;;\n0C9D;KANNADA LETTER JHA;Lo;0;L;;;;;N;;;;;\n0C9E;KANNADA LETTER NYA;Lo;0;L;;;;;N;;;;;\n0C9F;KANNADA LETTER TTA;Lo;0;L;;;;;N;;;;;\n0CA0;KANNADA LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0CA1;KANNADA LETTER DDA;Lo;0;L;;;;;N;;;;;\n0CA2;KANNADA LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0CA3;KANNADA LETTER NNA;Lo;0;L;;;;;N;;;;;\n0CA4;KANNADA LETTER TA;Lo;0;L;;;;;N;;;;;\n0CA5;KANNADA LETTER THA;Lo;0;L;;;;;N;;;;;\n0CA6;KANNADA LETTER DA;Lo;0;L;;;;;N;;;;;\n0CA7;KANNADA LETTER DHA;Lo;0;L;;;;;N;;;;;\n0CA8;KANNADA LETTER NA;Lo;0;L;;;;;N;;;;;\n0CAA;KANNADA LETTER PA;Lo;0;L;;;;;N;;;;;\n0CAB;KANNADA LETTER PHA;Lo;0;L;;;;;N;;;;;\n0CAC;KANNADA LETTER BA;Lo;0;L;;;;;N;;;;;\n0CAD;KANNADA LETTER BHA;Lo;0;L;;;;;N;;;;;\n0CAE;KANNADA LETTER MA;Lo;0;L;;;;;N;;;;;\n0CAF;KANNADA LETTER YA;Lo;0;L;;;;;N;;;;;\n0CB0;KANNADA LETTER RA;Lo;0;L;;;;;N;;;;;\n0CB1;KANNADA LETTER RRA;Lo;0;L;;;;;N;;;;;\n0CB2;KANNADA LETTER LA;Lo;0;L;;;;;N;;;;;\n0CB3;KANNADA LETTER LLA;Lo;0;L;;;;;N;;;;;\n0CB5;KANNADA LETTER VA;Lo;0;L;;;;;N;;;;;\n0CB6;KANNADA LETTER SHA;Lo;0;L;;;;;N;;;;;\n0CB7;KANNADA LETTER SSA;Lo;0;L;;;;;N;;;;;\n0CB8;KANNADA LETTER SA;Lo;0;L;;;;;N;;;;;\n0CB9;KANNADA LETTER HA;Lo;0;L;;;;;N;;;;;\n0CBC;KANNADA SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n0CBD;KANNADA SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n0CBE;KANNADA VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0CBF;KANNADA VOWEL SIGN I;Mn;0;L;;;;;N;;;;;\n0CC0;KANNADA VOWEL SIGN II;Mc;0;L;0CBF 0CD5;;;;N;;;;;\n0CC1;KANNADA VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n0CC2;KANNADA VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n0CC3;KANNADA VOWEL SIGN VOCALIC R;Mc;0;L;;;;;N;;;;;\n0CC4;KANNADA VOWEL SIGN VOCALIC RR;Mc;0;L;;;;;N;;;;;\n0CC6;KANNADA VOWEL SIGN E;Mn;0;L;;;;;N;;;;;\n0CC7;KANNADA VOWEL SIGN EE;Mc;0;L;0CC6 0CD5;;;;N;;;;;\n0CC8;KANNADA VOWEL SIGN AI;Mc;0;L;0CC6 0CD6;;;;N;;;;;\n0CCA;KANNADA VOWEL SIGN O;Mc;0;L;0CC6 0CC2;;;;N;;;;;\n0CCB;KANNADA VOWEL SIGN OO;Mc;0;L;0CCA 0CD5;;;;N;;;;;\n0CCC;KANNADA VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\n0CCD;KANNADA SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0CD5;KANNADA LENGTH MARK;Mc;0;L;;;;;N;;;;;\n0CD6;KANNADA AI LENGTH MARK;Mc;0;L;;;;;N;;;;;\n0CDE;KANNADA LETTER FA;Lo;0;L;;;;;N;;;;;\n0CE0;KANNADA LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0CE1;KANNADA LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0CE2;KANNADA VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0CE3;KANNADA VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0CE6;KANNADA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0CE7;KANNADA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0CE8;KANNADA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0CE9;KANNADA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0CEA;KANNADA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0CEB;KANNADA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0CEC;KANNADA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0CED;KANNADA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0CEE;KANNADA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0CEF;KANNADA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0CF1;KANNADA SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;\n0CF2;KANNADA SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;\n0D02;MALAYALAM SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\n0D03;MALAYALAM SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n0D05;MALAYALAM LETTER A;Lo;0;L;;;;;N;;;;;\n0D06;MALAYALAM LETTER AA;Lo;0;L;;;;;N;;;;;\n0D07;MALAYALAM LETTER I;Lo;0;L;;;;;N;;;;;\n0D08;MALAYALAM LETTER II;Lo;0;L;;;;;N;;;;;\n0D09;MALAYALAM LETTER U;Lo;0;L;;;;;N;;;;;\n0D0A;MALAYALAM LETTER UU;Lo;0;L;;;;;N;;;;;\n0D0B;MALAYALAM LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n0D0C;MALAYALAM LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n0D0E;MALAYALAM LETTER E;Lo;0;L;;;;;N;;;;;\n0D0F;MALAYALAM LETTER EE;Lo;0;L;;;;;N;;;;;\n0D10;MALAYALAM LETTER AI;Lo;0;L;;;;;N;;;;;\n0D12;MALAYALAM LETTER O;Lo;0;L;;;;;N;;;;;\n0D13;MALAYALAM LETTER OO;Lo;0;L;;;;;N;;;;;\n0D14;MALAYALAM LETTER AU;Lo;0;L;;;;;N;;;;;\n0D15;MALAYALAM LETTER KA;Lo;0;L;;;;;N;;;;;\n0D16;MALAYALAM LETTER KHA;Lo;0;L;;;;;N;;;;;\n0D17;MALAYALAM LETTER GA;Lo;0;L;;;;;N;;;;;\n0D18;MALAYALAM LETTER GHA;Lo;0;L;;;;;N;;;;;\n0D19;MALAYALAM LETTER NGA;Lo;0;L;;;;;N;;;;;\n0D1A;MALAYALAM LETTER CA;Lo;0;L;;;;;N;;;;;\n0D1B;MALAYALAM LETTER CHA;Lo;0;L;;;;;N;;;;;\n0D1C;MALAYALAM LETTER JA;Lo;0;L;;;;;N;;;;;\n0D1D;MALAYALAM LETTER JHA;Lo;0;L;;;;;N;;;;;\n0D1E;MALAYALAM LETTER NYA;Lo;0;L;;;;;N;;;;;\n0D1F;MALAYALAM LETTER TTA;Lo;0;L;;;;;N;;;;;\n0D20;MALAYALAM LETTER TTHA;Lo;0;L;;;;;N;;;;;\n0D21;MALAYALAM LETTER DDA;Lo;0;L;;;;;N;;;;;\n0D22;MALAYALAM LETTER DDHA;Lo;0;L;;;;;N;;;;;\n0D23;MALAYALAM LETTER NNA;Lo;0;L;;;;;N;;;;;\n0D24;MALAYALAM LETTER TA;Lo;0;L;;;;;N;;;;;\n0D25;MALAYALAM LETTER THA;Lo;0;L;;;;;N;;;;;\n0D26;MALAYALAM LETTER DA;Lo;0;L;;;;;N;;;;;\n0D27;MALAYALAM LETTER DHA;Lo;0;L;;;;;N;;;;;\n0D28;MALAYALAM LETTER NA;Lo;0;L;;;;;N;;;;;\n0D29;MALAYALAM LETTER NNNA;Lo;0;L;;;;;N;;;;;\n0D2A;MALAYALAM LETTER PA;Lo;0;L;;;;;N;;;;;\n0D2B;MALAYALAM LETTER PHA;Lo;0;L;;;;;N;;;;;\n0D2C;MALAYALAM LETTER BA;Lo;0;L;;;;;N;;;;;\n0D2D;MALAYALAM LETTER BHA;Lo;0;L;;;;;N;;;;;\n0D2E;MALAYALAM LETTER MA;Lo;0;L;;;;;N;;;;;\n0D2F;MALAYALAM LETTER YA;Lo;0;L;;;;;N;;;;;\n0D30;MALAYALAM LETTER RA;Lo;0;L;;;;;N;;;;;\n0D31;MALAYALAM LETTER RRA;Lo;0;L;;;;;N;;;;;\n0D32;MALAYALAM LETTER LA;Lo;0;L;;;;;N;;;;;\n0D33;MALAYALAM LETTER LLA;Lo;0;L;;;;;N;;;;;\n0D34;MALAYALAM LETTER LLLA;Lo;0;L;;;;;N;;;;;\n0D35;MALAYALAM LETTER VA;Lo;0;L;;;;;N;;;;;\n0D36;MALAYALAM LETTER SHA;Lo;0;L;;;;;N;;;;;\n0D37;MALAYALAM LETTER SSA;Lo;0;L;;;;;N;;;;;\n0D38;MALAYALAM LETTER SA;Lo;0;L;;;;;N;;;;;\n0D39;MALAYALAM LETTER HA;Lo;0;L;;;;;N;;;;;\n0D3A;MALAYALAM LETTER TTTA;Lo;0;L;;;;;N;;;;;\n0D3D;MALAYALAM SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n0D3E;MALAYALAM VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n0D3F;MALAYALAM VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n0D40;MALAYALAM VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n0D41;MALAYALAM VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n0D42;MALAYALAM VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n0D43;MALAYALAM VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n0D44;MALAYALAM VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n0D46;MALAYALAM VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n0D47;MALAYALAM VOWEL SIGN EE;Mc;0;L;;;;;N;;;;;\n0D48;MALAYALAM VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n0D4A;MALAYALAM VOWEL SIGN O;Mc;0;L;0D46 0D3E;;;;N;;;;;\n0D4B;MALAYALAM VOWEL SIGN OO;Mc;0;L;0D47 0D3E;;;;N;;;;;\n0D4C;MALAYALAM VOWEL SIGN AU;Mc;0;L;0D46 0D57;;;;N;;;;;\n0D4D;MALAYALAM SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n0D4E;MALAYALAM LETTER DOT REPH;Lo;0;L;;;;;N;;;;;\n0D57;MALAYALAM AU LENGTH MARK;Mc;0;L;;;;;N;;;;;\n0D60;MALAYALAM LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n0D61;MALAYALAM LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n0D62;MALAYALAM VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n0D63;MALAYALAM VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n0D66;MALAYALAM DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0D67;MALAYALAM DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0D68;MALAYALAM DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0D69;MALAYALAM DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0D6A;MALAYALAM DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0D6B;MALAYALAM DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0D6C;MALAYALAM DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0D6D;MALAYALAM DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0D6E;MALAYALAM DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0D6F;MALAYALAM DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0D70;MALAYALAM NUMBER TEN;No;0;L;;;;10;N;;;;;\n0D71;MALAYALAM NUMBER ONE HUNDRED;No;0;L;;;;100;N;;;;;\n0D72;MALAYALAM NUMBER ONE THOUSAND;No;0;L;;;;1000;N;;;;;\n0D73;MALAYALAM FRACTION ONE QUARTER;No;0;L;;;;1/4;N;;;;;\n0D74;MALAYALAM FRACTION ONE HALF;No;0;L;;;;1/2;N;;;;;\n0D75;MALAYALAM FRACTION THREE QUARTERS;No;0;L;;;;3/4;N;;;;;\n0D79;MALAYALAM DATE MARK;So;0;L;;;;;N;;;;;\n0D7A;MALAYALAM LETTER CHILLU NN;Lo;0;L;;;;;N;;;;;\n0D7B;MALAYALAM LETTER CHILLU N;Lo;0;L;;;;;N;;;;;\n0D7C;MALAYALAM LETTER CHILLU RR;Lo;0;L;;;;;N;;;;;\n0D7D;MALAYALAM LETTER CHILLU L;Lo;0;L;;;;;N;;;;;\n0D7E;MALAYALAM LETTER CHILLU LL;Lo;0;L;;;;;N;;;;;\n0D7F;MALAYALAM LETTER CHILLU K;Lo;0;L;;;;;N;;;;;\n0D82;SINHALA SIGN ANUSVARAYA;Mc;0;L;;;;;N;;;;;\n0D83;SINHALA SIGN VISARGAYA;Mc;0;L;;;;;N;;;;;\n0D85;SINHALA LETTER AYANNA;Lo;0;L;;;;;N;;;;;\n0D86;SINHALA LETTER AAYANNA;Lo;0;L;;;;;N;;;;;\n0D87;SINHALA LETTER AEYANNA;Lo;0;L;;;;;N;;;;;\n0D88;SINHALA LETTER AEEYANNA;Lo;0;L;;;;;N;;;;;\n0D89;SINHALA LETTER IYANNA;Lo;0;L;;;;;N;;;;;\n0D8A;SINHALA LETTER IIYANNA;Lo;0;L;;;;;N;;;;;\n0D8B;SINHALA LETTER UYANNA;Lo;0;L;;;;;N;;;;;\n0D8C;SINHALA LETTER UUYANNA;Lo;0;L;;;;;N;;;;;\n0D8D;SINHALA LETTER IRUYANNA;Lo;0;L;;;;;N;;;;;\n0D8E;SINHALA LETTER IRUUYANNA;Lo;0;L;;;;;N;;;;;\n0D8F;SINHALA LETTER ILUYANNA;Lo;0;L;;;;;N;;;;;\n0D90;SINHALA LETTER ILUUYANNA;Lo;0;L;;;;;N;;;;;\n0D91;SINHALA LETTER EYANNA;Lo;0;L;;;;;N;;;;;\n0D92;SINHALA LETTER EEYANNA;Lo;0;L;;;;;N;;;;;\n0D93;SINHALA LETTER AIYANNA;Lo;0;L;;;;;N;;;;;\n0D94;SINHALA LETTER OYANNA;Lo;0;L;;;;;N;;;;;\n0D95;SINHALA LETTER OOYANNA;Lo;0;L;;;;;N;;;;;\n0D96;SINHALA LETTER AUYANNA;Lo;0;L;;;;;N;;;;;\n0D9A;SINHALA LETTER ALPAPRAANA KAYANNA;Lo;0;L;;;;;N;;;;;\n0D9B;SINHALA LETTER MAHAAPRAANA KAYANNA;Lo;0;L;;;;;N;;;;;\n0D9C;SINHALA LETTER ALPAPRAANA GAYANNA;Lo;0;L;;;;;N;;;;;\n0D9D;SINHALA LETTER MAHAAPRAANA GAYANNA;Lo;0;L;;;;;N;;;;;\n0D9E;SINHALA LETTER KANTAJA NAASIKYAYA;Lo;0;L;;;;;N;;;;;\n0D9F;SINHALA LETTER SANYAKA GAYANNA;Lo;0;L;;;;;N;;;;;\n0DA0;SINHALA LETTER ALPAPRAANA CAYANNA;Lo;0;L;;;;;N;;;;;\n0DA1;SINHALA LETTER MAHAAPRAANA CAYANNA;Lo;0;L;;;;;N;;;;;\n0DA2;SINHALA LETTER ALPAPRAANA JAYANNA;Lo;0;L;;;;;N;;;;;\n0DA3;SINHALA LETTER MAHAAPRAANA JAYANNA;Lo;0;L;;;;;N;;;;;\n0DA4;SINHALA LETTER TAALUJA NAASIKYAYA;Lo;0;L;;;;;N;;;;;\n0DA5;SINHALA LETTER TAALUJA SANYOOGA NAAKSIKYAYA;Lo;0;L;;;;;N;;;;;\n0DA6;SINHALA LETTER SANYAKA JAYANNA;Lo;0;L;;;;;N;;;;;\n0DA7;SINHALA LETTER ALPAPRAANA TTAYANNA;Lo;0;L;;;;;N;;;;;\n0DA8;SINHALA LETTER MAHAAPRAANA TTAYANNA;Lo;0;L;;;;;N;;;;;\n0DA9;SINHALA LETTER ALPAPRAANA DDAYANNA;Lo;0;L;;;;;N;;;;;\n0DAA;SINHALA LETTER MAHAAPRAANA DDAYANNA;Lo;0;L;;;;;N;;;;;\n0DAB;SINHALA LETTER MUURDHAJA NAYANNA;Lo;0;L;;;;;N;;;;;\n0DAC;SINHALA LETTER SANYAKA DDAYANNA;Lo;0;L;;;;;N;;;;;\n0DAD;SINHALA LETTER ALPAPRAANA TAYANNA;Lo;0;L;;;;;N;;;;;\n0DAE;SINHALA LETTER MAHAAPRAANA TAYANNA;Lo;0;L;;;;;N;;;;;\n0DAF;SINHALA LETTER ALPAPRAANA DAYANNA;Lo;0;L;;;;;N;;;;;\n0DB0;SINHALA LETTER MAHAAPRAANA DAYANNA;Lo;0;L;;;;;N;;;;;\n0DB1;SINHALA LETTER DANTAJA NAYANNA;Lo;0;L;;;;;N;;;;;\n0DB3;SINHALA LETTER SANYAKA DAYANNA;Lo;0;L;;;;;N;;;;;\n0DB4;SINHALA LETTER ALPAPRAANA PAYANNA;Lo;0;L;;;;;N;;;;;\n0DB5;SINHALA LETTER MAHAAPRAANA PAYANNA;Lo;0;L;;;;;N;;;;;\n0DB6;SINHALA LETTER ALPAPRAANA BAYANNA;Lo;0;L;;;;;N;;;;;\n0DB7;SINHALA LETTER MAHAAPRAANA BAYANNA;Lo;0;L;;;;;N;;;;;\n0DB8;SINHALA LETTER MAYANNA;Lo;0;L;;;;;N;;;;;\n0DB9;SINHALA LETTER AMBA BAYANNA;Lo;0;L;;;;;N;;;;;\n0DBA;SINHALA LETTER YAYANNA;Lo;0;L;;;;;N;;;;;\n0DBB;SINHALA LETTER RAYANNA;Lo;0;L;;;;;N;;;;;\n0DBD;SINHALA LETTER DANTAJA LAYANNA;Lo;0;L;;;;;N;;;;;\n0DC0;SINHALA LETTER VAYANNA;Lo;0;L;;;;;N;;;;;\n0DC1;SINHALA LETTER TAALUJA SAYANNA;Lo;0;L;;;;;N;;;;;\n0DC2;SINHALA LETTER MUURDHAJA SAYANNA;Lo;0;L;;;;;N;;;;;\n0DC3;SINHALA LETTER DANTAJA SAYANNA;Lo;0;L;;;;;N;;;;;\n0DC4;SINHALA LETTER HAYANNA;Lo;0;L;;;;;N;;;;;\n0DC5;SINHALA LETTER MUURDHAJA LAYANNA;Lo;0;L;;;;;N;;;;;\n0DC6;SINHALA LETTER FAYANNA;Lo;0;L;;;;;N;;;;;\n0DCA;SINHALA SIGN AL-LAKUNA;Mn;9;NSM;;;;;N;;;;;\n0DCF;SINHALA VOWEL SIGN AELA-PILLA;Mc;0;L;;;;;N;;;;;\n0DD0;SINHALA VOWEL SIGN KETTI AEDA-PILLA;Mc;0;L;;;;;N;;;;;\n0DD1;SINHALA VOWEL SIGN DIGA AEDA-PILLA;Mc;0;L;;;;;N;;;;;\n0DD2;SINHALA VOWEL SIGN KETTI IS-PILLA;Mn;0;NSM;;;;;N;;;;;\n0DD3;SINHALA VOWEL SIGN DIGA IS-PILLA;Mn;0;NSM;;;;;N;;;;;\n0DD4;SINHALA VOWEL SIGN KETTI PAA-PILLA;Mn;0;NSM;;;;;N;;;;;\n0DD6;SINHALA VOWEL SIGN DIGA PAA-PILLA;Mn;0;NSM;;;;;N;;;;;\n0DD8;SINHALA VOWEL SIGN GAETTA-PILLA;Mc;0;L;;;;;N;;;;;\n0DD9;SINHALA VOWEL SIGN KOMBUVA;Mc;0;L;;;;;N;;;;;\n0DDA;SINHALA VOWEL SIGN DIGA KOMBUVA;Mc;0;L;0DD9 0DCA;;;;N;;;;;\n0DDB;SINHALA VOWEL SIGN KOMBU DEKA;Mc;0;L;;;;;N;;;;;\n0DDC;SINHALA VOWEL SIGN KOMBUVA HAA AELA-PILLA;Mc;0;L;0DD9 0DCF;;;;N;;;;;\n0DDD;SINHALA VOWEL SIGN KOMBUVA HAA DIGA AELA-PILLA;Mc;0;L;0DDC 0DCA;;;;N;;;;;\n0DDE;SINHALA VOWEL SIGN KOMBUVA HAA GAYANUKITTA;Mc;0;L;0DD9 0DDF;;;;N;;;;;\n0DDF;SINHALA VOWEL SIGN GAYANUKITTA;Mc;0;L;;;;;N;;;;;\n0DF2;SINHALA VOWEL SIGN DIGA GAETTA-PILLA;Mc;0;L;;;;;N;;;;;\n0DF3;SINHALA VOWEL SIGN DIGA GAYANUKITTA;Mc;0;L;;;;;N;;;;;\n0DF4;SINHALA PUNCTUATION KUNDDALIYA;Po;0;L;;;;;N;;;;;\n0E01;THAI CHARACTER KO KAI;Lo;0;L;;;;;N;THAI LETTER KO KAI;;;;\n0E02;THAI CHARACTER KHO KHAI;Lo;0;L;;;;;N;THAI LETTER KHO KHAI;;;;\n0E03;THAI CHARACTER KHO KHUAT;Lo;0;L;;;;;N;THAI LETTER KHO KHUAT;;;;\n0E04;THAI CHARACTER KHO KHWAI;Lo;0;L;;;;;N;THAI LETTER KHO KHWAI;;;;\n0E05;THAI CHARACTER KHO KHON;Lo;0;L;;;;;N;THAI LETTER KHO KHON;;;;\n0E06;THAI CHARACTER KHO RAKHANG;Lo;0;L;;;;;N;THAI LETTER KHO RAKHANG;;;;\n0E07;THAI CHARACTER NGO NGU;Lo;0;L;;;;;N;THAI LETTER NGO NGU;;;;\n0E08;THAI CHARACTER CHO CHAN;Lo;0;L;;;;;N;THAI LETTER CHO CHAN;;;;\n0E09;THAI CHARACTER CHO CHING;Lo;0;L;;;;;N;THAI LETTER CHO CHING;;;;\n0E0A;THAI CHARACTER CHO CHANG;Lo;0;L;;;;;N;THAI LETTER CHO CHANG;;;;\n0E0B;THAI CHARACTER SO SO;Lo;0;L;;;;;N;THAI LETTER SO SO;;;;\n0E0C;THAI CHARACTER CHO CHOE;Lo;0;L;;;;;N;THAI LETTER CHO CHOE;;;;\n0E0D;THAI CHARACTER YO YING;Lo;0;L;;;;;N;THAI LETTER YO YING;;;;\n0E0E;THAI CHARACTER DO CHADA;Lo;0;L;;;;;N;THAI LETTER DO CHADA;;;;\n0E0F;THAI CHARACTER TO PATAK;Lo;0;L;;;;;N;THAI LETTER TO PATAK;;;;\n0E10;THAI CHARACTER THO THAN;Lo;0;L;;;;;N;THAI LETTER THO THAN;;;;\n0E11;THAI CHARACTER THO NANGMONTHO;Lo;0;L;;;;;N;THAI LETTER THO NANGMONTHO;;;;\n0E12;THAI CHARACTER THO PHUTHAO;Lo;0;L;;;;;N;THAI LETTER THO PHUTHAO;;;;\n0E13;THAI CHARACTER NO NEN;Lo;0;L;;;;;N;THAI LETTER NO NEN;;;;\n0E14;THAI CHARACTER DO DEK;Lo;0;L;;;;;N;THAI LETTER DO DEK;;;;\n0E15;THAI CHARACTER TO TAO;Lo;0;L;;;;;N;THAI LETTER TO TAO;;;;\n0E16;THAI CHARACTER THO THUNG;Lo;0;L;;;;;N;THAI LETTER THO THUNG;;;;\n0E17;THAI CHARACTER THO THAHAN;Lo;0;L;;;;;N;THAI LETTER THO THAHAN;;;;\n0E18;THAI CHARACTER THO THONG;Lo;0;L;;;;;N;THAI LETTER THO THONG;;;;\n0E19;THAI CHARACTER NO NU;Lo;0;L;;;;;N;THAI LETTER NO NU;;;;\n0E1A;THAI CHARACTER BO BAIMAI;Lo;0;L;;;;;N;THAI LETTER BO BAIMAI;;;;\n0E1B;THAI CHARACTER PO PLA;Lo;0;L;;;;;N;THAI LETTER PO PLA;;;;\n0E1C;THAI CHARACTER PHO PHUNG;Lo;0;L;;;;;N;THAI LETTER PHO PHUNG;;;;\n0E1D;THAI CHARACTER FO FA;Lo;0;L;;;;;N;THAI LETTER FO FA;;;;\n0E1E;THAI CHARACTER PHO PHAN;Lo;0;L;;;;;N;THAI LETTER PHO PHAN;;;;\n0E1F;THAI CHARACTER FO FAN;Lo;0;L;;;;;N;THAI LETTER FO FAN;;;;\n0E20;THAI CHARACTER PHO SAMPHAO;Lo;0;L;;;;;N;THAI LETTER PHO SAMPHAO;;;;\n0E21;THAI CHARACTER MO MA;Lo;0;L;;;;;N;THAI LETTER MO MA;;;;\n0E22;THAI CHARACTER YO YAK;Lo;0;L;;;;;N;THAI LETTER YO YAK;;;;\n0E23;THAI CHARACTER RO RUA;Lo;0;L;;;;;N;THAI LETTER RO RUA;;;;\n0E24;THAI CHARACTER RU;Lo;0;L;;;;;N;THAI LETTER RU;;;;\n0E25;THAI CHARACTER LO LING;Lo;0;L;;;;;N;THAI LETTER LO LING;;;;\n0E26;THAI CHARACTER LU;Lo;0;L;;;;;N;THAI LETTER LU;;;;\n0E27;THAI CHARACTER WO WAEN;Lo;0;L;;;;;N;THAI LETTER WO WAEN;;;;\n0E28;THAI CHARACTER SO SALA;Lo;0;L;;;;;N;THAI LETTER SO SALA;;;;\n0E29;THAI CHARACTER SO RUSI;Lo;0;L;;;;;N;THAI LETTER SO RUSI;;;;\n0E2A;THAI CHARACTER SO SUA;Lo;0;L;;;;;N;THAI LETTER SO SUA;;;;\n0E2B;THAI CHARACTER HO HIP;Lo;0;L;;;;;N;THAI LETTER HO HIP;;;;\n0E2C;THAI CHARACTER LO CHULA;Lo;0;L;;;;;N;THAI LETTER LO CHULA;;;;\n0E2D;THAI CHARACTER O ANG;Lo;0;L;;;;;N;THAI LETTER O ANG;;;;\n0E2E;THAI CHARACTER HO NOKHUK;Lo;0;L;;;;;N;THAI LETTER HO NOK HUK;;;;\n0E2F;THAI CHARACTER PAIYANNOI;Lo;0;L;;;;;N;THAI PAI YAN NOI;;;;\n0E30;THAI CHARACTER SARA A;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA A;;;;\n0E31;THAI CHARACTER MAI HAN-AKAT;Mn;0;NSM;;;;;N;THAI VOWEL SIGN MAI HAN-AKAT;;;;\n0E32;THAI CHARACTER SARA AA;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA AA;;;;\n0E33;THAI CHARACTER SARA AM;Lo;0;L;<compat> 0E4D 0E32;;;;N;THAI VOWEL SIGN SARA AM;;;;\n0E34;THAI CHARACTER SARA I;Mn;0;NSM;;;;;N;THAI VOWEL SIGN SARA I;;;;\n0E35;THAI CHARACTER SARA II;Mn;0;NSM;;;;;N;THAI VOWEL SIGN SARA II;;;;\n0E36;THAI CHARACTER SARA UE;Mn;0;NSM;;;;;N;THAI VOWEL SIGN SARA UE;;;;\n0E37;THAI CHARACTER SARA UEE;Mn;0;NSM;;;;;N;THAI VOWEL SIGN SARA UEE;;;;\n0E38;THAI CHARACTER SARA U;Mn;103;NSM;;;;;N;THAI VOWEL SIGN SARA U;;;;\n0E39;THAI CHARACTER SARA UU;Mn;103;NSM;;;;;N;THAI VOWEL SIGN SARA UU;;;;\n0E3A;THAI CHARACTER PHINTHU;Mn;9;NSM;;;;;N;THAI VOWEL SIGN PHINTHU;;;;\n0E3F;THAI CURRENCY SYMBOL BAHT;Sc;0;ET;;;;;N;THAI BAHT SIGN;;;;\n0E40;THAI CHARACTER SARA E;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA E;;;;\n0E41;THAI CHARACTER SARA AE;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA AE;;;;\n0E42;THAI CHARACTER SARA O;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA O;;;;\n0E43;THAI CHARACTER SARA AI MAIMUAN;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA MAI MUAN;;;;\n0E44;THAI CHARACTER SARA AI MAIMALAI;Lo;0;L;;;;;N;THAI VOWEL SIGN SARA MAI MALAI;;;;\n0E45;THAI CHARACTER LAKKHANGYAO;Lo;0;L;;;;;N;THAI LAK KHANG YAO;;;;\n0E46;THAI CHARACTER MAIYAMOK;Lm;0;L;;;;;N;THAI MAI YAMOK;;;;\n0E47;THAI CHARACTER MAITAIKHU;Mn;0;NSM;;;;;N;THAI VOWEL SIGN MAI TAI KHU;;;;\n0E48;THAI CHARACTER MAI EK;Mn;107;NSM;;;;;N;THAI TONE MAI EK;;;;\n0E49;THAI CHARACTER MAI THO;Mn;107;NSM;;;;;N;THAI TONE MAI THO;;;;\n0E4A;THAI CHARACTER MAI TRI;Mn;107;NSM;;;;;N;THAI TONE MAI TRI;;;;\n0E4B;THAI CHARACTER MAI CHATTAWA;Mn;107;NSM;;;;;N;THAI TONE MAI CHATTAWA;;;;\n0E4C;THAI CHARACTER THANTHAKHAT;Mn;0;NSM;;;;;N;THAI THANTHAKHAT;;;;\n0E4D;THAI CHARACTER NIKHAHIT;Mn;0;NSM;;;;;N;THAI NIKKHAHIT;;;;\n0E4E;THAI CHARACTER YAMAKKAN;Mn;0;NSM;;;;;N;THAI YAMAKKAN;;;;\n0E4F;THAI CHARACTER FONGMAN;Po;0;L;;;;;N;THAI FONGMAN;;;;\n0E50;THAI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0E51;THAI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0E52;THAI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0E53;THAI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0E54;THAI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0E55;THAI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0E56;THAI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0E57;THAI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0E58;THAI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0E59;THAI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0E5A;THAI CHARACTER ANGKHANKHU;Po;0;L;;;;;N;THAI ANGKHANKHU;;;;\n0E5B;THAI CHARACTER KHOMUT;Po;0;L;;;;;N;THAI KHOMUT;;;;\n0E81;LAO LETTER KO;Lo;0;L;;;;;N;;;;;\n0E82;LAO LETTER KHO SUNG;Lo;0;L;;;;;N;;;;;\n0E84;LAO LETTER KHO TAM;Lo;0;L;;;;;N;;;;;\n0E87;LAO LETTER NGO;Lo;0;L;;;;;N;;;;;\n0E88;LAO LETTER CO;Lo;0;L;;;;;N;;;;;\n0E8A;LAO LETTER SO TAM;Lo;0;L;;;;;N;;;;;\n0E8D;LAO LETTER NYO;Lo;0;L;;;;;N;;;;;\n0E94;LAO LETTER DO;Lo;0;L;;;;;N;;;;;\n0E95;LAO LETTER TO;Lo;0;L;;;;;N;;;;;\n0E96;LAO LETTER THO SUNG;Lo;0;L;;;;;N;;;;;\n0E97;LAO LETTER THO TAM;Lo;0;L;;;;;N;;;;;\n0E99;LAO LETTER NO;Lo;0;L;;;;;N;;;;;\n0E9A;LAO LETTER BO;Lo;0;L;;;;;N;;;;;\n0E9B;LAO LETTER PO;Lo;0;L;;;;;N;;;;;\n0E9C;LAO LETTER PHO SUNG;Lo;0;L;;;;;N;;;;;\n0E9D;LAO LETTER FO TAM;Lo;0;L;;;;;N;;;;;\n0E9E;LAO LETTER PHO TAM;Lo;0;L;;;;;N;;;;;\n0E9F;LAO LETTER FO SUNG;Lo;0;L;;;;;N;;;;;\n0EA1;LAO LETTER MO;Lo;0;L;;;;;N;;;;;\n0EA2;LAO LETTER YO;Lo;0;L;;;;;N;;;;;\n0EA3;LAO LETTER LO LING;Lo;0;L;;;;;N;;;;;\n0EA5;LAO LETTER LO LOOT;Lo;0;L;;;;;N;;;;;\n0EA7;LAO LETTER WO;Lo;0;L;;;;;N;;;;;\n0EAA;LAO LETTER SO SUNG;Lo;0;L;;;;;N;;;;;\n0EAB;LAO LETTER HO SUNG;Lo;0;L;;;;;N;;;;;\n0EAD;LAO LETTER O;Lo;0;L;;;;;N;;;;;\n0EAE;LAO LETTER HO TAM;Lo;0;L;;;;;N;;;;;\n0EAF;LAO ELLIPSIS;Lo;0;L;;;;;N;;;;;\n0EB0;LAO VOWEL SIGN A;Lo;0;L;;;;;N;;;;;\n0EB1;LAO VOWEL SIGN MAI KAN;Mn;0;NSM;;;;;N;;;;;\n0EB2;LAO VOWEL SIGN AA;Lo;0;L;;;;;N;;;;;\n0EB3;LAO VOWEL SIGN AM;Lo;0;L;<compat> 0ECD 0EB2;;;;N;;;;;\n0EB4;LAO VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n0EB5;LAO VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n0EB6;LAO VOWEL SIGN Y;Mn;0;NSM;;;;;N;;;;;\n0EB7;LAO VOWEL SIGN YY;Mn;0;NSM;;;;;N;;;;;\n0EB8;LAO VOWEL SIGN U;Mn;118;NSM;;;;;N;;;;;\n0EB9;LAO VOWEL SIGN UU;Mn;118;NSM;;;;;N;;;;;\n0EBB;LAO VOWEL SIGN MAI KON;Mn;0;NSM;;;;;N;;;;;\n0EBC;LAO SEMIVOWEL SIGN LO;Mn;0;NSM;;;;;N;;;;;\n0EBD;LAO SEMIVOWEL SIGN NYO;Lo;0;L;;;;;N;;;;;\n0EC0;LAO VOWEL SIGN E;Lo;0;L;;;;;N;;;;;\n0EC1;LAO VOWEL SIGN EI;Lo;0;L;;;;;N;;;;;\n0EC2;LAO VOWEL SIGN O;Lo;0;L;;;;;N;;;;;\n0EC3;LAO VOWEL SIGN AY;Lo;0;L;;;;;N;;;;;\n0EC4;LAO VOWEL SIGN AI;Lo;0;L;;;;;N;;;;;\n0EC6;LAO KO LA;Lm;0;L;;;;;N;;;;;\n0EC8;LAO TONE MAI EK;Mn;122;NSM;;;;;N;;;;;\n0EC9;LAO TONE MAI THO;Mn;122;NSM;;;;;N;;;;;\n0ECA;LAO TONE MAI TI;Mn;122;NSM;;;;;N;;;;;\n0ECB;LAO TONE MAI CATAWA;Mn;122;NSM;;;;;N;;;;;\n0ECC;LAO CANCELLATION MARK;Mn;0;NSM;;;;;N;;;;;\n0ECD;LAO NIGGAHITA;Mn;0;NSM;;;;;N;;;;;\n0ED0;LAO DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0ED1;LAO DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0ED2;LAO DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0ED3;LAO DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0ED4;LAO DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0ED5;LAO DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0ED6;LAO DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0ED7;LAO DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0ED8;LAO DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0ED9;LAO DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0EDC;LAO HO NO;Lo;0;L;<compat> 0EAB 0E99;;;;N;;;;;\n0EDD;LAO HO MO;Lo;0;L;<compat> 0EAB 0EA1;;;;N;;;;;\n0EDE;LAO LETTER KHMU GO;Lo;0;L;;;;;N;;;;;\n0EDF;LAO LETTER KHMU NYO;Lo;0;L;;;;;N;;;;;\n0F00;TIBETAN SYLLABLE OM;Lo;0;L;;;;;N;;;;;\n0F01;TIBETAN MARK GTER YIG MGO TRUNCATED A;So;0;L;;;;;N;;;;;\n0F02;TIBETAN MARK GTER YIG MGO -UM RNAM BCAD MA;So;0;L;;;;;N;;;;;\n0F03;TIBETAN MARK GTER YIG MGO -UM GTER TSHEG MA;So;0;L;;;;;N;;;;;\n0F04;TIBETAN MARK INITIAL YIG MGO MDUN MA;Po;0;L;;;;;N;TIBETAN SINGLE ORNAMENT;;;;\n0F05;TIBETAN MARK CLOSING YIG MGO SGAB MA;Po;0;L;;;;;N;;;;;\n0F06;TIBETAN MARK CARET YIG MGO PHUR SHAD MA;Po;0;L;;;;;N;;;;;\n0F07;TIBETAN MARK YIG MGO TSHEG SHAD MA;Po;0;L;;;;;N;;;;;\n0F08;TIBETAN MARK SBRUL SHAD;Po;0;L;;;;;N;TIBETAN RGYANSHAD;;;;\n0F09;TIBETAN MARK BSKUR YIG MGO;Po;0;L;;;;;N;;;;;\n0F0A;TIBETAN MARK BKA- SHOG YIG MGO;Po;0;L;;;;;N;;;;;\n0F0B;TIBETAN MARK INTERSYLLABIC TSHEG;Po;0;L;;;;;N;TIBETAN TSEG;;;;\n0F0C;TIBETAN MARK DELIMITER TSHEG BSTAR;Po;0;L;<noBreak> 0F0B;;;;N;;;;;\n0F0D;TIBETAN MARK SHAD;Po;0;L;;;;;N;TIBETAN SHAD;;;;\n0F0E;TIBETAN MARK NYIS SHAD;Po;0;L;;;;;N;TIBETAN DOUBLE SHAD;;;;\n0F0F;TIBETAN MARK TSHEG SHAD;Po;0;L;;;;;N;;;;;\n0F10;TIBETAN MARK NYIS TSHEG SHAD;Po;0;L;;;;;N;;;;;\n0F11;TIBETAN MARK RIN CHEN SPUNGS SHAD;Po;0;L;;;;;N;TIBETAN RINCHANPHUNGSHAD;;;;\n0F12;TIBETAN MARK RGYA GRAM SHAD;Po;0;L;;;;;N;;;;;\n0F13;TIBETAN MARK CARET -DZUD RTAGS ME LONG CAN;So;0;L;;;;;N;;;;;\n0F14;TIBETAN MARK GTER TSHEG;Po;0;L;;;;;N;TIBETAN COMMA;;;;\n0F15;TIBETAN LOGOTYPE SIGN CHAD RTAGS;So;0;L;;;;;N;;;;;\n0F16;TIBETAN LOGOTYPE SIGN LHAG RTAGS;So;0;L;;;;;N;;;;;\n0F17;TIBETAN ASTROLOGICAL SIGN SGRA GCAN -CHAR RTAGS;So;0;L;;;;;N;;;;;\n0F18;TIBETAN ASTROLOGICAL SIGN -KHYUD PA;Mn;220;NSM;;;;;N;;;;;\n0F19;TIBETAN ASTROLOGICAL SIGN SDONG TSHUGS;Mn;220;NSM;;;;;N;;;;;\n0F1A;TIBETAN SIGN RDEL DKAR GCIG;So;0;L;;;;;N;;;;;\n0F1B;TIBETAN SIGN RDEL DKAR GNYIS;So;0;L;;;;;N;;;;;\n0F1C;TIBETAN SIGN RDEL DKAR GSUM;So;0;L;;;;;N;;;;;\n0F1D;TIBETAN SIGN RDEL NAG GCIG;So;0;L;;;;;N;;;;;\n0F1E;TIBETAN SIGN RDEL NAG GNYIS;So;0;L;;;;;N;;;;;\n0F1F;TIBETAN SIGN RDEL DKAR RDEL NAG;So;0;L;;;;;N;;;;;\n0F20;TIBETAN DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n0F21;TIBETAN DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n0F22;TIBETAN DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n0F23;TIBETAN DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n0F24;TIBETAN DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n0F25;TIBETAN DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n0F26;TIBETAN DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n0F27;TIBETAN DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n0F28;TIBETAN DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n0F29;TIBETAN DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n0F2A;TIBETAN DIGIT HALF ONE;No;0;L;;;;1/2;N;;;;;\n0F2B;TIBETAN DIGIT HALF TWO;No;0;L;;;;3/2;N;;;;;\n0F2C;TIBETAN DIGIT HALF THREE;No;0;L;;;;5/2;N;;;;;\n0F2D;TIBETAN DIGIT HALF FOUR;No;0;L;;;;7/2;N;;;;;\n0F2E;TIBETAN DIGIT HALF FIVE;No;0;L;;;;9/2;N;;;;;\n0F2F;TIBETAN DIGIT HALF SIX;No;0;L;;;;11/2;N;;;;;\n0F30;TIBETAN DIGIT HALF SEVEN;No;0;L;;;;13/2;N;;;;;\n0F31;TIBETAN DIGIT HALF EIGHT;No;0;L;;;;15/2;N;;;;;\n0F32;TIBETAN DIGIT HALF NINE;No;0;L;;;;17/2;N;;;;;\n0F33;TIBETAN DIGIT HALF ZERO;No;0;L;;;;-1/2;N;;;;;\n0F34;TIBETAN MARK BSDUS RTAGS;So;0;L;;;;;N;;;;;\n0F35;TIBETAN MARK NGAS BZUNG NYI ZLA;Mn;220;NSM;;;;;N;TIBETAN HONORIFIC UNDER RING;;;;\n0F36;TIBETAN MARK CARET -DZUD RTAGS BZHI MIG CAN;So;0;L;;;;;N;;;;;\n0F37;TIBETAN MARK NGAS BZUNG SGOR RTAGS;Mn;220;NSM;;;;;N;TIBETAN UNDER RING;;;;\n0F38;TIBETAN MARK CHE MGO;So;0;L;;;;;N;;;;;\n0F39;TIBETAN MARK TSA -PHRU;Mn;216;NSM;;;;;N;TIBETAN LENITION MARK;;;;\n0F3A;TIBETAN MARK GUG RTAGS GYON;Ps;0;ON;;;;;Y;;;;;\n0F3B;TIBETAN MARK GUG RTAGS GYAS;Pe;0;ON;;;;;Y;;;;;\n0F3C;TIBETAN MARK ANG KHANG GYON;Ps;0;ON;;;;;Y;TIBETAN LEFT BRACE;;;;\n0F3D;TIBETAN MARK ANG KHANG GYAS;Pe;0;ON;;;;;Y;TIBETAN RIGHT BRACE;;;;\n0F3E;TIBETAN SIGN YAR TSHES;Mc;0;L;;;;;N;;;;;\n0F3F;TIBETAN SIGN MAR TSHES;Mc;0;L;;;;;N;;;;;\n0F40;TIBETAN LETTER KA;Lo;0;L;;;;;N;;;;;\n0F41;TIBETAN LETTER KHA;Lo;0;L;;;;;N;;;;;\n0F42;TIBETAN LETTER GA;Lo;0;L;;;;;N;;;;;\n0F43;TIBETAN LETTER GHA;Lo;0;L;0F42 0FB7;;;;N;;;;;\n0F44;TIBETAN LETTER NGA;Lo;0;L;;;;;N;;;;;\n0F45;TIBETAN LETTER CA;Lo;0;L;;;;;N;;;;;\n0F46;TIBETAN LETTER CHA;Lo;0;L;;;;;N;;;;;\n0F47;TIBETAN LETTER JA;Lo;0;L;;;;;N;;;;;\n0F49;TIBETAN LETTER NYA;Lo;0;L;;;;;N;;;;;\n0F4A;TIBETAN LETTER TTA;Lo;0;L;;;;;N;TIBETAN LETTER REVERSED TA;;;;\n0F4B;TIBETAN LETTER TTHA;Lo;0;L;;;;;N;TIBETAN LETTER REVERSED THA;;;;\n0F4C;TIBETAN LETTER DDA;Lo;0;L;;;;;N;TIBETAN LETTER REVERSED DA;;;;\n0F4D;TIBETAN LETTER DDHA;Lo;0;L;0F4C 0FB7;;;;N;;;;;\n0F4E;TIBETAN LETTER NNA;Lo;0;L;;;;;N;TIBETAN LETTER REVERSED NA;;;;\n0F4F;TIBETAN LETTER TA;Lo;0;L;;;;;N;;;;;\n0F50;TIBETAN LETTER THA;Lo;0;L;;;;;N;;;;;\n0F51;TIBETAN LETTER DA;Lo;0;L;;;;;N;;;;;\n0F52;TIBETAN LETTER DHA;Lo;0;L;0F51 0FB7;;;;N;;;;;\n0F53;TIBETAN LETTER NA;Lo;0;L;;;;;N;;;;;\n0F54;TIBETAN LETTER PA;Lo;0;L;;;;;N;;;;;\n0F55;TIBETAN LETTER PHA;Lo;0;L;;;;;N;;;;;\n0F56;TIBETAN LETTER BA;Lo;0;L;;;;;N;;;;;\n0F57;TIBETAN LETTER BHA;Lo;0;L;0F56 0FB7;;;;N;;;;;\n0F58;TIBETAN LETTER MA;Lo;0;L;;;;;N;;;;;\n0F59;TIBETAN LETTER TSA;Lo;0;L;;;;;N;;;;;\n0F5A;TIBETAN LETTER TSHA;Lo;0;L;;;;;N;;;;;\n0F5B;TIBETAN LETTER DZA;Lo;0;L;;;;;N;;;;;\n0F5C;TIBETAN LETTER DZHA;Lo;0;L;0F5B 0FB7;;;;N;;;;;\n0F5D;TIBETAN LETTER WA;Lo;0;L;;;;;N;;;;;\n0F5E;TIBETAN LETTER ZHA;Lo;0;L;;;;;N;;;;;\n0F5F;TIBETAN LETTER ZA;Lo;0;L;;;;;N;;;;;\n0F60;TIBETAN LETTER -A;Lo;0;L;;;;;N;TIBETAN LETTER AA;;;;\n0F61;TIBETAN LETTER YA;Lo;0;L;;;;;N;;;;;\n0F62;TIBETAN LETTER RA;Lo;0;L;;;;;N;;;;;\n0F63;TIBETAN LETTER LA;Lo;0;L;;;;;N;;;;;\n0F64;TIBETAN LETTER SHA;Lo;0;L;;;;;N;;;;;\n0F65;TIBETAN LETTER SSA;Lo;0;L;;;;;N;TIBETAN LETTER REVERSED SHA;;;;\n0F66;TIBETAN LETTER SA;Lo;0;L;;;;;N;;;;;\n0F67;TIBETAN LETTER HA;Lo;0;L;;;;;N;;;;;\n0F68;TIBETAN LETTER A;Lo;0;L;;;;;N;;;;;\n0F69;TIBETAN LETTER KSSA;Lo;0;L;0F40 0FB5;;;;N;;;;;\n0F6A;TIBETAN LETTER FIXED-FORM RA;Lo;0;L;;;;;N;;;;;\n0F6B;TIBETAN LETTER KKA;Lo;0;L;;;;;N;;;;;\n0F6C;TIBETAN LETTER RRA;Lo;0;L;;;;;N;;;;;\n0F71;TIBETAN VOWEL SIGN AA;Mn;129;NSM;;;;;N;;;;;\n0F72;TIBETAN VOWEL SIGN I;Mn;130;NSM;;;;;N;;;;;\n0F73;TIBETAN VOWEL SIGN II;Mn;0;NSM;0F71 0F72;;;;N;;;;;\n0F74;TIBETAN VOWEL SIGN U;Mn;132;NSM;;;;;N;;;;;\n0F75;TIBETAN VOWEL SIGN UU;Mn;0;NSM;0F71 0F74;;;;N;;;;;\n0F76;TIBETAN VOWEL SIGN VOCALIC R;Mn;0;NSM;0FB2 0F80;;;;N;;;;;\n0F77;TIBETAN VOWEL SIGN VOCALIC RR;Mn;0;NSM;<compat> 0FB2 0F81;;;;N;;;;;\n0F78;TIBETAN VOWEL SIGN VOCALIC L;Mn;0;NSM;0FB3 0F80;;;;N;;;;;\n0F79;TIBETAN VOWEL SIGN VOCALIC LL;Mn;0;NSM;<compat> 0FB3 0F81;;;;N;;;;;\n0F7A;TIBETAN VOWEL SIGN E;Mn;130;NSM;;;;;N;;;;;\n0F7B;TIBETAN VOWEL SIGN EE;Mn;130;NSM;;;;;N;TIBETAN VOWEL SIGN AI;;;;\n0F7C;TIBETAN VOWEL SIGN O;Mn;130;NSM;;;;;N;;;;;\n0F7D;TIBETAN VOWEL SIGN OO;Mn;130;NSM;;;;;N;TIBETAN VOWEL SIGN AU;;;;\n0F7E;TIBETAN SIGN RJES SU NGA RO;Mn;0;NSM;;;;;N;TIBETAN ANUSVARA;;;;\n0F7F;TIBETAN SIGN RNAM BCAD;Mc;0;L;;;;;N;TIBETAN VISARGA;;;;\n0F80;TIBETAN VOWEL SIGN REVERSED I;Mn;130;NSM;;;;;N;TIBETAN VOWEL SIGN SHORT I;;;;\n0F81;TIBETAN VOWEL SIGN REVERSED II;Mn;0;NSM;0F71 0F80;;;;N;;;;;\n0F82;TIBETAN SIGN NYI ZLA NAA DA;Mn;230;NSM;;;;;N;TIBETAN CANDRABINDU WITH ORNAMENT;;;;\n0F83;TIBETAN SIGN SNA LDAN;Mn;230;NSM;;;;;N;TIBETAN CANDRABINDU;;;;\n0F84;TIBETAN MARK HALANTA;Mn;9;NSM;;;;;N;TIBETAN VIRAMA;;;;\n0F85;TIBETAN MARK PALUTA;Po;0;L;;;;;N;TIBETAN CHUCHENYIGE;;;;\n0F86;TIBETAN SIGN LCI RTAGS;Mn;230;NSM;;;;;N;;;;;\n0F87;TIBETAN SIGN YANG RTAGS;Mn;230;NSM;;;;;N;;;;;\n0F88;TIBETAN SIGN LCE TSA CAN;Lo;0;L;;;;;N;;;;;\n0F89;TIBETAN SIGN MCHU CAN;Lo;0;L;;;;;N;;;;;\n0F8A;TIBETAN SIGN GRU CAN RGYINGS;Lo;0;L;;;;;N;;;;;\n0F8B;TIBETAN SIGN GRU MED RGYINGS;Lo;0;L;;;;;N;;;;;\n0F8C;TIBETAN SIGN INVERTED MCHU CAN;Lo;0;L;;;;;N;;;;;\n0F8D;TIBETAN SUBJOINED SIGN LCE TSA CAN;Mn;0;NSM;;;;;N;;;;;\n0F8E;TIBETAN SUBJOINED SIGN MCHU CAN;Mn;0;NSM;;;;;N;;;;;\n0F8F;TIBETAN SUBJOINED SIGN INVERTED MCHU CAN;Mn;0;NSM;;;;;N;;;;;\n0F90;TIBETAN SUBJOINED LETTER KA;Mn;0;NSM;;;;;N;;;;;\n0F91;TIBETAN SUBJOINED LETTER KHA;Mn;0;NSM;;;;;N;;;;;\n0F92;TIBETAN SUBJOINED LETTER GA;Mn;0;NSM;;;;;N;;;;;\n0F93;TIBETAN SUBJOINED LETTER GHA;Mn;0;NSM;0F92 0FB7;;;;N;;;;;\n0F94;TIBETAN SUBJOINED LETTER NGA;Mn;0;NSM;;;;;N;;;;;\n0F95;TIBETAN SUBJOINED LETTER CA;Mn;0;NSM;;;;;N;;;;;\n0F96;TIBETAN SUBJOINED LETTER CHA;Mn;0;NSM;;;;;N;;;;;\n0F97;TIBETAN SUBJOINED LETTER JA;Mn;0;NSM;;;;;N;;;;;\n0F99;TIBETAN SUBJOINED LETTER NYA;Mn;0;NSM;;;;;N;;;;;\n0F9A;TIBETAN SUBJOINED LETTER TTA;Mn;0;NSM;;;;;N;;;;;\n0F9B;TIBETAN SUBJOINED LETTER TTHA;Mn;0;NSM;;;;;N;;;;;\n0F9C;TIBETAN SUBJOINED LETTER DDA;Mn;0;NSM;;;;;N;;;;;\n0F9D;TIBETAN SUBJOINED LETTER DDHA;Mn;0;NSM;0F9C 0FB7;;;;N;;;;;\n0F9E;TIBETAN SUBJOINED LETTER NNA;Mn;0;NSM;;;;;N;;;;;\n0F9F;TIBETAN SUBJOINED LETTER TA;Mn;0;NSM;;;;;N;;;;;\n0FA0;TIBETAN SUBJOINED LETTER THA;Mn;0;NSM;;;;;N;;;;;\n0FA1;TIBETAN SUBJOINED LETTER DA;Mn;0;NSM;;;;;N;;;;;\n0FA2;TIBETAN SUBJOINED LETTER DHA;Mn;0;NSM;0FA1 0FB7;;;;N;;;;;\n0FA3;TIBETAN SUBJOINED LETTER NA;Mn;0;NSM;;;;;N;;;;;\n0FA4;TIBETAN SUBJOINED LETTER PA;Mn;0;NSM;;;;;N;;;;;\n0FA5;TIBETAN SUBJOINED LETTER PHA;Mn;0;NSM;;;;;N;;;;;\n0FA6;TIBETAN SUBJOINED LETTER BA;Mn;0;NSM;;;;;N;;;;;\n0FA7;TIBETAN SUBJOINED LETTER BHA;Mn;0;NSM;0FA6 0FB7;;;;N;;;;;\n0FA8;TIBETAN SUBJOINED LETTER MA;Mn;0;NSM;;;;;N;;;;;\n0FA9;TIBETAN SUBJOINED LETTER TSA;Mn;0;NSM;;;;;N;;;;;\n0FAA;TIBETAN SUBJOINED LETTER TSHA;Mn;0;NSM;;;;;N;;;;;\n0FAB;TIBETAN SUBJOINED LETTER DZA;Mn;0;NSM;;;;;N;;;;;\n0FAC;TIBETAN SUBJOINED LETTER DZHA;Mn;0;NSM;0FAB 0FB7;;;;N;;;;;\n0FAD;TIBETAN SUBJOINED LETTER WA;Mn;0;NSM;;;;;N;;;;;\n0FAE;TIBETAN SUBJOINED LETTER ZHA;Mn;0;NSM;;;;;N;;;;;\n0FAF;TIBETAN SUBJOINED LETTER ZA;Mn;0;NSM;;;;;N;;;;;\n0FB0;TIBETAN SUBJOINED LETTER -A;Mn;0;NSM;;;;;N;;;;;\n0FB1;TIBETAN SUBJOINED LETTER YA;Mn;0;NSM;;;;;N;;;;;\n0FB2;TIBETAN SUBJOINED LETTER RA;Mn;0;NSM;;;;;N;;;;;\n0FB3;TIBETAN SUBJOINED LETTER LA;Mn;0;NSM;;;;;N;;;;;\n0FB4;TIBETAN SUBJOINED LETTER SHA;Mn;0;NSM;;;;;N;;;;;\n0FB5;TIBETAN SUBJOINED LETTER SSA;Mn;0;NSM;;;;;N;;;;;\n0FB6;TIBETAN SUBJOINED LETTER SA;Mn;0;NSM;;;;;N;;;;;\n0FB7;TIBETAN SUBJOINED LETTER HA;Mn;0;NSM;;;;;N;;;;;\n0FB8;TIBETAN SUBJOINED LETTER A;Mn;0;NSM;;;;;N;;;;;\n0FB9;TIBETAN SUBJOINED LETTER KSSA;Mn;0;NSM;0F90 0FB5;;;;N;;;;;\n0FBA;TIBETAN SUBJOINED LETTER FIXED-FORM WA;Mn;0;NSM;;;;;N;;;;;\n0FBB;TIBETAN SUBJOINED LETTER FIXED-FORM YA;Mn;0;NSM;;;;;N;;;;;\n0FBC;TIBETAN SUBJOINED LETTER FIXED-FORM RA;Mn;0;NSM;;;;;N;;;;;\n0FBE;TIBETAN KU RU KHA;So;0;L;;;;;N;;;;;\n0FBF;TIBETAN KU RU KHA BZHI MIG CAN;So;0;L;;;;;N;;;;;\n0FC0;TIBETAN CANTILLATION SIGN HEAVY BEAT;So;0;L;;;;;N;;;;;\n0FC1;TIBETAN CANTILLATION SIGN LIGHT BEAT;So;0;L;;;;;N;;;;;\n0FC2;TIBETAN CANTILLATION SIGN CANG TE-U;So;0;L;;;;;N;;;;;\n0FC3;TIBETAN CANTILLATION SIGN SBUB -CHAL;So;0;L;;;;;N;;;;;\n0FC4;TIBETAN SYMBOL DRIL BU;So;0;L;;;;;N;;;;;\n0FC5;TIBETAN SYMBOL RDO RJE;So;0;L;;;;;N;;;;;\n0FC6;TIBETAN SYMBOL PADMA GDAN;Mn;220;NSM;;;;;N;;;;;\n0FC7;TIBETAN SYMBOL RDO RJE RGYA GRAM;So;0;L;;;;;N;;;;;\n0FC8;TIBETAN SYMBOL PHUR PA;So;0;L;;;;;N;;;;;\n0FC9;TIBETAN SYMBOL NOR BU;So;0;L;;;;;N;;;;;\n0FCA;TIBETAN SYMBOL NOR BU NYIS -KHYIL;So;0;L;;;;;N;;;;;\n0FCB;TIBETAN SYMBOL NOR BU GSUM -KHYIL;So;0;L;;;;;N;;;;;\n0FCC;TIBETAN SYMBOL NOR BU BZHI -KHYIL;So;0;L;;;;;N;;;;;\n0FCE;TIBETAN SIGN RDEL NAG RDEL DKAR;So;0;L;;;;;N;;;;;\n0FCF;TIBETAN SIGN RDEL NAG GSUM;So;0;L;;;;;N;;;;;\n0FD0;TIBETAN MARK BSKA- SHOG GI MGO RGYAN;Po;0;L;;;;;N;;;;;\n0FD1;TIBETAN MARK MNYAM YIG GI MGO RGYAN;Po;0;L;;;;;N;;;;;\n0FD2;TIBETAN MARK NYIS TSHEG;Po;0;L;;;;;N;;;;;\n0FD3;TIBETAN MARK INITIAL BRDA RNYING YIG MGO MDUN MA;Po;0;L;;;;;N;;;;;\n0FD4;TIBETAN MARK CLOSING BRDA RNYING YIG MGO SGAB MA;Po;0;L;;;;;N;;;;;\n0FD5;RIGHT-FACING SVASTI SIGN;So;0;L;;;;;N;;;;;\n0FD6;LEFT-FACING SVASTI SIGN;So;0;L;;;;;N;;;;;\n0FD7;RIGHT-FACING SVASTI SIGN WITH DOTS;So;0;L;;;;;N;;;;;\n0FD8;LEFT-FACING SVASTI SIGN WITH DOTS;So;0;L;;;;;N;;;;;\n0FD9;TIBETAN MARK LEADING MCHAN RTAGS;Po;0;L;;;;;N;;;;;\n0FDA;TIBETAN MARK TRAILING MCHAN RTAGS;Po;0;L;;;;;N;;;;;\n1000;MYANMAR LETTER KA;Lo;0;L;;;;;N;;;;;\n1001;MYANMAR LETTER KHA;Lo;0;L;;;;;N;;;;;\n1002;MYANMAR LETTER GA;Lo;0;L;;;;;N;;;;;\n1003;MYANMAR LETTER GHA;Lo;0;L;;;;;N;;;;;\n1004;MYANMAR LETTER NGA;Lo;0;L;;;;;N;;;;;\n1005;MYANMAR LETTER CA;Lo;0;L;;;;;N;;;;;\n1006;MYANMAR LETTER CHA;Lo;0;L;;;;;N;;;;;\n1007;MYANMAR LETTER JA;Lo;0;L;;;;;N;;;;;\n1008;MYANMAR LETTER JHA;Lo;0;L;;;;;N;;;;;\n1009;MYANMAR LETTER NYA;Lo;0;L;;;;;N;;;;;\n100A;MYANMAR LETTER NNYA;Lo;0;L;;;;;N;;;;;\n100B;MYANMAR LETTER TTA;Lo;0;L;;;;;N;;;;;\n100C;MYANMAR LETTER TTHA;Lo;0;L;;;;;N;;;;;\n100D;MYANMAR LETTER DDA;Lo;0;L;;;;;N;;;;;\n100E;MYANMAR LETTER DDHA;Lo;0;L;;;;;N;;;;;\n100F;MYANMAR LETTER NNA;Lo;0;L;;;;;N;;;;;\n1010;MYANMAR LETTER TA;Lo;0;L;;;;;N;;;;;\n1011;MYANMAR LETTER THA;Lo;0;L;;;;;N;;;;;\n1012;MYANMAR LETTER DA;Lo;0;L;;;;;N;;;;;\n1013;MYANMAR LETTER DHA;Lo;0;L;;;;;N;;;;;\n1014;MYANMAR LETTER NA;Lo;0;L;;;;;N;;;;;\n1015;MYANMAR LETTER PA;Lo;0;L;;;;;N;;;;;\n1016;MYANMAR LETTER PHA;Lo;0;L;;;;;N;;;;;\n1017;MYANMAR LETTER BA;Lo;0;L;;;;;N;;;;;\n1018;MYANMAR LETTER BHA;Lo;0;L;;;;;N;;;;;\n1019;MYANMAR LETTER MA;Lo;0;L;;;;;N;;;;;\n101A;MYANMAR LETTER YA;Lo;0;L;;;;;N;;;;;\n101B;MYANMAR LETTER RA;Lo;0;L;;;;;N;;;;;\n101C;MYANMAR LETTER LA;Lo;0;L;;;;;N;;;;;\n101D;MYANMAR LETTER WA;Lo;0;L;;;;;N;;;;;\n101E;MYANMAR LETTER SA;Lo;0;L;;;;;N;;;;;\n101F;MYANMAR LETTER HA;Lo;0;L;;;;;N;;;;;\n1020;MYANMAR LETTER LLA;Lo;0;L;;;;;N;;;;;\n1021;MYANMAR LETTER A;Lo;0;L;;;;;N;;;;;\n1022;MYANMAR LETTER SHAN A;Lo;0;L;;;;;N;;;;;\n1023;MYANMAR LETTER I;Lo;0;L;;;;;N;;;;;\n1024;MYANMAR LETTER II;Lo;0;L;;;;;N;;;;;\n1025;MYANMAR LETTER U;Lo;0;L;;;;;N;;;;;\n1026;MYANMAR LETTER UU;Lo;0;L;1025 102E;;;;N;;;;;\n1027;MYANMAR LETTER E;Lo;0;L;;;;;N;;;;;\n1028;MYANMAR LETTER MON E;Lo;0;L;;;;;N;;;;;\n1029;MYANMAR LETTER O;Lo;0;L;;;;;N;;;;;\n102A;MYANMAR LETTER AU;Lo;0;L;;;;;N;;;;;\n102B;MYANMAR VOWEL SIGN TALL AA;Mc;0;L;;;;;N;;;;;\n102C;MYANMAR VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n102D;MYANMAR VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n102E;MYANMAR VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n102F;MYANMAR VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1030;MYANMAR VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n1031;MYANMAR VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n1032;MYANMAR VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n1033;MYANMAR VOWEL SIGN MON II;Mn;0;NSM;;;;;N;;;;;\n1034;MYANMAR VOWEL SIGN MON O;Mn;0;NSM;;;;;N;;;;;\n1035;MYANMAR VOWEL SIGN E ABOVE;Mn;0;NSM;;;;;N;;;;;\n1036;MYANMAR SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n1037;MYANMAR SIGN DOT BELOW;Mn;7;NSM;;;;;N;;;;;\n1038;MYANMAR SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n1039;MYANMAR SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n103A;MYANMAR SIGN ASAT;Mn;9;NSM;;;;;N;;;;;\n103B;MYANMAR CONSONANT SIGN MEDIAL YA;Mc;0;L;;;;;N;;;;;\n103C;MYANMAR CONSONANT SIGN MEDIAL RA;Mc;0;L;;;;;N;;;;;\n103D;MYANMAR CONSONANT SIGN MEDIAL WA;Mn;0;NSM;;;;;N;;;;;\n103E;MYANMAR CONSONANT SIGN MEDIAL HA;Mn;0;NSM;;;;;N;;;;;\n103F;MYANMAR LETTER GREAT SA;Lo;0;L;;;;;N;;;;;\n1040;MYANMAR DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1041;MYANMAR DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1042;MYANMAR DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1043;MYANMAR DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1044;MYANMAR DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1045;MYANMAR DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1046;MYANMAR DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1047;MYANMAR DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1048;MYANMAR DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1049;MYANMAR DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n104A;MYANMAR SIGN LITTLE SECTION;Po;0;L;;;;;N;;;;;\n104B;MYANMAR SIGN SECTION;Po;0;L;;;;;N;;;;;\n104C;MYANMAR SYMBOL LOCATIVE;Po;0;L;;;;;N;;;;;\n104D;MYANMAR SYMBOL COMPLETED;Po;0;L;;;;;N;;;;;\n104E;MYANMAR SYMBOL AFOREMENTIONED;Po;0;L;;;;;N;;;;;\n104F;MYANMAR SYMBOL GENITIVE;Po;0;L;;;;;N;;;;;\n1050;MYANMAR LETTER SHA;Lo;0;L;;;;;N;;;;;\n1051;MYANMAR LETTER SSA;Lo;0;L;;;;;N;;;;;\n1052;MYANMAR LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n1053;MYANMAR LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n1054;MYANMAR LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n1055;MYANMAR LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n1056;MYANMAR VOWEL SIGN VOCALIC R;Mc;0;L;;;;;N;;;;;\n1057;MYANMAR VOWEL SIGN VOCALIC RR;Mc;0;L;;;;;N;;;;;\n1058;MYANMAR VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n1059;MYANMAR VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n105A;MYANMAR LETTER MON NGA;Lo;0;L;;;;;N;;;;;\n105B;MYANMAR LETTER MON JHA;Lo;0;L;;;;;N;;;;;\n105C;MYANMAR LETTER MON BBA;Lo;0;L;;;;;N;;;;;\n105D;MYANMAR LETTER MON BBE;Lo;0;L;;;;;N;;;;;\n105E;MYANMAR CONSONANT SIGN MON MEDIAL NA;Mn;0;NSM;;;;;N;;;;;\n105F;MYANMAR CONSONANT SIGN MON MEDIAL MA;Mn;0;NSM;;;;;N;;;;;\n1060;MYANMAR CONSONANT SIGN MON MEDIAL LA;Mn;0;NSM;;;;;N;;;;;\n1061;MYANMAR LETTER SGAW KAREN SHA;Lo;0;L;;;;;N;;;;;\n1062;MYANMAR VOWEL SIGN SGAW KAREN EU;Mc;0;L;;;;;N;;;;;\n1063;MYANMAR TONE MARK SGAW KAREN HATHI;Mc;0;L;;;;;N;;;;;\n1064;MYANMAR TONE MARK SGAW KAREN KE PHO;Mc;0;L;;;;;N;;;;;\n1065;MYANMAR LETTER WESTERN PWO KAREN THA;Lo;0;L;;;;;N;;;;;\n1066;MYANMAR LETTER WESTERN PWO KAREN PWA;Lo;0;L;;;;;N;;;;;\n1067;MYANMAR VOWEL SIGN WESTERN PWO KAREN EU;Mc;0;L;;;;;N;;;;;\n1068;MYANMAR VOWEL SIGN WESTERN PWO KAREN UE;Mc;0;L;;;;;N;;;;;\n1069;MYANMAR SIGN WESTERN PWO KAREN TONE-1;Mc;0;L;;;;;N;;;;;\n106A;MYANMAR SIGN WESTERN PWO KAREN TONE-2;Mc;0;L;;;;;N;;;;;\n106B;MYANMAR SIGN WESTERN PWO KAREN TONE-3;Mc;0;L;;;;;N;;;;;\n106C;MYANMAR SIGN WESTERN PWO KAREN TONE-4;Mc;0;L;;;;;N;;;;;\n106D;MYANMAR SIGN WESTERN PWO KAREN TONE-5;Mc;0;L;;;;;N;;;;;\n106E;MYANMAR LETTER EASTERN PWO KAREN NNA;Lo;0;L;;;;;N;;;;;\n106F;MYANMAR LETTER EASTERN PWO KAREN YWA;Lo;0;L;;;;;N;;;;;\n1070;MYANMAR LETTER EASTERN PWO KAREN GHWA;Lo;0;L;;;;;N;;;;;\n1071;MYANMAR VOWEL SIGN GEBA KAREN I;Mn;0;NSM;;;;;N;;;;;\n1072;MYANMAR VOWEL SIGN KAYAH OE;Mn;0;NSM;;;;;N;;;;;\n1073;MYANMAR VOWEL SIGN KAYAH U;Mn;0;NSM;;;;;N;;;;;\n1074;MYANMAR VOWEL SIGN KAYAH EE;Mn;0;NSM;;;;;N;;;;;\n1075;MYANMAR LETTER SHAN KA;Lo;0;L;;;;;N;;;;;\n1076;MYANMAR LETTER SHAN KHA;Lo;0;L;;;;;N;;;;;\n1077;MYANMAR LETTER SHAN GA;Lo;0;L;;;;;N;;;;;\n1078;MYANMAR LETTER SHAN CA;Lo;0;L;;;;;N;;;;;\n1079;MYANMAR LETTER SHAN ZA;Lo;0;L;;;;;N;;;;;\n107A;MYANMAR LETTER SHAN NYA;Lo;0;L;;;;;N;;;;;\n107B;MYANMAR LETTER SHAN DA;Lo;0;L;;;;;N;;;;;\n107C;MYANMAR LETTER SHAN NA;Lo;0;L;;;;;N;;;;;\n107D;MYANMAR LETTER SHAN PHA;Lo;0;L;;;;;N;;;;;\n107E;MYANMAR LETTER SHAN FA;Lo;0;L;;;;;N;;;;;\n107F;MYANMAR LETTER SHAN BA;Lo;0;L;;;;;N;;;;;\n1080;MYANMAR LETTER SHAN THA;Lo;0;L;;;;;N;;;;;\n1081;MYANMAR LETTER SHAN HA;Lo;0;L;;;;;N;;;;;\n1082;MYANMAR CONSONANT SIGN SHAN MEDIAL WA;Mn;0;NSM;;;;;N;;;;;\n1083;MYANMAR VOWEL SIGN SHAN AA;Mc;0;L;;;;;N;;;;;\n1084;MYANMAR VOWEL SIGN SHAN E;Mc;0;L;;;;;N;;;;;\n1085;MYANMAR VOWEL SIGN SHAN E ABOVE;Mn;0;NSM;;;;;N;;;;;\n1086;MYANMAR VOWEL SIGN SHAN FINAL Y;Mn;0;NSM;;;;;N;;;;;\n1087;MYANMAR SIGN SHAN TONE-2;Mc;0;L;;;;;N;;;;;\n1088;MYANMAR SIGN SHAN TONE-3;Mc;0;L;;;;;N;;;;;\n1089;MYANMAR SIGN SHAN TONE-5;Mc;0;L;;;;;N;;;;;\n108A;MYANMAR SIGN SHAN TONE-6;Mc;0;L;;;;;N;;;;;\n108B;MYANMAR SIGN SHAN COUNCIL TONE-2;Mc;0;L;;;;;N;;;;;\n108C;MYANMAR SIGN SHAN COUNCIL TONE-3;Mc;0;L;;;;;N;;;;;\n108D;MYANMAR SIGN SHAN COUNCIL EMPHATIC TONE;Mn;220;NSM;;;;;N;;;;;\n108E;MYANMAR LETTER RUMAI PALAUNG FA;Lo;0;L;;;;;N;;;;;\n108F;MYANMAR SIGN RUMAI PALAUNG TONE-5;Mc;0;L;;;;;N;;;;;\n1090;MYANMAR SHAN DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1091;MYANMAR SHAN DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1092;MYANMAR SHAN DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1093;MYANMAR SHAN DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1094;MYANMAR SHAN DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1095;MYANMAR SHAN DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1096;MYANMAR SHAN DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1097;MYANMAR SHAN DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1098;MYANMAR SHAN DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1099;MYANMAR SHAN DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n109A;MYANMAR SIGN KHAMTI TONE-1;Mc;0;L;;;;;N;;;;;\n109B;MYANMAR SIGN KHAMTI TONE-3;Mc;0;L;;;;;N;;;;;\n109C;MYANMAR VOWEL SIGN AITON A;Mc;0;L;;;;;N;;;;;\n109D;MYANMAR VOWEL SIGN AITON AI;Mn;0;NSM;;;;;N;;;;;\n109E;MYANMAR SYMBOL SHAN ONE;So;0;L;;;;;N;;;;;\n109F;MYANMAR SYMBOL SHAN EXCLAMATION;So;0;L;;;;;N;;;;;\n10A0;GEORGIAN CAPITAL LETTER AN;Lu;0;L;;;;;N;;;;2D00;\n10A1;GEORGIAN CAPITAL LETTER BAN;Lu;0;L;;;;;N;;;;2D01;\n10A2;GEORGIAN CAPITAL LETTER GAN;Lu;0;L;;;;;N;;;;2D02;\n10A3;GEORGIAN CAPITAL LETTER DON;Lu;0;L;;;;;N;;;;2D03;\n10A4;GEORGIAN CAPITAL LETTER EN;Lu;0;L;;;;;N;;;;2D04;\n10A5;GEORGIAN CAPITAL LETTER VIN;Lu;0;L;;;;;N;;;;2D05;\n10A6;GEORGIAN CAPITAL LETTER ZEN;Lu;0;L;;;;;N;;;;2D06;\n10A7;GEORGIAN CAPITAL LETTER TAN;Lu;0;L;;;;;N;;;;2D07;\n10A8;GEORGIAN CAPITAL LETTER IN;Lu;0;L;;;;;N;;;;2D08;\n10A9;GEORGIAN CAPITAL LETTER KAN;Lu;0;L;;;;;N;;;;2D09;\n10AA;GEORGIAN CAPITAL LETTER LAS;Lu;0;L;;;;;N;;;;2D0A;\n10AB;GEORGIAN CAPITAL LETTER MAN;Lu;0;L;;;;;N;;;;2D0B;\n10AC;GEORGIAN CAPITAL LETTER NAR;Lu;0;L;;;;;N;;;;2D0C;\n10AD;GEORGIAN CAPITAL LETTER ON;Lu;0;L;;;;;N;;;;2D0D;\n10AE;GEORGIAN CAPITAL LETTER PAR;Lu;0;L;;;;;N;;;;2D0E;\n10AF;GEORGIAN CAPITAL LETTER ZHAR;Lu;0;L;;;;;N;;;;2D0F;\n10B0;GEORGIAN CAPITAL LETTER RAE;Lu;0;L;;;;;N;;;;2D10;\n10B1;GEORGIAN CAPITAL LETTER SAN;Lu;0;L;;;;;N;;;;2D11;\n10B2;GEORGIAN CAPITAL LETTER TAR;Lu;0;L;;;;;N;;;;2D12;\n10B3;GEORGIAN CAPITAL LETTER UN;Lu;0;L;;;;;N;;;;2D13;\n10B4;GEORGIAN CAPITAL LETTER PHAR;Lu;0;L;;;;;N;;;;2D14;\n10B5;GEORGIAN CAPITAL LETTER KHAR;Lu;0;L;;;;;N;;;;2D15;\n10B6;GEORGIAN CAPITAL LETTER GHAN;Lu;0;L;;;;;N;;;;2D16;\n10B7;GEORGIAN CAPITAL LETTER QAR;Lu;0;L;;;;;N;;;;2D17;\n10B8;GEORGIAN CAPITAL LETTER SHIN;Lu;0;L;;;;;N;;;;2D18;\n10B9;GEORGIAN CAPITAL LETTER CHIN;Lu;0;L;;;;;N;;;;2D19;\n10BA;GEORGIAN CAPITAL LETTER CAN;Lu;0;L;;;;;N;;;;2D1A;\n10BB;GEORGIAN CAPITAL LETTER JIL;Lu;0;L;;;;;N;;;;2D1B;\n10BC;GEORGIAN CAPITAL LETTER CIL;Lu;0;L;;;;;N;;;;2D1C;\n10BD;GEORGIAN CAPITAL LETTER CHAR;Lu;0;L;;;;;N;;;;2D1D;\n10BE;GEORGIAN CAPITAL LETTER XAN;Lu;0;L;;;;;N;;;;2D1E;\n10BF;GEORGIAN CAPITAL LETTER JHAN;Lu;0;L;;;;;N;;;;2D1F;\n10C0;GEORGIAN CAPITAL LETTER HAE;Lu;0;L;;;;;N;;;;2D20;\n10C1;GEORGIAN CAPITAL LETTER HE;Lu;0;L;;;;;N;;;;2D21;\n10C2;GEORGIAN CAPITAL LETTER HIE;Lu;0;L;;;;;N;;;;2D22;\n10C3;GEORGIAN CAPITAL LETTER WE;Lu;0;L;;;;;N;;;;2D23;\n10C4;GEORGIAN CAPITAL LETTER HAR;Lu;0;L;;;;;N;;;;2D24;\n10C5;GEORGIAN CAPITAL LETTER HOE;Lu;0;L;;;;;N;;;;2D25;\n10C7;GEORGIAN CAPITAL LETTER YN;Lu;0;L;;;;;N;;;;2D27;\n10CD;GEORGIAN CAPITAL LETTER AEN;Lu;0;L;;;;;N;;;;2D2D;\n10D0;GEORGIAN LETTER AN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER AN;;;;\n10D1;GEORGIAN LETTER BAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER BAN;;;;\n10D2;GEORGIAN LETTER GAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER GAN;;;;\n10D3;GEORGIAN LETTER DON;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER DON;;;;\n10D4;GEORGIAN LETTER EN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER EN;;;;\n10D5;GEORGIAN LETTER VIN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER VIN;;;;\n10D6;GEORGIAN LETTER ZEN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER ZEN;;;;\n10D7;GEORGIAN LETTER TAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER TAN;;;;\n10D8;GEORGIAN LETTER IN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER IN;;;;\n10D9;GEORGIAN LETTER KAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER KAN;;;;\n10DA;GEORGIAN LETTER LAS;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER LAS;;;;\n10DB;GEORGIAN LETTER MAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER MAN;;;;\n10DC;GEORGIAN LETTER NAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER NAR;;;;\n10DD;GEORGIAN LETTER ON;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER ON;;;;\n10DE;GEORGIAN LETTER PAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER PAR;;;;\n10DF;GEORGIAN LETTER ZHAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER ZHAR;;;;\n10E0;GEORGIAN LETTER RAE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER RAE;;;;\n10E1;GEORGIAN LETTER SAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER SAN;;;;\n10E2;GEORGIAN LETTER TAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER TAR;;;;\n10E3;GEORGIAN LETTER UN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER UN;;;;\n10E4;GEORGIAN LETTER PHAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER PHAR;;;;\n10E5;GEORGIAN LETTER KHAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER KHAR;;;;\n10E6;GEORGIAN LETTER GHAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER GHAN;;;;\n10E7;GEORGIAN LETTER QAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER QAR;;;;\n10E8;GEORGIAN LETTER SHIN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER SHIN;;;;\n10E9;GEORGIAN LETTER CHIN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER CHIN;;;;\n10EA;GEORGIAN LETTER CAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER CAN;;;;\n10EB;GEORGIAN LETTER JIL;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER JIL;;;;\n10EC;GEORGIAN LETTER CIL;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER CIL;;;;\n10ED;GEORGIAN LETTER CHAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER CHAR;;;;\n10EE;GEORGIAN LETTER XAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER XAN;;;;\n10EF;GEORGIAN LETTER JHAN;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER JHAN;;;;\n10F0;GEORGIAN LETTER HAE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER HAE;;;;\n10F1;GEORGIAN LETTER HE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER HE;;;;\n10F2;GEORGIAN LETTER HIE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER HIE;;;;\n10F3;GEORGIAN LETTER WE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER WE;;;;\n10F4;GEORGIAN LETTER HAR;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER HAR;;;;\n10F5;GEORGIAN LETTER HOE;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER HOE;;;;\n10F6;GEORGIAN LETTER FI;Lo;0;L;;;;;N;GEORGIAN SMALL LETTER FI;;;;\n10F7;GEORGIAN LETTER YN;Lo;0;L;;;;;N;;;;;\n10F8;GEORGIAN LETTER ELIFI;Lo;0;L;;;;;N;;;;;\n10F9;GEORGIAN LETTER TURNED GAN;Lo;0;L;;;;;N;;;;;\n10FA;GEORGIAN LETTER AIN;Lo;0;L;;;;;N;;;;;\n10FB;GEORGIAN PARAGRAPH SEPARATOR;Po;0;L;;;;;N;;;;;\n10FC;MODIFIER LETTER GEORGIAN NAR;Lm;0;L;<super> 10DC;;;;N;;;;;\n10FD;GEORGIAN LETTER AEN;Lo;0;L;;;;;N;;;;;\n10FE;GEORGIAN LETTER HARD SIGN;Lo;0;L;;;;;N;;;;;\n10FF;GEORGIAN LETTER LABIAL SIGN;Lo;0;L;;;;;N;;;;;\n1100;HANGUL CHOSEONG KIYEOK;Lo;0;L;;;;;N;;;;;\n1101;HANGUL CHOSEONG SSANGKIYEOK;Lo;0;L;;;;;N;;;;;\n1102;HANGUL CHOSEONG NIEUN;Lo;0;L;;;;;N;;;;;\n1103;HANGUL CHOSEONG TIKEUT;Lo;0;L;;;;;N;;;;;\n1104;HANGUL CHOSEONG SSANGTIKEUT;Lo;0;L;;;;;N;;;;;\n1105;HANGUL CHOSEONG RIEUL;Lo;0;L;;;;;N;;;;;\n1106;HANGUL CHOSEONG MIEUM;Lo;0;L;;;;;N;;;;;\n1107;HANGUL CHOSEONG PIEUP;Lo;0;L;;;;;N;;;;;\n1108;HANGUL CHOSEONG SSANGPIEUP;Lo;0;L;;;;;N;;;;;\n1109;HANGUL CHOSEONG SIOS;Lo;0;L;;;;;N;;;;;\n110A;HANGUL CHOSEONG SSANGSIOS;Lo;0;L;;;;;N;;;;;\n110B;HANGUL CHOSEONG IEUNG;Lo;0;L;;;;;N;;;;;\n110C;HANGUL CHOSEONG CIEUC;Lo;0;L;;;;;N;;;;;\n110D;HANGUL CHOSEONG SSANGCIEUC;Lo;0;L;;;;;N;;;;;\n110E;HANGUL CHOSEONG CHIEUCH;Lo;0;L;;;;;N;;;;;\n110F;HANGUL CHOSEONG KHIEUKH;Lo;0;L;;;;;N;;;;;\n1110;HANGUL CHOSEONG THIEUTH;Lo;0;L;;;;;N;;;;;\n1111;HANGUL CHOSEONG PHIEUPH;Lo;0;L;;;;;N;;;;;\n1112;HANGUL CHOSEONG HIEUH;Lo;0;L;;;;;N;;;;;\n1113;HANGUL CHOSEONG NIEUN-KIYEOK;Lo;0;L;;;;;N;;;;;\n1114;HANGUL CHOSEONG SSANGNIEUN;Lo;0;L;;;;;N;;;;;\n1115;HANGUL CHOSEONG NIEUN-TIKEUT;Lo;0;L;;;;;N;;;;;\n1116;HANGUL CHOSEONG NIEUN-PIEUP;Lo;0;L;;;;;N;;;;;\n1117;HANGUL CHOSEONG TIKEUT-KIYEOK;Lo;0;L;;;;;N;;;;;\n1118;HANGUL CHOSEONG RIEUL-NIEUN;Lo;0;L;;;;;N;;;;;\n1119;HANGUL CHOSEONG SSANGRIEUL;Lo;0;L;;;;;N;;;;;\n111A;HANGUL CHOSEONG RIEUL-HIEUH;Lo;0;L;;;;;N;;;;;\n111B;HANGUL CHOSEONG KAPYEOUNRIEUL;Lo;0;L;;;;;N;;;;;\n111C;HANGUL CHOSEONG MIEUM-PIEUP;Lo;0;L;;;;;N;;;;;\n111D;HANGUL CHOSEONG KAPYEOUNMIEUM;Lo;0;L;;;;;N;;;;;\n111E;HANGUL CHOSEONG PIEUP-KIYEOK;Lo;0;L;;;;;N;;;;;\n111F;HANGUL CHOSEONG PIEUP-NIEUN;Lo;0;L;;;;;N;;;;;\n1120;HANGUL CHOSEONG PIEUP-TIKEUT;Lo;0;L;;;;;N;;;;;\n1121;HANGUL CHOSEONG PIEUP-SIOS;Lo;0;L;;;;;N;;;;;\n1122;HANGUL CHOSEONG PIEUP-SIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\n1123;HANGUL CHOSEONG PIEUP-SIOS-TIKEUT;Lo;0;L;;;;;N;;;;;\n1124;HANGUL CHOSEONG PIEUP-SIOS-PIEUP;Lo;0;L;;;;;N;;;;;\n1125;HANGUL CHOSEONG PIEUP-SSANGSIOS;Lo;0;L;;;;;N;;;;;\n1126;HANGUL CHOSEONG PIEUP-SIOS-CIEUC;Lo;0;L;;;;;N;;;;;\n1127;HANGUL CHOSEONG PIEUP-CIEUC;Lo;0;L;;;;;N;;;;;\n1128;HANGUL CHOSEONG PIEUP-CHIEUCH;Lo;0;L;;;;;N;;;;;\n1129;HANGUL CHOSEONG PIEUP-THIEUTH;Lo;0;L;;;;;N;;;;;\n112A;HANGUL CHOSEONG PIEUP-PHIEUPH;Lo;0;L;;;;;N;;;;;\n112B;HANGUL CHOSEONG KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\n112C;HANGUL CHOSEONG KAPYEOUNSSANGPIEUP;Lo;0;L;;;;;N;;;;;\n112D;HANGUL CHOSEONG SIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\n112E;HANGUL CHOSEONG SIOS-NIEUN;Lo;0;L;;;;;N;;;;;\n112F;HANGUL CHOSEONG SIOS-TIKEUT;Lo;0;L;;;;;N;;;;;\n1130;HANGUL CHOSEONG SIOS-RIEUL;Lo;0;L;;;;;N;;;;;\n1131;HANGUL CHOSEONG SIOS-MIEUM;Lo;0;L;;;;;N;;;;;\n1132;HANGUL CHOSEONG SIOS-PIEUP;Lo;0;L;;;;;N;;;;;\n1133;HANGUL CHOSEONG SIOS-PIEUP-KIYEOK;Lo;0;L;;;;;N;;;;;\n1134;HANGUL CHOSEONG SIOS-SSANGSIOS;Lo;0;L;;;;;N;;;;;\n1135;HANGUL CHOSEONG SIOS-IEUNG;Lo;0;L;;;;;N;;;;;\n1136;HANGUL CHOSEONG SIOS-CIEUC;Lo;0;L;;;;;N;;;;;\n1137;HANGUL CHOSEONG SIOS-CHIEUCH;Lo;0;L;;;;;N;;;;;\n1138;HANGUL CHOSEONG SIOS-KHIEUKH;Lo;0;L;;;;;N;;;;;\n1139;HANGUL CHOSEONG SIOS-THIEUTH;Lo;0;L;;;;;N;;;;;\n113A;HANGUL CHOSEONG SIOS-PHIEUPH;Lo;0;L;;;;;N;;;;;\n113B;HANGUL CHOSEONG SIOS-HIEUH;Lo;0;L;;;;;N;;;;;\n113C;HANGUL CHOSEONG CHITUEUMSIOS;Lo;0;L;;;;;N;;;;;\n113D;HANGUL CHOSEONG CHITUEUMSSANGSIOS;Lo;0;L;;;;;N;;;;;\n113E;HANGUL CHOSEONG CEONGCHIEUMSIOS;Lo;0;L;;;;;N;;;;;\n113F;HANGUL CHOSEONG CEONGCHIEUMSSANGSIOS;Lo;0;L;;;;;N;;;;;\n1140;HANGUL CHOSEONG PANSIOS;Lo;0;L;;;;;N;;;;;\n1141;HANGUL CHOSEONG IEUNG-KIYEOK;Lo;0;L;;;;;N;;;;;\n1142;HANGUL CHOSEONG IEUNG-TIKEUT;Lo;0;L;;;;;N;;;;;\n1143;HANGUL CHOSEONG IEUNG-MIEUM;Lo;0;L;;;;;N;;;;;\n1144;HANGUL CHOSEONG IEUNG-PIEUP;Lo;0;L;;;;;N;;;;;\n1145;HANGUL CHOSEONG IEUNG-SIOS;Lo;0;L;;;;;N;;;;;\n1146;HANGUL CHOSEONG IEUNG-PANSIOS;Lo;0;L;;;;;N;;;;;\n1147;HANGUL CHOSEONG SSANGIEUNG;Lo;0;L;;;;;N;;;;;\n1148;HANGUL CHOSEONG IEUNG-CIEUC;Lo;0;L;;;;;N;;;;;\n1149;HANGUL CHOSEONG IEUNG-CHIEUCH;Lo;0;L;;;;;N;;;;;\n114A;HANGUL CHOSEONG IEUNG-THIEUTH;Lo;0;L;;;;;N;;;;;\n114B;HANGUL CHOSEONG IEUNG-PHIEUPH;Lo;0;L;;;;;N;;;;;\n114C;HANGUL CHOSEONG YESIEUNG;Lo;0;L;;;;;N;;;;;\n114D;HANGUL CHOSEONG CIEUC-IEUNG;Lo;0;L;;;;;N;;;;;\n114E;HANGUL CHOSEONG CHITUEUMCIEUC;Lo;0;L;;;;;N;;;;;\n114F;HANGUL CHOSEONG CHITUEUMSSANGCIEUC;Lo;0;L;;;;;N;;;;;\n1150;HANGUL CHOSEONG CEONGCHIEUMCIEUC;Lo;0;L;;;;;N;;;;;\n1151;HANGUL CHOSEONG CEONGCHIEUMSSANGCIEUC;Lo;0;L;;;;;N;;;;;\n1152;HANGUL CHOSEONG CHIEUCH-KHIEUKH;Lo;0;L;;;;;N;;;;;\n1153;HANGUL CHOSEONG CHIEUCH-HIEUH;Lo;0;L;;;;;N;;;;;\n1154;HANGUL CHOSEONG CHITUEUMCHIEUCH;Lo;0;L;;;;;N;;;;;\n1155;HANGUL CHOSEONG CEONGCHIEUMCHIEUCH;Lo;0;L;;;;;N;;;;;\n1156;HANGUL CHOSEONG PHIEUPH-PIEUP;Lo;0;L;;;;;N;;;;;\n1157;HANGUL CHOSEONG KAPYEOUNPHIEUPH;Lo;0;L;;;;;N;;;;;\n1158;HANGUL CHOSEONG SSANGHIEUH;Lo;0;L;;;;;N;;;;;\n1159;HANGUL CHOSEONG YEORINHIEUH;Lo;0;L;;;;;N;;;;;\n115A;HANGUL CHOSEONG KIYEOK-TIKEUT;Lo;0;L;;;;;N;;;;;\n115B;HANGUL CHOSEONG NIEUN-SIOS;Lo;0;L;;;;;N;;;;;\n115C;HANGUL CHOSEONG NIEUN-CIEUC;Lo;0;L;;;;;N;;;;;\n115D;HANGUL CHOSEONG NIEUN-HIEUH;Lo;0;L;;;;;N;;;;;\n115E;HANGUL CHOSEONG TIKEUT-RIEUL;Lo;0;L;;;;;N;;;;;\n115F;HANGUL CHOSEONG FILLER;Lo;0;L;;;;;N;;;;;\n1160;HANGUL JUNGSEONG FILLER;Lo;0;L;;;;;N;;;;;\n1161;HANGUL JUNGSEONG A;Lo;0;L;;;;;N;;;;;\n1162;HANGUL JUNGSEONG AE;Lo;0;L;;;;;N;;;;;\n1163;HANGUL JUNGSEONG YA;Lo;0;L;;;;;N;;;;;\n1164;HANGUL JUNGSEONG YAE;Lo;0;L;;;;;N;;;;;\n1165;HANGUL JUNGSEONG EO;Lo;0;L;;;;;N;;;;;\n1166;HANGUL JUNGSEONG E;Lo;0;L;;;;;N;;;;;\n1167;HANGUL JUNGSEONG YEO;Lo;0;L;;;;;N;;;;;\n1168;HANGUL JUNGSEONG YE;Lo;0;L;;;;;N;;;;;\n1169;HANGUL JUNGSEONG O;Lo;0;L;;;;;N;;;;;\n116A;HANGUL JUNGSEONG WA;Lo;0;L;;;;;N;;;;;\n116B;HANGUL JUNGSEONG WAE;Lo;0;L;;;;;N;;;;;\n116C;HANGUL JUNGSEONG OE;Lo;0;L;;;;;N;;;;;\n116D;HANGUL JUNGSEONG YO;Lo;0;L;;;;;N;;;;;\n116E;HANGUL JUNGSEONG U;Lo;0;L;;;;;N;;;;;\n116F;HANGUL JUNGSEONG WEO;Lo;0;L;;;;;N;;;;;\n1170;HANGUL JUNGSEONG WE;Lo;0;L;;;;;N;;;;;\n1171;HANGUL JUNGSEONG WI;Lo;0;L;;;;;N;;;;;\n1172;HANGUL JUNGSEONG YU;Lo;0;L;;;;;N;;;;;\n1173;HANGUL JUNGSEONG EU;Lo;0;L;;;;;N;;;;;\n1174;HANGUL JUNGSEONG YI;Lo;0;L;;;;;N;;;;;\n1175;HANGUL JUNGSEONG I;Lo;0;L;;;;;N;;;;;\n1176;HANGUL JUNGSEONG A-O;Lo;0;L;;;;;N;;;;;\n1177;HANGUL JUNGSEONG A-U;Lo;0;L;;;;;N;;;;;\n1178;HANGUL JUNGSEONG YA-O;Lo;0;L;;;;;N;;;;;\n1179;HANGUL JUNGSEONG YA-YO;Lo;0;L;;;;;N;;;;;\n117A;HANGUL JUNGSEONG EO-O;Lo;0;L;;;;;N;;;;;\n117B;HANGUL JUNGSEONG EO-U;Lo;0;L;;;;;N;;;;;\n117C;HANGUL JUNGSEONG EO-EU;Lo;0;L;;;;;N;;;;;\n117D;HANGUL JUNGSEONG YEO-O;Lo;0;L;;;;;N;;;;;\n117E;HANGUL JUNGSEONG YEO-U;Lo;0;L;;;;;N;;;;;\n117F;HANGUL JUNGSEONG O-EO;Lo;0;L;;;;;N;;;;;\n1180;HANGUL JUNGSEONG O-E;Lo;0;L;;;;;N;;;;;\n1181;HANGUL JUNGSEONG O-YE;Lo;0;L;;;;;N;;;;;\n1182;HANGUL JUNGSEONG O-O;Lo;0;L;;;;;N;;;;;\n1183;HANGUL JUNGSEONG O-U;Lo;0;L;;;;;N;;;;;\n1184;HANGUL JUNGSEONG YO-YA;Lo;0;L;;;;;N;;;;;\n1185;HANGUL JUNGSEONG YO-YAE;Lo;0;L;;;;;N;;;;;\n1186;HANGUL JUNGSEONG YO-YEO;Lo;0;L;;;;;N;;;;;\n1187;HANGUL JUNGSEONG YO-O;Lo;0;L;;;;;N;;;;;\n1188;HANGUL JUNGSEONG YO-I;Lo;0;L;;;;;N;;;;;\n1189;HANGUL JUNGSEONG U-A;Lo;0;L;;;;;N;;;;;\n118A;HANGUL JUNGSEONG U-AE;Lo;0;L;;;;;N;;;;;\n118B;HANGUL JUNGSEONG U-EO-EU;Lo;0;L;;;;;N;;;;;\n118C;HANGUL JUNGSEONG U-YE;Lo;0;L;;;;;N;;;;;\n118D;HANGUL JUNGSEONG U-U;Lo;0;L;;;;;N;;;;;\n118E;HANGUL JUNGSEONG YU-A;Lo;0;L;;;;;N;;;;;\n118F;HANGUL JUNGSEONG YU-EO;Lo;0;L;;;;;N;;;;;\n1190;HANGUL JUNGSEONG YU-E;Lo;0;L;;;;;N;;;;;\n1191;HANGUL JUNGSEONG YU-YEO;Lo;0;L;;;;;N;;;;;\n1192;HANGUL JUNGSEONG YU-YE;Lo;0;L;;;;;N;;;;;\n1193;HANGUL JUNGSEONG YU-U;Lo;0;L;;;;;N;;;;;\n1194;HANGUL JUNGSEONG YU-I;Lo;0;L;;;;;N;;;;;\n1195;HANGUL JUNGSEONG EU-U;Lo;0;L;;;;;N;;;;;\n1196;HANGUL JUNGSEONG EU-EU;Lo;0;L;;;;;N;;;;;\n1197;HANGUL JUNGSEONG YI-U;Lo;0;L;;;;;N;;;;;\n1198;HANGUL JUNGSEONG I-A;Lo;0;L;;;;;N;;;;;\n1199;HANGUL JUNGSEONG I-YA;Lo;0;L;;;;;N;;;;;\n119A;HANGUL JUNGSEONG I-O;Lo;0;L;;;;;N;;;;;\n119B;HANGUL JUNGSEONG I-U;Lo;0;L;;;;;N;;;;;\n119C;HANGUL JUNGSEONG I-EU;Lo;0;L;;;;;N;;;;;\n119D;HANGUL JUNGSEONG I-ARAEA;Lo;0;L;;;;;N;;;;;\n119E;HANGUL JUNGSEONG ARAEA;Lo;0;L;;;;;N;;;;;\n119F;HANGUL JUNGSEONG ARAEA-EO;Lo;0;L;;;;;N;;;;;\n11A0;HANGUL JUNGSEONG ARAEA-U;Lo;0;L;;;;;N;;;;;\n11A1;HANGUL JUNGSEONG ARAEA-I;Lo;0;L;;;;;N;;;;;\n11A2;HANGUL JUNGSEONG SSANGARAEA;Lo;0;L;;;;;N;;;;;\n11A3;HANGUL JUNGSEONG A-EU;Lo;0;L;;;;;N;;;;;\n11A4;HANGUL JUNGSEONG YA-U;Lo;0;L;;;;;N;;;;;\n11A5;HANGUL JUNGSEONG YEO-YA;Lo;0;L;;;;;N;;;;;\n11A6;HANGUL JUNGSEONG O-YA;Lo;0;L;;;;;N;;;;;\n11A7;HANGUL JUNGSEONG O-YAE;Lo;0;L;;;;;N;;;;;\n11A8;HANGUL JONGSEONG KIYEOK;Lo;0;L;;;;;N;;;;;\n11A9;HANGUL JONGSEONG SSANGKIYEOK;Lo;0;L;;;;;N;;;;;\n11AA;HANGUL JONGSEONG KIYEOK-SIOS;Lo;0;L;;;;;N;;;;;\n11AB;HANGUL JONGSEONG NIEUN;Lo;0;L;;;;;N;;;;;\n11AC;HANGUL JONGSEONG NIEUN-CIEUC;Lo;0;L;;;;;N;;;;;\n11AD;HANGUL JONGSEONG NIEUN-HIEUH;Lo;0;L;;;;;N;;;;;\n11AE;HANGUL JONGSEONG TIKEUT;Lo;0;L;;;;;N;;;;;\n11AF;HANGUL JONGSEONG RIEUL;Lo;0;L;;;;;N;;;;;\n11B0;HANGUL JONGSEONG RIEUL-KIYEOK;Lo;0;L;;;;;N;;;;;\n11B1;HANGUL JONGSEONG RIEUL-MIEUM;Lo;0;L;;;;;N;;;;;\n11B2;HANGUL JONGSEONG RIEUL-PIEUP;Lo;0;L;;;;;N;;;;;\n11B3;HANGUL JONGSEONG RIEUL-SIOS;Lo;0;L;;;;;N;;;;;\n11B4;HANGUL JONGSEONG RIEUL-THIEUTH;Lo;0;L;;;;;N;;;;;\n11B5;HANGUL JONGSEONG RIEUL-PHIEUPH;Lo;0;L;;;;;N;;;;;\n11B6;HANGUL JONGSEONG RIEUL-HIEUH;Lo;0;L;;;;;N;;;;;\n11B7;HANGUL JONGSEONG MIEUM;Lo;0;L;;;;;N;;;;;\n11B8;HANGUL JONGSEONG PIEUP;Lo;0;L;;;;;N;;;;;\n11B9;HANGUL JONGSEONG PIEUP-SIOS;Lo;0;L;;;;;N;;;;;\n11BA;HANGUL JONGSEONG SIOS;Lo;0;L;;;;;N;;;;;\n11BB;HANGUL JONGSEONG SSANGSIOS;Lo;0;L;;;;;N;;;;;\n11BC;HANGUL JONGSEONG IEUNG;Lo;0;L;;;;;N;;;;;\n11BD;HANGUL JONGSEONG CIEUC;Lo;0;L;;;;;N;;;;;\n11BE;HANGUL JONGSEONG CHIEUCH;Lo;0;L;;;;;N;;;;;\n11BF;HANGUL JONGSEONG KHIEUKH;Lo;0;L;;;;;N;;;;;\n11C0;HANGUL JONGSEONG THIEUTH;Lo;0;L;;;;;N;;;;;\n11C1;HANGUL JONGSEONG PHIEUPH;Lo;0;L;;;;;N;;;;;\n11C2;HANGUL JONGSEONG HIEUH;Lo;0;L;;;;;N;;;;;\n11C3;HANGUL JONGSEONG KIYEOK-RIEUL;Lo;0;L;;;;;N;;;;;\n11C4;HANGUL JONGSEONG KIYEOK-SIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\n11C5;HANGUL JONGSEONG NIEUN-KIYEOK;Lo;0;L;;;;;N;;;;;\n11C6;HANGUL JONGSEONG NIEUN-TIKEUT;Lo;0;L;;;;;N;;;;;\n11C7;HANGUL JONGSEONG NIEUN-SIOS;Lo;0;L;;;;;N;;;;;\n11C8;HANGUL JONGSEONG NIEUN-PANSIOS;Lo;0;L;;;;;N;;;;;\n11C9;HANGUL JONGSEONG NIEUN-THIEUTH;Lo;0;L;;;;;N;;;;;\n11CA;HANGUL JONGSEONG TIKEUT-KIYEOK;Lo;0;L;;;;;N;;;;;\n11CB;HANGUL JONGSEONG TIKEUT-RIEUL;Lo;0;L;;;;;N;;;;;\n11CC;HANGUL JONGSEONG RIEUL-KIYEOK-SIOS;Lo;0;L;;;;;N;;;;;\n11CD;HANGUL JONGSEONG RIEUL-NIEUN;Lo;0;L;;;;;N;;;;;\n11CE;HANGUL JONGSEONG RIEUL-TIKEUT;Lo;0;L;;;;;N;;;;;\n11CF;HANGUL JONGSEONG RIEUL-TIKEUT-HIEUH;Lo;0;L;;;;;N;;;;;\n11D0;HANGUL JONGSEONG SSANGRIEUL;Lo;0;L;;;;;N;;;;;\n11D1;HANGUL JONGSEONG RIEUL-MIEUM-KIYEOK;Lo;0;L;;;;;N;;;;;\n11D2;HANGUL JONGSEONG RIEUL-MIEUM-SIOS;Lo;0;L;;;;;N;;;;;\n11D3;HANGUL JONGSEONG RIEUL-PIEUP-SIOS;Lo;0;L;;;;;N;;;;;\n11D4;HANGUL JONGSEONG RIEUL-PIEUP-HIEUH;Lo;0;L;;;;;N;;;;;\n11D5;HANGUL JONGSEONG RIEUL-KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\n11D6;HANGUL JONGSEONG RIEUL-SSANGSIOS;Lo;0;L;;;;;N;;;;;\n11D7;HANGUL JONGSEONG RIEUL-PANSIOS;Lo;0;L;;;;;N;;;;;\n11D8;HANGUL JONGSEONG RIEUL-KHIEUKH;Lo;0;L;;;;;N;;;;;\n11D9;HANGUL JONGSEONG RIEUL-YEORINHIEUH;Lo;0;L;;;;;N;;;;;\n11DA;HANGUL JONGSEONG MIEUM-KIYEOK;Lo;0;L;;;;;N;;;;;\n11DB;HANGUL JONGSEONG MIEUM-RIEUL;Lo;0;L;;;;;N;;;;;\n11DC;HANGUL JONGSEONG MIEUM-PIEUP;Lo;0;L;;;;;N;;;;;\n11DD;HANGUL JONGSEONG MIEUM-SIOS;Lo;0;L;;;;;N;;;;;\n11DE;HANGUL JONGSEONG MIEUM-SSANGSIOS;Lo;0;L;;;;;N;;;;;\n11DF;HANGUL JONGSEONG MIEUM-PANSIOS;Lo;0;L;;;;;N;;;;;\n11E0;HANGUL JONGSEONG MIEUM-CHIEUCH;Lo;0;L;;;;;N;;;;;\n11E1;HANGUL JONGSEONG MIEUM-HIEUH;Lo;0;L;;;;;N;;;;;\n11E2;HANGUL JONGSEONG KAPYEOUNMIEUM;Lo;0;L;;;;;N;;;;;\n11E3;HANGUL JONGSEONG PIEUP-RIEUL;Lo;0;L;;;;;N;;;;;\n11E4;HANGUL JONGSEONG PIEUP-PHIEUPH;Lo;0;L;;;;;N;;;;;\n11E5;HANGUL JONGSEONG PIEUP-HIEUH;Lo;0;L;;;;;N;;;;;\n11E6;HANGUL JONGSEONG KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\n11E7;HANGUL JONGSEONG SIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\n11E8;HANGUL JONGSEONG SIOS-TIKEUT;Lo;0;L;;;;;N;;;;;\n11E9;HANGUL JONGSEONG SIOS-RIEUL;Lo;0;L;;;;;N;;;;;\n11EA;HANGUL JONGSEONG SIOS-PIEUP;Lo;0;L;;;;;N;;;;;\n11EB;HANGUL JONGSEONG PANSIOS;Lo;0;L;;;;;N;;;;;\n11EC;HANGUL JONGSEONG IEUNG-KIYEOK;Lo;0;L;;;;;N;;;;;\n11ED;HANGUL JONGSEONG IEUNG-SSANGKIYEOK;Lo;0;L;;;;;N;;;;;\n11EE;HANGUL JONGSEONG SSANGIEUNG;Lo;0;L;;;;;N;;;;;\n11EF;HANGUL JONGSEONG IEUNG-KHIEUKH;Lo;0;L;;;;;N;;;;;\n11F0;HANGUL JONGSEONG YESIEUNG;Lo;0;L;;;;;N;;;;;\n11F1;HANGUL JONGSEONG YESIEUNG-SIOS;Lo;0;L;;;;;N;;;;;\n11F2;HANGUL JONGSEONG YESIEUNG-PANSIOS;Lo;0;L;;;;;N;;;;;\n11F3;HANGUL JONGSEONG PHIEUPH-PIEUP;Lo;0;L;;;;;N;;;;;\n11F4;HANGUL JONGSEONG KAPYEOUNPHIEUPH;Lo;0;L;;;;;N;;;;;\n11F5;HANGUL JONGSEONG HIEUH-NIEUN;Lo;0;L;;;;;N;;;;;\n11F6;HANGUL JONGSEONG HIEUH-RIEUL;Lo;0;L;;;;;N;;;;;\n11F7;HANGUL JONGSEONG HIEUH-MIEUM;Lo;0;L;;;;;N;;;;;\n11F8;HANGUL JONGSEONG HIEUH-PIEUP;Lo;0;L;;;;;N;;;;;\n11F9;HANGUL JONGSEONG YEORINHIEUH;Lo;0;L;;;;;N;;;;;\n11FA;HANGUL JONGSEONG KIYEOK-NIEUN;Lo;0;L;;;;;N;;;;;\n11FB;HANGUL JONGSEONG KIYEOK-PIEUP;Lo;0;L;;;;;N;;;;;\n11FC;HANGUL JONGSEONG KIYEOK-CHIEUCH;Lo;0;L;;;;;N;;;;;\n11FD;HANGUL JONGSEONG KIYEOK-KHIEUKH;Lo;0;L;;;;;N;;;;;\n11FE;HANGUL JONGSEONG KIYEOK-HIEUH;Lo;0;L;;;;;N;;;;;\n11FF;HANGUL JONGSEONG SSANGNIEUN;Lo;0;L;;;;;N;;;;;\n1200;ETHIOPIC SYLLABLE HA;Lo;0;L;;;;;N;;;;;\n1201;ETHIOPIC SYLLABLE HU;Lo;0;L;;;;;N;;;;;\n1202;ETHIOPIC SYLLABLE HI;Lo;0;L;;;;;N;;;;;\n1203;ETHIOPIC SYLLABLE HAA;Lo;0;L;;;;;N;;;;;\n1204;ETHIOPIC SYLLABLE HEE;Lo;0;L;;;;;N;;;;;\n1205;ETHIOPIC SYLLABLE HE;Lo;0;L;;;;;N;;;;;\n1206;ETHIOPIC SYLLABLE HO;Lo;0;L;;;;;N;;;;;\n1207;ETHIOPIC SYLLABLE HOA;Lo;0;L;;;;;N;;;;;\n1208;ETHIOPIC SYLLABLE LA;Lo;0;L;;;;;N;;;;;\n1209;ETHIOPIC SYLLABLE LU;Lo;0;L;;;;;N;;;;;\n120A;ETHIOPIC SYLLABLE LI;Lo;0;L;;;;;N;;;;;\n120B;ETHIOPIC SYLLABLE LAA;Lo;0;L;;;;;N;;;;;\n120C;ETHIOPIC SYLLABLE LEE;Lo;0;L;;;;;N;;;;;\n120D;ETHIOPIC SYLLABLE LE;Lo;0;L;;;;;N;;;;;\n120E;ETHIOPIC SYLLABLE LO;Lo;0;L;;;;;N;;;;;\n120F;ETHIOPIC SYLLABLE LWA;Lo;0;L;;;;;N;;;;;\n1210;ETHIOPIC SYLLABLE HHA;Lo;0;L;;;;;N;;;;;\n1211;ETHIOPIC SYLLABLE HHU;Lo;0;L;;;;;N;;;;;\n1212;ETHIOPIC SYLLABLE HHI;Lo;0;L;;;;;N;;;;;\n1213;ETHIOPIC SYLLABLE HHAA;Lo;0;L;;;;;N;;;;;\n1214;ETHIOPIC SYLLABLE HHEE;Lo;0;L;;;;;N;;;;;\n1215;ETHIOPIC SYLLABLE HHE;Lo;0;L;;;;;N;;;;;\n1216;ETHIOPIC SYLLABLE HHO;Lo;0;L;;;;;N;;;;;\n1217;ETHIOPIC SYLLABLE HHWA;Lo;0;L;;;;;N;;;;;\n1218;ETHIOPIC SYLLABLE MA;Lo;0;L;;;;;N;;;;;\n1219;ETHIOPIC SYLLABLE MU;Lo;0;L;;;;;N;;;;;\n121A;ETHIOPIC SYLLABLE MI;Lo;0;L;;;;;N;;;;;\n121B;ETHIOPIC SYLLABLE MAA;Lo;0;L;;;;;N;;;;;\n121C;ETHIOPIC SYLLABLE MEE;Lo;0;L;;;;;N;;;;;\n121D;ETHIOPIC SYLLABLE ME;Lo;0;L;;;;;N;;;;;\n121E;ETHIOPIC SYLLABLE MO;Lo;0;L;;;;;N;;;;;\n121F;ETHIOPIC SYLLABLE MWA;Lo;0;L;;;;;N;;;;;\n1220;ETHIOPIC SYLLABLE SZA;Lo;0;L;;;;;N;;;;;\n1221;ETHIOPIC SYLLABLE SZU;Lo;0;L;;;;;N;;;;;\n1222;ETHIOPIC SYLLABLE SZI;Lo;0;L;;;;;N;;;;;\n1223;ETHIOPIC SYLLABLE SZAA;Lo;0;L;;;;;N;;;;;\n1224;ETHIOPIC SYLLABLE SZEE;Lo;0;L;;;;;N;;;;;\n1225;ETHIOPIC SYLLABLE SZE;Lo;0;L;;;;;N;;;;;\n1226;ETHIOPIC SYLLABLE SZO;Lo;0;L;;;;;N;;;;;\n1227;ETHIOPIC SYLLABLE SZWA;Lo;0;L;;;;;N;;;;;\n1228;ETHIOPIC SYLLABLE RA;Lo;0;L;;;;;N;;;;;\n1229;ETHIOPIC SYLLABLE RU;Lo;0;L;;;;;N;;;;;\n122A;ETHIOPIC SYLLABLE RI;Lo;0;L;;;;;N;;;;;\n122B;ETHIOPIC SYLLABLE RAA;Lo;0;L;;;;;N;;;;;\n122C;ETHIOPIC SYLLABLE REE;Lo;0;L;;;;;N;;;;;\n122D;ETHIOPIC SYLLABLE RE;Lo;0;L;;;;;N;;;;;\n122E;ETHIOPIC SYLLABLE RO;Lo;0;L;;;;;N;;;;;\n122F;ETHIOPIC SYLLABLE RWA;Lo;0;L;;;;;N;;;;;\n1230;ETHIOPIC SYLLABLE SA;Lo;0;L;;;;;N;;;;;\n1231;ETHIOPIC SYLLABLE SU;Lo;0;L;;;;;N;;;;;\n1232;ETHIOPIC SYLLABLE SI;Lo;0;L;;;;;N;;;;;\n1233;ETHIOPIC SYLLABLE SAA;Lo;0;L;;;;;N;;;;;\n1234;ETHIOPIC SYLLABLE SEE;Lo;0;L;;;;;N;;;;;\n1235;ETHIOPIC SYLLABLE SE;Lo;0;L;;;;;N;;;;;\n1236;ETHIOPIC SYLLABLE SO;Lo;0;L;;;;;N;;;;;\n1237;ETHIOPIC SYLLABLE SWA;Lo;0;L;;;;;N;;;;;\n1238;ETHIOPIC SYLLABLE SHA;Lo;0;L;;;;;N;;;;;\n1239;ETHIOPIC SYLLABLE SHU;Lo;0;L;;;;;N;;;;;\n123A;ETHIOPIC SYLLABLE SHI;Lo;0;L;;;;;N;;;;;\n123B;ETHIOPIC SYLLABLE SHAA;Lo;0;L;;;;;N;;;;;\n123C;ETHIOPIC SYLLABLE SHEE;Lo;0;L;;;;;N;;;;;\n123D;ETHIOPIC SYLLABLE SHE;Lo;0;L;;;;;N;;;;;\n123E;ETHIOPIC SYLLABLE SHO;Lo;0;L;;;;;N;;;;;\n123F;ETHIOPIC SYLLABLE SHWA;Lo;0;L;;;;;N;;;;;\n1240;ETHIOPIC SYLLABLE QA;Lo;0;L;;;;;N;;;;;\n1241;ETHIOPIC SYLLABLE QU;Lo;0;L;;;;;N;;;;;\n1242;ETHIOPIC SYLLABLE QI;Lo;0;L;;;;;N;;;;;\n1243;ETHIOPIC SYLLABLE QAA;Lo;0;L;;;;;N;;;;;\n1244;ETHIOPIC SYLLABLE QEE;Lo;0;L;;;;;N;;;;;\n1245;ETHIOPIC SYLLABLE QE;Lo;0;L;;;;;N;;;;;\n1246;ETHIOPIC SYLLABLE QO;Lo;0;L;;;;;N;;;;;\n1247;ETHIOPIC SYLLABLE QOA;Lo;0;L;;;;;N;;;;;\n1248;ETHIOPIC SYLLABLE QWA;Lo;0;L;;;;;N;;;;;\n124A;ETHIOPIC SYLLABLE QWI;Lo;0;L;;;;;N;;;;;\n124B;ETHIOPIC SYLLABLE QWAA;Lo;0;L;;;;;N;;;;;\n124C;ETHIOPIC SYLLABLE QWEE;Lo;0;L;;;;;N;;;;;\n124D;ETHIOPIC SYLLABLE QWE;Lo;0;L;;;;;N;;;;;\n1250;ETHIOPIC SYLLABLE QHA;Lo;0;L;;;;;N;;;;;\n1251;ETHIOPIC SYLLABLE QHU;Lo;0;L;;;;;N;;;;;\n1252;ETHIOPIC SYLLABLE QHI;Lo;0;L;;;;;N;;;;;\n1253;ETHIOPIC SYLLABLE QHAA;Lo;0;L;;;;;N;;;;;\n1254;ETHIOPIC SYLLABLE QHEE;Lo;0;L;;;;;N;;;;;\n1255;ETHIOPIC SYLLABLE QHE;Lo;0;L;;;;;N;;;;;\n1256;ETHIOPIC SYLLABLE QHO;Lo;0;L;;;;;N;;;;;\n1258;ETHIOPIC SYLLABLE QHWA;Lo;0;L;;;;;N;;;;;\n125A;ETHIOPIC SYLLABLE QHWI;Lo;0;L;;;;;N;;;;;\n125B;ETHIOPIC SYLLABLE QHWAA;Lo;0;L;;;;;N;;;;;\n125C;ETHIOPIC SYLLABLE QHWEE;Lo;0;L;;;;;N;;;;;\n125D;ETHIOPIC SYLLABLE QHWE;Lo;0;L;;;;;N;;;;;\n1260;ETHIOPIC SYLLABLE BA;Lo;0;L;;;;;N;;;;;\n1261;ETHIOPIC SYLLABLE BU;Lo;0;L;;;;;N;;;;;\n1262;ETHIOPIC SYLLABLE BI;Lo;0;L;;;;;N;;;;;\n1263;ETHIOPIC SYLLABLE BAA;Lo;0;L;;;;;N;;;;;\n1264;ETHIOPIC SYLLABLE BEE;Lo;0;L;;;;;N;;;;;\n1265;ETHIOPIC SYLLABLE BE;Lo;0;L;;;;;N;;;;;\n1266;ETHIOPIC SYLLABLE BO;Lo;0;L;;;;;N;;;;;\n1267;ETHIOPIC SYLLABLE BWA;Lo;0;L;;;;;N;;;;;\n1268;ETHIOPIC SYLLABLE VA;Lo;0;L;;;;;N;;;;;\n1269;ETHIOPIC SYLLABLE VU;Lo;0;L;;;;;N;;;;;\n126A;ETHIOPIC SYLLABLE VI;Lo;0;L;;;;;N;;;;;\n126B;ETHIOPIC SYLLABLE VAA;Lo;0;L;;;;;N;;;;;\n126C;ETHIOPIC SYLLABLE VEE;Lo;0;L;;;;;N;;;;;\n126D;ETHIOPIC SYLLABLE VE;Lo;0;L;;;;;N;;;;;\n126E;ETHIOPIC SYLLABLE VO;Lo;0;L;;;;;N;;;;;\n126F;ETHIOPIC SYLLABLE VWA;Lo;0;L;;;;;N;;;;;\n1270;ETHIOPIC SYLLABLE TA;Lo;0;L;;;;;N;;;;;\n1271;ETHIOPIC SYLLABLE TU;Lo;0;L;;;;;N;;;;;\n1272;ETHIOPIC SYLLABLE TI;Lo;0;L;;;;;N;;;;;\n1273;ETHIOPIC SYLLABLE TAA;Lo;0;L;;;;;N;;;;;\n1274;ETHIOPIC SYLLABLE TEE;Lo;0;L;;;;;N;;;;;\n1275;ETHIOPIC SYLLABLE TE;Lo;0;L;;;;;N;;;;;\n1276;ETHIOPIC SYLLABLE TO;Lo;0;L;;;;;N;;;;;\n1277;ETHIOPIC SYLLABLE TWA;Lo;0;L;;;;;N;;;;;\n1278;ETHIOPIC SYLLABLE CA;Lo;0;L;;;;;N;;;;;\n1279;ETHIOPIC SYLLABLE CU;Lo;0;L;;;;;N;;;;;\n127A;ETHIOPIC SYLLABLE CI;Lo;0;L;;;;;N;;;;;\n127B;ETHIOPIC SYLLABLE CAA;Lo;0;L;;;;;N;;;;;\n127C;ETHIOPIC SYLLABLE CEE;Lo;0;L;;;;;N;;;;;\n127D;ETHIOPIC SYLLABLE CE;Lo;0;L;;;;;N;;;;;\n127E;ETHIOPIC SYLLABLE CO;Lo;0;L;;;;;N;;;;;\n127F;ETHIOPIC SYLLABLE CWA;Lo;0;L;;;;;N;;;;;\n1280;ETHIOPIC SYLLABLE XA;Lo;0;L;;;;;N;;;;;\n1281;ETHIOPIC SYLLABLE XU;Lo;0;L;;;;;N;;;;;\n1282;ETHIOPIC SYLLABLE XI;Lo;0;L;;;;;N;;;;;\n1283;ETHIOPIC SYLLABLE XAA;Lo;0;L;;;;;N;;;;;\n1284;ETHIOPIC SYLLABLE XEE;Lo;0;L;;;;;N;;;;;\n1285;ETHIOPIC SYLLABLE XE;Lo;0;L;;;;;N;;;;;\n1286;ETHIOPIC SYLLABLE XO;Lo;0;L;;;;;N;;;;;\n1287;ETHIOPIC SYLLABLE XOA;Lo;0;L;;;;;N;;;;;\n1288;ETHIOPIC SYLLABLE XWA;Lo;0;L;;;;;N;;;;;\n128A;ETHIOPIC SYLLABLE XWI;Lo;0;L;;;;;N;;;;;\n128B;ETHIOPIC SYLLABLE XWAA;Lo;0;L;;;;;N;;;;;\n128C;ETHIOPIC SYLLABLE XWEE;Lo;0;L;;;;;N;;;;;\n128D;ETHIOPIC SYLLABLE XWE;Lo;0;L;;;;;N;;;;;\n1290;ETHIOPIC SYLLABLE NA;Lo;0;L;;;;;N;;;;;\n1291;ETHIOPIC SYLLABLE NU;Lo;0;L;;;;;N;;;;;\n1292;ETHIOPIC SYLLABLE NI;Lo;0;L;;;;;N;;;;;\n1293;ETHIOPIC SYLLABLE NAA;Lo;0;L;;;;;N;;;;;\n1294;ETHIOPIC SYLLABLE NEE;Lo;0;L;;;;;N;;;;;\n1295;ETHIOPIC SYLLABLE NE;Lo;0;L;;;;;N;;;;;\n1296;ETHIOPIC SYLLABLE NO;Lo;0;L;;;;;N;;;;;\n1297;ETHIOPIC SYLLABLE NWA;Lo;0;L;;;;;N;;;;;\n1298;ETHIOPIC SYLLABLE NYA;Lo;0;L;;;;;N;;;;;\n1299;ETHIOPIC SYLLABLE NYU;Lo;0;L;;;;;N;;;;;\n129A;ETHIOPIC SYLLABLE NYI;Lo;0;L;;;;;N;;;;;\n129B;ETHIOPIC SYLLABLE NYAA;Lo;0;L;;;;;N;;;;;\n129C;ETHIOPIC SYLLABLE NYEE;Lo;0;L;;;;;N;;;;;\n129D;ETHIOPIC SYLLABLE NYE;Lo;0;L;;;;;N;;;;;\n129E;ETHIOPIC SYLLABLE NYO;Lo;0;L;;;;;N;;;;;\n129F;ETHIOPIC SYLLABLE NYWA;Lo;0;L;;;;;N;;;;;\n12A0;ETHIOPIC SYLLABLE GLOTTAL A;Lo;0;L;;;;;N;;;;;\n12A1;ETHIOPIC SYLLABLE GLOTTAL U;Lo;0;L;;;;;N;;;;;\n12A2;ETHIOPIC SYLLABLE GLOTTAL I;Lo;0;L;;;;;N;;;;;\n12A3;ETHIOPIC SYLLABLE GLOTTAL AA;Lo;0;L;;;;;N;;;;;\n12A4;ETHIOPIC SYLLABLE GLOTTAL EE;Lo;0;L;;;;;N;;;;;\n12A5;ETHIOPIC SYLLABLE GLOTTAL E;Lo;0;L;;;;;N;;;;;\n12A6;ETHIOPIC SYLLABLE GLOTTAL O;Lo;0;L;;;;;N;;;;;\n12A7;ETHIOPIC SYLLABLE GLOTTAL WA;Lo;0;L;;;;;N;;;;;\n12A8;ETHIOPIC SYLLABLE KA;Lo;0;L;;;;;N;;;;;\n12A9;ETHIOPIC SYLLABLE KU;Lo;0;L;;;;;N;;;;;\n12AA;ETHIOPIC SYLLABLE KI;Lo;0;L;;;;;N;;;;;\n12AB;ETHIOPIC SYLLABLE KAA;Lo;0;L;;;;;N;;;;;\n12AC;ETHIOPIC SYLLABLE KEE;Lo;0;L;;;;;N;;;;;\n12AD;ETHIOPIC SYLLABLE KE;Lo;0;L;;;;;N;;;;;\n12AE;ETHIOPIC SYLLABLE KO;Lo;0;L;;;;;N;;;;;\n12AF;ETHIOPIC SYLLABLE KOA;Lo;0;L;;;;;N;;;;;\n12B0;ETHIOPIC SYLLABLE KWA;Lo;0;L;;;;;N;;;;;\n12B2;ETHIOPIC SYLLABLE KWI;Lo;0;L;;;;;N;;;;;\n12B3;ETHIOPIC SYLLABLE KWAA;Lo;0;L;;;;;N;;;;;\n12B4;ETHIOPIC SYLLABLE KWEE;Lo;0;L;;;;;N;;;;;\n12B5;ETHIOPIC SYLLABLE KWE;Lo;0;L;;;;;N;;;;;\n12B8;ETHIOPIC SYLLABLE KXA;Lo;0;L;;;;;N;;;;;\n12B9;ETHIOPIC SYLLABLE KXU;Lo;0;L;;;;;N;;;;;\n12BA;ETHIOPIC SYLLABLE KXI;Lo;0;L;;;;;N;;;;;\n12BB;ETHIOPIC SYLLABLE KXAA;Lo;0;L;;;;;N;;;;;\n12BC;ETHIOPIC SYLLABLE KXEE;Lo;0;L;;;;;N;;;;;\n12BD;ETHIOPIC SYLLABLE KXE;Lo;0;L;;;;;N;;;;;\n12BE;ETHIOPIC SYLLABLE KXO;Lo;0;L;;;;;N;;;;;\n12C0;ETHIOPIC SYLLABLE KXWA;Lo;0;L;;;;;N;;;;;\n12C2;ETHIOPIC SYLLABLE KXWI;Lo;0;L;;;;;N;;;;;\n12C3;ETHIOPIC SYLLABLE KXWAA;Lo;0;L;;;;;N;;;;;\n12C4;ETHIOPIC SYLLABLE KXWEE;Lo;0;L;;;;;N;;;;;\n12C5;ETHIOPIC SYLLABLE KXWE;Lo;0;L;;;;;N;;;;;\n12C8;ETHIOPIC SYLLABLE WA;Lo;0;L;;;;;N;;;;;\n12C9;ETHIOPIC SYLLABLE WU;Lo;0;L;;;;;N;;;;;\n12CA;ETHIOPIC SYLLABLE WI;Lo;0;L;;;;;N;;;;;\n12CB;ETHIOPIC SYLLABLE WAA;Lo;0;L;;;;;N;;;;;\n12CC;ETHIOPIC SYLLABLE WEE;Lo;0;L;;;;;N;;;;;\n12CD;ETHIOPIC SYLLABLE WE;Lo;0;L;;;;;N;;;;;\n12CE;ETHIOPIC SYLLABLE WO;Lo;0;L;;;;;N;;;;;\n12CF;ETHIOPIC SYLLABLE WOA;Lo;0;L;;;;;N;;;;;\n12D0;ETHIOPIC SYLLABLE PHARYNGEAL A;Lo;0;L;;;;;N;;;;;\n12D1;ETHIOPIC SYLLABLE PHARYNGEAL U;Lo;0;L;;;;;N;;;;;\n12D2;ETHIOPIC SYLLABLE PHARYNGEAL I;Lo;0;L;;;;;N;;;;;\n12D3;ETHIOPIC SYLLABLE PHARYNGEAL AA;Lo;0;L;;;;;N;;;;;\n12D4;ETHIOPIC SYLLABLE PHARYNGEAL EE;Lo;0;L;;;;;N;;;;;\n12D5;ETHIOPIC SYLLABLE PHARYNGEAL E;Lo;0;L;;;;;N;;;;;\n12D6;ETHIOPIC SYLLABLE PHARYNGEAL O;Lo;0;L;;;;;N;;;;;\n12D8;ETHIOPIC SYLLABLE ZA;Lo;0;L;;;;;N;;;;;\n12D9;ETHIOPIC SYLLABLE ZU;Lo;0;L;;;;;N;;;;;\n12DA;ETHIOPIC SYLLABLE ZI;Lo;0;L;;;;;N;;;;;\n12DB;ETHIOPIC SYLLABLE ZAA;Lo;0;L;;;;;N;;;;;\n12DC;ETHIOPIC SYLLABLE ZEE;Lo;0;L;;;;;N;;;;;\n12DD;ETHIOPIC SYLLABLE ZE;Lo;0;L;;;;;N;;;;;\n12DE;ETHIOPIC SYLLABLE ZO;Lo;0;L;;;;;N;;;;;\n12DF;ETHIOPIC SYLLABLE ZWA;Lo;0;L;;;;;N;;;;;\n12E0;ETHIOPIC SYLLABLE ZHA;Lo;0;L;;;;;N;;;;;\n12E1;ETHIOPIC SYLLABLE ZHU;Lo;0;L;;;;;N;;;;;\n12E2;ETHIOPIC SYLLABLE ZHI;Lo;0;L;;;;;N;;;;;\n12E3;ETHIOPIC SYLLABLE ZHAA;Lo;0;L;;;;;N;;;;;\n12E4;ETHIOPIC SYLLABLE ZHEE;Lo;0;L;;;;;N;;;;;\n12E5;ETHIOPIC SYLLABLE ZHE;Lo;0;L;;;;;N;;;;;\n12E6;ETHIOPIC SYLLABLE ZHO;Lo;0;L;;;;;N;;;;;\n12E7;ETHIOPIC SYLLABLE ZHWA;Lo;0;L;;;;;N;;;;;\n12E8;ETHIOPIC SYLLABLE YA;Lo;0;L;;;;;N;;;;;\n12E9;ETHIOPIC SYLLABLE YU;Lo;0;L;;;;;N;;;;;\n12EA;ETHIOPIC SYLLABLE YI;Lo;0;L;;;;;N;;;;;\n12EB;ETHIOPIC SYLLABLE YAA;Lo;0;L;;;;;N;;;;;\n12EC;ETHIOPIC SYLLABLE YEE;Lo;0;L;;;;;N;;;;;\n12ED;ETHIOPIC SYLLABLE YE;Lo;0;L;;;;;N;;;;;\n12EE;ETHIOPIC SYLLABLE YO;Lo;0;L;;;;;N;;;;;\n12EF;ETHIOPIC SYLLABLE YOA;Lo;0;L;;;;;N;;;;;\n12F0;ETHIOPIC SYLLABLE DA;Lo;0;L;;;;;N;;;;;\n12F1;ETHIOPIC SYLLABLE DU;Lo;0;L;;;;;N;;;;;\n12F2;ETHIOPIC SYLLABLE DI;Lo;0;L;;;;;N;;;;;\n12F3;ETHIOPIC SYLLABLE DAA;Lo;0;L;;;;;N;;;;;\n12F4;ETHIOPIC SYLLABLE DEE;Lo;0;L;;;;;N;;;;;\n12F5;ETHIOPIC SYLLABLE DE;Lo;0;L;;;;;N;;;;;\n12F6;ETHIOPIC SYLLABLE DO;Lo;0;L;;;;;N;;;;;\n12F7;ETHIOPIC SYLLABLE DWA;Lo;0;L;;;;;N;;;;;\n12F8;ETHIOPIC SYLLABLE DDA;Lo;0;L;;;;;N;;;;;\n12F9;ETHIOPIC SYLLABLE DDU;Lo;0;L;;;;;N;;;;;\n12FA;ETHIOPIC SYLLABLE DDI;Lo;0;L;;;;;N;;;;;\n12FB;ETHIOPIC SYLLABLE DDAA;Lo;0;L;;;;;N;;;;;\n12FC;ETHIOPIC SYLLABLE DDEE;Lo;0;L;;;;;N;;;;;\n12FD;ETHIOPIC SYLLABLE DDE;Lo;0;L;;;;;N;;;;;\n12FE;ETHIOPIC SYLLABLE DDO;Lo;0;L;;;;;N;;;;;\n12FF;ETHIOPIC SYLLABLE DDWA;Lo;0;L;;;;;N;;;;;\n1300;ETHIOPIC SYLLABLE JA;Lo;0;L;;;;;N;;;;;\n1301;ETHIOPIC SYLLABLE JU;Lo;0;L;;;;;N;;;;;\n1302;ETHIOPIC SYLLABLE JI;Lo;0;L;;;;;N;;;;;\n1303;ETHIOPIC SYLLABLE JAA;Lo;0;L;;;;;N;;;;;\n1304;ETHIOPIC SYLLABLE JEE;Lo;0;L;;;;;N;;;;;\n1305;ETHIOPIC SYLLABLE JE;Lo;0;L;;;;;N;;;;;\n1306;ETHIOPIC SYLLABLE JO;Lo;0;L;;;;;N;;;;;\n1307;ETHIOPIC SYLLABLE JWA;Lo;0;L;;;;;N;;;;;\n1308;ETHIOPIC SYLLABLE GA;Lo;0;L;;;;;N;;;;;\n1309;ETHIOPIC SYLLABLE GU;Lo;0;L;;;;;N;;;;;\n130A;ETHIOPIC SYLLABLE GI;Lo;0;L;;;;;N;;;;;\n130B;ETHIOPIC SYLLABLE GAA;Lo;0;L;;;;;N;;;;;\n130C;ETHIOPIC SYLLABLE GEE;Lo;0;L;;;;;N;;;;;\n130D;ETHIOPIC SYLLABLE GE;Lo;0;L;;;;;N;;;;;\n130E;ETHIOPIC SYLLABLE GO;Lo;0;L;;;;;N;;;;;\n130F;ETHIOPIC SYLLABLE GOA;Lo;0;L;;;;;N;;;;;\n1310;ETHIOPIC SYLLABLE GWA;Lo;0;L;;;;;N;;;;;\n1312;ETHIOPIC SYLLABLE GWI;Lo;0;L;;;;;N;;;;;\n1313;ETHIOPIC SYLLABLE GWAA;Lo;0;L;;;;;N;;;;;\n1314;ETHIOPIC SYLLABLE GWEE;Lo;0;L;;;;;N;;;;;\n1315;ETHIOPIC SYLLABLE GWE;Lo;0;L;;;;;N;;;;;\n1318;ETHIOPIC SYLLABLE GGA;Lo;0;L;;;;;N;;;;;\n1319;ETHIOPIC SYLLABLE GGU;Lo;0;L;;;;;N;;;;;\n131A;ETHIOPIC SYLLABLE GGI;Lo;0;L;;;;;N;;;;;\n131B;ETHIOPIC SYLLABLE GGAA;Lo;0;L;;;;;N;;;;;\n131C;ETHIOPIC SYLLABLE GGEE;Lo;0;L;;;;;N;;;;;\n131D;ETHIOPIC SYLLABLE GGE;Lo;0;L;;;;;N;;;;;\n131E;ETHIOPIC SYLLABLE GGO;Lo;0;L;;;;;N;;;;;\n131F;ETHIOPIC SYLLABLE GGWAA;Lo;0;L;;;;;N;;;;;\n1320;ETHIOPIC SYLLABLE THA;Lo;0;L;;;;;N;;;;;\n1321;ETHIOPIC SYLLABLE THU;Lo;0;L;;;;;N;;;;;\n1322;ETHIOPIC SYLLABLE THI;Lo;0;L;;;;;N;;;;;\n1323;ETHIOPIC SYLLABLE THAA;Lo;0;L;;;;;N;;;;;\n1324;ETHIOPIC SYLLABLE THEE;Lo;0;L;;;;;N;;;;;\n1325;ETHIOPIC SYLLABLE THE;Lo;0;L;;;;;N;;;;;\n1326;ETHIOPIC SYLLABLE THO;Lo;0;L;;;;;N;;;;;\n1327;ETHIOPIC SYLLABLE THWA;Lo;0;L;;;;;N;;;;;\n1328;ETHIOPIC SYLLABLE CHA;Lo;0;L;;;;;N;;;;;\n1329;ETHIOPIC SYLLABLE CHU;Lo;0;L;;;;;N;;;;;\n132A;ETHIOPIC SYLLABLE CHI;Lo;0;L;;;;;N;;;;;\n132B;ETHIOPIC SYLLABLE CHAA;Lo;0;L;;;;;N;;;;;\n132C;ETHIOPIC SYLLABLE CHEE;Lo;0;L;;;;;N;;;;;\n132D;ETHIOPIC SYLLABLE CHE;Lo;0;L;;;;;N;;;;;\n132E;ETHIOPIC SYLLABLE CHO;Lo;0;L;;;;;N;;;;;\n132F;ETHIOPIC SYLLABLE CHWA;Lo;0;L;;;;;N;;;;;\n1330;ETHIOPIC SYLLABLE PHA;Lo;0;L;;;;;N;;;;;\n1331;ETHIOPIC SYLLABLE PHU;Lo;0;L;;;;;N;;;;;\n1332;ETHIOPIC SYLLABLE PHI;Lo;0;L;;;;;N;;;;;\n1333;ETHIOPIC SYLLABLE PHAA;Lo;0;L;;;;;N;;;;;\n1334;ETHIOPIC SYLLABLE PHEE;Lo;0;L;;;;;N;;;;;\n1335;ETHIOPIC SYLLABLE PHE;Lo;0;L;;;;;N;;;;;\n1336;ETHIOPIC SYLLABLE PHO;Lo;0;L;;;;;N;;;;;\n1337;ETHIOPIC SYLLABLE PHWA;Lo;0;L;;;;;N;;;;;\n1338;ETHIOPIC SYLLABLE TSA;Lo;0;L;;;;;N;;;;;\n1339;ETHIOPIC SYLLABLE TSU;Lo;0;L;;;;;N;;;;;\n133A;ETHIOPIC SYLLABLE TSI;Lo;0;L;;;;;N;;;;;\n133B;ETHIOPIC SYLLABLE TSAA;Lo;0;L;;;;;N;;;;;\n133C;ETHIOPIC SYLLABLE TSEE;Lo;0;L;;;;;N;;;;;\n133D;ETHIOPIC SYLLABLE TSE;Lo;0;L;;;;;N;;;;;\n133E;ETHIOPIC SYLLABLE TSO;Lo;0;L;;;;;N;;;;;\n133F;ETHIOPIC SYLLABLE TSWA;Lo;0;L;;;;;N;;;;;\n1340;ETHIOPIC SYLLABLE TZA;Lo;0;L;;;;;N;;;;;\n1341;ETHIOPIC SYLLABLE TZU;Lo;0;L;;;;;N;;;;;\n1342;ETHIOPIC SYLLABLE TZI;Lo;0;L;;;;;N;;;;;\n1343;ETHIOPIC SYLLABLE TZAA;Lo;0;L;;;;;N;;;;;\n1344;ETHIOPIC SYLLABLE TZEE;Lo;0;L;;;;;N;;;;;\n1345;ETHIOPIC SYLLABLE TZE;Lo;0;L;;;;;N;;;;;\n1346;ETHIOPIC SYLLABLE TZO;Lo;0;L;;;;;N;;;;;\n1347;ETHIOPIC SYLLABLE TZOA;Lo;0;L;;;;;N;;;;;\n1348;ETHIOPIC SYLLABLE FA;Lo;0;L;;;;;N;;;;;\n1349;ETHIOPIC SYLLABLE FU;Lo;0;L;;;;;N;;;;;\n134A;ETHIOPIC SYLLABLE FI;Lo;0;L;;;;;N;;;;;\n134B;ETHIOPIC SYLLABLE FAA;Lo;0;L;;;;;N;;;;;\n134C;ETHIOPIC SYLLABLE FEE;Lo;0;L;;;;;N;;;;;\n134D;ETHIOPIC SYLLABLE FE;Lo;0;L;;;;;N;;;;;\n134E;ETHIOPIC SYLLABLE FO;Lo;0;L;;;;;N;;;;;\n134F;ETHIOPIC SYLLABLE FWA;Lo;0;L;;;;;N;;;;;\n1350;ETHIOPIC SYLLABLE PA;Lo;0;L;;;;;N;;;;;\n1351;ETHIOPIC SYLLABLE PU;Lo;0;L;;;;;N;;;;;\n1352;ETHIOPIC SYLLABLE PI;Lo;0;L;;;;;N;;;;;\n1353;ETHIOPIC SYLLABLE PAA;Lo;0;L;;;;;N;;;;;\n1354;ETHIOPIC SYLLABLE PEE;Lo;0;L;;;;;N;;;;;\n1355;ETHIOPIC SYLLABLE PE;Lo;0;L;;;;;N;;;;;\n1356;ETHIOPIC SYLLABLE PO;Lo;0;L;;;;;N;;;;;\n1357;ETHIOPIC SYLLABLE PWA;Lo;0;L;;;;;N;;;;;\n1358;ETHIOPIC SYLLABLE RYA;Lo;0;L;;;;;N;;;;;\n1359;ETHIOPIC SYLLABLE MYA;Lo;0;L;;;;;N;;;;;\n135A;ETHIOPIC SYLLABLE FYA;Lo;0;L;;;;;N;;;;;\n135D;ETHIOPIC COMBINING GEMINATION AND VOWEL LENGTH MARK;Mn;230;NSM;;;;;N;;;;;\n135E;ETHIOPIC COMBINING VOWEL LENGTH MARK;Mn;230;NSM;;;;;N;;;;;\n135F;ETHIOPIC COMBINING GEMINATION MARK;Mn;230;NSM;;;;;N;;;;;\n1360;ETHIOPIC SECTION MARK;Po;0;L;;;;;N;;;;;\n1361;ETHIOPIC WORDSPACE;Po;0;L;;;;;N;;;;;\n1362;ETHIOPIC FULL STOP;Po;0;L;;;;;N;;;;;\n1363;ETHIOPIC COMMA;Po;0;L;;;;;N;;;;;\n1364;ETHIOPIC SEMICOLON;Po;0;L;;;;;N;;;;;\n1365;ETHIOPIC COLON;Po;0;L;;;;;N;;;;;\n1366;ETHIOPIC PREFACE COLON;Po;0;L;;;;;N;;;;;\n1367;ETHIOPIC QUESTION MARK;Po;0;L;;;;;N;;;;;\n1368;ETHIOPIC PARAGRAPH SEPARATOR;Po;0;L;;;;;N;;;;;\n1369;ETHIOPIC DIGIT ONE;No;0;L;;;1;1;N;;;;;\n136A;ETHIOPIC DIGIT TWO;No;0;L;;;2;2;N;;;;;\n136B;ETHIOPIC DIGIT THREE;No;0;L;;;3;3;N;;;;;\n136C;ETHIOPIC DIGIT FOUR;No;0;L;;;4;4;N;;;;;\n136D;ETHIOPIC DIGIT FIVE;No;0;L;;;5;5;N;;;;;\n136E;ETHIOPIC DIGIT SIX;No;0;L;;;6;6;N;;;;;\n136F;ETHIOPIC DIGIT SEVEN;No;0;L;;;7;7;N;;;;;\n1370;ETHIOPIC DIGIT EIGHT;No;0;L;;;8;8;N;;;;;\n1371;ETHIOPIC DIGIT NINE;No;0;L;;;9;9;N;;;;;\n1372;ETHIOPIC NUMBER TEN;No;0;L;;;;10;N;;;;;\n1373;ETHIOPIC NUMBER TWENTY;No;0;L;;;;20;N;;;;;\n1374;ETHIOPIC NUMBER THIRTY;No;0;L;;;;30;N;;;;;\n1375;ETHIOPIC NUMBER FORTY;No;0;L;;;;40;N;;;;;\n1376;ETHIOPIC NUMBER FIFTY;No;0;L;;;;50;N;;;;;\n1377;ETHIOPIC NUMBER SIXTY;No;0;L;;;;60;N;;;;;\n1378;ETHIOPIC NUMBER SEVENTY;No;0;L;;;;70;N;;;;;\n1379;ETHIOPIC NUMBER EIGHTY;No;0;L;;;;80;N;;;;;\n137A;ETHIOPIC NUMBER NINETY;No;0;L;;;;90;N;;;;;\n137B;ETHIOPIC NUMBER HUNDRED;No;0;L;;;;100;N;;;;;\n137C;ETHIOPIC NUMBER TEN THOUSAND;No;0;L;;;;10000;N;;;;;\n1380;ETHIOPIC SYLLABLE SEBATBEIT MWA;Lo;0;L;;;;;N;;;;;\n1381;ETHIOPIC SYLLABLE MWI;Lo;0;L;;;;;N;;;;;\n1382;ETHIOPIC SYLLABLE MWEE;Lo;0;L;;;;;N;;;;;\n1383;ETHIOPIC SYLLABLE MWE;Lo;0;L;;;;;N;;;;;\n1384;ETHIOPIC SYLLABLE SEBATBEIT BWA;Lo;0;L;;;;;N;;;;;\n1385;ETHIOPIC SYLLABLE BWI;Lo;0;L;;;;;N;;;;;\n1386;ETHIOPIC SYLLABLE BWEE;Lo;0;L;;;;;N;;;;;\n1387;ETHIOPIC SYLLABLE BWE;Lo;0;L;;;;;N;;;;;\n1388;ETHIOPIC SYLLABLE SEBATBEIT FWA;Lo;0;L;;;;;N;;;;;\n1389;ETHIOPIC SYLLABLE FWI;Lo;0;L;;;;;N;;;;;\n138A;ETHIOPIC SYLLABLE FWEE;Lo;0;L;;;;;N;;;;;\n138B;ETHIOPIC SYLLABLE FWE;Lo;0;L;;;;;N;;;;;\n138C;ETHIOPIC SYLLABLE SEBATBEIT PWA;Lo;0;L;;;;;N;;;;;\n138D;ETHIOPIC SYLLABLE PWI;Lo;0;L;;;;;N;;;;;\n138E;ETHIOPIC SYLLABLE PWEE;Lo;0;L;;;;;N;;;;;\n138F;ETHIOPIC SYLLABLE PWE;Lo;0;L;;;;;N;;;;;\n1390;ETHIOPIC TONAL MARK YIZET;So;0;ON;;;;;N;;;;;\n1391;ETHIOPIC TONAL MARK DERET;So;0;ON;;;;;N;;;;;\n1392;ETHIOPIC TONAL MARK RIKRIK;So;0;ON;;;;;N;;;;;\n1393;ETHIOPIC TONAL MARK SHORT RIKRIK;So;0;ON;;;;;N;;;;;\n1394;ETHIOPIC TONAL MARK DIFAT;So;0;ON;;;;;N;;;;;\n1395;ETHIOPIC TONAL MARK KENAT;So;0;ON;;;;;N;;;;;\n1396;ETHIOPIC TONAL MARK CHIRET;So;0;ON;;;;;N;;;;;\n1397;ETHIOPIC TONAL MARK HIDET;So;0;ON;;;;;N;;;;;\n1398;ETHIOPIC TONAL MARK DERET-HIDET;So;0;ON;;;;;N;;;;;\n1399;ETHIOPIC TONAL MARK KURT;So;0;ON;;;;;N;;;;;\n13A0;CHEROKEE LETTER A;Lo;0;L;;;;;N;;;;;\n13A1;CHEROKEE LETTER E;Lo;0;L;;;;;N;;;;;\n13A2;CHEROKEE LETTER I;Lo;0;L;;;;;N;;;;;\n13A3;CHEROKEE LETTER O;Lo;0;L;;;;;N;;;;;\n13A4;CHEROKEE LETTER U;Lo;0;L;;;;;N;;;;;\n13A5;CHEROKEE LETTER V;Lo;0;L;;;;;N;;;;;\n13A6;CHEROKEE LETTER GA;Lo;0;L;;;;;N;;;;;\n13A7;CHEROKEE LETTER KA;Lo;0;L;;;;;N;;;;;\n13A8;CHEROKEE LETTER GE;Lo;0;L;;;;;N;;;;;\n13A9;CHEROKEE LETTER GI;Lo;0;L;;;;;N;;;;;\n13AA;CHEROKEE LETTER GO;Lo;0;L;;;;;N;;;;;\n13AB;CHEROKEE LETTER GU;Lo;0;L;;;;;N;;;;;\n13AC;CHEROKEE LETTER GV;Lo;0;L;;;;;N;;;;;\n13AD;CHEROKEE LETTER HA;Lo;0;L;;;;;N;;;;;\n13AE;CHEROKEE LETTER HE;Lo;0;L;;;;;N;;;;;\n13AF;CHEROKEE LETTER HI;Lo;0;L;;;;;N;;;;;\n13B0;CHEROKEE LETTER HO;Lo;0;L;;;;;N;;;;;\n13B1;CHEROKEE LETTER HU;Lo;0;L;;;;;N;;;;;\n13B2;CHEROKEE LETTER HV;Lo;0;L;;;;;N;;;;;\n13B3;CHEROKEE LETTER LA;Lo;0;L;;;;;N;;;;;\n13B4;CHEROKEE LETTER LE;Lo;0;L;;;;;N;;;;;\n13B5;CHEROKEE LETTER LI;Lo;0;L;;;;;N;;;;;\n13B6;CHEROKEE LETTER LO;Lo;0;L;;;;;N;;;;;\n13B7;CHEROKEE LETTER LU;Lo;0;L;;;;;N;;;;;\n13B8;CHEROKEE LETTER LV;Lo;0;L;;;;;N;;;;;\n13B9;CHEROKEE LETTER MA;Lo;0;L;;;;;N;;;;;\n13BA;CHEROKEE LETTER ME;Lo;0;L;;;;;N;;;;;\n13BB;CHEROKEE LETTER MI;Lo;0;L;;;;;N;;;;;\n13BC;CHEROKEE LETTER MO;Lo;0;L;;;;;N;;;;;\n13BD;CHEROKEE LETTER MU;Lo;0;L;;;;;N;;;;;\n13BE;CHEROKEE LETTER NA;Lo;0;L;;;;;N;;;;;\n13BF;CHEROKEE LETTER HNA;Lo;0;L;;;;;N;;;;;\n13C0;CHEROKEE LETTER NAH;Lo;0;L;;;;;N;;;;;\n13C1;CHEROKEE LETTER NE;Lo;0;L;;;;;N;;;;;\n13C2;CHEROKEE LETTER NI;Lo;0;L;;;;;N;;;;;\n13C3;CHEROKEE LETTER NO;Lo;0;L;;;;;N;;;;;\n13C4;CHEROKEE LETTER NU;Lo;0;L;;;;;N;;;;;\n13C5;CHEROKEE LETTER NV;Lo;0;L;;;;;N;;;;;\n13C6;CHEROKEE LETTER QUA;Lo;0;L;;;;;N;;;;;\n13C7;CHEROKEE LETTER QUE;Lo;0;L;;;;;N;;;;;\n13C8;CHEROKEE LETTER QUI;Lo;0;L;;;;;N;;;;;\n13C9;CHEROKEE LETTER QUO;Lo;0;L;;;;;N;;;;;\n13CA;CHEROKEE LETTER QUU;Lo;0;L;;;;;N;;;;;\n13CB;CHEROKEE LETTER QUV;Lo;0;L;;;;;N;;;;;\n13CC;CHEROKEE LETTER SA;Lo;0;L;;;;;N;;;;;\n13CD;CHEROKEE LETTER S;Lo;0;L;;;;;N;;;;;\n13CE;CHEROKEE LETTER SE;Lo;0;L;;;;;N;;;;;\n13CF;CHEROKEE LETTER SI;Lo;0;L;;;;;N;;;;;\n13D0;CHEROKEE LETTER SO;Lo;0;L;;;;;N;;;;;\n13D1;CHEROKEE LETTER SU;Lo;0;L;;;;;N;;;;;\n13D2;CHEROKEE LETTER SV;Lo;0;L;;;;;N;;;;;\n13D3;CHEROKEE LETTER DA;Lo;0;L;;;;;N;;;;;\n13D4;CHEROKEE LETTER TA;Lo;0;L;;;;;N;;;;;\n13D5;CHEROKEE LETTER DE;Lo;0;L;;;;;N;;;;;\n13D6;CHEROKEE LETTER TE;Lo;0;L;;;;;N;;;;;\n13D7;CHEROKEE LETTER DI;Lo;0;L;;;;;N;;;;;\n13D8;CHEROKEE LETTER TI;Lo;0;L;;;;;N;;;;;\n13D9;CHEROKEE LETTER DO;Lo;0;L;;;;;N;;;;;\n13DA;CHEROKEE LETTER DU;Lo;0;L;;;;;N;;;;;\n13DB;CHEROKEE LETTER DV;Lo;0;L;;;;;N;;;;;\n13DC;CHEROKEE LETTER DLA;Lo;0;L;;;;;N;;;;;\n13DD;CHEROKEE LETTER TLA;Lo;0;L;;;;;N;;;;;\n13DE;CHEROKEE LETTER TLE;Lo;0;L;;;;;N;;;;;\n13DF;CHEROKEE LETTER TLI;Lo;0;L;;;;;N;;;;;\n13E0;CHEROKEE LETTER TLO;Lo;0;L;;;;;N;;;;;\n13E1;CHEROKEE LETTER TLU;Lo;0;L;;;;;N;;;;;\n13E2;CHEROKEE LETTER TLV;Lo;0;L;;;;;N;;;;;\n13E3;CHEROKEE LETTER TSA;Lo;0;L;;;;;N;;;;;\n13E4;CHEROKEE LETTER TSE;Lo;0;L;;;;;N;;;;;\n13E5;CHEROKEE LETTER TSI;Lo;0;L;;;;;N;;;;;\n13E6;CHEROKEE LETTER TSO;Lo;0;L;;;;;N;;;;;\n13E7;CHEROKEE LETTER TSU;Lo;0;L;;;;;N;;;;;\n13E8;CHEROKEE LETTER TSV;Lo;0;L;;;;;N;;;;;\n13E9;CHEROKEE LETTER WA;Lo;0;L;;;;;N;;;;;\n13EA;CHEROKEE LETTER WE;Lo;0;L;;;;;N;;;;;\n13EB;CHEROKEE LETTER WI;Lo;0;L;;;;;N;;;;;\n13EC;CHEROKEE LETTER WO;Lo;0;L;;;;;N;;;;;\n13ED;CHEROKEE LETTER WU;Lo;0;L;;;;;N;;;;;\n13EE;CHEROKEE LETTER WV;Lo;0;L;;;;;N;;;;;\n13EF;CHEROKEE LETTER YA;Lo;0;L;;;;;N;;;;;\n13F0;CHEROKEE LETTER YE;Lo;0;L;;;;;N;;;;;\n13F1;CHEROKEE LETTER YI;Lo;0;L;;;;;N;;;;;\n13F2;CHEROKEE LETTER YO;Lo;0;L;;;;;N;;;;;\n13F3;CHEROKEE LETTER YU;Lo;0;L;;;;;N;;;;;\n13F4;CHEROKEE LETTER YV;Lo;0;L;;;;;N;;;;;\n1400;CANADIAN SYLLABICS HYPHEN;Pd;0;ON;;;;;N;;;;;\n1401;CANADIAN SYLLABICS E;Lo;0;L;;;;;N;;;;;\n1402;CANADIAN SYLLABICS AAI;Lo;0;L;;;;;N;;;;;\n1403;CANADIAN SYLLABICS I;Lo;0;L;;;;;N;;;;;\n1404;CANADIAN SYLLABICS II;Lo;0;L;;;;;N;;;;;\n1405;CANADIAN SYLLABICS O;Lo;0;L;;;;;N;;;;;\n1406;CANADIAN SYLLABICS OO;Lo;0;L;;;;;N;;;;;\n1407;CANADIAN SYLLABICS Y-CREE OO;Lo;0;L;;;;;N;;;;;\n1408;CANADIAN SYLLABICS CARRIER EE;Lo;0;L;;;;;N;;;;;\n1409;CANADIAN SYLLABICS CARRIER I;Lo;0;L;;;;;N;;;;;\n140A;CANADIAN SYLLABICS A;Lo;0;L;;;;;N;;;;;\n140B;CANADIAN SYLLABICS AA;Lo;0;L;;;;;N;;;;;\n140C;CANADIAN SYLLABICS WE;Lo;0;L;;;;;N;;;;;\n140D;CANADIAN SYLLABICS WEST-CREE WE;Lo;0;L;;;;;N;;;;;\n140E;CANADIAN SYLLABICS WI;Lo;0;L;;;;;N;;;;;\n140F;CANADIAN SYLLABICS WEST-CREE WI;Lo;0;L;;;;;N;;;;;\n1410;CANADIAN SYLLABICS WII;Lo;0;L;;;;;N;;;;;\n1411;CANADIAN SYLLABICS WEST-CREE WII;Lo;0;L;;;;;N;;;;;\n1412;CANADIAN SYLLABICS WO;Lo;0;L;;;;;N;;;;;\n1413;CANADIAN SYLLABICS WEST-CREE WO;Lo;0;L;;;;;N;;;;;\n1414;CANADIAN SYLLABICS WOO;Lo;0;L;;;;;N;;;;;\n1415;CANADIAN SYLLABICS WEST-CREE WOO;Lo;0;L;;;;;N;;;;;\n1416;CANADIAN SYLLABICS NASKAPI WOO;Lo;0;L;;;;;N;;;;;\n1417;CANADIAN SYLLABICS WA;Lo;0;L;;;;;N;;;;;\n1418;CANADIAN SYLLABICS WEST-CREE WA;Lo;0;L;;;;;N;;;;;\n1419;CANADIAN SYLLABICS WAA;Lo;0;L;;;;;N;;;;;\n141A;CANADIAN SYLLABICS WEST-CREE WAA;Lo;0;L;;;;;N;;;;;\n141B;CANADIAN SYLLABICS NASKAPI WAA;Lo;0;L;;;;;N;;;;;\n141C;CANADIAN SYLLABICS AI;Lo;0;L;;;;;N;;;;;\n141D;CANADIAN SYLLABICS Y-CREE W;Lo;0;L;;;;;N;;;;;\n141E;CANADIAN SYLLABICS GLOTTAL STOP;Lo;0;L;;;;;N;;;;;\n141F;CANADIAN SYLLABICS FINAL ACUTE;Lo;0;L;;;;;N;;;;;\n1420;CANADIAN SYLLABICS FINAL GRAVE;Lo;0;L;;;;;N;;;;;\n1421;CANADIAN SYLLABICS FINAL BOTTOM HALF RING;Lo;0;L;;;;;N;;;;;\n1422;CANADIAN SYLLABICS FINAL TOP HALF RING;Lo;0;L;;;;;N;;;;;\n1423;CANADIAN SYLLABICS FINAL RIGHT HALF RING;Lo;0;L;;;;;N;;;;;\n1424;CANADIAN SYLLABICS FINAL RING;Lo;0;L;;;;;N;;;;;\n1425;CANADIAN SYLLABICS FINAL DOUBLE ACUTE;Lo;0;L;;;;;N;;;;;\n1426;CANADIAN SYLLABICS FINAL DOUBLE SHORT VERTICAL STROKES;Lo;0;L;;;;;N;;;;;\n1427;CANADIAN SYLLABICS FINAL MIDDLE DOT;Lo;0;L;;;;;N;;;;;\n1428;CANADIAN SYLLABICS FINAL SHORT HORIZONTAL STROKE;Lo;0;L;;;;;N;;;;;\n1429;CANADIAN SYLLABICS FINAL PLUS;Lo;0;L;;;;;N;;;;;\n142A;CANADIAN SYLLABICS FINAL DOWN TACK;Lo;0;L;;;;;N;;;;;\n142B;CANADIAN SYLLABICS EN;Lo;0;L;;;;;N;;;;;\n142C;CANADIAN SYLLABICS IN;Lo;0;L;;;;;N;;;;;\n142D;CANADIAN SYLLABICS ON;Lo;0;L;;;;;N;;;;;\n142E;CANADIAN SYLLABICS AN;Lo;0;L;;;;;N;;;;;\n142F;CANADIAN SYLLABICS PE;Lo;0;L;;;;;N;;;;;\n1430;CANADIAN SYLLABICS PAAI;Lo;0;L;;;;;N;;;;;\n1431;CANADIAN SYLLABICS PI;Lo;0;L;;;;;N;;;;;\n1432;CANADIAN SYLLABICS PII;Lo;0;L;;;;;N;;;;;\n1433;CANADIAN SYLLABICS PO;Lo;0;L;;;;;N;;;;;\n1434;CANADIAN SYLLABICS POO;Lo;0;L;;;;;N;;;;;\n1435;CANADIAN SYLLABICS Y-CREE POO;Lo;0;L;;;;;N;;;;;\n1436;CANADIAN SYLLABICS CARRIER HEE;Lo;0;L;;;;;N;;;;;\n1437;CANADIAN SYLLABICS CARRIER HI;Lo;0;L;;;;;N;;;;;\n1438;CANADIAN SYLLABICS PA;Lo;0;L;;;;;N;;;;;\n1439;CANADIAN SYLLABICS PAA;Lo;0;L;;;;;N;;;;;\n143A;CANADIAN SYLLABICS PWE;Lo;0;L;;;;;N;;;;;\n143B;CANADIAN SYLLABICS WEST-CREE PWE;Lo;0;L;;;;;N;;;;;\n143C;CANADIAN SYLLABICS PWI;Lo;0;L;;;;;N;;;;;\n143D;CANADIAN SYLLABICS WEST-CREE PWI;Lo;0;L;;;;;N;;;;;\n143E;CANADIAN SYLLABICS PWII;Lo;0;L;;;;;N;;;;;\n143F;CANADIAN SYLLABICS WEST-CREE PWII;Lo;0;L;;;;;N;;;;;\n1440;CANADIAN SYLLABICS PWO;Lo;0;L;;;;;N;;;;;\n1441;CANADIAN SYLLABICS WEST-CREE PWO;Lo;0;L;;;;;N;;;;;\n1442;CANADIAN SYLLABICS PWOO;Lo;0;L;;;;;N;;;;;\n1443;CANADIAN SYLLABICS WEST-CREE PWOO;Lo;0;L;;;;;N;;;;;\n1444;CANADIAN SYLLABICS PWA;Lo;0;L;;;;;N;;;;;\n1445;CANADIAN SYLLABICS WEST-CREE PWA;Lo;0;L;;;;;N;;;;;\n1446;CANADIAN SYLLABICS PWAA;Lo;0;L;;;;;N;;;;;\n1447;CANADIAN SYLLABICS WEST-CREE PWAA;Lo;0;L;;;;;N;;;;;\n1448;CANADIAN SYLLABICS Y-CREE PWAA;Lo;0;L;;;;;N;;;;;\n1449;CANADIAN SYLLABICS P;Lo;0;L;;;;;N;;;;;\n144A;CANADIAN SYLLABICS WEST-CREE P;Lo;0;L;;;;;N;;;;;\n144B;CANADIAN SYLLABICS CARRIER H;Lo;0;L;;;;;N;;;;;\n144C;CANADIAN SYLLABICS TE;Lo;0;L;;;;;N;;;;;\n144D;CANADIAN SYLLABICS TAAI;Lo;0;L;;;;;N;;;;;\n144E;CANADIAN SYLLABICS TI;Lo;0;L;;;;;N;;;;;\n144F;CANADIAN SYLLABICS TII;Lo;0;L;;;;;N;;;;;\n1450;CANADIAN SYLLABICS TO;Lo;0;L;;;;;N;;;;;\n1451;CANADIAN SYLLABICS TOO;Lo;0;L;;;;;N;;;;;\n1452;CANADIAN SYLLABICS Y-CREE TOO;Lo;0;L;;;;;N;;;;;\n1453;CANADIAN SYLLABICS CARRIER DEE;Lo;0;L;;;;;N;;;;;\n1454;CANADIAN SYLLABICS CARRIER DI;Lo;0;L;;;;;N;;;;;\n1455;CANADIAN SYLLABICS TA;Lo;0;L;;;;;N;;;;;\n1456;CANADIAN SYLLABICS TAA;Lo;0;L;;;;;N;;;;;\n1457;CANADIAN SYLLABICS TWE;Lo;0;L;;;;;N;;;;;\n1458;CANADIAN SYLLABICS WEST-CREE TWE;Lo;0;L;;;;;N;;;;;\n1459;CANADIAN SYLLABICS TWI;Lo;0;L;;;;;N;;;;;\n145A;CANADIAN SYLLABICS WEST-CREE TWI;Lo;0;L;;;;;N;;;;;\n145B;CANADIAN SYLLABICS TWII;Lo;0;L;;;;;N;;;;;\n145C;CANADIAN SYLLABICS WEST-CREE TWII;Lo;0;L;;;;;N;;;;;\n145D;CANADIAN SYLLABICS TWO;Lo;0;L;;;;;N;;;;;\n145E;CANADIAN SYLLABICS WEST-CREE TWO;Lo;0;L;;;;;N;;;;;\n145F;CANADIAN SYLLABICS TWOO;Lo;0;L;;;;;N;;;;;\n1460;CANADIAN SYLLABICS WEST-CREE TWOO;Lo;0;L;;;;;N;;;;;\n1461;CANADIAN SYLLABICS TWA;Lo;0;L;;;;;N;;;;;\n1462;CANADIAN SYLLABICS WEST-CREE TWA;Lo;0;L;;;;;N;;;;;\n1463;CANADIAN SYLLABICS TWAA;Lo;0;L;;;;;N;;;;;\n1464;CANADIAN SYLLABICS WEST-CREE TWAA;Lo;0;L;;;;;N;;;;;\n1465;CANADIAN SYLLABICS NASKAPI TWAA;Lo;0;L;;;;;N;;;;;\n1466;CANADIAN SYLLABICS T;Lo;0;L;;;;;N;;;;;\n1467;CANADIAN SYLLABICS TTE;Lo;0;L;;;;;N;;;;;\n1468;CANADIAN SYLLABICS TTI;Lo;0;L;;;;;N;;;;;\n1469;CANADIAN SYLLABICS TTO;Lo;0;L;;;;;N;;;;;\n146A;CANADIAN SYLLABICS TTA;Lo;0;L;;;;;N;;;;;\n146B;CANADIAN SYLLABICS KE;Lo;0;L;;;;;N;;;;;\n146C;CANADIAN SYLLABICS KAAI;Lo;0;L;;;;;N;;;;;\n146D;CANADIAN SYLLABICS KI;Lo;0;L;;;;;N;;;;;\n146E;CANADIAN SYLLABICS KII;Lo;0;L;;;;;N;;;;;\n146F;CANADIAN SYLLABICS KO;Lo;0;L;;;;;N;;;;;\n1470;CANADIAN SYLLABICS KOO;Lo;0;L;;;;;N;;;;;\n1471;CANADIAN SYLLABICS Y-CREE KOO;Lo;0;L;;;;;N;;;;;\n1472;CANADIAN SYLLABICS KA;Lo;0;L;;;;;N;;;;;\n1473;CANADIAN SYLLABICS KAA;Lo;0;L;;;;;N;;;;;\n1474;CANADIAN SYLLABICS KWE;Lo;0;L;;;;;N;;;;;\n1475;CANADIAN SYLLABICS WEST-CREE KWE;Lo;0;L;;;;;N;;;;;\n1476;CANADIAN SYLLABICS KWI;Lo;0;L;;;;;N;;;;;\n1477;CANADIAN SYLLABICS WEST-CREE KWI;Lo;0;L;;;;;N;;;;;\n1478;CANADIAN SYLLABICS KWII;Lo;0;L;;;;;N;;;;;\n1479;CANADIAN SYLLABICS WEST-CREE KWII;Lo;0;L;;;;;N;;;;;\n147A;CANADIAN SYLLABICS KWO;Lo;0;L;;;;;N;;;;;\n147B;CANADIAN SYLLABICS WEST-CREE KWO;Lo;0;L;;;;;N;;;;;\n147C;CANADIAN SYLLABICS KWOO;Lo;0;L;;;;;N;;;;;\n147D;CANADIAN SYLLABICS WEST-CREE KWOO;Lo;0;L;;;;;N;;;;;\n147E;CANADIAN SYLLABICS KWA;Lo;0;L;;;;;N;;;;;\n147F;CANADIAN SYLLABICS WEST-CREE KWA;Lo;0;L;;;;;N;;;;;\n1480;CANADIAN SYLLABICS KWAA;Lo;0;L;;;;;N;;;;;\n1481;CANADIAN SYLLABICS WEST-CREE KWAA;Lo;0;L;;;;;N;;;;;\n1482;CANADIAN SYLLABICS NASKAPI KWAA;Lo;0;L;;;;;N;;;;;\n1483;CANADIAN SYLLABICS K;Lo;0;L;;;;;N;;;;;\n1484;CANADIAN SYLLABICS KW;Lo;0;L;;;;;N;;;;;\n1485;CANADIAN SYLLABICS SOUTH-SLAVEY KEH;Lo;0;L;;;;;N;;;;;\n1486;CANADIAN SYLLABICS SOUTH-SLAVEY KIH;Lo;0;L;;;;;N;;;;;\n1487;CANADIAN SYLLABICS SOUTH-SLAVEY KOH;Lo;0;L;;;;;N;;;;;\n1488;CANADIAN SYLLABICS SOUTH-SLAVEY KAH;Lo;0;L;;;;;N;;;;;\n1489;CANADIAN SYLLABICS CE;Lo;0;L;;;;;N;;;;;\n148A;CANADIAN SYLLABICS CAAI;Lo;0;L;;;;;N;;;;;\n148B;CANADIAN SYLLABICS CI;Lo;0;L;;;;;N;;;;;\n148C;CANADIAN SYLLABICS CII;Lo;0;L;;;;;N;;;;;\n148D;CANADIAN SYLLABICS CO;Lo;0;L;;;;;N;;;;;\n148E;CANADIAN SYLLABICS COO;Lo;0;L;;;;;N;;;;;\n148F;CANADIAN SYLLABICS Y-CREE COO;Lo;0;L;;;;;N;;;;;\n1490;CANADIAN SYLLABICS CA;Lo;0;L;;;;;N;;;;;\n1491;CANADIAN SYLLABICS CAA;Lo;0;L;;;;;N;;;;;\n1492;CANADIAN SYLLABICS CWE;Lo;0;L;;;;;N;;;;;\n1493;CANADIAN SYLLABICS WEST-CREE CWE;Lo;0;L;;;;;N;;;;;\n1494;CANADIAN SYLLABICS CWI;Lo;0;L;;;;;N;;;;;\n1495;CANADIAN SYLLABICS WEST-CREE CWI;Lo;0;L;;;;;N;;;;;\n1496;CANADIAN SYLLABICS CWII;Lo;0;L;;;;;N;;;;;\n1497;CANADIAN SYLLABICS WEST-CREE CWII;Lo;0;L;;;;;N;;;;;\n1498;CANADIAN SYLLABICS CWO;Lo;0;L;;;;;N;;;;;\n1499;CANADIAN SYLLABICS WEST-CREE CWO;Lo;0;L;;;;;N;;;;;\n149A;CANADIAN SYLLABICS CWOO;Lo;0;L;;;;;N;;;;;\n149B;CANADIAN SYLLABICS WEST-CREE CWOO;Lo;0;L;;;;;N;;;;;\n149C;CANADIAN SYLLABICS CWA;Lo;0;L;;;;;N;;;;;\n149D;CANADIAN SYLLABICS WEST-CREE CWA;Lo;0;L;;;;;N;;;;;\n149E;CANADIAN SYLLABICS CWAA;Lo;0;L;;;;;N;;;;;\n149F;CANADIAN SYLLABICS WEST-CREE CWAA;Lo;0;L;;;;;N;;;;;\n14A0;CANADIAN SYLLABICS NASKAPI CWAA;Lo;0;L;;;;;N;;;;;\n14A1;CANADIAN SYLLABICS C;Lo;0;L;;;;;N;;;;;\n14A2;CANADIAN SYLLABICS SAYISI TH;Lo;0;L;;;;;N;;;;;\n14A3;CANADIAN SYLLABICS ME;Lo;0;L;;;;;N;;;;;\n14A4;CANADIAN SYLLABICS MAAI;Lo;0;L;;;;;N;;;;;\n14A5;CANADIAN SYLLABICS MI;Lo;0;L;;;;;N;;;;;\n14A6;CANADIAN SYLLABICS MII;Lo;0;L;;;;;N;;;;;\n14A7;CANADIAN SYLLABICS MO;Lo;0;L;;;;;N;;;;;\n14A8;CANADIAN SYLLABICS MOO;Lo;0;L;;;;;N;;;;;\n14A9;CANADIAN SYLLABICS Y-CREE MOO;Lo;0;L;;;;;N;;;;;\n14AA;CANADIAN SYLLABICS MA;Lo;0;L;;;;;N;;;;;\n14AB;CANADIAN SYLLABICS MAA;Lo;0;L;;;;;N;;;;;\n14AC;CANADIAN SYLLABICS MWE;Lo;0;L;;;;;N;;;;;\n14AD;CANADIAN SYLLABICS WEST-CREE MWE;Lo;0;L;;;;;N;;;;;\n14AE;CANADIAN SYLLABICS MWI;Lo;0;L;;;;;N;;;;;\n14AF;CANADIAN SYLLABICS WEST-CREE MWI;Lo;0;L;;;;;N;;;;;\n14B0;CANADIAN SYLLABICS MWII;Lo;0;L;;;;;N;;;;;\n14B1;CANADIAN SYLLABICS WEST-CREE MWII;Lo;0;L;;;;;N;;;;;\n14B2;CANADIAN SYLLABICS MWO;Lo;0;L;;;;;N;;;;;\n14B3;CANADIAN SYLLABICS WEST-CREE MWO;Lo;0;L;;;;;N;;;;;\n14B4;CANADIAN SYLLABICS MWOO;Lo;0;L;;;;;N;;;;;\n14B5;CANADIAN SYLLABICS WEST-CREE MWOO;Lo;0;L;;;;;N;;;;;\n14B6;CANADIAN SYLLABICS MWA;Lo;0;L;;;;;N;;;;;\n14B7;CANADIAN SYLLABICS WEST-CREE MWA;Lo;0;L;;;;;N;;;;;\n14B8;CANADIAN SYLLABICS MWAA;Lo;0;L;;;;;N;;;;;\n14B9;CANADIAN SYLLABICS WEST-CREE MWAA;Lo;0;L;;;;;N;;;;;\n14BA;CANADIAN SYLLABICS NASKAPI MWAA;Lo;0;L;;;;;N;;;;;\n14BB;CANADIAN SYLLABICS M;Lo;0;L;;;;;N;;;;;\n14BC;CANADIAN SYLLABICS WEST-CREE M;Lo;0;L;;;;;N;;;;;\n14BD;CANADIAN SYLLABICS MH;Lo;0;L;;;;;N;;;;;\n14BE;CANADIAN SYLLABICS ATHAPASCAN M;Lo;0;L;;;;;N;;;;;\n14BF;CANADIAN SYLLABICS SAYISI M;Lo;0;L;;;;;N;;;;;\n14C0;CANADIAN SYLLABICS NE;Lo;0;L;;;;;N;;;;;\n14C1;CANADIAN SYLLABICS NAAI;Lo;0;L;;;;;N;;;;;\n14C2;CANADIAN SYLLABICS NI;Lo;0;L;;;;;N;;;;;\n14C3;CANADIAN SYLLABICS NII;Lo;0;L;;;;;N;;;;;\n14C4;CANADIAN SYLLABICS NO;Lo;0;L;;;;;N;;;;;\n14C5;CANADIAN SYLLABICS NOO;Lo;0;L;;;;;N;;;;;\n14C6;CANADIAN SYLLABICS Y-CREE NOO;Lo;0;L;;;;;N;;;;;\n14C7;CANADIAN SYLLABICS NA;Lo;0;L;;;;;N;;;;;\n14C8;CANADIAN SYLLABICS NAA;Lo;0;L;;;;;N;;;;;\n14C9;CANADIAN SYLLABICS NWE;Lo;0;L;;;;;N;;;;;\n14CA;CANADIAN SYLLABICS WEST-CREE NWE;Lo;0;L;;;;;N;;;;;\n14CB;CANADIAN SYLLABICS NWA;Lo;0;L;;;;;N;;;;;\n14CC;CANADIAN SYLLABICS WEST-CREE NWA;Lo;0;L;;;;;N;;;;;\n14CD;CANADIAN SYLLABICS NWAA;Lo;0;L;;;;;N;;;;;\n14CE;CANADIAN SYLLABICS WEST-CREE NWAA;Lo;0;L;;;;;N;;;;;\n14CF;CANADIAN SYLLABICS NASKAPI NWAA;Lo;0;L;;;;;N;;;;;\n14D0;CANADIAN SYLLABICS N;Lo;0;L;;;;;N;;;;;\n14D1;CANADIAN SYLLABICS CARRIER NG;Lo;0;L;;;;;N;;;;;\n14D2;CANADIAN SYLLABICS NH;Lo;0;L;;;;;N;;;;;\n14D3;CANADIAN SYLLABICS LE;Lo;0;L;;;;;N;;;;;\n14D4;CANADIAN SYLLABICS LAAI;Lo;0;L;;;;;N;;;;;\n14D5;CANADIAN SYLLABICS LI;Lo;0;L;;;;;N;;;;;\n14D6;CANADIAN SYLLABICS LII;Lo;0;L;;;;;N;;;;;\n14D7;CANADIAN SYLLABICS LO;Lo;0;L;;;;;N;;;;;\n14D8;CANADIAN SYLLABICS LOO;Lo;0;L;;;;;N;;;;;\n14D9;CANADIAN SYLLABICS Y-CREE LOO;Lo;0;L;;;;;N;;;;;\n14DA;CANADIAN SYLLABICS LA;Lo;0;L;;;;;N;;;;;\n14DB;CANADIAN SYLLABICS LAA;Lo;0;L;;;;;N;;;;;\n14DC;CANADIAN SYLLABICS LWE;Lo;0;L;;;;;N;;;;;\n14DD;CANADIAN SYLLABICS WEST-CREE LWE;Lo;0;L;;;;;N;;;;;\n14DE;CANADIAN SYLLABICS LWI;Lo;0;L;;;;;N;;;;;\n14DF;CANADIAN SYLLABICS WEST-CREE LWI;Lo;0;L;;;;;N;;;;;\n14E0;CANADIAN SYLLABICS LWII;Lo;0;L;;;;;N;;;;;\n14E1;CANADIAN SYLLABICS WEST-CREE LWII;Lo;0;L;;;;;N;;;;;\n14E2;CANADIAN SYLLABICS LWO;Lo;0;L;;;;;N;;;;;\n14E3;CANADIAN SYLLABICS WEST-CREE LWO;Lo;0;L;;;;;N;;;;;\n14E4;CANADIAN SYLLABICS LWOO;Lo;0;L;;;;;N;;;;;\n14E5;CANADIAN SYLLABICS WEST-CREE LWOO;Lo;0;L;;;;;N;;;;;\n14E6;CANADIAN SYLLABICS LWA;Lo;0;L;;;;;N;;;;;\n14E7;CANADIAN SYLLABICS WEST-CREE LWA;Lo;0;L;;;;;N;;;;;\n14E8;CANADIAN SYLLABICS LWAA;Lo;0;L;;;;;N;;;;;\n14E9;CANADIAN SYLLABICS WEST-CREE LWAA;Lo;0;L;;;;;N;;;;;\n14EA;CANADIAN SYLLABICS L;Lo;0;L;;;;;N;;;;;\n14EB;CANADIAN SYLLABICS WEST-CREE L;Lo;0;L;;;;;N;;;;;\n14EC;CANADIAN SYLLABICS MEDIAL L;Lo;0;L;;;;;N;;;;;\n14ED;CANADIAN SYLLABICS SE;Lo;0;L;;;;;N;;;;;\n14EE;CANADIAN SYLLABICS SAAI;Lo;0;L;;;;;N;;;;;\n14EF;CANADIAN SYLLABICS SI;Lo;0;L;;;;;N;;;;;\n14F0;CANADIAN SYLLABICS SII;Lo;0;L;;;;;N;;;;;\n14F1;CANADIAN SYLLABICS SO;Lo;0;L;;;;;N;;;;;\n14F2;CANADIAN SYLLABICS SOO;Lo;0;L;;;;;N;;;;;\n14F3;CANADIAN SYLLABICS Y-CREE SOO;Lo;0;L;;;;;N;;;;;\n14F4;CANADIAN SYLLABICS SA;Lo;0;L;;;;;N;;;;;\n14F5;CANADIAN SYLLABICS SAA;Lo;0;L;;;;;N;;;;;\n14F6;CANADIAN SYLLABICS SWE;Lo;0;L;;;;;N;;;;;\n14F7;CANADIAN SYLLABICS WEST-CREE SWE;Lo;0;L;;;;;N;;;;;\n14F8;CANADIAN SYLLABICS SWI;Lo;0;L;;;;;N;;;;;\n14F9;CANADIAN SYLLABICS WEST-CREE SWI;Lo;0;L;;;;;N;;;;;\n14FA;CANADIAN SYLLABICS SWII;Lo;0;L;;;;;N;;;;;\n14FB;CANADIAN SYLLABICS WEST-CREE SWII;Lo;0;L;;;;;N;;;;;\n14FC;CANADIAN SYLLABICS SWO;Lo;0;L;;;;;N;;;;;\n14FD;CANADIAN SYLLABICS WEST-CREE SWO;Lo;0;L;;;;;N;;;;;\n14FE;CANADIAN SYLLABICS SWOO;Lo;0;L;;;;;N;;;;;\n14FF;CANADIAN SYLLABICS WEST-CREE SWOO;Lo;0;L;;;;;N;;;;;\n1500;CANADIAN SYLLABICS SWA;Lo;0;L;;;;;N;;;;;\n1501;CANADIAN SYLLABICS WEST-CREE SWA;Lo;0;L;;;;;N;;;;;\n1502;CANADIAN SYLLABICS SWAA;Lo;0;L;;;;;N;;;;;\n1503;CANADIAN SYLLABICS WEST-CREE SWAA;Lo;0;L;;;;;N;;;;;\n1504;CANADIAN SYLLABICS NASKAPI SWAA;Lo;0;L;;;;;N;;;;;\n1505;CANADIAN SYLLABICS S;Lo;0;L;;;;;N;;;;;\n1506;CANADIAN SYLLABICS ATHAPASCAN S;Lo;0;L;;;;;N;;;;;\n1507;CANADIAN SYLLABICS SW;Lo;0;L;;;;;N;;;;;\n1508;CANADIAN SYLLABICS BLACKFOOT S;Lo;0;L;;;;;N;;;;;\n1509;CANADIAN SYLLABICS MOOSE-CREE SK;Lo;0;L;;;;;N;;;;;\n150A;CANADIAN SYLLABICS NASKAPI SKW;Lo;0;L;;;;;N;;;;;\n150B;CANADIAN SYLLABICS NASKAPI S-W;Lo;0;L;;;;;N;;;;;\n150C;CANADIAN SYLLABICS NASKAPI SPWA;Lo;0;L;;;;;N;;;;;\n150D;CANADIAN SYLLABICS NASKAPI STWA;Lo;0;L;;;;;N;;;;;\n150E;CANADIAN SYLLABICS NASKAPI SKWA;Lo;0;L;;;;;N;;;;;\n150F;CANADIAN SYLLABICS NASKAPI SCWA;Lo;0;L;;;;;N;;;;;\n1510;CANADIAN SYLLABICS SHE;Lo;0;L;;;;;N;;;;;\n1511;CANADIAN SYLLABICS SHI;Lo;0;L;;;;;N;;;;;\n1512;CANADIAN SYLLABICS SHII;Lo;0;L;;;;;N;;;;;\n1513;CANADIAN SYLLABICS SHO;Lo;0;L;;;;;N;;;;;\n1514;CANADIAN SYLLABICS SHOO;Lo;0;L;;;;;N;;;;;\n1515;CANADIAN SYLLABICS SHA;Lo;0;L;;;;;N;;;;;\n1516;CANADIAN SYLLABICS SHAA;Lo;0;L;;;;;N;;;;;\n1517;CANADIAN SYLLABICS SHWE;Lo;0;L;;;;;N;;;;;\n1518;CANADIAN SYLLABICS WEST-CREE SHWE;Lo;0;L;;;;;N;;;;;\n1519;CANADIAN SYLLABICS SHWI;Lo;0;L;;;;;N;;;;;\n151A;CANADIAN SYLLABICS WEST-CREE SHWI;Lo;0;L;;;;;N;;;;;\n151B;CANADIAN SYLLABICS SHWII;Lo;0;L;;;;;N;;;;;\n151C;CANADIAN SYLLABICS WEST-CREE SHWII;Lo;0;L;;;;;N;;;;;\n151D;CANADIAN SYLLABICS SHWO;Lo;0;L;;;;;N;;;;;\n151E;CANADIAN SYLLABICS WEST-CREE SHWO;Lo;0;L;;;;;N;;;;;\n151F;CANADIAN SYLLABICS SHWOO;Lo;0;L;;;;;N;;;;;\n1520;CANADIAN SYLLABICS WEST-CREE SHWOO;Lo;0;L;;;;;N;;;;;\n1521;CANADIAN SYLLABICS SHWA;Lo;0;L;;;;;N;;;;;\n1522;CANADIAN SYLLABICS WEST-CREE SHWA;Lo;0;L;;;;;N;;;;;\n1523;CANADIAN SYLLABICS SHWAA;Lo;0;L;;;;;N;;;;;\n1524;CANADIAN SYLLABICS WEST-CREE SHWAA;Lo;0;L;;;;;N;;;;;\n1525;CANADIAN SYLLABICS SH;Lo;0;L;;;;;N;;;;;\n1526;CANADIAN SYLLABICS YE;Lo;0;L;;;;;N;;;;;\n1527;CANADIAN SYLLABICS YAAI;Lo;0;L;;;;;N;;;;;\n1528;CANADIAN SYLLABICS YI;Lo;0;L;;;;;N;;;;;\n1529;CANADIAN SYLLABICS YII;Lo;0;L;;;;;N;;;;;\n152A;CANADIAN SYLLABICS YO;Lo;0;L;;;;;N;;;;;\n152B;CANADIAN SYLLABICS YOO;Lo;0;L;;;;;N;;;;;\n152C;CANADIAN SYLLABICS Y-CREE YOO;Lo;0;L;;;;;N;;;;;\n152D;CANADIAN SYLLABICS YA;Lo;0;L;;;;;N;;;;;\n152E;CANADIAN SYLLABICS YAA;Lo;0;L;;;;;N;;;;;\n152F;CANADIAN SYLLABICS YWE;Lo;0;L;;;;;N;;;;;\n1530;CANADIAN SYLLABICS WEST-CREE YWE;Lo;0;L;;;;;N;;;;;\n1531;CANADIAN SYLLABICS YWI;Lo;0;L;;;;;N;;;;;\n1532;CANADIAN SYLLABICS WEST-CREE YWI;Lo;0;L;;;;;N;;;;;\n1533;CANADIAN SYLLABICS YWII;Lo;0;L;;;;;N;;;;;\n1534;CANADIAN SYLLABICS WEST-CREE YWII;Lo;0;L;;;;;N;;;;;\n1535;CANADIAN SYLLABICS YWO;Lo;0;L;;;;;N;;;;;\n1536;CANADIAN SYLLABICS WEST-CREE YWO;Lo;0;L;;;;;N;;;;;\n1537;CANADIAN SYLLABICS YWOO;Lo;0;L;;;;;N;;;;;\n1538;CANADIAN SYLLABICS WEST-CREE YWOO;Lo;0;L;;;;;N;;;;;\n1539;CANADIAN SYLLABICS YWA;Lo;0;L;;;;;N;;;;;\n153A;CANADIAN SYLLABICS WEST-CREE YWA;Lo;0;L;;;;;N;;;;;\n153B;CANADIAN SYLLABICS YWAA;Lo;0;L;;;;;N;;;;;\n153C;CANADIAN SYLLABICS WEST-CREE YWAA;Lo;0;L;;;;;N;;;;;\n153D;CANADIAN SYLLABICS NASKAPI YWAA;Lo;0;L;;;;;N;;;;;\n153E;CANADIAN SYLLABICS Y;Lo;0;L;;;;;N;;;;;\n153F;CANADIAN SYLLABICS BIBLE-CREE Y;Lo;0;L;;;;;N;;;;;\n1540;CANADIAN SYLLABICS WEST-CREE Y;Lo;0;L;;;;;N;;;;;\n1541;CANADIAN SYLLABICS SAYISI YI;Lo;0;L;;;;;N;;;;;\n1542;CANADIAN SYLLABICS RE;Lo;0;L;;;;;N;;;;;\n1543;CANADIAN SYLLABICS R-CREE RE;Lo;0;L;;;;;N;;;;;\n1544;CANADIAN SYLLABICS WEST-CREE LE;Lo;0;L;;;;;N;;;;;\n1545;CANADIAN SYLLABICS RAAI;Lo;0;L;;;;;N;;;;;\n1546;CANADIAN SYLLABICS RI;Lo;0;L;;;;;N;;;;;\n1547;CANADIAN SYLLABICS RII;Lo;0;L;;;;;N;;;;;\n1548;CANADIAN SYLLABICS RO;Lo;0;L;;;;;N;;;;;\n1549;CANADIAN SYLLABICS ROO;Lo;0;L;;;;;N;;;;;\n154A;CANADIAN SYLLABICS WEST-CREE LO;Lo;0;L;;;;;N;;;;;\n154B;CANADIAN SYLLABICS RA;Lo;0;L;;;;;N;;;;;\n154C;CANADIAN SYLLABICS RAA;Lo;0;L;;;;;N;;;;;\n154D;CANADIAN SYLLABICS WEST-CREE LA;Lo;0;L;;;;;N;;;;;\n154E;CANADIAN SYLLABICS RWAA;Lo;0;L;;;;;N;;;;;\n154F;CANADIAN SYLLABICS WEST-CREE RWAA;Lo;0;L;;;;;N;;;;;\n1550;CANADIAN SYLLABICS R;Lo;0;L;;;;;N;;;;;\n1551;CANADIAN SYLLABICS WEST-CREE R;Lo;0;L;;;;;N;;;;;\n1552;CANADIAN SYLLABICS MEDIAL R;Lo;0;L;;;;;N;;;;;\n1553;CANADIAN SYLLABICS FE;Lo;0;L;;;;;N;;;;;\n1554;CANADIAN SYLLABICS FAAI;Lo;0;L;;;;;N;;;;;\n1555;CANADIAN SYLLABICS FI;Lo;0;L;;;;;N;;;;;\n1556;CANADIAN SYLLABICS FII;Lo;0;L;;;;;N;;;;;\n1557;CANADIAN SYLLABICS FO;Lo;0;L;;;;;N;;;;;\n1558;CANADIAN SYLLABICS FOO;Lo;0;L;;;;;N;;;;;\n1559;CANADIAN SYLLABICS FA;Lo;0;L;;;;;N;;;;;\n155A;CANADIAN SYLLABICS FAA;Lo;0;L;;;;;N;;;;;\n155B;CANADIAN SYLLABICS FWAA;Lo;0;L;;;;;N;;;;;\n155C;CANADIAN SYLLABICS WEST-CREE FWAA;Lo;0;L;;;;;N;;;;;\n155D;CANADIAN SYLLABICS F;Lo;0;L;;;;;N;;;;;\n155E;CANADIAN SYLLABICS THE;Lo;0;L;;;;;N;;;;;\n155F;CANADIAN SYLLABICS N-CREE THE;Lo;0;L;;;;;N;;;;;\n1560;CANADIAN SYLLABICS THI;Lo;0;L;;;;;N;;;;;\n1561;CANADIAN SYLLABICS N-CREE THI;Lo;0;L;;;;;N;;;;;\n1562;CANADIAN SYLLABICS THII;Lo;0;L;;;;;N;;;;;\n1563;CANADIAN SYLLABICS N-CREE THII;Lo;0;L;;;;;N;;;;;\n1564;CANADIAN SYLLABICS THO;Lo;0;L;;;;;N;;;;;\n1565;CANADIAN SYLLABICS THOO;Lo;0;L;;;;;N;;;;;\n1566;CANADIAN SYLLABICS THA;Lo;0;L;;;;;N;;;;;\n1567;CANADIAN SYLLABICS THAA;Lo;0;L;;;;;N;;;;;\n1568;CANADIAN SYLLABICS THWAA;Lo;0;L;;;;;N;;;;;\n1569;CANADIAN SYLLABICS WEST-CREE THWAA;Lo;0;L;;;;;N;;;;;\n156A;CANADIAN SYLLABICS TH;Lo;0;L;;;;;N;;;;;\n156B;CANADIAN SYLLABICS TTHE;Lo;0;L;;;;;N;;;;;\n156C;CANADIAN SYLLABICS TTHI;Lo;0;L;;;;;N;;;;;\n156D;CANADIAN SYLLABICS TTHO;Lo;0;L;;;;;N;;;;;\n156E;CANADIAN SYLLABICS TTHA;Lo;0;L;;;;;N;;;;;\n156F;CANADIAN SYLLABICS TTH;Lo;0;L;;;;;N;;;;;\n1570;CANADIAN SYLLABICS TYE;Lo;0;L;;;;;N;;;;;\n1571;CANADIAN SYLLABICS TYI;Lo;0;L;;;;;N;;;;;\n1572;CANADIAN SYLLABICS TYO;Lo;0;L;;;;;N;;;;;\n1573;CANADIAN SYLLABICS TYA;Lo;0;L;;;;;N;;;;;\n1574;CANADIAN SYLLABICS NUNAVIK HE;Lo;0;L;;;;;N;;;;;\n1575;CANADIAN SYLLABICS NUNAVIK HI;Lo;0;L;;;;;N;;;;;\n1576;CANADIAN SYLLABICS NUNAVIK HII;Lo;0;L;;;;;N;;;;;\n1577;CANADIAN SYLLABICS NUNAVIK HO;Lo;0;L;;;;;N;;;;;\n1578;CANADIAN SYLLABICS NUNAVIK HOO;Lo;0;L;;;;;N;;;;;\n1579;CANADIAN SYLLABICS NUNAVIK HA;Lo;0;L;;;;;N;;;;;\n157A;CANADIAN SYLLABICS NUNAVIK HAA;Lo;0;L;;;;;N;;;;;\n157B;CANADIAN SYLLABICS NUNAVIK H;Lo;0;L;;;;;N;;;;;\n157C;CANADIAN SYLLABICS NUNAVUT H;Lo;0;L;;;;;N;;;;;\n157D;CANADIAN SYLLABICS HK;Lo;0;L;;;;;N;;;;;\n157E;CANADIAN SYLLABICS QAAI;Lo;0;L;;;;;N;;;;;\n157F;CANADIAN SYLLABICS QI;Lo;0;L;;;;;N;;;;;\n1580;CANADIAN SYLLABICS QII;Lo;0;L;;;;;N;;;;;\n1581;CANADIAN SYLLABICS QO;Lo;0;L;;;;;N;;;;;\n1582;CANADIAN SYLLABICS QOO;Lo;0;L;;;;;N;;;;;\n1583;CANADIAN SYLLABICS QA;Lo;0;L;;;;;N;;;;;\n1584;CANADIAN SYLLABICS QAA;Lo;0;L;;;;;N;;;;;\n1585;CANADIAN SYLLABICS Q;Lo;0;L;;;;;N;;;;;\n1586;CANADIAN SYLLABICS TLHE;Lo;0;L;;;;;N;;;;;\n1587;CANADIAN SYLLABICS TLHI;Lo;0;L;;;;;N;;;;;\n1588;CANADIAN SYLLABICS TLHO;Lo;0;L;;;;;N;;;;;\n1589;CANADIAN SYLLABICS TLHA;Lo;0;L;;;;;N;;;;;\n158A;CANADIAN SYLLABICS WEST-CREE RE;Lo;0;L;;;;;N;;;;;\n158B;CANADIAN SYLLABICS WEST-CREE RI;Lo;0;L;;;;;N;;;;;\n158C;CANADIAN SYLLABICS WEST-CREE RO;Lo;0;L;;;;;N;;;;;\n158D;CANADIAN SYLLABICS WEST-CREE RA;Lo;0;L;;;;;N;;;;;\n158E;CANADIAN SYLLABICS NGAAI;Lo;0;L;;;;;N;;;;;\n158F;CANADIAN SYLLABICS NGI;Lo;0;L;;;;;N;;;;;\n1590;CANADIAN SYLLABICS NGII;Lo;0;L;;;;;N;;;;;\n1591;CANADIAN SYLLABICS NGO;Lo;0;L;;;;;N;;;;;\n1592;CANADIAN SYLLABICS NGOO;Lo;0;L;;;;;N;;;;;\n1593;CANADIAN SYLLABICS NGA;Lo;0;L;;;;;N;;;;;\n1594;CANADIAN SYLLABICS NGAA;Lo;0;L;;;;;N;;;;;\n1595;CANADIAN SYLLABICS NG;Lo;0;L;;;;;N;;;;;\n1596;CANADIAN SYLLABICS NNG;Lo;0;L;;;;;N;;;;;\n1597;CANADIAN SYLLABICS SAYISI SHE;Lo;0;L;;;;;N;;;;;\n1598;CANADIAN SYLLABICS SAYISI SHI;Lo;0;L;;;;;N;;;;;\n1599;CANADIAN SYLLABICS SAYISI SHO;Lo;0;L;;;;;N;;;;;\n159A;CANADIAN SYLLABICS SAYISI SHA;Lo;0;L;;;;;N;;;;;\n159B;CANADIAN SYLLABICS WOODS-CREE THE;Lo;0;L;;;;;N;;;;;\n159C;CANADIAN SYLLABICS WOODS-CREE THI;Lo;0;L;;;;;N;;;;;\n159D;CANADIAN SYLLABICS WOODS-CREE THO;Lo;0;L;;;;;N;;;;;\n159E;CANADIAN SYLLABICS WOODS-CREE THA;Lo;0;L;;;;;N;;;;;\n159F;CANADIAN SYLLABICS WOODS-CREE TH;Lo;0;L;;;;;N;;;;;\n15A0;CANADIAN SYLLABICS LHI;Lo;0;L;;;;;N;;;;;\n15A1;CANADIAN SYLLABICS LHII;Lo;0;L;;;;;N;;;;;\n15A2;CANADIAN SYLLABICS LHO;Lo;0;L;;;;;N;;;;;\n15A3;CANADIAN SYLLABICS LHOO;Lo;0;L;;;;;N;;;;;\n15A4;CANADIAN SYLLABICS LHA;Lo;0;L;;;;;N;;;;;\n15A5;CANADIAN SYLLABICS LHAA;Lo;0;L;;;;;N;;;;;\n15A6;CANADIAN SYLLABICS LH;Lo;0;L;;;;;N;;;;;\n15A7;CANADIAN SYLLABICS TH-CREE THE;Lo;0;L;;;;;N;;;;;\n15A8;CANADIAN SYLLABICS TH-CREE THI;Lo;0;L;;;;;N;;;;;\n15A9;CANADIAN SYLLABICS TH-CREE THII;Lo;0;L;;;;;N;;;;;\n15AA;CANADIAN SYLLABICS TH-CREE THO;Lo;0;L;;;;;N;;;;;\n15AB;CANADIAN SYLLABICS TH-CREE THOO;Lo;0;L;;;;;N;;;;;\n15AC;CANADIAN SYLLABICS TH-CREE THA;Lo;0;L;;;;;N;;;;;\n15AD;CANADIAN SYLLABICS TH-CREE THAA;Lo;0;L;;;;;N;;;;;\n15AE;CANADIAN SYLLABICS TH-CREE TH;Lo;0;L;;;;;N;;;;;\n15AF;CANADIAN SYLLABICS AIVILIK B;Lo;0;L;;;;;N;;;;;\n15B0;CANADIAN SYLLABICS BLACKFOOT E;Lo;0;L;;;;;N;;;;;\n15B1;CANADIAN SYLLABICS BLACKFOOT I;Lo;0;L;;;;;N;;;;;\n15B2;CANADIAN SYLLABICS BLACKFOOT O;Lo;0;L;;;;;N;;;;;\n15B3;CANADIAN SYLLABICS BLACKFOOT A;Lo;0;L;;;;;N;;;;;\n15B4;CANADIAN SYLLABICS BLACKFOOT WE;Lo;0;L;;;;;N;;;;;\n15B5;CANADIAN SYLLABICS BLACKFOOT WI;Lo;0;L;;;;;N;;;;;\n15B6;CANADIAN SYLLABICS BLACKFOOT WO;Lo;0;L;;;;;N;;;;;\n15B7;CANADIAN SYLLABICS BLACKFOOT WA;Lo;0;L;;;;;N;;;;;\n15B8;CANADIAN SYLLABICS BLACKFOOT NE;Lo;0;L;;;;;N;;;;;\n15B9;CANADIAN SYLLABICS BLACKFOOT NI;Lo;0;L;;;;;N;;;;;\n15BA;CANADIAN SYLLABICS BLACKFOOT NO;Lo;0;L;;;;;N;;;;;\n15BB;CANADIAN SYLLABICS BLACKFOOT NA;Lo;0;L;;;;;N;;;;;\n15BC;CANADIAN SYLLABICS BLACKFOOT KE;Lo;0;L;;;;;N;;;;;\n15BD;CANADIAN SYLLABICS BLACKFOOT KI;Lo;0;L;;;;;N;;;;;\n15BE;CANADIAN SYLLABICS BLACKFOOT KO;Lo;0;L;;;;;N;;;;;\n15BF;CANADIAN SYLLABICS BLACKFOOT KA;Lo;0;L;;;;;N;;;;;\n15C0;CANADIAN SYLLABICS SAYISI HE;Lo;0;L;;;;;N;;;;;\n15C1;CANADIAN SYLLABICS SAYISI HI;Lo;0;L;;;;;N;;;;;\n15C2;CANADIAN SYLLABICS SAYISI HO;Lo;0;L;;;;;N;;;;;\n15C3;CANADIAN SYLLABICS SAYISI HA;Lo;0;L;;;;;N;;;;;\n15C4;CANADIAN SYLLABICS CARRIER GHU;Lo;0;L;;;;;N;;;;;\n15C5;CANADIAN SYLLABICS CARRIER GHO;Lo;0;L;;;;;N;;;;;\n15C6;CANADIAN SYLLABICS CARRIER GHE;Lo;0;L;;;;;N;;;;;\n15C7;CANADIAN SYLLABICS CARRIER GHEE;Lo;0;L;;;;;N;;;;;\n15C8;CANADIAN SYLLABICS CARRIER GHI;Lo;0;L;;;;;N;;;;;\n15C9;CANADIAN SYLLABICS CARRIER GHA;Lo;0;L;;;;;N;;;;;\n15CA;CANADIAN SYLLABICS CARRIER RU;Lo;0;L;;;;;N;;;;;\n15CB;CANADIAN SYLLABICS CARRIER RO;Lo;0;L;;;;;N;;;;;\n15CC;CANADIAN SYLLABICS CARRIER RE;Lo;0;L;;;;;N;;;;;\n15CD;CANADIAN SYLLABICS CARRIER REE;Lo;0;L;;;;;N;;;;;\n15CE;CANADIAN SYLLABICS CARRIER RI;Lo;0;L;;;;;N;;;;;\n15CF;CANADIAN SYLLABICS CARRIER RA;Lo;0;L;;;;;N;;;;;\n15D0;CANADIAN SYLLABICS CARRIER WU;Lo;0;L;;;;;N;;;;;\n15D1;CANADIAN SYLLABICS CARRIER WO;Lo;0;L;;;;;N;;;;;\n15D2;CANADIAN SYLLABICS CARRIER WE;Lo;0;L;;;;;N;;;;;\n15D3;CANADIAN SYLLABICS CARRIER WEE;Lo;0;L;;;;;N;;;;;\n15D4;CANADIAN SYLLABICS CARRIER WI;Lo;0;L;;;;;N;;;;;\n15D5;CANADIAN SYLLABICS CARRIER WA;Lo;0;L;;;;;N;;;;;\n15D6;CANADIAN SYLLABICS CARRIER HWU;Lo;0;L;;;;;N;;;;;\n15D7;CANADIAN SYLLABICS CARRIER HWO;Lo;0;L;;;;;N;;;;;\n15D8;CANADIAN SYLLABICS CARRIER HWE;Lo;0;L;;;;;N;;;;;\n15D9;CANADIAN SYLLABICS CARRIER HWEE;Lo;0;L;;;;;N;;;;;\n15DA;CANADIAN SYLLABICS CARRIER HWI;Lo;0;L;;;;;N;;;;;\n15DB;CANADIAN SYLLABICS CARRIER HWA;Lo;0;L;;;;;N;;;;;\n15DC;CANADIAN SYLLABICS CARRIER THU;Lo;0;L;;;;;N;;;;;\n15DD;CANADIAN SYLLABICS CARRIER THO;Lo;0;L;;;;;N;;;;;\n15DE;CANADIAN SYLLABICS CARRIER THE;Lo;0;L;;;;;N;;;;;\n15DF;CANADIAN SYLLABICS CARRIER THEE;Lo;0;L;;;;;N;;;;;\n15E0;CANADIAN SYLLABICS CARRIER THI;Lo;0;L;;;;;N;;;;;\n15E1;CANADIAN SYLLABICS CARRIER THA;Lo;0;L;;;;;N;;;;;\n15E2;CANADIAN SYLLABICS CARRIER TTU;Lo;0;L;;;;;N;;;;;\n15E3;CANADIAN SYLLABICS CARRIER TTO;Lo;0;L;;;;;N;;;;;\n15E4;CANADIAN SYLLABICS CARRIER TTE;Lo;0;L;;;;;N;;;;;\n15E5;CANADIAN SYLLABICS CARRIER TTEE;Lo;0;L;;;;;N;;;;;\n15E6;CANADIAN SYLLABICS CARRIER TTI;Lo;0;L;;;;;N;;;;;\n15E7;CANADIAN SYLLABICS CARRIER TTA;Lo;0;L;;;;;N;;;;;\n15E8;CANADIAN SYLLABICS CARRIER PU;Lo;0;L;;;;;N;;;;;\n15E9;CANADIAN SYLLABICS CARRIER PO;Lo;0;L;;;;;N;;;;;\n15EA;CANADIAN SYLLABICS CARRIER PE;Lo;0;L;;;;;N;;;;;\n15EB;CANADIAN SYLLABICS CARRIER PEE;Lo;0;L;;;;;N;;;;;\n15EC;CANADIAN SYLLABICS CARRIER PI;Lo;0;L;;;;;N;;;;;\n15ED;CANADIAN SYLLABICS CARRIER PA;Lo;0;L;;;;;N;;;;;\n15EE;CANADIAN SYLLABICS CARRIER P;Lo;0;L;;;;;N;;;;;\n15EF;CANADIAN SYLLABICS CARRIER GU;Lo;0;L;;;;;N;;;;;\n15F0;CANADIAN SYLLABICS CARRIER GO;Lo;0;L;;;;;N;;;;;\n15F1;CANADIAN SYLLABICS CARRIER GE;Lo;0;L;;;;;N;;;;;\n15F2;CANADIAN SYLLABICS CARRIER GEE;Lo;0;L;;;;;N;;;;;\n15F3;CANADIAN SYLLABICS CARRIER GI;Lo;0;L;;;;;N;;;;;\n15F4;CANADIAN SYLLABICS CARRIER GA;Lo;0;L;;;;;N;;;;;\n15F5;CANADIAN SYLLABICS CARRIER KHU;Lo;0;L;;;;;N;;;;;\n15F6;CANADIAN SYLLABICS CARRIER KHO;Lo;0;L;;;;;N;;;;;\n15F7;CANADIAN SYLLABICS CARRIER KHE;Lo;0;L;;;;;N;;;;;\n15F8;CANADIAN SYLLABICS CARRIER KHEE;Lo;0;L;;;;;N;;;;;\n15F9;CANADIAN SYLLABICS CARRIER KHI;Lo;0;L;;;;;N;;;;;\n15FA;CANADIAN SYLLABICS CARRIER KHA;Lo;0;L;;;;;N;;;;;\n15FB;CANADIAN SYLLABICS CARRIER KKU;Lo;0;L;;;;;N;;;;;\n15FC;CANADIAN SYLLABICS CARRIER KKO;Lo;0;L;;;;;N;;;;;\n15FD;CANADIAN SYLLABICS CARRIER KKE;Lo;0;L;;;;;N;;;;;\n15FE;CANADIAN SYLLABICS CARRIER KKEE;Lo;0;L;;;;;N;;;;;\n15FF;CANADIAN SYLLABICS CARRIER KKI;Lo;0;L;;;;;N;;;;;\n1600;CANADIAN SYLLABICS CARRIER KKA;Lo;0;L;;;;;N;;;;;\n1601;CANADIAN SYLLABICS CARRIER KK;Lo;0;L;;;;;N;;;;;\n1602;CANADIAN SYLLABICS CARRIER NU;Lo;0;L;;;;;N;;;;;\n1603;CANADIAN SYLLABICS CARRIER NO;Lo;0;L;;;;;N;;;;;\n1604;CANADIAN SYLLABICS CARRIER NE;Lo;0;L;;;;;N;;;;;\n1605;CANADIAN SYLLABICS CARRIER NEE;Lo;0;L;;;;;N;;;;;\n1606;CANADIAN SYLLABICS CARRIER NI;Lo;0;L;;;;;N;;;;;\n1607;CANADIAN SYLLABICS CARRIER NA;Lo;0;L;;;;;N;;;;;\n1608;CANADIAN SYLLABICS CARRIER MU;Lo;0;L;;;;;N;;;;;\n1609;CANADIAN SYLLABICS CARRIER MO;Lo;0;L;;;;;N;;;;;\n160A;CANADIAN SYLLABICS CARRIER ME;Lo;0;L;;;;;N;;;;;\n160B;CANADIAN SYLLABICS CARRIER MEE;Lo;0;L;;;;;N;;;;;\n160C;CANADIAN SYLLABICS CARRIER MI;Lo;0;L;;;;;N;;;;;\n160D;CANADIAN SYLLABICS CARRIER MA;Lo;0;L;;;;;N;;;;;\n160E;CANADIAN SYLLABICS CARRIER YU;Lo;0;L;;;;;N;;;;;\n160F;CANADIAN SYLLABICS CARRIER YO;Lo;0;L;;;;;N;;;;;\n1610;CANADIAN SYLLABICS CARRIER YE;Lo;0;L;;;;;N;;;;;\n1611;CANADIAN SYLLABICS CARRIER YEE;Lo;0;L;;;;;N;;;;;\n1612;CANADIAN SYLLABICS CARRIER YI;Lo;0;L;;;;;N;;;;;\n1613;CANADIAN SYLLABICS CARRIER YA;Lo;0;L;;;;;N;;;;;\n1614;CANADIAN SYLLABICS CARRIER JU;Lo;0;L;;;;;N;;;;;\n1615;CANADIAN SYLLABICS SAYISI JU;Lo;0;L;;;;;N;;;;;\n1616;CANADIAN SYLLABICS CARRIER JO;Lo;0;L;;;;;N;;;;;\n1617;CANADIAN SYLLABICS CARRIER JE;Lo;0;L;;;;;N;;;;;\n1618;CANADIAN SYLLABICS CARRIER JEE;Lo;0;L;;;;;N;;;;;\n1619;CANADIAN SYLLABICS CARRIER JI;Lo;0;L;;;;;N;;;;;\n161A;CANADIAN SYLLABICS SAYISI JI;Lo;0;L;;;;;N;;;;;\n161B;CANADIAN SYLLABICS CARRIER JA;Lo;0;L;;;;;N;;;;;\n161C;CANADIAN SYLLABICS CARRIER JJU;Lo;0;L;;;;;N;;;;;\n161D;CANADIAN SYLLABICS CARRIER JJO;Lo;0;L;;;;;N;;;;;\n161E;CANADIAN SYLLABICS CARRIER JJE;Lo;0;L;;;;;N;;;;;\n161F;CANADIAN SYLLABICS CARRIER JJEE;Lo;0;L;;;;;N;;;;;\n1620;CANADIAN SYLLABICS CARRIER JJI;Lo;0;L;;;;;N;;;;;\n1621;CANADIAN SYLLABICS CARRIER JJA;Lo;0;L;;;;;N;;;;;\n1622;CANADIAN SYLLABICS CARRIER LU;Lo;0;L;;;;;N;;;;;\n1623;CANADIAN SYLLABICS CARRIER LO;Lo;0;L;;;;;N;;;;;\n1624;CANADIAN SYLLABICS CARRIER LE;Lo;0;L;;;;;N;;;;;\n1625;CANADIAN SYLLABICS CARRIER LEE;Lo;0;L;;;;;N;;;;;\n1626;CANADIAN SYLLABICS CARRIER LI;Lo;0;L;;;;;N;;;;;\n1627;CANADIAN SYLLABICS CARRIER LA;Lo;0;L;;;;;N;;;;;\n1628;CANADIAN SYLLABICS CARRIER DLU;Lo;0;L;;;;;N;;;;;\n1629;CANADIAN SYLLABICS CARRIER DLO;Lo;0;L;;;;;N;;;;;\n162A;CANADIAN SYLLABICS CARRIER DLE;Lo;0;L;;;;;N;;;;;\n162B;CANADIAN SYLLABICS CARRIER DLEE;Lo;0;L;;;;;N;;;;;\n162C;CANADIAN SYLLABICS CARRIER DLI;Lo;0;L;;;;;N;;;;;\n162D;CANADIAN SYLLABICS CARRIER DLA;Lo;0;L;;;;;N;;;;;\n162E;CANADIAN SYLLABICS CARRIER LHU;Lo;0;L;;;;;N;;;;;\n162F;CANADIAN SYLLABICS CARRIER LHO;Lo;0;L;;;;;N;;;;;\n1630;CANADIAN SYLLABICS CARRIER LHE;Lo;0;L;;;;;N;;;;;\n1631;CANADIAN SYLLABICS CARRIER LHEE;Lo;0;L;;;;;N;;;;;\n1632;CANADIAN SYLLABICS CARRIER LHI;Lo;0;L;;;;;N;;;;;\n1633;CANADIAN SYLLABICS CARRIER LHA;Lo;0;L;;;;;N;;;;;\n1634;CANADIAN SYLLABICS CARRIER TLHU;Lo;0;L;;;;;N;;;;;\n1635;CANADIAN SYLLABICS CARRIER TLHO;Lo;0;L;;;;;N;;;;;\n1636;CANADIAN SYLLABICS CARRIER TLHE;Lo;0;L;;;;;N;;;;;\n1637;CANADIAN SYLLABICS CARRIER TLHEE;Lo;0;L;;;;;N;;;;;\n1638;CANADIAN SYLLABICS CARRIER TLHI;Lo;0;L;;;;;N;;;;;\n1639;CANADIAN SYLLABICS CARRIER TLHA;Lo;0;L;;;;;N;;;;;\n163A;CANADIAN SYLLABICS CARRIER TLU;Lo;0;L;;;;;N;;;;;\n163B;CANADIAN SYLLABICS CARRIER TLO;Lo;0;L;;;;;N;;;;;\n163C;CANADIAN SYLLABICS CARRIER TLE;Lo;0;L;;;;;N;;;;;\n163D;CANADIAN SYLLABICS CARRIER TLEE;Lo;0;L;;;;;N;;;;;\n163E;CANADIAN SYLLABICS CARRIER TLI;Lo;0;L;;;;;N;;;;;\n163F;CANADIAN SYLLABICS CARRIER TLA;Lo;0;L;;;;;N;;;;;\n1640;CANADIAN SYLLABICS CARRIER ZU;Lo;0;L;;;;;N;;;;;\n1641;CANADIAN SYLLABICS CARRIER ZO;Lo;0;L;;;;;N;;;;;\n1642;CANADIAN SYLLABICS CARRIER ZE;Lo;0;L;;;;;N;;;;;\n1643;CANADIAN SYLLABICS CARRIER ZEE;Lo;0;L;;;;;N;;;;;\n1644;CANADIAN SYLLABICS CARRIER ZI;Lo;0;L;;;;;N;;;;;\n1645;CANADIAN SYLLABICS CARRIER ZA;Lo;0;L;;;;;N;;;;;\n1646;CANADIAN SYLLABICS CARRIER Z;Lo;0;L;;;;;N;;;;;\n1647;CANADIAN SYLLABICS CARRIER INITIAL Z;Lo;0;L;;;;;N;;;;;\n1648;CANADIAN SYLLABICS CARRIER DZU;Lo;0;L;;;;;N;;;;;\n1649;CANADIAN SYLLABICS CARRIER DZO;Lo;0;L;;;;;N;;;;;\n164A;CANADIAN SYLLABICS CARRIER DZE;Lo;0;L;;;;;N;;;;;\n164B;CANADIAN SYLLABICS CARRIER DZEE;Lo;0;L;;;;;N;;;;;\n164C;CANADIAN SYLLABICS CARRIER DZI;Lo;0;L;;;;;N;;;;;\n164D;CANADIAN SYLLABICS CARRIER DZA;Lo;0;L;;;;;N;;;;;\n164E;CANADIAN SYLLABICS CARRIER SU;Lo;0;L;;;;;N;;;;;\n164F;CANADIAN SYLLABICS CARRIER SO;Lo;0;L;;;;;N;;;;;\n1650;CANADIAN SYLLABICS CARRIER SE;Lo;0;L;;;;;N;;;;;\n1651;CANADIAN SYLLABICS CARRIER SEE;Lo;0;L;;;;;N;;;;;\n1652;CANADIAN SYLLABICS CARRIER SI;Lo;0;L;;;;;N;;;;;\n1653;CANADIAN SYLLABICS CARRIER SA;Lo;0;L;;;;;N;;;;;\n1654;CANADIAN SYLLABICS CARRIER SHU;Lo;0;L;;;;;N;;;;;\n1655;CANADIAN SYLLABICS CARRIER SHO;Lo;0;L;;;;;N;;;;;\n1656;CANADIAN SYLLABICS CARRIER SHE;Lo;0;L;;;;;N;;;;;\n1657;CANADIAN SYLLABICS CARRIER SHEE;Lo;0;L;;;;;N;;;;;\n1658;CANADIAN SYLLABICS CARRIER SHI;Lo;0;L;;;;;N;;;;;\n1659;CANADIAN SYLLABICS CARRIER SHA;Lo;0;L;;;;;N;;;;;\n165A;CANADIAN SYLLABICS CARRIER SH;Lo;0;L;;;;;N;;;;;\n165B;CANADIAN SYLLABICS CARRIER TSU;Lo;0;L;;;;;N;;;;;\n165C;CANADIAN SYLLABICS CARRIER TSO;Lo;0;L;;;;;N;;;;;\n165D;CANADIAN SYLLABICS CARRIER TSE;Lo;0;L;;;;;N;;;;;\n165E;CANADIAN SYLLABICS CARRIER TSEE;Lo;0;L;;;;;N;;;;;\n165F;CANADIAN SYLLABICS CARRIER TSI;Lo;0;L;;;;;N;;;;;\n1660;CANADIAN SYLLABICS CARRIER TSA;Lo;0;L;;;;;N;;;;;\n1661;CANADIAN SYLLABICS CARRIER CHU;Lo;0;L;;;;;N;;;;;\n1662;CANADIAN SYLLABICS CARRIER CHO;Lo;0;L;;;;;N;;;;;\n1663;CANADIAN SYLLABICS CARRIER CHE;Lo;0;L;;;;;N;;;;;\n1664;CANADIAN SYLLABICS CARRIER CHEE;Lo;0;L;;;;;N;;;;;\n1665;CANADIAN SYLLABICS CARRIER CHI;Lo;0;L;;;;;N;;;;;\n1666;CANADIAN SYLLABICS CARRIER CHA;Lo;0;L;;;;;N;;;;;\n1667;CANADIAN SYLLABICS CARRIER TTSU;Lo;0;L;;;;;N;;;;;\n1668;CANADIAN SYLLABICS CARRIER TTSO;Lo;0;L;;;;;N;;;;;\n1669;CANADIAN SYLLABICS CARRIER TTSE;Lo;0;L;;;;;N;;;;;\n166A;CANADIAN SYLLABICS CARRIER TTSEE;Lo;0;L;;;;;N;;;;;\n166B;CANADIAN SYLLABICS CARRIER TTSI;Lo;0;L;;;;;N;;;;;\n166C;CANADIAN SYLLABICS CARRIER TTSA;Lo;0;L;;;;;N;;;;;\n166D;CANADIAN SYLLABICS CHI SIGN;Po;0;L;;;;;N;;;;;\n166E;CANADIAN SYLLABICS FULL STOP;Po;0;L;;;;;N;;;;;\n166F;CANADIAN SYLLABICS QAI;Lo;0;L;;;;;N;;;;;\n1670;CANADIAN SYLLABICS NGAI;Lo;0;L;;;;;N;;;;;\n1671;CANADIAN SYLLABICS NNGI;Lo;0;L;;;;;N;;;;;\n1672;CANADIAN SYLLABICS NNGII;Lo;0;L;;;;;N;;;;;\n1673;CANADIAN SYLLABICS NNGO;Lo;0;L;;;;;N;;;;;\n1674;CANADIAN SYLLABICS NNGOO;Lo;0;L;;;;;N;;;;;\n1675;CANADIAN SYLLABICS NNGA;Lo;0;L;;;;;N;;;;;\n1676;CANADIAN SYLLABICS NNGAA;Lo;0;L;;;;;N;;;;;\n1677;CANADIAN SYLLABICS WOODS-CREE THWEE;Lo;0;L;;;;;N;;;;;\n1678;CANADIAN SYLLABICS WOODS-CREE THWI;Lo;0;L;;;;;N;;;;;\n1679;CANADIAN SYLLABICS WOODS-CREE THWII;Lo;0;L;;;;;N;;;;;\n167A;CANADIAN SYLLABICS WOODS-CREE THWO;Lo;0;L;;;;;N;;;;;\n167B;CANADIAN SYLLABICS WOODS-CREE THWOO;Lo;0;L;;;;;N;;;;;\n167C;CANADIAN SYLLABICS WOODS-CREE THWA;Lo;0;L;;;;;N;;;;;\n167D;CANADIAN SYLLABICS WOODS-CREE THWAA;Lo;0;L;;;;;N;;;;;\n167E;CANADIAN SYLLABICS WOODS-CREE FINAL TH;Lo;0;L;;;;;N;;;;;\n167F;CANADIAN SYLLABICS BLACKFOOT W;Lo;0;L;;;;;N;;;;;\n1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;\n1681;OGHAM LETTER BEITH;Lo;0;L;;;;;N;;;;;\n1682;OGHAM LETTER LUIS;Lo;0;L;;;;;N;;;;;\n1683;OGHAM LETTER FEARN;Lo;0;L;;;;;N;;;;;\n1684;OGHAM LETTER SAIL;Lo;0;L;;;;;N;;;;;\n1685;OGHAM LETTER NION;Lo;0;L;;;;;N;;;;;\n1686;OGHAM LETTER UATH;Lo;0;L;;;;;N;;;;;\n1687;OGHAM LETTER DAIR;Lo;0;L;;;;;N;;;;;\n1688;OGHAM LETTER TINNE;Lo;0;L;;;;;N;;;;;\n1689;OGHAM LETTER COLL;Lo;0;L;;;;;N;;;;;\n168A;OGHAM LETTER CEIRT;Lo;0;L;;;;;N;;;;;\n168B;OGHAM LETTER MUIN;Lo;0;L;;;;;N;;;;;\n168C;OGHAM LETTER GORT;Lo;0;L;;;;;N;;;;;\n168D;OGHAM LETTER NGEADAL;Lo;0;L;;;;;N;;;;;\n168E;OGHAM LETTER STRAIF;Lo;0;L;;;;;N;;;;;\n168F;OGHAM LETTER RUIS;Lo;0;L;;;;;N;;;;;\n1690;OGHAM LETTER AILM;Lo;0;L;;;;;N;;;;;\n1691;OGHAM LETTER ONN;Lo;0;L;;;;;N;;;;;\n1692;OGHAM LETTER UR;Lo;0;L;;;;;N;;;;;\n1693;OGHAM LETTER EADHADH;Lo;0;L;;;;;N;;;;;\n1694;OGHAM LETTER IODHADH;Lo;0;L;;;;;N;;;;;\n1695;OGHAM LETTER EABHADH;Lo;0;L;;;;;N;;;;;\n1696;OGHAM LETTER OR;Lo;0;L;;;;;N;;;;;\n1697;OGHAM LETTER UILLEANN;Lo;0;L;;;;;N;;;;;\n1698;OGHAM LETTER IFIN;Lo;0;L;;;;;N;;;;;\n1699;OGHAM LETTER EAMHANCHOLL;Lo;0;L;;;;;N;;;;;\n169A;OGHAM LETTER PEITH;Lo;0;L;;;;;N;;;;;\n169B;OGHAM FEATHER MARK;Ps;0;ON;;;;;Y;;;;;\n169C;OGHAM REVERSED FEATHER MARK;Pe;0;ON;;;;;Y;;;;;\n16A0;RUNIC LETTER FEHU FEOH FE F;Lo;0;L;;;;;N;;;;;\n16A1;RUNIC LETTER V;Lo;0;L;;;;;N;;;;;\n16A2;RUNIC LETTER URUZ UR U;Lo;0;L;;;;;N;;;;;\n16A3;RUNIC LETTER YR;Lo;0;L;;;;;N;;;;;\n16A4;RUNIC LETTER Y;Lo;0;L;;;;;N;;;;;\n16A5;RUNIC LETTER W;Lo;0;L;;;;;N;;;;;\n16A6;RUNIC LETTER THURISAZ THURS THORN;Lo;0;L;;;;;N;;;;;\n16A7;RUNIC LETTER ETH;Lo;0;L;;;;;N;;;;;\n16A8;RUNIC LETTER ANSUZ A;Lo;0;L;;;;;N;;;;;\n16A9;RUNIC LETTER OS O;Lo;0;L;;;;;N;;;;;\n16AA;RUNIC LETTER AC A;Lo;0;L;;;;;N;;;;;\n16AB;RUNIC LETTER AESC;Lo;0;L;;;;;N;;;;;\n16AC;RUNIC LETTER LONG-BRANCH-OSS O;Lo;0;L;;;;;N;;;;;\n16AD;RUNIC LETTER SHORT-TWIG-OSS O;Lo;0;L;;;;;N;;;;;\n16AE;RUNIC LETTER O;Lo;0;L;;;;;N;;;;;\n16AF;RUNIC LETTER OE;Lo;0;L;;;;;N;;;;;\n16B0;RUNIC LETTER ON;Lo;0;L;;;;;N;;;;;\n16B1;RUNIC LETTER RAIDO RAD REID R;Lo;0;L;;;;;N;;;;;\n16B2;RUNIC LETTER KAUNA;Lo;0;L;;;;;N;;;;;\n16B3;RUNIC LETTER CEN;Lo;0;L;;;;;N;;;;;\n16B4;RUNIC LETTER KAUN K;Lo;0;L;;;;;N;;;;;\n16B5;RUNIC LETTER G;Lo;0;L;;;;;N;;;;;\n16B6;RUNIC LETTER ENG;Lo;0;L;;;;;N;;;;;\n16B7;RUNIC LETTER GEBO GYFU G;Lo;0;L;;;;;N;;;;;\n16B8;RUNIC LETTER GAR;Lo;0;L;;;;;N;;;;;\n16B9;RUNIC LETTER WUNJO WYNN W;Lo;0;L;;;;;N;;;;;\n16BA;RUNIC LETTER HAGLAZ H;Lo;0;L;;;;;N;;;;;\n16BB;RUNIC LETTER HAEGL H;Lo;0;L;;;;;N;;;;;\n16BC;RUNIC LETTER LONG-BRANCH-HAGALL H;Lo;0;L;;;;;N;;;;;\n16BD;RUNIC LETTER SHORT-TWIG-HAGALL H;Lo;0;L;;;;;N;;;;;\n16BE;RUNIC LETTER NAUDIZ NYD NAUD N;Lo;0;L;;;;;N;;;;;\n16BF;RUNIC LETTER SHORT-TWIG-NAUD N;Lo;0;L;;;;;N;;;;;\n16C0;RUNIC LETTER DOTTED-N;Lo;0;L;;;;;N;;;;;\n16C1;RUNIC LETTER ISAZ IS ISS I;Lo;0;L;;;;;N;;;;;\n16C2;RUNIC LETTER E;Lo;0;L;;;;;N;;;;;\n16C3;RUNIC LETTER JERAN J;Lo;0;L;;;;;N;;;;;\n16C4;RUNIC LETTER GER;Lo;0;L;;;;;N;;;;;\n16C5;RUNIC LETTER LONG-BRANCH-AR AE;Lo;0;L;;;;;N;;;;;\n16C6;RUNIC LETTER SHORT-TWIG-AR A;Lo;0;L;;;;;N;;;;;\n16C7;RUNIC LETTER IWAZ EOH;Lo;0;L;;;;;N;;;;;\n16C8;RUNIC LETTER PERTHO PEORTH P;Lo;0;L;;;;;N;;;;;\n16C9;RUNIC LETTER ALGIZ EOLHX;Lo;0;L;;;;;N;;;;;\n16CA;RUNIC LETTER SOWILO S;Lo;0;L;;;;;N;;;;;\n16CB;RUNIC LETTER SIGEL LONG-BRANCH-SOL S;Lo;0;L;;;;;N;;;;;\n16CC;RUNIC LETTER SHORT-TWIG-SOL S;Lo;0;L;;;;;N;;;;;\n16CD;RUNIC LETTER C;Lo;0;L;;;;;N;;;;;\n16CE;RUNIC LETTER Z;Lo;0;L;;;;;N;;;;;\n16CF;RUNIC LETTER TIWAZ TIR TYR T;Lo;0;L;;;;;N;;;;;\n16D0;RUNIC LETTER SHORT-TWIG-TYR T;Lo;0;L;;;;;N;;;;;\n16D1;RUNIC LETTER D;Lo;0;L;;;;;N;;;;;\n16D2;RUNIC LETTER BERKANAN BEORC BJARKAN B;Lo;0;L;;;;;N;;;;;\n16D3;RUNIC LETTER SHORT-TWIG-BJARKAN B;Lo;0;L;;;;;N;;;;;\n16D4;RUNIC LETTER DOTTED-P;Lo;0;L;;;;;N;;;;;\n16D5;RUNIC LETTER OPEN-P;Lo;0;L;;;;;N;;;;;\n16D6;RUNIC LETTER EHWAZ EH E;Lo;0;L;;;;;N;;;;;\n16D7;RUNIC LETTER MANNAZ MAN M;Lo;0;L;;;;;N;;;;;\n16D8;RUNIC LETTER LONG-BRANCH-MADR M;Lo;0;L;;;;;N;;;;;\n16D9;RUNIC LETTER SHORT-TWIG-MADR M;Lo;0;L;;;;;N;;;;;\n16DA;RUNIC LETTER LAUKAZ LAGU LOGR L;Lo;0;L;;;;;N;;;;;\n16DB;RUNIC LETTER DOTTED-L;Lo;0;L;;;;;N;;;;;\n16DC;RUNIC LETTER INGWAZ;Lo;0;L;;;;;N;;;;;\n16DD;RUNIC LETTER ING;Lo;0;L;;;;;N;;;;;\n16DE;RUNIC LETTER DAGAZ DAEG D;Lo;0;L;;;;;N;;;;;\n16DF;RUNIC LETTER OTHALAN ETHEL O;Lo;0;L;;;;;N;;;;;\n16E0;RUNIC LETTER EAR;Lo;0;L;;;;;N;;;;;\n16E1;RUNIC LETTER IOR;Lo;0;L;;;;;N;;;;;\n16E2;RUNIC LETTER CWEORTH;Lo;0;L;;;;;N;;;;;\n16E3;RUNIC LETTER CALC;Lo;0;L;;;;;N;;;;;\n16E4;RUNIC LETTER CEALC;Lo;0;L;;;;;N;;;;;\n16E5;RUNIC LETTER STAN;Lo;0;L;;;;;N;;;;;\n16E6;RUNIC LETTER LONG-BRANCH-YR;Lo;0;L;;;;;N;;;;;\n16E7;RUNIC LETTER SHORT-TWIG-YR;Lo;0;L;;;;;N;;;;;\n16E8;RUNIC LETTER ICELANDIC-YR;Lo;0;L;;;;;N;;;;;\n16E9;RUNIC LETTER Q;Lo;0;L;;;;;N;;;;;\n16EA;RUNIC LETTER X;Lo;0;L;;;;;N;;;;;\n16EB;RUNIC SINGLE PUNCTUATION;Po;0;L;;;;;N;;;;;\n16EC;RUNIC MULTIPLE PUNCTUATION;Po;0;L;;;;;N;;;;;\n16ED;RUNIC CROSS PUNCTUATION;Po;0;L;;;;;N;;;;;\n16EE;RUNIC ARLAUG SYMBOL;Nl;0;L;;;;17;N;;;;;\n16EF;RUNIC TVIMADUR SYMBOL;Nl;0;L;;;;18;N;;;;;\n16F0;RUNIC BELGTHOR SYMBOL;Nl;0;L;;;;19;N;;;;;\n1700;TAGALOG LETTER A;Lo;0;L;;;;;N;;;;;\n1701;TAGALOG LETTER I;Lo;0;L;;;;;N;;;;;\n1702;TAGALOG LETTER U;Lo;0;L;;;;;N;;;;;\n1703;TAGALOG LETTER KA;Lo;0;L;;;;;N;;;;;\n1704;TAGALOG LETTER GA;Lo;0;L;;;;;N;;;;;\n1705;TAGALOG LETTER NGA;Lo;0;L;;;;;N;;;;;\n1706;TAGALOG LETTER TA;Lo;0;L;;;;;N;;;;;\n1707;TAGALOG LETTER DA;Lo;0;L;;;;;N;;;;;\n1708;TAGALOG LETTER NA;Lo;0;L;;;;;N;;;;;\n1709;TAGALOG LETTER PA;Lo;0;L;;;;;N;;;;;\n170A;TAGALOG LETTER BA;Lo;0;L;;;;;N;;;;;\n170B;TAGALOG LETTER MA;Lo;0;L;;;;;N;;;;;\n170C;TAGALOG LETTER YA;Lo;0;L;;;;;N;;;;;\n170E;TAGALOG LETTER LA;Lo;0;L;;;;;N;;;;;\n170F;TAGALOG LETTER WA;Lo;0;L;;;;;N;;;;;\n1710;TAGALOG LETTER SA;Lo;0;L;;;;;N;;;;;\n1711;TAGALOG LETTER HA;Lo;0;L;;;;;N;;;;;\n1712;TAGALOG VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1713;TAGALOG VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1714;TAGALOG SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n1720;HANUNOO LETTER A;Lo;0;L;;;;;N;;;;;\n1721;HANUNOO LETTER I;Lo;0;L;;;;;N;;;;;\n1722;HANUNOO LETTER U;Lo;0;L;;;;;N;;;;;\n1723;HANUNOO LETTER KA;Lo;0;L;;;;;N;;;;;\n1724;HANUNOO LETTER GA;Lo;0;L;;;;;N;;;;;\n1725;HANUNOO LETTER NGA;Lo;0;L;;;;;N;;;;;\n1726;HANUNOO LETTER TA;Lo;0;L;;;;;N;;;;;\n1727;HANUNOO LETTER DA;Lo;0;L;;;;;N;;;;;\n1728;HANUNOO LETTER NA;Lo;0;L;;;;;N;;;;;\n1729;HANUNOO LETTER PA;Lo;0;L;;;;;N;;;;;\n172A;HANUNOO LETTER BA;Lo;0;L;;;;;N;;;;;\n172B;HANUNOO LETTER MA;Lo;0;L;;;;;N;;;;;\n172C;HANUNOO LETTER YA;Lo;0;L;;;;;N;;;;;\n172D;HANUNOO LETTER RA;Lo;0;L;;;;;N;;;;;\n172E;HANUNOO LETTER LA;Lo;0;L;;;;;N;;;;;\n172F;HANUNOO LETTER WA;Lo;0;L;;;;;N;;;;;\n1730;HANUNOO LETTER SA;Lo;0;L;;;;;N;;;;;\n1731;HANUNOO LETTER HA;Lo;0;L;;;;;N;;;;;\n1732;HANUNOO VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1733;HANUNOO VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1734;HANUNOO SIGN PAMUDPOD;Mn;9;NSM;;;;;N;;;;;\n1735;PHILIPPINE SINGLE PUNCTUATION;Po;0;L;;;;;N;;;;;\n1736;PHILIPPINE DOUBLE PUNCTUATION;Po;0;L;;;;;N;;;;;\n1740;BUHID LETTER A;Lo;0;L;;;;;N;;;;;\n1741;BUHID LETTER I;Lo;0;L;;;;;N;;;;;\n1742;BUHID LETTER U;Lo;0;L;;;;;N;;;;;\n1743;BUHID LETTER KA;Lo;0;L;;;;;N;;;;;\n1744;BUHID LETTER GA;Lo;0;L;;;;;N;;;;;\n1745;BUHID LETTER NGA;Lo;0;L;;;;;N;;;;;\n1746;BUHID LETTER TA;Lo;0;L;;;;;N;;;;;\n1747;BUHID LETTER DA;Lo;0;L;;;;;N;;;;;\n1748;BUHID LETTER NA;Lo;0;L;;;;;N;;;;;\n1749;BUHID LETTER PA;Lo;0;L;;;;;N;;;;;\n174A;BUHID LETTER BA;Lo;0;L;;;;;N;;;;;\n174B;BUHID LETTER MA;Lo;0;L;;;;;N;;;;;\n174C;BUHID LETTER YA;Lo;0;L;;;;;N;;;;;\n174D;BUHID LETTER RA;Lo;0;L;;;;;N;;;;;\n174E;BUHID LETTER LA;Lo;0;L;;;;;N;;;;;\n174F;BUHID LETTER WA;Lo;0;L;;;;;N;;;;;\n1750;BUHID LETTER SA;Lo;0;L;;;;;N;;;;;\n1751;BUHID LETTER HA;Lo;0;L;;;;;N;;;;;\n1752;BUHID VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1753;BUHID VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1760;TAGBANWA LETTER A;Lo;0;L;;;;;N;;;;;\n1761;TAGBANWA LETTER I;Lo;0;L;;;;;N;;;;;\n1762;TAGBANWA LETTER U;Lo;0;L;;;;;N;;;;;\n1763;TAGBANWA LETTER KA;Lo;0;L;;;;;N;;;;;\n1764;TAGBANWA LETTER GA;Lo;0;L;;;;;N;;;;;\n1765;TAGBANWA LETTER NGA;Lo;0;L;;;;;N;;;;;\n1766;TAGBANWA LETTER TA;Lo;0;L;;;;;N;;;;;\n1767;TAGBANWA LETTER DA;Lo;0;L;;;;;N;;;;;\n1768;TAGBANWA LETTER NA;Lo;0;L;;;;;N;;;;;\n1769;TAGBANWA LETTER PA;Lo;0;L;;;;;N;;;;;\n176A;TAGBANWA LETTER BA;Lo;0;L;;;;;N;;;;;\n176B;TAGBANWA LETTER MA;Lo;0;L;;;;;N;;;;;\n176C;TAGBANWA LETTER YA;Lo;0;L;;;;;N;;;;;\n176E;TAGBANWA LETTER LA;Lo;0;L;;;;;N;;;;;\n176F;TAGBANWA LETTER WA;Lo;0;L;;;;;N;;;;;\n1770;TAGBANWA LETTER SA;Lo;0;L;;;;;N;;;;;\n1772;TAGBANWA VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1773;TAGBANWA VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1780;KHMER LETTER KA;Lo;0;L;;;;;N;;;;;\n1781;KHMER LETTER KHA;Lo;0;L;;;;;N;;;;;\n1782;KHMER LETTER KO;Lo;0;L;;;;;N;;;;;\n1783;KHMER LETTER KHO;Lo;0;L;;;;;N;;;;;\n1784;KHMER LETTER NGO;Lo;0;L;;;;;N;;;;;\n1785;KHMER LETTER CA;Lo;0;L;;;;;N;;;;;\n1786;KHMER LETTER CHA;Lo;0;L;;;;;N;;;;;\n1787;KHMER LETTER CO;Lo;0;L;;;;;N;;;;;\n1788;KHMER LETTER CHO;Lo;0;L;;;;;N;;;;;\n1789;KHMER LETTER NYO;Lo;0;L;;;;;N;;;;;\n178A;KHMER LETTER DA;Lo;0;L;;;;;N;;;;;\n178B;KHMER LETTER TTHA;Lo;0;L;;;;;N;;;;;\n178C;KHMER LETTER DO;Lo;0;L;;;;;N;;;;;\n178D;KHMER LETTER TTHO;Lo;0;L;;;;;N;;;;;\n178E;KHMER LETTER NNO;Lo;0;L;;;;;N;;;;;\n178F;KHMER LETTER TA;Lo;0;L;;;;;N;;;;;\n1790;KHMER LETTER THA;Lo;0;L;;;;;N;;;;;\n1791;KHMER LETTER TO;Lo;0;L;;;;;N;;;;;\n1792;KHMER LETTER THO;Lo;0;L;;;;;N;;;;;\n1793;KHMER LETTER NO;Lo;0;L;;;;;N;;;;;\n1794;KHMER LETTER BA;Lo;0;L;;;;;N;;;;;\n1795;KHMER LETTER PHA;Lo;0;L;;;;;N;;;;;\n1796;KHMER LETTER PO;Lo;0;L;;;;;N;;;;;\n1797;KHMER LETTER PHO;Lo;0;L;;;;;N;;;;;\n1798;KHMER LETTER MO;Lo;0;L;;;;;N;;;;;\n1799;KHMER LETTER YO;Lo;0;L;;;;;N;;;;;\n179A;KHMER LETTER RO;Lo;0;L;;;;;N;;;;;\n179B;KHMER LETTER LO;Lo;0;L;;;;;N;;;;;\n179C;KHMER LETTER VO;Lo;0;L;;;;;N;;;;;\n179D;KHMER LETTER SHA;Lo;0;L;;;;;N;;;;;\n179E;KHMER LETTER SSO;Lo;0;L;;;;;N;;;;;\n179F;KHMER LETTER SA;Lo;0;L;;;;;N;;;;;\n17A0;KHMER LETTER HA;Lo;0;L;;;;;N;;;;;\n17A1;KHMER LETTER LA;Lo;0;L;;;;;N;;;;;\n17A2;KHMER LETTER QA;Lo;0;L;;;;;N;;;;;\n17A3;KHMER INDEPENDENT VOWEL QAQ;Lo;0;L;;;;;N;;;;;\n17A4;KHMER INDEPENDENT VOWEL QAA;Lo;0;L;;;;;N;;;;;\n17A5;KHMER INDEPENDENT VOWEL QI;Lo;0;L;;;;;N;;;;;\n17A6;KHMER INDEPENDENT VOWEL QII;Lo;0;L;;;;;N;;;;;\n17A7;KHMER INDEPENDENT VOWEL QU;Lo;0;L;;;;;N;;;;;\n17A8;KHMER INDEPENDENT VOWEL QUK;Lo;0;L;;;;;N;;;;;\n17A9;KHMER INDEPENDENT VOWEL QUU;Lo;0;L;;;;;N;;;;;\n17AA;KHMER INDEPENDENT VOWEL QUUV;Lo;0;L;;;;;N;;;;;\n17AB;KHMER INDEPENDENT VOWEL RY;Lo;0;L;;;;;N;;;;;\n17AC;KHMER INDEPENDENT VOWEL RYY;Lo;0;L;;;;;N;;;;;\n17AD;KHMER INDEPENDENT VOWEL LY;Lo;0;L;;;;;N;;;;;\n17AE;KHMER INDEPENDENT VOWEL LYY;Lo;0;L;;;;;N;;;;;\n17AF;KHMER INDEPENDENT VOWEL QE;Lo;0;L;;;;;N;;;;;\n17B0;KHMER INDEPENDENT VOWEL QAI;Lo;0;L;;;;;N;;;;;\n17B1;KHMER INDEPENDENT VOWEL QOO TYPE ONE;Lo;0;L;;;;;N;;;;;\n17B2;KHMER INDEPENDENT VOWEL QOO TYPE TWO;Lo;0;L;;;;;N;;;;;\n17B3;KHMER INDEPENDENT VOWEL QAU;Lo;0;L;;;;;N;;;;;\n17B4;KHMER VOWEL INHERENT AQ;Mn;0;NSM;;;;;N;;;;;\n17B5;KHMER VOWEL INHERENT AA;Mn;0;NSM;;;;;N;;;;;\n17B6;KHMER VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n17B7;KHMER VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n17B8;KHMER VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n17B9;KHMER VOWEL SIGN Y;Mn;0;NSM;;;;;N;;;;;\n17BA;KHMER VOWEL SIGN YY;Mn;0;NSM;;;;;N;;;;;\n17BB;KHMER VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n17BC;KHMER VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n17BD;KHMER VOWEL SIGN UA;Mn;0;NSM;;;;;N;;;;;\n17BE;KHMER VOWEL SIGN OE;Mc;0;L;;;;;N;;;;;\n17BF;KHMER VOWEL SIGN YA;Mc;0;L;;;;;N;;;;;\n17C0;KHMER VOWEL SIGN IE;Mc;0;L;;;;;N;;;;;\n17C1;KHMER VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n17C2;KHMER VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;\n17C3;KHMER VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n17C4;KHMER VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\n17C5;KHMER VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n17C6;KHMER SIGN NIKAHIT;Mn;0;NSM;;;;;N;;;;;\n17C7;KHMER SIGN REAHMUK;Mc;0;L;;;;;N;;;;;\n17C8;KHMER SIGN YUUKALEAPINTU;Mc;0;L;;;;;N;;;;;\n17C9;KHMER SIGN MUUSIKATOAN;Mn;0;NSM;;;;;N;;;;;\n17CA;KHMER SIGN TRIISAP;Mn;0;NSM;;;;;N;;;;;\n17CB;KHMER SIGN BANTOC;Mn;0;NSM;;;;;N;;;;;\n17CC;KHMER SIGN ROBAT;Mn;0;NSM;;;;;N;;;;;\n17CD;KHMER SIGN TOANDAKHIAT;Mn;0;NSM;;;;;N;;;;;\n17CE;KHMER SIGN KAKABAT;Mn;0;NSM;;;;;N;;;;;\n17CF;KHMER SIGN AHSDA;Mn;0;NSM;;;;;N;;;;;\n17D0;KHMER SIGN SAMYOK SANNYA;Mn;0;NSM;;;;;N;;;;;\n17D1;KHMER SIGN VIRIAM;Mn;0;NSM;;;;;N;;;;;\n17D2;KHMER SIGN COENG;Mn;9;NSM;;;;;N;;;;;\n17D3;KHMER SIGN BATHAMASAT;Mn;0;NSM;;;;;N;;;;;\n17D4;KHMER SIGN KHAN;Po;0;L;;;;;N;;;;;\n17D5;KHMER SIGN BARIYOOSAN;Po;0;L;;;;;N;;;;;\n17D6;KHMER SIGN CAMNUC PII KUUH;Po;0;L;;;;;N;;;;;\n17D7;KHMER SIGN LEK TOO;Lm;0;L;;;;;N;;;;;\n17D8;KHMER SIGN BEYYAL;Po;0;L;;;;;N;;;;;\n17D9;KHMER SIGN PHNAEK MUAN;Po;0;L;;;;;N;;;;;\n17DA;KHMER SIGN KOOMUUT;Po;0;L;;;;;N;;;;;\n17DB;KHMER CURRENCY SYMBOL RIEL;Sc;0;ET;;;;;N;;;;;\n17DC;KHMER SIGN AVAKRAHASANYA;Lo;0;L;;;;;N;;;;;\n17DD;KHMER SIGN ATTHACAN;Mn;230;NSM;;;;;N;;;;;\n17E0;KHMER DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n17E1;KHMER DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n17E2;KHMER DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n17E3;KHMER DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n17E4;KHMER DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n17E5;KHMER DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n17E6;KHMER DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n17E7;KHMER DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n17E8;KHMER DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n17E9;KHMER DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n17F0;KHMER SYMBOL LEK ATTAK SON;No;0;ON;;;;0;N;;;;;\n17F1;KHMER SYMBOL LEK ATTAK MUOY;No;0;ON;;;;1;N;;;;;\n17F2;KHMER SYMBOL LEK ATTAK PII;No;0;ON;;;;2;N;;;;;\n17F3;KHMER SYMBOL LEK ATTAK BEI;No;0;ON;;;;3;N;;;;;\n17F4;KHMER SYMBOL LEK ATTAK BUON;No;0;ON;;;;4;N;;;;;\n17F5;KHMER SYMBOL LEK ATTAK PRAM;No;0;ON;;;;5;N;;;;;\n17F6;KHMER SYMBOL LEK ATTAK PRAM-MUOY;No;0;ON;;;;6;N;;;;;\n17F7;KHMER SYMBOL LEK ATTAK PRAM-PII;No;0;ON;;;;7;N;;;;;\n17F8;KHMER SYMBOL LEK ATTAK PRAM-BEI;No;0;ON;;;;8;N;;;;;\n17F9;KHMER SYMBOL LEK ATTAK PRAM-BUON;No;0;ON;;;;9;N;;;;;\n1800;MONGOLIAN BIRGA;Po;0;ON;;;;;N;;;;;\n1801;MONGOLIAN ELLIPSIS;Po;0;ON;;;;;N;;;;;\n1802;MONGOLIAN COMMA;Po;0;ON;;;;;N;;;;;\n1803;MONGOLIAN FULL STOP;Po;0;ON;;;;;N;;;;;\n1804;MONGOLIAN COLON;Po;0;ON;;;;;N;;;;;\n1805;MONGOLIAN FOUR DOTS;Po;0;ON;;;;;N;;;;;\n1806;MONGOLIAN TODO SOFT HYPHEN;Pd;0;ON;;;;;N;;;;;\n1807;MONGOLIAN SIBE SYLLABLE BOUNDARY MARKER;Po;0;ON;;;;;N;;;;;\n1808;MONGOLIAN MANCHU COMMA;Po;0;ON;;;;;N;;;;;\n1809;MONGOLIAN MANCHU FULL STOP;Po;0;ON;;;;;N;;;;;\n180A;MONGOLIAN NIRUGU;Po;0;ON;;;;;N;;;;;\n180B;MONGOLIAN FREE VARIATION SELECTOR ONE;Mn;0;NSM;;;;;N;;;;;\n180C;MONGOLIAN FREE VARIATION SELECTOR TWO;Mn;0;NSM;;;;;N;;;;;\n180D;MONGOLIAN FREE VARIATION SELECTOR THREE;Mn;0;NSM;;;;;N;;;;;\n180E;MONGOLIAN VOWEL SEPARATOR;Zs;0;WS;;;;;N;;;;;\n1810;MONGOLIAN DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1811;MONGOLIAN DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1812;MONGOLIAN DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1813;MONGOLIAN DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1814;MONGOLIAN DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1815;MONGOLIAN DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1816;MONGOLIAN DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1817;MONGOLIAN DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1818;MONGOLIAN DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1819;MONGOLIAN DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1820;MONGOLIAN LETTER A;Lo;0;L;;;;;N;;;;;\n1821;MONGOLIAN LETTER E;Lo;0;L;;;;;N;;;;;\n1822;MONGOLIAN LETTER I;Lo;0;L;;;;;N;;;;;\n1823;MONGOLIAN LETTER O;Lo;0;L;;;;;N;;;;;\n1824;MONGOLIAN LETTER U;Lo;0;L;;;;;N;;;;;\n1825;MONGOLIAN LETTER OE;Lo;0;L;;;;;N;;;;;\n1826;MONGOLIAN LETTER UE;Lo;0;L;;;;;N;;;;;\n1827;MONGOLIAN LETTER EE;Lo;0;L;;;;;N;;;;;\n1828;MONGOLIAN LETTER NA;Lo;0;L;;;;;N;;;;;\n1829;MONGOLIAN LETTER ANG;Lo;0;L;;;;;N;;;;;\n182A;MONGOLIAN LETTER BA;Lo;0;L;;;;;N;;;;;\n182B;MONGOLIAN LETTER PA;Lo;0;L;;;;;N;;;;;\n182C;MONGOLIAN LETTER QA;Lo;0;L;;;;;N;;;;;\n182D;MONGOLIAN LETTER GA;Lo;0;L;;;;;N;;;;;\n182E;MONGOLIAN LETTER MA;Lo;0;L;;;;;N;;;;;\n182F;MONGOLIAN LETTER LA;Lo;0;L;;;;;N;;;;;\n1830;MONGOLIAN LETTER SA;Lo;0;L;;;;;N;;;;;\n1831;MONGOLIAN LETTER SHA;Lo;0;L;;;;;N;;;;;\n1832;MONGOLIAN LETTER TA;Lo;0;L;;;;;N;;;;;\n1833;MONGOLIAN LETTER DA;Lo;0;L;;;;;N;;;;;\n1834;MONGOLIAN LETTER CHA;Lo;0;L;;;;;N;;;;;\n1835;MONGOLIAN LETTER JA;Lo;0;L;;;;;N;;;;;\n1836;MONGOLIAN LETTER YA;Lo;0;L;;;;;N;;;;;\n1837;MONGOLIAN LETTER RA;Lo;0;L;;;;;N;;;;;\n1838;MONGOLIAN LETTER WA;Lo;0;L;;;;;N;;;;;\n1839;MONGOLIAN LETTER FA;Lo;0;L;;;;;N;;;;;\n183A;MONGOLIAN LETTER KA;Lo;0;L;;;;;N;;;;;\n183B;MONGOLIAN LETTER KHA;Lo;0;L;;;;;N;;;;;\n183C;MONGOLIAN LETTER TSA;Lo;0;L;;;;;N;;;;;\n183D;MONGOLIAN LETTER ZA;Lo;0;L;;;;;N;;;;;\n183E;MONGOLIAN LETTER HAA;Lo;0;L;;;;;N;;;;;\n183F;MONGOLIAN LETTER ZRA;Lo;0;L;;;;;N;;;;;\n1840;MONGOLIAN LETTER LHA;Lo;0;L;;;;;N;;;;;\n1841;MONGOLIAN LETTER ZHI;Lo;0;L;;;;;N;;;;;\n1842;MONGOLIAN LETTER CHI;Lo;0;L;;;;;N;;;;;\n1843;MONGOLIAN LETTER TODO LONG VOWEL SIGN;Lm;0;L;;;;;N;;;;;\n1844;MONGOLIAN LETTER TODO E;Lo;0;L;;;;;N;;;;;\n1845;MONGOLIAN LETTER TODO I;Lo;0;L;;;;;N;;;;;\n1846;MONGOLIAN LETTER TODO O;Lo;0;L;;;;;N;;;;;\n1847;MONGOLIAN LETTER TODO U;Lo;0;L;;;;;N;;;;;\n1848;MONGOLIAN LETTER TODO OE;Lo;0;L;;;;;N;;;;;\n1849;MONGOLIAN LETTER TODO UE;Lo;0;L;;;;;N;;;;;\n184A;MONGOLIAN LETTER TODO ANG;Lo;0;L;;;;;N;;;;;\n184B;MONGOLIAN LETTER TODO BA;Lo;0;L;;;;;N;;;;;\n184C;MONGOLIAN LETTER TODO PA;Lo;0;L;;;;;N;;;;;\n184D;MONGOLIAN LETTER TODO QA;Lo;0;L;;;;;N;;;;;\n184E;MONGOLIAN LETTER TODO GA;Lo;0;L;;;;;N;;;;;\n184F;MONGOLIAN LETTER TODO MA;Lo;0;L;;;;;N;;;;;\n1850;MONGOLIAN LETTER TODO TA;Lo;0;L;;;;;N;;;;;\n1851;MONGOLIAN LETTER TODO DA;Lo;0;L;;;;;N;;;;;\n1852;MONGOLIAN LETTER TODO CHA;Lo;0;L;;;;;N;;;;;\n1853;MONGOLIAN LETTER TODO JA;Lo;0;L;;;;;N;;;;;\n1854;MONGOLIAN LETTER TODO TSA;Lo;0;L;;;;;N;;;;;\n1855;MONGOLIAN LETTER TODO YA;Lo;0;L;;;;;N;;;;;\n1856;MONGOLIAN LETTER TODO WA;Lo;0;L;;;;;N;;;;;\n1857;MONGOLIAN LETTER TODO KA;Lo;0;L;;;;;N;;;;;\n1858;MONGOLIAN LETTER TODO GAA;Lo;0;L;;;;;N;;;;;\n1859;MONGOLIAN LETTER TODO HAA;Lo;0;L;;;;;N;;;;;\n185A;MONGOLIAN LETTER TODO JIA;Lo;0;L;;;;;N;;;;;\n185B;MONGOLIAN LETTER TODO NIA;Lo;0;L;;;;;N;;;;;\n185C;MONGOLIAN LETTER TODO DZA;Lo;0;L;;;;;N;;;;;\n185D;MONGOLIAN LETTER SIBE E;Lo;0;L;;;;;N;;;;;\n185E;MONGOLIAN LETTER SIBE I;Lo;0;L;;;;;N;;;;;\n185F;MONGOLIAN LETTER SIBE IY;Lo;0;L;;;;;N;;;;;\n1860;MONGOLIAN LETTER SIBE UE;Lo;0;L;;;;;N;;;;;\n1861;MONGOLIAN LETTER SIBE U;Lo;0;L;;;;;N;;;;;\n1862;MONGOLIAN LETTER SIBE ANG;Lo;0;L;;;;;N;;;;;\n1863;MONGOLIAN LETTER SIBE KA;Lo;0;L;;;;;N;;;;;\n1864;MONGOLIAN LETTER SIBE GA;Lo;0;L;;;;;N;;;;;\n1865;MONGOLIAN LETTER SIBE HA;Lo;0;L;;;;;N;;;;;\n1866;MONGOLIAN LETTER SIBE PA;Lo;0;L;;;;;N;;;;;\n1867;MONGOLIAN LETTER SIBE SHA;Lo;0;L;;;;;N;;;;;\n1868;MONGOLIAN LETTER SIBE TA;Lo;0;L;;;;;N;;;;;\n1869;MONGOLIAN LETTER SIBE DA;Lo;0;L;;;;;N;;;;;\n186A;MONGOLIAN LETTER SIBE JA;Lo;0;L;;;;;N;;;;;\n186B;MONGOLIAN LETTER SIBE FA;Lo;0;L;;;;;N;;;;;\n186C;MONGOLIAN LETTER SIBE GAA;Lo;0;L;;;;;N;;;;;\n186D;MONGOLIAN LETTER SIBE HAA;Lo;0;L;;;;;N;;;;;\n186E;MONGOLIAN LETTER SIBE TSA;Lo;0;L;;;;;N;;;;;\n186F;MONGOLIAN LETTER SIBE ZA;Lo;0;L;;;;;N;;;;;\n1870;MONGOLIAN LETTER SIBE RAA;Lo;0;L;;;;;N;;;;;\n1871;MONGOLIAN LETTER SIBE CHA;Lo;0;L;;;;;N;;;;;\n1872;MONGOLIAN LETTER SIBE ZHA;Lo;0;L;;;;;N;;;;;\n1873;MONGOLIAN LETTER MANCHU I;Lo;0;L;;;;;N;;;;;\n1874;MONGOLIAN LETTER MANCHU KA;Lo;0;L;;;;;N;;;;;\n1875;MONGOLIAN LETTER MANCHU RA;Lo;0;L;;;;;N;;;;;\n1876;MONGOLIAN LETTER MANCHU FA;Lo;0;L;;;;;N;;;;;\n1877;MONGOLIAN LETTER MANCHU ZHA;Lo;0;L;;;;;N;;;;;\n1880;MONGOLIAN LETTER ALI GALI ANUSVARA ONE;Lo;0;L;;;;;N;;;;;\n1881;MONGOLIAN LETTER ALI GALI VISARGA ONE;Lo;0;L;;;;;N;;;;;\n1882;MONGOLIAN LETTER ALI GALI DAMARU;Lo;0;L;;;;;N;;;;;\n1883;MONGOLIAN LETTER ALI GALI UBADAMA;Lo;0;L;;;;;N;;;;;\n1884;MONGOLIAN LETTER ALI GALI INVERTED UBADAMA;Lo;0;L;;;;;N;;;;;\n1885;MONGOLIAN LETTER ALI GALI BALUDA;Lo;0;L;;;;;N;;;;;\n1886;MONGOLIAN LETTER ALI GALI THREE BALUDA;Lo;0;L;;;;;N;;;;;\n1887;MONGOLIAN LETTER ALI GALI A;Lo;0;L;;;;;N;;;;;\n1888;MONGOLIAN LETTER ALI GALI I;Lo;0;L;;;;;N;;;;;\n1889;MONGOLIAN LETTER ALI GALI KA;Lo;0;L;;;;;N;;;;;\n188A;MONGOLIAN LETTER ALI GALI NGA;Lo;0;L;;;;;N;;;;;\n188B;MONGOLIAN LETTER ALI GALI CA;Lo;0;L;;;;;N;;;;;\n188C;MONGOLIAN LETTER ALI GALI TTA;Lo;0;L;;;;;N;;;;;\n188D;MONGOLIAN LETTER ALI GALI TTHA;Lo;0;L;;;;;N;;;;;\n188E;MONGOLIAN LETTER ALI GALI DDA;Lo;0;L;;;;;N;;;;;\n188F;MONGOLIAN LETTER ALI GALI NNA;Lo;0;L;;;;;N;;;;;\n1890;MONGOLIAN LETTER ALI GALI TA;Lo;0;L;;;;;N;;;;;\n1891;MONGOLIAN LETTER ALI GALI DA;Lo;0;L;;;;;N;;;;;\n1892;MONGOLIAN LETTER ALI GALI PA;Lo;0;L;;;;;N;;;;;\n1893;MONGOLIAN LETTER ALI GALI PHA;Lo;0;L;;;;;N;;;;;\n1894;MONGOLIAN LETTER ALI GALI SSA;Lo;0;L;;;;;N;;;;;\n1895;MONGOLIAN LETTER ALI GALI ZHA;Lo;0;L;;;;;N;;;;;\n1896;MONGOLIAN LETTER ALI GALI ZA;Lo;0;L;;;;;N;;;;;\n1897;MONGOLIAN LETTER ALI GALI AH;Lo;0;L;;;;;N;;;;;\n1898;MONGOLIAN LETTER TODO ALI GALI TA;Lo;0;L;;;;;N;;;;;\n1899;MONGOLIAN LETTER TODO ALI GALI ZHA;Lo;0;L;;;;;N;;;;;\n189A;MONGOLIAN LETTER MANCHU ALI GALI GHA;Lo;0;L;;;;;N;;;;;\n189B;MONGOLIAN LETTER MANCHU ALI GALI NGA;Lo;0;L;;;;;N;;;;;\n189C;MONGOLIAN LETTER MANCHU ALI GALI CA;Lo;0;L;;;;;N;;;;;\n189D;MONGOLIAN LETTER MANCHU ALI GALI JHA;Lo;0;L;;;;;N;;;;;\n189E;MONGOLIAN LETTER MANCHU ALI GALI TTA;Lo;0;L;;;;;N;;;;;\n189F;MONGOLIAN LETTER MANCHU ALI GALI DDHA;Lo;0;L;;;;;N;;;;;\n18A0;MONGOLIAN LETTER MANCHU ALI GALI TA;Lo;0;L;;;;;N;;;;;\n18A1;MONGOLIAN LETTER MANCHU ALI GALI DHA;Lo;0;L;;;;;N;;;;;\n18A2;MONGOLIAN LETTER MANCHU ALI GALI SSA;Lo;0;L;;;;;N;;;;;\n18A3;MONGOLIAN LETTER MANCHU ALI GALI CYA;Lo;0;L;;;;;N;;;;;\n18A4;MONGOLIAN LETTER MANCHU ALI GALI ZHA;Lo;0;L;;;;;N;;;;;\n18A5;MONGOLIAN LETTER MANCHU ALI GALI ZA;Lo;0;L;;;;;N;;;;;\n18A6;MONGOLIAN LETTER ALI GALI HALF U;Lo;0;L;;;;;N;;;;;\n18A7;MONGOLIAN LETTER ALI GALI HALF YA;Lo;0;L;;;;;N;;;;;\n18A8;MONGOLIAN LETTER MANCHU ALI GALI BHA;Lo;0;L;;;;;N;;;;;\n18A9;MONGOLIAN LETTER ALI GALI DAGALGA;Mn;228;NSM;;;;;N;;;;;\n18AA;MONGOLIAN LETTER MANCHU ALI GALI LHA;Lo;0;L;;;;;N;;;;;\n18B0;CANADIAN SYLLABICS OY;Lo;0;L;;;;;N;;;;;\n18B1;CANADIAN SYLLABICS AY;Lo;0;L;;;;;N;;;;;\n18B2;CANADIAN SYLLABICS AAY;Lo;0;L;;;;;N;;;;;\n18B3;CANADIAN SYLLABICS WAY;Lo;0;L;;;;;N;;;;;\n18B4;CANADIAN SYLLABICS POY;Lo;0;L;;;;;N;;;;;\n18B5;CANADIAN SYLLABICS PAY;Lo;0;L;;;;;N;;;;;\n18B6;CANADIAN SYLLABICS PWOY;Lo;0;L;;;;;N;;;;;\n18B7;CANADIAN SYLLABICS TAY;Lo;0;L;;;;;N;;;;;\n18B8;CANADIAN SYLLABICS KAY;Lo;0;L;;;;;N;;;;;\n18B9;CANADIAN SYLLABICS KWAY;Lo;0;L;;;;;N;;;;;\n18BA;CANADIAN SYLLABICS MAY;Lo;0;L;;;;;N;;;;;\n18BB;CANADIAN SYLLABICS NOY;Lo;0;L;;;;;N;;;;;\n18BC;CANADIAN SYLLABICS NAY;Lo;0;L;;;;;N;;;;;\n18BD;CANADIAN SYLLABICS LAY;Lo;0;L;;;;;N;;;;;\n18BE;CANADIAN SYLLABICS SOY;Lo;0;L;;;;;N;;;;;\n18BF;CANADIAN SYLLABICS SAY;Lo;0;L;;;;;N;;;;;\n18C0;CANADIAN SYLLABICS SHOY;Lo;0;L;;;;;N;;;;;\n18C1;CANADIAN SYLLABICS SHAY;Lo;0;L;;;;;N;;;;;\n18C2;CANADIAN SYLLABICS SHWOY;Lo;0;L;;;;;N;;;;;\n18C3;CANADIAN SYLLABICS YOY;Lo;0;L;;;;;N;;;;;\n18C4;CANADIAN SYLLABICS YAY;Lo;0;L;;;;;N;;;;;\n18C5;CANADIAN SYLLABICS RAY;Lo;0;L;;;;;N;;;;;\n18C6;CANADIAN SYLLABICS NWI;Lo;0;L;;;;;N;;;;;\n18C7;CANADIAN SYLLABICS OJIBWAY NWI;Lo;0;L;;;;;N;;;;;\n18C8;CANADIAN SYLLABICS NWII;Lo;0;L;;;;;N;;;;;\n18C9;CANADIAN SYLLABICS OJIBWAY NWII;Lo;0;L;;;;;N;;;;;\n18CA;CANADIAN SYLLABICS NWO;Lo;0;L;;;;;N;;;;;\n18CB;CANADIAN SYLLABICS OJIBWAY NWO;Lo;0;L;;;;;N;;;;;\n18CC;CANADIAN SYLLABICS NWOO;Lo;0;L;;;;;N;;;;;\n18CD;CANADIAN SYLLABICS OJIBWAY NWOO;Lo;0;L;;;;;N;;;;;\n18CE;CANADIAN SYLLABICS RWEE;Lo;0;L;;;;;N;;;;;\n18CF;CANADIAN SYLLABICS RWI;Lo;0;L;;;;;N;;;;;\n18D0;CANADIAN SYLLABICS RWII;Lo;0;L;;;;;N;;;;;\n18D1;CANADIAN SYLLABICS RWO;Lo;0;L;;;;;N;;;;;\n18D2;CANADIAN SYLLABICS RWOO;Lo;0;L;;;;;N;;;;;\n18D3;CANADIAN SYLLABICS RWA;Lo;0;L;;;;;N;;;;;\n18D4;CANADIAN SYLLABICS OJIBWAY P;Lo;0;L;;;;;N;;;;;\n18D5;CANADIAN SYLLABICS OJIBWAY T;Lo;0;L;;;;;N;;;;;\n18D6;CANADIAN SYLLABICS OJIBWAY K;Lo;0;L;;;;;N;;;;;\n18D7;CANADIAN SYLLABICS OJIBWAY C;Lo;0;L;;;;;N;;;;;\n18D8;CANADIAN SYLLABICS OJIBWAY M;Lo;0;L;;;;;N;;;;;\n18D9;CANADIAN SYLLABICS OJIBWAY N;Lo;0;L;;;;;N;;;;;\n18DA;CANADIAN SYLLABICS OJIBWAY S;Lo;0;L;;;;;N;;;;;\n18DB;CANADIAN SYLLABICS OJIBWAY SH;Lo;0;L;;;;;N;;;;;\n18DC;CANADIAN SYLLABICS EASTERN W;Lo;0;L;;;;;N;;;;;\n18DD;CANADIAN SYLLABICS WESTERN W;Lo;0;L;;;;;N;;;;;\n18DE;CANADIAN SYLLABICS FINAL SMALL RING;Lo;0;L;;;;;N;;;;;\n18DF;CANADIAN SYLLABICS FINAL RAISED DOT;Lo;0;L;;;;;N;;;;;\n18E0;CANADIAN SYLLABICS R-CREE RWE;Lo;0;L;;;;;N;;;;;\n18E1;CANADIAN SYLLABICS WEST-CREE LOO;Lo;0;L;;;;;N;;;;;\n18E2;CANADIAN SYLLABICS WEST-CREE LAA;Lo;0;L;;;;;N;;;;;\n18E3;CANADIAN SYLLABICS THWE;Lo;0;L;;;;;N;;;;;\n18E4;CANADIAN SYLLABICS THWA;Lo;0;L;;;;;N;;;;;\n18E5;CANADIAN SYLLABICS TTHWE;Lo;0;L;;;;;N;;;;;\n18E6;CANADIAN SYLLABICS TTHOO;Lo;0;L;;;;;N;;;;;\n18E7;CANADIAN SYLLABICS TTHAA;Lo;0;L;;;;;N;;;;;\n18E8;CANADIAN SYLLABICS TLHWE;Lo;0;L;;;;;N;;;;;\n18E9;CANADIAN SYLLABICS TLHOO;Lo;0;L;;;;;N;;;;;\n18EA;CANADIAN SYLLABICS SAYISI SHWE;Lo;0;L;;;;;N;;;;;\n18EB;CANADIAN SYLLABICS SAYISI SHOO;Lo;0;L;;;;;N;;;;;\n18EC;CANADIAN SYLLABICS SAYISI HOO;Lo;0;L;;;;;N;;;;;\n18ED;CANADIAN SYLLABICS CARRIER GWU;Lo;0;L;;;;;N;;;;;\n18EE;CANADIAN SYLLABICS CARRIER DENE GEE;Lo;0;L;;;;;N;;;;;\n18EF;CANADIAN SYLLABICS CARRIER GAA;Lo;0;L;;;;;N;;;;;\n18F0;CANADIAN SYLLABICS CARRIER GWA;Lo;0;L;;;;;N;;;;;\n18F1;CANADIAN SYLLABICS SAYISI JUU;Lo;0;L;;;;;N;;;;;\n18F2;CANADIAN SYLLABICS CARRIER JWA;Lo;0;L;;;;;N;;;;;\n18F3;CANADIAN SYLLABICS BEAVER DENE L;Lo;0;L;;;;;N;;;;;\n18F4;CANADIAN SYLLABICS BEAVER DENE R;Lo;0;L;;;;;N;;;;;\n18F5;CANADIAN SYLLABICS CARRIER DENTAL S;Lo;0;L;;;;;N;;;;;\n1900;LIMBU VOWEL-CARRIER LETTER;Lo;0;L;;;;;N;;;;;\n1901;LIMBU LETTER KA;Lo;0;L;;;;;N;;;;;\n1902;LIMBU LETTER KHA;Lo;0;L;;;;;N;;;;;\n1903;LIMBU LETTER GA;Lo;0;L;;;;;N;;;;;\n1904;LIMBU LETTER GHA;Lo;0;L;;;;;N;;;;;\n1905;LIMBU LETTER NGA;Lo;0;L;;;;;N;;;;;\n1906;LIMBU LETTER CA;Lo;0;L;;;;;N;;;;;\n1907;LIMBU LETTER CHA;Lo;0;L;;;;;N;;;;;\n1908;LIMBU LETTER JA;Lo;0;L;;;;;N;;;;;\n1909;LIMBU LETTER JHA;Lo;0;L;;;;;N;;;;;\n190A;LIMBU LETTER YAN;Lo;0;L;;;;;N;;;;;\n190B;LIMBU LETTER TA;Lo;0;L;;;;;N;;;;;\n190C;LIMBU LETTER THA;Lo;0;L;;;;;N;;;;;\n190D;LIMBU LETTER DA;Lo;0;L;;;;;N;;;;;\n190E;LIMBU LETTER DHA;Lo;0;L;;;;;N;;;;;\n190F;LIMBU LETTER NA;Lo;0;L;;;;;N;;;;;\n1910;LIMBU LETTER PA;Lo;0;L;;;;;N;;;;;\n1911;LIMBU LETTER PHA;Lo;0;L;;;;;N;;;;;\n1912;LIMBU LETTER BA;Lo;0;L;;;;;N;;;;;\n1913;LIMBU LETTER BHA;Lo;0;L;;;;;N;;;;;\n1914;LIMBU LETTER MA;Lo;0;L;;;;;N;;;;;\n1915;LIMBU LETTER YA;Lo;0;L;;;;;N;;;;;\n1916;LIMBU LETTER RA;Lo;0;L;;;;;N;;;;;\n1917;LIMBU LETTER LA;Lo;0;L;;;;;N;;;;;\n1918;LIMBU LETTER WA;Lo;0;L;;;;;N;;;;;\n1919;LIMBU LETTER SHA;Lo;0;L;;;;;N;;;;;\n191A;LIMBU LETTER SSA;Lo;0;L;;;;;N;;;;;\n191B;LIMBU LETTER SA;Lo;0;L;;;;;N;;;;;\n191C;LIMBU LETTER HA;Lo;0;L;;;;;N;;;;;\n1920;LIMBU VOWEL SIGN A;Mn;0;NSM;;;;;N;;;;;\n1921;LIMBU VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1922;LIMBU VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1923;LIMBU VOWEL SIGN EE;Mc;0;L;;;;;N;;;;;\n1924;LIMBU VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n1925;LIMBU VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\n1926;LIMBU VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n1927;LIMBU VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n1928;LIMBU VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n1929;LIMBU SUBJOINED LETTER YA;Mc;0;L;;;;;N;;;;;\n192A;LIMBU SUBJOINED LETTER RA;Mc;0;L;;;;;N;;;;;\n192B;LIMBU SUBJOINED LETTER WA;Mc;0;L;;;;;N;;;;;\n1930;LIMBU SMALL LETTER KA;Mc;0;L;;;;;N;;;;;\n1931;LIMBU SMALL LETTER NGA;Mc;0;L;;;;;N;;;;;\n1932;LIMBU SMALL LETTER ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n1933;LIMBU SMALL LETTER TA;Mc;0;L;;;;;N;;;;;\n1934;LIMBU SMALL LETTER NA;Mc;0;L;;;;;N;;;;;\n1935;LIMBU SMALL LETTER PA;Mc;0;L;;;;;N;;;;;\n1936;LIMBU SMALL LETTER MA;Mc;0;L;;;;;N;;;;;\n1937;LIMBU SMALL LETTER RA;Mc;0;L;;;;;N;;;;;\n1938;LIMBU SMALL LETTER LA;Mc;0;L;;;;;N;;;;;\n1939;LIMBU SIGN MUKPHRENG;Mn;222;NSM;;;;;N;;;;;\n193A;LIMBU SIGN KEMPHRENG;Mn;230;NSM;;;;;N;;;;;\n193B;LIMBU SIGN SA-I;Mn;220;NSM;;;;;N;;;;;\n1940;LIMBU SIGN LOO;So;0;ON;;;;;N;;;;;\n1944;LIMBU EXCLAMATION MARK;Po;0;ON;;;;;N;;;;;\n1945;LIMBU QUESTION MARK;Po;0;ON;;;;;N;;;;;\n1946;LIMBU DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1947;LIMBU DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1948;LIMBU DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1949;LIMBU DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n194A;LIMBU DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n194B;LIMBU DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n194C;LIMBU DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n194D;LIMBU DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n194E;LIMBU DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n194F;LIMBU DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1950;TAI LE LETTER KA;Lo;0;L;;;;;N;;;;;\n1951;TAI LE LETTER XA;Lo;0;L;;;;;N;;;;;\n1952;TAI LE LETTER NGA;Lo;0;L;;;;;N;;;;;\n1953;TAI LE LETTER TSA;Lo;0;L;;;;;N;;;;;\n1954;TAI LE LETTER SA;Lo;0;L;;;;;N;;;;;\n1955;TAI LE LETTER YA;Lo;0;L;;;;;N;;;;;\n1956;TAI LE LETTER TA;Lo;0;L;;;;;N;;;;;\n1957;TAI LE LETTER THA;Lo;0;L;;;;;N;;;;;\n1958;TAI LE LETTER LA;Lo;0;L;;;;;N;;;;;\n1959;TAI LE LETTER PA;Lo;0;L;;;;;N;;;;;\n195A;TAI LE LETTER PHA;Lo;0;L;;;;;N;;;;;\n195B;TAI LE LETTER MA;Lo;0;L;;;;;N;;;;;\n195C;TAI LE LETTER FA;Lo;0;L;;;;;N;;;;;\n195D;TAI LE LETTER VA;Lo;0;L;;;;;N;;;;;\n195E;TAI LE LETTER HA;Lo;0;L;;;;;N;;;;;\n195F;TAI LE LETTER QA;Lo;0;L;;;;;N;;;;;\n1960;TAI LE LETTER KHA;Lo;0;L;;;;;N;;;;;\n1961;TAI LE LETTER TSHA;Lo;0;L;;;;;N;;;;;\n1962;TAI LE LETTER NA;Lo;0;L;;;;;N;;;;;\n1963;TAI LE LETTER A;Lo;0;L;;;;;N;;;;;\n1964;TAI LE LETTER I;Lo;0;L;;;;;N;;;;;\n1965;TAI LE LETTER EE;Lo;0;L;;;;;N;;;;;\n1966;TAI LE LETTER EH;Lo;0;L;;;;;N;;;;;\n1967;TAI LE LETTER U;Lo;0;L;;;;;N;;;;;\n1968;TAI LE LETTER OO;Lo;0;L;;;;;N;;;;;\n1969;TAI LE LETTER O;Lo;0;L;;;;;N;;;;;\n196A;TAI LE LETTER UE;Lo;0;L;;;;;N;;;;;\n196B;TAI LE LETTER E;Lo;0;L;;;;;N;;;;;\n196C;TAI LE LETTER AUE;Lo;0;L;;;;;N;;;;;\n196D;TAI LE LETTER AI;Lo;0;L;;;;;N;;;;;\n1970;TAI LE LETTER TONE-2;Lo;0;L;;;;;N;;;;;\n1971;TAI LE LETTER TONE-3;Lo;0;L;;;;;N;;;;;\n1972;TAI LE LETTER TONE-4;Lo;0;L;;;;;N;;;;;\n1973;TAI LE LETTER TONE-5;Lo;0;L;;;;;N;;;;;\n1974;TAI LE LETTER TONE-6;Lo;0;L;;;;;N;;;;;\n1980;NEW TAI LUE LETTER HIGH QA;Lo;0;L;;;;;N;;;;;\n1981;NEW TAI LUE LETTER LOW QA;Lo;0;L;;;;;N;;;;;\n1982;NEW TAI LUE LETTER HIGH KA;Lo;0;L;;;;;N;;;;;\n1983;NEW TAI LUE LETTER HIGH XA;Lo;0;L;;;;;N;;;;;\n1984;NEW TAI LUE LETTER HIGH NGA;Lo;0;L;;;;;N;;;;;\n1985;NEW TAI LUE LETTER LOW KA;Lo;0;L;;;;;N;;;;;\n1986;NEW TAI LUE LETTER LOW XA;Lo;0;L;;;;;N;;;;;\n1987;NEW TAI LUE LETTER LOW NGA;Lo;0;L;;;;;N;;;;;\n1988;NEW TAI LUE LETTER HIGH TSA;Lo;0;L;;;;;N;;;;;\n1989;NEW TAI LUE LETTER HIGH SA;Lo;0;L;;;;;N;;;;;\n198A;NEW TAI LUE LETTER HIGH YA;Lo;0;L;;;;;N;;;;;\n198B;NEW TAI LUE LETTER LOW TSA;Lo;0;L;;;;;N;;;;;\n198C;NEW TAI LUE LETTER LOW SA;Lo;0;L;;;;;N;;;;;\n198D;NEW TAI LUE LETTER LOW YA;Lo;0;L;;;;;N;;;;;\n198E;NEW TAI LUE LETTER HIGH TA;Lo;0;L;;;;;N;;;;;\n198F;NEW TAI LUE LETTER HIGH THA;Lo;0;L;;;;;N;;;;;\n1990;NEW TAI LUE LETTER HIGH NA;Lo;0;L;;;;;N;;;;;\n1991;NEW TAI LUE LETTER LOW TA;Lo;0;L;;;;;N;;;;;\n1992;NEW TAI LUE LETTER LOW THA;Lo;0;L;;;;;N;;;;;\n1993;NEW TAI LUE LETTER LOW NA;Lo;0;L;;;;;N;;;;;\n1994;NEW TAI LUE LETTER HIGH PA;Lo;0;L;;;;;N;;;;;\n1995;NEW TAI LUE LETTER HIGH PHA;Lo;0;L;;;;;N;;;;;\n1996;NEW TAI LUE LETTER HIGH MA;Lo;0;L;;;;;N;;;;;\n1997;NEW TAI LUE LETTER LOW PA;Lo;0;L;;;;;N;;;;;\n1998;NEW TAI LUE LETTER LOW PHA;Lo;0;L;;;;;N;;;;;\n1999;NEW TAI LUE LETTER LOW MA;Lo;0;L;;;;;N;;;;;\n199A;NEW TAI LUE LETTER HIGH FA;Lo;0;L;;;;;N;;;;;\n199B;NEW TAI LUE LETTER HIGH VA;Lo;0;L;;;;;N;;;;;\n199C;NEW TAI LUE LETTER HIGH LA;Lo;0;L;;;;;N;;;;;\n199D;NEW TAI LUE LETTER LOW FA;Lo;0;L;;;;;N;;;;;\n199E;NEW TAI LUE LETTER LOW VA;Lo;0;L;;;;;N;;;;;\n199F;NEW TAI LUE LETTER LOW LA;Lo;0;L;;;;;N;;;;;\n19A0;NEW TAI LUE LETTER HIGH HA;Lo;0;L;;;;;N;;;;;\n19A1;NEW TAI LUE LETTER HIGH DA;Lo;0;L;;;;;N;;;;;\n19A2;NEW TAI LUE LETTER HIGH BA;Lo;0;L;;;;;N;;;;;\n19A3;NEW TAI LUE LETTER LOW HA;Lo;0;L;;;;;N;;;;;\n19A4;NEW TAI LUE LETTER LOW DA;Lo;0;L;;;;;N;;;;;\n19A5;NEW TAI LUE LETTER LOW BA;Lo;0;L;;;;;N;;;;;\n19A6;NEW TAI LUE LETTER HIGH KVA;Lo;0;L;;;;;N;;;;;\n19A7;NEW TAI LUE LETTER HIGH XVA;Lo;0;L;;;;;N;;;;;\n19A8;NEW TAI LUE LETTER LOW KVA;Lo;0;L;;;;;N;;;;;\n19A9;NEW TAI LUE LETTER LOW XVA;Lo;0;L;;;;;N;;;;;\n19AA;NEW TAI LUE LETTER HIGH SUA;Lo;0;L;;;;;N;;;;;\n19AB;NEW TAI LUE LETTER LOW SUA;Lo;0;L;;;;;N;;;;;\n19B0;NEW TAI LUE VOWEL SIGN VOWEL SHORTENER;Mc;0;L;;;;;N;;;;;\n19B1;NEW TAI LUE VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n19B2;NEW TAI LUE VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n19B3;NEW TAI LUE VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n19B4;NEW TAI LUE VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n19B5;NEW TAI LUE VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n19B6;NEW TAI LUE VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;\n19B7;NEW TAI LUE VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n19B8;NEW TAI LUE VOWEL SIGN OA;Mc;0;L;;;;;N;;;;;\n19B9;NEW TAI LUE VOWEL SIGN UE;Mc;0;L;;;;;N;;;;;\n19BA;NEW TAI LUE VOWEL SIGN AY;Mc;0;L;;;;;N;;;;;\n19BB;NEW TAI LUE VOWEL SIGN AAY;Mc;0;L;;;;;N;;;;;\n19BC;NEW TAI LUE VOWEL SIGN UY;Mc;0;L;;;;;N;;;;;\n19BD;NEW TAI LUE VOWEL SIGN OY;Mc;0;L;;;;;N;;;;;\n19BE;NEW TAI LUE VOWEL SIGN OAY;Mc;0;L;;;;;N;;;;;\n19BF;NEW TAI LUE VOWEL SIGN UEY;Mc;0;L;;;;;N;;;;;\n19C0;NEW TAI LUE VOWEL SIGN IY;Mc;0;L;;;;;N;;;;;\n19C1;NEW TAI LUE LETTER FINAL V;Lo;0;L;;;;;N;;;;;\n19C2;NEW TAI LUE LETTER FINAL NG;Lo;0;L;;;;;N;;;;;\n19C3;NEW TAI LUE LETTER FINAL N;Lo;0;L;;;;;N;;;;;\n19C4;NEW TAI LUE LETTER FINAL M;Lo;0;L;;;;;N;;;;;\n19C5;NEW TAI LUE LETTER FINAL K;Lo;0;L;;;;;N;;;;;\n19C6;NEW TAI LUE LETTER FINAL D;Lo;0;L;;;;;N;;;;;\n19C7;NEW TAI LUE LETTER FINAL B;Lo;0;L;;;;;N;;;;;\n19C8;NEW TAI LUE TONE MARK-1;Mc;0;L;;;;;N;;;;;\n19C9;NEW TAI LUE TONE MARK-2;Mc;0;L;;;;;N;;;;;\n19D0;NEW TAI LUE DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n19D1;NEW TAI LUE DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n19D2;NEW TAI LUE DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n19D3;NEW TAI LUE DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n19D4;NEW TAI LUE DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n19D5;NEW TAI LUE DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n19D6;NEW TAI LUE DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n19D7;NEW TAI LUE DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n19D8;NEW TAI LUE DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n19D9;NEW TAI LUE DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n19DA;NEW TAI LUE THAM DIGIT ONE;No;0;L;;;1;1;N;;;;;\n19DE;NEW TAI LUE SIGN LAE;So;0;ON;;;;;N;;;;;\n19DF;NEW TAI LUE SIGN LAEV;So;0;ON;;;;;N;;;;;\n19E0;KHMER SYMBOL PATHAMASAT;So;0;ON;;;;;N;;;;;\n19E1;KHMER SYMBOL MUOY KOET;So;0;ON;;;;;N;;;;;\n19E2;KHMER SYMBOL PII KOET;So;0;ON;;;;;N;;;;;\n19E3;KHMER SYMBOL BEI KOET;So;0;ON;;;;;N;;;;;\n19E4;KHMER SYMBOL BUON KOET;So;0;ON;;;;;N;;;;;\n19E5;KHMER SYMBOL PRAM KOET;So;0;ON;;;;;N;;;;;\n19E6;KHMER SYMBOL PRAM-MUOY KOET;So;0;ON;;;;;N;;;;;\n19E7;KHMER SYMBOL PRAM-PII KOET;So;0;ON;;;;;N;;;;;\n19E8;KHMER SYMBOL PRAM-BEI KOET;So;0;ON;;;;;N;;;;;\n19E9;KHMER SYMBOL PRAM-BUON KOET;So;0;ON;;;;;N;;;;;\n19EA;KHMER SYMBOL DAP KOET;So;0;ON;;;;;N;;;;;\n19EB;KHMER SYMBOL DAP-MUOY KOET;So;0;ON;;;;;N;;;;;\n19EC;KHMER SYMBOL DAP-PII KOET;So;0;ON;;;;;N;;;;;\n19ED;KHMER SYMBOL DAP-BEI KOET;So;0;ON;;;;;N;;;;;\n19EE;KHMER SYMBOL DAP-BUON KOET;So;0;ON;;;;;N;;;;;\n19EF;KHMER SYMBOL DAP-PRAM KOET;So;0;ON;;;;;N;;;;;\n19F0;KHMER SYMBOL TUTEYASAT;So;0;ON;;;;;N;;;;;\n19F1;KHMER SYMBOL MUOY ROC;So;0;ON;;;;;N;;;;;\n19F2;KHMER SYMBOL PII ROC;So;0;ON;;;;;N;;;;;\n19F3;KHMER SYMBOL BEI ROC;So;0;ON;;;;;N;;;;;\n19F4;KHMER SYMBOL BUON ROC;So;0;ON;;;;;N;;;;;\n19F5;KHMER SYMBOL PRAM ROC;So;0;ON;;;;;N;;;;;\n19F6;KHMER SYMBOL PRAM-MUOY ROC;So;0;ON;;;;;N;;;;;\n19F7;KHMER SYMBOL PRAM-PII ROC;So;0;ON;;;;;N;;;;;\n19F8;KHMER SYMBOL PRAM-BEI ROC;So;0;ON;;;;;N;;;;;\n19F9;KHMER SYMBOL PRAM-BUON ROC;So;0;ON;;;;;N;;;;;\n19FA;KHMER SYMBOL DAP ROC;So;0;ON;;;;;N;;;;;\n19FB;KHMER SYMBOL DAP-MUOY ROC;So;0;ON;;;;;N;;;;;\n19FC;KHMER SYMBOL DAP-PII ROC;So;0;ON;;;;;N;;;;;\n19FD;KHMER SYMBOL DAP-BEI ROC;So;0;ON;;;;;N;;;;;\n19FE;KHMER SYMBOL DAP-BUON ROC;So;0;ON;;;;;N;;;;;\n19FF;KHMER SYMBOL DAP-PRAM ROC;So;0;ON;;;;;N;;;;;\n1A00;BUGINESE LETTER KA;Lo;0;L;;;;;N;;;;;\n1A01;BUGINESE LETTER GA;Lo;0;L;;;;;N;;;;;\n1A02;BUGINESE LETTER NGA;Lo;0;L;;;;;N;;;;;\n1A03;BUGINESE LETTER NGKA;Lo;0;L;;;;;N;;;;;\n1A04;BUGINESE LETTER PA;Lo;0;L;;;;;N;;;;;\n1A05;BUGINESE LETTER BA;Lo;0;L;;;;;N;;;;;\n1A06;BUGINESE LETTER MA;Lo;0;L;;;;;N;;;;;\n1A07;BUGINESE LETTER MPA;Lo;0;L;;;;;N;;;;;\n1A08;BUGINESE LETTER TA;Lo;0;L;;;;;N;;;;;\n1A09;BUGINESE LETTER DA;Lo;0;L;;;;;N;;;;;\n1A0A;BUGINESE LETTER NA;Lo;0;L;;;;;N;;;;;\n1A0B;BUGINESE LETTER NRA;Lo;0;L;;;;;N;;;;;\n1A0C;BUGINESE LETTER CA;Lo;0;L;;;;;N;;;;;\n1A0D;BUGINESE LETTER JA;Lo;0;L;;;;;N;;;;;\n1A0E;BUGINESE LETTER NYA;Lo;0;L;;;;;N;;;;;\n1A0F;BUGINESE LETTER NYCA;Lo;0;L;;;;;N;;;;;\n1A10;BUGINESE LETTER YA;Lo;0;L;;;;;N;;;;;\n1A11;BUGINESE LETTER RA;Lo;0;L;;;;;N;;;;;\n1A12;BUGINESE LETTER LA;Lo;0;L;;;;;N;;;;;\n1A13;BUGINESE LETTER VA;Lo;0;L;;;;;N;;;;;\n1A14;BUGINESE LETTER SA;Lo;0;L;;;;;N;;;;;\n1A15;BUGINESE LETTER A;Lo;0;L;;;;;N;;;;;\n1A16;BUGINESE LETTER HA;Lo;0;L;;;;;N;;;;;\n1A17;BUGINESE VOWEL SIGN I;Mn;230;NSM;;;;;N;;;;;\n1A18;BUGINESE VOWEL SIGN U;Mn;220;NSM;;;;;N;;;;;\n1A19;BUGINESE VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n1A1A;BUGINESE VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n1A1B;BUGINESE VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;\n1A1E;BUGINESE PALLAWA;Po;0;L;;;;;N;;;;;\n1A1F;BUGINESE END OF SECTION;Po;0;L;;;;;N;;;;;\n1A20;TAI THAM LETTER HIGH KA;Lo;0;L;;;;;N;;;;;\n1A21;TAI THAM LETTER HIGH KHA;Lo;0;L;;;;;N;;;;;\n1A22;TAI THAM LETTER HIGH KXA;Lo;0;L;;;;;N;;;;;\n1A23;TAI THAM LETTER LOW KA;Lo;0;L;;;;;N;;;;;\n1A24;TAI THAM LETTER LOW KXA;Lo;0;L;;;;;N;;;;;\n1A25;TAI THAM LETTER LOW KHA;Lo;0;L;;;;;N;;;;;\n1A26;TAI THAM LETTER NGA;Lo;0;L;;;;;N;;;;;\n1A27;TAI THAM LETTER HIGH CA;Lo;0;L;;;;;N;;;;;\n1A28;TAI THAM LETTER HIGH CHA;Lo;0;L;;;;;N;;;;;\n1A29;TAI THAM LETTER LOW CA;Lo;0;L;;;;;N;;;;;\n1A2A;TAI THAM LETTER LOW SA;Lo;0;L;;;;;N;;;;;\n1A2B;TAI THAM LETTER LOW CHA;Lo;0;L;;;;;N;;;;;\n1A2C;TAI THAM LETTER NYA;Lo;0;L;;;;;N;;;;;\n1A2D;TAI THAM LETTER RATA;Lo;0;L;;;;;N;;;;;\n1A2E;TAI THAM LETTER HIGH RATHA;Lo;0;L;;;;;N;;;;;\n1A2F;TAI THAM LETTER DA;Lo;0;L;;;;;N;;;;;\n1A30;TAI THAM LETTER LOW RATHA;Lo;0;L;;;;;N;;;;;\n1A31;TAI THAM LETTER RANA;Lo;0;L;;;;;N;;;;;\n1A32;TAI THAM LETTER HIGH TA;Lo;0;L;;;;;N;;;;;\n1A33;TAI THAM LETTER HIGH THA;Lo;0;L;;;;;N;;;;;\n1A34;TAI THAM LETTER LOW TA;Lo;0;L;;;;;N;;;;;\n1A35;TAI THAM LETTER LOW THA;Lo;0;L;;;;;N;;;;;\n1A36;TAI THAM LETTER NA;Lo;0;L;;;;;N;;;;;\n1A37;TAI THAM LETTER BA;Lo;0;L;;;;;N;;;;;\n1A38;TAI THAM LETTER HIGH PA;Lo;0;L;;;;;N;;;;;\n1A39;TAI THAM LETTER HIGH PHA;Lo;0;L;;;;;N;;;;;\n1A3A;TAI THAM LETTER HIGH FA;Lo;0;L;;;;;N;;;;;\n1A3B;TAI THAM LETTER LOW PA;Lo;0;L;;;;;N;;;;;\n1A3C;TAI THAM LETTER LOW FA;Lo;0;L;;;;;N;;;;;\n1A3D;TAI THAM LETTER LOW PHA;Lo;0;L;;;;;N;;;;;\n1A3E;TAI THAM LETTER MA;Lo;0;L;;;;;N;;;;;\n1A3F;TAI THAM LETTER LOW YA;Lo;0;L;;;;;N;;;;;\n1A40;TAI THAM LETTER HIGH YA;Lo;0;L;;;;;N;;;;;\n1A41;TAI THAM LETTER RA;Lo;0;L;;;;;N;;;;;\n1A42;TAI THAM LETTER RUE;Lo;0;L;;;;;N;;;;;\n1A43;TAI THAM LETTER LA;Lo;0;L;;;;;N;;;;;\n1A44;TAI THAM LETTER LUE;Lo;0;L;;;;;N;;;;;\n1A45;TAI THAM LETTER WA;Lo;0;L;;;;;N;;;;;\n1A46;TAI THAM LETTER HIGH SHA;Lo;0;L;;;;;N;;;;;\n1A47;TAI THAM LETTER HIGH SSA;Lo;0;L;;;;;N;;;;;\n1A48;TAI THAM LETTER HIGH SA;Lo;0;L;;;;;N;;;;;\n1A49;TAI THAM LETTER HIGH HA;Lo;0;L;;;;;N;;;;;\n1A4A;TAI THAM LETTER LLA;Lo;0;L;;;;;N;;;;;\n1A4B;TAI THAM LETTER A;Lo;0;L;;;;;N;;;;;\n1A4C;TAI THAM LETTER LOW HA;Lo;0;L;;;;;N;;;;;\n1A4D;TAI THAM LETTER I;Lo;0;L;;;;;N;;;;;\n1A4E;TAI THAM LETTER II;Lo;0;L;;;;;N;;;;;\n1A4F;TAI THAM LETTER U;Lo;0;L;;;;;N;;;;;\n1A50;TAI THAM LETTER UU;Lo;0;L;;;;;N;;;;;\n1A51;TAI THAM LETTER EE;Lo;0;L;;;;;N;;;;;\n1A52;TAI THAM LETTER OO;Lo;0;L;;;;;N;;;;;\n1A53;TAI THAM LETTER LAE;Lo;0;L;;;;;N;;;;;\n1A54;TAI THAM LETTER GREAT SA;Lo;0;L;;;;;N;;;;;\n1A55;TAI THAM CONSONANT SIGN MEDIAL RA;Mc;0;L;;;;;N;;;;;\n1A56;TAI THAM CONSONANT SIGN MEDIAL LA;Mn;0;NSM;;;;;N;;;;;\n1A57;TAI THAM CONSONANT SIGN LA TANG LAI;Mc;0;L;;;;;N;;;;;\n1A58;TAI THAM SIGN MAI KANG LAI;Mn;0;NSM;;;;;N;;;;;\n1A59;TAI THAM CONSONANT SIGN FINAL NGA;Mn;0;NSM;;;;;N;;;;;\n1A5A;TAI THAM CONSONANT SIGN LOW PA;Mn;0;NSM;;;;;N;;;;;\n1A5B;TAI THAM CONSONANT SIGN HIGH RATHA OR LOW PA;Mn;0;NSM;;;;;N;;;;;\n1A5C;TAI THAM CONSONANT SIGN MA;Mn;0;NSM;;;;;N;;;;;\n1A5D;TAI THAM CONSONANT SIGN BA;Mn;0;NSM;;;;;N;;;;;\n1A5E;TAI THAM CONSONANT SIGN SA;Mn;0;NSM;;;;;N;;;;;\n1A60;TAI THAM SIGN SAKOT;Mn;9;NSM;;;;;N;;;;;\n1A61;TAI THAM VOWEL SIGN A;Mc;0;L;;;;;N;;;;;\n1A62;TAI THAM VOWEL SIGN MAI SAT;Mn;0;NSM;;;;;N;;;;;\n1A63;TAI THAM VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n1A64;TAI THAM VOWEL SIGN TALL AA;Mc;0;L;;;;;N;;;;;\n1A65;TAI THAM VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1A66;TAI THAM VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n1A67;TAI THAM VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;;\n1A68;TAI THAM VOWEL SIGN UUE;Mn;0;NSM;;;;;N;;;;;\n1A69;TAI THAM VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1A6A;TAI THAM VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n1A6B;TAI THAM VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n1A6C;TAI THAM VOWEL SIGN OA BELOW;Mn;0;NSM;;;;;N;;;;;\n1A6D;TAI THAM VOWEL SIGN OY;Mc;0;L;;;;;N;;;;;\n1A6E;TAI THAM VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n1A6F;TAI THAM VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;\n1A70;TAI THAM VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\n1A71;TAI THAM VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n1A72;TAI THAM VOWEL SIGN THAM AI;Mc;0;L;;;;;N;;;;;\n1A73;TAI THAM VOWEL SIGN OA ABOVE;Mn;0;NSM;;;;;N;;;;;\n1A74;TAI THAM SIGN MAI KANG;Mn;0;NSM;;;;;N;;;;;\n1A75;TAI THAM SIGN TONE-1;Mn;230;NSM;;;;;N;;;;;\n1A76;TAI THAM SIGN TONE-2;Mn;230;NSM;;;;;N;;;;;\n1A77;TAI THAM SIGN KHUEN TONE-3;Mn;230;NSM;;;;;N;;;;;\n1A78;TAI THAM SIGN KHUEN TONE-4;Mn;230;NSM;;;;;N;;;;;\n1A79;TAI THAM SIGN KHUEN TONE-5;Mn;230;NSM;;;;;N;;;;;\n1A7A;TAI THAM SIGN RA HAAM;Mn;230;NSM;;;;;N;;;;;\n1A7B;TAI THAM SIGN MAI SAM;Mn;230;NSM;;;;;N;;;;;\n1A7C;TAI THAM SIGN KHUEN-LUE KARAN;Mn;230;NSM;;;;;N;;;;;\n1A7F;TAI THAM COMBINING CRYPTOGRAMMIC DOT;Mn;220;NSM;;;;;N;;;;;\n1A80;TAI THAM HORA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1A81;TAI THAM HORA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1A82;TAI THAM HORA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1A83;TAI THAM HORA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1A84;TAI THAM HORA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1A85;TAI THAM HORA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1A86;TAI THAM HORA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1A87;TAI THAM HORA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1A88;TAI THAM HORA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1A89;TAI THAM HORA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1A90;TAI THAM THAM DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1A91;TAI THAM THAM DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1A92;TAI THAM THAM DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1A93;TAI THAM THAM DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1A94;TAI THAM THAM DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1A95;TAI THAM THAM DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1A96;TAI THAM THAM DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1A97;TAI THAM THAM DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1A98;TAI THAM THAM DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1A99;TAI THAM THAM DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1AA0;TAI THAM SIGN WIANG;Po;0;L;;;;;N;;;;;\n1AA1;TAI THAM SIGN WIANGWAAK;Po;0;L;;;;;N;;;;;\n1AA2;TAI THAM SIGN SAWAN;Po;0;L;;;;;N;;;;;\n1AA3;TAI THAM SIGN KEOW;Po;0;L;;;;;N;;;;;\n1AA4;TAI THAM SIGN HOY;Po;0;L;;;;;N;;;;;\n1AA5;TAI THAM SIGN DOKMAI;Po;0;L;;;;;N;;;;;\n1AA6;TAI THAM SIGN REVERSED ROTATED RANA;Po;0;L;;;;;N;;;;;\n1AA7;TAI THAM SIGN MAI YAMOK;Lm;0;L;;;;;N;;;;;\n1AA8;TAI THAM SIGN KAAN;Po;0;L;;;;;N;;;;;\n1AA9;TAI THAM SIGN KAANKUU;Po;0;L;;;;;N;;;;;\n1AAA;TAI THAM SIGN SATKAAN;Po;0;L;;;;;N;;;;;\n1AAB;TAI THAM SIGN SATKAANKUU;Po;0;L;;;;;N;;;;;\n1AAC;TAI THAM SIGN HANG;Po;0;L;;;;;N;;;;;\n1AAD;TAI THAM SIGN CAANG;Po;0;L;;;;;N;;;;;\n1B00;BALINESE SIGN ULU RICEM;Mn;0;NSM;;;;;N;;;;;\n1B01;BALINESE SIGN ULU CANDRA;Mn;0;NSM;;;;;N;;;;;\n1B02;BALINESE SIGN CECEK;Mn;0;NSM;;;;;N;;;;;\n1B03;BALINESE SIGN SURANG;Mn;0;NSM;;;;;N;;;;;\n1B04;BALINESE SIGN BISAH;Mc;0;L;;;;;N;;;;;\n1B05;BALINESE LETTER AKARA;Lo;0;L;;;;;N;;;;;\n1B06;BALINESE LETTER AKARA TEDUNG;Lo;0;L;1B05 1B35;;;;N;;;;;\n1B07;BALINESE LETTER IKARA;Lo;0;L;;;;;N;;;;;\n1B08;BALINESE LETTER IKARA TEDUNG;Lo;0;L;1B07 1B35;;;;N;;;;;\n1B09;BALINESE LETTER UKARA;Lo;0;L;;;;;N;;;;;\n1B0A;BALINESE LETTER UKARA TEDUNG;Lo;0;L;1B09 1B35;;;;N;;;;;\n1B0B;BALINESE LETTER RA REPA;Lo;0;L;;;;;N;;;;;\n1B0C;BALINESE LETTER RA REPA TEDUNG;Lo;0;L;1B0B 1B35;;;;N;;;;;\n1B0D;BALINESE LETTER LA LENGA;Lo;0;L;;;;;N;;;;;\n1B0E;BALINESE LETTER LA LENGA TEDUNG;Lo;0;L;1B0D 1B35;;;;N;;;;;\n1B0F;BALINESE LETTER EKARA;Lo;0;L;;;;;N;;;;;\n1B10;BALINESE LETTER AIKARA;Lo;0;L;;;;;N;;;;;\n1B11;BALINESE LETTER OKARA;Lo;0;L;;;;;N;;;;;\n1B12;BALINESE LETTER OKARA TEDUNG;Lo;0;L;1B11 1B35;;;;N;;;;;\n1B13;BALINESE LETTER KA;Lo;0;L;;;;;N;;;;;\n1B14;BALINESE LETTER KA MAHAPRANA;Lo;0;L;;;;;N;;;;;\n1B15;BALINESE LETTER GA;Lo;0;L;;;;;N;;;;;\n1B16;BALINESE LETTER GA GORA;Lo;0;L;;;;;N;;;;;\n1B17;BALINESE LETTER NGA;Lo;0;L;;;;;N;;;;;\n1B18;BALINESE LETTER CA;Lo;0;L;;;;;N;;;;;\n1B19;BALINESE LETTER CA LACA;Lo;0;L;;;;;N;;;;;\n1B1A;BALINESE LETTER JA;Lo;0;L;;;;;N;;;;;\n1B1B;BALINESE LETTER JA JERA;Lo;0;L;;;;;N;;;;;\n1B1C;BALINESE LETTER NYA;Lo;0;L;;;;;N;;;;;\n1B1D;BALINESE LETTER TA LATIK;Lo;0;L;;;;;N;;;;;\n1B1E;BALINESE LETTER TA MURDA MAHAPRANA;Lo;0;L;;;;;N;;;;;\n1B1F;BALINESE LETTER DA MURDA ALPAPRANA;Lo;0;L;;;;;N;;;;;\n1B20;BALINESE LETTER DA MURDA MAHAPRANA;Lo;0;L;;;;;N;;;;;\n1B21;BALINESE LETTER NA RAMBAT;Lo;0;L;;;;;N;;;;;\n1B22;BALINESE LETTER TA;Lo;0;L;;;;;N;;;;;\n1B23;BALINESE LETTER TA TAWA;Lo;0;L;;;;;N;;;;;\n1B24;BALINESE LETTER DA;Lo;0;L;;;;;N;;;;;\n1B25;BALINESE LETTER DA MADU;Lo;0;L;;;;;N;;;;;\n1B26;BALINESE LETTER NA;Lo;0;L;;;;;N;;;;;\n1B27;BALINESE LETTER PA;Lo;0;L;;;;;N;;;;;\n1B28;BALINESE LETTER PA KAPAL;Lo;0;L;;;;;N;;;;;\n1B29;BALINESE LETTER BA;Lo;0;L;;;;;N;;;;;\n1B2A;BALINESE LETTER BA KEMBANG;Lo;0;L;;;;;N;;;;;\n1B2B;BALINESE LETTER MA;Lo;0;L;;;;;N;;;;;\n1B2C;BALINESE LETTER YA;Lo;0;L;;;;;N;;;;;\n1B2D;BALINESE LETTER RA;Lo;0;L;;;;;N;;;;;\n1B2E;BALINESE LETTER LA;Lo;0;L;;;;;N;;;;;\n1B2F;BALINESE LETTER WA;Lo;0;L;;;;;N;;;;;\n1B30;BALINESE LETTER SA SAGA;Lo;0;L;;;;;N;;;;;\n1B31;BALINESE LETTER SA SAPA;Lo;0;L;;;;;N;;;;;\n1B32;BALINESE LETTER SA;Lo;0;L;;;;;N;;;;;\n1B33;BALINESE LETTER HA;Lo;0;L;;;;;N;;;;;\n1B34;BALINESE SIGN REREKAN;Mn;7;NSM;;;;;N;;;;;\n1B35;BALINESE VOWEL SIGN TEDUNG;Mc;0;L;;;;;N;;;;;\n1B36;BALINESE VOWEL SIGN ULU;Mn;0;NSM;;;;;N;;;;;\n1B37;BALINESE VOWEL SIGN ULU SARI;Mn;0;NSM;;;;;N;;;;;\n1B38;BALINESE VOWEL SIGN SUKU;Mn;0;NSM;;;;;N;;;;;\n1B39;BALINESE VOWEL SIGN SUKU ILUT;Mn;0;NSM;;;;;N;;;;;\n1B3A;BALINESE VOWEL SIGN RA REPA;Mn;0;NSM;;;;;N;;;;;\n1B3B;BALINESE VOWEL SIGN RA REPA TEDUNG;Mc;0;L;1B3A 1B35;;;;N;;;;;\n1B3C;BALINESE VOWEL SIGN LA LENGA;Mn;0;NSM;;;;;N;;;;;\n1B3D;BALINESE VOWEL SIGN LA LENGA TEDUNG;Mc;0;L;1B3C 1B35;;;;N;;;;;\n1B3E;BALINESE VOWEL SIGN TALING;Mc;0;L;;;;;N;;;;;\n1B3F;BALINESE VOWEL SIGN TALING REPA;Mc;0;L;;;;;N;;;;;\n1B40;BALINESE VOWEL SIGN TALING TEDUNG;Mc;0;L;1B3E 1B35;;;;N;;;;;\n1B41;BALINESE VOWEL SIGN TALING REPA TEDUNG;Mc;0;L;1B3F 1B35;;;;N;;;;;\n1B42;BALINESE VOWEL SIGN PEPET;Mn;0;NSM;;;;;N;;;;;\n1B43;BALINESE VOWEL SIGN PEPET TEDUNG;Mc;0;L;1B42 1B35;;;;N;;;;;\n1B44;BALINESE ADEG ADEG;Mc;9;L;;;;;N;;;;;\n1B45;BALINESE LETTER KAF SASAK;Lo;0;L;;;;;N;;;;;\n1B46;BALINESE LETTER KHOT SASAK;Lo;0;L;;;;;N;;;;;\n1B47;BALINESE LETTER TZIR SASAK;Lo;0;L;;;;;N;;;;;\n1B48;BALINESE LETTER EF SASAK;Lo;0;L;;;;;N;;;;;\n1B49;BALINESE LETTER VE SASAK;Lo;0;L;;;;;N;;;;;\n1B4A;BALINESE LETTER ZAL SASAK;Lo;0;L;;;;;N;;;;;\n1B4B;BALINESE LETTER ASYURA SASAK;Lo;0;L;;;;;N;;;;;\n1B50;BALINESE DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1B51;BALINESE DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1B52;BALINESE DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1B53;BALINESE DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1B54;BALINESE DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1B55;BALINESE DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1B56;BALINESE DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1B57;BALINESE DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1B58;BALINESE DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1B59;BALINESE DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1B5A;BALINESE PANTI;Po;0;L;;;;;N;;;;;\n1B5B;BALINESE PAMADA;Po;0;L;;;;;N;;;;;\n1B5C;BALINESE WINDU;Po;0;L;;;;;N;;;;;\n1B5D;BALINESE CARIK PAMUNGKAH;Po;0;L;;;;;N;;;;;\n1B5E;BALINESE CARIK SIKI;Po;0;L;;;;;N;;;;;\n1B5F;BALINESE CARIK PAREREN;Po;0;L;;;;;N;;;;;\n1B60;BALINESE PAMENENG;Po;0;L;;;;;N;;;;;\n1B61;BALINESE MUSICAL SYMBOL DONG;So;0;L;;;;;N;;;;;\n1B62;BALINESE MUSICAL SYMBOL DENG;So;0;L;;;;;N;;;;;\n1B63;BALINESE MUSICAL SYMBOL DUNG;So;0;L;;;;;N;;;;;\n1B64;BALINESE MUSICAL SYMBOL DANG;So;0;L;;;;;N;;;;;\n1B65;BALINESE MUSICAL SYMBOL DANG SURANG;So;0;L;;;;;N;;;;;\n1B66;BALINESE MUSICAL SYMBOL DING;So;0;L;;;;;N;;;;;\n1B67;BALINESE MUSICAL SYMBOL DAENG;So;0;L;;;;;N;;;;;\n1B68;BALINESE MUSICAL SYMBOL DEUNG;So;0;L;;;;;N;;;;;\n1B69;BALINESE MUSICAL SYMBOL DAING;So;0;L;;;;;N;;;;;\n1B6A;BALINESE MUSICAL SYMBOL DANG GEDE;So;0;L;;;;;N;;;;;\n1B6B;BALINESE MUSICAL SYMBOL COMBINING TEGEH;Mn;230;NSM;;;;;N;;;;;\n1B6C;BALINESE MUSICAL SYMBOL COMBINING ENDEP;Mn;220;NSM;;;;;N;;;;;\n1B6D;BALINESE MUSICAL SYMBOL COMBINING KEMPUL;Mn;230;NSM;;;;;N;;;;;\n1B6E;BALINESE MUSICAL SYMBOL COMBINING KEMPLI;Mn;230;NSM;;;;;N;;;;;\n1B6F;BALINESE MUSICAL SYMBOL COMBINING JEGOGAN;Mn;230;NSM;;;;;N;;;;;\n1B70;BALINESE MUSICAL SYMBOL COMBINING KEMPUL WITH JEGOGAN;Mn;230;NSM;;;;;N;;;;;\n1B71;BALINESE MUSICAL SYMBOL COMBINING KEMPLI WITH JEGOGAN;Mn;230;NSM;;;;;N;;;;;\n1B72;BALINESE MUSICAL SYMBOL COMBINING BENDE;Mn;230;NSM;;;;;N;;;;;\n1B73;BALINESE MUSICAL SYMBOL COMBINING GONG;Mn;230;NSM;;;;;N;;;;;\n1B74;BALINESE MUSICAL SYMBOL RIGHT-HAND OPEN DUG;So;0;L;;;;;N;;;;;\n1B75;BALINESE MUSICAL SYMBOL RIGHT-HAND OPEN DAG;So;0;L;;;;;N;;;;;\n1B76;BALINESE MUSICAL SYMBOL RIGHT-HAND CLOSED TUK;So;0;L;;;;;N;;;;;\n1B77;BALINESE MUSICAL SYMBOL RIGHT-HAND CLOSED TAK;So;0;L;;;;;N;;;;;\n1B78;BALINESE MUSICAL SYMBOL LEFT-HAND OPEN PANG;So;0;L;;;;;N;;;;;\n1B79;BALINESE MUSICAL SYMBOL LEFT-HAND OPEN PUNG;So;0;L;;;;;N;;;;;\n1B7A;BALINESE MUSICAL SYMBOL LEFT-HAND CLOSED PLAK;So;0;L;;;;;N;;;;;\n1B7B;BALINESE MUSICAL SYMBOL LEFT-HAND CLOSED PLUK;So;0;L;;;;;N;;;;;\n1B7C;BALINESE MUSICAL SYMBOL LEFT-HAND OPEN PING;So;0;L;;;;;N;;;;;\n1B80;SUNDANESE SIGN PANYECEK;Mn;0;NSM;;;;;N;;;;;\n1B81;SUNDANESE SIGN PANGLAYAR;Mn;0;NSM;;;;;N;;;;;\n1B82;SUNDANESE SIGN PANGWISAD;Mc;0;L;;;;;N;;;;;\n1B83;SUNDANESE LETTER A;Lo;0;L;;;;;N;;;;;\n1B84;SUNDANESE LETTER I;Lo;0;L;;;;;N;;;;;\n1B85;SUNDANESE LETTER U;Lo;0;L;;;;;N;;;;;\n1B86;SUNDANESE LETTER AE;Lo;0;L;;;;;N;;;;;\n1B87;SUNDANESE LETTER O;Lo;0;L;;;;;N;;;;;\n1B88;SUNDANESE LETTER E;Lo;0;L;;;;;N;;;;;\n1B89;SUNDANESE LETTER EU;Lo;0;L;;;;;N;;;;;\n1B8A;SUNDANESE LETTER KA;Lo;0;L;;;;;N;;;;;\n1B8B;SUNDANESE LETTER QA;Lo;0;L;;;;;N;;;;;\n1B8C;SUNDANESE LETTER GA;Lo;0;L;;;;;N;;;;;\n1B8D;SUNDANESE LETTER NGA;Lo;0;L;;;;;N;;;;;\n1B8E;SUNDANESE LETTER CA;Lo;0;L;;;;;N;;;;;\n1B8F;SUNDANESE LETTER JA;Lo;0;L;;;;;N;;;;;\n1B90;SUNDANESE LETTER ZA;Lo;0;L;;;;;N;;;;;\n1B91;SUNDANESE LETTER NYA;Lo;0;L;;;;;N;;;;;\n1B92;SUNDANESE LETTER TA;Lo;0;L;;;;;N;;;;;\n1B93;SUNDANESE LETTER DA;Lo;0;L;;;;;N;;;;;\n1B94;SUNDANESE LETTER NA;Lo;0;L;;;;;N;;;;;\n1B95;SUNDANESE LETTER PA;Lo;0;L;;;;;N;;;;;\n1B96;SUNDANESE LETTER FA;Lo;0;L;;;;;N;;;;;\n1B97;SUNDANESE LETTER VA;Lo;0;L;;;;;N;;;;;\n1B98;SUNDANESE LETTER BA;Lo;0;L;;;;;N;;;;;\n1B99;SUNDANESE LETTER MA;Lo;0;L;;;;;N;;;;;\n1B9A;SUNDANESE LETTER YA;Lo;0;L;;;;;N;;;;;\n1B9B;SUNDANESE LETTER RA;Lo;0;L;;;;;N;;;;;\n1B9C;SUNDANESE LETTER LA;Lo;0;L;;;;;N;;;;;\n1B9D;SUNDANESE LETTER WA;Lo;0;L;;;;;N;;;;;\n1B9E;SUNDANESE LETTER SA;Lo;0;L;;;;;N;;;;;\n1B9F;SUNDANESE LETTER XA;Lo;0;L;;;;;N;;;;;\n1BA0;SUNDANESE LETTER HA;Lo;0;L;;;;;N;;;;;\n1BA1;SUNDANESE CONSONANT SIGN PAMINGKAL;Mc;0;L;;;;;N;;;;;\n1BA2;SUNDANESE CONSONANT SIGN PANYAKRA;Mn;0;NSM;;;;;N;;;;;\n1BA3;SUNDANESE CONSONANT SIGN PANYIKU;Mn;0;NSM;;;;;N;;;;;\n1BA4;SUNDANESE VOWEL SIGN PANGHULU;Mn;0;NSM;;;;;N;;;;;\n1BA5;SUNDANESE VOWEL SIGN PANYUKU;Mn;0;NSM;;;;;N;;;;;\n1BA6;SUNDANESE VOWEL SIGN PANAELAENG;Mc;0;L;;;;;N;;;;;\n1BA7;SUNDANESE VOWEL SIGN PANOLONG;Mc;0;L;;;;;N;;;;;\n1BA8;SUNDANESE VOWEL SIGN PAMEPET;Mn;0;NSM;;;;;N;;;;;\n1BA9;SUNDANESE VOWEL SIGN PANEULEUNG;Mn;0;NSM;;;;;N;;;;;\n1BAA;SUNDANESE SIGN PAMAAEH;Mc;9;L;;;;;N;;;;;\n1BAB;SUNDANESE SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n1BAC;SUNDANESE CONSONANT SIGN PASANGAN MA;Mc;0;L;;;;;N;;;;;\n1BAD;SUNDANESE CONSONANT SIGN PASANGAN WA;Mc;0;L;;;;;N;;;;;\n1BAE;SUNDANESE LETTER KHA;Lo;0;L;;;;;N;;;;;\n1BAF;SUNDANESE LETTER SYA;Lo;0;L;;;;;N;;;;;\n1BB0;SUNDANESE DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1BB1;SUNDANESE DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1BB2;SUNDANESE DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1BB3;SUNDANESE DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1BB4;SUNDANESE DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1BB5;SUNDANESE DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1BB6;SUNDANESE DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1BB7;SUNDANESE DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1BB8;SUNDANESE DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1BB9;SUNDANESE DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1BBA;SUNDANESE AVAGRAHA;Lo;0;L;;;;;N;;;;;\n1BBB;SUNDANESE LETTER REU;Lo;0;L;;;;;N;;;;;\n1BBC;SUNDANESE LETTER LEU;Lo;0;L;;;;;N;;;;;\n1BBD;SUNDANESE LETTER BHA;Lo;0;L;;;;;N;;;;;\n1BBE;SUNDANESE LETTER FINAL K;Lo;0;L;;;;;N;;;;;\n1BBF;SUNDANESE LETTER FINAL M;Lo;0;L;;;;;N;;;;;\n1BC0;BATAK LETTER A;Lo;0;L;;;;;N;;;;;\n1BC1;BATAK LETTER SIMALUNGUN A;Lo;0;L;;;;;N;;;;;\n1BC2;BATAK LETTER HA;Lo;0;L;;;;;N;;;;;\n1BC3;BATAK LETTER SIMALUNGUN HA;Lo;0;L;;;;;N;;;;;\n1BC4;BATAK LETTER MANDAILING HA;Lo;0;L;;;;;N;;;;;\n1BC5;BATAK LETTER BA;Lo;0;L;;;;;N;;;;;\n1BC6;BATAK LETTER KARO BA;Lo;0;L;;;;;N;;;;;\n1BC7;BATAK LETTER PA;Lo;0;L;;;;;N;;;;;\n1BC8;BATAK LETTER SIMALUNGUN PA;Lo;0;L;;;;;N;;;;;\n1BC9;BATAK LETTER NA;Lo;0;L;;;;;N;;;;;\n1BCA;BATAK LETTER MANDAILING NA;Lo;0;L;;;;;N;;;;;\n1BCB;BATAK LETTER WA;Lo;0;L;;;;;N;;;;;\n1BCC;BATAK LETTER SIMALUNGUN WA;Lo;0;L;;;;;N;;;;;\n1BCD;BATAK LETTER PAKPAK WA;Lo;0;L;;;;;N;;;;;\n1BCE;BATAK LETTER GA;Lo;0;L;;;;;N;;;;;\n1BCF;BATAK LETTER SIMALUNGUN GA;Lo;0;L;;;;;N;;;;;\n1BD0;BATAK LETTER JA;Lo;0;L;;;;;N;;;;;\n1BD1;BATAK LETTER DA;Lo;0;L;;;;;N;;;;;\n1BD2;BATAK LETTER RA;Lo;0;L;;;;;N;;;;;\n1BD3;BATAK LETTER SIMALUNGUN RA;Lo;0;L;;;;;N;;;;;\n1BD4;BATAK LETTER MA;Lo;0;L;;;;;N;;;;;\n1BD5;BATAK LETTER SIMALUNGUN MA;Lo;0;L;;;;;N;;;;;\n1BD6;BATAK LETTER SOUTHERN TA;Lo;0;L;;;;;N;;;;;\n1BD7;BATAK LETTER NORTHERN TA;Lo;0;L;;;;;N;;;;;\n1BD8;BATAK LETTER SA;Lo;0;L;;;;;N;;;;;\n1BD9;BATAK LETTER SIMALUNGUN SA;Lo;0;L;;;;;N;;;;;\n1BDA;BATAK LETTER MANDAILING SA;Lo;0;L;;;;;N;;;;;\n1BDB;BATAK LETTER YA;Lo;0;L;;;;;N;;;;;\n1BDC;BATAK LETTER SIMALUNGUN YA;Lo;0;L;;;;;N;;;;;\n1BDD;BATAK LETTER NGA;Lo;0;L;;;;;N;;;;;\n1BDE;BATAK LETTER LA;Lo;0;L;;;;;N;;;;;\n1BDF;BATAK LETTER SIMALUNGUN LA;Lo;0;L;;;;;N;;;;;\n1BE0;BATAK LETTER NYA;Lo;0;L;;;;;N;;;;;\n1BE1;BATAK LETTER CA;Lo;0;L;;;;;N;;;;;\n1BE2;BATAK LETTER NDA;Lo;0;L;;;;;N;;;;;\n1BE3;BATAK LETTER MBA;Lo;0;L;;;;;N;;;;;\n1BE4;BATAK LETTER I;Lo;0;L;;;;;N;;;;;\n1BE5;BATAK LETTER U;Lo;0;L;;;;;N;;;;;\n1BE6;BATAK SIGN TOMPI;Mn;7;NSM;;;;;N;;;;;\n1BE7;BATAK VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n1BE8;BATAK VOWEL SIGN PAKPAK E;Mn;0;NSM;;;;;N;;;;;\n1BE9;BATAK VOWEL SIGN EE;Mn;0;NSM;;;;;N;;;;;\n1BEA;BATAK VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n1BEB;BATAK VOWEL SIGN KARO I;Mc;0;L;;;;;N;;;;;\n1BEC;BATAK VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n1BED;BATAK VOWEL SIGN KARO O;Mn;0;NSM;;;;;N;;;;;\n1BEE;BATAK VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n1BEF;BATAK VOWEL SIGN U FOR SIMALUNGUN SA;Mn;0;NSM;;;;;N;;;;;\n1BF0;BATAK CONSONANT SIGN NG;Mn;0;NSM;;;;;N;;;;;\n1BF1;BATAK CONSONANT SIGN H;Mn;0;NSM;;;;;N;;;;;\n1BF2;BATAK PANGOLAT;Mc;9;L;;;;;N;;;;;\n1BF3;BATAK PANONGONAN;Mc;9;L;;;;;N;;;;;\n1BFC;BATAK SYMBOL BINDU NA METEK;Po;0;L;;;;;N;;;;;\n1BFD;BATAK SYMBOL BINDU PINARBORAS;Po;0;L;;;;;N;;;;;\n1BFE;BATAK SYMBOL BINDU JUDUL;Po;0;L;;;;;N;;;;;\n1BFF;BATAK SYMBOL BINDU PANGOLAT;Po;0;L;;;;;N;;;;;\n1C00;LEPCHA LETTER KA;Lo;0;L;;;;;N;;;;;\n1C01;LEPCHA LETTER KLA;Lo;0;L;;;;;N;;;;;\n1C02;LEPCHA LETTER KHA;Lo;0;L;;;;;N;;;;;\n1C03;LEPCHA LETTER GA;Lo;0;L;;;;;N;;;;;\n1C04;LEPCHA LETTER GLA;Lo;0;L;;;;;N;;;;;\n1C05;LEPCHA LETTER NGA;Lo;0;L;;;;;N;;;;;\n1C06;LEPCHA LETTER CA;Lo;0;L;;;;;N;;;;;\n1C07;LEPCHA LETTER CHA;Lo;0;L;;;;;N;;;;;\n1C08;LEPCHA LETTER JA;Lo;0;L;;;;;N;;;;;\n1C09;LEPCHA LETTER NYA;Lo;0;L;;;;;N;;;;;\n1C0A;LEPCHA LETTER TA;Lo;0;L;;;;;N;;;;;\n1C0B;LEPCHA LETTER THA;Lo;0;L;;;;;N;;;;;\n1C0C;LEPCHA LETTER DA;Lo;0;L;;;;;N;;;;;\n1C0D;LEPCHA LETTER NA;Lo;0;L;;;;;N;;;;;\n1C0E;LEPCHA LETTER PA;Lo;0;L;;;;;N;;;;;\n1C0F;LEPCHA LETTER PLA;Lo;0;L;;;;;N;;;;;\n1C10;LEPCHA LETTER PHA;Lo;0;L;;;;;N;;;;;\n1C11;LEPCHA LETTER FA;Lo;0;L;;;;;N;;;;;\n1C12;LEPCHA LETTER FLA;Lo;0;L;;;;;N;;;;;\n1C13;LEPCHA LETTER BA;Lo;0;L;;;;;N;;;;;\n1C14;LEPCHA LETTER BLA;Lo;0;L;;;;;N;;;;;\n1C15;LEPCHA LETTER MA;Lo;0;L;;;;;N;;;;;\n1C16;LEPCHA LETTER MLA;Lo;0;L;;;;;N;;;;;\n1C17;LEPCHA LETTER TSA;Lo;0;L;;;;;N;;;;;\n1C18;LEPCHA LETTER TSHA;Lo;0;L;;;;;N;;;;;\n1C19;LEPCHA LETTER DZA;Lo;0;L;;;;;N;;;;;\n1C1A;LEPCHA LETTER YA;Lo;0;L;;;;;N;;;;;\n1C1B;LEPCHA LETTER RA;Lo;0;L;;;;;N;;;;;\n1C1C;LEPCHA LETTER LA;Lo;0;L;;;;;N;;;;;\n1C1D;LEPCHA LETTER HA;Lo;0;L;;;;;N;;;;;\n1C1E;LEPCHA LETTER HLA;Lo;0;L;;;;;N;;;;;\n1C1F;LEPCHA LETTER VA;Lo;0;L;;;;;N;;;;;\n1C20;LEPCHA LETTER SA;Lo;0;L;;;;;N;;;;;\n1C21;LEPCHA LETTER SHA;Lo;0;L;;;;;N;;;;;\n1C22;LEPCHA LETTER WA;Lo;0;L;;;;;N;;;;;\n1C23;LEPCHA LETTER A;Lo;0;L;;;;;N;;;;;\n1C24;LEPCHA SUBJOINED LETTER YA;Mc;0;L;;;;;N;;;;;\n1C25;LEPCHA SUBJOINED LETTER RA;Mc;0;L;;;;;N;;;;;\n1C26;LEPCHA VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n1C27;LEPCHA VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n1C28;LEPCHA VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n1C29;LEPCHA VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\n1C2A;LEPCHA VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n1C2B;LEPCHA VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n1C2C;LEPCHA VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n1C2D;LEPCHA CONSONANT SIGN K;Mn;0;NSM;;;;;N;;;;;\n1C2E;LEPCHA CONSONANT SIGN M;Mn;0;NSM;;;;;N;;;;;\n1C2F;LEPCHA CONSONANT SIGN L;Mn;0;NSM;;;;;N;;;;;\n1C30;LEPCHA CONSONANT SIGN N;Mn;0;NSM;;;;;N;;;;;\n1C31;LEPCHA CONSONANT SIGN P;Mn;0;NSM;;;;;N;;;;;\n1C32;LEPCHA CONSONANT SIGN R;Mn;0;NSM;;;;;N;;;;;\n1C33;LEPCHA CONSONANT SIGN T;Mn;0;NSM;;;;;N;;;;;\n1C34;LEPCHA CONSONANT SIGN NYIN-DO;Mc;0;L;;;;;N;;;;;\n1C35;LEPCHA CONSONANT SIGN KANG;Mc;0;L;;;;;N;;;;;\n1C36;LEPCHA SIGN RAN;Mn;0;NSM;;;;;N;;;;;\n1C37;LEPCHA SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n1C3B;LEPCHA PUNCTUATION TA-ROL;Po;0;L;;;;;N;;;;;\n1C3C;LEPCHA PUNCTUATION NYET THYOOM TA-ROL;Po;0;L;;;;;N;;;;;\n1C3D;LEPCHA PUNCTUATION CER-WA;Po;0;L;;;;;N;;;;;\n1C3E;LEPCHA PUNCTUATION TSHOOK CER-WA;Po;0;L;;;;;N;;;;;\n1C3F;LEPCHA PUNCTUATION TSHOOK;Po;0;L;;;;;N;;;;;\n1C40;LEPCHA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1C41;LEPCHA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1C42;LEPCHA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1C43;LEPCHA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1C44;LEPCHA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1C45;LEPCHA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1C46;LEPCHA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1C47;LEPCHA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1C48;LEPCHA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1C49;LEPCHA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1C4D;LEPCHA LETTER TTA;Lo;0;L;;;;;N;;;;;\n1C4E;LEPCHA LETTER TTHA;Lo;0;L;;;;;N;;;;;\n1C4F;LEPCHA LETTER DDA;Lo;0;L;;;;;N;;;;;\n1C50;OL CHIKI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n1C51;OL CHIKI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n1C52;OL CHIKI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n1C53;OL CHIKI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1C54;OL CHIKI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1C55;OL CHIKI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1C56;OL CHIKI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1C57;OL CHIKI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1C58;OL CHIKI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1C59;OL CHIKI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n1C5A;OL CHIKI LETTER LA;Lo;0;L;;;;;N;;;;;\n1C5B;OL CHIKI LETTER AT;Lo;0;L;;;;;N;;;;;\n1C5C;OL CHIKI LETTER AG;Lo;0;L;;;;;N;;;;;\n1C5D;OL CHIKI LETTER ANG;Lo;0;L;;;;;N;;;;;\n1C5E;OL CHIKI LETTER AL;Lo;0;L;;;;;N;;;;;\n1C5F;OL CHIKI LETTER LAA;Lo;0;L;;;;;N;;;;;\n1C60;OL CHIKI LETTER AAK;Lo;0;L;;;;;N;;;;;\n1C61;OL CHIKI LETTER AAJ;Lo;0;L;;;;;N;;;;;\n1C62;OL CHIKI LETTER AAM;Lo;0;L;;;;;N;;;;;\n1C63;OL CHIKI LETTER AAW;Lo;0;L;;;;;N;;;;;\n1C64;OL CHIKI LETTER LI;Lo;0;L;;;;;N;;;;;\n1C65;OL CHIKI LETTER IS;Lo;0;L;;;;;N;;;;;\n1C66;OL CHIKI LETTER IH;Lo;0;L;;;;;N;;;;;\n1C67;OL CHIKI LETTER INY;Lo;0;L;;;;;N;;;;;\n1C68;OL CHIKI LETTER IR;Lo;0;L;;;;;N;;;;;\n1C69;OL CHIKI LETTER LU;Lo;0;L;;;;;N;;;;;\n1C6A;OL CHIKI LETTER UC;Lo;0;L;;;;;N;;;;;\n1C6B;OL CHIKI LETTER UD;Lo;0;L;;;;;N;;;;;\n1C6C;OL CHIKI LETTER UNN;Lo;0;L;;;;;N;;;;;\n1C6D;OL CHIKI LETTER UY;Lo;0;L;;;;;N;;;;;\n1C6E;OL CHIKI LETTER LE;Lo;0;L;;;;;N;;;;;\n1C6F;OL CHIKI LETTER EP;Lo;0;L;;;;;N;;;;;\n1C70;OL CHIKI LETTER EDD;Lo;0;L;;;;;N;;;;;\n1C71;OL CHIKI LETTER EN;Lo;0;L;;;;;N;;;;;\n1C72;OL CHIKI LETTER ERR;Lo;0;L;;;;;N;;;;;\n1C73;OL CHIKI LETTER LO;Lo;0;L;;;;;N;;;;;\n1C74;OL CHIKI LETTER OTT;Lo;0;L;;;;;N;;;;;\n1C75;OL CHIKI LETTER OB;Lo;0;L;;;;;N;;;;;\n1C76;OL CHIKI LETTER OV;Lo;0;L;;;;;N;;;;;\n1C77;OL CHIKI LETTER OH;Lo;0;L;;;;;N;;;;;\n1C78;OL CHIKI MU TTUDDAG;Lm;0;L;;;;;N;;;;;\n1C79;OL CHIKI GAAHLAA TTUDDAAG;Lm;0;L;;;;;N;;;;;\n1C7A;OL CHIKI MU-GAAHLAA TTUDDAAG;Lm;0;L;;;;;N;;;;;\n1C7B;OL CHIKI RELAA;Lm;0;L;;;;;N;;;;;\n1C7C;OL CHIKI PHAARKAA;Lm;0;L;;;;;N;;;;;\n1C7D;OL CHIKI AHAD;Lm;0;L;;;;;N;;;;;\n1C7E;OL CHIKI PUNCTUATION MUCAAD;Po;0;L;;;;;N;;;;;\n1C7F;OL CHIKI PUNCTUATION DOUBLE MUCAAD;Po;0;L;;;;;N;;;;;\n1CC0;SUNDANESE PUNCTUATION BINDU SURYA;Po;0;L;;;;;N;;;;;\n1CC1;SUNDANESE PUNCTUATION BINDU PANGLONG;Po;0;L;;;;;N;;;;;\n1CC2;SUNDANESE PUNCTUATION BINDU PURNAMA;Po;0;L;;;;;N;;;;;\n1CC3;SUNDANESE PUNCTUATION BINDU CAKRA;Po;0;L;;;;;N;;;;;\n1CC4;SUNDANESE PUNCTUATION BINDU LEU SATANGA;Po;0;L;;;;;N;;;;;\n1CC5;SUNDANESE PUNCTUATION BINDU KA SATANGA;Po;0;L;;;;;N;;;;;\n1CC6;SUNDANESE PUNCTUATION BINDU DA SATANGA;Po;0;L;;;;;N;;;;;\n1CC7;SUNDANESE PUNCTUATION BINDU BA SATANGA;Po;0;L;;;;;N;;;;;\n1CD0;VEDIC TONE KARSHANA;Mn;230;NSM;;;;;N;;;;;\n1CD1;VEDIC TONE SHARA;Mn;230;NSM;;;;;N;;;;;\n1CD2;VEDIC TONE PRENKHA;Mn;230;NSM;;;;;N;;;;;\n1CD3;VEDIC SIGN NIHSHVASA;Po;0;L;;;;;N;;;;;\n1CD4;VEDIC SIGN YAJURVEDIC MIDLINE SVARITA;Mn;1;NSM;;;;;N;;;;;\n1CD5;VEDIC TONE YAJURVEDIC AGGRAVATED INDEPENDENT SVARITA;Mn;220;NSM;;;;;N;;;;;\n1CD6;VEDIC TONE YAJURVEDIC INDEPENDENT SVARITA;Mn;220;NSM;;;;;N;;;;;\n1CD7;VEDIC TONE YAJURVEDIC KATHAKA INDEPENDENT SVARITA;Mn;220;NSM;;;;;N;;;;;\n1CD8;VEDIC TONE CANDRA BELOW;Mn;220;NSM;;;;;N;;;;;\n1CD9;VEDIC TONE YAJURVEDIC KATHAKA INDEPENDENT SVARITA SCHROEDER;Mn;220;NSM;;;;;N;;;;;\n1CDA;VEDIC TONE DOUBLE SVARITA;Mn;230;NSM;;;;;N;;;;;\n1CDB;VEDIC TONE TRIPLE SVARITA;Mn;230;NSM;;;;;N;;;;;\n1CDC;VEDIC TONE KATHAKA ANUDATTA;Mn;220;NSM;;;;;N;;;;;\n1CDD;VEDIC TONE DOT BELOW;Mn;220;NSM;;;;;N;;;;;\n1CDE;VEDIC TONE TWO DOTS BELOW;Mn;220;NSM;;;;;N;;;;;\n1CDF;VEDIC TONE THREE DOTS BELOW;Mn;220;NSM;;;;;N;;;;;\n1CE0;VEDIC TONE RIGVEDIC KASHMIRI INDEPENDENT SVARITA;Mn;230;NSM;;;;;N;;;;;\n1CE1;VEDIC TONE ATHARVAVEDIC INDEPENDENT SVARITA;Mc;0;L;;;;;N;;;;;\n1CE2;VEDIC SIGN VISARGA SVARITA;Mn;1;NSM;;;;;N;;;;;\n1CE3;VEDIC SIGN VISARGA UDATTA;Mn;1;NSM;;;;;N;;;;;\n1CE4;VEDIC SIGN REVERSED VISARGA UDATTA;Mn;1;NSM;;;;;N;;;;;\n1CE5;VEDIC SIGN VISARGA ANUDATTA;Mn;1;NSM;;;;;N;;;;;\n1CE6;VEDIC SIGN REVERSED VISARGA ANUDATTA;Mn;1;NSM;;;;;N;;;;;\n1CE7;VEDIC SIGN VISARGA UDATTA WITH TAIL;Mn;1;NSM;;;;;N;;;;;\n1CE8;VEDIC SIGN VISARGA ANUDATTA WITH TAIL;Mn;1;NSM;;;;;N;;;;;\n1CE9;VEDIC SIGN ANUSVARA ANTARGOMUKHA;Lo;0;L;;;;;N;;;;;\n1CEA;VEDIC SIGN ANUSVARA BAHIRGOMUKHA;Lo;0;L;;;;;N;;;;;\n1CEB;VEDIC SIGN ANUSVARA VAMAGOMUKHA;Lo;0;L;;;;;N;;;;;\n1CEC;VEDIC SIGN ANUSVARA VAMAGOMUKHA WITH TAIL;Lo;0;L;;;;;N;;;;;\n1CED;VEDIC SIGN TIRYAK;Mn;220;NSM;;;;;N;;;;;\n1CEE;VEDIC SIGN HEXIFORM LONG ANUSVARA;Lo;0;L;;;;;N;;;;;\n1CEF;VEDIC SIGN LONG ANUSVARA;Lo;0;L;;;;;N;;;;;\n1CF0;VEDIC SIGN RTHANG LONG ANUSVARA;Lo;0;L;;;;;N;;;;;\n1CF1;VEDIC SIGN ANUSVARA UBHAYATO MUKHA;Lo;0;L;;;;;N;;;;;\n1CF2;VEDIC SIGN ARDHAVISARGA;Mc;0;L;;;;;N;;;;;\n1CF3;VEDIC SIGN ROTATED ARDHAVISARGA;Mc;0;L;;;;;N;;;;;\n1CF4;VEDIC TONE CANDRA ABOVE;Mn;230;NSM;;;;;N;;;;;\n1CF5;VEDIC SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;\n1CF6;VEDIC SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;\n1D00;LATIN LETTER SMALL CAPITAL A;Ll;0;L;;;;;N;;;;;\n1D01;LATIN LETTER SMALL CAPITAL AE;Ll;0;L;;;;;N;;;;;\n1D02;LATIN SMALL LETTER TURNED AE;Ll;0;L;;;;;N;;;;;\n1D03;LATIN LETTER SMALL CAPITAL BARRED B;Ll;0;L;;;;;N;;;;;\n1D04;LATIN LETTER SMALL CAPITAL C;Ll;0;L;;;;;N;;;;;\n1D05;LATIN LETTER SMALL CAPITAL D;Ll;0;L;;;;;N;;;;;\n1D06;LATIN LETTER SMALL CAPITAL ETH;Ll;0;L;;;;;N;;;;;\n1D07;LATIN LETTER SMALL CAPITAL E;Ll;0;L;;;;;N;;;;;\n1D08;LATIN SMALL LETTER TURNED OPEN E;Ll;0;L;;;;;N;;;;;\n1D09;LATIN SMALL LETTER TURNED I;Ll;0;L;;;;;N;;;;;\n1D0A;LATIN LETTER SMALL CAPITAL J;Ll;0;L;;;;;N;;;;;\n1D0B;LATIN LETTER SMALL CAPITAL K;Ll;0;L;;;;;N;;;;;\n1D0C;LATIN LETTER SMALL CAPITAL L WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D0D;LATIN LETTER SMALL CAPITAL M;Ll;0;L;;;;;N;;;;;\n1D0E;LATIN LETTER SMALL CAPITAL REVERSED N;Ll;0;L;;;;;N;;;;;\n1D0F;LATIN LETTER SMALL CAPITAL O;Ll;0;L;;;;;N;;;;;\n1D10;LATIN LETTER SMALL CAPITAL OPEN O;Ll;0;L;;;;;N;;;;;\n1D11;LATIN SMALL LETTER SIDEWAYS O;Ll;0;L;;;;;N;;;;;\n1D12;LATIN SMALL LETTER SIDEWAYS OPEN O;Ll;0;L;;;;;N;;;;;\n1D13;LATIN SMALL LETTER SIDEWAYS O WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D14;LATIN SMALL LETTER TURNED OE;Ll;0;L;;;;;N;;;;;\n1D15;LATIN LETTER SMALL CAPITAL OU;Ll;0;L;;;;;N;;;;;\n1D16;LATIN SMALL LETTER TOP HALF O;Ll;0;L;;;;;N;;;;;\n1D17;LATIN SMALL LETTER BOTTOM HALF O;Ll;0;L;;;;;N;;;;;\n1D18;LATIN LETTER SMALL CAPITAL P;Ll;0;L;;;;;N;;;;;\n1D19;LATIN LETTER SMALL CAPITAL REVERSED R;Ll;0;L;;;;;N;;;;;\n1D1A;LATIN LETTER SMALL CAPITAL TURNED R;Ll;0;L;;;;;N;;;;;\n1D1B;LATIN LETTER SMALL CAPITAL T;Ll;0;L;;;;;N;;;;;\n1D1C;LATIN LETTER SMALL CAPITAL U;Ll;0;L;;;;;N;;;;;\n1D1D;LATIN SMALL LETTER SIDEWAYS U;Ll;0;L;;;;;N;;;;;\n1D1E;LATIN SMALL LETTER SIDEWAYS DIAERESIZED U;Ll;0;L;;;;;N;;;;;\n1D1F;LATIN SMALL LETTER SIDEWAYS TURNED M;Ll;0;L;;;;;N;;;;;\n1D20;LATIN LETTER SMALL CAPITAL V;Ll;0;L;;;;;N;;;;;\n1D21;LATIN LETTER SMALL CAPITAL W;Ll;0;L;;;;;N;;;;;\n1D22;LATIN LETTER SMALL CAPITAL Z;Ll;0;L;;;;;N;;;;;\n1D23;LATIN LETTER SMALL CAPITAL EZH;Ll;0;L;;;;;N;;;;;\n1D24;LATIN LETTER VOICED LARYNGEAL SPIRANT;Ll;0;L;;;;;N;;;;;\n1D25;LATIN LETTER AIN;Ll;0;L;;;;;N;;;;;\n1D26;GREEK LETTER SMALL CAPITAL GAMMA;Ll;0;L;;;;;N;;;;;\n1D27;GREEK LETTER SMALL CAPITAL LAMDA;Ll;0;L;;;;;N;;;;;\n1D28;GREEK LETTER SMALL CAPITAL PI;Ll;0;L;;;;;N;;;;;\n1D29;GREEK LETTER SMALL CAPITAL RHO;Ll;0;L;;;;;N;;;;;\n1D2A;GREEK LETTER SMALL CAPITAL PSI;Ll;0;L;;;;;N;;;;;\n1D2B;CYRILLIC LETTER SMALL CAPITAL EL;Ll;0;L;;;;;N;;;;;\n1D2C;MODIFIER LETTER CAPITAL A;Lm;0;L;<super> 0041;;;;N;;;;;\n1D2D;MODIFIER LETTER CAPITAL AE;Lm;0;L;<super> 00C6;;;;N;;;;;\n1D2E;MODIFIER LETTER CAPITAL B;Lm;0;L;<super> 0042;;;;N;;;;;\n1D2F;MODIFIER LETTER CAPITAL BARRED B;Lm;0;L;;;;;N;;;;;\n1D30;MODIFIER LETTER CAPITAL D;Lm;0;L;<super> 0044;;;;N;;;;;\n1D31;MODIFIER LETTER CAPITAL E;Lm;0;L;<super> 0045;;;;N;;;;;\n1D32;MODIFIER LETTER CAPITAL REVERSED E;Lm;0;L;<super> 018E;;;;N;;;;;\n1D33;MODIFIER LETTER CAPITAL G;Lm;0;L;<super> 0047;;;;N;;;;;\n1D34;MODIFIER LETTER CAPITAL H;Lm;0;L;<super> 0048;;;;N;;;;;\n1D35;MODIFIER LETTER CAPITAL I;Lm;0;L;<super> 0049;;;;N;;;;;\n1D36;MODIFIER LETTER CAPITAL J;Lm;0;L;<super> 004A;;;;N;;;;;\n1D37;MODIFIER LETTER CAPITAL K;Lm;0;L;<super> 004B;;;;N;;;;;\n1D38;MODIFIER LETTER CAPITAL L;Lm;0;L;<super> 004C;;;;N;;;;;\n1D39;MODIFIER LETTER CAPITAL M;Lm;0;L;<super> 004D;;;;N;;;;;\n1D3A;MODIFIER LETTER CAPITAL N;Lm;0;L;<super> 004E;;;;N;;;;;\n1D3B;MODIFIER LETTER CAPITAL REVERSED N;Lm;0;L;;;;;N;;;;;\n1D3C;MODIFIER LETTER CAPITAL O;Lm;0;L;<super> 004F;;;;N;;;;;\n1D3D;MODIFIER LETTER CAPITAL OU;Lm;0;L;<super> 0222;;;;N;;;;;\n1D3E;MODIFIER LETTER CAPITAL P;Lm;0;L;<super> 0050;;;;N;;;;;\n1D3F;MODIFIER LETTER CAPITAL R;Lm;0;L;<super> 0052;;;;N;;;;;\n1D40;MODIFIER LETTER CAPITAL T;Lm;0;L;<super> 0054;;;;N;;;;;\n1D41;MODIFIER LETTER CAPITAL U;Lm;0;L;<super> 0055;;;;N;;;;;\n1D42;MODIFIER LETTER CAPITAL W;Lm;0;L;<super> 0057;;;;N;;;;;\n1D43;MODIFIER LETTER SMALL A;Lm;0;L;<super> 0061;;;;N;;;;;\n1D44;MODIFIER LETTER SMALL TURNED A;Lm;0;L;<super> 0250;;;;N;;;;;\n1D45;MODIFIER LETTER SMALL ALPHA;Lm;0;L;<super> 0251;;;;N;;;;;\n1D46;MODIFIER LETTER SMALL TURNED AE;Lm;0;L;<super> 1D02;;;;N;;;;;\n1D47;MODIFIER LETTER SMALL B;Lm;0;L;<super> 0062;;;;N;;;;;\n1D48;MODIFIER LETTER SMALL D;Lm;0;L;<super> 0064;;;;N;;;;;\n1D49;MODIFIER LETTER SMALL E;Lm;0;L;<super> 0065;;;;N;;;;;\n1D4A;MODIFIER LETTER SMALL SCHWA;Lm;0;L;<super> 0259;;;;N;;;;;\n1D4B;MODIFIER LETTER SMALL OPEN E;Lm;0;L;<super> 025B;;;;N;;;;;\n1D4C;MODIFIER LETTER SMALL TURNED OPEN E;Lm;0;L;<super> 025C;;;;N;;;;;\n1D4D;MODIFIER LETTER SMALL G;Lm;0;L;<super> 0067;;;;N;;;;;\n1D4E;MODIFIER LETTER SMALL TURNED I;Lm;0;L;;;;;N;;;;;\n1D4F;MODIFIER LETTER SMALL K;Lm;0;L;<super> 006B;;;;N;;;;;\n1D50;MODIFIER LETTER SMALL M;Lm;0;L;<super> 006D;;;;N;;;;;\n1D51;MODIFIER LETTER SMALL ENG;Lm;0;L;<super> 014B;;;;N;;;;;\n1D52;MODIFIER LETTER SMALL O;Lm;0;L;<super> 006F;;;;N;;;;;\n1D53;MODIFIER LETTER SMALL OPEN O;Lm;0;L;<super> 0254;;;;N;;;;;\n1D54;MODIFIER LETTER SMALL TOP HALF O;Lm;0;L;<super> 1D16;;;;N;;;;;\n1D55;MODIFIER LETTER SMALL BOTTOM HALF O;Lm;0;L;<super> 1D17;;;;N;;;;;\n1D56;MODIFIER LETTER SMALL P;Lm;0;L;<super> 0070;;;;N;;;;;\n1D57;MODIFIER LETTER SMALL T;Lm;0;L;<super> 0074;;;;N;;;;;\n1D58;MODIFIER LETTER SMALL U;Lm;0;L;<super> 0075;;;;N;;;;;\n1D59;MODIFIER LETTER SMALL SIDEWAYS U;Lm;0;L;<super> 1D1D;;;;N;;;;;\n1D5A;MODIFIER LETTER SMALL TURNED M;Lm;0;L;<super> 026F;;;;N;;;;;\n1D5B;MODIFIER LETTER SMALL V;Lm;0;L;<super> 0076;;;;N;;;;;\n1D5C;MODIFIER LETTER SMALL AIN;Lm;0;L;<super> 1D25;;;;N;;;;;\n1D5D;MODIFIER LETTER SMALL BETA;Lm;0;L;<super> 03B2;;;;N;;;;;\n1D5E;MODIFIER LETTER SMALL GREEK GAMMA;Lm;0;L;<super> 03B3;;;;N;;;;;\n1D5F;MODIFIER LETTER SMALL DELTA;Lm;0;L;<super> 03B4;;;;N;;;;;\n1D60;MODIFIER LETTER SMALL GREEK PHI;Lm;0;L;<super> 03C6;;;;N;;;;;\n1D61;MODIFIER LETTER SMALL CHI;Lm;0;L;<super> 03C7;;;;N;;;;;\n1D62;LATIN SUBSCRIPT SMALL LETTER I;Lm;0;L;<sub> 0069;;;;N;;;;;\n1D63;LATIN SUBSCRIPT SMALL LETTER R;Lm;0;L;<sub> 0072;;;;N;;;;;\n1D64;LATIN SUBSCRIPT SMALL LETTER U;Lm;0;L;<sub> 0075;;;;N;;;;;\n1D65;LATIN SUBSCRIPT SMALL LETTER V;Lm;0;L;<sub> 0076;;;;N;;;;;\n1D66;GREEK SUBSCRIPT SMALL LETTER BETA;Lm;0;L;<sub> 03B2;;;;N;;;;;\n1D67;GREEK SUBSCRIPT SMALL LETTER GAMMA;Lm;0;L;<sub> 03B3;;;;N;;;;;\n1D68;GREEK SUBSCRIPT SMALL LETTER RHO;Lm;0;L;<sub> 03C1;;;;N;;;;;\n1D69;GREEK SUBSCRIPT SMALL LETTER PHI;Lm;0;L;<sub> 03C6;;;;N;;;;;\n1D6A;GREEK SUBSCRIPT SMALL LETTER CHI;Lm;0;L;<sub> 03C7;;;;N;;;;;\n1D6B;LATIN SMALL LETTER UE;Ll;0;L;;;;;N;;;;;\n1D6C;LATIN SMALL LETTER B WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D6D;LATIN SMALL LETTER D WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D6E;LATIN SMALL LETTER F WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D6F;LATIN SMALL LETTER M WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D70;LATIN SMALL LETTER N WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D71;LATIN SMALL LETTER P WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D72;LATIN SMALL LETTER R WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D73;LATIN SMALL LETTER R WITH FISHHOOK AND MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D74;LATIN SMALL LETTER S WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D75;LATIN SMALL LETTER T WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D76;LATIN SMALL LETTER Z WITH MIDDLE TILDE;Ll;0;L;;;;;N;;;;;\n1D77;LATIN SMALL LETTER TURNED G;Ll;0;L;;;;;N;;;;;\n1D78;MODIFIER LETTER CYRILLIC EN;Lm;0;L;<super> 043D;;;;N;;;;;\n1D79;LATIN SMALL LETTER INSULAR G;Ll;0;L;;;;;N;;;A77D;;A77D\n1D7A;LATIN SMALL LETTER TH WITH STRIKETHROUGH;Ll;0;L;;;;;N;;;;;\n1D7B;LATIN SMALL CAPITAL LETTER I WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D7C;LATIN SMALL LETTER IOTA WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D7D;LATIN SMALL LETTER P WITH STROKE;Ll;0;L;;;;;N;;;2C63;;2C63\n1D7E;LATIN SMALL CAPITAL LETTER U WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D7F;LATIN SMALL LETTER UPSILON WITH STROKE;Ll;0;L;;;;;N;;;;;\n1D80;LATIN SMALL LETTER B WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D81;LATIN SMALL LETTER D WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D82;LATIN SMALL LETTER F WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D83;LATIN SMALL LETTER G WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D84;LATIN SMALL LETTER K WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D85;LATIN SMALL LETTER L WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D86;LATIN SMALL LETTER M WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D87;LATIN SMALL LETTER N WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D88;LATIN SMALL LETTER P WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D89;LATIN SMALL LETTER R WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8A;LATIN SMALL LETTER S WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8B;LATIN SMALL LETTER ESH WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8C;LATIN SMALL LETTER V WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8D;LATIN SMALL LETTER X WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8E;LATIN SMALL LETTER Z WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;\n1D8F;LATIN SMALL LETTER A WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D90;LATIN SMALL LETTER ALPHA WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D91;LATIN SMALL LETTER D WITH HOOK AND TAIL;Ll;0;L;;;;;N;;;;;\n1D92;LATIN SMALL LETTER E WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D93;LATIN SMALL LETTER OPEN E WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D94;LATIN SMALL LETTER REVERSED OPEN E WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D95;LATIN SMALL LETTER SCHWA WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D96;LATIN SMALL LETTER I WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D97;LATIN SMALL LETTER OPEN O WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D98;LATIN SMALL LETTER ESH WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D99;LATIN SMALL LETTER U WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D9A;LATIN SMALL LETTER EZH WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;\n1D9B;MODIFIER LETTER SMALL TURNED ALPHA;Lm;0;L;<super> 0252;;;;N;;;;;\n1D9C;MODIFIER LETTER SMALL C;Lm;0;L;<super> 0063;;;;N;;;;;\n1D9D;MODIFIER LETTER SMALL C WITH CURL;Lm;0;L;<super> 0255;;;;N;;;;;\n1D9E;MODIFIER LETTER SMALL ETH;Lm;0;L;<super> 00F0;;;;N;;;;;\n1D9F;MODIFIER LETTER SMALL REVERSED OPEN E;Lm;0;L;<super> 025C;;;;N;;;;;\n1DA0;MODIFIER LETTER SMALL F;Lm;0;L;<super> 0066;;;;N;;;;;\n1DA1;MODIFIER LETTER SMALL DOTLESS J WITH STROKE;Lm;0;L;<super> 025F;;;;N;;;;;\n1DA2;MODIFIER LETTER SMALL SCRIPT G;Lm;0;L;<super> 0261;;;;N;;;;;\n1DA3;MODIFIER LETTER SMALL TURNED H;Lm;0;L;<super> 0265;;;;N;;;;;\n1DA4;MODIFIER LETTER SMALL I WITH STROKE;Lm;0;L;<super> 0268;;;;N;;;;;\n1DA5;MODIFIER LETTER SMALL IOTA;Lm;0;L;<super> 0269;;;;N;;;;;\n1DA6;MODIFIER LETTER SMALL CAPITAL I;Lm;0;L;<super> 026A;;;;N;;;;;\n1DA7;MODIFIER LETTER SMALL CAPITAL I WITH STROKE;Lm;0;L;<super> 1D7B;;;;N;;;;;\n1DA8;MODIFIER LETTER SMALL J WITH CROSSED-TAIL;Lm;0;L;<super> 029D;;;;N;;;;;\n1DA9;MODIFIER LETTER SMALL L WITH RETROFLEX HOOK;Lm;0;L;<super> 026D;;;;N;;;;;\n1DAA;MODIFIER LETTER SMALL L WITH PALATAL HOOK;Lm;0;L;<super> 1D85;;;;N;;;;;\n1DAB;MODIFIER LETTER SMALL CAPITAL L;Lm;0;L;<super> 029F;;;;N;;;;;\n1DAC;MODIFIER LETTER SMALL M WITH HOOK;Lm;0;L;<super> 0271;;;;N;;;;;\n1DAD;MODIFIER LETTER SMALL TURNED M WITH LONG LEG;Lm;0;L;<super> 0270;;;;N;;;;;\n1DAE;MODIFIER LETTER SMALL N WITH LEFT HOOK;Lm;0;L;<super> 0272;;;;N;;;;;\n1DAF;MODIFIER LETTER SMALL N WITH RETROFLEX HOOK;Lm;0;L;<super> 0273;;;;N;;;;;\n1DB0;MODIFIER LETTER SMALL CAPITAL N;Lm;0;L;<super> 0274;;;;N;;;;;\n1DB1;MODIFIER LETTER SMALL BARRED O;Lm;0;L;<super> 0275;;;;N;;;;;\n1DB2;MODIFIER LETTER SMALL PHI;Lm;0;L;<super> 0278;;;;N;;;;;\n1DB3;MODIFIER LETTER SMALL S WITH HOOK;Lm;0;L;<super> 0282;;;;N;;;;;\n1DB4;MODIFIER LETTER SMALL ESH;Lm;0;L;<super> 0283;;;;N;;;;;\n1DB5;MODIFIER LETTER SMALL T WITH PALATAL HOOK;Lm;0;L;<super> 01AB;;;;N;;;;;\n1DB6;MODIFIER LETTER SMALL U BAR;Lm;0;L;<super> 0289;;;;N;;;;;\n1DB7;MODIFIER LETTER SMALL UPSILON;Lm;0;L;<super> 028A;;;;N;;;;;\n1DB8;MODIFIER LETTER SMALL CAPITAL U;Lm;0;L;<super> 1D1C;;;;N;;;;;\n1DB9;MODIFIER LETTER SMALL V WITH HOOK;Lm;0;L;<super> 028B;;;;N;;;;;\n1DBA;MODIFIER LETTER SMALL TURNED V;Lm;0;L;<super> 028C;;;;N;;;;;\n1DBB;MODIFIER LETTER SMALL Z;Lm;0;L;<super> 007A;;;;N;;;;;\n1DBC;MODIFIER LETTER SMALL Z WITH RETROFLEX HOOK;Lm;0;L;<super> 0290;;;;N;;;;;\n1DBD;MODIFIER LETTER SMALL Z WITH CURL;Lm;0;L;<super> 0291;;;;N;;;;;\n1DBE;MODIFIER LETTER SMALL EZH;Lm;0;L;<super> 0292;;;;N;;;;;\n1DBF;MODIFIER LETTER SMALL THETA;Lm;0;L;<super> 03B8;;;;N;;;;;\n1DC0;COMBINING DOTTED GRAVE ACCENT;Mn;230;NSM;;;;;N;;;;;\n1DC1;COMBINING DOTTED ACUTE ACCENT;Mn;230;NSM;;;;;N;;;;;\n1DC2;COMBINING SNAKE BELOW;Mn;220;NSM;;;;;N;;;;;\n1DC3;COMBINING SUSPENSION MARK;Mn;230;NSM;;;;;N;;;;;\n1DC4;COMBINING MACRON-ACUTE;Mn;230;NSM;;;;;N;;;;;\n1DC5;COMBINING GRAVE-MACRON;Mn;230;NSM;;;;;N;;;;;\n1DC6;COMBINING MACRON-GRAVE;Mn;230;NSM;;;;;N;;;;;\n1DC7;COMBINING ACUTE-MACRON;Mn;230;NSM;;;;;N;;;;;\n1DC8;COMBINING GRAVE-ACUTE-GRAVE;Mn;230;NSM;;;;;N;;;;;\n1DC9;COMBINING ACUTE-GRAVE-ACUTE;Mn;230;NSM;;;;;N;;;;;\n1DCA;COMBINING LATIN SMALL LETTER R BELOW;Mn;220;NSM;;;;;N;;;;;\n1DCB;COMBINING BREVE-MACRON;Mn;230;NSM;;;;;N;;;;;\n1DCC;COMBINING MACRON-BREVE;Mn;230;NSM;;;;;N;;;;;\n1DCD;COMBINING DOUBLE CIRCUMFLEX ABOVE;Mn;234;NSM;;;;;N;;;;;\n1DCE;COMBINING OGONEK ABOVE;Mn;214;NSM;;;;;N;;;;;\n1DCF;COMBINING ZIGZAG BELOW;Mn;220;NSM;;;;;N;;;;;\n1DD0;COMBINING IS BELOW;Mn;202;NSM;;;;;N;;;;;\n1DD1;COMBINING UR ABOVE;Mn;230;NSM;;;;;N;;;;;\n1DD2;COMBINING US ABOVE;Mn;230;NSM;;;;;N;;;;;\n1DD3;COMBINING LATIN SMALL LETTER FLATTENED OPEN A ABOVE;Mn;230;NSM;;;;;N;;;;;\n1DD4;COMBINING LATIN SMALL LETTER AE;Mn;230;NSM;;;;;N;;;;;\n1DD5;COMBINING LATIN SMALL LETTER AO;Mn;230;NSM;;;;;N;;;;;\n1DD6;COMBINING LATIN SMALL LETTER AV;Mn;230;NSM;;;;;N;;;;;\n1DD7;COMBINING LATIN SMALL LETTER C CEDILLA;Mn;230;NSM;;;;;N;;;;;\n1DD8;COMBINING LATIN SMALL LETTER INSULAR D;Mn;230;NSM;;;;;N;;;;;\n1DD9;COMBINING LATIN SMALL LETTER ETH;Mn;230;NSM;;;;;N;;;;;\n1DDA;COMBINING LATIN SMALL LETTER G;Mn;230;NSM;;;;;N;;;;;\n1DDB;COMBINING LATIN LETTER SMALL CAPITAL G;Mn;230;NSM;;;;;N;;;;;\n1DDC;COMBINING LATIN SMALL LETTER K;Mn;230;NSM;;;;;N;;;;;\n1DDD;COMBINING LATIN SMALL LETTER L;Mn;230;NSM;;;;;N;;;;;\n1DDE;COMBINING LATIN LETTER SMALL CAPITAL L;Mn;230;NSM;;;;;N;;;;;\n1DDF;COMBINING LATIN LETTER SMALL CAPITAL M;Mn;230;NSM;;;;;N;;;;;\n1DE0;COMBINING LATIN SMALL LETTER N;Mn;230;NSM;;;;;N;;;;;\n1DE1;COMBINING LATIN LETTER SMALL CAPITAL N;Mn;230;NSM;;;;;N;;;;;\n1DE2;COMBINING LATIN LETTER SMALL CAPITAL R;Mn;230;NSM;;;;;N;;;;;\n1DE3;COMBINING LATIN SMALL LETTER R ROTUNDA;Mn;230;NSM;;;;;N;;;;;\n1DE4;COMBINING LATIN SMALL LETTER S;Mn;230;NSM;;;;;N;;;;;\n1DE5;COMBINING LATIN SMALL LETTER LONG S;Mn;230;NSM;;;;;N;;;;;\n1DE6;COMBINING LATIN SMALL LETTER Z;Mn;230;NSM;;;;;N;;;;;\n1DFC;COMBINING DOUBLE INVERTED BREVE BELOW;Mn;233;NSM;;;;;N;;;;;\n1DFD;COMBINING ALMOST EQUAL TO BELOW;Mn;220;NSM;;;;;N;;;;;\n1DFE;COMBINING LEFT ARROWHEAD ABOVE;Mn;230;NSM;;;;;N;;;;;\n1DFF;COMBINING RIGHT ARROWHEAD AND DOWN ARROWHEAD BELOW;Mn;220;NSM;;;;;N;;;;;\n1E00;LATIN CAPITAL LETTER A WITH RING BELOW;Lu;0;L;0041 0325;;;;N;;;;1E01;\n1E01;LATIN SMALL LETTER A WITH RING BELOW;Ll;0;L;0061 0325;;;;N;;;1E00;;1E00\n1E02;LATIN CAPITAL LETTER B WITH DOT ABOVE;Lu;0;L;0042 0307;;;;N;;;;1E03;\n1E03;LATIN SMALL LETTER B WITH DOT ABOVE;Ll;0;L;0062 0307;;;;N;;;1E02;;1E02\n1E04;LATIN CAPITAL LETTER B WITH DOT BELOW;Lu;0;L;0042 0323;;;;N;;;;1E05;\n1E05;LATIN SMALL LETTER B WITH DOT BELOW;Ll;0;L;0062 0323;;;;N;;;1E04;;1E04\n1E06;LATIN CAPITAL LETTER B WITH LINE BELOW;Lu;0;L;0042 0331;;;;N;;;;1E07;\n1E07;LATIN SMALL LETTER B WITH LINE BELOW;Ll;0;L;0062 0331;;;;N;;;1E06;;1E06\n1E08;LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE;Lu;0;L;00C7 0301;;;;N;;;;1E09;\n1E09;LATIN SMALL LETTER C WITH CEDILLA AND ACUTE;Ll;0;L;00E7 0301;;;;N;;;1E08;;1E08\n1E0A;LATIN CAPITAL LETTER D WITH DOT ABOVE;Lu;0;L;0044 0307;;;;N;;;;1E0B;\n1E0B;LATIN SMALL LETTER D WITH DOT ABOVE;Ll;0;L;0064 0307;;;;N;;;1E0A;;1E0A\n1E0C;LATIN CAPITAL LETTER D WITH DOT BELOW;Lu;0;L;0044 0323;;;;N;;;;1E0D;\n1E0D;LATIN SMALL LETTER D WITH DOT BELOW;Ll;0;L;0064 0323;;;;N;;;1E0C;;1E0C\n1E0E;LATIN CAPITAL LETTER D WITH LINE BELOW;Lu;0;L;0044 0331;;;;N;;;;1E0F;\n1E0F;LATIN SMALL LETTER D WITH LINE BELOW;Ll;0;L;0064 0331;;;;N;;;1E0E;;1E0E\n1E10;LATIN CAPITAL LETTER D WITH CEDILLA;Lu;0;L;0044 0327;;;;N;;;;1E11;\n1E11;LATIN SMALL LETTER D WITH CEDILLA;Ll;0;L;0064 0327;;;;N;;;1E10;;1E10\n1E12;LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW;Lu;0;L;0044 032D;;;;N;;;;1E13;\n1E13;LATIN SMALL LETTER D WITH CIRCUMFLEX BELOW;Ll;0;L;0064 032D;;;;N;;;1E12;;1E12\n1E14;LATIN CAPITAL LETTER E WITH MACRON AND GRAVE;Lu;0;L;0112 0300;;;;N;;;;1E15;\n1E15;LATIN SMALL LETTER E WITH MACRON AND GRAVE;Ll;0;L;0113 0300;;;;N;;;1E14;;1E14\n1E16;LATIN CAPITAL LETTER E WITH MACRON AND ACUTE;Lu;0;L;0112 0301;;;;N;;;;1E17;\n1E17;LATIN SMALL LETTER E WITH MACRON AND ACUTE;Ll;0;L;0113 0301;;;;N;;;1E16;;1E16\n1E18;LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW;Lu;0;L;0045 032D;;;;N;;;;1E19;\n1E19;LATIN SMALL LETTER E WITH CIRCUMFLEX BELOW;Ll;0;L;0065 032D;;;;N;;;1E18;;1E18\n1E1A;LATIN CAPITAL LETTER E WITH TILDE BELOW;Lu;0;L;0045 0330;;;;N;;;;1E1B;\n1E1B;LATIN SMALL LETTER E WITH TILDE BELOW;Ll;0;L;0065 0330;;;;N;;;1E1A;;1E1A\n1E1C;LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE;Lu;0;L;0228 0306;;;;N;;;;1E1D;\n1E1D;LATIN SMALL LETTER E WITH CEDILLA AND BREVE;Ll;0;L;0229 0306;;;;N;;;1E1C;;1E1C\n1E1E;LATIN CAPITAL LETTER F WITH DOT ABOVE;Lu;0;L;0046 0307;;;;N;;;;1E1F;\n1E1F;LATIN SMALL LETTER F WITH DOT ABOVE;Ll;0;L;0066 0307;;;;N;;;1E1E;;1E1E\n1E20;LATIN CAPITAL LETTER G WITH MACRON;Lu;0;L;0047 0304;;;;N;;;;1E21;\n1E21;LATIN SMALL LETTER G WITH MACRON;Ll;0;L;0067 0304;;;;N;;;1E20;;1E20\n1E22;LATIN CAPITAL LETTER H WITH DOT ABOVE;Lu;0;L;0048 0307;;;;N;;;;1E23;\n1E23;LATIN SMALL LETTER H WITH DOT ABOVE;Ll;0;L;0068 0307;;;;N;;;1E22;;1E22\n1E24;LATIN CAPITAL LETTER H WITH DOT BELOW;Lu;0;L;0048 0323;;;;N;;;;1E25;\n1E25;LATIN SMALL LETTER H WITH DOT BELOW;Ll;0;L;0068 0323;;;;N;;;1E24;;1E24\n1E26;LATIN CAPITAL LETTER H WITH DIAERESIS;Lu;0;L;0048 0308;;;;N;;;;1E27;\n1E27;LATIN SMALL LETTER H WITH DIAERESIS;Ll;0;L;0068 0308;;;;N;;;1E26;;1E26\n1E28;LATIN CAPITAL LETTER H WITH CEDILLA;Lu;0;L;0048 0327;;;;N;;;;1E29;\n1E29;LATIN SMALL LETTER H WITH CEDILLA;Ll;0;L;0068 0327;;;;N;;;1E28;;1E28\n1E2A;LATIN CAPITAL LETTER H WITH BREVE BELOW;Lu;0;L;0048 032E;;;;N;;;;1E2B;\n1E2B;LATIN SMALL LETTER H WITH BREVE BELOW;Ll;0;L;0068 032E;;;;N;;;1E2A;;1E2A\n1E2C;LATIN CAPITAL LETTER I WITH TILDE BELOW;Lu;0;L;0049 0330;;;;N;;;;1E2D;\n1E2D;LATIN SMALL LETTER I WITH TILDE BELOW;Ll;0;L;0069 0330;;;;N;;;1E2C;;1E2C\n1E2E;LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE;Lu;0;L;00CF 0301;;;;N;;;;1E2F;\n1E2F;LATIN SMALL LETTER I WITH DIAERESIS AND ACUTE;Ll;0;L;00EF 0301;;;;N;;;1E2E;;1E2E\n1E30;LATIN CAPITAL LETTER K WITH ACUTE;Lu;0;L;004B 0301;;;;N;;;;1E31;\n1E31;LATIN SMALL LETTER K WITH ACUTE;Ll;0;L;006B 0301;;;;N;;;1E30;;1E30\n1E32;LATIN CAPITAL LETTER K WITH DOT BELOW;Lu;0;L;004B 0323;;;;N;;;;1E33;\n1E33;LATIN SMALL LETTER K WITH DOT BELOW;Ll;0;L;006B 0323;;;;N;;;1E32;;1E32\n1E34;LATIN CAPITAL LETTER K WITH LINE BELOW;Lu;0;L;004B 0331;;;;N;;;;1E35;\n1E35;LATIN SMALL LETTER K WITH LINE BELOW;Ll;0;L;006B 0331;;;;N;;;1E34;;1E34\n1E36;LATIN CAPITAL LETTER L WITH DOT BELOW;Lu;0;L;004C 0323;;;;N;;;;1E37;\n1E37;LATIN SMALL LETTER L WITH DOT BELOW;Ll;0;L;006C 0323;;;;N;;;1E36;;1E36\n1E38;LATIN CAPITAL LETTER L WITH DOT BELOW AND MACRON;Lu;0;L;1E36 0304;;;;N;;;;1E39;\n1E39;LATIN SMALL LETTER L WITH DOT BELOW AND MACRON;Ll;0;L;1E37 0304;;;;N;;;1E38;;1E38\n1E3A;LATIN CAPITAL LETTER L WITH LINE BELOW;Lu;0;L;004C 0331;;;;N;;;;1E3B;\n1E3B;LATIN SMALL LETTER L WITH LINE BELOW;Ll;0;L;006C 0331;;;;N;;;1E3A;;1E3A\n1E3C;LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW;Lu;0;L;004C 032D;;;;N;;;;1E3D;\n1E3D;LATIN SMALL LETTER L WITH CIRCUMFLEX BELOW;Ll;0;L;006C 032D;;;;N;;;1E3C;;1E3C\n1E3E;LATIN CAPITAL LETTER M WITH ACUTE;Lu;0;L;004D 0301;;;;N;;;;1E3F;\n1E3F;LATIN SMALL LETTER M WITH ACUTE;Ll;0;L;006D 0301;;;;N;;;1E3E;;1E3E\n1E40;LATIN CAPITAL LETTER M WITH DOT ABOVE;Lu;0;L;004D 0307;;;;N;;;;1E41;\n1E41;LATIN SMALL LETTER M WITH DOT ABOVE;Ll;0;L;006D 0307;;;;N;;;1E40;;1E40\n1E42;LATIN CAPITAL LETTER M WITH DOT BELOW;Lu;0;L;004D 0323;;;;N;;;;1E43;\n1E43;LATIN SMALL LETTER M WITH DOT BELOW;Ll;0;L;006D 0323;;;;N;;;1E42;;1E42\n1E44;LATIN CAPITAL LETTER N WITH DOT ABOVE;Lu;0;L;004E 0307;;;;N;;;;1E45;\n1E45;LATIN SMALL LETTER N WITH DOT ABOVE;Ll;0;L;006E 0307;;;;N;;;1E44;;1E44\n1E46;LATIN CAPITAL LETTER N WITH DOT BELOW;Lu;0;L;004E 0323;;;;N;;;;1E47;\n1E47;LATIN SMALL LETTER N WITH DOT BELOW;Ll;0;L;006E 0323;;;;N;;;1E46;;1E46\n1E48;LATIN CAPITAL LETTER N WITH LINE BELOW;Lu;0;L;004E 0331;;;;N;;;;1E49;\n1E49;LATIN SMALL LETTER N WITH LINE BELOW;Ll;0;L;006E 0331;;;;N;;;1E48;;1E48\n1E4A;LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW;Lu;0;L;004E 032D;;;;N;;;;1E4B;\n1E4B;LATIN SMALL LETTER N WITH CIRCUMFLEX BELOW;Ll;0;L;006E 032D;;;;N;;;1E4A;;1E4A\n1E4C;LATIN CAPITAL LETTER O WITH TILDE AND ACUTE;Lu;0;L;00D5 0301;;;;N;;;;1E4D;\n1E4D;LATIN SMALL LETTER O WITH TILDE AND ACUTE;Ll;0;L;00F5 0301;;;;N;;;1E4C;;1E4C\n1E4E;LATIN CAPITAL LETTER O WITH TILDE AND DIAERESIS;Lu;0;L;00D5 0308;;;;N;;;;1E4F;\n1E4F;LATIN SMALL LETTER O WITH TILDE AND DIAERESIS;Ll;0;L;00F5 0308;;;;N;;;1E4E;;1E4E\n1E50;LATIN CAPITAL LETTER O WITH MACRON AND GRAVE;Lu;0;L;014C 0300;;;;N;;;;1E51;\n1E51;LATIN SMALL LETTER O WITH MACRON AND GRAVE;Ll;0;L;014D 0300;;;;N;;;1E50;;1E50\n1E52;LATIN CAPITAL LETTER O WITH MACRON AND ACUTE;Lu;0;L;014C 0301;;;;N;;;;1E53;\n1E53;LATIN SMALL LETTER O WITH MACRON AND ACUTE;Ll;0;L;014D 0301;;;;N;;;1E52;;1E52\n1E54;LATIN CAPITAL LETTER P WITH ACUTE;Lu;0;L;0050 0301;;;;N;;;;1E55;\n1E55;LATIN SMALL LETTER P WITH ACUTE;Ll;0;L;0070 0301;;;;N;;;1E54;;1E54\n1E56;LATIN CAPITAL LETTER P WITH DOT ABOVE;Lu;0;L;0050 0307;;;;N;;;;1E57;\n1E57;LATIN SMALL LETTER P WITH DOT ABOVE;Ll;0;L;0070 0307;;;;N;;;1E56;;1E56\n1E58;LATIN CAPITAL LETTER R WITH DOT ABOVE;Lu;0;L;0052 0307;;;;N;;;;1E59;\n1E59;LATIN SMALL LETTER R WITH DOT ABOVE;Ll;0;L;0072 0307;;;;N;;;1E58;;1E58\n1E5A;LATIN CAPITAL LETTER R WITH DOT BELOW;Lu;0;L;0052 0323;;;;N;;;;1E5B;\n1E5B;LATIN SMALL LETTER R WITH DOT BELOW;Ll;0;L;0072 0323;;;;N;;;1E5A;;1E5A\n1E5C;LATIN CAPITAL LETTER R WITH DOT BELOW AND MACRON;Lu;0;L;1E5A 0304;;;;N;;;;1E5D;\n1E5D;LATIN SMALL LETTER R WITH DOT BELOW AND MACRON;Ll;0;L;1E5B 0304;;;;N;;;1E5C;;1E5C\n1E5E;LATIN CAPITAL LETTER R WITH LINE BELOW;Lu;0;L;0052 0331;;;;N;;;;1E5F;\n1E5F;LATIN SMALL LETTER R WITH LINE BELOW;Ll;0;L;0072 0331;;;;N;;;1E5E;;1E5E\n1E60;LATIN CAPITAL LETTER S WITH DOT ABOVE;Lu;0;L;0053 0307;;;;N;;;;1E61;\n1E61;LATIN SMALL LETTER S WITH DOT ABOVE;Ll;0;L;0073 0307;;;;N;;;1E60;;1E60\n1E62;LATIN CAPITAL LETTER S WITH DOT BELOW;Lu;0;L;0053 0323;;;;N;;;;1E63;\n1E63;LATIN SMALL LETTER S WITH DOT BELOW;Ll;0;L;0073 0323;;;;N;;;1E62;;1E62\n1E64;LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE;Lu;0;L;015A 0307;;;;N;;;;1E65;\n1E65;LATIN SMALL LETTER S WITH ACUTE AND DOT ABOVE;Ll;0;L;015B 0307;;;;N;;;1E64;;1E64\n1E66;LATIN CAPITAL LETTER S WITH CARON AND DOT ABOVE;Lu;0;L;0160 0307;;;;N;;;;1E67;\n1E67;LATIN SMALL LETTER S WITH CARON AND DOT ABOVE;Ll;0;L;0161 0307;;;;N;;;1E66;;1E66\n1E68;LATIN CAPITAL LETTER S WITH DOT BELOW AND DOT ABOVE;Lu;0;L;1E62 0307;;;;N;;;;1E69;\n1E69;LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE;Ll;0;L;1E63 0307;;;;N;;;1E68;;1E68\n1E6A;LATIN CAPITAL LETTER T WITH DOT ABOVE;Lu;0;L;0054 0307;;;;N;;;;1E6B;\n1E6B;LATIN SMALL LETTER T WITH DOT ABOVE;Ll;0;L;0074 0307;;;;N;;;1E6A;;1E6A\n1E6C;LATIN CAPITAL LETTER T WITH DOT BELOW;Lu;0;L;0054 0323;;;;N;;;;1E6D;\n1E6D;LATIN SMALL LETTER T WITH DOT BELOW;Ll;0;L;0074 0323;;;;N;;;1E6C;;1E6C\n1E6E;LATIN CAPITAL LETTER T WITH LINE BELOW;Lu;0;L;0054 0331;;;;N;;;;1E6F;\n1E6F;LATIN SMALL LETTER T WITH LINE BELOW;Ll;0;L;0074 0331;;;;N;;;1E6E;;1E6E\n1E70;LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW;Lu;0;L;0054 032D;;;;N;;;;1E71;\n1E71;LATIN SMALL LETTER T WITH CIRCUMFLEX BELOW;Ll;0;L;0074 032D;;;;N;;;1E70;;1E70\n1E72;LATIN CAPITAL LETTER U WITH DIAERESIS BELOW;Lu;0;L;0055 0324;;;;N;;;;1E73;\n1E73;LATIN SMALL LETTER U WITH DIAERESIS BELOW;Ll;0;L;0075 0324;;;;N;;;1E72;;1E72\n1E74;LATIN CAPITAL LETTER U WITH TILDE BELOW;Lu;0;L;0055 0330;;;;N;;;;1E75;\n1E75;LATIN SMALL LETTER U WITH TILDE BELOW;Ll;0;L;0075 0330;;;;N;;;1E74;;1E74\n1E76;LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW;Lu;0;L;0055 032D;;;;N;;;;1E77;\n1E77;LATIN SMALL LETTER U WITH CIRCUMFLEX BELOW;Ll;0;L;0075 032D;;;;N;;;1E76;;1E76\n1E78;LATIN CAPITAL LETTER U WITH TILDE AND ACUTE;Lu;0;L;0168 0301;;;;N;;;;1E79;\n1E79;LATIN SMALL LETTER U WITH TILDE AND ACUTE;Ll;0;L;0169 0301;;;;N;;;1E78;;1E78\n1E7A;LATIN CAPITAL LETTER U WITH MACRON AND DIAERESIS;Lu;0;L;016A 0308;;;;N;;;;1E7B;\n1E7B;LATIN SMALL LETTER U WITH MACRON AND DIAERESIS;Ll;0;L;016B 0308;;;;N;;;1E7A;;1E7A\n1E7C;LATIN CAPITAL LETTER V WITH TILDE;Lu;0;L;0056 0303;;;;N;;;;1E7D;\n1E7D;LATIN SMALL LETTER V WITH TILDE;Ll;0;L;0076 0303;;;;N;;;1E7C;;1E7C\n1E7E;LATIN CAPITAL LETTER V WITH DOT BELOW;Lu;0;L;0056 0323;;;;N;;;;1E7F;\n1E7F;LATIN SMALL LETTER V WITH DOT BELOW;Ll;0;L;0076 0323;;;;N;;;1E7E;;1E7E\n1E80;LATIN CAPITAL LETTER W WITH GRAVE;Lu;0;L;0057 0300;;;;N;;;;1E81;\n1E81;LATIN SMALL LETTER W WITH GRAVE;Ll;0;L;0077 0300;;;;N;;;1E80;;1E80\n1E82;LATIN CAPITAL LETTER W WITH ACUTE;Lu;0;L;0057 0301;;;;N;;;;1E83;\n1E83;LATIN SMALL LETTER W WITH ACUTE;Ll;0;L;0077 0301;;;;N;;;1E82;;1E82\n1E84;LATIN CAPITAL LETTER W WITH DIAERESIS;Lu;0;L;0057 0308;;;;N;;;;1E85;\n1E85;LATIN SMALL LETTER W WITH DIAERESIS;Ll;0;L;0077 0308;;;;N;;;1E84;;1E84\n1E86;LATIN CAPITAL LETTER W WITH DOT ABOVE;Lu;0;L;0057 0307;;;;N;;;;1E87;\n1E87;LATIN SMALL LETTER W WITH DOT ABOVE;Ll;0;L;0077 0307;;;;N;;;1E86;;1E86\n1E88;LATIN CAPITAL LETTER W WITH DOT BELOW;Lu;0;L;0057 0323;;;;N;;;;1E89;\n1E89;LATIN SMALL LETTER W WITH DOT BELOW;Ll;0;L;0077 0323;;;;N;;;1E88;;1E88\n1E8A;LATIN CAPITAL LETTER X WITH DOT ABOVE;Lu;0;L;0058 0307;;;;N;;;;1E8B;\n1E8B;LATIN SMALL LETTER X WITH DOT ABOVE;Ll;0;L;0078 0307;;;;N;;;1E8A;;1E8A\n1E8C;LATIN CAPITAL LETTER X WITH DIAERESIS;Lu;0;L;0058 0308;;;;N;;;;1E8D;\n1E8D;LATIN SMALL LETTER X WITH DIAERESIS;Ll;0;L;0078 0308;;;;N;;;1E8C;;1E8C\n1E8E;LATIN CAPITAL LETTER Y WITH DOT ABOVE;Lu;0;L;0059 0307;;;;N;;;;1E8F;\n1E8F;LATIN SMALL LETTER Y WITH DOT ABOVE;Ll;0;L;0079 0307;;;;N;;;1E8E;;1E8E\n1E90;LATIN CAPITAL LETTER Z WITH CIRCUMFLEX;Lu;0;L;005A 0302;;;;N;;;;1E91;\n1E91;LATIN SMALL LETTER Z WITH CIRCUMFLEX;Ll;0;L;007A 0302;;;;N;;;1E90;;1E90\n1E92;LATIN CAPITAL LETTER Z WITH DOT BELOW;Lu;0;L;005A 0323;;;;N;;;;1E93;\n1E93;LATIN SMALL LETTER Z WITH DOT BELOW;Ll;0;L;007A 0323;;;;N;;;1E92;;1E92\n1E94;LATIN CAPITAL LETTER Z WITH LINE BELOW;Lu;0;L;005A 0331;;;;N;;;;1E95;\n1E95;LATIN SMALL LETTER Z WITH LINE BELOW;Ll;0;L;007A 0331;;;;N;;;1E94;;1E94\n1E96;LATIN SMALL LETTER H WITH LINE BELOW;Ll;0;L;0068 0331;;;;N;;;;;\n1E97;LATIN SMALL LETTER T WITH DIAERESIS;Ll;0;L;0074 0308;;;;N;;;;;\n1E98;LATIN SMALL LETTER W WITH RING ABOVE;Ll;0;L;0077 030A;;;;N;;;;;\n1E99;LATIN SMALL LETTER Y WITH RING ABOVE;Ll;0;L;0079 030A;;;;N;;;;;\n1E9A;LATIN SMALL LETTER A WITH RIGHT HALF RING;Ll;0;L;<compat> 0061 02BE;;;;N;;;;;\n1E9B;LATIN SMALL LETTER LONG S WITH DOT ABOVE;Ll;0;L;017F 0307;;;;N;;;1E60;;1E60\n1E9C;LATIN SMALL LETTER LONG S WITH DIAGONAL STROKE;Ll;0;L;;;;;N;;;;;\n1E9D;LATIN SMALL LETTER LONG S WITH HIGH STROKE;Ll;0;L;;;;;N;;;;;\n1E9E;LATIN CAPITAL LETTER SHARP S;Lu;0;L;;;;;N;;;;00DF;\n1E9F;LATIN SMALL LETTER DELTA;Ll;0;L;;;;;N;;;;;\n1EA0;LATIN CAPITAL LETTER A WITH DOT BELOW;Lu;0;L;0041 0323;;;;N;;;;1EA1;\n1EA1;LATIN SMALL LETTER A WITH DOT BELOW;Ll;0;L;0061 0323;;;;N;;;1EA0;;1EA0\n1EA2;LATIN CAPITAL LETTER A WITH HOOK ABOVE;Lu;0;L;0041 0309;;;;N;;;;1EA3;\n1EA3;LATIN SMALL LETTER A WITH HOOK ABOVE;Ll;0;L;0061 0309;;;;N;;;1EA2;;1EA2\n1EA4;LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE;Lu;0;L;00C2 0301;;;;N;;;;1EA5;\n1EA5;LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE;Ll;0;L;00E2 0301;;;;N;;;1EA4;;1EA4\n1EA6;LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE;Lu;0;L;00C2 0300;;;;N;;;;1EA7;\n1EA7;LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE;Ll;0;L;00E2 0300;;;;N;;;1EA6;;1EA6\n1EA8;LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE;Lu;0;L;00C2 0309;;;;N;;;;1EA9;\n1EA9;LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE;Ll;0;L;00E2 0309;;;;N;;;1EA8;;1EA8\n1EAA;LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE;Lu;0;L;00C2 0303;;;;N;;;;1EAB;\n1EAB;LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE;Ll;0;L;00E2 0303;;;;N;;;1EAA;;1EAA\n1EAC;LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW;Lu;0;L;1EA0 0302;;;;N;;;;1EAD;\n1EAD;LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW;Ll;0;L;1EA1 0302;;;;N;;;1EAC;;1EAC\n1EAE;LATIN CAPITAL LETTER A WITH BREVE AND ACUTE;Lu;0;L;0102 0301;;;;N;;;;1EAF;\n1EAF;LATIN SMALL LETTER A WITH BREVE AND ACUTE;Ll;0;L;0103 0301;;;;N;;;1EAE;;1EAE\n1EB0;LATIN CAPITAL LETTER A WITH BREVE AND GRAVE;Lu;0;L;0102 0300;;;;N;;;;1EB1;\n1EB1;LATIN SMALL LETTER A WITH BREVE AND GRAVE;Ll;0;L;0103 0300;;;;N;;;1EB0;;1EB0\n1EB2;LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE;Lu;0;L;0102 0309;;;;N;;;;1EB3;\n1EB3;LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE;Ll;0;L;0103 0309;;;;N;;;1EB2;;1EB2\n1EB4;LATIN CAPITAL LETTER A WITH BREVE AND TILDE;Lu;0;L;0102 0303;;;;N;;;;1EB5;\n1EB5;LATIN SMALL LETTER A WITH BREVE AND TILDE;Ll;0;L;0103 0303;;;;N;;;1EB4;;1EB4\n1EB6;LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW;Lu;0;L;1EA0 0306;;;;N;;;;1EB7;\n1EB7;LATIN SMALL LETTER A WITH BREVE AND DOT BELOW;Ll;0;L;1EA1 0306;;;;N;;;1EB6;;1EB6\n1EB8;LATIN CAPITAL LETTER E WITH DOT BELOW;Lu;0;L;0045 0323;;;;N;;;;1EB9;\n1EB9;LATIN SMALL LETTER E WITH DOT BELOW;Ll;0;L;0065 0323;;;;N;;;1EB8;;1EB8\n1EBA;LATIN CAPITAL LETTER E WITH HOOK ABOVE;Lu;0;L;0045 0309;;;;N;;;;1EBB;\n1EBB;LATIN SMALL LETTER E WITH HOOK ABOVE;Ll;0;L;0065 0309;;;;N;;;1EBA;;1EBA\n1EBC;LATIN CAPITAL LETTER E WITH TILDE;Lu;0;L;0045 0303;;;;N;;;;1EBD;\n1EBD;LATIN SMALL LETTER E WITH TILDE;Ll;0;L;0065 0303;;;;N;;;1EBC;;1EBC\n1EBE;LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE;Lu;0;L;00CA 0301;;;;N;;;;1EBF;\n1EBF;LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE;Ll;0;L;00EA 0301;;;;N;;;1EBE;;1EBE\n1EC0;LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE;Lu;0;L;00CA 0300;;;;N;;;;1EC1;\n1EC1;LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE;Ll;0;L;00EA 0300;;;;N;;;1EC0;;1EC0\n1EC2;LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE;Lu;0;L;00CA 0309;;;;N;;;;1EC3;\n1EC3;LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE;Ll;0;L;00EA 0309;;;;N;;;1EC2;;1EC2\n1EC4;LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE;Lu;0;L;00CA 0303;;;;N;;;;1EC5;\n1EC5;LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE;Ll;0;L;00EA 0303;;;;N;;;1EC4;;1EC4\n1EC6;LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW;Lu;0;L;1EB8 0302;;;;N;;;;1EC7;\n1EC7;LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW;Ll;0;L;1EB9 0302;;;;N;;;1EC6;;1EC6\n1EC8;LATIN CAPITAL LETTER I WITH HOOK ABOVE;Lu;0;L;0049 0309;;;;N;;;;1EC9;\n1EC9;LATIN SMALL LETTER I WITH HOOK ABOVE;Ll;0;L;0069 0309;;;;N;;;1EC8;;1EC8\n1ECA;LATIN CAPITAL LETTER I WITH DOT BELOW;Lu;0;L;0049 0323;;;;N;;;;1ECB;\n1ECB;LATIN SMALL LETTER I WITH DOT BELOW;Ll;0;L;0069 0323;;;;N;;;1ECA;;1ECA\n1ECC;LATIN CAPITAL LETTER O WITH DOT BELOW;Lu;0;L;004F 0323;;;;N;;;;1ECD;\n1ECD;LATIN SMALL LETTER O WITH DOT BELOW;Ll;0;L;006F 0323;;;;N;;;1ECC;;1ECC\n1ECE;LATIN CAPITAL LETTER O WITH HOOK ABOVE;Lu;0;L;004F 0309;;;;N;;;;1ECF;\n1ECF;LATIN SMALL LETTER O WITH HOOK ABOVE;Ll;0;L;006F 0309;;;;N;;;1ECE;;1ECE\n1ED0;LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE;Lu;0;L;00D4 0301;;;;N;;;;1ED1;\n1ED1;LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE;Ll;0;L;00F4 0301;;;;N;;;1ED0;;1ED0\n1ED2;LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE;Lu;0;L;00D4 0300;;;;N;;;;1ED3;\n1ED3;LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE;Ll;0;L;00F4 0300;;;;N;;;1ED2;;1ED2\n1ED4;LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE;Lu;0;L;00D4 0309;;;;N;;;;1ED5;\n1ED5;LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE;Ll;0;L;00F4 0309;;;;N;;;1ED4;;1ED4\n1ED6;LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE;Lu;0;L;00D4 0303;;;;N;;;;1ED7;\n1ED7;LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE;Ll;0;L;00F4 0303;;;;N;;;1ED6;;1ED6\n1ED8;LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW;Lu;0;L;1ECC 0302;;;;N;;;;1ED9;\n1ED9;LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW;Ll;0;L;1ECD 0302;;;;N;;;1ED8;;1ED8\n1EDA;LATIN CAPITAL LETTER O WITH HORN AND ACUTE;Lu;0;L;01A0 0301;;;;N;;;;1EDB;\n1EDB;LATIN SMALL LETTER O WITH HORN AND ACUTE;Ll;0;L;01A1 0301;;;;N;;;1EDA;;1EDA\n1EDC;LATIN CAPITAL LETTER O WITH HORN AND GRAVE;Lu;0;L;01A0 0300;;;;N;;;;1EDD;\n1EDD;LATIN SMALL LETTER O WITH HORN AND GRAVE;Ll;0;L;01A1 0300;;;;N;;;1EDC;;1EDC\n1EDE;LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE;Lu;0;L;01A0 0309;;;;N;;;;1EDF;\n1EDF;LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE;Ll;0;L;01A1 0309;;;;N;;;1EDE;;1EDE\n1EE0;LATIN CAPITAL LETTER O WITH HORN AND TILDE;Lu;0;L;01A0 0303;;;;N;;;;1EE1;\n1EE1;LATIN SMALL LETTER O WITH HORN AND TILDE;Ll;0;L;01A1 0303;;;;N;;;1EE0;;1EE0\n1EE2;LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW;Lu;0;L;01A0 0323;;;;N;;;;1EE3;\n1EE3;LATIN SMALL LETTER O WITH HORN AND DOT BELOW;Ll;0;L;01A1 0323;;;;N;;;1EE2;;1EE2\n1EE4;LATIN CAPITAL LETTER U WITH DOT BELOW;Lu;0;L;0055 0323;;;;N;;;;1EE5;\n1EE5;LATIN SMALL LETTER U WITH DOT BELOW;Ll;0;L;0075 0323;;;;N;;;1EE4;;1EE4\n1EE6;LATIN CAPITAL LETTER U WITH HOOK ABOVE;Lu;0;L;0055 0309;;;;N;;;;1EE7;\n1EE7;LATIN SMALL LETTER U WITH HOOK ABOVE;Ll;0;L;0075 0309;;;;N;;;1EE6;;1EE6\n1EE8;LATIN CAPITAL LETTER U WITH HORN AND ACUTE;Lu;0;L;01AF 0301;;;;N;;;;1EE9;\n1EE9;LATIN SMALL LETTER U WITH HORN AND ACUTE;Ll;0;L;01B0 0301;;;;N;;;1EE8;;1EE8\n1EEA;LATIN CAPITAL LETTER U WITH HORN AND GRAVE;Lu;0;L;01AF 0300;;;;N;;;;1EEB;\n1EEB;LATIN SMALL LETTER U WITH HORN AND GRAVE;Ll;0;L;01B0 0300;;;;N;;;1EEA;;1EEA\n1EEC;LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE;Lu;0;L;01AF 0309;;;;N;;;;1EED;\n1EED;LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE;Ll;0;L;01B0 0309;;;;N;;;1EEC;;1EEC\n1EEE;LATIN CAPITAL LETTER U WITH HORN AND TILDE;Lu;0;L;01AF 0303;;;;N;;;;1EEF;\n1EEF;LATIN SMALL LETTER U WITH HORN AND TILDE;Ll;0;L;01B0 0303;;;;N;;;1EEE;;1EEE\n1EF0;LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW;Lu;0;L;01AF 0323;;;;N;;;;1EF1;\n1EF1;LATIN SMALL LETTER U WITH HORN AND DOT BELOW;Ll;0;L;01B0 0323;;;;N;;;1EF0;;1EF0\n1EF2;LATIN CAPITAL LETTER Y WITH GRAVE;Lu;0;L;0059 0300;;;;N;;;;1EF3;\n1EF3;LATIN SMALL LETTER Y WITH GRAVE;Ll;0;L;0079 0300;;;;N;;;1EF2;;1EF2\n1EF4;LATIN CAPITAL LETTER Y WITH DOT BELOW;Lu;0;L;0059 0323;;;;N;;;;1EF5;\n1EF5;LATIN SMALL LETTER Y WITH DOT BELOW;Ll;0;L;0079 0323;;;;N;;;1EF4;;1EF4\n1EF6;LATIN CAPITAL LETTER Y WITH HOOK ABOVE;Lu;0;L;0059 0309;;;;N;;;;1EF7;\n1EF7;LATIN SMALL LETTER Y WITH HOOK ABOVE;Ll;0;L;0079 0309;;;;N;;;1EF6;;1EF6\n1EF8;LATIN CAPITAL LETTER Y WITH TILDE;Lu;0;L;0059 0303;;;;N;;;;1EF9;\n1EF9;LATIN SMALL LETTER Y WITH TILDE;Ll;0;L;0079 0303;;;;N;;;1EF8;;1EF8\n1EFA;LATIN CAPITAL LETTER MIDDLE-WELSH LL;Lu;0;L;;;;;N;;;;1EFB;\n1EFB;LATIN SMALL LETTER MIDDLE-WELSH LL;Ll;0;L;;;;;N;;;1EFA;;1EFA\n1EFC;LATIN CAPITAL LETTER MIDDLE-WELSH V;Lu;0;L;;;;;N;;;;1EFD;\n1EFD;LATIN SMALL LETTER MIDDLE-WELSH V;Ll;0;L;;;;;N;;;1EFC;;1EFC\n1EFE;LATIN CAPITAL LETTER Y WITH LOOP;Lu;0;L;;;;;N;;;;1EFF;\n1EFF;LATIN SMALL LETTER Y WITH LOOP;Ll;0;L;;;;;N;;;1EFE;;1EFE\n1F00;GREEK SMALL LETTER ALPHA WITH PSILI;Ll;0;L;03B1 0313;;;;N;;;1F08;;1F08\n1F01;GREEK SMALL LETTER ALPHA WITH DASIA;Ll;0;L;03B1 0314;;;;N;;;1F09;;1F09\n1F02;GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA;Ll;0;L;1F00 0300;;;;N;;;1F0A;;1F0A\n1F03;GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA;Ll;0;L;1F01 0300;;;;N;;;1F0B;;1F0B\n1F04;GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA;Ll;0;L;1F00 0301;;;;N;;;1F0C;;1F0C\n1F05;GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA;Ll;0;L;1F01 0301;;;;N;;;1F0D;;1F0D\n1F06;GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI;Ll;0;L;1F00 0342;;;;N;;;1F0E;;1F0E\n1F07;GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI;Ll;0;L;1F01 0342;;;;N;;;1F0F;;1F0F\n1F08;GREEK CAPITAL LETTER ALPHA WITH PSILI;Lu;0;L;0391 0313;;;;N;;;;1F00;\n1F09;GREEK CAPITAL LETTER ALPHA WITH DASIA;Lu;0;L;0391 0314;;;;N;;;;1F01;\n1F0A;GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA;Lu;0;L;1F08 0300;;;;N;;;;1F02;\n1F0B;GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA;Lu;0;L;1F09 0300;;;;N;;;;1F03;\n1F0C;GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA;Lu;0;L;1F08 0301;;;;N;;;;1F04;\n1F0D;GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA;Lu;0;L;1F09 0301;;;;N;;;;1F05;\n1F0E;GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI;Lu;0;L;1F08 0342;;;;N;;;;1F06;\n1F0F;GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI;Lu;0;L;1F09 0342;;;;N;;;;1F07;\n1F10;GREEK SMALL LETTER EPSILON WITH PSILI;Ll;0;L;03B5 0313;;;;N;;;1F18;;1F18\n1F11;GREEK SMALL LETTER EPSILON WITH DASIA;Ll;0;L;03B5 0314;;;;N;;;1F19;;1F19\n1F12;GREEK SMALL LETTER EPSILON WITH PSILI AND VARIA;Ll;0;L;1F10 0300;;;;N;;;1F1A;;1F1A\n1F13;GREEK SMALL LETTER EPSILON WITH DASIA AND VARIA;Ll;0;L;1F11 0300;;;;N;;;1F1B;;1F1B\n1F14;GREEK SMALL LETTER EPSILON WITH PSILI AND OXIA;Ll;0;L;1F10 0301;;;;N;;;1F1C;;1F1C\n1F15;GREEK SMALL LETTER EPSILON WITH DASIA AND OXIA;Ll;0;L;1F11 0301;;;;N;;;1F1D;;1F1D\n1F18;GREEK CAPITAL LETTER EPSILON WITH PSILI;Lu;0;L;0395 0313;;;;N;;;;1F10;\n1F19;GREEK CAPITAL LETTER EPSILON WITH DASIA;Lu;0;L;0395 0314;;;;N;;;;1F11;\n1F1A;GREEK CAPITAL LETTER EPSILON WITH PSILI AND VARIA;Lu;0;L;1F18 0300;;;;N;;;;1F12;\n1F1B;GREEK CAPITAL LETTER EPSILON WITH DASIA AND VARIA;Lu;0;L;1F19 0300;;;;N;;;;1F13;\n1F1C;GREEK CAPITAL LETTER EPSILON WITH PSILI AND OXIA;Lu;0;L;1F18 0301;;;;N;;;;1F14;\n1F1D;GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA;Lu;0;L;1F19 0301;;;;N;;;;1F15;\n1F20;GREEK SMALL LETTER ETA WITH PSILI;Ll;0;L;03B7 0313;;;;N;;;1F28;;1F28\n1F21;GREEK SMALL LETTER ETA WITH DASIA;Ll;0;L;03B7 0314;;;;N;;;1F29;;1F29\n1F22;GREEK SMALL LETTER ETA WITH PSILI AND VARIA;Ll;0;L;1F20 0300;;;;N;;;1F2A;;1F2A\n1F23;GREEK SMALL LETTER ETA WITH DASIA AND VARIA;Ll;0;L;1F21 0300;;;;N;;;1F2B;;1F2B\n1F24;GREEK SMALL LETTER ETA WITH PSILI AND OXIA;Ll;0;L;1F20 0301;;;;N;;;1F2C;;1F2C\n1F25;GREEK SMALL LETTER ETA WITH DASIA AND OXIA;Ll;0;L;1F21 0301;;;;N;;;1F2D;;1F2D\n1F26;GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI;Ll;0;L;1F20 0342;;;;N;;;1F2E;;1F2E\n1F27;GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI;Ll;0;L;1F21 0342;;;;N;;;1F2F;;1F2F\n1F28;GREEK CAPITAL LETTER ETA WITH PSILI;Lu;0;L;0397 0313;;;;N;;;;1F20;\n1F29;GREEK CAPITAL LETTER ETA WITH DASIA;Lu;0;L;0397 0314;;;;N;;;;1F21;\n1F2A;GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA;Lu;0;L;1F28 0300;;;;N;;;;1F22;\n1F2B;GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA;Lu;0;L;1F29 0300;;;;N;;;;1F23;\n1F2C;GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA;Lu;0;L;1F28 0301;;;;N;;;;1F24;\n1F2D;GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA;Lu;0;L;1F29 0301;;;;N;;;;1F25;\n1F2E;GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI;Lu;0;L;1F28 0342;;;;N;;;;1F26;\n1F2F;GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI;Lu;0;L;1F29 0342;;;;N;;;;1F27;\n1F30;GREEK SMALL LETTER IOTA WITH PSILI;Ll;0;L;03B9 0313;;;;N;;;1F38;;1F38\n1F31;GREEK SMALL LETTER IOTA WITH DASIA;Ll;0;L;03B9 0314;;;;N;;;1F39;;1F39\n1F32;GREEK SMALL LETTER IOTA WITH PSILI AND VARIA;Ll;0;L;1F30 0300;;;;N;;;1F3A;;1F3A\n1F33;GREEK SMALL LETTER IOTA WITH DASIA AND VARIA;Ll;0;L;1F31 0300;;;;N;;;1F3B;;1F3B\n1F34;GREEK SMALL LETTER IOTA WITH PSILI AND OXIA;Ll;0;L;1F30 0301;;;;N;;;1F3C;;1F3C\n1F35;GREEK SMALL LETTER IOTA WITH DASIA AND OXIA;Ll;0;L;1F31 0301;;;;N;;;1F3D;;1F3D\n1F36;GREEK SMALL LETTER IOTA WITH PSILI AND PERISPOMENI;Ll;0;L;1F30 0342;;;;N;;;1F3E;;1F3E\n1F37;GREEK SMALL LETTER IOTA WITH DASIA AND PERISPOMENI;Ll;0;L;1F31 0342;;;;N;;;1F3F;;1F3F\n1F38;GREEK CAPITAL LETTER IOTA WITH PSILI;Lu;0;L;0399 0313;;;;N;;;;1F30;\n1F39;GREEK CAPITAL LETTER IOTA WITH DASIA;Lu;0;L;0399 0314;;;;N;;;;1F31;\n1F3A;GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA;Lu;0;L;1F38 0300;;;;N;;;;1F32;\n1F3B;GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA;Lu;0;L;1F39 0300;;;;N;;;;1F33;\n1F3C;GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA;Lu;0;L;1F38 0301;;;;N;;;;1F34;\n1F3D;GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA;Lu;0;L;1F39 0301;;;;N;;;;1F35;\n1F3E;GREEK CAPITAL LETTER IOTA WITH PSILI AND PERISPOMENI;Lu;0;L;1F38 0342;;;;N;;;;1F36;\n1F3F;GREEK CAPITAL LETTER IOTA WITH DASIA AND PERISPOMENI;Lu;0;L;1F39 0342;;;;N;;;;1F37;\n1F40;GREEK SMALL LETTER OMICRON WITH PSILI;Ll;0;L;03BF 0313;;;;N;;;1F48;;1F48\n1F41;GREEK SMALL LETTER OMICRON WITH DASIA;Ll;0;L;03BF 0314;;;;N;;;1F49;;1F49\n1F42;GREEK SMALL LETTER OMICRON WITH PSILI AND VARIA;Ll;0;L;1F40 0300;;;;N;;;1F4A;;1F4A\n1F43;GREEK SMALL LETTER OMICRON WITH DASIA AND VARIA;Ll;0;L;1F41 0300;;;;N;;;1F4B;;1F4B\n1F44;GREEK SMALL LETTER OMICRON WITH PSILI AND OXIA;Ll;0;L;1F40 0301;;;;N;;;1F4C;;1F4C\n1F45;GREEK SMALL LETTER OMICRON WITH DASIA AND OXIA;Ll;0;L;1F41 0301;;;;N;;;1F4D;;1F4D\n1F48;GREEK CAPITAL LETTER OMICRON WITH PSILI;Lu;0;L;039F 0313;;;;N;;;;1F40;\n1F49;GREEK CAPITAL LETTER OMICRON WITH DASIA;Lu;0;L;039F 0314;;;;N;;;;1F41;\n1F4A;GREEK CAPITAL LETTER OMICRON WITH PSILI AND VARIA;Lu;0;L;1F48 0300;;;;N;;;;1F42;\n1F4B;GREEK CAPITAL LETTER OMICRON WITH DASIA AND VARIA;Lu;0;L;1F49 0300;;;;N;;;;1F43;\n1F4C;GREEK CAPITAL LETTER OMICRON WITH PSILI AND OXIA;Lu;0;L;1F48 0301;;;;N;;;;1F44;\n1F4D;GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA;Lu;0;L;1F49 0301;;;;N;;;;1F45;\n1F50;GREEK SMALL LETTER UPSILON WITH PSILI;Ll;0;L;03C5 0313;;;;N;;;;;\n1F51;GREEK SMALL LETTER UPSILON WITH DASIA;Ll;0;L;03C5 0314;;;;N;;;1F59;;1F59\n1F52;GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA;Ll;0;L;1F50 0300;;;;N;;;;;\n1F53;GREEK SMALL LETTER UPSILON WITH DASIA AND VARIA;Ll;0;L;1F51 0300;;;;N;;;1F5B;;1F5B\n1F54;GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA;Ll;0;L;1F50 0301;;;;N;;;;;\n1F55;GREEK SMALL LETTER UPSILON WITH DASIA AND OXIA;Ll;0;L;1F51 0301;;;;N;;;1F5D;;1F5D\n1F56;GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI;Ll;0;L;1F50 0342;;;;N;;;;;\n1F57;GREEK SMALL LETTER UPSILON WITH DASIA AND PERISPOMENI;Ll;0;L;1F51 0342;;;;N;;;1F5F;;1F5F\n1F59;GREEK CAPITAL LETTER UPSILON WITH DASIA;Lu;0;L;03A5 0314;;;;N;;;;1F51;\n1F5B;GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA;Lu;0;L;1F59 0300;;;;N;;;;1F53;\n1F5D;GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA;Lu;0;L;1F59 0301;;;;N;;;;1F55;\n1F5F;GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI;Lu;0;L;1F59 0342;;;;N;;;;1F57;\n1F60;GREEK SMALL LETTER OMEGA WITH PSILI;Ll;0;L;03C9 0313;;;;N;;;1F68;;1F68\n1F61;GREEK SMALL LETTER OMEGA WITH DASIA;Ll;0;L;03C9 0314;;;;N;;;1F69;;1F69\n1F62;GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA;Ll;0;L;1F60 0300;;;;N;;;1F6A;;1F6A\n1F63;GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA;Ll;0;L;1F61 0300;;;;N;;;1F6B;;1F6B\n1F64;GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA;Ll;0;L;1F60 0301;;;;N;;;1F6C;;1F6C\n1F65;GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA;Ll;0;L;1F61 0301;;;;N;;;1F6D;;1F6D\n1F66;GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI;Ll;0;L;1F60 0342;;;;N;;;1F6E;;1F6E\n1F67;GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI;Ll;0;L;1F61 0342;;;;N;;;1F6F;;1F6F\n1F68;GREEK CAPITAL LETTER OMEGA WITH PSILI;Lu;0;L;03A9 0313;;;;N;;;;1F60;\n1F69;GREEK CAPITAL LETTER OMEGA WITH DASIA;Lu;0;L;03A9 0314;;;;N;;;;1F61;\n1F6A;GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA;Lu;0;L;1F68 0300;;;;N;;;;1F62;\n1F6B;GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA;Lu;0;L;1F69 0300;;;;N;;;;1F63;\n1F6C;GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA;Lu;0;L;1F68 0301;;;;N;;;;1F64;\n1F6D;GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA;Lu;0;L;1F69 0301;;;;N;;;;1F65;\n1F6E;GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI;Lu;0;L;1F68 0342;;;;N;;;;1F66;\n1F6F;GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI;Lu;0;L;1F69 0342;;;;N;;;;1F67;\n1F70;GREEK SMALL LETTER ALPHA WITH VARIA;Ll;0;L;03B1 0300;;;;N;;;1FBA;;1FBA\n1F71;GREEK SMALL LETTER ALPHA WITH OXIA;Ll;0;L;03AC;;;;N;;;1FBB;;1FBB\n1F72;GREEK SMALL LETTER EPSILON WITH VARIA;Ll;0;L;03B5 0300;;;;N;;;1FC8;;1FC8\n1F73;GREEK SMALL LETTER EPSILON WITH OXIA;Ll;0;L;03AD;;;;N;;;1FC9;;1FC9\n1F74;GREEK SMALL LETTER ETA WITH VARIA;Ll;0;L;03B7 0300;;;;N;;;1FCA;;1FCA\n1F75;GREEK SMALL LETTER ETA WITH OXIA;Ll;0;L;03AE;;;;N;;;1FCB;;1FCB\n1F76;GREEK SMALL LETTER IOTA WITH VARIA;Ll;0;L;03B9 0300;;;;N;;;1FDA;;1FDA\n1F77;GREEK SMALL LETTER IOTA WITH OXIA;Ll;0;L;03AF;;;;N;;;1FDB;;1FDB\n1F78;GREEK SMALL LETTER OMICRON WITH VARIA;Ll;0;L;03BF 0300;;;;N;;;1FF8;;1FF8\n1F79;GREEK SMALL LETTER OMICRON WITH OXIA;Ll;0;L;03CC;;;;N;;;1FF9;;1FF9\n1F7A;GREEK SMALL LETTER UPSILON WITH VARIA;Ll;0;L;03C5 0300;;;;N;;;1FEA;;1FEA\n1F7B;GREEK SMALL LETTER UPSILON WITH OXIA;Ll;0;L;03CD;;;;N;;;1FEB;;1FEB\n1F7C;GREEK SMALL LETTER OMEGA WITH VARIA;Ll;0;L;03C9 0300;;;;N;;;1FFA;;1FFA\n1F7D;GREEK SMALL LETTER OMEGA WITH OXIA;Ll;0;L;03CE;;;;N;;;1FFB;;1FFB\n1F80;GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI;Ll;0;L;1F00 0345;;;;N;;;1F88;;1F88\n1F81;GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI;Ll;0;L;1F01 0345;;;;N;;;1F89;;1F89\n1F82;GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F02 0345;;;;N;;;1F8A;;1F8A\n1F83;GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F03 0345;;;;N;;;1F8B;;1F8B\n1F84;GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F04 0345;;;;N;;;1F8C;;1F8C\n1F85;GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F05 0345;;;;N;;;1F8D;;1F8D\n1F86;GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F06 0345;;;;N;;;1F8E;;1F8E\n1F87;GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F07 0345;;;;N;;;1F8F;;1F8F\n1F88;GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI;Lt;0;L;1F08 0345;;;;N;;;;1F80;\n1F89;GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI;Lt;0;L;1F09 0345;;;;N;;;;1F81;\n1F8A;GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F0A 0345;;;;N;;;;1F82;\n1F8B;GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F0B 0345;;;;N;;;;1F83;\n1F8C;GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F0C 0345;;;;N;;;;1F84;\n1F8D;GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F0D 0345;;;;N;;;;1F85;\n1F8E;GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F0E 0345;;;;N;;;;1F86;\n1F8F;GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F0F 0345;;;;N;;;;1F87;\n1F90;GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI;Ll;0;L;1F20 0345;;;;N;;;1F98;;1F98\n1F91;GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI;Ll;0;L;1F21 0345;;;;N;;;1F99;;1F99\n1F92;GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F22 0345;;;;N;;;1F9A;;1F9A\n1F93;GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F23 0345;;;;N;;;1F9B;;1F9B\n1F94;GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F24 0345;;;;N;;;1F9C;;1F9C\n1F95;GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F25 0345;;;;N;;;1F9D;;1F9D\n1F96;GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F26 0345;;;;N;;;1F9E;;1F9E\n1F97;GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F27 0345;;;;N;;;1F9F;;1F9F\n1F98;GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI;Lt;0;L;1F28 0345;;;;N;;;;1F90;\n1F99;GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI;Lt;0;L;1F29 0345;;;;N;;;;1F91;\n1F9A;GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F2A 0345;;;;N;;;;1F92;\n1F9B;GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F2B 0345;;;;N;;;;1F93;\n1F9C;GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F2C 0345;;;;N;;;;1F94;\n1F9D;GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F2D 0345;;;;N;;;;1F95;\n1F9E;GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F2E 0345;;;;N;;;;1F96;\n1F9F;GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F2F 0345;;;;N;;;;1F97;\n1FA0;GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI;Ll;0;L;1F60 0345;;;;N;;;1FA8;;1FA8\n1FA1;GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI;Ll;0;L;1F61 0345;;;;N;;;1FA9;;1FA9\n1FA2;GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F62 0345;;;;N;;;1FAA;;1FAA\n1FA3;GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI;Ll;0;L;1F63 0345;;;;N;;;1FAB;;1FAB\n1FA4;GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F64 0345;;;;N;;;1FAC;;1FAC\n1FA5;GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI;Ll;0;L;1F65 0345;;;;N;;;1FAD;;1FAD\n1FA6;GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F66 0345;;;;N;;;1FAE;;1FAE\n1FA7;GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1F67 0345;;;;N;;;1FAF;;1FAF\n1FA8;GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI;Lt;0;L;1F68 0345;;;;N;;;;1FA0;\n1FA9;GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI;Lt;0;L;1F69 0345;;;;N;;;;1FA1;\n1FAA;GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F6A 0345;;;;N;;;;1FA2;\n1FAB;GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI;Lt;0;L;1F6B 0345;;;;N;;;;1FA3;\n1FAC;GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F6C 0345;;;;N;;;;1FA4;\n1FAD;GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI;Lt;0;L;1F6D 0345;;;;N;;;;1FA5;\n1FAE;GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F6E 0345;;;;N;;;;1FA6;\n1FAF;GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI;Lt;0;L;1F6F 0345;;;;N;;;;1FA7;\n1FB0;GREEK SMALL LETTER ALPHA WITH VRACHY;Ll;0;L;03B1 0306;;;;N;;;1FB8;;1FB8\n1FB1;GREEK SMALL LETTER ALPHA WITH MACRON;Ll;0;L;03B1 0304;;;;N;;;1FB9;;1FB9\n1FB2;GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI;Ll;0;L;1F70 0345;;;;N;;;;;\n1FB3;GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI;Ll;0;L;03B1 0345;;;;N;;;1FBC;;1FBC\n1FB4;GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI;Ll;0;L;03AC 0345;;;;N;;;;;\n1FB6;GREEK SMALL LETTER ALPHA WITH PERISPOMENI;Ll;0;L;03B1 0342;;;;N;;;;;\n1FB7;GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1FB6 0345;;;;N;;;;;\n1FB8;GREEK CAPITAL LETTER ALPHA WITH VRACHY;Lu;0;L;0391 0306;;;;N;;;;1FB0;\n1FB9;GREEK CAPITAL LETTER ALPHA WITH MACRON;Lu;0;L;0391 0304;;;;N;;;;1FB1;\n1FBA;GREEK CAPITAL LETTER ALPHA WITH VARIA;Lu;0;L;0391 0300;;;;N;;;;1F70;\n1FBB;GREEK CAPITAL LETTER ALPHA WITH OXIA;Lu;0;L;0386;;;;N;;;;1F71;\n1FBC;GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI;Lt;0;L;0391 0345;;;;N;;;;1FB3;\n1FBD;GREEK KORONIS;Sk;0;ON;<compat> 0020 0313;;;;N;;;;;\n1FBE;GREEK PROSGEGRAMMENI;Ll;0;L;03B9;;;;N;;;0399;;0399\n1FBF;GREEK PSILI;Sk;0;ON;<compat> 0020 0313;;;;N;;;;;\n1FC0;GREEK PERISPOMENI;Sk;0;ON;<compat> 0020 0342;;;;N;;;;;\n1FC1;GREEK DIALYTIKA AND PERISPOMENI;Sk;0;ON;00A8 0342;;;;N;;;;;\n1FC2;GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI;Ll;0;L;1F74 0345;;;;N;;;;;\n1FC3;GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI;Ll;0;L;03B7 0345;;;;N;;;1FCC;;1FCC\n1FC4;GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI;Ll;0;L;03AE 0345;;;;N;;;;;\n1FC6;GREEK SMALL LETTER ETA WITH PERISPOMENI;Ll;0;L;03B7 0342;;;;N;;;;;\n1FC7;GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1FC6 0345;;;;N;;;;;\n1FC8;GREEK CAPITAL LETTER EPSILON WITH VARIA;Lu;0;L;0395 0300;;;;N;;;;1F72;\n1FC9;GREEK CAPITAL LETTER EPSILON WITH OXIA;Lu;0;L;0388;;;;N;;;;1F73;\n1FCA;GREEK CAPITAL LETTER ETA WITH VARIA;Lu;0;L;0397 0300;;;;N;;;;1F74;\n1FCB;GREEK CAPITAL LETTER ETA WITH OXIA;Lu;0;L;0389;;;;N;;;;1F75;\n1FCC;GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI;Lt;0;L;0397 0345;;;;N;;;;1FC3;\n1FCD;GREEK PSILI AND VARIA;Sk;0;ON;1FBF 0300;;;;N;;;;;\n1FCE;GREEK PSILI AND OXIA;Sk;0;ON;1FBF 0301;;;;N;;;;;\n1FCF;GREEK PSILI AND PERISPOMENI;Sk;0;ON;1FBF 0342;;;;N;;;;;\n1FD0;GREEK SMALL LETTER IOTA WITH VRACHY;Ll;0;L;03B9 0306;;;;N;;;1FD8;;1FD8\n1FD1;GREEK SMALL LETTER IOTA WITH MACRON;Ll;0;L;03B9 0304;;;;N;;;1FD9;;1FD9\n1FD2;GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA;Ll;0;L;03CA 0300;;;;N;;;;;\n1FD3;GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA;Ll;0;L;0390;;;;N;;;;;\n1FD6;GREEK SMALL LETTER IOTA WITH PERISPOMENI;Ll;0;L;03B9 0342;;;;N;;;;;\n1FD7;GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI;Ll;0;L;03CA 0342;;;;N;;;;;\n1FD8;GREEK CAPITAL LETTER IOTA WITH VRACHY;Lu;0;L;0399 0306;;;;N;;;;1FD0;\n1FD9;GREEK CAPITAL LETTER IOTA WITH MACRON;Lu;0;L;0399 0304;;;;N;;;;1FD1;\n1FDA;GREEK CAPITAL LETTER IOTA WITH VARIA;Lu;0;L;0399 0300;;;;N;;;;1F76;\n1FDB;GREEK CAPITAL LETTER IOTA WITH OXIA;Lu;0;L;038A;;;;N;;;;1F77;\n1FDD;GREEK DASIA AND VARIA;Sk;0;ON;1FFE 0300;;;;N;;;;;\n1FDE;GREEK DASIA AND OXIA;Sk;0;ON;1FFE 0301;;;;N;;;;;\n1FDF;GREEK DASIA AND PERISPOMENI;Sk;0;ON;1FFE 0342;;;;N;;;;;\n1FE0;GREEK SMALL LETTER UPSILON WITH VRACHY;Ll;0;L;03C5 0306;;;;N;;;1FE8;;1FE8\n1FE1;GREEK SMALL LETTER UPSILON WITH MACRON;Ll;0;L;03C5 0304;;;;N;;;1FE9;;1FE9\n1FE2;GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA;Ll;0;L;03CB 0300;;;;N;;;;;\n1FE3;GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA;Ll;0;L;03B0;;;;N;;;;;\n1FE4;GREEK SMALL LETTER RHO WITH PSILI;Ll;0;L;03C1 0313;;;;N;;;;;\n1FE5;GREEK SMALL LETTER RHO WITH DASIA;Ll;0;L;03C1 0314;;;;N;;;1FEC;;1FEC\n1FE6;GREEK SMALL LETTER UPSILON WITH PERISPOMENI;Ll;0;L;03C5 0342;;;;N;;;;;\n1FE7;GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI;Ll;0;L;03CB 0342;;;;N;;;;;\n1FE8;GREEK CAPITAL LETTER UPSILON WITH VRACHY;Lu;0;L;03A5 0306;;;;N;;;;1FE0;\n1FE9;GREEK CAPITAL LETTER UPSILON WITH MACRON;Lu;0;L;03A5 0304;;;;N;;;;1FE1;\n1FEA;GREEK CAPITAL LETTER UPSILON WITH VARIA;Lu;0;L;03A5 0300;;;;N;;;;1F7A;\n1FEB;GREEK CAPITAL LETTER UPSILON WITH OXIA;Lu;0;L;038E;;;;N;;;;1F7B;\n1FEC;GREEK CAPITAL LETTER RHO WITH DASIA;Lu;0;L;03A1 0314;;;;N;;;;1FE5;\n1FED;GREEK DIALYTIKA AND VARIA;Sk;0;ON;00A8 0300;;;;N;;;;;\n1FEE;GREEK DIALYTIKA AND OXIA;Sk;0;ON;0385;;;;N;;;;;\n1FEF;GREEK VARIA;Sk;0;ON;0060;;;;N;;;;;\n1FF2;GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI;Ll;0;L;1F7C 0345;;;;N;;;;;\n1FF3;GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI;Ll;0;L;03C9 0345;;;;N;;;1FFC;;1FFC\n1FF4;GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI;Ll;0;L;03CE 0345;;;;N;;;;;\n1FF6;GREEK SMALL LETTER OMEGA WITH PERISPOMENI;Ll;0;L;03C9 0342;;;;N;;;;;\n1FF7;GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI;Ll;0;L;1FF6 0345;;;;N;;;;;\n1FF8;GREEK CAPITAL LETTER OMICRON WITH VARIA;Lu;0;L;039F 0300;;;;N;;;;1F78;\n1FF9;GREEK CAPITAL LETTER OMICRON WITH OXIA;Lu;0;L;038C;;;;N;;;;1F79;\n1FFA;GREEK CAPITAL LETTER OMEGA WITH VARIA;Lu;0;L;03A9 0300;;;;N;;;;1F7C;\n1FFB;GREEK CAPITAL LETTER OMEGA WITH OXIA;Lu;0;L;038F;;;;N;;;;1F7D;\n1FFC;GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI;Lt;0;L;03A9 0345;;;;N;;;;1FF3;\n1FFD;GREEK OXIA;Sk;0;ON;00B4;;;;N;;;;;\n1FFE;GREEK DASIA;Sk;0;ON;<compat> 0020 0314;;;;N;;;;;\n2000;EN QUAD;Zs;0;WS;2002;;;;N;;;;;\n2001;EM QUAD;Zs;0;WS;2003;;;;N;;;;;\n2002;EN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2003;EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2004;THREE-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2005;FOUR-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2006;SIX-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2007;FIGURE SPACE;Zs;0;WS;<noBreak> 0020;;;;N;;;;;\n2008;PUNCTUATION SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2009;THIN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n200A;HAIR SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n200B;ZERO WIDTH SPACE;Cf;0;BN;;;;;N;;;;;\n200C;ZERO WIDTH NON-JOINER;Cf;0;BN;;;;;N;;;;;\n200D;ZERO WIDTH JOINER;Cf;0;BN;;;;;N;;;;;\n200E;LEFT-TO-RIGHT MARK;Cf;0;L;;;;;N;;;;;\n200F;RIGHT-TO-LEFT MARK;Cf;0;R;;;;;N;;;;;\n2010;HYPHEN;Pd;0;ON;;;;;N;;;;;\n2011;NON-BREAKING HYPHEN;Pd;0;ON;<noBreak> 2010;;;;N;;;;;\n2012;FIGURE DASH;Pd;0;ON;;;;;N;;;;;\n2013;EN DASH;Pd;0;ON;;;;;N;;;;;\n2014;EM DASH;Pd;0;ON;;;;;N;;;;;\n2015;HORIZONTAL BAR;Pd;0;ON;;;;;N;QUOTATION DASH;;;;\n2016;DOUBLE VERTICAL LINE;Po;0;ON;;;;;N;DOUBLE VERTICAL BAR;;;;\n2017;DOUBLE LOW LINE;Po;0;ON;<compat> 0020 0333;;;;N;SPACING DOUBLE UNDERSCORE;;;;\n2018;LEFT SINGLE QUOTATION MARK;Pi;0;ON;;;;;N;SINGLE TURNED COMMA QUOTATION MARK;;;;\n2019;RIGHT SINGLE QUOTATION MARK;Pf;0;ON;;;;;N;SINGLE COMMA QUOTATION MARK;;;;\n201A;SINGLE LOW-9 QUOTATION MARK;Ps;0;ON;;;;;N;LOW SINGLE COMMA QUOTATION MARK;;;;\n201B;SINGLE HIGH-REVERSED-9 QUOTATION MARK;Pi;0;ON;;;;;N;SINGLE REVERSED COMMA QUOTATION MARK;;;;\n201C;LEFT DOUBLE QUOTATION MARK;Pi;0;ON;;;;;N;DOUBLE TURNED COMMA QUOTATION MARK;;;;\n201D;RIGHT DOUBLE QUOTATION MARK;Pf;0;ON;;;;;N;DOUBLE COMMA QUOTATION MARK;;;;\n201E;DOUBLE LOW-9 QUOTATION MARK;Ps;0;ON;;;;;N;LOW DOUBLE COMMA QUOTATION MARK;;;;\n201F;DOUBLE HIGH-REVERSED-9 QUOTATION MARK;Pi;0;ON;;;;;N;DOUBLE REVERSED COMMA QUOTATION MARK;;;;\n2020;DAGGER;Po;0;ON;;;;;N;;;;;\n2021;DOUBLE DAGGER;Po;0;ON;;;;;N;;;;;\n2022;BULLET;Po;0;ON;;;;;N;;;;;\n2023;TRIANGULAR BULLET;Po;0;ON;;;;;N;;;;;\n2024;ONE DOT LEADER;Po;0;ON;<compat> 002E;;;;N;;;;;\n2025;TWO DOT LEADER;Po;0;ON;<compat> 002E 002E;;;;N;;;;;\n2026;HORIZONTAL ELLIPSIS;Po;0;ON;<compat> 002E 002E 002E;;;;N;;;;;\n2027;HYPHENATION POINT;Po;0;ON;;;;;N;;;;;\n2028;LINE SEPARATOR;Zl;0;WS;;;;;N;;;;;\n2029;PARAGRAPH SEPARATOR;Zp;0;B;;;;;N;;;;;\n202A;LEFT-TO-RIGHT EMBEDDING;Cf;0;LRE;;;;;N;;;;;\n202B;RIGHT-TO-LEFT EMBEDDING;Cf;0;RLE;;;;;N;;;;;\n202C;POP DIRECTIONAL FORMATTING;Cf;0;PDF;;;;;N;;;;;\n202D;LEFT-TO-RIGHT OVERRIDE;Cf;0;LRO;;;;;N;;;;;\n202E;RIGHT-TO-LEFT OVERRIDE;Cf;0;RLO;;;;;N;;;;;\n202F;NARROW NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;;;;;\n2030;PER MILLE SIGN;Po;0;ET;;;;;N;;;;;\n2031;PER TEN THOUSAND SIGN;Po;0;ET;;;;;N;;;;;\n2032;PRIME;Po;0;ET;;;;;N;;;;;\n2033;DOUBLE PRIME;Po;0;ET;<compat> 2032 2032;;;;N;;;;;\n2034;TRIPLE PRIME;Po;0;ET;<compat> 2032 2032 2032;;;;N;;;;;\n2035;REVERSED PRIME;Po;0;ON;;;;;N;;;;;\n2036;REVERSED DOUBLE PRIME;Po;0;ON;<compat> 2035 2035;;;;N;;;;;\n2037;REVERSED TRIPLE PRIME;Po;0;ON;<compat> 2035 2035 2035;;;;N;;;;;\n2038;CARET;Po;0;ON;;;;;N;;;;;\n2039;SINGLE LEFT-POINTING ANGLE QUOTATION MARK;Pi;0;ON;;;;;Y;LEFT POINTING SINGLE GUILLEMET;;;;\n203A;SINGLE RIGHT-POINTING ANGLE QUOTATION MARK;Pf;0;ON;;;;;Y;RIGHT POINTING SINGLE GUILLEMET;;;;\n203B;REFERENCE MARK;Po;0;ON;;;;;N;;;;;\n203C;DOUBLE EXCLAMATION MARK;Po;0;ON;<compat> 0021 0021;;;;N;;;;;\n203D;INTERROBANG;Po;0;ON;;;;;N;;;;;\n203E;OVERLINE;Po;0;ON;<compat> 0020 0305;;;;N;SPACING OVERSCORE;;;;\n203F;UNDERTIE;Pc;0;ON;;;;;N;;;;;\n2040;CHARACTER TIE;Pc;0;ON;;;;;N;;;;;\n2041;CARET INSERTION POINT;Po;0;ON;;;;;N;;;;;\n2042;ASTERISM;Po;0;ON;;;;;N;;;;;\n2043;HYPHEN BULLET;Po;0;ON;;;;;N;;;;;\n2044;FRACTION SLASH;Sm;0;CS;;;;;N;;;;;\n2045;LEFT SQUARE BRACKET WITH QUILL;Ps;0;ON;;;;;Y;;;;;\n2046;RIGHT SQUARE BRACKET WITH QUILL;Pe;0;ON;;;;;Y;;;;;\n2047;DOUBLE QUESTION MARK;Po;0;ON;<compat> 003F 003F;;;;N;;;;;\n2048;QUESTION EXCLAMATION MARK;Po;0;ON;<compat> 003F 0021;;;;N;;;;;\n2049;EXCLAMATION QUESTION MARK;Po;0;ON;<compat> 0021 003F;;;;N;;;;;\n204A;TIRONIAN SIGN ET;Po;0;ON;;;;;N;;;;;\n204B;REVERSED PILCROW SIGN;Po;0;ON;;;;;N;;;;;\n204C;BLACK LEFTWARDS BULLET;Po;0;ON;;;;;N;;;;;\n204D;BLACK RIGHTWARDS BULLET;Po;0;ON;;;;;N;;;;;\n204E;LOW ASTERISK;Po;0;ON;;;;;N;;;;;\n204F;REVERSED SEMICOLON;Po;0;ON;;;;;N;;;;;\n2050;CLOSE UP;Po;0;ON;;;;;N;;;;;\n2051;TWO ASTERISKS ALIGNED VERTICALLY;Po;0;ON;;;;;N;;;;;\n2052;COMMERCIAL MINUS SIGN;Sm;0;ON;;;;;N;;;;;\n2053;SWUNG DASH;Po;0;ON;;;;;N;;;;;\n2054;INVERTED UNDERTIE;Pc;0;ON;;;;;N;;;;;\n2055;FLOWER PUNCTUATION MARK;Po;0;ON;;;;;N;;;;;\n2056;THREE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n2057;QUADRUPLE PRIME;Po;0;ON;<compat> 2032 2032 2032 2032;;;;N;;;;;\n2058;FOUR DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n2059;FIVE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n205A;TWO DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n205B;FOUR DOT MARK;Po;0;ON;;;;;N;;;;;\n205C;DOTTED CROSS;Po;0;ON;;;;;N;;;;;\n205D;TRICOLON;Po;0;ON;;;;;N;;;;;\n205E;VERTICAL FOUR DOTS;Po;0;ON;;;;;N;;;;;\n205F;MEDIUM MATHEMATICAL SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n2060;WORD JOINER;Cf;0;BN;;;;;N;;;;;\n2061;FUNCTION APPLICATION;Cf;0;BN;;;;;N;;;;;\n2062;INVISIBLE TIMES;Cf;0;BN;;;;;N;;;;;\n2063;INVISIBLE SEPARATOR;Cf;0;BN;;;;;N;;;;;\n2064;INVISIBLE PLUS;Cf;0;BN;;;;;N;;;;;\n206A;INHIBIT SYMMETRIC SWAPPING;Cf;0;BN;;;;;N;;;;;\n206B;ACTIVATE SYMMETRIC SWAPPING;Cf;0;BN;;;;;N;;;;;\n206C;INHIBIT ARABIC FORM SHAPING;Cf;0;BN;;;;;N;;;;;\n206D;ACTIVATE ARABIC FORM SHAPING;Cf;0;BN;;;;;N;;;;;\n206E;NATIONAL DIGIT SHAPES;Cf;0;BN;;;;;N;;;;;\n206F;NOMINAL DIGIT SHAPES;Cf;0;BN;;;;;N;;;;;\n2070;SUPERSCRIPT ZERO;No;0;EN;<super> 0030;;0;0;N;SUPERSCRIPT DIGIT ZERO;;;;\n2071;SUPERSCRIPT LATIN SMALL LETTER I;Lm;0;L;<super> 0069;;;;N;;;;;\n2074;SUPERSCRIPT FOUR;No;0;EN;<super> 0034;;4;4;N;SUPERSCRIPT DIGIT FOUR;;;;\n2075;SUPERSCRIPT FIVE;No;0;EN;<super> 0035;;5;5;N;SUPERSCRIPT DIGIT FIVE;;;;\n2076;SUPERSCRIPT SIX;No;0;EN;<super> 0036;;6;6;N;SUPERSCRIPT DIGIT SIX;;;;\n2077;SUPERSCRIPT SEVEN;No;0;EN;<super> 0037;;7;7;N;SUPERSCRIPT DIGIT SEVEN;;;;\n2078;SUPERSCRIPT EIGHT;No;0;EN;<super> 0038;;8;8;N;SUPERSCRIPT DIGIT EIGHT;;;;\n2079;SUPERSCRIPT NINE;No;0;EN;<super> 0039;;9;9;N;SUPERSCRIPT DIGIT NINE;;;;\n207A;SUPERSCRIPT PLUS SIGN;Sm;0;ES;<super> 002B;;;;N;;;;;\n207B;SUPERSCRIPT MINUS;Sm;0;ES;<super> 2212;;;;N;SUPERSCRIPT HYPHEN-MINUS;;;;\n207C;SUPERSCRIPT EQUALS SIGN;Sm;0;ON;<super> 003D;;;;N;;;;;\n207D;SUPERSCRIPT LEFT PARENTHESIS;Ps;0;ON;<super> 0028;;;;Y;SUPERSCRIPT OPENING PARENTHESIS;;;;\n207E;SUPERSCRIPT RIGHT PARENTHESIS;Pe;0;ON;<super> 0029;;;;Y;SUPERSCRIPT CLOSING PARENTHESIS;;;;\n207F;SUPERSCRIPT LATIN SMALL LETTER N;Lm;0;L;<super> 006E;;;;N;;;;;\n2080;SUBSCRIPT ZERO;No;0;EN;<sub> 0030;;0;0;N;SUBSCRIPT DIGIT ZERO;;;;\n2081;SUBSCRIPT ONE;No;0;EN;<sub> 0031;;1;1;N;SUBSCRIPT DIGIT ONE;;;;\n2082;SUBSCRIPT TWO;No;0;EN;<sub> 0032;;2;2;N;SUBSCRIPT DIGIT TWO;;;;\n2083;SUBSCRIPT THREE;No;0;EN;<sub> 0033;;3;3;N;SUBSCRIPT DIGIT THREE;;;;\n2084;SUBSCRIPT FOUR;No;0;EN;<sub> 0034;;4;4;N;SUBSCRIPT DIGIT FOUR;;;;\n2085;SUBSCRIPT FIVE;No;0;EN;<sub> 0035;;5;5;N;SUBSCRIPT DIGIT FIVE;;;;\n2086;SUBSCRIPT SIX;No;0;EN;<sub> 0036;;6;6;N;SUBSCRIPT DIGIT SIX;;;;\n2087;SUBSCRIPT SEVEN;No;0;EN;<sub> 0037;;7;7;N;SUBSCRIPT DIGIT SEVEN;;;;\n2088;SUBSCRIPT EIGHT;No;0;EN;<sub> 0038;;8;8;N;SUBSCRIPT DIGIT EIGHT;;;;\n2089;SUBSCRIPT NINE;No;0;EN;<sub> 0039;;9;9;N;SUBSCRIPT DIGIT NINE;;;;\n208A;SUBSCRIPT PLUS SIGN;Sm;0;ES;<sub> 002B;;;;N;;;;;\n208B;SUBSCRIPT MINUS;Sm;0;ES;<sub> 2212;;;;N;SUBSCRIPT HYPHEN-MINUS;;;;\n208C;SUBSCRIPT EQUALS SIGN;Sm;0;ON;<sub> 003D;;;;N;;;;;\n208D;SUBSCRIPT LEFT PARENTHESIS;Ps;0;ON;<sub> 0028;;;;Y;SUBSCRIPT OPENING PARENTHESIS;;;;\n208E;SUBSCRIPT RIGHT PARENTHESIS;Pe;0;ON;<sub> 0029;;;;Y;SUBSCRIPT CLOSING PARENTHESIS;;;;\n2090;LATIN SUBSCRIPT SMALL LETTER A;Lm;0;L;<sub> 0061;;;;N;;;;;\n2091;LATIN SUBSCRIPT SMALL LETTER E;Lm;0;L;<sub> 0065;;;;N;;;;;\n2092;LATIN SUBSCRIPT SMALL LETTER O;Lm;0;L;<sub> 006F;;;;N;;;;;\n2093;LATIN SUBSCRIPT SMALL LETTER X;Lm;0;L;<sub> 0078;;;;N;;;;;\n2094;LATIN SUBSCRIPT SMALL LETTER SCHWA;Lm;0;L;<sub> 0259;;;;N;;;;;\n2095;LATIN SUBSCRIPT SMALL LETTER H;Lm;0;L;<sub> 0068;;;;N;;;;;\n2096;LATIN SUBSCRIPT SMALL LETTER K;Lm;0;L;<sub> 006B;;;;N;;;;;\n2097;LATIN SUBSCRIPT SMALL LETTER L;Lm;0;L;<sub> 006C;;;;N;;;;;\n2098;LATIN SUBSCRIPT SMALL LETTER M;Lm;0;L;<sub> 006D;;;;N;;;;;\n2099;LATIN SUBSCRIPT SMALL LETTER N;Lm;0;L;<sub> 006E;;;;N;;;;;\n209A;LATIN SUBSCRIPT SMALL LETTER P;Lm;0;L;<sub> 0070;;;;N;;;;;\n209B;LATIN SUBSCRIPT SMALL LETTER S;Lm;0;L;<sub> 0073;;;;N;;;;;\n209C;LATIN SUBSCRIPT SMALL LETTER T;Lm;0;L;<sub> 0074;;;;N;;;;;\n20A0;EURO-CURRENCY SIGN;Sc;0;ET;;;;;N;;;;;\n20A1;COLON SIGN;Sc;0;ET;;;;;N;;;;;\n20A2;CRUZEIRO SIGN;Sc;0;ET;;;;;N;;;;;\n20A3;FRENCH FRANC SIGN;Sc;0;ET;;;;;N;;;;;\n20A4;LIRA SIGN;Sc;0;ET;;;;;N;;;;;\n20A5;MILL SIGN;Sc;0;ET;;;;;N;;;;;\n20A6;NAIRA SIGN;Sc;0;ET;;;;;N;;;;;\n20A7;PESETA SIGN;Sc;0;ET;;;;;N;;;;;\n20A8;RUPEE SIGN;Sc;0;ET;<compat> 0052 0073;;;;N;;;;;\n20A9;WON SIGN;Sc;0;ET;;;;;N;;;;;\n20AA;NEW SHEQEL SIGN;Sc;0;ET;;;;;N;;;;;\n20AB;DONG SIGN;Sc;0;ET;;;;;N;;;;;\n20AC;EURO SIGN;Sc;0;ET;;;;;N;;;;;\n20AD;KIP SIGN;Sc;0;ET;;;;;N;;;;;\n20AE;TUGRIK SIGN;Sc;0;ET;;;;;N;;;;;\n20AF;DRACHMA SIGN;Sc;0;ET;;;;;N;;;;;\n20B0;GERMAN PENNY SIGN;Sc;0;ET;;;;;N;;;;;\n20B1;PESO SIGN;Sc;0;ET;;;;;N;;;;;\n20B2;GUARANI SIGN;Sc;0;ET;;;;;N;;;;;\n20B3;AUSTRAL SIGN;Sc;0;ET;;;;;N;;;;;\n20B4;HRYVNIA SIGN;Sc;0;ET;;;;;N;;;;;\n20B5;CEDI SIGN;Sc;0;ET;;;;;N;;;;;\n20B6;LIVRE TOURNOIS SIGN;Sc;0;ET;;;;;N;;;;;\n20B7;SPESMILO SIGN;Sc;0;ET;;;;;N;;;;;\n20B8;TENGE SIGN;Sc;0;ET;;;;;N;;;;;\n20B9;INDIAN RUPEE SIGN;Sc;0;ET;;;;;N;;;;;\n20D0;COMBINING LEFT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT HARPOON ABOVE;;;;\n20D1;COMBINING RIGHT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT HARPOON ABOVE;;;;\n20D2;COMBINING LONG VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG VERTICAL BAR OVERLAY;;;;\n20D3;COMBINING SHORT VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING SHORT VERTICAL BAR OVERLAY;;;;\n20D4;COMBINING ANTICLOCKWISE ARROW ABOVE;Mn;230;NSM;;;;;N;NON-SPACING ANTICLOCKWISE ARROW ABOVE;;;;\n20D5;COMBINING CLOCKWISE ARROW ABOVE;Mn;230;NSM;;;;;N;NON-SPACING CLOCKWISE ARROW ABOVE;;;;\n20D6;COMBINING LEFT ARROW ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT ARROW ABOVE;;;;\n20D7;COMBINING RIGHT ARROW ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT ARROW ABOVE;;;;\n20D8;COMBINING RING OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING RING OVERLAY;;;;\n20D9;COMBINING CLOCKWISE RING OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING CLOCKWISE RING OVERLAY;;;;\n20DA;COMBINING ANTICLOCKWISE RING OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING ANTICLOCKWISE RING OVERLAY;;;;\n20DB;COMBINING THREE DOTS ABOVE;Mn;230;NSM;;;;;N;NON-SPACING THREE DOTS ABOVE;;;;\n20DC;COMBINING FOUR DOTS ABOVE;Mn;230;NSM;;;;;N;NON-SPACING FOUR DOTS ABOVE;;;;\n20DD;COMBINING ENCLOSING CIRCLE;Me;0;NSM;;;;;N;ENCLOSING CIRCLE;;;;\n20DE;COMBINING ENCLOSING SQUARE;Me;0;NSM;;;;;N;ENCLOSING SQUARE;;;;\n20DF;COMBINING ENCLOSING DIAMOND;Me;0;NSM;;;;;N;ENCLOSING DIAMOND;;;;\n20E0;COMBINING ENCLOSING CIRCLE BACKSLASH;Me;0;NSM;;;;;N;ENCLOSING CIRCLE SLASH;;;;\n20E1;COMBINING LEFT RIGHT ARROW ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT RIGHT ARROW ABOVE;;;;\n20E2;COMBINING ENCLOSING SCREEN;Me;0;NSM;;;;;N;;;;;\n20E3;COMBINING ENCLOSING KEYCAP;Me;0;NSM;;;;;N;;;;;\n20E4;COMBINING ENCLOSING UPWARD POINTING TRIANGLE;Me;0;NSM;;;;;N;;;;;\n20E5;COMBINING REVERSE SOLIDUS OVERLAY;Mn;1;NSM;;;;;N;;;;;\n20E6;COMBINING DOUBLE VERTICAL STROKE OVERLAY;Mn;1;NSM;;;;;N;;;;;\n20E7;COMBINING ANNUITY SYMBOL;Mn;230;NSM;;;;;N;;;;;\n20E8;COMBINING TRIPLE UNDERDOT;Mn;220;NSM;;;;;N;;;;;\n20E9;COMBINING WIDE BRIDGE ABOVE;Mn;230;NSM;;;;;N;;;;;\n20EA;COMBINING LEFTWARDS ARROW OVERLAY;Mn;1;NSM;;;;;N;;;;;\n20EB;COMBINING LONG DOUBLE SOLIDUS OVERLAY;Mn;1;NSM;;;;;N;;;;;\n20EC;COMBINING RIGHTWARDS HARPOON WITH BARB DOWNWARDS;Mn;220;NSM;;;;;N;;;;;\n20ED;COMBINING LEFTWARDS HARPOON WITH BARB DOWNWARDS;Mn;220;NSM;;;;;N;;;;;\n20EE;COMBINING LEFT ARROW BELOW;Mn;220;NSM;;;;;N;;;;;\n20EF;COMBINING RIGHT ARROW BELOW;Mn;220;NSM;;;;;N;;;;;\n20F0;COMBINING ASTERISK ABOVE;Mn;230;NSM;;;;;N;;;;;\n2100;ACCOUNT OF;So;0;ON;<compat> 0061 002F 0063;;;;N;;;;;\n2101;ADDRESSED TO THE SUBJECT;So;0;ON;<compat> 0061 002F 0073;;;;N;;;;;\n2102;DOUBLE-STRUCK CAPITAL C;Lu;0;L;<font> 0043;;;;N;DOUBLE-STRUCK C;;;;\n2103;DEGREE CELSIUS;So;0;ON;<compat> 00B0 0043;;;;N;DEGREES CENTIGRADE;;;;\n2104;CENTRE LINE SYMBOL;So;0;ON;;;;;N;C L SYMBOL;;;;\n2105;CARE OF;So;0;ON;<compat> 0063 002F 006F;;;;N;;;;;\n2106;CADA UNA;So;0;ON;<compat> 0063 002F 0075;;;;N;;;;;\n2107;EULER CONSTANT;Lu;0;L;<compat> 0190;;;;N;EULERS;;;;\n2108;SCRUPLE;So;0;ON;;;;;N;;;;;\n2109;DEGREE FAHRENHEIT;So;0;ON;<compat> 00B0 0046;;;;N;DEGREES FAHRENHEIT;;;;\n210A;SCRIPT SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n210B;SCRIPT CAPITAL H;Lu;0;L;<font> 0048;;;;N;SCRIPT H;;;;\n210C;BLACK-LETTER CAPITAL H;Lu;0;L;<font> 0048;;;;N;BLACK-LETTER H;;;;\n210D;DOUBLE-STRUCK CAPITAL H;Lu;0;L;<font> 0048;;;;N;DOUBLE-STRUCK H;;;;\n210E;PLANCK CONSTANT;Ll;0;L;<font> 0068;;;;N;;;;;\n210F;PLANCK CONSTANT OVER TWO PI;Ll;0;L;<font> 0127;;;;N;PLANCK CONSTANT OVER 2 PI;;;;\n2110;SCRIPT CAPITAL I;Lu;0;L;<font> 0049;;;;N;SCRIPT I;;;;\n2111;BLACK-LETTER CAPITAL I;Lu;0;L;<font> 0049;;;;N;BLACK-LETTER I;;;;\n2112;SCRIPT CAPITAL L;Lu;0;L;<font> 004C;;;;N;SCRIPT L;;;;\n2113;SCRIPT SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n2114;L B BAR SYMBOL;So;0;ON;;;;;N;;;;;\n2115;DOUBLE-STRUCK CAPITAL N;Lu;0;L;<font> 004E;;;;N;DOUBLE-STRUCK N;;;;\n2116;NUMERO SIGN;So;0;ON;<compat> 004E 006F;;;;N;NUMERO;;;;\n2117;SOUND RECORDING COPYRIGHT;So;0;ON;;;;;N;;;;;\n2118;SCRIPT CAPITAL P;Sm;0;ON;;;;;N;SCRIPT P;;;;\n2119;DOUBLE-STRUCK CAPITAL P;Lu;0;L;<font> 0050;;;;N;DOUBLE-STRUCK P;;;;\n211A;DOUBLE-STRUCK CAPITAL Q;Lu;0;L;<font> 0051;;;;N;DOUBLE-STRUCK Q;;;;\n211B;SCRIPT CAPITAL R;Lu;0;L;<font> 0052;;;;N;SCRIPT R;;;;\n211C;BLACK-LETTER CAPITAL R;Lu;0;L;<font> 0052;;;;N;BLACK-LETTER R;;;;\n211D;DOUBLE-STRUCK CAPITAL R;Lu;0;L;<font> 0052;;;;N;DOUBLE-STRUCK R;;;;\n211E;PRESCRIPTION TAKE;So;0;ON;;;;;N;;;;;\n211F;RESPONSE;So;0;ON;;;;;N;;;;;\n2120;SERVICE MARK;So;0;ON;<super> 0053 004D;;;;N;;;;;\n2121;TELEPHONE SIGN;So;0;ON;<compat> 0054 0045 004C;;;;N;T E L SYMBOL;;;;\n2122;TRADE MARK SIGN;So;0;ON;<super> 0054 004D;;;;N;TRADEMARK;;;;\n2123;VERSICLE;So;0;ON;;;;;N;;;;;\n2124;DOUBLE-STRUCK CAPITAL Z;Lu;0;L;<font> 005A;;;;N;DOUBLE-STRUCK Z;;;;\n2125;OUNCE SIGN;So;0;ON;;;;;N;OUNCE;;;;\n2126;OHM SIGN;Lu;0;L;03A9;;;;N;OHM;;;03C9;\n2127;INVERTED OHM SIGN;So;0;ON;;;;;N;MHO;;;;\n2128;BLACK-LETTER CAPITAL Z;Lu;0;L;<font> 005A;;;;N;BLACK-LETTER Z;;;;\n2129;TURNED GREEK SMALL LETTER IOTA;So;0;ON;;;;;N;;;;;\n212A;KELVIN SIGN;Lu;0;L;004B;;;;N;DEGREES KELVIN;;;006B;\n212B;ANGSTROM SIGN;Lu;0;L;00C5;;;;N;ANGSTROM UNIT;;;00E5;\n212C;SCRIPT CAPITAL B;Lu;0;L;<font> 0042;;;;N;SCRIPT B;;;;\n212D;BLACK-LETTER CAPITAL C;Lu;0;L;<font> 0043;;;;N;BLACK-LETTER C;;;;\n212E;ESTIMATED SYMBOL;So;0;ET;;;;;N;;;;;\n212F;SCRIPT SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n2130;SCRIPT CAPITAL E;Lu;0;L;<font> 0045;;;;N;SCRIPT E;;;;\n2131;SCRIPT CAPITAL F;Lu;0;L;<font> 0046;;;;N;SCRIPT F;;;;\n2132;TURNED CAPITAL F;Lu;0;L;;;;;N;TURNED F;;;214E;\n2133;SCRIPT CAPITAL M;Lu;0;L;<font> 004D;;;;N;SCRIPT M;;;;\n2134;SCRIPT SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n2135;ALEF SYMBOL;Lo;0;L;<compat> 05D0;;;;N;FIRST TRANSFINITE CARDINAL;;;;\n2136;BET SYMBOL;Lo;0;L;<compat> 05D1;;;;N;SECOND TRANSFINITE CARDINAL;;;;\n2137;GIMEL SYMBOL;Lo;0;L;<compat> 05D2;;;;N;THIRD TRANSFINITE CARDINAL;;;;\n2138;DALET SYMBOL;Lo;0;L;<compat> 05D3;;;;N;FOURTH TRANSFINITE CARDINAL;;;;\n2139;INFORMATION SOURCE;Ll;0;L;<font> 0069;;;;N;;;;;\n213A;ROTATED CAPITAL Q;So;0;ON;;;;;N;;;;;\n213B;FACSIMILE SIGN;So;0;ON;<compat> 0046 0041 0058;;;;N;;;;;\n213C;DOUBLE-STRUCK SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n213D;DOUBLE-STRUCK SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n213E;DOUBLE-STRUCK CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n213F;DOUBLE-STRUCK CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n2140;DOUBLE-STRUCK N-ARY SUMMATION;Sm;0;ON;<font> 2211;;;;Y;;;;;\n2141;TURNED SANS-SERIF CAPITAL G;Sm;0;ON;;;;;N;;;;;\n2142;TURNED SANS-SERIF CAPITAL L;Sm;0;ON;;;;;N;;;;;\n2143;REVERSED SANS-SERIF CAPITAL L;Sm;0;ON;;;;;N;;;;;\n2144;TURNED SANS-SERIF CAPITAL Y;Sm;0;ON;;;;;N;;;;;\n2145;DOUBLE-STRUCK ITALIC CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n2146;DOUBLE-STRUCK ITALIC SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n2147;DOUBLE-STRUCK ITALIC SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n2148;DOUBLE-STRUCK ITALIC SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n2149;DOUBLE-STRUCK ITALIC SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n214A;PROPERTY LINE;So;0;ON;;;;;N;;;;;\n214B;TURNED AMPERSAND;Sm;0;ON;;;;;N;;;;;\n214C;PER SIGN;So;0;ON;;;;;N;;;;;\n214D;AKTIESELSKAB;So;0;ON;;;;;N;;;;;\n214E;TURNED SMALL F;Ll;0;L;;;;;N;;;2132;;2132\n214F;SYMBOL FOR SAMARITAN SOURCE;So;0;L;;;;;N;;;;;\n2150;VULGAR FRACTION ONE SEVENTH;No;0;ON;<fraction> 0031 2044 0037;;;1/7;N;;;;;\n2151;VULGAR FRACTION ONE NINTH;No;0;ON;<fraction> 0031 2044 0039;;;1/9;N;;;;;\n2152;VULGAR FRACTION ONE TENTH;No;0;ON;<fraction> 0031 2044 0031 0030;;;1/10;N;;;;;\n2153;VULGAR FRACTION ONE THIRD;No;0;ON;<fraction> 0031 2044 0033;;;1/3;N;FRACTION ONE THIRD;;;;\n2154;VULGAR FRACTION TWO THIRDS;No;0;ON;<fraction> 0032 2044 0033;;;2/3;N;FRACTION TWO THIRDS;;;;\n2155;VULGAR FRACTION ONE FIFTH;No;0;ON;<fraction> 0031 2044 0035;;;1/5;N;FRACTION ONE FIFTH;;;;\n2156;VULGAR FRACTION TWO FIFTHS;No;0;ON;<fraction> 0032 2044 0035;;;2/5;N;FRACTION TWO FIFTHS;;;;\n2157;VULGAR FRACTION THREE FIFTHS;No;0;ON;<fraction> 0033 2044 0035;;;3/5;N;FRACTION THREE FIFTHS;;;;\n2158;VULGAR FRACTION FOUR FIFTHS;No;0;ON;<fraction> 0034 2044 0035;;;4/5;N;FRACTION FOUR FIFTHS;;;;\n2159;VULGAR FRACTION ONE SIXTH;No;0;ON;<fraction> 0031 2044 0036;;;1/6;N;FRACTION ONE SIXTH;;;;\n215A;VULGAR FRACTION FIVE SIXTHS;No;0;ON;<fraction> 0035 2044 0036;;;5/6;N;FRACTION FIVE SIXTHS;;;;\n215B;VULGAR FRACTION ONE EIGHTH;No;0;ON;<fraction> 0031 2044 0038;;;1/8;N;FRACTION ONE EIGHTH;;;;\n215C;VULGAR FRACTION THREE EIGHTHS;No;0;ON;<fraction> 0033 2044 0038;;;3/8;N;FRACTION THREE EIGHTHS;;;;\n215D;VULGAR FRACTION FIVE EIGHTHS;No;0;ON;<fraction> 0035 2044 0038;;;5/8;N;FRACTION FIVE EIGHTHS;;;;\n215E;VULGAR FRACTION SEVEN EIGHTHS;No;0;ON;<fraction> 0037 2044 0038;;;7/8;N;FRACTION SEVEN EIGHTHS;;;;\n215F;FRACTION NUMERATOR ONE;No;0;ON;<fraction> 0031 2044;;;1;N;;;;;\n2160;ROMAN NUMERAL ONE;Nl;0;L;<compat> 0049;;;1;N;;;;2170;\n2161;ROMAN NUMERAL TWO;Nl;0;L;<compat> 0049 0049;;;2;N;;;;2171;\n2162;ROMAN NUMERAL THREE;Nl;0;L;<compat> 0049 0049 0049;;;3;N;;;;2172;\n2163;ROMAN NUMERAL FOUR;Nl;0;L;<compat> 0049 0056;;;4;N;;;;2173;\n2164;ROMAN NUMERAL FIVE;Nl;0;L;<compat> 0056;;;5;N;;;;2174;\n2165;ROMAN NUMERAL SIX;Nl;0;L;<compat> 0056 0049;;;6;N;;;;2175;\n2166;ROMAN NUMERAL SEVEN;Nl;0;L;<compat> 0056 0049 0049;;;7;N;;;;2176;\n2167;ROMAN NUMERAL EIGHT;Nl;0;L;<compat> 0056 0049 0049 0049;;;8;N;;;;2177;\n2168;ROMAN NUMERAL NINE;Nl;0;L;<compat> 0049 0058;;;9;N;;;;2178;\n2169;ROMAN NUMERAL TEN;Nl;0;L;<compat> 0058;;;10;N;;;;2179;\n216A;ROMAN NUMERAL ELEVEN;Nl;0;L;<compat> 0058 0049;;;11;N;;;;217A;\n216B;ROMAN NUMERAL TWELVE;Nl;0;L;<compat> 0058 0049 0049;;;12;N;;;;217B;\n216C;ROMAN NUMERAL FIFTY;Nl;0;L;<compat> 004C;;;50;N;;;;217C;\n216D;ROMAN NUMERAL ONE HUNDRED;Nl;0;L;<compat> 0043;;;100;N;;;;217D;\n216E;ROMAN NUMERAL FIVE HUNDRED;Nl;0;L;<compat> 0044;;;500;N;;;;217E;\n216F;ROMAN NUMERAL ONE THOUSAND;Nl;0;L;<compat> 004D;;;1000;N;;;;217F;\n2170;SMALL ROMAN NUMERAL ONE;Nl;0;L;<compat> 0069;;;1;N;;;2160;;2160\n2171;SMALL ROMAN NUMERAL TWO;Nl;0;L;<compat> 0069 0069;;;2;N;;;2161;;2161\n2172;SMALL ROMAN NUMERAL THREE;Nl;0;L;<compat> 0069 0069 0069;;;3;N;;;2162;;2162\n2173;SMALL ROMAN NUMERAL FOUR;Nl;0;L;<compat> 0069 0076;;;4;N;;;2163;;2163\n2174;SMALL ROMAN NUMERAL FIVE;Nl;0;L;<compat> 0076;;;5;N;;;2164;;2164\n2175;SMALL ROMAN NUMERAL SIX;Nl;0;L;<compat> 0076 0069;;;6;N;;;2165;;2165\n2176;SMALL ROMAN NUMERAL SEVEN;Nl;0;L;<compat> 0076 0069 0069;;;7;N;;;2166;;2166\n2177;SMALL ROMAN NUMERAL EIGHT;Nl;0;L;<compat> 0076 0069 0069 0069;;;8;N;;;2167;;2167\n2178;SMALL ROMAN NUMERAL NINE;Nl;0;L;<compat> 0069 0078;;;9;N;;;2168;;2168\n2179;SMALL ROMAN NUMERAL TEN;Nl;0;L;<compat> 0078;;;10;N;;;2169;;2169\n217A;SMALL ROMAN NUMERAL ELEVEN;Nl;0;L;<compat> 0078 0069;;;11;N;;;216A;;216A\n217B;SMALL ROMAN NUMERAL TWELVE;Nl;0;L;<compat> 0078 0069 0069;;;12;N;;;216B;;216B\n217C;SMALL ROMAN NUMERAL FIFTY;Nl;0;L;<compat> 006C;;;50;N;;;216C;;216C\n217D;SMALL ROMAN NUMERAL ONE HUNDRED;Nl;0;L;<compat> 0063;;;100;N;;;216D;;216D\n217E;SMALL ROMAN NUMERAL FIVE HUNDRED;Nl;0;L;<compat> 0064;;;500;N;;;216E;;216E\n217F;SMALL ROMAN NUMERAL ONE THOUSAND;Nl;0;L;<compat> 006D;;;1000;N;;;216F;;216F\n2180;ROMAN NUMERAL ONE THOUSAND C D;Nl;0;L;;;;1000;N;;;;;\n2181;ROMAN NUMERAL FIVE THOUSAND;Nl;0;L;;;;5000;N;;;;;\n2182;ROMAN NUMERAL TEN THOUSAND;Nl;0;L;;;;10000;N;;;;;\n2183;ROMAN NUMERAL REVERSED ONE HUNDRED;Lu;0;L;;;;;N;;;;2184;\n2184;LATIN SMALL LETTER REVERSED C;Ll;0;L;;;;;N;;;2183;;2183\n2185;ROMAN NUMERAL SIX LATE FORM;Nl;0;L;;;;6;N;;;;;\n2186;ROMAN NUMERAL FIFTY EARLY FORM;Nl;0;L;;;;50;N;;;;;\n2187;ROMAN NUMERAL FIFTY THOUSAND;Nl;0;L;;;;50000;N;;;;;\n2188;ROMAN NUMERAL ONE HUNDRED THOUSAND;Nl;0;L;;;;100000;N;;;;;\n2189;VULGAR FRACTION ZERO THIRDS;No;0;ON;<fraction> 0030 2044 0033;;;0;N;;;;;\n2190;LEFTWARDS ARROW;Sm;0;ON;;;;;N;LEFT ARROW;;;;\n2191;UPWARDS ARROW;Sm;0;ON;;;;;N;UP ARROW;;;;\n2192;RIGHTWARDS ARROW;Sm;0;ON;;;;;N;RIGHT ARROW;;;;\n2193;DOWNWARDS ARROW;Sm;0;ON;;;;;N;DOWN ARROW;;;;\n2194;LEFT RIGHT ARROW;Sm;0;ON;;;;;N;;;;;\n2195;UP DOWN ARROW;So;0;ON;;;;;N;;;;;\n2196;NORTH WEST ARROW;So;0;ON;;;;;N;UPPER LEFT ARROW;;;;\n2197;NORTH EAST ARROW;So;0;ON;;;;;N;UPPER RIGHT ARROW;;;;\n2198;SOUTH EAST ARROW;So;0;ON;;;;;N;LOWER RIGHT ARROW;;;;\n2199;SOUTH WEST ARROW;So;0;ON;;;;;N;LOWER LEFT ARROW;;;;\n219A;LEFTWARDS ARROW WITH STROKE;Sm;0;ON;2190 0338;;;;N;LEFT ARROW WITH STROKE;;;;\n219B;RIGHTWARDS ARROW WITH STROKE;Sm;0;ON;2192 0338;;;;N;RIGHT ARROW WITH STROKE;;;;\n219C;LEFTWARDS WAVE ARROW;So;0;ON;;;;;N;LEFT WAVE ARROW;;;;\n219D;RIGHTWARDS WAVE ARROW;So;0;ON;;;;;N;RIGHT WAVE ARROW;;;;\n219E;LEFTWARDS TWO HEADED ARROW;So;0;ON;;;;;N;LEFT TWO HEADED ARROW;;;;\n219F;UPWARDS TWO HEADED ARROW;So;0;ON;;;;;N;UP TWO HEADED ARROW;;;;\n21A0;RIGHTWARDS TWO HEADED ARROW;Sm;0;ON;;;;;N;RIGHT TWO HEADED ARROW;;;;\n21A1;DOWNWARDS TWO HEADED ARROW;So;0;ON;;;;;N;DOWN TWO HEADED ARROW;;;;\n21A2;LEFTWARDS ARROW WITH TAIL;So;0;ON;;;;;N;LEFT ARROW WITH TAIL;;;;\n21A3;RIGHTWARDS ARROW WITH TAIL;Sm;0;ON;;;;;N;RIGHT ARROW WITH TAIL;;;;\n21A4;LEFTWARDS ARROW FROM BAR;So;0;ON;;;;;N;LEFT ARROW FROM BAR;;;;\n21A5;UPWARDS ARROW FROM BAR;So;0;ON;;;;;N;UP ARROW FROM BAR;;;;\n21A6;RIGHTWARDS ARROW FROM BAR;Sm;0;ON;;;;;N;RIGHT ARROW FROM BAR;;;;\n21A7;DOWNWARDS ARROW FROM BAR;So;0;ON;;;;;N;DOWN ARROW FROM BAR;;;;\n21A8;UP DOWN ARROW WITH BASE;So;0;ON;;;;;N;;;;;\n21A9;LEFTWARDS ARROW WITH HOOK;So;0;ON;;;;;N;LEFT ARROW WITH HOOK;;;;\n21AA;RIGHTWARDS ARROW WITH HOOK;So;0;ON;;;;;N;RIGHT ARROW WITH HOOK;;;;\n21AB;LEFTWARDS ARROW WITH LOOP;So;0;ON;;;;;N;LEFT ARROW WITH LOOP;;;;\n21AC;RIGHTWARDS ARROW WITH LOOP;So;0;ON;;;;;N;RIGHT ARROW WITH LOOP;;;;\n21AD;LEFT RIGHT WAVE ARROW;So;0;ON;;;;;N;;;;;\n21AE;LEFT RIGHT ARROW WITH STROKE;Sm;0;ON;2194 0338;;;;N;;;;;\n21AF;DOWNWARDS ZIGZAG ARROW;So;0;ON;;;;;N;DOWN ZIGZAG ARROW;;;;\n21B0;UPWARDS ARROW WITH TIP LEFTWARDS;So;0;ON;;;;;N;UP ARROW WITH TIP LEFT;;;;\n21B1;UPWARDS ARROW WITH TIP RIGHTWARDS;So;0;ON;;;;;N;UP ARROW WITH TIP RIGHT;;;;\n21B2;DOWNWARDS ARROW WITH TIP LEFTWARDS;So;0;ON;;;;;N;DOWN ARROW WITH TIP LEFT;;;;\n21B3;DOWNWARDS ARROW WITH TIP RIGHTWARDS;So;0;ON;;;;;N;DOWN ARROW WITH TIP RIGHT;;;;\n21B4;RIGHTWARDS ARROW WITH CORNER DOWNWARDS;So;0;ON;;;;;N;RIGHT ARROW WITH CORNER DOWN;;;;\n21B5;DOWNWARDS ARROW WITH CORNER LEFTWARDS;So;0;ON;;;;;N;DOWN ARROW WITH CORNER LEFT;;;;\n21B6;ANTICLOCKWISE TOP SEMICIRCLE ARROW;So;0;ON;;;;;N;;;;;\n21B7;CLOCKWISE TOP SEMICIRCLE ARROW;So;0;ON;;;;;N;;;;;\n21B8;NORTH WEST ARROW TO LONG BAR;So;0;ON;;;;;N;UPPER LEFT ARROW TO LONG BAR;;;;\n21B9;LEFTWARDS ARROW TO BAR OVER RIGHTWARDS ARROW TO BAR;So;0;ON;;;;;N;LEFT ARROW TO BAR OVER RIGHT ARROW TO BAR;;;;\n21BA;ANTICLOCKWISE OPEN CIRCLE ARROW;So;0;ON;;;;;N;;;;;\n21BB;CLOCKWISE OPEN CIRCLE ARROW;So;0;ON;;;;;N;;;;;\n21BC;LEFTWARDS HARPOON WITH BARB UPWARDS;So;0;ON;;;;;N;LEFT HARPOON WITH BARB UP;;;;\n21BD;LEFTWARDS HARPOON WITH BARB DOWNWARDS;So;0;ON;;;;;N;LEFT HARPOON WITH BARB DOWN;;;;\n21BE;UPWARDS HARPOON WITH BARB RIGHTWARDS;So;0;ON;;;;;N;UP HARPOON WITH BARB RIGHT;;;;\n21BF;UPWARDS HARPOON WITH BARB LEFTWARDS;So;0;ON;;;;;N;UP HARPOON WITH BARB LEFT;;;;\n21C0;RIGHTWARDS HARPOON WITH BARB UPWARDS;So;0;ON;;;;;N;RIGHT HARPOON WITH BARB UP;;;;\n21C1;RIGHTWARDS HARPOON WITH BARB DOWNWARDS;So;0;ON;;;;;N;RIGHT HARPOON WITH BARB DOWN;;;;\n21C2;DOWNWARDS HARPOON WITH BARB RIGHTWARDS;So;0;ON;;;;;N;DOWN HARPOON WITH BARB RIGHT;;;;\n21C3;DOWNWARDS HARPOON WITH BARB LEFTWARDS;So;0;ON;;;;;N;DOWN HARPOON WITH BARB LEFT;;;;\n21C4;RIGHTWARDS ARROW OVER LEFTWARDS ARROW;So;0;ON;;;;;N;RIGHT ARROW OVER LEFT ARROW;;;;\n21C5;UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW;So;0;ON;;;;;N;UP ARROW LEFT OF DOWN ARROW;;;;\n21C6;LEFTWARDS ARROW OVER RIGHTWARDS ARROW;So;0;ON;;;;;N;LEFT ARROW OVER RIGHT ARROW;;;;\n21C7;LEFTWARDS PAIRED ARROWS;So;0;ON;;;;;N;LEFT PAIRED ARROWS;;;;\n21C8;UPWARDS PAIRED ARROWS;So;0;ON;;;;;N;UP PAIRED ARROWS;;;;\n21C9;RIGHTWARDS PAIRED ARROWS;So;0;ON;;;;;N;RIGHT PAIRED ARROWS;;;;\n21CA;DOWNWARDS PAIRED ARROWS;So;0;ON;;;;;N;DOWN PAIRED ARROWS;;;;\n21CB;LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON;So;0;ON;;;;;N;LEFT HARPOON OVER RIGHT HARPOON;;;;\n21CC;RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON;So;0;ON;;;;;N;RIGHT HARPOON OVER LEFT HARPOON;;;;\n21CD;LEFTWARDS DOUBLE ARROW WITH STROKE;So;0;ON;21D0 0338;;;;N;LEFT DOUBLE ARROW WITH STROKE;;;;\n21CE;LEFT RIGHT DOUBLE ARROW WITH STROKE;Sm;0;ON;21D4 0338;;;;N;;;;;\n21CF;RIGHTWARDS DOUBLE ARROW WITH STROKE;Sm;0;ON;21D2 0338;;;;N;RIGHT DOUBLE ARROW WITH STROKE;;;;\n21D0;LEFTWARDS DOUBLE ARROW;So;0;ON;;;;;N;LEFT DOUBLE ARROW;;;;\n21D1;UPWARDS DOUBLE ARROW;So;0;ON;;;;;N;UP DOUBLE ARROW;;;;\n21D2;RIGHTWARDS DOUBLE ARROW;Sm;0;ON;;;;;N;RIGHT DOUBLE ARROW;;;;\n21D3;DOWNWARDS DOUBLE ARROW;So;0;ON;;;;;N;DOWN DOUBLE ARROW;;;;\n21D4;LEFT RIGHT DOUBLE ARROW;Sm;0;ON;;;;;N;;;;;\n21D5;UP DOWN DOUBLE ARROW;So;0;ON;;;;;N;;;;;\n21D6;NORTH WEST DOUBLE ARROW;So;0;ON;;;;;N;UPPER LEFT DOUBLE ARROW;;;;\n21D7;NORTH EAST DOUBLE ARROW;So;0;ON;;;;;N;UPPER RIGHT DOUBLE ARROW;;;;\n21D8;SOUTH EAST DOUBLE ARROW;So;0;ON;;;;;N;LOWER RIGHT DOUBLE ARROW;;;;\n21D9;SOUTH WEST DOUBLE ARROW;So;0;ON;;;;;N;LOWER LEFT DOUBLE ARROW;;;;\n21DA;LEFTWARDS TRIPLE ARROW;So;0;ON;;;;;N;LEFT TRIPLE ARROW;;;;\n21DB;RIGHTWARDS TRIPLE ARROW;So;0;ON;;;;;N;RIGHT TRIPLE ARROW;;;;\n21DC;LEFTWARDS SQUIGGLE ARROW;So;0;ON;;;;;N;LEFT SQUIGGLE ARROW;;;;\n21DD;RIGHTWARDS SQUIGGLE ARROW;So;0;ON;;;;;N;RIGHT SQUIGGLE ARROW;;;;\n21DE;UPWARDS ARROW WITH DOUBLE STROKE;So;0;ON;;;;;N;UP ARROW WITH DOUBLE STROKE;;;;\n21DF;DOWNWARDS ARROW WITH DOUBLE STROKE;So;0;ON;;;;;N;DOWN ARROW WITH DOUBLE STROKE;;;;\n21E0;LEFTWARDS DASHED ARROW;So;0;ON;;;;;N;LEFT DASHED ARROW;;;;\n21E1;UPWARDS DASHED ARROW;So;0;ON;;;;;N;UP DASHED ARROW;;;;\n21E2;RIGHTWARDS DASHED ARROW;So;0;ON;;;;;N;RIGHT DASHED ARROW;;;;\n21E3;DOWNWARDS DASHED ARROW;So;0;ON;;;;;N;DOWN DASHED ARROW;;;;\n21E4;LEFTWARDS ARROW TO BAR;So;0;ON;;;;;N;LEFT ARROW TO BAR;;;;\n21E5;RIGHTWARDS ARROW TO BAR;So;0;ON;;;;;N;RIGHT ARROW TO BAR;;;;\n21E6;LEFTWARDS WHITE ARROW;So;0;ON;;;;;N;WHITE LEFT ARROW;;;;\n21E7;UPWARDS WHITE ARROW;So;0;ON;;;;;N;WHITE UP ARROW;;;;\n21E8;RIGHTWARDS WHITE ARROW;So;0;ON;;;;;N;WHITE RIGHT ARROW;;;;\n21E9;DOWNWARDS WHITE ARROW;So;0;ON;;;;;N;WHITE DOWN ARROW;;;;\n21EA;UPWARDS WHITE ARROW FROM BAR;So;0;ON;;;;;N;WHITE UP ARROW FROM BAR;;;;\n21EB;UPWARDS WHITE ARROW ON PEDESTAL;So;0;ON;;;;;N;;;;;\n21EC;UPWARDS WHITE ARROW ON PEDESTAL WITH HORIZONTAL BAR;So;0;ON;;;;;N;;;;;\n21ED;UPWARDS WHITE ARROW ON PEDESTAL WITH VERTICAL BAR;So;0;ON;;;;;N;;;;;\n21EE;UPWARDS WHITE DOUBLE ARROW;So;0;ON;;;;;N;;;;;\n21EF;UPWARDS WHITE DOUBLE ARROW ON PEDESTAL;So;0;ON;;;;;N;;;;;\n21F0;RIGHTWARDS WHITE ARROW FROM WALL;So;0;ON;;;;;N;;;;;\n21F1;NORTH WEST ARROW TO CORNER;So;0;ON;;;;;N;;;;;\n21F2;SOUTH EAST ARROW TO CORNER;So;0;ON;;;;;N;;;;;\n21F3;UP DOWN WHITE ARROW;So;0;ON;;;;;N;;;;;\n21F4;RIGHT ARROW WITH SMALL CIRCLE;Sm;0;ON;;;;;N;;;;;\n21F5;DOWNWARDS ARROW LEFTWARDS OF UPWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n21F6;THREE RIGHTWARDS ARROWS;Sm;0;ON;;;;;N;;;;;\n21F7;LEFTWARDS ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21F8;RIGHTWARDS ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21F9;LEFT RIGHT ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21FA;LEFTWARDS ARROW WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21FB;RIGHTWARDS ARROW WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21FC;LEFT RIGHT ARROW WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n21FD;LEFTWARDS OPEN-HEADED ARROW;Sm;0;ON;;;;;N;;;;;\n21FE;RIGHTWARDS OPEN-HEADED ARROW;Sm;0;ON;;;;;N;;;;;\n21FF;LEFT RIGHT OPEN-HEADED ARROW;Sm;0;ON;;;;;N;;;;;\n2200;FOR ALL;Sm;0;ON;;;;;N;;;;;\n2201;COMPLEMENT;Sm;0;ON;;;;;Y;;;;;\n2202;PARTIAL DIFFERENTIAL;Sm;0;ON;;;;;Y;;;;;\n2203;THERE EXISTS;Sm;0;ON;;;;;Y;;;;;\n2204;THERE DOES NOT EXIST;Sm;0;ON;2203 0338;;;;Y;;;;;\n2205;EMPTY SET;Sm;0;ON;;;;;N;;;;;\n2206;INCREMENT;Sm;0;ON;;;;;N;;;;;\n2207;NABLA;Sm;0;ON;;;;;N;;;;;\n2208;ELEMENT OF;Sm;0;ON;;;;;Y;;;;;\n2209;NOT AN ELEMENT OF;Sm;0;ON;2208 0338;;;;Y;;;;;\n220A;SMALL ELEMENT OF;Sm;0;ON;;;;;Y;;;;;\n220B;CONTAINS AS MEMBER;Sm;0;ON;;;;;Y;;;;;\n220C;DOES NOT CONTAIN AS MEMBER;Sm;0;ON;220B 0338;;;;Y;;;;;\n220D;SMALL CONTAINS AS MEMBER;Sm;0;ON;;;;;Y;;;;;\n220E;END OF PROOF;Sm;0;ON;;;;;N;;;;;\n220F;N-ARY PRODUCT;Sm;0;ON;;;;;N;;;;;\n2210;N-ARY COPRODUCT;Sm;0;ON;;;;;N;;;;;\n2211;N-ARY SUMMATION;Sm;0;ON;;;;;Y;;;;;\n2212;MINUS SIGN;Sm;0;ES;;;;;N;;;;;\n2213;MINUS-OR-PLUS SIGN;Sm;0;ET;;;;;N;;;;;\n2214;DOT PLUS;Sm;0;ON;;;;;N;;;;;\n2215;DIVISION SLASH;Sm;0;ON;;;;;Y;;;;;\n2216;SET MINUS;Sm;0;ON;;;;;Y;;;;;\n2217;ASTERISK OPERATOR;Sm;0;ON;;;;;N;;;;;\n2218;RING OPERATOR;Sm;0;ON;;;;;N;;;;;\n2219;BULLET OPERATOR;Sm;0;ON;;;;;N;;;;;\n221A;SQUARE ROOT;Sm;0;ON;;;;;Y;;;;;\n221B;CUBE ROOT;Sm;0;ON;;;;;Y;;;;;\n221C;FOURTH ROOT;Sm;0;ON;;;;;Y;;;;;\n221D;PROPORTIONAL TO;Sm;0;ON;;;;;Y;;;;;\n221E;INFINITY;Sm;0;ON;;;;;N;;;;;\n221F;RIGHT ANGLE;Sm;0;ON;;;;;Y;;;;;\n2220;ANGLE;Sm;0;ON;;;;;Y;;;;;\n2221;MEASURED ANGLE;Sm;0;ON;;;;;Y;;;;;\n2222;SPHERICAL ANGLE;Sm;0;ON;;;;;Y;;;;;\n2223;DIVIDES;Sm;0;ON;;;;;N;;;;;\n2224;DOES NOT DIVIDE;Sm;0;ON;2223 0338;;;;Y;;;;;\n2225;PARALLEL TO;Sm;0;ON;;;;;N;;;;;\n2226;NOT PARALLEL TO;Sm;0;ON;2225 0338;;;;Y;;;;;\n2227;LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n2228;LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n2229;INTERSECTION;Sm;0;ON;;;;;N;;;;;\n222A;UNION;Sm;0;ON;;;;;N;;;;;\n222B;INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n222C;DOUBLE INTEGRAL;Sm;0;ON;<compat> 222B 222B;;;;Y;;;;;\n222D;TRIPLE INTEGRAL;Sm;0;ON;<compat> 222B 222B 222B;;;;Y;;;;;\n222E;CONTOUR INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n222F;SURFACE INTEGRAL;Sm;0;ON;<compat> 222E 222E;;;;Y;;;;;\n2230;VOLUME INTEGRAL;Sm;0;ON;<compat> 222E 222E 222E;;;;Y;;;;;\n2231;CLOCKWISE INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2232;CLOCKWISE CONTOUR INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2233;ANTICLOCKWISE CONTOUR INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2234;THEREFORE;Sm;0;ON;;;;;N;;;;;\n2235;BECAUSE;Sm;0;ON;;;;;N;;;;;\n2236;RATIO;Sm;0;ON;;;;;N;;;;;\n2237;PROPORTION;Sm;0;ON;;;;;N;;;;;\n2238;DOT MINUS;Sm;0;ON;;;;;N;;;;;\n2239;EXCESS;Sm;0;ON;;;;;Y;;;;;\n223A;GEOMETRIC PROPORTION;Sm;0;ON;;;;;N;;;;;\n223B;HOMOTHETIC;Sm;0;ON;;;;;Y;;;;;\n223C;TILDE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n223D;REVERSED TILDE;Sm;0;ON;;;;;Y;;;;;\n223E;INVERTED LAZY S;Sm;0;ON;;;;;Y;;;;;\n223F;SINE WAVE;Sm;0;ON;;;;;Y;;;;;\n2240;WREATH PRODUCT;Sm;0;ON;;;;;Y;;;;;\n2241;NOT TILDE;Sm;0;ON;223C 0338;;;;Y;;;;;\n2242;MINUS TILDE;Sm;0;ON;;;;;Y;;;;;\n2243;ASYMPTOTICALLY EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2244;NOT ASYMPTOTICALLY EQUAL TO;Sm;0;ON;2243 0338;;;;Y;;;;;\n2245;APPROXIMATELY EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2246;APPROXIMATELY BUT NOT ACTUALLY EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2247;NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO;Sm;0;ON;2245 0338;;;;Y;;;;;\n2248;ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2249;NOT ALMOST EQUAL TO;Sm;0;ON;2248 0338;;;;Y;;;;;\n224A;ALMOST EQUAL OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n224B;TRIPLE TILDE;Sm;0;ON;;;;;Y;;;;;\n224C;ALL EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n224D;EQUIVALENT TO;Sm;0;ON;;;;;N;;;;;\n224E;GEOMETRICALLY EQUIVALENT TO;Sm;0;ON;;;;;N;;;;;\n224F;DIFFERENCE BETWEEN;Sm;0;ON;;;;;N;;;;;\n2250;APPROACHES THE LIMIT;Sm;0;ON;;;;;N;;;;;\n2251;GEOMETRICALLY EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2252;APPROXIMATELY EQUAL TO OR THE IMAGE OF;Sm;0;ON;;;;;Y;;;;;\n2253;IMAGE OF OR APPROXIMATELY EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2254;COLON EQUALS;Sm;0;ON;;;;;Y;COLON EQUAL;;;;\n2255;EQUALS COLON;Sm;0;ON;;;;;Y;EQUAL COLON;;;;\n2256;RING IN EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2257;RING EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2258;CORRESPONDS TO;Sm;0;ON;;;;;N;;;;;\n2259;ESTIMATES;Sm;0;ON;;;;;N;;;;;\n225A;EQUIANGULAR TO;Sm;0;ON;;;;;N;;;;;\n225B;STAR EQUALS;Sm;0;ON;;;;;N;;;;;\n225C;DELTA EQUAL TO;Sm;0;ON;;;;;N;;;;;\n225D;EQUAL TO BY DEFINITION;Sm;0;ON;;;;;N;;;;;\n225E;MEASURED BY;Sm;0;ON;;;;;N;;;;;\n225F;QUESTIONED EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2260;NOT EQUAL TO;Sm;0;ON;003D 0338;;;;Y;;;;;\n2261;IDENTICAL TO;Sm;0;ON;;;;;N;;;;;\n2262;NOT IDENTICAL TO;Sm;0;ON;2261 0338;;;;Y;;;;;\n2263;STRICTLY EQUIVALENT TO;Sm;0;ON;;;;;N;;;;;\n2264;LESS-THAN OR EQUAL TO;Sm;0;ON;;;;;Y;LESS THAN OR EQUAL TO;;;;\n2265;GREATER-THAN OR EQUAL TO;Sm;0;ON;;;;;Y;GREATER THAN OR EQUAL TO;;;;\n2266;LESS-THAN OVER EQUAL TO;Sm;0;ON;;;;;Y;LESS THAN OVER EQUAL TO;;;;\n2267;GREATER-THAN OVER EQUAL TO;Sm;0;ON;;;;;Y;GREATER THAN OVER EQUAL TO;;;;\n2268;LESS-THAN BUT NOT EQUAL TO;Sm;0;ON;;;;;Y;LESS THAN BUT NOT EQUAL TO;;;;\n2269;GREATER-THAN BUT NOT EQUAL TO;Sm;0;ON;;;;;Y;GREATER THAN BUT NOT EQUAL TO;;;;\n226A;MUCH LESS-THAN;Sm;0;ON;;;;;Y;MUCH LESS THAN;;;;\n226B;MUCH GREATER-THAN;Sm;0;ON;;;;;Y;MUCH GREATER THAN;;;;\n226C;BETWEEN;Sm;0;ON;;;;;N;;;;;\n226D;NOT EQUIVALENT TO;Sm;0;ON;224D 0338;;;;N;;;;;\n226E;NOT LESS-THAN;Sm;0;ON;003C 0338;;;;Y;NOT LESS THAN;;;;\n226F;NOT GREATER-THAN;Sm;0;ON;003E 0338;;;;Y;NOT GREATER THAN;;;;\n2270;NEITHER LESS-THAN NOR EQUAL TO;Sm;0;ON;2264 0338;;;;Y;NEITHER LESS THAN NOR EQUAL TO;;;;\n2271;NEITHER GREATER-THAN NOR EQUAL TO;Sm;0;ON;2265 0338;;;;Y;NEITHER GREATER THAN NOR EQUAL TO;;;;\n2272;LESS-THAN OR EQUIVALENT TO;Sm;0;ON;;;;;Y;LESS THAN OR EQUIVALENT TO;;;;\n2273;GREATER-THAN OR EQUIVALENT TO;Sm;0;ON;;;;;Y;GREATER THAN OR EQUIVALENT TO;;;;\n2274;NEITHER LESS-THAN NOR EQUIVALENT TO;Sm;0;ON;2272 0338;;;;Y;NEITHER LESS THAN NOR EQUIVALENT TO;;;;\n2275;NEITHER GREATER-THAN NOR EQUIVALENT TO;Sm;0;ON;2273 0338;;;;Y;NEITHER GREATER THAN NOR EQUIVALENT TO;;;;\n2276;LESS-THAN OR GREATER-THAN;Sm;0;ON;;;;;Y;LESS THAN OR GREATER THAN;;;;\n2277;GREATER-THAN OR LESS-THAN;Sm;0;ON;;;;;Y;GREATER THAN OR LESS THAN;;;;\n2278;NEITHER LESS-THAN NOR GREATER-THAN;Sm;0;ON;2276 0338;;;;Y;NEITHER LESS THAN NOR GREATER THAN;;;;\n2279;NEITHER GREATER-THAN NOR LESS-THAN;Sm;0;ON;2277 0338;;;;Y;NEITHER GREATER THAN NOR LESS THAN;;;;\n227A;PRECEDES;Sm;0;ON;;;;;Y;;;;;\n227B;SUCCEEDS;Sm;0;ON;;;;;Y;;;;;\n227C;PRECEDES OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n227D;SUCCEEDS OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n227E;PRECEDES OR EQUIVALENT TO;Sm;0;ON;;;;;Y;;;;;\n227F;SUCCEEDS OR EQUIVALENT TO;Sm;0;ON;;;;;Y;;;;;\n2280;DOES NOT PRECEDE;Sm;0;ON;227A 0338;;;;Y;;;;;\n2281;DOES NOT SUCCEED;Sm;0;ON;227B 0338;;;;Y;;;;;\n2282;SUBSET OF;Sm;0;ON;;;;;Y;;;;;\n2283;SUPERSET OF;Sm;0;ON;;;;;Y;;;;;\n2284;NOT A SUBSET OF;Sm;0;ON;2282 0338;;;;Y;;;;;\n2285;NOT A SUPERSET OF;Sm;0;ON;2283 0338;;;;Y;;;;;\n2286;SUBSET OF OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2287;SUPERSET OF OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2288;NEITHER A SUBSET OF NOR EQUAL TO;Sm;0;ON;2286 0338;;;;Y;;;;;\n2289;NEITHER A SUPERSET OF NOR EQUAL TO;Sm;0;ON;2287 0338;;;;Y;;;;;\n228A;SUBSET OF WITH NOT EQUAL TO;Sm;0;ON;;;;;Y;SUBSET OF OR NOT EQUAL TO;;;;\n228B;SUPERSET OF WITH NOT EQUAL TO;Sm;0;ON;;;;;Y;SUPERSET OF OR NOT EQUAL TO;;;;\n228C;MULTISET;Sm;0;ON;;;;;Y;;;;;\n228D;MULTISET MULTIPLICATION;Sm;0;ON;;;;;N;;;;;\n228E;MULTISET UNION;Sm;0;ON;;;;;N;;;;;\n228F;SQUARE IMAGE OF;Sm;0;ON;;;;;Y;;;;;\n2290;SQUARE ORIGINAL OF;Sm;0;ON;;;;;Y;;;;;\n2291;SQUARE IMAGE OF OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2292;SQUARE ORIGINAL OF OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2293;SQUARE CAP;Sm;0;ON;;;;;N;;;;;\n2294;SQUARE CUP;Sm;0;ON;;;;;N;;;;;\n2295;CIRCLED PLUS;Sm;0;ON;;;;;N;;;;;\n2296;CIRCLED MINUS;Sm;0;ON;;;;;N;;;;;\n2297;CIRCLED TIMES;Sm;0;ON;;;;;N;;;;;\n2298;CIRCLED DIVISION SLASH;Sm;0;ON;;;;;Y;;;;;\n2299;CIRCLED DOT OPERATOR;Sm;0;ON;;;;;N;;;;;\n229A;CIRCLED RING OPERATOR;Sm;0;ON;;;;;N;;;;;\n229B;CIRCLED ASTERISK OPERATOR;Sm;0;ON;;;;;N;;;;;\n229C;CIRCLED EQUALS;Sm;0;ON;;;;;N;;;;;\n229D;CIRCLED DASH;Sm;0;ON;;;;;N;;;;;\n229E;SQUARED PLUS;Sm;0;ON;;;;;N;;;;;\n229F;SQUARED MINUS;Sm;0;ON;;;;;N;;;;;\n22A0;SQUARED TIMES;Sm;0;ON;;;;;N;;;;;\n22A1;SQUARED DOT OPERATOR;Sm;0;ON;;;;;N;;;;;\n22A2;RIGHT TACK;Sm;0;ON;;;;;Y;;;;;\n22A3;LEFT TACK;Sm;0;ON;;;;;Y;;;;;\n22A4;DOWN TACK;Sm;0;ON;;;;;N;;;;;\n22A5;UP TACK;Sm;0;ON;;;;;N;;;;;\n22A6;ASSERTION;Sm;0;ON;;;;;Y;;;;;\n22A7;MODELS;Sm;0;ON;;;;;Y;;;;;\n22A8;TRUE;Sm;0;ON;;;;;Y;;;;;\n22A9;FORCES;Sm;0;ON;;;;;Y;;;;;\n22AA;TRIPLE VERTICAL BAR RIGHT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n22AB;DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n22AC;DOES NOT PROVE;Sm;0;ON;22A2 0338;;;;Y;;;;;\n22AD;NOT TRUE;Sm;0;ON;22A8 0338;;;;Y;;;;;\n22AE;DOES NOT FORCE;Sm;0;ON;22A9 0338;;;;Y;;;;;\n22AF;NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE;Sm;0;ON;22AB 0338;;;;Y;;;;;\n22B0;PRECEDES UNDER RELATION;Sm;0;ON;;;;;Y;;;;;\n22B1;SUCCEEDS UNDER RELATION;Sm;0;ON;;;;;Y;;;;;\n22B2;NORMAL SUBGROUP OF;Sm;0;ON;;;;;Y;;;;;\n22B3;CONTAINS AS NORMAL SUBGROUP;Sm;0;ON;;;;;Y;;;;;\n22B4;NORMAL SUBGROUP OF OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n22B5;CONTAINS AS NORMAL SUBGROUP OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n22B6;ORIGINAL OF;Sm;0;ON;;;;;Y;;;;;\n22B7;IMAGE OF;Sm;0;ON;;;;;Y;;;;;\n22B8;MULTIMAP;Sm;0;ON;;;;;Y;;;;;\n22B9;HERMITIAN CONJUGATE MATRIX;Sm;0;ON;;;;;N;;;;;\n22BA;INTERCALATE;Sm;0;ON;;;;;N;;;;;\n22BB;XOR;Sm;0;ON;;;;;N;;;;;\n22BC;NAND;Sm;0;ON;;;;;N;;;;;\n22BD;NOR;Sm;0;ON;;;;;N;;;;;\n22BE;RIGHT ANGLE WITH ARC;Sm;0;ON;;;;;Y;;;;;\n22BF;RIGHT TRIANGLE;Sm;0;ON;;;;;Y;;;;;\n22C0;N-ARY LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n22C1;N-ARY LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n22C2;N-ARY INTERSECTION;Sm;0;ON;;;;;N;;;;;\n22C3;N-ARY UNION;Sm;0;ON;;;;;N;;;;;\n22C4;DIAMOND OPERATOR;Sm;0;ON;;;;;N;;;;;\n22C5;DOT OPERATOR;Sm;0;ON;;;;;N;;;;;\n22C6;STAR OPERATOR;Sm;0;ON;;;;;N;;;;;\n22C7;DIVISION TIMES;Sm;0;ON;;;;;N;;;;;\n22C8;BOWTIE;Sm;0;ON;;;;;N;;;;;\n22C9;LEFT NORMAL FACTOR SEMIDIRECT PRODUCT;Sm;0;ON;;;;;Y;;;;;\n22CA;RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT;Sm;0;ON;;;;;Y;;;;;\n22CB;LEFT SEMIDIRECT PRODUCT;Sm;0;ON;;;;;Y;;;;;\n22CC;RIGHT SEMIDIRECT PRODUCT;Sm;0;ON;;;;;Y;;;;;\n22CD;REVERSED TILDE EQUALS;Sm;0;ON;;;;;Y;;;;;\n22CE;CURLY LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n22CF;CURLY LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n22D0;DOUBLE SUBSET;Sm;0;ON;;;;;Y;;;;;\n22D1;DOUBLE SUPERSET;Sm;0;ON;;;;;Y;;;;;\n22D2;DOUBLE INTERSECTION;Sm;0;ON;;;;;N;;;;;\n22D3;DOUBLE UNION;Sm;0;ON;;;;;N;;;;;\n22D4;PITCHFORK;Sm;0;ON;;;;;N;;;;;\n22D5;EQUAL AND PARALLEL TO;Sm;0;ON;;;;;N;;;;;\n22D6;LESS-THAN WITH DOT;Sm;0;ON;;;;;Y;LESS THAN WITH DOT;;;;\n22D7;GREATER-THAN WITH DOT;Sm;0;ON;;;;;Y;GREATER THAN WITH DOT;;;;\n22D8;VERY MUCH LESS-THAN;Sm;0;ON;;;;;Y;VERY MUCH LESS THAN;;;;\n22D9;VERY MUCH GREATER-THAN;Sm;0;ON;;;;;Y;VERY MUCH GREATER THAN;;;;\n22DA;LESS-THAN EQUAL TO OR GREATER-THAN;Sm;0;ON;;;;;Y;LESS THAN EQUAL TO OR GREATER THAN;;;;\n22DB;GREATER-THAN EQUAL TO OR LESS-THAN;Sm;0;ON;;;;;Y;GREATER THAN EQUAL TO OR LESS THAN;;;;\n22DC;EQUAL TO OR LESS-THAN;Sm;0;ON;;;;;Y;EQUAL TO OR LESS THAN;;;;\n22DD;EQUAL TO OR GREATER-THAN;Sm;0;ON;;;;;Y;EQUAL TO OR GREATER THAN;;;;\n22DE;EQUAL TO OR PRECEDES;Sm;0;ON;;;;;Y;;;;;\n22DF;EQUAL TO OR SUCCEEDS;Sm;0;ON;;;;;Y;;;;;\n22E0;DOES NOT PRECEDE OR EQUAL;Sm;0;ON;227C 0338;;;;Y;;;;;\n22E1;DOES NOT SUCCEED OR EQUAL;Sm;0;ON;227D 0338;;;;Y;;;;;\n22E2;NOT SQUARE IMAGE OF OR EQUAL TO;Sm;0;ON;2291 0338;;;;Y;;;;;\n22E3;NOT SQUARE ORIGINAL OF OR EQUAL TO;Sm;0;ON;2292 0338;;;;Y;;;;;\n22E4;SQUARE IMAGE OF OR NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n22E5;SQUARE ORIGINAL OF OR NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n22E6;LESS-THAN BUT NOT EQUIVALENT TO;Sm;0;ON;;;;;Y;LESS THAN BUT NOT EQUIVALENT TO;;;;\n22E7;GREATER-THAN BUT NOT EQUIVALENT TO;Sm;0;ON;;;;;Y;GREATER THAN BUT NOT EQUIVALENT TO;;;;\n22E8;PRECEDES BUT NOT EQUIVALENT TO;Sm;0;ON;;;;;Y;;;;;\n22E9;SUCCEEDS BUT NOT EQUIVALENT TO;Sm;0;ON;;;;;Y;;;;;\n22EA;NOT NORMAL SUBGROUP OF;Sm;0;ON;22B2 0338;;;;Y;;;;;\n22EB;DOES NOT CONTAIN AS NORMAL SUBGROUP;Sm;0;ON;22B3 0338;;;;Y;;;;;\n22EC;NOT NORMAL SUBGROUP OF OR EQUAL TO;Sm;0;ON;22B4 0338;;;;Y;;;;;\n22ED;DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL;Sm;0;ON;22B5 0338;;;;Y;;;;;\n22EE;VERTICAL ELLIPSIS;Sm;0;ON;;;;;N;;;;;\n22EF;MIDLINE HORIZONTAL ELLIPSIS;Sm;0;ON;;;;;N;;;;;\n22F0;UP RIGHT DIAGONAL ELLIPSIS;Sm;0;ON;;;;;Y;;;;;\n22F1;DOWN RIGHT DIAGONAL ELLIPSIS;Sm;0;ON;;;;;Y;;;;;\n22F2;ELEMENT OF WITH LONG HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22F3;ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22F4;SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22F5;ELEMENT OF WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n22F6;ELEMENT OF WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n22F7;SMALL ELEMENT OF WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n22F8;ELEMENT OF WITH UNDERBAR;Sm;0;ON;;;;;Y;;;;;\n22F9;ELEMENT OF WITH TWO HORIZONTAL STROKES;Sm;0;ON;;;;;Y;;;;;\n22FA;CONTAINS WITH LONG HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22FB;CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22FC;SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n22FD;CONTAINS WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n22FE;SMALL CONTAINS WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n22FF;Z NOTATION BAG MEMBERSHIP;Sm;0;ON;;;;;Y;;;;;\n2300;DIAMETER SIGN;So;0;ON;;;;;N;;;;;\n2301;ELECTRIC ARROW;So;0;ON;;;;;N;;;;;\n2302;HOUSE;So;0;ON;;;;;N;;;;;\n2303;UP ARROWHEAD;So;0;ON;;;;;N;;;;;\n2304;DOWN ARROWHEAD;So;0;ON;;;;;N;;;;;\n2305;PROJECTIVE;So;0;ON;;;;;N;;;;;\n2306;PERSPECTIVE;So;0;ON;;;;;N;;;;;\n2307;WAVY LINE;So;0;ON;;;;;N;;;;;\n2308;LEFT CEILING;Sm;0;ON;;;;;Y;;;;;\n2309;RIGHT CEILING;Sm;0;ON;;;;;Y;;;;;\n230A;LEFT FLOOR;Sm;0;ON;;;;;Y;;;;;\n230B;RIGHT FLOOR;Sm;0;ON;;;;;Y;;;;;\n230C;BOTTOM RIGHT CROP;So;0;ON;;;;;N;;;;;\n230D;BOTTOM LEFT CROP;So;0;ON;;;;;N;;;;;\n230E;TOP RIGHT CROP;So;0;ON;;;;;N;;;;;\n230F;TOP LEFT CROP;So;0;ON;;;;;N;;;;;\n2310;REVERSED NOT SIGN;So;0;ON;;;;;N;;;;;\n2311;SQUARE LOZENGE;So;0;ON;;;;;N;;;;;\n2312;ARC;So;0;ON;;;;;N;;;;;\n2313;SEGMENT;So;0;ON;;;;;N;;;;;\n2314;SECTOR;So;0;ON;;;;;N;;;;;\n2315;TELEPHONE RECORDER;So;0;ON;;;;;N;;;;;\n2316;POSITION INDICATOR;So;0;ON;;;;;N;;;;;\n2317;VIEWDATA SQUARE;So;0;ON;;;;;N;;;;;\n2318;PLACE OF INTEREST SIGN;So;0;ON;;;;;N;COMMAND KEY;;;;\n2319;TURNED NOT SIGN;So;0;ON;;;;;N;;;;;\n231A;WATCH;So;0;ON;;;;;N;;;;;\n231B;HOURGLASS;So;0;ON;;;;;N;;;;;\n231C;TOP LEFT CORNER;So;0;ON;;;;;N;;;;;\n231D;TOP RIGHT CORNER;So;0;ON;;;;;N;;;;;\n231E;BOTTOM LEFT CORNER;So;0;ON;;;;;N;;;;;\n231F;BOTTOM RIGHT CORNER;So;0;ON;;;;;N;;;;;\n2320;TOP HALF INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2321;BOTTOM HALF INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2322;FROWN;So;0;ON;;;;;N;;;;;\n2323;SMILE;So;0;ON;;;;;N;;;;;\n2324;UP ARROWHEAD BETWEEN TWO HORIZONTAL BARS;So;0;ON;;;;;N;ENTER KEY;;;;\n2325;OPTION KEY;So;0;ON;;;;;N;;;;;\n2326;ERASE TO THE RIGHT;So;0;ON;;;;;N;DELETE TO THE RIGHT KEY;;;;\n2327;X IN A RECTANGLE BOX;So;0;ON;;;;;N;CLEAR KEY;;;;\n2328;KEYBOARD;So;0;ON;;;;;N;;;;;\n2329;LEFT-POINTING ANGLE BRACKET;Ps;0;ON;3008;;;;Y;BRA;;;;\n232A;RIGHT-POINTING ANGLE BRACKET;Pe;0;ON;3009;;;;Y;KET;;;;\n232B;ERASE TO THE LEFT;So;0;ON;;;;;N;DELETE TO THE LEFT KEY;;;;\n232C;BENZENE RING;So;0;ON;;;;;N;;;;;\n232D;CYLINDRICITY;So;0;ON;;;;;N;;;;;\n232E;ALL AROUND-PROFILE;So;0;ON;;;;;N;;;;;\n232F;SYMMETRY;So;0;ON;;;;;N;;;;;\n2330;TOTAL RUNOUT;So;0;ON;;;;;N;;;;;\n2331;DIMENSION ORIGIN;So;0;ON;;;;;N;;;;;\n2332;CONICAL TAPER;So;0;ON;;;;;N;;;;;\n2333;SLOPE;So;0;ON;;;;;N;;;;;\n2334;COUNTERBORE;So;0;ON;;;;;N;;;;;\n2335;COUNTERSINK;So;0;ON;;;;;N;;;;;\n2336;APL FUNCTIONAL SYMBOL I-BEAM;So;0;L;;;;;N;;;;;\n2337;APL FUNCTIONAL SYMBOL SQUISH QUAD;So;0;L;;;;;N;;;;;\n2338;APL FUNCTIONAL SYMBOL QUAD EQUAL;So;0;L;;;;;N;;;;;\n2339;APL FUNCTIONAL SYMBOL QUAD DIVIDE;So;0;L;;;;;N;;;;;\n233A;APL FUNCTIONAL SYMBOL QUAD DIAMOND;So;0;L;;;;;N;;;;;\n233B;APL FUNCTIONAL SYMBOL QUAD JOT;So;0;L;;;;;N;;;;;\n233C;APL FUNCTIONAL SYMBOL QUAD CIRCLE;So;0;L;;;;;N;;;;;\n233D;APL FUNCTIONAL SYMBOL CIRCLE STILE;So;0;L;;;;;N;;;;;\n233E;APL FUNCTIONAL SYMBOL CIRCLE JOT;So;0;L;;;;;N;;;;;\n233F;APL FUNCTIONAL SYMBOL SLASH BAR;So;0;L;;;;;N;;;;;\n2340;APL FUNCTIONAL SYMBOL BACKSLASH BAR;So;0;L;;;;;N;;;;;\n2341;APL FUNCTIONAL SYMBOL QUAD SLASH;So;0;L;;;;;N;;;;;\n2342;APL FUNCTIONAL SYMBOL QUAD BACKSLASH;So;0;L;;;;;N;;;;;\n2343;APL FUNCTIONAL SYMBOL QUAD LESS-THAN;So;0;L;;;;;N;;;;;\n2344;APL FUNCTIONAL SYMBOL QUAD GREATER-THAN;So;0;L;;;;;N;;;;;\n2345;APL FUNCTIONAL SYMBOL LEFTWARDS VANE;So;0;L;;;;;N;;;;;\n2346;APL FUNCTIONAL SYMBOL RIGHTWARDS VANE;So;0;L;;;;;N;;;;;\n2347;APL FUNCTIONAL SYMBOL QUAD LEFTWARDS ARROW;So;0;L;;;;;N;;;;;\n2348;APL FUNCTIONAL SYMBOL QUAD RIGHTWARDS ARROW;So;0;L;;;;;N;;;;;\n2349;APL FUNCTIONAL SYMBOL CIRCLE BACKSLASH;So;0;L;;;;;N;;;;;\n234A;APL FUNCTIONAL SYMBOL DOWN TACK UNDERBAR;So;0;L;;;;;N;;;;;\n234B;APL FUNCTIONAL SYMBOL DELTA STILE;So;0;L;;;;;N;;;;;\n234C;APL FUNCTIONAL SYMBOL QUAD DOWN CARET;So;0;L;;;;;N;;;;;\n234D;APL FUNCTIONAL SYMBOL QUAD DELTA;So;0;L;;;;;N;;;;;\n234E;APL FUNCTIONAL SYMBOL DOWN TACK JOT;So;0;L;;;;;N;;;;;\n234F;APL FUNCTIONAL SYMBOL UPWARDS VANE;So;0;L;;;;;N;;;;;\n2350;APL FUNCTIONAL SYMBOL QUAD UPWARDS ARROW;So;0;L;;;;;N;;;;;\n2351;APL FUNCTIONAL SYMBOL UP TACK OVERBAR;So;0;L;;;;;N;;;;;\n2352;APL FUNCTIONAL SYMBOL DEL STILE;So;0;L;;;;;N;;;;;\n2353;APL FUNCTIONAL SYMBOL QUAD UP CARET;So;0;L;;;;;N;;;;;\n2354;APL FUNCTIONAL SYMBOL QUAD DEL;So;0;L;;;;;N;;;;;\n2355;APL FUNCTIONAL SYMBOL UP TACK JOT;So;0;L;;;;;N;;;;;\n2356;APL FUNCTIONAL SYMBOL DOWNWARDS VANE;So;0;L;;;;;N;;;;;\n2357;APL FUNCTIONAL SYMBOL QUAD DOWNWARDS ARROW;So;0;L;;;;;N;;;;;\n2358;APL FUNCTIONAL SYMBOL QUOTE UNDERBAR;So;0;L;;;;;N;;;;;\n2359;APL FUNCTIONAL SYMBOL DELTA UNDERBAR;So;0;L;;;;;N;;;;;\n235A;APL FUNCTIONAL SYMBOL DIAMOND UNDERBAR;So;0;L;;;;;N;;;;;\n235B;APL FUNCTIONAL SYMBOL JOT UNDERBAR;So;0;L;;;;;N;;;;;\n235C;APL FUNCTIONAL SYMBOL CIRCLE UNDERBAR;So;0;L;;;;;N;;;;;\n235D;APL FUNCTIONAL SYMBOL UP SHOE JOT;So;0;L;;;;;N;;;;;\n235E;APL FUNCTIONAL SYMBOL QUOTE QUAD;So;0;L;;;;;N;;;;;\n235F;APL FUNCTIONAL SYMBOL CIRCLE STAR;So;0;L;;;;;N;;;;;\n2360;APL FUNCTIONAL SYMBOL QUAD COLON;So;0;L;;;;;N;;;;;\n2361;APL FUNCTIONAL SYMBOL UP TACK DIAERESIS;So;0;L;;;;;N;;;;;\n2362;APL FUNCTIONAL SYMBOL DEL DIAERESIS;So;0;L;;;;;N;;;;;\n2363;APL FUNCTIONAL SYMBOL STAR DIAERESIS;So;0;L;;;;;N;;;;;\n2364;APL FUNCTIONAL SYMBOL JOT DIAERESIS;So;0;L;;;;;N;;;;;\n2365;APL FUNCTIONAL SYMBOL CIRCLE DIAERESIS;So;0;L;;;;;N;;;;;\n2366;APL FUNCTIONAL SYMBOL DOWN SHOE STILE;So;0;L;;;;;N;;;;;\n2367;APL FUNCTIONAL SYMBOL LEFT SHOE STILE;So;0;L;;;;;N;;;;;\n2368;APL FUNCTIONAL SYMBOL TILDE DIAERESIS;So;0;L;;;;;N;;;;;\n2369;APL FUNCTIONAL SYMBOL GREATER-THAN DIAERESIS;So;0;L;;;;;N;;;;;\n236A;APL FUNCTIONAL SYMBOL COMMA BAR;So;0;L;;;;;N;;;;;\n236B;APL FUNCTIONAL SYMBOL DEL TILDE;So;0;L;;;;;N;;;;;\n236C;APL FUNCTIONAL SYMBOL ZILDE;So;0;L;;;;;N;;;;;\n236D;APL FUNCTIONAL SYMBOL STILE TILDE;So;0;L;;;;;N;;;;;\n236E;APL FUNCTIONAL SYMBOL SEMICOLON UNDERBAR;So;0;L;;;;;N;;;;;\n236F;APL FUNCTIONAL SYMBOL QUAD NOT EQUAL;So;0;L;;;;;N;;;;;\n2370;APL FUNCTIONAL SYMBOL QUAD QUESTION;So;0;L;;;;;N;;;;;\n2371;APL FUNCTIONAL SYMBOL DOWN CARET TILDE;So;0;L;;;;;N;;;;;\n2372;APL FUNCTIONAL SYMBOL UP CARET TILDE;So;0;L;;;;;N;;;;;\n2373;APL FUNCTIONAL SYMBOL IOTA;So;0;L;;;;;N;;;;;\n2374;APL FUNCTIONAL SYMBOL RHO;So;0;L;;;;;N;;;;;\n2375;APL FUNCTIONAL SYMBOL OMEGA;So;0;L;;;;;N;;;;;\n2376;APL FUNCTIONAL SYMBOL ALPHA UNDERBAR;So;0;L;;;;;N;;;;;\n2377;APL FUNCTIONAL SYMBOL EPSILON UNDERBAR;So;0;L;;;;;N;;;;;\n2378;APL FUNCTIONAL SYMBOL IOTA UNDERBAR;So;0;L;;;;;N;;;;;\n2379;APL FUNCTIONAL SYMBOL OMEGA UNDERBAR;So;0;L;;;;;N;;;;;\n237A;APL FUNCTIONAL SYMBOL ALPHA;So;0;L;;;;;N;;;;;\n237B;NOT CHECK MARK;So;0;ON;;;;;N;;;;;\n237C;RIGHT ANGLE WITH DOWNWARDS ZIGZAG ARROW;Sm;0;ON;;;;;N;;;;;\n237D;SHOULDERED OPEN BOX;So;0;ON;;;;;N;;;;;\n237E;BELL SYMBOL;So;0;ON;;;;;N;;;;;\n237F;VERTICAL LINE WITH MIDDLE DOT;So;0;ON;;;;;N;;;;;\n2380;INSERTION SYMBOL;So;0;ON;;;;;N;;;;;\n2381;CONTINUOUS UNDERLINE SYMBOL;So;0;ON;;;;;N;;;;;\n2382;DISCONTINUOUS UNDERLINE SYMBOL;So;0;ON;;;;;N;;;;;\n2383;EMPHASIS SYMBOL;So;0;ON;;;;;N;;;;;\n2384;COMPOSITION SYMBOL;So;0;ON;;;;;N;;;;;\n2385;WHITE SQUARE WITH CENTRE VERTICAL LINE;So;0;ON;;;;;N;;;;;\n2386;ENTER SYMBOL;So;0;ON;;;;;N;;;;;\n2387;ALTERNATIVE KEY SYMBOL;So;0;ON;;;;;N;;;;;\n2388;HELM SYMBOL;So;0;ON;;;;;N;;;;;\n2389;CIRCLED HORIZONTAL BAR WITH NOTCH;So;0;ON;;;;;N;;;;;\n238A;CIRCLED TRIANGLE DOWN;So;0;ON;;;;;N;;;;;\n238B;BROKEN CIRCLE WITH NORTHWEST ARROW;So;0;ON;;;;;N;;;;;\n238C;UNDO SYMBOL;So;0;ON;;;;;N;;;;;\n238D;MONOSTABLE SYMBOL;So;0;ON;;;;;N;;;;;\n238E;HYSTERESIS SYMBOL;So;0;ON;;;;;N;;;;;\n238F;OPEN-CIRCUIT-OUTPUT H-TYPE SYMBOL;So;0;ON;;;;;N;;;;;\n2390;OPEN-CIRCUIT-OUTPUT L-TYPE SYMBOL;So;0;ON;;;;;N;;;;;\n2391;PASSIVE-PULL-DOWN-OUTPUT SYMBOL;So;0;ON;;;;;N;;;;;\n2392;PASSIVE-PULL-UP-OUTPUT SYMBOL;So;0;ON;;;;;N;;;;;\n2393;DIRECT CURRENT SYMBOL FORM TWO;So;0;ON;;;;;N;;;;;\n2394;SOFTWARE-FUNCTION SYMBOL;So;0;ON;;;;;N;;;;;\n2395;APL FUNCTIONAL SYMBOL QUAD;So;0;L;;;;;N;;;;;\n2396;DECIMAL SEPARATOR KEY SYMBOL;So;0;ON;;;;;N;;;;;\n2397;PREVIOUS PAGE;So;0;ON;;;;;N;;;;;\n2398;NEXT PAGE;So;0;ON;;;;;N;;;;;\n2399;PRINT SCREEN SYMBOL;So;0;ON;;;;;N;;;;;\n239A;CLEAR SCREEN SYMBOL;So;0;ON;;;;;N;;;;;\n239B;LEFT PARENTHESIS UPPER HOOK;Sm;0;ON;;;;;N;;;;;\n239C;LEFT PARENTHESIS EXTENSION;Sm;0;ON;;;;;N;;;;;\n239D;LEFT PARENTHESIS LOWER HOOK;Sm;0;ON;;;;;N;;;;;\n239E;RIGHT PARENTHESIS UPPER HOOK;Sm;0;ON;;;;;N;;;;;\n239F;RIGHT PARENTHESIS EXTENSION;Sm;0;ON;;;;;N;;;;;\n23A0;RIGHT PARENTHESIS LOWER HOOK;Sm;0;ON;;;;;N;;;;;\n23A1;LEFT SQUARE BRACKET UPPER CORNER;Sm;0;ON;;;;;N;;;;;\n23A2;LEFT SQUARE BRACKET EXTENSION;Sm;0;ON;;;;;N;;;;;\n23A3;LEFT SQUARE BRACKET LOWER CORNER;Sm;0;ON;;;;;N;;;;;\n23A4;RIGHT SQUARE BRACKET UPPER CORNER;Sm;0;ON;;;;;N;;;;;\n23A5;RIGHT SQUARE BRACKET EXTENSION;Sm;0;ON;;;;;N;;;;;\n23A6;RIGHT SQUARE BRACKET LOWER CORNER;Sm;0;ON;;;;;N;;;;;\n23A7;LEFT CURLY BRACKET UPPER HOOK;Sm;0;ON;;;;;N;;;;;\n23A8;LEFT CURLY BRACKET MIDDLE PIECE;Sm;0;ON;;;;;N;;;;;\n23A9;LEFT CURLY BRACKET LOWER HOOK;Sm;0;ON;;;;;N;;;;;\n23AA;CURLY BRACKET EXTENSION;Sm;0;ON;;;;;N;;;;;\n23AB;RIGHT CURLY BRACKET UPPER HOOK;Sm;0;ON;;;;;N;;;;;\n23AC;RIGHT CURLY BRACKET MIDDLE PIECE;Sm;0;ON;;;;;N;;;;;\n23AD;RIGHT CURLY BRACKET LOWER HOOK;Sm;0;ON;;;;;N;;;;;\n23AE;INTEGRAL EXTENSION;Sm;0;ON;;;;;N;;;;;\n23AF;HORIZONTAL LINE EXTENSION;Sm;0;ON;;;;;N;;;;;\n23B0;UPPER LEFT OR LOWER RIGHT CURLY BRACKET SECTION;Sm;0;ON;;;;;N;;;;;\n23B1;UPPER RIGHT OR LOWER LEFT CURLY BRACKET SECTION;Sm;0;ON;;;;;N;;;;;\n23B2;SUMMATION TOP;Sm;0;ON;;;;;N;;;;;\n23B3;SUMMATION BOTTOM;Sm;0;ON;;;;;N;;;;;\n23B4;TOP SQUARE BRACKET;So;0;ON;;;;;N;;;;;\n23B5;BOTTOM SQUARE BRACKET;So;0;ON;;;;;N;;;;;\n23B6;BOTTOM SQUARE BRACKET OVER TOP SQUARE BRACKET;So;0;ON;;;;;N;;;;;\n23B7;RADICAL SYMBOL BOTTOM;So;0;ON;;;;;N;;;;;\n23B8;LEFT VERTICAL BOX LINE;So;0;ON;;;;;N;;;;;\n23B9;RIGHT VERTICAL BOX LINE;So;0;ON;;;;;N;;;;;\n23BA;HORIZONTAL SCAN LINE-1;So;0;ON;;;;;N;;;;;\n23BB;HORIZONTAL SCAN LINE-3;So;0;ON;;;;;N;;;;;\n23BC;HORIZONTAL SCAN LINE-7;So;0;ON;;;;;N;;;;;\n23BD;HORIZONTAL SCAN LINE-9;So;0;ON;;;;;N;;;;;\n23BE;DENTISTRY SYMBOL LIGHT VERTICAL AND TOP RIGHT;So;0;ON;;;;;N;;;;;\n23BF;DENTISTRY SYMBOL LIGHT VERTICAL AND BOTTOM RIGHT;So;0;ON;;;;;N;;;;;\n23C0;DENTISTRY SYMBOL LIGHT VERTICAL WITH CIRCLE;So;0;ON;;;;;N;;;;;\n23C1;DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH CIRCLE;So;0;ON;;;;;N;;;;;\n23C2;DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH CIRCLE;So;0;ON;;;;;N;;;;;\n23C3;DENTISTRY SYMBOL LIGHT VERTICAL WITH TRIANGLE;So;0;ON;;;;;N;;;;;\n23C4;DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH TRIANGLE;So;0;ON;;;;;N;;;;;\n23C5;DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH TRIANGLE;So;0;ON;;;;;N;;;;;\n23C6;DENTISTRY SYMBOL LIGHT VERTICAL AND WAVE;So;0;ON;;;;;N;;;;;\n23C7;DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL WITH WAVE;So;0;ON;;;;;N;;;;;\n23C8;DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL WITH WAVE;So;0;ON;;;;;N;;;;;\n23C9;DENTISTRY SYMBOL LIGHT DOWN AND HORIZONTAL;So;0;ON;;;;;N;;;;;\n23CA;DENTISTRY SYMBOL LIGHT UP AND HORIZONTAL;So;0;ON;;;;;N;;;;;\n23CB;DENTISTRY SYMBOL LIGHT VERTICAL AND TOP LEFT;So;0;ON;;;;;N;;;;;\n23CC;DENTISTRY SYMBOL LIGHT VERTICAL AND BOTTOM LEFT;So;0;ON;;;;;N;;;;;\n23CD;SQUARE FOOT;So;0;ON;;;;;N;;;;;\n23CE;RETURN SYMBOL;So;0;ON;;;;;N;;;;;\n23CF;EJECT SYMBOL;So;0;ON;;;;;N;;;;;\n23D0;VERTICAL LINE EXTENSION;So;0;ON;;;;;N;;;;;\n23D1;METRICAL BREVE;So;0;ON;;;;;N;;;;;\n23D2;METRICAL LONG OVER SHORT;So;0;ON;;;;;N;;;;;\n23D3;METRICAL SHORT OVER LONG;So;0;ON;;;;;N;;;;;\n23D4;METRICAL LONG OVER TWO SHORTS;So;0;ON;;;;;N;;;;;\n23D5;METRICAL TWO SHORTS OVER LONG;So;0;ON;;;;;N;;;;;\n23D6;METRICAL TWO SHORTS JOINED;So;0;ON;;;;;N;;;;;\n23D7;METRICAL TRISEME;So;0;ON;;;;;N;;;;;\n23D8;METRICAL TETRASEME;So;0;ON;;;;;N;;;;;\n23D9;METRICAL PENTASEME;So;0;ON;;;;;N;;;;;\n23DA;EARTH GROUND;So;0;ON;;;;;N;;;;;\n23DB;FUSE;So;0;ON;;;;;N;;;;;\n23DC;TOP PARENTHESIS;Sm;0;ON;;;;;N;;;;;\n23DD;BOTTOM PARENTHESIS;Sm;0;ON;;;;;N;;;;;\n23DE;TOP CURLY BRACKET;Sm;0;ON;;;;;N;;;;;\n23DF;BOTTOM CURLY BRACKET;Sm;0;ON;;;;;N;;;;;\n23E0;TOP TORTOISE SHELL BRACKET;Sm;0;ON;;;;;N;;;;;\n23E1;BOTTOM TORTOISE SHELL BRACKET;Sm;0;ON;;;;;N;;;;;\n23E2;WHITE TRAPEZIUM;So;0;ON;;;;;N;;;;;\n23E3;BENZENE RING WITH CIRCLE;So;0;ON;;;;;N;;;;;\n23E4;STRAIGHTNESS;So;0;ON;;;;;N;;;;;\n23E5;FLATNESS;So;0;ON;;;;;N;;;;;\n23E6;AC CURRENT;So;0;ON;;;;;N;;;;;\n23E7;ELECTRICAL INTERSECTION;So;0;ON;;;;;N;;;;;\n23E8;DECIMAL EXPONENT SYMBOL;So;0;ON;;;;;N;;;;;\n23E9;BLACK RIGHT-POINTING DOUBLE TRIANGLE;So;0;ON;;;;;N;;;;;\n23EA;BLACK LEFT-POINTING DOUBLE TRIANGLE;So;0;ON;;;;;N;;;;;\n23EB;BLACK UP-POINTING DOUBLE TRIANGLE;So;0;ON;;;;;N;;;;;\n23EC;BLACK DOWN-POINTING DOUBLE TRIANGLE;So;0;ON;;;;;N;;;;;\n23ED;BLACK RIGHT-POINTING DOUBLE TRIANGLE WITH VERTICAL BAR;So;0;ON;;;;;N;;;;;\n23EE;BLACK LEFT-POINTING DOUBLE TRIANGLE WITH VERTICAL BAR;So;0;ON;;;;;N;;;;;\n23EF;BLACK RIGHT-POINTING TRIANGLE WITH DOUBLE VERTICAL BAR;So;0;ON;;;;;N;;;;;\n23F0;ALARM CLOCK;So;0;ON;;;;;N;;;;;\n23F1;STOPWATCH;So;0;ON;;;;;N;;;;;\n23F2;TIMER CLOCK;So;0;ON;;;;;N;;;;;\n23F3;HOURGLASS WITH FLOWING SAND;So;0;ON;;;;;N;;;;;\n2400;SYMBOL FOR NULL;So;0;ON;;;;;N;GRAPHIC FOR NULL;;;;\n2401;SYMBOL FOR START OF HEADING;So;0;ON;;;;;N;GRAPHIC FOR START OF HEADING;;;;\n2402;SYMBOL FOR START OF TEXT;So;0;ON;;;;;N;GRAPHIC FOR START OF TEXT;;;;\n2403;SYMBOL FOR END OF TEXT;So;0;ON;;;;;N;GRAPHIC FOR END OF TEXT;;;;\n2404;SYMBOL FOR END OF TRANSMISSION;So;0;ON;;;;;N;GRAPHIC FOR END OF TRANSMISSION;;;;\n2405;SYMBOL FOR ENQUIRY;So;0;ON;;;;;N;GRAPHIC FOR ENQUIRY;;;;\n2406;SYMBOL FOR ACKNOWLEDGE;So;0;ON;;;;;N;GRAPHIC FOR ACKNOWLEDGE;;;;\n2407;SYMBOL FOR BELL;So;0;ON;;;;;N;GRAPHIC FOR BELL;;;;\n2408;SYMBOL FOR BACKSPACE;So;0;ON;;;;;N;GRAPHIC FOR BACKSPACE;;;;\n2409;SYMBOL FOR HORIZONTAL TABULATION;So;0;ON;;;;;N;GRAPHIC FOR HORIZONTAL TABULATION;;;;\n240A;SYMBOL FOR LINE FEED;So;0;ON;;;;;N;GRAPHIC FOR LINE FEED;;;;\n240B;SYMBOL FOR VERTICAL TABULATION;So;0;ON;;;;;N;GRAPHIC FOR VERTICAL TABULATION;;;;\n240C;SYMBOL FOR FORM FEED;So;0;ON;;;;;N;GRAPHIC FOR FORM FEED;;;;\n240D;SYMBOL FOR CARRIAGE RETURN;So;0;ON;;;;;N;GRAPHIC FOR CARRIAGE RETURN;;;;\n240E;SYMBOL FOR SHIFT OUT;So;0;ON;;;;;N;GRAPHIC FOR SHIFT OUT;;;;\n240F;SYMBOL FOR SHIFT IN;So;0;ON;;;;;N;GRAPHIC FOR SHIFT IN;;;;\n2410;SYMBOL FOR DATA LINK ESCAPE;So;0;ON;;;;;N;GRAPHIC FOR DATA LINK ESCAPE;;;;\n2411;SYMBOL FOR DEVICE CONTROL ONE;So;0;ON;;;;;N;GRAPHIC FOR DEVICE CONTROL ONE;;;;\n2412;SYMBOL FOR DEVICE CONTROL TWO;So;0;ON;;;;;N;GRAPHIC FOR DEVICE CONTROL TWO;;;;\n2413;SYMBOL FOR DEVICE CONTROL THREE;So;0;ON;;;;;N;GRAPHIC FOR DEVICE CONTROL THREE;;;;\n2414;SYMBOL FOR DEVICE CONTROL FOUR;So;0;ON;;;;;N;GRAPHIC FOR DEVICE CONTROL FOUR;;;;\n2415;SYMBOL FOR NEGATIVE ACKNOWLEDGE;So;0;ON;;;;;N;GRAPHIC FOR NEGATIVE ACKNOWLEDGE;;;;\n2416;SYMBOL FOR SYNCHRONOUS IDLE;So;0;ON;;;;;N;GRAPHIC FOR SYNCHRONOUS IDLE;;;;\n2417;SYMBOL FOR END OF TRANSMISSION BLOCK;So;0;ON;;;;;N;GRAPHIC FOR END OF TRANSMISSION BLOCK;;;;\n2418;SYMBOL FOR CANCEL;So;0;ON;;;;;N;GRAPHIC FOR CANCEL;;;;\n2419;SYMBOL FOR END OF MEDIUM;So;0;ON;;;;;N;GRAPHIC FOR END OF MEDIUM;;;;\n241A;SYMBOL FOR SUBSTITUTE;So;0;ON;;;;;N;GRAPHIC FOR SUBSTITUTE;;;;\n241B;SYMBOL FOR ESCAPE;So;0;ON;;;;;N;GRAPHIC FOR ESCAPE;;;;\n241C;SYMBOL FOR FILE SEPARATOR;So;0;ON;;;;;N;GRAPHIC FOR FILE SEPARATOR;;;;\n241D;SYMBOL FOR GROUP SEPARATOR;So;0;ON;;;;;N;GRAPHIC FOR GROUP SEPARATOR;;;;\n241E;SYMBOL FOR RECORD SEPARATOR;So;0;ON;;;;;N;GRAPHIC FOR RECORD SEPARATOR;;;;\n241F;SYMBOL FOR UNIT SEPARATOR;So;0;ON;;;;;N;GRAPHIC FOR UNIT SEPARATOR;;;;\n2420;SYMBOL FOR SPACE;So;0;ON;;;;;N;GRAPHIC FOR SPACE;;;;\n2421;SYMBOL FOR DELETE;So;0;ON;;;;;N;GRAPHIC FOR DELETE;;;;\n2422;BLANK SYMBOL;So;0;ON;;;;;N;BLANK;;;;\n2423;OPEN BOX;So;0;ON;;;;;N;;;;;\n2424;SYMBOL FOR NEWLINE;So;0;ON;;;;;N;GRAPHIC FOR NEWLINE;;;;\n2425;SYMBOL FOR DELETE FORM TWO;So;0;ON;;;;;N;;;;;\n2426;SYMBOL FOR SUBSTITUTE FORM TWO;So;0;ON;;;;;N;;;;;\n2440;OCR HOOK;So;0;ON;;;;;N;;;;;\n2441;OCR CHAIR;So;0;ON;;;;;N;;;;;\n2442;OCR FORK;So;0;ON;;;;;N;;;;;\n2443;OCR INVERTED FORK;So;0;ON;;;;;N;;;;;\n2444;OCR BELT BUCKLE;So;0;ON;;;;;N;;;;;\n2445;OCR BOW TIE;So;0;ON;;;;;N;;;;;\n2446;OCR BRANCH BANK IDENTIFICATION;So;0;ON;;;;;N;;;;;\n2447;OCR AMOUNT OF CHECK;So;0;ON;;;;;N;;;;;\n2448;OCR DASH;So;0;ON;;;;;N;;;;;\n2449;OCR CUSTOMER ACCOUNT NUMBER;So;0;ON;;;;;N;;;;;\n244A;OCR DOUBLE BACKSLASH;So;0;ON;;;;;N;;;;;\n2460;CIRCLED DIGIT ONE;No;0;ON;<circle> 0031;;1;1;N;;;;;\n2461;CIRCLED DIGIT TWO;No;0;ON;<circle> 0032;;2;2;N;;;;;\n2462;CIRCLED DIGIT THREE;No;0;ON;<circle> 0033;;3;3;N;;;;;\n2463;CIRCLED DIGIT FOUR;No;0;ON;<circle> 0034;;4;4;N;;;;;\n2464;CIRCLED DIGIT FIVE;No;0;ON;<circle> 0035;;5;5;N;;;;;\n2465;CIRCLED DIGIT SIX;No;0;ON;<circle> 0036;;6;6;N;;;;;\n2466;CIRCLED DIGIT SEVEN;No;0;ON;<circle> 0037;;7;7;N;;;;;\n2467;CIRCLED DIGIT EIGHT;No;0;ON;<circle> 0038;;8;8;N;;;;;\n2468;CIRCLED DIGIT NINE;No;0;ON;<circle> 0039;;9;9;N;;;;;\n2469;CIRCLED NUMBER TEN;No;0;ON;<circle> 0031 0030;;;10;N;;;;;\n246A;CIRCLED NUMBER ELEVEN;No;0;ON;<circle> 0031 0031;;;11;N;;;;;\n246B;CIRCLED NUMBER TWELVE;No;0;ON;<circle> 0031 0032;;;12;N;;;;;\n246C;CIRCLED NUMBER THIRTEEN;No;0;ON;<circle> 0031 0033;;;13;N;;;;;\n246D;CIRCLED NUMBER FOURTEEN;No;0;ON;<circle> 0031 0034;;;14;N;;;;;\n246E;CIRCLED NUMBER FIFTEEN;No;0;ON;<circle> 0031 0035;;;15;N;;;;;\n246F;CIRCLED NUMBER SIXTEEN;No;0;ON;<circle> 0031 0036;;;16;N;;;;;\n2470;CIRCLED NUMBER SEVENTEEN;No;0;ON;<circle> 0031 0037;;;17;N;;;;;\n2471;CIRCLED NUMBER EIGHTEEN;No;0;ON;<circle> 0031 0038;;;18;N;;;;;\n2472;CIRCLED NUMBER NINETEEN;No;0;ON;<circle> 0031 0039;;;19;N;;;;;\n2473;CIRCLED NUMBER TWENTY;No;0;ON;<circle> 0032 0030;;;20;N;;;;;\n2474;PARENTHESIZED DIGIT ONE;No;0;ON;<compat> 0028 0031 0029;;1;1;N;;;;;\n2475;PARENTHESIZED DIGIT TWO;No;0;ON;<compat> 0028 0032 0029;;2;2;N;;;;;\n2476;PARENTHESIZED DIGIT THREE;No;0;ON;<compat> 0028 0033 0029;;3;3;N;;;;;\n2477;PARENTHESIZED DIGIT FOUR;No;0;ON;<compat> 0028 0034 0029;;4;4;N;;;;;\n2478;PARENTHESIZED DIGIT FIVE;No;0;ON;<compat> 0028 0035 0029;;5;5;N;;;;;\n2479;PARENTHESIZED DIGIT SIX;No;0;ON;<compat> 0028 0036 0029;;6;6;N;;;;;\n247A;PARENTHESIZED DIGIT SEVEN;No;0;ON;<compat> 0028 0037 0029;;7;7;N;;;;;\n247B;PARENTHESIZED DIGIT EIGHT;No;0;ON;<compat> 0028 0038 0029;;8;8;N;;;;;\n247C;PARENTHESIZED DIGIT NINE;No;0;ON;<compat> 0028 0039 0029;;9;9;N;;;;;\n247D;PARENTHESIZED NUMBER TEN;No;0;ON;<compat> 0028 0031 0030 0029;;;10;N;;;;;\n247E;PARENTHESIZED NUMBER ELEVEN;No;0;ON;<compat> 0028 0031 0031 0029;;;11;N;;;;;\n247F;PARENTHESIZED NUMBER TWELVE;No;0;ON;<compat> 0028 0031 0032 0029;;;12;N;;;;;\n2480;PARENTHESIZED NUMBER THIRTEEN;No;0;ON;<compat> 0028 0031 0033 0029;;;13;N;;;;;\n2481;PARENTHESIZED NUMBER FOURTEEN;No;0;ON;<compat> 0028 0031 0034 0029;;;14;N;;;;;\n2482;PARENTHESIZED NUMBER FIFTEEN;No;0;ON;<compat> 0028 0031 0035 0029;;;15;N;;;;;\n2483;PARENTHESIZED NUMBER SIXTEEN;No;0;ON;<compat> 0028 0031 0036 0029;;;16;N;;;;;\n2484;PARENTHESIZED NUMBER SEVENTEEN;No;0;ON;<compat> 0028 0031 0037 0029;;;17;N;;;;;\n2485;PARENTHESIZED NUMBER EIGHTEEN;No;0;ON;<compat> 0028 0031 0038 0029;;;18;N;;;;;\n2486;PARENTHESIZED NUMBER NINETEEN;No;0;ON;<compat> 0028 0031 0039 0029;;;19;N;;;;;\n2487;PARENTHESIZED NUMBER TWENTY;No;0;ON;<compat> 0028 0032 0030 0029;;;20;N;;;;;\n2488;DIGIT ONE FULL STOP;No;0;EN;<compat> 0031 002E;;1;1;N;DIGIT ONE PERIOD;;;;\n2489;DIGIT TWO FULL STOP;No;0;EN;<compat> 0032 002E;;2;2;N;DIGIT TWO PERIOD;;;;\n248A;DIGIT THREE FULL STOP;No;0;EN;<compat> 0033 002E;;3;3;N;DIGIT THREE PERIOD;;;;\n248B;DIGIT FOUR FULL STOP;No;0;EN;<compat> 0034 002E;;4;4;N;DIGIT FOUR PERIOD;;;;\n248C;DIGIT FIVE FULL STOP;No;0;EN;<compat> 0035 002E;;5;5;N;DIGIT FIVE PERIOD;;;;\n248D;DIGIT SIX FULL STOP;No;0;EN;<compat> 0036 002E;;6;6;N;DIGIT SIX PERIOD;;;;\n248E;DIGIT SEVEN FULL STOP;No;0;EN;<compat> 0037 002E;;7;7;N;DIGIT SEVEN PERIOD;;;;\n248F;DIGIT EIGHT FULL STOP;No;0;EN;<compat> 0038 002E;;8;8;N;DIGIT EIGHT PERIOD;;;;\n2490;DIGIT NINE FULL STOP;No;0;EN;<compat> 0039 002E;;9;9;N;DIGIT NINE PERIOD;;;;\n2491;NUMBER TEN FULL STOP;No;0;EN;<compat> 0031 0030 002E;;;10;N;NUMBER TEN PERIOD;;;;\n2492;NUMBER ELEVEN FULL STOP;No;0;EN;<compat> 0031 0031 002E;;;11;N;NUMBER ELEVEN PERIOD;;;;\n2493;NUMBER TWELVE FULL STOP;No;0;EN;<compat> 0031 0032 002E;;;12;N;NUMBER TWELVE PERIOD;;;;\n2494;NUMBER THIRTEEN FULL STOP;No;0;EN;<compat> 0031 0033 002E;;;13;N;NUMBER THIRTEEN PERIOD;;;;\n2495;NUMBER FOURTEEN FULL STOP;No;0;EN;<compat> 0031 0034 002E;;;14;N;NUMBER FOURTEEN PERIOD;;;;\n2496;NUMBER FIFTEEN FULL STOP;No;0;EN;<compat> 0031 0035 002E;;;15;N;NUMBER FIFTEEN PERIOD;;;;\n2497;NUMBER SIXTEEN FULL STOP;No;0;EN;<compat> 0031 0036 002E;;;16;N;NUMBER SIXTEEN PERIOD;;;;\n2498;NUMBER SEVENTEEN FULL STOP;No;0;EN;<compat> 0031 0037 002E;;;17;N;NUMBER SEVENTEEN PERIOD;;;;\n2499;NUMBER EIGHTEEN FULL STOP;No;0;EN;<compat> 0031 0038 002E;;;18;N;NUMBER EIGHTEEN PERIOD;;;;\n249A;NUMBER NINETEEN FULL STOP;No;0;EN;<compat> 0031 0039 002E;;;19;N;NUMBER NINETEEN PERIOD;;;;\n249B;NUMBER TWENTY FULL STOP;No;0;EN;<compat> 0032 0030 002E;;;20;N;NUMBER TWENTY PERIOD;;;;\n249C;PARENTHESIZED LATIN SMALL LETTER A;So;0;L;<compat> 0028 0061 0029;;;;N;;;;;\n249D;PARENTHESIZED LATIN SMALL LETTER B;So;0;L;<compat> 0028 0062 0029;;;;N;;;;;\n249E;PARENTHESIZED LATIN SMALL LETTER C;So;0;L;<compat> 0028 0063 0029;;;;N;;;;;\n249F;PARENTHESIZED LATIN SMALL LETTER D;So;0;L;<compat> 0028 0064 0029;;;;N;;;;;\n24A0;PARENTHESIZED LATIN SMALL LETTER E;So;0;L;<compat> 0028 0065 0029;;;;N;;;;;\n24A1;PARENTHESIZED LATIN SMALL LETTER F;So;0;L;<compat> 0028 0066 0029;;;;N;;;;;\n24A2;PARENTHESIZED LATIN SMALL LETTER G;So;0;L;<compat> 0028 0067 0029;;;;N;;;;;\n24A3;PARENTHESIZED LATIN SMALL LETTER H;So;0;L;<compat> 0028 0068 0029;;;;N;;;;;\n24A4;PARENTHESIZED LATIN SMALL LETTER I;So;0;L;<compat> 0028 0069 0029;;;;N;;;;;\n24A5;PARENTHESIZED LATIN SMALL LETTER J;So;0;L;<compat> 0028 006A 0029;;;;N;;;;;\n24A6;PARENTHESIZED LATIN SMALL LETTER K;So;0;L;<compat> 0028 006B 0029;;;;N;;;;;\n24A7;PARENTHESIZED LATIN SMALL LETTER L;So;0;L;<compat> 0028 006C 0029;;;;N;;;;;\n24A8;PARENTHESIZED LATIN SMALL LETTER M;So;0;L;<compat> 0028 006D 0029;;;;N;;;;;\n24A9;PARENTHESIZED LATIN SMALL LETTER N;So;0;L;<compat> 0028 006E 0029;;;;N;;;;;\n24AA;PARENTHESIZED LATIN SMALL LETTER O;So;0;L;<compat> 0028 006F 0029;;;;N;;;;;\n24AB;PARENTHESIZED LATIN SMALL LETTER P;So;0;L;<compat> 0028 0070 0029;;;;N;;;;;\n24AC;PARENTHESIZED LATIN SMALL LETTER Q;So;0;L;<compat> 0028 0071 0029;;;;N;;;;;\n24AD;PARENTHESIZED LATIN SMALL LETTER R;So;0;L;<compat> 0028 0072 0029;;;;N;;;;;\n24AE;PARENTHESIZED LATIN SMALL LETTER S;So;0;L;<compat> 0028 0073 0029;;;;N;;;;;\n24AF;PARENTHESIZED LATIN SMALL LETTER T;So;0;L;<compat> 0028 0074 0029;;;;N;;;;;\n24B0;PARENTHESIZED LATIN SMALL LETTER U;So;0;L;<compat> 0028 0075 0029;;;;N;;;;;\n24B1;PARENTHESIZED LATIN SMALL LETTER V;So;0;L;<compat> 0028 0076 0029;;;;N;;;;;\n24B2;PARENTHESIZED LATIN SMALL LETTER W;So;0;L;<compat> 0028 0077 0029;;;;N;;;;;\n24B3;PARENTHESIZED LATIN SMALL LETTER X;So;0;L;<compat> 0028 0078 0029;;;;N;;;;;\n24B4;PARENTHESIZED LATIN SMALL LETTER Y;So;0;L;<compat> 0028 0079 0029;;;;N;;;;;\n24B5;PARENTHESIZED LATIN SMALL LETTER Z;So;0;L;<compat> 0028 007A 0029;;;;N;;;;;\n24B6;CIRCLED LATIN CAPITAL LETTER A;So;0;L;<circle> 0041;;;;N;;;;24D0;\n24B7;CIRCLED LATIN CAPITAL LETTER B;So;0;L;<circle> 0042;;;;N;;;;24D1;\n24B8;CIRCLED LATIN CAPITAL LETTER C;So;0;L;<circle> 0043;;;;N;;;;24D2;\n24B9;CIRCLED LATIN CAPITAL LETTER D;So;0;L;<circle> 0044;;;;N;;;;24D3;\n24BA;CIRCLED LATIN CAPITAL LETTER E;So;0;L;<circle> 0045;;;;N;;;;24D4;\n24BB;CIRCLED LATIN CAPITAL LETTER F;So;0;L;<circle> 0046;;;;N;;;;24D5;\n24BC;CIRCLED LATIN CAPITAL LETTER G;So;0;L;<circle> 0047;;;;N;;;;24D6;\n24BD;CIRCLED LATIN CAPITAL LETTER H;So;0;L;<circle> 0048;;;;N;;;;24D7;\n24BE;CIRCLED LATIN CAPITAL LETTER I;So;0;L;<circle> 0049;;;;N;;;;24D8;\n24BF;CIRCLED LATIN CAPITAL LETTER J;So;0;L;<circle> 004A;;;;N;;;;24D9;\n24C0;CIRCLED LATIN CAPITAL LETTER K;So;0;L;<circle> 004B;;;;N;;;;24DA;\n24C1;CIRCLED LATIN CAPITAL LETTER L;So;0;L;<circle> 004C;;;;N;;;;24DB;\n24C2;CIRCLED LATIN CAPITAL LETTER M;So;0;L;<circle> 004D;;;;N;;;;24DC;\n24C3;CIRCLED LATIN CAPITAL LETTER N;So;0;L;<circle> 004E;;;;N;;;;24DD;\n24C4;CIRCLED LATIN CAPITAL LETTER O;So;0;L;<circle> 004F;;;;N;;;;24DE;\n24C5;CIRCLED LATIN CAPITAL LETTER P;So;0;L;<circle> 0050;;;;N;;;;24DF;\n24C6;CIRCLED LATIN CAPITAL LETTER Q;So;0;L;<circle> 0051;;;;N;;;;24E0;\n24C7;CIRCLED LATIN CAPITAL LETTER R;So;0;L;<circle> 0052;;;;N;;;;24E1;\n24C8;CIRCLED LATIN CAPITAL LETTER S;So;0;L;<circle> 0053;;;;N;;;;24E2;\n24C9;CIRCLED LATIN CAPITAL LETTER T;So;0;L;<circle> 0054;;;;N;;;;24E3;\n24CA;CIRCLED LATIN CAPITAL LETTER U;So;0;L;<circle> 0055;;;;N;;;;24E4;\n24CB;CIRCLED LATIN CAPITAL LETTER V;So;0;L;<circle> 0056;;;;N;;;;24E5;\n24CC;CIRCLED LATIN CAPITAL LETTER W;So;0;L;<circle> 0057;;;;N;;;;24E6;\n24CD;CIRCLED LATIN CAPITAL LETTER X;So;0;L;<circle> 0058;;;;N;;;;24E7;\n24CE;CIRCLED LATIN CAPITAL LETTER Y;So;0;L;<circle> 0059;;;;N;;;;24E8;\n24CF;CIRCLED LATIN CAPITAL LETTER Z;So;0;L;<circle> 005A;;;;N;;;;24E9;\n24D0;CIRCLED LATIN SMALL LETTER A;So;0;L;<circle> 0061;;;;N;;;24B6;;24B6\n24D1;CIRCLED LATIN SMALL LETTER B;So;0;L;<circle> 0062;;;;N;;;24B7;;24B7\n24D2;CIRCLED LATIN SMALL LETTER C;So;0;L;<circle> 0063;;;;N;;;24B8;;24B8\n24D3;CIRCLED LATIN SMALL LETTER D;So;0;L;<circle> 0064;;;;N;;;24B9;;24B9\n24D4;CIRCLED LATIN SMALL LETTER E;So;0;L;<circle> 0065;;;;N;;;24BA;;24BA\n24D5;CIRCLED LATIN SMALL LETTER F;So;0;L;<circle> 0066;;;;N;;;24BB;;24BB\n24D6;CIRCLED LATIN SMALL LETTER G;So;0;L;<circle> 0067;;;;N;;;24BC;;24BC\n24D7;CIRCLED LATIN SMALL LETTER H;So;0;L;<circle> 0068;;;;N;;;24BD;;24BD\n24D8;CIRCLED LATIN SMALL LETTER I;So;0;L;<circle> 0069;;;;N;;;24BE;;24BE\n24D9;CIRCLED LATIN SMALL LETTER J;So;0;L;<circle> 006A;;;;N;;;24BF;;24BF\n24DA;CIRCLED LATIN SMALL LETTER K;So;0;L;<circle> 006B;;;;N;;;24C0;;24C0\n24DB;CIRCLED LATIN SMALL LETTER L;So;0;L;<circle> 006C;;;;N;;;24C1;;24C1\n24DC;CIRCLED LATIN SMALL LETTER M;So;0;L;<circle> 006D;;;;N;;;24C2;;24C2\n24DD;CIRCLED LATIN SMALL LETTER N;So;0;L;<circle> 006E;;;;N;;;24C3;;24C3\n24DE;CIRCLED LATIN SMALL LETTER O;So;0;L;<circle> 006F;;;;N;;;24C4;;24C4\n24DF;CIRCLED LATIN SMALL LETTER P;So;0;L;<circle> 0070;;;;N;;;24C5;;24C5\n24E0;CIRCLED LATIN SMALL LETTER Q;So;0;L;<circle> 0071;;;;N;;;24C6;;24C6\n24E1;CIRCLED LATIN SMALL LETTER R;So;0;L;<circle> 0072;;;;N;;;24C7;;24C7\n24E2;CIRCLED LATIN SMALL LETTER S;So;0;L;<circle> 0073;;;;N;;;24C8;;24C8\n24E3;CIRCLED LATIN SMALL LETTER T;So;0;L;<circle> 0074;;;;N;;;24C9;;24C9\n24E4;CIRCLED LATIN SMALL LETTER U;So;0;L;<circle> 0075;;;;N;;;24CA;;24CA\n24E5;CIRCLED LATIN SMALL LETTER V;So;0;L;<circle> 0076;;;;N;;;24CB;;24CB\n24E6;CIRCLED LATIN SMALL LETTER W;So;0;L;<circle> 0077;;;;N;;;24CC;;24CC\n24E7;CIRCLED LATIN SMALL LETTER X;So;0;L;<circle> 0078;;;;N;;;24CD;;24CD\n24E8;CIRCLED LATIN SMALL LETTER Y;So;0;L;<circle> 0079;;;;N;;;24CE;;24CE\n24E9;CIRCLED LATIN SMALL LETTER Z;So;0;L;<circle> 007A;;;;N;;;24CF;;24CF\n24EA;CIRCLED DIGIT ZERO;No;0;ON;<circle> 0030;;0;0;N;;;;;\n24EB;NEGATIVE CIRCLED NUMBER ELEVEN;No;0;ON;;;;11;N;;;;;\n24EC;NEGATIVE CIRCLED NUMBER TWELVE;No;0;ON;;;;12;N;;;;;\n24ED;NEGATIVE CIRCLED NUMBER THIRTEEN;No;0;ON;;;;13;N;;;;;\n24EE;NEGATIVE CIRCLED NUMBER FOURTEEN;No;0;ON;;;;14;N;;;;;\n24EF;NEGATIVE CIRCLED NUMBER FIFTEEN;No;0;ON;;;;15;N;;;;;\n24F0;NEGATIVE CIRCLED NUMBER SIXTEEN;No;0;ON;;;;16;N;;;;;\n24F1;NEGATIVE CIRCLED NUMBER SEVENTEEN;No;0;ON;;;;17;N;;;;;\n24F2;NEGATIVE CIRCLED NUMBER EIGHTEEN;No;0;ON;;;;18;N;;;;;\n24F3;NEGATIVE CIRCLED NUMBER NINETEEN;No;0;ON;;;;19;N;;;;;\n24F4;NEGATIVE CIRCLED NUMBER TWENTY;No;0;ON;;;;20;N;;;;;\n24F5;DOUBLE CIRCLED DIGIT ONE;No;0;ON;;;1;1;N;;;;;\n24F6;DOUBLE CIRCLED DIGIT TWO;No;0;ON;;;2;2;N;;;;;\n24F7;DOUBLE CIRCLED DIGIT THREE;No;0;ON;;;3;3;N;;;;;\n24F8;DOUBLE CIRCLED DIGIT FOUR;No;0;ON;;;4;4;N;;;;;\n24F9;DOUBLE CIRCLED DIGIT FIVE;No;0;ON;;;5;5;N;;;;;\n24FA;DOUBLE CIRCLED DIGIT SIX;No;0;ON;;;6;6;N;;;;;\n24FB;DOUBLE CIRCLED DIGIT SEVEN;No;0;ON;;;7;7;N;;;;;\n24FC;DOUBLE CIRCLED DIGIT EIGHT;No;0;ON;;;8;8;N;;;;;\n24FD;DOUBLE CIRCLED DIGIT NINE;No;0;ON;;;9;9;N;;;;;\n24FE;DOUBLE CIRCLED NUMBER TEN;No;0;ON;;;;10;N;;;;;\n24FF;NEGATIVE CIRCLED DIGIT ZERO;No;0;ON;;;0;0;N;;;;;\n2500;BOX DRAWINGS LIGHT HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT HORIZONTAL;;;;\n2501;BOX DRAWINGS HEAVY HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY HORIZONTAL;;;;\n2502;BOX DRAWINGS LIGHT VERTICAL;So;0;ON;;;;;N;FORMS LIGHT VERTICAL;;;;\n2503;BOX DRAWINGS HEAVY VERTICAL;So;0;ON;;;;;N;FORMS HEAVY VERTICAL;;;;\n2504;BOX DRAWINGS LIGHT TRIPLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT TRIPLE DASH HORIZONTAL;;;;\n2505;BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY TRIPLE DASH HORIZONTAL;;;;\n2506;BOX DRAWINGS LIGHT TRIPLE DASH VERTICAL;So;0;ON;;;;;N;FORMS LIGHT TRIPLE DASH VERTICAL;;;;\n2507;BOX DRAWINGS HEAVY TRIPLE DASH VERTICAL;So;0;ON;;;;;N;FORMS HEAVY TRIPLE DASH VERTICAL;;;;\n2508;BOX DRAWINGS LIGHT QUADRUPLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT QUADRUPLE DASH HORIZONTAL;;;;\n2509;BOX DRAWINGS HEAVY QUADRUPLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY QUADRUPLE DASH HORIZONTAL;;;;\n250A;BOX DRAWINGS LIGHT QUADRUPLE DASH VERTICAL;So;0;ON;;;;;N;FORMS LIGHT QUADRUPLE DASH VERTICAL;;;;\n250B;BOX DRAWINGS HEAVY QUADRUPLE DASH VERTICAL;So;0;ON;;;;;N;FORMS HEAVY QUADRUPLE DASH VERTICAL;;;;\n250C;BOX DRAWINGS LIGHT DOWN AND RIGHT;So;0;ON;;;;;N;FORMS LIGHT DOWN AND RIGHT;;;;\n250D;BOX DRAWINGS DOWN LIGHT AND RIGHT HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND RIGHT HEAVY;;;;\n250E;BOX DRAWINGS DOWN HEAVY AND RIGHT LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND RIGHT LIGHT;;;;\n250F;BOX DRAWINGS HEAVY DOWN AND RIGHT;So;0;ON;;;;;N;FORMS HEAVY DOWN AND RIGHT;;;;\n2510;BOX DRAWINGS LIGHT DOWN AND LEFT;So;0;ON;;;;;N;FORMS LIGHT DOWN AND LEFT;;;;\n2511;BOX DRAWINGS DOWN LIGHT AND LEFT HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND LEFT HEAVY;;;;\n2512;BOX DRAWINGS DOWN HEAVY AND LEFT LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND LEFT LIGHT;;;;\n2513;BOX DRAWINGS HEAVY DOWN AND LEFT;So;0;ON;;;;;N;FORMS HEAVY DOWN AND LEFT;;;;\n2514;BOX DRAWINGS LIGHT UP AND RIGHT;So;0;ON;;;;;N;FORMS LIGHT UP AND RIGHT;;;;\n2515;BOX DRAWINGS UP LIGHT AND RIGHT HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND RIGHT HEAVY;;;;\n2516;BOX DRAWINGS UP HEAVY AND RIGHT LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND RIGHT LIGHT;;;;\n2517;BOX DRAWINGS HEAVY UP AND RIGHT;So;0;ON;;;;;N;FORMS HEAVY UP AND RIGHT;;;;\n2518;BOX DRAWINGS LIGHT UP AND LEFT;So;0;ON;;;;;N;FORMS LIGHT UP AND LEFT;;;;\n2519;BOX DRAWINGS UP LIGHT AND LEFT HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND LEFT HEAVY;;;;\n251A;BOX DRAWINGS UP HEAVY AND LEFT LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND LEFT LIGHT;;;;\n251B;BOX DRAWINGS HEAVY UP AND LEFT;So;0;ON;;;;;N;FORMS HEAVY UP AND LEFT;;;;\n251C;BOX DRAWINGS LIGHT VERTICAL AND RIGHT;So;0;ON;;;;;N;FORMS LIGHT VERTICAL AND RIGHT;;;;\n251D;BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY;So;0;ON;;;;;N;FORMS VERTICAL LIGHT AND RIGHT HEAVY;;;;\n251E;BOX DRAWINGS UP HEAVY AND RIGHT DOWN LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND RIGHT DOWN LIGHT;;;;\n251F;BOX DRAWINGS DOWN HEAVY AND RIGHT UP LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND RIGHT UP LIGHT;;;;\n2520;BOX DRAWINGS VERTICAL HEAVY AND RIGHT LIGHT;So;0;ON;;;;;N;FORMS VERTICAL HEAVY AND RIGHT LIGHT;;;;\n2521;BOX DRAWINGS DOWN LIGHT AND RIGHT UP HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND RIGHT UP HEAVY;;;;\n2522;BOX DRAWINGS UP LIGHT AND RIGHT DOWN HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND RIGHT DOWN HEAVY;;;;\n2523;BOX DRAWINGS HEAVY VERTICAL AND RIGHT;So;0;ON;;;;;N;FORMS HEAVY VERTICAL AND RIGHT;;;;\n2524;BOX DRAWINGS LIGHT VERTICAL AND LEFT;So;0;ON;;;;;N;FORMS LIGHT VERTICAL AND LEFT;;;;\n2525;BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY;So;0;ON;;;;;N;FORMS VERTICAL LIGHT AND LEFT HEAVY;;;;\n2526;BOX DRAWINGS UP HEAVY AND LEFT DOWN LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND LEFT DOWN LIGHT;;;;\n2527;BOX DRAWINGS DOWN HEAVY AND LEFT UP LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND LEFT UP LIGHT;;;;\n2528;BOX DRAWINGS VERTICAL HEAVY AND LEFT LIGHT;So;0;ON;;;;;N;FORMS VERTICAL HEAVY AND LEFT LIGHT;;;;\n2529;BOX DRAWINGS DOWN LIGHT AND LEFT UP HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND LEFT UP HEAVY;;;;\n252A;BOX DRAWINGS UP LIGHT AND LEFT DOWN HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND LEFT DOWN HEAVY;;;;\n252B;BOX DRAWINGS HEAVY VERTICAL AND LEFT;So;0;ON;;;;;N;FORMS HEAVY VERTICAL AND LEFT;;;;\n252C;BOX DRAWINGS LIGHT DOWN AND HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT DOWN AND HORIZONTAL;;;;\n252D;BOX DRAWINGS LEFT HEAVY AND RIGHT DOWN LIGHT;So;0;ON;;;;;N;FORMS LEFT HEAVY AND RIGHT DOWN LIGHT;;;;\n252E;BOX DRAWINGS RIGHT HEAVY AND LEFT DOWN LIGHT;So;0;ON;;;;;N;FORMS RIGHT HEAVY AND LEFT DOWN LIGHT;;;;\n252F;BOX DRAWINGS DOWN LIGHT AND HORIZONTAL HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND HORIZONTAL HEAVY;;;;\n2530;BOX DRAWINGS DOWN HEAVY AND HORIZONTAL LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND HORIZONTAL LIGHT;;;;\n2531;BOX DRAWINGS RIGHT LIGHT AND LEFT DOWN HEAVY;So;0;ON;;;;;N;FORMS RIGHT LIGHT AND LEFT DOWN HEAVY;;;;\n2532;BOX DRAWINGS LEFT LIGHT AND RIGHT DOWN HEAVY;So;0;ON;;;;;N;FORMS LEFT LIGHT AND RIGHT DOWN HEAVY;;;;\n2533;BOX DRAWINGS HEAVY DOWN AND HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY DOWN AND HORIZONTAL;;;;\n2534;BOX DRAWINGS LIGHT UP AND HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT UP AND HORIZONTAL;;;;\n2535;BOX DRAWINGS LEFT HEAVY AND RIGHT UP LIGHT;So;0;ON;;;;;N;FORMS LEFT HEAVY AND RIGHT UP LIGHT;;;;\n2536;BOX DRAWINGS RIGHT HEAVY AND LEFT UP LIGHT;So;0;ON;;;;;N;FORMS RIGHT HEAVY AND LEFT UP LIGHT;;;;\n2537;BOX DRAWINGS UP LIGHT AND HORIZONTAL HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND HORIZONTAL HEAVY;;;;\n2538;BOX DRAWINGS UP HEAVY AND HORIZONTAL LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND HORIZONTAL LIGHT;;;;\n2539;BOX DRAWINGS RIGHT LIGHT AND LEFT UP HEAVY;So;0;ON;;;;;N;FORMS RIGHT LIGHT AND LEFT UP HEAVY;;;;\n253A;BOX DRAWINGS LEFT LIGHT AND RIGHT UP HEAVY;So;0;ON;;;;;N;FORMS LEFT LIGHT AND RIGHT UP HEAVY;;;;\n253B;BOX DRAWINGS HEAVY UP AND HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY UP AND HORIZONTAL;;;;\n253C;BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT VERTICAL AND HORIZONTAL;;;;\n253D;BOX DRAWINGS LEFT HEAVY AND RIGHT VERTICAL LIGHT;So;0;ON;;;;;N;FORMS LEFT HEAVY AND RIGHT VERTICAL LIGHT;;;;\n253E;BOX DRAWINGS RIGHT HEAVY AND LEFT VERTICAL LIGHT;So;0;ON;;;;;N;FORMS RIGHT HEAVY AND LEFT VERTICAL LIGHT;;;;\n253F;BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY;So;0;ON;;;;;N;FORMS VERTICAL LIGHT AND HORIZONTAL HEAVY;;;;\n2540;BOX DRAWINGS UP HEAVY AND DOWN HORIZONTAL LIGHT;So;0;ON;;;;;N;FORMS UP HEAVY AND DOWN HORIZONTAL LIGHT;;;;\n2541;BOX DRAWINGS DOWN HEAVY AND UP HORIZONTAL LIGHT;So;0;ON;;;;;N;FORMS DOWN HEAVY AND UP HORIZONTAL LIGHT;;;;\n2542;BOX DRAWINGS VERTICAL HEAVY AND HORIZONTAL LIGHT;So;0;ON;;;;;N;FORMS VERTICAL HEAVY AND HORIZONTAL LIGHT;;;;\n2543;BOX DRAWINGS LEFT UP HEAVY AND RIGHT DOWN LIGHT;So;0;ON;;;;;N;FORMS LEFT UP HEAVY AND RIGHT DOWN LIGHT;;;;\n2544;BOX DRAWINGS RIGHT UP HEAVY AND LEFT DOWN LIGHT;So;0;ON;;;;;N;FORMS RIGHT UP HEAVY AND LEFT DOWN LIGHT;;;;\n2545;BOX DRAWINGS LEFT DOWN HEAVY AND RIGHT UP LIGHT;So;0;ON;;;;;N;FORMS LEFT DOWN HEAVY AND RIGHT UP LIGHT;;;;\n2546;BOX DRAWINGS RIGHT DOWN HEAVY AND LEFT UP LIGHT;So;0;ON;;;;;N;FORMS RIGHT DOWN HEAVY AND LEFT UP LIGHT;;;;\n2547;BOX DRAWINGS DOWN LIGHT AND UP HORIZONTAL HEAVY;So;0;ON;;;;;N;FORMS DOWN LIGHT AND UP HORIZONTAL HEAVY;;;;\n2548;BOX DRAWINGS UP LIGHT AND DOWN HORIZONTAL HEAVY;So;0;ON;;;;;N;FORMS UP LIGHT AND DOWN HORIZONTAL HEAVY;;;;\n2549;BOX DRAWINGS RIGHT LIGHT AND LEFT VERTICAL HEAVY;So;0;ON;;;;;N;FORMS RIGHT LIGHT AND LEFT VERTICAL HEAVY;;;;\n254A;BOX DRAWINGS LEFT LIGHT AND RIGHT VERTICAL HEAVY;So;0;ON;;;;;N;FORMS LEFT LIGHT AND RIGHT VERTICAL HEAVY;;;;\n254B;BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY VERTICAL AND HORIZONTAL;;;;\n254C;BOX DRAWINGS LIGHT DOUBLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS LIGHT DOUBLE DASH HORIZONTAL;;;;\n254D;BOX DRAWINGS HEAVY DOUBLE DASH HORIZONTAL;So;0;ON;;;;;N;FORMS HEAVY DOUBLE DASH HORIZONTAL;;;;\n254E;BOX DRAWINGS LIGHT DOUBLE DASH VERTICAL;So;0;ON;;;;;N;FORMS LIGHT DOUBLE DASH VERTICAL;;;;\n254F;BOX DRAWINGS HEAVY DOUBLE DASH VERTICAL;So;0;ON;;;;;N;FORMS HEAVY DOUBLE DASH VERTICAL;;;;\n2550;BOX DRAWINGS DOUBLE HORIZONTAL;So;0;ON;;;;;N;FORMS DOUBLE HORIZONTAL;;;;\n2551;BOX DRAWINGS DOUBLE VERTICAL;So;0;ON;;;;;N;FORMS DOUBLE VERTICAL;;;;\n2552;BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE;So;0;ON;;;;;N;FORMS DOWN SINGLE AND RIGHT DOUBLE;;;;\n2553;BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE;So;0;ON;;;;;N;FORMS DOWN DOUBLE AND RIGHT SINGLE;;;;\n2554;BOX DRAWINGS DOUBLE DOWN AND RIGHT;So;0;ON;;;;;N;FORMS DOUBLE DOWN AND RIGHT;;;;\n2555;BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE;So;0;ON;;;;;N;FORMS DOWN SINGLE AND LEFT DOUBLE;;;;\n2556;BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE;So;0;ON;;;;;N;FORMS DOWN DOUBLE AND LEFT SINGLE;;;;\n2557;BOX DRAWINGS DOUBLE DOWN AND LEFT;So;0;ON;;;;;N;FORMS DOUBLE DOWN AND LEFT;;;;\n2558;BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE;So;0;ON;;;;;N;FORMS UP SINGLE AND RIGHT DOUBLE;;;;\n2559;BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE;So;0;ON;;;;;N;FORMS UP DOUBLE AND RIGHT SINGLE;;;;\n255A;BOX DRAWINGS DOUBLE UP AND RIGHT;So;0;ON;;;;;N;FORMS DOUBLE UP AND RIGHT;;;;\n255B;BOX DRAWINGS UP SINGLE AND LEFT DOUBLE;So;0;ON;;;;;N;FORMS UP SINGLE AND LEFT DOUBLE;;;;\n255C;BOX DRAWINGS UP DOUBLE AND LEFT SINGLE;So;0;ON;;;;;N;FORMS UP DOUBLE AND LEFT SINGLE;;;;\n255D;BOX DRAWINGS DOUBLE UP AND LEFT;So;0;ON;;;;;N;FORMS DOUBLE UP AND LEFT;;;;\n255E;BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE;So;0;ON;;;;;N;FORMS VERTICAL SINGLE AND RIGHT DOUBLE;;;;\n255F;BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE;So;0;ON;;;;;N;FORMS VERTICAL DOUBLE AND RIGHT SINGLE;;;;\n2560;BOX DRAWINGS DOUBLE VERTICAL AND RIGHT;So;0;ON;;;;;N;FORMS DOUBLE VERTICAL AND RIGHT;;;;\n2561;BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE;So;0;ON;;;;;N;FORMS VERTICAL SINGLE AND LEFT DOUBLE;;;;\n2562;BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE;So;0;ON;;;;;N;FORMS VERTICAL DOUBLE AND LEFT SINGLE;;;;\n2563;BOX DRAWINGS DOUBLE VERTICAL AND LEFT;So;0;ON;;;;;N;FORMS DOUBLE VERTICAL AND LEFT;;;;\n2564;BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE;So;0;ON;;;;;N;FORMS DOWN SINGLE AND HORIZONTAL DOUBLE;;;;\n2565;BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE;So;0;ON;;;;;N;FORMS DOWN DOUBLE AND HORIZONTAL SINGLE;;;;\n2566;BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL;So;0;ON;;;;;N;FORMS DOUBLE DOWN AND HORIZONTAL;;;;\n2567;BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE;So;0;ON;;;;;N;FORMS UP SINGLE AND HORIZONTAL DOUBLE;;;;\n2568;BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE;So;0;ON;;;;;N;FORMS UP DOUBLE AND HORIZONTAL SINGLE;;;;\n2569;BOX DRAWINGS DOUBLE UP AND HORIZONTAL;So;0;ON;;;;;N;FORMS DOUBLE UP AND HORIZONTAL;;;;\n256A;BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE;So;0;ON;;;;;N;FORMS VERTICAL SINGLE AND HORIZONTAL DOUBLE;;;;\n256B;BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE;So;0;ON;;;;;N;FORMS VERTICAL DOUBLE AND HORIZONTAL SINGLE;;;;\n256C;BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL;So;0;ON;;;;;N;FORMS DOUBLE VERTICAL AND HORIZONTAL;;;;\n256D;BOX DRAWINGS LIGHT ARC DOWN AND RIGHT;So;0;ON;;;;;N;FORMS LIGHT ARC DOWN AND RIGHT;;;;\n256E;BOX DRAWINGS LIGHT ARC DOWN AND LEFT;So;0;ON;;;;;N;FORMS LIGHT ARC DOWN AND LEFT;;;;\n256F;BOX DRAWINGS LIGHT ARC UP AND LEFT;So;0;ON;;;;;N;FORMS LIGHT ARC UP AND LEFT;;;;\n2570;BOX DRAWINGS LIGHT ARC UP AND RIGHT;So;0;ON;;;;;N;FORMS LIGHT ARC UP AND RIGHT;;;;\n2571;BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT;So;0;ON;;;;;N;FORMS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT;;;;\n2572;BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT;So;0;ON;;;;;N;FORMS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT;;;;\n2573;BOX DRAWINGS LIGHT DIAGONAL CROSS;So;0;ON;;;;;N;FORMS LIGHT DIAGONAL CROSS;;;;\n2574;BOX DRAWINGS LIGHT LEFT;So;0;ON;;;;;N;FORMS LIGHT LEFT;;;;\n2575;BOX DRAWINGS LIGHT UP;So;0;ON;;;;;N;FORMS LIGHT UP;;;;\n2576;BOX DRAWINGS LIGHT RIGHT;So;0;ON;;;;;N;FORMS LIGHT RIGHT;;;;\n2577;BOX DRAWINGS LIGHT DOWN;So;0;ON;;;;;N;FORMS LIGHT DOWN;;;;\n2578;BOX DRAWINGS HEAVY LEFT;So;0;ON;;;;;N;FORMS HEAVY LEFT;;;;\n2579;BOX DRAWINGS HEAVY UP;So;0;ON;;;;;N;FORMS HEAVY UP;;;;\n257A;BOX DRAWINGS HEAVY RIGHT;So;0;ON;;;;;N;FORMS HEAVY RIGHT;;;;\n257B;BOX DRAWINGS HEAVY DOWN;So;0;ON;;;;;N;FORMS HEAVY DOWN;;;;\n257C;BOX DRAWINGS LIGHT LEFT AND HEAVY RIGHT;So;0;ON;;;;;N;FORMS LIGHT LEFT AND HEAVY RIGHT;;;;\n257D;BOX DRAWINGS LIGHT UP AND HEAVY DOWN;So;0;ON;;;;;N;FORMS LIGHT UP AND HEAVY DOWN;;;;\n257E;BOX DRAWINGS HEAVY LEFT AND LIGHT RIGHT;So;0;ON;;;;;N;FORMS HEAVY LEFT AND LIGHT RIGHT;;;;\n257F;BOX DRAWINGS HEAVY UP AND LIGHT DOWN;So;0;ON;;;;;N;FORMS HEAVY UP AND LIGHT DOWN;;;;\n2580;UPPER HALF BLOCK;So;0;ON;;;;;N;;;;;\n2581;LOWER ONE EIGHTH BLOCK;So;0;ON;;;;;N;;;;;\n2582;LOWER ONE QUARTER BLOCK;So;0;ON;;;;;N;;;;;\n2583;LOWER THREE EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n2584;LOWER HALF BLOCK;So;0;ON;;;;;N;;;;;\n2585;LOWER FIVE EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n2586;LOWER THREE QUARTERS BLOCK;So;0;ON;;;;;N;LOWER THREE QUARTER BLOCK;;;;\n2587;LOWER SEVEN EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n2588;FULL BLOCK;So;0;ON;;;;;N;;;;;\n2589;LEFT SEVEN EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n258A;LEFT THREE QUARTERS BLOCK;So;0;ON;;;;;N;LEFT THREE QUARTER BLOCK;;;;\n258B;LEFT FIVE EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n258C;LEFT HALF BLOCK;So;0;ON;;;;;N;;;;;\n258D;LEFT THREE EIGHTHS BLOCK;So;0;ON;;;;;N;;;;;\n258E;LEFT ONE QUARTER BLOCK;So;0;ON;;;;;N;;;;;\n258F;LEFT ONE EIGHTH BLOCK;So;0;ON;;;;;N;;;;;\n2590;RIGHT HALF BLOCK;So;0;ON;;;;;N;;;;;\n2591;LIGHT SHADE;So;0;ON;;;;;N;;;;;\n2592;MEDIUM SHADE;So;0;ON;;;;;N;;;;;\n2593;DARK SHADE;So;0;ON;;;;;N;;;;;\n2594;UPPER ONE EIGHTH BLOCK;So;0;ON;;;;;N;;;;;\n2595;RIGHT ONE EIGHTH BLOCK;So;0;ON;;;;;N;;;;;\n2596;QUADRANT LOWER LEFT;So;0;ON;;;;;N;;;;;\n2597;QUADRANT LOWER RIGHT;So;0;ON;;;;;N;;;;;\n2598;QUADRANT UPPER LEFT;So;0;ON;;;;;N;;;;;\n2599;QUADRANT UPPER LEFT AND LOWER LEFT AND LOWER RIGHT;So;0;ON;;;;;N;;;;;\n259A;QUADRANT UPPER LEFT AND LOWER RIGHT;So;0;ON;;;;;N;;;;;\n259B;QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER LEFT;So;0;ON;;;;;N;;;;;\n259C;QUADRANT UPPER LEFT AND UPPER RIGHT AND LOWER RIGHT;So;0;ON;;;;;N;;;;;\n259D;QUADRANT UPPER RIGHT;So;0;ON;;;;;N;;;;;\n259E;QUADRANT UPPER RIGHT AND LOWER LEFT;So;0;ON;;;;;N;;;;;\n259F;QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT;So;0;ON;;;;;N;;;;;\n25A0;BLACK SQUARE;So;0;ON;;;;;N;;;;;\n25A1;WHITE SQUARE;So;0;ON;;;;;N;;;;;\n25A2;WHITE SQUARE WITH ROUNDED CORNERS;So;0;ON;;;;;N;;;;;\n25A3;WHITE SQUARE CONTAINING BLACK SMALL SQUARE;So;0;ON;;;;;N;;;;;\n25A4;SQUARE WITH HORIZONTAL FILL;So;0;ON;;;;;N;;;;;\n25A5;SQUARE WITH VERTICAL FILL;So;0;ON;;;;;N;;;;;\n25A6;SQUARE WITH ORTHOGONAL CROSSHATCH FILL;So;0;ON;;;;;N;;;;;\n25A7;SQUARE WITH UPPER LEFT TO LOWER RIGHT FILL;So;0;ON;;;;;N;;;;;\n25A8;SQUARE WITH UPPER RIGHT TO LOWER LEFT FILL;So;0;ON;;;;;N;;;;;\n25A9;SQUARE WITH DIAGONAL CROSSHATCH FILL;So;0;ON;;;;;N;;;;;\n25AA;BLACK SMALL SQUARE;So;0;ON;;;;;N;;;;;\n25AB;WHITE SMALL SQUARE;So;0;ON;;;;;N;;;;;\n25AC;BLACK RECTANGLE;So;0;ON;;;;;N;;;;;\n25AD;WHITE RECTANGLE;So;0;ON;;;;;N;;;;;\n25AE;BLACK VERTICAL RECTANGLE;So;0;ON;;;;;N;;;;;\n25AF;WHITE VERTICAL RECTANGLE;So;0;ON;;;;;N;;;;;\n25B0;BLACK PARALLELOGRAM;So;0;ON;;;;;N;;;;;\n25B1;WHITE PARALLELOGRAM;So;0;ON;;;;;N;;;;;\n25B2;BLACK UP-POINTING TRIANGLE;So;0;ON;;;;;N;BLACK UP POINTING TRIANGLE;;;;\n25B3;WHITE UP-POINTING TRIANGLE;So;0;ON;;;;;N;WHITE UP POINTING TRIANGLE;;;;\n25B4;BLACK UP-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;BLACK UP POINTING SMALL TRIANGLE;;;;\n25B5;WHITE UP-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;WHITE UP POINTING SMALL TRIANGLE;;;;\n25B6;BLACK RIGHT-POINTING TRIANGLE;So;0;ON;;;;;N;BLACK RIGHT POINTING TRIANGLE;;;;\n25B7;WHITE RIGHT-POINTING TRIANGLE;Sm;0;ON;;;;;N;WHITE RIGHT POINTING TRIANGLE;;;;\n25B8;BLACK RIGHT-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;BLACK RIGHT POINTING SMALL TRIANGLE;;;;\n25B9;WHITE RIGHT-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;WHITE RIGHT POINTING SMALL TRIANGLE;;;;\n25BA;BLACK RIGHT-POINTING POINTER;So;0;ON;;;;;N;BLACK RIGHT POINTING POINTER;;;;\n25BB;WHITE RIGHT-POINTING POINTER;So;0;ON;;;;;N;WHITE RIGHT POINTING POINTER;;;;\n25BC;BLACK DOWN-POINTING TRIANGLE;So;0;ON;;;;;N;BLACK DOWN POINTING TRIANGLE;;;;\n25BD;WHITE DOWN-POINTING TRIANGLE;So;0;ON;;;;;N;WHITE DOWN POINTING TRIANGLE;;;;\n25BE;BLACK DOWN-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;BLACK DOWN POINTING SMALL TRIANGLE;;;;\n25BF;WHITE DOWN-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;WHITE DOWN POINTING SMALL TRIANGLE;;;;\n25C0;BLACK LEFT-POINTING TRIANGLE;So;0;ON;;;;;N;BLACK LEFT POINTING TRIANGLE;;;;\n25C1;WHITE LEFT-POINTING TRIANGLE;Sm;0;ON;;;;;N;WHITE LEFT POINTING TRIANGLE;;;;\n25C2;BLACK LEFT-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;BLACK LEFT POINTING SMALL TRIANGLE;;;;\n25C3;WHITE LEFT-POINTING SMALL TRIANGLE;So;0;ON;;;;;N;WHITE LEFT POINTING SMALL TRIANGLE;;;;\n25C4;BLACK LEFT-POINTING POINTER;So;0;ON;;;;;N;BLACK LEFT POINTING POINTER;;;;\n25C5;WHITE LEFT-POINTING POINTER;So;0;ON;;;;;N;WHITE LEFT POINTING POINTER;;;;\n25C6;BLACK DIAMOND;So;0;ON;;;;;N;;;;;\n25C7;WHITE DIAMOND;So;0;ON;;;;;N;;;;;\n25C8;WHITE DIAMOND CONTAINING BLACK SMALL DIAMOND;So;0;ON;;;;;N;;;;;\n25C9;FISHEYE;So;0;ON;;;;;N;;;;;\n25CA;LOZENGE;So;0;ON;;;;;N;;;;;\n25CB;WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n25CC;DOTTED CIRCLE;So;0;ON;;;;;N;;;;;\n25CD;CIRCLE WITH VERTICAL FILL;So;0;ON;;;;;N;;;;;\n25CE;BULLSEYE;So;0;ON;;;;;N;;;;;\n25CF;BLACK CIRCLE;So;0;ON;;;;;N;;;;;\n25D0;CIRCLE WITH LEFT HALF BLACK;So;0;ON;;;;;N;;;;;\n25D1;CIRCLE WITH RIGHT HALF BLACK;So;0;ON;;;;;N;;;;;\n25D2;CIRCLE WITH LOWER HALF BLACK;So;0;ON;;;;;N;;;;;\n25D3;CIRCLE WITH UPPER HALF BLACK;So;0;ON;;;;;N;;;;;\n25D4;CIRCLE WITH UPPER RIGHT QUADRANT BLACK;So;0;ON;;;;;N;;;;;\n25D5;CIRCLE WITH ALL BUT UPPER LEFT QUADRANT BLACK;So;0;ON;;;;;N;;;;;\n25D6;LEFT HALF BLACK CIRCLE;So;0;ON;;;;;N;;;;;\n25D7;RIGHT HALF BLACK CIRCLE;So;0;ON;;;;;N;;;;;\n25D8;INVERSE BULLET;So;0;ON;;;;;N;;;;;\n25D9;INVERSE WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n25DA;UPPER HALF INVERSE WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n25DB;LOWER HALF INVERSE WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n25DC;UPPER LEFT QUADRANT CIRCULAR ARC;So;0;ON;;;;;N;;;;;\n25DD;UPPER RIGHT QUADRANT CIRCULAR ARC;So;0;ON;;;;;N;;;;;\n25DE;LOWER RIGHT QUADRANT CIRCULAR ARC;So;0;ON;;;;;N;;;;;\n25DF;LOWER LEFT QUADRANT CIRCULAR ARC;So;0;ON;;;;;N;;;;;\n25E0;UPPER HALF CIRCLE;So;0;ON;;;;;N;;;;;\n25E1;LOWER HALF CIRCLE;So;0;ON;;;;;N;;;;;\n25E2;BLACK LOWER RIGHT TRIANGLE;So;0;ON;;;;;N;;;;;\n25E3;BLACK LOWER LEFT TRIANGLE;So;0;ON;;;;;N;;;;;\n25E4;BLACK UPPER LEFT TRIANGLE;So;0;ON;;;;;N;;;;;\n25E5;BLACK UPPER RIGHT TRIANGLE;So;0;ON;;;;;N;;;;;\n25E6;WHITE BULLET;So;0;ON;;;;;N;;;;;\n25E7;SQUARE WITH LEFT HALF BLACK;So;0;ON;;;;;N;;;;;\n25E8;SQUARE WITH RIGHT HALF BLACK;So;0;ON;;;;;N;;;;;\n25E9;SQUARE WITH UPPER LEFT DIAGONAL HALF BLACK;So;0;ON;;;;;N;;;;;\n25EA;SQUARE WITH LOWER RIGHT DIAGONAL HALF BLACK;So;0;ON;;;;;N;;;;;\n25EB;WHITE SQUARE WITH VERTICAL BISECTING LINE;So;0;ON;;;;;N;;;;;\n25EC;WHITE UP-POINTING TRIANGLE WITH DOT;So;0;ON;;;;;N;WHITE UP POINTING TRIANGLE WITH DOT;;;;\n25ED;UP-POINTING TRIANGLE WITH LEFT HALF BLACK;So;0;ON;;;;;N;UP POINTING TRIANGLE WITH LEFT HALF BLACK;;;;\n25EE;UP-POINTING TRIANGLE WITH RIGHT HALF BLACK;So;0;ON;;;;;N;UP POINTING TRIANGLE WITH RIGHT HALF BLACK;;;;\n25EF;LARGE CIRCLE;So;0;ON;;;;;N;;;;;\n25F0;WHITE SQUARE WITH UPPER LEFT QUADRANT;So;0;ON;;;;;N;;;;;\n25F1;WHITE SQUARE WITH LOWER LEFT QUADRANT;So;0;ON;;;;;N;;;;;\n25F2;WHITE SQUARE WITH LOWER RIGHT QUADRANT;So;0;ON;;;;;N;;;;;\n25F3;WHITE SQUARE WITH UPPER RIGHT QUADRANT;So;0;ON;;;;;N;;;;;\n25F4;WHITE CIRCLE WITH UPPER LEFT QUADRANT;So;0;ON;;;;;N;;;;;\n25F5;WHITE CIRCLE WITH LOWER LEFT QUADRANT;So;0;ON;;;;;N;;;;;\n25F6;WHITE CIRCLE WITH LOWER RIGHT QUADRANT;So;0;ON;;;;;N;;;;;\n25F7;WHITE CIRCLE WITH UPPER RIGHT QUADRANT;So;0;ON;;;;;N;;;;;\n25F8;UPPER LEFT TRIANGLE;Sm;0;ON;;;;;N;;;;;\n25F9;UPPER RIGHT TRIANGLE;Sm;0;ON;;;;;N;;;;;\n25FA;LOWER LEFT TRIANGLE;Sm;0;ON;;;;;N;;;;;\n25FB;WHITE MEDIUM SQUARE;Sm;0;ON;;;;;N;;;;;\n25FC;BLACK MEDIUM SQUARE;Sm;0;ON;;;;;N;;;;;\n25FD;WHITE MEDIUM SMALL SQUARE;Sm;0;ON;;;;;N;;;;;\n25FE;BLACK MEDIUM SMALL SQUARE;Sm;0;ON;;;;;N;;;;;\n25FF;LOWER RIGHT TRIANGLE;Sm;0;ON;;;;;N;;;;;\n2600;BLACK SUN WITH RAYS;So;0;ON;;;;;N;;;;;\n2601;CLOUD;So;0;ON;;;;;N;;;;;\n2602;UMBRELLA;So;0;ON;;;;;N;;;;;\n2603;SNOWMAN;So;0;ON;;;;;N;;;;;\n2604;COMET;So;0;ON;;;;;N;;;;;\n2605;BLACK STAR;So;0;ON;;;;;N;;;;;\n2606;WHITE STAR;So;0;ON;;;;;N;;;;;\n2607;LIGHTNING;So;0;ON;;;;;N;;;;;\n2608;THUNDERSTORM;So;0;ON;;;;;N;;;;;\n2609;SUN;So;0;ON;;;;;N;;;;;\n260A;ASCENDING NODE;So;0;ON;;;;;N;;;;;\n260B;DESCENDING NODE;So;0;ON;;;;;N;;;;;\n260C;CONJUNCTION;So;0;ON;;;;;N;;;;;\n260D;OPPOSITION;So;0;ON;;;;;N;;;;;\n260E;BLACK TELEPHONE;So;0;ON;;;;;N;;;;;\n260F;WHITE TELEPHONE;So;0;ON;;;;;N;;;;;\n2610;BALLOT BOX;So;0;ON;;;;;N;;;;;\n2611;BALLOT BOX WITH CHECK;So;0;ON;;;;;N;;;;;\n2612;BALLOT BOX WITH X;So;0;ON;;;;;N;;;;;\n2613;SALTIRE;So;0;ON;;;;;N;;;;;\n2614;UMBRELLA WITH RAIN DROPS;So;0;ON;;;;;N;;;;;\n2615;HOT BEVERAGE;So;0;ON;;;;;N;;;;;\n2616;WHITE SHOGI PIECE;So;0;ON;;;;;N;;;;;\n2617;BLACK SHOGI PIECE;So;0;ON;;;;;N;;;;;\n2618;SHAMROCK;So;0;ON;;;;;N;;;;;\n2619;REVERSED ROTATED FLORAL HEART BULLET;So;0;ON;;;;;N;;;;;\n261A;BLACK LEFT POINTING INDEX;So;0;ON;;;;;N;;;;;\n261B;BLACK RIGHT POINTING INDEX;So;0;ON;;;;;N;;;;;\n261C;WHITE LEFT POINTING INDEX;So;0;ON;;;;;N;;;;;\n261D;WHITE UP POINTING INDEX;So;0;ON;;;;;N;;;;;\n261E;WHITE RIGHT POINTING INDEX;So;0;ON;;;;;N;;;;;\n261F;WHITE DOWN POINTING INDEX;So;0;ON;;;;;N;;;;;\n2620;SKULL AND CROSSBONES;So;0;ON;;;;;N;;;;;\n2621;CAUTION SIGN;So;0;ON;;;;;N;;;;;\n2622;RADIOACTIVE SIGN;So;0;ON;;;;;N;;;;;\n2623;BIOHAZARD SIGN;So;0;ON;;;;;N;;;;;\n2624;CADUCEUS;So;0;ON;;;;;N;;;;;\n2625;ANKH;So;0;ON;;;;;N;;;;;\n2626;ORTHODOX CROSS;So;0;ON;;;;;N;;;;;\n2627;CHI RHO;So;0;ON;;;;;N;;;;;\n2628;CROSS OF LORRAINE;So;0;ON;;;;;N;;;;;\n2629;CROSS OF JERUSALEM;So;0;ON;;;;;N;;;;;\n262A;STAR AND CRESCENT;So;0;ON;;;;;N;;;;;\n262B;FARSI SYMBOL;So;0;ON;;;;;N;SYMBOL OF IRAN;;;;\n262C;ADI SHAKTI;So;0;ON;;;;;N;;;;;\n262D;HAMMER AND SICKLE;So;0;ON;;;;;N;;;;;\n262E;PEACE SYMBOL;So;0;ON;;;;;N;;;;;\n262F;YIN YANG;So;0;ON;;;;;N;;;;;\n2630;TRIGRAM FOR HEAVEN;So;0;ON;;;;;N;;;;;\n2631;TRIGRAM FOR LAKE;So;0;ON;;;;;N;;;;;\n2632;TRIGRAM FOR FIRE;So;0;ON;;;;;N;;;;;\n2633;TRIGRAM FOR THUNDER;So;0;ON;;;;;N;;;;;\n2634;TRIGRAM FOR WIND;So;0;ON;;;;;N;;;;;\n2635;TRIGRAM FOR WATER;So;0;ON;;;;;N;;;;;\n2636;TRIGRAM FOR MOUNTAIN;So;0;ON;;;;;N;;;;;\n2637;TRIGRAM FOR EARTH;So;0;ON;;;;;N;;;;;\n2638;WHEEL OF DHARMA;So;0;ON;;;;;N;;;;;\n2639;WHITE FROWNING FACE;So;0;ON;;;;;N;;;;;\n263A;WHITE SMILING FACE;So;0;ON;;;;;N;;;;;\n263B;BLACK SMILING FACE;So;0;ON;;;;;N;;;;;\n263C;WHITE SUN WITH RAYS;So;0;ON;;;;;N;;;;;\n263D;FIRST QUARTER MOON;So;0;ON;;;;;N;;;;;\n263E;LAST QUARTER MOON;So;0;ON;;;;;N;;;;;\n263F;MERCURY;So;0;ON;;;;;N;;;;;\n2640;FEMALE SIGN;So;0;ON;;;;;N;;;;;\n2641;EARTH;So;0;ON;;;;;N;;;;;\n2642;MALE SIGN;So;0;ON;;;;;N;;;;;\n2643;JUPITER;So;0;ON;;;;;N;;;;;\n2644;SATURN;So;0;ON;;;;;N;;;;;\n2645;URANUS;So;0;ON;;;;;N;;;;;\n2646;NEPTUNE;So;0;ON;;;;;N;;;;;\n2647;PLUTO;So;0;ON;;;;;N;;;;;\n2648;ARIES;So;0;ON;;;;;N;;;;;\n2649;TAURUS;So;0;ON;;;;;N;;;;;\n264A;GEMINI;So;0;ON;;;;;N;;;;;\n264B;CANCER;So;0;ON;;;;;N;;;;;\n264C;LEO;So;0;ON;;;;;N;;;;;\n264D;VIRGO;So;0;ON;;;;;N;;;;;\n264E;LIBRA;So;0;ON;;;;;N;;;;;\n264F;SCORPIUS;So;0;ON;;;;;N;;;;;\n2650;SAGITTARIUS;So;0;ON;;;;;N;;;;;\n2651;CAPRICORN;So;0;ON;;;;;N;;;;;\n2652;AQUARIUS;So;0;ON;;;;;N;;;;;\n2653;PISCES;So;0;ON;;;;;N;;;;;\n2654;WHITE CHESS KING;So;0;ON;;;;;N;;;;;\n2655;WHITE CHESS QUEEN;So;0;ON;;;;;N;;;;;\n2656;WHITE CHESS ROOK;So;0;ON;;;;;N;;;;;\n2657;WHITE CHESS BISHOP;So;0;ON;;;;;N;;;;;\n2658;WHITE CHESS KNIGHT;So;0;ON;;;;;N;;;;;\n2659;WHITE CHESS PAWN;So;0;ON;;;;;N;;;;;\n265A;BLACK CHESS KING;So;0;ON;;;;;N;;;;;\n265B;BLACK CHESS QUEEN;So;0;ON;;;;;N;;;;;\n265C;BLACK CHESS ROOK;So;0;ON;;;;;N;;;;;\n265D;BLACK CHESS BISHOP;So;0;ON;;;;;N;;;;;\n265E;BLACK CHESS KNIGHT;So;0;ON;;;;;N;;;;;\n265F;BLACK CHESS PAWN;So;0;ON;;;;;N;;;;;\n2660;BLACK SPADE SUIT;So;0;ON;;;;;N;;;;;\n2661;WHITE HEART SUIT;So;0;ON;;;;;N;;;;;\n2662;WHITE DIAMOND SUIT;So;0;ON;;;;;N;;;;;\n2663;BLACK CLUB SUIT;So;0;ON;;;;;N;;;;;\n2664;WHITE SPADE SUIT;So;0;ON;;;;;N;;;;;\n2665;BLACK HEART SUIT;So;0;ON;;;;;N;;;;;\n2666;BLACK DIAMOND SUIT;So;0;ON;;;;;N;;;;;\n2667;WHITE CLUB SUIT;So;0;ON;;;;;N;;;;;\n2668;HOT SPRINGS;So;0;ON;;;;;N;;;;;\n2669;QUARTER NOTE;So;0;ON;;;;;N;;;;;\n266A;EIGHTH NOTE;So;0;ON;;;;;N;;;;;\n266B;BEAMED EIGHTH NOTES;So;0;ON;;;;;N;BARRED EIGHTH NOTES;;;;\n266C;BEAMED SIXTEENTH NOTES;So;0;ON;;;;;N;BARRED SIXTEENTH NOTES;;;;\n266D;MUSIC FLAT SIGN;So;0;ON;;;;;N;FLAT;;;;\n266E;MUSIC NATURAL SIGN;So;0;ON;;;;;N;NATURAL;;;;\n266F;MUSIC SHARP SIGN;Sm;0;ON;;;;;N;SHARP;;;;\n2670;WEST SYRIAC CROSS;So;0;ON;;;;;N;;;;;\n2671;EAST SYRIAC CROSS;So;0;ON;;;;;N;;;;;\n2672;UNIVERSAL RECYCLING SYMBOL;So;0;ON;;;;;N;;;;;\n2673;RECYCLING SYMBOL FOR TYPE-1 PLASTICS;So;0;ON;;;;;N;;;;;\n2674;RECYCLING SYMBOL FOR TYPE-2 PLASTICS;So;0;ON;;;;;N;;;;;\n2675;RECYCLING SYMBOL FOR TYPE-3 PLASTICS;So;0;ON;;;;;N;;;;;\n2676;RECYCLING SYMBOL FOR TYPE-4 PLASTICS;So;0;ON;;;;;N;;;;;\n2677;RECYCLING SYMBOL FOR TYPE-5 PLASTICS;So;0;ON;;;;;N;;;;;\n2678;RECYCLING SYMBOL FOR TYPE-6 PLASTICS;So;0;ON;;;;;N;;;;;\n2679;RECYCLING SYMBOL FOR TYPE-7 PLASTICS;So;0;ON;;;;;N;;;;;\n267A;RECYCLING SYMBOL FOR GENERIC MATERIALS;So;0;ON;;;;;N;;;;;\n267B;BLACK UNIVERSAL RECYCLING SYMBOL;So;0;ON;;;;;N;;;;;\n267C;RECYCLED PAPER SYMBOL;So;0;ON;;;;;N;;;;;\n267D;PARTIALLY-RECYCLED PAPER SYMBOL;So;0;ON;;;;;N;;;;;\n267E;PERMANENT PAPER SIGN;So;0;ON;;;;;N;;;;;\n267F;WHEELCHAIR SYMBOL;So;0;ON;;;;;N;;;;;\n2680;DIE FACE-1;So;0;ON;;;;;N;;;;;\n2681;DIE FACE-2;So;0;ON;;;;;N;;;;;\n2682;DIE FACE-3;So;0;ON;;;;;N;;;;;\n2683;DIE FACE-4;So;0;ON;;;;;N;;;;;\n2684;DIE FACE-5;So;0;ON;;;;;N;;;;;\n2685;DIE FACE-6;So;0;ON;;;;;N;;;;;\n2686;WHITE CIRCLE WITH DOT RIGHT;So;0;ON;;;;;N;;;;;\n2687;WHITE CIRCLE WITH TWO DOTS;So;0;ON;;;;;N;;;;;\n2688;BLACK CIRCLE WITH WHITE DOT RIGHT;So;0;ON;;;;;N;;;;;\n2689;BLACK CIRCLE WITH TWO WHITE DOTS;So;0;ON;;;;;N;;;;;\n268A;MONOGRAM FOR YANG;So;0;ON;;;;;N;;;;;\n268B;MONOGRAM FOR YIN;So;0;ON;;;;;N;;;;;\n268C;DIGRAM FOR GREATER YANG;So;0;ON;;;;;N;;;;;\n268D;DIGRAM FOR LESSER YIN;So;0;ON;;;;;N;;;;;\n268E;DIGRAM FOR LESSER YANG;So;0;ON;;;;;N;;;;;\n268F;DIGRAM FOR GREATER YIN;So;0;ON;;;;;N;;;;;\n2690;WHITE FLAG;So;0;ON;;;;;N;;;;;\n2691;BLACK FLAG;So;0;ON;;;;;N;;;;;\n2692;HAMMER AND PICK;So;0;ON;;;;;N;;;;;\n2693;ANCHOR;So;0;ON;;;;;N;;;;;\n2694;CROSSED SWORDS;So;0;ON;;;;;N;;;;;\n2695;STAFF OF AESCULAPIUS;So;0;ON;;;;;N;;;;;\n2696;SCALES;So;0;ON;;;;;N;;;;;\n2697;ALEMBIC;So;0;ON;;;;;N;;;;;\n2698;FLOWER;So;0;ON;;;;;N;;;;;\n2699;GEAR;So;0;ON;;;;;N;;;;;\n269A;STAFF OF HERMES;So;0;ON;;;;;N;;;;;\n269B;ATOM SYMBOL;So;0;ON;;;;;N;;;;;\n269C;FLEUR-DE-LIS;So;0;ON;;;;;N;;;;;\n269D;OUTLINED WHITE STAR;So;0;ON;;;;;N;;;;;\n269E;THREE LINES CONVERGING RIGHT;So;0;ON;;;;;N;;;;;\n269F;THREE LINES CONVERGING LEFT;So;0;ON;;;;;N;;;;;\n26A0;WARNING SIGN;So;0;ON;;;;;N;;;;;\n26A1;HIGH VOLTAGE SIGN;So;0;ON;;;;;N;;;;;\n26A2;DOUBLED FEMALE SIGN;So;0;ON;;;;;N;;;;;\n26A3;DOUBLED MALE SIGN;So;0;ON;;;;;N;;;;;\n26A4;INTERLOCKED FEMALE AND MALE SIGN;So;0;ON;;;;;N;;;;;\n26A5;MALE AND FEMALE SIGN;So;0;ON;;;;;N;;;;;\n26A6;MALE WITH STROKE SIGN;So;0;ON;;;;;N;;;;;\n26A7;MALE WITH STROKE AND MALE AND FEMALE SIGN;So;0;ON;;;;;N;;;;;\n26A8;VERTICAL MALE WITH STROKE SIGN;So;0;ON;;;;;N;;;;;\n26A9;HORIZONTAL MALE WITH STROKE SIGN;So;0;ON;;;;;N;;;;;\n26AA;MEDIUM WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n26AB;MEDIUM BLACK CIRCLE;So;0;ON;;;;;N;;;;;\n26AC;MEDIUM SMALL WHITE CIRCLE;So;0;L;;;;;N;;;;;\n26AD;MARRIAGE SYMBOL;So;0;ON;;;;;N;;;;;\n26AE;DIVORCE SYMBOL;So;0;ON;;;;;N;;;;;\n26AF;UNMARRIED PARTNERSHIP SYMBOL;So;0;ON;;;;;N;;;;;\n26B0;COFFIN;So;0;ON;;;;;N;;;;;\n26B1;FUNERAL URN;So;0;ON;;;;;N;;;;;\n26B2;NEUTER;So;0;ON;;;;;N;;;;;\n26B3;CERES;So;0;ON;;;;;N;;;;;\n26B4;PALLAS;So;0;ON;;;;;N;;;;;\n26B5;JUNO;So;0;ON;;;;;N;;;;;\n26B6;VESTA;So;0;ON;;;;;N;;;;;\n26B7;CHIRON;So;0;ON;;;;;N;;;;;\n26B8;BLACK MOON LILITH;So;0;ON;;;;;N;;;;;\n26B9;SEXTILE;So;0;ON;;;;;N;;;;;\n26BA;SEMISEXTILE;So;0;ON;;;;;N;;;;;\n26BB;QUINCUNX;So;0;ON;;;;;N;;;;;\n26BC;SESQUIQUADRATE;So;0;ON;;;;;N;;;;;\n26BD;SOCCER BALL;So;0;ON;;;;;N;;;;;\n26BE;BASEBALL;So;0;ON;;;;;N;;;;;\n26BF;SQUARED KEY;So;0;ON;;;;;N;;;;;\n26C0;WHITE DRAUGHTS MAN;So;0;ON;;;;;N;;;;;\n26C1;WHITE DRAUGHTS KING;So;0;ON;;;;;N;;;;;\n26C2;BLACK DRAUGHTS MAN;So;0;ON;;;;;N;;;;;\n26C3;BLACK DRAUGHTS KING;So;0;ON;;;;;N;;;;;\n26C4;SNOWMAN WITHOUT SNOW;So;0;ON;;;;;N;;;;;\n26C5;SUN BEHIND CLOUD;So;0;ON;;;;;N;;;;;\n26C6;RAIN;So;0;ON;;;;;N;;;;;\n26C7;BLACK SNOWMAN;So;0;ON;;;;;N;;;;;\n26C8;THUNDER CLOUD AND RAIN;So;0;ON;;;;;N;;;;;\n26C9;TURNED WHITE SHOGI PIECE;So;0;ON;;;;;N;;;;;\n26CA;TURNED BLACK SHOGI PIECE;So;0;ON;;;;;N;;;;;\n26CB;WHITE DIAMOND IN SQUARE;So;0;ON;;;;;N;;;;;\n26CC;CROSSING LANES;So;0;ON;;;;;N;;;;;\n26CD;DISABLED CAR;So;0;ON;;;;;N;;;;;\n26CE;OPHIUCHUS;So;0;ON;;;;;N;;;;;\n26CF;PICK;So;0;ON;;;;;N;;;;;\n26D0;CAR SLIDING;So;0;ON;;;;;N;;;;;\n26D1;HELMET WITH WHITE CROSS;So;0;ON;;;;;N;;;;;\n26D2;CIRCLED CROSSING LANES;So;0;ON;;;;;N;;;;;\n26D3;CHAINS;So;0;ON;;;;;N;;;;;\n26D4;NO ENTRY;So;0;ON;;;;;N;;;;;\n26D5;ALTERNATE ONE-WAY LEFT WAY TRAFFIC;So;0;ON;;;;;N;;;;;\n26D6;BLACK TWO-WAY LEFT WAY TRAFFIC;So;0;ON;;;;;N;;;;;\n26D7;WHITE TWO-WAY LEFT WAY TRAFFIC;So;0;ON;;;;;N;;;;;\n26D8;BLACK LEFT LANE MERGE;So;0;ON;;;;;N;;;;;\n26D9;WHITE LEFT LANE MERGE;So;0;ON;;;;;N;;;;;\n26DA;DRIVE SLOW SIGN;So;0;ON;;;;;N;;;;;\n26DB;HEAVY WHITE DOWN-POINTING TRIANGLE;So;0;ON;;;;;N;;;;;\n26DC;LEFT CLOSED ENTRY;So;0;ON;;;;;N;;;;;\n26DD;SQUARED SALTIRE;So;0;ON;;;;;N;;;;;\n26DE;FALLING DIAGONAL IN WHITE CIRCLE IN BLACK SQUARE;So;0;ON;;;;;N;;;;;\n26DF;BLACK TRUCK;So;0;ON;;;;;N;;;;;\n26E0;RESTRICTED LEFT ENTRY-1;So;0;ON;;;;;N;;;;;\n26E1;RESTRICTED LEFT ENTRY-2;So;0;ON;;;;;N;;;;;\n26E2;ASTRONOMICAL SYMBOL FOR URANUS;So;0;ON;;;;;N;;;;;\n26E3;HEAVY CIRCLE WITH STROKE AND TWO DOTS ABOVE;So;0;ON;;;;;N;;;;;\n26E4;PENTAGRAM;So;0;ON;;;;;N;;;;;\n26E5;RIGHT-HANDED INTERLACED PENTAGRAM;So;0;ON;;;;;N;;;;;\n26E6;LEFT-HANDED INTERLACED PENTAGRAM;So;0;ON;;;;;N;;;;;\n26E7;INVERTED PENTAGRAM;So;0;ON;;;;;N;;;;;\n26E8;BLACK CROSS ON SHIELD;So;0;ON;;;;;N;;;;;\n26E9;SHINTO SHRINE;So;0;ON;;;;;N;;;;;\n26EA;CHURCH;So;0;ON;;;;;N;;;;;\n26EB;CASTLE;So;0;ON;;;;;N;;;;;\n26EC;HISTORIC SITE;So;0;ON;;;;;N;;;;;\n26ED;GEAR WITHOUT HUB;So;0;ON;;;;;N;;;;;\n26EE;GEAR WITH HANDLES;So;0;ON;;;;;N;;;;;\n26EF;MAP SYMBOL FOR LIGHTHOUSE;So;0;ON;;;;;N;;;;;\n26F0;MOUNTAIN;So;0;ON;;;;;N;;;;;\n26F1;UMBRELLA ON GROUND;So;0;ON;;;;;N;;;;;\n26F2;FOUNTAIN;So;0;ON;;;;;N;;;;;\n26F3;FLAG IN HOLE;So;0;ON;;;;;N;;;;;\n26F4;FERRY;So;0;ON;;;;;N;;;;;\n26F5;SAILBOAT;So;0;ON;;;;;N;;;;;\n26F6;SQUARE FOUR CORNERS;So;0;ON;;;;;N;;;;;\n26F7;SKIER;So;0;ON;;;;;N;;;;;\n26F8;ICE SKATE;So;0;ON;;;;;N;;;;;\n26F9;PERSON WITH BALL;So;0;ON;;;;;N;;;;;\n26FA;TENT;So;0;ON;;;;;N;;;;;\n26FB;JAPANESE BANK SYMBOL;So;0;ON;;;;;N;;;;;\n26FC;HEADSTONE GRAVEYARD SYMBOL;So;0;ON;;;;;N;;;;;\n26FD;FUEL PUMP;So;0;ON;;;;;N;;;;;\n26FE;CUP ON BLACK SQUARE;So;0;ON;;;;;N;;;;;\n26FF;WHITE FLAG WITH HORIZONTAL MIDDLE BLACK STRIPE;So;0;ON;;;;;N;;;;;\n2701;UPPER BLADE SCISSORS;So;0;ON;;;;;N;;;;;\n2702;BLACK SCISSORS;So;0;ON;;;;;N;;;;;\n2703;LOWER BLADE SCISSORS;So;0;ON;;;;;N;;;;;\n2704;WHITE SCISSORS;So;0;ON;;;;;N;;;;;\n2705;WHITE HEAVY CHECK MARK;So;0;ON;;;;;N;;;;;\n2706;TELEPHONE LOCATION SIGN;So;0;ON;;;;;N;;;;;\n2707;TAPE DRIVE;So;0;ON;;;;;N;;;;;\n2708;AIRPLANE;So;0;ON;;;;;N;;;;;\n2709;ENVELOPE;So;0;ON;;;;;N;;;;;\n270A;RAISED FIST;So;0;ON;;;;;N;;;;;\n270B;RAISED HAND;So;0;ON;;;;;N;;;;;\n270C;VICTORY HAND;So;0;ON;;;;;N;;;;;\n270D;WRITING HAND;So;0;ON;;;;;N;;;;;\n270E;LOWER RIGHT PENCIL;So;0;ON;;;;;N;;;;;\n270F;PENCIL;So;0;ON;;;;;N;;;;;\n2710;UPPER RIGHT PENCIL;So;0;ON;;;;;N;;;;;\n2711;WHITE NIB;So;0;ON;;;;;N;;;;;\n2712;BLACK NIB;So;0;ON;;;;;N;;;;;\n2713;CHECK MARK;So;0;ON;;;;;N;;;;;\n2714;HEAVY CHECK MARK;So;0;ON;;;;;N;;;;;\n2715;MULTIPLICATION X;So;0;ON;;;;;N;;;;;\n2716;HEAVY MULTIPLICATION X;So;0;ON;;;;;N;;;;;\n2717;BALLOT X;So;0;ON;;;;;N;;;;;\n2718;HEAVY BALLOT X;So;0;ON;;;;;N;;;;;\n2719;OUTLINED GREEK CROSS;So;0;ON;;;;;N;;;;;\n271A;HEAVY GREEK CROSS;So;0;ON;;;;;N;;;;;\n271B;OPEN CENTRE CROSS;So;0;ON;;;;;N;OPEN CENTER CROSS;;;;\n271C;HEAVY OPEN CENTRE CROSS;So;0;ON;;;;;N;HEAVY OPEN CENTER CROSS;;;;\n271D;LATIN CROSS;So;0;ON;;;;;N;;;;;\n271E;SHADOWED WHITE LATIN CROSS;So;0;ON;;;;;N;;;;;\n271F;OUTLINED LATIN CROSS;So;0;ON;;;;;N;;;;;\n2720;MALTESE CROSS;So;0;ON;;;;;N;;;;;\n2721;STAR OF DAVID;So;0;ON;;;;;N;;;;;\n2722;FOUR TEARDROP-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n2723;FOUR BALLOON-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n2724;HEAVY FOUR BALLOON-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n2725;FOUR CLUB-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n2726;BLACK FOUR POINTED STAR;So;0;ON;;;;;N;;;;;\n2727;WHITE FOUR POINTED STAR;So;0;ON;;;;;N;;;;;\n2728;SPARKLES;So;0;ON;;;;;N;;;;;\n2729;STRESS OUTLINED WHITE STAR;So;0;ON;;;;;N;;;;;\n272A;CIRCLED WHITE STAR;So;0;ON;;;;;N;;;;;\n272B;OPEN CENTRE BLACK STAR;So;0;ON;;;;;N;OPEN CENTER BLACK STAR;;;;\n272C;BLACK CENTRE WHITE STAR;So;0;ON;;;;;N;BLACK CENTER WHITE STAR;;;;\n272D;OUTLINED BLACK STAR;So;0;ON;;;;;N;;;;;\n272E;HEAVY OUTLINED BLACK STAR;So;0;ON;;;;;N;;;;;\n272F;PINWHEEL STAR;So;0;ON;;;;;N;;;;;\n2730;SHADOWED WHITE STAR;So;0;ON;;;;;N;;;;;\n2731;HEAVY ASTERISK;So;0;ON;;;;;N;;;;;\n2732;OPEN CENTRE ASTERISK;So;0;ON;;;;;N;OPEN CENTER ASTERISK;;;;\n2733;EIGHT SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n2734;EIGHT POINTED BLACK STAR;So;0;ON;;;;;N;;;;;\n2735;EIGHT POINTED PINWHEEL STAR;So;0;ON;;;;;N;;;;;\n2736;SIX POINTED BLACK STAR;So;0;ON;;;;;N;;;;;\n2737;EIGHT POINTED RECTILINEAR BLACK STAR;So;0;ON;;;;;N;;;;;\n2738;HEAVY EIGHT POINTED RECTILINEAR BLACK STAR;So;0;ON;;;;;N;;;;;\n2739;TWELVE POINTED BLACK STAR;So;0;ON;;;;;N;;;;;\n273A;SIXTEEN POINTED ASTERISK;So;0;ON;;;;;N;;;;;\n273B;TEARDROP-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n273C;OPEN CENTRE TEARDROP-SPOKED ASTERISK;So;0;ON;;;;;N;OPEN CENTER TEARDROP-SPOKED ASTERISK;;;;\n273D;HEAVY TEARDROP-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n273E;SIX PETALLED BLACK AND WHITE FLORETTE;So;0;ON;;;;;N;;;;;\n273F;BLACK FLORETTE;So;0;ON;;;;;N;;;;;\n2740;WHITE FLORETTE;So;0;ON;;;;;N;;;;;\n2741;EIGHT PETALLED OUTLINED BLACK FLORETTE;So;0;ON;;;;;N;;;;;\n2742;CIRCLED OPEN CENTRE EIGHT POINTED STAR;So;0;ON;;;;;N;CIRCLED OPEN CENTER EIGHT POINTED STAR;;;;\n2743;HEAVY TEARDROP-SPOKED PINWHEEL ASTERISK;So;0;ON;;;;;N;;;;;\n2744;SNOWFLAKE;So;0;ON;;;;;N;;;;;\n2745;TIGHT TRIFOLIATE SNOWFLAKE;So;0;ON;;;;;N;;;;;\n2746;HEAVY CHEVRON SNOWFLAKE;So;0;ON;;;;;N;;;;;\n2747;SPARKLE;So;0;ON;;;;;N;;;;;\n2748;HEAVY SPARKLE;So;0;ON;;;;;N;;;;;\n2749;BALLOON-SPOKED ASTERISK;So;0;ON;;;;;N;;;;;\n274A;EIGHT TEARDROP-SPOKED PROPELLER ASTERISK;So;0;ON;;;;;N;;;;;\n274B;HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK;So;0;ON;;;;;N;;;;;\n274C;CROSS MARK;So;0;ON;;;;;N;;;;;\n274D;SHADOWED WHITE CIRCLE;So;0;ON;;;;;N;;;;;\n274E;NEGATIVE SQUARED CROSS MARK;So;0;ON;;;;;N;;;;;\n274F;LOWER RIGHT DROP-SHADOWED WHITE SQUARE;So;0;ON;;;;;N;;;;;\n2750;UPPER RIGHT DROP-SHADOWED WHITE SQUARE;So;0;ON;;;;;N;;;;;\n2751;LOWER RIGHT SHADOWED WHITE SQUARE;So;0;ON;;;;;N;;;;;\n2752;UPPER RIGHT SHADOWED WHITE SQUARE;So;0;ON;;;;;N;;;;;\n2753;BLACK QUESTION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2754;WHITE QUESTION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2755;WHITE EXCLAMATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2756;BLACK DIAMOND MINUS WHITE X;So;0;ON;;;;;N;;;;;\n2757;HEAVY EXCLAMATION MARK SYMBOL;So;0;ON;;;;;N;;;;;\n2758;LIGHT VERTICAL BAR;So;0;ON;;;;;N;;;;;\n2759;MEDIUM VERTICAL BAR;So;0;ON;;;;;N;;;;;\n275A;HEAVY VERTICAL BAR;So;0;ON;;;;;N;;;;;\n275B;HEAVY SINGLE TURNED COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n275C;HEAVY SINGLE COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n275D;HEAVY DOUBLE TURNED COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n275E;HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n275F;HEAVY LOW SINGLE COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2760;HEAVY LOW DOUBLE COMMA QUOTATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2761;CURVED STEM PARAGRAPH SIGN ORNAMENT;So;0;ON;;;;;N;;;;;\n2762;HEAVY EXCLAMATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2763;HEAVY HEART EXCLAMATION MARK ORNAMENT;So;0;ON;;;;;N;;;;;\n2764;HEAVY BLACK HEART;So;0;ON;;;;;N;;;;;\n2765;ROTATED HEAVY BLACK HEART BULLET;So;0;ON;;;;;N;;;;;\n2766;FLORAL HEART;So;0;ON;;;;;N;;;;;\n2767;ROTATED FLORAL HEART BULLET;So;0;ON;;;;;N;;;;;\n2768;MEDIUM LEFT PARENTHESIS ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n2769;MEDIUM RIGHT PARENTHESIS ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n276A;MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n276B;MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n276C;MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n276D;MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n276E;HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n276F;HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n2770;HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n2771;HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n2772;LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n2773;LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n2774;MEDIUM LEFT CURLY BRACKET ORNAMENT;Ps;0;ON;;;;;Y;;;;;\n2775;MEDIUM RIGHT CURLY BRACKET ORNAMENT;Pe;0;ON;;;;;Y;;;;;\n2776;DINGBAT NEGATIVE CIRCLED DIGIT ONE;No;0;ON;;;1;1;N;INVERSE CIRCLED DIGIT ONE;;;;\n2777;DINGBAT NEGATIVE CIRCLED DIGIT TWO;No;0;ON;;;2;2;N;INVERSE CIRCLED DIGIT TWO;;;;\n2778;DINGBAT NEGATIVE CIRCLED DIGIT THREE;No;0;ON;;;3;3;N;INVERSE CIRCLED DIGIT THREE;;;;\n2779;DINGBAT NEGATIVE CIRCLED DIGIT FOUR;No;0;ON;;;4;4;N;INVERSE CIRCLED DIGIT FOUR;;;;\n277A;DINGBAT NEGATIVE CIRCLED DIGIT FIVE;No;0;ON;;;5;5;N;INVERSE CIRCLED DIGIT FIVE;;;;\n277B;DINGBAT NEGATIVE CIRCLED DIGIT SIX;No;0;ON;;;6;6;N;INVERSE CIRCLED DIGIT SIX;;;;\n277C;DINGBAT NEGATIVE CIRCLED DIGIT SEVEN;No;0;ON;;;7;7;N;INVERSE CIRCLED DIGIT SEVEN;;;;\n277D;DINGBAT NEGATIVE CIRCLED DIGIT EIGHT;No;0;ON;;;8;8;N;INVERSE CIRCLED DIGIT EIGHT;;;;\n277E;DINGBAT NEGATIVE CIRCLED DIGIT NINE;No;0;ON;;;9;9;N;INVERSE CIRCLED DIGIT NINE;;;;\n277F;DINGBAT NEGATIVE CIRCLED NUMBER TEN;No;0;ON;;;;10;N;INVERSE CIRCLED NUMBER TEN;;;;\n2780;DINGBAT CIRCLED SANS-SERIF DIGIT ONE;No;0;ON;;;1;1;N;CIRCLED SANS-SERIF DIGIT ONE;;;;\n2781;DINGBAT CIRCLED SANS-SERIF DIGIT TWO;No;0;ON;;;2;2;N;CIRCLED SANS-SERIF DIGIT TWO;;;;\n2782;DINGBAT CIRCLED SANS-SERIF DIGIT THREE;No;0;ON;;;3;3;N;CIRCLED SANS-SERIF DIGIT THREE;;;;\n2783;DINGBAT CIRCLED SANS-SERIF DIGIT FOUR;No;0;ON;;;4;4;N;CIRCLED SANS-SERIF DIGIT FOUR;;;;\n2784;DINGBAT CIRCLED SANS-SERIF DIGIT FIVE;No;0;ON;;;5;5;N;CIRCLED SANS-SERIF DIGIT FIVE;;;;\n2785;DINGBAT CIRCLED SANS-SERIF DIGIT SIX;No;0;ON;;;6;6;N;CIRCLED SANS-SERIF DIGIT SIX;;;;\n2786;DINGBAT CIRCLED SANS-SERIF DIGIT SEVEN;No;0;ON;;;7;7;N;CIRCLED SANS-SERIF DIGIT SEVEN;;;;\n2787;DINGBAT CIRCLED SANS-SERIF DIGIT EIGHT;No;0;ON;;;8;8;N;CIRCLED SANS-SERIF DIGIT EIGHT;;;;\n2788;DINGBAT CIRCLED SANS-SERIF DIGIT NINE;No;0;ON;;;9;9;N;CIRCLED SANS-SERIF DIGIT NINE;;;;\n2789;DINGBAT CIRCLED SANS-SERIF NUMBER TEN;No;0;ON;;;;10;N;CIRCLED SANS-SERIF NUMBER TEN;;;;\n278A;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ONE;No;0;ON;;;1;1;N;INVERSE CIRCLED SANS-SERIF DIGIT ONE;;;;\n278B;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT TWO;No;0;ON;;;2;2;N;INVERSE CIRCLED SANS-SERIF DIGIT TWO;;;;\n278C;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT THREE;No;0;ON;;;3;3;N;INVERSE CIRCLED SANS-SERIF DIGIT THREE;;;;\n278D;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT FOUR;No;0;ON;;;4;4;N;INVERSE CIRCLED SANS-SERIF DIGIT FOUR;;;;\n278E;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT FIVE;No;0;ON;;;5;5;N;INVERSE CIRCLED SANS-SERIF DIGIT FIVE;;;;\n278F;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT SIX;No;0;ON;;;6;6;N;INVERSE CIRCLED SANS-SERIF DIGIT SIX;;;;\n2790;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT SEVEN;No;0;ON;;;7;7;N;INVERSE CIRCLED SANS-SERIF DIGIT SEVEN;;;;\n2791;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT EIGHT;No;0;ON;;;8;8;N;INVERSE CIRCLED SANS-SERIF DIGIT EIGHT;;;;\n2792;DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT NINE;No;0;ON;;;9;9;N;INVERSE CIRCLED SANS-SERIF DIGIT NINE;;;;\n2793;DINGBAT NEGATIVE CIRCLED SANS-SERIF NUMBER TEN;No;0;ON;;;;10;N;INVERSE CIRCLED SANS-SERIF NUMBER TEN;;;;\n2794;HEAVY WIDE-HEADED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY WIDE-HEADED RIGHT ARROW;;;;\n2795;HEAVY PLUS SIGN;So;0;ON;;;;;N;;;;;\n2796;HEAVY MINUS SIGN;So;0;ON;;;;;N;;;;;\n2797;HEAVY DIVISION SIGN;So;0;ON;;;;;N;;;;;\n2798;HEAVY SOUTH EAST ARROW;So;0;ON;;;;;N;HEAVY LOWER RIGHT ARROW;;;;\n2799;HEAVY RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY RIGHT ARROW;;;;\n279A;HEAVY NORTH EAST ARROW;So;0;ON;;;;;N;HEAVY UPPER RIGHT ARROW;;;;\n279B;DRAFTING POINT RIGHTWARDS ARROW;So;0;ON;;;;;N;DRAFTING POINT RIGHT ARROW;;;;\n279C;HEAVY ROUND-TIPPED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY ROUND-TIPPED RIGHT ARROW;;;;\n279D;TRIANGLE-HEADED RIGHTWARDS ARROW;So;0;ON;;;;;N;TRIANGLE-HEADED RIGHT ARROW;;;;\n279E;HEAVY TRIANGLE-HEADED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY TRIANGLE-HEADED RIGHT ARROW;;;;\n279F;DASHED TRIANGLE-HEADED RIGHTWARDS ARROW;So;0;ON;;;;;N;DASHED TRIANGLE-HEADED RIGHT ARROW;;;;\n27A0;HEAVY DASHED TRIANGLE-HEADED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY DASHED TRIANGLE-HEADED RIGHT ARROW;;;;\n27A1;BLACK RIGHTWARDS ARROW;So;0;ON;;;;;N;BLACK RIGHT ARROW;;;;\n27A2;THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEAD;So;0;ON;;;;;N;THREE-D TOP-LIGHTED RIGHT ARROWHEAD;;;;\n27A3;THREE-D BOTTOM-LIGHTED RIGHTWARDS ARROWHEAD;So;0;ON;;;;;N;THREE-D BOTTOM-LIGHTED RIGHT ARROWHEAD;;;;\n27A4;BLACK RIGHTWARDS ARROWHEAD;So;0;ON;;;;;N;BLACK RIGHT ARROWHEAD;;;;\n27A5;HEAVY BLACK CURVED DOWNWARDS AND RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY BLACK CURVED DOWN AND RIGHT ARROW;;;;\n27A6;HEAVY BLACK CURVED UPWARDS AND RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY BLACK CURVED UP AND RIGHT ARROW;;;;\n27A7;SQUAT BLACK RIGHTWARDS ARROW;So;0;ON;;;;;N;SQUAT BLACK RIGHT ARROW;;;;\n27A8;HEAVY CONCAVE-POINTED BLACK RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY CONCAVE-POINTED BLACK RIGHT ARROW;;;;\n27A9;RIGHT-SHADED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;RIGHT-SHADED WHITE RIGHT ARROW;;;;\n27AA;LEFT-SHADED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;LEFT-SHADED WHITE RIGHT ARROW;;;;\n27AB;BACK-TILTED SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;BACK-TILTED SHADOWED WHITE RIGHT ARROW;;;;\n27AC;FRONT-TILTED SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;FRONT-TILTED SHADOWED WHITE RIGHT ARROW;;;;\n27AD;HEAVY LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY LOWER RIGHT-SHADOWED WHITE RIGHT ARROW;;;;\n27AE;HEAVY UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY UPPER RIGHT-SHADOWED WHITE RIGHT ARROW;;;;\n27AF;NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHT ARROW;;;;\n27B0;CURLY LOOP;So;0;ON;;;;;N;;;;;\n27B1;NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHT ARROW;;;;\n27B2;CIRCLED HEAVY WHITE RIGHTWARDS ARROW;So;0;ON;;;;;N;CIRCLED HEAVY WHITE RIGHT ARROW;;;;\n27B3;WHITE-FEATHERED RIGHTWARDS ARROW;So;0;ON;;;;;N;WHITE-FEATHERED RIGHT ARROW;;;;\n27B4;BLACK-FEATHERED SOUTH EAST ARROW;So;0;ON;;;;;N;BLACK-FEATHERED LOWER RIGHT ARROW;;;;\n27B5;BLACK-FEATHERED RIGHTWARDS ARROW;So;0;ON;;;;;N;BLACK-FEATHERED RIGHT ARROW;;;;\n27B6;BLACK-FEATHERED NORTH EAST ARROW;So;0;ON;;;;;N;BLACK-FEATHERED UPPER RIGHT ARROW;;;;\n27B7;HEAVY BLACK-FEATHERED SOUTH EAST ARROW;So;0;ON;;;;;N;HEAVY BLACK-FEATHERED LOWER RIGHT ARROW;;;;\n27B8;HEAVY BLACK-FEATHERED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY BLACK-FEATHERED RIGHT ARROW;;;;\n27B9;HEAVY BLACK-FEATHERED NORTH EAST ARROW;So;0;ON;;;;;N;HEAVY BLACK-FEATHERED UPPER RIGHT ARROW;;;;\n27BA;TEARDROP-BARBED RIGHTWARDS ARROW;So;0;ON;;;;;N;TEARDROP-BARBED RIGHT ARROW;;;;\n27BB;HEAVY TEARDROP-SHANKED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY TEARDROP-SHANKED RIGHT ARROW;;;;\n27BC;WEDGE-TAILED RIGHTWARDS ARROW;So;0;ON;;;;;N;WEDGE-TAILED RIGHT ARROW;;;;\n27BD;HEAVY WEDGE-TAILED RIGHTWARDS ARROW;So;0;ON;;;;;N;HEAVY WEDGE-TAILED RIGHT ARROW;;;;\n27BE;OPEN-OUTLINED RIGHTWARDS ARROW;So;0;ON;;;;;N;OPEN-OUTLINED RIGHT ARROW;;;;\n27BF;DOUBLE CURLY LOOP;So;0;ON;;;;;N;;;;;\n27C0;THREE DIMENSIONAL ANGLE;Sm;0;ON;;;;;Y;;;;;\n27C1;WHITE TRIANGLE CONTAINING SMALL WHITE TRIANGLE;Sm;0;ON;;;;;N;;;;;\n27C2;PERPENDICULAR;Sm;0;ON;;;;;N;;;;;\n27C3;OPEN SUBSET;Sm;0;ON;;;;;Y;;;;;\n27C4;OPEN SUPERSET;Sm;0;ON;;;;;Y;;;;;\n27C5;LEFT S-SHAPED BAG DELIMITER;Ps;0;ON;;;;;Y;;;;;\n27C6;RIGHT S-SHAPED BAG DELIMITER;Pe;0;ON;;;;;Y;;;;;\n27C7;OR WITH DOT INSIDE;Sm;0;ON;;;;;N;;;;;\n27C8;REVERSE SOLIDUS PRECEDING SUBSET;Sm;0;ON;;;;;Y;;;;;\n27C9;SUPERSET PRECEDING SOLIDUS;Sm;0;ON;;;;;Y;;;;;\n27CA;VERTICAL BAR WITH HORIZONTAL STROKE;Sm;0;ON;;;;;N;;;;;\n27CB;MATHEMATICAL RISING DIAGONAL;Sm;0;ON;;;;;Y;;;;;\n27CC;LONG DIVISION;Sm;0;ON;;;;;Y;;;;;\n27CD;MATHEMATICAL FALLING DIAGONAL;Sm;0;ON;;;;;Y;;;;;\n27CE;SQUARED LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n27CF;SQUARED LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n27D0;WHITE DIAMOND WITH CENTRED DOT;Sm;0;ON;;;;;N;;;;;\n27D1;AND WITH DOT;Sm;0;ON;;;;;N;;;;;\n27D2;ELEMENT OF OPENING UPWARDS;Sm;0;ON;;;;;N;;;;;\n27D3;LOWER RIGHT CORNER WITH DOT;Sm;0;ON;;;;;Y;;;;;\n27D4;UPPER LEFT CORNER WITH DOT;Sm;0;ON;;;;;Y;;;;;\n27D5;LEFT OUTER JOIN;Sm;0;ON;;;;;Y;;;;;\n27D6;RIGHT OUTER JOIN;Sm;0;ON;;;;;Y;;;;;\n27D7;FULL OUTER JOIN;Sm;0;ON;;;;;N;;;;;\n27D8;LARGE UP TACK;Sm;0;ON;;;;;N;;;;;\n27D9;LARGE DOWN TACK;Sm;0;ON;;;;;N;;;;;\n27DA;LEFT AND RIGHT DOUBLE TURNSTILE;Sm;0;ON;;;;;N;;;;;\n27DB;LEFT AND RIGHT TACK;Sm;0;ON;;;;;N;;;;;\n27DC;LEFT MULTIMAP;Sm;0;ON;;;;;Y;;;;;\n27DD;LONG RIGHT TACK;Sm;0;ON;;;;;Y;;;;;\n27DE;LONG LEFT TACK;Sm;0;ON;;;;;Y;;;;;\n27DF;UP TACK WITH CIRCLE ABOVE;Sm;0;ON;;;;;N;;;;;\n27E0;LOZENGE DIVIDED BY HORIZONTAL RULE;Sm;0;ON;;;;;N;;;;;\n27E1;WHITE CONCAVE-SIDED DIAMOND;Sm;0;ON;;;;;N;;;;;\n27E2;WHITE CONCAVE-SIDED DIAMOND WITH LEFTWARDS TICK;Sm;0;ON;;;;;Y;;;;;\n27E3;WHITE CONCAVE-SIDED DIAMOND WITH RIGHTWARDS TICK;Sm;0;ON;;;;;Y;;;;;\n27E4;WHITE SQUARE WITH LEFTWARDS TICK;Sm;0;ON;;;;;Y;;;;;\n27E5;WHITE SQUARE WITH RIGHTWARDS TICK;Sm;0;ON;;;;;Y;;;;;\n27E6;MATHEMATICAL LEFT WHITE SQUARE BRACKET;Ps;0;ON;;;;;Y;;;;;\n27E7;MATHEMATICAL RIGHT WHITE SQUARE BRACKET;Pe;0;ON;;;;;Y;;;;;\n27E8;MATHEMATICAL LEFT ANGLE BRACKET;Ps;0;ON;;;;;Y;;;;;\n27E9;MATHEMATICAL RIGHT ANGLE BRACKET;Pe;0;ON;;;;;Y;;;;;\n27EA;MATHEMATICAL LEFT DOUBLE ANGLE BRACKET;Ps;0;ON;;;;;Y;;;;;\n27EB;MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET;Pe;0;ON;;;;;Y;;;;;\n27EC;MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET;Ps;0;ON;;;;;Y;;;;;\n27ED;MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET;Pe;0;ON;;;;;Y;;;;;\n27EE;MATHEMATICAL LEFT FLATTENED PARENTHESIS;Ps;0;ON;;;;;Y;;;;;\n27EF;MATHEMATICAL RIGHT FLATTENED PARENTHESIS;Pe;0;ON;;;;;Y;;;;;\n27F0;UPWARDS QUADRUPLE ARROW;Sm;0;ON;;;;;N;;;;;\n27F1;DOWNWARDS QUADRUPLE ARROW;Sm;0;ON;;;;;N;;;;;\n27F2;ANTICLOCKWISE GAPPED CIRCLE ARROW;Sm;0;ON;;;;;N;;;;;\n27F3;CLOCKWISE GAPPED CIRCLE ARROW;Sm;0;ON;;;;;N;;;;;\n27F4;RIGHT ARROW WITH CIRCLED PLUS;Sm;0;ON;;;;;N;;;;;\n27F5;LONG LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n27F6;LONG RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n27F7;LONG LEFT RIGHT ARROW;Sm;0;ON;;;;;N;;;;;\n27F8;LONG LEFTWARDS DOUBLE ARROW;Sm;0;ON;;;;;N;;;;;\n27F9;LONG RIGHTWARDS DOUBLE ARROW;Sm;0;ON;;;;;N;;;;;\n27FA;LONG LEFT RIGHT DOUBLE ARROW;Sm;0;ON;;;;;N;;;;;\n27FB;LONG LEFTWARDS ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n27FC;LONG RIGHTWARDS ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n27FD;LONG LEFTWARDS DOUBLE ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n27FE;LONG RIGHTWARDS DOUBLE ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n27FF;LONG RIGHTWARDS SQUIGGLE ARROW;Sm;0;ON;;;;;N;;;;;\n2800;BRAILLE PATTERN BLANK;So;0;L;;;;;N;;;;;\n2801;BRAILLE PATTERN DOTS-1;So;0;L;;;;;N;;;;;\n2802;BRAILLE PATTERN DOTS-2;So;0;L;;;;;N;;;;;\n2803;BRAILLE PATTERN DOTS-12;So;0;L;;;;;N;;;;;\n2804;BRAILLE PATTERN DOTS-3;So;0;L;;;;;N;;;;;\n2805;BRAILLE PATTERN DOTS-13;So;0;L;;;;;N;;;;;\n2806;BRAILLE PATTERN DOTS-23;So;0;L;;;;;N;;;;;\n2807;BRAILLE PATTERN DOTS-123;So;0;L;;;;;N;;;;;\n2808;BRAILLE PATTERN DOTS-4;So;0;L;;;;;N;;;;;\n2809;BRAILLE PATTERN DOTS-14;So;0;L;;;;;N;;;;;\n280A;BRAILLE PATTERN DOTS-24;So;0;L;;;;;N;;;;;\n280B;BRAILLE PATTERN DOTS-124;So;0;L;;;;;N;;;;;\n280C;BRAILLE PATTERN DOTS-34;So;0;L;;;;;N;;;;;\n280D;BRAILLE PATTERN DOTS-134;So;0;L;;;;;N;;;;;\n280E;BRAILLE PATTERN DOTS-234;So;0;L;;;;;N;;;;;\n280F;BRAILLE PATTERN DOTS-1234;So;0;L;;;;;N;;;;;\n2810;BRAILLE PATTERN DOTS-5;So;0;L;;;;;N;;;;;\n2811;BRAILLE PATTERN DOTS-15;So;0;L;;;;;N;;;;;\n2812;BRAILLE PATTERN DOTS-25;So;0;L;;;;;N;;;;;\n2813;BRAILLE PATTERN DOTS-125;So;0;L;;;;;N;;;;;\n2814;BRAILLE PATTERN DOTS-35;So;0;L;;;;;N;;;;;\n2815;BRAILLE PATTERN DOTS-135;So;0;L;;;;;N;;;;;\n2816;BRAILLE PATTERN DOTS-235;So;0;L;;;;;N;;;;;\n2817;BRAILLE PATTERN DOTS-1235;So;0;L;;;;;N;;;;;\n2818;BRAILLE PATTERN DOTS-45;So;0;L;;;;;N;;;;;\n2819;BRAILLE PATTERN DOTS-145;So;0;L;;;;;N;;;;;\n281A;BRAILLE PATTERN DOTS-245;So;0;L;;;;;N;;;;;\n281B;BRAILLE PATTERN DOTS-1245;So;0;L;;;;;N;;;;;\n281C;BRAILLE PATTERN DOTS-345;So;0;L;;;;;N;;;;;\n281D;BRAILLE PATTERN DOTS-1345;So;0;L;;;;;N;;;;;\n281E;BRAILLE PATTERN DOTS-2345;So;0;L;;;;;N;;;;;\n281F;BRAILLE PATTERN DOTS-12345;So;0;L;;;;;N;;;;;\n2820;BRAILLE PATTERN DOTS-6;So;0;L;;;;;N;;;;;\n2821;BRAILLE PATTERN DOTS-16;So;0;L;;;;;N;;;;;\n2822;BRAILLE PATTERN DOTS-26;So;0;L;;;;;N;;;;;\n2823;BRAILLE PATTERN DOTS-126;So;0;L;;;;;N;;;;;\n2824;BRAILLE PATTERN DOTS-36;So;0;L;;;;;N;;;;;\n2825;BRAILLE PATTERN DOTS-136;So;0;L;;;;;N;;;;;\n2826;BRAILLE PATTERN DOTS-236;So;0;L;;;;;N;;;;;\n2827;BRAILLE PATTERN DOTS-1236;So;0;L;;;;;N;;;;;\n2828;BRAILLE PATTERN DOTS-46;So;0;L;;;;;N;;;;;\n2829;BRAILLE PATTERN DOTS-146;So;0;L;;;;;N;;;;;\n282A;BRAILLE PATTERN DOTS-246;So;0;L;;;;;N;;;;;\n282B;BRAILLE PATTERN DOTS-1246;So;0;L;;;;;N;;;;;\n282C;BRAILLE PATTERN DOTS-346;So;0;L;;;;;N;;;;;\n282D;BRAILLE PATTERN DOTS-1346;So;0;L;;;;;N;;;;;\n282E;BRAILLE PATTERN DOTS-2346;So;0;L;;;;;N;;;;;\n282F;BRAILLE PATTERN DOTS-12346;So;0;L;;;;;N;;;;;\n2830;BRAILLE PATTERN DOTS-56;So;0;L;;;;;N;;;;;\n2831;BRAILLE PATTERN DOTS-156;So;0;L;;;;;N;;;;;\n2832;BRAILLE PATTERN DOTS-256;So;0;L;;;;;N;;;;;\n2833;BRAILLE PATTERN DOTS-1256;So;0;L;;;;;N;;;;;\n2834;BRAILLE PATTERN DOTS-356;So;0;L;;;;;N;;;;;\n2835;BRAILLE PATTERN DOTS-1356;So;0;L;;;;;N;;;;;\n2836;BRAILLE PATTERN DOTS-2356;So;0;L;;;;;N;;;;;\n2837;BRAILLE PATTERN DOTS-12356;So;0;L;;;;;N;;;;;\n2838;BRAILLE PATTERN DOTS-456;So;0;L;;;;;N;;;;;\n2839;BRAILLE PATTERN DOTS-1456;So;0;L;;;;;N;;;;;\n283A;BRAILLE PATTERN DOTS-2456;So;0;L;;;;;N;;;;;\n283B;BRAILLE PATTERN DOTS-12456;So;0;L;;;;;N;;;;;\n283C;BRAILLE PATTERN DOTS-3456;So;0;L;;;;;N;;;;;\n283D;BRAILLE PATTERN DOTS-13456;So;0;L;;;;;N;;;;;\n283E;BRAILLE PATTERN DOTS-23456;So;0;L;;;;;N;;;;;\n283F;BRAILLE PATTERN DOTS-123456;So;0;L;;;;;N;;;;;\n2840;BRAILLE PATTERN DOTS-7;So;0;L;;;;;N;;;;;\n2841;BRAILLE PATTERN DOTS-17;So;0;L;;;;;N;;;;;\n2842;BRAILLE PATTERN DOTS-27;So;0;L;;;;;N;;;;;\n2843;BRAILLE PATTERN DOTS-127;So;0;L;;;;;N;;;;;\n2844;BRAILLE PATTERN DOTS-37;So;0;L;;;;;N;;;;;\n2845;BRAILLE PATTERN DOTS-137;So;0;L;;;;;N;;;;;\n2846;BRAILLE PATTERN DOTS-237;So;0;L;;;;;N;;;;;\n2847;BRAILLE PATTERN DOTS-1237;So;0;L;;;;;N;;;;;\n2848;BRAILLE PATTERN DOTS-47;So;0;L;;;;;N;;;;;\n2849;BRAILLE PATTERN DOTS-147;So;0;L;;;;;N;;;;;\n284A;BRAILLE PATTERN DOTS-247;So;0;L;;;;;N;;;;;\n284B;BRAILLE PATTERN DOTS-1247;So;0;L;;;;;N;;;;;\n284C;BRAILLE PATTERN DOTS-347;So;0;L;;;;;N;;;;;\n284D;BRAILLE PATTERN DOTS-1347;So;0;L;;;;;N;;;;;\n284E;BRAILLE PATTERN DOTS-2347;So;0;L;;;;;N;;;;;\n284F;BRAILLE PATTERN DOTS-12347;So;0;L;;;;;N;;;;;\n2850;BRAILLE PATTERN DOTS-57;So;0;L;;;;;N;;;;;\n2851;BRAILLE PATTERN DOTS-157;So;0;L;;;;;N;;;;;\n2852;BRAILLE PATTERN DOTS-257;So;0;L;;;;;N;;;;;\n2853;BRAILLE PATTERN DOTS-1257;So;0;L;;;;;N;;;;;\n2854;BRAILLE PATTERN DOTS-357;So;0;L;;;;;N;;;;;\n2855;BRAILLE PATTERN DOTS-1357;So;0;L;;;;;N;;;;;\n2856;BRAILLE PATTERN DOTS-2357;So;0;L;;;;;N;;;;;\n2857;BRAILLE PATTERN DOTS-12357;So;0;L;;;;;N;;;;;\n2858;BRAILLE PATTERN DOTS-457;So;0;L;;;;;N;;;;;\n2859;BRAILLE PATTERN DOTS-1457;So;0;L;;;;;N;;;;;\n285A;BRAILLE PATTERN DOTS-2457;So;0;L;;;;;N;;;;;\n285B;BRAILLE PATTERN DOTS-12457;So;0;L;;;;;N;;;;;\n285C;BRAILLE PATTERN DOTS-3457;So;0;L;;;;;N;;;;;\n285D;BRAILLE PATTERN DOTS-13457;So;0;L;;;;;N;;;;;\n285E;BRAILLE PATTERN DOTS-23457;So;0;L;;;;;N;;;;;\n285F;BRAILLE PATTERN DOTS-123457;So;0;L;;;;;N;;;;;\n2860;BRAILLE PATTERN DOTS-67;So;0;L;;;;;N;;;;;\n2861;BRAILLE PATTERN DOTS-167;So;0;L;;;;;N;;;;;\n2862;BRAILLE PATTERN DOTS-267;So;0;L;;;;;N;;;;;\n2863;BRAILLE PATTERN DOTS-1267;So;0;L;;;;;N;;;;;\n2864;BRAILLE PATTERN DOTS-367;So;0;L;;;;;N;;;;;\n2865;BRAILLE PATTERN DOTS-1367;So;0;L;;;;;N;;;;;\n2866;BRAILLE PATTERN DOTS-2367;So;0;L;;;;;N;;;;;\n2867;BRAILLE PATTERN DOTS-12367;So;0;L;;;;;N;;;;;\n2868;BRAILLE PATTERN DOTS-467;So;0;L;;;;;N;;;;;\n2869;BRAILLE PATTERN DOTS-1467;So;0;L;;;;;N;;;;;\n286A;BRAILLE PATTERN DOTS-2467;So;0;L;;;;;N;;;;;\n286B;BRAILLE PATTERN DOTS-12467;So;0;L;;;;;N;;;;;\n286C;BRAILLE PATTERN DOTS-3467;So;0;L;;;;;N;;;;;\n286D;BRAILLE PATTERN DOTS-13467;So;0;L;;;;;N;;;;;\n286E;BRAILLE PATTERN DOTS-23467;So;0;L;;;;;N;;;;;\n286F;BRAILLE PATTERN DOTS-123467;So;0;L;;;;;N;;;;;\n2870;BRAILLE PATTERN DOTS-567;So;0;L;;;;;N;;;;;\n2871;BRAILLE PATTERN DOTS-1567;So;0;L;;;;;N;;;;;\n2872;BRAILLE PATTERN DOTS-2567;So;0;L;;;;;N;;;;;\n2873;BRAILLE PATTERN DOTS-12567;So;0;L;;;;;N;;;;;\n2874;BRAILLE PATTERN DOTS-3567;So;0;L;;;;;N;;;;;\n2875;BRAILLE PATTERN DOTS-13567;So;0;L;;;;;N;;;;;\n2876;BRAILLE PATTERN DOTS-23567;So;0;L;;;;;N;;;;;\n2877;BRAILLE PATTERN DOTS-123567;So;0;L;;;;;N;;;;;\n2878;BRAILLE PATTERN DOTS-4567;So;0;L;;;;;N;;;;;\n2879;BRAILLE PATTERN DOTS-14567;So;0;L;;;;;N;;;;;\n287A;BRAILLE PATTERN DOTS-24567;So;0;L;;;;;N;;;;;\n287B;BRAILLE PATTERN DOTS-124567;So;0;L;;;;;N;;;;;\n287C;BRAILLE PATTERN DOTS-34567;So;0;L;;;;;N;;;;;\n287D;BRAILLE PATTERN DOTS-134567;So;0;L;;;;;N;;;;;\n287E;BRAILLE PATTERN DOTS-234567;So;0;L;;;;;N;;;;;\n287F;BRAILLE PATTERN DOTS-1234567;So;0;L;;;;;N;;;;;\n2880;BRAILLE PATTERN DOTS-8;So;0;L;;;;;N;;;;;\n2881;BRAILLE PATTERN DOTS-18;So;0;L;;;;;N;;;;;\n2882;BRAILLE PATTERN DOTS-28;So;0;L;;;;;N;;;;;\n2883;BRAILLE PATTERN DOTS-128;So;0;L;;;;;N;;;;;\n2884;BRAILLE PATTERN DOTS-38;So;0;L;;;;;N;;;;;\n2885;BRAILLE PATTERN DOTS-138;So;0;L;;;;;N;;;;;\n2886;BRAILLE PATTERN DOTS-238;So;0;L;;;;;N;;;;;\n2887;BRAILLE PATTERN DOTS-1238;So;0;L;;;;;N;;;;;\n2888;BRAILLE PATTERN DOTS-48;So;0;L;;;;;N;;;;;\n2889;BRAILLE PATTERN DOTS-148;So;0;L;;;;;N;;;;;\n288A;BRAILLE PATTERN DOTS-248;So;0;L;;;;;N;;;;;\n288B;BRAILLE PATTERN DOTS-1248;So;0;L;;;;;N;;;;;\n288C;BRAILLE PATTERN DOTS-348;So;0;L;;;;;N;;;;;\n288D;BRAILLE PATTERN DOTS-1348;So;0;L;;;;;N;;;;;\n288E;BRAILLE PATTERN DOTS-2348;So;0;L;;;;;N;;;;;\n288F;BRAILLE PATTERN DOTS-12348;So;0;L;;;;;N;;;;;\n2890;BRAILLE PATTERN DOTS-58;So;0;L;;;;;N;;;;;\n2891;BRAILLE PATTERN DOTS-158;So;0;L;;;;;N;;;;;\n2892;BRAILLE PATTERN DOTS-258;So;0;L;;;;;N;;;;;\n2893;BRAILLE PATTERN DOTS-1258;So;0;L;;;;;N;;;;;\n2894;BRAILLE PATTERN DOTS-358;So;0;L;;;;;N;;;;;\n2895;BRAILLE PATTERN DOTS-1358;So;0;L;;;;;N;;;;;\n2896;BRAILLE PATTERN DOTS-2358;So;0;L;;;;;N;;;;;\n2897;BRAILLE PATTERN DOTS-12358;So;0;L;;;;;N;;;;;\n2898;BRAILLE PATTERN DOTS-458;So;0;L;;;;;N;;;;;\n2899;BRAILLE PATTERN DOTS-1458;So;0;L;;;;;N;;;;;\n289A;BRAILLE PATTERN DOTS-2458;So;0;L;;;;;N;;;;;\n289B;BRAILLE PATTERN DOTS-12458;So;0;L;;;;;N;;;;;\n289C;BRAILLE PATTERN DOTS-3458;So;0;L;;;;;N;;;;;\n289D;BRAILLE PATTERN DOTS-13458;So;0;L;;;;;N;;;;;\n289E;BRAILLE PATTERN DOTS-23458;So;0;L;;;;;N;;;;;\n289F;BRAILLE PATTERN DOTS-123458;So;0;L;;;;;N;;;;;\n28A0;BRAILLE PATTERN DOTS-68;So;0;L;;;;;N;;;;;\n28A1;BRAILLE PATTERN DOTS-168;So;0;L;;;;;N;;;;;\n28A2;BRAILLE PATTERN DOTS-268;So;0;L;;;;;N;;;;;\n28A3;BRAILLE PATTERN DOTS-1268;So;0;L;;;;;N;;;;;\n28A4;BRAILLE PATTERN DOTS-368;So;0;L;;;;;N;;;;;\n28A5;BRAILLE PATTERN DOTS-1368;So;0;L;;;;;N;;;;;\n28A6;BRAILLE PATTERN DOTS-2368;So;0;L;;;;;N;;;;;\n28A7;BRAILLE PATTERN DOTS-12368;So;0;L;;;;;N;;;;;\n28A8;BRAILLE PATTERN DOTS-468;So;0;L;;;;;N;;;;;\n28A9;BRAILLE PATTERN DOTS-1468;So;0;L;;;;;N;;;;;\n28AA;BRAILLE PATTERN DOTS-2468;So;0;L;;;;;N;;;;;\n28AB;BRAILLE PATTERN DOTS-12468;So;0;L;;;;;N;;;;;\n28AC;BRAILLE PATTERN DOTS-3468;So;0;L;;;;;N;;;;;\n28AD;BRAILLE PATTERN DOTS-13468;So;0;L;;;;;N;;;;;\n28AE;BRAILLE PATTERN DOTS-23468;So;0;L;;;;;N;;;;;\n28AF;BRAILLE PATTERN DOTS-123468;So;0;L;;;;;N;;;;;\n28B0;BRAILLE PATTERN DOTS-568;So;0;L;;;;;N;;;;;\n28B1;BRAILLE PATTERN DOTS-1568;So;0;L;;;;;N;;;;;\n28B2;BRAILLE PATTERN DOTS-2568;So;0;L;;;;;N;;;;;\n28B3;BRAILLE PATTERN DOTS-12568;So;0;L;;;;;N;;;;;\n28B4;BRAILLE PATTERN DOTS-3568;So;0;L;;;;;N;;;;;\n28B5;BRAILLE PATTERN DOTS-13568;So;0;L;;;;;N;;;;;\n28B6;BRAILLE PATTERN DOTS-23568;So;0;L;;;;;N;;;;;\n28B7;BRAILLE PATTERN DOTS-123568;So;0;L;;;;;N;;;;;\n28B8;BRAILLE PATTERN DOTS-4568;So;0;L;;;;;N;;;;;\n28B9;BRAILLE PATTERN DOTS-14568;So;0;L;;;;;N;;;;;\n28BA;BRAILLE PATTERN DOTS-24568;So;0;L;;;;;N;;;;;\n28BB;BRAILLE PATTERN DOTS-124568;So;0;L;;;;;N;;;;;\n28BC;BRAILLE PATTERN DOTS-34568;So;0;L;;;;;N;;;;;\n28BD;BRAILLE PATTERN DOTS-134568;So;0;L;;;;;N;;;;;\n28BE;BRAILLE PATTERN DOTS-234568;So;0;L;;;;;N;;;;;\n28BF;BRAILLE PATTERN DOTS-1234568;So;0;L;;;;;N;;;;;\n28C0;BRAILLE PATTERN DOTS-78;So;0;L;;;;;N;;;;;\n28C1;BRAILLE PATTERN DOTS-178;So;0;L;;;;;N;;;;;\n28C2;BRAILLE PATTERN DOTS-278;So;0;L;;;;;N;;;;;\n28C3;BRAILLE PATTERN DOTS-1278;So;0;L;;;;;N;;;;;\n28C4;BRAILLE PATTERN DOTS-378;So;0;L;;;;;N;;;;;\n28C5;BRAILLE PATTERN DOTS-1378;So;0;L;;;;;N;;;;;\n28C6;BRAILLE PATTERN DOTS-2378;So;0;L;;;;;N;;;;;\n28C7;BRAILLE PATTERN DOTS-12378;So;0;L;;;;;N;;;;;\n28C8;BRAILLE PATTERN DOTS-478;So;0;L;;;;;N;;;;;\n28C9;BRAILLE PATTERN DOTS-1478;So;0;L;;;;;N;;;;;\n28CA;BRAILLE PATTERN DOTS-2478;So;0;L;;;;;N;;;;;\n28CB;BRAILLE PATTERN DOTS-12478;So;0;L;;;;;N;;;;;\n28CC;BRAILLE PATTERN DOTS-3478;So;0;L;;;;;N;;;;;\n28CD;BRAILLE PATTERN DOTS-13478;So;0;L;;;;;N;;;;;\n28CE;BRAILLE PATTERN DOTS-23478;So;0;L;;;;;N;;;;;\n28CF;BRAILLE PATTERN DOTS-123478;So;0;L;;;;;N;;;;;\n28D0;BRAILLE PATTERN DOTS-578;So;0;L;;;;;N;;;;;\n28D1;BRAILLE PATTERN DOTS-1578;So;0;L;;;;;N;;;;;\n28D2;BRAILLE PATTERN DOTS-2578;So;0;L;;;;;N;;;;;\n28D3;BRAILLE PATTERN DOTS-12578;So;0;L;;;;;N;;;;;\n28D4;BRAILLE PATTERN DOTS-3578;So;0;L;;;;;N;;;;;\n28D5;BRAILLE PATTERN DOTS-13578;So;0;L;;;;;N;;;;;\n28D6;BRAILLE PATTERN DOTS-23578;So;0;L;;;;;N;;;;;\n28D7;BRAILLE PATTERN DOTS-123578;So;0;L;;;;;N;;;;;\n28D8;BRAILLE PATTERN DOTS-4578;So;0;L;;;;;N;;;;;\n28D9;BRAILLE PATTERN DOTS-14578;So;0;L;;;;;N;;;;;\n28DA;BRAILLE PATTERN DOTS-24578;So;0;L;;;;;N;;;;;\n28DB;BRAILLE PATTERN DOTS-124578;So;0;L;;;;;N;;;;;\n28DC;BRAILLE PATTERN DOTS-34578;So;0;L;;;;;N;;;;;\n28DD;BRAILLE PATTERN DOTS-134578;So;0;L;;;;;N;;;;;\n28DE;BRAILLE PATTERN DOTS-234578;So;0;L;;;;;N;;;;;\n28DF;BRAILLE PATTERN DOTS-1234578;So;0;L;;;;;N;;;;;\n28E0;BRAILLE PATTERN DOTS-678;So;0;L;;;;;N;;;;;\n28E1;BRAILLE PATTERN DOTS-1678;So;0;L;;;;;N;;;;;\n28E2;BRAILLE PATTERN DOTS-2678;So;0;L;;;;;N;;;;;\n28E3;BRAILLE PATTERN DOTS-12678;So;0;L;;;;;N;;;;;\n28E4;BRAILLE PATTERN DOTS-3678;So;0;L;;;;;N;;;;;\n28E5;BRAILLE PATTERN DOTS-13678;So;0;L;;;;;N;;;;;\n28E6;BRAILLE PATTERN DOTS-23678;So;0;L;;;;;N;;;;;\n28E7;BRAILLE PATTERN DOTS-123678;So;0;L;;;;;N;;;;;\n28E8;BRAILLE PATTERN DOTS-4678;So;0;L;;;;;N;;;;;\n28E9;BRAILLE PATTERN DOTS-14678;So;0;L;;;;;N;;;;;\n28EA;BRAILLE PATTERN DOTS-24678;So;0;L;;;;;N;;;;;\n28EB;BRAILLE PATTERN DOTS-124678;So;0;L;;;;;N;;;;;\n28EC;BRAILLE PATTERN DOTS-34678;So;0;L;;;;;N;;;;;\n28ED;BRAILLE PATTERN DOTS-134678;So;0;L;;;;;N;;;;;\n28EE;BRAILLE PATTERN DOTS-234678;So;0;L;;;;;N;;;;;\n28EF;BRAILLE PATTERN DOTS-1234678;So;0;L;;;;;N;;;;;\n28F0;BRAILLE PATTERN DOTS-5678;So;0;L;;;;;N;;;;;\n28F1;BRAILLE PATTERN DOTS-15678;So;0;L;;;;;N;;;;;\n28F2;BRAILLE PATTERN DOTS-25678;So;0;L;;;;;N;;;;;\n28F3;BRAILLE PATTERN DOTS-125678;So;0;L;;;;;N;;;;;\n28F4;BRAILLE PATTERN DOTS-35678;So;0;L;;;;;N;;;;;\n28F5;BRAILLE PATTERN DOTS-135678;So;0;L;;;;;N;;;;;\n28F6;BRAILLE PATTERN DOTS-235678;So;0;L;;;;;N;;;;;\n28F7;BRAILLE PATTERN DOTS-1235678;So;0;L;;;;;N;;;;;\n28F8;BRAILLE PATTERN DOTS-45678;So;0;L;;;;;N;;;;;\n28F9;BRAILLE PATTERN DOTS-145678;So;0;L;;;;;N;;;;;\n28FA;BRAILLE PATTERN DOTS-245678;So;0;L;;;;;N;;;;;\n28FB;BRAILLE PATTERN DOTS-1245678;So;0;L;;;;;N;;;;;\n28FC;BRAILLE PATTERN DOTS-345678;So;0;L;;;;;N;;;;;\n28FD;BRAILLE PATTERN DOTS-1345678;So;0;L;;;;;N;;;;;\n28FE;BRAILLE PATTERN DOTS-2345678;So;0;L;;;;;N;;;;;\n28FF;BRAILLE PATTERN DOTS-12345678;So;0;L;;;;;N;;;;;\n2900;RIGHTWARDS TWO-HEADED ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2901;RIGHTWARDS TWO-HEADED ARROW WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2902;LEFTWARDS DOUBLE ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2903;RIGHTWARDS DOUBLE ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2904;LEFT RIGHT DOUBLE ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2905;RIGHTWARDS TWO-HEADED ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n2906;LEFTWARDS DOUBLE ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n2907;RIGHTWARDS DOUBLE ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n2908;DOWNWARDS ARROW WITH HORIZONTAL STROKE;Sm;0;ON;;;;;N;;;;;\n2909;UPWARDS ARROW WITH HORIZONTAL STROKE;Sm;0;ON;;;;;N;;;;;\n290A;UPWARDS TRIPLE ARROW;Sm;0;ON;;;;;N;;;;;\n290B;DOWNWARDS TRIPLE ARROW;Sm;0;ON;;;;;N;;;;;\n290C;LEFTWARDS DOUBLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n290D;RIGHTWARDS DOUBLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n290E;LEFTWARDS TRIPLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n290F;RIGHTWARDS TRIPLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n2910;RIGHTWARDS TWO-HEADED TRIPLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n2911;RIGHTWARDS ARROW WITH DOTTED STEM;Sm;0;ON;;;;;N;;;;;\n2912;UPWARDS ARROW TO BAR;Sm;0;ON;;;;;N;;;;;\n2913;DOWNWARDS ARROW TO BAR;Sm;0;ON;;;;;N;;;;;\n2914;RIGHTWARDS ARROW WITH TAIL WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2915;RIGHTWARDS ARROW WITH TAIL WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2916;RIGHTWARDS TWO-HEADED ARROW WITH TAIL;Sm;0;ON;;;;;N;;;;;\n2917;RIGHTWARDS TWO-HEADED ARROW WITH TAIL WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2918;RIGHTWARDS TWO-HEADED ARROW WITH TAIL WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2919;LEFTWARDS ARROW-TAIL;Sm;0;ON;;;;;N;;;;;\n291A;RIGHTWARDS ARROW-TAIL;Sm;0;ON;;;;;N;;;;;\n291B;LEFTWARDS DOUBLE ARROW-TAIL;Sm;0;ON;;;;;N;;;;;\n291C;RIGHTWARDS DOUBLE ARROW-TAIL;Sm;0;ON;;;;;N;;;;;\n291D;LEFTWARDS ARROW TO BLACK DIAMOND;Sm;0;ON;;;;;N;;;;;\n291E;RIGHTWARDS ARROW TO BLACK DIAMOND;Sm;0;ON;;;;;N;;;;;\n291F;LEFTWARDS ARROW FROM BAR TO BLACK DIAMOND;Sm;0;ON;;;;;N;;;;;\n2920;RIGHTWARDS ARROW FROM BAR TO BLACK DIAMOND;Sm;0;ON;;;;;N;;;;;\n2921;NORTH WEST AND SOUTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2922;NORTH EAST AND SOUTH WEST ARROW;Sm;0;ON;;;;;N;;;;;\n2923;NORTH WEST ARROW WITH HOOK;Sm;0;ON;;;;;N;;;;;\n2924;NORTH EAST ARROW WITH HOOK;Sm;0;ON;;;;;N;;;;;\n2925;SOUTH EAST ARROW WITH HOOK;Sm;0;ON;;;;;N;;;;;\n2926;SOUTH WEST ARROW WITH HOOK;Sm;0;ON;;;;;N;;;;;\n2927;NORTH WEST ARROW AND NORTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2928;NORTH EAST ARROW AND SOUTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2929;SOUTH EAST ARROW AND SOUTH WEST ARROW;Sm;0;ON;;;;;N;;;;;\n292A;SOUTH WEST ARROW AND NORTH WEST ARROW;Sm;0;ON;;;;;N;;;;;\n292B;RISING DIAGONAL CROSSING FALLING DIAGONAL;Sm;0;ON;;;;;N;;;;;\n292C;FALLING DIAGONAL CROSSING RISING DIAGONAL;Sm;0;ON;;;;;N;;;;;\n292D;SOUTH EAST ARROW CROSSING NORTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n292E;NORTH EAST ARROW CROSSING SOUTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n292F;FALLING DIAGONAL CROSSING NORTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2930;RISING DIAGONAL CROSSING SOUTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2931;NORTH EAST ARROW CROSSING NORTH WEST ARROW;Sm;0;ON;;;;;N;;;;;\n2932;NORTH WEST ARROW CROSSING NORTH EAST ARROW;Sm;0;ON;;;;;N;;;;;\n2933;WAVE ARROW POINTING DIRECTLY RIGHT;Sm;0;ON;;;;;N;;;;;\n2934;ARROW POINTING RIGHTWARDS THEN CURVING UPWARDS;Sm;0;ON;;;;;N;;;;;\n2935;ARROW POINTING RIGHTWARDS THEN CURVING DOWNWARDS;Sm;0;ON;;;;;N;;;;;\n2936;ARROW POINTING DOWNWARDS THEN CURVING LEFTWARDS;Sm;0;ON;;;;;N;;;;;\n2937;ARROW POINTING DOWNWARDS THEN CURVING RIGHTWARDS;Sm;0;ON;;;;;N;;;;;\n2938;RIGHT-SIDE ARC CLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n2939;LEFT-SIDE ARC ANTICLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n293A;TOP ARC ANTICLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n293B;BOTTOM ARC ANTICLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n293C;TOP ARC CLOCKWISE ARROW WITH MINUS;Sm;0;ON;;;;;N;;;;;\n293D;TOP ARC ANTICLOCKWISE ARROW WITH PLUS;Sm;0;ON;;;;;N;;;;;\n293E;LOWER RIGHT SEMICIRCULAR CLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n293F;LOWER LEFT SEMICIRCULAR ANTICLOCKWISE ARROW;Sm;0;ON;;;;;N;;;;;\n2940;ANTICLOCKWISE CLOSED CIRCLE ARROW;Sm;0;ON;;;;;N;;;;;\n2941;CLOCKWISE CLOSED CIRCLE ARROW;Sm;0;ON;;;;;N;;;;;\n2942;RIGHTWARDS ARROW ABOVE SHORT LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2943;LEFTWARDS ARROW ABOVE SHORT RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2944;SHORT RIGHTWARDS ARROW ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2945;RIGHTWARDS ARROW WITH PLUS BELOW;Sm;0;ON;;;;;N;;;;;\n2946;LEFTWARDS ARROW WITH PLUS BELOW;Sm;0;ON;;;;;N;;;;;\n2947;RIGHTWARDS ARROW THROUGH X;Sm;0;ON;;;;;N;;;;;\n2948;LEFT RIGHT ARROW THROUGH SMALL CIRCLE;Sm;0;ON;;;;;N;;;;;\n2949;UPWARDS TWO-HEADED ARROW FROM SMALL CIRCLE;Sm;0;ON;;;;;N;;;;;\n294A;LEFT BARB UP RIGHT BARB DOWN HARPOON;Sm;0;ON;;;;;N;;;;;\n294B;LEFT BARB DOWN RIGHT BARB UP HARPOON;Sm;0;ON;;;;;N;;;;;\n294C;UP BARB RIGHT DOWN BARB LEFT HARPOON;Sm;0;ON;;;;;N;;;;;\n294D;UP BARB LEFT DOWN BARB RIGHT HARPOON;Sm;0;ON;;;;;N;;;;;\n294E;LEFT BARB UP RIGHT BARB UP HARPOON;Sm;0;ON;;;;;N;;;;;\n294F;UP BARB RIGHT DOWN BARB RIGHT HARPOON;Sm;0;ON;;;;;N;;;;;\n2950;LEFT BARB DOWN RIGHT BARB DOWN HARPOON;Sm;0;ON;;;;;N;;;;;\n2951;UP BARB LEFT DOWN BARB LEFT HARPOON;Sm;0;ON;;;;;N;;;;;\n2952;LEFTWARDS HARPOON WITH BARB UP TO BAR;Sm;0;ON;;;;;N;;;;;\n2953;RIGHTWARDS HARPOON WITH BARB UP TO BAR;Sm;0;ON;;;;;N;;;;;\n2954;UPWARDS HARPOON WITH BARB RIGHT TO BAR;Sm;0;ON;;;;;N;;;;;\n2955;DOWNWARDS HARPOON WITH BARB RIGHT TO BAR;Sm;0;ON;;;;;N;;;;;\n2956;LEFTWARDS HARPOON WITH BARB DOWN TO BAR;Sm;0;ON;;;;;N;;;;;\n2957;RIGHTWARDS HARPOON WITH BARB DOWN TO BAR;Sm;0;ON;;;;;N;;;;;\n2958;UPWARDS HARPOON WITH BARB LEFT TO BAR;Sm;0;ON;;;;;N;;;;;\n2959;DOWNWARDS HARPOON WITH BARB LEFT TO BAR;Sm;0;ON;;;;;N;;;;;\n295A;LEFTWARDS HARPOON WITH BARB UP FROM BAR;Sm;0;ON;;;;;N;;;;;\n295B;RIGHTWARDS HARPOON WITH BARB UP FROM BAR;Sm;0;ON;;;;;N;;;;;\n295C;UPWARDS HARPOON WITH BARB RIGHT FROM BAR;Sm;0;ON;;;;;N;;;;;\n295D;DOWNWARDS HARPOON WITH BARB RIGHT FROM BAR;Sm;0;ON;;;;;N;;;;;\n295E;LEFTWARDS HARPOON WITH BARB DOWN FROM BAR;Sm;0;ON;;;;;N;;;;;\n295F;RIGHTWARDS HARPOON WITH BARB DOWN FROM BAR;Sm;0;ON;;;;;N;;;;;\n2960;UPWARDS HARPOON WITH BARB LEFT FROM BAR;Sm;0;ON;;;;;N;;;;;\n2961;DOWNWARDS HARPOON WITH BARB LEFT FROM BAR;Sm;0;ON;;;;;N;;;;;\n2962;LEFTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB DOWN;Sm;0;ON;;;;;N;;;;;\n2963;UPWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT;Sm;0;ON;;;;;N;;;;;\n2964;RIGHTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB DOWN;Sm;0;ON;;;;;N;;;;;\n2965;DOWNWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT;Sm;0;ON;;;;;N;;;;;\n2966;LEFTWARDS HARPOON WITH BARB UP ABOVE RIGHTWARDS HARPOON WITH BARB UP;Sm;0;ON;;;;;N;;;;;\n2967;LEFTWARDS HARPOON WITH BARB DOWN ABOVE RIGHTWARDS HARPOON WITH BARB DOWN;Sm;0;ON;;;;;N;;;;;\n2968;RIGHTWARDS HARPOON WITH BARB UP ABOVE LEFTWARDS HARPOON WITH BARB UP;Sm;0;ON;;;;;N;;;;;\n2969;RIGHTWARDS HARPOON WITH BARB DOWN ABOVE LEFTWARDS HARPOON WITH BARB DOWN;Sm;0;ON;;;;;N;;;;;\n296A;LEFTWARDS HARPOON WITH BARB UP ABOVE LONG DASH;Sm;0;ON;;;;;N;;;;;\n296B;LEFTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH;Sm;0;ON;;;;;N;;;;;\n296C;RIGHTWARDS HARPOON WITH BARB UP ABOVE LONG DASH;Sm;0;ON;;;;;N;;;;;\n296D;RIGHTWARDS HARPOON WITH BARB DOWN BELOW LONG DASH;Sm;0;ON;;;;;N;;;;;\n296E;UPWARDS HARPOON WITH BARB LEFT BESIDE DOWNWARDS HARPOON WITH BARB RIGHT;Sm;0;ON;;;;;N;;;;;\n296F;DOWNWARDS HARPOON WITH BARB LEFT BESIDE UPWARDS HARPOON WITH BARB RIGHT;Sm;0;ON;;;;;N;;;;;\n2970;RIGHT DOUBLE ARROW WITH ROUNDED HEAD;Sm;0;ON;;;;;N;;;;;\n2971;EQUALS SIGN ABOVE RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2972;TILDE OPERATOR ABOVE RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2973;LEFTWARDS ARROW ABOVE TILDE OPERATOR;Sm;0;ON;;;;;N;;;;;\n2974;RIGHTWARDS ARROW ABOVE TILDE OPERATOR;Sm;0;ON;;;;;N;;;;;\n2975;RIGHTWARDS ARROW ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2976;LESS-THAN ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2977;LEFTWARDS ARROW THROUGH LESS-THAN;Sm;0;ON;;;;;N;;;;;\n2978;GREATER-THAN ABOVE RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2979;SUBSET ABOVE RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n297A;LEFTWARDS ARROW THROUGH SUBSET;Sm;0;ON;;;;;N;;;;;\n297B;SUPERSET ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n297C;LEFT FISH TAIL;Sm;0;ON;;;;;N;;;;;\n297D;RIGHT FISH TAIL;Sm;0;ON;;;;;N;;;;;\n297E;UP FISH TAIL;Sm;0;ON;;;;;N;;;;;\n297F;DOWN FISH TAIL;Sm;0;ON;;;;;N;;;;;\n2980;TRIPLE VERTICAL BAR DELIMITER;Sm;0;ON;;;;;N;;;;;\n2981;Z NOTATION SPOT;Sm;0;ON;;;;;N;;;;;\n2982;Z NOTATION TYPE COLON;Sm;0;ON;;;;;N;;;;;\n2983;LEFT WHITE CURLY BRACKET;Ps;0;ON;;;;;Y;;;;;\n2984;RIGHT WHITE CURLY BRACKET;Pe;0;ON;;;;;Y;;;;;\n2985;LEFT WHITE PARENTHESIS;Ps;0;ON;;;;;Y;;;;;\n2986;RIGHT WHITE PARENTHESIS;Pe;0;ON;;;;;Y;;;;;\n2987;Z NOTATION LEFT IMAGE BRACKET;Ps;0;ON;;;;;Y;;;;;\n2988;Z NOTATION RIGHT IMAGE BRACKET;Pe;0;ON;;;;;Y;;;;;\n2989;Z NOTATION LEFT BINDING BRACKET;Ps;0;ON;;;;;Y;;;;;\n298A;Z NOTATION RIGHT BINDING BRACKET;Pe;0;ON;;;;;Y;;;;;\n298B;LEFT SQUARE BRACKET WITH UNDERBAR;Ps;0;ON;;;;;Y;;;;;\n298C;RIGHT SQUARE BRACKET WITH UNDERBAR;Pe;0;ON;;;;;Y;;;;;\n298D;LEFT SQUARE BRACKET WITH TICK IN TOP CORNER;Ps;0;ON;;;;;Y;;;;;\n298E;RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER;Pe;0;ON;;;;;Y;;;;;\n298F;LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER;Ps;0;ON;;;;;Y;;;;;\n2990;RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER;Pe;0;ON;;;;;Y;;;;;\n2991;LEFT ANGLE BRACKET WITH DOT;Ps;0;ON;;;;;Y;;;;;\n2992;RIGHT ANGLE BRACKET WITH DOT;Pe;0;ON;;;;;Y;;;;;\n2993;LEFT ARC LESS-THAN BRACKET;Ps;0;ON;;;;;Y;;;;;\n2994;RIGHT ARC GREATER-THAN BRACKET;Pe;0;ON;;;;;Y;;;;;\n2995;DOUBLE LEFT ARC GREATER-THAN BRACKET;Ps;0;ON;;;;;Y;;;;;\n2996;DOUBLE RIGHT ARC LESS-THAN BRACKET;Pe;0;ON;;;;;Y;;;;;\n2997;LEFT BLACK TORTOISE SHELL BRACKET;Ps;0;ON;;;;;Y;;;;;\n2998;RIGHT BLACK TORTOISE SHELL BRACKET;Pe;0;ON;;;;;Y;;;;;\n2999;DOTTED FENCE;Sm;0;ON;;;;;N;;;;;\n299A;VERTICAL ZIGZAG LINE;Sm;0;ON;;;;;N;;;;;\n299B;MEASURED ANGLE OPENING LEFT;Sm;0;ON;;;;;Y;;;;;\n299C;RIGHT ANGLE VARIANT WITH SQUARE;Sm;0;ON;;;;;Y;;;;;\n299D;MEASURED RIGHT ANGLE WITH DOT;Sm;0;ON;;;;;Y;;;;;\n299E;ANGLE WITH S INSIDE;Sm;0;ON;;;;;Y;;;;;\n299F;ACUTE ANGLE;Sm;0;ON;;;;;Y;;;;;\n29A0;SPHERICAL ANGLE OPENING LEFT;Sm;0;ON;;;;;Y;;;;;\n29A1;SPHERICAL ANGLE OPENING UP;Sm;0;ON;;;;;Y;;;;;\n29A2;TURNED ANGLE;Sm;0;ON;;;;;Y;;;;;\n29A3;REVERSED ANGLE;Sm;0;ON;;;;;Y;;;;;\n29A4;ANGLE WITH UNDERBAR;Sm;0;ON;;;;;Y;;;;;\n29A5;REVERSED ANGLE WITH UNDERBAR;Sm;0;ON;;;;;Y;;;;;\n29A6;OBLIQUE ANGLE OPENING UP;Sm;0;ON;;;;;Y;;;;;\n29A7;OBLIQUE ANGLE OPENING DOWN;Sm;0;ON;;;;;Y;;;;;\n29A8;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND RIGHT;Sm;0;ON;;;;;Y;;;;;\n29A9;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING UP AND LEFT;Sm;0;ON;;;;;Y;;;;;\n29AA;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND RIGHT;Sm;0;ON;;;;;Y;;;;;\n29AB;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING DOWN AND LEFT;Sm;0;ON;;;;;Y;;;;;\n29AC;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND UP;Sm;0;ON;;;;;Y;;;;;\n29AD;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND UP;Sm;0;ON;;;;;Y;;;;;\n29AE;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING RIGHT AND DOWN;Sm;0;ON;;;;;Y;;;;;\n29AF;MEASURED ANGLE WITH OPEN ARM ENDING IN ARROW POINTING LEFT AND DOWN;Sm;0;ON;;;;;Y;;;;;\n29B0;REVERSED EMPTY SET;Sm;0;ON;;;;;N;;;;;\n29B1;EMPTY SET WITH OVERBAR;Sm;0;ON;;;;;N;;;;;\n29B2;EMPTY SET WITH SMALL CIRCLE ABOVE;Sm;0;ON;;;;;N;;;;;\n29B3;EMPTY SET WITH RIGHT ARROW ABOVE;Sm;0;ON;;;;;N;;;;;\n29B4;EMPTY SET WITH LEFT ARROW ABOVE;Sm;0;ON;;;;;N;;;;;\n29B5;CIRCLE WITH HORIZONTAL BAR;Sm;0;ON;;;;;N;;;;;\n29B6;CIRCLED VERTICAL BAR;Sm;0;ON;;;;;N;;;;;\n29B7;CIRCLED PARALLEL;Sm;0;ON;;;;;N;;;;;\n29B8;CIRCLED REVERSE SOLIDUS;Sm;0;ON;;;;;Y;;;;;\n29B9;CIRCLED PERPENDICULAR;Sm;0;ON;;;;;N;;;;;\n29BA;CIRCLE DIVIDED BY HORIZONTAL BAR AND TOP HALF DIVIDED BY VERTICAL BAR;Sm;0;ON;;;;;N;;;;;\n29BB;CIRCLE WITH SUPERIMPOSED X;Sm;0;ON;;;;;N;;;;;\n29BC;CIRCLED ANTICLOCKWISE-ROTATED DIVISION SIGN;Sm;0;ON;;;;;N;;;;;\n29BD;UP ARROW THROUGH CIRCLE;Sm;0;ON;;;;;N;;;;;\n29BE;CIRCLED WHITE BULLET;Sm;0;ON;;;;;N;;;;;\n29BF;CIRCLED BULLET;Sm;0;ON;;;;;N;;;;;\n29C0;CIRCLED LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n29C1;CIRCLED GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n29C2;CIRCLE WITH SMALL CIRCLE TO THE RIGHT;Sm;0;ON;;;;;Y;;;;;\n29C3;CIRCLE WITH TWO HORIZONTAL STROKES TO THE RIGHT;Sm;0;ON;;;;;Y;;;;;\n29C4;SQUARED RISING DIAGONAL SLASH;Sm;0;ON;;;;;Y;;;;;\n29C5;SQUARED FALLING DIAGONAL SLASH;Sm;0;ON;;;;;Y;;;;;\n29C6;SQUARED ASTERISK;Sm;0;ON;;;;;N;;;;;\n29C7;SQUARED SMALL CIRCLE;Sm;0;ON;;;;;N;;;;;\n29C8;SQUARED SQUARE;Sm;0;ON;;;;;N;;;;;\n29C9;TWO JOINED SQUARES;Sm;0;ON;;;;;Y;;;;;\n29CA;TRIANGLE WITH DOT ABOVE;Sm;0;ON;;;;;N;;;;;\n29CB;TRIANGLE WITH UNDERBAR;Sm;0;ON;;;;;N;;;;;\n29CC;S IN TRIANGLE;Sm;0;ON;;;;;N;;;;;\n29CD;TRIANGLE WITH SERIFS AT BOTTOM;Sm;0;ON;;;;;N;;;;;\n29CE;RIGHT TRIANGLE ABOVE LEFT TRIANGLE;Sm;0;ON;;;;;Y;;;;;\n29CF;LEFT TRIANGLE BESIDE VERTICAL BAR;Sm;0;ON;;;;;Y;;;;;\n29D0;VERTICAL BAR BESIDE RIGHT TRIANGLE;Sm;0;ON;;;;;Y;;;;;\n29D1;BOWTIE WITH LEFT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29D2;BOWTIE WITH RIGHT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29D3;BLACK BOWTIE;Sm;0;ON;;;;;N;;;;;\n29D4;TIMES WITH LEFT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29D5;TIMES WITH RIGHT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29D6;WHITE HOURGLASS;Sm;0;ON;;;;;N;;;;;\n29D7;BLACK HOURGLASS;Sm;0;ON;;;;;N;;;;;\n29D8;LEFT WIGGLY FENCE;Ps;0;ON;;;;;Y;;;;;\n29D9;RIGHT WIGGLY FENCE;Pe;0;ON;;;;;Y;;;;;\n29DA;LEFT DOUBLE WIGGLY FENCE;Ps;0;ON;;;;;Y;;;;;\n29DB;RIGHT DOUBLE WIGGLY FENCE;Pe;0;ON;;;;;Y;;;;;\n29DC;INCOMPLETE INFINITY;Sm;0;ON;;;;;Y;;;;;\n29DD;TIE OVER INFINITY;Sm;0;ON;;;;;N;;;;;\n29DE;INFINITY NEGATED WITH VERTICAL BAR;Sm;0;ON;;;;;N;;;;;\n29DF;DOUBLE-ENDED MULTIMAP;Sm;0;ON;;;;;N;;;;;\n29E0;SQUARE WITH CONTOURED OUTLINE;Sm;0;ON;;;;;N;;;;;\n29E1;INCREASES AS;Sm;0;ON;;;;;Y;;;;;\n29E2;SHUFFLE PRODUCT;Sm;0;ON;;;;;N;;;;;\n29E3;EQUALS SIGN AND SLANTED PARALLEL;Sm;0;ON;;;;;Y;;;;;\n29E4;EQUALS SIGN AND SLANTED PARALLEL WITH TILDE ABOVE;Sm;0;ON;;;;;Y;;;;;\n29E5;IDENTICAL TO AND SLANTED PARALLEL;Sm;0;ON;;;;;Y;;;;;\n29E6;GLEICH STARK;Sm;0;ON;;;;;N;;;;;\n29E7;THERMODYNAMIC;Sm;0;ON;;;;;N;;;;;\n29E8;DOWN-POINTING TRIANGLE WITH LEFT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29E9;DOWN-POINTING TRIANGLE WITH RIGHT HALF BLACK;Sm;0;ON;;;;;Y;;;;;\n29EA;BLACK DIAMOND WITH DOWN ARROW;Sm;0;ON;;;;;N;;;;;\n29EB;BLACK LOZENGE;Sm;0;ON;;;;;N;;;;;\n29EC;WHITE CIRCLE WITH DOWN ARROW;Sm;0;ON;;;;;N;;;;;\n29ED;BLACK CIRCLE WITH DOWN ARROW;Sm;0;ON;;;;;N;;;;;\n29EE;ERROR-BARRED WHITE SQUARE;Sm;0;ON;;;;;N;;;;;\n29EF;ERROR-BARRED BLACK SQUARE;Sm;0;ON;;;;;N;;;;;\n29F0;ERROR-BARRED WHITE DIAMOND;Sm;0;ON;;;;;N;;;;;\n29F1;ERROR-BARRED BLACK DIAMOND;Sm;0;ON;;;;;N;;;;;\n29F2;ERROR-BARRED WHITE CIRCLE;Sm;0;ON;;;;;N;;;;;\n29F3;ERROR-BARRED BLACK CIRCLE;Sm;0;ON;;;;;N;;;;;\n29F4;RULE-DELAYED;Sm;0;ON;;;;;Y;;;;;\n29F5;REVERSE SOLIDUS OPERATOR;Sm;0;ON;;;;;Y;;;;;\n29F6;SOLIDUS WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n29F7;REVERSE SOLIDUS WITH HORIZONTAL STROKE;Sm;0;ON;;;;;Y;;;;;\n29F8;BIG SOLIDUS;Sm;0;ON;;;;;Y;;;;;\n29F9;BIG REVERSE SOLIDUS;Sm;0;ON;;;;;Y;;;;;\n29FA;DOUBLE PLUS;Sm;0;ON;;;;;N;;;;;\n29FB;TRIPLE PLUS;Sm;0;ON;;;;;N;;;;;\n29FC;LEFT-POINTING CURVED ANGLE BRACKET;Ps;0;ON;;;;;Y;;;;;\n29FD;RIGHT-POINTING CURVED ANGLE BRACKET;Pe;0;ON;;;;;Y;;;;;\n29FE;TINY;Sm;0;ON;;;;;N;;;;;\n29FF;MINY;Sm;0;ON;;;;;N;;;;;\n2A00;N-ARY CIRCLED DOT OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A01;N-ARY CIRCLED PLUS OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A02;N-ARY CIRCLED TIMES OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A03;N-ARY UNION OPERATOR WITH DOT;Sm;0;ON;;;;;N;;;;;\n2A04;N-ARY UNION OPERATOR WITH PLUS;Sm;0;ON;;;;;N;;;;;\n2A05;N-ARY SQUARE INTERSECTION OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A06;N-ARY SQUARE UNION OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A07;TWO LOGICAL AND OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A08;TWO LOGICAL OR OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A09;N-ARY TIMES OPERATOR;Sm;0;ON;;;;;N;;;;;\n2A0A;MODULO TWO SUM;Sm;0;ON;;;;;Y;;;;;\n2A0B;SUMMATION WITH INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2A0C;QUADRUPLE INTEGRAL OPERATOR;Sm;0;ON;<compat> 222B 222B 222B 222B;;;;Y;;;;;\n2A0D;FINITE PART INTEGRAL;Sm;0;ON;;;;;Y;;;;;\n2A0E;INTEGRAL WITH DOUBLE STROKE;Sm;0;ON;;;;;Y;;;;;\n2A0F;INTEGRAL AVERAGE WITH SLASH;Sm;0;ON;;;;;Y;;;;;\n2A10;CIRCULATION FUNCTION;Sm;0;ON;;;;;Y;;;;;\n2A11;ANTICLOCKWISE INTEGRATION;Sm;0;ON;;;;;Y;;;;;\n2A12;LINE INTEGRATION WITH RECTANGULAR PATH AROUND POLE;Sm;0;ON;;;;;Y;;;;;\n2A13;LINE INTEGRATION WITH SEMICIRCULAR PATH AROUND POLE;Sm;0;ON;;;;;Y;;;;;\n2A14;LINE INTEGRATION NOT INCLUDING THE POLE;Sm;0;ON;;;;;Y;;;;;\n2A15;INTEGRAL AROUND A POINT OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2A16;QUATERNION INTEGRAL OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2A17;INTEGRAL WITH LEFTWARDS ARROW WITH HOOK;Sm;0;ON;;;;;Y;;;;;\n2A18;INTEGRAL WITH TIMES SIGN;Sm;0;ON;;;;;Y;;;;;\n2A19;INTEGRAL WITH INTERSECTION;Sm;0;ON;;;;;Y;;;;;\n2A1A;INTEGRAL WITH UNION;Sm;0;ON;;;;;Y;;;;;\n2A1B;INTEGRAL WITH OVERBAR;Sm;0;ON;;;;;Y;;;;;\n2A1C;INTEGRAL WITH UNDERBAR;Sm;0;ON;;;;;Y;;;;;\n2A1D;JOIN;Sm;0;ON;;;;;N;;;;;\n2A1E;LARGE LEFT TRIANGLE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2A1F;Z NOTATION SCHEMA COMPOSITION;Sm;0;ON;;;;;Y;;;;;\n2A20;Z NOTATION SCHEMA PIPING;Sm;0;ON;;;;;Y;;;;;\n2A21;Z NOTATION SCHEMA PROJECTION;Sm;0;ON;;;;;Y;;;;;\n2A22;PLUS SIGN WITH SMALL CIRCLE ABOVE;Sm;0;ON;;;;;N;;;;;\n2A23;PLUS SIGN WITH CIRCUMFLEX ACCENT ABOVE;Sm;0;ON;;;;;N;;;;;\n2A24;PLUS SIGN WITH TILDE ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A25;PLUS SIGN WITH DOT BELOW;Sm;0;ON;;;;;N;;;;;\n2A26;PLUS SIGN WITH TILDE BELOW;Sm;0;ON;;;;;Y;;;;;\n2A27;PLUS SIGN WITH SUBSCRIPT TWO;Sm;0;ON;;;;;N;;;;;\n2A28;PLUS SIGN WITH BLACK TRIANGLE;Sm;0;ON;;;;;N;;;;;\n2A29;MINUS SIGN WITH COMMA ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A2A;MINUS SIGN WITH DOT BELOW;Sm;0;ON;;;;;N;;;;;\n2A2B;MINUS SIGN WITH FALLING DOTS;Sm;0;ON;;;;;Y;;;;;\n2A2C;MINUS SIGN WITH RISING DOTS;Sm;0;ON;;;;;Y;;;;;\n2A2D;PLUS SIGN IN LEFT HALF CIRCLE;Sm;0;ON;;;;;Y;;;;;\n2A2E;PLUS SIGN IN RIGHT HALF CIRCLE;Sm;0;ON;;;;;Y;;;;;\n2A2F;VECTOR OR CROSS PRODUCT;Sm;0;ON;;;;;N;;;;;\n2A30;MULTIPLICATION SIGN WITH DOT ABOVE;Sm;0;ON;;;;;N;;;;;\n2A31;MULTIPLICATION SIGN WITH UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2A32;SEMIDIRECT PRODUCT WITH BOTTOM CLOSED;Sm;0;ON;;;;;N;;;;;\n2A33;SMASH PRODUCT;Sm;0;ON;;;;;N;;;;;\n2A34;MULTIPLICATION SIGN IN LEFT HALF CIRCLE;Sm;0;ON;;;;;Y;;;;;\n2A35;MULTIPLICATION SIGN IN RIGHT HALF CIRCLE;Sm;0;ON;;;;;Y;;;;;\n2A36;CIRCLED MULTIPLICATION SIGN WITH CIRCUMFLEX ACCENT;Sm;0;ON;;;;;N;;;;;\n2A37;MULTIPLICATION SIGN IN DOUBLE CIRCLE;Sm;0;ON;;;;;N;;;;;\n2A38;CIRCLED DIVISION SIGN;Sm;0;ON;;;;;N;;;;;\n2A39;PLUS SIGN IN TRIANGLE;Sm;0;ON;;;;;N;;;;;\n2A3A;MINUS SIGN IN TRIANGLE;Sm;0;ON;;;;;N;;;;;\n2A3B;MULTIPLICATION SIGN IN TRIANGLE;Sm;0;ON;;;;;N;;;;;\n2A3C;INTERIOR PRODUCT;Sm;0;ON;;;;;Y;;;;;\n2A3D;RIGHTHAND INTERIOR PRODUCT;Sm;0;ON;;;;;Y;;;;;\n2A3E;Z NOTATION RELATIONAL COMPOSITION;Sm;0;ON;;;;;Y;;;;;\n2A3F;AMALGAMATION OR COPRODUCT;Sm;0;ON;;;;;N;;;;;\n2A40;INTERSECTION WITH DOT;Sm;0;ON;;;;;N;;;;;\n2A41;UNION WITH MINUS SIGN;Sm;0;ON;;;;;N;;;;;\n2A42;UNION WITH OVERBAR;Sm;0;ON;;;;;N;;;;;\n2A43;INTERSECTION WITH OVERBAR;Sm;0;ON;;;;;N;;;;;\n2A44;INTERSECTION WITH LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n2A45;UNION WITH LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n2A46;UNION ABOVE INTERSECTION;Sm;0;ON;;;;;N;;;;;\n2A47;INTERSECTION ABOVE UNION;Sm;0;ON;;;;;N;;;;;\n2A48;UNION ABOVE BAR ABOVE INTERSECTION;Sm;0;ON;;;;;N;;;;;\n2A49;INTERSECTION ABOVE BAR ABOVE UNION;Sm;0;ON;;;;;N;;;;;\n2A4A;UNION BESIDE AND JOINED WITH UNION;Sm;0;ON;;;;;N;;;;;\n2A4B;INTERSECTION BESIDE AND JOINED WITH INTERSECTION;Sm;0;ON;;;;;N;;;;;\n2A4C;CLOSED UNION WITH SERIFS;Sm;0;ON;;;;;N;;;;;\n2A4D;CLOSED INTERSECTION WITH SERIFS;Sm;0;ON;;;;;N;;;;;\n2A4E;DOUBLE SQUARE INTERSECTION;Sm;0;ON;;;;;N;;;;;\n2A4F;DOUBLE SQUARE UNION;Sm;0;ON;;;;;N;;;;;\n2A50;CLOSED UNION WITH SERIFS AND SMASH PRODUCT;Sm;0;ON;;;;;N;;;;;\n2A51;LOGICAL AND WITH DOT ABOVE;Sm;0;ON;;;;;N;;;;;\n2A52;LOGICAL OR WITH DOT ABOVE;Sm;0;ON;;;;;N;;;;;\n2A53;DOUBLE LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n2A54;DOUBLE LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n2A55;TWO INTERSECTING LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n2A56;TWO INTERSECTING LOGICAL OR;Sm;0;ON;;;;;N;;;;;\n2A57;SLOPING LARGE OR;Sm;0;ON;;;;;Y;;;;;\n2A58;SLOPING LARGE AND;Sm;0;ON;;;;;Y;;;;;\n2A59;LOGICAL OR OVERLAPPING LOGICAL AND;Sm;0;ON;;;;;N;;;;;\n2A5A;LOGICAL AND WITH MIDDLE STEM;Sm;0;ON;;;;;N;;;;;\n2A5B;LOGICAL OR WITH MIDDLE STEM;Sm;0;ON;;;;;N;;;;;\n2A5C;LOGICAL AND WITH HORIZONTAL DASH;Sm;0;ON;;;;;N;;;;;\n2A5D;LOGICAL OR WITH HORIZONTAL DASH;Sm;0;ON;;;;;N;;;;;\n2A5E;LOGICAL AND WITH DOUBLE OVERBAR;Sm;0;ON;;;;;N;;;;;\n2A5F;LOGICAL AND WITH UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2A60;LOGICAL AND WITH DOUBLE UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2A61;SMALL VEE WITH UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2A62;LOGICAL OR WITH DOUBLE OVERBAR;Sm;0;ON;;;;;N;;;;;\n2A63;LOGICAL OR WITH DOUBLE UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2A64;Z NOTATION DOMAIN ANTIRESTRICTION;Sm;0;ON;;;;;Y;;;;;\n2A65;Z NOTATION RANGE ANTIRESTRICTION;Sm;0;ON;;;;;Y;;;;;\n2A66;EQUALS SIGN WITH DOT BELOW;Sm;0;ON;;;;;N;;;;;\n2A67;IDENTICAL WITH DOT ABOVE;Sm;0;ON;;;;;N;;;;;\n2A68;TRIPLE HORIZONTAL BAR WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2A69;TRIPLE HORIZONTAL BAR WITH TRIPLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2A6A;TILDE OPERATOR WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A6B;TILDE OPERATOR WITH RISING DOTS;Sm;0;ON;;;;;Y;;;;;\n2A6C;SIMILAR MINUS SIMILAR;Sm;0;ON;;;;;Y;;;;;\n2A6D;CONGRUENT WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A6E;EQUALS WITH ASTERISK;Sm;0;ON;;;;;N;;;;;\n2A6F;ALMOST EQUAL TO WITH CIRCUMFLEX ACCENT;Sm;0;ON;;;;;Y;;;;;\n2A70;APPROXIMATELY EQUAL OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2A71;EQUALS SIGN ABOVE PLUS SIGN;Sm;0;ON;;;;;N;;;;;\n2A72;PLUS SIGN ABOVE EQUALS SIGN;Sm;0;ON;;;;;N;;;;;\n2A73;EQUALS SIGN ABOVE TILDE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2A74;DOUBLE COLON EQUAL;Sm;0;ON;<compat> 003A 003A 003D;;;;Y;;;;;\n2A75;TWO CONSECUTIVE EQUALS SIGNS;Sm;0;ON;<compat> 003D 003D;;;;N;;;;;\n2A76;THREE CONSECUTIVE EQUALS SIGNS;Sm;0;ON;<compat> 003D 003D 003D;;;;N;;;;;\n2A77;EQUALS SIGN WITH TWO DOTS ABOVE AND TWO DOTS BELOW;Sm;0;ON;;;;;N;;;;;\n2A78;EQUIVALENT WITH FOUR DOTS ABOVE;Sm;0;ON;;;;;N;;;;;\n2A79;LESS-THAN WITH CIRCLE INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A7A;GREATER-THAN WITH CIRCLE INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A7B;LESS-THAN WITH QUESTION MARK ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A7C;GREATER-THAN WITH QUESTION MARK ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A7D;LESS-THAN OR SLANTED EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2A7E;GREATER-THAN OR SLANTED EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2A7F;LESS-THAN OR SLANTED EQUAL TO WITH DOT INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A80;GREATER-THAN OR SLANTED EQUAL TO WITH DOT INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A81;LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A82;GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2A83;LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE RIGHT;Sm;0;ON;;;;;Y;;;;;\n2A84;GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE LEFT;Sm;0;ON;;;;;Y;;;;;\n2A85;LESS-THAN OR APPROXIMATE;Sm;0;ON;;;;;Y;;;;;\n2A86;GREATER-THAN OR APPROXIMATE;Sm;0;ON;;;;;Y;;;;;\n2A87;LESS-THAN AND SINGLE-LINE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2A88;GREATER-THAN AND SINGLE-LINE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2A89;LESS-THAN AND NOT APPROXIMATE;Sm;0;ON;;;;;Y;;;;;\n2A8A;GREATER-THAN AND NOT APPROXIMATE;Sm;0;ON;;;;;Y;;;;;\n2A8B;LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A8C;GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A8D;LESS-THAN ABOVE SIMILAR OR EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A8E;GREATER-THAN ABOVE SIMILAR OR EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A8F;LESS-THAN ABOVE SIMILAR ABOVE GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A90;GREATER-THAN ABOVE SIMILAR ABOVE LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A91;LESS-THAN ABOVE GREATER-THAN ABOVE DOUBLE-LINE EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A92;GREATER-THAN ABOVE LESS-THAN ABOVE DOUBLE-LINE EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A93;LESS-THAN ABOVE SLANTED EQUAL ABOVE GREATER-THAN ABOVE SLANTED EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A94;GREATER-THAN ABOVE SLANTED EQUAL ABOVE LESS-THAN ABOVE SLANTED EQUAL;Sm;0;ON;;;;;Y;;;;;\n2A95;SLANTED EQUAL TO OR LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A96;SLANTED EQUAL TO OR GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A97;SLANTED EQUAL TO OR LESS-THAN WITH DOT INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A98;SLANTED EQUAL TO OR GREATER-THAN WITH DOT INSIDE;Sm;0;ON;;;;;Y;;;;;\n2A99;DOUBLE-LINE EQUAL TO OR LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9A;DOUBLE-LINE EQUAL TO OR GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9B;DOUBLE-LINE SLANTED EQUAL TO OR LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9C;DOUBLE-LINE SLANTED EQUAL TO OR GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9D;SIMILAR OR LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9E;SIMILAR OR GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2A9F;SIMILAR ABOVE LESS-THAN ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AA0;SIMILAR ABOVE GREATER-THAN ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AA1;DOUBLE NESTED LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2AA2;DOUBLE NESTED GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2AA3;DOUBLE NESTED LESS-THAN WITH UNDERBAR;Sm;0;ON;;;;;Y;;;;;\n2AA4;GREATER-THAN OVERLAPPING LESS-THAN;Sm;0;ON;;;;;N;;;;;\n2AA5;GREATER-THAN BESIDE LESS-THAN;Sm;0;ON;;;;;N;;;;;\n2AA6;LESS-THAN CLOSED BY CURVE;Sm;0;ON;;;;;Y;;;;;\n2AA7;GREATER-THAN CLOSED BY CURVE;Sm;0;ON;;;;;Y;;;;;\n2AA8;LESS-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL;Sm;0;ON;;;;;Y;;;;;\n2AA9;GREATER-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL;Sm;0;ON;;;;;Y;;;;;\n2AAA;SMALLER THAN;Sm;0;ON;;;;;Y;;;;;\n2AAB;LARGER THAN;Sm;0;ON;;;;;Y;;;;;\n2AAC;SMALLER THAN OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AAD;LARGER THAN OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AAE;EQUALS SIGN WITH BUMPY ABOVE;Sm;0;ON;;;;;N;;;;;\n2AAF;PRECEDES ABOVE SINGLE-LINE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AB0;SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AB1;PRECEDES ABOVE SINGLE-LINE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB2;SUCCEEDS ABOVE SINGLE-LINE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB3;PRECEDES ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AB4;SUCCEEDS ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AB5;PRECEDES ABOVE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB6;SUCCEEDS ABOVE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB7;PRECEDES ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB8;SUCCEEDS ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AB9;PRECEDES ABOVE NOT ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ABA;SUCCEEDS ABOVE NOT ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ABB;DOUBLE PRECEDES;Sm;0;ON;;;;;Y;;;;;\n2ABC;DOUBLE SUCCEEDS;Sm;0;ON;;;;;Y;;;;;\n2ABD;SUBSET WITH DOT;Sm;0;ON;;;;;Y;;;;;\n2ABE;SUPERSET WITH DOT;Sm;0;ON;;;;;Y;;;;;\n2ABF;SUBSET WITH PLUS SIGN BELOW;Sm;0;ON;;;;;Y;;;;;\n2AC0;SUPERSET WITH PLUS SIGN BELOW;Sm;0;ON;;;;;Y;;;;;\n2AC1;SUBSET WITH MULTIPLICATION SIGN BELOW;Sm;0;ON;;;;;Y;;;;;\n2AC2;SUPERSET WITH MULTIPLICATION SIGN BELOW;Sm;0;ON;;;;;Y;;;;;\n2AC3;SUBSET OF OR EQUAL TO WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2AC4;SUPERSET OF OR EQUAL TO WITH DOT ABOVE;Sm;0;ON;;;;;Y;;;;;\n2AC5;SUBSET OF ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AC6;SUPERSET OF ABOVE EQUALS SIGN;Sm;0;ON;;;;;Y;;;;;\n2AC7;SUBSET OF ABOVE TILDE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2AC8;SUPERSET OF ABOVE TILDE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2AC9;SUBSET OF ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ACA;SUPERSET OF ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ACB;SUBSET OF ABOVE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ACC;SUPERSET OF ABOVE NOT EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2ACD;SQUARE LEFT OPEN BOX OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2ACE;SQUARE RIGHT OPEN BOX OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2ACF;CLOSED SUBSET;Sm;0;ON;;;;;Y;;;;;\n2AD0;CLOSED SUPERSET;Sm;0;ON;;;;;Y;;;;;\n2AD1;CLOSED SUBSET OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AD2;CLOSED SUPERSET OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AD3;SUBSET ABOVE SUPERSET;Sm;0;ON;;;;;Y;;;;;\n2AD4;SUPERSET ABOVE SUBSET;Sm;0;ON;;;;;Y;;;;;\n2AD5;SUBSET ABOVE SUBSET;Sm;0;ON;;;;;Y;;;;;\n2AD6;SUPERSET ABOVE SUPERSET;Sm;0;ON;;;;;Y;;;;;\n2AD7;SUPERSET BESIDE SUBSET;Sm;0;ON;;;;;N;;;;;\n2AD8;SUPERSET BESIDE AND JOINED BY DASH WITH SUBSET;Sm;0;ON;;;;;N;;;;;\n2AD9;ELEMENT OF OPENING DOWNWARDS;Sm;0;ON;;;;;N;;;;;\n2ADA;PITCHFORK WITH TEE TOP;Sm;0;ON;;;;;N;;;;;\n2ADB;TRANSVERSAL INTERSECTION;Sm;0;ON;;;;;N;;;;;\n2ADC;FORKING;Sm;0;ON;2ADD 0338;;;;Y;;;;;\n2ADD;NONFORKING;Sm;0;ON;;;;;N;;;;;\n2ADE;SHORT LEFT TACK;Sm;0;ON;;;;;Y;;;;;\n2ADF;SHORT DOWN TACK;Sm;0;ON;;;;;N;;;;;\n2AE0;SHORT UP TACK;Sm;0;ON;;;;;N;;;;;\n2AE1;PERPENDICULAR WITH S;Sm;0;ON;;;;;N;;;;;\n2AE2;VERTICAL BAR TRIPLE RIGHT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n2AE3;DOUBLE VERTICAL BAR LEFT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n2AE4;VERTICAL BAR DOUBLE LEFT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n2AE5;DOUBLE VERTICAL BAR DOUBLE LEFT TURNSTILE;Sm;0;ON;;;;;Y;;;;;\n2AE6;LONG DASH FROM LEFT MEMBER OF DOUBLE VERTICAL;Sm;0;ON;;;;;Y;;;;;\n2AE7;SHORT DOWN TACK WITH OVERBAR;Sm;0;ON;;;;;N;;;;;\n2AE8;SHORT UP TACK WITH UNDERBAR;Sm;0;ON;;;;;N;;;;;\n2AE9;SHORT UP TACK ABOVE SHORT DOWN TACK;Sm;0;ON;;;;;N;;;;;\n2AEA;DOUBLE DOWN TACK;Sm;0;ON;;;;;N;;;;;\n2AEB;DOUBLE UP TACK;Sm;0;ON;;;;;N;;;;;\n2AEC;DOUBLE STROKE NOT SIGN;Sm;0;ON;;;;;Y;;;;;\n2AED;REVERSED DOUBLE STROKE NOT SIGN;Sm;0;ON;;;;;Y;;;;;\n2AEE;DOES NOT DIVIDE WITH REVERSED NEGATION SLASH;Sm;0;ON;;;;;Y;;;;;\n2AEF;VERTICAL LINE WITH CIRCLE ABOVE;Sm;0;ON;;;;;N;;;;;\n2AF0;VERTICAL LINE WITH CIRCLE BELOW;Sm;0;ON;;;;;N;;;;;\n2AF1;DOWN TACK WITH CIRCLE BELOW;Sm;0;ON;;;;;N;;;;;\n2AF2;PARALLEL WITH HORIZONTAL STROKE;Sm;0;ON;;;;;N;;;;;\n2AF3;PARALLEL WITH TILDE OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2AF4;TRIPLE VERTICAL BAR BINARY RELATION;Sm;0;ON;;;;;N;;;;;\n2AF5;TRIPLE VERTICAL BAR WITH HORIZONTAL STROKE;Sm;0;ON;;;;;N;;;;;\n2AF6;TRIPLE COLON OPERATOR;Sm;0;ON;;;;;N;;;;;\n2AF7;TRIPLE NESTED LESS-THAN;Sm;0;ON;;;;;Y;;;;;\n2AF8;TRIPLE NESTED GREATER-THAN;Sm;0;ON;;;;;Y;;;;;\n2AF9;DOUBLE-LINE SLANTED LESS-THAN OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AFA;DOUBLE-LINE SLANTED GREATER-THAN OR EQUAL TO;Sm;0;ON;;;;;Y;;;;;\n2AFB;TRIPLE SOLIDUS BINARY RELATION;Sm;0;ON;;;;;Y;;;;;\n2AFC;LARGE TRIPLE VERTICAL BAR OPERATOR;Sm;0;ON;;;;;N;;;;;\n2AFD;DOUBLE SOLIDUS OPERATOR;Sm;0;ON;;;;;Y;;;;;\n2AFE;WHITE VERTICAL BAR;Sm;0;ON;;;;;N;;;;;\n2AFF;N-ARY WHITE VERTICAL BAR;Sm;0;ON;;;;;N;;;;;\n2B00;NORTH EAST WHITE ARROW;So;0;ON;;;;;N;;;;;\n2B01;NORTH WEST WHITE ARROW;So;0;ON;;;;;N;;;;;\n2B02;SOUTH EAST WHITE ARROW;So;0;ON;;;;;N;;;;;\n2B03;SOUTH WEST WHITE ARROW;So;0;ON;;;;;N;;;;;\n2B04;LEFT RIGHT WHITE ARROW;So;0;ON;;;;;N;;;;;\n2B05;LEFTWARDS BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B06;UPWARDS BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B07;DOWNWARDS BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B08;NORTH EAST BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B09;NORTH WEST BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B0A;SOUTH EAST BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B0B;SOUTH WEST BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B0C;LEFT RIGHT BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B0D;UP DOWN BLACK ARROW;So;0;ON;;;;;N;;;;;\n2B0E;RIGHTWARDS ARROW WITH TIP DOWNWARDS;So;0;ON;;;;;N;;;;;\n2B0F;RIGHTWARDS ARROW WITH TIP UPWARDS;So;0;ON;;;;;N;;;;;\n2B10;LEFTWARDS ARROW WITH TIP DOWNWARDS;So;0;ON;;;;;N;;;;;\n2B11;LEFTWARDS ARROW WITH TIP UPWARDS;So;0;ON;;;;;N;;;;;\n2B12;SQUARE WITH TOP HALF BLACK;So;0;ON;;;;;N;;;;;\n2B13;SQUARE WITH BOTTOM HALF BLACK;So;0;ON;;;;;N;;;;;\n2B14;SQUARE WITH UPPER RIGHT DIAGONAL HALF BLACK;So;0;ON;;;;;N;;;;;\n2B15;SQUARE WITH LOWER LEFT DIAGONAL HALF BLACK;So;0;ON;;;;;N;;;;;\n2B16;DIAMOND WITH LEFT HALF BLACK;So;0;ON;;;;;N;;;;;\n2B17;DIAMOND WITH RIGHT HALF BLACK;So;0;ON;;;;;N;;;;;\n2B18;DIAMOND WITH TOP HALF BLACK;So;0;ON;;;;;N;;;;;\n2B19;DIAMOND WITH BOTTOM HALF BLACK;So;0;ON;;;;;N;;;;;\n2B1A;DOTTED SQUARE;So;0;ON;;;;;N;;;;;\n2B1B;BLACK LARGE SQUARE;So;0;ON;;;;;N;;;;;\n2B1C;WHITE LARGE SQUARE;So;0;ON;;;;;N;;;;;\n2B1D;BLACK VERY SMALL SQUARE;So;0;ON;;;;;N;;;;;\n2B1E;WHITE VERY SMALL SQUARE;So;0;ON;;;;;N;;;;;\n2B1F;BLACK PENTAGON;So;0;ON;;;;;N;;;;;\n2B20;WHITE PENTAGON;So;0;ON;;;;;N;;;;;\n2B21;WHITE HEXAGON;So;0;ON;;;;;N;;;;;\n2B22;BLACK HEXAGON;So;0;ON;;;;;N;;;;;\n2B23;HORIZONTAL BLACK HEXAGON;So;0;ON;;;;;N;;;;;\n2B24;BLACK LARGE CIRCLE;So;0;ON;;;;;N;;;;;\n2B25;BLACK MEDIUM DIAMOND;So;0;ON;;;;;N;;;;;\n2B26;WHITE MEDIUM DIAMOND;So;0;ON;;;;;N;;;;;\n2B27;BLACK MEDIUM LOZENGE;So;0;ON;;;;;N;;;;;\n2B28;WHITE MEDIUM LOZENGE;So;0;ON;;;;;N;;;;;\n2B29;BLACK SMALL DIAMOND;So;0;ON;;;;;N;;;;;\n2B2A;BLACK SMALL LOZENGE;So;0;ON;;;;;N;;;;;\n2B2B;WHITE SMALL LOZENGE;So;0;ON;;;;;N;;;;;\n2B2C;BLACK HORIZONTAL ELLIPSE;So;0;ON;;;;;N;;;;;\n2B2D;WHITE HORIZONTAL ELLIPSE;So;0;ON;;;;;N;;;;;\n2B2E;BLACK VERTICAL ELLIPSE;So;0;ON;;;;;N;;;;;\n2B2F;WHITE VERTICAL ELLIPSE;So;0;ON;;;;;N;;;;;\n2B30;LEFT ARROW WITH SMALL CIRCLE;Sm;0;ON;;;;;N;;;;;\n2B31;THREE LEFTWARDS ARROWS;Sm;0;ON;;;;;N;;;;;\n2B32;LEFT ARROW WITH CIRCLED PLUS;Sm;0;ON;;;;;N;;;;;\n2B33;LONG LEFTWARDS SQUIGGLE ARROW;Sm;0;ON;;;;;N;;;;;\n2B34;LEFTWARDS TWO-HEADED ARROW WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B35;LEFTWARDS TWO-HEADED ARROW WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B36;LEFTWARDS TWO-HEADED ARROW FROM BAR;Sm;0;ON;;;;;N;;;;;\n2B37;LEFTWARDS TWO-HEADED TRIPLE DASH ARROW;Sm;0;ON;;;;;N;;;;;\n2B38;LEFTWARDS ARROW WITH DOTTED STEM;Sm;0;ON;;;;;N;;;;;\n2B39;LEFTWARDS ARROW WITH TAIL WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B3A;LEFTWARDS ARROW WITH TAIL WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B3B;LEFTWARDS TWO-HEADED ARROW WITH TAIL;Sm;0;ON;;;;;N;;;;;\n2B3C;LEFTWARDS TWO-HEADED ARROW WITH TAIL WITH VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B3D;LEFTWARDS TWO-HEADED ARROW WITH TAIL WITH DOUBLE VERTICAL STROKE;Sm;0;ON;;;;;N;;;;;\n2B3E;LEFTWARDS ARROW THROUGH X;Sm;0;ON;;;;;N;;;;;\n2B3F;WAVE ARROW POINTING DIRECTLY LEFT;Sm;0;ON;;;;;N;;;;;\n2B40;EQUALS SIGN ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2B41;REVERSE TILDE OPERATOR ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2B42;LEFTWARDS ARROW ABOVE REVERSE ALMOST EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2B43;RIGHTWARDS ARROW THROUGH GREATER-THAN;Sm;0;ON;;;;;N;;;;;\n2B44;RIGHTWARDS ARROW THROUGH SUPERSET;Sm;0;ON;;;;;N;;;;;\n2B45;LEFTWARDS QUADRUPLE ARROW;So;0;ON;;;;;N;;;;;\n2B46;RIGHTWARDS QUADRUPLE ARROW;So;0;ON;;;;;N;;;;;\n2B47;REVERSE TILDE OPERATOR ABOVE RIGHTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2B48;RIGHTWARDS ARROW ABOVE REVERSE ALMOST EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2B49;TILDE OPERATOR ABOVE LEFTWARDS ARROW;Sm;0;ON;;;;;N;;;;;\n2B4A;LEFTWARDS ARROW ABOVE ALMOST EQUAL TO;Sm;0;ON;;;;;N;;;;;\n2B4B;LEFTWARDS ARROW ABOVE REVERSE TILDE OPERATOR;Sm;0;ON;;;;;N;;;;;\n2B4C;RIGHTWARDS ARROW ABOVE REVERSE TILDE OPERATOR;Sm;0;ON;;;;;N;;;;;\n2B50;WHITE MEDIUM STAR;So;0;ON;;;;;N;;;;;\n2B51;BLACK SMALL STAR;So;0;ON;;;;;N;;;;;\n2B52;WHITE SMALL STAR;So;0;ON;;;;;N;;;;;\n2B53;BLACK RIGHT-POINTING PENTAGON;So;0;ON;;;;;N;;;;;\n2B54;WHITE RIGHT-POINTING PENTAGON;So;0;ON;;;;;N;;;;;\n2B55;HEAVY LARGE CIRCLE;So;0;ON;;;;;N;;;;;\n2B56;HEAVY OVAL WITH OVAL INSIDE;So;0;ON;;;;;N;;;;;\n2B57;HEAVY CIRCLE WITH CIRCLE INSIDE;So;0;ON;;;;;N;;;;;\n2B58;HEAVY CIRCLE;So;0;ON;;;;;N;;;;;\n2B59;HEAVY CIRCLED SALTIRE;So;0;ON;;;;;N;;;;;\n2C00;GLAGOLITIC CAPITAL LETTER AZU;Lu;0;L;;;;;N;;;;2C30;\n2C01;GLAGOLITIC CAPITAL LETTER BUKY;Lu;0;L;;;;;N;;;;2C31;\n2C02;GLAGOLITIC CAPITAL LETTER VEDE;Lu;0;L;;;;;N;;;;2C32;\n2C03;GLAGOLITIC CAPITAL LETTER GLAGOLI;Lu;0;L;;;;;N;;;;2C33;\n2C04;GLAGOLITIC CAPITAL LETTER DOBRO;Lu;0;L;;;;;N;;;;2C34;\n2C05;GLAGOLITIC CAPITAL LETTER YESTU;Lu;0;L;;;;;N;;;;2C35;\n2C06;GLAGOLITIC CAPITAL LETTER ZHIVETE;Lu;0;L;;;;;N;;;;2C36;\n2C07;GLAGOLITIC CAPITAL LETTER DZELO;Lu;0;L;;;;;N;;;;2C37;\n2C08;GLAGOLITIC CAPITAL LETTER ZEMLJA;Lu;0;L;;;;;N;;;;2C38;\n2C09;GLAGOLITIC CAPITAL LETTER IZHE;Lu;0;L;;;;;N;;;;2C39;\n2C0A;GLAGOLITIC CAPITAL LETTER INITIAL IZHE;Lu;0;L;;;;;N;;;;2C3A;\n2C0B;GLAGOLITIC CAPITAL LETTER I;Lu;0;L;;;;;N;;;;2C3B;\n2C0C;GLAGOLITIC CAPITAL LETTER DJERVI;Lu;0;L;;;;;N;;;;2C3C;\n2C0D;GLAGOLITIC CAPITAL LETTER KAKO;Lu;0;L;;;;;N;;;;2C3D;\n2C0E;GLAGOLITIC CAPITAL LETTER LJUDIJE;Lu;0;L;;;;;N;;;;2C3E;\n2C0F;GLAGOLITIC CAPITAL LETTER MYSLITE;Lu;0;L;;;;;N;;;;2C3F;\n2C10;GLAGOLITIC CAPITAL LETTER NASHI;Lu;0;L;;;;;N;;;;2C40;\n2C11;GLAGOLITIC CAPITAL LETTER ONU;Lu;0;L;;;;;N;;;;2C41;\n2C12;GLAGOLITIC CAPITAL LETTER POKOJI;Lu;0;L;;;;;N;;;;2C42;\n2C13;GLAGOLITIC CAPITAL LETTER RITSI;Lu;0;L;;;;;N;;;;2C43;\n2C14;GLAGOLITIC CAPITAL LETTER SLOVO;Lu;0;L;;;;;N;;;;2C44;\n2C15;GLAGOLITIC CAPITAL LETTER TVRIDO;Lu;0;L;;;;;N;;;;2C45;\n2C16;GLAGOLITIC CAPITAL LETTER UKU;Lu;0;L;;;;;N;;;;2C46;\n2C17;GLAGOLITIC CAPITAL LETTER FRITU;Lu;0;L;;;;;N;;;;2C47;\n2C18;GLAGOLITIC CAPITAL LETTER HERU;Lu;0;L;;;;;N;;;;2C48;\n2C19;GLAGOLITIC CAPITAL LETTER OTU;Lu;0;L;;;;;N;;;;2C49;\n2C1A;GLAGOLITIC CAPITAL LETTER PE;Lu;0;L;;;;;N;;;;2C4A;\n2C1B;GLAGOLITIC CAPITAL LETTER SHTA;Lu;0;L;;;;;N;;;;2C4B;\n2C1C;GLAGOLITIC CAPITAL LETTER TSI;Lu;0;L;;;;;N;;;;2C4C;\n2C1D;GLAGOLITIC CAPITAL LETTER CHRIVI;Lu;0;L;;;;;N;;;;2C4D;\n2C1E;GLAGOLITIC CAPITAL LETTER SHA;Lu;0;L;;;;;N;;;;2C4E;\n2C1F;GLAGOLITIC CAPITAL LETTER YERU;Lu;0;L;;;;;N;;;;2C4F;\n2C20;GLAGOLITIC CAPITAL LETTER YERI;Lu;0;L;;;;;N;;;;2C50;\n2C21;GLAGOLITIC CAPITAL LETTER YATI;Lu;0;L;;;;;N;;;;2C51;\n2C22;GLAGOLITIC CAPITAL LETTER SPIDERY HA;Lu;0;L;;;;;N;;;;2C52;\n2C23;GLAGOLITIC CAPITAL LETTER YU;Lu;0;L;;;;;N;;;;2C53;\n2C24;GLAGOLITIC CAPITAL LETTER SMALL YUS;Lu;0;L;;;;;N;;;;2C54;\n2C25;GLAGOLITIC CAPITAL LETTER SMALL YUS WITH TAIL;Lu;0;L;;;;;N;;;;2C55;\n2C26;GLAGOLITIC CAPITAL LETTER YO;Lu;0;L;;;;;N;;;;2C56;\n2C27;GLAGOLITIC CAPITAL LETTER IOTATED SMALL YUS;Lu;0;L;;;;;N;;;;2C57;\n2C28;GLAGOLITIC CAPITAL LETTER BIG YUS;Lu;0;L;;;;;N;;;;2C58;\n2C29;GLAGOLITIC CAPITAL LETTER IOTATED BIG YUS;Lu;0;L;;;;;N;;;;2C59;\n2C2A;GLAGOLITIC CAPITAL LETTER FITA;Lu;0;L;;;;;N;;;;2C5A;\n2C2B;GLAGOLITIC CAPITAL LETTER IZHITSA;Lu;0;L;;;;;N;;;;2C5B;\n2C2C;GLAGOLITIC CAPITAL LETTER SHTAPIC;Lu;0;L;;;;;N;;;;2C5C;\n2C2D;GLAGOLITIC CAPITAL LETTER TROKUTASTI A;Lu;0;L;;;;;N;;;;2C5D;\n2C2E;GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE;Lu;0;L;;;;;N;;;;2C5E;\n2C30;GLAGOLITIC SMALL LETTER AZU;Ll;0;L;;;;;N;;;2C00;;2C00\n2C31;GLAGOLITIC SMALL LETTER BUKY;Ll;0;L;;;;;N;;;2C01;;2C01\n2C32;GLAGOLITIC SMALL LETTER VEDE;Ll;0;L;;;;;N;;;2C02;;2C02\n2C33;GLAGOLITIC SMALL LETTER GLAGOLI;Ll;0;L;;;;;N;;;2C03;;2C03\n2C34;GLAGOLITIC SMALL LETTER DOBRO;Ll;0;L;;;;;N;;;2C04;;2C04\n2C35;GLAGOLITIC SMALL LETTER YESTU;Ll;0;L;;;;;N;;;2C05;;2C05\n2C36;GLAGOLITIC SMALL LETTER ZHIVETE;Ll;0;L;;;;;N;;;2C06;;2C06\n2C37;GLAGOLITIC SMALL LETTER DZELO;Ll;0;L;;;;;N;;;2C07;;2C07\n2C38;GLAGOLITIC SMALL LETTER ZEMLJA;Ll;0;L;;;;;N;;;2C08;;2C08\n2C39;GLAGOLITIC SMALL LETTER IZHE;Ll;0;L;;;;;N;;;2C09;;2C09\n2C3A;GLAGOLITIC SMALL LETTER INITIAL IZHE;Ll;0;L;;;;;N;;;2C0A;;2C0A\n2C3B;GLAGOLITIC SMALL LETTER I;Ll;0;L;;;;;N;;;2C0B;;2C0B\n2C3C;GLAGOLITIC SMALL LETTER DJERVI;Ll;0;L;;;;;N;;;2C0C;;2C0C\n2C3D;GLAGOLITIC SMALL LETTER KAKO;Ll;0;L;;;;;N;;;2C0D;;2C0D\n2C3E;GLAGOLITIC SMALL LETTER LJUDIJE;Ll;0;L;;;;;N;;;2C0E;;2C0E\n2C3F;GLAGOLITIC SMALL LETTER MYSLITE;Ll;0;L;;;;;N;;;2C0F;;2C0F\n2C40;GLAGOLITIC SMALL LETTER NASHI;Ll;0;L;;;;;N;;;2C10;;2C10\n2C41;GLAGOLITIC SMALL LETTER ONU;Ll;0;L;;;;;N;;;2C11;;2C11\n2C42;GLAGOLITIC SMALL LETTER POKOJI;Ll;0;L;;;;;N;;;2C12;;2C12\n2C43;GLAGOLITIC SMALL LETTER RITSI;Ll;0;L;;;;;N;;;2C13;;2C13\n2C44;GLAGOLITIC SMALL LETTER SLOVO;Ll;0;L;;;;;N;;;2C14;;2C14\n2C45;GLAGOLITIC SMALL LETTER TVRIDO;Ll;0;L;;;;;N;;;2C15;;2C15\n2C46;GLAGOLITIC SMALL LETTER UKU;Ll;0;L;;;;;N;;;2C16;;2C16\n2C47;GLAGOLITIC SMALL LETTER FRITU;Ll;0;L;;;;;N;;;2C17;;2C17\n2C48;GLAGOLITIC SMALL LETTER HERU;Ll;0;L;;;;;N;;;2C18;;2C18\n2C49;GLAGOLITIC SMALL LETTER OTU;Ll;0;L;;;;;N;;;2C19;;2C19\n2C4A;GLAGOLITIC SMALL LETTER PE;Ll;0;L;;;;;N;;;2C1A;;2C1A\n2C4B;GLAGOLITIC SMALL LETTER SHTA;Ll;0;L;;;;;N;;;2C1B;;2C1B\n2C4C;GLAGOLITIC SMALL LETTER TSI;Ll;0;L;;;;;N;;;2C1C;;2C1C\n2C4D;GLAGOLITIC SMALL LETTER CHRIVI;Ll;0;L;;;;;N;;;2C1D;;2C1D\n2C4E;GLAGOLITIC SMALL LETTER SHA;Ll;0;L;;;;;N;;;2C1E;;2C1E\n2C4F;GLAGOLITIC SMALL LETTER YERU;Ll;0;L;;;;;N;;;2C1F;;2C1F\n2C50;GLAGOLITIC SMALL LETTER YERI;Ll;0;L;;;;;N;;;2C20;;2C20\n2C51;GLAGOLITIC SMALL LETTER YATI;Ll;0;L;;;;;N;;;2C21;;2C21\n2C52;GLAGOLITIC SMALL LETTER SPIDERY HA;Ll;0;L;;;;;N;;;2C22;;2C22\n2C53;GLAGOLITIC SMALL LETTER YU;Ll;0;L;;;;;N;;;2C23;;2C23\n2C54;GLAGOLITIC SMALL LETTER SMALL YUS;Ll;0;L;;;;;N;;;2C24;;2C24\n2C55;GLAGOLITIC SMALL LETTER SMALL YUS WITH TAIL;Ll;0;L;;;;;N;;;2C25;;2C25\n2C56;GLAGOLITIC SMALL LETTER YO;Ll;0;L;;;;;N;;;2C26;;2C26\n2C57;GLAGOLITIC SMALL LETTER IOTATED SMALL YUS;Ll;0;L;;;;;N;;;2C27;;2C27\n2C58;GLAGOLITIC SMALL LETTER BIG YUS;Ll;0;L;;;;;N;;;2C28;;2C28\n2C59;GLAGOLITIC SMALL LETTER IOTATED BIG YUS;Ll;0;L;;;;;N;;;2C29;;2C29\n2C5A;GLAGOLITIC SMALL LETTER FITA;Ll;0;L;;;;;N;;;2C2A;;2C2A\n2C5B;GLAGOLITIC SMALL LETTER IZHITSA;Ll;0;L;;;;;N;;;2C2B;;2C2B\n2C5C;GLAGOLITIC SMALL LETTER SHTAPIC;Ll;0;L;;;;;N;;;2C2C;;2C2C\n2C5D;GLAGOLITIC SMALL LETTER TROKUTASTI A;Ll;0;L;;;;;N;;;2C2D;;2C2D\n2C5E;GLAGOLITIC SMALL LETTER LATINATE MYSLITE;Ll;0;L;;;;;N;;;2C2E;;2C2E\n2C60;LATIN CAPITAL LETTER L WITH DOUBLE BAR;Lu;0;L;;;;;N;;;;2C61;\n2C61;LATIN SMALL LETTER L WITH DOUBLE BAR;Ll;0;L;;;;;N;;;2C60;;2C60\n2C62;LATIN CAPITAL LETTER L WITH MIDDLE TILDE;Lu;0;L;;;;;N;;;;026B;\n2C63;LATIN CAPITAL LETTER P WITH STROKE;Lu;0;L;;;;;N;;;;1D7D;\n2C64;LATIN CAPITAL LETTER R WITH TAIL;Lu;0;L;;;;;N;;;;027D;\n2C65;LATIN SMALL LETTER A WITH STROKE;Ll;0;L;;;;;N;;;023A;;023A\n2C66;LATIN SMALL LETTER T WITH DIAGONAL STROKE;Ll;0;L;;;;;N;;;023E;;023E\n2C67;LATIN CAPITAL LETTER H WITH DESCENDER;Lu;0;L;;;;;N;;;;2C68;\n2C68;LATIN SMALL LETTER H WITH DESCENDER;Ll;0;L;;;;;N;;;2C67;;2C67\n2C69;LATIN CAPITAL LETTER K WITH DESCENDER;Lu;0;L;;;;;N;;;;2C6A;\n2C6A;LATIN SMALL LETTER K WITH DESCENDER;Ll;0;L;;;;;N;;;2C69;;2C69\n2C6B;LATIN CAPITAL LETTER Z WITH DESCENDER;Lu;0;L;;;;;N;;;;2C6C;\n2C6C;LATIN SMALL LETTER Z WITH DESCENDER;Ll;0;L;;;;;N;;;2C6B;;2C6B\n2C6D;LATIN CAPITAL LETTER ALPHA;Lu;0;L;;;;;N;;;;0251;\n2C6E;LATIN CAPITAL LETTER M WITH HOOK;Lu;0;L;;;;;N;;;;0271;\n2C6F;LATIN CAPITAL LETTER TURNED A;Lu;0;L;;;;;N;;;;0250;\n2C70;LATIN CAPITAL LETTER TURNED ALPHA;Lu;0;L;;;;;N;;;;0252;\n2C71;LATIN SMALL LETTER V WITH RIGHT HOOK;Ll;0;L;;;;;N;;;;;\n2C72;LATIN CAPITAL LETTER W WITH HOOK;Lu;0;L;;;;;N;;;;2C73;\n2C73;LATIN SMALL LETTER W WITH HOOK;Ll;0;L;;;;;N;;;2C72;;2C72\n2C74;LATIN SMALL LETTER V WITH CURL;Ll;0;L;;;;;N;;;;;\n2C75;LATIN CAPITAL LETTER HALF H;Lu;0;L;;;;;N;;;;2C76;\n2C76;LATIN SMALL LETTER HALF H;Ll;0;L;;;;;N;;;2C75;;2C75\n2C77;LATIN SMALL LETTER TAILLESS PHI;Ll;0;L;;;;;N;;;;;\n2C78;LATIN SMALL LETTER E WITH NOTCH;Ll;0;L;;;;;N;;;;;\n2C79;LATIN SMALL LETTER TURNED R WITH TAIL;Ll;0;L;;;;;N;;;;;\n2C7A;LATIN SMALL LETTER O WITH LOW RING INSIDE;Ll;0;L;;;;;N;;;;;\n2C7B;LATIN LETTER SMALL CAPITAL TURNED E;Ll;0;L;;;;;N;;;;;\n2C7C;LATIN SUBSCRIPT SMALL LETTER J;Lm;0;L;<sub> 006A;;;;N;;;;;\n2C7D;MODIFIER LETTER CAPITAL V;Lm;0;L;<super> 0056;;;;N;;;;;\n2C7E;LATIN CAPITAL LETTER S WITH SWASH TAIL;Lu;0;L;;;;;N;;;;023F;\n2C7F;LATIN CAPITAL LETTER Z WITH SWASH TAIL;Lu;0;L;;;;;N;;;;0240;\n2C80;COPTIC CAPITAL LETTER ALFA;Lu;0;L;;;;;N;;;;2C81;\n2C81;COPTIC SMALL LETTER ALFA;Ll;0;L;;;;;N;;;2C80;;2C80\n2C82;COPTIC CAPITAL LETTER VIDA;Lu;0;L;;;;;N;;;;2C83;\n2C83;COPTIC SMALL LETTER VIDA;Ll;0;L;;;;;N;;;2C82;;2C82\n2C84;COPTIC CAPITAL LETTER GAMMA;Lu;0;L;;;;;N;;;;2C85;\n2C85;COPTIC SMALL LETTER GAMMA;Ll;0;L;;;;;N;;;2C84;;2C84\n2C86;COPTIC CAPITAL LETTER DALDA;Lu;0;L;;;;;N;;;;2C87;\n2C87;COPTIC SMALL LETTER DALDA;Ll;0;L;;;;;N;;;2C86;;2C86\n2C88;COPTIC CAPITAL LETTER EIE;Lu;0;L;;;;;N;;;;2C89;\n2C89;COPTIC SMALL LETTER EIE;Ll;0;L;;;;;N;;;2C88;;2C88\n2C8A;COPTIC CAPITAL LETTER SOU;Lu;0;L;;;;;N;;;;2C8B;\n2C8B;COPTIC SMALL LETTER SOU;Ll;0;L;;;;;N;;;2C8A;;2C8A\n2C8C;COPTIC CAPITAL LETTER ZATA;Lu;0;L;;;;;N;;;;2C8D;\n2C8D;COPTIC SMALL LETTER ZATA;Ll;0;L;;;;;N;;;2C8C;;2C8C\n2C8E;COPTIC CAPITAL LETTER HATE;Lu;0;L;;;;;N;;;;2C8F;\n2C8F;COPTIC SMALL LETTER HATE;Ll;0;L;;;;;N;;;2C8E;;2C8E\n2C90;COPTIC CAPITAL LETTER THETHE;Lu;0;L;;;;;N;;;;2C91;\n2C91;COPTIC SMALL LETTER THETHE;Ll;0;L;;;;;N;;;2C90;;2C90\n2C92;COPTIC CAPITAL LETTER IAUDA;Lu;0;L;;;;;N;;;;2C93;\n2C93;COPTIC SMALL LETTER IAUDA;Ll;0;L;;;;;N;;;2C92;;2C92\n2C94;COPTIC CAPITAL LETTER KAPA;Lu;0;L;;;;;N;;;;2C95;\n2C95;COPTIC SMALL LETTER KAPA;Ll;0;L;;;;;N;;;2C94;;2C94\n2C96;COPTIC CAPITAL LETTER LAULA;Lu;0;L;;;;;N;;;;2C97;\n2C97;COPTIC SMALL LETTER LAULA;Ll;0;L;;;;;N;;;2C96;;2C96\n2C98;COPTIC CAPITAL LETTER MI;Lu;0;L;;;;;N;;;;2C99;\n2C99;COPTIC SMALL LETTER MI;Ll;0;L;;;;;N;;;2C98;;2C98\n2C9A;COPTIC CAPITAL LETTER NI;Lu;0;L;;;;;N;;;;2C9B;\n2C9B;COPTIC SMALL LETTER NI;Ll;0;L;;;;;N;;;2C9A;;2C9A\n2C9C;COPTIC CAPITAL LETTER KSI;Lu;0;L;;;;;N;;;;2C9D;\n2C9D;COPTIC SMALL LETTER KSI;Ll;0;L;;;;;N;;;2C9C;;2C9C\n2C9E;COPTIC CAPITAL LETTER O;Lu;0;L;;;;;N;;;;2C9F;\n2C9F;COPTIC SMALL LETTER O;Ll;0;L;;;;;N;;;2C9E;;2C9E\n2CA0;COPTIC CAPITAL LETTER PI;Lu;0;L;;;;;N;;;;2CA1;\n2CA1;COPTIC SMALL LETTER PI;Ll;0;L;;;;;N;;;2CA0;;2CA0\n2CA2;COPTIC CAPITAL LETTER RO;Lu;0;L;;;;;N;;;;2CA3;\n2CA3;COPTIC SMALL LETTER RO;Ll;0;L;;;;;N;;;2CA2;;2CA2\n2CA4;COPTIC CAPITAL LETTER SIMA;Lu;0;L;;;;;N;;;;2CA5;\n2CA5;COPTIC SMALL LETTER SIMA;Ll;0;L;;;;;N;;;2CA4;;2CA4\n2CA6;COPTIC CAPITAL LETTER TAU;Lu;0;L;;;;;N;;;;2CA7;\n2CA7;COPTIC SMALL LETTER TAU;Ll;0;L;;;;;N;;;2CA6;;2CA6\n2CA8;COPTIC CAPITAL LETTER UA;Lu;0;L;;;;;N;;;;2CA9;\n2CA9;COPTIC SMALL LETTER UA;Ll;0;L;;;;;N;;;2CA8;;2CA8\n2CAA;COPTIC CAPITAL LETTER FI;Lu;0;L;;;;;N;;;;2CAB;\n2CAB;COPTIC SMALL LETTER FI;Ll;0;L;;;;;N;;;2CAA;;2CAA\n2CAC;COPTIC CAPITAL LETTER KHI;Lu;0;L;;;;;N;;;;2CAD;\n2CAD;COPTIC SMALL LETTER KHI;Ll;0;L;;;;;N;;;2CAC;;2CAC\n2CAE;COPTIC CAPITAL LETTER PSI;Lu;0;L;;;;;N;;;;2CAF;\n2CAF;COPTIC SMALL LETTER PSI;Ll;0;L;;;;;N;;;2CAE;;2CAE\n2CB0;COPTIC CAPITAL LETTER OOU;Lu;0;L;;;;;N;;;;2CB1;\n2CB1;COPTIC SMALL LETTER OOU;Ll;0;L;;;;;N;;;2CB0;;2CB0\n2CB2;COPTIC CAPITAL LETTER DIALECT-P ALEF;Lu;0;L;;;;;N;;;;2CB3;\n2CB3;COPTIC SMALL LETTER DIALECT-P ALEF;Ll;0;L;;;;;N;;;2CB2;;2CB2\n2CB4;COPTIC CAPITAL LETTER OLD COPTIC AIN;Lu;0;L;;;;;N;;;;2CB5;\n2CB5;COPTIC SMALL LETTER OLD COPTIC AIN;Ll;0;L;;;;;N;;;2CB4;;2CB4\n2CB6;COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE;Lu;0;L;;;;;N;;;;2CB7;\n2CB7;COPTIC SMALL LETTER CRYPTOGRAMMIC EIE;Ll;0;L;;;;;N;;;2CB6;;2CB6\n2CB8;COPTIC CAPITAL LETTER DIALECT-P KAPA;Lu;0;L;;;;;N;;;;2CB9;\n2CB9;COPTIC SMALL LETTER DIALECT-P KAPA;Ll;0;L;;;;;N;;;2CB8;;2CB8\n2CBA;COPTIC CAPITAL LETTER DIALECT-P NI;Lu;0;L;;;;;N;;;;2CBB;\n2CBB;COPTIC SMALL LETTER DIALECT-P NI;Ll;0;L;;;;;N;;;2CBA;;2CBA\n2CBC;COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI;Lu;0;L;;;;;N;;;;2CBD;\n2CBD;COPTIC SMALL LETTER CRYPTOGRAMMIC NI;Ll;0;L;;;;;N;;;2CBC;;2CBC\n2CBE;COPTIC CAPITAL LETTER OLD COPTIC OOU;Lu;0;L;;;;;N;;;;2CBF;\n2CBF;COPTIC SMALL LETTER OLD COPTIC OOU;Ll;0;L;;;;;N;;;2CBE;;2CBE\n2CC0;COPTIC CAPITAL LETTER SAMPI;Lu;0;L;;;;;N;;;;2CC1;\n2CC1;COPTIC SMALL LETTER SAMPI;Ll;0;L;;;;;N;;;2CC0;;2CC0\n2CC2;COPTIC CAPITAL LETTER CROSSED SHEI;Lu;0;L;;;;;N;;;;2CC3;\n2CC3;COPTIC SMALL LETTER CROSSED SHEI;Ll;0;L;;;;;N;;;2CC2;;2CC2\n2CC4;COPTIC CAPITAL LETTER OLD COPTIC SHEI;Lu;0;L;;;;;N;;;;2CC5;\n2CC5;COPTIC SMALL LETTER OLD COPTIC SHEI;Ll;0;L;;;;;N;;;2CC4;;2CC4\n2CC6;COPTIC CAPITAL LETTER OLD COPTIC ESH;Lu;0;L;;;;;N;;;;2CC7;\n2CC7;COPTIC SMALL LETTER OLD COPTIC ESH;Ll;0;L;;;;;N;;;2CC6;;2CC6\n2CC8;COPTIC CAPITAL LETTER AKHMIMIC KHEI;Lu;0;L;;;;;N;;;;2CC9;\n2CC9;COPTIC SMALL LETTER AKHMIMIC KHEI;Ll;0;L;;;;;N;;;2CC8;;2CC8\n2CCA;COPTIC CAPITAL LETTER DIALECT-P HORI;Lu;0;L;;;;;N;;;;2CCB;\n2CCB;COPTIC SMALL LETTER DIALECT-P HORI;Ll;0;L;;;;;N;;;2CCA;;2CCA\n2CCC;COPTIC CAPITAL LETTER OLD COPTIC HORI;Lu;0;L;;;;;N;;;;2CCD;\n2CCD;COPTIC SMALL LETTER OLD COPTIC HORI;Ll;0;L;;;;;N;;;2CCC;;2CCC\n2CCE;COPTIC CAPITAL LETTER OLD COPTIC HA;Lu;0;L;;;;;N;;;;2CCF;\n2CCF;COPTIC SMALL LETTER OLD COPTIC HA;Ll;0;L;;;;;N;;;2CCE;;2CCE\n2CD0;COPTIC CAPITAL LETTER L-SHAPED HA;Lu;0;L;;;;;N;;;;2CD1;\n2CD1;COPTIC SMALL LETTER L-SHAPED HA;Ll;0;L;;;;;N;;;2CD0;;2CD0\n2CD2;COPTIC CAPITAL LETTER OLD COPTIC HEI;Lu;0;L;;;;;N;;;;2CD3;\n2CD3;COPTIC SMALL LETTER OLD COPTIC HEI;Ll;0;L;;;;;N;;;2CD2;;2CD2\n2CD4;COPTIC CAPITAL LETTER OLD COPTIC HAT;Lu;0;L;;;;;N;;;;2CD5;\n2CD5;COPTIC SMALL LETTER OLD COPTIC HAT;Ll;0;L;;;;;N;;;2CD4;;2CD4\n2CD6;COPTIC CAPITAL LETTER OLD COPTIC GANGIA;Lu;0;L;;;;;N;;;;2CD7;\n2CD7;COPTIC SMALL LETTER OLD COPTIC GANGIA;Ll;0;L;;;;;N;;;2CD6;;2CD6\n2CD8;COPTIC CAPITAL LETTER OLD COPTIC DJA;Lu;0;L;;;;;N;;;;2CD9;\n2CD9;COPTIC SMALL LETTER OLD COPTIC DJA;Ll;0;L;;;;;N;;;2CD8;;2CD8\n2CDA;COPTIC CAPITAL LETTER OLD COPTIC SHIMA;Lu;0;L;;;;;N;;;;2CDB;\n2CDB;COPTIC SMALL LETTER OLD COPTIC SHIMA;Ll;0;L;;;;;N;;;2CDA;;2CDA\n2CDC;COPTIC CAPITAL LETTER OLD NUBIAN SHIMA;Lu;0;L;;;;;N;;;;2CDD;\n2CDD;COPTIC SMALL LETTER OLD NUBIAN SHIMA;Ll;0;L;;;;;N;;;2CDC;;2CDC\n2CDE;COPTIC CAPITAL LETTER OLD NUBIAN NGI;Lu;0;L;;;;;N;;;;2CDF;\n2CDF;COPTIC SMALL LETTER OLD NUBIAN NGI;Ll;0;L;;;;;N;;;2CDE;;2CDE\n2CE0;COPTIC CAPITAL LETTER OLD NUBIAN NYI;Lu;0;L;;;;;N;;;;2CE1;\n2CE1;COPTIC SMALL LETTER OLD NUBIAN NYI;Ll;0;L;;;;;N;;;2CE0;;2CE0\n2CE2;COPTIC CAPITAL LETTER OLD NUBIAN WAU;Lu;0;L;;;;;N;;;;2CE3;\n2CE3;COPTIC SMALL LETTER OLD NUBIAN WAU;Ll;0;L;;;;;N;;;2CE2;;2CE2\n2CE4;COPTIC SYMBOL KAI;Ll;0;L;;;;;N;;;;;\n2CE5;COPTIC SYMBOL MI RO;So;0;ON;;;;;N;;;;;\n2CE6;COPTIC SYMBOL PI RO;So;0;ON;;;;;N;;;;;\n2CE7;COPTIC SYMBOL STAUROS;So;0;ON;;;;;N;;;;;\n2CE8;COPTIC SYMBOL TAU RO;So;0;ON;;;;;N;;;;;\n2CE9;COPTIC SYMBOL KHI RO;So;0;ON;;;;;N;;;;;\n2CEA;COPTIC SYMBOL SHIMA SIMA;So;0;ON;;;;;N;;;;;\n2CEB;COPTIC CAPITAL LETTER CRYPTOGRAMMIC SHEI;Lu;0;L;;;;;N;;;;2CEC;\n2CEC;COPTIC SMALL LETTER CRYPTOGRAMMIC SHEI;Ll;0;L;;;;;N;;;2CEB;;2CEB\n2CED;COPTIC CAPITAL LETTER CRYPTOGRAMMIC GANGIA;Lu;0;L;;;;;N;;;;2CEE;\n2CEE;COPTIC SMALL LETTER CRYPTOGRAMMIC GANGIA;Ll;0;L;;;;;N;;;2CED;;2CED\n2CEF;COPTIC COMBINING NI ABOVE;Mn;230;NSM;;;;;N;;;;;\n2CF0;COPTIC COMBINING SPIRITUS ASPER;Mn;230;NSM;;;;;N;;;;;\n2CF1;COPTIC COMBINING SPIRITUS LENIS;Mn;230;NSM;;;;;N;;;;;\n2CF2;COPTIC CAPITAL LETTER BOHAIRIC KHEI;Lu;0;L;;;;;N;;;;2CF3;\n2CF3;COPTIC SMALL LETTER BOHAIRIC KHEI;Ll;0;L;;;;;N;;;2CF2;;2CF2\n2CF9;COPTIC OLD NUBIAN FULL STOP;Po;0;ON;;;;;N;;;;;\n2CFA;COPTIC OLD NUBIAN DIRECT QUESTION MARK;Po;0;ON;;;;;N;;;;;\n2CFB;COPTIC OLD NUBIAN INDIRECT QUESTION MARK;Po;0;ON;;;;;N;;;;;\n2CFC;COPTIC OLD NUBIAN VERSE DIVIDER;Po;0;ON;;;;;N;;;;;\n2CFD;COPTIC FRACTION ONE HALF;No;0;ON;;;;1/2;N;;;;;\n2CFE;COPTIC FULL STOP;Po;0;ON;;;;;N;;;;;\n2CFF;COPTIC MORPHOLOGICAL DIVIDER;Po;0;ON;;;;;N;;;;;\n2D00;GEORGIAN SMALL LETTER AN;Ll;0;L;;;;;N;;;10A0;;10A0\n2D01;GEORGIAN SMALL LETTER BAN;Ll;0;L;;;;;N;;;10A1;;10A1\n2D02;GEORGIAN SMALL LETTER GAN;Ll;0;L;;;;;N;;;10A2;;10A2\n2D03;GEORGIAN SMALL LETTER DON;Ll;0;L;;;;;N;;;10A3;;10A3\n2D04;GEORGIAN SMALL LETTER EN;Ll;0;L;;;;;N;;;10A4;;10A4\n2D05;GEORGIAN SMALL LETTER VIN;Ll;0;L;;;;;N;;;10A5;;10A5\n2D06;GEORGIAN SMALL LETTER ZEN;Ll;0;L;;;;;N;;;10A6;;10A6\n2D07;GEORGIAN SMALL LETTER TAN;Ll;0;L;;;;;N;;;10A7;;10A7\n2D08;GEORGIAN SMALL LETTER IN;Ll;0;L;;;;;N;;;10A8;;10A8\n2D09;GEORGIAN SMALL LETTER KAN;Ll;0;L;;;;;N;;;10A9;;10A9\n2D0A;GEORGIAN SMALL LETTER LAS;Ll;0;L;;;;;N;;;10AA;;10AA\n2D0B;GEORGIAN SMALL LETTER MAN;Ll;0;L;;;;;N;;;10AB;;10AB\n2D0C;GEORGIAN SMALL LETTER NAR;Ll;0;L;;;;;N;;;10AC;;10AC\n2D0D;GEORGIAN SMALL LETTER ON;Ll;0;L;;;;;N;;;10AD;;10AD\n2D0E;GEORGIAN SMALL LETTER PAR;Ll;0;L;;;;;N;;;10AE;;10AE\n2D0F;GEORGIAN SMALL LETTER ZHAR;Ll;0;L;;;;;N;;;10AF;;10AF\n2D10;GEORGIAN SMALL LETTER RAE;Ll;0;L;;;;;N;;;10B0;;10B0\n2D11;GEORGIAN SMALL LETTER SAN;Ll;0;L;;;;;N;;;10B1;;10B1\n2D12;GEORGIAN SMALL LETTER TAR;Ll;0;L;;;;;N;;;10B2;;10B2\n2D13;GEORGIAN SMALL LETTER UN;Ll;0;L;;;;;N;;;10B3;;10B3\n2D14;GEORGIAN SMALL LETTER PHAR;Ll;0;L;;;;;N;;;10B4;;10B4\n2D15;GEORGIAN SMALL LETTER KHAR;Ll;0;L;;;;;N;;;10B5;;10B5\n2D16;GEORGIAN SMALL LETTER GHAN;Ll;0;L;;;;;N;;;10B6;;10B6\n2D17;GEORGIAN SMALL LETTER QAR;Ll;0;L;;;;;N;;;10B7;;10B7\n2D18;GEORGIAN SMALL LETTER SHIN;Ll;0;L;;;;;N;;;10B8;;10B8\n2D19;GEORGIAN SMALL LETTER CHIN;Ll;0;L;;;;;N;;;10B9;;10B9\n2D1A;GEORGIAN SMALL LETTER CAN;Ll;0;L;;;;;N;;;10BA;;10BA\n2D1B;GEORGIAN SMALL LETTER JIL;Ll;0;L;;;;;N;;;10BB;;10BB\n2D1C;GEORGIAN SMALL LETTER CIL;Ll;0;L;;;;;N;;;10BC;;10BC\n2D1D;GEORGIAN SMALL LETTER CHAR;Ll;0;L;;;;;N;;;10BD;;10BD\n2D1E;GEORGIAN SMALL LETTER XAN;Ll;0;L;;;;;N;;;10BE;;10BE\n2D1F;GEORGIAN SMALL LETTER JHAN;Ll;0;L;;;;;N;;;10BF;;10BF\n2D20;GEORGIAN SMALL LETTER HAE;Ll;0;L;;;;;N;;;10C0;;10C0\n2D21;GEORGIAN SMALL LETTER HE;Ll;0;L;;;;;N;;;10C1;;10C1\n2D22;GEORGIAN SMALL LETTER HIE;Ll;0;L;;;;;N;;;10C2;;10C2\n2D23;GEORGIAN SMALL LETTER WE;Ll;0;L;;;;;N;;;10C3;;10C3\n2D24;GEORGIAN SMALL LETTER HAR;Ll;0;L;;;;;N;;;10C4;;10C4\n2D25;GEORGIAN SMALL LETTER HOE;Ll;0;L;;;;;N;;;10C5;;10C5\n2D27;GEORGIAN SMALL LETTER YN;Ll;0;L;;;;;N;;;10C7;;10C7\n2D2D;GEORGIAN SMALL LETTER AEN;Ll;0;L;;;;;N;;;10CD;;10CD\n2D30;TIFINAGH LETTER YA;Lo;0;L;;;;;N;;;;;\n2D31;TIFINAGH LETTER YAB;Lo;0;L;;;;;N;;;;;\n2D32;TIFINAGH LETTER YABH;Lo;0;L;;;;;N;;;;;\n2D33;TIFINAGH LETTER YAG;Lo;0;L;;;;;N;;;;;\n2D34;TIFINAGH LETTER YAGHH;Lo;0;L;;;;;N;;;;;\n2D35;TIFINAGH LETTER BERBER ACADEMY YAJ;Lo;0;L;;;;;N;;;;;\n2D36;TIFINAGH LETTER YAJ;Lo;0;L;;;;;N;;;;;\n2D37;TIFINAGH LETTER YAD;Lo;0;L;;;;;N;;;;;\n2D38;TIFINAGH LETTER YADH;Lo;0;L;;;;;N;;;;;\n2D39;TIFINAGH LETTER YADD;Lo;0;L;;;;;N;;;;;\n2D3A;TIFINAGH LETTER YADDH;Lo;0;L;;;;;N;;;;;\n2D3B;TIFINAGH LETTER YEY;Lo;0;L;;;;;N;;;;;\n2D3C;TIFINAGH LETTER YAF;Lo;0;L;;;;;N;;;;;\n2D3D;TIFINAGH LETTER YAK;Lo;0;L;;;;;N;;;;;\n2D3E;TIFINAGH LETTER TUAREG YAK;Lo;0;L;;;;;N;;;;;\n2D3F;TIFINAGH LETTER YAKHH;Lo;0;L;;;;;N;;;;;\n2D40;TIFINAGH LETTER YAH;Lo;0;L;;;;;N;;;;;\n2D41;TIFINAGH LETTER BERBER ACADEMY YAH;Lo;0;L;;;;;N;;;;;\n2D42;TIFINAGH LETTER TUAREG YAH;Lo;0;L;;;;;N;;;;;\n2D43;TIFINAGH LETTER YAHH;Lo;0;L;;;;;N;;;;;\n2D44;TIFINAGH LETTER YAA;Lo;0;L;;;;;N;;;;;\n2D45;TIFINAGH LETTER YAKH;Lo;0;L;;;;;N;;;;;\n2D46;TIFINAGH LETTER TUAREG YAKH;Lo;0;L;;;;;N;;;;;\n2D47;TIFINAGH LETTER YAQ;Lo;0;L;;;;;N;;;;;\n2D48;TIFINAGH LETTER TUAREG YAQ;Lo;0;L;;;;;N;;;;;\n2D49;TIFINAGH LETTER YI;Lo;0;L;;;;;N;;;;;\n2D4A;TIFINAGH LETTER YAZH;Lo;0;L;;;;;N;;;;;\n2D4B;TIFINAGH LETTER AHAGGAR YAZH;Lo;0;L;;;;;N;;;;;\n2D4C;TIFINAGH LETTER TUAREG YAZH;Lo;0;L;;;;;N;;;;;\n2D4D;TIFINAGH LETTER YAL;Lo;0;L;;;;;N;;;;;\n2D4E;TIFINAGH LETTER YAM;Lo;0;L;;;;;N;;;;;\n2D4F;TIFINAGH LETTER YAN;Lo;0;L;;;;;N;;;;;\n2D50;TIFINAGH LETTER TUAREG YAGN;Lo;0;L;;;;;N;;;;;\n2D51;TIFINAGH LETTER TUAREG YANG;Lo;0;L;;;;;N;;;;;\n2D52;TIFINAGH LETTER YAP;Lo;0;L;;;;;N;;;;;\n2D53;TIFINAGH LETTER YU;Lo;0;L;;;;;N;;;;;\n2D54;TIFINAGH LETTER YAR;Lo;0;L;;;;;N;;;;;\n2D55;TIFINAGH LETTER YARR;Lo;0;L;;;;;N;;;;;\n2D56;TIFINAGH LETTER YAGH;Lo;0;L;;;;;N;;;;;\n2D57;TIFINAGH LETTER TUAREG YAGH;Lo;0;L;;;;;N;;;;;\n2D58;TIFINAGH LETTER AYER YAGH;Lo;0;L;;;;;N;;;;;\n2D59;TIFINAGH LETTER YAS;Lo;0;L;;;;;N;;;;;\n2D5A;TIFINAGH LETTER YASS;Lo;0;L;;;;;N;;;;;\n2D5B;TIFINAGH LETTER YASH;Lo;0;L;;;;;N;;;;;\n2D5C;TIFINAGH LETTER YAT;Lo;0;L;;;;;N;;;;;\n2D5D;TIFINAGH LETTER YATH;Lo;0;L;;;;;N;;;;;\n2D5E;TIFINAGH LETTER YACH;Lo;0;L;;;;;N;;;;;\n2D5F;TIFINAGH LETTER YATT;Lo;0;L;;;;;N;;;;;\n2D60;TIFINAGH LETTER YAV;Lo;0;L;;;;;N;;;;;\n2D61;TIFINAGH LETTER YAW;Lo;0;L;;;;;N;;;;;\n2D62;TIFINAGH LETTER YAY;Lo;0;L;;;;;N;;;;;\n2D63;TIFINAGH LETTER YAZ;Lo;0;L;;;;;N;;;;;\n2D64;TIFINAGH LETTER TAWELLEMET YAZ;Lo;0;L;;;;;N;;;;;\n2D65;TIFINAGH LETTER YAZZ;Lo;0;L;;;;;N;;;;;\n2D66;TIFINAGH LETTER YE;Lo;0;L;;;;;N;;;;;\n2D67;TIFINAGH LETTER YO;Lo;0;L;;;;;N;;;;;\n2D6F;TIFINAGH MODIFIER LETTER LABIALIZATION MARK;Lm;0;L;<super> 2D61;;;;N;;;;;\n2D70;TIFINAGH SEPARATOR MARK;Po;0;L;;;;;N;;;;;\n2D7F;TIFINAGH CONSONANT JOINER;Mn;9;NSM;;;;;N;;;;;\n2D80;ETHIOPIC SYLLABLE LOA;Lo;0;L;;;;;N;;;;;\n2D81;ETHIOPIC SYLLABLE MOA;Lo;0;L;;;;;N;;;;;\n2D82;ETHIOPIC SYLLABLE ROA;Lo;0;L;;;;;N;;;;;\n2D83;ETHIOPIC SYLLABLE SOA;Lo;0;L;;;;;N;;;;;\n2D84;ETHIOPIC SYLLABLE SHOA;Lo;0;L;;;;;N;;;;;\n2D85;ETHIOPIC SYLLABLE BOA;Lo;0;L;;;;;N;;;;;\n2D86;ETHIOPIC SYLLABLE TOA;Lo;0;L;;;;;N;;;;;\n2D87;ETHIOPIC SYLLABLE COA;Lo;0;L;;;;;N;;;;;\n2D88;ETHIOPIC SYLLABLE NOA;Lo;0;L;;;;;N;;;;;\n2D89;ETHIOPIC SYLLABLE NYOA;Lo;0;L;;;;;N;;;;;\n2D8A;ETHIOPIC SYLLABLE GLOTTAL OA;Lo;0;L;;;;;N;;;;;\n2D8B;ETHIOPIC SYLLABLE ZOA;Lo;0;L;;;;;N;;;;;\n2D8C;ETHIOPIC SYLLABLE DOA;Lo;0;L;;;;;N;;;;;\n2D8D;ETHIOPIC SYLLABLE DDOA;Lo;0;L;;;;;N;;;;;\n2D8E;ETHIOPIC SYLLABLE JOA;Lo;0;L;;;;;N;;;;;\n2D8F;ETHIOPIC SYLLABLE THOA;Lo;0;L;;;;;N;;;;;\n2D90;ETHIOPIC SYLLABLE CHOA;Lo;0;L;;;;;N;;;;;\n2D91;ETHIOPIC SYLLABLE PHOA;Lo;0;L;;;;;N;;;;;\n2D92;ETHIOPIC SYLLABLE POA;Lo;0;L;;;;;N;;;;;\n2D93;ETHIOPIC SYLLABLE GGWA;Lo;0;L;;;;;N;;;;;\n2D94;ETHIOPIC SYLLABLE GGWI;Lo;0;L;;;;;N;;;;;\n2D95;ETHIOPIC SYLLABLE GGWEE;Lo;0;L;;;;;N;;;;;\n2D96;ETHIOPIC SYLLABLE GGWE;Lo;0;L;;;;;N;;;;;\n2DA0;ETHIOPIC SYLLABLE SSA;Lo;0;L;;;;;N;;;;;\n2DA1;ETHIOPIC SYLLABLE SSU;Lo;0;L;;;;;N;;;;;\n2DA2;ETHIOPIC SYLLABLE SSI;Lo;0;L;;;;;N;;;;;\n2DA3;ETHIOPIC SYLLABLE SSAA;Lo;0;L;;;;;N;;;;;\n2DA4;ETHIOPIC SYLLABLE SSEE;Lo;0;L;;;;;N;;;;;\n2DA5;ETHIOPIC SYLLABLE SSE;Lo;0;L;;;;;N;;;;;\n2DA6;ETHIOPIC SYLLABLE SSO;Lo;0;L;;;;;N;;;;;\n2DA8;ETHIOPIC SYLLABLE CCA;Lo;0;L;;;;;N;;;;;\n2DA9;ETHIOPIC SYLLABLE CCU;Lo;0;L;;;;;N;;;;;\n2DAA;ETHIOPIC SYLLABLE CCI;Lo;0;L;;;;;N;;;;;\n2DAB;ETHIOPIC SYLLABLE CCAA;Lo;0;L;;;;;N;;;;;\n2DAC;ETHIOPIC SYLLABLE CCEE;Lo;0;L;;;;;N;;;;;\n2DAD;ETHIOPIC SYLLABLE CCE;Lo;0;L;;;;;N;;;;;\n2DAE;ETHIOPIC SYLLABLE CCO;Lo;0;L;;;;;N;;;;;\n2DB0;ETHIOPIC SYLLABLE ZZA;Lo;0;L;;;;;N;;;;;\n2DB1;ETHIOPIC SYLLABLE ZZU;Lo;0;L;;;;;N;;;;;\n2DB2;ETHIOPIC SYLLABLE ZZI;Lo;0;L;;;;;N;;;;;\n2DB3;ETHIOPIC SYLLABLE ZZAA;Lo;0;L;;;;;N;;;;;\n2DB4;ETHIOPIC SYLLABLE ZZEE;Lo;0;L;;;;;N;;;;;\n2DB5;ETHIOPIC SYLLABLE ZZE;Lo;0;L;;;;;N;;;;;\n2DB6;ETHIOPIC SYLLABLE ZZO;Lo;0;L;;;;;N;;;;;\n2DB8;ETHIOPIC SYLLABLE CCHA;Lo;0;L;;;;;N;;;;;\n2DB9;ETHIOPIC SYLLABLE CCHU;Lo;0;L;;;;;N;;;;;\n2DBA;ETHIOPIC SYLLABLE CCHI;Lo;0;L;;;;;N;;;;;\n2DBB;ETHIOPIC SYLLABLE CCHAA;Lo;0;L;;;;;N;;;;;\n2DBC;ETHIOPIC SYLLABLE CCHEE;Lo;0;L;;;;;N;;;;;\n2DBD;ETHIOPIC SYLLABLE CCHE;Lo;0;L;;;;;N;;;;;\n2DBE;ETHIOPIC SYLLABLE CCHO;Lo;0;L;;;;;N;;;;;\n2DC0;ETHIOPIC SYLLABLE QYA;Lo;0;L;;;;;N;;;;;\n2DC1;ETHIOPIC SYLLABLE QYU;Lo;0;L;;;;;N;;;;;\n2DC2;ETHIOPIC SYLLABLE QYI;Lo;0;L;;;;;N;;;;;\n2DC3;ETHIOPIC SYLLABLE QYAA;Lo;0;L;;;;;N;;;;;\n2DC4;ETHIOPIC SYLLABLE QYEE;Lo;0;L;;;;;N;;;;;\n2DC5;ETHIOPIC SYLLABLE QYE;Lo;0;L;;;;;N;;;;;\n2DC6;ETHIOPIC SYLLABLE QYO;Lo;0;L;;;;;N;;;;;\n2DC8;ETHIOPIC SYLLABLE KYA;Lo;0;L;;;;;N;;;;;\n2DC9;ETHIOPIC SYLLABLE KYU;Lo;0;L;;;;;N;;;;;\n2DCA;ETHIOPIC SYLLABLE KYI;Lo;0;L;;;;;N;;;;;\n2DCB;ETHIOPIC SYLLABLE KYAA;Lo;0;L;;;;;N;;;;;\n2DCC;ETHIOPIC SYLLABLE KYEE;Lo;0;L;;;;;N;;;;;\n2DCD;ETHIOPIC SYLLABLE KYE;Lo;0;L;;;;;N;;;;;\n2DCE;ETHIOPIC SYLLABLE KYO;Lo;0;L;;;;;N;;;;;\n2DD0;ETHIOPIC SYLLABLE XYA;Lo;0;L;;;;;N;;;;;\n2DD1;ETHIOPIC SYLLABLE XYU;Lo;0;L;;;;;N;;;;;\n2DD2;ETHIOPIC SYLLABLE XYI;Lo;0;L;;;;;N;;;;;\n2DD3;ETHIOPIC SYLLABLE XYAA;Lo;0;L;;;;;N;;;;;\n2DD4;ETHIOPIC SYLLABLE XYEE;Lo;0;L;;;;;N;;;;;\n2DD5;ETHIOPIC SYLLABLE XYE;Lo;0;L;;;;;N;;;;;\n2DD6;ETHIOPIC SYLLABLE XYO;Lo;0;L;;;;;N;;;;;\n2DD8;ETHIOPIC SYLLABLE GYA;Lo;0;L;;;;;N;;;;;\n2DD9;ETHIOPIC SYLLABLE GYU;Lo;0;L;;;;;N;;;;;\n2DDA;ETHIOPIC SYLLABLE GYI;Lo;0;L;;;;;N;;;;;\n2DDB;ETHIOPIC SYLLABLE GYAA;Lo;0;L;;;;;N;;;;;\n2DDC;ETHIOPIC SYLLABLE GYEE;Lo;0;L;;;;;N;;;;;\n2DDD;ETHIOPIC SYLLABLE GYE;Lo;0;L;;;;;N;;;;;\n2DDE;ETHIOPIC SYLLABLE GYO;Lo;0;L;;;;;N;;;;;\n2DE0;COMBINING CYRILLIC LETTER BE;Mn;230;NSM;;;;;N;;;;;\n2DE1;COMBINING CYRILLIC LETTER VE;Mn;230;NSM;;;;;N;;;;;\n2DE2;COMBINING CYRILLIC LETTER GHE;Mn;230;NSM;;;;;N;;;;;\n2DE3;COMBINING CYRILLIC LETTER DE;Mn;230;NSM;;;;;N;;;;;\n2DE4;COMBINING CYRILLIC LETTER ZHE;Mn;230;NSM;;;;;N;;;;;\n2DE5;COMBINING CYRILLIC LETTER ZE;Mn;230;NSM;;;;;N;;;;;\n2DE6;COMBINING CYRILLIC LETTER KA;Mn;230;NSM;;;;;N;;;;;\n2DE7;COMBINING CYRILLIC LETTER EL;Mn;230;NSM;;;;;N;;;;;\n2DE8;COMBINING CYRILLIC LETTER EM;Mn;230;NSM;;;;;N;;;;;\n2DE9;COMBINING CYRILLIC LETTER EN;Mn;230;NSM;;;;;N;;;;;\n2DEA;COMBINING CYRILLIC LETTER O;Mn;230;NSM;;;;;N;;;;;\n2DEB;COMBINING CYRILLIC LETTER PE;Mn;230;NSM;;;;;N;;;;;\n2DEC;COMBINING CYRILLIC LETTER ER;Mn;230;NSM;;;;;N;;;;;\n2DED;COMBINING CYRILLIC LETTER ES;Mn;230;NSM;;;;;N;;;;;\n2DEE;COMBINING CYRILLIC LETTER TE;Mn;230;NSM;;;;;N;;;;;\n2DEF;COMBINING CYRILLIC LETTER HA;Mn;230;NSM;;;;;N;;;;;\n2DF0;COMBINING CYRILLIC LETTER TSE;Mn;230;NSM;;;;;N;;;;;\n2DF1;COMBINING CYRILLIC LETTER CHE;Mn;230;NSM;;;;;N;;;;;\n2DF2;COMBINING CYRILLIC LETTER SHA;Mn;230;NSM;;;;;N;;;;;\n2DF3;COMBINING CYRILLIC LETTER SHCHA;Mn;230;NSM;;;;;N;;;;;\n2DF4;COMBINING CYRILLIC LETTER FITA;Mn;230;NSM;;;;;N;;;;;\n2DF5;COMBINING CYRILLIC LETTER ES-TE;Mn;230;NSM;;;;;N;;;;;\n2DF6;COMBINING CYRILLIC LETTER A;Mn;230;NSM;;;;;N;;;;;\n2DF7;COMBINING CYRILLIC LETTER IE;Mn;230;NSM;;;;;N;;;;;\n2DF8;COMBINING CYRILLIC LETTER DJERV;Mn;230;NSM;;;;;N;;;;;\n2DF9;COMBINING CYRILLIC LETTER MONOGRAPH UK;Mn;230;NSM;;;;;N;;;;;\n2DFA;COMBINING CYRILLIC LETTER YAT;Mn;230;NSM;;;;;N;;;;;\n2DFB;COMBINING CYRILLIC LETTER YU;Mn;230;NSM;;;;;N;;;;;\n2DFC;COMBINING CYRILLIC LETTER IOTIFIED A;Mn;230;NSM;;;;;N;;;;;\n2DFD;COMBINING CYRILLIC LETTER LITTLE YUS;Mn;230;NSM;;;;;N;;;;;\n2DFE;COMBINING CYRILLIC LETTER BIG YUS;Mn;230;NSM;;;;;N;;;;;\n2DFF;COMBINING CYRILLIC LETTER IOTIFIED BIG YUS;Mn;230;NSM;;;;;N;;;;;\n2E00;RIGHT ANGLE SUBSTITUTION MARKER;Po;0;ON;;;;;N;;;;;\n2E01;RIGHT ANGLE DOTTED SUBSTITUTION MARKER;Po;0;ON;;;;;N;;;;;\n2E02;LEFT SUBSTITUTION BRACKET;Pi;0;ON;;;;;Y;;;;;\n2E03;RIGHT SUBSTITUTION BRACKET;Pf;0;ON;;;;;Y;;;;;\n2E04;LEFT DOTTED SUBSTITUTION BRACKET;Pi;0;ON;;;;;Y;;;;;\n2E05;RIGHT DOTTED SUBSTITUTION BRACKET;Pf;0;ON;;;;;Y;;;;;\n2E06;RAISED INTERPOLATION MARKER;Po;0;ON;;;;;N;;;;;\n2E07;RAISED DOTTED INTERPOLATION MARKER;Po;0;ON;;;;;N;;;;;\n2E08;DOTTED TRANSPOSITION MARKER;Po;0;ON;;;;;N;;;;;\n2E09;LEFT TRANSPOSITION BRACKET;Pi;0;ON;;;;;Y;;;;;\n2E0A;RIGHT TRANSPOSITION BRACKET;Pf;0;ON;;;;;Y;;;;;\n2E0B;RAISED SQUARE;Po;0;ON;;;;;N;;;;;\n2E0C;LEFT RAISED OMISSION BRACKET;Pi;0;ON;;;;;Y;;;;;\n2E0D;RIGHT RAISED OMISSION BRACKET;Pf;0;ON;;;;;Y;;;;;\n2E0E;EDITORIAL CORONIS;Po;0;ON;;;;;N;;;;;\n2E0F;PARAGRAPHOS;Po;0;ON;;;;;N;;;;;\n2E10;FORKED PARAGRAPHOS;Po;0;ON;;;;;N;;;;;\n2E11;REVERSED FORKED PARAGRAPHOS;Po;0;ON;;;;;N;;;;;\n2E12;HYPODIASTOLE;Po;0;ON;;;;;N;;;;;\n2E13;DOTTED OBELOS;Po;0;ON;;;;;N;;;;;\n2E14;DOWNWARDS ANCORA;Po;0;ON;;;;;N;;;;;\n2E15;UPWARDS ANCORA;Po;0;ON;;;;;N;;;;;\n2E16;DOTTED RIGHT-POINTING ANGLE;Po;0;ON;;;;;N;;;;;\n2E17;DOUBLE OBLIQUE HYPHEN;Pd;0;ON;;;;;N;;;;;\n2E18;INVERTED INTERROBANG;Po;0;ON;;;;;N;;;;;\n2E19;PALM BRANCH;Po;0;ON;;;;;N;;;;;\n2E1A;HYPHEN WITH DIAERESIS;Pd;0;ON;;;;;N;;;;;\n2E1B;TILDE WITH RING ABOVE;Po;0;ON;;;;;N;;;;;\n2E1C;LEFT LOW PARAPHRASE BRACKET;Pi;0;ON;;;;;Y;;;;;\n2E1D;RIGHT LOW PARAPHRASE BRACKET;Pf;0;ON;;;;;Y;;;;;\n2E1E;TILDE WITH DOT ABOVE;Po;0;ON;;;;;N;;;;;\n2E1F;TILDE WITH DOT BELOW;Po;0;ON;;;;;N;;;;;\n2E20;LEFT VERTICAL BAR WITH QUILL;Pi;0;ON;;;;;Y;;;;;\n2E21;RIGHT VERTICAL BAR WITH QUILL;Pf;0;ON;;;;;Y;;;;;\n2E22;TOP LEFT HALF BRACKET;Ps;0;ON;;;;;Y;;;;;\n2E23;TOP RIGHT HALF BRACKET;Pe;0;ON;;;;;Y;;;;;\n2E24;BOTTOM LEFT HALF BRACKET;Ps;0;ON;;;;;Y;;;;;\n2E25;BOTTOM RIGHT HALF BRACKET;Pe;0;ON;;;;;Y;;;;;\n2E26;LEFT SIDEWAYS U BRACKET;Ps;0;ON;;;;;Y;;;;;\n2E27;RIGHT SIDEWAYS U BRACKET;Pe;0;ON;;;;;Y;;;;;\n2E28;LEFT DOUBLE PARENTHESIS;Ps;0;ON;;;;;Y;;;;;\n2E29;RIGHT DOUBLE PARENTHESIS;Pe;0;ON;;;;;Y;;;;;\n2E2A;TWO DOTS OVER ONE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n2E2B;ONE DOT OVER TWO DOTS PUNCTUATION;Po;0;ON;;;;;N;;;;;\n2E2C;SQUARED FOUR DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n2E2D;FIVE DOT MARK;Po;0;ON;;;;;N;;;;;\n2E2E;REVERSED QUESTION MARK;Po;0;ON;;;;;N;;;;;\n2E2F;VERTICAL TILDE;Lm;0;ON;;;;;N;;;;;\n2E30;RING POINT;Po;0;ON;;;;;N;;;;;\n2E31;WORD SEPARATOR MIDDLE DOT;Po;0;ON;;;;;N;;;;;\n2E32;TURNED COMMA;Po;0;ON;;;;;N;;;;;\n2E33;RAISED DOT;Po;0;ON;;;;;N;;;;;\n2E34;RAISED COMMA;Po;0;ON;;;;;N;;;;;\n2E35;TURNED SEMICOLON;Po;0;ON;;;;;N;;;;;\n2E36;DAGGER WITH LEFT GUARD;Po;0;ON;;;;;N;;;;;\n2E37;DAGGER WITH RIGHT GUARD;Po;0;ON;;;;;N;;;;;\n2E38;TURNED DAGGER;Po;0;ON;;;;;N;;;;;\n2E39;TOP HALF SECTION SIGN;Po;0;ON;;;;;N;;;;;\n2E3A;TWO-EM DASH;Pd;0;ON;;;;;N;;;;;\n2E3B;THREE-EM DASH;Pd;0;ON;;;;;N;;;;;\n2E80;CJK RADICAL REPEAT;So;0;ON;;;;;N;;;;;\n2E81;CJK RADICAL CLIFF;So;0;ON;;;;;N;;;;;\n2E82;CJK RADICAL SECOND ONE;So;0;ON;;;;;N;;;;;\n2E83;CJK RADICAL SECOND TWO;So;0;ON;;;;;N;;;;;\n2E84;CJK RADICAL SECOND THREE;So;0;ON;;;;;N;;;;;\n2E85;CJK RADICAL PERSON;So;0;ON;;;;;N;;;;;\n2E86;CJK RADICAL BOX;So;0;ON;;;;;N;;;;;\n2E87;CJK RADICAL TABLE;So;0;ON;;;;;N;;;;;\n2E88;CJK RADICAL KNIFE ONE;So;0;ON;;;;;N;;;;;\n2E89;CJK RADICAL KNIFE TWO;So;0;ON;;;;;N;;;;;\n2E8A;CJK RADICAL DIVINATION;So;0;ON;;;;;N;;;;;\n2E8B;CJK RADICAL SEAL;So;0;ON;;;;;N;;;;;\n2E8C;CJK RADICAL SMALL ONE;So;0;ON;;;;;N;;;;;\n2E8D;CJK RADICAL SMALL TWO;So;0;ON;;;;;N;;;;;\n2E8E;CJK RADICAL LAME ONE;So;0;ON;;;;;N;;;;;\n2E8F;CJK RADICAL LAME TWO;So;0;ON;;;;;N;;;;;\n2E90;CJK RADICAL LAME THREE;So;0;ON;;;;;N;;;;;\n2E91;CJK RADICAL LAME FOUR;So;0;ON;;;;;N;;;;;\n2E92;CJK RADICAL SNAKE;So;0;ON;;;;;N;;;;;\n2E93;CJK RADICAL THREAD;So;0;ON;;;;;N;;;;;\n2E94;CJK RADICAL SNOUT ONE;So;0;ON;;;;;N;;;;;\n2E95;CJK RADICAL SNOUT TWO;So;0;ON;;;;;N;;;;;\n2E96;CJK RADICAL HEART ONE;So;0;ON;;;;;N;;;;;\n2E97;CJK RADICAL HEART TWO;So;0;ON;;;;;N;;;;;\n2E98;CJK RADICAL HAND;So;0;ON;;;;;N;;;;;\n2E99;CJK RADICAL RAP;So;0;ON;;;;;N;;;;;\n2E9B;CJK RADICAL CHOKE;So;0;ON;;;;;N;;;;;\n2E9C;CJK RADICAL SUN;So;0;ON;;;;;N;;;;;\n2E9D;CJK RADICAL MOON;So;0;ON;;;;;N;;;;;\n2E9E;CJK RADICAL DEATH;So;0;ON;;;;;N;;;;;\n2E9F;CJK RADICAL MOTHER;So;0;ON;<compat> 6BCD;;;;N;;;;;\n2EA0;CJK RADICAL CIVILIAN;So;0;ON;;;;;N;;;;;\n2EA1;CJK RADICAL WATER ONE;So;0;ON;;;;;N;;;;;\n2EA2;CJK RADICAL WATER TWO;So;0;ON;;;;;N;;;;;\n2EA3;CJK RADICAL FIRE;So;0;ON;;;;;N;;;;;\n2EA4;CJK RADICAL PAW ONE;So;0;ON;;;;;N;;;;;\n2EA5;CJK RADICAL PAW TWO;So;0;ON;;;;;N;;;;;\n2EA6;CJK RADICAL SIMPLIFIED HALF TREE TRUNK;So;0;ON;;;;;N;;;;;\n2EA7;CJK RADICAL COW;So;0;ON;;;;;N;;;;;\n2EA8;CJK RADICAL DOG;So;0;ON;;;;;N;;;;;\n2EA9;CJK RADICAL JADE;So;0;ON;;;;;N;;;;;\n2EAA;CJK RADICAL BOLT OF CLOTH;So;0;ON;;;;;N;;;;;\n2EAB;CJK RADICAL EYE;So;0;ON;;;;;N;;;;;\n2EAC;CJK RADICAL SPIRIT ONE;So;0;ON;;;;;N;;;;;\n2EAD;CJK RADICAL SPIRIT TWO;So;0;ON;;;;;N;;;;;\n2EAE;CJK RADICAL BAMBOO;So;0;ON;;;;;N;;;;;\n2EAF;CJK RADICAL SILK;So;0;ON;;;;;N;;;;;\n2EB0;CJK RADICAL C-SIMPLIFIED SILK;So;0;ON;;;;;N;;;;;\n2EB1;CJK RADICAL NET ONE;So;0;ON;;;;;N;;;;;\n2EB2;CJK RADICAL NET TWO;So;0;ON;;;;;N;;;;;\n2EB3;CJK RADICAL NET THREE;So;0;ON;;;;;N;;;;;\n2EB4;CJK RADICAL NET FOUR;So;0;ON;;;;;N;;;;;\n2EB5;CJK RADICAL MESH;So;0;ON;;;;;N;;;;;\n2EB6;CJK RADICAL SHEEP;So;0;ON;;;;;N;;;;;\n2EB7;CJK RADICAL RAM;So;0;ON;;;;;N;;;;;\n2EB8;CJK RADICAL EWE;So;0;ON;;;;;N;;;;;\n2EB9;CJK RADICAL OLD;So;0;ON;;;;;N;;;;;\n2EBA;CJK RADICAL BRUSH ONE;So;0;ON;;;;;N;;;;;\n2EBB;CJK RADICAL BRUSH TWO;So;0;ON;;;;;N;;;;;\n2EBC;CJK RADICAL MEAT;So;0;ON;;;;;N;;;;;\n2EBD;CJK RADICAL MORTAR;So;0;ON;;;;;N;;;;;\n2EBE;CJK RADICAL GRASS ONE;So;0;ON;;;;;N;;;;;\n2EBF;CJK RADICAL GRASS TWO;So;0;ON;;;;;N;;;;;\n2EC0;CJK RADICAL GRASS THREE;So;0;ON;;;;;N;;;;;\n2EC1;CJK RADICAL TIGER;So;0;ON;;;;;N;;;;;\n2EC2;CJK RADICAL CLOTHES;So;0;ON;;;;;N;;;;;\n2EC3;CJK RADICAL WEST ONE;So;0;ON;;;;;N;;;;;\n2EC4;CJK RADICAL WEST TWO;So;0;ON;;;;;N;;;;;\n2EC5;CJK RADICAL C-SIMPLIFIED SEE;So;0;ON;;;;;N;;;;;\n2EC6;CJK RADICAL SIMPLIFIED HORN;So;0;ON;;;;;N;;;;;\n2EC7;CJK RADICAL HORN;So;0;ON;;;;;N;;;;;\n2EC8;CJK RADICAL C-SIMPLIFIED SPEECH;So;0;ON;;;;;N;;;;;\n2EC9;CJK RADICAL C-SIMPLIFIED SHELL;So;0;ON;;;;;N;;;;;\n2ECA;CJK RADICAL FOOT;So;0;ON;;;;;N;;;;;\n2ECB;CJK RADICAL C-SIMPLIFIED CART;So;0;ON;;;;;N;;;;;\n2ECC;CJK RADICAL SIMPLIFIED WALK;So;0;ON;;;;;N;;;;;\n2ECD;CJK RADICAL WALK ONE;So;0;ON;;;;;N;;;;;\n2ECE;CJK RADICAL WALK TWO;So;0;ON;;;;;N;;;;;\n2ECF;CJK RADICAL CITY;So;0;ON;;;;;N;;;;;\n2ED0;CJK RADICAL C-SIMPLIFIED GOLD;So;0;ON;;;;;N;;;;;\n2ED1;CJK RADICAL LONG ONE;So;0;ON;;;;;N;;;;;\n2ED2;CJK RADICAL LONG TWO;So;0;ON;;;;;N;;;;;\n2ED3;CJK RADICAL C-SIMPLIFIED LONG;So;0;ON;;;;;N;;;;;\n2ED4;CJK RADICAL C-SIMPLIFIED GATE;So;0;ON;;;;;N;;;;;\n2ED5;CJK RADICAL MOUND ONE;So;0;ON;;;;;N;;;;;\n2ED6;CJK RADICAL MOUND TWO;So;0;ON;;;;;N;;;;;\n2ED7;CJK RADICAL RAIN;So;0;ON;;;;;N;;;;;\n2ED8;CJK RADICAL BLUE;So;0;ON;;;;;N;;;;;\n2ED9;CJK RADICAL C-SIMPLIFIED TANNED LEATHER;So;0;ON;;;;;N;;;;;\n2EDA;CJK RADICAL C-SIMPLIFIED LEAF;So;0;ON;;;;;N;;;;;\n2EDB;CJK RADICAL C-SIMPLIFIED WIND;So;0;ON;;;;;N;;;;;\n2EDC;CJK RADICAL C-SIMPLIFIED FLY;So;0;ON;;;;;N;;;;;\n2EDD;CJK RADICAL EAT ONE;So;0;ON;;;;;N;;;;;\n2EDE;CJK RADICAL EAT TWO;So;0;ON;;;;;N;;;;;\n2EDF;CJK RADICAL EAT THREE;So;0;ON;;;;;N;;;;;\n2EE0;CJK RADICAL C-SIMPLIFIED EAT;So;0;ON;;;;;N;;;;;\n2EE1;CJK RADICAL HEAD;So;0;ON;;;;;N;;;;;\n2EE2;CJK RADICAL C-SIMPLIFIED HORSE;So;0;ON;;;;;N;;;;;\n2EE3;CJK RADICAL BONE;So;0;ON;;;;;N;;;;;\n2EE4;CJK RADICAL GHOST;So;0;ON;;;;;N;;;;;\n2EE5;CJK RADICAL C-SIMPLIFIED FISH;So;0;ON;;;;;N;;;;;\n2EE6;CJK RADICAL C-SIMPLIFIED BIRD;So;0;ON;;;;;N;;;;;\n2EE7;CJK RADICAL C-SIMPLIFIED SALT;So;0;ON;;;;;N;;;;;\n2EE8;CJK RADICAL SIMPLIFIED WHEAT;So;0;ON;;;;;N;;;;;\n2EE9;CJK RADICAL SIMPLIFIED YELLOW;So;0;ON;;;;;N;;;;;\n2EEA;CJK RADICAL C-SIMPLIFIED FROG;So;0;ON;;;;;N;;;;;\n2EEB;CJK RADICAL J-SIMPLIFIED EVEN;So;0;ON;;;;;N;;;;;\n2EEC;CJK RADICAL C-SIMPLIFIED EVEN;So;0;ON;;;;;N;;;;;\n2EED;CJK RADICAL J-SIMPLIFIED TOOTH;So;0;ON;;;;;N;;;;;\n2EEE;CJK RADICAL C-SIMPLIFIED TOOTH;So;0;ON;;;;;N;;;;;\n2EEF;CJK RADICAL J-SIMPLIFIED DRAGON;So;0;ON;;;;;N;;;;;\n2EF0;CJK RADICAL C-SIMPLIFIED DRAGON;So;0;ON;;;;;N;;;;;\n2EF1;CJK RADICAL TURTLE;So;0;ON;;;;;N;;;;;\n2EF2;CJK RADICAL J-SIMPLIFIED TURTLE;So;0;ON;;;;;N;;;;;\n2EF3;CJK RADICAL C-SIMPLIFIED TURTLE;So;0;ON;<compat> 9F9F;;;;N;;;;;\n2F00;KANGXI RADICAL ONE;So;0;ON;<compat> 4E00;;;;N;;;;;\n2F01;KANGXI RADICAL LINE;So;0;ON;<compat> 4E28;;;;N;;;;;\n2F02;KANGXI RADICAL DOT;So;0;ON;<compat> 4E36;;;;N;;;;;\n2F03;KANGXI RADICAL SLASH;So;0;ON;<compat> 4E3F;;;;N;;;;;\n2F04;KANGXI RADICAL SECOND;So;0;ON;<compat> 4E59;;;;N;;;;;\n2F05;KANGXI RADICAL HOOK;So;0;ON;<compat> 4E85;;;;N;;;;;\n2F06;KANGXI RADICAL TWO;So;0;ON;<compat> 4E8C;;;;N;;;;;\n2F07;KANGXI RADICAL LID;So;0;ON;<compat> 4EA0;;;;N;;;;;\n2F08;KANGXI RADICAL MAN;So;0;ON;<compat> 4EBA;;;;N;;;;;\n2F09;KANGXI RADICAL LEGS;So;0;ON;<compat> 513F;;;;N;;;;;\n2F0A;KANGXI RADICAL ENTER;So;0;ON;<compat> 5165;;;;N;;;;;\n2F0B;KANGXI RADICAL EIGHT;So;0;ON;<compat> 516B;;;;N;;;;;\n2F0C;KANGXI RADICAL DOWN BOX;So;0;ON;<compat> 5182;;;;N;;;;;\n2F0D;KANGXI RADICAL COVER;So;0;ON;<compat> 5196;;;;N;;;;;\n2F0E;KANGXI RADICAL ICE;So;0;ON;<compat> 51AB;;;;N;;;;;\n2F0F;KANGXI RADICAL TABLE;So;0;ON;<compat> 51E0;;;;N;;;;;\n2F10;KANGXI RADICAL OPEN BOX;So;0;ON;<compat> 51F5;;;;N;;;;;\n2F11;KANGXI RADICAL KNIFE;So;0;ON;<compat> 5200;;;;N;;;;;\n2F12;KANGXI RADICAL POWER;So;0;ON;<compat> 529B;;;;N;;;;;\n2F13;KANGXI RADICAL WRAP;So;0;ON;<compat> 52F9;;;;N;;;;;\n2F14;KANGXI RADICAL SPOON;So;0;ON;<compat> 5315;;;;N;;;;;\n2F15;KANGXI RADICAL RIGHT OPEN BOX;So;0;ON;<compat> 531A;;;;N;;;;;\n2F16;KANGXI RADICAL HIDING ENCLOSURE;So;0;ON;<compat> 5338;;;;N;;;;;\n2F17;KANGXI RADICAL TEN;So;0;ON;<compat> 5341;;;;N;;;;;\n2F18;KANGXI RADICAL DIVINATION;So;0;ON;<compat> 535C;;;;N;;;;;\n2F19;KANGXI RADICAL SEAL;So;0;ON;<compat> 5369;;;;N;;;;;\n2F1A;KANGXI RADICAL CLIFF;So;0;ON;<compat> 5382;;;;N;;;;;\n2F1B;KANGXI RADICAL PRIVATE;So;0;ON;<compat> 53B6;;;;N;;;;;\n2F1C;KANGXI RADICAL AGAIN;So;0;ON;<compat> 53C8;;;;N;;;;;\n2F1D;KANGXI RADICAL MOUTH;So;0;ON;<compat> 53E3;;;;N;;;;;\n2F1E;KANGXI RADICAL ENCLOSURE;So;0;ON;<compat> 56D7;;;;N;;;;;\n2F1F;KANGXI RADICAL EARTH;So;0;ON;<compat> 571F;;;;N;;;;;\n2F20;KANGXI RADICAL SCHOLAR;So;0;ON;<compat> 58EB;;;;N;;;;;\n2F21;KANGXI RADICAL GO;So;0;ON;<compat> 5902;;;;N;;;;;\n2F22;KANGXI RADICAL GO SLOWLY;So;0;ON;<compat> 590A;;;;N;;;;;\n2F23;KANGXI RADICAL EVENING;So;0;ON;<compat> 5915;;;;N;;;;;\n2F24;KANGXI RADICAL BIG;So;0;ON;<compat> 5927;;;;N;;;;;\n2F25;KANGXI RADICAL WOMAN;So;0;ON;<compat> 5973;;;;N;;;;;\n2F26;KANGXI RADICAL CHILD;So;0;ON;<compat> 5B50;;;;N;;;;;\n2F27;KANGXI RADICAL ROOF;So;0;ON;<compat> 5B80;;;;N;;;;;\n2F28;KANGXI RADICAL INCH;So;0;ON;<compat> 5BF8;;;;N;;;;;\n2F29;KANGXI RADICAL SMALL;So;0;ON;<compat> 5C0F;;;;N;;;;;\n2F2A;KANGXI RADICAL LAME;So;0;ON;<compat> 5C22;;;;N;;;;;\n2F2B;KANGXI RADICAL CORPSE;So;0;ON;<compat> 5C38;;;;N;;;;;\n2F2C;KANGXI RADICAL SPROUT;So;0;ON;<compat> 5C6E;;;;N;;;;;\n2F2D;KANGXI RADICAL MOUNTAIN;So;0;ON;<compat> 5C71;;;;N;;;;;\n2F2E;KANGXI RADICAL RIVER;So;0;ON;<compat> 5DDB;;;;N;;;;;\n2F2F;KANGXI RADICAL WORK;So;0;ON;<compat> 5DE5;;;;N;;;;;\n2F30;KANGXI RADICAL ONESELF;So;0;ON;<compat> 5DF1;;;;N;;;;;\n2F31;KANGXI RADICAL TURBAN;So;0;ON;<compat> 5DFE;;;;N;;;;;\n2F32;KANGXI RADICAL DRY;So;0;ON;<compat> 5E72;;;;N;;;;;\n2F33;KANGXI RADICAL SHORT THREAD;So;0;ON;<compat> 5E7A;;;;N;;;;;\n2F34;KANGXI RADICAL DOTTED CLIFF;So;0;ON;<compat> 5E7F;;;;N;;;;;\n2F35;KANGXI RADICAL LONG STRIDE;So;0;ON;<compat> 5EF4;;;;N;;;;;\n2F36;KANGXI RADICAL TWO HANDS;So;0;ON;<compat> 5EFE;;;;N;;;;;\n2F37;KANGXI RADICAL SHOOT;So;0;ON;<compat> 5F0B;;;;N;;;;;\n2F38;KANGXI RADICAL BOW;So;0;ON;<compat> 5F13;;;;N;;;;;\n2F39;KANGXI RADICAL SNOUT;So;0;ON;<compat> 5F50;;;;N;;;;;\n2F3A;KANGXI RADICAL BRISTLE;So;0;ON;<compat> 5F61;;;;N;;;;;\n2F3B;KANGXI RADICAL STEP;So;0;ON;<compat> 5F73;;;;N;;;;;\n2F3C;KANGXI RADICAL HEART;So;0;ON;<compat> 5FC3;;;;N;;;;;\n2F3D;KANGXI RADICAL HALBERD;So;0;ON;<compat> 6208;;;;N;;;;;\n2F3E;KANGXI RADICAL DOOR;So;0;ON;<compat> 6236;;;;N;;;;;\n2F3F;KANGXI RADICAL HAND;So;0;ON;<compat> 624B;;;;N;;;;;\n2F40;KANGXI RADICAL BRANCH;So;0;ON;<compat> 652F;;;;N;;;;;\n2F41;KANGXI RADICAL RAP;So;0;ON;<compat> 6534;;;;N;;;;;\n2F42;KANGXI RADICAL SCRIPT;So;0;ON;<compat> 6587;;;;N;;;;;\n2F43;KANGXI RADICAL DIPPER;So;0;ON;<compat> 6597;;;;N;;;;;\n2F44;KANGXI RADICAL AXE;So;0;ON;<compat> 65A4;;;;N;;;;;\n2F45;KANGXI RADICAL SQUARE;So;0;ON;<compat> 65B9;;;;N;;;;;\n2F46;KANGXI RADICAL NOT;So;0;ON;<compat> 65E0;;;;N;;;;;\n2F47;KANGXI RADICAL SUN;So;0;ON;<compat> 65E5;;;;N;;;;;\n2F48;KANGXI RADICAL SAY;So;0;ON;<compat> 66F0;;;;N;;;;;\n2F49;KANGXI RADICAL MOON;So;0;ON;<compat> 6708;;;;N;;;;;\n2F4A;KANGXI RADICAL TREE;So;0;ON;<compat> 6728;;;;N;;;;;\n2F4B;KANGXI RADICAL LACK;So;0;ON;<compat> 6B20;;;;N;;;;;\n2F4C;KANGXI RADICAL STOP;So;0;ON;<compat> 6B62;;;;N;;;;;\n2F4D;KANGXI RADICAL DEATH;So;0;ON;<compat> 6B79;;;;N;;;;;\n2F4E;KANGXI RADICAL WEAPON;So;0;ON;<compat> 6BB3;;;;N;;;;;\n2F4F;KANGXI RADICAL DO NOT;So;0;ON;<compat> 6BCB;;;;N;;;;;\n2F50;KANGXI RADICAL COMPARE;So;0;ON;<compat> 6BD4;;;;N;;;;;\n2F51;KANGXI RADICAL FUR;So;0;ON;<compat> 6BDB;;;;N;;;;;\n2F52;KANGXI RADICAL CLAN;So;0;ON;<compat> 6C0F;;;;N;;;;;\n2F53;KANGXI RADICAL STEAM;So;0;ON;<compat> 6C14;;;;N;;;;;\n2F54;KANGXI RADICAL WATER;So;0;ON;<compat> 6C34;;;;N;;;;;\n2F55;KANGXI RADICAL FIRE;So;0;ON;<compat> 706B;;;;N;;;;;\n2F56;KANGXI RADICAL CLAW;So;0;ON;<compat> 722A;;;;N;;;;;\n2F57;KANGXI RADICAL FATHER;So;0;ON;<compat> 7236;;;;N;;;;;\n2F58;KANGXI RADICAL DOUBLE X;So;0;ON;<compat> 723B;;;;N;;;;;\n2F59;KANGXI RADICAL HALF TREE TRUNK;So;0;ON;<compat> 723F;;;;N;;;;;\n2F5A;KANGXI RADICAL SLICE;So;0;ON;<compat> 7247;;;;N;;;;;\n2F5B;KANGXI RADICAL FANG;So;0;ON;<compat> 7259;;;;N;;;;;\n2F5C;KANGXI RADICAL COW;So;0;ON;<compat> 725B;;;;N;;;;;\n2F5D;KANGXI RADICAL DOG;So;0;ON;<compat> 72AC;;;;N;;;;;\n2F5E;KANGXI RADICAL PROFOUND;So;0;ON;<compat> 7384;;;;N;;;;;\n2F5F;KANGXI RADICAL JADE;So;0;ON;<compat> 7389;;;;N;;;;;\n2F60;KANGXI RADICAL MELON;So;0;ON;<compat> 74DC;;;;N;;;;;\n2F61;KANGXI RADICAL TILE;So;0;ON;<compat> 74E6;;;;N;;;;;\n2F62;KANGXI RADICAL SWEET;So;0;ON;<compat> 7518;;;;N;;;;;\n2F63;KANGXI RADICAL LIFE;So;0;ON;<compat> 751F;;;;N;;;;;\n2F64;KANGXI RADICAL USE;So;0;ON;<compat> 7528;;;;N;;;;;\n2F65;KANGXI RADICAL FIELD;So;0;ON;<compat> 7530;;;;N;;;;;\n2F66;KANGXI RADICAL BOLT OF CLOTH;So;0;ON;<compat> 758B;;;;N;;;;;\n2F67;KANGXI RADICAL SICKNESS;So;0;ON;<compat> 7592;;;;N;;;;;\n2F68;KANGXI RADICAL DOTTED TENT;So;0;ON;<compat> 7676;;;;N;;;;;\n2F69;KANGXI RADICAL WHITE;So;0;ON;<compat> 767D;;;;N;;;;;\n2F6A;KANGXI RADICAL SKIN;So;0;ON;<compat> 76AE;;;;N;;;;;\n2F6B;KANGXI RADICAL DISH;So;0;ON;<compat> 76BF;;;;N;;;;;\n2F6C;KANGXI RADICAL EYE;So;0;ON;<compat> 76EE;;;;N;;;;;\n2F6D;KANGXI RADICAL SPEAR;So;0;ON;<compat> 77DB;;;;N;;;;;\n2F6E;KANGXI RADICAL ARROW;So;0;ON;<compat> 77E2;;;;N;;;;;\n2F6F;KANGXI RADICAL STONE;So;0;ON;<compat> 77F3;;;;N;;;;;\n2F70;KANGXI RADICAL SPIRIT;So;0;ON;<compat> 793A;;;;N;;;;;\n2F71;KANGXI RADICAL TRACK;So;0;ON;<compat> 79B8;;;;N;;;;;\n2F72;KANGXI RADICAL GRAIN;So;0;ON;<compat> 79BE;;;;N;;;;;\n2F73;KANGXI RADICAL CAVE;So;0;ON;<compat> 7A74;;;;N;;;;;\n2F74;KANGXI RADICAL STAND;So;0;ON;<compat> 7ACB;;;;N;;;;;\n2F75;KANGXI RADICAL BAMBOO;So;0;ON;<compat> 7AF9;;;;N;;;;;\n2F76;KANGXI RADICAL RICE;So;0;ON;<compat> 7C73;;;;N;;;;;\n2F77;KANGXI RADICAL SILK;So;0;ON;<compat> 7CF8;;;;N;;;;;\n2F78;KANGXI RADICAL JAR;So;0;ON;<compat> 7F36;;;;N;;;;;\n2F79;KANGXI RADICAL NET;So;0;ON;<compat> 7F51;;;;N;;;;;\n2F7A;KANGXI RADICAL SHEEP;So;0;ON;<compat> 7F8A;;;;N;;;;;\n2F7B;KANGXI RADICAL FEATHER;So;0;ON;<compat> 7FBD;;;;N;;;;;\n2F7C;KANGXI RADICAL OLD;So;0;ON;<compat> 8001;;;;N;;;;;\n2F7D;KANGXI RADICAL AND;So;0;ON;<compat> 800C;;;;N;;;;;\n2F7E;KANGXI RADICAL PLOW;So;0;ON;<compat> 8012;;;;N;;;;;\n2F7F;KANGXI RADICAL EAR;So;0;ON;<compat> 8033;;;;N;;;;;\n2F80;KANGXI RADICAL BRUSH;So;0;ON;<compat> 807F;;;;N;;;;;\n2F81;KANGXI RADICAL MEAT;So;0;ON;<compat> 8089;;;;N;;;;;\n2F82;KANGXI RADICAL MINISTER;So;0;ON;<compat> 81E3;;;;N;;;;;\n2F83;KANGXI RADICAL SELF;So;0;ON;<compat> 81EA;;;;N;;;;;\n2F84;KANGXI RADICAL ARRIVE;So;0;ON;<compat> 81F3;;;;N;;;;;\n2F85;KANGXI RADICAL MORTAR;So;0;ON;<compat> 81FC;;;;N;;;;;\n2F86;KANGXI RADICAL TONGUE;So;0;ON;<compat> 820C;;;;N;;;;;\n2F87;KANGXI RADICAL OPPOSE;So;0;ON;<compat> 821B;;;;N;;;;;\n2F88;KANGXI RADICAL BOAT;So;0;ON;<compat> 821F;;;;N;;;;;\n2F89;KANGXI RADICAL STOPPING;So;0;ON;<compat> 826E;;;;N;;;;;\n2F8A;KANGXI RADICAL COLOR;So;0;ON;<compat> 8272;;;;N;;;;;\n2F8B;KANGXI RADICAL GRASS;So;0;ON;<compat> 8278;;;;N;;;;;\n2F8C;KANGXI RADICAL TIGER;So;0;ON;<compat> 864D;;;;N;;;;;\n2F8D;KANGXI RADICAL INSECT;So;0;ON;<compat> 866B;;;;N;;;;;\n2F8E;KANGXI RADICAL BLOOD;So;0;ON;<compat> 8840;;;;N;;;;;\n2F8F;KANGXI RADICAL WALK ENCLOSURE;So;0;ON;<compat> 884C;;;;N;;;;;\n2F90;KANGXI RADICAL CLOTHES;So;0;ON;<compat> 8863;;;;N;;;;;\n2F91;KANGXI RADICAL WEST;So;0;ON;<compat> 897E;;;;N;;;;;\n2F92;KANGXI RADICAL SEE;So;0;ON;<compat> 898B;;;;N;;;;;\n2F93;KANGXI RADICAL HORN;So;0;ON;<compat> 89D2;;;;N;;;;;\n2F94;KANGXI RADICAL SPEECH;So;0;ON;<compat> 8A00;;;;N;;;;;\n2F95;KANGXI RADICAL VALLEY;So;0;ON;<compat> 8C37;;;;N;;;;;\n2F96;KANGXI RADICAL BEAN;So;0;ON;<compat> 8C46;;;;N;;;;;\n2F97;KANGXI RADICAL PIG;So;0;ON;<compat> 8C55;;;;N;;;;;\n2F98;KANGXI RADICAL BADGER;So;0;ON;<compat> 8C78;;;;N;;;;;\n2F99;KANGXI RADICAL SHELL;So;0;ON;<compat> 8C9D;;;;N;;;;;\n2F9A;KANGXI RADICAL RED;So;0;ON;<compat> 8D64;;;;N;;;;;\n2F9B;KANGXI RADICAL RUN;So;0;ON;<compat> 8D70;;;;N;;;;;\n2F9C;KANGXI RADICAL FOOT;So;0;ON;<compat> 8DB3;;;;N;;;;;\n2F9D;KANGXI RADICAL BODY;So;0;ON;<compat> 8EAB;;;;N;;;;;\n2F9E;KANGXI RADICAL CART;So;0;ON;<compat> 8ECA;;;;N;;;;;\n2F9F;KANGXI RADICAL BITTER;So;0;ON;<compat> 8F9B;;;;N;;;;;\n2FA0;KANGXI RADICAL MORNING;So;0;ON;<compat> 8FB0;;;;N;;;;;\n2FA1;KANGXI RADICAL WALK;So;0;ON;<compat> 8FB5;;;;N;;;;;\n2FA2;KANGXI RADICAL CITY;So;0;ON;<compat> 9091;;;;N;;;;;\n2FA3;KANGXI RADICAL WINE;So;0;ON;<compat> 9149;;;;N;;;;;\n2FA4;KANGXI RADICAL DISTINGUISH;So;0;ON;<compat> 91C6;;;;N;;;;;\n2FA5;KANGXI RADICAL VILLAGE;So;0;ON;<compat> 91CC;;;;N;;;;;\n2FA6;KANGXI RADICAL GOLD;So;0;ON;<compat> 91D1;;;;N;;;;;\n2FA7;KANGXI RADICAL LONG;So;0;ON;<compat> 9577;;;;N;;;;;\n2FA8;KANGXI RADICAL GATE;So;0;ON;<compat> 9580;;;;N;;;;;\n2FA9;KANGXI RADICAL MOUND;So;0;ON;<compat> 961C;;;;N;;;;;\n2FAA;KANGXI RADICAL SLAVE;So;0;ON;<compat> 96B6;;;;N;;;;;\n2FAB;KANGXI RADICAL SHORT TAILED BIRD;So;0;ON;<compat> 96B9;;;;N;;;;;\n2FAC;KANGXI RADICAL RAIN;So;0;ON;<compat> 96E8;;;;N;;;;;\n2FAD;KANGXI RADICAL BLUE;So;0;ON;<compat> 9751;;;;N;;;;;\n2FAE;KANGXI RADICAL WRONG;So;0;ON;<compat> 975E;;;;N;;;;;\n2FAF;KANGXI RADICAL FACE;So;0;ON;<compat> 9762;;;;N;;;;;\n2FB0;KANGXI RADICAL LEATHER;So;0;ON;<compat> 9769;;;;N;;;;;\n2FB1;KANGXI RADICAL TANNED LEATHER;So;0;ON;<compat> 97CB;;;;N;;;;;\n2FB2;KANGXI RADICAL LEEK;So;0;ON;<compat> 97ED;;;;N;;;;;\n2FB3;KANGXI RADICAL SOUND;So;0;ON;<compat> 97F3;;;;N;;;;;\n2FB4;KANGXI RADICAL LEAF;So;0;ON;<compat> 9801;;;;N;;;;;\n2FB5;KANGXI RADICAL WIND;So;0;ON;<compat> 98A8;;;;N;;;;;\n2FB6;KANGXI RADICAL FLY;So;0;ON;<compat> 98DB;;;;N;;;;;\n2FB7;KANGXI RADICAL EAT;So;0;ON;<compat> 98DF;;;;N;;;;;\n2FB8;KANGXI RADICAL HEAD;So;0;ON;<compat> 9996;;;;N;;;;;\n2FB9;KANGXI RADICAL FRAGRANT;So;0;ON;<compat> 9999;;;;N;;;;;\n2FBA;KANGXI RADICAL HORSE;So;0;ON;<compat> 99AC;;;;N;;;;;\n2FBB;KANGXI RADICAL BONE;So;0;ON;<compat> 9AA8;;;;N;;;;;\n2FBC;KANGXI RADICAL TALL;So;0;ON;<compat> 9AD8;;;;N;;;;;\n2FBD;KANGXI RADICAL HAIR;So;0;ON;<compat> 9ADF;;;;N;;;;;\n2FBE;KANGXI RADICAL FIGHT;So;0;ON;<compat> 9B25;;;;N;;;;;\n2FBF;KANGXI RADICAL SACRIFICIAL WINE;So;0;ON;<compat> 9B2F;;;;N;;;;;\n2FC0;KANGXI RADICAL CAULDRON;So;0;ON;<compat> 9B32;;;;N;;;;;\n2FC1;KANGXI RADICAL GHOST;So;0;ON;<compat> 9B3C;;;;N;;;;;\n2FC2;KANGXI RADICAL FISH;So;0;ON;<compat> 9B5A;;;;N;;;;;\n2FC3;KANGXI RADICAL BIRD;So;0;ON;<compat> 9CE5;;;;N;;;;;\n2FC4;KANGXI RADICAL SALT;So;0;ON;<compat> 9E75;;;;N;;;;;\n2FC5;KANGXI RADICAL DEER;So;0;ON;<compat> 9E7F;;;;N;;;;;\n2FC6;KANGXI RADICAL WHEAT;So;0;ON;<compat> 9EA5;;;;N;;;;;\n2FC7;KANGXI RADICAL HEMP;So;0;ON;<compat> 9EBB;;;;N;;;;;\n2FC8;KANGXI RADICAL YELLOW;So;0;ON;<compat> 9EC3;;;;N;;;;;\n2FC9;KANGXI RADICAL MILLET;So;0;ON;<compat> 9ECD;;;;N;;;;;\n2FCA;KANGXI RADICAL BLACK;So;0;ON;<compat> 9ED1;;;;N;;;;;\n2FCB;KANGXI RADICAL EMBROIDERY;So;0;ON;<compat> 9EF9;;;;N;;;;;\n2FCC;KANGXI RADICAL FROG;So;0;ON;<compat> 9EFD;;;;N;;;;;\n2FCD;KANGXI RADICAL TRIPOD;So;0;ON;<compat> 9F0E;;;;N;;;;;\n2FCE;KANGXI RADICAL DRUM;So;0;ON;<compat> 9F13;;;;N;;;;;\n2FCF;KANGXI RADICAL RAT;So;0;ON;<compat> 9F20;;;;N;;;;;\n2FD0;KANGXI RADICAL NOSE;So;0;ON;<compat> 9F3B;;;;N;;;;;\n2FD1;KANGXI RADICAL EVEN;So;0;ON;<compat> 9F4A;;;;N;;;;;\n2FD2;KANGXI RADICAL TOOTH;So;0;ON;<compat> 9F52;;;;N;;;;;\n2FD3;KANGXI RADICAL DRAGON;So;0;ON;<compat> 9F8D;;;;N;;;;;\n2FD4;KANGXI RADICAL TURTLE;So;0;ON;<compat> 9F9C;;;;N;;;;;\n2FD5;KANGXI RADICAL FLUTE;So;0;ON;<compat> 9FA0;;;;N;;;;;\n2FF0;IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RIGHT;So;0;ON;;;;;N;;;;;\n2FF1;IDEOGRAPHIC DESCRIPTION CHARACTER ABOVE TO BELOW;So;0;ON;;;;;N;;;;;\n2FF2;IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO MIDDLE AND RIGHT;So;0;ON;;;;;N;;;;;\n2FF3;IDEOGRAPHIC DESCRIPTION CHARACTER ABOVE TO MIDDLE AND BELOW;So;0;ON;;;;;N;;;;;\n2FF4;IDEOGRAPHIC DESCRIPTION CHARACTER FULL SURROUND;So;0;ON;;;;;N;;;;;\n2FF5;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM ABOVE;So;0;ON;;;;;N;;;;;\n2FF6;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM BELOW;So;0;ON;;;;;N;;;;;\n2FF7;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM LEFT;So;0;ON;;;;;N;;;;;\n2FF8;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM UPPER LEFT;So;0;ON;;;;;N;;;;;\n2FF9;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM UPPER RIGHT;So;0;ON;;;;;N;;;;;\n2FFA;IDEOGRAPHIC DESCRIPTION CHARACTER SURROUND FROM LOWER LEFT;So;0;ON;;;;;N;;;;;\n2FFB;IDEOGRAPHIC DESCRIPTION CHARACTER OVERLAID;So;0;ON;;;;;N;;;;;\n3000;IDEOGRAPHIC SPACE;Zs;0;WS;<wide> 0020;;;;N;;;;;\n3001;IDEOGRAPHIC COMMA;Po;0;ON;;;;;N;;;;;\n3002;IDEOGRAPHIC FULL STOP;Po;0;ON;;;;;N;IDEOGRAPHIC PERIOD;;;;\n3003;DITTO MARK;Po;0;ON;;;;;N;;;;;\n3004;JAPANESE INDUSTRIAL STANDARD SYMBOL;So;0;ON;;;;;N;;;;;\n3005;IDEOGRAPHIC ITERATION MARK;Lm;0;L;;;;;N;;;;;\n3006;IDEOGRAPHIC CLOSING MARK;Lo;0;L;;;;;N;;;;;\n3007;IDEOGRAPHIC NUMBER ZERO;Nl;0;L;;;;0;N;;;;;\n3008;LEFT ANGLE BRACKET;Ps;0;ON;;;;;Y;OPENING ANGLE BRACKET;;;;\n3009;RIGHT ANGLE BRACKET;Pe;0;ON;;;;;Y;CLOSING ANGLE BRACKET;;;;\n300A;LEFT DOUBLE ANGLE BRACKET;Ps;0;ON;;;;;Y;OPENING DOUBLE ANGLE BRACKET;;;;\n300B;RIGHT DOUBLE ANGLE BRACKET;Pe;0;ON;;;;;Y;CLOSING DOUBLE ANGLE BRACKET;;;;\n300C;LEFT CORNER BRACKET;Ps;0;ON;;;;;Y;OPENING CORNER BRACKET;;;;\n300D;RIGHT CORNER BRACKET;Pe;0;ON;;;;;Y;CLOSING CORNER BRACKET;;;;\n300E;LEFT WHITE CORNER BRACKET;Ps;0;ON;;;;;Y;OPENING WHITE CORNER BRACKET;;;;\n300F;RIGHT WHITE CORNER BRACKET;Pe;0;ON;;;;;Y;CLOSING WHITE CORNER BRACKET;;;;\n3010;LEFT BLACK LENTICULAR BRACKET;Ps;0;ON;;;;;Y;OPENING BLACK LENTICULAR BRACKET;;;;\n3011;RIGHT BLACK LENTICULAR BRACKET;Pe;0;ON;;;;;Y;CLOSING BLACK LENTICULAR BRACKET;;;;\n3012;POSTAL MARK;So;0;ON;;;;;N;;;;;\n3013;GETA MARK;So;0;ON;;;;;N;;;;;\n3014;LEFT TORTOISE SHELL BRACKET;Ps;0;ON;;;;;Y;OPENING TORTOISE SHELL BRACKET;;;;\n3015;RIGHT TORTOISE SHELL BRACKET;Pe;0;ON;;;;;Y;CLOSING TORTOISE SHELL BRACKET;;;;\n3016;LEFT WHITE LENTICULAR BRACKET;Ps;0;ON;;;;;Y;OPENING WHITE LENTICULAR BRACKET;;;;\n3017;RIGHT WHITE LENTICULAR BRACKET;Pe;0;ON;;;;;Y;CLOSING WHITE LENTICULAR BRACKET;;;;\n3018;LEFT WHITE TORTOISE SHELL BRACKET;Ps;0;ON;;;;;Y;OPENING WHITE TORTOISE SHELL BRACKET;;;;\n3019;RIGHT WHITE TORTOISE SHELL BRACKET;Pe;0;ON;;;;;Y;CLOSING WHITE TORTOISE SHELL BRACKET;;;;\n301A;LEFT WHITE SQUARE BRACKET;Ps;0;ON;;;;;Y;OPENING WHITE SQUARE BRACKET;;;;\n301B;RIGHT WHITE SQUARE BRACKET;Pe;0;ON;;;;;Y;CLOSING WHITE SQUARE BRACKET;;;;\n301C;WAVE DASH;Pd;0;ON;;;;;N;;;;;\n301D;REVERSED DOUBLE PRIME QUOTATION MARK;Ps;0;ON;;;;;N;;;;;\n301E;DOUBLE PRIME QUOTATION MARK;Pe;0;ON;;;;;N;;;;;\n301F;LOW DOUBLE PRIME QUOTATION MARK;Pe;0;ON;;;;;N;;;;;\n3020;POSTAL MARK FACE;So;0;ON;;;;;N;;;;;\n3021;HANGZHOU NUMERAL ONE;Nl;0;L;;;;1;N;;;;;\n3022;HANGZHOU NUMERAL TWO;Nl;0;L;;;;2;N;;;;;\n3023;HANGZHOU NUMERAL THREE;Nl;0;L;;;;3;N;;;;;\n3024;HANGZHOU NUMERAL FOUR;Nl;0;L;;;;4;N;;;;;\n3025;HANGZHOU NUMERAL FIVE;Nl;0;L;;;;5;N;;;;;\n3026;HANGZHOU NUMERAL SIX;Nl;0;L;;;;6;N;;;;;\n3027;HANGZHOU NUMERAL SEVEN;Nl;0;L;;;;7;N;;;;;\n3028;HANGZHOU NUMERAL EIGHT;Nl;0;L;;;;8;N;;;;;\n3029;HANGZHOU NUMERAL NINE;Nl;0;L;;;;9;N;;;;;\n302A;IDEOGRAPHIC LEVEL TONE MARK;Mn;218;NSM;;;;;N;;;;;\n302B;IDEOGRAPHIC RISING TONE MARK;Mn;228;NSM;;;;;N;;;;;\n302C;IDEOGRAPHIC DEPARTING TONE MARK;Mn;232;NSM;;;;;N;;;;;\n302D;IDEOGRAPHIC ENTERING TONE MARK;Mn;222;NSM;;;;;N;;;;;\n302E;HANGUL SINGLE DOT TONE MARK;Mc;224;L;;;;;N;;;;;\n302F;HANGUL DOUBLE DOT TONE MARK;Mc;224;L;;;;;N;;;;;\n3030;WAVY DASH;Pd;0;ON;;;;;N;;;;;\n3031;VERTICAL KANA REPEAT MARK;Lm;0;L;;;;;N;;;;;\n3032;VERTICAL KANA REPEAT WITH VOICED SOUND MARK;Lm;0;L;;;;;N;;;;;\n3033;VERTICAL KANA REPEAT MARK UPPER HALF;Lm;0;L;;;;;N;;;;;\n3034;VERTICAL KANA REPEAT WITH VOICED SOUND MARK UPPER HALF;Lm;0;L;;;;;N;;;;;\n3035;VERTICAL KANA REPEAT MARK LOWER HALF;Lm;0;L;;;;;N;;;;;\n3036;CIRCLED POSTAL MARK;So;0;ON;<compat> 3012;;;;N;;;;;\n3037;IDEOGRAPHIC TELEGRAPH LINE FEED SEPARATOR SYMBOL;So;0;ON;;;;;N;;;;;\n3038;HANGZHOU NUMERAL TEN;Nl;0;L;<compat> 5341;;;10;N;;;;;\n3039;HANGZHOU NUMERAL TWENTY;Nl;0;L;<compat> 5344;;;20;N;;;;;\n303A;HANGZHOU NUMERAL THIRTY;Nl;0;L;<compat> 5345;;;30;N;;;;;\n303B;VERTICAL IDEOGRAPHIC ITERATION MARK;Lm;0;L;;;;;N;;;;;\n303C;MASU MARK;Lo;0;L;;;;;N;;;;;\n303D;PART ALTERNATION MARK;Po;0;ON;;;;;N;;;;;\n303E;IDEOGRAPHIC VARIATION INDICATOR;So;0;ON;;;;;N;;;;;\n303F;IDEOGRAPHIC HALF FILL SPACE;So;0;ON;;;;;N;;;;;\n3041;HIRAGANA LETTER SMALL A;Lo;0;L;;;;;N;;;;;\n3042;HIRAGANA LETTER A;Lo;0;L;;;;;N;;;;;\n3043;HIRAGANA LETTER SMALL I;Lo;0;L;;;;;N;;;;;\n3044;HIRAGANA LETTER I;Lo;0;L;;;;;N;;;;;\n3045;HIRAGANA LETTER SMALL U;Lo;0;L;;;;;N;;;;;\n3046;HIRAGANA LETTER U;Lo;0;L;;;;;N;;;;;\n3047;HIRAGANA LETTER SMALL E;Lo;0;L;;;;;N;;;;;\n3048;HIRAGANA LETTER E;Lo;0;L;;;;;N;;;;;\n3049;HIRAGANA LETTER SMALL O;Lo;0;L;;;;;N;;;;;\n304A;HIRAGANA LETTER O;Lo;0;L;;;;;N;;;;;\n304B;HIRAGANA LETTER KA;Lo;0;L;;;;;N;;;;;\n304C;HIRAGANA LETTER GA;Lo;0;L;304B 3099;;;;N;;;;;\n304D;HIRAGANA LETTER KI;Lo;0;L;;;;;N;;;;;\n304E;HIRAGANA LETTER GI;Lo;0;L;304D 3099;;;;N;;;;;\n304F;HIRAGANA LETTER KU;Lo;0;L;;;;;N;;;;;\n3050;HIRAGANA LETTER GU;Lo;0;L;304F 3099;;;;N;;;;;\n3051;HIRAGANA LETTER KE;Lo;0;L;;;;;N;;;;;\n3052;HIRAGANA LETTER GE;Lo;0;L;3051 3099;;;;N;;;;;\n3053;HIRAGANA LETTER KO;Lo;0;L;;;;;N;;;;;\n3054;HIRAGANA LETTER GO;Lo;0;L;3053 3099;;;;N;;;;;\n3055;HIRAGANA LETTER SA;Lo;0;L;;;;;N;;;;;\n3056;HIRAGANA LETTER ZA;Lo;0;L;3055 3099;;;;N;;;;;\n3057;HIRAGANA LETTER SI;Lo;0;L;;;;;N;;;;;\n3058;HIRAGANA LETTER ZI;Lo;0;L;3057 3099;;;;N;;;;;\n3059;HIRAGANA LETTER SU;Lo;0;L;;;;;N;;;;;\n305A;HIRAGANA LETTER ZU;Lo;0;L;3059 3099;;;;N;;;;;\n305B;HIRAGANA LETTER SE;Lo;0;L;;;;;N;;;;;\n305C;HIRAGANA LETTER ZE;Lo;0;L;305B 3099;;;;N;;;;;\n305D;HIRAGANA LETTER SO;Lo;0;L;;;;;N;;;;;\n305E;HIRAGANA LETTER ZO;Lo;0;L;305D 3099;;;;N;;;;;\n305F;HIRAGANA LETTER TA;Lo;0;L;;;;;N;;;;;\n3060;HIRAGANA LETTER DA;Lo;0;L;305F 3099;;;;N;;;;;\n3061;HIRAGANA LETTER TI;Lo;0;L;;;;;N;;;;;\n3062;HIRAGANA LETTER DI;Lo;0;L;3061 3099;;;;N;;;;;\n3063;HIRAGANA LETTER SMALL TU;Lo;0;L;;;;;N;;;;;\n3064;HIRAGANA LETTER TU;Lo;0;L;;;;;N;;;;;\n3065;HIRAGANA LETTER DU;Lo;0;L;3064 3099;;;;N;;;;;\n3066;HIRAGANA LETTER TE;Lo;0;L;;;;;N;;;;;\n3067;HIRAGANA LETTER DE;Lo;0;L;3066 3099;;;;N;;;;;\n3068;HIRAGANA LETTER TO;Lo;0;L;;;;;N;;;;;\n3069;HIRAGANA LETTER DO;Lo;0;L;3068 3099;;;;N;;;;;\n306A;HIRAGANA LETTER NA;Lo;0;L;;;;;N;;;;;\n306B;HIRAGANA LETTER NI;Lo;0;L;;;;;N;;;;;\n306C;HIRAGANA LETTER NU;Lo;0;L;;;;;N;;;;;\n306D;HIRAGANA LETTER NE;Lo;0;L;;;;;N;;;;;\n306E;HIRAGANA LETTER NO;Lo;0;L;;;;;N;;;;;\n306F;HIRAGANA LETTER HA;Lo;0;L;;;;;N;;;;;\n3070;HIRAGANA LETTER BA;Lo;0;L;306F 3099;;;;N;;;;;\n3071;HIRAGANA LETTER PA;Lo;0;L;306F 309A;;;;N;;;;;\n3072;HIRAGANA LETTER HI;Lo;0;L;;;;;N;;;;;\n3073;HIRAGANA LETTER BI;Lo;0;L;3072 3099;;;;N;;;;;\n3074;HIRAGANA LETTER PI;Lo;0;L;3072 309A;;;;N;;;;;\n3075;HIRAGANA LETTER HU;Lo;0;L;;;;;N;;;;;\n3076;HIRAGANA LETTER BU;Lo;0;L;3075 3099;;;;N;;;;;\n3077;HIRAGANA LETTER PU;Lo;0;L;3075 309A;;;;N;;;;;\n3078;HIRAGANA LETTER HE;Lo;0;L;;;;;N;;;;;\n3079;HIRAGANA LETTER BE;Lo;0;L;3078 3099;;;;N;;;;;\n307A;HIRAGANA LETTER PE;Lo;0;L;3078 309A;;;;N;;;;;\n307B;HIRAGANA LETTER HO;Lo;0;L;;;;;N;;;;;\n307C;HIRAGANA LETTER BO;Lo;0;L;307B 3099;;;;N;;;;;\n307D;HIRAGANA LETTER PO;Lo;0;L;307B 309A;;;;N;;;;;\n307E;HIRAGANA LETTER MA;Lo;0;L;;;;;N;;;;;\n307F;HIRAGANA LETTER MI;Lo;0;L;;;;;N;;;;;\n3080;HIRAGANA LETTER MU;Lo;0;L;;;;;N;;;;;\n3081;HIRAGANA LETTER ME;Lo;0;L;;;;;N;;;;;\n3082;HIRAGANA LETTER MO;Lo;0;L;;;;;N;;;;;\n3083;HIRAGANA LETTER SMALL YA;Lo;0;L;;;;;N;;;;;\n3084;HIRAGANA LETTER YA;Lo;0;L;;;;;N;;;;;\n3085;HIRAGANA LETTER SMALL YU;Lo;0;L;;;;;N;;;;;\n3086;HIRAGANA LETTER YU;Lo;0;L;;;;;N;;;;;\n3087;HIRAGANA LETTER SMALL YO;Lo;0;L;;;;;N;;;;;\n3088;HIRAGANA LETTER YO;Lo;0;L;;;;;N;;;;;\n3089;HIRAGANA LETTER RA;Lo;0;L;;;;;N;;;;;\n308A;HIRAGANA LETTER RI;Lo;0;L;;;;;N;;;;;\n308B;HIRAGANA LETTER RU;Lo;0;L;;;;;N;;;;;\n308C;HIRAGANA LETTER RE;Lo;0;L;;;;;N;;;;;\n308D;HIRAGANA LETTER RO;Lo;0;L;;;;;N;;;;;\n308E;HIRAGANA LETTER SMALL WA;Lo;0;L;;;;;N;;;;;\n308F;HIRAGANA LETTER WA;Lo;0;L;;;;;N;;;;;\n3090;HIRAGANA LETTER WI;Lo;0;L;;;;;N;;;;;\n3091;HIRAGANA LETTER WE;Lo;0;L;;;;;N;;;;;\n3092;HIRAGANA LETTER WO;Lo;0;L;;;;;N;;;;;\n3093;HIRAGANA LETTER N;Lo;0;L;;;;;N;;;;;\n3094;HIRAGANA LETTER VU;Lo;0;L;3046 3099;;;;N;;;;;\n3095;HIRAGANA LETTER SMALL KA;Lo;0;L;;;;;N;;;;;\n3096;HIRAGANA LETTER SMALL KE;Lo;0;L;;;;;N;;;;;\n3099;COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK;Mn;8;NSM;;;;;N;NON-SPACING KATAKANA-HIRAGANA VOICED SOUND MARK;;;;\n309A;COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK;Mn;8;NSM;;;;;N;NON-SPACING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK;;;;\n309B;KATAKANA-HIRAGANA VOICED SOUND MARK;Sk;0;ON;<compat> 0020 3099;;;;N;;;;;\n309C;KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK;Sk;0;ON;<compat> 0020 309A;;;;N;;;;;\n309D;HIRAGANA ITERATION MARK;Lm;0;L;;;;;N;;;;;\n309E;HIRAGANA VOICED ITERATION MARK;Lm;0;L;309D 3099;;;;N;;;;;\n309F;HIRAGANA DIGRAPH YORI;Lo;0;L;<vertical> 3088 308A;;;;N;;;;;\n30A0;KATAKANA-HIRAGANA DOUBLE HYPHEN;Pd;0;ON;;;;;N;;;;;\n30A1;KATAKANA LETTER SMALL A;Lo;0;L;;;;;N;;;;;\n30A2;KATAKANA LETTER A;Lo;0;L;;;;;N;;;;;\n30A3;KATAKANA LETTER SMALL I;Lo;0;L;;;;;N;;;;;\n30A4;KATAKANA LETTER I;Lo;0;L;;;;;N;;;;;\n30A5;KATAKANA LETTER SMALL U;Lo;0;L;;;;;N;;;;;\n30A6;KATAKANA LETTER U;Lo;0;L;;;;;N;;;;;\n30A7;KATAKANA LETTER SMALL E;Lo;0;L;;;;;N;;;;;\n30A8;KATAKANA LETTER E;Lo;0;L;;;;;N;;;;;\n30A9;KATAKANA LETTER SMALL O;Lo;0;L;;;;;N;;;;;\n30AA;KATAKANA LETTER O;Lo;0;L;;;;;N;;;;;\n30AB;KATAKANA LETTER KA;Lo;0;L;;;;;N;;;;;\n30AC;KATAKANA LETTER GA;Lo;0;L;30AB 3099;;;;N;;;;;\n30AD;KATAKANA LETTER KI;Lo;0;L;;;;;N;;;;;\n30AE;KATAKANA LETTER GI;Lo;0;L;30AD 3099;;;;N;;;;;\n30AF;KATAKANA LETTER KU;Lo;0;L;;;;;N;;;;;\n30B0;KATAKANA LETTER GU;Lo;0;L;30AF 3099;;;;N;;;;;\n30B1;KATAKANA LETTER KE;Lo;0;L;;;;;N;;;;;\n30B2;KATAKANA LETTER GE;Lo;0;L;30B1 3099;;;;N;;;;;\n30B3;KATAKANA LETTER KO;Lo;0;L;;;;;N;;;;;\n30B4;KATAKANA LETTER GO;Lo;0;L;30B3 3099;;;;N;;;;;\n30B5;KATAKANA LETTER SA;Lo;0;L;;;;;N;;;;;\n30B6;KATAKANA LETTER ZA;Lo;0;L;30B5 3099;;;;N;;;;;\n30B7;KATAKANA LETTER SI;Lo;0;L;;;;;N;;;;;\n30B8;KATAKANA LETTER ZI;Lo;0;L;30B7 3099;;;;N;;;;;\n30B9;KATAKANA LETTER SU;Lo;0;L;;;;;N;;;;;\n30BA;KATAKANA LETTER ZU;Lo;0;L;30B9 3099;;;;N;;;;;\n30BB;KATAKANA LETTER SE;Lo;0;L;;;;;N;;;;;\n30BC;KATAKANA LETTER ZE;Lo;0;L;30BB 3099;;;;N;;;;;\n30BD;KATAKANA LETTER SO;Lo;0;L;;;;;N;;;;;\n30BE;KATAKANA LETTER ZO;Lo;0;L;30BD 3099;;;;N;;;;;\n30BF;KATAKANA LETTER TA;Lo;0;L;;;;;N;;;;;\n30C0;KATAKANA LETTER DA;Lo;0;L;30BF 3099;;;;N;;;;;\n30C1;KATAKANA LETTER TI;Lo;0;L;;;;;N;;;;;\n30C2;KATAKANA LETTER DI;Lo;0;L;30C1 3099;;;;N;;;;;\n30C3;KATAKANA LETTER SMALL TU;Lo;0;L;;;;;N;;;;;\n30C4;KATAKANA LETTER TU;Lo;0;L;;;;;N;;;;;\n30C5;KATAKANA LETTER DU;Lo;0;L;30C4 3099;;;;N;;;;;\n30C6;KATAKANA LETTER TE;Lo;0;L;;;;;N;;;;;\n30C7;KATAKANA LETTER DE;Lo;0;L;30C6 3099;;;;N;;;;;\n30C8;KATAKANA LETTER TO;Lo;0;L;;;;;N;;;;;\n30C9;KATAKANA LETTER DO;Lo;0;L;30C8 3099;;;;N;;;;;\n30CA;KATAKANA LETTER NA;Lo;0;L;;;;;N;;;;;\n30CB;KATAKANA LETTER NI;Lo;0;L;;;;;N;;;;;\n30CC;KATAKANA LETTER NU;Lo;0;L;;;;;N;;;;;\n30CD;KATAKANA LETTER NE;Lo;0;L;;;;;N;;;;;\n30CE;KATAKANA LETTER NO;Lo;0;L;;;;;N;;;;;\n30CF;KATAKANA LETTER HA;Lo;0;L;;;;;N;;;;;\n30D0;KATAKANA LETTER BA;Lo;0;L;30CF 3099;;;;N;;;;;\n30D1;KATAKANA LETTER PA;Lo;0;L;30CF 309A;;;;N;;;;;\n30D2;KATAKANA LETTER HI;Lo;0;L;;;;;N;;;;;\n30D3;KATAKANA LETTER BI;Lo;0;L;30D2 3099;;;;N;;;;;\n30D4;KATAKANA LETTER PI;Lo;0;L;30D2 309A;;;;N;;;;;\n30D5;KATAKANA LETTER HU;Lo;0;L;;;;;N;;;;;\n30D6;KATAKANA LETTER BU;Lo;0;L;30D5 3099;;;;N;;;;;\n30D7;KATAKANA LETTER PU;Lo;0;L;30D5 309A;;;;N;;;;;\n30D8;KATAKANA LETTER HE;Lo;0;L;;;;;N;;;;;\n30D9;KATAKANA LETTER BE;Lo;0;L;30D8 3099;;;;N;;;;;\n30DA;KATAKANA LETTER PE;Lo;0;L;30D8 309A;;;;N;;;;;\n30DB;KATAKANA LETTER HO;Lo;0;L;;;;;N;;;;;\n30DC;KATAKANA LETTER BO;Lo;0;L;30DB 3099;;;;N;;;;;\n30DD;KATAKANA LETTER PO;Lo;0;L;30DB 309A;;;;N;;;;;\n30DE;KATAKANA LETTER MA;Lo;0;L;;;;;N;;;;;\n30DF;KATAKANA LETTER MI;Lo;0;L;;;;;N;;;;;\n30E0;KATAKANA LETTER MU;Lo;0;L;;;;;N;;;;;\n30E1;KATAKANA LETTER ME;Lo;0;L;;;;;N;;;;;\n30E2;KATAKANA LETTER MO;Lo;0;L;;;;;N;;;;;\n30E3;KATAKANA LETTER SMALL YA;Lo;0;L;;;;;N;;;;;\n30E4;KATAKANA LETTER YA;Lo;0;L;;;;;N;;;;;\n30E5;KATAKANA LETTER SMALL YU;Lo;0;L;;;;;N;;;;;\n30E6;KATAKANA LETTER YU;Lo;0;L;;;;;N;;;;;\n30E7;KATAKANA LETTER SMALL YO;Lo;0;L;;;;;N;;;;;\n30E8;KATAKANA LETTER YO;Lo;0;L;;;;;N;;;;;\n30E9;KATAKANA LETTER RA;Lo;0;L;;;;;N;;;;;\n30EA;KATAKANA LETTER RI;Lo;0;L;;;;;N;;;;;\n30EB;KATAKANA LETTER RU;Lo;0;L;;;;;N;;;;;\n30EC;KATAKANA LETTER RE;Lo;0;L;;;;;N;;;;;\n30ED;KATAKANA LETTER RO;Lo;0;L;;;;;N;;;;;\n30EE;KATAKANA LETTER SMALL WA;Lo;0;L;;;;;N;;;;;\n30EF;KATAKANA LETTER WA;Lo;0;L;;;;;N;;;;;\n30F0;KATAKANA LETTER WI;Lo;0;L;;;;;N;;;;;\n30F1;KATAKANA LETTER WE;Lo;0;L;;;;;N;;;;;\n30F2;KATAKANA LETTER WO;Lo;0;L;;;;;N;;;;;\n30F3;KATAKANA LETTER N;Lo;0;L;;;;;N;;;;;\n30F4;KATAKANA LETTER VU;Lo;0;L;30A6 3099;;;;N;;;;;\n30F5;KATAKANA LETTER SMALL KA;Lo;0;L;;;;;N;;;;;\n30F6;KATAKANA LETTER SMALL KE;Lo;0;L;;;;;N;;;;;\n30F7;KATAKANA LETTER VA;Lo;0;L;30EF 3099;;;;N;;;;;\n30F8;KATAKANA LETTER VI;Lo;0;L;30F0 3099;;;;N;;;;;\n30F9;KATAKANA LETTER VE;Lo;0;L;30F1 3099;;;;N;;;;;\n30FA;KATAKANA LETTER VO;Lo;0;L;30F2 3099;;;;N;;;;;\n30FB;KATAKANA MIDDLE DOT;Po;0;ON;;;;;N;;;;;\n30FC;KATAKANA-HIRAGANA PROLONGED SOUND MARK;Lm;0;L;;;;;N;;;;;\n30FD;KATAKANA ITERATION MARK;Lm;0;L;;;;;N;;;;;\n30FE;KATAKANA VOICED ITERATION MARK;Lm;0;L;30FD 3099;;;;N;;;;;\n30FF;KATAKANA DIGRAPH KOTO;Lo;0;L;<vertical> 30B3 30C8;;;;N;;;;;\n3105;BOPOMOFO LETTER B;Lo;0;L;;;;;N;;;;;\n3106;BOPOMOFO LETTER P;Lo;0;L;;;;;N;;;;;\n3107;BOPOMOFO LETTER M;Lo;0;L;;;;;N;;;;;\n3108;BOPOMOFO LETTER F;Lo;0;L;;;;;N;;;;;\n3109;BOPOMOFO LETTER D;Lo;0;L;;;;;N;;;;;\n310A;BOPOMOFO LETTER T;Lo;0;L;;;;;N;;;;;\n310B;BOPOMOFO LETTER N;Lo;0;L;;;;;N;;;;;\n310C;BOPOMOFO LETTER L;Lo;0;L;;;;;N;;;;;\n310D;BOPOMOFO LETTER G;Lo;0;L;;;;;N;;;;;\n310E;BOPOMOFO LETTER K;Lo;0;L;;;;;N;;;;;\n310F;BOPOMOFO LETTER H;Lo;0;L;;;;;N;;;;;\n3110;BOPOMOFO LETTER J;Lo;0;L;;;;;N;;;;;\n3111;BOPOMOFO LETTER Q;Lo;0;L;;;;;N;;;;;\n3112;BOPOMOFO LETTER X;Lo;0;L;;;;;N;;;;;\n3113;BOPOMOFO LETTER ZH;Lo;0;L;;;;;N;;;;;\n3114;BOPOMOFO LETTER CH;Lo;0;L;;;;;N;;;;;\n3115;BOPOMOFO LETTER SH;Lo;0;L;;;;;N;;;;;\n3116;BOPOMOFO LETTER R;Lo;0;L;;;;;N;;;;;\n3117;BOPOMOFO LETTER Z;Lo;0;L;;;;;N;;;;;\n3118;BOPOMOFO LETTER C;Lo;0;L;;;;;N;;;;;\n3119;BOPOMOFO LETTER S;Lo;0;L;;;;;N;;;;;\n311A;BOPOMOFO LETTER A;Lo;0;L;;;;;N;;;;;\n311B;BOPOMOFO LETTER O;Lo;0;L;;;;;N;;;;;\n311C;BOPOMOFO LETTER E;Lo;0;L;;;;;N;;;;;\n311D;BOPOMOFO LETTER EH;Lo;0;L;;;;;N;;;;;\n311E;BOPOMOFO LETTER AI;Lo;0;L;;;;;N;;;;;\n311F;BOPOMOFO LETTER EI;Lo;0;L;;;;;N;;;;;\n3120;BOPOMOFO LETTER AU;Lo;0;L;;;;;N;;;;;\n3121;BOPOMOFO LETTER OU;Lo;0;L;;;;;N;;;;;\n3122;BOPOMOFO LETTER AN;Lo;0;L;;;;;N;;;;;\n3123;BOPOMOFO LETTER EN;Lo;0;L;;;;;N;;;;;\n3124;BOPOMOFO LETTER ANG;Lo;0;L;;;;;N;;;;;\n3125;BOPOMOFO LETTER ENG;Lo;0;L;;;;;N;;;;;\n3126;BOPOMOFO LETTER ER;Lo;0;L;;;;;N;;;;;\n3127;BOPOMOFO LETTER I;Lo;0;L;;;;;N;;;;;\n3128;BOPOMOFO LETTER U;Lo;0;L;;;;;N;;;;;\n3129;BOPOMOFO LETTER IU;Lo;0;L;;;;;N;;;;;\n312A;BOPOMOFO LETTER V;Lo;0;L;;;;;N;;;;;\n312B;BOPOMOFO LETTER NG;Lo;0;L;;;;;N;;;;;\n312C;BOPOMOFO LETTER GN;Lo;0;L;;;;;N;;;;;\n312D;BOPOMOFO LETTER IH;Lo;0;L;;;;;N;;;;;\n3131;HANGUL LETTER KIYEOK;Lo;0;L;<compat> 1100;;;;N;HANGUL LETTER GIYEOG;;;;\n3132;HANGUL LETTER SSANGKIYEOK;Lo;0;L;<compat> 1101;;;;N;HANGUL LETTER SSANG GIYEOG;;;;\n3133;HANGUL LETTER KIYEOK-SIOS;Lo;0;L;<compat> 11AA;;;;N;HANGUL LETTER GIYEOG SIOS;;;;\n3134;HANGUL LETTER NIEUN;Lo;0;L;<compat> 1102;;;;N;;;;;\n3135;HANGUL LETTER NIEUN-CIEUC;Lo;0;L;<compat> 11AC;;;;N;HANGUL LETTER NIEUN JIEUJ;;;;\n3136;HANGUL LETTER NIEUN-HIEUH;Lo;0;L;<compat> 11AD;;;;N;HANGUL LETTER NIEUN HIEUH;;;;\n3137;HANGUL LETTER TIKEUT;Lo;0;L;<compat> 1103;;;;N;HANGUL LETTER DIGEUD;;;;\n3138;HANGUL LETTER SSANGTIKEUT;Lo;0;L;<compat> 1104;;;;N;HANGUL LETTER SSANG DIGEUD;;;;\n3139;HANGUL LETTER RIEUL;Lo;0;L;<compat> 1105;;;;N;HANGUL LETTER LIEUL;;;;\n313A;HANGUL LETTER RIEUL-KIYEOK;Lo;0;L;<compat> 11B0;;;;N;HANGUL LETTER LIEUL GIYEOG;;;;\n313B;HANGUL LETTER RIEUL-MIEUM;Lo;0;L;<compat> 11B1;;;;N;HANGUL LETTER LIEUL MIEUM;;;;\n313C;HANGUL LETTER RIEUL-PIEUP;Lo;0;L;<compat> 11B2;;;;N;HANGUL LETTER LIEUL BIEUB;;;;\n313D;HANGUL LETTER RIEUL-SIOS;Lo;0;L;<compat> 11B3;;;;N;HANGUL LETTER LIEUL SIOS;;;;\n313E;HANGUL LETTER RIEUL-THIEUTH;Lo;0;L;<compat> 11B4;;;;N;HANGUL LETTER LIEUL TIEUT;;;;\n313F;HANGUL LETTER RIEUL-PHIEUPH;Lo;0;L;<compat> 11B5;;;;N;HANGUL LETTER LIEUL PIEUP;;;;\n3140;HANGUL LETTER RIEUL-HIEUH;Lo;0;L;<compat> 111A;;;;N;HANGUL LETTER LIEUL HIEUH;;;;\n3141;HANGUL LETTER MIEUM;Lo;0;L;<compat> 1106;;;;N;;;;;\n3142;HANGUL LETTER PIEUP;Lo;0;L;<compat> 1107;;;;N;HANGUL LETTER BIEUB;;;;\n3143;HANGUL LETTER SSANGPIEUP;Lo;0;L;<compat> 1108;;;;N;HANGUL LETTER SSANG BIEUB;;;;\n3144;HANGUL LETTER PIEUP-SIOS;Lo;0;L;<compat> 1121;;;;N;HANGUL LETTER BIEUB SIOS;;;;\n3145;HANGUL LETTER SIOS;Lo;0;L;<compat> 1109;;;;N;;;;;\n3146;HANGUL LETTER SSANGSIOS;Lo;0;L;<compat> 110A;;;;N;HANGUL LETTER SSANG SIOS;;;;\n3147;HANGUL LETTER IEUNG;Lo;0;L;<compat> 110B;;;;N;;;;;\n3148;HANGUL LETTER CIEUC;Lo;0;L;<compat> 110C;;;;N;HANGUL LETTER JIEUJ;;;;\n3149;HANGUL LETTER SSANGCIEUC;Lo;0;L;<compat> 110D;;;;N;HANGUL LETTER SSANG JIEUJ;;;;\n314A;HANGUL LETTER CHIEUCH;Lo;0;L;<compat> 110E;;;;N;HANGUL LETTER CIEUC;;;;\n314B;HANGUL LETTER KHIEUKH;Lo;0;L;<compat> 110F;;;;N;HANGUL LETTER KIYEOK;;;;\n314C;HANGUL LETTER THIEUTH;Lo;0;L;<compat> 1110;;;;N;HANGUL LETTER TIEUT;;;;\n314D;HANGUL LETTER PHIEUPH;Lo;0;L;<compat> 1111;;;;N;HANGUL LETTER PIEUP;;;;\n314E;HANGUL LETTER HIEUH;Lo;0;L;<compat> 1112;;;;N;;;;;\n314F;HANGUL LETTER A;Lo;0;L;<compat> 1161;;;;N;;;;;\n3150;HANGUL LETTER AE;Lo;0;L;<compat> 1162;;;;N;;;;;\n3151;HANGUL LETTER YA;Lo;0;L;<compat> 1163;;;;N;;;;;\n3152;HANGUL LETTER YAE;Lo;0;L;<compat> 1164;;;;N;;;;;\n3153;HANGUL LETTER EO;Lo;0;L;<compat> 1165;;;;N;;;;;\n3154;HANGUL LETTER E;Lo;0;L;<compat> 1166;;;;N;;;;;\n3155;HANGUL LETTER YEO;Lo;0;L;<compat> 1167;;;;N;;;;;\n3156;HANGUL LETTER YE;Lo;0;L;<compat> 1168;;;;N;;;;;\n3157;HANGUL LETTER O;Lo;0;L;<compat> 1169;;;;N;;;;;\n3158;HANGUL LETTER WA;Lo;0;L;<compat> 116A;;;;N;;;;;\n3159;HANGUL LETTER WAE;Lo;0;L;<compat> 116B;;;;N;;;;;\n315A;HANGUL LETTER OE;Lo;0;L;<compat> 116C;;;;N;;;;;\n315B;HANGUL LETTER YO;Lo;0;L;<compat> 116D;;;;N;;;;;\n315C;HANGUL LETTER U;Lo;0;L;<compat> 116E;;;;N;;;;;\n315D;HANGUL LETTER WEO;Lo;0;L;<compat> 116F;;;;N;;;;;\n315E;HANGUL LETTER WE;Lo;0;L;<compat> 1170;;;;N;;;;;\n315F;HANGUL LETTER WI;Lo;0;L;<compat> 1171;;;;N;;;;;\n3160;HANGUL LETTER YU;Lo;0;L;<compat> 1172;;;;N;;;;;\n3161;HANGUL LETTER EU;Lo;0;L;<compat> 1173;;;;N;;;;;\n3162;HANGUL LETTER YI;Lo;0;L;<compat> 1174;;;;N;;;;;\n3163;HANGUL LETTER I;Lo;0;L;<compat> 1175;;;;N;;;;;\n3164;HANGUL FILLER;Lo;0;L;<compat> 1160;;;;N;HANGUL CAE OM;;;;\n3165;HANGUL LETTER SSANGNIEUN;Lo;0;L;<compat> 1114;;;;N;HANGUL LETTER SSANG NIEUN;;;;\n3166;HANGUL LETTER NIEUN-TIKEUT;Lo;0;L;<compat> 1115;;;;N;HANGUL LETTER NIEUN DIGEUD;;;;\n3167;HANGUL LETTER NIEUN-SIOS;Lo;0;L;<compat> 11C7;;;;N;HANGUL LETTER NIEUN SIOS;;;;\n3168;HANGUL LETTER NIEUN-PANSIOS;Lo;0;L;<compat> 11C8;;;;N;HANGUL LETTER NIEUN BAN CHI EUM;;;;\n3169;HANGUL LETTER RIEUL-KIYEOK-SIOS;Lo;0;L;<compat> 11CC;;;;N;HANGUL LETTER LIEUL GIYEOG SIOS;;;;\n316A;HANGUL LETTER RIEUL-TIKEUT;Lo;0;L;<compat> 11CE;;;;N;HANGUL LETTER LIEUL DIGEUD;;;;\n316B;HANGUL LETTER RIEUL-PIEUP-SIOS;Lo;0;L;<compat> 11D3;;;;N;HANGUL LETTER LIEUL BIEUB SIOS;;;;\n316C;HANGUL LETTER RIEUL-PANSIOS;Lo;0;L;<compat> 11D7;;;;N;HANGUL LETTER LIEUL BAN CHI EUM;;;;\n316D;HANGUL LETTER RIEUL-YEORINHIEUH;Lo;0;L;<compat> 11D9;;;;N;HANGUL LETTER LIEUL YEOLIN HIEUH;;;;\n316E;HANGUL LETTER MIEUM-PIEUP;Lo;0;L;<compat> 111C;;;;N;HANGUL LETTER MIEUM BIEUB;;;;\n316F;HANGUL LETTER MIEUM-SIOS;Lo;0;L;<compat> 11DD;;;;N;HANGUL LETTER MIEUM SIOS;;;;\n3170;HANGUL LETTER MIEUM-PANSIOS;Lo;0;L;<compat> 11DF;;;;N;HANGUL LETTER BIEUB BAN CHI EUM;;;;\n3171;HANGUL LETTER KAPYEOUNMIEUM;Lo;0;L;<compat> 111D;;;;N;HANGUL LETTER MIEUM SUN GYEONG EUM;;;;\n3172;HANGUL LETTER PIEUP-KIYEOK;Lo;0;L;<compat> 111E;;;;N;HANGUL LETTER BIEUB GIYEOG;;;;\n3173;HANGUL LETTER PIEUP-TIKEUT;Lo;0;L;<compat> 1120;;;;N;HANGUL LETTER BIEUB DIGEUD;;;;\n3174;HANGUL LETTER PIEUP-SIOS-KIYEOK;Lo;0;L;<compat> 1122;;;;N;HANGUL LETTER BIEUB SIOS GIYEOG;;;;\n3175;HANGUL LETTER PIEUP-SIOS-TIKEUT;Lo;0;L;<compat> 1123;;;;N;HANGUL LETTER BIEUB SIOS DIGEUD;;;;\n3176;HANGUL LETTER PIEUP-CIEUC;Lo;0;L;<compat> 1127;;;;N;HANGUL LETTER BIEUB JIEUJ;;;;\n3177;HANGUL LETTER PIEUP-THIEUTH;Lo;0;L;<compat> 1129;;;;N;HANGUL LETTER BIEUB TIEUT;;;;\n3178;HANGUL LETTER KAPYEOUNPIEUP;Lo;0;L;<compat> 112B;;;;N;HANGUL LETTER BIEUB SUN GYEONG EUM;;;;\n3179;HANGUL LETTER KAPYEOUNSSANGPIEUP;Lo;0;L;<compat> 112C;;;;N;HANGUL LETTER SSANG BIEUB SUN GYEONG EUM;;;;\n317A;HANGUL LETTER SIOS-KIYEOK;Lo;0;L;<compat> 112D;;;;N;HANGUL LETTER SIOS GIYEOG;;;;\n317B;HANGUL LETTER SIOS-NIEUN;Lo;0;L;<compat> 112E;;;;N;HANGUL LETTER SIOS NIEUN;;;;\n317C;HANGUL LETTER SIOS-TIKEUT;Lo;0;L;<compat> 112F;;;;N;HANGUL LETTER SIOS DIGEUD;;;;\n317D;HANGUL LETTER SIOS-PIEUP;Lo;0;L;<compat> 1132;;;;N;HANGUL LETTER SIOS BIEUB;;;;\n317E;HANGUL LETTER SIOS-CIEUC;Lo;0;L;<compat> 1136;;;;N;HANGUL LETTER SIOS JIEUJ;;;;\n317F;HANGUL LETTER PANSIOS;Lo;0;L;<compat> 1140;;;;N;HANGUL LETTER BAN CHI EUM;;;;\n3180;HANGUL LETTER SSANGIEUNG;Lo;0;L;<compat> 1147;;;;N;HANGUL LETTER SSANG IEUNG;;;;\n3181;HANGUL LETTER YESIEUNG;Lo;0;L;<compat> 114C;;;;N;HANGUL LETTER NGIEUNG;;;;\n3182;HANGUL LETTER YESIEUNG-SIOS;Lo;0;L;<compat> 11F1;;;;N;HANGUL LETTER NGIEUNG SIOS;;;;\n3183;HANGUL LETTER YESIEUNG-PANSIOS;Lo;0;L;<compat> 11F2;;;;N;HANGUL LETTER NGIEUNG BAN CHI EUM;;;;\n3184;HANGUL LETTER KAPYEOUNPHIEUPH;Lo;0;L;<compat> 1157;;;;N;HANGUL LETTER PIEUP SUN GYEONG EUM;;;;\n3185;HANGUL LETTER SSANGHIEUH;Lo;0;L;<compat> 1158;;;;N;HANGUL LETTER SSANG HIEUH;;;;\n3186;HANGUL LETTER YEORINHIEUH;Lo;0;L;<compat> 1159;;;;N;HANGUL LETTER YEOLIN HIEUH;;;;\n3187;HANGUL LETTER YO-YA;Lo;0;L;<compat> 1184;;;;N;HANGUL LETTER YOYA;;;;\n3188;HANGUL LETTER YO-YAE;Lo;0;L;<compat> 1185;;;;N;HANGUL LETTER YOYAE;;;;\n3189;HANGUL LETTER YO-I;Lo;0;L;<compat> 1188;;;;N;HANGUL LETTER YOI;;;;\n318A;HANGUL LETTER YU-YEO;Lo;0;L;<compat> 1191;;;;N;HANGUL LETTER YUYEO;;;;\n318B;HANGUL LETTER YU-YE;Lo;0;L;<compat> 1192;;;;N;HANGUL LETTER YUYE;;;;\n318C;HANGUL LETTER YU-I;Lo;0;L;<compat> 1194;;;;N;HANGUL LETTER YUI;;;;\n318D;HANGUL LETTER ARAEA;Lo;0;L;<compat> 119E;;;;N;HANGUL LETTER ALAE A;;;;\n318E;HANGUL LETTER ARAEAE;Lo;0;L;<compat> 11A1;;;;N;HANGUL LETTER ALAE AE;;;;\n3190;IDEOGRAPHIC ANNOTATION LINKING MARK;So;0;L;;;;;N;KANBUN TATETEN;;;;\n3191;IDEOGRAPHIC ANNOTATION REVERSE MARK;So;0;L;;;;;N;KAERITEN RE;;;;\n3192;IDEOGRAPHIC ANNOTATION ONE MARK;No;0;L;<super> 4E00;;;1;N;KAERITEN ITI;;;;\n3193;IDEOGRAPHIC ANNOTATION TWO MARK;No;0;L;<super> 4E8C;;;2;N;KAERITEN NI;;;;\n3194;IDEOGRAPHIC ANNOTATION THREE MARK;No;0;L;<super> 4E09;;;3;N;KAERITEN SAN;;;;\n3195;IDEOGRAPHIC ANNOTATION FOUR MARK;No;0;L;<super> 56DB;;;4;N;KAERITEN SI;;;;\n3196;IDEOGRAPHIC ANNOTATION TOP MARK;So;0;L;<super> 4E0A;;;;N;KAERITEN ZYOU;;;;\n3197;IDEOGRAPHIC ANNOTATION MIDDLE MARK;So;0;L;<super> 4E2D;;;;N;KAERITEN TYUU;;;;\n3198;IDEOGRAPHIC ANNOTATION BOTTOM MARK;So;0;L;<super> 4E0B;;;;N;KAERITEN GE;;;;\n3199;IDEOGRAPHIC ANNOTATION FIRST MARK;So;0;L;<super> 7532;;;;N;KAERITEN KOU;;;;\n319A;IDEOGRAPHIC ANNOTATION SECOND MARK;So;0;L;<super> 4E59;;;;N;KAERITEN OTU;;;;\n319B;IDEOGRAPHIC ANNOTATION THIRD MARK;So;0;L;<super> 4E19;;;;N;KAERITEN HEI;;;;\n319C;IDEOGRAPHIC ANNOTATION FOURTH MARK;So;0;L;<super> 4E01;;;;N;KAERITEN TEI;;;;\n319D;IDEOGRAPHIC ANNOTATION HEAVEN MARK;So;0;L;<super> 5929;;;;N;KAERITEN TEN;;;;\n319E;IDEOGRAPHIC ANNOTATION EARTH MARK;So;0;L;<super> 5730;;;;N;KAERITEN TI;;;;\n319F;IDEOGRAPHIC ANNOTATION MAN MARK;So;0;L;<super> 4EBA;;;;N;KAERITEN ZIN;;;;\n31A0;BOPOMOFO LETTER BU;Lo;0;L;;;;;N;;;;;\n31A1;BOPOMOFO LETTER ZI;Lo;0;L;;;;;N;;;;;\n31A2;BOPOMOFO LETTER JI;Lo;0;L;;;;;N;;;;;\n31A3;BOPOMOFO LETTER GU;Lo;0;L;;;;;N;;;;;\n31A4;BOPOMOFO LETTER EE;Lo;0;L;;;;;N;;;;;\n31A5;BOPOMOFO LETTER ENN;Lo;0;L;;;;;N;;;;;\n31A6;BOPOMOFO LETTER OO;Lo;0;L;;;;;N;;;;;\n31A7;BOPOMOFO LETTER ONN;Lo;0;L;;;;;N;;;;;\n31A8;BOPOMOFO LETTER IR;Lo;0;L;;;;;N;;;;;\n31A9;BOPOMOFO LETTER ANN;Lo;0;L;;;;;N;;;;;\n31AA;BOPOMOFO LETTER INN;Lo;0;L;;;;;N;;;;;\n31AB;BOPOMOFO LETTER UNN;Lo;0;L;;;;;N;;;;;\n31AC;BOPOMOFO LETTER IM;Lo;0;L;;;;;N;;;;;\n31AD;BOPOMOFO LETTER NGG;Lo;0;L;;;;;N;;;;;\n31AE;BOPOMOFO LETTER AINN;Lo;0;L;;;;;N;;;;;\n31AF;BOPOMOFO LETTER AUNN;Lo;0;L;;;;;N;;;;;\n31B0;BOPOMOFO LETTER AM;Lo;0;L;;;;;N;;;;;\n31B1;BOPOMOFO LETTER OM;Lo;0;L;;;;;N;;;;;\n31B2;BOPOMOFO LETTER ONG;Lo;0;L;;;;;N;;;;;\n31B3;BOPOMOFO LETTER INNN;Lo;0;L;;;;;N;;;;;\n31B4;BOPOMOFO FINAL LETTER P;Lo;0;L;;;;;N;;;;;\n31B5;BOPOMOFO FINAL LETTER T;Lo;0;L;;;;;N;;;;;\n31B6;BOPOMOFO FINAL LETTER K;Lo;0;L;;;;;N;;;;;\n31B7;BOPOMOFO FINAL LETTER H;Lo;0;L;;;;;N;;;;;\n31B8;BOPOMOFO LETTER GH;Lo;0;L;;;;;N;;;;;\n31B9;BOPOMOFO LETTER LH;Lo;0;L;;;;;N;;;;;\n31BA;BOPOMOFO LETTER ZY;Lo;0;L;;;;;N;;;;;\n31C0;CJK STROKE T;So;0;ON;;;;;N;;;;;\n31C1;CJK STROKE WG;So;0;ON;;;;;N;;;;;\n31C2;CJK STROKE XG;So;0;ON;;;;;N;;;;;\n31C3;CJK STROKE BXG;So;0;ON;;;;;N;;;;;\n31C4;CJK STROKE SW;So;0;ON;;;;;N;;;;;\n31C5;CJK STROKE HZZ;So;0;ON;;;;;N;;;;;\n31C6;CJK STROKE HZG;So;0;ON;;;;;N;;;;;\n31C7;CJK STROKE HP;So;0;ON;;;;;N;;;;;\n31C8;CJK STROKE HZWG;So;0;ON;;;;;N;;;;;\n31C9;CJK STROKE SZWG;So;0;ON;;;;;N;;;;;\n31CA;CJK STROKE HZT;So;0;ON;;;;;N;;;;;\n31CB;CJK STROKE HZZP;So;0;ON;;;;;N;;;;;\n31CC;CJK STROKE HPWG;So;0;ON;;;;;N;;;;;\n31CD;CJK STROKE HZW;So;0;ON;;;;;N;;;;;\n31CE;CJK STROKE HZZZ;So;0;ON;;;;;N;;;;;\n31CF;CJK STROKE N;So;0;ON;;;;;N;;;;;\n31D0;CJK STROKE H;So;0;ON;;;;;N;;;;;\n31D1;CJK STROKE S;So;0;ON;;;;;N;;;;;\n31D2;CJK STROKE P;So;0;ON;;;;;N;;;;;\n31D3;CJK STROKE SP;So;0;ON;;;;;N;;;;;\n31D4;CJK STROKE D;So;0;ON;;;;;N;;;;;\n31D5;CJK STROKE HZ;So;0;ON;;;;;N;;;;;\n31D6;CJK STROKE HG;So;0;ON;;;;;N;;;;;\n31D7;CJK STROKE SZ;So;0;ON;;;;;N;;;;;\n31D8;CJK STROKE SWZ;So;0;ON;;;;;N;;;;;\n31D9;CJK STROKE ST;So;0;ON;;;;;N;;;;;\n31DA;CJK STROKE SG;So;0;ON;;;;;N;;;;;\n31DB;CJK STROKE PD;So;0;ON;;;;;N;;;;;\n31DC;CJK STROKE PZ;So;0;ON;;;;;N;;;;;\n31DD;CJK STROKE TN;So;0;ON;;;;;N;;;;;\n31DE;CJK STROKE SZZ;So;0;ON;;;;;N;;;;;\n31DF;CJK STROKE SWG;So;0;ON;;;;;N;;;;;\n31E0;CJK STROKE HXWG;So;0;ON;;;;;N;;;;;\n31E1;CJK STROKE HZZZG;So;0;ON;;;;;N;;;;;\n31E2;CJK STROKE PG;So;0;ON;;;;;N;;;;;\n31E3;CJK STROKE Q;So;0;ON;;;;;N;;;;;\n31F0;KATAKANA LETTER SMALL KU;Lo;0;L;;;;;N;;;;;\n31F1;KATAKANA LETTER SMALL SI;Lo;0;L;;;;;N;;;;;\n31F2;KATAKANA LETTER SMALL SU;Lo;0;L;;;;;N;;;;;\n31F3;KATAKANA LETTER SMALL TO;Lo;0;L;;;;;N;;;;;\n31F4;KATAKANA LETTER SMALL NU;Lo;0;L;;;;;N;;;;;\n31F5;KATAKANA LETTER SMALL HA;Lo;0;L;;;;;N;;;;;\n31F6;KATAKANA LETTER SMALL HI;Lo;0;L;;;;;N;;;;;\n31F7;KATAKANA LETTER SMALL HU;Lo;0;L;;;;;N;;;;;\n31F8;KATAKANA LETTER SMALL HE;Lo;0;L;;;;;N;;;;;\n31F9;KATAKANA LETTER SMALL HO;Lo;0;L;;;;;N;;;;;\n31FA;KATAKANA LETTER SMALL MU;Lo;0;L;;;;;N;;;;;\n31FB;KATAKANA LETTER SMALL RA;Lo;0;L;;;;;N;;;;;\n31FC;KATAKANA LETTER SMALL RI;Lo;0;L;;;;;N;;;;;\n31FD;KATAKANA LETTER SMALL RU;Lo;0;L;;;;;N;;;;;\n31FE;KATAKANA LETTER SMALL RE;Lo;0;L;;;;;N;;;;;\n31FF;KATAKANA LETTER SMALL RO;Lo;0;L;;;;;N;;;;;\n3200;PARENTHESIZED HANGUL KIYEOK;So;0;L;<compat> 0028 1100 0029;;;;N;PARENTHESIZED HANGUL GIYEOG;;;;\n3201;PARENTHESIZED HANGUL NIEUN;So;0;L;<compat> 0028 1102 0029;;;;N;;;;;\n3202;PARENTHESIZED HANGUL TIKEUT;So;0;L;<compat> 0028 1103 0029;;;;N;PARENTHESIZED HANGUL DIGEUD;;;;\n3203;PARENTHESIZED HANGUL RIEUL;So;0;L;<compat> 0028 1105 0029;;;;N;PARENTHESIZED HANGUL LIEUL;;;;\n3204;PARENTHESIZED HANGUL MIEUM;So;0;L;<compat> 0028 1106 0029;;;;N;;;;;\n3205;PARENTHESIZED HANGUL PIEUP;So;0;L;<compat> 0028 1107 0029;;;;N;PARENTHESIZED HANGUL BIEUB;;;;\n3206;PARENTHESIZED HANGUL SIOS;So;0;L;<compat> 0028 1109 0029;;;;N;;;;;\n3207;PARENTHESIZED HANGUL IEUNG;So;0;L;<compat> 0028 110B 0029;;;;N;;;;;\n3208;PARENTHESIZED HANGUL CIEUC;So;0;L;<compat> 0028 110C 0029;;;;N;PARENTHESIZED HANGUL JIEUJ;;;;\n3209;PARENTHESIZED HANGUL CHIEUCH;So;0;L;<compat> 0028 110E 0029;;;;N;PARENTHESIZED HANGUL CIEUC;;;;\n320A;PARENTHESIZED HANGUL KHIEUKH;So;0;L;<compat> 0028 110F 0029;;;;N;PARENTHESIZED HANGUL KIYEOK;;;;\n320B;PARENTHESIZED HANGUL THIEUTH;So;0;L;<compat> 0028 1110 0029;;;;N;PARENTHESIZED HANGUL TIEUT;;;;\n320C;PARENTHESIZED HANGUL PHIEUPH;So;0;L;<compat> 0028 1111 0029;;;;N;PARENTHESIZED HANGUL PIEUP;;;;\n320D;PARENTHESIZED HANGUL HIEUH;So;0;L;<compat> 0028 1112 0029;;;;N;;;;;\n320E;PARENTHESIZED HANGUL KIYEOK A;So;0;L;<compat> 0028 1100 1161 0029;;;;N;PARENTHESIZED HANGUL GA;;;;\n320F;PARENTHESIZED HANGUL NIEUN A;So;0;L;<compat> 0028 1102 1161 0029;;;;N;PARENTHESIZED HANGUL NA;;;;\n3210;PARENTHESIZED HANGUL TIKEUT A;So;0;L;<compat> 0028 1103 1161 0029;;;;N;PARENTHESIZED HANGUL DA;;;;\n3211;PARENTHESIZED HANGUL RIEUL A;So;0;L;<compat> 0028 1105 1161 0029;;;;N;PARENTHESIZED HANGUL LA;;;;\n3212;PARENTHESIZED HANGUL MIEUM A;So;0;L;<compat> 0028 1106 1161 0029;;;;N;PARENTHESIZED HANGUL MA;;;;\n3213;PARENTHESIZED HANGUL PIEUP A;So;0;L;<compat> 0028 1107 1161 0029;;;;N;PARENTHESIZED HANGUL BA;;;;\n3214;PARENTHESIZED HANGUL SIOS A;So;0;L;<compat> 0028 1109 1161 0029;;;;N;PARENTHESIZED HANGUL SA;;;;\n3215;PARENTHESIZED HANGUL IEUNG A;So;0;L;<compat> 0028 110B 1161 0029;;;;N;PARENTHESIZED HANGUL A;;;;\n3216;PARENTHESIZED HANGUL CIEUC A;So;0;L;<compat> 0028 110C 1161 0029;;;;N;PARENTHESIZED HANGUL JA;;;;\n3217;PARENTHESIZED HANGUL CHIEUCH A;So;0;L;<compat> 0028 110E 1161 0029;;;;N;PARENTHESIZED HANGUL CA;;;;\n3218;PARENTHESIZED HANGUL KHIEUKH A;So;0;L;<compat> 0028 110F 1161 0029;;;;N;PARENTHESIZED HANGUL KA;;;;\n3219;PARENTHESIZED HANGUL THIEUTH A;So;0;L;<compat> 0028 1110 1161 0029;;;;N;PARENTHESIZED HANGUL TA;;;;\n321A;PARENTHESIZED HANGUL PHIEUPH A;So;0;L;<compat> 0028 1111 1161 0029;;;;N;PARENTHESIZED HANGUL PA;;;;\n321B;PARENTHESIZED HANGUL HIEUH A;So;0;L;<compat> 0028 1112 1161 0029;;;;N;PARENTHESIZED HANGUL HA;;;;\n321C;PARENTHESIZED HANGUL CIEUC U;So;0;L;<compat> 0028 110C 116E 0029;;;;N;PARENTHESIZED HANGUL JU;;;;\n321D;PARENTHESIZED KOREAN CHARACTER OJEON;So;0;ON;<compat> 0028 110B 1169 110C 1165 11AB 0029;;;;N;;;;;\n321E;PARENTHESIZED KOREAN CHARACTER O HU;So;0;ON;<compat> 0028 110B 1169 1112 116E 0029;;;;N;;;;;\n3220;PARENTHESIZED IDEOGRAPH ONE;No;0;L;<compat> 0028 4E00 0029;;;1;N;;;;;\n3221;PARENTHESIZED IDEOGRAPH TWO;No;0;L;<compat> 0028 4E8C 0029;;;2;N;;;;;\n3222;PARENTHESIZED IDEOGRAPH THREE;No;0;L;<compat> 0028 4E09 0029;;;3;N;;;;;\n3223;PARENTHESIZED IDEOGRAPH FOUR;No;0;L;<compat> 0028 56DB 0029;;;4;N;;;;;\n3224;PARENTHESIZED IDEOGRAPH FIVE;No;0;L;<compat> 0028 4E94 0029;;;5;N;;;;;\n3225;PARENTHESIZED IDEOGRAPH SIX;No;0;L;<compat> 0028 516D 0029;;;6;N;;;;;\n3226;PARENTHESIZED IDEOGRAPH SEVEN;No;0;L;<compat> 0028 4E03 0029;;;7;N;;;;;\n3227;PARENTHESIZED IDEOGRAPH EIGHT;No;0;L;<compat> 0028 516B 0029;;;8;N;;;;;\n3228;PARENTHESIZED IDEOGRAPH NINE;No;0;L;<compat> 0028 4E5D 0029;;;9;N;;;;;\n3229;PARENTHESIZED IDEOGRAPH TEN;No;0;L;<compat> 0028 5341 0029;;;10;N;;;;;\n322A;PARENTHESIZED IDEOGRAPH MOON;So;0;L;<compat> 0028 6708 0029;;;;N;;;;;\n322B;PARENTHESIZED IDEOGRAPH FIRE;So;0;L;<compat> 0028 706B 0029;;;;N;;;;;\n322C;PARENTHESIZED IDEOGRAPH WATER;So;0;L;<compat> 0028 6C34 0029;;;;N;;;;;\n322D;PARENTHESIZED IDEOGRAPH WOOD;So;0;L;<compat> 0028 6728 0029;;;;N;;;;;\n322E;PARENTHESIZED IDEOGRAPH METAL;So;0;L;<compat> 0028 91D1 0029;;;;N;;;;;\n322F;PARENTHESIZED IDEOGRAPH EARTH;So;0;L;<compat> 0028 571F 0029;;;;N;;;;;\n3230;PARENTHESIZED IDEOGRAPH SUN;So;0;L;<compat> 0028 65E5 0029;;;;N;;;;;\n3231;PARENTHESIZED IDEOGRAPH STOCK;So;0;L;<compat> 0028 682A 0029;;;;N;;;;;\n3232;PARENTHESIZED IDEOGRAPH HAVE;So;0;L;<compat> 0028 6709 0029;;;;N;;;;;\n3233;PARENTHESIZED IDEOGRAPH SOCIETY;So;0;L;<compat> 0028 793E 0029;;;;N;;;;;\n3234;PARENTHESIZED IDEOGRAPH NAME;So;0;L;<compat> 0028 540D 0029;;;;N;;;;;\n3235;PARENTHESIZED IDEOGRAPH SPECIAL;So;0;L;<compat> 0028 7279 0029;;;;N;;;;;\n3236;PARENTHESIZED IDEOGRAPH FINANCIAL;So;0;L;<compat> 0028 8CA1 0029;;;;N;;;;;\n3237;PARENTHESIZED IDEOGRAPH CONGRATULATION;So;0;L;<compat> 0028 795D 0029;;;;N;;;;;\n3238;PARENTHESIZED IDEOGRAPH LABOR;So;0;L;<compat> 0028 52B4 0029;;;;N;;;;;\n3239;PARENTHESIZED IDEOGRAPH REPRESENT;So;0;L;<compat> 0028 4EE3 0029;;;;N;;;;;\n323A;PARENTHESIZED IDEOGRAPH CALL;So;0;L;<compat> 0028 547C 0029;;;;N;;;;;\n323B;PARENTHESIZED IDEOGRAPH STUDY;So;0;L;<compat> 0028 5B66 0029;;;;N;;;;;\n323C;PARENTHESIZED IDEOGRAPH SUPERVISE;So;0;L;<compat> 0028 76E3 0029;;;;N;;;;;\n323D;PARENTHESIZED IDEOGRAPH ENTERPRISE;So;0;L;<compat> 0028 4F01 0029;;;;N;;;;;\n323E;PARENTHESIZED IDEOGRAPH RESOURCE;So;0;L;<compat> 0028 8CC7 0029;;;;N;;;;;\n323F;PARENTHESIZED IDEOGRAPH ALLIANCE;So;0;L;<compat> 0028 5354 0029;;;;N;;;;;\n3240;PARENTHESIZED IDEOGRAPH FESTIVAL;So;0;L;<compat> 0028 796D 0029;;;;N;;;;;\n3241;PARENTHESIZED IDEOGRAPH REST;So;0;L;<compat> 0028 4F11 0029;;;;N;;;;;\n3242;PARENTHESIZED IDEOGRAPH SELF;So;0;L;<compat> 0028 81EA 0029;;;;N;;;;;\n3243;PARENTHESIZED IDEOGRAPH REACH;So;0;L;<compat> 0028 81F3 0029;;;;N;;;;;\n3244;CIRCLED IDEOGRAPH QUESTION;So;0;L;<circle> 554F;;;;N;;;;;\n3245;CIRCLED IDEOGRAPH KINDERGARTEN;So;0;L;<circle> 5E7C;;;;N;;;;;\n3246;CIRCLED IDEOGRAPH SCHOOL;So;0;L;<circle> 6587;;;;N;;;;;\n3247;CIRCLED IDEOGRAPH KOTO;So;0;L;<circle> 7B8F;;;;N;;;;;\n3248;CIRCLED NUMBER TEN ON BLACK SQUARE;No;0;L;;;;10;N;;;;;\n3249;CIRCLED NUMBER TWENTY ON BLACK SQUARE;No;0;L;;;;20;N;;;;;\n324A;CIRCLED NUMBER THIRTY ON BLACK SQUARE;No;0;L;;;;30;N;;;;;\n324B;CIRCLED NUMBER FORTY ON BLACK SQUARE;No;0;L;;;;40;N;;;;;\n324C;CIRCLED NUMBER FIFTY ON BLACK SQUARE;No;0;L;;;;50;N;;;;;\n324D;CIRCLED NUMBER SIXTY ON BLACK SQUARE;No;0;L;;;;60;N;;;;;\n324E;CIRCLED NUMBER SEVENTY ON BLACK SQUARE;No;0;L;;;;70;N;;;;;\n324F;CIRCLED NUMBER EIGHTY ON BLACK SQUARE;No;0;L;;;;80;N;;;;;\n3250;PARTNERSHIP SIGN;So;0;ON;<square> 0050 0054 0045;;;;N;;;;;\n3251;CIRCLED NUMBER TWENTY ONE;No;0;ON;<circle> 0032 0031;;;21;N;;;;;\n3252;CIRCLED NUMBER TWENTY TWO;No;0;ON;<circle> 0032 0032;;;22;N;;;;;\n3253;CIRCLED NUMBER TWENTY THREE;No;0;ON;<circle> 0032 0033;;;23;N;;;;;\n3254;CIRCLED NUMBER TWENTY FOUR;No;0;ON;<circle> 0032 0034;;;24;N;;;;;\n3255;CIRCLED NUMBER TWENTY FIVE;No;0;ON;<circle> 0032 0035;;;25;N;;;;;\n3256;CIRCLED NUMBER TWENTY SIX;No;0;ON;<circle> 0032 0036;;;26;N;;;;;\n3257;CIRCLED NUMBER TWENTY SEVEN;No;0;ON;<circle> 0032 0037;;;27;N;;;;;\n3258;CIRCLED NUMBER TWENTY EIGHT;No;0;ON;<circle> 0032 0038;;;28;N;;;;;\n3259;CIRCLED NUMBER TWENTY NINE;No;0;ON;<circle> 0032 0039;;;29;N;;;;;\n325A;CIRCLED NUMBER THIRTY;No;0;ON;<circle> 0033 0030;;;30;N;;;;;\n325B;CIRCLED NUMBER THIRTY ONE;No;0;ON;<circle> 0033 0031;;;31;N;;;;;\n325C;CIRCLED NUMBER THIRTY TWO;No;0;ON;<circle> 0033 0032;;;32;N;;;;;\n325D;CIRCLED NUMBER THIRTY THREE;No;0;ON;<circle> 0033 0033;;;33;N;;;;;\n325E;CIRCLED NUMBER THIRTY FOUR;No;0;ON;<circle> 0033 0034;;;34;N;;;;;\n325F;CIRCLED NUMBER THIRTY FIVE;No;0;ON;<circle> 0033 0035;;;35;N;;;;;\n3260;CIRCLED HANGUL KIYEOK;So;0;L;<circle> 1100;;;;N;CIRCLED HANGUL GIYEOG;;;;\n3261;CIRCLED HANGUL NIEUN;So;0;L;<circle> 1102;;;;N;;;;;\n3262;CIRCLED HANGUL TIKEUT;So;0;L;<circle> 1103;;;;N;CIRCLED HANGUL DIGEUD;;;;\n3263;CIRCLED HANGUL RIEUL;So;0;L;<circle> 1105;;;;N;CIRCLED HANGUL LIEUL;;;;\n3264;CIRCLED HANGUL MIEUM;So;0;L;<circle> 1106;;;;N;;;;;\n3265;CIRCLED HANGUL PIEUP;So;0;L;<circle> 1107;;;;N;CIRCLED HANGUL BIEUB;;;;\n3266;CIRCLED HANGUL SIOS;So;0;L;<circle> 1109;;;;N;;;;;\n3267;CIRCLED HANGUL IEUNG;So;0;L;<circle> 110B;;;;N;;;;;\n3268;CIRCLED HANGUL CIEUC;So;0;L;<circle> 110C;;;;N;CIRCLED HANGUL JIEUJ;;;;\n3269;CIRCLED HANGUL CHIEUCH;So;0;L;<circle> 110E;;;;N;CIRCLED HANGUL CIEUC;;;;\n326A;CIRCLED HANGUL KHIEUKH;So;0;L;<circle> 110F;;;;N;CIRCLED HANGUL KIYEOK;;;;\n326B;CIRCLED HANGUL THIEUTH;So;0;L;<circle> 1110;;;;N;CIRCLED HANGUL TIEUT;;;;\n326C;CIRCLED HANGUL PHIEUPH;So;0;L;<circle> 1111;;;;N;CIRCLED HANGUL PIEUP;;;;\n326D;CIRCLED HANGUL HIEUH;So;0;L;<circle> 1112;;;;N;;;;;\n326E;CIRCLED HANGUL KIYEOK A;So;0;L;<circle> 1100 1161;;;;N;CIRCLED HANGUL GA;;;;\n326F;CIRCLED HANGUL NIEUN A;So;0;L;<circle> 1102 1161;;;;N;CIRCLED HANGUL NA;;;;\n3270;CIRCLED HANGUL TIKEUT A;So;0;L;<circle> 1103 1161;;;;N;CIRCLED HANGUL DA;;;;\n3271;CIRCLED HANGUL RIEUL A;So;0;L;<circle> 1105 1161;;;;N;CIRCLED HANGUL LA;;;;\n3272;CIRCLED HANGUL MIEUM A;So;0;L;<circle> 1106 1161;;;;N;CIRCLED HANGUL MA;;;;\n3273;CIRCLED HANGUL PIEUP A;So;0;L;<circle> 1107 1161;;;;N;CIRCLED HANGUL BA;;;;\n3274;CIRCLED HANGUL SIOS A;So;0;L;<circle> 1109 1161;;;;N;CIRCLED HANGUL SA;;;;\n3275;CIRCLED HANGUL IEUNG A;So;0;L;<circle> 110B 1161;;;;N;CIRCLED HANGUL A;;;;\n3276;CIRCLED HANGUL CIEUC A;So;0;L;<circle> 110C 1161;;;;N;CIRCLED HANGUL JA;;;;\n3277;CIRCLED HANGUL CHIEUCH A;So;0;L;<circle> 110E 1161;;;;N;CIRCLED HANGUL CA;;;;\n3278;CIRCLED HANGUL KHIEUKH A;So;0;L;<circle> 110F 1161;;;;N;CIRCLED HANGUL KA;;;;\n3279;CIRCLED HANGUL THIEUTH A;So;0;L;<circle> 1110 1161;;;;N;CIRCLED HANGUL TA;;;;\n327A;CIRCLED HANGUL PHIEUPH A;So;0;L;<circle> 1111 1161;;;;N;CIRCLED HANGUL PA;;;;\n327B;CIRCLED HANGUL HIEUH A;So;0;L;<circle> 1112 1161;;;;N;CIRCLED HANGUL HA;;;;\n327C;CIRCLED KOREAN CHARACTER CHAMKO;So;0;ON;<circle> 110E 1161 11B7 1100 1169;;;;N;;;;;\n327D;CIRCLED KOREAN CHARACTER JUEUI;So;0;ON;<circle> 110C 116E 110B 1174;;;;N;;;;;\n327E;CIRCLED HANGUL IEUNG U;So;0;ON;<circle> 110B 116E;;;;N;;;;;\n327F;KOREAN STANDARD SYMBOL;So;0;L;;;;;N;;;;;\n3280;CIRCLED IDEOGRAPH ONE;No;0;L;<circle> 4E00;;;1;N;;;;;\n3281;CIRCLED IDEOGRAPH TWO;No;0;L;<circle> 4E8C;;;2;N;;;;;\n3282;CIRCLED IDEOGRAPH THREE;No;0;L;<circle> 4E09;;;3;N;;;;;\n3283;CIRCLED IDEOGRAPH FOUR;No;0;L;<circle> 56DB;;;4;N;;;;;\n3284;CIRCLED IDEOGRAPH FIVE;No;0;L;<circle> 4E94;;;5;N;;;;;\n3285;CIRCLED IDEOGRAPH SIX;No;0;L;<circle> 516D;;;6;N;;;;;\n3286;CIRCLED IDEOGRAPH SEVEN;No;0;L;<circle> 4E03;;;7;N;;;;;\n3287;CIRCLED IDEOGRAPH EIGHT;No;0;L;<circle> 516B;;;8;N;;;;;\n3288;CIRCLED IDEOGRAPH NINE;No;0;L;<circle> 4E5D;;;9;N;;;;;\n3289;CIRCLED IDEOGRAPH TEN;No;0;L;<circle> 5341;;;10;N;;;;;\n328A;CIRCLED IDEOGRAPH MOON;So;0;L;<circle> 6708;;;;N;;;;;\n328B;CIRCLED IDEOGRAPH FIRE;So;0;L;<circle> 706B;;;;N;;;;;\n328C;CIRCLED IDEOGRAPH WATER;So;0;L;<circle> 6C34;;;;N;;;;;\n328D;CIRCLED IDEOGRAPH WOOD;So;0;L;<circle> 6728;;;;N;;;;;\n328E;CIRCLED IDEOGRAPH METAL;So;0;L;<circle> 91D1;;;;N;;;;;\n328F;CIRCLED IDEOGRAPH EARTH;So;0;L;<circle> 571F;;;;N;;;;;\n3290;CIRCLED IDEOGRAPH SUN;So;0;L;<circle> 65E5;;;;N;;;;;\n3291;CIRCLED IDEOGRAPH STOCK;So;0;L;<circle> 682A;;;;N;;;;;\n3292;CIRCLED IDEOGRAPH HAVE;So;0;L;<circle> 6709;;;;N;;;;;\n3293;CIRCLED IDEOGRAPH SOCIETY;So;0;L;<circle> 793E;;;;N;;;;;\n3294;CIRCLED IDEOGRAPH NAME;So;0;L;<circle> 540D;;;;N;;;;;\n3295;CIRCLED IDEOGRAPH SPECIAL;So;0;L;<circle> 7279;;;;N;;;;;\n3296;CIRCLED IDEOGRAPH FINANCIAL;So;0;L;<circle> 8CA1;;;;N;;;;;\n3297;CIRCLED IDEOGRAPH CONGRATULATION;So;0;L;<circle> 795D;;;;N;;;;;\n3298;CIRCLED IDEOGRAPH LABOR;So;0;L;<circle> 52B4;;;;N;;;;;\n3299;CIRCLED IDEOGRAPH SECRET;So;0;L;<circle> 79D8;;;;N;;;;;\n329A;CIRCLED IDEOGRAPH MALE;So;0;L;<circle> 7537;;;;N;;;;;\n329B;CIRCLED IDEOGRAPH FEMALE;So;0;L;<circle> 5973;;;;N;;;;;\n329C;CIRCLED IDEOGRAPH SUITABLE;So;0;L;<circle> 9069;;;;N;;;;;\n329D;CIRCLED IDEOGRAPH EXCELLENT;So;0;L;<circle> 512A;;;;N;;;;;\n329E;CIRCLED IDEOGRAPH PRINT;So;0;L;<circle> 5370;;;;N;;;;;\n329F;CIRCLED IDEOGRAPH ATTENTION;So;0;L;<circle> 6CE8;;;;N;;;;;\n32A0;CIRCLED IDEOGRAPH ITEM;So;0;L;<circle> 9805;;;;N;;;;;\n32A1;CIRCLED IDEOGRAPH REST;So;0;L;<circle> 4F11;;;;N;;;;;\n32A2;CIRCLED IDEOGRAPH COPY;So;0;L;<circle> 5199;;;;N;;;;;\n32A3;CIRCLED IDEOGRAPH CORRECT;So;0;L;<circle> 6B63;;;;N;;;;;\n32A4;CIRCLED IDEOGRAPH HIGH;So;0;L;<circle> 4E0A;;;;N;;;;;\n32A5;CIRCLED IDEOGRAPH CENTRE;So;0;L;<circle> 4E2D;;;;N;CIRCLED IDEOGRAPH CENTER;;;;\n32A6;CIRCLED IDEOGRAPH LOW;So;0;L;<circle> 4E0B;;;;N;;;;;\n32A7;CIRCLED IDEOGRAPH LEFT;So;0;L;<circle> 5DE6;;;;N;;;;;\n32A8;CIRCLED IDEOGRAPH RIGHT;So;0;L;<circle> 53F3;;;;N;;;;;\n32A9;CIRCLED IDEOGRAPH MEDICINE;So;0;L;<circle> 533B;;;;N;;;;;\n32AA;CIRCLED IDEOGRAPH RELIGION;So;0;L;<circle> 5B97;;;;N;;;;;\n32AB;CIRCLED IDEOGRAPH STUDY;So;0;L;<circle> 5B66;;;;N;;;;;\n32AC;CIRCLED IDEOGRAPH SUPERVISE;So;0;L;<circle> 76E3;;;;N;;;;;\n32AD;CIRCLED IDEOGRAPH ENTERPRISE;So;0;L;<circle> 4F01;;;;N;;;;;\n32AE;CIRCLED IDEOGRAPH RESOURCE;So;0;L;<circle> 8CC7;;;;N;;;;;\n32AF;CIRCLED IDEOGRAPH ALLIANCE;So;0;L;<circle> 5354;;;;N;;;;;\n32B0;CIRCLED IDEOGRAPH NIGHT;So;0;L;<circle> 591C;;;;N;;;;;\n32B1;CIRCLED NUMBER THIRTY SIX;No;0;ON;<circle> 0033 0036;;;36;N;;;;;\n32B2;CIRCLED NUMBER THIRTY SEVEN;No;0;ON;<circle> 0033 0037;;;37;N;;;;;\n32B3;CIRCLED NUMBER THIRTY EIGHT;No;0;ON;<circle> 0033 0038;;;38;N;;;;;\n32B4;CIRCLED NUMBER THIRTY NINE;No;0;ON;<circle> 0033 0039;;;39;N;;;;;\n32B5;CIRCLED NUMBER FORTY;No;0;ON;<circle> 0034 0030;;;40;N;;;;;\n32B6;CIRCLED NUMBER FORTY ONE;No;0;ON;<circle> 0034 0031;;;41;N;;;;;\n32B7;CIRCLED NUMBER FORTY TWO;No;0;ON;<circle> 0034 0032;;;42;N;;;;;\n32B8;CIRCLED NUMBER FORTY THREE;No;0;ON;<circle> 0034 0033;;;43;N;;;;;\n32B9;CIRCLED NUMBER FORTY FOUR;No;0;ON;<circle> 0034 0034;;;44;N;;;;;\n32BA;CIRCLED NUMBER FORTY FIVE;No;0;ON;<circle> 0034 0035;;;45;N;;;;;\n32BB;CIRCLED NUMBER FORTY SIX;No;0;ON;<circle> 0034 0036;;;46;N;;;;;\n32BC;CIRCLED NUMBER FORTY SEVEN;No;0;ON;<circle> 0034 0037;;;47;N;;;;;\n32BD;CIRCLED NUMBER FORTY EIGHT;No;0;ON;<circle> 0034 0038;;;48;N;;;;;\n32BE;CIRCLED NUMBER FORTY NINE;No;0;ON;<circle> 0034 0039;;;49;N;;;;;\n32BF;CIRCLED NUMBER FIFTY;No;0;ON;<circle> 0035 0030;;;50;N;;;;;\n32C0;IDEOGRAPHIC TELEGRAPH SYMBOL FOR JANUARY;So;0;L;<compat> 0031 6708;;;;N;;;;;\n32C1;IDEOGRAPHIC TELEGRAPH SYMBOL FOR FEBRUARY;So;0;L;<compat> 0032 6708;;;;N;;;;;\n32C2;IDEOGRAPHIC TELEGRAPH SYMBOL FOR MARCH;So;0;L;<compat> 0033 6708;;;;N;;;;;\n32C3;IDEOGRAPHIC TELEGRAPH SYMBOL FOR APRIL;So;0;L;<compat> 0034 6708;;;;N;;;;;\n32C4;IDEOGRAPHIC TELEGRAPH SYMBOL FOR MAY;So;0;L;<compat> 0035 6708;;;;N;;;;;\n32C5;IDEOGRAPHIC TELEGRAPH SYMBOL FOR JUNE;So;0;L;<compat> 0036 6708;;;;N;;;;;\n32C6;IDEOGRAPHIC TELEGRAPH SYMBOL FOR JULY;So;0;L;<compat> 0037 6708;;;;N;;;;;\n32C7;IDEOGRAPHIC TELEGRAPH SYMBOL FOR AUGUST;So;0;L;<compat> 0038 6708;;;;N;;;;;\n32C8;IDEOGRAPHIC TELEGRAPH SYMBOL FOR SEPTEMBER;So;0;L;<compat> 0039 6708;;;;N;;;;;\n32C9;IDEOGRAPHIC TELEGRAPH SYMBOL FOR OCTOBER;So;0;L;<compat> 0031 0030 6708;;;;N;;;;;\n32CA;IDEOGRAPHIC TELEGRAPH SYMBOL FOR NOVEMBER;So;0;L;<compat> 0031 0031 6708;;;;N;;;;;\n32CB;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DECEMBER;So;0;L;<compat> 0031 0032 6708;;;;N;;;;;\n32CC;SQUARE HG;So;0;ON;<square> 0048 0067;;;;N;;;;;\n32CD;SQUARE ERG;So;0;ON;<square> 0065 0072 0067;;;;N;;;;;\n32CE;SQUARE EV;So;0;ON;<square> 0065 0056;;;;N;;;;;\n32CF;LIMITED LIABILITY SIGN;So;0;ON;<square> 004C 0054 0044;;;;N;;;;;\n32D0;CIRCLED KATAKANA A;So;0;L;<circle> 30A2;;;;N;;;;;\n32D1;CIRCLED KATAKANA I;So;0;L;<circle> 30A4;;;;N;;;;;\n32D2;CIRCLED KATAKANA U;So;0;L;<circle> 30A6;;;;N;;;;;\n32D3;CIRCLED KATAKANA E;So;0;L;<circle> 30A8;;;;N;;;;;\n32D4;CIRCLED KATAKANA O;So;0;L;<circle> 30AA;;;;N;;;;;\n32D5;CIRCLED KATAKANA KA;So;0;L;<circle> 30AB;;;;N;;;;;\n32D6;CIRCLED KATAKANA KI;So;0;L;<circle> 30AD;;;;N;;;;;\n32D7;CIRCLED KATAKANA KU;So;0;L;<circle> 30AF;;;;N;;;;;\n32D8;CIRCLED KATAKANA KE;So;0;L;<circle> 30B1;;;;N;;;;;\n32D9;CIRCLED KATAKANA KO;So;0;L;<circle> 30B3;;;;N;;;;;\n32DA;CIRCLED KATAKANA SA;So;0;L;<circle> 30B5;;;;N;;;;;\n32DB;CIRCLED KATAKANA SI;So;0;L;<circle> 30B7;;;;N;;;;;\n32DC;CIRCLED KATAKANA SU;So;0;L;<circle> 30B9;;;;N;;;;;\n32DD;CIRCLED KATAKANA SE;So;0;L;<circle> 30BB;;;;N;;;;;\n32DE;CIRCLED KATAKANA SO;So;0;L;<circle> 30BD;;;;N;;;;;\n32DF;CIRCLED KATAKANA TA;So;0;L;<circle> 30BF;;;;N;;;;;\n32E0;CIRCLED KATAKANA TI;So;0;L;<circle> 30C1;;;;N;;;;;\n32E1;CIRCLED KATAKANA TU;So;0;L;<circle> 30C4;;;;N;;;;;\n32E2;CIRCLED KATAKANA TE;So;0;L;<circle> 30C6;;;;N;;;;;\n32E3;CIRCLED KATAKANA TO;So;0;L;<circle> 30C8;;;;N;;;;;\n32E4;CIRCLED KATAKANA NA;So;0;L;<circle> 30CA;;;;N;;;;;\n32E5;CIRCLED KATAKANA NI;So;0;L;<circle> 30CB;;;;N;;;;;\n32E6;CIRCLED KATAKANA NU;So;0;L;<circle> 30CC;;;;N;;;;;\n32E7;CIRCLED KATAKANA NE;So;0;L;<circle> 30CD;;;;N;;;;;\n32E8;CIRCLED KATAKANA NO;So;0;L;<circle> 30CE;;;;N;;;;;\n32E9;CIRCLED KATAKANA HA;So;0;L;<circle> 30CF;;;;N;;;;;\n32EA;CIRCLED KATAKANA HI;So;0;L;<circle> 30D2;;;;N;;;;;\n32EB;CIRCLED KATAKANA HU;So;0;L;<circle> 30D5;;;;N;;;;;\n32EC;CIRCLED KATAKANA HE;So;0;L;<circle> 30D8;;;;N;;;;;\n32ED;CIRCLED KATAKANA HO;So;0;L;<circle> 30DB;;;;N;;;;;\n32EE;CIRCLED KATAKANA MA;So;0;L;<circle> 30DE;;;;N;;;;;\n32EF;CIRCLED KATAKANA MI;So;0;L;<circle> 30DF;;;;N;;;;;\n32F0;CIRCLED KATAKANA MU;So;0;L;<circle> 30E0;;;;N;;;;;\n32F1;CIRCLED KATAKANA ME;So;0;L;<circle> 30E1;;;;N;;;;;\n32F2;CIRCLED KATAKANA MO;So;0;L;<circle> 30E2;;;;N;;;;;\n32F3;CIRCLED KATAKANA YA;So;0;L;<circle> 30E4;;;;N;;;;;\n32F4;CIRCLED KATAKANA YU;So;0;L;<circle> 30E6;;;;N;;;;;\n32F5;CIRCLED KATAKANA YO;So;0;L;<circle> 30E8;;;;N;;;;;\n32F6;CIRCLED KATAKANA RA;So;0;L;<circle> 30E9;;;;N;;;;;\n32F7;CIRCLED KATAKANA RI;So;0;L;<circle> 30EA;;;;N;;;;;\n32F8;CIRCLED KATAKANA RU;So;0;L;<circle> 30EB;;;;N;;;;;\n32F9;CIRCLED KATAKANA RE;So;0;L;<circle> 30EC;;;;N;;;;;\n32FA;CIRCLED KATAKANA RO;So;0;L;<circle> 30ED;;;;N;;;;;\n32FB;CIRCLED KATAKANA WA;So;0;L;<circle> 30EF;;;;N;;;;;\n32FC;CIRCLED KATAKANA WI;So;0;L;<circle> 30F0;;;;N;;;;;\n32FD;CIRCLED KATAKANA WE;So;0;L;<circle> 30F1;;;;N;;;;;\n32FE;CIRCLED KATAKANA WO;So;0;L;<circle> 30F2;;;;N;;;;;\n3300;SQUARE APAATO;So;0;L;<square> 30A2 30D1 30FC 30C8;;;;N;SQUARED APAATO;;;;\n3301;SQUARE ARUHUA;So;0;L;<square> 30A2 30EB 30D5 30A1;;;;N;SQUARED ARUHUA;;;;\n3302;SQUARE ANPEA;So;0;L;<square> 30A2 30F3 30DA 30A2;;;;N;SQUARED ANPEA;;;;\n3303;SQUARE AARU;So;0;L;<square> 30A2 30FC 30EB;;;;N;SQUARED AARU;;;;\n3304;SQUARE ININGU;So;0;L;<square> 30A4 30CB 30F3 30B0;;;;N;SQUARED ININGU;;;;\n3305;SQUARE INTI;So;0;L;<square> 30A4 30F3 30C1;;;;N;SQUARED INTI;;;;\n3306;SQUARE UON;So;0;L;<square> 30A6 30A9 30F3;;;;N;SQUARED UON;;;;\n3307;SQUARE ESUKUUDO;So;0;L;<square> 30A8 30B9 30AF 30FC 30C9;;;;N;SQUARED ESUKUUDO;;;;\n3308;SQUARE EEKAA;So;0;L;<square> 30A8 30FC 30AB 30FC;;;;N;SQUARED EEKAA;;;;\n3309;SQUARE ONSU;So;0;L;<square> 30AA 30F3 30B9;;;;N;SQUARED ONSU;;;;\n330A;SQUARE OOMU;So;0;L;<square> 30AA 30FC 30E0;;;;N;SQUARED OOMU;;;;\n330B;SQUARE KAIRI;So;0;L;<square> 30AB 30A4 30EA;;;;N;SQUARED KAIRI;;;;\n330C;SQUARE KARATTO;So;0;L;<square> 30AB 30E9 30C3 30C8;;;;N;SQUARED KARATTO;;;;\n330D;SQUARE KARORII;So;0;L;<square> 30AB 30ED 30EA 30FC;;;;N;SQUARED KARORII;;;;\n330E;SQUARE GARON;So;0;L;<square> 30AC 30ED 30F3;;;;N;SQUARED GARON;;;;\n330F;SQUARE GANMA;So;0;L;<square> 30AC 30F3 30DE;;;;N;SQUARED GANMA;;;;\n3310;SQUARE GIGA;So;0;L;<square> 30AE 30AC;;;;N;SQUARED GIGA;;;;\n3311;SQUARE GINII;So;0;L;<square> 30AE 30CB 30FC;;;;N;SQUARED GINII;;;;\n3312;SQUARE KYURII;So;0;L;<square> 30AD 30E5 30EA 30FC;;;;N;SQUARED KYURII;;;;\n3313;SQUARE GIRUDAA;So;0;L;<square> 30AE 30EB 30C0 30FC;;;;N;SQUARED GIRUDAA;;;;\n3314;SQUARE KIRO;So;0;L;<square> 30AD 30ED;;;;N;SQUARED KIRO;;;;\n3315;SQUARE KIROGURAMU;So;0;L;<square> 30AD 30ED 30B0 30E9 30E0;;;;N;SQUARED KIROGURAMU;;;;\n3316;SQUARE KIROMEETORU;So;0;L;<square> 30AD 30ED 30E1 30FC 30C8 30EB;;;;N;SQUARED KIROMEETORU;;;;\n3317;SQUARE KIROWATTO;So;0;L;<square> 30AD 30ED 30EF 30C3 30C8;;;;N;SQUARED KIROWATTO;;;;\n3318;SQUARE GURAMU;So;0;L;<square> 30B0 30E9 30E0;;;;N;SQUARED GURAMU;;;;\n3319;SQUARE GURAMUTON;So;0;L;<square> 30B0 30E9 30E0 30C8 30F3;;;;N;SQUARED GURAMUTON;;;;\n331A;SQUARE KURUZEIRO;So;0;L;<square> 30AF 30EB 30BC 30A4 30ED;;;;N;SQUARED KURUZEIRO;;;;\n331B;SQUARE KUROONE;So;0;L;<square> 30AF 30ED 30FC 30CD;;;;N;SQUARED KUROONE;;;;\n331C;SQUARE KEESU;So;0;L;<square> 30B1 30FC 30B9;;;;N;SQUARED KEESU;;;;\n331D;SQUARE KORUNA;So;0;L;<square> 30B3 30EB 30CA;;;;N;SQUARED KORUNA;;;;\n331E;SQUARE KOOPO;So;0;L;<square> 30B3 30FC 30DD;;;;N;SQUARED KOOPO;;;;\n331F;SQUARE SAIKURU;So;0;L;<square> 30B5 30A4 30AF 30EB;;;;N;SQUARED SAIKURU;;;;\n3320;SQUARE SANTIIMU;So;0;L;<square> 30B5 30F3 30C1 30FC 30E0;;;;N;SQUARED SANTIIMU;;;;\n3321;SQUARE SIRINGU;So;0;L;<square> 30B7 30EA 30F3 30B0;;;;N;SQUARED SIRINGU;;;;\n3322;SQUARE SENTI;So;0;L;<square> 30BB 30F3 30C1;;;;N;SQUARED SENTI;;;;\n3323;SQUARE SENTO;So;0;L;<square> 30BB 30F3 30C8;;;;N;SQUARED SENTO;;;;\n3324;SQUARE DAASU;So;0;L;<square> 30C0 30FC 30B9;;;;N;SQUARED DAASU;;;;\n3325;SQUARE DESI;So;0;L;<square> 30C7 30B7;;;;N;SQUARED DESI;;;;\n3326;SQUARE DORU;So;0;L;<square> 30C9 30EB;;;;N;SQUARED DORU;;;;\n3327;SQUARE TON;So;0;L;<square> 30C8 30F3;;;;N;SQUARED TON;;;;\n3328;SQUARE NANO;So;0;L;<square> 30CA 30CE;;;;N;SQUARED NANO;;;;\n3329;SQUARE NOTTO;So;0;L;<square> 30CE 30C3 30C8;;;;N;SQUARED NOTTO;;;;\n332A;SQUARE HAITU;So;0;L;<square> 30CF 30A4 30C4;;;;N;SQUARED HAITU;;;;\n332B;SQUARE PAASENTO;So;0;L;<square> 30D1 30FC 30BB 30F3 30C8;;;;N;SQUARED PAASENTO;;;;\n332C;SQUARE PAATU;So;0;L;<square> 30D1 30FC 30C4;;;;N;SQUARED PAATU;;;;\n332D;SQUARE BAARERU;So;0;L;<square> 30D0 30FC 30EC 30EB;;;;N;SQUARED BAARERU;;;;\n332E;SQUARE PIASUTORU;So;0;L;<square> 30D4 30A2 30B9 30C8 30EB;;;;N;SQUARED PIASUTORU;;;;\n332F;SQUARE PIKURU;So;0;L;<square> 30D4 30AF 30EB;;;;N;SQUARED PIKURU;;;;\n3330;SQUARE PIKO;So;0;L;<square> 30D4 30B3;;;;N;SQUARED PIKO;;;;\n3331;SQUARE BIRU;So;0;L;<square> 30D3 30EB;;;;N;SQUARED BIRU;;;;\n3332;SQUARE HUARADDO;So;0;L;<square> 30D5 30A1 30E9 30C3 30C9;;;;N;SQUARED HUARADDO;;;;\n3333;SQUARE HUIITO;So;0;L;<square> 30D5 30A3 30FC 30C8;;;;N;SQUARED HUIITO;;;;\n3334;SQUARE BUSSYERU;So;0;L;<square> 30D6 30C3 30B7 30A7 30EB;;;;N;SQUARED BUSSYERU;;;;\n3335;SQUARE HURAN;So;0;L;<square> 30D5 30E9 30F3;;;;N;SQUARED HURAN;;;;\n3336;SQUARE HEKUTAARU;So;0;L;<square> 30D8 30AF 30BF 30FC 30EB;;;;N;SQUARED HEKUTAARU;;;;\n3337;SQUARE PESO;So;0;L;<square> 30DA 30BD;;;;N;SQUARED PESO;;;;\n3338;SQUARE PENIHI;So;0;L;<square> 30DA 30CB 30D2;;;;N;SQUARED PENIHI;;;;\n3339;SQUARE HERUTU;So;0;L;<square> 30D8 30EB 30C4;;;;N;SQUARED HERUTU;;;;\n333A;SQUARE PENSU;So;0;L;<square> 30DA 30F3 30B9;;;;N;SQUARED PENSU;;;;\n333B;SQUARE PEEZI;So;0;L;<square> 30DA 30FC 30B8;;;;N;SQUARED PEEZI;;;;\n333C;SQUARE BEETA;So;0;L;<square> 30D9 30FC 30BF;;;;N;SQUARED BEETA;;;;\n333D;SQUARE POINTO;So;0;L;<square> 30DD 30A4 30F3 30C8;;;;N;SQUARED POINTO;;;;\n333E;SQUARE BORUTO;So;0;L;<square> 30DC 30EB 30C8;;;;N;SQUARED BORUTO;;;;\n333F;SQUARE HON;So;0;L;<square> 30DB 30F3;;;;N;SQUARED HON;;;;\n3340;SQUARE PONDO;So;0;L;<square> 30DD 30F3 30C9;;;;N;SQUARED PONDO;;;;\n3341;SQUARE HOORU;So;0;L;<square> 30DB 30FC 30EB;;;;N;SQUARED HOORU;;;;\n3342;SQUARE HOON;So;0;L;<square> 30DB 30FC 30F3;;;;N;SQUARED HOON;;;;\n3343;SQUARE MAIKURO;So;0;L;<square> 30DE 30A4 30AF 30ED;;;;N;SQUARED MAIKURO;;;;\n3344;SQUARE MAIRU;So;0;L;<square> 30DE 30A4 30EB;;;;N;SQUARED MAIRU;;;;\n3345;SQUARE MAHHA;So;0;L;<square> 30DE 30C3 30CF;;;;N;SQUARED MAHHA;;;;\n3346;SQUARE MARUKU;So;0;L;<square> 30DE 30EB 30AF;;;;N;SQUARED MARUKU;;;;\n3347;SQUARE MANSYON;So;0;L;<square> 30DE 30F3 30B7 30E7 30F3;;;;N;SQUARED MANSYON;;;;\n3348;SQUARE MIKURON;So;0;L;<square> 30DF 30AF 30ED 30F3;;;;N;SQUARED MIKURON;;;;\n3349;SQUARE MIRI;So;0;L;<square> 30DF 30EA;;;;N;SQUARED MIRI;;;;\n334A;SQUARE MIRIBAARU;So;0;L;<square> 30DF 30EA 30D0 30FC 30EB;;;;N;SQUARED MIRIBAARU;;;;\n334B;SQUARE MEGA;So;0;L;<square> 30E1 30AC;;;;N;SQUARED MEGA;;;;\n334C;SQUARE MEGATON;So;0;L;<square> 30E1 30AC 30C8 30F3;;;;N;SQUARED MEGATON;;;;\n334D;SQUARE MEETORU;So;0;L;<square> 30E1 30FC 30C8 30EB;;;;N;SQUARED MEETORU;;;;\n334E;SQUARE YAADO;So;0;L;<square> 30E4 30FC 30C9;;;;N;SQUARED YAADO;;;;\n334F;SQUARE YAARU;So;0;L;<square> 30E4 30FC 30EB;;;;N;SQUARED YAARU;;;;\n3350;SQUARE YUAN;So;0;L;<square> 30E6 30A2 30F3;;;;N;SQUARED YUAN;;;;\n3351;SQUARE RITTORU;So;0;L;<square> 30EA 30C3 30C8 30EB;;;;N;SQUARED RITTORU;;;;\n3352;SQUARE RIRA;So;0;L;<square> 30EA 30E9;;;;N;SQUARED RIRA;;;;\n3353;SQUARE RUPII;So;0;L;<square> 30EB 30D4 30FC;;;;N;SQUARED RUPII;;;;\n3354;SQUARE RUUBURU;So;0;L;<square> 30EB 30FC 30D6 30EB;;;;N;SQUARED RUUBURU;;;;\n3355;SQUARE REMU;So;0;L;<square> 30EC 30E0;;;;N;SQUARED REMU;;;;\n3356;SQUARE RENTOGEN;So;0;L;<square> 30EC 30F3 30C8 30B2 30F3;;;;N;SQUARED RENTOGEN;;;;\n3357;SQUARE WATTO;So;0;L;<square> 30EF 30C3 30C8;;;;N;SQUARED WATTO;;;;\n3358;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ZERO;So;0;L;<compat> 0030 70B9;;;;N;;;;;\n3359;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ONE;So;0;L;<compat> 0031 70B9;;;;N;;;;;\n335A;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWO;So;0;L;<compat> 0032 70B9;;;;N;;;;;\n335B;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR THREE;So;0;L;<compat> 0033 70B9;;;;N;;;;;\n335C;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR FOUR;So;0;L;<compat> 0034 70B9;;;;N;;;;;\n335D;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR FIVE;So;0;L;<compat> 0035 70B9;;;;N;;;;;\n335E;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR SIX;So;0;L;<compat> 0036 70B9;;;;N;;;;;\n335F;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR SEVEN;So;0;L;<compat> 0037 70B9;;;;N;;;;;\n3360;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR EIGHT;So;0;L;<compat> 0038 70B9;;;;N;;;;;\n3361;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR NINE;So;0;L;<compat> 0039 70B9;;;;N;;;;;\n3362;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TEN;So;0;L;<compat> 0031 0030 70B9;;;;N;;;;;\n3363;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR ELEVEN;So;0;L;<compat> 0031 0031 70B9;;;;N;;;;;\n3364;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWELVE;So;0;L;<compat> 0031 0032 70B9;;;;N;;;;;\n3365;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR THIRTEEN;So;0;L;<compat> 0031 0033 70B9;;;;N;;;;;\n3366;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR FOURTEEN;So;0;L;<compat> 0031 0034 70B9;;;;N;;;;;\n3367;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR FIFTEEN;So;0;L;<compat> 0031 0035 70B9;;;;N;;;;;\n3368;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR SIXTEEN;So;0;L;<compat> 0031 0036 70B9;;;;N;;;;;\n3369;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR SEVENTEEN;So;0;L;<compat> 0031 0037 70B9;;;;N;;;;;\n336A;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR EIGHTEEN;So;0;L;<compat> 0031 0038 70B9;;;;N;;;;;\n336B;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR NINETEEN;So;0;L;<compat> 0031 0039 70B9;;;;N;;;;;\n336C;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWENTY;So;0;L;<compat> 0032 0030 70B9;;;;N;;;;;\n336D;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWENTY-ONE;So;0;L;<compat> 0032 0031 70B9;;;;N;;;;;\n336E;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWENTY-TWO;So;0;L;<compat> 0032 0032 70B9;;;;N;;;;;\n336F;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWENTY-THREE;So;0;L;<compat> 0032 0033 70B9;;;;N;;;;;\n3370;IDEOGRAPHIC TELEGRAPH SYMBOL FOR HOUR TWENTY-FOUR;So;0;L;<compat> 0032 0034 70B9;;;;N;;;;;\n3371;SQUARE HPA;So;0;L;<square> 0068 0050 0061;;;;N;;;;;\n3372;SQUARE DA;So;0;L;<square> 0064 0061;;;;N;;;;;\n3373;SQUARE AU;So;0;L;<square> 0041 0055;;;;N;;;;;\n3374;SQUARE BAR;So;0;L;<square> 0062 0061 0072;;;;N;;;;;\n3375;SQUARE OV;So;0;L;<square> 006F 0056;;;;N;;;;;\n3376;SQUARE PC;So;0;L;<square> 0070 0063;;;;N;;;;;\n3377;SQUARE DM;So;0;ON;<square> 0064 006D;;;;N;;;;;\n3378;SQUARE DM SQUARED;So;0;ON;<square> 0064 006D 00B2;;;;N;;;;;\n3379;SQUARE DM CUBED;So;0;ON;<square> 0064 006D 00B3;;;;N;;;;;\n337A;SQUARE IU;So;0;ON;<square> 0049 0055;;;;N;;;;;\n337B;SQUARE ERA NAME HEISEI;So;0;L;<square> 5E73 6210;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME HEISEI;;;;\n337C;SQUARE ERA NAME SYOUWA;So;0;L;<square> 662D 548C;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME SYOUWA;;;;\n337D;SQUARE ERA NAME TAISYOU;So;0;L;<square> 5927 6B63;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME TAISYOU;;;;\n337E;SQUARE ERA NAME MEIZI;So;0;L;<square> 660E 6CBB;;;;N;SQUARED TWO IDEOGRAPHS ERA NAME MEIZI;;;;\n337F;SQUARE CORPORATION;So;0;L;<square> 682A 5F0F 4F1A 793E;;;;N;SQUARED FOUR IDEOGRAPHS CORPORATION;;;;\n3380;SQUARE PA AMPS;So;0;L;<square> 0070 0041;;;;N;SQUARED PA AMPS;;;;\n3381;SQUARE NA;So;0;L;<square> 006E 0041;;;;N;SQUARED NA;;;;\n3382;SQUARE MU A;So;0;L;<square> 03BC 0041;;;;N;SQUARED MU A;;;;\n3383;SQUARE MA;So;0;L;<square> 006D 0041;;;;N;SQUARED MA;;;;\n3384;SQUARE KA;So;0;L;<square> 006B 0041;;;;N;SQUARED KA;;;;\n3385;SQUARE KB;So;0;L;<square> 004B 0042;;;;N;SQUARED KB;;;;\n3386;SQUARE MB;So;0;L;<square> 004D 0042;;;;N;SQUARED MB;;;;\n3387;SQUARE GB;So;0;L;<square> 0047 0042;;;;N;SQUARED GB;;;;\n3388;SQUARE CAL;So;0;L;<square> 0063 0061 006C;;;;N;SQUARED CAL;;;;\n3389;SQUARE KCAL;So;0;L;<square> 006B 0063 0061 006C;;;;N;SQUARED KCAL;;;;\n338A;SQUARE PF;So;0;L;<square> 0070 0046;;;;N;SQUARED PF;;;;\n338B;SQUARE NF;So;0;L;<square> 006E 0046;;;;N;SQUARED NF;;;;\n338C;SQUARE MU F;So;0;L;<square> 03BC 0046;;;;N;SQUARED MU F;;;;\n338D;SQUARE MU G;So;0;L;<square> 03BC 0067;;;;N;SQUARED MU G;;;;\n338E;SQUARE MG;So;0;L;<square> 006D 0067;;;;N;SQUARED MG;;;;\n338F;SQUARE KG;So;0;L;<square> 006B 0067;;;;N;SQUARED KG;;;;\n3390;SQUARE HZ;So;0;L;<square> 0048 007A;;;;N;SQUARED HZ;;;;\n3391;SQUARE KHZ;So;0;L;<square> 006B 0048 007A;;;;N;SQUARED KHZ;;;;\n3392;SQUARE MHZ;So;0;L;<square> 004D 0048 007A;;;;N;SQUARED MHZ;;;;\n3393;SQUARE GHZ;So;0;L;<square> 0047 0048 007A;;;;N;SQUARED GHZ;;;;\n3394;SQUARE THZ;So;0;L;<square> 0054 0048 007A;;;;N;SQUARED THZ;;;;\n3395;SQUARE MU L;So;0;L;<square> 03BC 2113;;;;N;SQUARED MU L;;;;\n3396;SQUARE ML;So;0;L;<square> 006D 2113;;;;N;SQUARED ML;;;;\n3397;SQUARE DL;So;0;L;<square> 0064 2113;;;;N;SQUARED DL;;;;\n3398;SQUARE KL;So;0;L;<square> 006B 2113;;;;N;SQUARED KL;;;;\n3399;SQUARE FM;So;0;L;<square> 0066 006D;;;;N;SQUARED FM;;;;\n339A;SQUARE NM;So;0;L;<square> 006E 006D;;;;N;SQUARED NM;;;;\n339B;SQUARE MU M;So;0;L;<square> 03BC 006D;;;;N;SQUARED MU M;;;;\n339C;SQUARE MM;So;0;L;<square> 006D 006D;;;;N;SQUARED MM;;;;\n339D;SQUARE CM;So;0;L;<square> 0063 006D;;;;N;SQUARED CM;;;;\n339E;SQUARE KM;So;0;L;<square> 006B 006D;;;;N;SQUARED KM;;;;\n339F;SQUARE MM SQUARED;So;0;L;<square> 006D 006D 00B2;;;;N;SQUARED MM SQUARED;;;;\n33A0;SQUARE CM SQUARED;So;0;L;<square> 0063 006D 00B2;;;;N;SQUARED CM SQUARED;;;;\n33A1;SQUARE M SQUARED;So;0;L;<square> 006D 00B2;;;;N;SQUARED M SQUARED;;;;\n33A2;SQUARE KM SQUARED;So;0;L;<square> 006B 006D 00B2;;;;N;SQUARED KM SQUARED;;;;\n33A3;SQUARE MM CUBED;So;0;L;<square> 006D 006D 00B3;;;;N;SQUARED MM CUBED;;;;\n33A4;SQUARE CM CUBED;So;0;L;<square> 0063 006D 00B3;;;;N;SQUARED CM CUBED;;;;\n33A5;SQUARE M CUBED;So;0;L;<square> 006D 00B3;;;;N;SQUARED M CUBED;;;;\n33A6;SQUARE KM CUBED;So;0;L;<square> 006B 006D 00B3;;;;N;SQUARED KM CUBED;;;;\n33A7;SQUARE M OVER S;So;0;L;<square> 006D 2215 0073;;;;N;SQUARED M OVER S;;;;\n33A8;SQUARE M OVER S SQUARED;So;0;L;<square> 006D 2215 0073 00B2;;;;N;SQUARED M OVER S SQUARED;;;;\n33A9;SQUARE PA;So;0;L;<square> 0050 0061;;;;N;SQUARED PA;;;;\n33AA;SQUARE KPA;So;0;L;<square> 006B 0050 0061;;;;N;SQUARED KPA;;;;\n33AB;SQUARE MPA;So;0;L;<square> 004D 0050 0061;;;;N;SQUARED MPA;;;;\n33AC;SQUARE GPA;So;0;L;<square> 0047 0050 0061;;;;N;SQUARED GPA;;;;\n33AD;SQUARE RAD;So;0;L;<square> 0072 0061 0064;;;;N;SQUARED RAD;;;;\n33AE;SQUARE RAD OVER S;So;0;L;<square> 0072 0061 0064 2215 0073;;;;N;SQUARED RAD OVER S;;;;\n33AF;SQUARE RAD OVER S SQUARED;So;0;L;<square> 0072 0061 0064 2215 0073 00B2;;;;N;SQUARED RAD OVER S SQUARED;;;;\n33B0;SQUARE PS;So;0;L;<square> 0070 0073;;;;N;SQUARED PS;;;;\n33B1;SQUARE NS;So;0;L;<square> 006E 0073;;;;N;SQUARED NS;;;;\n33B2;SQUARE MU S;So;0;L;<square> 03BC 0073;;;;N;SQUARED MU S;;;;\n33B3;SQUARE MS;So;0;L;<square> 006D 0073;;;;N;SQUARED MS;;;;\n33B4;SQUARE PV;So;0;L;<square> 0070 0056;;;;N;SQUARED PV;;;;\n33B5;SQUARE NV;So;0;L;<square> 006E 0056;;;;N;SQUARED NV;;;;\n33B6;SQUARE MU V;So;0;L;<square> 03BC 0056;;;;N;SQUARED MU V;;;;\n33B7;SQUARE MV;So;0;L;<square> 006D 0056;;;;N;SQUARED MV;;;;\n33B8;SQUARE KV;So;0;L;<square> 006B 0056;;;;N;SQUARED KV;;;;\n33B9;SQUARE MV MEGA;So;0;L;<square> 004D 0056;;;;N;SQUARED MV MEGA;;;;\n33BA;SQUARE PW;So;0;L;<square> 0070 0057;;;;N;SQUARED PW;;;;\n33BB;SQUARE NW;So;0;L;<square> 006E 0057;;;;N;SQUARED NW;;;;\n33BC;SQUARE MU W;So;0;L;<square> 03BC 0057;;;;N;SQUARED MU W;;;;\n33BD;SQUARE MW;So;0;L;<square> 006D 0057;;;;N;SQUARED MW;;;;\n33BE;SQUARE KW;So;0;L;<square> 006B 0057;;;;N;SQUARED KW;;;;\n33BF;SQUARE MW MEGA;So;0;L;<square> 004D 0057;;;;N;SQUARED MW MEGA;;;;\n33C0;SQUARE K OHM;So;0;L;<square> 006B 03A9;;;;N;SQUARED K OHM;;;;\n33C1;SQUARE M OHM;So;0;L;<square> 004D 03A9;;;;N;SQUARED M OHM;;;;\n33C2;SQUARE AM;So;0;L;<square> 0061 002E 006D 002E;;;;N;SQUARED AM;;;;\n33C3;SQUARE BQ;So;0;L;<square> 0042 0071;;;;N;SQUARED BQ;;;;\n33C4;SQUARE CC;So;0;L;<square> 0063 0063;;;;N;SQUARED CC;;;;\n33C5;SQUARE CD;So;0;L;<square> 0063 0064;;;;N;SQUARED CD;;;;\n33C6;SQUARE C OVER KG;So;0;L;<square> 0043 2215 006B 0067;;;;N;SQUARED C OVER KG;;;;\n33C7;SQUARE CO;So;0;L;<square> 0043 006F 002E;;;;N;SQUARED CO;;;;\n33C8;SQUARE DB;So;0;L;<square> 0064 0042;;;;N;SQUARED DB;;;;\n33C9;SQUARE GY;So;0;L;<square> 0047 0079;;;;N;SQUARED GY;;;;\n33CA;SQUARE HA;So;0;L;<square> 0068 0061;;;;N;SQUARED HA;;;;\n33CB;SQUARE HP;So;0;L;<square> 0048 0050;;;;N;SQUARED HP;;;;\n33CC;SQUARE IN;So;0;L;<square> 0069 006E;;;;N;SQUARED IN;;;;\n33CD;SQUARE KK;So;0;L;<square> 004B 004B;;;;N;SQUARED KK;;;;\n33CE;SQUARE KM CAPITAL;So;0;L;<square> 004B 004D;;;;N;SQUARED KM CAPITAL;;;;\n33CF;SQUARE KT;So;0;L;<square> 006B 0074;;;;N;SQUARED KT;;;;\n33D0;SQUARE LM;So;0;L;<square> 006C 006D;;;;N;SQUARED LM;;;;\n33D1;SQUARE LN;So;0;L;<square> 006C 006E;;;;N;SQUARED LN;;;;\n33D2;SQUARE LOG;So;0;L;<square> 006C 006F 0067;;;;N;SQUARED LOG;;;;\n33D3;SQUARE LX;So;0;L;<square> 006C 0078;;;;N;SQUARED LX;;;;\n33D4;SQUARE MB SMALL;So;0;L;<square> 006D 0062;;;;N;SQUARED MB SMALL;;;;\n33D5;SQUARE MIL;So;0;L;<square> 006D 0069 006C;;;;N;SQUARED MIL;;;;\n33D6;SQUARE MOL;So;0;L;<square> 006D 006F 006C;;;;N;SQUARED MOL;;;;\n33D7;SQUARE PH;So;0;L;<square> 0050 0048;;;;N;SQUARED PH;;;;\n33D8;SQUARE PM;So;0;L;<square> 0070 002E 006D 002E;;;;N;SQUARED PM;;;;\n33D9;SQUARE PPM;So;0;L;<square> 0050 0050 004D;;;;N;SQUARED PPM;;;;\n33DA;SQUARE PR;So;0;L;<square> 0050 0052;;;;N;SQUARED PR;;;;\n33DB;SQUARE SR;So;0;L;<square> 0073 0072;;;;N;SQUARED SR;;;;\n33DC;SQUARE SV;So;0;L;<square> 0053 0076;;;;N;SQUARED SV;;;;\n33DD;SQUARE WB;So;0;L;<square> 0057 0062;;;;N;SQUARED WB;;;;\n33DE;SQUARE V OVER M;So;0;ON;<square> 0056 2215 006D;;;;N;;;;;\n33DF;SQUARE A OVER M;So;0;ON;<square> 0041 2215 006D;;;;N;;;;;\n33E0;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY ONE;So;0;L;<compat> 0031 65E5;;;;N;;;;;\n33E1;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWO;So;0;L;<compat> 0032 65E5;;;;N;;;;;\n33E2;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY THREE;So;0;L;<compat> 0033 65E5;;;;N;;;;;\n33E3;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY FOUR;So;0;L;<compat> 0034 65E5;;;;N;;;;;\n33E4;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY FIVE;So;0;L;<compat> 0035 65E5;;;;N;;;;;\n33E5;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY SIX;So;0;L;<compat> 0036 65E5;;;;N;;;;;\n33E6;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY SEVEN;So;0;L;<compat> 0037 65E5;;;;N;;;;;\n33E7;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY EIGHT;So;0;L;<compat> 0038 65E5;;;;N;;;;;\n33E8;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY NINE;So;0;L;<compat> 0039 65E5;;;;N;;;;;\n33E9;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TEN;So;0;L;<compat> 0031 0030 65E5;;;;N;;;;;\n33EA;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY ELEVEN;So;0;L;<compat> 0031 0031 65E5;;;;N;;;;;\n33EB;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWELVE;So;0;L;<compat> 0031 0032 65E5;;;;N;;;;;\n33EC;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY THIRTEEN;So;0;L;<compat> 0031 0033 65E5;;;;N;;;;;\n33ED;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY FOURTEEN;So;0;L;<compat> 0031 0034 65E5;;;;N;;;;;\n33EE;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY FIFTEEN;So;0;L;<compat> 0031 0035 65E5;;;;N;;;;;\n33EF;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY SIXTEEN;So;0;L;<compat> 0031 0036 65E5;;;;N;;;;;\n33F0;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY SEVENTEEN;So;0;L;<compat> 0031 0037 65E5;;;;N;;;;;\n33F1;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY EIGHTEEN;So;0;L;<compat> 0031 0038 65E5;;;;N;;;;;\n33F2;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY NINETEEN;So;0;L;<compat> 0031 0039 65E5;;;;N;;;;;\n33F3;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY;So;0;L;<compat> 0032 0030 65E5;;;;N;;;;;\n33F4;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-ONE;So;0;L;<compat> 0032 0031 65E5;;;;N;;;;;\n33F5;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-TWO;So;0;L;<compat> 0032 0032 65E5;;;;N;;;;;\n33F6;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-THREE;So;0;L;<compat> 0032 0033 65E5;;;;N;;;;;\n33F7;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-FOUR;So;0;L;<compat> 0032 0034 65E5;;;;N;;;;;\n33F8;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-FIVE;So;0;L;<compat> 0032 0035 65E5;;;;N;;;;;\n33F9;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-SIX;So;0;L;<compat> 0032 0036 65E5;;;;N;;;;;\n33FA;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-SEVEN;So;0;L;<compat> 0032 0037 65E5;;;;N;;;;;\n33FB;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-EIGHT;So;0;L;<compat> 0032 0038 65E5;;;;N;;;;;\n33FC;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY TWENTY-NINE;So;0;L;<compat> 0032 0039 65E5;;;;N;;;;;\n33FD;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY THIRTY;So;0;L;<compat> 0033 0030 65E5;;;;N;;;;;\n33FE;IDEOGRAPHIC TELEGRAPH SYMBOL FOR DAY THIRTY-ONE;So;0;L;<compat> 0033 0031 65E5;;;;N;;;;;\n33FF;SQUARE GAL;So;0;ON;<square> 0067 0061 006C;;;;N;;;;;\n3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;\n4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;\n4DC0;HEXAGRAM FOR THE CREATIVE HEAVEN;So;0;ON;;;;;N;;;;;\n4DC1;HEXAGRAM FOR THE RECEPTIVE EARTH;So;0;ON;;;;;N;;;;;\n4DC2;HEXAGRAM FOR DIFFICULTY AT THE BEGINNING;So;0;ON;;;;;N;;;;;\n4DC3;HEXAGRAM FOR YOUTHFUL FOLLY;So;0;ON;;;;;N;;;;;\n4DC4;HEXAGRAM FOR WAITING;So;0;ON;;;;;N;;;;;\n4DC5;HEXAGRAM FOR CONFLICT;So;0;ON;;;;;N;;;;;\n4DC6;HEXAGRAM FOR THE ARMY;So;0;ON;;;;;N;;;;;\n4DC7;HEXAGRAM FOR HOLDING TOGETHER;So;0;ON;;;;;N;;;;;\n4DC8;HEXAGRAM FOR SMALL TAMING;So;0;ON;;;;;N;;;;;\n4DC9;HEXAGRAM FOR TREADING;So;0;ON;;;;;N;;;;;\n4DCA;HEXAGRAM FOR PEACE;So;0;ON;;;;;N;;;;;\n4DCB;HEXAGRAM FOR STANDSTILL;So;0;ON;;;;;N;;;;;\n4DCC;HEXAGRAM FOR FELLOWSHIP;So;0;ON;;;;;N;;;;;\n4DCD;HEXAGRAM FOR GREAT POSSESSION;So;0;ON;;;;;N;;;;;\n4DCE;HEXAGRAM FOR MODESTY;So;0;ON;;;;;N;;;;;\n4DCF;HEXAGRAM FOR ENTHUSIASM;So;0;ON;;;;;N;;;;;\n4DD0;HEXAGRAM FOR FOLLOWING;So;0;ON;;;;;N;;;;;\n4DD1;HEXAGRAM FOR WORK ON THE DECAYED;So;0;ON;;;;;N;;;;;\n4DD2;HEXAGRAM FOR APPROACH;So;0;ON;;;;;N;;;;;\n4DD3;HEXAGRAM FOR CONTEMPLATION;So;0;ON;;;;;N;;;;;\n4DD4;HEXAGRAM FOR BITING THROUGH;So;0;ON;;;;;N;;;;;\n4DD5;HEXAGRAM FOR GRACE;So;0;ON;;;;;N;;;;;\n4DD6;HEXAGRAM FOR SPLITTING APART;So;0;ON;;;;;N;;;;;\n4DD7;HEXAGRAM FOR RETURN;So;0;ON;;;;;N;;;;;\n4DD8;HEXAGRAM FOR INNOCENCE;So;0;ON;;;;;N;;;;;\n4DD9;HEXAGRAM FOR GREAT TAMING;So;0;ON;;;;;N;;;;;\n4DDA;HEXAGRAM FOR MOUTH CORNERS;So;0;ON;;;;;N;;;;;\n4DDB;HEXAGRAM FOR GREAT PREPONDERANCE;So;0;ON;;;;;N;;;;;\n4DDC;HEXAGRAM FOR THE ABYSMAL WATER;So;0;ON;;;;;N;;;;;\n4DDD;HEXAGRAM FOR THE CLINGING FIRE;So;0;ON;;;;;N;;;;;\n4DDE;HEXAGRAM FOR INFLUENCE;So;0;ON;;;;;N;;;;;\n4DDF;HEXAGRAM FOR DURATION;So;0;ON;;;;;N;;;;;\n4DE0;HEXAGRAM FOR RETREAT;So;0;ON;;;;;N;;;;;\n4DE1;HEXAGRAM FOR GREAT POWER;So;0;ON;;;;;N;;;;;\n4DE2;HEXAGRAM FOR PROGRESS;So;0;ON;;;;;N;;;;;\n4DE3;HEXAGRAM FOR DARKENING OF THE LIGHT;So;0;ON;;;;;N;;;;;\n4DE4;HEXAGRAM FOR THE FAMILY;So;0;ON;;;;;N;;;;;\n4DE5;HEXAGRAM FOR OPPOSITION;So;0;ON;;;;;N;;;;;\n4DE6;HEXAGRAM FOR OBSTRUCTION;So;0;ON;;;;;N;;;;;\n4DE7;HEXAGRAM FOR DELIVERANCE;So;0;ON;;;;;N;;;;;\n4DE8;HEXAGRAM FOR DECREASE;So;0;ON;;;;;N;;;;;\n4DE9;HEXAGRAM FOR INCREASE;So;0;ON;;;;;N;;;;;\n4DEA;HEXAGRAM FOR BREAKTHROUGH;So;0;ON;;;;;N;;;;;\n4DEB;HEXAGRAM FOR COMING TO MEET;So;0;ON;;;;;N;;;;;\n4DEC;HEXAGRAM FOR GATHERING TOGETHER;So;0;ON;;;;;N;;;;;\n4DED;HEXAGRAM FOR PUSHING UPWARD;So;0;ON;;;;;N;;;;;\n4DEE;HEXAGRAM FOR OPPRESSION;So;0;ON;;;;;N;;;;;\n4DEF;HEXAGRAM FOR THE WELL;So;0;ON;;;;;N;;;;;\n4DF0;HEXAGRAM FOR REVOLUTION;So;0;ON;;;;;N;;;;;\n4DF1;HEXAGRAM FOR THE CAULDRON;So;0;ON;;;;;N;;;;;\n4DF2;HEXAGRAM FOR THE AROUSING THUNDER;So;0;ON;;;;;N;;;;;\n4DF3;HEXAGRAM FOR THE KEEPING STILL MOUNTAIN;So;0;ON;;;;;N;;;;;\n4DF4;HEXAGRAM FOR DEVELOPMENT;So;0;ON;;;;;N;;;;;\n4DF5;HEXAGRAM FOR THE MARRYING MAIDEN;So;0;ON;;;;;N;;;;;\n4DF6;HEXAGRAM FOR ABUNDANCE;So;0;ON;;;;;N;;;;;\n4DF7;HEXAGRAM FOR THE WANDERER;So;0;ON;;;;;N;;;;;\n4DF8;HEXAGRAM FOR THE GENTLE WIND;So;0;ON;;;;;N;;;;;\n4DF9;HEXAGRAM FOR THE JOYOUS LAKE;So;0;ON;;;;;N;;;;;\n4DFA;HEXAGRAM FOR DISPERSION;So;0;ON;;;;;N;;;;;\n4DFB;HEXAGRAM FOR LIMITATION;So;0;ON;;;;;N;;;;;\n4DFC;HEXAGRAM FOR INNER TRUTH;So;0;ON;;;;;N;;;;;\n4DFD;HEXAGRAM FOR SMALL PREPONDERANCE;So;0;ON;;;;;N;;;;;\n4DFE;HEXAGRAM FOR AFTER COMPLETION;So;0;ON;;;;;N;;;;;\n4DFF;HEXAGRAM FOR BEFORE COMPLETION;So;0;ON;;;;;N;;;;;\n4E00;<CJK Ideograph, First>;Lo;0;L;;;;;N;;;;;\n9FCC;<CJK Ideograph, Last>;Lo;0;L;;;;;N;;;;;\nA000;YI SYLLABLE IT;Lo;0;L;;;;;N;;;;;\nA001;YI SYLLABLE IX;Lo;0;L;;;;;N;;;;;\nA002;YI SYLLABLE I;Lo;0;L;;;;;N;;;;;\nA003;YI SYLLABLE IP;Lo;0;L;;;;;N;;;;;\nA004;YI SYLLABLE IET;Lo;0;L;;;;;N;;;;;\nA005;YI SYLLABLE IEX;Lo;0;L;;;;;N;;;;;\nA006;YI SYLLABLE IE;Lo;0;L;;;;;N;;;;;\nA007;YI SYLLABLE IEP;Lo;0;L;;;;;N;;;;;\nA008;YI SYLLABLE AT;Lo;0;L;;;;;N;;;;;\nA009;YI SYLLABLE AX;Lo;0;L;;;;;N;;;;;\nA00A;YI SYLLABLE A;Lo;0;L;;;;;N;;;;;\nA00B;YI SYLLABLE AP;Lo;0;L;;;;;N;;;;;\nA00C;YI SYLLABLE UOX;Lo;0;L;;;;;N;;;;;\nA00D;YI SYLLABLE UO;Lo;0;L;;;;;N;;;;;\nA00E;YI SYLLABLE UOP;Lo;0;L;;;;;N;;;;;\nA00F;YI SYLLABLE OT;Lo;0;L;;;;;N;;;;;\nA010;YI SYLLABLE OX;Lo;0;L;;;;;N;;;;;\nA011;YI SYLLABLE O;Lo;0;L;;;;;N;;;;;\nA012;YI SYLLABLE OP;Lo;0;L;;;;;N;;;;;\nA013;YI SYLLABLE EX;Lo;0;L;;;;;N;;;;;\nA014;YI SYLLABLE E;Lo;0;L;;;;;N;;;;;\nA015;YI SYLLABLE WU;Lm;0;L;;;;;N;;;;;\nA016;YI SYLLABLE BIT;Lo;0;L;;;;;N;;;;;\nA017;YI SYLLABLE BIX;Lo;0;L;;;;;N;;;;;\nA018;YI SYLLABLE BI;Lo;0;L;;;;;N;;;;;\nA019;YI SYLLABLE BIP;Lo;0;L;;;;;N;;;;;\nA01A;YI SYLLABLE BIET;Lo;0;L;;;;;N;;;;;\nA01B;YI SYLLABLE BIEX;Lo;0;L;;;;;N;;;;;\nA01C;YI SYLLABLE BIE;Lo;0;L;;;;;N;;;;;\nA01D;YI SYLLABLE BIEP;Lo;0;L;;;;;N;;;;;\nA01E;YI SYLLABLE BAT;Lo;0;L;;;;;N;;;;;\nA01F;YI SYLLABLE BAX;Lo;0;L;;;;;N;;;;;\nA020;YI SYLLABLE BA;Lo;0;L;;;;;N;;;;;\nA021;YI SYLLABLE BAP;Lo;0;L;;;;;N;;;;;\nA022;YI SYLLABLE BUOX;Lo;0;L;;;;;N;;;;;\nA023;YI SYLLABLE BUO;Lo;0;L;;;;;N;;;;;\nA024;YI SYLLABLE BUOP;Lo;0;L;;;;;N;;;;;\nA025;YI SYLLABLE BOT;Lo;0;L;;;;;N;;;;;\nA026;YI SYLLABLE BOX;Lo;0;L;;;;;N;;;;;\nA027;YI SYLLABLE BO;Lo;0;L;;;;;N;;;;;\nA028;YI SYLLABLE BOP;Lo;0;L;;;;;N;;;;;\nA029;YI SYLLABLE BEX;Lo;0;L;;;;;N;;;;;\nA02A;YI SYLLABLE BE;Lo;0;L;;;;;N;;;;;\nA02B;YI SYLLABLE BEP;Lo;0;L;;;;;N;;;;;\nA02C;YI SYLLABLE BUT;Lo;0;L;;;;;N;;;;;\nA02D;YI SYLLABLE BUX;Lo;0;L;;;;;N;;;;;\nA02E;YI SYLLABLE BU;Lo;0;L;;;;;N;;;;;\nA02F;YI SYLLABLE BUP;Lo;0;L;;;;;N;;;;;\nA030;YI SYLLABLE BURX;Lo;0;L;;;;;N;;;;;\nA031;YI SYLLABLE BUR;Lo;0;L;;;;;N;;;;;\nA032;YI SYLLABLE BYT;Lo;0;L;;;;;N;;;;;\nA033;YI SYLLABLE BYX;Lo;0;L;;;;;N;;;;;\nA034;YI SYLLABLE BY;Lo;0;L;;;;;N;;;;;\nA035;YI SYLLABLE BYP;Lo;0;L;;;;;N;;;;;\nA036;YI SYLLABLE BYRX;Lo;0;L;;;;;N;;;;;\nA037;YI SYLLABLE BYR;Lo;0;L;;;;;N;;;;;\nA038;YI SYLLABLE PIT;Lo;0;L;;;;;N;;;;;\nA039;YI SYLLABLE PIX;Lo;0;L;;;;;N;;;;;\nA03A;YI SYLLABLE PI;Lo;0;L;;;;;N;;;;;\nA03B;YI SYLLABLE PIP;Lo;0;L;;;;;N;;;;;\nA03C;YI SYLLABLE PIEX;Lo;0;L;;;;;N;;;;;\nA03D;YI SYLLABLE PIE;Lo;0;L;;;;;N;;;;;\nA03E;YI SYLLABLE PIEP;Lo;0;L;;;;;N;;;;;\nA03F;YI SYLLABLE PAT;Lo;0;L;;;;;N;;;;;\nA040;YI SYLLABLE PAX;Lo;0;L;;;;;N;;;;;\nA041;YI SYLLABLE PA;Lo;0;L;;;;;N;;;;;\nA042;YI SYLLABLE PAP;Lo;0;L;;;;;N;;;;;\nA043;YI SYLLABLE PUOX;Lo;0;L;;;;;N;;;;;\nA044;YI SYLLABLE PUO;Lo;0;L;;;;;N;;;;;\nA045;YI SYLLABLE PUOP;Lo;0;L;;;;;N;;;;;\nA046;YI SYLLABLE POT;Lo;0;L;;;;;N;;;;;\nA047;YI SYLLABLE POX;Lo;0;L;;;;;N;;;;;\nA048;YI SYLLABLE PO;Lo;0;L;;;;;N;;;;;\nA049;YI SYLLABLE POP;Lo;0;L;;;;;N;;;;;\nA04A;YI SYLLABLE PUT;Lo;0;L;;;;;N;;;;;\nA04B;YI SYLLABLE PUX;Lo;0;L;;;;;N;;;;;\nA04C;YI SYLLABLE PU;Lo;0;L;;;;;N;;;;;\nA04D;YI SYLLABLE PUP;Lo;0;L;;;;;N;;;;;\nA04E;YI SYLLABLE PURX;Lo;0;L;;;;;N;;;;;\nA04F;YI SYLLABLE PUR;Lo;0;L;;;;;N;;;;;\nA050;YI SYLLABLE PYT;Lo;0;L;;;;;N;;;;;\nA051;YI SYLLABLE PYX;Lo;0;L;;;;;N;;;;;\nA052;YI SYLLABLE PY;Lo;0;L;;;;;N;;;;;\nA053;YI SYLLABLE PYP;Lo;0;L;;;;;N;;;;;\nA054;YI SYLLABLE PYRX;Lo;0;L;;;;;N;;;;;\nA055;YI SYLLABLE PYR;Lo;0;L;;;;;N;;;;;\nA056;YI SYLLABLE BBIT;Lo;0;L;;;;;N;;;;;\nA057;YI SYLLABLE BBIX;Lo;0;L;;;;;N;;;;;\nA058;YI SYLLABLE BBI;Lo;0;L;;;;;N;;;;;\nA059;YI SYLLABLE BBIP;Lo;0;L;;;;;N;;;;;\nA05A;YI SYLLABLE BBIET;Lo;0;L;;;;;N;;;;;\nA05B;YI SYLLABLE BBIEX;Lo;0;L;;;;;N;;;;;\nA05C;YI SYLLABLE BBIE;Lo;0;L;;;;;N;;;;;\nA05D;YI SYLLABLE BBIEP;Lo;0;L;;;;;N;;;;;\nA05E;YI SYLLABLE BBAT;Lo;0;L;;;;;N;;;;;\nA05F;YI SYLLABLE BBAX;Lo;0;L;;;;;N;;;;;\nA060;YI SYLLABLE BBA;Lo;0;L;;;;;N;;;;;\nA061;YI SYLLABLE BBAP;Lo;0;L;;;;;N;;;;;\nA062;YI SYLLABLE BBUOX;Lo;0;L;;;;;N;;;;;\nA063;YI SYLLABLE BBUO;Lo;0;L;;;;;N;;;;;\nA064;YI SYLLABLE BBUOP;Lo;0;L;;;;;N;;;;;\nA065;YI SYLLABLE BBOT;Lo;0;L;;;;;N;;;;;\nA066;YI SYLLABLE BBOX;Lo;0;L;;;;;N;;;;;\nA067;YI SYLLABLE BBO;Lo;0;L;;;;;N;;;;;\nA068;YI SYLLABLE BBOP;Lo;0;L;;;;;N;;;;;\nA069;YI SYLLABLE BBEX;Lo;0;L;;;;;N;;;;;\nA06A;YI SYLLABLE BBE;Lo;0;L;;;;;N;;;;;\nA06B;YI SYLLABLE BBEP;Lo;0;L;;;;;N;;;;;\nA06C;YI SYLLABLE BBUT;Lo;0;L;;;;;N;;;;;\nA06D;YI SYLLABLE BBUX;Lo;0;L;;;;;N;;;;;\nA06E;YI SYLLABLE BBU;Lo;0;L;;;;;N;;;;;\nA06F;YI SYLLABLE BBUP;Lo;0;L;;;;;N;;;;;\nA070;YI SYLLABLE BBURX;Lo;0;L;;;;;N;;;;;\nA071;YI SYLLABLE BBUR;Lo;0;L;;;;;N;;;;;\nA072;YI SYLLABLE BBYT;Lo;0;L;;;;;N;;;;;\nA073;YI SYLLABLE BBYX;Lo;0;L;;;;;N;;;;;\nA074;YI SYLLABLE BBY;Lo;0;L;;;;;N;;;;;\nA075;YI SYLLABLE BBYP;Lo;0;L;;;;;N;;;;;\nA076;YI SYLLABLE NBIT;Lo;0;L;;;;;N;;;;;\nA077;YI SYLLABLE NBIX;Lo;0;L;;;;;N;;;;;\nA078;YI SYLLABLE NBI;Lo;0;L;;;;;N;;;;;\nA079;YI SYLLABLE NBIP;Lo;0;L;;;;;N;;;;;\nA07A;YI SYLLABLE NBIEX;Lo;0;L;;;;;N;;;;;\nA07B;YI SYLLABLE NBIE;Lo;0;L;;;;;N;;;;;\nA07C;YI SYLLABLE NBIEP;Lo;0;L;;;;;N;;;;;\nA07D;YI SYLLABLE NBAT;Lo;0;L;;;;;N;;;;;\nA07E;YI SYLLABLE NBAX;Lo;0;L;;;;;N;;;;;\nA07F;YI SYLLABLE NBA;Lo;0;L;;;;;N;;;;;\nA080;YI SYLLABLE NBAP;Lo;0;L;;;;;N;;;;;\nA081;YI SYLLABLE NBOT;Lo;0;L;;;;;N;;;;;\nA082;YI SYLLABLE NBOX;Lo;0;L;;;;;N;;;;;\nA083;YI SYLLABLE NBO;Lo;0;L;;;;;N;;;;;\nA084;YI SYLLABLE NBOP;Lo;0;L;;;;;N;;;;;\nA085;YI SYLLABLE NBUT;Lo;0;L;;;;;N;;;;;\nA086;YI SYLLABLE NBUX;Lo;0;L;;;;;N;;;;;\nA087;YI SYLLABLE NBU;Lo;0;L;;;;;N;;;;;\nA088;YI SYLLABLE NBUP;Lo;0;L;;;;;N;;;;;\nA089;YI SYLLABLE NBURX;Lo;0;L;;;;;N;;;;;\nA08A;YI SYLLABLE NBUR;Lo;0;L;;;;;N;;;;;\nA08B;YI SYLLABLE NBYT;Lo;0;L;;;;;N;;;;;\nA08C;YI SYLLABLE NBYX;Lo;0;L;;;;;N;;;;;\nA08D;YI SYLLABLE NBY;Lo;0;L;;;;;N;;;;;\nA08E;YI SYLLABLE NBYP;Lo;0;L;;;;;N;;;;;\nA08F;YI SYLLABLE NBYRX;Lo;0;L;;;;;N;;;;;\nA090;YI SYLLABLE NBYR;Lo;0;L;;;;;N;;;;;\nA091;YI SYLLABLE HMIT;Lo;0;L;;;;;N;;;;;\nA092;YI SYLLABLE HMIX;Lo;0;L;;;;;N;;;;;\nA093;YI SYLLABLE HMI;Lo;0;L;;;;;N;;;;;\nA094;YI SYLLABLE HMIP;Lo;0;L;;;;;N;;;;;\nA095;YI SYLLABLE HMIEX;Lo;0;L;;;;;N;;;;;\nA096;YI SYLLABLE HMIE;Lo;0;L;;;;;N;;;;;\nA097;YI SYLLABLE HMIEP;Lo;0;L;;;;;N;;;;;\nA098;YI SYLLABLE HMAT;Lo;0;L;;;;;N;;;;;\nA099;YI SYLLABLE HMAX;Lo;0;L;;;;;N;;;;;\nA09A;YI SYLLABLE HMA;Lo;0;L;;;;;N;;;;;\nA09B;YI SYLLABLE HMAP;Lo;0;L;;;;;N;;;;;\nA09C;YI SYLLABLE HMUOX;Lo;0;L;;;;;N;;;;;\nA09D;YI SYLLABLE HMUO;Lo;0;L;;;;;N;;;;;\nA09E;YI SYLLABLE HMUOP;Lo;0;L;;;;;N;;;;;\nA09F;YI SYLLABLE HMOT;Lo;0;L;;;;;N;;;;;\nA0A0;YI SYLLABLE HMOX;Lo;0;L;;;;;N;;;;;\nA0A1;YI SYLLABLE HMO;Lo;0;L;;;;;N;;;;;\nA0A2;YI SYLLABLE HMOP;Lo;0;L;;;;;N;;;;;\nA0A3;YI SYLLABLE HMUT;Lo;0;L;;;;;N;;;;;\nA0A4;YI SYLLABLE HMUX;Lo;0;L;;;;;N;;;;;\nA0A5;YI SYLLABLE HMU;Lo;0;L;;;;;N;;;;;\nA0A6;YI SYLLABLE HMUP;Lo;0;L;;;;;N;;;;;\nA0A7;YI SYLLABLE HMURX;Lo;0;L;;;;;N;;;;;\nA0A8;YI SYLLABLE HMUR;Lo;0;L;;;;;N;;;;;\nA0A9;YI SYLLABLE HMYX;Lo;0;L;;;;;N;;;;;\nA0AA;YI SYLLABLE HMY;Lo;0;L;;;;;N;;;;;\nA0AB;YI SYLLABLE HMYP;Lo;0;L;;;;;N;;;;;\nA0AC;YI SYLLABLE HMYRX;Lo;0;L;;;;;N;;;;;\nA0AD;YI SYLLABLE HMYR;Lo;0;L;;;;;N;;;;;\nA0AE;YI SYLLABLE MIT;Lo;0;L;;;;;N;;;;;\nA0AF;YI SYLLABLE MIX;Lo;0;L;;;;;N;;;;;\nA0B0;YI SYLLABLE MI;Lo;0;L;;;;;N;;;;;\nA0B1;YI SYLLABLE MIP;Lo;0;L;;;;;N;;;;;\nA0B2;YI SYLLABLE MIEX;Lo;0;L;;;;;N;;;;;\nA0B3;YI SYLLABLE MIE;Lo;0;L;;;;;N;;;;;\nA0B4;YI SYLLABLE MIEP;Lo;0;L;;;;;N;;;;;\nA0B5;YI SYLLABLE MAT;Lo;0;L;;;;;N;;;;;\nA0B6;YI SYLLABLE MAX;Lo;0;L;;;;;N;;;;;\nA0B7;YI SYLLABLE MA;Lo;0;L;;;;;N;;;;;\nA0B8;YI SYLLABLE MAP;Lo;0;L;;;;;N;;;;;\nA0B9;YI SYLLABLE MUOT;Lo;0;L;;;;;N;;;;;\nA0BA;YI SYLLABLE MUOX;Lo;0;L;;;;;N;;;;;\nA0BB;YI SYLLABLE MUO;Lo;0;L;;;;;N;;;;;\nA0BC;YI SYLLABLE MUOP;Lo;0;L;;;;;N;;;;;\nA0BD;YI SYLLABLE MOT;Lo;0;L;;;;;N;;;;;\nA0BE;YI SYLLABLE MOX;Lo;0;L;;;;;N;;;;;\nA0BF;YI SYLLABLE MO;Lo;0;L;;;;;N;;;;;\nA0C0;YI SYLLABLE MOP;Lo;0;L;;;;;N;;;;;\nA0C1;YI SYLLABLE MEX;Lo;0;L;;;;;N;;;;;\nA0C2;YI SYLLABLE ME;Lo;0;L;;;;;N;;;;;\nA0C3;YI SYLLABLE MUT;Lo;0;L;;;;;N;;;;;\nA0C4;YI SYLLABLE MUX;Lo;0;L;;;;;N;;;;;\nA0C5;YI SYLLABLE MU;Lo;0;L;;;;;N;;;;;\nA0C6;YI SYLLABLE MUP;Lo;0;L;;;;;N;;;;;\nA0C7;YI SYLLABLE MURX;Lo;0;L;;;;;N;;;;;\nA0C8;YI SYLLABLE MUR;Lo;0;L;;;;;N;;;;;\nA0C9;YI SYLLABLE MYT;Lo;0;L;;;;;N;;;;;\nA0CA;YI SYLLABLE MYX;Lo;0;L;;;;;N;;;;;\nA0CB;YI SYLLABLE MY;Lo;0;L;;;;;N;;;;;\nA0CC;YI SYLLABLE MYP;Lo;0;L;;;;;N;;;;;\nA0CD;YI SYLLABLE FIT;Lo;0;L;;;;;N;;;;;\nA0CE;YI SYLLABLE FIX;Lo;0;L;;;;;N;;;;;\nA0CF;YI SYLLABLE FI;Lo;0;L;;;;;N;;;;;\nA0D0;YI SYLLABLE FIP;Lo;0;L;;;;;N;;;;;\nA0D1;YI SYLLABLE FAT;Lo;0;L;;;;;N;;;;;\nA0D2;YI SYLLABLE FAX;Lo;0;L;;;;;N;;;;;\nA0D3;YI SYLLABLE FA;Lo;0;L;;;;;N;;;;;\nA0D4;YI SYLLABLE FAP;Lo;0;L;;;;;N;;;;;\nA0D5;YI SYLLABLE FOX;Lo;0;L;;;;;N;;;;;\nA0D6;YI SYLLABLE FO;Lo;0;L;;;;;N;;;;;\nA0D7;YI SYLLABLE FOP;Lo;0;L;;;;;N;;;;;\nA0D8;YI SYLLABLE FUT;Lo;0;L;;;;;N;;;;;\nA0D9;YI SYLLABLE FUX;Lo;0;L;;;;;N;;;;;\nA0DA;YI SYLLABLE FU;Lo;0;L;;;;;N;;;;;\nA0DB;YI SYLLABLE FUP;Lo;0;L;;;;;N;;;;;\nA0DC;YI SYLLABLE FURX;Lo;0;L;;;;;N;;;;;\nA0DD;YI SYLLABLE FUR;Lo;0;L;;;;;N;;;;;\nA0DE;YI SYLLABLE FYT;Lo;0;L;;;;;N;;;;;\nA0DF;YI SYLLABLE FYX;Lo;0;L;;;;;N;;;;;\nA0E0;YI SYLLABLE FY;Lo;0;L;;;;;N;;;;;\nA0E1;YI SYLLABLE FYP;Lo;0;L;;;;;N;;;;;\nA0E2;YI SYLLABLE VIT;Lo;0;L;;;;;N;;;;;\nA0E3;YI SYLLABLE VIX;Lo;0;L;;;;;N;;;;;\nA0E4;YI SYLLABLE VI;Lo;0;L;;;;;N;;;;;\nA0E5;YI SYLLABLE VIP;Lo;0;L;;;;;N;;;;;\nA0E6;YI SYLLABLE VIET;Lo;0;L;;;;;N;;;;;\nA0E7;YI SYLLABLE VIEX;Lo;0;L;;;;;N;;;;;\nA0E8;YI SYLLABLE VIE;Lo;0;L;;;;;N;;;;;\nA0E9;YI SYLLABLE VIEP;Lo;0;L;;;;;N;;;;;\nA0EA;YI SYLLABLE VAT;Lo;0;L;;;;;N;;;;;\nA0EB;YI SYLLABLE VAX;Lo;0;L;;;;;N;;;;;\nA0EC;YI SYLLABLE VA;Lo;0;L;;;;;N;;;;;\nA0ED;YI SYLLABLE VAP;Lo;0;L;;;;;N;;;;;\nA0EE;YI SYLLABLE VOT;Lo;0;L;;;;;N;;;;;\nA0EF;YI SYLLABLE VOX;Lo;0;L;;;;;N;;;;;\nA0F0;YI SYLLABLE VO;Lo;0;L;;;;;N;;;;;\nA0F1;YI SYLLABLE VOP;Lo;0;L;;;;;N;;;;;\nA0F2;YI SYLLABLE VEX;Lo;0;L;;;;;N;;;;;\nA0F3;YI SYLLABLE VEP;Lo;0;L;;;;;N;;;;;\nA0F4;YI SYLLABLE VUT;Lo;0;L;;;;;N;;;;;\nA0F5;YI SYLLABLE VUX;Lo;0;L;;;;;N;;;;;\nA0F6;YI SYLLABLE VU;Lo;0;L;;;;;N;;;;;\nA0F7;YI SYLLABLE VUP;Lo;0;L;;;;;N;;;;;\nA0F8;YI SYLLABLE VURX;Lo;0;L;;;;;N;;;;;\nA0F9;YI SYLLABLE VUR;Lo;0;L;;;;;N;;;;;\nA0FA;YI SYLLABLE VYT;Lo;0;L;;;;;N;;;;;\nA0FB;YI SYLLABLE VYX;Lo;0;L;;;;;N;;;;;\nA0FC;YI SYLLABLE VY;Lo;0;L;;;;;N;;;;;\nA0FD;YI SYLLABLE VYP;Lo;0;L;;;;;N;;;;;\nA0FE;YI SYLLABLE VYRX;Lo;0;L;;;;;N;;;;;\nA0FF;YI SYLLABLE VYR;Lo;0;L;;;;;N;;;;;\nA100;YI SYLLABLE DIT;Lo;0;L;;;;;N;;;;;\nA101;YI SYLLABLE DIX;Lo;0;L;;;;;N;;;;;\nA102;YI SYLLABLE DI;Lo;0;L;;;;;N;;;;;\nA103;YI SYLLABLE DIP;Lo;0;L;;;;;N;;;;;\nA104;YI SYLLABLE DIEX;Lo;0;L;;;;;N;;;;;\nA105;YI SYLLABLE DIE;Lo;0;L;;;;;N;;;;;\nA106;YI SYLLABLE DIEP;Lo;0;L;;;;;N;;;;;\nA107;YI SYLLABLE DAT;Lo;0;L;;;;;N;;;;;\nA108;YI SYLLABLE DAX;Lo;0;L;;;;;N;;;;;\nA109;YI SYLLABLE DA;Lo;0;L;;;;;N;;;;;\nA10A;YI SYLLABLE DAP;Lo;0;L;;;;;N;;;;;\nA10B;YI SYLLABLE DUOX;Lo;0;L;;;;;N;;;;;\nA10C;YI SYLLABLE DUO;Lo;0;L;;;;;N;;;;;\nA10D;YI SYLLABLE DOT;Lo;0;L;;;;;N;;;;;\nA10E;YI SYLLABLE DOX;Lo;0;L;;;;;N;;;;;\nA10F;YI SYLLABLE DO;Lo;0;L;;;;;N;;;;;\nA110;YI SYLLABLE DOP;Lo;0;L;;;;;N;;;;;\nA111;YI SYLLABLE DEX;Lo;0;L;;;;;N;;;;;\nA112;YI SYLLABLE DE;Lo;0;L;;;;;N;;;;;\nA113;YI SYLLABLE DEP;Lo;0;L;;;;;N;;;;;\nA114;YI SYLLABLE DUT;Lo;0;L;;;;;N;;;;;\nA115;YI SYLLABLE DUX;Lo;0;L;;;;;N;;;;;\nA116;YI SYLLABLE DU;Lo;0;L;;;;;N;;;;;\nA117;YI SYLLABLE DUP;Lo;0;L;;;;;N;;;;;\nA118;YI SYLLABLE DURX;Lo;0;L;;;;;N;;;;;\nA119;YI SYLLABLE DUR;Lo;0;L;;;;;N;;;;;\nA11A;YI SYLLABLE TIT;Lo;0;L;;;;;N;;;;;\nA11B;YI SYLLABLE TIX;Lo;0;L;;;;;N;;;;;\nA11C;YI SYLLABLE TI;Lo;0;L;;;;;N;;;;;\nA11D;YI SYLLABLE TIP;Lo;0;L;;;;;N;;;;;\nA11E;YI SYLLABLE TIEX;Lo;0;L;;;;;N;;;;;\nA11F;YI SYLLABLE TIE;Lo;0;L;;;;;N;;;;;\nA120;YI SYLLABLE TIEP;Lo;0;L;;;;;N;;;;;\nA121;YI SYLLABLE TAT;Lo;0;L;;;;;N;;;;;\nA122;YI SYLLABLE TAX;Lo;0;L;;;;;N;;;;;\nA123;YI SYLLABLE TA;Lo;0;L;;;;;N;;;;;\nA124;YI SYLLABLE TAP;Lo;0;L;;;;;N;;;;;\nA125;YI SYLLABLE TUOT;Lo;0;L;;;;;N;;;;;\nA126;YI SYLLABLE TUOX;Lo;0;L;;;;;N;;;;;\nA127;YI SYLLABLE TUO;Lo;0;L;;;;;N;;;;;\nA128;YI SYLLABLE TUOP;Lo;0;L;;;;;N;;;;;\nA129;YI SYLLABLE TOT;Lo;0;L;;;;;N;;;;;\nA12A;YI SYLLABLE TOX;Lo;0;L;;;;;N;;;;;\nA12B;YI SYLLABLE TO;Lo;0;L;;;;;N;;;;;\nA12C;YI SYLLABLE TOP;Lo;0;L;;;;;N;;;;;\nA12D;YI SYLLABLE TEX;Lo;0;L;;;;;N;;;;;\nA12E;YI SYLLABLE TE;Lo;0;L;;;;;N;;;;;\nA12F;YI SYLLABLE TEP;Lo;0;L;;;;;N;;;;;\nA130;YI SYLLABLE TUT;Lo;0;L;;;;;N;;;;;\nA131;YI SYLLABLE TUX;Lo;0;L;;;;;N;;;;;\nA132;YI SYLLABLE TU;Lo;0;L;;;;;N;;;;;\nA133;YI SYLLABLE TUP;Lo;0;L;;;;;N;;;;;\nA134;YI SYLLABLE TURX;Lo;0;L;;;;;N;;;;;\nA135;YI SYLLABLE TUR;Lo;0;L;;;;;N;;;;;\nA136;YI SYLLABLE DDIT;Lo;0;L;;;;;N;;;;;\nA137;YI SYLLABLE DDIX;Lo;0;L;;;;;N;;;;;\nA138;YI SYLLABLE DDI;Lo;0;L;;;;;N;;;;;\nA139;YI SYLLABLE DDIP;Lo;0;L;;;;;N;;;;;\nA13A;YI SYLLABLE DDIEX;Lo;0;L;;;;;N;;;;;\nA13B;YI SYLLABLE DDIE;Lo;0;L;;;;;N;;;;;\nA13C;YI SYLLABLE DDIEP;Lo;0;L;;;;;N;;;;;\nA13D;YI SYLLABLE DDAT;Lo;0;L;;;;;N;;;;;\nA13E;YI SYLLABLE DDAX;Lo;0;L;;;;;N;;;;;\nA13F;YI SYLLABLE DDA;Lo;0;L;;;;;N;;;;;\nA140;YI SYLLABLE DDAP;Lo;0;L;;;;;N;;;;;\nA141;YI SYLLABLE DDUOX;Lo;0;L;;;;;N;;;;;\nA142;YI SYLLABLE DDUO;Lo;0;L;;;;;N;;;;;\nA143;YI SYLLABLE DDUOP;Lo;0;L;;;;;N;;;;;\nA144;YI SYLLABLE DDOT;Lo;0;L;;;;;N;;;;;\nA145;YI SYLLABLE DDOX;Lo;0;L;;;;;N;;;;;\nA146;YI SYLLABLE DDO;Lo;0;L;;;;;N;;;;;\nA147;YI SYLLABLE DDOP;Lo;0;L;;;;;N;;;;;\nA148;YI SYLLABLE DDEX;Lo;0;L;;;;;N;;;;;\nA149;YI SYLLABLE DDE;Lo;0;L;;;;;N;;;;;\nA14A;YI SYLLABLE DDEP;Lo;0;L;;;;;N;;;;;\nA14B;YI SYLLABLE DDUT;Lo;0;L;;;;;N;;;;;\nA14C;YI SYLLABLE DDUX;Lo;0;L;;;;;N;;;;;\nA14D;YI SYLLABLE DDU;Lo;0;L;;;;;N;;;;;\nA14E;YI SYLLABLE DDUP;Lo;0;L;;;;;N;;;;;\nA14F;YI SYLLABLE DDURX;Lo;0;L;;;;;N;;;;;\nA150;YI SYLLABLE DDUR;Lo;0;L;;;;;N;;;;;\nA151;YI SYLLABLE NDIT;Lo;0;L;;;;;N;;;;;\nA152;YI SYLLABLE NDIX;Lo;0;L;;;;;N;;;;;\nA153;YI SYLLABLE NDI;Lo;0;L;;;;;N;;;;;\nA154;YI SYLLABLE NDIP;Lo;0;L;;;;;N;;;;;\nA155;YI SYLLABLE NDIEX;Lo;0;L;;;;;N;;;;;\nA156;YI SYLLABLE NDIE;Lo;0;L;;;;;N;;;;;\nA157;YI SYLLABLE NDAT;Lo;0;L;;;;;N;;;;;\nA158;YI SYLLABLE NDAX;Lo;0;L;;;;;N;;;;;\nA159;YI SYLLABLE NDA;Lo;0;L;;;;;N;;;;;\nA15A;YI SYLLABLE NDAP;Lo;0;L;;;;;N;;;;;\nA15B;YI SYLLABLE NDOT;Lo;0;L;;;;;N;;;;;\nA15C;YI SYLLABLE NDOX;Lo;0;L;;;;;N;;;;;\nA15D;YI SYLLABLE NDO;Lo;0;L;;;;;N;;;;;\nA15E;YI SYLLABLE NDOP;Lo;0;L;;;;;N;;;;;\nA15F;YI SYLLABLE NDEX;Lo;0;L;;;;;N;;;;;\nA160;YI SYLLABLE NDE;Lo;0;L;;;;;N;;;;;\nA161;YI SYLLABLE NDEP;Lo;0;L;;;;;N;;;;;\nA162;YI SYLLABLE NDUT;Lo;0;L;;;;;N;;;;;\nA163;YI SYLLABLE NDUX;Lo;0;L;;;;;N;;;;;\nA164;YI SYLLABLE NDU;Lo;0;L;;;;;N;;;;;\nA165;YI SYLLABLE NDUP;Lo;0;L;;;;;N;;;;;\nA166;YI SYLLABLE NDURX;Lo;0;L;;;;;N;;;;;\nA167;YI SYLLABLE NDUR;Lo;0;L;;;;;N;;;;;\nA168;YI SYLLABLE HNIT;Lo;0;L;;;;;N;;;;;\nA169;YI SYLLABLE HNIX;Lo;0;L;;;;;N;;;;;\nA16A;YI SYLLABLE HNI;Lo;0;L;;;;;N;;;;;\nA16B;YI SYLLABLE HNIP;Lo;0;L;;;;;N;;;;;\nA16C;YI SYLLABLE HNIET;Lo;0;L;;;;;N;;;;;\nA16D;YI SYLLABLE HNIEX;Lo;0;L;;;;;N;;;;;\nA16E;YI SYLLABLE HNIE;Lo;0;L;;;;;N;;;;;\nA16F;YI SYLLABLE HNIEP;Lo;0;L;;;;;N;;;;;\nA170;YI SYLLABLE HNAT;Lo;0;L;;;;;N;;;;;\nA171;YI SYLLABLE HNAX;Lo;0;L;;;;;N;;;;;\nA172;YI SYLLABLE HNA;Lo;0;L;;;;;N;;;;;\nA173;YI SYLLABLE HNAP;Lo;0;L;;;;;N;;;;;\nA174;YI SYLLABLE HNUOX;Lo;0;L;;;;;N;;;;;\nA175;YI SYLLABLE HNUO;Lo;0;L;;;;;N;;;;;\nA176;YI SYLLABLE HNOT;Lo;0;L;;;;;N;;;;;\nA177;YI SYLLABLE HNOX;Lo;0;L;;;;;N;;;;;\nA178;YI SYLLABLE HNOP;Lo;0;L;;;;;N;;;;;\nA179;YI SYLLABLE HNEX;Lo;0;L;;;;;N;;;;;\nA17A;YI SYLLABLE HNE;Lo;0;L;;;;;N;;;;;\nA17B;YI SYLLABLE HNEP;Lo;0;L;;;;;N;;;;;\nA17C;YI SYLLABLE HNUT;Lo;0;L;;;;;N;;;;;\nA17D;YI SYLLABLE NIT;Lo;0;L;;;;;N;;;;;\nA17E;YI SYLLABLE NIX;Lo;0;L;;;;;N;;;;;\nA17F;YI SYLLABLE NI;Lo;0;L;;;;;N;;;;;\nA180;YI SYLLABLE NIP;Lo;0;L;;;;;N;;;;;\nA181;YI SYLLABLE NIEX;Lo;0;L;;;;;N;;;;;\nA182;YI SYLLABLE NIE;Lo;0;L;;;;;N;;;;;\nA183;YI SYLLABLE NIEP;Lo;0;L;;;;;N;;;;;\nA184;YI SYLLABLE NAX;Lo;0;L;;;;;N;;;;;\nA185;YI SYLLABLE NA;Lo;0;L;;;;;N;;;;;\nA186;YI SYLLABLE NAP;Lo;0;L;;;;;N;;;;;\nA187;YI SYLLABLE NUOX;Lo;0;L;;;;;N;;;;;\nA188;YI SYLLABLE NUO;Lo;0;L;;;;;N;;;;;\nA189;YI SYLLABLE NUOP;Lo;0;L;;;;;N;;;;;\nA18A;YI SYLLABLE NOT;Lo;0;L;;;;;N;;;;;\nA18B;YI SYLLABLE NOX;Lo;0;L;;;;;N;;;;;\nA18C;YI SYLLABLE NO;Lo;0;L;;;;;N;;;;;\nA18D;YI SYLLABLE NOP;Lo;0;L;;;;;N;;;;;\nA18E;YI SYLLABLE NEX;Lo;0;L;;;;;N;;;;;\nA18F;YI SYLLABLE NE;Lo;0;L;;;;;N;;;;;\nA190;YI SYLLABLE NEP;Lo;0;L;;;;;N;;;;;\nA191;YI SYLLABLE NUT;Lo;0;L;;;;;N;;;;;\nA192;YI SYLLABLE NUX;Lo;0;L;;;;;N;;;;;\nA193;YI SYLLABLE NU;Lo;0;L;;;;;N;;;;;\nA194;YI SYLLABLE NUP;Lo;0;L;;;;;N;;;;;\nA195;YI SYLLABLE NURX;Lo;0;L;;;;;N;;;;;\nA196;YI SYLLABLE NUR;Lo;0;L;;;;;N;;;;;\nA197;YI SYLLABLE HLIT;Lo;0;L;;;;;N;;;;;\nA198;YI SYLLABLE HLIX;Lo;0;L;;;;;N;;;;;\nA199;YI SYLLABLE HLI;Lo;0;L;;;;;N;;;;;\nA19A;YI SYLLABLE HLIP;Lo;0;L;;;;;N;;;;;\nA19B;YI SYLLABLE HLIEX;Lo;0;L;;;;;N;;;;;\nA19C;YI SYLLABLE HLIE;Lo;0;L;;;;;N;;;;;\nA19D;YI SYLLABLE HLIEP;Lo;0;L;;;;;N;;;;;\nA19E;YI SYLLABLE HLAT;Lo;0;L;;;;;N;;;;;\nA19F;YI SYLLABLE HLAX;Lo;0;L;;;;;N;;;;;\nA1A0;YI SYLLABLE HLA;Lo;0;L;;;;;N;;;;;\nA1A1;YI SYLLABLE HLAP;Lo;0;L;;;;;N;;;;;\nA1A2;YI SYLLABLE HLUOX;Lo;0;L;;;;;N;;;;;\nA1A3;YI SYLLABLE HLUO;Lo;0;L;;;;;N;;;;;\nA1A4;YI SYLLABLE HLUOP;Lo;0;L;;;;;N;;;;;\nA1A5;YI SYLLABLE HLOX;Lo;0;L;;;;;N;;;;;\nA1A6;YI SYLLABLE HLO;Lo;0;L;;;;;N;;;;;\nA1A7;YI SYLLABLE HLOP;Lo;0;L;;;;;N;;;;;\nA1A8;YI SYLLABLE HLEX;Lo;0;L;;;;;N;;;;;\nA1A9;YI SYLLABLE HLE;Lo;0;L;;;;;N;;;;;\nA1AA;YI SYLLABLE HLEP;Lo;0;L;;;;;N;;;;;\nA1AB;YI SYLLABLE HLUT;Lo;0;L;;;;;N;;;;;\nA1AC;YI SYLLABLE HLUX;Lo;0;L;;;;;N;;;;;\nA1AD;YI SYLLABLE HLU;Lo;0;L;;;;;N;;;;;\nA1AE;YI SYLLABLE HLUP;Lo;0;L;;;;;N;;;;;\nA1AF;YI SYLLABLE HLURX;Lo;0;L;;;;;N;;;;;\nA1B0;YI SYLLABLE HLUR;Lo;0;L;;;;;N;;;;;\nA1B1;YI SYLLABLE HLYT;Lo;0;L;;;;;N;;;;;\nA1B2;YI SYLLABLE HLYX;Lo;0;L;;;;;N;;;;;\nA1B3;YI SYLLABLE HLY;Lo;0;L;;;;;N;;;;;\nA1B4;YI SYLLABLE HLYP;Lo;0;L;;;;;N;;;;;\nA1B5;YI SYLLABLE HLYRX;Lo;0;L;;;;;N;;;;;\nA1B6;YI SYLLABLE HLYR;Lo;0;L;;;;;N;;;;;\nA1B7;YI SYLLABLE LIT;Lo;0;L;;;;;N;;;;;\nA1B8;YI SYLLABLE LIX;Lo;0;L;;;;;N;;;;;\nA1B9;YI SYLLABLE LI;Lo;0;L;;;;;N;;;;;\nA1BA;YI SYLLABLE LIP;Lo;0;L;;;;;N;;;;;\nA1BB;YI SYLLABLE LIET;Lo;0;L;;;;;N;;;;;\nA1BC;YI SYLLABLE LIEX;Lo;0;L;;;;;N;;;;;\nA1BD;YI SYLLABLE LIE;Lo;0;L;;;;;N;;;;;\nA1BE;YI SYLLABLE LIEP;Lo;0;L;;;;;N;;;;;\nA1BF;YI SYLLABLE LAT;Lo;0;L;;;;;N;;;;;\nA1C0;YI SYLLABLE LAX;Lo;0;L;;;;;N;;;;;\nA1C1;YI SYLLABLE LA;Lo;0;L;;;;;N;;;;;\nA1C2;YI SYLLABLE LAP;Lo;0;L;;;;;N;;;;;\nA1C3;YI SYLLABLE LUOT;Lo;0;L;;;;;N;;;;;\nA1C4;YI SYLLABLE LUOX;Lo;0;L;;;;;N;;;;;\nA1C5;YI SYLLABLE LUO;Lo;0;L;;;;;N;;;;;\nA1C6;YI SYLLABLE LUOP;Lo;0;L;;;;;N;;;;;\nA1C7;YI SYLLABLE LOT;Lo;0;L;;;;;N;;;;;\nA1C8;YI SYLLABLE LOX;Lo;0;L;;;;;N;;;;;\nA1C9;YI SYLLABLE LO;Lo;0;L;;;;;N;;;;;\nA1CA;YI SYLLABLE LOP;Lo;0;L;;;;;N;;;;;\nA1CB;YI SYLLABLE LEX;Lo;0;L;;;;;N;;;;;\nA1CC;YI SYLLABLE LE;Lo;0;L;;;;;N;;;;;\nA1CD;YI SYLLABLE LEP;Lo;0;L;;;;;N;;;;;\nA1CE;YI SYLLABLE LUT;Lo;0;L;;;;;N;;;;;\nA1CF;YI SYLLABLE LUX;Lo;0;L;;;;;N;;;;;\nA1D0;YI SYLLABLE LU;Lo;0;L;;;;;N;;;;;\nA1D1;YI SYLLABLE LUP;Lo;0;L;;;;;N;;;;;\nA1D2;YI SYLLABLE LURX;Lo;0;L;;;;;N;;;;;\nA1D3;YI SYLLABLE LUR;Lo;0;L;;;;;N;;;;;\nA1D4;YI SYLLABLE LYT;Lo;0;L;;;;;N;;;;;\nA1D5;YI SYLLABLE LYX;Lo;0;L;;;;;N;;;;;\nA1D6;YI SYLLABLE LY;Lo;0;L;;;;;N;;;;;\nA1D7;YI SYLLABLE LYP;Lo;0;L;;;;;N;;;;;\nA1D8;YI SYLLABLE LYRX;Lo;0;L;;;;;N;;;;;\nA1D9;YI SYLLABLE LYR;Lo;0;L;;;;;N;;;;;\nA1DA;YI SYLLABLE GIT;Lo;0;L;;;;;N;;;;;\nA1DB;YI SYLLABLE GIX;Lo;0;L;;;;;N;;;;;\nA1DC;YI SYLLABLE GI;Lo;0;L;;;;;N;;;;;\nA1DD;YI SYLLABLE GIP;Lo;0;L;;;;;N;;;;;\nA1DE;YI SYLLABLE GIET;Lo;0;L;;;;;N;;;;;\nA1DF;YI SYLLABLE GIEX;Lo;0;L;;;;;N;;;;;\nA1E0;YI SYLLABLE GIE;Lo;0;L;;;;;N;;;;;\nA1E1;YI SYLLABLE GIEP;Lo;0;L;;;;;N;;;;;\nA1E2;YI SYLLABLE GAT;Lo;0;L;;;;;N;;;;;\nA1E3;YI SYLLABLE GAX;Lo;0;L;;;;;N;;;;;\nA1E4;YI SYLLABLE GA;Lo;0;L;;;;;N;;;;;\nA1E5;YI SYLLABLE GAP;Lo;0;L;;;;;N;;;;;\nA1E6;YI SYLLABLE GUOT;Lo;0;L;;;;;N;;;;;\nA1E7;YI SYLLABLE GUOX;Lo;0;L;;;;;N;;;;;\nA1E8;YI SYLLABLE GUO;Lo;0;L;;;;;N;;;;;\nA1E9;YI SYLLABLE GUOP;Lo;0;L;;;;;N;;;;;\nA1EA;YI SYLLABLE GOT;Lo;0;L;;;;;N;;;;;\nA1EB;YI SYLLABLE GOX;Lo;0;L;;;;;N;;;;;\nA1EC;YI SYLLABLE GO;Lo;0;L;;;;;N;;;;;\nA1ED;YI SYLLABLE GOP;Lo;0;L;;;;;N;;;;;\nA1EE;YI SYLLABLE GET;Lo;0;L;;;;;N;;;;;\nA1EF;YI SYLLABLE GEX;Lo;0;L;;;;;N;;;;;\nA1F0;YI SYLLABLE GE;Lo;0;L;;;;;N;;;;;\nA1F1;YI SYLLABLE GEP;Lo;0;L;;;;;N;;;;;\nA1F2;YI SYLLABLE GUT;Lo;0;L;;;;;N;;;;;\nA1F3;YI SYLLABLE GUX;Lo;0;L;;;;;N;;;;;\nA1F4;YI SYLLABLE GU;Lo;0;L;;;;;N;;;;;\nA1F5;YI SYLLABLE GUP;Lo;0;L;;;;;N;;;;;\nA1F6;YI SYLLABLE GURX;Lo;0;L;;;;;N;;;;;\nA1F7;YI SYLLABLE GUR;Lo;0;L;;;;;N;;;;;\nA1F8;YI SYLLABLE KIT;Lo;0;L;;;;;N;;;;;\nA1F9;YI SYLLABLE KIX;Lo;0;L;;;;;N;;;;;\nA1FA;YI SYLLABLE KI;Lo;0;L;;;;;N;;;;;\nA1FB;YI SYLLABLE KIP;Lo;0;L;;;;;N;;;;;\nA1FC;YI SYLLABLE KIEX;Lo;0;L;;;;;N;;;;;\nA1FD;YI SYLLABLE KIE;Lo;0;L;;;;;N;;;;;\nA1FE;YI SYLLABLE KIEP;Lo;0;L;;;;;N;;;;;\nA1FF;YI SYLLABLE KAT;Lo;0;L;;;;;N;;;;;\nA200;YI SYLLABLE KAX;Lo;0;L;;;;;N;;;;;\nA201;YI SYLLABLE KA;Lo;0;L;;;;;N;;;;;\nA202;YI SYLLABLE KAP;Lo;0;L;;;;;N;;;;;\nA203;YI SYLLABLE KUOX;Lo;0;L;;;;;N;;;;;\nA204;YI SYLLABLE KUO;Lo;0;L;;;;;N;;;;;\nA205;YI SYLLABLE KUOP;Lo;0;L;;;;;N;;;;;\nA206;YI SYLLABLE KOT;Lo;0;L;;;;;N;;;;;\nA207;YI SYLLABLE KOX;Lo;0;L;;;;;N;;;;;\nA208;YI SYLLABLE KO;Lo;0;L;;;;;N;;;;;\nA209;YI SYLLABLE KOP;Lo;0;L;;;;;N;;;;;\nA20A;YI SYLLABLE KET;Lo;0;L;;;;;N;;;;;\nA20B;YI SYLLABLE KEX;Lo;0;L;;;;;N;;;;;\nA20C;YI SYLLABLE KE;Lo;0;L;;;;;N;;;;;\nA20D;YI SYLLABLE KEP;Lo;0;L;;;;;N;;;;;\nA20E;YI SYLLABLE KUT;Lo;0;L;;;;;N;;;;;\nA20F;YI SYLLABLE KUX;Lo;0;L;;;;;N;;;;;\nA210;YI SYLLABLE KU;Lo;0;L;;;;;N;;;;;\nA211;YI SYLLABLE KUP;Lo;0;L;;;;;N;;;;;\nA212;YI SYLLABLE KURX;Lo;0;L;;;;;N;;;;;\nA213;YI SYLLABLE KUR;Lo;0;L;;;;;N;;;;;\nA214;YI SYLLABLE GGIT;Lo;0;L;;;;;N;;;;;\nA215;YI SYLLABLE GGIX;Lo;0;L;;;;;N;;;;;\nA216;YI SYLLABLE GGI;Lo;0;L;;;;;N;;;;;\nA217;YI SYLLABLE GGIEX;Lo;0;L;;;;;N;;;;;\nA218;YI SYLLABLE GGIE;Lo;0;L;;;;;N;;;;;\nA219;YI SYLLABLE GGIEP;Lo;0;L;;;;;N;;;;;\nA21A;YI SYLLABLE GGAT;Lo;0;L;;;;;N;;;;;\nA21B;YI SYLLABLE GGAX;Lo;0;L;;;;;N;;;;;\nA21C;YI SYLLABLE GGA;Lo;0;L;;;;;N;;;;;\nA21D;YI SYLLABLE GGAP;Lo;0;L;;;;;N;;;;;\nA21E;YI SYLLABLE GGUOT;Lo;0;L;;;;;N;;;;;\nA21F;YI SYLLABLE GGUOX;Lo;0;L;;;;;N;;;;;\nA220;YI SYLLABLE GGUO;Lo;0;L;;;;;N;;;;;\nA221;YI SYLLABLE GGUOP;Lo;0;L;;;;;N;;;;;\nA222;YI SYLLABLE GGOT;Lo;0;L;;;;;N;;;;;\nA223;YI SYLLABLE GGOX;Lo;0;L;;;;;N;;;;;\nA224;YI SYLLABLE GGO;Lo;0;L;;;;;N;;;;;\nA225;YI SYLLABLE GGOP;Lo;0;L;;;;;N;;;;;\nA226;YI SYLLABLE GGET;Lo;0;L;;;;;N;;;;;\nA227;YI SYLLABLE GGEX;Lo;0;L;;;;;N;;;;;\nA228;YI SYLLABLE GGE;Lo;0;L;;;;;N;;;;;\nA229;YI SYLLABLE GGEP;Lo;0;L;;;;;N;;;;;\nA22A;YI SYLLABLE GGUT;Lo;0;L;;;;;N;;;;;\nA22B;YI SYLLABLE GGUX;Lo;0;L;;;;;N;;;;;\nA22C;YI SYLLABLE GGU;Lo;0;L;;;;;N;;;;;\nA22D;YI SYLLABLE GGUP;Lo;0;L;;;;;N;;;;;\nA22E;YI SYLLABLE GGURX;Lo;0;L;;;;;N;;;;;\nA22F;YI SYLLABLE GGUR;Lo;0;L;;;;;N;;;;;\nA230;YI SYLLABLE MGIEX;Lo;0;L;;;;;N;;;;;\nA231;YI SYLLABLE MGIE;Lo;0;L;;;;;N;;;;;\nA232;YI SYLLABLE MGAT;Lo;0;L;;;;;N;;;;;\nA233;YI SYLLABLE MGAX;Lo;0;L;;;;;N;;;;;\nA234;YI SYLLABLE MGA;Lo;0;L;;;;;N;;;;;\nA235;YI SYLLABLE MGAP;Lo;0;L;;;;;N;;;;;\nA236;YI SYLLABLE MGUOX;Lo;0;L;;;;;N;;;;;\nA237;YI SYLLABLE MGUO;Lo;0;L;;;;;N;;;;;\nA238;YI SYLLABLE MGUOP;Lo;0;L;;;;;N;;;;;\nA239;YI SYLLABLE MGOT;Lo;0;L;;;;;N;;;;;\nA23A;YI SYLLABLE MGOX;Lo;0;L;;;;;N;;;;;\nA23B;YI SYLLABLE MGO;Lo;0;L;;;;;N;;;;;\nA23C;YI SYLLABLE MGOP;Lo;0;L;;;;;N;;;;;\nA23D;YI SYLLABLE MGEX;Lo;0;L;;;;;N;;;;;\nA23E;YI SYLLABLE MGE;Lo;0;L;;;;;N;;;;;\nA23F;YI SYLLABLE MGEP;Lo;0;L;;;;;N;;;;;\nA240;YI SYLLABLE MGUT;Lo;0;L;;;;;N;;;;;\nA241;YI SYLLABLE MGUX;Lo;0;L;;;;;N;;;;;\nA242;YI SYLLABLE MGU;Lo;0;L;;;;;N;;;;;\nA243;YI SYLLABLE MGUP;Lo;0;L;;;;;N;;;;;\nA244;YI SYLLABLE MGURX;Lo;0;L;;;;;N;;;;;\nA245;YI SYLLABLE MGUR;Lo;0;L;;;;;N;;;;;\nA246;YI SYLLABLE HXIT;Lo;0;L;;;;;N;;;;;\nA247;YI SYLLABLE HXIX;Lo;0;L;;;;;N;;;;;\nA248;YI SYLLABLE HXI;Lo;0;L;;;;;N;;;;;\nA249;YI SYLLABLE HXIP;Lo;0;L;;;;;N;;;;;\nA24A;YI SYLLABLE HXIET;Lo;0;L;;;;;N;;;;;\nA24B;YI SYLLABLE HXIEX;Lo;0;L;;;;;N;;;;;\nA24C;YI SYLLABLE HXIE;Lo;0;L;;;;;N;;;;;\nA24D;YI SYLLABLE HXIEP;Lo;0;L;;;;;N;;;;;\nA24E;YI SYLLABLE HXAT;Lo;0;L;;;;;N;;;;;\nA24F;YI SYLLABLE HXAX;Lo;0;L;;;;;N;;;;;\nA250;YI SYLLABLE HXA;Lo;0;L;;;;;N;;;;;\nA251;YI SYLLABLE HXAP;Lo;0;L;;;;;N;;;;;\nA252;YI SYLLABLE HXUOT;Lo;0;L;;;;;N;;;;;\nA253;YI SYLLABLE HXUOX;Lo;0;L;;;;;N;;;;;\nA254;YI SYLLABLE HXUO;Lo;0;L;;;;;N;;;;;\nA255;YI SYLLABLE HXUOP;Lo;0;L;;;;;N;;;;;\nA256;YI SYLLABLE HXOT;Lo;0;L;;;;;N;;;;;\nA257;YI SYLLABLE HXOX;Lo;0;L;;;;;N;;;;;\nA258;YI SYLLABLE HXO;Lo;0;L;;;;;N;;;;;\nA259;YI SYLLABLE HXOP;Lo;0;L;;;;;N;;;;;\nA25A;YI SYLLABLE HXEX;Lo;0;L;;;;;N;;;;;\nA25B;YI SYLLABLE HXE;Lo;0;L;;;;;N;;;;;\nA25C;YI SYLLABLE HXEP;Lo;0;L;;;;;N;;;;;\nA25D;YI SYLLABLE NGIEX;Lo;0;L;;;;;N;;;;;\nA25E;YI SYLLABLE NGIE;Lo;0;L;;;;;N;;;;;\nA25F;YI SYLLABLE NGIEP;Lo;0;L;;;;;N;;;;;\nA260;YI SYLLABLE NGAT;Lo;0;L;;;;;N;;;;;\nA261;YI SYLLABLE NGAX;Lo;0;L;;;;;N;;;;;\nA262;YI SYLLABLE NGA;Lo;0;L;;;;;N;;;;;\nA263;YI SYLLABLE NGAP;Lo;0;L;;;;;N;;;;;\nA264;YI SYLLABLE NGUOT;Lo;0;L;;;;;N;;;;;\nA265;YI SYLLABLE NGUOX;Lo;0;L;;;;;N;;;;;\nA266;YI SYLLABLE NGUO;Lo;0;L;;;;;N;;;;;\nA267;YI SYLLABLE NGOT;Lo;0;L;;;;;N;;;;;\nA268;YI SYLLABLE NGOX;Lo;0;L;;;;;N;;;;;\nA269;YI SYLLABLE NGO;Lo;0;L;;;;;N;;;;;\nA26A;YI SYLLABLE NGOP;Lo;0;L;;;;;N;;;;;\nA26B;YI SYLLABLE NGEX;Lo;0;L;;;;;N;;;;;\nA26C;YI SYLLABLE NGE;Lo;0;L;;;;;N;;;;;\nA26D;YI SYLLABLE NGEP;Lo;0;L;;;;;N;;;;;\nA26E;YI SYLLABLE HIT;Lo;0;L;;;;;N;;;;;\nA26F;YI SYLLABLE HIEX;Lo;0;L;;;;;N;;;;;\nA270;YI SYLLABLE HIE;Lo;0;L;;;;;N;;;;;\nA271;YI SYLLABLE HAT;Lo;0;L;;;;;N;;;;;\nA272;YI SYLLABLE HAX;Lo;0;L;;;;;N;;;;;\nA273;YI SYLLABLE HA;Lo;0;L;;;;;N;;;;;\nA274;YI SYLLABLE HAP;Lo;0;L;;;;;N;;;;;\nA275;YI SYLLABLE HUOT;Lo;0;L;;;;;N;;;;;\nA276;YI SYLLABLE HUOX;Lo;0;L;;;;;N;;;;;\nA277;YI SYLLABLE HUO;Lo;0;L;;;;;N;;;;;\nA278;YI SYLLABLE HUOP;Lo;0;L;;;;;N;;;;;\nA279;YI SYLLABLE HOT;Lo;0;L;;;;;N;;;;;\nA27A;YI SYLLABLE HOX;Lo;0;L;;;;;N;;;;;\nA27B;YI SYLLABLE HO;Lo;0;L;;;;;N;;;;;\nA27C;YI SYLLABLE HOP;Lo;0;L;;;;;N;;;;;\nA27D;YI SYLLABLE HEX;Lo;0;L;;;;;N;;;;;\nA27E;YI SYLLABLE HE;Lo;0;L;;;;;N;;;;;\nA27F;YI SYLLABLE HEP;Lo;0;L;;;;;N;;;;;\nA280;YI SYLLABLE WAT;Lo;0;L;;;;;N;;;;;\nA281;YI SYLLABLE WAX;Lo;0;L;;;;;N;;;;;\nA282;YI SYLLABLE WA;Lo;0;L;;;;;N;;;;;\nA283;YI SYLLABLE WAP;Lo;0;L;;;;;N;;;;;\nA284;YI SYLLABLE WUOX;Lo;0;L;;;;;N;;;;;\nA285;YI SYLLABLE WUO;Lo;0;L;;;;;N;;;;;\nA286;YI SYLLABLE WUOP;Lo;0;L;;;;;N;;;;;\nA287;YI SYLLABLE WOX;Lo;0;L;;;;;N;;;;;\nA288;YI SYLLABLE WO;Lo;0;L;;;;;N;;;;;\nA289;YI SYLLABLE WOP;Lo;0;L;;;;;N;;;;;\nA28A;YI SYLLABLE WEX;Lo;0;L;;;;;N;;;;;\nA28B;YI SYLLABLE WE;Lo;0;L;;;;;N;;;;;\nA28C;YI SYLLABLE WEP;Lo;0;L;;;;;N;;;;;\nA28D;YI SYLLABLE ZIT;Lo;0;L;;;;;N;;;;;\nA28E;YI SYLLABLE ZIX;Lo;0;L;;;;;N;;;;;\nA28F;YI SYLLABLE ZI;Lo;0;L;;;;;N;;;;;\nA290;YI SYLLABLE ZIP;Lo;0;L;;;;;N;;;;;\nA291;YI SYLLABLE ZIEX;Lo;0;L;;;;;N;;;;;\nA292;YI SYLLABLE ZIE;Lo;0;L;;;;;N;;;;;\nA293;YI SYLLABLE ZIEP;Lo;0;L;;;;;N;;;;;\nA294;YI SYLLABLE ZAT;Lo;0;L;;;;;N;;;;;\nA295;YI SYLLABLE ZAX;Lo;0;L;;;;;N;;;;;\nA296;YI SYLLABLE ZA;Lo;0;L;;;;;N;;;;;\nA297;YI SYLLABLE ZAP;Lo;0;L;;;;;N;;;;;\nA298;YI SYLLABLE ZUOX;Lo;0;L;;;;;N;;;;;\nA299;YI SYLLABLE ZUO;Lo;0;L;;;;;N;;;;;\nA29A;YI SYLLABLE ZUOP;Lo;0;L;;;;;N;;;;;\nA29B;YI SYLLABLE ZOT;Lo;0;L;;;;;N;;;;;\nA29C;YI SYLLABLE ZOX;Lo;0;L;;;;;N;;;;;\nA29D;YI SYLLABLE ZO;Lo;0;L;;;;;N;;;;;\nA29E;YI SYLLABLE ZOP;Lo;0;L;;;;;N;;;;;\nA29F;YI SYLLABLE ZEX;Lo;0;L;;;;;N;;;;;\nA2A0;YI SYLLABLE ZE;Lo;0;L;;;;;N;;;;;\nA2A1;YI SYLLABLE ZEP;Lo;0;L;;;;;N;;;;;\nA2A2;YI SYLLABLE ZUT;Lo;0;L;;;;;N;;;;;\nA2A3;YI SYLLABLE ZUX;Lo;0;L;;;;;N;;;;;\nA2A4;YI SYLLABLE ZU;Lo;0;L;;;;;N;;;;;\nA2A5;YI SYLLABLE ZUP;Lo;0;L;;;;;N;;;;;\nA2A6;YI SYLLABLE ZURX;Lo;0;L;;;;;N;;;;;\nA2A7;YI SYLLABLE ZUR;Lo;0;L;;;;;N;;;;;\nA2A8;YI SYLLABLE ZYT;Lo;0;L;;;;;N;;;;;\nA2A9;YI SYLLABLE ZYX;Lo;0;L;;;;;N;;;;;\nA2AA;YI SYLLABLE ZY;Lo;0;L;;;;;N;;;;;\nA2AB;YI SYLLABLE ZYP;Lo;0;L;;;;;N;;;;;\nA2AC;YI SYLLABLE ZYRX;Lo;0;L;;;;;N;;;;;\nA2AD;YI SYLLABLE ZYR;Lo;0;L;;;;;N;;;;;\nA2AE;YI SYLLABLE CIT;Lo;0;L;;;;;N;;;;;\nA2AF;YI SYLLABLE CIX;Lo;0;L;;;;;N;;;;;\nA2B0;YI SYLLABLE CI;Lo;0;L;;;;;N;;;;;\nA2B1;YI SYLLABLE CIP;Lo;0;L;;;;;N;;;;;\nA2B2;YI SYLLABLE CIET;Lo;0;L;;;;;N;;;;;\nA2B3;YI SYLLABLE CIEX;Lo;0;L;;;;;N;;;;;\nA2B4;YI SYLLABLE CIE;Lo;0;L;;;;;N;;;;;\nA2B5;YI SYLLABLE CIEP;Lo;0;L;;;;;N;;;;;\nA2B6;YI SYLLABLE CAT;Lo;0;L;;;;;N;;;;;\nA2B7;YI SYLLABLE CAX;Lo;0;L;;;;;N;;;;;\nA2B8;YI SYLLABLE CA;Lo;0;L;;;;;N;;;;;\nA2B9;YI SYLLABLE CAP;Lo;0;L;;;;;N;;;;;\nA2BA;YI SYLLABLE CUOX;Lo;0;L;;;;;N;;;;;\nA2BB;YI SYLLABLE CUO;Lo;0;L;;;;;N;;;;;\nA2BC;YI SYLLABLE CUOP;Lo;0;L;;;;;N;;;;;\nA2BD;YI SYLLABLE COT;Lo;0;L;;;;;N;;;;;\nA2BE;YI SYLLABLE COX;Lo;0;L;;;;;N;;;;;\nA2BF;YI SYLLABLE CO;Lo;0;L;;;;;N;;;;;\nA2C0;YI SYLLABLE COP;Lo;0;L;;;;;N;;;;;\nA2C1;YI SYLLABLE CEX;Lo;0;L;;;;;N;;;;;\nA2C2;YI SYLLABLE CE;Lo;0;L;;;;;N;;;;;\nA2C3;YI SYLLABLE CEP;Lo;0;L;;;;;N;;;;;\nA2C4;YI SYLLABLE CUT;Lo;0;L;;;;;N;;;;;\nA2C5;YI SYLLABLE CUX;Lo;0;L;;;;;N;;;;;\nA2C6;YI SYLLABLE CU;Lo;0;L;;;;;N;;;;;\nA2C7;YI SYLLABLE CUP;Lo;0;L;;;;;N;;;;;\nA2C8;YI SYLLABLE CURX;Lo;0;L;;;;;N;;;;;\nA2C9;YI SYLLABLE CUR;Lo;0;L;;;;;N;;;;;\nA2CA;YI SYLLABLE CYT;Lo;0;L;;;;;N;;;;;\nA2CB;YI SYLLABLE CYX;Lo;0;L;;;;;N;;;;;\nA2CC;YI SYLLABLE CY;Lo;0;L;;;;;N;;;;;\nA2CD;YI SYLLABLE CYP;Lo;0;L;;;;;N;;;;;\nA2CE;YI SYLLABLE CYRX;Lo;0;L;;;;;N;;;;;\nA2CF;YI SYLLABLE CYR;Lo;0;L;;;;;N;;;;;\nA2D0;YI SYLLABLE ZZIT;Lo;0;L;;;;;N;;;;;\nA2D1;YI SYLLABLE ZZIX;Lo;0;L;;;;;N;;;;;\nA2D2;YI SYLLABLE ZZI;Lo;0;L;;;;;N;;;;;\nA2D3;YI SYLLABLE ZZIP;Lo;0;L;;;;;N;;;;;\nA2D4;YI SYLLABLE ZZIET;Lo;0;L;;;;;N;;;;;\nA2D5;YI SYLLABLE ZZIEX;Lo;0;L;;;;;N;;;;;\nA2D6;YI SYLLABLE ZZIE;Lo;0;L;;;;;N;;;;;\nA2D7;YI SYLLABLE ZZIEP;Lo;0;L;;;;;N;;;;;\nA2D8;YI SYLLABLE ZZAT;Lo;0;L;;;;;N;;;;;\nA2D9;YI SYLLABLE ZZAX;Lo;0;L;;;;;N;;;;;\nA2DA;YI SYLLABLE ZZA;Lo;0;L;;;;;N;;;;;\nA2DB;YI SYLLABLE ZZAP;Lo;0;L;;;;;N;;;;;\nA2DC;YI SYLLABLE ZZOX;Lo;0;L;;;;;N;;;;;\nA2DD;YI SYLLABLE ZZO;Lo;0;L;;;;;N;;;;;\nA2DE;YI SYLLABLE ZZOP;Lo;0;L;;;;;N;;;;;\nA2DF;YI SYLLABLE ZZEX;Lo;0;L;;;;;N;;;;;\nA2E0;YI SYLLABLE ZZE;Lo;0;L;;;;;N;;;;;\nA2E1;YI SYLLABLE ZZEP;Lo;0;L;;;;;N;;;;;\nA2E2;YI SYLLABLE ZZUX;Lo;0;L;;;;;N;;;;;\nA2E3;YI SYLLABLE ZZU;Lo;0;L;;;;;N;;;;;\nA2E4;YI SYLLABLE ZZUP;Lo;0;L;;;;;N;;;;;\nA2E5;YI SYLLABLE ZZURX;Lo;0;L;;;;;N;;;;;\nA2E6;YI SYLLABLE ZZUR;Lo;0;L;;;;;N;;;;;\nA2E7;YI SYLLABLE ZZYT;Lo;0;L;;;;;N;;;;;\nA2E8;YI SYLLABLE ZZYX;Lo;0;L;;;;;N;;;;;\nA2E9;YI SYLLABLE ZZY;Lo;0;L;;;;;N;;;;;\nA2EA;YI SYLLABLE ZZYP;Lo;0;L;;;;;N;;;;;\nA2EB;YI SYLLABLE ZZYRX;Lo;0;L;;;;;N;;;;;\nA2EC;YI SYLLABLE ZZYR;Lo;0;L;;;;;N;;;;;\nA2ED;YI SYLLABLE NZIT;Lo;0;L;;;;;N;;;;;\nA2EE;YI SYLLABLE NZIX;Lo;0;L;;;;;N;;;;;\nA2EF;YI SYLLABLE NZI;Lo;0;L;;;;;N;;;;;\nA2F0;YI SYLLABLE NZIP;Lo;0;L;;;;;N;;;;;\nA2F1;YI SYLLABLE NZIEX;Lo;0;L;;;;;N;;;;;\nA2F2;YI SYLLABLE NZIE;Lo;0;L;;;;;N;;;;;\nA2F3;YI SYLLABLE NZIEP;Lo;0;L;;;;;N;;;;;\nA2F4;YI SYLLABLE NZAT;Lo;0;L;;;;;N;;;;;\nA2F5;YI SYLLABLE NZAX;Lo;0;L;;;;;N;;;;;\nA2F6;YI SYLLABLE NZA;Lo;0;L;;;;;N;;;;;\nA2F7;YI SYLLABLE NZAP;Lo;0;L;;;;;N;;;;;\nA2F8;YI SYLLABLE NZUOX;Lo;0;L;;;;;N;;;;;\nA2F9;YI SYLLABLE NZUO;Lo;0;L;;;;;N;;;;;\nA2FA;YI SYLLABLE NZOX;Lo;0;L;;;;;N;;;;;\nA2FB;YI SYLLABLE NZOP;Lo;0;L;;;;;N;;;;;\nA2FC;YI SYLLABLE NZEX;Lo;0;L;;;;;N;;;;;\nA2FD;YI SYLLABLE NZE;Lo;0;L;;;;;N;;;;;\nA2FE;YI SYLLABLE NZUX;Lo;0;L;;;;;N;;;;;\nA2FF;YI SYLLABLE NZU;Lo;0;L;;;;;N;;;;;\nA300;YI SYLLABLE NZUP;Lo;0;L;;;;;N;;;;;\nA301;YI SYLLABLE NZURX;Lo;0;L;;;;;N;;;;;\nA302;YI SYLLABLE NZUR;Lo;0;L;;;;;N;;;;;\nA303;YI SYLLABLE NZYT;Lo;0;L;;;;;N;;;;;\nA304;YI SYLLABLE NZYX;Lo;0;L;;;;;N;;;;;\nA305;YI SYLLABLE NZY;Lo;0;L;;;;;N;;;;;\nA306;YI SYLLABLE NZYP;Lo;0;L;;;;;N;;;;;\nA307;YI SYLLABLE NZYRX;Lo;0;L;;;;;N;;;;;\nA308;YI SYLLABLE NZYR;Lo;0;L;;;;;N;;;;;\nA309;YI SYLLABLE SIT;Lo;0;L;;;;;N;;;;;\nA30A;YI SYLLABLE SIX;Lo;0;L;;;;;N;;;;;\nA30B;YI SYLLABLE SI;Lo;0;L;;;;;N;;;;;\nA30C;YI SYLLABLE SIP;Lo;0;L;;;;;N;;;;;\nA30D;YI SYLLABLE SIEX;Lo;0;L;;;;;N;;;;;\nA30E;YI SYLLABLE SIE;Lo;0;L;;;;;N;;;;;\nA30F;YI SYLLABLE SIEP;Lo;0;L;;;;;N;;;;;\nA310;YI SYLLABLE SAT;Lo;0;L;;;;;N;;;;;\nA311;YI SYLLABLE SAX;Lo;0;L;;;;;N;;;;;\nA312;YI SYLLABLE SA;Lo;0;L;;;;;N;;;;;\nA313;YI SYLLABLE SAP;Lo;0;L;;;;;N;;;;;\nA314;YI SYLLABLE SUOX;Lo;0;L;;;;;N;;;;;\nA315;YI SYLLABLE SUO;Lo;0;L;;;;;N;;;;;\nA316;YI SYLLABLE SUOP;Lo;0;L;;;;;N;;;;;\nA317;YI SYLLABLE SOT;Lo;0;L;;;;;N;;;;;\nA318;YI SYLLABLE SOX;Lo;0;L;;;;;N;;;;;\nA319;YI SYLLABLE SO;Lo;0;L;;;;;N;;;;;\nA31A;YI SYLLABLE SOP;Lo;0;L;;;;;N;;;;;\nA31B;YI SYLLABLE SEX;Lo;0;L;;;;;N;;;;;\nA31C;YI SYLLABLE SE;Lo;0;L;;;;;N;;;;;\nA31D;YI SYLLABLE SEP;Lo;0;L;;;;;N;;;;;\nA31E;YI SYLLABLE SUT;Lo;0;L;;;;;N;;;;;\nA31F;YI SYLLABLE SUX;Lo;0;L;;;;;N;;;;;\nA320;YI SYLLABLE SU;Lo;0;L;;;;;N;;;;;\nA321;YI SYLLABLE SUP;Lo;0;L;;;;;N;;;;;\nA322;YI SYLLABLE SURX;Lo;0;L;;;;;N;;;;;\nA323;YI SYLLABLE SUR;Lo;0;L;;;;;N;;;;;\nA324;YI SYLLABLE SYT;Lo;0;L;;;;;N;;;;;\nA325;YI SYLLABLE SYX;Lo;0;L;;;;;N;;;;;\nA326;YI SYLLABLE SY;Lo;0;L;;;;;N;;;;;\nA327;YI SYLLABLE SYP;Lo;0;L;;;;;N;;;;;\nA328;YI SYLLABLE SYRX;Lo;0;L;;;;;N;;;;;\nA329;YI SYLLABLE SYR;Lo;0;L;;;;;N;;;;;\nA32A;YI SYLLABLE SSIT;Lo;0;L;;;;;N;;;;;\nA32B;YI SYLLABLE SSIX;Lo;0;L;;;;;N;;;;;\nA32C;YI SYLLABLE SSI;Lo;0;L;;;;;N;;;;;\nA32D;YI SYLLABLE SSIP;Lo;0;L;;;;;N;;;;;\nA32E;YI SYLLABLE SSIEX;Lo;0;L;;;;;N;;;;;\nA32F;YI SYLLABLE SSIE;Lo;0;L;;;;;N;;;;;\nA330;YI SYLLABLE SSIEP;Lo;0;L;;;;;N;;;;;\nA331;YI SYLLABLE SSAT;Lo;0;L;;;;;N;;;;;\nA332;YI SYLLABLE SSAX;Lo;0;L;;;;;N;;;;;\nA333;YI SYLLABLE SSA;Lo;0;L;;;;;N;;;;;\nA334;YI SYLLABLE SSAP;Lo;0;L;;;;;N;;;;;\nA335;YI SYLLABLE SSOT;Lo;0;L;;;;;N;;;;;\nA336;YI SYLLABLE SSOX;Lo;0;L;;;;;N;;;;;\nA337;YI SYLLABLE SSO;Lo;0;L;;;;;N;;;;;\nA338;YI SYLLABLE SSOP;Lo;0;L;;;;;N;;;;;\nA339;YI SYLLABLE SSEX;Lo;0;L;;;;;N;;;;;\nA33A;YI SYLLABLE SSE;Lo;0;L;;;;;N;;;;;\nA33B;YI SYLLABLE SSEP;Lo;0;L;;;;;N;;;;;\nA33C;YI SYLLABLE SSUT;Lo;0;L;;;;;N;;;;;\nA33D;YI SYLLABLE SSUX;Lo;0;L;;;;;N;;;;;\nA33E;YI SYLLABLE SSU;Lo;0;L;;;;;N;;;;;\nA33F;YI SYLLABLE SSUP;Lo;0;L;;;;;N;;;;;\nA340;YI SYLLABLE SSYT;Lo;0;L;;;;;N;;;;;\nA341;YI SYLLABLE SSYX;Lo;0;L;;;;;N;;;;;\nA342;YI SYLLABLE SSY;Lo;0;L;;;;;N;;;;;\nA343;YI SYLLABLE SSYP;Lo;0;L;;;;;N;;;;;\nA344;YI SYLLABLE SSYRX;Lo;0;L;;;;;N;;;;;\nA345;YI SYLLABLE SSYR;Lo;0;L;;;;;N;;;;;\nA346;YI SYLLABLE ZHAT;Lo;0;L;;;;;N;;;;;\nA347;YI SYLLABLE ZHAX;Lo;0;L;;;;;N;;;;;\nA348;YI SYLLABLE ZHA;Lo;0;L;;;;;N;;;;;\nA349;YI SYLLABLE ZHAP;Lo;0;L;;;;;N;;;;;\nA34A;YI SYLLABLE ZHUOX;Lo;0;L;;;;;N;;;;;\nA34B;YI SYLLABLE ZHUO;Lo;0;L;;;;;N;;;;;\nA34C;YI SYLLABLE ZHUOP;Lo;0;L;;;;;N;;;;;\nA34D;YI SYLLABLE ZHOT;Lo;0;L;;;;;N;;;;;\nA34E;YI SYLLABLE ZHOX;Lo;0;L;;;;;N;;;;;\nA34F;YI SYLLABLE ZHO;Lo;0;L;;;;;N;;;;;\nA350;YI SYLLABLE ZHOP;Lo;0;L;;;;;N;;;;;\nA351;YI SYLLABLE ZHET;Lo;0;L;;;;;N;;;;;\nA352;YI SYLLABLE ZHEX;Lo;0;L;;;;;N;;;;;\nA353;YI SYLLABLE ZHE;Lo;0;L;;;;;N;;;;;\nA354;YI SYLLABLE ZHEP;Lo;0;L;;;;;N;;;;;\nA355;YI SYLLABLE ZHUT;Lo;0;L;;;;;N;;;;;\nA356;YI SYLLABLE ZHUX;Lo;0;L;;;;;N;;;;;\nA357;YI SYLLABLE ZHU;Lo;0;L;;;;;N;;;;;\nA358;YI SYLLABLE ZHUP;Lo;0;L;;;;;N;;;;;\nA359;YI SYLLABLE ZHURX;Lo;0;L;;;;;N;;;;;\nA35A;YI SYLLABLE ZHUR;Lo;0;L;;;;;N;;;;;\nA35B;YI SYLLABLE ZHYT;Lo;0;L;;;;;N;;;;;\nA35C;YI SYLLABLE ZHYX;Lo;0;L;;;;;N;;;;;\nA35D;YI SYLLABLE ZHY;Lo;0;L;;;;;N;;;;;\nA35E;YI SYLLABLE ZHYP;Lo;0;L;;;;;N;;;;;\nA35F;YI SYLLABLE ZHYRX;Lo;0;L;;;;;N;;;;;\nA360;YI SYLLABLE ZHYR;Lo;0;L;;;;;N;;;;;\nA361;YI SYLLABLE CHAT;Lo;0;L;;;;;N;;;;;\nA362;YI SYLLABLE CHAX;Lo;0;L;;;;;N;;;;;\nA363;YI SYLLABLE CHA;Lo;0;L;;;;;N;;;;;\nA364;YI SYLLABLE CHAP;Lo;0;L;;;;;N;;;;;\nA365;YI SYLLABLE CHUOT;Lo;0;L;;;;;N;;;;;\nA366;YI SYLLABLE CHUOX;Lo;0;L;;;;;N;;;;;\nA367;YI SYLLABLE CHUO;Lo;0;L;;;;;N;;;;;\nA368;YI SYLLABLE CHUOP;Lo;0;L;;;;;N;;;;;\nA369;YI SYLLABLE CHOT;Lo;0;L;;;;;N;;;;;\nA36A;YI SYLLABLE CHOX;Lo;0;L;;;;;N;;;;;\nA36B;YI SYLLABLE CHO;Lo;0;L;;;;;N;;;;;\nA36C;YI SYLLABLE CHOP;Lo;0;L;;;;;N;;;;;\nA36D;YI SYLLABLE CHET;Lo;0;L;;;;;N;;;;;\nA36E;YI SYLLABLE CHEX;Lo;0;L;;;;;N;;;;;\nA36F;YI SYLLABLE CHE;Lo;0;L;;;;;N;;;;;\nA370;YI SYLLABLE CHEP;Lo;0;L;;;;;N;;;;;\nA371;YI SYLLABLE CHUX;Lo;0;L;;;;;N;;;;;\nA372;YI SYLLABLE CHU;Lo;0;L;;;;;N;;;;;\nA373;YI SYLLABLE CHUP;Lo;0;L;;;;;N;;;;;\nA374;YI SYLLABLE CHURX;Lo;0;L;;;;;N;;;;;\nA375;YI SYLLABLE CHUR;Lo;0;L;;;;;N;;;;;\nA376;YI SYLLABLE CHYT;Lo;0;L;;;;;N;;;;;\nA377;YI SYLLABLE CHYX;Lo;0;L;;;;;N;;;;;\nA378;YI SYLLABLE CHY;Lo;0;L;;;;;N;;;;;\nA379;YI SYLLABLE CHYP;Lo;0;L;;;;;N;;;;;\nA37A;YI SYLLABLE CHYRX;Lo;0;L;;;;;N;;;;;\nA37B;YI SYLLABLE CHYR;Lo;0;L;;;;;N;;;;;\nA37C;YI SYLLABLE RRAX;Lo;0;L;;;;;N;;;;;\nA37D;YI SYLLABLE RRA;Lo;0;L;;;;;N;;;;;\nA37E;YI SYLLABLE RRUOX;Lo;0;L;;;;;N;;;;;\nA37F;YI SYLLABLE RRUO;Lo;0;L;;;;;N;;;;;\nA380;YI SYLLABLE RROT;Lo;0;L;;;;;N;;;;;\nA381;YI SYLLABLE RROX;Lo;0;L;;;;;N;;;;;\nA382;YI SYLLABLE RRO;Lo;0;L;;;;;N;;;;;\nA383;YI SYLLABLE RROP;Lo;0;L;;;;;N;;;;;\nA384;YI SYLLABLE RRET;Lo;0;L;;;;;N;;;;;\nA385;YI SYLLABLE RREX;Lo;0;L;;;;;N;;;;;\nA386;YI SYLLABLE RRE;Lo;0;L;;;;;N;;;;;\nA387;YI SYLLABLE RREP;Lo;0;L;;;;;N;;;;;\nA388;YI SYLLABLE RRUT;Lo;0;L;;;;;N;;;;;\nA389;YI SYLLABLE RRUX;Lo;0;L;;;;;N;;;;;\nA38A;YI SYLLABLE RRU;Lo;0;L;;;;;N;;;;;\nA38B;YI SYLLABLE RRUP;Lo;0;L;;;;;N;;;;;\nA38C;YI SYLLABLE RRURX;Lo;0;L;;;;;N;;;;;\nA38D;YI SYLLABLE RRUR;Lo;0;L;;;;;N;;;;;\nA38E;YI SYLLABLE RRYT;Lo;0;L;;;;;N;;;;;\nA38F;YI SYLLABLE RRYX;Lo;0;L;;;;;N;;;;;\nA390;YI SYLLABLE RRY;Lo;0;L;;;;;N;;;;;\nA391;YI SYLLABLE RRYP;Lo;0;L;;;;;N;;;;;\nA392;YI SYLLABLE RRYRX;Lo;0;L;;;;;N;;;;;\nA393;YI SYLLABLE RRYR;Lo;0;L;;;;;N;;;;;\nA394;YI SYLLABLE NRAT;Lo;0;L;;;;;N;;;;;\nA395;YI SYLLABLE NRAX;Lo;0;L;;;;;N;;;;;\nA396;YI SYLLABLE NRA;Lo;0;L;;;;;N;;;;;\nA397;YI SYLLABLE NRAP;Lo;0;L;;;;;N;;;;;\nA398;YI SYLLABLE NROX;Lo;0;L;;;;;N;;;;;\nA399;YI SYLLABLE NRO;Lo;0;L;;;;;N;;;;;\nA39A;YI SYLLABLE NROP;Lo;0;L;;;;;N;;;;;\nA39B;YI SYLLABLE NRET;Lo;0;L;;;;;N;;;;;\nA39C;YI SYLLABLE NREX;Lo;0;L;;;;;N;;;;;\nA39D;YI SYLLABLE NRE;Lo;0;L;;;;;N;;;;;\nA39E;YI SYLLABLE NREP;Lo;0;L;;;;;N;;;;;\nA39F;YI SYLLABLE NRUT;Lo;0;L;;;;;N;;;;;\nA3A0;YI SYLLABLE NRUX;Lo;0;L;;;;;N;;;;;\nA3A1;YI SYLLABLE NRU;Lo;0;L;;;;;N;;;;;\nA3A2;YI SYLLABLE NRUP;Lo;0;L;;;;;N;;;;;\nA3A3;YI SYLLABLE NRURX;Lo;0;L;;;;;N;;;;;\nA3A4;YI SYLLABLE NRUR;Lo;0;L;;;;;N;;;;;\nA3A5;YI SYLLABLE NRYT;Lo;0;L;;;;;N;;;;;\nA3A6;YI SYLLABLE NRYX;Lo;0;L;;;;;N;;;;;\nA3A7;YI SYLLABLE NRY;Lo;0;L;;;;;N;;;;;\nA3A8;YI SYLLABLE NRYP;Lo;0;L;;;;;N;;;;;\nA3A9;YI SYLLABLE NRYRX;Lo;0;L;;;;;N;;;;;\nA3AA;YI SYLLABLE NRYR;Lo;0;L;;;;;N;;;;;\nA3AB;YI SYLLABLE SHAT;Lo;0;L;;;;;N;;;;;\nA3AC;YI SYLLABLE SHAX;Lo;0;L;;;;;N;;;;;\nA3AD;YI SYLLABLE SHA;Lo;0;L;;;;;N;;;;;\nA3AE;YI SYLLABLE SHAP;Lo;0;L;;;;;N;;;;;\nA3AF;YI SYLLABLE SHUOX;Lo;0;L;;;;;N;;;;;\nA3B0;YI SYLLABLE SHUO;Lo;0;L;;;;;N;;;;;\nA3B1;YI SYLLABLE SHUOP;Lo;0;L;;;;;N;;;;;\nA3B2;YI SYLLABLE SHOT;Lo;0;L;;;;;N;;;;;\nA3B3;YI SYLLABLE SHOX;Lo;0;L;;;;;N;;;;;\nA3B4;YI SYLLABLE SHO;Lo;0;L;;;;;N;;;;;\nA3B5;YI SYLLABLE SHOP;Lo;0;L;;;;;N;;;;;\nA3B6;YI SYLLABLE SHET;Lo;0;L;;;;;N;;;;;\nA3B7;YI SYLLABLE SHEX;Lo;0;L;;;;;N;;;;;\nA3B8;YI SYLLABLE SHE;Lo;0;L;;;;;N;;;;;\nA3B9;YI SYLLABLE SHEP;Lo;0;L;;;;;N;;;;;\nA3BA;YI SYLLABLE SHUT;Lo;0;L;;;;;N;;;;;\nA3BB;YI SYLLABLE SHUX;Lo;0;L;;;;;N;;;;;\nA3BC;YI SYLLABLE SHU;Lo;0;L;;;;;N;;;;;\nA3BD;YI SYLLABLE SHUP;Lo;0;L;;;;;N;;;;;\nA3BE;YI SYLLABLE SHURX;Lo;0;L;;;;;N;;;;;\nA3BF;YI SYLLABLE SHUR;Lo;0;L;;;;;N;;;;;\nA3C0;YI SYLLABLE SHYT;Lo;0;L;;;;;N;;;;;\nA3C1;YI SYLLABLE SHYX;Lo;0;L;;;;;N;;;;;\nA3C2;YI SYLLABLE SHY;Lo;0;L;;;;;N;;;;;\nA3C3;YI SYLLABLE SHYP;Lo;0;L;;;;;N;;;;;\nA3C4;YI SYLLABLE SHYRX;Lo;0;L;;;;;N;;;;;\nA3C5;YI SYLLABLE SHYR;Lo;0;L;;;;;N;;;;;\nA3C6;YI SYLLABLE RAT;Lo;0;L;;;;;N;;;;;\nA3C7;YI SYLLABLE RAX;Lo;0;L;;;;;N;;;;;\nA3C8;YI SYLLABLE RA;Lo;0;L;;;;;N;;;;;\nA3C9;YI SYLLABLE RAP;Lo;0;L;;;;;N;;;;;\nA3CA;YI SYLLABLE RUOX;Lo;0;L;;;;;N;;;;;\nA3CB;YI SYLLABLE RUO;Lo;0;L;;;;;N;;;;;\nA3CC;YI SYLLABLE RUOP;Lo;0;L;;;;;N;;;;;\nA3CD;YI SYLLABLE ROT;Lo;0;L;;;;;N;;;;;\nA3CE;YI SYLLABLE ROX;Lo;0;L;;;;;N;;;;;\nA3CF;YI SYLLABLE RO;Lo;0;L;;;;;N;;;;;\nA3D0;YI SYLLABLE ROP;Lo;0;L;;;;;N;;;;;\nA3D1;YI SYLLABLE REX;Lo;0;L;;;;;N;;;;;\nA3D2;YI SYLLABLE RE;Lo;0;L;;;;;N;;;;;\nA3D3;YI SYLLABLE REP;Lo;0;L;;;;;N;;;;;\nA3D4;YI SYLLABLE RUT;Lo;0;L;;;;;N;;;;;\nA3D5;YI SYLLABLE RUX;Lo;0;L;;;;;N;;;;;\nA3D6;YI SYLLABLE RU;Lo;0;L;;;;;N;;;;;\nA3D7;YI SYLLABLE RUP;Lo;0;L;;;;;N;;;;;\nA3D8;YI SYLLABLE RURX;Lo;0;L;;;;;N;;;;;\nA3D9;YI SYLLABLE RUR;Lo;0;L;;;;;N;;;;;\nA3DA;YI SYLLABLE RYT;Lo;0;L;;;;;N;;;;;\nA3DB;YI SYLLABLE RYX;Lo;0;L;;;;;N;;;;;\nA3DC;YI SYLLABLE RY;Lo;0;L;;;;;N;;;;;\nA3DD;YI SYLLABLE RYP;Lo;0;L;;;;;N;;;;;\nA3DE;YI SYLLABLE RYRX;Lo;0;L;;;;;N;;;;;\nA3DF;YI SYLLABLE RYR;Lo;0;L;;;;;N;;;;;\nA3E0;YI SYLLABLE JIT;Lo;0;L;;;;;N;;;;;\nA3E1;YI SYLLABLE JIX;Lo;0;L;;;;;N;;;;;\nA3E2;YI SYLLABLE JI;Lo;0;L;;;;;N;;;;;\nA3E3;YI SYLLABLE JIP;Lo;0;L;;;;;N;;;;;\nA3E4;YI SYLLABLE JIET;Lo;0;L;;;;;N;;;;;\nA3E5;YI SYLLABLE JIEX;Lo;0;L;;;;;N;;;;;\nA3E6;YI SYLLABLE JIE;Lo;0;L;;;;;N;;;;;\nA3E7;YI SYLLABLE JIEP;Lo;0;L;;;;;N;;;;;\nA3E8;YI SYLLABLE JUOT;Lo;0;L;;;;;N;;;;;\nA3E9;YI SYLLABLE JUOX;Lo;0;L;;;;;N;;;;;\nA3EA;YI SYLLABLE JUO;Lo;0;L;;;;;N;;;;;\nA3EB;YI SYLLABLE JUOP;Lo;0;L;;;;;N;;;;;\nA3EC;YI SYLLABLE JOT;Lo;0;L;;;;;N;;;;;\nA3ED;YI SYLLABLE JOX;Lo;0;L;;;;;N;;;;;\nA3EE;YI SYLLABLE JO;Lo;0;L;;;;;N;;;;;\nA3EF;YI SYLLABLE JOP;Lo;0;L;;;;;N;;;;;\nA3F0;YI SYLLABLE JUT;Lo;0;L;;;;;N;;;;;\nA3F1;YI SYLLABLE JUX;Lo;0;L;;;;;N;;;;;\nA3F2;YI SYLLABLE JU;Lo;0;L;;;;;N;;;;;\nA3F3;YI SYLLABLE JUP;Lo;0;L;;;;;N;;;;;\nA3F4;YI SYLLABLE JURX;Lo;0;L;;;;;N;;;;;\nA3F5;YI SYLLABLE JUR;Lo;0;L;;;;;N;;;;;\nA3F6;YI SYLLABLE JYT;Lo;0;L;;;;;N;;;;;\nA3F7;YI SYLLABLE JYX;Lo;0;L;;;;;N;;;;;\nA3F8;YI SYLLABLE JY;Lo;0;L;;;;;N;;;;;\nA3F9;YI SYLLABLE JYP;Lo;0;L;;;;;N;;;;;\nA3FA;YI SYLLABLE JYRX;Lo;0;L;;;;;N;;;;;\nA3FB;YI SYLLABLE JYR;Lo;0;L;;;;;N;;;;;\nA3FC;YI SYLLABLE QIT;Lo;0;L;;;;;N;;;;;\nA3FD;YI SYLLABLE QIX;Lo;0;L;;;;;N;;;;;\nA3FE;YI SYLLABLE QI;Lo;0;L;;;;;N;;;;;\nA3FF;YI SYLLABLE QIP;Lo;0;L;;;;;N;;;;;\nA400;YI SYLLABLE QIET;Lo;0;L;;;;;N;;;;;\nA401;YI SYLLABLE QIEX;Lo;0;L;;;;;N;;;;;\nA402;YI SYLLABLE QIE;Lo;0;L;;;;;N;;;;;\nA403;YI SYLLABLE QIEP;Lo;0;L;;;;;N;;;;;\nA404;YI SYLLABLE QUOT;Lo;0;L;;;;;N;;;;;\nA405;YI SYLLABLE QUOX;Lo;0;L;;;;;N;;;;;\nA406;YI SYLLABLE QUO;Lo;0;L;;;;;N;;;;;\nA407;YI SYLLABLE QUOP;Lo;0;L;;;;;N;;;;;\nA408;YI SYLLABLE QOT;Lo;0;L;;;;;N;;;;;\nA409;YI SYLLABLE QOX;Lo;0;L;;;;;N;;;;;\nA40A;YI SYLLABLE QO;Lo;0;L;;;;;N;;;;;\nA40B;YI SYLLABLE QOP;Lo;0;L;;;;;N;;;;;\nA40C;YI SYLLABLE QUT;Lo;0;L;;;;;N;;;;;\nA40D;YI SYLLABLE QUX;Lo;0;L;;;;;N;;;;;\nA40E;YI SYLLABLE QU;Lo;0;L;;;;;N;;;;;\nA40F;YI SYLLABLE QUP;Lo;0;L;;;;;N;;;;;\nA410;YI SYLLABLE QURX;Lo;0;L;;;;;N;;;;;\nA411;YI SYLLABLE QUR;Lo;0;L;;;;;N;;;;;\nA412;YI SYLLABLE QYT;Lo;0;L;;;;;N;;;;;\nA413;YI SYLLABLE QYX;Lo;0;L;;;;;N;;;;;\nA414;YI SYLLABLE QY;Lo;0;L;;;;;N;;;;;\nA415;YI SYLLABLE QYP;Lo;0;L;;;;;N;;;;;\nA416;YI SYLLABLE QYRX;Lo;0;L;;;;;N;;;;;\nA417;YI SYLLABLE QYR;Lo;0;L;;;;;N;;;;;\nA418;YI SYLLABLE JJIT;Lo;0;L;;;;;N;;;;;\nA419;YI SYLLABLE JJIX;Lo;0;L;;;;;N;;;;;\nA41A;YI SYLLABLE JJI;Lo;0;L;;;;;N;;;;;\nA41B;YI SYLLABLE JJIP;Lo;0;L;;;;;N;;;;;\nA41C;YI SYLLABLE JJIET;Lo;0;L;;;;;N;;;;;\nA41D;YI SYLLABLE JJIEX;Lo;0;L;;;;;N;;;;;\nA41E;YI SYLLABLE JJIE;Lo;0;L;;;;;N;;;;;\nA41F;YI SYLLABLE JJIEP;Lo;0;L;;;;;N;;;;;\nA420;YI SYLLABLE JJUOX;Lo;0;L;;;;;N;;;;;\nA421;YI SYLLABLE JJUO;Lo;0;L;;;;;N;;;;;\nA422;YI SYLLABLE JJUOP;Lo;0;L;;;;;N;;;;;\nA423;YI SYLLABLE JJOT;Lo;0;L;;;;;N;;;;;\nA424;YI SYLLABLE JJOX;Lo;0;L;;;;;N;;;;;\nA425;YI SYLLABLE JJO;Lo;0;L;;;;;N;;;;;\nA426;YI SYLLABLE JJOP;Lo;0;L;;;;;N;;;;;\nA427;YI SYLLABLE JJUT;Lo;0;L;;;;;N;;;;;\nA428;YI SYLLABLE JJUX;Lo;0;L;;;;;N;;;;;\nA429;YI SYLLABLE JJU;Lo;0;L;;;;;N;;;;;\nA42A;YI SYLLABLE JJUP;Lo;0;L;;;;;N;;;;;\nA42B;YI SYLLABLE JJURX;Lo;0;L;;;;;N;;;;;\nA42C;YI SYLLABLE JJUR;Lo;0;L;;;;;N;;;;;\nA42D;YI SYLLABLE JJYT;Lo;0;L;;;;;N;;;;;\nA42E;YI SYLLABLE JJYX;Lo;0;L;;;;;N;;;;;\nA42F;YI SYLLABLE JJY;Lo;0;L;;;;;N;;;;;\nA430;YI SYLLABLE JJYP;Lo;0;L;;;;;N;;;;;\nA431;YI SYLLABLE NJIT;Lo;0;L;;;;;N;;;;;\nA432;YI SYLLABLE NJIX;Lo;0;L;;;;;N;;;;;\nA433;YI SYLLABLE NJI;Lo;0;L;;;;;N;;;;;\nA434;YI SYLLABLE NJIP;Lo;0;L;;;;;N;;;;;\nA435;YI SYLLABLE NJIET;Lo;0;L;;;;;N;;;;;\nA436;YI SYLLABLE NJIEX;Lo;0;L;;;;;N;;;;;\nA437;YI SYLLABLE NJIE;Lo;0;L;;;;;N;;;;;\nA438;YI SYLLABLE NJIEP;Lo;0;L;;;;;N;;;;;\nA439;YI SYLLABLE NJUOX;Lo;0;L;;;;;N;;;;;\nA43A;YI SYLLABLE NJUO;Lo;0;L;;;;;N;;;;;\nA43B;YI SYLLABLE NJOT;Lo;0;L;;;;;N;;;;;\nA43C;YI SYLLABLE NJOX;Lo;0;L;;;;;N;;;;;\nA43D;YI SYLLABLE NJO;Lo;0;L;;;;;N;;;;;\nA43E;YI SYLLABLE NJOP;Lo;0;L;;;;;N;;;;;\nA43F;YI SYLLABLE NJUX;Lo;0;L;;;;;N;;;;;\nA440;YI SYLLABLE NJU;Lo;0;L;;;;;N;;;;;\nA441;YI SYLLABLE NJUP;Lo;0;L;;;;;N;;;;;\nA442;YI SYLLABLE NJURX;Lo;0;L;;;;;N;;;;;\nA443;YI SYLLABLE NJUR;Lo;0;L;;;;;N;;;;;\nA444;YI SYLLABLE NJYT;Lo;0;L;;;;;N;;;;;\nA445;YI SYLLABLE NJYX;Lo;0;L;;;;;N;;;;;\nA446;YI SYLLABLE NJY;Lo;0;L;;;;;N;;;;;\nA447;YI SYLLABLE NJYP;Lo;0;L;;;;;N;;;;;\nA448;YI SYLLABLE NJYRX;Lo;0;L;;;;;N;;;;;\nA449;YI SYLLABLE NJYR;Lo;0;L;;;;;N;;;;;\nA44A;YI SYLLABLE NYIT;Lo;0;L;;;;;N;;;;;\nA44B;YI SYLLABLE NYIX;Lo;0;L;;;;;N;;;;;\nA44C;YI SYLLABLE NYI;Lo;0;L;;;;;N;;;;;\nA44D;YI SYLLABLE NYIP;Lo;0;L;;;;;N;;;;;\nA44E;YI SYLLABLE NYIET;Lo;0;L;;;;;N;;;;;\nA44F;YI SYLLABLE NYIEX;Lo;0;L;;;;;N;;;;;\nA450;YI SYLLABLE NYIE;Lo;0;L;;;;;N;;;;;\nA451;YI SYLLABLE NYIEP;Lo;0;L;;;;;N;;;;;\nA452;YI SYLLABLE NYUOX;Lo;0;L;;;;;N;;;;;\nA453;YI SYLLABLE NYUO;Lo;0;L;;;;;N;;;;;\nA454;YI SYLLABLE NYUOP;Lo;0;L;;;;;N;;;;;\nA455;YI SYLLABLE NYOT;Lo;0;L;;;;;N;;;;;\nA456;YI SYLLABLE NYOX;Lo;0;L;;;;;N;;;;;\nA457;YI SYLLABLE NYO;Lo;0;L;;;;;N;;;;;\nA458;YI SYLLABLE NYOP;Lo;0;L;;;;;N;;;;;\nA459;YI SYLLABLE NYUT;Lo;0;L;;;;;N;;;;;\nA45A;YI SYLLABLE NYUX;Lo;0;L;;;;;N;;;;;\nA45B;YI SYLLABLE NYU;Lo;0;L;;;;;N;;;;;\nA45C;YI SYLLABLE NYUP;Lo;0;L;;;;;N;;;;;\nA45D;YI SYLLABLE XIT;Lo;0;L;;;;;N;;;;;\nA45E;YI SYLLABLE XIX;Lo;0;L;;;;;N;;;;;\nA45F;YI SYLLABLE XI;Lo;0;L;;;;;N;;;;;\nA460;YI SYLLABLE XIP;Lo;0;L;;;;;N;;;;;\nA461;YI SYLLABLE XIET;Lo;0;L;;;;;N;;;;;\nA462;YI SYLLABLE XIEX;Lo;0;L;;;;;N;;;;;\nA463;YI SYLLABLE XIE;Lo;0;L;;;;;N;;;;;\nA464;YI SYLLABLE XIEP;Lo;0;L;;;;;N;;;;;\nA465;YI SYLLABLE XUOX;Lo;0;L;;;;;N;;;;;\nA466;YI SYLLABLE XUO;Lo;0;L;;;;;N;;;;;\nA467;YI SYLLABLE XOT;Lo;0;L;;;;;N;;;;;\nA468;YI SYLLABLE XOX;Lo;0;L;;;;;N;;;;;\nA469;YI SYLLABLE XO;Lo;0;L;;;;;N;;;;;\nA46A;YI SYLLABLE XOP;Lo;0;L;;;;;N;;;;;\nA46B;YI SYLLABLE XYT;Lo;0;L;;;;;N;;;;;\nA46C;YI SYLLABLE XYX;Lo;0;L;;;;;N;;;;;\nA46D;YI SYLLABLE XY;Lo;0;L;;;;;N;;;;;\nA46E;YI SYLLABLE XYP;Lo;0;L;;;;;N;;;;;\nA46F;YI SYLLABLE XYRX;Lo;0;L;;;;;N;;;;;\nA470;YI SYLLABLE XYR;Lo;0;L;;;;;N;;;;;\nA471;YI SYLLABLE YIT;Lo;0;L;;;;;N;;;;;\nA472;YI SYLLABLE YIX;Lo;0;L;;;;;N;;;;;\nA473;YI SYLLABLE YI;Lo;0;L;;;;;N;;;;;\nA474;YI SYLLABLE YIP;Lo;0;L;;;;;N;;;;;\nA475;YI SYLLABLE YIET;Lo;0;L;;;;;N;;;;;\nA476;YI SYLLABLE YIEX;Lo;0;L;;;;;N;;;;;\nA477;YI SYLLABLE YIE;Lo;0;L;;;;;N;;;;;\nA478;YI SYLLABLE YIEP;Lo;0;L;;;;;N;;;;;\nA479;YI SYLLABLE YUOT;Lo;0;L;;;;;N;;;;;\nA47A;YI SYLLABLE YUOX;Lo;0;L;;;;;N;;;;;\nA47B;YI SYLLABLE YUO;Lo;0;L;;;;;N;;;;;\nA47C;YI SYLLABLE YUOP;Lo;0;L;;;;;N;;;;;\nA47D;YI SYLLABLE YOT;Lo;0;L;;;;;N;;;;;\nA47E;YI SYLLABLE YOX;Lo;0;L;;;;;N;;;;;\nA47F;YI SYLLABLE YO;Lo;0;L;;;;;N;;;;;\nA480;YI SYLLABLE YOP;Lo;0;L;;;;;N;;;;;\nA481;YI SYLLABLE YUT;Lo;0;L;;;;;N;;;;;\nA482;YI SYLLABLE YUX;Lo;0;L;;;;;N;;;;;\nA483;YI SYLLABLE YU;Lo;0;L;;;;;N;;;;;\nA484;YI SYLLABLE YUP;Lo;0;L;;;;;N;;;;;\nA485;YI SYLLABLE YURX;Lo;0;L;;;;;N;;;;;\nA486;YI SYLLABLE YUR;Lo;0;L;;;;;N;;;;;\nA487;YI SYLLABLE YYT;Lo;0;L;;;;;N;;;;;\nA488;YI SYLLABLE YYX;Lo;0;L;;;;;N;;;;;\nA489;YI SYLLABLE YY;Lo;0;L;;;;;N;;;;;\nA48A;YI SYLLABLE YYP;Lo;0;L;;;;;N;;;;;\nA48B;YI SYLLABLE YYRX;Lo;0;L;;;;;N;;;;;\nA48C;YI SYLLABLE YYR;Lo;0;L;;;;;N;;;;;\nA490;YI RADICAL QOT;So;0;ON;;;;;N;;;;;\nA491;YI RADICAL LI;So;0;ON;;;;;N;;;;;\nA492;YI RADICAL KIT;So;0;ON;;;;;N;;;;;\nA493;YI RADICAL NYIP;So;0;ON;;;;;N;;;;;\nA494;YI RADICAL CYP;So;0;ON;;;;;N;;;;;\nA495;YI RADICAL SSI;So;0;ON;;;;;N;;;;;\nA496;YI RADICAL GGOP;So;0;ON;;;;;N;;;;;\nA497;YI RADICAL GEP;So;0;ON;;;;;N;;;;;\nA498;YI RADICAL MI;So;0;ON;;;;;N;;;;;\nA499;YI RADICAL HXIT;So;0;ON;;;;;N;;;;;\nA49A;YI RADICAL LYR;So;0;ON;;;;;N;;;;;\nA49B;YI RADICAL BBUT;So;0;ON;;;;;N;;;;;\nA49C;YI RADICAL MOP;So;0;ON;;;;;N;;;;;\nA49D;YI RADICAL YO;So;0;ON;;;;;N;;;;;\nA49E;YI RADICAL PUT;So;0;ON;;;;;N;;;;;\nA49F;YI RADICAL HXUO;So;0;ON;;;;;N;;;;;\nA4A0;YI RADICAL TAT;So;0;ON;;;;;N;;;;;\nA4A1;YI RADICAL GA;So;0;ON;;;;;N;;;;;\nA4A2;YI RADICAL ZUP;So;0;ON;;;;;N;;;;;\nA4A3;YI RADICAL CYT;So;0;ON;;;;;N;;;;;\nA4A4;YI RADICAL DDUR;So;0;ON;;;;;N;;;;;\nA4A5;YI RADICAL BUR;So;0;ON;;;;;N;;;;;\nA4A6;YI RADICAL GGUO;So;0;ON;;;;;N;;;;;\nA4A7;YI RADICAL NYOP;So;0;ON;;;;;N;;;;;\nA4A8;YI RADICAL TU;So;0;ON;;;;;N;;;;;\nA4A9;YI RADICAL OP;So;0;ON;;;;;N;;;;;\nA4AA;YI RADICAL JJUT;So;0;ON;;;;;N;;;;;\nA4AB;YI RADICAL ZOT;So;0;ON;;;;;N;;;;;\nA4AC;YI RADICAL PYT;So;0;ON;;;;;N;;;;;\nA4AD;YI RADICAL HMO;So;0;ON;;;;;N;;;;;\nA4AE;YI RADICAL YIT;So;0;ON;;;;;N;;;;;\nA4AF;YI RADICAL VUR;So;0;ON;;;;;N;;;;;\nA4B0;YI RADICAL SHY;So;0;ON;;;;;N;;;;;\nA4B1;YI RADICAL VEP;So;0;ON;;;;;N;;;;;\nA4B2;YI RADICAL ZA;So;0;ON;;;;;N;;;;;\nA4B3;YI RADICAL JO;So;0;ON;;;;;N;;;;;\nA4B4;YI RADICAL NZUP;So;0;ON;;;;;N;;;;;\nA4B5;YI RADICAL JJY;So;0;ON;;;;;N;;;;;\nA4B6;YI RADICAL GOT;So;0;ON;;;;;N;;;;;\nA4B7;YI RADICAL JJIE;So;0;ON;;;;;N;;;;;\nA4B8;YI RADICAL WO;So;0;ON;;;;;N;;;;;\nA4B9;YI RADICAL DU;So;0;ON;;;;;N;;;;;\nA4BA;YI RADICAL SHUR;So;0;ON;;;;;N;;;;;\nA4BB;YI RADICAL LIE;So;0;ON;;;;;N;;;;;\nA4BC;YI RADICAL CY;So;0;ON;;;;;N;;;;;\nA4BD;YI RADICAL CUOP;So;0;ON;;;;;N;;;;;\nA4BE;YI RADICAL CIP;So;0;ON;;;;;N;;;;;\nA4BF;YI RADICAL HXOP;So;0;ON;;;;;N;;;;;\nA4C0;YI RADICAL SHAT;So;0;ON;;;;;N;;;;;\nA4C1;YI RADICAL ZUR;So;0;ON;;;;;N;;;;;\nA4C2;YI RADICAL SHOP;So;0;ON;;;;;N;;;;;\nA4C3;YI RADICAL CHE;So;0;ON;;;;;N;;;;;\nA4C4;YI RADICAL ZZIET;So;0;ON;;;;;N;;;;;\nA4C5;YI RADICAL NBIE;So;0;ON;;;;;N;;;;;\nA4C6;YI RADICAL KE;So;0;ON;;;;;N;;;;;\nA4D0;LISU LETTER BA;Lo;0;L;;;;;N;;;;;\nA4D1;LISU LETTER PA;Lo;0;L;;;;;N;;;;;\nA4D2;LISU LETTER PHA;Lo;0;L;;;;;N;;;;;\nA4D3;LISU LETTER DA;Lo;0;L;;;;;N;;;;;\nA4D4;LISU LETTER TA;Lo;0;L;;;;;N;;;;;\nA4D5;LISU LETTER THA;Lo;0;L;;;;;N;;;;;\nA4D6;LISU LETTER GA;Lo;0;L;;;;;N;;;;;\nA4D7;LISU LETTER KA;Lo;0;L;;;;;N;;;;;\nA4D8;LISU LETTER KHA;Lo;0;L;;;;;N;;;;;\nA4D9;LISU LETTER JA;Lo;0;L;;;;;N;;;;;\nA4DA;LISU LETTER CA;Lo;0;L;;;;;N;;;;;\nA4DB;LISU LETTER CHA;Lo;0;L;;;;;N;;;;;\nA4DC;LISU LETTER DZA;Lo;0;L;;;;;N;;;;;\nA4DD;LISU LETTER TSA;Lo;0;L;;;;;N;;;;;\nA4DE;LISU LETTER TSHA;Lo;0;L;;;;;N;;;;;\nA4DF;LISU LETTER MA;Lo;0;L;;;;;N;;;;;\nA4E0;LISU LETTER NA;Lo;0;L;;;;;N;;;;;\nA4E1;LISU LETTER LA;Lo;0;L;;;;;N;;;;;\nA4E2;LISU LETTER SA;Lo;0;L;;;;;N;;;;;\nA4E3;LISU LETTER ZHA;Lo;0;L;;;;;N;;;;;\nA4E4;LISU LETTER ZA;Lo;0;L;;;;;N;;;;;\nA4E5;LISU LETTER NGA;Lo;0;L;;;;;N;;;;;\nA4E6;LISU LETTER HA;Lo;0;L;;;;;N;;;;;\nA4E7;LISU LETTER XA;Lo;0;L;;;;;N;;;;;\nA4E8;LISU LETTER HHA;Lo;0;L;;;;;N;;;;;\nA4E9;LISU LETTER FA;Lo;0;L;;;;;N;;;;;\nA4EA;LISU LETTER WA;Lo;0;L;;;;;N;;;;;\nA4EB;LISU LETTER SHA;Lo;0;L;;;;;N;;;;;\nA4EC;LISU LETTER YA;Lo;0;L;;;;;N;;;;;\nA4ED;LISU LETTER GHA;Lo;0;L;;;;;N;;;;;\nA4EE;LISU LETTER A;Lo;0;L;;;;;N;;;;;\nA4EF;LISU LETTER AE;Lo;0;L;;;;;N;;;;;\nA4F0;LISU LETTER E;Lo;0;L;;;;;N;;;;;\nA4F1;LISU LETTER EU;Lo;0;L;;;;;N;;;;;\nA4F2;LISU LETTER I;Lo;0;L;;;;;N;;;;;\nA4F3;LISU LETTER O;Lo;0;L;;;;;N;;;;;\nA4F4;LISU LETTER U;Lo;0;L;;;;;N;;;;;\nA4F5;LISU LETTER UE;Lo;0;L;;;;;N;;;;;\nA4F6;LISU LETTER UH;Lo;0;L;;;;;N;;;;;\nA4F7;LISU LETTER OE;Lo;0;L;;;;;N;;;;;\nA4F8;LISU LETTER TONE MYA TI;Lm;0;L;;;;;N;;;;;\nA4F9;LISU LETTER TONE NA PO;Lm;0;L;;;;;N;;;;;\nA4FA;LISU LETTER TONE MYA CYA;Lm;0;L;;;;;N;;;;;\nA4FB;LISU LETTER TONE MYA BO;Lm;0;L;;;;;N;;;;;\nA4FC;LISU LETTER TONE MYA NA;Lm;0;L;;;;;N;;;;;\nA4FD;LISU LETTER TONE MYA JEU;Lm;0;L;;;;;N;;;;;\nA4FE;LISU PUNCTUATION COMMA;Po;0;L;;;;;N;;;;;\nA4FF;LISU PUNCTUATION FULL STOP;Po;0;L;;;;;N;;;;;\nA500;VAI SYLLABLE EE;Lo;0;L;;;;;N;;;;;\nA501;VAI SYLLABLE EEN;Lo;0;L;;;;;N;;;;;\nA502;VAI SYLLABLE HEE;Lo;0;L;;;;;N;;;;;\nA503;VAI SYLLABLE WEE;Lo;0;L;;;;;N;;;;;\nA504;VAI SYLLABLE WEEN;Lo;0;L;;;;;N;;;;;\nA505;VAI SYLLABLE PEE;Lo;0;L;;;;;N;;;;;\nA506;VAI SYLLABLE BHEE;Lo;0;L;;;;;N;;;;;\nA507;VAI SYLLABLE BEE;Lo;0;L;;;;;N;;;;;\nA508;VAI SYLLABLE MBEE;Lo;0;L;;;;;N;;;;;\nA509;VAI SYLLABLE KPEE;Lo;0;L;;;;;N;;;;;\nA50A;VAI SYLLABLE MGBEE;Lo;0;L;;;;;N;;;;;\nA50B;VAI SYLLABLE GBEE;Lo;0;L;;;;;N;;;;;\nA50C;VAI SYLLABLE FEE;Lo;0;L;;;;;N;;;;;\nA50D;VAI SYLLABLE VEE;Lo;0;L;;;;;N;;;;;\nA50E;VAI SYLLABLE TEE;Lo;0;L;;;;;N;;;;;\nA50F;VAI SYLLABLE THEE;Lo;0;L;;;;;N;;;;;\nA510;VAI SYLLABLE DHEE;Lo;0;L;;;;;N;;;;;\nA511;VAI SYLLABLE DHHEE;Lo;0;L;;;;;N;;;;;\nA512;VAI SYLLABLE LEE;Lo;0;L;;;;;N;;;;;\nA513;VAI SYLLABLE REE;Lo;0;L;;;;;N;;;;;\nA514;VAI SYLLABLE DEE;Lo;0;L;;;;;N;;;;;\nA515;VAI SYLLABLE NDEE;Lo;0;L;;;;;N;;;;;\nA516;VAI SYLLABLE SEE;Lo;0;L;;;;;N;;;;;\nA517;VAI SYLLABLE SHEE;Lo;0;L;;;;;N;;;;;\nA518;VAI SYLLABLE ZEE;Lo;0;L;;;;;N;;;;;\nA519;VAI SYLLABLE ZHEE;Lo;0;L;;;;;N;;;;;\nA51A;VAI SYLLABLE CEE;Lo;0;L;;;;;N;;;;;\nA51B;VAI SYLLABLE JEE;Lo;0;L;;;;;N;;;;;\nA51C;VAI SYLLABLE NJEE;Lo;0;L;;;;;N;;;;;\nA51D;VAI SYLLABLE YEE;Lo;0;L;;;;;N;;;;;\nA51E;VAI SYLLABLE KEE;Lo;0;L;;;;;N;;;;;\nA51F;VAI SYLLABLE NGGEE;Lo;0;L;;;;;N;;;;;\nA520;VAI SYLLABLE GEE;Lo;0;L;;;;;N;;;;;\nA521;VAI SYLLABLE MEE;Lo;0;L;;;;;N;;;;;\nA522;VAI SYLLABLE NEE;Lo;0;L;;;;;N;;;;;\nA523;VAI SYLLABLE NYEE;Lo;0;L;;;;;N;;;;;\nA524;VAI SYLLABLE I;Lo;0;L;;;;;N;;;;;\nA525;VAI SYLLABLE IN;Lo;0;L;;;;;N;;;;;\nA526;VAI SYLLABLE HI;Lo;0;L;;;;;N;;;;;\nA527;VAI SYLLABLE HIN;Lo;0;L;;;;;N;;;;;\nA528;VAI SYLLABLE WI;Lo;0;L;;;;;N;;;;;\nA529;VAI SYLLABLE WIN;Lo;0;L;;;;;N;;;;;\nA52A;VAI SYLLABLE PI;Lo;0;L;;;;;N;;;;;\nA52B;VAI SYLLABLE BHI;Lo;0;L;;;;;N;;;;;\nA52C;VAI SYLLABLE BI;Lo;0;L;;;;;N;;;;;\nA52D;VAI SYLLABLE MBI;Lo;0;L;;;;;N;;;;;\nA52E;VAI SYLLABLE KPI;Lo;0;L;;;;;N;;;;;\nA52F;VAI SYLLABLE MGBI;Lo;0;L;;;;;N;;;;;\nA530;VAI SYLLABLE GBI;Lo;0;L;;;;;N;;;;;\nA531;VAI SYLLABLE FI;Lo;0;L;;;;;N;;;;;\nA532;VAI SYLLABLE VI;Lo;0;L;;;;;N;;;;;\nA533;VAI SYLLABLE TI;Lo;0;L;;;;;N;;;;;\nA534;VAI SYLLABLE THI;Lo;0;L;;;;;N;;;;;\nA535;VAI SYLLABLE DHI;Lo;0;L;;;;;N;;;;;\nA536;VAI SYLLABLE DHHI;Lo;0;L;;;;;N;;;;;\nA537;VAI SYLLABLE LI;Lo;0;L;;;;;N;;;;;\nA538;VAI SYLLABLE RI;Lo;0;L;;;;;N;;;;;\nA539;VAI SYLLABLE DI;Lo;0;L;;;;;N;;;;;\nA53A;VAI SYLLABLE NDI;Lo;0;L;;;;;N;;;;;\nA53B;VAI SYLLABLE SI;Lo;0;L;;;;;N;;;;;\nA53C;VAI SYLLABLE SHI;Lo;0;L;;;;;N;;;;;\nA53D;VAI SYLLABLE ZI;Lo;0;L;;;;;N;;;;;\nA53E;VAI SYLLABLE ZHI;Lo;0;L;;;;;N;;;;;\nA53F;VAI SYLLABLE CI;Lo;0;L;;;;;N;;;;;\nA540;VAI SYLLABLE JI;Lo;0;L;;;;;N;;;;;\nA541;VAI SYLLABLE NJI;Lo;0;L;;;;;N;;;;;\nA542;VAI SYLLABLE YI;Lo;0;L;;;;;N;;;;;\nA543;VAI SYLLABLE KI;Lo;0;L;;;;;N;;;;;\nA544;VAI SYLLABLE NGGI;Lo;0;L;;;;;N;;;;;\nA545;VAI SYLLABLE GI;Lo;0;L;;;;;N;;;;;\nA546;VAI SYLLABLE MI;Lo;0;L;;;;;N;;;;;\nA547;VAI SYLLABLE NI;Lo;0;L;;;;;N;;;;;\nA548;VAI SYLLABLE NYI;Lo;0;L;;;;;N;;;;;\nA549;VAI SYLLABLE A;Lo;0;L;;;;;N;;;;;\nA54A;VAI SYLLABLE AN;Lo;0;L;;;;;N;;;;;\nA54B;VAI SYLLABLE NGAN;Lo;0;L;;;;;N;;;;;\nA54C;VAI SYLLABLE HA;Lo;0;L;;;;;N;;;;;\nA54D;VAI SYLLABLE HAN;Lo;0;L;;;;;N;;;;;\nA54E;VAI SYLLABLE WA;Lo;0;L;;;;;N;;;;;\nA54F;VAI SYLLABLE WAN;Lo;0;L;;;;;N;;;;;\nA550;VAI SYLLABLE PA;Lo;0;L;;;;;N;;;;;\nA551;VAI SYLLABLE BHA;Lo;0;L;;;;;N;;;;;\nA552;VAI SYLLABLE BA;Lo;0;L;;;;;N;;;;;\nA553;VAI SYLLABLE MBA;Lo;0;L;;;;;N;;;;;\nA554;VAI SYLLABLE KPA;Lo;0;L;;;;;N;;;;;\nA555;VAI SYLLABLE KPAN;Lo;0;L;;;;;N;;;;;\nA556;VAI SYLLABLE MGBA;Lo;0;L;;;;;N;;;;;\nA557;VAI SYLLABLE GBA;Lo;0;L;;;;;N;;;;;\nA558;VAI SYLLABLE FA;Lo;0;L;;;;;N;;;;;\nA559;VAI SYLLABLE VA;Lo;0;L;;;;;N;;;;;\nA55A;VAI SYLLABLE TA;Lo;0;L;;;;;N;;;;;\nA55B;VAI SYLLABLE THA;Lo;0;L;;;;;N;;;;;\nA55C;VAI SYLLABLE DHA;Lo;0;L;;;;;N;;;;;\nA55D;VAI SYLLABLE DHHA;Lo;0;L;;;;;N;;;;;\nA55E;VAI SYLLABLE LA;Lo;0;L;;;;;N;;;;;\nA55F;VAI SYLLABLE RA;Lo;0;L;;;;;N;;;;;\nA560;VAI SYLLABLE DA;Lo;0;L;;;;;N;;;;;\nA561;VAI SYLLABLE NDA;Lo;0;L;;;;;N;;;;;\nA562;VAI SYLLABLE SA;Lo;0;L;;;;;N;;;;;\nA563;VAI SYLLABLE SHA;Lo;0;L;;;;;N;;;;;\nA564;VAI SYLLABLE ZA;Lo;0;L;;;;;N;;;;;\nA565;VAI SYLLABLE ZHA;Lo;0;L;;;;;N;;;;;\nA566;VAI SYLLABLE CA;Lo;0;L;;;;;N;;;;;\nA567;VAI SYLLABLE JA;Lo;0;L;;;;;N;;;;;\nA568;VAI SYLLABLE NJA;Lo;0;L;;;;;N;;;;;\nA569;VAI SYLLABLE YA;Lo;0;L;;;;;N;;;;;\nA56A;VAI SYLLABLE KA;Lo;0;L;;;;;N;;;;;\nA56B;VAI SYLLABLE KAN;Lo;0;L;;;;;N;;;;;\nA56C;VAI SYLLABLE NGGA;Lo;0;L;;;;;N;;;;;\nA56D;VAI SYLLABLE GA;Lo;0;L;;;;;N;;;;;\nA56E;VAI SYLLABLE MA;Lo;0;L;;;;;N;;;;;\nA56F;VAI SYLLABLE NA;Lo;0;L;;;;;N;;;;;\nA570;VAI SYLLABLE NYA;Lo;0;L;;;;;N;;;;;\nA571;VAI SYLLABLE OO;Lo;0;L;;;;;N;;;;;\nA572;VAI SYLLABLE OON;Lo;0;L;;;;;N;;;;;\nA573;VAI SYLLABLE HOO;Lo;0;L;;;;;N;;;;;\nA574;VAI SYLLABLE WOO;Lo;0;L;;;;;N;;;;;\nA575;VAI SYLLABLE WOON;Lo;0;L;;;;;N;;;;;\nA576;VAI SYLLABLE POO;Lo;0;L;;;;;N;;;;;\nA577;VAI SYLLABLE BHOO;Lo;0;L;;;;;N;;;;;\nA578;VAI SYLLABLE BOO;Lo;0;L;;;;;N;;;;;\nA579;VAI SYLLABLE MBOO;Lo;0;L;;;;;N;;;;;\nA57A;VAI SYLLABLE KPOO;Lo;0;L;;;;;N;;;;;\nA57B;VAI SYLLABLE MGBOO;Lo;0;L;;;;;N;;;;;\nA57C;VAI SYLLABLE GBOO;Lo;0;L;;;;;N;;;;;\nA57D;VAI SYLLABLE FOO;Lo;0;L;;;;;N;;;;;\nA57E;VAI SYLLABLE VOO;Lo;0;L;;;;;N;;;;;\nA57F;VAI SYLLABLE TOO;Lo;0;L;;;;;N;;;;;\nA580;VAI SYLLABLE THOO;Lo;0;L;;;;;N;;;;;\nA581;VAI SYLLABLE DHOO;Lo;0;L;;;;;N;;;;;\nA582;VAI SYLLABLE DHHOO;Lo;0;L;;;;;N;;;;;\nA583;VAI SYLLABLE LOO;Lo;0;L;;;;;N;;;;;\nA584;VAI SYLLABLE ROO;Lo;0;L;;;;;N;;;;;\nA585;VAI SYLLABLE DOO;Lo;0;L;;;;;N;;;;;\nA586;VAI SYLLABLE NDOO;Lo;0;L;;;;;N;;;;;\nA587;VAI SYLLABLE SOO;Lo;0;L;;;;;N;;;;;\nA588;VAI SYLLABLE SHOO;Lo;0;L;;;;;N;;;;;\nA589;VAI SYLLABLE ZOO;Lo;0;L;;;;;N;;;;;\nA58A;VAI SYLLABLE ZHOO;Lo;0;L;;;;;N;;;;;\nA58B;VAI SYLLABLE COO;Lo;0;L;;;;;N;;;;;\nA58C;VAI SYLLABLE JOO;Lo;0;L;;;;;N;;;;;\nA58D;VAI SYLLABLE NJOO;Lo;0;L;;;;;N;;;;;\nA58E;VAI SYLLABLE YOO;Lo;0;L;;;;;N;;;;;\nA58F;VAI SYLLABLE KOO;Lo;0;L;;;;;N;;;;;\nA590;VAI SYLLABLE NGGOO;Lo;0;L;;;;;N;;;;;\nA591;VAI SYLLABLE GOO;Lo;0;L;;;;;N;;;;;\nA592;VAI SYLLABLE MOO;Lo;0;L;;;;;N;;;;;\nA593;VAI SYLLABLE NOO;Lo;0;L;;;;;N;;;;;\nA594;VAI SYLLABLE NYOO;Lo;0;L;;;;;N;;;;;\nA595;VAI SYLLABLE U;Lo;0;L;;;;;N;;;;;\nA596;VAI SYLLABLE UN;Lo;0;L;;;;;N;;;;;\nA597;VAI SYLLABLE HU;Lo;0;L;;;;;N;;;;;\nA598;VAI SYLLABLE HUN;Lo;0;L;;;;;N;;;;;\nA599;VAI SYLLABLE WU;Lo;0;L;;;;;N;;;;;\nA59A;VAI SYLLABLE WUN;Lo;0;L;;;;;N;;;;;\nA59B;VAI SYLLABLE PU;Lo;0;L;;;;;N;;;;;\nA59C;VAI SYLLABLE BHU;Lo;0;L;;;;;N;;;;;\nA59D;VAI SYLLABLE BU;Lo;0;L;;;;;N;;;;;\nA59E;VAI SYLLABLE MBU;Lo;0;L;;;;;N;;;;;\nA59F;VAI SYLLABLE KPU;Lo;0;L;;;;;N;;;;;\nA5A0;VAI SYLLABLE MGBU;Lo;0;L;;;;;N;;;;;\nA5A1;VAI SYLLABLE GBU;Lo;0;L;;;;;N;;;;;\nA5A2;VAI SYLLABLE FU;Lo;0;L;;;;;N;;;;;\nA5A3;VAI SYLLABLE VU;Lo;0;L;;;;;N;;;;;\nA5A4;VAI SYLLABLE TU;Lo;0;L;;;;;N;;;;;\nA5A5;VAI SYLLABLE THU;Lo;0;L;;;;;N;;;;;\nA5A6;VAI SYLLABLE DHU;Lo;0;L;;;;;N;;;;;\nA5A7;VAI SYLLABLE DHHU;Lo;0;L;;;;;N;;;;;\nA5A8;VAI SYLLABLE LU;Lo;0;L;;;;;N;;;;;\nA5A9;VAI SYLLABLE RU;Lo;0;L;;;;;N;;;;;\nA5AA;VAI SYLLABLE DU;Lo;0;L;;;;;N;;;;;\nA5AB;VAI SYLLABLE NDU;Lo;0;L;;;;;N;;;;;\nA5AC;VAI SYLLABLE SU;Lo;0;L;;;;;N;;;;;\nA5AD;VAI SYLLABLE SHU;Lo;0;L;;;;;N;;;;;\nA5AE;VAI SYLLABLE ZU;Lo;0;L;;;;;N;;;;;\nA5AF;VAI SYLLABLE ZHU;Lo;0;L;;;;;N;;;;;\nA5B0;VAI SYLLABLE CU;Lo;0;L;;;;;N;;;;;\nA5B1;VAI SYLLABLE JU;Lo;0;L;;;;;N;;;;;\nA5B2;VAI SYLLABLE NJU;Lo;0;L;;;;;N;;;;;\nA5B3;VAI SYLLABLE YU;Lo;0;L;;;;;N;;;;;\nA5B4;VAI SYLLABLE KU;Lo;0;L;;;;;N;;;;;\nA5B5;VAI SYLLABLE NGGU;Lo;0;L;;;;;N;;;;;\nA5B6;VAI SYLLABLE GU;Lo;0;L;;;;;N;;;;;\nA5B7;VAI SYLLABLE MU;Lo;0;L;;;;;N;;;;;\nA5B8;VAI SYLLABLE NU;Lo;0;L;;;;;N;;;;;\nA5B9;VAI SYLLABLE NYU;Lo;0;L;;;;;N;;;;;\nA5BA;VAI SYLLABLE O;Lo;0;L;;;;;N;;;;;\nA5BB;VAI SYLLABLE ON;Lo;0;L;;;;;N;;;;;\nA5BC;VAI SYLLABLE NGON;Lo;0;L;;;;;N;;;;;\nA5BD;VAI SYLLABLE HO;Lo;0;L;;;;;N;;;;;\nA5BE;VAI SYLLABLE HON;Lo;0;L;;;;;N;;;;;\nA5BF;VAI SYLLABLE WO;Lo;0;L;;;;;N;;;;;\nA5C0;VAI SYLLABLE WON;Lo;0;L;;;;;N;;;;;\nA5C1;VAI SYLLABLE PO;Lo;0;L;;;;;N;;;;;\nA5C2;VAI SYLLABLE BHO;Lo;0;L;;;;;N;;;;;\nA5C3;VAI SYLLABLE BO;Lo;0;L;;;;;N;;;;;\nA5C4;VAI SYLLABLE MBO;Lo;0;L;;;;;N;;;;;\nA5C5;VAI SYLLABLE KPO;Lo;0;L;;;;;N;;;;;\nA5C6;VAI SYLLABLE MGBO;Lo;0;L;;;;;N;;;;;\nA5C7;VAI SYLLABLE GBO;Lo;0;L;;;;;N;;;;;\nA5C8;VAI SYLLABLE GBON;Lo;0;L;;;;;N;;;;;\nA5C9;VAI SYLLABLE FO;Lo;0;L;;;;;N;;;;;\nA5CA;VAI SYLLABLE VO;Lo;0;L;;;;;N;;;;;\nA5CB;VAI SYLLABLE TO;Lo;0;L;;;;;N;;;;;\nA5CC;VAI SYLLABLE THO;Lo;0;L;;;;;N;;;;;\nA5CD;VAI SYLLABLE DHO;Lo;0;L;;;;;N;;;;;\nA5CE;VAI SYLLABLE DHHO;Lo;0;L;;;;;N;;;;;\nA5CF;VAI SYLLABLE LO;Lo;0;L;;;;;N;;;;;\nA5D0;VAI SYLLABLE RO;Lo;0;L;;;;;N;;;;;\nA5D1;VAI SYLLABLE DO;Lo;0;L;;;;;N;;;;;\nA5D2;VAI SYLLABLE NDO;Lo;0;L;;;;;N;;;;;\nA5D3;VAI SYLLABLE SO;Lo;0;L;;;;;N;;;;;\nA5D4;VAI SYLLABLE SHO;Lo;0;L;;;;;N;;;;;\nA5D5;VAI SYLLABLE ZO;Lo;0;L;;;;;N;;;;;\nA5D6;VAI SYLLABLE ZHO;Lo;0;L;;;;;N;;;;;\nA5D7;VAI SYLLABLE CO;Lo;0;L;;;;;N;;;;;\nA5D8;VAI SYLLABLE JO;Lo;0;L;;;;;N;;;;;\nA5D9;VAI SYLLABLE NJO;Lo;0;L;;;;;N;;;;;\nA5DA;VAI SYLLABLE YO;Lo;0;L;;;;;N;;;;;\nA5DB;VAI SYLLABLE KO;Lo;0;L;;;;;N;;;;;\nA5DC;VAI SYLLABLE NGGO;Lo;0;L;;;;;N;;;;;\nA5DD;VAI SYLLABLE GO;Lo;0;L;;;;;N;;;;;\nA5DE;VAI SYLLABLE MO;Lo;0;L;;;;;N;;;;;\nA5DF;VAI SYLLABLE NO;Lo;0;L;;;;;N;;;;;\nA5E0;VAI SYLLABLE NYO;Lo;0;L;;;;;N;;;;;\nA5E1;VAI SYLLABLE E;Lo;0;L;;;;;N;;;;;\nA5E2;VAI SYLLABLE EN;Lo;0;L;;;;;N;;;;;\nA5E3;VAI SYLLABLE NGEN;Lo;0;L;;;;;N;;;;;\nA5E4;VAI SYLLABLE HE;Lo;0;L;;;;;N;;;;;\nA5E5;VAI SYLLABLE HEN;Lo;0;L;;;;;N;;;;;\nA5E6;VAI SYLLABLE WE;Lo;0;L;;;;;N;;;;;\nA5E7;VAI SYLLABLE WEN;Lo;0;L;;;;;N;;;;;\nA5E8;VAI SYLLABLE PE;Lo;0;L;;;;;N;;;;;\nA5E9;VAI SYLLABLE BHE;Lo;0;L;;;;;N;;;;;\nA5EA;VAI SYLLABLE BE;Lo;0;L;;;;;N;;;;;\nA5EB;VAI SYLLABLE MBE;Lo;0;L;;;;;N;;;;;\nA5EC;VAI SYLLABLE KPE;Lo;0;L;;;;;N;;;;;\nA5ED;VAI SYLLABLE KPEN;Lo;0;L;;;;;N;;;;;\nA5EE;VAI SYLLABLE MGBE;Lo;0;L;;;;;N;;;;;\nA5EF;VAI SYLLABLE GBE;Lo;0;L;;;;;N;;;;;\nA5F0;VAI SYLLABLE GBEN;Lo;0;L;;;;;N;;;;;\nA5F1;VAI SYLLABLE FE;Lo;0;L;;;;;N;;;;;\nA5F2;VAI SYLLABLE VE;Lo;0;L;;;;;N;;;;;\nA5F3;VAI SYLLABLE TE;Lo;0;L;;;;;N;;;;;\nA5F4;VAI SYLLABLE THE;Lo;0;L;;;;;N;;;;;\nA5F5;VAI SYLLABLE DHE;Lo;0;L;;;;;N;;;;;\nA5F6;VAI SYLLABLE DHHE;Lo;0;L;;;;;N;;;;;\nA5F7;VAI SYLLABLE LE;Lo;0;L;;;;;N;;;;;\nA5F8;VAI SYLLABLE RE;Lo;0;L;;;;;N;;;;;\nA5F9;VAI SYLLABLE DE;Lo;0;L;;;;;N;;;;;\nA5FA;VAI SYLLABLE NDE;Lo;0;L;;;;;N;;;;;\nA5FB;VAI SYLLABLE SE;Lo;0;L;;;;;N;;;;;\nA5FC;VAI SYLLABLE SHE;Lo;0;L;;;;;N;;;;;\nA5FD;VAI SYLLABLE ZE;Lo;0;L;;;;;N;;;;;\nA5FE;VAI SYLLABLE ZHE;Lo;0;L;;;;;N;;;;;\nA5FF;VAI SYLLABLE CE;Lo;0;L;;;;;N;;;;;\nA600;VAI SYLLABLE JE;Lo;0;L;;;;;N;;;;;\nA601;VAI SYLLABLE NJE;Lo;0;L;;;;;N;;;;;\nA602;VAI SYLLABLE YE;Lo;0;L;;;;;N;;;;;\nA603;VAI SYLLABLE KE;Lo;0;L;;;;;N;;;;;\nA604;VAI SYLLABLE NGGE;Lo;0;L;;;;;N;;;;;\nA605;VAI SYLLABLE NGGEN;Lo;0;L;;;;;N;;;;;\nA606;VAI SYLLABLE GE;Lo;0;L;;;;;N;;;;;\nA607;VAI SYLLABLE GEN;Lo;0;L;;;;;N;;;;;\nA608;VAI SYLLABLE ME;Lo;0;L;;;;;N;;;;;\nA609;VAI SYLLABLE NE;Lo;0;L;;;;;N;;;;;\nA60A;VAI SYLLABLE NYE;Lo;0;L;;;;;N;;;;;\nA60B;VAI SYLLABLE NG;Lo;0;L;;;;;N;;;;;\nA60C;VAI SYLLABLE LENGTHENER;Lm;0;L;;;;;N;;;;;\nA60D;VAI COMMA;Po;0;ON;;;;;N;;;;;\nA60E;VAI FULL STOP;Po;0;ON;;;;;N;;;;;\nA60F;VAI QUESTION MARK;Po;0;ON;;;;;N;;;;;\nA610;VAI SYLLABLE NDOLE FA;Lo;0;L;;;;;N;;;;;\nA611;VAI SYLLABLE NDOLE KA;Lo;0;L;;;;;N;;;;;\nA612;VAI SYLLABLE NDOLE SOO;Lo;0;L;;;;;N;;;;;\nA613;VAI SYMBOL FEENG;Lo;0;L;;;;;N;;;;;\nA614;VAI SYMBOL KEENG;Lo;0;L;;;;;N;;;;;\nA615;VAI SYMBOL TING;Lo;0;L;;;;;N;;;;;\nA616;VAI SYMBOL NII;Lo;0;L;;;;;N;;;;;\nA617;VAI SYMBOL BANG;Lo;0;L;;;;;N;;;;;\nA618;VAI SYMBOL FAA;Lo;0;L;;;;;N;;;;;\nA619;VAI SYMBOL TAA;Lo;0;L;;;;;N;;;;;\nA61A;VAI SYMBOL DANG;Lo;0;L;;;;;N;;;;;\nA61B;VAI SYMBOL DOONG;Lo;0;L;;;;;N;;;;;\nA61C;VAI SYMBOL KUNG;Lo;0;L;;;;;N;;;;;\nA61D;VAI SYMBOL TONG;Lo;0;L;;;;;N;;;;;\nA61E;VAI SYMBOL DO-O;Lo;0;L;;;;;N;;;;;\nA61F;VAI SYMBOL JONG;Lo;0;L;;;;;N;;;;;\nA620;VAI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nA621;VAI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nA622;VAI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nA623;VAI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nA624;VAI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nA625;VAI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nA626;VAI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nA627;VAI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nA628;VAI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nA629;VAI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nA62A;VAI SYLLABLE NDOLE MA;Lo;0;L;;;;;N;;;;;\nA62B;VAI SYLLABLE NDOLE DO;Lo;0;L;;;;;N;;;;;\nA640;CYRILLIC CAPITAL LETTER ZEMLYA;Lu;0;L;;;;;N;;;;A641;\nA641;CYRILLIC SMALL LETTER ZEMLYA;Ll;0;L;;;;;N;;;A640;;A640\nA642;CYRILLIC CAPITAL LETTER DZELO;Lu;0;L;;;;;N;;;;A643;\nA643;CYRILLIC SMALL LETTER DZELO;Ll;0;L;;;;;N;;;A642;;A642\nA644;CYRILLIC CAPITAL LETTER REVERSED DZE;Lu;0;L;;;;;N;;;;A645;\nA645;CYRILLIC SMALL LETTER REVERSED DZE;Ll;0;L;;;;;N;;;A644;;A644\nA646;CYRILLIC CAPITAL LETTER IOTA;Lu;0;L;;;;;N;;;;A647;\nA647;CYRILLIC SMALL LETTER IOTA;Ll;0;L;;;;;N;;;A646;;A646\nA648;CYRILLIC CAPITAL LETTER DJERV;Lu;0;L;;;;;N;;;;A649;\nA649;CYRILLIC SMALL LETTER DJERV;Ll;0;L;;;;;N;;;A648;;A648\nA64A;CYRILLIC CAPITAL LETTER MONOGRAPH UK;Lu;0;L;;;;;N;;;;A64B;\nA64B;CYRILLIC SMALL LETTER MONOGRAPH UK;Ll;0;L;;;;;N;;;A64A;;A64A\nA64C;CYRILLIC CAPITAL LETTER BROAD OMEGA;Lu;0;L;;;;;N;;;;A64D;\nA64D;CYRILLIC SMALL LETTER BROAD OMEGA;Ll;0;L;;;;;N;;;A64C;;A64C\nA64E;CYRILLIC CAPITAL LETTER NEUTRAL YER;Lu;0;L;;;;;N;;;;A64F;\nA64F;CYRILLIC SMALL LETTER NEUTRAL YER;Ll;0;L;;;;;N;;;A64E;;A64E\nA650;CYRILLIC CAPITAL LETTER YERU WITH BACK YER;Lu;0;L;;;;;N;;;;A651;\nA651;CYRILLIC SMALL LETTER YERU WITH BACK YER;Ll;0;L;;;;;N;;;A650;;A650\nA652;CYRILLIC CAPITAL LETTER IOTIFIED YAT;Lu;0;L;;;;;N;;;;A653;\nA653;CYRILLIC SMALL LETTER IOTIFIED YAT;Ll;0;L;;;;;N;;;A652;;A652\nA654;CYRILLIC CAPITAL LETTER REVERSED YU;Lu;0;L;;;;;N;;;;A655;\nA655;CYRILLIC SMALL LETTER REVERSED YU;Ll;0;L;;;;;N;;;A654;;A654\nA656;CYRILLIC CAPITAL LETTER IOTIFIED A;Lu;0;L;;;;;N;;;;A657;\nA657;CYRILLIC SMALL LETTER IOTIFIED A;Ll;0;L;;;;;N;;;A656;;A656\nA658;CYRILLIC CAPITAL LETTER CLOSED LITTLE YUS;Lu;0;L;;;;;N;;;;A659;\nA659;CYRILLIC SMALL LETTER CLOSED LITTLE YUS;Ll;0;L;;;;;N;;;A658;;A658\nA65A;CYRILLIC CAPITAL LETTER BLENDED YUS;Lu;0;L;;;;;N;;;;A65B;\nA65B;CYRILLIC SMALL LETTER BLENDED YUS;Ll;0;L;;;;;N;;;A65A;;A65A\nA65C;CYRILLIC CAPITAL LETTER IOTIFIED CLOSED LITTLE YUS;Lu;0;L;;;;;N;;;;A65D;\nA65D;CYRILLIC SMALL LETTER IOTIFIED CLOSED LITTLE YUS;Ll;0;L;;;;;N;;;A65C;;A65C\nA65E;CYRILLIC CAPITAL LETTER YN;Lu;0;L;;;;;N;;;;A65F;\nA65F;CYRILLIC SMALL LETTER YN;Ll;0;L;;;;;N;;;A65E;;A65E\nA660;CYRILLIC CAPITAL LETTER REVERSED TSE;Lu;0;L;;;;;N;;;;A661;\nA661;CYRILLIC SMALL LETTER REVERSED TSE;Ll;0;L;;;;;N;;;A660;;A660\nA662;CYRILLIC CAPITAL LETTER SOFT DE;Lu;0;L;;;;;N;;;;A663;\nA663;CYRILLIC SMALL LETTER SOFT DE;Ll;0;L;;;;;N;;;A662;;A662\nA664;CYRILLIC CAPITAL LETTER SOFT EL;Lu;0;L;;;;;N;;;;A665;\nA665;CYRILLIC SMALL LETTER SOFT EL;Ll;0;L;;;;;N;;;A664;;A664\nA666;CYRILLIC CAPITAL LETTER SOFT EM;Lu;0;L;;;;;N;;;;A667;\nA667;CYRILLIC SMALL LETTER SOFT EM;Ll;0;L;;;;;N;;;A666;;A666\nA668;CYRILLIC CAPITAL LETTER MONOCULAR O;Lu;0;L;;;;;N;;;;A669;\nA669;CYRILLIC SMALL LETTER MONOCULAR O;Ll;0;L;;;;;N;;;A668;;A668\nA66A;CYRILLIC CAPITAL LETTER BINOCULAR O;Lu;0;L;;;;;N;;;;A66B;\nA66B;CYRILLIC SMALL LETTER BINOCULAR O;Ll;0;L;;;;;N;;;A66A;;A66A\nA66C;CYRILLIC CAPITAL LETTER DOUBLE MONOCULAR O;Lu;0;L;;;;;N;;;;A66D;\nA66D;CYRILLIC SMALL LETTER DOUBLE MONOCULAR O;Ll;0;L;;;;;N;;;A66C;;A66C\nA66E;CYRILLIC LETTER MULTIOCULAR O;Lo;0;L;;;;;N;;;;;\nA66F;COMBINING CYRILLIC VZMET;Mn;230;NSM;;;;;N;;;;;\nA670;COMBINING CYRILLIC TEN MILLIONS SIGN;Me;0;NSM;;;;;N;;;;;\nA671;COMBINING CYRILLIC HUNDRED MILLIONS SIGN;Me;0;NSM;;;;;N;;;;;\nA672;COMBINING CYRILLIC THOUSAND MILLIONS SIGN;Me;0;NSM;;;;;N;;;;;\nA673;SLAVONIC ASTERISK;Po;0;ON;;;;;N;;;;;\nA674;COMBINING CYRILLIC LETTER UKRAINIAN IE;Mn;230;NSM;;;;;N;;;;;\nA675;COMBINING CYRILLIC LETTER I;Mn;230;NSM;;;;;N;;;;;\nA676;COMBINING CYRILLIC LETTER YI;Mn;230;NSM;;;;;N;;;;;\nA677;COMBINING CYRILLIC LETTER U;Mn;230;NSM;;;;;N;;;;;\nA678;COMBINING CYRILLIC LETTER HARD SIGN;Mn;230;NSM;;;;;N;;;;;\nA679;COMBINING CYRILLIC LETTER YERU;Mn;230;NSM;;;;;N;;;;;\nA67A;COMBINING CYRILLIC LETTER SOFT SIGN;Mn;230;NSM;;;;;N;;;;;\nA67B;COMBINING CYRILLIC LETTER OMEGA;Mn;230;NSM;;;;;N;;;;;\nA67C;COMBINING CYRILLIC KAVYKA;Mn;230;NSM;;;;;N;;;;;\nA67D;COMBINING CYRILLIC PAYEROK;Mn;230;NSM;;;;;N;;;;;\nA67E;CYRILLIC KAVYKA;Po;0;ON;;;;;N;;;;;\nA67F;CYRILLIC PAYEROK;Lm;0;ON;;;;;N;;;;;\nA680;CYRILLIC CAPITAL LETTER DWE;Lu;0;L;;;;;N;;;;A681;\nA681;CYRILLIC SMALL LETTER DWE;Ll;0;L;;;;;N;;;A680;;A680\nA682;CYRILLIC CAPITAL LETTER DZWE;Lu;0;L;;;;;N;;;;A683;\nA683;CYRILLIC SMALL LETTER DZWE;Ll;0;L;;;;;N;;;A682;;A682\nA684;CYRILLIC CAPITAL LETTER ZHWE;Lu;0;L;;;;;N;;;;A685;\nA685;CYRILLIC SMALL LETTER ZHWE;Ll;0;L;;;;;N;;;A684;;A684\nA686;CYRILLIC CAPITAL LETTER CCHE;Lu;0;L;;;;;N;;;;A687;\nA687;CYRILLIC SMALL LETTER CCHE;Ll;0;L;;;;;N;;;A686;;A686\nA688;CYRILLIC CAPITAL LETTER DZZE;Lu;0;L;;;;;N;;;;A689;\nA689;CYRILLIC SMALL LETTER DZZE;Ll;0;L;;;;;N;;;A688;;A688\nA68A;CYRILLIC CAPITAL LETTER TE WITH MIDDLE HOOK;Lu;0;L;;;;;N;;;;A68B;\nA68B;CYRILLIC SMALL LETTER TE WITH MIDDLE HOOK;Ll;0;L;;;;;N;;;A68A;;A68A\nA68C;CYRILLIC CAPITAL LETTER TWE;Lu;0;L;;;;;N;;;;A68D;\nA68D;CYRILLIC SMALL LETTER TWE;Ll;0;L;;;;;N;;;A68C;;A68C\nA68E;CYRILLIC CAPITAL LETTER TSWE;Lu;0;L;;;;;N;;;;A68F;\nA68F;CYRILLIC SMALL LETTER TSWE;Ll;0;L;;;;;N;;;A68E;;A68E\nA690;CYRILLIC CAPITAL LETTER TSSE;Lu;0;L;;;;;N;;;;A691;\nA691;CYRILLIC SMALL LETTER TSSE;Ll;0;L;;;;;N;;;A690;;A690\nA692;CYRILLIC CAPITAL LETTER TCHE;Lu;0;L;;;;;N;;;;A693;\nA693;CYRILLIC SMALL LETTER TCHE;Ll;0;L;;;;;N;;;A692;;A692\nA694;CYRILLIC CAPITAL LETTER HWE;Lu;0;L;;;;;N;;;;A695;\nA695;CYRILLIC SMALL LETTER HWE;Ll;0;L;;;;;N;;;A694;;A694\nA696;CYRILLIC CAPITAL LETTER SHWE;Lu;0;L;;;;;N;;;;A697;\nA697;CYRILLIC SMALL LETTER SHWE;Ll;0;L;;;;;N;;;A696;;A696\nA69F;COMBINING CYRILLIC LETTER IOTIFIED E;Mn;230;NSM;;;;;N;;;;;\nA6A0;BAMUM LETTER A;Lo;0;L;;;;;N;;;;;\nA6A1;BAMUM LETTER KA;Lo;0;L;;;;;N;;;;;\nA6A2;BAMUM LETTER U;Lo;0;L;;;;;N;;;;;\nA6A3;BAMUM LETTER KU;Lo;0;L;;;;;N;;;;;\nA6A4;BAMUM LETTER EE;Lo;0;L;;;;;N;;;;;\nA6A5;BAMUM LETTER REE;Lo;0;L;;;;;N;;;;;\nA6A6;BAMUM LETTER TAE;Lo;0;L;;;;;N;;;;;\nA6A7;BAMUM LETTER O;Lo;0;L;;;;;N;;;;;\nA6A8;BAMUM LETTER NYI;Lo;0;L;;;;;N;;;;;\nA6A9;BAMUM LETTER I;Lo;0;L;;;;;N;;;;;\nA6AA;BAMUM LETTER LA;Lo;0;L;;;;;N;;;;;\nA6AB;BAMUM LETTER PA;Lo;0;L;;;;;N;;;;;\nA6AC;BAMUM LETTER RII;Lo;0;L;;;;;N;;;;;\nA6AD;BAMUM LETTER RIEE;Lo;0;L;;;;;N;;;;;\nA6AE;BAMUM LETTER LEEEE;Lo;0;L;;;;;N;;;;;\nA6AF;BAMUM LETTER MEEEE;Lo;0;L;;;;;N;;;;;\nA6B0;BAMUM LETTER TAA;Lo;0;L;;;;;N;;;;;\nA6B1;BAMUM LETTER NDAA;Lo;0;L;;;;;N;;;;;\nA6B2;BAMUM LETTER NJAEM;Lo;0;L;;;;;N;;;;;\nA6B3;BAMUM LETTER M;Lo;0;L;;;;;N;;;;;\nA6B4;BAMUM LETTER SUU;Lo;0;L;;;;;N;;;;;\nA6B5;BAMUM LETTER MU;Lo;0;L;;;;;N;;;;;\nA6B6;BAMUM LETTER SHII;Lo;0;L;;;;;N;;;;;\nA6B7;BAMUM LETTER SI;Lo;0;L;;;;;N;;;;;\nA6B8;BAMUM LETTER SHEUX;Lo;0;L;;;;;N;;;;;\nA6B9;BAMUM LETTER SEUX;Lo;0;L;;;;;N;;;;;\nA6BA;BAMUM LETTER KYEE;Lo;0;L;;;;;N;;;;;\nA6BB;BAMUM LETTER KET;Lo;0;L;;;;;N;;;;;\nA6BC;BAMUM LETTER NUAE;Lo;0;L;;;;;N;;;;;\nA6BD;BAMUM LETTER NU;Lo;0;L;;;;;N;;;;;\nA6BE;BAMUM LETTER NJUAE;Lo;0;L;;;;;N;;;;;\nA6BF;BAMUM LETTER YOQ;Lo;0;L;;;;;N;;;;;\nA6C0;BAMUM LETTER SHU;Lo;0;L;;;;;N;;;;;\nA6C1;BAMUM LETTER YUQ;Lo;0;L;;;;;N;;;;;\nA6C2;BAMUM LETTER YA;Lo;0;L;;;;;N;;;;;\nA6C3;BAMUM LETTER NSHA;Lo;0;L;;;;;N;;;;;\nA6C4;BAMUM LETTER KEUX;Lo;0;L;;;;;N;;;;;\nA6C5;BAMUM LETTER PEUX;Lo;0;L;;;;;N;;;;;\nA6C6;BAMUM LETTER NJEE;Lo;0;L;;;;;N;;;;;\nA6C7;BAMUM LETTER NTEE;Lo;0;L;;;;;N;;;;;\nA6C8;BAMUM LETTER PUE;Lo;0;L;;;;;N;;;;;\nA6C9;BAMUM LETTER WUE;Lo;0;L;;;;;N;;;;;\nA6CA;BAMUM LETTER PEE;Lo;0;L;;;;;N;;;;;\nA6CB;BAMUM LETTER FEE;Lo;0;L;;;;;N;;;;;\nA6CC;BAMUM LETTER RU;Lo;0;L;;;;;N;;;;;\nA6CD;BAMUM LETTER LU;Lo;0;L;;;;;N;;;;;\nA6CE;BAMUM LETTER MI;Lo;0;L;;;;;N;;;;;\nA6CF;BAMUM LETTER NI;Lo;0;L;;;;;N;;;;;\nA6D0;BAMUM LETTER REUX;Lo;0;L;;;;;N;;;;;\nA6D1;BAMUM LETTER RAE;Lo;0;L;;;;;N;;;;;\nA6D2;BAMUM LETTER KEN;Lo;0;L;;;;;N;;;;;\nA6D3;BAMUM LETTER NGKWAEN;Lo;0;L;;;;;N;;;;;\nA6D4;BAMUM LETTER NGGA;Lo;0;L;;;;;N;;;;;\nA6D5;BAMUM LETTER NGA;Lo;0;L;;;;;N;;;;;\nA6D6;BAMUM LETTER SHO;Lo;0;L;;;;;N;;;;;\nA6D7;BAMUM LETTER PUAE;Lo;0;L;;;;;N;;;;;\nA6D8;BAMUM LETTER FU;Lo;0;L;;;;;N;;;;;\nA6D9;BAMUM LETTER FOM;Lo;0;L;;;;;N;;;;;\nA6DA;BAMUM LETTER WA;Lo;0;L;;;;;N;;;;;\nA6DB;BAMUM LETTER NA;Lo;0;L;;;;;N;;;;;\nA6DC;BAMUM LETTER LI;Lo;0;L;;;;;N;;;;;\nA6DD;BAMUM LETTER PI;Lo;0;L;;;;;N;;;;;\nA6DE;BAMUM LETTER LOQ;Lo;0;L;;;;;N;;;;;\nA6DF;BAMUM LETTER KO;Lo;0;L;;;;;N;;;;;\nA6E0;BAMUM LETTER MBEN;Lo;0;L;;;;;N;;;;;\nA6E1;BAMUM LETTER REN;Lo;0;L;;;;;N;;;;;\nA6E2;BAMUM LETTER MEN;Lo;0;L;;;;;N;;;;;\nA6E3;BAMUM LETTER MA;Lo;0;L;;;;;N;;;;;\nA6E4;BAMUM LETTER TI;Lo;0;L;;;;;N;;;;;\nA6E5;BAMUM LETTER KI;Lo;0;L;;;;;N;;;;;\nA6E6;BAMUM LETTER MO;Nl;0;L;;;;1;N;;;;;\nA6E7;BAMUM LETTER MBAA;Nl;0;L;;;;2;N;;;;;\nA6E8;BAMUM LETTER TET;Nl;0;L;;;;3;N;;;;;\nA6E9;BAMUM LETTER KPA;Nl;0;L;;;;4;N;;;;;\nA6EA;BAMUM LETTER TEN;Nl;0;L;;;;5;N;;;;;\nA6EB;BAMUM LETTER NTUU;Nl;0;L;;;;6;N;;;;;\nA6EC;BAMUM LETTER SAMBA;Nl;0;L;;;;7;N;;;;;\nA6ED;BAMUM LETTER FAAMAE;Nl;0;L;;;;8;N;;;;;\nA6EE;BAMUM LETTER KOVUU;Nl;0;L;;;;9;N;;;;;\nA6EF;BAMUM LETTER KOGHOM;Nl;0;L;;;;0;N;;;;;\nA6F0;BAMUM COMBINING MARK KOQNDON;Mn;230;NSM;;;;;N;;;;;\nA6F1;BAMUM COMBINING MARK TUKWENTIS;Mn;230;NSM;;;;;N;;;;;\nA6F2;BAMUM NJAEMLI;Po;0;L;;;;;N;;;;;\nA6F3;BAMUM FULL STOP;Po;0;L;;;;;N;;;;;\nA6F4;BAMUM COLON;Po;0;L;;;;;N;;;;;\nA6F5;BAMUM COMMA;Po;0;L;;;;;N;;;;;\nA6F6;BAMUM SEMICOLON;Po;0;L;;;;;N;;;;;\nA6F7;BAMUM QUESTION MARK;Po;0;L;;;;;N;;;;;\nA700;MODIFIER LETTER CHINESE TONE YIN PING;Sk;0;ON;;;;;N;;;;;\nA701;MODIFIER LETTER CHINESE TONE YANG PING;Sk;0;ON;;;;;N;;;;;\nA702;MODIFIER LETTER CHINESE TONE YIN SHANG;Sk;0;ON;;;;;N;;;;;\nA703;MODIFIER LETTER CHINESE TONE YANG SHANG;Sk;0;ON;;;;;N;;;;;\nA704;MODIFIER LETTER CHINESE TONE YIN QU;Sk;0;ON;;;;;N;;;;;\nA705;MODIFIER LETTER CHINESE TONE YANG QU;Sk;0;ON;;;;;N;;;;;\nA706;MODIFIER LETTER CHINESE TONE YIN RU;Sk;0;ON;;;;;N;;;;;\nA707;MODIFIER LETTER CHINESE TONE YANG RU;Sk;0;ON;;;;;N;;;;;\nA708;MODIFIER LETTER EXTRA-HIGH DOTTED TONE BAR;Sk;0;ON;;;;;N;;;;;\nA709;MODIFIER LETTER HIGH DOTTED TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70A;MODIFIER LETTER MID DOTTED TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70B;MODIFIER LETTER LOW DOTTED TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70C;MODIFIER LETTER EXTRA-LOW DOTTED TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70D;MODIFIER LETTER EXTRA-HIGH DOTTED LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70E;MODIFIER LETTER HIGH DOTTED LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA70F;MODIFIER LETTER MID DOTTED LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA710;MODIFIER LETTER LOW DOTTED LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA711;MODIFIER LETTER EXTRA-LOW DOTTED LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA712;MODIFIER LETTER EXTRA-HIGH LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA713;MODIFIER LETTER HIGH LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA714;MODIFIER LETTER MID LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA715;MODIFIER LETTER LOW LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA716;MODIFIER LETTER EXTRA-LOW LEFT-STEM TONE BAR;Sk;0;ON;;;;;N;;;;;\nA717;MODIFIER LETTER DOT VERTICAL BAR;Lm;0;ON;;;;;N;;;;;\nA718;MODIFIER LETTER DOT SLASH;Lm;0;ON;;;;;N;;;;;\nA719;MODIFIER LETTER DOT HORIZONTAL BAR;Lm;0;ON;;;;;N;;;;;\nA71A;MODIFIER LETTER LOWER RIGHT CORNER ANGLE;Lm;0;ON;;;;;N;;;;;\nA71B;MODIFIER LETTER RAISED UP ARROW;Lm;0;ON;;;;;N;;;;;\nA71C;MODIFIER LETTER RAISED DOWN ARROW;Lm;0;ON;;;;;N;;;;;\nA71D;MODIFIER LETTER RAISED EXCLAMATION MARK;Lm;0;ON;;;;;N;;;;;\nA71E;MODIFIER LETTER RAISED INVERTED EXCLAMATION MARK;Lm;0;ON;;;;;N;;;;;\nA71F;MODIFIER LETTER LOW INVERTED EXCLAMATION MARK;Lm;0;ON;;;;;N;;;;;\nA720;MODIFIER LETTER STRESS AND HIGH TONE;Sk;0;ON;;;;;N;;;;;\nA721;MODIFIER LETTER STRESS AND LOW TONE;Sk;0;ON;;;;;N;;;;;\nA722;LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF;Lu;0;L;;;;;N;;;;A723;\nA723;LATIN SMALL LETTER EGYPTOLOGICAL ALEF;Ll;0;L;;;;;N;;;A722;;A722\nA724;LATIN CAPITAL LETTER EGYPTOLOGICAL AIN;Lu;0;L;;;;;N;;;;A725;\nA725;LATIN SMALL LETTER EGYPTOLOGICAL AIN;Ll;0;L;;;;;N;;;A724;;A724\nA726;LATIN CAPITAL LETTER HENG;Lu;0;L;;;;;N;;;;A727;\nA727;LATIN SMALL LETTER HENG;Ll;0;L;;;;;N;;;A726;;A726\nA728;LATIN CAPITAL LETTER TZ;Lu;0;L;;;;;N;;;;A729;\nA729;LATIN SMALL LETTER TZ;Ll;0;L;;;;;N;;;A728;;A728\nA72A;LATIN CAPITAL LETTER TRESILLO;Lu;0;L;;;;;N;;;;A72B;\nA72B;LATIN SMALL LETTER TRESILLO;Ll;0;L;;;;;N;;;A72A;;A72A\nA72C;LATIN CAPITAL LETTER CUATRILLO;Lu;0;L;;;;;N;;;;A72D;\nA72D;LATIN SMALL LETTER CUATRILLO;Ll;0;L;;;;;N;;;A72C;;A72C\nA72E;LATIN CAPITAL LETTER CUATRILLO WITH COMMA;Lu;0;L;;;;;N;;;;A72F;\nA72F;LATIN SMALL LETTER CUATRILLO WITH COMMA;Ll;0;L;;;;;N;;;A72E;;A72E\nA730;LATIN LETTER SMALL CAPITAL F;Ll;0;L;;;;;N;;;;;\nA731;LATIN LETTER SMALL CAPITAL S;Ll;0;L;;;;;N;;;;;\nA732;LATIN CAPITAL LETTER AA;Lu;0;L;;;;;N;;;;A733;\nA733;LATIN SMALL LETTER AA;Ll;0;L;;;;;N;;;A732;;A732\nA734;LATIN CAPITAL LETTER AO;Lu;0;L;;;;;N;;;;A735;\nA735;LATIN SMALL LETTER AO;Ll;0;L;;;;;N;;;A734;;A734\nA736;LATIN CAPITAL LETTER AU;Lu;0;L;;;;;N;;;;A737;\nA737;LATIN SMALL LETTER AU;Ll;0;L;;;;;N;;;A736;;A736\nA738;LATIN CAPITAL LETTER AV;Lu;0;L;;;;;N;;;;A739;\nA739;LATIN SMALL LETTER AV;Ll;0;L;;;;;N;;;A738;;A738\nA73A;LATIN CAPITAL LETTER AV WITH HORIZONTAL BAR;Lu;0;L;;;;;N;;;;A73B;\nA73B;LATIN SMALL LETTER AV WITH HORIZONTAL BAR;Ll;0;L;;;;;N;;;A73A;;A73A\nA73C;LATIN CAPITAL LETTER AY;Lu;0;L;;;;;N;;;;A73D;\nA73D;LATIN SMALL LETTER AY;Ll;0;L;;;;;N;;;A73C;;A73C\nA73E;LATIN CAPITAL LETTER REVERSED C WITH DOT;Lu;0;L;;;;;N;;;;A73F;\nA73F;LATIN SMALL LETTER REVERSED C WITH DOT;Ll;0;L;;;;;N;;;A73E;;A73E\nA740;LATIN CAPITAL LETTER K WITH STROKE;Lu;0;L;;;;;N;;;;A741;\nA741;LATIN SMALL LETTER K WITH STROKE;Ll;0;L;;;;;N;;;A740;;A740\nA742;LATIN CAPITAL LETTER K WITH DIAGONAL STROKE;Lu;0;L;;;;;N;;;;A743;\nA743;LATIN SMALL LETTER K WITH DIAGONAL STROKE;Ll;0;L;;;;;N;;;A742;;A742\nA744;LATIN CAPITAL LETTER K WITH STROKE AND DIAGONAL STROKE;Lu;0;L;;;;;N;;;;A745;\nA745;LATIN SMALL LETTER K WITH STROKE AND DIAGONAL STROKE;Ll;0;L;;;;;N;;;A744;;A744\nA746;LATIN CAPITAL LETTER BROKEN L;Lu;0;L;;;;;N;;;;A747;\nA747;LATIN SMALL LETTER BROKEN L;Ll;0;L;;;;;N;;;A746;;A746\nA748;LATIN CAPITAL LETTER L WITH HIGH STROKE;Lu;0;L;;;;;N;;;;A749;\nA749;LATIN SMALL LETTER L WITH HIGH STROKE;Ll;0;L;;;;;N;;;A748;;A748\nA74A;LATIN CAPITAL LETTER O WITH LONG STROKE OVERLAY;Lu;0;L;;;;;N;;;;A74B;\nA74B;LATIN SMALL LETTER O WITH LONG STROKE OVERLAY;Ll;0;L;;;;;N;;;A74A;;A74A\nA74C;LATIN CAPITAL LETTER O WITH LOOP;Lu;0;L;;;;;N;;;;A74D;\nA74D;LATIN SMALL LETTER O WITH LOOP;Ll;0;L;;;;;N;;;A74C;;A74C\nA74E;LATIN CAPITAL LETTER OO;Lu;0;L;;;;;N;;;;A74F;\nA74F;LATIN SMALL LETTER OO;Ll;0;L;;;;;N;;;A74E;;A74E\nA750;LATIN CAPITAL LETTER P WITH STROKE THROUGH DESCENDER;Lu;0;L;;;;;N;;;;A751;\nA751;LATIN SMALL LETTER P WITH STROKE THROUGH DESCENDER;Ll;0;L;;;;;N;;;A750;;A750\nA752;LATIN CAPITAL LETTER P WITH FLOURISH;Lu;0;L;;;;;N;;;;A753;\nA753;LATIN SMALL LETTER P WITH FLOURISH;Ll;0;L;;;;;N;;;A752;;A752\nA754;LATIN CAPITAL LETTER P WITH SQUIRREL TAIL;Lu;0;L;;;;;N;;;;A755;\nA755;LATIN SMALL LETTER P WITH SQUIRREL TAIL;Ll;0;L;;;;;N;;;A754;;A754\nA756;LATIN CAPITAL LETTER Q WITH STROKE THROUGH DESCENDER;Lu;0;L;;;;;N;;;;A757;\nA757;LATIN SMALL LETTER Q WITH STROKE THROUGH DESCENDER;Ll;0;L;;;;;N;;;A756;;A756\nA758;LATIN CAPITAL LETTER Q WITH DIAGONAL STROKE;Lu;0;L;;;;;N;;;;A759;\nA759;LATIN SMALL LETTER Q WITH DIAGONAL STROKE;Ll;0;L;;;;;N;;;A758;;A758\nA75A;LATIN CAPITAL LETTER R ROTUNDA;Lu;0;L;;;;;N;;;;A75B;\nA75B;LATIN SMALL LETTER R ROTUNDA;Ll;0;L;;;;;N;;;A75A;;A75A\nA75C;LATIN CAPITAL LETTER RUM ROTUNDA;Lu;0;L;;;;;N;;;;A75D;\nA75D;LATIN SMALL LETTER RUM ROTUNDA;Ll;0;L;;;;;N;;;A75C;;A75C\nA75E;LATIN CAPITAL LETTER V WITH DIAGONAL STROKE;Lu;0;L;;;;;N;;;;A75F;\nA75F;LATIN SMALL LETTER V WITH DIAGONAL STROKE;Ll;0;L;;;;;N;;;A75E;;A75E\nA760;LATIN CAPITAL LETTER VY;Lu;0;L;;;;;N;;;;A761;\nA761;LATIN SMALL LETTER VY;Ll;0;L;;;;;N;;;A760;;A760\nA762;LATIN CAPITAL LETTER VISIGOTHIC Z;Lu;0;L;;;;;N;;;;A763;\nA763;LATIN SMALL LETTER VISIGOTHIC Z;Ll;0;L;;;;;N;;;A762;;A762\nA764;LATIN CAPITAL LETTER THORN WITH STROKE;Lu;0;L;;;;;N;;;;A765;\nA765;LATIN SMALL LETTER THORN WITH STROKE;Ll;0;L;;;;;N;;;A764;;A764\nA766;LATIN CAPITAL LETTER THORN WITH STROKE THROUGH DESCENDER;Lu;0;L;;;;;N;;;;A767;\nA767;LATIN SMALL LETTER THORN WITH STROKE THROUGH DESCENDER;Ll;0;L;;;;;N;;;A766;;A766\nA768;LATIN CAPITAL LETTER VEND;Lu;0;L;;;;;N;;;;A769;\nA769;LATIN SMALL LETTER VEND;Ll;0;L;;;;;N;;;A768;;A768\nA76A;LATIN CAPITAL LETTER ET;Lu;0;L;;;;;N;;;;A76B;\nA76B;LATIN SMALL LETTER ET;Ll;0;L;;;;;N;;;A76A;;A76A\nA76C;LATIN CAPITAL LETTER IS;Lu;0;L;;;;;N;;;;A76D;\nA76D;LATIN SMALL LETTER IS;Ll;0;L;;;;;N;;;A76C;;A76C\nA76E;LATIN CAPITAL LETTER CON;Lu;0;L;;;;;N;;;;A76F;\nA76F;LATIN SMALL LETTER CON;Ll;0;L;;;;;N;;;A76E;;A76E\nA770;MODIFIER LETTER US;Lm;0;L;<super> A76F;;;;N;;;;;\nA771;LATIN SMALL LETTER DUM;Ll;0;L;;;;;N;;;;;\nA772;LATIN SMALL LETTER LUM;Ll;0;L;;;;;N;;;;;\nA773;LATIN SMALL LETTER MUM;Ll;0;L;;;;;N;;;;;\nA774;LATIN SMALL LETTER NUM;Ll;0;L;;;;;N;;;;;\nA775;LATIN SMALL LETTER RUM;Ll;0;L;;;;;N;;;;;\nA776;LATIN LETTER SMALL CAPITAL RUM;Ll;0;L;;;;;N;;;;;\nA777;LATIN SMALL LETTER TUM;Ll;0;L;;;;;N;;;;;\nA778;LATIN SMALL LETTER UM;Ll;0;L;;;;;N;;;;;\nA779;LATIN CAPITAL LETTER INSULAR D;Lu;0;L;;;;;N;;;;A77A;\nA77A;LATIN SMALL LETTER INSULAR D;Ll;0;L;;;;;N;;;A779;;A779\nA77B;LATIN CAPITAL LETTER INSULAR F;Lu;0;L;;;;;N;;;;A77C;\nA77C;LATIN SMALL LETTER INSULAR F;Ll;0;L;;;;;N;;;A77B;;A77B\nA77D;LATIN CAPITAL LETTER INSULAR G;Lu;0;L;;;;;N;;;;1D79;\nA77E;LATIN CAPITAL LETTER TURNED INSULAR G;Lu;0;L;;;;;N;;;;A77F;\nA77F;LATIN SMALL LETTER TURNED INSULAR G;Ll;0;L;;;;;N;;;A77E;;A77E\nA780;LATIN CAPITAL LETTER TURNED L;Lu;0;L;;;;;N;;;;A781;\nA781;LATIN SMALL LETTER TURNED L;Ll;0;L;;;;;N;;;A780;;A780\nA782;LATIN CAPITAL LETTER INSULAR R;Lu;0;L;;;;;N;;;;A783;\nA783;LATIN SMALL LETTER INSULAR R;Ll;0;L;;;;;N;;;A782;;A782\nA784;LATIN CAPITAL LETTER INSULAR S;Lu;0;L;;;;;N;;;;A785;\nA785;LATIN SMALL LETTER INSULAR S;Ll;0;L;;;;;N;;;A784;;A784\nA786;LATIN CAPITAL LETTER INSULAR T;Lu;0;L;;;;;N;;;;A787;\nA787;LATIN SMALL LETTER INSULAR T;Ll;0;L;;;;;N;;;A786;;A786\nA788;MODIFIER LETTER LOW CIRCUMFLEX ACCENT;Lm;0;ON;;;;;N;;;;;\nA789;MODIFIER LETTER COLON;Sk;0;L;;;;;N;;;;;\nA78A;MODIFIER LETTER SHORT EQUALS SIGN;Sk;0;L;;;;;N;;;;;\nA78B;LATIN CAPITAL LETTER SALTILLO;Lu;0;L;;;;;N;;;;A78C;\nA78C;LATIN SMALL LETTER SALTILLO;Ll;0;L;;;;;N;;;A78B;;A78B\nA78D;LATIN CAPITAL LETTER TURNED H;Lu;0;L;;;;;N;;;;0265;\nA78E;LATIN SMALL LETTER L WITH RETROFLEX HOOK AND BELT;Ll;0;L;;;;;N;;;;;\nA790;LATIN CAPITAL LETTER N WITH DESCENDER;Lu;0;L;;;;;N;;;;A791;\nA791;LATIN SMALL LETTER N WITH DESCENDER;Ll;0;L;;;;;N;;;A790;;A790\nA792;LATIN CAPITAL LETTER C WITH BAR;Lu;0;L;;;;;N;;;;A793;\nA793;LATIN SMALL LETTER C WITH BAR;Ll;0;L;;;;;N;;;A792;;A792\nA7A0;LATIN CAPITAL LETTER G WITH OBLIQUE STROKE;Lu;0;L;;;;;N;;;;A7A1;\nA7A1;LATIN SMALL LETTER G WITH OBLIQUE STROKE;Ll;0;L;;;;;N;;;A7A0;;A7A0\nA7A2;LATIN CAPITAL LETTER K WITH OBLIQUE STROKE;Lu;0;L;;;;;N;;;;A7A3;\nA7A3;LATIN SMALL LETTER K WITH OBLIQUE STROKE;Ll;0;L;;;;;N;;;A7A2;;A7A2\nA7A4;LATIN CAPITAL LETTER N WITH OBLIQUE STROKE;Lu;0;L;;;;;N;;;;A7A5;\nA7A5;LATIN SMALL LETTER N WITH OBLIQUE STROKE;Ll;0;L;;;;;N;;;A7A4;;A7A4\nA7A6;LATIN CAPITAL LETTER R WITH OBLIQUE STROKE;Lu;0;L;;;;;N;;;;A7A7;\nA7A7;LATIN SMALL LETTER R WITH OBLIQUE STROKE;Ll;0;L;;;;;N;;;A7A6;;A7A6\nA7A8;LATIN CAPITAL LETTER S WITH OBLIQUE STROKE;Lu;0;L;;;;;N;;;;A7A9;\nA7A9;LATIN SMALL LETTER S WITH OBLIQUE STROKE;Ll;0;L;;;;;N;;;A7A8;;A7A8\nA7AA;LATIN CAPITAL LETTER H WITH HOOK;Lu;0;L;;;;;N;;;;0266;\nA7F8;MODIFIER LETTER CAPITAL H WITH STROKE;Lm;0;L;<super> 0126;;;;N;;;;;\nA7F9;MODIFIER LETTER SMALL LIGATURE OE;Lm;0;L;<super> 0153;;;;N;;;;;\nA7FA;LATIN LETTER SMALL CAPITAL TURNED M;Ll;0;L;;;;;N;;;;;\nA7FB;LATIN EPIGRAPHIC LETTER REVERSED F;Lo;0;L;;;;;N;;;;;\nA7FC;LATIN EPIGRAPHIC LETTER REVERSED P;Lo;0;L;;;;;N;;;;;\nA7FD;LATIN EPIGRAPHIC LETTER INVERTED M;Lo;0;L;;;;;N;;;;;\nA7FE;LATIN EPIGRAPHIC LETTER I LONGA;Lo;0;L;;;;;N;;;;;\nA7FF;LATIN EPIGRAPHIC LETTER ARCHAIC M;Lo;0;L;;;;;N;;;;;\nA800;SYLOTI NAGRI LETTER A;Lo;0;L;;;;;N;;;;;\nA801;SYLOTI NAGRI LETTER I;Lo;0;L;;;;;N;;;;;\nA802;SYLOTI NAGRI SIGN DVISVARA;Mn;0;NSM;;;;;N;;;;;\nA803;SYLOTI NAGRI LETTER U;Lo;0;L;;;;;N;;;;;\nA804;SYLOTI NAGRI LETTER E;Lo;0;L;;;;;N;;;;;\nA805;SYLOTI NAGRI LETTER O;Lo;0;L;;;;;N;;;;;\nA806;SYLOTI NAGRI SIGN HASANTA;Mn;9;NSM;;;;;N;;;;;\nA807;SYLOTI NAGRI LETTER KO;Lo;0;L;;;;;N;;;;;\nA808;SYLOTI NAGRI LETTER KHO;Lo;0;L;;;;;N;;;;;\nA809;SYLOTI NAGRI LETTER GO;Lo;0;L;;;;;N;;;;;\nA80A;SYLOTI NAGRI LETTER GHO;Lo;0;L;;;;;N;;;;;\nA80B;SYLOTI NAGRI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\nA80C;SYLOTI NAGRI LETTER CO;Lo;0;L;;;;;N;;;;;\nA80D;SYLOTI NAGRI LETTER CHO;Lo;0;L;;;;;N;;;;;\nA80E;SYLOTI NAGRI LETTER JO;Lo;0;L;;;;;N;;;;;\nA80F;SYLOTI NAGRI LETTER JHO;Lo;0;L;;;;;N;;;;;\nA810;SYLOTI NAGRI LETTER TTO;Lo;0;L;;;;;N;;;;;\nA811;SYLOTI NAGRI LETTER TTHO;Lo;0;L;;;;;N;;;;;\nA812;SYLOTI NAGRI LETTER DDO;Lo;0;L;;;;;N;;;;;\nA813;SYLOTI NAGRI LETTER DDHO;Lo;0;L;;;;;N;;;;;\nA814;SYLOTI NAGRI LETTER TO;Lo;0;L;;;;;N;;;;;\nA815;SYLOTI NAGRI LETTER THO;Lo;0;L;;;;;N;;;;;\nA816;SYLOTI NAGRI LETTER DO;Lo;0;L;;;;;N;;;;;\nA817;SYLOTI NAGRI LETTER DHO;Lo;0;L;;;;;N;;;;;\nA818;SYLOTI NAGRI LETTER NO;Lo;0;L;;;;;N;;;;;\nA819;SYLOTI NAGRI LETTER PO;Lo;0;L;;;;;N;;;;;\nA81A;SYLOTI NAGRI LETTER PHO;Lo;0;L;;;;;N;;;;;\nA81B;SYLOTI NAGRI LETTER BO;Lo;0;L;;;;;N;;;;;\nA81C;SYLOTI NAGRI LETTER BHO;Lo;0;L;;;;;N;;;;;\nA81D;SYLOTI NAGRI LETTER MO;Lo;0;L;;;;;N;;;;;\nA81E;SYLOTI NAGRI LETTER RO;Lo;0;L;;;;;N;;;;;\nA81F;SYLOTI NAGRI LETTER LO;Lo;0;L;;;;;N;;;;;\nA820;SYLOTI NAGRI LETTER RRO;Lo;0;L;;;;;N;;;;;\nA821;SYLOTI NAGRI LETTER SO;Lo;0;L;;;;;N;;;;;\nA822;SYLOTI NAGRI LETTER HO;Lo;0;L;;;;;N;;;;;\nA823;SYLOTI NAGRI VOWEL SIGN A;Mc;0;L;;;;;N;;;;;\nA824;SYLOTI NAGRI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\nA825;SYLOTI NAGRI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\nA826;SYLOTI NAGRI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\nA827;SYLOTI NAGRI VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\nA828;SYLOTI NAGRI POETRY MARK-1;So;0;ON;;;;;N;;;;;\nA829;SYLOTI NAGRI POETRY MARK-2;So;0;ON;;;;;N;;;;;\nA82A;SYLOTI NAGRI POETRY MARK-3;So;0;ON;;;;;N;;;;;\nA82B;SYLOTI NAGRI POETRY MARK-4;So;0;ON;;;;;N;;;;;\nA830;NORTH INDIC FRACTION ONE QUARTER;No;0;L;;;;1/4;N;;;;;\nA831;NORTH INDIC FRACTION ONE HALF;No;0;L;;;;1/2;N;;;;;\nA832;NORTH INDIC FRACTION THREE QUARTERS;No;0;L;;;;3/4;N;;;;;\nA833;NORTH INDIC FRACTION ONE SIXTEENTH;No;0;L;;;;1/16;N;;;;;\nA834;NORTH INDIC FRACTION ONE EIGHTH;No;0;L;;;;1/8;N;;;;;\nA835;NORTH INDIC FRACTION THREE SIXTEENTHS;No;0;L;;;;3/16;N;;;;;\nA836;NORTH INDIC QUARTER MARK;So;0;L;;;;;N;;;;;\nA837;NORTH INDIC PLACEHOLDER MARK;So;0;L;;;;;N;;;;;\nA838;NORTH INDIC RUPEE MARK;Sc;0;ET;;;;;N;;;;;\nA839;NORTH INDIC QUANTITY MARK;So;0;ET;;;;;N;;;;;\nA840;PHAGS-PA LETTER KA;Lo;0;L;;;;;N;;;;;\nA841;PHAGS-PA LETTER KHA;Lo;0;L;;;;;N;;;;;\nA842;PHAGS-PA LETTER GA;Lo;0;L;;;;;N;;;;;\nA843;PHAGS-PA LETTER NGA;Lo;0;L;;;;;N;;;;;\nA844;PHAGS-PA LETTER CA;Lo;0;L;;;;;N;;;;;\nA845;PHAGS-PA LETTER CHA;Lo;0;L;;;;;N;;;;;\nA846;PHAGS-PA LETTER JA;Lo;0;L;;;;;N;;;;;\nA847;PHAGS-PA LETTER NYA;Lo;0;L;;;;;N;;;;;\nA848;PHAGS-PA LETTER TA;Lo;0;L;;;;;N;;;;;\nA849;PHAGS-PA LETTER THA;Lo;0;L;;;;;N;;;;;\nA84A;PHAGS-PA LETTER DA;Lo;0;L;;;;;N;;;;;\nA84B;PHAGS-PA LETTER NA;Lo;0;L;;;;;N;;;;;\nA84C;PHAGS-PA LETTER PA;Lo;0;L;;;;;N;;;;;\nA84D;PHAGS-PA LETTER PHA;Lo;0;L;;;;;N;;;;;\nA84E;PHAGS-PA LETTER BA;Lo;0;L;;;;;N;;;;;\nA84F;PHAGS-PA LETTER MA;Lo;0;L;;;;;N;;;;;\nA850;PHAGS-PA LETTER TSA;Lo;0;L;;;;;N;;;;;\nA851;PHAGS-PA LETTER TSHA;Lo;0;L;;;;;N;;;;;\nA852;PHAGS-PA LETTER DZA;Lo;0;L;;;;;N;;;;;\nA853;PHAGS-PA LETTER WA;Lo;0;L;;;;;N;;;;;\nA854;PHAGS-PA LETTER ZHA;Lo;0;L;;;;;N;;;;;\nA855;PHAGS-PA LETTER ZA;Lo;0;L;;;;;N;;;;;\nA856;PHAGS-PA LETTER SMALL A;Lo;0;L;;;;;N;;;;;\nA857;PHAGS-PA LETTER YA;Lo;0;L;;;;;N;;;;;\nA858;PHAGS-PA LETTER RA;Lo;0;L;;;;;N;;;;;\nA859;PHAGS-PA LETTER LA;Lo;0;L;;;;;N;;;;;\nA85A;PHAGS-PA LETTER SHA;Lo;0;L;;;;;N;;;;;\nA85B;PHAGS-PA LETTER SA;Lo;0;L;;;;;N;;;;;\nA85C;PHAGS-PA LETTER HA;Lo;0;L;;;;;N;;;;;\nA85D;PHAGS-PA LETTER A;Lo;0;L;;;;;N;;;;;\nA85E;PHAGS-PA LETTER I;Lo;0;L;;;;;N;;;;;\nA85F;PHAGS-PA LETTER U;Lo;0;L;;;;;N;;;;;\nA860;PHAGS-PA LETTER E;Lo;0;L;;;;;N;;;;;\nA861;PHAGS-PA LETTER O;Lo;0;L;;;;;N;;;;;\nA862;PHAGS-PA LETTER QA;Lo;0;L;;;;;N;;;;;\nA863;PHAGS-PA LETTER XA;Lo;0;L;;;;;N;;;;;\nA864;PHAGS-PA LETTER FA;Lo;0;L;;;;;N;;;;;\nA865;PHAGS-PA LETTER GGA;Lo;0;L;;;;;N;;;;;\nA866;PHAGS-PA LETTER EE;Lo;0;L;;;;;N;;;;;\nA867;PHAGS-PA SUBJOINED LETTER WA;Lo;0;L;;;;;N;;;;;\nA868;PHAGS-PA SUBJOINED LETTER YA;Lo;0;L;;;;;N;;;;;\nA869;PHAGS-PA LETTER TTA;Lo;0;L;;;;;N;;;;;\nA86A;PHAGS-PA LETTER TTHA;Lo;0;L;;;;;N;;;;;\nA86B;PHAGS-PA LETTER DDA;Lo;0;L;;;;;N;;;;;\nA86C;PHAGS-PA LETTER NNA;Lo;0;L;;;;;N;;;;;\nA86D;PHAGS-PA LETTER ALTERNATE YA;Lo;0;L;;;;;N;;;;;\nA86E;PHAGS-PA LETTER VOICELESS SHA;Lo;0;L;;;;;N;;;;;\nA86F;PHAGS-PA LETTER VOICED HA;Lo;0;L;;;;;N;;;;;\nA870;PHAGS-PA LETTER ASPIRATED FA;Lo;0;L;;;;;N;;;;;\nA871;PHAGS-PA SUBJOINED LETTER RA;Lo;0;L;;;;;N;;;;;\nA872;PHAGS-PA SUPERFIXED LETTER RA;Lo;0;L;;;;;N;;;;;\nA873;PHAGS-PA LETTER CANDRABINDU;Lo;0;L;;;;;N;;;;;\nA874;PHAGS-PA SINGLE HEAD MARK;Po;0;ON;;;;;N;;;;;\nA875;PHAGS-PA DOUBLE HEAD MARK;Po;0;ON;;;;;N;;;;;\nA876;PHAGS-PA MARK SHAD;Po;0;ON;;;;;N;;;;;\nA877;PHAGS-PA MARK DOUBLE SHAD;Po;0;ON;;;;;N;;;;;\nA880;SAURASHTRA SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;\nA881;SAURASHTRA SIGN VISARGA;Mc;0;L;;;;;N;;;;;\nA882;SAURASHTRA LETTER A;Lo;0;L;;;;;N;;;;;\nA883;SAURASHTRA LETTER AA;Lo;0;L;;;;;N;;;;;\nA884;SAURASHTRA LETTER I;Lo;0;L;;;;;N;;;;;\nA885;SAURASHTRA LETTER II;Lo;0;L;;;;;N;;;;;\nA886;SAURASHTRA LETTER U;Lo;0;L;;;;;N;;;;;\nA887;SAURASHTRA LETTER UU;Lo;0;L;;;;;N;;;;;\nA888;SAURASHTRA LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\nA889;SAURASHTRA LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\nA88A;SAURASHTRA LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\nA88B;SAURASHTRA LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\nA88C;SAURASHTRA LETTER E;Lo;0;L;;;;;N;;;;;\nA88D;SAURASHTRA LETTER EE;Lo;0;L;;;;;N;;;;;\nA88E;SAURASHTRA LETTER AI;Lo;0;L;;;;;N;;;;;\nA88F;SAURASHTRA LETTER O;Lo;0;L;;;;;N;;;;;\nA890;SAURASHTRA LETTER OO;Lo;0;L;;;;;N;;;;;\nA891;SAURASHTRA LETTER AU;Lo;0;L;;;;;N;;;;;\nA892;SAURASHTRA LETTER KA;Lo;0;L;;;;;N;;;;;\nA893;SAURASHTRA LETTER KHA;Lo;0;L;;;;;N;;;;;\nA894;SAURASHTRA LETTER GA;Lo;0;L;;;;;N;;;;;\nA895;SAURASHTRA LETTER GHA;Lo;0;L;;;;;N;;;;;\nA896;SAURASHTRA LETTER NGA;Lo;0;L;;;;;N;;;;;\nA897;SAURASHTRA LETTER CA;Lo;0;L;;;;;N;;;;;\nA898;SAURASHTRA LETTER CHA;Lo;0;L;;;;;N;;;;;\nA899;SAURASHTRA LETTER JA;Lo;0;L;;;;;N;;;;;\nA89A;SAURASHTRA LETTER JHA;Lo;0;L;;;;;N;;;;;\nA89B;SAURASHTRA LETTER NYA;Lo;0;L;;;;;N;;;;;\nA89C;SAURASHTRA LETTER TTA;Lo;0;L;;;;;N;;;;;\nA89D;SAURASHTRA LETTER TTHA;Lo;0;L;;;;;N;;;;;\nA89E;SAURASHTRA LETTER DDA;Lo;0;L;;;;;N;;;;;\nA89F;SAURASHTRA LETTER DDHA;Lo;0;L;;;;;N;;;;;\nA8A0;SAURASHTRA LETTER NNA;Lo;0;L;;;;;N;;;;;\nA8A1;SAURASHTRA LETTER TA;Lo;0;L;;;;;N;;;;;\nA8A2;SAURASHTRA LETTER THA;Lo;0;L;;;;;N;;;;;\nA8A3;SAURASHTRA LETTER DA;Lo;0;L;;;;;N;;;;;\nA8A4;SAURASHTRA LETTER DHA;Lo;0;L;;;;;N;;;;;\nA8A5;SAURASHTRA LETTER NA;Lo;0;L;;;;;N;;;;;\nA8A6;SAURASHTRA LETTER PA;Lo;0;L;;;;;N;;;;;\nA8A7;SAURASHTRA LETTER PHA;Lo;0;L;;;;;N;;;;;\nA8A8;SAURASHTRA LETTER BA;Lo;0;L;;;;;N;;;;;\nA8A9;SAURASHTRA LETTER BHA;Lo;0;L;;;;;N;;;;;\nA8AA;SAURASHTRA LETTER MA;Lo;0;L;;;;;N;;;;;\nA8AB;SAURASHTRA LETTER YA;Lo;0;L;;;;;N;;;;;\nA8AC;SAURASHTRA LETTER RA;Lo;0;L;;;;;N;;;;;\nA8AD;SAURASHTRA LETTER LA;Lo;0;L;;;;;N;;;;;\nA8AE;SAURASHTRA LETTER VA;Lo;0;L;;;;;N;;;;;\nA8AF;SAURASHTRA LETTER SHA;Lo;0;L;;;;;N;;;;;\nA8B0;SAURASHTRA LETTER SSA;Lo;0;L;;;;;N;;;;;\nA8B1;SAURASHTRA LETTER SA;Lo;0;L;;;;;N;;;;;\nA8B2;SAURASHTRA LETTER HA;Lo;0;L;;;;;N;;;;;\nA8B3;SAURASHTRA LETTER LLA;Lo;0;L;;;;;N;;;;;\nA8B4;SAURASHTRA CONSONANT SIGN HAARU;Mc;0;L;;;;;N;;;;;\nA8B5;SAURASHTRA VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\nA8B6;SAURASHTRA VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\nA8B7;SAURASHTRA VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\nA8B8;SAURASHTRA VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\nA8B9;SAURASHTRA VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\nA8BA;SAURASHTRA VOWEL SIGN VOCALIC R;Mc;0;L;;;;;N;;;;;\nA8BB;SAURASHTRA VOWEL SIGN VOCALIC RR;Mc;0;L;;;;;N;;;;;\nA8BC;SAURASHTRA VOWEL SIGN VOCALIC L;Mc;0;L;;;;;N;;;;;\nA8BD;SAURASHTRA VOWEL SIGN VOCALIC LL;Mc;0;L;;;;;N;;;;;\nA8BE;SAURASHTRA VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\nA8BF;SAURASHTRA VOWEL SIGN EE;Mc;0;L;;;;;N;;;;;\nA8C0;SAURASHTRA VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\nA8C1;SAURASHTRA VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\nA8C2;SAURASHTRA VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\nA8C3;SAURASHTRA VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\nA8C4;SAURASHTRA SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\nA8CE;SAURASHTRA DANDA;Po;0;L;;;;;N;;;;;\nA8CF;SAURASHTRA DOUBLE DANDA;Po;0;L;;;;;N;;;;;\nA8D0;SAURASHTRA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nA8D1;SAURASHTRA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nA8D2;SAURASHTRA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nA8D3;SAURASHTRA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nA8D4;SAURASHTRA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nA8D5;SAURASHTRA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nA8D6;SAURASHTRA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nA8D7;SAURASHTRA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nA8D8;SAURASHTRA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nA8D9;SAURASHTRA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nA8E0;COMBINING DEVANAGARI DIGIT ZERO;Mn;230;NSM;;;;;N;;;;;\nA8E1;COMBINING DEVANAGARI DIGIT ONE;Mn;230;NSM;;;;;N;;;;;\nA8E2;COMBINING DEVANAGARI DIGIT TWO;Mn;230;NSM;;;;;N;;;;;\nA8E3;COMBINING DEVANAGARI DIGIT THREE;Mn;230;NSM;;;;;N;;;;;\nA8E4;COMBINING DEVANAGARI DIGIT FOUR;Mn;230;NSM;;;;;N;;;;;\nA8E5;COMBINING DEVANAGARI DIGIT FIVE;Mn;230;NSM;;;;;N;;;;;\nA8E6;COMBINING DEVANAGARI DIGIT SIX;Mn;230;NSM;;;;;N;;;;;\nA8E7;COMBINING DEVANAGARI DIGIT SEVEN;Mn;230;NSM;;;;;N;;;;;\nA8E8;COMBINING DEVANAGARI DIGIT EIGHT;Mn;230;NSM;;;;;N;;;;;\nA8E9;COMBINING DEVANAGARI DIGIT NINE;Mn;230;NSM;;;;;N;;;;;\nA8EA;COMBINING DEVANAGARI LETTER A;Mn;230;NSM;;;;;N;;;;;\nA8EB;COMBINING DEVANAGARI LETTER U;Mn;230;NSM;;;;;N;;;;;\nA8EC;COMBINING DEVANAGARI LETTER KA;Mn;230;NSM;;;;;N;;;;;\nA8ED;COMBINING DEVANAGARI LETTER NA;Mn;230;NSM;;;;;N;;;;;\nA8EE;COMBINING DEVANAGARI LETTER PA;Mn;230;NSM;;;;;N;;;;;\nA8EF;COMBINING DEVANAGARI LETTER RA;Mn;230;NSM;;;;;N;;;;;\nA8F0;COMBINING DEVANAGARI LETTER VI;Mn;230;NSM;;;;;N;;;;;\nA8F1;COMBINING DEVANAGARI SIGN AVAGRAHA;Mn;230;NSM;;;;;N;;;;;\nA8F2;DEVANAGARI SIGN SPACING CANDRABINDU;Lo;0;L;;;;;N;;;;;\nA8F3;DEVANAGARI SIGN CANDRABINDU VIRAMA;Lo;0;L;;;;;N;;;;;\nA8F4;DEVANAGARI SIGN DOUBLE CANDRABINDU VIRAMA;Lo;0;L;;;;;N;;;;;\nA8F5;DEVANAGARI SIGN CANDRABINDU TWO;Lo;0;L;;;;;N;;;;;\nA8F6;DEVANAGARI SIGN CANDRABINDU THREE;Lo;0;L;;;;;N;;;;;\nA8F7;DEVANAGARI SIGN CANDRABINDU AVAGRAHA;Lo;0;L;;;;;N;;;;;\nA8F8;DEVANAGARI SIGN PUSHPIKA;Po;0;L;;;;;N;;;;;\nA8F9;DEVANAGARI GAP FILLER;Po;0;L;;;;;N;;;;;\nA8FA;DEVANAGARI CARET;Po;0;L;;;;;N;;;;;\nA8FB;DEVANAGARI HEADSTROKE;Lo;0;L;;;;;N;;;;;\nA900;KAYAH LI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nA901;KAYAH LI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nA902;KAYAH LI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nA903;KAYAH LI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nA904;KAYAH LI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nA905;KAYAH LI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nA906;KAYAH LI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nA907;KAYAH LI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nA908;KAYAH LI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nA909;KAYAH LI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nA90A;KAYAH LI LETTER KA;Lo;0;L;;;;;N;;;;;\nA90B;KAYAH LI LETTER KHA;Lo;0;L;;;;;N;;;;;\nA90C;KAYAH LI LETTER GA;Lo;0;L;;;;;N;;;;;\nA90D;KAYAH LI LETTER NGA;Lo;0;L;;;;;N;;;;;\nA90E;KAYAH LI LETTER SA;Lo;0;L;;;;;N;;;;;\nA90F;KAYAH LI LETTER SHA;Lo;0;L;;;;;N;;;;;\nA910;KAYAH LI LETTER ZA;Lo;0;L;;;;;N;;;;;\nA911;KAYAH LI LETTER NYA;Lo;0;L;;;;;N;;;;;\nA912;KAYAH LI LETTER TA;Lo;0;L;;;;;N;;;;;\nA913;KAYAH LI LETTER HTA;Lo;0;L;;;;;N;;;;;\nA914;KAYAH LI LETTER NA;Lo;0;L;;;;;N;;;;;\nA915;KAYAH LI LETTER PA;Lo;0;L;;;;;N;;;;;\nA916;KAYAH LI LETTER PHA;Lo;0;L;;;;;N;;;;;\nA917;KAYAH LI LETTER MA;Lo;0;L;;;;;N;;;;;\nA918;KAYAH LI LETTER DA;Lo;0;L;;;;;N;;;;;\nA919;KAYAH LI LETTER BA;Lo;0;L;;;;;N;;;;;\nA91A;KAYAH LI LETTER RA;Lo;0;L;;;;;N;;;;;\nA91B;KAYAH LI LETTER YA;Lo;0;L;;;;;N;;;;;\nA91C;KAYAH LI LETTER LA;Lo;0;L;;;;;N;;;;;\nA91D;KAYAH LI LETTER WA;Lo;0;L;;;;;N;;;;;\nA91E;KAYAH LI LETTER THA;Lo;0;L;;;;;N;;;;;\nA91F;KAYAH LI LETTER HA;Lo;0;L;;;;;N;;;;;\nA920;KAYAH LI LETTER VA;Lo;0;L;;;;;N;;;;;\nA921;KAYAH LI LETTER CA;Lo;0;L;;;;;N;;;;;\nA922;KAYAH LI LETTER A;Lo;0;L;;;;;N;;;;;\nA923;KAYAH LI LETTER OE;Lo;0;L;;;;;N;;;;;\nA924;KAYAH LI LETTER I;Lo;0;L;;;;;N;;;;;\nA925;KAYAH LI LETTER OO;Lo;0;L;;;;;N;;;;;\nA926;KAYAH LI VOWEL UE;Mn;0;NSM;;;;;N;;;;;\nA927;KAYAH LI VOWEL E;Mn;0;NSM;;;;;N;;;;;\nA928;KAYAH LI VOWEL U;Mn;0;NSM;;;;;N;;;;;\nA929;KAYAH LI VOWEL EE;Mn;0;NSM;;;;;N;;;;;\nA92A;KAYAH LI VOWEL O;Mn;0;NSM;;;;;N;;;;;\nA92B;KAYAH LI TONE PLOPHU;Mn;220;NSM;;;;;N;;;;;\nA92C;KAYAH LI TONE CALYA;Mn;220;NSM;;;;;N;;;;;\nA92D;KAYAH LI TONE CALYA PLOPHU;Mn;220;NSM;;;;;N;;;;;\nA92E;KAYAH LI SIGN CWI;Po;0;L;;;;;N;;;;;\nA92F;KAYAH LI SIGN SHYA;Po;0;L;;;;;N;;;;;\nA930;REJANG LETTER KA;Lo;0;L;;;;;N;;;;;\nA931;REJANG LETTER GA;Lo;0;L;;;;;N;;;;;\nA932;REJANG LETTER NGA;Lo;0;L;;;;;N;;;;;\nA933;REJANG LETTER TA;Lo;0;L;;;;;N;;;;;\nA934;REJANG LETTER DA;Lo;0;L;;;;;N;;;;;\nA935;REJANG LETTER NA;Lo;0;L;;;;;N;;;;;\nA936;REJANG LETTER PA;Lo;0;L;;;;;N;;;;;\nA937;REJANG LETTER BA;Lo;0;L;;;;;N;;;;;\nA938;REJANG LETTER MA;Lo;0;L;;;;;N;;;;;\nA939;REJANG LETTER CA;Lo;0;L;;;;;N;;;;;\nA93A;REJANG LETTER JA;Lo;0;L;;;;;N;;;;;\nA93B;REJANG LETTER NYA;Lo;0;L;;;;;N;;;;;\nA93C;REJANG LETTER SA;Lo;0;L;;;;;N;;;;;\nA93D;REJANG LETTER RA;Lo;0;L;;;;;N;;;;;\nA93E;REJANG LETTER LA;Lo;0;L;;;;;N;;;;;\nA93F;REJANG LETTER YA;Lo;0;L;;;;;N;;;;;\nA940;REJANG LETTER WA;Lo;0;L;;;;;N;;;;;\nA941;REJANG LETTER HA;Lo;0;L;;;;;N;;;;;\nA942;REJANG LETTER MBA;Lo;0;L;;;;;N;;;;;\nA943;REJANG LETTER NGGA;Lo;0;L;;;;;N;;;;;\nA944;REJANG LETTER NDA;Lo;0;L;;;;;N;;;;;\nA945;REJANG LETTER NYJA;Lo;0;L;;;;;N;;;;;\nA946;REJANG LETTER A;Lo;0;L;;;;;N;;;;;\nA947;REJANG VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\nA948;REJANG VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\nA949;REJANG VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\nA94A;REJANG VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\nA94B;REJANG VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\nA94C;REJANG VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\nA94D;REJANG VOWEL SIGN EU;Mn;0;NSM;;;;;N;;;;;\nA94E;REJANG VOWEL SIGN EA;Mn;0;NSM;;;;;N;;;;;\nA94F;REJANG CONSONANT SIGN NG;Mn;0;NSM;;;;;N;;;;;\nA950;REJANG CONSONANT SIGN N;Mn;0;NSM;;;;;N;;;;;\nA951;REJANG CONSONANT SIGN R;Mn;0;NSM;;;;;N;;;;;\nA952;REJANG CONSONANT SIGN H;Mc;0;L;;;;;N;;;;;\nA953;REJANG VIRAMA;Mc;9;L;;;;;N;;;;;\nA95F;REJANG SECTION MARK;Po;0;L;;;;;N;;;;;\nA960;HANGUL CHOSEONG TIKEUT-MIEUM;Lo;0;L;;;;;N;;;;;\nA961;HANGUL CHOSEONG TIKEUT-PIEUP;Lo;0;L;;;;;N;;;;;\nA962;HANGUL CHOSEONG TIKEUT-SIOS;Lo;0;L;;;;;N;;;;;\nA963;HANGUL CHOSEONG TIKEUT-CIEUC;Lo;0;L;;;;;N;;;;;\nA964;HANGUL CHOSEONG RIEUL-KIYEOK;Lo;0;L;;;;;N;;;;;\nA965;HANGUL CHOSEONG RIEUL-SSANGKIYEOK;Lo;0;L;;;;;N;;;;;\nA966;HANGUL CHOSEONG RIEUL-TIKEUT;Lo;0;L;;;;;N;;;;;\nA967;HANGUL CHOSEONG RIEUL-SSANGTIKEUT;Lo;0;L;;;;;N;;;;;\nA968;HANGUL CHOSEONG RIEUL-MIEUM;Lo;0;L;;;;;N;;;;;\nA969;HANGUL CHOSEONG RIEUL-PIEUP;Lo;0;L;;;;;N;;;;;\nA96A;HANGUL CHOSEONG RIEUL-SSANGPIEUP;Lo;0;L;;;;;N;;;;;\nA96B;HANGUL CHOSEONG RIEUL-KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\nA96C;HANGUL CHOSEONG RIEUL-SIOS;Lo;0;L;;;;;N;;;;;\nA96D;HANGUL CHOSEONG RIEUL-CIEUC;Lo;0;L;;;;;N;;;;;\nA96E;HANGUL CHOSEONG RIEUL-KHIEUKH;Lo;0;L;;;;;N;;;;;\nA96F;HANGUL CHOSEONG MIEUM-KIYEOK;Lo;0;L;;;;;N;;;;;\nA970;HANGUL CHOSEONG MIEUM-TIKEUT;Lo;0;L;;;;;N;;;;;\nA971;HANGUL CHOSEONG MIEUM-SIOS;Lo;0;L;;;;;N;;;;;\nA972;HANGUL CHOSEONG PIEUP-SIOS-THIEUTH;Lo;0;L;;;;;N;;;;;\nA973;HANGUL CHOSEONG PIEUP-KHIEUKH;Lo;0;L;;;;;N;;;;;\nA974;HANGUL CHOSEONG PIEUP-HIEUH;Lo;0;L;;;;;N;;;;;\nA975;HANGUL CHOSEONG SSANGSIOS-PIEUP;Lo;0;L;;;;;N;;;;;\nA976;HANGUL CHOSEONG IEUNG-RIEUL;Lo;0;L;;;;;N;;;;;\nA977;HANGUL CHOSEONG IEUNG-HIEUH;Lo;0;L;;;;;N;;;;;\nA978;HANGUL CHOSEONG SSANGCIEUC-HIEUH;Lo;0;L;;;;;N;;;;;\nA979;HANGUL CHOSEONG SSANGTHIEUTH;Lo;0;L;;;;;N;;;;;\nA97A;HANGUL CHOSEONG PHIEUPH-HIEUH;Lo;0;L;;;;;N;;;;;\nA97B;HANGUL CHOSEONG HIEUH-SIOS;Lo;0;L;;;;;N;;;;;\nA97C;HANGUL CHOSEONG SSANGYEORINHIEUH;Lo;0;L;;;;;N;;;;;\nA980;JAVANESE SIGN PANYANGGA;Mn;0;NSM;;;;;N;;;;;\nA981;JAVANESE SIGN CECAK;Mn;0;NSM;;;;;N;;;;;\nA982;JAVANESE SIGN LAYAR;Mn;0;NSM;;;;;N;;;;;\nA983;JAVANESE SIGN WIGNYAN;Mc;0;L;;;;;N;;;;;\nA984;JAVANESE LETTER A;Lo;0;L;;;;;N;;;;;\nA985;JAVANESE LETTER I KAWI;Lo;0;L;;;;;N;;;;;\nA986;JAVANESE LETTER I;Lo;0;L;;;;;N;;;;;\nA987;JAVANESE LETTER II;Lo;0;L;;;;;N;;;;;\nA988;JAVANESE LETTER U;Lo;0;L;;;;;N;;;;;\nA989;JAVANESE LETTER PA CEREK;Lo;0;L;;;;;N;;;;;\nA98A;JAVANESE LETTER NGA LELET;Lo;0;L;;;;;N;;;;;\nA98B;JAVANESE LETTER NGA LELET RASWADI;Lo;0;L;;;;;N;;;;;\nA98C;JAVANESE LETTER E;Lo;0;L;;;;;N;;;;;\nA98D;JAVANESE LETTER AI;Lo;0;L;;;;;N;;;;;\nA98E;JAVANESE LETTER O;Lo;0;L;;;;;N;;;;;\nA98F;JAVANESE LETTER KA;Lo;0;L;;;;;N;;;;;\nA990;JAVANESE LETTER KA SASAK;Lo;0;L;;;;;N;;;;;\nA991;JAVANESE LETTER KA MURDA;Lo;0;L;;;;;N;;;;;\nA992;JAVANESE LETTER GA;Lo;0;L;;;;;N;;;;;\nA993;JAVANESE LETTER GA MURDA;Lo;0;L;;;;;N;;;;;\nA994;JAVANESE LETTER NGA;Lo;0;L;;;;;N;;;;;\nA995;JAVANESE LETTER CA;Lo;0;L;;;;;N;;;;;\nA996;JAVANESE LETTER CA MURDA;Lo;0;L;;;;;N;;;;;\nA997;JAVANESE LETTER JA;Lo;0;L;;;;;N;;;;;\nA998;JAVANESE LETTER NYA MURDA;Lo;0;L;;;;;N;;;;;\nA999;JAVANESE LETTER JA MAHAPRANA;Lo;0;L;;;;;N;;;;;\nA99A;JAVANESE LETTER NYA;Lo;0;L;;;;;N;;;;;\nA99B;JAVANESE LETTER TTA;Lo;0;L;;;;;N;;;;;\nA99C;JAVANESE LETTER TTA MAHAPRANA;Lo;0;L;;;;;N;;;;;\nA99D;JAVANESE LETTER DDA;Lo;0;L;;;;;N;;;;;\nA99E;JAVANESE LETTER DDA MAHAPRANA;Lo;0;L;;;;;N;;;;;\nA99F;JAVANESE LETTER NA MURDA;Lo;0;L;;;;;N;;;;;\nA9A0;JAVANESE LETTER TA;Lo;0;L;;;;;N;;;;;\nA9A1;JAVANESE LETTER TA MURDA;Lo;0;L;;;;;N;;;;;\nA9A2;JAVANESE LETTER DA;Lo;0;L;;;;;N;;;;;\nA9A3;JAVANESE LETTER DA MAHAPRANA;Lo;0;L;;;;;N;;;;;\nA9A4;JAVANESE LETTER NA;Lo;0;L;;;;;N;;;;;\nA9A5;JAVANESE LETTER PA;Lo;0;L;;;;;N;;;;;\nA9A6;JAVANESE LETTER PA MURDA;Lo;0;L;;;;;N;;;;;\nA9A7;JAVANESE LETTER BA;Lo;0;L;;;;;N;;;;;\nA9A8;JAVANESE LETTER BA MURDA;Lo;0;L;;;;;N;;;;;\nA9A9;JAVANESE LETTER MA;Lo;0;L;;;;;N;;;;;\nA9AA;JAVANESE LETTER YA;Lo;0;L;;;;;N;;;;;\nA9AB;JAVANESE LETTER RA;Lo;0;L;;;;;N;;;;;\nA9AC;JAVANESE LETTER RA AGUNG;Lo;0;L;;;;;N;;;;;\nA9AD;JAVANESE LETTER LA;Lo;0;L;;;;;N;;;;;\nA9AE;JAVANESE LETTER WA;Lo;0;L;;;;;N;;;;;\nA9AF;JAVANESE LETTER SA MURDA;Lo;0;L;;;;;N;;;;;\nA9B0;JAVANESE LETTER SA MAHAPRANA;Lo;0;L;;;;;N;;;;;\nA9B1;JAVANESE LETTER SA;Lo;0;L;;;;;N;;;;;\nA9B2;JAVANESE LETTER HA;Lo;0;L;;;;;N;;;;;\nA9B3;JAVANESE SIGN CECAK TELU;Mn;7;NSM;;;;;N;;;;;\nA9B4;JAVANESE VOWEL SIGN TARUNG;Mc;0;L;;;;;N;;;;;\nA9B5;JAVANESE VOWEL SIGN TOLONG;Mc;0;L;;;;;N;;;;;\nA9B6;JAVANESE VOWEL SIGN WULU;Mn;0;NSM;;;;;N;;;;;\nA9B7;JAVANESE VOWEL SIGN WULU MELIK;Mn;0;NSM;;;;;N;;;;;\nA9B8;JAVANESE VOWEL SIGN SUKU;Mn;0;NSM;;;;;N;;;;;\nA9B9;JAVANESE VOWEL SIGN SUKU MENDUT;Mn;0;NSM;;;;;N;;;;;\nA9BA;JAVANESE VOWEL SIGN TALING;Mc;0;L;;;;;N;;;;;\nA9BB;JAVANESE VOWEL SIGN DIRGA MURE;Mc;0;L;;;;;N;;;;;\nA9BC;JAVANESE VOWEL SIGN PEPET;Mn;0;NSM;;;;;N;;;;;\nA9BD;JAVANESE CONSONANT SIGN KERET;Mc;0;L;;;;;N;;;;;\nA9BE;JAVANESE CONSONANT SIGN PENGKAL;Mc;0;L;;;;;N;;;;;\nA9BF;JAVANESE CONSONANT SIGN CAKRA;Mc;0;L;;;;;N;;;;;\nA9C0;JAVANESE PANGKON;Mc;9;L;;;;;N;;;;;\nA9C1;JAVANESE LEFT RERENGGAN;Po;0;L;;;;;N;;;;;\nA9C2;JAVANESE RIGHT RERENGGAN;Po;0;L;;;;;N;;;;;\nA9C3;JAVANESE PADA ANDAP;Po;0;L;;;;;N;;;;;\nA9C4;JAVANESE PADA MADYA;Po;0;L;;;;;N;;;;;\nA9C5;JAVANESE PADA LUHUR;Po;0;L;;;;;N;;;;;\nA9C6;JAVANESE PADA WINDU;Po;0;L;;;;;N;;;;;\nA9C7;JAVANESE PADA PANGKAT;Po;0;L;;;;;N;;;;;\nA9C8;JAVANESE PADA LINGSA;Po;0;L;;;;;N;;;;;\nA9C9;JAVANESE PADA LUNGSI;Po;0;L;;;;;N;;;;;\nA9CA;JAVANESE PADA ADEG;Po;0;L;;;;;N;;;;;\nA9CB;JAVANESE PADA ADEG ADEG;Po;0;L;;;;;N;;;;;\nA9CC;JAVANESE PADA PISELEH;Po;0;L;;;;;N;;;;;\nA9CD;JAVANESE TURNED PADA PISELEH;Po;0;L;;;;;N;;;;;\nA9CF;JAVANESE PANGRANGKEP;Lm;0;L;;;;;N;;;;;\nA9D0;JAVANESE DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nA9D1;JAVANESE DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nA9D2;JAVANESE DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nA9D3;JAVANESE DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nA9D4;JAVANESE DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nA9D5;JAVANESE DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nA9D6;JAVANESE DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nA9D7;JAVANESE DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nA9D8;JAVANESE DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nA9D9;JAVANESE DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nA9DE;JAVANESE PADA TIRTA TUMETES;Po;0;L;;;;;N;;;;;\nA9DF;JAVANESE PADA ISEN-ISEN;Po;0;L;;;;;N;;;;;\nAA00;CHAM LETTER A;Lo;0;L;;;;;N;;;;;\nAA01;CHAM LETTER I;Lo;0;L;;;;;N;;;;;\nAA02;CHAM LETTER U;Lo;0;L;;;;;N;;;;;\nAA03;CHAM LETTER E;Lo;0;L;;;;;N;;;;;\nAA04;CHAM LETTER AI;Lo;0;L;;;;;N;;;;;\nAA05;CHAM LETTER O;Lo;0;L;;;;;N;;;;;\nAA06;CHAM LETTER KA;Lo;0;L;;;;;N;;;;;\nAA07;CHAM LETTER KHA;Lo;0;L;;;;;N;;;;;\nAA08;CHAM LETTER GA;Lo;0;L;;;;;N;;;;;\nAA09;CHAM LETTER GHA;Lo;0;L;;;;;N;;;;;\nAA0A;CHAM LETTER NGUE;Lo;0;L;;;;;N;;;;;\nAA0B;CHAM LETTER NGA;Lo;0;L;;;;;N;;;;;\nAA0C;CHAM LETTER CHA;Lo;0;L;;;;;N;;;;;\nAA0D;CHAM LETTER CHHA;Lo;0;L;;;;;N;;;;;\nAA0E;CHAM LETTER JA;Lo;0;L;;;;;N;;;;;\nAA0F;CHAM LETTER JHA;Lo;0;L;;;;;N;;;;;\nAA10;CHAM LETTER NHUE;Lo;0;L;;;;;N;;;;;\nAA11;CHAM LETTER NHA;Lo;0;L;;;;;N;;;;;\nAA12;CHAM LETTER NHJA;Lo;0;L;;;;;N;;;;;\nAA13;CHAM LETTER TA;Lo;0;L;;;;;N;;;;;\nAA14;CHAM LETTER THA;Lo;0;L;;;;;N;;;;;\nAA15;CHAM LETTER DA;Lo;0;L;;;;;N;;;;;\nAA16;CHAM LETTER DHA;Lo;0;L;;;;;N;;;;;\nAA17;CHAM LETTER NUE;Lo;0;L;;;;;N;;;;;\nAA18;CHAM LETTER NA;Lo;0;L;;;;;N;;;;;\nAA19;CHAM LETTER DDA;Lo;0;L;;;;;N;;;;;\nAA1A;CHAM LETTER PA;Lo;0;L;;;;;N;;;;;\nAA1B;CHAM LETTER PPA;Lo;0;L;;;;;N;;;;;\nAA1C;CHAM LETTER PHA;Lo;0;L;;;;;N;;;;;\nAA1D;CHAM LETTER BA;Lo;0;L;;;;;N;;;;;\nAA1E;CHAM LETTER BHA;Lo;0;L;;;;;N;;;;;\nAA1F;CHAM LETTER MUE;Lo;0;L;;;;;N;;;;;\nAA20;CHAM LETTER MA;Lo;0;L;;;;;N;;;;;\nAA21;CHAM LETTER BBA;Lo;0;L;;;;;N;;;;;\nAA22;CHAM LETTER YA;Lo;0;L;;;;;N;;;;;\nAA23;CHAM LETTER RA;Lo;0;L;;;;;N;;;;;\nAA24;CHAM LETTER LA;Lo;0;L;;;;;N;;;;;\nAA25;CHAM LETTER VA;Lo;0;L;;;;;N;;;;;\nAA26;CHAM LETTER SSA;Lo;0;L;;;;;N;;;;;\nAA27;CHAM LETTER SA;Lo;0;L;;;;;N;;;;;\nAA28;CHAM LETTER HA;Lo;0;L;;;;;N;;;;;\nAA29;CHAM VOWEL SIGN AA;Mn;0;NSM;;;;;N;;;;;\nAA2A;CHAM VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\nAA2B;CHAM VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\nAA2C;CHAM VOWEL SIGN EI;Mn;0;NSM;;;;;N;;;;;\nAA2D;CHAM VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\nAA2E;CHAM VOWEL SIGN OE;Mn;0;NSM;;;;;N;;;;;\nAA2F;CHAM VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\nAA30;CHAM VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\nAA31;CHAM VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\nAA32;CHAM VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;;\nAA33;CHAM CONSONANT SIGN YA;Mc;0;L;;;;;N;;;;;\nAA34;CHAM CONSONANT SIGN RA;Mc;0;L;;;;;N;;;;;\nAA35;CHAM CONSONANT SIGN LA;Mn;0;NSM;;;;;N;;;;;\nAA36;CHAM CONSONANT SIGN WA;Mn;0;NSM;;;;;N;;;;;\nAA40;CHAM LETTER FINAL K;Lo;0;L;;;;;N;;;;;\nAA41;CHAM LETTER FINAL G;Lo;0;L;;;;;N;;;;;\nAA42;CHAM LETTER FINAL NG;Lo;0;L;;;;;N;;;;;\nAA43;CHAM CONSONANT SIGN FINAL NG;Mn;0;NSM;;;;;N;;;;;\nAA44;CHAM LETTER FINAL CH;Lo;0;L;;;;;N;;;;;\nAA45;CHAM LETTER FINAL T;Lo;0;L;;;;;N;;;;;\nAA46;CHAM LETTER FINAL N;Lo;0;L;;;;;N;;;;;\nAA47;CHAM LETTER FINAL P;Lo;0;L;;;;;N;;;;;\nAA48;CHAM LETTER FINAL Y;Lo;0;L;;;;;N;;;;;\nAA49;CHAM LETTER FINAL R;Lo;0;L;;;;;N;;;;;\nAA4A;CHAM LETTER FINAL L;Lo;0;L;;;;;N;;;;;\nAA4B;CHAM LETTER FINAL SS;Lo;0;L;;;;;N;;;;;\nAA4C;CHAM CONSONANT SIGN FINAL M;Mn;0;NSM;;;;;N;;;;;\nAA4D;CHAM CONSONANT SIGN FINAL H;Mc;0;L;;;;;N;;;;;\nAA50;CHAM DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nAA51;CHAM DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nAA52;CHAM DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nAA53;CHAM DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nAA54;CHAM DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nAA55;CHAM DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nAA56;CHAM DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nAA57;CHAM DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nAA58;CHAM DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nAA59;CHAM DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nAA5C;CHAM PUNCTUATION SPIRAL;Po;0;L;;;;;N;;;;;\nAA5D;CHAM PUNCTUATION DANDA;Po;0;L;;;;;N;;;;;\nAA5E;CHAM PUNCTUATION DOUBLE DANDA;Po;0;L;;;;;N;;;;;\nAA5F;CHAM PUNCTUATION TRIPLE DANDA;Po;0;L;;;;;N;;;;;\nAA60;MYANMAR LETTER KHAMTI GA;Lo;0;L;;;;;N;;;;;\nAA61;MYANMAR LETTER KHAMTI CA;Lo;0;L;;;;;N;;;;;\nAA62;MYANMAR LETTER KHAMTI CHA;Lo;0;L;;;;;N;;;;;\nAA63;MYANMAR LETTER KHAMTI JA;Lo;0;L;;;;;N;;;;;\nAA64;MYANMAR LETTER KHAMTI JHA;Lo;0;L;;;;;N;;;;;\nAA65;MYANMAR LETTER KHAMTI NYA;Lo;0;L;;;;;N;;;;;\nAA66;MYANMAR LETTER KHAMTI TTA;Lo;0;L;;;;;N;;;;;\nAA67;MYANMAR LETTER KHAMTI TTHA;Lo;0;L;;;;;N;;;;;\nAA68;MYANMAR LETTER KHAMTI DDA;Lo;0;L;;;;;N;;;;;\nAA69;MYANMAR LETTER KHAMTI DDHA;Lo;0;L;;;;;N;;;;;\nAA6A;MYANMAR LETTER KHAMTI DHA;Lo;0;L;;;;;N;;;;;\nAA6B;MYANMAR LETTER KHAMTI NA;Lo;0;L;;;;;N;;;;;\nAA6C;MYANMAR LETTER KHAMTI SA;Lo;0;L;;;;;N;;;;;\nAA6D;MYANMAR LETTER KHAMTI HA;Lo;0;L;;;;;N;;;;;\nAA6E;MYANMAR LETTER KHAMTI HHA;Lo;0;L;;;;;N;;;;;\nAA6F;MYANMAR LETTER KHAMTI FA;Lo;0;L;;;;;N;;;;;\nAA70;MYANMAR MODIFIER LETTER KHAMTI REDUPLICATION;Lm;0;L;;;;;N;;;;;\nAA71;MYANMAR LETTER KHAMTI XA;Lo;0;L;;;;;N;;;;;\nAA72;MYANMAR LETTER KHAMTI ZA;Lo;0;L;;;;;N;;;;;\nAA73;MYANMAR LETTER KHAMTI RA;Lo;0;L;;;;;N;;;;;\nAA74;MYANMAR LOGOGRAM KHAMTI OAY;Lo;0;L;;;;;N;;;;;\nAA75;MYANMAR LOGOGRAM KHAMTI QN;Lo;0;L;;;;;N;;;;;\nAA76;MYANMAR LOGOGRAM KHAMTI HM;Lo;0;L;;;;;N;;;;;\nAA77;MYANMAR SYMBOL AITON EXCLAMATION;So;0;L;;;;;N;;;;;\nAA78;MYANMAR SYMBOL AITON ONE;So;0;L;;;;;N;;;;;\nAA79;MYANMAR SYMBOL AITON TWO;So;0;L;;;;;N;;;;;\nAA7A;MYANMAR LETTER AITON RA;Lo;0;L;;;;;N;;;;;\nAA7B;MYANMAR SIGN PAO KAREN TONE;Mc;0;L;;;;;N;;;;;\nAA80;TAI VIET LETTER LOW KO;Lo;0;L;;;;;N;;;;;\nAA81;TAI VIET LETTER HIGH KO;Lo;0;L;;;;;N;;;;;\nAA82;TAI VIET LETTER LOW KHO;Lo;0;L;;;;;N;;;;;\nAA83;TAI VIET LETTER HIGH KHO;Lo;0;L;;;;;N;;;;;\nAA84;TAI VIET LETTER LOW KHHO;Lo;0;L;;;;;N;;;;;\nAA85;TAI VIET LETTER HIGH KHHO;Lo;0;L;;;;;N;;;;;\nAA86;TAI VIET LETTER LOW GO;Lo;0;L;;;;;N;;;;;\nAA87;TAI VIET LETTER HIGH GO;Lo;0;L;;;;;N;;;;;\nAA88;TAI VIET LETTER LOW NGO;Lo;0;L;;;;;N;;;;;\nAA89;TAI VIET LETTER HIGH NGO;Lo;0;L;;;;;N;;;;;\nAA8A;TAI VIET LETTER LOW CO;Lo;0;L;;;;;N;;;;;\nAA8B;TAI VIET LETTER HIGH CO;Lo;0;L;;;;;N;;;;;\nAA8C;TAI VIET LETTER LOW CHO;Lo;0;L;;;;;N;;;;;\nAA8D;TAI VIET LETTER HIGH CHO;Lo;0;L;;;;;N;;;;;\nAA8E;TAI VIET LETTER LOW SO;Lo;0;L;;;;;N;;;;;\nAA8F;TAI VIET LETTER HIGH SO;Lo;0;L;;;;;N;;;;;\nAA90;TAI VIET LETTER LOW NYO;Lo;0;L;;;;;N;;;;;\nAA91;TAI VIET LETTER HIGH NYO;Lo;0;L;;;;;N;;;;;\nAA92;TAI VIET LETTER LOW DO;Lo;0;L;;;;;N;;;;;\nAA93;TAI VIET LETTER HIGH DO;Lo;0;L;;;;;N;;;;;\nAA94;TAI VIET LETTER LOW TO;Lo;0;L;;;;;N;;;;;\nAA95;TAI VIET LETTER HIGH TO;Lo;0;L;;;;;N;;;;;\nAA96;TAI VIET LETTER LOW THO;Lo;0;L;;;;;N;;;;;\nAA97;TAI VIET LETTER HIGH THO;Lo;0;L;;;;;N;;;;;\nAA98;TAI VIET LETTER LOW NO;Lo;0;L;;;;;N;;;;;\nAA99;TAI VIET LETTER HIGH NO;Lo;0;L;;;;;N;;;;;\nAA9A;TAI VIET LETTER LOW BO;Lo;0;L;;;;;N;;;;;\nAA9B;TAI VIET LETTER HIGH BO;Lo;0;L;;;;;N;;;;;\nAA9C;TAI VIET LETTER LOW PO;Lo;0;L;;;;;N;;;;;\nAA9D;TAI VIET LETTER HIGH PO;Lo;0;L;;;;;N;;;;;\nAA9E;TAI VIET LETTER LOW PHO;Lo;0;L;;;;;N;;;;;\nAA9F;TAI VIET LETTER HIGH PHO;Lo;0;L;;;;;N;;;;;\nAAA0;TAI VIET LETTER LOW FO;Lo;0;L;;;;;N;;;;;\nAAA1;TAI VIET LETTER HIGH FO;Lo;0;L;;;;;N;;;;;\nAAA2;TAI VIET LETTER LOW MO;Lo;0;L;;;;;N;;;;;\nAAA3;TAI VIET LETTER HIGH MO;Lo;0;L;;;;;N;;;;;\nAAA4;TAI VIET LETTER LOW YO;Lo;0;L;;;;;N;;;;;\nAAA5;TAI VIET LETTER HIGH YO;Lo;0;L;;;;;N;;;;;\nAAA6;TAI VIET LETTER LOW RO;Lo;0;L;;;;;N;;;;;\nAAA7;TAI VIET LETTER HIGH RO;Lo;0;L;;;;;N;;;;;\nAAA8;TAI VIET LETTER LOW LO;Lo;0;L;;;;;N;;;;;\nAAA9;TAI VIET LETTER HIGH LO;Lo;0;L;;;;;N;;;;;\nAAAA;TAI VIET LETTER LOW VO;Lo;0;L;;;;;N;;;;;\nAAAB;TAI VIET LETTER HIGH VO;Lo;0;L;;;;;N;;;;;\nAAAC;TAI VIET LETTER LOW HO;Lo;0;L;;;;;N;;;;;\nAAAD;TAI VIET LETTER HIGH HO;Lo;0;L;;;;;N;;;;;\nAAAE;TAI VIET LETTER LOW O;Lo;0;L;;;;;N;;;;;\nAAAF;TAI VIET LETTER HIGH O;Lo;0;L;;;;;N;;;;;\nAAB0;TAI VIET MAI KANG;Mn;230;NSM;;;;;N;;;;;\nAAB1;TAI VIET VOWEL AA;Lo;0;L;;;;;N;;;;;\nAAB2;TAI VIET VOWEL I;Mn;230;NSM;;;;;N;;;;;\nAAB3;TAI VIET VOWEL UE;Mn;230;NSM;;;;;N;;;;;\nAAB4;TAI VIET VOWEL U;Mn;220;NSM;;;;;N;;;;;\nAAB5;TAI VIET VOWEL E;Lo;0;L;;;;;N;;;;;\nAAB6;TAI VIET VOWEL O;Lo;0;L;;;;;N;;;;;\nAAB7;TAI VIET MAI KHIT;Mn;230;NSM;;;;;N;;;;;\nAAB8;TAI VIET VOWEL IA;Mn;230;NSM;;;;;N;;;;;\nAAB9;TAI VIET VOWEL UEA;Lo;0;L;;;;;N;;;;;\nAABA;TAI VIET VOWEL UA;Lo;0;L;;;;;N;;;;;\nAABB;TAI VIET VOWEL AUE;Lo;0;L;;;;;N;;;;;\nAABC;TAI VIET VOWEL AY;Lo;0;L;;;;;N;;;;;\nAABD;TAI VIET VOWEL AN;Lo;0;L;;;;;N;;;;;\nAABE;TAI VIET VOWEL AM;Mn;230;NSM;;;;;N;;;;;\nAABF;TAI VIET TONE MAI EK;Mn;230;NSM;;;;;N;;;;;\nAAC0;TAI VIET TONE MAI NUENG;Lo;0;L;;;;;N;;;;;\nAAC1;TAI VIET TONE MAI THO;Mn;230;NSM;;;;;N;;;;;\nAAC2;TAI VIET TONE MAI SONG;Lo;0;L;;;;;N;;;;;\nAADB;TAI VIET SYMBOL KON;Lo;0;L;;;;;N;;;;;\nAADC;TAI VIET SYMBOL NUENG;Lo;0;L;;;;;N;;;;;\nAADD;TAI VIET SYMBOL SAM;Lm;0;L;;;;;N;;;;;\nAADE;TAI VIET SYMBOL HO HOI;Po;0;L;;;;;N;;;;;\nAADF;TAI VIET SYMBOL KOI KOI;Po;0;L;;;;;N;;;;;\nAAE0;MEETEI MAYEK LETTER E;Lo;0;L;;;;;N;;;;;\nAAE1;MEETEI MAYEK LETTER O;Lo;0;L;;;;;N;;;;;\nAAE2;MEETEI MAYEK LETTER CHA;Lo;0;L;;;;;N;;;;;\nAAE3;MEETEI MAYEK LETTER NYA;Lo;0;L;;;;;N;;;;;\nAAE4;MEETEI MAYEK LETTER TTA;Lo;0;L;;;;;N;;;;;\nAAE5;MEETEI MAYEK LETTER TTHA;Lo;0;L;;;;;N;;;;;\nAAE6;MEETEI MAYEK LETTER DDA;Lo;0;L;;;;;N;;;;;\nAAE7;MEETEI MAYEK LETTER DDHA;Lo;0;L;;;;;N;;;;;\nAAE8;MEETEI MAYEK LETTER NNA;Lo;0;L;;;;;N;;;;;\nAAE9;MEETEI MAYEK LETTER SHA;Lo;0;L;;;;;N;;;;;\nAAEA;MEETEI MAYEK LETTER SSA;Lo;0;L;;;;;N;;;;;\nAAEB;MEETEI MAYEK VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\nAAEC;MEETEI MAYEK VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\nAAED;MEETEI MAYEK VOWEL SIGN AAI;Mn;0;NSM;;;;;N;;;;;\nAAEE;MEETEI MAYEK VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\nAAEF;MEETEI MAYEK VOWEL SIGN AAU;Mc;0;L;;;;;N;;;;;\nAAF0;MEETEI MAYEK CHEIKHAN;Po;0;L;;;;;N;;;;;\nAAF1;MEETEI MAYEK AHANG KHUDAM;Po;0;L;;;;;N;;;;;\nAAF2;MEETEI MAYEK ANJI;Lo;0;L;;;;;N;;;;;\nAAF3;MEETEI MAYEK SYLLABLE REPETITION MARK;Lm;0;L;;;;;N;;;;;\nAAF4;MEETEI MAYEK WORD REPETITION MARK;Lm;0;L;;;;;N;;;;;\nAAF5;MEETEI MAYEK VOWEL SIGN VISARGA;Mc;0;L;;;;;N;;;;;\nAAF6;MEETEI MAYEK VIRAMA;Mn;9;NSM;;;;;N;;;;;\nAB01;ETHIOPIC SYLLABLE TTHU;Lo;0;L;;;;;N;;;;;\nAB02;ETHIOPIC SYLLABLE TTHI;Lo;0;L;;;;;N;;;;;\nAB03;ETHIOPIC SYLLABLE TTHAA;Lo;0;L;;;;;N;;;;;\nAB04;ETHIOPIC SYLLABLE TTHEE;Lo;0;L;;;;;N;;;;;\nAB05;ETHIOPIC SYLLABLE TTHE;Lo;0;L;;;;;N;;;;;\nAB06;ETHIOPIC SYLLABLE TTHO;Lo;0;L;;;;;N;;;;;\nAB09;ETHIOPIC SYLLABLE DDHU;Lo;0;L;;;;;N;;;;;\nAB0A;ETHIOPIC SYLLABLE DDHI;Lo;0;L;;;;;N;;;;;\nAB0B;ETHIOPIC SYLLABLE DDHAA;Lo;0;L;;;;;N;;;;;\nAB0C;ETHIOPIC SYLLABLE DDHEE;Lo;0;L;;;;;N;;;;;\nAB0D;ETHIOPIC SYLLABLE DDHE;Lo;0;L;;;;;N;;;;;\nAB0E;ETHIOPIC SYLLABLE DDHO;Lo;0;L;;;;;N;;;;;\nAB11;ETHIOPIC SYLLABLE DZU;Lo;0;L;;;;;N;;;;;\nAB12;ETHIOPIC SYLLABLE DZI;Lo;0;L;;;;;N;;;;;\nAB13;ETHIOPIC SYLLABLE DZAA;Lo;0;L;;;;;N;;;;;\nAB14;ETHIOPIC SYLLABLE DZEE;Lo;0;L;;;;;N;;;;;\nAB15;ETHIOPIC SYLLABLE DZE;Lo;0;L;;;;;N;;;;;\nAB16;ETHIOPIC SYLLABLE DZO;Lo;0;L;;;;;N;;;;;\nAB20;ETHIOPIC SYLLABLE CCHHA;Lo;0;L;;;;;N;;;;;\nAB21;ETHIOPIC SYLLABLE CCHHU;Lo;0;L;;;;;N;;;;;\nAB22;ETHIOPIC SYLLABLE CCHHI;Lo;0;L;;;;;N;;;;;\nAB23;ETHIOPIC SYLLABLE CCHHAA;Lo;0;L;;;;;N;;;;;\nAB24;ETHIOPIC SYLLABLE CCHHEE;Lo;0;L;;;;;N;;;;;\nAB25;ETHIOPIC SYLLABLE CCHHE;Lo;0;L;;;;;N;;;;;\nAB26;ETHIOPIC SYLLABLE CCHHO;Lo;0;L;;;;;N;;;;;\nAB28;ETHIOPIC SYLLABLE BBA;Lo;0;L;;;;;N;;;;;\nAB29;ETHIOPIC SYLLABLE BBU;Lo;0;L;;;;;N;;;;;\nAB2A;ETHIOPIC SYLLABLE BBI;Lo;0;L;;;;;N;;;;;\nAB2B;ETHIOPIC SYLLABLE BBAA;Lo;0;L;;;;;N;;;;;\nAB2C;ETHIOPIC SYLLABLE BBEE;Lo;0;L;;;;;N;;;;;\nAB2D;ETHIOPIC SYLLABLE BBE;Lo;0;L;;;;;N;;;;;\nAB2E;ETHIOPIC SYLLABLE BBO;Lo;0;L;;;;;N;;;;;\nABC0;MEETEI MAYEK LETTER KOK;Lo;0;L;;;;;N;;;;;\nABC1;MEETEI MAYEK LETTER SAM;Lo;0;L;;;;;N;;;;;\nABC2;MEETEI MAYEK LETTER LAI;Lo;0;L;;;;;N;;;;;\nABC3;MEETEI MAYEK LETTER MIT;Lo;0;L;;;;;N;;;;;\nABC4;MEETEI MAYEK LETTER PA;Lo;0;L;;;;;N;;;;;\nABC5;MEETEI MAYEK LETTER NA;Lo;0;L;;;;;N;;;;;\nABC6;MEETEI MAYEK LETTER CHIL;Lo;0;L;;;;;N;;;;;\nABC7;MEETEI MAYEK LETTER TIL;Lo;0;L;;;;;N;;;;;\nABC8;MEETEI MAYEK LETTER KHOU;Lo;0;L;;;;;N;;;;;\nABC9;MEETEI MAYEK LETTER NGOU;Lo;0;L;;;;;N;;;;;\nABCA;MEETEI MAYEK LETTER THOU;Lo;0;L;;;;;N;;;;;\nABCB;MEETEI MAYEK LETTER WAI;Lo;0;L;;;;;N;;;;;\nABCC;MEETEI MAYEK LETTER YANG;Lo;0;L;;;;;N;;;;;\nABCD;MEETEI MAYEK LETTER HUK;Lo;0;L;;;;;N;;;;;\nABCE;MEETEI MAYEK LETTER UN;Lo;0;L;;;;;N;;;;;\nABCF;MEETEI MAYEK LETTER I;Lo;0;L;;;;;N;;;;;\nABD0;MEETEI MAYEK LETTER PHAM;Lo;0;L;;;;;N;;;;;\nABD1;MEETEI MAYEK LETTER ATIYA;Lo;0;L;;;;;N;;;;;\nABD2;MEETEI MAYEK LETTER GOK;Lo;0;L;;;;;N;;;;;\nABD3;MEETEI MAYEK LETTER JHAM;Lo;0;L;;;;;N;;;;;\nABD4;MEETEI MAYEK LETTER RAI;Lo;0;L;;;;;N;;;;;\nABD5;MEETEI MAYEK LETTER BA;Lo;0;L;;;;;N;;;;;\nABD6;MEETEI MAYEK LETTER JIL;Lo;0;L;;;;;N;;;;;\nABD7;MEETEI MAYEK LETTER DIL;Lo;0;L;;;;;N;;;;;\nABD8;MEETEI MAYEK LETTER GHOU;Lo;0;L;;;;;N;;;;;\nABD9;MEETEI MAYEK LETTER DHOU;Lo;0;L;;;;;N;;;;;\nABDA;MEETEI MAYEK LETTER BHAM;Lo;0;L;;;;;N;;;;;\nABDB;MEETEI MAYEK LETTER KOK LONSUM;Lo;0;L;;;;;N;;;;;\nABDC;MEETEI MAYEK LETTER LAI LONSUM;Lo;0;L;;;;;N;;;;;\nABDD;MEETEI MAYEK LETTER MIT LONSUM;Lo;0;L;;;;;N;;;;;\nABDE;MEETEI MAYEK LETTER PA LONSUM;Lo;0;L;;;;;N;;;;;\nABDF;MEETEI MAYEK LETTER NA LONSUM;Lo;0;L;;;;;N;;;;;\nABE0;MEETEI MAYEK LETTER TIL LONSUM;Lo;0;L;;;;;N;;;;;\nABE1;MEETEI MAYEK LETTER NGOU LONSUM;Lo;0;L;;;;;N;;;;;\nABE2;MEETEI MAYEK LETTER I LONSUM;Lo;0;L;;;;;N;;;;;\nABE3;MEETEI MAYEK VOWEL SIGN ONAP;Mc;0;L;;;;;N;;;;;\nABE4;MEETEI MAYEK VOWEL SIGN INAP;Mc;0;L;;;;;N;;;;;\nABE5;MEETEI MAYEK VOWEL SIGN ANAP;Mn;0;NSM;;;;;N;;;;;\nABE6;MEETEI MAYEK VOWEL SIGN YENAP;Mc;0;L;;;;;N;;;;;\nABE7;MEETEI MAYEK VOWEL SIGN SOUNAP;Mc;0;L;;;;;N;;;;;\nABE8;MEETEI MAYEK VOWEL SIGN UNAP;Mn;0;NSM;;;;;N;;;;;\nABE9;MEETEI MAYEK VOWEL SIGN CHEINAP;Mc;0;L;;;;;N;;;;;\nABEA;MEETEI MAYEK VOWEL SIGN NUNG;Mc;0;L;;;;;N;;;;;\nABEB;MEETEI MAYEK CHEIKHEI;Po;0;L;;;;;N;;;;;\nABEC;MEETEI MAYEK LUM IYEK;Mc;0;L;;;;;N;;;;;\nABED;MEETEI MAYEK APUN IYEK;Mn;9;NSM;;;;;N;;;;;\nABF0;MEETEI MAYEK DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\nABF1;MEETEI MAYEK DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\nABF2;MEETEI MAYEK DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\nABF3;MEETEI MAYEK DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\nABF4;MEETEI MAYEK DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\nABF5;MEETEI MAYEK DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\nABF6;MEETEI MAYEK DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\nABF7;MEETEI MAYEK DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\nABF8;MEETEI MAYEK DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\nABF9;MEETEI MAYEK DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\nAC00;<Hangul Syllable, First>;Lo;0;L;;;;;N;;;;;\nD7A3;<Hangul Syllable, Last>;Lo;0;L;;;;;N;;;;;\nD7B0;HANGUL JUNGSEONG O-YEO;Lo;0;L;;;;;N;;;;;\nD7B1;HANGUL JUNGSEONG O-O-I;Lo;0;L;;;;;N;;;;;\nD7B2;HANGUL JUNGSEONG YO-A;Lo;0;L;;;;;N;;;;;\nD7B3;HANGUL JUNGSEONG YO-AE;Lo;0;L;;;;;N;;;;;\nD7B4;HANGUL JUNGSEONG YO-EO;Lo;0;L;;;;;N;;;;;\nD7B5;HANGUL JUNGSEONG U-YEO;Lo;0;L;;;;;N;;;;;\nD7B6;HANGUL JUNGSEONG U-I-I;Lo;0;L;;;;;N;;;;;\nD7B7;HANGUL JUNGSEONG YU-AE;Lo;0;L;;;;;N;;;;;\nD7B8;HANGUL JUNGSEONG YU-O;Lo;0;L;;;;;N;;;;;\nD7B9;HANGUL JUNGSEONG EU-A;Lo;0;L;;;;;N;;;;;\nD7BA;HANGUL JUNGSEONG EU-EO;Lo;0;L;;;;;N;;;;;\nD7BB;HANGUL JUNGSEONG EU-E;Lo;0;L;;;;;N;;;;;\nD7BC;HANGUL JUNGSEONG EU-O;Lo;0;L;;;;;N;;;;;\nD7BD;HANGUL JUNGSEONG I-YA-O;Lo;0;L;;;;;N;;;;;\nD7BE;HANGUL JUNGSEONG I-YAE;Lo;0;L;;;;;N;;;;;\nD7BF;HANGUL JUNGSEONG I-YEO;Lo;0;L;;;;;N;;;;;\nD7C0;HANGUL JUNGSEONG I-YE;Lo;0;L;;;;;N;;;;;\nD7C1;HANGUL JUNGSEONG I-O-I;Lo;0;L;;;;;N;;;;;\nD7C2;HANGUL JUNGSEONG I-YO;Lo;0;L;;;;;N;;;;;\nD7C3;HANGUL JUNGSEONG I-YU;Lo;0;L;;;;;N;;;;;\nD7C4;HANGUL JUNGSEONG I-I;Lo;0;L;;;;;N;;;;;\nD7C5;HANGUL JUNGSEONG ARAEA-A;Lo;0;L;;;;;N;;;;;\nD7C6;HANGUL JUNGSEONG ARAEA-E;Lo;0;L;;;;;N;;;;;\nD7CB;HANGUL JONGSEONG NIEUN-RIEUL;Lo;0;L;;;;;N;;;;;\nD7CC;HANGUL JONGSEONG NIEUN-CHIEUCH;Lo;0;L;;;;;N;;;;;\nD7CD;HANGUL JONGSEONG SSANGTIKEUT;Lo;0;L;;;;;N;;;;;\nD7CE;HANGUL JONGSEONG SSANGTIKEUT-PIEUP;Lo;0;L;;;;;N;;;;;\nD7CF;HANGUL JONGSEONG TIKEUT-PIEUP;Lo;0;L;;;;;N;;;;;\nD7D0;HANGUL JONGSEONG TIKEUT-SIOS;Lo;0;L;;;;;N;;;;;\nD7D1;HANGUL JONGSEONG TIKEUT-SIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\nD7D2;HANGUL JONGSEONG TIKEUT-CIEUC;Lo;0;L;;;;;N;;;;;\nD7D3;HANGUL JONGSEONG TIKEUT-CHIEUCH;Lo;0;L;;;;;N;;;;;\nD7D4;HANGUL JONGSEONG TIKEUT-THIEUTH;Lo;0;L;;;;;N;;;;;\nD7D5;HANGUL JONGSEONG RIEUL-SSANGKIYEOK;Lo;0;L;;;;;N;;;;;\nD7D6;HANGUL JONGSEONG RIEUL-KIYEOK-HIEUH;Lo;0;L;;;;;N;;;;;\nD7D7;HANGUL JONGSEONG SSANGRIEUL-KHIEUKH;Lo;0;L;;;;;N;;;;;\nD7D8;HANGUL JONGSEONG RIEUL-MIEUM-HIEUH;Lo;0;L;;;;;N;;;;;\nD7D9;HANGUL JONGSEONG RIEUL-PIEUP-TIKEUT;Lo;0;L;;;;;N;;;;;\nD7DA;HANGUL JONGSEONG RIEUL-PIEUP-PHIEUPH;Lo;0;L;;;;;N;;;;;\nD7DB;HANGUL JONGSEONG RIEUL-YESIEUNG;Lo;0;L;;;;;N;;;;;\nD7DC;HANGUL JONGSEONG RIEUL-YEORINHIEUH-HIEUH;Lo;0;L;;;;;N;;;;;\nD7DD;HANGUL JONGSEONG KAPYEOUNRIEUL;Lo;0;L;;;;;N;;;;;\nD7DE;HANGUL JONGSEONG MIEUM-NIEUN;Lo;0;L;;;;;N;;;;;\nD7DF;HANGUL JONGSEONG MIEUM-SSANGNIEUN;Lo;0;L;;;;;N;;;;;\nD7E0;HANGUL JONGSEONG SSANGMIEUM;Lo;0;L;;;;;N;;;;;\nD7E1;HANGUL JONGSEONG MIEUM-PIEUP-SIOS;Lo;0;L;;;;;N;;;;;\nD7E2;HANGUL JONGSEONG MIEUM-CIEUC;Lo;0;L;;;;;N;;;;;\nD7E3;HANGUL JONGSEONG PIEUP-TIKEUT;Lo;0;L;;;;;N;;;;;\nD7E4;HANGUL JONGSEONG PIEUP-RIEUL-PHIEUPH;Lo;0;L;;;;;N;;;;;\nD7E5;HANGUL JONGSEONG PIEUP-MIEUM;Lo;0;L;;;;;N;;;;;\nD7E6;HANGUL JONGSEONG SSANGPIEUP;Lo;0;L;;;;;N;;;;;\nD7E7;HANGUL JONGSEONG PIEUP-SIOS-TIKEUT;Lo;0;L;;;;;N;;;;;\nD7E8;HANGUL JONGSEONG PIEUP-CIEUC;Lo;0;L;;;;;N;;;;;\nD7E9;HANGUL JONGSEONG PIEUP-CHIEUCH;Lo;0;L;;;;;N;;;;;\nD7EA;HANGUL JONGSEONG SIOS-MIEUM;Lo;0;L;;;;;N;;;;;\nD7EB;HANGUL JONGSEONG SIOS-KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\nD7EC;HANGUL JONGSEONG SSANGSIOS-KIYEOK;Lo;0;L;;;;;N;;;;;\nD7ED;HANGUL JONGSEONG SSANGSIOS-TIKEUT;Lo;0;L;;;;;N;;;;;\nD7EE;HANGUL JONGSEONG SIOS-PANSIOS;Lo;0;L;;;;;N;;;;;\nD7EF;HANGUL JONGSEONG SIOS-CIEUC;Lo;0;L;;;;;N;;;;;\nD7F0;HANGUL JONGSEONG SIOS-CHIEUCH;Lo;0;L;;;;;N;;;;;\nD7F1;HANGUL JONGSEONG SIOS-THIEUTH;Lo;0;L;;;;;N;;;;;\nD7F2;HANGUL JONGSEONG SIOS-HIEUH;Lo;0;L;;;;;N;;;;;\nD7F3;HANGUL JONGSEONG PANSIOS-PIEUP;Lo;0;L;;;;;N;;;;;\nD7F4;HANGUL JONGSEONG PANSIOS-KAPYEOUNPIEUP;Lo;0;L;;;;;N;;;;;\nD7F5;HANGUL JONGSEONG YESIEUNG-MIEUM;Lo;0;L;;;;;N;;;;;\nD7F6;HANGUL JONGSEONG YESIEUNG-HIEUH;Lo;0;L;;;;;N;;;;;\nD7F7;HANGUL JONGSEONG CIEUC-PIEUP;Lo;0;L;;;;;N;;;;;\nD7F8;HANGUL JONGSEONG CIEUC-SSANGPIEUP;Lo;0;L;;;;;N;;;;;\nD7F9;HANGUL JONGSEONG SSANGCIEUC;Lo;0;L;;;;;N;;;;;\nD7FA;HANGUL JONGSEONG PHIEUPH-SIOS;Lo;0;L;;;;;N;;;;;\nD7FB;HANGUL JONGSEONG PHIEUPH-THIEUTH;Lo;0;L;;;;;N;;;;;\nD800;<Non Private Use High Surrogate, First>;Cs;0;L;;;;;N;;;;;\nDB7F;<Non Private Use High Surrogate, Last>;Cs;0;L;;;;;N;;;;;\nDB80;<Private Use High Surrogate, First>;Cs;0;L;;;;;N;;;;;\nDBFF;<Private Use High Surrogate, Last>;Cs;0;L;;;;;N;;;;;\nDC00;<Low Surrogate, First>;Cs;0;L;;;;;N;;;;;\nDFFF;<Low Surrogate, Last>;Cs;0;L;;;;;N;;;;;\nE000;<Private Use, First>;Co;0;L;;;;;N;;;;;\nF8FF;<Private Use, Last>;Co;0;L;;;;;N;;;;;\nF900;CJK COMPATIBILITY IDEOGRAPH-F900;Lo;0;L;8C48;;;;N;;;;;\nF901;CJK COMPATIBILITY IDEOGRAPH-F901;Lo;0;L;66F4;;;;N;;;;;\nF902;CJK COMPATIBILITY IDEOGRAPH-F902;Lo;0;L;8ECA;;;;N;;;;;\nF903;CJK COMPATIBILITY IDEOGRAPH-F903;Lo;0;L;8CC8;;;;N;;;;;\nF904;CJK COMPATIBILITY IDEOGRAPH-F904;Lo;0;L;6ED1;;;;N;;;;;\nF905;CJK COMPATIBILITY IDEOGRAPH-F905;Lo;0;L;4E32;;;;N;;;;;\nF906;CJK COMPATIBILITY IDEOGRAPH-F906;Lo;0;L;53E5;;;;N;;;;;\nF907;CJK COMPATIBILITY IDEOGRAPH-F907;Lo;0;L;9F9C;;;;N;;;;;\nF908;CJK COMPATIBILITY IDEOGRAPH-F908;Lo;0;L;9F9C;;;;N;;;;;\nF909;CJK COMPATIBILITY IDEOGRAPH-F909;Lo;0;L;5951;;;;N;;;;;\nF90A;CJK COMPATIBILITY IDEOGRAPH-F90A;Lo;0;L;91D1;;;;N;;;;;\nF90B;CJK COMPATIBILITY IDEOGRAPH-F90B;Lo;0;L;5587;;;;N;;;;;\nF90C;CJK COMPATIBILITY IDEOGRAPH-F90C;Lo;0;L;5948;;;;N;;;;;\nF90D;CJK COMPATIBILITY IDEOGRAPH-F90D;Lo;0;L;61F6;;;;N;;;;;\nF90E;CJK COMPATIBILITY IDEOGRAPH-F90E;Lo;0;L;7669;;;;N;;;;;\nF90F;CJK COMPATIBILITY IDEOGRAPH-F90F;Lo;0;L;7F85;;;;N;;;;;\nF910;CJK COMPATIBILITY IDEOGRAPH-F910;Lo;0;L;863F;;;;N;;;;;\nF911;CJK COMPATIBILITY IDEOGRAPH-F911;Lo;0;L;87BA;;;;N;;;;;\nF912;CJK COMPATIBILITY IDEOGRAPH-F912;Lo;0;L;88F8;;;;N;;;;;\nF913;CJK COMPATIBILITY IDEOGRAPH-F913;Lo;0;L;908F;;;;N;;;;;\nF914;CJK COMPATIBILITY IDEOGRAPH-F914;Lo;0;L;6A02;;;;N;;;;;\nF915;CJK COMPATIBILITY IDEOGRAPH-F915;Lo;0;L;6D1B;;;;N;;;;;\nF916;CJK COMPATIBILITY IDEOGRAPH-F916;Lo;0;L;70D9;;;;N;;;;;\nF917;CJK COMPATIBILITY IDEOGRAPH-F917;Lo;0;L;73DE;;;;N;;;;;\nF918;CJK COMPATIBILITY IDEOGRAPH-F918;Lo;0;L;843D;;;;N;;;;;\nF919;CJK COMPATIBILITY IDEOGRAPH-F919;Lo;0;L;916A;;;;N;;;;;\nF91A;CJK COMPATIBILITY IDEOGRAPH-F91A;Lo;0;L;99F1;;;;N;;;;;\nF91B;CJK COMPATIBILITY IDEOGRAPH-F91B;Lo;0;L;4E82;;;;N;;;;;\nF91C;CJK COMPATIBILITY IDEOGRAPH-F91C;Lo;0;L;5375;;;;N;;;;;\nF91D;CJK COMPATIBILITY IDEOGRAPH-F91D;Lo;0;L;6B04;;;;N;;;;;\nF91E;CJK COMPATIBILITY IDEOGRAPH-F91E;Lo;0;L;721B;;;;N;;;;;\nF91F;CJK COMPATIBILITY IDEOGRAPH-F91F;Lo;0;L;862D;;;;N;;;;;\nF920;CJK COMPATIBILITY IDEOGRAPH-F920;Lo;0;L;9E1E;;;;N;;;;;\nF921;CJK COMPATIBILITY IDEOGRAPH-F921;Lo;0;L;5D50;;;;N;;;;;\nF922;CJK COMPATIBILITY IDEOGRAPH-F922;Lo;0;L;6FEB;;;;N;;;;;\nF923;CJK COMPATIBILITY IDEOGRAPH-F923;Lo;0;L;85CD;;;;N;;;;;\nF924;CJK COMPATIBILITY IDEOGRAPH-F924;Lo;0;L;8964;;;;N;;;;;\nF925;CJK COMPATIBILITY IDEOGRAPH-F925;Lo;0;L;62C9;;;;N;;;;;\nF926;CJK COMPATIBILITY IDEOGRAPH-F926;Lo;0;L;81D8;;;;N;;;;;\nF927;CJK COMPATIBILITY IDEOGRAPH-F927;Lo;0;L;881F;;;;N;;;;;\nF928;CJK COMPATIBILITY IDEOGRAPH-F928;Lo;0;L;5ECA;;;;N;;;;;\nF929;CJK COMPATIBILITY IDEOGRAPH-F929;Lo;0;L;6717;;;;N;;;;;\nF92A;CJK COMPATIBILITY IDEOGRAPH-F92A;Lo;0;L;6D6A;;;;N;;;;;\nF92B;CJK COMPATIBILITY IDEOGRAPH-F92B;Lo;0;L;72FC;;;;N;;;;;\nF92C;CJK COMPATIBILITY IDEOGRAPH-F92C;Lo;0;L;90CE;;;;N;;;;;\nF92D;CJK COMPATIBILITY IDEOGRAPH-F92D;Lo;0;L;4F86;;;;N;;;;;\nF92E;CJK COMPATIBILITY IDEOGRAPH-F92E;Lo;0;L;51B7;;;;N;;;;;\nF92F;CJK COMPATIBILITY IDEOGRAPH-F92F;Lo;0;L;52DE;;;;N;;;;;\nF930;CJK COMPATIBILITY IDEOGRAPH-F930;Lo;0;L;64C4;;;;N;;;;;\nF931;CJK COMPATIBILITY IDEOGRAPH-F931;Lo;0;L;6AD3;;;;N;;;;;\nF932;CJK COMPATIBILITY IDEOGRAPH-F932;Lo;0;L;7210;;;;N;;;;;\nF933;CJK COMPATIBILITY IDEOGRAPH-F933;Lo;0;L;76E7;;;;N;;;;;\nF934;CJK COMPATIBILITY IDEOGRAPH-F934;Lo;0;L;8001;;;;N;;;;;\nF935;CJK COMPATIBILITY IDEOGRAPH-F935;Lo;0;L;8606;;;;N;;;;;\nF936;CJK COMPATIBILITY IDEOGRAPH-F936;Lo;0;L;865C;;;;N;;;;;\nF937;CJK COMPATIBILITY IDEOGRAPH-F937;Lo;0;L;8DEF;;;;N;;;;;\nF938;CJK COMPATIBILITY IDEOGRAPH-F938;Lo;0;L;9732;;;;N;;;;;\nF939;CJK COMPATIBILITY IDEOGRAPH-F939;Lo;0;L;9B6F;;;;N;;;;;\nF93A;CJK COMPATIBILITY IDEOGRAPH-F93A;Lo;0;L;9DFA;;;;N;;;;;\nF93B;CJK COMPATIBILITY IDEOGRAPH-F93B;Lo;0;L;788C;;;;N;;;;;\nF93C;CJK COMPATIBILITY IDEOGRAPH-F93C;Lo;0;L;797F;;;;N;;;;;\nF93D;CJK COMPATIBILITY IDEOGRAPH-F93D;Lo;0;L;7DA0;;;;N;;;;;\nF93E;CJK COMPATIBILITY IDEOGRAPH-F93E;Lo;0;L;83C9;;;;N;;;;;\nF93F;CJK COMPATIBILITY IDEOGRAPH-F93F;Lo;0;L;9304;;;;N;;;;;\nF940;CJK COMPATIBILITY IDEOGRAPH-F940;Lo;0;L;9E7F;;;;N;;;;;\nF941;CJK COMPATIBILITY IDEOGRAPH-F941;Lo;0;L;8AD6;;;;N;;;;;\nF942;CJK COMPATIBILITY IDEOGRAPH-F942;Lo;0;L;58DF;;;;N;;;;;\nF943;CJK COMPATIBILITY IDEOGRAPH-F943;Lo;0;L;5F04;;;;N;;;;;\nF944;CJK COMPATIBILITY IDEOGRAPH-F944;Lo;0;L;7C60;;;;N;;;;;\nF945;CJK COMPATIBILITY IDEOGRAPH-F945;Lo;0;L;807E;;;;N;;;;;\nF946;CJK COMPATIBILITY IDEOGRAPH-F946;Lo;0;L;7262;;;;N;;;;;\nF947;CJK COMPATIBILITY IDEOGRAPH-F947;Lo;0;L;78CA;;;;N;;;;;\nF948;CJK COMPATIBILITY IDEOGRAPH-F948;Lo;0;L;8CC2;;;;N;;;;;\nF949;CJK COMPATIBILITY IDEOGRAPH-F949;Lo;0;L;96F7;;;;N;;;;;\nF94A;CJK COMPATIBILITY IDEOGRAPH-F94A;Lo;0;L;58D8;;;;N;;;;;\nF94B;CJK COMPATIBILITY IDEOGRAPH-F94B;Lo;0;L;5C62;;;;N;;;;;\nF94C;CJK COMPATIBILITY IDEOGRAPH-F94C;Lo;0;L;6A13;;;;N;;;;;\nF94D;CJK COMPATIBILITY IDEOGRAPH-F94D;Lo;0;L;6DDA;;;;N;;;;;\nF94E;CJK COMPATIBILITY IDEOGRAPH-F94E;Lo;0;L;6F0F;;;;N;;;;;\nF94F;CJK COMPATIBILITY IDEOGRAPH-F94F;Lo;0;L;7D2F;;;;N;;;;;\nF950;CJK COMPATIBILITY IDEOGRAPH-F950;Lo;0;L;7E37;;;;N;;;;;\nF951;CJK COMPATIBILITY IDEOGRAPH-F951;Lo;0;L;964B;;;;N;;;;;\nF952;CJK COMPATIBILITY IDEOGRAPH-F952;Lo;0;L;52D2;;;;N;;;;;\nF953;CJK COMPATIBILITY IDEOGRAPH-F953;Lo;0;L;808B;;;;N;;;;;\nF954;CJK COMPATIBILITY IDEOGRAPH-F954;Lo;0;L;51DC;;;;N;;;;;\nF955;CJK COMPATIBILITY IDEOGRAPH-F955;Lo;0;L;51CC;;;;N;;;;;\nF956;CJK COMPATIBILITY IDEOGRAPH-F956;Lo;0;L;7A1C;;;;N;;;;;\nF957;CJK COMPATIBILITY IDEOGRAPH-F957;Lo;0;L;7DBE;;;;N;;;;;\nF958;CJK COMPATIBILITY IDEOGRAPH-F958;Lo;0;L;83F1;;;;N;;;;;\nF959;CJK COMPATIBILITY IDEOGRAPH-F959;Lo;0;L;9675;;;;N;;;;;\nF95A;CJK COMPATIBILITY IDEOGRAPH-F95A;Lo;0;L;8B80;;;;N;;;;;\nF95B;CJK COMPATIBILITY IDEOGRAPH-F95B;Lo;0;L;62CF;;;;N;;;;;\nF95C;CJK COMPATIBILITY IDEOGRAPH-F95C;Lo;0;L;6A02;;;;N;;;;;\nF95D;CJK COMPATIBILITY IDEOGRAPH-F95D;Lo;0;L;8AFE;;;;N;;;;;\nF95E;CJK COMPATIBILITY IDEOGRAPH-F95E;Lo;0;L;4E39;;;;N;;;;;\nF95F;CJK COMPATIBILITY IDEOGRAPH-F95F;Lo;0;L;5BE7;;;;N;;;;;\nF960;CJK COMPATIBILITY IDEOGRAPH-F960;Lo;0;L;6012;;;;N;;;;;\nF961;CJK COMPATIBILITY IDEOGRAPH-F961;Lo;0;L;7387;;;;N;;;;;\nF962;CJK COMPATIBILITY IDEOGRAPH-F962;Lo;0;L;7570;;;;N;;;;;\nF963;CJK COMPATIBILITY IDEOGRAPH-F963;Lo;0;L;5317;;;;N;;;;;\nF964;CJK COMPATIBILITY IDEOGRAPH-F964;Lo;0;L;78FB;;;;N;;;;;\nF965;CJK COMPATIBILITY IDEOGRAPH-F965;Lo;0;L;4FBF;;;;N;;;;;\nF966;CJK COMPATIBILITY IDEOGRAPH-F966;Lo;0;L;5FA9;;;;N;;;;;\nF967;CJK COMPATIBILITY IDEOGRAPH-F967;Lo;0;L;4E0D;;;;N;;;;;\nF968;CJK COMPATIBILITY IDEOGRAPH-F968;Lo;0;L;6CCC;;;;N;;;;;\nF969;CJK COMPATIBILITY IDEOGRAPH-F969;Lo;0;L;6578;;;;N;;;;;\nF96A;CJK COMPATIBILITY IDEOGRAPH-F96A;Lo;0;L;7D22;;;;N;;;;;\nF96B;CJK COMPATIBILITY IDEOGRAPH-F96B;Lo;0;L;53C3;;;3;N;;;;;\nF96C;CJK COMPATIBILITY IDEOGRAPH-F96C;Lo;0;L;585E;;;;N;;;;;\nF96D;CJK COMPATIBILITY IDEOGRAPH-F96D;Lo;0;L;7701;;;;N;;;;;\nF96E;CJK COMPATIBILITY IDEOGRAPH-F96E;Lo;0;L;8449;;;;N;;;;;\nF96F;CJK COMPATIBILITY IDEOGRAPH-F96F;Lo;0;L;8AAA;;;;N;;;;;\nF970;CJK COMPATIBILITY IDEOGRAPH-F970;Lo;0;L;6BBA;;;;N;;;;;\nF971;CJK COMPATIBILITY IDEOGRAPH-F971;Lo;0;L;8FB0;;;;N;;;;;\nF972;CJK COMPATIBILITY IDEOGRAPH-F972;Lo;0;L;6C88;;;;N;;;;;\nF973;CJK COMPATIBILITY IDEOGRAPH-F973;Lo;0;L;62FE;;;10;N;;;;;\nF974;CJK COMPATIBILITY IDEOGRAPH-F974;Lo;0;L;82E5;;;;N;;;;;\nF975;CJK COMPATIBILITY IDEOGRAPH-F975;Lo;0;L;63A0;;;;N;;;;;\nF976;CJK COMPATIBILITY IDEOGRAPH-F976;Lo;0;L;7565;;;;N;;;;;\nF977;CJK COMPATIBILITY IDEOGRAPH-F977;Lo;0;L;4EAE;;;;N;;;;;\nF978;CJK COMPATIBILITY IDEOGRAPH-F978;Lo;0;L;5169;;;2;N;;;;;\nF979;CJK COMPATIBILITY IDEOGRAPH-F979;Lo;0;L;51C9;;;;N;;;;;\nF97A;CJK COMPATIBILITY IDEOGRAPH-F97A;Lo;0;L;6881;;;;N;;;;;\nF97B;CJK COMPATIBILITY IDEOGRAPH-F97B;Lo;0;L;7CE7;;;;N;;;;;\nF97C;CJK COMPATIBILITY IDEOGRAPH-F97C;Lo;0;L;826F;;;;N;;;;;\nF97D;CJK COMPATIBILITY IDEOGRAPH-F97D;Lo;0;L;8AD2;;;;N;;;;;\nF97E;CJK COMPATIBILITY IDEOGRAPH-F97E;Lo;0;L;91CF;;;;N;;;;;\nF97F;CJK COMPATIBILITY IDEOGRAPH-F97F;Lo;0;L;52F5;;;;N;;;;;\nF980;CJK COMPATIBILITY IDEOGRAPH-F980;Lo;0;L;5442;;;;N;;;;;\nF981;CJK COMPATIBILITY IDEOGRAPH-F981;Lo;0;L;5973;;;;N;;;;;\nF982;CJK COMPATIBILITY IDEOGRAPH-F982;Lo;0;L;5EEC;;;;N;;;;;\nF983;CJK COMPATIBILITY IDEOGRAPH-F983;Lo;0;L;65C5;;;;N;;;;;\nF984;CJK COMPATIBILITY IDEOGRAPH-F984;Lo;0;L;6FFE;;;;N;;;;;\nF985;CJK COMPATIBILITY IDEOGRAPH-F985;Lo;0;L;792A;;;;N;;;;;\nF986;CJK COMPATIBILITY IDEOGRAPH-F986;Lo;0;L;95AD;;;;N;;;;;\nF987;CJK COMPATIBILITY IDEOGRAPH-F987;Lo;0;L;9A6A;;;;N;;;;;\nF988;CJK COMPATIBILITY IDEOGRAPH-F988;Lo;0;L;9E97;;;;N;;;;;\nF989;CJK COMPATIBILITY IDEOGRAPH-F989;Lo;0;L;9ECE;;;;N;;;;;\nF98A;CJK COMPATIBILITY IDEOGRAPH-F98A;Lo;0;L;529B;;;;N;;;;;\nF98B;CJK COMPATIBILITY IDEOGRAPH-F98B;Lo;0;L;66C6;;;;N;;;;;\nF98C;CJK COMPATIBILITY IDEOGRAPH-F98C;Lo;0;L;6B77;;;;N;;;;;\nF98D;CJK COMPATIBILITY IDEOGRAPH-F98D;Lo;0;L;8F62;;;;N;;;;;\nF98E;CJK COMPATIBILITY IDEOGRAPH-F98E;Lo;0;L;5E74;;;;N;;;;;\nF98F;CJK COMPATIBILITY IDEOGRAPH-F98F;Lo;0;L;6190;;;;N;;;;;\nF990;CJK COMPATIBILITY IDEOGRAPH-F990;Lo;0;L;6200;;;;N;;;;;\nF991;CJK COMPATIBILITY IDEOGRAPH-F991;Lo;0;L;649A;;;;N;;;;;\nF992;CJK COMPATIBILITY IDEOGRAPH-F992;Lo;0;L;6F23;;;;N;;;;;\nF993;CJK COMPATIBILITY IDEOGRAPH-F993;Lo;0;L;7149;;;;N;;;;;\nF994;CJK COMPATIBILITY IDEOGRAPH-F994;Lo;0;L;7489;;;;N;;;;;\nF995;CJK COMPATIBILITY IDEOGRAPH-F995;Lo;0;L;79CA;;;;N;;;;;\nF996;CJK COMPATIBILITY IDEOGRAPH-F996;Lo;0;L;7DF4;;;;N;;;;;\nF997;CJK COMPATIBILITY IDEOGRAPH-F997;Lo;0;L;806F;;;;N;;;;;\nF998;CJK COMPATIBILITY IDEOGRAPH-F998;Lo;0;L;8F26;;;;N;;;;;\nF999;CJK COMPATIBILITY IDEOGRAPH-F999;Lo;0;L;84EE;;;;N;;;;;\nF99A;CJK COMPATIBILITY IDEOGRAPH-F99A;Lo;0;L;9023;;;;N;;;;;\nF99B;CJK COMPATIBILITY IDEOGRAPH-F99B;Lo;0;L;934A;;;;N;;;;;\nF99C;CJK COMPATIBILITY IDEOGRAPH-F99C;Lo;0;L;5217;;;;N;;;;;\nF99D;CJK COMPATIBILITY IDEOGRAPH-F99D;Lo;0;L;52A3;;;;N;;;;;\nF99E;CJK COMPATIBILITY IDEOGRAPH-F99E;Lo;0;L;54BD;;;;N;;;;;\nF99F;CJK COMPATIBILITY IDEOGRAPH-F99F;Lo;0;L;70C8;;;;N;;;;;\nF9A0;CJK COMPATIBILITY IDEOGRAPH-F9A0;Lo;0;L;88C2;;;;N;;;;;\nF9A1;CJK COMPATIBILITY IDEOGRAPH-F9A1;Lo;0;L;8AAA;;;;N;;;;;\nF9A2;CJK COMPATIBILITY IDEOGRAPH-F9A2;Lo;0;L;5EC9;;;;N;;;;;\nF9A3;CJK COMPATIBILITY IDEOGRAPH-F9A3;Lo;0;L;5FF5;;;;N;;;;;\nF9A4;CJK COMPATIBILITY IDEOGRAPH-F9A4;Lo;0;L;637B;;;;N;;;;;\nF9A5;CJK COMPATIBILITY IDEOGRAPH-F9A5;Lo;0;L;6BAE;;;;N;;;;;\nF9A6;CJK COMPATIBILITY IDEOGRAPH-F9A6;Lo;0;L;7C3E;;;;N;;;;;\nF9A7;CJK COMPATIBILITY IDEOGRAPH-F9A7;Lo;0;L;7375;;;;N;;;;;\nF9A8;CJK COMPATIBILITY IDEOGRAPH-F9A8;Lo;0;L;4EE4;;;;N;;;;;\nF9A9;CJK COMPATIBILITY IDEOGRAPH-F9A9;Lo;0;L;56F9;;;;N;;;;;\nF9AA;CJK COMPATIBILITY IDEOGRAPH-F9AA;Lo;0;L;5BE7;;;;N;;;;;\nF9AB;CJK COMPATIBILITY IDEOGRAPH-F9AB;Lo;0;L;5DBA;;;;N;;;;;\nF9AC;CJK COMPATIBILITY IDEOGRAPH-F9AC;Lo;0;L;601C;;;;N;;;;;\nF9AD;CJK COMPATIBILITY IDEOGRAPH-F9AD;Lo;0;L;73B2;;;;N;;;;;\nF9AE;CJK COMPATIBILITY IDEOGRAPH-F9AE;Lo;0;L;7469;;;;N;;;;;\nF9AF;CJK COMPATIBILITY IDEOGRAPH-F9AF;Lo;0;L;7F9A;;;;N;;;;;\nF9B0;CJK COMPATIBILITY IDEOGRAPH-F9B0;Lo;0;L;8046;;;;N;;;;;\nF9B1;CJK COMPATIBILITY IDEOGRAPH-F9B1;Lo;0;L;9234;;;;N;;;;;\nF9B2;CJK COMPATIBILITY IDEOGRAPH-F9B2;Lo;0;L;96F6;;;0;N;;;;;\nF9B3;CJK COMPATIBILITY IDEOGRAPH-F9B3;Lo;0;L;9748;;;;N;;;;;\nF9B4;CJK COMPATIBILITY IDEOGRAPH-F9B4;Lo;0;L;9818;;;;N;;;;;\nF9B5;CJK COMPATIBILITY IDEOGRAPH-F9B5;Lo;0;L;4F8B;;;;N;;;;;\nF9B6;CJK COMPATIBILITY IDEOGRAPH-F9B6;Lo;0;L;79AE;;;;N;;;;;\nF9B7;CJK COMPATIBILITY IDEOGRAPH-F9B7;Lo;0;L;91B4;;;;N;;;;;\nF9B8;CJK COMPATIBILITY IDEOGRAPH-F9B8;Lo;0;L;96B8;;;;N;;;;;\nF9B9;CJK COMPATIBILITY IDEOGRAPH-F9B9;Lo;0;L;60E1;;;;N;;;;;\nF9BA;CJK COMPATIBILITY IDEOGRAPH-F9BA;Lo;0;L;4E86;;;;N;;;;;\nF9BB;CJK COMPATIBILITY IDEOGRAPH-F9BB;Lo;0;L;50DA;;;;N;;;;;\nF9BC;CJK COMPATIBILITY IDEOGRAPH-F9BC;Lo;0;L;5BEE;;;;N;;;;;\nF9BD;CJK COMPATIBILITY IDEOGRAPH-F9BD;Lo;0;L;5C3F;;;;N;;;;;\nF9BE;CJK COMPATIBILITY IDEOGRAPH-F9BE;Lo;0;L;6599;;;;N;;;;;\nF9BF;CJK COMPATIBILITY IDEOGRAPH-F9BF;Lo;0;L;6A02;;;;N;;;;;\nF9C0;CJK COMPATIBILITY IDEOGRAPH-F9C0;Lo;0;L;71CE;;;;N;;;;;\nF9C1;CJK COMPATIBILITY IDEOGRAPH-F9C1;Lo;0;L;7642;;;;N;;;;;\nF9C2;CJK COMPATIBILITY IDEOGRAPH-F9C2;Lo;0;L;84FC;;;;N;;;;;\nF9C3;CJK COMPATIBILITY IDEOGRAPH-F9C3;Lo;0;L;907C;;;;N;;;;;\nF9C4;CJK COMPATIBILITY IDEOGRAPH-F9C4;Lo;0;L;9F8D;;;;N;;;;;\nF9C5;CJK COMPATIBILITY IDEOGRAPH-F9C5;Lo;0;L;6688;;;;N;;;;;\nF9C6;CJK COMPATIBILITY IDEOGRAPH-F9C6;Lo;0;L;962E;;;;N;;;;;\nF9C7;CJK COMPATIBILITY IDEOGRAPH-F9C7;Lo;0;L;5289;;;;N;;;;;\nF9C8;CJK COMPATIBILITY IDEOGRAPH-F9C8;Lo;0;L;677B;;;;N;;;;;\nF9C9;CJK COMPATIBILITY IDEOGRAPH-F9C9;Lo;0;L;67F3;;;;N;;;;;\nF9CA;CJK COMPATIBILITY IDEOGRAPH-F9CA;Lo;0;L;6D41;;;;N;;;;;\nF9CB;CJK COMPATIBILITY IDEOGRAPH-F9CB;Lo;0;L;6E9C;;;;N;;;;;\nF9CC;CJK COMPATIBILITY IDEOGRAPH-F9CC;Lo;0;L;7409;;;;N;;;;;\nF9CD;CJK COMPATIBILITY IDEOGRAPH-F9CD;Lo;0;L;7559;;;;N;;;;;\nF9CE;CJK COMPATIBILITY IDEOGRAPH-F9CE;Lo;0;L;786B;;;;N;;;;;\nF9CF;CJK COMPATIBILITY IDEOGRAPH-F9CF;Lo;0;L;7D10;;;;N;;;;;\nF9D0;CJK COMPATIBILITY IDEOGRAPH-F9D0;Lo;0;L;985E;;;;N;;;;;\nF9D1;CJK COMPATIBILITY IDEOGRAPH-F9D1;Lo;0;L;516D;;;6;N;;;;;\nF9D2;CJK COMPATIBILITY IDEOGRAPH-F9D2;Lo;0;L;622E;;;;N;;;;;\nF9D3;CJK COMPATIBILITY IDEOGRAPH-F9D3;Lo;0;L;9678;;;6;N;;;;;\nF9D4;CJK COMPATIBILITY IDEOGRAPH-F9D4;Lo;0;L;502B;;;;N;;;;;\nF9D5;CJK COMPATIBILITY IDEOGRAPH-F9D5;Lo;0;L;5D19;;;;N;;;;;\nF9D6;CJK COMPATIBILITY IDEOGRAPH-F9D6;Lo;0;L;6DEA;;;;N;;;;;\nF9D7;CJK COMPATIBILITY IDEOGRAPH-F9D7;Lo;0;L;8F2A;;;;N;;;;;\nF9D8;CJK COMPATIBILITY IDEOGRAPH-F9D8;Lo;0;L;5F8B;;;;N;;;;;\nF9D9;CJK COMPATIBILITY IDEOGRAPH-F9D9;Lo;0;L;6144;;;;N;;;;;\nF9DA;CJK COMPATIBILITY IDEOGRAPH-F9DA;Lo;0;L;6817;;;;N;;;;;\nF9DB;CJK COMPATIBILITY IDEOGRAPH-F9DB;Lo;0;L;7387;;;;N;;;;;\nF9DC;CJK COMPATIBILITY IDEOGRAPH-F9DC;Lo;0;L;9686;;;;N;;;;;\nF9DD;CJK COMPATIBILITY IDEOGRAPH-F9DD;Lo;0;L;5229;;;;N;;;;;\nF9DE;CJK COMPATIBILITY IDEOGRAPH-F9DE;Lo;0;L;540F;;;;N;;;;;\nF9DF;CJK COMPATIBILITY IDEOGRAPH-F9DF;Lo;0;L;5C65;;;;N;;;;;\nF9E0;CJK COMPATIBILITY IDEOGRAPH-F9E0;Lo;0;L;6613;;;;N;;;;;\nF9E1;CJK COMPATIBILITY IDEOGRAPH-F9E1;Lo;0;L;674E;;;;N;;;;;\nF9E2;CJK COMPATIBILITY IDEOGRAPH-F9E2;Lo;0;L;68A8;;;;N;;;;;\nF9E3;CJK COMPATIBILITY IDEOGRAPH-F9E3;Lo;0;L;6CE5;;;;N;;;;;\nF9E4;CJK COMPATIBILITY IDEOGRAPH-F9E4;Lo;0;L;7406;;;;N;;;;;\nF9E5;CJK COMPATIBILITY IDEOGRAPH-F9E5;Lo;0;L;75E2;;;;N;;;;;\nF9E6;CJK COMPATIBILITY IDEOGRAPH-F9E6;Lo;0;L;7F79;;;;N;;;;;\nF9E7;CJK COMPATIBILITY IDEOGRAPH-F9E7;Lo;0;L;88CF;;;;N;;;;;\nF9E8;CJK COMPATIBILITY IDEOGRAPH-F9E8;Lo;0;L;88E1;;;;N;;;;;\nF9E9;CJK COMPATIBILITY IDEOGRAPH-F9E9;Lo;0;L;91CC;;;;N;;;;;\nF9EA;CJK COMPATIBILITY IDEOGRAPH-F9EA;Lo;0;L;96E2;;;;N;;;;;\nF9EB;CJK COMPATIBILITY IDEOGRAPH-F9EB;Lo;0;L;533F;;;;N;;;;;\nF9EC;CJK COMPATIBILITY IDEOGRAPH-F9EC;Lo;0;L;6EBA;;;;N;;;;;\nF9ED;CJK COMPATIBILITY IDEOGRAPH-F9ED;Lo;0;L;541D;;;;N;;;;;\nF9EE;CJK COMPATIBILITY IDEOGRAPH-F9EE;Lo;0;L;71D0;;;;N;;;;;\nF9EF;CJK COMPATIBILITY IDEOGRAPH-F9EF;Lo;0;L;7498;;;;N;;;;;\nF9F0;CJK COMPATIBILITY IDEOGRAPH-F9F0;Lo;0;L;85FA;;;;N;;;;;\nF9F1;CJK COMPATIBILITY IDEOGRAPH-F9F1;Lo;0;L;96A3;;;;N;;;;;\nF9F2;CJK COMPATIBILITY IDEOGRAPH-F9F2;Lo;0;L;9C57;;;;N;;;;;\nF9F3;CJK COMPATIBILITY IDEOGRAPH-F9F3;Lo;0;L;9E9F;;;;N;;;;;\nF9F4;CJK COMPATIBILITY IDEOGRAPH-F9F4;Lo;0;L;6797;;;;N;;;;;\nF9F5;CJK COMPATIBILITY IDEOGRAPH-F9F5;Lo;0;L;6DCB;;;;N;;;;;\nF9F6;CJK COMPATIBILITY IDEOGRAPH-F9F6;Lo;0;L;81E8;;;;N;;;;;\nF9F7;CJK COMPATIBILITY IDEOGRAPH-F9F7;Lo;0;L;7ACB;;;;N;;;;;\nF9F8;CJK COMPATIBILITY IDEOGRAPH-F9F8;Lo;0;L;7B20;;;;N;;;;;\nF9F9;CJK COMPATIBILITY IDEOGRAPH-F9F9;Lo;0;L;7C92;;;;N;;;;;\nF9FA;CJK COMPATIBILITY IDEOGRAPH-F9FA;Lo;0;L;72C0;;;;N;;;;;\nF9FB;CJK COMPATIBILITY IDEOGRAPH-F9FB;Lo;0;L;7099;;;;N;;;;;\nF9FC;CJK COMPATIBILITY IDEOGRAPH-F9FC;Lo;0;L;8B58;;;;N;;;;;\nF9FD;CJK COMPATIBILITY IDEOGRAPH-F9FD;Lo;0;L;4EC0;;;10;N;;;;;\nF9FE;CJK COMPATIBILITY IDEOGRAPH-F9FE;Lo;0;L;8336;;;;N;;;;;\nF9FF;CJK COMPATIBILITY IDEOGRAPH-F9FF;Lo;0;L;523A;;;;N;;;;;\nFA00;CJK COMPATIBILITY IDEOGRAPH-FA00;Lo;0;L;5207;;;;N;;;;;\nFA01;CJK COMPATIBILITY IDEOGRAPH-FA01;Lo;0;L;5EA6;;;;N;;;;;\nFA02;CJK COMPATIBILITY IDEOGRAPH-FA02;Lo;0;L;62D3;;;;N;;;;;\nFA03;CJK COMPATIBILITY IDEOGRAPH-FA03;Lo;0;L;7CD6;;;;N;;;;;\nFA04;CJK COMPATIBILITY IDEOGRAPH-FA04;Lo;0;L;5B85;;;;N;;;;;\nFA05;CJK COMPATIBILITY IDEOGRAPH-FA05;Lo;0;L;6D1E;;;;N;;;;;\nFA06;CJK COMPATIBILITY IDEOGRAPH-FA06;Lo;0;L;66B4;;;;N;;;;;\nFA07;CJK COMPATIBILITY IDEOGRAPH-FA07;Lo;0;L;8F3B;;;;N;;;;;\nFA08;CJK COMPATIBILITY IDEOGRAPH-FA08;Lo;0;L;884C;;;;N;;;;;\nFA09;CJK COMPATIBILITY IDEOGRAPH-FA09;Lo;0;L;964D;;;;N;;;;;\nFA0A;CJK COMPATIBILITY IDEOGRAPH-FA0A;Lo;0;L;898B;;;;N;;;;;\nFA0B;CJK COMPATIBILITY IDEOGRAPH-FA0B;Lo;0;L;5ED3;;;;N;;;;;\nFA0C;CJK COMPATIBILITY IDEOGRAPH-FA0C;Lo;0;L;5140;;;;N;;;;;\nFA0D;CJK COMPATIBILITY IDEOGRAPH-FA0D;Lo;0;L;55C0;;;;N;;;;;\nFA0E;CJK COMPATIBILITY IDEOGRAPH-FA0E;Lo;0;L;;;;;N;;;;;\nFA0F;CJK COMPATIBILITY IDEOGRAPH-FA0F;Lo;0;L;;;;;N;;;;;\nFA10;CJK COMPATIBILITY IDEOGRAPH-FA10;Lo;0;L;585A;;;;N;;;;;\nFA11;CJK COMPATIBILITY IDEOGRAPH-FA11;Lo;0;L;;;;;N;;;;;\nFA12;CJK COMPATIBILITY IDEOGRAPH-FA12;Lo;0;L;6674;;;;N;;;;;\nFA13;CJK COMPATIBILITY IDEOGRAPH-FA13;Lo;0;L;;;;;N;;;;;\nFA14;CJK COMPATIBILITY IDEOGRAPH-FA14;Lo;0;L;;;;;N;;;;;\nFA15;CJK COMPATIBILITY IDEOGRAPH-FA15;Lo;0;L;51DE;;;;N;;;;;\nFA16;CJK COMPATIBILITY IDEOGRAPH-FA16;Lo;0;L;732A;;;;N;;;;;\nFA17;CJK COMPATIBILITY IDEOGRAPH-FA17;Lo;0;L;76CA;;;;N;;;;;\nFA18;CJK COMPATIBILITY IDEOGRAPH-FA18;Lo;0;L;793C;;;;N;;;;;\nFA19;CJK COMPATIBILITY IDEOGRAPH-FA19;Lo;0;L;795E;;;;N;;;;;\nFA1A;CJK COMPATIBILITY IDEOGRAPH-FA1A;Lo;0;L;7965;;;;N;;;;;\nFA1B;CJK COMPATIBILITY IDEOGRAPH-FA1B;Lo;0;L;798F;;;;N;;;;;\nFA1C;CJK COMPATIBILITY IDEOGRAPH-FA1C;Lo;0;L;9756;;;;N;;;;;\nFA1D;CJK COMPATIBILITY IDEOGRAPH-FA1D;Lo;0;L;7CBE;;;;N;;;;;\nFA1E;CJK COMPATIBILITY IDEOGRAPH-FA1E;Lo;0;L;7FBD;;;;N;;;;;\nFA1F;CJK COMPATIBILITY IDEOGRAPH-FA1F;Lo;0;L;;;;;N;;;;;\nFA20;CJK COMPATIBILITY IDEOGRAPH-FA20;Lo;0;L;8612;;;;N;;;;;\nFA21;CJK COMPATIBILITY IDEOGRAPH-FA21;Lo;0;L;;;;;N;;;;;\nFA22;CJK COMPATIBILITY IDEOGRAPH-FA22;Lo;0;L;8AF8;;;;N;;;;;\nFA23;CJK COMPATIBILITY IDEOGRAPH-FA23;Lo;0;L;;;;;N;;;;;\nFA24;CJK COMPATIBILITY IDEOGRAPH-FA24;Lo;0;L;;;;;N;;;;;\nFA25;CJK COMPATIBILITY IDEOGRAPH-FA25;Lo;0;L;9038;;;;N;;;;;\nFA26;CJK COMPATIBILITY IDEOGRAPH-FA26;Lo;0;L;90FD;;;;N;;;;;\nFA27;CJK COMPATIBILITY IDEOGRAPH-FA27;Lo;0;L;;;;;N;;;;;\nFA28;CJK COMPATIBILITY IDEOGRAPH-FA28;Lo;0;L;;;;;N;;;;;\nFA29;CJK COMPATIBILITY IDEOGRAPH-FA29;Lo;0;L;;;;;N;;;;;\nFA2A;CJK COMPATIBILITY IDEOGRAPH-FA2A;Lo;0;L;98EF;;;;N;;;;;\nFA2B;CJK COMPATIBILITY IDEOGRAPH-FA2B;Lo;0;L;98FC;;;;N;;;;;\nFA2C;CJK COMPATIBILITY IDEOGRAPH-FA2C;Lo;0;L;9928;;;;N;;;;;\nFA2D;CJK COMPATIBILITY IDEOGRAPH-FA2D;Lo;0;L;9DB4;;;;N;;;;;\nFA2E;CJK COMPATIBILITY IDEOGRAPH-FA2E;Lo;0;L;90DE;;;;N;;;;;\nFA2F;CJK COMPATIBILITY IDEOGRAPH-FA2F;Lo;0;L;96B7;;;;N;;;;;\nFA30;CJK COMPATIBILITY IDEOGRAPH-FA30;Lo;0;L;4FAE;;;;N;;;;;\nFA31;CJK COMPATIBILITY IDEOGRAPH-FA31;Lo;0;L;50E7;;;;N;;;;;\nFA32;CJK COMPATIBILITY IDEOGRAPH-FA32;Lo;0;L;514D;;;;N;;;;;\nFA33;CJK COMPATIBILITY IDEOGRAPH-FA33;Lo;0;L;52C9;;;;N;;;;;\nFA34;CJK COMPATIBILITY IDEOGRAPH-FA34;Lo;0;L;52E4;;;;N;;;;;\nFA35;CJK COMPATIBILITY IDEOGRAPH-FA35;Lo;0;L;5351;;;;N;;;;;\nFA36;CJK COMPATIBILITY IDEOGRAPH-FA36;Lo;0;L;559D;;;;N;;;;;\nFA37;CJK COMPATIBILITY IDEOGRAPH-FA37;Lo;0;L;5606;;;;N;;;;;\nFA38;CJK COMPATIBILITY IDEOGRAPH-FA38;Lo;0;L;5668;;;;N;;;;;\nFA39;CJK COMPATIBILITY IDEOGRAPH-FA39;Lo;0;L;5840;;;;N;;;;;\nFA3A;CJK COMPATIBILITY IDEOGRAPH-FA3A;Lo;0;L;58A8;;;;N;;;;;\nFA3B;CJK COMPATIBILITY IDEOGRAPH-FA3B;Lo;0;L;5C64;;;;N;;;;;\nFA3C;CJK COMPATIBILITY IDEOGRAPH-FA3C;Lo;0;L;5C6E;;;;N;;;;;\nFA3D;CJK COMPATIBILITY IDEOGRAPH-FA3D;Lo;0;L;6094;;;;N;;;;;\nFA3E;CJK COMPATIBILITY IDEOGRAPH-FA3E;Lo;0;L;6168;;;;N;;;;;\nFA3F;CJK COMPATIBILITY IDEOGRAPH-FA3F;Lo;0;L;618E;;;;N;;;;;\nFA40;CJK COMPATIBILITY IDEOGRAPH-FA40;Lo;0;L;61F2;;;;N;;;;;\nFA41;CJK COMPATIBILITY IDEOGRAPH-FA41;Lo;0;L;654F;;;;N;;;;;\nFA42;CJK COMPATIBILITY IDEOGRAPH-FA42;Lo;0;L;65E2;;;;N;;;;;\nFA43;CJK COMPATIBILITY IDEOGRAPH-FA43;Lo;0;L;6691;;;;N;;;;;\nFA44;CJK COMPATIBILITY IDEOGRAPH-FA44;Lo;0;L;6885;;;;N;;;;;\nFA45;CJK COMPATIBILITY IDEOGRAPH-FA45;Lo;0;L;6D77;;;;N;;;;;\nFA46;CJK COMPATIBILITY IDEOGRAPH-FA46;Lo;0;L;6E1A;;;;N;;;;;\nFA47;CJK COMPATIBILITY IDEOGRAPH-FA47;Lo;0;L;6F22;;;;N;;;;;\nFA48;CJK COMPATIBILITY IDEOGRAPH-FA48;Lo;0;L;716E;;;;N;;;;;\nFA49;CJK COMPATIBILITY IDEOGRAPH-FA49;Lo;0;L;722B;;;;N;;;;;\nFA4A;CJK COMPATIBILITY IDEOGRAPH-FA4A;Lo;0;L;7422;;;;N;;;;;\nFA4B;CJK COMPATIBILITY IDEOGRAPH-FA4B;Lo;0;L;7891;;;;N;;;;;\nFA4C;CJK COMPATIBILITY IDEOGRAPH-FA4C;Lo;0;L;793E;;;;N;;;;;\nFA4D;CJK COMPATIBILITY IDEOGRAPH-FA4D;Lo;0;L;7949;;;;N;;;;;\nFA4E;CJK COMPATIBILITY IDEOGRAPH-FA4E;Lo;0;L;7948;;;;N;;;;;\nFA4F;CJK COMPATIBILITY IDEOGRAPH-FA4F;Lo;0;L;7950;;;;N;;;;;\nFA50;CJK COMPATIBILITY IDEOGRAPH-FA50;Lo;0;L;7956;;;;N;;;;;\nFA51;CJK COMPATIBILITY IDEOGRAPH-FA51;Lo;0;L;795D;;;;N;;;;;\nFA52;CJK COMPATIBILITY IDEOGRAPH-FA52;Lo;0;L;798D;;;;N;;;;;\nFA53;CJK COMPATIBILITY IDEOGRAPH-FA53;Lo;0;L;798E;;;;N;;;;;\nFA54;CJK COMPATIBILITY IDEOGRAPH-FA54;Lo;0;L;7A40;;;;N;;;;;\nFA55;CJK COMPATIBILITY IDEOGRAPH-FA55;Lo;0;L;7A81;;;;N;;;;;\nFA56;CJK COMPATIBILITY IDEOGRAPH-FA56;Lo;0;L;7BC0;;;;N;;;;;\nFA57;CJK COMPATIBILITY IDEOGRAPH-FA57;Lo;0;L;7DF4;;;;N;;;;;\nFA58;CJK COMPATIBILITY IDEOGRAPH-FA58;Lo;0;L;7E09;;;;N;;;;;\nFA59;CJK COMPATIBILITY IDEOGRAPH-FA59;Lo;0;L;7E41;;;;N;;;;;\nFA5A;CJK COMPATIBILITY IDEOGRAPH-FA5A;Lo;0;L;7F72;;;;N;;;;;\nFA5B;CJK COMPATIBILITY IDEOGRAPH-FA5B;Lo;0;L;8005;;;;N;;;;;\nFA5C;CJK COMPATIBILITY IDEOGRAPH-FA5C;Lo;0;L;81ED;;;;N;;;;;\nFA5D;CJK COMPATIBILITY IDEOGRAPH-FA5D;Lo;0;L;8279;;;;N;;;;;\nFA5E;CJK COMPATIBILITY IDEOGRAPH-FA5E;Lo;0;L;8279;;;;N;;;;;\nFA5F;CJK COMPATIBILITY IDEOGRAPH-FA5F;Lo;0;L;8457;;;;N;;;;;\nFA60;CJK COMPATIBILITY IDEOGRAPH-FA60;Lo;0;L;8910;;;;N;;;;;\nFA61;CJK COMPATIBILITY IDEOGRAPH-FA61;Lo;0;L;8996;;;;N;;;;;\nFA62;CJK COMPATIBILITY IDEOGRAPH-FA62;Lo;0;L;8B01;;;;N;;;;;\nFA63;CJK COMPATIBILITY IDEOGRAPH-FA63;Lo;0;L;8B39;;;;N;;;;;\nFA64;CJK COMPATIBILITY IDEOGRAPH-FA64;Lo;0;L;8CD3;;;;N;;;;;\nFA65;CJK COMPATIBILITY IDEOGRAPH-FA65;Lo;0;L;8D08;;;;N;;;;;\nFA66;CJK COMPATIBILITY IDEOGRAPH-FA66;Lo;0;L;8FB6;;;;N;;;;;\nFA67;CJK COMPATIBILITY IDEOGRAPH-FA67;Lo;0;L;9038;;;;N;;;;;\nFA68;CJK COMPATIBILITY IDEOGRAPH-FA68;Lo;0;L;96E3;;;;N;;;;;\nFA69;CJK COMPATIBILITY IDEOGRAPH-FA69;Lo;0;L;97FF;;;;N;;;;;\nFA6A;CJK COMPATIBILITY IDEOGRAPH-FA6A;Lo;0;L;983B;;;;N;;;;;\nFA6B;CJK COMPATIBILITY IDEOGRAPH-FA6B;Lo;0;L;6075;;;;N;;;;;\nFA6C;CJK COMPATIBILITY IDEOGRAPH-FA6C;Lo;0;L;242EE;;;;N;;;;;\nFA6D;CJK COMPATIBILITY IDEOGRAPH-FA6D;Lo;0;L;8218;;;;N;;;;;\nFA70;CJK COMPATIBILITY IDEOGRAPH-FA70;Lo;0;L;4E26;;;;N;;;;;\nFA71;CJK COMPATIBILITY IDEOGRAPH-FA71;Lo;0;L;51B5;;;;N;;;;;\nFA72;CJK COMPATIBILITY IDEOGRAPH-FA72;Lo;0;L;5168;;;;N;;;;;\nFA73;CJK COMPATIBILITY IDEOGRAPH-FA73;Lo;0;L;4F80;;;;N;;;;;\nFA74;CJK COMPATIBILITY IDEOGRAPH-FA74;Lo;0;L;5145;;;;N;;;;;\nFA75;CJK COMPATIBILITY IDEOGRAPH-FA75;Lo;0;L;5180;;;;N;;;;;\nFA76;CJK COMPATIBILITY IDEOGRAPH-FA76;Lo;0;L;52C7;;;;N;;;;;\nFA77;CJK COMPATIBILITY IDEOGRAPH-FA77;Lo;0;L;52FA;;;;N;;;;;\nFA78;CJK COMPATIBILITY IDEOGRAPH-FA78;Lo;0;L;559D;;;;N;;;;;\nFA79;CJK COMPATIBILITY IDEOGRAPH-FA79;Lo;0;L;5555;;;;N;;;;;\nFA7A;CJK COMPATIBILITY IDEOGRAPH-FA7A;Lo;0;L;5599;;;;N;;;;;\nFA7B;CJK COMPATIBILITY IDEOGRAPH-FA7B;Lo;0;L;55E2;;;;N;;;;;\nFA7C;CJK COMPATIBILITY IDEOGRAPH-FA7C;Lo;0;L;585A;;;;N;;;;;\nFA7D;CJK COMPATIBILITY IDEOGRAPH-FA7D;Lo;0;L;58B3;;;;N;;;;;\nFA7E;CJK COMPATIBILITY IDEOGRAPH-FA7E;Lo;0;L;5944;;;;N;;;;;\nFA7F;CJK COMPATIBILITY IDEOGRAPH-FA7F;Lo;0;L;5954;;;;N;;;;;\nFA80;CJK COMPATIBILITY IDEOGRAPH-FA80;Lo;0;L;5A62;;;;N;;;;;\nFA81;CJK COMPATIBILITY IDEOGRAPH-FA81;Lo;0;L;5B28;;;;N;;;;;\nFA82;CJK COMPATIBILITY IDEOGRAPH-FA82;Lo;0;L;5ED2;;;;N;;;;;\nFA83;CJK COMPATIBILITY IDEOGRAPH-FA83;Lo;0;L;5ED9;;;;N;;;;;\nFA84;CJK COMPATIBILITY IDEOGRAPH-FA84;Lo;0;L;5F69;;;;N;;;;;\nFA85;CJK COMPATIBILITY IDEOGRAPH-FA85;Lo;0;L;5FAD;;;;N;;;;;\nFA86;CJK COMPATIBILITY IDEOGRAPH-FA86;Lo;0;L;60D8;;;;N;;;;;\nFA87;CJK COMPATIBILITY IDEOGRAPH-FA87;Lo;0;L;614E;;;;N;;;;;\nFA88;CJK COMPATIBILITY IDEOGRAPH-FA88;Lo;0;L;6108;;;;N;;;;;\nFA89;CJK COMPATIBILITY IDEOGRAPH-FA89;Lo;0;L;618E;;;;N;;;;;\nFA8A;CJK COMPATIBILITY IDEOGRAPH-FA8A;Lo;0;L;6160;;;;N;;;;;\nFA8B;CJK COMPATIBILITY IDEOGRAPH-FA8B;Lo;0;L;61F2;;;;N;;;;;\nFA8C;CJK COMPATIBILITY IDEOGRAPH-FA8C;Lo;0;L;6234;;;;N;;;;;\nFA8D;CJK COMPATIBILITY IDEOGRAPH-FA8D;Lo;0;L;63C4;;;;N;;;;;\nFA8E;CJK COMPATIBILITY IDEOGRAPH-FA8E;Lo;0;L;641C;;;;N;;;;;\nFA8F;CJK COMPATIBILITY IDEOGRAPH-FA8F;Lo;0;L;6452;;;;N;;;;;\nFA90;CJK COMPATIBILITY IDEOGRAPH-FA90;Lo;0;L;6556;;;;N;;;;;\nFA91;CJK COMPATIBILITY IDEOGRAPH-FA91;Lo;0;L;6674;;;;N;;;;;\nFA92;CJK COMPATIBILITY IDEOGRAPH-FA92;Lo;0;L;6717;;;;N;;;;;\nFA93;CJK COMPATIBILITY IDEOGRAPH-FA93;Lo;0;L;671B;;;;N;;;;;\nFA94;CJK COMPATIBILITY IDEOGRAPH-FA94;Lo;0;L;6756;;;;N;;;;;\nFA95;CJK COMPATIBILITY IDEOGRAPH-FA95;Lo;0;L;6B79;;;;N;;;;;\nFA96;CJK COMPATIBILITY IDEOGRAPH-FA96;Lo;0;L;6BBA;;;;N;;;;;\nFA97;CJK COMPATIBILITY IDEOGRAPH-FA97;Lo;0;L;6D41;;;;N;;;;;\nFA98;CJK COMPATIBILITY IDEOGRAPH-FA98;Lo;0;L;6EDB;;;;N;;;;;\nFA99;CJK COMPATIBILITY IDEOGRAPH-FA99;Lo;0;L;6ECB;;;;N;;;;;\nFA9A;CJK COMPATIBILITY IDEOGRAPH-FA9A;Lo;0;L;6F22;;;;N;;;;;\nFA9B;CJK COMPATIBILITY IDEOGRAPH-FA9B;Lo;0;L;701E;;;;N;;;;;\nFA9C;CJK COMPATIBILITY IDEOGRAPH-FA9C;Lo;0;L;716E;;;;N;;;;;\nFA9D;CJK COMPATIBILITY IDEOGRAPH-FA9D;Lo;0;L;77A7;;;;N;;;;;\nFA9E;CJK COMPATIBILITY IDEOGRAPH-FA9E;Lo;0;L;7235;;;;N;;;;;\nFA9F;CJK COMPATIBILITY IDEOGRAPH-FA9F;Lo;0;L;72AF;;;;N;;;;;\nFAA0;CJK COMPATIBILITY IDEOGRAPH-FAA0;Lo;0;L;732A;;;;N;;;;;\nFAA1;CJK COMPATIBILITY IDEOGRAPH-FAA1;Lo;0;L;7471;;;;N;;;;;\nFAA2;CJK COMPATIBILITY IDEOGRAPH-FAA2;Lo;0;L;7506;;;;N;;;;;\nFAA3;CJK COMPATIBILITY IDEOGRAPH-FAA3;Lo;0;L;753B;;;;N;;;;;\nFAA4;CJK COMPATIBILITY IDEOGRAPH-FAA4;Lo;0;L;761D;;;;N;;;;;\nFAA5;CJK COMPATIBILITY IDEOGRAPH-FAA5;Lo;0;L;761F;;;;N;;;;;\nFAA6;CJK COMPATIBILITY IDEOGRAPH-FAA6;Lo;0;L;76CA;;;;N;;;;;\nFAA7;CJK COMPATIBILITY IDEOGRAPH-FAA7;Lo;0;L;76DB;;;;N;;;;;\nFAA8;CJK COMPATIBILITY IDEOGRAPH-FAA8;Lo;0;L;76F4;;;;N;;;;;\nFAA9;CJK COMPATIBILITY IDEOGRAPH-FAA9;Lo;0;L;774A;;;;N;;;;;\nFAAA;CJK COMPATIBILITY IDEOGRAPH-FAAA;Lo;0;L;7740;;;;N;;;;;\nFAAB;CJK COMPATIBILITY IDEOGRAPH-FAAB;Lo;0;L;78CC;;;;N;;;;;\nFAAC;CJK COMPATIBILITY IDEOGRAPH-FAAC;Lo;0;L;7AB1;;;;N;;;;;\nFAAD;CJK COMPATIBILITY IDEOGRAPH-FAAD;Lo;0;L;7BC0;;;;N;;;;;\nFAAE;CJK COMPATIBILITY IDEOGRAPH-FAAE;Lo;0;L;7C7B;;;;N;;;;;\nFAAF;CJK COMPATIBILITY IDEOGRAPH-FAAF;Lo;0;L;7D5B;;;;N;;;;;\nFAB0;CJK COMPATIBILITY IDEOGRAPH-FAB0;Lo;0;L;7DF4;;;;N;;;;;\nFAB1;CJK COMPATIBILITY IDEOGRAPH-FAB1;Lo;0;L;7F3E;;;;N;;;;;\nFAB2;CJK COMPATIBILITY IDEOGRAPH-FAB2;Lo;0;L;8005;;;;N;;;;;\nFAB3;CJK COMPATIBILITY IDEOGRAPH-FAB3;Lo;0;L;8352;;;;N;;;;;\nFAB4;CJK COMPATIBILITY IDEOGRAPH-FAB4;Lo;0;L;83EF;;;;N;;;;;\nFAB5;CJK COMPATIBILITY IDEOGRAPH-FAB5;Lo;0;L;8779;;;;N;;;;;\nFAB6;CJK COMPATIBILITY IDEOGRAPH-FAB6;Lo;0;L;8941;;;;N;;;;;\nFAB7;CJK COMPATIBILITY IDEOGRAPH-FAB7;Lo;0;L;8986;;;;N;;;;;\nFAB8;CJK COMPATIBILITY IDEOGRAPH-FAB8;Lo;0;L;8996;;;;N;;;;;\nFAB9;CJK COMPATIBILITY IDEOGRAPH-FAB9;Lo;0;L;8ABF;;;;N;;;;;\nFABA;CJK COMPATIBILITY IDEOGRAPH-FABA;Lo;0;L;8AF8;;;;N;;;;;\nFABB;CJK COMPATIBILITY IDEOGRAPH-FABB;Lo;0;L;8ACB;;;;N;;;;;\nFABC;CJK COMPATIBILITY IDEOGRAPH-FABC;Lo;0;L;8B01;;;;N;;;;;\nFABD;CJK COMPATIBILITY IDEOGRAPH-FABD;Lo;0;L;8AFE;;;;N;;;;;\nFABE;CJK COMPATIBILITY IDEOGRAPH-FABE;Lo;0;L;8AED;;;;N;;;;;\nFABF;CJK COMPATIBILITY IDEOGRAPH-FABF;Lo;0;L;8B39;;;;N;;;;;\nFAC0;CJK COMPATIBILITY IDEOGRAPH-FAC0;Lo;0;L;8B8A;;;;N;;;;;\nFAC1;CJK COMPATIBILITY IDEOGRAPH-FAC1;Lo;0;L;8D08;;;;N;;;;;\nFAC2;CJK COMPATIBILITY IDEOGRAPH-FAC2;Lo;0;L;8F38;;;;N;;;;;\nFAC3;CJK COMPATIBILITY IDEOGRAPH-FAC3;Lo;0;L;9072;;;;N;;;;;\nFAC4;CJK COMPATIBILITY IDEOGRAPH-FAC4;Lo;0;L;9199;;;;N;;;;;\nFAC5;CJK COMPATIBILITY IDEOGRAPH-FAC5;Lo;0;L;9276;;;;N;;;;;\nFAC6;CJK COMPATIBILITY IDEOGRAPH-FAC6;Lo;0;L;967C;;;;N;;;;;\nFAC7;CJK COMPATIBILITY IDEOGRAPH-FAC7;Lo;0;L;96E3;;;;N;;;;;\nFAC8;CJK COMPATIBILITY IDEOGRAPH-FAC8;Lo;0;L;9756;;;;N;;;;;\nFAC9;CJK COMPATIBILITY IDEOGRAPH-FAC9;Lo;0;L;97DB;;;;N;;;;;\nFACA;CJK COMPATIBILITY IDEOGRAPH-FACA;Lo;0;L;97FF;;;;N;;;;;\nFACB;CJK COMPATIBILITY IDEOGRAPH-FACB;Lo;0;L;980B;;;;N;;;;;\nFACC;CJK COMPATIBILITY IDEOGRAPH-FACC;Lo;0;L;983B;;;;N;;;;;\nFACD;CJK COMPATIBILITY IDEOGRAPH-FACD;Lo;0;L;9B12;;;;N;;;;;\nFACE;CJK COMPATIBILITY IDEOGRAPH-FACE;Lo;0;L;9F9C;;;;N;;;;;\nFACF;CJK COMPATIBILITY IDEOGRAPH-FACF;Lo;0;L;2284A;;;;N;;;;;\nFAD0;CJK COMPATIBILITY IDEOGRAPH-FAD0;Lo;0;L;22844;;;;N;;;;;\nFAD1;CJK COMPATIBILITY IDEOGRAPH-FAD1;Lo;0;L;233D5;;;;N;;;;;\nFAD2;CJK COMPATIBILITY IDEOGRAPH-FAD2;Lo;0;L;3B9D;;;;N;;;;;\nFAD3;CJK COMPATIBILITY IDEOGRAPH-FAD3;Lo;0;L;4018;;;;N;;;;;\nFAD4;CJK COMPATIBILITY IDEOGRAPH-FAD4;Lo;0;L;4039;;;;N;;;;;\nFAD5;CJK COMPATIBILITY IDEOGRAPH-FAD5;Lo;0;L;25249;;;;N;;;;;\nFAD6;CJK COMPATIBILITY IDEOGRAPH-FAD6;Lo;0;L;25CD0;;;;N;;;;;\nFAD7;CJK COMPATIBILITY IDEOGRAPH-FAD7;Lo;0;L;27ED3;;;;N;;;;;\nFAD8;CJK COMPATIBILITY IDEOGRAPH-FAD8;Lo;0;L;9F43;;;;N;;;;;\nFAD9;CJK COMPATIBILITY IDEOGRAPH-FAD9;Lo;0;L;9F8E;;;;N;;;;;\nFB00;LATIN SMALL LIGATURE FF;Ll;0;L;<compat> 0066 0066;;;;N;;;;;\nFB01;LATIN SMALL LIGATURE FI;Ll;0;L;<compat> 0066 0069;;;;N;;;;;\nFB02;LATIN SMALL LIGATURE FL;Ll;0;L;<compat> 0066 006C;;;;N;;;;;\nFB03;LATIN SMALL LIGATURE FFI;Ll;0;L;<compat> 0066 0066 0069;;;;N;;;;;\nFB04;LATIN SMALL LIGATURE FFL;Ll;0;L;<compat> 0066 0066 006C;;;;N;;;;;\nFB05;LATIN SMALL LIGATURE LONG S T;Ll;0;L;<compat> 017F 0074;;;;N;;;;;\nFB06;LATIN SMALL LIGATURE ST;Ll;0;L;<compat> 0073 0074;;;;N;;;;;\nFB13;ARMENIAN SMALL LIGATURE MEN NOW;Ll;0;L;<compat> 0574 0576;;;;N;;;;;\nFB14;ARMENIAN SMALL LIGATURE MEN ECH;Ll;0;L;<compat> 0574 0565;;;;N;;;;;\nFB15;ARMENIAN SMALL LIGATURE MEN INI;Ll;0;L;<compat> 0574 056B;;;;N;;;;;\nFB16;ARMENIAN SMALL LIGATURE VEW NOW;Ll;0;L;<compat> 057E 0576;;;;N;;;;;\nFB17;ARMENIAN SMALL LIGATURE MEN XEH;Ll;0;L;<compat> 0574 056D;;;;N;;;;;\nFB1D;HEBREW LETTER YOD WITH HIRIQ;Lo;0;R;05D9 05B4;;;;N;;;;;\nFB1E;HEBREW POINT JUDEO-SPANISH VARIKA;Mn;26;NSM;;;;;N;HEBREW POINT VARIKA;;;;\nFB1F;HEBREW LIGATURE YIDDISH YOD YOD PATAH;Lo;0;R;05F2 05B7;;;;N;;;;;\nFB20;HEBREW LETTER ALTERNATIVE AYIN;Lo;0;R;<font> 05E2;;;;N;;;;;\nFB21;HEBREW LETTER WIDE ALEF;Lo;0;R;<font> 05D0;;;;N;;;;;\nFB22;HEBREW LETTER WIDE DALET;Lo;0;R;<font> 05D3;;;;N;;;;;\nFB23;HEBREW LETTER WIDE HE;Lo;0;R;<font> 05D4;;;;N;;;;;\nFB24;HEBREW LETTER WIDE KAF;Lo;0;R;<font> 05DB;;;;N;;;;;\nFB25;HEBREW LETTER WIDE LAMED;Lo;0;R;<font> 05DC;;;;N;;;;;\nFB26;HEBREW LETTER WIDE FINAL MEM;Lo;0;R;<font> 05DD;;;;N;;;;;\nFB27;HEBREW LETTER WIDE RESH;Lo;0;R;<font> 05E8;;;;N;;;;;\nFB28;HEBREW LETTER WIDE TAV;Lo;0;R;<font> 05EA;;;;N;;;;;\nFB29;HEBREW LETTER ALTERNATIVE PLUS SIGN;Sm;0;ES;<font> 002B;;;;N;;;;;\nFB2A;HEBREW LETTER SHIN WITH SHIN DOT;Lo;0;R;05E9 05C1;;;;N;;;;;\nFB2B;HEBREW LETTER SHIN WITH SIN DOT;Lo;0;R;05E9 05C2;;;;N;;;;;\nFB2C;HEBREW LETTER SHIN WITH DAGESH AND SHIN DOT;Lo;0;R;FB49 05C1;;;;N;;;;;\nFB2D;HEBREW LETTER SHIN WITH DAGESH AND SIN DOT;Lo;0;R;FB49 05C2;;;;N;;;;;\nFB2E;HEBREW LETTER ALEF WITH PATAH;Lo;0;R;05D0 05B7;;;;N;;;;;\nFB2F;HEBREW LETTER ALEF WITH QAMATS;Lo;0;R;05D0 05B8;;;;N;;;;;\nFB30;HEBREW LETTER ALEF WITH MAPIQ;Lo;0;R;05D0 05BC;;;;N;;;;;\nFB31;HEBREW LETTER BET WITH DAGESH;Lo;0;R;05D1 05BC;;;;N;;;;;\nFB32;HEBREW LETTER GIMEL WITH DAGESH;Lo;0;R;05D2 05BC;;;;N;;;;;\nFB33;HEBREW LETTER DALET WITH DAGESH;Lo;0;R;05D3 05BC;;;;N;;;;;\nFB34;HEBREW LETTER HE WITH MAPIQ;Lo;0;R;05D4 05BC;;;;N;;;;;\nFB35;HEBREW LETTER VAV WITH DAGESH;Lo;0;R;05D5 05BC;;;;N;;;;;\nFB36;HEBREW LETTER ZAYIN WITH DAGESH;Lo;0;R;05D6 05BC;;;;N;;;;;\nFB38;HEBREW LETTER TET WITH DAGESH;Lo;0;R;05D8 05BC;;;;N;;;;;\nFB39;HEBREW LETTER YOD WITH DAGESH;Lo;0;R;05D9 05BC;;;;N;;;;;\nFB3A;HEBREW LETTER FINAL KAF WITH DAGESH;Lo;0;R;05DA 05BC;;;;N;;;;;\nFB3B;HEBREW LETTER KAF WITH DAGESH;Lo;0;R;05DB 05BC;;;;N;;;;;\nFB3C;HEBREW LETTER LAMED WITH DAGESH;Lo;0;R;05DC 05BC;;;;N;;;;;\nFB3E;HEBREW LETTER MEM WITH DAGESH;Lo;0;R;05DE 05BC;;;;N;;;;;\nFB40;HEBREW LETTER NUN WITH DAGESH;Lo;0;R;05E0 05BC;;;;N;;;;;\nFB41;HEBREW LETTER SAMEKH WITH DAGESH;Lo;0;R;05E1 05BC;;;;N;;;;;\nFB43;HEBREW LETTER FINAL PE WITH DAGESH;Lo;0;R;05E3 05BC;;;;N;;;;;\nFB44;HEBREW LETTER PE WITH DAGESH;Lo;0;R;05E4 05BC;;;;N;;;;;\nFB46;HEBREW LETTER TSADI WITH DAGESH;Lo;0;R;05E6 05BC;;;;N;;;;;\nFB47;HEBREW LETTER QOF WITH DAGESH;Lo;0;R;05E7 05BC;;;;N;;;;;\nFB48;HEBREW LETTER RESH WITH DAGESH;Lo;0;R;05E8 05BC;;;;N;;;;;\nFB49;HEBREW LETTER SHIN WITH DAGESH;Lo;0;R;05E9 05BC;;;;N;;;;;\nFB4A;HEBREW LETTER TAV WITH DAGESH;Lo;0;R;05EA 05BC;;;;N;;;;;\nFB4B;HEBREW LETTER VAV WITH HOLAM;Lo;0;R;05D5 05B9;;;;N;;;;;\nFB4C;HEBREW LETTER BET WITH RAFE;Lo;0;R;05D1 05BF;;;;N;;;;;\nFB4D;HEBREW LETTER KAF WITH RAFE;Lo;0;R;05DB 05BF;;;;N;;;;;\nFB4E;HEBREW LETTER PE WITH RAFE;Lo;0;R;05E4 05BF;;;;N;;;;;\nFB4F;HEBREW LIGATURE ALEF LAMED;Lo;0;R;<compat> 05D0 05DC;;;;N;;;;;\nFB50;ARABIC LETTER ALEF WASLA ISOLATED FORM;Lo;0;AL;<isolated> 0671;;;;N;;;;;\nFB51;ARABIC LETTER ALEF WASLA FINAL FORM;Lo;0;AL;<final> 0671;;;;N;;;;;\nFB52;ARABIC LETTER BEEH ISOLATED FORM;Lo;0;AL;<isolated> 067B;;;;N;;;;;\nFB53;ARABIC LETTER BEEH FINAL FORM;Lo;0;AL;<final> 067B;;;;N;;;;;\nFB54;ARABIC LETTER BEEH INITIAL FORM;Lo;0;AL;<initial> 067B;;;;N;;;;;\nFB55;ARABIC LETTER BEEH MEDIAL FORM;Lo;0;AL;<medial> 067B;;;;N;;;;;\nFB56;ARABIC LETTER PEH ISOLATED FORM;Lo;0;AL;<isolated> 067E;;;;N;;;;;\nFB57;ARABIC LETTER PEH FINAL FORM;Lo;0;AL;<final> 067E;;;;N;;;;;\nFB58;ARABIC LETTER PEH INITIAL FORM;Lo;0;AL;<initial> 067E;;;;N;;;;;\nFB59;ARABIC LETTER PEH MEDIAL FORM;Lo;0;AL;<medial> 067E;;;;N;;;;;\nFB5A;ARABIC LETTER BEHEH ISOLATED FORM;Lo;0;AL;<isolated> 0680;;;;N;;;;;\nFB5B;ARABIC LETTER BEHEH FINAL FORM;Lo;0;AL;<final> 0680;;;;N;;;;;\nFB5C;ARABIC LETTER BEHEH INITIAL FORM;Lo;0;AL;<initial> 0680;;;;N;;;;;\nFB5D;ARABIC LETTER BEHEH MEDIAL FORM;Lo;0;AL;<medial> 0680;;;;N;;;;;\nFB5E;ARABIC LETTER TTEHEH ISOLATED FORM;Lo;0;AL;<isolated> 067A;;;;N;;;;;\nFB5F;ARABIC LETTER TTEHEH FINAL FORM;Lo;0;AL;<final> 067A;;;;N;;;;;\nFB60;ARABIC LETTER TTEHEH INITIAL FORM;Lo;0;AL;<initial> 067A;;;;N;;;;;\nFB61;ARABIC LETTER TTEHEH MEDIAL FORM;Lo;0;AL;<medial> 067A;;;;N;;;;;\nFB62;ARABIC LETTER TEHEH ISOLATED FORM;Lo;0;AL;<isolated> 067F;;;;N;;;;;\nFB63;ARABIC LETTER TEHEH FINAL FORM;Lo;0;AL;<final> 067F;;;;N;;;;;\nFB64;ARABIC LETTER TEHEH INITIAL FORM;Lo;0;AL;<initial> 067F;;;;N;;;;;\nFB65;ARABIC LETTER TEHEH MEDIAL FORM;Lo;0;AL;<medial> 067F;;;;N;;;;;\nFB66;ARABIC LETTER TTEH ISOLATED FORM;Lo;0;AL;<isolated> 0679;;;;N;;;;;\nFB67;ARABIC LETTER TTEH FINAL FORM;Lo;0;AL;<final> 0679;;;;N;;;;;\nFB68;ARABIC LETTER TTEH INITIAL FORM;Lo;0;AL;<initial> 0679;;;;N;;;;;\nFB69;ARABIC LETTER TTEH MEDIAL FORM;Lo;0;AL;<medial> 0679;;;;N;;;;;\nFB6A;ARABIC LETTER VEH ISOLATED FORM;Lo;0;AL;<isolated> 06A4;;;;N;;;;;\nFB6B;ARABIC LETTER VEH FINAL FORM;Lo;0;AL;<final> 06A4;;;;N;;;;;\nFB6C;ARABIC LETTER VEH INITIAL FORM;Lo;0;AL;<initial> 06A4;;;;N;;;;;\nFB6D;ARABIC LETTER VEH MEDIAL FORM;Lo;0;AL;<medial> 06A4;;;;N;;;;;\nFB6E;ARABIC LETTER PEHEH ISOLATED FORM;Lo;0;AL;<isolated> 06A6;;;;N;;;;;\nFB6F;ARABIC LETTER PEHEH FINAL FORM;Lo;0;AL;<final> 06A6;;;;N;;;;;\nFB70;ARABIC LETTER PEHEH INITIAL FORM;Lo;0;AL;<initial> 06A6;;;;N;;;;;\nFB71;ARABIC LETTER PEHEH MEDIAL FORM;Lo;0;AL;<medial> 06A6;;;;N;;;;;\nFB72;ARABIC LETTER DYEH ISOLATED FORM;Lo;0;AL;<isolated> 0684;;;;N;;;;;\nFB73;ARABIC LETTER DYEH FINAL FORM;Lo;0;AL;<final> 0684;;;;N;;;;;\nFB74;ARABIC LETTER DYEH INITIAL FORM;Lo;0;AL;<initial> 0684;;;;N;;;;;\nFB75;ARABIC LETTER DYEH MEDIAL FORM;Lo;0;AL;<medial> 0684;;;;N;;;;;\nFB76;ARABIC LETTER NYEH ISOLATED FORM;Lo;0;AL;<isolated> 0683;;;;N;;;;;\nFB77;ARABIC LETTER NYEH FINAL FORM;Lo;0;AL;<final> 0683;;;;N;;;;;\nFB78;ARABIC LETTER NYEH INITIAL FORM;Lo;0;AL;<initial> 0683;;;;N;;;;;\nFB79;ARABIC LETTER NYEH MEDIAL FORM;Lo;0;AL;<medial> 0683;;;;N;;;;;\nFB7A;ARABIC LETTER TCHEH ISOLATED FORM;Lo;0;AL;<isolated> 0686;;;;N;;;;;\nFB7B;ARABIC LETTER TCHEH FINAL FORM;Lo;0;AL;<final> 0686;;;;N;;;;;\nFB7C;ARABIC LETTER TCHEH INITIAL FORM;Lo;0;AL;<initial> 0686;;;;N;;;;;\nFB7D;ARABIC LETTER TCHEH MEDIAL FORM;Lo;0;AL;<medial> 0686;;;;N;;;;;\nFB7E;ARABIC LETTER TCHEHEH ISOLATED FORM;Lo;0;AL;<isolated> 0687;;;;N;;;;;\nFB7F;ARABIC LETTER TCHEHEH FINAL FORM;Lo;0;AL;<final> 0687;;;;N;;;;;\nFB80;ARABIC LETTER TCHEHEH INITIAL FORM;Lo;0;AL;<initial> 0687;;;;N;;;;;\nFB81;ARABIC LETTER TCHEHEH MEDIAL FORM;Lo;0;AL;<medial> 0687;;;;N;;;;;\nFB82;ARABIC LETTER DDAHAL ISOLATED FORM;Lo;0;AL;<isolated> 068D;;;;N;;;;;\nFB83;ARABIC LETTER DDAHAL FINAL FORM;Lo;0;AL;<final> 068D;;;;N;;;;;\nFB84;ARABIC LETTER DAHAL ISOLATED FORM;Lo;0;AL;<isolated> 068C;;;;N;;;;;\nFB85;ARABIC LETTER DAHAL FINAL FORM;Lo;0;AL;<final> 068C;;;;N;;;;;\nFB86;ARABIC LETTER DUL ISOLATED FORM;Lo;0;AL;<isolated> 068E;;;;N;;;;;\nFB87;ARABIC LETTER DUL FINAL FORM;Lo;0;AL;<final> 068E;;;;N;;;;;\nFB88;ARABIC LETTER DDAL ISOLATED FORM;Lo;0;AL;<isolated> 0688;;;;N;;;;;\nFB89;ARABIC LETTER DDAL FINAL FORM;Lo;0;AL;<final> 0688;;;;N;;;;;\nFB8A;ARABIC LETTER JEH ISOLATED FORM;Lo;0;AL;<isolated> 0698;;;;N;;;;;\nFB8B;ARABIC LETTER JEH FINAL FORM;Lo;0;AL;<final> 0698;;;;N;;;;;\nFB8C;ARABIC LETTER RREH ISOLATED FORM;Lo;0;AL;<isolated> 0691;;;;N;;;;;\nFB8D;ARABIC LETTER RREH FINAL FORM;Lo;0;AL;<final> 0691;;;;N;;;;;\nFB8E;ARABIC LETTER KEHEH ISOLATED FORM;Lo;0;AL;<isolated> 06A9;;;;N;;;;;\nFB8F;ARABIC LETTER KEHEH FINAL FORM;Lo;0;AL;<final> 06A9;;;;N;;;;;\nFB90;ARABIC LETTER KEHEH INITIAL FORM;Lo;0;AL;<initial> 06A9;;;;N;;;;;\nFB91;ARABIC LETTER KEHEH MEDIAL FORM;Lo;0;AL;<medial> 06A9;;;;N;;;;;\nFB92;ARABIC LETTER GAF ISOLATED FORM;Lo;0;AL;<isolated> 06AF;;;;N;;;;;\nFB93;ARABIC LETTER GAF FINAL FORM;Lo;0;AL;<final> 06AF;;;;N;;;;;\nFB94;ARABIC LETTER GAF INITIAL FORM;Lo;0;AL;<initial> 06AF;;;;N;;;;;\nFB95;ARABIC LETTER GAF MEDIAL FORM;Lo;0;AL;<medial> 06AF;;;;N;;;;;\nFB96;ARABIC LETTER GUEH ISOLATED FORM;Lo;0;AL;<isolated> 06B3;;;;N;;;;;\nFB97;ARABIC LETTER GUEH FINAL FORM;Lo;0;AL;<final> 06B3;;;;N;;;;;\nFB98;ARABIC LETTER GUEH INITIAL FORM;Lo;0;AL;<initial> 06B3;;;;N;;;;;\nFB99;ARABIC LETTER GUEH MEDIAL FORM;Lo;0;AL;<medial> 06B3;;;;N;;;;;\nFB9A;ARABIC LETTER NGOEH ISOLATED FORM;Lo;0;AL;<isolated> 06B1;;;;N;;;;;\nFB9B;ARABIC LETTER NGOEH FINAL FORM;Lo;0;AL;<final> 06B1;;;;N;;;;;\nFB9C;ARABIC LETTER NGOEH INITIAL FORM;Lo;0;AL;<initial> 06B1;;;;N;;;;;\nFB9D;ARABIC LETTER NGOEH MEDIAL FORM;Lo;0;AL;<medial> 06B1;;;;N;;;;;\nFB9E;ARABIC LETTER NOON GHUNNA ISOLATED FORM;Lo;0;AL;<isolated> 06BA;;;;N;;;;;\nFB9F;ARABIC LETTER NOON GHUNNA FINAL FORM;Lo;0;AL;<final> 06BA;;;;N;;;;;\nFBA0;ARABIC LETTER RNOON ISOLATED FORM;Lo;0;AL;<isolated> 06BB;;;;N;;;;;\nFBA1;ARABIC LETTER RNOON FINAL FORM;Lo;0;AL;<final> 06BB;;;;N;;;;;\nFBA2;ARABIC LETTER RNOON INITIAL FORM;Lo;0;AL;<initial> 06BB;;;;N;;;;;\nFBA3;ARABIC LETTER RNOON MEDIAL FORM;Lo;0;AL;<medial> 06BB;;;;N;;;;;\nFBA4;ARABIC LETTER HEH WITH YEH ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 06C0;;;;N;;;;;\nFBA5;ARABIC LETTER HEH WITH YEH ABOVE FINAL FORM;Lo;0;AL;<final> 06C0;;;;N;;;;;\nFBA6;ARABIC LETTER HEH GOAL ISOLATED FORM;Lo;0;AL;<isolated> 06C1;;;;N;;;;;\nFBA7;ARABIC LETTER HEH GOAL FINAL FORM;Lo;0;AL;<final> 06C1;;;;N;;;;;\nFBA8;ARABIC LETTER HEH GOAL INITIAL FORM;Lo;0;AL;<initial> 06C1;;;;N;;;;;\nFBA9;ARABIC LETTER HEH GOAL MEDIAL FORM;Lo;0;AL;<medial> 06C1;;;;N;;;;;\nFBAA;ARABIC LETTER HEH DOACHASHMEE ISOLATED FORM;Lo;0;AL;<isolated> 06BE;;;;N;;;;;\nFBAB;ARABIC LETTER HEH DOACHASHMEE FINAL FORM;Lo;0;AL;<final> 06BE;;;;N;;;;;\nFBAC;ARABIC LETTER HEH DOACHASHMEE INITIAL FORM;Lo;0;AL;<initial> 06BE;;;;N;;;;;\nFBAD;ARABIC LETTER HEH DOACHASHMEE MEDIAL FORM;Lo;0;AL;<medial> 06BE;;;;N;;;;;\nFBAE;ARABIC LETTER YEH BARREE ISOLATED FORM;Lo;0;AL;<isolated> 06D2;;;;N;;;;;\nFBAF;ARABIC LETTER YEH BARREE FINAL FORM;Lo;0;AL;<final> 06D2;;;;N;;;;;\nFBB0;ARABIC LETTER YEH BARREE WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 06D3;;;;N;;;;;\nFBB1;ARABIC LETTER YEH BARREE WITH HAMZA ABOVE FINAL FORM;Lo;0;AL;<final> 06D3;;;;N;;;;;\nFBB2;ARABIC SYMBOL DOT ABOVE;Sk;0;AL;;;;;N;;;;;\nFBB3;ARABIC SYMBOL DOT BELOW;Sk;0;AL;;;;;N;;;;;\nFBB4;ARABIC SYMBOL TWO DOTS ABOVE;Sk;0;AL;;;;;N;;;;;\nFBB5;ARABIC SYMBOL TWO DOTS BELOW;Sk;0;AL;;;;;N;;;;;\nFBB6;ARABIC SYMBOL THREE DOTS ABOVE;Sk;0;AL;;;;;N;;;;;\nFBB7;ARABIC SYMBOL THREE DOTS BELOW;Sk;0;AL;;;;;N;;;;;\nFBB8;ARABIC SYMBOL THREE DOTS POINTING DOWNWARDS ABOVE;Sk;0;AL;;;;;N;;;;;\nFBB9;ARABIC SYMBOL THREE DOTS POINTING DOWNWARDS BELOW;Sk;0;AL;;;;;N;;;;;\nFBBA;ARABIC SYMBOL FOUR DOTS ABOVE;Sk;0;AL;;;;;N;;;;;\nFBBB;ARABIC SYMBOL FOUR DOTS BELOW;Sk;0;AL;;;;;N;;;;;\nFBBC;ARABIC SYMBOL DOUBLE VERTICAL BAR BELOW;Sk;0;AL;;;;;N;;;;;\nFBBD;ARABIC SYMBOL TWO DOTS VERTICALLY ABOVE;Sk;0;AL;;;;;N;;;;;\nFBBE;ARABIC SYMBOL TWO DOTS VERTICALLY BELOW;Sk;0;AL;;;;;N;;;;;\nFBBF;ARABIC SYMBOL RING;Sk;0;AL;;;;;N;;;;;\nFBC0;ARABIC SYMBOL SMALL TAH ABOVE;Sk;0;AL;;;;;N;;;;;\nFBC1;ARABIC SYMBOL SMALL TAH BELOW;Sk;0;AL;;;;;N;;;;;\nFBD3;ARABIC LETTER NG ISOLATED FORM;Lo;0;AL;<isolated> 06AD;;;;N;;;;;\nFBD4;ARABIC LETTER NG FINAL FORM;Lo;0;AL;<final> 06AD;;;;N;;;;;\nFBD5;ARABIC LETTER NG INITIAL FORM;Lo;0;AL;<initial> 06AD;;;;N;;;;;\nFBD6;ARABIC LETTER NG MEDIAL FORM;Lo;0;AL;<medial> 06AD;;;;N;;;;;\nFBD7;ARABIC LETTER U ISOLATED FORM;Lo;0;AL;<isolated> 06C7;;;;N;;;;;\nFBD8;ARABIC LETTER U FINAL FORM;Lo;0;AL;<final> 06C7;;;;N;;;;;\nFBD9;ARABIC LETTER OE ISOLATED FORM;Lo;0;AL;<isolated> 06C6;;;;N;;;;;\nFBDA;ARABIC LETTER OE FINAL FORM;Lo;0;AL;<final> 06C6;;;;N;;;;;\nFBDB;ARABIC LETTER YU ISOLATED FORM;Lo;0;AL;<isolated> 06C8;;;;N;;;;;\nFBDC;ARABIC LETTER YU FINAL FORM;Lo;0;AL;<final> 06C8;;;;N;;;;;\nFBDD;ARABIC LETTER U WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0677;;;;N;;;;;\nFBDE;ARABIC LETTER VE ISOLATED FORM;Lo;0;AL;<isolated> 06CB;;;;N;;;;;\nFBDF;ARABIC LETTER VE FINAL FORM;Lo;0;AL;<final> 06CB;;;;N;;;;;\nFBE0;ARABIC LETTER KIRGHIZ OE ISOLATED FORM;Lo;0;AL;<isolated> 06C5;;;;N;;;;;\nFBE1;ARABIC LETTER KIRGHIZ OE FINAL FORM;Lo;0;AL;<final> 06C5;;;;N;;;;;\nFBE2;ARABIC LETTER KIRGHIZ YU ISOLATED FORM;Lo;0;AL;<isolated> 06C9;;;;N;;;;;\nFBE3;ARABIC LETTER KIRGHIZ YU FINAL FORM;Lo;0;AL;<final> 06C9;;;;N;;;;;\nFBE4;ARABIC LETTER E ISOLATED FORM;Lo;0;AL;<isolated> 06D0;;;;N;;;;;\nFBE5;ARABIC LETTER E FINAL FORM;Lo;0;AL;<final> 06D0;;;;N;;;;;\nFBE6;ARABIC LETTER E INITIAL FORM;Lo;0;AL;<initial> 06D0;;;;N;;;;;\nFBE7;ARABIC LETTER E MEDIAL FORM;Lo;0;AL;<medial> 06D0;;;;N;;;;;\nFBE8;ARABIC LETTER UIGHUR KAZAKH KIRGHIZ ALEF MAKSURA INITIAL FORM;Lo;0;AL;<initial> 0649;;;;N;;;;;\nFBE9;ARABIC LETTER UIGHUR KAZAKH KIRGHIZ ALEF MAKSURA MEDIAL FORM;Lo;0;AL;<medial> 0649;;;;N;;;;;\nFBEA;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0626 0627;;;;N;;;;;\nFBEB;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF FINAL FORM;Lo;0;AL;<final> 0626 0627;;;;N;;;;;\nFBEC;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH AE ISOLATED FORM;Lo;0;AL;<isolated> 0626 06D5;;;;N;;;;;\nFBED;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH AE FINAL FORM;Lo;0;AL;<final> 0626 06D5;;;;N;;;;;\nFBEE;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH WAW ISOLATED FORM;Lo;0;AL;<isolated> 0626 0648;;;;N;;;;;\nFBEF;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH WAW FINAL FORM;Lo;0;AL;<final> 0626 0648;;;;N;;;;;\nFBF0;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH U ISOLATED FORM;Lo;0;AL;<isolated> 0626 06C7;;;;N;;;;;\nFBF1;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH U FINAL FORM;Lo;0;AL;<final> 0626 06C7;;;;N;;;;;\nFBF2;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH OE ISOLATED FORM;Lo;0;AL;<isolated> 0626 06C6;;;;N;;;;;\nFBF3;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH OE FINAL FORM;Lo;0;AL;<final> 0626 06C6;;;;N;;;;;\nFBF4;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH YU ISOLATED FORM;Lo;0;AL;<isolated> 0626 06C8;;;;N;;;;;\nFBF5;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH YU FINAL FORM;Lo;0;AL;<final> 0626 06C8;;;;N;;;;;\nFBF6;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH E ISOLATED FORM;Lo;0;AL;<isolated> 0626 06D0;;;;N;;;;;\nFBF7;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH E FINAL FORM;Lo;0;AL;<final> 0626 06D0;;;;N;;;;;\nFBF8;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH E INITIAL FORM;Lo;0;AL;<initial> 0626 06D0;;;;N;;;;;\nFBF9;ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0626 0649;;;;N;;;;;\nFBFA;ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0626 0649;;;;N;;;;;\nFBFB;ARABIC LIGATURE UIGHUR KIRGHIZ YEH WITH HAMZA ABOVE WITH ALEF MAKSURA INITIAL FORM;Lo;0;AL;<initial> 0626 0649;;;;N;;;;;\nFBFC;ARABIC LETTER FARSI YEH ISOLATED FORM;Lo;0;AL;<isolated> 06CC;;;;N;;;;;\nFBFD;ARABIC LETTER FARSI YEH FINAL FORM;Lo;0;AL;<final> 06CC;;;;N;;;;;\nFBFE;ARABIC LETTER FARSI YEH INITIAL FORM;Lo;0;AL;<initial> 06CC;;;;N;;;;;\nFBFF;ARABIC LETTER FARSI YEH MEDIAL FORM;Lo;0;AL;<medial> 06CC;;;;N;;;;;\nFC00;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0626 062C;;;;N;;;;;\nFC01;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0626 062D;;;;N;;;;;\nFC02;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0626 0645;;;;N;;;;;\nFC03;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0626 0649;;;;N;;;;;\nFC04;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0626 064A;;;;N;;;;;\nFC05;ARABIC LIGATURE BEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0628 062C;;;;N;;;;;\nFC06;ARABIC LIGATURE BEH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0628 062D;;;;N;;;;;\nFC07;ARABIC LIGATURE BEH WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0628 062E;;;;N;;;;;\nFC08;ARABIC LIGATURE BEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0628 0645;;;;N;;;;;\nFC09;ARABIC LIGATURE BEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0628 0649;;;;N;;;;;\nFC0A;ARABIC LIGATURE BEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0628 064A;;;;N;;;;;\nFC0B;ARABIC LIGATURE TEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 062A 062C;;;;N;;;;;\nFC0C;ARABIC LIGATURE TEH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 062A 062D;;;;N;;;;;\nFC0D;ARABIC LIGATURE TEH WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 062A 062E;;;;N;;;;;\nFC0E;ARABIC LIGATURE TEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 062A 0645;;;;N;;;;;\nFC0F;ARABIC LIGATURE TEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 062A 0649;;;;N;;;;;\nFC10;ARABIC LIGATURE TEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 062A 064A;;;;N;;;;;\nFC11;ARABIC LIGATURE THEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 062B 062C;;;;N;;;;;\nFC12;ARABIC LIGATURE THEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 062B 0645;;;;N;;;;;\nFC13;ARABIC LIGATURE THEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 062B 0649;;;;N;;;;;\nFC14;ARABIC LIGATURE THEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 062B 064A;;;;N;;;;;\nFC15;ARABIC LIGATURE JEEM WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 062C 062D;;;;N;;;;;\nFC16;ARABIC LIGATURE JEEM WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 062C 0645;;;;N;;;;;\nFC17;ARABIC LIGATURE HAH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 062D 062C;;;;N;;;;;\nFC18;ARABIC LIGATURE HAH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 062D 0645;;;;N;;;;;\nFC19;ARABIC LIGATURE KHAH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 062E 062C;;;;N;;;;;\nFC1A;ARABIC LIGATURE KHAH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 062E 062D;;;;N;;;;;\nFC1B;ARABIC LIGATURE KHAH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 062E 0645;;;;N;;;;;\nFC1C;ARABIC LIGATURE SEEN WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0633 062C;;;;N;;;;;\nFC1D;ARABIC LIGATURE SEEN WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0633 062D;;;;N;;;;;\nFC1E;ARABIC LIGATURE SEEN WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0633 062E;;;;N;;;;;\nFC1F;ARABIC LIGATURE SEEN WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0633 0645;;;;N;;;;;\nFC20;ARABIC LIGATURE SAD WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0635 062D;;;;N;;;;;\nFC21;ARABIC LIGATURE SAD WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0635 0645;;;;N;;;;;\nFC22;ARABIC LIGATURE DAD WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0636 062C;;;;N;;;;;\nFC23;ARABIC LIGATURE DAD WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0636 062D;;;;N;;;;;\nFC24;ARABIC LIGATURE DAD WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0636 062E;;;;N;;;;;\nFC25;ARABIC LIGATURE DAD WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0636 0645;;;;N;;;;;\nFC26;ARABIC LIGATURE TAH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0637 062D;;;;N;;;;;\nFC27;ARABIC LIGATURE TAH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0637 0645;;;;N;;;;;\nFC28;ARABIC LIGATURE ZAH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0638 0645;;;;N;;;;;\nFC29;ARABIC LIGATURE AIN WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0639 062C;;;;N;;;;;\nFC2A;ARABIC LIGATURE AIN WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0639 0645;;;;N;;;;;\nFC2B;ARABIC LIGATURE GHAIN WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 063A 062C;;;;N;;;;;\nFC2C;ARABIC LIGATURE GHAIN WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 063A 0645;;;;N;;;;;\nFC2D;ARABIC LIGATURE FEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0641 062C;;;;N;;;;;\nFC2E;ARABIC LIGATURE FEH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0641 062D;;;;N;;;;;\nFC2F;ARABIC LIGATURE FEH WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0641 062E;;;;N;;;;;\nFC30;ARABIC LIGATURE FEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0641 0645;;;;N;;;;;\nFC31;ARABIC LIGATURE FEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0641 0649;;;;N;;;;;\nFC32;ARABIC LIGATURE FEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0641 064A;;;;N;;;;;\nFC33;ARABIC LIGATURE QAF WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0642 062D;;;;N;;;;;\nFC34;ARABIC LIGATURE QAF WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0642 0645;;;;N;;;;;\nFC35;ARABIC LIGATURE QAF WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0642 0649;;;;N;;;;;\nFC36;ARABIC LIGATURE QAF WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0642 064A;;;;N;;;;;\nFC37;ARABIC LIGATURE KAF WITH ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0643 0627;;;;N;;;;;\nFC38;ARABIC LIGATURE KAF WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0643 062C;;;;N;;;;;\nFC39;ARABIC LIGATURE KAF WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0643 062D;;;;N;;;;;\nFC3A;ARABIC LIGATURE KAF WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0643 062E;;;;N;;;;;\nFC3B;ARABIC LIGATURE KAF WITH LAM ISOLATED FORM;Lo;0;AL;<isolated> 0643 0644;;;;N;;;;;\nFC3C;ARABIC LIGATURE KAF WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0643 0645;;;;N;;;;;\nFC3D;ARABIC LIGATURE KAF WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0643 0649;;;;N;;;;;\nFC3E;ARABIC LIGATURE KAF WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0643 064A;;;;N;;;;;\nFC3F;ARABIC LIGATURE LAM WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0644 062C;;;;N;;;;;\nFC40;ARABIC LIGATURE LAM WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0644 062D;;;;N;;;;;\nFC41;ARABIC LIGATURE LAM WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0644 062E;;;;N;;;;;\nFC42;ARABIC LIGATURE LAM WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0644 0645;;;;N;;;;;\nFC43;ARABIC LIGATURE LAM WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0644 0649;;;;N;;;;;\nFC44;ARABIC LIGATURE LAM WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0644 064A;;;;N;;;;;\nFC45;ARABIC LIGATURE MEEM WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0645 062C;;;;N;;;;;\nFC46;ARABIC LIGATURE MEEM WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0645 062D;;;;N;;;;;\nFC47;ARABIC LIGATURE MEEM WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0645 062E;;;;N;;;;;\nFC48;ARABIC LIGATURE MEEM WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0645 0645;;;;N;;;;;\nFC49;ARABIC LIGATURE MEEM WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0645 0649;;;;N;;;;;\nFC4A;ARABIC LIGATURE MEEM WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0645 064A;;;;N;;;;;\nFC4B;ARABIC LIGATURE NOON WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0646 062C;;;;N;;;;;\nFC4C;ARABIC LIGATURE NOON WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0646 062D;;;;N;;;;;\nFC4D;ARABIC LIGATURE NOON WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0646 062E;;;;N;;;;;\nFC4E;ARABIC LIGATURE NOON WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0646 0645;;;;N;;;;;\nFC4F;ARABIC LIGATURE NOON WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0646 0649;;;;N;;;;;\nFC50;ARABIC LIGATURE NOON WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0646 064A;;;;N;;;;;\nFC51;ARABIC LIGATURE HEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0647 062C;;;;N;;;;;\nFC52;ARABIC LIGATURE HEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0647 0645;;;;N;;;;;\nFC53;ARABIC LIGATURE HEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0647 0649;;;;N;;;;;\nFC54;ARABIC LIGATURE HEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0647 064A;;;;N;;;;;\nFC55;ARABIC LIGATURE YEH WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 064A 062C;;;;N;;;;;\nFC56;ARABIC LIGATURE YEH WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 064A 062D;;;;N;;;;;\nFC57;ARABIC LIGATURE YEH WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 064A 062E;;;;N;;;;;\nFC58;ARABIC LIGATURE YEH WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 064A 0645;;;;N;;;;;\nFC59;ARABIC LIGATURE YEH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 064A 0649;;;;N;;;;;\nFC5A;ARABIC LIGATURE YEH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 064A 064A;;;;N;;;;;\nFC5B;ARABIC LIGATURE THAL WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0630 0670;;;;N;;;;;\nFC5C;ARABIC LIGATURE REH WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0631 0670;;;;N;;;;;\nFC5D;ARABIC LIGATURE ALEF MAKSURA WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0649 0670;;;;N;;;;;\nFC5E;ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM;Lo;0;AL;<isolated> 0020 064C 0651;;;;N;;;;;\nFC5F;ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM;Lo;0;AL;<isolated> 0020 064D 0651;;;;N;;;;;\nFC60;ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM;Lo;0;AL;<isolated> 0020 064E 0651;;;;N;;;;;\nFC61;ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM;Lo;0;AL;<isolated> 0020 064F 0651;;;;N;;;;;\nFC62;ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM;Lo;0;AL;<isolated> 0020 0650 0651;;;;N;;;;;\nFC63;ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0020 0651 0670;;;;N;;;;;\nFC64;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH REH FINAL FORM;Lo;0;AL;<final> 0626 0631;;;;N;;;;;\nFC65;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ZAIN FINAL FORM;Lo;0;AL;<final> 0626 0632;;;;N;;;;;\nFC66;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH MEEM FINAL FORM;Lo;0;AL;<final> 0626 0645;;;;N;;;;;\nFC67;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH NOON FINAL FORM;Lo;0;AL;<final> 0626 0646;;;;N;;;;;\nFC68;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0626 0649;;;;N;;;;;\nFC69;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH YEH FINAL FORM;Lo;0;AL;<final> 0626 064A;;;;N;;;;;\nFC6A;ARABIC LIGATURE BEH WITH REH FINAL FORM;Lo;0;AL;<final> 0628 0631;;;;N;;;;;\nFC6B;ARABIC LIGATURE BEH WITH ZAIN FINAL FORM;Lo;0;AL;<final> 0628 0632;;;;N;;;;;\nFC6C;ARABIC LIGATURE BEH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0628 0645;;;;N;;;;;\nFC6D;ARABIC LIGATURE BEH WITH NOON FINAL FORM;Lo;0;AL;<final> 0628 0646;;;;N;;;;;\nFC6E;ARABIC LIGATURE BEH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0628 0649;;;;N;;;;;\nFC6F;ARABIC LIGATURE BEH WITH YEH FINAL FORM;Lo;0;AL;<final> 0628 064A;;;;N;;;;;\nFC70;ARABIC LIGATURE TEH WITH REH FINAL FORM;Lo;0;AL;<final> 062A 0631;;;;N;;;;;\nFC71;ARABIC LIGATURE TEH WITH ZAIN FINAL FORM;Lo;0;AL;<final> 062A 0632;;;;N;;;;;\nFC72;ARABIC LIGATURE TEH WITH MEEM FINAL FORM;Lo;0;AL;<final> 062A 0645;;;;N;;;;;\nFC73;ARABIC LIGATURE TEH WITH NOON FINAL FORM;Lo;0;AL;<final> 062A 0646;;;;N;;;;;\nFC74;ARABIC LIGATURE TEH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062A 0649;;;;N;;;;;\nFC75;ARABIC LIGATURE TEH WITH YEH FINAL FORM;Lo;0;AL;<final> 062A 064A;;;;N;;;;;\nFC76;ARABIC LIGATURE THEH WITH REH FINAL FORM;Lo;0;AL;<final> 062B 0631;;;;N;;;;;\nFC77;ARABIC LIGATURE THEH WITH ZAIN FINAL FORM;Lo;0;AL;<final> 062B 0632;;;;N;;;;;\nFC78;ARABIC LIGATURE THEH WITH MEEM FINAL FORM;Lo;0;AL;<final> 062B 0645;;;;N;;;;;\nFC79;ARABIC LIGATURE THEH WITH NOON FINAL FORM;Lo;0;AL;<final> 062B 0646;;;;N;;;;;\nFC7A;ARABIC LIGATURE THEH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062B 0649;;;;N;;;;;\nFC7B;ARABIC LIGATURE THEH WITH YEH FINAL FORM;Lo;0;AL;<final> 062B 064A;;;;N;;;;;\nFC7C;ARABIC LIGATURE FEH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0641 0649;;;;N;;;;;\nFC7D;ARABIC LIGATURE FEH WITH YEH FINAL FORM;Lo;0;AL;<final> 0641 064A;;;;N;;;;;\nFC7E;ARABIC LIGATURE QAF WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0642 0649;;;;N;;;;;\nFC7F;ARABIC LIGATURE QAF WITH YEH FINAL FORM;Lo;0;AL;<final> 0642 064A;;;;N;;;;;\nFC80;ARABIC LIGATURE KAF WITH ALEF FINAL FORM;Lo;0;AL;<final> 0643 0627;;;;N;;;;;\nFC81;ARABIC LIGATURE KAF WITH LAM FINAL FORM;Lo;0;AL;<final> 0643 0644;;;;N;;;;;\nFC82;ARABIC LIGATURE KAF WITH MEEM FINAL FORM;Lo;0;AL;<final> 0643 0645;;;;N;;;;;\nFC83;ARABIC LIGATURE KAF WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0643 0649;;;;N;;;;;\nFC84;ARABIC LIGATURE KAF WITH YEH FINAL FORM;Lo;0;AL;<final> 0643 064A;;;;N;;;;;\nFC85;ARABIC LIGATURE LAM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0644 0645;;;;N;;;;;\nFC86;ARABIC LIGATURE LAM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0644 0649;;;;N;;;;;\nFC87;ARABIC LIGATURE LAM WITH YEH FINAL FORM;Lo;0;AL;<final> 0644 064A;;;;N;;;;;\nFC88;ARABIC LIGATURE MEEM WITH ALEF FINAL FORM;Lo;0;AL;<final> 0645 0627;;;;N;;;;;\nFC89;ARABIC LIGATURE MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0645 0645;;;;N;;;;;\nFC8A;ARABIC LIGATURE NOON WITH REH FINAL FORM;Lo;0;AL;<final> 0646 0631;;;;N;;;;;\nFC8B;ARABIC LIGATURE NOON WITH ZAIN FINAL FORM;Lo;0;AL;<final> 0646 0632;;;;N;;;;;\nFC8C;ARABIC LIGATURE NOON WITH MEEM FINAL FORM;Lo;0;AL;<final> 0646 0645;;;;N;;;;;\nFC8D;ARABIC LIGATURE NOON WITH NOON FINAL FORM;Lo;0;AL;<final> 0646 0646;;;;N;;;;;\nFC8E;ARABIC LIGATURE NOON WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0646 0649;;;;N;;;;;\nFC8F;ARABIC LIGATURE NOON WITH YEH FINAL FORM;Lo;0;AL;<final> 0646 064A;;;;N;;;;;\nFC90;ARABIC LIGATURE ALEF MAKSURA WITH SUPERSCRIPT ALEF FINAL FORM;Lo;0;AL;<final> 0649 0670;;;;N;;;;;\nFC91;ARABIC LIGATURE YEH WITH REH FINAL FORM;Lo;0;AL;<final> 064A 0631;;;;N;;;;;\nFC92;ARABIC LIGATURE YEH WITH ZAIN FINAL FORM;Lo;0;AL;<final> 064A 0632;;;;N;;;;;\nFC93;ARABIC LIGATURE YEH WITH MEEM FINAL FORM;Lo;0;AL;<final> 064A 0645;;;;N;;;;;\nFC94;ARABIC LIGATURE YEH WITH NOON FINAL FORM;Lo;0;AL;<final> 064A 0646;;;;N;;;;;\nFC95;ARABIC LIGATURE YEH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 064A 0649;;;;N;;;;;\nFC96;ARABIC LIGATURE YEH WITH YEH FINAL FORM;Lo;0;AL;<final> 064A 064A;;;;N;;;;;\nFC97;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0626 062C;;;;N;;;;;\nFC98;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0626 062D;;;;N;;;;;\nFC99;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0626 062E;;;;N;;;;;\nFC9A;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0626 0645;;;;N;;;;;\nFC9B;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0626 0647;;;;N;;;;;\nFC9C;ARABIC LIGATURE BEH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0628 062C;;;;N;;;;;\nFC9D;ARABIC LIGATURE BEH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0628 062D;;;;N;;;;;\nFC9E;ARABIC LIGATURE BEH WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0628 062E;;;;N;;;;;\nFC9F;ARABIC LIGATURE BEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0628 0645;;;;N;;;;;\nFCA0;ARABIC LIGATURE BEH WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0628 0647;;;;N;;;;;\nFCA1;ARABIC LIGATURE TEH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 062A 062C;;;;N;;;;;\nFCA2;ARABIC LIGATURE TEH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 062A 062D;;;;N;;;;;\nFCA3;ARABIC LIGATURE TEH WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 062A 062E;;;;N;;;;;\nFCA4;ARABIC LIGATURE TEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062A 0645;;;;N;;;;;\nFCA5;ARABIC LIGATURE TEH WITH HEH INITIAL FORM;Lo;0;AL;<initial> 062A 0647;;;;N;;;;;\nFCA6;ARABIC LIGATURE THEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062B 0645;;;;N;;;;;\nFCA7;ARABIC LIGATURE JEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 062C 062D;;;;N;;;;;\nFCA8;ARABIC LIGATURE JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062C 0645;;;;N;;;;;\nFCA9;ARABIC LIGATURE HAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 062D 062C;;;;N;;;;;\nFCAA;ARABIC LIGATURE HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062D 0645;;;;N;;;;;\nFCAB;ARABIC LIGATURE KHAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 062E 062C;;;;N;;;;;\nFCAC;ARABIC LIGATURE KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062E 0645;;;;N;;;;;\nFCAD;ARABIC LIGATURE SEEN WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0633 062C;;;;N;;;;;\nFCAE;ARABIC LIGATURE SEEN WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0633 062D;;;;N;;;;;\nFCAF;ARABIC LIGATURE SEEN WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0633 062E;;;;N;;;;;\nFCB0;ARABIC LIGATURE SEEN WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0633 0645;;;;N;;;;;\nFCB1;ARABIC LIGATURE SAD WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0635 062D;;;;N;;;;;\nFCB2;ARABIC LIGATURE SAD WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0635 062E;;;;N;;;;;\nFCB3;ARABIC LIGATURE SAD WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0635 0645;;;;N;;;;;\nFCB4;ARABIC LIGATURE DAD WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0636 062C;;;;N;;;;;\nFCB5;ARABIC LIGATURE DAD WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0636 062D;;;;N;;;;;\nFCB6;ARABIC LIGATURE DAD WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0636 062E;;;;N;;;;;\nFCB7;ARABIC LIGATURE DAD WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0636 0645;;;;N;;;;;\nFCB8;ARABIC LIGATURE TAH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0637 062D;;;;N;;;;;\nFCB9;ARABIC LIGATURE ZAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0638 0645;;;;N;;;;;\nFCBA;ARABIC LIGATURE AIN WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0639 062C;;;;N;;;;;\nFCBB;ARABIC LIGATURE AIN WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0639 0645;;;;N;;;;;\nFCBC;ARABIC LIGATURE GHAIN WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 063A 062C;;;;N;;;;;\nFCBD;ARABIC LIGATURE GHAIN WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 063A 0645;;;;N;;;;;\nFCBE;ARABIC LIGATURE FEH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0641 062C;;;;N;;;;;\nFCBF;ARABIC LIGATURE FEH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0641 062D;;;;N;;;;;\nFCC0;ARABIC LIGATURE FEH WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0641 062E;;;;N;;;;;\nFCC1;ARABIC LIGATURE FEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0641 0645;;;;N;;;;;\nFCC2;ARABIC LIGATURE QAF WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0642 062D;;;;N;;;;;\nFCC3;ARABIC LIGATURE QAF WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0642 0645;;;;N;;;;;\nFCC4;ARABIC LIGATURE KAF WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0643 062C;;;;N;;;;;\nFCC5;ARABIC LIGATURE KAF WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0643 062D;;;;N;;;;;\nFCC6;ARABIC LIGATURE KAF WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0643 062E;;;;N;;;;;\nFCC7;ARABIC LIGATURE KAF WITH LAM INITIAL FORM;Lo;0;AL;<initial> 0643 0644;;;;N;;;;;\nFCC8;ARABIC LIGATURE KAF WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0643 0645;;;;N;;;;;\nFCC9;ARABIC LIGATURE LAM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0644 062C;;;;N;;;;;\nFCCA;ARABIC LIGATURE LAM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0644 062D;;;;N;;;;;\nFCCB;ARABIC LIGATURE LAM WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0644 062E;;;;N;;;;;\nFCCC;ARABIC LIGATURE LAM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0644 0645;;;;N;;;;;\nFCCD;ARABIC LIGATURE LAM WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0644 0647;;;;N;;;;;\nFCCE;ARABIC LIGATURE MEEM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062C;;;;N;;;;;\nFCCF;ARABIC LIGATURE MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0645 062D;;;;N;;;;;\nFCD0;ARABIC LIGATURE MEEM WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0645 062E;;;;N;;;;;\nFCD1;ARABIC LIGATURE MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0645 0645;;;;N;;;;;\nFCD2;ARABIC LIGATURE NOON WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0646 062C;;;;N;;;;;\nFCD3;ARABIC LIGATURE NOON WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0646 062D;;;;N;;;;;\nFCD4;ARABIC LIGATURE NOON WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0646 062E;;;;N;;;;;\nFCD5;ARABIC LIGATURE NOON WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0646 0645;;;;N;;;;;\nFCD6;ARABIC LIGATURE NOON WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0646 0647;;;;N;;;;;\nFCD7;ARABIC LIGATURE HEH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0647 062C;;;;N;;;;;\nFCD8;ARABIC LIGATURE HEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0647 0645;;;;N;;;;;\nFCD9;ARABIC LIGATURE HEH WITH SUPERSCRIPT ALEF INITIAL FORM;Lo;0;AL;<initial> 0647 0670;;;;N;;;;;\nFCDA;ARABIC LIGATURE YEH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 064A 062C;;;;N;;;;;\nFCDB;ARABIC LIGATURE YEH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 064A 062D;;;;N;;;;;\nFCDC;ARABIC LIGATURE YEH WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 064A 062E;;;;N;;;;;\nFCDD;ARABIC LIGATURE YEH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 064A 0645;;;;N;;;;;\nFCDE;ARABIC LIGATURE YEH WITH HEH INITIAL FORM;Lo;0;AL;<initial> 064A 0647;;;;N;;;;;\nFCDF;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0626 0645;;;;N;;;;;\nFCE0;ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 0626 0647;;;;N;;;;;\nFCE1;ARABIC LIGATURE BEH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0628 0645;;;;N;;;;;\nFCE2;ARABIC LIGATURE BEH WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 0628 0647;;;;N;;;;;\nFCE3;ARABIC LIGATURE TEH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 062A 0645;;;;N;;;;;\nFCE4;ARABIC LIGATURE TEH WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 062A 0647;;;;N;;;;;\nFCE5;ARABIC LIGATURE THEH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 062B 0645;;;;N;;;;;\nFCE6;ARABIC LIGATURE THEH WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 062B 0647;;;;N;;;;;\nFCE7;ARABIC LIGATURE SEEN WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0633 0645;;;;N;;;;;\nFCE8;ARABIC LIGATURE SEEN WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 0633 0647;;;;N;;;;;\nFCE9;ARABIC LIGATURE SHEEN WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0634 0645;;;;N;;;;;\nFCEA;ARABIC LIGATURE SHEEN WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 0634 0647;;;;N;;;;;\nFCEB;ARABIC LIGATURE KAF WITH LAM MEDIAL FORM;Lo;0;AL;<medial> 0643 0644;;;;N;;;;;\nFCEC;ARABIC LIGATURE KAF WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0643 0645;;;;N;;;;;\nFCED;ARABIC LIGATURE LAM WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0644 0645;;;;N;;;;;\nFCEE;ARABIC LIGATURE NOON WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0646 0645;;;;N;;;;;\nFCEF;ARABIC LIGATURE NOON WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 0646 0647;;;;N;;;;;\nFCF0;ARABIC LIGATURE YEH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 064A 0645;;;;N;;;;;\nFCF1;ARABIC LIGATURE YEH WITH HEH MEDIAL FORM;Lo;0;AL;<medial> 064A 0647;;;;N;;;;;\nFCF2;ARABIC LIGATURE SHADDA WITH FATHA MEDIAL FORM;Lo;0;AL;<medial> 0640 064E 0651;;;;N;;;;;\nFCF3;ARABIC LIGATURE SHADDA WITH DAMMA MEDIAL FORM;Lo;0;AL;<medial> 0640 064F 0651;;;;N;;;;;\nFCF4;ARABIC LIGATURE SHADDA WITH KASRA MEDIAL FORM;Lo;0;AL;<medial> 0640 0650 0651;;;;N;;;;;\nFCF5;ARABIC LIGATURE TAH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0637 0649;;;;N;;;;;\nFCF6;ARABIC LIGATURE TAH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0637 064A;;;;N;;;;;\nFCF7;ARABIC LIGATURE AIN WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0639 0649;;;;N;;;;;\nFCF8;ARABIC LIGATURE AIN WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0639 064A;;;;N;;;;;\nFCF9;ARABIC LIGATURE GHAIN WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 063A 0649;;;;N;;;;;\nFCFA;ARABIC LIGATURE GHAIN WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 063A 064A;;;;N;;;;;\nFCFB;ARABIC LIGATURE SEEN WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0633 0649;;;;N;;;;;\nFCFC;ARABIC LIGATURE SEEN WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0633 064A;;;;N;;;;;\nFCFD;ARABIC LIGATURE SHEEN WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0634 0649;;;;N;;;;;\nFCFE;ARABIC LIGATURE SHEEN WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0634 064A;;;;N;;;;;\nFCFF;ARABIC LIGATURE HAH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 062D 0649;;;;N;;;;;\nFD00;ARABIC LIGATURE HAH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 062D 064A;;;;N;;;;;\nFD01;ARABIC LIGATURE JEEM WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 062C 0649;;;;N;;;;;\nFD02;ARABIC LIGATURE JEEM WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 062C 064A;;;;N;;;;;\nFD03;ARABIC LIGATURE KHAH WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 062E 0649;;;;N;;;;;\nFD04;ARABIC LIGATURE KHAH WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 062E 064A;;;;N;;;;;\nFD05;ARABIC LIGATURE SAD WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0635 0649;;;;N;;;;;\nFD06;ARABIC LIGATURE SAD WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0635 064A;;;;N;;;;;\nFD07;ARABIC LIGATURE DAD WITH ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0636 0649;;;;N;;;;;\nFD08;ARABIC LIGATURE DAD WITH YEH ISOLATED FORM;Lo;0;AL;<isolated> 0636 064A;;;;N;;;;;\nFD09;ARABIC LIGATURE SHEEN WITH JEEM ISOLATED FORM;Lo;0;AL;<isolated> 0634 062C;;;;N;;;;;\nFD0A;ARABIC LIGATURE SHEEN WITH HAH ISOLATED FORM;Lo;0;AL;<isolated> 0634 062D;;;;N;;;;;\nFD0B;ARABIC LIGATURE SHEEN WITH KHAH ISOLATED FORM;Lo;0;AL;<isolated> 0634 062E;;;;N;;;;;\nFD0C;ARABIC LIGATURE SHEEN WITH MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0634 0645;;;;N;;;;;\nFD0D;ARABIC LIGATURE SHEEN WITH REH ISOLATED FORM;Lo;0;AL;<isolated> 0634 0631;;;;N;;;;;\nFD0E;ARABIC LIGATURE SEEN WITH REH ISOLATED FORM;Lo;0;AL;<isolated> 0633 0631;;;;N;;;;;\nFD0F;ARABIC LIGATURE SAD WITH REH ISOLATED FORM;Lo;0;AL;<isolated> 0635 0631;;;;N;;;;;\nFD10;ARABIC LIGATURE DAD WITH REH ISOLATED FORM;Lo;0;AL;<isolated> 0636 0631;;;;N;;;;;\nFD11;ARABIC LIGATURE TAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0637 0649;;;;N;;;;;\nFD12;ARABIC LIGATURE TAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0637 064A;;;;N;;;;;\nFD13;ARABIC LIGATURE AIN WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0639 0649;;;;N;;;;;\nFD14;ARABIC LIGATURE AIN WITH YEH FINAL FORM;Lo;0;AL;<final> 0639 064A;;;;N;;;;;\nFD15;ARABIC LIGATURE GHAIN WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 063A 0649;;;;N;;;;;\nFD16;ARABIC LIGATURE GHAIN WITH YEH FINAL FORM;Lo;0;AL;<final> 063A 064A;;;;N;;;;;\nFD17;ARABIC LIGATURE SEEN WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0633 0649;;;;N;;;;;\nFD18;ARABIC LIGATURE SEEN WITH YEH FINAL FORM;Lo;0;AL;<final> 0633 064A;;;;N;;;;;\nFD19;ARABIC LIGATURE SHEEN WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0634 0649;;;;N;;;;;\nFD1A;ARABIC LIGATURE SHEEN WITH YEH FINAL FORM;Lo;0;AL;<final> 0634 064A;;;;N;;;;;\nFD1B;ARABIC LIGATURE HAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062D 0649;;;;N;;;;;\nFD1C;ARABIC LIGATURE HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 062D 064A;;;;N;;;;;\nFD1D;ARABIC LIGATURE JEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062C 0649;;;;N;;;;;\nFD1E;ARABIC LIGATURE JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062C 064A;;;;N;;;;;\nFD1F;ARABIC LIGATURE KHAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062E 0649;;;;N;;;;;\nFD20;ARABIC LIGATURE KHAH WITH YEH FINAL FORM;Lo;0;AL;<final> 062E 064A;;;;N;;;;;\nFD21;ARABIC LIGATURE SAD WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0635 0649;;;;N;;;;;\nFD22;ARABIC LIGATURE SAD WITH YEH FINAL FORM;Lo;0;AL;<final> 0635 064A;;;;N;;;;;\nFD23;ARABIC LIGATURE DAD WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0636 0649;;;;N;;;;;\nFD24;ARABIC LIGATURE DAD WITH YEH FINAL FORM;Lo;0;AL;<final> 0636 064A;;;;N;;;;;\nFD25;ARABIC LIGATURE SHEEN WITH JEEM FINAL FORM;Lo;0;AL;<final> 0634 062C;;;;N;;;;;\nFD26;ARABIC LIGATURE SHEEN WITH HAH FINAL FORM;Lo;0;AL;<final> 0634 062D;;;;N;;;;;\nFD27;ARABIC LIGATURE SHEEN WITH KHAH FINAL FORM;Lo;0;AL;<final> 0634 062E;;;;N;;;;;\nFD28;ARABIC LIGATURE SHEEN WITH MEEM FINAL FORM;Lo;0;AL;<final> 0634 0645;;;;N;;;;;\nFD29;ARABIC LIGATURE SHEEN WITH REH FINAL FORM;Lo;0;AL;<final> 0634 0631;;;;N;;;;;\nFD2A;ARABIC LIGATURE SEEN WITH REH FINAL FORM;Lo;0;AL;<final> 0633 0631;;;;N;;;;;\nFD2B;ARABIC LIGATURE SAD WITH REH FINAL FORM;Lo;0;AL;<final> 0635 0631;;;;N;;;;;\nFD2C;ARABIC LIGATURE DAD WITH REH FINAL FORM;Lo;0;AL;<final> 0636 0631;;;;N;;;;;\nFD2D;ARABIC LIGATURE SHEEN WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0634 062C;;;;N;;;;;\nFD2E;ARABIC LIGATURE SHEEN WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0634 062D;;;;N;;;;;\nFD2F;ARABIC LIGATURE SHEEN WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0634 062E;;;;N;;;;;\nFD30;ARABIC LIGATURE SHEEN WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0634 0645;;;;N;;;;;\nFD31;ARABIC LIGATURE SEEN WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0633 0647;;;;N;;;;;\nFD32;ARABIC LIGATURE SHEEN WITH HEH INITIAL FORM;Lo;0;AL;<initial> 0634 0647;;;;N;;;;;\nFD33;ARABIC LIGATURE TAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0637 0645;;;;N;;;;;\nFD34;ARABIC LIGATURE SEEN WITH JEEM MEDIAL FORM;Lo;0;AL;<medial> 0633 062C;;;;N;;;;;\nFD35;ARABIC LIGATURE SEEN WITH HAH MEDIAL FORM;Lo;0;AL;<medial> 0633 062D;;;;N;;;;;\nFD36;ARABIC LIGATURE SEEN WITH KHAH MEDIAL FORM;Lo;0;AL;<medial> 0633 062E;;;;N;;;;;\nFD37;ARABIC LIGATURE SHEEN WITH JEEM MEDIAL FORM;Lo;0;AL;<medial> 0634 062C;;;;N;;;;;\nFD38;ARABIC LIGATURE SHEEN WITH HAH MEDIAL FORM;Lo;0;AL;<medial> 0634 062D;;;;N;;;;;\nFD39;ARABIC LIGATURE SHEEN WITH KHAH MEDIAL FORM;Lo;0;AL;<medial> 0634 062E;;;;N;;;;;\nFD3A;ARABIC LIGATURE TAH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0637 0645;;;;N;;;;;\nFD3B;ARABIC LIGATURE ZAH WITH MEEM MEDIAL FORM;Lo;0;AL;<medial> 0638 0645;;;;N;;;;;\nFD3C;ARABIC LIGATURE ALEF WITH FATHATAN FINAL FORM;Lo;0;AL;<final> 0627 064B;;;;N;;;;;\nFD3D;ARABIC LIGATURE ALEF WITH FATHATAN ISOLATED FORM;Lo;0;AL;<isolated> 0627 064B;;;;N;;;;;\nFD3E;ORNATE LEFT PARENTHESIS;Ps;0;ON;;;;;N;;;;;\nFD3F;ORNATE RIGHT PARENTHESIS;Pe;0;ON;;;;;N;;;;;\nFD50;ARABIC LIGATURE TEH WITH JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062A 062C 0645;;;;N;;;;;\nFD51;ARABIC LIGATURE TEH WITH HAH WITH JEEM FINAL FORM;Lo;0;AL;<final> 062A 062D 062C;;;;N;;;;;\nFD52;ARABIC LIGATURE TEH WITH HAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 062A 062D 062C;;;;N;;;;;\nFD53;ARABIC LIGATURE TEH WITH HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062A 062D 0645;;;;N;;;;;\nFD54;ARABIC LIGATURE TEH WITH KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 062A 062E 0645;;;;N;;;;;\nFD55;ARABIC LIGATURE TEH WITH MEEM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 062A 0645 062C;;;;N;;;;;\nFD56;ARABIC LIGATURE TEH WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 062A 0645 062D;;;;N;;;;;\nFD57;ARABIC LIGATURE TEH WITH MEEM WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 062A 0645 062E;;;;N;;;;;\nFD58;ARABIC LIGATURE JEEM WITH MEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 062C 0645 062D;;;;N;;;;;\nFD59;ARABIC LIGATURE JEEM WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 062C 0645 062D;;;;N;;;;;\nFD5A;ARABIC LIGATURE HAH WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062D 0645 064A;;;;N;;;;;\nFD5B;ARABIC LIGATURE HAH WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062D 0645 0649;;;;N;;;;;\nFD5C;ARABIC LIGATURE SEEN WITH HAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0633 062D 062C;;;;N;;;;;\nFD5D;ARABIC LIGATURE SEEN WITH JEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0633 062C 062D;;;;N;;;;;\nFD5E;ARABIC LIGATURE SEEN WITH JEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0633 062C 0649;;;;N;;;;;\nFD5F;ARABIC LIGATURE SEEN WITH MEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 0633 0645 062D;;;;N;;;;;\nFD60;ARABIC LIGATURE SEEN WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0633 0645 062D;;;;N;;;;;\nFD61;ARABIC LIGATURE SEEN WITH MEEM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0633 0645 062C;;;;N;;;;;\nFD62;ARABIC LIGATURE SEEN WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0633 0645 0645;;;;N;;;;;\nFD63;ARABIC LIGATURE SEEN WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0633 0645 0645;;;;N;;;;;\nFD64;ARABIC LIGATURE SAD WITH HAH WITH HAH FINAL FORM;Lo;0;AL;<final> 0635 062D 062D;;;;N;;;;;\nFD65;ARABIC LIGATURE SAD WITH HAH WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0635 062D 062D;;;;N;;;;;\nFD66;ARABIC LIGATURE SAD WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0635 0645 0645;;;;N;;;;;\nFD67;ARABIC LIGATURE SHEEN WITH HAH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0634 062D 0645;;;;N;;;;;\nFD68;ARABIC LIGATURE SHEEN WITH HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0634 062D 0645;;;;N;;;;;\nFD69;ARABIC LIGATURE SHEEN WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0634 062C 064A;;;;N;;;;;\nFD6A;ARABIC LIGATURE SHEEN WITH MEEM WITH KHAH FINAL FORM;Lo;0;AL;<final> 0634 0645 062E;;;;N;;;;;\nFD6B;ARABIC LIGATURE SHEEN WITH MEEM WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0634 0645 062E;;;;N;;;;;\nFD6C;ARABIC LIGATURE SHEEN WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0634 0645 0645;;;;N;;;;;\nFD6D;ARABIC LIGATURE SHEEN WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0634 0645 0645;;;;N;;;;;\nFD6E;ARABIC LIGATURE DAD WITH HAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0636 062D 0649;;;;N;;;;;\nFD6F;ARABIC LIGATURE DAD WITH KHAH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0636 062E 0645;;;;N;;;;;\nFD70;ARABIC LIGATURE DAD WITH KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0636 062E 0645;;;;N;;;;;\nFD71;ARABIC LIGATURE TAH WITH MEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 0637 0645 062D;;;;N;;;;;\nFD72;ARABIC LIGATURE TAH WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0637 0645 062D;;;;N;;;;;\nFD73;ARABIC LIGATURE TAH WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0637 0645 0645;;;;N;;;;;\nFD74;ARABIC LIGATURE TAH WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0637 0645 064A;;;;N;;;;;\nFD75;ARABIC LIGATURE AIN WITH JEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0639 062C 0645;;;;N;;;;;\nFD76;ARABIC LIGATURE AIN WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0639 0645 0645;;;;N;;;;;\nFD77;ARABIC LIGATURE AIN WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0639 0645 0645;;;;N;;;;;\nFD78;ARABIC LIGATURE AIN WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0639 0645 0649;;;;N;;;;;\nFD79;ARABIC LIGATURE GHAIN WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 063A 0645 0645;;;;N;;;;;\nFD7A;ARABIC LIGATURE GHAIN WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 063A 0645 064A;;;;N;;;;;\nFD7B;ARABIC LIGATURE GHAIN WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 063A 0645 0649;;;;N;;;;;\nFD7C;ARABIC LIGATURE FEH WITH KHAH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0641 062E 0645;;;;N;;;;;\nFD7D;ARABIC LIGATURE FEH WITH KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0641 062E 0645;;;;N;;;;;\nFD7E;ARABIC LIGATURE QAF WITH MEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 0642 0645 062D;;;;N;;;;;\nFD7F;ARABIC LIGATURE QAF WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0642 0645 0645;;;;N;;;;;\nFD80;ARABIC LIGATURE LAM WITH HAH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0644 062D 0645;;;;N;;;;;\nFD81;ARABIC LIGATURE LAM WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0644 062D 064A;;;;N;;;;;\nFD82;ARABIC LIGATURE LAM WITH HAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0644 062D 0649;;;;N;;;;;\nFD83;ARABIC LIGATURE LAM WITH JEEM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0644 062C 062C;;;;N;;;;;\nFD84;ARABIC LIGATURE LAM WITH JEEM WITH JEEM FINAL FORM;Lo;0;AL;<final> 0644 062C 062C;;;;N;;;;;\nFD85;ARABIC LIGATURE LAM WITH KHAH WITH MEEM FINAL FORM;Lo;0;AL;<final> 0644 062E 0645;;;;N;;;;;\nFD86;ARABIC LIGATURE LAM WITH KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0644 062E 0645;;;;N;;;;;\nFD87;ARABIC LIGATURE LAM WITH MEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 0644 0645 062D;;;;N;;;;;\nFD88;ARABIC LIGATURE LAM WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0644 0645 062D;;;;N;;;;;\nFD89;ARABIC LIGATURE MEEM WITH HAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062D 062C;;;;N;;;;;\nFD8A;ARABIC LIGATURE MEEM WITH HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062D 0645;;;;N;;;;;\nFD8B;ARABIC LIGATURE MEEM WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0645 062D 064A;;;;N;;;;;\nFD8C;ARABIC LIGATURE MEEM WITH JEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0645 062C 062D;;;;N;;;;;\nFD8D;ARABIC LIGATURE MEEM WITH JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062C 0645;;;;N;;;;;\nFD8E;ARABIC LIGATURE MEEM WITH KHAH WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062E 062C;;;;N;;;;;\nFD8F;ARABIC LIGATURE MEEM WITH KHAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0645 062E 0645;;;;N;;;;;\nFD92;ARABIC LIGATURE MEEM WITH JEEM WITH KHAH INITIAL FORM;Lo;0;AL;<initial> 0645 062C 062E;;;;N;;;;;\nFD93;ARABIC LIGATURE HEH WITH MEEM WITH JEEM INITIAL FORM;Lo;0;AL;<initial> 0647 0645 062C;;;;N;;;;;\nFD94;ARABIC LIGATURE HEH WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0647 0645 0645;;;;N;;;;;\nFD95;ARABIC LIGATURE NOON WITH HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0646 062D 0645;;;;N;;;;;\nFD96;ARABIC LIGATURE NOON WITH HAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0646 062D 0649;;;;N;;;;;\nFD97;ARABIC LIGATURE NOON WITH JEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0646 062C 0645;;;;N;;;;;\nFD98;ARABIC LIGATURE NOON WITH JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0646 062C 0645;;;;N;;;;;\nFD99;ARABIC LIGATURE NOON WITH JEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0646 062C 0649;;;;N;;;;;\nFD9A;ARABIC LIGATURE NOON WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0646 0645 064A;;;;N;;;;;\nFD9B;ARABIC LIGATURE NOON WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0646 0645 0649;;;;N;;;;;\nFD9C;ARABIC LIGATURE YEH WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 064A 0645 0645;;;;N;;;;;\nFD9D;ARABIC LIGATURE YEH WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 064A 0645 0645;;;;N;;;;;\nFD9E;ARABIC LIGATURE BEH WITH KHAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0628 062E 064A;;;;N;;;;;\nFD9F;ARABIC LIGATURE TEH WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062A 062C 064A;;;;N;;;;;\nFDA0;ARABIC LIGATURE TEH WITH JEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062A 062C 0649;;;;N;;;;;\nFDA1;ARABIC LIGATURE TEH WITH KHAH WITH YEH FINAL FORM;Lo;0;AL;<final> 062A 062E 064A;;;;N;;;;;\nFDA2;ARABIC LIGATURE TEH WITH KHAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062A 062E 0649;;;;N;;;;;\nFDA3;ARABIC LIGATURE TEH WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062A 0645 064A;;;;N;;;;;\nFDA4;ARABIC LIGATURE TEH WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062A 0645 0649;;;;N;;;;;\nFDA5;ARABIC LIGATURE JEEM WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062C 0645 064A;;;;N;;;;;\nFDA6;ARABIC LIGATURE JEEM WITH HAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062C 062D 0649;;;;N;;;;;\nFDA7;ARABIC LIGATURE JEEM WITH MEEM WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 062C 0645 0649;;;;N;;;;;\nFDA8;ARABIC LIGATURE SEEN WITH KHAH WITH ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0633 062E 0649;;;;N;;;;;\nFDA9;ARABIC LIGATURE SAD WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0635 062D 064A;;;;N;;;;;\nFDAA;ARABIC LIGATURE SHEEN WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0634 062D 064A;;;;N;;;;;\nFDAB;ARABIC LIGATURE DAD WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0636 062D 064A;;;;N;;;;;\nFDAC;ARABIC LIGATURE LAM WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0644 062C 064A;;;;N;;;;;\nFDAD;ARABIC LIGATURE LAM WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0644 0645 064A;;;;N;;;;;\nFDAE;ARABIC LIGATURE YEH WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 064A 062D 064A;;;;N;;;;;\nFDAF;ARABIC LIGATURE YEH WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 064A 062C 064A;;;;N;;;;;\nFDB0;ARABIC LIGATURE YEH WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 064A 0645 064A;;;;N;;;;;\nFDB1;ARABIC LIGATURE MEEM WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0645 0645 064A;;;;N;;;;;\nFDB2;ARABIC LIGATURE QAF WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0642 0645 064A;;;;N;;;;;\nFDB3;ARABIC LIGATURE NOON WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0646 062D 064A;;;;N;;;;;\nFDB4;ARABIC LIGATURE QAF WITH MEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0642 0645 062D;;;;N;;;;;\nFDB5;ARABIC LIGATURE LAM WITH HAH WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0644 062D 0645;;;;N;;;;;\nFDB6;ARABIC LIGATURE AIN WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0639 0645 064A;;;;N;;;;;\nFDB7;ARABIC LIGATURE KAF WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0643 0645 064A;;;;N;;;;;\nFDB8;ARABIC LIGATURE NOON WITH JEEM WITH HAH INITIAL FORM;Lo;0;AL;<initial> 0646 062C 062D;;;;N;;;;;\nFDB9;ARABIC LIGATURE MEEM WITH KHAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0645 062E 064A;;;;N;;;;;\nFDBA;ARABIC LIGATURE LAM WITH JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0644 062C 0645;;;;N;;;;;\nFDBB;ARABIC LIGATURE KAF WITH MEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0643 0645 0645;;;;N;;;;;\nFDBC;ARABIC LIGATURE LAM WITH JEEM WITH MEEM FINAL FORM;Lo;0;AL;<final> 0644 062C 0645;;;;N;;;;;\nFDBD;ARABIC LIGATURE NOON WITH JEEM WITH HAH FINAL FORM;Lo;0;AL;<final> 0646 062C 062D;;;;N;;;;;\nFDBE;ARABIC LIGATURE JEEM WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 062C 062D 064A;;;;N;;;;;\nFDBF;ARABIC LIGATURE HAH WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 062D 062C 064A;;;;N;;;;;\nFDC0;ARABIC LIGATURE MEEM WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0645 062C 064A;;;;N;;;;;\nFDC1;ARABIC LIGATURE FEH WITH MEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0641 0645 064A;;;;N;;;;;\nFDC2;ARABIC LIGATURE BEH WITH HAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0628 062D 064A;;;;N;;;;;\nFDC3;ARABIC LIGATURE KAF WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0643 0645 0645;;;;N;;;;;\nFDC4;ARABIC LIGATURE AIN WITH JEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0639 062C 0645;;;;N;;;;;\nFDC5;ARABIC LIGATURE SAD WITH MEEM WITH MEEM INITIAL FORM;Lo;0;AL;<initial> 0635 0645 0645;;;;N;;;;;\nFDC6;ARABIC LIGATURE SEEN WITH KHAH WITH YEH FINAL FORM;Lo;0;AL;<final> 0633 062E 064A;;;;N;;;;;\nFDC7;ARABIC LIGATURE NOON WITH JEEM WITH YEH FINAL FORM;Lo;0;AL;<final> 0646 062C 064A;;;;N;;;;;\nFDF0;ARABIC LIGATURE SALLA USED AS KORANIC STOP SIGN ISOLATED FORM;Lo;0;AL;<isolated> 0635 0644 06D2;;;;N;;;;;\nFDF1;ARABIC LIGATURE QALA USED AS KORANIC STOP SIGN ISOLATED FORM;Lo;0;AL;<isolated> 0642 0644 06D2;;;;N;;;;;\nFDF2;ARABIC LIGATURE ALLAH ISOLATED FORM;Lo;0;AL;<isolated> 0627 0644 0644 0647;;;;N;;;;;\nFDF3;ARABIC LIGATURE AKBAR ISOLATED FORM;Lo;0;AL;<isolated> 0627 0643 0628 0631;;;;N;;;;;\nFDF4;ARABIC LIGATURE MOHAMMAD ISOLATED FORM;Lo;0;AL;<isolated> 0645 062D 0645 062F;;;;N;;;;;\nFDF5;ARABIC LIGATURE SALAM ISOLATED FORM;Lo;0;AL;<isolated> 0635 0644 0639 0645;;;;N;;;;;\nFDF6;ARABIC LIGATURE RASOUL ISOLATED FORM;Lo;0;AL;<isolated> 0631 0633 0648 0644;;;;N;;;;;\nFDF7;ARABIC LIGATURE ALAYHE ISOLATED FORM;Lo;0;AL;<isolated> 0639 0644 064A 0647;;;;N;;;;;\nFDF8;ARABIC LIGATURE WASALLAM ISOLATED FORM;Lo;0;AL;<isolated> 0648 0633 0644 0645;;;;N;;;;;\nFDF9;ARABIC LIGATURE SALLA ISOLATED FORM;Lo;0;AL;<isolated> 0635 0644 0649;;;;N;;;;;\nFDFA;ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM;Lo;0;AL;<isolated> 0635 0644 0649 0020 0627 0644 0644 0647 0020 0639 0644 064A 0647 0020 0648 0633 0644 0645;;;;N;ARABIC LETTER SALLALLAHOU ALAYHE WASALLAM;;;;\nFDFB;ARABIC LIGATURE JALLAJALALOUHOU;Lo;0;AL;<isolated> 062C 0644 0020 062C 0644 0627 0644 0647;;;;N;ARABIC LETTER JALLAJALALOUHOU;;;;\nFDFC;RIAL SIGN;Sc;0;AL;<isolated> 0631 06CC 0627 0644;;;;N;;;;;\nFDFD;ARABIC LIGATURE BISMILLAH AR-RAHMAN AR-RAHEEM;So;0;ON;;;;;N;;;;;\nFE00;VARIATION SELECTOR-1;Mn;0;NSM;;;;;N;;;;;\nFE01;VARIATION SELECTOR-2;Mn;0;NSM;;;;;N;;;;;\nFE02;VARIATION SELECTOR-3;Mn;0;NSM;;;;;N;;;;;\nFE03;VARIATION SELECTOR-4;Mn;0;NSM;;;;;N;;;;;\nFE04;VARIATION SELECTOR-5;Mn;0;NSM;;;;;N;;;;;\nFE05;VARIATION SELECTOR-6;Mn;0;NSM;;;;;N;;;;;\nFE06;VARIATION SELECTOR-7;Mn;0;NSM;;;;;N;;;;;\nFE07;VARIATION SELECTOR-8;Mn;0;NSM;;;;;N;;;;;\nFE08;VARIATION SELECTOR-9;Mn;0;NSM;;;;;N;;;;;\nFE09;VARIATION SELECTOR-10;Mn;0;NSM;;;;;N;;;;;\nFE0A;VARIATION SELECTOR-11;Mn;0;NSM;;;;;N;;;;;\nFE0B;VARIATION SELECTOR-12;Mn;0;NSM;;;;;N;;;;;\nFE0C;VARIATION SELECTOR-13;Mn;0;NSM;;;;;N;;;;;\nFE0D;VARIATION SELECTOR-14;Mn;0;NSM;;;;;N;;;;;\nFE0E;VARIATION SELECTOR-15;Mn;0;NSM;;;;;N;;;;;\nFE0F;VARIATION SELECTOR-16;Mn;0;NSM;;;;;N;;;;;\nFE10;PRESENTATION FORM FOR VERTICAL COMMA;Po;0;ON;<vertical> 002C;;;;N;;;;;\nFE11;PRESENTATION FORM FOR VERTICAL IDEOGRAPHIC COMMA;Po;0;ON;<vertical> 3001;;;;N;;;;;\nFE12;PRESENTATION FORM FOR VERTICAL IDEOGRAPHIC FULL STOP;Po;0;ON;<vertical> 3002;;;;N;;;;;\nFE13;PRESENTATION FORM FOR VERTICAL COLON;Po;0;ON;<vertical> 003A;;;;N;;;;;\nFE14;PRESENTATION FORM FOR VERTICAL SEMICOLON;Po;0;ON;<vertical> 003B;;;;N;;;;;\nFE15;PRESENTATION FORM FOR VERTICAL EXCLAMATION MARK;Po;0;ON;<vertical> 0021;;;;N;;;;;\nFE16;PRESENTATION FORM FOR VERTICAL QUESTION MARK;Po;0;ON;<vertical> 003F;;;;N;;;;;\nFE17;PRESENTATION FORM FOR VERTICAL LEFT WHITE LENTICULAR BRACKET;Ps;0;ON;<vertical> 3016;;;;N;;;;;\nFE18;PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRAKCET;Pe;0;ON;<vertical> 3017;;;;N;;;;;\nFE19;PRESENTATION FORM FOR VERTICAL HORIZONTAL ELLIPSIS;Po;0;ON;<vertical> 2026;;;;N;;;;;\nFE20;COMBINING LIGATURE LEFT HALF;Mn;230;NSM;;;;;N;;;;;\nFE21;COMBINING LIGATURE RIGHT HALF;Mn;230;NSM;;;;;N;;;;;\nFE22;COMBINING DOUBLE TILDE LEFT HALF;Mn;230;NSM;;;;;N;;;;;\nFE23;COMBINING DOUBLE TILDE RIGHT HALF;Mn;230;NSM;;;;;N;;;;;\nFE24;COMBINING MACRON LEFT HALF;Mn;230;NSM;;;;;N;;;;;\nFE25;COMBINING MACRON RIGHT HALF;Mn;230;NSM;;;;;N;;;;;\nFE26;COMBINING CONJOINING MACRON;Mn;230;NSM;;;;;N;;;;;\nFE30;PRESENTATION FORM FOR VERTICAL TWO DOT LEADER;Po;0;ON;<vertical> 2025;;;;N;GLYPH FOR VERTICAL TWO DOT LEADER;;;;\nFE31;PRESENTATION FORM FOR VERTICAL EM DASH;Pd;0;ON;<vertical> 2014;;;;N;GLYPH FOR VERTICAL EM DASH;;;;\nFE32;PRESENTATION FORM FOR VERTICAL EN DASH;Pd;0;ON;<vertical> 2013;;;;N;GLYPH FOR VERTICAL EN DASH;;;;\nFE33;PRESENTATION FORM FOR VERTICAL LOW LINE;Pc;0;ON;<vertical> 005F;;;;N;GLYPH FOR VERTICAL SPACING UNDERSCORE;;;;\nFE34;PRESENTATION FORM FOR VERTICAL WAVY LOW LINE;Pc;0;ON;<vertical> 005F;;;;N;GLYPH FOR VERTICAL SPACING WAVY UNDERSCORE;;;;\nFE35;PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS;Ps;0;ON;<vertical> 0028;;;;N;GLYPH FOR VERTICAL OPENING PARENTHESIS;;;;\nFE36;PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS;Pe;0;ON;<vertical> 0029;;;;N;GLYPH FOR VERTICAL CLOSING PARENTHESIS;;;;\nFE37;PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET;Ps;0;ON;<vertical> 007B;;;;N;GLYPH FOR VERTICAL OPENING CURLY BRACKET;;;;\nFE38;PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET;Pe;0;ON;<vertical> 007D;;;;N;GLYPH FOR VERTICAL CLOSING CURLY BRACKET;;;;\nFE39;PRESENTATION FORM FOR VERTICAL LEFT TORTOISE SHELL BRACKET;Ps;0;ON;<vertical> 3014;;;;N;GLYPH FOR VERTICAL OPENING TORTOISE SHELL BRACKET;;;;\nFE3A;PRESENTATION FORM FOR VERTICAL RIGHT TORTOISE SHELL BRACKET;Pe;0;ON;<vertical> 3015;;;;N;GLYPH FOR VERTICAL CLOSING TORTOISE SHELL BRACKET;;;;\nFE3B;PRESENTATION FORM FOR VERTICAL LEFT BLACK LENTICULAR BRACKET;Ps;0;ON;<vertical> 3010;;;;N;GLYPH FOR VERTICAL OPENING BLACK LENTICULAR BRACKET;;;;\nFE3C;PRESENTATION FORM FOR VERTICAL RIGHT BLACK LENTICULAR BRACKET;Pe;0;ON;<vertical> 3011;;;;N;GLYPH FOR VERTICAL CLOSING BLACK LENTICULAR BRACKET;;;;\nFE3D;PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET;Ps;0;ON;<vertical> 300A;;;;N;GLYPH FOR VERTICAL OPENING DOUBLE ANGLE BRACKET;;;;\nFE3E;PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET;Pe;0;ON;<vertical> 300B;;;;N;GLYPH FOR VERTICAL CLOSING DOUBLE ANGLE BRACKET;;;;\nFE3F;PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET;Ps;0;ON;<vertical> 3008;;;;N;GLYPH FOR VERTICAL OPENING ANGLE BRACKET;;;;\nFE40;PRESENTATION FORM FOR VERTICAL RIGHT ANGLE BRACKET;Pe;0;ON;<vertical> 3009;;;;N;GLYPH FOR VERTICAL CLOSING ANGLE BRACKET;;;;\nFE41;PRESENTATION FORM FOR VERTICAL LEFT CORNER BRACKET;Ps;0;ON;<vertical> 300C;;;;N;GLYPH FOR VERTICAL OPENING CORNER BRACKET;;;;\nFE42;PRESENTATION FORM FOR VERTICAL RIGHT CORNER BRACKET;Pe;0;ON;<vertical> 300D;;;;N;GLYPH FOR VERTICAL CLOSING CORNER BRACKET;;;;\nFE43;PRESENTATION FORM FOR VERTICAL LEFT WHITE CORNER BRACKET;Ps;0;ON;<vertical> 300E;;;;N;GLYPH FOR VERTICAL OPENING WHITE CORNER BRACKET;;;;\nFE44;PRESENTATION FORM FOR VERTICAL RIGHT WHITE CORNER BRACKET;Pe;0;ON;<vertical> 300F;;;;N;GLYPH FOR VERTICAL CLOSING WHITE CORNER BRACKET;;;;\nFE45;SESAME DOT;Po;0;ON;;;;;N;;;;;\nFE46;WHITE SESAME DOT;Po;0;ON;;;;;N;;;;;\nFE47;PRESENTATION FORM FOR VERTICAL LEFT SQUARE BRACKET;Ps;0;ON;<vertical> 005B;;;;N;;;;;\nFE48;PRESENTATION FORM FOR VERTICAL RIGHT SQUARE BRACKET;Pe;0;ON;<vertical> 005D;;;;N;;;;;\nFE49;DASHED OVERLINE;Po;0;ON;<compat> 203E;;;;N;SPACING DASHED OVERSCORE;;;;\nFE4A;CENTRELINE OVERLINE;Po;0;ON;<compat> 203E;;;;N;SPACING CENTERLINE OVERSCORE;;;;\nFE4B;WAVY OVERLINE;Po;0;ON;<compat> 203E;;;;N;SPACING WAVY OVERSCORE;;;;\nFE4C;DOUBLE WAVY OVERLINE;Po;0;ON;<compat> 203E;;;;N;SPACING DOUBLE WAVY OVERSCORE;;;;\nFE4D;DASHED LOW LINE;Pc;0;ON;<compat> 005F;;;;N;SPACING DASHED UNDERSCORE;;;;\nFE4E;CENTRELINE LOW LINE;Pc;0;ON;<compat> 005F;;;;N;SPACING CENTERLINE UNDERSCORE;;;;\nFE4F;WAVY LOW LINE;Pc;0;ON;<compat> 005F;;;;N;SPACING WAVY UNDERSCORE;;;;\nFE50;SMALL COMMA;Po;0;CS;<small> 002C;;;;N;;;;;\nFE51;SMALL IDEOGRAPHIC COMMA;Po;0;ON;<small> 3001;;;;N;;;;;\nFE52;SMALL FULL STOP;Po;0;CS;<small> 002E;;;;N;SMALL PERIOD;;;;\nFE54;SMALL SEMICOLON;Po;0;ON;<small> 003B;;;;N;;;;;\nFE55;SMALL COLON;Po;0;CS;<small> 003A;;;;N;;;;;\nFE56;SMALL QUESTION MARK;Po;0;ON;<small> 003F;;;;N;;;;;\nFE57;SMALL EXCLAMATION MARK;Po;0;ON;<small> 0021;;;;N;;;;;\nFE58;SMALL EM DASH;Pd;0;ON;<small> 2014;;;;N;;;;;\nFE59;SMALL LEFT PARENTHESIS;Ps;0;ON;<small> 0028;;;;Y;SMALL OPENING PARENTHESIS;;;;\nFE5A;SMALL RIGHT PARENTHESIS;Pe;0;ON;<small> 0029;;;;Y;SMALL CLOSING PARENTHESIS;;;;\nFE5B;SMALL LEFT CURLY BRACKET;Ps;0;ON;<small> 007B;;;;Y;SMALL OPENING CURLY BRACKET;;;;\nFE5C;SMALL RIGHT CURLY BRACKET;Pe;0;ON;<small> 007D;;;;Y;SMALL CLOSING CURLY BRACKET;;;;\nFE5D;SMALL LEFT TORTOISE SHELL BRACKET;Ps;0;ON;<small> 3014;;;;Y;SMALL OPENING TORTOISE SHELL BRACKET;;;;\nFE5E;SMALL RIGHT TORTOISE SHELL BRACKET;Pe;0;ON;<small> 3015;;;;Y;SMALL CLOSING TORTOISE SHELL BRACKET;;;;\nFE5F;SMALL NUMBER SIGN;Po;0;ET;<small> 0023;;;;N;;;;;\nFE60;SMALL AMPERSAND;Po;0;ON;<small> 0026;;;;N;;;;;\nFE61;SMALL ASTERISK;Po;0;ON;<small> 002A;;;;N;;;;;\nFE62;SMALL PLUS SIGN;Sm;0;ES;<small> 002B;;;;N;;;;;\nFE63;SMALL HYPHEN-MINUS;Pd;0;ES;<small> 002D;;;;N;;;;;\nFE64;SMALL LESS-THAN SIGN;Sm;0;ON;<small> 003C;;;;Y;;;;;\nFE65;SMALL GREATER-THAN SIGN;Sm;0;ON;<small> 003E;;;;Y;;;;;\nFE66;SMALL EQUALS SIGN;Sm;0;ON;<small> 003D;;;;N;;;;;\nFE68;SMALL REVERSE SOLIDUS;Po;0;ON;<small> 005C;;;;N;SMALL BACKSLASH;;;;\nFE69;SMALL DOLLAR SIGN;Sc;0;ET;<small> 0024;;;;N;;;;;\nFE6A;SMALL PERCENT SIGN;Po;0;ET;<small> 0025;;;;N;;;;;\nFE6B;SMALL COMMERCIAL AT;Po;0;ON;<small> 0040;;;;N;;;;;\nFE70;ARABIC FATHATAN ISOLATED FORM;Lo;0;AL;<isolated> 0020 064B;;;;N;ARABIC SPACING FATHATAN;;;;\nFE71;ARABIC TATWEEL WITH FATHATAN ABOVE;Lo;0;AL;<medial> 0640 064B;;;;N;ARABIC FATHATAN ON TATWEEL;;;;\nFE72;ARABIC DAMMATAN ISOLATED FORM;Lo;0;AL;<isolated> 0020 064C;;;;N;ARABIC SPACING DAMMATAN;;;;\nFE73;ARABIC TAIL FRAGMENT;Lo;0;AL;;;;;N;;;;;\nFE74;ARABIC KASRATAN ISOLATED FORM;Lo;0;AL;<isolated> 0020 064D;;;;N;ARABIC SPACING KASRATAN;;;;\nFE76;ARABIC FATHA ISOLATED FORM;Lo;0;AL;<isolated> 0020 064E;;;;N;ARABIC SPACING FATHAH;;;;\nFE77;ARABIC FATHA MEDIAL FORM;Lo;0;AL;<medial> 0640 064E;;;;N;ARABIC FATHAH ON TATWEEL;;;;\nFE78;ARABIC DAMMA ISOLATED FORM;Lo;0;AL;<isolated> 0020 064F;;;;N;ARABIC SPACING DAMMAH;;;;\nFE79;ARABIC DAMMA MEDIAL FORM;Lo;0;AL;<medial> 0640 064F;;;;N;ARABIC DAMMAH ON TATWEEL;;;;\nFE7A;ARABIC KASRA ISOLATED FORM;Lo;0;AL;<isolated> 0020 0650;;;;N;ARABIC SPACING KASRAH;;;;\nFE7B;ARABIC KASRA MEDIAL FORM;Lo;0;AL;<medial> 0640 0650;;;;N;ARABIC KASRAH ON TATWEEL;;;;\nFE7C;ARABIC SHADDA ISOLATED FORM;Lo;0;AL;<isolated> 0020 0651;;;;N;ARABIC SPACING SHADDAH;;;;\nFE7D;ARABIC SHADDA MEDIAL FORM;Lo;0;AL;<medial> 0640 0651;;;;N;ARABIC SHADDAH ON TATWEEL;;;;\nFE7E;ARABIC SUKUN ISOLATED FORM;Lo;0;AL;<isolated> 0020 0652;;;;N;ARABIC SPACING SUKUN;;;;\nFE7F;ARABIC SUKUN MEDIAL FORM;Lo;0;AL;<medial> 0640 0652;;;;N;ARABIC SUKUN ON TATWEEL;;;;\nFE80;ARABIC LETTER HAMZA ISOLATED FORM;Lo;0;AL;<isolated> 0621;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH;;;;\nFE81;ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0622;;;;N;GLYPH FOR ISOLATE ARABIC MADDAH ON ALEF;;;;\nFE82;ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM;Lo;0;AL;<final> 0622;;;;N;GLYPH FOR FINAL ARABIC MADDAH ON ALEF;;;;\nFE83;ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0623;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH ON ALEF;;;;\nFE84;ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM;Lo;0;AL;<final> 0623;;;;N;GLYPH FOR FINAL ARABIC HAMZAH ON ALEF;;;;\nFE85;ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0624;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH ON WAW;;;;\nFE86;ARABIC LETTER WAW WITH HAMZA ABOVE FINAL FORM;Lo;0;AL;<final> 0624;;;;N;GLYPH FOR FINAL ARABIC HAMZAH ON WAW;;;;\nFE87;ARABIC LETTER ALEF WITH HAMZA BELOW ISOLATED FORM;Lo;0;AL;<isolated> 0625;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH UNDER ALEF;;;;\nFE88;ARABIC LETTER ALEF WITH HAMZA BELOW FINAL FORM;Lo;0;AL;<final> 0625;;;;N;GLYPH FOR FINAL ARABIC HAMZAH UNDER ALEF;;;;\nFE89;ARABIC LETTER YEH WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0626;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH ON YA;;;;\nFE8A;ARABIC LETTER YEH WITH HAMZA ABOVE FINAL FORM;Lo;0;AL;<final> 0626;;;;N;GLYPH FOR FINAL ARABIC HAMZAH ON YA;;;;\nFE8B;ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM;Lo;0;AL;<initial> 0626;;;;N;GLYPH FOR INITIAL ARABIC HAMZAH ON YA;;;;\nFE8C;ARABIC LETTER YEH WITH HAMZA ABOVE MEDIAL FORM;Lo;0;AL;<medial> 0626;;;;N;GLYPH FOR MEDIAL ARABIC HAMZAH ON YA;;;;\nFE8D;ARABIC LETTER ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0627;;;;N;GLYPH FOR ISOLATE ARABIC ALEF;;;;\nFE8E;ARABIC LETTER ALEF FINAL FORM;Lo;0;AL;<final> 0627;;;;N;GLYPH FOR FINAL ARABIC ALEF;;;;\nFE8F;ARABIC LETTER BEH ISOLATED FORM;Lo;0;AL;<isolated> 0628;;;;N;GLYPH FOR ISOLATE ARABIC BAA;;;;\nFE90;ARABIC LETTER BEH FINAL FORM;Lo;0;AL;<final> 0628;;;;N;GLYPH FOR FINAL ARABIC BAA;;;;\nFE91;ARABIC LETTER BEH INITIAL FORM;Lo;0;AL;<initial> 0628;;;;N;GLYPH FOR INITIAL ARABIC BAA;;;;\nFE92;ARABIC LETTER BEH MEDIAL FORM;Lo;0;AL;<medial> 0628;;;;N;GLYPH FOR MEDIAL ARABIC BAA;;;;\nFE93;ARABIC LETTER TEH MARBUTA ISOLATED FORM;Lo;0;AL;<isolated> 0629;;;;N;GLYPH FOR ISOLATE ARABIC TAA MARBUTAH;;;;\nFE94;ARABIC LETTER TEH MARBUTA FINAL FORM;Lo;0;AL;<final> 0629;;;;N;GLYPH FOR FINAL ARABIC TAA MARBUTAH;;;;\nFE95;ARABIC LETTER TEH ISOLATED FORM;Lo;0;AL;<isolated> 062A;;;;N;GLYPH FOR ISOLATE ARABIC TAA;;;;\nFE96;ARABIC LETTER TEH FINAL FORM;Lo;0;AL;<final> 062A;;;;N;GLYPH FOR FINAL ARABIC TAA;;;;\nFE97;ARABIC LETTER TEH INITIAL FORM;Lo;0;AL;<initial> 062A;;;;N;GLYPH FOR INITIAL ARABIC TAA;;;;\nFE98;ARABIC LETTER TEH MEDIAL FORM;Lo;0;AL;<medial> 062A;;;;N;GLYPH FOR MEDIAL ARABIC TAA;;;;\nFE99;ARABIC LETTER THEH ISOLATED FORM;Lo;0;AL;<isolated> 062B;;;;N;GLYPH FOR ISOLATE ARABIC THAA;;;;\nFE9A;ARABIC LETTER THEH FINAL FORM;Lo;0;AL;<final> 062B;;;;N;GLYPH FOR FINAL ARABIC THAA;;;;\nFE9B;ARABIC LETTER THEH INITIAL FORM;Lo;0;AL;<initial> 062B;;;;N;GLYPH FOR INITIAL ARABIC THAA;;;;\nFE9C;ARABIC LETTER THEH MEDIAL FORM;Lo;0;AL;<medial> 062B;;;;N;GLYPH FOR MEDIAL ARABIC THAA;;;;\nFE9D;ARABIC LETTER JEEM ISOLATED FORM;Lo;0;AL;<isolated> 062C;;;;N;GLYPH FOR ISOLATE ARABIC JEEM;;;;\nFE9E;ARABIC LETTER JEEM FINAL FORM;Lo;0;AL;<final> 062C;;;;N;GLYPH FOR FINAL ARABIC JEEM;;;;\nFE9F;ARABIC LETTER JEEM INITIAL FORM;Lo;0;AL;<initial> 062C;;;;N;GLYPH FOR INITIAL ARABIC JEEM;;;;\nFEA0;ARABIC LETTER JEEM MEDIAL FORM;Lo;0;AL;<medial> 062C;;;;N;GLYPH FOR MEDIAL ARABIC JEEM;;;;\nFEA1;ARABIC LETTER HAH ISOLATED FORM;Lo;0;AL;<isolated> 062D;;;;N;GLYPH FOR ISOLATE ARABIC HAA;;;;\nFEA2;ARABIC LETTER HAH FINAL FORM;Lo;0;AL;<final> 062D;;;;N;GLYPH FOR FINAL ARABIC HAA;;;;\nFEA3;ARABIC LETTER HAH INITIAL FORM;Lo;0;AL;<initial> 062D;;;;N;GLYPH FOR INITIAL ARABIC HAA;;;;\nFEA4;ARABIC LETTER HAH MEDIAL FORM;Lo;0;AL;<medial> 062D;;;;N;GLYPH FOR MEDIAL ARABIC HAA;;;;\nFEA5;ARABIC LETTER KHAH ISOLATED FORM;Lo;0;AL;<isolated> 062E;;;;N;GLYPH FOR ISOLATE ARABIC KHAA;;;;\nFEA6;ARABIC LETTER KHAH FINAL FORM;Lo;0;AL;<final> 062E;;;;N;GLYPH FOR FINAL ARABIC KHAA;;;;\nFEA7;ARABIC LETTER KHAH INITIAL FORM;Lo;0;AL;<initial> 062E;;;;N;GLYPH FOR INITIAL ARABIC KHAA;;;;\nFEA8;ARABIC LETTER KHAH MEDIAL FORM;Lo;0;AL;<medial> 062E;;;;N;GLYPH FOR MEDIAL ARABIC KHAA;;;;\nFEA9;ARABIC LETTER DAL ISOLATED FORM;Lo;0;AL;<isolated> 062F;;;;N;GLYPH FOR ISOLATE ARABIC DAL;;;;\nFEAA;ARABIC LETTER DAL FINAL FORM;Lo;0;AL;<final> 062F;;;;N;GLYPH FOR FINAL ARABIC DAL;;;;\nFEAB;ARABIC LETTER THAL ISOLATED FORM;Lo;0;AL;<isolated> 0630;;;;N;GLYPH FOR ISOLATE ARABIC THAL;;;;\nFEAC;ARABIC LETTER THAL FINAL FORM;Lo;0;AL;<final> 0630;;;;N;GLYPH FOR FINAL ARABIC THAL;;;;\nFEAD;ARABIC LETTER REH ISOLATED FORM;Lo;0;AL;<isolated> 0631;;;;N;GLYPH FOR ISOLATE ARABIC RA;;;;\nFEAE;ARABIC LETTER REH FINAL FORM;Lo;0;AL;<final> 0631;;;;N;GLYPH FOR FINAL ARABIC RA;;;;\nFEAF;ARABIC LETTER ZAIN ISOLATED FORM;Lo;0;AL;<isolated> 0632;;;;N;GLYPH FOR ISOLATE ARABIC ZAIN;;;;\nFEB0;ARABIC LETTER ZAIN FINAL FORM;Lo;0;AL;<final> 0632;;;;N;GLYPH FOR FINAL ARABIC ZAIN;;;;\nFEB1;ARABIC LETTER SEEN ISOLATED FORM;Lo;0;AL;<isolated> 0633;;;;N;GLYPH FOR ISOLATE ARABIC SEEN;;;;\nFEB2;ARABIC LETTER SEEN FINAL FORM;Lo;0;AL;<final> 0633;;;;N;GLYPH FOR FINAL ARABIC SEEN;;;;\nFEB3;ARABIC LETTER SEEN INITIAL FORM;Lo;0;AL;<initial> 0633;;;;N;GLYPH FOR INITIAL ARABIC SEEN;;;;\nFEB4;ARABIC LETTER SEEN MEDIAL FORM;Lo;0;AL;<medial> 0633;;;;N;GLYPH FOR MEDIAL ARABIC SEEN;;;;\nFEB5;ARABIC LETTER SHEEN ISOLATED FORM;Lo;0;AL;<isolated> 0634;;;;N;GLYPH FOR ISOLATE ARABIC SHEEN;;;;\nFEB6;ARABIC LETTER SHEEN FINAL FORM;Lo;0;AL;<final> 0634;;;;N;GLYPH FOR FINAL ARABIC SHEEN;;;;\nFEB7;ARABIC LETTER SHEEN INITIAL FORM;Lo;0;AL;<initial> 0634;;;;N;GLYPH FOR INITIAL ARABIC SHEEN;;;;\nFEB8;ARABIC LETTER SHEEN MEDIAL FORM;Lo;0;AL;<medial> 0634;;;;N;GLYPH FOR MEDIAL ARABIC SHEEN;;;;\nFEB9;ARABIC LETTER SAD ISOLATED FORM;Lo;0;AL;<isolated> 0635;;;;N;GLYPH FOR ISOLATE ARABIC SAD;;;;\nFEBA;ARABIC LETTER SAD FINAL FORM;Lo;0;AL;<final> 0635;;;;N;GLYPH FOR FINAL ARABIC SAD;;;;\nFEBB;ARABIC LETTER SAD INITIAL FORM;Lo;0;AL;<initial> 0635;;;;N;GLYPH FOR INITIAL ARABIC SAD;;;;\nFEBC;ARABIC LETTER SAD MEDIAL FORM;Lo;0;AL;<medial> 0635;;;;N;GLYPH FOR MEDIAL ARABIC SAD;;;;\nFEBD;ARABIC LETTER DAD ISOLATED FORM;Lo;0;AL;<isolated> 0636;;;;N;GLYPH FOR ISOLATE ARABIC DAD;;;;\nFEBE;ARABIC LETTER DAD FINAL FORM;Lo;0;AL;<final> 0636;;;;N;GLYPH FOR FINAL ARABIC DAD;;;;\nFEBF;ARABIC LETTER DAD INITIAL FORM;Lo;0;AL;<initial> 0636;;;;N;GLYPH FOR INITIAL ARABIC DAD;;;;\nFEC0;ARABIC LETTER DAD MEDIAL FORM;Lo;0;AL;<medial> 0636;;;;N;GLYPH FOR MEDIAL ARABIC DAD;;;;\nFEC1;ARABIC LETTER TAH ISOLATED FORM;Lo;0;AL;<isolated> 0637;;;;N;GLYPH FOR ISOLATE ARABIC TAH;;;;\nFEC2;ARABIC LETTER TAH FINAL FORM;Lo;0;AL;<final> 0637;;;;N;GLYPH FOR FINAL ARABIC TAH;;;;\nFEC3;ARABIC LETTER TAH INITIAL FORM;Lo;0;AL;<initial> 0637;;;;N;GLYPH FOR INITIAL ARABIC TAH;;;;\nFEC4;ARABIC LETTER TAH MEDIAL FORM;Lo;0;AL;<medial> 0637;;;;N;GLYPH FOR MEDIAL ARABIC TAH;;;;\nFEC5;ARABIC LETTER ZAH ISOLATED FORM;Lo;0;AL;<isolated> 0638;;;;N;GLYPH FOR ISOLATE ARABIC DHAH;;;;\nFEC6;ARABIC LETTER ZAH FINAL FORM;Lo;0;AL;<final> 0638;;;;N;GLYPH FOR FINAL ARABIC DHAH;;;;\nFEC7;ARABIC LETTER ZAH INITIAL FORM;Lo;0;AL;<initial> 0638;;;;N;GLYPH FOR INITIAL ARABIC DHAH;;;;\nFEC8;ARABIC LETTER ZAH MEDIAL FORM;Lo;0;AL;<medial> 0638;;;;N;GLYPH FOR MEDIAL ARABIC DHAH;;;;\nFEC9;ARABIC LETTER AIN ISOLATED FORM;Lo;0;AL;<isolated> 0639;;;;N;GLYPH FOR ISOLATE ARABIC AIN;;;;\nFECA;ARABIC LETTER AIN FINAL FORM;Lo;0;AL;<final> 0639;;;;N;GLYPH FOR FINAL ARABIC AIN;;;;\nFECB;ARABIC LETTER AIN INITIAL FORM;Lo;0;AL;<initial> 0639;;;;N;GLYPH FOR INITIAL ARABIC AIN;;;;\nFECC;ARABIC LETTER AIN MEDIAL FORM;Lo;0;AL;<medial> 0639;;;;N;GLYPH FOR MEDIAL ARABIC AIN;;;;\nFECD;ARABIC LETTER GHAIN ISOLATED FORM;Lo;0;AL;<isolated> 063A;;;;N;GLYPH FOR ISOLATE ARABIC GHAIN;;;;\nFECE;ARABIC LETTER GHAIN FINAL FORM;Lo;0;AL;<final> 063A;;;;N;GLYPH FOR FINAL ARABIC GHAIN;;;;\nFECF;ARABIC LETTER GHAIN INITIAL FORM;Lo;0;AL;<initial> 063A;;;;N;GLYPH FOR INITIAL ARABIC GHAIN;;;;\nFED0;ARABIC LETTER GHAIN MEDIAL FORM;Lo;0;AL;<medial> 063A;;;;N;GLYPH FOR MEDIAL ARABIC GHAIN;;;;\nFED1;ARABIC LETTER FEH ISOLATED FORM;Lo;0;AL;<isolated> 0641;;;;N;GLYPH FOR ISOLATE ARABIC FA;;;;\nFED2;ARABIC LETTER FEH FINAL FORM;Lo;0;AL;<final> 0641;;;;N;GLYPH FOR FINAL ARABIC FA;;;;\nFED3;ARABIC LETTER FEH INITIAL FORM;Lo;0;AL;<initial> 0641;;;;N;GLYPH FOR INITIAL ARABIC FA;;;;\nFED4;ARABIC LETTER FEH MEDIAL FORM;Lo;0;AL;<medial> 0641;;;;N;GLYPH FOR MEDIAL ARABIC FA;;;;\nFED5;ARABIC LETTER QAF ISOLATED FORM;Lo;0;AL;<isolated> 0642;;;;N;GLYPH FOR ISOLATE ARABIC QAF;;;;\nFED6;ARABIC LETTER QAF FINAL FORM;Lo;0;AL;<final> 0642;;;;N;GLYPH FOR FINAL ARABIC QAF;;;;\nFED7;ARABIC LETTER QAF INITIAL FORM;Lo;0;AL;<initial> 0642;;;;N;GLYPH FOR INITIAL ARABIC QAF;;;;\nFED8;ARABIC LETTER QAF MEDIAL FORM;Lo;0;AL;<medial> 0642;;;;N;GLYPH FOR MEDIAL ARABIC QAF;;;;\nFED9;ARABIC LETTER KAF ISOLATED FORM;Lo;0;AL;<isolated> 0643;;;;N;GLYPH FOR ISOLATE ARABIC CAF;;;;\nFEDA;ARABIC LETTER KAF FINAL FORM;Lo;0;AL;<final> 0643;;;;N;GLYPH FOR FINAL ARABIC CAF;;;;\nFEDB;ARABIC LETTER KAF INITIAL FORM;Lo;0;AL;<initial> 0643;;;;N;GLYPH FOR INITIAL ARABIC CAF;;;;\nFEDC;ARABIC LETTER KAF MEDIAL FORM;Lo;0;AL;<medial> 0643;;;;N;GLYPH FOR MEDIAL ARABIC CAF;;;;\nFEDD;ARABIC LETTER LAM ISOLATED FORM;Lo;0;AL;<isolated> 0644;;;;N;GLYPH FOR ISOLATE ARABIC LAM;;;;\nFEDE;ARABIC LETTER LAM FINAL FORM;Lo;0;AL;<final> 0644;;;;N;GLYPH FOR FINAL ARABIC LAM;;;;\nFEDF;ARABIC LETTER LAM INITIAL FORM;Lo;0;AL;<initial> 0644;;;;N;GLYPH FOR INITIAL ARABIC LAM;;;;\nFEE0;ARABIC LETTER LAM MEDIAL FORM;Lo;0;AL;<medial> 0644;;;;N;GLYPH FOR MEDIAL ARABIC LAM;;;;\nFEE1;ARABIC LETTER MEEM ISOLATED FORM;Lo;0;AL;<isolated> 0645;;;;N;GLYPH FOR ISOLATE ARABIC MEEM;;;;\nFEE2;ARABIC LETTER MEEM FINAL FORM;Lo;0;AL;<final> 0645;;;;N;GLYPH FOR FINAL ARABIC MEEM;;;;\nFEE3;ARABIC LETTER MEEM INITIAL FORM;Lo;0;AL;<initial> 0645;;;;N;GLYPH FOR INITIAL ARABIC MEEM;;;;\nFEE4;ARABIC LETTER MEEM MEDIAL FORM;Lo;0;AL;<medial> 0645;;;;N;GLYPH FOR MEDIAL ARABIC MEEM;;;;\nFEE5;ARABIC LETTER NOON ISOLATED FORM;Lo;0;AL;<isolated> 0646;;;;N;GLYPH FOR ISOLATE ARABIC NOON;;;;\nFEE6;ARABIC LETTER NOON FINAL FORM;Lo;0;AL;<final> 0646;;;;N;GLYPH FOR FINAL ARABIC NOON;;;;\nFEE7;ARABIC LETTER NOON INITIAL FORM;Lo;0;AL;<initial> 0646;;;;N;GLYPH FOR INITIAL ARABIC NOON;;;;\nFEE8;ARABIC LETTER NOON MEDIAL FORM;Lo;0;AL;<medial> 0646;;;;N;GLYPH FOR MEDIAL ARABIC NOON;;;;\nFEE9;ARABIC LETTER HEH ISOLATED FORM;Lo;0;AL;<isolated> 0647;;;;N;GLYPH FOR ISOLATE ARABIC HA;;;;\nFEEA;ARABIC LETTER HEH FINAL FORM;Lo;0;AL;<final> 0647;;;;N;GLYPH FOR FINAL ARABIC HA;;;;\nFEEB;ARABIC LETTER HEH INITIAL FORM;Lo;0;AL;<initial> 0647;;;;N;GLYPH FOR INITIAL ARABIC HA;;;;\nFEEC;ARABIC LETTER HEH MEDIAL FORM;Lo;0;AL;<medial> 0647;;;;N;GLYPH FOR MEDIAL ARABIC HA;;;;\nFEED;ARABIC LETTER WAW ISOLATED FORM;Lo;0;AL;<isolated> 0648;;;;N;GLYPH FOR ISOLATE ARABIC WAW;;;;\nFEEE;ARABIC LETTER WAW FINAL FORM;Lo;0;AL;<final> 0648;;;;N;GLYPH FOR FINAL ARABIC WAW;;;;\nFEEF;ARABIC LETTER ALEF MAKSURA ISOLATED FORM;Lo;0;AL;<isolated> 0649;;;;N;GLYPH FOR ISOLATE ARABIC ALEF MAQSURAH;;;;\nFEF0;ARABIC LETTER ALEF MAKSURA FINAL FORM;Lo;0;AL;<final> 0649;;;;N;GLYPH FOR FINAL ARABIC ALEF MAQSURAH;;;;\nFEF1;ARABIC LETTER YEH ISOLATED FORM;Lo;0;AL;<isolated> 064A;;;;N;GLYPH FOR ISOLATE ARABIC YA;;;;\nFEF2;ARABIC LETTER YEH FINAL FORM;Lo;0;AL;<final> 064A;;;;N;GLYPH FOR FINAL ARABIC YA;;;;\nFEF3;ARABIC LETTER YEH INITIAL FORM;Lo;0;AL;<initial> 064A;;;;N;GLYPH FOR INITIAL ARABIC YA;;;;\nFEF4;ARABIC LETTER YEH MEDIAL FORM;Lo;0;AL;<medial> 064A;;;;N;GLYPH FOR MEDIAL ARABIC YA;;;;\nFEF5;ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0644 0622;;;;N;GLYPH FOR ISOLATE ARABIC MADDAH ON LIGATURE LAM ALEF;;;;\nFEF6;ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM;Lo;0;AL;<final> 0644 0622;;;;N;GLYPH FOR FINAL ARABIC MADDAH ON LIGATURE LAM ALEF;;;;\nFEF7;ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM;Lo;0;AL;<isolated> 0644 0623;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH ON LIGATURE LAM ALEF;;;;\nFEF8;ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM;Lo;0;AL;<final> 0644 0623;;;;N;GLYPH FOR FINAL ARABIC HAMZAH ON LIGATURE LAM ALEF;;;;\nFEF9;ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM;Lo;0;AL;<isolated> 0644 0625;;;;N;GLYPH FOR ISOLATE ARABIC HAMZAH UNDER LIGATURE LAM ALEF;;;;\nFEFA;ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM;Lo;0;AL;<final> 0644 0625;;;;N;GLYPH FOR FINAL ARABIC HAMZAH UNDER LIGATURE LAM ALEF;;;;\nFEFB;ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM;Lo;0;AL;<isolated> 0644 0627;;;;N;GLYPH FOR ISOLATE ARABIC LIGATURE LAM ALEF;;;;\nFEFC;ARABIC LIGATURE LAM WITH ALEF FINAL FORM;Lo;0;AL;<final> 0644 0627;;;;N;GLYPH FOR FINAL ARABIC LIGATURE LAM ALEF;;;;\nFEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;;\nFF01;FULLWIDTH EXCLAMATION MARK;Po;0;ON;<wide> 0021;;;;N;;;;;\nFF02;FULLWIDTH QUOTATION MARK;Po;0;ON;<wide> 0022;;;;N;;;;;\nFF03;FULLWIDTH NUMBER SIGN;Po;0;ET;<wide> 0023;;;;N;;;;;\nFF04;FULLWIDTH DOLLAR SIGN;Sc;0;ET;<wide> 0024;;;;N;;;;;\nFF05;FULLWIDTH PERCENT SIGN;Po;0;ET;<wide> 0025;;;;N;;;;;\nFF06;FULLWIDTH AMPERSAND;Po;0;ON;<wide> 0026;;;;N;;;;;\nFF07;FULLWIDTH APOSTROPHE;Po;0;ON;<wide> 0027;;;;N;;;;;\nFF08;FULLWIDTH LEFT PARENTHESIS;Ps;0;ON;<wide> 0028;;;;Y;FULLWIDTH OPENING PARENTHESIS;;;;\nFF09;FULLWIDTH RIGHT PARENTHESIS;Pe;0;ON;<wide> 0029;;;;Y;FULLWIDTH CLOSING PARENTHESIS;;;;\nFF0A;FULLWIDTH ASTERISK;Po;0;ON;<wide> 002A;;;;N;;;;;\nFF0B;FULLWIDTH PLUS SIGN;Sm;0;ES;<wide> 002B;;;;N;;;;;\nFF0C;FULLWIDTH COMMA;Po;0;CS;<wide> 002C;;;;N;;;;;\nFF0D;FULLWIDTH HYPHEN-MINUS;Pd;0;ES;<wide> 002D;;;;N;;;;;\nFF0E;FULLWIDTH FULL STOP;Po;0;CS;<wide> 002E;;;;N;FULLWIDTH PERIOD;;;;\nFF0F;FULLWIDTH SOLIDUS;Po;0;CS;<wide> 002F;;;;N;FULLWIDTH SLASH;;;;\nFF10;FULLWIDTH DIGIT ZERO;Nd;0;EN;<wide> 0030;0;0;0;N;;;;;\nFF11;FULLWIDTH DIGIT ONE;Nd;0;EN;<wide> 0031;1;1;1;N;;;;;\nFF12;FULLWIDTH DIGIT TWO;Nd;0;EN;<wide> 0032;2;2;2;N;;;;;\nFF13;FULLWIDTH DIGIT THREE;Nd;0;EN;<wide> 0033;3;3;3;N;;;;;\nFF14;FULLWIDTH DIGIT FOUR;Nd;0;EN;<wide> 0034;4;4;4;N;;;;;\nFF15;FULLWIDTH DIGIT FIVE;Nd;0;EN;<wide> 0035;5;5;5;N;;;;;\nFF16;FULLWIDTH DIGIT SIX;Nd;0;EN;<wide> 0036;6;6;6;N;;;;;\nFF17;FULLWIDTH DIGIT SEVEN;Nd;0;EN;<wide> 0037;7;7;7;N;;;;;\nFF18;FULLWIDTH DIGIT EIGHT;Nd;0;EN;<wide> 0038;8;8;8;N;;;;;\nFF19;FULLWIDTH DIGIT NINE;Nd;0;EN;<wide> 0039;9;9;9;N;;;;;\nFF1A;FULLWIDTH COLON;Po;0;CS;<wide> 003A;;;;N;;;;;\nFF1B;FULLWIDTH SEMICOLON;Po;0;ON;<wide> 003B;;;;N;;;;;\nFF1C;FULLWIDTH LESS-THAN SIGN;Sm;0;ON;<wide> 003C;;;;Y;;;;;\nFF1D;FULLWIDTH EQUALS SIGN;Sm;0;ON;<wide> 003D;;;;N;;;;;\nFF1E;FULLWIDTH GREATER-THAN SIGN;Sm;0;ON;<wide> 003E;;;;Y;;;;;\nFF1F;FULLWIDTH QUESTION MARK;Po;0;ON;<wide> 003F;;;;N;;;;;\nFF20;FULLWIDTH COMMERCIAL AT;Po;0;ON;<wide> 0040;;;;N;;;;;\nFF21;FULLWIDTH LATIN CAPITAL LETTER A;Lu;0;L;<wide> 0041;;;;N;;;;FF41;\nFF22;FULLWIDTH LATIN CAPITAL LETTER B;Lu;0;L;<wide> 0042;;;;N;;;;FF42;\nFF23;FULLWIDTH LATIN CAPITAL LETTER C;Lu;0;L;<wide> 0043;;;;N;;;;FF43;\nFF24;FULLWIDTH LATIN CAPITAL LETTER D;Lu;0;L;<wide> 0044;;;;N;;;;FF44;\nFF25;FULLWIDTH LATIN CAPITAL LETTER E;Lu;0;L;<wide> 0045;;;;N;;;;FF45;\nFF26;FULLWIDTH LATIN CAPITAL LETTER F;Lu;0;L;<wide> 0046;;;;N;;;;FF46;\nFF27;FULLWIDTH LATIN CAPITAL LETTER G;Lu;0;L;<wide> 0047;;;;N;;;;FF47;\nFF28;FULLWIDTH LATIN CAPITAL LETTER H;Lu;0;L;<wide> 0048;;;;N;;;;FF48;\nFF29;FULLWIDTH LATIN CAPITAL LETTER I;Lu;0;L;<wide> 0049;;;;N;;;;FF49;\nFF2A;FULLWIDTH LATIN CAPITAL LETTER J;Lu;0;L;<wide> 004A;;;;N;;;;FF4A;\nFF2B;FULLWIDTH LATIN CAPITAL LETTER K;Lu;0;L;<wide> 004B;;;;N;;;;FF4B;\nFF2C;FULLWIDTH LATIN CAPITAL LETTER L;Lu;0;L;<wide> 004C;;;;N;;;;FF4C;\nFF2D;FULLWIDTH LATIN CAPITAL LETTER M;Lu;0;L;<wide> 004D;;;;N;;;;FF4D;\nFF2E;FULLWIDTH LATIN CAPITAL LETTER N;Lu;0;L;<wide> 004E;;;;N;;;;FF4E;\nFF2F;FULLWIDTH LATIN CAPITAL LETTER O;Lu;0;L;<wide> 004F;;;;N;;;;FF4F;\nFF30;FULLWIDTH LATIN CAPITAL LETTER P;Lu;0;L;<wide> 0050;;;;N;;;;FF50;\nFF31;FULLWIDTH LATIN CAPITAL LETTER Q;Lu;0;L;<wide> 0051;;;;N;;;;FF51;\nFF32;FULLWIDTH LATIN CAPITAL LETTER R;Lu;0;L;<wide> 0052;;;;N;;;;FF52;\nFF33;FULLWIDTH LATIN CAPITAL LETTER S;Lu;0;L;<wide> 0053;;;;N;;;;FF53;\nFF34;FULLWIDTH LATIN CAPITAL LETTER T;Lu;0;L;<wide> 0054;;;;N;;;;FF54;\nFF35;FULLWIDTH LATIN CAPITAL LETTER U;Lu;0;L;<wide> 0055;;;;N;;;;FF55;\nFF36;FULLWIDTH LATIN CAPITAL LETTER V;Lu;0;L;<wide> 0056;;;;N;;;;FF56;\nFF37;FULLWIDTH LATIN CAPITAL LETTER W;Lu;0;L;<wide> 0057;;;;N;;;;FF57;\nFF38;FULLWIDTH LATIN CAPITAL LETTER X;Lu;0;L;<wide> 0058;;;;N;;;;FF58;\nFF39;FULLWIDTH LATIN CAPITAL LETTER Y;Lu;0;L;<wide> 0059;;;;N;;;;FF59;\nFF3A;FULLWIDTH LATIN CAPITAL LETTER Z;Lu;0;L;<wide> 005A;;;;N;;;;FF5A;\nFF3B;FULLWIDTH LEFT SQUARE BRACKET;Ps;0;ON;<wide> 005B;;;;Y;FULLWIDTH OPENING SQUARE BRACKET;;;;\nFF3C;FULLWIDTH REVERSE SOLIDUS;Po;0;ON;<wide> 005C;;;;N;FULLWIDTH BACKSLASH;;;;\nFF3D;FULLWIDTH RIGHT SQUARE BRACKET;Pe;0;ON;<wide> 005D;;;;Y;FULLWIDTH CLOSING SQUARE BRACKET;;;;\nFF3E;FULLWIDTH CIRCUMFLEX ACCENT;Sk;0;ON;<wide> 005E;;;;N;FULLWIDTH SPACING CIRCUMFLEX;;;;\nFF3F;FULLWIDTH LOW LINE;Pc;0;ON;<wide> 005F;;;;N;FULLWIDTH SPACING UNDERSCORE;;;;\nFF40;FULLWIDTH GRAVE ACCENT;Sk;0;ON;<wide> 0060;;;;N;FULLWIDTH SPACING GRAVE;;;;\nFF41;FULLWIDTH LATIN SMALL LETTER A;Ll;0;L;<wide> 0061;;;;N;;;FF21;;FF21\nFF42;FULLWIDTH LATIN SMALL LETTER B;Ll;0;L;<wide> 0062;;;;N;;;FF22;;FF22\nFF43;FULLWIDTH LATIN SMALL LETTER C;Ll;0;L;<wide> 0063;;;;N;;;FF23;;FF23\nFF44;FULLWIDTH LATIN SMALL LETTER D;Ll;0;L;<wide> 0064;;;;N;;;FF24;;FF24\nFF45;FULLWIDTH LATIN SMALL LETTER E;Ll;0;L;<wide> 0065;;;;N;;;FF25;;FF25\nFF46;FULLWIDTH LATIN SMALL LETTER F;Ll;0;L;<wide> 0066;;;;N;;;FF26;;FF26\nFF47;FULLWIDTH LATIN SMALL LETTER G;Ll;0;L;<wide> 0067;;;;N;;;FF27;;FF27\nFF48;FULLWIDTH LATIN SMALL LETTER H;Ll;0;L;<wide> 0068;;;;N;;;FF28;;FF28\nFF49;FULLWIDTH LATIN SMALL LETTER I;Ll;0;L;<wide> 0069;;;;N;;;FF29;;FF29\nFF4A;FULLWIDTH LATIN SMALL LETTER J;Ll;0;L;<wide> 006A;;;;N;;;FF2A;;FF2A\nFF4B;FULLWIDTH LATIN SMALL LETTER K;Ll;0;L;<wide> 006B;;;;N;;;FF2B;;FF2B\nFF4C;FULLWIDTH LATIN SMALL LETTER L;Ll;0;L;<wide> 006C;;;;N;;;FF2C;;FF2C\nFF4D;FULLWIDTH LATIN SMALL LETTER M;Ll;0;L;<wide> 006D;;;;N;;;FF2D;;FF2D\nFF4E;FULLWIDTH LATIN SMALL LETTER N;Ll;0;L;<wide> 006E;;;;N;;;FF2E;;FF2E\nFF4F;FULLWIDTH LATIN SMALL LETTER O;Ll;0;L;<wide> 006F;;;;N;;;FF2F;;FF2F\nFF50;FULLWIDTH LATIN SMALL LETTER P;Ll;0;L;<wide> 0070;;;;N;;;FF30;;FF30\nFF51;FULLWIDTH LATIN SMALL LETTER Q;Ll;0;L;<wide> 0071;;;;N;;;FF31;;FF31\nFF52;FULLWIDTH LATIN SMALL LETTER R;Ll;0;L;<wide> 0072;;;;N;;;FF32;;FF32\nFF53;FULLWIDTH LATIN SMALL LETTER S;Ll;0;L;<wide> 0073;;;;N;;;FF33;;FF33\nFF54;FULLWIDTH LATIN SMALL LETTER T;Ll;0;L;<wide> 0074;;;;N;;;FF34;;FF34\nFF55;FULLWIDTH LATIN SMALL LETTER U;Ll;0;L;<wide> 0075;;;;N;;;FF35;;FF35\nFF56;FULLWIDTH LATIN SMALL LETTER V;Ll;0;L;<wide> 0076;;;;N;;;FF36;;FF36\nFF57;FULLWIDTH LATIN SMALL LETTER W;Ll;0;L;<wide> 0077;;;;N;;;FF37;;FF37\nFF58;FULLWIDTH LATIN SMALL LETTER X;Ll;0;L;<wide> 0078;;;;N;;;FF38;;FF38\nFF59;FULLWIDTH LATIN SMALL LETTER Y;Ll;0;L;<wide> 0079;;;;N;;;FF39;;FF39\nFF5A;FULLWIDTH LATIN SMALL LETTER Z;Ll;0;L;<wide> 007A;;;;N;;;FF3A;;FF3A\nFF5B;FULLWIDTH LEFT CURLY BRACKET;Ps;0;ON;<wide> 007B;;;;Y;FULLWIDTH OPENING CURLY BRACKET;;;;\nFF5C;FULLWIDTH VERTICAL LINE;Sm;0;ON;<wide> 007C;;;;N;FULLWIDTH VERTICAL BAR;;;;\nFF5D;FULLWIDTH RIGHT CURLY BRACKET;Pe;0;ON;<wide> 007D;;;;Y;FULLWIDTH CLOSING CURLY BRACKET;;;;\nFF5E;FULLWIDTH TILDE;Sm;0;ON;<wide> 007E;;;;N;FULLWIDTH SPACING TILDE;;;;\nFF5F;FULLWIDTH LEFT WHITE PARENTHESIS;Ps;0;ON;<wide> 2985;;;;Y;;;;;\nFF60;FULLWIDTH RIGHT WHITE PARENTHESIS;Pe;0;ON;<wide> 2986;;;;Y;;;;;\nFF61;HALFWIDTH IDEOGRAPHIC FULL STOP;Po;0;ON;<narrow> 3002;;;;N;HALFWIDTH IDEOGRAPHIC PERIOD;;;;\nFF62;HALFWIDTH LEFT CORNER BRACKET;Ps;0;ON;<narrow> 300C;;;;Y;HALFWIDTH OPENING CORNER BRACKET;;;;\nFF63;HALFWIDTH RIGHT CORNER BRACKET;Pe;0;ON;<narrow> 300D;;;;Y;HALFWIDTH CLOSING CORNER BRACKET;;;;\nFF64;HALFWIDTH IDEOGRAPHIC COMMA;Po;0;ON;<narrow> 3001;;;;N;;;;;\nFF65;HALFWIDTH KATAKANA MIDDLE DOT;Po;0;ON;<narrow> 30FB;;;;N;;;;;\nFF66;HALFWIDTH KATAKANA LETTER WO;Lo;0;L;<narrow> 30F2;;;;N;;;;;\nFF67;HALFWIDTH KATAKANA LETTER SMALL A;Lo;0;L;<narrow> 30A1;;;;N;;;;;\nFF68;HALFWIDTH KATAKANA LETTER SMALL I;Lo;0;L;<narrow> 30A3;;;;N;;;;;\nFF69;HALFWIDTH KATAKANA LETTER SMALL U;Lo;0;L;<narrow> 30A5;;;;N;;;;;\nFF6A;HALFWIDTH KATAKANA LETTER SMALL E;Lo;0;L;<narrow> 30A7;;;;N;;;;;\nFF6B;HALFWIDTH KATAKANA LETTER SMALL O;Lo;0;L;<narrow> 30A9;;;;N;;;;;\nFF6C;HALFWIDTH KATAKANA LETTER SMALL YA;Lo;0;L;<narrow> 30E3;;;;N;;;;;\nFF6D;HALFWIDTH KATAKANA LETTER SMALL YU;Lo;0;L;<narrow> 30E5;;;;N;;;;;\nFF6E;HALFWIDTH KATAKANA LETTER SMALL YO;Lo;0;L;<narrow> 30E7;;;;N;;;;;\nFF6F;HALFWIDTH KATAKANA LETTER SMALL TU;Lo;0;L;<narrow> 30C3;;;;N;;;;;\nFF70;HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK;Lm;0;L;<narrow> 30FC;;;;N;;;;;\nFF71;HALFWIDTH KATAKANA LETTER A;Lo;0;L;<narrow> 30A2;;;;N;;;;;\nFF72;HALFWIDTH KATAKANA LETTER I;Lo;0;L;<narrow> 30A4;;;;N;;;;;\nFF73;HALFWIDTH KATAKANA LETTER U;Lo;0;L;<narrow> 30A6;;;;N;;;;;\nFF74;HALFWIDTH KATAKANA LETTER E;Lo;0;L;<narrow> 30A8;;;;N;;;;;\nFF75;HALFWIDTH KATAKANA LETTER O;Lo;0;L;<narrow> 30AA;;;;N;;;;;\nFF76;HALFWIDTH KATAKANA LETTER KA;Lo;0;L;<narrow> 30AB;;;;N;;;;;\nFF77;HALFWIDTH KATAKANA LETTER KI;Lo;0;L;<narrow> 30AD;;;;N;;;;;\nFF78;HALFWIDTH KATAKANA LETTER KU;Lo;0;L;<narrow> 30AF;;;;N;;;;;\nFF79;HALFWIDTH KATAKANA LETTER KE;Lo;0;L;<narrow> 30B1;;;;N;;;;;\nFF7A;HALFWIDTH KATAKANA LETTER KO;Lo;0;L;<narrow> 30B3;;;;N;;;;;\nFF7B;HALFWIDTH KATAKANA LETTER SA;Lo;0;L;<narrow> 30B5;;;;N;;;;;\nFF7C;HALFWIDTH KATAKANA LETTER SI;Lo;0;L;<narrow> 30B7;;;;N;;;;;\nFF7D;HALFWIDTH KATAKANA LETTER SU;Lo;0;L;<narrow> 30B9;;;;N;;;;;\nFF7E;HALFWIDTH KATAKANA LETTER SE;Lo;0;L;<narrow> 30BB;;;;N;;;;;\nFF7F;HALFWIDTH KATAKANA LETTER SO;Lo;0;L;<narrow> 30BD;;;;N;;;;;\nFF80;HALFWIDTH KATAKANA LETTER TA;Lo;0;L;<narrow> 30BF;;;;N;;;;;\nFF81;HALFWIDTH KATAKANA LETTER TI;Lo;0;L;<narrow> 30C1;;;;N;;;;;\nFF82;HALFWIDTH KATAKANA LETTER TU;Lo;0;L;<narrow> 30C4;;;;N;;;;;\nFF83;HALFWIDTH KATAKANA LETTER TE;Lo;0;L;<narrow> 30C6;;;;N;;;;;\nFF84;HALFWIDTH KATAKANA LETTER TO;Lo;0;L;<narrow> 30C8;;;;N;;;;;\nFF85;HALFWIDTH KATAKANA LETTER NA;Lo;0;L;<narrow> 30CA;;;;N;;;;;\nFF86;HALFWIDTH KATAKANA LETTER NI;Lo;0;L;<narrow> 30CB;;;;N;;;;;\nFF87;HALFWIDTH KATAKANA LETTER NU;Lo;0;L;<narrow> 30CC;;;;N;;;;;\nFF88;HALFWIDTH KATAKANA LETTER NE;Lo;0;L;<narrow> 30CD;;;;N;;;;;\nFF89;HALFWIDTH KATAKANA LETTER NO;Lo;0;L;<narrow> 30CE;;;;N;;;;;\nFF8A;HALFWIDTH KATAKANA LETTER HA;Lo;0;L;<narrow> 30CF;;;;N;;;;;\nFF8B;HALFWIDTH KATAKANA LETTER HI;Lo;0;L;<narrow> 30D2;;;;N;;;;;\nFF8C;HALFWIDTH KATAKANA LETTER HU;Lo;0;L;<narrow> 30D5;;;;N;;;;;\nFF8D;HALFWIDTH KATAKANA LETTER HE;Lo;0;L;<narrow> 30D8;;;;N;;;;;\nFF8E;HALFWIDTH KATAKANA LETTER HO;Lo;0;L;<narrow> 30DB;;;;N;;;;;\nFF8F;HALFWIDTH KATAKANA LETTER MA;Lo;0;L;<narrow> 30DE;;;;N;;;;;\nFF90;HALFWIDTH KATAKANA LETTER MI;Lo;0;L;<narrow> 30DF;;;;N;;;;;\nFF91;HALFWIDTH KATAKANA LETTER MU;Lo;0;L;<narrow> 30E0;;;;N;;;;;\nFF92;HALFWIDTH KATAKANA LETTER ME;Lo;0;L;<narrow> 30E1;;;;N;;;;;\nFF93;HALFWIDTH KATAKANA LETTER MO;Lo;0;L;<narrow> 30E2;;;;N;;;;;\nFF94;HALFWIDTH KATAKANA LETTER YA;Lo;0;L;<narrow> 30E4;;;;N;;;;;\nFF95;HALFWIDTH KATAKANA LETTER YU;Lo;0;L;<narrow> 30E6;;;;N;;;;;\nFF96;HALFWIDTH KATAKANA LETTER YO;Lo;0;L;<narrow> 30E8;;;;N;;;;;\nFF97;HALFWIDTH KATAKANA LETTER RA;Lo;0;L;<narrow> 30E9;;;;N;;;;;\nFF98;HALFWIDTH KATAKANA LETTER RI;Lo;0;L;<narrow> 30EA;;;;N;;;;;\nFF99;HALFWIDTH KATAKANA LETTER RU;Lo;0;L;<narrow> 30EB;;;;N;;;;;\nFF9A;HALFWIDTH KATAKANA LETTER RE;Lo;0;L;<narrow> 30EC;;;;N;;;;;\nFF9B;HALFWIDTH KATAKANA LETTER RO;Lo;0;L;<narrow> 30ED;;;;N;;;;;\nFF9C;HALFWIDTH KATAKANA LETTER WA;Lo;0;L;<narrow> 30EF;;;;N;;;;;\nFF9D;HALFWIDTH KATAKANA LETTER N;Lo;0;L;<narrow> 30F3;;;;N;;;;;\nFF9E;HALFWIDTH KATAKANA VOICED SOUND MARK;Lm;0;L;<narrow> 3099;;;;N;;;;;\nFF9F;HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK;Lm;0;L;<narrow> 309A;;;;N;;;;;\nFFA0;HALFWIDTH HANGUL FILLER;Lo;0;L;<narrow> 3164;;;;N;HALFWIDTH HANGUL CAE OM;;;;\nFFA1;HALFWIDTH HANGUL LETTER KIYEOK;Lo;0;L;<narrow> 3131;;;;N;HALFWIDTH HANGUL LETTER GIYEOG;;;;\nFFA2;HALFWIDTH HANGUL LETTER SSANGKIYEOK;Lo;0;L;<narrow> 3132;;;;N;HALFWIDTH HANGUL LETTER SSANG GIYEOG;;;;\nFFA3;HALFWIDTH HANGUL LETTER KIYEOK-SIOS;Lo;0;L;<narrow> 3133;;;;N;HALFWIDTH HANGUL LETTER GIYEOG SIOS;;;;\nFFA4;HALFWIDTH HANGUL LETTER NIEUN;Lo;0;L;<narrow> 3134;;;;N;;;;;\nFFA5;HALFWIDTH HANGUL LETTER NIEUN-CIEUC;Lo;0;L;<narrow> 3135;;;;N;HALFWIDTH HANGUL LETTER NIEUN JIEUJ;;;;\nFFA6;HALFWIDTH HANGUL LETTER NIEUN-HIEUH;Lo;0;L;<narrow> 3136;;;;N;HALFWIDTH HANGUL LETTER NIEUN HIEUH;;;;\nFFA7;HALFWIDTH HANGUL LETTER TIKEUT;Lo;0;L;<narrow> 3137;;;;N;HALFWIDTH HANGUL LETTER DIGEUD;;;;\nFFA8;HALFWIDTH HANGUL LETTER SSANGTIKEUT;Lo;0;L;<narrow> 3138;;;;N;HALFWIDTH HANGUL LETTER SSANG DIGEUD;;;;\nFFA9;HALFWIDTH HANGUL LETTER RIEUL;Lo;0;L;<narrow> 3139;;;;N;HALFWIDTH HANGUL LETTER LIEUL;;;;\nFFAA;HALFWIDTH HANGUL LETTER RIEUL-KIYEOK;Lo;0;L;<narrow> 313A;;;;N;HALFWIDTH HANGUL LETTER LIEUL GIYEOG;;;;\nFFAB;HALFWIDTH HANGUL LETTER RIEUL-MIEUM;Lo;0;L;<narrow> 313B;;;;N;HALFWIDTH HANGUL LETTER LIEUL MIEUM;;;;\nFFAC;HALFWIDTH HANGUL LETTER RIEUL-PIEUP;Lo;0;L;<narrow> 313C;;;;N;HALFWIDTH HANGUL LETTER LIEUL BIEUB;;;;\nFFAD;HALFWIDTH HANGUL LETTER RIEUL-SIOS;Lo;0;L;<narrow> 313D;;;;N;HALFWIDTH HANGUL LETTER LIEUL SIOS;;;;\nFFAE;HALFWIDTH HANGUL LETTER RIEUL-THIEUTH;Lo;0;L;<narrow> 313E;;;;N;HALFWIDTH HANGUL LETTER LIEUL TIEUT;;;;\nFFAF;HALFWIDTH HANGUL LETTER RIEUL-PHIEUPH;Lo;0;L;<narrow> 313F;;;;N;HALFWIDTH HANGUL LETTER LIEUL PIEUP;;;;\nFFB0;HALFWIDTH HANGUL LETTER RIEUL-HIEUH;Lo;0;L;<narrow> 3140;;;;N;HALFWIDTH HANGUL LETTER LIEUL HIEUH;;;;\nFFB1;HALFWIDTH HANGUL LETTER MIEUM;Lo;0;L;<narrow> 3141;;;;N;;;;;\nFFB2;HALFWIDTH HANGUL LETTER PIEUP;Lo;0;L;<narrow> 3142;;;;N;HALFWIDTH HANGUL LETTER BIEUB;;;;\nFFB3;HALFWIDTH HANGUL LETTER SSANGPIEUP;Lo;0;L;<narrow> 3143;;;;N;HALFWIDTH HANGUL LETTER SSANG BIEUB;;;;\nFFB4;HALFWIDTH HANGUL LETTER PIEUP-SIOS;Lo;0;L;<narrow> 3144;;;;N;HALFWIDTH HANGUL LETTER BIEUB SIOS;;;;\nFFB5;HALFWIDTH HANGUL LETTER SIOS;Lo;0;L;<narrow> 3145;;;;N;;;;;\nFFB6;HALFWIDTH HANGUL LETTER SSANGSIOS;Lo;0;L;<narrow> 3146;;;;N;HALFWIDTH HANGUL LETTER SSANG SIOS;;;;\nFFB7;HALFWIDTH HANGUL LETTER IEUNG;Lo;0;L;<narrow> 3147;;;;N;;;;;\nFFB8;HALFWIDTH HANGUL LETTER CIEUC;Lo;0;L;<narrow> 3148;;;;N;HALFWIDTH HANGUL LETTER JIEUJ;;;;\nFFB9;HALFWIDTH HANGUL LETTER SSANGCIEUC;Lo;0;L;<narrow> 3149;;;;N;HALFWIDTH HANGUL LETTER SSANG JIEUJ;;;;\nFFBA;HALFWIDTH HANGUL LETTER CHIEUCH;Lo;0;L;<narrow> 314A;;;;N;HALFWIDTH HANGUL LETTER CIEUC;;;;\nFFBB;HALFWIDTH HANGUL LETTER KHIEUKH;Lo;0;L;<narrow> 314B;;;;N;HALFWIDTH HANGUL LETTER KIYEOK;;;;\nFFBC;HALFWIDTH HANGUL LETTER THIEUTH;Lo;0;L;<narrow> 314C;;;;N;HALFWIDTH HANGUL LETTER TIEUT;;;;\nFFBD;HALFWIDTH HANGUL LETTER PHIEUPH;Lo;0;L;<narrow> 314D;;;;N;HALFWIDTH HANGUL LETTER PIEUP;;;;\nFFBE;HALFWIDTH HANGUL LETTER HIEUH;Lo;0;L;<narrow> 314E;;;;N;;;;;\nFFC2;HALFWIDTH HANGUL LETTER A;Lo;0;L;<narrow> 314F;;;;N;;;;;\nFFC3;HALFWIDTH HANGUL LETTER AE;Lo;0;L;<narrow> 3150;;;;N;;;;;\nFFC4;HALFWIDTH HANGUL LETTER YA;Lo;0;L;<narrow> 3151;;;;N;;;;;\nFFC5;HALFWIDTH HANGUL LETTER YAE;Lo;0;L;<narrow> 3152;;;;N;;;;;\nFFC6;HALFWIDTH HANGUL LETTER EO;Lo;0;L;<narrow> 3153;;;;N;;;;;\nFFC7;HALFWIDTH HANGUL LETTER E;Lo;0;L;<narrow> 3154;;;;N;;;;;\nFFCA;HALFWIDTH HANGUL LETTER YEO;Lo;0;L;<narrow> 3155;;;;N;;;;;\nFFCB;HALFWIDTH HANGUL LETTER YE;Lo;0;L;<narrow> 3156;;;;N;;;;;\nFFCC;HALFWIDTH HANGUL LETTER O;Lo;0;L;<narrow> 3157;;;;N;;;;;\nFFCD;HALFWIDTH HANGUL LETTER WA;Lo;0;L;<narrow> 3158;;;;N;;;;;\nFFCE;HALFWIDTH HANGUL LETTER WAE;Lo;0;L;<narrow> 3159;;;;N;;;;;\nFFCF;HALFWIDTH HANGUL LETTER OE;Lo;0;L;<narrow> 315A;;;;N;;;;;\nFFD2;HALFWIDTH HANGUL LETTER YO;Lo;0;L;<narrow> 315B;;;;N;;;;;\nFFD3;HALFWIDTH HANGUL LETTER U;Lo;0;L;<narrow> 315C;;;;N;;;;;\nFFD4;HALFWIDTH HANGUL LETTER WEO;Lo;0;L;<narrow> 315D;;;;N;;;;;\nFFD5;HALFWIDTH HANGUL LETTER WE;Lo;0;L;<narrow> 315E;;;;N;;;;;\nFFD6;HALFWIDTH HANGUL LETTER WI;Lo;0;L;<narrow> 315F;;;;N;;;;;\nFFD7;HALFWIDTH HANGUL LETTER YU;Lo;0;L;<narrow> 3160;;;;N;;;;;\nFFDA;HALFWIDTH HANGUL LETTER EU;Lo;0;L;<narrow> 3161;;;;N;;;;;\nFFDB;HALFWIDTH HANGUL LETTER YI;Lo;0;L;<narrow> 3162;;;;N;;;;;\nFFDC;HALFWIDTH HANGUL LETTER I;Lo;0;L;<narrow> 3163;;;;N;;;;;\nFFE0;FULLWIDTH CENT SIGN;Sc;0;ET;<wide> 00A2;;;;N;;;;;\nFFE1;FULLWIDTH POUND SIGN;Sc;0;ET;<wide> 00A3;;;;N;;;;;\nFFE2;FULLWIDTH NOT SIGN;Sm;0;ON;<wide> 00AC;;;;N;;;;;\nFFE3;FULLWIDTH MACRON;Sk;0;ON;<wide> 00AF;;;;N;FULLWIDTH SPACING MACRON;;;;\nFFE4;FULLWIDTH BROKEN BAR;So;0;ON;<wide> 00A6;;;;N;FULLWIDTH BROKEN VERTICAL BAR;;;;\nFFE5;FULLWIDTH YEN SIGN;Sc;0;ET;<wide> 00A5;;;;N;;;;;\nFFE6;FULLWIDTH WON SIGN;Sc;0;ET;<wide> 20A9;;;;N;;;;;\nFFE8;HALFWIDTH FORMS LIGHT VERTICAL;So;0;ON;<narrow> 2502;;;;N;;;;;\nFFE9;HALFWIDTH LEFTWARDS ARROW;Sm;0;ON;<narrow> 2190;;;;N;;;;;\nFFEA;HALFWIDTH UPWARDS ARROW;Sm;0;ON;<narrow> 2191;;;;N;;;;;\nFFEB;HALFWIDTH RIGHTWARDS ARROW;Sm;0;ON;<narrow> 2192;;;;N;;;;;\nFFEC;HALFWIDTH DOWNWARDS ARROW;Sm;0;ON;<narrow> 2193;;;;N;;;;;\nFFED;HALFWIDTH BLACK SQUARE;So;0;ON;<narrow> 25A0;;;;N;;;;;\nFFEE;HALFWIDTH WHITE CIRCLE;So;0;ON;<narrow> 25CB;;;;N;;;;;\nFFF9;INTERLINEAR ANNOTATION ANCHOR;Cf;0;ON;;;;;N;;;;;\nFFFA;INTERLINEAR ANNOTATION SEPARATOR;Cf;0;ON;;;;;N;;;;;\nFFFB;INTERLINEAR ANNOTATION TERMINATOR;Cf;0;ON;;;;;N;;;;;\nFFFC;OBJECT REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;\nFFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;\n10000;LINEAR B SYLLABLE B008 A;Lo;0;L;;;;;N;;;;;\n10001;LINEAR B SYLLABLE B038 E;Lo;0;L;;;;;N;;;;;\n10002;LINEAR B SYLLABLE B028 I;Lo;0;L;;;;;N;;;;;\n10003;LINEAR B SYLLABLE B061 O;Lo;0;L;;;;;N;;;;;\n10004;LINEAR B SYLLABLE B010 U;Lo;0;L;;;;;N;;;;;\n10005;LINEAR B SYLLABLE B001 DA;Lo;0;L;;;;;N;;;;;\n10006;LINEAR B SYLLABLE B045 DE;Lo;0;L;;;;;N;;;;;\n10007;LINEAR B SYLLABLE B007 DI;Lo;0;L;;;;;N;;;;;\n10008;LINEAR B SYLLABLE B014 DO;Lo;0;L;;;;;N;;;;;\n10009;LINEAR B SYLLABLE B051 DU;Lo;0;L;;;;;N;;;;;\n1000A;LINEAR B SYLLABLE B057 JA;Lo;0;L;;;;;N;;;;;\n1000B;LINEAR B SYLLABLE B046 JE;Lo;0;L;;;;;N;;;;;\n1000D;LINEAR B SYLLABLE B036 JO;Lo;0;L;;;;;N;;;;;\n1000E;LINEAR B SYLLABLE B065 JU;Lo;0;L;;;;;N;;;;;\n1000F;LINEAR B SYLLABLE B077 KA;Lo;0;L;;;;;N;;;;;\n10010;LINEAR B SYLLABLE B044 KE;Lo;0;L;;;;;N;;;;;\n10011;LINEAR B SYLLABLE B067 KI;Lo;0;L;;;;;N;;;;;\n10012;LINEAR B SYLLABLE B070 KO;Lo;0;L;;;;;N;;;;;\n10013;LINEAR B SYLLABLE B081 KU;Lo;0;L;;;;;N;;;;;\n10014;LINEAR B SYLLABLE B080 MA;Lo;0;L;;;;;N;;;;;\n10015;LINEAR B SYLLABLE B013 ME;Lo;0;L;;;;;N;;;;;\n10016;LINEAR B SYLLABLE B073 MI;Lo;0;L;;;;;N;;;;;\n10017;LINEAR B SYLLABLE B015 MO;Lo;0;L;;;;;N;;;;;\n10018;LINEAR B SYLLABLE B023 MU;Lo;0;L;;;;;N;;;;;\n10019;LINEAR B SYLLABLE B006 NA;Lo;0;L;;;;;N;;;;;\n1001A;LINEAR B SYLLABLE B024 NE;Lo;0;L;;;;;N;;;;;\n1001B;LINEAR B SYLLABLE B030 NI;Lo;0;L;;;;;N;;;;;\n1001C;LINEAR B SYLLABLE B052 NO;Lo;0;L;;;;;N;;;;;\n1001D;LINEAR B SYLLABLE B055 NU;Lo;0;L;;;;;N;;;;;\n1001E;LINEAR B SYLLABLE B003 PA;Lo;0;L;;;;;N;;;;;\n1001F;LINEAR B SYLLABLE B072 PE;Lo;0;L;;;;;N;;;;;\n10020;LINEAR B SYLLABLE B039 PI;Lo;0;L;;;;;N;;;;;\n10021;LINEAR B SYLLABLE B011 PO;Lo;0;L;;;;;N;;;;;\n10022;LINEAR B SYLLABLE B050 PU;Lo;0;L;;;;;N;;;;;\n10023;LINEAR B SYLLABLE B016 QA;Lo;0;L;;;;;N;;;;;\n10024;LINEAR B SYLLABLE B078 QE;Lo;0;L;;;;;N;;;;;\n10025;LINEAR B SYLLABLE B021 QI;Lo;0;L;;;;;N;;;;;\n10026;LINEAR B SYLLABLE B032 QO;Lo;0;L;;;;;N;;;;;\n10028;LINEAR B SYLLABLE B060 RA;Lo;0;L;;;;;N;;;;;\n10029;LINEAR B SYLLABLE B027 RE;Lo;0;L;;;;;N;;;;;\n1002A;LINEAR B SYLLABLE B053 RI;Lo;0;L;;;;;N;;;;;\n1002B;LINEAR B SYLLABLE B002 RO;Lo;0;L;;;;;N;;;;;\n1002C;LINEAR B SYLLABLE B026 RU;Lo;0;L;;;;;N;;;;;\n1002D;LINEAR B SYLLABLE B031 SA;Lo;0;L;;;;;N;;;;;\n1002E;LINEAR B SYLLABLE B009 SE;Lo;0;L;;;;;N;;;;;\n1002F;LINEAR B SYLLABLE B041 SI;Lo;0;L;;;;;N;;;;;\n10030;LINEAR B SYLLABLE B012 SO;Lo;0;L;;;;;N;;;;;\n10031;LINEAR B SYLLABLE B058 SU;Lo;0;L;;;;;N;;;;;\n10032;LINEAR B SYLLABLE B059 TA;Lo;0;L;;;;;N;;;;;\n10033;LINEAR B SYLLABLE B004 TE;Lo;0;L;;;;;N;;;;;\n10034;LINEAR B SYLLABLE B037 TI;Lo;0;L;;;;;N;;;;;\n10035;LINEAR B SYLLABLE B005 TO;Lo;0;L;;;;;N;;;;;\n10036;LINEAR B SYLLABLE B069 TU;Lo;0;L;;;;;N;;;;;\n10037;LINEAR B SYLLABLE B054 WA;Lo;0;L;;;;;N;;;;;\n10038;LINEAR B SYLLABLE B075 WE;Lo;0;L;;;;;N;;;;;\n10039;LINEAR B SYLLABLE B040 WI;Lo;0;L;;;;;N;;;;;\n1003A;LINEAR B SYLLABLE B042 WO;Lo;0;L;;;;;N;;;;;\n1003C;LINEAR B SYLLABLE B017 ZA;Lo;0;L;;;;;N;;;;;\n1003D;LINEAR B SYLLABLE B074 ZE;Lo;0;L;;;;;N;;;;;\n1003F;LINEAR B SYLLABLE B020 ZO;Lo;0;L;;;;;N;;;;;\n10040;LINEAR B SYLLABLE B025 A2;Lo;0;L;;;;;N;;;;;\n10041;LINEAR B SYLLABLE B043 A3;Lo;0;L;;;;;N;;;;;\n10042;LINEAR B SYLLABLE B085 AU;Lo;0;L;;;;;N;;;;;\n10043;LINEAR B SYLLABLE B071 DWE;Lo;0;L;;;;;N;;;;;\n10044;LINEAR B SYLLABLE B090 DWO;Lo;0;L;;;;;N;;;;;\n10045;LINEAR B SYLLABLE B048 NWA;Lo;0;L;;;;;N;;;;;\n10046;LINEAR B SYLLABLE B029 PU2;Lo;0;L;;;;;N;;;;;\n10047;LINEAR B SYLLABLE B062 PTE;Lo;0;L;;;;;N;;;;;\n10048;LINEAR B SYLLABLE B076 RA2;Lo;0;L;;;;;N;;;;;\n10049;LINEAR B SYLLABLE B033 RA3;Lo;0;L;;;;;N;;;;;\n1004A;LINEAR B SYLLABLE B068 RO2;Lo;0;L;;;;;N;;;;;\n1004B;LINEAR B SYLLABLE B066 TA2;Lo;0;L;;;;;N;;;;;\n1004C;LINEAR B SYLLABLE B087 TWE;Lo;0;L;;;;;N;;;;;\n1004D;LINEAR B SYLLABLE B091 TWO;Lo;0;L;;;;;N;;;;;\n10050;LINEAR B SYMBOL B018;Lo;0;L;;;;;N;;;;;\n10051;LINEAR B SYMBOL B019;Lo;0;L;;;;;N;;;;;\n10052;LINEAR B SYMBOL B022;Lo;0;L;;;;;N;;;;;\n10053;LINEAR B SYMBOL B034;Lo;0;L;;;;;N;;;;;\n10054;LINEAR B SYMBOL B047;Lo;0;L;;;;;N;;;;;\n10055;LINEAR B SYMBOL B049;Lo;0;L;;;;;N;;;;;\n10056;LINEAR B SYMBOL B056;Lo;0;L;;;;;N;;;;;\n10057;LINEAR B SYMBOL B063;Lo;0;L;;;;;N;;;;;\n10058;LINEAR B SYMBOL B064;Lo;0;L;;;;;N;;;;;\n10059;LINEAR B SYMBOL B079;Lo;0;L;;;;;N;;;;;\n1005A;LINEAR B SYMBOL B082;Lo;0;L;;;;;N;;;;;\n1005B;LINEAR B SYMBOL B083;Lo;0;L;;;;;N;;;;;\n1005C;LINEAR B SYMBOL B086;Lo;0;L;;;;;N;;;;;\n1005D;LINEAR B SYMBOL B089;Lo;0;L;;;;;N;;;;;\n10080;LINEAR B IDEOGRAM B100 MAN;Lo;0;L;;;;;N;;;;;\n10081;LINEAR B IDEOGRAM B102 WOMAN;Lo;0;L;;;;;N;;;;;\n10082;LINEAR B IDEOGRAM B104 DEER;Lo;0;L;;;;;N;;;;;\n10083;LINEAR B IDEOGRAM B105 EQUID;Lo;0;L;;;;;N;;;;;\n10084;LINEAR B IDEOGRAM B105F MARE;Lo;0;L;;;;;N;;;;;\n10085;LINEAR B IDEOGRAM B105M STALLION;Lo;0;L;;;;;N;;;;;\n10086;LINEAR B IDEOGRAM B106F EWE;Lo;0;L;;;;;N;;;;;\n10087;LINEAR B IDEOGRAM B106M RAM;Lo;0;L;;;;;N;;;;;\n10088;LINEAR B IDEOGRAM B107F SHE-GOAT;Lo;0;L;;;;;N;;;;;\n10089;LINEAR B IDEOGRAM B107M HE-GOAT;Lo;0;L;;;;;N;;;;;\n1008A;LINEAR B IDEOGRAM B108F SOW;Lo;0;L;;;;;N;;;;;\n1008B;LINEAR B IDEOGRAM B108M BOAR;Lo;0;L;;;;;N;;;;;\n1008C;LINEAR B IDEOGRAM B109F COW;Lo;0;L;;;;;N;;;;;\n1008D;LINEAR B IDEOGRAM B109M BULL;Lo;0;L;;;;;N;;;;;\n1008E;LINEAR B IDEOGRAM B120 WHEAT;Lo;0;L;;;;;N;;;;;\n1008F;LINEAR B IDEOGRAM B121 BARLEY;Lo;0;L;;;;;N;;;;;\n10090;LINEAR B IDEOGRAM B122 OLIVE;Lo;0;L;;;;;N;;;;;\n10091;LINEAR B IDEOGRAM B123 SPICE;Lo;0;L;;;;;N;;;;;\n10092;LINEAR B IDEOGRAM B125 CYPERUS;Lo;0;L;;;;;N;;;;;\n10093;LINEAR B MONOGRAM B127 KAPO;Lo;0;L;;;;;N;;;;;\n10094;LINEAR B MONOGRAM B128 KANAKO;Lo;0;L;;;;;N;;;;;\n10095;LINEAR B IDEOGRAM B130 OIL;Lo;0;L;;;;;N;;;;;\n10096;LINEAR B IDEOGRAM B131 WINE;Lo;0;L;;;;;N;;;;;\n10097;LINEAR B IDEOGRAM B132;Lo;0;L;;;;;N;;;;;\n10098;LINEAR B MONOGRAM B133 AREPA;Lo;0;L;;;;;N;;;;;\n10099;LINEAR B MONOGRAM B135 MERI;Lo;0;L;;;;;N;;;;;\n1009A;LINEAR B IDEOGRAM B140 BRONZE;Lo;0;L;;;;;N;;;;;\n1009B;LINEAR B IDEOGRAM B141 GOLD;Lo;0;L;;;;;N;;;;;\n1009C;LINEAR B IDEOGRAM B142;Lo;0;L;;;;;N;;;;;\n1009D;LINEAR B IDEOGRAM B145 WOOL;Lo;0;L;;;;;N;;;;;\n1009E;LINEAR B IDEOGRAM B146;Lo;0;L;;;;;N;;;;;\n1009F;LINEAR B IDEOGRAM B150;Lo;0;L;;;;;N;;;;;\n100A0;LINEAR B IDEOGRAM B151 HORN;Lo;0;L;;;;;N;;;;;\n100A1;LINEAR B IDEOGRAM B152;Lo;0;L;;;;;N;;;;;\n100A2;LINEAR B IDEOGRAM B153;Lo;0;L;;;;;N;;;;;\n100A3;LINEAR B IDEOGRAM B154;Lo;0;L;;;;;N;;;;;\n100A4;LINEAR B MONOGRAM B156 TURO2;Lo;0;L;;;;;N;;;;;\n100A5;LINEAR B IDEOGRAM B157;Lo;0;L;;;;;N;;;;;\n100A6;LINEAR B IDEOGRAM B158;Lo;0;L;;;;;N;;;;;\n100A7;LINEAR B IDEOGRAM B159 CLOTH;Lo;0;L;;;;;N;;;;;\n100A8;LINEAR B IDEOGRAM B160;Lo;0;L;;;;;N;;;;;\n100A9;LINEAR B IDEOGRAM B161;Lo;0;L;;;;;N;;;;;\n100AA;LINEAR B IDEOGRAM B162 GARMENT;Lo;0;L;;;;;N;;;;;\n100AB;LINEAR B IDEOGRAM B163 ARMOUR;Lo;0;L;;;;;N;;;;;\n100AC;LINEAR B IDEOGRAM B164;Lo;0;L;;;;;N;;;;;\n100AD;LINEAR B IDEOGRAM B165;Lo;0;L;;;;;N;;;;;\n100AE;LINEAR B IDEOGRAM B166;Lo;0;L;;;;;N;;;;;\n100AF;LINEAR B IDEOGRAM B167;Lo;0;L;;;;;N;;;;;\n100B0;LINEAR B IDEOGRAM B168;Lo;0;L;;;;;N;;;;;\n100B1;LINEAR B IDEOGRAM B169;Lo;0;L;;;;;N;;;;;\n100B2;LINEAR B IDEOGRAM B170;Lo;0;L;;;;;N;;;;;\n100B3;LINEAR B IDEOGRAM B171;Lo;0;L;;;;;N;;;;;\n100B4;LINEAR B IDEOGRAM B172;Lo;0;L;;;;;N;;;;;\n100B5;LINEAR B IDEOGRAM B173 MONTH;Lo;0;L;;;;;N;;;;;\n100B6;LINEAR B IDEOGRAM B174;Lo;0;L;;;;;N;;;;;\n100B7;LINEAR B IDEOGRAM B176 TREE;Lo;0;L;;;;;N;;;;;\n100B8;LINEAR B IDEOGRAM B177;Lo;0;L;;;;;N;;;;;\n100B9;LINEAR B IDEOGRAM B178;Lo;0;L;;;;;N;;;;;\n100BA;LINEAR B IDEOGRAM B179;Lo;0;L;;;;;N;;;;;\n100BB;LINEAR B IDEOGRAM B180;Lo;0;L;;;;;N;;;;;\n100BC;LINEAR B IDEOGRAM B181;Lo;0;L;;;;;N;;;;;\n100BD;LINEAR B IDEOGRAM B182;Lo;0;L;;;;;N;;;;;\n100BE;LINEAR B IDEOGRAM B183;Lo;0;L;;;;;N;;;;;\n100BF;LINEAR B IDEOGRAM B184;Lo;0;L;;;;;N;;;;;\n100C0;LINEAR B IDEOGRAM B185;Lo;0;L;;;;;N;;;;;\n100C1;LINEAR B IDEOGRAM B189;Lo;0;L;;;;;N;;;;;\n100C2;LINEAR B IDEOGRAM B190;Lo;0;L;;;;;N;;;;;\n100C3;LINEAR B IDEOGRAM B191 HELMET;Lo;0;L;;;;;N;;;;;\n100C4;LINEAR B IDEOGRAM B220 FOOTSTOOL;Lo;0;L;;;;;N;;;;;\n100C5;LINEAR B IDEOGRAM B225 BATHTUB;Lo;0;L;;;;;N;;;;;\n100C6;LINEAR B IDEOGRAM B230 SPEAR;Lo;0;L;;;;;N;;;;;\n100C7;LINEAR B IDEOGRAM B231 ARROW;Lo;0;L;;;;;N;;;;;\n100C8;LINEAR B IDEOGRAM B232;Lo;0;L;;;;;N;;;;;\n100C9;LINEAR B IDEOGRAM B233 SWORD;Lo;0;L;;;;;N;;;;;\n100CA;LINEAR B IDEOGRAM B234;Lo;0;L;;;;;N;;;;;\n100CB;LINEAR B IDEOGRAM B236;Lo;0;L;;;;;N;;;;;\n100CC;LINEAR B IDEOGRAM B240 WHEELED CHARIOT;Lo;0;L;;;;;N;;;;;\n100CD;LINEAR B IDEOGRAM B241 CHARIOT;Lo;0;L;;;;;N;;;;;\n100CE;LINEAR B IDEOGRAM B242 CHARIOT FRAME;Lo;0;L;;;;;N;;;;;\n100CF;LINEAR B IDEOGRAM B243 WHEEL;Lo;0;L;;;;;N;;;;;\n100D0;LINEAR B IDEOGRAM B245;Lo;0;L;;;;;N;;;;;\n100D1;LINEAR B IDEOGRAM B246;Lo;0;L;;;;;N;;;;;\n100D2;LINEAR B MONOGRAM B247 DIPTE;Lo;0;L;;;;;N;;;;;\n100D3;LINEAR B IDEOGRAM B248;Lo;0;L;;;;;N;;;;;\n100D4;LINEAR B IDEOGRAM B249;Lo;0;L;;;;;N;;;;;\n100D5;LINEAR B IDEOGRAM B251;Lo;0;L;;;;;N;;;;;\n100D6;LINEAR B IDEOGRAM B252;Lo;0;L;;;;;N;;;;;\n100D7;LINEAR B IDEOGRAM B253;Lo;0;L;;;;;N;;;;;\n100D8;LINEAR B IDEOGRAM B254 DART;Lo;0;L;;;;;N;;;;;\n100D9;LINEAR B IDEOGRAM B255;Lo;0;L;;;;;N;;;;;\n100DA;LINEAR B IDEOGRAM B256;Lo;0;L;;;;;N;;;;;\n100DB;LINEAR B IDEOGRAM B257;Lo;0;L;;;;;N;;;;;\n100DC;LINEAR B IDEOGRAM B258;Lo;0;L;;;;;N;;;;;\n100DD;LINEAR B IDEOGRAM B259;Lo;0;L;;;;;N;;;;;\n100DE;LINEAR B IDEOGRAM VESSEL B155;Lo;0;L;;;;;N;;;;;\n100DF;LINEAR B IDEOGRAM VESSEL B200;Lo;0;L;;;;;N;;;;;\n100E0;LINEAR B IDEOGRAM VESSEL B201;Lo;0;L;;;;;N;;;;;\n100E1;LINEAR B IDEOGRAM VESSEL B202;Lo;0;L;;;;;N;;;;;\n100E2;LINEAR B IDEOGRAM VESSEL B203;Lo;0;L;;;;;N;;;;;\n100E3;LINEAR B IDEOGRAM VESSEL B204;Lo;0;L;;;;;N;;;;;\n100E4;LINEAR B IDEOGRAM VESSEL B205;Lo;0;L;;;;;N;;;;;\n100E5;LINEAR B IDEOGRAM VESSEL B206;Lo;0;L;;;;;N;;;;;\n100E6;LINEAR B IDEOGRAM VESSEL B207;Lo;0;L;;;;;N;;;;;\n100E7;LINEAR B IDEOGRAM VESSEL B208;Lo;0;L;;;;;N;;;;;\n100E8;LINEAR B IDEOGRAM VESSEL B209;Lo;0;L;;;;;N;;;;;\n100E9;LINEAR B IDEOGRAM VESSEL B210;Lo;0;L;;;;;N;;;;;\n100EA;LINEAR B IDEOGRAM VESSEL B211;Lo;0;L;;;;;N;;;;;\n100EB;LINEAR B IDEOGRAM VESSEL B212;Lo;0;L;;;;;N;;;;;\n100EC;LINEAR B IDEOGRAM VESSEL B213;Lo;0;L;;;;;N;;;;;\n100ED;LINEAR B IDEOGRAM VESSEL B214;Lo;0;L;;;;;N;;;;;\n100EE;LINEAR B IDEOGRAM VESSEL B215;Lo;0;L;;;;;N;;;;;\n100EF;LINEAR B IDEOGRAM VESSEL B216;Lo;0;L;;;;;N;;;;;\n100F0;LINEAR B IDEOGRAM VESSEL B217;Lo;0;L;;;;;N;;;;;\n100F1;LINEAR B IDEOGRAM VESSEL B218;Lo;0;L;;;;;N;;;;;\n100F2;LINEAR B IDEOGRAM VESSEL B219;Lo;0;L;;;;;N;;;;;\n100F3;LINEAR B IDEOGRAM VESSEL B221;Lo;0;L;;;;;N;;;;;\n100F4;LINEAR B IDEOGRAM VESSEL B222;Lo;0;L;;;;;N;;;;;\n100F5;LINEAR B IDEOGRAM VESSEL B226;Lo;0;L;;;;;N;;;;;\n100F6;LINEAR B IDEOGRAM VESSEL B227;Lo;0;L;;;;;N;;;;;\n100F7;LINEAR B IDEOGRAM VESSEL B228;Lo;0;L;;;;;N;;;;;\n100F8;LINEAR B IDEOGRAM VESSEL B229;Lo;0;L;;;;;N;;;;;\n100F9;LINEAR B IDEOGRAM VESSEL B250;Lo;0;L;;;;;N;;;;;\n100FA;LINEAR B IDEOGRAM VESSEL B305;Lo;0;L;;;;;N;;;;;\n10100;AEGEAN WORD SEPARATOR LINE;Po;0;L;;;;;N;;;;;\n10101;AEGEAN WORD SEPARATOR DOT;Po;0;ON;;;;;N;;;;;\n10102;AEGEAN CHECK MARK;Po;0;L;;;;;N;;;;;\n10107;AEGEAN NUMBER ONE;No;0;L;;;;1;N;;;;;\n10108;AEGEAN NUMBER TWO;No;0;L;;;;2;N;;;;;\n10109;AEGEAN NUMBER THREE;No;0;L;;;;3;N;;;;;\n1010A;AEGEAN NUMBER FOUR;No;0;L;;;;4;N;;;;;\n1010B;AEGEAN NUMBER FIVE;No;0;L;;;;5;N;;;;;\n1010C;AEGEAN NUMBER SIX;No;0;L;;;;6;N;;;;;\n1010D;AEGEAN NUMBER SEVEN;No;0;L;;;;7;N;;;;;\n1010E;AEGEAN NUMBER EIGHT;No;0;L;;;;8;N;;;;;\n1010F;AEGEAN NUMBER NINE;No;0;L;;;;9;N;;;;;\n10110;AEGEAN NUMBER TEN;No;0;L;;;;10;N;;;;;\n10111;AEGEAN NUMBER TWENTY;No;0;L;;;;20;N;;;;;\n10112;AEGEAN NUMBER THIRTY;No;0;L;;;;30;N;;;;;\n10113;AEGEAN NUMBER FORTY;No;0;L;;;;40;N;;;;;\n10114;AEGEAN NUMBER FIFTY;No;0;L;;;;50;N;;;;;\n10115;AEGEAN NUMBER SIXTY;No;0;L;;;;60;N;;;;;\n10116;AEGEAN NUMBER SEVENTY;No;0;L;;;;70;N;;;;;\n10117;AEGEAN NUMBER EIGHTY;No;0;L;;;;80;N;;;;;\n10118;AEGEAN NUMBER NINETY;No;0;L;;;;90;N;;;;;\n10119;AEGEAN NUMBER ONE HUNDRED;No;0;L;;;;100;N;;;;;\n1011A;AEGEAN NUMBER TWO HUNDRED;No;0;L;;;;200;N;;;;;\n1011B;AEGEAN NUMBER THREE HUNDRED;No;0;L;;;;300;N;;;;;\n1011C;AEGEAN NUMBER FOUR HUNDRED;No;0;L;;;;400;N;;;;;\n1011D;AEGEAN NUMBER FIVE HUNDRED;No;0;L;;;;500;N;;;;;\n1011E;AEGEAN NUMBER SIX HUNDRED;No;0;L;;;;600;N;;;;;\n1011F;AEGEAN NUMBER SEVEN HUNDRED;No;0;L;;;;700;N;;;;;\n10120;AEGEAN NUMBER EIGHT HUNDRED;No;0;L;;;;800;N;;;;;\n10121;AEGEAN NUMBER NINE HUNDRED;No;0;L;;;;900;N;;;;;\n10122;AEGEAN NUMBER ONE THOUSAND;No;0;L;;;;1000;N;;;;;\n10123;AEGEAN NUMBER TWO THOUSAND;No;0;L;;;;2000;N;;;;;\n10124;AEGEAN NUMBER THREE THOUSAND;No;0;L;;;;3000;N;;;;;\n10125;AEGEAN NUMBER FOUR THOUSAND;No;0;L;;;;4000;N;;;;;\n10126;AEGEAN NUMBER FIVE THOUSAND;No;0;L;;;;5000;N;;;;;\n10127;AEGEAN NUMBER SIX THOUSAND;No;0;L;;;;6000;N;;;;;\n10128;AEGEAN NUMBER SEVEN THOUSAND;No;0;L;;;;7000;N;;;;;\n10129;AEGEAN NUMBER EIGHT THOUSAND;No;0;L;;;;8000;N;;;;;\n1012A;AEGEAN NUMBER NINE THOUSAND;No;0;L;;;;9000;N;;;;;\n1012B;AEGEAN NUMBER TEN THOUSAND;No;0;L;;;;10000;N;;;;;\n1012C;AEGEAN NUMBER TWENTY THOUSAND;No;0;L;;;;20000;N;;;;;\n1012D;AEGEAN NUMBER THIRTY THOUSAND;No;0;L;;;;30000;N;;;;;\n1012E;AEGEAN NUMBER FORTY THOUSAND;No;0;L;;;;40000;N;;;;;\n1012F;AEGEAN NUMBER FIFTY THOUSAND;No;0;L;;;;50000;N;;;;;\n10130;AEGEAN NUMBER SIXTY THOUSAND;No;0;L;;;;60000;N;;;;;\n10131;AEGEAN NUMBER SEVENTY THOUSAND;No;0;L;;;;70000;N;;;;;\n10132;AEGEAN NUMBER EIGHTY THOUSAND;No;0;L;;;;80000;N;;;;;\n10133;AEGEAN NUMBER NINETY THOUSAND;No;0;L;;;;90000;N;;;;;\n10137;AEGEAN WEIGHT BASE UNIT;So;0;L;;;;;N;;;;;\n10138;AEGEAN WEIGHT FIRST SUBUNIT;So;0;L;;;;;N;;;;;\n10139;AEGEAN WEIGHT SECOND SUBUNIT;So;0;L;;;;;N;;;;;\n1013A;AEGEAN WEIGHT THIRD SUBUNIT;So;0;L;;;;;N;;;;;\n1013B;AEGEAN WEIGHT FOURTH SUBUNIT;So;0;L;;;;;N;;;;;\n1013C;AEGEAN DRY MEASURE FIRST SUBUNIT;So;0;L;;;;;N;;;;;\n1013D;AEGEAN LIQUID MEASURE FIRST SUBUNIT;So;0;L;;;;;N;;;;;\n1013E;AEGEAN MEASURE SECOND SUBUNIT;So;0;L;;;;;N;;;;;\n1013F;AEGEAN MEASURE THIRD SUBUNIT;So;0;L;;;;;N;;;;;\n10140;GREEK ACROPHONIC ATTIC ONE QUARTER;Nl;0;ON;;;;1/4;N;;;;;\n10141;GREEK ACROPHONIC ATTIC ONE HALF;Nl;0;ON;;;;1/2;N;;;;;\n10142;GREEK ACROPHONIC ATTIC ONE DRACHMA;Nl;0;ON;;;;1;N;;;;;\n10143;GREEK ACROPHONIC ATTIC FIVE;Nl;0;ON;;;;5;N;;;;;\n10144;GREEK ACROPHONIC ATTIC FIFTY;Nl;0;ON;;;;50;N;;;;;\n10145;GREEK ACROPHONIC ATTIC FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n10146;GREEK ACROPHONIC ATTIC FIVE THOUSAND;Nl;0;ON;;;;5000;N;;;;;\n10147;GREEK ACROPHONIC ATTIC FIFTY THOUSAND;Nl;0;ON;;;;50000;N;;;;;\n10148;GREEK ACROPHONIC ATTIC FIVE TALENTS;Nl;0;ON;;;;5;N;;;;;\n10149;GREEK ACROPHONIC ATTIC TEN TALENTS;Nl;0;ON;;;;10;N;;;;;\n1014A;GREEK ACROPHONIC ATTIC FIFTY TALENTS;Nl;0;ON;;;;50;N;;;;;\n1014B;GREEK ACROPHONIC ATTIC ONE HUNDRED TALENTS;Nl;0;ON;;;;100;N;;;;;\n1014C;GREEK ACROPHONIC ATTIC FIVE HUNDRED TALENTS;Nl;0;ON;;;;500;N;;;;;\n1014D;GREEK ACROPHONIC ATTIC ONE THOUSAND TALENTS;Nl;0;ON;;;;1000;N;;;;;\n1014E;GREEK ACROPHONIC ATTIC FIVE THOUSAND TALENTS;Nl;0;ON;;;;5000;N;;;;;\n1014F;GREEK ACROPHONIC ATTIC FIVE STATERS;Nl;0;ON;;;;5;N;;;;;\n10150;GREEK ACROPHONIC ATTIC TEN STATERS;Nl;0;ON;;;;10;N;;;;;\n10151;GREEK ACROPHONIC ATTIC FIFTY STATERS;Nl;0;ON;;;;50;N;;;;;\n10152;GREEK ACROPHONIC ATTIC ONE HUNDRED STATERS;Nl;0;ON;;;;100;N;;;;;\n10153;GREEK ACROPHONIC ATTIC FIVE HUNDRED STATERS;Nl;0;ON;;;;500;N;;;;;\n10154;GREEK ACROPHONIC ATTIC ONE THOUSAND STATERS;Nl;0;ON;;;;1000;N;;;;;\n10155;GREEK ACROPHONIC ATTIC TEN THOUSAND STATERS;Nl;0;ON;;;;10000;N;;;;;\n10156;GREEK ACROPHONIC ATTIC FIFTY THOUSAND STATERS;Nl;0;ON;;;;50000;N;;;;;\n10157;GREEK ACROPHONIC ATTIC TEN MNAS;Nl;0;ON;;;;10;N;;;;;\n10158;GREEK ACROPHONIC HERAEUM ONE PLETHRON;Nl;0;ON;;;;1;N;;;;;\n10159;GREEK ACROPHONIC THESPIAN ONE;Nl;0;ON;;;;1;N;;;;;\n1015A;GREEK ACROPHONIC HERMIONIAN ONE;Nl;0;ON;;;;1;N;;;;;\n1015B;GREEK ACROPHONIC EPIDAUREAN TWO;Nl;0;ON;;;;2;N;;;;;\n1015C;GREEK ACROPHONIC THESPIAN TWO;Nl;0;ON;;;;2;N;;;;;\n1015D;GREEK ACROPHONIC CYRENAIC TWO DRACHMAS;Nl;0;ON;;;;2;N;;;;;\n1015E;GREEK ACROPHONIC EPIDAUREAN TWO DRACHMAS;Nl;0;ON;;;;2;N;;;;;\n1015F;GREEK ACROPHONIC TROEZENIAN FIVE;Nl;0;ON;;;;5;N;;;;;\n10160;GREEK ACROPHONIC TROEZENIAN TEN;Nl;0;ON;;;;10;N;;;;;\n10161;GREEK ACROPHONIC TROEZENIAN TEN ALTERNATE FORM;Nl;0;ON;;;;10;N;;;;;\n10162;GREEK ACROPHONIC HERMIONIAN TEN;Nl;0;ON;;;;10;N;;;;;\n10163;GREEK ACROPHONIC MESSENIAN TEN;Nl;0;ON;;;;10;N;;;;;\n10164;GREEK ACROPHONIC THESPIAN TEN;Nl;0;ON;;;;10;N;;;;;\n10165;GREEK ACROPHONIC THESPIAN THIRTY;Nl;0;ON;;;;30;N;;;;;\n10166;GREEK ACROPHONIC TROEZENIAN FIFTY;Nl;0;ON;;;;50;N;;;;;\n10167;GREEK ACROPHONIC TROEZENIAN FIFTY ALTERNATE FORM;Nl;0;ON;;;;50;N;;;;;\n10168;GREEK ACROPHONIC HERMIONIAN FIFTY;Nl;0;ON;;;;50;N;;;;;\n10169;GREEK ACROPHONIC THESPIAN FIFTY;Nl;0;ON;;;;50;N;;;;;\n1016A;GREEK ACROPHONIC THESPIAN ONE HUNDRED;Nl;0;ON;;;;100;N;;;;;\n1016B;GREEK ACROPHONIC THESPIAN THREE HUNDRED;Nl;0;ON;;;;300;N;;;;;\n1016C;GREEK ACROPHONIC EPIDAUREAN FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n1016D;GREEK ACROPHONIC TROEZENIAN FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n1016E;GREEK ACROPHONIC THESPIAN FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n1016F;GREEK ACROPHONIC CARYSTIAN FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n10170;GREEK ACROPHONIC NAXIAN FIVE HUNDRED;Nl;0;ON;;;;500;N;;;;;\n10171;GREEK ACROPHONIC THESPIAN ONE THOUSAND;Nl;0;ON;;;;1000;N;;;;;\n10172;GREEK ACROPHONIC THESPIAN FIVE THOUSAND;Nl;0;ON;;;;5000;N;;;;;\n10173;GREEK ACROPHONIC DELPHIC FIVE MNAS;Nl;0;ON;;;;5;N;;;;;\n10174;GREEK ACROPHONIC STRATIAN FIFTY MNAS;Nl;0;ON;;;;50;N;;;;;\n10175;GREEK ONE HALF SIGN;No;0;ON;;;;1/2;N;;;;;\n10176;GREEK ONE HALF SIGN ALTERNATE FORM;No;0;ON;;;;1/2;N;;;;;\n10177;GREEK TWO THIRDS SIGN;No;0;ON;;;;2/3;N;;;;;\n10178;GREEK THREE QUARTERS SIGN;No;0;ON;;;;3/4;N;;;;;\n10179;GREEK YEAR SIGN;So;0;ON;;;;;N;;;;;\n1017A;GREEK TALENT SIGN;So;0;ON;;;;;N;;;;;\n1017B;GREEK DRACHMA SIGN;So;0;ON;;;;;N;;;;;\n1017C;GREEK OBOL SIGN;So;0;ON;;;;;N;;;;;\n1017D;GREEK TWO OBOLS SIGN;So;0;ON;;;;;N;;;;;\n1017E;GREEK THREE OBOLS SIGN;So;0;ON;;;;;N;;;;;\n1017F;GREEK FOUR OBOLS SIGN;So;0;ON;;;;;N;;;;;\n10180;GREEK FIVE OBOLS SIGN;So;0;ON;;;;;N;;;;;\n10181;GREEK METRETES SIGN;So;0;ON;;;;;N;;;;;\n10182;GREEK KYATHOS BASE SIGN;So;0;ON;;;;;N;;;;;\n10183;GREEK LITRA SIGN;So;0;ON;;;;;N;;;;;\n10184;GREEK OUNKIA SIGN;So;0;ON;;;;;N;;;;;\n10185;GREEK XESTES SIGN;So;0;ON;;;;;N;;;;;\n10186;GREEK ARTABE SIGN;So;0;ON;;;;;N;;;;;\n10187;GREEK AROURA SIGN;So;0;ON;;;;;N;;;;;\n10188;GREEK GRAMMA SIGN;So;0;ON;;;;;N;;;;;\n10189;GREEK TRYBLION BASE SIGN;So;0;ON;;;;;N;;;;;\n1018A;GREEK ZERO SIGN;No;0;ON;;;;0;N;;;;;\n10190;ROMAN SEXTANS SIGN;So;0;ON;;;;;N;;;;;\n10191;ROMAN UNCIA SIGN;So;0;ON;;;;;N;;;;;\n10192;ROMAN SEMUNCIA SIGN;So;0;ON;;;;;N;;;;;\n10193;ROMAN SEXTULA SIGN;So;0;ON;;;;;N;;;;;\n10194;ROMAN DIMIDIA SEXTULA SIGN;So;0;ON;;;;;N;;;;;\n10195;ROMAN SILIQUA SIGN;So;0;ON;;;;;N;;;;;\n10196;ROMAN DENARIUS SIGN;So;0;ON;;;;;N;;;;;\n10197;ROMAN QUINARIUS SIGN;So;0;ON;;;;;N;;;;;\n10198;ROMAN SESTERTIUS SIGN;So;0;ON;;;;;N;;;;;\n10199;ROMAN DUPONDIUS SIGN;So;0;ON;;;;;N;;;;;\n1019A;ROMAN AS SIGN;So;0;ON;;;;;N;;;;;\n1019B;ROMAN CENTURIAL SIGN;So;0;ON;;;;;N;;;;;\n101D0;PHAISTOS DISC SIGN PEDESTRIAN;So;0;L;;;;;N;;;;;\n101D1;PHAISTOS DISC SIGN PLUMED HEAD;So;0;L;;;;;N;;;;;\n101D2;PHAISTOS DISC SIGN TATTOOED HEAD;So;0;L;;;;;N;;;;;\n101D3;PHAISTOS DISC SIGN CAPTIVE;So;0;L;;;;;N;;;;;\n101D4;PHAISTOS DISC SIGN CHILD;So;0;L;;;;;N;;;;;\n101D5;PHAISTOS DISC SIGN WOMAN;So;0;L;;;;;N;;;;;\n101D6;PHAISTOS DISC SIGN HELMET;So;0;L;;;;;N;;;;;\n101D7;PHAISTOS DISC SIGN GAUNTLET;So;0;L;;;;;N;;;;;\n101D8;PHAISTOS DISC SIGN TIARA;So;0;L;;;;;N;;;;;\n101D9;PHAISTOS DISC SIGN ARROW;So;0;L;;;;;N;;;;;\n101DA;PHAISTOS DISC SIGN BOW;So;0;L;;;;;N;;;;;\n101DB;PHAISTOS DISC SIGN SHIELD;So;0;L;;;;;N;;;;;\n101DC;PHAISTOS DISC SIGN CLUB;So;0;L;;;;;N;;;;;\n101DD;PHAISTOS DISC SIGN MANACLES;So;0;L;;;;;N;;;;;\n101DE;PHAISTOS DISC SIGN MATTOCK;So;0;L;;;;;N;;;;;\n101DF;PHAISTOS DISC SIGN SAW;So;0;L;;;;;N;;;;;\n101E0;PHAISTOS DISC SIGN LID;So;0;L;;;;;N;;;;;\n101E1;PHAISTOS DISC SIGN BOOMERANG;So;0;L;;;;;N;;;;;\n101E2;PHAISTOS DISC SIGN CARPENTRY PLANE;So;0;L;;;;;N;;;;;\n101E3;PHAISTOS DISC SIGN DOLIUM;So;0;L;;;;;N;;;;;\n101E4;PHAISTOS DISC SIGN COMB;So;0;L;;;;;N;;;;;\n101E5;PHAISTOS DISC SIGN SLING;So;0;L;;;;;N;;;;;\n101E6;PHAISTOS DISC SIGN COLUMN;So;0;L;;;;;N;;;;;\n101E7;PHAISTOS DISC SIGN BEEHIVE;So;0;L;;;;;N;;;;;\n101E8;PHAISTOS DISC SIGN SHIP;So;0;L;;;;;N;;;;;\n101E9;PHAISTOS DISC SIGN HORN;So;0;L;;;;;N;;;;;\n101EA;PHAISTOS DISC SIGN HIDE;So;0;L;;;;;N;;;;;\n101EB;PHAISTOS DISC SIGN BULLS LEG;So;0;L;;;;;N;;;;;\n101EC;PHAISTOS DISC SIGN CAT;So;0;L;;;;;N;;;;;\n101ED;PHAISTOS DISC SIGN RAM;So;0;L;;;;;N;;;;;\n101EE;PHAISTOS DISC SIGN EAGLE;So;0;L;;;;;N;;;;;\n101EF;PHAISTOS DISC SIGN DOVE;So;0;L;;;;;N;;;;;\n101F0;PHAISTOS DISC SIGN TUNNY;So;0;L;;;;;N;;;;;\n101F1;PHAISTOS DISC SIGN BEE;So;0;L;;;;;N;;;;;\n101F2;PHAISTOS DISC SIGN PLANE TREE;So;0;L;;;;;N;;;;;\n101F3;PHAISTOS DISC SIGN VINE;So;0;L;;;;;N;;;;;\n101F4;PHAISTOS DISC SIGN PAPYRUS;So;0;L;;;;;N;;;;;\n101F5;PHAISTOS DISC SIGN ROSETTE;So;0;L;;;;;N;;;;;\n101F6;PHAISTOS DISC SIGN LILY;So;0;L;;;;;N;;;;;\n101F7;PHAISTOS DISC SIGN OX BACK;So;0;L;;;;;N;;;;;\n101F8;PHAISTOS DISC SIGN FLUTE;So;0;L;;;;;N;;;;;\n101F9;PHAISTOS DISC SIGN GRATER;So;0;L;;;;;N;;;;;\n101FA;PHAISTOS DISC SIGN STRAINER;So;0;L;;;;;N;;;;;\n101FB;PHAISTOS DISC SIGN SMALL AXE;So;0;L;;;;;N;;;;;\n101FC;PHAISTOS DISC SIGN WAVY BAND;So;0;L;;;;;N;;;;;\n101FD;PHAISTOS DISC SIGN COMBINING OBLIQUE STROKE;Mn;220;NSM;;;;;N;;;;;\n10280;LYCIAN LETTER A;Lo;0;L;;;;;N;;;;;\n10281;LYCIAN LETTER E;Lo;0;L;;;;;N;;;;;\n10282;LYCIAN LETTER B;Lo;0;L;;;;;N;;;;;\n10283;LYCIAN LETTER BH;Lo;0;L;;;;;N;;;;;\n10284;LYCIAN LETTER G;Lo;0;L;;;;;N;;;;;\n10285;LYCIAN LETTER D;Lo;0;L;;;;;N;;;;;\n10286;LYCIAN LETTER I;Lo;0;L;;;;;N;;;;;\n10287;LYCIAN LETTER W;Lo;0;L;;;;;N;;;;;\n10288;LYCIAN LETTER Z;Lo;0;L;;;;;N;;;;;\n10289;LYCIAN LETTER TH;Lo;0;L;;;;;N;;;;;\n1028A;LYCIAN LETTER J;Lo;0;L;;;;;N;;;;;\n1028B;LYCIAN LETTER K;Lo;0;L;;;;;N;;;;;\n1028C;LYCIAN LETTER Q;Lo;0;L;;;;;N;;;;;\n1028D;LYCIAN LETTER L;Lo;0;L;;;;;N;;;;;\n1028E;LYCIAN LETTER M;Lo;0;L;;;;;N;;;;;\n1028F;LYCIAN LETTER N;Lo;0;L;;;;;N;;;;;\n10290;LYCIAN LETTER MM;Lo;0;L;;;;;N;;;;;\n10291;LYCIAN LETTER NN;Lo;0;L;;;;;N;;;;;\n10292;LYCIAN LETTER U;Lo;0;L;;;;;N;;;;;\n10293;LYCIAN LETTER P;Lo;0;L;;;;;N;;;;;\n10294;LYCIAN LETTER KK;Lo;0;L;;;;;N;;;;;\n10295;LYCIAN LETTER R;Lo;0;L;;;;;N;;;;;\n10296;LYCIAN LETTER S;Lo;0;L;;;;;N;;;;;\n10297;LYCIAN LETTER T;Lo;0;L;;;;;N;;;;;\n10298;LYCIAN LETTER TT;Lo;0;L;;;;;N;;;;;\n10299;LYCIAN LETTER AN;Lo;0;L;;;;;N;;;;;\n1029A;LYCIAN LETTER EN;Lo;0;L;;;;;N;;;;;\n1029B;LYCIAN LETTER H;Lo;0;L;;;;;N;;;;;\n1029C;LYCIAN LETTER X;Lo;0;L;;;;;N;;;;;\n102A0;CARIAN LETTER A;Lo;0;L;;;;;N;;;;;\n102A1;CARIAN LETTER P2;Lo;0;L;;;;;N;;;;;\n102A2;CARIAN LETTER D;Lo;0;L;;;;;N;;;;;\n102A3;CARIAN LETTER L;Lo;0;L;;;;;N;;;;;\n102A4;CARIAN LETTER UUU;Lo;0;L;;;;;N;;;;;\n102A5;CARIAN LETTER R;Lo;0;L;;;;;N;;;;;\n102A6;CARIAN LETTER LD;Lo;0;L;;;;;N;;;;;\n102A7;CARIAN LETTER A2;Lo;0;L;;;;;N;;;;;\n102A8;CARIAN LETTER Q;Lo;0;L;;;;;N;;;;;\n102A9;CARIAN LETTER B;Lo;0;L;;;;;N;;;;;\n102AA;CARIAN LETTER M;Lo;0;L;;;;;N;;;;;\n102AB;CARIAN LETTER O;Lo;0;L;;;;;N;;;;;\n102AC;CARIAN LETTER D2;Lo;0;L;;;;;N;;;;;\n102AD;CARIAN LETTER T;Lo;0;L;;;;;N;;;;;\n102AE;CARIAN LETTER SH;Lo;0;L;;;;;N;;;;;\n102AF;CARIAN LETTER SH2;Lo;0;L;;;;;N;;;;;\n102B0;CARIAN LETTER S;Lo;0;L;;;;;N;;;;;\n102B1;CARIAN LETTER C-18;Lo;0;L;;;;;N;;;;;\n102B2;CARIAN LETTER U;Lo;0;L;;;;;N;;;;;\n102B3;CARIAN LETTER NN;Lo;0;L;;;;;N;;;;;\n102B4;CARIAN LETTER X;Lo;0;L;;;;;N;;;;;\n102B5;CARIAN LETTER N;Lo;0;L;;;;;N;;;;;\n102B6;CARIAN LETTER TT2;Lo;0;L;;;;;N;;;;;\n102B7;CARIAN LETTER P;Lo;0;L;;;;;N;;;;;\n102B8;CARIAN LETTER SS;Lo;0;L;;;;;N;;;;;\n102B9;CARIAN LETTER I;Lo;0;L;;;;;N;;;;;\n102BA;CARIAN LETTER E;Lo;0;L;;;;;N;;;;;\n102BB;CARIAN LETTER UUUU;Lo;0;L;;;;;N;;;;;\n102BC;CARIAN LETTER K;Lo;0;L;;;;;N;;;;;\n102BD;CARIAN LETTER K2;Lo;0;L;;;;;N;;;;;\n102BE;CARIAN LETTER ND;Lo;0;L;;;;;N;;;;;\n102BF;CARIAN LETTER UU;Lo;0;L;;;;;N;;;;;\n102C0;CARIAN LETTER G;Lo;0;L;;;;;N;;;;;\n102C1;CARIAN LETTER G2;Lo;0;L;;;;;N;;;;;\n102C2;CARIAN LETTER ST;Lo;0;L;;;;;N;;;;;\n102C3;CARIAN LETTER ST2;Lo;0;L;;;;;N;;;;;\n102C4;CARIAN LETTER NG;Lo;0;L;;;;;N;;;;;\n102C5;CARIAN LETTER II;Lo;0;L;;;;;N;;;;;\n102C6;CARIAN LETTER C-39;Lo;0;L;;;;;N;;;;;\n102C7;CARIAN LETTER TT;Lo;0;L;;;;;N;;;;;\n102C8;CARIAN LETTER UUU2;Lo;0;L;;;;;N;;;;;\n102C9;CARIAN LETTER RR;Lo;0;L;;;;;N;;;;;\n102CA;CARIAN LETTER MB;Lo;0;L;;;;;N;;;;;\n102CB;CARIAN LETTER MB2;Lo;0;L;;;;;N;;;;;\n102CC;CARIAN LETTER MB3;Lo;0;L;;;;;N;;;;;\n102CD;CARIAN LETTER MB4;Lo;0;L;;;;;N;;;;;\n102CE;CARIAN LETTER LD2;Lo;0;L;;;;;N;;;;;\n102CF;CARIAN LETTER E2;Lo;0;L;;;;;N;;;;;\n102D0;CARIAN LETTER UUU3;Lo;0;L;;;;;N;;;;;\n10300;OLD ITALIC LETTER A;Lo;0;L;;;;;N;;;;;\n10301;OLD ITALIC LETTER BE;Lo;0;L;;;;;N;;;;;\n10302;OLD ITALIC LETTER KE;Lo;0;L;;;;;N;;;;;\n10303;OLD ITALIC LETTER DE;Lo;0;L;;;;;N;;;;;\n10304;OLD ITALIC LETTER E;Lo;0;L;;;;;N;;;;;\n10305;OLD ITALIC LETTER VE;Lo;0;L;;;;;N;;;;;\n10306;OLD ITALIC LETTER ZE;Lo;0;L;;;;;N;;;;;\n10307;OLD ITALIC LETTER HE;Lo;0;L;;;;;N;;;;;\n10308;OLD ITALIC LETTER THE;Lo;0;L;;;;;N;;;;;\n10309;OLD ITALIC LETTER I;Lo;0;L;;;;;N;;;;;\n1030A;OLD ITALIC LETTER KA;Lo;0;L;;;;;N;;;;;\n1030B;OLD ITALIC LETTER EL;Lo;0;L;;;;;N;;;;;\n1030C;OLD ITALIC LETTER EM;Lo;0;L;;;;;N;;;;;\n1030D;OLD ITALIC LETTER EN;Lo;0;L;;;;;N;;;;;\n1030E;OLD ITALIC LETTER ESH;Lo;0;L;;;;;N;;;;;\n1030F;OLD ITALIC LETTER O;Lo;0;L;;;;;N;;;;;\n10310;OLD ITALIC LETTER PE;Lo;0;L;;;;;N;;;;;\n10311;OLD ITALIC LETTER SHE;Lo;0;L;;;;;N;;;;;\n10312;OLD ITALIC LETTER KU;Lo;0;L;;;;;N;;;;;\n10313;OLD ITALIC LETTER ER;Lo;0;L;;;;;N;;;;;\n10314;OLD ITALIC LETTER ES;Lo;0;L;;;;;N;;;;;\n10315;OLD ITALIC LETTER TE;Lo;0;L;;;;;N;;;;;\n10316;OLD ITALIC LETTER U;Lo;0;L;;;;;N;;;;;\n10317;OLD ITALIC LETTER EKS;Lo;0;L;;;;;N;;;;;\n10318;OLD ITALIC LETTER PHE;Lo;0;L;;;;;N;;;;;\n10319;OLD ITALIC LETTER KHE;Lo;0;L;;;;;N;;;;;\n1031A;OLD ITALIC LETTER EF;Lo;0;L;;;;;N;;;;;\n1031B;OLD ITALIC LETTER ERS;Lo;0;L;;;;;N;;;;;\n1031C;OLD ITALIC LETTER CHE;Lo;0;L;;;;;N;;;;;\n1031D;OLD ITALIC LETTER II;Lo;0;L;;;;;N;;;;;\n1031E;OLD ITALIC LETTER UU;Lo;0;L;;;;;N;;;;;\n10320;OLD ITALIC NUMERAL ONE;No;0;L;;;;1;N;;;;;\n10321;OLD ITALIC NUMERAL FIVE;No;0;L;;;;5;N;;;;;\n10322;OLD ITALIC NUMERAL TEN;No;0;L;;;;10;N;;;;;\n10323;OLD ITALIC NUMERAL FIFTY;No;0;L;;;;50;N;;;;;\n10330;GOTHIC LETTER AHSA;Lo;0;L;;;;;N;;;;;\n10331;GOTHIC LETTER BAIRKAN;Lo;0;L;;;;;N;;;;;\n10332;GOTHIC LETTER GIBA;Lo;0;L;;;;;N;;;;;\n10333;GOTHIC LETTER DAGS;Lo;0;L;;;;;N;;;;;\n10334;GOTHIC LETTER AIHVUS;Lo;0;L;;;;;N;;;;;\n10335;GOTHIC LETTER QAIRTHRA;Lo;0;L;;;;;N;;;;;\n10336;GOTHIC LETTER IUJA;Lo;0;L;;;;;N;;;;;\n10337;GOTHIC LETTER HAGL;Lo;0;L;;;;;N;;;;;\n10338;GOTHIC LETTER THIUTH;Lo;0;L;;;;;N;;;;;\n10339;GOTHIC LETTER EIS;Lo;0;L;;;;;N;;;;;\n1033A;GOTHIC LETTER KUSMA;Lo;0;L;;;;;N;;;;;\n1033B;GOTHIC LETTER LAGUS;Lo;0;L;;;;;N;;;;;\n1033C;GOTHIC LETTER MANNA;Lo;0;L;;;;;N;;;;;\n1033D;GOTHIC LETTER NAUTHS;Lo;0;L;;;;;N;;;;;\n1033E;GOTHIC LETTER JER;Lo;0;L;;;;;N;;;;;\n1033F;GOTHIC LETTER URUS;Lo;0;L;;;;;N;;;;;\n10340;GOTHIC LETTER PAIRTHRA;Lo;0;L;;;;;N;;;;;\n10341;GOTHIC LETTER NINETY;Nl;0;L;;;;90;N;;;;;\n10342;GOTHIC LETTER RAIDA;Lo;0;L;;;;;N;;;;;\n10343;GOTHIC LETTER SAUIL;Lo;0;L;;;;;N;;;;;\n10344;GOTHIC LETTER TEIWS;Lo;0;L;;;;;N;;;;;\n10345;GOTHIC LETTER WINJA;Lo;0;L;;;;;N;;;;;\n10346;GOTHIC LETTER FAIHU;Lo;0;L;;;;;N;;;;;\n10347;GOTHIC LETTER IGGWS;Lo;0;L;;;;;N;;;;;\n10348;GOTHIC LETTER HWAIR;Lo;0;L;;;;;N;;;;;\n10349;GOTHIC LETTER OTHAL;Lo;0;L;;;;;N;;;;;\n1034A;GOTHIC LETTER NINE HUNDRED;Nl;0;L;;;;900;N;;;;;\n10380;UGARITIC LETTER ALPA;Lo;0;L;;;;;N;;;;;\n10381;UGARITIC LETTER BETA;Lo;0;L;;;;;N;;;;;\n10382;UGARITIC LETTER GAMLA;Lo;0;L;;;;;N;;;;;\n10383;UGARITIC LETTER KHA;Lo;0;L;;;;;N;;;;;\n10384;UGARITIC LETTER DELTA;Lo;0;L;;;;;N;;;;;\n10385;UGARITIC LETTER HO;Lo;0;L;;;;;N;;;;;\n10386;UGARITIC LETTER WO;Lo;0;L;;;;;N;;;;;\n10387;UGARITIC LETTER ZETA;Lo;0;L;;;;;N;;;;;\n10388;UGARITIC LETTER HOTA;Lo;0;L;;;;;N;;;;;\n10389;UGARITIC LETTER TET;Lo;0;L;;;;;N;;;;;\n1038A;UGARITIC LETTER YOD;Lo;0;L;;;;;N;;;;;\n1038B;UGARITIC LETTER KAF;Lo;0;L;;;;;N;;;;;\n1038C;UGARITIC LETTER SHIN;Lo;0;L;;;;;N;;;;;\n1038D;UGARITIC LETTER LAMDA;Lo;0;L;;;;;N;;;;;\n1038E;UGARITIC LETTER MEM;Lo;0;L;;;;;N;;;;;\n1038F;UGARITIC LETTER DHAL;Lo;0;L;;;;;N;;;;;\n10390;UGARITIC LETTER NUN;Lo;0;L;;;;;N;;;;;\n10391;UGARITIC LETTER ZU;Lo;0;L;;;;;N;;;;;\n10392;UGARITIC LETTER SAMKA;Lo;0;L;;;;;N;;;;;\n10393;UGARITIC LETTER AIN;Lo;0;L;;;;;N;;;;;\n10394;UGARITIC LETTER PU;Lo;0;L;;;;;N;;;;;\n10395;UGARITIC LETTER SADE;Lo;0;L;;;;;N;;;;;\n10396;UGARITIC LETTER QOPA;Lo;0;L;;;;;N;;;;;\n10397;UGARITIC LETTER RASHA;Lo;0;L;;;;;N;;;;;\n10398;UGARITIC LETTER THANNA;Lo;0;L;;;;;N;;;;;\n10399;UGARITIC LETTER GHAIN;Lo;0;L;;;;;N;;;;;\n1039A;UGARITIC LETTER TO;Lo;0;L;;;;;N;;;;;\n1039B;UGARITIC LETTER I;Lo;0;L;;;;;N;;;;;\n1039C;UGARITIC LETTER U;Lo;0;L;;;;;N;;;;;\n1039D;UGARITIC LETTER SSU;Lo;0;L;;;;;N;;;;;\n1039F;UGARITIC WORD DIVIDER;Po;0;L;;;;;N;;;;;\n103A0;OLD PERSIAN SIGN A;Lo;0;L;;;;;N;;;;;\n103A1;OLD PERSIAN SIGN I;Lo;0;L;;;;;N;;;;;\n103A2;OLD PERSIAN SIGN U;Lo;0;L;;;;;N;;;;;\n103A3;OLD PERSIAN SIGN KA;Lo;0;L;;;;;N;;;;;\n103A4;OLD PERSIAN SIGN KU;Lo;0;L;;;;;N;;;;;\n103A5;OLD PERSIAN SIGN GA;Lo;0;L;;;;;N;;;;;\n103A6;OLD PERSIAN SIGN GU;Lo;0;L;;;;;N;;;;;\n103A7;OLD PERSIAN SIGN XA;Lo;0;L;;;;;N;;;;;\n103A8;OLD PERSIAN SIGN CA;Lo;0;L;;;;;N;;;;;\n103A9;OLD PERSIAN SIGN JA;Lo;0;L;;;;;N;;;;;\n103AA;OLD PERSIAN SIGN JI;Lo;0;L;;;;;N;;;;;\n103AB;OLD PERSIAN SIGN TA;Lo;0;L;;;;;N;;;;;\n103AC;OLD PERSIAN SIGN TU;Lo;0;L;;;;;N;;;;;\n103AD;OLD PERSIAN SIGN DA;Lo;0;L;;;;;N;;;;;\n103AE;OLD PERSIAN SIGN DI;Lo;0;L;;;;;N;;;;;\n103AF;OLD PERSIAN SIGN DU;Lo;0;L;;;;;N;;;;;\n103B0;OLD PERSIAN SIGN THA;Lo;0;L;;;;;N;;;;;\n103B1;OLD PERSIAN SIGN PA;Lo;0;L;;;;;N;;;;;\n103B2;OLD PERSIAN SIGN BA;Lo;0;L;;;;;N;;;;;\n103B3;OLD PERSIAN SIGN FA;Lo;0;L;;;;;N;;;;;\n103B4;OLD PERSIAN SIGN NA;Lo;0;L;;;;;N;;;;;\n103B5;OLD PERSIAN SIGN NU;Lo;0;L;;;;;N;;;;;\n103B6;OLD PERSIAN SIGN MA;Lo;0;L;;;;;N;;;;;\n103B7;OLD PERSIAN SIGN MI;Lo;0;L;;;;;N;;;;;\n103B8;OLD PERSIAN SIGN MU;Lo;0;L;;;;;N;;;;;\n103B9;OLD PERSIAN SIGN YA;Lo;0;L;;;;;N;;;;;\n103BA;OLD PERSIAN SIGN VA;Lo;0;L;;;;;N;;;;;\n103BB;OLD PERSIAN SIGN VI;Lo;0;L;;;;;N;;;;;\n103BC;OLD PERSIAN SIGN RA;Lo;0;L;;;;;N;;;;;\n103BD;OLD PERSIAN SIGN RU;Lo;0;L;;;;;N;;;;;\n103BE;OLD PERSIAN SIGN LA;Lo;0;L;;;;;N;;;;;\n103BF;OLD PERSIAN SIGN SA;Lo;0;L;;;;;N;;;;;\n103C0;OLD PERSIAN SIGN ZA;Lo;0;L;;;;;N;;;;;\n103C1;OLD PERSIAN SIGN SHA;Lo;0;L;;;;;N;;;;;\n103C2;OLD PERSIAN SIGN SSA;Lo;0;L;;;;;N;;;;;\n103C3;OLD PERSIAN SIGN HA;Lo;0;L;;;;;N;;;;;\n103C8;OLD PERSIAN SIGN AURAMAZDAA;Lo;0;L;;;;;N;;;;;\n103C9;OLD PERSIAN SIGN AURAMAZDAA-2;Lo;0;L;;;;;N;;;;;\n103CA;OLD PERSIAN SIGN AURAMAZDAAHA;Lo;0;L;;;;;N;;;;;\n103CB;OLD PERSIAN SIGN XSHAAYATHIYA;Lo;0;L;;;;;N;;;;;\n103CC;OLD PERSIAN SIGN DAHYAAUSH;Lo;0;L;;;;;N;;;;;\n103CD;OLD PERSIAN SIGN DAHYAAUSH-2;Lo;0;L;;;;;N;;;;;\n103CE;OLD PERSIAN SIGN BAGA;Lo;0;L;;;;;N;;;;;\n103CF;OLD PERSIAN SIGN BUUMISH;Lo;0;L;;;;;N;;;;;\n103D0;OLD PERSIAN WORD DIVIDER;Po;0;L;;;;;N;;;;;\n103D1;OLD PERSIAN NUMBER ONE;Nl;0;L;;;;1;N;;;;;\n103D2;OLD PERSIAN NUMBER TWO;Nl;0;L;;;;2;N;;;;;\n103D3;OLD PERSIAN NUMBER TEN;Nl;0;L;;;;10;N;;;;;\n103D4;OLD PERSIAN NUMBER TWENTY;Nl;0;L;;;;20;N;;;;;\n103D5;OLD PERSIAN NUMBER HUNDRED;Nl;0;L;;;;100;N;;;;;\n10400;DESERET CAPITAL LETTER LONG I;Lu;0;L;;;;;N;;;;10428;\n10401;DESERET CAPITAL LETTER LONG E;Lu;0;L;;;;;N;;;;10429;\n10402;DESERET CAPITAL LETTER LONG A;Lu;0;L;;;;;N;;;;1042A;\n10403;DESERET CAPITAL LETTER LONG AH;Lu;0;L;;;;;N;;;;1042B;\n10404;DESERET CAPITAL LETTER LONG O;Lu;0;L;;;;;N;;;;1042C;\n10405;DESERET CAPITAL LETTER LONG OO;Lu;0;L;;;;;N;;;;1042D;\n10406;DESERET CAPITAL LETTER SHORT I;Lu;0;L;;;;;N;;;;1042E;\n10407;DESERET CAPITAL LETTER SHORT E;Lu;0;L;;;;;N;;;;1042F;\n10408;DESERET CAPITAL LETTER SHORT A;Lu;0;L;;;;;N;;;;10430;\n10409;DESERET CAPITAL LETTER SHORT AH;Lu;0;L;;;;;N;;;;10431;\n1040A;DESERET CAPITAL LETTER SHORT O;Lu;0;L;;;;;N;;;;10432;\n1040B;DESERET CAPITAL LETTER SHORT OO;Lu;0;L;;;;;N;;;;10433;\n1040C;DESERET CAPITAL LETTER AY;Lu;0;L;;;;;N;;;;10434;\n1040D;DESERET CAPITAL LETTER OW;Lu;0;L;;;;;N;;;;10435;\n1040E;DESERET CAPITAL LETTER WU;Lu;0;L;;;;;N;;;;10436;\n1040F;DESERET CAPITAL LETTER YEE;Lu;0;L;;;;;N;;;;10437;\n10410;DESERET CAPITAL LETTER H;Lu;0;L;;;;;N;;;;10438;\n10411;DESERET CAPITAL LETTER PEE;Lu;0;L;;;;;N;;;;10439;\n10412;DESERET CAPITAL LETTER BEE;Lu;0;L;;;;;N;;;;1043A;\n10413;DESERET CAPITAL LETTER TEE;Lu;0;L;;;;;N;;;;1043B;\n10414;DESERET CAPITAL LETTER DEE;Lu;0;L;;;;;N;;;;1043C;\n10415;DESERET CAPITAL LETTER CHEE;Lu;0;L;;;;;N;;;;1043D;\n10416;DESERET CAPITAL LETTER JEE;Lu;0;L;;;;;N;;;;1043E;\n10417;DESERET CAPITAL LETTER KAY;Lu;0;L;;;;;N;;;;1043F;\n10418;DESERET CAPITAL LETTER GAY;Lu;0;L;;;;;N;;;;10440;\n10419;DESERET CAPITAL LETTER EF;Lu;0;L;;;;;N;;;;10441;\n1041A;DESERET CAPITAL LETTER VEE;Lu;0;L;;;;;N;;;;10442;\n1041B;DESERET CAPITAL LETTER ETH;Lu;0;L;;;;;N;;;;10443;\n1041C;DESERET CAPITAL LETTER THEE;Lu;0;L;;;;;N;;;;10444;\n1041D;DESERET CAPITAL LETTER ES;Lu;0;L;;;;;N;;;;10445;\n1041E;DESERET CAPITAL LETTER ZEE;Lu;0;L;;;;;N;;;;10446;\n1041F;DESERET CAPITAL LETTER ESH;Lu;0;L;;;;;N;;;;10447;\n10420;DESERET CAPITAL LETTER ZHEE;Lu;0;L;;;;;N;;;;10448;\n10421;DESERET CAPITAL LETTER ER;Lu;0;L;;;;;N;;;;10449;\n10422;DESERET CAPITAL LETTER EL;Lu;0;L;;;;;N;;;;1044A;\n10423;DESERET CAPITAL LETTER EM;Lu;0;L;;;;;N;;;;1044B;\n10424;DESERET CAPITAL LETTER EN;Lu;0;L;;;;;N;;;;1044C;\n10425;DESERET CAPITAL LETTER ENG;Lu;0;L;;;;;N;;;;1044D;\n10426;DESERET CAPITAL LETTER OI;Lu;0;L;;;;;N;;;;1044E;\n10427;DESERET CAPITAL LETTER EW;Lu;0;L;;;;;N;;;;1044F;\n10428;DESERET SMALL LETTER LONG I;Ll;0;L;;;;;N;;;10400;;10400\n10429;DESERET SMALL LETTER LONG E;Ll;0;L;;;;;N;;;10401;;10401\n1042A;DESERET SMALL LETTER LONG A;Ll;0;L;;;;;N;;;10402;;10402\n1042B;DESERET SMALL LETTER LONG AH;Ll;0;L;;;;;N;;;10403;;10403\n1042C;DESERET SMALL LETTER LONG O;Ll;0;L;;;;;N;;;10404;;10404\n1042D;DESERET SMALL LETTER LONG OO;Ll;0;L;;;;;N;;;10405;;10405\n1042E;DESERET SMALL LETTER SHORT I;Ll;0;L;;;;;N;;;10406;;10406\n1042F;DESERET SMALL LETTER SHORT E;Ll;0;L;;;;;N;;;10407;;10407\n10430;DESERET SMALL LETTER SHORT A;Ll;0;L;;;;;N;;;10408;;10408\n10431;DESERET SMALL LETTER SHORT AH;Ll;0;L;;;;;N;;;10409;;10409\n10432;DESERET SMALL LETTER SHORT O;Ll;0;L;;;;;N;;;1040A;;1040A\n10433;DESERET SMALL LETTER SHORT OO;Ll;0;L;;;;;N;;;1040B;;1040B\n10434;DESERET SMALL LETTER AY;Ll;0;L;;;;;N;;;1040C;;1040C\n10435;DESERET SMALL LETTER OW;Ll;0;L;;;;;N;;;1040D;;1040D\n10436;DESERET SMALL LETTER WU;Ll;0;L;;;;;N;;;1040E;;1040E\n10437;DESERET SMALL LETTER YEE;Ll;0;L;;;;;N;;;1040F;;1040F\n10438;DESERET SMALL LETTER H;Ll;0;L;;;;;N;;;10410;;10410\n10439;DESERET SMALL LETTER PEE;Ll;0;L;;;;;N;;;10411;;10411\n1043A;DESERET SMALL LETTER BEE;Ll;0;L;;;;;N;;;10412;;10412\n1043B;DESERET SMALL LETTER TEE;Ll;0;L;;;;;N;;;10413;;10413\n1043C;DESERET SMALL LETTER DEE;Ll;0;L;;;;;N;;;10414;;10414\n1043D;DESERET SMALL LETTER CHEE;Ll;0;L;;;;;N;;;10415;;10415\n1043E;DESERET SMALL LETTER JEE;Ll;0;L;;;;;N;;;10416;;10416\n1043F;DESERET SMALL LETTER KAY;Ll;0;L;;;;;N;;;10417;;10417\n10440;DESERET SMALL LETTER GAY;Ll;0;L;;;;;N;;;10418;;10418\n10441;DESERET SMALL LETTER EF;Ll;0;L;;;;;N;;;10419;;10419\n10442;DESERET SMALL LETTER VEE;Ll;0;L;;;;;N;;;1041A;;1041A\n10443;DESERET SMALL LETTER ETH;Ll;0;L;;;;;N;;;1041B;;1041B\n10444;DESERET SMALL LETTER THEE;Ll;0;L;;;;;N;;;1041C;;1041C\n10445;DESERET SMALL LETTER ES;Ll;0;L;;;;;N;;;1041D;;1041D\n10446;DESERET SMALL LETTER ZEE;Ll;0;L;;;;;N;;;1041E;;1041E\n10447;DESERET SMALL LETTER ESH;Ll;0;L;;;;;N;;;1041F;;1041F\n10448;DESERET SMALL LETTER ZHEE;Ll;0;L;;;;;N;;;10420;;10420\n10449;DESERET SMALL LETTER ER;Ll;0;L;;;;;N;;;10421;;10421\n1044A;DESERET SMALL LETTER EL;Ll;0;L;;;;;N;;;10422;;10422\n1044B;DESERET SMALL LETTER EM;Ll;0;L;;;;;N;;;10423;;10423\n1044C;DESERET SMALL LETTER EN;Ll;0;L;;;;;N;;;10424;;10424\n1044D;DESERET SMALL LETTER ENG;Ll;0;L;;;;;N;;;10425;;10425\n1044E;DESERET SMALL LETTER OI;Ll;0;L;;;;;N;;;10426;;10426\n1044F;DESERET SMALL LETTER EW;Ll;0;L;;;;;N;;;10427;;10427\n10450;SHAVIAN LETTER PEEP;Lo;0;L;;;;;N;;;;;\n10451;SHAVIAN LETTER TOT;Lo;0;L;;;;;N;;;;;\n10452;SHAVIAN LETTER KICK;Lo;0;L;;;;;N;;;;;\n10453;SHAVIAN LETTER FEE;Lo;0;L;;;;;N;;;;;\n10454;SHAVIAN LETTER THIGH;Lo;0;L;;;;;N;;;;;\n10455;SHAVIAN LETTER SO;Lo;0;L;;;;;N;;;;;\n10456;SHAVIAN LETTER SURE;Lo;0;L;;;;;N;;;;;\n10457;SHAVIAN LETTER CHURCH;Lo;0;L;;;;;N;;;;;\n10458;SHAVIAN LETTER YEA;Lo;0;L;;;;;N;;;;;\n10459;SHAVIAN LETTER HUNG;Lo;0;L;;;;;N;;;;;\n1045A;SHAVIAN LETTER BIB;Lo;0;L;;;;;N;;;;;\n1045B;SHAVIAN LETTER DEAD;Lo;0;L;;;;;N;;;;;\n1045C;SHAVIAN LETTER GAG;Lo;0;L;;;;;N;;;;;\n1045D;SHAVIAN LETTER VOW;Lo;0;L;;;;;N;;;;;\n1045E;SHAVIAN LETTER THEY;Lo;0;L;;;;;N;;;;;\n1045F;SHAVIAN LETTER ZOO;Lo;0;L;;;;;N;;;;;\n10460;SHAVIAN LETTER MEASURE;Lo;0;L;;;;;N;;;;;\n10461;SHAVIAN LETTER JUDGE;Lo;0;L;;;;;N;;;;;\n10462;SHAVIAN LETTER WOE;Lo;0;L;;;;;N;;;;;\n10463;SHAVIAN LETTER HA-HA;Lo;0;L;;;;;N;;;;;\n10464;SHAVIAN LETTER LOLL;Lo;0;L;;;;;N;;;;;\n10465;SHAVIAN LETTER MIME;Lo;0;L;;;;;N;;;;;\n10466;SHAVIAN LETTER IF;Lo;0;L;;;;;N;;;;;\n10467;SHAVIAN LETTER EGG;Lo;0;L;;;;;N;;;;;\n10468;SHAVIAN LETTER ASH;Lo;0;L;;;;;N;;;;;\n10469;SHAVIAN LETTER ADO;Lo;0;L;;;;;N;;;;;\n1046A;SHAVIAN LETTER ON;Lo;0;L;;;;;N;;;;;\n1046B;SHAVIAN LETTER WOOL;Lo;0;L;;;;;N;;;;;\n1046C;SHAVIAN LETTER OUT;Lo;0;L;;;;;N;;;;;\n1046D;SHAVIAN LETTER AH;Lo;0;L;;;;;N;;;;;\n1046E;SHAVIAN LETTER ROAR;Lo;0;L;;;;;N;;;;;\n1046F;SHAVIAN LETTER NUN;Lo;0;L;;;;;N;;;;;\n10470;SHAVIAN LETTER EAT;Lo;0;L;;;;;N;;;;;\n10471;SHAVIAN LETTER AGE;Lo;0;L;;;;;N;;;;;\n10472;SHAVIAN LETTER ICE;Lo;0;L;;;;;N;;;;;\n10473;SHAVIAN LETTER UP;Lo;0;L;;;;;N;;;;;\n10474;SHAVIAN LETTER OAK;Lo;0;L;;;;;N;;;;;\n10475;SHAVIAN LETTER OOZE;Lo;0;L;;;;;N;;;;;\n10476;SHAVIAN LETTER OIL;Lo;0;L;;;;;N;;;;;\n10477;SHAVIAN LETTER AWE;Lo;0;L;;;;;N;;;;;\n10478;SHAVIAN LETTER ARE;Lo;0;L;;;;;N;;;;;\n10479;SHAVIAN LETTER OR;Lo;0;L;;;;;N;;;;;\n1047A;SHAVIAN LETTER AIR;Lo;0;L;;;;;N;;;;;\n1047B;SHAVIAN LETTER ERR;Lo;0;L;;;;;N;;;;;\n1047C;SHAVIAN LETTER ARRAY;Lo;0;L;;;;;N;;;;;\n1047D;SHAVIAN LETTER EAR;Lo;0;L;;;;;N;;;;;\n1047E;SHAVIAN LETTER IAN;Lo;0;L;;;;;N;;;;;\n1047F;SHAVIAN LETTER YEW;Lo;0;L;;;;;N;;;;;\n10480;OSMANYA LETTER ALEF;Lo;0;L;;;;;N;;;;;\n10481;OSMANYA LETTER BA;Lo;0;L;;;;;N;;;;;\n10482;OSMANYA LETTER TA;Lo;0;L;;;;;N;;;;;\n10483;OSMANYA LETTER JA;Lo;0;L;;;;;N;;;;;\n10484;OSMANYA LETTER XA;Lo;0;L;;;;;N;;;;;\n10485;OSMANYA LETTER KHA;Lo;0;L;;;;;N;;;;;\n10486;OSMANYA LETTER DEEL;Lo;0;L;;;;;N;;;;;\n10487;OSMANYA LETTER RA;Lo;0;L;;;;;N;;;;;\n10488;OSMANYA LETTER SA;Lo;0;L;;;;;N;;;;;\n10489;OSMANYA LETTER SHIIN;Lo;0;L;;;;;N;;;;;\n1048A;OSMANYA LETTER DHA;Lo;0;L;;;;;N;;;;;\n1048B;OSMANYA LETTER CAYN;Lo;0;L;;;;;N;;;;;\n1048C;OSMANYA LETTER GA;Lo;0;L;;;;;N;;;;;\n1048D;OSMANYA LETTER FA;Lo;0;L;;;;;N;;;;;\n1048E;OSMANYA LETTER QAAF;Lo;0;L;;;;;N;;;;;\n1048F;OSMANYA LETTER KAAF;Lo;0;L;;;;;N;;;;;\n10490;OSMANYA LETTER LAAN;Lo;0;L;;;;;N;;;;;\n10491;OSMANYA LETTER MIIN;Lo;0;L;;;;;N;;;;;\n10492;OSMANYA LETTER NUUN;Lo;0;L;;;;;N;;;;;\n10493;OSMANYA LETTER WAW;Lo;0;L;;;;;N;;;;;\n10494;OSMANYA LETTER HA;Lo;0;L;;;;;N;;;;;\n10495;OSMANYA LETTER YA;Lo;0;L;;;;;N;;;;;\n10496;OSMANYA LETTER A;Lo;0;L;;;;;N;;;;;\n10497;OSMANYA LETTER E;Lo;0;L;;;;;N;;;;;\n10498;OSMANYA LETTER I;Lo;0;L;;;;;N;;;;;\n10499;OSMANYA LETTER O;Lo;0;L;;;;;N;;;;;\n1049A;OSMANYA LETTER U;Lo;0;L;;;;;N;;;;;\n1049B;OSMANYA LETTER AA;Lo;0;L;;;;;N;;;;;\n1049C;OSMANYA LETTER EE;Lo;0;L;;;;;N;;;;;\n1049D;OSMANYA LETTER OO;Lo;0;L;;;;;N;;;;;\n104A0;OSMANYA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n104A1;OSMANYA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n104A2;OSMANYA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n104A3;OSMANYA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n104A4;OSMANYA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n104A5;OSMANYA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n104A6;OSMANYA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n104A7;OSMANYA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n104A8;OSMANYA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n104A9;OSMANYA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n10800;CYPRIOT SYLLABLE A;Lo;0;R;;;;;N;;;;;\n10801;CYPRIOT SYLLABLE E;Lo;0;R;;;;;N;;;;;\n10802;CYPRIOT SYLLABLE I;Lo;0;R;;;;;N;;;;;\n10803;CYPRIOT SYLLABLE O;Lo;0;R;;;;;N;;;;;\n10804;CYPRIOT SYLLABLE U;Lo;0;R;;;;;N;;;;;\n10805;CYPRIOT SYLLABLE JA;Lo;0;R;;;;;N;;;;;\n10808;CYPRIOT SYLLABLE JO;Lo;0;R;;;;;N;;;;;\n1080A;CYPRIOT SYLLABLE KA;Lo;0;R;;;;;N;;;;;\n1080B;CYPRIOT SYLLABLE KE;Lo;0;R;;;;;N;;;;;\n1080C;CYPRIOT SYLLABLE KI;Lo;0;R;;;;;N;;;;;\n1080D;CYPRIOT SYLLABLE KO;Lo;0;R;;;;;N;;;;;\n1080E;CYPRIOT SYLLABLE KU;Lo;0;R;;;;;N;;;;;\n1080F;CYPRIOT SYLLABLE LA;Lo;0;R;;;;;N;;;;;\n10810;CYPRIOT SYLLABLE LE;Lo;0;R;;;;;N;;;;;\n10811;CYPRIOT SYLLABLE LI;Lo;0;R;;;;;N;;;;;\n10812;CYPRIOT SYLLABLE LO;Lo;0;R;;;;;N;;;;;\n10813;CYPRIOT SYLLABLE LU;Lo;0;R;;;;;N;;;;;\n10814;CYPRIOT SYLLABLE MA;Lo;0;R;;;;;N;;;;;\n10815;CYPRIOT SYLLABLE ME;Lo;0;R;;;;;N;;;;;\n10816;CYPRIOT SYLLABLE MI;Lo;0;R;;;;;N;;;;;\n10817;CYPRIOT SYLLABLE MO;Lo;0;R;;;;;N;;;;;\n10818;CYPRIOT SYLLABLE MU;Lo;0;R;;;;;N;;;;;\n10819;CYPRIOT SYLLABLE NA;Lo;0;R;;;;;N;;;;;\n1081A;CYPRIOT SYLLABLE NE;Lo;0;R;;;;;N;;;;;\n1081B;CYPRIOT SYLLABLE NI;Lo;0;R;;;;;N;;;;;\n1081C;CYPRIOT SYLLABLE NO;Lo;0;R;;;;;N;;;;;\n1081D;CYPRIOT SYLLABLE NU;Lo;0;R;;;;;N;;;;;\n1081E;CYPRIOT SYLLABLE PA;Lo;0;R;;;;;N;;;;;\n1081F;CYPRIOT SYLLABLE PE;Lo;0;R;;;;;N;;;;;\n10820;CYPRIOT SYLLABLE PI;Lo;0;R;;;;;N;;;;;\n10821;CYPRIOT SYLLABLE PO;Lo;0;R;;;;;N;;;;;\n10822;CYPRIOT SYLLABLE PU;Lo;0;R;;;;;N;;;;;\n10823;CYPRIOT SYLLABLE RA;Lo;0;R;;;;;N;;;;;\n10824;CYPRIOT SYLLABLE RE;Lo;0;R;;;;;N;;;;;\n10825;CYPRIOT SYLLABLE RI;Lo;0;R;;;;;N;;;;;\n10826;CYPRIOT SYLLABLE RO;Lo;0;R;;;;;N;;;;;\n10827;CYPRIOT SYLLABLE RU;Lo;0;R;;;;;N;;;;;\n10828;CYPRIOT SYLLABLE SA;Lo;0;R;;;;;N;;;;;\n10829;CYPRIOT SYLLABLE SE;Lo;0;R;;;;;N;;;;;\n1082A;CYPRIOT SYLLABLE SI;Lo;0;R;;;;;N;;;;;\n1082B;CYPRIOT SYLLABLE SO;Lo;0;R;;;;;N;;;;;\n1082C;CYPRIOT SYLLABLE SU;Lo;0;R;;;;;N;;;;;\n1082D;CYPRIOT SYLLABLE TA;Lo;0;R;;;;;N;;;;;\n1082E;CYPRIOT SYLLABLE TE;Lo;0;R;;;;;N;;;;;\n1082F;CYPRIOT SYLLABLE TI;Lo;0;R;;;;;N;;;;;\n10830;CYPRIOT SYLLABLE TO;Lo;0;R;;;;;N;;;;;\n10831;CYPRIOT SYLLABLE TU;Lo;0;R;;;;;N;;;;;\n10832;CYPRIOT SYLLABLE WA;Lo;0;R;;;;;N;;;;;\n10833;CYPRIOT SYLLABLE WE;Lo;0;R;;;;;N;;;;;\n10834;CYPRIOT SYLLABLE WI;Lo;0;R;;;;;N;;;;;\n10835;CYPRIOT SYLLABLE WO;Lo;0;R;;;;;N;;;;;\n10837;CYPRIOT SYLLABLE XA;Lo;0;R;;;;;N;;;;;\n10838;CYPRIOT SYLLABLE XE;Lo;0;R;;;;;N;;;;;\n1083C;CYPRIOT SYLLABLE ZA;Lo;0;R;;;;;N;;;;;\n1083F;CYPRIOT SYLLABLE ZO;Lo;0;R;;;;;N;;;;;\n10840;IMPERIAL ARAMAIC LETTER ALEPH;Lo;0;R;;;;;N;;;;;\n10841;IMPERIAL ARAMAIC LETTER BETH;Lo;0;R;;;;;N;;;;;\n10842;IMPERIAL ARAMAIC LETTER GIMEL;Lo;0;R;;;;;N;;;;;\n10843;IMPERIAL ARAMAIC LETTER DALETH;Lo;0;R;;;;;N;;;;;\n10844;IMPERIAL ARAMAIC LETTER HE;Lo;0;R;;;;;N;;;;;\n10845;IMPERIAL ARAMAIC LETTER WAW;Lo;0;R;;;;;N;;;;;\n10846;IMPERIAL ARAMAIC LETTER ZAYIN;Lo;0;R;;;;;N;;;;;\n10847;IMPERIAL ARAMAIC LETTER HETH;Lo;0;R;;;;;N;;;;;\n10848;IMPERIAL ARAMAIC LETTER TETH;Lo;0;R;;;;;N;;;;;\n10849;IMPERIAL ARAMAIC LETTER YODH;Lo;0;R;;;;;N;;;;;\n1084A;IMPERIAL ARAMAIC LETTER KAPH;Lo;0;R;;;;;N;;;;;\n1084B;IMPERIAL ARAMAIC LETTER LAMEDH;Lo;0;R;;;;;N;;;;;\n1084C;IMPERIAL ARAMAIC LETTER MEM;Lo;0;R;;;;;N;;;;;\n1084D;IMPERIAL ARAMAIC LETTER NUN;Lo;0;R;;;;;N;;;;;\n1084E;IMPERIAL ARAMAIC LETTER SAMEKH;Lo;0;R;;;;;N;;;;;\n1084F;IMPERIAL ARAMAIC LETTER AYIN;Lo;0;R;;;;;N;;;;;\n10850;IMPERIAL ARAMAIC LETTER PE;Lo;0;R;;;;;N;;;;;\n10851;IMPERIAL ARAMAIC LETTER SADHE;Lo;0;R;;;;;N;;;;;\n10852;IMPERIAL ARAMAIC LETTER QOPH;Lo;0;R;;;;;N;;;;;\n10853;IMPERIAL ARAMAIC LETTER RESH;Lo;0;R;;;;;N;;;;;\n10854;IMPERIAL ARAMAIC LETTER SHIN;Lo;0;R;;;;;N;;;;;\n10855;IMPERIAL ARAMAIC LETTER TAW;Lo;0;R;;;;;N;;;;;\n10857;IMPERIAL ARAMAIC SECTION SIGN;Po;0;R;;;;;N;;;;;\n10858;IMPERIAL ARAMAIC NUMBER ONE;No;0;R;;;;1;N;;;;;\n10859;IMPERIAL ARAMAIC NUMBER TWO;No;0;R;;;;2;N;;;;;\n1085A;IMPERIAL ARAMAIC NUMBER THREE;No;0;R;;;;3;N;;;;;\n1085B;IMPERIAL ARAMAIC NUMBER TEN;No;0;R;;;;10;N;;;;;\n1085C;IMPERIAL ARAMAIC NUMBER TWENTY;No;0;R;;;;20;N;;;;;\n1085D;IMPERIAL ARAMAIC NUMBER ONE HUNDRED;No;0;R;;;;100;N;;;;;\n1085E;IMPERIAL ARAMAIC NUMBER ONE THOUSAND;No;0;R;;;;1000;N;;;;;\n1085F;IMPERIAL ARAMAIC NUMBER TEN THOUSAND;No;0;R;;;;10000;N;;;;;\n10900;PHOENICIAN LETTER ALF;Lo;0;R;;;;;N;;;;;\n10901;PHOENICIAN LETTER BET;Lo;0;R;;;;;N;;;;;\n10902;PHOENICIAN LETTER GAML;Lo;0;R;;;;;N;;;;;\n10903;PHOENICIAN LETTER DELT;Lo;0;R;;;;;N;;;;;\n10904;PHOENICIAN LETTER HE;Lo;0;R;;;;;N;;;;;\n10905;PHOENICIAN LETTER WAU;Lo;0;R;;;;;N;;;;;\n10906;PHOENICIAN LETTER ZAI;Lo;0;R;;;;;N;;;;;\n10907;PHOENICIAN LETTER HET;Lo;0;R;;;;;N;;;;;\n10908;PHOENICIAN LETTER TET;Lo;0;R;;;;;N;;;;;\n10909;PHOENICIAN LETTER YOD;Lo;0;R;;;;;N;;;;;\n1090A;PHOENICIAN LETTER KAF;Lo;0;R;;;;;N;;;;;\n1090B;PHOENICIAN LETTER LAMD;Lo;0;R;;;;;N;;;;;\n1090C;PHOENICIAN LETTER MEM;Lo;0;R;;;;;N;;;;;\n1090D;PHOENICIAN LETTER NUN;Lo;0;R;;;;;N;;;;;\n1090E;PHOENICIAN LETTER SEMK;Lo;0;R;;;;;N;;;;;\n1090F;PHOENICIAN LETTER AIN;Lo;0;R;;;;;N;;;;;\n10910;PHOENICIAN LETTER PE;Lo;0;R;;;;;N;;;;;\n10911;PHOENICIAN LETTER SADE;Lo;0;R;;;;;N;;;;;\n10912;PHOENICIAN LETTER QOF;Lo;0;R;;;;;N;;;;;\n10913;PHOENICIAN LETTER ROSH;Lo;0;R;;;;;N;;;;;\n10914;PHOENICIAN LETTER SHIN;Lo;0;R;;;;;N;;;;;\n10915;PHOENICIAN LETTER TAU;Lo;0;R;;;;;N;;;;;\n10916;PHOENICIAN NUMBER ONE;No;0;R;;;;1;N;;;;;\n10917;PHOENICIAN NUMBER TEN;No;0;R;;;;10;N;;;;;\n10918;PHOENICIAN NUMBER TWENTY;No;0;R;;;;20;N;;;;;\n10919;PHOENICIAN NUMBER ONE HUNDRED;No;0;R;;;;100;N;;;;;\n1091A;PHOENICIAN NUMBER TWO;No;0;R;;;;2;N;;;;;\n1091B;PHOENICIAN NUMBER THREE;No;0;R;;;;3;N;;;;;\n1091F;PHOENICIAN WORD SEPARATOR;Po;0;ON;;;;;N;;;;;\n10920;LYDIAN LETTER A;Lo;0;R;;;;;N;;;;;\n10921;LYDIAN LETTER B;Lo;0;R;;;;;N;;;;;\n10922;LYDIAN LETTER G;Lo;0;R;;;;;N;;;;;\n10923;LYDIAN LETTER D;Lo;0;R;;;;;N;;;;;\n10924;LYDIAN LETTER E;Lo;0;R;;;;;N;;;;;\n10925;LYDIAN LETTER V;Lo;0;R;;;;;N;;;;;\n10926;LYDIAN LETTER I;Lo;0;R;;;;;N;;;;;\n10927;LYDIAN LETTER Y;Lo;0;R;;;;;N;;;;;\n10928;LYDIAN LETTER K;Lo;0;R;;;;;N;;;;;\n10929;LYDIAN LETTER L;Lo;0;R;;;;;N;;;;;\n1092A;LYDIAN LETTER M;Lo;0;R;;;;;N;;;;;\n1092B;LYDIAN LETTER N;Lo;0;R;;;;;N;;;;;\n1092C;LYDIAN LETTER O;Lo;0;R;;;;;N;;;;;\n1092D;LYDIAN LETTER R;Lo;0;R;;;;;N;;;;;\n1092E;LYDIAN LETTER SS;Lo;0;R;;;;;N;;;;;\n1092F;LYDIAN LETTER T;Lo;0;R;;;;;N;;;;;\n10930;LYDIAN LETTER U;Lo;0;R;;;;;N;;;;;\n10931;LYDIAN LETTER F;Lo;0;R;;;;;N;;;;;\n10932;LYDIAN LETTER Q;Lo;0;R;;;;;N;;;;;\n10933;LYDIAN LETTER S;Lo;0;R;;;;;N;;;;;\n10934;LYDIAN LETTER TT;Lo;0;R;;;;;N;;;;;\n10935;LYDIAN LETTER AN;Lo;0;R;;;;;N;;;;;\n10936;LYDIAN LETTER EN;Lo;0;R;;;;;N;;;;;\n10937;LYDIAN LETTER LY;Lo;0;R;;;;;N;;;;;\n10938;LYDIAN LETTER NN;Lo;0;R;;;;;N;;;;;\n10939;LYDIAN LETTER C;Lo;0;R;;;;;N;;;;;\n1093F;LYDIAN TRIANGULAR MARK;Po;0;R;;;;;N;;;;;\n10980;MEROITIC HIEROGLYPHIC LETTER A;Lo;0;R;;;;;N;;;;;\n10981;MEROITIC HIEROGLYPHIC LETTER E;Lo;0;R;;;;;N;;;;;\n10982;MEROITIC HIEROGLYPHIC LETTER I;Lo;0;R;;;;;N;;;;;\n10983;MEROITIC HIEROGLYPHIC LETTER O;Lo;0;R;;;;;N;;;;;\n10984;MEROITIC HIEROGLYPHIC LETTER YA;Lo;0;R;;;;;N;;;;;\n10985;MEROITIC HIEROGLYPHIC LETTER WA;Lo;0;R;;;;;N;;;;;\n10986;MEROITIC HIEROGLYPHIC LETTER BA;Lo;0;R;;;;;N;;;;;\n10987;MEROITIC HIEROGLYPHIC LETTER BA-2;Lo;0;R;;;;;N;;;;;\n10988;MEROITIC HIEROGLYPHIC LETTER PA;Lo;0;R;;;;;N;;;;;\n10989;MEROITIC HIEROGLYPHIC LETTER MA;Lo;0;R;;;;;N;;;;;\n1098A;MEROITIC HIEROGLYPHIC LETTER NA;Lo;0;R;;;;;N;;;;;\n1098B;MEROITIC HIEROGLYPHIC LETTER NA-2;Lo;0;R;;;;;N;;;;;\n1098C;MEROITIC HIEROGLYPHIC LETTER NE;Lo;0;R;;;;;N;;;;;\n1098D;MEROITIC HIEROGLYPHIC LETTER NE-2;Lo;0;R;;;;;N;;;;;\n1098E;MEROITIC HIEROGLYPHIC LETTER RA;Lo;0;R;;;;;N;;;;;\n1098F;MEROITIC HIEROGLYPHIC LETTER RA-2;Lo;0;R;;;;;N;;;;;\n10990;MEROITIC HIEROGLYPHIC LETTER LA;Lo;0;R;;;;;N;;;;;\n10991;MEROITIC HIEROGLYPHIC LETTER KHA;Lo;0;R;;;;;N;;;;;\n10992;MEROITIC HIEROGLYPHIC LETTER HHA;Lo;0;R;;;;;N;;;;;\n10993;MEROITIC HIEROGLYPHIC LETTER SA;Lo;0;R;;;;;N;;;;;\n10994;MEROITIC HIEROGLYPHIC LETTER SA-2;Lo;0;R;;;;;N;;;;;\n10995;MEROITIC HIEROGLYPHIC LETTER SE;Lo;0;R;;;;;N;;;;;\n10996;MEROITIC HIEROGLYPHIC LETTER KA;Lo;0;R;;;;;N;;;;;\n10997;MEROITIC HIEROGLYPHIC LETTER QA;Lo;0;R;;;;;N;;;;;\n10998;MEROITIC HIEROGLYPHIC LETTER TA;Lo;0;R;;;;;N;;;;;\n10999;MEROITIC HIEROGLYPHIC LETTER TA-2;Lo;0;R;;;;;N;;;;;\n1099A;MEROITIC HIEROGLYPHIC LETTER TE;Lo;0;R;;;;;N;;;;;\n1099B;MEROITIC HIEROGLYPHIC LETTER TE-2;Lo;0;R;;;;;N;;;;;\n1099C;MEROITIC HIEROGLYPHIC LETTER TO;Lo;0;R;;;;;N;;;;;\n1099D;MEROITIC HIEROGLYPHIC LETTER DA;Lo;0;R;;;;;N;;;;;\n1099E;MEROITIC HIEROGLYPHIC SYMBOL VIDJ;Lo;0;R;;;;;N;;;;;\n1099F;MEROITIC HIEROGLYPHIC SYMBOL VIDJ-2;Lo;0;R;;;;;N;;;;;\n109A0;MEROITIC CURSIVE LETTER A;Lo;0;R;;;;;N;;;;;\n109A1;MEROITIC CURSIVE LETTER E;Lo;0;R;;;;;N;;;;;\n109A2;MEROITIC CURSIVE LETTER I;Lo;0;R;;;;;N;;;;;\n109A3;MEROITIC CURSIVE LETTER O;Lo;0;R;;;;;N;;;;;\n109A4;MEROITIC CURSIVE LETTER YA;Lo;0;R;;;;;N;;;;;\n109A5;MEROITIC CURSIVE LETTER WA;Lo;0;R;;;;;N;;;;;\n109A6;MEROITIC CURSIVE LETTER BA;Lo;0;R;;;;;N;;;;;\n109A7;MEROITIC CURSIVE LETTER PA;Lo;0;R;;;;;N;;;;;\n109A8;MEROITIC CURSIVE LETTER MA;Lo;0;R;;;;;N;;;;;\n109A9;MEROITIC CURSIVE LETTER NA;Lo;0;R;;;;;N;;;;;\n109AA;MEROITIC CURSIVE LETTER NE;Lo;0;R;;;;;N;;;;;\n109AB;MEROITIC CURSIVE LETTER RA;Lo;0;R;;;;;N;;;;;\n109AC;MEROITIC CURSIVE LETTER LA;Lo;0;R;;;;;N;;;;;\n109AD;MEROITIC CURSIVE LETTER KHA;Lo;0;R;;;;;N;;;;;\n109AE;MEROITIC CURSIVE LETTER HHA;Lo;0;R;;;;;N;;;;;\n109AF;MEROITIC CURSIVE LETTER SA;Lo;0;R;;;;;N;;;;;\n109B0;MEROITIC CURSIVE LETTER ARCHAIC SA;Lo;0;R;;;;;N;;;;;\n109B1;MEROITIC CURSIVE LETTER SE;Lo;0;R;;;;;N;;;;;\n109B2;MEROITIC CURSIVE LETTER KA;Lo;0;R;;;;;N;;;;;\n109B3;MEROITIC CURSIVE LETTER QA;Lo;0;R;;;;;N;;;;;\n109B4;MEROITIC CURSIVE LETTER TA;Lo;0;R;;;;;N;;;;;\n109B5;MEROITIC CURSIVE LETTER TE;Lo;0;R;;;;;N;;;;;\n109B6;MEROITIC CURSIVE LETTER TO;Lo;0;R;;;;;N;;;;;\n109B7;MEROITIC CURSIVE LETTER DA;Lo;0;R;;;;;N;;;;;\n109BE;MEROITIC CURSIVE LOGOGRAM RMT;Lo;0;R;;;;;N;;;;;\n109BF;MEROITIC CURSIVE LOGOGRAM IMN;Lo;0;R;;;;;N;;;;;\n10A00;KHAROSHTHI LETTER A;Lo;0;R;;;;;N;;;;;\n10A01;KHAROSHTHI VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n10A02;KHAROSHTHI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n10A03;KHAROSHTHI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n10A05;KHAROSHTHI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n10A06;KHAROSHTHI VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n10A0C;KHAROSHTHI VOWEL LENGTH MARK;Mn;0;NSM;;;;;N;;;;;\n10A0D;KHAROSHTHI SIGN DOUBLE RING BELOW;Mn;220;NSM;;;;;N;;;;;\n10A0E;KHAROSHTHI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n10A0F;KHAROSHTHI SIGN VISARGA;Mn;230;NSM;;;;;N;;;;;\n10A10;KHAROSHTHI LETTER KA;Lo;0;R;;;;;N;;;;;\n10A11;KHAROSHTHI LETTER KHA;Lo;0;R;;;;;N;;;;;\n10A12;KHAROSHTHI LETTER GA;Lo;0;R;;;;;N;;;;;\n10A13;KHAROSHTHI LETTER GHA;Lo;0;R;;;;;N;;;;;\n10A15;KHAROSHTHI LETTER CA;Lo;0;R;;;;;N;;;;;\n10A16;KHAROSHTHI LETTER CHA;Lo;0;R;;;;;N;;;;;\n10A17;KHAROSHTHI LETTER JA;Lo;0;R;;;;;N;;;;;\n10A19;KHAROSHTHI LETTER NYA;Lo;0;R;;;;;N;;;;;\n10A1A;KHAROSHTHI LETTER TTA;Lo;0;R;;;;;N;;;;;\n10A1B;KHAROSHTHI LETTER TTHA;Lo;0;R;;;;;N;;;;;\n10A1C;KHAROSHTHI LETTER DDA;Lo;0;R;;;;;N;;;;;\n10A1D;KHAROSHTHI LETTER DDHA;Lo;0;R;;;;;N;;;;;\n10A1E;KHAROSHTHI LETTER NNA;Lo;0;R;;;;;N;;;;;\n10A1F;KHAROSHTHI LETTER TA;Lo;0;R;;;;;N;;;;;\n10A20;KHAROSHTHI LETTER THA;Lo;0;R;;;;;N;;;;;\n10A21;KHAROSHTHI LETTER DA;Lo;0;R;;;;;N;;;;;\n10A22;KHAROSHTHI LETTER DHA;Lo;0;R;;;;;N;;;;;\n10A23;KHAROSHTHI LETTER NA;Lo;0;R;;;;;N;;;;;\n10A24;KHAROSHTHI LETTER PA;Lo;0;R;;;;;N;;;;;\n10A25;KHAROSHTHI LETTER PHA;Lo;0;R;;;;;N;;;;;\n10A26;KHAROSHTHI LETTER BA;Lo;0;R;;;;;N;;;;;\n10A27;KHAROSHTHI LETTER BHA;Lo;0;R;;;;;N;;;;;\n10A28;KHAROSHTHI LETTER MA;Lo;0;R;;;;;N;;;;;\n10A29;KHAROSHTHI LETTER YA;Lo;0;R;;;;;N;;;;;\n10A2A;KHAROSHTHI LETTER RA;Lo;0;R;;;;;N;;;;;\n10A2B;KHAROSHTHI LETTER LA;Lo;0;R;;;;;N;;;;;\n10A2C;KHAROSHTHI LETTER VA;Lo;0;R;;;;;N;;;;;\n10A2D;KHAROSHTHI LETTER SHA;Lo;0;R;;;;;N;;;;;\n10A2E;KHAROSHTHI LETTER SSA;Lo;0;R;;;;;N;;;;;\n10A2F;KHAROSHTHI LETTER SA;Lo;0;R;;;;;N;;;;;\n10A30;KHAROSHTHI LETTER ZA;Lo;0;R;;;;;N;;;;;\n10A31;KHAROSHTHI LETTER HA;Lo;0;R;;;;;N;;;;;\n10A32;KHAROSHTHI LETTER KKA;Lo;0;R;;;;;N;;;;;\n10A33;KHAROSHTHI LETTER TTTHA;Lo;0;R;;;;;N;;;;;\n10A38;KHAROSHTHI SIGN BAR ABOVE;Mn;230;NSM;;;;;N;;;;;\n10A39;KHAROSHTHI SIGN CAUDA;Mn;1;NSM;;;;;N;;;;;\n10A3A;KHAROSHTHI SIGN DOT BELOW;Mn;220;NSM;;;;;N;;;;;\n10A3F;KHAROSHTHI VIRAMA;Mn;9;NSM;;;;;N;;;;;\n10A40;KHAROSHTHI DIGIT ONE;No;0;R;;;1;1;N;;;;;\n10A41;KHAROSHTHI DIGIT TWO;No;0;R;;;2;2;N;;;;;\n10A42;KHAROSHTHI DIGIT THREE;No;0;R;;;3;3;N;;;;;\n10A43;KHAROSHTHI DIGIT FOUR;No;0;R;;;4;4;N;;;;;\n10A44;KHAROSHTHI NUMBER TEN;No;0;R;;;;10;N;;;;;\n10A45;KHAROSHTHI NUMBER TWENTY;No;0;R;;;;20;N;;;;;\n10A46;KHAROSHTHI NUMBER ONE HUNDRED;No;0;R;;;;100;N;;;;;\n10A47;KHAROSHTHI NUMBER ONE THOUSAND;No;0;R;;;;1000;N;;;;;\n10A50;KHAROSHTHI PUNCTUATION DOT;Po;0;R;;;;;N;;;;;\n10A51;KHAROSHTHI PUNCTUATION SMALL CIRCLE;Po;0;R;;;;;N;;;;;\n10A52;KHAROSHTHI PUNCTUATION CIRCLE;Po;0;R;;;;;N;;;;;\n10A53;KHAROSHTHI PUNCTUATION CRESCENT BAR;Po;0;R;;;;;N;;;;;\n10A54;KHAROSHTHI PUNCTUATION MANGALAM;Po;0;R;;;;;N;;;;;\n10A55;KHAROSHTHI PUNCTUATION LOTUS;Po;0;R;;;;;N;;;;;\n10A56;KHAROSHTHI PUNCTUATION DANDA;Po;0;R;;;;;N;;;;;\n10A57;KHAROSHTHI PUNCTUATION DOUBLE DANDA;Po;0;R;;;;;N;;;;;\n10A58;KHAROSHTHI PUNCTUATION LINES;Po;0;R;;;;;N;;;;;\n10A60;OLD SOUTH ARABIAN LETTER HE;Lo;0;R;;;;;N;;;;;\n10A61;OLD SOUTH ARABIAN LETTER LAMEDH;Lo;0;R;;;;;N;;;;;\n10A62;OLD SOUTH ARABIAN LETTER HETH;Lo;0;R;;;;;N;;;;;\n10A63;OLD SOUTH ARABIAN LETTER MEM;Lo;0;R;;;;;N;;;;;\n10A64;OLD SOUTH ARABIAN LETTER QOPH;Lo;0;R;;;;;N;;;;;\n10A65;OLD SOUTH ARABIAN LETTER WAW;Lo;0;R;;;;;N;;;;;\n10A66;OLD SOUTH ARABIAN LETTER SHIN;Lo;0;R;;;;;N;;;;;\n10A67;OLD SOUTH ARABIAN LETTER RESH;Lo;0;R;;;;;N;;;;;\n10A68;OLD SOUTH ARABIAN LETTER BETH;Lo;0;R;;;;;N;;;;;\n10A69;OLD SOUTH ARABIAN LETTER TAW;Lo;0;R;;;;;N;;;;;\n10A6A;OLD SOUTH ARABIAN LETTER SAT;Lo;0;R;;;;;N;;;;;\n10A6B;OLD SOUTH ARABIAN LETTER KAPH;Lo;0;R;;;;;N;;;;;\n10A6C;OLD SOUTH ARABIAN LETTER NUN;Lo;0;R;;;;;N;;;;;\n10A6D;OLD SOUTH ARABIAN LETTER KHETH;Lo;0;R;;;;;N;;;;;\n10A6E;OLD SOUTH ARABIAN LETTER SADHE;Lo;0;R;;;;;N;;;;;\n10A6F;OLD SOUTH ARABIAN LETTER SAMEKH;Lo;0;R;;;;;N;;;;;\n10A70;OLD SOUTH ARABIAN LETTER FE;Lo;0;R;;;;;N;;;;;\n10A71;OLD SOUTH ARABIAN LETTER ALEF;Lo;0;R;;;;;N;;;;;\n10A72;OLD SOUTH ARABIAN LETTER AYN;Lo;0;R;;;;;N;;;;;\n10A73;OLD SOUTH ARABIAN LETTER DHADHE;Lo;0;R;;;;;N;;;;;\n10A74;OLD SOUTH ARABIAN LETTER GIMEL;Lo;0;R;;;;;N;;;;;\n10A75;OLD SOUTH ARABIAN LETTER DALETH;Lo;0;R;;;;;N;;;;;\n10A76;OLD SOUTH ARABIAN LETTER GHAYN;Lo;0;R;;;;;N;;;;;\n10A77;OLD SOUTH ARABIAN LETTER TETH;Lo;0;R;;;;;N;;;;;\n10A78;OLD SOUTH ARABIAN LETTER ZAYN;Lo;0;R;;;;;N;;;;;\n10A79;OLD SOUTH ARABIAN LETTER DHALETH;Lo;0;R;;;;;N;;;;;\n10A7A;OLD SOUTH ARABIAN LETTER YODH;Lo;0;R;;;;;N;;;;;\n10A7B;OLD SOUTH ARABIAN LETTER THAW;Lo;0;R;;;;;N;;;;;\n10A7C;OLD SOUTH ARABIAN LETTER THETH;Lo;0;R;;;;;N;;;;;\n10A7D;OLD SOUTH ARABIAN NUMBER ONE;No;0;R;;;;1;N;;;;;\n10A7E;OLD SOUTH ARABIAN NUMBER FIFTY;No;0;R;;;;50;N;;;;;\n10A7F;OLD SOUTH ARABIAN NUMERIC INDICATOR;Po;0;R;;;;;N;;;;;\n10B00;AVESTAN LETTER A;Lo;0;R;;;;;N;;;;;\n10B01;AVESTAN LETTER AA;Lo;0;R;;;;;N;;;;;\n10B02;AVESTAN LETTER AO;Lo;0;R;;;;;N;;;;;\n10B03;AVESTAN LETTER AAO;Lo;0;R;;;;;N;;;;;\n10B04;AVESTAN LETTER AN;Lo;0;R;;;;;N;;;;;\n10B05;AVESTAN LETTER AAN;Lo;0;R;;;;;N;;;;;\n10B06;AVESTAN LETTER AE;Lo;0;R;;;;;N;;;;;\n10B07;AVESTAN LETTER AEE;Lo;0;R;;;;;N;;;;;\n10B08;AVESTAN LETTER E;Lo;0;R;;;;;N;;;;;\n10B09;AVESTAN LETTER EE;Lo;0;R;;;;;N;;;;;\n10B0A;AVESTAN LETTER O;Lo;0;R;;;;;N;;;;;\n10B0B;AVESTAN LETTER OO;Lo;0;R;;;;;N;;;;;\n10B0C;AVESTAN LETTER I;Lo;0;R;;;;;N;;;;;\n10B0D;AVESTAN LETTER II;Lo;0;R;;;;;N;;;;;\n10B0E;AVESTAN LETTER U;Lo;0;R;;;;;N;;;;;\n10B0F;AVESTAN LETTER UU;Lo;0;R;;;;;N;;;;;\n10B10;AVESTAN LETTER KE;Lo;0;R;;;;;N;;;;;\n10B11;AVESTAN LETTER XE;Lo;0;R;;;;;N;;;;;\n10B12;AVESTAN LETTER XYE;Lo;0;R;;;;;N;;;;;\n10B13;AVESTAN LETTER XVE;Lo;0;R;;;;;N;;;;;\n10B14;AVESTAN LETTER GE;Lo;0;R;;;;;N;;;;;\n10B15;AVESTAN LETTER GGE;Lo;0;R;;;;;N;;;;;\n10B16;AVESTAN LETTER GHE;Lo;0;R;;;;;N;;;;;\n10B17;AVESTAN LETTER CE;Lo;0;R;;;;;N;;;;;\n10B18;AVESTAN LETTER JE;Lo;0;R;;;;;N;;;;;\n10B19;AVESTAN LETTER TE;Lo;0;R;;;;;N;;;;;\n10B1A;AVESTAN LETTER THE;Lo;0;R;;;;;N;;;;;\n10B1B;AVESTAN LETTER DE;Lo;0;R;;;;;N;;;;;\n10B1C;AVESTAN LETTER DHE;Lo;0;R;;;;;N;;;;;\n10B1D;AVESTAN LETTER TTE;Lo;0;R;;;;;N;;;;;\n10B1E;AVESTAN LETTER PE;Lo;0;R;;;;;N;;;;;\n10B1F;AVESTAN LETTER FE;Lo;0;R;;;;;N;;;;;\n10B20;AVESTAN LETTER BE;Lo;0;R;;;;;N;;;;;\n10B21;AVESTAN LETTER BHE;Lo;0;R;;;;;N;;;;;\n10B22;AVESTAN LETTER NGE;Lo;0;R;;;;;N;;;;;\n10B23;AVESTAN LETTER NGYE;Lo;0;R;;;;;N;;;;;\n10B24;AVESTAN LETTER NGVE;Lo;0;R;;;;;N;;;;;\n10B25;AVESTAN LETTER NE;Lo;0;R;;;;;N;;;;;\n10B26;AVESTAN LETTER NYE;Lo;0;R;;;;;N;;;;;\n10B27;AVESTAN LETTER NNE;Lo;0;R;;;;;N;;;;;\n10B28;AVESTAN LETTER ME;Lo;0;R;;;;;N;;;;;\n10B29;AVESTAN LETTER HME;Lo;0;R;;;;;N;;;;;\n10B2A;AVESTAN LETTER YYE;Lo;0;R;;;;;N;;;;;\n10B2B;AVESTAN LETTER YE;Lo;0;R;;;;;N;;;;;\n10B2C;AVESTAN LETTER VE;Lo;0;R;;;;;N;;;;;\n10B2D;AVESTAN LETTER RE;Lo;0;R;;;;;N;;;;;\n10B2E;AVESTAN LETTER LE;Lo;0;R;;;;;N;;;;;\n10B2F;AVESTAN LETTER SE;Lo;0;R;;;;;N;;;;;\n10B30;AVESTAN LETTER ZE;Lo;0;R;;;;;N;;;;;\n10B31;AVESTAN LETTER SHE;Lo;0;R;;;;;N;;;;;\n10B32;AVESTAN LETTER ZHE;Lo;0;R;;;;;N;;;;;\n10B33;AVESTAN LETTER SHYE;Lo;0;R;;;;;N;;;;;\n10B34;AVESTAN LETTER SSHE;Lo;0;R;;;;;N;;;;;\n10B35;AVESTAN LETTER HE;Lo;0;R;;;;;N;;;;;\n10B39;AVESTAN ABBREVIATION MARK;Po;0;ON;;;;;N;;;;;\n10B3A;TINY TWO DOTS OVER ONE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B3B;SMALL TWO DOTS OVER ONE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B3C;LARGE TWO DOTS OVER ONE DOT PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B3D;LARGE ONE DOT OVER TWO DOTS PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B3E;LARGE TWO RINGS OVER ONE RING PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B3F;LARGE ONE RING OVER TWO RINGS PUNCTUATION;Po;0;ON;;;;;N;;;;;\n10B40;INSCRIPTIONAL PARTHIAN LETTER ALEPH;Lo;0;R;;;;;N;;;;;\n10B41;INSCRIPTIONAL PARTHIAN LETTER BETH;Lo;0;R;;;;;N;;;;;\n10B42;INSCRIPTIONAL PARTHIAN LETTER GIMEL;Lo;0;R;;;;;N;;;;;\n10B43;INSCRIPTIONAL PARTHIAN LETTER DALETH;Lo;0;R;;;;;N;;;;;\n10B44;INSCRIPTIONAL PARTHIAN LETTER HE;Lo;0;R;;;;;N;;;;;\n10B45;INSCRIPTIONAL PARTHIAN LETTER WAW;Lo;0;R;;;;;N;;;;;\n10B46;INSCRIPTIONAL PARTHIAN LETTER ZAYIN;Lo;0;R;;;;;N;;;;;\n10B47;INSCRIPTIONAL PARTHIAN LETTER HETH;Lo;0;R;;;;;N;;;;;\n10B48;INSCRIPTIONAL PARTHIAN LETTER TETH;Lo;0;R;;;;;N;;;;;\n10B49;INSCRIPTIONAL PARTHIAN LETTER YODH;Lo;0;R;;;;;N;;;;;\n10B4A;INSCRIPTIONAL PARTHIAN LETTER KAPH;Lo;0;R;;;;;N;;;;;\n10B4B;INSCRIPTIONAL PARTHIAN LETTER LAMEDH;Lo;0;R;;;;;N;;;;;\n10B4C;INSCRIPTIONAL PARTHIAN LETTER MEM;Lo;0;R;;;;;N;;;;;\n10B4D;INSCRIPTIONAL PARTHIAN LETTER NUN;Lo;0;R;;;;;N;;;;;\n10B4E;INSCRIPTIONAL PARTHIAN LETTER SAMEKH;Lo;0;R;;;;;N;;;;;\n10B4F;INSCRIPTIONAL PARTHIAN LETTER AYIN;Lo;0;R;;;;;N;;;;;\n10B50;INSCRIPTIONAL PARTHIAN LETTER PE;Lo;0;R;;;;;N;;;;;\n10B51;INSCRIPTIONAL PARTHIAN LETTER SADHE;Lo;0;R;;;;;N;;;;;\n10B52;INSCRIPTIONAL PARTHIAN LETTER QOPH;Lo;0;R;;;;;N;;;;;\n10B53;INSCRIPTIONAL PARTHIAN LETTER RESH;Lo;0;R;;;;;N;;;;;\n10B54;INSCRIPTIONAL PARTHIAN LETTER SHIN;Lo;0;R;;;;;N;;;;;\n10B55;INSCRIPTIONAL PARTHIAN LETTER TAW;Lo;0;R;;;;;N;;;;;\n10B58;INSCRIPTIONAL PARTHIAN NUMBER ONE;No;0;R;;;;1;N;;;;;\n10B59;INSCRIPTIONAL PARTHIAN NUMBER TWO;No;0;R;;;;2;N;;;;;\n10B5A;INSCRIPTIONAL PARTHIAN NUMBER THREE;No;0;R;;;;3;N;;;;;\n10B5B;INSCRIPTIONAL PARTHIAN NUMBER FOUR;No;0;R;;;;4;N;;;;;\n10B5C;INSCRIPTIONAL PARTHIAN NUMBER TEN;No;0;R;;;;10;N;;;;;\n10B5D;INSCRIPTIONAL PARTHIAN NUMBER TWENTY;No;0;R;;;;20;N;;;;;\n10B5E;INSCRIPTIONAL PARTHIAN NUMBER ONE HUNDRED;No;0;R;;;;100;N;;;;;\n10B5F;INSCRIPTIONAL PARTHIAN NUMBER ONE THOUSAND;No;0;R;;;;1000;N;;;;;\n10B60;INSCRIPTIONAL PAHLAVI LETTER ALEPH;Lo;0;R;;;;;N;;;;;\n10B61;INSCRIPTIONAL PAHLAVI LETTER BETH;Lo;0;R;;;;;N;;;;;\n10B62;INSCRIPTIONAL PAHLAVI LETTER GIMEL;Lo;0;R;;;;;N;;;;;\n10B63;INSCRIPTIONAL PAHLAVI LETTER DALETH;Lo;0;R;;;;;N;;;;;\n10B64;INSCRIPTIONAL PAHLAVI LETTER HE;Lo;0;R;;;;;N;;;;;\n10B65;INSCRIPTIONAL PAHLAVI LETTER WAW-AYIN-RESH;Lo;0;R;;;;;N;;;;;\n10B66;INSCRIPTIONAL PAHLAVI LETTER ZAYIN;Lo;0;R;;;;;N;;;;;\n10B67;INSCRIPTIONAL PAHLAVI LETTER HETH;Lo;0;R;;;;;N;;;;;\n10B68;INSCRIPTIONAL PAHLAVI LETTER TETH;Lo;0;R;;;;;N;;;;;\n10B69;INSCRIPTIONAL PAHLAVI LETTER YODH;Lo;0;R;;;;;N;;;;;\n10B6A;INSCRIPTIONAL PAHLAVI LETTER KAPH;Lo;0;R;;;;;N;;;;;\n10B6B;INSCRIPTIONAL PAHLAVI LETTER LAMEDH;Lo;0;R;;;;;N;;;;;\n10B6C;INSCRIPTIONAL PAHLAVI LETTER MEM-QOPH;Lo;0;R;;;;;N;;;;;\n10B6D;INSCRIPTIONAL PAHLAVI LETTER NUN;Lo;0;R;;;;;N;;;;;\n10B6E;INSCRIPTIONAL PAHLAVI LETTER SAMEKH;Lo;0;R;;;;;N;;;;;\n10B6F;INSCRIPTIONAL PAHLAVI LETTER PE;Lo;0;R;;;;;N;;;;;\n10B70;INSCRIPTIONAL PAHLAVI LETTER SADHE;Lo;0;R;;;;;N;;;;;\n10B71;INSCRIPTIONAL PAHLAVI LETTER SHIN;Lo;0;R;;;;;N;;;;;\n10B72;INSCRIPTIONAL PAHLAVI LETTER TAW;Lo;0;R;;;;;N;;;;;\n10B78;INSCRIPTIONAL PAHLAVI NUMBER ONE;No;0;R;;;;1;N;;;;;\n10B79;INSCRIPTIONAL PAHLAVI NUMBER TWO;No;0;R;;;;2;N;;;;;\n10B7A;INSCRIPTIONAL PAHLAVI NUMBER THREE;No;0;R;;;;3;N;;;;;\n10B7B;INSCRIPTIONAL PAHLAVI NUMBER FOUR;No;0;R;;;;4;N;;;;;\n10B7C;INSCRIPTIONAL PAHLAVI NUMBER TEN;No;0;R;;;;10;N;;;;;\n10B7D;INSCRIPTIONAL PAHLAVI NUMBER TWENTY;No;0;R;;;;20;N;;;;;\n10B7E;INSCRIPTIONAL PAHLAVI NUMBER ONE HUNDRED;No;0;R;;;;100;N;;;;;\n10B7F;INSCRIPTIONAL PAHLAVI NUMBER ONE THOUSAND;No;0;R;;;;1000;N;;;;;\n10C00;OLD TURKIC LETTER ORKHON A;Lo;0;R;;;;;N;;;;;\n10C01;OLD TURKIC LETTER YENISEI A;Lo;0;R;;;;;N;;;;;\n10C02;OLD TURKIC LETTER YENISEI AE;Lo;0;R;;;;;N;;;;;\n10C03;OLD TURKIC LETTER ORKHON I;Lo;0;R;;;;;N;;;;;\n10C04;OLD TURKIC LETTER YENISEI I;Lo;0;R;;;;;N;;;;;\n10C05;OLD TURKIC LETTER YENISEI E;Lo;0;R;;;;;N;;;;;\n10C06;OLD TURKIC LETTER ORKHON O;Lo;0;R;;;;;N;;;;;\n10C07;OLD TURKIC LETTER ORKHON OE;Lo;0;R;;;;;N;;;;;\n10C08;OLD TURKIC LETTER YENISEI OE;Lo;0;R;;;;;N;;;;;\n10C09;OLD TURKIC LETTER ORKHON AB;Lo;0;R;;;;;N;;;;;\n10C0A;OLD TURKIC LETTER YENISEI AB;Lo;0;R;;;;;N;;;;;\n10C0B;OLD TURKIC LETTER ORKHON AEB;Lo;0;R;;;;;N;;;;;\n10C0C;OLD TURKIC LETTER YENISEI AEB;Lo;0;R;;;;;N;;;;;\n10C0D;OLD TURKIC LETTER ORKHON AG;Lo;0;R;;;;;N;;;;;\n10C0E;OLD TURKIC LETTER YENISEI AG;Lo;0;R;;;;;N;;;;;\n10C0F;OLD TURKIC LETTER ORKHON AEG;Lo;0;R;;;;;N;;;;;\n10C10;OLD TURKIC LETTER YENISEI AEG;Lo;0;R;;;;;N;;;;;\n10C11;OLD TURKIC LETTER ORKHON AD;Lo;0;R;;;;;N;;;;;\n10C12;OLD TURKIC LETTER YENISEI AD;Lo;0;R;;;;;N;;;;;\n10C13;OLD TURKIC LETTER ORKHON AED;Lo;0;R;;;;;N;;;;;\n10C14;OLD TURKIC LETTER ORKHON EZ;Lo;0;R;;;;;N;;;;;\n10C15;OLD TURKIC LETTER YENISEI EZ;Lo;0;R;;;;;N;;;;;\n10C16;OLD TURKIC LETTER ORKHON AY;Lo;0;R;;;;;N;;;;;\n10C17;OLD TURKIC LETTER YENISEI AY;Lo;0;R;;;;;N;;;;;\n10C18;OLD TURKIC LETTER ORKHON AEY;Lo;0;R;;;;;N;;;;;\n10C19;OLD TURKIC LETTER YENISEI AEY;Lo;0;R;;;;;N;;;;;\n10C1A;OLD TURKIC LETTER ORKHON AEK;Lo;0;R;;;;;N;;;;;\n10C1B;OLD TURKIC LETTER YENISEI AEK;Lo;0;R;;;;;N;;;;;\n10C1C;OLD TURKIC LETTER ORKHON OEK;Lo;0;R;;;;;N;;;;;\n10C1D;OLD TURKIC LETTER YENISEI OEK;Lo;0;R;;;;;N;;;;;\n10C1E;OLD TURKIC LETTER ORKHON AL;Lo;0;R;;;;;N;;;;;\n10C1F;OLD TURKIC LETTER YENISEI AL;Lo;0;R;;;;;N;;;;;\n10C20;OLD TURKIC LETTER ORKHON AEL;Lo;0;R;;;;;N;;;;;\n10C21;OLD TURKIC LETTER ORKHON ELT;Lo;0;R;;;;;N;;;;;\n10C22;OLD TURKIC LETTER ORKHON EM;Lo;0;R;;;;;N;;;;;\n10C23;OLD TURKIC LETTER ORKHON AN;Lo;0;R;;;;;N;;;;;\n10C24;OLD TURKIC LETTER ORKHON AEN;Lo;0;R;;;;;N;;;;;\n10C25;OLD TURKIC LETTER YENISEI AEN;Lo;0;R;;;;;N;;;;;\n10C26;OLD TURKIC LETTER ORKHON ENT;Lo;0;R;;;;;N;;;;;\n10C27;OLD TURKIC LETTER YENISEI ENT;Lo;0;R;;;;;N;;;;;\n10C28;OLD TURKIC LETTER ORKHON ENC;Lo;0;R;;;;;N;;;;;\n10C29;OLD TURKIC LETTER YENISEI ENC;Lo;0;R;;;;;N;;;;;\n10C2A;OLD TURKIC LETTER ORKHON ENY;Lo;0;R;;;;;N;;;;;\n10C2B;OLD TURKIC LETTER YENISEI ENY;Lo;0;R;;;;;N;;;;;\n10C2C;OLD TURKIC LETTER YENISEI ANG;Lo;0;R;;;;;N;;;;;\n10C2D;OLD TURKIC LETTER ORKHON ENG;Lo;0;R;;;;;N;;;;;\n10C2E;OLD TURKIC LETTER YENISEI AENG;Lo;0;R;;;;;N;;;;;\n10C2F;OLD TURKIC LETTER ORKHON EP;Lo;0;R;;;;;N;;;;;\n10C30;OLD TURKIC LETTER ORKHON OP;Lo;0;R;;;;;N;;;;;\n10C31;OLD TURKIC LETTER ORKHON IC;Lo;0;R;;;;;N;;;;;\n10C32;OLD TURKIC LETTER ORKHON EC;Lo;0;R;;;;;N;;;;;\n10C33;OLD TURKIC LETTER YENISEI EC;Lo;0;R;;;;;N;;;;;\n10C34;OLD TURKIC LETTER ORKHON AQ;Lo;0;R;;;;;N;;;;;\n10C35;OLD TURKIC LETTER YENISEI AQ;Lo;0;R;;;;;N;;;;;\n10C36;OLD TURKIC LETTER ORKHON IQ;Lo;0;R;;;;;N;;;;;\n10C37;OLD TURKIC LETTER YENISEI IQ;Lo;0;R;;;;;N;;;;;\n10C38;OLD TURKIC LETTER ORKHON OQ;Lo;0;R;;;;;N;;;;;\n10C39;OLD TURKIC LETTER YENISEI OQ;Lo;0;R;;;;;N;;;;;\n10C3A;OLD TURKIC LETTER ORKHON AR;Lo;0;R;;;;;N;;;;;\n10C3B;OLD TURKIC LETTER YENISEI AR;Lo;0;R;;;;;N;;;;;\n10C3C;OLD TURKIC LETTER ORKHON AER;Lo;0;R;;;;;N;;;;;\n10C3D;OLD TURKIC LETTER ORKHON AS;Lo;0;R;;;;;N;;;;;\n10C3E;OLD TURKIC LETTER ORKHON AES;Lo;0;R;;;;;N;;;;;\n10C3F;OLD TURKIC LETTER ORKHON ASH;Lo;0;R;;;;;N;;;;;\n10C40;OLD TURKIC LETTER YENISEI ASH;Lo;0;R;;;;;N;;;;;\n10C41;OLD TURKIC LETTER ORKHON ESH;Lo;0;R;;;;;N;;;;;\n10C42;OLD TURKIC LETTER YENISEI ESH;Lo;0;R;;;;;N;;;;;\n10C43;OLD TURKIC LETTER ORKHON AT;Lo;0;R;;;;;N;;;;;\n10C44;OLD TURKIC LETTER YENISEI AT;Lo;0;R;;;;;N;;;;;\n10C45;OLD TURKIC LETTER ORKHON AET;Lo;0;R;;;;;N;;;;;\n10C46;OLD TURKIC LETTER YENISEI AET;Lo;0;R;;;;;N;;;;;\n10C47;OLD TURKIC LETTER ORKHON OT;Lo;0;R;;;;;N;;;;;\n10C48;OLD TURKIC LETTER ORKHON BASH;Lo;0;R;;;;;N;;;;;\n10E60;RUMI DIGIT ONE;No;0;AN;;;1;1;N;;;;;\n10E61;RUMI DIGIT TWO;No;0;AN;;;2;2;N;;;;;\n10E62;RUMI DIGIT THREE;No;0;AN;;;3;3;N;;;;;\n10E63;RUMI DIGIT FOUR;No;0;AN;;;4;4;N;;;;;\n10E64;RUMI DIGIT FIVE;No;0;AN;;;5;5;N;;;;;\n10E65;RUMI DIGIT SIX;No;0;AN;;;6;6;N;;;;;\n10E66;RUMI DIGIT SEVEN;No;0;AN;;;7;7;N;;;;;\n10E67;RUMI DIGIT EIGHT;No;0;AN;;;8;8;N;;;;;\n10E68;RUMI DIGIT NINE;No;0;AN;;;9;9;N;;;;;\n10E69;RUMI NUMBER TEN;No;0;AN;;;;10;N;;;;;\n10E6A;RUMI NUMBER TWENTY;No;0;AN;;;;20;N;;;;;\n10E6B;RUMI NUMBER THIRTY;No;0;AN;;;;30;N;;;;;\n10E6C;RUMI NUMBER FORTY;No;0;AN;;;;40;N;;;;;\n10E6D;RUMI NUMBER FIFTY;No;0;AN;;;;50;N;;;;;\n10E6E;RUMI NUMBER SIXTY;No;0;AN;;;;60;N;;;;;\n10E6F;RUMI NUMBER SEVENTY;No;0;AN;;;;70;N;;;;;\n10E70;RUMI NUMBER EIGHTY;No;0;AN;;;;80;N;;;;;\n10E71;RUMI NUMBER NINETY;No;0;AN;;;;90;N;;;;;\n10E72;RUMI NUMBER ONE HUNDRED;No;0;AN;;;;100;N;;;;;\n10E73;RUMI NUMBER TWO HUNDRED;No;0;AN;;;;200;N;;;;;\n10E74;RUMI NUMBER THREE HUNDRED;No;0;AN;;;;300;N;;;;;\n10E75;RUMI NUMBER FOUR HUNDRED;No;0;AN;;;;400;N;;;;;\n10E76;RUMI NUMBER FIVE HUNDRED;No;0;AN;;;;500;N;;;;;\n10E77;RUMI NUMBER SIX HUNDRED;No;0;AN;;;;600;N;;;;;\n10E78;RUMI NUMBER SEVEN HUNDRED;No;0;AN;;;;700;N;;;;;\n10E79;RUMI NUMBER EIGHT HUNDRED;No;0;AN;;;;800;N;;;;;\n10E7A;RUMI NUMBER NINE HUNDRED;No;0;AN;;;;900;N;;;;;\n10E7B;RUMI FRACTION ONE HALF;No;0;AN;;;;1/2;N;;;;;\n10E7C;RUMI FRACTION ONE QUARTER;No;0;AN;;;;1/4;N;;;;;\n10E7D;RUMI FRACTION ONE THIRD;No;0;AN;;;;1/3;N;;;;;\n10E7E;RUMI FRACTION TWO THIRDS;No;0;AN;;;;2/3;N;;;;;\n11000;BRAHMI SIGN CANDRABINDU;Mc;0;L;;;;;N;;;;;\n11001;BRAHMI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n11002;BRAHMI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n11003;BRAHMI SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;\n11004;BRAHMI SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;\n11005;BRAHMI LETTER A;Lo;0;L;;;;;N;;;;;\n11006;BRAHMI LETTER AA;Lo;0;L;;;;;N;;;;;\n11007;BRAHMI LETTER I;Lo;0;L;;;;;N;;;;;\n11008;BRAHMI LETTER II;Lo;0;L;;;;;N;;;;;\n11009;BRAHMI LETTER U;Lo;0;L;;;;;N;;;;;\n1100A;BRAHMI LETTER UU;Lo;0;L;;;;;N;;;;;\n1100B;BRAHMI LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n1100C;BRAHMI LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n1100D;BRAHMI LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n1100E;BRAHMI LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n1100F;BRAHMI LETTER E;Lo;0;L;;;;;N;;;;;\n11010;BRAHMI LETTER AI;Lo;0;L;;;;;N;;;;;\n11011;BRAHMI LETTER O;Lo;0;L;;;;;N;;;;;\n11012;BRAHMI LETTER AU;Lo;0;L;;;;;N;;;;;\n11013;BRAHMI LETTER KA;Lo;0;L;;;;;N;;;;;\n11014;BRAHMI LETTER KHA;Lo;0;L;;;;;N;;;;;\n11015;BRAHMI LETTER GA;Lo;0;L;;;;;N;;;;;\n11016;BRAHMI LETTER GHA;Lo;0;L;;;;;N;;;;;\n11017;BRAHMI LETTER NGA;Lo;0;L;;;;;N;;;;;\n11018;BRAHMI LETTER CA;Lo;0;L;;;;;N;;;;;\n11019;BRAHMI LETTER CHA;Lo;0;L;;;;;N;;;;;\n1101A;BRAHMI LETTER JA;Lo;0;L;;;;;N;;;;;\n1101B;BRAHMI LETTER JHA;Lo;0;L;;;;;N;;;;;\n1101C;BRAHMI LETTER NYA;Lo;0;L;;;;;N;;;;;\n1101D;BRAHMI LETTER TTA;Lo;0;L;;;;;N;;;;;\n1101E;BRAHMI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n1101F;BRAHMI LETTER DDA;Lo;0;L;;;;;N;;;;;\n11020;BRAHMI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n11021;BRAHMI LETTER NNA;Lo;0;L;;;;;N;;;;;\n11022;BRAHMI LETTER TA;Lo;0;L;;;;;N;;;;;\n11023;BRAHMI LETTER THA;Lo;0;L;;;;;N;;;;;\n11024;BRAHMI LETTER DA;Lo;0;L;;;;;N;;;;;\n11025;BRAHMI LETTER DHA;Lo;0;L;;;;;N;;;;;\n11026;BRAHMI LETTER NA;Lo;0;L;;;;;N;;;;;\n11027;BRAHMI LETTER PA;Lo;0;L;;;;;N;;;;;\n11028;BRAHMI LETTER PHA;Lo;0;L;;;;;N;;;;;\n11029;BRAHMI LETTER BA;Lo;0;L;;;;;N;;;;;\n1102A;BRAHMI LETTER BHA;Lo;0;L;;;;;N;;;;;\n1102B;BRAHMI LETTER MA;Lo;0;L;;;;;N;;;;;\n1102C;BRAHMI LETTER YA;Lo;0;L;;;;;N;;;;;\n1102D;BRAHMI LETTER RA;Lo;0;L;;;;;N;;;;;\n1102E;BRAHMI LETTER LA;Lo;0;L;;;;;N;;;;;\n1102F;BRAHMI LETTER VA;Lo;0;L;;;;;N;;;;;\n11030;BRAHMI LETTER SHA;Lo;0;L;;;;;N;;;;;\n11031;BRAHMI LETTER SSA;Lo;0;L;;;;;N;;;;;\n11032;BRAHMI LETTER SA;Lo;0;L;;;;;N;;;;;\n11033;BRAHMI LETTER HA;Lo;0;L;;;;;N;;;;;\n11034;BRAHMI LETTER LLA;Lo;0;L;;;;;N;;;;;\n11035;BRAHMI LETTER OLD TAMIL LLLA;Lo;0;L;;;;;N;;;;;\n11036;BRAHMI LETTER OLD TAMIL RRA;Lo;0;L;;;;;N;;;;;\n11037;BRAHMI LETTER OLD TAMIL NNNA;Lo;0;L;;;;;N;;;;;\n11038;BRAHMI VOWEL SIGN AA;Mn;0;NSM;;;;;N;;;;;\n11039;BRAHMI VOWEL SIGN BHATTIPROLU AA;Mn;0;NSM;;;;;N;;;;;\n1103A;BRAHMI VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n1103B;BRAHMI VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n1103C;BRAHMI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1103D;BRAHMI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n1103E;BRAHMI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n1103F;BRAHMI VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n11040;BRAHMI VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n11041;BRAHMI VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n11042;BRAHMI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n11043;BRAHMI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n11044;BRAHMI VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n11045;BRAHMI VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\n11046;BRAHMI VIRAMA;Mn;9;NSM;;;;;N;;;;;\n11047;BRAHMI DANDA;Po;0;L;;;;;N;;;;;\n11048;BRAHMI DOUBLE DANDA;Po;0;L;;;;;N;;;;;\n11049;BRAHMI PUNCTUATION DOT;Po;0;L;;;;;N;;;;;\n1104A;BRAHMI PUNCTUATION DOUBLE DOT;Po;0;L;;;;;N;;;;;\n1104B;BRAHMI PUNCTUATION LINE;Po;0;L;;;;;N;;;;;\n1104C;BRAHMI PUNCTUATION CRESCENT BAR;Po;0;L;;;;;N;;;;;\n1104D;BRAHMI PUNCTUATION LOTUS;Po;0;L;;;;;N;;;;;\n11052;BRAHMI NUMBER ONE;No;0;ON;;;1;1;N;;;;;\n11053;BRAHMI NUMBER TWO;No;0;ON;;;2;2;N;;;;;\n11054;BRAHMI NUMBER THREE;No;0;ON;;;3;3;N;;;;;\n11055;BRAHMI NUMBER FOUR;No;0;ON;;;4;4;N;;;;;\n11056;BRAHMI NUMBER FIVE;No;0;ON;;;5;5;N;;;;;\n11057;BRAHMI NUMBER SIX;No;0;ON;;;6;6;N;;;;;\n11058;BRAHMI NUMBER SEVEN;No;0;ON;;;7;7;N;;;;;\n11059;BRAHMI NUMBER EIGHT;No;0;ON;;;8;8;N;;;;;\n1105A;BRAHMI NUMBER NINE;No;0;ON;;;9;9;N;;;;;\n1105B;BRAHMI NUMBER TEN;No;0;ON;;;;10;N;;;;;\n1105C;BRAHMI NUMBER TWENTY;No;0;ON;;;;20;N;;;;;\n1105D;BRAHMI NUMBER THIRTY;No;0;ON;;;;30;N;;;;;\n1105E;BRAHMI NUMBER FORTY;No;0;ON;;;;40;N;;;;;\n1105F;BRAHMI NUMBER FIFTY;No;0;ON;;;;50;N;;;;;\n11060;BRAHMI NUMBER SIXTY;No;0;ON;;;;60;N;;;;;\n11061;BRAHMI NUMBER SEVENTY;No;0;ON;;;;70;N;;;;;\n11062;BRAHMI NUMBER EIGHTY;No;0;ON;;;;80;N;;;;;\n11063;BRAHMI NUMBER NINETY;No;0;ON;;;;90;N;;;;;\n11064;BRAHMI NUMBER ONE HUNDRED;No;0;ON;;;;100;N;;;;;\n11065;BRAHMI NUMBER ONE THOUSAND;No;0;ON;;;;1000;N;;;;;\n11066;BRAHMI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n11067;BRAHMI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n11068;BRAHMI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n11069;BRAHMI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1106A;BRAHMI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1106B;BRAHMI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1106C;BRAHMI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1106D;BRAHMI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1106E;BRAHMI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1106F;BRAHMI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n11080;KAITHI SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n11081;KAITHI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n11082;KAITHI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n11083;KAITHI LETTER A;Lo;0;L;;;;;N;;;;;\n11084;KAITHI LETTER AA;Lo;0;L;;;;;N;;;;;\n11085;KAITHI LETTER I;Lo;0;L;;;;;N;;;;;\n11086;KAITHI LETTER II;Lo;0;L;;;;;N;;;;;\n11087;KAITHI LETTER U;Lo;0;L;;;;;N;;;;;\n11088;KAITHI LETTER UU;Lo;0;L;;;;;N;;;;;\n11089;KAITHI LETTER E;Lo;0;L;;;;;N;;;;;\n1108A;KAITHI LETTER AI;Lo;0;L;;;;;N;;;;;\n1108B;KAITHI LETTER O;Lo;0;L;;;;;N;;;;;\n1108C;KAITHI LETTER AU;Lo;0;L;;;;;N;;;;;\n1108D;KAITHI LETTER KA;Lo;0;L;;;;;N;;;;;\n1108E;KAITHI LETTER KHA;Lo;0;L;;;;;N;;;;;\n1108F;KAITHI LETTER GA;Lo;0;L;;;;;N;;;;;\n11090;KAITHI LETTER GHA;Lo;0;L;;;;;N;;;;;\n11091;KAITHI LETTER NGA;Lo;0;L;;;;;N;;;;;\n11092;KAITHI LETTER CA;Lo;0;L;;;;;N;;;;;\n11093;KAITHI LETTER CHA;Lo;0;L;;;;;N;;;;;\n11094;KAITHI LETTER JA;Lo;0;L;;;;;N;;;;;\n11095;KAITHI LETTER JHA;Lo;0;L;;;;;N;;;;;\n11096;KAITHI LETTER NYA;Lo;0;L;;;;;N;;;;;\n11097;KAITHI LETTER TTA;Lo;0;L;;;;;N;;;;;\n11098;KAITHI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n11099;KAITHI LETTER DDA;Lo;0;L;;;;;N;;;;;\n1109A;KAITHI LETTER DDDHA;Lo;0;L;11099 110BA;;;;N;;;;;\n1109B;KAITHI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n1109C;KAITHI LETTER RHA;Lo;0;L;1109B 110BA;;;;N;;;;;\n1109D;KAITHI LETTER NNA;Lo;0;L;;;;;N;;;;;\n1109E;KAITHI LETTER TA;Lo;0;L;;;;;N;;;;;\n1109F;KAITHI LETTER THA;Lo;0;L;;;;;N;;;;;\n110A0;KAITHI LETTER DA;Lo;0;L;;;;;N;;;;;\n110A1;KAITHI LETTER DHA;Lo;0;L;;;;;N;;;;;\n110A2;KAITHI LETTER NA;Lo;0;L;;;;;N;;;;;\n110A3;KAITHI LETTER PA;Lo;0;L;;;;;N;;;;;\n110A4;KAITHI LETTER PHA;Lo;0;L;;;;;N;;;;;\n110A5;KAITHI LETTER BA;Lo;0;L;;;;;N;;;;;\n110A6;KAITHI LETTER BHA;Lo;0;L;;;;;N;;;;;\n110A7;KAITHI LETTER MA;Lo;0;L;;;;;N;;;;;\n110A8;KAITHI LETTER YA;Lo;0;L;;;;;N;;;;;\n110A9;KAITHI LETTER RA;Lo;0;L;;;;;N;;;;;\n110AA;KAITHI LETTER LA;Lo;0;L;;;;;N;;;;;\n110AB;KAITHI LETTER VA;Lo;0;L;110A5 110BA;;;;N;;;;;\n110AC;KAITHI LETTER SHA;Lo;0;L;;;;;N;;;;;\n110AD;KAITHI LETTER SSA;Lo;0;L;;;;;N;;;;;\n110AE;KAITHI LETTER SA;Lo;0;L;;;;;N;;;;;\n110AF;KAITHI LETTER HA;Lo;0;L;;;;;N;;;;;\n110B0;KAITHI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n110B1;KAITHI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n110B2;KAITHI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n110B3;KAITHI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n110B4;KAITHI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n110B5;KAITHI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n110B6;KAITHI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n110B7;KAITHI VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n110B8;KAITHI VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n110B9;KAITHI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;\n110BA;KAITHI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n110BB;KAITHI ABBREVIATION SIGN;Po;0;L;;;;;N;;;;;\n110BC;KAITHI ENUMERATION SIGN;Po;0;L;;;;;N;;;;;\n110BD;KAITHI NUMBER SIGN;Cf;0;L;;;;;N;;;;;\n110BE;KAITHI SECTION MARK;Po;0;L;;;;;N;;;;;\n110BF;KAITHI DOUBLE SECTION MARK;Po;0;L;;;;;N;;;;;\n110C0;KAITHI DANDA;Po;0;L;;;;;N;;;;;\n110C1;KAITHI DOUBLE DANDA;Po;0;L;;;;;N;;;;;\n110D0;SORA SOMPENG LETTER SAH;Lo;0;L;;;;;N;;;;;\n110D1;SORA SOMPENG LETTER TAH;Lo;0;L;;;;;N;;;;;\n110D2;SORA SOMPENG LETTER BAH;Lo;0;L;;;;;N;;;;;\n110D3;SORA SOMPENG LETTER CAH;Lo;0;L;;;;;N;;;;;\n110D4;SORA SOMPENG LETTER DAH;Lo;0;L;;;;;N;;;;;\n110D5;SORA SOMPENG LETTER GAH;Lo;0;L;;;;;N;;;;;\n110D6;SORA SOMPENG LETTER MAH;Lo;0;L;;;;;N;;;;;\n110D7;SORA SOMPENG LETTER NGAH;Lo;0;L;;;;;N;;;;;\n110D8;SORA SOMPENG LETTER LAH;Lo;0;L;;;;;N;;;;;\n110D9;SORA SOMPENG LETTER NAH;Lo;0;L;;;;;N;;;;;\n110DA;SORA SOMPENG LETTER VAH;Lo;0;L;;;;;N;;;;;\n110DB;SORA SOMPENG LETTER PAH;Lo;0;L;;;;;N;;;;;\n110DC;SORA SOMPENG LETTER YAH;Lo;0;L;;;;;N;;;;;\n110DD;SORA SOMPENG LETTER RAH;Lo;0;L;;;;;N;;;;;\n110DE;SORA SOMPENG LETTER HAH;Lo;0;L;;;;;N;;;;;\n110DF;SORA SOMPENG LETTER KAH;Lo;0;L;;;;;N;;;;;\n110E0;SORA SOMPENG LETTER JAH;Lo;0;L;;;;;N;;;;;\n110E1;SORA SOMPENG LETTER NYAH;Lo;0;L;;;;;N;;;;;\n110E2;SORA SOMPENG LETTER AH;Lo;0;L;;;;;N;;;;;\n110E3;SORA SOMPENG LETTER EEH;Lo;0;L;;;;;N;;;;;\n110E4;SORA SOMPENG LETTER IH;Lo;0;L;;;;;N;;;;;\n110E5;SORA SOMPENG LETTER UH;Lo;0;L;;;;;N;;;;;\n110E6;SORA SOMPENG LETTER OH;Lo;0;L;;;;;N;;;;;\n110E7;SORA SOMPENG LETTER EH;Lo;0;L;;;;;N;;;;;\n110E8;SORA SOMPENG LETTER MAE;Lo;0;L;;;;;N;;;;;\n110F0;SORA SOMPENG DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n110F1;SORA SOMPENG DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n110F2;SORA SOMPENG DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n110F3;SORA SOMPENG DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n110F4;SORA SOMPENG DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n110F5;SORA SOMPENG DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n110F6;SORA SOMPENG DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n110F7;SORA SOMPENG DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n110F8;SORA SOMPENG DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n110F9;SORA SOMPENG DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n11100;CHAKMA SIGN CANDRABINDU;Mn;230;NSM;;;;;N;;;;;\n11101;CHAKMA SIGN ANUSVARA;Mn;230;NSM;;;;;N;;;;;\n11102;CHAKMA SIGN VISARGA;Mn;230;NSM;;;;;N;;;;;\n11103;CHAKMA LETTER AA;Lo;0;L;;;;;N;;;;;\n11104;CHAKMA LETTER I;Lo;0;L;;;;;N;;;;;\n11105;CHAKMA LETTER U;Lo;0;L;;;;;N;;;;;\n11106;CHAKMA LETTER E;Lo;0;L;;;;;N;;;;;\n11107;CHAKMA LETTER KAA;Lo;0;L;;;;;N;;;;;\n11108;CHAKMA LETTER KHAA;Lo;0;L;;;;;N;;;;;\n11109;CHAKMA LETTER GAA;Lo;0;L;;;;;N;;;;;\n1110A;CHAKMA LETTER GHAA;Lo;0;L;;;;;N;;;;;\n1110B;CHAKMA LETTER NGAA;Lo;0;L;;;;;N;;;;;\n1110C;CHAKMA LETTER CAA;Lo;0;L;;;;;N;;;;;\n1110D;CHAKMA LETTER CHAA;Lo;0;L;;;;;N;;;;;\n1110E;CHAKMA LETTER JAA;Lo;0;L;;;;;N;;;;;\n1110F;CHAKMA LETTER JHAA;Lo;0;L;;;;;N;;;;;\n11110;CHAKMA LETTER NYAA;Lo;0;L;;;;;N;;;;;\n11111;CHAKMA LETTER TTAA;Lo;0;L;;;;;N;;;;;\n11112;CHAKMA LETTER TTHAA;Lo;0;L;;;;;N;;;;;\n11113;CHAKMA LETTER DDAA;Lo;0;L;;;;;N;;;;;\n11114;CHAKMA LETTER DDHAA;Lo;0;L;;;;;N;;;;;\n11115;CHAKMA LETTER NNAA;Lo;0;L;;;;;N;;;;;\n11116;CHAKMA LETTER TAA;Lo;0;L;;;;;N;;;;;\n11117;CHAKMA LETTER THAA;Lo;0;L;;;;;N;;;;;\n11118;CHAKMA LETTER DAA;Lo;0;L;;;;;N;;;;;\n11119;CHAKMA LETTER DHAA;Lo;0;L;;;;;N;;;;;\n1111A;CHAKMA LETTER NAA;Lo;0;L;;;;;N;;;;;\n1111B;CHAKMA LETTER PAA;Lo;0;L;;;;;N;;;;;\n1111C;CHAKMA LETTER PHAA;Lo;0;L;;;;;N;;;;;\n1111D;CHAKMA LETTER BAA;Lo;0;L;;;;;N;;;;;\n1111E;CHAKMA LETTER BHAA;Lo;0;L;;;;;N;;;;;\n1111F;CHAKMA LETTER MAA;Lo;0;L;;;;;N;;;;;\n11120;CHAKMA LETTER YYAA;Lo;0;L;;;;;N;;;;;\n11121;CHAKMA LETTER YAA;Lo;0;L;;;;;N;;;;;\n11122;CHAKMA LETTER RAA;Lo;0;L;;;;;N;;;;;\n11123;CHAKMA LETTER LAA;Lo;0;L;;;;;N;;;;;\n11124;CHAKMA LETTER WAA;Lo;0;L;;;;;N;;;;;\n11125;CHAKMA LETTER SAA;Lo;0;L;;;;;N;;;;;\n11126;CHAKMA LETTER HAA;Lo;0;L;;;;;N;;;;;\n11127;CHAKMA VOWEL SIGN A;Mn;0;NSM;;;;;N;;;;;\n11128;CHAKMA VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;\n11129;CHAKMA VOWEL SIGN II;Mn;0;NSM;;;;;N;;;;;\n1112A;CHAKMA VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n1112B;CHAKMA VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n1112C;CHAKMA VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n1112D;CHAKMA VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n1112E;CHAKMA VOWEL SIGN O;Mn;0;NSM;11131 11127;;;;N;;;;;\n1112F;CHAKMA VOWEL SIGN AU;Mn;0;NSM;11132 11127;;;;N;;;;;\n11130;CHAKMA VOWEL SIGN OI;Mn;0;NSM;;;;;N;;;;;\n11131;CHAKMA O MARK;Mn;0;NSM;;;;;N;;;;;\n11132;CHAKMA AU MARK;Mn;0;NSM;;;;;N;;;;;\n11133;CHAKMA VIRAMA;Mn;9;NSM;;;;;N;;;;;\n11134;CHAKMA MAAYYAA;Mn;9;NSM;;;;;N;;;;;\n11136;CHAKMA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n11137;CHAKMA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n11138;CHAKMA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n11139;CHAKMA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n1113A;CHAKMA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n1113B;CHAKMA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n1113C;CHAKMA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n1113D;CHAKMA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n1113E;CHAKMA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n1113F;CHAKMA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n11140;CHAKMA SECTION MARK;Po;0;L;;;;;N;;;;;\n11141;CHAKMA DANDA;Po;0;L;;;;;N;;;;;\n11142;CHAKMA DOUBLE DANDA;Po;0;L;;;;;N;;;;;\n11143;CHAKMA QUESTION MARK;Po;0;L;;;;;N;;;;;\n11180;SHARADA SIGN CANDRABINDU;Mn;0;NSM;;;;;N;;;;;\n11181;SHARADA SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n11182;SHARADA SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n11183;SHARADA LETTER A;Lo;0;L;;;;;N;;;;;\n11184;SHARADA LETTER AA;Lo;0;L;;;;;N;;;;;\n11185;SHARADA LETTER I;Lo;0;L;;;;;N;;;;;\n11186;SHARADA LETTER II;Lo;0;L;;;;;N;;;;;\n11187;SHARADA LETTER U;Lo;0;L;;;;;N;;;;;\n11188;SHARADA LETTER UU;Lo;0;L;;;;;N;;;;;\n11189;SHARADA LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;\n1118A;SHARADA LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;\n1118B;SHARADA LETTER VOCALIC L;Lo;0;L;;;;;N;;;;;\n1118C;SHARADA LETTER VOCALIC LL;Lo;0;L;;;;;N;;;;;\n1118D;SHARADA LETTER E;Lo;0;L;;;;;N;;;;;\n1118E;SHARADA LETTER AI;Lo;0;L;;;;;N;;;;;\n1118F;SHARADA LETTER O;Lo;0;L;;;;;N;;;;;\n11190;SHARADA LETTER AU;Lo;0;L;;;;;N;;;;;\n11191;SHARADA LETTER KA;Lo;0;L;;;;;N;;;;;\n11192;SHARADA LETTER KHA;Lo;0;L;;;;;N;;;;;\n11193;SHARADA LETTER GA;Lo;0;L;;;;;N;;;;;\n11194;SHARADA LETTER GHA;Lo;0;L;;;;;N;;;;;\n11195;SHARADA LETTER NGA;Lo;0;L;;;;;N;;;;;\n11196;SHARADA LETTER CA;Lo;0;L;;;;;N;;;;;\n11197;SHARADA LETTER CHA;Lo;0;L;;;;;N;;;;;\n11198;SHARADA LETTER JA;Lo;0;L;;;;;N;;;;;\n11199;SHARADA LETTER JHA;Lo;0;L;;;;;N;;;;;\n1119A;SHARADA LETTER NYA;Lo;0;L;;;;;N;;;;;\n1119B;SHARADA LETTER TTA;Lo;0;L;;;;;N;;;;;\n1119C;SHARADA LETTER TTHA;Lo;0;L;;;;;N;;;;;\n1119D;SHARADA LETTER DDA;Lo;0;L;;;;;N;;;;;\n1119E;SHARADA LETTER DDHA;Lo;0;L;;;;;N;;;;;\n1119F;SHARADA LETTER NNA;Lo;0;L;;;;;N;;;;;\n111A0;SHARADA LETTER TA;Lo;0;L;;;;;N;;;;;\n111A1;SHARADA LETTER THA;Lo;0;L;;;;;N;;;;;\n111A2;SHARADA LETTER DA;Lo;0;L;;;;;N;;;;;\n111A3;SHARADA LETTER DHA;Lo;0;L;;;;;N;;;;;\n111A4;SHARADA LETTER NA;Lo;0;L;;;;;N;;;;;\n111A5;SHARADA LETTER PA;Lo;0;L;;;;;N;;;;;\n111A6;SHARADA LETTER PHA;Lo;0;L;;;;;N;;;;;\n111A7;SHARADA LETTER BA;Lo;0;L;;;;;N;;;;;\n111A8;SHARADA LETTER BHA;Lo;0;L;;;;;N;;;;;\n111A9;SHARADA LETTER MA;Lo;0;L;;;;;N;;;;;\n111AA;SHARADA LETTER YA;Lo;0;L;;;;;N;;;;;\n111AB;SHARADA LETTER RA;Lo;0;L;;;;;N;;;;;\n111AC;SHARADA LETTER LA;Lo;0;L;;;;;N;;;;;\n111AD;SHARADA LETTER LLA;Lo;0;L;;;;;N;;;;;\n111AE;SHARADA LETTER VA;Lo;0;L;;;;;N;;;;;\n111AF;SHARADA LETTER SHA;Lo;0;L;;;;;N;;;;;\n111B0;SHARADA LETTER SSA;Lo;0;L;;;;;N;;;;;\n111B1;SHARADA LETTER SA;Lo;0;L;;;;;N;;;;;\n111B2;SHARADA LETTER HA;Lo;0;L;;;;;N;;;;;\n111B3;SHARADA VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n111B4;SHARADA VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n111B5;SHARADA VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n111B6;SHARADA VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n111B7;SHARADA VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n111B8;SHARADA VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;\n111B9;SHARADA VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;\n111BA;SHARADA VOWEL SIGN VOCALIC L;Mn;0;NSM;;;;;N;;;;;\n111BB;SHARADA VOWEL SIGN VOCALIC LL;Mn;0;NSM;;;;;N;;;;;\n111BC;SHARADA VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n111BD;SHARADA VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n111BE;SHARADA VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n111BF;SHARADA VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n111C0;SHARADA SIGN VIRAMA;Mc;9;L;;;;;N;;;;;\n111C1;SHARADA SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;\n111C2;SHARADA SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;\n111C3;SHARADA SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;\n111C4;SHARADA OM;Lo;0;L;;;;;N;;;;;\n111C5;SHARADA DANDA;Po;0;L;;;;;N;;;;;\n111C6;SHARADA DOUBLE DANDA;Po;0;L;;;;;N;;;;;\n111C7;SHARADA ABBREVIATION SIGN;Po;0;L;;;;;N;;;;;\n111C8;SHARADA SEPARATOR;Po;0;L;;;;;N;;;;;\n111D0;SHARADA DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n111D1;SHARADA DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n111D2;SHARADA DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n111D3;SHARADA DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n111D4;SHARADA DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n111D5;SHARADA DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n111D6;SHARADA DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n111D7;SHARADA DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n111D8;SHARADA DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n111D9;SHARADA DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n11680;TAKRI LETTER A;Lo;0;L;;;;;N;;;;;\n11681;TAKRI LETTER AA;Lo;0;L;;;;;N;;;;;\n11682;TAKRI LETTER I;Lo;0;L;;;;;N;;;;;\n11683;TAKRI LETTER II;Lo;0;L;;;;;N;;;;;\n11684;TAKRI LETTER U;Lo;0;L;;;;;N;;;;;\n11685;TAKRI LETTER UU;Lo;0;L;;;;;N;;;;;\n11686;TAKRI LETTER E;Lo;0;L;;;;;N;;;;;\n11687;TAKRI LETTER AI;Lo;0;L;;;;;N;;;;;\n11688;TAKRI LETTER O;Lo;0;L;;;;;N;;;;;\n11689;TAKRI LETTER AU;Lo;0;L;;;;;N;;;;;\n1168A;TAKRI LETTER KA;Lo;0;L;;;;;N;;;;;\n1168B;TAKRI LETTER KHA;Lo;0;L;;;;;N;;;;;\n1168C;TAKRI LETTER GA;Lo;0;L;;;;;N;;;;;\n1168D;TAKRI LETTER GHA;Lo;0;L;;;;;N;;;;;\n1168E;TAKRI LETTER NGA;Lo;0;L;;;;;N;;;;;\n1168F;TAKRI LETTER CA;Lo;0;L;;;;;N;;;;;\n11690;TAKRI LETTER CHA;Lo;0;L;;;;;N;;;;;\n11691;TAKRI LETTER JA;Lo;0;L;;;;;N;;;;;\n11692;TAKRI LETTER JHA;Lo;0;L;;;;;N;;;;;\n11693;TAKRI LETTER NYA;Lo;0;L;;;;;N;;;;;\n11694;TAKRI LETTER TTA;Lo;0;L;;;;;N;;;;;\n11695;TAKRI LETTER TTHA;Lo;0;L;;;;;N;;;;;\n11696;TAKRI LETTER DDA;Lo;0;L;;;;;N;;;;;\n11697;TAKRI LETTER DDHA;Lo;0;L;;;;;N;;;;;\n11698;TAKRI LETTER NNA;Lo;0;L;;;;;N;;;;;\n11699;TAKRI LETTER TA;Lo;0;L;;;;;N;;;;;\n1169A;TAKRI LETTER THA;Lo;0;L;;;;;N;;;;;\n1169B;TAKRI LETTER DA;Lo;0;L;;;;;N;;;;;\n1169C;TAKRI LETTER DHA;Lo;0;L;;;;;N;;;;;\n1169D;TAKRI LETTER NA;Lo;0;L;;;;;N;;;;;\n1169E;TAKRI LETTER PA;Lo;0;L;;;;;N;;;;;\n1169F;TAKRI LETTER PHA;Lo;0;L;;;;;N;;;;;\n116A0;TAKRI LETTER BA;Lo;0;L;;;;;N;;;;;\n116A1;TAKRI LETTER BHA;Lo;0;L;;;;;N;;;;;\n116A2;TAKRI LETTER MA;Lo;0;L;;;;;N;;;;;\n116A3;TAKRI LETTER YA;Lo;0;L;;;;;N;;;;;\n116A4;TAKRI LETTER RA;Lo;0;L;;;;;N;;;;;\n116A5;TAKRI LETTER LA;Lo;0;L;;;;;N;;;;;\n116A6;TAKRI LETTER VA;Lo;0;L;;;;;N;;;;;\n116A7;TAKRI LETTER SHA;Lo;0;L;;;;;N;;;;;\n116A8;TAKRI LETTER SA;Lo;0;L;;;;;N;;;;;\n116A9;TAKRI LETTER HA;Lo;0;L;;;;;N;;;;;\n116AA;TAKRI LETTER RRA;Lo;0;L;;;;;N;;;;;\n116AB;TAKRI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;\n116AC;TAKRI SIGN VISARGA;Mc;0;L;;;;;N;;;;;\n116AD;TAKRI VOWEL SIGN AA;Mn;0;NSM;;;;;N;;;;;\n116AE;TAKRI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n116AF;TAKRI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n116B0;TAKRI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;\n116B1;TAKRI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;\n116B2;TAKRI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;\n116B3;TAKRI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;\n116B4;TAKRI VOWEL SIGN O;Mn;0;NSM;;;;;N;;;;;\n116B5;TAKRI VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;\n116B6;TAKRI SIGN VIRAMA;Mc;9;L;;;;;N;;;;;\n116B7;TAKRI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;\n116C0;TAKRI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;\n116C1;TAKRI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;\n116C2;TAKRI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;\n116C3;TAKRI DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;\n116C4;TAKRI DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;\n116C5;TAKRI DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;\n116C6;TAKRI DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;\n116C7;TAKRI DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;\n116C8;TAKRI DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;\n116C9;TAKRI DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;\n12000;CUNEIFORM SIGN A;Lo;0;L;;;;;N;;;;;\n12001;CUNEIFORM SIGN A TIMES A;Lo;0;L;;;;;N;;;;;\n12002;CUNEIFORM SIGN A TIMES BAD;Lo;0;L;;;;;N;;;;;\n12003;CUNEIFORM SIGN A TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12004;CUNEIFORM SIGN A TIMES HA;Lo;0;L;;;;;N;;;;;\n12005;CUNEIFORM SIGN A TIMES IGI;Lo;0;L;;;;;N;;;;;\n12006;CUNEIFORM SIGN A TIMES LAGAR GUNU;Lo;0;L;;;;;N;;;;;\n12007;CUNEIFORM SIGN A TIMES MUSH;Lo;0;L;;;;;N;;;;;\n12008;CUNEIFORM SIGN A TIMES SAG;Lo;0;L;;;;;N;;;;;\n12009;CUNEIFORM SIGN A2;Lo;0;L;;;;;N;;;;;\n1200A;CUNEIFORM SIGN AB;Lo;0;L;;;;;N;;;;;\n1200B;CUNEIFORM SIGN AB TIMES ASH2;Lo;0;L;;;;;N;;;;;\n1200C;CUNEIFORM SIGN AB TIMES DUN3 GUNU;Lo;0;L;;;;;N;;;;;\n1200D;CUNEIFORM SIGN AB TIMES GAL;Lo;0;L;;;;;N;;;;;\n1200E;CUNEIFORM SIGN AB TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n1200F;CUNEIFORM SIGN AB TIMES HA;Lo;0;L;;;;;N;;;;;\n12010;CUNEIFORM SIGN AB TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n12011;CUNEIFORM SIGN AB TIMES IMIN;Lo;0;L;;;;;N;;;;;\n12012;CUNEIFORM SIGN AB TIMES LAGAB;Lo;0;L;;;;;N;;;;;\n12013;CUNEIFORM SIGN AB TIMES SHESH;Lo;0;L;;;;;N;;;;;\n12014;CUNEIFORM SIGN AB TIMES U PLUS U PLUS U;Lo;0;L;;;;;N;;;;;\n12015;CUNEIFORM SIGN AB GUNU;Lo;0;L;;;;;N;;;;;\n12016;CUNEIFORM SIGN AB2;Lo;0;L;;;;;N;;;;;\n12017;CUNEIFORM SIGN AB2 TIMES BALAG;Lo;0;L;;;;;N;;;;;\n12018;CUNEIFORM SIGN AB2 TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12019;CUNEIFORM SIGN AB2 TIMES ME PLUS EN;Lo;0;L;;;;;N;;;;;\n1201A;CUNEIFORM SIGN AB2 TIMES SHA3;Lo;0;L;;;;;N;;;;;\n1201B;CUNEIFORM SIGN AB2 TIMES TAK4;Lo;0;L;;;;;N;;;;;\n1201C;CUNEIFORM SIGN AD;Lo;0;L;;;;;N;;;;;\n1201D;CUNEIFORM SIGN AK;Lo;0;L;;;;;N;;;;;\n1201E;CUNEIFORM SIGN AK TIMES ERIN2;Lo;0;L;;;;;N;;;;;\n1201F;CUNEIFORM SIGN AK TIMES SHITA PLUS GISH;Lo;0;L;;;;;N;;;;;\n12020;CUNEIFORM SIGN AL;Lo;0;L;;;;;N;;;;;\n12021;CUNEIFORM SIGN AL TIMES AL;Lo;0;L;;;;;N;;;;;\n12022;CUNEIFORM SIGN AL TIMES DIM2;Lo;0;L;;;;;N;;;;;\n12023;CUNEIFORM SIGN AL TIMES GISH;Lo;0;L;;;;;N;;;;;\n12024;CUNEIFORM SIGN AL TIMES HA;Lo;0;L;;;;;N;;;;;\n12025;CUNEIFORM SIGN AL TIMES KAD3;Lo;0;L;;;;;N;;;;;\n12026;CUNEIFORM SIGN AL TIMES KI;Lo;0;L;;;;;N;;;;;\n12027;CUNEIFORM SIGN AL TIMES SHE;Lo;0;L;;;;;N;;;;;\n12028;CUNEIFORM SIGN AL TIMES USH;Lo;0;L;;;;;N;;;;;\n12029;CUNEIFORM SIGN ALAN;Lo;0;L;;;;;N;;;;;\n1202A;CUNEIFORM SIGN ALEPH;Lo;0;L;;;;;N;;;;;\n1202B;CUNEIFORM SIGN AMAR;Lo;0;L;;;;;N;;;;;\n1202C;CUNEIFORM SIGN AMAR TIMES SHE;Lo;0;L;;;;;N;;;;;\n1202D;CUNEIFORM SIGN AN;Lo;0;L;;;;;N;;;;;\n1202E;CUNEIFORM SIGN AN OVER AN;Lo;0;L;;;;;N;;;;;\n1202F;CUNEIFORM SIGN AN THREE TIMES;Lo;0;L;;;;;N;;;;;\n12030;CUNEIFORM SIGN AN PLUS NAGA OPPOSING AN PLUS NAGA;Lo;0;L;;;;;N;;;;;\n12031;CUNEIFORM SIGN AN PLUS NAGA SQUARED;Lo;0;L;;;;;N;;;;;\n12032;CUNEIFORM SIGN ANSHE;Lo;0;L;;;;;N;;;;;\n12033;CUNEIFORM SIGN APIN;Lo;0;L;;;;;N;;;;;\n12034;CUNEIFORM SIGN ARAD;Lo;0;L;;;;;N;;;;;\n12035;CUNEIFORM SIGN ARAD TIMES KUR;Lo;0;L;;;;;N;;;;;\n12036;CUNEIFORM SIGN ARKAB;Lo;0;L;;;;;N;;;;;\n12037;CUNEIFORM SIGN ASAL2;Lo;0;L;;;;;N;;;;;\n12038;CUNEIFORM SIGN ASH;Lo;0;L;;;;;N;;;;;\n12039;CUNEIFORM SIGN ASH ZIDA TENU;Lo;0;L;;;;;N;;;;;\n1203A;CUNEIFORM SIGN ASH KABA TENU;Lo;0;L;;;;;N;;;;;\n1203B;CUNEIFORM SIGN ASH OVER ASH TUG2 OVER TUG2 TUG2 OVER TUG2 PAP;Lo;0;L;;;;;N;;;;;\n1203C;CUNEIFORM SIGN ASH OVER ASH OVER ASH;Lo;0;L;;;;;N;;;;;\n1203D;CUNEIFORM SIGN ASH OVER ASH OVER ASH CROSSING ASH OVER ASH OVER ASH;Lo;0;L;;;;;N;;;;;\n1203E;CUNEIFORM SIGN ASH2;Lo;0;L;;;;;N;;;;;\n1203F;CUNEIFORM SIGN ASHGAB;Lo;0;L;;;;;N;;;;;\n12040;CUNEIFORM SIGN BA;Lo;0;L;;;;;N;;;;;\n12041;CUNEIFORM SIGN BAD;Lo;0;L;;;;;N;;;;;\n12042;CUNEIFORM SIGN BAG3;Lo;0;L;;;;;N;;;;;\n12043;CUNEIFORM SIGN BAHAR2;Lo;0;L;;;;;N;;;;;\n12044;CUNEIFORM SIGN BAL;Lo;0;L;;;;;N;;;;;\n12045;CUNEIFORM SIGN BAL OVER BAL;Lo;0;L;;;;;N;;;;;\n12046;CUNEIFORM SIGN BALAG;Lo;0;L;;;;;N;;;;;\n12047;CUNEIFORM SIGN BAR;Lo;0;L;;;;;N;;;;;\n12048;CUNEIFORM SIGN BARA2;Lo;0;L;;;;;N;;;;;\n12049;CUNEIFORM SIGN BI;Lo;0;L;;;;;N;;;;;\n1204A;CUNEIFORM SIGN BI TIMES A;Lo;0;L;;;;;N;;;;;\n1204B;CUNEIFORM SIGN BI TIMES GAR;Lo;0;L;;;;;N;;;;;\n1204C;CUNEIFORM SIGN BI TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n1204D;CUNEIFORM SIGN BU;Lo;0;L;;;;;N;;;;;\n1204E;CUNEIFORM SIGN BU OVER BU AB;Lo;0;L;;;;;N;;;;;\n1204F;CUNEIFORM SIGN BU OVER BU UN;Lo;0;L;;;;;N;;;;;\n12050;CUNEIFORM SIGN BU CROSSING BU;Lo;0;L;;;;;N;;;;;\n12051;CUNEIFORM SIGN BULUG;Lo;0;L;;;;;N;;;;;\n12052;CUNEIFORM SIGN BULUG OVER BULUG;Lo;0;L;;;;;N;;;;;\n12053;CUNEIFORM SIGN BUR;Lo;0;L;;;;;N;;;;;\n12054;CUNEIFORM SIGN BUR2;Lo;0;L;;;;;N;;;;;\n12055;CUNEIFORM SIGN DA;Lo;0;L;;;;;N;;;;;\n12056;CUNEIFORM SIGN DAG;Lo;0;L;;;;;N;;;;;\n12057;CUNEIFORM SIGN DAG KISIM5 TIMES A PLUS MASH;Lo;0;L;;;;;N;;;;;\n12058;CUNEIFORM SIGN DAG KISIM5 TIMES AMAR;Lo;0;L;;;;;N;;;;;\n12059;CUNEIFORM SIGN DAG KISIM5 TIMES BALAG;Lo;0;L;;;;;N;;;;;\n1205A;CUNEIFORM SIGN DAG KISIM5 TIMES BI;Lo;0;L;;;;;N;;;;;\n1205B;CUNEIFORM SIGN DAG KISIM5 TIMES GA;Lo;0;L;;;;;N;;;;;\n1205C;CUNEIFORM SIGN DAG KISIM5 TIMES GA PLUS MASH;Lo;0;L;;;;;N;;;;;\n1205D;CUNEIFORM SIGN DAG KISIM5 TIMES GI;Lo;0;L;;;;;N;;;;;\n1205E;CUNEIFORM SIGN DAG KISIM5 TIMES GIR2;Lo;0;L;;;;;N;;;;;\n1205F;CUNEIFORM SIGN DAG KISIM5 TIMES GUD;Lo;0;L;;;;;N;;;;;\n12060;CUNEIFORM SIGN DAG KISIM5 TIMES HA;Lo;0;L;;;;;N;;;;;\n12061;CUNEIFORM SIGN DAG KISIM5 TIMES IR;Lo;0;L;;;;;N;;;;;\n12062;CUNEIFORM SIGN DAG KISIM5 TIMES IR PLUS LU;Lo;0;L;;;;;N;;;;;\n12063;CUNEIFORM SIGN DAG KISIM5 TIMES KAK;Lo;0;L;;;;;N;;;;;\n12064;CUNEIFORM SIGN DAG KISIM5 TIMES LA;Lo;0;L;;;;;N;;;;;\n12065;CUNEIFORM SIGN DAG KISIM5 TIMES LU;Lo;0;L;;;;;N;;;;;\n12066;CUNEIFORM SIGN DAG KISIM5 TIMES LU PLUS MASH2;Lo;0;L;;;;;N;;;;;\n12067;CUNEIFORM SIGN DAG KISIM5 TIMES LUM;Lo;0;L;;;;;N;;;;;\n12068;CUNEIFORM SIGN DAG KISIM5 TIMES NE;Lo;0;L;;;;;N;;;;;\n12069;CUNEIFORM SIGN DAG KISIM5 TIMES PAP PLUS PAP;Lo;0;L;;;;;N;;;;;\n1206A;CUNEIFORM SIGN DAG KISIM5 TIMES SI;Lo;0;L;;;;;N;;;;;\n1206B;CUNEIFORM SIGN DAG KISIM5 TIMES TAK4;Lo;0;L;;;;;N;;;;;\n1206C;CUNEIFORM SIGN DAG KISIM5 TIMES U2 PLUS GIR2;Lo;0;L;;;;;N;;;;;\n1206D;CUNEIFORM SIGN DAG KISIM5 TIMES USH;Lo;0;L;;;;;N;;;;;\n1206E;CUNEIFORM SIGN DAM;Lo;0;L;;;;;N;;;;;\n1206F;CUNEIFORM SIGN DAR;Lo;0;L;;;;;N;;;;;\n12070;CUNEIFORM SIGN DARA3;Lo;0;L;;;;;N;;;;;\n12071;CUNEIFORM SIGN DARA4;Lo;0;L;;;;;N;;;;;\n12072;CUNEIFORM SIGN DI;Lo;0;L;;;;;N;;;;;\n12073;CUNEIFORM SIGN DIB;Lo;0;L;;;;;N;;;;;\n12074;CUNEIFORM SIGN DIM;Lo;0;L;;;;;N;;;;;\n12075;CUNEIFORM SIGN DIM TIMES SHE;Lo;0;L;;;;;N;;;;;\n12076;CUNEIFORM SIGN DIM2;Lo;0;L;;;;;N;;;;;\n12077;CUNEIFORM SIGN DIN;Lo;0;L;;;;;N;;;;;\n12078;CUNEIFORM SIGN DIN KASKAL U GUNU DISH;Lo;0;L;;;;;N;;;;;\n12079;CUNEIFORM SIGN DISH;Lo;0;L;;;;;N;;;;;\n1207A;CUNEIFORM SIGN DU;Lo;0;L;;;;;N;;;;;\n1207B;CUNEIFORM SIGN DU OVER DU;Lo;0;L;;;;;N;;;;;\n1207C;CUNEIFORM SIGN DU GUNU;Lo;0;L;;;;;N;;;;;\n1207D;CUNEIFORM SIGN DU SHESHIG;Lo;0;L;;;;;N;;;;;\n1207E;CUNEIFORM SIGN DUB;Lo;0;L;;;;;N;;;;;\n1207F;CUNEIFORM SIGN DUB TIMES ESH2;Lo;0;L;;;;;N;;;;;\n12080;CUNEIFORM SIGN DUB2;Lo;0;L;;;;;N;;;;;\n12081;CUNEIFORM SIGN DUG;Lo;0;L;;;;;N;;;;;\n12082;CUNEIFORM SIGN DUGUD;Lo;0;L;;;;;N;;;;;\n12083;CUNEIFORM SIGN DUH;Lo;0;L;;;;;N;;;;;\n12084;CUNEIFORM SIGN DUN;Lo;0;L;;;;;N;;;;;\n12085;CUNEIFORM SIGN DUN3;Lo;0;L;;;;;N;;;;;\n12086;CUNEIFORM SIGN DUN3 GUNU;Lo;0;L;;;;;N;;;;;\n12087;CUNEIFORM SIGN DUN3 GUNU GUNU;Lo;0;L;;;;;N;;;;;\n12088;CUNEIFORM SIGN DUN4;Lo;0;L;;;;;N;;;;;\n12089;CUNEIFORM SIGN DUR2;Lo;0;L;;;;;N;;;;;\n1208A;CUNEIFORM SIGN E;Lo;0;L;;;;;N;;;;;\n1208B;CUNEIFORM SIGN E TIMES PAP;Lo;0;L;;;;;N;;;;;\n1208C;CUNEIFORM SIGN E OVER E NUN OVER NUN;Lo;0;L;;;;;N;;;;;\n1208D;CUNEIFORM SIGN E2;Lo;0;L;;;;;N;;;;;\n1208E;CUNEIFORM SIGN E2 TIMES A PLUS HA PLUS DA;Lo;0;L;;;;;N;;;;;\n1208F;CUNEIFORM SIGN E2 TIMES GAR;Lo;0;L;;;;;N;;;;;\n12090;CUNEIFORM SIGN E2 TIMES MI;Lo;0;L;;;;;N;;;;;\n12091;CUNEIFORM SIGN E2 TIMES SAL;Lo;0;L;;;;;N;;;;;\n12092;CUNEIFORM SIGN E2 TIMES SHE;Lo;0;L;;;;;N;;;;;\n12093;CUNEIFORM SIGN E2 TIMES U;Lo;0;L;;;;;N;;;;;\n12094;CUNEIFORM SIGN EDIN;Lo;0;L;;;;;N;;;;;\n12095;CUNEIFORM SIGN EGIR;Lo;0;L;;;;;N;;;;;\n12096;CUNEIFORM SIGN EL;Lo;0;L;;;;;N;;;;;\n12097;CUNEIFORM SIGN EN;Lo;0;L;;;;;N;;;;;\n12098;CUNEIFORM SIGN EN TIMES GAN2;Lo;0;L;;;;;N;;;;;\n12099;CUNEIFORM SIGN EN TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n1209A;CUNEIFORM SIGN EN TIMES ME;Lo;0;L;;;;;N;;;;;\n1209B;CUNEIFORM SIGN EN CROSSING EN;Lo;0;L;;;;;N;;;;;\n1209C;CUNEIFORM SIGN EN OPPOSING EN;Lo;0;L;;;;;N;;;;;\n1209D;CUNEIFORM SIGN EN SQUARED;Lo;0;L;;;;;N;;;;;\n1209E;CUNEIFORM SIGN EREN;Lo;0;L;;;;;N;;;;;\n1209F;CUNEIFORM SIGN ERIN2;Lo;0;L;;;;;N;;;;;\n120A0;CUNEIFORM SIGN ESH2;Lo;0;L;;;;;N;;;;;\n120A1;CUNEIFORM SIGN EZEN;Lo;0;L;;;;;N;;;;;\n120A2;CUNEIFORM SIGN EZEN TIMES A;Lo;0;L;;;;;N;;;;;\n120A3;CUNEIFORM SIGN EZEN TIMES A PLUS LAL;Lo;0;L;;;;;N;;;;;\n120A4;CUNEIFORM SIGN EZEN TIMES A PLUS LAL TIMES LAL;Lo;0;L;;;;;N;;;;;\n120A5;CUNEIFORM SIGN EZEN TIMES AN;Lo;0;L;;;;;N;;;;;\n120A6;CUNEIFORM SIGN EZEN TIMES BAD;Lo;0;L;;;;;N;;;;;\n120A7;CUNEIFORM SIGN EZEN TIMES DUN3 GUNU;Lo;0;L;;;;;N;;;;;\n120A8;CUNEIFORM SIGN EZEN TIMES DUN3 GUNU GUNU;Lo;0;L;;;;;N;;;;;\n120A9;CUNEIFORM SIGN EZEN TIMES HA;Lo;0;L;;;;;N;;;;;\n120AA;CUNEIFORM SIGN EZEN TIMES HA GUNU;Lo;0;L;;;;;N;;;;;\n120AB;CUNEIFORM SIGN EZEN TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n120AC;CUNEIFORM SIGN EZEN TIMES KASKAL;Lo;0;L;;;;;N;;;;;\n120AD;CUNEIFORM SIGN EZEN TIMES KASKAL SQUARED;Lo;0;L;;;;;N;;;;;\n120AE;CUNEIFORM SIGN EZEN TIMES KU3;Lo;0;L;;;;;N;;;;;\n120AF;CUNEIFORM SIGN EZEN TIMES LA;Lo;0;L;;;;;N;;;;;\n120B0;CUNEIFORM SIGN EZEN TIMES LAL TIMES LAL;Lo;0;L;;;;;N;;;;;\n120B1;CUNEIFORM SIGN EZEN TIMES LI;Lo;0;L;;;;;N;;;;;\n120B2;CUNEIFORM SIGN EZEN TIMES LU;Lo;0;L;;;;;N;;;;;\n120B3;CUNEIFORM SIGN EZEN TIMES U2;Lo;0;L;;;;;N;;;;;\n120B4;CUNEIFORM SIGN EZEN TIMES UD;Lo;0;L;;;;;N;;;;;\n120B5;CUNEIFORM SIGN GA;Lo;0;L;;;;;N;;;;;\n120B6;CUNEIFORM SIGN GA GUNU;Lo;0;L;;;;;N;;;;;\n120B7;CUNEIFORM SIGN GA2;Lo;0;L;;;;;N;;;;;\n120B8;CUNEIFORM SIGN GA2 TIMES A PLUS DA PLUS HA;Lo;0;L;;;;;N;;;;;\n120B9;CUNEIFORM SIGN GA2 TIMES A PLUS HA;Lo;0;L;;;;;N;;;;;\n120BA;CUNEIFORM SIGN GA2 TIMES A PLUS IGI;Lo;0;L;;;;;N;;;;;\n120BB;CUNEIFORM SIGN GA2 TIMES AB2 TENU PLUS TAB;Lo;0;L;;;;;N;;;;;\n120BC;CUNEIFORM SIGN GA2 TIMES AN;Lo;0;L;;;;;N;;;;;\n120BD;CUNEIFORM SIGN GA2 TIMES ASH;Lo;0;L;;;;;N;;;;;\n120BE;CUNEIFORM SIGN GA2 TIMES ASH2 PLUS GAL;Lo;0;L;;;;;N;;;;;\n120BF;CUNEIFORM SIGN GA2 TIMES BAD;Lo;0;L;;;;;N;;;;;\n120C0;CUNEIFORM SIGN GA2 TIMES BAR PLUS RA;Lo;0;L;;;;;N;;;;;\n120C1;CUNEIFORM SIGN GA2 TIMES BUR;Lo;0;L;;;;;N;;;;;\n120C2;CUNEIFORM SIGN GA2 TIMES BUR PLUS RA;Lo;0;L;;;;;N;;;;;\n120C3;CUNEIFORM SIGN GA2 TIMES DA;Lo;0;L;;;;;N;;;;;\n120C4;CUNEIFORM SIGN GA2 TIMES DI;Lo;0;L;;;;;N;;;;;\n120C5;CUNEIFORM SIGN GA2 TIMES DIM TIMES SHE;Lo;0;L;;;;;N;;;;;\n120C6;CUNEIFORM SIGN GA2 TIMES DUB;Lo;0;L;;;;;N;;;;;\n120C7;CUNEIFORM SIGN GA2 TIMES EL;Lo;0;L;;;;;N;;;;;\n120C8;CUNEIFORM SIGN GA2 TIMES EL PLUS LA;Lo;0;L;;;;;N;;;;;\n120C9;CUNEIFORM SIGN GA2 TIMES EN;Lo;0;L;;;;;N;;;;;\n120CA;CUNEIFORM SIGN GA2 TIMES EN TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n120CB;CUNEIFORM SIGN GA2 TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n120CC;CUNEIFORM SIGN GA2 TIMES GAR;Lo;0;L;;;;;N;;;;;\n120CD;CUNEIFORM SIGN GA2 TIMES GI;Lo;0;L;;;;;N;;;;;\n120CE;CUNEIFORM SIGN GA2 TIMES GI4;Lo;0;L;;;;;N;;;;;\n120CF;CUNEIFORM SIGN GA2 TIMES GI4 PLUS A;Lo;0;L;;;;;N;;;;;\n120D0;CUNEIFORM SIGN GA2 TIMES GIR2 PLUS SU;Lo;0;L;;;;;N;;;;;\n120D1;CUNEIFORM SIGN GA2 TIMES HA PLUS LU PLUS ESH2;Lo;0;L;;;;;N;;;;;\n120D2;CUNEIFORM SIGN GA2 TIMES HAL;Lo;0;L;;;;;N;;;;;\n120D3;CUNEIFORM SIGN GA2 TIMES HAL PLUS LA;Lo;0;L;;;;;N;;;;;\n120D4;CUNEIFORM SIGN GA2 TIMES HI PLUS LI;Lo;0;L;;;;;N;;;;;\n120D5;CUNEIFORM SIGN GA2 TIMES HUB2;Lo;0;L;;;;;N;;;;;\n120D6;CUNEIFORM SIGN GA2 TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n120D7;CUNEIFORM SIGN GA2 TIMES ISH PLUS HU PLUS ASH;Lo;0;L;;;;;N;;;;;\n120D8;CUNEIFORM SIGN GA2 TIMES KAK;Lo;0;L;;;;;N;;;;;\n120D9;CUNEIFORM SIGN GA2 TIMES KASKAL;Lo;0;L;;;;;N;;;;;\n120DA;CUNEIFORM SIGN GA2 TIMES KID;Lo;0;L;;;;;N;;;;;\n120DB;CUNEIFORM SIGN GA2 TIMES KID PLUS LAL;Lo;0;L;;;;;N;;;;;\n120DC;CUNEIFORM SIGN GA2 TIMES KU3 PLUS AN;Lo;0;L;;;;;N;;;;;\n120DD;CUNEIFORM SIGN GA2 TIMES LA;Lo;0;L;;;;;N;;;;;\n120DE;CUNEIFORM SIGN GA2 TIMES ME PLUS EN;Lo;0;L;;;;;N;;;;;\n120DF;CUNEIFORM SIGN GA2 TIMES MI;Lo;0;L;;;;;N;;;;;\n120E0;CUNEIFORM SIGN GA2 TIMES NUN;Lo;0;L;;;;;N;;;;;\n120E1;CUNEIFORM SIGN GA2 TIMES NUN OVER NUN;Lo;0;L;;;;;N;;;;;\n120E2;CUNEIFORM SIGN GA2 TIMES PA;Lo;0;L;;;;;N;;;;;\n120E3;CUNEIFORM SIGN GA2 TIMES SAL;Lo;0;L;;;;;N;;;;;\n120E4;CUNEIFORM SIGN GA2 TIMES SAR;Lo;0;L;;;;;N;;;;;\n120E5;CUNEIFORM SIGN GA2 TIMES SHE;Lo;0;L;;;;;N;;;;;\n120E6;CUNEIFORM SIGN GA2 TIMES SHE PLUS TUR;Lo;0;L;;;;;N;;;;;\n120E7;CUNEIFORM SIGN GA2 TIMES SHID;Lo;0;L;;;;;N;;;;;\n120E8;CUNEIFORM SIGN GA2 TIMES SUM;Lo;0;L;;;;;N;;;;;\n120E9;CUNEIFORM SIGN GA2 TIMES TAK4;Lo;0;L;;;;;N;;;;;\n120EA;CUNEIFORM SIGN GA2 TIMES U;Lo;0;L;;;;;N;;;;;\n120EB;CUNEIFORM SIGN GA2 TIMES UD;Lo;0;L;;;;;N;;;;;\n120EC;CUNEIFORM SIGN GA2 TIMES UD PLUS DU;Lo;0;L;;;;;N;;;;;\n120ED;CUNEIFORM SIGN GA2 OVER GA2;Lo;0;L;;;;;N;;;;;\n120EE;CUNEIFORM SIGN GABA;Lo;0;L;;;;;N;;;;;\n120EF;CUNEIFORM SIGN GABA CROSSING GABA;Lo;0;L;;;;;N;;;;;\n120F0;CUNEIFORM SIGN GAD;Lo;0;L;;;;;N;;;;;\n120F1;CUNEIFORM SIGN GAD OVER GAD GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n120F2;CUNEIFORM SIGN GAL;Lo;0;L;;;;;N;;;;;\n120F3;CUNEIFORM SIGN GAL GAD OVER GAD GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n120F4;CUNEIFORM SIGN GALAM;Lo;0;L;;;;;N;;;;;\n120F5;CUNEIFORM SIGN GAM;Lo;0;L;;;;;N;;;;;\n120F6;CUNEIFORM SIGN GAN;Lo;0;L;;;;;N;;;;;\n120F7;CUNEIFORM SIGN GAN2;Lo;0;L;;;;;N;;;;;\n120F8;CUNEIFORM SIGN GAN2 TENU;Lo;0;L;;;;;N;;;;;\n120F9;CUNEIFORM SIGN GAN2 OVER GAN2;Lo;0;L;;;;;N;;;;;\n120FA;CUNEIFORM SIGN GAN2 CROSSING GAN2;Lo;0;L;;;;;N;;;;;\n120FB;CUNEIFORM SIGN GAR;Lo;0;L;;;;;N;;;;;\n120FC;CUNEIFORM SIGN GAR3;Lo;0;L;;;;;N;;;;;\n120FD;CUNEIFORM SIGN GASHAN;Lo;0;L;;;;;N;;;;;\n120FE;CUNEIFORM SIGN GESHTIN;Lo;0;L;;;;;N;;;;;\n120FF;CUNEIFORM SIGN GESHTIN TIMES KUR;Lo;0;L;;;;;N;;;;;\n12100;CUNEIFORM SIGN GI;Lo;0;L;;;;;N;;;;;\n12101;CUNEIFORM SIGN GI TIMES E;Lo;0;L;;;;;N;;;;;\n12102;CUNEIFORM SIGN GI TIMES U;Lo;0;L;;;;;N;;;;;\n12103;CUNEIFORM SIGN GI CROSSING GI;Lo;0;L;;;;;N;;;;;\n12104;CUNEIFORM SIGN GI4;Lo;0;L;;;;;N;;;;;\n12105;CUNEIFORM SIGN GI4 OVER GI4;Lo;0;L;;;;;N;;;;;\n12106;CUNEIFORM SIGN GI4 CROSSING GI4;Lo;0;L;;;;;N;;;;;\n12107;CUNEIFORM SIGN GIDIM;Lo;0;L;;;;;N;;;;;\n12108;CUNEIFORM SIGN GIR2;Lo;0;L;;;;;N;;;;;\n12109;CUNEIFORM SIGN GIR2 GUNU;Lo;0;L;;;;;N;;;;;\n1210A;CUNEIFORM SIGN GIR3;Lo;0;L;;;;;N;;;;;\n1210B;CUNEIFORM SIGN GIR3 TIMES A PLUS IGI;Lo;0;L;;;;;N;;;;;\n1210C;CUNEIFORM SIGN GIR3 TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n1210D;CUNEIFORM SIGN GIR3 TIMES IGI;Lo;0;L;;;;;N;;;;;\n1210E;CUNEIFORM SIGN GIR3 TIMES LU PLUS IGI;Lo;0;L;;;;;N;;;;;\n1210F;CUNEIFORM SIGN GIR3 TIMES PA;Lo;0;L;;;;;N;;;;;\n12110;CUNEIFORM SIGN GISAL;Lo;0;L;;;;;N;;;;;\n12111;CUNEIFORM SIGN GISH;Lo;0;L;;;;;N;;;;;\n12112;CUNEIFORM SIGN GISH CROSSING GISH;Lo;0;L;;;;;N;;;;;\n12113;CUNEIFORM SIGN GISH TIMES BAD;Lo;0;L;;;;;N;;;;;\n12114;CUNEIFORM SIGN GISH TIMES TAK4;Lo;0;L;;;;;N;;;;;\n12115;CUNEIFORM SIGN GISH TENU;Lo;0;L;;;;;N;;;;;\n12116;CUNEIFORM SIGN GU;Lo;0;L;;;;;N;;;;;\n12117;CUNEIFORM SIGN GU CROSSING GU;Lo;0;L;;;;;N;;;;;\n12118;CUNEIFORM SIGN GU2;Lo;0;L;;;;;N;;;;;\n12119;CUNEIFORM SIGN GU2 TIMES KAK;Lo;0;L;;;;;N;;;;;\n1211A;CUNEIFORM SIGN GU2 TIMES KAK TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n1211B;CUNEIFORM SIGN GU2 TIMES NUN;Lo;0;L;;;;;N;;;;;\n1211C;CUNEIFORM SIGN GU2 TIMES SAL PLUS TUG2;Lo;0;L;;;;;N;;;;;\n1211D;CUNEIFORM SIGN GU2 GUNU;Lo;0;L;;;;;N;;;;;\n1211E;CUNEIFORM SIGN GUD;Lo;0;L;;;;;N;;;;;\n1211F;CUNEIFORM SIGN GUD TIMES A PLUS KUR;Lo;0;L;;;;;N;;;;;\n12120;CUNEIFORM SIGN GUD TIMES KUR;Lo;0;L;;;;;N;;;;;\n12121;CUNEIFORM SIGN GUD OVER GUD LUGAL;Lo;0;L;;;;;N;;;;;\n12122;CUNEIFORM SIGN GUL;Lo;0;L;;;;;N;;;;;\n12123;CUNEIFORM SIGN GUM;Lo;0;L;;;;;N;;;;;\n12124;CUNEIFORM SIGN GUM TIMES SHE;Lo;0;L;;;;;N;;;;;\n12125;CUNEIFORM SIGN GUR;Lo;0;L;;;;;N;;;;;\n12126;CUNEIFORM SIGN GUR7;Lo;0;L;;;;;N;;;;;\n12127;CUNEIFORM SIGN GURUN;Lo;0;L;;;;;N;;;;;\n12128;CUNEIFORM SIGN GURUSH;Lo;0;L;;;;;N;;;;;\n12129;CUNEIFORM SIGN HA;Lo;0;L;;;;;N;;;;;\n1212A;CUNEIFORM SIGN HA TENU;Lo;0;L;;;;;N;;;;;\n1212B;CUNEIFORM SIGN HA GUNU;Lo;0;L;;;;;N;;;;;\n1212C;CUNEIFORM SIGN HAL;Lo;0;L;;;;;N;;;;;\n1212D;CUNEIFORM SIGN HI;Lo;0;L;;;;;N;;;;;\n1212E;CUNEIFORM SIGN HI TIMES ASH;Lo;0;L;;;;;N;;;;;\n1212F;CUNEIFORM SIGN HI TIMES ASH2;Lo;0;L;;;;;N;;;;;\n12130;CUNEIFORM SIGN HI TIMES BAD;Lo;0;L;;;;;N;;;;;\n12131;CUNEIFORM SIGN HI TIMES DISH;Lo;0;L;;;;;N;;;;;\n12132;CUNEIFORM SIGN HI TIMES GAD;Lo;0;L;;;;;N;;;;;\n12133;CUNEIFORM SIGN HI TIMES KIN;Lo;0;L;;;;;N;;;;;\n12134;CUNEIFORM SIGN HI TIMES NUN;Lo;0;L;;;;;N;;;;;\n12135;CUNEIFORM SIGN HI TIMES SHE;Lo;0;L;;;;;N;;;;;\n12136;CUNEIFORM SIGN HI TIMES U;Lo;0;L;;;;;N;;;;;\n12137;CUNEIFORM SIGN HU;Lo;0;L;;;;;N;;;;;\n12138;CUNEIFORM SIGN HUB2;Lo;0;L;;;;;N;;;;;\n12139;CUNEIFORM SIGN HUB2 TIMES AN;Lo;0;L;;;;;N;;;;;\n1213A;CUNEIFORM SIGN HUB2 TIMES HAL;Lo;0;L;;;;;N;;;;;\n1213B;CUNEIFORM SIGN HUB2 TIMES KASKAL;Lo;0;L;;;;;N;;;;;\n1213C;CUNEIFORM SIGN HUB2 TIMES LISH;Lo;0;L;;;;;N;;;;;\n1213D;CUNEIFORM SIGN HUB2 TIMES UD;Lo;0;L;;;;;N;;;;;\n1213E;CUNEIFORM SIGN HUL2;Lo;0;L;;;;;N;;;;;\n1213F;CUNEIFORM SIGN I;Lo;0;L;;;;;N;;;;;\n12140;CUNEIFORM SIGN I A;Lo;0;L;;;;;N;;;;;\n12141;CUNEIFORM SIGN IB;Lo;0;L;;;;;N;;;;;\n12142;CUNEIFORM SIGN IDIM;Lo;0;L;;;;;N;;;;;\n12143;CUNEIFORM SIGN IDIM OVER IDIM BUR;Lo;0;L;;;;;N;;;;;\n12144;CUNEIFORM SIGN IDIM OVER IDIM SQUARED;Lo;0;L;;;;;N;;;;;\n12145;CUNEIFORM SIGN IG;Lo;0;L;;;;;N;;;;;\n12146;CUNEIFORM SIGN IGI;Lo;0;L;;;;;N;;;;;\n12147;CUNEIFORM SIGN IGI DIB;Lo;0;L;;;;;N;;;;;\n12148;CUNEIFORM SIGN IGI RI;Lo;0;L;;;;;N;;;;;\n12149;CUNEIFORM SIGN IGI OVER IGI SHIR OVER SHIR UD OVER UD;Lo;0;L;;;;;N;;;;;\n1214A;CUNEIFORM SIGN IGI GUNU;Lo;0;L;;;;;N;;;;;\n1214B;CUNEIFORM SIGN IL;Lo;0;L;;;;;N;;;;;\n1214C;CUNEIFORM SIGN IL TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n1214D;CUNEIFORM SIGN IL2;Lo;0;L;;;;;N;;;;;\n1214E;CUNEIFORM SIGN IM;Lo;0;L;;;;;N;;;;;\n1214F;CUNEIFORM SIGN IM TIMES TAK4;Lo;0;L;;;;;N;;;;;\n12150;CUNEIFORM SIGN IM CROSSING IM;Lo;0;L;;;;;N;;;;;\n12151;CUNEIFORM SIGN IM OPPOSING IM;Lo;0;L;;;;;N;;;;;\n12152;CUNEIFORM SIGN IM SQUARED;Lo;0;L;;;;;N;;;;;\n12153;CUNEIFORM SIGN IMIN;Lo;0;L;;;;;N;;;;;\n12154;CUNEIFORM SIGN IN;Lo;0;L;;;;;N;;;;;\n12155;CUNEIFORM SIGN IR;Lo;0;L;;;;;N;;;;;\n12156;CUNEIFORM SIGN ISH;Lo;0;L;;;;;N;;;;;\n12157;CUNEIFORM SIGN KA;Lo;0;L;;;;;N;;;;;\n12158;CUNEIFORM SIGN KA TIMES A;Lo;0;L;;;;;N;;;;;\n12159;CUNEIFORM SIGN KA TIMES AD;Lo;0;L;;;;;N;;;;;\n1215A;CUNEIFORM SIGN KA TIMES AD PLUS KU3;Lo;0;L;;;;;N;;;;;\n1215B;CUNEIFORM SIGN KA TIMES ASH2;Lo;0;L;;;;;N;;;;;\n1215C;CUNEIFORM SIGN KA TIMES BAD;Lo;0;L;;;;;N;;;;;\n1215D;CUNEIFORM SIGN KA TIMES BALAG;Lo;0;L;;;;;N;;;;;\n1215E;CUNEIFORM SIGN KA TIMES BAR;Lo;0;L;;;;;N;;;;;\n1215F;CUNEIFORM SIGN KA TIMES BI;Lo;0;L;;;;;N;;;;;\n12160;CUNEIFORM SIGN KA TIMES ERIN2;Lo;0;L;;;;;N;;;;;\n12161;CUNEIFORM SIGN KA TIMES ESH2;Lo;0;L;;;;;N;;;;;\n12162;CUNEIFORM SIGN KA TIMES GA;Lo;0;L;;;;;N;;;;;\n12163;CUNEIFORM SIGN KA TIMES GAL;Lo;0;L;;;;;N;;;;;\n12164;CUNEIFORM SIGN KA TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12165;CUNEIFORM SIGN KA TIMES GAR;Lo;0;L;;;;;N;;;;;\n12166;CUNEIFORM SIGN KA TIMES GAR PLUS SHA3 PLUS A;Lo;0;L;;;;;N;;;;;\n12167;CUNEIFORM SIGN KA TIMES GI;Lo;0;L;;;;;N;;;;;\n12168;CUNEIFORM SIGN KA TIMES GIR2;Lo;0;L;;;;;N;;;;;\n12169;CUNEIFORM SIGN KA TIMES GISH PLUS SAR;Lo;0;L;;;;;N;;;;;\n1216A;CUNEIFORM SIGN KA TIMES GISH CROSSING GISH;Lo;0;L;;;;;N;;;;;\n1216B;CUNEIFORM SIGN KA TIMES GU;Lo;0;L;;;;;N;;;;;\n1216C;CUNEIFORM SIGN KA TIMES GUR7;Lo;0;L;;;;;N;;;;;\n1216D;CUNEIFORM SIGN KA TIMES IGI;Lo;0;L;;;;;N;;;;;\n1216E;CUNEIFORM SIGN KA TIMES IM;Lo;0;L;;;;;N;;;;;\n1216F;CUNEIFORM SIGN KA TIMES KAK;Lo;0;L;;;;;N;;;;;\n12170;CUNEIFORM SIGN KA TIMES KI;Lo;0;L;;;;;N;;;;;\n12171;CUNEIFORM SIGN KA TIMES KID;Lo;0;L;;;;;N;;;;;\n12172;CUNEIFORM SIGN KA TIMES LI;Lo;0;L;;;;;N;;;;;\n12173;CUNEIFORM SIGN KA TIMES LU;Lo;0;L;;;;;N;;;;;\n12174;CUNEIFORM SIGN KA TIMES ME;Lo;0;L;;;;;N;;;;;\n12175;CUNEIFORM SIGN KA TIMES ME PLUS DU;Lo;0;L;;;;;N;;;;;\n12176;CUNEIFORM SIGN KA TIMES ME PLUS GI;Lo;0;L;;;;;N;;;;;\n12177;CUNEIFORM SIGN KA TIMES ME PLUS TE;Lo;0;L;;;;;N;;;;;\n12178;CUNEIFORM SIGN KA TIMES MI;Lo;0;L;;;;;N;;;;;\n12179;CUNEIFORM SIGN KA TIMES MI PLUS NUNUZ;Lo;0;L;;;;;N;;;;;\n1217A;CUNEIFORM SIGN KA TIMES NE;Lo;0;L;;;;;N;;;;;\n1217B;CUNEIFORM SIGN KA TIMES NUN;Lo;0;L;;;;;N;;;;;\n1217C;CUNEIFORM SIGN KA TIMES PI;Lo;0;L;;;;;N;;;;;\n1217D;CUNEIFORM SIGN KA TIMES RU;Lo;0;L;;;;;N;;;;;\n1217E;CUNEIFORM SIGN KA TIMES SA;Lo;0;L;;;;;N;;;;;\n1217F;CUNEIFORM SIGN KA TIMES SAR;Lo;0;L;;;;;N;;;;;\n12180;CUNEIFORM SIGN KA TIMES SHA;Lo;0;L;;;;;N;;;;;\n12181;CUNEIFORM SIGN KA TIMES SHE;Lo;0;L;;;;;N;;;;;\n12182;CUNEIFORM SIGN KA TIMES SHID;Lo;0;L;;;;;N;;;;;\n12183;CUNEIFORM SIGN KA TIMES SHU;Lo;0;L;;;;;N;;;;;\n12184;CUNEIFORM SIGN KA TIMES SIG;Lo;0;L;;;;;N;;;;;\n12185;CUNEIFORM SIGN KA TIMES SUHUR;Lo;0;L;;;;;N;;;;;\n12186;CUNEIFORM SIGN KA TIMES TAR;Lo;0;L;;;;;N;;;;;\n12187;CUNEIFORM SIGN KA TIMES U;Lo;0;L;;;;;N;;;;;\n12188;CUNEIFORM SIGN KA TIMES U2;Lo;0;L;;;;;N;;;;;\n12189;CUNEIFORM SIGN KA TIMES UD;Lo;0;L;;;;;N;;;;;\n1218A;CUNEIFORM SIGN KA TIMES UMUM TIMES PA;Lo;0;L;;;;;N;;;;;\n1218B;CUNEIFORM SIGN KA TIMES USH;Lo;0;L;;;;;N;;;;;\n1218C;CUNEIFORM SIGN KA TIMES ZI;Lo;0;L;;;;;N;;;;;\n1218D;CUNEIFORM SIGN KA2;Lo;0;L;;;;;N;;;;;\n1218E;CUNEIFORM SIGN KA2 CROSSING KA2;Lo;0;L;;;;;N;;;;;\n1218F;CUNEIFORM SIGN KAB;Lo;0;L;;;;;N;;;;;\n12190;CUNEIFORM SIGN KAD2;Lo;0;L;;;;;N;;;;;\n12191;CUNEIFORM SIGN KAD3;Lo;0;L;;;;;N;;;;;\n12192;CUNEIFORM SIGN KAD4;Lo;0;L;;;;;N;;;;;\n12193;CUNEIFORM SIGN KAD5;Lo;0;L;;;;;N;;;;;\n12194;CUNEIFORM SIGN KAD5 OVER KAD5;Lo;0;L;;;;;N;;;;;\n12195;CUNEIFORM SIGN KAK;Lo;0;L;;;;;N;;;;;\n12196;CUNEIFORM SIGN KAK TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n12197;CUNEIFORM SIGN KAL;Lo;0;L;;;;;N;;;;;\n12198;CUNEIFORM SIGN KAL TIMES BAD;Lo;0;L;;;;;N;;;;;\n12199;CUNEIFORM SIGN KAL CROSSING KAL;Lo;0;L;;;;;N;;;;;\n1219A;CUNEIFORM SIGN KAM2;Lo;0;L;;;;;N;;;;;\n1219B;CUNEIFORM SIGN KAM4;Lo;0;L;;;;;N;;;;;\n1219C;CUNEIFORM SIGN KASKAL;Lo;0;L;;;;;N;;;;;\n1219D;CUNEIFORM SIGN KASKAL LAGAB TIMES U OVER LAGAB TIMES U;Lo;0;L;;;;;N;;;;;\n1219E;CUNEIFORM SIGN KASKAL OVER KASKAL LAGAB TIMES U OVER LAGAB TIMES U;Lo;0;L;;;;;N;;;;;\n1219F;CUNEIFORM SIGN KESH2;Lo;0;L;;;;;N;;;;;\n121A0;CUNEIFORM SIGN KI;Lo;0;L;;;;;N;;;;;\n121A1;CUNEIFORM SIGN KI TIMES BAD;Lo;0;L;;;;;N;;;;;\n121A2;CUNEIFORM SIGN KI TIMES U;Lo;0;L;;;;;N;;;;;\n121A3;CUNEIFORM SIGN KI TIMES UD;Lo;0;L;;;;;N;;;;;\n121A4;CUNEIFORM SIGN KID;Lo;0;L;;;;;N;;;;;\n121A5;CUNEIFORM SIGN KIN;Lo;0;L;;;;;N;;;;;\n121A6;CUNEIFORM SIGN KISAL;Lo;0;L;;;;;N;;;;;\n121A7;CUNEIFORM SIGN KISH;Lo;0;L;;;;;N;;;;;\n121A8;CUNEIFORM SIGN KISIM5;Lo;0;L;;;;;N;;;;;\n121A9;CUNEIFORM SIGN KISIM5 OVER KISIM5;Lo;0;L;;;;;N;;;;;\n121AA;CUNEIFORM SIGN KU;Lo;0;L;;;;;N;;;;;\n121AB;CUNEIFORM SIGN KU OVER HI TIMES ASH2 KU OVER HI TIMES ASH2;Lo;0;L;;;;;N;;;;;\n121AC;CUNEIFORM SIGN KU3;Lo;0;L;;;;;N;;;;;\n121AD;CUNEIFORM SIGN KU4;Lo;0;L;;;;;N;;;;;\n121AE;CUNEIFORM SIGN KU4 VARIANT FORM;Lo;0;L;;;;;N;;;;;\n121AF;CUNEIFORM SIGN KU7;Lo;0;L;;;;;N;;;;;\n121B0;CUNEIFORM SIGN KUL;Lo;0;L;;;;;N;;;;;\n121B1;CUNEIFORM SIGN KUL GUNU;Lo;0;L;;;;;N;;;;;\n121B2;CUNEIFORM SIGN KUN;Lo;0;L;;;;;N;;;;;\n121B3;CUNEIFORM SIGN KUR;Lo;0;L;;;;;N;;;;;\n121B4;CUNEIFORM SIGN KUR OPPOSING KUR;Lo;0;L;;;;;N;;;;;\n121B5;CUNEIFORM SIGN KUSHU2;Lo;0;L;;;;;N;;;;;\n121B6;CUNEIFORM SIGN KWU318;Lo;0;L;;;;;N;;;;;\n121B7;CUNEIFORM SIGN LA;Lo;0;L;;;;;N;;;;;\n121B8;CUNEIFORM SIGN LAGAB;Lo;0;L;;;;;N;;;;;\n121B9;CUNEIFORM SIGN LAGAB TIMES A;Lo;0;L;;;;;N;;;;;\n121BA;CUNEIFORM SIGN LAGAB TIMES A PLUS DA PLUS HA;Lo;0;L;;;;;N;;;;;\n121BB;CUNEIFORM SIGN LAGAB TIMES A PLUS GAR;Lo;0;L;;;;;N;;;;;\n121BC;CUNEIFORM SIGN LAGAB TIMES A PLUS LAL;Lo;0;L;;;;;N;;;;;\n121BD;CUNEIFORM SIGN LAGAB TIMES AL;Lo;0;L;;;;;N;;;;;\n121BE;CUNEIFORM SIGN LAGAB TIMES AN;Lo;0;L;;;;;N;;;;;\n121BF;CUNEIFORM SIGN LAGAB TIMES ASH ZIDA TENU;Lo;0;L;;;;;N;;;;;\n121C0;CUNEIFORM SIGN LAGAB TIMES BAD;Lo;0;L;;;;;N;;;;;\n121C1;CUNEIFORM SIGN LAGAB TIMES BI;Lo;0;L;;;;;N;;;;;\n121C2;CUNEIFORM SIGN LAGAB TIMES DAR;Lo;0;L;;;;;N;;;;;\n121C3;CUNEIFORM SIGN LAGAB TIMES EN;Lo;0;L;;;;;N;;;;;\n121C4;CUNEIFORM SIGN LAGAB TIMES GA;Lo;0;L;;;;;N;;;;;\n121C5;CUNEIFORM SIGN LAGAB TIMES GAR;Lo;0;L;;;;;N;;;;;\n121C6;CUNEIFORM SIGN LAGAB TIMES GUD;Lo;0;L;;;;;N;;;;;\n121C7;CUNEIFORM SIGN LAGAB TIMES GUD PLUS GUD;Lo;0;L;;;;;N;;;;;\n121C8;CUNEIFORM SIGN LAGAB TIMES HA;Lo;0;L;;;;;N;;;;;\n121C9;CUNEIFORM SIGN LAGAB TIMES HAL;Lo;0;L;;;;;N;;;;;\n121CA;CUNEIFORM SIGN LAGAB TIMES HI TIMES NUN;Lo;0;L;;;;;N;;;;;\n121CB;CUNEIFORM SIGN LAGAB TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n121CC;CUNEIFORM SIGN LAGAB TIMES IM;Lo;0;L;;;;;N;;;;;\n121CD;CUNEIFORM SIGN LAGAB TIMES IM PLUS HA;Lo;0;L;;;;;N;;;;;\n121CE;CUNEIFORM SIGN LAGAB TIMES IM PLUS LU;Lo;0;L;;;;;N;;;;;\n121CF;CUNEIFORM SIGN LAGAB TIMES KI;Lo;0;L;;;;;N;;;;;\n121D0;CUNEIFORM SIGN LAGAB TIMES KIN;Lo;0;L;;;;;N;;;;;\n121D1;CUNEIFORM SIGN LAGAB TIMES KU3;Lo;0;L;;;;;N;;;;;\n121D2;CUNEIFORM SIGN LAGAB TIMES KUL;Lo;0;L;;;;;N;;;;;\n121D3;CUNEIFORM SIGN LAGAB TIMES KUL PLUS HI PLUS A;Lo;0;L;;;;;N;;;;;\n121D4;CUNEIFORM SIGN LAGAB TIMES LAGAB;Lo;0;L;;;;;N;;;;;\n121D5;CUNEIFORM SIGN LAGAB TIMES LISH;Lo;0;L;;;;;N;;;;;\n121D6;CUNEIFORM SIGN LAGAB TIMES LU;Lo;0;L;;;;;N;;;;;\n121D7;CUNEIFORM SIGN LAGAB TIMES LUL;Lo;0;L;;;;;N;;;;;\n121D8;CUNEIFORM SIGN LAGAB TIMES ME;Lo;0;L;;;;;N;;;;;\n121D9;CUNEIFORM SIGN LAGAB TIMES ME PLUS EN;Lo;0;L;;;;;N;;;;;\n121DA;CUNEIFORM SIGN LAGAB TIMES MUSH;Lo;0;L;;;;;N;;;;;\n121DB;CUNEIFORM SIGN LAGAB TIMES NE;Lo;0;L;;;;;N;;;;;\n121DC;CUNEIFORM SIGN LAGAB TIMES SHE PLUS SUM;Lo;0;L;;;;;N;;;;;\n121DD;CUNEIFORM SIGN LAGAB TIMES SHITA PLUS GISH PLUS ERIN2;Lo;0;L;;;;;N;;;;;\n121DE;CUNEIFORM SIGN LAGAB TIMES SHITA PLUS GISH TENU;Lo;0;L;;;;;N;;;;;\n121DF;CUNEIFORM SIGN LAGAB TIMES SHU2;Lo;0;L;;;;;N;;;;;\n121E0;CUNEIFORM SIGN LAGAB TIMES SHU2 PLUS SHU2;Lo;0;L;;;;;N;;;;;\n121E1;CUNEIFORM SIGN LAGAB TIMES SUM;Lo;0;L;;;;;N;;;;;\n121E2;CUNEIFORM SIGN LAGAB TIMES TAG;Lo;0;L;;;;;N;;;;;\n121E3;CUNEIFORM SIGN LAGAB TIMES TAK4;Lo;0;L;;;;;N;;;;;\n121E4;CUNEIFORM SIGN LAGAB TIMES TE PLUS A PLUS SU PLUS NA;Lo;0;L;;;;;N;;;;;\n121E5;CUNEIFORM SIGN LAGAB TIMES U;Lo;0;L;;;;;N;;;;;\n121E6;CUNEIFORM SIGN LAGAB TIMES U PLUS A;Lo;0;L;;;;;N;;;;;\n121E7;CUNEIFORM SIGN LAGAB TIMES U PLUS U PLUS U;Lo;0;L;;;;;N;;;;;\n121E8;CUNEIFORM SIGN LAGAB TIMES U2 PLUS ASH;Lo;0;L;;;;;N;;;;;\n121E9;CUNEIFORM SIGN LAGAB TIMES UD;Lo;0;L;;;;;N;;;;;\n121EA;CUNEIFORM SIGN LAGAB TIMES USH;Lo;0;L;;;;;N;;;;;\n121EB;CUNEIFORM SIGN LAGAB SQUARED;Lo;0;L;;;;;N;;;;;\n121EC;CUNEIFORM SIGN LAGAR;Lo;0;L;;;;;N;;;;;\n121ED;CUNEIFORM SIGN LAGAR TIMES SHE;Lo;0;L;;;;;N;;;;;\n121EE;CUNEIFORM SIGN LAGAR TIMES SHE PLUS SUM;Lo;0;L;;;;;N;;;;;\n121EF;CUNEIFORM SIGN LAGAR GUNU;Lo;0;L;;;;;N;;;;;\n121F0;CUNEIFORM SIGN LAGAR GUNU OVER LAGAR GUNU SHE;Lo;0;L;;;;;N;;;;;\n121F1;CUNEIFORM SIGN LAHSHU;Lo;0;L;;;;;N;;;;;\n121F2;CUNEIFORM SIGN LAL;Lo;0;L;;;;;N;;;;;\n121F3;CUNEIFORM SIGN LAL TIMES LAL;Lo;0;L;;;;;N;;;;;\n121F4;CUNEIFORM SIGN LAM;Lo;0;L;;;;;N;;;;;\n121F5;CUNEIFORM SIGN LAM TIMES KUR;Lo;0;L;;;;;N;;;;;\n121F6;CUNEIFORM SIGN LAM TIMES KUR PLUS RU;Lo;0;L;;;;;N;;;;;\n121F7;CUNEIFORM SIGN LI;Lo;0;L;;;;;N;;;;;\n121F8;CUNEIFORM SIGN LIL;Lo;0;L;;;;;N;;;;;\n121F9;CUNEIFORM SIGN LIMMU2;Lo;0;L;;;;;N;;;;;\n121FA;CUNEIFORM SIGN LISH;Lo;0;L;;;;;N;;;;;\n121FB;CUNEIFORM SIGN LU;Lo;0;L;;;;;N;;;;;\n121FC;CUNEIFORM SIGN LU TIMES BAD;Lo;0;L;;;;;N;;;;;\n121FD;CUNEIFORM SIGN LU2;Lo;0;L;;;;;N;;;;;\n121FE;CUNEIFORM SIGN LU2 TIMES AL;Lo;0;L;;;;;N;;;;;\n121FF;CUNEIFORM SIGN LU2 TIMES BAD;Lo;0;L;;;;;N;;;;;\n12200;CUNEIFORM SIGN LU2 TIMES ESH2;Lo;0;L;;;;;N;;;;;\n12201;CUNEIFORM SIGN LU2 TIMES ESH2 TENU;Lo;0;L;;;;;N;;;;;\n12202;CUNEIFORM SIGN LU2 TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12203;CUNEIFORM SIGN LU2 TIMES HI TIMES BAD;Lo;0;L;;;;;N;;;;;\n12204;CUNEIFORM SIGN LU2 TIMES IM;Lo;0;L;;;;;N;;;;;\n12205;CUNEIFORM SIGN LU2 TIMES KAD2;Lo;0;L;;;;;N;;;;;\n12206;CUNEIFORM SIGN LU2 TIMES KAD3;Lo;0;L;;;;;N;;;;;\n12207;CUNEIFORM SIGN LU2 TIMES KAD3 PLUS ASH;Lo;0;L;;;;;N;;;;;\n12208;CUNEIFORM SIGN LU2 TIMES KI;Lo;0;L;;;;;N;;;;;\n12209;CUNEIFORM SIGN LU2 TIMES LA PLUS ASH;Lo;0;L;;;;;N;;;;;\n1220A;CUNEIFORM SIGN LU2 TIMES LAGAB;Lo;0;L;;;;;N;;;;;\n1220B;CUNEIFORM SIGN LU2 TIMES ME PLUS EN;Lo;0;L;;;;;N;;;;;\n1220C;CUNEIFORM SIGN LU2 TIMES NE;Lo;0;L;;;;;N;;;;;\n1220D;CUNEIFORM SIGN LU2 TIMES NU;Lo;0;L;;;;;N;;;;;\n1220E;CUNEIFORM SIGN LU2 TIMES SI PLUS ASH;Lo;0;L;;;;;N;;;;;\n1220F;CUNEIFORM SIGN LU2 TIMES SIK2 PLUS BU;Lo;0;L;;;;;N;;;;;\n12210;CUNEIFORM SIGN LU2 TIMES TUG2;Lo;0;L;;;;;N;;;;;\n12211;CUNEIFORM SIGN LU2 TENU;Lo;0;L;;;;;N;;;;;\n12212;CUNEIFORM SIGN LU2 CROSSING LU2;Lo;0;L;;;;;N;;;;;\n12213;CUNEIFORM SIGN LU2 OPPOSING LU2;Lo;0;L;;;;;N;;;;;\n12214;CUNEIFORM SIGN LU2 SQUARED;Lo;0;L;;;;;N;;;;;\n12215;CUNEIFORM SIGN LU2 SHESHIG;Lo;0;L;;;;;N;;;;;\n12216;CUNEIFORM SIGN LU3;Lo;0;L;;;;;N;;;;;\n12217;CUNEIFORM SIGN LUGAL;Lo;0;L;;;;;N;;;;;\n12218;CUNEIFORM SIGN LUGAL OVER LUGAL;Lo;0;L;;;;;N;;;;;\n12219;CUNEIFORM SIGN LUGAL OPPOSING LUGAL;Lo;0;L;;;;;N;;;;;\n1221A;CUNEIFORM SIGN LUGAL SHESHIG;Lo;0;L;;;;;N;;;;;\n1221B;CUNEIFORM SIGN LUH;Lo;0;L;;;;;N;;;;;\n1221C;CUNEIFORM SIGN LUL;Lo;0;L;;;;;N;;;;;\n1221D;CUNEIFORM SIGN LUM;Lo;0;L;;;;;N;;;;;\n1221E;CUNEIFORM SIGN LUM OVER LUM;Lo;0;L;;;;;N;;;;;\n1221F;CUNEIFORM SIGN LUM OVER LUM GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n12220;CUNEIFORM SIGN MA;Lo;0;L;;;;;N;;;;;\n12221;CUNEIFORM SIGN MA TIMES TAK4;Lo;0;L;;;;;N;;;;;\n12222;CUNEIFORM SIGN MA GUNU;Lo;0;L;;;;;N;;;;;\n12223;CUNEIFORM SIGN MA2;Lo;0;L;;;;;N;;;;;\n12224;CUNEIFORM SIGN MAH;Lo;0;L;;;;;N;;;;;\n12225;CUNEIFORM SIGN MAR;Lo;0;L;;;;;N;;;;;\n12226;CUNEIFORM SIGN MASH;Lo;0;L;;;;;N;;;;;\n12227;CUNEIFORM SIGN MASH2;Lo;0;L;;;;;N;;;;;\n12228;CUNEIFORM SIGN ME;Lo;0;L;;;;;N;;;;;\n12229;CUNEIFORM SIGN MES;Lo;0;L;;;;;N;;;;;\n1222A;CUNEIFORM SIGN MI;Lo;0;L;;;;;N;;;;;\n1222B;CUNEIFORM SIGN MIN;Lo;0;L;;;;;N;;;;;\n1222C;CUNEIFORM SIGN MU;Lo;0;L;;;;;N;;;;;\n1222D;CUNEIFORM SIGN MU OVER MU;Lo;0;L;;;;;N;;;;;\n1222E;CUNEIFORM SIGN MUG;Lo;0;L;;;;;N;;;;;\n1222F;CUNEIFORM SIGN MUG GUNU;Lo;0;L;;;;;N;;;;;\n12230;CUNEIFORM SIGN MUNSUB;Lo;0;L;;;;;N;;;;;\n12231;CUNEIFORM SIGN MURGU2;Lo;0;L;;;;;N;;;;;\n12232;CUNEIFORM SIGN MUSH;Lo;0;L;;;;;N;;;;;\n12233;CUNEIFORM SIGN MUSH TIMES A;Lo;0;L;;;;;N;;;;;\n12234;CUNEIFORM SIGN MUSH TIMES KUR;Lo;0;L;;;;;N;;;;;\n12235;CUNEIFORM SIGN MUSH TIMES ZA;Lo;0;L;;;;;N;;;;;\n12236;CUNEIFORM SIGN MUSH OVER MUSH;Lo;0;L;;;;;N;;;;;\n12237;CUNEIFORM SIGN MUSH OVER MUSH TIMES A PLUS NA;Lo;0;L;;;;;N;;;;;\n12238;CUNEIFORM SIGN MUSH CROSSING MUSH;Lo;0;L;;;;;N;;;;;\n12239;CUNEIFORM SIGN MUSH3;Lo;0;L;;;;;N;;;;;\n1223A;CUNEIFORM SIGN MUSH3 TIMES A;Lo;0;L;;;;;N;;;;;\n1223B;CUNEIFORM SIGN MUSH3 TIMES A PLUS DI;Lo;0;L;;;;;N;;;;;\n1223C;CUNEIFORM SIGN MUSH3 TIMES DI;Lo;0;L;;;;;N;;;;;\n1223D;CUNEIFORM SIGN MUSH3 GUNU;Lo;0;L;;;;;N;;;;;\n1223E;CUNEIFORM SIGN NA;Lo;0;L;;;;;N;;;;;\n1223F;CUNEIFORM SIGN NA2;Lo;0;L;;;;;N;;;;;\n12240;CUNEIFORM SIGN NAGA;Lo;0;L;;;;;N;;;;;\n12241;CUNEIFORM SIGN NAGA INVERTED;Lo;0;L;;;;;N;;;;;\n12242;CUNEIFORM SIGN NAGA TIMES SHU TENU;Lo;0;L;;;;;N;;;;;\n12243;CUNEIFORM SIGN NAGA OPPOSING NAGA;Lo;0;L;;;;;N;;;;;\n12244;CUNEIFORM SIGN NAGAR;Lo;0;L;;;;;N;;;;;\n12245;CUNEIFORM SIGN NAM NUTILLU;Lo;0;L;;;;;N;;;;;\n12246;CUNEIFORM SIGN NAM;Lo;0;L;;;;;N;;;;;\n12247;CUNEIFORM SIGN NAM2;Lo;0;L;;;;;N;;;;;\n12248;CUNEIFORM SIGN NE;Lo;0;L;;;;;N;;;;;\n12249;CUNEIFORM SIGN NE TIMES A;Lo;0;L;;;;;N;;;;;\n1224A;CUNEIFORM SIGN NE TIMES UD;Lo;0;L;;;;;N;;;;;\n1224B;CUNEIFORM SIGN NE SHESHIG;Lo;0;L;;;;;N;;;;;\n1224C;CUNEIFORM SIGN NI;Lo;0;L;;;;;N;;;;;\n1224D;CUNEIFORM SIGN NI TIMES E;Lo;0;L;;;;;N;;;;;\n1224E;CUNEIFORM SIGN NI2;Lo;0;L;;;;;N;;;;;\n1224F;CUNEIFORM SIGN NIM;Lo;0;L;;;;;N;;;;;\n12250;CUNEIFORM SIGN NIM TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12251;CUNEIFORM SIGN NIM TIMES GAR PLUS GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12252;CUNEIFORM SIGN NINDA2;Lo;0;L;;;;;N;;;;;\n12253;CUNEIFORM SIGN NINDA2 TIMES AN;Lo;0;L;;;;;N;;;;;\n12254;CUNEIFORM SIGN NINDA2 TIMES ASH;Lo;0;L;;;;;N;;;;;\n12255;CUNEIFORM SIGN NINDA2 TIMES ASH PLUS ASH;Lo;0;L;;;;;N;;;;;\n12256;CUNEIFORM SIGN NINDA2 TIMES GUD;Lo;0;L;;;;;N;;;;;\n12257;CUNEIFORM SIGN NINDA2 TIMES ME PLUS GAN2 TENU;Lo;0;L;;;;;N;;;;;\n12258;CUNEIFORM SIGN NINDA2 TIMES NE;Lo;0;L;;;;;N;;;;;\n12259;CUNEIFORM SIGN NINDA2 TIMES NUN;Lo;0;L;;;;;N;;;;;\n1225A;CUNEIFORM SIGN NINDA2 TIMES SHE;Lo;0;L;;;;;N;;;;;\n1225B;CUNEIFORM SIGN NINDA2 TIMES SHE PLUS A AN;Lo;0;L;;;;;N;;;;;\n1225C;CUNEIFORM SIGN NINDA2 TIMES SHE PLUS ASH;Lo;0;L;;;;;N;;;;;\n1225D;CUNEIFORM SIGN NINDA2 TIMES SHE PLUS ASH PLUS ASH;Lo;0;L;;;;;N;;;;;\n1225E;CUNEIFORM SIGN NINDA2 TIMES U2 PLUS ASH;Lo;0;L;;;;;N;;;;;\n1225F;CUNEIFORM SIGN NINDA2 TIMES USH;Lo;0;L;;;;;N;;;;;\n12260;CUNEIFORM SIGN NISAG;Lo;0;L;;;;;N;;;;;\n12261;CUNEIFORM SIGN NU;Lo;0;L;;;;;N;;;;;\n12262;CUNEIFORM SIGN NU11;Lo;0;L;;;;;N;;;;;\n12263;CUNEIFORM SIGN NUN;Lo;0;L;;;;;N;;;;;\n12264;CUNEIFORM SIGN NUN LAGAR TIMES GAR;Lo;0;L;;;;;N;;;;;\n12265;CUNEIFORM SIGN NUN LAGAR TIMES MASH;Lo;0;L;;;;;N;;;;;\n12266;CUNEIFORM SIGN NUN LAGAR TIMES SAL;Lo;0;L;;;;;N;;;;;\n12267;CUNEIFORM SIGN NUN LAGAR TIMES SAL OVER NUN LAGAR TIMES SAL;Lo;0;L;;;;;N;;;;;\n12268;CUNEIFORM SIGN NUN LAGAR TIMES USH;Lo;0;L;;;;;N;;;;;\n12269;CUNEIFORM SIGN NUN TENU;Lo;0;L;;;;;N;;;;;\n1226A;CUNEIFORM SIGN NUN OVER NUN;Lo;0;L;;;;;N;;;;;\n1226B;CUNEIFORM SIGN NUN CROSSING NUN;Lo;0;L;;;;;N;;;;;\n1226C;CUNEIFORM SIGN NUN CROSSING NUN LAGAR OVER LAGAR;Lo;0;L;;;;;N;;;;;\n1226D;CUNEIFORM SIGN NUNUZ;Lo;0;L;;;;;N;;;;;\n1226E;CUNEIFORM SIGN NUNUZ AB2 TIMES ASHGAB;Lo;0;L;;;;;N;;;;;\n1226F;CUNEIFORM SIGN NUNUZ AB2 TIMES BI;Lo;0;L;;;;;N;;;;;\n12270;CUNEIFORM SIGN NUNUZ AB2 TIMES DUG;Lo;0;L;;;;;N;;;;;\n12271;CUNEIFORM SIGN NUNUZ AB2 TIMES GUD;Lo;0;L;;;;;N;;;;;\n12272;CUNEIFORM SIGN NUNUZ AB2 TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n12273;CUNEIFORM SIGN NUNUZ AB2 TIMES KAD3;Lo;0;L;;;;;N;;;;;\n12274;CUNEIFORM SIGN NUNUZ AB2 TIMES LA;Lo;0;L;;;;;N;;;;;\n12275;CUNEIFORM SIGN NUNUZ AB2 TIMES NE;Lo;0;L;;;;;N;;;;;\n12276;CUNEIFORM SIGN NUNUZ AB2 TIMES SILA3;Lo;0;L;;;;;N;;;;;\n12277;CUNEIFORM SIGN NUNUZ AB2 TIMES U2;Lo;0;L;;;;;N;;;;;\n12278;CUNEIFORM SIGN NUNUZ KISIM5 TIMES BI;Lo;0;L;;;;;N;;;;;\n12279;CUNEIFORM SIGN NUNUZ KISIM5 TIMES BI U;Lo;0;L;;;;;N;;;;;\n1227A;CUNEIFORM SIGN PA;Lo;0;L;;;;;N;;;;;\n1227B;CUNEIFORM SIGN PAD;Lo;0;L;;;;;N;;;;;\n1227C;CUNEIFORM SIGN PAN;Lo;0;L;;;;;N;;;;;\n1227D;CUNEIFORM SIGN PAP;Lo;0;L;;;;;N;;;;;\n1227E;CUNEIFORM SIGN PESH2;Lo;0;L;;;;;N;;;;;\n1227F;CUNEIFORM SIGN PI;Lo;0;L;;;;;N;;;;;\n12280;CUNEIFORM SIGN PI TIMES A;Lo;0;L;;;;;N;;;;;\n12281;CUNEIFORM SIGN PI TIMES AB;Lo;0;L;;;;;N;;;;;\n12282;CUNEIFORM SIGN PI TIMES BI;Lo;0;L;;;;;N;;;;;\n12283;CUNEIFORM SIGN PI TIMES BU;Lo;0;L;;;;;N;;;;;\n12284;CUNEIFORM SIGN PI TIMES E;Lo;0;L;;;;;N;;;;;\n12285;CUNEIFORM SIGN PI TIMES I;Lo;0;L;;;;;N;;;;;\n12286;CUNEIFORM SIGN PI TIMES IB;Lo;0;L;;;;;N;;;;;\n12287;CUNEIFORM SIGN PI TIMES U;Lo;0;L;;;;;N;;;;;\n12288;CUNEIFORM SIGN PI TIMES U2;Lo;0;L;;;;;N;;;;;\n12289;CUNEIFORM SIGN PI CROSSING PI;Lo;0;L;;;;;N;;;;;\n1228A;CUNEIFORM SIGN PIRIG;Lo;0;L;;;;;N;;;;;\n1228B;CUNEIFORM SIGN PIRIG TIMES KAL;Lo;0;L;;;;;N;;;;;\n1228C;CUNEIFORM SIGN PIRIG TIMES UD;Lo;0;L;;;;;N;;;;;\n1228D;CUNEIFORM SIGN PIRIG TIMES ZA;Lo;0;L;;;;;N;;;;;\n1228E;CUNEIFORM SIGN PIRIG OPPOSING PIRIG;Lo;0;L;;;;;N;;;;;\n1228F;CUNEIFORM SIGN RA;Lo;0;L;;;;;N;;;;;\n12290;CUNEIFORM SIGN RAB;Lo;0;L;;;;;N;;;;;\n12291;CUNEIFORM SIGN RI;Lo;0;L;;;;;N;;;;;\n12292;CUNEIFORM SIGN RU;Lo;0;L;;;;;N;;;;;\n12293;CUNEIFORM SIGN SA;Lo;0;L;;;;;N;;;;;\n12294;CUNEIFORM SIGN SAG NUTILLU;Lo;0;L;;;;;N;;;;;\n12295;CUNEIFORM SIGN SAG;Lo;0;L;;;;;N;;;;;\n12296;CUNEIFORM SIGN SAG TIMES A;Lo;0;L;;;;;N;;;;;\n12297;CUNEIFORM SIGN SAG TIMES DU;Lo;0;L;;;;;N;;;;;\n12298;CUNEIFORM SIGN SAG TIMES DUB;Lo;0;L;;;;;N;;;;;\n12299;CUNEIFORM SIGN SAG TIMES HA;Lo;0;L;;;;;N;;;;;\n1229A;CUNEIFORM SIGN SAG TIMES KAK;Lo;0;L;;;;;N;;;;;\n1229B;CUNEIFORM SIGN SAG TIMES KUR;Lo;0;L;;;;;N;;;;;\n1229C;CUNEIFORM SIGN SAG TIMES LUM;Lo;0;L;;;;;N;;;;;\n1229D;CUNEIFORM SIGN SAG TIMES MI;Lo;0;L;;;;;N;;;;;\n1229E;CUNEIFORM SIGN SAG TIMES NUN;Lo;0;L;;;;;N;;;;;\n1229F;CUNEIFORM SIGN SAG TIMES SAL;Lo;0;L;;;;;N;;;;;\n122A0;CUNEIFORM SIGN SAG TIMES SHID;Lo;0;L;;;;;N;;;;;\n122A1;CUNEIFORM SIGN SAG TIMES TAB;Lo;0;L;;;;;N;;;;;\n122A2;CUNEIFORM SIGN SAG TIMES U2;Lo;0;L;;;;;N;;;;;\n122A3;CUNEIFORM SIGN SAG TIMES UB;Lo;0;L;;;;;N;;;;;\n122A4;CUNEIFORM SIGN SAG TIMES UM;Lo;0;L;;;;;N;;;;;\n122A5;CUNEIFORM SIGN SAG TIMES UR;Lo;0;L;;;;;N;;;;;\n122A6;CUNEIFORM SIGN SAG TIMES USH;Lo;0;L;;;;;N;;;;;\n122A7;CUNEIFORM SIGN SAG OVER SAG;Lo;0;L;;;;;N;;;;;\n122A8;CUNEIFORM SIGN SAG GUNU;Lo;0;L;;;;;N;;;;;\n122A9;CUNEIFORM SIGN SAL;Lo;0;L;;;;;N;;;;;\n122AA;CUNEIFORM SIGN SAL LAGAB TIMES ASH2;Lo;0;L;;;;;N;;;;;\n122AB;CUNEIFORM SIGN SANGA2;Lo;0;L;;;;;N;;;;;\n122AC;CUNEIFORM SIGN SAR;Lo;0;L;;;;;N;;;;;\n122AD;CUNEIFORM SIGN SHA;Lo;0;L;;;;;N;;;;;\n122AE;CUNEIFORM SIGN SHA3;Lo;0;L;;;;;N;;;;;\n122AF;CUNEIFORM SIGN SHA3 TIMES A;Lo;0;L;;;;;N;;;;;\n122B0;CUNEIFORM SIGN SHA3 TIMES BAD;Lo;0;L;;;;;N;;;;;\n122B1;CUNEIFORM SIGN SHA3 TIMES GISH;Lo;0;L;;;;;N;;;;;\n122B2;CUNEIFORM SIGN SHA3 TIMES NE;Lo;0;L;;;;;N;;;;;\n122B3;CUNEIFORM SIGN SHA3 TIMES SHU2;Lo;0;L;;;;;N;;;;;\n122B4;CUNEIFORM SIGN SHA3 TIMES TUR;Lo;0;L;;;;;N;;;;;\n122B5;CUNEIFORM SIGN SHA3 TIMES U;Lo;0;L;;;;;N;;;;;\n122B6;CUNEIFORM SIGN SHA3 TIMES U PLUS A;Lo;0;L;;;;;N;;;;;\n122B7;CUNEIFORM SIGN SHA6;Lo;0;L;;;;;N;;;;;\n122B8;CUNEIFORM SIGN SHAB6;Lo;0;L;;;;;N;;;;;\n122B9;CUNEIFORM SIGN SHAR2;Lo;0;L;;;;;N;;;;;\n122BA;CUNEIFORM SIGN SHE;Lo;0;L;;;;;N;;;;;\n122BB;CUNEIFORM SIGN SHE HU;Lo;0;L;;;;;N;;;;;\n122BC;CUNEIFORM SIGN SHE OVER SHE GAD OVER GAD GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n122BD;CUNEIFORM SIGN SHE OVER SHE TAB OVER TAB GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n122BE;CUNEIFORM SIGN SHEG9;Lo;0;L;;;;;N;;;;;\n122BF;CUNEIFORM SIGN SHEN;Lo;0;L;;;;;N;;;;;\n122C0;CUNEIFORM SIGN SHESH;Lo;0;L;;;;;N;;;;;\n122C1;CUNEIFORM SIGN SHESH2;Lo;0;L;;;;;N;;;;;\n122C2;CUNEIFORM SIGN SHESHLAM;Lo;0;L;;;;;N;;;;;\n122C3;CUNEIFORM SIGN SHID;Lo;0;L;;;;;N;;;;;\n122C4;CUNEIFORM SIGN SHID TIMES A;Lo;0;L;;;;;N;;;;;\n122C5;CUNEIFORM SIGN SHID TIMES IM;Lo;0;L;;;;;N;;;;;\n122C6;CUNEIFORM SIGN SHIM;Lo;0;L;;;;;N;;;;;\n122C7;CUNEIFORM SIGN SHIM TIMES A;Lo;0;L;;;;;N;;;;;\n122C8;CUNEIFORM SIGN SHIM TIMES BAL;Lo;0;L;;;;;N;;;;;\n122C9;CUNEIFORM SIGN SHIM TIMES BULUG;Lo;0;L;;;;;N;;;;;\n122CA;CUNEIFORM SIGN SHIM TIMES DIN;Lo;0;L;;;;;N;;;;;\n122CB;CUNEIFORM SIGN SHIM TIMES GAR;Lo;0;L;;;;;N;;;;;\n122CC;CUNEIFORM SIGN SHIM TIMES IGI;Lo;0;L;;;;;N;;;;;\n122CD;CUNEIFORM SIGN SHIM TIMES IGI GUNU;Lo;0;L;;;;;N;;;;;\n122CE;CUNEIFORM SIGN SHIM TIMES KUSHU2;Lo;0;L;;;;;N;;;;;\n122CF;CUNEIFORM SIGN SHIM TIMES LUL;Lo;0;L;;;;;N;;;;;\n122D0;CUNEIFORM SIGN SHIM TIMES MUG;Lo;0;L;;;;;N;;;;;\n122D1;CUNEIFORM SIGN SHIM TIMES SAL;Lo;0;L;;;;;N;;;;;\n122D2;CUNEIFORM SIGN SHINIG;Lo;0;L;;;;;N;;;;;\n122D3;CUNEIFORM SIGN SHIR;Lo;0;L;;;;;N;;;;;\n122D4;CUNEIFORM SIGN SHIR TENU;Lo;0;L;;;;;N;;;;;\n122D5;CUNEIFORM SIGN SHIR OVER SHIR BUR OVER BUR;Lo;0;L;;;;;N;;;;;\n122D6;CUNEIFORM SIGN SHITA;Lo;0;L;;;;;N;;;;;\n122D7;CUNEIFORM SIGN SHU;Lo;0;L;;;;;N;;;;;\n122D8;CUNEIFORM SIGN SHU OVER INVERTED SHU;Lo;0;L;;;;;N;;;;;\n122D9;CUNEIFORM SIGN SHU2;Lo;0;L;;;;;N;;;;;\n122DA;CUNEIFORM SIGN SHUBUR;Lo;0;L;;;;;N;;;;;\n122DB;CUNEIFORM SIGN SI;Lo;0;L;;;;;N;;;;;\n122DC;CUNEIFORM SIGN SI GUNU;Lo;0;L;;;;;N;;;;;\n122DD;CUNEIFORM SIGN SIG;Lo;0;L;;;;;N;;;;;\n122DE;CUNEIFORM SIGN SIG4;Lo;0;L;;;;;N;;;;;\n122DF;CUNEIFORM SIGN SIG4 OVER SIG4 SHU2;Lo;0;L;;;;;N;;;;;\n122E0;CUNEIFORM SIGN SIK2;Lo;0;L;;;;;N;;;;;\n122E1;CUNEIFORM SIGN SILA3;Lo;0;L;;;;;N;;;;;\n122E2;CUNEIFORM SIGN SU;Lo;0;L;;;;;N;;;;;\n122E3;CUNEIFORM SIGN SU OVER SU;Lo;0;L;;;;;N;;;;;\n122E4;CUNEIFORM SIGN SUD;Lo;0;L;;;;;N;;;;;\n122E5;CUNEIFORM SIGN SUD2;Lo;0;L;;;;;N;;;;;\n122E6;CUNEIFORM SIGN SUHUR;Lo;0;L;;;;;N;;;;;\n122E7;CUNEIFORM SIGN SUM;Lo;0;L;;;;;N;;;;;\n122E8;CUNEIFORM SIGN SUMASH;Lo;0;L;;;;;N;;;;;\n122E9;CUNEIFORM SIGN SUR;Lo;0;L;;;;;N;;;;;\n122EA;CUNEIFORM SIGN SUR9;Lo;0;L;;;;;N;;;;;\n122EB;CUNEIFORM SIGN TA;Lo;0;L;;;;;N;;;;;\n122EC;CUNEIFORM SIGN TA ASTERISK;Lo;0;L;;;;;N;;;;;\n122ED;CUNEIFORM SIGN TA TIMES HI;Lo;0;L;;;;;N;;;;;\n122EE;CUNEIFORM SIGN TA TIMES MI;Lo;0;L;;;;;N;;;;;\n122EF;CUNEIFORM SIGN TA GUNU;Lo;0;L;;;;;N;;;;;\n122F0;CUNEIFORM SIGN TAB;Lo;0;L;;;;;N;;;;;\n122F1;CUNEIFORM SIGN TAB OVER TAB NI OVER NI DISH OVER DISH;Lo;0;L;;;;;N;;;;;\n122F2;CUNEIFORM SIGN TAB SQUARED;Lo;0;L;;;;;N;;;;;\n122F3;CUNEIFORM SIGN TAG;Lo;0;L;;;;;N;;;;;\n122F4;CUNEIFORM SIGN TAG TIMES BI;Lo;0;L;;;;;N;;;;;\n122F5;CUNEIFORM SIGN TAG TIMES GUD;Lo;0;L;;;;;N;;;;;\n122F6;CUNEIFORM SIGN TAG TIMES SHE;Lo;0;L;;;;;N;;;;;\n122F7;CUNEIFORM SIGN TAG TIMES SHU;Lo;0;L;;;;;N;;;;;\n122F8;CUNEIFORM SIGN TAG TIMES TUG2;Lo;0;L;;;;;N;;;;;\n122F9;CUNEIFORM SIGN TAG TIMES UD;Lo;0;L;;;;;N;;;;;\n122FA;CUNEIFORM SIGN TAK4;Lo;0;L;;;;;N;;;;;\n122FB;CUNEIFORM SIGN TAR;Lo;0;L;;;;;N;;;;;\n122FC;CUNEIFORM SIGN TE;Lo;0;L;;;;;N;;;;;\n122FD;CUNEIFORM SIGN TE GUNU;Lo;0;L;;;;;N;;;;;\n122FE;CUNEIFORM SIGN TI;Lo;0;L;;;;;N;;;;;\n122FF;CUNEIFORM SIGN TI TENU;Lo;0;L;;;;;N;;;;;\n12300;CUNEIFORM SIGN TIL;Lo;0;L;;;;;N;;;;;\n12301;CUNEIFORM SIGN TIR;Lo;0;L;;;;;N;;;;;\n12302;CUNEIFORM SIGN TIR TIMES TAK4;Lo;0;L;;;;;N;;;;;\n12303;CUNEIFORM SIGN TIR OVER TIR;Lo;0;L;;;;;N;;;;;\n12304;CUNEIFORM SIGN TIR OVER TIR GAD OVER GAD GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n12305;CUNEIFORM SIGN TU;Lo;0;L;;;;;N;;;;;\n12306;CUNEIFORM SIGN TUG2;Lo;0;L;;;;;N;;;;;\n12307;CUNEIFORM SIGN TUK;Lo;0;L;;;;;N;;;;;\n12308;CUNEIFORM SIGN TUM;Lo;0;L;;;;;N;;;;;\n12309;CUNEIFORM SIGN TUR;Lo;0;L;;;;;N;;;;;\n1230A;CUNEIFORM SIGN TUR OVER TUR ZA OVER ZA;Lo;0;L;;;;;N;;;;;\n1230B;CUNEIFORM SIGN U;Lo;0;L;;;;;N;;;;;\n1230C;CUNEIFORM SIGN U GUD;Lo;0;L;;;;;N;;;;;\n1230D;CUNEIFORM SIGN U U U;Lo;0;L;;;;;N;;;;;\n1230E;CUNEIFORM SIGN U OVER U PA OVER PA GAR OVER GAR;Lo;0;L;;;;;N;;;;;\n1230F;CUNEIFORM SIGN U OVER U SUR OVER SUR;Lo;0;L;;;;;N;;;;;\n12310;CUNEIFORM SIGN U OVER U U REVERSED OVER U REVERSED;Lo;0;L;;;;;N;;;;;\n12311;CUNEIFORM SIGN U2;Lo;0;L;;;;;N;;;;;\n12312;CUNEIFORM SIGN UB;Lo;0;L;;;;;N;;;;;\n12313;CUNEIFORM SIGN UD;Lo;0;L;;;;;N;;;;;\n12314;CUNEIFORM SIGN UD KUSHU2;Lo;0;L;;;;;N;;;;;\n12315;CUNEIFORM SIGN UD TIMES BAD;Lo;0;L;;;;;N;;;;;\n12316;CUNEIFORM SIGN UD TIMES MI;Lo;0;L;;;;;N;;;;;\n12317;CUNEIFORM SIGN UD TIMES U PLUS U PLUS U;Lo;0;L;;;;;N;;;;;\n12318;CUNEIFORM SIGN UD TIMES U PLUS U PLUS U GUNU;Lo;0;L;;;;;N;;;;;\n12319;CUNEIFORM SIGN UD GUNU;Lo;0;L;;;;;N;;;;;\n1231A;CUNEIFORM SIGN UD SHESHIG;Lo;0;L;;;;;N;;;;;\n1231B;CUNEIFORM SIGN UD SHESHIG TIMES BAD;Lo;0;L;;;;;N;;;;;\n1231C;CUNEIFORM SIGN UDUG;Lo;0;L;;;;;N;;;;;\n1231D;CUNEIFORM SIGN UM;Lo;0;L;;;;;N;;;;;\n1231E;CUNEIFORM SIGN UM TIMES LAGAB;Lo;0;L;;;;;N;;;;;\n1231F;CUNEIFORM SIGN UM TIMES ME PLUS DA;Lo;0;L;;;;;N;;;;;\n12320;CUNEIFORM SIGN UM TIMES SHA3;Lo;0;L;;;;;N;;;;;\n12321;CUNEIFORM SIGN UM TIMES U;Lo;0;L;;;;;N;;;;;\n12322;CUNEIFORM SIGN UMBIN;Lo;0;L;;;;;N;;;;;\n12323;CUNEIFORM SIGN UMUM;Lo;0;L;;;;;N;;;;;\n12324;CUNEIFORM SIGN UMUM TIMES KASKAL;Lo;0;L;;;;;N;;;;;\n12325;CUNEIFORM SIGN UMUM TIMES PA;Lo;0;L;;;;;N;;;;;\n12326;CUNEIFORM SIGN UN;Lo;0;L;;;;;N;;;;;\n12327;CUNEIFORM SIGN UN GUNU;Lo;0;L;;;;;N;;;;;\n12328;CUNEIFORM SIGN UR;Lo;0;L;;;;;N;;;;;\n12329;CUNEIFORM SIGN UR CROSSING UR;Lo;0;L;;;;;N;;;;;\n1232A;CUNEIFORM SIGN UR SHESHIG;Lo;0;L;;;;;N;;;;;\n1232B;CUNEIFORM SIGN UR2;Lo;0;L;;;;;N;;;;;\n1232C;CUNEIFORM SIGN UR2 TIMES A PLUS HA;Lo;0;L;;;;;N;;;;;\n1232D;CUNEIFORM SIGN UR2 TIMES A PLUS NA;Lo;0;L;;;;;N;;;;;\n1232E;CUNEIFORM SIGN UR2 TIMES AL;Lo;0;L;;;;;N;;;;;\n1232F;CUNEIFORM SIGN UR2 TIMES HA;Lo;0;L;;;;;N;;;;;\n12330;CUNEIFORM SIGN UR2 TIMES NUN;Lo;0;L;;;;;N;;;;;\n12331;CUNEIFORM SIGN UR2 TIMES U2;Lo;0;L;;;;;N;;;;;\n12332;CUNEIFORM SIGN UR2 TIMES U2 PLUS ASH;Lo;0;L;;;;;N;;;;;\n12333;CUNEIFORM SIGN UR2 TIMES U2 PLUS BI;Lo;0;L;;;;;N;;;;;\n12334;CUNEIFORM SIGN UR4;Lo;0;L;;;;;N;;;;;\n12335;CUNEIFORM SIGN URI;Lo;0;L;;;;;N;;;;;\n12336;CUNEIFORM SIGN URI3;Lo;0;L;;;;;N;;;;;\n12337;CUNEIFORM SIGN URU;Lo;0;L;;;;;N;;;;;\n12338;CUNEIFORM SIGN URU TIMES A;Lo;0;L;;;;;N;;;;;\n12339;CUNEIFORM SIGN URU TIMES ASHGAB;Lo;0;L;;;;;N;;;;;\n1233A;CUNEIFORM SIGN URU TIMES BAR;Lo;0;L;;;;;N;;;;;\n1233B;CUNEIFORM SIGN URU TIMES DUN;Lo;0;L;;;;;N;;;;;\n1233C;CUNEIFORM SIGN URU TIMES GA;Lo;0;L;;;;;N;;;;;\n1233D;CUNEIFORM SIGN URU TIMES GAL;Lo;0;L;;;;;N;;;;;\n1233E;CUNEIFORM SIGN URU TIMES GAN2 TENU;Lo;0;L;;;;;N;;;;;\n1233F;CUNEIFORM SIGN URU TIMES GAR;Lo;0;L;;;;;N;;;;;\n12340;CUNEIFORM SIGN URU TIMES GU;Lo;0;L;;;;;N;;;;;\n12341;CUNEIFORM SIGN URU TIMES HA;Lo;0;L;;;;;N;;;;;\n12342;CUNEIFORM SIGN URU TIMES IGI;Lo;0;L;;;;;N;;;;;\n12343;CUNEIFORM SIGN URU TIMES IM;Lo;0;L;;;;;N;;;;;\n12344;CUNEIFORM SIGN URU TIMES ISH;Lo;0;L;;;;;N;;;;;\n12345;CUNEIFORM SIGN URU TIMES KI;Lo;0;L;;;;;N;;;;;\n12346;CUNEIFORM SIGN URU TIMES LUM;Lo;0;L;;;;;N;;;;;\n12347;CUNEIFORM SIGN URU TIMES MIN;Lo;0;L;;;;;N;;;;;\n12348;CUNEIFORM SIGN URU TIMES PA;Lo;0;L;;;;;N;;;;;\n12349;CUNEIFORM SIGN URU TIMES SHE;Lo;0;L;;;;;N;;;;;\n1234A;CUNEIFORM SIGN URU TIMES SIG4;Lo;0;L;;;;;N;;;;;\n1234B;CUNEIFORM SIGN URU TIMES TU;Lo;0;L;;;;;N;;;;;\n1234C;CUNEIFORM SIGN URU TIMES U PLUS GUD;Lo;0;L;;;;;N;;;;;\n1234D;CUNEIFORM SIGN URU TIMES UD;Lo;0;L;;;;;N;;;;;\n1234E;CUNEIFORM SIGN URU TIMES URUDA;Lo;0;L;;;;;N;;;;;\n1234F;CUNEIFORM SIGN URUDA;Lo;0;L;;;;;N;;;;;\n12350;CUNEIFORM SIGN URUDA TIMES U;Lo;0;L;;;;;N;;;;;\n12351;CUNEIFORM SIGN USH;Lo;0;L;;;;;N;;;;;\n12352;CUNEIFORM SIGN USH TIMES A;Lo;0;L;;;;;N;;;;;\n12353;CUNEIFORM SIGN USH TIMES KU;Lo;0;L;;;;;N;;;;;\n12354;CUNEIFORM SIGN USH TIMES KUR;Lo;0;L;;;;;N;;;;;\n12355;CUNEIFORM SIGN USH TIMES TAK4;Lo;0;L;;;;;N;;;;;\n12356;CUNEIFORM SIGN USHX;Lo;0;L;;;;;N;;;;;\n12357;CUNEIFORM SIGN USH2;Lo;0;L;;;;;N;;;;;\n12358;CUNEIFORM SIGN USHUMX;Lo;0;L;;;;;N;;;;;\n12359;CUNEIFORM SIGN UTUKI;Lo;0;L;;;;;N;;;;;\n1235A;CUNEIFORM SIGN UZ3;Lo;0;L;;;;;N;;;;;\n1235B;CUNEIFORM SIGN UZ3 TIMES KASKAL;Lo;0;L;;;;;N;;;;;\n1235C;CUNEIFORM SIGN UZU;Lo;0;L;;;;;N;;;;;\n1235D;CUNEIFORM SIGN ZA;Lo;0;L;;;;;N;;;;;\n1235E;CUNEIFORM SIGN ZA TENU;Lo;0;L;;;;;N;;;;;\n1235F;CUNEIFORM SIGN ZA SQUARED TIMES KUR;Lo;0;L;;;;;N;;;;;\n12360;CUNEIFORM SIGN ZAG;Lo;0;L;;;;;N;;;;;\n12361;CUNEIFORM SIGN ZAMX;Lo;0;L;;;;;N;;;;;\n12362;CUNEIFORM SIGN ZE2;Lo;0;L;;;;;N;;;;;\n12363;CUNEIFORM SIGN ZI;Lo;0;L;;;;;N;;;;;\n12364;CUNEIFORM SIGN ZI OVER ZI;Lo;0;L;;;;;N;;;;;\n12365;CUNEIFORM SIGN ZI3;Lo;0;L;;;;;N;;;;;\n12366;CUNEIFORM SIGN ZIB;Lo;0;L;;;;;N;;;;;\n12367;CUNEIFORM SIGN ZIB KABA TENU;Lo;0;L;;;;;N;;;;;\n12368;CUNEIFORM SIGN ZIG;Lo;0;L;;;;;N;;;;;\n12369;CUNEIFORM SIGN ZIZ2;Lo;0;L;;;;;N;;;;;\n1236A;CUNEIFORM SIGN ZU;Lo;0;L;;;;;N;;;;;\n1236B;CUNEIFORM SIGN ZU5;Lo;0;L;;;;;N;;;;;\n1236C;CUNEIFORM SIGN ZU5 TIMES A;Lo;0;L;;;;;N;;;;;\n1236D;CUNEIFORM SIGN ZUBUR;Lo;0;L;;;;;N;;;;;\n1236E;CUNEIFORM SIGN ZUM;Lo;0;L;;;;;N;;;;;\n12400;CUNEIFORM NUMERIC SIGN TWO ASH;Nl;0;L;;;;2;N;;;;;\n12401;CUNEIFORM NUMERIC SIGN THREE ASH;Nl;0;L;;;;3;N;;;;;\n12402;CUNEIFORM NUMERIC SIGN FOUR ASH;Nl;0;L;;;;4;N;;;;;\n12403;CUNEIFORM NUMERIC SIGN FIVE ASH;Nl;0;L;;;;5;N;;;;;\n12404;CUNEIFORM NUMERIC SIGN SIX ASH;Nl;0;L;;;;6;N;;;;;\n12405;CUNEIFORM NUMERIC SIGN SEVEN ASH;Nl;0;L;;;;7;N;;;;;\n12406;CUNEIFORM NUMERIC SIGN EIGHT ASH;Nl;0;L;;;;8;N;;;;;\n12407;CUNEIFORM NUMERIC SIGN NINE ASH;Nl;0;L;;;;9;N;;;;;\n12408;CUNEIFORM NUMERIC SIGN THREE DISH;Nl;0;L;;;;3;N;;;;;\n12409;CUNEIFORM NUMERIC SIGN FOUR DISH;Nl;0;L;;;;4;N;;;;;\n1240A;CUNEIFORM NUMERIC SIGN FIVE DISH;Nl;0;L;;;;5;N;;;;;\n1240B;CUNEIFORM NUMERIC SIGN SIX DISH;Nl;0;L;;;;6;N;;;;;\n1240C;CUNEIFORM NUMERIC SIGN SEVEN DISH;Nl;0;L;;;;7;N;;;;;\n1240D;CUNEIFORM NUMERIC SIGN EIGHT DISH;Nl;0;L;;;;8;N;;;;;\n1240E;CUNEIFORM NUMERIC SIGN NINE DISH;Nl;0;L;;;;9;N;;;;;\n1240F;CUNEIFORM NUMERIC SIGN FOUR U;Nl;0;L;;;;4;N;;;;;\n12410;CUNEIFORM NUMERIC SIGN FIVE U;Nl;0;L;;;;5;N;;;;;\n12411;CUNEIFORM NUMERIC SIGN SIX U;Nl;0;L;;;;6;N;;;;;\n12412;CUNEIFORM NUMERIC SIGN SEVEN U;Nl;0;L;;;;7;N;;;;;\n12413;CUNEIFORM NUMERIC SIGN EIGHT U;Nl;0;L;;;;8;N;;;;;\n12414;CUNEIFORM NUMERIC SIGN NINE U;Nl;0;L;;;;9;N;;;;;\n12415;CUNEIFORM NUMERIC SIGN ONE GESH2;Nl;0;L;;;;1;N;;;;;\n12416;CUNEIFORM NUMERIC SIGN TWO GESH2;Nl;0;L;;;;2;N;;;;;\n12417;CUNEIFORM NUMERIC SIGN THREE GESH2;Nl;0;L;;;;3;N;;;;;\n12418;CUNEIFORM NUMERIC SIGN FOUR GESH2;Nl;0;L;;;;4;N;;;;;\n12419;CUNEIFORM NUMERIC SIGN FIVE GESH2;Nl;0;L;;;;5;N;;;;;\n1241A;CUNEIFORM NUMERIC SIGN SIX GESH2;Nl;0;L;;;;6;N;;;;;\n1241B;CUNEIFORM NUMERIC SIGN SEVEN GESH2;Nl;0;L;;;;7;N;;;;;\n1241C;CUNEIFORM NUMERIC SIGN EIGHT GESH2;Nl;0;L;;;;8;N;;;;;\n1241D;CUNEIFORM NUMERIC SIGN NINE GESH2;Nl;0;L;;;;9;N;;;;;\n1241E;CUNEIFORM NUMERIC SIGN ONE GESHU;Nl;0;L;;;;1;N;;;;;\n1241F;CUNEIFORM NUMERIC SIGN TWO GESHU;Nl;0;L;;;;2;N;;;;;\n12420;CUNEIFORM NUMERIC SIGN THREE GESHU;Nl;0;L;;;;3;N;;;;;\n12421;CUNEIFORM NUMERIC SIGN FOUR GESHU;Nl;0;L;;;;4;N;;;;;\n12422;CUNEIFORM NUMERIC SIGN FIVE GESHU;Nl;0;L;;;;5;N;;;;;\n12423;CUNEIFORM NUMERIC SIGN TWO SHAR2;Nl;0;L;;;;2;N;;;;;\n12424;CUNEIFORM NUMERIC SIGN THREE SHAR2;Nl;0;L;;;;3;N;;;;;\n12425;CUNEIFORM NUMERIC SIGN THREE SHAR2 VARIANT FORM;Nl;0;L;;;;3;N;;;;;\n12426;CUNEIFORM NUMERIC SIGN FOUR SHAR2;Nl;0;L;;;;4;N;;;;;\n12427;CUNEIFORM NUMERIC SIGN FIVE SHAR2;Nl;0;L;;;;5;N;;;;;\n12428;CUNEIFORM NUMERIC SIGN SIX SHAR2;Nl;0;L;;;;6;N;;;;;\n12429;CUNEIFORM NUMERIC SIGN SEVEN SHAR2;Nl;0;L;;;;7;N;;;;;\n1242A;CUNEIFORM NUMERIC SIGN EIGHT SHAR2;Nl;0;L;;;;8;N;;;;;\n1242B;CUNEIFORM NUMERIC SIGN NINE SHAR2;Nl;0;L;;;;9;N;;;;;\n1242C;CUNEIFORM NUMERIC SIGN ONE SHARU;Nl;0;L;;;;1;N;;;;;\n1242D;CUNEIFORM NUMERIC SIGN TWO SHARU;Nl;0;L;;;;2;N;;;;;\n1242E;CUNEIFORM NUMERIC SIGN THREE SHARU;Nl;0;L;;;;3;N;;;;;\n1242F;CUNEIFORM NUMERIC SIGN THREE SHARU VARIANT FORM;Nl;0;L;;;;3;N;;;;;\n12430;CUNEIFORM NUMERIC SIGN FOUR SHARU;Nl;0;L;;;;4;N;;;;;\n12431;CUNEIFORM NUMERIC SIGN FIVE SHARU;Nl;0;L;;;;5;N;;;;;\n12432;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS DISH;Nl;0;L;;;;;N;;;;;\n12433;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS MIN;Nl;0;L;;;;;N;;;;;\n12434;CUNEIFORM NUMERIC SIGN ONE BURU;Nl;0;L;;;;1;N;;;;;\n12435;CUNEIFORM NUMERIC SIGN TWO BURU;Nl;0;L;;;;2;N;;;;;\n12436;CUNEIFORM NUMERIC SIGN THREE BURU;Nl;0;L;;;;3;N;;;;;\n12437;CUNEIFORM NUMERIC SIGN THREE BURU VARIANT FORM;Nl;0;L;;;;3;N;;;;;\n12438;CUNEIFORM NUMERIC SIGN FOUR BURU;Nl;0;L;;;;4;N;;;;;\n12439;CUNEIFORM NUMERIC SIGN FIVE BURU;Nl;0;L;;;;5;N;;;;;\n1243A;CUNEIFORM NUMERIC SIGN THREE VARIANT FORM ESH16;Nl;0;L;;;;3;N;;;;;\n1243B;CUNEIFORM NUMERIC SIGN THREE VARIANT FORM ESH21;Nl;0;L;;;;3;N;;;;;\n1243C;CUNEIFORM NUMERIC SIGN FOUR VARIANT FORM LIMMU;Nl;0;L;;;;4;N;;;;;\n1243D;CUNEIFORM NUMERIC SIGN FOUR VARIANT FORM LIMMU4;Nl;0;L;;;;4;N;;;;;\n1243E;CUNEIFORM NUMERIC SIGN FOUR VARIANT FORM LIMMU A;Nl;0;L;;;;4;N;;;;;\n1243F;CUNEIFORM NUMERIC SIGN FOUR VARIANT FORM LIMMU B;Nl;0;L;;;;4;N;;;;;\n12440;CUNEIFORM NUMERIC SIGN SIX VARIANT FORM ASH9;Nl;0;L;;;;6;N;;;;;\n12441;CUNEIFORM NUMERIC SIGN SEVEN VARIANT FORM IMIN3;Nl;0;L;;;;7;N;;;;;\n12442;CUNEIFORM NUMERIC SIGN SEVEN VARIANT FORM IMIN A;Nl;0;L;;;;7;N;;;;;\n12443;CUNEIFORM NUMERIC SIGN SEVEN VARIANT FORM IMIN B;Nl;0;L;;;;7;N;;;;;\n12444;CUNEIFORM NUMERIC SIGN EIGHT VARIANT FORM USSU;Nl;0;L;;;;8;N;;;;;\n12445;CUNEIFORM NUMERIC SIGN EIGHT VARIANT FORM USSU3;Nl;0;L;;;;8;N;;;;;\n12446;CUNEIFORM NUMERIC SIGN NINE VARIANT FORM ILIMMU;Nl;0;L;;;;9;N;;;;;\n12447;CUNEIFORM NUMERIC SIGN NINE VARIANT FORM ILIMMU3;Nl;0;L;;;;9;N;;;;;\n12448;CUNEIFORM NUMERIC SIGN NINE VARIANT FORM ILIMMU4;Nl;0;L;;;;9;N;;;;;\n12449;CUNEIFORM NUMERIC SIGN NINE VARIANT FORM ILIMMU A;Nl;0;L;;;;9;N;;;;;\n1244A;CUNEIFORM NUMERIC SIGN TWO ASH TENU;Nl;0;L;;;;2;N;;;;;\n1244B;CUNEIFORM NUMERIC SIGN THREE ASH TENU;Nl;0;L;;;;3;N;;;;;\n1244C;CUNEIFORM NUMERIC SIGN FOUR ASH TENU;Nl;0;L;;;;4;N;;;;;\n1244D;CUNEIFORM NUMERIC SIGN FIVE ASH TENU;Nl;0;L;;;;5;N;;;;;\n1244E;CUNEIFORM NUMERIC SIGN SIX ASH TENU;Nl;0;L;;;;6;N;;;;;\n1244F;CUNEIFORM NUMERIC SIGN ONE BAN2;Nl;0;L;;;;1;N;;;;;\n12450;CUNEIFORM NUMERIC SIGN TWO BAN2;Nl;0;L;;;;2;N;;;;;\n12451;CUNEIFORM NUMERIC SIGN THREE BAN2;Nl;0;L;;;;3;N;;;;;\n12452;CUNEIFORM NUMERIC SIGN FOUR BAN2;Nl;0;L;;;;4;N;;;;;\n12453;CUNEIFORM NUMERIC SIGN FOUR BAN2 VARIANT FORM;Nl;0;L;;;;4;N;;;;;\n12454;CUNEIFORM NUMERIC SIGN FIVE BAN2;Nl;0;L;;;;5;N;;;;;\n12455;CUNEIFORM NUMERIC SIGN FIVE BAN2 VARIANT FORM;Nl;0;L;;;;5;N;;;;;\n12456;CUNEIFORM NUMERIC SIGN NIGIDAMIN;Nl;0;L;;;;;N;;;;;\n12457;CUNEIFORM NUMERIC SIGN NIGIDAESH;Nl;0;L;;;;;N;;;;;\n12458;CUNEIFORM NUMERIC SIGN ONE ESHE3;Nl;0;L;;;;1;N;;;;;\n12459;CUNEIFORM NUMERIC SIGN TWO ESHE3;Nl;0;L;;;;2;N;;;;;\n1245A;CUNEIFORM NUMERIC SIGN ONE THIRD DISH;Nl;0;L;;;;1/3;N;;;;;\n1245B;CUNEIFORM NUMERIC SIGN TWO THIRDS DISH;Nl;0;L;;;;2/3;N;;;;;\n1245C;CUNEIFORM NUMERIC SIGN FIVE SIXTHS DISH;Nl;0;L;;;;5/6;N;;;;;\n1245D;CUNEIFORM NUMERIC SIGN ONE THIRD VARIANT FORM A;Nl;0;L;;;;1/3;N;;;;;\n1245E;CUNEIFORM NUMERIC SIGN TWO THIRDS VARIANT FORM A;Nl;0;L;;;;2/3;N;;;;;\n1245F;CUNEIFORM NUMERIC SIGN ONE EIGHTH ASH;Nl;0;L;;;;1/8;N;;;;;\n12460;CUNEIFORM NUMERIC SIGN ONE QUARTER ASH;Nl;0;L;;;;1/4;N;;;;;\n12461;CUNEIFORM NUMERIC SIGN OLD ASSYRIAN ONE SIXTH;Nl;0;L;;;;1/6;N;;;;;\n12462;CUNEIFORM NUMERIC SIGN OLD ASSYRIAN ONE QUARTER;Nl;0;L;;;;1/4;N;;;;;\n12470;CUNEIFORM PUNCTUATION SIGN OLD ASSYRIAN WORD DIVIDER;Po;0;L;;;;;N;;;;;\n12471;CUNEIFORM PUNCTUATION SIGN VERTICAL COLON;Po;0;L;;;;;N;;;;;\n12472;CUNEIFORM PUNCTUATION SIGN DIAGONAL COLON;Po;0;L;;;;;N;;;;;\n12473;CUNEIFORM PUNCTUATION SIGN DIAGONAL TRICOLON;Po;0;L;;;;;N;;;;;\n13000;EGYPTIAN HIEROGLYPH A001;Lo;0;L;;;;;N;;;;;\n13001;EGYPTIAN HIEROGLYPH A002;Lo;0;L;;;;;N;;;;;\n13002;EGYPTIAN HIEROGLYPH A003;Lo;0;L;;;;;N;;;;;\n13003;EGYPTIAN HIEROGLYPH A004;Lo;0;L;;;;;N;;;;;\n13004;EGYPTIAN HIEROGLYPH A005;Lo;0;L;;;;;N;;;;;\n13005;EGYPTIAN HIEROGLYPH A005A;Lo;0;L;;;;;N;;;;;\n13006;EGYPTIAN HIEROGLYPH A006;Lo;0;L;;;;;N;;;;;\n13007;EGYPTIAN HIEROGLYPH A006A;Lo;0;L;;;;;N;;;;;\n13008;EGYPTIAN HIEROGLYPH A006B;Lo;0;L;;;;;N;;;;;\n13009;EGYPTIAN HIEROGLYPH A007;Lo;0;L;;;;;N;;;;;\n1300A;EGYPTIAN HIEROGLYPH A008;Lo;0;L;;;;;N;;;;;\n1300B;EGYPTIAN HIEROGLYPH A009;Lo;0;L;;;;;N;;;;;\n1300C;EGYPTIAN HIEROGLYPH A010;Lo;0;L;;;;;N;;;;;\n1300D;EGYPTIAN HIEROGLYPH A011;Lo;0;L;;;;;N;;;;;\n1300E;EGYPTIAN HIEROGLYPH A012;Lo;0;L;;;;;N;;;;;\n1300F;EGYPTIAN HIEROGLYPH A013;Lo;0;L;;;;;N;;;;;\n13010;EGYPTIAN HIEROGLYPH A014;Lo;0;L;;;;;N;;;;;\n13011;EGYPTIAN HIEROGLYPH A014A;Lo;0;L;;;;;N;;;;;\n13012;EGYPTIAN HIEROGLYPH A015;Lo;0;L;;;;;N;;;;;\n13013;EGYPTIAN HIEROGLYPH A016;Lo;0;L;;;;;N;;;;;\n13014;EGYPTIAN HIEROGLYPH A017;Lo;0;L;;;;;N;;;;;\n13015;EGYPTIAN HIEROGLYPH A017A;Lo;0;L;;;;;N;;;;;\n13016;EGYPTIAN HIEROGLYPH A018;Lo;0;L;;;;;N;;;;;\n13017;EGYPTIAN HIEROGLYPH A019;Lo;0;L;;;;;N;;;;;\n13018;EGYPTIAN HIEROGLYPH A020;Lo;0;L;;;;;N;;;;;\n13019;EGYPTIAN HIEROGLYPH A021;Lo;0;L;;;;;N;;;;;\n1301A;EGYPTIAN HIEROGLYPH A022;Lo;0;L;;;;;N;;;;;\n1301B;EGYPTIAN HIEROGLYPH A023;Lo;0;L;;;;;N;;;;;\n1301C;EGYPTIAN HIEROGLYPH A024;Lo;0;L;;;;;N;;;;;\n1301D;EGYPTIAN HIEROGLYPH A025;Lo;0;L;;;;;N;;;;;\n1301E;EGYPTIAN HIEROGLYPH A026;Lo;0;L;;;;;N;;;;;\n1301F;EGYPTIAN HIEROGLYPH A027;Lo;0;L;;;;;N;;;;;\n13020;EGYPTIAN HIEROGLYPH A028;Lo;0;L;;;;;N;;;;;\n13021;EGYPTIAN HIEROGLYPH A029;Lo;0;L;;;;;N;;;;;\n13022;EGYPTIAN HIEROGLYPH A030;Lo;0;L;;;;;N;;;;;\n13023;EGYPTIAN HIEROGLYPH A031;Lo;0;L;;;;;N;;;;;\n13024;EGYPTIAN HIEROGLYPH A032;Lo;0;L;;;;;N;;;;;\n13025;EGYPTIAN HIEROGLYPH A032A;Lo;0;L;;;;;N;;;;;\n13026;EGYPTIAN HIEROGLYPH A033;Lo;0;L;;;;;N;;;;;\n13027;EGYPTIAN HIEROGLYPH A034;Lo;0;L;;;;;N;;;;;\n13028;EGYPTIAN HIEROGLYPH A035;Lo;0;L;;;;;N;;;;;\n13029;EGYPTIAN HIEROGLYPH A036;Lo;0;L;;;;;N;;;;;\n1302A;EGYPTIAN HIEROGLYPH A037;Lo;0;L;;;;;N;;;;;\n1302B;EGYPTIAN HIEROGLYPH A038;Lo;0;L;;;;;N;;;;;\n1302C;EGYPTIAN HIEROGLYPH A039;Lo;0;L;;;;;N;;;;;\n1302D;EGYPTIAN HIEROGLYPH A040;Lo;0;L;;;;;N;;;;;\n1302E;EGYPTIAN HIEROGLYPH A040A;Lo;0;L;;;;;N;;;;;\n1302F;EGYPTIAN HIEROGLYPH A041;Lo;0;L;;;;;N;;;;;\n13030;EGYPTIAN HIEROGLYPH A042;Lo;0;L;;;;;N;;;;;\n13031;EGYPTIAN HIEROGLYPH A042A;Lo;0;L;;;;;N;;;;;\n13032;EGYPTIAN HIEROGLYPH A043;Lo;0;L;;;;;N;;;;;\n13033;EGYPTIAN HIEROGLYPH A043A;Lo;0;L;;;;;N;;;;;\n13034;EGYPTIAN HIEROGLYPH A044;Lo;0;L;;;;;N;;;;;\n13035;EGYPTIAN HIEROGLYPH A045;Lo;0;L;;;;;N;;;;;\n13036;EGYPTIAN HIEROGLYPH A045A;Lo;0;L;;;;;N;;;;;\n13037;EGYPTIAN HIEROGLYPH A046;Lo;0;L;;;;;N;;;;;\n13038;EGYPTIAN HIEROGLYPH A047;Lo;0;L;;;;;N;;;;;\n13039;EGYPTIAN HIEROGLYPH A048;Lo;0;L;;;;;N;;;;;\n1303A;EGYPTIAN HIEROGLYPH A049;Lo;0;L;;;;;N;;;;;\n1303B;EGYPTIAN HIEROGLYPH A050;Lo;0;L;;;;;N;;;;;\n1303C;EGYPTIAN HIEROGLYPH A051;Lo;0;L;;;;;N;;;;;\n1303D;EGYPTIAN HIEROGLYPH A052;Lo;0;L;;;;;N;;;;;\n1303E;EGYPTIAN HIEROGLYPH A053;Lo;0;L;;;;;N;;;;;\n1303F;EGYPTIAN HIEROGLYPH A054;Lo;0;L;;;;;N;;;;;\n13040;EGYPTIAN HIEROGLYPH A055;Lo;0;L;;;;;N;;;;;\n13041;EGYPTIAN HIEROGLYPH A056;Lo;0;L;;;;;N;;;;;\n13042;EGYPTIAN HIEROGLYPH A057;Lo;0;L;;;;;N;;;;;\n13043;EGYPTIAN HIEROGLYPH A058;Lo;0;L;;;;;N;;;;;\n13044;EGYPTIAN HIEROGLYPH A059;Lo;0;L;;;;;N;;;;;\n13045;EGYPTIAN HIEROGLYPH A060;Lo;0;L;;;;;N;;;;;\n13046;EGYPTIAN HIEROGLYPH A061;Lo;0;L;;;;;N;;;;;\n13047;EGYPTIAN HIEROGLYPH A062;Lo;0;L;;;;;N;;;;;\n13048;EGYPTIAN HIEROGLYPH A063;Lo;0;L;;;;;N;;;;;\n13049;EGYPTIAN HIEROGLYPH A064;Lo;0;L;;;;;N;;;;;\n1304A;EGYPTIAN HIEROGLYPH A065;Lo;0;L;;;;;N;;;;;\n1304B;EGYPTIAN HIEROGLYPH A066;Lo;0;L;;;;;N;;;;;\n1304C;EGYPTIAN HIEROGLYPH A067;Lo;0;L;;;;;N;;;;;\n1304D;EGYPTIAN HIEROGLYPH A068;Lo;0;L;;;;;N;;;;;\n1304E;EGYPTIAN HIEROGLYPH A069;Lo;0;L;;;;;N;;;;;\n1304F;EGYPTIAN HIEROGLYPH A070;Lo;0;L;;;;;N;;;;;\n13050;EGYPTIAN HIEROGLYPH B001;Lo;0;L;;;;;N;;;;;\n13051;EGYPTIAN HIEROGLYPH B002;Lo;0;L;;;;;N;;;;;\n13052;EGYPTIAN HIEROGLYPH B003;Lo;0;L;;;;;N;;;;;\n13053;EGYPTIAN HIEROGLYPH B004;Lo;0;L;;;;;N;;;;;\n13054;EGYPTIAN HIEROGLYPH B005;Lo;0;L;;;;;N;;;;;\n13055;EGYPTIAN HIEROGLYPH B005A;Lo;0;L;;;;;N;;;;;\n13056;EGYPTIAN HIEROGLYPH B006;Lo;0;L;;;;;N;;;;;\n13057;EGYPTIAN HIEROGLYPH B007;Lo;0;L;;;;;N;;;;;\n13058;EGYPTIAN HIEROGLYPH B008;Lo;0;L;;;;;N;;;;;\n13059;EGYPTIAN HIEROGLYPH B009;Lo;0;L;;;;;N;;;;;\n1305A;EGYPTIAN HIEROGLYPH C001;Lo;0;L;;;;;N;;;;;\n1305B;EGYPTIAN HIEROGLYPH C002;Lo;0;L;;;;;N;;;;;\n1305C;EGYPTIAN HIEROGLYPH C002A;Lo;0;L;;;;;N;;;;;\n1305D;EGYPTIAN HIEROGLYPH C002B;Lo;0;L;;;;;N;;;;;\n1305E;EGYPTIAN HIEROGLYPH C002C;Lo;0;L;;;;;N;;;;;\n1305F;EGYPTIAN HIEROGLYPH C003;Lo;0;L;;;;;N;;;;;\n13060;EGYPTIAN HIEROGLYPH C004;Lo;0;L;;;;;N;;;;;\n13061;EGYPTIAN HIEROGLYPH C005;Lo;0;L;;;;;N;;;;;\n13062;EGYPTIAN HIEROGLYPH C006;Lo;0;L;;;;;N;;;;;\n13063;EGYPTIAN HIEROGLYPH C007;Lo;0;L;;;;;N;;;;;\n13064;EGYPTIAN HIEROGLYPH C008;Lo;0;L;;;;;N;;;;;\n13065;EGYPTIAN HIEROGLYPH C009;Lo;0;L;;;;;N;;;;;\n13066;EGYPTIAN HIEROGLYPH C010;Lo;0;L;;;;;N;;;;;\n13067;EGYPTIAN HIEROGLYPH C010A;Lo;0;L;;;;;N;;;;;\n13068;EGYPTIAN HIEROGLYPH C011;Lo;0;L;;;;;N;;;;;\n13069;EGYPTIAN HIEROGLYPH C012;Lo;0;L;;;;;N;;;;;\n1306A;EGYPTIAN HIEROGLYPH C013;Lo;0;L;;;;;N;;;;;\n1306B;EGYPTIAN HIEROGLYPH C014;Lo;0;L;;;;;N;;;;;\n1306C;EGYPTIAN HIEROGLYPH C015;Lo;0;L;;;;;N;;;;;\n1306D;EGYPTIAN HIEROGLYPH C016;Lo;0;L;;;;;N;;;;;\n1306E;EGYPTIAN HIEROGLYPH C017;Lo;0;L;;;;;N;;;;;\n1306F;EGYPTIAN HIEROGLYPH C018;Lo;0;L;;;;;N;;;;;\n13070;EGYPTIAN HIEROGLYPH C019;Lo;0;L;;;;;N;;;;;\n13071;EGYPTIAN HIEROGLYPH C020;Lo;0;L;;;;;N;;;;;\n13072;EGYPTIAN HIEROGLYPH C021;Lo;0;L;;;;;N;;;;;\n13073;EGYPTIAN HIEROGLYPH C022;Lo;0;L;;;;;N;;;;;\n13074;EGYPTIAN HIEROGLYPH C023;Lo;0;L;;;;;N;;;;;\n13075;EGYPTIAN HIEROGLYPH C024;Lo;0;L;;;;;N;;;;;\n13076;EGYPTIAN HIEROGLYPH D001;Lo;0;L;;;;;N;;;;;\n13077;EGYPTIAN HIEROGLYPH D002;Lo;0;L;;;;;N;;;;;\n13078;EGYPTIAN HIEROGLYPH D003;Lo;0;L;;;;;N;;;;;\n13079;EGYPTIAN HIEROGLYPH D004;Lo;0;L;;;;;N;;;;;\n1307A;EGYPTIAN HIEROGLYPH D005;Lo;0;L;;;;;N;;;;;\n1307B;EGYPTIAN HIEROGLYPH D006;Lo;0;L;;;;;N;;;;;\n1307C;EGYPTIAN HIEROGLYPH D007;Lo;0;L;;;;;N;;;;;\n1307D;EGYPTIAN HIEROGLYPH D008;Lo;0;L;;;;;N;;;;;\n1307E;EGYPTIAN HIEROGLYPH D008A;Lo;0;L;;;;;N;;;;;\n1307F;EGYPTIAN HIEROGLYPH D009;Lo;0;L;;;;;N;;;;;\n13080;EGYPTIAN HIEROGLYPH D010;Lo;0;L;;;;;N;;;;;\n13081;EGYPTIAN HIEROGLYPH D011;Lo;0;L;;;;;N;;;;;\n13082;EGYPTIAN HIEROGLYPH D012;Lo;0;L;;;;;N;;;;;\n13083;EGYPTIAN HIEROGLYPH D013;Lo;0;L;;;;;N;;;;;\n13084;EGYPTIAN HIEROGLYPH D014;Lo;0;L;;;;;N;;;;;\n13085;EGYPTIAN HIEROGLYPH D015;Lo;0;L;;;;;N;;;;;\n13086;EGYPTIAN HIEROGLYPH D016;Lo;0;L;;;;;N;;;;;\n13087;EGYPTIAN HIEROGLYPH D017;Lo;0;L;;;;;N;;;;;\n13088;EGYPTIAN HIEROGLYPH D018;Lo;0;L;;;;;N;;;;;\n13089;EGYPTIAN HIEROGLYPH D019;Lo;0;L;;;;;N;;;;;\n1308A;EGYPTIAN HIEROGLYPH D020;Lo;0;L;;;;;N;;;;;\n1308B;EGYPTIAN HIEROGLYPH D021;Lo;0;L;;;;;N;;;;;\n1308C;EGYPTIAN HIEROGLYPH D022;Lo;0;L;;;;;N;;;;;\n1308D;EGYPTIAN HIEROGLYPH D023;Lo;0;L;;;;;N;;;;;\n1308E;EGYPTIAN HIEROGLYPH D024;Lo;0;L;;;;;N;;;;;\n1308F;EGYPTIAN HIEROGLYPH D025;Lo;0;L;;;;;N;;;;;\n13090;EGYPTIAN HIEROGLYPH D026;Lo;0;L;;;;;N;;;;;\n13091;EGYPTIAN HIEROGLYPH D027;Lo;0;L;;;;;N;;;;;\n13092;EGYPTIAN HIEROGLYPH D027A;Lo;0;L;;;;;N;;;;;\n13093;EGYPTIAN HIEROGLYPH D028;Lo;0;L;;;;;N;;;;;\n13094;EGYPTIAN HIEROGLYPH D029;Lo;0;L;;;;;N;;;;;\n13095;EGYPTIAN HIEROGLYPH D030;Lo;0;L;;;;;N;;;;;\n13096;EGYPTIAN HIEROGLYPH D031;Lo;0;L;;;;;N;;;;;\n13097;EGYPTIAN HIEROGLYPH D031A;Lo;0;L;;;;;N;;;;;\n13098;EGYPTIAN HIEROGLYPH D032;Lo;0;L;;;;;N;;;;;\n13099;EGYPTIAN HIEROGLYPH D033;Lo;0;L;;;;;N;;;;;\n1309A;EGYPTIAN HIEROGLYPH D034;Lo;0;L;;;;;N;;;;;\n1309B;EGYPTIAN HIEROGLYPH D034A;Lo;0;L;;;;;N;;;;;\n1309C;EGYPTIAN HIEROGLYPH D035;Lo;0;L;;;;;N;;;;;\n1309D;EGYPTIAN HIEROGLYPH D036;Lo;0;L;;;;;N;;;;;\n1309E;EGYPTIAN HIEROGLYPH D037;Lo;0;L;;;;;N;;;;;\n1309F;EGYPTIAN HIEROGLYPH D038;Lo;0;L;;;;;N;;;;;\n130A0;EGYPTIAN HIEROGLYPH D039;Lo;0;L;;;;;N;;;;;\n130A1;EGYPTIAN HIEROGLYPH D040;Lo;0;L;;;;;N;;;;;\n130A2;EGYPTIAN HIEROGLYPH D041;Lo;0;L;;;;;N;;;;;\n130A3;EGYPTIAN HIEROGLYPH D042;Lo;0;L;;;;;N;;;;;\n130A4;EGYPTIAN HIEROGLYPH D043;Lo;0;L;;;;;N;;;;;\n130A5;EGYPTIAN HIEROGLYPH D044;Lo;0;L;;;;;N;;;;;\n130A6;EGYPTIAN HIEROGLYPH D045;Lo;0;L;;;;;N;;;;;\n130A7;EGYPTIAN HIEROGLYPH D046;Lo;0;L;;;;;N;;;;;\n130A8;EGYPTIAN HIEROGLYPH D046A;Lo;0;L;;;;;N;;;;;\n130A9;EGYPTIAN HIEROGLYPH D047;Lo;0;L;;;;;N;;;;;\n130AA;EGYPTIAN HIEROGLYPH D048;Lo;0;L;;;;;N;;;;;\n130AB;EGYPTIAN HIEROGLYPH D048A;Lo;0;L;;;;;N;;;;;\n130AC;EGYPTIAN HIEROGLYPH D049;Lo;0;L;;;;;N;;;;;\n130AD;EGYPTIAN HIEROGLYPH D050;Lo;0;L;;;;;N;;;;;\n130AE;EGYPTIAN HIEROGLYPH D050A;Lo;0;L;;;;;N;;;;;\n130AF;EGYPTIAN HIEROGLYPH D050B;Lo;0;L;;;;;N;;;;;\n130B0;EGYPTIAN HIEROGLYPH D050C;Lo;0;L;;;;;N;;;;;\n130B1;EGYPTIAN HIEROGLYPH D050D;Lo;0;L;;;;;N;;;;;\n130B2;EGYPTIAN HIEROGLYPH D050E;Lo;0;L;;;;;N;;;;;\n130B3;EGYPTIAN HIEROGLYPH D050F;Lo;0;L;;;;;N;;;;;\n130B4;EGYPTIAN HIEROGLYPH D050G;Lo;0;L;;;;;N;;;;;\n130B5;EGYPTIAN HIEROGLYPH D050H;Lo;0;L;;;;;N;;;;;\n130B6;EGYPTIAN HIEROGLYPH D050I;Lo;0;L;;;;;N;;;;;\n130B7;EGYPTIAN HIEROGLYPH D051;Lo;0;L;;;;;N;;;;;\n130B8;EGYPTIAN HIEROGLYPH D052;Lo;0;L;;;;;N;;;;;\n130B9;EGYPTIAN HIEROGLYPH D052A;Lo;0;L;;;;;N;;;;;\n130BA;EGYPTIAN HIEROGLYPH D053;Lo;0;L;;;;;N;;;;;\n130BB;EGYPTIAN HIEROGLYPH D054;Lo;0;L;;;;;N;;;;;\n130BC;EGYPTIAN HIEROGLYPH D054A;Lo;0;L;;;;;N;;;;;\n130BD;EGYPTIAN HIEROGLYPH D055;Lo;0;L;;;;;N;;;;;\n130BE;EGYPTIAN HIEROGLYPH D056;Lo;0;L;;;;;N;;;;;\n130BF;EGYPTIAN HIEROGLYPH D057;Lo;0;L;;;;;N;;;;;\n130C0;EGYPTIAN HIEROGLYPH D058;Lo;0;L;;;;;N;;;;;\n130C1;EGYPTIAN HIEROGLYPH D059;Lo;0;L;;;;;N;;;;;\n130C2;EGYPTIAN HIEROGLYPH D060;Lo;0;L;;;;;N;;;;;\n130C3;EGYPTIAN HIEROGLYPH D061;Lo;0;L;;;;;N;;;;;\n130C4;EGYPTIAN HIEROGLYPH D062;Lo;0;L;;;;;N;;;;;\n130C5;EGYPTIAN HIEROGLYPH D063;Lo;0;L;;;;;N;;;;;\n130C6;EGYPTIAN HIEROGLYPH D064;Lo;0;L;;;;;N;;;;;\n130C7;EGYPTIAN HIEROGLYPH D065;Lo;0;L;;;;;N;;;;;\n130C8;EGYPTIAN HIEROGLYPH D066;Lo;0;L;;;;;N;;;;;\n130C9;EGYPTIAN HIEROGLYPH D067;Lo;0;L;;;;;N;;;;;\n130CA;EGYPTIAN HIEROGLYPH D067A;Lo;0;L;;;;;N;;;;;\n130CB;EGYPTIAN HIEROGLYPH D067B;Lo;0;L;;;;;N;;;;;\n130CC;EGYPTIAN HIEROGLYPH D067C;Lo;0;L;;;;;N;;;;;\n130CD;EGYPTIAN HIEROGLYPH D067D;Lo;0;L;;;;;N;;;;;\n130CE;EGYPTIAN HIEROGLYPH D067E;Lo;0;L;;;;;N;;;;;\n130CF;EGYPTIAN HIEROGLYPH D067F;Lo;0;L;;;;;N;;;;;\n130D0;EGYPTIAN HIEROGLYPH D067G;Lo;0;L;;;;;N;;;;;\n130D1;EGYPTIAN HIEROGLYPH D067H;Lo;0;L;;;;;N;;;;;\n130D2;EGYPTIAN HIEROGLYPH E001;Lo;0;L;;;;;N;;;;;\n130D3;EGYPTIAN HIEROGLYPH E002;Lo;0;L;;;;;N;;;;;\n130D4;EGYPTIAN HIEROGLYPH E003;Lo;0;L;;;;;N;;;;;\n130D5;EGYPTIAN HIEROGLYPH E004;Lo;0;L;;;;;N;;;;;\n130D6;EGYPTIAN HIEROGLYPH E005;Lo;0;L;;;;;N;;;;;\n130D7;EGYPTIAN HIEROGLYPH E006;Lo;0;L;;;;;N;;;;;\n130D8;EGYPTIAN HIEROGLYPH E007;Lo;0;L;;;;;N;;;;;\n130D9;EGYPTIAN HIEROGLYPH E008;Lo;0;L;;;;;N;;;;;\n130DA;EGYPTIAN HIEROGLYPH E008A;Lo;0;L;;;;;N;;;;;\n130DB;EGYPTIAN HIEROGLYPH E009;Lo;0;L;;;;;N;;;;;\n130DC;EGYPTIAN HIEROGLYPH E009A;Lo;0;L;;;;;N;;;;;\n130DD;EGYPTIAN HIEROGLYPH E010;Lo;0;L;;;;;N;;;;;\n130DE;EGYPTIAN HIEROGLYPH E011;Lo;0;L;;;;;N;;;;;\n130DF;EGYPTIAN HIEROGLYPH E012;Lo;0;L;;;;;N;;;;;\n130E0;EGYPTIAN HIEROGLYPH E013;Lo;0;L;;;;;N;;;;;\n130E1;EGYPTIAN HIEROGLYPH E014;Lo;0;L;;;;;N;;;;;\n130E2;EGYPTIAN HIEROGLYPH E015;Lo;0;L;;;;;N;;;;;\n130E3;EGYPTIAN HIEROGLYPH E016;Lo;0;L;;;;;N;;;;;\n130E4;EGYPTIAN HIEROGLYPH E016A;Lo;0;L;;;;;N;;;;;\n130E5;EGYPTIAN HIEROGLYPH E017;Lo;0;L;;;;;N;;;;;\n130E6;EGYPTIAN HIEROGLYPH E017A;Lo;0;L;;;;;N;;;;;\n130E7;EGYPTIAN HIEROGLYPH E018;Lo;0;L;;;;;N;;;;;\n130E8;EGYPTIAN HIEROGLYPH E019;Lo;0;L;;;;;N;;;;;\n130E9;EGYPTIAN HIEROGLYPH E020;Lo;0;L;;;;;N;;;;;\n130EA;EGYPTIAN HIEROGLYPH E020A;Lo;0;L;;;;;N;;;;;\n130EB;EGYPTIAN HIEROGLYPH E021;Lo;0;L;;;;;N;;;;;\n130EC;EGYPTIAN HIEROGLYPH E022;Lo;0;L;;;;;N;;;;;\n130ED;EGYPTIAN HIEROGLYPH E023;Lo;0;L;;;;;N;;;;;\n130EE;EGYPTIAN HIEROGLYPH E024;Lo;0;L;;;;;N;;;;;\n130EF;EGYPTIAN HIEROGLYPH E025;Lo;0;L;;;;;N;;;;;\n130F0;EGYPTIAN HIEROGLYPH E026;Lo;0;L;;;;;N;;;;;\n130F1;EGYPTIAN HIEROGLYPH E027;Lo;0;L;;;;;N;;;;;\n130F2;EGYPTIAN HIEROGLYPH E028;Lo;0;L;;;;;N;;;;;\n130F3;EGYPTIAN HIEROGLYPH E028A;Lo;0;L;;;;;N;;;;;\n130F4;EGYPTIAN HIEROGLYPH E029;Lo;0;L;;;;;N;;;;;\n130F5;EGYPTIAN HIEROGLYPH E030;Lo;0;L;;;;;N;;;;;\n130F6;EGYPTIAN HIEROGLYPH E031;Lo;0;L;;;;;N;;;;;\n130F7;EGYPTIAN HIEROGLYPH E032;Lo;0;L;;;;;N;;;;;\n130F8;EGYPTIAN HIEROGLYPH E033;Lo;0;L;;;;;N;;;;;\n130F9;EGYPTIAN HIEROGLYPH E034;Lo;0;L;;;;;N;;;;;\n130FA;EGYPTIAN HIEROGLYPH E034A;Lo;0;L;;;;;N;;;;;\n130FB;EGYPTIAN HIEROGLYPH E036;Lo;0;L;;;;;N;;;;;\n130FC;EGYPTIAN HIEROGLYPH E037;Lo;0;L;;;;;N;;;;;\n130FD;EGYPTIAN HIEROGLYPH E038;Lo;0;L;;;;;N;;;;;\n130FE;EGYPTIAN HIEROGLYPH F001;Lo;0;L;;;;;N;;;;;\n130FF;EGYPTIAN HIEROGLYPH F001A;Lo;0;L;;;;;N;;;;;\n13100;EGYPTIAN HIEROGLYPH F002;Lo;0;L;;;;;N;;;;;\n13101;EGYPTIAN HIEROGLYPH F003;Lo;0;L;;;;;N;;;;;\n13102;EGYPTIAN HIEROGLYPH F004;Lo;0;L;;;;;N;;;;;\n13103;EGYPTIAN HIEROGLYPH F005;Lo;0;L;;;;;N;;;;;\n13104;EGYPTIAN HIEROGLYPH F006;Lo;0;L;;;;;N;;;;;\n13105;EGYPTIAN HIEROGLYPH F007;Lo;0;L;;;;;N;;;;;\n13106;EGYPTIAN HIEROGLYPH F008;Lo;0;L;;;;;N;;;;;\n13107;EGYPTIAN HIEROGLYPH F009;Lo;0;L;;;;;N;;;;;\n13108;EGYPTIAN HIEROGLYPH F010;Lo;0;L;;;;;N;;;;;\n13109;EGYPTIAN HIEROGLYPH F011;Lo;0;L;;;;;N;;;;;\n1310A;EGYPTIAN HIEROGLYPH F012;Lo;0;L;;;;;N;;;;;\n1310B;EGYPTIAN HIEROGLYPH F013;Lo;0;L;;;;;N;;;;;\n1310C;EGYPTIAN HIEROGLYPH F013A;Lo;0;L;;;;;N;;;;;\n1310D;EGYPTIAN HIEROGLYPH F014;Lo;0;L;;;;;N;;;;;\n1310E;EGYPTIAN HIEROGLYPH F015;Lo;0;L;;;;;N;;;;;\n1310F;EGYPTIAN HIEROGLYPH F016;Lo;0;L;;;;;N;;;;;\n13110;EGYPTIAN HIEROGLYPH F017;Lo;0;L;;;;;N;;;;;\n13111;EGYPTIAN HIEROGLYPH F018;Lo;0;L;;;;;N;;;;;\n13112;EGYPTIAN HIEROGLYPH F019;Lo;0;L;;;;;N;;;;;\n13113;EGYPTIAN HIEROGLYPH F020;Lo;0;L;;;;;N;;;;;\n13114;EGYPTIAN HIEROGLYPH F021;Lo;0;L;;;;;N;;;;;\n13115;EGYPTIAN HIEROGLYPH F021A;Lo;0;L;;;;;N;;;;;\n13116;EGYPTIAN HIEROGLYPH F022;Lo;0;L;;;;;N;;;;;\n13117;EGYPTIAN HIEROGLYPH F023;Lo;0;L;;;;;N;;;;;\n13118;EGYPTIAN HIEROGLYPH F024;Lo;0;L;;;;;N;;;;;\n13119;EGYPTIAN HIEROGLYPH F025;Lo;0;L;;;;;N;;;;;\n1311A;EGYPTIAN HIEROGLYPH F026;Lo;0;L;;;;;N;;;;;\n1311B;EGYPTIAN HIEROGLYPH F027;Lo;0;L;;;;;N;;;;;\n1311C;EGYPTIAN HIEROGLYPH F028;Lo;0;L;;;;;N;;;;;\n1311D;EGYPTIAN HIEROGLYPH F029;Lo;0;L;;;;;N;;;;;\n1311E;EGYPTIAN HIEROGLYPH F030;Lo;0;L;;;;;N;;;;;\n1311F;EGYPTIAN HIEROGLYPH F031;Lo;0;L;;;;;N;;;;;\n13120;EGYPTIAN HIEROGLYPH F031A;Lo;0;L;;;;;N;;;;;\n13121;EGYPTIAN HIEROGLYPH F032;Lo;0;L;;;;;N;;;;;\n13122;EGYPTIAN HIEROGLYPH F033;Lo;0;L;;;;;N;;;;;\n13123;EGYPTIAN HIEROGLYPH F034;Lo;0;L;;;;;N;;;;;\n13124;EGYPTIAN HIEROGLYPH F035;Lo;0;L;;;;;N;;;;;\n13125;EGYPTIAN HIEROGLYPH F036;Lo;0;L;;;;;N;;;;;\n13126;EGYPTIAN HIEROGLYPH F037;Lo;0;L;;;;;N;;;;;\n13127;EGYPTIAN HIEROGLYPH F037A;Lo;0;L;;;;;N;;;;;\n13128;EGYPTIAN HIEROGLYPH F038;Lo;0;L;;;;;N;;;;;\n13129;EGYPTIAN HIEROGLYPH F038A;Lo;0;L;;;;;N;;;;;\n1312A;EGYPTIAN HIEROGLYPH F039;Lo;0;L;;;;;N;;;;;\n1312B;EGYPTIAN HIEROGLYPH F040;Lo;0;L;;;;;N;;;;;\n1312C;EGYPTIAN HIEROGLYPH F041;Lo;0;L;;;;;N;;;;;\n1312D;EGYPTIAN HIEROGLYPH F042;Lo;0;L;;;;;N;;;;;\n1312E;EGYPTIAN HIEROGLYPH F043;Lo;0;L;;;;;N;;;;;\n1312F;EGYPTIAN HIEROGLYPH F044;Lo;0;L;;;;;N;;;;;\n13130;EGYPTIAN HIEROGLYPH F045;Lo;0;L;;;;;N;;;;;\n13131;EGYPTIAN HIEROGLYPH F045A;Lo;0;L;;;;;N;;;;;\n13132;EGYPTIAN HIEROGLYPH F046;Lo;0;L;;;;;N;;;;;\n13133;EGYPTIAN HIEROGLYPH F046A;Lo;0;L;;;;;N;;;;;\n13134;EGYPTIAN HIEROGLYPH F047;Lo;0;L;;;;;N;;;;;\n13135;EGYPTIAN HIEROGLYPH F047A;Lo;0;L;;;;;N;;;;;\n13136;EGYPTIAN HIEROGLYPH F048;Lo;0;L;;;;;N;;;;;\n13137;EGYPTIAN HIEROGLYPH F049;Lo;0;L;;;;;N;;;;;\n13138;EGYPTIAN HIEROGLYPH F050;Lo;0;L;;;;;N;;;;;\n13139;EGYPTIAN HIEROGLYPH F051;Lo;0;L;;;;;N;;;;;\n1313A;EGYPTIAN HIEROGLYPH F051A;Lo;0;L;;;;;N;;;;;\n1313B;EGYPTIAN HIEROGLYPH F051B;Lo;0;L;;;;;N;;;;;\n1313C;EGYPTIAN HIEROGLYPH F051C;Lo;0;L;;;;;N;;;;;\n1313D;EGYPTIAN HIEROGLYPH F052;Lo;0;L;;;;;N;;;;;\n1313E;EGYPTIAN HIEROGLYPH F053;Lo;0;L;;;;;N;;;;;\n1313F;EGYPTIAN HIEROGLYPH G001;Lo;0;L;;;;;N;;;;;\n13140;EGYPTIAN HIEROGLYPH G002;Lo;0;L;;;;;N;;;;;\n13141;EGYPTIAN HIEROGLYPH G003;Lo;0;L;;;;;N;;;;;\n13142;EGYPTIAN HIEROGLYPH G004;Lo;0;L;;;;;N;;;;;\n13143;EGYPTIAN HIEROGLYPH G005;Lo;0;L;;;;;N;;;;;\n13144;EGYPTIAN HIEROGLYPH G006;Lo;0;L;;;;;N;;;;;\n13145;EGYPTIAN HIEROGLYPH G006A;Lo;0;L;;;;;N;;;;;\n13146;EGYPTIAN HIEROGLYPH G007;Lo;0;L;;;;;N;;;;;\n13147;EGYPTIAN HIEROGLYPH G007A;Lo;0;L;;;;;N;;;;;\n13148;EGYPTIAN HIEROGLYPH G007B;Lo;0;L;;;;;N;;;;;\n13149;EGYPTIAN HIEROGLYPH G008;Lo;0;L;;;;;N;;;;;\n1314A;EGYPTIAN HIEROGLYPH G009;Lo;0;L;;;;;N;;;;;\n1314B;EGYPTIAN HIEROGLYPH G010;Lo;0;L;;;;;N;;;;;\n1314C;EGYPTIAN HIEROGLYPH G011;Lo;0;L;;;;;N;;;;;\n1314D;EGYPTIAN HIEROGLYPH G011A;Lo;0;L;;;;;N;;;;;\n1314E;EGYPTIAN HIEROGLYPH G012;Lo;0;L;;;;;N;;;;;\n1314F;EGYPTIAN HIEROGLYPH G013;Lo;0;L;;;;;N;;;;;\n13150;EGYPTIAN HIEROGLYPH G014;Lo;0;L;;;;;N;;;;;\n13151;EGYPTIAN HIEROGLYPH G015;Lo;0;L;;;;;N;;;;;\n13152;EGYPTIAN HIEROGLYPH G016;Lo;0;L;;;;;N;;;;;\n13153;EGYPTIAN HIEROGLYPH G017;Lo;0;L;;;;;N;;;;;\n13154;EGYPTIAN HIEROGLYPH G018;Lo;0;L;;;;;N;;;;;\n13155;EGYPTIAN HIEROGLYPH G019;Lo;0;L;;;;;N;;;;;\n13156;EGYPTIAN HIEROGLYPH G020;Lo;0;L;;;;;N;;;;;\n13157;EGYPTIAN HIEROGLYPH G020A;Lo;0;L;;;;;N;;;;;\n13158;EGYPTIAN HIEROGLYPH G021;Lo;0;L;;;;;N;;;;;\n13159;EGYPTIAN HIEROGLYPH G022;Lo;0;L;;;;;N;;;;;\n1315A;EGYPTIAN HIEROGLYPH G023;Lo;0;L;;;;;N;;;;;\n1315B;EGYPTIAN HIEROGLYPH G024;Lo;0;L;;;;;N;;;;;\n1315C;EGYPTIAN HIEROGLYPH G025;Lo;0;L;;;;;N;;;;;\n1315D;EGYPTIAN HIEROGLYPH G026;Lo;0;L;;;;;N;;;;;\n1315E;EGYPTIAN HIEROGLYPH G026A;Lo;0;L;;;;;N;;;;;\n1315F;EGYPTIAN HIEROGLYPH G027;Lo;0;L;;;;;N;;;;;\n13160;EGYPTIAN HIEROGLYPH G028;Lo;0;L;;;;;N;;;;;\n13161;EGYPTIAN HIEROGLYPH G029;Lo;0;L;;;;;N;;;;;\n13162;EGYPTIAN HIEROGLYPH G030;Lo;0;L;;;;;N;;;;;\n13163;EGYPTIAN HIEROGLYPH G031;Lo;0;L;;;;;N;;;;;\n13164;EGYPTIAN HIEROGLYPH G032;Lo;0;L;;;;;N;;;;;\n13165;EGYPTIAN HIEROGLYPH G033;Lo;0;L;;;;;N;;;;;\n13166;EGYPTIAN HIEROGLYPH G034;Lo;0;L;;;;;N;;;;;\n13167;EGYPTIAN HIEROGLYPH G035;Lo;0;L;;;;;N;;;;;\n13168;EGYPTIAN HIEROGLYPH G036;Lo;0;L;;;;;N;;;;;\n13169;EGYPTIAN HIEROGLYPH G036A;Lo;0;L;;;;;N;;;;;\n1316A;EGYPTIAN HIEROGLYPH G037;Lo;0;L;;;;;N;;;;;\n1316B;EGYPTIAN HIEROGLYPH G037A;Lo;0;L;;;;;N;;;;;\n1316C;EGYPTIAN HIEROGLYPH G038;Lo;0;L;;;;;N;;;;;\n1316D;EGYPTIAN HIEROGLYPH G039;Lo;0;L;;;;;N;;;;;\n1316E;EGYPTIAN HIEROGLYPH G040;Lo;0;L;;;;;N;;;;;\n1316F;EGYPTIAN HIEROGLYPH G041;Lo;0;L;;;;;N;;;;;\n13170;EGYPTIAN HIEROGLYPH G042;Lo;0;L;;;;;N;;;;;\n13171;EGYPTIAN HIEROGLYPH G043;Lo;0;L;;;;;N;;;;;\n13172;EGYPTIAN HIEROGLYPH G043A;Lo;0;L;;;;;N;;;;;\n13173;EGYPTIAN HIEROGLYPH G044;Lo;0;L;;;;;N;;;;;\n13174;EGYPTIAN HIEROGLYPH G045;Lo;0;L;;;;;N;;;;;\n13175;EGYPTIAN HIEROGLYPH G045A;Lo;0;L;;;;;N;;;;;\n13176;EGYPTIAN HIEROGLYPH G046;Lo;0;L;;;;;N;;;;;\n13177;EGYPTIAN HIEROGLYPH G047;Lo;0;L;;;;;N;;;;;\n13178;EGYPTIAN HIEROGLYPH G048;Lo;0;L;;;;;N;;;;;\n13179;EGYPTIAN HIEROGLYPH G049;Lo;0;L;;;;;N;;;;;\n1317A;EGYPTIAN HIEROGLYPH G050;Lo;0;L;;;;;N;;;;;\n1317B;EGYPTIAN HIEROGLYPH G051;Lo;0;L;;;;;N;;;;;\n1317C;EGYPTIAN HIEROGLYPH G052;Lo;0;L;;;;;N;;;;;\n1317D;EGYPTIAN HIEROGLYPH G053;Lo;0;L;;;;;N;;;;;\n1317E;EGYPTIAN HIEROGLYPH G054;Lo;0;L;;;;;N;;;;;\n1317F;EGYPTIAN HIEROGLYPH H001;Lo;0;L;;;;;N;;;;;\n13180;EGYPTIAN HIEROGLYPH H002;Lo;0;L;;;;;N;;;;;\n13181;EGYPTIAN HIEROGLYPH H003;Lo;0;L;;;;;N;;;;;\n13182;EGYPTIAN HIEROGLYPH H004;Lo;0;L;;;;;N;;;;;\n13183;EGYPTIAN HIEROGLYPH H005;Lo;0;L;;;;;N;;;;;\n13184;EGYPTIAN HIEROGLYPH H006;Lo;0;L;;;;;N;;;;;\n13185;EGYPTIAN HIEROGLYPH H006A;Lo;0;L;;;;;N;;;;;\n13186;EGYPTIAN HIEROGLYPH H007;Lo;0;L;;;;;N;;;;;\n13187;EGYPTIAN HIEROGLYPH H008;Lo;0;L;;;;;N;;;;;\n13188;EGYPTIAN HIEROGLYPH I001;Lo;0;L;;;;;N;;;;;\n13189;EGYPTIAN HIEROGLYPH I002;Lo;0;L;;;;;N;;;;;\n1318A;EGYPTIAN HIEROGLYPH I003;Lo;0;L;;;;;N;;;;;\n1318B;EGYPTIAN HIEROGLYPH I004;Lo;0;L;;;;;N;;;;;\n1318C;EGYPTIAN HIEROGLYPH I005;Lo;0;L;;;;;N;;;;;\n1318D;EGYPTIAN HIEROGLYPH I005A;Lo;0;L;;;;;N;;;;;\n1318E;EGYPTIAN HIEROGLYPH I006;Lo;0;L;;;;;N;;;;;\n1318F;EGYPTIAN HIEROGLYPH I007;Lo;0;L;;;;;N;;;;;\n13190;EGYPTIAN HIEROGLYPH I008;Lo;0;L;;;;;N;;;;;\n13191;EGYPTIAN HIEROGLYPH I009;Lo;0;L;;;;;N;;;;;\n13192;EGYPTIAN HIEROGLYPH I009A;Lo;0;L;;;;;N;;;;;\n13193;EGYPTIAN HIEROGLYPH I010;Lo;0;L;;;;;N;;;;;\n13194;EGYPTIAN HIEROGLYPH I010A;Lo;0;L;;;;;N;;;;;\n13195;EGYPTIAN HIEROGLYPH I011;Lo;0;L;;;;;N;;;;;\n13196;EGYPTIAN HIEROGLYPH I011A;Lo;0;L;;;;;N;;;;;\n13197;EGYPTIAN HIEROGLYPH I012;Lo;0;L;;;;;N;;;;;\n13198;EGYPTIAN HIEROGLYPH I013;Lo;0;L;;;;;N;;;;;\n13199;EGYPTIAN HIEROGLYPH I014;Lo;0;L;;;;;N;;;;;\n1319A;EGYPTIAN HIEROGLYPH I015;Lo;0;L;;;;;N;;;;;\n1319B;EGYPTIAN HIEROGLYPH K001;Lo;0;L;;;;;N;;;;;\n1319C;EGYPTIAN HIEROGLYPH K002;Lo;0;L;;;;;N;;;;;\n1319D;EGYPTIAN HIEROGLYPH K003;Lo;0;L;;;;;N;;;;;\n1319E;EGYPTIAN HIEROGLYPH K004;Lo;0;L;;;;;N;;;;;\n1319F;EGYPTIAN HIEROGLYPH K005;Lo;0;L;;;;;N;;;;;\n131A0;EGYPTIAN HIEROGLYPH K006;Lo;0;L;;;;;N;;;;;\n131A1;EGYPTIAN HIEROGLYPH K007;Lo;0;L;;;;;N;;;;;\n131A2;EGYPTIAN HIEROGLYPH K008;Lo;0;L;;;;;N;;;;;\n131A3;EGYPTIAN HIEROGLYPH L001;Lo;0;L;;;;;N;;;;;\n131A4;EGYPTIAN HIEROGLYPH L002;Lo;0;L;;;;;N;;;;;\n131A5;EGYPTIAN HIEROGLYPH L002A;Lo;0;L;;;;;N;;;;;\n131A6;EGYPTIAN HIEROGLYPH L003;Lo;0;L;;;;;N;;;;;\n131A7;EGYPTIAN HIEROGLYPH L004;Lo;0;L;;;;;N;;;;;\n131A8;EGYPTIAN HIEROGLYPH L005;Lo;0;L;;;;;N;;;;;\n131A9;EGYPTIAN HIEROGLYPH L006;Lo;0;L;;;;;N;;;;;\n131AA;EGYPTIAN HIEROGLYPH L006A;Lo;0;L;;;;;N;;;;;\n131AB;EGYPTIAN HIEROGLYPH L007;Lo;0;L;;;;;N;;;;;\n131AC;EGYPTIAN HIEROGLYPH L008;Lo;0;L;;;;;N;;;;;\n131AD;EGYPTIAN HIEROGLYPH M001;Lo;0;L;;;;;N;;;;;\n131AE;EGYPTIAN HIEROGLYPH M001A;Lo;0;L;;;;;N;;;;;\n131AF;EGYPTIAN HIEROGLYPH M001B;Lo;0;L;;;;;N;;;;;\n131B0;EGYPTIAN HIEROGLYPH M002;Lo;0;L;;;;;N;;;;;\n131B1;EGYPTIAN HIEROGLYPH M003;Lo;0;L;;;;;N;;;;;\n131B2;EGYPTIAN HIEROGLYPH M003A;Lo;0;L;;;;;N;;;;;\n131B3;EGYPTIAN HIEROGLYPH M004;Lo;0;L;;;;;N;;;;;\n131B4;EGYPTIAN HIEROGLYPH M005;Lo;0;L;;;;;N;;;;;\n131B5;EGYPTIAN HIEROGLYPH M006;Lo;0;L;;;;;N;;;;;\n131B6;EGYPTIAN HIEROGLYPH M007;Lo;0;L;;;;;N;;;;;\n131B7;EGYPTIAN HIEROGLYPH M008;Lo;0;L;;;;;N;;;;;\n131B8;EGYPTIAN HIEROGLYPH M009;Lo;0;L;;;;;N;;;;;\n131B9;EGYPTIAN HIEROGLYPH M010;Lo;0;L;;;;;N;;;;;\n131BA;EGYPTIAN HIEROGLYPH M010A;Lo;0;L;;;;;N;;;;;\n131BB;EGYPTIAN HIEROGLYPH M011;Lo;0;L;;;;;N;;;;;\n131BC;EGYPTIAN HIEROGLYPH M012;Lo;0;L;;;;;N;;;;;\n131BD;EGYPTIAN HIEROGLYPH M012A;Lo;0;L;;;;;N;;;;;\n131BE;EGYPTIAN HIEROGLYPH M012B;Lo;0;L;;;;;N;;;;;\n131BF;EGYPTIAN HIEROGLYPH M012C;Lo;0;L;;;;;N;;;;;\n131C0;EGYPTIAN HIEROGLYPH M012D;Lo;0;L;;;;;N;;;;;\n131C1;EGYPTIAN HIEROGLYPH M012E;Lo;0;L;;;;;N;;;;;\n131C2;EGYPTIAN HIEROGLYPH M012F;Lo;0;L;;;;;N;;;;;\n131C3;EGYPTIAN HIEROGLYPH M012G;Lo;0;L;;;;;N;;;;;\n131C4;EGYPTIAN HIEROGLYPH M012H;Lo;0;L;;;;;N;;;;;\n131C5;EGYPTIAN HIEROGLYPH M013;Lo;0;L;;;;;N;;;;;\n131C6;EGYPTIAN HIEROGLYPH M014;Lo;0;L;;;;;N;;;;;\n131C7;EGYPTIAN HIEROGLYPH M015;Lo;0;L;;;;;N;;;;;\n131C8;EGYPTIAN HIEROGLYPH M015A;Lo;0;L;;;;;N;;;;;\n131C9;EGYPTIAN HIEROGLYPH M016;Lo;0;L;;;;;N;;;;;\n131CA;EGYPTIAN HIEROGLYPH M016A;Lo;0;L;;;;;N;;;;;\n131CB;EGYPTIAN HIEROGLYPH M017;Lo;0;L;;;;;N;;;;;\n131CC;EGYPTIAN HIEROGLYPH M017A;Lo;0;L;;;;;N;;;;;\n131CD;EGYPTIAN HIEROGLYPH M018;Lo;0;L;;;;;N;;;;;\n131CE;EGYPTIAN HIEROGLYPH M019;Lo;0;L;;;;;N;;;;;\n131CF;EGYPTIAN HIEROGLYPH M020;Lo;0;L;;;;;N;;;;;\n131D0;EGYPTIAN HIEROGLYPH M021;Lo;0;L;;;;;N;;;;;\n131D1;EGYPTIAN HIEROGLYPH M022;Lo;0;L;;;;;N;;;;;\n131D2;EGYPTIAN HIEROGLYPH M022A;Lo;0;L;;;;;N;;;;;\n131D3;EGYPTIAN HIEROGLYPH M023;Lo;0;L;;;;;N;;;;;\n131D4;EGYPTIAN HIEROGLYPH M024;Lo;0;L;;;;;N;;;;;\n131D5;EGYPTIAN HIEROGLYPH M024A;Lo;0;L;;;;;N;;;;;\n131D6;EGYPTIAN HIEROGLYPH M025;Lo;0;L;;;;;N;;;;;\n131D7;EGYPTIAN HIEROGLYPH M026;Lo;0;L;;;;;N;;;;;\n131D8;EGYPTIAN HIEROGLYPH M027;Lo;0;L;;;;;N;;;;;\n131D9;EGYPTIAN HIEROGLYPH M028;Lo;0;L;;;;;N;;;;;\n131DA;EGYPTIAN HIEROGLYPH M028A;Lo;0;L;;;;;N;;;;;\n131DB;EGYPTIAN HIEROGLYPH M029;Lo;0;L;;;;;N;;;;;\n131DC;EGYPTIAN HIEROGLYPH M030;Lo;0;L;;;;;N;;;;;\n131DD;EGYPTIAN HIEROGLYPH M031;Lo;0;L;;;;;N;;;;;\n131DE;EGYPTIAN HIEROGLYPH M031A;Lo;0;L;;;;;N;;;;;\n131DF;EGYPTIAN HIEROGLYPH M032;Lo;0;L;;;;;N;;;;;\n131E0;EGYPTIAN HIEROGLYPH M033;Lo;0;L;;;;;N;;;;;\n131E1;EGYPTIAN HIEROGLYPH M033A;Lo;0;L;;;;;N;;;;;\n131E2;EGYPTIAN HIEROGLYPH M033B;Lo;0;L;;;;;N;;;;;\n131E3;EGYPTIAN HIEROGLYPH M034;Lo;0;L;;;;;N;;;;;\n131E4;EGYPTIAN HIEROGLYPH M035;Lo;0;L;;;;;N;;;;;\n131E5;EGYPTIAN HIEROGLYPH M036;Lo;0;L;;;;;N;;;;;\n131E6;EGYPTIAN HIEROGLYPH M037;Lo;0;L;;;;;N;;;;;\n131E7;EGYPTIAN HIEROGLYPH M038;Lo;0;L;;;;;N;;;;;\n131E8;EGYPTIAN HIEROGLYPH M039;Lo;0;L;;;;;N;;;;;\n131E9;EGYPTIAN HIEROGLYPH M040;Lo;0;L;;;;;N;;;;;\n131EA;EGYPTIAN HIEROGLYPH M040A;Lo;0;L;;;;;N;;;;;\n131EB;EGYPTIAN HIEROGLYPH M041;Lo;0;L;;;;;N;;;;;\n131EC;EGYPTIAN HIEROGLYPH M042;Lo;0;L;;;;;N;;;;;\n131ED;EGYPTIAN HIEROGLYPH M043;Lo;0;L;;;;;N;;;;;\n131EE;EGYPTIAN HIEROGLYPH M044;Lo;0;L;;;;;N;;;;;\n131EF;EGYPTIAN HIEROGLYPH N001;Lo;0;L;;;;;N;;;;;\n131F0;EGYPTIAN HIEROGLYPH N002;Lo;0;L;;;;;N;;;;;\n131F1;EGYPTIAN HIEROGLYPH N003;Lo;0;L;;;;;N;;;;;\n131F2;EGYPTIAN HIEROGLYPH N004;Lo;0;L;;;;;N;;;;;\n131F3;EGYPTIAN HIEROGLYPH N005;Lo;0;L;;;;;N;;;;;\n131F4;EGYPTIAN HIEROGLYPH N006;Lo;0;L;;;;;N;;;;;\n131F5;EGYPTIAN HIEROGLYPH N007;Lo;0;L;;;;;N;;;;;\n131F6;EGYPTIAN HIEROGLYPH N008;Lo;0;L;;;;;N;;;;;\n131F7;EGYPTIAN HIEROGLYPH N009;Lo;0;L;;;;;N;;;;;\n131F8;EGYPTIAN HIEROGLYPH N010;Lo;0;L;;;;;N;;;;;\n131F9;EGYPTIAN HIEROGLYPH N011;Lo;0;L;;;;;N;;;;;\n131FA;EGYPTIAN HIEROGLYPH N012;Lo;0;L;;;;;N;;;;;\n131FB;EGYPTIAN HIEROGLYPH N013;Lo;0;L;;;;;N;;;;;\n131FC;EGYPTIAN HIEROGLYPH N014;Lo;0;L;;;;;N;;;;;\n131FD;EGYPTIAN HIEROGLYPH N015;Lo;0;L;;;;;N;;;;;\n131FE;EGYPTIAN HIEROGLYPH N016;Lo;0;L;;;;;N;;;;;\n131FF;EGYPTIAN HIEROGLYPH N017;Lo;0;L;;;;;N;;;;;\n13200;EGYPTIAN HIEROGLYPH N018;Lo;0;L;;;;;N;;;;;\n13201;EGYPTIAN HIEROGLYPH N018A;Lo;0;L;;;;;N;;;;;\n13202;EGYPTIAN HIEROGLYPH N018B;Lo;0;L;;;;;N;;;;;\n13203;EGYPTIAN HIEROGLYPH N019;Lo;0;L;;;;;N;;;;;\n13204;EGYPTIAN HIEROGLYPH N020;Lo;0;L;;;;;N;;;;;\n13205;EGYPTIAN HIEROGLYPH N021;Lo;0;L;;;;;N;;;;;\n13206;EGYPTIAN HIEROGLYPH N022;Lo;0;L;;;;;N;;;;;\n13207;EGYPTIAN HIEROGLYPH N023;Lo;0;L;;;;;N;;;;;\n13208;EGYPTIAN HIEROGLYPH N024;Lo;0;L;;;;;N;;;;;\n13209;EGYPTIAN HIEROGLYPH N025;Lo;0;L;;;;;N;;;;;\n1320A;EGYPTIAN HIEROGLYPH N025A;Lo;0;L;;;;;N;;;;;\n1320B;EGYPTIAN HIEROGLYPH N026;Lo;0;L;;;;;N;;;;;\n1320C;EGYPTIAN HIEROGLYPH N027;Lo;0;L;;;;;N;;;;;\n1320D;EGYPTIAN HIEROGLYPH N028;Lo;0;L;;;;;N;;;;;\n1320E;EGYPTIAN HIEROGLYPH N029;Lo;0;L;;;;;N;;;;;\n1320F;EGYPTIAN HIEROGLYPH N030;Lo;0;L;;;;;N;;;;;\n13210;EGYPTIAN HIEROGLYPH N031;Lo;0;L;;;;;N;;;;;\n13211;EGYPTIAN HIEROGLYPH N032;Lo;0;L;;;;;N;;;;;\n13212;EGYPTIAN HIEROGLYPH N033;Lo;0;L;;;;;N;;;;;\n13213;EGYPTIAN HIEROGLYPH N033A;Lo;0;L;;;;;N;;;;;\n13214;EGYPTIAN HIEROGLYPH N034;Lo;0;L;;;;;N;;;;;\n13215;EGYPTIAN HIEROGLYPH N034A;Lo;0;L;;;;;N;;;;;\n13216;EGYPTIAN HIEROGLYPH N035;Lo;0;L;;;;;N;;;;;\n13217;EGYPTIAN HIEROGLYPH N035A;Lo;0;L;;;;;N;;;;;\n13218;EGYPTIAN HIEROGLYPH N036;Lo;0;L;;;;;N;;;;;\n13219;EGYPTIAN HIEROGLYPH N037;Lo;0;L;;;;;N;;;;;\n1321A;EGYPTIAN HIEROGLYPH N037A;Lo;0;L;;;;;N;;;;;\n1321B;EGYPTIAN HIEROGLYPH N038;Lo;0;L;;;;;N;;;;;\n1321C;EGYPTIAN HIEROGLYPH N039;Lo;0;L;;;;;N;;;;;\n1321D;EGYPTIAN HIEROGLYPH N040;Lo;0;L;;;;;N;;;;;\n1321E;EGYPTIAN HIEROGLYPH N041;Lo;0;L;;;;;N;;;;;\n1321F;EGYPTIAN HIEROGLYPH N042;Lo;0;L;;;;;N;;;;;\n13220;EGYPTIAN HIEROGLYPH NL001;Lo;0;L;;;;;N;;;;;\n13221;EGYPTIAN HIEROGLYPH NL002;Lo;0;L;;;;;N;;;;;\n13222;EGYPTIAN HIEROGLYPH NL003;Lo;0;L;;;;;N;;;;;\n13223;EGYPTIAN HIEROGLYPH NL004;Lo;0;L;;;;;N;;;;;\n13224;EGYPTIAN HIEROGLYPH NL005;Lo;0;L;;;;;N;;;;;\n13225;EGYPTIAN HIEROGLYPH NL005A;Lo;0;L;;;;;N;;;;;\n13226;EGYPTIAN HIEROGLYPH NL006;Lo;0;L;;;;;N;;;;;\n13227;EGYPTIAN HIEROGLYPH NL007;Lo;0;L;;;;;N;;;;;\n13228;EGYPTIAN HIEROGLYPH NL008;Lo;0;L;;;;;N;;;;;\n13229;EGYPTIAN HIEROGLYPH NL009;Lo;0;L;;;;;N;;;;;\n1322A;EGYPTIAN HIEROGLYPH NL010;Lo;0;L;;;;;N;;;;;\n1322B;EGYPTIAN HIEROGLYPH NL011;Lo;0;L;;;;;N;;;;;\n1322C;EGYPTIAN HIEROGLYPH NL012;Lo;0;L;;;;;N;;;;;\n1322D;EGYPTIAN HIEROGLYPH NL013;Lo;0;L;;;;;N;;;;;\n1322E;EGYPTIAN HIEROGLYPH NL014;Lo;0;L;;;;;N;;;;;\n1322F;EGYPTIAN HIEROGLYPH NL015;Lo;0;L;;;;;N;;;;;\n13230;EGYPTIAN HIEROGLYPH NL016;Lo;0;L;;;;;N;;;;;\n13231;EGYPTIAN HIEROGLYPH NL017;Lo;0;L;;;;;N;;;;;\n13232;EGYPTIAN HIEROGLYPH NL017A;Lo;0;L;;;;;N;;;;;\n13233;EGYPTIAN HIEROGLYPH NL018;Lo;0;L;;;;;N;;;;;\n13234;EGYPTIAN HIEROGLYPH NL019;Lo;0;L;;;;;N;;;;;\n13235;EGYPTIAN HIEROGLYPH NL020;Lo;0;L;;;;;N;;;;;\n13236;EGYPTIAN HIEROGLYPH NU001;Lo;0;L;;;;;N;;;;;\n13237;EGYPTIAN HIEROGLYPH NU002;Lo;0;L;;;;;N;;;;;\n13238;EGYPTIAN HIEROGLYPH NU003;Lo;0;L;;;;;N;;;;;\n13239;EGYPTIAN HIEROGLYPH NU004;Lo;0;L;;;;;N;;;;;\n1323A;EGYPTIAN HIEROGLYPH NU005;Lo;0;L;;;;;N;;;;;\n1323B;EGYPTIAN HIEROGLYPH NU006;Lo;0;L;;;;;N;;;;;\n1323C;EGYPTIAN HIEROGLYPH NU007;Lo;0;L;;;;;N;;;;;\n1323D;EGYPTIAN HIEROGLYPH NU008;Lo;0;L;;;;;N;;;;;\n1323E;EGYPTIAN HIEROGLYPH NU009;Lo;0;L;;;;;N;;;;;\n1323F;EGYPTIAN HIEROGLYPH NU010;Lo;0;L;;;;;N;;;;;\n13240;EGYPTIAN HIEROGLYPH NU010A;Lo;0;L;;;;;N;;;;;\n13241;EGYPTIAN HIEROGLYPH NU011;Lo;0;L;;;;;N;;;;;\n13242;EGYPTIAN HIEROGLYPH NU011A;Lo;0;L;;;;;N;;;;;\n13243;EGYPTIAN HIEROGLYPH NU012;Lo;0;L;;;;;N;;;;;\n13244;EGYPTIAN HIEROGLYPH NU013;Lo;0;L;;;;;N;;;;;\n13245;EGYPTIAN HIEROGLYPH NU014;Lo;0;L;;;;;N;;;;;\n13246;EGYPTIAN HIEROGLYPH NU015;Lo;0;L;;;;;N;;;;;\n13247;EGYPTIAN HIEROGLYPH NU016;Lo;0;L;;;;;N;;;;;\n13248;EGYPTIAN HIEROGLYPH NU017;Lo;0;L;;;;;N;;;;;\n13249;EGYPTIAN HIEROGLYPH NU018;Lo;0;L;;;;;N;;;;;\n1324A;EGYPTIAN HIEROGLYPH NU018A;Lo;0;L;;;;;N;;;;;\n1324B;EGYPTIAN HIEROGLYPH NU019;Lo;0;L;;;;;N;;;;;\n1324C;EGYPTIAN HIEROGLYPH NU020;Lo;0;L;;;;;N;;;;;\n1324D;EGYPTIAN HIEROGLYPH NU021;Lo;0;L;;;;;N;;;;;\n1324E;EGYPTIAN HIEROGLYPH NU022;Lo;0;L;;;;;N;;;;;\n1324F;EGYPTIAN HIEROGLYPH NU022A;Lo;0;L;;;;;N;;;;;\n13250;EGYPTIAN HIEROGLYPH O001;Lo;0;L;;;;;N;;;;;\n13251;EGYPTIAN HIEROGLYPH O001A;Lo;0;L;;;;;N;;;;;\n13252;EGYPTIAN HIEROGLYPH O002;Lo;0;L;;;;;N;;;;;\n13253;EGYPTIAN HIEROGLYPH O003;Lo;0;L;;;;;N;;;;;\n13254;EGYPTIAN HIEROGLYPH O004;Lo;0;L;;;;;N;;;;;\n13255;EGYPTIAN HIEROGLYPH O005;Lo;0;L;;;;;N;;;;;\n13256;EGYPTIAN HIEROGLYPH O005A;Lo;0;L;;;;;N;;;;;\n13257;EGYPTIAN HIEROGLYPH O006;Lo;0;L;;;;;N;;;;;\n13258;EGYPTIAN HIEROGLYPH O006A;Lo;0;L;;;;;N;;;;;\n13259;EGYPTIAN HIEROGLYPH O006B;Lo;0;L;;;;;N;;;;;\n1325A;EGYPTIAN HIEROGLYPH O006C;Lo;0;L;;;;;N;;;;;\n1325B;EGYPTIAN HIEROGLYPH O006D;Lo;0;L;;;;;N;;;;;\n1325C;EGYPTIAN HIEROGLYPH O006E;Lo;0;L;;;;;N;;;;;\n1325D;EGYPTIAN HIEROGLYPH O006F;Lo;0;L;;;;;N;;;;;\n1325E;EGYPTIAN HIEROGLYPH O007;Lo;0;L;;;;;N;;;;;\n1325F;EGYPTIAN HIEROGLYPH O008;Lo;0;L;;;;;N;;;;;\n13260;EGYPTIAN HIEROGLYPH O009;Lo;0;L;;;;;N;;;;;\n13261;EGYPTIAN HIEROGLYPH O010;Lo;0;L;;;;;N;;;;;\n13262;EGYPTIAN HIEROGLYPH O010A;Lo;0;L;;;;;N;;;;;\n13263;EGYPTIAN HIEROGLYPH O010B;Lo;0;L;;;;;N;;;;;\n13264;EGYPTIAN HIEROGLYPH O010C;Lo;0;L;;;;;N;;;;;\n13265;EGYPTIAN HIEROGLYPH O011;Lo;0;L;;;;;N;;;;;\n13266;EGYPTIAN HIEROGLYPH O012;Lo;0;L;;;;;N;;;;;\n13267;EGYPTIAN HIEROGLYPH O013;Lo;0;L;;;;;N;;;;;\n13268;EGYPTIAN HIEROGLYPH O014;Lo;0;L;;;;;N;;;;;\n13269;EGYPTIAN HIEROGLYPH O015;Lo;0;L;;;;;N;;;;;\n1326A;EGYPTIAN HIEROGLYPH O016;Lo;0;L;;;;;N;;;;;\n1326B;EGYPTIAN HIEROGLYPH O017;Lo;0;L;;;;;N;;;;;\n1326C;EGYPTIAN HIEROGLYPH O018;Lo;0;L;;;;;N;;;;;\n1326D;EGYPTIAN HIEROGLYPH O019;Lo;0;L;;;;;N;;;;;\n1326E;EGYPTIAN HIEROGLYPH O019A;Lo;0;L;;;;;N;;;;;\n1326F;EGYPTIAN HIEROGLYPH O020;Lo;0;L;;;;;N;;;;;\n13270;EGYPTIAN HIEROGLYPH O020A;Lo;0;L;;;;;N;;;;;\n13271;EGYPTIAN HIEROGLYPH O021;Lo;0;L;;;;;N;;;;;\n13272;EGYPTIAN HIEROGLYPH O022;Lo;0;L;;;;;N;;;;;\n13273;EGYPTIAN HIEROGLYPH O023;Lo;0;L;;;;;N;;;;;\n13274;EGYPTIAN HIEROGLYPH O024;Lo;0;L;;;;;N;;;;;\n13275;EGYPTIAN HIEROGLYPH O024A;Lo;0;L;;;;;N;;;;;\n13276;EGYPTIAN HIEROGLYPH O025;Lo;0;L;;;;;N;;;;;\n13277;EGYPTIAN HIEROGLYPH O025A;Lo;0;L;;;;;N;;;;;\n13278;EGYPTIAN HIEROGLYPH O026;Lo;0;L;;;;;N;;;;;\n13279;EGYPTIAN HIEROGLYPH O027;Lo;0;L;;;;;N;;;;;\n1327A;EGYPTIAN HIEROGLYPH O028;Lo;0;L;;;;;N;;;;;\n1327B;EGYPTIAN HIEROGLYPH O029;Lo;0;L;;;;;N;;;;;\n1327C;EGYPTIAN HIEROGLYPH O029A;Lo;0;L;;;;;N;;;;;\n1327D;EGYPTIAN HIEROGLYPH O030;Lo;0;L;;;;;N;;;;;\n1327E;EGYPTIAN HIEROGLYPH O030A;Lo;0;L;;;;;N;;;;;\n1327F;EGYPTIAN HIEROGLYPH O031;Lo;0;L;;;;;N;;;;;\n13280;EGYPTIAN HIEROGLYPH O032;Lo;0;L;;;;;N;;;;;\n13281;EGYPTIAN HIEROGLYPH O033;Lo;0;L;;;;;N;;;;;\n13282;EGYPTIAN HIEROGLYPH O033A;Lo;0;L;;;;;N;;;;;\n13283;EGYPTIAN HIEROGLYPH O034;Lo;0;L;;;;;N;;;;;\n13284;EGYPTIAN HIEROGLYPH O035;Lo;0;L;;;;;N;;;;;\n13285;EGYPTIAN HIEROGLYPH O036;Lo;0;L;;;;;N;;;;;\n13286;EGYPTIAN HIEROGLYPH O036A;Lo;0;L;;;;;N;;;;;\n13287;EGYPTIAN HIEROGLYPH O036B;Lo;0;L;;;;;N;;;;;\n13288;EGYPTIAN HIEROGLYPH O036C;Lo;0;L;;;;;N;;;;;\n13289;EGYPTIAN HIEROGLYPH O036D;Lo;0;L;;;;;N;;;;;\n1328A;EGYPTIAN HIEROGLYPH O037;Lo;0;L;;;;;N;;;;;\n1328B;EGYPTIAN HIEROGLYPH O038;Lo;0;L;;;;;N;;;;;\n1328C;EGYPTIAN HIEROGLYPH O039;Lo;0;L;;;;;N;;;;;\n1328D;EGYPTIAN HIEROGLYPH O040;Lo;0;L;;;;;N;;;;;\n1328E;EGYPTIAN HIEROGLYPH O041;Lo;0;L;;;;;N;;;;;\n1328F;EGYPTIAN HIEROGLYPH O042;Lo;0;L;;;;;N;;;;;\n13290;EGYPTIAN HIEROGLYPH O043;Lo;0;L;;;;;N;;;;;\n13291;EGYPTIAN HIEROGLYPH O044;Lo;0;L;;;;;N;;;;;\n13292;EGYPTIAN HIEROGLYPH O045;Lo;0;L;;;;;N;;;;;\n13293;EGYPTIAN HIEROGLYPH O046;Lo;0;L;;;;;N;;;;;\n13294;EGYPTIAN HIEROGLYPH O047;Lo;0;L;;;;;N;;;;;\n13295;EGYPTIAN HIEROGLYPH O048;Lo;0;L;;;;;N;;;;;\n13296;EGYPTIAN HIEROGLYPH O049;Lo;0;L;;;;;N;;;;;\n13297;EGYPTIAN HIEROGLYPH O050;Lo;0;L;;;;;N;;;;;\n13298;EGYPTIAN HIEROGLYPH O050A;Lo;0;L;;;;;N;;;;;\n13299;EGYPTIAN HIEROGLYPH O050B;Lo;0;L;;;;;N;;;;;\n1329A;EGYPTIAN HIEROGLYPH O051;Lo;0;L;;;;;N;;;;;\n1329B;EGYPTIAN HIEROGLYPH P001;Lo;0;L;;;;;N;;;;;\n1329C;EGYPTIAN HIEROGLYPH P001A;Lo;0;L;;;;;N;;;;;\n1329D;EGYPTIAN HIEROGLYPH P002;Lo;0;L;;;;;N;;;;;\n1329E;EGYPTIAN HIEROGLYPH P003;Lo;0;L;;;;;N;;;;;\n1329F;EGYPTIAN HIEROGLYPH P003A;Lo;0;L;;;;;N;;;;;\n132A0;EGYPTIAN HIEROGLYPH P004;Lo;0;L;;;;;N;;;;;\n132A1;EGYPTIAN HIEROGLYPH P005;Lo;0;L;;;;;N;;;;;\n132A2;EGYPTIAN HIEROGLYPH P006;Lo;0;L;;;;;N;;;;;\n132A3;EGYPTIAN HIEROGLYPH P007;Lo;0;L;;;;;N;;;;;\n132A4;EGYPTIAN HIEROGLYPH P008;Lo;0;L;;;;;N;;;;;\n132A5;EGYPTIAN HIEROGLYPH P009;Lo;0;L;;;;;N;;;;;\n132A6;EGYPTIAN HIEROGLYPH P010;Lo;0;L;;;;;N;;;;;\n132A7;EGYPTIAN HIEROGLYPH P011;Lo;0;L;;;;;N;;;;;\n132A8;EGYPTIAN HIEROGLYPH Q001;Lo;0;L;;;;;N;;;;;\n132A9;EGYPTIAN HIEROGLYPH Q002;Lo;0;L;;;;;N;;;;;\n132AA;EGYPTIAN HIEROGLYPH Q003;Lo;0;L;;;;;N;;;;;\n132AB;EGYPTIAN HIEROGLYPH Q004;Lo;0;L;;;;;N;;;;;\n132AC;EGYPTIAN HIEROGLYPH Q005;Lo;0;L;;;;;N;;;;;\n132AD;EGYPTIAN HIEROGLYPH Q006;Lo;0;L;;;;;N;;;;;\n132AE;EGYPTIAN HIEROGLYPH Q007;Lo;0;L;;;;;N;;;;;\n132AF;EGYPTIAN HIEROGLYPH R001;Lo;0;L;;;;;N;;;;;\n132B0;EGYPTIAN HIEROGLYPH R002;Lo;0;L;;;;;N;;;;;\n132B1;EGYPTIAN HIEROGLYPH R002A;Lo;0;L;;;;;N;;;;;\n132B2;EGYPTIAN HIEROGLYPH R003;Lo;0;L;;;;;N;;;;;\n132B3;EGYPTIAN HIEROGLYPH R003A;Lo;0;L;;;;;N;;;;;\n132B4;EGYPTIAN HIEROGLYPH R003B;Lo;0;L;;;;;N;;;;;\n132B5;EGYPTIAN HIEROGLYPH R004;Lo;0;L;;;;;N;;;;;\n132B6;EGYPTIAN HIEROGLYPH R005;Lo;0;L;;;;;N;;;;;\n132B7;EGYPTIAN HIEROGLYPH R006;Lo;0;L;;;;;N;;;;;\n132B8;EGYPTIAN HIEROGLYPH R007;Lo;0;L;;;;;N;;;;;\n132B9;EGYPTIAN HIEROGLYPH R008;Lo;0;L;;;;;N;;;;;\n132BA;EGYPTIAN HIEROGLYPH R009;Lo;0;L;;;;;N;;;;;\n132BB;EGYPTIAN HIEROGLYPH R010;Lo;0;L;;;;;N;;;;;\n132BC;EGYPTIAN HIEROGLYPH R010A;Lo;0;L;;;;;N;;;;;\n132BD;EGYPTIAN HIEROGLYPH R011;Lo;0;L;;;;;N;;;;;\n132BE;EGYPTIAN HIEROGLYPH R012;Lo;0;L;;;;;N;;;;;\n132BF;EGYPTIAN HIEROGLYPH R013;Lo;0;L;;;;;N;;;;;\n132C0;EGYPTIAN HIEROGLYPH R014;Lo;0;L;;;;;N;;;;;\n132C1;EGYPTIAN HIEROGLYPH R015;Lo;0;L;;;;;N;;;;;\n132C2;EGYPTIAN HIEROGLYPH R016;Lo;0;L;;;;;N;;;;;\n132C3;EGYPTIAN HIEROGLYPH R016A;Lo;0;L;;;;;N;;;;;\n132C4;EGYPTIAN HIEROGLYPH R017;Lo;0;L;;;;;N;;;;;\n132C5;EGYPTIAN HIEROGLYPH R018;Lo;0;L;;;;;N;;;;;\n132C6;EGYPTIAN HIEROGLYPH R019;Lo;0;L;;;;;N;;;;;\n132C7;EGYPTIAN HIEROGLYPH R020;Lo;0;L;;;;;N;;;;;\n132C8;EGYPTIAN HIEROGLYPH R021;Lo;0;L;;;;;N;;;;;\n132C9;EGYPTIAN HIEROGLYPH R022;Lo;0;L;;;;;N;;;;;\n132CA;EGYPTIAN HIEROGLYPH R023;Lo;0;L;;;;;N;;;;;\n132CB;EGYPTIAN HIEROGLYPH R024;Lo;0;L;;;;;N;;;;;\n132CC;EGYPTIAN HIEROGLYPH R025;Lo;0;L;;;;;N;;;;;\n132CD;EGYPTIAN HIEROGLYPH R026;Lo;0;L;;;;;N;;;;;\n132CE;EGYPTIAN HIEROGLYPH R027;Lo;0;L;;;;;N;;;;;\n132CF;EGYPTIAN HIEROGLYPH R028;Lo;0;L;;;;;N;;;;;\n132D0;EGYPTIAN HIEROGLYPH R029;Lo;0;L;;;;;N;;;;;\n132D1;EGYPTIAN HIEROGLYPH S001;Lo;0;L;;;;;N;;;;;\n132D2;EGYPTIAN HIEROGLYPH S002;Lo;0;L;;;;;N;;;;;\n132D3;EGYPTIAN HIEROGLYPH S002A;Lo;0;L;;;;;N;;;;;\n132D4;EGYPTIAN HIEROGLYPH S003;Lo;0;L;;;;;N;;;;;\n132D5;EGYPTIAN HIEROGLYPH S004;Lo;0;L;;;;;N;;;;;\n132D6;EGYPTIAN HIEROGLYPH S005;Lo;0;L;;;;;N;;;;;\n132D7;EGYPTIAN HIEROGLYPH S006;Lo;0;L;;;;;N;;;;;\n132D8;EGYPTIAN HIEROGLYPH S006A;Lo;0;L;;;;;N;;;;;\n132D9;EGYPTIAN HIEROGLYPH S007;Lo;0;L;;;;;N;;;;;\n132DA;EGYPTIAN HIEROGLYPH S008;Lo;0;L;;;;;N;;;;;\n132DB;EGYPTIAN HIEROGLYPH S009;Lo;0;L;;;;;N;;;;;\n132DC;EGYPTIAN HIEROGLYPH S010;Lo;0;L;;;;;N;;;;;\n132DD;EGYPTIAN HIEROGLYPH S011;Lo;0;L;;;;;N;;;;;\n132DE;EGYPTIAN HIEROGLYPH S012;Lo;0;L;;;;;N;;;;;\n132DF;EGYPTIAN HIEROGLYPH S013;Lo;0;L;;;;;N;;;;;\n132E0;EGYPTIAN HIEROGLYPH S014;Lo;0;L;;;;;N;;;;;\n132E1;EGYPTIAN HIEROGLYPH S014A;Lo;0;L;;;;;N;;;;;\n132E2;EGYPTIAN HIEROGLYPH S014B;Lo;0;L;;;;;N;;;;;\n132E3;EGYPTIAN HIEROGLYPH S015;Lo;0;L;;;;;N;;;;;\n132E4;EGYPTIAN HIEROGLYPH S016;Lo;0;L;;;;;N;;;;;\n132E5;EGYPTIAN HIEROGLYPH S017;Lo;0;L;;;;;N;;;;;\n132E6;EGYPTIAN HIEROGLYPH S017A;Lo;0;L;;;;;N;;;;;\n132E7;EGYPTIAN HIEROGLYPH S018;Lo;0;L;;;;;N;;;;;\n132E8;EGYPTIAN HIEROGLYPH S019;Lo;0;L;;;;;N;;;;;\n132E9;EGYPTIAN HIEROGLYPH S020;Lo;0;L;;;;;N;;;;;\n132EA;EGYPTIAN HIEROGLYPH S021;Lo;0;L;;;;;N;;;;;\n132EB;EGYPTIAN HIEROGLYPH S022;Lo;0;L;;;;;N;;;;;\n132EC;EGYPTIAN HIEROGLYPH S023;Lo;0;L;;;;;N;;;;;\n132ED;EGYPTIAN HIEROGLYPH S024;Lo;0;L;;;;;N;;;;;\n132EE;EGYPTIAN HIEROGLYPH S025;Lo;0;L;;;;;N;;;;;\n132EF;EGYPTIAN HIEROGLYPH S026;Lo;0;L;;;;;N;;;;;\n132F0;EGYPTIAN HIEROGLYPH S026A;Lo;0;L;;;;;N;;;;;\n132F1;EGYPTIAN HIEROGLYPH S026B;Lo;0;L;;;;;N;;;;;\n132F2;EGYPTIAN HIEROGLYPH S027;Lo;0;L;;;;;N;;;;;\n132F3;EGYPTIAN HIEROGLYPH S028;Lo;0;L;;;;;N;;;;;\n132F4;EGYPTIAN HIEROGLYPH S029;Lo;0;L;;;;;N;;;;;\n132F5;EGYPTIAN HIEROGLYPH S030;Lo;0;L;;;;;N;;;;;\n132F6;EGYPTIAN HIEROGLYPH S031;Lo;0;L;;;;;N;;;;;\n132F7;EGYPTIAN HIEROGLYPH S032;Lo;0;L;;;;;N;;;;;\n132F8;EGYPTIAN HIEROGLYPH S033;Lo;0;L;;;;;N;;;;;\n132F9;EGYPTIAN HIEROGLYPH S034;Lo;0;L;;;;;N;;;;;\n132FA;EGYPTIAN HIEROGLYPH S035;Lo;0;L;;;;;N;;;;;\n132FB;EGYPTIAN HIEROGLYPH S035A;Lo;0;L;;;;;N;;;;;\n132FC;EGYPTIAN HIEROGLYPH S036;Lo;0;L;;;;;N;;;;;\n132FD;EGYPTIAN HIEROGLYPH S037;Lo;0;L;;;;;N;;;;;\n132FE;EGYPTIAN HIEROGLYPH S038;Lo;0;L;;;;;N;;;;;\n132FF;EGYPTIAN HIEROGLYPH S039;Lo;0;L;;;;;N;;;;;\n13300;EGYPTIAN HIEROGLYPH S040;Lo;0;L;;;;;N;;;;;\n13301;EGYPTIAN HIEROGLYPH S041;Lo;0;L;;;;;N;;;;;\n13302;EGYPTIAN HIEROGLYPH S042;Lo;0;L;;;;;N;;;;;\n13303;EGYPTIAN HIEROGLYPH S043;Lo;0;L;;;;;N;;;;;\n13304;EGYPTIAN HIEROGLYPH S044;Lo;0;L;;;;;N;;;;;\n13305;EGYPTIAN HIEROGLYPH S045;Lo;0;L;;;;;N;;;;;\n13306;EGYPTIAN HIEROGLYPH S046;Lo;0;L;;;;;N;;;;;\n13307;EGYPTIAN HIEROGLYPH T001;Lo;0;L;;;;;N;;;;;\n13308;EGYPTIAN HIEROGLYPH T002;Lo;0;L;;;;;N;;;;;\n13309;EGYPTIAN HIEROGLYPH T003;Lo;0;L;;;;;N;;;;;\n1330A;EGYPTIAN HIEROGLYPH T003A;Lo;0;L;;;;;N;;;;;\n1330B;EGYPTIAN HIEROGLYPH T004;Lo;0;L;;;;;N;;;;;\n1330C;EGYPTIAN HIEROGLYPH T005;Lo;0;L;;;;;N;;;;;\n1330D;EGYPTIAN HIEROGLYPH T006;Lo;0;L;;;;;N;;;;;\n1330E;EGYPTIAN HIEROGLYPH T007;Lo;0;L;;;;;N;;;;;\n1330F;EGYPTIAN HIEROGLYPH T007A;Lo;0;L;;;;;N;;;;;\n13310;EGYPTIAN HIEROGLYPH T008;Lo;0;L;;;;;N;;;;;\n13311;EGYPTIAN HIEROGLYPH T008A;Lo;0;L;;;;;N;;;;;\n13312;EGYPTIAN HIEROGLYPH T009;Lo;0;L;;;;;N;;;;;\n13313;EGYPTIAN HIEROGLYPH T009A;Lo;0;L;;;;;N;;;;;\n13314;EGYPTIAN HIEROGLYPH T010;Lo;0;L;;;;;N;;;;;\n13315;EGYPTIAN HIEROGLYPH T011;Lo;0;L;;;;;N;;;;;\n13316;EGYPTIAN HIEROGLYPH T011A;Lo;0;L;;;;;N;;;;;\n13317;EGYPTIAN HIEROGLYPH T012;Lo;0;L;;;;;N;;;;;\n13318;EGYPTIAN HIEROGLYPH T013;Lo;0;L;;;;;N;;;;;\n13319;EGYPTIAN HIEROGLYPH T014;Lo;0;L;;;;;N;;;;;\n1331A;EGYPTIAN HIEROGLYPH T015;Lo;0;L;;;;;N;;;;;\n1331B;EGYPTIAN HIEROGLYPH T016;Lo;0;L;;;;;N;;;;;\n1331C;EGYPTIAN HIEROGLYPH T016A;Lo;0;L;;;;;N;;;;;\n1331D;EGYPTIAN HIEROGLYPH T017;Lo;0;L;;;;;N;;;;;\n1331E;EGYPTIAN HIEROGLYPH T018;Lo;0;L;;;;;N;;;;;\n1331F;EGYPTIAN HIEROGLYPH T019;Lo;0;L;;;;;N;;;;;\n13320;EGYPTIAN HIEROGLYPH T020;Lo;0;L;;;;;N;;;;;\n13321;EGYPTIAN HIEROGLYPH T021;Lo;0;L;;;;;N;;;;;\n13322;EGYPTIAN HIEROGLYPH T022;Lo;0;L;;;;;N;;;;;\n13323;EGYPTIAN HIEROGLYPH T023;Lo;0;L;;;;;N;;;;;\n13324;EGYPTIAN HIEROGLYPH T024;Lo;0;L;;;;;N;;;;;\n13325;EGYPTIAN HIEROGLYPH T025;Lo;0;L;;;;;N;;;;;\n13326;EGYPTIAN HIEROGLYPH T026;Lo;0;L;;;;;N;;;;;\n13327;EGYPTIAN HIEROGLYPH T027;Lo;0;L;;;;;N;;;;;\n13328;EGYPTIAN HIEROGLYPH T028;Lo;0;L;;;;;N;;;;;\n13329;EGYPTIAN HIEROGLYPH T029;Lo;0;L;;;;;N;;;;;\n1332A;EGYPTIAN HIEROGLYPH T030;Lo;0;L;;;;;N;;;;;\n1332B;EGYPTIAN HIEROGLYPH T031;Lo;0;L;;;;;N;;;;;\n1332C;EGYPTIAN HIEROGLYPH T032;Lo;0;L;;;;;N;;;;;\n1332D;EGYPTIAN HIEROGLYPH T032A;Lo;0;L;;;;;N;;;;;\n1332E;EGYPTIAN HIEROGLYPH T033;Lo;0;L;;;;;N;;;;;\n1332F;EGYPTIAN HIEROGLYPH T033A;Lo;0;L;;;;;N;;;;;\n13330;EGYPTIAN HIEROGLYPH T034;Lo;0;L;;;;;N;;;;;\n13331;EGYPTIAN HIEROGLYPH T035;Lo;0;L;;;;;N;;;;;\n13332;EGYPTIAN HIEROGLYPH T036;Lo;0;L;;;;;N;;;;;\n13333;EGYPTIAN HIEROGLYPH U001;Lo;0;L;;;;;N;;;;;\n13334;EGYPTIAN HIEROGLYPH U002;Lo;0;L;;;;;N;;;;;\n13335;EGYPTIAN HIEROGLYPH U003;Lo;0;L;;;;;N;;;;;\n13336;EGYPTIAN HIEROGLYPH U004;Lo;0;L;;;;;N;;;;;\n13337;EGYPTIAN HIEROGLYPH U005;Lo;0;L;;;;;N;;;;;\n13338;EGYPTIAN HIEROGLYPH U006;Lo;0;L;;;;;N;;;;;\n13339;EGYPTIAN HIEROGLYPH U006A;Lo;0;L;;;;;N;;;;;\n1333A;EGYPTIAN HIEROGLYPH U006B;Lo;0;L;;;;;N;;;;;\n1333B;EGYPTIAN HIEROGLYPH U007;Lo;0;L;;;;;N;;;;;\n1333C;EGYPTIAN HIEROGLYPH U008;Lo;0;L;;;;;N;;;;;\n1333D;EGYPTIAN HIEROGLYPH U009;Lo;0;L;;;;;N;;;;;\n1333E;EGYPTIAN HIEROGLYPH U010;Lo;0;L;;;;;N;;;;;\n1333F;EGYPTIAN HIEROGLYPH U011;Lo;0;L;;;;;N;;;;;\n13340;EGYPTIAN HIEROGLYPH U012;Lo;0;L;;;;;N;;;;;\n13341;EGYPTIAN HIEROGLYPH U013;Lo;0;L;;;;;N;;;;;\n13342;EGYPTIAN HIEROGLYPH U014;Lo;0;L;;;;;N;;;;;\n13343;EGYPTIAN HIEROGLYPH U015;Lo;0;L;;;;;N;;;;;\n13344;EGYPTIAN HIEROGLYPH U016;Lo;0;L;;;;;N;;;;;\n13345;EGYPTIAN HIEROGLYPH U017;Lo;0;L;;;;;N;;;;;\n13346;EGYPTIAN HIEROGLYPH U018;Lo;0;L;;;;;N;;;;;\n13347;EGYPTIAN HIEROGLYPH U019;Lo;0;L;;;;;N;;;;;\n13348;EGYPTIAN HIEROGLYPH U020;Lo;0;L;;;;;N;;;;;\n13349;EGYPTIAN HIEROGLYPH U021;Lo;0;L;;;;;N;;;;;\n1334A;EGYPTIAN HIEROGLYPH U022;Lo;0;L;;;;;N;;;;;\n1334B;EGYPTIAN HIEROGLYPH U023;Lo;0;L;;;;;N;;;;;\n1334C;EGYPTIAN HIEROGLYPH U023A;Lo;0;L;;;;;N;;;;;\n1334D;EGYPTIAN HIEROGLYPH U024;Lo;0;L;;;;;N;;;;;\n1334E;EGYPTIAN HIEROGLYPH U025;Lo;0;L;;;;;N;;;;;\n1334F;EGYPTIAN HIEROGLYPH U026;Lo;0;L;;;;;N;;;;;\n13350;EGYPTIAN HIEROGLYPH U027;Lo;0;L;;;;;N;;;;;\n13351;EGYPTIAN HIEROGLYPH U028;Lo;0;L;;;;;N;;;;;\n13352;EGYPTIAN HIEROGLYPH U029;Lo;0;L;;;;;N;;;;;\n13353;EGYPTIAN HIEROGLYPH U029A;Lo;0;L;;;;;N;;;;;\n13354;EGYPTIAN HIEROGLYPH U030;Lo;0;L;;;;;N;;;;;\n13355;EGYPTIAN HIEROGLYPH U031;Lo;0;L;;;;;N;;;;;\n13356;EGYPTIAN HIEROGLYPH U032;Lo;0;L;;;;;N;;;;;\n13357;EGYPTIAN HIEROGLYPH U032A;Lo;0;L;;;;;N;;;;;\n13358;EGYPTIAN HIEROGLYPH U033;Lo;0;L;;;;;N;;;;;\n13359;EGYPTIAN HIEROGLYPH U034;Lo;0;L;;;;;N;;;;;\n1335A;EGYPTIAN HIEROGLYPH U035;Lo;0;L;;;;;N;;;;;\n1335B;EGYPTIAN HIEROGLYPH U036;Lo;0;L;;;;;N;;;;;\n1335C;EGYPTIAN HIEROGLYPH U037;Lo;0;L;;;;;N;;;;;\n1335D;EGYPTIAN HIEROGLYPH U038;Lo;0;L;;;;;N;;;;;\n1335E;EGYPTIAN HIEROGLYPH U039;Lo;0;L;;;;;N;;;;;\n1335F;EGYPTIAN HIEROGLYPH U040;Lo;0;L;;;;;N;;;;;\n13360;EGYPTIAN HIEROGLYPH U041;Lo;0;L;;;;;N;;;;;\n13361;EGYPTIAN HIEROGLYPH U042;Lo;0;L;;;;;N;;;;;\n13362;EGYPTIAN HIEROGLYPH V001;Lo;0;L;;;;;N;;;;;\n13363;EGYPTIAN HIEROGLYPH V001A;Lo;0;L;;;;;N;;;;;\n13364;EGYPTIAN HIEROGLYPH V001B;Lo;0;L;;;;;N;;;;;\n13365;EGYPTIAN HIEROGLYPH V001C;Lo;0;L;;;;;N;;;;;\n13366;EGYPTIAN HIEROGLYPH V001D;Lo;0;L;;;;;N;;;;;\n13367;EGYPTIAN HIEROGLYPH V001E;Lo;0;L;;;;;N;;;;;\n13368;EGYPTIAN HIEROGLYPH V001F;Lo;0;L;;;;;N;;;;;\n13369;EGYPTIAN HIEROGLYPH V001G;Lo;0;L;;;;;N;;;;;\n1336A;EGYPTIAN HIEROGLYPH V001H;Lo;0;L;;;;;N;;;;;\n1336B;EGYPTIAN HIEROGLYPH V001I;Lo;0;L;;;;;N;;;;;\n1336C;EGYPTIAN HIEROGLYPH V002;Lo;0;L;;;;;N;;;;;\n1336D;EGYPTIAN HIEROGLYPH V002A;Lo;0;L;;;;;N;;;;;\n1336E;EGYPTIAN HIEROGLYPH V003;Lo;0;L;;;;;N;;;;;\n1336F;EGYPTIAN HIEROGLYPH V004;Lo;0;L;;;;;N;;;;;\n13370;EGYPTIAN HIEROGLYPH V005;Lo;0;L;;;;;N;;;;;\n13371;EGYPTIAN HIEROGLYPH V006;Lo;0;L;;;;;N;;;;;\n13372;EGYPTIAN HIEROGLYPH V007;Lo;0;L;;;;;N;;;;;\n13373;EGYPTIAN HIEROGLYPH V007A;Lo;0;L;;;;;N;;;;;\n13374;EGYPTIAN HIEROGLYPH V007B;Lo;0;L;;;;;N;;;;;\n13375;EGYPTIAN HIEROGLYPH V008;Lo;0;L;;;;;N;;;;;\n13376;EGYPTIAN HIEROGLYPH V009;Lo;0;L;;;;;N;;;;;\n13377;EGYPTIAN HIEROGLYPH V010;Lo;0;L;;;;;N;;;;;\n13378;EGYPTIAN HIEROGLYPH V011;Lo;0;L;;;;;N;;;;;\n13379;EGYPTIAN HIEROGLYPH V011A;Lo;0;L;;;;;N;;;;;\n1337A;EGYPTIAN HIEROGLYPH V011B;Lo;0;L;;;;;N;;;;;\n1337B;EGYPTIAN HIEROGLYPH V011C;Lo;0;L;;;;;N;;;;;\n1337C;EGYPTIAN HIEROGLYPH V012;Lo;0;L;;;;;N;;;;;\n1337D;EGYPTIAN HIEROGLYPH V012A;Lo;0;L;;;;;N;;;;;\n1337E;EGYPTIAN HIEROGLYPH V012B;Lo;0;L;;;;;N;;;;;\n1337F;EGYPTIAN HIEROGLYPH V013;Lo;0;L;;;;;N;;;;;\n13380;EGYPTIAN HIEROGLYPH V014;Lo;0;L;;;;;N;;;;;\n13381;EGYPTIAN HIEROGLYPH V015;Lo;0;L;;;;;N;;;;;\n13382;EGYPTIAN HIEROGLYPH V016;Lo;0;L;;;;;N;;;;;\n13383;EGYPTIAN HIEROGLYPH V017;Lo;0;L;;;;;N;;;;;\n13384;EGYPTIAN HIEROGLYPH V018;Lo;0;L;;;;;N;;;;;\n13385;EGYPTIAN HIEROGLYPH V019;Lo;0;L;;;;;N;;;;;\n13386;EGYPTIAN HIEROGLYPH V020;Lo;0;L;;;;;N;;;;;\n13387;EGYPTIAN HIEROGLYPH V020A;Lo;0;L;;;;;N;;;;;\n13388;EGYPTIAN HIEROGLYPH V020B;Lo;0;L;;;;;N;;;;;\n13389;EGYPTIAN HIEROGLYPH V020C;Lo;0;L;;;;;N;;;;;\n1338A;EGYPTIAN HIEROGLYPH V020D;Lo;0;L;;;;;N;;;;;\n1338B;EGYPTIAN HIEROGLYPH V020E;Lo;0;L;;;;;N;;;;;\n1338C;EGYPTIAN HIEROGLYPH V020F;Lo;0;L;;;;;N;;;;;\n1338D;EGYPTIAN HIEROGLYPH V020G;Lo;0;L;;;;;N;;;;;\n1338E;EGYPTIAN HIEROGLYPH V020H;Lo;0;L;;;;;N;;;;;\n1338F;EGYPTIAN HIEROGLYPH V020I;Lo;0;L;;;;;N;;;;;\n13390;EGYPTIAN HIEROGLYPH V020J;Lo;0;L;;;;;N;;;;;\n13391;EGYPTIAN HIEROGLYPH V020K;Lo;0;L;;;;;N;;;;;\n13392;EGYPTIAN HIEROGLYPH V020L;Lo;0;L;;;;;N;;;;;\n13393;EGYPTIAN HIEROGLYPH V021;Lo;0;L;;;;;N;;;;;\n13394;EGYPTIAN HIEROGLYPH V022;Lo;0;L;;;;;N;;;;;\n13395;EGYPTIAN HIEROGLYPH V023;Lo;0;L;;;;;N;;;;;\n13396;EGYPTIAN HIEROGLYPH V023A;Lo;0;L;;;;;N;;;;;\n13397;EGYPTIAN HIEROGLYPH V024;Lo;0;L;;;;;N;;;;;\n13398;EGYPTIAN HIEROGLYPH V025;Lo;0;L;;;;;N;;;;;\n13399;EGYPTIAN HIEROGLYPH V026;Lo;0;L;;;;;N;;;;;\n1339A;EGYPTIAN HIEROGLYPH V027;Lo;0;L;;;;;N;;;;;\n1339B;EGYPTIAN HIEROGLYPH V028;Lo;0;L;;;;;N;;;;;\n1339C;EGYPTIAN HIEROGLYPH V028A;Lo;0;L;;;;;N;;;;;\n1339D;EGYPTIAN HIEROGLYPH V029;Lo;0;L;;;;;N;;;;;\n1339E;EGYPTIAN HIEROGLYPH V029A;Lo;0;L;;;;;N;;;;;\n1339F;EGYPTIAN HIEROGLYPH V030;Lo;0;L;;;;;N;;;;;\n133A0;EGYPTIAN HIEROGLYPH V030A;Lo;0;L;;;;;N;;;;;\n133A1;EGYPTIAN HIEROGLYPH V031;Lo;0;L;;;;;N;;;;;\n133A2;EGYPTIAN HIEROGLYPH V031A;Lo;0;L;;;;;N;;;;;\n133A3;EGYPTIAN HIEROGLYPH V032;Lo;0;L;;;;;N;;;;;\n133A4;EGYPTIAN HIEROGLYPH V033;Lo;0;L;;;;;N;;;;;\n133A5;EGYPTIAN HIEROGLYPH V033A;Lo;0;L;;;;;N;;;;;\n133A6;EGYPTIAN HIEROGLYPH V034;Lo;0;L;;;;;N;;;;;\n133A7;EGYPTIAN HIEROGLYPH V035;Lo;0;L;;;;;N;;;;;\n133A8;EGYPTIAN HIEROGLYPH V036;Lo;0;L;;;;;N;;;;;\n133A9;EGYPTIAN HIEROGLYPH V037;Lo;0;L;;;;;N;;;;;\n133AA;EGYPTIAN HIEROGLYPH V037A;Lo;0;L;;;;;N;;;;;\n133AB;EGYPTIAN HIEROGLYPH V038;Lo;0;L;;;;;N;;;;;\n133AC;EGYPTIAN HIEROGLYPH V039;Lo;0;L;;;;;N;;;;;\n133AD;EGYPTIAN HIEROGLYPH V040;Lo;0;L;;;;;N;;;;;\n133AE;EGYPTIAN HIEROGLYPH V040A;Lo;0;L;;;;;N;;;;;\n133AF;EGYPTIAN HIEROGLYPH W001;Lo;0;L;;;;;N;;;;;\n133B0;EGYPTIAN HIEROGLYPH W002;Lo;0;L;;;;;N;;;;;\n133B1;EGYPTIAN HIEROGLYPH W003;Lo;0;L;;;;;N;;;;;\n133B2;EGYPTIAN HIEROGLYPH W003A;Lo;0;L;;;;;N;;;;;\n133B3;EGYPTIAN HIEROGLYPH W004;Lo;0;L;;;;;N;;;;;\n133B4;EGYPTIAN HIEROGLYPH W005;Lo;0;L;;;;;N;;;;;\n133B5;EGYPTIAN HIEROGLYPH W006;Lo;0;L;;;;;N;;;;;\n133B6;EGYPTIAN HIEROGLYPH W007;Lo;0;L;;;;;N;;;;;\n133B7;EGYPTIAN HIEROGLYPH W008;Lo;0;L;;;;;N;;;;;\n133B8;EGYPTIAN HIEROGLYPH W009;Lo;0;L;;;;;N;;;;;\n133B9;EGYPTIAN HIEROGLYPH W009A;Lo;0;L;;;;;N;;;;;\n133BA;EGYPTIAN HIEROGLYPH W010;Lo;0;L;;;;;N;;;;;\n133BB;EGYPTIAN HIEROGLYPH W010A;Lo;0;L;;;;;N;;;;;\n133BC;EGYPTIAN HIEROGLYPH W011;Lo;0;L;;;;;N;;;;;\n133BD;EGYPTIAN HIEROGLYPH W012;Lo;0;L;;;;;N;;;;;\n133BE;EGYPTIAN HIEROGLYPH W013;Lo;0;L;;;;;N;;;;;\n133BF;EGYPTIAN HIEROGLYPH W014;Lo;0;L;;;;;N;;;;;\n133C0;EGYPTIAN HIEROGLYPH W014A;Lo;0;L;;;;;N;;;;;\n133C1;EGYPTIAN HIEROGLYPH W015;Lo;0;L;;;;;N;;;;;\n133C2;EGYPTIAN HIEROGLYPH W016;Lo;0;L;;;;;N;;;;;\n133C3;EGYPTIAN HIEROGLYPH W017;Lo;0;L;;;;;N;;;;;\n133C4;EGYPTIAN HIEROGLYPH W017A;Lo;0;L;;;;;N;;;;;\n133C5;EGYPTIAN HIEROGLYPH W018;Lo;0;L;;;;;N;;;;;\n133C6;EGYPTIAN HIEROGLYPH W018A;Lo;0;L;;;;;N;;;;;\n133C7;EGYPTIAN HIEROGLYPH W019;Lo;0;L;;;;;N;;;;;\n133C8;EGYPTIAN HIEROGLYPH W020;Lo;0;L;;;;;N;;;;;\n133C9;EGYPTIAN HIEROGLYPH W021;Lo;0;L;;;;;N;;;;;\n133CA;EGYPTIAN HIEROGLYPH W022;Lo;0;L;;;;;N;;;;;\n133CB;EGYPTIAN HIEROGLYPH W023;Lo;0;L;;;;;N;;;;;\n133CC;EGYPTIAN HIEROGLYPH W024;Lo;0;L;;;;;N;;;;;\n133CD;EGYPTIAN HIEROGLYPH W024A;Lo;0;L;;;;;N;;;;;\n133CE;EGYPTIAN HIEROGLYPH W025;Lo;0;L;;;;;N;;;;;\n133CF;EGYPTIAN HIEROGLYPH X001;Lo;0;L;;;;;N;;;;;\n133D0;EGYPTIAN HIEROGLYPH X002;Lo;0;L;;;;;N;;;;;\n133D1;EGYPTIAN HIEROGLYPH X003;Lo;0;L;;;;;N;;;;;\n133D2;EGYPTIAN HIEROGLYPH X004;Lo;0;L;;;;;N;;;;;\n133D3;EGYPTIAN HIEROGLYPH X004A;Lo;0;L;;;;;N;;;;;\n133D4;EGYPTIAN HIEROGLYPH X004B;Lo;0;L;;;;;N;;;;;\n133D5;EGYPTIAN HIEROGLYPH X005;Lo;0;L;;;;;N;;;;;\n133D6;EGYPTIAN HIEROGLYPH X006;Lo;0;L;;;;;N;;;;;\n133D7;EGYPTIAN HIEROGLYPH X006A;Lo;0;L;;;;;N;;;;;\n133D8;EGYPTIAN HIEROGLYPH X007;Lo;0;L;;;;;N;;;;;\n133D9;EGYPTIAN HIEROGLYPH X008;Lo;0;L;;;;;N;;;;;\n133DA;EGYPTIAN HIEROGLYPH X008A;Lo;0;L;;;;;N;;;;;\n133DB;EGYPTIAN HIEROGLYPH Y001;Lo;0;L;;;;;N;;;;;\n133DC;EGYPTIAN HIEROGLYPH Y001A;Lo;0;L;;;;;N;;;;;\n133DD;EGYPTIAN HIEROGLYPH Y002;Lo;0;L;;;;;N;;;;;\n133DE;EGYPTIAN HIEROGLYPH Y003;Lo;0;L;;;;;N;;;;;\n133DF;EGYPTIAN HIEROGLYPH Y004;Lo;0;L;;;;;N;;;;;\n133E0;EGYPTIAN HIEROGLYPH Y005;Lo;0;L;;;;;N;;;;;\n133E1;EGYPTIAN HIEROGLYPH Y006;Lo;0;L;;;;;N;;;;;\n133E2;EGYPTIAN HIEROGLYPH Y007;Lo;0;L;;;;;N;;;;;\n133E3;EGYPTIAN HIEROGLYPH Y008;Lo;0;L;;;;;N;;;;;\n133E4;EGYPTIAN HIEROGLYPH Z001;Lo;0;L;;;;;N;;;;;\n133E5;EGYPTIAN HIEROGLYPH Z002;Lo;0;L;;;;;N;;;;;\n133E6;EGYPTIAN HIEROGLYPH Z002A;Lo;0;L;;;;;N;;;;;\n133E7;EGYPTIAN HIEROGLYPH Z002B;Lo;0;L;;;;;N;;;;;\n133E8;EGYPTIAN HIEROGLYPH Z002C;Lo;0;L;;;;;N;;;;;\n133E9;EGYPTIAN HIEROGLYPH Z002D;Lo;0;L;;;;;N;;;;;\n133EA;EGYPTIAN HIEROGLYPH Z003;Lo;0;L;;;;;N;;;;;\n133EB;EGYPTIAN HIEROGLYPH Z003A;Lo;0;L;;;;;N;;;;;\n133EC;EGYPTIAN HIEROGLYPH Z003B;Lo;0;L;;;;;N;;;;;\n133ED;EGYPTIAN HIEROGLYPH Z004;Lo;0;L;;;;;N;;;;;\n133EE;EGYPTIAN HIEROGLYPH Z004A;Lo;0;L;;;;;N;;;;;\n133EF;EGYPTIAN HIEROGLYPH Z005;Lo;0;L;;;;;N;;;;;\n133F0;EGYPTIAN HIEROGLYPH Z005A;Lo;0;L;;;;;N;;;;;\n133F1;EGYPTIAN HIEROGLYPH Z006;Lo;0;L;;;;;N;;;;;\n133F2;EGYPTIAN HIEROGLYPH Z007;Lo;0;L;;;;;N;;;;;\n133F3;EGYPTIAN HIEROGLYPH Z008;Lo;0;L;;;;;N;;;;;\n133F4;EGYPTIAN HIEROGLYPH Z009;Lo;0;L;;;;;N;;;;;\n133F5;EGYPTIAN HIEROGLYPH Z010;Lo;0;L;;;;;N;;;;;\n133F6;EGYPTIAN HIEROGLYPH Z011;Lo;0;L;;;;;N;;;;;\n133F7;EGYPTIAN HIEROGLYPH Z012;Lo;0;L;;;;;N;;;;;\n133F8;EGYPTIAN HIEROGLYPH Z013;Lo;0;L;;;;;N;;;;;\n133F9;EGYPTIAN HIEROGLYPH Z014;Lo;0;L;;;;;N;;;;;\n133FA;EGYPTIAN HIEROGLYPH Z015;Lo;0;L;;;;;N;;;;;\n133FB;EGYPTIAN HIEROGLYPH Z015A;Lo;0;L;;;;;N;;;;;\n133FC;EGYPTIAN HIEROGLYPH Z015B;Lo;0;L;;;;;N;;;;;\n133FD;EGYPTIAN HIEROGLYPH Z015C;Lo;0;L;;;;;N;;;;;\n133FE;EGYPTIAN HIEROGLYPH Z015D;Lo;0;L;;;;;N;;;;;\n133FF;EGYPTIAN HIEROGLYPH Z015E;Lo;0;L;;;;;N;;;;;\n13400;EGYPTIAN HIEROGLYPH Z015F;Lo;0;L;;;;;N;;;;;\n13401;EGYPTIAN HIEROGLYPH Z015G;Lo;0;L;;;;;N;;;;;\n13402;EGYPTIAN HIEROGLYPH Z015H;Lo;0;L;;;;;N;;;;;\n13403;EGYPTIAN HIEROGLYPH Z015I;Lo;0;L;;;;;N;;;;;\n13404;EGYPTIAN HIEROGLYPH Z016;Lo;0;L;;;;;N;;;;;\n13405;EGYPTIAN HIEROGLYPH Z016A;Lo;0;L;;;;;N;;;;;\n13406;EGYPTIAN HIEROGLYPH Z016B;Lo;0;L;;;;;N;;;;;\n13407;EGYPTIAN HIEROGLYPH Z016C;Lo;0;L;;;;;N;;;;;\n13408;EGYPTIAN HIEROGLYPH Z016D;Lo;0;L;;;;;N;;;;;\n13409;EGYPTIAN HIEROGLYPH Z016E;Lo;0;L;;;;;N;;;;;\n1340A;EGYPTIAN HIEROGLYPH Z016F;Lo;0;L;;;;;N;;;;;\n1340B;EGYPTIAN HIEROGLYPH Z016G;Lo;0;L;;;;;N;;;;;\n1340C;EGYPTIAN HIEROGLYPH Z016H;Lo;0;L;;;;;N;;;;;\n1340D;EGYPTIAN HIEROGLYPH AA001;Lo;0;L;;;;;N;;;;;\n1340E;EGYPTIAN HIEROGLYPH AA002;Lo;0;L;;;;;N;;;;;\n1340F;EGYPTIAN HIEROGLYPH AA003;Lo;0;L;;;;;N;;;;;\n13410;EGYPTIAN HIEROGLYPH AA004;Lo;0;L;;;;;N;;;;;\n13411;EGYPTIAN HIEROGLYPH AA005;Lo;0;L;;;;;N;;;;;\n13412;EGYPTIAN HIEROGLYPH AA006;Lo;0;L;;;;;N;;;;;\n13413;EGYPTIAN HIEROGLYPH AA007;Lo;0;L;;;;;N;;;;;\n13414;EGYPTIAN HIEROGLYPH AA007A;Lo;0;L;;;;;N;;;;;\n13415;EGYPTIAN HIEROGLYPH AA007B;Lo;0;L;;;;;N;;;;;\n13416;EGYPTIAN HIEROGLYPH AA008;Lo;0;L;;;;;N;;;;;\n13417;EGYPTIAN HIEROGLYPH AA009;Lo;0;L;;;;;N;;;;;\n13418;EGYPTIAN HIEROGLYPH AA010;Lo;0;L;;;;;N;;;;;\n13419;EGYPTIAN HIEROGLYPH AA011;Lo;0;L;;;;;N;;;;;\n1341A;EGYPTIAN HIEROGLYPH AA012;Lo;0;L;;;;;N;;;;;\n1341B;EGYPTIAN HIEROGLYPH AA013;Lo;0;L;;;;;N;;;;;\n1341C;EGYPTIAN HIEROGLYPH AA014;Lo;0;L;;;;;N;;;;;\n1341D;EGYPTIAN HIEROGLYPH AA015;Lo;0;L;;;;;N;;;;;\n1341E;EGYPTIAN HIEROGLYPH AA016;Lo;0;L;;;;;N;;;;;\n1341F;EGYPTIAN HIEROGLYPH AA017;Lo;0;L;;;;;N;;;;;\n13420;EGYPTIAN HIEROGLYPH AA018;Lo;0;L;;;;;N;;;;;\n13421;EGYPTIAN HIEROGLYPH AA019;Lo;0;L;;;;;N;;;;;\n13422;EGYPTIAN HIEROGLYPH AA020;Lo;0;L;;;;;N;;;;;\n13423;EGYPTIAN HIEROGLYPH AA021;Lo;0;L;;;;;N;;;;;\n13424;EGYPTIAN HIEROGLYPH AA022;Lo;0;L;;;;;N;;;;;\n13425;EGYPTIAN HIEROGLYPH AA023;Lo;0;L;;;;;N;;;;;\n13426;EGYPTIAN HIEROGLYPH AA024;Lo;0;L;;;;;N;;;;;\n13427;EGYPTIAN HIEROGLYPH AA025;Lo;0;L;;;;;N;;;;;\n13428;EGYPTIAN HIEROGLYPH AA026;Lo;0;L;;;;;N;;;;;\n13429;EGYPTIAN HIEROGLYPH AA027;Lo;0;L;;;;;N;;;;;\n1342A;EGYPTIAN HIEROGLYPH AA028;Lo;0;L;;;;;N;;;;;\n1342B;EGYPTIAN HIEROGLYPH AA029;Lo;0;L;;;;;N;;;;;\n1342C;EGYPTIAN HIEROGLYPH AA030;Lo;0;L;;;;;N;;;;;\n1342D;EGYPTIAN HIEROGLYPH AA031;Lo;0;L;;;;;N;;;;;\n1342E;EGYPTIAN HIEROGLYPH AA032;Lo;0;L;;;;;N;;;;;\n16800;BAMUM LETTER PHASE-A NGKUE MFON;Lo;0;L;;;;;N;;;;;\n16801;BAMUM LETTER PHASE-A GBIEE FON;Lo;0;L;;;;;N;;;;;\n16802;BAMUM LETTER PHASE-A PON MFON PIPAEMGBIEE;Lo;0;L;;;;;N;;;;;\n16803;BAMUM LETTER PHASE-A PON MFON PIPAEMBA;Lo;0;L;;;;;N;;;;;\n16804;BAMUM LETTER PHASE-A NAA MFON;Lo;0;L;;;;;N;;;;;\n16805;BAMUM LETTER PHASE-A SHUENSHUET;Lo;0;L;;;;;N;;;;;\n16806;BAMUM LETTER PHASE-A TITA MFON;Lo;0;L;;;;;N;;;;;\n16807;BAMUM LETTER PHASE-A NZA MFON;Lo;0;L;;;;;N;;;;;\n16808;BAMUM LETTER PHASE-A SHINDA PA NJI;Lo;0;L;;;;;N;;;;;\n16809;BAMUM LETTER PHASE-A PON PA NJI PIPAEMGBIEE;Lo;0;L;;;;;N;;;;;\n1680A;BAMUM LETTER PHASE-A PON PA NJI PIPAEMBA;Lo;0;L;;;;;N;;;;;\n1680B;BAMUM LETTER PHASE-A MAEMBGBIEE;Lo;0;L;;;;;N;;;;;\n1680C;BAMUM LETTER PHASE-A TU MAEMBA;Lo;0;L;;;;;N;;;;;\n1680D;BAMUM LETTER PHASE-A NGANGU;Lo;0;L;;;;;N;;;;;\n1680E;BAMUM LETTER PHASE-A MAEMVEUX;Lo;0;L;;;;;N;;;;;\n1680F;BAMUM LETTER PHASE-A MANSUAE;Lo;0;L;;;;;N;;;;;\n16810;BAMUM LETTER PHASE-A MVEUAENGAM;Lo;0;L;;;;;N;;;;;\n16811;BAMUM LETTER PHASE-A SEUNYAM;Lo;0;L;;;;;N;;;;;\n16812;BAMUM LETTER PHASE-A NTOQPEN;Lo;0;L;;;;;N;;;;;\n16813;BAMUM LETTER PHASE-A KEUKEUTNDA;Lo;0;L;;;;;N;;;;;\n16814;BAMUM LETTER PHASE-A NKINDI;Lo;0;L;;;;;N;;;;;\n16815;BAMUM LETTER PHASE-A SUU;Lo;0;L;;;;;N;;;;;\n16816;BAMUM LETTER PHASE-A NGKUENZEUM;Lo;0;L;;;;;N;;;;;\n16817;BAMUM LETTER PHASE-A LAPAQ;Lo;0;L;;;;;N;;;;;\n16818;BAMUM LETTER PHASE-A LET KUT;Lo;0;L;;;;;N;;;;;\n16819;BAMUM LETTER PHASE-A NTAP MFAA;Lo;0;L;;;;;N;;;;;\n1681A;BAMUM LETTER PHASE-A MAEKEUP;Lo;0;L;;;;;N;;;;;\n1681B;BAMUM LETTER PHASE-A PASHAE;Lo;0;L;;;;;N;;;;;\n1681C;BAMUM LETTER PHASE-A GHEUAERAE;Lo;0;L;;;;;N;;;;;\n1681D;BAMUM LETTER PHASE-A PAMSHAE;Lo;0;L;;;;;N;;;;;\n1681E;BAMUM LETTER PHASE-A MON NGGEUAET;Lo;0;L;;;;;N;;;;;\n1681F;BAMUM LETTER PHASE-A NZUN MEUT;Lo;0;L;;;;;N;;;;;\n16820;BAMUM LETTER PHASE-A U YUQ NAE;Lo;0;L;;;;;N;;;;;\n16821;BAMUM LETTER PHASE-A GHEUAEGHEUAE;Lo;0;L;;;;;N;;;;;\n16822;BAMUM LETTER PHASE-A NTAP NTAA;Lo;0;L;;;;;N;;;;;\n16823;BAMUM LETTER PHASE-A SISA;Lo;0;L;;;;;N;;;;;\n16824;BAMUM LETTER PHASE-A MGBASA;Lo;0;L;;;;;N;;;;;\n16825;BAMUM LETTER PHASE-A MEUNJOMNDEUQ;Lo;0;L;;;;;N;;;;;\n16826;BAMUM LETTER PHASE-A MOOMPUQ;Lo;0;L;;;;;N;;;;;\n16827;BAMUM LETTER PHASE-A KAFA;Lo;0;L;;;;;N;;;;;\n16828;BAMUM LETTER PHASE-A PA LEERAEWA;Lo;0;L;;;;;N;;;;;\n16829;BAMUM LETTER PHASE-A NDA LEERAEWA;Lo;0;L;;;;;N;;;;;\n1682A;BAMUM LETTER PHASE-A PET;Lo;0;L;;;;;N;;;;;\n1682B;BAMUM LETTER PHASE-A MAEMKPEN;Lo;0;L;;;;;N;;;;;\n1682C;BAMUM LETTER PHASE-A NIKA;Lo;0;L;;;;;N;;;;;\n1682D;BAMUM LETTER PHASE-A PUP;Lo;0;L;;;;;N;;;;;\n1682E;BAMUM LETTER PHASE-A TUAEP;Lo;0;L;;;;;N;;;;;\n1682F;BAMUM LETTER PHASE-A LUAEP;Lo;0;L;;;;;N;;;;;\n16830;BAMUM LETTER PHASE-A SONJAM;Lo;0;L;;;;;N;;;;;\n16831;BAMUM LETTER PHASE-A TEUTEUWEN;Lo;0;L;;;;;N;;;;;\n16832;BAMUM LETTER PHASE-A MAENYI;Lo;0;L;;;;;N;;;;;\n16833;BAMUM LETTER PHASE-A KET;Lo;0;L;;;;;N;;;;;\n16834;BAMUM LETTER PHASE-A NDAANGGEUAET;Lo;0;L;;;;;N;;;;;\n16835;BAMUM LETTER PHASE-A KUOQ;Lo;0;L;;;;;N;;;;;\n16836;BAMUM LETTER PHASE-A MOOMEUT;Lo;0;L;;;;;N;;;;;\n16837;BAMUM LETTER PHASE-A SHUM;Lo;0;L;;;;;N;;;;;\n16838;BAMUM LETTER PHASE-A LOMMAE;Lo;0;L;;;;;N;;;;;\n16839;BAMUM LETTER PHASE-A FIRI;Lo;0;L;;;;;N;;;;;\n1683A;BAMUM LETTER PHASE-A ROM;Lo;0;L;;;;;N;;;;;\n1683B;BAMUM LETTER PHASE-A KPOQ;Lo;0;L;;;;;N;;;;;\n1683C;BAMUM LETTER PHASE-A SOQ;Lo;0;L;;;;;N;;;;;\n1683D;BAMUM LETTER PHASE-A MAP PIEET;Lo;0;L;;;;;N;;;;;\n1683E;BAMUM LETTER PHASE-A SHIRAE;Lo;0;L;;;;;N;;;;;\n1683F;BAMUM LETTER PHASE-A NTAP;Lo;0;L;;;;;N;;;;;\n16840;BAMUM LETTER PHASE-A SHOQ NSHUT YUM;Lo;0;L;;;;;N;;;;;\n16841;BAMUM LETTER PHASE-A NYIT MONGKEUAEQ;Lo;0;L;;;;;N;;;;;\n16842;BAMUM LETTER PHASE-A PAARAE;Lo;0;L;;;;;N;;;;;\n16843;BAMUM LETTER PHASE-A NKAARAE;Lo;0;L;;;;;N;;;;;\n16844;BAMUM LETTER PHASE-A UNKNOWN;Lo;0;L;;;;;N;;;;;\n16845;BAMUM LETTER PHASE-A NGGEN;Lo;0;L;;;;;N;;;;;\n16846;BAMUM LETTER PHASE-A MAESI;Lo;0;L;;;;;N;;;;;\n16847;BAMUM LETTER PHASE-A NJAM;Lo;0;L;;;;;N;;;;;\n16848;BAMUM LETTER PHASE-A MBANYI;Lo;0;L;;;;;N;;;;;\n16849;BAMUM LETTER PHASE-A NYET;Lo;0;L;;;;;N;;;;;\n1684A;BAMUM LETTER PHASE-A TEUAEN;Lo;0;L;;;;;N;;;;;\n1684B;BAMUM LETTER PHASE-A SOT;Lo;0;L;;;;;N;;;;;\n1684C;BAMUM LETTER PHASE-A PAAM;Lo;0;L;;;;;N;;;;;\n1684D;BAMUM LETTER PHASE-A NSHIEE;Lo;0;L;;;;;N;;;;;\n1684E;BAMUM LETTER PHASE-A MAEM;Lo;0;L;;;;;N;;;;;\n1684F;BAMUM LETTER PHASE-A NYI;Lo;0;L;;;;;N;;;;;\n16850;BAMUM LETTER PHASE-A KAQ;Lo;0;L;;;;;N;;;;;\n16851;BAMUM LETTER PHASE-A NSHA;Lo;0;L;;;;;N;;;;;\n16852;BAMUM LETTER PHASE-A VEE;Lo;0;L;;;;;N;;;;;\n16853;BAMUM LETTER PHASE-A LU;Lo;0;L;;;;;N;;;;;\n16854;BAMUM LETTER PHASE-A NEN;Lo;0;L;;;;;N;;;;;\n16855;BAMUM LETTER PHASE-A NAQ;Lo;0;L;;;;;N;;;;;\n16856;BAMUM LETTER PHASE-A MBAQ;Lo;0;L;;;;;N;;;;;\n16857;BAMUM LETTER PHASE-B NSHUET;Lo;0;L;;;;;N;;;;;\n16858;BAMUM LETTER PHASE-B TU MAEMGBIEE;Lo;0;L;;;;;N;;;;;\n16859;BAMUM LETTER PHASE-B SIEE;Lo;0;L;;;;;N;;;;;\n1685A;BAMUM LETTER PHASE-B SET TU;Lo;0;L;;;;;N;;;;;\n1685B;BAMUM LETTER PHASE-B LOM NTEUM;Lo;0;L;;;;;N;;;;;\n1685C;BAMUM LETTER PHASE-B MBA MAELEE;Lo;0;L;;;;;N;;;;;\n1685D;BAMUM LETTER PHASE-B KIEEM;Lo;0;L;;;;;N;;;;;\n1685E;BAMUM LETTER PHASE-B YEURAE;Lo;0;L;;;;;N;;;;;\n1685F;BAMUM LETTER PHASE-B MBAARAE;Lo;0;L;;;;;N;;;;;\n16860;BAMUM LETTER PHASE-B KAM;Lo;0;L;;;;;N;;;;;\n16861;BAMUM LETTER PHASE-B PEESHI;Lo;0;L;;;;;N;;;;;\n16862;BAMUM LETTER PHASE-B YAFU LEERAEWA;Lo;0;L;;;;;N;;;;;\n16863;BAMUM LETTER PHASE-B LAM NSHUT NYAM;Lo;0;L;;;;;N;;;;;\n16864;BAMUM LETTER PHASE-B NTIEE SHEUOQ;Lo;0;L;;;;;N;;;;;\n16865;BAMUM LETTER PHASE-B NDU NJAA;Lo;0;L;;;;;N;;;;;\n16866;BAMUM LETTER PHASE-B GHEUGHEUAEM;Lo;0;L;;;;;N;;;;;\n16867;BAMUM LETTER PHASE-B PIT;Lo;0;L;;;;;N;;;;;\n16868;BAMUM LETTER PHASE-B TU NSIEE;Lo;0;L;;;;;N;;;;;\n16869;BAMUM LETTER PHASE-B SHET NJAQ;Lo;0;L;;;;;N;;;;;\n1686A;BAMUM LETTER PHASE-B SHEUAEQTU;Lo;0;L;;;;;N;;;;;\n1686B;BAMUM LETTER PHASE-B MFON TEUAEQ;Lo;0;L;;;;;N;;;;;\n1686C;BAMUM LETTER PHASE-B MBIT MBAAKET;Lo;0;L;;;;;N;;;;;\n1686D;BAMUM LETTER PHASE-B NYI NTEUM;Lo;0;L;;;;;N;;;;;\n1686E;BAMUM LETTER PHASE-B KEUPUQ;Lo;0;L;;;;;N;;;;;\n1686F;BAMUM LETTER PHASE-B GHEUGHEN;Lo;0;L;;;;;N;;;;;\n16870;BAMUM LETTER PHASE-B KEUYEUX;Lo;0;L;;;;;N;;;;;\n16871;BAMUM LETTER PHASE-B LAANAE;Lo;0;L;;;;;N;;;;;\n16872;BAMUM LETTER PHASE-B PARUM;Lo;0;L;;;;;N;;;;;\n16873;BAMUM LETTER PHASE-B VEUM;Lo;0;L;;;;;N;;;;;\n16874;BAMUM LETTER PHASE-B NGKINDI MVOP;Lo;0;L;;;;;N;;;;;\n16875;BAMUM LETTER PHASE-B NGGEU MBU;Lo;0;L;;;;;N;;;;;\n16876;BAMUM LETTER PHASE-B WUAET;Lo;0;L;;;;;N;;;;;\n16877;BAMUM LETTER PHASE-B SAKEUAE;Lo;0;L;;;;;N;;;;;\n16878;BAMUM LETTER PHASE-B TAAM;Lo;0;L;;;;;N;;;;;\n16879;BAMUM LETTER PHASE-B MEUQ;Lo;0;L;;;;;N;;;;;\n1687A;BAMUM LETTER PHASE-B NGGUOQ;Lo;0;L;;;;;N;;;;;\n1687B;BAMUM LETTER PHASE-B NGGUOQ LARGE;Lo;0;L;;;;;N;;;;;\n1687C;BAMUM LETTER PHASE-B MFIYAQ;Lo;0;L;;;;;N;;;;;\n1687D;BAMUM LETTER PHASE-B SUE;Lo;0;L;;;;;N;;;;;\n1687E;BAMUM LETTER PHASE-B MBEURI;Lo;0;L;;;;;N;;;;;\n1687F;BAMUM LETTER PHASE-B MONTIEEN;Lo;0;L;;;;;N;;;;;\n16880;BAMUM LETTER PHASE-B NYAEMAE;Lo;0;L;;;;;N;;;;;\n16881;BAMUM LETTER PHASE-B PUNGAAM;Lo;0;L;;;;;N;;;;;\n16882;BAMUM LETTER PHASE-B MEUT NGGEET;Lo;0;L;;;;;N;;;;;\n16883;BAMUM LETTER PHASE-B FEUX;Lo;0;L;;;;;N;;;;;\n16884;BAMUM LETTER PHASE-B MBUOQ;Lo;0;L;;;;;N;;;;;\n16885;BAMUM LETTER PHASE-B FEE;Lo;0;L;;;;;N;;;;;\n16886;BAMUM LETTER PHASE-B KEUAEM;Lo;0;L;;;;;N;;;;;\n16887;BAMUM LETTER PHASE-B MA NJEUAENA;Lo;0;L;;;;;N;;;;;\n16888;BAMUM LETTER PHASE-B MA NJUQA;Lo;0;L;;;;;N;;;;;\n16889;BAMUM LETTER PHASE-B LET;Lo;0;L;;;;;N;;;;;\n1688A;BAMUM LETTER PHASE-B NGGAAM;Lo;0;L;;;;;N;;;;;\n1688B;BAMUM LETTER PHASE-B NSEN;Lo;0;L;;;;;N;;;;;\n1688C;BAMUM LETTER PHASE-B MA;Lo;0;L;;;;;N;;;;;\n1688D;BAMUM LETTER PHASE-B KIQ;Lo;0;L;;;;;N;;;;;\n1688E;BAMUM LETTER PHASE-B NGOM;Lo;0;L;;;;;N;;;;;\n1688F;BAMUM LETTER PHASE-C NGKUE MAEMBA;Lo;0;L;;;;;N;;;;;\n16890;BAMUM LETTER PHASE-C NZA;Lo;0;L;;;;;N;;;;;\n16891;BAMUM LETTER PHASE-C YUM;Lo;0;L;;;;;N;;;;;\n16892;BAMUM LETTER PHASE-C WANGKUOQ;Lo;0;L;;;;;N;;;;;\n16893;BAMUM LETTER PHASE-C NGGEN;Lo;0;L;;;;;N;;;;;\n16894;BAMUM LETTER PHASE-C NDEUAEREE;Lo;0;L;;;;;N;;;;;\n16895;BAMUM LETTER PHASE-C NGKAQ;Lo;0;L;;;;;N;;;;;\n16896;BAMUM LETTER PHASE-C GHARAE;Lo;0;L;;;;;N;;;;;\n16897;BAMUM LETTER PHASE-C MBEEKEET;Lo;0;L;;;;;N;;;;;\n16898;BAMUM LETTER PHASE-C GBAYI;Lo;0;L;;;;;N;;;;;\n16899;BAMUM LETTER PHASE-C NYIR MKPARAQ MEUN;Lo;0;L;;;;;N;;;;;\n1689A;BAMUM LETTER PHASE-C NTU MBIT;Lo;0;L;;;;;N;;;;;\n1689B;BAMUM LETTER PHASE-C MBEUM;Lo;0;L;;;;;N;;;;;\n1689C;BAMUM LETTER PHASE-C PIRIEEN;Lo;0;L;;;;;N;;;;;\n1689D;BAMUM LETTER PHASE-C NDOMBU;Lo;0;L;;;;;N;;;;;\n1689E;BAMUM LETTER PHASE-C MBAA CABBAGE-TREE;Lo;0;L;;;;;N;;;;;\n1689F;BAMUM LETTER PHASE-C KEUSHEUAEP;Lo;0;L;;;;;N;;;;;\n168A0;BAMUM LETTER PHASE-C GHAP;Lo;0;L;;;;;N;;;;;\n168A1;BAMUM LETTER PHASE-C KEUKAQ;Lo;0;L;;;;;N;;;;;\n168A2;BAMUM LETTER PHASE-C YU MUOMAE;Lo;0;L;;;;;N;;;;;\n168A3;BAMUM LETTER PHASE-C NZEUM;Lo;0;L;;;;;N;;;;;\n168A4;BAMUM LETTER PHASE-C MBUE;Lo;0;L;;;;;N;;;;;\n168A5;BAMUM LETTER PHASE-C NSEUAEN;Lo;0;L;;;;;N;;;;;\n168A6;BAMUM LETTER PHASE-C MBIT;Lo;0;L;;;;;N;;;;;\n168A7;BAMUM LETTER PHASE-C YEUQ;Lo;0;L;;;;;N;;;;;\n168A8;BAMUM LETTER PHASE-C KPARAQ;Lo;0;L;;;;;N;;;;;\n168A9;BAMUM LETTER PHASE-C KAA;Lo;0;L;;;;;N;;;;;\n168AA;BAMUM LETTER PHASE-C SEUX;Lo;0;L;;;;;N;;;;;\n168AB;BAMUM LETTER PHASE-C NDIDA;Lo;0;L;;;;;N;;;;;\n168AC;BAMUM LETTER PHASE-C TAASHAE;Lo;0;L;;;;;N;;;;;\n168AD;BAMUM LETTER PHASE-C NJUEQ;Lo;0;L;;;;;N;;;;;\n168AE;BAMUM LETTER PHASE-C TITA YUE;Lo;0;L;;;;;N;;;;;\n168AF;BAMUM LETTER PHASE-C SUAET;Lo;0;L;;;;;N;;;;;\n168B0;BAMUM LETTER PHASE-C NGGUAEN NYAM;Lo;0;L;;;;;N;;;;;\n168B1;BAMUM LETTER PHASE-C VEUX;Lo;0;L;;;;;N;;;;;\n168B2;BAMUM LETTER PHASE-C NANSANAQ;Lo;0;L;;;;;N;;;;;\n168B3;BAMUM LETTER PHASE-C MA KEUAERI;Lo;0;L;;;;;N;;;;;\n168B4;BAMUM LETTER PHASE-C NTAA;Lo;0;L;;;;;N;;;;;\n168B5;BAMUM LETTER PHASE-C NGGUON;Lo;0;L;;;;;N;;;;;\n168B6;BAMUM LETTER PHASE-C LAP;Lo;0;L;;;;;N;;;;;\n168B7;BAMUM LETTER PHASE-C MBIRIEEN;Lo;0;L;;;;;N;;;;;\n168B8;BAMUM LETTER PHASE-C MGBASAQ;Lo;0;L;;;;;N;;;;;\n168B9;BAMUM LETTER PHASE-C NTEUNGBA;Lo;0;L;;;;;N;;;;;\n168BA;BAMUM LETTER PHASE-C TEUTEUX;Lo;0;L;;;;;N;;;;;\n168BB;BAMUM LETTER PHASE-C NGGUM;Lo;0;L;;;;;N;;;;;\n168BC;BAMUM LETTER PHASE-C FUE;Lo;0;L;;;;;N;;;;;\n168BD;BAMUM LETTER PHASE-C NDEUT;Lo;0;L;;;;;N;;;;;\n168BE;BAMUM LETTER PHASE-C NSA;Lo;0;L;;;;;N;;;;;\n168BF;BAMUM LETTER PHASE-C NSHAQ;Lo;0;L;;;;;N;;;;;\n168C0;BAMUM LETTER PHASE-C BUNG;Lo;0;L;;;;;N;;;;;\n168C1;BAMUM LETTER PHASE-C VEUAEPEN;Lo;0;L;;;;;N;;;;;\n168C2;BAMUM LETTER PHASE-C MBERAE;Lo;0;L;;;;;N;;;;;\n168C3;BAMUM LETTER PHASE-C RU;Lo;0;L;;;;;N;;;;;\n168C4;BAMUM LETTER PHASE-C NJAEM;Lo;0;L;;;;;N;;;;;\n168C5;BAMUM LETTER PHASE-C LAM;Lo;0;L;;;;;N;;;;;\n168C6;BAMUM LETTER PHASE-C TITUAEP;Lo;0;L;;;;;N;;;;;\n168C7;BAMUM LETTER PHASE-C NSUOT NGOM;Lo;0;L;;;;;N;;;;;\n168C8;BAMUM LETTER PHASE-C NJEEEE;Lo;0;L;;;;;N;;;;;\n168C9;BAMUM LETTER PHASE-C KET;Lo;0;L;;;;;N;;;;;\n168CA;BAMUM LETTER PHASE-C NGGU;Lo;0;L;;;;;N;;;;;\n168CB;BAMUM LETTER PHASE-C MAESI;Lo;0;L;;;;;N;;;;;\n168CC;BAMUM LETTER PHASE-C MBUAEM;Lo;0;L;;;;;N;;;;;\n168CD;BAMUM LETTER PHASE-C LU;Lo;0;L;;;;;N;;;;;\n168CE;BAMUM LETTER PHASE-C KUT;Lo;0;L;;;;;N;;;;;\n168CF;BAMUM LETTER PHASE-C NJAM;Lo;0;L;;;;;N;;;;;\n168D0;BAMUM LETTER PHASE-C NGOM;Lo;0;L;;;;;N;;;;;\n168D1;BAMUM LETTER PHASE-C WUP;Lo;0;L;;;;;N;;;;;\n168D2;BAMUM LETTER PHASE-C NGGUEET;Lo;0;L;;;;;N;;;;;\n168D3;BAMUM LETTER PHASE-C NSOM;Lo;0;L;;;;;N;;;;;\n168D4;BAMUM LETTER PHASE-C NTEN;Lo;0;L;;;;;N;;;;;\n168D5;BAMUM LETTER PHASE-C KUOP NKAARAE;Lo;0;L;;;;;N;;;;;\n168D6;BAMUM LETTER PHASE-C NSUN;Lo;0;L;;;;;N;;;;;\n168D7;BAMUM LETTER PHASE-C NDAM;Lo;0;L;;;;;N;;;;;\n168D8;BAMUM LETTER PHASE-C MA NSIEE;Lo;0;L;;;;;N;;;;;\n168D9;BAMUM LETTER PHASE-C YAA;Lo;0;L;;;;;N;;;;;\n168DA;BAMUM LETTER PHASE-C NDAP;Lo;0;L;;;;;N;;;;;\n168DB;BAMUM LETTER PHASE-C SHUEQ;Lo;0;L;;;;;N;;;;;\n168DC;BAMUM LETTER PHASE-C SETFON;Lo;0;L;;;;;N;;;;;\n168DD;BAMUM LETTER PHASE-C MBI;Lo;0;L;;;;;N;;;;;\n168DE;BAMUM LETTER PHASE-C MAEMBA;Lo;0;L;;;;;N;;;;;\n168DF;BAMUM LETTER PHASE-C MBANYI;Lo;0;L;;;;;N;;;;;\n168E0;BAMUM LETTER PHASE-C KEUSEUX;Lo;0;L;;;;;N;;;;;\n168E1;BAMUM LETTER PHASE-C MBEUX;Lo;0;L;;;;;N;;;;;\n168E2;BAMUM LETTER PHASE-C KEUM;Lo;0;L;;;;;N;;;;;\n168E3;BAMUM LETTER PHASE-C MBAA PICKET;Lo;0;L;;;;;N;;;;;\n168E4;BAMUM LETTER PHASE-C YUWOQ;Lo;0;L;;;;;N;;;;;\n168E5;BAMUM LETTER PHASE-C NJEUX;Lo;0;L;;;;;N;;;;;\n168E6;BAMUM LETTER PHASE-C MIEE;Lo;0;L;;;;;N;;;;;\n168E7;BAMUM LETTER PHASE-C MUAE;Lo;0;L;;;;;N;;;;;\n168E8;BAMUM LETTER PHASE-C SHIQ;Lo;0;L;;;;;N;;;;;\n168E9;BAMUM LETTER PHASE-C KEN LAW;Lo;0;L;;;;;N;;;;;\n168EA;BAMUM LETTER PHASE-C KEN FATIGUE;Lo;0;L;;;;;N;;;;;\n168EB;BAMUM LETTER PHASE-C NGAQ;Lo;0;L;;;;;N;;;;;\n168EC;BAMUM LETTER PHASE-C NAQ;Lo;0;L;;;;;N;;;;;\n168ED;BAMUM LETTER PHASE-C LIQ;Lo;0;L;;;;;N;;;;;\n168EE;BAMUM LETTER PHASE-C PIN;Lo;0;L;;;;;N;;;;;\n168EF;BAMUM LETTER PHASE-C PEN;Lo;0;L;;;;;N;;;;;\n168F0;BAMUM LETTER PHASE-C TET;Lo;0;L;;;;;N;;;;;\n168F1;BAMUM LETTER PHASE-D MBUO;Lo;0;L;;;;;N;;;;;\n168F2;BAMUM LETTER PHASE-D WAP;Lo;0;L;;;;;N;;;;;\n168F3;BAMUM LETTER PHASE-D NJI;Lo;0;L;;;;;N;;;;;\n168F4;BAMUM LETTER PHASE-D MFON;Lo;0;L;;;;;N;;;;;\n168F5;BAMUM LETTER PHASE-D NJIEE;Lo;0;L;;;;;N;;;;;\n168F6;BAMUM LETTER PHASE-D LIEE;Lo;0;L;;;;;N;;;;;\n168F7;BAMUM LETTER PHASE-D NJEUT;Lo;0;L;;;;;N;;;;;\n168F8;BAMUM LETTER PHASE-D NSHEE;Lo;0;L;;;;;N;;;;;\n168F9;BAMUM LETTER PHASE-D NGGAAMAE;Lo;0;L;;;;;N;;;;;\n168FA;BAMUM LETTER PHASE-D NYAM;Lo;0;L;;;;;N;;;;;\n168FB;BAMUM LETTER PHASE-D WUAEN;Lo;0;L;;;;;N;;;;;\n168FC;BAMUM LETTER PHASE-D NGKUN;Lo;0;L;;;;;N;;;;;\n168FD;BAMUM LETTER PHASE-D SHEE;Lo;0;L;;;;;N;;;;;\n168FE;BAMUM LETTER PHASE-D NGKAP;Lo;0;L;;;;;N;;;;;\n168FF;BAMUM LETTER PHASE-D KEUAETMEUN;Lo;0;L;;;;;N;;;;;\n16900;BAMUM LETTER PHASE-D TEUT;Lo;0;L;;;;;N;;;;;\n16901;BAMUM LETTER PHASE-D SHEUAE;Lo;0;L;;;;;N;;;;;\n16902;BAMUM LETTER PHASE-D NJAP;Lo;0;L;;;;;N;;;;;\n16903;BAMUM LETTER PHASE-D SUE;Lo;0;L;;;;;N;;;;;\n16904;BAMUM LETTER PHASE-D KET;Lo;0;L;;;;;N;;;;;\n16905;BAMUM LETTER PHASE-D YAEMMAE;Lo;0;L;;;;;N;;;;;\n16906;BAMUM LETTER PHASE-D KUOM;Lo;0;L;;;;;N;;;;;\n16907;BAMUM LETTER PHASE-D SAP;Lo;0;L;;;;;N;;;;;\n16908;BAMUM LETTER PHASE-D MFEUT;Lo;0;L;;;;;N;;;;;\n16909;BAMUM LETTER PHASE-D NDEUX;Lo;0;L;;;;;N;;;;;\n1690A;BAMUM LETTER PHASE-D MALEERI;Lo;0;L;;;;;N;;;;;\n1690B;BAMUM LETTER PHASE-D MEUT;Lo;0;L;;;;;N;;;;;\n1690C;BAMUM LETTER PHASE-D SEUAEQ;Lo;0;L;;;;;N;;;;;\n1690D;BAMUM LETTER PHASE-D YEN;Lo;0;L;;;;;N;;;;;\n1690E;BAMUM LETTER PHASE-D NJEUAEM;Lo;0;L;;;;;N;;;;;\n1690F;BAMUM LETTER PHASE-D KEUOT MBUAE;Lo;0;L;;;;;N;;;;;\n16910;BAMUM LETTER PHASE-D NGKEURI;Lo;0;L;;;;;N;;;;;\n16911;BAMUM LETTER PHASE-D TU;Lo;0;L;;;;;N;;;;;\n16912;BAMUM LETTER PHASE-D GHAA;Lo;0;L;;;;;N;;;;;\n16913;BAMUM LETTER PHASE-D NGKYEE;Lo;0;L;;;;;N;;;;;\n16914;BAMUM LETTER PHASE-D FEUFEUAET;Lo;0;L;;;;;N;;;;;\n16915;BAMUM LETTER PHASE-D NDEE;Lo;0;L;;;;;N;;;;;\n16916;BAMUM LETTER PHASE-D MGBOFUM;Lo;0;L;;;;;N;;;;;\n16917;BAMUM LETTER PHASE-D LEUAEP;Lo;0;L;;;;;N;;;;;\n16918;BAMUM LETTER PHASE-D NDON;Lo;0;L;;;;;N;;;;;\n16919;BAMUM LETTER PHASE-D MONI;Lo;0;L;;;;;N;;;;;\n1691A;BAMUM LETTER PHASE-D MGBEUN;Lo;0;L;;;;;N;;;;;\n1691B;BAMUM LETTER PHASE-D PUUT;Lo;0;L;;;;;N;;;;;\n1691C;BAMUM LETTER PHASE-D MGBIEE;Lo;0;L;;;;;N;;;;;\n1691D;BAMUM LETTER PHASE-D MFO;Lo;0;L;;;;;N;;;;;\n1691E;BAMUM LETTER PHASE-D LUM;Lo;0;L;;;;;N;;;;;\n1691F;BAMUM LETTER PHASE-D NSIEEP;Lo;0;L;;;;;N;;;;;\n16920;BAMUM LETTER PHASE-D MBAA;Lo;0;L;;;;;N;;;;;\n16921;BAMUM LETTER PHASE-D KWAET;Lo;0;L;;;;;N;;;;;\n16922;BAMUM LETTER PHASE-D NYET;Lo;0;L;;;;;N;;;;;\n16923;BAMUM LETTER PHASE-D TEUAEN;Lo;0;L;;;;;N;;;;;\n16924;BAMUM LETTER PHASE-D SOT;Lo;0;L;;;;;N;;;;;\n16925;BAMUM LETTER PHASE-D YUWOQ;Lo;0;L;;;;;N;;;;;\n16926;BAMUM LETTER PHASE-D KEUM;Lo;0;L;;;;;N;;;;;\n16927;BAMUM LETTER PHASE-D RAEM;Lo;0;L;;;;;N;;;;;\n16928;BAMUM LETTER PHASE-D TEEEE;Lo;0;L;;;;;N;;;;;\n16929;BAMUM LETTER PHASE-D NGKEUAEQ;Lo;0;L;;;;;N;;;;;\n1692A;BAMUM LETTER PHASE-D MFEUAE;Lo;0;L;;;;;N;;;;;\n1692B;BAMUM LETTER PHASE-D NSIEET;Lo;0;L;;;;;N;;;;;\n1692C;BAMUM LETTER PHASE-D KEUP;Lo;0;L;;;;;N;;;;;\n1692D;BAMUM LETTER PHASE-D PIP;Lo;0;L;;;;;N;;;;;\n1692E;BAMUM LETTER PHASE-D PEUTAE;Lo;0;L;;;;;N;;;;;\n1692F;BAMUM LETTER PHASE-D NYUE;Lo;0;L;;;;;N;;;;;\n16930;BAMUM LETTER PHASE-D LET;Lo;0;L;;;;;N;;;;;\n16931;BAMUM LETTER PHASE-D NGGAAM;Lo;0;L;;;;;N;;;;;\n16932;BAMUM LETTER PHASE-D MFIEE;Lo;0;L;;;;;N;;;;;\n16933;BAMUM LETTER PHASE-D NGGWAEN;Lo;0;L;;;;;N;;;;;\n16934;BAMUM LETTER PHASE-D YUOM;Lo;0;L;;;;;N;;;;;\n16935;BAMUM LETTER PHASE-D PAP;Lo;0;L;;;;;N;;;;;\n16936;BAMUM LETTER PHASE-D YUOP;Lo;0;L;;;;;N;;;;;\n16937;BAMUM LETTER PHASE-D NDAM;Lo;0;L;;;;;N;;;;;\n16938;BAMUM LETTER PHASE-D NTEUM;Lo;0;L;;;;;N;;;;;\n16939;BAMUM LETTER PHASE-D SUAE;Lo;0;L;;;;;N;;;;;\n1693A;BAMUM LETTER PHASE-D KUN;Lo;0;L;;;;;N;;;;;\n1693B;BAMUM LETTER PHASE-D NGGEUX;Lo;0;L;;;;;N;;;;;\n1693C;BAMUM LETTER PHASE-D NGKIEE;Lo;0;L;;;;;N;;;;;\n1693D;BAMUM LETTER PHASE-D TUOT;Lo;0;L;;;;;N;;;;;\n1693E;BAMUM LETTER PHASE-D MEUN;Lo;0;L;;;;;N;;;;;\n1693F;BAMUM LETTER PHASE-D KUQ;Lo;0;L;;;;;N;;;;;\n16940;BAMUM LETTER PHASE-D NSUM;Lo;0;L;;;;;N;;;;;\n16941;BAMUM LETTER PHASE-D TEUN;Lo;0;L;;;;;N;;;;;\n16942;BAMUM LETTER PHASE-D MAENJET;Lo;0;L;;;;;N;;;;;\n16943;BAMUM LETTER PHASE-D NGGAP;Lo;0;L;;;;;N;;;;;\n16944;BAMUM LETTER PHASE-D LEUM;Lo;0;L;;;;;N;;;;;\n16945;BAMUM LETTER PHASE-D NGGUOM;Lo;0;L;;;;;N;;;;;\n16946;BAMUM LETTER PHASE-D NSHUT;Lo;0;L;;;;;N;;;;;\n16947;BAMUM LETTER PHASE-D NJUEQ;Lo;0;L;;;;;N;;;;;\n16948;BAMUM LETTER PHASE-D GHEUAE;Lo;0;L;;;;;N;;;;;\n16949;BAMUM LETTER PHASE-D KU;Lo;0;L;;;;;N;;;;;\n1694A;BAMUM LETTER PHASE-D REN OLD;Lo;0;L;;;;;N;;;;;\n1694B;BAMUM LETTER PHASE-D TAE;Lo;0;L;;;;;N;;;;;\n1694C;BAMUM LETTER PHASE-D TOQ;Lo;0;L;;;;;N;;;;;\n1694D;BAMUM LETTER PHASE-D NYI;Lo;0;L;;;;;N;;;;;\n1694E;BAMUM LETTER PHASE-D RII;Lo;0;L;;;;;N;;;;;\n1694F;BAMUM LETTER PHASE-D LEEEE;Lo;0;L;;;;;N;;;;;\n16950;BAMUM LETTER PHASE-D MEEEE;Lo;0;L;;;;;N;;;;;\n16951;BAMUM LETTER PHASE-D M;Lo;0;L;;;;;N;;;;;\n16952;BAMUM LETTER PHASE-D SUU;Lo;0;L;;;;;N;;;;;\n16953;BAMUM LETTER PHASE-D MU;Lo;0;L;;;;;N;;;;;\n16954;BAMUM LETTER PHASE-D SHII;Lo;0;L;;;;;N;;;;;\n16955;BAMUM LETTER PHASE-D SHEUX;Lo;0;L;;;;;N;;;;;\n16956;BAMUM LETTER PHASE-D KYEE;Lo;0;L;;;;;N;;;;;\n16957;BAMUM LETTER PHASE-D NU;Lo;0;L;;;;;N;;;;;\n16958;BAMUM LETTER PHASE-D SHU;Lo;0;L;;;;;N;;;;;\n16959;BAMUM LETTER PHASE-D NTEE;Lo;0;L;;;;;N;;;;;\n1695A;BAMUM LETTER PHASE-D PEE;Lo;0;L;;;;;N;;;;;\n1695B;BAMUM LETTER PHASE-D NI;Lo;0;L;;;;;N;;;;;\n1695C;BAMUM LETTER PHASE-D SHOQ;Lo;0;L;;;;;N;;;;;\n1695D;BAMUM LETTER PHASE-D PUQ;Lo;0;L;;;;;N;;;;;\n1695E;BAMUM LETTER PHASE-D MVOP;Lo;0;L;;;;;N;;;;;\n1695F;BAMUM LETTER PHASE-D LOQ;Lo;0;L;;;;;N;;;;;\n16960;BAMUM LETTER PHASE-D REN MUCH;Lo;0;L;;;;;N;;;;;\n16961;BAMUM LETTER PHASE-D TI;Lo;0;L;;;;;N;;;;;\n16962;BAMUM LETTER PHASE-D NTUU;Lo;0;L;;;;;N;;;;;\n16963;BAMUM LETTER PHASE-D MBAA SEVEN;Lo;0;L;;;;;N;;;;;\n16964;BAMUM LETTER PHASE-D SAQ;Lo;0;L;;;;;N;;;;;\n16965;BAMUM LETTER PHASE-D FAA;Lo;0;L;;;;;N;;;;;\n16966;BAMUM LETTER PHASE-E NDAP;Lo;0;L;;;;;N;;;;;\n16967;BAMUM LETTER PHASE-E TOON;Lo;0;L;;;;;N;;;;;\n16968;BAMUM LETTER PHASE-E MBEUM;Lo;0;L;;;;;N;;;;;\n16969;BAMUM LETTER PHASE-E LAP;Lo;0;L;;;;;N;;;;;\n1696A;BAMUM LETTER PHASE-E VOM;Lo;0;L;;;;;N;;;;;\n1696B;BAMUM LETTER PHASE-E LOON;Lo;0;L;;;;;N;;;;;\n1696C;BAMUM LETTER PHASE-E PAA;Lo;0;L;;;;;N;;;;;\n1696D;BAMUM LETTER PHASE-E SOM;Lo;0;L;;;;;N;;;;;\n1696E;BAMUM LETTER PHASE-E RAQ;Lo;0;L;;;;;N;;;;;\n1696F;BAMUM LETTER PHASE-E NSHUOP;Lo;0;L;;;;;N;;;;;\n16970;BAMUM LETTER PHASE-E NDUN;Lo;0;L;;;;;N;;;;;\n16971;BAMUM LETTER PHASE-E PUAE;Lo;0;L;;;;;N;;;;;\n16972;BAMUM LETTER PHASE-E TAM;Lo;0;L;;;;;N;;;;;\n16973;BAMUM LETTER PHASE-E NGKA;Lo;0;L;;;;;N;;;;;\n16974;BAMUM LETTER PHASE-E KPEUX;Lo;0;L;;;;;N;;;;;\n16975;BAMUM LETTER PHASE-E WUO;Lo;0;L;;;;;N;;;;;\n16976;BAMUM LETTER PHASE-E SEE;Lo;0;L;;;;;N;;;;;\n16977;BAMUM LETTER PHASE-E NGGEUAET;Lo;0;L;;;;;N;;;;;\n16978;BAMUM LETTER PHASE-E PAAM;Lo;0;L;;;;;N;;;;;\n16979;BAMUM LETTER PHASE-E TOO;Lo;0;L;;;;;N;;;;;\n1697A;BAMUM LETTER PHASE-E KUOP;Lo;0;L;;;;;N;;;;;\n1697B;BAMUM LETTER PHASE-E LOM;Lo;0;L;;;;;N;;;;;\n1697C;BAMUM LETTER PHASE-E NSHIEE;Lo;0;L;;;;;N;;;;;\n1697D;BAMUM LETTER PHASE-E NGOP;Lo;0;L;;;;;N;;;;;\n1697E;BAMUM LETTER PHASE-E MAEM;Lo;0;L;;;;;N;;;;;\n1697F;BAMUM LETTER PHASE-E NGKEUX;Lo;0;L;;;;;N;;;;;\n16980;BAMUM LETTER PHASE-E NGOQ;Lo;0;L;;;;;N;;;;;\n16981;BAMUM LETTER PHASE-E NSHUE;Lo;0;L;;;;;N;;;;;\n16982;BAMUM LETTER PHASE-E RIMGBA;Lo;0;L;;;;;N;;;;;\n16983;BAMUM LETTER PHASE-E NJEUX;Lo;0;L;;;;;N;;;;;\n16984;BAMUM LETTER PHASE-E PEEM;Lo;0;L;;;;;N;;;;;\n16985;BAMUM LETTER PHASE-E SAA;Lo;0;L;;;;;N;;;;;\n16986;BAMUM LETTER PHASE-E NGGURAE;Lo;0;L;;;;;N;;;;;\n16987;BAMUM LETTER PHASE-E MGBA;Lo;0;L;;;;;N;;;;;\n16988;BAMUM LETTER PHASE-E GHEUX;Lo;0;L;;;;;N;;;;;\n16989;BAMUM LETTER PHASE-E NGKEUAEM;Lo;0;L;;;;;N;;;;;\n1698A;BAMUM LETTER PHASE-E NJAEMLI;Lo;0;L;;;;;N;;;;;\n1698B;BAMUM LETTER PHASE-E MAP;Lo;0;L;;;;;N;;;;;\n1698C;BAMUM LETTER PHASE-E LOOT;Lo;0;L;;;;;N;;;;;\n1698D;BAMUM LETTER PHASE-E NGGEEEE;Lo;0;L;;;;;N;;;;;\n1698E;BAMUM LETTER PHASE-E NDIQ;Lo;0;L;;;;;N;;;;;\n1698F;BAMUM LETTER PHASE-E TAEN NTEUM;Lo;0;L;;;;;N;;;;;\n16990;BAMUM LETTER PHASE-E SET;Lo;0;L;;;;;N;;;;;\n16991;BAMUM LETTER PHASE-E PUM;Lo;0;L;;;;;N;;;;;\n16992;BAMUM LETTER PHASE-E NDAA SOFTNESS;Lo;0;L;;;;;N;;;;;\n16993;BAMUM LETTER PHASE-E NGGUAESHAE NYAM;Lo;0;L;;;;;N;;;;;\n16994;BAMUM LETTER PHASE-E YIEE;Lo;0;L;;;;;N;;;;;\n16995;BAMUM LETTER PHASE-E GHEUN;Lo;0;L;;;;;N;;;;;\n16996;BAMUM LETTER PHASE-E TUAE;Lo;0;L;;;;;N;;;;;\n16997;BAMUM LETTER PHASE-E YEUAE;Lo;0;L;;;;;N;;;;;\n16998;BAMUM LETTER PHASE-E PO;Lo;0;L;;;;;N;;;;;\n16999;BAMUM LETTER PHASE-E TUMAE;Lo;0;L;;;;;N;;;;;\n1699A;BAMUM LETTER PHASE-E KEUAE;Lo;0;L;;;;;N;;;;;\n1699B;BAMUM LETTER PHASE-E SUAEN;Lo;0;L;;;;;N;;;;;\n1699C;BAMUM LETTER PHASE-E TEUAEQ;Lo;0;L;;;;;N;;;;;\n1699D;BAMUM LETTER PHASE-E VEUAE;Lo;0;L;;;;;N;;;;;\n1699E;BAMUM LETTER PHASE-E WEUX;Lo;0;L;;;;;N;;;;;\n1699F;BAMUM LETTER PHASE-E LAAM;Lo;0;L;;;;;N;;;;;\n169A0;BAMUM LETTER PHASE-E PU;Lo;0;L;;;;;N;;;;;\n169A1;BAMUM LETTER PHASE-E TAAQ;Lo;0;L;;;;;N;;;;;\n169A2;BAMUM LETTER PHASE-E GHAAMAE;Lo;0;L;;;;;N;;;;;\n169A3;BAMUM LETTER PHASE-E NGEUREUT;Lo;0;L;;;;;N;;;;;\n169A4;BAMUM LETTER PHASE-E SHEUAEQ;Lo;0;L;;;;;N;;;;;\n169A5;BAMUM LETTER PHASE-E MGBEN;Lo;0;L;;;;;N;;;;;\n169A6;BAMUM LETTER PHASE-E MBEE;Lo;0;L;;;;;N;;;;;\n169A7;BAMUM LETTER PHASE-E NZAQ;Lo;0;L;;;;;N;;;;;\n169A8;BAMUM LETTER PHASE-E NKOM;Lo;0;L;;;;;N;;;;;\n169A9;BAMUM LETTER PHASE-E GBET;Lo;0;L;;;;;N;;;;;\n169AA;BAMUM LETTER PHASE-E TUM;Lo;0;L;;;;;N;;;;;\n169AB;BAMUM LETTER PHASE-E KUET;Lo;0;L;;;;;N;;;;;\n169AC;BAMUM LETTER PHASE-E YAP;Lo;0;L;;;;;N;;;;;\n169AD;BAMUM LETTER PHASE-E NYI CLEAVER;Lo;0;L;;;;;N;;;;;\n169AE;BAMUM LETTER PHASE-E YIT;Lo;0;L;;;;;N;;;;;\n169AF;BAMUM LETTER PHASE-E MFEUQ;Lo;0;L;;;;;N;;;;;\n169B0;BAMUM LETTER PHASE-E NDIAQ;Lo;0;L;;;;;N;;;;;\n169B1;BAMUM LETTER PHASE-E PIEEQ;Lo;0;L;;;;;N;;;;;\n169B2;BAMUM LETTER PHASE-E YUEQ;Lo;0;L;;;;;N;;;;;\n169B3;BAMUM LETTER PHASE-E LEUAEM;Lo;0;L;;;;;N;;;;;\n169B4;BAMUM LETTER PHASE-E FUE;Lo;0;L;;;;;N;;;;;\n169B5;BAMUM LETTER PHASE-E GBEUX;Lo;0;L;;;;;N;;;;;\n169B6;BAMUM LETTER PHASE-E NGKUP;Lo;0;L;;;;;N;;;;;\n169B7;BAMUM LETTER PHASE-E KET;Lo;0;L;;;;;N;;;;;\n169B8;BAMUM LETTER PHASE-E MAE;Lo;0;L;;;;;N;;;;;\n169B9;BAMUM LETTER PHASE-E NGKAAMI;Lo;0;L;;;;;N;;;;;\n169BA;BAMUM LETTER PHASE-E GHET;Lo;0;L;;;;;N;;;;;\n169BB;BAMUM LETTER PHASE-E FA;Lo;0;L;;;;;N;;;;;\n169BC;BAMUM LETTER PHASE-E NTUM;Lo;0;L;;;;;N;;;;;\n169BD;BAMUM LETTER PHASE-E PEUT;Lo;0;L;;;;;N;;;;;\n169BE;BAMUM LETTER PHASE-E YEUM;Lo;0;L;;;;;N;;;;;\n169BF;BAMUM LETTER PHASE-E NGGEUAE;Lo;0;L;;;;;N;;;;;\n169C0;BAMUM LETTER PHASE-E NYI BETWEEN;Lo;0;L;;;;;N;;;;;\n169C1;BAMUM LETTER PHASE-E NZUQ;Lo;0;L;;;;;N;;;;;\n169C2;BAMUM LETTER PHASE-E POON;Lo;0;L;;;;;N;;;;;\n169C3;BAMUM LETTER PHASE-E MIEE;Lo;0;L;;;;;N;;;;;\n169C4;BAMUM LETTER PHASE-E FUET;Lo;0;L;;;;;N;;;;;\n169C5;BAMUM LETTER PHASE-E NAE;Lo;0;L;;;;;N;;;;;\n169C6;BAMUM LETTER PHASE-E MUAE;Lo;0;L;;;;;N;;;;;\n169C7;BAMUM LETTER PHASE-E GHEUAE;Lo;0;L;;;;;N;;;;;\n169C8;BAMUM LETTER PHASE-E FU I;Lo;0;L;;;;;N;;;;;\n169C9;BAMUM LETTER PHASE-E MVI;Lo;0;L;;;;;N;;;;;\n169CA;BAMUM LETTER PHASE-E PUAQ;Lo;0;L;;;;;N;;;;;\n169CB;BAMUM LETTER PHASE-E NGKUM;Lo;0;L;;;;;N;;;;;\n169CC;BAMUM LETTER PHASE-E KUT;Lo;0;L;;;;;N;;;;;\n169CD;BAMUM LETTER PHASE-E PIET;Lo;0;L;;;;;N;;;;;\n169CE;BAMUM LETTER PHASE-E NTAP;Lo;0;L;;;;;N;;;;;\n169CF;BAMUM LETTER PHASE-E YEUAET;Lo;0;L;;;;;N;;;;;\n169D0;BAMUM LETTER PHASE-E NGGUP;Lo;0;L;;;;;N;;;;;\n169D1;BAMUM LETTER PHASE-E PA PEOPLE;Lo;0;L;;;;;N;;;;;\n169D2;BAMUM LETTER PHASE-E FU CALL;Lo;0;L;;;;;N;;;;;\n169D3;BAMUM LETTER PHASE-E FOM;Lo;0;L;;;;;N;;;;;\n169D4;BAMUM LETTER PHASE-E NJEE;Lo;0;L;;;;;N;;;;;\n169D5;BAMUM LETTER PHASE-E A;Lo;0;L;;;;;N;;;;;\n169D6;BAMUM LETTER PHASE-E TOQ;Lo;0;L;;;;;N;;;;;\n169D7;BAMUM LETTER PHASE-E O;Lo;0;L;;;;;N;;;;;\n169D8;BAMUM LETTER PHASE-E I;Lo;0;L;;;;;N;;;;;\n169D9;BAMUM LETTER PHASE-E LAQ;Lo;0;L;;;;;N;;;;;\n169DA;BAMUM LETTER PHASE-E PA PLURAL;Lo;0;L;;;;;N;;;;;\n169DB;BAMUM LETTER PHASE-E TAA;Lo;0;L;;;;;N;;;;;\n169DC;BAMUM LETTER PHASE-E TAQ;Lo;0;L;;;;;N;;;;;\n169DD;BAMUM LETTER PHASE-E NDAA MY HOUSE;Lo;0;L;;;;;N;;;;;\n169DE;BAMUM LETTER PHASE-E SHIQ;Lo;0;L;;;;;N;;;;;\n169DF;BAMUM LETTER PHASE-E YEUX;Lo;0;L;;;;;N;;;;;\n169E0;BAMUM LETTER PHASE-E NGUAE;Lo;0;L;;;;;N;;;;;\n169E1;BAMUM LETTER PHASE-E YUAEN;Lo;0;L;;;;;N;;;;;\n169E2;BAMUM LETTER PHASE-E YOQ SWIMMING;Lo;0;L;;;;;N;;;;;\n169E3;BAMUM LETTER PHASE-E YOQ COVER;Lo;0;L;;;;;N;;;;;\n169E4;BAMUM LETTER PHASE-E YUQ;Lo;0;L;;;;;N;;;;;\n169E5;BAMUM LETTER PHASE-E YUN;Lo;0;L;;;;;N;;;;;\n169E6;BAMUM LETTER PHASE-E KEUX;Lo;0;L;;;;;N;;;;;\n169E7;BAMUM LETTER PHASE-E PEUX;Lo;0;L;;;;;N;;;;;\n169E8;BAMUM LETTER PHASE-E NJEE EPOCH;Lo;0;L;;;;;N;;;;;\n169E9;BAMUM LETTER PHASE-E PUE;Lo;0;L;;;;;N;;;;;\n169EA;BAMUM LETTER PHASE-E WUE;Lo;0;L;;;;;N;;;;;\n169EB;BAMUM LETTER PHASE-E FEE;Lo;0;L;;;;;N;;;;;\n169EC;BAMUM LETTER PHASE-E VEE;Lo;0;L;;;;;N;;;;;\n169ED;BAMUM LETTER PHASE-E LU;Lo;0;L;;;;;N;;;;;\n169EE;BAMUM LETTER PHASE-E MI;Lo;0;L;;;;;N;;;;;\n169EF;BAMUM LETTER PHASE-E REUX;Lo;0;L;;;;;N;;;;;\n169F0;BAMUM LETTER PHASE-E RAE;Lo;0;L;;;;;N;;;;;\n169F1;BAMUM LETTER PHASE-E NGUAET;Lo;0;L;;;;;N;;;;;\n169F2;BAMUM LETTER PHASE-E NGA;Lo;0;L;;;;;N;;;;;\n169F3;BAMUM LETTER PHASE-E SHO;Lo;0;L;;;;;N;;;;;\n169F4;BAMUM LETTER PHASE-E SHOQ;Lo;0;L;;;;;N;;;;;\n169F5;BAMUM LETTER PHASE-E FU REMEDY;Lo;0;L;;;;;N;;;;;\n169F6;BAMUM LETTER PHASE-E NA;Lo;0;L;;;;;N;;;;;\n169F7;BAMUM LETTER PHASE-E PI;Lo;0;L;;;;;N;;;;;\n169F8;BAMUM LETTER PHASE-E LOQ;Lo;0;L;;;;;N;;;;;\n169F9;BAMUM LETTER PHASE-E KO;Lo;0;L;;;;;N;;;;;\n169FA;BAMUM LETTER PHASE-E MEN;Lo;0;L;;;;;N;;;;;\n169FB;BAMUM LETTER PHASE-E MA;Lo;0;L;;;;;N;;;;;\n169FC;BAMUM LETTER PHASE-E MAQ;Lo;0;L;;;;;N;;;;;\n169FD;BAMUM LETTER PHASE-E TEU;Lo;0;L;;;;;N;;;;;\n169FE;BAMUM LETTER PHASE-E KI;Lo;0;L;;;;;N;;;;;\n169FF;BAMUM LETTER PHASE-E MON;Lo;0;L;;;;;N;;;;;\n16A00;BAMUM LETTER PHASE-E TEN;Lo;0;L;;;;;N;;;;;\n16A01;BAMUM LETTER PHASE-E FAQ;Lo;0;L;;;;;N;;;;;\n16A02;BAMUM LETTER PHASE-E GHOM;Lo;0;L;;;;;N;;;;;\n16A03;BAMUM LETTER PHASE-F KA;Lo;0;L;;;;;N;;;;;\n16A04;BAMUM LETTER PHASE-F U;Lo;0;L;;;;;N;;;;;\n16A05;BAMUM LETTER PHASE-F KU;Lo;0;L;;;;;N;;;;;\n16A06;BAMUM LETTER PHASE-F EE;Lo;0;L;;;;;N;;;;;\n16A07;BAMUM LETTER PHASE-F REE;Lo;0;L;;;;;N;;;;;\n16A08;BAMUM LETTER PHASE-F TAE;Lo;0;L;;;;;N;;;;;\n16A09;BAMUM LETTER PHASE-F NYI;Lo;0;L;;;;;N;;;;;\n16A0A;BAMUM LETTER PHASE-F LA;Lo;0;L;;;;;N;;;;;\n16A0B;BAMUM LETTER PHASE-F RII;Lo;0;L;;;;;N;;;;;\n16A0C;BAMUM LETTER PHASE-F RIEE;Lo;0;L;;;;;N;;;;;\n16A0D;BAMUM LETTER PHASE-F MEEEE;Lo;0;L;;;;;N;;;;;\n16A0E;BAMUM LETTER PHASE-F TAA;Lo;0;L;;;;;N;;;;;\n16A0F;BAMUM LETTER PHASE-F NDAA;Lo;0;L;;;;;N;;;;;\n16A10;BAMUM LETTER PHASE-F NJAEM;Lo;0;L;;;;;N;;;;;\n16A11;BAMUM LETTER PHASE-F M;Lo;0;L;;;;;N;;;;;\n16A12;BAMUM LETTER PHASE-F SUU;Lo;0;L;;;;;N;;;;;\n16A13;BAMUM LETTER PHASE-F SHII;Lo;0;L;;;;;N;;;;;\n16A14;BAMUM LETTER PHASE-F SI;Lo;0;L;;;;;N;;;;;\n16A15;BAMUM LETTER PHASE-F SEUX;Lo;0;L;;;;;N;;;;;\n16A16;BAMUM LETTER PHASE-F KYEE;Lo;0;L;;;;;N;;;;;\n16A17;BAMUM LETTER PHASE-F KET;Lo;0;L;;;;;N;;;;;\n16A18;BAMUM LETTER PHASE-F NUAE;Lo;0;L;;;;;N;;;;;\n16A19;BAMUM LETTER PHASE-F NU;Lo;0;L;;;;;N;;;;;\n16A1A;BAMUM LETTER PHASE-F NJUAE;Lo;0;L;;;;;N;;;;;\n16A1B;BAMUM LETTER PHASE-F YOQ;Lo;0;L;;;;;N;;;;;\n16A1C;BAMUM LETTER PHASE-F SHU;Lo;0;L;;;;;N;;;;;\n16A1D;BAMUM LETTER PHASE-F YA;Lo;0;L;;;;;N;;;;;\n16A1E;BAMUM LETTER PHASE-F NSHA;Lo;0;L;;;;;N;;;;;\n16A1F;BAMUM LETTER PHASE-F PEUX;Lo;0;L;;;;;N;;;;;\n16A20;BAMUM LETTER PHASE-F NTEE;Lo;0;L;;;;;N;;;;;\n16A21;BAMUM LETTER PHASE-F WUE;Lo;0;L;;;;;N;;;;;\n16A22;BAMUM LETTER PHASE-F PEE;Lo;0;L;;;;;N;;;;;\n16A23;BAMUM LETTER PHASE-F RU;Lo;0;L;;;;;N;;;;;\n16A24;BAMUM LETTER PHASE-F NI;Lo;0;L;;;;;N;;;;;\n16A25;BAMUM LETTER PHASE-F REUX;Lo;0;L;;;;;N;;;;;\n16A26;BAMUM LETTER PHASE-F KEN;Lo;0;L;;;;;N;;;;;\n16A27;BAMUM LETTER PHASE-F NGKWAEN;Lo;0;L;;;;;N;;;;;\n16A28;BAMUM LETTER PHASE-F NGGA;Lo;0;L;;;;;N;;;;;\n16A29;BAMUM LETTER PHASE-F SHO;Lo;0;L;;;;;N;;;;;\n16A2A;BAMUM LETTER PHASE-F PUAE;Lo;0;L;;;;;N;;;;;\n16A2B;BAMUM LETTER PHASE-F FOM;Lo;0;L;;;;;N;;;;;\n16A2C;BAMUM LETTER PHASE-F WA;Lo;0;L;;;;;N;;;;;\n16A2D;BAMUM LETTER PHASE-F LI;Lo;0;L;;;;;N;;;;;\n16A2E;BAMUM LETTER PHASE-F LOQ;Lo;0;L;;;;;N;;;;;\n16A2F;BAMUM LETTER PHASE-F KO;Lo;0;L;;;;;N;;;;;\n16A30;BAMUM LETTER PHASE-F MBEN;Lo;0;L;;;;;N;;;;;\n16A31;BAMUM LETTER PHASE-F REN;Lo;0;L;;;;;N;;;;;\n16A32;BAMUM LETTER PHASE-F MA;Lo;0;L;;;;;N;;;;;\n16A33;BAMUM LETTER PHASE-F MO;Lo;0;L;;;;;N;;;;;\n16A34;BAMUM LETTER PHASE-F MBAA;Lo;0;L;;;;;N;;;;;\n16A35;BAMUM LETTER PHASE-F TET;Lo;0;L;;;;;N;;;;;\n16A36;BAMUM LETTER PHASE-F KPA;Lo;0;L;;;;;N;;;;;\n16A37;BAMUM LETTER PHASE-F SAMBA;Lo;0;L;;;;;N;;;;;\n16A38;BAMUM LETTER PHASE-F VUEQ;Lo;0;L;;;;;N;;;;;\n16F00;MIAO LETTER PA;Lo;0;L;;;;;N;;;;;\n16F01;MIAO LETTER BA;Lo;0;L;;;;;N;;;;;\n16F02;MIAO LETTER YI PA;Lo;0;L;;;;;N;;;;;\n16F03;MIAO LETTER PLA;Lo;0;L;;;;;N;;;;;\n16F04;MIAO LETTER MA;Lo;0;L;;;;;N;;;;;\n16F05;MIAO LETTER MHA;Lo;0;L;;;;;N;;;;;\n16F06;MIAO LETTER ARCHAIC MA;Lo;0;L;;;;;N;;;;;\n16F07;MIAO LETTER FA;Lo;0;L;;;;;N;;;;;\n16F08;MIAO LETTER VA;Lo;0;L;;;;;N;;;;;\n16F09;MIAO LETTER VFA;Lo;0;L;;;;;N;;;;;\n16F0A;MIAO LETTER TA;Lo;0;L;;;;;N;;;;;\n16F0B;MIAO LETTER DA;Lo;0;L;;;;;N;;;;;\n16F0C;MIAO LETTER YI TTA;Lo;0;L;;;;;N;;;;;\n16F0D;MIAO LETTER YI TA;Lo;0;L;;;;;N;;;;;\n16F0E;MIAO LETTER TTA;Lo;0;L;;;;;N;;;;;\n16F0F;MIAO LETTER DDA;Lo;0;L;;;;;N;;;;;\n16F10;MIAO LETTER NA;Lo;0;L;;;;;N;;;;;\n16F11;MIAO LETTER NHA;Lo;0;L;;;;;N;;;;;\n16F12;MIAO LETTER YI NNA;Lo;0;L;;;;;N;;;;;\n16F13;MIAO LETTER ARCHAIC NA;Lo;0;L;;;;;N;;;;;\n16F14;MIAO LETTER NNA;Lo;0;L;;;;;N;;;;;\n16F15;MIAO LETTER NNHA;Lo;0;L;;;;;N;;;;;\n16F16;MIAO LETTER LA;Lo;0;L;;;;;N;;;;;\n16F17;MIAO LETTER LYA;Lo;0;L;;;;;N;;;;;\n16F18;MIAO LETTER LHA;Lo;0;L;;;;;N;;;;;\n16F19;MIAO LETTER LHYA;Lo;0;L;;;;;N;;;;;\n16F1A;MIAO LETTER TLHA;Lo;0;L;;;;;N;;;;;\n16F1B;MIAO LETTER DLHA;Lo;0;L;;;;;N;;;;;\n16F1C;MIAO LETTER TLHYA;Lo;0;L;;;;;N;;;;;\n16F1D;MIAO LETTER DLHYA;Lo;0;L;;;;;N;;;;;\n16F1E;MIAO LETTER KA;Lo;0;L;;;;;N;;;;;\n16F1F;MIAO LETTER GA;Lo;0;L;;;;;N;;;;;\n16F20;MIAO LETTER YI KA;Lo;0;L;;;;;N;;;;;\n16F21;MIAO LETTER QA;Lo;0;L;;;;;N;;;;;\n16F22;MIAO LETTER QGA;Lo;0;L;;;;;N;;;;;\n16F23;MIAO LETTER NGA;Lo;0;L;;;;;N;;;;;\n16F24;MIAO LETTER NGHA;Lo;0;L;;;;;N;;;;;\n16F25;MIAO LETTER ARCHAIC NGA;Lo;0;L;;;;;N;;;;;\n16F26;MIAO LETTER HA;Lo;0;L;;;;;N;;;;;\n16F27;MIAO LETTER XA;Lo;0;L;;;;;N;;;;;\n16F28;MIAO LETTER GHA;Lo;0;L;;;;;N;;;;;\n16F29;MIAO LETTER GHHA;Lo;0;L;;;;;N;;;;;\n16F2A;MIAO LETTER TSSA;Lo;0;L;;;;;N;;;;;\n16F2B;MIAO LETTER DZZA;Lo;0;L;;;;;N;;;;;\n16F2C;MIAO LETTER NYA;Lo;0;L;;;;;N;;;;;\n16F2D;MIAO LETTER NYHA;Lo;0;L;;;;;N;;;;;\n16F2E;MIAO LETTER TSHA;Lo;0;L;;;;;N;;;;;\n16F2F;MIAO LETTER DZHA;Lo;0;L;;;;;N;;;;;\n16F30;MIAO LETTER YI TSHA;Lo;0;L;;;;;N;;;;;\n16F31;MIAO LETTER YI DZHA;Lo;0;L;;;;;N;;;;;\n16F32;MIAO LETTER REFORMED TSHA;Lo;0;L;;;;;N;;;;;\n16F33;MIAO LETTER SHA;Lo;0;L;;;;;N;;;;;\n16F34;MIAO LETTER SSA;Lo;0;L;;;;;N;;;;;\n16F35;MIAO LETTER ZHA;Lo;0;L;;;;;N;;;;;\n16F36;MIAO LETTER ZSHA;Lo;0;L;;;;;N;;;;;\n16F37;MIAO LETTER TSA;Lo;0;L;;;;;N;;;;;\n16F38;MIAO LETTER DZA;Lo;0;L;;;;;N;;;;;\n16F39;MIAO LETTER YI TSA;Lo;0;L;;;;;N;;;;;\n16F3A;MIAO LETTER SA;Lo;0;L;;;;;N;;;;;\n16F3B;MIAO LETTER ZA;Lo;0;L;;;;;N;;;;;\n16F3C;MIAO LETTER ZSA;Lo;0;L;;;;;N;;;;;\n16F3D;MIAO LETTER ZZA;Lo;0;L;;;;;N;;;;;\n16F3E;MIAO LETTER ZZSA;Lo;0;L;;;;;N;;;;;\n16F3F;MIAO LETTER ARCHAIC ZZA;Lo;0;L;;;;;N;;;;;\n16F40;MIAO LETTER ZZYA;Lo;0;L;;;;;N;;;;;\n16F41;MIAO LETTER ZZSYA;Lo;0;L;;;;;N;;;;;\n16F42;MIAO LETTER WA;Lo;0;L;;;;;N;;;;;\n16F43;MIAO LETTER AH;Lo;0;L;;;;;N;;;;;\n16F44;MIAO LETTER HHA;Lo;0;L;;;;;N;;;;;\n16F50;MIAO LETTER NASALIZATION;Lo;0;L;;;;;N;;;;;\n16F51;MIAO SIGN ASPIRATION;Mc;0;L;;;;;N;;;;;\n16F52;MIAO SIGN REFORMED VOICING;Mc;0;L;;;;;N;;;;;\n16F53;MIAO SIGN REFORMED ASPIRATION;Mc;0;L;;;;;N;;;;;\n16F54;MIAO VOWEL SIGN A;Mc;0;L;;;;;N;;;;;\n16F55;MIAO VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;\n16F56;MIAO VOWEL SIGN AHH;Mc;0;L;;;;;N;;;;;\n16F57;MIAO VOWEL SIGN AN;Mc;0;L;;;;;N;;;;;\n16F58;MIAO VOWEL SIGN ANG;Mc;0;L;;;;;N;;;;;\n16F59;MIAO VOWEL SIGN O;Mc;0;L;;;;;N;;;;;\n16F5A;MIAO VOWEL SIGN OO;Mc;0;L;;;;;N;;;;;\n16F5B;MIAO VOWEL SIGN WO;Mc;0;L;;;;;N;;;;;\n16F5C;MIAO VOWEL SIGN W;Mc;0;L;;;;;N;;;;;\n16F5D;MIAO VOWEL SIGN E;Mc;0;L;;;;;N;;;;;\n16F5E;MIAO VOWEL SIGN EN;Mc;0;L;;;;;N;;;;;\n16F5F;MIAO VOWEL SIGN ENG;Mc;0;L;;;;;N;;;;;\n16F60;MIAO VOWEL SIGN OEY;Mc;0;L;;;;;N;;;;;\n16F61;MIAO VOWEL SIGN I;Mc;0;L;;;;;N;;;;;\n16F62;MIAO VOWEL SIGN IA;Mc;0;L;;;;;N;;;;;\n16F63;MIAO VOWEL SIGN IAN;Mc;0;L;;;;;N;;;;;\n16F64;MIAO VOWEL SIGN IANG;Mc;0;L;;;;;N;;;;;\n16F65;MIAO VOWEL SIGN IO;Mc;0;L;;;;;N;;;;;\n16F66;MIAO VOWEL SIGN IE;Mc;0;L;;;;;N;;;;;\n16F67;MIAO VOWEL SIGN II;Mc;0;L;;;;;N;;;;;\n16F68;MIAO VOWEL SIGN IU;Mc;0;L;;;;;N;;;;;\n16F69;MIAO VOWEL SIGN ING;Mc;0;L;;;;;N;;;;;\n16F6A;MIAO VOWEL SIGN U;Mc;0;L;;;;;N;;;;;\n16F6B;MIAO VOWEL SIGN UA;Mc;0;L;;;;;N;;;;;\n16F6C;MIAO VOWEL SIGN UAN;Mc;0;L;;;;;N;;;;;\n16F6D;MIAO VOWEL SIGN UANG;Mc;0;L;;;;;N;;;;;\n16F6E;MIAO VOWEL SIGN UU;Mc;0;L;;;;;N;;;;;\n16F6F;MIAO VOWEL SIGN UEI;Mc;0;L;;;;;N;;;;;\n16F70;MIAO VOWEL SIGN UNG;Mc;0;L;;;;;N;;;;;\n16F71;MIAO VOWEL SIGN Y;Mc;0;L;;;;;N;;;;;\n16F72;MIAO VOWEL SIGN YI;Mc;0;L;;;;;N;;;;;\n16F73;MIAO VOWEL SIGN AE;Mc;0;L;;;;;N;;;;;\n16F74;MIAO VOWEL SIGN AEE;Mc;0;L;;;;;N;;;;;\n16F75;MIAO VOWEL SIGN ERR;Mc;0;L;;;;;N;;;;;\n16F76;MIAO VOWEL SIGN ROUNDED ERR;Mc;0;L;;;;;N;;;;;\n16F77;MIAO VOWEL SIGN ER;Mc;0;L;;;;;N;;;;;\n16F78;MIAO VOWEL SIGN ROUNDED ER;Mc;0;L;;;;;N;;;;;\n16F79;MIAO VOWEL SIGN AI;Mc;0;L;;;;;N;;;;;\n16F7A;MIAO VOWEL SIGN EI;Mc;0;L;;;;;N;;;;;\n16F7B;MIAO VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;\n16F7C;MIAO VOWEL SIGN OU;Mc;0;L;;;;;N;;;;;\n16F7D;MIAO VOWEL SIGN N;Mc;0;L;;;;;N;;;;;\n16F7E;MIAO VOWEL SIGN NG;Mc;0;L;;;;;N;;;;;\n16F8F;MIAO TONE RIGHT;Mn;0;NSM;;;;;N;;;;;\n16F90;MIAO TONE TOP RIGHT;Mn;0;NSM;;;;;N;;;;;\n16F91;MIAO TONE ABOVE;Mn;0;NSM;;;;;N;;;;;\n16F92;MIAO TONE BELOW;Mn;0;NSM;;;;;N;;;;;\n16F93;MIAO LETTER TONE-2;Lm;0;L;;;;;N;;;;;\n16F94;MIAO LETTER TONE-3;Lm;0;L;;;;;N;;;;;\n16F95;MIAO LETTER TONE-4;Lm;0;L;;;;;N;;;;;\n16F96;MIAO LETTER TONE-5;Lm;0;L;;;;;N;;;;;\n16F97;MIAO LETTER TONE-6;Lm;0;L;;;;;N;;;;;\n16F98;MIAO LETTER TONE-7;Lm;0;L;;;;;N;;;;;\n16F99;MIAO LETTER TONE-8;Lm;0;L;;;;;N;;;;;\n16F9A;MIAO LETTER REFORMED TONE-1;Lm;0;L;;;;;N;;;;;\n16F9B;MIAO LETTER REFORMED TONE-2;Lm;0;L;;;;;N;;;;;\n16F9C;MIAO LETTER REFORMED TONE-4;Lm;0;L;;;;;N;;;;;\n16F9D;MIAO LETTER REFORMED TONE-5;Lm;0;L;;;;;N;;;;;\n16F9E;MIAO LETTER REFORMED TONE-6;Lm;0;L;;;;;N;;;;;\n16F9F;MIAO LETTER REFORMED TONE-8;Lm;0;L;;;;;N;;;;;\n1B000;KATAKANA LETTER ARCHAIC E;Lo;0;L;;;;;N;;;;;\n1B001;HIRAGANA LETTER ARCHAIC YE;Lo;0;L;;;;;N;;;;;\n1D000;BYZANTINE MUSICAL SYMBOL PSILI;So;0;L;;;;;N;;;;;\n1D001;BYZANTINE MUSICAL SYMBOL DASEIA;So;0;L;;;;;N;;;;;\n1D002;BYZANTINE MUSICAL SYMBOL PERISPOMENI;So;0;L;;;;;N;;;;;\n1D003;BYZANTINE MUSICAL SYMBOL OXEIA EKFONITIKON;So;0;L;;;;;N;;;;;\n1D004;BYZANTINE MUSICAL SYMBOL OXEIA DIPLI;So;0;L;;;;;N;;;;;\n1D005;BYZANTINE MUSICAL SYMBOL VAREIA EKFONITIKON;So;0;L;;;;;N;;;;;\n1D006;BYZANTINE MUSICAL SYMBOL VAREIA DIPLI;So;0;L;;;;;N;;;;;\n1D007;BYZANTINE MUSICAL SYMBOL KATHISTI;So;0;L;;;;;N;;;;;\n1D008;BYZANTINE MUSICAL SYMBOL SYRMATIKI;So;0;L;;;;;N;;;;;\n1D009;BYZANTINE MUSICAL SYMBOL PARAKLITIKI;So;0;L;;;;;N;;;;;\n1D00A;BYZANTINE MUSICAL SYMBOL YPOKRISIS;So;0;L;;;;;N;;;;;\n1D00B;BYZANTINE MUSICAL SYMBOL YPOKRISIS DIPLI;So;0;L;;;;;N;;;;;\n1D00C;BYZANTINE MUSICAL SYMBOL KREMASTI;So;0;L;;;;;N;;;;;\n1D00D;BYZANTINE MUSICAL SYMBOL APESO EKFONITIKON;So;0;L;;;;;N;;;;;\n1D00E;BYZANTINE MUSICAL SYMBOL EXO EKFONITIKON;So;0;L;;;;;N;;;;;\n1D00F;BYZANTINE MUSICAL SYMBOL TELEIA;So;0;L;;;;;N;;;;;\n1D010;BYZANTINE MUSICAL SYMBOL KENTIMATA;So;0;L;;;;;N;;;;;\n1D011;BYZANTINE MUSICAL SYMBOL APOSTROFOS;So;0;L;;;;;N;;;;;\n1D012;BYZANTINE MUSICAL SYMBOL APOSTROFOS DIPLI;So;0;L;;;;;N;;;;;\n1D013;BYZANTINE MUSICAL SYMBOL SYNEVMA;So;0;L;;;;;N;;;;;\n1D014;BYZANTINE MUSICAL SYMBOL THITA;So;0;L;;;;;N;;;;;\n1D015;BYZANTINE MUSICAL SYMBOL OLIGON ARCHAION;So;0;L;;;;;N;;;;;\n1D016;BYZANTINE MUSICAL SYMBOL GORGON ARCHAION;So;0;L;;;;;N;;;;;\n1D017;BYZANTINE MUSICAL SYMBOL PSILON;So;0;L;;;;;N;;;;;\n1D018;BYZANTINE MUSICAL SYMBOL CHAMILON;So;0;L;;;;;N;;;;;\n1D019;BYZANTINE MUSICAL SYMBOL VATHY;So;0;L;;;;;N;;;;;\n1D01A;BYZANTINE MUSICAL SYMBOL ISON ARCHAION;So;0;L;;;;;N;;;;;\n1D01B;BYZANTINE MUSICAL SYMBOL KENTIMA ARCHAION;So;0;L;;;;;N;;;;;\n1D01C;BYZANTINE MUSICAL SYMBOL KENTIMATA ARCHAION;So;0;L;;;;;N;;;;;\n1D01D;BYZANTINE MUSICAL SYMBOL SAXIMATA;So;0;L;;;;;N;;;;;\n1D01E;BYZANTINE MUSICAL SYMBOL PARICHON;So;0;L;;;;;N;;;;;\n1D01F;BYZANTINE MUSICAL SYMBOL STAVROS APODEXIA;So;0;L;;;;;N;;;;;\n1D020;BYZANTINE MUSICAL SYMBOL OXEIAI ARCHAION;So;0;L;;;;;N;;;;;\n1D021;BYZANTINE MUSICAL SYMBOL VAREIAI ARCHAION;So;0;L;;;;;N;;;;;\n1D022;BYZANTINE MUSICAL SYMBOL APODERMA ARCHAION;So;0;L;;;;;N;;;;;\n1D023;BYZANTINE MUSICAL SYMBOL APOTHEMA;So;0;L;;;;;N;;;;;\n1D024;BYZANTINE MUSICAL SYMBOL KLASMA;So;0;L;;;;;N;;;;;\n1D025;BYZANTINE MUSICAL SYMBOL REVMA;So;0;L;;;;;N;;;;;\n1D026;BYZANTINE MUSICAL SYMBOL PIASMA ARCHAION;So;0;L;;;;;N;;;;;\n1D027;BYZANTINE MUSICAL SYMBOL TINAGMA;So;0;L;;;;;N;;;;;\n1D028;BYZANTINE MUSICAL SYMBOL ANATRICHISMA;So;0;L;;;;;N;;;;;\n1D029;BYZANTINE MUSICAL SYMBOL SEISMA;So;0;L;;;;;N;;;;;\n1D02A;BYZANTINE MUSICAL SYMBOL SYNAGMA ARCHAION;So;0;L;;;;;N;;;;;\n1D02B;BYZANTINE MUSICAL SYMBOL SYNAGMA META STAVROU;So;0;L;;;;;N;;;;;\n1D02C;BYZANTINE MUSICAL SYMBOL OYRANISMA ARCHAION;So;0;L;;;;;N;;;;;\n1D02D;BYZANTINE MUSICAL SYMBOL THEMA;So;0;L;;;;;N;;;;;\n1D02E;BYZANTINE MUSICAL SYMBOL LEMOI;So;0;L;;;;;N;;;;;\n1D02F;BYZANTINE MUSICAL SYMBOL DYO;So;0;L;;;;;N;;;;;\n1D030;BYZANTINE MUSICAL SYMBOL TRIA;So;0;L;;;;;N;;;;;\n1D031;BYZANTINE MUSICAL SYMBOL TESSERA;So;0;L;;;;;N;;;;;\n1D032;BYZANTINE MUSICAL SYMBOL KRATIMATA;So;0;L;;;;;N;;;;;\n1D033;BYZANTINE MUSICAL SYMBOL APESO EXO NEO;So;0;L;;;;;N;;;;;\n1D034;BYZANTINE MUSICAL SYMBOL FTHORA ARCHAION;So;0;L;;;;;N;;;;;\n1D035;BYZANTINE MUSICAL SYMBOL IMIFTHORA;So;0;L;;;;;N;;;;;\n1D036;BYZANTINE MUSICAL SYMBOL TROMIKON ARCHAION;So;0;L;;;;;N;;;;;\n1D037;BYZANTINE MUSICAL SYMBOL KATAVA TROMIKON;So;0;L;;;;;N;;;;;\n1D038;BYZANTINE MUSICAL SYMBOL PELASTON;So;0;L;;;;;N;;;;;\n1D039;BYZANTINE MUSICAL SYMBOL PSIFISTON;So;0;L;;;;;N;;;;;\n1D03A;BYZANTINE MUSICAL SYMBOL KONTEVMA;So;0;L;;;;;N;;;;;\n1D03B;BYZANTINE MUSICAL SYMBOL CHOREVMA ARCHAION;So;0;L;;;;;N;;;;;\n1D03C;BYZANTINE MUSICAL SYMBOL RAPISMA;So;0;L;;;;;N;;;;;\n1D03D;BYZANTINE MUSICAL SYMBOL PARAKALESMA ARCHAION;So;0;L;;;;;N;;;;;\n1D03E;BYZANTINE MUSICAL SYMBOL PARAKLITIKI ARCHAION;So;0;L;;;;;N;;;;;\n1D03F;BYZANTINE MUSICAL SYMBOL ICHADIN;So;0;L;;;;;N;;;;;\n1D040;BYZANTINE MUSICAL SYMBOL NANA;So;0;L;;;;;N;;;;;\n1D041;BYZANTINE MUSICAL SYMBOL PETASMA;So;0;L;;;;;N;;;;;\n1D042;BYZANTINE MUSICAL SYMBOL KONTEVMA ALLO;So;0;L;;;;;N;;;;;\n1D043;BYZANTINE MUSICAL SYMBOL TROMIKON ALLO;So;0;L;;;;;N;;;;;\n1D044;BYZANTINE MUSICAL SYMBOL STRAGGISMATA;So;0;L;;;;;N;;;;;\n1D045;BYZANTINE MUSICAL SYMBOL GRONTHISMATA;So;0;L;;;;;N;;;;;\n1D046;BYZANTINE MUSICAL SYMBOL ISON NEO;So;0;L;;;;;N;;;;;\n1D047;BYZANTINE MUSICAL SYMBOL OLIGON NEO;So;0;L;;;;;N;;;;;\n1D048;BYZANTINE MUSICAL SYMBOL OXEIA NEO;So;0;L;;;;;N;;;;;\n1D049;BYZANTINE MUSICAL SYMBOL PETASTI;So;0;L;;;;;N;;;;;\n1D04A;BYZANTINE MUSICAL SYMBOL KOUFISMA;So;0;L;;;;;N;;;;;\n1D04B;BYZANTINE MUSICAL SYMBOL PETASTOKOUFISMA;So;0;L;;;;;N;;;;;\n1D04C;BYZANTINE MUSICAL SYMBOL KRATIMOKOUFISMA;So;0;L;;;;;N;;;;;\n1D04D;BYZANTINE MUSICAL SYMBOL PELASTON NEO;So;0;L;;;;;N;;;;;\n1D04E;BYZANTINE MUSICAL SYMBOL KENTIMATA NEO ANO;So;0;L;;;;;N;;;;;\n1D04F;BYZANTINE MUSICAL SYMBOL KENTIMA NEO ANO;So;0;L;;;;;N;;;;;\n1D050;BYZANTINE MUSICAL SYMBOL YPSILI;So;0;L;;;;;N;;;;;\n1D051;BYZANTINE MUSICAL SYMBOL APOSTROFOS NEO;So;0;L;;;;;N;;;;;\n1D052;BYZANTINE MUSICAL SYMBOL APOSTROFOI SYNDESMOS NEO;So;0;L;;;;;N;;;;;\n1D053;BYZANTINE MUSICAL SYMBOL YPORROI;So;0;L;;;;;N;;;;;\n1D054;BYZANTINE MUSICAL SYMBOL KRATIMOYPORROON;So;0;L;;;;;N;;;;;\n1D055;BYZANTINE MUSICAL SYMBOL ELAFRON;So;0;L;;;;;N;;;;;\n1D056;BYZANTINE MUSICAL SYMBOL CHAMILI;So;0;L;;;;;N;;;;;\n1D057;BYZANTINE MUSICAL SYMBOL MIKRON ISON;So;0;L;;;;;N;;;;;\n1D058;BYZANTINE MUSICAL SYMBOL VAREIA NEO;So;0;L;;;;;N;;;;;\n1D059;BYZANTINE MUSICAL SYMBOL PIASMA NEO;So;0;L;;;;;N;;;;;\n1D05A;BYZANTINE MUSICAL SYMBOL PSIFISTON NEO;So;0;L;;;;;N;;;;;\n1D05B;BYZANTINE MUSICAL SYMBOL OMALON;So;0;L;;;;;N;;;;;\n1D05C;BYZANTINE MUSICAL SYMBOL ANTIKENOMA;So;0;L;;;;;N;;;;;\n1D05D;BYZANTINE MUSICAL SYMBOL LYGISMA;So;0;L;;;;;N;;;;;\n1D05E;BYZANTINE MUSICAL SYMBOL PARAKLITIKI NEO;So;0;L;;;;;N;;;;;\n1D05F;BYZANTINE MUSICAL SYMBOL PARAKALESMA NEO;So;0;L;;;;;N;;;;;\n1D060;BYZANTINE MUSICAL SYMBOL ETERON PARAKALESMA;So;0;L;;;;;N;;;;;\n1D061;BYZANTINE MUSICAL SYMBOL KYLISMA;So;0;L;;;;;N;;;;;\n1D062;BYZANTINE MUSICAL SYMBOL ANTIKENOKYLISMA;So;0;L;;;;;N;;;;;\n1D063;BYZANTINE MUSICAL SYMBOL TROMIKON NEO;So;0;L;;;;;N;;;;;\n1D064;BYZANTINE MUSICAL SYMBOL EKSTREPTON;So;0;L;;;;;N;;;;;\n1D065;BYZANTINE MUSICAL SYMBOL SYNAGMA NEO;So;0;L;;;;;N;;;;;\n1D066;BYZANTINE MUSICAL SYMBOL SYRMA;So;0;L;;;;;N;;;;;\n1D067;BYZANTINE MUSICAL SYMBOL CHOREVMA NEO;So;0;L;;;;;N;;;;;\n1D068;BYZANTINE MUSICAL SYMBOL EPEGERMA;So;0;L;;;;;N;;;;;\n1D069;BYZANTINE MUSICAL SYMBOL SEISMA NEO;So;0;L;;;;;N;;;;;\n1D06A;BYZANTINE MUSICAL SYMBOL XIRON KLASMA;So;0;L;;;;;N;;;;;\n1D06B;BYZANTINE MUSICAL SYMBOL TROMIKOPSIFISTON;So;0;L;;;;;N;;;;;\n1D06C;BYZANTINE MUSICAL SYMBOL PSIFISTOLYGISMA;So;0;L;;;;;N;;;;;\n1D06D;BYZANTINE MUSICAL SYMBOL TROMIKOLYGISMA;So;0;L;;;;;N;;;;;\n1D06E;BYZANTINE MUSICAL SYMBOL TROMIKOPARAKALESMA;So;0;L;;;;;N;;;;;\n1D06F;BYZANTINE MUSICAL SYMBOL PSIFISTOPARAKALESMA;So;0;L;;;;;N;;;;;\n1D070;BYZANTINE MUSICAL SYMBOL TROMIKOSYNAGMA;So;0;L;;;;;N;;;;;\n1D071;BYZANTINE MUSICAL SYMBOL PSIFISTOSYNAGMA;So;0;L;;;;;N;;;;;\n1D072;BYZANTINE MUSICAL SYMBOL GORGOSYNTHETON;So;0;L;;;;;N;;;;;\n1D073;BYZANTINE MUSICAL SYMBOL ARGOSYNTHETON;So;0;L;;;;;N;;;;;\n1D074;BYZANTINE MUSICAL SYMBOL ETERON ARGOSYNTHETON;So;0;L;;;;;N;;;;;\n1D075;BYZANTINE MUSICAL SYMBOL OYRANISMA NEO;So;0;L;;;;;N;;;;;\n1D076;BYZANTINE MUSICAL SYMBOL THEMATISMOS ESO;So;0;L;;;;;N;;;;;\n1D077;BYZANTINE MUSICAL SYMBOL THEMATISMOS EXO;So;0;L;;;;;N;;;;;\n1D078;BYZANTINE MUSICAL SYMBOL THEMA APLOUN;So;0;L;;;;;N;;;;;\n1D079;BYZANTINE MUSICAL SYMBOL THES KAI APOTHES;So;0;L;;;;;N;;;;;\n1D07A;BYZANTINE MUSICAL SYMBOL KATAVASMA;So;0;L;;;;;N;;;;;\n1D07B;BYZANTINE MUSICAL SYMBOL ENDOFONON;So;0;L;;;;;N;;;;;\n1D07C;BYZANTINE MUSICAL SYMBOL YFEN KATO;So;0;L;;;;;N;;;;;\n1D07D;BYZANTINE MUSICAL SYMBOL YFEN ANO;So;0;L;;;;;N;;;;;\n1D07E;BYZANTINE MUSICAL SYMBOL STAVROS;So;0;L;;;;;N;;;;;\n1D07F;BYZANTINE MUSICAL SYMBOL KLASMA ANO;So;0;L;;;;;N;;;;;\n1D080;BYZANTINE MUSICAL SYMBOL DIPLI ARCHAION;So;0;L;;;;;N;;;;;\n1D081;BYZANTINE MUSICAL SYMBOL KRATIMA ARCHAION;So;0;L;;;;;N;;;;;\n1D082;BYZANTINE MUSICAL SYMBOL KRATIMA ALLO;So;0;L;;;;;N;;;;;\n1D083;BYZANTINE MUSICAL SYMBOL KRATIMA NEO;So;0;L;;;;;N;;;;;\n1D084;BYZANTINE MUSICAL SYMBOL APODERMA NEO;So;0;L;;;;;N;;;;;\n1D085;BYZANTINE MUSICAL SYMBOL APLI;So;0;L;;;;;N;;;;;\n1D086;BYZANTINE MUSICAL SYMBOL DIPLI;So;0;L;;;;;N;;;;;\n1D087;BYZANTINE MUSICAL SYMBOL TRIPLI;So;0;L;;;;;N;;;;;\n1D088;BYZANTINE MUSICAL SYMBOL TETRAPLI;So;0;L;;;;;N;;;;;\n1D089;BYZANTINE MUSICAL SYMBOL KORONIS;So;0;L;;;;;N;;;;;\n1D08A;BYZANTINE MUSICAL SYMBOL LEIMMA ENOS CHRONOU;So;0;L;;;;;N;;;;;\n1D08B;BYZANTINE MUSICAL SYMBOL LEIMMA DYO CHRONON;So;0;L;;;;;N;;;;;\n1D08C;BYZANTINE MUSICAL SYMBOL LEIMMA TRION CHRONON;So;0;L;;;;;N;;;;;\n1D08D;BYZANTINE MUSICAL SYMBOL LEIMMA TESSARON CHRONON;So;0;L;;;;;N;;;;;\n1D08E;BYZANTINE MUSICAL SYMBOL LEIMMA IMISEOS CHRONOU;So;0;L;;;;;N;;;;;\n1D08F;BYZANTINE MUSICAL SYMBOL GORGON NEO ANO;So;0;L;;;;;N;;;;;\n1D090;BYZANTINE MUSICAL SYMBOL GORGON PARESTIGMENON ARISTERA;So;0;L;;;;;N;;;;;\n1D091;BYZANTINE MUSICAL SYMBOL GORGON PARESTIGMENON DEXIA;So;0;L;;;;;N;;;;;\n1D092;BYZANTINE MUSICAL SYMBOL DIGORGON;So;0;L;;;;;N;;;;;\n1D093;BYZANTINE MUSICAL SYMBOL DIGORGON PARESTIGMENON ARISTERA KATO;So;0;L;;;;;N;;;;;\n1D094;BYZANTINE MUSICAL SYMBOL DIGORGON PARESTIGMENON ARISTERA ANO;So;0;L;;;;;N;;;;;\n1D095;BYZANTINE MUSICAL SYMBOL DIGORGON PARESTIGMENON DEXIA;So;0;L;;;;;N;;;;;\n1D096;BYZANTINE MUSICAL SYMBOL TRIGORGON;So;0;L;;;;;N;;;;;\n1D097;BYZANTINE MUSICAL SYMBOL ARGON;So;0;L;;;;;N;;;;;\n1D098;BYZANTINE MUSICAL SYMBOL IMIDIARGON;So;0;L;;;;;N;;;;;\n1D099;BYZANTINE MUSICAL SYMBOL DIARGON;So;0;L;;;;;N;;;;;\n1D09A;BYZANTINE MUSICAL SYMBOL AGOGI POLI ARGI;So;0;L;;;;;N;;;;;\n1D09B;BYZANTINE MUSICAL SYMBOL AGOGI ARGOTERI;So;0;L;;;;;N;;;;;\n1D09C;BYZANTINE MUSICAL SYMBOL AGOGI ARGI;So;0;L;;;;;N;;;;;\n1D09D;BYZANTINE MUSICAL SYMBOL AGOGI METRIA;So;0;L;;;;;N;;;;;\n1D09E;BYZANTINE MUSICAL SYMBOL AGOGI MESI;So;0;L;;;;;N;;;;;\n1D09F;BYZANTINE MUSICAL SYMBOL AGOGI GORGI;So;0;L;;;;;N;;;;;\n1D0A0;BYZANTINE MUSICAL SYMBOL AGOGI GORGOTERI;So;0;L;;;;;N;;;;;\n1D0A1;BYZANTINE MUSICAL SYMBOL AGOGI POLI GORGI;So;0;L;;;;;N;;;;;\n1D0A2;BYZANTINE MUSICAL SYMBOL MARTYRIA PROTOS ICHOS;So;0;L;;;;;N;;;;;\n1D0A3;BYZANTINE MUSICAL SYMBOL MARTYRIA ALLI PROTOS ICHOS;So;0;L;;;;;N;;;;;\n1D0A4;BYZANTINE MUSICAL SYMBOL MARTYRIA DEYTEROS ICHOS;So;0;L;;;;;N;;;;;\n1D0A5;BYZANTINE MUSICAL SYMBOL MARTYRIA ALLI DEYTEROS ICHOS;So;0;L;;;;;N;;;;;\n1D0A6;BYZANTINE MUSICAL SYMBOL MARTYRIA TRITOS ICHOS;So;0;L;;;;;N;;;;;\n1D0A7;BYZANTINE MUSICAL SYMBOL MARTYRIA TRIFONIAS;So;0;L;;;;;N;;;;;\n1D0A8;BYZANTINE MUSICAL SYMBOL MARTYRIA TETARTOS ICHOS;So;0;L;;;;;N;;;;;\n1D0A9;BYZANTINE MUSICAL SYMBOL MARTYRIA TETARTOS LEGETOS ICHOS;So;0;L;;;;;N;;;;;\n1D0AA;BYZANTINE MUSICAL SYMBOL MARTYRIA LEGETOS ICHOS;So;0;L;;;;;N;;;;;\n1D0AB;BYZANTINE MUSICAL SYMBOL MARTYRIA PLAGIOS ICHOS;So;0;L;;;;;N;;;;;\n1D0AC;BYZANTINE MUSICAL SYMBOL ISAKIA TELOUS ICHIMATOS;So;0;L;;;;;N;;;;;\n1D0AD;BYZANTINE MUSICAL SYMBOL APOSTROFOI TELOUS ICHIMATOS;So;0;L;;;;;N;;;;;\n1D0AE;BYZANTINE MUSICAL SYMBOL FANEROSIS TETRAFONIAS;So;0;L;;;;;N;;;;;\n1D0AF;BYZANTINE MUSICAL SYMBOL FANEROSIS MONOFONIAS;So;0;L;;;;;N;;;;;\n1D0B0;BYZANTINE MUSICAL SYMBOL FANEROSIS DIFONIAS;So;0;L;;;;;N;;;;;\n1D0B1;BYZANTINE MUSICAL SYMBOL MARTYRIA VARYS ICHOS;So;0;L;;;;;N;;;;;\n1D0B2;BYZANTINE MUSICAL SYMBOL MARTYRIA PROTOVARYS ICHOS;So;0;L;;;;;N;;;;;\n1D0B3;BYZANTINE MUSICAL SYMBOL MARTYRIA PLAGIOS TETARTOS ICHOS;So;0;L;;;;;N;;;;;\n1D0B4;BYZANTINE MUSICAL SYMBOL GORTHMIKON N APLOUN;So;0;L;;;;;N;;;;;\n1D0B5;BYZANTINE MUSICAL SYMBOL GORTHMIKON N DIPLOUN;So;0;L;;;;;N;;;;;\n1D0B6;BYZANTINE MUSICAL SYMBOL ENARXIS KAI FTHORA VOU;So;0;L;;;;;N;;;;;\n1D0B7;BYZANTINE MUSICAL SYMBOL IMIFONON;So;0;L;;;;;N;;;;;\n1D0B8;BYZANTINE MUSICAL SYMBOL IMIFTHORON;So;0;L;;;;;N;;;;;\n1D0B9;BYZANTINE MUSICAL SYMBOL FTHORA ARCHAION DEYTEROU ICHOU;So;0;L;;;;;N;;;;;\n1D0BA;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI PA;So;0;L;;;;;N;;;;;\n1D0BB;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI NANA;So;0;L;;;;;N;;;;;\n1D0BC;BYZANTINE MUSICAL SYMBOL FTHORA NAOS ICHOS;So;0;L;;;;;N;;;;;\n1D0BD;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI DI;So;0;L;;;;;N;;;;;\n1D0BE;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON DIATONON DI;So;0;L;;;;;N;;;;;\n1D0BF;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI KE;So;0;L;;;;;N;;;;;\n1D0C0;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI ZO;So;0;L;;;;;N;;;;;\n1D0C1;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI NI KATO;So;0;L;;;;;N;;;;;\n1D0C2;BYZANTINE MUSICAL SYMBOL FTHORA DIATONIKI NI ANO;So;0;L;;;;;N;;;;;\n1D0C3;BYZANTINE MUSICAL SYMBOL FTHORA MALAKON CHROMA DIFONIAS;So;0;L;;;;;N;;;;;\n1D0C4;BYZANTINE MUSICAL SYMBOL FTHORA MALAKON CHROMA MONOFONIAS;So;0;L;;;;;N;;;;;\n1D0C5;BYZANTINE MUSICAL SYMBOL FHTORA SKLIRON CHROMA VASIS;So;0;L;;;;;N;;;;;\n1D0C6;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA SYNAFI;So;0;L;;;;;N;;;;;\n1D0C7;BYZANTINE MUSICAL SYMBOL FTHORA NENANO;So;0;L;;;;;N;;;;;\n1D0C8;BYZANTINE MUSICAL SYMBOL CHROA ZYGOS;So;0;L;;;;;N;;;;;\n1D0C9;BYZANTINE MUSICAL SYMBOL CHROA KLITON;So;0;L;;;;;N;;;;;\n1D0CA;BYZANTINE MUSICAL SYMBOL CHROA SPATHI;So;0;L;;;;;N;;;;;\n1D0CB;BYZANTINE MUSICAL SYMBOL FTHORA I YFESIS TETARTIMORION;So;0;L;;;;;N;;;;;\n1D0CC;BYZANTINE MUSICAL SYMBOL FTHORA ENARMONIOS ANTIFONIA;So;0;L;;;;;N;;;;;\n1D0CD;BYZANTINE MUSICAL SYMBOL YFESIS TRITIMORION;So;0;L;;;;;N;;;;;\n1D0CE;BYZANTINE MUSICAL SYMBOL DIESIS TRITIMORION;So;0;L;;;;;N;;;;;\n1D0CF;BYZANTINE MUSICAL SYMBOL DIESIS TETARTIMORION;So;0;L;;;;;N;;;;;\n1D0D0;BYZANTINE MUSICAL SYMBOL DIESIS APLI DYO DODEKATA;So;0;L;;;;;N;;;;;\n1D0D1;BYZANTINE MUSICAL SYMBOL DIESIS MONOGRAMMOS TESSERA DODEKATA;So;0;L;;;;;N;;;;;\n1D0D2;BYZANTINE MUSICAL SYMBOL DIESIS DIGRAMMOS EX DODEKATA;So;0;L;;;;;N;;;;;\n1D0D3;BYZANTINE MUSICAL SYMBOL DIESIS TRIGRAMMOS OKTO DODEKATA;So;0;L;;;;;N;;;;;\n1D0D4;BYZANTINE MUSICAL SYMBOL YFESIS APLI DYO DODEKATA;So;0;L;;;;;N;;;;;\n1D0D5;BYZANTINE MUSICAL SYMBOL YFESIS MONOGRAMMOS TESSERA DODEKATA;So;0;L;;;;;N;;;;;\n1D0D6;BYZANTINE MUSICAL SYMBOL YFESIS DIGRAMMOS EX DODEKATA;So;0;L;;;;;N;;;;;\n1D0D7;BYZANTINE MUSICAL SYMBOL YFESIS TRIGRAMMOS OKTO DODEKATA;So;0;L;;;;;N;;;;;\n1D0D8;BYZANTINE MUSICAL SYMBOL GENIKI DIESIS;So;0;L;;;;;N;;;;;\n1D0D9;BYZANTINE MUSICAL SYMBOL GENIKI YFESIS;So;0;L;;;;;N;;;;;\n1D0DA;BYZANTINE MUSICAL SYMBOL DIASTOLI APLI MIKRI;So;0;L;;;;;N;;;;;\n1D0DB;BYZANTINE MUSICAL SYMBOL DIASTOLI APLI MEGALI;So;0;L;;;;;N;;;;;\n1D0DC;BYZANTINE MUSICAL SYMBOL DIASTOLI DIPLI;So;0;L;;;;;N;;;;;\n1D0DD;BYZANTINE MUSICAL SYMBOL DIASTOLI THESEOS;So;0;L;;;;;N;;;;;\n1D0DE;BYZANTINE MUSICAL SYMBOL SIMANSIS THESEOS;So;0;L;;;;;N;;;;;\n1D0DF;BYZANTINE MUSICAL SYMBOL SIMANSIS THESEOS DISIMOU;So;0;L;;;;;N;;;;;\n1D0E0;BYZANTINE MUSICAL SYMBOL SIMANSIS THESEOS TRISIMOU;So;0;L;;;;;N;;;;;\n1D0E1;BYZANTINE MUSICAL SYMBOL SIMANSIS THESEOS TETRASIMOU;So;0;L;;;;;N;;;;;\n1D0E2;BYZANTINE MUSICAL SYMBOL SIMANSIS ARSEOS;So;0;L;;;;;N;;;;;\n1D0E3;BYZANTINE MUSICAL SYMBOL SIMANSIS ARSEOS DISIMOU;So;0;L;;;;;N;;;;;\n1D0E4;BYZANTINE MUSICAL SYMBOL SIMANSIS ARSEOS TRISIMOU;So;0;L;;;;;N;;;;;\n1D0E5;BYZANTINE MUSICAL SYMBOL SIMANSIS ARSEOS TETRASIMOU;So;0;L;;;;;N;;;;;\n1D0E6;BYZANTINE MUSICAL SYMBOL DIGRAMMA GG;So;0;L;;;;;N;;;;;\n1D0E7;BYZANTINE MUSICAL SYMBOL DIFTOGGOS OU;So;0;L;;;;;N;;;;;\n1D0E8;BYZANTINE MUSICAL SYMBOL STIGMA;So;0;L;;;;;N;;;;;\n1D0E9;BYZANTINE MUSICAL SYMBOL ARKTIKO PA;So;0;L;;;;;N;;;;;\n1D0EA;BYZANTINE MUSICAL SYMBOL ARKTIKO VOU;So;0;L;;;;;N;;;;;\n1D0EB;BYZANTINE MUSICAL SYMBOL ARKTIKO GA;So;0;L;;;;;N;;;;;\n1D0EC;BYZANTINE MUSICAL SYMBOL ARKTIKO DI;So;0;L;;;;;N;;;;;\n1D0ED;BYZANTINE MUSICAL SYMBOL ARKTIKO KE;So;0;L;;;;;N;;;;;\n1D0EE;BYZANTINE MUSICAL SYMBOL ARKTIKO ZO;So;0;L;;;;;N;;;;;\n1D0EF;BYZANTINE MUSICAL SYMBOL ARKTIKO NI;So;0;L;;;;;N;;;;;\n1D0F0;BYZANTINE MUSICAL SYMBOL KENTIMATA NEO MESO;So;0;L;;;;;N;;;;;\n1D0F1;BYZANTINE MUSICAL SYMBOL KENTIMA NEO MESO;So;0;L;;;;;N;;;;;\n1D0F2;BYZANTINE MUSICAL SYMBOL KENTIMATA NEO KATO;So;0;L;;;;;N;;;;;\n1D0F3;BYZANTINE MUSICAL SYMBOL KENTIMA NEO KATO;So;0;L;;;;;N;;;;;\n1D0F4;BYZANTINE MUSICAL SYMBOL KLASMA KATO;So;0;L;;;;;N;;;;;\n1D0F5;BYZANTINE MUSICAL SYMBOL GORGON NEO KATO;So;0;L;;;;;N;;;;;\n1D100;MUSICAL SYMBOL SINGLE BARLINE;So;0;L;;;;;N;;;;;\n1D101;MUSICAL SYMBOL DOUBLE BARLINE;So;0;L;;;;;N;;;;;\n1D102;MUSICAL SYMBOL FINAL BARLINE;So;0;L;;;;;N;;;;;\n1D103;MUSICAL SYMBOL REVERSE FINAL BARLINE;So;0;L;;;;;N;;;;;\n1D104;MUSICAL SYMBOL DASHED BARLINE;So;0;L;;;;;N;;;;;\n1D105;MUSICAL SYMBOL SHORT BARLINE;So;0;L;;;;;N;;;;;\n1D106;MUSICAL SYMBOL LEFT REPEAT SIGN;So;0;L;;;;;N;;;;;\n1D107;MUSICAL SYMBOL RIGHT REPEAT SIGN;So;0;L;;;;;N;;;;;\n1D108;MUSICAL SYMBOL REPEAT DOTS;So;0;L;;;;;N;;;;;\n1D109;MUSICAL SYMBOL DAL SEGNO;So;0;L;;;;;N;;;;;\n1D10A;MUSICAL SYMBOL DA CAPO;So;0;L;;;;;N;;;;;\n1D10B;MUSICAL SYMBOL SEGNO;So;0;L;;;;;N;;;;;\n1D10C;MUSICAL SYMBOL CODA;So;0;L;;;;;N;;;;;\n1D10D;MUSICAL SYMBOL REPEATED FIGURE-1;So;0;L;;;;;N;;;;;\n1D10E;MUSICAL SYMBOL REPEATED FIGURE-2;So;0;L;;;;;N;;;;;\n1D10F;MUSICAL SYMBOL REPEATED FIGURE-3;So;0;L;;;;;N;;;;;\n1D110;MUSICAL SYMBOL FERMATA;So;0;L;;;;;N;;;;;\n1D111;MUSICAL SYMBOL FERMATA BELOW;So;0;L;;;;;N;;;;;\n1D112;MUSICAL SYMBOL BREATH MARK;So;0;L;;;;;N;;;;;\n1D113;MUSICAL SYMBOL CAESURA;So;0;L;;;;;N;;;;;\n1D114;MUSICAL SYMBOL BRACE;So;0;L;;;;;N;;;;;\n1D115;MUSICAL SYMBOL BRACKET;So;0;L;;;;;N;;;;;\n1D116;MUSICAL SYMBOL ONE-LINE STAFF;So;0;L;;;;;N;;;;;\n1D117;MUSICAL SYMBOL TWO-LINE STAFF;So;0;L;;;;;N;;;;;\n1D118;MUSICAL SYMBOL THREE-LINE STAFF;So;0;L;;;;;N;;;;;\n1D119;MUSICAL SYMBOL FOUR-LINE STAFF;So;0;L;;;;;N;;;;;\n1D11A;MUSICAL SYMBOL FIVE-LINE STAFF;So;0;L;;;;;N;;;;;\n1D11B;MUSICAL SYMBOL SIX-LINE STAFF;So;0;L;;;;;N;;;;;\n1D11C;MUSICAL SYMBOL SIX-STRING FRETBOARD;So;0;L;;;;;N;;;;;\n1D11D;MUSICAL SYMBOL FOUR-STRING FRETBOARD;So;0;L;;;;;N;;;;;\n1D11E;MUSICAL SYMBOL G CLEF;So;0;L;;;;;N;;;;;\n1D11F;MUSICAL SYMBOL G CLEF OTTAVA ALTA;So;0;L;;;;;N;;;;;\n1D120;MUSICAL SYMBOL G CLEF OTTAVA BASSA;So;0;L;;;;;N;;;;;\n1D121;MUSICAL SYMBOL C CLEF;So;0;L;;;;;N;;;;;\n1D122;MUSICAL SYMBOL F CLEF;So;0;L;;;;;N;;;;;\n1D123;MUSICAL SYMBOL F CLEF OTTAVA ALTA;So;0;L;;;;;N;;;;;\n1D124;MUSICAL SYMBOL F CLEF OTTAVA BASSA;So;0;L;;;;;N;;;;;\n1D125;MUSICAL SYMBOL DRUM CLEF-1;So;0;L;;;;;N;;;;;\n1D126;MUSICAL SYMBOL DRUM CLEF-2;So;0;L;;;;;N;;;;;\n1D129;MUSICAL SYMBOL MULTIPLE MEASURE REST;So;0;L;;;;;N;;;;;\n1D12A;MUSICAL SYMBOL DOUBLE SHARP;So;0;L;;;;;N;;;;;\n1D12B;MUSICAL SYMBOL DOUBLE FLAT;So;0;L;;;;;N;;;;;\n1D12C;MUSICAL SYMBOL FLAT UP;So;0;L;;;;;N;;;;;\n1D12D;MUSICAL SYMBOL FLAT DOWN;So;0;L;;;;;N;;;;;\n1D12E;MUSICAL SYMBOL NATURAL UP;So;0;L;;;;;N;;;;;\n1D12F;MUSICAL SYMBOL NATURAL DOWN;So;0;L;;;;;N;;;;;\n1D130;MUSICAL SYMBOL SHARP UP;So;0;L;;;;;N;;;;;\n1D131;MUSICAL SYMBOL SHARP DOWN;So;0;L;;;;;N;;;;;\n1D132;MUSICAL SYMBOL QUARTER TONE SHARP;So;0;L;;;;;N;;;;;\n1D133;MUSICAL SYMBOL QUARTER TONE FLAT;So;0;L;;;;;N;;;;;\n1D134;MUSICAL SYMBOL COMMON TIME;So;0;L;;;;;N;;;;;\n1D135;MUSICAL SYMBOL CUT TIME;So;0;L;;;;;N;;;;;\n1D136;MUSICAL SYMBOL OTTAVA ALTA;So;0;L;;;;;N;;;;;\n1D137;MUSICAL SYMBOL OTTAVA BASSA;So;0;L;;;;;N;;;;;\n1D138;MUSICAL SYMBOL QUINDICESIMA ALTA;So;0;L;;;;;N;;;;;\n1D139;MUSICAL SYMBOL QUINDICESIMA BASSA;So;0;L;;;;;N;;;;;\n1D13A;MUSICAL SYMBOL MULTI REST;So;0;L;;;;;N;;;;;\n1D13B;MUSICAL SYMBOL WHOLE REST;So;0;L;;;;;N;;;;;\n1D13C;MUSICAL SYMBOL HALF REST;So;0;L;;;;;N;;;;;\n1D13D;MUSICAL SYMBOL QUARTER REST;So;0;L;;;;;N;;;;;\n1D13E;MUSICAL SYMBOL EIGHTH REST;So;0;L;;;;;N;;;;;\n1D13F;MUSICAL SYMBOL SIXTEENTH REST;So;0;L;;;;;N;;;;;\n1D140;MUSICAL SYMBOL THIRTY-SECOND REST;So;0;L;;;;;N;;;;;\n1D141;MUSICAL SYMBOL SIXTY-FOURTH REST;So;0;L;;;;;N;;;;;\n1D142;MUSICAL SYMBOL ONE HUNDRED TWENTY-EIGHTH REST;So;0;L;;;;;N;;;;;\n1D143;MUSICAL SYMBOL X NOTEHEAD;So;0;L;;;;;N;;;;;\n1D144;MUSICAL SYMBOL PLUS NOTEHEAD;So;0;L;;;;;N;;;;;\n1D145;MUSICAL SYMBOL CIRCLE X NOTEHEAD;So;0;L;;;;;N;;;;;\n1D146;MUSICAL SYMBOL SQUARE NOTEHEAD WHITE;So;0;L;;;;;N;;;;;\n1D147;MUSICAL SYMBOL SQUARE NOTEHEAD BLACK;So;0;L;;;;;N;;;;;\n1D148;MUSICAL SYMBOL TRIANGLE NOTEHEAD UP WHITE;So;0;L;;;;;N;;;;;\n1D149;MUSICAL SYMBOL TRIANGLE NOTEHEAD UP BLACK;So;0;L;;;;;N;;;;;\n1D14A;MUSICAL SYMBOL TRIANGLE NOTEHEAD LEFT WHITE;So;0;L;;;;;N;;;;;\n1D14B;MUSICAL SYMBOL TRIANGLE NOTEHEAD LEFT BLACK;So;0;L;;;;;N;;;;;\n1D14C;MUSICAL SYMBOL TRIANGLE NOTEHEAD RIGHT WHITE;So;0;L;;;;;N;;;;;\n1D14D;MUSICAL SYMBOL TRIANGLE NOTEHEAD RIGHT BLACK;So;0;L;;;;;N;;;;;\n1D14E;MUSICAL SYMBOL TRIANGLE NOTEHEAD DOWN WHITE;So;0;L;;;;;N;;;;;\n1D14F;MUSICAL SYMBOL TRIANGLE NOTEHEAD DOWN BLACK;So;0;L;;;;;N;;;;;\n1D150;MUSICAL SYMBOL TRIANGLE NOTEHEAD UP RIGHT WHITE;So;0;L;;;;;N;;;;;\n1D151;MUSICAL SYMBOL TRIANGLE NOTEHEAD UP RIGHT BLACK;So;0;L;;;;;N;;;;;\n1D152;MUSICAL SYMBOL MOON NOTEHEAD WHITE;So;0;L;;;;;N;;;;;\n1D153;MUSICAL SYMBOL MOON NOTEHEAD BLACK;So;0;L;;;;;N;;;;;\n1D154;MUSICAL SYMBOL TRIANGLE-ROUND NOTEHEAD DOWN WHITE;So;0;L;;;;;N;;;;;\n1D155;MUSICAL SYMBOL TRIANGLE-ROUND NOTEHEAD DOWN BLACK;So;0;L;;;;;N;;;;;\n1D156;MUSICAL SYMBOL PARENTHESIS NOTEHEAD;So;0;L;;;;;N;;;;;\n1D157;MUSICAL SYMBOL VOID NOTEHEAD;So;0;L;;;;;N;;;;;\n1D158;MUSICAL SYMBOL NOTEHEAD BLACK;So;0;L;;;;;N;;;;;\n1D159;MUSICAL SYMBOL NULL NOTEHEAD;So;0;L;;;;;N;;;;;\n1D15A;MUSICAL SYMBOL CLUSTER NOTEHEAD WHITE;So;0;L;;;;;N;;;;;\n1D15B;MUSICAL SYMBOL CLUSTER NOTEHEAD BLACK;So;0;L;;;;;N;;;;;\n1D15C;MUSICAL SYMBOL BREVE;So;0;L;;;;;N;;;;;\n1D15D;MUSICAL SYMBOL WHOLE NOTE;So;0;L;;;;;N;;;;;\n1D15E;MUSICAL SYMBOL HALF NOTE;So;0;L;1D157 1D165;;;;N;;;;;\n1D15F;MUSICAL SYMBOL QUARTER NOTE;So;0;L;1D158 1D165;;;;N;;;;;\n1D160;MUSICAL SYMBOL EIGHTH NOTE;So;0;L;1D15F 1D16E;;;;N;;;;;\n1D161;MUSICAL SYMBOL SIXTEENTH NOTE;So;0;L;1D15F 1D16F;;;;N;;;;;\n1D162;MUSICAL SYMBOL THIRTY-SECOND NOTE;So;0;L;1D15F 1D170;;;;N;;;;;\n1D163;MUSICAL SYMBOL SIXTY-FOURTH NOTE;So;0;L;1D15F 1D171;;;;N;;;;;\n1D164;MUSICAL SYMBOL ONE HUNDRED TWENTY-EIGHTH NOTE;So;0;L;1D15F 1D172;;;;N;;;;;\n1D165;MUSICAL SYMBOL COMBINING STEM;Mc;216;L;;;;;N;;;;;\n1D166;MUSICAL SYMBOL COMBINING SPRECHGESANG STEM;Mc;216;L;;;;;N;;;;;\n1D167;MUSICAL SYMBOL COMBINING TREMOLO-1;Mn;1;NSM;;;;;N;;;;;\n1D168;MUSICAL SYMBOL COMBINING TREMOLO-2;Mn;1;NSM;;;;;N;;;;;\n1D169;MUSICAL SYMBOL COMBINING TREMOLO-3;Mn;1;NSM;;;;;N;;;;;\n1D16A;MUSICAL SYMBOL FINGERED TREMOLO-1;So;0;L;;;;;N;;;;;\n1D16B;MUSICAL SYMBOL FINGERED TREMOLO-2;So;0;L;;;;;N;;;;;\n1D16C;MUSICAL SYMBOL FINGERED TREMOLO-3;So;0;L;;;;;N;;;;;\n1D16D;MUSICAL SYMBOL COMBINING AUGMENTATION DOT;Mc;226;L;;;;;N;;;;;\n1D16E;MUSICAL SYMBOL COMBINING FLAG-1;Mc;216;L;;;;;N;;;;;\n1D16F;MUSICAL SYMBOL COMBINING FLAG-2;Mc;216;L;;;;;N;;;;;\n1D170;MUSICAL SYMBOL COMBINING FLAG-3;Mc;216;L;;;;;N;;;;;\n1D171;MUSICAL SYMBOL COMBINING FLAG-4;Mc;216;L;;;;;N;;;;;\n1D172;MUSICAL SYMBOL COMBINING FLAG-5;Mc;216;L;;;;;N;;;;;\n1D173;MUSICAL SYMBOL BEGIN BEAM;Cf;0;BN;;;;;N;;;;;\n1D174;MUSICAL SYMBOL END BEAM;Cf;0;BN;;;;;N;;;;;\n1D175;MUSICAL SYMBOL BEGIN TIE;Cf;0;BN;;;;;N;;;;;\n1D176;MUSICAL SYMBOL END TIE;Cf;0;BN;;;;;N;;;;;\n1D177;MUSICAL SYMBOL BEGIN SLUR;Cf;0;BN;;;;;N;;;;;\n1D178;MUSICAL SYMBOL END SLUR;Cf;0;BN;;;;;N;;;;;\n1D179;MUSICAL SYMBOL BEGIN PHRASE;Cf;0;BN;;;;;N;;;;;\n1D17A;MUSICAL SYMBOL END PHRASE;Cf;0;BN;;;;;N;;;;;\n1D17B;MUSICAL SYMBOL COMBINING ACCENT;Mn;220;NSM;;;;;N;;;;;\n1D17C;MUSICAL SYMBOL COMBINING STACCATO;Mn;220;NSM;;;;;N;;;;;\n1D17D;MUSICAL SYMBOL COMBINING TENUTO;Mn;220;NSM;;;;;N;;;;;\n1D17E;MUSICAL SYMBOL COMBINING STACCATISSIMO;Mn;220;NSM;;;;;N;;;;;\n1D17F;MUSICAL SYMBOL COMBINING MARCATO;Mn;220;NSM;;;;;N;;;;;\n1D180;MUSICAL SYMBOL COMBINING MARCATO-STACCATO;Mn;220;NSM;;;;;N;;;;;\n1D181;MUSICAL SYMBOL COMBINING ACCENT-STACCATO;Mn;220;NSM;;;;;N;;;;;\n1D182;MUSICAL SYMBOL COMBINING LOURE;Mn;220;NSM;;;;;N;;;;;\n1D183;MUSICAL SYMBOL ARPEGGIATO UP;So;0;L;;;;;N;;;;;\n1D184;MUSICAL SYMBOL ARPEGGIATO DOWN;So;0;L;;;;;N;;;;;\n1D185;MUSICAL SYMBOL COMBINING DOIT;Mn;230;NSM;;;;;N;;;;;\n1D186;MUSICAL SYMBOL COMBINING RIP;Mn;230;NSM;;;;;N;;;;;\n1D187;MUSICAL SYMBOL COMBINING FLIP;Mn;230;NSM;;;;;N;;;;;\n1D188;MUSICAL SYMBOL COMBINING SMEAR;Mn;230;NSM;;;;;N;;;;;\n1D189;MUSICAL SYMBOL COMBINING BEND;Mn;230;NSM;;;;;N;;;;;\n1D18A;MUSICAL SYMBOL COMBINING DOUBLE TONGUE;Mn;220;NSM;;;;;N;;;;;\n1D18B;MUSICAL SYMBOL COMBINING TRIPLE TONGUE;Mn;220;NSM;;;;;N;;;;;\n1D18C;MUSICAL SYMBOL RINFORZANDO;So;0;L;;;;;N;;;;;\n1D18D;MUSICAL SYMBOL SUBITO;So;0;L;;;;;N;;;;;\n1D18E;MUSICAL SYMBOL Z;So;0;L;;;;;N;;;;;\n1D18F;MUSICAL SYMBOL PIANO;So;0;L;;;;;N;;;;;\n1D190;MUSICAL SYMBOL MEZZO;So;0;L;;;;;N;;;;;\n1D191;MUSICAL SYMBOL FORTE;So;0;L;;;;;N;;;;;\n1D192;MUSICAL SYMBOL CRESCENDO;So;0;L;;;;;N;;;;;\n1D193;MUSICAL SYMBOL DECRESCENDO;So;0;L;;;;;N;;;;;\n1D194;MUSICAL SYMBOL GRACE NOTE SLASH;So;0;L;;;;;N;;;;;\n1D195;MUSICAL SYMBOL GRACE NOTE NO SLASH;So;0;L;;;;;N;;;;;\n1D196;MUSICAL SYMBOL TR;So;0;L;;;;;N;;;;;\n1D197;MUSICAL SYMBOL TURN;So;0;L;;;;;N;;;;;\n1D198;MUSICAL SYMBOL INVERTED TURN;So;0;L;;;;;N;;;;;\n1D199;MUSICAL SYMBOL TURN SLASH;So;0;L;;;;;N;;;;;\n1D19A;MUSICAL SYMBOL TURN UP;So;0;L;;;;;N;;;;;\n1D19B;MUSICAL SYMBOL ORNAMENT STROKE-1;So;0;L;;;;;N;;;;;\n1D19C;MUSICAL SYMBOL ORNAMENT STROKE-2;So;0;L;;;;;N;;;;;\n1D19D;MUSICAL SYMBOL ORNAMENT STROKE-3;So;0;L;;;;;N;;;;;\n1D19E;MUSICAL SYMBOL ORNAMENT STROKE-4;So;0;L;;;;;N;;;;;\n1D19F;MUSICAL SYMBOL ORNAMENT STROKE-5;So;0;L;;;;;N;;;;;\n1D1A0;MUSICAL SYMBOL ORNAMENT STROKE-6;So;0;L;;;;;N;;;;;\n1D1A1;MUSICAL SYMBOL ORNAMENT STROKE-7;So;0;L;;;;;N;;;;;\n1D1A2;MUSICAL SYMBOL ORNAMENT STROKE-8;So;0;L;;;;;N;;;;;\n1D1A3;MUSICAL SYMBOL ORNAMENT STROKE-9;So;0;L;;;;;N;;;;;\n1D1A4;MUSICAL SYMBOL ORNAMENT STROKE-10;So;0;L;;;;;N;;;;;\n1D1A5;MUSICAL SYMBOL ORNAMENT STROKE-11;So;0;L;;;;;N;;;;;\n1D1A6;MUSICAL SYMBOL HAUPTSTIMME;So;0;L;;;;;N;;;;;\n1D1A7;MUSICAL SYMBOL NEBENSTIMME;So;0;L;;;;;N;;;;;\n1D1A8;MUSICAL SYMBOL END OF STIMME;So;0;L;;;;;N;;;;;\n1D1A9;MUSICAL SYMBOL DEGREE SLASH;So;0;L;;;;;N;;;;;\n1D1AA;MUSICAL SYMBOL COMBINING DOWN BOW;Mn;230;NSM;;;;;N;;;;;\n1D1AB;MUSICAL SYMBOL COMBINING UP BOW;Mn;230;NSM;;;;;N;;;;;\n1D1AC;MUSICAL SYMBOL COMBINING HARMONIC;Mn;230;NSM;;;;;N;;;;;\n1D1AD;MUSICAL SYMBOL COMBINING SNAP PIZZICATO;Mn;230;NSM;;;;;N;;;;;\n1D1AE;MUSICAL SYMBOL PEDAL MARK;So;0;L;;;;;N;;;;;\n1D1AF;MUSICAL SYMBOL PEDAL UP MARK;So;0;L;;;;;N;;;;;\n1D1B0;MUSICAL SYMBOL HALF PEDAL MARK;So;0;L;;;;;N;;;;;\n1D1B1;MUSICAL SYMBOL GLISSANDO UP;So;0;L;;;;;N;;;;;\n1D1B2;MUSICAL SYMBOL GLISSANDO DOWN;So;0;L;;;;;N;;;;;\n1D1B3;MUSICAL SYMBOL WITH FINGERNAILS;So;0;L;;;;;N;;;;;\n1D1B4;MUSICAL SYMBOL DAMP;So;0;L;;;;;N;;;;;\n1D1B5;MUSICAL SYMBOL DAMP ALL;So;0;L;;;;;N;;;;;\n1D1B6;MUSICAL SYMBOL MAXIMA;So;0;L;;;;;N;;;;;\n1D1B7;MUSICAL SYMBOL LONGA;So;0;L;;;;;N;;;;;\n1D1B8;MUSICAL SYMBOL BREVIS;So;0;L;;;;;N;;;;;\n1D1B9;MUSICAL SYMBOL SEMIBREVIS WHITE;So;0;L;;;;;N;;;;;\n1D1BA;MUSICAL SYMBOL SEMIBREVIS BLACK;So;0;L;;;;;N;;;;;\n1D1BB;MUSICAL SYMBOL MINIMA;So;0;L;1D1B9 1D165;;;;N;;;;;\n1D1BC;MUSICAL SYMBOL MINIMA BLACK;So;0;L;1D1BA 1D165;;;;N;;;;;\n1D1BD;MUSICAL SYMBOL SEMIMINIMA WHITE;So;0;L;1D1BB 1D16E;;;;N;;;;;\n1D1BE;MUSICAL SYMBOL SEMIMINIMA BLACK;So;0;L;1D1BC 1D16E;;;;N;;;;;\n1D1BF;MUSICAL SYMBOL FUSA WHITE;So;0;L;1D1BB 1D16F;;;;N;;;;;\n1D1C0;MUSICAL SYMBOL FUSA BLACK;So;0;L;1D1BC 1D16F;;;;N;;;;;\n1D1C1;MUSICAL SYMBOL LONGA PERFECTA REST;So;0;L;;;;;N;;;;;\n1D1C2;MUSICAL SYMBOL LONGA IMPERFECTA REST;So;0;L;;;;;N;;;;;\n1D1C3;MUSICAL SYMBOL BREVIS REST;So;0;L;;;;;N;;;;;\n1D1C4;MUSICAL SYMBOL SEMIBREVIS REST;So;0;L;;;;;N;;;;;\n1D1C5;MUSICAL SYMBOL MINIMA REST;So;0;L;;;;;N;;;;;\n1D1C6;MUSICAL SYMBOL SEMIMINIMA REST;So;0;L;;;;;N;;;;;\n1D1C7;MUSICAL SYMBOL TEMPUS PERFECTUM CUM PROLATIONE PERFECTA;So;0;L;;;;;N;;;;;\n1D1C8;MUSICAL SYMBOL TEMPUS PERFECTUM CUM PROLATIONE IMPERFECTA;So;0;L;;;;;N;;;;;\n1D1C9;MUSICAL SYMBOL TEMPUS PERFECTUM CUM PROLATIONE PERFECTA DIMINUTION-1;So;0;L;;;;;N;;;;;\n1D1CA;MUSICAL SYMBOL TEMPUS IMPERFECTUM CUM PROLATIONE PERFECTA;So;0;L;;;;;N;;;;;\n1D1CB;MUSICAL SYMBOL TEMPUS IMPERFECTUM CUM PROLATIONE IMPERFECTA;So;0;L;;;;;N;;;;;\n1D1CC;MUSICAL SYMBOL TEMPUS IMPERFECTUM CUM PROLATIONE IMPERFECTA DIMINUTION-1;So;0;L;;;;;N;;;;;\n1D1CD;MUSICAL SYMBOL TEMPUS IMPERFECTUM CUM PROLATIONE IMPERFECTA DIMINUTION-2;So;0;L;;;;;N;;;;;\n1D1CE;MUSICAL SYMBOL TEMPUS IMPERFECTUM CUM PROLATIONE IMPERFECTA DIMINUTION-3;So;0;L;;;;;N;;;;;\n1D1CF;MUSICAL SYMBOL CROIX;So;0;L;;;;;N;;;;;\n1D1D0;MUSICAL SYMBOL GREGORIAN C CLEF;So;0;L;;;;;N;;;;;\n1D1D1;MUSICAL SYMBOL GREGORIAN F CLEF;So;0;L;;;;;N;;;;;\n1D1D2;MUSICAL SYMBOL SQUARE B;So;0;L;;;;;N;;;;;\n1D1D3;MUSICAL SYMBOL VIRGA;So;0;L;;;;;N;;;;;\n1D1D4;MUSICAL SYMBOL PODATUS;So;0;L;;;;;N;;;;;\n1D1D5;MUSICAL SYMBOL CLIVIS;So;0;L;;;;;N;;;;;\n1D1D6;MUSICAL SYMBOL SCANDICUS;So;0;L;;;;;N;;;;;\n1D1D7;MUSICAL SYMBOL CLIMACUS;So;0;L;;;;;N;;;;;\n1D1D8;MUSICAL SYMBOL TORCULUS;So;0;L;;;;;N;;;;;\n1D1D9;MUSICAL SYMBOL PORRECTUS;So;0;L;;;;;N;;;;;\n1D1DA;MUSICAL SYMBOL PORRECTUS FLEXUS;So;0;L;;;;;N;;;;;\n1D1DB;MUSICAL SYMBOL SCANDICUS FLEXUS;So;0;L;;;;;N;;;;;\n1D1DC;MUSICAL SYMBOL TORCULUS RESUPINUS;So;0;L;;;;;N;;;;;\n1D1DD;MUSICAL SYMBOL PES SUBPUNCTIS;So;0;L;;;;;N;;;;;\n1D200;GREEK VOCAL NOTATION SYMBOL-1;So;0;ON;;;;;N;;;;;\n1D201;GREEK VOCAL NOTATION SYMBOL-2;So;0;ON;;;;;N;;;;;\n1D202;GREEK VOCAL NOTATION SYMBOL-3;So;0;ON;;;;;N;;;;;\n1D203;GREEK VOCAL NOTATION SYMBOL-4;So;0;ON;;;;;N;;;;;\n1D204;GREEK VOCAL NOTATION SYMBOL-5;So;0;ON;;;;;N;;;;;\n1D205;GREEK VOCAL NOTATION SYMBOL-6;So;0;ON;;;;;N;;;;;\n1D206;GREEK VOCAL NOTATION SYMBOL-7;So;0;ON;;;;;N;;;;;\n1D207;GREEK VOCAL NOTATION SYMBOL-8;So;0;ON;;;;;N;;;;;\n1D208;GREEK VOCAL NOTATION SYMBOL-9;So;0;ON;;;;;N;;;;;\n1D209;GREEK VOCAL NOTATION SYMBOL-10;So;0;ON;;;;;N;;;;;\n1D20A;GREEK VOCAL NOTATION SYMBOL-11;So;0;ON;;;;;N;;;;;\n1D20B;GREEK VOCAL NOTATION SYMBOL-12;So;0;ON;;;;;N;;;;;\n1D20C;GREEK VOCAL NOTATION SYMBOL-13;So;0;ON;;;;;N;;;;;\n1D20D;GREEK VOCAL NOTATION SYMBOL-14;So;0;ON;;;;;N;;;;;\n1D20E;GREEK VOCAL NOTATION SYMBOL-15;So;0;ON;;;;;N;;;;;\n1D20F;GREEK VOCAL NOTATION SYMBOL-16;So;0;ON;;;;;N;;;;;\n1D210;GREEK VOCAL NOTATION SYMBOL-17;So;0;ON;;;;;N;;;;;\n1D211;GREEK VOCAL NOTATION SYMBOL-18;So;0;ON;;;;;N;;;;;\n1D212;GREEK VOCAL NOTATION SYMBOL-19;So;0;ON;;;;;N;;;;;\n1D213;GREEK VOCAL NOTATION SYMBOL-20;So;0;ON;;;;;N;;;;;\n1D214;GREEK VOCAL NOTATION SYMBOL-21;So;0;ON;;;;;N;;;;;\n1D215;GREEK VOCAL NOTATION SYMBOL-22;So;0;ON;;;;;N;;;;;\n1D216;GREEK VOCAL NOTATION SYMBOL-23;So;0;ON;;;;;N;;;;;\n1D217;GREEK VOCAL NOTATION SYMBOL-24;So;0;ON;;;;;N;;;;;\n1D218;GREEK VOCAL NOTATION SYMBOL-50;So;0;ON;;;;;N;;;;;\n1D219;GREEK VOCAL NOTATION SYMBOL-51;So;0;ON;;;;;N;;;;;\n1D21A;GREEK VOCAL NOTATION SYMBOL-52;So;0;ON;;;;;N;;;;;\n1D21B;GREEK VOCAL NOTATION SYMBOL-53;So;0;ON;;;;;N;;;;;\n1D21C;GREEK VOCAL NOTATION SYMBOL-54;So;0;ON;;;;;N;;;;;\n1D21D;GREEK INSTRUMENTAL NOTATION SYMBOL-1;So;0;ON;;;;;N;;;;;\n1D21E;GREEK INSTRUMENTAL NOTATION SYMBOL-2;So;0;ON;;;;;N;;;;;\n1D21F;GREEK INSTRUMENTAL NOTATION SYMBOL-4;So;0;ON;;;;;N;;;;;\n1D220;GREEK INSTRUMENTAL NOTATION SYMBOL-5;So;0;ON;;;;;N;;;;;\n1D221;GREEK INSTRUMENTAL NOTATION SYMBOL-7;So;0;ON;;;;;N;;;;;\n1D222;GREEK INSTRUMENTAL NOTATION SYMBOL-8;So;0;ON;;;;;N;;;;;\n1D223;GREEK INSTRUMENTAL NOTATION SYMBOL-11;So;0;ON;;;;;N;;;;;\n1D224;GREEK INSTRUMENTAL NOTATION SYMBOL-12;So;0;ON;;;;;N;;;;;\n1D225;GREEK INSTRUMENTAL NOTATION SYMBOL-13;So;0;ON;;;;;N;;;;;\n1D226;GREEK INSTRUMENTAL NOTATION SYMBOL-14;So;0;ON;;;;;N;;;;;\n1D227;GREEK INSTRUMENTAL NOTATION SYMBOL-17;So;0;ON;;;;;N;;;;;\n1D228;GREEK INSTRUMENTAL NOTATION SYMBOL-18;So;0;ON;;;;;N;;;;;\n1D229;GREEK INSTRUMENTAL NOTATION SYMBOL-19;So;0;ON;;;;;N;;;;;\n1D22A;GREEK INSTRUMENTAL NOTATION SYMBOL-23;So;0;ON;;;;;N;;;;;\n1D22B;GREEK INSTRUMENTAL NOTATION SYMBOL-24;So;0;ON;;;;;N;;;;;\n1D22C;GREEK INSTRUMENTAL NOTATION SYMBOL-25;So;0;ON;;;;;N;;;;;\n1D22D;GREEK INSTRUMENTAL NOTATION SYMBOL-26;So;0;ON;;;;;N;;;;;\n1D22E;GREEK INSTRUMENTAL NOTATION SYMBOL-27;So;0;ON;;;;;N;;;;;\n1D22F;GREEK INSTRUMENTAL NOTATION SYMBOL-29;So;0;ON;;;;;N;;;;;\n1D230;GREEK INSTRUMENTAL NOTATION SYMBOL-30;So;0;ON;;;;;N;;;;;\n1D231;GREEK INSTRUMENTAL NOTATION SYMBOL-32;So;0;ON;;;;;N;;;;;\n1D232;GREEK INSTRUMENTAL NOTATION SYMBOL-36;So;0;ON;;;;;N;;;;;\n1D233;GREEK INSTRUMENTAL NOTATION SYMBOL-37;So;0;ON;;;;;N;;;;;\n1D234;GREEK INSTRUMENTAL NOTATION SYMBOL-38;So;0;ON;;;;;N;;;;;\n1D235;GREEK INSTRUMENTAL NOTATION SYMBOL-39;So;0;ON;;;;;N;;;;;\n1D236;GREEK INSTRUMENTAL NOTATION SYMBOL-40;So;0;ON;;;;;N;;;;;\n1D237;GREEK INSTRUMENTAL NOTATION SYMBOL-42;So;0;ON;;;;;N;;;;;\n1D238;GREEK INSTRUMENTAL NOTATION SYMBOL-43;So;0;ON;;;;;N;;;;;\n1D239;GREEK INSTRUMENTAL NOTATION SYMBOL-45;So;0;ON;;;;;N;;;;;\n1D23A;GREEK INSTRUMENTAL NOTATION SYMBOL-47;So;0;ON;;;;;N;;;;;\n1D23B;GREEK INSTRUMENTAL NOTATION SYMBOL-48;So;0;ON;;;;;N;;;;;\n1D23C;GREEK INSTRUMENTAL NOTATION SYMBOL-49;So;0;ON;;;;;N;;;;;\n1D23D;GREEK INSTRUMENTAL NOTATION SYMBOL-50;So;0;ON;;;;;N;;;;;\n1D23E;GREEK INSTRUMENTAL NOTATION SYMBOL-51;So;0;ON;;;;;N;;;;;\n1D23F;GREEK INSTRUMENTAL NOTATION SYMBOL-52;So;0;ON;;;;;N;;;;;\n1D240;GREEK INSTRUMENTAL NOTATION SYMBOL-53;So;0;ON;;;;;N;;;;;\n1D241;GREEK INSTRUMENTAL NOTATION SYMBOL-54;So;0;ON;;;;;N;;;;;\n1D242;COMBINING GREEK MUSICAL TRISEME;Mn;230;NSM;;;;;N;;;;;\n1D243;COMBINING GREEK MUSICAL TETRASEME;Mn;230;NSM;;;;;N;;;;;\n1D244;COMBINING GREEK MUSICAL PENTASEME;Mn;230;NSM;;;;;N;;;;;\n1D245;GREEK MUSICAL LEIMMA;So;0;ON;;;;;N;;;;;\n1D300;MONOGRAM FOR EARTH;So;0;ON;;;;;N;;;;;\n1D301;DIGRAM FOR HEAVENLY EARTH;So;0;ON;;;;;N;;;;;\n1D302;DIGRAM FOR HUMAN EARTH;So;0;ON;;;;;N;;;;;\n1D303;DIGRAM FOR EARTHLY HEAVEN;So;0;ON;;;;;N;;;;;\n1D304;DIGRAM FOR EARTHLY HUMAN;So;0;ON;;;;;N;;;;;\n1D305;DIGRAM FOR EARTH;So;0;ON;;;;;N;;;;;\n1D306;TETRAGRAM FOR CENTRE;So;0;ON;;;;;N;;;;;\n1D307;TETRAGRAM FOR FULL CIRCLE;So;0;ON;;;;;N;;;;;\n1D308;TETRAGRAM FOR MIRED;So;0;ON;;;;;N;;;;;\n1D309;TETRAGRAM FOR BARRIER;So;0;ON;;;;;N;;;;;\n1D30A;TETRAGRAM FOR KEEPING SMALL;So;0;ON;;;;;N;;;;;\n1D30B;TETRAGRAM FOR CONTRARIETY;So;0;ON;;;;;N;;;;;\n1D30C;TETRAGRAM FOR ASCENT;So;0;ON;;;;;N;;;;;\n1D30D;TETRAGRAM FOR OPPOSITION;So;0;ON;;;;;N;;;;;\n1D30E;TETRAGRAM FOR BRANCHING OUT;So;0;ON;;;;;N;;;;;\n1D30F;TETRAGRAM FOR DEFECTIVENESS OR DISTORTION;So;0;ON;;;;;N;;;;;\n1D310;TETRAGRAM FOR DIVERGENCE;So;0;ON;;;;;N;;;;;\n1D311;TETRAGRAM FOR YOUTHFULNESS;So;0;ON;;;;;N;;;;;\n1D312;TETRAGRAM FOR INCREASE;So;0;ON;;;;;N;;;;;\n1D313;TETRAGRAM FOR PENETRATION;So;0;ON;;;;;N;;;;;\n1D314;TETRAGRAM FOR REACH;So;0;ON;;;;;N;;;;;\n1D315;TETRAGRAM FOR CONTACT;So;0;ON;;;;;N;;;;;\n1D316;TETRAGRAM FOR HOLDING BACK;So;0;ON;;;;;N;;;;;\n1D317;TETRAGRAM FOR WAITING;So;0;ON;;;;;N;;;;;\n1D318;TETRAGRAM FOR FOLLOWING;So;0;ON;;;;;N;;;;;\n1D319;TETRAGRAM FOR ADVANCE;So;0;ON;;;;;N;;;;;\n1D31A;TETRAGRAM FOR RELEASE;So;0;ON;;;;;N;;;;;\n1D31B;TETRAGRAM FOR RESISTANCE;So;0;ON;;;;;N;;;;;\n1D31C;TETRAGRAM FOR EASE;So;0;ON;;;;;N;;;;;\n1D31D;TETRAGRAM FOR JOY;So;0;ON;;;;;N;;;;;\n1D31E;TETRAGRAM FOR CONTENTION;So;0;ON;;;;;N;;;;;\n1D31F;TETRAGRAM FOR ENDEAVOUR;So;0;ON;;;;;N;;;;;\n1D320;TETRAGRAM FOR DUTIES;So;0;ON;;;;;N;;;;;\n1D321;TETRAGRAM FOR CHANGE;So;0;ON;;;;;N;;;;;\n1D322;TETRAGRAM FOR DECISIVENESS;So;0;ON;;;;;N;;;;;\n1D323;TETRAGRAM FOR BOLD RESOLUTION;So;0;ON;;;;;N;;;;;\n1D324;TETRAGRAM FOR PACKING;So;0;ON;;;;;N;;;;;\n1D325;TETRAGRAM FOR LEGION;So;0;ON;;;;;N;;;;;\n1D326;TETRAGRAM FOR CLOSENESS;So;0;ON;;;;;N;;;;;\n1D327;TETRAGRAM FOR KINSHIP;So;0;ON;;;;;N;;;;;\n1D328;TETRAGRAM FOR GATHERING;So;0;ON;;;;;N;;;;;\n1D329;TETRAGRAM FOR STRENGTH;So;0;ON;;;;;N;;;;;\n1D32A;TETRAGRAM FOR PURITY;So;0;ON;;;;;N;;;;;\n1D32B;TETRAGRAM FOR FULLNESS;So;0;ON;;;;;N;;;;;\n1D32C;TETRAGRAM FOR RESIDENCE;So;0;ON;;;;;N;;;;;\n1D32D;TETRAGRAM FOR LAW OR MODEL;So;0;ON;;;;;N;;;;;\n1D32E;TETRAGRAM FOR RESPONSE;So;0;ON;;;;;N;;;;;\n1D32F;TETRAGRAM FOR GOING TO MEET;So;0;ON;;;;;N;;;;;\n1D330;TETRAGRAM FOR ENCOUNTERS;So;0;ON;;;;;N;;;;;\n1D331;TETRAGRAM FOR STOVE;So;0;ON;;;;;N;;;;;\n1D332;TETRAGRAM FOR GREATNESS;So;0;ON;;;;;N;;;;;\n1D333;TETRAGRAM FOR ENLARGEMENT;So;0;ON;;;;;N;;;;;\n1D334;TETRAGRAM FOR PATTERN;So;0;ON;;;;;N;;;;;\n1D335;TETRAGRAM FOR RITUAL;So;0;ON;;;;;N;;;;;\n1D336;TETRAGRAM FOR FLIGHT;So;0;ON;;;;;N;;;;;\n1D337;TETRAGRAM FOR VASTNESS OR WASTING;So;0;ON;;;;;N;;;;;\n1D338;TETRAGRAM FOR CONSTANCY;So;0;ON;;;;;N;;;;;\n1D339;TETRAGRAM FOR MEASURE;So;0;ON;;;;;N;;;;;\n1D33A;TETRAGRAM FOR ETERNITY;So;0;ON;;;;;N;;;;;\n1D33B;TETRAGRAM FOR UNITY;So;0;ON;;;;;N;;;;;\n1D33C;TETRAGRAM FOR DIMINISHMENT;So;0;ON;;;;;N;;;;;\n1D33D;TETRAGRAM FOR CLOSED MOUTH;So;0;ON;;;;;N;;;;;\n1D33E;TETRAGRAM FOR GUARDEDNESS;So;0;ON;;;;;N;;;;;\n1D33F;TETRAGRAM FOR GATHERING IN;So;0;ON;;;;;N;;;;;\n1D340;TETRAGRAM FOR MASSING;So;0;ON;;;;;N;;;;;\n1D341;TETRAGRAM FOR ACCUMULATION;So;0;ON;;;;;N;;;;;\n1D342;TETRAGRAM FOR EMBELLISHMENT;So;0;ON;;;;;N;;;;;\n1D343;TETRAGRAM FOR DOUBT;So;0;ON;;;;;N;;;;;\n1D344;TETRAGRAM FOR WATCH;So;0;ON;;;;;N;;;;;\n1D345;TETRAGRAM FOR SINKING;So;0;ON;;;;;N;;;;;\n1D346;TETRAGRAM FOR INNER;So;0;ON;;;;;N;;;;;\n1D347;TETRAGRAM FOR DEPARTURE;So;0;ON;;;;;N;;;;;\n1D348;TETRAGRAM FOR DARKENING;So;0;ON;;;;;N;;;;;\n1D349;TETRAGRAM FOR DIMMING;So;0;ON;;;;;N;;;;;\n1D34A;TETRAGRAM FOR EXHAUSTION;So;0;ON;;;;;N;;;;;\n1D34B;TETRAGRAM FOR SEVERANCE;So;0;ON;;;;;N;;;;;\n1D34C;TETRAGRAM FOR STOPPAGE;So;0;ON;;;;;N;;;;;\n1D34D;TETRAGRAM FOR HARDNESS;So;0;ON;;;;;N;;;;;\n1D34E;TETRAGRAM FOR COMPLETION;So;0;ON;;;;;N;;;;;\n1D34F;TETRAGRAM FOR CLOSURE;So;0;ON;;;;;N;;;;;\n1D350;TETRAGRAM FOR FAILURE;So;0;ON;;;;;N;;;;;\n1D351;TETRAGRAM FOR AGGRAVATION;So;0;ON;;;;;N;;;;;\n1D352;TETRAGRAM FOR COMPLIANCE;So;0;ON;;;;;N;;;;;\n1D353;TETRAGRAM FOR ON THE VERGE;So;0;ON;;;;;N;;;;;\n1D354;TETRAGRAM FOR DIFFICULTIES;So;0;ON;;;;;N;;;;;\n1D355;TETRAGRAM FOR LABOURING;So;0;ON;;;;;N;;;;;\n1D356;TETRAGRAM FOR FOSTERING;So;0;ON;;;;;N;;;;;\n1D360;COUNTING ROD UNIT DIGIT ONE;No;0;L;;;;1;N;;;;;\n1D361;COUNTING ROD UNIT DIGIT TWO;No;0;L;;;;2;N;;;;;\n1D362;COUNTING ROD UNIT DIGIT THREE;No;0;L;;;;3;N;;;;;\n1D363;COUNTING ROD UNIT DIGIT FOUR;No;0;L;;;;4;N;;;;;\n1D364;COUNTING ROD UNIT DIGIT FIVE;No;0;L;;;;5;N;;;;;\n1D365;COUNTING ROD UNIT DIGIT SIX;No;0;L;;;;6;N;;;;;\n1D366;COUNTING ROD UNIT DIGIT SEVEN;No;0;L;;;;7;N;;;;;\n1D367;COUNTING ROD UNIT DIGIT EIGHT;No;0;L;;;;8;N;;;;;\n1D368;COUNTING ROD UNIT DIGIT NINE;No;0;L;;;;9;N;;;;;\n1D369;COUNTING ROD TENS DIGIT ONE;No;0;L;;;;10;N;;;;;\n1D36A;COUNTING ROD TENS DIGIT TWO;No;0;L;;;;20;N;;;;;\n1D36B;COUNTING ROD TENS DIGIT THREE;No;0;L;;;;30;N;;;;;\n1D36C;COUNTING ROD TENS DIGIT FOUR;No;0;L;;;;40;N;;;;;\n1D36D;COUNTING ROD TENS DIGIT FIVE;No;0;L;;;;50;N;;;;;\n1D36E;COUNTING ROD TENS DIGIT SIX;No;0;L;;;;60;N;;;;;\n1D36F;COUNTING ROD TENS DIGIT SEVEN;No;0;L;;;;70;N;;;;;\n1D370;COUNTING ROD TENS DIGIT EIGHT;No;0;L;;;;80;N;;;;;\n1D371;COUNTING ROD TENS DIGIT NINE;No;0;L;;;;90;N;;;;;\n1D400;MATHEMATICAL BOLD CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D401;MATHEMATICAL BOLD CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D402;MATHEMATICAL BOLD CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D403;MATHEMATICAL BOLD CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D404;MATHEMATICAL BOLD CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D405;MATHEMATICAL BOLD CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D406;MATHEMATICAL BOLD CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D407;MATHEMATICAL BOLD CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D408;MATHEMATICAL BOLD CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D409;MATHEMATICAL BOLD CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D40A;MATHEMATICAL BOLD CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D40B;MATHEMATICAL BOLD CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D40C;MATHEMATICAL BOLD CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D40D;MATHEMATICAL BOLD CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D40E;MATHEMATICAL BOLD CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D40F;MATHEMATICAL BOLD CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D410;MATHEMATICAL BOLD CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D411;MATHEMATICAL BOLD CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D412;MATHEMATICAL BOLD CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D413;MATHEMATICAL BOLD CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D414;MATHEMATICAL BOLD CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D415;MATHEMATICAL BOLD CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D416;MATHEMATICAL BOLD CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D417;MATHEMATICAL BOLD CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D418;MATHEMATICAL BOLD CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D419;MATHEMATICAL BOLD CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D41A;MATHEMATICAL BOLD SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D41B;MATHEMATICAL BOLD SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D41C;MATHEMATICAL BOLD SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D41D;MATHEMATICAL BOLD SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D41E;MATHEMATICAL BOLD SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D41F;MATHEMATICAL BOLD SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D420;MATHEMATICAL BOLD SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D421;MATHEMATICAL BOLD SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D422;MATHEMATICAL BOLD SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D423;MATHEMATICAL BOLD SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D424;MATHEMATICAL BOLD SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D425;MATHEMATICAL BOLD SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D426;MATHEMATICAL BOLD SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D427;MATHEMATICAL BOLD SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D428;MATHEMATICAL BOLD SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D429;MATHEMATICAL BOLD SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D42A;MATHEMATICAL BOLD SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D42B;MATHEMATICAL BOLD SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D42C;MATHEMATICAL BOLD SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D42D;MATHEMATICAL BOLD SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D42E;MATHEMATICAL BOLD SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D42F;MATHEMATICAL BOLD SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D430;MATHEMATICAL BOLD SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D431;MATHEMATICAL BOLD SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D432;MATHEMATICAL BOLD SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D433;MATHEMATICAL BOLD SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D434;MATHEMATICAL ITALIC CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D435;MATHEMATICAL ITALIC CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D436;MATHEMATICAL ITALIC CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D437;MATHEMATICAL ITALIC CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D438;MATHEMATICAL ITALIC CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D439;MATHEMATICAL ITALIC CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D43A;MATHEMATICAL ITALIC CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D43B;MATHEMATICAL ITALIC CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D43C;MATHEMATICAL ITALIC CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D43D;MATHEMATICAL ITALIC CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D43E;MATHEMATICAL ITALIC CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D43F;MATHEMATICAL ITALIC CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D440;MATHEMATICAL ITALIC CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D441;MATHEMATICAL ITALIC CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D442;MATHEMATICAL ITALIC CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D443;MATHEMATICAL ITALIC CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D444;MATHEMATICAL ITALIC CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D445;MATHEMATICAL ITALIC CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D446;MATHEMATICAL ITALIC CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D447;MATHEMATICAL ITALIC CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D448;MATHEMATICAL ITALIC CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D449;MATHEMATICAL ITALIC CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D44A;MATHEMATICAL ITALIC CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D44B;MATHEMATICAL ITALIC CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D44C;MATHEMATICAL ITALIC CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D44D;MATHEMATICAL ITALIC CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D44E;MATHEMATICAL ITALIC SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D44F;MATHEMATICAL ITALIC SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D450;MATHEMATICAL ITALIC SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D451;MATHEMATICAL ITALIC SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D452;MATHEMATICAL ITALIC SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D453;MATHEMATICAL ITALIC SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D454;MATHEMATICAL ITALIC SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D456;MATHEMATICAL ITALIC SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D457;MATHEMATICAL ITALIC SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D458;MATHEMATICAL ITALIC SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D459;MATHEMATICAL ITALIC SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D45A;MATHEMATICAL ITALIC SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D45B;MATHEMATICAL ITALIC SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D45C;MATHEMATICAL ITALIC SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D45D;MATHEMATICAL ITALIC SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D45E;MATHEMATICAL ITALIC SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D45F;MATHEMATICAL ITALIC SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D460;MATHEMATICAL ITALIC SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D461;MATHEMATICAL ITALIC SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D462;MATHEMATICAL ITALIC SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D463;MATHEMATICAL ITALIC SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D464;MATHEMATICAL ITALIC SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D465;MATHEMATICAL ITALIC SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D466;MATHEMATICAL ITALIC SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D467;MATHEMATICAL ITALIC SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D468;MATHEMATICAL BOLD ITALIC CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D469;MATHEMATICAL BOLD ITALIC CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D46A;MATHEMATICAL BOLD ITALIC CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D46B;MATHEMATICAL BOLD ITALIC CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D46C;MATHEMATICAL BOLD ITALIC CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D46D;MATHEMATICAL BOLD ITALIC CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D46E;MATHEMATICAL BOLD ITALIC CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D46F;MATHEMATICAL BOLD ITALIC CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D470;MATHEMATICAL BOLD ITALIC CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D471;MATHEMATICAL BOLD ITALIC CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D472;MATHEMATICAL BOLD ITALIC CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D473;MATHEMATICAL BOLD ITALIC CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D474;MATHEMATICAL BOLD ITALIC CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D475;MATHEMATICAL BOLD ITALIC CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D476;MATHEMATICAL BOLD ITALIC CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D477;MATHEMATICAL BOLD ITALIC CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D478;MATHEMATICAL BOLD ITALIC CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D479;MATHEMATICAL BOLD ITALIC CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D47A;MATHEMATICAL BOLD ITALIC CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D47B;MATHEMATICAL BOLD ITALIC CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D47C;MATHEMATICAL BOLD ITALIC CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D47D;MATHEMATICAL BOLD ITALIC CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D47E;MATHEMATICAL BOLD ITALIC CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D47F;MATHEMATICAL BOLD ITALIC CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D480;MATHEMATICAL BOLD ITALIC CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D481;MATHEMATICAL BOLD ITALIC CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D482;MATHEMATICAL BOLD ITALIC SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D483;MATHEMATICAL BOLD ITALIC SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D484;MATHEMATICAL BOLD ITALIC SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D485;MATHEMATICAL BOLD ITALIC SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D486;MATHEMATICAL BOLD ITALIC SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D487;MATHEMATICAL BOLD ITALIC SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D488;MATHEMATICAL BOLD ITALIC SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D489;MATHEMATICAL BOLD ITALIC SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D48A;MATHEMATICAL BOLD ITALIC SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D48B;MATHEMATICAL BOLD ITALIC SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D48C;MATHEMATICAL BOLD ITALIC SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D48D;MATHEMATICAL BOLD ITALIC SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D48E;MATHEMATICAL BOLD ITALIC SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D48F;MATHEMATICAL BOLD ITALIC SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D490;MATHEMATICAL BOLD ITALIC SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D491;MATHEMATICAL BOLD ITALIC SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D492;MATHEMATICAL BOLD ITALIC SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D493;MATHEMATICAL BOLD ITALIC SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D494;MATHEMATICAL BOLD ITALIC SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D495;MATHEMATICAL BOLD ITALIC SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D496;MATHEMATICAL BOLD ITALIC SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D497;MATHEMATICAL BOLD ITALIC SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D498;MATHEMATICAL BOLD ITALIC SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D499;MATHEMATICAL BOLD ITALIC SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D49A;MATHEMATICAL BOLD ITALIC SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D49B;MATHEMATICAL BOLD ITALIC SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D49C;MATHEMATICAL SCRIPT CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D49E;MATHEMATICAL SCRIPT CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D49F;MATHEMATICAL SCRIPT CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D4A2;MATHEMATICAL SCRIPT CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D4A5;MATHEMATICAL SCRIPT CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D4A6;MATHEMATICAL SCRIPT CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D4A9;MATHEMATICAL SCRIPT CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D4AA;MATHEMATICAL SCRIPT CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D4AB;MATHEMATICAL SCRIPT CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D4AC;MATHEMATICAL SCRIPT CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D4AE;MATHEMATICAL SCRIPT CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D4AF;MATHEMATICAL SCRIPT CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D4B0;MATHEMATICAL SCRIPT CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D4B1;MATHEMATICAL SCRIPT CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D4B2;MATHEMATICAL SCRIPT CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D4B3;MATHEMATICAL SCRIPT CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D4B4;MATHEMATICAL SCRIPT CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D4B5;MATHEMATICAL SCRIPT CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D4B6;MATHEMATICAL SCRIPT SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D4B7;MATHEMATICAL SCRIPT SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D4B8;MATHEMATICAL SCRIPT SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D4B9;MATHEMATICAL SCRIPT SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D4BB;MATHEMATICAL SCRIPT SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D4BD;MATHEMATICAL SCRIPT SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D4BE;MATHEMATICAL SCRIPT SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D4BF;MATHEMATICAL SCRIPT SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D4C0;MATHEMATICAL SCRIPT SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D4C1;MATHEMATICAL SCRIPT SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D4C2;MATHEMATICAL SCRIPT SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D4C3;MATHEMATICAL SCRIPT SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D4C5;MATHEMATICAL SCRIPT SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D4C6;MATHEMATICAL SCRIPT SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D4C7;MATHEMATICAL SCRIPT SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D4C8;MATHEMATICAL SCRIPT SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D4C9;MATHEMATICAL SCRIPT SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D4CA;MATHEMATICAL SCRIPT SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D4CB;MATHEMATICAL SCRIPT SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D4CC;MATHEMATICAL SCRIPT SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D4CD;MATHEMATICAL SCRIPT SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D4CE;MATHEMATICAL SCRIPT SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D4CF;MATHEMATICAL SCRIPT SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D4D0;MATHEMATICAL BOLD SCRIPT CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D4D1;MATHEMATICAL BOLD SCRIPT CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D4D2;MATHEMATICAL BOLD SCRIPT CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D4D3;MATHEMATICAL BOLD SCRIPT CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D4D4;MATHEMATICAL BOLD SCRIPT CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D4D5;MATHEMATICAL BOLD SCRIPT CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D4D6;MATHEMATICAL BOLD SCRIPT CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D4D7;MATHEMATICAL BOLD SCRIPT CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D4D8;MATHEMATICAL BOLD SCRIPT CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D4D9;MATHEMATICAL BOLD SCRIPT CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D4DA;MATHEMATICAL BOLD SCRIPT CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D4DB;MATHEMATICAL BOLD SCRIPT CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D4DC;MATHEMATICAL BOLD SCRIPT CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D4DD;MATHEMATICAL BOLD SCRIPT CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D4DE;MATHEMATICAL BOLD SCRIPT CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D4DF;MATHEMATICAL BOLD SCRIPT CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D4E0;MATHEMATICAL BOLD SCRIPT CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D4E1;MATHEMATICAL BOLD SCRIPT CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D4E2;MATHEMATICAL BOLD SCRIPT CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D4E3;MATHEMATICAL BOLD SCRIPT CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D4E4;MATHEMATICAL BOLD SCRIPT CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D4E5;MATHEMATICAL BOLD SCRIPT CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D4E6;MATHEMATICAL BOLD SCRIPT CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D4E7;MATHEMATICAL BOLD SCRIPT CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D4E8;MATHEMATICAL BOLD SCRIPT CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D4E9;MATHEMATICAL BOLD SCRIPT CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D4EA;MATHEMATICAL BOLD SCRIPT SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D4EB;MATHEMATICAL BOLD SCRIPT SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D4EC;MATHEMATICAL BOLD SCRIPT SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D4ED;MATHEMATICAL BOLD SCRIPT SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D4EE;MATHEMATICAL BOLD SCRIPT SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D4EF;MATHEMATICAL BOLD SCRIPT SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D4F0;MATHEMATICAL BOLD SCRIPT SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D4F1;MATHEMATICAL BOLD SCRIPT SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D4F2;MATHEMATICAL BOLD SCRIPT SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D4F3;MATHEMATICAL BOLD SCRIPT SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D4F4;MATHEMATICAL BOLD SCRIPT SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D4F5;MATHEMATICAL BOLD SCRIPT SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D4F6;MATHEMATICAL BOLD SCRIPT SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D4F7;MATHEMATICAL BOLD SCRIPT SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D4F8;MATHEMATICAL BOLD SCRIPT SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D4F9;MATHEMATICAL BOLD SCRIPT SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D4FA;MATHEMATICAL BOLD SCRIPT SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D4FB;MATHEMATICAL BOLD SCRIPT SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D4FC;MATHEMATICAL BOLD SCRIPT SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D4FD;MATHEMATICAL BOLD SCRIPT SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D4FE;MATHEMATICAL BOLD SCRIPT SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D4FF;MATHEMATICAL BOLD SCRIPT SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D500;MATHEMATICAL BOLD SCRIPT SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D501;MATHEMATICAL BOLD SCRIPT SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D502;MATHEMATICAL BOLD SCRIPT SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D503;MATHEMATICAL BOLD SCRIPT SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D504;MATHEMATICAL FRAKTUR CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D505;MATHEMATICAL FRAKTUR CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D507;MATHEMATICAL FRAKTUR CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D508;MATHEMATICAL FRAKTUR CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D509;MATHEMATICAL FRAKTUR CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D50A;MATHEMATICAL FRAKTUR CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D50D;MATHEMATICAL FRAKTUR CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D50E;MATHEMATICAL FRAKTUR CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D50F;MATHEMATICAL FRAKTUR CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D510;MATHEMATICAL FRAKTUR CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D511;MATHEMATICAL FRAKTUR CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D512;MATHEMATICAL FRAKTUR CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D513;MATHEMATICAL FRAKTUR CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D514;MATHEMATICAL FRAKTUR CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D516;MATHEMATICAL FRAKTUR CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D517;MATHEMATICAL FRAKTUR CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D518;MATHEMATICAL FRAKTUR CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D519;MATHEMATICAL FRAKTUR CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D51A;MATHEMATICAL FRAKTUR CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D51B;MATHEMATICAL FRAKTUR CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D51C;MATHEMATICAL FRAKTUR CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D51E;MATHEMATICAL FRAKTUR SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D51F;MATHEMATICAL FRAKTUR SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D520;MATHEMATICAL FRAKTUR SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D521;MATHEMATICAL FRAKTUR SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D522;MATHEMATICAL FRAKTUR SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D523;MATHEMATICAL FRAKTUR SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D524;MATHEMATICAL FRAKTUR SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D525;MATHEMATICAL FRAKTUR SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D526;MATHEMATICAL FRAKTUR SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D527;MATHEMATICAL FRAKTUR SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D528;MATHEMATICAL FRAKTUR SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D529;MATHEMATICAL FRAKTUR SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D52A;MATHEMATICAL FRAKTUR SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D52B;MATHEMATICAL FRAKTUR SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D52C;MATHEMATICAL FRAKTUR SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D52D;MATHEMATICAL FRAKTUR SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D52E;MATHEMATICAL FRAKTUR SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D52F;MATHEMATICAL FRAKTUR SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D530;MATHEMATICAL FRAKTUR SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D531;MATHEMATICAL FRAKTUR SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D532;MATHEMATICAL FRAKTUR SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D533;MATHEMATICAL FRAKTUR SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D534;MATHEMATICAL FRAKTUR SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D535;MATHEMATICAL FRAKTUR SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D536;MATHEMATICAL FRAKTUR SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D537;MATHEMATICAL FRAKTUR SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D538;MATHEMATICAL DOUBLE-STRUCK CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D539;MATHEMATICAL DOUBLE-STRUCK CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D53B;MATHEMATICAL DOUBLE-STRUCK CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D53C;MATHEMATICAL DOUBLE-STRUCK CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D53D;MATHEMATICAL DOUBLE-STRUCK CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D53E;MATHEMATICAL DOUBLE-STRUCK CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D540;MATHEMATICAL DOUBLE-STRUCK CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D541;MATHEMATICAL DOUBLE-STRUCK CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D542;MATHEMATICAL DOUBLE-STRUCK CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D543;MATHEMATICAL DOUBLE-STRUCK CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D544;MATHEMATICAL DOUBLE-STRUCK CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D546;MATHEMATICAL DOUBLE-STRUCK CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D54A;MATHEMATICAL DOUBLE-STRUCK CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D54B;MATHEMATICAL DOUBLE-STRUCK CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D54C;MATHEMATICAL DOUBLE-STRUCK CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D54D;MATHEMATICAL DOUBLE-STRUCK CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D54E;MATHEMATICAL DOUBLE-STRUCK CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D54F;MATHEMATICAL DOUBLE-STRUCK CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D550;MATHEMATICAL DOUBLE-STRUCK CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D552;MATHEMATICAL DOUBLE-STRUCK SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D553;MATHEMATICAL DOUBLE-STRUCK SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D554;MATHEMATICAL DOUBLE-STRUCK SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D555;MATHEMATICAL DOUBLE-STRUCK SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D556;MATHEMATICAL DOUBLE-STRUCK SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D557;MATHEMATICAL DOUBLE-STRUCK SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D558;MATHEMATICAL DOUBLE-STRUCK SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D559;MATHEMATICAL DOUBLE-STRUCK SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D55A;MATHEMATICAL DOUBLE-STRUCK SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D55B;MATHEMATICAL DOUBLE-STRUCK SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D55C;MATHEMATICAL DOUBLE-STRUCK SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D55D;MATHEMATICAL DOUBLE-STRUCK SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D55E;MATHEMATICAL DOUBLE-STRUCK SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D55F;MATHEMATICAL DOUBLE-STRUCK SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D560;MATHEMATICAL DOUBLE-STRUCK SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D561;MATHEMATICAL DOUBLE-STRUCK SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D562;MATHEMATICAL DOUBLE-STRUCK SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D563;MATHEMATICAL DOUBLE-STRUCK SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D564;MATHEMATICAL DOUBLE-STRUCK SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D565;MATHEMATICAL DOUBLE-STRUCK SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D566;MATHEMATICAL DOUBLE-STRUCK SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D567;MATHEMATICAL DOUBLE-STRUCK SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D568;MATHEMATICAL DOUBLE-STRUCK SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D569;MATHEMATICAL DOUBLE-STRUCK SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D56A;MATHEMATICAL DOUBLE-STRUCK SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D56B;MATHEMATICAL DOUBLE-STRUCK SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D56C;MATHEMATICAL BOLD FRAKTUR CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D56D;MATHEMATICAL BOLD FRAKTUR CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D56E;MATHEMATICAL BOLD FRAKTUR CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D56F;MATHEMATICAL BOLD FRAKTUR CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D570;MATHEMATICAL BOLD FRAKTUR CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D571;MATHEMATICAL BOLD FRAKTUR CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D572;MATHEMATICAL BOLD FRAKTUR CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D573;MATHEMATICAL BOLD FRAKTUR CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D574;MATHEMATICAL BOLD FRAKTUR CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D575;MATHEMATICAL BOLD FRAKTUR CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D576;MATHEMATICAL BOLD FRAKTUR CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D577;MATHEMATICAL BOLD FRAKTUR CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D578;MATHEMATICAL BOLD FRAKTUR CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D579;MATHEMATICAL BOLD FRAKTUR CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D57A;MATHEMATICAL BOLD FRAKTUR CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D57B;MATHEMATICAL BOLD FRAKTUR CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D57C;MATHEMATICAL BOLD FRAKTUR CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D57D;MATHEMATICAL BOLD FRAKTUR CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D57E;MATHEMATICAL BOLD FRAKTUR CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D57F;MATHEMATICAL BOLD FRAKTUR CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D580;MATHEMATICAL BOLD FRAKTUR CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D581;MATHEMATICAL BOLD FRAKTUR CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D582;MATHEMATICAL BOLD FRAKTUR CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D583;MATHEMATICAL BOLD FRAKTUR CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D584;MATHEMATICAL BOLD FRAKTUR CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D585;MATHEMATICAL BOLD FRAKTUR CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D586;MATHEMATICAL BOLD FRAKTUR SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D587;MATHEMATICAL BOLD FRAKTUR SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D588;MATHEMATICAL BOLD FRAKTUR SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D589;MATHEMATICAL BOLD FRAKTUR SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D58A;MATHEMATICAL BOLD FRAKTUR SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D58B;MATHEMATICAL BOLD FRAKTUR SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D58C;MATHEMATICAL BOLD FRAKTUR SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D58D;MATHEMATICAL BOLD FRAKTUR SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D58E;MATHEMATICAL BOLD FRAKTUR SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D58F;MATHEMATICAL BOLD FRAKTUR SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D590;MATHEMATICAL BOLD FRAKTUR SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D591;MATHEMATICAL BOLD FRAKTUR SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D592;MATHEMATICAL BOLD FRAKTUR SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D593;MATHEMATICAL BOLD FRAKTUR SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D594;MATHEMATICAL BOLD FRAKTUR SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D595;MATHEMATICAL BOLD FRAKTUR SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D596;MATHEMATICAL BOLD FRAKTUR SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D597;MATHEMATICAL BOLD FRAKTUR SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D598;MATHEMATICAL BOLD FRAKTUR SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D599;MATHEMATICAL BOLD FRAKTUR SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D59A;MATHEMATICAL BOLD FRAKTUR SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D59B;MATHEMATICAL BOLD FRAKTUR SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D59C;MATHEMATICAL BOLD FRAKTUR SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D59D;MATHEMATICAL BOLD FRAKTUR SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D59E;MATHEMATICAL BOLD FRAKTUR SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D59F;MATHEMATICAL BOLD FRAKTUR SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D5A0;MATHEMATICAL SANS-SERIF CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D5A1;MATHEMATICAL SANS-SERIF CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D5A2;MATHEMATICAL SANS-SERIF CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D5A3;MATHEMATICAL SANS-SERIF CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D5A4;MATHEMATICAL SANS-SERIF CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D5A5;MATHEMATICAL SANS-SERIF CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D5A6;MATHEMATICAL SANS-SERIF CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D5A7;MATHEMATICAL SANS-SERIF CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D5A8;MATHEMATICAL SANS-SERIF CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D5A9;MATHEMATICAL SANS-SERIF CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D5AA;MATHEMATICAL SANS-SERIF CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D5AB;MATHEMATICAL SANS-SERIF CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D5AC;MATHEMATICAL SANS-SERIF CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D5AD;MATHEMATICAL SANS-SERIF CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D5AE;MATHEMATICAL SANS-SERIF CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D5AF;MATHEMATICAL SANS-SERIF CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D5B0;MATHEMATICAL SANS-SERIF CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D5B1;MATHEMATICAL SANS-SERIF CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D5B2;MATHEMATICAL SANS-SERIF CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D5B3;MATHEMATICAL SANS-SERIF CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D5B4;MATHEMATICAL SANS-SERIF CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D5B5;MATHEMATICAL SANS-SERIF CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D5B6;MATHEMATICAL SANS-SERIF CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D5B7;MATHEMATICAL SANS-SERIF CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D5B8;MATHEMATICAL SANS-SERIF CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D5B9;MATHEMATICAL SANS-SERIF CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D5BA;MATHEMATICAL SANS-SERIF SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D5BB;MATHEMATICAL SANS-SERIF SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D5BC;MATHEMATICAL SANS-SERIF SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D5BD;MATHEMATICAL SANS-SERIF SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D5BE;MATHEMATICAL SANS-SERIF SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D5BF;MATHEMATICAL SANS-SERIF SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D5C0;MATHEMATICAL SANS-SERIF SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D5C1;MATHEMATICAL SANS-SERIF SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D5C2;MATHEMATICAL SANS-SERIF SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D5C3;MATHEMATICAL SANS-SERIF SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D5C4;MATHEMATICAL SANS-SERIF SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D5C5;MATHEMATICAL SANS-SERIF SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D5C6;MATHEMATICAL SANS-SERIF SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D5C7;MATHEMATICAL SANS-SERIF SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D5C8;MATHEMATICAL SANS-SERIF SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D5C9;MATHEMATICAL SANS-SERIF SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D5CA;MATHEMATICAL SANS-SERIF SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D5CB;MATHEMATICAL SANS-SERIF SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D5CC;MATHEMATICAL SANS-SERIF SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D5CD;MATHEMATICAL SANS-SERIF SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D5CE;MATHEMATICAL SANS-SERIF SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D5CF;MATHEMATICAL SANS-SERIF SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D5D0;MATHEMATICAL SANS-SERIF SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D5D1;MATHEMATICAL SANS-SERIF SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D5D2;MATHEMATICAL SANS-SERIF SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D5D3;MATHEMATICAL SANS-SERIF SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D5D4;MATHEMATICAL SANS-SERIF BOLD CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D5D5;MATHEMATICAL SANS-SERIF BOLD CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D5D6;MATHEMATICAL SANS-SERIF BOLD CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D5D7;MATHEMATICAL SANS-SERIF BOLD CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D5D8;MATHEMATICAL SANS-SERIF BOLD CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D5D9;MATHEMATICAL SANS-SERIF BOLD CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D5DA;MATHEMATICAL SANS-SERIF BOLD CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D5DB;MATHEMATICAL SANS-SERIF BOLD CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D5DC;MATHEMATICAL SANS-SERIF BOLD CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D5DD;MATHEMATICAL SANS-SERIF BOLD CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D5DE;MATHEMATICAL SANS-SERIF BOLD CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D5DF;MATHEMATICAL SANS-SERIF BOLD CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D5E0;MATHEMATICAL SANS-SERIF BOLD CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D5E1;MATHEMATICAL SANS-SERIF BOLD CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D5E2;MATHEMATICAL SANS-SERIF BOLD CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D5E3;MATHEMATICAL SANS-SERIF BOLD CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D5E4;MATHEMATICAL SANS-SERIF BOLD CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D5E5;MATHEMATICAL SANS-SERIF BOLD CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D5E6;MATHEMATICAL SANS-SERIF BOLD CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D5E7;MATHEMATICAL SANS-SERIF BOLD CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D5E8;MATHEMATICAL SANS-SERIF BOLD CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D5E9;MATHEMATICAL SANS-SERIF BOLD CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D5EA;MATHEMATICAL SANS-SERIF BOLD CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D5EB;MATHEMATICAL SANS-SERIF BOLD CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D5EC;MATHEMATICAL SANS-SERIF BOLD CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D5ED;MATHEMATICAL SANS-SERIF BOLD CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D5EE;MATHEMATICAL SANS-SERIF BOLD SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D5EF;MATHEMATICAL SANS-SERIF BOLD SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D5F0;MATHEMATICAL SANS-SERIF BOLD SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D5F1;MATHEMATICAL SANS-SERIF BOLD SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D5F2;MATHEMATICAL SANS-SERIF BOLD SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D5F3;MATHEMATICAL SANS-SERIF BOLD SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D5F4;MATHEMATICAL SANS-SERIF BOLD SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D5F5;MATHEMATICAL SANS-SERIF BOLD SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D5F6;MATHEMATICAL SANS-SERIF BOLD SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D5F7;MATHEMATICAL SANS-SERIF BOLD SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D5F8;MATHEMATICAL SANS-SERIF BOLD SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D5F9;MATHEMATICAL SANS-SERIF BOLD SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D5FA;MATHEMATICAL SANS-SERIF BOLD SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D5FB;MATHEMATICAL SANS-SERIF BOLD SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D5FC;MATHEMATICAL SANS-SERIF BOLD SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D5FD;MATHEMATICAL SANS-SERIF BOLD SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D5FE;MATHEMATICAL SANS-SERIF BOLD SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D5FF;MATHEMATICAL SANS-SERIF BOLD SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D600;MATHEMATICAL SANS-SERIF BOLD SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D601;MATHEMATICAL SANS-SERIF BOLD SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D602;MATHEMATICAL SANS-SERIF BOLD SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D603;MATHEMATICAL SANS-SERIF BOLD SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D604;MATHEMATICAL SANS-SERIF BOLD SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D605;MATHEMATICAL SANS-SERIF BOLD SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D606;MATHEMATICAL SANS-SERIF BOLD SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D607;MATHEMATICAL SANS-SERIF BOLD SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D608;MATHEMATICAL SANS-SERIF ITALIC CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D609;MATHEMATICAL SANS-SERIF ITALIC CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D60A;MATHEMATICAL SANS-SERIF ITALIC CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D60B;MATHEMATICAL SANS-SERIF ITALIC CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D60C;MATHEMATICAL SANS-SERIF ITALIC CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D60D;MATHEMATICAL SANS-SERIF ITALIC CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D60E;MATHEMATICAL SANS-SERIF ITALIC CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D60F;MATHEMATICAL SANS-SERIF ITALIC CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D610;MATHEMATICAL SANS-SERIF ITALIC CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D611;MATHEMATICAL SANS-SERIF ITALIC CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D612;MATHEMATICAL SANS-SERIF ITALIC CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D613;MATHEMATICAL SANS-SERIF ITALIC CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D614;MATHEMATICAL SANS-SERIF ITALIC CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D615;MATHEMATICAL SANS-SERIF ITALIC CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D616;MATHEMATICAL SANS-SERIF ITALIC CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D617;MATHEMATICAL SANS-SERIF ITALIC CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D618;MATHEMATICAL SANS-SERIF ITALIC CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D619;MATHEMATICAL SANS-SERIF ITALIC CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D61A;MATHEMATICAL SANS-SERIF ITALIC CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D61B;MATHEMATICAL SANS-SERIF ITALIC CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D61C;MATHEMATICAL SANS-SERIF ITALIC CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D61D;MATHEMATICAL SANS-SERIF ITALIC CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D61E;MATHEMATICAL SANS-SERIF ITALIC CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D61F;MATHEMATICAL SANS-SERIF ITALIC CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D620;MATHEMATICAL SANS-SERIF ITALIC CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D621;MATHEMATICAL SANS-SERIF ITALIC CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D622;MATHEMATICAL SANS-SERIF ITALIC SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D623;MATHEMATICAL SANS-SERIF ITALIC SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D624;MATHEMATICAL SANS-SERIF ITALIC SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D625;MATHEMATICAL SANS-SERIF ITALIC SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D626;MATHEMATICAL SANS-SERIF ITALIC SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D627;MATHEMATICAL SANS-SERIF ITALIC SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D628;MATHEMATICAL SANS-SERIF ITALIC SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D629;MATHEMATICAL SANS-SERIF ITALIC SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D62A;MATHEMATICAL SANS-SERIF ITALIC SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D62B;MATHEMATICAL SANS-SERIF ITALIC SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D62C;MATHEMATICAL SANS-SERIF ITALIC SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D62D;MATHEMATICAL SANS-SERIF ITALIC SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D62E;MATHEMATICAL SANS-SERIF ITALIC SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D62F;MATHEMATICAL SANS-SERIF ITALIC SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D630;MATHEMATICAL SANS-SERIF ITALIC SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D631;MATHEMATICAL SANS-SERIF ITALIC SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D632;MATHEMATICAL SANS-SERIF ITALIC SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D633;MATHEMATICAL SANS-SERIF ITALIC SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D634;MATHEMATICAL SANS-SERIF ITALIC SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D635;MATHEMATICAL SANS-SERIF ITALIC SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D636;MATHEMATICAL SANS-SERIF ITALIC SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D637;MATHEMATICAL SANS-SERIF ITALIC SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D638;MATHEMATICAL SANS-SERIF ITALIC SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D639;MATHEMATICAL SANS-SERIF ITALIC SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D63A;MATHEMATICAL SANS-SERIF ITALIC SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D63B;MATHEMATICAL SANS-SERIF ITALIC SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D63C;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D63D;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D63E;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D63F;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D640;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D641;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D642;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D643;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D644;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D645;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D646;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D647;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D648;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D649;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D64A;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D64B;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D64C;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D64D;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D64E;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D64F;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D650;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D651;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D652;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D653;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D654;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D655;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D656;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D657;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D658;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D659;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D65A;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D65B;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D65C;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D65D;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D65E;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D65F;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D660;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D661;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D662;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D663;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D664;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D665;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D666;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D667;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D668;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D669;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D66A;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D66B;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D66C;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D66D;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D66E;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D66F;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D670;MATHEMATICAL MONOSPACE CAPITAL A;Lu;0;L;<font> 0041;;;;N;;;;;\n1D671;MATHEMATICAL MONOSPACE CAPITAL B;Lu;0;L;<font> 0042;;;;N;;;;;\n1D672;MATHEMATICAL MONOSPACE CAPITAL C;Lu;0;L;<font> 0043;;;;N;;;;;\n1D673;MATHEMATICAL MONOSPACE CAPITAL D;Lu;0;L;<font> 0044;;;;N;;;;;\n1D674;MATHEMATICAL MONOSPACE CAPITAL E;Lu;0;L;<font> 0045;;;;N;;;;;\n1D675;MATHEMATICAL MONOSPACE CAPITAL F;Lu;0;L;<font> 0046;;;;N;;;;;\n1D676;MATHEMATICAL MONOSPACE CAPITAL G;Lu;0;L;<font> 0047;;;;N;;;;;\n1D677;MATHEMATICAL MONOSPACE CAPITAL H;Lu;0;L;<font> 0048;;;;N;;;;;\n1D678;MATHEMATICAL MONOSPACE CAPITAL I;Lu;0;L;<font> 0049;;;;N;;;;;\n1D679;MATHEMATICAL MONOSPACE CAPITAL J;Lu;0;L;<font> 004A;;;;N;;;;;\n1D67A;MATHEMATICAL MONOSPACE CAPITAL K;Lu;0;L;<font> 004B;;;;N;;;;;\n1D67B;MATHEMATICAL MONOSPACE CAPITAL L;Lu;0;L;<font> 004C;;;;N;;;;;\n1D67C;MATHEMATICAL MONOSPACE CAPITAL M;Lu;0;L;<font> 004D;;;;N;;;;;\n1D67D;MATHEMATICAL MONOSPACE CAPITAL N;Lu;0;L;<font> 004E;;;;N;;;;;\n1D67E;MATHEMATICAL MONOSPACE CAPITAL O;Lu;0;L;<font> 004F;;;;N;;;;;\n1D67F;MATHEMATICAL MONOSPACE CAPITAL P;Lu;0;L;<font> 0050;;;;N;;;;;\n1D680;MATHEMATICAL MONOSPACE CAPITAL Q;Lu;0;L;<font> 0051;;;;N;;;;;\n1D681;MATHEMATICAL MONOSPACE CAPITAL R;Lu;0;L;<font> 0052;;;;N;;;;;\n1D682;MATHEMATICAL MONOSPACE CAPITAL S;Lu;0;L;<font> 0053;;;;N;;;;;\n1D683;MATHEMATICAL MONOSPACE CAPITAL T;Lu;0;L;<font> 0054;;;;N;;;;;\n1D684;MATHEMATICAL MONOSPACE CAPITAL U;Lu;0;L;<font> 0055;;;;N;;;;;\n1D685;MATHEMATICAL MONOSPACE CAPITAL V;Lu;0;L;<font> 0056;;;;N;;;;;\n1D686;MATHEMATICAL MONOSPACE CAPITAL W;Lu;0;L;<font> 0057;;;;N;;;;;\n1D687;MATHEMATICAL MONOSPACE CAPITAL X;Lu;0;L;<font> 0058;;;;N;;;;;\n1D688;MATHEMATICAL MONOSPACE CAPITAL Y;Lu;0;L;<font> 0059;;;;N;;;;;\n1D689;MATHEMATICAL MONOSPACE CAPITAL Z;Lu;0;L;<font> 005A;;;;N;;;;;\n1D68A;MATHEMATICAL MONOSPACE SMALL A;Ll;0;L;<font> 0061;;;;N;;;;;\n1D68B;MATHEMATICAL MONOSPACE SMALL B;Ll;0;L;<font> 0062;;;;N;;;;;\n1D68C;MATHEMATICAL MONOSPACE SMALL C;Ll;0;L;<font> 0063;;;;N;;;;;\n1D68D;MATHEMATICAL MONOSPACE SMALL D;Ll;0;L;<font> 0064;;;;N;;;;;\n1D68E;MATHEMATICAL MONOSPACE SMALL E;Ll;0;L;<font> 0065;;;;N;;;;;\n1D68F;MATHEMATICAL MONOSPACE SMALL F;Ll;0;L;<font> 0066;;;;N;;;;;\n1D690;MATHEMATICAL MONOSPACE SMALL G;Ll;0;L;<font> 0067;;;;N;;;;;\n1D691;MATHEMATICAL MONOSPACE SMALL H;Ll;0;L;<font> 0068;;;;N;;;;;\n1D692;MATHEMATICAL MONOSPACE SMALL I;Ll;0;L;<font> 0069;;;;N;;;;;\n1D693;MATHEMATICAL MONOSPACE SMALL J;Ll;0;L;<font> 006A;;;;N;;;;;\n1D694;MATHEMATICAL MONOSPACE SMALL K;Ll;0;L;<font> 006B;;;;N;;;;;\n1D695;MATHEMATICAL MONOSPACE SMALL L;Ll;0;L;<font> 006C;;;;N;;;;;\n1D696;MATHEMATICAL MONOSPACE SMALL M;Ll;0;L;<font> 006D;;;;N;;;;;\n1D697;MATHEMATICAL MONOSPACE SMALL N;Ll;0;L;<font> 006E;;;;N;;;;;\n1D698;MATHEMATICAL MONOSPACE SMALL O;Ll;0;L;<font> 006F;;;;N;;;;;\n1D699;MATHEMATICAL MONOSPACE SMALL P;Ll;0;L;<font> 0070;;;;N;;;;;\n1D69A;MATHEMATICAL MONOSPACE SMALL Q;Ll;0;L;<font> 0071;;;;N;;;;;\n1D69B;MATHEMATICAL MONOSPACE SMALL R;Ll;0;L;<font> 0072;;;;N;;;;;\n1D69C;MATHEMATICAL MONOSPACE SMALL S;Ll;0;L;<font> 0073;;;;N;;;;;\n1D69D;MATHEMATICAL MONOSPACE SMALL T;Ll;0;L;<font> 0074;;;;N;;;;;\n1D69E;MATHEMATICAL MONOSPACE SMALL U;Ll;0;L;<font> 0075;;;;N;;;;;\n1D69F;MATHEMATICAL MONOSPACE SMALL V;Ll;0;L;<font> 0076;;;;N;;;;;\n1D6A0;MATHEMATICAL MONOSPACE SMALL W;Ll;0;L;<font> 0077;;;;N;;;;;\n1D6A1;MATHEMATICAL MONOSPACE SMALL X;Ll;0;L;<font> 0078;;;;N;;;;;\n1D6A2;MATHEMATICAL MONOSPACE SMALL Y;Ll;0;L;<font> 0079;;;;N;;;;;\n1D6A3;MATHEMATICAL MONOSPACE SMALL Z;Ll;0;L;<font> 007A;;;;N;;;;;\n1D6A4;MATHEMATICAL ITALIC SMALL DOTLESS I;Ll;0;L;<font> 0131;;;;N;;;;;\n1D6A5;MATHEMATICAL ITALIC SMALL DOTLESS J;Ll;0;L;<font> 0237;;;;N;;;;;\n1D6A8;MATHEMATICAL BOLD CAPITAL ALPHA;Lu;0;L;<font> 0391;;;;N;;;;;\n1D6A9;MATHEMATICAL BOLD CAPITAL BETA;Lu;0;L;<font> 0392;;;;N;;;;;\n1D6AA;MATHEMATICAL BOLD CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n1D6AB;MATHEMATICAL BOLD CAPITAL DELTA;Lu;0;L;<font> 0394;;;;N;;;;;\n1D6AC;MATHEMATICAL BOLD CAPITAL EPSILON;Lu;0;L;<font> 0395;;;;N;;;;;\n1D6AD;MATHEMATICAL BOLD CAPITAL ZETA;Lu;0;L;<font> 0396;;;;N;;;;;\n1D6AE;MATHEMATICAL BOLD CAPITAL ETA;Lu;0;L;<font> 0397;;;;N;;;;;\n1D6AF;MATHEMATICAL BOLD CAPITAL THETA;Lu;0;L;<font> 0398;;;;N;;;;;\n1D6B0;MATHEMATICAL BOLD CAPITAL IOTA;Lu;0;L;<font> 0399;;;;N;;;;;\n1D6B1;MATHEMATICAL BOLD CAPITAL KAPPA;Lu;0;L;<font> 039A;;;;N;;;;;\n1D6B2;MATHEMATICAL BOLD CAPITAL LAMDA;Lu;0;L;<font> 039B;;;;N;;;;;\n1D6B3;MATHEMATICAL BOLD CAPITAL MU;Lu;0;L;<font> 039C;;;;N;;;;;\n1D6B4;MATHEMATICAL BOLD CAPITAL NU;Lu;0;L;<font> 039D;;;;N;;;;;\n1D6B5;MATHEMATICAL BOLD CAPITAL XI;Lu;0;L;<font> 039E;;;;N;;;;;\n1D6B6;MATHEMATICAL BOLD CAPITAL OMICRON;Lu;0;L;<font> 039F;;;;N;;;;;\n1D6B7;MATHEMATICAL BOLD CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n1D6B8;MATHEMATICAL BOLD CAPITAL RHO;Lu;0;L;<font> 03A1;;;;N;;;;;\n1D6B9;MATHEMATICAL BOLD CAPITAL THETA SYMBOL;Lu;0;L;<font> 03F4;;;;N;;;;;\n1D6BA;MATHEMATICAL BOLD CAPITAL SIGMA;Lu;0;L;<font> 03A3;;;;N;;;;;\n1D6BB;MATHEMATICAL BOLD CAPITAL TAU;Lu;0;L;<font> 03A4;;;;N;;;;;\n1D6BC;MATHEMATICAL BOLD CAPITAL UPSILON;Lu;0;L;<font> 03A5;;;;N;;;;;\n1D6BD;MATHEMATICAL BOLD CAPITAL PHI;Lu;0;L;<font> 03A6;;;;N;;;;;\n1D6BE;MATHEMATICAL BOLD CAPITAL CHI;Lu;0;L;<font> 03A7;;;;N;;;;;\n1D6BF;MATHEMATICAL BOLD CAPITAL PSI;Lu;0;L;<font> 03A8;;;;N;;;;;\n1D6C0;MATHEMATICAL BOLD CAPITAL OMEGA;Lu;0;L;<font> 03A9;;;;N;;;;;\n1D6C1;MATHEMATICAL BOLD NABLA;Sm;0;L;<font> 2207;;;;N;;;;;\n1D6C2;MATHEMATICAL BOLD SMALL ALPHA;Ll;0;L;<font> 03B1;;;;N;;;;;\n1D6C3;MATHEMATICAL BOLD SMALL BETA;Ll;0;L;<font> 03B2;;;;N;;;;;\n1D6C4;MATHEMATICAL BOLD SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n1D6C5;MATHEMATICAL BOLD SMALL DELTA;Ll;0;L;<font> 03B4;;;;N;;;;;\n1D6C6;MATHEMATICAL BOLD SMALL EPSILON;Ll;0;L;<font> 03B5;;;;N;;;;;\n1D6C7;MATHEMATICAL BOLD SMALL ZETA;Ll;0;L;<font> 03B6;;;;N;;;;;\n1D6C8;MATHEMATICAL BOLD SMALL ETA;Ll;0;L;<font> 03B7;;;;N;;;;;\n1D6C9;MATHEMATICAL BOLD SMALL THETA;Ll;0;L;<font> 03B8;;;;N;;;;;\n1D6CA;MATHEMATICAL BOLD SMALL IOTA;Ll;0;L;<font> 03B9;;;;N;;;;;\n1D6CB;MATHEMATICAL BOLD SMALL KAPPA;Ll;0;L;<font> 03BA;;;;N;;;;;\n1D6CC;MATHEMATICAL BOLD SMALL LAMDA;Ll;0;L;<font> 03BB;;;;N;;;;;\n1D6CD;MATHEMATICAL BOLD SMALL MU;Ll;0;L;<font> 03BC;;;;N;;;;;\n1D6CE;MATHEMATICAL BOLD SMALL NU;Ll;0;L;<font> 03BD;;;;N;;;;;\n1D6CF;MATHEMATICAL BOLD SMALL XI;Ll;0;L;<font> 03BE;;;;N;;;;;\n1D6D0;MATHEMATICAL BOLD SMALL OMICRON;Ll;0;L;<font> 03BF;;;;N;;;;;\n1D6D1;MATHEMATICAL BOLD SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n1D6D2;MATHEMATICAL BOLD SMALL RHO;Ll;0;L;<font> 03C1;;;;N;;;;;\n1D6D3;MATHEMATICAL BOLD SMALL FINAL SIGMA;Ll;0;L;<font> 03C2;;;;N;;;;;\n1D6D4;MATHEMATICAL BOLD SMALL SIGMA;Ll;0;L;<font> 03C3;;;;N;;;;;\n1D6D5;MATHEMATICAL BOLD SMALL TAU;Ll;0;L;<font> 03C4;;;;N;;;;;\n1D6D6;MATHEMATICAL BOLD SMALL UPSILON;Ll;0;L;<font> 03C5;;;;N;;;;;\n1D6D7;MATHEMATICAL BOLD SMALL PHI;Ll;0;L;<font> 03C6;;;;N;;;;;\n1D6D8;MATHEMATICAL BOLD SMALL CHI;Ll;0;L;<font> 03C7;;;;N;;;;;\n1D6D9;MATHEMATICAL BOLD SMALL PSI;Ll;0;L;<font> 03C8;;;;N;;;;;\n1D6DA;MATHEMATICAL BOLD SMALL OMEGA;Ll;0;L;<font> 03C9;;;;N;;;;;\n1D6DB;MATHEMATICAL BOLD PARTIAL DIFFERENTIAL;Sm;0;ON;<font> 2202;;;;Y;;;;;\n1D6DC;MATHEMATICAL BOLD EPSILON SYMBOL;Ll;0;L;<font> 03F5;;;;N;;;;;\n1D6DD;MATHEMATICAL BOLD THETA SYMBOL;Ll;0;L;<font> 03D1;;;;N;;;;;\n1D6DE;MATHEMATICAL BOLD KAPPA SYMBOL;Ll;0;L;<font> 03F0;;;;N;;;;;\n1D6DF;MATHEMATICAL BOLD PHI SYMBOL;Ll;0;L;<font> 03D5;;;;N;;;;;\n1D6E0;MATHEMATICAL BOLD RHO SYMBOL;Ll;0;L;<font> 03F1;;;;N;;;;;\n1D6E1;MATHEMATICAL BOLD PI SYMBOL;Ll;0;L;<font> 03D6;;;;N;;;;;\n1D6E2;MATHEMATICAL ITALIC CAPITAL ALPHA;Lu;0;L;<font> 0391;;;;N;;;;;\n1D6E3;MATHEMATICAL ITALIC CAPITAL BETA;Lu;0;L;<font> 0392;;;;N;;;;;\n1D6E4;MATHEMATICAL ITALIC CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n1D6E5;MATHEMATICAL ITALIC CAPITAL DELTA;Lu;0;L;<font> 0394;;;;N;;;;;\n1D6E6;MATHEMATICAL ITALIC CAPITAL EPSILON;Lu;0;L;<font> 0395;;;;N;;;;;\n1D6E7;MATHEMATICAL ITALIC CAPITAL ZETA;Lu;0;L;<font> 0396;;;;N;;;;;\n1D6E8;MATHEMATICAL ITALIC CAPITAL ETA;Lu;0;L;<font> 0397;;;;N;;;;;\n1D6E9;MATHEMATICAL ITALIC CAPITAL THETA;Lu;0;L;<font> 0398;;;;N;;;;;\n1D6EA;MATHEMATICAL ITALIC CAPITAL IOTA;Lu;0;L;<font> 0399;;;;N;;;;;\n1D6EB;MATHEMATICAL ITALIC CAPITAL KAPPA;Lu;0;L;<font> 039A;;;;N;;;;;\n1D6EC;MATHEMATICAL ITALIC CAPITAL LAMDA;Lu;0;L;<font> 039B;;;;N;;;;;\n1D6ED;MATHEMATICAL ITALIC CAPITAL MU;Lu;0;L;<font> 039C;;;;N;;;;;\n1D6EE;MATHEMATICAL ITALIC CAPITAL NU;Lu;0;L;<font> 039D;;;;N;;;;;\n1D6EF;MATHEMATICAL ITALIC CAPITAL XI;Lu;0;L;<font> 039E;;;;N;;;;;\n1D6F0;MATHEMATICAL ITALIC CAPITAL OMICRON;Lu;0;L;<font> 039F;;;;N;;;;;\n1D6F1;MATHEMATICAL ITALIC CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n1D6F2;MATHEMATICAL ITALIC CAPITAL RHO;Lu;0;L;<font> 03A1;;;;N;;;;;\n1D6F3;MATHEMATICAL ITALIC CAPITAL THETA SYMBOL;Lu;0;L;<font> 03F4;;;;N;;;;;\n1D6F4;MATHEMATICAL ITALIC CAPITAL SIGMA;Lu;0;L;<font> 03A3;;;;N;;;;;\n1D6F5;MATHEMATICAL ITALIC CAPITAL TAU;Lu;0;L;<font> 03A4;;;;N;;;;;\n1D6F6;MATHEMATICAL ITALIC CAPITAL UPSILON;Lu;0;L;<font> 03A5;;;;N;;;;;\n1D6F7;MATHEMATICAL ITALIC CAPITAL PHI;Lu;0;L;<font> 03A6;;;;N;;;;;\n1D6F8;MATHEMATICAL ITALIC CAPITAL CHI;Lu;0;L;<font> 03A7;;;;N;;;;;\n1D6F9;MATHEMATICAL ITALIC CAPITAL PSI;Lu;0;L;<font> 03A8;;;;N;;;;;\n1D6FA;MATHEMATICAL ITALIC CAPITAL OMEGA;Lu;0;L;<font> 03A9;;;;N;;;;;\n1D6FB;MATHEMATICAL ITALIC NABLA;Sm;0;L;<font> 2207;;;;N;;;;;\n1D6FC;MATHEMATICAL ITALIC SMALL ALPHA;Ll;0;L;<font> 03B1;;;;N;;;;;\n1D6FD;MATHEMATICAL ITALIC SMALL BETA;Ll;0;L;<font> 03B2;;;;N;;;;;\n1D6FE;MATHEMATICAL ITALIC SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n1D6FF;MATHEMATICAL ITALIC SMALL DELTA;Ll;0;L;<font> 03B4;;;;N;;;;;\n1D700;MATHEMATICAL ITALIC SMALL EPSILON;Ll;0;L;<font> 03B5;;;;N;;;;;\n1D701;MATHEMATICAL ITALIC SMALL ZETA;Ll;0;L;<font> 03B6;;;;N;;;;;\n1D702;MATHEMATICAL ITALIC SMALL ETA;Ll;0;L;<font> 03B7;;;;N;;;;;\n1D703;MATHEMATICAL ITALIC SMALL THETA;Ll;0;L;<font> 03B8;;;;N;;;;;\n1D704;MATHEMATICAL ITALIC SMALL IOTA;Ll;0;L;<font> 03B9;;;;N;;;;;\n1D705;MATHEMATICAL ITALIC SMALL KAPPA;Ll;0;L;<font> 03BA;;;;N;;;;;\n1D706;MATHEMATICAL ITALIC SMALL LAMDA;Ll;0;L;<font> 03BB;;;;N;;;;;\n1D707;MATHEMATICAL ITALIC SMALL MU;Ll;0;L;<font> 03BC;;;;N;;;;;\n1D708;MATHEMATICAL ITALIC SMALL NU;Ll;0;L;<font> 03BD;;;;N;;;;;\n1D709;MATHEMATICAL ITALIC SMALL XI;Ll;0;L;<font> 03BE;;;;N;;;;;\n1D70A;MATHEMATICAL ITALIC SMALL OMICRON;Ll;0;L;<font> 03BF;;;;N;;;;;\n1D70B;MATHEMATICAL ITALIC SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n1D70C;MATHEMATICAL ITALIC SMALL RHO;Ll;0;L;<font> 03C1;;;;N;;;;;\n1D70D;MATHEMATICAL ITALIC SMALL FINAL SIGMA;Ll;0;L;<font> 03C2;;;;N;;;;;\n1D70E;MATHEMATICAL ITALIC SMALL SIGMA;Ll;0;L;<font> 03C3;;;;N;;;;;\n1D70F;MATHEMATICAL ITALIC SMALL TAU;Ll;0;L;<font> 03C4;;;;N;;;;;\n1D710;MATHEMATICAL ITALIC SMALL UPSILON;Ll;0;L;<font> 03C5;;;;N;;;;;\n1D711;MATHEMATICAL ITALIC SMALL PHI;Ll;0;L;<font> 03C6;;;;N;;;;;\n1D712;MATHEMATICAL ITALIC SMALL CHI;Ll;0;L;<font> 03C7;;;;N;;;;;\n1D713;MATHEMATICAL ITALIC SMALL PSI;Ll;0;L;<font> 03C8;;;;N;;;;;\n1D714;MATHEMATICAL ITALIC SMALL OMEGA;Ll;0;L;<font> 03C9;;;;N;;;;;\n1D715;MATHEMATICAL ITALIC PARTIAL DIFFERENTIAL;Sm;0;ON;<font> 2202;;;;Y;;;;;\n1D716;MATHEMATICAL ITALIC EPSILON SYMBOL;Ll;0;L;<font> 03F5;;;;N;;;;;\n1D717;MATHEMATICAL ITALIC THETA SYMBOL;Ll;0;L;<font> 03D1;;;;N;;;;;\n1D718;MATHEMATICAL ITALIC KAPPA SYMBOL;Ll;0;L;<font> 03F0;;;;N;;;;;\n1D719;MATHEMATICAL ITALIC PHI SYMBOL;Ll;0;L;<font> 03D5;;;;N;;;;;\n1D71A;MATHEMATICAL ITALIC RHO SYMBOL;Ll;0;L;<font> 03F1;;;;N;;;;;\n1D71B;MATHEMATICAL ITALIC PI SYMBOL;Ll;0;L;<font> 03D6;;;;N;;;;;\n1D71C;MATHEMATICAL BOLD ITALIC CAPITAL ALPHA;Lu;0;L;<font> 0391;;;;N;;;;;\n1D71D;MATHEMATICAL BOLD ITALIC CAPITAL BETA;Lu;0;L;<font> 0392;;;;N;;;;;\n1D71E;MATHEMATICAL BOLD ITALIC CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n1D71F;MATHEMATICAL BOLD ITALIC CAPITAL DELTA;Lu;0;L;<font> 0394;;;;N;;;;;\n1D720;MATHEMATICAL BOLD ITALIC CAPITAL EPSILON;Lu;0;L;<font> 0395;;;;N;;;;;\n1D721;MATHEMATICAL BOLD ITALIC CAPITAL ZETA;Lu;0;L;<font> 0396;;;;N;;;;;\n1D722;MATHEMATICAL BOLD ITALIC CAPITAL ETA;Lu;0;L;<font> 0397;;;;N;;;;;\n1D723;MATHEMATICAL BOLD ITALIC CAPITAL THETA;Lu;0;L;<font> 0398;;;;N;;;;;\n1D724;MATHEMATICAL BOLD ITALIC CAPITAL IOTA;Lu;0;L;<font> 0399;;;;N;;;;;\n1D725;MATHEMATICAL BOLD ITALIC CAPITAL KAPPA;Lu;0;L;<font> 039A;;;;N;;;;;\n1D726;MATHEMATICAL BOLD ITALIC CAPITAL LAMDA;Lu;0;L;<font> 039B;;;;N;;;;;\n1D727;MATHEMATICAL BOLD ITALIC CAPITAL MU;Lu;0;L;<font> 039C;;;;N;;;;;\n1D728;MATHEMATICAL BOLD ITALIC CAPITAL NU;Lu;0;L;<font> 039D;;;;N;;;;;\n1D729;MATHEMATICAL BOLD ITALIC CAPITAL XI;Lu;0;L;<font> 039E;;;;N;;;;;\n1D72A;MATHEMATICAL BOLD ITALIC CAPITAL OMICRON;Lu;0;L;<font> 039F;;;;N;;;;;\n1D72B;MATHEMATICAL BOLD ITALIC CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n1D72C;MATHEMATICAL BOLD ITALIC CAPITAL RHO;Lu;0;L;<font> 03A1;;;;N;;;;;\n1D72D;MATHEMATICAL BOLD ITALIC CAPITAL THETA SYMBOL;Lu;0;L;<font> 03F4;;;;N;;;;;\n1D72E;MATHEMATICAL BOLD ITALIC CAPITAL SIGMA;Lu;0;L;<font> 03A3;;;;N;;;;;\n1D72F;MATHEMATICAL BOLD ITALIC CAPITAL TAU;Lu;0;L;<font> 03A4;;;;N;;;;;\n1D730;MATHEMATICAL BOLD ITALIC CAPITAL UPSILON;Lu;0;L;<font> 03A5;;;;N;;;;;\n1D731;MATHEMATICAL BOLD ITALIC CAPITAL PHI;Lu;0;L;<font> 03A6;;;;N;;;;;\n1D732;MATHEMATICAL BOLD ITALIC CAPITAL CHI;Lu;0;L;<font> 03A7;;;;N;;;;;\n1D733;MATHEMATICAL BOLD ITALIC CAPITAL PSI;Lu;0;L;<font> 03A8;;;;N;;;;;\n1D734;MATHEMATICAL BOLD ITALIC CAPITAL OMEGA;Lu;0;L;<font> 03A9;;;;N;;;;;\n1D735;MATHEMATICAL BOLD ITALIC NABLA;Sm;0;L;<font> 2207;;;;N;;;;;\n1D736;MATHEMATICAL BOLD ITALIC SMALL ALPHA;Ll;0;L;<font> 03B1;;;;N;;;;;\n1D737;MATHEMATICAL BOLD ITALIC SMALL BETA;Ll;0;L;<font> 03B2;;;;N;;;;;\n1D738;MATHEMATICAL BOLD ITALIC SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n1D739;MATHEMATICAL BOLD ITALIC SMALL DELTA;Ll;0;L;<font> 03B4;;;;N;;;;;\n1D73A;MATHEMATICAL BOLD ITALIC SMALL EPSILON;Ll;0;L;<font> 03B5;;;;N;;;;;\n1D73B;MATHEMATICAL BOLD ITALIC SMALL ZETA;Ll;0;L;<font> 03B6;;;;N;;;;;\n1D73C;MATHEMATICAL BOLD ITALIC SMALL ETA;Ll;0;L;<font> 03B7;;;;N;;;;;\n1D73D;MATHEMATICAL BOLD ITALIC SMALL THETA;Ll;0;L;<font> 03B8;;;;N;;;;;\n1D73E;MATHEMATICAL BOLD ITALIC SMALL IOTA;Ll;0;L;<font> 03B9;;;;N;;;;;\n1D73F;MATHEMATICAL BOLD ITALIC SMALL KAPPA;Ll;0;L;<font> 03BA;;;;N;;;;;\n1D740;MATHEMATICAL BOLD ITALIC SMALL LAMDA;Ll;0;L;<font> 03BB;;;;N;;;;;\n1D741;MATHEMATICAL BOLD ITALIC SMALL MU;Ll;0;L;<font> 03BC;;;;N;;;;;\n1D742;MATHEMATICAL BOLD ITALIC SMALL NU;Ll;0;L;<font> 03BD;;;;N;;;;;\n1D743;MATHEMATICAL BOLD ITALIC SMALL XI;Ll;0;L;<font> 03BE;;;;N;;;;;\n1D744;MATHEMATICAL BOLD ITALIC SMALL OMICRON;Ll;0;L;<font> 03BF;;;;N;;;;;\n1D745;MATHEMATICAL BOLD ITALIC SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n1D746;MATHEMATICAL BOLD ITALIC SMALL RHO;Ll;0;L;<font> 03C1;;;;N;;;;;\n1D747;MATHEMATICAL BOLD ITALIC SMALL FINAL SIGMA;Ll;0;L;<font> 03C2;;;;N;;;;;\n1D748;MATHEMATICAL BOLD ITALIC SMALL SIGMA;Ll;0;L;<font> 03C3;;;;N;;;;;\n1D749;MATHEMATICAL BOLD ITALIC SMALL TAU;Ll;0;L;<font> 03C4;;;;N;;;;;\n1D74A;MATHEMATICAL BOLD ITALIC SMALL UPSILON;Ll;0;L;<font> 03C5;;;;N;;;;;\n1D74B;MATHEMATICAL BOLD ITALIC SMALL PHI;Ll;0;L;<font> 03C6;;;;N;;;;;\n1D74C;MATHEMATICAL BOLD ITALIC SMALL CHI;Ll;0;L;<font> 03C7;;;;N;;;;;\n1D74D;MATHEMATICAL BOLD ITALIC SMALL PSI;Ll;0;L;<font> 03C8;;;;N;;;;;\n1D74E;MATHEMATICAL BOLD ITALIC SMALL OMEGA;Ll;0;L;<font> 03C9;;;;N;;;;;\n1D74F;MATHEMATICAL BOLD ITALIC PARTIAL DIFFERENTIAL;Sm;0;ON;<font> 2202;;;;Y;;;;;\n1D750;MATHEMATICAL BOLD ITALIC EPSILON SYMBOL;Ll;0;L;<font> 03F5;;;;N;;;;;\n1D751;MATHEMATICAL BOLD ITALIC THETA SYMBOL;Ll;0;L;<font> 03D1;;;;N;;;;;\n1D752;MATHEMATICAL BOLD ITALIC KAPPA SYMBOL;Ll;0;L;<font> 03F0;;;;N;;;;;\n1D753;MATHEMATICAL BOLD ITALIC PHI SYMBOL;Ll;0;L;<font> 03D5;;;;N;;;;;\n1D754;MATHEMATICAL BOLD ITALIC RHO SYMBOL;Ll;0;L;<font> 03F1;;;;N;;;;;\n1D755;MATHEMATICAL BOLD ITALIC PI SYMBOL;Ll;0;L;<font> 03D6;;;;N;;;;;\n1D756;MATHEMATICAL SANS-SERIF BOLD CAPITAL ALPHA;Lu;0;L;<font> 0391;;;;N;;;;;\n1D757;MATHEMATICAL SANS-SERIF BOLD CAPITAL BETA;Lu;0;L;<font> 0392;;;;N;;;;;\n1D758;MATHEMATICAL SANS-SERIF BOLD CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n1D759;MATHEMATICAL SANS-SERIF BOLD CAPITAL DELTA;Lu;0;L;<font> 0394;;;;N;;;;;\n1D75A;MATHEMATICAL SANS-SERIF BOLD CAPITAL EPSILON;Lu;0;L;<font> 0395;;;;N;;;;;\n1D75B;MATHEMATICAL SANS-SERIF BOLD CAPITAL ZETA;Lu;0;L;<font> 0396;;;;N;;;;;\n1D75C;MATHEMATICAL SANS-SERIF BOLD CAPITAL ETA;Lu;0;L;<font> 0397;;;;N;;;;;\n1D75D;MATHEMATICAL SANS-SERIF BOLD CAPITAL THETA;Lu;0;L;<font> 0398;;;;N;;;;;\n1D75E;MATHEMATICAL SANS-SERIF BOLD CAPITAL IOTA;Lu;0;L;<font> 0399;;;;N;;;;;\n1D75F;MATHEMATICAL SANS-SERIF BOLD CAPITAL KAPPA;Lu;0;L;<font> 039A;;;;N;;;;;\n1D760;MATHEMATICAL SANS-SERIF BOLD CAPITAL LAMDA;Lu;0;L;<font> 039B;;;;N;;;;;\n1D761;MATHEMATICAL SANS-SERIF BOLD CAPITAL MU;Lu;0;L;<font> 039C;;;;N;;;;;\n1D762;MATHEMATICAL SANS-SERIF BOLD CAPITAL NU;Lu;0;L;<font> 039D;;;;N;;;;;\n1D763;MATHEMATICAL SANS-SERIF BOLD CAPITAL XI;Lu;0;L;<font> 039E;;;;N;;;;;\n1D764;MATHEMATICAL SANS-SERIF BOLD CAPITAL OMICRON;Lu;0;L;<font> 039F;;;;N;;;;;\n1D765;MATHEMATICAL SANS-SERIF BOLD CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n1D766;MATHEMATICAL SANS-SERIF BOLD CAPITAL RHO;Lu;0;L;<font> 03A1;;;;N;;;;;\n1D767;MATHEMATICAL SANS-SERIF BOLD CAPITAL THETA SYMBOL;Lu;0;L;<font> 03F4;;;;N;;;;;\n1D768;MATHEMATICAL SANS-SERIF BOLD CAPITAL SIGMA;Lu;0;L;<font> 03A3;;;;N;;;;;\n1D769;MATHEMATICAL SANS-SERIF BOLD CAPITAL TAU;Lu;0;L;<font> 03A4;;;;N;;;;;\n1D76A;MATHEMATICAL SANS-SERIF BOLD CAPITAL UPSILON;Lu;0;L;<font> 03A5;;;;N;;;;;\n1D76B;MATHEMATICAL SANS-SERIF BOLD CAPITAL PHI;Lu;0;L;<font> 03A6;;;;N;;;;;\n1D76C;MATHEMATICAL SANS-SERIF BOLD CAPITAL CHI;Lu;0;L;<font> 03A7;;;;N;;;;;\n1D76D;MATHEMATICAL SANS-SERIF BOLD CAPITAL PSI;Lu;0;L;<font> 03A8;;;;N;;;;;\n1D76E;MATHEMATICAL SANS-SERIF BOLD CAPITAL OMEGA;Lu;0;L;<font> 03A9;;;;N;;;;;\n1D76F;MATHEMATICAL SANS-SERIF BOLD NABLA;Sm;0;L;<font> 2207;;;;N;;;;;\n1D770;MATHEMATICAL SANS-SERIF BOLD SMALL ALPHA;Ll;0;L;<font> 03B1;;;;N;;;;;\n1D771;MATHEMATICAL SANS-SERIF BOLD SMALL BETA;Ll;0;L;<font> 03B2;;;;N;;;;;\n1D772;MATHEMATICAL SANS-SERIF BOLD SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n1D773;MATHEMATICAL SANS-SERIF BOLD SMALL DELTA;Ll;0;L;<font> 03B4;;;;N;;;;;\n1D774;MATHEMATICAL SANS-SERIF BOLD SMALL EPSILON;Ll;0;L;<font> 03B5;;;;N;;;;;\n1D775;MATHEMATICAL SANS-SERIF BOLD SMALL ZETA;Ll;0;L;<font> 03B6;;;;N;;;;;\n1D776;MATHEMATICAL SANS-SERIF BOLD SMALL ETA;Ll;0;L;<font> 03B7;;;;N;;;;;\n1D777;MATHEMATICAL SANS-SERIF BOLD SMALL THETA;Ll;0;L;<font> 03B8;;;;N;;;;;\n1D778;MATHEMATICAL SANS-SERIF BOLD SMALL IOTA;Ll;0;L;<font> 03B9;;;;N;;;;;\n1D779;MATHEMATICAL SANS-SERIF BOLD SMALL KAPPA;Ll;0;L;<font> 03BA;;;;N;;;;;\n1D77A;MATHEMATICAL SANS-SERIF BOLD SMALL LAMDA;Ll;0;L;<font> 03BB;;;;N;;;;;\n1D77B;MATHEMATICAL SANS-SERIF BOLD SMALL MU;Ll;0;L;<font> 03BC;;;;N;;;;;\n1D77C;MATHEMATICAL SANS-SERIF BOLD SMALL NU;Ll;0;L;<font> 03BD;;;;N;;;;;\n1D77D;MATHEMATICAL SANS-SERIF BOLD SMALL XI;Ll;0;L;<font> 03BE;;;;N;;;;;\n1D77E;MATHEMATICAL SANS-SERIF BOLD SMALL OMICRON;Ll;0;L;<font> 03BF;;;;N;;;;;\n1D77F;MATHEMATICAL SANS-SERIF BOLD SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n1D780;MATHEMATICAL SANS-SERIF BOLD SMALL RHO;Ll;0;L;<font> 03C1;;;;N;;;;;\n1D781;MATHEMATICAL SANS-SERIF BOLD SMALL FINAL SIGMA;Ll;0;L;<font> 03C2;;;;N;;;;;\n1D782;MATHEMATICAL SANS-SERIF BOLD SMALL SIGMA;Ll;0;L;<font> 03C3;;;;N;;;;;\n1D783;MATHEMATICAL SANS-SERIF BOLD SMALL TAU;Ll;0;L;<font> 03C4;;;;N;;;;;\n1D784;MATHEMATICAL SANS-SERIF BOLD SMALL UPSILON;Ll;0;L;<font> 03C5;;;;N;;;;;\n1D785;MATHEMATICAL SANS-SERIF BOLD SMALL PHI;Ll;0;L;<font> 03C6;;;;N;;;;;\n1D786;MATHEMATICAL SANS-SERIF BOLD SMALL CHI;Ll;0;L;<font> 03C7;;;;N;;;;;\n1D787;MATHEMATICAL SANS-SERIF BOLD SMALL PSI;Ll;0;L;<font> 03C8;;;;N;;;;;\n1D788;MATHEMATICAL SANS-SERIF BOLD SMALL OMEGA;Ll;0;L;<font> 03C9;;;;N;;;;;\n1D789;MATHEMATICAL SANS-SERIF BOLD PARTIAL DIFFERENTIAL;Sm;0;ON;<font> 2202;;;;Y;;;;;\n1D78A;MATHEMATICAL SANS-SERIF BOLD EPSILON SYMBOL;Ll;0;L;<font> 03F5;;;;N;;;;;\n1D78B;MATHEMATICAL SANS-SERIF BOLD THETA SYMBOL;Ll;0;L;<font> 03D1;;;;N;;;;;\n1D78C;MATHEMATICAL SANS-SERIF BOLD KAPPA SYMBOL;Ll;0;L;<font> 03F0;;;;N;;;;;\n1D78D;MATHEMATICAL SANS-SERIF BOLD PHI SYMBOL;Ll;0;L;<font> 03D5;;;;N;;;;;\n1D78E;MATHEMATICAL SANS-SERIF BOLD RHO SYMBOL;Ll;0;L;<font> 03F1;;;;N;;;;;\n1D78F;MATHEMATICAL SANS-SERIF BOLD PI SYMBOL;Ll;0;L;<font> 03D6;;;;N;;;;;\n1D790;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL ALPHA;Lu;0;L;<font> 0391;;;;N;;;;;\n1D791;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL BETA;Lu;0;L;<font> 0392;;;;N;;;;;\n1D792;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL GAMMA;Lu;0;L;<font> 0393;;;;N;;;;;\n1D793;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL DELTA;Lu;0;L;<font> 0394;;;;N;;;;;\n1D794;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL EPSILON;Lu;0;L;<font> 0395;;;;N;;;;;\n1D795;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL ZETA;Lu;0;L;<font> 0396;;;;N;;;;;\n1D796;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL ETA;Lu;0;L;<font> 0397;;;;N;;;;;\n1D797;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL THETA;Lu;0;L;<font> 0398;;;;N;;;;;\n1D798;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL IOTA;Lu;0;L;<font> 0399;;;;N;;;;;\n1D799;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL KAPPA;Lu;0;L;<font> 039A;;;;N;;;;;\n1D79A;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL LAMDA;Lu;0;L;<font> 039B;;;;N;;;;;\n1D79B;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL MU;Lu;0;L;<font> 039C;;;;N;;;;;\n1D79C;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL NU;Lu;0;L;<font> 039D;;;;N;;;;;\n1D79D;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL XI;Lu;0;L;<font> 039E;;;;N;;;;;\n1D79E;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL OMICRON;Lu;0;L;<font> 039F;;;;N;;;;;\n1D79F;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL PI;Lu;0;L;<font> 03A0;;;;N;;;;;\n1D7A0;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL RHO;Lu;0;L;<font> 03A1;;;;N;;;;;\n1D7A1;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL THETA SYMBOL;Lu;0;L;<font> 03F4;;;;N;;;;;\n1D7A2;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL SIGMA;Lu;0;L;<font> 03A3;;;;N;;;;;\n1D7A3;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL TAU;Lu;0;L;<font> 03A4;;;;N;;;;;\n1D7A4;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL UPSILON;Lu;0;L;<font> 03A5;;;;N;;;;;\n1D7A5;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL PHI;Lu;0;L;<font> 03A6;;;;N;;;;;\n1D7A6;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL CHI;Lu;0;L;<font> 03A7;;;;N;;;;;\n1D7A7;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL PSI;Lu;0;L;<font> 03A8;;;;N;;;;;\n1D7A8;MATHEMATICAL SANS-SERIF BOLD ITALIC CAPITAL OMEGA;Lu;0;L;<font> 03A9;;;;N;;;;;\n1D7A9;MATHEMATICAL SANS-SERIF BOLD ITALIC NABLA;Sm;0;L;<font> 2207;;;;N;;;;;\n1D7AA;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL ALPHA;Ll;0;L;<font> 03B1;;;;N;;;;;\n1D7AB;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL BETA;Ll;0;L;<font> 03B2;;;;N;;;;;\n1D7AC;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL GAMMA;Ll;0;L;<font> 03B3;;;;N;;;;;\n1D7AD;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL DELTA;Ll;0;L;<font> 03B4;;;;N;;;;;\n1D7AE;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL EPSILON;Ll;0;L;<font> 03B5;;;;N;;;;;\n1D7AF;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL ZETA;Ll;0;L;<font> 03B6;;;;N;;;;;\n1D7B0;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL ETA;Ll;0;L;<font> 03B7;;;;N;;;;;\n1D7B1;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL THETA;Ll;0;L;<font> 03B8;;;;N;;;;;\n1D7B2;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL IOTA;Ll;0;L;<font> 03B9;;;;N;;;;;\n1D7B3;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL KAPPA;Ll;0;L;<font> 03BA;;;;N;;;;;\n1D7B4;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL LAMDA;Ll;0;L;<font> 03BB;;;;N;;;;;\n1D7B5;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL MU;Ll;0;L;<font> 03BC;;;;N;;;;;\n1D7B6;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL NU;Ll;0;L;<font> 03BD;;;;N;;;;;\n1D7B7;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL XI;Ll;0;L;<font> 03BE;;;;N;;;;;\n1D7B8;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL OMICRON;Ll;0;L;<font> 03BF;;;;N;;;;;\n1D7B9;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL PI;Ll;0;L;<font> 03C0;;;;N;;;;;\n1D7BA;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL RHO;Ll;0;L;<font> 03C1;;;;N;;;;;\n1D7BB;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL FINAL SIGMA;Ll;0;L;<font> 03C2;;;;N;;;;;\n1D7BC;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL SIGMA;Ll;0;L;<font> 03C3;;;;N;;;;;\n1D7BD;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL TAU;Ll;0;L;<font> 03C4;;;;N;;;;;\n1D7BE;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL UPSILON;Ll;0;L;<font> 03C5;;;;N;;;;;\n1D7BF;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL PHI;Ll;0;L;<font> 03C6;;;;N;;;;;\n1D7C0;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL CHI;Ll;0;L;<font> 03C7;;;;N;;;;;\n1D7C1;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL PSI;Ll;0;L;<font> 03C8;;;;N;;;;;\n1D7C2;MATHEMATICAL SANS-SERIF BOLD ITALIC SMALL OMEGA;Ll;0;L;<font> 03C9;;;;N;;;;;\n1D7C3;MATHEMATICAL SANS-SERIF BOLD ITALIC PARTIAL DIFFERENTIAL;Sm;0;ON;<font> 2202;;;;Y;;;;;\n1D7C4;MATHEMATICAL SANS-SERIF BOLD ITALIC EPSILON SYMBOL;Ll;0;L;<font> 03F5;;;;N;;;;;\n1D7C5;MATHEMATICAL SANS-SERIF BOLD ITALIC THETA SYMBOL;Ll;0;L;<font> 03D1;;;;N;;;;;\n1D7C6;MATHEMATICAL SANS-SERIF BOLD ITALIC KAPPA SYMBOL;Ll;0;L;<font> 03F0;;;;N;;;;;\n1D7C7;MATHEMATICAL SANS-SERIF BOLD ITALIC PHI SYMBOL;Ll;0;L;<font> 03D5;;;;N;;;;;\n1D7C8;MATHEMATICAL SANS-SERIF BOLD ITALIC RHO SYMBOL;Ll;0;L;<font> 03F1;;;;N;;;;;\n1D7C9;MATHEMATICAL SANS-SERIF BOLD ITALIC PI SYMBOL;Ll;0;L;<font> 03D6;;;;N;;;;;\n1D7CA;MATHEMATICAL BOLD CAPITAL DIGAMMA;Lu;0;L;<font> 03DC;;;;N;;;;;\n1D7CB;MATHEMATICAL BOLD SMALL DIGAMMA;Ll;0;L;<font> 03DD;;;;N;;;;;\n1D7CE;MATHEMATICAL BOLD DIGIT ZERO;Nd;0;EN;<font> 0030;0;0;0;N;;;;;\n1D7CF;MATHEMATICAL BOLD DIGIT ONE;Nd;0;EN;<font> 0031;1;1;1;N;;;;;\n1D7D0;MATHEMATICAL BOLD DIGIT TWO;Nd;0;EN;<font> 0032;2;2;2;N;;;;;\n1D7D1;MATHEMATICAL BOLD DIGIT THREE;Nd;0;EN;<font> 0033;3;3;3;N;;;;;\n1D7D2;MATHEMATICAL BOLD DIGIT FOUR;Nd;0;EN;<font> 0034;4;4;4;N;;;;;\n1D7D3;MATHEMATICAL BOLD DIGIT FIVE;Nd;0;EN;<font> 0035;5;5;5;N;;;;;\n1D7D4;MATHEMATICAL BOLD DIGIT SIX;Nd;0;EN;<font> 0036;6;6;6;N;;;;;\n1D7D5;MATHEMATICAL BOLD DIGIT SEVEN;Nd;0;EN;<font> 0037;7;7;7;N;;;;;\n1D7D6;MATHEMATICAL BOLD DIGIT EIGHT;Nd;0;EN;<font> 0038;8;8;8;N;;;;;\n1D7D7;MATHEMATICAL BOLD DIGIT NINE;Nd;0;EN;<font> 0039;9;9;9;N;;;;;\n1D7D8;MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO;Nd;0;EN;<font> 0030;0;0;0;N;;;;;\n1D7D9;MATHEMATICAL DOUBLE-STRUCK DIGIT ONE;Nd;0;EN;<font> 0031;1;1;1;N;;;;;\n1D7DA;MATHEMATICAL DOUBLE-STRUCK DIGIT TWO;Nd;0;EN;<font> 0032;2;2;2;N;;;;;\n1D7DB;MATHEMATICAL DOUBLE-STRUCK DIGIT THREE;Nd;0;EN;<font> 0033;3;3;3;N;;;;;\n1D7DC;MATHEMATICAL DOUBLE-STRUCK DIGIT FOUR;Nd;0;EN;<font> 0034;4;4;4;N;;;;;\n1D7DD;MATHEMATICAL DOUBLE-STRUCK DIGIT FIVE;Nd;0;EN;<font> 0035;5;5;5;N;;;;;\n1D7DE;MATHEMATICAL DOUBLE-STRUCK DIGIT SIX;Nd;0;EN;<font> 0036;6;6;6;N;;;;;\n1D7DF;MATHEMATICAL DOUBLE-STRUCK DIGIT SEVEN;Nd;0;EN;<font> 0037;7;7;7;N;;;;;\n1D7E0;MATHEMATICAL DOUBLE-STRUCK DIGIT EIGHT;Nd;0;EN;<font> 0038;8;8;8;N;;;;;\n1D7E1;MATHEMATICAL DOUBLE-STRUCK DIGIT NINE;Nd;0;EN;<font> 0039;9;9;9;N;;;;;\n1D7E2;MATHEMATICAL SANS-SERIF DIGIT ZERO;Nd;0;EN;<font> 0030;0;0;0;N;;;;;\n1D7E3;MATHEMATICAL SANS-SERIF DIGIT ONE;Nd;0;EN;<font> 0031;1;1;1;N;;;;;\n1D7E4;MATHEMATICAL SANS-SERIF DIGIT TWO;Nd;0;EN;<font> 0032;2;2;2;N;;;;;\n1D7E5;MATHEMATICAL SANS-SERIF DIGIT THREE;Nd;0;EN;<font> 0033;3;3;3;N;;;;;\n1D7E6;MATHEMATICAL SANS-SERIF DIGIT FOUR;Nd;0;EN;<font> 0034;4;4;4;N;;;;;\n1D7E7;MATHEMATICAL SANS-SERIF DIGIT FIVE;Nd;0;EN;<font> 0035;5;5;5;N;;;;;\n1D7E8;MATHEMATICAL SANS-SERIF DIGIT SIX;Nd;0;EN;<font> 0036;6;6;6;N;;;;;\n1D7E9;MATHEMATICAL SANS-SERIF DIGIT SEVEN;Nd;0;EN;<font> 0037;7;7;7;N;;;;;\n1D7EA;MATHEMATICAL SANS-SERIF DIGIT EIGHT;Nd;0;EN;<font> 0038;8;8;8;N;;;;;\n1D7EB;MATHEMATICAL SANS-SERIF DIGIT NINE;Nd;0;EN;<font> 0039;9;9;9;N;;;;;\n1D7EC;MATHEMATICAL SANS-SERIF BOLD DIGIT ZERO;Nd;0;EN;<font> 0030;0;0;0;N;;;;;\n1D7ED;MATHEMATICAL SANS-SERIF BOLD DIGIT ONE;Nd;0;EN;<font> 0031;1;1;1;N;;;;;\n1D7EE;MATHEMATICAL SANS-SERIF BOLD DIGIT TWO;Nd;0;EN;<font> 0032;2;2;2;N;;;;;\n1D7EF;MATHEMATICAL SANS-SERIF BOLD DIGIT THREE;Nd;0;EN;<font> 0033;3;3;3;N;;;;;\n1D7F0;MATHEMATICAL SANS-SERIF BOLD DIGIT FOUR;Nd;0;EN;<font> 0034;4;4;4;N;;;;;\n1D7F1;MATHEMATICAL SANS-SERIF BOLD DIGIT FIVE;Nd;0;EN;<font> 0035;5;5;5;N;;;;;\n1D7F2;MATHEMATICAL SANS-SERIF BOLD DIGIT SIX;Nd;0;EN;<font> 0036;6;6;6;N;;;;;\n1D7F3;MATHEMATICAL SANS-SERIF BOLD DIGIT SEVEN;Nd;0;EN;<font> 0037;7;7;7;N;;;;;\n1D7F4;MATHEMATICAL SANS-SERIF BOLD DIGIT EIGHT;Nd;0;EN;<font> 0038;8;8;8;N;;;;;\n1D7F5;MATHEMATICAL SANS-SERIF BOLD DIGIT NINE;Nd;0;EN;<font> 0039;9;9;9;N;;;;;\n1D7F6;MATHEMATICAL MONOSPACE DIGIT ZERO;Nd;0;EN;<font> 0030;0;0;0;N;;;;;\n1D7F7;MATHEMATICAL MONOSPACE DIGIT ONE;Nd;0;EN;<font> 0031;1;1;1;N;;;;;\n1D7F8;MATHEMATICAL MONOSPACE DIGIT TWO;Nd;0;EN;<font> 0032;2;2;2;N;;;;;\n1D7F9;MATHEMATICAL MONOSPACE DIGIT THREE;Nd;0;EN;<font> 0033;3;3;3;N;;;;;\n1D7FA;MATHEMATICAL MONOSPACE DIGIT FOUR;Nd;0;EN;<font> 0034;4;4;4;N;;;;;\n1D7FB;MATHEMATICAL MONOSPACE DIGIT FIVE;Nd;0;EN;<font> 0035;5;5;5;N;;;;;\n1D7FC;MATHEMATICAL MONOSPACE DIGIT SIX;Nd;0;EN;<font> 0036;6;6;6;N;;;;;\n1D7FD;MATHEMATICAL MONOSPACE DIGIT SEVEN;Nd;0;EN;<font> 0037;7;7;7;N;;;;;\n1D7FE;MATHEMATICAL MONOSPACE DIGIT EIGHT;Nd;0;EN;<font> 0038;8;8;8;N;;;;;\n1D7FF;MATHEMATICAL MONOSPACE DIGIT NINE;Nd;0;EN;<font> 0039;9;9;9;N;;;;;\n1EE00;ARABIC MATHEMATICAL ALEF;Lo;0;AL;<font> 0627;;;;N;;;;;\n1EE01;ARABIC MATHEMATICAL BEH;Lo;0;AL;<font> 0628;;;;N;;;;;\n1EE02;ARABIC MATHEMATICAL JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EE03;ARABIC MATHEMATICAL DAL;Lo;0;AL;<font> 062F;;;;N;;;;;\n1EE05;ARABIC MATHEMATICAL WAW;Lo;0;AL;<font> 0648;;;;N;;;;;\n1EE06;ARABIC MATHEMATICAL ZAIN;Lo;0;AL;<font> 0632;;;;N;;;;;\n1EE07;ARABIC MATHEMATICAL HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EE08;ARABIC MATHEMATICAL TAH;Lo;0;AL;<font> 0637;;;;N;;;;;\n1EE09;ARABIC MATHEMATICAL YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EE0A;ARABIC MATHEMATICAL KAF;Lo;0;AL;<font> 0643;;;;N;;;;;\n1EE0B;ARABIC MATHEMATICAL LAM;Lo;0;AL;<font> 0644;;;;N;;;;;\n1EE0C;ARABIC MATHEMATICAL MEEM;Lo;0;AL;<font> 0645;;;;N;;;;;\n1EE0D;ARABIC MATHEMATICAL NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EE0E;ARABIC MATHEMATICAL SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EE0F;ARABIC MATHEMATICAL AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EE10;ARABIC MATHEMATICAL FEH;Lo;0;AL;<font> 0641;;;;N;;;;;\n1EE11;ARABIC MATHEMATICAL SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EE12;ARABIC MATHEMATICAL QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EE13;ARABIC MATHEMATICAL REH;Lo;0;AL;<font> 0631;;;;N;;;;;\n1EE14;ARABIC MATHEMATICAL SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EE15;ARABIC MATHEMATICAL TEH;Lo;0;AL;<font> 062A;;;;N;;;;;\n1EE16;ARABIC MATHEMATICAL THEH;Lo;0;AL;<font> 062B;;;;N;;;;;\n1EE17;ARABIC MATHEMATICAL KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EE18;ARABIC MATHEMATICAL THAL;Lo;0;AL;<font> 0630;;;;N;;;;;\n1EE19;ARABIC MATHEMATICAL DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EE1A;ARABIC MATHEMATICAL ZAH;Lo;0;AL;<font> 0638;;;;N;;;;;\n1EE1B;ARABIC MATHEMATICAL GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EE1C;ARABIC MATHEMATICAL DOTLESS BEH;Lo;0;AL;<font> 066E;;;;N;;;;;\n1EE1D;ARABIC MATHEMATICAL DOTLESS NOON;Lo;0;AL;<font> 06BA;;;;N;;;;;\n1EE1E;ARABIC MATHEMATICAL DOTLESS FEH;Lo;0;AL;<font> 06A1;;;;N;;;;;\n1EE1F;ARABIC MATHEMATICAL DOTLESS QAF;Lo;0;AL;<font> 066F;;;;N;;;;;\n1EE21;ARABIC MATHEMATICAL INITIAL BEH;Lo;0;AL;<font> 0628;;;;N;;;;;\n1EE22;ARABIC MATHEMATICAL INITIAL JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EE24;ARABIC MATHEMATICAL INITIAL HEH;Lo;0;AL;<font> 0647;;;;N;;;;;\n1EE27;ARABIC MATHEMATICAL INITIAL HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EE29;ARABIC MATHEMATICAL INITIAL YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EE2A;ARABIC MATHEMATICAL INITIAL KAF;Lo;0;AL;<font> 0643;;;;N;;;;;\n1EE2B;ARABIC MATHEMATICAL INITIAL LAM;Lo;0;AL;<font> 0644;;;;N;;;;;\n1EE2C;ARABIC MATHEMATICAL INITIAL MEEM;Lo;0;AL;<font> 0645;;;;N;;;;;\n1EE2D;ARABIC MATHEMATICAL INITIAL NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EE2E;ARABIC MATHEMATICAL INITIAL SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EE2F;ARABIC MATHEMATICAL INITIAL AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EE30;ARABIC MATHEMATICAL INITIAL FEH;Lo;0;AL;<font> 0641;;;;N;;;;;\n1EE31;ARABIC MATHEMATICAL INITIAL SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EE32;ARABIC MATHEMATICAL INITIAL QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EE34;ARABIC MATHEMATICAL INITIAL SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EE35;ARABIC MATHEMATICAL INITIAL TEH;Lo;0;AL;<font> 062A;;;;N;;;;;\n1EE36;ARABIC MATHEMATICAL INITIAL THEH;Lo;0;AL;<font> 062B;;;;N;;;;;\n1EE37;ARABIC MATHEMATICAL INITIAL KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EE39;ARABIC MATHEMATICAL INITIAL DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EE3B;ARABIC MATHEMATICAL INITIAL GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EE42;ARABIC MATHEMATICAL TAILED JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EE47;ARABIC MATHEMATICAL TAILED HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EE49;ARABIC MATHEMATICAL TAILED YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EE4B;ARABIC MATHEMATICAL TAILED LAM;Lo;0;AL;<font> 0644;;;;N;;;;;\n1EE4D;ARABIC MATHEMATICAL TAILED NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EE4E;ARABIC MATHEMATICAL TAILED SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EE4F;ARABIC MATHEMATICAL TAILED AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EE51;ARABIC MATHEMATICAL TAILED SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EE52;ARABIC MATHEMATICAL TAILED QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EE54;ARABIC MATHEMATICAL TAILED SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EE57;ARABIC MATHEMATICAL TAILED KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EE59;ARABIC MATHEMATICAL TAILED DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EE5B;ARABIC MATHEMATICAL TAILED GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EE5D;ARABIC MATHEMATICAL TAILED DOTLESS NOON;Lo;0;AL;<font> 06BA;;;;N;;;;;\n1EE5F;ARABIC MATHEMATICAL TAILED DOTLESS QAF;Lo;0;AL;<font> 066F;;;;N;;;;;\n1EE61;ARABIC MATHEMATICAL STRETCHED BEH;Lo;0;AL;<font> 0628;;;;N;;;;;\n1EE62;ARABIC MATHEMATICAL STRETCHED JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EE64;ARABIC MATHEMATICAL STRETCHED HEH;Lo;0;AL;<font> 0647;;;;N;;;;;\n1EE67;ARABIC MATHEMATICAL STRETCHED HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EE68;ARABIC MATHEMATICAL STRETCHED TAH;Lo;0;AL;<font> 0637;;;;N;;;;;\n1EE69;ARABIC MATHEMATICAL STRETCHED YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EE6A;ARABIC MATHEMATICAL STRETCHED KAF;Lo;0;AL;<font> 0643;;;;N;;;;;\n1EE6C;ARABIC MATHEMATICAL STRETCHED MEEM;Lo;0;AL;<font> 0645;;;;N;;;;;\n1EE6D;ARABIC MATHEMATICAL STRETCHED NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EE6E;ARABIC MATHEMATICAL STRETCHED SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EE6F;ARABIC MATHEMATICAL STRETCHED AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EE70;ARABIC MATHEMATICAL STRETCHED FEH;Lo;0;AL;<font> 0641;;;;N;;;;;\n1EE71;ARABIC MATHEMATICAL STRETCHED SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EE72;ARABIC MATHEMATICAL STRETCHED QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EE74;ARABIC MATHEMATICAL STRETCHED SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EE75;ARABIC MATHEMATICAL STRETCHED TEH;Lo;0;AL;<font> 062A;;;;N;;;;;\n1EE76;ARABIC MATHEMATICAL STRETCHED THEH;Lo;0;AL;<font> 062B;;;;N;;;;;\n1EE77;ARABIC MATHEMATICAL STRETCHED KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EE79;ARABIC MATHEMATICAL STRETCHED DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EE7A;ARABIC MATHEMATICAL STRETCHED ZAH;Lo;0;AL;<font> 0638;;;;N;;;;;\n1EE7B;ARABIC MATHEMATICAL STRETCHED GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EE7C;ARABIC MATHEMATICAL STRETCHED DOTLESS BEH;Lo;0;AL;<font> 066E;;;;N;;;;;\n1EE7E;ARABIC MATHEMATICAL STRETCHED DOTLESS FEH;Lo;0;AL;<font> 06A1;;;;N;;;;;\n1EE80;ARABIC MATHEMATICAL LOOPED ALEF;Lo;0;AL;<font> 0627;;;;N;;;;;\n1EE81;ARABIC MATHEMATICAL LOOPED BEH;Lo;0;AL;<font> 0628;;;;N;;;;;\n1EE82;ARABIC MATHEMATICAL LOOPED JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EE83;ARABIC MATHEMATICAL LOOPED DAL;Lo;0;AL;<font> 062F;;;;N;;;;;\n1EE84;ARABIC MATHEMATICAL LOOPED HEH;Lo;0;AL;<font> 0647;;;;N;;;;;\n1EE85;ARABIC MATHEMATICAL LOOPED WAW;Lo;0;AL;<font> 0648;;;;N;;;;;\n1EE86;ARABIC MATHEMATICAL LOOPED ZAIN;Lo;0;AL;<font> 0632;;;;N;;;;;\n1EE87;ARABIC MATHEMATICAL LOOPED HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EE88;ARABIC MATHEMATICAL LOOPED TAH;Lo;0;AL;<font> 0637;;;;N;;;;;\n1EE89;ARABIC MATHEMATICAL LOOPED YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EE8B;ARABIC MATHEMATICAL LOOPED LAM;Lo;0;AL;<font> 0644;;;;N;;;;;\n1EE8C;ARABIC MATHEMATICAL LOOPED MEEM;Lo;0;AL;<font> 0645;;;;N;;;;;\n1EE8D;ARABIC MATHEMATICAL LOOPED NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EE8E;ARABIC MATHEMATICAL LOOPED SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EE8F;ARABIC MATHEMATICAL LOOPED AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EE90;ARABIC MATHEMATICAL LOOPED FEH;Lo;0;AL;<font> 0641;;;;N;;;;;\n1EE91;ARABIC MATHEMATICAL LOOPED SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EE92;ARABIC MATHEMATICAL LOOPED QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EE93;ARABIC MATHEMATICAL LOOPED REH;Lo;0;AL;<font> 0631;;;;N;;;;;\n1EE94;ARABIC MATHEMATICAL LOOPED SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EE95;ARABIC MATHEMATICAL LOOPED TEH;Lo;0;AL;<font> 062A;;;;N;;;;;\n1EE96;ARABIC MATHEMATICAL LOOPED THEH;Lo;0;AL;<font> 062B;;;;N;;;;;\n1EE97;ARABIC MATHEMATICAL LOOPED KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EE98;ARABIC MATHEMATICAL LOOPED THAL;Lo;0;AL;<font> 0630;;;;N;;;;;\n1EE99;ARABIC MATHEMATICAL LOOPED DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EE9A;ARABIC MATHEMATICAL LOOPED ZAH;Lo;0;AL;<font> 0638;;;;N;;;;;\n1EE9B;ARABIC MATHEMATICAL LOOPED GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EEA1;ARABIC MATHEMATICAL DOUBLE-STRUCK BEH;Lo;0;AL;<font> 0628;;;;N;;;;;\n1EEA2;ARABIC MATHEMATICAL DOUBLE-STRUCK JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;\n1EEA3;ARABIC MATHEMATICAL DOUBLE-STRUCK DAL;Lo;0;AL;<font> 062F;;;;N;;;;;\n1EEA5;ARABIC MATHEMATICAL DOUBLE-STRUCK WAW;Lo;0;AL;<font> 0648;;;;N;;;;;\n1EEA6;ARABIC MATHEMATICAL DOUBLE-STRUCK ZAIN;Lo;0;AL;<font> 0632;;;;N;;;;;\n1EEA7;ARABIC MATHEMATICAL DOUBLE-STRUCK HAH;Lo;0;AL;<font> 062D;;;;N;;;;;\n1EEA8;ARABIC MATHEMATICAL DOUBLE-STRUCK TAH;Lo;0;AL;<font> 0637;;;;N;;;;;\n1EEA9;ARABIC MATHEMATICAL DOUBLE-STRUCK YEH;Lo;0;AL;<font> 064A;;;;N;;;;;\n1EEAB;ARABIC MATHEMATICAL DOUBLE-STRUCK LAM;Lo;0;AL;<font> 0644;;;;N;;;;;\n1EEAC;ARABIC MATHEMATICAL DOUBLE-STRUCK MEEM;Lo;0;AL;<font> 0645;;;;N;;;;;\n1EEAD;ARABIC MATHEMATICAL DOUBLE-STRUCK NOON;Lo;0;AL;<font> 0646;;;;N;;;;;\n1EEAE;ARABIC MATHEMATICAL DOUBLE-STRUCK SEEN;Lo;0;AL;<font> 0633;;;;N;;;;;\n1EEAF;ARABIC MATHEMATICAL DOUBLE-STRUCK AIN;Lo;0;AL;<font> 0639;;;;N;;;;;\n1EEB0;ARABIC MATHEMATICAL DOUBLE-STRUCK FEH;Lo;0;AL;<font> 0641;;;;N;;;;;\n1EEB1;ARABIC MATHEMATICAL DOUBLE-STRUCK SAD;Lo;0;AL;<font> 0635;;;;N;;;;;\n1EEB2;ARABIC MATHEMATICAL DOUBLE-STRUCK QAF;Lo;0;AL;<font> 0642;;;;N;;;;;\n1EEB3;ARABIC MATHEMATICAL DOUBLE-STRUCK REH;Lo;0;AL;<font> 0631;;;;N;;;;;\n1EEB4;ARABIC MATHEMATICAL DOUBLE-STRUCK SHEEN;Lo;0;AL;<font> 0634;;;;N;;;;;\n1EEB5;ARABIC MATHEMATICAL DOUBLE-STRUCK TEH;Lo;0;AL;<font> 062A;;;;N;;;;;\n1EEB6;ARABIC MATHEMATICAL DOUBLE-STRUCK THEH;Lo;0;AL;<font> 062B;;;;N;;;;;\n1EEB7;ARABIC MATHEMATICAL DOUBLE-STRUCK KHAH;Lo;0;AL;<font> 062E;;;;N;;;;;\n1EEB8;ARABIC MATHEMATICAL DOUBLE-STRUCK THAL;Lo;0;AL;<font> 0630;;;;N;;;;;\n1EEB9;ARABIC MATHEMATICAL DOUBLE-STRUCK DAD;Lo;0;AL;<font> 0636;;;;N;;;;;\n1EEBA;ARABIC MATHEMATICAL DOUBLE-STRUCK ZAH;Lo;0;AL;<font> 0638;;;;N;;;;;\n1EEBB;ARABIC MATHEMATICAL DOUBLE-STRUCK GHAIN;Lo;0;AL;<font> 063A;;;;N;;;;;\n1EEF0;ARABIC MATHEMATICAL OPERATOR MEEM WITH HAH WITH TATWEEL;Sm;0;ON;;;;;N;;;;;\n1EEF1;ARABIC MATHEMATICAL OPERATOR HAH WITH DAL;Sm;0;ON;;;;;N;;;;;\n1F000;MAHJONG TILE EAST WIND;So;0;ON;;;;;N;;;;;\n1F001;MAHJONG TILE SOUTH WIND;So;0;ON;;;;;N;;;;;\n1F002;MAHJONG TILE WEST WIND;So;0;ON;;;;;N;;;;;\n1F003;MAHJONG TILE NORTH WIND;So;0;ON;;;;;N;;;;;\n1F004;MAHJONG TILE RED DRAGON;So;0;ON;;;;;N;;;;;\n1F005;MAHJONG TILE GREEN DRAGON;So;0;ON;;;;;N;;;;;\n1F006;MAHJONG TILE WHITE DRAGON;So;0;ON;;;;;N;;;;;\n1F007;MAHJONG TILE ONE OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F008;MAHJONG TILE TWO OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F009;MAHJONG TILE THREE OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00A;MAHJONG TILE FOUR OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00B;MAHJONG TILE FIVE OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00C;MAHJONG TILE SIX OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00D;MAHJONG TILE SEVEN OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00E;MAHJONG TILE EIGHT OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F00F;MAHJONG TILE NINE OF CHARACTERS;So;0;ON;;;;;N;;;;;\n1F010;MAHJONG TILE ONE OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F011;MAHJONG TILE TWO OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F012;MAHJONG TILE THREE OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F013;MAHJONG TILE FOUR OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F014;MAHJONG TILE FIVE OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F015;MAHJONG TILE SIX OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F016;MAHJONG TILE SEVEN OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F017;MAHJONG TILE EIGHT OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F018;MAHJONG TILE NINE OF BAMBOOS;So;0;ON;;;;;N;;;;;\n1F019;MAHJONG TILE ONE OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01A;MAHJONG TILE TWO OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01B;MAHJONG TILE THREE OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01C;MAHJONG TILE FOUR OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01D;MAHJONG TILE FIVE OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01E;MAHJONG TILE SIX OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F01F;MAHJONG TILE SEVEN OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F020;MAHJONG TILE EIGHT OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F021;MAHJONG TILE NINE OF CIRCLES;So;0;ON;;;;;N;;;;;\n1F022;MAHJONG TILE PLUM;So;0;ON;;;;;N;;;;;\n1F023;MAHJONG TILE ORCHID;So;0;ON;;;;;N;;;;;\n1F024;MAHJONG TILE BAMBOO;So;0;ON;;;;;N;;;;;\n1F025;MAHJONG TILE CHRYSANTHEMUM;So;0;ON;;;;;N;;;;;\n1F026;MAHJONG TILE SPRING;So;0;ON;;;;;N;;;;;\n1F027;MAHJONG TILE SUMMER;So;0;ON;;;;;N;;;;;\n1F028;MAHJONG TILE AUTUMN;So;0;ON;;;;;N;;;;;\n1F029;MAHJONG TILE WINTER;So;0;ON;;;;;N;;;;;\n1F02A;MAHJONG TILE JOKER;So;0;ON;;;;;N;;;;;\n1F02B;MAHJONG TILE BACK;So;0;ON;;;;;N;;;;;\n1F030;DOMINO TILE HORIZONTAL BACK;So;0;ON;;;;;N;;;;;\n1F031;DOMINO TILE HORIZONTAL-00-00;So;0;ON;;;;;N;;;;;\n1F032;DOMINO TILE HORIZONTAL-00-01;So;0;ON;;;;;N;;;;;\n1F033;DOMINO TILE HORIZONTAL-00-02;So;0;ON;;;;;N;;;;;\n1F034;DOMINO TILE HORIZONTAL-00-03;So;0;ON;;;;;N;;;;;\n1F035;DOMINO TILE HORIZONTAL-00-04;So;0;ON;;;;;N;;;;;\n1F036;DOMINO TILE HORIZONTAL-00-05;So;0;ON;;;;;N;;;;;\n1F037;DOMINO TILE HORIZONTAL-00-06;So;0;ON;;;;;N;;;;;\n1F038;DOMINO TILE HORIZONTAL-01-00;So;0;ON;;;;;N;;;;;\n1F039;DOMINO TILE HORIZONTAL-01-01;So;0;ON;;;;;N;;;;;\n1F03A;DOMINO TILE HORIZONTAL-01-02;So;0;ON;;;;;N;;;;;\n1F03B;DOMINO TILE HORIZONTAL-01-03;So;0;ON;;;;;N;;;;;\n1F03C;DOMINO TILE HORIZONTAL-01-04;So;0;ON;;;;;N;;;;;\n1F03D;DOMINO TILE HORIZONTAL-01-05;So;0;ON;;;;;N;;;;;\n1F03E;DOMINO TILE HORIZONTAL-01-06;So;0;ON;;;;;N;;;;;\n1F03F;DOMINO TILE HORIZONTAL-02-00;So;0;ON;;;;;N;;;;;\n1F040;DOMINO TILE HORIZONTAL-02-01;So;0;ON;;;;;N;;;;;\n1F041;DOMINO TILE HORIZONTAL-02-02;So;0;ON;;;;;N;;;;;\n1F042;DOMINO TILE HORIZONTAL-02-03;So;0;ON;;;;;N;;;;;\n1F043;DOMINO TILE HORIZONTAL-02-04;So;0;ON;;;;;N;;;;;\n1F044;DOMINO TILE HORIZONTAL-02-05;So;0;ON;;;;;N;;;;;\n1F045;DOMINO TILE HORIZONTAL-02-06;So;0;ON;;;;;N;;;;;\n1F046;DOMINO TILE HORIZONTAL-03-00;So;0;ON;;;;;N;;;;;\n1F047;DOMINO TILE HORIZONTAL-03-01;So;0;ON;;;;;N;;;;;\n1F048;DOMINO TILE HORIZONTAL-03-02;So;0;ON;;;;;N;;;;;\n1F049;DOMINO TILE HORIZONTAL-03-03;So;0;ON;;;;;N;;;;;\n1F04A;DOMINO TILE HORIZONTAL-03-04;So;0;ON;;;;;N;;;;;\n1F04B;DOMINO TILE HORIZONTAL-03-05;So;0;ON;;;;;N;;;;;\n1F04C;DOMINO TILE HORIZONTAL-03-06;So;0;ON;;;;;N;;;;;\n1F04D;DOMINO TILE HORIZONTAL-04-00;So;0;ON;;;;;N;;;;;\n1F04E;DOMINO TILE HORIZONTAL-04-01;So;0;ON;;;;;N;;;;;\n1F04F;DOMINO TILE HORIZONTAL-04-02;So;0;ON;;;;;N;;;;;\n1F050;DOMINO TILE HORIZONTAL-04-03;So;0;ON;;;;;N;;;;;\n1F051;DOMINO TILE HORIZONTAL-04-04;So;0;ON;;;;;N;;;;;\n1F052;DOMINO TILE HORIZONTAL-04-05;So;0;ON;;;;;N;;;;;\n1F053;DOMINO TILE HORIZONTAL-04-06;So;0;ON;;;;;N;;;;;\n1F054;DOMINO TILE HORIZONTAL-05-00;So;0;ON;;;;;N;;;;;\n1F055;DOMINO TILE HORIZONTAL-05-01;So;0;ON;;;;;N;;;;;\n1F056;DOMINO TILE HORIZONTAL-05-02;So;0;ON;;;;;N;;;;;\n1F057;DOMINO TILE HORIZONTAL-05-03;So;0;ON;;;;;N;;;;;\n1F058;DOMINO TILE HORIZONTAL-05-04;So;0;ON;;;;;N;;;;;\n1F059;DOMINO TILE HORIZONTAL-05-05;So;0;ON;;;;;N;;;;;\n1F05A;DOMINO TILE HORIZONTAL-05-06;So;0;ON;;;;;N;;;;;\n1F05B;DOMINO TILE HORIZONTAL-06-00;So;0;ON;;;;;N;;;;;\n1F05C;DOMINO TILE HORIZONTAL-06-01;So;0;ON;;;;;N;;;;;\n1F05D;DOMINO TILE HORIZONTAL-06-02;So;0;ON;;;;;N;;;;;\n1F05E;DOMINO TILE HORIZONTAL-06-03;So;0;ON;;;;;N;;;;;\n1F05F;DOMINO TILE HORIZONTAL-06-04;So;0;ON;;;;;N;;;;;\n1F060;DOMINO TILE HORIZONTAL-06-05;So;0;ON;;;;;N;;;;;\n1F061;DOMINO TILE HORIZONTAL-06-06;So;0;ON;;;;;N;;;;;\n1F062;DOMINO TILE VERTICAL BACK;So;0;ON;;;;;N;;;;;\n1F063;DOMINO TILE VERTICAL-00-00;So;0;ON;;;;;N;;;;;\n1F064;DOMINO TILE VERTICAL-00-01;So;0;ON;;;;;N;;;;;\n1F065;DOMINO TILE VERTICAL-00-02;So;0;ON;;;;;N;;;;;\n1F066;DOMINO TILE VERTICAL-00-03;So;0;ON;;;;;N;;;;;\n1F067;DOMINO TILE VERTICAL-00-04;So;0;ON;;;;;N;;;;;\n1F068;DOMINO TILE VERTICAL-00-05;So;0;ON;;;;;N;;;;;\n1F069;DOMINO TILE VERTICAL-00-06;So;0;ON;;;;;N;;;;;\n1F06A;DOMINO TILE VERTICAL-01-00;So;0;ON;;;;;N;;;;;\n1F06B;DOMINO TILE VERTICAL-01-01;So;0;ON;;;;;N;;;;;\n1F06C;DOMINO TILE VERTICAL-01-02;So;0;ON;;;;;N;;;;;\n1F06D;DOMINO TILE VERTICAL-01-03;So;0;ON;;;;;N;;;;;\n1F06E;DOMINO TILE VERTICAL-01-04;So;0;ON;;;;;N;;;;;\n1F06F;DOMINO TILE VERTICAL-01-05;So;0;ON;;;;;N;;;;;\n1F070;DOMINO TILE VERTICAL-01-06;So;0;ON;;;;;N;;;;;\n1F071;DOMINO TILE VERTICAL-02-00;So;0;ON;;;;;N;;;;;\n1F072;DOMINO TILE VERTICAL-02-01;So;0;ON;;;;;N;;;;;\n1F073;DOMINO TILE VERTICAL-02-02;So;0;ON;;;;;N;;;;;\n1F074;DOMINO TILE VERTICAL-02-03;So;0;ON;;;;;N;;;;;\n1F075;DOMINO TILE VERTICAL-02-04;So;0;ON;;;;;N;;;;;\n1F076;DOMINO TILE VERTICAL-02-05;So;0;ON;;;;;N;;;;;\n1F077;DOMINO TILE VERTICAL-02-06;So;0;ON;;;;;N;;;;;\n1F078;DOMINO TILE VERTICAL-03-00;So;0;ON;;;;;N;;;;;\n1F079;DOMINO TILE VERTICAL-03-01;So;0;ON;;;;;N;;;;;\n1F07A;DOMINO TILE VERTICAL-03-02;So;0;ON;;;;;N;;;;;\n1F07B;DOMINO TILE VERTICAL-03-03;So;0;ON;;;;;N;;;;;\n1F07C;DOMINO TILE VERTICAL-03-04;So;0;ON;;;;;N;;;;;\n1F07D;DOMINO TILE VERTICAL-03-05;So;0;ON;;;;;N;;;;;\n1F07E;DOMINO TILE VERTICAL-03-06;So;0;ON;;;;;N;;;;;\n1F07F;DOMINO TILE VERTICAL-04-00;So;0;ON;;;;;N;;;;;\n1F080;DOMINO TILE VERTICAL-04-01;So;0;ON;;;;;N;;;;;\n1F081;DOMINO TILE VERTICAL-04-02;So;0;ON;;;;;N;;;;;\n1F082;DOMINO TILE VERTICAL-04-03;So;0;ON;;;;;N;;;;;\n1F083;DOMINO TILE VERTICAL-04-04;So;0;ON;;;;;N;;;;;\n1F084;DOMINO TILE VERTICAL-04-05;So;0;ON;;;;;N;;;;;\n1F085;DOMINO TILE VERTICAL-04-06;So;0;ON;;;;;N;;;;;\n1F086;DOMINO TILE VERTICAL-05-00;So;0;ON;;;;;N;;;;;\n1F087;DOMINO TILE VERTICAL-05-01;So;0;ON;;;;;N;;;;;\n1F088;DOMINO TILE VERTICAL-05-02;So;0;ON;;;;;N;;;;;\n1F089;DOMINO TILE VERTICAL-05-03;So;0;ON;;;;;N;;;;;\n1F08A;DOMINO TILE VERTICAL-05-04;So;0;ON;;;;;N;;;;;\n1F08B;DOMINO TILE VERTICAL-05-05;So;0;ON;;;;;N;;;;;\n1F08C;DOMINO TILE VERTICAL-05-06;So;0;ON;;;;;N;;;;;\n1F08D;DOMINO TILE VERTICAL-06-00;So;0;ON;;;;;N;;;;;\n1F08E;DOMINO TILE VERTICAL-06-01;So;0;ON;;;;;N;;;;;\n1F08F;DOMINO TILE VERTICAL-06-02;So;0;ON;;;;;N;;;;;\n1F090;DOMINO TILE VERTICAL-06-03;So;0;ON;;;;;N;;;;;\n1F091;DOMINO TILE VERTICAL-06-04;So;0;ON;;;;;N;;;;;\n1F092;DOMINO TILE VERTICAL-06-05;So;0;ON;;;;;N;;;;;\n1F093;DOMINO TILE VERTICAL-06-06;So;0;ON;;;;;N;;;;;\n1F0A0;PLAYING CARD BACK;So;0;ON;;;;;N;;;;;\n1F0A1;PLAYING CARD ACE OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A2;PLAYING CARD TWO OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A3;PLAYING CARD THREE OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A4;PLAYING CARD FOUR OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A5;PLAYING CARD FIVE OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A6;PLAYING CARD SIX OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A7;PLAYING CARD SEVEN OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A8;PLAYING CARD EIGHT OF SPADES;So;0;ON;;;;;N;;;;;\n1F0A9;PLAYING CARD NINE OF SPADES;So;0;ON;;;;;N;;;;;\n1F0AA;PLAYING CARD TEN OF SPADES;So;0;ON;;;;;N;;;;;\n1F0AB;PLAYING CARD JACK OF SPADES;So;0;ON;;;;;N;;;;;\n1F0AC;PLAYING CARD KNIGHT OF SPADES;So;0;ON;;;;;N;;;;;\n1F0AD;PLAYING CARD QUEEN OF SPADES;So;0;ON;;;;;N;;;;;\n1F0AE;PLAYING CARD KING OF SPADES;So;0;ON;;;;;N;;;;;\n1F0B1;PLAYING CARD ACE OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B2;PLAYING CARD TWO OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B3;PLAYING CARD THREE OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B4;PLAYING CARD FOUR OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B5;PLAYING CARD FIVE OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B6;PLAYING CARD SIX OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B7;PLAYING CARD SEVEN OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B8;PLAYING CARD EIGHT OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0B9;PLAYING CARD NINE OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0BA;PLAYING CARD TEN OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0BB;PLAYING CARD JACK OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0BC;PLAYING CARD KNIGHT OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0BD;PLAYING CARD QUEEN OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0BE;PLAYING CARD KING OF HEARTS;So;0;ON;;;;;N;;;;;\n1F0C1;PLAYING CARD ACE OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C2;PLAYING CARD TWO OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C3;PLAYING CARD THREE OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C4;PLAYING CARD FOUR OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C5;PLAYING CARD FIVE OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C6;PLAYING CARD SIX OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C7;PLAYING CARD SEVEN OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C8;PLAYING CARD EIGHT OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0C9;PLAYING CARD NINE OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CA;PLAYING CARD TEN OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CB;PLAYING CARD JACK OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CC;PLAYING CARD KNIGHT OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CD;PLAYING CARD QUEEN OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CE;PLAYING CARD KING OF DIAMONDS;So;0;ON;;;;;N;;;;;\n1F0CF;PLAYING CARD BLACK JOKER;So;0;ON;;;;;N;;;;;\n1F0D1;PLAYING CARD ACE OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D2;PLAYING CARD TWO OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D3;PLAYING CARD THREE OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D4;PLAYING CARD FOUR OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D5;PLAYING CARD FIVE OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D6;PLAYING CARD SIX OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D7;PLAYING CARD SEVEN OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D8;PLAYING CARD EIGHT OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0D9;PLAYING CARD NINE OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DA;PLAYING CARD TEN OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DB;PLAYING CARD JACK OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DC;PLAYING CARD KNIGHT OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DD;PLAYING CARD QUEEN OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DE;PLAYING CARD KING OF CLUBS;So;0;ON;;;;;N;;;;;\n1F0DF;PLAYING CARD WHITE JOKER;So;0;ON;;;;;N;;;;;\n1F100;DIGIT ZERO FULL STOP;No;0;EN;<compat> 0030 002E;;0;0;N;;;;;\n1F101;DIGIT ZERO COMMA;No;0;EN;<compat> 0030 002C;;0;0;N;;;;;\n1F102;DIGIT ONE COMMA;No;0;EN;<compat> 0031 002C;;1;1;N;;;;;\n1F103;DIGIT TWO COMMA;No;0;EN;<compat> 0032 002C;;2;2;N;;;;;\n1F104;DIGIT THREE COMMA;No;0;EN;<compat> 0033 002C;;3;3;N;;;;;\n1F105;DIGIT FOUR COMMA;No;0;EN;<compat> 0034 002C;;4;4;N;;;;;\n1F106;DIGIT FIVE COMMA;No;0;EN;<compat> 0035 002C;;5;5;N;;;;;\n1F107;DIGIT SIX COMMA;No;0;EN;<compat> 0036 002C;;6;6;N;;;;;\n1F108;DIGIT SEVEN COMMA;No;0;EN;<compat> 0037 002C;;7;7;N;;;;;\n1F109;DIGIT EIGHT COMMA;No;0;EN;<compat> 0038 002C;;8;8;N;;;;;\n1F10A;DIGIT NINE COMMA;No;0;EN;<compat> 0039 002C;;9;9;N;;;;;\n1F110;PARENTHESIZED LATIN CAPITAL LETTER A;So;0;L;<compat> 0028 0041 0029;;;;N;;;;;\n1F111;PARENTHESIZED LATIN CAPITAL LETTER B;So;0;L;<compat> 0028 0042 0029;;;;N;;;;;\n1F112;PARENTHESIZED LATIN CAPITAL LETTER C;So;0;L;<compat> 0028 0043 0029;;;;N;;;;;\n1F113;PARENTHESIZED LATIN CAPITAL LETTER D;So;0;L;<compat> 0028 0044 0029;;;;N;;;;;\n1F114;PARENTHESIZED LATIN CAPITAL LETTER E;So;0;L;<compat> 0028 0045 0029;;;;N;;;;;\n1F115;PARENTHESIZED LATIN CAPITAL LETTER F;So;0;L;<compat> 0028 0046 0029;;;;N;;;;;\n1F116;PARENTHESIZED LATIN CAPITAL LETTER G;So;0;L;<compat> 0028 0047 0029;;;;N;;;;;\n1F117;PARENTHESIZED LATIN CAPITAL LETTER H;So;0;L;<compat> 0028 0048 0029;;;;N;;;;;\n1F118;PARENTHESIZED LATIN CAPITAL LETTER I;So;0;L;<compat> 0028 0049 0029;;;;N;;;;;\n1F119;PARENTHESIZED LATIN CAPITAL LETTER J;So;0;L;<compat> 0028 004A 0029;;;;N;;;;;\n1F11A;PARENTHESIZED LATIN CAPITAL LETTER K;So;0;L;<compat> 0028 004B 0029;;;;N;;;;;\n1F11B;PARENTHESIZED LATIN CAPITAL LETTER L;So;0;L;<compat> 0028 004C 0029;;;;N;;;;;\n1F11C;PARENTHESIZED LATIN CAPITAL LETTER M;So;0;L;<compat> 0028 004D 0029;;;;N;;;;;\n1F11D;PARENTHESIZED LATIN CAPITAL LETTER N;So;0;L;<compat> 0028 004E 0029;;;;N;;;;;\n1F11E;PARENTHESIZED LATIN CAPITAL LETTER O;So;0;L;<compat> 0028 004F 0029;;;;N;;;;;\n1F11F;PARENTHESIZED LATIN CAPITAL LETTER P;So;0;L;<compat> 0028 0050 0029;;;;N;;;;;\n1F120;PARENTHESIZED LATIN CAPITAL LETTER Q;So;0;L;<compat> 0028 0051 0029;;;;N;;;;;\n1F121;PARENTHESIZED LATIN CAPITAL LETTER R;So;0;L;<compat> 0028 0052 0029;;;;N;;;;;\n1F122;PARENTHESIZED LATIN CAPITAL LETTER S;So;0;L;<compat> 0028 0053 0029;;;;N;;;;;\n1F123;PARENTHESIZED LATIN CAPITAL LETTER T;So;0;L;<compat> 0028 0054 0029;;;;N;;;;;\n1F124;PARENTHESIZED LATIN CAPITAL LETTER U;So;0;L;<compat> 0028 0055 0029;;;;N;;;;;\n1F125;PARENTHESIZED LATIN CAPITAL LETTER V;So;0;L;<compat> 0028 0056 0029;;;;N;;;;;\n1F126;PARENTHESIZED LATIN CAPITAL LETTER W;So;0;L;<compat> 0028 0057 0029;;;;N;;;;;\n1F127;PARENTHESIZED LATIN CAPITAL LETTER X;So;0;L;<compat> 0028 0058 0029;;;;N;;;;;\n1F128;PARENTHESIZED LATIN CAPITAL LETTER Y;So;0;L;<compat> 0028 0059 0029;;;;N;;;;;\n1F129;PARENTHESIZED LATIN CAPITAL LETTER Z;So;0;L;<compat> 0028 005A 0029;;;;N;;;;;\n1F12A;TORTOISE SHELL BRACKETED LATIN CAPITAL LETTER S;So;0;L;<compat> 3014 0053 3015;;;;N;;;;;\n1F12B;CIRCLED ITALIC LATIN CAPITAL LETTER C;So;0;L;<circle> 0043;;;;N;;;;;\n1F12C;CIRCLED ITALIC LATIN CAPITAL LETTER R;So;0;L;<circle> 0052;;;;N;;;;;\n1F12D;CIRCLED CD;So;0;L;<circle> 0043 0044;;;;N;;;;;\n1F12E;CIRCLED WZ;So;0;L;<circle> 0057 005A;;;;N;;;;;\n1F130;SQUARED LATIN CAPITAL LETTER A;So;0;L;<square> 0041;;;;N;;;;;\n1F131;SQUARED LATIN CAPITAL LETTER B;So;0;L;<square> 0042;;;;N;;;;;\n1F132;SQUARED LATIN CAPITAL LETTER C;So;0;L;<square> 0043;;;;N;;;;;\n1F133;SQUARED LATIN CAPITAL LETTER D;So;0;L;<square> 0044;;;;N;;;;;\n1F134;SQUARED LATIN CAPITAL LETTER E;So;0;L;<square> 0045;;;;N;;;;;\n1F135;SQUARED LATIN CAPITAL LETTER F;So;0;L;<square> 0046;;;;N;;;;;\n1F136;SQUARED LATIN CAPITAL LETTER G;So;0;L;<square> 0047;;;;N;;;;;\n1F137;SQUARED LATIN CAPITAL LETTER H;So;0;L;<square> 0048;;;;N;;;;;\n1F138;SQUARED LATIN CAPITAL LETTER I;So;0;L;<square> 0049;;;;N;;;;;\n1F139;SQUARED LATIN CAPITAL LETTER J;So;0;L;<square> 004A;;;;N;;;;;\n1F13A;SQUARED LATIN CAPITAL LETTER K;So;0;L;<square> 004B;;;;N;;;;;\n1F13B;SQUARED LATIN CAPITAL LETTER L;So;0;L;<square> 004C;;;;N;;;;;\n1F13C;SQUARED LATIN CAPITAL LETTER M;So;0;L;<square> 004D;;;;N;;;;;\n1F13D;SQUARED LATIN CAPITAL LETTER N;So;0;L;<square> 004E;;;;N;;;;;\n1F13E;SQUARED LATIN CAPITAL LETTER O;So;0;L;<square> 004F;;;;N;;;;;\n1F13F;SQUARED LATIN CAPITAL LETTER P;So;0;L;<square> 0050;;;;N;;;;;\n1F140;SQUARED LATIN CAPITAL LETTER Q;So;0;L;<square> 0051;;;;N;;;;;\n1F141;SQUARED LATIN CAPITAL LETTER R;So;0;L;<square> 0052;;;;N;;;;;\n1F142;SQUARED LATIN CAPITAL LETTER S;So;0;L;<square> 0053;;;;N;;;;;\n1F143;SQUARED LATIN CAPITAL LETTER T;So;0;L;<square> 0054;;;;N;;;;;\n1F144;SQUARED LATIN CAPITAL LETTER U;So;0;L;<square> 0055;;;;N;;;;;\n1F145;SQUARED LATIN CAPITAL LETTER V;So;0;L;<square> 0056;;;;N;;;;;\n1F146;SQUARED LATIN CAPITAL LETTER W;So;0;L;<square> 0057;;;;N;;;;;\n1F147;SQUARED LATIN CAPITAL LETTER X;So;0;L;<square> 0058;;;;N;;;;;\n1F148;SQUARED LATIN CAPITAL LETTER Y;So;0;L;<square> 0059;;;;N;;;;;\n1F149;SQUARED LATIN CAPITAL LETTER Z;So;0;L;<square> 005A;;;;N;;;;;\n1F14A;SQUARED HV;So;0;L;<square> 0048 0056;;;;N;;;;;\n1F14B;SQUARED MV;So;0;L;<square> 004D 0056;;;;N;;;;;\n1F14C;SQUARED SD;So;0;L;<square> 0053 0044;;;;N;;;;;\n1F14D;SQUARED SS;So;0;L;<square> 0053 0053;;;;N;;;;;\n1F14E;SQUARED PPV;So;0;L;<square> 0050 0050 0056;;;;N;;;;;\n1F14F;SQUARED WC;So;0;L;<square> 0057 0043;;;;N;;;;;\n1F150;NEGATIVE CIRCLED LATIN CAPITAL LETTER A;So;0;L;;;;;N;;;;;\n1F151;NEGATIVE CIRCLED LATIN CAPITAL LETTER B;So;0;L;;;;;N;;;;;\n1F152;NEGATIVE CIRCLED LATIN CAPITAL LETTER C;So;0;L;;;;;N;;;;;\n1F153;NEGATIVE CIRCLED LATIN CAPITAL LETTER D;So;0;L;;;;;N;;;;;\n1F154;NEGATIVE CIRCLED LATIN CAPITAL LETTER E;So;0;L;;;;;N;;;;;\n1F155;NEGATIVE CIRCLED LATIN CAPITAL LETTER F;So;0;L;;;;;N;;;;;\n1F156;NEGATIVE CIRCLED LATIN CAPITAL LETTER G;So;0;L;;;;;N;;;;;\n1F157;NEGATIVE CIRCLED LATIN CAPITAL LETTER H;So;0;L;;;;;N;;;;;\n1F158;NEGATIVE CIRCLED LATIN CAPITAL LETTER I;So;0;L;;;;;N;;;;;\n1F159;NEGATIVE CIRCLED LATIN CAPITAL LETTER J;So;0;L;;;;;N;;;;;\n1F15A;NEGATIVE CIRCLED LATIN CAPITAL LETTER K;So;0;L;;;;;N;;;;;\n1F15B;NEGATIVE CIRCLED LATIN CAPITAL LETTER L;So;0;L;;;;;N;;;;;\n1F15C;NEGATIVE CIRCLED LATIN CAPITAL LETTER M;So;0;L;;;;;N;;;;;\n1F15D;NEGATIVE CIRCLED LATIN CAPITAL LETTER N;So;0;L;;;;;N;;;;;\n1F15E;NEGATIVE CIRCLED LATIN CAPITAL LETTER O;So;0;L;;;;;N;;;;;\n1F15F;NEGATIVE CIRCLED LATIN CAPITAL LETTER P;So;0;L;;;;;N;;;;;\n1F160;NEGATIVE CIRCLED LATIN CAPITAL LETTER Q;So;0;L;;;;;N;;;;;\n1F161;NEGATIVE CIRCLED LATIN CAPITAL LETTER R;So;0;L;;;;;N;;;;;\n1F162;NEGATIVE CIRCLED LATIN CAPITAL LETTER S;So;0;L;;;;;N;;;;;\n1F163;NEGATIVE CIRCLED LATIN CAPITAL LETTER T;So;0;L;;;;;N;;;;;\n1F164;NEGATIVE CIRCLED LATIN CAPITAL LETTER U;So;0;L;;;;;N;;;;;\n1F165;NEGATIVE CIRCLED LATIN CAPITAL LETTER V;So;0;L;;;;;N;;;;;\n1F166;NEGATIVE CIRCLED LATIN CAPITAL LETTER W;So;0;L;;;;;N;;;;;\n1F167;NEGATIVE CIRCLED LATIN CAPITAL LETTER X;So;0;L;;;;;N;;;;;\n1F168;NEGATIVE CIRCLED LATIN CAPITAL LETTER Y;So;0;L;;;;;N;;;;;\n1F169;NEGATIVE CIRCLED LATIN CAPITAL LETTER Z;So;0;L;;;;;N;;;;;\n1F16A;RAISED MC SIGN;So;0;ON;<super> 004D 0043;;;;N;;;;;\n1F16B;RAISED MD SIGN;So;0;ON;<super> 004D 0044;;;;N;;;;;\n1F170;NEGATIVE SQUARED LATIN CAPITAL LETTER A;So;0;L;;;;;N;;;;;\n1F171;NEGATIVE SQUARED LATIN CAPITAL LETTER B;So;0;L;;;;;N;;;;;\n1F172;NEGATIVE SQUARED LATIN CAPITAL LETTER C;So;0;L;;;;;N;;;;;\n1F173;NEGATIVE SQUARED LATIN CAPITAL LETTER D;So;0;L;;;;;N;;;;;\n1F174;NEGATIVE SQUARED LATIN CAPITAL LETTER E;So;0;L;;;;;N;;;;;\n1F175;NEGATIVE SQUARED LATIN CAPITAL LETTER F;So;0;L;;;;;N;;;;;\n1F176;NEGATIVE SQUARED LATIN CAPITAL LETTER G;So;0;L;;;;;N;;;;;\n1F177;NEGATIVE SQUARED LATIN CAPITAL LETTER H;So;0;L;;;;;N;;;;;\n1F178;NEGATIVE SQUARED LATIN CAPITAL LETTER I;So;0;L;;;;;N;;;;;\n1F179;NEGATIVE SQUARED LATIN CAPITAL LETTER J;So;0;L;;;;;N;;;;;\n1F17A;NEGATIVE SQUARED LATIN CAPITAL LETTER K;So;0;L;;;;;N;;;;;\n1F17B;NEGATIVE SQUARED LATIN CAPITAL LETTER L;So;0;L;;;;;N;;;;;\n1F17C;NEGATIVE SQUARED LATIN CAPITAL LETTER M;So;0;L;;;;;N;;;;;\n1F17D;NEGATIVE SQUARED LATIN CAPITAL LETTER N;So;0;L;;;;;N;;;;;\n1F17E;NEGATIVE SQUARED LATIN CAPITAL LETTER O;So;0;L;;;;;N;;;;;\n1F17F;NEGATIVE SQUARED LATIN CAPITAL LETTER P;So;0;L;;;;;N;;;;;\n1F180;NEGATIVE SQUARED LATIN CAPITAL LETTER Q;So;0;L;;;;;N;;;;;\n1F181;NEGATIVE SQUARED LATIN CAPITAL LETTER R;So;0;L;;;;;N;;;;;\n1F182;NEGATIVE SQUARED LATIN CAPITAL LETTER S;So;0;L;;;;;N;;;;;\n1F183;NEGATIVE SQUARED LATIN CAPITAL LETTER T;So;0;L;;;;;N;;;;;\n1F184;NEGATIVE SQUARED LATIN CAPITAL LETTER U;So;0;L;;;;;N;;;;;\n1F185;NEGATIVE SQUARED LATIN CAPITAL LETTER V;So;0;L;;;;;N;;;;;\n1F186;NEGATIVE SQUARED LATIN CAPITAL LETTER W;So;0;L;;;;;N;;;;;\n1F187;NEGATIVE SQUARED LATIN CAPITAL LETTER X;So;0;L;;;;;N;;;;;\n1F188;NEGATIVE SQUARED LATIN CAPITAL LETTER Y;So;0;L;;;;;N;;;;;\n1F189;NEGATIVE SQUARED LATIN CAPITAL LETTER Z;So;0;L;;;;;N;;;;;\n1F18A;CROSSED NEGATIVE SQUARED LATIN CAPITAL LETTER P;So;0;L;;;;;N;;;;;\n1F18B;NEGATIVE SQUARED IC;So;0;L;;;;;N;;;;;\n1F18C;NEGATIVE SQUARED PA;So;0;L;;;;;N;;;;;\n1F18D;NEGATIVE SQUARED SA;So;0;L;;;;;N;;;;;\n1F18E;NEGATIVE SQUARED AB;So;0;L;;;;;N;;;;;\n1F18F;NEGATIVE SQUARED WC;So;0;L;;;;;N;;;;;\n1F190;SQUARE DJ;So;0;L;<square> 0044 004A;;;;N;;;;;\n1F191;SQUARED CL;So;0;L;;;;;N;;;;;\n1F192;SQUARED COOL;So;0;L;;;;;N;;;;;\n1F193;SQUARED FREE;So;0;L;;;;;N;;;;;\n1F194;SQUARED ID;So;0;L;;;;;N;;;;;\n1F195;SQUARED NEW;So;0;L;;;;;N;;;;;\n1F196;SQUARED NG;So;0;L;;;;;N;;;;;\n1F197;SQUARED OK;So;0;L;;;;;N;;;;;\n1F198;SQUARED SOS;So;0;L;;;;;N;;;;;\n1F199;SQUARED UP WITH EXCLAMATION MARK;So;0;L;;;;;N;;;;;\n1F19A;SQUARED VS;So;0;L;;;;;N;;;;;\n1F1E6;REGIONAL INDICATOR SYMBOL LETTER A;So;0;L;;;;;N;;;;;\n1F1E7;REGIONAL INDICATOR SYMBOL LETTER B;So;0;L;;;;;N;;;;;\n1F1E8;REGIONAL INDICATOR SYMBOL LETTER C;So;0;L;;;;;N;;;;;\n1F1E9;REGIONAL INDICATOR SYMBOL LETTER D;So;0;L;;;;;N;;;;;\n1F1EA;REGIONAL INDICATOR SYMBOL LETTER E;So;0;L;;;;;N;;;;;\n1F1EB;REGIONAL INDICATOR SYMBOL LETTER F;So;0;L;;;;;N;;;;;\n1F1EC;REGIONAL INDICATOR SYMBOL LETTER G;So;0;L;;;;;N;;;;;\n1F1ED;REGIONAL INDICATOR SYMBOL LETTER H;So;0;L;;;;;N;;;;;\n1F1EE;REGIONAL INDICATOR SYMBOL LETTER I;So;0;L;;;;;N;;;;;\n1F1EF;REGIONAL INDICATOR SYMBOL LETTER J;So;0;L;;;;;N;;;;;\n1F1F0;REGIONAL INDICATOR SYMBOL LETTER K;So;0;L;;;;;N;;;;;\n1F1F1;REGIONAL INDICATOR SYMBOL LETTER L;So;0;L;;;;;N;;;;;\n1F1F2;REGIONAL INDICATOR SYMBOL LETTER M;So;0;L;;;;;N;;;;;\n1F1F3;REGIONAL INDICATOR SYMBOL LETTER N;So;0;L;;;;;N;;;;;\n1F1F4;REGIONAL INDICATOR SYMBOL LETTER O;So;0;L;;;;;N;;;;;\n1F1F5;REGIONAL INDICATOR SYMBOL LETTER P;So;0;L;;;;;N;;;;;\n1F1F6;REGIONAL INDICATOR SYMBOL LETTER Q;So;0;L;;;;;N;;;;;\n1F1F7;REGIONAL INDICATOR SYMBOL LETTER R;So;0;L;;;;;N;;;;;\n1F1F8;REGIONAL INDICATOR SYMBOL LETTER S;So;0;L;;;;;N;;;;;\n1F1F9;REGIONAL INDICATOR SYMBOL LETTER T;So;0;L;;;;;N;;;;;\n1F1FA;REGIONAL INDICATOR SYMBOL LETTER U;So;0;L;;;;;N;;;;;\n1F1FB;REGIONAL INDICATOR SYMBOL LETTER V;So;0;L;;;;;N;;;;;\n1F1FC;REGIONAL INDICATOR SYMBOL LETTER W;So;0;L;;;;;N;;;;;\n1F1FD;REGIONAL INDICATOR SYMBOL LETTER X;So;0;L;;;;;N;;;;;\n1F1FE;REGIONAL INDICATOR SYMBOL LETTER Y;So;0;L;;;;;N;;;;;\n1F1FF;REGIONAL INDICATOR SYMBOL LETTER Z;So;0;L;;;;;N;;;;;\n1F200;SQUARE HIRAGANA HOKA;So;0;L;<square> 307B 304B;;;;N;;;;;\n1F201;SQUARED KATAKANA KOKO;So;0;L;<square> 30B3 30B3;;;;N;;;;;\n1F202;SQUARED KATAKANA SA;So;0;L;<square> 30B5;;;;N;;;;;\n1F210;SQUARED CJK UNIFIED IDEOGRAPH-624B;So;0;L;<square> 624B;;;;N;;;;;\n1F211;SQUARED CJK UNIFIED IDEOGRAPH-5B57;So;0;L;<square> 5B57;;;;N;;;;;\n1F212;SQUARED CJK UNIFIED IDEOGRAPH-53CC;So;0;L;<square> 53CC;;;;N;;;;;\n1F213;SQUARED KATAKANA DE;So;0;L;<square> 30C7;;;;N;;;;;\n1F214;SQUARED CJK UNIFIED IDEOGRAPH-4E8C;So;0;L;<square> 4E8C;;;;N;;;;;\n1F215;SQUARED CJK UNIFIED IDEOGRAPH-591A;So;0;L;<square> 591A;;;;N;;;;;\n1F216;SQUARED CJK UNIFIED IDEOGRAPH-89E3;So;0;L;<square> 89E3;;;;N;;;;;\n1F217;SQUARED CJK UNIFIED IDEOGRAPH-5929;So;0;L;<square> 5929;;;;N;;;;;\n1F218;SQUARED CJK UNIFIED IDEOGRAPH-4EA4;So;0;L;<square> 4EA4;;;;N;;;;;\n1F219;SQUARED CJK UNIFIED IDEOGRAPH-6620;So;0;L;<square> 6620;;;;N;;;;;\n1F21A;SQUARED CJK UNIFIED IDEOGRAPH-7121;So;0;L;<square> 7121;;;;N;;;;;\n1F21B;SQUARED CJK UNIFIED IDEOGRAPH-6599;So;0;L;<square> 6599;;;;N;;;;;\n1F21C;SQUARED CJK UNIFIED IDEOGRAPH-524D;So;0;L;<square> 524D;;;;N;;;;;\n1F21D;SQUARED CJK UNIFIED IDEOGRAPH-5F8C;So;0;L;<square> 5F8C;;;;N;;;;;\n1F21E;SQUARED CJK UNIFIED IDEOGRAPH-518D;So;0;L;<square> 518D;;;;N;;;;;\n1F21F;SQUARED CJK UNIFIED IDEOGRAPH-65B0;So;0;L;<square> 65B0;;;;N;;;;;\n1F220;SQUARED CJK UNIFIED IDEOGRAPH-521D;So;0;L;<square> 521D;;;;N;;;;;\n1F221;SQUARED CJK UNIFIED IDEOGRAPH-7D42;So;0;L;<square> 7D42;;;;N;;;;;\n1F222;SQUARED CJK UNIFIED IDEOGRAPH-751F;So;0;L;<square> 751F;;;;N;;;;;\n1F223;SQUARED CJK UNIFIED IDEOGRAPH-8CA9;So;0;L;<square> 8CA9;;;;N;;;;;\n1F224;SQUARED CJK UNIFIED IDEOGRAPH-58F0;So;0;L;<square> 58F0;;;;N;;;;;\n1F225;SQUARED CJK UNIFIED IDEOGRAPH-5439;So;0;L;<square> 5439;;;;N;;;;;\n1F226;SQUARED CJK UNIFIED IDEOGRAPH-6F14;So;0;L;<square> 6F14;;;;N;;;;;\n1F227;SQUARED CJK UNIFIED IDEOGRAPH-6295;So;0;L;<square> 6295;;;;N;;;;;\n1F228;SQUARED CJK UNIFIED IDEOGRAPH-6355;So;0;L;<square> 6355;;;;N;;;;;\n1F229;SQUARED CJK UNIFIED IDEOGRAPH-4E00;So;0;L;<square> 4E00;;;;N;;;;;\n1F22A;SQUARED CJK UNIFIED IDEOGRAPH-4E09;So;0;L;<square> 4E09;;;;N;;;;;\n1F22B;SQUARED CJK UNIFIED IDEOGRAPH-904A;So;0;L;<square> 904A;;;;N;;;;;\n1F22C;SQUARED CJK UNIFIED IDEOGRAPH-5DE6;So;0;L;<square> 5DE6;;;;N;;;;;\n1F22D;SQUARED CJK UNIFIED IDEOGRAPH-4E2D;So;0;L;<square> 4E2D;;;;N;;;;;\n1F22E;SQUARED CJK UNIFIED IDEOGRAPH-53F3;So;0;L;<square> 53F3;;;;N;;;;;\n1F22F;SQUARED CJK UNIFIED IDEOGRAPH-6307;So;0;L;<square> 6307;;;;N;;;;;\n1F230;SQUARED CJK UNIFIED IDEOGRAPH-8D70;So;0;L;<square> 8D70;;;;N;;;;;\n1F231;SQUARED CJK UNIFIED IDEOGRAPH-6253;So;0;L;<square> 6253;;;;N;;;;;\n1F232;SQUARED CJK UNIFIED IDEOGRAPH-7981;So;0;L;<square> 7981;;;;N;;;;;\n1F233;SQUARED CJK UNIFIED IDEOGRAPH-7A7A;So;0;L;<square> 7A7A;;;;N;;;;;\n1F234;SQUARED CJK UNIFIED IDEOGRAPH-5408;So;0;L;<square> 5408;;;;N;;;;;\n1F235;SQUARED CJK UNIFIED IDEOGRAPH-6E80;So;0;L;<square> 6E80;;;;N;;;;;\n1F236;SQUARED CJK UNIFIED IDEOGRAPH-6709;So;0;L;<square> 6709;;;;N;;;;;\n1F237;SQUARED CJK UNIFIED IDEOGRAPH-6708;So;0;L;<square> 6708;;;;N;;;;;\n1F238;SQUARED CJK UNIFIED IDEOGRAPH-7533;So;0;L;<square> 7533;;;;N;;;;;\n1F239;SQUARED CJK UNIFIED IDEOGRAPH-5272;So;0;L;<square> 5272;;;;N;;;;;\n1F23A;SQUARED CJK UNIFIED IDEOGRAPH-55B6;So;0;L;<square> 55B6;;;;N;;;;;\n1F240;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-672C;So;0;L;<compat> 3014 672C 3015;;;;N;;;;;\n1F241;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-4E09;So;0;L;<compat> 3014 4E09 3015;;;;N;;;;;\n1F242;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-4E8C;So;0;L;<compat> 3014 4E8C 3015;;;;N;;;;;\n1F243;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-5B89;So;0;L;<compat> 3014 5B89 3015;;;;N;;;;;\n1F244;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-70B9;So;0;L;<compat> 3014 70B9 3015;;;;N;;;;;\n1F245;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-6253;So;0;L;<compat> 3014 6253 3015;;;;N;;;;;\n1F246;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-76D7;So;0;L;<compat> 3014 76D7 3015;;;;N;;;;;\n1F247;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-52DD;So;0;L;<compat> 3014 52DD 3015;;;;N;;;;;\n1F248;TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRAPH-6557;So;0;L;<compat> 3014 6557 3015;;;;N;;;;;\n1F250;CIRCLED IDEOGRAPH ADVANTAGE;So;0;L;<circle> 5F97;;;;N;;;;;\n1F251;CIRCLED IDEOGRAPH ACCEPT;So;0;L;<circle> 53EF;;;;N;;;;;\n1F300;CYCLONE;So;0;ON;;;;;N;;;;;\n1F301;FOGGY;So;0;ON;;;;;N;;;;;\n1F302;CLOSED UMBRELLA;So;0;ON;;;;;N;;;;;\n1F303;NIGHT WITH STARS;So;0;ON;;;;;N;;;;;\n1F304;SUNRISE OVER MOUNTAINS;So;0;ON;;;;;N;;;;;\n1F305;SUNRISE;So;0;ON;;;;;N;;;;;\n1F306;CITYSCAPE AT DUSK;So;0;ON;;;;;N;;;;;\n1F307;SUNSET OVER BUILDINGS;So;0;ON;;;;;N;;;;;\n1F308;RAINBOW;So;0;ON;;;;;N;;;;;\n1F309;BRIDGE AT NIGHT;So;0;ON;;;;;N;;;;;\n1F30A;WATER WAVE;So;0;ON;;;;;N;;;;;\n1F30B;VOLCANO;So;0;ON;;;;;N;;;;;\n1F30C;MILKY WAY;So;0;ON;;;;;N;;;;;\n1F30D;EARTH GLOBE EUROPE-AFRICA;So;0;ON;;;;;N;;;;;\n1F30E;EARTH GLOBE AMERICAS;So;0;ON;;;;;N;;;;;\n1F30F;EARTH GLOBE ASIA-AUSTRALIA;So;0;ON;;;;;N;;;;;\n1F310;GLOBE WITH MERIDIANS;So;0;ON;;;;;N;;;;;\n1F311;NEW MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F312;WAXING CRESCENT MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F313;FIRST QUARTER MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F314;WAXING GIBBOUS MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F315;FULL MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F316;WANING GIBBOUS MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F317;LAST QUARTER MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F318;WANING CRESCENT MOON SYMBOL;So;0;ON;;;;;N;;;;;\n1F319;CRESCENT MOON;So;0;ON;;;;;N;;;;;\n1F31A;NEW MOON WITH FACE;So;0;ON;;;;;N;;;;;\n1F31B;FIRST QUARTER MOON WITH FACE;So;0;ON;;;;;N;;;;;\n1F31C;LAST QUARTER MOON WITH FACE;So;0;ON;;;;;N;;;;;\n1F31D;FULL MOON WITH FACE;So;0;ON;;;;;N;;;;;\n1F31E;SUN WITH FACE;So;0;ON;;;;;N;;;;;\n1F31F;GLOWING STAR;So;0;ON;;;;;N;;;;;\n1F320;SHOOTING STAR;So;0;ON;;;;;N;;;;;\n1F330;CHESTNUT;So;0;ON;;;;;N;;;;;\n1F331;SEEDLING;So;0;ON;;;;;N;;;;;\n1F332;EVERGREEN TREE;So;0;ON;;;;;N;;;;;\n1F333;DECIDUOUS TREE;So;0;ON;;;;;N;;;;;\n1F334;PALM TREE;So;0;ON;;;;;N;;;;;\n1F335;CACTUS;So;0;ON;;;;;N;;;;;\n1F337;TULIP;So;0;ON;;;;;N;;;;;\n1F338;CHERRY BLOSSOM;So;0;ON;;;;;N;;;;;\n1F339;ROSE;So;0;ON;;;;;N;;;;;\n1F33A;HIBISCUS;So;0;ON;;;;;N;;;;;\n1F33B;SUNFLOWER;So;0;ON;;;;;N;;;;;\n1F33C;BLOSSOM;So;0;ON;;;;;N;;;;;\n1F33D;EAR OF MAIZE;So;0;ON;;;;;N;;;;;\n1F33E;EAR OF RICE;So;0;ON;;;;;N;;;;;\n1F33F;HERB;So;0;ON;;;;;N;;;;;\n1F340;FOUR LEAF CLOVER;So;0;ON;;;;;N;;;;;\n1F341;MAPLE LEAF;So;0;ON;;;;;N;;;;;\n1F342;FALLEN LEAF;So;0;ON;;;;;N;;;;;\n1F343;LEAF FLUTTERING IN WIND;So;0;ON;;;;;N;;;;;\n1F344;MUSHROOM;So;0;ON;;;;;N;;;;;\n1F345;TOMATO;So;0;ON;;;;;N;;;;;\n1F346;AUBERGINE;So;0;ON;;;;;N;;;;;\n1F347;GRAPES;So;0;ON;;;;;N;;;;;\n1F348;MELON;So;0;ON;;;;;N;;;;;\n1F349;WATERMELON;So;0;ON;;;;;N;;;;;\n1F34A;TANGERINE;So;0;ON;;;;;N;;;;;\n1F34B;LEMON;So;0;ON;;;;;N;;;;;\n1F34C;BANANA;So;0;ON;;;;;N;;;;;\n1F34D;PINEAPPLE;So;0;ON;;;;;N;;;;;\n1F34E;RED APPLE;So;0;ON;;;;;N;;;;;\n1F34F;GREEN APPLE;So;0;ON;;;;;N;;;;;\n1F350;PEAR;So;0;ON;;;;;N;;;;;\n1F351;PEACH;So;0;ON;;;;;N;;;;;\n1F352;CHERRIES;So;0;ON;;;;;N;;;;;\n1F353;STRAWBERRY;So;0;ON;;;;;N;;;;;\n1F354;HAMBURGER;So;0;ON;;;;;N;;;;;\n1F355;SLICE OF PIZZA;So;0;ON;;;;;N;;;;;\n1F356;MEAT ON BONE;So;0;ON;;;;;N;;;;;\n1F357;POULTRY LEG;So;0;ON;;;;;N;;;;;\n1F358;RICE CRACKER;So;0;ON;;;;;N;;;;;\n1F359;RICE BALL;So;0;ON;;;;;N;;;;;\n1F35A;COOKED RICE;So;0;ON;;;;;N;;;;;\n1F35B;CURRY AND RICE;So;0;ON;;;;;N;;;;;\n1F35C;STEAMING BOWL;So;0;ON;;;;;N;;;;;\n1F35D;SPAGHETTI;So;0;ON;;;;;N;;;;;\n1F35E;BREAD;So;0;ON;;;;;N;;;;;\n1F35F;FRENCH FRIES;So;0;ON;;;;;N;;;;;\n1F360;ROASTED SWEET POTATO;So;0;ON;;;;;N;;;;;\n1F361;DANGO;So;0;ON;;;;;N;;;;;\n1F362;ODEN;So;0;ON;;;;;N;;;;;\n1F363;SUSHI;So;0;ON;;;;;N;;;;;\n1F364;FRIED SHRIMP;So;0;ON;;;;;N;;;;;\n1F365;FISH CAKE WITH SWIRL DESIGN;So;0;ON;;;;;N;;;;;\n1F366;SOFT ICE CREAM;So;0;ON;;;;;N;;;;;\n1F367;SHAVED ICE;So;0;ON;;;;;N;;;;;\n1F368;ICE CREAM;So;0;ON;;;;;N;;;;;\n1F369;DOUGHNUT;So;0;ON;;;;;N;;;;;\n1F36A;COOKIE;So;0;ON;;;;;N;;;;;\n1F36B;CHOCOLATE BAR;So;0;ON;;;;;N;;;;;\n1F36C;CANDY;So;0;ON;;;;;N;;;;;\n1F36D;LOLLIPOP;So;0;ON;;;;;N;;;;;\n1F36E;CUSTARD;So;0;ON;;;;;N;;;;;\n1F36F;HONEY POT;So;0;ON;;;;;N;;;;;\n1F370;SHORTCAKE;So;0;ON;;;;;N;;;;;\n1F371;BENTO BOX;So;0;ON;;;;;N;;;;;\n1F372;POT OF FOOD;So;0;ON;;;;;N;;;;;\n1F373;COOKING;So;0;ON;;;;;N;;;;;\n1F374;FORK AND KNIFE;So;0;ON;;;;;N;;;;;\n1F375;TEACUP WITHOUT HANDLE;So;0;ON;;;;;N;;;;;\n1F376;SAKE BOTTLE AND CUP;So;0;ON;;;;;N;;;;;\n1F377;WINE GLASS;So;0;ON;;;;;N;;;;;\n1F378;COCKTAIL GLASS;So;0;ON;;;;;N;;;;;\n1F379;TROPICAL DRINK;So;0;ON;;;;;N;;;;;\n1F37A;BEER MUG;So;0;ON;;;;;N;;;;;\n1F37B;CLINKING BEER MUGS;So;0;ON;;;;;N;;;;;\n1F37C;BABY BOTTLE;So;0;ON;;;;;N;;;;;\n1F380;RIBBON;So;0;ON;;;;;N;;;;;\n1F381;WRAPPED PRESENT;So;0;ON;;;;;N;;;;;\n1F382;BIRTHDAY CAKE;So;0;ON;;;;;N;;;;;\n1F383;JACK-O-LANTERN;So;0;ON;;;;;N;;;;;\n1F384;CHRISTMAS TREE;So;0;ON;;;;;N;;;;;\n1F385;FATHER CHRISTMAS;So;0;ON;;;;;N;;;;;\n1F386;FIREWORKS;So;0;ON;;;;;N;;;;;\n1F387;FIREWORK SPARKLER;So;0;ON;;;;;N;;;;;\n1F388;BALLOON;So;0;ON;;;;;N;;;;;\n1F389;PARTY POPPER;So;0;ON;;;;;N;;;;;\n1F38A;CONFETTI BALL;So;0;ON;;;;;N;;;;;\n1F38B;TANABATA TREE;So;0;ON;;;;;N;;;;;\n1F38C;CROSSED FLAGS;So;0;ON;;;;;N;;;;;\n1F38D;PINE DECORATION;So;0;ON;;;;;N;;;;;\n1F38E;JAPANESE DOLLS;So;0;ON;;;;;N;;;;;\n1F38F;CARP STREAMER;So;0;ON;;;;;N;;;;;\n1F390;WIND CHIME;So;0;ON;;;;;N;;;;;\n1F391;MOON VIEWING CEREMONY;So;0;ON;;;;;N;;;;;\n1F392;SCHOOL SATCHEL;So;0;ON;;;;;N;;;;;\n1F393;GRADUATION CAP;So;0;ON;;;;;N;;;;;\n1F3A0;CAROUSEL HORSE;So;0;ON;;;;;N;;;;;\n1F3A1;FERRIS WHEEL;So;0;ON;;;;;N;;;;;\n1F3A2;ROLLER COASTER;So;0;ON;;;;;N;;;;;\n1F3A3;FISHING POLE AND FISH;So;0;ON;;;;;N;;;;;\n1F3A4;MICROPHONE;So;0;ON;;;;;N;;;;;\n1F3A5;MOVIE CAMERA;So;0;ON;;;;;N;;;;;\n1F3A6;CINEMA;So;0;ON;;;;;N;;;;;\n1F3A7;HEADPHONE;So;0;ON;;;;;N;;;;;\n1F3A8;ARTIST PALETTE;So;0;ON;;;;;N;;;;;\n1F3A9;TOP HAT;So;0;ON;;;;;N;;;;;\n1F3AA;CIRCUS TENT;So;0;ON;;;;;N;;;;;\n1F3AB;TICKET;So;0;ON;;;;;N;;;;;\n1F3AC;CLAPPER BOARD;So;0;ON;;;;;N;;;;;\n1F3AD;PERFORMING ARTS;So;0;ON;;;;;N;;;;;\n1F3AE;VIDEO GAME;So;0;ON;;;;;N;;;;;\n1F3AF;DIRECT HIT;So;0;ON;;;;;N;;;;;\n1F3B0;SLOT MACHINE;So;0;ON;;;;;N;;;;;\n1F3B1;BILLIARDS;So;0;ON;;;;;N;;;;;\n1F3B2;GAME DIE;So;0;ON;;;;;N;;;;;\n1F3B3;BOWLING;So;0;ON;;;;;N;;;;;\n1F3B4;FLOWER PLAYING CARDS;So;0;ON;;;;;N;;;;;\n1F3B5;MUSICAL NOTE;So;0;ON;;;;;N;;;;;\n1F3B6;MULTIPLE MUSICAL NOTES;So;0;ON;;;;;N;;;;;\n1F3B7;SAXOPHONE;So;0;ON;;;;;N;;;;;\n1F3B8;GUITAR;So;0;ON;;;;;N;;;;;\n1F3B9;MUSICAL KEYBOARD;So;0;ON;;;;;N;;;;;\n1F3BA;TRUMPET;So;0;ON;;;;;N;;;;;\n1F3BB;VIOLIN;So;0;ON;;;;;N;;;;;\n1F3BC;MUSICAL SCORE;So;0;ON;;;;;N;;;;;\n1F3BD;RUNNING SHIRT WITH SASH;So;0;ON;;;;;N;;;;;\n1F3BE;TENNIS RACQUET AND BALL;So;0;ON;;;;;N;;;;;\n1F3BF;SKI AND SKI BOOT;So;0;ON;;;;;N;;;;;\n1F3C0;BASKETBALL AND HOOP;So;0;ON;;;;;N;;;;;\n1F3C1;CHEQUERED FLAG;So;0;ON;;;;;N;;;;;\n1F3C2;SNOWBOARDER;So;0;ON;;;;;N;;;;;\n1F3C3;RUNNER;So;0;ON;;;;;N;;;;;\n1F3C4;SURFER;So;0;ON;;;;;N;;;;;\n1F3C6;TROPHY;So;0;ON;;;;;N;;;;;\n1F3C7;HORSE RACING;So;0;ON;;;;;N;;;;;\n1F3C8;AMERICAN FOOTBALL;So;0;ON;;;;;N;;;;;\n1F3C9;RUGBY FOOTBALL;So;0;ON;;;;;N;;;;;\n1F3CA;SWIMMER;So;0;ON;;;;;N;;;;;\n1F3E0;HOUSE BUILDING;So;0;ON;;;;;N;;;;;\n1F3E1;HOUSE WITH GARDEN;So;0;ON;;;;;N;;;;;\n1F3E2;OFFICE BUILDING;So;0;ON;;;;;N;;;;;\n1F3E3;JAPANESE POST OFFICE;So;0;ON;;;;;N;;;;;\n1F3E4;EUROPEAN POST OFFICE;So;0;ON;;;;;N;;;;;\n1F3E5;HOSPITAL;So;0;ON;;;;;N;;;;;\n1F3E6;BANK;So;0;ON;;;;;N;;;;;\n1F3E7;AUTOMATED TELLER MACHINE;So;0;ON;;;;;N;;;;;\n1F3E8;HOTEL;So;0;ON;;;;;N;;;;;\n1F3E9;LOVE HOTEL;So;0;ON;;;;;N;;;;;\n1F3EA;CONVENIENCE STORE;So;0;ON;;;;;N;;;;;\n1F3EB;SCHOOL;So;0;ON;;;;;N;;;;;\n1F3EC;DEPARTMENT STORE;So;0;ON;;;;;N;;;;;\n1F3ED;FACTORY;So;0;ON;;;;;N;;;;;\n1F3EE;IZAKAYA LANTERN;So;0;ON;;;;;N;;;;;\n1F3EF;JAPANESE CASTLE;So;0;ON;;;;;N;;;;;\n1F3F0;EUROPEAN CASTLE;So;0;ON;;;;;N;;;;;\n1F400;RAT;So;0;ON;;;;;N;;;;;\n1F401;MOUSE;So;0;ON;;;;;N;;;;;\n1F402;OX;So;0;ON;;;;;N;;;;;\n1F403;WATER BUFFALO;So;0;ON;;;;;N;;;;;\n1F404;COW;So;0;ON;;;;;N;;;;;\n1F405;TIGER;So;0;ON;;;;;N;;;;;\n1F406;LEOPARD;So;0;ON;;;;;N;;;;;\n1F407;RABBIT;So;0;ON;;;;;N;;;;;\n1F408;CAT;So;0;ON;;;;;N;;;;;\n1F409;DRAGON;So;0;ON;;;;;N;;;;;\n1F40A;CROCODILE;So;0;ON;;;;;N;;;;;\n1F40B;WHALE;So;0;ON;;;;;N;;;;;\n1F40C;SNAIL;So;0;ON;;;;;N;;;;;\n1F40D;SNAKE;So;0;ON;;;;;N;;;;;\n1F40E;HORSE;So;0;ON;;;;;N;;;;;\n1F40F;RAM;So;0;ON;;;;;N;;;;;\n1F410;GOAT;So;0;ON;;;;;N;;;;;\n1F411;SHEEP;So;0;ON;;;;;N;;;;;\n1F412;MONKEY;So;0;ON;;;;;N;;;;;\n1F413;ROOSTER;So;0;ON;;;;;N;;;;;\n1F414;CHICKEN;So;0;ON;;;;;N;;;;;\n1F415;DOG;So;0;ON;;;;;N;;;;;\n1F416;PIG;So;0;ON;;;;;N;;;;;\n1F417;BOAR;So;0;ON;;;;;N;;;;;\n1F418;ELEPHANT;So;0;ON;;;;;N;;;;;\n1F419;OCTOPUS;So;0;ON;;;;;N;;;;;\n1F41A;SPIRAL SHELL;So;0;ON;;;;;N;;;;;\n1F41B;BUG;So;0;ON;;;;;N;;;;;\n1F41C;ANT;So;0;ON;;;;;N;;;;;\n1F41D;HONEYBEE;So;0;ON;;;;;N;;;;;\n1F41E;LADY BEETLE;So;0;ON;;;;;N;;;;;\n1F41F;FISH;So;0;ON;;;;;N;;;;;\n1F420;TROPICAL FISH;So;0;ON;;;;;N;;;;;\n1F421;BLOWFISH;So;0;ON;;;;;N;;;;;\n1F422;TURTLE;So;0;ON;;;;;N;;;;;\n1F423;HATCHING CHICK;So;0;ON;;;;;N;;;;;\n1F424;BABY CHICK;So;0;ON;;;;;N;;;;;\n1F425;FRONT-FACING BABY CHICK;So;0;ON;;;;;N;;;;;\n1F426;BIRD;So;0;ON;;;;;N;;;;;\n1F427;PENGUIN;So;0;ON;;;;;N;;;;;\n1F428;KOALA;So;0;ON;;;;;N;;;;;\n1F429;POODLE;So;0;ON;;;;;N;;;;;\n1F42A;DROMEDARY CAMEL;So;0;ON;;;;;N;;;;;\n1F42B;BACTRIAN CAMEL;So;0;ON;;;;;N;;;;;\n1F42C;DOLPHIN;So;0;ON;;;;;N;;;;;\n1F42D;MOUSE FACE;So;0;ON;;;;;N;;;;;\n1F42E;COW FACE;So;0;ON;;;;;N;;;;;\n1F42F;TIGER FACE;So;0;ON;;;;;N;;;;;\n1F430;RABBIT FACE;So;0;ON;;;;;N;;;;;\n1F431;CAT FACE;So;0;ON;;;;;N;;;;;\n1F432;DRAGON FACE;So;0;ON;;;;;N;;;;;\n1F433;SPOUTING WHALE;So;0;ON;;;;;N;;;;;\n1F434;HORSE FACE;So;0;ON;;;;;N;;;;;\n1F435;MONKEY FACE;So;0;ON;;;;;N;;;;;\n1F436;DOG FACE;So;0;ON;;;;;N;;;;;\n1F437;PIG FACE;So;0;ON;;;;;N;;;;;\n1F438;FROG FACE;So;0;ON;;;;;N;;;;;\n1F439;HAMSTER FACE;So;0;ON;;;;;N;;;;;\n1F43A;WOLF FACE;So;0;ON;;;;;N;;;;;\n1F43B;BEAR FACE;So;0;ON;;;;;N;;;;;\n1F43C;PANDA FACE;So;0;ON;;;;;N;;;;;\n1F43D;PIG NOSE;So;0;ON;;;;;N;;;;;\n1F43E;PAW PRINTS;So;0;ON;;;;;N;;;;;\n1F440;EYES;So;0;ON;;;;;N;;;;;\n1F442;EAR;So;0;ON;;;;;N;;;;;\n1F443;NOSE;So;0;ON;;;;;N;;;;;\n1F444;MOUTH;So;0;ON;;;;;N;;;;;\n1F445;TONGUE;So;0;ON;;;;;N;;;;;\n1F446;WHITE UP POINTING BACKHAND INDEX;So;0;ON;;;;;N;;;;;\n1F447;WHITE DOWN POINTING BACKHAND INDEX;So;0;ON;;;;;N;;;;;\n1F448;WHITE LEFT POINTING BACKHAND INDEX;So;0;ON;;;;;N;;;;;\n1F449;WHITE RIGHT POINTING BACKHAND INDEX;So;0;ON;;;;;N;;;;;\n1F44A;FISTED HAND SIGN;So;0;ON;;;;;N;;;;;\n1F44B;WAVING HAND SIGN;So;0;ON;;;;;N;;;;;\n1F44C;OK HAND SIGN;So;0;ON;;;;;N;;;;;\n1F44D;THUMBS UP SIGN;So;0;ON;;;;;N;;;;;\n1F44E;THUMBS DOWN SIGN;So;0;ON;;;;;N;;;;;\n1F44F;CLAPPING HANDS SIGN;So;0;ON;;;;;N;;;;;\n1F450;OPEN HANDS SIGN;So;0;ON;;;;;N;;;;;\n1F451;CROWN;So;0;ON;;;;;N;;;;;\n1F452;WOMANS HAT;So;0;ON;;;;;N;;;;;\n1F453;EYEGLASSES;So;0;ON;;;;;N;;;;;\n1F454;NECKTIE;So;0;ON;;;;;N;;;;;\n1F455;T-SHIRT;So;0;ON;;;;;N;;;;;\n1F456;JEANS;So;0;ON;;;;;N;;;;;\n1F457;DRESS;So;0;ON;;;;;N;;;;;\n1F458;KIMONO;So;0;ON;;;;;N;;;;;\n1F459;BIKINI;So;0;ON;;;;;N;;;;;\n1F45A;WOMANS CLOTHES;So;0;ON;;;;;N;;;;;\n1F45B;PURSE;So;0;ON;;;;;N;;;;;\n1F45C;HANDBAG;So;0;ON;;;;;N;;;;;\n1F45D;POUCH;So;0;ON;;;;;N;;;;;\n1F45E;MANS SHOE;So;0;ON;;;;;N;;;;;\n1F45F;ATHLETIC SHOE;So;0;ON;;;;;N;;;;;\n1F460;HIGH-HEELED SHOE;So;0;ON;;;;;N;;;;;\n1F461;WOMANS SANDAL;So;0;ON;;;;;N;;;;;\n1F462;WOMANS BOOTS;So;0;ON;;;;;N;;;;;\n1F463;FOOTPRINTS;So;0;ON;;;;;N;;;;;\n1F464;BUST IN SILHOUETTE;So;0;ON;;;;;N;;;;;\n1F465;BUSTS IN SILHOUETTE;So;0;ON;;;;;N;;;;;\n1F466;BOY;So;0;ON;;;;;N;;;;;\n1F467;GIRL;So;0;ON;;;;;N;;;;;\n1F468;MAN;So;0;ON;;;;;N;;;;;\n1F469;WOMAN;So;0;ON;;;;;N;;;;;\n1F46A;FAMILY;So;0;ON;;;;;N;;;;;\n1F46B;MAN AND WOMAN HOLDING HANDS;So;0;ON;;;;;N;;;;;\n1F46C;TWO MEN HOLDING HANDS;So;0;ON;;;;;N;;;;;\n1F46D;TWO WOMEN HOLDING HANDS;So;0;ON;;;;;N;;;;;\n1F46E;POLICE OFFICER;So;0;ON;;;;;N;;;;;\n1F46F;WOMAN WITH BUNNY EARS;So;0;ON;;;;;N;;;;;\n1F470;BRIDE WITH VEIL;So;0;ON;;;;;N;;;;;\n1F471;PERSON WITH BLOND HAIR;So;0;ON;;;;;N;;;;;\n1F472;MAN WITH GUA PI MAO;So;0;ON;;;;;N;;;;;\n1F473;MAN WITH TURBAN;So;0;ON;;;;;N;;;;;\n1F474;OLDER MAN;So;0;ON;;;;;N;;;;;\n1F475;OLDER WOMAN;So;0;ON;;;;;N;;;;;\n1F476;BABY;So;0;ON;;;;;N;;;;;\n1F477;CONSTRUCTION WORKER;So;0;ON;;;;;N;;;;;\n1F478;PRINCESS;So;0;ON;;;;;N;;;;;\n1F479;JAPANESE OGRE;So;0;ON;;;;;N;;;;;\n1F47A;JAPANESE GOBLIN;So;0;ON;;;;;N;;;;;\n1F47B;GHOST;So;0;ON;;;;;N;;;;;\n1F47C;BABY ANGEL;So;0;ON;;;;;N;;;;;\n1F47D;EXTRATERRESTRIAL ALIEN;So;0;ON;;;;;N;;;;;\n1F47E;ALIEN MONSTER;So;0;ON;;;;;N;;;;;\n1F47F;IMP;So;0;ON;;;;;N;;;;;\n1F480;SKULL;So;0;ON;;;;;N;;;;;\n1F481;INFORMATION DESK PERSON;So;0;ON;;;;;N;;;;;\n1F482;GUARDSMAN;So;0;ON;;;;;N;;;;;\n1F483;DANCER;So;0;ON;;;;;N;;;;;\n1F484;LIPSTICK;So;0;ON;;;;;N;;;;;\n1F485;NAIL POLISH;So;0;ON;;;;;N;;;;;\n1F486;FACE MASSAGE;So;0;ON;;;;;N;;;;;\n1F487;HAIRCUT;So;0;ON;;;;;N;;;;;\n1F488;BARBER POLE;So;0;ON;;;;;N;;;;;\n1F489;SYRINGE;So;0;ON;;;;;N;;;;;\n1F48A;PILL;So;0;ON;;;;;N;;;;;\n1F48B;KISS MARK;So;0;ON;;;;;N;;;;;\n1F48C;LOVE LETTER;So;0;ON;;;;;N;;;;;\n1F48D;RING;So;0;ON;;;;;N;;;;;\n1F48E;GEM STONE;So;0;ON;;;;;N;;;;;\n1F48F;KISS;So;0;ON;;;;;N;;;;;\n1F490;BOUQUET;So;0;ON;;;;;N;;;;;\n1F491;COUPLE WITH HEART;So;0;ON;;;;;N;;;;;\n1F492;WEDDING;So;0;ON;;;;;N;;;;;\n1F493;BEATING HEART;So;0;ON;;;;;N;;;;;\n1F494;BROKEN HEART;So;0;ON;;;;;N;;;;;\n1F495;TWO HEARTS;So;0;ON;;;;;N;;;;;\n1F496;SPARKLING HEART;So;0;ON;;;;;N;;;;;\n1F497;GROWING HEART;So;0;ON;;;;;N;;;;;\n1F498;HEART WITH ARROW;So;0;ON;;;;;N;;;;;\n1F499;BLUE HEART;So;0;ON;;;;;N;;;;;\n1F49A;GREEN HEART;So;0;ON;;;;;N;;;;;\n1F49B;YELLOW HEART;So;0;ON;;;;;N;;;;;\n1F49C;PURPLE HEART;So;0;ON;;;;;N;;;;;\n1F49D;HEART WITH RIBBON;So;0;ON;;;;;N;;;;;\n1F49E;REVOLVING HEARTS;So;0;ON;;;;;N;;;;;\n1F49F;HEART DECORATION;So;0;ON;;;;;N;;;;;\n1F4A0;DIAMOND SHAPE WITH A DOT INSIDE;So;0;ON;;;;;N;;;;;\n1F4A1;ELECTRIC LIGHT BULB;So;0;ON;;;;;N;;;;;\n1F4A2;ANGER SYMBOL;So;0;ON;;;;;N;;;;;\n1F4A3;BOMB;So;0;ON;;;;;N;;;;;\n1F4A4;SLEEPING SYMBOL;So;0;ON;;;;;N;;;;;\n1F4A5;COLLISION SYMBOL;So;0;ON;;;;;N;;;;;\n1F4A6;SPLASHING SWEAT SYMBOL;So;0;ON;;;;;N;;;;;\n1F4A7;DROPLET;So;0;ON;;;;;N;;;;;\n1F4A8;DASH SYMBOL;So;0;ON;;;;;N;;;;;\n1F4A9;PILE OF POO;So;0;ON;;;;;N;;;;;\n1F4AA;FLEXED BICEPS;So;0;ON;;;;;N;;;;;\n1F4AB;DIZZY SYMBOL;So;0;ON;;;;;N;;;;;\n1F4AC;SPEECH BALLOON;So;0;ON;;;;;N;;;;;\n1F4AD;THOUGHT BALLOON;So;0;ON;;;;;N;;;;;\n1F4AE;WHITE FLOWER;So;0;ON;;;;;N;;;;;\n1F4AF;HUNDRED POINTS SYMBOL;So;0;ON;;;;;N;;;;;\n1F4B0;MONEY BAG;So;0;ON;;;;;N;;;;;\n1F4B1;CURRENCY EXCHANGE;So;0;ON;;;;;N;;;;;\n1F4B2;HEAVY DOLLAR SIGN;So;0;ON;;;;;N;;;;;\n1F4B3;CREDIT CARD;So;0;ON;;;;;N;;;;;\n1F4B4;BANKNOTE WITH YEN SIGN;So;0;ON;;;;;N;;;;;\n1F4B5;BANKNOTE WITH DOLLAR SIGN;So;0;ON;;;;;N;;;;;\n1F4B6;BANKNOTE WITH EURO SIGN;So;0;ON;;;;;N;;;;;\n1F4B7;BANKNOTE WITH POUND SIGN;So;0;ON;;;;;N;;;;;\n1F4B8;MONEY WITH WINGS;So;0;ON;;;;;N;;;;;\n1F4B9;CHART WITH UPWARDS TREND AND YEN SIGN;So;0;ON;;;;;N;;;;;\n1F4BA;SEAT;So;0;ON;;;;;N;;;;;\n1F4BB;PERSONAL COMPUTER;So;0;ON;;;;;N;;;;;\n1F4BC;BRIEFCASE;So;0;ON;;;;;N;;;;;\n1F4BD;MINIDISC;So;0;ON;;;;;N;;;;;\n1F4BE;FLOPPY DISK;So;0;ON;;;;;N;;;;;\n1F4BF;OPTICAL DISC;So;0;ON;;;;;N;;;;;\n1F4C0;DVD;So;0;ON;;;;;N;;;;;\n1F4C1;FILE FOLDER;So;0;ON;;;;;N;;;;;\n1F4C2;OPEN FILE FOLDER;So;0;ON;;;;;N;;;;;\n1F4C3;PAGE WITH CURL;So;0;ON;;;;;N;;;;;\n1F4C4;PAGE FACING UP;So;0;ON;;;;;N;;;;;\n1F4C5;CALENDAR;So;0;ON;;;;;N;;;;;\n1F4C6;TEAR-OFF CALENDAR;So;0;ON;;;;;N;;;;;\n1F4C7;CARD INDEX;So;0;ON;;;;;N;;;;;\n1F4C8;CHART WITH UPWARDS TREND;So;0;ON;;;;;N;;;;;\n1F4C9;CHART WITH DOWNWARDS TREND;So;0;ON;;;;;N;;;;;\n1F4CA;BAR CHART;So;0;ON;;;;;N;;;;;\n1F4CB;CLIPBOARD;So;0;ON;;;;;N;;;;;\n1F4CC;PUSHPIN;So;0;ON;;;;;N;;;;;\n1F4CD;ROUND PUSHPIN;So;0;ON;;;;;N;;;;;\n1F4CE;PAPERCLIP;So;0;ON;;;;;N;;;;;\n1F4CF;STRAIGHT RULER;So;0;ON;;;;;N;;;;;\n1F4D0;TRIANGULAR RULER;So;0;ON;;;;;N;;;;;\n1F4D1;BOOKMARK TABS;So;0;ON;;;;;N;;;;;\n1F4D2;LEDGER;So;0;ON;;;;;N;;;;;\n1F4D3;NOTEBOOK;So;0;ON;;;;;N;;;;;\n1F4D4;NOTEBOOK WITH DECORATIVE COVER;So;0;ON;;;;;N;;;;;\n1F4D5;CLOSED BOOK;So;0;ON;;;;;N;;;;;\n1F4D6;OPEN BOOK;So;0;ON;;;;;N;;;;;\n1F4D7;GREEN BOOK;So;0;ON;;;;;N;;;;;\n1F4D8;BLUE BOOK;So;0;ON;;;;;N;;;;;\n1F4D9;ORANGE BOOK;So;0;ON;;;;;N;;;;;\n1F4DA;BOOKS;So;0;ON;;;;;N;;;;;\n1F4DB;NAME BADGE;So;0;ON;;;;;N;;;;;\n1F4DC;SCROLL;So;0;ON;;;;;N;;;;;\n1F4DD;MEMO;So;0;ON;;;;;N;;;;;\n1F4DE;TELEPHONE RECEIVER;So;0;ON;;;;;N;;;;;\n1F4DF;PAGER;So;0;ON;;;;;N;;;;;\n1F4E0;FAX MACHINE;So;0;ON;;;;;N;;;;;\n1F4E1;SATELLITE ANTENNA;So;0;ON;;;;;N;;;;;\n1F4E2;PUBLIC ADDRESS LOUDSPEAKER;So;0;ON;;;;;N;;;;;\n1F4E3;CHEERING MEGAPHONE;So;0;ON;;;;;N;;;;;\n1F4E4;OUTBOX TRAY;So;0;ON;;;;;N;;;;;\n1F4E5;INBOX TRAY;So;0;ON;;;;;N;;;;;\n1F4E6;PACKAGE;So;0;ON;;;;;N;;;;;\n1F4E7;E-MAIL SYMBOL;So;0;ON;;;;;N;;;;;\n1F4E8;INCOMING ENVELOPE;So;0;ON;;;;;N;;;;;\n1F4E9;ENVELOPE WITH DOWNWARDS ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F4EA;CLOSED MAILBOX WITH LOWERED FLAG;So;0;ON;;;;;N;;;;;\n1F4EB;CLOSED MAILBOX WITH RAISED FLAG;So;0;ON;;;;;N;;;;;\n1F4EC;OPEN MAILBOX WITH RAISED FLAG;So;0;ON;;;;;N;;;;;\n1F4ED;OPEN MAILBOX WITH LOWERED FLAG;So;0;ON;;;;;N;;;;;\n1F4EE;POSTBOX;So;0;ON;;;;;N;;;;;\n1F4EF;POSTAL HORN;So;0;ON;;;;;N;;;;;\n1F4F0;NEWSPAPER;So;0;ON;;;;;N;;;;;\n1F4F1;MOBILE PHONE;So;0;ON;;;;;N;;;;;\n1F4F2;MOBILE PHONE WITH RIGHTWARDS ARROW AT LEFT;So;0;ON;;;;;N;;;;;\n1F4F3;VIBRATION MODE;So;0;ON;;;;;N;;;;;\n1F4F4;MOBILE PHONE OFF;So;0;ON;;;;;N;;;;;\n1F4F5;NO MOBILE PHONES;So;0;ON;;;;;N;;;;;\n1F4F6;ANTENNA WITH BARS;So;0;ON;;;;;N;;;;;\n1F4F7;CAMERA;So;0;ON;;;;;N;;;;;\n1F4F9;VIDEO CAMERA;So;0;ON;;;;;N;;;;;\n1F4FA;TELEVISION;So;0;ON;;;;;N;;;;;\n1F4FB;RADIO;So;0;ON;;;;;N;;;;;\n1F4FC;VIDEOCASSETTE;So;0;ON;;;;;N;;;;;\n1F500;TWISTED RIGHTWARDS ARROWS;So;0;ON;;;;;N;;;;;\n1F501;CLOCKWISE RIGHTWARDS AND LEFTWARDS OPEN CIRCLE ARROWS;So;0;ON;;;;;N;;;;;\n1F502;CLOCKWISE RIGHTWARDS AND LEFTWARDS OPEN CIRCLE ARROWS WITH CIRCLED ONE OVERLAY;So;0;ON;;;;;N;;;;;\n1F503;CLOCKWISE DOWNWARDS AND UPWARDS OPEN CIRCLE ARROWS;So;0;ON;;;;;N;;;;;\n1F504;ANTICLOCKWISE DOWNWARDS AND UPWARDS OPEN CIRCLE ARROWS;So;0;ON;;;;;N;;;;;\n1F505;LOW BRIGHTNESS SYMBOL;So;0;ON;;;;;N;;;;;\n1F506;HIGH BRIGHTNESS SYMBOL;So;0;ON;;;;;N;;;;;\n1F507;SPEAKER WITH CANCELLATION STROKE;So;0;ON;;;;;N;;;;;\n1F508;SPEAKER;So;0;ON;;;;;N;;;;;\n1F509;SPEAKER WITH ONE SOUND WAVE;So;0;ON;;;;;N;;;;;\n1F50A;SPEAKER WITH THREE SOUND WAVES;So;0;ON;;;;;N;;;;;\n1F50B;BATTERY;So;0;ON;;;;;N;;;;;\n1F50C;ELECTRIC PLUG;So;0;ON;;;;;N;;;;;\n1F50D;LEFT-POINTING MAGNIFYING GLASS;So;0;ON;;;;;N;;;;;\n1F50E;RIGHT-POINTING MAGNIFYING GLASS;So;0;ON;;;;;N;;;;;\n1F50F;LOCK WITH INK PEN;So;0;ON;;;;;N;;;;;\n1F510;CLOSED LOCK WITH KEY;So;0;ON;;;;;N;;;;;\n1F511;KEY;So;0;ON;;;;;N;;;;;\n1F512;LOCK;So;0;ON;;;;;N;;;;;\n1F513;OPEN LOCK;So;0;ON;;;;;N;;;;;\n1F514;BELL;So;0;ON;;;;;N;;;;;\n1F515;BELL WITH CANCELLATION STROKE;So;0;ON;;;;;N;;;;;\n1F516;BOOKMARK;So;0;ON;;;;;N;;;;;\n1F517;LINK SYMBOL;So;0;ON;;;;;N;;;;;\n1F518;RADIO BUTTON;So;0;ON;;;;;N;;;;;\n1F519;BACK WITH LEFTWARDS ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F51A;END WITH LEFTWARDS ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F51B;ON WITH EXCLAMATION MARK WITH LEFT RIGHT ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F51C;SOON WITH RIGHTWARDS ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F51D;TOP WITH UPWARDS ARROW ABOVE;So;0;ON;;;;;N;;;;;\n1F51E;NO ONE UNDER EIGHTEEN SYMBOL;So;0;ON;;;;;N;;;;;\n1F51F;KEYCAP TEN;So;0;ON;;;;;N;;;;;\n1F520;INPUT SYMBOL FOR LATIN CAPITAL LETTERS;So;0;ON;;;;;N;;;;;\n1F521;INPUT SYMBOL FOR LATIN SMALL LETTERS;So;0;ON;;;;;N;;;;;\n1F522;INPUT SYMBOL FOR NUMBERS;So;0;ON;;;;;N;;;;;\n1F523;INPUT SYMBOL FOR SYMBOLS;So;0;ON;;;;;N;;;;;\n1F524;INPUT SYMBOL FOR LATIN LETTERS;So;0;ON;;;;;N;;;;;\n1F525;FIRE;So;0;ON;;;;;N;;;;;\n1F526;ELECTRIC TORCH;So;0;ON;;;;;N;;;;;\n1F527;WRENCH;So;0;ON;;;;;N;;;;;\n1F528;HAMMER;So;0;ON;;;;;N;;;;;\n1F529;NUT AND BOLT;So;0;ON;;;;;N;;;;;\n1F52A;HOCHO;So;0;ON;;;;;N;;;;;\n1F52B;PISTOL;So;0;ON;;;;;N;;;;;\n1F52C;MICROSCOPE;So;0;ON;;;;;N;;;;;\n1F52D;TELESCOPE;So;0;ON;;;;;N;;;;;\n1F52E;CRYSTAL BALL;So;0;ON;;;;;N;;;;;\n1F52F;SIX POINTED STAR WITH MIDDLE DOT;So;0;ON;;;;;N;;;;;\n1F530;JAPANESE SYMBOL FOR BEGINNER;So;0;ON;;;;;N;;;;;\n1F531;TRIDENT EMBLEM;So;0;ON;;;;;N;;;;;\n1F532;BLACK SQUARE BUTTON;So;0;ON;;;;;N;;;;;\n1F533;WHITE SQUARE BUTTON;So;0;ON;;;;;N;;;;;\n1F534;LARGE RED CIRCLE;So;0;ON;;;;;N;;;;;\n1F535;LARGE BLUE CIRCLE;So;0;ON;;;;;N;;;;;\n1F536;LARGE ORANGE DIAMOND;So;0;ON;;;;;N;;;;;\n1F537;LARGE BLUE DIAMOND;So;0;ON;;;;;N;;;;;\n1F538;SMALL ORANGE DIAMOND;So;0;ON;;;;;N;;;;;\n1F539;SMALL BLUE DIAMOND;So;0;ON;;;;;N;;;;;\n1F53A;UP-POINTING RED TRIANGLE;So;0;ON;;;;;N;;;;;\n1F53B;DOWN-POINTING RED TRIANGLE;So;0;ON;;;;;N;;;;;\n1F53C;UP-POINTING SMALL RED TRIANGLE;So;0;ON;;;;;N;;;;;\n1F53D;DOWN-POINTING SMALL RED TRIANGLE;So;0;ON;;;;;N;;;;;\n1F540;CIRCLED CROSS POMMEE;So;0;ON;;;;;N;;;;;\n1F541;CROSS POMMEE WITH HALF-CIRCLE BELOW;So;0;ON;;;;;N;;;;;\n1F542;CROSS POMMEE;So;0;ON;;;;;N;;;;;\n1F543;NOTCHED LEFT SEMICIRCLE WITH THREE DOTS;So;0;ON;;;;;N;;;;;\n1F550;CLOCK FACE ONE OCLOCK;So;0;ON;;;;;N;;;;;\n1F551;CLOCK FACE TWO OCLOCK;So;0;ON;;;;;N;;;;;\n1F552;CLOCK FACE THREE OCLOCK;So;0;ON;;;;;N;;;;;\n1F553;CLOCK FACE FOUR OCLOCK;So;0;ON;;;;;N;;;;;\n1F554;CLOCK FACE FIVE OCLOCK;So;0;ON;;;;;N;;;;;\n1F555;CLOCK FACE SIX OCLOCK;So;0;ON;;;;;N;;;;;\n1F556;CLOCK FACE SEVEN OCLOCK;So;0;ON;;;;;N;;;;;\n1F557;CLOCK FACE EIGHT OCLOCK;So;0;ON;;;;;N;;;;;\n1F558;CLOCK FACE NINE OCLOCK;So;0;ON;;;;;N;;;;;\n1F559;CLOCK FACE TEN OCLOCK;So;0;ON;;;;;N;;;;;\n1F55A;CLOCK FACE ELEVEN OCLOCK;So;0;ON;;;;;N;;;;;\n1F55B;CLOCK FACE TWELVE OCLOCK;So;0;ON;;;;;N;;;;;\n1F55C;CLOCK FACE ONE-THIRTY;So;0;ON;;;;;N;;;;;\n1F55D;CLOCK FACE TWO-THIRTY;So;0;ON;;;;;N;;;;;\n1F55E;CLOCK FACE THREE-THIRTY;So;0;ON;;;;;N;;;;;\n1F55F;CLOCK FACE FOUR-THIRTY;So;0;ON;;;;;N;;;;;\n1F560;CLOCK FACE FIVE-THIRTY;So;0;ON;;;;;N;;;;;\n1F561;CLOCK FACE SIX-THIRTY;So;0;ON;;;;;N;;;;;\n1F562;CLOCK FACE SEVEN-THIRTY;So;0;ON;;;;;N;;;;;\n1F563;CLOCK FACE EIGHT-THIRTY;So;0;ON;;;;;N;;;;;\n1F564;CLOCK FACE NINE-THIRTY;So;0;ON;;;;;N;;;;;\n1F565;CLOCK FACE TEN-THIRTY;So;0;ON;;;;;N;;;;;\n1F566;CLOCK FACE ELEVEN-THIRTY;So;0;ON;;;;;N;;;;;\n1F567;CLOCK FACE TWELVE-THIRTY;So;0;ON;;;;;N;;;;;\n1F5FB;MOUNT FUJI;So;0;ON;;;;;N;;;;;\n1F5FC;TOKYO TOWER;So;0;ON;;;;;N;;;;;\n1F5FD;STATUE OF LIBERTY;So;0;ON;;;;;N;;;;;\n1F5FE;SILHOUETTE OF JAPAN;So;0;ON;;;;;N;;;;;\n1F5FF;MOYAI;So;0;ON;;;;;N;;;;;\n1F600;GRINNING FACE;So;0;ON;;;;;N;;;;;\n1F601;GRINNING FACE WITH SMILING EYES;So;0;ON;;;;;N;;;;;\n1F602;FACE WITH TEARS OF JOY;So;0;ON;;;;;N;;;;;\n1F603;SMILING FACE WITH OPEN MOUTH;So;0;ON;;;;;N;;;;;\n1F604;SMILING FACE WITH OPEN MOUTH AND SMILING EYES;So;0;ON;;;;;N;;;;;\n1F605;SMILING FACE WITH OPEN MOUTH AND COLD SWEAT;So;0;ON;;;;;N;;;;;\n1F606;SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES;So;0;ON;;;;;N;;;;;\n1F607;SMILING FACE WITH HALO;So;0;ON;;;;;N;;;;;\n1F608;SMILING FACE WITH HORNS;So;0;ON;;;;;N;;;;;\n1F609;WINKING FACE;So;0;ON;;;;;N;;;;;\n1F60A;SMILING FACE WITH SMILING EYES;So;0;ON;;;;;N;;;;;\n1F60B;FACE SAVOURING DELICIOUS FOOD;So;0;ON;;;;;N;;;;;\n1F60C;RELIEVED FACE;So;0;ON;;;;;N;;;;;\n1F60D;SMILING FACE WITH HEART-SHAPED EYES;So;0;ON;;;;;N;;;;;\n1F60E;SMILING FACE WITH SUNGLASSES;So;0;ON;;;;;N;;;;;\n1F60F;SMIRKING FACE;So;0;ON;;;;;N;;;;;\n1F610;NEUTRAL FACE;So;0;ON;;;;;N;;;;;\n1F611;EXPRESSIONLESS FACE;So;0;ON;;;;;N;;;;;\n1F612;UNAMUSED FACE;So;0;ON;;;;;N;;;;;\n1F613;FACE WITH COLD SWEAT;So;0;ON;;;;;N;;;;;\n1F614;PENSIVE FACE;So;0;ON;;;;;N;;;;;\n1F615;CONFUSED FACE;So;0;ON;;;;;N;;;;;\n1F616;CONFOUNDED FACE;So;0;ON;;;;;N;;;;;\n1F617;KISSING FACE;So;0;ON;;;;;N;;;;;\n1F618;FACE THROWING A KISS;So;0;ON;;;;;N;;;;;\n1F619;KISSING FACE WITH SMILING EYES;So;0;ON;;;;;N;;;;;\n1F61A;KISSING FACE WITH CLOSED EYES;So;0;ON;;;;;N;;;;;\n1F61B;FACE WITH STUCK-OUT TONGUE;So;0;ON;;;;;N;;;;;\n1F61C;FACE WITH STUCK-OUT TONGUE AND WINKING EYE;So;0;ON;;;;;N;;;;;\n1F61D;FACE WITH STUCK-OUT TONGUE AND TIGHTLY-CLOSED EYES;So;0;ON;;;;;N;;;;;\n1F61E;DISAPPOINTED FACE;So;0;ON;;;;;N;;;;;\n1F61F;WORRIED FACE;So;0;ON;;;;;N;;;;;\n1F620;ANGRY FACE;So;0;ON;;;;;N;;;;;\n1F621;POUTING FACE;So;0;ON;;;;;N;;;;;\n1F622;CRYING FACE;So;0;ON;;;;;N;;;;;\n1F623;PERSEVERING FACE;So;0;ON;;;;;N;;;;;\n1F624;FACE WITH LOOK OF TRIUMPH;So;0;ON;;;;;N;;;;;\n1F625;DISAPPOINTED BUT RELIEVED FACE;So;0;ON;;;;;N;;;;;\n1F626;FROWNING FACE WITH OPEN MOUTH;So;0;ON;;;;;N;;;;;\n1F627;ANGUISHED FACE;So;0;ON;;;;;N;;;;;\n1F628;FEARFUL FACE;So;0;ON;;;;;N;;;;;\n1F629;WEARY FACE;So;0;ON;;;;;N;;;;;\n1F62A;SLEEPY FACE;So;0;ON;;;;;N;;;;;\n1F62B;TIRED FACE;So;0;ON;;;;;N;;;;;\n1F62C;GRIMACING FACE;So;0;ON;;;;;N;;;;;\n1F62D;LOUDLY CRYING FACE;So;0;ON;;;;;N;;;;;\n1F62E;FACE WITH OPEN MOUTH;So;0;ON;;;;;N;;;;;\n1F62F;HUSHED FACE;So;0;ON;;;;;N;;;;;\n1F630;FACE WITH OPEN MOUTH AND COLD SWEAT;So;0;ON;;;;;N;;;;;\n1F631;FACE SCREAMING IN FEAR;So;0;ON;;;;;N;;;;;\n1F632;ASTONISHED FACE;So;0;ON;;;;;N;;;;;\n1F633;FLUSHED FACE;So;0;ON;;;;;N;;;;;\n1F634;SLEEPING FACE;So;0;ON;;;;;N;;;;;\n1F635;DIZZY FACE;So;0;ON;;;;;N;;;;;\n1F636;FACE WITHOUT MOUTH;So;0;ON;;;;;N;;;;;\n1F637;FACE WITH MEDICAL MASK;So;0;ON;;;;;N;;;;;\n1F638;GRINNING CAT FACE WITH SMILING EYES;So;0;ON;;;;;N;;;;;\n1F639;CAT FACE WITH TEARS OF JOY;So;0;ON;;;;;N;;;;;\n1F63A;SMILING CAT FACE WITH OPEN MOUTH;So;0;ON;;;;;N;;;;;\n1F63B;SMILING CAT FACE WITH HEART-SHAPED EYES;So;0;ON;;;;;N;;;;;\n1F63C;CAT FACE WITH WRY SMILE;So;0;ON;;;;;N;;;;;\n1F63D;KISSING CAT FACE WITH CLOSED EYES;So;0;ON;;;;;N;;;;;\n1F63E;POUTING CAT FACE;So;0;ON;;;;;N;;;;;\n1F63F;CRYING CAT FACE;So;0;ON;;;;;N;;;;;\n1F640;WEARY CAT FACE;So;0;ON;;;;;N;;;;;\n1F645;FACE WITH NO GOOD GESTURE;So;0;ON;;;;;N;;;;;\n1F646;FACE WITH OK GESTURE;So;0;ON;;;;;N;;;;;\n1F647;PERSON BOWING DEEPLY;So;0;ON;;;;;N;;;;;\n1F648;SEE-NO-EVIL MONKEY;So;0;ON;;;;;N;;;;;\n1F649;HEAR-NO-EVIL MONKEY;So;0;ON;;;;;N;;;;;\n1F64A;SPEAK-NO-EVIL MONKEY;So;0;ON;;;;;N;;;;;\n1F64B;HAPPY PERSON RAISING ONE HAND;So;0;ON;;;;;N;;;;;\n1F64C;PERSON RAISING BOTH HANDS IN CELEBRATION;So;0;ON;;;;;N;;;;;\n1F64D;PERSON FROWNING;So;0;ON;;;;;N;;;;;\n1F64E;PERSON WITH POUTING FACE;So;0;ON;;;;;N;;;;;\n1F64F;PERSON WITH FOLDED HANDS;So;0;ON;;;;;N;;;;;\n1F680;ROCKET;So;0;ON;;;;;N;;;;;\n1F681;HELICOPTER;So;0;ON;;;;;N;;;;;\n1F682;STEAM LOCOMOTIVE;So;0;ON;;;;;N;;;;;\n1F683;RAILWAY CAR;So;0;ON;;;;;N;;;;;\n1F684;HIGH-SPEED TRAIN;So;0;ON;;;;;N;;;;;\n1F685;HIGH-SPEED TRAIN WITH BULLET NOSE;So;0;ON;;;;;N;;;;;\n1F686;TRAIN;So;0;ON;;;;;N;;;;;\n1F687;METRO;So;0;ON;;;;;N;;;;;\n1F688;LIGHT RAIL;So;0;ON;;;;;N;;;;;\n1F689;STATION;So;0;ON;;;;;N;;;;;\n1F68A;TRAM;So;0;ON;;;;;N;;;;;\n1F68B;TRAM CAR;So;0;ON;;;;;N;;;;;\n1F68C;BUS;So;0;ON;;;;;N;;;;;\n1F68D;ONCOMING BUS;So;0;ON;;;;;N;;;;;\n1F68E;TROLLEYBUS;So;0;ON;;;;;N;;;;;\n1F68F;BUS STOP;So;0;ON;;;;;N;;;;;\n1F690;MINIBUS;So;0;ON;;;;;N;;;;;\n1F691;AMBULANCE;So;0;ON;;;;;N;;;;;\n1F692;FIRE ENGINE;So;0;ON;;;;;N;;;;;\n1F693;POLICE CAR;So;0;ON;;;;;N;;;;;\n1F694;ONCOMING POLICE CAR;So;0;ON;;;;;N;;;;;\n1F695;TAXI;So;0;ON;;;;;N;;;;;\n1F696;ONCOMING TAXI;So;0;ON;;;;;N;;;;;\n1F697;AUTOMOBILE;So;0;ON;;;;;N;;;;;\n1F698;ONCOMING AUTOMOBILE;So;0;ON;;;;;N;;;;;\n1F699;RECREATIONAL VEHICLE;So;0;ON;;;;;N;;;;;\n1F69A;DELIVERY TRUCK;So;0;ON;;;;;N;;;;;\n1F69B;ARTICULATED LORRY;So;0;ON;;;;;N;;;;;\n1F69C;TRACTOR;So;0;ON;;;;;N;;;;;\n1F69D;MONORAIL;So;0;ON;;;;;N;;;;;\n1F69E;MOUNTAIN RAILWAY;So;0;ON;;;;;N;;;;;\n1F69F;SUSPENSION RAILWAY;So;0;ON;;;;;N;;;;;\n1F6A0;MOUNTAIN CABLEWAY;So;0;ON;;;;;N;;;;;\n1F6A1;AERIAL TRAMWAY;So;0;ON;;;;;N;;;;;\n1F6A2;SHIP;So;0;ON;;;;;N;;;;;\n1F6A3;ROWBOAT;So;0;ON;;;;;N;;;;;\n1F6A4;SPEEDBOAT;So;0;ON;;;;;N;;;;;\n1F6A5;HORIZONTAL TRAFFIC LIGHT;So;0;ON;;;;;N;;;;;\n1F6A6;VERTICAL TRAFFIC LIGHT;So;0;ON;;;;;N;;;;;\n1F6A7;CONSTRUCTION SIGN;So;0;ON;;;;;N;;;;;\n1F6A8;POLICE CARS REVOLVING LIGHT;So;0;ON;;;;;N;;;;;\n1F6A9;TRIANGULAR FLAG ON POST;So;0;ON;;;;;N;;;;;\n1F6AA;DOOR;So;0;ON;;;;;N;;;;;\n1F6AB;NO ENTRY SIGN;So;0;ON;;;;;N;;;;;\n1F6AC;SMOKING SYMBOL;So;0;ON;;;;;N;;;;;\n1F6AD;NO SMOKING SYMBOL;So;0;ON;;;;;N;;;;;\n1F6AE;PUT LITTER IN ITS PLACE SYMBOL;So;0;ON;;;;;N;;;;;\n1F6AF;DO NOT LITTER SYMBOL;So;0;ON;;;;;N;;;;;\n1F6B0;POTABLE WATER SYMBOL;So;0;ON;;;;;N;;;;;\n1F6B1;NON-POTABLE WATER SYMBOL;So;0;ON;;;;;N;;;;;\n1F6B2;BICYCLE;So;0;ON;;;;;N;;;;;\n1F6B3;NO BICYCLES;So;0;ON;;;;;N;;;;;\n1F6B4;BICYCLIST;So;0;ON;;;;;N;;;;;\n1F6B5;MOUNTAIN BICYCLIST;So;0;ON;;;;;N;;;;;\n1F6B6;PEDESTRIAN;So;0;ON;;;;;N;;;;;\n1F6B7;NO PEDESTRIANS;So;0;ON;;;;;N;;;;;\n1F6B8;CHILDREN CROSSING;So;0;ON;;;;;N;;;;;\n1F6B9;MENS SYMBOL;So;0;ON;;;;;N;;;;;\n1F6BA;WOMENS SYMBOL;So;0;ON;;;;;N;;;;;\n1F6BB;RESTROOM;So;0;ON;;;;;N;;;;;\n1F6BC;BABY SYMBOL;So;0;ON;;;;;N;;;;;\n1F6BD;TOILET;So;0;ON;;;;;N;;;;;\n1F6BE;WATER CLOSET;So;0;ON;;;;;N;;;;;\n1F6BF;SHOWER;So;0;ON;;;;;N;;;;;\n1F6C0;BATH;So;0;ON;;;;;N;;;;;\n1F6C1;BATHTUB;So;0;ON;;;;;N;;;;;\n1F6C2;PASSPORT CONTROL;So;0;ON;;;;;N;;;;;\n1F6C3;CUSTOMS;So;0;ON;;;;;N;;;;;\n1F6C4;BAGGAGE CLAIM;So;0;ON;;;;;N;;;;;\n1F6C5;LEFT LUGGAGE;So;0;ON;;;;;N;;;;;\n1F700;ALCHEMICAL SYMBOL FOR QUINTESSENCE;So;0;ON;;;;;N;;;;;\n1F701;ALCHEMICAL SYMBOL FOR AIR;So;0;ON;;;;;N;;;;;\n1F702;ALCHEMICAL SYMBOL FOR FIRE;So;0;ON;;;;;N;;;;;\n1F703;ALCHEMICAL SYMBOL FOR EARTH;So;0;ON;;;;;N;;;;;\n1F704;ALCHEMICAL SYMBOL FOR WATER;So;0;ON;;;;;N;;;;;\n1F705;ALCHEMICAL SYMBOL FOR AQUAFORTIS;So;0;ON;;;;;N;;;;;\n1F706;ALCHEMICAL SYMBOL FOR AQUA REGIA;So;0;ON;;;;;N;;;;;\n1F707;ALCHEMICAL SYMBOL FOR AQUA REGIA-2;So;0;ON;;;;;N;;;;;\n1F708;ALCHEMICAL SYMBOL FOR AQUA VITAE;So;0;ON;;;;;N;;;;;\n1F709;ALCHEMICAL SYMBOL FOR AQUA VITAE-2;So;0;ON;;;;;N;;;;;\n1F70A;ALCHEMICAL SYMBOL FOR VINEGAR;So;0;ON;;;;;N;;;;;\n1F70B;ALCHEMICAL SYMBOL FOR VINEGAR-2;So;0;ON;;;;;N;;;;;\n1F70C;ALCHEMICAL SYMBOL FOR VINEGAR-3;So;0;ON;;;;;N;;;;;\n1F70D;ALCHEMICAL SYMBOL FOR SULFUR;So;0;ON;;;;;N;;;;;\n1F70E;ALCHEMICAL SYMBOL FOR PHILOSOPHERS SULFUR;So;0;ON;;;;;N;;;;;\n1F70F;ALCHEMICAL SYMBOL FOR BLACK SULFUR;So;0;ON;;;;;N;;;;;\n1F710;ALCHEMICAL SYMBOL FOR MERCURY SUBLIMATE;So;0;ON;;;;;N;;;;;\n1F711;ALCHEMICAL SYMBOL FOR MERCURY SUBLIMATE-2;So;0;ON;;;;;N;;;;;\n1F712;ALCHEMICAL SYMBOL FOR MERCURY SUBLIMATE-3;So;0;ON;;;;;N;;;;;\n1F713;ALCHEMICAL SYMBOL FOR CINNABAR;So;0;ON;;;;;N;;;;;\n1F714;ALCHEMICAL SYMBOL FOR SALT;So;0;ON;;;;;N;;;;;\n1F715;ALCHEMICAL SYMBOL FOR NITRE;So;0;ON;;;;;N;;;;;\n1F716;ALCHEMICAL SYMBOL FOR VITRIOL;So;0;ON;;;;;N;;;;;\n1F717;ALCHEMICAL SYMBOL FOR VITRIOL-2;So;0;ON;;;;;N;;;;;\n1F718;ALCHEMICAL SYMBOL FOR ROCK SALT;So;0;ON;;;;;N;;;;;\n1F719;ALCHEMICAL SYMBOL FOR ROCK SALT-2;So;0;ON;;;;;N;;;;;\n1F71A;ALCHEMICAL SYMBOL FOR GOLD;So;0;ON;;;;;N;;;;;\n1F71B;ALCHEMICAL SYMBOL FOR SILVER;So;0;ON;;;;;N;;;;;\n1F71C;ALCHEMICAL SYMBOL FOR IRON ORE;So;0;ON;;;;;N;;;;;\n1F71D;ALCHEMICAL SYMBOL FOR IRON ORE-2;So;0;ON;;;;;N;;;;;\n1F71E;ALCHEMICAL SYMBOL FOR CROCUS OF IRON;So;0;ON;;;;;N;;;;;\n1F71F;ALCHEMICAL SYMBOL FOR REGULUS OF IRON;So;0;ON;;;;;N;;;;;\n1F720;ALCHEMICAL SYMBOL FOR COPPER ORE;So;0;ON;;;;;N;;;;;\n1F721;ALCHEMICAL SYMBOL FOR IRON-COPPER ORE;So;0;ON;;;;;N;;;;;\n1F722;ALCHEMICAL SYMBOL FOR SUBLIMATE OF COPPER;So;0;ON;;;;;N;;;;;\n1F723;ALCHEMICAL SYMBOL FOR CROCUS OF COPPER;So;0;ON;;;;;N;;;;;\n1F724;ALCHEMICAL SYMBOL FOR CROCUS OF COPPER-2;So;0;ON;;;;;N;;;;;\n1F725;ALCHEMICAL SYMBOL FOR COPPER ANTIMONIATE;So;0;ON;;;;;N;;;;;\n1F726;ALCHEMICAL SYMBOL FOR SALT OF COPPER ANTIMONIATE;So;0;ON;;;;;N;;;;;\n1F727;ALCHEMICAL SYMBOL FOR SUBLIMATE OF SALT OF COPPER;So;0;ON;;;;;N;;;;;\n1F728;ALCHEMICAL SYMBOL FOR VERDIGRIS;So;0;ON;;;;;N;;;;;\n1F729;ALCHEMICAL SYMBOL FOR TIN ORE;So;0;ON;;;;;N;;;;;\n1F72A;ALCHEMICAL SYMBOL FOR LEAD ORE;So;0;ON;;;;;N;;;;;\n1F72B;ALCHEMICAL SYMBOL FOR ANTIMONY ORE;So;0;ON;;;;;N;;;;;\n1F72C;ALCHEMICAL SYMBOL FOR SUBLIMATE OF ANTIMONY;So;0;ON;;;;;N;;;;;\n1F72D;ALCHEMICAL SYMBOL FOR SALT OF ANTIMONY;So;0;ON;;;;;N;;;;;\n1F72E;ALCHEMICAL SYMBOL FOR SUBLIMATE OF SALT OF ANTIMONY;So;0;ON;;;;;N;;;;;\n1F72F;ALCHEMICAL SYMBOL FOR VINEGAR OF ANTIMONY;So;0;ON;;;;;N;;;;;\n1F730;ALCHEMICAL SYMBOL FOR REGULUS OF ANTIMONY;So;0;ON;;;;;N;;;;;\n1F731;ALCHEMICAL SYMBOL FOR REGULUS OF ANTIMONY-2;So;0;ON;;;;;N;;;;;\n1F732;ALCHEMICAL SYMBOL FOR REGULUS;So;0;ON;;;;;N;;;;;\n1F733;ALCHEMICAL SYMBOL FOR REGULUS-2;So;0;ON;;;;;N;;;;;\n1F734;ALCHEMICAL SYMBOL FOR REGULUS-3;So;0;ON;;;;;N;;;;;\n1F735;ALCHEMICAL SYMBOL FOR REGULUS-4;So;0;ON;;;;;N;;;;;\n1F736;ALCHEMICAL SYMBOL FOR ALKALI;So;0;ON;;;;;N;;;;;\n1F737;ALCHEMICAL SYMBOL FOR ALKALI-2;So;0;ON;;;;;N;;;;;\n1F738;ALCHEMICAL SYMBOL FOR MARCASITE;So;0;ON;;;;;N;;;;;\n1F739;ALCHEMICAL SYMBOL FOR SAL-AMMONIAC;So;0;ON;;;;;N;;;;;\n1F73A;ALCHEMICAL SYMBOL FOR ARSENIC;So;0;ON;;;;;N;;;;;\n1F73B;ALCHEMICAL SYMBOL FOR REALGAR;So;0;ON;;;;;N;;;;;\n1F73C;ALCHEMICAL SYMBOL FOR REALGAR-2;So;0;ON;;;;;N;;;;;\n1F73D;ALCHEMICAL SYMBOL FOR AURIPIGMENT;So;0;ON;;;;;N;;;;;\n1F73E;ALCHEMICAL SYMBOL FOR BISMUTH ORE;So;0;ON;;;;;N;;;;;\n1F73F;ALCHEMICAL SYMBOL FOR TARTAR;So;0;ON;;;;;N;;;;;\n1F740;ALCHEMICAL SYMBOL FOR TARTAR-2;So;0;ON;;;;;N;;;;;\n1F741;ALCHEMICAL SYMBOL FOR QUICK LIME;So;0;ON;;;;;N;;;;;\n1F742;ALCHEMICAL SYMBOL FOR BORAX;So;0;ON;;;;;N;;;;;\n1F743;ALCHEMICAL SYMBOL FOR BORAX-2;So;0;ON;;;;;N;;;;;\n1F744;ALCHEMICAL SYMBOL FOR BORAX-3;So;0;ON;;;;;N;;;;;\n1F745;ALCHEMICAL SYMBOL FOR ALUM;So;0;ON;;;;;N;;;;;\n1F746;ALCHEMICAL SYMBOL FOR OIL;So;0;ON;;;;;N;;;;;\n1F747;ALCHEMICAL SYMBOL FOR SPIRIT;So;0;ON;;;;;N;;;;;\n1F748;ALCHEMICAL SYMBOL FOR TINCTURE;So;0;ON;;;;;N;;;;;\n1F749;ALCHEMICAL SYMBOL FOR GUM;So;0;ON;;;;;N;;;;;\n1F74A;ALCHEMICAL SYMBOL FOR WAX;So;0;ON;;;;;N;;;;;\n1F74B;ALCHEMICAL SYMBOL FOR POWDER;So;0;ON;;;;;N;;;;;\n1F74C;ALCHEMICAL SYMBOL FOR CALX;So;0;ON;;;;;N;;;;;\n1F74D;ALCHEMICAL SYMBOL FOR TUTTY;So;0;ON;;;;;N;;;;;\n1F74E;ALCHEMICAL SYMBOL FOR CAPUT MORTUUM;So;0;ON;;;;;N;;;;;\n1F74F;ALCHEMICAL SYMBOL FOR SCEPTER OF JOVE;So;0;ON;;;;;N;;;;;\n1F750;ALCHEMICAL SYMBOL FOR CADUCEUS;So;0;ON;;;;;N;;;;;\n1F751;ALCHEMICAL SYMBOL FOR TRIDENT;So;0;ON;;;;;N;;;;;\n1F752;ALCHEMICAL SYMBOL FOR STARRED TRIDENT;So;0;ON;;;;;N;;;;;\n1F753;ALCHEMICAL SYMBOL FOR LODESTONE;So;0;ON;;;;;N;;;;;\n1F754;ALCHEMICAL SYMBOL FOR SOAP;So;0;ON;;;;;N;;;;;\n1F755;ALCHEMICAL SYMBOL FOR URINE;So;0;ON;;;;;N;;;;;\n1F756;ALCHEMICAL SYMBOL FOR HORSE DUNG;So;0;ON;;;;;N;;;;;\n1F757;ALCHEMICAL SYMBOL FOR ASHES;So;0;ON;;;;;N;;;;;\n1F758;ALCHEMICAL SYMBOL FOR POT ASHES;So;0;ON;;;;;N;;;;;\n1F759;ALCHEMICAL SYMBOL FOR BRICK;So;0;ON;;;;;N;;;;;\n1F75A;ALCHEMICAL SYMBOL FOR POWDERED BRICK;So;0;ON;;;;;N;;;;;\n1F75B;ALCHEMICAL SYMBOL FOR AMALGAM;So;0;ON;;;;;N;;;;;\n1F75C;ALCHEMICAL SYMBOL FOR STRATUM SUPER STRATUM;So;0;ON;;;;;N;;;;;\n1F75D;ALCHEMICAL SYMBOL FOR STRATUM SUPER STRATUM-2;So;0;ON;;;;;N;;;;;\n1F75E;ALCHEMICAL SYMBOL FOR SUBLIMATION;So;0;ON;;;;;N;;;;;\n1F75F;ALCHEMICAL SYMBOL FOR PRECIPITATE;So;0;ON;;;;;N;;;;;\n1F760;ALCHEMICAL SYMBOL FOR DISTILL;So;0;ON;;;;;N;;;;;\n1F761;ALCHEMICAL SYMBOL FOR DISSOLVE;So;0;ON;;;;;N;;;;;\n1F762;ALCHEMICAL SYMBOL FOR DISSOLVE-2;So;0;ON;;;;;N;;;;;\n1F763;ALCHEMICAL SYMBOL FOR PURIFY;So;0;ON;;;;;N;;;;;\n1F764;ALCHEMICAL SYMBOL FOR PUTREFACTION;So;0;ON;;;;;N;;;;;\n1F765;ALCHEMICAL SYMBOL FOR CRUCIBLE;So;0;ON;;;;;N;;;;;\n1F766;ALCHEMICAL SYMBOL FOR CRUCIBLE-2;So;0;ON;;;;;N;;;;;\n1F767;ALCHEMICAL SYMBOL FOR CRUCIBLE-3;So;0;ON;;;;;N;;;;;\n1F768;ALCHEMICAL SYMBOL FOR CRUCIBLE-4;So;0;ON;;;;;N;;;;;\n1F769;ALCHEMICAL SYMBOL FOR CRUCIBLE-5;So;0;ON;;;;;N;;;;;\n1F76A;ALCHEMICAL SYMBOL FOR ALEMBIC;So;0;ON;;;;;N;;;;;\n1F76B;ALCHEMICAL SYMBOL FOR BATH OF MARY;So;0;ON;;;;;N;;;;;\n1F76C;ALCHEMICAL SYMBOL FOR BATH OF VAPOURS;So;0;ON;;;;;N;;;;;\n1F76D;ALCHEMICAL SYMBOL FOR RETORT;So;0;ON;;;;;N;;;;;\n1F76E;ALCHEMICAL SYMBOL FOR HOUR;So;0;ON;;;;;N;;;;;\n1F76F;ALCHEMICAL SYMBOL FOR NIGHT;So;0;ON;;;;;N;;;;;\n1F770;ALCHEMICAL SYMBOL FOR DAY-NIGHT;So;0;ON;;;;;N;;;;;\n1F771;ALCHEMICAL SYMBOL FOR MONTH;So;0;ON;;;;;N;;;;;\n1F772;ALCHEMICAL SYMBOL FOR HALF DRAM;So;0;ON;;;;;N;;;;;\n1F773;ALCHEMICAL SYMBOL FOR HALF OUNCE;So;0;ON;;;;;N;;;;;\n20000;<CJK Ideograph Extension B, First>;Lo;0;L;;;;;N;;;;;\n2A6D6;<CJK Ideograph Extension B, Last>;Lo;0;L;;;;;N;;;;;\n2A700;<CJK Ideograph Extension C, First>;Lo;0;L;;;;;N;;;;;\n2B734;<CJK Ideograph Extension C, Last>;Lo;0;L;;;;;N;;;;;\n2B740;<CJK Ideograph Extension D, First>;Lo;0;L;;;;;N;;;;;\n2B81D;<CJK Ideograph Extension D, Last>;Lo;0;L;;;;;N;;;;;\n2F800;CJK COMPATIBILITY IDEOGRAPH-2F800;Lo;0;L;4E3D;;;;N;;;;;\n2F801;CJK COMPATIBILITY IDEOGRAPH-2F801;Lo;0;L;4E38;;;;N;;;;;\n2F802;CJK COMPATIBILITY IDEOGRAPH-2F802;Lo;0;L;4E41;;;;N;;;;;\n2F803;CJK COMPATIBILITY IDEOGRAPH-2F803;Lo;0;L;20122;;;;N;;;;;\n2F804;CJK COMPATIBILITY IDEOGRAPH-2F804;Lo;0;L;4F60;;;;N;;;;;\n2F805;CJK COMPATIBILITY IDEOGRAPH-2F805;Lo;0;L;4FAE;;;;N;;;;;\n2F806;CJK COMPATIBILITY IDEOGRAPH-2F806;Lo;0;L;4FBB;;;;N;;;;;\n2F807;CJK COMPATIBILITY IDEOGRAPH-2F807;Lo;0;L;5002;;;;N;;;;;\n2F808;CJK COMPATIBILITY IDEOGRAPH-2F808;Lo;0;L;507A;;;;N;;;;;\n2F809;CJK COMPATIBILITY IDEOGRAPH-2F809;Lo;0;L;5099;;;;N;;;;;\n2F80A;CJK COMPATIBILITY IDEOGRAPH-2F80A;Lo;0;L;50E7;;;;N;;;;;\n2F80B;CJK COMPATIBILITY IDEOGRAPH-2F80B;Lo;0;L;50CF;;;;N;;;;;\n2F80C;CJK COMPATIBILITY IDEOGRAPH-2F80C;Lo;0;L;349E;;;;N;;;;;\n2F80D;CJK COMPATIBILITY IDEOGRAPH-2F80D;Lo;0;L;2063A;;;;N;;;;;\n2F80E;CJK COMPATIBILITY IDEOGRAPH-2F80E;Lo;0;L;514D;;;;N;;;;;\n2F80F;CJK COMPATIBILITY IDEOGRAPH-2F80F;Lo;0;L;5154;;;;N;;;;;\n2F810;CJK COMPATIBILITY IDEOGRAPH-2F810;Lo;0;L;5164;;;;N;;;;;\n2F811;CJK COMPATIBILITY IDEOGRAPH-2F811;Lo;0;L;5177;;;;N;;;;;\n2F812;CJK COMPATIBILITY IDEOGRAPH-2F812;Lo;0;L;2051C;;;;N;;;;;\n2F813;CJK COMPATIBILITY IDEOGRAPH-2F813;Lo;0;L;34B9;;;;N;;;;;\n2F814;CJK COMPATIBILITY IDEOGRAPH-2F814;Lo;0;L;5167;;;;N;;;;;\n2F815;CJK COMPATIBILITY IDEOGRAPH-2F815;Lo;0;L;518D;;;;N;;;;;\n2F816;CJK COMPATIBILITY IDEOGRAPH-2F816;Lo;0;L;2054B;;;;N;;;;;\n2F817;CJK COMPATIBILITY IDEOGRAPH-2F817;Lo;0;L;5197;;;;N;;;;;\n2F818;CJK COMPATIBILITY IDEOGRAPH-2F818;Lo;0;L;51A4;;;;N;;;;;\n2F819;CJK COMPATIBILITY IDEOGRAPH-2F819;Lo;0;L;4ECC;;;;N;;;;;\n2F81A;CJK COMPATIBILITY IDEOGRAPH-2F81A;Lo;0;L;51AC;;;;N;;;;;\n2F81B;CJK COMPATIBILITY IDEOGRAPH-2F81B;Lo;0;L;51B5;;;;N;;;;;\n2F81C;CJK COMPATIBILITY IDEOGRAPH-2F81C;Lo;0;L;291DF;;;;N;;;;;\n2F81D;CJK COMPATIBILITY IDEOGRAPH-2F81D;Lo;0;L;51F5;;;;N;;;;;\n2F81E;CJK COMPATIBILITY IDEOGRAPH-2F81E;Lo;0;L;5203;;;;N;;;;;\n2F81F;CJK COMPATIBILITY IDEOGRAPH-2F81F;Lo;0;L;34DF;;;;N;;;;;\n2F820;CJK COMPATIBILITY IDEOGRAPH-2F820;Lo;0;L;523B;;;;N;;;;;\n2F821;CJK COMPATIBILITY IDEOGRAPH-2F821;Lo;0;L;5246;;;;N;;;;;\n2F822;CJK COMPATIBILITY IDEOGRAPH-2F822;Lo;0;L;5272;;;;N;;;;;\n2F823;CJK COMPATIBILITY IDEOGRAPH-2F823;Lo;0;L;5277;;;;N;;;;;\n2F824;CJK COMPATIBILITY IDEOGRAPH-2F824;Lo;0;L;3515;;;;N;;;;;\n2F825;CJK COMPATIBILITY IDEOGRAPH-2F825;Lo;0;L;52C7;;;;N;;;;;\n2F826;CJK COMPATIBILITY IDEOGRAPH-2F826;Lo;0;L;52C9;;;;N;;;;;\n2F827;CJK COMPATIBILITY IDEOGRAPH-2F827;Lo;0;L;52E4;;;;N;;;;;\n2F828;CJK COMPATIBILITY IDEOGRAPH-2F828;Lo;0;L;52FA;;;;N;;;;;\n2F829;CJK COMPATIBILITY IDEOGRAPH-2F829;Lo;0;L;5305;;;;N;;;;;\n2F82A;CJK COMPATIBILITY IDEOGRAPH-2F82A;Lo;0;L;5306;;;;N;;;;;\n2F82B;CJK COMPATIBILITY IDEOGRAPH-2F82B;Lo;0;L;5317;;;;N;;;;;\n2F82C;CJK COMPATIBILITY IDEOGRAPH-2F82C;Lo;0;L;5349;;;;N;;;;;\n2F82D;CJK COMPATIBILITY IDEOGRAPH-2F82D;Lo;0;L;5351;;;;N;;;;;\n2F82E;CJK COMPATIBILITY IDEOGRAPH-2F82E;Lo;0;L;535A;;;;N;;;;;\n2F82F;CJK COMPATIBILITY IDEOGRAPH-2F82F;Lo;0;L;5373;;;;N;;;;;\n2F830;CJK COMPATIBILITY IDEOGRAPH-2F830;Lo;0;L;537D;;;;N;;;;;\n2F831;CJK COMPATIBILITY IDEOGRAPH-2F831;Lo;0;L;537F;;;;N;;;;;\n2F832;CJK COMPATIBILITY IDEOGRAPH-2F832;Lo;0;L;537F;;;;N;;;;;\n2F833;CJK COMPATIBILITY IDEOGRAPH-2F833;Lo;0;L;537F;;;;N;;;;;\n2F834;CJK COMPATIBILITY IDEOGRAPH-2F834;Lo;0;L;20A2C;;;;N;;;;;\n2F835;CJK COMPATIBILITY IDEOGRAPH-2F835;Lo;0;L;7070;;;;N;;;;;\n2F836;CJK COMPATIBILITY IDEOGRAPH-2F836;Lo;0;L;53CA;;;;N;;;;;\n2F837;CJK COMPATIBILITY IDEOGRAPH-2F837;Lo;0;L;53DF;;;;N;;;;;\n2F838;CJK COMPATIBILITY IDEOGRAPH-2F838;Lo;0;L;20B63;;;;N;;;;;\n2F839;CJK COMPATIBILITY IDEOGRAPH-2F839;Lo;0;L;53EB;;;;N;;;;;\n2F83A;CJK COMPATIBILITY IDEOGRAPH-2F83A;Lo;0;L;53F1;;;;N;;;;;\n2F83B;CJK COMPATIBILITY IDEOGRAPH-2F83B;Lo;0;L;5406;;;;N;;;;;\n2F83C;CJK COMPATIBILITY IDEOGRAPH-2F83C;Lo;0;L;549E;;;;N;;;;;\n2F83D;CJK COMPATIBILITY IDEOGRAPH-2F83D;Lo;0;L;5438;;;;N;;;;;\n2F83E;CJK COMPATIBILITY IDEOGRAPH-2F83E;Lo;0;L;5448;;;;N;;;;;\n2F83F;CJK COMPATIBILITY IDEOGRAPH-2F83F;Lo;0;L;5468;;;;N;;;;;\n2F840;CJK COMPATIBILITY IDEOGRAPH-2F840;Lo;0;L;54A2;;;;N;;;;;\n2F841;CJK COMPATIBILITY IDEOGRAPH-2F841;Lo;0;L;54F6;;;;N;;;;;\n2F842;CJK COMPATIBILITY IDEOGRAPH-2F842;Lo;0;L;5510;;;;N;;;;;\n2F843;CJK COMPATIBILITY IDEOGRAPH-2F843;Lo;0;L;5553;;;;N;;;;;\n2F844;CJK COMPATIBILITY IDEOGRAPH-2F844;Lo;0;L;5563;;;;N;;;;;\n2F845;CJK COMPATIBILITY IDEOGRAPH-2F845;Lo;0;L;5584;;;;N;;;;;\n2F846;CJK COMPATIBILITY IDEOGRAPH-2F846;Lo;0;L;5584;;;;N;;;;;\n2F847;CJK COMPATIBILITY IDEOGRAPH-2F847;Lo;0;L;5599;;;;N;;;;;\n2F848;CJK COMPATIBILITY IDEOGRAPH-2F848;Lo;0;L;55AB;;;;N;;;;;\n2F849;CJK COMPATIBILITY IDEOGRAPH-2F849;Lo;0;L;55B3;;;;N;;;;;\n2F84A;CJK COMPATIBILITY IDEOGRAPH-2F84A;Lo;0;L;55C2;;;;N;;;;;\n2F84B;CJK COMPATIBILITY IDEOGRAPH-2F84B;Lo;0;L;5716;;;;N;;;;;\n2F84C;CJK COMPATIBILITY IDEOGRAPH-2F84C;Lo;0;L;5606;;;;N;;;;;\n2F84D;CJK COMPATIBILITY IDEOGRAPH-2F84D;Lo;0;L;5717;;;;N;;;;;\n2F84E;CJK COMPATIBILITY IDEOGRAPH-2F84E;Lo;0;L;5651;;;;N;;;;;\n2F84F;CJK COMPATIBILITY IDEOGRAPH-2F84F;Lo;0;L;5674;;;;N;;;;;\n2F850;CJK COMPATIBILITY IDEOGRAPH-2F850;Lo;0;L;5207;;;;N;;;;;\n2F851;CJK COMPATIBILITY IDEOGRAPH-2F851;Lo;0;L;58EE;;;;N;;;;;\n2F852;CJK COMPATIBILITY IDEOGRAPH-2F852;Lo;0;L;57CE;;;;N;;;;;\n2F853;CJK COMPATIBILITY IDEOGRAPH-2F853;Lo;0;L;57F4;;;;N;;;;;\n2F854;CJK COMPATIBILITY IDEOGRAPH-2F854;Lo;0;L;580D;;;;N;;;;;\n2F855;CJK COMPATIBILITY IDEOGRAPH-2F855;Lo;0;L;578B;;;;N;;;;;\n2F856;CJK COMPATIBILITY IDEOGRAPH-2F856;Lo;0;L;5832;;;;N;;;;;\n2F857;CJK COMPATIBILITY IDEOGRAPH-2F857;Lo;0;L;5831;;;;N;;;;;\n2F858;CJK COMPATIBILITY IDEOGRAPH-2F858;Lo;0;L;58AC;;;;N;;;;;\n2F859;CJK COMPATIBILITY IDEOGRAPH-2F859;Lo;0;L;214E4;;;;N;;;;;\n2F85A;CJK COMPATIBILITY IDEOGRAPH-2F85A;Lo;0;L;58F2;;;;N;;;;;\n2F85B;CJK COMPATIBILITY IDEOGRAPH-2F85B;Lo;0;L;58F7;;;;N;;;;;\n2F85C;CJK COMPATIBILITY IDEOGRAPH-2F85C;Lo;0;L;5906;;;;N;;;;;\n2F85D;CJK COMPATIBILITY IDEOGRAPH-2F85D;Lo;0;L;591A;;;;N;;;;;\n2F85E;CJK COMPATIBILITY IDEOGRAPH-2F85E;Lo;0;L;5922;;;;N;;;;;\n2F85F;CJK COMPATIBILITY IDEOGRAPH-2F85F;Lo;0;L;5962;;;;N;;;;;\n2F860;CJK COMPATIBILITY IDEOGRAPH-2F860;Lo;0;L;216A8;;;;N;;;;;\n2F861;CJK COMPATIBILITY IDEOGRAPH-2F861;Lo;0;L;216EA;;;;N;;;;;\n2F862;CJK COMPATIBILITY IDEOGRAPH-2F862;Lo;0;L;59EC;;;;N;;;;;\n2F863;CJK COMPATIBILITY IDEOGRAPH-2F863;Lo;0;L;5A1B;;;;N;;;;;\n2F864;CJK COMPATIBILITY IDEOGRAPH-2F864;Lo;0;L;5A27;;;;N;;;;;\n2F865;CJK COMPATIBILITY IDEOGRAPH-2F865;Lo;0;L;59D8;;;;N;;;;;\n2F866;CJK COMPATIBILITY IDEOGRAPH-2F866;Lo;0;L;5A66;;;;N;;;;;\n2F867;CJK COMPATIBILITY IDEOGRAPH-2F867;Lo;0;L;36EE;;;;N;;;;;\n2F868;CJK COMPATIBILITY IDEOGRAPH-2F868;Lo;0;L;36FC;;;;N;;;;;\n2F869;CJK COMPATIBILITY IDEOGRAPH-2F869;Lo;0;L;5B08;;;;N;;;;;\n2F86A;CJK COMPATIBILITY IDEOGRAPH-2F86A;Lo;0;L;5B3E;;;;N;;;;;\n2F86B;CJK COMPATIBILITY IDEOGRAPH-2F86B;Lo;0;L;5B3E;;;;N;;;;;\n2F86C;CJK COMPATIBILITY IDEOGRAPH-2F86C;Lo;0;L;219C8;;;;N;;;;;\n2F86D;CJK COMPATIBILITY IDEOGRAPH-2F86D;Lo;0;L;5BC3;;;;N;;;;;\n2F86E;CJK COMPATIBILITY IDEOGRAPH-2F86E;Lo;0;L;5BD8;;;;N;;;;;\n2F86F;CJK COMPATIBILITY IDEOGRAPH-2F86F;Lo;0;L;5BE7;;;;N;;;;;\n2F870;CJK COMPATIBILITY IDEOGRAPH-2F870;Lo;0;L;5BF3;;;;N;;;;;\n2F871;CJK COMPATIBILITY IDEOGRAPH-2F871;Lo;0;L;21B18;;;;N;;;;;\n2F872;CJK COMPATIBILITY IDEOGRAPH-2F872;Lo;0;L;5BFF;;;;N;;;;;\n2F873;CJK COMPATIBILITY IDEOGRAPH-2F873;Lo;0;L;5C06;;;;N;;;;;\n2F874;CJK COMPATIBILITY IDEOGRAPH-2F874;Lo;0;L;5F53;;;;N;;;;;\n2F875;CJK COMPATIBILITY IDEOGRAPH-2F875;Lo;0;L;5C22;;;;N;;;;;\n2F876;CJK COMPATIBILITY IDEOGRAPH-2F876;Lo;0;L;3781;;;;N;;;;;\n2F877;CJK COMPATIBILITY IDEOGRAPH-2F877;Lo;0;L;5C60;;;;N;;;;;\n2F878;CJK COMPATIBILITY IDEOGRAPH-2F878;Lo;0;L;5C6E;;;;N;;;;;\n2F879;CJK COMPATIBILITY IDEOGRAPH-2F879;Lo;0;L;5CC0;;;;N;;;;;\n2F87A;CJK COMPATIBILITY IDEOGRAPH-2F87A;Lo;0;L;5C8D;;;;N;;;;;\n2F87B;CJK COMPATIBILITY IDEOGRAPH-2F87B;Lo;0;L;21DE4;;;;N;;;;;\n2F87C;CJK COMPATIBILITY IDEOGRAPH-2F87C;Lo;0;L;5D43;;;;N;;;;;\n2F87D;CJK COMPATIBILITY IDEOGRAPH-2F87D;Lo;0;L;21DE6;;;;N;;;;;\n2F87E;CJK COMPATIBILITY IDEOGRAPH-2F87E;Lo;0;L;5D6E;;;;N;;;;;\n2F87F;CJK COMPATIBILITY IDEOGRAPH-2F87F;Lo;0;L;5D6B;;;;N;;;;;\n2F880;CJK COMPATIBILITY IDEOGRAPH-2F880;Lo;0;L;5D7C;;;;N;;;;;\n2F881;CJK COMPATIBILITY IDEOGRAPH-2F881;Lo;0;L;5DE1;;;;N;;;;;\n2F882;CJK COMPATIBILITY IDEOGRAPH-2F882;Lo;0;L;5DE2;;;;N;;;;;\n2F883;CJK COMPATIBILITY IDEOGRAPH-2F883;Lo;0;L;382F;;;;N;;;;;\n2F884;CJK COMPATIBILITY IDEOGRAPH-2F884;Lo;0;L;5DFD;;;;N;;;;;\n2F885;CJK COMPATIBILITY IDEOGRAPH-2F885;Lo;0;L;5E28;;;;N;;;;;\n2F886;CJK COMPATIBILITY IDEOGRAPH-2F886;Lo;0;L;5E3D;;;;N;;;;;\n2F887;CJK COMPATIBILITY IDEOGRAPH-2F887;Lo;0;L;5E69;;;;N;;;;;\n2F888;CJK COMPATIBILITY IDEOGRAPH-2F888;Lo;0;L;3862;;;;N;;;;;\n2F889;CJK COMPATIBILITY IDEOGRAPH-2F889;Lo;0;L;22183;;;;N;;;;;\n2F88A;CJK COMPATIBILITY IDEOGRAPH-2F88A;Lo;0;L;387C;;;;N;;;;;\n2F88B;CJK COMPATIBILITY IDEOGRAPH-2F88B;Lo;0;L;5EB0;;;;N;;;;;\n2F88C;CJK COMPATIBILITY IDEOGRAPH-2F88C;Lo;0;L;5EB3;;;;N;;;;;\n2F88D;CJK COMPATIBILITY IDEOGRAPH-2F88D;Lo;0;L;5EB6;;;;N;;;;;\n2F88E;CJK COMPATIBILITY IDEOGRAPH-2F88E;Lo;0;L;5ECA;;;;N;;;;;\n2F88F;CJK COMPATIBILITY IDEOGRAPH-2F88F;Lo;0;L;2A392;;;;N;;;;;\n2F890;CJK COMPATIBILITY IDEOGRAPH-2F890;Lo;0;L;5EFE;;;9;N;;;;;\n2F891;CJK COMPATIBILITY IDEOGRAPH-2F891;Lo;0;L;22331;;;;N;;;;;\n2F892;CJK COMPATIBILITY IDEOGRAPH-2F892;Lo;0;L;22331;;;;N;;;;;\n2F893;CJK COMPATIBILITY IDEOGRAPH-2F893;Lo;0;L;8201;;;;N;;;;;\n2F894;CJK COMPATIBILITY IDEOGRAPH-2F894;Lo;0;L;5F22;;;;N;;;;;\n2F895;CJK COMPATIBILITY IDEOGRAPH-2F895;Lo;0;L;5F22;;;;N;;;;;\n2F896;CJK COMPATIBILITY IDEOGRAPH-2F896;Lo;0;L;38C7;;;;N;;;;;\n2F897;CJK COMPATIBILITY IDEOGRAPH-2F897;Lo;0;L;232B8;;;;N;;;;;\n2F898;CJK COMPATIBILITY IDEOGRAPH-2F898;Lo;0;L;261DA;;;;N;;;;;\n2F899;CJK COMPATIBILITY IDEOGRAPH-2F899;Lo;0;L;5F62;;;;N;;;;;\n2F89A;CJK COMPATIBILITY IDEOGRAPH-2F89A;Lo;0;L;5F6B;;;;N;;;;;\n2F89B;CJK COMPATIBILITY IDEOGRAPH-2F89B;Lo;0;L;38E3;;;;N;;;;;\n2F89C;CJK COMPATIBILITY IDEOGRAPH-2F89C;Lo;0;L;5F9A;;;;N;;;;;\n2F89D;CJK COMPATIBILITY IDEOGRAPH-2F89D;Lo;0;L;5FCD;;;;N;;;;;\n2F89E;CJK COMPATIBILITY IDEOGRAPH-2F89E;Lo;0;L;5FD7;;;;N;;;;;\n2F89F;CJK COMPATIBILITY IDEOGRAPH-2F89F;Lo;0;L;5FF9;;;;N;;;;;\n2F8A0;CJK COMPATIBILITY IDEOGRAPH-2F8A0;Lo;0;L;6081;;;;N;;;;;\n2F8A1;CJK COMPATIBILITY IDEOGRAPH-2F8A1;Lo;0;L;393A;;;;N;;;;;\n2F8A2;CJK COMPATIBILITY IDEOGRAPH-2F8A2;Lo;0;L;391C;;;;N;;;;;\n2F8A3;CJK COMPATIBILITY IDEOGRAPH-2F8A3;Lo;0;L;6094;;;;N;;;;;\n2F8A4;CJK COMPATIBILITY IDEOGRAPH-2F8A4;Lo;0;L;226D4;;;;N;;;;;\n2F8A5;CJK COMPATIBILITY IDEOGRAPH-2F8A5;Lo;0;L;60C7;;;;N;;;;;\n2F8A6;CJK COMPATIBILITY IDEOGRAPH-2F8A6;Lo;0;L;6148;;;;N;;;;;\n2F8A7;CJK COMPATIBILITY IDEOGRAPH-2F8A7;Lo;0;L;614C;;;;N;;;;;\n2F8A8;CJK COMPATIBILITY IDEOGRAPH-2F8A8;Lo;0;L;614E;;;;N;;;;;\n2F8A9;CJK COMPATIBILITY IDEOGRAPH-2F8A9;Lo;0;L;614C;;;;N;;;;;\n2F8AA;CJK COMPATIBILITY IDEOGRAPH-2F8AA;Lo;0;L;617A;;;;N;;;;;\n2F8AB;CJK COMPATIBILITY IDEOGRAPH-2F8AB;Lo;0;L;618E;;;;N;;;;;\n2F8AC;CJK COMPATIBILITY IDEOGRAPH-2F8AC;Lo;0;L;61B2;;;;N;;;;;\n2F8AD;CJK COMPATIBILITY IDEOGRAPH-2F8AD;Lo;0;L;61A4;;;;N;;;;;\n2F8AE;CJK COMPATIBILITY IDEOGRAPH-2F8AE;Lo;0;L;61AF;;;;N;;;;;\n2F8AF;CJK COMPATIBILITY IDEOGRAPH-2F8AF;Lo;0;L;61DE;;;;N;;;;;\n2F8B0;CJK COMPATIBILITY IDEOGRAPH-2F8B0;Lo;0;L;61F2;;;;N;;;;;\n2F8B1;CJK COMPATIBILITY IDEOGRAPH-2F8B1;Lo;0;L;61F6;;;;N;;;;;\n2F8B2;CJK COMPATIBILITY IDEOGRAPH-2F8B2;Lo;0;L;6210;;;;N;;;;;\n2F8B3;CJK COMPATIBILITY IDEOGRAPH-2F8B3;Lo;0;L;621B;;;;N;;;;;\n2F8B4;CJK COMPATIBILITY IDEOGRAPH-2F8B4;Lo;0;L;625D;;;;N;;;;;\n2F8B5;CJK COMPATIBILITY IDEOGRAPH-2F8B5;Lo;0;L;62B1;;;;N;;;;;\n2F8B6;CJK COMPATIBILITY IDEOGRAPH-2F8B6;Lo;0;L;62D4;;;;N;;;;;\n2F8B7;CJK COMPATIBILITY IDEOGRAPH-2F8B7;Lo;0;L;6350;;;;N;;;;;\n2F8B8;CJK COMPATIBILITY IDEOGRAPH-2F8B8;Lo;0;L;22B0C;;;;N;;;;;\n2F8B9;CJK COMPATIBILITY IDEOGRAPH-2F8B9;Lo;0;L;633D;;;;N;;;;;\n2F8BA;CJK COMPATIBILITY IDEOGRAPH-2F8BA;Lo;0;L;62FC;;;;N;;;;;\n2F8BB;CJK COMPATIBILITY IDEOGRAPH-2F8BB;Lo;0;L;6368;;;;N;;;;;\n2F8BC;CJK COMPATIBILITY IDEOGRAPH-2F8BC;Lo;0;L;6383;;;;N;;;;;\n2F8BD;CJK COMPATIBILITY IDEOGRAPH-2F8BD;Lo;0;L;63E4;;;;N;;;;;\n2F8BE;CJK COMPATIBILITY IDEOGRAPH-2F8BE;Lo;0;L;22BF1;;;;N;;;;;\n2F8BF;CJK COMPATIBILITY IDEOGRAPH-2F8BF;Lo;0;L;6422;;;;N;;;;;\n2F8C0;CJK COMPATIBILITY IDEOGRAPH-2F8C0;Lo;0;L;63C5;;;;N;;;;;\n2F8C1;CJK COMPATIBILITY IDEOGRAPH-2F8C1;Lo;0;L;63A9;;;;N;;;;;\n2F8C2;CJK COMPATIBILITY IDEOGRAPH-2F8C2;Lo;0;L;3A2E;;;;N;;;;;\n2F8C3;CJK COMPATIBILITY IDEOGRAPH-2F8C3;Lo;0;L;6469;;;;N;;;;;\n2F8C4;CJK COMPATIBILITY IDEOGRAPH-2F8C4;Lo;0;L;647E;;;;N;;;;;\n2F8C5;CJK COMPATIBILITY IDEOGRAPH-2F8C5;Lo;0;L;649D;;;;N;;;;;\n2F8C6;CJK COMPATIBILITY IDEOGRAPH-2F8C6;Lo;0;L;6477;;;;N;;;;;\n2F8C7;CJK COMPATIBILITY IDEOGRAPH-2F8C7;Lo;0;L;3A6C;;;;N;;;;;\n2F8C8;CJK COMPATIBILITY IDEOGRAPH-2F8C8;Lo;0;L;654F;;;;N;;;;;\n2F8C9;CJK COMPATIBILITY IDEOGRAPH-2F8C9;Lo;0;L;656C;;;;N;;;;;\n2F8CA;CJK COMPATIBILITY IDEOGRAPH-2F8CA;Lo;0;L;2300A;;;;N;;;;;\n2F8CB;CJK COMPATIBILITY IDEOGRAPH-2F8CB;Lo;0;L;65E3;;;;N;;;;;\n2F8CC;CJK COMPATIBILITY IDEOGRAPH-2F8CC;Lo;0;L;66F8;;;;N;;;;;\n2F8CD;CJK COMPATIBILITY IDEOGRAPH-2F8CD;Lo;0;L;6649;;;;N;;;;;\n2F8CE;CJK COMPATIBILITY IDEOGRAPH-2F8CE;Lo;0;L;3B19;;;;N;;;;;\n2F8CF;CJK COMPATIBILITY IDEOGRAPH-2F8CF;Lo;0;L;6691;;;;N;;;;;\n2F8D0;CJK COMPATIBILITY IDEOGRAPH-2F8D0;Lo;0;L;3B08;;;;N;;;;;\n2F8D1;CJK COMPATIBILITY IDEOGRAPH-2F8D1;Lo;0;L;3AE4;;;;N;;;;;\n2F8D2;CJK COMPATIBILITY IDEOGRAPH-2F8D2;Lo;0;L;5192;;;;N;;;;;\n2F8D3;CJK COMPATIBILITY IDEOGRAPH-2F8D3;Lo;0;L;5195;;;;N;;;;;\n2F8D4;CJK COMPATIBILITY IDEOGRAPH-2F8D4;Lo;0;L;6700;;;;N;;;;;\n2F8D5;CJK COMPATIBILITY IDEOGRAPH-2F8D5;Lo;0;L;669C;;;;N;;;;;\n2F8D6;CJK COMPATIBILITY IDEOGRAPH-2F8D6;Lo;0;L;80AD;;;;N;;;;;\n2F8D7;CJK COMPATIBILITY IDEOGRAPH-2F8D7;Lo;0;L;43D9;;;;N;;;;;\n2F8D8;CJK COMPATIBILITY IDEOGRAPH-2F8D8;Lo;0;L;6717;;;;N;;;;;\n2F8D9;CJK COMPATIBILITY IDEOGRAPH-2F8D9;Lo;0;L;671B;;;;N;;;;;\n2F8DA;CJK COMPATIBILITY IDEOGRAPH-2F8DA;Lo;0;L;6721;;;;N;;;;;\n2F8DB;CJK COMPATIBILITY IDEOGRAPH-2F8DB;Lo;0;L;675E;;;;N;;;;;\n2F8DC;CJK COMPATIBILITY IDEOGRAPH-2F8DC;Lo;0;L;6753;;;;N;;;;;\n2F8DD;CJK COMPATIBILITY IDEOGRAPH-2F8DD;Lo;0;L;233C3;;;;N;;;;;\n2F8DE;CJK COMPATIBILITY IDEOGRAPH-2F8DE;Lo;0;L;3B49;;;;N;;;;;\n2F8DF;CJK COMPATIBILITY IDEOGRAPH-2F8DF;Lo;0;L;67FA;;;;N;;;;;\n2F8E0;CJK COMPATIBILITY IDEOGRAPH-2F8E0;Lo;0;L;6785;;;;N;;;;;\n2F8E1;CJK COMPATIBILITY IDEOGRAPH-2F8E1;Lo;0;L;6852;;;;N;;;;;\n2F8E2;CJK COMPATIBILITY IDEOGRAPH-2F8E2;Lo;0;L;6885;;;;N;;;;;\n2F8E3;CJK COMPATIBILITY IDEOGRAPH-2F8E3;Lo;0;L;2346D;;;;N;;;;;\n2F8E4;CJK COMPATIBILITY IDEOGRAPH-2F8E4;Lo;0;L;688E;;;;N;;;;;\n2F8E5;CJK COMPATIBILITY IDEOGRAPH-2F8E5;Lo;0;L;681F;;;;N;;;;;\n2F8E6;CJK COMPATIBILITY IDEOGRAPH-2F8E6;Lo;0;L;6914;;;;N;;;;;\n2F8E7;CJK COMPATIBILITY IDEOGRAPH-2F8E7;Lo;0;L;3B9D;;;;N;;;;;\n2F8E8;CJK COMPATIBILITY IDEOGRAPH-2F8E8;Lo;0;L;6942;;;;N;;;;;\n2F8E9;CJK COMPATIBILITY IDEOGRAPH-2F8E9;Lo;0;L;69A3;;;;N;;;;;\n2F8EA;CJK COMPATIBILITY IDEOGRAPH-2F8EA;Lo;0;L;69EA;;;;N;;;;;\n2F8EB;CJK COMPATIBILITY IDEOGRAPH-2F8EB;Lo;0;L;6AA8;;;;N;;;;;\n2F8EC;CJK COMPATIBILITY IDEOGRAPH-2F8EC;Lo;0;L;236A3;;;;N;;;;;\n2F8ED;CJK COMPATIBILITY IDEOGRAPH-2F8ED;Lo;0;L;6ADB;;;;N;;;;;\n2F8EE;CJK COMPATIBILITY IDEOGRAPH-2F8EE;Lo;0;L;3C18;;;;N;;;;;\n2F8EF;CJK COMPATIBILITY IDEOGRAPH-2F8EF;Lo;0;L;6B21;;;;N;;;;;\n2F8F0;CJK COMPATIBILITY IDEOGRAPH-2F8F0;Lo;0;L;238A7;;;;N;;;;;\n2F8F1;CJK COMPATIBILITY IDEOGRAPH-2F8F1;Lo;0;L;6B54;;;;N;;;;;\n2F8F2;CJK COMPATIBILITY IDEOGRAPH-2F8F2;Lo;0;L;3C4E;;;;N;;;;;\n2F8F3;CJK COMPATIBILITY IDEOGRAPH-2F8F3;Lo;0;L;6B72;;;;N;;;;;\n2F8F4;CJK COMPATIBILITY IDEOGRAPH-2F8F4;Lo;0;L;6B9F;;;;N;;;;;\n2F8F5;CJK COMPATIBILITY IDEOGRAPH-2F8F5;Lo;0;L;6BBA;;;;N;;;;;\n2F8F6;CJK COMPATIBILITY IDEOGRAPH-2F8F6;Lo;0;L;6BBB;;;;N;;;;;\n2F8F7;CJK COMPATIBILITY IDEOGRAPH-2F8F7;Lo;0;L;23A8D;;;;N;;;;;\n2F8F8;CJK COMPATIBILITY IDEOGRAPH-2F8F8;Lo;0;L;21D0B;;;;N;;;;;\n2F8F9;CJK COMPATIBILITY IDEOGRAPH-2F8F9;Lo;0;L;23AFA;;;;N;;;;;\n2F8FA;CJK COMPATIBILITY IDEOGRAPH-2F8FA;Lo;0;L;6C4E;;;;N;;;;;\n2F8FB;CJK COMPATIBILITY IDEOGRAPH-2F8FB;Lo;0;L;23CBC;;;;N;;;;;\n2F8FC;CJK COMPATIBILITY IDEOGRAPH-2F8FC;Lo;0;L;6CBF;;;;N;;;;;\n2F8FD;CJK COMPATIBILITY IDEOGRAPH-2F8FD;Lo;0;L;6CCD;;;;N;;;;;\n2F8FE;CJK COMPATIBILITY IDEOGRAPH-2F8FE;Lo;0;L;6C67;;;;N;;;;;\n2F8FF;CJK COMPATIBILITY IDEOGRAPH-2F8FF;Lo;0;L;6D16;;;;N;;;;;\n2F900;CJK COMPATIBILITY IDEOGRAPH-2F900;Lo;0;L;6D3E;;;;N;;;;;\n2F901;CJK COMPATIBILITY IDEOGRAPH-2F901;Lo;0;L;6D77;;;;N;;;;;\n2F902;CJK COMPATIBILITY IDEOGRAPH-2F902;Lo;0;L;6D41;;;;N;;;;;\n2F903;CJK COMPATIBILITY IDEOGRAPH-2F903;Lo;0;L;6D69;;;;N;;;;;\n2F904;CJK COMPATIBILITY IDEOGRAPH-2F904;Lo;0;L;6D78;;;;N;;;;;\n2F905;CJK COMPATIBILITY IDEOGRAPH-2F905;Lo;0;L;6D85;;;;N;;;;;\n2F906;CJK COMPATIBILITY IDEOGRAPH-2F906;Lo;0;L;23D1E;;;;N;;;;;\n2F907;CJK COMPATIBILITY IDEOGRAPH-2F907;Lo;0;L;6D34;;;;N;;;;;\n2F908;CJK COMPATIBILITY IDEOGRAPH-2F908;Lo;0;L;6E2F;;;;N;;;;;\n2F909;CJK COMPATIBILITY IDEOGRAPH-2F909;Lo;0;L;6E6E;;;;N;;;;;\n2F90A;CJK COMPATIBILITY IDEOGRAPH-2F90A;Lo;0;L;3D33;;;;N;;;;;\n2F90B;CJK COMPATIBILITY IDEOGRAPH-2F90B;Lo;0;L;6ECB;;;;N;;;;;\n2F90C;CJK COMPATIBILITY IDEOGRAPH-2F90C;Lo;0;L;6EC7;;;;N;;;;;\n2F90D;CJK COMPATIBILITY IDEOGRAPH-2F90D;Lo;0;L;23ED1;;;;N;;;;;\n2F90E;CJK COMPATIBILITY IDEOGRAPH-2F90E;Lo;0;L;6DF9;;;;N;;;;;\n2F90F;CJK COMPATIBILITY IDEOGRAPH-2F90F;Lo;0;L;6F6E;;;;N;;;;;\n2F910;CJK COMPATIBILITY IDEOGRAPH-2F910;Lo;0;L;23F5E;;;;N;;;;;\n2F911;CJK COMPATIBILITY IDEOGRAPH-2F911;Lo;0;L;23F8E;;;;N;;;;;\n2F912;CJK COMPATIBILITY IDEOGRAPH-2F912;Lo;0;L;6FC6;;;;N;;;;;\n2F913;CJK COMPATIBILITY IDEOGRAPH-2F913;Lo;0;L;7039;;;;N;;;;;\n2F914;CJK COMPATIBILITY IDEOGRAPH-2F914;Lo;0;L;701E;;;;N;;;;;\n2F915;CJK COMPATIBILITY IDEOGRAPH-2F915;Lo;0;L;701B;;;;N;;;;;\n2F916;CJK COMPATIBILITY IDEOGRAPH-2F916;Lo;0;L;3D96;;;;N;;;;;\n2F917;CJK COMPATIBILITY IDEOGRAPH-2F917;Lo;0;L;704A;;;;N;;;;;\n2F918;CJK COMPATIBILITY IDEOGRAPH-2F918;Lo;0;L;707D;;;;N;;;;;\n2F919;CJK COMPATIBILITY IDEOGRAPH-2F919;Lo;0;L;7077;;;;N;;;;;\n2F91A;CJK COMPATIBILITY IDEOGRAPH-2F91A;Lo;0;L;70AD;;;;N;;;;;\n2F91B;CJK COMPATIBILITY IDEOGRAPH-2F91B;Lo;0;L;20525;;;;N;;;;;\n2F91C;CJK COMPATIBILITY IDEOGRAPH-2F91C;Lo;0;L;7145;;;;N;;;;;\n2F91D;CJK COMPATIBILITY IDEOGRAPH-2F91D;Lo;0;L;24263;;;;N;;;;;\n2F91E;CJK COMPATIBILITY IDEOGRAPH-2F91E;Lo;0;L;719C;;;;N;;;;;\n2F91F;CJK COMPATIBILITY IDEOGRAPH-2F91F;Lo;0;L;243AB;;;;N;;;;;\n2F920;CJK COMPATIBILITY IDEOGRAPH-2F920;Lo;0;L;7228;;;;N;;;;;\n2F921;CJK COMPATIBILITY IDEOGRAPH-2F921;Lo;0;L;7235;;;;N;;;;;\n2F922;CJK COMPATIBILITY IDEOGRAPH-2F922;Lo;0;L;7250;;;;N;;;;;\n2F923;CJK COMPATIBILITY IDEOGRAPH-2F923;Lo;0;L;24608;;;;N;;;;;\n2F924;CJK COMPATIBILITY IDEOGRAPH-2F924;Lo;0;L;7280;;;;N;;;;;\n2F925;CJK COMPATIBILITY IDEOGRAPH-2F925;Lo;0;L;7295;;;;N;;;;;\n2F926;CJK COMPATIBILITY IDEOGRAPH-2F926;Lo;0;L;24735;;;;N;;;;;\n2F927;CJK COMPATIBILITY IDEOGRAPH-2F927;Lo;0;L;24814;;;;N;;;;;\n2F928;CJK COMPATIBILITY IDEOGRAPH-2F928;Lo;0;L;737A;;;;N;;;;;\n2F929;CJK COMPATIBILITY IDEOGRAPH-2F929;Lo;0;L;738B;;;;N;;;;;\n2F92A;CJK COMPATIBILITY IDEOGRAPH-2F92A;Lo;0;L;3EAC;;;;N;;;;;\n2F92B;CJK COMPATIBILITY IDEOGRAPH-2F92B;Lo;0;L;73A5;;;;N;;;;;\n2F92C;CJK COMPATIBILITY IDEOGRAPH-2F92C;Lo;0;L;3EB8;;;;N;;;;;\n2F92D;CJK COMPATIBILITY IDEOGRAPH-2F92D;Lo;0;L;3EB8;;;;N;;;;;\n2F92E;CJK COMPATIBILITY IDEOGRAPH-2F92E;Lo;0;L;7447;;;;N;;;;;\n2F92F;CJK COMPATIBILITY IDEOGRAPH-2F92F;Lo;0;L;745C;;;;N;;;;;\n2F930;CJK COMPATIBILITY IDEOGRAPH-2F930;Lo;0;L;7471;;;;N;;;;;\n2F931;CJK COMPATIBILITY IDEOGRAPH-2F931;Lo;0;L;7485;;;;N;;;;;\n2F932;CJK COMPATIBILITY IDEOGRAPH-2F932;Lo;0;L;74CA;;;;N;;;;;\n2F933;CJK COMPATIBILITY IDEOGRAPH-2F933;Lo;0;L;3F1B;;;;N;;;;;\n2F934;CJK COMPATIBILITY IDEOGRAPH-2F934;Lo;0;L;7524;;;;N;;;;;\n2F935;CJK COMPATIBILITY IDEOGRAPH-2F935;Lo;0;L;24C36;;;;N;;;;;\n2F936;CJK COMPATIBILITY IDEOGRAPH-2F936;Lo;0;L;753E;;;;N;;;;;\n2F937;CJK COMPATIBILITY IDEOGRAPH-2F937;Lo;0;L;24C92;;;;N;;;;;\n2F938;CJK COMPATIBILITY IDEOGRAPH-2F938;Lo;0;L;7570;;;;N;;;;;\n2F939;CJK COMPATIBILITY IDEOGRAPH-2F939;Lo;0;L;2219F;;;;N;;;;;\n2F93A;CJK COMPATIBILITY IDEOGRAPH-2F93A;Lo;0;L;7610;;;;N;;;;;\n2F93B;CJK COMPATIBILITY IDEOGRAPH-2F93B;Lo;0;L;24FA1;;;;N;;;;;\n2F93C;CJK COMPATIBILITY IDEOGRAPH-2F93C;Lo;0;L;24FB8;;;;N;;;;;\n2F93D;CJK COMPATIBILITY IDEOGRAPH-2F93D;Lo;0;L;25044;;;;N;;;;;\n2F93E;CJK COMPATIBILITY IDEOGRAPH-2F93E;Lo;0;L;3FFC;;;;N;;;;;\n2F93F;CJK COMPATIBILITY IDEOGRAPH-2F93F;Lo;0;L;4008;;;;N;;;;;\n2F940;CJK COMPATIBILITY IDEOGRAPH-2F940;Lo;0;L;76F4;;;;N;;;;;\n2F941;CJK COMPATIBILITY IDEOGRAPH-2F941;Lo;0;L;250F3;;;;N;;;;;\n2F942;CJK COMPATIBILITY IDEOGRAPH-2F942;Lo;0;L;250F2;;;;N;;;;;\n2F943;CJK COMPATIBILITY IDEOGRAPH-2F943;Lo;0;L;25119;;;;N;;;;;\n2F944;CJK COMPATIBILITY IDEOGRAPH-2F944;Lo;0;L;25133;;;;N;;;;;\n2F945;CJK COMPATIBILITY IDEOGRAPH-2F945;Lo;0;L;771E;;;;N;;;;;\n2F946;CJK COMPATIBILITY IDEOGRAPH-2F946;Lo;0;L;771F;;;;N;;;;;\n2F947;CJK COMPATIBILITY IDEOGRAPH-2F947;Lo;0;L;771F;;;;N;;;;;\n2F948;CJK COMPATIBILITY IDEOGRAPH-2F948;Lo;0;L;774A;;;;N;;;;;\n2F949;CJK COMPATIBILITY IDEOGRAPH-2F949;Lo;0;L;4039;;;;N;;;;;\n2F94A;CJK COMPATIBILITY IDEOGRAPH-2F94A;Lo;0;L;778B;;;;N;;;;;\n2F94B;CJK COMPATIBILITY IDEOGRAPH-2F94B;Lo;0;L;4046;;;;N;;;;;\n2F94C;CJK COMPATIBILITY IDEOGRAPH-2F94C;Lo;0;L;4096;;;;N;;;;;\n2F94D;CJK COMPATIBILITY IDEOGRAPH-2F94D;Lo;0;L;2541D;;;;N;;;;;\n2F94E;CJK COMPATIBILITY IDEOGRAPH-2F94E;Lo;0;L;784E;;;;N;;;;;\n2F94F;CJK COMPATIBILITY IDEOGRAPH-2F94F;Lo;0;L;788C;;;;N;;;;;\n2F950;CJK COMPATIBILITY IDEOGRAPH-2F950;Lo;0;L;78CC;;;;N;;;;;\n2F951;CJK COMPATIBILITY IDEOGRAPH-2F951;Lo;0;L;40E3;;;;N;;;;;\n2F952;CJK COMPATIBILITY IDEOGRAPH-2F952;Lo;0;L;25626;;;;N;;;;;\n2F953;CJK COMPATIBILITY IDEOGRAPH-2F953;Lo;0;L;7956;;;;N;;;;;\n2F954;CJK COMPATIBILITY IDEOGRAPH-2F954;Lo;0;L;2569A;;;;N;;;;;\n2F955;CJK COMPATIBILITY IDEOGRAPH-2F955;Lo;0;L;256C5;;;;N;;;;;\n2F956;CJK COMPATIBILITY IDEOGRAPH-2F956;Lo;0;L;798F;;;;N;;;;;\n2F957;CJK COMPATIBILITY IDEOGRAPH-2F957;Lo;0;L;79EB;;;;N;;;;;\n2F958;CJK COMPATIBILITY IDEOGRAPH-2F958;Lo;0;L;412F;;;;N;;;;;\n2F959;CJK COMPATIBILITY IDEOGRAPH-2F959;Lo;0;L;7A40;;;;N;;;;;\n2F95A;CJK COMPATIBILITY IDEOGRAPH-2F95A;Lo;0;L;7A4A;;;;N;;;;;\n2F95B;CJK COMPATIBILITY IDEOGRAPH-2F95B;Lo;0;L;7A4F;;;;N;;;;;\n2F95C;CJK COMPATIBILITY IDEOGRAPH-2F95C;Lo;0;L;2597C;;;;N;;;;;\n2F95D;CJK COMPATIBILITY IDEOGRAPH-2F95D;Lo;0;L;25AA7;;;;N;;;;;\n2F95E;CJK COMPATIBILITY IDEOGRAPH-2F95E;Lo;0;L;25AA7;;;;N;;;;;\n2F95F;CJK COMPATIBILITY IDEOGRAPH-2F95F;Lo;0;L;7AEE;;;;N;;;;;\n2F960;CJK COMPATIBILITY IDEOGRAPH-2F960;Lo;0;L;4202;;;;N;;;;;\n2F961;CJK COMPATIBILITY IDEOGRAPH-2F961;Lo;0;L;25BAB;;;;N;;;;;\n2F962;CJK COMPATIBILITY IDEOGRAPH-2F962;Lo;0;L;7BC6;;;;N;;;;;\n2F963;CJK COMPATIBILITY IDEOGRAPH-2F963;Lo;0;L;7BC9;;;;N;;;;;\n2F964;CJK COMPATIBILITY IDEOGRAPH-2F964;Lo;0;L;4227;;;;N;;;;;\n2F965;CJK COMPATIBILITY IDEOGRAPH-2F965;Lo;0;L;25C80;;;;N;;;;;\n2F966;CJK COMPATIBILITY IDEOGRAPH-2F966;Lo;0;L;7CD2;;;;N;;;;;\n2F967;CJK COMPATIBILITY IDEOGRAPH-2F967;Lo;0;L;42A0;;;;N;;;;;\n2F968;CJK COMPATIBILITY IDEOGRAPH-2F968;Lo;0;L;7CE8;;;;N;;;;;\n2F969;CJK COMPATIBILITY IDEOGRAPH-2F969;Lo;0;L;7CE3;;;;N;;;;;\n2F96A;CJK COMPATIBILITY IDEOGRAPH-2F96A;Lo;0;L;7D00;;;;N;;;;;\n2F96B;CJK COMPATIBILITY IDEOGRAPH-2F96B;Lo;0;L;25F86;;;;N;;;;;\n2F96C;CJK COMPATIBILITY IDEOGRAPH-2F96C;Lo;0;L;7D63;;;;N;;;;;\n2F96D;CJK COMPATIBILITY IDEOGRAPH-2F96D;Lo;0;L;4301;;;;N;;;;;\n2F96E;CJK COMPATIBILITY IDEOGRAPH-2F96E;Lo;0;L;7DC7;;;;N;;;;;\n2F96F;CJK COMPATIBILITY IDEOGRAPH-2F96F;Lo;0;L;7E02;;;;N;;;;;\n2F970;CJK COMPATIBILITY IDEOGRAPH-2F970;Lo;0;L;7E45;;;;N;;;;;\n2F971;CJK COMPATIBILITY IDEOGRAPH-2F971;Lo;0;L;4334;;;;N;;;;;\n2F972;CJK COMPATIBILITY IDEOGRAPH-2F972;Lo;0;L;26228;;;;N;;;;;\n2F973;CJK COMPATIBILITY IDEOGRAPH-2F973;Lo;0;L;26247;;;;N;;;;;\n2F974;CJK COMPATIBILITY IDEOGRAPH-2F974;Lo;0;L;4359;;;;N;;;;;\n2F975;CJK COMPATIBILITY IDEOGRAPH-2F975;Lo;0;L;262D9;;;;N;;;;;\n2F976;CJK COMPATIBILITY IDEOGRAPH-2F976;Lo;0;L;7F7A;;;;N;;;;;\n2F977;CJK COMPATIBILITY IDEOGRAPH-2F977;Lo;0;L;2633E;;;;N;;;;;\n2F978;CJK COMPATIBILITY IDEOGRAPH-2F978;Lo;0;L;7F95;;;;N;;;;;\n2F979;CJK COMPATIBILITY IDEOGRAPH-2F979;Lo;0;L;7FFA;;;;N;;;;;\n2F97A;CJK COMPATIBILITY IDEOGRAPH-2F97A;Lo;0;L;8005;;;;N;;;;;\n2F97B;CJK COMPATIBILITY IDEOGRAPH-2F97B;Lo;0;L;264DA;;;;N;;;;;\n2F97C;CJK COMPATIBILITY IDEOGRAPH-2F97C;Lo;0;L;26523;;;;N;;;;;\n2F97D;CJK COMPATIBILITY IDEOGRAPH-2F97D;Lo;0;L;8060;;;;N;;;;;\n2F97E;CJK COMPATIBILITY IDEOGRAPH-2F97E;Lo;0;L;265A8;;;;N;;;;;\n2F97F;CJK COMPATIBILITY IDEOGRAPH-2F97F;Lo;0;L;8070;;;;N;;;;;\n2F980;CJK COMPATIBILITY IDEOGRAPH-2F980;Lo;0;L;2335F;;;;N;;;;;\n2F981;CJK COMPATIBILITY IDEOGRAPH-2F981;Lo;0;L;43D5;;;;N;;;;;\n2F982;CJK COMPATIBILITY IDEOGRAPH-2F982;Lo;0;L;80B2;;;;N;;;;;\n2F983;CJK COMPATIBILITY IDEOGRAPH-2F983;Lo;0;L;8103;;;;N;;;;;\n2F984;CJK COMPATIBILITY IDEOGRAPH-2F984;Lo;0;L;440B;;;;N;;;;;\n2F985;CJK COMPATIBILITY IDEOGRAPH-2F985;Lo;0;L;813E;;;;N;;;;;\n2F986;CJK COMPATIBILITY IDEOGRAPH-2F986;Lo;0;L;5AB5;;;;N;;;;;\n2F987;CJK COMPATIBILITY IDEOGRAPH-2F987;Lo;0;L;267A7;;;;N;;;;;\n2F988;CJK COMPATIBILITY IDEOGRAPH-2F988;Lo;0;L;267B5;;;;N;;;;;\n2F989;CJK COMPATIBILITY IDEOGRAPH-2F989;Lo;0;L;23393;;;;N;;;;;\n2F98A;CJK COMPATIBILITY IDEOGRAPH-2F98A;Lo;0;L;2339C;;;;N;;;;;\n2F98B;CJK COMPATIBILITY IDEOGRAPH-2F98B;Lo;0;L;8201;;;;N;;;;;\n2F98C;CJK COMPATIBILITY IDEOGRAPH-2F98C;Lo;0;L;8204;;;;N;;;;;\n2F98D;CJK COMPATIBILITY IDEOGRAPH-2F98D;Lo;0;L;8F9E;;;;N;;;;;\n2F98E;CJK COMPATIBILITY IDEOGRAPH-2F98E;Lo;0;L;446B;;;;N;;;;;\n2F98F;CJK COMPATIBILITY IDEOGRAPH-2F98F;Lo;0;L;8291;;;;N;;;;;\n2F990;CJK COMPATIBILITY IDEOGRAPH-2F990;Lo;0;L;828B;;;;N;;;;;\n2F991;CJK COMPATIBILITY IDEOGRAPH-2F991;Lo;0;L;829D;;;;N;;;;;\n2F992;CJK COMPATIBILITY IDEOGRAPH-2F992;Lo;0;L;52B3;;;;N;;;;;\n2F993;CJK COMPATIBILITY IDEOGRAPH-2F993;Lo;0;L;82B1;;;;N;;;;;\n2F994;CJK COMPATIBILITY IDEOGRAPH-2F994;Lo;0;L;82B3;;;;N;;;;;\n2F995;CJK COMPATIBILITY IDEOGRAPH-2F995;Lo;0;L;82BD;;;;N;;;;;\n2F996;CJK COMPATIBILITY IDEOGRAPH-2F996;Lo;0;L;82E6;;;;N;;;;;\n2F997;CJK COMPATIBILITY IDEOGRAPH-2F997;Lo;0;L;26B3C;;;;N;;;;;\n2F998;CJK COMPATIBILITY IDEOGRAPH-2F998;Lo;0;L;82E5;;;;N;;;;;\n2F999;CJK COMPATIBILITY IDEOGRAPH-2F999;Lo;0;L;831D;;;;N;;;;;\n2F99A;CJK COMPATIBILITY IDEOGRAPH-2F99A;Lo;0;L;8363;;;;N;;;;;\n2F99B;CJK COMPATIBILITY IDEOGRAPH-2F99B;Lo;0;L;83AD;;;;N;;;;;\n2F99C;CJK COMPATIBILITY IDEOGRAPH-2F99C;Lo;0;L;8323;;;;N;;;;;\n2F99D;CJK COMPATIBILITY IDEOGRAPH-2F99D;Lo;0;L;83BD;;;;N;;;;;\n2F99E;CJK COMPATIBILITY IDEOGRAPH-2F99E;Lo;0;L;83E7;;;;N;;;;;\n2F99F;CJK COMPATIBILITY IDEOGRAPH-2F99F;Lo;0;L;8457;;;;N;;;;;\n2F9A0;CJK COMPATIBILITY IDEOGRAPH-2F9A0;Lo;0;L;8353;;;;N;;;;;\n2F9A1;CJK COMPATIBILITY IDEOGRAPH-2F9A1;Lo;0;L;83CA;;;;N;;;;;\n2F9A2;CJK COMPATIBILITY IDEOGRAPH-2F9A2;Lo;0;L;83CC;;;;N;;;;;\n2F9A3;CJK COMPATIBILITY IDEOGRAPH-2F9A3;Lo;0;L;83DC;;;;N;;;;;\n2F9A4;CJK COMPATIBILITY IDEOGRAPH-2F9A4;Lo;0;L;26C36;;;;N;;;;;\n2F9A5;CJK COMPATIBILITY IDEOGRAPH-2F9A5;Lo;0;L;26D6B;;;;N;;;;;\n2F9A6;CJK COMPATIBILITY IDEOGRAPH-2F9A6;Lo;0;L;26CD5;;;;N;;;;;\n2F9A7;CJK COMPATIBILITY IDEOGRAPH-2F9A7;Lo;0;L;452B;;;;N;;;;;\n2F9A8;CJK COMPATIBILITY IDEOGRAPH-2F9A8;Lo;0;L;84F1;;;;N;;;;;\n2F9A9;CJK COMPATIBILITY IDEOGRAPH-2F9A9;Lo;0;L;84F3;;;;N;;;;;\n2F9AA;CJK COMPATIBILITY IDEOGRAPH-2F9AA;Lo;0;L;8516;;;;N;;;;;\n2F9AB;CJK COMPATIBILITY IDEOGRAPH-2F9AB;Lo;0;L;273CA;;;;N;;;;;\n2F9AC;CJK COMPATIBILITY IDEOGRAPH-2F9AC;Lo;0;L;8564;;;;N;;;;;\n2F9AD;CJK COMPATIBILITY IDEOGRAPH-2F9AD;Lo;0;L;26F2C;;;;N;;;;;\n2F9AE;CJK COMPATIBILITY IDEOGRAPH-2F9AE;Lo;0;L;455D;;;;N;;;;;\n2F9AF;CJK COMPATIBILITY IDEOGRAPH-2F9AF;Lo;0;L;4561;;;;N;;;;;\n2F9B0;CJK COMPATIBILITY IDEOGRAPH-2F9B0;Lo;0;L;26FB1;;;;N;;;;;\n2F9B1;CJK COMPATIBILITY IDEOGRAPH-2F9B1;Lo;0;L;270D2;;;;N;;;;;\n2F9B2;CJK COMPATIBILITY IDEOGRAPH-2F9B2;Lo;0;L;456B;;;;N;;;;;\n2F9B3;CJK COMPATIBILITY IDEOGRAPH-2F9B3;Lo;0;L;8650;;;;N;;;;;\n2F9B4;CJK COMPATIBILITY IDEOGRAPH-2F9B4;Lo;0;L;865C;;;;N;;;;;\n2F9B5;CJK COMPATIBILITY IDEOGRAPH-2F9B5;Lo;0;L;8667;;;;N;;;;;\n2F9B6;CJK COMPATIBILITY IDEOGRAPH-2F9B6;Lo;0;L;8669;;;;N;;;;;\n2F9B7;CJK COMPATIBILITY IDEOGRAPH-2F9B7;Lo;0;L;86A9;;;;N;;;;;\n2F9B8;CJK COMPATIBILITY IDEOGRAPH-2F9B8;Lo;0;L;8688;;;;N;;;;;\n2F9B9;CJK COMPATIBILITY IDEOGRAPH-2F9B9;Lo;0;L;870E;;;;N;;;;;\n2F9BA;CJK COMPATIBILITY IDEOGRAPH-2F9BA;Lo;0;L;86E2;;;;N;;;;;\n2F9BB;CJK COMPATIBILITY IDEOGRAPH-2F9BB;Lo;0;L;8779;;;;N;;;;;\n2F9BC;CJK COMPATIBILITY IDEOGRAPH-2F9BC;Lo;0;L;8728;;;;N;;;;;\n2F9BD;CJK COMPATIBILITY IDEOGRAPH-2F9BD;Lo;0;L;876B;;;;N;;;;;\n2F9BE;CJK COMPATIBILITY IDEOGRAPH-2F9BE;Lo;0;L;8786;;;;N;;;;;\n2F9BF;CJK COMPATIBILITY IDEOGRAPH-2F9BF;Lo;0;L;45D7;;;;N;;;;;\n2F9C0;CJK COMPATIBILITY IDEOGRAPH-2F9C0;Lo;0;L;87E1;;;;N;;;;;\n2F9C1;CJK COMPATIBILITY IDEOGRAPH-2F9C1;Lo;0;L;8801;;;;N;;;;;\n2F9C2;CJK COMPATIBILITY IDEOGRAPH-2F9C2;Lo;0;L;45F9;;;;N;;;;;\n2F9C3;CJK COMPATIBILITY IDEOGRAPH-2F9C3;Lo;0;L;8860;;;;N;;;;;\n2F9C4;CJK COMPATIBILITY IDEOGRAPH-2F9C4;Lo;0;L;8863;;;;N;;;;;\n2F9C5;CJK COMPATIBILITY IDEOGRAPH-2F9C5;Lo;0;L;27667;;;;N;;;;;\n2F9C6;CJK COMPATIBILITY IDEOGRAPH-2F9C6;Lo;0;L;88D7;;;;N;;;;;\n2F9C7;CJK COMPATIBILITY IDEOGRAPH-2F9C7;Lo;0;L;88DE;;;;N;;;;;\n2F9C8;CJK COMPATIBILITY IDEOGRAPH-2F9C8;Lo;0;L;4635;;;;N;;;;;\n2F9C9;CJK COMPATIBILITY IDEOGRAPH-2F9C9;Lo;0;L;88FA;;;;N;;;;;\n2F9CA;CJK COMPATIBILITY IDEOGRAPH-2F9CA;Lo;0;L;34BB;;;;N;;;;;\n2F9CB;CJK COMPATIBILITY IDEOGRAPH-2F9CB;Lo;0;L;278AE;;;;N;;;;;\n2F9CC;CJK COMPATIBILITY IDEOGRAPH-2F9CC;Lo;0;L;27966;;;;N;;;;;\n2F9CD;CJK COMPATIBILITY IDEOGRAPH-2F9CD;Lo;0;L;46BE;;;;N;;;;;\n2F9CE;CJK COMPATIBILITY IDEOGRAPH-2F9CE;Lo;0;L;46C7;;;;N;;;;;\n2F9CF;CJK COMPATIBILITY IDEOGRAPH-2F9CF;Lo;0;L;8AA0;;;;N;;;;;\n2F9D0;CJK COMPATIBILITY IDEOGRAPH-2F9D0;Lo;0;L;8AED;;;;N;;;;;\n2F9D1;CJK COMPATIBILITY IDEOGRAPH-2F9D1;Lo;0;L;8B8A;;;;N;;;;;\n2F9D2;CJK COMPATIBILITY IDEOGRAPH-2F9D2;Lo;0;L;8C55;;;;N;;;;;\n2F9D3;CJK COMPATIBILITY IDEOGRAPH-2F9D3;Lo;0;L;27CA8;;;;N;;;;;\n2F9D4;CJK COMPATIBILITY IDEOGRAPH-2F9D4;Lo;0;L;8CAB;;;;N;;;;;\n2F9D5;CJK COMPATIBILITY IDEOGRAPH-2F9D5;Lo;0;L;8CC1;;;;N;;;;;\n2F9D6;CJK COMPATIBILITY IDEOGRAPH-2F9D6;Lo;0;L;8D1B;;;;N;;;;;\n2F9D7;CJK COMPATIBILITY IDEOGRAPH-2F9D7;Lo;0;L;8D77;;;;N;;;;;\n2F9D8;CJK COMPATIBILITY IDEOGRAPH-2F9D8;Lo;0;L;27F2F;;;;N;;;;;\n2F9D9;CJK COMPATIBILITY IDEOGRAPH-2F9D9;Lo;0;L;20804;;;;N;;;;;\n2F9DA;CJK COMPATIBILITY IDEOGRAPH-2F9DA;Lo;0;L;8DCB;;;;N;;;;;\n2F9DB;CJK COMPATIBILITY IDEOGRAPH-2F9DB;Lo;0;L;8DBC;;;;N;;;;;\n2F9DC;CJK COMPATIBILITY IDEOGRAPH-2F9DC;Lo;0;L;8DF0;;;;N;;;;;\n2F9DD;CJK COMPATIBILITY IDEOGRAPH-2F9DD;Lo;0;L;208DE;;;;N;;;;;\n2F9DE;CJK COMPATIBILITY IDEOGRAPH-2F9DE;Lo;0;L;8ED4;;;;N;;;;;\n2F9DF;CJK COMPATIBILITY IDEOGRAPH-2F9DF;Lo;0;L;8F38;;;;N;;;;;\n2F9E0;CJK COMPATIBILITY IDEOGRAPH-2F9E0;Lo;0;L;285D2;;;;N;;;;;\n2F9E1;CJK COMPATIBILITY IDEOGRAPH-2F9E1;Lo;0;L;285ED;;;;N;;;;;\n2F9E2;CJK COMPATIBILITY IDEOGRAPH-2F9E2;Lo;0;L;9094;;;;N;;;;;\n2F9E3;CJK COMPATIBILITY IDEOGRAPH-2F9E3;Lo;0;L;90F1;;;;N;;;;;\n2F9E4;CJK COMPATIBILITY IDEOGRAPH-2F9E4;Lo;0;L;9111;;;;N;;;;;\n2F9E5;CJK COMPATIBILITY IDEOGRAPH-2F9E5;Lo;0;L;2872E;;;;N;;;;;\n2F9E6;CJK COMPATIBILITY IDEOGRAPH-2F9E6;Lo;0;L;911B;;;;N;;;;;\n2F9E7;CJK COMPATIBILITY IDEOGRAPH-2F9E7;Lo;0;L;9238;;;;N;;;;;\n2F9E8;CJK COMPATIBILITY IDEOGRAPH-2F9E8;Lo;0;L;92D7;;;;N;;;;;\n2F9E9;CJK COMPATIBILITY IDEOGRAPH-2F9E9;Lo;0;L;92D8;;;;N;;;;;\n2F9EA;CJK COMPATIBILITY IDEOGRAPH-2F9EA;Lo;0;L;927C;;;;N;;;;;\n2F9EB;CJK COMPATIBILITY IDEOGRAPH-2F9EB;Lo;0;L;93F9;;;;N;;;;;\n2F9EC;CJK COMPATIBILITY IDEOGRAPH-2F9EC;Lo;0;L;9415;;;;N;;;;;\n2F9ED;CJK COMPATIBILITY IDEOGRAPH-2F9ED;Lo;0;L;28BFA;;;;N;;;;;\n2F9EE;CJK COMPATIBILITY IDEOGRAPH-2F9EE;Lo;0;L;958B;;;;N;;;;;\n2F9EF;CJK COMPATIBILITY IDEOGRAPH-2F9EF;Lo;0;L;4995;;;;N;;;;;\n2F9F0;CJK COMPATIBILITY IDEOGRAPH-2F9F0;Lo;0;L;95B7;;;;N;;;;;\n2F9F1;CJK COMPATIBILITY IDEOGRAPH-2F9F1;Lo;0;L;28D77;;;;N;;;;;\n2F9F2;CJK COMPATIBILITY IDEOGRAPH-2F9F2;Lo;0;L;49E6;;;;N;;;;;\n2F9F3;CJK COMPATIBILITY IDEOGRAPH-2F9F3;Lo;0;L;96C3;;;;N;;;;;\n2F9F4;CJK COMPATIBILITY IDEOGRAPH-2F9F4;Lo;0;L;5DB2;;;;N;;;;;\n2F9F5;CJK COMPATIBILITY IDEOGRAPH-2F9F5;Lo;0;L;9723;;;;N;;;;;\n2F9F6;CJK COMPATIBILITY IDEOGRAPH-2F9F6;Lo;0;L;29145;;;;N;;;;;\n2F9F7;CJK COMPATIBILITY IDEOGRAPH-2F9F7;Lo;0;L;2921A;;;;N;;;;;\n2F9F8;CJK COMPATIBILITY IDEOGRAPH-2F9F8;Lo;0;L;4A6E;;;;N;;;;;\n2F9F9;CJK COMPATIBILITY IDEOGRAPH-2F9F9;Lo;0;L;4A76;;;;N;;;;;\n2F9FA;CJK COMPATIBILITY IDEOGRAPH-2F9FA;Lo;0;L;97E0;;;;N;;;;;\n2F9FB;CJK COMPATIBILITY IDEOGRAPH-2F9FB;Lo;0;L;2940A;;;;N;;;;;\n2F9FC;CJK COMPATIBILITY IDEOGRAPH-2F9FC;Lo;0;L;4AB2;;;;N;;;;;\n2F9FD;CJK COMPATIBILITY IDEOGRAPH-2F9FD;Lo;0;L;29496;;;;N;;;;;\n2F9FE;CJK COMPATIBILITY IDEOGRAPH-2F9FE;Lo;0;L;980B;;;;N;;;;;\n2F9FF;CJK COMPATIBILITY IDEOGRAPH-2F9FF;Lo;0;L;980B;;;;N;;;;;\n2FA00;CJK COMPATIBILITY IDEOGRAPH-2FA00;Lo;0;L;9829;;;;N;;;;;\n2FA01;CJK COMPATIBILITY IDEOGRAPH-2FA01;Lo;0;L;295B6;;;;N;;;;;\n2FA02;CJK COMPATIBILITY IDEOGRAPH-2FA02;Lo;0;L;98E2;;;;N;;;;;\n2FA03;CJK COMPATIBILITY IDEOGRAPH-2FA03;Lo;0;L;4B33;;;;N;;;;;\n2FA04;CJK COMPATIBILITY IDEOGRAPH-2FA04;Lo;0;L;9929;;;;N;;;;;\n2FA05;CJK COMPATIBILITY IDEOGRAPH-2FA05;Lo;0;L;99A7;;;;N;;;;;\n2FA06;CJK COMPATIBILITY IDEOGRAPH-2FA06;Lo;0;L;99C2;;;;N;;;;;\n2FA07;CJK COMPATIBILITY IDEOGRAPH-2FA07;Lo;0;L;99FE;;;;N;;;;;\n2FA08;CJK COMPATIBILITY IDEOGRAPH-2FA08;Lo;0;L;4BCE;;;;N;;;;;\n2FA09;CJK COMPATIBILITY IDEOGRAPH-2FA09;Lo;0;L;29B30;;;;N;;;;;\n2FA0A;CJK COMPATIBILITY IDEOGRAPH-2FA0A;Lo;0;L;9B12;;;;N;;;;;\n2FA0B;CJK COMPATIBILITY IDEOGRAPH-2FA0B;Lo;0;L;9C40;;;;N;;;;;\n2FA0C;CJK COMPATIBILITY IDEOGRAPH-2FA0C;Lo;0;L;9CFD;;;;N;;;;;\n2FA0D;CJK COMPATIBILITY IDEOGRAPH-2FA0D;Lo;0;L;4CCE;;;;N;;;;;\n2FA0E;CJK COMPATIBILITY IDEOGRAPH-2FA0E;Lo;0;L;4CED;;;;N;;;;;\n2FA0F;CJK COMPATIBILITY IDEOGRAPH-2FA0F;Lo;0;L;9D67;;;;N;;;;;\n2FA10;CJK COMPATIBILITY IDEOGRAPH-2FA10;Lo;0;L;2A0CE;;;;N;;;;;\n2FA11;CJK COMPATIBILITY IDEOGRAPH-2FA11;Lo;0;L;4CF8;;;;N;;;;;\n2FA12;CJK COMPATIBILITY IDEOGRAPH-2FA12;Lo;0;L;2A105;;;;N;;;;;\n2FA13;CJK COMPATIBILITY IDEOGRAPH-2FA13;Lo;0;L;2A20E;;;;N;;;;;\n2FA14;CJK COMPATIBILITY IDEOGRAPH-2FA14;Lo;0;L;2A291;;;;N;;;;;\n2FA15;CJK COMPATIBILITY IDEOGRAPH-2FA15;Lo;0;L;9EBB;;;;N;;;;;\n2FA16;CJK COMPATIBILITY IDEOGRAPH-2FA16;Lo;0;L;4D56;;;;N;;;;;\n2FA17;CJK COMPATIBILITY IDEOGRAPH-2FA17;Lo;0;L;9EF9;;;;N;;;;;\n2FA18;CJK COMPATIBILITY IDEOGRAPH-2FA18;Lo;0;L;9EFE;;;;N;;;;;\n2FA19;CJK COMPATIBILITY IDEOGRAPH-2FA19;Lo;0;L;9F05;;;;N;;;;;\n2FA1A;CJK COMPATIBILITY IDEOGRAPH-2FA1A;Lo;0;L;9F0F;;;;N;;;;;\n2FA1B;CJK COMPATIBILITY IDEOGRAPH-2FA1B;Lo;0;L;9F16;;;;N;;;;;\n2FA1C;CJK COMPATIBILITY IDEOGRAPH-2FA1C;Lo;0;L;9F3B;;;;N;;;;;\n2FA1D;CJK COMPATIBILITY IDEOGRAPH-2FA1D;Lo;0;L;2A600;;;;N;;;;;\nE0001;LANGUAGE TAG;Cf;0;BN;;;;;N;;;;;\nE0020;TAG SPACE;Cf;0;BN;;;;;N;;;;;\nE0021;TAG EXCLAMATION MARK;Cf;0;BN;;;;;N;;;;;\nE0022;TAG QUOTATION MARK;Cf;0;BN;;;;;N;;;;;\nE0023;TAG NUMBER SIGN;Cf;0;BN;;;;;N;;;;;\nE0024;TAG DOLLAR SIGN;Cf;0;BN;;;;;N;;;;;\nE0025;TAG PERCENT SIGN;Cf;0;BN;;;;;N;;;;;\nE0026;TAG AMPERSAND;Cf;0;BN;;;;;N;;;;;\nE0027;TAG APOSTROPHE;Cf;0;BN;;;;;N;;;;;\nE0028;TAG LEFT PARENTHESIS;Cf;0;BN;;;;;N;;;;;\nE0029;TAG RIGHT PARENTHESIS;Cf;0;BN;;;;;N;;;;;\nE002A;TAG ASTERISK;Cf;0;BN;;;;;N;;;;;\nE002B;TAG PLUS SIGN;Cf;0;BN;;;;;N;;;;;\nE002C;TAG COMMA;Cf;0;BN;;;;;N;;;;;\nE002D;TAG HYPHEN-MINUS;Cf;0;BN;;;;;N;;;;;\nE002E;TAG FULL STOP;Cf;0;BN;;;;;N;;;;;\nE002F;TAG SOLIDUS;Cf;0;BN;;;;;N;;;;;\nE0030;TAG DIGIT ZERO;Cf;0;BN;;;;;N;;;;;\nE0031;TAG DIGIT ONE;Cf;0;BN;;;;;N;;;;;\nE0032;TAG DIGIT TWO;Cf;0;BN;;;;;N;;;;;\nE0033;TAG DIGIT THREE;Cf;0;BN;;;;;N;;;;;\nE0034;TAG DIGIT FOUR;Cf;0;BN;;;;;N;;;;;\nE0035;TAG DIGIT FIVE;Cf;0;BN;;;;;N;;;;;\nE0036;TAG DIGIT SIX;Cf;0;BN;;;;;N;;;;;\nE0037;TAG DIGIT SEVEN;Cf;0;BN;;;;;N;;;;;\nE0038;TAG DIGIT EIGHT;Cf;0;BN;;;;;N;;;;;\nE0039;TAG DIGIT NINE;Cf;0;BN;;;;;N;;;;;\nE003A;TAG COLON;Cf;0;BN;;;;;N;;;;;\nE003B;TAG SEMICOLON;Cf;0;BN;;;;;N;;;;;\nE003C;TAG LESS-THAN SIGN;Cf;0;BN;;;;;N;;;;;\nE003D;TAG EQUALS SIGN;Cf;0;BN;;;;;N;;;;;\nE003E;TAG GREATER-THAN SIGN;Cf;0;BN;;;;;N;;;;;\nE003F;TAG QUESTION MARK;Cf;0;BN;;;;;N;;;;;\nE0040;TAG COMMERCIAL AT;Cf;0;BN;;;;;N;;;;;\nE0041;TAG LATIN CAPITAL LETTER A;Cf;0;BN;;;;;N;;;;;\nE0042;TAG LATIN CAPITAL LETTER B;Cf;0;BN;;;;;N;;;;;\nE0043;TAG LATIN CAPITAL LETTER C;Cf;0;BN;;;;;N;;;;;\nE0044;TAG LATIN CAPITAL LETTER D;Cf;0;BN;;;;;N;;;;;\nE0045;TAG LATIN CAPITAL LETTER E;Cf;0;BN;;;;;N;;;;;\nE0046;TAG LATIN CAPITAL LETTER F;Cf;0;BN;;;;;N;;;;;\nE0047;TAG LATIN CAPITAL LETTER G;Cf;0;BN;;;;;N;;;;;\nE0048;TAG LATIN CAPITAL LETTER H;Cf;0;BN;;;;;N;;;;;\nE0049;TAG LATIN CAPITAL LETTER I;Cf;0;BN;;;;;N;;;;;\nE004A;TAG LATIN CAPITAL LETTER J;Cf;0;BN;;;;;N;;;;;\nE004B;TAG LATIN CAPITAL LETTER K;Cf;0;BN;;;;;N;;;;;\nE004C;TAG LATIN CAPITAL LETTER L;Cf;0;BN;;;;;N;;;;;\nE004D;TAG LATIN CAPITAL LETTER M;Cf;0;BN;;;;;N;;;;;\nE004E;TAG LATIN CAPITAL LETTER N;Cf;0;BN;;;;;N;;;;;\nE004F;TAG LATIN CAPITAL LETTER O;Cf;0;BN;;;;;N;;;;;\nE0050;TAG LATIN CAPITAL LETTER P;Cf;0;BN;;;;;N;;;;;\nE0051;TAG LATIN CAPITAL LETTER Q;Cf;0;BN;;;;;N;;;;;\nE0052;TAG LATIN CAPITAL LETTER R;Cf;0;BN;;;;;N;;;;;\nE0053;TAG LATIN CAPITAL LETTER S;Cf;0;BN;;;;;N;;;;;\nE0054;TAG LATIN CAPITAL LETTER T;Cf;0;BN;;;;;N;;;;;\nE0055;TAG LATIN CAPITAL LETTER U;Cf;0;BN;;;;;N;;;;;\nE0056;TAG LATIN CAPITAL LETTER V;Cf;0;BN;;;;;N;;;;;\nE0057;TAG LATIN CAPITAL LETTER W;Cf;0;BN;;;;;N;;;;;\nE0058;TAG LATIN CAPITAL LETTER X;Cf;0;BN;;;;;N;;;;;\nE0059;TAG LATIN CAPITAL LETTER Y;Cf;0;BN;;;;;N;;;;;\nE005A;TAG LATIN CAPITAL LETTER Z;Cf;0;BN;;;;;N;;;;;\nE005B;TAG LEFT SQUARE BRACKET;Cf;0;BN;;;;;N;;;;;\nE005C;TAG REVERSE SOLIDUS;Cf;0;BN;;;;;N;;;;;\nE005D;TAG RIGHT SQUARE BRACKET;Cf;0;BN;;;;;N;;;;;\nE005E;TAG CIRCUMFLEX ACCENT;Cf;0;BN;;;;;N;;;;;\nE005F;TAG LOW LINE;Cf;0;BN;;;;;N;;;;;\nE0060;TAG GRAVE ACCENT;Cf;0;BN;;;;;N;;;;;\nE0061;TAG LATIN SMALL LETTER A;Cf;0;BN;;;;;N;;;;;\nE0062;TAG LATIN SMALL LETTER B;Cf;0;BN;;;;;N;;;;;\nE0063;TAG LATIN SMALL LETTER C;Cf;0;BN;;;;;N;;;;;\nE0064;TAG LATIN SMALL LETTER D;Cf;0;BN;;;;;N;;;;;\nE0065;TAG LATIN SMALL LETTER E;Cf;0;BN;;;;;N;;;;;\nE0066;TAG LATIN SMALL LETTER F;Cf;0;BN;;;;;N;;;;;\nE0067;TAG LATIN SMALL LETTER G;Cf;0;BN;;;;;N;;;;;\nE0068;TAG LATIN SMALL LETTER H;Cf;0;BN;;;;;N;;;;;\nE0069;TAG LATIN SMALL LETTER I;Cf;0;BN;;;;;N;;;;;\nE006A;TAG LATIN SMALL LETTER J;Cf;0;BN;;;;;N;;;;;\nE006B;TAG LATIN SMALL LETTER K;Cf;0;BN;;;;;N;;;;;\nE006C;TAG LATIN SMALL LETTER L;Cf;0;BN;;;;;N;;;;;\nE006D;TAG LATIN SMALL LETTER M;Cf;0;BN;;;;;N;;;;;\nE006E;TAG LATIN SMALL LETTER N;Cf;0;BN;;;;;N;;;;;\nE006F;TAG LATIN SMALL LETTER O;Cf;0;BN;;;;;N;;;;;\nE0070;TAG LATIN SMALL LETTER P;Cf;0;BN;;;;;N;;;;;\nE0071;TAG LATIN SMALL LETTER Q;Cf;0;BN;;;;;N;;;;;\nE0072;TAG LATIN SMALL LETTER R;Cf;0;BN;;;;;N;;;;;\nE0073;TAG LATIN SMALL LETTER S;Cf;0;BN;;;;;N;;;;;\nE0074;TAG LATIN SMALL LETTER T;Cf;0;BN;;;;;N;;;;;\nE0075;TAG LATIN SMALL LETTER U;Cf;0;BN;;;;;N;;;;;\nE0076;TAG LATIN SMALL LETTER V;Cf;0;BN;;;;;N;;;;;\nE0077;TAG LATIN SMALL LETTER W;Cf;0;BN;;;;;N;;;;;\nE0078;TAG LATIN SMALL LETTER X;Cf;0;BN;;;;;N;;;;;\nE0079;TAG LATIN SMALL LETTER Y;Cf;0;BN;;;;;N;;;;;\nE007A;TAG LATIN SMALL LETTER Z;Cf;0;BN;;;;;N;;;;;\nE007B;TAG LEFT CURLY BRACKET;Cf;0;BN;;;;;N;;;;;\nE007C;TAG VERTICAL LINE;Cf;0;BN;;;;;N;;;;;\nE007D;TAG RIGHT CURLY BRACKET;Cf;0;BN;;;;;N;;;;;\nE007E;TAG TILDE;Cf;0;BN;;;;;N;;;;;\nE007F;CANCEL TAG;Cf;0;BN;;;;;N;;;;;\nE0100;VARIATION SELECTOR-17;Mn;0;NSM;;;;;N;;;;;\nE0101;VARIATION SELECTOR-18;Mn;0;NSM;;;;;N;;;;;\nE0102;VARIATION SELECTOR-19;Mn;0;NSM;;;;;N;;;;;\nE0103;VARIATION SELECTOR-20;Mn;0;NSM;;;;;N;;;;;\nE0104;VARIATION SELECTOR-21;Mn;0;NSM;;;;;N;;;;;\nE0105;VARIATION SELECTOR-22;Mn;0;NSM;;;;;N;;;;;\nE0106;VARIATION SELECTOR-23;Mn;0;NSM;;;;;N;;;;;\nE0107;VARIATION SELECTOR-24;Mn;0;NSM;;;;;N;;;;;\nE0108;VARIATION SELECTOR-25;Mn;0;NSM;;;;;N;;;;;\nE0109;VARIATION SELECTOR-26;Mn;0;NSM;;;;;N;;;;;\nE010A;VARIATION SELECTOR-27;Mn;0;NSM;;;;;N;;;;;\nE010B;VARIATION SELECTOR-28;Mn;0;NSM;;;;;N;;;;;\nE010C;VARIATION SELECTOR-29;Mn;0;NSM;;;;;N;;;;;\nE010D;VARIATION SELECTOR-30;Mn;0;NSM;;;;;N;;;;;\nE010E;VARIATION SELECTOR-31;Mn;0;NSM;;;;;N;;;;;\nE010F;VARIATION SELECTOR-32;Mn;0;NSM;;;;;N;;;;;\nE0110;VARIATION SELECTOR-33;Mn;0;NSM;;;;;N;;;;;\nE0111;VARIATION SELECTOR-34;Mn;0;NSM;;;;;N;;;;;\nE0112;VARIATION SELECTOR-35;Mn;0;NSM;;;;;N;;;;;\nE0113;VARIATION SELECTOR-36;Mn;0;NSM;;;;;N;;;;;\nE0114;VARIATION SELECTOR-37;Mn;0;NSM;;;;;N;;;;;\nE0115;VARIATION SELECTOR-38;Mn;0;NSM;;;;;N;;;;;\nE0116;VARIATION SELECTOR-39;Mn;0;NSM;;;;;N;;;;;\nE0117;VARIATION SELECTOR-40;Mn;0;NSM;;;;;N;;;;;\nE0118;VARIATION SELECTOR-41;Mn;0;NSM;;;;;N;;;;;\nE0119;VARIATION SELECTOR-42;Mn;0;NSM;;;;;N;;;;;\nE011A;VARIATION SELECTOR-43;Mn;0;NSM;;;;;N;;;;;\nE011B;VARIATION SELECTOR-44;Mn;0;NSM;;;;;N;;;;;\nE011C;VARIATION SELECTOR-45;Mn;0;NSM;;;;;N;;;;;\nE011D;VARIATION SELECTOR-46;Mn;0;NSM;;;;;N;;;;;\nE011E;VARIATION SELECTOR-47;Mn;0;NSM;;;;;N;;;;;\nE011F;VARIATION SELECTOR-48;Mn;0;NSM;;;;;N;;;;;\nE0120;VARIATION SELECTOR-49;Mn;0;NSM;;;;;N;;;;;\nE0121;VARIATION SELECTOR-50;Mn;0;NSM;;;;;N;;;;;\nE0122;VARIATION SELECTOR-51;Mn;0;NSM;;;;;N;;;;;\nE0123;VARIATION SELECTOR-52;Mn;0;NSM;;;;;N;;;;;\nE0124;VARIATION SELECTOR-53;Mn;0;NSM;;;;;N;;;;;\nE0125;VARIATION SELECTOR-54;Mn;0;NSM;;;;;N;;;;;\nE0126;VARIATION SELECTOR-55;Mn;0;NSM;;;;;N;;;;;\nE0127;VARIATION SELECTOR-56;Mn;0;NSM;;;;;N;;;;;\nE0128;VARIATION SELECTOR-57;Mn;0;NSM;;;;;N;;;;;\nE0129;VARIATION SELECTOR-58;Mn;0;NSM;;;;;N;;;;;\nE012A;VARIATION SELECTOR-59;Mn;0;NSM;;;;;N;;;;;\nE012B;VARIATION SELECTOR-60;Mn;0;NSM;;;;;N;;;;;\nE012C;VARIATION SELECTOR-61;Mn;0;NSM;;;;;N;;;;;\nE012D;VARIATION SELECTOR-62;Mn;0;NSM;;;;;N;;;;;\nE012E;VARIATION SELECTOR-63;Mn;0;NSM;;;;;N;;;;;\nE012F;VARIATION SELECTOR-64;Mn;0;NSM;;;;;N;;;;;\nE0130;VARIATION SELECTOR-65;Mn;0;NSM;;;;;N;;;;;\nE0131;VARIATION SELECTOR-66;Mn;0;NSM;;;;;N;;;;;\nE0132;VARIATION SELECTOR-67;Mn;0;NSM;;;;;N;;;;;\nE0133;VARIATION SELECTOR-68;Mn;0;NSM;;;;;N;;;;;\nE0134;VARIATION SELECTOR-69;Mn;0;NSM;;;;;N;;;;;\nE0135;VARIATION SELECTOR-70;Mn;0;NSM;;;;;N;;;;;\nE0136;VARIATION SELECTOR-71;Mn;0;NSM;;;;;N;;;;;\nE0137;VARIATION SELECTOR-72;Mn;0;NSM;;;;;N;;;;;\nE0138;VARIATION SELECTOR-73;Mn;0;NSM;;;;;N;;;;;\nE0139;VARIATION SELECTOR-74;Mn;0;NSM;;;;;N;;;;;\nE013A;VARIATION SELECTOR-75;Mn;0;NSM;;;;;N;;;;;\nE013B;VARIATION SELECTOR-76;Mn;0;NSM;;;;;N;;;;;\nE013C;VARIATION SELECTOR-77;Mn;0;NSM;;;;;N;;;;;\nE013D;VARIATION SELECTOR-78;Mn;0;NSM;;;;;N;;;;;\nE013E;VARIATION SELECTOR-79;Mn;0;NSM;;;;;N;;;;;\nE013F;VARIATION SELECTOR-80;Mn;0;NSM;;;;;N;;;;;\nE0140;VARIATION SELECTOR-81;Mn;0;NSM;;;;;N;;;;;\nE0141;VARIATION SELECTOR-82;Mn;0;NSM;;;;;N;;;;;\nE0142;VARIATION SELECTOR-83;Mn;0;NSM;;;;;N;;;;;\nE0143;VARIATION SELECTOR-84;Mn;0;NSM;;;;;N;;;;;\nE0144;VARIATION SELECTOR-85;Mn;0;NSM;;;;;N;;;;;\nE0145;VARIATION SELECTOR-86;Mn;0;NSM;;;;;N;;;;;\nE0146;VARIATION SELECTOR-87;Mn;0;NSM;;;;;N;;;;;\nE0147;VARIATION SELECTOR-88;Mn;0;NSM;;;;;N;;;;;\nE0148;VARIATION SELECTOR-89;Mn;0;NSM;;;;;N;;;;;\nE0149;VARIATION SELECTOR-90;Mn;0;NSM;;;;;N;;;;;\nE014A;VARIATION SELECTOR-91;Mn;0;NSM;;;;;N;;;;;\nE014B;VARIATION SELECTOR-92;Mn;0;NSM;;;;;N;;;;;\nE014C;VARIATION SELECTOR-93;Mn;0;NSM;;;;;N;;;;;\nE014D;VARIATION SELECTOR-94;Mn;0;NSM;;;;;N;;;;;\nE014E;VARIATION SELECTOR-95;Mn;0;NSM;;;;;N;;;;;\nE014F;VARIATION SELECTOR-96;Mn;0;NSM;;;;;N;;;;;\nE0150;VARIATION SELECTOR-97;Mn;0;NSM;;;;;N;;;;;\nE0151;VARIATION SELECTOR-98;Mn;0;NSM;;;;;N;;;;;\nE0152;VARIATION SELECTOR-99;Mn;0;NSM;;;;;N;;;;;\nE0153;VARIATION SELECTOR-100;Mn;0;NSM;;;;;N;;;;;\nE0154;VARIATION SELECTOR-101;Mn;0;NSM;;;;;N;;;;;\nE0155;VARIATION SELECTOR-102;Mn;0;NSM;;;;;N;;;;;\nE0156;VARIATION SELECTOR-103;Mn;0;NSM;;;;;N;;;;;\nE0157;VARIATION SELECTOR-104;Mn;0;NSM;;;;;N;;;;;\nE0158;VARIATION SELECTOR-105;Mn;0;NSM;;;;;N;;;;;\nE0159;VARIATION SELECTOR-106;Mn;0;NSM;;;;;N;;;;;\nE015A;VARIATION SELECTOR-107;Mn;0;NSM;;;;;N;;;;;\nE015B;VARIATION SELECTOR-108;Mn;0;NSM;;;;;N;;;;;\nE015C;VARIATION SELECTOR-109;Mn;0;NSM;;;;;N;;;;;\nE015D;VARIATION SELECTOR-110;Mn;0;NSM;;;;;N;;;;;\nE015E;VARIATION SELECTOR-111;Mn;0;NSM;;;;;N;;;;;\nE015F;VARIATION SELECTOR-112;Mn;0;NSM;;;;;N;;;;;\nE0160;VARIATION SELECTOR-113;Mn;0;NSM;;;;;N;;;;;\nE0161;VARIATION SELECTOR-114;Mn;0;NSM;;;;;N;;;;;\nE0162;VARIATION SELECTOR-115;Mn;0;NSM;;;;;N;;;;;\nE0163;VARIATION SELECTOR-116;Mn;0;NSM;;;;;N;;;;;\nE0164;VARIATION SELECTOR-117;Mn;0;NSM;;;;;N;;;;;\nE0165;VARIATION SELECTOR-118;Mn;0;NSM;;;;;N;;;;;\nE0166;VARIATION SELECTOR-119;Mn;0;NSM;;;;;N;;;;;\nE0167;VARIATION SELECTOR-120;Mn;0;NSM;;;;;N;;;;;\nE0168;VARIATION SELECTOR-121;Mn;0;NSM;;;;;N;;;;;\nE0169;VARIATION SELECTOR-122;Mn;0;NSM;;;;;N;;;;;\nE016A;VARIATION SELECTOR-123;Mn;0;NSM;;;;;N;;;;;\nE016B;VARIATION SELECTOR-124;Mn;0;NSM;;;;;N;;;;;\nE016C;VARIATION SELECTOR-125;Mn;0;NSM;;;;;N;;;;;\nE016D;VARIATION SELECTOR-126;Mn;0;NSM;;;;;N;;;;;\nE016E;VARIATION SELECTOR-127;Mn;0;NSM;;;;;N;;;;;\nE016F;VARIATION SELECTOR-128;Mn;0;NSM;;;;;N;;;;;\nE0170;VARIATION SELECTOR-129;Mn;0;NSM;;;;;N;;;;;\nE0171;VARIATION SELECTOR-130;Mn;0;NSM;;;;;N;;;;;\nE0172;VARIATION SELECTOR-131;Mn;0;NSM;;;;;N;;;;;\nE0173;VARIATION SELECTOR-132;Mn;0;NSM;;;;;N;;;;;\nE0174;VARIATION SELECTOR-133;Mn;0;NSM;;;;;N;;;;;\nE0175;VARIATION SELECTOR-134;Mn;0;NSM;;;;;N;;;;;\nE0176;VARIATION SELECTOR-135;Mn;0;NSM;;;;;N;;;;;\nE0177;VARIATION SELECTOR-136;Mn;0;NSM;;;;;N;;;;;\nE0178;VARIATION SELECTOR-137;Mn;0;NSM;;;;;N;;;;;\nE0179;VARIATION SELECTOR-138;Mn;0;NSM;;;;;N;;;;;\nE017A;VARIATION SELECTOR-139;Mn;0;NSM;;;;;N;;;;;\nE017B;VARIATION SELECTOR-140;Mn;0;NSM;;;;;N;;;;;\nE017C;VARIATION SELECTOR-141;Mn;0;NSM;;;;;N;;;;;\nE017D;VARIATION SELECTOR-142;Mn;0;NSM;;;;;N;;;;;\nE017E;VARIATION SELECTOR-143;Mn;0;NSM;;;;;N;;;;;\nE017F;VARIATION SELECTOR-144;Mn;0;NSM;;;;;N;;;;;\nE0180;VARIATION SELECTOR-145;Mn;0;NSM;;;;;N;;;;;\nE0181;VARIATION SELECTOR-146;Mn;0;NSM;;;;;N;;;;;\nE0182;VARIATION SELECTOR-147;Mn;0;NSM;;;;;N;;;;;\nE0183;VARIATION SELECTOR-148;Mn;0;NSM;;;;;N;;;;;\nE0184;VARIATION SELECTOR-149;Mn;0;NSM;;;;;N;;;;;\nE0185;VARIATION SELECTOR-150;Mn;0;NSM;;;;;N;;;;;\nE0186;VARIATION SELECTOR-151;Mn;0;NSM;;;;;N;;;;;\nE0187;VARIATION SELECTOR-152;Mn;0;NSM;;;;;N;;;;;\nE0188;VARIATION SELECTOR-153;Mn;0;NSM;;;;;N;;;;;\nE0189;VARIATION SELECTOR-154;Mn;0;NSM;;;;;N;;;;;\nE018A;VARIATION SELECTOR-155;Mn;0;NSM;;;;;N;;;;;\nE018B;VARIATION SELECTOR-156;Mn;0;NSM;;;;;N;;;;;\nE018C;VARIATION SELECTOR-157;Mn;0;NSM;;;;;N;;;;;\nE018D;VARIATION SELECTOR-158;Mn;0;NSM;;;;;N;;;;;\nE018E;VARIATION SELECTOR-159;Mn;0;NSM;;;;;N;;;;;\nE018F;VARIATION SELECTOR-160;Mn;0;NSM;;;;;N;;;;;\nE0190;VARIATION SELECTOR-161;Mn;0;NSM;;;;;N;;;;;\nE0191;VARIATION SELECTOR-162;Mn;0;NSM;;;;;N;;;;;\nE0192;VARIATION SELECTOR-163;Mn;0;NSM;;;;;N;;;;;\nE0193;VARIATION SELECTOR-164;Mn;0;NSM;;;;;N;;;;;\nE0194;VARIATION SELECTOR-165;Mn;0;NSM;;;;;N;;;;;\nE0195;VARIATION SELECTOR-166;Mn;0;NSM;;;;;N;;;;;\nE0196;VARIATION SELECTOR-167;Mn;0;NSM;;;;;N;;;;;\nE0197;VARIATION SELECTOR-168;Mn;0;NSM;;;;;N;;;;;\nE0198;VARIATION SELECTOR-169;Mn;0;NSM;;;;;N;;;;;\nE0199;VARIATION SELECTOR-170;Mn;0;NSM;;;;;N;;;;;\nE019A;VARIATION SELECTOR-171;Mn;0;NSM;;;;;N;;;;;\nE019B;VARIATION SELECTOR-172;Mn;0;NSM;;;;;N;;;;;\nE019C;VARIATION SELECTOR-173;Mn;0;NSM;;;;;N;;;;;\nE019D;VARIATION SELECTOR-174;Mn;0;NSM;;;;;N;;;;;\nE019E;VARIATION SELECTOR-175;Mn;0;NSM;;;;;N;;;;;\nE019F;VARIATION SELECTOR-176;Mn;0;NSM;;;;;N;;;;;\nE01A0;VARIATION SELECTOR-177;Mn;0;NSM;;;;;N;;;;;\nE01A1;VARIATION SELECTOR-178;Mn;0;NSM;;;;;N;;;;;\nE01A2;VARIATION SELECTOR-179;Mn;0;NSM;;;;;N;;;;;\nE01A3;VARIATION SELECTOR-180;Mn;0;NSM;;;;;N;;;;;\nE01A4;VARIATION SELECTOR-181;Mn;0;NSM;;;;;N;;;;;\nE01A5;VARIATION SELECTOR-182;Mn;0;NSM;;;;;N;;;;;\nE01A6;VARIATION SELECTOR-183;Mn;0;NSM;;;;;N;;;;;\nE01A7;VARIATION SELECTOR-184;Mn;0;NSM;;;;;N;;;;;\nE01A8;VARIATION SELECTOR-185;Mn;0;NSM;;;;;N;;;;;\nE01A9;VARIATION SELECTOR-186;Mn;0;NSM;;;;;N;;;;;\nE01AA;VARIATION SELECTOR-187;Mn;0;NSM;;;;;N;;;;;\nE01AB;VARIATION SELECTOR-188;Mn;0;NSM;;;;;N;;;;;\nE01AC;VARIATION SELECTOR-189;Mn;0;NSM;;;;;N;;;;;\nE01AD;VARIATION SELECTOR-190;Mn;0;NSM;;;;;N;;;;;\nE01AE;VARIATION SELECTOR-191;Mn;0;NSM;;;;;N;;;;;\nE01AF;VARIATION SELECTOR-192;Mn;0;NSM;;;;;N;;;;;\nE01B0;VARIATION SELECTOR-193;Mn;0;NSM;;;;;N;;;;;\nE01B1;VARIATION SELECTOR-194;Mn;0;NSM;;;;;N;;;;;\nE01B2;VARIATION SELECTOR-195;Mn;0;NSM;;;;;N;;;;;\nE01B3;VARIATION SELECTOR-196;Mn;0;NSM;;;;;N;;;;;\nE01B4;VARIATION SELECTOR-197;Mn;0;NSM;;;;;N;;;;;\nE01B5;VARIATION SELECTOR-198;Mn;0;NSM;;;;;N;;;;;\nE01B6;VARIATION SELECTOR-199;Mn;0;NSM;;;;;N;;;;;\nE01B7;VARIATION SELECTOR-200;Mn;0;NSM;;;;;N;;;;;\nE01B8;VARIATION SELECTOR-201;Mn;0;NSM;;;;;N;;;;;\nE01B9;VARIATION SELECTOR-202;Mn;0;NSM;;;;;N;;;;;\nE01BA;VARIATION SELECTOR-203;Mn;0;NSM;;;;;N;;;;;\nE01BB;VARIATION SELECTOR-204;Mn;0;NSM;;;;;N;;;;;\nE01BC;VARIATION SELECTOR-205;Mn;0;NSM;;;;;N;;;;;\nE01BD;VARIATION SELECTOR-206;Mn;0;NSM;;;;;N;;;;;\nE01BE;VARIATION SELECTOR-207;Mn;0;NSM;;;;;N;;;;;\nE01BF;VARIATION SELECTOR-208;Mn;0;NSM;;;;;N;;;;;\nE01C0;VARIATION SELECTOR-209;Mn;0;NSM;;;;;N;;;;;\nE01C1;VARIATION SELECTOR-210;Mn;0;NSM;;;;;N;;;;;\nE01C2;VARIATION SELECTOR-211;Mn;0;NSM;;;;;N;;;;;\nE01C3;VARIATION SELECTOR-212;Mn;0;NSM;;;;;N;;;;;\nE01C4;VARIATION SELECTOR-213;Mn;0;NSM;;;;;N;;;;;\nE01C5;VARIATION SELECTOR-214;Mn;0;NSM;;;;;N;;;;;\nE01C6;VARIATION SELECTOR-215;Mn;0;NSM;;;;;N;;;;;\nE01C7;VARIATION SELECTOR-216;Mn;0;NSM;;;;;N;;;;;\nE01C8;VARIATION SELECTOR-217;Mn;0;NSM;;;;;N;;;;;\nE01C9;VARIATION SELECTOR-218;Mn;0;NSM;;;;;N;;;;;\nE01CA;VARIATION SELECTOR-219;Mn;0;NSM;;;;;N;;;;;\nE01CB;VARIATION SELECTOR-220;Mn;0;NSM;;;;;N;;;;;\nE01CC;VARIATION SELECTOR-221;Mn;0;NSM;;;;;N;;;;;\nE01CD;VARIATION SELECTOR-222;Mn;0;NSM;;;;;N;;;;;\nE01CE;VARIATION SELECTOR-223;Mn;0;NSM;;;;;N;;;;;\nE01CF;VARIATION SELECTOR-224;Mn;0;NSM;;;;;N;;;;;\nE01D0;VARIATION SELECTOR-225;Mn;0;NSM;;;;;N;;;;;\nE01D1;VARIATION SELECTOR-226;Mn;0;NSM;;;;;N;;;;;\nE01D2;VARIATION SELECTOR-227;Mn;0;NSM;;;;;N;;;;;\nE01D3;VARIATION SELECTOR-228;Mn;0;NSM;;;;;N;;;;;\nE01D4;VARIATION SELECTOR-229;Mn;0;NSM;;;;;N;;;;;\nE01D5;VARIATION SELECTOR-230;Mn;0;NSM;;;;;N;;;;;\nE01D6;VARIATION SELECTOR-231;Mn;0;NSM;;;;;N;;;;;\nE01D7;VARIATION SELECTOR-232;Mn;0;NSM;;;;;N;;;;;\nE01D8;VARIATION SELECTOR-233;Mn;0;NSM;;;;;N;;;;;\nE01D9;VARIATION SELECTOR-234;Mn;0;NSM;;;;;N;;;;;\nE01DA;VARIATION SELECTOR-235;Mn;0;NSM;;;;;N;;;;;\nE01DB;VARIATION SELECTOR-236;Mn;0;NSM;;;;;N;;;;;\nE01DC;VARIATION SELECTOR-237;Mn;0;NSM;;;;;N;;;;;\nE01DD;VARIATION SELECTOR-238;Mn;0;NSM;;;;;N;;;;;\nE01DE;VARIATION SELECTOR-239;Mn;0;NSM;;;;;N;;;;;\nE01DF;VARIATION SELECTOR-240;Mn;0;NSM;;;;;N;;;;;\nE01E0;VARIATION SELECTOR-241;Mn;0;NSM;;;;;N;;;;;\nE01E1;VARIATION SELECTOR-242;Mn;0;NSM;;;;;N;;;;;\nE01E2;VARIATION SELECTOR-243;Mn;0;NSM;;;;;N;;;;;\nE01E3;VARIATION SELECTOR-244;Mn;0;NSM;;;;;N;;;;;\nE01E4;VARIATION SELECTOR-245;Mn;0;NSM;;;;;N;;;;;\nE01E5;VARIATION SELECTOR-246;Mn;0;NSM;;;;;N;;;;;\nE01E6;VARIATION SELECTOR-247;Mn;0;NSM;;;;;N;;;;;\nE01E7;VARIATION SELECTOR-248;Mn;0;NSM;;;;;N;;;;;\nE01E8;VARIATION SELECTOR-249;Mn;0;NSM;;;;;N;;;;;\nE01E9;VARIATION SELECTOR-250;Mn;0;NSM;;;;;N;;;;;\nE01EA;VARIATION SELECTOR-251;Mn;0;NSM;;;;;N;;;;;\nE01EB;VARIATION SELECTOR-252;Mn;0;NSM;;;;;N;;;;;\nE01EC;VARIATION SELECTOR-253;Mn;0;NSM;;;;;N;;;;;\nE01ED;VARIATION SELECTOR-254;Mn;0;NSM;;;;;N;;;;;\nE01EE;VARIATION SELECTOR-255;Mn;0;NSM;;;;;N;;;;;\nE01EF;VARIATION SELECTOR-256;Mn;0;NSM;;;;;N;;;;;\nF0000;<Plane 15 Private Use, First>;Co;0;L;;;;;N;;;;;\nFFFFD;<Plane 15 Private Use, Last>;Co;0;L;;;;;N;;;;;\n100000;<Plane 16 Private Use, First>;Co;0;L;;;;;N;;;;;\n10FFFD;<Plane 16 Private Use, Last>;Co;0;L;;;;;N;;;;;\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/unicode/mkunicode.tcl",
    "content": "\nsource [file join [file dirname [info script]] parseunicode.tcl]\n\nproc print_rd {map} {\n  global tl_lookup_table\n  set aChar [list]\n  set lRange [list]\n\n  set nRange 1\n  set iFirst  [lindex $map 0 0]\n  set cPrev   [lindex $map 0 1]\n\n  foreach m [lrange $map 1 end] {\n    foreach {i c} $m {}\n\n    if {$cPrev == $c} {\n      for {set j [expr $iFirst+$nRange]} {$j<$i} {incr j} {\n        if {[info exists tl_lookup_table($j)]==0} break\n      }\n\n      if {$j==$i} {\n        set nNew [expr {(1 + $i - $iFirst)}]\n        if {$nNew<=8} {\n          set nRange $nNew\n          continue\n        }\n      }\n    }\n\n    lappend lRange [list $iFirst $nRange]\n    lappend aChar  $cPrev\n\n    set iFirst $i\n    set cPrev  $c\n    set nRange 1\n  }\n  lappend lRange [list $iFirst $nRange]\n  lappend aChar $cPrev\n\n  puts \"/*\"\n  puts \"** If the argument is a codepoint corresponding to a lowercase letter\"\n  puts \"** in the ASCII range with a diacritic added, return the codepoint\"\n  puts \"** of the ASCII letter only. For example, if passed 235 - \\\"LATIN\"\n  puts \"** SMALL LETTER E WITH DIAERESIS\\\" - return 65 (\\\"LATIN SMALL LETTER\"\n  puts \"** E\\\"). The resuls of passing a codepoint that corresponds to an\"\n  puts \"** uppercase letter are undefined.\"\n  puts \"*/\"\n  puts \"static int ${::remove_diacritic}(int c)\\{\"\n  puts \"  unsigned short aDia\\[\\] = \\{\"\n  puts -nonewline \"        0, \"\n  set i 1\n  foreach r $lRange {\n    foreach {iCode nRange} $r {}\n    if {($i % 8)==0} {puts \"\" ; puts -nonewline \"    \" }\n    incr i\n\n    puts -nonewline [format \"%5d\" [expr ($iCode<<3) + $nRange-1]]\n    puts -nonewline \", \"\n  }\n  puts \"\"\n  puts \"  \\};\"\n  puts \"  char aChar\\[\\] = \\{\"\n  puts -nonewline \"    '\\\\0', \"\n  set i 1\n  foreach c $aChar {\n    set str \"'$c',  \"\n    if {$c == \"\"} { set str \"'\\\\0', \" }\n\n    if {($i % 12)==0} {puts \"\" ; puts -nonewline \"    \" }\n    incr i\n    puts -nonewline \"$str\"\n  }\n  puts \"\"\n  puts \"  \\};\"\n  puts {\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);}\n  puts \"\\}\"\n}\n\nproc print_isdiacritic {zFunc map} {\n\n  set lCode [list]\n  foreach m $map {\n    foreach {code char} $m {}\n    if {$code && $char == \"\"} { lappend lCode $code }\n  }\n  set lCode [lsort -integer $lCode]\n  set iFirst [lindex $lCode 0]\n  set iLast [lindex $lCode end]\n\n  set i1 0\n  set i2 0\n\n  foreach c $lCode {\n    set i [expr $c - $iFirst]\n    if {$i < 32} {\n      set i1 [expr {$i1 | (1<<$i)}]\n    } else {\n      set i2 [expr {$i2 | (1<<($i-32))}]\n    }\n  }\n\n  puts \"/*\"\n  puts \"** Return true if the argument interpreted as a unicode codepoint\" \n  puts \"** is a diacritical modifier character.\"\n  puts \"*/\"\n  puts \"int ${zFunc}\\(int c)\\{\"\n  puts \"  unsigned int mask0 = [format \"0x%08X\" $i1];\"\n  puts \"  unsigned int mask1 = [format \"0x%08X\" $i2];\"\n\n  puts \"  if( c<$iFirst || c>$iLast ) return 0;\"\n  puts \"  return (c < $iFirst+32) ?\"\n  puts \"      (mask0 & (1 << (c-$iFirst))) :\"\n  puts \"      (mask1 & (1 << (c-$iFirst-32)));\"\n  puts \"\\}\"\n}\n\n\n#-------------------------------------------------------------------------\n\nproc an_load_separator_ranges {} {\n  global unicodedata.txt\n  set lSep [an_load_unicodedata_text ${unicodedata.txt}]\n  unset -nocomplain iFirst \n  unset -nocomplain nRange \n  set lRange [list]\n  foreach sep $lSep {\n    if {0==[info exists iFirst]} {\n      set iFirst $sep\n      set nRange 1\n    } elseif { $sep == ($iFirst+$nRange) } {\n      incr nRange\n    } else {\n      lappend lRange [list $iFirst $nRange]\n      set iFirst $sep\n      set nRange 1\n    }\n  } \n  lappend lRange [list $iFirst $nRange]\n  set lRange\n}\n\nproc an_print_range_array {lRange} {\n  set iFirstMax 0\n  set nRangeMax 0\n  foreach range $lRange {\n    foreach {iFirst nRange} $range {}\n    if {$iFirst > $iFirstMax} {set iFirstMax $iFirst}\n    if {$nRange > $nRangeMax} {set nRangeMax $nRange}\n  }\n  if {$iFirstMax >= (1<<22)} {error \"first-max is too large for format\"}\n  if {$nRangeMax >= (1<<10)} {error \"range-max is too large for format\"}\n\n  puts -nonewline \"  \"\n  puts [string trim {\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  }]\n  puts -nonewline \"  static const unsigned int aEntry\\[\\] = \\{\"\n  set i 0\n  foreach range $lRange {\n    foreach {iFirst nRange} $range {}\n    set u32 [format \"0x%08X\" [expr ($iFirst<<10) + $nRange]]\n\n    if {($i % 5)==0} {puts \"\" ; puts -nonewline \"   \"}\n    puts -nonewline \" $u32,\"\n    incr i\n  }\n  puts \"\"\n  puts \"  \\};\"\n}\n\nproc an_print_ascii_bitmap {lRange} {\n  foreach range $lRange {\n    foreach {iFirst nRange} $range {}\n    for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} {\n      if {$i<=127} { set a($i) 1 }\n    }\n  }\n\n  set aAscii [list 0 0 0 0]\n  foreach key [array names a] {\n    set idx [expr $key >> 5]\n    lset aAscii $idx [expr [lindex $aAscii $idx] | (1 << ($key&0x001F))]\n  }\n\n  puts \"  static const unsigned int aAscii\\[4\\] = \\{\"\n  puts -nonewline \"   \"\n  foreach v $aAscii { puts -nonewline [format \" 0x%08X,\" $v] }\n  puts \"\"\n  puts \"  \\};\"\n}\n\nproc print_isalnum {zFunc lRange} {\n  puts \"/*\"\n  puts \"** Return true if the argument corresponds to a unicode codepoint\"\n  puts \"** classified as either a letter or a number. Otherwise false.\"\n  puts \"**\"\n  puts \"** The results are undefined if the value passed to this function\"\n  puts \"** is less than zero.\"\n  puts \"*/\"\n  puts \"int ${zFunc}\\(int c)\\{\"\n  an_print_range_array $lRange\n  an_print_ascii_bitmap $lRange\n  puts {\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;}\n  puts \"\\}\"\n}\n\nproc print_test_isalnum {zFunc lRange} {\n  foreach range $lRange {\n    foreach {iFirst nRange} $range {}\n    for {set i $iFirst} {$i < ($iFirst+$nRange)} {incr i} { set a($i) 1 }\n  }\n\n  puts \"static int isalnum_test(int *piCode)\\{\"\n  puts -nonewline \"  unsigned char aAlnum\\[\\] = \\{\"\n  for {set i 0} {$i < 70000} {incr i} {\n    if {($i % 32)==0} { puts \"\" ; puts -nonewline \"    \" }\n    set bFlag [expr ![info exists a($i)]]\n    puts -nonewline \"${bFlag},\"\n  }\n  puts \"\"\n  puts \"  \\};\"\n\n  puts -nonewline \"  int aLargeSep\\[\\] = \\{\"\n  set i 0\n  foreach iSep [lsort -integer [array names a]] {\n    if {$iSep<70000} continue\n    if {($i % 8)==0} { puts \"\" ; puts -nonewline \"   \" }\n    puts -nonewline \" $iSep,\"\n    incr i\n  }\n  puts \"\"\n  puts \"  \\};\"\n  puts -nonewline \"  int aLargeOther\\[\\] = \\{\"\n  set i 0\n  foreach iSep [lsort -integer [array names a]] {\n    if {$iSep<70000} continue\n    if {[info exists a([expr $iSep-1])]==0} {\n      if {($i % 8)==0} { puts \"\" ; puts -nonewline \"   \" }\n      puts -nonewline \" [expr $iSep-1],\"\n      incr i\n    }\n    if {[info exists a([expr $iSep+1])]==0} {\n      if {($i % 8)==0} { puts \"\" ; puts -nonewline \"   \" }\n      puts -nonewline \" [expr $iSep+1],\"\n      incr i\n    }\n  }\n  puts \"\"\n  puts \"  \\};\"\n\n  puts [subst -nocommands {\n  int i;\n  for(i=0; i<sizeof(aAlnum)/sizeof(aAlnum[0]); i++){\n    if( ${zFunc}(i)!=aAlnum[i] ){\n      *piCode = i;\n      return 1;\n    }\n  }\n  for(i=0; i<sizeof(aLargeSep)/sizeof(aLargeSep[0]); i++){\n    if( ${zFunc}(aLargeSep[i])!=0 ){\n      *piCode = aLargeSep[i];\n      return 1;\n    }\n  }\n  for(i=0; i<sizeof(aLargeOther)/sizeof(aLargeOther[0]); i++){\n    if( ${zFunc}(aLargeOther[i])!=1 ){\n      *piCode = aLargeOther[i];\n      return 1;\n    }\n  }\n  }]\n  puts \"  return 0;\"\n  puts \"\\}\"\n}\n\n#-------------------------------------------------------------------------\n\nproc tl_create_records {} {\n  global tl_lookup_table\n\n  set iFirst \"\"\n  set nOff 0\n  set nRange 0\n  set nIncr 0\n\n  set lRecord [list]\n  foreach code [lsort -integer [array names tl_lookup_table]] {\n    set mapping $tl_lookup_table($code)\n    if {$iFirst == \"\"} {\n      set iFirst $code\n      set nOff   [expr $mapping - $code]\n      set nRange 1\n      set nIncr 1\n    } else {\n      set diff [expr $code - ($iFirst + ($nIncr * ($nRange - 1)))]\n      if { $nRange==1 && ($diff==1 || $diff==2) } {\n        set nIncr $diff\n      }\n\n      if {$diff != $nIncr || ($mapping - $code)!=$nOff} {\n        if { $nRange==1 } {set nIncr 1}\n        lappend lRecord [list $iFirst $nIncr $nRange $nOff]\n        set iFirst $code\n        set nOff   [expr $mapping - $code]\n        set nRange 1\n        set nIncr 1\n      } else {\n        incr nRange\n      }\n    }\n  }\n\n  lappend lRecord [list $iFirst $nIncr $nRange $nOff]\n\n  set lRecord\n}\n\nproc tl_print_table_header {} {\n  puts -nonewline \"  \"\n  puts [string trim {\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  }]\n  puts \"  static const struct TableEntry \\{\"\n  puts \"    unsigned short iCode;\"\n  puts \"    unsigned char flags;\"\n  puts \"    unsigned char nRange;\"\n  puts \"  \\} aEntry\\[\\] = \\{\"\n}\n\nproc tl_print_table_entry {togglevar entry liOff} {\n  upvar $togglevar t\n  foreach {iFirst nIncr nRange nOff} $entry {}\n\n  if {$iFirst > (1<<16)} { return 1 }\n\n  if {[info exists t]==0} {set t 0}\n  if {$t==0} { puts -nonewline \"    \" }\n\n  set flags 0\n  if {$nIncr==2} { set flags 1 ; set nRange [expr $nRange * 2]}\n  if {$nOff<0}   { incr nOff [expr (1<<16)] }\n\n  set idx [lsearch $liOff $nOff]\n  if {$idx<0} {error \"malfunction generating aiOff\"}\n  set flags [expr $flags + $idx*2]\n\n  set txt \"{$iFirst, $flags, $nRange},\"\n  if {$t==2} {\n    puts $txt\n  } else {\n    puts -nonewline [format \"% -23s\" $txt]\n  }\n  set t [expr ($t+1)%3]\n\n  return 0\n}\n\nproc tl_print_table_footer {togglevar} {\n  upvar $togglevar t\n  if {$t!=0} {puts \"\"}\n  puts \"  \\};\"\n}\n\nproc tl_print_if_entry {entry} {\n  foreach {iFirst nIncr nRange nOff} $entry {}\n  if {$nIncr==2} {error \"tl_print_if_entry needs improvement!\"}\n\n  puts \"  else if( c>=$iFirst && c<[expr $iFirst+$nRange] )\\{\"\n  puts \"    ret = c + $nOff;\"\n  puts \"  \\}\"\n}\n\nproc tl_generate_ioff_table {lRecord} {\n  foreach entry $lRecord {\n    foreach {iFirst nIncr nRange iOff} $entry {}\n    if {$iOff<0}   { incr iOff [expr (1<<16)] }\n    if {[info exists a($iOff)]} continue\n    set a($iOff) 1\n  }\n\n  set liOff [lsort -integer [array names a]]\n  if {[llength $liOff]>128} { error \"Too many distinct ioffs\" }\n  return $liOff\n}\n\nproc tl_print_ioff_table {liOff} {\n  puts -nonewline \"  static const unsigned short aiOff\\[\\] = \\{\"\n  set i 0\n  foreach off $liOff {\n    if {($i % 8)==0} {puts \"\" ; puts -nonewline \"   \"}\n    puts -nonewline [format \"% -7s\" \"$off,\"]\n    incr i\n  }\n  puts \"\"\n  puts \"  \\};\"\n\n}\n\nproc print_fold {zFunc} {\n\n  set lRecord [tl_create_records]\n\n  set lHigh [list]\n  puts \"/*\"\n  puts \"** Interpret the argument as a unicode codepoint. If the codepoint\"\n  puts \"** is an upper case character that has a lower case equivalent,\"\n  puts \"** return the codepoint corresponding to the lower case version.\"\n  puts \"** Otherwise, return a copy of the argument.\"\n  puts \"**\"\n  puts \"** The results are undefined if the value passed to this function\"\n  puts \"** is less than zero.\"\n  puts \"*/\"\n  puts \"int ${zFunc}\\(int c, int bRemoveDiacritic)\\{\"\n\n  set liOff [tl_generate_ioff_table $lRecord]\n  tl_print_table_header\n  foreach entry $lRecord { \n    if {[tl_print_table_entry toggle $entry $liOff]} { \n      lappend lHigh $entry \n    } \n  }\n  tl_print_table_footer toggle\n  tl_print_ioff_table $liOff\n\n  puts [subst -nocommands {\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( bRemoveDiacritic ) ret = ${::remove_diacritic}(ret);\n  }\n  }]\n\n  foreach entry $lHigh {\n    tl_print_if_entry $entry\n  }\n\n  puts \"\"\n  puts \"  return ret;\"\n  puts \"\\}\"\n}\n\nproc print_fold_test {zFunc mappings} {\n  global tl_lookup_table\n\n  foreach m $mappings {\n    set c [lindex $m 1]\n    if {$c == \"\"} {\n      set extra([lindex $m 0]) 0\n    } else {\n      scan $c %c i\n      set extra([lindex $m 0]) $i\n    }\n  }\n\n  puts \"static int fold_test(int *piCode)\\{\"\n  puts -nonewline \"  static int aLookup\\[\\] = \\{\"\n  for {set i 0} {$i < 70000} {incr i} {\n\n    set expected $i\n    catch { set expected $tl_lookup_table($i) }\n    set expected2 $expected\n    catch { set expected2 $extra($expected2) }\n\n    if {($i % 4)==0}  { puts \"\" ; puts -nonewline \"    \" }\n    puts -nonewline \"$expected, $expected2, \"\n  }\n  puts \"  \\};\"\n  puts \"  int i;\"\n  puts \"  for(i=0; i<sizeof(aLookup)/sizeof(aLookup\\[0\\]); i++)\\{\"\n  puts \"    int iCode = (i/2);\"\n  puts \"    int bFlag = i & 0x0001;\"\n  puts \"    if( ${zFunc}\\(iCode, bFlag)!=aLookup\\[i\\] )\\{\"\n  puts \"      *piCode = iCode;\"\n  puts \"      return 1;\"\n  puts \"    \\}\"\n  puts \"  \\}\"\n  puts \"  return 0;\"\n  puts \"\\}\"\n}\n\n\nproc print_fileheader {} {\n  puts [string trim {\n/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n  }]\n  puts \"\"\n  if {$::generate_fts5_code} {\n    # no-op\n  } else {\n    puts \"#ifndef SQLITE_DISABLE_FTS3_UNICODE\"\n    puts \"#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\"\n  }\n  puts \"\"\n  puts \"#include <assert.h>\"\n  puts \"\"\n}\n\nproc print_test_main {} {\n  puts \"\"\n  puts \"#include <stdio.h>\"\n  puts \"\"\n  puts \"int main(int argc, char **argv)\\{\"\n  puts \"  int r1, r2;\"\n  puts \"  int code;\"\n  puts \"  r1 = isalnum_test(&code);\"\n  puts \"  if( r1 ) printf(\\\"isalnum(): Problem with code %d\\\\n\\\",code);\"\n  puts \"  else printf(\\\"isalnum(): test passed\\\\n\\\");\"\n  puts \"  r2 = fold_test(&code);\"\n  puts \"  if( r2 ) printf(\\\"fold(): Problem with code %d\\\\n\\\",code);\"\n  puts \"  else printf(\\\"fold(): test passed\\\\n\\\");\"\n  puts \"  return (r1 || r2);\"\n  puts \"\\}\"\n}\n\n# Proces the command line arguments. Exit early if they are not to\n# our liking.\n#\nproc usage {} {\n  puts -nonewline stderr \"Usage: $::argv0 ?-test? ?-fts5? \"\n  puts            stderr \"<CaseFolding.txt file> <UnicodeData.txt file>\"\n  exit 1\n}\nif {[llength $argv]<2} usage\nset unicodedata.txt [lindex $argv end]\nset casefolding.txt [lindex $argv end-1]\n\nset remove_diacritic remove_diacritic\nset generate_test_code 0\nset generate_fts5_code 0\nset function_prefix \"sqlite3Fts\"\nfor {set i 0} {$i < [llength $argv]-2} {incr i} {\n  switch -- [lindex $argv $i] {\n    -test {\n      set generate_test_code 1\n    }\n    -fts5 {\n      set function_prefix sqlite3Fts5\n      set generate_fts5_code 1\n      set remove_diacritic fts5_remove_diacritic\n    }\n    default {\n      usage\n    }\n  }\n}\n\nprint_fileheader\n\n# Print the isalnum() function to stdout.\n#\nset lRange [an_load_separator_ranges]\nprint_isalnum ${function_prefix}UnicodeIsalnum $lRange\n\n# Leave a gap between the two generated C functions.\n#\nputs \"\"\nputs \"\"\n\n# Load the fold data. This is used by the [rd_XXX] commands\n# as well as [print_fold].\ntl_load_casefolding_txt ${casefolding.txt}\n\nset mappings [rd_load_unicodedata_text ${unicodedata.txt}]\nprint_rd $mappings\nputs \"\"\nputs \"\"\nprint_isdiacritic ${function_prefix}UnicodeIsdiacritic $mappings\nputs \"\"\nputs \"\"\n\n# Print the fold() function to stdout.\n#\nprint_fold ${function_prefix}UnicodeFold\n\n# Print the test routines and main() function to stdout, if -test \n# was specified.\n#\nif {$::generate_test_code} {\n  print_test_isalnum ${function_prefix}UnicodeIsalnum $lRange\n  print_fold_test ${function_prefix}UnicodeFold $mappings\n  print_test_main \n}\n\nif {$generate_fts5_code} {\n  # no-op\n} else {\n  puts \"#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */\"\n  puts \"#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */\"\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts3/unicode/parseunicode.tcl",
    "content": "\n#--------------------------------------------------------------------------\n# Parameter $zName must be a path to the file UnicodeData.txt. This command\n# reads the file and returns a list of mappings required to remove all\n# diacritical marks from a unicode string. Each mapping is itself a list\n# consisting of two elements - the unicode codepoint and the single ASCII\n# character that it should be replaced with, or an empty string if the \n# codepoint should simply be removed from the input. Examples:\n#\n#   { 224 a  }     (replace codepoint 224 to \"a\")\n#   { 769 \"\" }     (remove codepoint 769 from input)\n#\n# Mappings are only returned for non-upper case codepoints. It is assumed\n# that the input has already been folded to lower case.\n#\nproc rd_load_unicodedata_text {zName} {\n  global tl_lookup_table\n\n  set fd [open $zName]\n  set lField {\n    code\n    character_name\n    general_category\n    canonical_combining_classes\n    bidirectional_category\n    character_decomposition_mapping\n    decimal_digit_value\n    digit_value\n    numeric_value\n    mirrored\n    unicode_1_name\n    iso10646_comment_field\n    uppercase_mapping\n    lowercase_mapping\n    titlecase_mapping\n  }\n  set lRet [list]\n\n  while { ![eof $fd] } {\n    set line [gets $fd]\n    if {$line == \"\"} continue\n\n    set fields [split $line \";\"]\n    if {[llength $fields] != [llength $lField]} { error \"parse error: $line\" }\n    foreach $lField $fields {}\n    if { [llength $character_decomposition_mapping]!=2\n      || [string is xdigit [lindex $character_decomposition_mapping 0]]==0\n    } {\n      continue\n    }\n\n    set iCode  [expr \"0x$code\"]\n    set iAscii [expr \"0x[lindex $character_decomposition_mapping 0]\"]\n    set iDia   [expr \"0x[lindex $character_decomposition_mapping 1]\"]\n\n    if {[info exists tl_lookup_table($iCode)]} continue\n\n    if { ($iAscii >= 97 && $iAscii <= 122)\n      || ($iAscii >= 65 && $iAscii <= 90)\n    } {\n      lappend lRet [list $iCode [string tolower [format %c $iAscii]]]\n      set dia($iDia) 1\n    }\n  }\n\n  foreach d [array names dia] {\n    lappend lRet [list $d \"\"]\n  }\n  set lRet [lsort -integer -index 0 $lRet]\n\n  close $fd\n  set lRet\n}\n\n#-------------------------------------------------------------------------\n# Parameter $zName must be a path to the file UnicodeData.txt. This command\n# reads the file and returns a list of codepoints (integers). The list\n# contains all codepoints in the UnicodeData.txt assigned to any \"General\n# Category\" that is not a \"Letter\" or \"Number\".\n#\nproc an_load_unicodedata_text {zName} {\n  set fd [open $zName]\n  set lField {\n    code\n    character_name\n    general_category\n    canonical_combining_classes\n    bidirectional_category\n    character_decomposition_mapping\n    decimal_digit_value\n    digit_value\n    numeric_value\n    mirrored\n    unicode_1_name\n    iso10646_comment_field\n    uppercase_mapping\n    lowercase_mapping\n    titlecase_mapping\n  }\n  set lRet [list]\n\n  while { ![eof $fd] } {\n    set line [gets $fd]\n    if {$line == \"\"} continue\n\n    set fields [split $line \";\"]\n    if {[llength $fields] != [llength $lField]} { error \"parse error: $line\" }\n    foreach $lField $fields {}\n\n    set iCode [expr \"0x$code\"]\n    set bAlnum [expr {\n         [lsearch {L N} [string range $general_category 0 0]] >= 0\n      || $general_category==\"Co\"\n    }]\n\n    if { !$bAlnum } { lappend lRet $iCode }\n  }\n\n  close $fd\n  set lRet\n}\n\nproc tl_load_casefolding_txt {zName} {\n  global tl_lookup_table\n\n  set fd [open $zName]\n  while { ![eof $fd] } {\n    set line [gets $fd]\n    if {[string range $line 0 0] == \"#\"} continue\n    if {$line == \"\"} continue\n\n    foreach x {a b c d} {unset -nocomplain $x}\n    foreach {a b c d} [split $line \";\"] {}\n\n    set a2 [list]\n    set c2 [list]\n    foreach elem $a { lappend a2 [expr \"0x[string trim $elem]\"] }\n    foreach elem $c { lappend c2 [expr \"0x[string trim $elem]\"] }\n    set b [string trim $b]\n    set d [string trim $d]\n\n    if {$b==\"C\" || $b==\"S\"} { set tl_lookup_table($a2) $c2 }\n  }\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/extract_api_docs.tcl",
    "content": "#\n# 2014 August 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#--------------------------------------------------------------------------\n#\n# This script extracts the documentation for the API used by fts5 auxiliary \n# functions from header file fts5.h. It outputs html text on stdout that\n# is included in the documentation on the web.\n# \n\nset ::fts5_docs_output \"\"\nif {[info commands hd_putsnl]==\"\"} {\n  if {[llength $argv]>0} { set ::extract_api_docs_mode [lindex $argv 0] }\n  proc output {text} {\n    puts $text\n  }\n} else {\n  proc output {text} {\n    append ::fts5_docs_output \"$text\\n\"\n  }\n}\nif {[info exists ::extract_api_docs_mode]==0} {set ::extract_api_docs_mode api}\n\n\nset input_file [file join [file dir [info script]] fts5.h]\nset fd [open $input_file]\nset data [read $fd]\nclose $fd\n\n\n# Argument $data is the entire text of the fts5.h file. This function \n# extracts the definition of the Fts5ExtensionApi structure from it and\n# returns a key/value list of structure member names and definitions. i.e.\n#\n#   iVersion {int iVersion} xUserData {void *(*xUserData)(Fts5Context*)} ...\n#\nproc get_struct_members {data} {\n\n  # Extract the structure definition from the fts5.h file.\n  regexp \"struct Fts5ExtensionApi {(.*?)};\" $data -> defn\n\n  # Remove all comments from the structure definition\n  regsub -all {/[*].*?[*]/} $defn {} defn2\n\n  set res [list]\n  foreach member [split $defn2 {;}] {\n\n    set member [string trim $member]\n    if {$member!=\"\"} { \n      catch { set name [lindex $member end] }\n      regexp {.*?[(][*]([^)]*)[)]} $member -> name\n      lappend res $name $member\n    }\n  }\n\n  set res\n}\n\nproc get_struct_docs {data names} {\n  # Extract the structure definition from the fts5.h file.\n  regexp {EXTENSION API FUNCTIONS(.*?)[*]/} $data -> docs\n\n  set current_doc    \"\"\n  set current_header \"\"\n\n  foreach line [split $docs \"\\n\"] {\n    regsub {[*]*} $line {} line\n    if {[regexp {^  } $line]} {\n      append current_doc \"$line\\n\"\n    } elseif {[string trim $line]==\"\"} {\n      if {$current_header!=\"\"} { append current_doc \"\\n\" }\n    } else {\n      if {$current_doc != \"\"} {\n        lappend res $current_header $current_doc\n        set current_doc \"\"\n      }\n      set subject n/a\n      regexp {^ *([[:alpha:]]*)} $line -> subject\n      if {[lsearch $names $subject]>=0} {\n        set current_header $subject\n      } else {\n        set current_header [string trim $line]\n      }\n    }\n  }\n\n  if {$current_doc != \"\"} {\n    lappend res $current_header $current_doc\n  }\n\n  set res\n}\n\nproc get_tokenizer_docs {data} {\n  regexp {(xCreate:.*?)[*]/} $data -> docs\n\n  set res \"<dl>\\n\"\n  foreach line [split [string trim $docs] \"\\n\"] {\n    regexp {[*][*](.*)} $line -> line\n    if {[regexp {^ ?x.*:} $line]} {\n      append res \"<dt><b>$line</b></dt><dd><p style=margin-top:0>\\n\"\n      continue\n    }\n    if {[regexp {SYNONYM SUPPORT} $line]} {\n      set line \"</dl><h3>Synonym Support</h3>\"\n    }\n    if {[string trim $line] == \"\"} {\n      append res \"<p>\\n\"\n    } else {\n      append res \"$line\\n\"\n    }\n  }\n\n  set res\n}\n\nproc get_api_docs {data} {\n  # Initialize global array M as a map from Fts5StructureApi member name\n  # to member definition. i.e.\n  #\n  #   iVersion  -> {int iVersion}\n  #   xUserData -> {void *(*xUserData)(Fts5Context*)}\n  #   ...\n  #\n  array set M [get_struct_members $data]\n  \n  # Initialize global list D as a map from section name to documentation\n  # text. Most (all?) section names are structure member names.\n  #\n  set D [get_struct_docs $data [array names M]]\n  \n  output \"<dl>\"\n  foreach {sub docs} $D {\n    if {[info exists M($sub)]} {\n      set hdr $M($sub)\n      set link \" id=$sub\"\n    } else {\n      set link \"\"\n    }\n\n    #output \"<hr color=#eeeee style=\\\"margin:1em 8.4ex 0 8.4ex;\\\"$link>\"\n    #set style \"padding-left:6ex;font-size:1.4em;display:block\"\n    #output \"<h style=\\\"$style\\\"><pre>$hdr</pre></h>\"\n\n    regsub -line {^  *[)]} $hdr \")\" hdr\n    output \"<dt style=\\\"white-space:pre;font-family:monospace;font-size:120%\\\"\"\n    output \"$link>\"\n    output \"<b>$hdr</b></dt><dd>\"\n  \n    set mode \"\"\n    set margin \" style=margin-top:0.1em\"\n    foreach line [split [string trim $docs] \"\\n\"] {\n      if {[string trim $line]==\"\"} {\n        if {$mode != \"\"} {output \"</$mode>\"}\n        set mode \"\"\n      } elseif {$mode == \"\"} {\n        if {[regexp {^     } $line]} {\n          set mode codeblock\n        } else {\n          set mode p\n        }\n        output \"<$mode$margin>\"\n        set margin \"\"\n      }\n      output $line\n    }\n    if {$mode != \"\"} {output \"</$mode>\"}\n    output \"</dd>\"\n  }\n  output \"</dl>\"\n}\n\nproc get_fts5_struct {data start end} {\n  set res \"\"\n  set bOut 0\n  foreach line [split $data \"\\n\"] {\n    if {$bOut==0} {\n      if {[regexp $start $line]} {\n        set bOut 1\n      }\n    }\n\n    if {$bOut} {\n      append res \"$line\\n\"\n    }\n\n    if {$bOut} {\n      if {[regexp $end $line]} {\n        set bOut 0\n      }\n    }\n  }\n\n  set map [list /* <i>/* */ */</i>]\n  string map $map $res\n}\n\nproc main {data} {\n  switch $::extract_api_docs_mode {\n    fts5_api {\n      output [get_fts5_struct $data \"typedef struct fts5_api\" \"^\\};\"]\n    }\n\n    fts5_tokenizer {\n      output [get_fts5_struct $data \"typedef struct Fts5Tokenizer\" \"^\\};\"]\n      output [get_fts5_struct $data \\\n        \"Flags that may be passed as the third argument to xTokenize()\" \\\n        \"#define FTS5_TOKEN_COLOCATED\"\n      ]\n    }\n\n    fts5_extension {\n      output [get_fts5_struct $data \"typedef.*Fts5ExtensionApi\" \"^.;\"]\n    }\n\n    Fts5ExtensionApi {\n      set struct [get_fts5_struct $data \"^struct Fts5ExtensionApi\" \"^.;\"]\n      set map [list]\n      foreach {k v} [get_struct_members $data] {\n        if {[string match x* $k]==0} continue\n        lappend map $k \"<a href=#$k>$k</a>\"\n      }\n      output [string map $map $struct]\n    }\n\n    api {\n      get_api_docs $data\n    }\n\n    tokenizer_api {\n      output [get_tokenizer_docs $data]\n    }\n\n    default {\n    }\n  }\n}\nmain $data\n\nset ::fts5_docs_output\n\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5.h",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. The exception is if the table was created\n**   with the offsets=0 option specified. In this case *piOff is always\n**   set to -1.\n**\n**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) \n**   if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            In this case, when tokenizing query text, the tokenizer may \n**            provide multiple synonyms for a single term within the document.\n**            FTS5 then queries the index for each synonym individually. For\n**            example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entires in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is subsituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5Int.h",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTS5INT_H\n#define _FTS5INT_H\n\n#include \"fts5.h\"\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n#include <string.h>\n#include <assert.h>\n\n#ifndef SQLITE_AMALGAMATION\n\ntypedef unsigned char  u8;\ntypedef unsigned int   u32;\ntypedef unsigned short u16;\ntypedef short i16;\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\n\n#ifndef ArraySize\n# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))\n#endif\n\n#define testcase(x)\n#define ALWAYS(x) 1\n#define NEVER(x) 0\n\n#define MIN(x,y) (((x) < (y)) ? (x) : (y))\n#define MAX(x,y) (((x) > (y)) ? (x) : (y))\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n*/\n# define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n#endif\n\n/* Truncate very long tokens to this many bytes. Hard limit is \n** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset\n** field that occurs at the start of each leaf page (see fts5_index.c). */\n#define FTS5_MAX_TOKEN_SIZE 32768\n\n/*\n** Maximum number of prefix indexes on single FTS5 table. This must be\n** less than 32. If it is set to anything large than that, an #error\n** directive in fts5_index.c will cause the build to fail.\n*/\n#define FTS5_MAX_PREFIX_INDEXES 31\n\n#define FTS5_DEFAULT_NEARDIST 10\n#define FTS5_DEFAULT_RANK     \"bm25\"\n\n/* Name of rank and rowid columns */\n#define FTS5_RANK_NAME \"rank\"\n#define FTS5_ROWID_NAME \"rowid\"\n\n#ifdef SQLITE_DEBUG\n# define FTS5_CORRUPT sqlite3Fts5Corrupt()\nint sqlite3Fts5Corrupt(void);\n#else\n# define FTS5_CORRUPT SQLITE_CORRUPT_VTAB\n#endif\n\n/*\n** The assert_nc() macro is similar to the assert() macro, except that it\n** is used for assert() conditions that are true only if it can be \n** guranteed that the database is not corrupt.\n*/\n#ifdef SQLITE_DEBUG\nextern int sqlite3_fts5_may_be_corrupt;\n# define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))\n#else\n# define assert_nc(x) assert(x)\n#endif\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef UNUSED_PARAM2\n# define UNUSED_PARAM2(X, Y)  (void)(X), (void)(Y)\n#endif\n\ntypedef struct Fts5Global Fts5Global;\ntypedef struct Fts5Colset Fts5Colset;\n\n/* If a NEAR() clump or phrase may only match a specific set of columns, \n** then an object of the following type is used to record the set of columns.\n** Each entry in the aiCol[] array is a column that may be matched.\n**\n** This object is used by fts5_expr.c and fts5_index.c.\n*/\nstruct Fts5Colset {\n  int nCol;\n  int aiCol[1];\n};\n\n\n\n/**************************************************************************\n** Interface to code in fts5_config.c. fts5_config.c contains contains code\n** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.\n*/\n\ntypedef struct Fts5Config Fts5Config;\n\n/*\n** An instance of the following structure encodes all information that can\n** be gleaned from the CREATE VIRTUAL TABLE statement.\n**\n** And all information loaded from the %_config table.\n**\n** nAutomerge:\n**   The minimum number of segments that an auto-merge operation should\n**   attempt to merge together. A value of 1 sets the object to use the \n**   compile time default. Zero disables auto-merge altogether.\n**\n** zContent:\n**\n** zContentRowid:\n**   The value of the content_rowid= option, if one was specified. Or \n**   the string \"rowid\" otherwise. This text is not quoted - if it is\n**   used as part of an SQL statement it needs to be quoted appropriately.\n**\n** zContentExprlist:\n**\n** pzErrmsg:\n**   This exists in order to allow the fts5_index.c module to return a \n**   decent error message if it encounters a file-format version it does\n**   not understand.\n**\n** bColumnsize:\n**   True if the %_docsize table is created.\n**\n** bPrefixIndex:\n**   This is only used for debugging. If set to false, any prefix indexes\n**   are ignored. This value is configured using:\n**\n**       INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex);\n**\n*/\nstruct Fts5Config {\n  sqlite3 *db;                    /* Database handle */\n  char *zDb;                      /* Database holding FTS index (e.g. \"main\") */\n  char *zName;                    /* Name of FTS index */\n  int nCol;                       /* Number of columns */\n  char **azCol;                   /* Column names */\n  u8 *abUnindexed;                /* True for unindexed columns */\n  int nPrefix;                    /* Number of prefix indexes */\n  int *aPrefix;                   /* Sizes in bytes of nPrefix prefix indexes */\n  int eContent;                   /* An FTS5_CONTENT value */\n  char *zContent;                 /* content table */ \n  char *zContentRowid;            /* \"content_rowid=\" option value */ \n  int bColumnsize;                /* \"columnsize=\" option value (dflt==1) */\n  int eDetail;                    /* FTS5_DETAIL_XXX value */\n  char *zContentExprlist;\n  Fts5Tokenizer *pTok;\n  fts5_tokenizer *pTokApi;\n\n  /* Values loaded from the %_config table */\n  int iCookie;                    /* Incremented when %_config is modified */\n  int pgsz;                       /* Approximate page size used in %_data */\n  int nAutomerge;                 /* 'automerge' setting */\n  int nCrisisMerge;               /* Maximum allowed segments per level */\n  int nUsermerge;                 /* 'usermerge' setting */\n  int nHashSize;                  /* Bytes of memory for in-memory hash */\n  char *zRank;                    /* Name of rank function */\n  char *zRankArgs;                /* Arguments to rank function */\n\n  /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */\n  char **pzErrmsg;\n\n#ifdef SQLITE_DEBUG\n  int bPrefixIndex;               /* True to use prefix-indexes */\n#endif\n};\n\n/* Current expected value of %_config table 'version' field */\n#define FTS5_CURRENT_VERSION 4\n\n#define FTS5_CONTENT_NORMAL   0\n#define FTS5_CONTENT_NONE     1\n#define FTS5_CONTENT_EXTERNAL 2\n\n#define FTS5_DETAIL_FULL    0\n#define FTS5_DETAIL_NONE    1\n#define FTS5_DETAIL_COLUMNS 2\n\n\n\nint sqlite3Fts5ConfigParse(\n    Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char**\n);\nvoid sqlite3Fts5ConfigFree(Fts5Config*);\n\nint sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig);\n\nint sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n);\n\nvoid sqlite3Fts5Dequote(char *z);\n\n/* Load the contents of the %_config table */\nint sqlite3Fts5ConfigLoad(Fts5Config*, int);\n\n/* Set the value of a single config attribute */\nint sqlite3Fts5ConfigSetValue(Fts5Config*, const char*, sqlite3_value*, int*);\n\nint sqlite3Fts5ConfigParseRank(const char*, char**, char**);\n\n/*\n** End of interface to code in fts5_config.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_buffer.c.\n*/\n\n/*\n** Buffer object for the incremental building of string data.\n*/\ntypedef struct Fts5Buffer Fts5Buffer;\nstruct Fts5Buffer {\n  u8 *p;\n  int n;\n  int nSpace;\n};\n\nint sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32);\nvoid sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64);\nvoid sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*);\nvoid sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*);\nvoid sqlite3Fts5BufferFree(Fts5Buffer*);\nvoid sqlite3Fts5BufferZero(Fts5Buffer*);\nvoid sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*);\nvoid sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...);\n\nchar *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...);\n\n#define fts5BufferZero(x)             sqlite3Fts5BufferZero(x)\n#define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c)\n#define fts5BufferFree(a)             sqlite3Fts5BufferFree(a)\n#define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d)\n#define fts5BufferSet(a,b,c,d)        sqlite3Fts5BufferSet(a,b,c,d)\n\n#define fts5BufferGrow(pRc,pBuf,nn) ( \\\n  (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \\\n    sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \\\n)\n\n/* Write and decode big-endian 32-bit integer values */\nvoid sqlite3Fts5Put32(u8*, int);\nint sqlite3Fts5Get32(const u8*);\n\n#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)\n#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)\n\ntypedef struct Fts5PoslistReader Fts5PoslistReader;\nstruct Fts5PoslistReader {\n  /* Variables used only by sqlite3Fts5PoslistIterXXX() functions. */\n  const u8 *a;                    /* Position list to iterate through */\n  int n;                          /* Size of buffer at a[] in bytes */\n  int i;                          /* Current offset in a[] */\n\n  u8 bFlag;                       /* For client use (any custom purpose) */\n\n  /* Output variables */\n  u8 bEof;                        /* Set to true at EOF */\n  i64 iPos;                       /* (iCol<<32) + iPos */\n};\nint sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n);\nint sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*);\n\ntypedef struct Fts5PoslistWriter Fts5PoslistWriter;\nstruct Fts5PoslistWriter {\n  i64 iPrev;\n};\nint sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64);\nvoid sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64);\n\nint sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n);\n\n/* Malloc utility */\nvoid *sqlite3Fts5MallocZero(int *pRc, int nByte);\nchar *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);\n\n/* Character set tests (like isspace(), isalpha() etc.) */\nint sqlite3Fts5IsBareword(char t);\n\n\n/* Bucket of terms object used by the integrity-check in offsets=0 mode. */\ntypedef struct Fts5Termset Fts5Termset;\nint sqlite3Fts5TermsetNew(Fts5Termset**);\nint sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent);\nvoid sqlite3Fts5TermsetFree(Fts5Termset*);\n\n/*\n** End of interface to code in fts5_buffer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_index.c. fts5_index.c contains contains code\n** to access the data stored in the %_data table.\n*/\n\ntypedef struct Fts5Index Fts5Index;\ntypedef struct Fts5IndexIter Fts5IndexIter;\n\nstruct Fts5IndexIter {\n  i64 iRowid;\n  const u8 *pData;\n  int nData;\n  u8 bEof;\n};\n\n#define sqlite3Fts5IterEof(x) ((x)->bEof)\n\n/*\n** Values used as part of the flags argument passed to IndexQuery().\n*/\n#define FTS5INDEX_QUERY_PREFIX     0x0001   /* Prefix query */\n#define FTS5INDEX_QUERY_DESC       0x0002   /* Docs in descending rowid order */\n#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004   /* Do not use prefix index */\n#define FTS5INDEX_QUERY_SCAN       0x0008   /* Scan query (fts5vocab) */\n\n/* The following are used internally by the fts5_index.c module. They are\n** defined here only to make it easier to avoid clashes with the flags\n** above. */\n#define FTS5INDEX_QUERY_SKIPEMPTY  0x0010\n#define FTS5INDEX_QUERY_NOOUTPUT   0x0020\n\n/*\n** Create/destroy an Fts5Index object.\n*/\nint sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);\nint sqlite3Fts5IndexClose(Fts5Index *p);\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nu64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n);\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nint sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n);\n\n/*\n** Open a new iterator to iterate though all rowids that match the \n** specified token or token prefix.\n*/\nint sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n);\n\n/*\n** The various operations on open token or token prefix iterators opened\n** using sqlite3Fts5IndexQuery().\n*/\nint sqlite3Fts5IterNext(Fts5IndexIter*);\nint sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);\n\n/*\n** Close an iterator opened by sqlite3Fts5IndexQuery().\n*/\nvoid sqlite3Fts5IterClose(Fts5IndexIter*);\n\n/*\n** This interface is used by the fts5vocab module.\n*/\nconst char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);\nint sqlite3Fts5IterNextScan(Fts5IndexIter*);\n\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nint sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Indicate that subsequent calls to sqlite3Fts5IndexWrite() pertain to\n** document iDocid.\n*/\nint sqlite3Fts5IndexBeginWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int bDelete,                    /* True if current operation is a delete */\n  i64 iDocid                      /* Docid to add or remove data from */\n);\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n** Also close any open blob handles.\n*/\nint sqlite3Fts5IndexSync(Fts5Index *p);\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nint sqlite3Fts5IndexRollback(Fts5Index *p);\n\n/*\n** Get or set the \"averages\" values.\n*/\nint sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize);\nint sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);\n\n/*\n** Functions called by the storage module as part of integrity-check.\n*/\nint sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);\n\n/* \n** Called during virtual module initialization to register UDF \n** fts5_decode() with SQLite \n*/\nint sqlite3Fts5IndexInit(sqlite3*);\n\nint sqlite3Fts5IndexSetCookie(Fts5Index*, int);\n\n/*\n** Return the total number of entries read from the %_data table by \n** this connection since it was created.\n*/\nint sqlite3Fts5IndexReads(Fts5Index *p);\n\nint sqlite3Fts5IndexReinit(Fts5Index *p);\nint sqlite3Fts5IndexOptimize(Fts5Index *p);\nint sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge);\nint sqlite3Fts5IndexReset(Fts5Index *p);\n\nint sqlite3Fts5IndexLoadConfig(Fts5Index *p);\n\n/*\n** End of interface to code in fts5_index.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_varint.c. \n*/\nint sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v);\nint sqlite3Fts5GetVarintLen(u32 iVal);\nu8 sqlite3Fts5GetVarint(const unsigned char*, u64*);\nint sqlite3Fts5PutVarint(unsigned char *p, u64 v);\n\n#define fts5GetVarint32(a,b) sqlite3Fts5GetVarint32(a,(u32*)&b)\n#define fts5GetVarint    sqlite3Fts5GetVarint\n\n#define fts5FastGetVarint32(a, iOff, nVal) {      \\\n  nVal = (a)[iOff++];                             \\\n  if( nVal & 0x80 ){                              \\\n    iOff--;                                       \\\n    iOff += fts5GetVarint32(&(a)[iOff], nVal);    \\\n  }                                               \\\n}\n\n\n/*\n** End of interface to code in fts5_varint.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5.c. \n*/\n\nint sqlite3Fts5GetTokenizer(\n  Fts5Global*, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer**,\n  fts5_tokenizer**,\n  char **pzErr\n);\n\nFts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);\n\n/*\n** End of interface to code in fts5.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_hash.c. \n*/\ntypedef struct Fts5Hash Fts5Hash;\n\n/*\n** Create a hash table, free a hash table.\n*/\nint sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize);\nvoid sqlite3Fts5HashFree(Fts5Hash*);\n\nint sqlite3Fts5HashWrite(\n  Fts5Hash*,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nvoid sqlite3Fts5HashClear(Fts5Hash*);\n\nint sqlite3Fts5HashQuery(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n);\n\nint sqlite3Fts5HashScanInit(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n);\nvoid sqlite3Fts5HashScanNext(Fts5Hash*);\nint sqlite3Fts5HashScanEof(Fts5Hash*);\nvoid sqlite3Fts5HashScanEntry(Fts5Hash *,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n);\n\n\n/*\n** End of interface to code in fts5_hash.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_storage.c. fts5_storage.c contains contains \n** code to access the data stored in the %_content and %_docsize tables.\n*/\n\n#define FTS5_STMT_SCAN_ASC  0     /* SELECT rowid, * FROM ... ORDER BY 1 ASC */\n#define FTS5_STMT_SCAN_DESC 1     /* SELECT rowid, * FROM ... ORDER BY 1 DESC */\n#define FTS5_STMT_LOOKUP    2     /* SELECT rowid, * FROM ... WHERE rowid=? */\n\ntypedef struct Fts5Storage Fts5Storage;\n\nint sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**);\nint sqlite3Fts5StorageClose(Fts5Storage *p);\nint sqlite3Fts5StorageRename(Fts5Storage*, const char *zName);\n\nint sqlite3Fts5DropAll(Fts5Config*);\nint sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);\n\nint sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);\nint sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);\nint sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);\n\nint sqlite3Fts5StorageIntegrity(Fts5Storage *p);\n\nint sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);\nvoid sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);\n\nint sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);\nint sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg);\nint sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow);\n\nint sqlite3Fts5StorageSync(Fts5Storage *p);\nint sqlite3Fts5StorageRollback(Fts5Storage *p);\n\nint sqlite3Fts5StorageConfigValue(\n    Fts5Storage *p, const char*, sqlite3_value*, int\n);\n\nint sqlite3Fts5StorageDeleteAll(Fts5Storage *p);\nint sqlite3Fts5StorageRebuild(Fts5Storage *p);\nint sqlite3Fts5StorageOptimize(Fts5Storage *p);\nint sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge);\nint sqlite3Fts5StorageReset(Fts5Storage *p);\n\n/*\n** End of interface to code in fts5_storage.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5_expr.c. \n*/\ntypedef struct Fts5Expr Fts5Expr;\ntypedef struct Fts5ExprNode Fts5ExprNode;\ntypedef struct Fts5Parse Fts5Parse;\ntypedef struct Fts5Token Fts5Token;\ntypedef struct Fts5ExprPhrase Fts5ExprPhrase;\ntypedef struct Fts5ExprNearset Fts5ExprNearset;\n\nstruct Fts5Token {\n  const char *p;                  /* Token text (not NULL terminated) */\n  int n;                          /* Size of buffer p in bytes */\n};\n\n/* Parse a MATCH expression. */\nint sqlite3Fts5ExprNew(\n  Fts5Config *pConfig, \n  int iCol,                       /* Column on LHS of MATCH operator */\n  const char *zExpr,\n  Fts5Expr **ppNew, \n  char **pzErr\n);\n\n/*\n** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);\n**     rc==SQLITE_OK && 0==sqlite3Fts5ExprEof(pExpr);\n**     rc = sqlite3Fts5ExprNext(pExpr)\n** ){\n**   // The document with rowid iRowid matches the expression!\n**   i64 iRowid = sqlite3Fts5ExprRowid(pExpr);\n** }\n*/\nint sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);\nint sqlite3Fts5ExprNext(Fts5Expr*, i64 iMax);\nint sqlite3Fts5ExprEof(Fts5Expr*);\ni64 sqlite3Fts5ExprRowid(Fts5Expr*);\n\nvoid sqlite3Fts5ExprFree(Fts5Expr*);\n\n/* Called during startup to register a UDF with SQLite */\nint sqlite3Fts5ExprInit(Fts5Global*, sqlite3*);\n\nint sqlite3Fts5ExprPhraseCount(Fts5Expr*);\nint sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase);\nint sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **);\n\ntypedef struct Fts5PoslistPopulator Fts5PoslistPopulator;\nFts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);\nint sqlite3Fts5ExprPopulatePoslists(\n    Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int\n);\nvoid sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);\n\nint sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);\n\nint sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);\n\n/*******************************************\n** The fts5_expr.c API above this point is used by the other hand-written\n** C code in this module. The interfaces below this point are called by\n** the parser code in fts5parse.y.  */\n\nvoid sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...);\n\nFts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,\n  int eType,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight,\n  Fts5ExprNearset *pNear\n);\n\nFts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight\n);\n\nFts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse, \n  Fts5ExprPhrase *pPhrase, \n  Fts5Token *pToken,\n  int bPrefix\n);\n\nFts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse*, \n  Fts5ExprNearset*,\n  Fts5ExprPhrase* \n);\n\nFts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse*, \n  Fts5Colset*, \n  Fts5Token *\n);\n\nvoid sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*);\nvoid sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*);\nvoid sqlite3Fts5ParseNodeFree(Fts5ExprNode*);\n\nvoid sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*);\nvoid sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNode*, Fts5Colset*);\nFts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*);\nvoid sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p);\nvoid sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*);\n\n/*\n** End of interface to code in fts5_expr.c.\n**************************************************************************/\n\n\n\n/**************************************************************************\n** Interface to code in fts5_aux.c. \n*/\n\nint sqlite3Fts5AuxInit(fts5_api*);\n/*\n** End of interface to code in fts5_aux.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_tokenizer.c. \n*/\n\nint sqlite3Fts5TokenizerInit(fts5_api*);\n/*\n** End of interface to code in fts5_tokenizer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_vocab.c. \n*/\n\nint sqlite3Fts5VocabInit(Fts5Global*, sqlite3*);\n\n/*\n** End of interface to code in fts5_vocab.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to automatically generated code in fts5_unicode2.c. \n*/\nint sqlite3Fts5UnicodeIsalnum(int c);\nint sqlite3Fts5UnicodeIsdiacritic(int c);\nint sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);\n/*\n** End of interface to code in fts5_unicode2.c.\n**************************************************************************/\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_aux.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n#include \"fts5Int.h\"\n#include <math.h>                 /* amalgamator: keep */\n\n/*\n** Object used to iterate through all \"coalesced phrase instances\" in \n** a single column of the current row. If the phrase instances in the\n** column being considered do not overlap, this object simply iterates\n** through them. Or, if they do overlap (share one or more tokens in\n** common), each set of overlapping instances is treated as a single\n** match. See documentation for the highlight() auxiliary function for\n** details.\n**\n** Usage is:\n**\n**   for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);\n**      (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);\n**      rc = fts5CInstIterNext(&iter)\n**   ){\n**     printf(\"instance starts at %d, ends at %d\\n\", iter.iStart, iter.iEnd);\n**   }\n**\n*/\ntypedef struct CInstIter CInstIter;\nstruct CInstIter {\n  const Fts5ExtensionApi *pApi;   /* API offered by current FTS version */\n  Fts5Context *pFts;              /* First arg to pass to pApi functions */\n  int iCol;                       /* Column to search */\n  int iInst;                      /* Next phrase instance index */\n  int nInst;                      /* Total number of phrase instances */\n\n  /* Output variables */\n  int iStart;                     /* First token in coalesced phrase instance */\n  int iEnd;                       /* Last token in coalesced phrase instance */\n};\n\n/*\n** Advance the iterator to the next coalesced phrase instance. Return\n** an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int fts5CInstIterNext(CInstIter *pIter){\n  int rc = SQLITE_OK;\n  pIter->iStart = -1;\n  pIter->iEnd = -1;\n\n  while( rc==SQLITE_OK && pIter->iInst<pIter->nInst ){\n    int ip; int ic; int io;\n    rc = pIter->pApi->xInst(pIter->pFts, pIter->iInst, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      if( ic==pIter->iCol ){\n        int iEnd = io - 1 + pIter->pApi->xPhraseSize(pIter->pFts, ip);\n        if( pIter->iStart<0 ){\n          pIter->iStart = io;\n          pIter->iEnd = iEnd;\n        }else if( io<=pIter->iEnd ){\n          if( iEnd>pIter->iEnd ) pIter->iEnd = iEnd;\n        }else{\n          break;\n        }\n      }\n      pIter->iInst++;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Initialize the iterator object indicated by the final parameter to \n** iterate through coalesced phrase instances in column iCol.\n*/\nstatic int fts5CInstIterInit(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  int iCol,\n  CInstIter *pIter\n){\n  int rc;\n\n  memset(pIter, 0, sizeof(CInstIter));\n  pIter->pApi = pApi;\n  pIter->pFts = pFts;\n  pIter->iCol = iCol;\n  rc = pApi->xInstCount(pFts, &pIter->nInst);\n\n  if( rc==SQLITE_OK ){\n    rc = fts5CInstIterNext(pIter);\n  }\n\n  return rc;\n}\n\n\n\n/*************************************************************************\n** Start of highlight() implementation.\n*/\ntypedef struct HighlightContext HighlightContext;\nstruct HighlightContext {\n  CInstIter iter;                 /* Coalesced Instance Iterator */\n  int iPos;                       /* Current token offset in zIn[] */\n  int iRangeStart;                /* First token to include */\n  int iRangeEnd;                  /* If non-zero, last token to include */\n  const char *zOpen;              /* Opening highlight */\n  const char *zClose;             /* Closing highlight */\n  const char *zIn;                /* Input text */\n  int nIn;                        /* Size of input text in bytes */\n  int iOff;                       /* Current offset within zIn[] */\n  char *zOut;                     /* Output value */\n};\n\n/*\n** Append text to the HighlightContext output string - p->zOut. Argument\n** z points to a buffer containing n bytes of text to append. If n is \n** negative, everything up until the first '\\0' is appended to the output.\n**\n** If *pRc is set to any value other than SQLITE_OK when this function is \n** called, it is a no-op. If an error (i.e. an OOM condition) is encountered, \n** *pRc is set to an error code before returning. \n*/\nstatic void fts5HighlightAppend(\n  int *pRc, \n  HighlightContext *p, \n  const char *z, int n\n){\n  if( *pRc==SQLITE_OK ){\n    if( n<0 ) n = (int)strlen(z);\n    p->zOut = sqlite3_mprintf(\"%z%.*s\", p->zOut, n, z);\n    if( p->zOut==0 ) *pRc = SQLITE_NOMEM;\n  }\n}\n\n/*\n** Tokenizer callback used by implementation of highlight() function.\n*/\nstatic int fts5HighlightCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  HighlightContext *p = (HighlightContext*)pContext;\n  int rc = SQLITE_OK;\n  int iPos;\n\n  UNUSED_PARAM2(pToken, nToken);\n\n  if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;\n  iPos = p->iPos++;\n\n  if( p->iRangeEnd>0 ){\n    if( iPos<p->iRangeStart || iPos>p->iRangeEnd ) return SQLITE_OK;\n    if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iStart ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iEnd ){\n    if( p->iRangeEnd && p->iter.iStart<p->iRangeStart ){\n      fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    }\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zClose, -1);\n    p->iOff = iEndOff;\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&p->iter);\n    }\n  }\n\n  if( p->iRangeEnd>0 && iPos==p->iRangeEnd ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    p->iOff = iEndOff;\n    if( iPos>=p->iter.iStart && iPos<p->iter.iEnd ){\n      fts5HighlightAppend(&rc, p, p->zClose, -1);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of highlight() function.\n*/\nstatic void fts5HighlightFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc;\n  int iCol;\n\n  if( nVal!=3 ){\n    const char *zErr = \"wrong number of arguments to function highlight()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  iCol = sqlite3_value_int(apVal[0]);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);\n  ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);\n  rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn);\n\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n\n    if( rc==SQLITE_OK ){\n      sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n    }\n    sqlite3_free(ctx.zOut);\n  }\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n/*\n** End of highlight() implementation.\n**************************************************************************/\n\n/*\n** Context object passed to the fts5SentenceFinderCb() function.\n*/\ntypedef struct Fts5SFinder Fts5SFinder;\nstruct Fts5SFinder {\n  int iPos;                       /* Current token position */\n  int nFirstAlloc;                /* Allocated size of aFirst[] */\n  int nFirst;                     /* Number of entries in aFirst[] */\n  int *aFirst;                    /* Array of first token in each sentence */\n  const char *zDoc;               /* Document being tokenized */\n};\n\n/*\n** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if\n** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an\n** error occurs.\n*/\nstatic int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){\n  if( p->nFirstAlloc==p->nFirst ){\n    int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;\n    int *aNew;\n\n    aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    p->aFirst = aNew;\n    p->nFirstAlloc = nNew;\n  }\n  p->aFirst[p->nFirst++] = iAdd;\n  return SQLITE_OK;\n}\n\n/*\n** This function is an xTokenize() callback used by the auxiliary snippet()\n** function. Its job is to identify tokens that are the first in a sentence.\n** For each such token, an entry is added to the SFinder.aFirst[] array.\n*/\nstatic int fts5SentenceFinderCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  int rc = SQLITE_OK;\n\n  UNUSED_PARAM2(pToken, nToken);\n  UNUSED_PARAM(iEndOff);\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    Fts5SFinder *p = (Fts5SFinder*)pContext;\n    if( p->iPos>0 ){\n      int i;\n      char c = 0;\n      for(i=iStartOff-1; i>=0; i--){\n        c = p->zDoc[i];\n        if( c!=' ' && c!='\\t' && c!='\\n' && c!='\\r' ) break;\n      }\n      if( i!=iStartOff-1 && (c=='.' || c==':') ){\n        rc = fts5SentenceFinderAdd(p, p->iPos);\n      }\n    }else{\n      rc = fts5SentenceFinderAdd(p, 0);\n    }\n    p->iPos++;\n  }\n  return rc;\n}\n\nstatic int fts5SnippetScore(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  int nDocsize,                   /* Size of column in tokens */\n  unsigned char *aSeen,           /* Array with one element per query phrase */\n  int iCol,                       /* Column to score */\n  int iPos,                       /* Starting offset to score */\n  int nToken,                     /* Max tokens per snippet */\n  int *pnScore,                   /* OUT: Score */\n  int *piPos                      /* OUT: Adjusted offset */\n){\n  int rc;\n  int i;\n  int ip = 0;\n  int ic = 0;\n  int iOff = 0;\n  int iFirst = -1;\n  int nInst;\n  int nScore = 0;\n  int iLast = 0;\n\n  rc = pApi->xInstCount(pFts, &nInst);\n  for(i=0; i<nInst && rc==SQLITE_OK; i++){\n    rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);\n    if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){\n      nScore += (aSeen[ip] ? 1 : 1000);\n      aSeen[ip] = 1;\n      if( iFirst<0 ) iFirst = iOff;\n      iLast = iOff + pApi->xPhraseSize(pFts, ip);\n    }\n  }\n\n  *pnScore = nScore;\n  if( piPos ){\n    int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;\n    if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;\n    if( iAdj<0 ) iAdj = 0;\n    *piPos = iAdj;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of snippet() function.\n*/\nstatic void fts5SnippetFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc = SQLITE_OK;             /* Return code */\n  int iCol;                       /* 1st argument to snippet() */\n  const char *zEllips;            /* 4th argument to snippet() */\n  int nToken;                     /* 5th argument to snippet() */\n  int nInst = 0;                  /* Number of instance matches this row */\n  int i;                          /* Used to iterate through instances */\n  int nPhrase;                    /* Number of phrases in query */\n  unsigned char *aSeen;           /* Array of \"seen instance\" flags */\n  int iBestCol;                   /* Column containing best snippet */\n  int iBestStart = 0;             /* First token of best snippet */\n  int nBestScore = 0;             /* Score of best snippet */\n  int nColSize = 0;               /* Total size of iBestCol in tokens */\n  Fts5SFinder sFinder;            /* Used to find the beginnings of sentences */\n  int nCol;\n\n  if( nVal!=5 ){\n    const char *zErr = \"wrong number of arguments to function snippet()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  nCol = pApi->xColumnCount(pFts);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  iCol = sqlite3_value_int(apVal[0]);\n  ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);\n  ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);\n  zEllips = (const char*)sqlite3_value_text(apVal[3]);\n  nToken = sqlite3_value_int(apVal[4]);\n\n  iBestCol = (iCol>=0 ? iCol : 0);\n  nPhrase = pApi->xPhraseCount(pFts);\n  aSeen = sqlite3_malloc(nPhrase);\n  if( aSeen==0 ){\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n\n  memset(&sFinder, 0, sizeof(Fts5SFinder));\n  for(i=0; i<nCol; i++){\n    if( iCol<0 || iCol==i ){\n      int nDoc;\n      int nDocsize;\n      int ii;\n      sFinder.iPos = 0;\n      sFinder.nFirst = 0;\n      rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xTokenize(pFts, \n          sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb\n      );\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xColumnSize(pFts, i, &nDocsize);\n      if( rc!=SQLITE_OK ) break;\n\n      for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){\n        int ip, ic, io;\n        int iAdj;\n        int nScore;\n        int jj;\n\n        rc = pApi->xInst(pFts, ii, &ip, &ic, &io);\n        if( ic!=i || rc!=SQLITE_OK ) continue;\n        memset(aSeen, 0, nPhrase);\n        rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,\n            io, nToken, &nScore, &iAdj\n        );\n        if( rc==SQLITE_OK && nScore>nBestScore ){\n          nBestScore = nScore;\n          iBestCol = i;\n          iBestStart = iAdj;\n          nColSize = nDocsize;\n        }\n\n        if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){\n          for(jj=0; jj<(sFinder.nFirst-1); jj++){\n            if( sFinder.aFirst[jj+1]>io ) break;\n          }\n\n          if( sFinder.aFirst[jj]<io ){\n            memset(aSeen, 0, nPhrase);\n            rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i, \n              sFinder.aFirst[jj], nToken, &nScore, 0\n            );\n\n            nScore += (sFinder.aFirst[jj]==0 ? 120 : 100);\n            if( rc==SQLITE_OK && nScore>nBestScore ){\n              nBestScore = nScore;\n              iBestCol = i;\n              iBestStart = sFinder.aFirst[jj];\n              nColSize = nDocsize;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);\n  }\n  if( rc==SQLITE_OK && nColSize==0 ){\n    rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);\n  }\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);\n    }\n\n    ctx.iRangeStart = iBestStart;\n    ctx.iRangeEnd = iBestStart + nToken - 1;\n\n    if( iBestStart>0 ){\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n\n    /* Advance iterator ctx.iter so that it points to the first coalesced\n    ** phrase instance at or following position iBestStart. */\n    while( ctx.iter.iStart>=0 && ctx.iter.iStart<iBestStart && rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    if( ctx.iRangeEnd>=(nColSize-1) ){\n      fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n    }else{\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  sqlite3_free(ctx.zOut);\n  sqlite3_free(aSeen);\n  sqlite3_free(sFinder.aFirst);\n}\n\n/************************************************************************/\n\n/*\n** The first time the bm25() function is called for a query, an instance\n** of the following structure is allocated and populated.\n*/\ntypedef struct Fts5Bm25Data Fts5Bm25Data;\nstruct Fts5Bm25Data {\n  int nPhrase;                    /* Number of phrases in query */\n  double avgdl;                   /* Average number of tokens in each row */\n  double *aIDF;                   /* IDF for each phrase */\n  double *aFreq;                  /* Array used to calculate phrase freq. */\n};\n\n/*\n** Callback used by fts5Bm25GetData() to count the number of rows in the\n** table matched by each individual phrase within the query.\n*/\nstatic int fts5CountCb(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  void *pUserData                 /* Pointer to sqlite3_int64 variable */\n){\n  sqlite3_int64 *pn = (sqlite3_int64*)pUserData;\n  UNUSED_PARAM2(pApi, pFts);\n  (*pn)++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppData to point to the Fts5Bm25Data object for the current query. \n** If the object has not already been allocated, allocate and populate it\n** now.\n*/\nstatic int fts5Bm25GetData(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  Fts5Bm25Data **ppData           /* OUT: bm25-data object for this query */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Bm25Data *p;                /* Object to return */\n\n  p = pApi->xGetAuxdata(pFts, 0);\n  if( p==0 ){\n    int nPhrase;                  /* Number of phrases in query */\n    sqlite3_int64 nRow = 0;       /* Number of rows in table */\n    sqlite3_int64 nToken = 0;     /* Number of tokens in table */\n    int nByte;                    /* Bytes of space to allocate */\n    int i;\n\n    /* Allocate the Fts5Bm25Data object */\n    nPhrase = pApi->xPhraseCount(pFts);\n    nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);\n    p = (Fts5Bm25Data*)sqlite3_malloc(nByte);\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(p, 0, nByte);\n      p->nPhrase = nPhrase;\n      p->aIDF = (double*)&p[1];\n      p->aFreq = &p->aIDF[nPhrase];\n    }\n\n    /* Calculate the average document length for this FTS5 table */\n    if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);\n    if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);\n    if( rc==SQLITE_OK ) p->avgdl = (double)nToken  / (double)nRow;\n\n    /* Calculate an IDF for each phrase in the query */\n    for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n      sqlite3_int64 nHit = 0;\n      rc = pApi->xQueryPhrase(pFts, i, (void*)&nHit, fts5CountCb);\n      if( rc==SQLITE_OK ){\n        /* Calculate the IDF (Inverse Document Frequency) for phrase i.\n        ** This is done using the standard BM25 formula as found on wikipedia:\n        **\n        **   IDF = log( (N - nHit + 0.5) / (nHit + 0.5) )\n        **\n        ** where \"N\" is the total number of documents in the set and nHit\n        ** is the number that contain at least one instance of the phrase\n        ** under consideration.\n        **\n        ** The problem with this is that if (N < 2*nHit), the IDF is \n        ** negative. Which is undesirable. So the mimimum allowable IDF is\n        ** (1e-6) - roughly the same as a term that appears in just over\n        ** half of set of 5,000,000 documents.  */\n        double idf = log( (nRow - nHit + 0.5) / (nHit + 0.5) );\n        if( idf<=0.0 ) idf = 1e-6;\n        p->aIDF[i] = idf;\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(p);\n    }else{\n      rc = pApi->xSetAuxdata(pFts, p, sqlite3_free);\n    }\n    if( rc!=SQLITE_OK ) p = 0;\n  }\n  *ppData = p;\n  return rc;\n}\n\n/*\n** Implementation of bm25() function.\n*/\nstatic void fts5Bm25Function(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  const double k1 = 1.2;          /* Constant \"k1\" from BM25 formula */\n  const double b = 0.75;          /* Constant \"b\" from BM25 formula */\n  int rc = SQLITE_OK;             /* Error code */\n  double score = 0.0;             /* SQL function return value */\n  Fts5Bm25Data *pData;            /* Values allocated/calculated once only */\n  int i;                          /* Iterator variable */\n  int nInst = 0;                  /* Value returned by xInstCount() */\n  double D = 0.0;                 /* Total number of tokens in row */\n  double *aFreq = 0;              /* Array of phrase freq. for current row */\n\n  /* Calculate the phrase frequency (symbol \"f(qi,D)\" in the documentation)\n  ** for each phrase in the query for the current row. */\n  rc = fts5Bm25GetData(pApi, pFts, &pData);\n  if( rc==SQLITE_OK ){\n    aFreq = pData->aFreq;\n    memset(aFreq, 0, sizeof(double) * pData->nPhrase);\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n  for(i=0; rc==SQLITE_OK && i<nInst; i++){\n    int ip; int ic; int io;\n    rc = pApi->xInst(pFts, i, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      double w = (nVal > ic) ? sqlite3_value_double(apVal[ic]) : 1.0;\n      aFreq[ip] += w;\n    }\n  }\n\n  /* Figure out the total size of the current row in tokens. */\n  if( rc==SQLITE_OK ){\n    int nTok;\n    rc = pApi->xColumnSize(pFts, -1, &nTok);\n    D = (double)nTok;\n  }\n\n  /* Determine the BM25 score for the current row. */\n  for(i=0; rc==SQLITE_OK && i<pData->nPhrase; i++){\n    score += pData->aIDF[i] * (\n      ( aFreq[i] * (k1 + 1.0) ) / \n      ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) )\n    );\n  }\n  \n  /* If no error has occurred, return the calculated score. Otherwise,\n  ** throw an SQL exception.  */\n  if( rc==SQLITE_OK ){\n    sqlite3_result_double(pCtx, -1.0 * score);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\nint sqlite3Fts5AuxInit(fts5_api *pApi){\n  struct Builtin {\n    const char *zFunc;            /* Function name (nul-terminated) */\n    void *pUserData;              /* User-data pointer */\n    fts5_extension_function xFunc;/* Callback function */\n    void (*xDestroy)(void*);      /* Destructor function */\n  } aBuiltin [] = {\n    { \"snippet\",   0, fts5SnippetFunction, 0 },\n    { \"highlight\", 0, fts5HighlightFunction, 0 },\n    { \"bm25\",      0, fts5Bm25Function,    0 },\n  };\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateFunction(pApi,\n        aBuiltin[i].zFunc,\n        aBuiltin[i].pUserData,\n        aBuiltin[i].xFunc,\n        aBuiltin[i].xDestroy\n    );\n  }\n\n  return rc;\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_buffer.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n\n#include \"fts5Int.h\"\n\nint sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){\n  if( (u32)pBuf->nSpace<nByte ){\n    u32 nNew = pBuf->nSpace ? pBuf->nSpace : 64;\n    u8 *pNew;\n    while( nNew<nByte ){\n      nNew = nNew * 2;\n    }\n    pNew = sqlite3_realloc(pBuf->p, nNew);\n    if( pNew==0 ){\n      *pRc = SQLITE_NOMEM;\n      return 1;\n    }else{\n      pBuf->nSpace = nNew;\n      pBuf->p = pNew;\n    }\n  }\n  return 0;\n}\n\n\n/*\n** Encode value iVal as an SQLite varint and append it to the buffer object\n** pBuf. If an OOM error occurs, set the error code in p.\n*/\nvoid sqlite3Fts5BufferAppendVarint(int *pRc, Fts5Buffer *pBuf, i64 iVal){\n  if( fts5BufferGrow(pRc, pBuf, 9) ) return;\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iVal);\n}\n\nvoid sqlite3Fts5Put32(u8 *aBuf, int iVal){\n  aBuf[0] = (iVal>>24) & 0x00FF;\n  aBuf[1] = (iVal>>16) & 0x00FF;\n  aBuf[2] = (iVal>> 8) & 0x00FF;\n  aBuf[3] = (iVal>> 0) & 0x00FF;\n}\n\nint sqlite3Fts5Get32(const u8 *aBuf){\n  return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3];\n}\n\n/*\n** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set \n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nvoid sqlite3Fts5BufferAppendBlob(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  u32 nData, \n  const u8 *pData\n){\n  assert_nc( *pRc || nData>=0 );\n  if( nData ){\n    if( fts5BufferGrow(pRc, pBuf, nData) ) return;\n    memcpy(&pBuf->p[pBuf->n], pData, nData);\n    pBuf->n += nData;\n  }\n}\n\n/*\n** Append the nul-terminated string zStr to the buffer pBuf. This function\n** ensures that the byte following the buffer data is set to 0x00, even \n** though this byte is not included in the pBuf->n count.\n*/\nvoid sqlite3Fts5BufferAppendString(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  const char *zStr\n){\n  int nStr = (int)strlen(zStr);\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nStr+1, (const u8*)zStr);\n  pBuf->n--;\n}\n\n/*\n** Argument zFmt is a printf() style format string. This function performs\n** the printf() style processing, then appends the results to buffer pBuf.\n**\n** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte \n** following the buffer data is set to 0x00, even though this byte is not\n** included in the pBuf->n count.\n*/ \nvoid sqlite3Fts5BufferAppendPrintf(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  char *zFmt, ...\n){\n  if( *pRc==SQLITE_OK ){\n    char *zTmp;\n    va_list ap;\n    va_start(ap, zFmt);\n    zTmp = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n\n    if( zTmp==0 ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      sqlite3Fts5BufferAppendString(pRc, pBuf, zTmp);\n      sqlite3_free(zTmp);\n    }\n  }\n}\n\nchar *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    va_start(ap, zFmt);\n    zRet = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n    if( zRet==0 ){\n      *pRc = SQLITE_NOMEM; \n    }\n  }\n  return zRet;\n}\n \n\n/*\n** Free any buffer allocated by pBuf. Zero the structure before returning.\n*/\nvoid sqlite3Fts5BufferFree(Fts5Buffer *pBuf){\n  sqlite3_free(pBuf->p);\n  memset(pBuf, 0, sizeof(Fts5Buffer));\n}\n\n/*\n** Zero the contents of the buffer object. But do not free the associated \n** memory allocation.\n*/\nvoid sqlite3Fts5BufferZero(Fts5Buffer *pBuf){\n  pBuf->n = 0;\n}\n\n/*\n** Set the buffer to contain nData/pData. If an OOM error occurs, leave an\n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nvoid sqlite3Fts5BufferSet(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  int nData, \n  const u8 *pData\n){\n  pBuf->n = 0;\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nData, pData);\n}\n\nint sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n){\n  int i = *pi;\n  if( i>=n ){\n    /* EOF */\n    *piOff = -1;\n    return 1;  \n  }else{\n    i64 iOff = *piOff;\n    int iVal;\n    fts5FastGetVarint32(a, i, iVal);\n    if( iVal==1 ){\n      fts5FastGetVarint32(a, i, iVal);\n      iOff = ((i64)iVal) << 32;\n      fts5FastGetVarint32(a, i, iVal);\n    }\n    *piOff = iOff + (iVal-2);\n    *pi = i;\n    return 0;\n  }\n}\n\n\n/*\n** Advance the iterator object passed as the only argument. Return true\n** if the iterator reaches EOF, or false otherwise.\n*/\nint sqlite3Fts5PoslistReaderNext(Fts5PoslistReader *pIter){\n  if( sqlite3Fts5PoslistNext64(pIter->a, pIter->n, &pIter->i, &pIter->iPos) ){\n    pIter->bEof = 1;\n  }\n  return pIter->bEof;\n}\n\nint sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->a = a;\n  pIter->n = n;\n  sqlite3Fts5PoslistReaderNext(pIter);\n  return pIter->bEof;\n}\n\n/*\n** Append position iPos to the position list being accumulated in buffer\n** pBuf, which must be already be large enough to hold the new data.\n** The previous position written to this list is *piPrev. *piPrev is set\n** to iPos before returning.\n*/\nvoid sqlite3Fts5PoslistSafeAppend(\n  Fts5Buffer *pBuf, \n  i64 *piPrev, \n  i64 iPos\n){\n  static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;\n  if( (iPos & colmask) != (*piPrev & colmask) ){\n    pBuf->p[pBuf->n++] = 1;\n    pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));\n    *piPrev = (iPos & colmask);\n  }\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);\n  *piPrev = iPos;\n}\n\nint sqlite3Fts5PoslistWriterAppend(\n  Fts5Buffer *pBuf, \n  Fts5PoslistWriter *pWriter,\n  i64 iPos\n){\n  int rc = 0;   /* Initialized only to suppress erroneous warning from Clang */\n  if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;\n  sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);\n  return SQLITE_OK;\n}\n\nvoid *sqlite3Fts5MallocZero(int *pRc, int nByte){\n  void *pRet = 0;\n  if( *pRc==SQLITE_OK ){\n    pRet = sqlite3_malloc(nByte);\n    if( pRet==0 ){\n      if( nByte>0 ) *pRc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n/*\n** Return a nul-terminated copy of the string indicated by pIn. If nIn\n** is non-negative, then it is the length of the string in bytes. Otherwise,\n** the length of the string is determined using strlen().\n**\n** It is the responsibility of the caller to eventually free the returned\n** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. \n*/\nchar *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    if( nIn<0 ){\n      nIn = (int)strlen(pIn);\n    }\n    zRet = (char*)sqlite3_malloc(nIn+1);\n    if( zRet ){\n      memcpy(zRet, pIn, nIn);\n      zRet[nIn] = '\\0';\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n  return zRet;\n}\n\n\n/*\n** Return true if character 't' may be part of an FTS5 bareword, or false\n** otherwise. Characters that may be part of barewords:\n**\n**   * All non-ASCII characters,\n**   * The 52 upper and lower case ASCII characters, and\n**   * The 10 integer ASCII characters.\n**   * The underscore character \"_\" (0x5F).\n**   * The unicode \"subsitute\" character (0x1A).\n*/\nint sqlite3Fts5IsBareword(char t){\n  u8 aBareword[128] = {\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00 .. 0x0F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 1, 0, 0, 0, 0, 0,   /* 0x10 .. 0x1F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20 .. 0x2F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30 .. 0x3F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40 .. 0x4F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 1,   /* 0x50 .. 0x5F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60 .. 0x6F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 0    /* 0x70 .. 0x7F */\n  };\n\n  return (t & 0x80) || aBareword[(int)t];\n}\n\n\n/*************************************************************************\n*/\ntypedef struct Fts5TermsetEntry Fts5TermsetEntry;\nstruct Fts5TermsetEntry {\n  char *pTerm;\n  int nTerm;\n  int iIdx;                       /* Index (main or aPrefix[] entry) */\n  Fts5TermsetEntry *pNext;\n};\n\nstruct Fts5Termset {\n  Fts5TermsetEntry *apHash[512];\n};\n\nint sqlite3Fts5TermsetNew(Fts5Termset **pp){\n  int rc = SQLITE_OK;\n  *pp = sqlite3Fts5MallocZero(&rc, sizeof(Fts5Termset));\n  return rc;\n}\n\nint sqlite3Fts5TermsetAdd(\n  Fts5Termset *p, \n  int iIdx,\n  const char *pTerm, int nTerm, \n  int *pbPresent\n){\n  int rc = SQLITE_OK;\n  *pbPresent = 0;\n  if( p ){\n    int i;\n    u32 hash = 13;\n    Fts5TermsetEntry *pEntry;\n\n    /* Calculate a hash value for this term. This is the same hash checksum\n    ** used by the fts5_hash.c module. This is not important for correct\n    ** operation of the module, but is necessary to ensure that some tests\n    ** designed to produce hash table collisions really do work.  */\n    for(i=nTerm-1; i>=0; i--){\n      hash = (hash << 3) ^ hash ^ pTerm[i];\n    }\n    hash = (hash << 3) ^ hash ^ iIdx;\n    hash = hash % ArraySize(p->apHash);\n\n    for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){\n      if( pEntry->iIdx==iIdx \n          && pEntry->nTerm==nTerm \n          && memcmp(pEntry->pTerm, pTerm, nTerm)==0 \n      ){\n        *pbPresent = 1;\n        break;\n      }\n    }\n\n    if( pEntry==0 ){\n      pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm);\n      if( pEntry ){\n        pEntry->pTerm = (char*)&pEntry[1];\n        pEntry->nTerm = nTerm;\n        pEntry->iIdx = iIdx;\n        memcpy(pEntry->pTerm, pTerm, nTerm);\n        pEntry->pNext = p->apHash[hash];\n        p->apHash[hash] = pEntry;\n      }\n    }\n  }\n\n  return rc;\n}\n\nvoid sqlite3Fts5TermsetFree(Fts5Termset *p){\n  if( p ){\n    u32 i;\n    for(i=0; i<ArraySize(p->apHash); i++){\n      Fts5TermsetEntry *pEntry = p->apHash[i];\n      while( pEntry ){\n        Fts5TermsetEntry *pDel = pEntry;\n        pEntry = pEntry->pNext;\n        sqlite3_free(pDel);\n      }\n    }\n    sqlite3_free(p);\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_config.c",
    "content": "/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n#include \"fts5Int.h\"\n\n#define FTS5_DEFAULT_PAGE_SIZE   4050\n#define FTS5_DEFAULT_AUTOMERGE      4\n#define FTS5_DEFAULT_USERMERGE      4\n#define FTS5_DEFAULT_CRISISMERGE   16\n#define FTS5_DEFAULT_HASHSIZE    (1024*1024)\n\n/* Maximum allowed page size */\n#define FTS5_MAX_PAGE_SIZE (128*1024)\n\nstatic int fts5_iswhitespace(char x){\n  return (x==' ');\n}\n\nstatic int fts5_isopenquote(char x){\n  return (x=='\"' || x=='\\'' || x=='[' || x=='`');\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a white-space character.\n*/\nstatic const char *fts5ConfigSkipWhitespace(const char *pIn){\n  const char *p = pIn;\n  if( p ){\n    while( fts5_iswhitespace(*p) ){ p++; }\n  }\n  return p;\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a \"bareword\" character.\n*/\nstatic const char *fts5ConfigSkipBareword(const char *pIn){\n  const char *p = pIn;\n  while ( sqlite3Fts5IsBareword(*p) ) p++;\n  if( p==pIn ) p = 0;\n  return p;\n}\n\nstatic int fts5_isdigit(char a){\n  return (a>='0' && a<='9');\n}\n\n\n\nstatic const char *fts5ConfigSkipLiteral(const char *pIn){\n  const char *p = pIn;\n  switch( *p ){\n    case 'n': case 'N':\n      if( sqlite3_strnicmp(\"null\", p, 4)==0 ){\n        p = &p[4];\n      }else{\n        p = 0;\n      }\n      break;\n\n    case 'x': case 'X':\n      p++;\n      if( *p=='\\'' ){\n        p++;\n        while( (*p>='a' && *p<='f') \n            || (*p>='A' && *p<='F') \n            || (*p>='0' && *p<='9') \n            ){\n          p++;\n        }\n        if( *p=='\\'' && 0==((p-pIn)%2) ){\n          p++;\n        }else{\n          p = 0;\n        }\n      }else{\n        p = 0;\n      }\n      break;\n\n    case '\\'':\n      p++;\n      while( p ){\n        if( *p=='\\'' ){\n          p++;\n          if( *p!='\\'' ) break;\n        }\n        p++;\n        if( *p==0 ) p = 0;\n      }\n      break;\n\n    default:\n      /* maybe a number */\n      if( *p=='+' || *p=='-' ) p++;\n      while( fts5_isdigit(*p) ) p++;\n\n      /* At this point, if the literal was an integer, the parse is \n      ** finished. Or, if it is a floating point value, it may continue\n      ** with either a decimal point or an 'E' character. */\n      if( *p=='.' && fts5_isdigit(p[1]) ){\n        p += 2;\n        while( fts5_isdigit(*p) ) p++;\n      }\n      if( p==pIn ) p = 0;\n\n      break;\n  }\n\n  return p;\n}\n\n/*\n** The first character of the string pointed to by argument z is guaranteed\n** to be an open-quote character (see function fts5_isopenquote()).\n**\n** This function searches for the corresponding close-quote character within\n** the string and, if found, dequotes the string in place and adds a new\n** nul-terminator byte.\n**\n** If the close-quote is found, the value returned is the byte offset of\n** the character immediately following it. Or, if the close-quote is not \n** found, -1 is returned. If -1 is returned, the buffer is left in an \n** undefined state.\n*/\nstatic int fts5Dequote(char *z){\n  char q;\n  int iIn = 1;\n  int iOut = 0;\n  q = z[0];\n\n  /* Set stack variable q to the close-quote character */\n  assert( q=='[' || q=='\\'' || q=='\"' || q=='`' );\n  if( q=='[' ) q = ']';  \n\n  while( ALWAYS(z[iIn]) ){\n    if( z[iIn]==q ){\n      if( z[iIn+1]!=q ){\n        /* Character iIn was the close quote. */\n        iIn++;\n        break;\n      }else{\n        /* Character iIn and iIn+1 form an escaped quote character. Skip\n        ** the input cursor past both and copy a single quote character \n        ** to the output buffer. */\n        iIn += 2;\n        z[iOut++] = q;\n      }\n    }else{\n      z[iOut++] = z[iIn++];\n    }\n  }\n\n  z[iOut] = '\\0';\n  return iIn;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nvoid sqlite3Fts5Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  assert( 0==fts5_iswhitespace(z[0]) );\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    fts5Dequote(z);\n  }\n}\n\n\nstruct Fts5Enum {\n  const char *zName;\n  int eVal;\n};\ntypedef struct Fts5Enum Fts5Enum;\n\nstatic int fts5ConfigSetEnum(\n  const Fts5Enum *aEnum, \n  const char *zEnum, \n  int *peVal\n){\n  int nEnum = (int)strlen(zEnum);\n  int i;\n  int iVal = -1;\n\n  for(i=0; aEnum[i].zName; i++){\n    if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){\n      if( iVal>=0 ) return SQLITE_ERROR;\n      iVal = aEnum[i].eVal;\n    }\n  }\n\n  *peVal = iVal;\n  return iVal<0 ? SQLITE_ERROR : SQLITE_OK;\n}\n\n/*\n** Parse a \"special\" CREATE VIRTUAL TABLE directive and update\n** configuration object pConfig as appropriate.\n**\n** If successful, object pConfig is updated and SQLITE_OK returned. If\n** an error occurs, an SQLite error code is returned and an error message\n** may be left in *pzErr. It is the responsibility of the caller to\n** eventually free any such error message using sqlite3_free().\n*/\nstatic int fts5ConfigParseSpecial(\n  Fts5Global *pGlobal,\n  Fts5Config *pConfig,            /* Configuration object to update */\n  const char *zCmd,               /* Special command to parse */\n  const char *zArg,               /* Argument to parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  int nCmd = (int)strlen(zCmd);\n  if( sqlite3_strnicmp(\"prefix\", zCmd, nCmd)==0 ){\n    const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;\n    const char *p;\n    int bFirst = 1;\n    if( pConfig->aPrefix==0 ){\n      pConfig->aPrefix = sqlite3Fts5MallocZero(&rc, nByte);\n      if( rc ) return rc;\n    }\n\n    p = zArg;\n    while( 1 ){\n      int nPre = 0;\n\n      while( p[0]==' ' ) p++;\n      if( bFirst==0 && p[0]==',' ){\n        p++;\n        while( p[0]==' ' ) p++;\n      }else if( p[0]=='\\0' ){\n        break;\n      }\n      if( p[0]<'0' || p[0]>'9' ){\n        *pzErr = sqlite3_mprintf(\"malformed prefix=... directive\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      if( pConfig->nPrefix==FTS5_MAX_PREFIX_INDEXES ){\n        *pzErr = sqlite3_mprintf(\n            \"too many prefix indexes (max %d)\", FTS5_MAX_PREFIX_INDEXES\n        );\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      while( p[0]>='0' && p[0]<='9' && nPre<1000 ){\n        nPre = nPre*10 + (p[0] - '0');\n        p++;\n      }\n\n      if( nPre<=0 || nPre>=1000 ){\n        *pzErr = sqlite3_mprintf(\"prefix length out of range (max 999)\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      pConfig->aPrefix[pConfig->nPrefix] = nPre;\n      pConfig->nPrefix++;\n      bFirst = 0;\n    }\n    assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES );\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"tokenize\", zCmd, nCmd)==0 ){\n    const char *p = (const char*)zArg;\n    int nArg = (int)strlen(zArg) + 1;\n    char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);\n    char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);\n    char *pSpace = pDel;\n\n    if( azArg && pSpace ){\n      if( pConfig->pTok ){\n        *pzErr = sqlite3_mprintf(\"multiple tokenize=... directives\");\n        rc = SQLITE_ERROR;\n      }else{\n        for(nArg=0; p && *p; nArg++){\n          const char *p2 = fts5ConfigSkipWhitespace(p);\n          if( *p2=='\\'' ){\n            p = fts5ConfigSkipLiteral(p2);\n          }else{\n            p = fts5ConfigSkipBareword(p2);\n          }\n          if( p ){\n            memcpy(pSpace, p2, p-p2);\n            azArg[nArg] = pSpace;\n            sqlite3Fts5Dequote(pSpace);\n            pSpace += (p - p2) + 1;\n            p = fts5ConfigSkipWhitespace(p);\n          }\n        }\n        if( p==0 ){\n          *pzErr = sqlite3_mprintf(\"parse error in tokenize directive\");\n          rc = SQLITE_ERROR;\n        }else{\n          rc = sqlite3Fts5GetTokenizer(pGlobal, \n              (const char**)azArg, nArg, &pConfig->pTok, &pConfig->pTokApi,\n              pzErr\n          );\n        }\n      }\n    }\n\n    sqlite3_free(azArg);\n    sqlite3_free(pDel);\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content\", zCmd, nCmd)==0 ){\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n      *pzErr = sqlite3_mprintf(\"multiple content=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      if( zArg[0] ){\n        pConfig->eContent = FTS5_CONTENT_EXTERNAL;\n        pConfig->zContent = sqlite3Fts5Mprintf(&rc, \"%Q.%Q\", pConfig->zDb,zArg);\n      }else{\n        pConfig->eContent = FTS5_CONTENT_NONE;\n      }\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content_rowid\", zCmd, nCmd)==0 ){\n    if( pConfig->zContentRowid ){\n      *pzErr = sqlite3_mprintf(\"multiple content_rowid=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->zContentRowid = sqlite3Fts5Strndup(&rc, zArg, -1);\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"columnsize\", zCmd, nCmd)==0 ){\n    if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\\0' ){\n      *pzErr = sqlite3_mprintf(\"malformed columnsize=... directive\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->bColumnsize = (zArg[0]=='1');\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"detail\", zCmd, nCmd)==0 ){\n    const Fts5Enum aDetail[] = {\n      { \"none\", FTS5_DETAIL_NONE },\n      { \"full\", FTS5_DETAIL_FULL },\n      { \"columns\", FTS5_DETAIL_COLUMNS },\n      { 0, 0 }\n    };\n\n    if( (rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail)) ){\n      *pzErr = sqlite3_mprintf(\"malformed detail=... directive\");\n    }\n    return rc;\n  }\n\n  *pzErr = sqlite3_mprintf(\"unrecognized option: \\\"%.*s\\\"\", nCmd, zCmd);\n  return SQLITE_ERROR;\n}\n\n/*\n** Allocate an instance of the default tokenizer (\"simple\") at \n** Fts5Config.pTokenizer. Return SQLITE_OK if successful, or an SQLite error\n** code if an error occurs.\n*/\nstatic int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){\n  assert( pConfig->pTok==0 && pConfig->pTokApi==0 );\n  return sqlite3Fts5GetTokenizer(\n      pGlobal, 0, 0, &pConfig->pTok, &pConfig->pTokApi, 0\n  );\n}\n\n/*\n** Gobble up the first bareword or quoted word from the input buffer zIn.\n** Return a pointer to the character immediately following the last in\n** the gobbled word if successful, or a NULL pointer otherwise (failed\n** to find close-quote character).\n**\n** Before returning, set pzOut to point to a new buffer containing a\n** nul-terminated, dequoted copy of the gobbled word. If the word was\n** quoted, *pbQuoted is also set to 1 before returning.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op (NULL is returned). Otherwise, if an OOM occurs within this\n** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not*\n** set if a parse error (failed to find close quote) occurs.\n*/\nstatic const char *fts5ConfigGobbleWord(\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zIn,                /* Buffer to gobble string/bareword from */\n  char **pzOut,                   /* OUT: malloc'd buffer containing str/bw */\n  int *pbQuoted                   /* OUT: Set to true if dequoting required */\n){\n  const char *zRet = 0;\n\n  int nIn = (int)strlen(zIn);\n  char *zOut = sqlite3_malloc(nIn+1);\n\n  assert( *pRc==SQLITE_OK );\n  *pbQuoted = 0;\n  *pzOut = 0;\n\n  if( zOut==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    memcpy(zOut, zIn, nIn+1);\n    if( fts5_isopenquote(zOut[0]) ){\n      int ii = fts5Dequote(zOut);\n      zRet = &zIn[ii];\n      *pbQuoted = 1;\n    }else{\n      zRet = fts5ConfigSkipBareword(zIn);\n      if( zRet ){\n        zOut[zRet-zIn] = '\\0';\n      }\n    }\n  }\n\n  if( zRet==0 ){\n    sqlite3_free(zOut);\n  }else{\n    *pzOut = zOut;\n  }\n\n  return zRet;\n}\n\nstatic int fts5ConfigParseColumn(\n  Fts5Config *p, \n  char *zCol, \n  char *zArg, \n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME) \n   || 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME) \n  ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 column name: %s\", zCol);\n    rc = SQLITE_ERROR;\n  }else if( zArg ){\n    if( 0==sqlite3_stricmp(zArg, \"unindexed\") ){\n      p->abUnindexed[p->nCol] = 1;\n    }else{\n      *pzErr = sqlite3_mprintf(\"unrecognized column option: %s\", zArg);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  p->azCol[p->nCol++] = zCol;\n  return rc;\n}\n\n/*\n** Populate the Fts5Config.zContentExprlist string.\n*/\nstatic int fts5ConfigMakeExprlist(Fts5Config *p){\n  int i;\n  int rc = SQLITE_OK;\n  Fts5Buffer buf = {0, 0, 0};\n\n  sqlite3Fts5BufferAppendPrintf(&rc, &buf, \"T.%Q\", p->zContentRowid);\n  if( p->eContent!=FTS5_CONTENT_NONE ){\n    for(i=0; i<p->nCol; i++){\n      if( p->eContent==FTS5_CONTENT_EXTERNAL ){\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.%Q\", p->azCol[i]);\n      }else{\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.c%d\", i);\n      }\n    }\n  }\n\n  assert( p->zContentExprlist==0 );\n  p->zContentExprlist = (char*)buf.p;\n  return rc;\n}\n\n/*\n** Arguments nArg/azArg contain the string arguments passed to the xCreate\n** or xConnect method of the virtual table. This function attempts to \n** allocate an instance of Fts5Config containing the results of parsing\n** those arguments.\n**\n** If successful, SQLITE_OK is returned and *ppOut is set to point to the\n** new Fts5Config object. If an error occurs, an SQLite error code is \n** returned, *ppOut is set to NULL and an error message may be left in\n** *pzErr. It is the responsibility of the caller to eventually free any \n** such error message using sqlite3_free().\n*/\nint sqlite3Fts5ConfigParse(\n  Fts5Global *pGlobal,\n  sqlite3 *db,\n  int nArg,                       /* Number of arguments */\n  const char **azArg,             /* Array of nArg CREATE VIRTUAL TABLE args */\n  Fts5Config **ppOut,             /* OUT: Results of parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pRet;               /* New object to return */\n  int i;\n  int nByte;\n\n  *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));\n  if( pRet==0 ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(Fts5Config));\n  pRet->db = db;\n  pRet->iCookie = -1;\n\n  nByte = nArg * (sizeof(char*) + sizeof(u8));\n  pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);\n  pRet->abUnindexed = (u8*)&pRet->azCol[nArg];\n  pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);\n  pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);\n  pRet->bColumnsize = 1;\n  pRet->eDetail = FTS5_DETAIL_FULL;\n#ifdef SQLITE_DEBUG\n  pRet->bPrefixIndex = 1;\n#endif\n  if( rc==SQLITE_OK && sqlite3_stricmp(pRet->zName, FTS5_RANK_NAME)==0 ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 table name: %s\", pRet->zName);\n    rc = SQLITE_ERROR;\n  }\n\n  for(i=3; rc==SQLITE_OK && i<nArg; i++){\n    const char *zOrig = azArg[i];\n    const char *z;\n    char *zOne = 0;\n    char *zTwo = 0;\n    int bOption = 0;\n    int bMustBeCol = 0;\n\n    z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && *z=='=' ){\n      bOption = 1;\n      z++;\n      if( bMustBeCol ) z = 0;\n    }\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && z[0] ){\n      int bDummy;\n      z = fts5ConfigGobbleWord(&rc, z, &zTwo, &bDummy);\n      if( z && z[0] ) z = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( z==0 ){\n        *pzErr = sqlite3_mprintf(\"parse error in \\\"%s\\\"\", zOrig);\n        rc = SQLITE_ERROR;\n      }else{\n        if( bOption ){\n          rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:\"\", pzErr);\n        }else{\n          rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);\n          zOne = 0;\n        }\n      }\n    }\n\n    sqlite3_free(zOne);\n    sqlite3_free(zTwo);\n  }\n\n  /* If a tokenizer= option was successfully parsed, the tokenizer has\n  ** already been allocated. Otherwise, allocate an instance of the default\n  ** tokenizer (unicode61) now.  */\n  if( rc==SQLITE_OK && pRet->pTok==0 ){\n    rc = fts5ConfigDefaultTokenizer(pGlobal, pRet);\n  }\n\n  /* If no zContent option was specified, fill in the default values. */\n  if( rc==SQLITE_OK && pRet->zContent==0 ){\n    const char *zTail = 0;\n    assert( pRet->eContent==FTS5_CONTENT_NORMAL \n         || pRet->eContent==FTS5_CONTENT_NONE \n    );\n    if( pRet->eContent==FTS5_CONTENT_NORMAL ){\n      zTail = \"content\";\n    }else if( pRet->bColumnsize ){\n      zTail = \"docsize\";\n    }\n\n    if( zTail ){\n      pRet->zContent = sqlite3Fts5Mprintf(\n          &rc, \"%Q.'%q_%s'\", pRet->zDb, pRet->zName, zTail\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK && pRet->zContentRowid==0 ){\n    pRet->zContentRowid = sqlite3Fts5Strndup(&rc, \"rowid\", -1);\n  }\n\n  /* Formulate the zContentExprlist text */\n  if( rc==SQLITE_OK ){\n    rc = fts5ConfigMakeExprlist(pRet);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts5ConfigFree(pRet);\n    *ppOut = 0;\n  }\n  return rc;\n}\n\n/*\n** Free the configuration object passed as the only argument.\n*/\nvoid sqlite3Fts5ConfigFree(Fts5Config *pConfig){\n  if( pConfig ){\n    int i;\n    if( pConfig->pTok ){\n      pConfig->pTokApi->xDelete(pConfig->pTok);\n    }\n    sqlite3_free(pConfig->zDb);\n    sqlite3_free(pConfig->zName);\n    for(i=0; i<pConfig->nCol; i++){\n      sqlite3_free(pConfig->azCol[i]);\n    }\n    sqlite3_free(pConfig->azCol);\n    sqlite3_free(pConfig->aPrefix);\n    sqlite3_free(pConfig->zRank);\n    sqlite3_free(pConfig->zRankArgs);\n    sqlite3_free(pConfig->zContent);\n    sqlite3_free(pConfig->zContentRowid);\n    sqlite3_free(pConfig->zContentExprlist);\n    sqlite3_free(pConfig);\n  }\n}\n\n/*\n** Call sqlite3_declare_vtab() based on the contents of the configuration\n** object passed as the only argument. Return SQLITE_OK if successful, or\n** an SQLite error code if an error occurs.\n*/\nint sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig){\n  int i;\n  int rc = SQLITE_OK;\n  char *zSql;\n\n  zSql = sqlite3Fts5Mprintf(&rc, \"CREATE TABLE x(\");\n  for(i=0; zSql && i<pConfig->nCol; i++){\n    const char *zSep = (i==0?\"\":\", \");\n    zSql = sqlite3Fts5Mprintf(&rc, \"%z%s%Q\", zSql, zSep, pConfig->azCol[i]);\n  }\n  zSql = sqlite3Fts5Mprintf(&rc, \"%z, %Q HIDDEN, %s HIDDEN)\", \n      zSql, pConfig->zName, FTS5_RANK_NAME\n  );\n\n  assert( zSql || rc==SQLITE_NOMEM );\n  if( zSql ){\n    rc = sqlite3_declare_vtab(pConfig->db, zSql);\n    sqlite3_free(zSql);\n  }\n  \n  return rc;\n}\n\n/*\n** Tokenize the text passed via the second and third arguments.\n**\n** The callback is invoked once for each token in the input text. The\n** arguments passed to it are, in order:\n**\n**     void *pCtx          // Copy of 4th argument to sqlite3Fts5Tokenize()\n**     const char *pToken  // Pointer to buffer containing token\n**     int nToken          // Size of token in bytes\n**     int iStart          // Byte offset of start of token within input text\n**     int iEnd            // Byte offset of end of token within input text\n**     int iPos            // Position of token in input (first token is 0)\n**\n** If the callback returns a non-zero value the tokenization is abandoned\n** and no further callbacks are issued. \n**\n** This function returns SQLITE_OK if successful or an SQLite error code\n** if an error occurs. If the tokenization was abandoned early because\n** the callback returned SQLITE_DONE, this is not an error and this function\n** still returns SQLITE_OK. Or, if the tokenization was abandoned early\n** because the callback returned another non-zero value, it is assumed\n** to be an SQLite error code and returned to the caller.\n*/\nint sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n){\n  if( pText==0 ) return SQLITE_OK;\n  return pConfig->pTokApi->xTokenize(\n      pConfig->pTok, pCtx, flags, pText, nText, xToken\n  );\n}\n\n/*\n** Argument pIn points to the first character in what is expected to be\n** a comma-separated list of SQL literals followed by a ')' character.\n** If it actually is this, return a pointer to the ')'. Otherwise, return\n** NULL to indicate a parse error.\n*/\nstatic const char *fts5ConfigSkipArgs(const char *pIn){\n  const char *p = pIn;\n  \n  while( 1 ){\n    p = fts5ConfigSkipWhitespace(p);\n    p = fts5ConfigSkipLiteral(p);\n    p = fts5ConfigSkipWhitespace(p);\n    if( p==0 || *p==')' ) break;\n    if( *p!=',' ){\n      p = 0;\n      break;\n    }\n    p++;\n  }\n\n  return p;\n}\n\n/*\n** Parameter zIn contains a rank() function specification. The format of \n** this is:\n**\n**   + Bareword (function name)\n**   + Open parenthesis - \"(\"\n**   + Zero or more SQL literals in a comma separated list\n**   + Close parenthesis - \")\"\n*/\nint sqlite3Fts5ConfigParseRank(\n  const char *zIn,                /* Input string */\n  char **pzRank,                  /* OUT: Rank function name */\n  char **pzRankArgs               /* OUT: Rank function arguments */\n){\n  const char *p = zIn;\n  const char *pRank;\n  char *zRank = 0;\n  char *zRankArgs = 0;\n  int rc = SQLITE_OK;\n\n  *pzRank = 0;\n  *pzRankArgs = 0;\n\n  if( p==0 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = fts5ConfigSkipWhitespace(p);\n    pRank = p;\n    p = fts5ConfigSkipBareword(p);\n\n    if( p ){\n      zRank = sqlite3Fts5MallocZero(&rc, 1 + p - pRank);\n      if( zRank ) memcpy(zRank, pRank, p-pRank);\n    }else{\n      rc = SQLITE_ERROR;\n    }\n\n    if( rc==SQLITE_OK ){\n      p = fts5ConfigSkipWhitespace(p);\n      if( *p!='(' ) rc = SQLITE_ERROR;\n      p++;\n    }\n    if( rc==SQLITE_OK ){\n      const char *pArgs; \n      p = fts5ConfigSkipWhitespace(p);\n      pArgs = p;\n      if( *p!=')' ){\n        p = fts5ConfigSkipArgs(p);\n        if( p==0 ){\n          rc = SQLITE_ERROR;\n        }else{\n          zRankArgs = sqlite3Fts5MallocZero(&rc, 1 + p - pArgs);\n          if( zRankArgs ) memcpy(zRankArgs, pArgs, p-pArgs);\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRank);\n    assert( zRankArgs==0 );\n  }else{\n    *pzRank = zRank;\n    *pzRankArgs = zRankArgs;\n  }\n  return rc;\n}\n\nint sqlite3Fts5ConfigSetValue(\n  Fts5Config *pConfig, \n  const char *zKey, \n  sqlite3_value *pVal,\n  int *pbBadkey\n){\n  int rc = SQLITE_OK;\n\n  if( 0==sqlite3_stricmp(zKey, \"pgsz\") ){\n    int pgsz = 0;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      pgsz = sqlite3_value_int(pVal);\n    }\n    if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->pgsz = pgsz;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"hashsize\") ){\n    int nHashSize = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nHashSize = sqlite3_value_int(pVal);\n    }\n    if( nHashSize<=0 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nHashSize = nHashSize;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"automerge\") ){\n    int nAutomerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nAutomerge = sqlite3_value_int(pVal);\n    }\n    if( nAutomerge<0 || nAutomerge>64 ){\n      *pbBadkey = 1;\n    }else{\n      if( nAutomerge==1 ) nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n      pConfig->nAutomerge = nAutomerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"usermerge\") ){\n    int nUsermerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nUsermerge = sqlite3_value_int(pVal);\n    }\n    if( nUsermerge<2 || nUsermerge>16 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nUsermerge = nUsermerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"crisismerge\") ){\n    int nCrisisMerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nCrisisMerge = sqlite3_value_int(pVal);\n    }\n    if( nCrisisMerge<0 ){\n      *pbBadkey = 1;\n    }else{\n      if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n      pConfig->nCrisisMerge = nCrisisMerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"rank\") ){\n    const char *zIn = (const char*)sqlite3_value_text(pVal);\n    char *zRank;\n    char *zRankArgs;\n    rc = sqlite3Fts5ConfigParseRank(zIn, &zRank, &zRankArgs);\n    if( rc==SQLITE_OK ){\n      sqlite3_free(pConfig->zRank);\n      sqlite3_free(pConfig->zRankArgs);\n      pConfig->zRank = zRank;\n      pConfig->zRankArgs = zRankArgs;\n    }else if( rc==SQLITE_ERROR ){\n      rc = SQLITE_OK;\n      *pbBadkey = 1;\n    }\n  }else{\n    *pbBadkey = 1;\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the %_config table into memory.\n*/\nint sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){\n  const char *zSelect = \"SELECT k, v FROM %Q.'%q_config'\";\n  char *zSql;\n  sqlite3_stmt *p = 0;\n  int rc = SQLITE_OK;\n  int iVersion = 0;\n\n  /* Set default values */\n  pConfig->pgsz = FTS5_DEFAULT_PAGE_SIZE;\n  pConfig->nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n  pConfig->nUsermerge = FTS5_DEFAULT_USERMERGE;\n  pConfig->nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n  pConfig->nHashSize = FTS5_DEFAULT_HASHSIZE;\n\n  zSql = sqlite3Fts5Mprintf(&rc, zSelect, pConfig->zDb, pConfig->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p, 0);\n    sqlite3_free(zSql);\n  }\n\n  assert( rc==SQLITE_OK || p==0 );\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==sqlite3_step(p) ){\n      const char *zK = (const char*)sqlite3_column_text(p, 0);\n      sqlite3_value *pVal = sqlite3_column_value(p, 1);\n      if( 0==sqlite3_stricmp(zK, \"version\") ){\n        iVersion = sqlite3_value_int(pVal);\n      }else{\n        int bDummy = 0;\n        sqlite3Fts5ConfigSetValue(pConfig, zK, pVal, &bDummy);\n      }\n    }\n    rc = sqlite3_finalize(p);\n  }\n  \n  if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){\n    rc = SQLITE_ERROR;\n    if( pConfig->pzErrmsg ){\n      assert( 0==*pConfig->pzErrmsg );\n      *pConfig->pzErrmsg = sqlite3_mprintf(\n          \"invalid fts5 file format (found %d, expected %d) - run 'rebuild'\",\n          iVersion, FTS5_CURRENT_VERSION\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pConfig->iCookie = iCookie;\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_expr.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n#include \"fts5Int.h\"\n#include \"fts5parse.h\"\n\n/*\n** All token types in the generated fts5parse.h file are greater than 0.\n*/\n#define FTS5_EOF 0\n\n#define FTS5_LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n\ntypedef struct Fts5ExprTerm Fts5ExprTerm;\n\n/*\n** Functions generated by lemon from fts5parse.y.\n*/\nvoid *sqlite3Fts5ParserAlloc(void *(*mallocProc)(u64));\nvoid sqlite3Fts5ParserFree(void*, void (*freeProc)(void*));\nvoid sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);\n#ifndef NDEBUG\n#include <stdio.h>\nvoid sqlite3Fts5ParserTrace(FILE*, char*);\n#endif\n\n\nstruct Fts5Expr {\n  Fts5Index *pIndex;\n  Fts5Config *pConfig;\n  Fts5ExprNode *pRoot;\n  int bDesc;                      /* Iterate in descending rowid order */\n  int nPhrase;                    /* Number of phrases in expression */\n  Fts5ExprPhrase **apExprPhrase;  /* Pointers to phrase objects */\n};\n\n/*\n** eType:\n**   Expression node type. Always one of:\n**\n**       FTS5_AND                 (nChild, apChild valid)\n**       FTS5_OR                  (nChild, apChild valid)\n**       FTS5_NOT                 (nChild, apChild valid)\n**       FTS5_STRING              (pNear valid)\n**       FTS5_TERM                (pNear valid)\n*/\nstruct Fts5ExprNode {\n  int eType;                      /* Node type */\n  int bEof;                       /* True at EOF */\n  int bNomatch;                   /* True if entry is not a match */\n\n  /* Next method for this node. */\n  int (*xNext)(Fts5Expr*, Fts5ExprNode*, int, i64);\n\n  i64 iRowid;                     /* Current rowid */\n  Fts5ExprNearset *pNear;         /* For FTS5_STRING - cluster of phrases */\n\n  /* Child nodes. For a NOT node, this array always contains 2 entries. For \n  ** AND or OR nodes, it contains 2 or more entries.  */\n  int nChild;                     /* Number of child nodes */\n  Fts5ExprNode *apChild[1];       /* Array of child nodes */\n};\n\n#define Fts5NodeIsString(p) ((p)->eType==FTS5_TERM || (p)->eType==FTS5_STRING)\n\n/*\n** Invoke the xNext method of an Fts5ExprNode object. This macro should be\n** used as if it has the same signature as the xNext() methods themselves.\n*/\n#define fts5ExprNodeNext(a,b,c,d) (b)->xNext((a), (b), (c), (d))\n\n/*\n** An instance of the following structure represents a single search term\n** or term prefix.\n*/\nstruct Fts5ExprTerm {\n  int bPrefix;                    /* True for a prefix term */\n  char *zTerm;                    /* nul-terminated term */\n  Fts5IndexIter *pIter;           /* Iterator for this term */\n  Fts5ExprTerm *pSynonym;         /* Pointer to first in list of synonyms */\n};\n\n/*\n** A phrase. One or more terms that must appear in a contiguous sequence\n** within a document for it to match.\n*/\nstruct Fts5ExprPhrase {\n  Fts5ExprNode *pNode;            /* FTS5_STRING node this phrase is part of */\n  Fts5Buffer poslist;             /* Current position list */\n  int nTerm;                      /* Number of entries in aTerm[] */\n  Fts5ExprTerm aTerm[1];          /* Terms that make up this phrase */\n};\n\n/*\n** One or more phrases that must appear within a certain token distance of\n** each other within each matching document.\n*/\nstruct Fts5ExprNearset {\n  int nNear;                      /* NEAR parameter */\n  Fts5Colset *pColset;            /* Columns to search (NULL -> all columns) */\n  int nPhrase;                    /* Number of entries in aPhrase[] array */\n  Fts5ExprPhrase *apPhrase[1];    /* Array of phrase pointers */\n};\n\n\n/*\n** Parse context.\n*/\nstruct Fts5Parse {\n  Fts5Config *pConfig;\n  char *zErr;\n  int rc;\n  int nPhrase;                    /* Size of apPhrase array */\n  Fts5ExprPhrase **apPhrase;      /* Array of all phrases */\n  Fts5ExprNode *pExpr;            /* Result of a successful parse */\n};\n\nvoid sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){\n  va_list ap;\n  va_start(ap, zFmt);\n  if( pParse->rc==SQLITE_OK ){\n    pParse->zErr = sqlite3_vmprintf(zFmt, ap);\n    pParse->rc = SQLITE_ERROR;\n  }\n  va_end(ap);\n}\n\nstatic int fts5ExprIsspace(char t){\n  return t==' ' || t=='\\t' || t=='\\n' || t=='\\r';\n}\n\n/*\n** Read the first token from the nul-terminated string at *pz.\n*/\nstatic int fts5ExprGetToken(\n  Fts5Parse *pParse, \n  const char **pz,                /* IN/OUT: Pointer into buffer */\n  Fts5Token *pToken\n){\n  const char *z = *pz;\n  int tok;\n\n  /* Skip past any whitespace */\n  while( fts5ExprIsspace(*z) ) z++;\n\n  pToken->p = z;\n  pToken->n = 1;\n  switch( *z ){\n    case '(':  tok = FTS5_LP;    break;\n    case ')':  tok = FTS5_RP;    break;\n    case '{':  tok = FTS5_LCP;   break;\n    case '}':  tok = FTS5_RCP;   break;\n    case ':':  tok = FTS5_COLON; break;\n    case ',':  tok = FTS5_COMMA; break;\n    case '+':  tok = FTS5_PLUS;  break;\n    case '*':  tok = FTS5_STAR;  break;\n    case '-':  tok = FTS5_MINUS; break;\n    case '\\0': tok = FTS5_EOF;   break;\n\n    case '\"': {\n      const char *z2;\n      tok = FTS5_STRING;\n\n      for(z2=&z[1]; 1; z2++){\n        if( z2[0]=='\"' ){\n          z2++;\n          if( z2[0]!='\"' ) break;\n        }\n        if( z2[0]=='\\0' ){\n          sqlite3Fts5ParseError(pParse, \"unterminated string\");\n          return FTS5_EOF;\n        }\n      }\n      pToken->n = (z2 - z);\n      break;\n    }\n\n    default: {\n      const char *z2;\n      if( sqlite3Fts5IsBareword(z[0])==0 ){\n        sqlite3Fts5ParseError(pParse, \"fts5: syntax error near \\\"%.1s\\\"\", z);\n        return FTS5_EOF;\n      }\n      tok = FTS5_STRING;\n      for(z2=&z[1]; sqlite3Fts5IsBareword(*z2); z2++);\n      pToken->n = (z2 - z);\n      if( pToken->n==2 && memcmp(pToken->p, \"OR\", 2)==0 )  tok = FTS5_OR;\n      if( pToken->n==3 && memcmp(pToken->p, \"NOT\", 3)==0 ) tok = FTS5_NOT;\n      if( pToken->n==3 && memcmp(pToken->p, \"AND\", 3)==0 ) tok = FTS5_AND;\n      break;\n    }\n  }\n\n  *pz = &pToken->p[pToken->n];\n  return tok;\n}\n\nstatic void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); }\nstatic void fts5ParseFree(void *p){ sqlite3_free(p); }\n\nint sqlite3Fts5ExprNew(\n  Fts5Config *pConfig,            /* FTS5 Configuration */\n  int iCol,\n  const char *zExpr,              /* Expression text */\n  Fts5Expr **ppNew, \n  char **pzErr\n){\n  Fts5Parse sParse;\n  Fts5Token token;\n  const char *z = zExpr;\n  int t;                          /* Next token type */\n  void *pEngine;\n  Fts5Expr *pNew;\n\n  *ppNew = 0;\n  *pzErr = 0;\n  memset(&sParse, 0, sizeof(sParse));\n  pEngine = sqlite3Fts5ParserAlloc(fts5ParseAlloc);\n  if( pEngine==0 ){ return SQLITE_NOMEM; }\n  sParse.pConfig = pConfig;\n\n  do {\n    t = fts5ExprGetToken(&sParse, &z, &token);\n    sqlite3Fts5Parser(pEngine, t, token, &sParse);\n  }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF );\n  sqlite3Fts5ParserFree(pEngine, fts5ParseFree);\n\n  /* If the LHS of the MATCH expression was a user column, apply the\n  ** implicit column-filter.  */\n  if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){\n    int n = sizeof(Fts5Colset);\n    Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n);\n    if( pColset ){\n      pColset->nCol = 1;\n      pColset->aiCol[0] = iCol;\n      sqlite3Fts5ParseSetColset(&sParse, sParse.pExpr, pColset);\n    }\n  }\n\n  assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 );\n  if( sParse.rc==SQLITE_OK ){\n    *ppNew = pNew = sqlite3_malloc(sizeof(Fts5Expr));\n    if( pNew==0 ){\n      sParse.rc = SQLITE_NOMEM;\n      sqlite3Fts5ParseNodeFree(sParse.pExpr);\n    }else{\n      if( !sParse.pExpr ){\n        const int nByte = sizeof(Fts5ExprNode);\n        pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&sParse.rc, nByte);\n        if( pNew->pRoot ){\n          pNew->pRoot->bEof = 1;\n        }\n      }else{\n        pNew->pRoot = sParse.pExpr;\n      }\n      pNew->pIndex = 0;\n      pNew->pConfig = pConfig;\n      pNew->apExprPhrase = sParse.apPhrase;\n      pNew->nPhrase = sParse.nPhrase;\n      sParse.apPhrase = 0;\n    }\n  }else{\n    sqlite3Fts5ParseNodeFree(sParse.pExpr);\n  }\n\n  sqlite3_free(sParse.apPhrase);\n  *pzErr = sParse.zErr;\n  return sParse.rc;\n}\n\n/*\n** Free the expression node object passed as the only argument.\n*/\nvoid sqlite3Fts5ParseNodeFree(Fts5ExprNode *p){\n  if( p ){\n    int i;\n    for(i=0; i<p->nChild; i++){\n      sqlite3Fts5ParseNodeFree(p->apChild[i]);\n    }\n    sqlite3Fts5ParseNearsetFree(p->pNear);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Free the expression object passed as the only argument.\n*/\nvoid sqlite3Fts5ExprFree(Fts5Expr *p){\n  if( p ){\n    sqlite3Fts5ParseNodeFree(p->pRoot);\n    sqlite3_free(p->apExprPhrase);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Argument pTerm must be a synonym iterator. Return the current rowid\n** that it points to.\n*/\nstatic i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){\n  i64 iRet = 0;\n  int bRetValid = 0;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  assert( bDesc==0 || bDesc==1 );\n  for(p=pTerm; p; p=p->pSynonym){\n    if( 0==sqlite3Fts5IterEof(p->pIter) ){\n      i64 iRowid = p->pIter->iRowid;\n      if( bRetValid==0 || (bDesc!=(iRowid<iRet)) ){\n        iRet = iRowid;\n        bRetValid = 1;\n      }\n    }\n  }\n\n  if( pbEof && bRetValid==0 ) *pbEof = 1;\n  return iRet;\n}\n\n/*\n** Argument pTerm must be a synonym iterator.\n*/\nstatic int fts5ExprSynonymList(\n  Fts5ExprTerm *pTerm, \n  i64 iRowid,\n  Fts5Buffer *pBuf,               /* Use this buffer for space if required */\n  u8 **pa, int *pn\n){\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int nIter = 0;\n  int nAlloc = 4;\n  int rc = SQLITE_OK;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  for(p=pTerm; p; p=p->pSynonym){\n    Fts5IndexIter *pIter = p->pIter;\n    if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){\n      if( pIter->nData==0 ) continue;\n      if( nIter==nAlloc ){\n        int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;\n        Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte);\n        if( aNew==0 ){\n          rc = SQLITE_NOMEM;\n          goto synonym_poslist_out;\n        }\n        memcpy(aNew, aIter, sizeof(Fts5PoslistReader) * nIter);\n        nAlloc = nAlloc*2;\n        if( aIter!=aStatic ) sqlite3_free(aIter);\n        aIter = aNew;\n      }\n      sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &aIter[nIter]);\n      assert( aIter[nIter].bEof==0 );\n      nIter++;\n    }\n  }\n\n  if( nIter==1 ){\n    *pa = (u8*)aIter[0].a;\n    *pn = aIter[0].n;\n  }else{\n    Fts5PoslistWriter writer = {0};\n    i64 iPrev = -1;\n    fts5BufferZero(pBuf);\n    while( 1 ){\n      int i;\n      i64 iMin = FTS5_LARGEST_INT64;\n      for(i=0; i<nIter; i++){\n        if( aIter[i].bEof==0 ){\n          if( aIter[i].iPos==iPrev ){\n            if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) continue;\n          }\n          if( aIter[i].iPos<iMin ){\n            iMin = aIter[i].iPos;\n          }\n        }\n      }\n      if( iMin==FTS5_LARGEST_INT64 || rc!=SQLITE_OK ) break;\n      rc = sqlite3Fts5PoslistWriterAppend(pBuf, &writer, iMin);\n      iPrev = iMin;\n    }\n    if( rc==SQLITE_OK ){\n      *pa = pBuf->p;\n      *pn = pBuf->n;\n    }\n  }\n\n synonym_poslist_out:\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\n\n/*\n** All individual term iterators in pPhrase are guaranteed to be valid and\n** pointing to the same rowid when this function is called. This function \n** checks if the current rowid really is a match, and if so populates\n** the pPhrase->poslist buffer accordingly. Output parameter *pbMatch\n** is set to true if this is really a match, or false otherwise.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if the current rowid is \n** not a match.\n*/\nstatic int fts5ExprPhraseIsMatch(\n  Fts5ExprNode *pNode,            /* Node pPhrase belongs to */\n  Fts5ExprPhrase *pPhrase,        /* Phrase object to initialize */\n  int *pbMatch                    /* OUT: Set to true if really a match */\n){\n  Fts5PoslistWriter writer = {0};\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int i;\n  int rc = SQLITE_OK;\n  \n  fts5BufferZero(&pPhrase->poslist);\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pPhrase->nTerm>ArraySize(aStatic) ){\n    int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;\n    aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte);\n    if( !aIter ) return SQLITE_NOMEM;\n  }\n  memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);\n\n  /* Initialize a term iterator for each term in the phrase */\n  for(i=0; i<pPhrase->nTerm; i++){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n    int n = 0;\n    int bFlag = 0;\n    u8 *a = 0;\n    if( pTerm->pSynonym ){\n      Fts5Buffer buf = {0, 0, 0};\n      rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);\n      if( rc ){\n        sqlite3_free(a);\n        goto ismatch_out;\n      }\n      if( a==buf.p ) bFlag = 1;\n    }else{\n      a = (u8*)pTerm->pIter->pData;\n      n = pTerm->pIter->nData;\n    }\n    sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n    aIter[i].bFlag = (u8)bFlag;\n    if( aIter[i].bEof ) goto ismatch_out;\n  }\n\n  while( 1 ){\n    int bMatch;\n    i64 iPos = aIter[0].iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pPhrase->nTerm; i++){\n        Fts5PoslistReader *pPos = &aIter[i];\n        i64 iAdj = iPos + i;\n        if( pPos->iPos!=iAdj ){\n          bMatch = 0;\n          while( pPos->iPos<iAdj ){\n            if( sqlite3Fts5PoslistReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iAdj ) iPos = pPos->iPos-i;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Append position iPos to the output */\n    rc = sqlite3Fts5PoslistWriterAppend(&pPhrase->poslist, &writer, iPos);\n    if( rc!=SQLITE_OK ) goto ismatch_out;\n\n    for(i=0; i<pPhrase->nTerm; i++){\n      if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) goto ismatch_out;\n    }\n  }\n\n ismatch_out:\n  *pbMatch = (pPhrase->poslist.n>0);\n  for(i=0; i<pPhrase->nTerm; i++){\n    if( aIter[i].bFlag ) sqlite3_free((u8*)aIter[i].a);\n  }\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\ntypedef struct Fts5LookaheadReader Fts5LookaheadReader;\nstruct Fts5LookaheadReader {\n  const u8 *a;                    /* Buffer containing position list */\n  int n;                          /* Size of buffer a[] in bytes */\n  int i;                          /* Current offset in position list */\n  i64 iPos;                       /* Current position */\n  i64 iLookahead;                 /* Next position */\n};\n\n#define FTS5_LOOKAHEAD_EOF (((i64)1) << 62)\n\nstatic int fts5LookaheadReaderNext(Fts5LookaheadReader *p){\n  p->iPos = p->iLookahead;\n  if( sqlite3Fts5PoslistNext64(p->a, p->n, &p->i, &p->iLookahead) ){\n    p->iLookahead = FTS5_LOOKAHEAD_EOF;\n  }\n  return (p->iPos==FTS5_LOOKAHEAD_EOF);\n}\n\nstatic int fts5LookaheadReaderInit(\n  const u8 *a, int n,             /* Buffer to read position list from */\n  Fts5LookaheadReader *p          /* Iterator object to initialize */\n){\n  memset(p, 0, sizeof(Fts5LookaheadReader));\n  p->a = a;\n  p->n = n;\n  fts5LookaheadReaderNext(p);\n  return fts5LookaheadReaderNext(p);\n}\n\ntypedef struct Fts5NearTrimmer Fts5NearTrimmer;\nstruct Fts5NearTrimmer {\n  Fts5LookaheadReader reader;     /* Input iterator */\n  Fts5PoslistWriter writer;       /* Writer context */\n  Fts5Buffer *pOut;               /* Output poslist */\n};\n\n/*\n** The near-set object passed as the first argument contains more than\n** one phrase. All phrases currently point to the same row. The\n** Fts5ExprPhrase.poslist buffers are populated accordingly. This function\n** tests if the current row contains instances of each phrase sufficiently\n** close together to meet the NEAR constraint. Non-zero is returned if it\n** does, or zero otherwise.\n**\n** If in/out parameter (*pRc) is set to other than SQLITE_OK when this\n** function is called, it is a no-op. Or, if an error (e.g. SQLITE_NOMEM)\n** occurs within this function (*pRc) is set accordingly before returning.\n** The return value is undefined in both these cases.\n** \n** If no error occurs and non-zero (a match) is returned, the position-list\n** of each phrase object is edited to contain only those entries that\n** meet the constraint before returning.\n*/\nstatic int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){\n  Fts5NearTrimmer aStatic[4];\n  Fts5NearTrimmer *a = aStatic;\n  Fts5ExprPhrase **apPhrase = pNear->apPhrase;\n\n  int i;\n  int rc = *pRc;\n  int bMatch;\n\n  assert( pNear->nPhrase>1 );\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pNear->nPhrase>ArraySize(aStatic) ){\n    int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;\n    a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);\n  }else{\n    memset(aStatic, 0, sizeof(aStatic));\n  }\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return 0;\n  }\n\n  /* Initialize a lookahead iterator for each phrase. After passing the\n  ** buffer and buffer size to the lookaside-reader init function, zero\n  ** the phrase poslist buffer. The new poslist for the phrase (containing\n  ** the same entries as the original with some entries removed on account \n  ** of the NEAR constraint) is written over the original even as it is\n  ** being read. This is safe as the entries for the new poslist are a\n  ** subset of the old, so it is not possible for data yet to be read to\n  ** be overwritten.  */\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5Buffer *pPoslist = &apPhrase[i]->poslist;\n    fts5LookaheadReaderInit(pPoslist->p, pPoslist->n, &a[i].reader);\n    pPoslist->n = 0;\n    a[i].pOut = pPoslist;\n  }\n\n  while( 1 ){\n    int iAdv;\n    i64 iMin;\n    i64 iMax;\n\n    /* This block advances the phrase iterators until they point to a set of\n    ** entries that together comprise a match.  */\n    iMax = a[0].reader.iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pNear->nPhrase; i++){\n        Fts5LookaheadReader *pPos = &a[i].reader;\n        iMin = iMax - pNear->apPhrase[i]->nTerm - pNear->nNear;\n        if( pPos->iPos<iMin || pPos->iPos>iMax ){\n          bMatch = 0;\n          while( pPos->iPos<iMin ){\n            if( fts5LookaheadReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iMax ) iMax = pPos->iPos;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Add an entry to each output position list */\n    for(i=0; i<pNear->nPhrase; i++){\n      i64 iPos = a[i].reader.iPos;\n      Fts5PoslistWriter *pWriter = &a[i].writer;\n      if( a[i].pOut->n==0 || iPos!=pWriter->iPrev ){\n        sqlite3Fts5PoslistWriterAppend(a[i].pOut, pWriter, iPos);\n      }\n    }\n\n    iAdv = 0;\n    iMin = a[0].reader.iLookahead;\n    for(i=0; i<pNear->nPhrase; i++){\n      if( a[i].reader.iLookahead < iMin ){\n        iMin = a[i].reader.iLookahead;\n        iAdv = i;\n      }\n    }\n    if( fts5LookaheadReaderNext(&a[iAdv].reader) ) goto ismatch_out;\n  }\n\n  ismatch_out: {\n    int bRet = a[0].pOut->n>0;\n    *pRc = rc;\n    if( a!=aStatic ) sqlite3_free(a);\n    return bRet;\n  }\n}\n\n/*\n** Advance iterator pIter until it points to a value equal to or laster\n** than the initial value of *piLast. If this means the iterator points\n** to a value laster than *piLast, update *piLast to the new lastest value.\n**\n** If the iterator reaches EOF, set *pbEof to true before returning. If\n** an error occurs, set *pRc to an error code. If either *pbEof or *pRc\n** are set, return a non-zero value. Otherwise, return zero.\n*/\nstatic int fts5ExprAdvanceto(\n  Fts5IndexIter *pIter,           /* Iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc,                       /* OUT: Error code */\n  int *pbEof                      /* OUT: Set to true if EOF */\n){\n  i64 iLast = *piLast;\n  i64 iRowid;\n\n  iRowid = pIter->iRowid;\n  if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n    int rc = sqlite3Fts5IterNextFrom(pIter, iLast);\n    if( rc || sqlite3Fts5IterEof(pIter) ){\n      *pRc = rc;\n      *pbEof = 1;\n      return 1;\n    }\n    iRowid = pIter->iRowid;\n    assert( (bDesc==0 && iRowid>=iLast) || (bDesc==1 && iRowid<=iLast) );\n  }\n  *piLast = iRowid;\n\n  return 0;\n}\n\nstatic int fts5ExprSynonymAdvanceto(\n  Fts5ExprTerm *pTerm,            /* Term iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc                        /* OUT: Error code */\n){\n  int rc = SQLITE_OK;\n  i64 iLast = *piLast;\n  Fts5ExprTerm *p;\n  int bEof = 0;\n\n  for(p=pTerm; rc==SQLITE_OK && p; p=p->pSynonym){\n    if( sqlite3Fts5IterEof(p->pIter)==0 ){\n      i64 iRowid = p->pIter->iRowid;\n      if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n        rc = sqlite3Fts5IterNextFrom(p->pIter, iLast);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    bEof = 1;\n  }else{\n    *piLast = fts5ExprSynonymRowid(pTerm, bDesc, &bEof);\n  }\n  return bEof;\n}\n\n\nstatic int fts5ExprNearTest(\n  int *pRc,\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_STRING) */\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int rc = *pRc;\n\n  if( pExpr->pConfig->eDetail!=FTS5_DETAIL_FULL ){\n    Fts5ExprTerm *pTerm;\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];\n    pPhrase->poslist.n = 0;\n    for(pTerm=&pPhrase->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      Fts5IndexIter *pIter = pTerm->pIter;\n      if( sqlite3Fts5IterEof(pIter)==0 ){\n        if( pIter->iRowid==pNode->iRowid && pIter->nData>0 ){\n          pPhrase->poslist.n = 1;\n        }\n      }\n    }\n    return pPhrase->poslist.n;\n  }else{\n    int i;\n\n    /* Check that each phrase in the nearset matches the current row.\n    ** Populate the pPhrase->poslist buffers at the same time. If any\n    ** phrase is not a match, break out of the loop early.  */\n    for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){\n        int bMatch = 0;\n        rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);\n        if( bMatch==0 ) break;\n      }else{\n        Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n        fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);\n      }\n    }\n\n    *pRc = rc;\n    if( i==pNear->nPhrase && (i==1 || fts5ExprNearIsMatch(pRc, pNear)) ){\n      return 1;\n    }\n    return 0;\n  }\n}\n\n\n/*\n** Initialize all term iterators in the pNear object. If any term is found\n** to match no documents at all, return immediately without initializing any\n** further iterators.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return\n** SQLITE_OK. It is not considered an error if some term matches zero\n** documents.\n*/\nstatic int fts5ExprNearInitAll(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int i;\n\n  assert( pNode->bNomatch==0 );\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n    if( pPhrase->nTerm==0 ){\n      pNode->bEof = 1;\n      return SQLITE_OK;\n    }else{\n      int j;\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        Fts5ExprTerm *p;\n        int bHit = 0;\n\n        for(p=pTerm; p; p=p->pSynonym){\n          int rc;\n          if( p->pIter ){\n            sqlite3Fts5IterClose(p->pIter);\n            p->pIter = 0;\n          }\n          rc = sqlite3Fts5IndexQuery(\n              pExpr->pIndex, p->zTerm, (int)strlen(p->zTerm),\n              (pTerm->bPrefix ? FTS5INDEX_QUERY_PREFIX : 0) |\n              (pExpr->bDesc ? FTS5INDEX_QUERY_DESC : 0),\n              pNear->pColset,\n              &p->pIter\n          );\n          assert( (rc==SQLITE_OK)==(p->pIter!=0) );\n          if( rc!=SQLITE_OK ) return rc;\n          if( 0==sqlite3Fts5IterEof(p->pIter) ){\n            bHit = 1;\n          }\n        }\n\n        if( bHit==0 ){\n          pNode->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n    }\n  }\n\n  pNode->bEof = 0;\n  return SQLITE_OK;\n}\n\n/*\n** If pExpr is an ASC iterator, this function returns a value with the\n** same sign as:\n**\n**   (iLhs - iRhs)\n**\n** Otherwise, if this is a DESC iterator, the opposite is returned:\n**\n**   (iRhs - iLhs)\n*/\nstatic int fts5RowidCmp(\n  Fts5Expr *pExpr,\n  i64 iLhs,\n  i64 iRhs\n){\n  assert( pExpr->bDesc==0 || pExpr->bDesc==1 );\n  if( pExpr->bDesc==0 ){\n    if( iLhs<iRhs ) return -1;\n    return (iLhs > iRhs);\n  }else{\n    if( iLhs>iRhs ) return -1;\n    return (iLhs < iRhs);\n  }\n}\n\nstatic void fts5ExprSetEof(Fts5ExprNode *pNode){\n  int i;\n  pNode->bEof = 1;\n  pNode->bNomatch = 0;\n  for(i=0; i<pNode->nChild; i++){\n    fts5ExprSetEof(pNode->apChild[i]);\n  }\n}\n\nstatic void fts5ExprNodeZeroPoslist(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pNode->pNear;\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      pPhrase->poslist.n = 0;\n    }\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprNodeZeroPoslist(pNode->apChild[i]);\n    }\n  }\n}\n\n\n\n/*\n** Compare the values currently indicated by the two nodes as follows:\n**\n**    res = (*p1) - (*p2)\n**\n** Nodes that point to values that come later in the iteration order are\n** considered to be larger. Nodes at EOF are the largest of all.\n**\n** This means that if the iteration order is ASC, then numerically larger\n** rowids are considered larger. Or if it is the default DESC, numerically\n** smaller rowids are larger.\n*/\nstatic int fts5NodeCompare(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *p1, \n  Fts5ExprNode *p2\n){\n  if( p2->bEof ) return -1;\n  if( p1->bEof ) return +1;\n  return fts5RowidCmp(pExpr, p1->iRowid, p2->iRowid);\n}\n\n/*\n** All individual term iterators in pNear are guaranteed to be valid when\n** this function is called. This function checks if all term iterators\n** point to the same rowid, and if not, advances them until they do.\n** If an EOF is reached before this happens, *pbEof is set to true before\n** returning.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if an iterator reaches\n** EOF.\n*/\nstatic int fts5ExprNodeTest_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  Fts5ExprPhrase *pLeft = pNear->apPhrase[0];\n  int rc = SQLITE_OK;\n  i64 iLast;                      /* Lastest rowid any iterator points to */\n  int i, j;                       /* Phrase and token index, respectively */\n  int bMatch;                     /* True if all terms are at the same rowid */\n  const int bDesc = pExpr->bDesc;\n\n  /* Check that this node should not be FTS5_TERM */\n  assert( pNear->nPhrase>1 \n       || pNear->apPhrase[0]->nTerm>1 \n       || pNear->apPhrase[0]->aTerm[0].pSynonym\n  );\n\n  /* Initialize iLast, the \"lastest\" rowid any iterator points to. If the\n  ** iterator skips through rowids in the default ascending order, this means\n  ** the maximum rowid. Or, if the iterator is \"ORDER BY rowid DESC\", then it\n  ** means the minimum rowid.  */\n  if( pLeft->aTerm[0].pSynonym ){\n    iLast = fts5ExprSynonymRowid(&pLeft->aTerm[0], bDesc, 0);\n  }else{\n    iLast = pLeft->aTerm[0].pIter->iRowid;\n  }\n\n  do {\n    bMatch = 1;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        if( pTerm->pSynonym ){\n          i64 iRowid = fts5ExprSynonymRowid(pTerm, bDesc, 0);\n          if( iRowid==iLast ) continue;\n          bMatch = 0;\n          if( fts5ExprSynonymAdvanceto(pTerm, bDesc, &iLast, &rc) ){\n            pNode->bNomatch = 0;\n            pNode->bEof = 1;\n            return rc;\n          }\n        }else{\n          Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter;\n          if( pIter->iRowid==iLast || pIter->bEof ) continue;\n          bMatch = 0;\n          if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){\n            return rc;\n          }\n        }\n      }\n    }\n  }while( bMatch==0 );\n\n  pNode->iRowid = iLast;\n  pNode->bNomatch = ((0==fts5ExprNearTest(&rc, pExpr, pNode)) && rc==SQLITE_OK);\n  assert( pNode->bEof==0 || pNode->bNomatch==0 );\n\n  return rc;\n}\n\n/*\n** Advance the first term iterator in the first phrase of pNear. Set output\n** variable *pbEof to true if it reaches EOF or if an error occurs.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5ExprNodeNext_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode,            /* FTS5_STRING or FTS5_TERM node */\n  int bFromValid,\n  i64 iFrom \n){\n  Fts5ExprTerm *pTerm = &pNode->pNear->apPhrase[0]->aTerm[0];\n  int rc = SQLITE_OK;\n\n  pNode->bNomatch = 0;\n  if( pTerm->pSynonym ){\n    int bEof = 1;\n    Fts5ExprTerm *p;\n\n    /* Find the firstest rowid any synonym points to. */\n    i64 iRowid = fts5ExprSynonymRowid(pTerm, pExpr->bDesc, 0);\n\n    /* Advance each iterator that currently points to iRowid. Or, if iFrom\n    ** is valid - each iterator that points to a rowid before iFrom.  */\n    for(p=pTerm; p; p=p->pSynonym){\n      if( sqlite3Fts5IterEof(p->pIter)==0 ){\n        i64 ii = p->pIter->iRowid;\n        if( ii==iRowid \n         || (bFromValid && ii!=iFrom && (ii>iFrom)==pExpr->bDesc) \n        ){\n          if( bFromValid ){\n            rc = sqlite3Fts5IterNextFrom(p->pIter, iFrom);\n          }else{\n            rc = sqlite3Fts5IterNext(p->pIter);\n          }\n          if( rc!=SQLITE_OK ) break;\n          if( sqlite3Fts5IterEof(p->pIter)==0 ){\n            bEof = 0;\n          }\n        }else{\n          bEof = 0;\n        }\n      }\n    }\n\n    /* Set the EOF flag if either all synonym iterators are at EOF or an\n    ** error has occurred.  */\n    pNode->bEof = (rc || bEof);\n  }else{\n    Fts5IndexIter *pIter = pTerm->pIter;\n\n    assert( Fts5NodeIsString(pNode) );\n    if( bFromValid ){\n      rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n    }else{\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n\n    pNode->bEof = (rc || sqlite3Fts5IterEof(pIter));\n  }\n\n  if( pNode->bEof==0 ){\n    assert( rc==SQLITE_OK );\n    rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ExprNodeTest_TERM(\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_TERM) */\n){\n  /* As this \"NEAR\" object is actually a single phrase that consists \n  ** of a single term only, grab pointers into the poslist managed by the\n  ** fts5_index.c iterator object. This is much faster than synthesizing \n  ** a new poslist the way we have to for more complicated phrase or NEAR\n  ** expressions.  */\n  Fts5ExprPhrase *pPhrase = pNode->pNear->apPhrase[0];\n  Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n\n  assert( pNode->eType==FTS5_TERM );\n  assert( pNode->pNear->nPhrase==1 && pPhrase->nTerm==1 );\n  assert( pPhrase->aTerm[0].pSynonym==0 );\n\n  pPhrase->poslist.n = pIter->nData;\n  if( pExpr->pConfig->eDetail==FTS5_DETAIL_FULL ){\n    pPhrase->poslist.p = (u8*)pIter->pData;\n  }\n  pNode->iRowid = pIter->iRowid;\n  pNode->bNomatch = (pPhrase->poslist.n==0);\n  return SQLITE_OK;\n}\n\n/*\n** xNext() method for a node of type FTS5_TERM.\n*/\nstatic int fts5ExprNodeNext_TERM(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc;\n  Fts5IndexIter *pIter = pNode->pNear->apPhrase[0]->aTerm[0].pIter;\n\n  assert( pNode->bEof==0 );\n  if( bFromValid ){\n    rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n  }else{\n    rc = sqlite3Fts5IterNext(pIter);\n  }\n  if( rc==SQLITE_OK && sqlite3Fts5IterEof(pIter)==0 ){\n    rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n  }else{\n    pNode->bEof = 1;\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic void fts5ExprNodeTest_OR(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  Fts5ExprNode *pNext = pNode->apChild[0];\n  int i;\n\n  for(i=1; i<pNode->nChild; i++){\n    Fts5ExprNode *pChild = pNode->apChild[i];\n    int cmp = fts5NodeCompare(pExpr, pNext, pChild);\n    if( cmp>0 || (cmp==0 && pChild->bNomatch==0) ){\n      pNext = pChild;\n    }\n  }\n  pNode->iRowid = pNext->iRowid;\n  pNode->bEof = pNext->bEof;\n  pNode->bNomatch = pNext->bNomatch;\n}\n\nstatic int fts5ExprNodeNext_OR(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int i;\n  i64 iLast = pNode->iRowid;\n\n  for(i=0; i<pNode->nChild; i++){\n    Fts5ExprNode *p1 = pNode->apChild[i];\n    assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );\n    if( p1->bEof==0 ){\n      if( (p1->iRowid==iLast) \n       || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)\n      ){\n        int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);\n        if( rc!=SQLITE_OK ){\n          pNode->bNomatch = 0;\n          return rc;\n        }\n      }\n    }\n  }\n\n  fts5ExprNodeTest_OR(pExpr, pNode);\n  return SQLITE_OK;\n}\n\n/*\n** Argument pNode is an FTS5_AND node.\n*/\nstatic int fts5ExprNodeTest_AND(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pAnd              /* FTS5_AND node to advance */\n){\n  int iChild;\n  i64 iLast = pAnd->iRowid;\n  int rc = SQLITE_OK;\n  int bMatch;\n\n  assert( pAnd->bEof==0 );\n  do {\n    pAnd->bNomatch = 0;\n    bMatch = 1;\n    for(iChild=0; iChild<pAnd->nChild; iChild++){\n      Fts5ExprNode *pChild = pAnd->apChild[iChild];\n      int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);\n      if( cmp>0 ){\n        /* Advance pChild until it points to iLast or laster */\n        rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);\n        if( rc!=SQLITE_OK ){\n          pAnd->bNomatch = 0;\n          return rc;\n        }\n      }\n\n      /* If the child node is now at EOF, so is the parent AND node. Otherwise,\n      ** the child node is guaranteed to have advanced at least as far as\n      ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the\n      ** new lastest rowid seen so far.  */\n      assert( pChild->bEof || fts5RowidCmp(pExpr, iLast, pChild->iRowid)<=0 );\n      if( pChild->bEof ){\n        fts5ExprSetEof(pAnd);\n        bMatch = 1;\n        break;\n      }else if( iLast!=pChild->iRowid ){\n        bMatch = 0;\n        iLast = pChild->iRowid;\n      }\n\n      if( pChild->bNomatch ){\n        pAnd->bNomatch = 1;\n      }\n    }\n  }while( bMatch==0 );\n\n  if( pAnd->bNomatch && pAnd!=pExpr->pRoot ){\n    fts5ExprNodeZeroPoslist(pAnd);\n  }\n  pAnd->iRowid = iLast;\n  return SQLITE_OK;\n}\n\nstatic int fts5ExprNodeNext_AND(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_AND(pExpr, pNode);\n  }else{\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeTest_NOT(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode             /* FTS5_NOT node to advance */\n){\n  int rc = SQLITE_OK;\n  Fts5ExprNode *p1 = pNode->apChild[0];\n  Fts5ExprNode *p2 = pNode->apChild[1];\n  assert( pNode->nChild==2 );\n\n  while( rc==SQLITE_OK && p1->bEof==0 ){\n    int cmp = fts5NodeCompare(pExpr, p1, p2);\n    if( cmp>0 ){\n      rc = fts5ExprNodeNext(pExpr, p2, 1, p1->iRowid);\n      cmp = fts5NodeCompare(pExpr, p1, p2);\n    }\n    assert( rc!=SQLITE_OK || cmp<=0 );\n    if( cmp || p2->bNomatch ) break;\n    rc = fts5ExprNodeNext(pExpr, p1, 0, 0);\n  }\n  pNode->bEof = p1->bEof;\n  pNode->bNomatch = p1->bNomatch;\n  pNode->iRowid = p1->iRowid;\n  if( p1->bEof ){\n    fts5ExprNodeZeroPoslist(p2);\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeNext_NOT(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n  }\n  if( rc!=SQLITE_OK ){\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\n/*\n** If pNode currently points to a match, this function returns SQLITE_OK\n** without modifying it. Otherwise, pNode is advanced until it does point\n** to a match or EOF is reached.\n*/\nstatic int fts5ExprNodeTest(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  int rc = SQLITE_OK;\n  if( pNode->bEof==0 ){\n    switch( pNode->eType ){\n\n      case FTS5_STRING: {\n        rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_TERM: {\n        rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_AND: {\n        rc = fts5ExprNodeTest_AND(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_OR: {\n        fts5ExprNodeTest_OR(pExpr, pNode);\n        break;\n      }\n\n      default: assert( pNode->eType==FTS5_NOT ); {\n        rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n \n/*\n** Set node pNode, which is part of expression pExpr, to point to the first\n** match. If there are no matches, set the Node.bEof flag to indicate EOF.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n** It is not an error if there are no matches.\n*/\nstatic int fts5ExprNodeFirst(Fts5Expr *pExpr, Fts5ExprNode *pNode){\n  int rc = SQLITE_OK;\n  pNode->bEof = 0;\n  pNode->bNomatch = 0;\n\n  if( Fts5NodeIsString(pNode) ){\n    /* Initialize all term iterators in the NEAR object. */\n    rc = fts5ExprNearInitAll(pExpr, pNode);\n  }else if( pNode->xNext==0 ){\n    pNode->bEof = 1;\n  }else{\n    int i;\n    int nEof = 0;\n    for(i=0; i<pNode->nChild && rc==SQLITE_OK; i++){\n      Fts5ExprNode *pChild = pNode->apChild[i];\n      rc = fts5ExprNodeFirst(pExpr, pNode->apChild[i]);\n      assert( pChild->bEof==0 || pChild->bEof==1 );\n      nEof += pChild->bEof;\n    }\n    pNode->iRowid = pNode->apChild[0]->iRowid;\n\n    switch( pNode->eType ){\n      case FTS5_AND:\n        if( nEof>0 ) fts5ExprSetEof(pNode);\n        break;\n\n      case FTS5_OR:\n        if( pNode->nChild==nEof ) fts5ExprSetEof(pNode);\n        break;\n\n      default:\n        assert( pNode->eType==FTS5_NOT );\n        pNode->bEof = pNode->apChild[0]->bEof;\n        break;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest(pExpr, pNode);\n  }\n  return rc;\n}\n\n\n/*\n** Begin iterating through the set of documents in index pIdx matched by\n** the MATCH expression passed as the first argument. If the \"bDesc\" \n** parameter is passed a non-zero value, iteration is in descending rowid \n** order. Or, if it is zero, in ascending order.\n**\n** If iterating in ascending rowid order (bDesc==0), the first document\n** visited is that with the smallest rowid that is larger than or equal\n** to parameter iFirst. Or, if iterating in ascending order (bDesc==1),\n** then the first document visited must have a rowid smaller than or\n** equal to iFirst.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nint sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){\n  Fts5ExprNode *pRoot = p->pRoot;\n  int rc;                         /* Return code */\n\n  p->pIndex = pIdx;\n  p->bDesc = bDesc;\n  rc = fts5ExprNodeFirst(p, pRoot);\n\n  /* If not at EOF but the current rowid occurs earlier than iFirst in\n  ** the iteration order, move to document iFirst or later. */\n  if( rc==SQLITE_OK \n   && 0==pRoot->bEof \n   && fts5RowidCmp(p, pRoot->iRowid, iFirst)<0 \n  ){\n    rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);\n  }\n\n  /* If the iterator is not at a real match, skip forward until it is. */\n  while( pRoot->bNomatch ){\n    assert( pRoot->bEof==0 && rc==SQLITE_OK );\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n  }\n  return rc;\n}\n\n/*\n** Move to the next document \n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nint sqlite3Fts5ExprNext(Fts5Expr *p, i64 iLast){\n  int rc;\n  Fts5ExprNode *pRoot = p->pRoot;\n  assert( pRoot->bEof==0 && pRoot->bNomatch==0 );\n  do {\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n    assert( pRoot->bNomatch==0 || (rc==SQLITE_OK && pRoot->bEof==0) );\n  }while( pRoot->bNomatch );\n  if( fts5RowidCmp(p, pRoot->iRowid, iLast)>0 ){\n    pRoot->bEof = 1;\n  }\n  return rc;\n}\n\nint sqlite3Fts5ExprEof(Fts5Expr *p){\n  return p->pRoot->bEof;\n}\n\ni64 sqlite3Fts5ExprRowid(Fts5Expr *p){\n  return p->pRoot->iRowid;\n}\n\nstatic int fts5ParseStringFromToken(Fts5Token *pToken, char **pz){\n  int rc = SQLITE_OK;\n  *pz = sqlite3Fts5Strndup(&rc, pToken->p, pToken->n);\n  return rc;\n}\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nstatic void fts5ExprPhraseFree(Fts5ExprPhrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    for(i=0; i<pPhrase->nTerm; i++){\n      Fts5ExprTerm *pSyn;\n      Fts5ExprTerm *pNext;\n      Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n      sqlite3_free(pTerm->zTerm);\n      sqlite3Fts5IterClose(pTerm->pIter);\n      for(pSyn=pTerm->pSynonym; pSyn; pSyn=pNext){\n        pNext = pSyn->pSynonym;\n        sqlite3Fts5IterClose(pSyn->pIter);\n        fts5BufferFree((Fts5Buffer*)&pSyn[1]);\n        sqlite3_free(pSyn);\n      }\n    }\n    if( pPhrase->poslist.nSpace>0 ) fts5BufferFree(&pPhrase->poslist);\n    sqlite3_free(pPhrase);\n  }\n}\n\n/*\n** If argument pNear is NULL, then a new Fts5ExprNearset object is allocated\n** and populated with pPhrase. Or, if pNear is not NULL, phrase pPhrase is\n** appended to it and the results returned.\n**\n** If an OOM error occurs, both the pNear and pPhrase objects are freed and\n** NULL returned.\n*/\nFts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNearset *pNear,         /* Existing nearset, or NULL */\n  Fts5ExprPhrase *pPhrase         /* Recently parsed phrase */\n){\n  const int SZALLOC = 8;\n  Fts5ExprNearset *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    if( pPhrase==0 ){\n      return pNear;\n    }\n    if( pNear==0 ){\n      int nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);\n      pRet = sqlite3_malloc(nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }else{\n        memset(pRet, 0, nByte);\n      }\n    }else if( (pNear->nPhrase % SZALLOC)==0 ){\n      int nNew = pNear->nPhrase + SZALLOC;\n      int nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);\n\n      pRet = (Fts5ExprNearset*)sqlite3_realloc(pNear, nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }\n    }else{\n      pRet = pNear;\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNearsetFree(pNear);\n    sqlite3Fts5ParsePhraseFree(pPhrase);\n  }else{\n    if( pRet->nPhrase>0 ){\n      Fts5ExprPhrase *pLast = pRet->apPhrase[pRet->nPhrase-1];\n      assert( pLast==pParse->apPhrase[pParse->nPhrase-2] );\n      if( pPhrase->nTerm==0 ){\n        fts5ExprPhraseFree(pPhrase);\n        pRet->nPhrase--;\n        pParse->nPhrase--;\n        pPhrase = pLast;\n      }else if( pLast->nTerm==0 ){\n        fts5ExprPhraseFree(pLast);\n        pParse->apPhrase[pParse->nPhrase-2] = pPhrase;\n        pParse->nPhrase--;\n        pRet->nPhrase--;\n      }\n    }\n    pRet->apPhrase[pRet->nPhrase++] = pPhrase;\n  }\n  return pRet;\n}\n\ntypedef struct TokenCtx TokenCtx;\nstruct TokenCtx {\n  Fts5ExprPhrase *pPhrase;\n  int rc;\n};\n\n/*\n** Callback for tokenizing terms used by ParseTerm().\n*/\nstatic int fts5ParseTokenize(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int rc = SQLITE_OK;\n  const int SZALLOC = 8;\n  TokenCtx *pCtx = (TokenCtx*)pContext;\n  Fts5ExprPhrase *pPhrase = pCtx->pPhrase;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  /* If an error has already occurred, this is a no-op */\n  if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){\n    Fts5ExprTerm *pSyn;\n    int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;\n    pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte);\n    if( pSyn==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pSyn, 0, nByte);\n      pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);\n      memcpy(pSyn->zTerm, pToken, nToken);\n      pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;\n      pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;\n    }\n  }else{\n    Fts5ExprTerm *pTerm;\n    if( pPhrase==0 || (pPhrase->nTerm % SZALLOC)==0 ){\n      Fts5ExprPhrase *pNew;\n      int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);\n\n      pNew = (Fts5ExprPhrase*)sqlite3_realloc(pPhrase, \n          sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew\n      );\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pPhrase==0 ) memset(pNew, 0, sizeof(Fts5ExprPhrase));\n        pCtx->pPhrase = pPhrase = pNew;\n        pNew->nTerm = nNew - SZALLOC;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      pTerm = &pPhrase->aTerm[pPhrase->nTerm++];\n      memset(pTerm, 0, sizeof(Fts5ExprTerm));\n      pTerm->zTerm = sqlite3Fts5Strndup(&rc, pToken, nToken);\n    }\n  }\n\n  pCtx->rc = rc;\n  return rc;\n}\n\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nvoid sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase *pPhrase){\n  fts5ExprPhraseFree(pPhrase);\n}\n\n/*\n** Free the phrase object passed as the second argument.\n*/\nvoid sqlite3Fts5ParseNearsetFree(Fts5ExprNearset *pNear){\n  if( pNear ){\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      fts5ExprPhraseFree(pNear->apPhrase[i]);\n    }\n    sqlite3_free(pNear->pColset);\n    sqlite3_free(pNear);\n  }\n}\n\nvoid sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p){\n  assert( pParse->pExpr==0 );\n  pParse->pExpr = p;\n}\n\n/*\n** This function is called by the parser to process a string token. The\n** string may or may not be quoted. In any case it is tokenized and a\n** phrase object consisting of all tokens returned.\n*/\nFts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprPhrase *pAppend,        /* Phrase to append to */\n  Fts5Token *pToken,              /* String to tokenize */\n  int bPrefix                     /* True if there is a trailing \"*\" */\n){\n  Fts5Config *pConfig = pParse->pConfig;\n  TokenCtx sCtx;                  /* Context object passed to callback */\n  int rc;                         /* Tokenize return code */\n  char *z = 0;\n\n  memset(&sCtx, 0, sizeof(TokenCtx));\n  sCtx.pPhrase = pAppend;\n\n  rc = fts5ParseStringFromToken(pToken, &z);\n  if( rc==SQLITE_OK ){\n    int flags = FTS5_TOKENIZE_QUERY | (bPrefix ? FTS5_TOKENIZE_PREFIX : 0);\n    int n;\n    sqlite3Fts5Dequote(z);\n    n = (int)strlen(z);\n    rc = sqlite3Fts5Tokenize(pConfig, flags, z, n, &sCtx, fts5ParseTokenize);\n  }\n  sqlite3_free(z);\n  if( rc || (rc = sCtx.rc) ){\n    pParse->rc = rc;\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    sCtx.pPhrase = 0;\n  }else{\n\n    if( pAppend==0 ){\n      if( (pParse->nPhrase % 8)==0 ){\n        int nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);\n        Fts5ExprPhrase **apNew;\n        apNew = (Fts5ExprPhrase**)sqlite3_realloc(pParse->apPhrase, nByte);\n        if( apNew==0 ){\n          pParse->rc = SQLITE_NOMEM;\n          fts5ExprPhraseFree(sCtx.pPhrase);\n          return 0;\n        }\n        pParse->apPhrase = apNew;\n      }\n      pParse->nPhrase++;\n    }\n\n    if( sCtx.pPhrase==0 ){\n      /* This happens when parsing a token or quoted phrase that contains\n      ** no token characters at all. (e.g ... MATCH '\"\"'). */\n      sCtx.pPhrase = sqlite3Fts5MallocZero(&pParse->rc, sizeof(Fts5ExprPhrase));\n    }else if( sCtx.pPhrase->nTerm ){\n      sCtx.pPhrase->aTerm[sCtx.pPhrase->nTerm-1].bPrefix = bPrefix;\n    }\n    pParse->apPhrase[pParse->nPhrase-1] = sCtx.pPhrase;\n  }\n\n  return sCtx.pPhrase;\n}\n\n/*\n** Create a new FTS5 expression by cloning phrase iPhrase of the\n** expression passed as the second argument.\n*/\nint sqlite3Fts5ExprClonePhrase(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  Fts5Expr **ppNew\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5ExprPhrase *pOrig;          /* The phrase extracted from pExpr */\n  Fts5Expr *pNew = 0;             /* Expression to return via *ppNew */\n  TokenCtx sCtx = {0,0};          /* Context object for fts5ParseTokenize */\n\n  pOrig = pExpr->apExprPhrase[iPhrase];\n  pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));\n  if( rc==SQLITE_OK ){\n    pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNode));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;\n    if( pColsetOrig ){\n      int nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);\n      Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);\n      if( pColset ){ \n        memcpy(pColset, pColsetOrig, nByte);\n      }\n      pNew->pRoot->pNear->pColset = pColset;\n    }\n  }\n\n  if( pOrig->nTerm ){\n    int i;                          /* Used to iterate through phrase terms */\n    for(i=0; rc==SQLITE_OK && i<pOrig->nTerm; i++){\n      int tflags = 0;\n      Fts5ExprTerm *p;\n      for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){\n        const char *zTerm = p->zTerm;\n        rc = fts5ParseTokenize((void*)&sCtx, tflags, zTerm, (int)strlen(zTerm),\n            0, 0);\n        tflags = FTS5_TOKEN_COLOCATED;\n      }\n      if( rc==SQLITE_OK ){\n        sCtx.pPhrase->aTerm[i].bPrefix = pOrig->aTerm[i].bPrefix;\n      }\n    }\n  }else{\n    /* This happens when parsing a token or quoted phrase that contains\n    ** no token characters at all. (e.g ... MATCH '\"\"'). */\n    sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));\n  }\n\n  if( rc==SQLITE_OK ){\n    /* All the allocations succeeded. Put the expression object together. */\n    pNew->pIndex = pExpr->pIndex;\n    pNew->pConfig = pExpr->pConfig;\n    pNew->nPhrase = 1;\n    pNew->apExprPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->apPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->nPhrase = 1;\n    sCtx.pPhrase->pNode = pNew->pRoot;\n\n    if( pOrig->nTerm==1 && pOrig->aTerm[0].pSynonym==0 ){\n      pNew->pRoot->eType = FTS5_TERM;\n      pNew->pRoot->xNext = fts5ExprNodeNext_TERM;\n    }else{\n      pNew->pRoot->eType = FTS5_STRING;\n      pNew->pRoot->xNext = fts5ExprNodeNext_STRING;\n    }\n  }else{\n    sqlite3Fts5ExprFree(pNew);\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    pNew = 0;\n  }\n\n  *ppNew = pNew;\n  return rc;\n}\n\n\n/*\n** Token pTok has appeared in a MATCH expression where the NEAR operator\n** is expected. If token pTok does not contain \"NEAR\", store an error\n** in the pParse object.\n*/\nvoid sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token *pTok){\n  if( pTok->n!=4 || memcmp(\"NEAR\", pTok->p, 4) ){\n    sqlite3Fts5ParseError(\n        pParse, \"fts5: syntax error near \\\"%.*s\\\"\", pTok->n, pTok->p\n    );\n  }\n}\n\nvoid sqlite3Fts5ParseSetDistance(\n  Fts5Parse *pParse, \n  Fts5ExprNearset *pNear,\n  Fts5Token *p\n){\n  if( pNear ){\n    int nNear = 0;\n    int i;\n    if( p->n ){\n      for(i=0; i<p->n; i++){\n        char c = (char)p->p[i];\n        if( c<'0' || c>'9' ){\n          sqlite3Fts5ParseError(\n              pParse, \"expected integer, got \\\"%.*s\\\"\", p->n, p->p\n              );\n          return;\n        }\n        nNear = nNear * 10 + (p->p[i] - '0');\n      }\n    }else{\n      nNear = FTS5_DEFAULT_NEARDIST;\n    }\n    pNear->nNear = nNear;\n  }\n}\n\n/*\n** The second argument passed to this function may be NULL, or it may be\n** an existing Fts5Colset object. This function returns a pointer to\n** a new colset object containing the contents of (p) with new value column\n** number iCol appended. \n**\n** If an OOM error occurs, store an error code in pParse and return NULL.\n** The old colset object (if any) is not freed in this case.\n*/\nstatic Fts5Colset *fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *p,                  /* Existing colset object */\n  int iCol                        /* New column to add to colset object */\n){\n  int nCol = p ? p->nCol : 0;     /* Num. columns already in colset object */\n  Fts5Colset *pNew;               /* New colset object to return */\n\n  assert( pParse->rc==SQLITE_OK );\n  assert( iCol>=0 && iCol<pParse->pConfig->nCol );\n\n  pNew = sqlite3_realloc(p, sizeof(Fts5Colset) + sizeof(int)*nCol);\n  if( pNew==0 ){\n    pParse->rc = SQLITE_NOMEM;\n  }else{\n    int *aiCol = pNew->aiCol;\n    int i, j;\n    for(i=0; i<nCol; i++){\n      if( aiCol[i]==iCol ) return pNew;\n      if( aiCol[i]>iCol ) break;\n    }\n    for(j=nCol; j>i; j--){\n      aiCol[j] = aiCol[j-1];\n    }\n    aiCol[i] = iCol;\n    pNew->nCol = nCol+1;\n\n#ifndef NDEBUG\n    /* Check that the array is in order and contains no duplicate entries. */\n    for(i=1; i<pNew->nCol; i++) assert( pNew->aiCol[i]>pNew->aiCol[i-1] );\n#endif\n  }\n\n  return pNew;\n}\n\n/*\n** Allocate and return an Fts5Colset object specifying the inverse of\n** the colset passed as the second argument. Free the colset passed\n** as the second argument before returning.\n*/\nFts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){\n  Fts5Colset *pRet;\n  int nCol = pParse->pConfig->nCol;\n\n  pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, \n      sizeof(Fts5Colset) + sizeof(int)*nCol\n  );\n  if( pRet ){\n    int i;\n    int iOld = 0;\n    for(i=0; i<nCol; i++){\n      if( iOld>=p->nCol || p->aiCol[iOld]!=i ){\n        pRet->aiCol[pRet->nCol++] = i;\n      }else{\n        iOld++;\n      }\n    }\n  }\n\n  sqlite3_free(p);\n  return pRet;\n}\n\nFts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *pColset,            /* Existing colset object */\n  Fts5Token *p\n){\n  Fts5Colset *pRet = 0;\n  int iCol;\n  char *z;                        /* Dequoted copy of token p */\n\n  z = sqlite3Fts5Strndup(&pParse->rc, p->p, p->n);\n  if( pParse->rc==SQLITE_OK ){\n    Fts5Config *pConfig = pParse->pConfig;\n    sqlite3Fts5Dequote(z);\n    for(iCol=0; iCol<pConfig->nCol; iCol++){\n      if( 0==sqlite3_stricmp(pConfig->azCol[iCol], z) ) break;\n    }\n    if( iCol==pConfig->nCol ){\n      sqlite3Fts5ParseError(pParse, \"no such column: %s\", z);\n    }else{\n      pRet = fts5ParseColset(pParse, pColset, iCol);\n    }\n    sqlite3_free(z);\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3_free(pColset);\n  }\n\n  return pRet;\n}\n\n/*\n** If argument pOrig is NULL, or if (*pRc) is set to anything other than\n** SQLITE_OK when this function is called, NULL is returned. \n**\n** Otherwise, a copy of (*pOrig) is made into memory obtained from\n** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation\n** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned.\n*/\nstatic Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){\n  Fts5Colset *pRet;\n  if( pOrig ){\n    int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);\n    pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);\n    if( pRet ){ \n      memcpy(pRet, pOrig, nByte);\n    }\n  }else{\n    pRet = 0;\n  }\n  return pRet;\n}\n\n/*\n** Remove from colset pColset any columns that are not also in colset pMerge.\n*/\nstatic void fts5MergeColset(Fts5Colset *pColset, Fts5Colset *pMerge){\n  int iIn = 0;          /* Next input in pColset */\n  int iMerge = 0;       /* Next input in pMerge */\n  int iOut = 0;         /* Next output slot in pColset */\n\n  while( iIn<pColset->nCol && iMerge<pMerge->nCol ){\n    int iDiff = pColset->aiCol[iIn] - pMerge->aiCol[iMerge];\n    if( iDiff==0 ){\n      pColset->aiCol[iOut++] = pMerge->aiCol[iMerge];\n      iMerge++;\n      iIn++;\n    }else if( iDiff>0 ){\n      iMerge++;\n    }else{\n      iIn++;\n    }\n  }\n  pColset->nCol = iOut;\n}\n\n/*\n** Recursively apply colset pColset to expression node pNode and all of\n** its decendents. If (*ppFree) is not NULL, it contains a spare copy\n** of pColset. This function may use the spare copy and set (*ppFree) to\n** zero, or it may create copies of pColset using fts5CloneColset().\n*/\nstatic void fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pNode, \n  Fts5Colset *pColset,\n  Fts5Colset **ppFree\n){\n  if( pParse->rc==SQLITE_OK ){\n    assert( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING \n         || pNode->eType==FTS5_AND  || pNode->eType==FTS5_OR\n         || pNode->eType==FTS5_NOT  || pNode->eType==FTS5_EOF\n    );\n    if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->pColset ){\n        fts5MergeColset(pNear->pColset, pColset);\n        if( pNear->pColset->nCol==0 ){\n          pNode->eType = FTS5_EOF;\n          pNode->xNext = 0;\n        }\n      }else if( *ppFree ){\n        pNear->pColset = pColset;\n        *ppFree = 0;\n      }else{\n        pNear->pColset = fts5CloneColset(&pParse->rc, pColset);\n      }\n    }else{\n      int i;\n      assert( pNode->eType!=FTS5_EOF || pNode->nChild==0 );\n      for(i=0; i<pNode->nChild; i++){\n        fts5ParseSetColset(pParse, pNode->apChild[i], pColset, ppFree);\n      }\n    }\n  }\n}\n\n/*\n** Apply colset pColset to expression node pExpr and all of its descendents.\n*/\nvoid sqlite3Fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pExpr, \n  Fts5Colset *pColset \n){\n  Fts5Colset *pFree = pColset;\n  if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pParse->rc = SQLITE_ERROR;\n    pParse->zErr = sqlite3_mprintf(\n      \"fts5: column queries are not supported (detail=none)\"\n    );\n  }else{\n    fts5ParseSetColset(pParse, pExpr, pColset, &pFree);\n  }\n  sqlite3_free(pFree);\n}\n\nstatic void fts5ExprAssignXNext(Fts5ExprNode *pNode){\n  switch( pNode->eType ){\n    case FTS5_STRING: {\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->nPhrase==1 && pNear->apPhrase[0]->nTerm==1 \n       && pNear->apPhrase[0]->aTerm[0].pSynonym==0\n      ){\n        pNode->eType = FTS5_TERM;\n        pNode->xNext = fts5ExprNodeNext_TERM;\n      }else{\n        pNode->xNext = fts5ExprNodeNext_STRING;\n      }\n      break;\n    };\n\n    case FTS5_OR: {\n      pNode->xNext = fts5ExprNodeNext_OR;\n      break;\n    };\n\n    case FTS5_AND: {\n      pNode->xNext = fts5ExprNodeNext_AND;\n      break;\n    };\n\n    default: assert( pNode->eType==FTS5_NOT ); {\n      pNode->xNext = fts5ExprNodeNext_NOT;\n      break;\n    };\n  }\n}\n\nstatic void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){\n  if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){\n    int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;\n    memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);\n    p->nChild += pSub->nChild;\n    sqlite3_free(pSub);\n  }else{\n    p->apChild[p->nChild++] = pSub;\n  }\n}\n\n/*\n** Allocate and return a new expression object. If anything goes wrong (i.e.\n** OOM error), leave an error code in pParse and return NULL.\n*/\nFts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,              /* Parse context */\n  int eType,                      /* FTS5_STRING, AND, OR or NOT */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight,           /* Right hand child expression */\n  Fts5ExprNearset *pNear          /* For STRING expressions, the near cluster */\n){\n  Fts5ExprNode *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    int nChild = 0;               /* Number of children of returned node */\n    int nByte;                    /* Bytes of space to allocate for this node */\n \n    assert( (eType!=FTS5_STRING && !pNear)\n         || (eType==FTS5_STRING && !pLeft && !pRight)\n    );\n    if( eType==FTS5_STRING && pNear==0 ) return 0;\n    if( eType!=FTS5_STRING && pLeft==0 ) return pRight;\n    if( eType!=FTS5_STRING && pRight==0 ) return pLeft;\n\n    if( eType==FTS5_NOT ){\n      nChild = 2;\n    }else if( eType==FTS5_AND || eType==FTS5_OR ){\n      nChild = 2;\n      if( pLeft->eType==eType ) nChild += pLeft->nChild-1;\n      if( pRight->eType==eType ) nChild += pRight->nChild-1;\n    }\n\n    nByte = sizeof(Fts5ExprNode) + sizeof(Fts5ExprNode*)*(nChild-1);\n    pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte);\n\n    if( pRet ){\n      pRet->eType = eType;\n      pRet->pNear = pNear;\n      fts5ExprAssignXNext(pRet);\n      if( eType==FTS5_STRING ){\n        int iPhrase;\n        for(iPhrase=0; iPhrase<pNear->nPhrase; iPhrase++){\n          pNear->apPhrase[iPhrase]->pNode = pRet;\n          if( pNear->apPhrase[iPhrase]->nTerm==0 ){\n            pRet->xNext = 0;\n            pRet->eType = FTS5_EOF;\n          }\n        }\n\n        if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL \n         && (pNear->nPhrase!=1 || pNear->apPhrase[0]->nTerm>1)\n        ){\n          assert( pParse->rc==SQLITE_OK );\n          pParse->rc = SQLITE_ERROR;\n          assert( pParse->zErr==0 );\n          pParse->zErr = sqlite3_mprintf(\n              \"fts5: %s queries are not supported (detail!=full)\", \n              pNear->nPhrase==1 ? \"phrase\": \"NEAR\"\n          );\n          sqlite3_free(pRet);\n          pRet = 0;\n        }\n\n      }else{\n        fts5ExprAddChildren(pRet, pLeft);\n        fts5ExprAddChildren(pRet, pRight);\n      }\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n    sqlite3Fts5ParseNearsetFree(pNear);\n  }\n  return pRet;\n}\n\nFts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight            /* Right hand child expression */\n){\n  Fts5ExprNode *pRet = 0;\n  Fts5ExprNode *pPrev;\n\n  if( pParse->rc ){\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n  }else{\n\n    assert( pLeft->eType==FTS5_STRING \n        || pLeft->eType==FTS5_TERM\n        || pLeft->eType==FTS5_EOF\n        || pLeft->eType==FTS5_AND\n    );\n    assert( pRight->eType==FTS5_STRING \n        || pRight->eType==FTS5_TERM \n        || pRight->eType==FTS5_EOF \n    );\n\n    if( pLeft->eType==FTS5_AND ){\n      pPrev = pLeft->apChild[pLeft->nChild-1];\n    }else{\n      pPrev = pLeft;\n    }\n    assert( pPrev->eType==FTS5_STRING \n        || pPrev->eType==FTS5_TERM \n        || pPrev->eType==FTS5_EOF \n        );\n\n    if( pRight->eType==FTS5_EOF ){\n      assert( pParse->apPhrase[pParse->nPhrase-1]==pRight->pNear->apPhrase[0] );\n      sqlite3Fts5ParseNodeFree(pRight);\n      pRet = pLeft;\n      pParse->nPhrase--;\n    }\n    else if( pPrev->eType==FTS5_EOF ){\n      Fts5ExprPhrase **ap;\n\n      if( pPrev==pLeft ){\n        pRet = pRight;\n      }else{\n        pLeft->apChild[pLeft->nChild-1] = pRight;\n        pRet = pLeft;\n      }\n\n      ap = &pParse->apPhrase[pParse->nPhrase-1-pRight->pNear->nPhrase];\n      assert( ap[0]==pPrev->pNear->apPhrase[0] );\n      memmove(ap, &ap[1], sizeof(Fts5ExprPhrase*)*pRight->pNear->nPhrase);\n      pParse->nPhrase--;\n\n      sqlite3Fts5ParseNodeFree(pPrev);\n    }\n    else{\n      pRet = sqlite3Fts5ParseNode(pParse, FTS5_AND, pLeft, pRight, 0);\n    }\n  }\n\n  return pRet;\n}\n\nstatic char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){\n  int nByte = 0;\n  Fts5ExprTerm *p;\n  char *zQuoted;\n\n  /* Determine the maximum amount of space required. */\n  for(p=pTerm; p; p=p->pSynonym){\n    nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;\n  }\n  zQuoted = sqlite3_malloc(nByte);\n\n  if( zQuoted ){\n    int i = 0;\n    for(p=pTerm; p; p=p->pSynonym){\n      char *zIn = p->zTerm;\n      zQuoted[i++] = '\"';\n      while( *zIn ){\n        if( *zIn=='\"' ) zQuoted[i++] = '\"';\n        zQuoted[i++] = *zIn++;\n      }\n      zQuoted[i++] = '\"';\n      if( p->pSynonym ) zQuoted[i++] = '|';\n    }\n    if( pTerm->bPrefix ){\n      zQuoted[i++] = ' ';\n      zQuoted[i++] = '*';\n    }\n    zQuoted[i++] = '\\0';\n  }\n  return zQuoted;\n}\n\nstatic char *fts5PrintfAppend(char *zApp, const char *zFmt, ...){\n  char *zNew;\n  va_list ap;\n  va_start(ap, zFmt);\n  zNew = sqlite3_vmprintf(zFmt, ap);\n  va_end(ap);\n  if( zApp && zNew ){\n    char *zNew2 = sqlite3_mprintf(\"%s%s\", zApp, zNew);\n    sqlite3_free(zNew);\n    zNew = zNew2;\n  }\n  sqlite3_free(zApp);\n  return zNew;\n}\n\n/*\n** Compose a tcl-readable representation of expression pExpr. Return a \n** pointer to a buffer containing that representation. It is the \n** responsibility of the caller to at some point free the buffer using \n** sqlite3_free().\n*/\nstatic char *fts5ExprPrintTcl(\n  Fts5Config *pConfig, \n  const char *zNearsetCmd,\n  Fts5ExprNode *pExpr\n){\n  char *zRet = 0;\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    zRet = fts5PrintfAppend(zRet, \"%s \", zNearsetCmd);\n    if( zRet==0 ) return 0;\n    if( pNear->pColset ){\n      int *aiCol = pNear->pColset->aiCol;\n      int nCol = pNear->pColset->nCol;\n      if( nCol==1 ){\n        zRet = fts5PrintfAppend(zRet, \"-col %d \", aiCol[0]);\n      }else{\n        zRet = fts5PrintfAppend(zRet, \"-col {%d\", aiCol[0]);\n        for(i=1; i<pNear->pColset->nCol; i++){\n          zRet = fts5PrintfAppend(zRet, \" %d\", aiCol[i]);\n        }\n        zRet = fts5PrintfAppend(zRet, \"} \");\n      }\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"-near %d \", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n    zRet = fts5PrintfAppend(zRet, \"--\");\n    if( zRet==0 ) return 0;\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n\n      zRet = fts5PrintfAppend(zRet, \" {\");\n      for(iTerm=0; zRet && iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = pPhrase->aTerm[iTerm].zTerm;\n        zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" \", zTerm);\n        if( pPhrase->aTerm[iTerm].bPrefix ){\n          zRet = fts5PrintfAppend(zRet, \"*\");\n        }\n      }\n\n      if( zRet ) zRet = fts5PrintfAppend(zRet, \"}\");\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \"AND\"; break;\n      case FTS5_NOT: zOp = \"NOT\"; break;\n      default: \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \"OR\"; \n        break;\n    }\n\n    zRet = sqlite3_mprintf(\"%s\", zOp);\n    for(i=0; zRet && i<pExpr->nChild; i++){\n      char *z = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->apChild[i]);\n      if( !z ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        zRet = fts5PrintfAppend(zRet, \" [%z]\", z);\n      }\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *fts5ExprPrint(Fts5Config *pConfig, Fts5ExprNode *pExpr){\n  char *zRet = 0;\n  if( pExpr->eType==0 ){\n    return sqlite3_mprintf(\"\\\"\\\"\");\n  }else\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    if( pNear->pColset ){\n      int iCol = pNear->pColset->aiCol[0];\n      zRet = fts5PrintfAppend(zRet, \"%s : \", pConfig->azCol[iCol]);\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"NEAR(\");\n      if( zRet==0 ) return 0;\n    }\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( i!=0 ){\n        zRet = fts5PrintfAppend(zRet, \" \");\n        if( zRet==0 ) return 0;\n      }\n      for(iTerm=0; iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = fts5ExprTermPrint(&pPhrase->aTerm[iTerm]);\n        if( zTerm ){\n          zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" + \", zTerm);\n          sqlite3_free(zTerm);\n        }\n        if( zTerm==0 || zRet==0 ){\n          sqlite3_free(zRet);\n          return 0;\n        }\n      }\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \", %d)\", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \" AND \"; break;\n      case FTS5_NOT: zOp = \" NOT \"; break;\n      default:  \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \" OR \"; \n        break;\n    }\n\n    for(i=0; i<pExpr->nChild; i++){\n      char *z = fts5ExprPrint(pConfig, pExpr->apChild[i]);\n      if( z==0 ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        int e = pExpr->apChild[i]->eType;\n        int b = (e!=FTS5_STRING && e!=FTS5_TERM && e!=FTS5_EOF);\n        zRet = fts5PrintfAppend(zRet, \"%s%s%z%s\", \n            (i==0 ? \"\" : zOp),\n            (b?\"(\":\"\"), z, (b?\")\":\"\")\n        );\n      }\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** The implementation of user-defined scalar functions fts5_expr() (bTcl==0)\n** and fts5_expr_tcl() (bTcl!=0).\n*/\nstatic void fts5ExprFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal,          /* Function arguments */\n  int bTcl\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zExpr = 0;\n  char *zErr = 0;\n  Fts5Expr *pExpr = 0;\n  int rc;\n  int i;\n\n  const char **azConfig;          /* Array of arguments for Fts5Config */\n  const char *zNearsetCmd = \"nearset\";\n  int nConfig;                    /* Size of azConfig[] */\n  Fts5Config *pConfig = 0;\n  int iArg = 1;\n\n  if( nArg<1 ){\n    zErr = sqlite3_mprintf(\"wrong number of arguments to function %s\",\n        bTcl ? \"fts5_expr_tcl\" : \"fts5_expr\"\n    );\n    sqlite3_result_error(pCtx, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n\n  if( bTcl && nArg>1 ){\n    zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]);\n    iArg = 2;\n  }\n\n  nConfig = 3 + (nArg-iArg);\n  azConfig = (const char**)sqlite3_malloc(sizeof(char*) * nConfig);\n  if( azConfig==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return;\n  }\n  azConfig[0] = 0;\n  azConfig[1] = \"main\";\n  azConfig[2] = \"tbl\";\n  for(i=3; iArg<nArg; iArg++){\n    azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]);\n  }\n\n  zExpr = (const char*)sqlite3_value_text(apVal[0]);\n\n  rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);\n  }\n  if( rc==SQLITE_OK ){\n    char *zText;\n    if( pExpr->pRoot->xNext==0 ){\n      zText = sqlite3_mprintf(\"\");\n    }else if( bTcl ){\n      zText = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->pRoot);\n    }else{\n      zText = fts5ExprPrint(pConfig, pExpr->pRoot);\n    }\n    if( zText==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_result_text(pCtx, zText, -1, SQLITE_TRANSIENT);\n      sqlite3_free(zText);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    if( zErr ){\n      sqlite3_result_error(pCtx, zErr, -1);\n      sqlite3_free(zErr);\n    }else{\n      sqlite3_result_error_code(pCtx, rc);\n    }\n  }\n  sqlite3_free((void *)azConfig);\n  sqlite3Fts5ConfigFree(pConfig);\n  sqlite3Fts5ExprFree(pExpr);\n}\n\nstatic void fts5ExprFunctionHr(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 0);\n}\nstatic void fts5ExprFunctionTcl(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 1);\n}\n\n/*\n** The implementation of an SQLite user-defined-function that accepts a\n** single integer as an argument. If the integer is an alpha-numeric \n** unicode code point, 1 is returned. Otherwise 0.\n*/\nstatic void fts5ExprIsAlnum(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  int iCode;\n  if( nArg!=1 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_isalnum\", -1\n    );\n    return;\n  }\n  iCode = sqlite3_value_int(apVal[0]);\n  sqlite3_result_int(pCtx, sqlite3Fts5UnicodeIsalnum(iCode));\n}\n\nstatic void fts5ExprFold(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  if( nArg!=1 && nArg!=2 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_fold\", -1\n    );\n  }else{\n    int iCode;\n    int bRemoveDiacritics = 0;\n    iCode = sqlite3_value_int(apVal[0]);\n    if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);\n    sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));\n  }\n}\n\n/*\n** This is called during initialization to register the fts5_expr() scalar\n** UDF with the SQLite handle passed as the only argument.\n*/\nint sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){\n  struct Fts5ExprFunc {\n    const char *z;\n    void (*x)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"fts5_expr\",     fts5ExprFunctionHr },\n    { \"fts5_expr_tcl\", fts5ExprFunctionTcl },\n    { \"fts5_isalnum\",  fts5ExprIsAlnum },\n    { \"fts5_fold\",     fts5ExprFold },\n  };\n  int i;\n  int rc = SQLITE_OK;\n  void *pCtx = (void*)pGlobal;\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){\n    struct Fts5ExprFunc *p = &aFunc[i];\n    rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);\n  }\n\n  /* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */\n#ifndef NDEBUG\n  (void)sqlite3Fts5ParserTrace;\n#endif\n\n  return rc;\n}\n\n/*\n** Return the number of phrases in expression pExpr.\n*/\nint sqlite3Fts5ExprPhraseCount(Fts5Expr *pExpr){\n  return (pExpr ? pExpr->nPhrase : 0);\n}\n\n/*\n** Return the number of terms in the iPhrase'th phrase in pExpr.\n*/\nint sqlite3Fts5ExprPhraseSize(Fts5Expr *pExpr, int iPhrase){\n  if( iPhrase<0 || iPhrase>=pExpr->nPhrase ) return 0;\n  return pExpr->apExprPhrase[iPhrase]->nTerm;\n}\n\n/*\n** This function is used to access the current position list for phrase\n** iPhrase.\n*/\nint sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){\n  int nRet;\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){\n    *pa = pPhrase->poslist.p;\n    nRet = pPhrase->poslist.n;\n  }else{\n    *pa = 0;\n    nRet = 0;\n  }\n  return nRet;\n}\n\nstruct Fts5PoslistPopulator {\n  Fts5PoslistWriter writer;\n  int bOk;                        /* True if ok to populate */\n  int bMiss;\n};\n\nFts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){\n  Fts5PoslistPopulator *pRet;\n  pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n  if( pRet ){\n    int i;\n    memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n    for(i=0; i<pExpr->nPhrase; i++){\n      Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist;\n      Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n      assert( pExpr->apExprPhrase[i]->nTerm==1 );\n      if( bLive && \n          (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof)\n      ){\n        pRet[i].bMiss = 1;\n      }else{\n        pBuf->n = 0;\n      }\n    }\n  }\n  return pRet;\n}\n\nstruct Fts5ExprCtx {\n  Fts5Expr *pExpr;\n  Fts5PoslistPopulator *aPopulator;\n  i64 iOff;\n};\ntypedef struct Fts5ExprCtx Fts5ExprCtx;\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5ExprColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic int fts5ExprPopulatePoslistsCb(\n  void *pCtx,                /* Copy of 2nd argument to xTokenize() */\n  int tflags,                /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,        /* Pointer to buffer containing token */\n  int nToken,                /* Size of token in bytes */\n  int iUnused1,              /* Byte offset of token within input text */\n  int iUnused2               /* Byte offset of end of token within input text */\n){\n  Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;\n  Fts5Expr *pExpr = p->pExpr;\n  int i;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprTerm *pTerm;\n    if( p->aPopulator[i].bOk==0 ) continue;\n    for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      int nTerm = (int)strlen(pTerm->zTerm);\n      if( (nTerm==nToken || (nTerm<nToken && pTerm->bPrefix))\n       && memcmp(pTerm->zTerm, pToken, nTerm)==0\n      ){\n        int rc = sqlite3Fts5PoslistWriterAppend(\n            &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff\n        );\n        if( rc ) return rc;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\nint sqlite3Fts5ExprPopulatePoslists(\n  Fts5Config *pConfig,\n  Fts5Expr *pExpr, \n  Fts5PoslistPopulator *aPopulator,\n  int iCol, \n  const char *z, int n\n){\n  int i;\n  Fts5ExprCtx sCtx;\n  sCtx.pExpr = pExpr;\n  sCtx.aPopulator = aPopulator;\n  sCtx.iOff = (((i64)iCol) << 32) - 1;\n\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n    Fts5Colset *pColset = pNode->pNear->pColset;\n    if( (pColset && 0==fts5ExprColsetTest(pColset, iCol)) \n     || aPopulator[i].bMiss\n    ){\n      aPopulator[i].bOk = 0;\n    }else{\n      aPopulator[i].bOk = 1;\n    }\n  }\n\n  return sqlite3Fts5Tokenize(pConfig, \n      FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb\n  );\n}\n\nstatic void fts5ExprClearPoslists(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING ){\n    pNode->pNear->apPhrase[0]->poslist.n = 0;\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprClearPoslists(pNode->apChild[i]);\n    }\n  }\n}\n\nstatic int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){\n  pNode->iRowid = iRowid;\n  pNode->bEof = 0;\n  switch( pNode->eType ){\n    case FTS5_TERM:\n    case FTS5_STRING:\n      return (pNode->pNear->apPhrase[0]->poslist.n>0);\n\n    case FTS5_AND: {\n      int i;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){\n          fts5ExprClearPoslists(pNode);\n          return 0;\n        }\n      }\n      break;\n    }\n\n    case FTS5_OR: {\n      int i;\n      int bRet = 0;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){\n          bRet = 1;\n        }\n      }\n      return bRet;\n    }\n\n    default: {\n      assert( pNode->eType==FTS5_NOT );\n      if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid)\n          || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid)\n        ){\n        fts5ExprClearPoslists(pNode);\n        return 0;\n      }\n      break;\n    }\n  }\n  return 1;\n}\n\nvoid sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){\n  fts5ExprCheckPoslists(pExpr->pRoot, iRowid);\n}\n\n/*\n** This function is only called for detail=columns tables. \n*/\nint sqlite3Fts5ExprPhraseCollist(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  const u8 **ppCollist, \n  int *pnCollist\n){\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  int rc = SQLITE_OK;\n\n  assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );\n  assert( pExpr->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n\n  if( pNode->bEof==0 \n   && pNode->iRowid==pExpr->pRoot->iRowid \n   && pPhrase->poslist.n>0\n  ){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];\n    if( pTerm->pSynonym ){\n      Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];\n      rc = fts5ExprSynonymList(\n          pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist\n      );\n    }else{\n      *ppCollist = pPhrase->aTerm[0].pIter->pData;\n      *pnCollist = pPhrase->aTerm[0].pIter->nData;\n    }\n  }else{\n    *ppCollist = 0;\n    *pnCollist = 0;\n  }\n\n  return rc;\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_hash.c",
    "content": "/*\n** 2014 August 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n#include \"fts5Int.h\"\n\ntypedef struct Fts5HashEntry Fts5HashEntry;\n\n/*\n** This file contains the implementation of an in-memory hash table used\n** to accumuluate \"term -> doclist\" content before it is flused to a level-0\n** segment.\n*/\n\n\nstruct Fts5Hash {\n  int eDetail;                    /* Copy of Fts5Config.eDetail */\n  int *pnByte;                    /* Pointer to bytes counter */\n  int nEntry;                     /* Number of entries currently in hash */\n  int nSlot;                      /* Size of aSlot[] array */\n  Fts5HashEntry *pScan;           /* Current ordered scan item */\n  Fts5HashEntry **aSlot;          /* Array of hash slots */\n};\n\n/*\n** Each entry in the hash table is represented by an object of the \n** following type. Each object, its key (a nul-terminated string) and \n** its current data are stored in a single memory allocation. The \n** key immediately follows the object in memory. The position list\n** data immediately follows the key data in memory.\n**\n** The data that follows the key is in a similar, but not identical format\n** to the doclist data stored in the database. It is:\n**\n**   * Rowid, as a varint\n**   * Position list, without 0x00 terminator.\n**   * Size of previous position list and rowid, as a 4 byte\n**     big-endian integer.\n**\n** iRowidOff:\n**   Offset of last rowid written to data area. Relative to first byte of\n**   structure.\n**\n** nData:\n**   Bytes of data written since iRowidOff.\n*/\nstruct Fts5HashEntry {\n  Fts5HashEntry *pHashNext;       /* Next hash entry with same hash-key */\n  Fts5HashEntry *pScanNext;       /* Next entry in sorted order */\n  \n  int nAlloc;                     /* Total size of allocation */\n  int iSzPoslist;                 /* Offset of space for 4-byte poslist size */\n  int nData;                      /* Total bytes of data (incl. structure) */\n  int nKey;                       /* Length of key in bytes */\n  u8 bDel;                        /* Set delete-flag @ iSzPoslist */\n  u8 bContent;                    /* Set content-flag (detail=none mode) */\n  i16 iCol;                       /* Column of last value written */\n  int iPos;                       /* Position of last value written */\n  i64 iRowid;                     /* Rowid of last value written */\n};\n\n/*\n** Eqivalent to:\n**\n**   char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }\n*/\n#define fts5EntryKey(p) ( ((char *)(&(p)[1])) )\n\n\n/*\n** Allocate a new hash table.\n*/\nint sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){\n  int rc = SQLITE_OK;\n  Fts5Hash *pNew;\n\n  *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash));\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int nByte;\n    memset(pNew, 0, sizeof(Fts5Hash));\n    pNew->pnByte = pnByte;\n    pNew->eDetail = pConfig->eDetail;\n\n    pNew->nSlot = 1024;\n    nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;\n    pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc(nByte);\n    if( pNew->aSlot==0 ){\n      sqlite3_free(pNew);\n      *ppNew = 0;\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pNew->aSlot, 0, nByte);\n    }\n  }\n  return rc;\n}\n\n/*\n** Free a hash table object.\n*/\nvoid sqlite3Fts5HashFree(Fts5Hash *pHash){\n  if( pHash ){\n    sqlite3Fts5HashClear(pHash);\n    sqlite3_free(pHash->aSlot);\n    sqlite3_free(pHash);\n  }\n}\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nvoid sqlite3Fts5HashClear(Fts5Hash *pHash){\n  int i;\n  for(i=0; i<pHash->nSlot; i++){\n    Fts5HashEntry *pNext;\n    Fts5HashEntry *pSlot;\n    for(pSlot=pHash->aSlot[i]; pSlot; pSlot=pNext){\n      pNext = pSlot->pHashNext;\n      sqlite3_free(pSlot);\n    }\n  }\n  memset(pHash->aSlot, 0, pHash->nSlot * sizeof(Fts5HashEntry*));\n  pHash->nEntry = 0;\n}\n\nstatic unsigned int fts5HashKey(int nSlot, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  return (h % nSlot);\n}\n\nstatic unsigned int fts5HashKey2(int nSlot, u8 b, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  h = (h << 3) ^ h ^ b;\n  return (h % nSlot);\n}\n\n/*\n** Resize the hash table by doubling the number of slots.\n*/\nstatic int fts5HashResize(Fts5Hash *pHash){\n  int nNew = pHash->nSlot*2;\n  int i;\n  Fts5HashEntry **apNew;\n  Fts5HashEntry **apOld = pHash->aSlot;\n\n  apNew = (Fts5HashEntry**)sqlite3_malloc(nNew*sizeof(Fts5HashEntry*));\n  if( !apNew ) return SQLITE_NOMEM;\n  memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));\n\n  for(i=0; i<pHash->nSlot; i++){\n    while( apOld[i] ){\n      unsigned int iHash;\n      Fts5HashEntry *p = apOld[i];\n      apOld[i] = p->pHashNext;\n      iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p),\n                          (int)strlen(fts5EntryKey(p)));\n      p->pHashNext = apNew[iHash];\n      apNew[iHash] = p;\n    }\n  }\n\n  sqlite3_free(apOld);\n  pHash->nSlot = nNew;\n  pHash->aSlot = apNew;\n  return SQLITE_OK;\n}\n\nstatic void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){\n  if( p->iSzPoslist ){\n    u8 *pPtr = (u8*)p;\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      assert( p->nData==p->iSzPoslist );\n      if( p->bDel ){\n        pPtr[p->nData++] = 0x00;\n        if( p->bContent ){\n          pPtr[p->nData++] = 0x00;\n        }\n      }\n    }else{\n      int nSz = (p->nData - p->iSzPoslist - 1);       /* Size in bytes */\n      int nPos = nSz*2 + p->bDel;                     /* Value of nPos field */\n\n      assert( p->bDel==0 || p->bDel==1 );\n      if( nPos<=127 ){\n        pPtr[p->iSzPoslist] = (u8)nPos;\n      }else{\n        int nByte = sqlite3Fts5GetVarintLen((u32)nPos);\n        memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);\n        sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);\n        p->nData += (nByte-1);\n      }\n    }\n\n    p->iSzPoslist = 0;\n    p->bDel = 0;\n    p->bContent = 0;\n  }\n}\n\n/*\n** Add an entry to the in-memory hash table. The key is the concatenation\n** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).\n**\n**     (bByte || pToken) -> (iRowid,iCol,iPos)\n**\n** Or, if iCol is negative, then the value is a delete marker.\n*/\nint sqlite3Fts5HashWrite(\n  Fts5Hash *pHash,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,                     /* First byte of token */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  unsigned int iHash;\n  Fts5HashEntry *p;\n  u8 *pPtr;\n  int nIncr = 0;                  /* Amount to increment (*pHash->pnByte) by */\n  int bNew;                       /* If non-delete entry should be written */\n  \n  bNew = (pHash->eDetail==FTS5_DETAIL_FULL);\n\n  /* Attempt to locate an existing hash entry */\n  iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    char *zKey = fts5EntryKey(p);\n    if( zKey[0]==bByte \n     && p->nKey==nToken\n     && memcmp(&zKey[1], pToken, nToken)==0 \n    ){\n      break;\n    }\n  }\n\n  /* If an existing hash entry cannot be found, create a new one. */\n  if( p==0 ){\n    /* Figure out how much space to allocate */\n    char *zKey;\n    int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;\n    if( nByte<128 ) nByte = 128;\n\n    /* Grow the Fts5Hash.aSlot[] array if necessary. */\n    if( (pHash->nEntry*2)>=pHash->nSlot ){\n      int rc = fts5HashResize(pHash);\n      if( rc!=SQLITE_OK ) return rc;\n      iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n    }\n\n    /* Allocate new Fts5HashEntry and add it to the hash table. */\n    p = (Fts5HashEntry*)sqlite3_malloc(nByte);\n    if( !p ) return SQLITE_NOMEM;\n    memset(p, 0, sizeof(Fts5HashEntry));\n    p->nAlloc = nByte;\n    zKey = fts5EntryKey(p);\n    zKey[0] = bByte;\n    memcpy(&zKey[1], pToken, nToken);\n    assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );\n    p->nKey = nToken;\n    zKey[nToken+1] = '\\0';\n    p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);\n    p->pHashNext = pHash->aSlot[iHash];\n    pHash->aSlot[iHash] = p;\n    pHash->nEntry++;\n\n    /* Add the first rowid field to the hash-entry */\n    p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid);\n    p->iRowid = iRowid;\n\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n    }\n\n    nIncr += p->nData;\n  }else{\n\n    /* Appending to an existing hash-entry. Check that there is enough \n    ** space to append the largest possible new entry. Worst case scenario \n    ** is:\n    **\n    **     + 9 bytes for a new rowid,\n    **     + 4 byte reserved for the \"poslist size\" varint.\n    **     + 1 byte for a \"new column\" byte,\n    **     + 3 bytes for a new column number (16-bit max) as a varint,\n    **     + 5 bytes for the new position offset (32-bit max).\n    */\n    if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){\n      int nNew = p->nAlloc * 2;\n      Fts5HashEntry *pNew;\n      Fts5HashEntry **pp;\n      pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew);\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->nAlloc = nNew;\n      for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);\n      *pp = pNew;\n      p = pNew;\n    }\n    nIncr -= p->nData;\n  }\n  assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) );\n\n  pPtr = (u8*)p;\n\n  /* If this is a new rowid, append the 4-byte size field for the previous\n  ** entry, and the new rowid for this entry.  */\n  if( iRowid!=p->iRowid ){\n    fts5HashAddPoslistSize(pHash, p);\n    p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);\n    p->iRowid = iRowid;\n    bNew = 1;\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n      p->iPos = 0;\n    }\n  }\n\n  if( iCol>=0 ){\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      p->bContent = 1;\n    }else{\n      /* Append a new column value, if necessary */\n      assert( iCol>=p->iCol );\n      if( iCol!=p->iCol ){\n        if( pHash->eDetail==FTS5_DETAIL_FULL ){\n          pPtr[p->nData++] = 0x01;\n          p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol);\n          p->iCol = (i16)iCol;\n          p->iPos = 0;\n        }else{\n          bNew = 1;\n          p->iCol = (i16)(iPos = iCol);\n        }\n      }\n\n      /* Append the new position offset, if necessary */\n      if( bNew ){\n        p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2);\n        p->iPos = iPos;\n      }\n    }\n  }else{\n    /* This is a delete. Set the delete flag. */\n    p->bDel = 1;\n  }\n\n  nIncr += p->nData;\n  *pHash->pnByte += nIncr;\n  return SQLITE_OK;\n}\n\n\n/*\n** Arguments pLeft and pRight point to linked-lists of hash-entry objects,\n** each sorted in key order. This function merges the two lists into a\n** single list and returns a pointer to its first element.\n*/\nstatic Fts5HashEntry *fts5HashEntryMerge(\n  Fts5HashEntry *pLeft,\n  Fts5HashEntry *pRight\n){\n  Fts5HashEntry *p1 = pLeft;\n  Fts5HashEntry *p2 = pRight;\n  Fts5HashEntry *pRet = 0;\n  Fts5HashEntry **ppOut = &pRet;\n\n  while( p1 || p2 ){\n    if( p1==0 ){\n      *ppOut = p2;\n      p2 = 0;\n    }else if( p2==0 ){\n      *ppOut = p1;\n      p1 = 0;\n    }else{\n      int i = 0;\n      char *zKey1 = fts5EntryKey(p1);\n      char *zKey2 = fts5EntryKey(p2);\n      while( zKey1[i]==zKey2[i] ) i++;\n\n      if( ((u8)zKey1[i])>((u8)zKey2[i]) ){\n        /* p2 is smaller */\n        *ppOut = p2;\n        ppOut = &p2->pScanNext;\n        p2 = p2->pScanNext;\n      }else{\n        /* p1 is smaller */\n        *ppOut = p1;\n        ppOut = &p1->pScanNext;\n        p1 = p1->pScanNext;\n      }\n      *ppOut = 0;\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Extract all tokens from hash table iHash and link them into a list\n** in sorted order. The hash table is cleared before returning. It is\n** the responsibility of the caller to free the elements of the returned\n** list.\n*/\nstatic int fts5HashEntrySort(\n  Fts5Hash *pHash, \n  const char *pTerm, int nTerm,   /* Query prefix, if any */\n  Fts5HashEntry **ppSorted\n){\n  const int nMergeSlot = 32;\n  Fts5HashEntry **ap;\n  Fts5HashEntry *pList;\n  int iSlot;\n  int i;\n\n  *ppSorted = 0;\n  ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);\n  if( !ap ) return SQLITE_NOMEM;\n  memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);\n\n  for(iSlot=0; iSlot<pHash->nSlot; iSlot++){\n    Fts5HashEntry *pIter;\n    for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){\n      if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){\n        Fts5HashEntry *pEntry = pIter;\n        pEntry->pScanNext = 0;\n        for(i=0; ap[i]; i++){\n          pEntry = fts5HashEntryMerge(pEntry, ap[i]);\n          ap[i] = 0;\n        }\n        ap[i] = pEntry;\n      }\n    }\n  }\n\n  pList = 0;\n  for(i=0; i<nMergeSlot; i++){\n    pList = fts5HashEntryMerge(pList, ap[i]);\n  }\n\n  pHash->nEntry = 0;\n  sqlite3_free(ap);\n  *ppSorted = pList;\n  return SQLITE_OK;\n}\n\n/*\n** Query the hash table for a doclist associated with term pTerm/nTerm.\n*/\nint sqlite3Fts5HashQuery(\n  Fts5Hash *pHash,                /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n){\n  unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);\n  char *zKey = 0;\n  Fts5HashEntry *p;\n\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    zKey = fts5EntryKey(p);\n    if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;\n  }\n\n  if( p ){\n    fts5HashAddPoslistSize(pHash, p);\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n\n  return SQLITE_OK;\n}\n\nint sqlite3Fts5HashScanInit(\n  Fts5Hash *p,                    /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n){\n  return fts5HashEntrySort(p, pTerm, nTerm, &p->pScan);\n}\n\nvoid sqlite3Fts5HashScanNext(Fts5Hash *p){\n  assert( !sqlite3Fts5HashScanEof(p) );\n  p->pScan = p->pScan->pScanNext;\n}\n\nint sqlite3Fts5HashScanEof(Fts5Hash *p){\n  return (p->pScan==0);\n}\n\nvoid sqlite3Fts5HashScanEntry(\n  Fts5Hash *pHash,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n){\n  Fts5HashEntry *p;\n  if( (p = pHash->pScan) ){\n    char *zKey = fts5EntryKey(p);\n    int nTerm = (int)strlen(zKey);\n    fts5HashAddPoslistSize(pHash, p);\n    *pzTerm = zKey;\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *pzTerm = 0;\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_index.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Low level access to the FTS index stored in the database file. The \n** routines in this file file implement all read and write access to the\n** %_data table. Other parts of the system access this functionality via\n** the interface defined in fts5Int.h.\n*/\n\n\n#include \"fts5Int.h\"\n\n/*\n** Overview:\n**\n** The %_data table contains all the FTS indexes for an FTS5 virtual table.\n** As well as the main term index, there may be up to 31 prefix indexes.\n** The format is similar to FTS3/4, except that:\n**\n**   * all segment b-tree leaf data is stored in fixed size page records \n**     (e.g. 1000 bytes). A single doclist may span multiple pages. Care is \n**     taken to ensure it is possible to iterate in either direction through \n**     the entries in a doclist, or to seek to a specific entry within a \n**     doclist, without loading it into memory.\n**\n**   * large doclists that span many pages have associated \"doclist index\"\n**     records that contain a copy of the first rowid on each page spanned by\n**     the doclist. This is used to speed up seek operations, and merges of\n**     large doclists with very small doclists.\n**\n**   * extra fields in the \"structure record\" record the state of ongoing\n**     incremental merge operations.\n**\n*/\n\n\n#define FTS5_OPT_WORK_UNIT  1000  /* Number of leaf pages per optimize step */\n#define FTS5_WORK_UNIT      64    /* Number of leaf pages in unit of work */\n\n#define FTS5_MIN_DLIDX_SIZE 4     /* Add dlidx if this many empty pages */\n\n#define FTS5_MAIN_PREFIX '0'\n\n#if FTS5_MAX_PREFIX_INDEXES > 31\n# error \"FTS5_MAX_PREFIX_INDEXES is too large\"\n#endif\n\n/*\n** Details:\n**\n** The %_data table managed by this module,\n**\n**     CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB);\n**\n** , contains the following 5 types of records. See the comments surrounding\n** the FTS5_*_ROWID macros below for a description of how %_data rowids are \n** assigned to each fo them.\n**\n** 1. Structure Records:\n**\n**   The set of segments that make up an index - the index structure - are\n**   recorded in a single record within the %_data table. The record consists\n**   of a single 32-bit configuration cookie value followed by a list of \n**   SQLite varints. If the FTS table features more than one index (because\n**   there are one or more prefix indexes), it is guaranteed that all share\n**   the same cookie value.\n**\n**   Immediately following the configuration cookie, the record begins with\n**   three varints:\n**\n**     + number of levels,\n**     + total number of segments on all levels,\n**     + value of write counter.\n**\n**   Then, for each level from 0 to nMax:\n**\n**     + number of input segments in ongoing merge.\n**     + total number of segments in level.\n**     + for each segment from oldest to newest:\n**         + segment id (always > 0)\n**         + first leaf page number (often 1, always greater than 0)\n**         + final leaf page number\n**\n** 2. The Averages Record:\n**\n**   A single record within the %_data table. The data is a list of varints.\n**   The first value is the number of rows in the index. Then, for each column\n**   from left to right, the total number of tokens in the column for all\n**   rows of the table.\n**\n** 3. Segment leaves:\n**\n**   TERM/DOCLIST FORMAT:\n**\n**     Most of each segment leaf is taken up by term/doclist data. The \n**     general format of term/doclist, starting with the first term\n**     on the leaf page, is:\n**\n**         varint : size of first term\n**         blob:    first term data\n**         doclist: first doclist\n**         zero-or-more {\n**           varint:  number of bytes in common with previous term\n**           varint:  number of bytes of new term data (nNew)\n**           blob:    nNew bytes of new term data\n**           doclist: next doclist\n**         }\n**\n**     doclist format:\n**\n**         varint:  first rowid\n**         poslist: first poslist\n**         zero-or-more {\n**           varint:  rowid delta (always > 0)\n**           poslist: next poslist\n**         }\n**\n**     poslist format:\n**\n**         varint: size of poslist in bytes multiplied by 2, not including\n**                 this field. Plus 1 if this entry carries the \"delete\" flag.\n**         collist: collist for column 0\n**         zero-or-more {\n**           0x01 byte\n**           varint: column number (I)\n**           collist: collist for column I\n**         }\n**\n**     collist format:\n**\n**         varint: first offset + 2\n**         zero-or-more {\n**           varint: offset delta + 2\n**         }\n**\n**   PAGE FORMAT\n**\n**     Each leaf page begins with a 4-byte header containing 2 16-bit \n**     unsigned integer fields in big-endian format. They are:\n**\n**       * The byte offset of the first rowid on the page, if it exists\n**         and occurs before the first term (otherwise 0).\n**\n**       * The byte offset of the start of the page footer. If the page\n**         footer is 0 bytes in size, then this field is the same as the\n**         size of the leaf page in bytes.\n**\n**     The page footer consists of a single varint for each term located\n**     on the page. Each varint is the byte offset of the current term\n**     within the page, delta-compressed against the previous value. In\n**     other words, the first varint in the footer is the byte offset of\n**     the first term, the second is the byte offset of the second less that\n**     of the first, and so on.\n**\n**     The term/doclist format described above is accurate if the entire\n**     term/doclist data fits on a single leaf page. If this is not the case,\n**     the format is changed in two ways:\n**\n**       + if the first rowid on a page occurs before the first term, it\n**         is stored as a literal value:\n**\n**             varint:  first rowid\n**\n**       + the first term on each page is stored in the same way as the\n**         very first term of the segment:\n**\n**             varint : size of first term\n**             blob:    first term data\n**\n** 5. Segment doclist indexes:\n**\n**   Doclist indexes are themselves b-trees, however they usually consist of\n**   a single leaf record only. The format of each doclist index leaf page \n**   is:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear if leaf is also the root page, otherwise set.\n**\n**     * Page number of fts index leaf page. As a varint.\n**\n**     * First rowid on page indicated by previous field. As a varint.\n**\n**     * A list of varints, one for each subsequent termless page. A \n**       positive delta if the termless page contains at least one rowid, \n**       or an 0x00 byte otherwise.\n**\n**   Internal doclist index nodes are:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear for root page, otherwise set.\n**\n**     * Page number of first child page. As a varint.\n**\n**     * Copy of first rowid on page indicated by previous field. As a varint.\n**\n**     * A list of delta-encoded varints - the first rowid on each subsequent\n**       child page. \n**\n*/\n\n/*\n** Rowids for the averages and structure records in the %_data table.\n*/\n#define FTS5_AVERAGES_ROWID     1    /* Rowid used for the averages record */\n#define FTS5_STRUCTURE_ROWID   10    /* The structure record */\n\n/*\n** Macros determining the rowids used by segment leaves and dlidx leaves\n** and nodes. All nodes and leaves are stored in the %_data table with large\n** positive rowids.\n**\n** Each segment has a unique non-zero 16-bit id.\n**\n** The rowid for each segment leaf is found by passing the segment id and \n** the leaf page number to the FTS5_SEGMENT_ROWID macro. Leaves are numbered\n** sequentially starting from 1.\n*/\n#define FTS5_DATA_ID_B     16     /* Max seg id number 65535 */\n#define FTS5_DATA_DLI_B     1     /* Doclist-index flag (1 bit) */\n#define FTS5_DATA_HEIGHT_B  5     /* Max dlidx tree height of 32 */\n#define FTS5_DATA_PAGE_B   31     /* Max page number of 2147483648 */\n\n#define fts5_dri(segid, dlidx, height, pgno) (                                 \\\n ((i64)(segid)  << (FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)) +    \\\n ((i64)(dlidx)  << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B)) +                  \\\n ((i64)(height) << (FTS5_DATA_PAGE_B)) +                                       \\\n ((i64)(pgno))                                                                 \\\n)\n\n#define FTS5_SEGMENT_ROWID(segid, pgno)       fts5_dri(segid, 0, 0, pgno)\n#define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)\n\n/*\n** Maximum segments permitted in a single index \n*/\n#define FTS5_MAX_SEGMENT 2000\n\n#ifdef SQLITE_DEBUG\nint sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }\n#endif\n\n\n/*\n** Each time a blob is read from the %_data table, it is padded with this\n** many zero bytes. This makes it easier to decode the various record formats\n** without overreading if the records are corrupt.\n*/\n#define FTS5_DATA_ZERO_PADDING 8\n#define FTS5_DATA_PADDING 20\n\ntypedef struct Fts5Data Fts5Data;\ntypedef struct Fts5DlidxIter Fts5DlidxIter;\ntypedef struct Fts5DlidxLvl Fts5DlidxLvl;\ntypedef struct Fts5DlidxWriter Fts5DlidxWriter;\ntypedef struct Fts5Iter Fts5Iter;\ntypedef struct Fts5PageWriter Fts5PageWriter;\ntypedef struct Fts5SegIter Fts5SegIter;\ntypedef struct Fts5DoclistIter Fts5DoclistIter;\ntypedef struct Fts5SegWriter Fts5SegWriter;\ntypedef struct Fts5Structure Fts5Structure;\ntypedef struct Fts5StructureLevel Fts5StructureLevel;\ntypedef struct Fts5StructureSegment Fts5StructureSegment;\n\nstruct Fts5Data {\n  u8 *p;                          /* Pointer to buffer containing record */\n  int nn;                         /* Size of record in bytes */\n  int szLeaf;                     /* Size of leaf without page-index */\n};\n\n/*\n** One object per %_data table.\n*/\nstruct Fts5Index {\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  char *zDataTbl;                 /* Name of %_data table */\n  int nWorkUnit;                  /* Leaf pages in a \"unit\" of work */\n\n  /*\n  ** Variables related to the accumulation of tokens and doclists within the\n  ** in-memory hash tables before they are flushed to disk.\n  */\n  Fts5Hash *pHash;                /* Hash table for in-memory data */\n  int nPendingData;               /* Current bytes of pending data */\n  i64 iWriteRowid;                /* Rowid for current doc being written */\n  int bDelete;                    /* Current write is a delete */\n\n  /* Error state. */\n  int rc;                         /* Current error code */\n\n  /* State used by the fts5DataXXX() functions. */\n  sqlite3_blob *pReader;          /* RO incr-blob open on %_data table */\n  sqlite3_stmt *pWriter;          /* \"INSERT ... %_data VALUES(?,?)\" */\n  sqlite3_stmt *pDeleter;         /* \"DELETE FROM %_data ... id>=? AND id<=?\" */\n  sqlite3_stmt *pIdxWriter;       /* \"INSERT ... %_idx VALUES(?,?,?,?)\" */\n  sqlite3_stmt *pIdxDeleter;      /* \"DELETE FROM %_idx WHERE segid=? */\n  sqlite3_stmt *pIdxSelect;\n  int nRead;                      /* Total number of blocks read */\n\n  sqlite3_stmt *pDataVersion;\n  i64 iStructVersion;             /* data_version when pStruct read */\n  Fts5Structure *pStruct;         /* Current db structure (or NULL) */\n};\n\nstruct Fts5DoclistIter {\n  u8 *aEof;                       /* Pointer to 1 byte past end of doclist */\n\n  /* Output variables. aPoslist==0 at EOF */\n  i64 iRowid;\n  u8 *aPoslist;\n  int nPoslist;\n  int nSize;\n};\n\n/*\n** The contents of the \"structure\" record for each index are represented\n** using an Fts5Structure record in memory. Which uses instances of the \n** other Fts5StructureXXX types as components.\n*/\nstruct Fts5StructureSegment {\n  int iSegid;                     /* Segment id */\n  int pgnoFirst;                  /* First leaf page number in segment */\n  int pgnoLast;                   /* Last leaf page number in segment */\n};\nstruct Fts5StructureLevel {\n  int nMerge;                     /* Number of segments in incr-merge */\n  int nSeg;                       /* Total number of segments on level */\n  Fts5StructureSegment *aSeg;     /* Array of segments. aSeg[0] is oldest. */\n};\nstruct Fts5Structure {\n  int nRef;                       /* Object reference count */\n  u64 nWriteCounter;              /* Total leaves written to level 0 */\n  int nSegment;                   /* Total segments in this structure */\n  int nLevel;                     /* Number of levels in this index */\n  Fts5StructureLevel aLevel[1];   /* Array of nLevel level objects */\n};\n\n/*\n** An object of type Fts5SegWriter is used to write to segments.\n*/\nstruct Fts5PageWriter {\n  int pgno;                       /* Page number for this page */\n  int iPrevPgidx;                 /* Previous value written into pgidx */\n  Fts5Buffer buf;                 /* Buffer containing leaf data */\n  Fts5Buffer pgidx;               /* Buffer containing page-index */\n  Fts5Buffer term;                /* Buffer containing previous term on page */\n};\nstruct Fts5DlidxWriter {\n  int pgno;                       /* Page number for this page */\n  int bPrevValid;                 /* True if iPrev is valid */\n  i64 iPrev;                      /* Previous rowid value written to page */\n  Fts5Buffer buf;                 /* Buffer containing page data */\n};\nstruct Fts5SegWriter {\n  int iSegid;                     /* Segid to write to */\n  Fts5PageWriter writer;          /* PageWriter object */\n  i64 iPrevRowid;                 /* Previous rowid written to current leaf */\n  u8 bFirstRowidInDoclist;        /* True if next rowid is first in doclist */\n  u8 bFirstRowidInPage;           /* True if next rowid is first in page */\n  /* TODO1: Can use (writer.pgidx.n==0) instead of bFirstTermInPage */\n  u8 bFirstTermInPage;            /* True if next term will be first in leaf */\n  int nLeafWritten;               /* Number of leaf pages written */\n  int nEmpty;                     /* Number of contiguous term-less nodes */\n\n  int nDlidx;                     /* Allocated size of aDlidx[] array */\n  Fts5DlidxWriter *aDlidx;        /* Array of Fts5DlidxWriter objects */\n\n  /* Values to insert into the %_idx table */\n  Fts5Buffer btterm;              /* Next term to insert into %_idx table */\n  int iBtPage;                    /* Page number corresponding to btterm */\n};\n\ntypedef struct Fts5CResult Fts5CResult;\nstruct Fts5CResult {\n  u16 iFirst;                     /* aSeg[] index of firstest iterator */\n  u8 bTermEq;                     /* True if the terms are equal */\n};\n\n/*\n** Object for iterating through a single segment, visiting each term/rowid\n** pair in the segment.\n**\n** pSeg:\n**   The segment to iterate through.\n**\n** iLeafPgno:\n**   Current leaf page number within segment.\n**\n** iLeafOffset:\n**   Byte offset within the current leaf that is the first byte of the \n**   position list data (one byte passed the position-list size field).\n**   rowid field of the current entry. Usually this is the size field of the\n**   position list data. The exception is if the rowid for the current entry \n**   is the last thing on the leaf page.\n**\n** pLeaf:\n**   Buffer containing current leaf page data. Set to NULL at EOF.\n**\n** iTermLeafPgno, iTermLeafOffset:\n**   Leaf page number containing the last term read from the segment. And\n**   the offset immediately following the term data.\n**\n** flags:\n**   Mask of FTS5_SEGITER_XXX values. Interpreted as follows:\n**\n**   FTS5_SEGITER_ONETERM:\n**     If set, set the iterator to point to EOF after the current doclist \n**     has been exhausted. Do not proceed to the next term in the segment.\n**\n**   FTS5_SEGITER_REVERSE:\n**     This flag is only ever set if FTS5_SEGITER_ONETERM is also set. If\n**     it is set, iterate through rowid in descending order instead of the\n**     default ascending order.\n**\n** iRowidOffset/nRowidOffset/aRowidOffset:\n**     These are used if the FTS5_SEGITER_REVERSE flag is set.\n**\n**     For each rowid on the page corresponding to the current term, the\n**     corresponding aRowidOffset[] entry is set to the byte offset of the\n**     start of the \"position-list-size\" field within the page.\n**\n** iTermIdx:\n**     Index of current term on iTermLeafPgno.\n*/\nstruct Fts5SegIter {\n  Fts5StructureSegment *pSeg;     /* Segment to iterate through */\n  int flags;                      /* Mask of configuration flags */\n  int iLeafPgno;                  /* Current leaf page number */\n  Fts5Data *pLeaf;                /* Current leaf data */\n  Fts5Data *pNextLeaf;            /* Leaf page (iLeafPgno+1) */\n  int iLeafOffset;                /* Byte offset within current leaf */\n\n  /* Next method */\n  void (*xNext)(Fts5Index*, Fts5SegIter*, int*);\n\n  /* The page and offset from which the current term was read. The offset \n  ** is the offset of the first rowid in the current doclist.  */\n  int iTermLeafPgno;\n  int iTermLeafOffset;\n\n  int iPgidxOff;                  /* Next offset in pgidx */\n  int iEndofDoclist;\n\n  /* The following are only used if the FTS5_SEGITER_REVERSE flag is set. */\n  int iRowidOffset;               /* Current entry in aRowidOffset[] */\n  int nRowidOffset;               /* Allocated size of aRowidOffset[] array */\n  int *aRowidOffset;              /* Array of offset to rowid fields */\n\n  Fts5DlidxIter *pDlidx;          /* If there is a doclist-index */\n\n  /* Variables populated based on current entry. */\n  Fts5Buffer term;                /* Current term */\n  i64 iRowid;                     /* Current rowid */\n  int nPos;                       /* Number of bytes in current position list */\n  u8 bDel;                        /* True if the delete flag is set */\n};\n\n/*\n** Argument is a pointer to an Fts5Data structure that contains a \n** leaf page.\n*/\n#define ASSERT_SZLEAF_OK(x) assert( \\\n    (x)->szLeaf==(x)->nn || (x)->szLeaf==fts5GetU16(&(x)->p[2]) \\\n)\n\n#define FTS5_SEGITER_ONETERM 0x01\n#define FTS5_SEGITER_REVERSE 0x02\n\n/* \n** Argument is a pointer to an Fts5Data structure that contains a leaf\n** page. This macro evaluates to true if the leaf contains no terms, or\n** false if it contains at least one term.\n*/\n#define fts5LeafIsTermless(x) ((x)->szLeaf >= (x)->nn)\n\n#define fts5LeafTermOff(x, i) (fts5GetU16(&(x)->p[(x)->szLeaf + (i)*2]))\n\n#define fts5LeafFirstRowidOff(x) (fts5GetU16((x)->p))\n\n/*\n** Object for iterating through the merged results of one or more segments,\n** visiting each term/rowid pair in the merged data.\n**\n** nSeg is always a power of two greater than or equal to the number of\n** segments that this object is merging data from. Both the aSeg[] and\n** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded\n** with zeroed objects - these are handled as if they were iterators opened\n** on empty segments.\n**\n** The results of comparing segments aSeg[N] and aSeg[N+1], where N is an\n** even number, is stored in aFirst[(nSeg+N)/2]. The \"result\" of the \n** comparison in this context is the index of the iterator that currently\n** points to the smaller term/rowid combination. Iterators at EOF are\n** considered to be greater than all other iterators.\n**\n** aFirst[1] contains the index in aSeg[] of the iterator that points to\n** the smallest key overall. aFirst[0] is unused. \n**\n** poslist:\n**   Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered.\n**   There is no way to tell if this is populated or not.\n*/\nstruct Fts5Iter {\n  Fts5IndexIter base;             /* Base class containing output vars */\n\n  Fts5Index *pIndex;              /* Index that owns this iterator */\n  Fts5Structure *pStruct;         /* Database structure for this iterator */\n  Fts5Buffer poslist;             /* Buffer containing current poslist */\n  Fts5Colset *pColset;            /* Restrict matches to these columns */\n\n  /* Invoked to set output variables. */\n  void (*xSetOutputs)(Fts5Iter*, Fts5SegIter*);\n\n  int nSeg;                       /* Size of aSeg[] array */\n  int bRev;                       /* True to iterate in reverse order */\n  u8 bSkipEmpty;                  /* True to skip deleted entries */\n\n  i64 iSwitchRowid;               /* Firstest rowid of other than aFirst[1] */\n  Fts5CResult *aFirst;            /* Current merge state (see above) */\n  Fts5SegIter aSeg[1];            /* Array of segment iterators */\n};\n\n\n/*\n** An instance of the following type is used to iterate through the contents\n** of a doclist-index record.\n**\n** pData:\n**   Record containing the doclist-index data.\n**\n** bEof:\n**   Set to true once iterator has reached EOF.\n**\n** iOff:\n**   Set to the current offset within record pData.\n*/\nstruct Fts5DlidxLvl {\n  Fts5Data *pData;              /* Data for current page of this level */\n  int iOff;                     /* Current offset into pData */\n  int bEof;                     /* At EOF already */\n  int iFirstOff;                /* Used by reverse iterators */\n\n  /* Output variables */\n  int iLeafPgno;                /* Page number of current leaf page */\n  i64 iRowid;                   /* First rowid on leaf iLeafPgno */\n};\nstruct Fts5DlidxIter {\n  int nLvl;\n  int iSegid;\n  Fts5DlidxLvl aLvl[1];\n};\n\nstatic void fts5PutU16(u8 *aOut, u16 iVal){\n  aOut[0] = (iVal>>8);\n  aOut[1] = (iVal&0xFF);\n}\n\nstatic u16 fts5GetU16(const u8 *aIn){\n  return ((u16)aIn[0] << 8) + aIn[1];\n} \n\n/*\n** Allocate and return a buffer at least nByte bytes in size.\n**\n** If an OOM error is encountered, return NULL and set the error code in\n** the Fts5Index handle passed as the first argument.\n*/\nstatic void *fts5IdxMalloc(Fts5Index *p, int nByte){\n  return sqlite3Fts5MallocZero(&p->rc, nByte);\n}\n\n/*\n** Compare the contents of the pLeft buffer with the pRight/nRight blob.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5BufferCompareBlob(\n  Fts5Buffer *pLeft,              /* Left hand side of comparison */\n  const u8 *pRight, int nRight    /* Right hand side of comparison */\n){\n  int nCmp = MIN(pLeft->n, nRight);\n  int res = memcmp(pLeft->p, pRight, nCmp);\n  return (res==0 ? (pLeft->n - nRight) : res);\n}\n#endif\n\n/*\n** Compare the contents of the two buffers using memcmp(). If one buffer\n** is a prefix of the other, it is considered the lesser.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\nstatic int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){\n  int nCmp = MIN(pLeft->n, pRight->n);\n  int res = memcmp(pLeft->p, pRight->p, nCmp);\n  return (res==0 ? (pLeft->n - pRight->n) : res);\n}\n\nstatic int fts5LeafFirstTermOff(Fts5Data *pLeaf){\n  int ret;\n  fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);\n  return ret;\n}\n\n/*\n** Close the read-only blob handle, if it is open.\n*/\nstatic void fts5CloseReader(Fts5Index *p){\n  if( p->pReader ){\n    sqlite3_blob *pReader = p->pReader;\n    p->pReader = 0;\n    sqlite3_blob_close(pReader);\n  }\n}\n\n/*\n** Retrieve a record from the %_data table.\n**\n** If an error occurs, NULL is returned and an error left in the \n** Fts5Index object.\n*/\nstatic Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    int rc = SQLITE_OK;\n\n    if( p->pReader ){\n      /* This call may return SQLITE_ABORT if there has been a savepoint\n      ** rollback since it was last used. In this case a new blob handle\n      ** is required.  */\n      sqlite3_blob *pBlob = p->pReader;\n      p->pReader = 0;\n      rc = sqlite3_blob_reopen(pBlob, iRowid);\n      assert( p->pReader==0 );\n      p->pReader = pBlob;\n      if( rc!=SQLITE_OK ){\n        fts5CloseReader(p);\n      }\n      if( rc==SQLITE_ABORT ) rc = SQLITE_OK;\n    }\n\n    /* If the blob handle is not open at this point, open it and seek \n    ** to the requested entry.  */\n    if( p->pReader==0 && rc==SQLITE_OK ){\n      Fts5Config *pConfig = p->pConfig;\n      rc = sqlite3_blob_open(pConfig->db, \n          pConfig->zDb, p->zDataTbl, \"block\", iRowid, 0, &p->pReader\n      );\n    }\n\n    /* If either of the sqlite3_blob_open() or sqlite3_blob_reopen() calls\n    ** above returned SQLITE_ERROR, return SQLITE_CORRUPT_VTAB instead.\n    ** All the reasons those functions might return SQLITE_ERROR - missing\n    ** table, missing row, non-blob/text in block column - indicate \n    ** backing store corruption.  */\n    if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT;\n\n    if( rc==SQLITE_OK ){\n      u8 *aOut = 0;               /* Read blob data into this buffer */\n      int nByte = sqlite3_blob_bytes(p->pReader);\n      int nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;\n      pRet = (Fts5Data*)sqlite3_malloc(nAlloc);\n      if( pRet ){\n        pRet->nn = nByte;\n        aOut = pRet->p = (u8*)&pRet[1];\n      }else{\n        rc = SQLITE_NOMEM;\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pRet);\n        pRet = 0;\n      }else{\n        /* TODO1: Fix this */\n        pRet->szLeaf = fts5GetU16(&pRet->p[2]);\n      }\n    }\n    p->rc = rc;\n    p->nRead++;\n  }\n\n  assert( (pRet==0)==(p->rc!=SQLITE_OK) );\n  return pRet;\n}\n\n/*\n** Release a reference to data record returned by an earlier call to\n** fts5DataRead().\n*/\nstatic void fts5DataRelease(Fts5Data *pData){\n  sqlite3_free(pData);\n}\n\nstatic Fts5Data *fts5LeafRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = fts5DataRead(p, iRowid);\n  if( pRet ){\n    if( pRet->szLeaf>pRet->nn ){\n      p->rc = FTS5_CORRUPT;\n      fts5DataRelease(pRet);\n      pRet = 0;\n    }\n  }\n  return pRet;\n}\n\nstatic int fts5IndexPrepareStmt(\n  Fts5Index *p,\n  sqlite3_stmt **ppStmt,\n  char *zSql\n){\n  if( p->rc==SQLITE_OK ){\n    if( zSql ){\n      p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,\n                                 SQLITE_PREPARE_PERSISTENT, ppStmt, 0);\n    }else{\n      p->rc = SQLITE_NOMEM;\n    }\n  }\n  sqlite3_free(zSql);\n  return p->rc;\n}\n\n\n/*\n** INSERT OR REPLACE a record into the %_data table.\n*/\nstatic void fts5DataWrite(Fts5Index *p, i64 iRowid, const u8 *pData, int nData){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pWriter, sqlite3_mprintf(\n          \"REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n    if( p->rc ) return;\n  }\n\n  sqlite3_bind_int64(p->pWriter, 1, iRowid);\n  sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);\n  sqlite3_step(p->pWriter);\n  p->rc = sqlite3_reset(p->pWriter);\n}\n\n/*\n** Execute the following SQL:\n**\n**     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast\n*/\nstatic void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pDeleter==0 ){\n    int rc;\n    Fts5Config *pConfig = p->pConfig;\n    char *zSql = sqlite3_mprintf(\n        \"DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\", \n          pConfig->zDb, pConfig->zName\n    );\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);\n      sqlite3_free(zSql);\n    }\n    if( rc!=SQLITE_OK ){\n      p->rc = rc;\n      return;\n    }\n  }\n\n  sqlite3_bind_int64(p->pDeleter, 1, iFirst);\n  sqlite3_bind_int64(p->pDeleter, 2, iLast);\n  sqlite3_step(p->pDeleter);\n  p->rc = sqlite3_reset(p->pDeleter);\n}\n\n/*\n** Remove all records associated with segment iSegid.\n*/\nstatic void fts5DataRemoveSegment(Fts5Index *p, int iSegid){\n  i64 iFirst = FTS5_SEGMENT_ROWID(iSegid, 0);\n  i64 iLast = FTS5_SEGMENT_ROWID(iSegid+1, 0)-1;\n  fts5DataDelete(p, iFirst, iLast);\n  if( p->pIdxDeleter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxDeleter, sqlite3_mprintf(\n          \"DELETE FROM '%q'.'%q_idx' WHERE segid=?\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_bind_int(p->pIdxDeleter, 1, iSegid);\n    sqlite3_step(p->pIdxDeleter);\n    p->rc = sqlite3_reset(p->pIdxDeleter);\n  }\n}\n\n/*\n** Release a reference to an Fts5Structure object returned by an earlier \n** call to fts5StructureRead() or fts5StructureDecode().\n*/\nstatic void fts5StructureRelease(Fts5Structure *pStruct){\n  if( pStruct && 0>=(--pStruct->nRef) ){\n    int i;\n    assert( pStruct->nRef==0 );\n    for(i=0; i<pStruct->nLevel; i++){\n      sqlite3_free(pStruct->aLevel[i].aSeg);\n    }\n    sqlite3_free(pStruct);\n  }\n}\n\nstatic void fts5StructureRef(Fts5Structure *pStruct){\n  pStruct->nRef++;\n}\n\n/*\n** Deserialize and return the structure record currently stored in serialized\n** form within buffer pData/nData.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated by one slot. This allows the structure contents\n** to be more easily edited.\n**\n** If an error occurs, *ppOut is set to NULL and an SQLite error code\n** returned. Otherwise, *ppOut is set to point to the new object and\n** SQLITE_OK returned.\n*/\nstatic int fts5StructureDecode(\n  const u8 *pData,                /* Buffer containing serialized structure */\n  int nData,                      /* Size of buffer pData in bytes */\n  int *piCookie,                  /* Configuration cookie value */\n  Fts5Structure **ppOut           /* OUT: Deserialized object */\n){\n  int rc = SQLITE_OK;\n  int i = 0;\n  int iLvl;\n  int nLevel = 0;\n  int nSegment = 0;\n  int nByte;                      /* Bytes of space to allocate at pRet */\n  Fts5Structure *pRet = 0;        /* Structure object to return */\n\n  /* Grab the cookie value */\n  if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);\n  i = 4;\n\n  /* Read the total number of levels and segments from the start of the\n  ** structure record.  */\n  i += fts5GetVarint32(&pData[i], nLevel);\n  i += fts5GetVarint32(&pData[i], nSegment);\n  nByte = (\n      sizeof(Fts5Structure) +                    /* Main structure */\n      sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */\n  );\n  pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);\n\n  if( pRet ){\n    pRet->nRef = 1;\n    pRet->nLevel = nLevel;\n    pRet->nSegment = nSegment;\n    i += sqlite3Fts5GetVarint(&pData[i], &pRet->nWriteCounter);\n\n    for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];\n      int nTotal = 0;\n      int iSeg;\n\n      if( i>=nData ){\n        rc = FTS5_CORRUPT;\n      }else{\n        i += fts5GetVarint32(&pData[i], pLvl->nMerge);\n        i += fts5GetVarint32(&pData[i], nTotal);\n        assert( nTotal>=pLvl->nMerge );\n        pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, \n            nTotal * sizeof(Fts5StructureSegment)\n        );\n      }\n\n      if( rc==SQLITE_OK ){\n        pLvl->nSeg = nTotal;\n        for(iSeg=0; iSeg<nTotal; iSeg++){\n          if( i>=nData ){\n            rc = FTS5_CORRUPT;\n            break;\n          }\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);\n        }\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  *ppOut = pRet;\n  return rc;\n}\n\n/*\n**\n*/\nstatic void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){\n  if( *pRc==SQLITE_OK ){\n    Fts5Structure *pStruct = *ppStruct;\n    int nLevel = pStruct->nLevel;\n    int nByte = (\n        sizeof(Fts5Structure) +                  /* Main structure */\n        sizeof(Fts5StructureLevel) * (nLevel+1)  /* aLevel[] array */\n    );\n\n    pStruct = sqlite3_realloc(pStruct, nByte);\n    if( pStruct ){\n      memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));\n      pStruct->nLevel++;\n      *ppStruct = pStruct;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Extend level iLvl so that there is room for at least nExtra more\n** segments.\n*/\nstatic void fts5StructureExtendLevel(\n  int *pRc, \n  Fts5Structure *pStruct, \n  int iLvl, \n  int nExtra, \n  int bInsert\n){\n  if( *pRc==SQLITE_OK ){\n    Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n    Fts5StructureSegment *aNew;\n    int nByte;\n\n    nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);\n    aNew = sqlite3_realloc(pLvl->aSeg, nByte);\n    if( aNew ){\n      if( bInsert==0 ){\n        memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);\n      }else{\n        int nMove = pLvl->nSeg * sizeof(Fts5StructureSegment);\n        memmove(&aNew[nExtra], aNew, nMove);\n        memset(aNew, 0, sizeof(Fts5StructureSegment) * nExtra);\n      }\n      pLvl->aSeg = aNew;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\nstatic Fts5Structure *fts5StructureReadUncached(Fts5Index *p){\n  Fts5Structure *pRet = 0;\n  Fts5Config *pConfig = p->pConfig;\n  int iCookie;                    /* Configuration cookie */\n  Fts5Data *pData;\n\n  pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);\n  if( p->rc==SQLITE_OK ){\n    /* TODO: Do we need this if the leaf-index is appended? Probably... */\n    memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);\n    p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);\n    if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){\n      p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);\n    }\n    fts5DataRelease(pData);\n    if( p->rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic i64 fts5IndexDataVersion(Fts5Index *p){\n  i64 iVersion = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( p->pDataVersion==0 ){\n      p->rc = fts5IndexPrepareStmt(p, &p->pDataVersion, \n          sqlite3_mprintf(\"PRAGMA %Q.data_version\", p->pConfig->zDb)\n          );\n      if( p->rc ) return 0;\n    }\n\n    if( SQLITE_ROW==sqlite3_step(p->pDataVersion) ){\n      iVersion = sqlite3_column_int64(p->pDataVersion, 0);\n    }\n    p->rc = sqlite3_reset(p->pDataVersion);\n  }\n\n  return iVersion;\n}\n\n/*\n** Read, deserialize and return the structure record.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated as described for function fts5StructureDecode() \n** above.\n**\n** If an error occurs, NULL is returned and an error code left in the\n** Fts5Index handle. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic Fts5Structure *fts5StructureRead(Fts5Index *p){\n\n  if( p->pStruct==0 ){\n    p->iStructVersion = fts5IndexDataVersion(p);\n    if( p->rc==SQLITE_OK ){\n      p->pStruct = fts5StructureReadUncached(p);\n    }\n  }\n\n#if 0\n  else{\n    Fts5Structure *pTest = fts5StructureReadUncached(p);\n    if( pTest ){\n      int i, j;\n      assert_nc( p->pStruct->nSegment==pTest->nSegment );\n      assert_nc( p->pStruct->nLevel==pTest->nLevel );\n      for(i=0; i<pTest->nLevel; i++){\n        assert_nc( p->pStruct->aLevel[i].nMerge==pTest->aLevel[i].nMerge );\n        assert_nc( p->pStruct->aLevel[i].nSeg==pTest->aLevel[i].nSeg );\n        for(j=0; j<pTest->aLevel[i].nSeg; j++){\n          Fts5StructureSegment *p1 = &pTest->aLevel[i].aSeg[j];\n          Fts5StructureSegment *p2 = &p->pStruct->aLevel[i].aSeg[j];\n          assert_nc( p1->iSegid==p2->iSegid );\n          assert_nc( p1->pgnoFirst==p2->pgnoFirst );\n          assert_nc( p1->pgnoLast==p2->pgnoLast );\n        }\n      }\n      fts5StructureRelease(pTest);\n    }\n  }\n#endif\n\n  if( p->rc!=SQLITE_OK ) return 0;\n  assert( p->iStructVersion!=0 );\n  assert( p->pStruct!=0 );\n  fts5StructureRef(p->pStruct);\n  return p->pStruct;\n}\n\nstatic void fts5StructureInvalidate(Fts5Index *p){\n  if( p->pStruct ){\n    fts5StructureRelease(p->pStruct);\n    p->pStruct = 0;\n  }\n}\n\n/*\n** Return the total number of segments in index structure pStruct. This\n** function is only ever used as part of assert() conditions.\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5StructureCountSegments(Fts5Structure *pStruct){\n  int nSegment = 0;               /* Total number of segments */\n  if( pStruct ){\n    int iLvl;                     /* Used to iterate through levels */\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      nSegment += pStruct->aLevel[iLvl].nSeg;\n    }\n  }\n\n  return nSegment;\n}\n#endif\n\n#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) {     \\\n  assert( (pBuf)->nSpace>=((pBuf)->n+nBlob) );             \\\n  memcpy(&(pBuf)->p[(pBuf)->n], pBlob, nBlob);             \\\n  (pBuf)->n += nBlob;                                      \\\n}\n\n#define fts5BufferSafeAppendVarint(pBuf, iVal) {                \\\n  (pBuf)->n += sqlite3Fts5PutVarint(&(pBuf)->p[(pBuf)->n], (iVal));  \\\n  assert( (pBuf)->nSpace>=(pBuf)->n );                          \\\n}\n\n\n/*\n** Serialize and store the \"structure\" record.\n**\n** If an error occurs, leave an error code in the Fts5Index object. If an\n** error has already occurred, this function is a no-op.\n*/\nstatic void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){\n  if( p->rc==SQLITE_OK ){\n    Fts5Buffer buf;               /* Buffer to serialize record into */\n    int iLvl;                     /* Used to iterate through levels */\n    int iCookie;                  /* Cookie value to store */\n\n    assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n    memset(&buf, 0, sizeof(Fts5Buffer));\n\n    /* Append the current configuration cookie */\n    iCookie = p->pConfig->iCookie;\n    if( iCookie<0 ) iCookie = 0;\n\n    if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){\n      sqlite3Fts5Put32(buf.p, iCookie);\n      buf.n = 4;\n      fts5BufferSafeAppendVarint(&buf, pStruct->nLevel);\n      fts5BufferSafeAppendVarint(&buf, pStruct->nSegment);\n      fts5BufferSafeAppendVarint(&buf, (i64)pStruct->nWriteCounter);\n    }\n\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      int iSeg;                     /* Used to iterate through segments */\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nMerge);\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nSeg);\n      assert( pLvl->nMerge<=pLvl->nSeg );\n\n      for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].iSegid);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoFirst);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoLast);\n      }\n    }\n\n    fts5DataWrite(p, FTS5_STRUCTURE_ROWID, buf.p, buf.n);\n    fts5BufferFree(&buf);\n  }\n}\n\n#if 0\nstatic void fts5DebugStructure(int*,Fts5Buffer*,Fts5Structure*);\nstatic void fts5PrintStructure(const char *zCaption, Fts5Structure *pStruct){\n  int rc = SQLITE_OK;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(buf));\n  fts5DebugStructure(&rc, &buf, pStruct);\n  fprintf(stdout, \"%s: %s\\n\", zCaption, buf.p);\n  fflush(stdout);\n  fts5BufferFree(&buf);\n}\n#else\n# define fts5PrintStructure(x,y)\n#endif\n\nstatic int fts5SegmentSize(Fts5StructureSegment *pSeg){\n  return 1 + pSeg->pgnoLast - pSeg->pgnoFirst;\n}\n\n/*\n** Return a copy of index structure pStruct. Except, promote as many \n** segments as possible to level iPromote. If an OOM occurs, NULL is \n** returned.\n*/\nstatic void fts5StructurePromoteTo(\n  Fts5Index *p,\n  int iPromote,\n  int szPromote,\n  Fts5Structure *pStruct\n){\n  int il, is;\n  Fts5StructureLevel *pOut = &pStruct->aLevel[iPromote];\n\n  if( pOut->nMerge==0 ){\n    for(il=iPromote+1; il<pStruct->nLevel; il++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[il];\n      if( pLvl->nMerge ) return;\n      for(is=pLvl->nSeg-1; is>=0; is--){\n        int sz = fts5SegmentSize(&pLvl->aSeg[is]);\n        if( sz>szPromote ) return;\n        fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1);\n        if( p->rc ) return;\n        memcpy(pOut->aSeg, &pLvl->aSeg[is], sizeof(Fts5StructureSegment));\n        pOut->nSeg++;\n        pLvl->nSeg--;\n      }\n    }\n  }\n}\n\n/*\n** A new segment has just been written to level iLvl of index structure\n** pStruct. This function determines if any segments should be promoted\n** as a result. Segments are promoted in two scenarios:\n**\n**   a) If the segment just written is smaller than one or more segments\n**      within the previous populated level, it is promoted to the previous\n**      populated level.\n**\n**   b) If the segment just written is larger than the newest segment on\n**      the next populated level, then that segment, and any other adjacent\n**      segments that are also smaller than the one just written, are \n**      promoted. \n**\n** If one or more segments are promoted, the structure object is updated\n** to reflect this.\n*/\nstatic void fts5StructurePromote(\n  Fts5Index *p,                   /* FTS5 backend object */\n  int iLvl,                       /* Index level just updated */\n  Fts5Structure *pStruct          /* Index structure */\n){\n  if( p->rc==SQLITE_OK ){\n    int iTst;\n    int iPromote = -1;\n    int szPromote = 0;            /* Promote anything this size or smaller */\n    Fts5StructureSegment *pSeg;   /* Segment just written */\n    int szSeg;                    /* Size of segment just written */\n    int nSeg = pStruct->aLevel[iLvl].nSeg;\n\n    if( nSeg==0 ) return;\n    pSeg = &pStruct->aLevel[iLvl].aSeg[pStruct->aLevel[iLvl].nSeg-1];\n    szSeg = (1 + pSeg->pgnoLast - pSeg->pgnoFirst);\n\n    /* Check for condition (a) */\n    for(iTst=iLvl-1; iTst>=0 && pStruct->aLevel[iTst].nSeg==0; iTst--);\n    if( iTst>=0 ){\n      int i;\n      int szMax = 0;\n      Fts5StructureLevel *pTst = &pStruct->aLevel[iTst];\n      assert( pTst->nMerge==0 );\n      for(i=0; i<pTst->nSeg; i++){\n        int sz = pTst->aSeg[i].pgnoLast - pTst->aSeg[i].pgnoFirst + 1;\n        if( sz>szMax ) szMax = sz;\n      }\n      if( szMax>=szSeg ){\n        /* Condition (a) is true. Promote the newest segment on level \n        ** iLvl to level iTst.  */\n        iPromote = iTst;\n        szPromote = szMax;\n      }\n    }\n\n    /* If condition (a) is not met, assume (b) is true. StructurePromoteTo()\n    ** is a no-op if it is not.  */\n    if( iPromote<0 ){\n      iPromote = iLvl;\n      szPromote = szSeg;\n    }\n    fts5StructurePromoteTo(p, iPromote, szPromote, pStruct);\n  }\n}\n\n\n/*\n** Advance the iterator passed as the only argument. If the end of the \n** doclist-index page is reached, return non-zero.\n*/\nstatic int fts5DlidxLvlNext(Fts5DlidxLvl *pLvl){\n  Fts5Data *pData = pLvl->pData;\n\n  if( pLvl->iOff==0 ){\n    assert( pLvl->bEof==0 );\n    pLvl->iOff = 1;\n    pLvl->iOff += fts5GetVarint32(&pData->p[1], pLvl->iLeafPgno);\n    pLvl->iOff += fts5GetVarint(&pData->p[pLvl->iOff], (u64*)&pLvl->iRowid);\n    pLvl->iFirstOff = pLvl->iOff;\n  }else{\n    int iOff;\n    for(iOff=pLvl->iOff; iOff<pData->nn; iOff++){\n      if( pData->p[iOff] ) break; \n    }\n\n    if( iOff<pData->nn ){\n      i64 iVal;\n      pLvl->iLeafPgno += (iOff - pLvl->iOff) + 1;\n      iOff += fts5GetVarint(&pData->p[iOff], (u64*)&iVal);\n      pLvl->iRowid += iVal;\n      pLvl->iOff = iOff;\n    }else{\n      pLvl->bEof = 1;\n    }\n  }\n\n  return pLvl->bEof;\n}\n\n/*\n** Advance the iterator passed as the only argument.\n*/\nstatic int fts5DlidxIterNextR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlNext(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterNextR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ) fts5DlidxLvlNext(pLvl);\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterNext(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterNextR(p, pIter, 0);\n}\n\n/*\n** The iterator passed as the first argument has the following fields set\n** as follows. This function sets up the rest of the iterator so that it\n** points to the first rowid in the doclist-index.\n**\n**   pData:\n**     pointer to doclist-index record, \n**\n** When this function is called pIter->iLeafPgno is the page number the\n** doclist is associated with (the one featuring the term).\n*/\nstatic int fts5DlidxIterFirst(Fts5DlidxIter *pIter){\n  int i;\n  for(i=0; i<pIter->nLvl; i++){\n    fts5DlidxLvlNext(&pIter->aLvl[i]);\n  }\n  return pIter->aLvl[0].bEof;\n}\n\n\nstatic int fts5DlidxIterEof(Fts5Index *p, Fts5DlidxIter *pIter){\n  return p->rc!=SQLITE_OK || pIter->aLvl[0].bEof;\n}\n\nstatic void fts5DlidxIterLast(Fts5Index *p, Fts5DlidxIter *pIter){\n  int i;\n\n  /* Advance each level to the last entry on the last page */\n  for(i=pIter->nLvl-1; p->rc==SQLITE_OK && i>=0; i--){\n    Fts5DlidxLvl *pLvl = &pIter->aLvl[i];\n    while( fts5DlidxLvlNext(pLvl)==0 );\n    pLvl->bEof = 0;\n\n    if( i>0 ){\n      Fts5DlidxLvl *pChild = &pLvl[-1];\n      fts5DataRelease(pChild->pData);\n      memset(pChild, 0, sizeof(Fts5DlidxLvl));\n      pChild->pData = fts5DataRead(p, \n          FTS5_DLIDX_ROWID(pIter->iSegid, i-1, pLvl->iLeafPgno)\n      );\n    }\n  }\n}\n\n/*\n** Move the iterator passed as the only argument to the previous entry.\n*/\nstatic int fts5DlidxLvlPrev(Fts5DlidxLvl *pLvl){\n  int iOff = pLvl->iOff;\n\n  assert( pLvl->bEof==0 );\n  if( iOff<=pLvl->iFirstOff ){\n    pLvl->bEof = 1;\n  }else{\n    u8 *a = pLvl->pData->p;\n    i64 iVal;\n    int iLimit;\n    int ii;\n    int nZero = 0;\n\n    /* Currently iOff points to the first byte of a varint. This block \n    ** decrements iOff until it points to the first byte of the previous \n    ** varint. Taking care not to read any memory locations that occur\n    ** before the buffer in memory.  */\n    iLimit = (iOff>9 ? iOff-9 : 0);\n    for(iOff--; iOff>iLimit; iOff--){\n      if( (a[iOff-1] & 0x80)==0 ) break;\n    }\n\n    fts5GetVarint(&a[iOff], (u64*)&iVal);\n    pLvl->iRowid -= iVal;\n    pLvl->iLeafPgno--;\n\n    /* Skip backwards past any 0x00 varints. */\n    for(ii=iOff-1; ii>=pLvl->iFirstOff && a[ii]==0x00; ii--){\n      nZero++;\n    }\n    if( ii>=pLvl->iFirstOff && (a[ii] & 0x80) ){\n      /* The byte immediately before the last 0x00 byte has the 0x80 bit\n      ** set. So the last 0x00 is only a varint 0 if there are 8 more 0x80\n      ** bytes before a[ii]. */\n      int bZero = 0;              /* True if last 0x00 counts */\n      if( (ii-8)>=pLvl->iFirstOff ){\n        int j;\n        for(j=1; j<=8 && (a[ii-j] & 0x80); j++);\n        bZero = (j>8);\n      }\n      if( bZero==0 ) nZero--;\n    }\n    pLvl->iLeafPgno -= nZero;\n    pLvl->iOff = iOff - nZero;\n  }\n\n  return pLvl->bEof;\n}\n\nstatic int fts5DlidxIterPrevR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlPrev(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterPrevR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ){\n          while( fts5DlidxLvlNext(pLvl)==0 );\n          pLvl->bEof = 0;\n        }\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterPrev(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterPrevR(p, pIter, 0);\n}\n\n/*\n** Free a doclist-index iterator object allocated by fts5DlidxIterInit().\n*/\nstatic void fts5DlidxIterFree(Fts5DlidxIter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nLvl; i++){\n      fts5DataRelease(pIter->aLvl[i].pData);\n    }\n    sqlite3_free(pIter);\n  }\n}\n\nstatic Fts5DlidxIter *fts5DlidxIterInit(\n  Fts5Index *p,                   /* Fts5 Backend to iterate within */\n  int bRev,                       /* True for ORDER BY ASC */\n  int iSegid,                     /* Segment id */\n  int iLeafPg                     /* Leaf page number to load dlidx for */\n){\n  Fts5DlidxIter *pIter = 0;\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);\n    Fts5DlidxIter *pNew;\n\n    pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);\n    if( pNew==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      i64 iRowid = FTS5_DLIDX_ROWID(iSegid, i, iLeafPg);\n      Fts5DlidxLvl *pLvl = &pNew->aLvl[i];\n      pIter = pNew;\n      memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n      pLvl->pData = fts5DataRead(p, iRowid);\n      if( pLvl->pData && (pLvl->pData->p[0] & 0x0001)==0 ){\n        bDone = 1;\n      }\n      pIter->nLvl = i+1;\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iSegid = iSegid;\n    if( bRev==0 ){\n      fts5DlidxIterFirst(pIter);\n    }else{\n      fts5DlidxIterLast(p, pIter);\n    }\n  }\n\n  if( p->rc!=SQLITE_OK ){\n    fts5DlidxIterFree(pIter);\n    pIter = 0;\n  }\n\n  return pIter;\n}\n\nstatic i64 fts5DlidxIterRowid(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iRowid;\n}\nstatic int fts5DlidxIterPgno(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iLeafPgno;\n}\n\n/*\n** Load the next leaf page into the segment iterator.\n*/\nstatic void fts5SegIterNextPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter              /* Iterator to advance to next page */\n){\n  Fts5Data *pLeaf;\n  Fts5StructureSegment *pSeg = pIter->pSeg;\n  fts5DataRelease(pIter->pLeaf);\n  pIter->iLeafPgno++;\n  if( pIter->pNextLeaf ){\n    pIter->pLeaf = pIter->pNextLeaf;\n    pIter->pNextLeaf = 0;\n  }else if( pIter->iLeafPgno<=pSeg->pgnoLast ){\n    pIter->pLeaf = fts5LeafRead(p, \n        FTS5_SEGMENT_ROWID(pSeg->iSegid, pIter->iLeafPgno)\n    );\n  }else{\n    pIter->pLeaf = 0;\n  }\n  pLeaf = pIter->pLeaf;\n\n  if( pLeaf ){\n    pIter->iPgidxOff = pLeaf->szLeaf;\n    if( fts5LeafIsTermless(pLeaf) ){\n      pIter->iEndofDoclist = pLeaf->nn+1;\n    }else{\n      pIter->iPgidxOff += fts5GetVarint32(&pLeaf->p[pIter->iPgidxOff],\n          pIter->iEndofDoclist\n      );\n    }\n  }\n}\n\n/*\n** Argument p points to a buffer containing a varint to be interpreted as a\n** position list size field. Read the varint and return the number of bytes\n** read. Before returning, set *pnSz to the number of bytes in the position\n** list, and *pbDel to true if the delete flag is set, or false otherwise.\n*/\nstatic int fts5GetPoslistSize(const u8 *p, int *pnSz, int *pbDel){\n  int nSz;\n  int n = 0;\n  fts5FastGetVarint32(p, n, nSz);\n  assert_nc( nSz>=0 );\n  *pnSz = nSz/2;\n  *pbDel = nSz & 0x0001;\n  return n;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of a\n** position-list size field. Read the value of the field and store it\n** in the following variables:\n**\n**   Fts5SegIter.nPos\n**   Fts5SegIter.bDel\n**\n** Leave Fts5SegIter.iLeafOffset pointing to the first byte of the \n** position list content (if any).\n*/\nstatic void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){\n  if( p->rc==SQLITE_OK ){\n    int iOff = pIter->iLeafOffset;  /* Offset to read at */\n    ASSERT_SZLEAF_OK(pIter->pLeaf);\n    if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n      int iEod = MIN(pIter->iEndofDoclist, pIter->pLeaf->szLeaf);\n      pIter->bDel = 0;\n      pIter->nPos = 1;\n      if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n        pIter->bDel = 1;\n        iOff++;\n        if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n          pIter->nPos = 1;\n          iOff++;\n        }else{\n          pIter->nPos = 0;\n        }\n      }\n    }else{\n      int nSz;\n      fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n    pIter->iLeafOffset = iOff;\n  }\n}\n\nstatic void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  if( iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( pIter->pLeaf==0 ){\n      if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;\n      return;\n    }\n    iOff = 4;\n    a = pIter->pLeaf->p;\n  }\n  iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n  pIter->iLeafOffset = iOff;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of the \n** \"nSuffix\" field of a term. Function parameter nKeep contains the value\n** of the \"nPrefix\" field (if there was one - it is passed 0 if this is\n** the first term in the segment).\n**\n** This function populates:\n**\n**   Fts5SegIter.term\n**   Fts5SegIter.rowid\n**\n** accordingly and leaves (Fts5SegIter.iLeafOffset) set to the content of\n** the first position list. The position list belonging to document \n** (Fts5SegIter.iRowid).\n*/\nstatic void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;  /* Offset to read at */\n  int nNew;                       /* Bytes of new data */\n\n  iOff += fts5GetVarint32(&a[iOff], nNew);\n  if( iOff+nNew>pIter->pLeaf->nn ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n  pIter->term.n = nKeep;\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n  iOff += nNew;\n  pIter->iTermLeafOffset = iOff;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n  pIter->iLeafOffset = iOff;\n\n  if( pIter->iPgidxOff>=pIter->pLeaf->nn ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    pIter->iPgidxOff += fts5GetVarint32(&a[pIter->iPgidxOff], nExtra);\n    pIter->iEndofDoclist += nExtra;\n  }\n\n  fts5SegIterLoadRowid(p, pIter);\n}\n\nstatic void fts5SegIterNext(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_Reverse(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_None(Fts5Index*, Fts5SegIter*, int*);\n\nstatic void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){\n  if( pIter->flags & FTS5_SEGITER_REVERSE ){\n    pIter->xNext = fts5SegIterNext_Reverse;\n  }else if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pIter->xNext = fts5SegIterNext_None;\n  }else{\n    pIter->xNext = fts5SegIterNext;\n  }\n}\n\n/*\n** Initialize the iterator object pIter to iterate through the entries in\n** segment pSeg. The iterator is left pointing to the first entry when \n** this function returns.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterInit(\n  Fts5Index *p,                   /* FTS index object */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  if( pSeg->pgnoFirst==0 ){\n    /* This happens if the segment is being used as an input to an incremental\n    ** merge and all data has already been \"trimmed\". See function\n    ** fts5TrimSegments() for details. In this case leave the iterator empty.\n    ** The caller will see the (pIter->pLeaf==0) and assume the iterator is\n    ** at EOF already. */\n    assert( pIter->pLeaf==0 );\n    return;\n  }\n\n  if( p->rc==SQLITE_OK ){\n    memset(pIter, 0, sizeof(*pIter));\n    fts5SegIterSetNext(p, pIter);\n    pIter->pSeg = pSeg;\n    pIter->iLeafPgno = pSeg->pgnoFirst-1;\n    fts5SegIterNextPage(p, pIter);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iLeafOffset = 4;\n    assert_nc( pIter->pLeaf->nn>4 );\n    assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );\n    pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;\n    fts5SegIterLoadTerm(p, pIter, 0);\n    fts5SegIterLoadNPos(p, pIter);\n  }\n}\n\n/*\n** This function is only ever called on iterators created by calls to\n** Fts5IndexQuery() with the FTS5INDEX_QUERY_DESC flag set.\n**\n** The iterator is in an unusual state when this function is called: the\n** Fts5SegIter.iLeafOffset variable is set to the offset of the start of\n** the position-list size field for the first relevant rowid on the page.\n** Fts5SegIter.rowid is set, but nPos and bDel are not.\n**\n** This function advances the iterator so that it points to the last \n** relevant rowid on the page and, if necessary, initializes the \n** aRowidOffset[] and iRowidOffset variables. At this point the iterator\n** is in its regular state - Fts5SegIter.iLeafOffset points to the first\n** byte of the position list content associated with said rowid.\n*/\nstatic void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){\n  int eDetail = p->pConfig->eDetail;\n  int n = pIter->pLeaf->szLeaf;\n  int i = pIter->iLeafOffset;\n  u8 *a = pIter->pLeaf->p;\n  int iRowidOffset = 0;\n\n  if( n>pIter->iEndofDoclist ){\n    n = pIter->iEndofDoclist;\n  }\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  while( 1 ){\n    i64 iDelta = 0;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      /* todo */\n      if( i<n && a[i]==0 ){\n        i++;\n        if( i<n && a[i]==0 ) i++;\n      }\n    }else{\n      int nPos;\n      int bDummy;\n      i += fts5GetPoslistSize(&a[i], &nPos, &bDummy);\n      i += nPos;\n    }\n    if( i>=n ) break;\n    i += fts5GetVarint(&a[i], (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* If necessary, grow the pIter->aRowidOffset[] array. */\n    if( iRowidOffset>=pIter->nRowidOffset ){\n      int nNew = pIter->nRowidOffset + 8;\n      int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));\n      if( aNew==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n      pIter->aRowidOffset = aNew;\n      pIter->nRowidOffset = nNew;\n    }\n\n    pIter->aRowidOffset[iRowidOffset++] = pIter->iLeafOffset;\n    pIter->iLeafOffset = i;\n  }\n  pIter->iRowidOffset = iRowidOffset;\n  fts5SegIterLoadNPos(p, pIter);\n}\n\n/*\n**\n*/\nstatic void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n  while( p->rc==SQLITE_OK && pIter->iLeafPgno>pIter->iTermLeafPgno ){\n    Fts5Data *pNew;\n    pIter->iLeafPgno--;\n    pNew = fts5DataRead(p, FTS5_SEGMENT_ROWID(\n          pIter->pSeg->iSegid, pIter->iLeafPgno\n    ));\n    if( pNew ){\n      /* iTermLeafOffset may be equal to szLeaf if the term is the last\n      ** thing on the page - i.e. the first rowid is on the following page.\n      ** In this case leave pIter->pLeaf==0, this iterator is at EOF. */\n      if( pIter->iLeafPgno==pIter->iTermLeafPgno ){\n        assert( pIter->pLeaf==0 );\n        if( pIter->iTermLeafOffset<pNew->szLeaf ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = pIter->iTermLeafOffset;\n        }\n      }else{\n        int iRowidOff;\n        iRowidOff = fts5LeafFirstRowidOff(pNew);\n        if( iRowidOff ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = iRowidOff;\n        }\n      }\n\n      if( pIter->pLeaf ){\n        u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];\n        pIter->iLeafOffset += fts5GetVarint(a, (u64*)&pIter->iRowid);\n        break;\n      }else{\n        fts5DataRelease(pNew);\n      }\n    }\n  }\n\n  if( pIter->pLeaf ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n    fts5SegIterReverseInitPage(p, pIter);\n  }\n}\n\n/*\n** Return true if the iterator passed as the second argument currently\n** points to a delete marker. A delete marker is an entry with a 0 byte\n** position-list.\n*/\nstatic int fts5MultiIterIsEmpty(Fts5Index *p, Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n  return (p->rc==SQLITE_OK && pSeg->pLeaf && pSeg->nPos==0);\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used by reverse iterators.\n*/\nstatic void fts5SegIterNext_Reverse(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbUnused                   /* Unused */\n){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->pNextLeaf==0 );\n  UNUSED_PARAM(pbUnused);\n\n  if( pIter->iRowidOffset>0 ){\n    u8 *a = pIter->pLeaf->p;\n    int iOff;\n    i64 iDelta;\n\n    pIter->iRowidOffset--;\n    pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset];\n    fts5SegIterLoadNPos(p, pIter);\n    iOff = pIter->iLeafOffset;\n    if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){\n      iOff += pIter->nPos;\n    }\n    fts5GetVarint(&a[iOff], (u64*)&iDelta);\n    pIter->iRowid -= iDelta;\n  }else{\n    fts5SegIterReverseNewPage(p, pIter);\n  }\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used if detail=none and the\n** iterator is not a reverse direction iterator.\n*/\nstatic void fts5SegIterNext_None(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  int iOff;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (pIter->flags & FTS5_SEGITER_REVERSE)==0 );\n  assert( p->pConfig->eDetail==FTS5_DETAIL_NONE );\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  iOff = pIter->iLeafOffset;\n\n  /* Next entry is on the next page */\n  if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( p->rc || pIter->pLeaf==0 ) return;\n    pIter->iRowid = 0;\n    iOff = 4;\n  }\n\n  if( iOff<pIter->iEndofDoclist ){\n    /* Next entry is on the current page */\n    i64 iDelta;\n    iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], (u64*)&iDelta);\n    pIter->iLeafOffset = iOff;\n    pIter->iRowid += iDelta;\n  }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){\n    if( pIter->pSeg ){\n      int nKeep = 0;\n      if( iOff!=fts5LeafFirstTermOff(pIter->pLeaf) ){\n        iOff += fts5GetVarint32(&pIter->pLeaf->p[iOff], nKeep);\n      }\n      pIter->iLeafOffset = iOff;\n      fts5SegIterLoadTerm(p, pIter, nKeep);\n    }else{\n      const u8 *pList = 0;\n      const char *zTerm = 0;\n      int nList;\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n      if( pList==0 ) goto next_none_eof;\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList;\n      sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n    }\n\n    if( pbNewTerm ) *pbNewTerm = 1;\n  }else{\n    goto next_none_eof;\n  }\n\n  fts5SegIterLoadNPos(p, pIter);\n\n  return;\n next_none_eof:\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n}\n\n\n/*\n** Advance iterator pIter to the next entry. \n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. It \n** is not considered an error if the iterator reaches EOF. If an error has \n** already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterNext(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  Fts5Data *pLeaf = pIter->pLeaf;\n  int iOff;\n  int bNewTerm = 0;\n  int nKeep = 0;\n  u8 *a;\n  int n;\n\n  assert( pbNewTerm==0 || *pbNewTerm==0 );\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  /* Search for the end of the position list within the current page. */\n  a = pLeaf->p;\n  n = pLeaf->szLeaf;\n\n  ASSERT_SZLEAF_OK(pLeaf);\n  iOff = pIter->iLeafOffset + pIter->nPos;\n\n  if( iOff<n ){\n    /* The next entry is on the current page. */\n    assert_nc( iOff<=pIter->iEndofDoclist );\n    if( iOff>=pIter->iEndofDoclist ){\n      bNewTerm = 1;\n      if( iOff!=fts5LeafFirstTermOff(pLeaf) ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }else{\n      u64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], &iDelta);\n      pIter->iRowid += iDelta;\n      assert_nc( iDelta>0 );\n    }\n    pIter->iLeafOffset = iOff;\n\n  }else if( pIter->pSeg==0 ){\n    const u8 *pList = 0;\n    const char *zTerm = 0;\n    int nList = 0;\n    assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm );\n    if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n    }\n    if( pList==0 ){\n      fts5DataRelease(pIter->pLeaf);\n      pIter->pLeaf = 0;\n    }else{\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList+1;\n      sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),\n          (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n      *pbNewTerm = 1;\n    }\n  }else{\n    iOff = 0;\n    /* Next entry is not on the current page */\n    while( iOff==0 ){\n      fts5SegIterNextPage(p, pIter);\n      pLeaf = pIter->pLeaf;\n      if( pLeaf==0 ) break;\n      ASSERT_SZLEAF_OK(pLeaf);\n      if( (iOff = fts5LeafFirstRowidOff(pLeaf)) && iOff<pLeaf->szLeaf ){\n        iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n\n        if( pLeaf->nn>pLeaf->szLeaf ){\n          pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n              &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist\n          );\n        }\n      }\n      else if( pLeaf->nn>pLeaf->szLeaf ){\n        pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n            &pLeaf->p[pLeaf->szLeaf], iOff\n        );\n        pIter->iLeafOffset = iOff;\n        pIter->iEndofDoclist = iOff;\n        bNewTerm = 1;\n      }\n      assert_nc( iOff<pLeaf->szLeaf );\n      if( iOff>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n        return;\n      }\n    }\n  }\n\n  /* Check if the iterator is now at EOF. If so, return early. */\n  if( pIter->pLeaf ){\n    if( bNewTerm ){\n      if( pIter->flags & FTS5_SEGITER_ONETERM ){\n        fts5DataRelease(pIter->pLeaf);\n        pIter->pLeaf = 0;\n      }else{\n        fts5SegIterLoadTerm(p, pIter, nKeep);\n        fts5SegIterLoadNPos(p, pIter);\n        if( pbNewTerm ) *pbNewTerm = 1;\n      }\n    }else{\n      /* The following could be done by calling fts5SegIterLoadNPos(). But\n      ** this block is particularly performance critical, so equivalent\n      ** code is inlined. \n      **\n      ** Later: Switched back to fts5SegIterLoadNPos() because it supports\n      ** detail=none mode. Not ideal.\n      */\n      int nSz;\n      assert( p->rc==SQLITE_OK );\n      assert( pIter->iLeafOffset<=pIter->pLeaf->nn );\n      fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n  }\n}\n\n#define SWAPVAL(T, a, b) { T tmp; tmp=a; a=b; b=tmp; }\n\n#define fts5IndexSkipVarint(a, iOff) {            \\\n  int iEnd = iOff+9;                              \\\n  while( (a[iOff++] & 0x80) && iOff<iEnd );       \\\n}\n\n/*\n** Iterator pIter currently points to the first rowid in a doclist. This\n** function sets the iterator up so that iterates in reverse order through\n** the doclist.\n*/\nstatic void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  Fts5Data *pLast = 0;\n  int pgnoLast = 0;\n\n  if( pDlidx ){\n    int iSegid = pIter->pSeg->iSegid;\n    pgnoLast = fts5DlidxIterPgno(pDlidx);\n    pLast = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast));\n  }else{\n    Fts5Data *pLeaf = pIter->pLeaf;         /* Current leaf data */\n\n    /* Currently, Fts5SegIter.iLeafOffset points to the first byte of\n    ** position-list content for the current rowid. Back it up so that it\n    ** points to the start of the position-list size field. */\n    int iPoslist;\n    if( pIter->iTermLeafPgno==pIter->iLeafPgno ){\n      iPoslist = pIter->iTermLeafOffset;\n    }else{\n      iPoslist = 4;\n    }\n    fts5IndexSkipVarint(pLeaf->p, iPoslist);\n    pIter->iLeafOffset = iPoslist;\n\n    /* If this condition is true then the largest rowid for the current\n    ** term may not be stored on the current page. So search forward to\n    ** see where said rowid really is.  */\n    if( pIter->iEndofDoclist>=pLeaf->szLeaf ){\n      int pgno;\n      Fts5StructureSegment *pSeg = pIter->pSeg;\n\n      /* The last rowid in the doclist may not be on the current page. Search\n      ** forward to find the page containing the last rowid.  */\n      for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){\n        i64 iAbs = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno);\n        Fts5Data *pNew = fts5DataRead(p, iAbs);\n        if( pNew ){\n          int iRowid, bTermless;\n          iRowid = fts5LeafFirstRowidOff(pNew);\n          bTermless = fts5LeafIsTermless(pNew);\n          if( iRowid ){\n            SWAPVAL(Fts5Data*, pNew, pLast);\n            pgnoLast = pgno;\n          }\n          fts5DataRelease(pNew);\n          if( bTermless==0 ) break;\n        }\n      }\n    }\n  }\n\n  /* If pLast is NULL at this point, then the last rowid for this doclist\n  ** lies on the page currently indicated by the iterator. In this case \n  ** pIter->iLeafOffset is already set to point to the position-list size\n  ** field associated with the first relevant rowid on the page.\n  **\n  ** Or, if pLast is non-NULL, then it is the page that contains the last\n  ** rowid. In this case configure the iterator so that it points to the\n  ** first rowid on this page.\n  */\n  if( pLast ){\n    int iOff;\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = pLast;\n    pIter->iLeafPgno = pgnoLast;\n    iOff = fts5LeafFirstRowidOff(pLast);\n    iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);\n    pIter->iLeafOffset = iOff;\n\n    if( fts5LeafIsTermless(pLast) ){\n      pIter->iEndofDoclist = pLast->nn+1;\n    }else{\n      pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);\n    }\n\n  }\n\n  fts5SegIterReverseInitPage(p, pIter);\n}\n\n/*\n** Iterator pIter currently points to the first rowid of a doclist.\n** There is a doclist-index associated with the final term on the current \n** page. If the current term is the last term on the page, load the \n** doclist-index from disk and initialize an iterator at (pIter->pDlidx).\n*/\nstatic void fts5SegIterLoadDlidx(Fts5Index *p, Fts5SegIter *pIter){\n  int iSeg = pIter->pSeg->iSegid;\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx==0 );\n\n  /* Check if the current doclist ends on this page. If it does, return\n  ** early without loading the doclist-index (as it belongs to a different\n  ** term. */\n  if( pIter->iTermLeafPgno==pIter->iLeafPgno \n   && pIter->iEndofDoclist<pLeaf->szLeaf \n  ){\n    return;\n  }\n\n  pIter->pDlidx = fts5DlidxIterInit(p, bRev, iSeg, pIter->iTermLeafPgno);\n}\n\n/*\n** The iterator object passed as the second argument currently contains\n** no valid values except for the Fts5SegIter.pLeaf member variable. This\n** function searches the leaf page for a term matching (pTerm/nTerm).\n**\n** If the specified term is found on the page, then the iterator is left\n** pointing to it. If argument bGe is zero and the term is not found,\n** the iterator is left pointing at EOF.\n**\n** If bGe is non-zero and the specified term is not found, then the\n** iterator is left pointing to the smallest term in the segment that\n** is larger than the specified term, even if this term is not on the\n** current page.\n*/\nstatic void fts5LeafSeek(\n  Fts5Index *p,                   /* Leave any error code here */\n  int bGe,                        /* True for a >= search */\n  Fts5SegIter *pIter,             /* Iterator to seek */\n  const u8 *pTerm, int nTerm      /* Term to search for */\n){\n  int iOff;\n  const u8 *a = pIter->pLeaf->p;\n  int szLeaf = pIter->pLeaf->szLeaf;\n  int n = pIter->pLeaf->nn;\n\n  int nMatch = 0;\n  int nKeep = 0;\n  int nNew = 0;\n  int iTermOff;\n  int iPgidx;                     /* Current offset in pgidx */\n  int bEndOfPage = 0;\n\n  assert( p->rc==SQLITE_OK );\n\n  iPgidx = szLeaf;\n  iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff);\n  iOff = iTermOff;\n  if( iOff>n ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n\n  while( 1 ){\n\n    /* Figure out how many new bytes are in this term */\n    fts5FastGetVarint32(a, iOff, nNew);\n    if( nKeep<nMatch ){\n      goto search_failed;\n    }\n\n    assert( nKeep>=nMatch );\n    if( nKeep==nMatch ){\n      int nCmp;\n      int i;\n      nCmp = MIN(nNew, nTerm-nMatch);\n      for(i=0; i<nCmp; i++){\n        if( a[iOff+i]!=pTerm[nMatch+i] ) break;\n      }\n      nMatch += i;\n\n      if( nTerm==nMatch ){\n        if( i==nNew ){\n          goto search_success;\n        }else{\n          goto search_failed;\n        }\n      }else if( i<nNew && a[iOff+i]>pTerm[nMatch] ){\n        goto search_failed;\n      }\n    }\n\n    if( iPgidx>=n ){\n      bEndOfPage = 1;\n      break;\n    }\n\n    iPgidx += fts5GetVarint32(&a[iPgidx], nKeep);\n    iTermOff += nKeep;\n    iOff = iTermOff;\n\n    if( iOff>=n ){\n      p->rc = FTS5_CORRUPT;\n      return;\n    }\n\n    /* Read the nKeep field of the next term. */\n    fts5FastGetVarint32(a, iOff, nKeep);\n  }\n\n search_failed:\n  if( bGe==0 ){\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = 0;\n    return;\n  }else if( bEndOfPage ){\n    do {\n      fts5SegIterNextPage(p, pIter);\n      if( pIter->pLeaf==0 ) return;\n      a = pIter->pLeaf->p;\n      if( fts5LeafIsTermless(pIter->pLeaf)==0 ){\n        iPgidx = pIter->pLeaf->szLeaf;\n        iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);\n        if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){\n          p->rc = FTS5_CORRUPT;\n        }else{\n          nKeep = 0;\n          iTermOff = iOff;\n          n = pIter->pLeaf->nn;\n          iOff += fts5GetVarint32(&a[iOff], nNew);\n          break;\n        }\n      }\n    }while( 1 );\n  }\n\n search_success:\n\n  pIter->iLeafOffset = iOff + nNew;\n  pIter->iTermLeafOffset = pIter->iLeafOffset;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n\n  fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n\n  if( iPgidx>=n ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    iPgidx += fts5GetVarint32(&a[iPgidx], nExtra);\n    pIter->iEndofDoclist = iTermOff + nExtra;\n  }\n  pIter->iPgidxOff = iPgidx;\n\n  fts5SegIterLoadRowid(p, pIter);\n  fts5SegIterLoadNPos(p, pIter);\n}\n\nstatic sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){\n  if( p->pIdxSelect==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf(\n          \"SELECT pgno FROM '%q'.'%q_idx' WHERE \"\n          \"segid=? AND term<=? ORDER BY term DESC LIMIT 1\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  return p->pIdxSelect;\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within segment\n** pSeg. If there is no such term in the index, the iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterSeekInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  int iPg = 1;\n  int bGe = (flags & FTS5INDEX_QUERY_SCAN);\n  int bDlidx = 0;                 /* True if there is a doclist-index */\n  sqlite3_stmt *pIdxSelect = 0;\n\n  assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 );\n  assert( pTerm && nTerm );\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->pSeg = pSeg;\n\n  /* This block sets stack variable iPg to the leaf page number that may\n  ** contain term (pTerm/nTerm), if it is present in the segment. */\n  pIdxSelect = fts5IdxSelectStmt(p);\n  if( p->rc ) return;\n  sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid);\n  sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){\n    i64 val = sqlite3_column_int(pIdxSelect, 0);\n    iPg = (int)(val>>1);\n    bDlidx = (val & 0x0001);\n  }\n  p->rc = sqlite3_reset(pIdxSelect);\n\n  if( iPg<pSeg->pgnoFirst ){\n    iPg = pSeg->pgnoFirst;\n    bDlidx = 0;\n  }\n\n  pIter->iLeafPgno = iPg - 1;\n  fts5SegIterNextPage(p, pIter);\n\n  if( pIter->pLeaf ){\n    fts5LeafSeek(p, bGe, pIter, pTerm, nTerm);\n  }\n\n  if( p->rc==SQLITE_OK && bGe==0 ){\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    if( pIter->pLeaf ){\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n      }\n      if( bDlidx ){\n        fts5SegIterLoadDlidx(p, pIter);\n      }\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        fts5SegIterReverse(p, pIter);\n      }\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n\n  /* Either:\n  **\n  **   1) an error has occurred, or\n  **   2) the iterator points to EOF, or\n  **   3) the iterator points to an entry with term (pTerm/nTerm), or\n  **   4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points\n  **      to an entry with a term greater than or equal to (pTerm/nTerm).\n  */\n  assert( p->rc!=SQLITE_OK                                          /* 1 */\n   || pIter->pLeaf==0                                               /* 2 */\n   || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0          /* 3 */\n   || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0)  /* 4 */\n  );\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within the\n** in-memory hash table. If there is no such term in the hash-table, the \n** iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterHashInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  const u8 *pList = 0;\n  int nList = 0;\n  const u8 *z = 0;\n  int n = 0;\n\n  assert( p->pHash );\n  assert( p->rc==SQLITE_OK );\n\n  if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){\n    p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);\n    sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);\n    n = (z ? (int)strlen((const char*)z) : 0);\n  }else{\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    sqlite3Fts5HashQuery(p->pHash, (const char*)pTerm, nTerm, &pList, &nList);\n    z = pTerm;\n    n = nTerm;\n  }\n\n  if( pList ){\n    Fts5Data *pLeaf;\n    sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);\n    pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));\n    if( pLeaf==0 ) return;\n    pLeaf->p = (u8*)pList;\n    pLeaf->nn = pLeaf->szLeaf = nList;\n    pIter->pLeaf = pLeaf;\n    pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);\n    pIter->iEndofDoclist = pLeaf->nn;\n\n    if( flags & FTS5INDEX_QUERY_DESC ){\n      pIter->flags |= FTS5_SEGITER_REVERSE;\n      fts5SegIterReverseInitPage(p, pIter);\n    }else{\n      fts5SegIterLoadNPos(p, pIter);\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n}\n\n/*\n** Zero the iterator passed as the only argument.\n*/\nstatic void fts5SegIterClear(Fts5SegIter *pIter){\n  fts5BufferFree(&pIter->term);\n  fts5DataRelease(pIter->pLeaf);\n  fts5DataRelease(pIter->pNextLeaf);\n  fts5DlidxIterFree(pIter->pDlidx);\n  sqlite3_free(pIter->aRowidOffset);\n  memset(pIter, 0, sizeof(Fts5SegIter));\n}\n\n#ifdef SQLITE_DEBUG\n\n/*\n** This function is used as part of the big assert() procedure implemented by\n** fts5AssertMultiIterSetup(). It ensures that the result currently stored\n** in *pRes is the correct result of comparing the current positions of the\n** two iterators.\n*/\nstatic void fts5AssertComparisonResult(\n  Fts5Iter *pIter, \n  Fts5SegIter *p1,\n  Fts5SegIter *p2,\n  Fts5CResult *pRes\n){\n  int i1 = p1 - pIter->aSeg;\n  int i2 = p2 - pIter->aSeg;\n\n  if( p1->pLeaf || p2->pLeaf ){\n    if( p1->pLeaf==0 ){\n      assert( pRes->iFirst==i2 );\n    }else if( p2->pLeaf==0 ){\n      assert( pRes->iFirst==i1 );\n    }else{\n      int nMin = MIN(p1->term.n, p2->term.n);\n      int res = memcmp(p1->term.p, p2->term.p, nMin);\n      if( res==0 ) res = p1->term.n - p2->term.n;\n\n      if( res==0 ){\n        assert( pRes->bTermEq==1 );\n        assert( p1->iRowid!=p2->iRowid );\n        res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : 1;\n      }else{\n        assert( pRes->bTermEq==0 );\n      }\n\n      if( res<0 ){\n        assert( pRes->iFirst==i1 );\n      }else{\n        assert( pRes->iFirst==i2 );\n      }\n    }\n  }\n}\n\n/*\n** This function is a no-op unless SQLITE_DEBUG is defined when this module\n** is compiled. In that case, this function is essentially an assert() \n** statement used to verify that the contents of the pIter->aFirst[] array\n** are correct.\n*/\nstatic void fts5AssertMultiIterSetup(Fts5Index *p, Fts5Iter *pIter){\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pFirst = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int i;\n\n    assert( (pFirst->pLeaf==0)==pIter->base.bEof );\n\n    /* Check that pIter->iSwitchRowid is set correctly. */\n    for(i=0; i<pIter->nSeg; i++){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      assert( p1==pFirst \n           || p1->pLeaf==0 \n           || fts5BufferCompare(&pFirst->term, &p1->term) \n           || p1->iRowid==pIter->iSwitchRowid\n           || (p1->iRowid<pIter->iSwitchRowid)==pIter->bRev\n      );\n    }\n\n    for(i=0; i<pIter->nSeg; i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      Fts5SegIter *p2 = &pIter->aSeg[i+1];\n      Fts5CResult *pRes = &pIter->aFirst[(pIter->nSeg + i) / 2];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n\n    for(i=1; i<(pIter->nSeg / 2); i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[ pIter->aFirst[i*2].iFirst ];\n      Fts5SegIter *p2 = &pIter->aSeg[ pIter->aFirst[i*2+1].iFirst ];\n      Fts5CResult *pRes = &pIter->aFirst[i];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n  }\n}\n#else\n# define fts5AssertMultiIterSetup(x,y)\n#endif\n\n/*\n** Do the comparison necessary to populate pIter->aFirst[iOut].\n**\n** If the returned value is non-zero, then it is the index of an entry\n** in the pIter->aSeg[] array that is (a) not at EOF, and (b) pointing\n** to a key that is a duplicate of another, higher priority, \n** segment-iterator in the pSeg->aSeg[] array.\n*/\nstatic int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){\n  int i1;                         /* Index of left-hand Fts5SegIter */\n  int i2;                         /* Index of right-hand Fts5SegIter */\n  int iRes;\n  Fts5SegIter *p1;                /* Left-hand Fts5SegIter */\n  Fts5SegIter *p2;                /* Right-hand Fts5SegIter */\n  Fts5CResult *pRes = &pIter->aFirst[iOut];\n\n  assert( iOut<pIter->nSeg && iOut>0 );\n  assert( pIter->bRev==0 || pIter->bRev==1 );\n\n  if( iOut>=(pIter->nSeg/2) ){\n    i1 = (iOut - pIter->nSeg/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pIter->aFirst[iOut*2].iFirst;\n    i2 = pIter->aFirst[iOut*2+1].iFirst;\n  }\n  p1 = &pIter->aSeg[i1];\n  p2 = &pIter->aSeg[i2];\n\n  pRes->bTermEq = 0;\n  if( p1->pLeaf==0 ){           /* If p1 is at EOF */\n    iRes = i2;\n  }else if( p2->pLeaf==0 ){     /* If p2 is at EOF */\n    iRes = i1;\n  }else{\n    int res = fts5BufferCompare(&p1->term, &p2->term);\n    if( res==0 ){\n      assert( i2>i1 );\n      assert( i2!=0 );\n      pRes->bTermEq = 1;\n      if( p1->iRowid==p2->iRowid ){\n        p1->bDel = p2->bDel;\n        return i2;\n      }\n      res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1;\n    }\n    assert( res!=0 );\n    if( res<0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pRes->iFirst = (u16)iRes;\n  return 0;\n}\n\n/*\n** Move the seg-iter so that it points to the first rowid on page iLeafPgno.\n** It is an error if leaf iLeafPgno does not exist or contains no rowids.\n*/\nstatic void fts5SegIterGotoPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int iLeafPgno\n){\n  assert( iLeafPgno>pIter->iLeafPgno );\n\n  if( iLeafPgno>pIter->pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }else{\n    fts5DataRelease(pIter->pNextLeaf);\n    pIter->pNextLeaf = 0;\n    pIter->iLeafPgno = iLeafPgno-1;\n    fts5SegIterNextPage(p, pIter);\n    assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );\n\n    if( p->rc==SQLITE_OK ){\n      int iOff;\n      u8 *a = pIter->pLeaf->p;\n      int n = pIter->pLeaf->szLeaf;\n\n      iOff = fts5LeafFirstRowidOff(pIter->pLeaf);\n      if( iOff<4 || iOff>=n ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n        fts5SegIterLoadNPos(p, pIter);\n      }\n    }\n  }\n}\n\n/*\n** Advance the iterator passed as the second argument until it is at or \n** past rowid iFrom. Regardless of the value of iFrom, the iterator is\n** always advanced at least once.\n*/\nstatic void fts5SegIterNextFrom(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  i64 iMatch                      /* Advance iterator at least this far */\n){\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  int iLeafPgno = pIter->iLeafPgno;\n  int bMove = 1;\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx );\n  assert( pIter->pLeaf );\n\n  if( bRev==0 ){\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch>fts5DlidxIterRowid(pDlidx) ){\n      iLeafPgno = fts5DlidxIterPgno(pDlidx);\n      fts5DlidxIterNext(p, pDlidx);\n    }\n    assert_nc( iLeafPgno>=pIter->iLeafPgno || p->rc );\n    if( iLeafPgno>pIter->iLeafPgno ){\n      fts5SegIterGotoPage(p, pIter, iLeafPgno);\n      bMove = 0;\n    }\n  }else{\n    assert( pIter->pNextLeaf==0 );\n    assert( iMatch<pIter->iRowid );\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch<fts5DlidxIterRowid(pDlidx) ){\n      fts5DlidxIterPrev(p, pDlidx);\n    }\n    iLeafPgno = fts5DlidxIterPgno(pDlidx);\n\n    assert( fts5DlidxIterEof(p, pDlidx) || iLeafPgno<=pIter->iLeafPgno );\n\n    if( iLeafPgno<pIter->iLeafPgno ){\n      pIter->iLeafPgno = iLeafPgno+1;\n      fts5SegIterReverseNewPage(p, pIter);\n      bMove = 0;\n    }\n  }\n\n  do{\n    if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0);\n    if( pIter->pLeaf==0 ) break;\n    if( bRev==0 && pIter->iRowid>=iMatch ) break;\n    if( bRev!=0 && pIter->iRowid<=iMatch ) break;\n    bMove = 1;\n  }while( p->rc==SQLITE_OK );\n}\n\n\n/*\n** Free the iterator object passed as the second argument.\n*/\nstatic void fts5MultiIterFree(Fts5Iter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nSeg; i++){\n      fts5SegIterClear(&pIter->aSeg[i]);\n    }\n    fts5StructureRelease(pIter->pStruct);\n    fts5BufferFree(&pIter->poslist);\n    sqlite3_free(pIter);\n  }\n}\n\nstatic void fts5MultiIterAdvanced(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  int iMinset                     /* Minimum entry in aFirst[] to set */\n){\n  int i;\n  for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){\n    int iEq;\n    if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){\n      Fts5SegIter *pSeg = &pIter->aSeg[iEq];\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, 0);\n      i = pIter->nSeg + iEq;\n    }\n  }\n}\n\n/*\n** Sub-iterator iChanged of iterator pIter has just been advanced. It still\n** points to the same term though - just a different rowid. This function\n** attempts to update the contents of the pIter->aFirst[] accordingly.\n** If it does so successfully, 0 is returned. Otherwise 1.\n**\n** If non-zero is returned, the caller should call fts5MultiIterAdvanced()\n** on the iterator instead. That function does the same as this one, except\n** that it deals with more complicated cases as well.\n*/ \nstatic int fts5MultiIterAdvanceRowid(\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  Fts5SegIter **ppFirst\n){\n  Fts5SegIter *pNew = &pIter->aSeg[iChanged];\n\n  if( pNew->iRowid==pIter->iSwitchRowid\n   || (pNew->iRowid<pIter->iSwitchRowid)==pIter->bRev\n  ){\n    int i;\n    Fts5SegIter *pOther = &pIter->aSeg[iChanged ^ 0x0001];\n    pIter->iSwitchRowid = pIter->bRev ? SMALLEST_INT64 : LARGEST_INT64;\n    for(i=(pIter->nSeg+iChanged)/2; 1; i=i/2){\n      Fts5CResult *pRes = &pIter->aFirst[i];\n\n      assert( pNew->pLeaf );\n      assert( pRes->bTermEq==0 || pOther->pLeaf );\n\n      if( pRes->bTermEq ){\n        if( pNew->iRowid==pOther->iRowid ){\n          return 1;\n        }else if( (pOther->iRowid>pNew->iRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n          pNew = pOther;\n        }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n        }\n      }\n      pRes->iFirst = (u16)(pNew - pIter->aSeg);\n      if( i==1 ) break;\n\n      pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];\n    }\n  }\n\n  *ppFirst = pNew;\n  return 0;\n}\n\n/*\n** Set the pIter->bEof variable based on the state of the sub-iterators.\n*/\nstatic void fts5MultiIterSetEof(Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  pIter->base.bEof = pSeg->pLeaf==0;\n  pIter->iSwitchRowid = pSeg->iRowid;\n}\n\n/*\n** Move the iterator to the next entry. \n**\n** If an error occurs, an error code is left in Fts5Index.rc. It is not \n** considered an error if the iterator reaches EOF, or if it is already at \n** EOF when this function is called.\n*/\nstatic void fts5MultiIterNext(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int bFrom,                      /* True if argument iFrom is valid */\n  i64 iFrom                       /* Advance at least as far as this */\n){\n  int bUseFrom = bFrom;\n  assert( pIter->base.bEof==0 );\n  while( p->rc==SQLITE_OK ){\n    int iFirst = pIter->aFirst[1].iFirst;\n    int bNewTerm = 0;\n    Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n    assert( p->rc==SQLITE_OK );\n    if( bUseFrom && pSeg->pDlidx ){\n      fts5SegIterNextFrom(p, pSeg, iFrom);\n    }else{\n      pSeg->xNext(p, pSeg, &bNewTerm);\n    }\n\n    if( pSeg->pLeaf==0 || bNewTerm \n     || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n    ){\n      fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n      fts5MultiIterSetEof(pIter);\n      pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n      if( pSeg->pLeaf==0 ) return;\n    }\n\n    fts5AssertMultiIterSetup(p, pIter);\n    assert( pSeg==&pIter->aSeg[pIter->aFirst[1].iFirst] && pSeg->pLeaf );\n    if( pIter->bSkipEmpty==0 || pSeg->nPos ){\n      pIter->xSetOutputs(pIter, pSeg);\n      return;\n    }\n    bUseFrom = 0;\n  }\n}\n\nstatic void fts5MultiIterNext2(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int *pbNewTerm                  /* OUT: True if *might* be new term */\n){\n  assert( pIter->bSkipEmpty );\n  if( p->rc==SQLITE_OK ){\n    *pbNewTerm = 0;\n    do{\n      int iFirst = pIter->aFirst[1].iFirst;\n      Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n      int bNewTerm = 0;\n\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, &bNewTerm);\n      if( pSeg->pLeaf==0 || bNewTerm \n       || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n      ){\n        fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n        fts5MultiIterSetEof(pIter);\n        *pbNewTerm = 1;\n      }\n      fts5AssertMultiIterSetup(p, pIter);\n\n    }while( fts5MultiIterIsEmpty(p, pIter) );\n  }\n}\n\nstatic void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){\n  UNUSED_PARAM2(pUnused1, pUnused2);\n}\n\nstatic Fts5Iter *fts5MultiIterAlloc(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  int nSeg\n){\n  Fts5Iter *pNew;\n  int nSlot;                      /* Power of two >= nSeg */\n\n  for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2);\n  pNew = fts5IdxMalloc(p, \n      sizeof(Fts5Iter) +                  /* pNew */\n      sizeof(Fts5SegIter) * (nSlot-1) +   /* pNew->aSeg[] */\n      sizeof(Fts5CResult) * nSlot         /* pNew->aFirst[] */\n  );\n  if( pNew ){\n    pNew->nSeg = nSlot;\n    pNew->aFirst = (Fts5CResult*)&pNew->aSeg[nSlot];\n    pNew->pIndex = p;\n    pNew->xSetOutputs = fts5IterSetOutputs_Noop;\n  }\n  return pNew;\n}\n\nstatic void fts5PoslistCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);\n  }\n}\n\ntypedef struct PoslistCallbackCtx PoslistCallbackCtx;\nstruct PoslistCallbackCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int eState;                     /* See above */\n};\n\ntypedef struct PoslistOffsetsCtx PoslistOffsetsCtx;\nstruct PoslistOffsetsCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int iRead;\n  int iWrite;\n};\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5IndexColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic void fts5PoslistOffsetsCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    int i = 0;\n    while( i<nChunk ){\n      int iVal;\n      i += fts5GetVarint32(&pChunk[i], iVal);\n      iVal += pCtx->iRead - 2;\n      pCtx->iRead = iVal;\n      if( fts5IndexColsetTest(pCtx->pColset, iVal) ){\n        fts5BufferSafeAppendVarint(pCtx->pBuf, iVal + 2 - pCtx->iWrite);\n        pCtx->iWrite = iVal;\n      }\n    }\n  }\n}\n\nstatic void fts5PoslistFilterCallback(\n  Fts5Index *pUnused,\n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    /* Search through to find the first varint with value 1. This is the\n    ** start of the next columns hits. */\n    int i = 0;\n    int iStart = 0;\n\n    if( pCtx->eState==2 ){\n      int iCol;\n      fts5FastGetVarint32(pChunk, i, iCol);\n      if( fts5IndexColsetTest(pCtx->pColset, iCol) ){\n        pCtx->eState = 1;\n        fts5BufferSafeAppendVarint(pCtx->pBuf, 1);\n      }else{\n        pCtx->eState = 0;\n      }\n    }\n\n    do {\n      while( i<nChunk && pChunk[i]!=0x01 ){\n        while( pChunk[i] & 0x80 ) i++;\n        i++;\n      }\n      if( pCtx->eState ){\n        fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n      }\n      if( i<nChunk ){\n        int iCol;\n        iStart = i;\n        i++;\n        if( i>=nChunk ){\n          pCtx->eState = 2;\n        }else{\n          fts5FastGetVarint32(pChunk, i, iCol);\n          pCtx->eState = fts5IndexColsetTest(pCtx->pColset, iCol);\n          if( pCtx->eState ){\n            fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n            iStart = i;\n          }\n        }\n      }\n    }while( i<nChunk );\n  }\n}\n\nstatic void fts5ChunkIterate(\n  Fts5Index *p,                   /* Index object */\n  Fts5SegIter *pSeg,              /* Poslist of this iterator */\n  void *pCtx,                     /* Context pointer for xChunk callback */\n  void (*xChunk)(Fts5Index*, void*, const u8*, int)\n){\n  int nRem = pSeg->nPos;          /* Number of bytes still to come */\n  Fts5Data *pData = 0;\n  u8 *pChunk = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  int nChunk = MIN(nRem, pSeg->pLeaf->szLeaf - pSeg->iLeafOffset);\n  int pgno = pSeg->iLeafPgno;\n  int pgnoSave = 0;\n\n  /* This function does notmwork with detail=none databases. */\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){\n    pgnoSave = pgno+1;\n  }\n\n  while( 1 ){\n    xChunk(p, pCtx, pChunk, nChunk);\n    nRem -= nChunk;\n    fts5DataRelease(pData);\n    if( nRem<=0 ){\n      break;\n    }else{\n      pgno++;\n      pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno));\n      if( pData==0 ) break;\n      pChunk = &pData->p[4];\n      nChunk = MIN(nRem, pData->szLeaf - 4);\n      if( pgno==pgnoSave ){\n        assert( pSeg->pNextLeaf==0 );\n        pSeg->pNextLeaf = pData;\n        pData = 0;\n      }\n    }\n  }\n}\n\n/*\n** Iterator pIter currently points to a valid entry (not EOF). This\n** function appends the position list data for the current entry to\n** buffer pBuf. It does not make a copy of the position-list size\n** field.\n*/\nstatic void fts5SegiterPoslist(\n  Fts5Index *p,\n  Fts5SegIter *pSeg,\n  Fts5Colset *pColset,\n  Fts5Buffer *pBuf\n){\n  if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos) ){\n    if( pColset==0 ){\n      fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);\n    }else{\n      if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){\n        PoslistCallbackCtx sCtx;\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        sCtx.eState = fts5IndexColsetTest(pColset, 0);\n        assert( sCtx.eState==0 || sCtx.eState==1 );\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback);\n      }else{\n        PoslistOffsetsCtx sCtx;\n        memset(&sCtx, 0, sizeof(sCtx));\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback);\n      }\n    }\n  }\n}\n\n/*\n** IN/OUT parameter (*pa) points to a position list n bytes in size. If\n** the position list contains entries for column iCol, then (*pa) is set\n** to point to the sub-position-list for that column and the number of\n** bytes in it returned. Or, if the argument position list does not\n** contain any entries for column iCol, return 0.\n*/\nstatic int fts5IndexExtractCol(\n  const u8 **pa,                  /* IN/OUT: Pointer to poslist */\n  int n,                          /* IN: Size of poslist in bytes */\n  int iCol                        /* Column to extract from poslist */\n){\n  int iCurrent = 0;               /* Anything before the first 0x01 is col 0 */\n  const u8 *p = *pa;\n  const u8 *pEnd = &p[n];         /* One byte past end of position list */\n\n  while( iCol>iCurrent ){\n    /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n    ** not part of a varint. Note that it is not possible for a negative\n    ** or extremely large varint to occur within an uncorrupted position \n    ** list. So the last byte of each varint may be assumed to have a clear\n    ** 0x80 bit.  */\n    while( *p!=0x01 ){\n      while( *p++ & 0x80 );\n      if( p>=pEnd ) return 0;\n    }\n    *pa = p++;\n    iCurrent = *p++;\n    if( iCurrent & 0x80 ){\n      p--;\n      p += fts5GetVarint32(p, iCurrent);\n    }\n  }\n  if( iCol!=iCurrent ) return 0;\n\n  /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n  ** not part of a varint */\n  while( p<pEnd && *p!=0x01 ){\n    while( *p++ & 0x80 );\n  }\n\n  return p - (*pa);\n}\n\nstatic void fts5IndexExtractColset(\n  int *pRc,\n  Fts5Colset *pColset,            /* Colset to filter on */\n  const u8 *pPos, int nPos,       /* Position list */\n  Fts5Buffer *pBuf                /* Output buffer */\n){\n  if( *pRc==SQLITE_OK ){\n    int i;\n    fts5BufferZero(pBuf);\n    for(i=0; i<pColset->nCol; i++){\n      const u8 *pSub = pPos;\n      int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]);\n      if( nSub ){\n        fts5BufferAppendBlob(pRc, pBuf, nSub, pSub);\n      }\n    }\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=none tables.\n*/\nstatic void fts5IterSetOutputs_None(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_NONE );\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n}\n\n/*\n** xSetOutputs callback used by detail=full and detail=col tables when no\n** column filters are specified.\n*/\nstatic void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n\n  assert( pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_NONE );\n  assert( pIter->pColset==0 );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    pIter->base.pData = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, 0, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match\n** against no columns at all).\n*/\nstatic void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  UNUSED_PARAM(pSeg);\n  pIter->base.nData = 0;\n}\n\n/*\n** xSetOutputs callback used by detail=col when there is a column filter\n** and there are 100 or more columns. Also called as a fallback from\n** fts5IterSetOutputs_Col100 if the column-list spans more than one page.\n*/\nstatic void fts5IterSetOutputs_Col(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  fts5BufferZero(&pIter->poslist);\n  fts5SegiterPoslist(pIter->pIndex, pSeg, pIter->pColset, &pIter->poslist);\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.pData = pIter->poslist.p;\n  pIter->base.nData = pIter->poslist.n;\n}\n\n/*\n** xSetOutputs callback used when: \n**\n**   * detail=col,\n**   * there is a column filter, and\n**   * the table contains 100 or fewer columns. \n**\n** The last point is to ensure all column numbers are stored as \n** single-byte varints.\n*/\nstatic void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n  assert( pIter->pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){\n    fts5IterSetOutputs_Col(pIter, pSeg);\n  }else{\n    u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];\n    u8 *pEnd = (u8*)&a[pSeg->nPos]; \n    int iPrev = 0;\n    int *aiCol = pIter->pColset->aiCol;\n    int *aiColEnd = &aiCol[pIter->pColset->nCol];\n\n    u8 *aOut = pIter->poslist.p;\n    int iPrevOut = 0;\n\n    pIter->base.iRowid = pSeg->iRowid;\n\n    while( a<pEnd ){\n      iPrev += (int)a++[0] - 2;\n      while( *aiCol<iPrev ){\n        aiCol++;\n        if( aiCol==aiColEnd ) goto setoutputs_col_out;\n      }\n      if( *aiCol==iPrev ){\n        *aOut++ = (u8)((iPrev - iPrevOut) + 2);\n        iPrevOut = iPrev;\n      }\n    }\n\nsetoutputs_col_out:\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = aOut - pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=full when there is a column filter.\n*/\nstatic void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  Fts5Colset *pColset = pIter->pColset;\n  pIter->base.iRowid = pSeg->iRowid;\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_FULL );\n  assert( pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n    if( pColset->nCol==1 ){\n      pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]);\n      pIter->base.pData = a;\n    }else{\n      int *pRc = &pIter->pIndex->rc;\n      fts5BufferZero(&pIter->poslist);\n      fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist);\n      pIter->base.pData = pIter->poslist.p;\n      pIter->base.nData = pIter->poslist.n;\n    }\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, pColset, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = pIter->poslist.n;\n  }\n}\n\nstatic void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){\n  if( *pRc==SQLITE_OK ){\n    Fts5Config *pConfig = pIter->pIndex->pConfig;\n    if( pConfig->eDetail==FTS5_DETAIL_NONE ){\n      pIter->xSetOutputs = fts5IterSetOutputs_None;\n    }\n\n    else if( pIter->pColset==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Nocolset;\n    }\n\n    else if( pIter->pColset->nCol==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset;\n    }\n\n    else if( pConfig->eDetail==FTS5_DETAIL_FULL ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Full;\n    }\n\n    else{\n      assert( pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n      if( pConfig->nCol<=100 ){\n        pIter->xSetOutputs = fts5IterSetOutputs_Col100;\n        sqlite3Fts5BufferSize(pRc, &pIter->poslist, pConfig->nCol);\n      }else{\n        pIter->xSetOutputs = fts5IterSetOutputs_Col;\n      }\n    }\n  }\n}\n\n\n/*\n** Allocate a new Fts5Iter object.\n**\n** The new object will be used to iterate through data in structure pStruct.\n** If iLevel is -ve, then all data in all segments is merged. Or, if iLevel\n** is zero or greater, data from the first nSegment segments on level iLevel\n** is merged.\n**\n** The iterator initially points to the first term/rowid entry in the \n** iterated data.\n*/\nstatic void fts5MultiIterNew(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Structure *pStruct,         /* Structure of specific index */\n  int flags,                      /* FTS5INDEX_QUERY_XXX flags */\n  Fts5Colset *pColset,            /* Colset to filter on (or NULL) */\n  const u8 *pTerm, int nTerm,     /* Term to seek to (or NULL/0) */\n  int iLevel,                     /* Level to iterate (-1 for all) */\n  int nSegment,                   /* Number of segments to merge (iLevel>=0) */\n  Fts5Iter **ppOut                /* New object */\n){\n  int nSeg = 0;                   /* Number of segment-iters in use */\n  int iIter = 0;                  /* */\n  int iSeg;                       /* Used to iterate through segments */\n  Fts5StructureLevel *pLvl;\n  Fts5Iter *pNew;\n\n  assert( (pTerm==0 && nTerm==0) || iLevel<0 );\n\n  /* Allocate space for the new multi-seg-iterator. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n      nSeg = pStruct->nSegment;\n      nSeg += (p->pHash ? 1 : 0);\n    }else{\n      nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);\n    }\n  }\n  *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);\n  if( pNew==0 ) return;\n  pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));\n  pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));\n  pNew->pStruct = pStruct;\n  pNew->pColset = pColset;\n  fts5StructureRef(pStruct);\n  if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){\n    fts5IterSetOutputCb(&p->rc, pNew);\n  }\n\n  /* Initialize each of the component segment iterators. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      Fts5StructureLevel *pEnd = &pStruct->aLevel[pStruct->nLevel];\n      if( p->pHash ){\n        /* Add a segment iterator for the current contents of the hash table. */\n        Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n        fts5SegIterHashInit(p, pTerm, nTerm, flags, pIter);\n      }\n      for(pLvl=&pStruct->aLevel[0]; pLvl<pEnd; pLvl++){\n        for(iSeg=pLvl->nSeg-1; iSeg>=0; iSeg--){\n          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n          Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n          if( pTerm==0 ){\n            fts5SegIterInit(p, pSeg, pIter);\n          }else{\n            fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);\n          }\n        }\n      }\n    }else{\n      pLvl = &pStruct->aLevel[iLevel];\n      for(iSeg=nSeg-1; iSeg>=0; iSeg--){\n        fts5SegIterInit(p, &pLvl->aSeg[iSeg], &pNew->aSeg[iIter++]);\n      }\n    }\n    assert( iIter==nSeg );\n  }\n\n  /* If the above was successful, each component iterators now points \n  ** to the first entry in its segment. In this case initialize the \n  ** aFirst[] array. Or, if an error has occurred, free the iterator\n  ** object and set the output variable to NULL.  */\n  if( p->rc==SQLITE_OK ){\n    for(iIter=pNew->nSeg-1; iIter>0; iIter--){\n      int iEq;\n      if( (iEq = fts5MultiIterDoCompare(pNew, iIter)) ){\n        Fts5SegIter *pSeg = &pNew->aSeg[iEq];\n        if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0);\n        fts5MultiIterAdvanced(p, pNew, iEq, iIter);\n      }\n    }\n    fts5MultiIterSetEof(pNew);\n    fts5AssertMultiIterSetup(p, pNew);\n\n    if( pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew) ){\n      fts5MultiIterNext(p, pNew, 0, 0);\n    }else if( pNew->base.bEof==0 ){\n      Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];\n      pNew->xSetOutputs(pNew, pSeg);\n    }\n\n  }else{\n    fts5MultiIterFree(pNew);\n    *ppOut = 0;\n  }\n}\n\n/*\n** Create an Fts5Iter that iterates through the doclist provided\n** as the second argument.\n*/\nstatic void fts5MultiIterNew2(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Data *pData,                /* Doclist to iterate through */\n  int bDesc,                      /* True for descending rowid order */\n  Fts5Iter **ppOut                /* New object */\n){\n  Fts5Iter *pNew;\n  pNew = fts5MultiIterAlloc(p, 2);\n  if( pNew ){\n    Fts5SegIter *pIter = &pNew->aSeg[1];\n\n    pIter->flags = FTS5_SEGITER_ONETERM;\n    if( pData->szLeaf>0 ){\n      pIter->pLeaf = pData;\n      pIter->iLeafOffset = fts5GetVarint(pData->p, (u64*)&pIter->iRowid);\n      pIter->iEndofDoclist = pData->nn;\n      pNew->aFirst[1].iFirst = 1;\n      if( bDesc ){\n        pNew->bRev = 1;\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n        fts5SegIterReverseInitPage(p, pIter);\n      }else{\n        fts5SegIterLoadNPos(p, pIter);\n      }\n      pData = 0;\n    }else{\n      pNew->base.bEof = 1;\n    }\n    fts5SegIterSetNext(p, pIter);\n\n    *ppOut = pNew;\n  }\n\n  fts5DataRelease(pData);\n}\n\n/*\n** Return true if the iterator is at EOF or if an error has occurred. \n** False otherwise.\n*/\nstatic int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){\n  assert( p->rc \n      || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof \n  );\n  return (p->rc || pIter->base.bEof);\n}\n\n/*\n** Return the rowid of the entry that the iterator currently points\n** to. If the iterator points to EOF when this function is called the\n** results are undefined.\n*/\nstatic i64 fts5MultiIterRowid(Fts5Iter *pIter){\n  assert( pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf );\n  return pIter->aSeg[ pIter->aFirst[1].iFirst ].iRowid;\n}\n\n/*\n** Move the iterator to the next entry at or following iMatch.\n*/\nstatic void fts5MultiIterNextFrom(\n  Fts5Index *p, \n  Fts5Iter *pIter, \n  i64 iMatch\n){\n  while( 1 ){\n    i64 iRowid;\n    fts5MultiIterNext(p, pIter, 1, iMatch);\n    if( fts5MultiIterEof(p, pIter) ) break;\n    iRowid = fts5MultiIterRowid(pIter);\n    if( pIter->bRev==0 && iRowid>=iMatch ) break;\n    if( pIter->bRev!=0 && iRowid<=iMatch ) break;\n  }\n}\n\n/*\n** Return a pointer to a buffer containing the term associated with the \n** entry that the iterator currently points to.\n*/\nstatic const u8 *fts5MultiIterTerm(Fts5Iter *pIter, int *pn){\n  Fts5SegIter *p = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  *pn = p->term.n;\n  return p->term.p;\n}\n\n/*\n** Allocate a new segment-id for the structure pStruct. The new segment\n** id must be between 1 and 65335 inclusive, and must not be used by \n** any currently existing segment. If a free segment id cannot be found,\n** SQLITE_FULL is returned.\n**\n** If an error has already occurred, this function is a no-op. 0 is \n** returned in this case.\n*/\nstatic int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){\n  int iSegid = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( pStruct->nSegment>=FTS5_MAX_SEGMENT ){\n      p->rc = SQLITE_FULL;\n    }else{\n      /* FTS5_MAX_SEGMENT is currently defined as 2000. So the following\n      ** array is 63 elements, or 252 bytes, in size.  */\n      u32 aUsed[(FTS5_MAX_SEGMENT+31) / 32];\n      int iLvl, iSeg;\n      int i;\n      u32 mask;\n      memset(aUsed, 0, sizeof(aUsed));\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;\n          if( iId<=FTS5_MAX_SEGMENT ){\n            aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);\n          }\n        }\n      }\n\n      for(i=0; aUsed[i]==0xFFFFFFFF; i++);\n      mask = aUsed[i];\n      for(iSegid=0; mask & (1 << iSegid); iSegid++);\n      iSegid += 1 + i*32;\n\n#ifdef SQLITE_DEBUG\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );\n        }\n      }\n      assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );\n\n      {\n        sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);\n        if( p->rc==SQLITE_OK ){\n          u8 aBlob[2] = {0xff, 0xff};\n          sqlite3_bind_int(pIdxSelect, 1, iSegid);\n          sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);\n          assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );\n          p->rc = sqlite3_reset(pIdxSelect);\n        }\n      }\n#endif\n    }\n  }\n\n  return iSegid;\n}\n\n/*\n** Discard all data currently cached in the hash-tables.\n*/\nstatic void fts5IndexDiscardData(Fts5Index *p){\n  assert( p->pHash || p->nPendingData==0 );\n  if( p->pHash ){\n    sqlite3Fts5HashClear(p->pHash);\n    p->nPendingData = 0;\n  }\n}\n\n/*\n** Return the size of the prefix, in bytes, that buffer \n** (pNew/<length-unknown>) shares with buffer (pOld/nOld).\n**\n** Buffer (pNew/<length-unknown>) is guaranteed to be greater \n** than buffer (pOld/nOld).\n*/\nstatic int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){\n  int i;\n  for(i=0; i<nOld; i++){\n    if( pOld[i]!=pNew[i] ) break;\n  }\n  return i;\n}\n\nstatic void fts5WriteDlidxClear(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int bFlush                      /* If true, write dlidx to disk */\n){\n  int i;\n  assert( bFlush==0 || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n>0) );\n  for(i=0; i<pWriter->nDlidx; i++){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n    if( pDlidx->buf.n==0 ) break;\n    if( bFlush ){\n      assert( pDlidx->pgno!=0 );\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n    }\n    sqlite3Fts5BufferZero(&pDlidx->buf);\n    pDlidx->bPrevValid = 0;\n  }\n}\n\n/*\n** Grow the pWriter->aDlidx[] array to at least nLvl elements in size.\n** Any new array elements are zeroed before returning.\n*/\nstatic int fts5WriteDlidxGrow(\n  Fts5Index *p,\n  Fts5SegWriter *pWriter,\n  int nLvl\n){\n  if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){\n    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(\n        pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl\n    );\n    if( aDlidx==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      int nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);\n      memset(&aDlidx[pWriter->nDlidx], 0, nByte);\n      pWriter->aDlidx = aDlidx;\n      pWriter->nDlidx = nLvl;\n    }\n  }\n  return p->rc;\n}\n\n/*\n** If the current doclist-index accumulating in pWriter->aDlidx[] is large\n** enough, flush it to disk and return 1. Otherwise discard it and return\n** zero.\n*/\nstatic int fts5WriteFlushDlidx(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag = 0;\n\n  /* If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written\n  ** to the database, also write the doclist-index to disk.  */\n  if( pWriter->aDlidx[0].buf.n>0 && pWriter->nEmpty>=FTS5_MIN_DLIDX_SIZE ){\n    bFlag = 1;\n  }\n  fts5WriteDlidxClear(p, pWriter, bFlag);\n  pWriter->nEmpty = 0;\n  return bFlag;\n}\n\n/*\n** This function is called whenever processing of the doclist for the \n** last term on leaf page (pWriter->iBtPage) is completed. \n**\n** The doclist-index for that term is currently stored in-memory within the\n** Fts5SegWriter.aDlidx[] array. If it is large enough, this function\n** writes it out to disk. Or, if it is too small to bother with, discards\n** it.\n**\n** Fts5SegWriter.btterm currently contains the first term on page iBtPage.\n*/\nstatic void fts5WriteFlushBtree(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag;\n\n  assert( pWriter->iBtPage || pWriter->nEmpty==0 );\n  if( pWriter->iBtPage==0 ) return;\n  bFlag = fts5WriteFlushDlidx(p, pWriter);\n\n  if( p->rc==SQLITE_OK ){\n    const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:\"\");\n    /* The following was already done in fts5WriteInit(): */\n    /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */\n    sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);\n    sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));\n    sqlite3_step(p->pIdxWriter);\n    p->rc = sqlite3_reset(p->pIdxWriter);\n  }\n  pWriter->iBtPage = 0;\n}\n\n/*\n** This is called once for each leaf page except the first that contains\n** at least one term. Argument (nTerm/pTerm) is the split-key - a term that\n** is larger than all terms written to earlier leaves, and equal to or\n** smaller than the first term on the new leaf.\n**\n** If an error occurs, an error code is left in Fts5Index.rc. If an error\n** has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5WriteBtreeTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter,         /* Writer object */\n  int nTerm, const u8 *pTerm      /* First term on new page */\n){\n  fts5WriteFlushBtree(p, pWriter);\n  fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);\n  pWriter->iBtPage = pWriter->writer.pgno;\n}\n\n/*\n** This function is called when flushing a leaf page that contains no\n** terms at all to disk.\n*/\nstatic void fts5WriteBtreeNoTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter          /* Writer object */\n){\n  /* If there were no rowids on the leaf page either and the doclist-index\n  ** has already been started, append an 0x00 byte to it.  */\n  if( pWriter->bFirstRowidInPage && pWriter->aDlidx[0].buf.n>0 ){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[0];\n    assert( pDlidx->bPrevValid );\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, 0);\n  }\n\n  /* Increment the \"number of sequential leaves without a term\" counter. */\n  pWriter->nEmpty++;\n}\n\nstatic i64 fts5DlidxExtractFirstRowid(Fts5Buffer *pBuf){\n  i64 iRowid;\n  int iOff;\n\n  iOff = 1 + fts5GetVarint(&pBuf->p[1], (u64*)&iRowid);\n  fts5GetVarint(&pBuf->p[iOff], (u64*)&iRowid);\n  return iRowid;\n}\n\n/*\n** Rowid iRowid has just been appended to the current leaf page. It is the\n** first on the page. This function appends an appropriate entry to the current\n** doclist-index.\n*/\nstatic void fts5WriteDlidxAppend(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  i64 iRowid\n){\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    i64 iVal;\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n\n    if( pDlidx->buf.n>=p->pConfig->pgsz ){\n      /* The current doclist-index page is full. Write it to disk and push\n      ** a copy of iRowid (which will become the first rowid on the next\n      ** doclist-index leaf page) up into the next level of the b-tree \n      ** hierarchy. If the node being flushed is currently the root node,\n      ** also push its first rowid upwards. */\n      pDlidx->buf.p[0] = 0x01;    /* Not the root node */\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n      fts5WriteDlidxGrow(p, pWriter, i+2);\n      pDlidx = &pWriter->aDlidx[i];\n      if( p->rc==SQLITE_OK && pDlidx[1].buf.n==0 ){\n        i64 iFirst = fts5DlidxExtractFirstRowid(&pDlidx->buf);\n\n        /* This was the root node. Push its first rowid up to the new root. */\n        pDlidx[1].pgno = pDlidx->pgno;\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, 0);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, pDlidx->pgno);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, iFirst);\n        pDlidx[1].bPrevValid = 1;\n        pDlidx[1].iPrev = iFirst;\n      }\n\n      sqlite3Fts5BufferZero(&pDlidx->buf);\n      pDlidx->bPrevValid = 0;\n      pDlidx->pgno++;\n    }else{\n      bDone = 1;\n    }\n\n    if( pDlidx->bPrevValid ){\n      iVal = iRowid - pDlidx->iPrev;\n    }else{\n      i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno);\n      assert( pDlidx->buf.n==0 );\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, !bDone);\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iPgno);\n      iVal = iRowid;\n    }\n\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iVal);\n    pDlidx->bPrevValid = 1;\n    pDlidx->iPrev = iRowid;\n  }\n}\n\nstatic void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){\n  static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 };\n  Fts5PageWriter *pPage = &pWriter->writer;\n  i64 iRowid;\n\n  assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );\n\n  /* Set the szLeaf header field. */\n  assert( 0==fts5GetU16(&pPage->buf.p[2]) );\n  fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n);\n\n  if( pWriter->bFirstTermInPage ){\n    /* No term was written to this page. */\n    assert( pPage->pgidx.n==0 );\n    fts5WriteBtreeNoTerm(p, pWriter);\n  }else{\n    /* Append the pgidx to the page buffer. Set the szLeaf header field. */\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, pPage->pgidx.n, pPage->pgidx.p);\n  }\n\n  /* Write the page out to disk */\n  iRowid = FTS5_SEGMENT_ROWID(pWriter->iSegid, pPage->pgno);\n  fts5DataWrite(p, iRowid, pPage->buf.p, pPage->buf.n);\n\n  /* Initialize the next page. */\n  fts5BufferZero(&pPage->buf);\n  fts5BufferZero(&pPage->pgidx);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, 4, zero);\n  pPage->iPrevPgidx = 0;\n  pPage->pgno++;\n\n  /* Increase the leaves written counter */\n  pWriter->nLeafWritten++;\n\n  /* The new leaf holds no terms or rowids */\n  pWriter->bFirstTermInPage = 1;\n  pWriter->bFirstRowidInPage = 1;\n}\n\n/*\n** Append term pTerm/nTerm to the segment being written by the writer passed\n** as the second argument.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5WriteAppendTerm(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int nTerm, const u8 *pTerm \n){\n  int nPrefix;                    /* Bytes of prefix compression for term */\n  Fts5PageWriter *pPage = &pWriter->writer;\n  Fts5Buffer *pPgidx = &pWriter->writer.pgidx;\n\n  assert( p->rc==SQLITE_OK );\n  assert( pPage->buf.n>=4 );\n  assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );\n\n  /* If the current leaf page is full, flush it to disk. */\n  if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){\n    if( pPage->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n    fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);\n  }\n  \n  /* TODO1: Updating pgidx here. */\n  pPgidx->n += sqlite3Fts5PutVarint(\n      &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx\n  );\n  pPage->iPrevPgidx = pPage->buf.n;\n#if 0\n  fts5PutU16(&pPgidx->p[pPgidx->n], pPage->buf.n);\n  pPgidx->n += 2;\n#endif\n\n  if( pWriter->bFirstTermInPage ){\n    nPrefix = 0;\n    if( pPage->pgno!=1 ){\n      /* This is the first term on a leaf that is not the leftmost leaf in\n      ** the segment b-tree. In this case it is necessary to add a term to\n      ** the b-tree hierarchy that is (a) larger than the largest term \n      ** already written to the segment and (b) smaller than or equal to\n      ** this term. In other words, a prefix of (pTerm/nTerm) that is one\n      ** byte longer than the longest prefix (pTerm/nTerm) shares with the\n      ** previous term. \n      **\n      ** Usually, the previous term is available in pPage->term. The exception\n      ** is if this is the first term written in an incremental-merge step.\n      ** In this case the previous term is not available, so just write a\n      ** copy of (pTerm/nTerm) into the parent node. This is slightly\n      ** inefficient, but still correct.  */\n      int n = nTerm;\n      if( pPage->term.n ){\n        n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);\n      }\n      fts5WriteBtreeTerm(p, pWriter, n, pTerm);\n      pPage = &pWriter->writer;\n    }\n  }else{\n    nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);\n    fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);\n  }\n\n  /* Append the number of bytes of new data, then the term data itself\n  ** to the page. */\n  fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);\n\n  /* Update the Fts5PageWriter.term field. */\n  fts5BufferSet(&p->rc, &pPage->term, nTerm, pTerm);\n  pWriter->bFirstTermInPage = 0;\n\n  pWriter->bFirstRowidInPage = 0;\n  pWriter->bFirstRowidInDoclist = 1;\n\n  assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );\n  pWriter->aDlidx[0].pgno = pPage->pgno;\n}\n\n/*\n** Append a rowid and position-list size field to the writers output. \n*/\nstatic void fts5WriteAppendRowid(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  i64 iRowid\n){\n  if( p->rc==SQLITE_OK ){\n    Fts5PageWriter *pPage = &pWriter->writer;\n\n    if( (pPage->buf.n + pPage->pgidx.n)>=p->pConfig->pgsz ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n\n    /* If this is to be the first rowid written to the page, set the \n    ** rowid-pointer in the page-header. Also append a value to the dlidx\n    ** buffer, in case a doclist-index is required.  */\n    if( pWriter->bFirstRowidInPage ){\n      fts5PutU16(pPage->buf.p, (u16)pPage->buf.n);\n      fts5WriteDlidxAppend(p, pWriter, iRowid);\n    }\n\n    /* Write the rowid. */\n    if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);\n    }else{\n      assert( p->rc || iRowid>pWriter->iPrevRowid );\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);\n    }\n    pWriter->iPrevRowid = iRowid;\n    pWriter->bFirstRowidInDoclist = 0;\n    pWriter->bFirstRowidInPage = 0;\n  }\n}\n\nstatic void fts5WriteAppendPoslistData(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  const u8 *aData, \n  int nData\n){\n  Fts5PageWriter *pPage = &pWriter->writer;\n  const u8 *a = aData;\n  int n = nData;\n  \n  assert( p->pConfig->pgsz>0 );\n  while( p->rc==SQLITE_OK \n     && (pPage->buf.n + pPage->pgidx.n + n)>=p->pConfig->pgsz \n  ){\n    int nReq = p->pConfig->pgsz - pPage->buf.n - pPage->pgidx.n;\n    int nCopy = 0;\n    while( nCopy<nReq ){\n      i64 dummy;\n      nCopy += fts5GetVarint(&a[nCopy], (u64*)&dummy);\n    }\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, nCopy, a);\n    a += nCopy;\n    n -= nCopy;\n    fts5WriteFlushLeaf(p, pWriter);\n  }\n  if( n>0 ){\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, n, a);\n  }\n}\n\n/*\n** Flush any data cached by the writer object to the database. Free any\n** allocations associated with the writer.\n*/\nstatic void fts5WriteFinish(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,         /* Writer object */\n  int *pnLeaf                     /* OUT: Number of leaf pages in b-tree */\n){\n  int i;\n  Fts5PageWriter *pLeaf = &pWriter->writer;\n  if( p->rc==SQLITE_OK ){\n    assert( pLeaf->pgno>=1 );\n    if( pLeaf->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n    *pnLeaf = pLeaf->pgno-1;\n    if( pLeaf->pgno>1 ){\n      fts5WriteFlushBtree(p, pWriter);\n    }\n  }\n  fts5BufferFree(&pLeaf->term);\n  fts5BufferFree(&pLeaf->buf);\n  fts5BufferFree(&pLeaf->pgidx);\n  fts5BufferFree(&pWriter->btterm);\n\n  for(i=0; i<pWriter->nDlidx; i++){\n    sqlite3Fts5BufferFree(&pWriter->aDlidx[i].buf);\n  }\n  sqlite3_free(pWriter->aDlidx);\n}\n\nstatic void fts5WriteInit(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  int iSegid\n){\n  const int nBuffer = p->pConfig->pgsz + FTS5_DATA_PADDING;\n\n  memset(pWriter, 0, sizeof(Fts5SegWriter));\n  pWriter->iSegid = iSegid;\n\n  fts5WriteDlidxGrow(p, pWriter, 1);\n  pWriter->writer.pgno = 1;\n  pWriter->bFirstTermInPage = 1;\n  pWriter->iBtPage = 1;\n\n  assert( pWriter->writer.buf.n==0 );\n  assert( pWriter->writer.pgidx.n==0 );\n\n  /* Grow the two buffers to pgsz + padding bytes in size. */\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);\n\n  if( p->pIdxWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxWriter, sqlite3_mprintf(\n          \"INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n  }\n\n  if( p->rc==SQLITE_OK ){\n    /* Initialize the 4-byte leaf-page header to 0x00. */\n    memset(pWriter->writer.buf.p, 0, 4);\n    pWriter->writer.buf.n = 4;\n\n    /* Bind the current output segment id to the index-writer. This is an\n    ** optimization over binding the same value over and over as rows are\n    ** inserted into %_idx by the current writer.  */\n    sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid);\n  }\n}\n\n/*\n** Iterator pIter was used to iterate through the input segments of on an\n** incremental merge operation. This function is called if the incremental\n** merge step has finished but the input has not been completely exhausted.\n*/\nstatic void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){\n  int i;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  for(i=0; i<pIter->nSeg; i++){\n    Fts5SegIter *pSeg = &pIter->aSeg[i];\n    if( pSeg->pSeg==0 ){\n      /* no-op */\n    }else if( pSeg->pLeaf==0 ){\n      /* All keys from this input segment have been transfered to the output.\n      ** Set both the first and last page-numbers to 0 to indicate that the\n      ** segment is now empty. */\n      pSeg->pSeg->pgnoLast = 0;\n      pSeg->pSeg->pgnoFirst = 0;\n    }else{\n      int iOff = pSeg->iTermLeafOffset;     /* Offset on new first leaf page */\n      i64 iLeafRowid;\n      Fts5Data *pData;\n      int iId = pSeg->pSeg->iSegid;\n      u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};\n\n      iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);\n      pData = fts5DataRead(p, iLeafRowid);\n      if( pData ){\n        fts5BufferZero(&buf);\n        fts5BufferGrow(&p->rc, &buf, pData->nn);\n        fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);\n        fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);\n        fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);\n        fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);\n        if( p->rc==SQLITE_OK ){\n          /* Set the szLeaf field */\n          fts5PutU16(&buf.p[2], (u16)buf.n);\n        }\n\n        /* Set up the new page-index array */\n        fts5BufferAppendVarint(&p->rc, &buf, 4);\n        if( pSeg->iLeafPgno==pSeg->iTermLeafPgno \n         && pSeg->iEndofDoclist<pData->szLeaf \n        ){\n          int nDiff = pData->szLeaf - pSeg->iEndofDoclist;\n          fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);\n          fts5BufferAppendBlob(&p->rc, &buf, \n              pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]\n          );\n        }\n\n        fts5DataRelease(pData);\n        pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;\n        fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);\n        fts5DataWrite(p, iLeafRowid, buf.p, buf.n);\n      }\n    }\n  }\n  fts5BufferFree(&buf);\n}\n\nstatic void fts5MergeChunkCallback(\n  Fts5Index *p, \n  void *pCtx, \n  const u8 *pChunk, int nChunk\n){\n  Fts5SegWriter *pWriter = (Fts5SegWriter*)pCtx;\n  fts5WriteAppendPoslistData(p, pWriter, pChunk, nChunk);\n}\n\n/*\n**\n*/\nstatic void fts5IndexMergeLevel(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Stucture of index */\n  int iLvl,                       /* Level to read input from */\n  int *pnRem                      /* Write up to this many output leaves */\n){\n  Fts5Structure *pStruct = *ppStruct;\n  Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n  Fts5StructureLevel *pLvlOut;\n  Fts5Iter *pIter = 0;       /* Iterator to read input data */\n  int nRem = pnRem ? *pnRem : 0;  /* Output leaf pages left to write */\n  int nInput;                     /* Number of input segments */\n  Fts5SegWriter writer;           /* Writer object */\n  Fts5StructureSegment *pSeg;     /* Output segment */\n  Fts5Buffer term;\n  int bOldest;                    /* True if the output segment is the oldest */\n  int eDetail = p->pConfig->eDetail;\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  int bTermWritten = 0;           /* True if current term already output */\n\n  assert( iLvl<pStruct->nLevel );\n  assert( pLvl->nMerge<=pLvl->nSeg );\n\n  memset(&writer, 0, sizeof(Fts5SegWriter));\n  memset(&term, 0, sizeof(Fts5Buffer));\n  if( pLvl->nMerge ){\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n    assert( pLvlOut->nSeg>0 );\n    nInput = pLvl->nMerge;\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg-1];\n\n    fts5WriteInit(p, &writer, pSeg->iSegid);\n    writer.writer.pgno = pSeg->pgnoLast+1;\n    writer.iBtPage = 0;\n  }else{\n    int iSegid = fts5AllocateSegid(p, pStruct);\n\n    /* Extend the Fts5Structure object as required to ensure the output\n    ** segment exists. */\n    if( iLvl==pStruct->nLevel-1 ){\n      fts5StructureAddLevel(&p->rc, ppStruct);\n      pStruct = *ppStruct;\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, iLvl+1, 1, 0);\n    if( p->rc ) return;\n    pLvl = &pStruct->aLevel[iLvl];\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n\n    fts5WriteInit(p, &writer, iSegid);\n\n    /* Add the new segment to the output level */\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg];\n    pLvlOut->nSeg++;\n    pSeg->pgnoFirst = 1;\n    pSeg->iSegid = iSegid;\n    pStruct->nSegment++;\n\n    /* Read input from all segments in the input level */\n    nInput = pLvl->nSeg;\n  }\n  bOldest = (pLvlOut->nSeg==1 && pStruct->nLevel==iLvl+2);\n\n  assert( iLvl>=0 );\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, iLvl, nInput, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int nPos;                     /* position-list size field value */\n    int nTerm;\n    const u8 *pTerm;\n\n    pTerm = fts5MultiIterTerm(pIter, &nTerm);\n    if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){\n      if( pnRem && writer.nLeafWritten>nRem ){\n        break;\n      }\n      fts5BufferSet(&p->rc, &term, nTerm, pTerm);\n      bTermWritten =0;\n    }\n\n    /* Check for key annihilation. */\n    if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;\n\n    if( p->rc==SQLITE_OK && bTermWritten==0 ){\n      /* This is a new term. Append a term to the output segment. */\n      fts5WriteAppendTerm(p, &writer, nTerm, pTerm);\n      bTermWritten = 1;\n    }\n\n    /* Append the rowid to the output */\n    /* WRITEPOSLISTSIZE */\n    fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( pSegIter->bDel ){\n        fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        if( pSegIter->nPos>0 ){\n          fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        }\n      }\n    }else{\n      /* Append the position-list data to the output */\n      nPos = pSegIter->nPos*2 + pSegIter->bDel;\n      fts5BufferAppendVarint(&p->rc, &writer.writer.buf, nPos);\n      fts5ChunkIterate(p, pSegIter, (void*)&writer, fts5MergeChunkCallback);\n    }\n  }\n\n  /* Flush the last leaf page to disk. Set the output segment b-tree height\n  ** and last leaf page number at the same time.  */\n  fts5WriteFinish(p, &writer, &pSeg->pgnoLast);\n\n  if( fts5MultiIterEof(p, pIter) ){\n    int i;\n\n    /* Remove the redundant segments from the %_data table */\n    for(i=0; i<nInput; i++){\n      fts5DataRemoveSegment(p, pLvl->aSeg[i].iSegid);\n    }\n\n    /* Remove the redundant segments from the input level */\n    if( pLvl->nSeg!=nInput ){\n      int nMove = (pLvl->nSeg - nInput) * sizeof(Fts5StructureSegment);\n      memmove(pLvl->aSeg, &pLvl->aSeg[nInput], nMove);\n    }\n    pStruct->nSegment -= nInput;\n    pLvl->nSeg -= nInput;\n    pLvl->nMerge = 0;\n    if( pSeg->pgnoLast==0 ){\n      pLvlOut->nSeg--;\n      pStruct->nSegment--;\n    }\n  }else{\n    assert( pSeg->pgnoLast>0 );\n    fts5TrimSegments(p, pIter);\n    pLvl->nMerge = nInput;\n  }\n\n  fts5MultiIterFree(pIter);\n  fts5BufferFree(&term);\n  if( pnRem ) *pnRem -= writer.nLeafWritten;\n}\n\n/*\n** Do up to nPg pages of automerge work on the index.\n**\n** Return true if any changes were actually made, or false otherwise.\n*/\nstatic int fts5IndexMerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nPg,                        /* Pages of work to do */\n  int nMin                        /* Minimum number of segments to merge */\n){\n  int nRem = nPg;\n  int bRet = 0;\n  Fts5Structure *pStruct = *ppStruct;\n  while( nRem>0 && p->rc==SQLITE_OK ){\n    int iLvl;                   /* To iterate through levels */\n    int iBestLvl = 0;           /* Level offering the most input segments */\n    int nBest = 0;              /* Number of input segments on best level */\n\n    /* Set iBestLvl to the level to read input segments from. */\n    assert( pStruct->nLevel>0 );\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      if( pLvl->nMerge ){\n        if( pLvl->nMerge>nBest ){\n          iBestLvl = iLvl;\n          nBest = pLvl->nMerge;\n        }\n        break;\n      }\n      if( pLvl->nSeg>nBest ){\n        nBest = pLvl->nSeg;\n        iBestLvl = iLvl;\n      }\n    }\n\n    /* If nBest is still 0, then the index must be empty. */\n#ifdef SQLITE_DEBUG\n    for(iLvl=0; nBest==0 && iLvl<pStruct->nLevel; iLvl++){\n      assert( pStruct->aLevel[iLvl].nSeg==0 );\n    }\n#endif\n\n    if( nBest<nMin && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      break;\n    }\n    bRet = 1;\n    fts5IndexMergeLevel(p, &pStruct, iBestLvl, &nRem);\n    if( p->rc==SQLITE_OK && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      fts5StructurePromote(p, iBestLvl+1, pStruct);\n    }\n  }\n  *ppStruct = pStruct;\n  return bRet;\n}\n\n/*\n** A total of nLeaf leaf pages of data has just been flushed to a level-0\n** segment. This function updates the write-counter accordingly and, if\n** necessary, performs incremental merge work.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5IndexAutomerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nLeaf                       /* Number of output leaves just written */\n){\n  if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){\n    Fts5Structure *pStruct = *ppStruct;\n    u64 nWrite;                   /* Initial value of write-counter */\n    int nWork;                    /* Number of work-quanta to perform */\n    int nRem;                     /* Number of leaf pages left to write */\n\n    /* Update the write-counter. While doing so, set nWork. */\n    nWrite = pStruct->nWriteCounter;\n    nWork = (int)(((nWrite + nLeaf) / p->nWorkUnit) - (nWrite / p->nWorkUnit));\n    pStruct->nWriteCounter += nLeaf;\n    nRem = (int)(p->nWorkUnit * nWork * pStruct->nLevel);\n\n    fts5IndexMerge(p, ppStruct, nRem, p->pConfig->nAutomerge);\n  }\n}\n\nstatic void fts5IndexCrisismerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct        /* IN/OUT: Current structure of index */\n){\n  const int nCrisis = p->pConfig->nCrisisMerge;\n  Fts5Structure *pStruct = *ppStruct;\n  int iLvl = 0;\n\n  assert( p->rc!=SQLITE_OK || pStruct->nLevel>0 );\n  while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){\n    fts5IndexMergeLevel(p, &pStruct, iLvl, 0);\n    assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) );\n    fts5StructurePromote(p, iLvl+1, pStruct);\n    iLvl++;\n  }\n  *ppStruct = pStruct;\n}\n\nstatic int fts5IndexReturn(Fts5Index *p){\n  int rc = p->rc;\n  p->rc = SQLITE_OK;\n  return rc;\n}\n\ntypedef struct Fts5FlushCtx Fts5FlushCtx;\nstruct Fts5FlushCtx {\n  Fts5Index *pIdx;\n  Fts5SegWriter writer; \n};\n\n/*\n** Buffer aBuf[] contains a list of varints, all small enough to fit\n** in a 32-bit integer. Return the size of the largest prefix of this \n** list nMax bytes or less in size.\n*/\nstatic int fts5PoslistPrefix(const u8 *aBuf, int nMax){\n  int ret;\n  u32 dummy;\n  ret = fts5GetVarint32(aBuf, dummy);\n  if( ret<nMax ){\n    while( 1 ){\n      int i = fts5GetVarint32(&aBuf[ret], dummy);\n      if( (ret + i) > nMax ) break;\n      ret += i;\n    }\n  }\n  return ret;\n}\n\n/*\n** Flush the contents of in-memory hash table iHash to a new level-0 \n** segment on disk. Also update the corresponding structure record.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5FlushOneHash(Fts5Index *p){\n  Fts5Hash *pHash = p->pHash;\n  Fts5Structure *pStruct;\n  int iSegid;\n  int pgnoLast = 0;                 /* Last leaf page number in segment */\n\n  /* Obtain a reference to the index structure and allocate a new segment-id\n  ** for the new level-0 segment.  */\n  pStruct = fts5StructureRead(p);\n  iSegid = fts5AllocateSegid(p, pStruct);\n  fts5StructureInvalidate(p);\n\n  if( iSegid ){\n    const int pgsz = p->pConfig->pgsz;\n    int eDetail = p->pConfig->eDetail;\n    Fts5StructureSegment *pSeg;   /* New segment within pStruct */\n    Fts5Buffer *pBuf;             /* Buffer in which to assemble leaf page */\n    Fts5Buffer *pPgidx;           /* Buffer in which to assemble pgidx */\n\n    Fts5SegWriter writer;\n    fts5WriteInit(p, &writer, iSegid);\n\n    pBuf = &writer.writer.buf;\n    pPgidx = &writer.writer.pgidx;\n\n    /* fts5WriteInit() should have initialized the buffers to (most likely)\n    ** the maximum space required. */\n    assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n    assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n\n    /* Begin scanning through hash table entries. This loop runs once for each\n    ** term/doclist currently stored within the hash table. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0);\n    }\n    while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){\n      const char *zTerm;          /* Buffer containing term */\n      const u8 *pDoclist;         /* Pointer to doclist for this term */\n      int nDoclist;               /* Size of doclist in bytes */\n\n      /* Write the term for this entry to disk. */\n      sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);\n      fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);\n\n      assert( writer.bFirstRowidInPage==0 );\n      if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){\n        /* The entire doclist will fit on the current leaf. */\n        fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);\n      }else{\n        i64 iRowid = 0;\n        i64 iDelta = 0;\n        int iOff = 0;\n\n        /* The entire doclist will not fit on this leaf. The following \n        ** loop iterates through the poslists that make up the current \n        ** doclist.  */\n        while( p->rc==SQLITE_OK && iOff<nDoclist ){\n          iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);\n          iRowid += iDelta;\n          \n          if( writer.bFirstRowidInPage ){\n            fts5PutU16(&pBuf->p[0], (u16)pBuf->n);   /* first rowid on page */\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);\n            writer.bFirstRowidInPage = 0;\n            fts5WriteDlidxAppend(p, &writer, iRowid);\n          }else{\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);\n          }\n          assert( pBuf->n<=pBuf->nSpace );\n\n          if( eDetail==FTS5_DETAIL_NONE ){\n            if( iOff<nDoclist && pDoclist[iOff]==0 ){\n              pBuf->p[pBuf->n++] = 0;\n              iOff++;\n              if( iOff<nDoclist && pDoclist[iOff]==0 ){\n                pBuf->p[pBuf->n++] = 0;\n                iOff++;\n              }\n            }\n            if( (pBuf->n + pPgidx->n)>=pgsz ){\n              fts5WriteFlushLeaf(p, &writer);\n            }\n          }else{\n            int bDummy;\n            int nPos;\n            int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);\n            nCopy += nPos;\n            if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){\n              /* The entire poslist will fit on the current leaf. So copy\n              ** it in one go. */\n              fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy);\n            }else{\n              /* The entire poslist will not fit on this leaf. So it needs\n              ** to be broken into sections. The only qualification being\n              ** that each varint must be stored contiguously.  */\n              const u8 *pPoslist = &pDoclist[iOff];\n              int iPos = 0;\n              while( p->rc==SQLITE_OK ){\n                int nSpace = pgsz - pBuf->n - pPgidx->n;\n                int n = 0;\n                if( (nCopy - iPos)<=nSpace ){\n                  n = nCopy - iPos;\n                }else{\n                  n = fts5PoslistPrefix(&pPoslist[iPos], nSpace);\n                }\n                assert( n>0 );\n                fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n);\n                iPos += n;\n                if( (pBuf->n + pPgidx->n)>=pgsz ){\n                  fts5WriteFlushLeaf(p, &writer);\n                }\n                if( iPos>=nCopy ) break;\n              }\n            }\n            iOff += nCopy;\n          }\n        }\n      }\n\n      /* TODO2: Doclist terminator written here. */\n      /* pBuf->p[pBuf->n++] = '\\0'; */\n      assert( pBuf->n<=pBuf->nSpace );\n      sqlite3Fts5HashScanNext(pHash);\n    }\n    sqlite3Fts5HashClear(pHash);\n    fts5WriteFinish(p, &writer, &pgnoLast);\n\n    /* Update the Fts5Structure. It is written back to the database by the\n    ** fts5StructureRelease() call below.  */\n    if( pStruct->nLevel==0 ){\n      fts5StructureAddLevel(&p->rc, &pStruct);\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0);\n    if( p->rc==SQLITE_OK ){\n      pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ];\n      pSeg->iSegid = iSegid;\n      pSeg->pgnoFirst = 1;\n      pSeg->pgnoLast = pgnoLast;\n      pStruct->nSegment++;\n    }\n    fts5StructurePromote(p, 0, pStruct);\n  }\n\n  fts5IndexAutomerge(p, &pStruct, pgnoLast);\n  fts5IndexCrisismerge(p, &pStruct);\n  fts5StructureWrite(p, pStruct);\n  fts5StructureRelease(pStruct);\n}\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n*/\nstatic void fts5IndexFlush(Fts5Index *p){\n  /* Unless it is empty, flush the hash table to disk */\n  if( p->nPendingData ){\n    assert( p->pHash );\n    p->nPendingData = 0;\n    fts5FlushOneHash(p);\n  }\n}\n\nstatic Fts5Structure *fts5IndexOptimizeStruct(\n  Fts5Index *p, \n  Fts5Structure *pStruct\n){\n  Fts5Structure *pNew = 0;\n  int nByte = sizeof(Fts5Structure);\n  int nSeg = pStruct->nSegment;\n  int i;\n\n  /* Figure out if this structure requires optimization. A structure does\n  ** not require optimization if either:\n  **\n  **  + it consists of fewer than two segments, or \n  **  + all segments are on the same level, or\n  **  + all segments except one are currently inputs to a merge operation.\n  **\n  ** In the first case, return NULL. In the second, increment the ref-count\n  ** on *pStruct and return a copy of the pointer to it.\n  */\n  if( nSeg<2 ) return 0;\n  for(i=0; i<pStruct->nLevel; i++){\n    int nThis = pStruct->aLevel[i].nSeg;\n    if( nThis==nSeg || (nThis==nSeg-1 && pStruct->aLevel[i].nMerge==nThis) ){\n      fts5StructureRef(pStruct);\n      return pStruct;\n    }\n    assert( pStruct->aLevel[i].nMerge<=nThis );\n  }\n\n  nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel);\n  pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);\n\n  if( pNew ){\n    Fts5StructureLevel *pLvl;\n    nByte = nSeg * sizeof(Fts5StructureSegment);\n    pNew->nLevel = pStruct->nLevel+1;\n    pNew->nRef = 1;\n    pNew->nWriteCounter = pStruct->nWriteCounter;\n    pLvl = &pNew->aLevel[pStruct->nLevel];\n    pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);\n    if( pLvl->aSeg ){\n      int iLvl, iSeg;\n      int iSegOut = 0;\n      /* Iterate through all segments, from oldest to newest. Add them to\n      ** the new Fts5Level object so that pLvl->aSeg[0] is the oldest\n      ** segment in the data structure.  */\n      for(iLvl=pStruct->nLevel-1; iLvl>=0; iLvl--){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          pLvl->aSeg[iSegOut] = pStruct->aLevel[iLvl].aSeg[iSeg];\n          iSegOut++;\n        }\n      }\n      pNew->nSegment = pLvl->nSeg = nSeg;\n    }else{\n      sqlite3_free(pNew);\n      pNew = 0;\n    }\n  }\n\n  return pNew;\n}\n\nint sqlite3Fts5IndexOptimize(Fts5Index *p){\n  Fts5Structure *pStruct;\n  Fts5Structure *pNew = 0;\n\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  pStruct = fts5StructureRead(p);\n  fts5StructureInvalidate(p);\n\n  if( pStruct ){\n    pNew = fts5IndexOptimizeStruct(p, pStruct);\n  }\n  fts5StructureRelease(pStruct);\n\n  assert( pNew==0 || pNew->nSegment>0 );\n  if( pNew ){\n    int iLvl;\n    for(iLvl=0; pNew->aLevel[iLvl].nSeg==0; iLvl++){}\n    while( p->rc==SQLITE_OK && pNew->aLevel[iLvl].nSeg>0 ){\n      int nRem = FTS5_OPT_WORK_UNIT;\n      fts5IndexMergeLevel(p, &pNew, iLvl, &nRem);\n    }\n\n    fts5StructureWrite(p, pNew);\n    fts5StructureRelease(pNew);\n  }\n\n  return fts5IndexReturn(p); \n}\n\n/*\n** This is called to implement the special \"VALUES('merge', $nMerge)\"\n** INSERT command.\n*/\nint sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){\n  Fts5Structure *pStruct = fts5StructureRead(p);\n  if( pStruct ){\n    int nMin = p->pConfig->nUsermerge;\n    fts5StructureInvalidate(p);\n    if( nMerge<0 ){\n      Fts5Structure *pNew = fts5IndexOptimizeStruct(p, pStruct);\n      fts5StructureRelease(pStruct);\n      pStruct = pNew;\n      nMin = 2;\n      nMerge = nMerge*-1;\n    }\n    if( pStruct && pStruct->nLevel ){\n      if( fts5IndexMerge(p, &pStruct, nMerge, nMin) ){\n        fts5StructureWrite(p, pStruct);\n      }\n    }\n    fts5StructureRelease(pStruct);\n  }\n  return fts5IndexReturn(p);\n}\n\nstatic void fts5AppendRowid(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pUnused,\n  Fts5Buffer *pBuf\n){\n  UNUSED_PARAM(pUnused);\n  fts5BufferAppendVarint(&p->rc, pBuf, iDelta);\n}\n\nstatic void fts5AppendPoslist(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pMulti,\n  Fts5Buffer *pBuf\n){\n  int nData = pMulti->base.nData;\n  assert( nData>0 );\n  if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){\n    fts5BufferSafeAppendVarint(pBuf, iDelta);\n    fts5BufferSafeAppendVarint(pBuf, nData*2);\n    fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);\n  }\n}\n\n\nstatic void fts5DoclistIterNext(Fts5DoclistIter *pIter){\n  u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;\n\n  assert( pIter->aPoslist );\n  if( p>=pIter->aEof ){\n    pIter->aPoslist = 0;\n  }else{\n    i64 iDelta;\n\n    p += fts5GetVarint(p, (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* Read position list size */\n    if( p[0] & 0x80 ){\n      int nPos;\n      pIter->nSize = fts5GetVarint32(p, nPos);\n      pIter->nPoslist = (nPos>>1);\n    }else{\n      pIter->nPoslist = ((int)(p[0])) >> 1;\n      pIter->nSize = 1;\n    }\n\n    pIter->aPoslist = p;\n  }\n}\n\nstatic void fts5DoclistIterInit(\n  Fts5Buffer *pBuf, \n  Fts5DoclistIter *pIter\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->aPoslist = pBuf->p;\n  pIter->aEof = &pBuf->p[pBuf->n];\n  fts5DoclistIterNext(pIter);\n}\n\n#if 0\n/*\n** Append a doclist to buffer pBuf.\n**\n** This function assumes that space within the buffer has already been\n** allocated.\n*/\nstatic void fts5MergeAppendDocid(\n  Fts5Buffer *pBuf,               /* Buffer to write to */\n  i64 *piLastRowid,               /* IN/OUT: Previous rowid written (if any) */\n  i64 iRowid                      /* Rowid to append */\n){\n  assert( pBuf->n!=0 || (*piLastRowid)==0 );\n  fts5BufferSafeAppendVarint(pBuf, iRowid - *piLastRowid);\n  *piLastRowid = iRowid;\n}\n#endif\n\n#define fts5MergeAppendDocid(pBuf, iLastRowid, iRowid) {       \\\n  assert( (pBuf)->n!=0 || (iLastRowid)==0 );                   \\\n  fts5BufferSafeAppendVarint((pBuf), (iRowid) - (iLastRowid)); \\\n  (iLastRowid) = (iRowid);                                     \\\n}\n\n/*\n** Swap the contents of buffer *p1 with that of *p2.\n*/\nstatic void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){\n  Fts5Buffer tmp = *p1;\n  *p1 = *p2;\n  *p2 = tmp;\n}\n\nstatic void fts5NextRowid(Fts5Buffer *pBuf, int *piOff, i64 *piRowid){\n  int i = *piOff;\n  if( i>=pBuf->n ){\n    *piOff = -1;\n  }else{\n    u64 iVal;\n    *piOff = i + sqlite3Fts5GetVarint(&pBuf->p[i], &iVal);\n    *piRowid += iVal;\n  }\n}\n\n/*\n** This is the equivalent of fts5MergePrefixLists() for detail=none mode.\n** In this case the buffers consist of a delta-encoded list of rowids only.\n*/\nstatic void fts5MergeRowidLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  int i1 = 0;\n  int i2 = 0;\n  i64 iRowid1 = 0;\n  i64 iRowid2 = 0;\n  i64 iOut = 0;\n\n  Fts5Buffer out;\n  memset(&out, 0, sizeof(out));\n  sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n);\n  if( p->rc ) return;\n\n  fts5NextRowid(p1, &i1, &iRowid1);\n  fts5NextRowid(p2, &i2, &iRowid2);\n  while( i1>=0 || i2>=0 ){\n    if( i1>=0 && (i2<0 || iRowid1<iRowid2) ){\n      assert( iOut==0 || iRowid1>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid1 - iOut);\n      iOut = iRowid1;\n      fts5NextRowid(p1, &i1, &iRowid1);\n    }else{\n      assert( iOut==0 || iRowid2>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid2 - iOut);\n      iOut = iRowid2;\n      if( i1>=0 && iRowid1==iRowid2 ){\n        fts5NextRowid(p1, &i1, &iRowid1);\n      }\n      fts5NextRowid(p2, &i2, &iRowid2);\n    }\n  }\n\n  fts5BufferSwap(&out, p1);\n  fts5BufferFree(&out);\n}\n\n/*\n** Buffers p1 and p2 contain doclists. This function merges the content\n** of the two doclists together and sets buffer p1 to the result before\n** returning.\n**\n** If an error occurs, an error code is left in p->rc. If an error has\n** already occurred, this function is a no-op.\n*/\nstatic void fts5MergePrefixLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  if( p2->n ){\n    i64 iLastRowid = 0;\n    Fts5DoclistIter i1;\n    Fts5DoclistIter i2;\n    Fts5Buffer out = {0, 0, 0};\n    Fts5Buffer tmp = {0, 0, 0};\n\n    if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n) ) return;\n    fts5DoclistIterInit(p1, &i1);\n    fts5DoclistIterInit(p2, &i2);\n\n    while( 1 ){\n      if( i1.iRowid<i2.iRowid ){\n        /* Copy entry from i1 */\n        fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n        fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.nPoslist+i1.nSize);\n        fts5DoclistIterNext(&i1);\n        if( i1.aPoslist==0 ) break;\n      }\n      else if( i2.iRowid!=i1.iRowid ){\n        /* Copy entry from i2 */\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.nPoslist+i2.nSize);\n        fts5DoclistIterNext(&i2);\n        if( i2.aPoslist==0 ) break;\n      }\n      else{\n        /* Merge the two position lists. */ \n        i64 iPos1 = 0;\n        i64 iPos2 = 0;\n        int iOff1 = 0;\n        int iOff2 = 0;\n        u8 *a1 = &i1.aPoslist[i1.nSize];\n        u8 *a2 = &i2.aPoslist[i2.nSize];\n\n        i64 iPrev = 0;\n        Fts5PoslistWriter writer;\n        memset(&writer, 0, sizeof(writer));\n\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferZero(&tmp);\n        sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);\n        if( p->rc ) break;\n\n        sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        assert( iPos1>=0 && iPos2>=0 );\n\n        if( iPos1<iPos2 ){\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        }else{\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        }\n\n        if( iPos1>=0 && iPos2>=0 ){\n          while( 1 ){\n            if( iPos1<iPos2 ){\n              if( iPos1!=iPrev ){\n                sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n              }\n              sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n              if( iPos1<0 ) break;\n            }else{\n              assert( iPos2!=iPrev );\n              sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n              sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n              if( iPos2<0 ) break;\n            }\n          }\n        }\n\n        if( iPos1>=0 ){\n          if( iPos1!=iPrev ){\n            sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          }\n          fts5BufferSafeAppendBlob(&tmp, &a1[iOff1], i1.nPoslist-iOff1);\n        }else{\n          assert( iPos2>=0 && iPos2!=iPrev );\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          fts5BufferSafeAppendBlob(&tmp, &a2[iOff2], i2.nPoslist-iOff2);\n        }\n\n        /* WRITEPOSLISTSIZE */\n        fts5BufferSafeAppendVarint(&out, tmp.n * 2);\n        fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);\n        fts5DoclistIterNext(&i1);\n        fts5DoclistIterNext(&i2);\n        if( i1.aPoslist==0 || i2.aPoslist==0 ) break;\n      }\n    }\n\n    if( i1.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n      fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.aEof - i1.aPoslist);\n    }\n    else if( i2.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n      fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);\n    }\n\n    fts5BufferSet(&p->rc, p1, out.n, out.p);\n    fts5BufferFree(&tmp);\n    fts5BufferFree(&out);\n  }\n}\n\nstatic void fts5SetupPrefixIter(\n  Fts5Index *p,                   /* Index to read from */\n  int bDesc,                      /* True for \"ORDER BY rowid DESC\" */\n  const u8 *pToken,               /* Buffer containing prefix to match */\n  int nToken,                     /* Size of buffer pToken in bytes */\n  Fts5Colset *pColset,            /* Restrict matches to these columns */\n  Fts5Iter **ppIter          /* OUT: New iterator */\n){\n  Fts5Structure *pStruct;\n  Fts5Buffer *aBuf;\n  const int nBuf = 32;\n\n  void (*xMerge)(Fts5Index*, Fts5Buffer*, Fts5Buffer*);\n  void (*xAppend)(Fts5Index*, i64, Fts5Iter*, Fts5Buffer*);\n  if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    xMerge = fts5MergeRowidLists;\n    xAppend = fts5AppendRowid;\n  }else{\n    xMerge = fts5MergePrefixLists;\n    xAppend = fts5AppendPoslist;\n  }\n\n  aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf);\n  pStruct = fts5StructureRead(p);\n\n  if( aBuf && pStruct ){\n    const int flags = FTS5INDEX_QUERY_SCAN \n                    | FTS5INDEX_QUERY_SKIPEMPTY \n                    | FTS5INDEX_QUERY_NOOUTPUT;\n    int i;\n    i64 iLastRowid = 0;\n    Fts5Iter *p1 = 0;     /* Iterator used to gather data from index */\n    Fts5Data *pData;\n    Fts5Buffer doclist;\n    int bNewTerm = 1;\n\n    memset(&doclist, 0, sizeof(doclist));\n    fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1);\n    fts5IterSetOutputCb(&p->rc, p1);\n    for( /* no-op */ ;\n        fts5MultiIterEof(p, p1)==0;\n        fts5MultiIterNext2(p, p1, &bNewTerm)\n    ){\n      Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];\n      int nTerm = pSeg->term.n;\n      const u8 *pTerm = pSeg->term.p;\n      p1->xSetOutputs(p1, pSeg);\n\n      assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 );\n      if( bNewTerm ){\n        if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break;\n      }\n\n      if( p1->base.nData==0 ) continue;\n\n      if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){\n        for(i=0; p->rc==SQLITE_OK && doclist.n; i++){\n          assert( i<nBuf );\n          if( aBuf[i].n==0 ){\n            fts5BufferSwap(&doclist, &aBuf[i]);\n            fts5BufferZero(&doclist);\n          }else{\n            xMerge(p, &doclist, &aBuf[i]);\n            fts5BufferZero(&aBuf[i]);\n          }\n        }\n        iLastRowid = 0;\n      }\n\n      xAppend(p, p1->base.iRowid-iLastRowid, p1, &doclist);\n      iLastRowid = p1->base.iRowid;\n    }\n\n    for(i=0; i<nBuf; i++){\n      if( p->rc==SQLITE_OK ){\n        xMerge(p, &doclist, &aBuf[i]);\n      }\n      fts5BufferFree(&aBuf[i]);\n    }\n    fts5MultiIterFree(p1);\n\n    pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);\n    if( pData ){\n      pData->p = (u8*)&pData[1];\n      pData->nn = pData->szLeaf = doclist.n;\n      if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);\n      fts5MultiIterNew2(p, pData, bDesc, ppIter);\n    }\n    fts5BufferFree(&doclist);\n  }\n\n  fts5StructureRelease(pStruct);\n  sqlite3_free(aBuf);\n}\n\n\n/*\n** Indicate that all subsequent calls to sqlite3Fts5IndexWrite() pertain\n** to the document with rowid iRowid.\n*/\nint sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){\n  assert( p->rc==SQLITE_OK );\n\n  /* Allocate the hash table if it has not already been allocated */\n  if( p->pHash==0 ){\n    p->rc = sqlite3Fts5HashNew(p->pConfig, &p->pHash, &p->nPendingData);\n  }\n\n  /* Flush the hash table to disk if required */\n  if( iRowid<p->iWriteRowid \n   || (iRowid==p->iWriteRowid && p->bDelete==0)\n   || (p->nPendingData > p->pConfig->nHashSize) \n  ){\n    fts5IndexFlush(p);\n  }\n\n  p->iWriteRowid = iRowid;\n  p->bDelete = bDelete;\n  return fts5IndexReturn(p);\n}\n\n/*\n** Commit data to disk.\n*/\nint sqlite3Fts5IndexSync(Fts5Index *p){\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  fts5CloseReader(p);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nint sqlite3Fts5IndexRollback(Fts5Index *p){\n  fts5CloseReader(p);\n  fts5IndexDiscardData(p);\n  fts5StructureInvalidate(p);\n  /* assert( p->rc==SQLITE_OK ); */\n  return SQLITE_OK;\n}\n\n/*\n** The %_data table is completely empty when this function is called. This\n** function populates it with the initial structure objects for each index,\n** and the initial version of the \"averages\" record (a zero-byte blob).\n*/\nint sqlite3Fts5IndexReinit(Fts5Index *p){\n  Fts5Structure s;\n  fts5StructureInvalidate(p);\n  memset(&s, 0, sizeof(Fts5Structure));\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)\"\", 0);\n  fts5StructureWrite(p, &s);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying %_data table.\n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nint sqlite3Fts5IndexOpen(\n  Fts5Config *pConfig, \n  int bCreate, \n  Fts5Index **pp,\n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  Fts5Index *p;                   /* New object */\n\n  *pp = p = (Fts5Index*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Index));\n  if( rc==SQLITE_OK ){\n    p->pConfig = pConfig;\n    p->nWorkUnit = FTS5_WORK_UNIT;\n    p->zDataTbl = sqlite3Fts5Mprintf(&rc, \"%s_data\", pConfig->zName);\n    if( p->zDataTbl && bCreate ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"data\", \"id INTEGER PRIMARY KEY, block BLOB\", 0, pzErr\n      );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5CreateTable(pConfig, \"idx\", \n            \"segid, term, pgno, PRIMARY KEY(segid, term)\", \n            1, pzErr\n        );\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5IndexReinit(p);\n      }\n    }\n  }\n\n  assert( rc!=SQLITE_OK || p->rc==SQLITE_OK );\n  if( rc ){\n    sqlite3Fts5IndexClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5IndexOpen().\n*/\nint sqlite3Fts5IndexClose(Fts5Index *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( p->pReader==0 );\n    fts5StructureInvalidate(p);\n    sqlite3_finalize(p->pWriter);\n    sqlite3_finalize(p->pDeleter);\n    sqlite3_finalize(p->pIdxWriter);\n    sqlite3_finalize(p->pIdxDeleter);\n    sqlite3_finalize(p->pIdxSelect);\n    sqlite3_finalize(p->pDataVersion);\n    sqlite3Fts5HashFree(p->pHash);\n    sqlite3_free(p->zDataTbl);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nint sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n){\n  int n = 0;\n  int i;\n  for(i=0; i<nChar; i++){\n    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */\n    if( (unsigned char)p[n++]>=0xc0 ){\n      while( (p[n] & 0xc0)==0x80 ) n++;\n    }\n  }\n  return n;\n}\n\n/*\n** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of\n** unicode characters in the string.\n*/\nstatic int fts5IndexCharlen(const char *pIn, int nIn){\n  int nChar = 0;            \n  int i = 0;\n  while( i<nIn ){\n    if( (unsigned char)pIn[i++]>=0xc0 ){\n      while( i<nIn && (pIn[i] & 0xc0)==0x80 ) i++;\n    }\n    nChar++;\n  }\n  return nChar;\n}\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nint sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  int i;                          /* Used to iterate through indexes */\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = p->pConfig;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (iCol<0)==p->bDelete );\n\n  /* Add the entry to the main terms index. */\n  rc = sqlite3Fts5HashWrite(\n      p->pHash, p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX, pToken, nToken\n  );\n\n  for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){\n    const int nChar = pConfig->aPrefix[i];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5HashWrite(p->pHash, \n          p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken,\n          nByte\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Open a new iterator to iterate though all rowid that match the \n** specified token or token prefix.\n*/\nint sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n){\n  Fts5Config *pConfig = p->pConfig;\n  Fts5Iter *pRet = 0;\n  Fts5Buffer buf = {0, 0, 0};\n\n  /* If the QUERY_SCAN flag is set, all other flags must be clear. */\n  assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );\n\n  if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){\n    int iIdx = 0;                 /* Index to search */\n    if( nToken ) memcpy(&buf.p[1], pToken, nToken);\n\n    /* Figure out which index to search and set iIdx accordingly. If this\n    ** is a prefix query for which there is no prefix index, set iIdx to\n    ** greater than pConfig->nPrefix to indicate that the query will be\n    ** satisfied by scanning multiple terms in the main index.\n    **\n    ** If the QUERY_TEST_NOIDX flag was specified, then this must be a\n    ** prefix-query. Instead of using a prefix-index (if one exists), \n    ** evaluate the prefix query using the main FTS index. This is used\n    ** for internal sanity checking by the integrity-check in debug \n    ** mode only.  */\n#ifdef SQLITE_DEBUG\n    if( pConfig->bPrefixIndex==0 || (flags & FTS5INDEX_QUERY_TEST_NOIDX) ){\n      assert( flags & FTS5INDEX_QUERY_PREFIX );\n      iIdx = 1+pConfig->nPrefix;\n    }else\n#endif\n    if( flags & FTS5INDEX_QUERY_PREFIX ){\n      int nChar = fts5IndexCharlen(pToken, nToken);\n      for(iIdx=1; iIdx<=pConfig->nPrefix; iIdx++){\n        if( pConfig->aPrefix[iIdx-1]==nChar ) break;\n      }\n    }\n\n    if( iIdx<=pConfig->nPrefix ){\n      /* Straight index lookup */\n      Fts5Structure *pStruct = fts5StructureRead(p);\n      buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx);\n      if( pStruct ){\n        fts5MultiIterNew(p, pStruct, flags | FTS5INDEX_QUERY_SKIPEMPTY, \n            pColset, buf.p, nToken+1, -1, 0, &pRet\n        );\n        fts5StructureRelease(pStruct);\n      }\n    }else{\n      /* Scan multiple terms in the main index */\n      int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;\n      buf.p[0] = FTS5_MAIN_PREFIX;\n      fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);\n      assert( p->rc!=SQLITE_OK || pRet->pColset==0 );\n      fts5IterSetOutputCb(&p->rc, pRet);\n      if( p->rc==SQLITE_OK ){\n        Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];\n        if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);\n      }\n    }\n\n    if( p->rc ){\n      sqlite3Fts5IterClose((Fts5IndexIter*)pRet);\n      pRet = 0;\n      fts5CloseReader(p);\n    }\n\n    *ppIter = &pRet->base;\n    sqlite3Fts5BufferFree(&buf);\n  }\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return true if the iterator passed as the only argument is at EOF.\n*/\n/*\n** Move to the next matching rowid. \n*/\nint sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  assert( pIter->pIndex->rc==SQLITE_OK );\n  fts5MultiIterNext(pIter->pIndex, pIter, 0, 0);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching term/rowid. Used by the fts5vocab module.\n*/\nint sqlite3Fts5IterNextScan(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  Fts5Index *p = pIter->pIndex;\n\n  assert( pIter->pIndex->rc==SQLITE_OK );\n\n  fts5MultiIterNext(p, pIter, 0, 0);\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    if( pSeg->pLeaf && pSeg->term.p[0]!=FTS5_MAIN_PREFIX ){\n      fts5DataRelease(pSeg->pLeaf);\n      pSeg->pLeaf = 0;\n      pIter->base.bEof = 1;\n    }\n  }\n\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching rowid that occurs at or after iMatch. The\n** definition of \"at or after\" depends on whether this iterator iterates\n** in ascending or descending rowid order.\n*/\nint sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Return the current term.\n*/\nconst char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){\n  int n;\n  const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n);\n  *pn = n-1;\n  return &z[1];\n}\n\n/*\n** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().\n*/\nvoid sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){\n  if( pIndexIter ){\n    Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n    Fts5Index *pIndex = pIter->pIndex;\n    fts5MultiIterFree(pIter);\n    fts5CloseReader(pIndex);\n  }\n}\n\n/*\n** Read and decode the \"averages\" record from the database. \n**\n** Parameter anSize must point to an array of size nCol, where nCol is\n** the number of user defined columns in the FTS table.\n*/\nint sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize){\n  int nCol = p->pConfig->nCol;\n  Fts5Data *pData;\n\n  *pnRow = 0;\n  memset(anSize, 0, sizeof(i64) * nCol);\n  pData = fts5DataRead(p, FTS5_AVERAGES_ROWID);\n  if( p->rc==SQLITE_OK && pData->nn ){\n    int i = 0;\n    int iCol;\n    i += fts5GetVarint(&pData->p[i], (u64*)pnRow);\n    for(iCol=0; i<pData->nn && iCol<nCol; iCol++){\n      i += fts5GetVarint(&pData->p[i], (u64*)&anSize[iCol]);\n    }\n  }\n\n  fts5DataRelease(pData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Replace the current \"averages\" record with the contents of the buffer \n** supplied as the second argument.\n*/\nint sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8 *pData, int nData){\n  assert( p->rc==SQLITE_OK );\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, pData, nData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return the total number of blocks this module has read from the %_data\n** table since it was created.\n*/\nint sqlite3Fts5IndexReads(Fts5Index *p){\n  return p->nRead;\n}\n\n/*\n** Set the 32-bit cookie value stored at the start of all structure \n** records to the value passed as the second argument.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nint sqlite3Fts5IndexSetCookie(Fts5Index *p, int iNew){\n  int rc;                              /* Return code */\n  Fts5Config *pConfig = p->pConfig;    /* Configuration object */\n  u8 aCookie[4];                       /* Binary representation of iNew */\n  sqlite3_blob *pBlob = 0;\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3Fts5Put32(aCookie, iNew);\n\n  rc = sqlite3_blob_open(pConfig->db, pConfig->zDb, p->zDataTbl, \n      \"block\", FTS5_STRUCTURE_ROWID, 1, &pBlob\n  );\n  if( rc==SQLITE_OK ){\n    sqlite3_blob_write(pBlob, aCookie, 4, 0);\n    rc = sqlite3_blob_close(pBlob);\n  }\n\n  return rc;\n}\n\nint sqlite3Fts5IndexLoadConfig(Fts5Index *p){\n  Fts5Structure *pStruct;\n  pStruct = fts5StructureRead(p);\n  fts5StructureRelease(pStruct);\n  return fts5IndexReturn(p);\n}\n\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the integrity-check \n** functionality.\n*/\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nu64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n){\n  int i;\n  u64 ret = iRowid;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  if( iIdx>=0 ) ret += (ret<<3) + (FTS5_MAIN_PREFIX + iIdx);\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + pTerm[i];\n  return ret;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function is purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n**\n** Instead, it tests that the same set of pgno/rowid combinations are \n** visited regardless of whether the doclist-index identified by parameters\n** iSegid/iLeaf is iterated in forwards or reverse order.\n*/\nstatic void fts5TestDlidxReverse(\n  Fts5Index *p, \n  int iSegid,                     /* Segment id to load from */\n  int iLeaf                       /* Load doclist-index for this leaf */\n){\n  Fts5DlidxIter *pDlidx = 0;\n  u64 cksum1 = 13;\n  u64 cksum2 = 13;\n\n  for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterNext(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( pgno>iLeaf );\n    cksum1 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  for(pDlidx=fts5DlidxIterInit(p, 1, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterPrev(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( fts5DlidxIterPgno(pDlidx)>iLeaf );\n    cksum2 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  if( p->rc==SQLITE_OK && cksum1!=cksum2 ) p->rc = FTS5_CORRUPT;\n}\n\nstatic int fts5QueryCksum(\n  Fts5Index *p,                   /* Fts5 index object */\n  int iIdx,\n  const char *z,                  /* Index key to query for */\n  int n,                          /* Size of index key in bytes */\n  int flags,                      /* Flags for Fts5IndexQuery */\n  u64 *pCksum                     /* IN/OUT: Checksum value */\n){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum = *pCksum;\n  Fts5IndexIter *pIter = 0;\n  int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);\n\n  while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){\n    i64 rowid = pIter->iRowid;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);\n    }else{\n      Fts5PoslistReader sReader;\n      for(sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &sReader);\n          sReader.bEof==0;\n          sqlite3Fts5PoslistReaderNext(&sReader)\n      ){\n        int iCol = FTS5_POS2COLUMN(sReader.iPos);\n        int iOff = FTS5_POS2OFFSET(sReader.iPos);\n        cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n  }\n  sqlite3Fts5IterClose(pIter);\n\n  *pCksum = cksum;\n  return rc;\n}\n\n\n/*\n** This function is also purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n*/\nstatic void fts5TestTerm(\n  Fts5Index *p, \n  Fts5Buffer *pPrev,              /* Previous term */\n  const char *z, int n,           /* Possibly new term to test */\n  u64 expected,\n  u64 *pCksum\n){\n  int rc = p->rc;\n  if( pPrev->n==0 ){\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n  }else\n  if( rc==SQLITE_OK && (pPrev->n!=n || memcmp(pPrev->p, z, n)) ){\n    u64 cksum3 = *pCksum;\n    const char *zTerm = (const char*)&pPrev->p[1];  /* term sans prefix-byte */\n    int nTerm = pPrev->n-1;            /* Size of zTerm in bytes */\n    int iIdx = (pPrev->p[0] - FTS5_MAIN_PREFIX);\n    int flags = (iIdx==0 ? 0 : FTS5INDEX_QUERY_PREFIX);\n    u64 ck1 = 0;\n    u64 ck2 = 0;\n\n    /* Check that the results returned for ASC and DESC queries are\n    ** the same. If not, call this corruption.  */\n    rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, flags, &ck1);\n    if( rc==SQLITE_OK ){\n      int f = flags|FTS5INDEX_QUERY_DESC;\n      rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n    }\n    if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n\n    /* If this is a prefix query, check that the results returned if the\n    ** the index is disabled are the same. In both ASC and DESC order. \n    **\n    ** This check may only be performed if the hash table is empty. This\n    ** is because the hash table only supports a single scan query at\n    ** a time, and the multi-iter loop from which this function is called\n    ** is already performing such a scan. */\n    if( p->nPendingData==0 ){\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX|FTS5INDEX_QUERY_DESC;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n    }\n\n    cksum3 ^= ck1;\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n\n    if( rc==SQLITE_OK && cksum3!=expected ){\n      rc = FTS5_CORRUPT;\n    }\n    *pCksum = cksum3;\n  }\n  p->rc = rc;\n}\n \n#else\n# define fts5TestDlidxReverse(x,y,z)\n# define fts5TestTerm(u,v,w,x,y,z)\n#endif\n\n/*\n** Check that:\n**\n**   1) All leaves of pSeg between iFirst and iLast (inclusive) exist and\n**      contain zero terms.\n**   2) All leaves of pSeg between iNoRowid and iLast (inclusive) exist and\n**      contain zero rowids.\n*/\nstatic void fts5IndexIntegrityCheckEmpty(\n  Fts5Index *p,\n  Fts5StructureSegment *pSeg,     /* Segment to check internal consistency */\n  int iFirst,\n  int iNoRowid,\n  int iLast\n){\n  int i;\n\n  /* Now check that the iter.nEmpty leaves following the current leaf\n  ** (a) exist and (b) contain no terms. */\n  for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){\n    Fts5Data *pLeaf = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->iSegid, i));\n    if( pLeaf ){\n      if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT;\n      if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT;\n    }\n    fts5DataRelease(pLeaf);\n  }\n}\n\nstatic void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){\n  int iTermOff = 0;\n  int ii;\n\n  Fts5Buffer buf1 = {0,0,0};\n  Fts5Buffer buf2 = {0,0,0};\n\n  ii = pLeaf->szLeaf;\n  while( ii<pLeaf->nn && p->rc==SQLITE_OK ){\n    int res;\n    int iOff;\n    int nIncr;\n\n    ii += fts5GetVarint32(&pLeaf->p[ii], nIncr);\n    iTermOff += nIncr;\n    iOff = iTermOff;\n\n    if( iOff>=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else if( iTermOff==nIncr ){\n      int nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        fts5BufferSet(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n    }else{\n      int nKeep, nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nKeep);\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( nKeep>buf1.n || (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        buf1.n = nKeep;\n        fts5BufferAppendBlob(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n\n      if( p->rc==SQLITE_OK ){\n        res = fts5BufferCompare(&buf1, &buf2);\n        if( res<=0 ) p->rc = FTS5_CORRUPT;\n      }\n    }\n    fts5BufferSet(&p->rc, &buf2, buf1.n, buf1.p);\n  }\n\n  fts5BufferFree(&buf1);\n  fts5BufferFree(&buf2);\n}\n\nstatic void fts5IndexIntegrityCheckSegment(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5StructureSegment *pSeg      /* Segment to check internal consistency */\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pStmt = 0;\n  int rc2;\n  int iIdxPrevLeaf = pSeg->pgnoFirst-1;\n  int iDlidxPrevLeaf = pSeg->pgnoLast;\n\n  if( pSeg->pgnoFirst==0 ) return;\n\n  fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(\n      \"SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d\",\n      pConfig->zDb, pConfig->zName, pSeg->iSegid\n  ));\n\n  /* Iterate through the b-tree hierarchy.  */\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    i64 iRow;                     /* Rowid for this leaf */\n    Fts5Data *pLeaf;              /* Data for this leaf */\n\n    int nIdxTerm = sqlite3_column_bytes(pStmt, 1);\n    const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1);\n    int iIdxLeaf = sqlite3_column_int(pStmt, 2);\n    int bIdxDlidx = sqlite3_column_int(pStmt, 3);\n\n    /* If the leaf in question has already been trimmed from the segment, \n    ** ignore this b-tree entry. Otherwise, load it into memory. */\n    if( iIdxLeaf<pSeg->pgnoFirst ) continue;\n    iRow = FTS5_SEGMENT_ROWID(pSeg->iSegid, iIdxLeaf);\n    pLeaf = fts5LeafRead(p, iRow);\n    if( pLeaf==0 ) break;\n\n    /* Check that the leaf contains at least one term, and that it is equal\n    ** to or larger than the split-key in zIdxTerm.  Also check that if there\n    ** is also a rowid pointer within the leaf page header, it points to a\n    ** location before the term.  */\n    if( pLeaf->nn<=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else{\n      int iOff;                   /* Offset of first term on leaf */\n      int iRowidOff;              /* Offset of first rowid on leaf */\n      int nTerm;                  /* Size of term on leaf in bytes */\n      int res;                    /* Comparison of term and split-key */\n\n      iOff = fts5LeafFirstTermOff(pLeaf);\n      iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n      if( iRowidOff>=iOff ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);\n        res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));\n        if( res==0 ) res = nTerm - nIdxTerm;\n        if( res<0 ) p->rc = FTS5_CORRUPT;\n      }\n\n      fts5IntegrityCheckPgidx(p, pLeaf);\n    }\n    fts5DataRelease(pLeaf);\n    if( p->rc ) break;\n\n    /* Now check that the iter.nEmpty leaves following the current leaf\n    ** (a) exist and (b) contain no terms. */\n    fts5IndexIntegrityCheckEmpty(\n        p, pSeg, iIdxPrevLeaf+1, iDlidxPrevLeaf+1, iIdxLeaf-1\n    );\n    if( p->rc ) break;\n\n    /* If there is a doclist-index, check that it looks right. */\n    if( bIdxDlidx ){\n      Fts5DlidxIter *pDlidx = 0;  /* For iterating through doclist index */\n      int iPrevLeaf = iIdxLeaf;\n      int iSegid = pSeg->iSegid;\n      int iPg = 0;\n      i64 iKey;\n\n      for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iIdxLeaf);\n          fts5DlidxIterEof(p, pDlidx)==0;\n          fts5DlidxIterNext(p, pDlidx)\n      ){\n\n        /* Check any rowid-less pages that occur before the current leaf. */\n        for(iPg=iPrevLeaf+1; iPg<fts5DlidxIterPgno(pDlidx); iPg++){\n          iKey = FTS5_SEGMENT_ROWID(iSegid, iPg);\n          pLeaf = fts5DataRead(p, iKey);\n          if( pLeaf ){\n            if( fts5LeafFirstRowidOff(pLeaf)!=0 ) p->rc = FTS5_CORRUPT;\n            fts5DataRelease(pLeaf);\n          }\n        }\n        iPrevLeaf = fts5DlidxIterPgno(pDlidx);\n\n        /* Check that the leaf page indicated by the iterator really does\n        ** contain the rowid suggested by the same. */\n        iKey = FTS5_SEGMENT_ROWID(iSegid, iPrevLeaf);\n        pLeaf = fts5DataRead(p, iKey);\n        if( pLeaf ){\n          i64 iRowid;\n          int iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n          ASSERT_SZLEAF_OK(pLeaf);\n          if( iRowidOff>=pLeaf->szLeaf ){\n            p->rc = FTS5_CORRUPT;\n          }else{\n            fts5GetVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);\n            if( iRowid!=fts5DlidxIterRowid(pDlidx) ) p->rc = FTS5_CORRUPT;\n          }\n          fts5DataRelease(pLeaf);\n        }\n      }\n\n      iDlidxPrevLeaf = iPg;\n      fts5DlidxIterFree(pDlidx);\n      fts5TestDlidxReverse(p, iSegid, iIdxLeaf);\n    }else{\n      iDlidxPrevLeaf = pSeg->pgnoLast;\n      /* TODO: Check there is no doclist index */\n    }\n\n    iIdxPrevLeaf = iIdxLeaf;\n  }\n\n  rc2 = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n  /* Page iter.iLeaf must now be the rightmost leaf-page in the segment */\n#if 0\n  if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }\n#endif\n}\n\n\n/*\n** Run internal checks to ensure that the FTS index (a) is internally \n** consistent and (b) contains entries for which the XOR of the checksums\n** as calculated by sqlite3Fts5IndexEntryCksum() is cksum.\n**\n** Return SQLITE_CORRUPT if any of the internal checks fail, or if the\n** checksum does not match. Return SQLITE_OK if all checks pass without\n** error, or some other SQLite error code if another error (e.g. OOM)\n** occurs.\n*/\nint sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum2 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer poslist = {0,0,0};   /* Buffer used to hold a poslist */\n  Fts5Iter *pIter;                /* Used to iterate through entire index */\n  Fts5Structure *pStruct;         /* Index structure */\n\n#ifdef SQLITE_DEBUG\n  /* Used by extra internal tests only run if NDEBUG is not defined */\n  u64 cksum3 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer term = {0,0,0};      /* Buffer used to hold most recent term */\n#endif\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  \n  /* Load the FTS index structure */\n  pStruct = fts5StructureRead(p);\n\n  /* Check that the internal nodes of each segment match the leaves */\n  if( pStruct ){\n    int iLvl, iSeg;\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n        Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];\n        fts5IndexIntegrityCheckSegment(p, pSeg);\n      }\n    }\n  }\n\n  /* The cksum argument passed to this function is a checksum calculated\n  ** based on all expected entries in the FTS index (including prefix index\n  ** entries). This block checks that a checksum calculated based on the\n  ** actual contents of FTS index is identical.\n  **\n  ** Two versions of the same checksum are calculated. The first (stack\n  ** variable cksum2) based on entries extracted from the full-text index\n  ** while doing a linear scan of each individual index in turn. \n  **\n  ** As each term visited by the linear scans, a separate query for the\n  ** same term is performed. cksum3 is calculated based on the entries\n  ** extracted by these queries.\n  */\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, -1, 0, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    int n;                      /* Size of term in bytes */\n    i64 iPos = 0;               /* Position read from poslist */\n    int iOff = 0;               /* Offset within poslist */\n    i64 iRowid = fts5MultiIterRowid(pIter);\n    char *z = (char*)fts5MultiIterTerm(pIter, &n);\n\n    /* If this is a new term, query for it. Update cksum3 with the results. */\n    fts5TestTerm(p, &term, z, n, cksum2, &cksum3);\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( 0==fts5MultiIterIsEmpty(p, pIter) ){\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n);\n      }\n    }else{\n      poslist.n = 0;\n      fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist);\n      while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){\n        int iCol = FTS5_POS2COLUMN(iPos);\n        int iTokOff = FTS5_POS2OFFSET(iPos);\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n);\n      }\n    }\n  }\n  fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);\n\n  fts5MultiIterFree(pIter);\n  if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;\n\n  fts5StructureRelease(pStruct);\n#ifdef SQLITE_DEBUG\n  fts5BufferFree(&term);\n#endif\n  fts5BufferFree(&poslist);\n  return fts5IndexReturn(p);\n}\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the fts5_decode() scalar\n** function only.\n*/\n\n/*\n** Decode a segment-data rowid from the %_data table. This function is\n** the opposite of macro FTS5_SEGMENT_ROWID().\n*/\nstatic void fts5DecodeRowid(\n  i64 iRowid,                     /* Rowid from %_data table */\n  int *piSegid,                   /* OUT: Segment id */\n  int *pbDlidx,                   /* OUT: Dlidx flag */\n  int *piHeight,                  /* OUT: Height */\n  int *piPgno                     /* OUT: Page number */\n){\n  *piPgno = (int)(iRowid & (((i64)1 << FTS5_DATA_PAGE_B) - 1));\n  iRowid >>= FTS5_DATA_PAGE_B;\n\n  *piHeight = (int)(iRowid & (((i64)1 << FTS5_DATA_HEIGHT_B) - 1));\n  iRowid >>= FTS5_DATA_HEIGHT_B;\n\n  *pbDlidx = (int)(iRowid & 0x0001);\n  iRowid >>= FTS5_DATA_DLI_B;\n\n  *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1));\n}\n\nstatic void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){\n  int iSegid, iHeight, iPgno, bDlidx;       /* Rowid compenents */\n  fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  if( iSegid==0 ){\n    if( iKey==FTS5_AVERAGES_ROWID ){\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{averages} \");\n    }else{\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{structure}\");\n    }\n  }\n  else{\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{%ssegid=%d h=%d pgno=%d}\",\n        bDlidx ? \"dlidx \" : \"\", iSegid, iHeight, iPgno\n    );\n  }\n}\n\nstatic void fts5DebugStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  Fts5Structure *p\n){\n  int iLvl, iSeg;                 /* Iterate through levels, segments */\n\n  for(iLvl=0; iLvl<p->nLevel; iLvl++){\n    Fts5StructureLevel *pLvl = &p->aLevel[iLvl];\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \n        \" {lvl=%d nMerge=%d nSeg=%d\", iLvl, pLvl->nMerge, pLvl->nSeg\n    );\n    for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n      Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" {id=%d leaves=%d..%d}\", \n          pSeg->iSegid, pSeg->pgnoFirst, pSeg->pgnoLast\n      );\n    }\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"}\");\n  }\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain a serialized Fts5Structure object. This\n** function appends a human-readable representation of the same object\n** to the buffer passed as the second argument. \n*/\nstatic void fts5DecodeStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int rc;                         /* Return code */\n  Fts5Structure *p = 0;           /* Decoded structure object */\n\n  rc = fts5StructureDecode(pBlob, nBlob, 0, &p);\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return;\n  }\n\n  fts5DebugStructure(pRc, pBuf, p);\n  fts5StructureRelease(p);\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain an \"averages\" record. This function \n** appends a human-readable representation of record to the buffer passed \n** as the second argument. \n*/\nstatic void fts5DecodeAverages(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int i = 0;\n  const char *zSpace = \"\";\n\n  while( i<nBlob ){\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pBlob[i], &iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"%s%d\", zSpace, (int)iVal);\n    zSpace = \" \";\n  }\n}\n\n/*\n** Buffer (a/n) is assumed to contain a list of serialized varints. Read\n** each varint and append its string representation to buffer pBuf. Return\n** after either the input buffer is exhausted or a 0 value is read.\n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodePoslist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  int iOff = 0;\n  while( iOff<n ){\n    int iVal;\n    iOff += fts5GetVarint32(&a[iOff], iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %d\", iVal);\n  }\n  return iOff;\n}\n\n/*\n** The start of buffer (a/n) contains the start of a doclist. The doclist\n** may or may not finish within the buffer. This function appends a text\n** representation of the part of the doclist that is present to buffer\n** pBuf. \n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  i64 iDocid = 0;\n  int iOff = 0;\n\n  if( n>0 ){\n    iOff = sqlite3Fts5GetVarint(a, (u64*)&iDocid);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n  }\n  while( iOff<n ){\n    int nPos;\n    int bDel;\n    iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDel);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" nPos=%d%s\", nPos, bDel?\"*\":\"\");\n    iOff += fts5DecodePoslist(pRc, pBuf, &a[iOff], MIN(n-iOff, nPos));\n    if( iOff<n ){\n      i64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&iDelta);\n      iDocid += iDelta;\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n    }\n  }\n\n  return iOff;\n}\n\n/*\n** This function is part of the fts5_decode() debugging function. It is \n** only ever used with detail=none tables.\n**\n** Buffer (pData/nData) contains a doclist in the format used by detail=none\n** tables. This function appends a human-readable version of that list to\n** buffer pBuf.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is a\n** no-op. If an OOM or other error occurs within this function, *pRc is\n** set to an SQLite error code before returning. The final state of buffer\n** pBuf is undefined in this case.\n*/\nstatic void fts5DecodeRowidList(\n  int *pRc,                       /* IN/OUT: Error code */\n  Fts5Buffer *pBuf,               /* Buffer to append text to */\n  const u8 *pData, int nData      /* Data to decode list-of-rowids from */\n){\n  int i = 0;\n  i64 iRowid = 0;\n\n  while( i<nData ){\n    const char *zApp = \"\";\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pData[i], &iVal);\n    iRowid += iVal;\n\n    if( i<nData && pData[i]==0x00 ){\n      i++;\n      if( i<nData && pData[i]==0x00 ){\n        i++;\n        zApp = \"+\";\n      }else{\n        zApp = \"*\";\n      }\n    }\n\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %lld%s\", iRowid, zApp);\n  }\n}\n\n/*\n** The implementation of user-defined scalar function fts5_decode().\n*/\nstatic void fts5DecodeFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  i64 iRowid;                     /* Rowid for record being decoded */\n  int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */\n  const u8 *aBlob; int n;         /* Record to decode */\n  u8 *a = 0;\n  Fts5Buffer s;                   /* Build up text to return here */\n  int rc = SQLITE_OK;             /* Return code */\n  int nSpace = 0;\n  int eDetailNone = (sqlite3_user_data(pCtx)!=0);\n\n  assert( nArg==2 );\n  UNUSED_PARAM(nArg);\n  memset(&s, 0, sizeof(Fts5Buffer));\n  iRowid = sqlite3_value_int64(apVal[0]);\n\n  /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]\n  ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents\n  ** buffer overreads even if the record is corrupt.  */\n  n = sqlite3_value_bytes(apVal[1]);\n  aBlob = sqlite3_value_blob(apVal[1]);\n  nSpace = n + FTS5_DATA_ZERO_PADDING;\n  a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);\n  if( a==0 ) goto decode_out;\n  memcpy(a, aBlob, n);\n\n\n  fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  fts5DebugRowid(&rc, &s, iRowid);\n  if( bDlidx ){\n    Fts5Data dlidx;\n    Fts5DlidxLvl lvl;\n\n    dlidx.p = a;\n    dlidx.nn = n;\n\n    memset(&lvl, 0, sizeof(Fts5DlidxLvl));\n    lvl.pData = &dlidx;\n    lvl.iLeafPgno = iPgno;\n\n    for(fts5DlidxLvlNext(&lvl); lvl.bEof==0; fts5DlidxLvlNext(&lvl)){\n      sqlite3Fts5BufferAppendPrintf(&rc, &s, \n          \" %d(%lld)\", lvl.iLeafPgno, lvl.iRowid\n      );\n    }\n  }else if( iSegid==0 ){\n    if( iRowid==FTS5_AVERAGES_ROWID ){\n      fts5DecodeAverages(&rc, &s, a, n);\n    }else{\n      fts5DecodeStructure(&rc, &s, a, n);\n    }\n  }else if( eDetailNone ){\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;\n    int iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n    int iTermOff;\n    int nKeep = 0;\n    int iOff;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    /* Decode any entries that occur before the first term. */\n    if( szLeaf<n ){\n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], iTermOff);\n    }else{\n      iTermOff = szLeaf;\n    }\n    fts5DecodeRowidList(&rc, &s, &a[4], iTermOff-4);\n\n    iOff = iTermOff;\n    while( iOff<szLeaf ){\n      int nAppend;\n\n      /* Read the term data for the next term*/\n      iOff += fts5GetVarint32(&a[iOff], nAppend);\n      term.n = nKeep;\n      fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]);\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += nAppend;\n\n      /* Figure out where the doclist for this term ends */\n      if( iPgidxOff<n ){\n        int nIncr;\n        iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nIncr);\n        iTermOff += nIncr;\n      }else{\n        iTermOff = szLeaf;\n      }\n\n      fts5DecodeRowidList(&rc, &s, &a[iOff], iTermOff-iOff);\n      iOff = iTermOff;\n      if( iOff<szLeaf ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }\n\n    fts5BufferFree(&term);\n  }else{\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;                   /* Offset of pgidx in a[] */\n    int iPgidxOff;\n    int iPgidxPrev = 0;           /* Previous value read from pgidx */\n    int iTermOff = 0;\n    int iRowidOff = 0;\n    int iOff;\n    int nDoclist;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    if( n<4 ){\n      sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)\"corrupt\");\n      goto decode_out;\n    }else{\n      iRowidOff = fts5GetU16(&a[0]);\n      iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], iTermOff);\n      }\n    }\n\n    /* Decode the position list tail at the start of the page */\n    if( iRowidOff!=0 ){\n      iOff = iRowidOff;\n    }else if( iTermOff!=0 ){\n      iOff = iTermOff;\n    }else{\n      iOff = szLeaf;\n    }\n    fts5DecodePoslist(&rc, &s, &a[4], iOff-4);\n\n    /* Decode any more doclist data that appears on the page before the\n    ** first term. */\n    nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;\n    fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);\n\n    while( iPgidxOff<n ){\n      int bFirst = (iPgidxOff==szLeaf);     /* True for first term on page */\n      int nByte;                            /* Bytes of data */\n      int iEnd;\n      \n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nByte);\n      iPgidxPrev += nByte;\n      iOff = iPgidxPrev;\n\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], nByte);\n        iEnd = iPgidxPrev + nByte;\n      }else{\n        iEnd = szLeaf;\n      }\n\n      if( bFirst==0 ){\n        iOff += fts5GetVarint32(&a[iOff], nByte);\n        term.n = nByte;\n      }\n      iOff += fts5GetVarint32(&a[iOff], nByte);\n      fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);\n      iOff += nByte;\n\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);\n    }\n\n    fts5BufferFree(&term);\n  }\n  \n decode_out:\n  sqlite3_free(a);\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)s.p, s.n, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  fts5BufferFree(&s);\n}\n\n/*\n** The implementation of user-defined scalar function fts5_rowid().\n*/\nstatic void fts5RowidFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  const char *zArg;\n  if( nArg==0 ){\n    sqlite3_result_error(pCtx, \"should be: fts5_rowid(subject, ....)\", -1);\n  }else{\n    zArg = (const char*)sqlite3_value_text(apVal[0]);\n    if( 0==sqlite3_stricmp(zArg, \"segment\") ){\n      i64 iRowid;\n      int segid, pgno;\n      if( nArg!=3 ){\n        sqlite3_result_error(pCtx, \n            \"should be: fts5_rowid('segment', segid, pgno))\", -1\n        );\n      }else{\n        segid = sqlite3_value_int(apVal[1]);\n        pgno = sqlite3_value_int(apVal[2]);\n        iRowid = FTS5_SEGMENT_ROWID(segid, pgno);\n        sqlite3_result_int64(pCtx, iRowid);\n      }\n    }else{\n      sqlite3_result_error(pCtx, \n        \"first arg to fts5_rowid() must be 'segment'\" , -1\n      );\n    }\n  }\n}\n\n/*\n** This is called as part of registering the FTS5 module with database\n** connection db. It registers several user-defined scalar functions useful\n** with FTS5.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, some other\n** SQLite error code is returned instead.\n*/\nint sqlite3Fts5IndexInit(sqlite3 *db){\n  int rc = sqlite3_create_function(\n      db, \"fts5_decode\", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_decode_none\", 2, \n        SQLITE_UTF8, (void*)db, fts5DecodeFunction, 0, 0\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_rowid\", -1, SQLITE_UTF8, 0, fts5RowidFunction, 0, 0\n    );\n  }\n  return rc;\n}\n\n\nint sqlite3Fts5IndexReset(Fts5Index *p){\n  assert( p->pStruct==0 || p->iStructVersion!=0 );\n  if( fts5IndexDataVersion(p)!=p->iStructVersion ){\n    fts5StructureInvalidate(p);\n  }\n  return fts5IndexReturn(p);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_main.c",
    "content": "/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n#include \"fts5Int.h\"\n\n/*\n** This variable is set to false when running tests for which the on disk\n** structures should not be corrupt. Otherwise, true. If it is false, extra\n** assert() conditions in the fts5 code are activated - conditions that are\n** only true if it is guaranteed that the fts5 database is not corrupt.\n*/\nint sqlite3_fts5_may_be_corrupt = 1;\n\n\ntypedef struct Fts5Auxdata Fts5Auxdata;\ntypedef struct Fts5Auxiliary Fts5Auxiliary;\ntypedef struct Fts5Cursor Fts5Cursor;\ntypedef struct Fts5Sorter Fts5Sorter;\ntypedef struct Fts5Table Fts5Table;\ntypedef struct Fts5TokenizerModule Fts5TokenizerModule;\n\n/*\n** NOTES ON TRANSACTIONS: \n**\n** SQLite invokes the following virtual table methods as transactions are \n** opened and closed by the user:\n**\n**     xBegin():    Start of a new transaction.\n**     xSync():     Initial part of two-phase commit.\n**     xCommit():   Final part of two-phase commit.\n**     xRollback(): Rollback the transaction.\n**\n** Anything that is required as part of a commit that may fail is performed\n** in the xSync() callback. Current versions of SQLite ignore any errors \n** returned by xCommit().\n**\n** And as sub-transactions are opened/closed:\n**\n**     xSavepoint(int S):  Open savepoint S.\n**     xRelease(int S):    Commit and close savepoint S.\n**     xRollbackTo(int S): Rollback to start of savepoint S.\n**\n** During a write-transaction the fts5_index.c module may cache some data \n** in-memory. It is flushed to disk whenever xSync(), xRelease() or\n** xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo() \n** is called.\n**\n** Additionally, if SQLITE_DEBUG is defined, an instance of the following\n** structure is used to record the current transaction state. This information\n** is not required, but it is used in the assert() statements executed by\n** function fts5CheckTransactionState() (see below).\n*/\nstruct Fts5TransactionState {\n  int eState;                     /* 0==closed, 1==open, 2==synced */\n  int iSavepoint;                 /* Number of open savepoints (0 -> none) */\n};\n\n/*\n** A single object of this type is allocated when the FTS5 module is \n** registered with a database handle. It is used to store pointers to\n** all registered FTS5 extensions - tokenizers and auxiliary functions.\n*/\nstruct Fts5Global {\n  fts5_api api;                   /* User visible part of object (see fts5.h) */\n  sqlite3 *db;                    /* Associated database connection */ \n  i64 iNextId;                    /* Used to allocate unique cursor ids */\n  Fts5Auxiliary *pAux;            /* First in list of all aux. functions */\n  Fts5TokenizerModule *pTok;      /* First in list of all tokenizer modules */\n  Fts5TokenizerModule *pDfltTok;  /* Default tokenizer module */\n  Fts5Cursor *pCsr;               /* First in list of all open cursors */\n};\n\n/*\n** Each auxiliary function registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pAux list.\n*/\nstruct Fts5Auxiliary {\n  Fts5Global *pGlobal;            /* Global context for this function */\n  char *zFunc;                    /* Function name (nul-terminated) */\n  void *pUserData;                /* User-data pointer */\n  fts5_extension_function xFunc;  /* Callback function */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5Auxiliary *pNext;           /* Next registered auxiliary function */\n};\n\n/*\n** Each tokenizer module registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pTok list.\n*/\nstruct Fts5TokenizerModule {\n  char *zName;                    /* Name of tokenizer */\n  void *pUserData;                /* User pointer passed to xCreate() */\n  fts5_tokenizer x;               /* Tokenizer functions */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5TokenizerModule *pNext;     /* Next registered tokenizer module */\n};\n\n/*\n** Virtual-table object.\n*/\nstruct Fts5Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  Fts5Index *pIndex;              /* Full-text index */\n  Fts5Storage *pStorage;          /* Document store */\n  Fts5Global *pGlobal;            /* Global (connection wide) data */\n  Fts5Cursor *pSortCsr;           /* Sort data from this cursor */\n#ifdef SQLITE_DEBUG\n  struct Fts5TransactionState ts;\n#endif\n};\n\nstruct Fts5MatchPhrase {\n  Fts5Buffer *pPoslist;           /* Pointer to current poslist */\n  int nTerm;                      /* Size of phrase in terms */\n};\n\n/*\n** pStmt:\n**   SELECT rowid, <fts> FROM <fts> ORDER BY +rank;\n**\n** aIdx[]:\n**   There is one entry in the aIdx[] array for each phrase in the query,\n**   the value of which is the offset within aPoslist[] following the last \n**   byte of the position list for the corresponding phrase.\n*/\nstruct Fts5Sorter {\n  sqlite3_stmt *pStmt;\n  i64 iRowid;                     /* Current rowid */\n  const u8 *aPoslist;             /* Position lists for current row */\n  int nIdx;                       /* Number of entries in aIdx[] */\n  int aIdx[1];                    /* Offsets into aPoslist for current row */\n};\n\n\n/*\n** Virtual-table cursor object.\n**\n** iSpecial:\n**   If this is a 'special' query (refer to function fts5SpecialMatch()), \n**   then this variable contains the result of the query. \n**\n** iFirstRowid, iLastRowid:\n**   These variables are only used for FTS5_PLAN_MATCH cursors. Assuming the\n**   cursor iterates in ascending order of rowids, iFirstRowid is the lower\n**   limit of rowids to return, and iLastRowid the upper. In other words, the\n**   WHERE clause in the user's query might have been:\n**\n**       <tbl> MATCH <expr> AND rowid BETWEEN $iFirstRowid AND $iLastRowid\n**\n**   If the cursor iterates in descending order of rowid, iFirstRowid\n**   is the upper limit (i.e. the \"first\" rowid visited) and iLastRowid\n**   the lower.\n*/\nstruct Fts5Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts5Cursor *pNext;              /* Next cursor in Fts5Cursor.pCsr list */\n  int *aColumnSize;               /* Values for xColumnSize() */\n  i64 iCsrId;                     /* Cursor id */\n\n  /* Zero from this point onwards on cursor reset */\n  int ePlan;                      /* FTS5_PLAN_XXX value */\n  int bDesc;                      /* True for \"ORDER BY rowid DESC\" queries */\n  i64 iFirstRowid;                /* Return no rowids earlier than this */\n  i64 iLastRowid;                 /* Return no rowids later than this */\n  sqlite3_stmt *pStmt;            /* Statement used to read %_content */\n  Fts5Expr *pExpr;                /* Expression for MATCH queries */\n  Fts5Sorter *pSorter;            /* Sorter for \"ORDER BY rank\" queries */\n  int csrflags;                   /* Mask of cursor flags (see below) */\n  i64 iSpecial;                   /* Result of special query */\n\n  /* \"rank\" function. Populated on demand from vtab.xColumn(). */\n  char *zRank;                    /* Custom rank function */\n  char *zRankArgs;                /* Custom rank function args */\n  Fts5Auxiliary *pRank;           /* Rank callback (or NULL) */\n  int nRankArg;                   /* Number of trailing arguments for rank() */\n  sqlite3_value **apRankArg;      /* Array of trailing arguments */\n  sqlite3_stmt *pRankArgStmt;     /* Origin of objects in apRankArg[] */\n\n  /* Auxiliary data storage */\n  Fts5Auxiliary *pAux;            /* Currently executing extension function */\n  Fts5Auxdata *pAuxdata;          /* First in linked list of saved aux-data */\n\n  /* Cache used by auxiliary functions xInst() and xInstCount() */\n  Fts5PoslistReader *aInstIter;   /* One for each phrase */\n  int nInstAlloc;                 /* Size of aInst[] array (entries / 3) */\n  int nInstCount;                 /* Number of phrase instances */\n  int *aInst;                     /* 3 integers per phrase instance */\n};\n\n/*\n** Bits that make up the \"idxNum\" parameter passed indirectly by \n** xBestIndex() to xFilter().\n*/\n#define FTS5_BI_MATCH        0x0001         /* <tbl> MATCH ? */\n#define FTS5_BI_RANK         0x0002         /* rank MATCH ? */\n#define FTS5_BI_ROWID_EQ     0x0004         /* rowid == ? */\n#define FTS5_BI_ROWID_LE     0x0008         /* rowid <= ? */\n#define FTS5_BI_ROWID_GE     0x0010         /* rowid >= ? */\n\n#define FTS5_BI_ORDER_RANK   0x0020\n#define FTS5_BI_ORDER_ROWID  0x0040\n#define FTS5_BI_ORDER_DESC   0x0080\n\n/*\n** Values for Fts5Cursor.csrflags\n*/\n#define FTS5CSR_EOF               0x01\n#define FTS5CSR_REQUIRE_CONTENT   0x02\n#define FTS5CSR_REQUIRE_DOCSIZE   0x04\n#define FTS5CSR_REQUIRE_INST      0x08\n#define FTS5CSR_FREE_ZRANK        0x10\n#define FTS5CSR_REQUIRE_RESEEK    0x20\n#define FTS5CSR_REQUIRE_POSLIST   0x40\n\n#define BitFlagAllTest(x,y) (((x) & (y))==(y))\n#define BitFlagTest(x,y)    (((x) & (y))!=0)\n\n\n/*\n** Macros to Set(), Clear() and Test() cursor flags.\n*/\n#define CsrFlagSet(pCsr, flag)   ((pCsr)->csrflags |= (flag))\n#define CsrFlagClear(pCsr, flag) ((pCsr)->csrflags &= ~(flag))\n#define CsrFlagTest(pCsr, flag)  ((pCsr)->csrflags & (flag))\n\nstruct Fts5Auxdata {\n  Fts5Auxiliary *pAux;            /* Extension to which this belongs */\n  void *pPtr;                     /* Pointer value */\n  void(*xDelete)(void*);          /* Destructor */\n  Fts5Auxdata *pNext;             /* Next object in linked list */\n};\n\n#ifdef SQLITE_DEBUG\n#define FTS5_BEGIN      1\n#define FTS5_SYNC       2\n#define FTS5_COMMIT     3\n#define FTS5_ROLLBACK   4\n#define FTS5_SAVEPOINT  5\n#define FTS5_RELEASE    6\n#define FTS5_ROLLBACKTO 7\nstatic void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){\n  switch( op ){\n    case FTS5_BEGIN:\n      assert( p->ts.eState==0 );\n      p->ts.eState = 1;\n      p->ts.iSavepoint = -1;\n      break;\n\n    case FTS5_SYNC:\n      assert( p->ts.eState==1 );\n      p->ts.eState = 2;\n      break;\n\n    case FTS5_COMMIT:\n      assert( p->ts.eState==2 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_ROLLBACK:\n      assert( p->ts.eState==1 || p->ts.eState==2 || p->ts.eState==0 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_SAVEPOINT:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint>p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n      \n    case FTS5_RELEASE:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint-1;\n      break;\n\n    case FTS5_ROLLBACKTO:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n  }\n}\n#else\n# define fts5CheckTransactionState(x,y,z)\n#endif\n\n/*\n** Return true if pTab is a contentless table.\n*/\nstatic int fts5IsContentless(Fts5Table *pTab){\n  return pTab->pConfig->eContent==FTS5_CONTENT_NONE;\n}\n\n/*\n** Delete a virtual table handle allocated by fts5InitVtab(). \n*/\nstatic void fts5FreeVtab(Fts5Table *pTab){\n  if( pTab ){\n    sqlite3Fts5IndexClose(pTab->pIndex);\n    sqlite3Fts5StorageClose(pTab->pStorage);\n    sqlite3Fts5ConfigFree(pTab->pConfig);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5DisconnectMethod(sqlite3_vtab *pVtab){\n  fts5FreeVtab((Fts5Table*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5DestroyMethod(sqlite3_vtab *pVtab){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  int rc = sqlite3Fts5DropAll(pTab->pConfig);\n  if( rc==SQLITE_OK ){\n    fts5FreeVtab((Fts5Table*)pVtab);\n  }\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts5InitVtab(\n  int bCreate,                    /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pAux;\n  const char **azConfig = (const char**)argv;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = 0;        /* Results of parsing argc/argv */\n  Fts5Table *pTab = 0;            /* New virtual table object */\n\n  /* Allocate the new vtab object and parse the configuration */\n  pTab = (Fts5Table*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Table));\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);\n    assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );\n  }\n  if( rc==SQLITE_OK ){\n    pTab->pConfig = pConfig;\n    pTab->pGlobal = pGlobal;\n  }\n\n  /* Open the index sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->pIndex, pzErr);\n  }\n\n  /* Open the storage sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageOpen(\n        pConfig, pTab->pIndex, bCreate, &pTab->pStorage, pzErr\n    );\n  }\n\n  /* Call sqlite3_declare_vtab() */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigDeclareVtab(pConfig);\n  }\n\n  /* Load the initial configuration */\n  if( rc==SQLITE_OK ){\n    assert( pConfig->pzErrmsg==0 );\n    pConfig->pzErrmsg = pzErr;\n    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);\n    sqlite3Fts5IndexRollback(pTab->pIndex);\n    pConfig->pzErrmsg = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5FreeVtab(pTab);\n    pTab = 0;\n  }else if( bCreate ){\n    fts5CheckTransactionState(pTab, FTS5_BEGIN, 0);\n  }\n  *ppVTab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5InitVtab().\n*/\nstatic int fts5ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** The different query plans.\n*/\n#define FTS5_PLAN_MATCH          1       /* (<tbl> MATCH ?) */\n#define FTS5_PLAN_SOURCE         2       /* A source cursor for SORTED_MATCH */\n#define FTS5_PLAN_SPECIAL        3       /* An internal query */\n#define FTS5_PLAN_SORTED_MATCH   4       /* (<tbl> MATCH ? ORDER BY rank) */\n#define FTS5_PLAN_SCAN           5       /* No usable constraint */\n#define FTS5_PLAN_ROWID          6       /* (rowid = ?) */\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts5SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n#ifndef SQLITE_CORE\n  if( sqlite3_libversion_number()>=3008012 )\n#endif\n  {\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/*\n** Implementation of the xBestIndex method for FTS5 tables. Within the \n** WHERE constraint, it searches for the following:\n**\n**   1. A MATCH constraint against the special column.\n**   2. A MATCH constraint against the \"rank\" column.\n**   3. An == constraint against the rowid column.\n**   4. A < or <= constraint against the rowid column.\n**   5. A > or >= constraint against the rowid column.\n**\n** Within the ORDER BY, either:\n**\n**   5. ORDER BY rank [ASC|DESC]\n**   6. ORDER BY rowid [ASC|DESC]\n**\n** Costs are assigned as follows:\n**\n**  a) If an unusable MATCH operator is present in the WHERE clause, the\n**     cost is unconditionally set to 1e50 (a really big number).\n**\n**  a) If a MATCH operator is present, the cost depends on the other\n**     constraints also present. As follows:\n**\n**       * No other constraints:         cost=1000.0\n**       * One rowid range constraint:   cost=750.0\n**       * Both rowid range constraints: cost=500.0\n**       * An == rowid constraint:       cost=100.0\n**\n**  b) Otherwise, if there is no MATCH:\n**\n**       * No other constraints:         cost=1000000.0\n**       * One rowid range constraint:   cost=750000.0\n**       * Both rowid range constraints: cost=250000.0\n**       * An == rowid constraint:       cost=10.0\n**\n** Costs are not modified by the ORDER BY clause.\n*/\nstatic int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts5Table *pTab = (Fts5Table*)pVTab;\n  Fts5Config *pConfig = pTab->pConfig;\n  const int nCol = pConfig->nCol;\n  int idxFlags = 0;               /* Parameter passed through to xFilter() */\n  int bHasMatch;\n  int iNext;\n  int i;\n\n  struct Constraint {\n    int op;                       /* Mask against sqlite3_index_constraint.op */\n    int fts5op;                   /* FTS5 mask for idxFlags */\n    int iCol;                     /* 0==rowid, 1==tbl, 2==rank */\n    int omit;                     /* True to omit this if found */\n    int iConsIndex;               /* Index in pInfo->aConstraint[] */\n  } aConstraint[] = {\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_MATCH,    1, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_RANK,     2, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_EQ,    FTS5_BI_ROWID_EQ, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_LT|SQLITE_INDEX_CONSTRAINT_LE, \n                                    FTS5_BI_ROWID_LE, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_GT|SQLITE_INDEX_CONSTRAINT_GE, \n                                    FTS5_BI_ROWID_GE, 0, 0, -1},\n  };\n\n  int aColMap[3];\n  aColMap[0] = -1;\n  aColMap[1] = nCol;\n  aColMap[2] = nCol+1;\n\n  /* Set idxFlags flags for all WHERE clause terms that will be used. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    int iCol = p->iColumn;\n\n    if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol)\n     || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol)\n    ){\n      /* A MATCH operator or equivalent */\n      if( p->usable ){\n        idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16);\n        aConstraint[0].iConsIndex = i;\n      }else{\n        /* As there exists an unusable MATCH constraint this is an \n        ** unusable plan. Set a prohibitively high cost. */\n        pInfo->estimatedCost = 1e50;\n        return SQLITE_OK;\n      }\n    }else{\n      int j;\n      for(j=1; j<ArraySize(aConstraint); j++){\n        struct Constraint *pC = &aConstraint[j];\n        if( iCol==aColMap[pC->iCol] && p->op & pC->op && p->usable ){\n          pC->iConsIndex = i;\n          idxFlags |= pC->fts5op;\n        }\n      }\n    }\n  }\n\n  /* Set idxFlags flags for the ORDER BY clause */\n  if( pInfo->nOrderBy==1 ){\n    int iSort = pInfo->aOrderBy[0].iColumn;\n    if( iSort==(pConfig->nCol+1) && BitFlagTest(idxFlags, FTS5_BI_MATCH) ){\n      idxFlags |= FTS5_BI_ORDER_RANK;\n    }else if( iSort==-1 ){\n      idxFlags |= FTS5_BI_ORDER_ROWID;\n    }\n    if( BitFlagTest(idxFlags, FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) ){\n      pInfo->orderByConsumed = 1;\n      if( pInfo->aOrderBy[0].desc ){\n        idxFlags |= FTS5_BI_ORDER_DESC;\n      }\n    }\n  }\n\n  /* Calculate the estimated cost based on the flags set in idxFlags. */\n  bHasMatch = BitFlagTest(idxFlags, FTS5_BI_MATCH);\n  if( BitFlagTest(idxFlags, FTS5_BI_ROWID_EQ) ){\n    pInfo->estimatedCost = bHasMatch ? 100.0 : 10.0;\n    if( bHasMatch==0 ) fts5SetUniqueFlag(pInfo);\n  }else if( BitFlagAllTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 500.0 : 250000.0;\n  }else if( BitFlagTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 750.0 : 750000.0;\n  }else{\n    pInfo->estimatedCost = bHasMatch ? 1000.0 : 1000000.0;\n  }\n\n  /* Assign argvIndex values to each constraint in use. */\n  iNext = 1;\n  for(i=0; i<ArraySize(aConstraint); i++){\n    struct Constraint *pC = &aConstraint[i];\n    if( pC->iConsIndex>=0 ){\n      pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;\n      pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit;\n    }\n  }\n\n  pInfo->idxNum = idxFlags;\n  return SQLITE_OK;\n}\n\nstatic int fts5NewTransaction(Fts5Table *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;\n  }\n  return sqlite3Fts5StorageReset(pTab->pStorage);\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts5Table *pTab = (Fts5Table*)pVTab;\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = 0;           /* New cursor object */\n  int nByte;                      /* Bytes of space to allocate */\n  int rc;                         /* Return code */\n\n  rc = fts5NewTransaction(pTab);\n  if( rc==SQLITE_OK ){\n    nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);\n    pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);\n    if( pCsr ){\n      Fts5Global *pGlobal = pTab->pGlobal;\n      memset(pCsr, 0, nByte);\n      pCsr->aColumnSize = (int*)&pCsr[1];\n      pCsr->pNext = pGlobal->pCsr;\n      pGlobal->pCsr = pCsr;\n      pCsr->iCsrId = ++pGlobal->iNextId;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic int fts5StmtType(Fts5Cursor *pCsr){\n  if( pCsr->ePlan==FTS5_PLAN_SCAN ){\n    return (pCsr->bDesc) ? FTS5_STMT_SCAN_DESC : FTS5_STMT_SCAN_ASC;\n  }\n  return FTS5_STMT_LOOKUP;\n}\n\n/*\n** This function is called after the cursor passed as the only argument\n** is moved to point at a different row. It clears all cached data \n** specific to the previous row stored by the cursor object.\n*/\nstatic void fts5CsrNewrow(Fts5Cursor *pCsr){\n  CsrFlagSet(pCsr, \n      FTS5CSR_REQUIRE_CONTENT \n    | FTS5CSR_REQUIRE_DOCSIZE \n    | FTS5CSR_REQUIRE_INST \n    | FTS5CSR_REQUIRE_POSLIST \n  );\n}\n\nstatic void fts5FreeCursorComponents(Fts5Cursor *pCsr){\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Auxdata *pData;\n  Fts5Auxdata *pNext;\n\n  sqlite3_free(pCsr->aInstIter);\n  sqlite3_free(pCsr->aInst);\n  if( pCsr->pStmt ){\n    int eStmt = fts5StmtType(pCsr);\n    sqlite3Fts5StorageStmtRelease(pTab->pStorage, eStmt, pCsr->pStmt);\n  }\n  if( pCsr->pSorter ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n  }\n\n  if( pCsr->ePlan!=FTS5_PLAN_SOURCE ){\n    sqlite3Fts5ExprFree(pCsr->pExpr);\n  }\n\n  for(pData=pCsr->pAuxdata; pData; pData=pNext){\n    pNext = pData->pNext;\n    if( pData->xDelete ) pData->xDelete(pData->pPtr);\n    sqlite3_free(pData);\n  }\n\n  sqlite3_finalize(pCsr->pRankArgStmt);\n  sqlite3_free(pCsr->apRankArg);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){\n    sqlite3_free(pCsr->zRank);\n    sqlite3_free(pCsr->zRankArgs);\n  }\n\n  memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));\n}\n\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){\n  if( pCursor ){\n    Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n    Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n    Fts5Cursor **pp;\n\n    fts5FreeCursorComponents(pCsr);\n    /* Remove the cursor from the Fts5Global.pCsr list */\n    for(pp=&pTab->pGlobal->pCsr; (*pp)!=pCsr; pp=&(*pp)->pNext);\n    *pp = pCsr->pNext;\n\n    sqlite3_free(pCsr);\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5SorterNext(Fts5Cursor *pCsr){\n  Fts5Sorter *pSorter = pCsr->pSorter;\n  int rc;\n\n  rc = sqlite3_step(pSorter->pStmt);\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }else if( rc==SQLITE_ROW ){\n    const u8 *a;\n    const u8 *aBlob;\n    int nBlob;\n    int i;\n    int iOff = 0;\n    rc = SQLITE_OK;\n\n    pSorter->iRowid = sqlite3_column_int64(pSorter->pStmt, 0);\n    nBlob = sqlite3_column_bytes(pSorter->pStmt, 1);\n    aBlob = a = sqlite3_column_blob(pSorter->pStmt, 1);\n\n    /* nBlob==0 in detail=none mode. */\n    if( nBlob>0 ){\n      for(i=0; i<(pSorter->nIdx-1); i++){\n        int iVal;\n        a += fts5GetVarint32(a, iVal);\n        iOff += iVal;\n        pSorter->aIdx[i] = iOff;\n      }\n      pSorter->aIdx[i] = &aBlob[nBlob] - a;\n      pSorter->aPoslist = a;\n    }\n\n    fts5CsrNewrow(pCsr);\n  }\n\n  return rc;\n}\n\n\n/*\n** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors \n** open on table pTab.\n*/\nstatic void fts5TripCursors(Fts5Table *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->ePlan==FTS5_PLAN_MATCH\n     && pCsr->base.pVtab==(sqlite3_vtab*)pTab \n    ){\n      CsrFlagSet(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    }\n  }\n}\n\n/*\n** If the REQUIRE_RESEEK flag is set on the cursor passed as the first\n** argument, close and reopen all Fts5IndexIter iterators that the cursor \n** is using. Then attempt to move the cursor to a rowid equal to or laster\n** (in the cursors sort order - ASC or DESC) than the current rowid. \n**\n** If the new rowid is not equal to the old, set output parameter *pbSkip\n** to 1 before returning. Otherwise, leave it unchanged.\n**\n** Return SQLITE_OK if successful or if no reseek was required, or an \n** error code if an error occurred.\n*/\nstatic int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){\n  int rc = SQLITE_OK;\n  assert( *pbSkip==0 );\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){\n    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n    int bDesc = pCsr->bDesc;\n    i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);\n\n    rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);\n    if( rc==SQLITE_OK &&  iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){\n      *pbSkip = 1;\n    }\n\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    fts5CsrNewrow(pCsr);\n    if( sqlite3Fts5ExprEof(pCsr->pExpr) ){\n      CsrFlagSet(pCsr, FTS5CSR_EOF);\n      *pbSkip = 1;\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Advance the cursor to the next row in the table that matches the \n** search criteria.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts5EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts5NextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc;\n\n  assert( (pCsr->ePlan<3)==\n          (pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE) \n  );\n  assert( !CsrFlagTest(pCsr, FTS5CSR_EOF) );\n\n  if( pCsr->ePlan<3 ){\n    int bSkip = 0;\n    if( (rc = fts5CursorReseek(pCsr, &bSkip)) || bSkip ) return rc;\n    rc = sqlite3Fts5ExprNext(pCsr->pExpr, pCsr->iLastRowid);\n    CsrFlagSet(pCsr, sqlite3Fts5ExprEof(pCsr->pExpr));\n    fts5CsrNewrow(pCsr);\n  }else{\n    switch( pCsr->ePlan ){\n      case FTS5_PLAN_SPECIAL: {\n        CsrFlagSet(pCsr, FTS5CSR_EOF);\n        rc = SQLITE_OK;\n        break;\n      }\n  \n      case FTS5_PLAN_SORTED_MATCH: {\n        rc = fts5SorterNext(pCsr);\n        break;\n      }\n  \n      default:\n        rc = sqlite3_step(pCsr->pStmt);\n        if( rc!=SQLITE_ROW ){\n          CsrFlagSet(pCsr, FTS5CSR_EOF);\n          rc = sqlite3_reset(pCsr->pStmt);\n        }else{\n          rc = SQLITE_OK;\n        }\n        break;\n    }\n  }\n  \n  return rc;\n}\n\n\nstatic int fts5PrepareStatement(\n  sqlite3_stmt **ppStmt,\n  Fts5Config *pConfig, \n  const char *zFmt,\n  ...\n){\n  sqlite3_stmt *pRet = 0;\n  int rc;\n  char *zSql;\n  va_list ap;\n\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM; \n  }else{\n    rc = sqlite3_prepare_v3(pConfig->db, zSql, -1, \n                            SQLITE_PREPARE_PERSISTENT, &pRet, 0);\n    if( rc!=SQLITE_OK ){\n      *pConfig->pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pConfig->db));\n    }\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  *ppStmt = pRet;\n  return rc;\n} \n\nstatic int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Sorter *pSorter;\n  int nPhrase;\n  int nByte;\n  int rc;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n  \n  nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);\n  pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);\n  if( pSorter==0 ) return SQLITE_NOMEM;\n  memset(pSorter, 0, nByte);\n  pSorter->nIdx = nPhrase;\n\n  /* TODO: It would be better to have some system for reusing statement\n  ** handles here, rather than preparing a new one for each query. But that\n  ** is not possible as SQLite reference counts the virtual table objects.\n  ** And since the statement required here reads from this very virtual \n  ** table, saving it creates a circular reference.\n  **\n  ** If SQLite a built-in statement cache, this wouldn't be a problem. */\n  rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,\n      \"SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s\",\n      pConfig->zDb, pConfig->zName, zRank, pConfig->zName,\n      (zRankArgs ? \", \" : \"\"),\n      (zRankArgs ? zRankArgs : \"\"),\n      bDesc ? \"DESC\" : \"ASC\"\n  );\n\n  pCsr->pSorter = pSorter;\n  if( rc==SQLITE_OK ){\n    assert( pTab->pSortCsr==0 );\n    pTab->pSortCsr = pCsr;\n    rc = fts5SorterNext(pCsr);\n    pTab->pSortCsr = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n    pCsr->pSorter = 0;\n  }\n\n  return rc;\n}\n\nstatic int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){\n  int rc;\n  Fts5Expr *pExpr = pCsr->pExpr;\n  rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);\n  if( sqlite3Fts5ExprEof(pExpr) ){\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }\n  fts5CsrNewrow(pCsr);\n  return rc;\n}\n\n/*\n** Process a \"special\" query. A special query is identified as one with a\n** MATCH expression that begins with a '*' character. The remainder of\n** the text passed to the MATCH operator are used as  the special query\n** parameters.\n*/\nstatic int fts5SpecialMatch(\n  Fts5Table *pTab, \n  Fts5Cursor *pCsr, \n  const char *zQuery\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *z = zQuery;         /* Special query text */\n  int n;                          /* Number of bytes in text at z */\n\n  while( z[0]==' ' ) z++;\n  for(n=0; z[n] && z[n]!=' '; n++);\n\n  assert( pTab->base.zErrMsg==0 );\n  pCsr->ePlan = FTS5_PLAN_SPECIAL;\n\n  if( 0==sqlite3_strnicmp(\"reads\", z, n) ){\n    pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->pIndex);\n  }\n  else if( 0==sqlite3_strnicmp(\"id\", z, n) ){\n    pCsr->iSpecial = pCsr->iCsrId;\n  }\n  else{\n    /* An unrecognized directive. Return an error message. */\n    pTab->base.zErrMsg = sqlite3_mprintf(\"unknown special query: %.*s\", n, z);\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n/*\n** Search for an auxiliary function named zName that can be used with table\n** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary\n** structure. Otherwise, if no such function exists, return NULL.\n*/\nstatic Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){\n  Fts5Auxiliary *pAux;\n\n  for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){\n    if( sqlite3_stricmp(zName, pAux->zFunc)==0 ) return pAux;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n\nstatic int fts5FindRankFunction(Fts5Cursor *pCsr){\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n  Fts5Auxiliary *pAux = 0;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n\n  if( zRankArgs ){\n    char *zSql = sqlite3Fts5Mprintf(&rc, \"SELECT %s\", zRankArgs);\n    if( zSql ){\n      sqlite3_stmt *pStmt = 0;\n      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &pStmt, 0);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );\n      if( rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          int nByte;\n          pCsr->nRankArg = sqlite3_column_count(pStmt);\n          nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;\n          pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);\n          if( rc==SQLITE_OK ){\n            int i;\n            for(i=0; i<pCsr->nRankArg; i++){\n              pCsr->apRankArg[i] = sqlite3_column_value(pStmt, i);\n            }\n          }\n          pCsr->pRankArgStmt = pStmt;\n        }else{\n          rc = sqlite3_finalize(pStmt);\n          assert( rc!=SQLITE_OK );\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pAux = fts5FindAuxiliary(pTab, zRank);\n    if( pAux==0 ){\n      assert( pTab->base.zErrMsg==0 );\n      pTab->base.zErrMsg = sqlite3_mprintf(\"no such function: %s\", zRank);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  pCsr->pRank = pAux;\n  return rc;\n}\n\n\nstatic int fts5CursorParseRank(\n  Fts5Config *pConfig,\n  Fts5Cursor *pCsr, \n  sqlite3_value *pRank\n){\n  int rc = SQLITE_OK;\n  if( pRank ){\n    const char *z = (const char*)sqlite3_value_text(pRank);\n    char *zRank = 0;\n    char *zRankArgs = 0;\n\n    if( z==0 ){\n      if( sqlite3_value_type(pRank)==SQLITE_NULL ) rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5ConfigParseRank(z, &zRank, &zRankArgs);\n    }\n    if( rc==SQLITE_OK ){\n      pCsr->zRank = zRank;\n      pCsr->zRankArgs = zRankArgs;\n      CsrFlagSet(pCsr, FTS5CSR_FREE_ZRANK);\n    }else if( rc==SQLITE_ERROR ){\n      pCsr->base.pVtab->zErrMsg = sqlite3_mprintf(\n          \"parse error in rank function: %s\", z\n      );\n    }\n  }else{\n    if( pConfig->zRank ){\n      pCsr->zRank = (char*)pConfig->zRank;\n      pCsr->zRankArgs = (char*)pConfig->zRankArgs;\n    }else{\n      pCsr->zRank = (char*)FTS5_DEFAULT_RANK;\n      pCsr->zRankArgs = 0;\n    }\n  }\n  return rc;\n}\n\nstatic i64 fts5GetRowidLimit(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n** \n** There are three possible query strategies:\n**\n**   1. Full-text search using a MATCH operator.\n**   2. A by-rowid lookup.\n**   3. A full-table scan.\n*/\nstatic int fts5FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;             /* Error code */\n  int iVal = 0;                   /* Counter for apVal[] */\n  int bDesc;                      /* True if ORDER BY [rank|rowid] DESC */\n  int bOrderByRank;               /* True if ORDER BY rank */\n  sqlite3_value *pMatch = 0;      /* <tbl> MATCH ? expression (or NULL) */\n  sqlite3_value *pRank = 0;       /* rank MATCH ? expression (or NULL) */\n  sqlite3_value *pRowidEq = 0;    /* rowid = ? expression (or NULL) */\n  sqlite3_value *pRowidLe = 0;    /* rowid <= ? expression (or NULL) */\n  sqlite3_value *pRowidGe = 0;    /* rowid >= ? expression (or NULL) */\n  int iCol;                       /* Column on LHS of MATCH operator */\n  char **pzErrmsg = pConfig->pzErrmsg;\n\n  UNUSED_PARAM(zUnused);\n  UNUSED_PARAM(nVal);\n\n  if( pCsr->ePlan ){\n    fts5FreeCursorComponents(pCsr);\n    memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));\n  }\n\n  assert( pCsr->pStmt==0 );\n  assert( pCsr->pExpr==0 );\n  assert( pCsr->csrflags==0 );\n  assert( pCsr->pRank==0 );\n  assert( pCsr->zRank==0 );\n  assert( pCsr->zRankArgs==0 );\n\n  assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );\n  pConfig->pzErrmsg = &pTab->base.zErrMsg;\n\n  /* Decode the arguments passed through to this function.\n  **\n  ** Note: The following set of if(...) statements must be in the same\n  ** order as the corresponding entries in the struct at the top of\n  ** fts5BestIndexMethod().  */\n  if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_RANK) ) pRank = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_EQ) ) pRowidEq = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_LE) ) pRowidLe = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_GE) ) pRowidGe = apVal[iVal++];\n  iCol = (idxNum>>16);\n  assert( iCol>=0 && iCol<=pConfig->nCol );\n  assert( iVal==nVal );\n  bOrderByRank = ((idxNum & FTS5_BI_ORDER_RANK) ? 1 : 0);\n  pCsr->bDesc = bDesc = ((idxNum & FTS5_BI_ORDER_DESC) ? 1 : 0);\n\n  /* Set the cursor upper and lower rowid limits. Only some strategies \n  ** actually use them. This is ok, as the xBestIndex() method leaves the\n  ** sqlite3_index_constraint.omit flag clear for range constraints\n  ** on the rowid field.  */\n  if( pRowidEq ){\n    pRowidLe = pRowidGe = pRowidEq;\n  }\n  if( bDesc ){\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }else{\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }\n\n  if( pTab->pSortCsr ){\n    /* If pSortCsr is non-NULL, then this call is being made as part of \n    ** processing for a \"... MATCH <expr> ORDER BY rank\" query (ePlan is\n    ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will\n    ** return results to the user for this query. The current cursor \n    ** (pCursor) is used to execute the query issued by function \n    ** fts5CursorFirstSorted() above.  */\n    assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );\n    assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );\n    assert( pCsr->iLastRowid==LARGEST_INT64 );\n    assert( pCsr->iFirstRowid==SMALLEST_INT64 );\n    pCsr->ePlan = FTS5_PLAN_SOURCE;\n    pCsr->pExpr = pTab->pSortCsr->pExpr;\n    rc = fts5CursorFirst(pTab, pCsr, bDesc);\n  }else if( pMatch ){\n    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);\n    if( zExpr==0 ) zExpr = \"\";\n\n    rc = fts5CursorParseRank(pConfig, pCsr, pRank);\n    if( rc==SQLITE_OK ){\n      if( zExpr[0]=='*' ){\n        /* The user has issued a query of the form \"MATCH '*...'\". This\n        ** indicates that the MATCH expression is not a full text query,\n        ** but a request for an internal parameter.  */\n        rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);\n      }else{\n        char **pzErr = &pTab->base.zErrMsg;\n        rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);\n        if( rc==SQLITE_OK ){\n          if( bOrderByRank ){\n            pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;\n            rc = fts5CursorFirstSorted(pTab, pCsr, bDesc);\n          }else{\n            pCsr->ePlan = FTS5_PLAN_MATCH;\n            rc = fts5CursorFirst(pTab, pCsr, bDesc);\n          }\n        }\n      }\n    }\n  }else if( pConfig->zContent==0 ){\n    *pConfig->pzErrmsg = sqlite3_mprintf(\n        \"%s: table does not support scanning\", pConfig->zName\n    );\n    rc = SQLITE_ERROR;\n  }else{\n    /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup\n    ** by rowid (ePlan==FTS5_PLAN_ROWID).  */\n    pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->base.zErrMsg\n    );\n    if( rc==SQLITE_OK ){\n      if( pCsr->ePlan==FTS5_PLAN_ROWID ){\n        sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);\n      }else{\n        sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);\n        sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);\n      }\n      rc = fts5NextMethod(pCursor);\n    }\n  }\n\n  pConfig->pzErrmsg = pzErrmsg;\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  return (CsrFlagTest(pCsr, FTS5CSR_EOF) ? 1 : 0);\n}\n\n/*\n** Return the rowid that the cursor currently points to.\n*/\nstatic i64 fts5CursorRowid(Fts5Cursor *pCsr){\n  assert( pCsr->ePlan==FTS5_PLAN_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SOURCE \n  );\n  if( pCsr->pSorter ){\n    return pCsr->pSorter->iRowid;\n  }else{\n    return sqlite3Fts5ExprRowid(pCsr->pExpr);\n  }\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts5\n** exposes %_content.rowid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int ePlan = pCsr->ePlan;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n  switch( ePlan ){\n    case FTS5_PLAN_SPECIAL:\n      *pRowid = 0;\n      break;\n\n    case FTS5_PLAN_SOURCE:\n    case FTS5_PLAN_MATCH:\n    case FTS5_PLAN_SORTED_MATCH:\n      *pRowid = fts5CursorRowid(pCsr);\n      break;\n\n    default:\n      *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** If the cursor requires seeking (bSeekRequired flag is set), seek it.\n** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise.\n**\n** If argument bErrormsg is true and an error occurs, an error message may\n** be left in sqlite3_vtab.zErrMsg.\n*/\nstatic int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){\n  int rc = SQLITE_OK;\n\n  /* If the cursor does not yet have a statement handle, obtain one now. */ \n  if( pCsr->pStmt==0 ){\n    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n    int eStmt = fts5StmtType(pCsr);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->base.zErrMsg:0)\n    );\n    assert( rc!=SQLITE_OK || pTab->base.zErrMsg==0 );\n    assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );\n  }\n\n  if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){\n    assert( pCsr->pExpr );\n    sqlite3_reset(pCsr->pStmt);\n    sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      rc = SQLITE_OK;\n      CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);\n    }else{\n      rc = sqlite3_reset(pCsr->pStmt);\n      if( rc==SQLITE_OK ){\n        rc = FTS5_CORRUPT;\n      }\n    }\n  }\n  return rc;\n}\n\nstatic void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){\n  va_list ap;                     /* ... printf arguments */\n  va_start(ap, zFormat);\n  assert( p->base.zErrMsg==0 );\n  p->base.zErrMsg = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** This function is called to handle an FTS INSERT command. In other words,\n** an INSERT statement of the form:\n**\n**     INSERT INTO fts(fts) VALUES($pCmd)\n**     INSERT INTO fts(fts, rank) VALUES($pCmd, $pVal)\n**\n** Argument pVal is the value assigned to column \"fts\" by the INSERT \n** statement. This function returns SQLITE_OK if successful, or an SQLite\n** error code if an error occurs.\n**\n** The commands implemented by this function are documented in the \"Special\n** INSERT Directives\" section of the documentation. It should be updated if\n** more commands are added to this function.\n*/\nstatic int fts5SpecialInsert(\n  Fts5Table *pTab,                /* Fts5 table object */\n  const char *zCmd,               /* Text inserted into table-name column */\n  sqlite3_value *pVal             /* Value inserted into rank column */\n){\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n  int bError = 0;\n\n  if( 0==sqlite3_stricmp(\"delete-all\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      fts5SetVtabError(pTab, \n          \"'delete-all' may only be used with a \"\n          \"contentless or external content fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"rebuild\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NONE ){\n      fts5SetVtabError(pTab, \n          \"'rebuild' may not be used with a contentless fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageRebuild(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"optimize\", zCmd) ){\n    rc = sqlite3Fts5StorageOptimize(pTab->pStorage);\n  }else if( 0==sqlite3_stricmp(\"merge\", zCmd) ){\n    int nMerge = sqlite3_value_int(pVal);\n    rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);\n  }else if( 0==sqlite3_stricmp(\"integrity-check\", zCmd) ){\n    rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);\n#ifdef SQLITE_DEBUG\n  }else if( 0==sqlite3_stricmp(\"prefix-index\", zCmd) ){\n    pConfig->bPrefixIndex = sqlite3_value_int(pVal);\n#endif\n  }else{\n    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5ConfigSetValue(pTab->pConfig, zCmd, pVal, &bError);\n    }\n    if( rc==SQLITE_OK ){\n      if( bError ){\n        rc = SQLITE_ERROR;\n      }else{\n        rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int fts5SpecialDelete(\n  Fts5Table *pTab, \n  sqlite3_value **apVal\n){\n  int rc = SQLITE_OK;\n  int eType1 = sqlite3_value_type(apVal[1]);\n  if( eType1==SQLITE_INTEGER ){\n    sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);\n    rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]);\n  }\n  return rc;\n}\n\nstatic void fts5StorageInsert(\n  int *pRc, \n  Fts5Table *pTab, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);\n  }\n  *pRc = rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n**\n** A delete specifies a single argument - the rowid of the row to remove.\n** \n** Update and insert operations pass:\n**\n**   1. The \"old\" rowid, or NULL.\n**   2. The \"new\" rowid.\n**   3. Values for each of the nCol matchable columns.\n**   4. Values for the two hidden columns (<tablename> and \"rank\").\n*/\nstatic int fts5UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  Fts5Config *pConfig = pTab->pConfig;\n  int eType0;                     /* value_type() of apVal[0] */\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* A transaction must be open when this is called. */\n  assert( pTab->ts.eState==1 );\n\n  assert( pVtab->zErrMsg==0 );\n  assert( nArg==1 || nArg==(2+pConfig->nCol+2) );\n  assert( nArg==1 \n      || sqlite3_value_type(apVal[1])==SQLITE_INTEGER \n      || sqlite3_value_type(apVal[1])==SQLITE_NULL \n  );\n  assert( pTab->pConfig->pzErrmsg==0 );\n  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;\n\n  /* Put any active cursors into REQUIRE_SEEK state. */\n  fts5TripCursors(pTab);\n\n  eType0 = sqlite3_value_type(apVal[0]);\n  if( eType0==SQLITE_NULL \n   && sqlite3_value_type(apVal[2+pConfig->nCol])!=SQLITE_NULL \n  ){\n    /* A \"special\" INSERT op. These are handled separately. */\n    const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL \n      && 0==sqlite3_stricmp(\"delete\", z) \n    ){\n      rc = fts5SpecialDelete(pTab, apVal);\n    }else{\n      rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);\n    }\n  }else{\n    /* A regular INSERT, UPDATE or DELETE statement. The trick here is that\n    ** any conflict on the rowid value must be detected before any \n    ** modifications are made to the database file. There are 4 cases:\n    **\n    **   1) DELETE\n    **   2) UPDATE (rowid not modified)\n    **   3) UPDATE (rowid modified)\n    **   4) INSERT\n    **\n    ** Cases 3 and 4 may violate the rowid constraint.\n    */\n    int eConflict = SQLITE_ABORT;\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      eConflict = sqlite3_vtab_on_conflict(pConfig->db);\n    }\n\n    assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );\n    assert( nArg!=1 || eType0==SQLITE_INTEGER );\n\n    /* Filter out attempts to run UPDATE or DELETE on contentless tables.\n    ** This is not suported.  */\n    if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){\n      pTab->base.zErrMsg = sqlite3_mprintf(\n          \"cannot %s contentless fts5 table: %s\", \n          (nArg>1 ? \"UPDATE\" : \"DELETE from\"), pConfig->zName\n      );\n      rc = SQLITE_ERROR;\n    }\n\n    /* DELETE */\n    else if( nArg==1 ){\n      i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */\n      rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);\n    }\n\n    /* INSERT */\n    else if( eType0!=SQLITE_INTEGER ){     \n      /* If this is a REPLACE, first remove the current entry (if any) */\n      if( eConflict==SQLITE_REPLACE \n       && sqlite3_value_type(apVal[1])==SQLITE_INTEGER \n      ){\n        i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */\n        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n      }\n      fts5StorageInsert(&rc, pTab, apVal, pRowid);\n    }\n\n    /* UPDATE */\n    else{\n      i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */\n      i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */\n      if( iOld!=iNew ){\n        if( eConflict==SQLITE_REPLACE ){\n          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n          }\n          fts5StorageInsert(&rc, pTab, apVal, pRowid);\n        }else{\n          rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);\n          }\n        }\n      }else{\n        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n        fts5StorageInsert(&rc, pTab, apVal, pRowid);\n      }\n    }\n  }\n\n  pTab->pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xSync() method. \n*/\nstatic int fts5SyncMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_SYNC, 0);\n  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;\n  fts5TripCursors(pTab);\n  rc = sqlite3Fts5StorageSync(pTab->pStorage);\n  pTab->pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts5BeginMethod(sqlite3_vtab *pVtab){\n  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);\n  fts5NewTransaction((Fts5Table*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts5SyncMethod().\n*/\nstatic int fts5CommitMethod(sqlite3_vtab *pVtab){\n  UNUSED_PARAM(pVtab);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts5RollbackMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);\n  rc = sqlite3Fts5StorageRollback(pTab->pStorage);\n  return rc;\n}\n\nstatic int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);\n\nstatic void *fts5ApiUserData(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return pCsr->pAux->pUserData;\n}\n\nstatic int fts5ApiColumnCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return ((Fts5Table*)(pCsr->base.pVtab))->pConfig->nCol;\n}\n\nstatic int fts5ApiColumnTotalSize(\n  Fts5Context *pCtx, \n  int iCol, \n  sqlite3_int64 *pnToken\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);\n}\n\nstatic int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);\n}\n\nstatic int fts5ApiTokenize(\n  Fts5Context *pCtx, \n  const char *pText, int nText, \n  void *pUserData,\n  int (*xToken)(void*, int, const char*, int, int, int)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5Tokenize(\n      pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken\n  );\n}\n\nstatic int fts5ApiPhraseCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n}\n\nstatic int fts5ApiPhraseSize(Fts5Context *pCtx, int iPhrase){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseSize(pCsr->pExpr, iPhrase);\n}\n\nstatic int fts5ApiColumnText(\n  Fts5Context *pCtx, \n  int iCol, \n  const char **pz, \n  int *pn\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){\n    *pz = 0;\n    *pn = 0;\n  }else{\n    rc = fts5SeekCursor(pCsr, 0);\n    if( rc==SQLITE_OK ){\n      *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1);\n      *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    }\n  }\n  return rc;\n}\n\nstatic int fts5CsrPoslist(\n  Fts5Cursor *pCsr, \n  int iPhrase, \n  const u8 **pa,\n  int *pn\n){\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n  int rc = SQLITE_OK;\n  int bLive = (pCsr->pSorter==0);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){\n\n    if( pConfig->eDetail!=FTS5_DETAIL_FULL ){\n      Fts5PoslistPopulator *aPopulator;\n      int i;\n      aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive);\n      if( aPopulator==0 ) rc = SQLITE_NOMEM;\n      for(i=0; i<pConfig->nCol && rc==SQLITE_OK; i++){\n        int n; const char *z;\n        rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5ExprPopulatePoslists(\n              pConfig, pCsr->pExpr, aPopulator, i, z, n\n          );\n        }\n      }\n      sqlite3_free(aPopulator);\n\n      if( pCsr->pSorter ){\n        sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid);\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST);\n  }\n\n  if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n    *pn = pSorter->aIdx[iPhrase] - i1;\n    *pa = &pSorter->aPoslist[i1];\n  }else{\n    *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa);\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the Fts5Cursor.nInstCount and aInst[] variables are populated\n** correctly for the current view. Return SQLITE_OK if successful, or an\n** SQLite error code otherwise.\n*/\nstatic int fts5CacheInstArray(Fts5Cursor *pCsr){\n  int rc = SQLITE_OK;\n  Fts5PoslistReader *aIter;       /* One iterator for each phrase */\n  int nIter;                      /* Number of iterators/phrases */\n  \n  nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  if( pCsr->aInstIter==0 ){\n    int nByte = sizeof(Fts5PoslistReader) * nIter;\n    pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n  aIter = pCsr->aInstIter;\n\n  if( aIter ){\n    int nInst = 0;                /* Number instances seen so far */\n    int i;\n\n    /* Initialize all iterators */\n    for(i=0; i<nIter && rc==SQLITE_OK; i++){\n      const u8 *a;\n      int n; \n      rc = fts5CsrPoslist(pCsr, i, &a, &n);\n      if( rc==SQLITE_OK ){\n        sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      while( 1 ){\n        int *aInst;\n        int iBest = -1;\n        for(i=0; i<nIter; i++){\n          if( (aIter[i].bEof==0) \n              && (iBest<0 || aIter[i].iPos<aIter[iBest].iPos) \n            ){\n            iBest = i;\n          }\n        }\n        if( iBest<0 ) break;\n\n        nInst++;\n        if( nInst>=pCsr->nInstAlloc ){\n          pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;\n          aInst = (int*)sqlite3_realloc(\n              pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3\n              );\n          if( aInst ){\n            pCsr->aInst = aInst;\n          }else{\n            rc = SQLITE_NOMEM;\n            break;\n          }\n        }\n\n        aInst = &pCsr->aInst[3 * (nInst-1)];\n        aInst[0] = iBest;\n        aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);\n        aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);\n        sqlite3Fts5PoslistReaderNext(&aIter[iBest]);\n      }\n    }\n\n    pCsr->nInstCount = nInst;\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_INST);\n  }\n  return rc;\n}\n\nstatic int fts5ApiInstCount(Fts5Context *pCtx, int *pnInst){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) ){\n    *pnInst = pCsr->nInstCount;\n  }\n  return rc;\n}\n\nstatic int fts5ApiInst(\n  Fts5Context *pCtx, \n  int iIdx, \n  int *piPhrase, \n  int *piCol, \n  int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) \n  ){\n    if( iIdx<0 || iIdx>=pCsr->nInstCount ){\n      rc = SQLITE_RANGE;\n#if 0\n    }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 2];\n      *piOff = -1;\n#endif\n    }else{\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 1];\n      *piOff = pCsr->aInst[iIdx*3 + 2];\n    }\n  }\n  return rc;\n}\n\nstatic sqlite3_int64 fts5ApiRowid(Fts5Context *pCtx){\n  return fts5CursorRowid((Fts5Cursor*)pCtx);\n}\n\nstatic int fts5ColumnSizeCb(\n  void *pContext,                 /* Pointer to int */\n  int tflags,\n  const char *pUnused,            /* Buffer containing token */\n  int nUnused,                    /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int *pCnt = (int*)pContext;\n  UNUSED_PARAM2(pUnused, nUnused);\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    (*pCnt)++;\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){\n    if( pConfig->bColumnsize ){\n      i64 iRowid = fts5CursorRowid(pCsr);\n      rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);\n    }else if( pConfig->zContent==0 ){\n      int i;\n      for(i=0; i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          pCsr->aColumnSize[i] = -1;\n        }\n      }\n    }else{\n      int i;\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          const char *z; int n;\n          void *p = (void*)(&pCsr->aColumnSize[i]);\n          pCsr->aColumnSize[i] = 0;\n          rc = fts5ApiColumnText(pCtx, i, &z, &n);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5Tokenize(\n                pConfig, FTS5_TOKENIZE_AUX, z, n, p, fts5ColumnSizeCb\n            );\n          }\n        }\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_DOCSIZE);\n  }\n  if( iCol<0 ){\n    int i;\n    *pnToken = 0;\n    for(i=0; i<pConfig->nCol; i++){\n      *pnToken += pCsr->aColumnSize[i];\n    }\n  }else if( iCol<pConfig->nCol ){\n    *pnToken = pCsr->aColumnSize[iCol];\n  }else{\n    *pnToken = 0;\n    rc = SQLITE_RANGE;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the xSetAuxdata() method.\n*/\nstatic int fts5ApiSetAuxdata(\n  Fts5Context *pCtx,              /* Fts5 context */\n  void *pPtr,                     /* Pointer to save as auxdata */\n  void(*xDelete)(void*)           /* Destructor for pPtr (or NULL) */\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n\n  /* Search through the cursors list of Fts5Auxdata objects for one that\n  ** corresponds to the currently executing auxiliary function.  */\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    if( pData->xDelete ){\n      pData->xDelete(pData->pPtr);\n    }\n  }else{\n    int rc = SQLITE_OK;\n    pData = (Fts5Auxdata*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Auxdata));\n    if( pData==0 ){\n      if( xDelete ) xDelete(pPtr);\n      return rc;\n    }\n    pData->pAux = pCsr->pAux;\n    pData->pNext = pCsr->pAuxdata;\n    pCsr->pAuxdata = pData;\n  }\n\n  pData->xDelete = xDelete;\n  pData->pPtr = pPtr;\n  return SQLITE_OK;\n}\n\nstatic void *fts5ApiGetAuxdata(Fts5Context *pCtx, int bClear){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n  void *pRet = 0;\n\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    pRet = pData->pPtr;\n    if( bClear ){\n      pData->pPtr = 0;\n      pData->xDelete = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic void fts5ApiPhraseNext(\n  Fts5Context *pUnused, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  UNUSED_PARAM(pUnused);\n  if( pIter->a>=pIter->b ){\n    *piCol = -1;\n    *piOff = -1;\n  }else{\n    int iVal;\n    pIter->a += fts5GetVarint32(pIter->a, iVal);\n    if( iVal==1 ){\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n      *piCol = iVal;\n      *piOff = 0;\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n    }\n    *piOff += (iVal-2);\n  }\n}\n\nstatic int fts5ApiPhraseFirst(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int n;\n  int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n  if( rc==SQLITE_OK ){\n    pIter->b = &pIter->a[n];\n    *piCol = 0;\n    *piOff = 0;\n    fts5ApiPhraseNext(pCtx, pIter, piCol, piOff);\n  }\n  return rc;\n}\n\nstatic void fts5ApiPhraseNextColumn(\n  Fts5Context *pCtx, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    if( pIter->a>=pIter->b ){\n      *piCol = -1;\n    }else{\n      int iIncr;\n      pIter->a += fts5GetVarint32(&pIter->a[0], iIncr);\n      *piCol += (iIncr-2);\n    }\n  }else{\n    while( 1 ){\n      int dummy;\n      if( pIter->a>=pIter->b ){\n        *piCol = -1;\n        return;\n      }\n      if( pIter->a[0]==0x01 ) break;\n      pIter->a += fts5GetVarint32(pIter->a, dummy);\n    }\n    pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n  }\n}\n\nstatic int fts5ApiPhraseFirstColumn(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int n;\n    if( pSorter ){\n      int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n      n = pSorter->aIdx[iPhrase] - i1;\n      pIter->a = &pSorter->aPoslist[i1];\n    }else{\n      rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);\n    }\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      *piCol = 0;\n      fts5ApiPhraseNextColumn(pCtx, pIter, piCol);\n    }\n  }else{\n    int n;\n    rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      if( n<=0 ){\n        *piCol = -1;\n      }else if( pIter->a[0]==0x01 ){\n        pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n      }else{\n        *piCol = 0;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ApiQueryPhrase(Fts5Context*, int, void*, \n    int(*)(const Fts5ExtensionApi*, Fts5Context*, void*)\n);\n\nstatic const Fts5ExtensionApi sFts5Api = {\n  2,                            /* iVersion */\n  fts5ApiUserData,\n  fts5ApiColumnCount,\n  fts5ApiRowCount,\n  fts5ApiColumnTotalSize,\n  fts5ApiTokenize,\n  fts5ApiPhraseCount,\n  fts5ApiPhraseSize,\n  fts5ApiInstCount,\n  fts5ApiInst,\n  fts5ApiRowid,\n  fts5ApiColumnText,\n  fts5ApiColumnSize,\n  fts5ApiQueryPhrase,\n  fts5ApiSetAuxdata,\n  fts5ApiGetAuxdata,\n  fts5ApiPhraseFirst,\n  fts5ApiPhraseNext,\n  fts5ApiPhraseFirstColumn,\n  fts5ApiPhraseNextColumn,\n};\n\n/*\n** Implementation of API function xQueryPhrase().\n*/\nstatic int fts5ApiQueryPhrase(\n  Fts5Context *pCtx, \n  int iPhrase, \n  void *pUserData,\n  int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  int rc;\n  Fts5Cursor *pNew = 0;\n\n  rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);\n  if( rc==SQLITE_OK ){\n    pNew->ePlan = FTS5_PLAN_MATCH;\n    pNew->iFirstRowid = SMALLEST_INT64;\n    pNew->iLastRowid = LARGEST_INT64;\n    pNew->base.pVtab = (sqlite3_vtab*)pTab;\n    rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);\n  }\n\n  if( rc==SQLITE_OK ){\n    for(rc = fts5CursorFirst(pTab, pNew, 0);\n        rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;\n        rc = fts5NextMethod((sqlite3_vtab_cursor*)pNew)\n    ){\n      rc = xCallback(&sFts5Api, (Fts5Context*)pNew, pUserData);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        break;\n      }\n    }\n  }\n\n  fts5CloseMethod((sqlite3_vtab_cursor*)pNew);\n  return rc;\n}\n\nstatic void fts5ApiInvoke(\n  Fts5Auxiliary *pAux,\n  Fts5Cursor *pCsr,\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( pCsr->pAux==0 );\n  pCsr->pAux = pAux;\n  pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv);\n  pCsr->pAux = 0;\n}\n\nstatic Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){\n  Fts5Cursor *pCsr;\n  for(pCsr=pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->iCsrId==iCsrId ) break;\n  }\n  return pCsr;\n}\n\nstatic void fts5ApiCallback(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n\n  Fts5Auxiliary *pAux;\n  Fts5Cursor *pCsr;\n  i64 iCsrId;\n\n  assert( argc>=1 );\n  pAux = (Fts5Auxiliary*)sqlite3_user_data(context);\n  iCsrId = sqlite3_value_int64(argv[0]);\n\n  pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);\n  if( pCsr==0 ){\n    char *zErr = sqlite3_mprintf(\"no such cursor: %lld\", iCsrId);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n  }else{\n    fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);\n  }\n}\n\n\n/*\n** Given cursor id iId, return a pointer to the corresponding Fts5Index \n** object. Or NULL If the cursor id does not exist.\n**\n** If successful, set *ppConfig to point to the associated config object \n** before returning.\n*/\nFts5Index *sqlite3Fts5IndexFromCsrid(\n  Fts5Global *pGlobal,            /* FTS5 global context for db handle */\n  i64 iCsrId,                     /* Id of cursor to find */\n  Fts5Config **ppConfig           /* OUT: Configuration object */\n){\n  Fts5Cursor *pCsr;\n  Fts5Table *pTab;\n\n  pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);\n  pTab = (Fts5Table*)pCsr->base.pVtab;\n  *ppConfig = pTab->pConfig;\n\n  return pTab->pIndex;\n}\n\n/*\n** Return a \"position-list blob\" corresponding to the current position of\n** cursor pCsr via sqlite3_result_blob(). A position-list blob contains\n** the current position-list for each phrase in the query associated with\n** cursor pCsr.\n**\n** A position-list blob begins with (nPhrase-1) varints, where nPhrase is\n** the number of phrases in the query. Following the varints are the\n** concatenated position lists for each phrase, in order.\n**\n** The first varint (if it exists) contains the size of the position list\n** for phrase 0. The second (same disclaimer) contains the size of position\n** list 1. And so on. There is no size field for the final position list,\n** as it can be derived from the total size of the blob.\n*/\nstatic int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){\n  int i;\n  int rc = SQLITE_OK;\n  int nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  Fts5Buffer val;\n\n  memset(&val, 0, sizeof(Fts5Buffer));\n  switch( ((Fts5Table*)(pCsr->base.pVtab))->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n\n      /* Append the varints */\n      for(i=0; i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        nPoslist = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &pPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n\n      /* Append the varints */\n      for(i=0; rc==SQLITE_OK && i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &pPoslist, &nPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    default:\n      break;\n  }\n\n  sqlite3_result_blob(pCtx, val.p, val.n, sqlite3_free);\n  return rc;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n*/\nstatic int fts5ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n\n  if( pCsr->ePlan==FTS5_PLAN_SPECIAL ){\n    if( iCol==pConfig->nCol ){\n      sqlite3_result_int64(pCtx, pCsr->iSpecial);\n    }\n  }else\n\n  if( iCol==pConfig->nCol ){\n    /* User is requesting the value of the special column with the same name\n    ** as the table. Return the cursor integer id number. This value is only\n    ** useful in that it may be passed as the first argument to an FTS5\n    ** auxiliary function.  */\n    sqlite3_result_int64(pCtx, pCsr->iCsrId);\n  }else if( iCol==pConfig->nCol+1 ){\n\n    /* The value of the \"rank\" column. */\n    if( pCsr->ePlan==FTS5_PLAN_SOURCE ){\n      fts5PoslistBlob(pCtx, pCsr);\n    }else if( \n        pCsr->ePlan==FTS5_PLAN_MATCH\n     || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH\n    ){\n      if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){\n        fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);\n      }\n    }\n  }else if( !fts5IsContentless(pTab) ){\n    rc = fts5SeekCursor(pCsr, 1);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n    }\n  }\n  return rc;\n}\n\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts5FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nUnused,                    /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* OUT: User data for *pxFunc */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  Fts5Auxiliary *pAux;\n\n  UNUSED_PARAM(nUnused);\n  pAux = fts5FindAuxiliary(pTab, zName);\n  if( pAux ){\n    *pxFunc = fts5ApiCallback;\n    *ppArg = (void*)pAux;\n    return 1;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS5 xRename method. Rename an fts5 table.\n*/\nstatic int fts5RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  return sqlite3Fts5StorageRename(pTab->pStorage, zName);\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageSync(pTab->pStorage);\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageSync(pTab->pStorage);\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageRollback(pTab->pStorage);\n}\n\n/*\n** Register a new auxiliary function with global context pGlobal.\n*/\nstatic int fts5CreateAux(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_extension_function xFunc,  /* Aux. function implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  int rc = sqlite3_overload_function(pGlobal->db, zName, -1);\n  if( rc==SQLITE_OK ){\n    Fts5Auxiliary *pAux;\n    int nName;                      /* Size of zName in bytes, including \\0 */\n    int nByte;                      /* Bytes of space to allocate */\n\n    nName = (int)strlen(zName) + 1;\n    nByte = sizeof(Fts5Auxiliary) + nName;\n    pAux = (Fts5Auxiliary*)sqlite3_malloc(nByte);\n    if( pAux ){\n      memset(pAux, 0, nByte);\n      pAux->zFunc = (char*)&pAux[1];\n      memcpy(pAux->zFunc, zName, nName);\n      pAux->pGlobal = pGlobal;\n      pAux->pUserData = pUserData;\n      pAux->xFunc = xFunc;\n      pAux->xDestroy = xDestroy;\n      pAux->pNext = pGlobal->pAux;\n      pGlobal->pAux = pAux;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Register a new tokenizer. This is the implementation of the \n** fts5_api.xCreateTokenizer() method.\n*/\nstatic int fts5CreateTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_tokenizer *pTokenizer,     /* Tokenizer implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  Fts5TokenizerModule *pNew;\n  int nName;                      /* Size of zName and its \\0 terminator */\n  int nByte;                      /* Bytes of space to allocate */\n  int rc = SQLITE_OK;\n\n  nName = (int)strlen(zName) + 1;\n  nByte = sizeof(Fts5TokenizerModule) + nName;\n  pNew = (Fts5TokenizerModule*)sqlite3_malloc(nByte);\n  if( pNew ){\n    memset(pNew, 0, nByte);\n    pNew->zName = (char*)&pNew[1];\n    memcpy(pNew->zName, zName, nName);\n    pNew->pUserData = pUserData;\n    pNew->x = *pTokenizer;\n    pNew->xDestroy = xDestroy;\n    pNew->pNext = pGlobal->pTok;\n    pGlobal->pTok = pNew;\n    if( pNew->pNext==0 ){\n      pGlobal->pDfltTok = pNew;\n    }\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\nstatic Fts5TokenizerModule *fts5LocateTokenizer(\n  Fts5Global *pGlobal, \n  const char *zName\n){\n  Fts5TokenizerModule *pMod = 0;\n\n  if( zName==0 ){\n    pMod = pGlobal->pDfltTok;\n  }else{\n    for(pMod=pGlobal->pTok; pMod; pMod=pMod->pNext){\n      if( sqlite3_stricmp(zName, pMod->zName)==0 ) break;\n    }\n  }\n\n  return pMod;\n}\n\n/*\n** Find a tokenizer. This is the implementation of the \n** fts5_api.xFindTokenizer() method.\n*/\nstatic int fts5FindTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void **ppUserData,\n  fts5_tokenizer *pTokenizer      /* Populate this object */\n){\n  int rc = SQLITE_OK;\n  Fts5TokenizerModule *pMod;\n\n  pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName);\n  if( pMod ){\n    *pTokenizer = pMod->x;\n    *ppUserData = pMod->pUserData;\n  }else{\n    memset(pTokenizer, 0, sizeof(fts5_tokenizer));\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\nint sqlite3Fts5GetTokenizer(\n  Fts5Global *pGlobal, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer **ppTok,\n  fts5_tokenizer **ppTokApi,\n  char **pzErr\n){\n  Fts5TokenizerModule *pMod;\n  int rc = SQLITE_OK;\n\n  pMod = fts5LocateTokenizer(pGlobal, nArg==0 ? 0 : azArg[0]);\n  if( pMod==0 ){\n    assert( nArg>0 );\n    rc = SQLITE_ERROR;\n    *pzErr = sqlite3_mprintf(\"no such tokenizer: %s\", azArg[0]);\n  }else{\n    rc = pMod->x.xCreate(pMod->pUserData, &azArg[1], (nArg?nArg-1:0), ppTok);\n    *ppTokApi = &pMod->x;\n    if( rc!=SQLITE_OK && pzErr ){\n      *pzErr = sqlite3_mprintf(\"error in tokenizer constructor\");\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *ppTokApi = 0;\n    *ppTok = 0;\n  }\n\n  return rc;\n}\n\nstatic void fts5ModuleDestroy(void *pCtx){\n  Fts5TokenizerModule *pTok, *pNextTok;\n  Fts5Auxiliary *pAux, *pNextAux;\n  Fts5Global *pGlobal = (Fts5Global*)pCtx;\n\n  for(pAux=pGlobal->pAux; pAux; pAux=pNextAux){\n    pNextAux = pAux->pNext;\n    if( pAux->xDestroy ) pAux->xDestroy(pAux->pUserData);\n    sqlite3_free(pAux);\n  }\n\n  for(pTok=pGlobal->pTok; pTok; pTok=pNextTok){\n    pNextTok = pTok->pNext;\n    if( pTok->xDestroy ) pTok->xDestroy(pTok->pUserData);\n    sqlite3_free(pTok);\n  }\n\n  sqlite3_free(pGlobal);\n}\n\nstatic void fts5Fts5Func(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apArg           /* Function arguments */\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  fts5_api **ppApi;\n  UNUSED_PARAM(nArg);\n  assert( nArg==1 );\n  ppApi = (fts5_api**)sqlite3_value_pointer(apArg[0], \"fts5_api_ptr\");\n  if( ppApi ) *ppApi = &pGlobal->api;\n}\n\n/*\n** Implementation of fts5_source_id() function.\n*/\nstatic void fts5SourceIdFunc(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apUnused        /* Function arguments */\n){\n  assert( nArg==0 );\n  UNUSED_PARAM2(nArg, apUnused);\n  sqlite3_result_text(pCtx, \"--FTS5-SOURCE-ID--\", -1, SQLITE_TRANSIENT);\n}\n\nstatic int fts5Init(sqlite3 *db){\n  static const sqlite3_module fts5Mod = {\n    /* iVersion      */ 2,\n    /* xCreate       */ fts5CreateMethod,\n    /* xConnect      */ fts5ConnectMethod,\n    /* xBestIndex    */ fts5BestIndexMethod,\n    /* xDisconnect   */ fts5DisconnectMethod,\n    /* xDestroy      */ fts5DestroyMethod,\n    /* xOpen         */ fts5OpenMethod,\n    /* xClose        */ fts5CloseMethod,\n    /* xFilter       */ fts5FilterMethod,\n    /* xNext         */ fts5NextMethod,\n    /* xEof          */ fts5EofMethod,\n    /* xColumn       */ fts5ColumnMethod,\n    /* xRowid        */ fts5RowidMethod,\n    /* xUpdate       */ fts5UpdateMethod,\n    /* xBegin        */ fts5BeginMethod,\n    /* xSync         */ fts5SyncMethod,\n    /* xCommit       */ fts5CommitMethod,\n    /* xRollback     */ fts5RollbackMethod,\n    /* xFindFunction */ fts5FindFunctionMethod,\n    /* xRename       */ fts5RenameMethod,\n    /* xSavepoint    */ fts5SavepointMethod,\n    /* xRelease      */ fts5ReleaseMethod,\n    /* xRollbackTo   */ fts5RollbackToMethod,\n  };\n\n  int rc;\n  Fts5Global *pGlobal = 0;\n\n  pGlobal = (Fts5Global*)sqlite3_malloc(sizeof(Fts5Global));\n  if( pGlobal==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    void *p = (void*)pGlobal;\n    memset(pGlobal, 0, sizeof(Fts5Global));\n    pGlobal->db = db;\n    pGlobal->api.iVersion = 2;\n    pGlobal->api.xCreateFunction = fts5CreateAux;\n    pGlobal->api.xCreateTokenizer = fts5CreateTokenizer;\n    pGlobal->api.xFindTokenizer = fts5FindTokenizer;\n    rc = sqlite3_create_module_v2(db, \"fts5\", &fts5Mod, p, fts5ModuleDestroy);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5IndexInit(db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5ExprInit(pGlobal, db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5\", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5_source_id\", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0\n      );\n    }\n  }\n\n  /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file\n  ** fts5_test_mi.c is compiled and linked into the executable. And call\n  ** its entry point to enable the matchinfo() demo.  */\n#ifdef SQLITE_FTS5_ENABLE_TEST_MI\n  if( rc==SQLITE_OK ){\n    extern int sqlite3Fts5TestRegisterMatchinfo(sqlite3*);\n    rc = sqlite3Fts5TestRegisterMatchinfo(db);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** The following functions are used to register the module with SQLite. If\n** this module is being built as part of the SQLite core (SQLITE_CORE is\n** defined), then sqlite3_open() will call sqlite3Fts5Init() directly.\n**\n** Or, if this module is being built as a loadable extension, \n** sqlite3Fts5Init() is omitted and the two standard entry points\n** sqlite3_fts_init() and sqlite3_fts5_init() defined instead.\n*/\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fts_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fts5_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n#else\nint sqlite3Fts5Init(sqlite3 *db){\n  return fts5Init(db);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_storage.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n#include \"fts5Int.h\"\n\nstruct Fts5Storage {\n  Fts5Config *pConfig;\n  Fts5Index *pIndex;\n  int bTotalsValid;               /* True if nTotalRow/aTotalSize[] are valid */\n  i64 nTotalRow;                  /* Total number of rows in FTS table */\n  i64 *aTotalSize;                /* Total sizes of each column */ \n  sqlite3_stmt *aStmt[11];\n};\n\n\n#if FTS5_STMT_SCAN_ASC!=0 \n# error \"FTS5_STMT_SCAN_ASC mismatch\" \n#endif\n#if FTS5_STMT_SCAN_DESC!=1 \n# error \"FTS5_STMT_SCAN_DESC mismatch\" \n#endif\n#if FTS5_STMT_LOOKUP!=2\n# error \"FTS5_STMT_LOOKUP mismatch\" \n#endif\n\n#define FTS5_STMT_INSERT_CONTENT  3\n#define FTS5_STMT_REPLACE_CONTENT 4\n#define FTS5_STMT_DELETE_CONTENT  5\n#define FTS5_STMT_REPLACE_DOCSIZE  6\n#define FTS5_STMT_DELETE_DOCSIZE  7\n#define FTS5_STMT_LOOKUP_DOCSIZE  8\n#define FTS5_STMT_REPLACE_CONFIG 9\n#define FTS5_STMT_SCAN 10\n\n/*\n** Prepare the two insert statements - Fts5Storage.pInsertContent and\n** Fts5Storage.pInsertDocsize - if they have not already been prepared.\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageGetStmt(\n  Fts5Storage *p,                 /* Storage handle */\n  int eStmt,                      /* FTS5_STMT_XXX constant */\n  sqlite3_stmt **ppStmt,          /* OUT: Prepared statement handle */\n  char **pzErrMsg                 /* OUT: Error message (if any) */\n){\n  int rc = SQLITE_OK;\n\n  /* If there is no %_docsize table, there should be no requests for \n  ** statements to operate on it.  */\n  assert( p->pConfig->bColumnsize || (\n        eStmt!=FTS5_STMT_REPLACE_DOCSIZE \n     && eStmt!=FTS5_STMT_DELETE_DOCSIZE \n     && eStmt!=FTS5_STMT_LOOKUP_DOCSIZE \n  ));\n\n  assert( eStmt>=0 && eStmt<ArraySize(p->aStmt) );\n  if( p->aStmt[eStmt]==0 ){\n    const char *azStmt[] = {\n      \"SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\",\n      \"SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\",\n      \"SELECT %s FROM %s T WHERE T.%Q=?\",               /* LOOKUP  */\n\n      \"INSERT INTO %Q.'%q_content' VALUES(%s)\",         /* INSERT_CONTENT  */\n      \"REPLACE INTO %Q.'%q_content' VALUES(%s)\",        /* REPLACE_CONTENT */\n      \"DELETE FROM %Q.'%q_content' WHERE id=?\",         /* DELETE_CONTENT  */\n      \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",       /* REPLACE_DOCSIZE  */\n      \"DELETE FROM %Q.'%q_docsize' WHERE id=?\",         /* DELETE_DOCSIZE  */\n\n      \"SELECT sz FROM %Q.'%q_docsize' WHERE id=?\",      /* LOOKUP_DOCSIZE  */\n\n      \"REPLACE INTO %Q.'%q_config' VALUES(?,?)\",        /* REPLACE_CONFIG */\n      \"SELECT %s FROM %s AS T\",                         /* SCAN */\n    };\n    Fts5Config *pC = p->pConfig;\n    char *zSql = 0;\n\n    switch( eStmt ){\n      case FTS5_STMT_SCAN:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent\n        );\n        break;\n\n      case FTS5_STMT_SCAN_ASC:\n      case FTS5_STMT_SCAN_DESC:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zContentExprlist, \n            pC->zContent, pC->zContentRowid, pC->zContentRowid,\n            pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_LOOKUP:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent, pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_INSERT_CONTENT: \n      case FTS5_STMT_REPLACE_CONTENT: {\n        int nCol = pC->nCol + 1;\n        char *zBind;\n        int i;\n\n        zBind = sqlite3_malloc(1 + nCol*2);\n        if( zBind ){\n          for(i=0; i<nCol; i++){\n            zBind[i*2] = '?';\n            zBind[i*2 + 1] = ',';\n          }\n          zBind[i*2-1] = '\\0';\n          zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);\n          sqlite3_free(zBind);\n        }\n        break;\n      }\n\n      default:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName);\n        break;\n    }\n\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(pC->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);\n      sqlite3_free(zSql);\n      if( rc!=SQLITE_OK && pzErrMsg ){\n        *pzErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pC->db));\n      }\n    }\n  }\n\n  *ppStmt = p->aStmt[eStmt];\n  sqlite3_reset(*ppStmt);\n  return rc;\n}\n\n\nstatic int fts5ExecPrintf(\n  sqlite3 *db,\n  char **pzErr,\n  const char *zFormat,\n  ...\n){\n  int rc;\n  va_list ap;                     /* ... printf arguments */\n  char *zSql;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_exec(db, zSql, 0, 0, pzErr);\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error\n** code otherwise.\n*/\nint sqlite3Fts5DropAll(Fts5Config *pConfig){\n  int rc = fts5ExecPrintf(pConfig->db, 0, \n      \"DROP TABLE IF EXISTS %Q.'%q_data';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_idx';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_config';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_content';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  return rc;\n}\n\nstatic void fts5StorageRenameOne(\n  Fts5Config *pConfig,            /* Current FTS5 configuration */\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zTail,              /* Tail of table name e.g. \"data\", \"config\" */\n  const char *zName               /* New name of FTS5 table */\n){\n  if( *pRc==SQLITE_OK ){\n    *pRc = fts5ExecPrintf(pConfig->db, 0, \n        \"ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\",\n        pConfig->zDb, pConfig->zName, zTail, zName, zTail\n    );\n  }\n}\n\nint sqlite3Fts5StorageRename(Fts5Storage *pStorage, const char *zName){\n  Fts5Config *pConfig = pStorage->pConfig;\n  int rc = sqlite3Fts5StorageSync(pStorage);\n\n  fts5StorageRenameOne(pConfig, &rc, \"data\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"idx\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"config\", zName);\n  if( pConfig->bColumnsize ){\n    fts5StorageRenameOne(pConfig, &rc, \"docsize\", zName);\n  }\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    fts5StorageRenameOne(pConfig, &rc, \"content\", zName);\n  }\n  return rc;\n}\n\n/*\n** Create the shadow table named zPost, with definition zDefn. Return\n** SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nint sqlite3Fts5CreateTable(\n  Fts5Config *pConfig,            /* FTS5 configuration */\n  const char *zPost,              /* Shadow table to create (e.g. \"content\") */\n  const char *zDefn,              /* Columns etc. for shadow table */\n  int bWithout,                   /* True for without rowid */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc;\n  char *zErr = 0;\n\n  rc = fts5ExecPrintf(pConfig->db, &zErr, \"CREATE TABLE %Q.'%q_%q'(%s)%s\",\n      pConfig->zDb, pConfig->zName, zPost, zDefn, \n#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID\n      bWithout?\" WITHOUT ROWID\":\n#endif\n      \"\"\n  );\n  if( zErr ){\n    *pzErr = sqlite3_mprintf(\n        \"fts5: error creating shadow table %q_%s: %s\", \n        pConfig->zName, zPost, zErr\n    );\n    sqlite3_free(zErr);\n  }\n\n  return rc;\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying tables \n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nint sqlite3Fts5StorageOpen(\n  Fts5Config *pConfig, \n  Fts5Index *pIndex, \n  int bCreate, \n  Fts5Storage **pp,\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  Fts5Storage *p;                 /* New object */\n  int nByte;                      /* Bytes of space to allocate */\n\n  nByte = sizeof(Fts5Storage)               /* Fts5Storage object */\n        + pConfig->nCol * sizeof(i64);      /* Fts5Storage.aTotalSize[] */\n  *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n\n  memset(p, 0, nByte);\n  p->aTotalSize = (i64*)&p[1];\n  p->pConfig = pConfig;\n  p->pIndex = pIndex;\n\n  if( bCreate ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      int nDefn = 32 + pConfig->nCol*10;\n      char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);\n      if( zDefn==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        int i;\n        int iOff;\n        sqlite3_snprintf(nDefn, zDefn, \"id INTEGER PRIMARY KEY\");\n        iOff = (int)strlen(zDefn);\n        for(i=0; i<pConfig->nCol; i++){\n          sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], \", c%d\", i);\n          iOff += (int)strlen(&zDefn[iOff]);\n        }\n        rc = sqlite3Fts5CreateTable(pConfig, \"content\", zDefn, 0, pzErr);\n      }\n      sqlite3_free(zDefn);\n    }\n\n    if( rc==SQLITE_OK && pConfig->bColumnsize ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"docsize\", \"id INTEGER PRIMARY KEY, sz BLOB\", 0, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"config\", \"k PRIMARY KEY, v\", 1, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n    }\n  }\n\n  if( rc ){\n    sqlite3Fts5StorageClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5StorageOpen().\n*/\nint sqlite3Fts5StorageClose(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;\n\n    /* Finalize all SQL statements */\n    for(i=0; i<ArraySize(p->aStmt); i++){\n      sqlite3_finalize(p->aStmt[i]);\n    }\n\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\ntypedef struct Fts5InsertCtx Fts5InsertCtx;\nstruct Fts5InsertCtx {\n  Fts5Storage *pStorage;\n  int iCol;\n  int szCol;                      /* Size of column value in tokens */\n};\n\n/*\n** Tokenization callback used when inserting tokens into the FTS index.\n*/\nstatic int fts5StorageInsertCallback(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;\n  Fts5Index *pIdx = pCtx->pStorage->pIndex;\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n  return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);\n}\n\n/*\n** If a row with rowid iDel is present in the %_content table, add the\n** delete-markers to the FTS index necessary to delete it. Do not actually\n** remove the %_content row at this time though.\n*/\nstatic int fts5StorageDeleteFromIndex(\n  Fts5Storage *p, \n  i64 iDel, \n  sqlite3_value **apVal\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pSeek = 0;        /* SELECT to read row iDel from %_data */\n  int rc;                         /* Return code */\n  int rc2;                        /* sqlite3_reset() return code */\n  int iCol;\n  Fts5InsertCtx ctx;\n\n  if( apVal==0 ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3_bind_int64(pSeek, 1, iDel);\n    if( sqlite3_step(pSeek)!=SQLITE_ROW ){\n      return sqlite3_reset(pSeek);\n    }\n  }\n\n  ctx.pStorage = p;\n  ctx.iCol = -1;\n  rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);\n  for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){\n    if( pConfig->abUnindexed[iCol-1]==0 ){\n      const char *zText;\n      int nText;\n      if( pSeek ){\n        zText = (const char*)sqlite3_column_text(pSeek, iCol);\n        nText = sqlite3_column_bytes(pSeek, iCol);\n      }else{\n        zText = (const char*)sqlite3_value_text(apVal[iCol-1]);\n        nText = sqlite3_value_bytes(apVal[iCol-1]);\n      }\n      ctx.szCol = 0;\n      rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, \n          zText, nText, (void*)&ctx, fts5StorageInsertCallback\n      );\n      p->aTotalSize[iCol-1] -= (i64)ctx.szCol;\n    }\n  }\n  p->nTotalRow--;\n\n  rc2 = sqlite3_reset(pSeek);\n  if( rc==SQLITE_OK ) rc = rc2;\n  return rc;\n}\n\n\n/*\n** Insert a record into the %_docsize table. Specifically, do:\n**\n**   INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf);\n**\n** If there is no %_docsize table (as happens if the columnsize=0 option\n** is specified when the FTS5 table is created), this function is a no-op.\n*/\nstatic int fts5StorageInsertDocsize(\n  Fts5Storage *p,                 /* Storage module to write to */\n  i64 iRowid,                     /* id value */\n  Fts5Buffer *pBuf                /* sz value */\n){\n  int rc = SQLITE_OK;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pReplace, 1, iRowid);\n      sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n    }\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the \"averages\" record from disk into the \n** p->nTotalRow and p->aTotalSize[] variables. If successful, and if\n** argument bCache is true, set the p->bTotalsValid flag to indicate\n** that the contents of aTotalSize[] and nTotalRow are valid until\n** further notice.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageLoadTotals(Fts5Storage *p, int bCache){\n  int rc = SQLITE_OK;\n  if( p->bTotalsValid==0 ){\n    rc = sqlite3Fts5IndexGetAverages(p->pIndex, &p->nTotalRow, p->aTotalSize);\n    p->bTotalsValid = bCache;\n  }\n  return rc;\n}\n\n/*\n** Store the current contents of the p->nTotalRow and p->aTotalSize[] \n** variables in the \"averages\" record on disk.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageSaveTotals(Fts5Storage *p){\n  int nCol = p->pConfig->nCol;\n  int i;\n  Fts5Buffer buf;\n  int rc = SQLITE_OK;\n  memset(&buf, 0, sizeof(buf));\n\n  sqlite3Fts5BufferAppendVarint(&rc, &buf, p->nTotalRow);\n  for(i=0; i<nCol; i++){\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, p->aTotalSize[i]);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\n/*\n** Remove a row from the FTS table.\n*/\nint sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n  sqlite3_stmt *pDel = 0;\n\n  assert( pConfig->eContent!=FTS5_CONTENT_NORMAL || apVal==0 );\n  rc = fts5StorageLoadTotals(p, 1);\n\n  /* Delete the index records */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageDeleteFromIndex(p, iDel, apVal);\n  }\n\n  /* Delete the %_docsize record */\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  /* Delete the %_content record */\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Delete all entries in the FTS5 index.\n*/\nint sqlite3Fts5StorageDeleteAll(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n\n  /* Delete the contents of the %_data and %_docsize tables. */\n  rc = fts5ExecPrintf(pConfig->db, 0,\n      \"DELETE FROM %Q.'%q_data';\" \n      \"DELETE FROM %Q.'%q_idx';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0,\n        \"DELETE FROM %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n\n  /* Reinitialize the %_data table. This call creates the initial structure\n  ** and averages records.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexReinit(p->pIndex);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n  }\n  return rc;\n}\n\nint sqlite3Fts5StorageRebuild(Fts5Storage *p){\n  Fts5Buffer buf = {0,0,0};\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pScan = 0;\n  Fts5InsertCtx ctx;\n  int rc;\n\n  memset(&ctx, 0, sizeof(Fts5InsertCtx));\n  ctx.pStorage = p;\n  rc = sqlite3Fts5StorageDeleteAll(p);\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageLoadTotals(p, 1);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pScan) ){\n    i64 iRowid = sqlite3_column_int64(pScan, 0);\n\n    sqlite3Fts5BufferZero(&buf);\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n    for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n      ctx.szCol = 0;\n      if( pConfig->abUnindexed[ctx.iCol]==0 ){\n        rc = sqlite3Fts5Tokenize(pConfig, \n            FTS5_TOKENIZE_DOCUMENT,\n            (const char*)sqlite3_column_text(pScan, ctx.iCol+1),\n            sqlite3_column_bytes(pScan, ctx.iCol+1),\n            (void*)&ctx,\n            fts5StorageInsertCallback\n        );\n      }\n      sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n      p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n    }\n    p->nTotalRow++;\n\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n    }\n  }\n  sqlite3_free(buf.p);\n\n  /* Write the averages record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageSaveTotals(p);\n  }\n  return rc;\n}\n\nint sqlite3Fts5StorageOptimize(Fts5Storage *p){\n  return sqlite3Fts5IndexOptimize(p->pIndex);\n}\n\nint sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge){\n  return sqlite3Fts5IndexMerge(p->pIndex, nMerge);\n}\n\nint sqlite3Fts5StorageReset(Fts5Storage *p){\n  return sqlite3Fts5IndexReset(p->pIndex);\n}\n\n/*\n** Allocate a new rowid. This is used for \"external content\" tables when\n** a NULL value is inserted into the rowid column. The new rowid is allocated\n** by inserting a dummy row into the %_docsize table. The dummy will be\n** overwritten later.\n**\n** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In\n** this case the user is required to provide a rowid explicitly.\n*/\nstatic int fts5StorageNewRowid(Fts5Storage *p, i64 *piRowid){\n  int rc = SQLITE_MISMATCH;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pReplace, 1);\n      sqlite3_bind_null(pReplace, 2);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n    }\n    if( rc==SQLITE_OK ){\n      *piRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n    }\n  }\n  return rc;\n}\n\n/*\n** Insert a new row into the FTS content table.\n*/\nint sqlite3Fts5StorageContentInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;\n\n  /* Insert the new row into the %_content table. */\n  if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n    if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){\n      *piRowid = sqlite3_value_int64(apVal[1]);\n    }else{\n      rc = fts5StorageNewRowid(p, piRowid);\n    }\n  }else{\n    sqlite3_stmt *pInsert = 0;    /* Statement to write %_content table */\n    int i;                        /* Counter variable */\n    rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);\n    for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){\n      rc = sqlite3_bind_value(pInsert, i, apVal[i]);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_reset(pInsert);\n    }\n    *piRowid = sqlite3_last_insert_rowid(pConfig->db);\n  }\n\n  return rc;\n}\n\n/*\n** Insert new entries into the FTS index and %_docsize table.\n*/\nint sqlite3Fts5StorageIndexInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 iRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5InsertCtx ctx;              /* Tokenization callback context object */\n  Fts5Buffer buf;                 /* Buffer used to build up %_docsize blob */\n\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  ctx.pStorage = p;\n  rc = fts5StorageLoadTotals(p, 1);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n  }\n  for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n    ctx.szCol = 0;\n    if( pConfig->abUnindexed[ctx.iCol]==0 ){\n      rc = sqlite3Fts5Tokenize(pConfig, \n          FTS5_TOKENIZE_DOCUMENT,\n          (const char*)sqlite3_value_text(apVal[ctx.iCol+2]),\n          sqlite3_value_bytes(apVal[ctx.iCol+2]),\n          (void*)&ctx,\n          fts5StorageInsertCallback\n      );\n    }\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n    p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n  }\n  p->nTotalRow++;\n\n  /* Write the %_docsize record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\nstatic int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){\n  Fts5Config *pConfig = p->pConfig;\n  char *zSql;\n  int rc;\n\n  zSql = sqlite3_mprintf(\"SELECT count(*) FROM %Q.'%q_%s'\", \n      pConfig->zDb, pConfig->zName, zSuffix\n  );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pCnt = 0;\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pCnt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pCnt) ){\n        *pnRow = sqlite3_column_int64(pCnt, 0);\n      }\n      rc = sqlite3_finalize(pCnt);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/*\n** Context object used by sqlite3Fts5StorageIntegrity().\n*/\ntypedef struct Fts5IntegrityCtx Fts5IntegrityCtx;\nstruct Fts5IntegrityCtx {\n  i64 iRowid;\n  int iCol;\n  int szCol;\n  u64 cksum;\n  Fts5Termset *pTermset;\n  Fts5Config *pConfig;\n};\n\n\n/*\n** Tokenization callback used by integrity check.\n*/\nstatic int fts5StorageIntegrityCallback(\n  void *pContext,                 /* Pointer to Fts5IntegrityCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;\n  Fts5Termset *pTermset = pCtx->pTermset;\n  int bPresent;\n  int ii;\n  int rc = SQLITE_OK;\n  int iPos;\n  int iCol;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n\n  switch( pCtx->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n      iPos = pCtx->szCol-1;\n      iCol = pCtx->iCol;\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n      iPos = pCtx->iCol;\n      iCol = 0;\n      break;\n\n    default:\n      assert( pCtx->pConfig->eDetail==FTS5_DETAIL_NONE );\n      iPos = 0;\n      iCol = 0;\n      break;\n  }\n\n  rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent);\n  if( rc==SQLITE_OK && bPresent==0 ){\n    pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n        pCtx->iRowid, iCol, iPos, 0, pToken, nToken\n    );\n  }\n\n  for(ii=0; rc==SQLITE_OK && ii<pCtx->pConfig->nPrefix; ii++){\n    const int nChar = pCtx->pConfig->aPrefix[ii];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5TermsetAdd(pTermset, ii+1, pToken, nByte, &bPresent);\n      if( bPresent==0 ){\n        pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n            pCtx->iRowid, iCol, iPos, ii+1, pToken, nByte\n        );\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Check that the contents of the FTS index match that of the %_content\n** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return\n** some other SQLite error code if an error occurs while attempting to\n** determine this.\n*/\nint sqlite3Fts5StorageIntegrity(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;                         /* Return code */\n  int *aColSize;                  /* Array of size pConfig->nCol */\n  i64 *aTotalSize;                /* Array of size pConfig->nCol */\n  Fts5IntegrityCtx ctx;\n  sqlite3_stmt *pScan;\n\n  memset(&ctx, 0, sizeof(Fts5IntegrityCtx));\n  ctx.pConfig = p->pConfig;\n  aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));\n  if( !aTotalSize ) return SQLITE_NOMEM;\n  aColSize = (int*)&aTotalSize[pConfig->nCol];\n  memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);\n\n  /* Generate the expected index checksum based on the contents of the\n  ** %_content table. This block stores the checksum in ctx.cksum. */\n  rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    while( SQLITE_ROW==sqlite3_step(pScan) ){\n      int i;\n      ctx.iRowid = sqlite3_column_int64(pScan, 0);\n      ctx.szCol = 0;\n      if( pConfig->bColumnsize ){\n        rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);\n      }\n      if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){\n        rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n      }\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i] ) continue;\n        ctx.iCol = i;\n        ctx.szCol = 0;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5Tokenize(pConfig, \n              FTS5_TOKENIZE_DOCUMENT,\n              (const char*)sqlite3_column_text(pScan, i+1),\n              sqlite3_column_bytes(pScan, i+1),\n              (void*)&ctx,\n              fts5StorageIntegrityCallback\n          );\n        }\n        if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){\n          rc = FTS5_CORRUPT;\n        }\n        aTotalSize[i] += ctx.szCol;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          sqlite3Fts5TermsetFree(ctx.pTermset);\n          ctx.pTermset = 0;\n        }\n      }\n      sqlite3Fts5TermsetFree(ctx.pTermset);\n      ctx.pTermset = 0;\n\n      if( rc!=SQLITE_OK ) break;\n    }\n    rc2 = sqlite3_reset(pScan);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* Test that the \"totals\" (sometimes called \"averages\") record looks Ok */\n  if( rc==SQLITE_OK ){\n    int i;\n    rc = fts5StorageLoadTotals(p, 0);\n    for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n      if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;\n    }\n  }\n\n  /* Check that the %_docsize and %_content tables contain the expected\n  ** number of rows.  */\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"content\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"docsize\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n\n  /* Pass the expected checksum down to the FTS index module. It will\n  ** verify, amongst other things, that it matches the checksum generated by\n  ** inspecting the index itself.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);\n  }\n\n  sqlite3_free(aTotalSize);\n  return rc;\n}\n\n/*\n** Obtain an SQLite statement handle that may be used to read data from the\n** %_content table.\n*/\nint sqlite3Fts5StorageStmt(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt **pp, \n  char **pzErrMsg\n){\n  int rc;\n  assert( eStmt==FTS5_STMT_SCAN_ASC \n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  rc = fts5StorageGetStmt(p, eStmt, pp, pzErrMsg);\n  if( rc==SQLITE_OK ){\n    assert( p->aStmt[eStmt]==*pp );\n    p->aStmt[eStmt] = 0;\n  }\n  return rc;\n}\n\n/*\n** Release an SQLite statement handle obtained via an earlier call to\n** sqlite3Fts5StorageStmt(). The eStmt parameter passed to this function\n** must match that passed to the sqlite3Fts5StorageStmt() call.\n*/\nvoid sqlite3Fts5StorageStmtRelease(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt *pStmt\n){\n  assert( eStmt==FTS5_STMT_SCAN_ASC\n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  if( p->aStmt[eStmt]==0 ){\n    sqlite3_reset(pStmt);\n    p->aStmt[eStmt] = pStmt;\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n}\n\nstatic int fts5StorageDecodeSizeArray(\n  int *aCol, int nCol,            /* Array to populate */\n  const u8 *aBlob, int nBlob      /* Record to read varints from */\n){\n  int i;\n  int iOff = 0;\n  for(i=0; i<nCol; i++){\n    if( iOff>=nBlob ) return 1;\n    iOff += fts5GetVarint32(&aBlob[iOff], aCol[i]);\n  }\n  return (iOff!=nBlob);\n}\n\n/*\n** Argument aCol points to an array of integers containing one entry for\n** each table column. This function reads the %_docsize record for the\n** specified rowid and populates aCol[] with the results.\n**\n** An SQLite error code is returned if an error occurs, or SQLITE_OK\n** otherwise.\n*/\nint sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){\n  int nCol = p->pConfig->nCol;    /* Number of user columns in table */\n  sqlite3_stmt *pLookup = 0;      /* Statement to query %_docsize */\n  int rc;                         /* Return Code */\n\n  assert( p->pConfig->bColumnsize );\n  rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);\n  if( rc==SQLITE_OK ){\n    int bCorrupt = 1;\n    sqlite3_bind_int64(pLookup, 1, iRowid);\n    if( SQLITE_ROW==sqlite3_step(pLookup) ){\n      const u8 *aBlob = sqlite3_column_blob(pLookup, 0);\n      int nBlob = sqlite3_column_bytes(pLookup, 0);\n      if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){\n        bCorrupt = 0;\n      }\n    }\n    rc = sqlite3_reset(pLookup);\n    if( bCorrupt && rc==SQLITE_OK ){\n      rc = FTS5_CORRUPT;\n    }\n  }\n\n  return rc;\n}\n\nint sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnToken){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    *pnToken = 0;\n    if( iCol<0 ){\n      int i;\n      for(i=0; i<p->pConfig->nCol; i++){\n        *pnToken += p->aTotalSize[i];\n      }\n    }else if( iCol<p->pConfig->nCol ){\n      *pnToken = p->aTotalSize[iCol];\n    }else{\n      rc = SQLITE_RANGE;\n    }\n  }\n  return rc;\n}\n\nint sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    *pnRow = p->nTotalRow;\n  }\n  return rc;\n}\n\n/*\n** Flush any data currently held in-memory to disk.\n*/\nint sqlite3Fts5StorageSync(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n  if( p->bTotalsValid ){\n    rc = fts5StorageSaveTotals(p);\n    p->bTotalsValid = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSync(p->pIndex);\n  }\n  sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid);\n  return rc;\n}\n\nint sqlite3Fts5StorageRollback(Fts5Storage *p){\n  p->bTotalsValid = 0;\n  return sqlite3Fts5IndexRollback(p->pIndex);\n}\n\nint sqlite3Fts5StorageConfigValue(\n  Fts5Storage *p, \n  const char *z,\n  sqlite3_value *pVal,\n  int iVal\n){\n  sqlite3_stmt *pReplace = 0;\n  int rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_CONFIG, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_text(pReplace, 1, z, -1, SQLITE_STATIC);\n    if( pVal ){\n      sqlite3_bind_value(pReplace, 2, pVal);\n    }else{\n      sqlite3_bind_int(pReplace, 2, iVal);\n    }\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n  }\n  if( rc==SQLITE_OK && pVal ){\n    int iNew = p->pConfig->iCookie + 1;\n    rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);\n    if( rc==SQLITE_OK ){\n      p->pConfig->iCookie = iNew;\n    }\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_tcl.c",
    "content": "/*\n** 2014 Dec 01\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n#ifdef SQLITE_TEST\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\n#ifdef SQLITE_ENABLE_FTS5\n\n#include \"fts5.h\"\n#include <string.h>\n#include <assert.h>\n\nextern int sqlite3_fts5_may_be_corrupt;\nextern int sqlite3Fts5TestRegisterMatchinfo(sqlite3*);\nextern int sqlite3Fts5TestRegisterTok(sqlite3*, fts5_api*);\n\n/*************************************************************************\n** This is a copy of the first part of the SqliteDb structure in \n** tclsqlite.c.  We need it here so that the get_sqlite_pointer routine\n** can extract the sqlite3* pointer from an existing Tcl SQLite\n** connection.\n*/\n\nextern const char *sqlite3ErrName(int);\n\nstruct SqliteDb {\n  sqlite3 *db;\n};\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nstatic int f5tDbPointer(Tcl_Interp *interp, Tcl_Obj *pObj, sqlite3 **ppDb){\n  struct SqliteDb *p;\n  Tcl_CmdInfo cmdInfo;\n  char *z = Tcl_GetString(pObj);\n  if( Tcl_GetCommandInfo(interp, z, &cmdInfo) ){\n    p = (struct SqliteDb*)cmdInfo.objClientData;\n    *ppDb = p->db;\n    return TCL_OK;\n  }\n  return TCL_ERROR;\n}\n\n/* End of code that accesses the SqliteDb struct.\n**************************************************************************/\n\nstatic int f5tResultToErrorCode(const char *zRes){\n  struct ErrorCode {\n    int rc;\n    const char *zError;\n  } aErr[] = {\n    { SQLITE_DONE,  \"SQLITE_DONE\" },\n    { SQLITE_ERROR, \"SQLITE_ERROR\" },\n    { SQLITE_OK,    \"SQLITE_OK\" },\n    { SQLITE_OK,    \"\" },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aErr)/sizeof(aErr[0]); i++){\n    if( 0==sqlite3_stricmp(zRes, aErr[i].zError) ){\n      return aErr[i].rc;\n    }\n  }\n\n  return SQLITE_ERROR;\n}\n\nstatic int SQLITE_TCLAPI f5tDbAndApi(\n  Tcl_Interp *interp, \n  Tcl_Obj *pObj, \n  sqlite3 **ppDb, \n  fts5_api **ppApi\n){\n  sqlite3 *db = 0;\n  int rc = f5tDbPointer(interp, pObj, &db);\n  if( rc!=TCL_OK ){\n    return TCL_ERROR;\n  }else{\n    sqlite3_stmt *pStmt = 0;\n    fts5_api *pApi = 0;\n\n    rc = sqlite3_prepare_v2(db, \"SELECT fts5(?1)\", -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      Tcl_AppendResult(interp, \"error: \", sqlite3_errmsg(db), 0);\n      return TCL_ERROR;\n    }\n    sqlite3_bind_pointer(pStmt, 1, (void*)&pApi, \"fts5_api_ptr\", 0);\n    sqlite3_step(pStmt);\n\n    if( sqlite3_finalize(pStmt)!=SQLITE_OK ){\n      Tcl_AppendResult(interp, \"error: \", sqlite3_errmsg(db), 0);\n      return TCL_ERROR;\n    }\n\n    *ppDb = db;\n    *ppApi = pApi;\n  }\n\n  return TCL_OK;\n}\n\ntypedef struct F5tFunction F5tFunction;\nstruct F5tFunction {\n  Tcl_Interp *interp;\n  Tcl_Obj *pScript;\n};\n\ntypedef struct F5tApi F5tApi;\nstruct F5tApi {\n  const Fts5ExtensionApi *pApi;\n  Fts5Context *pFts;\n};\n\n/*\n** An object of this type is used with the xSetAuxdata() and xGetAuxdata()\n** API test wrappers. The tcl interface allows a single tcl value to be \n** saved using xSetAuxdata(). Instead of simply storing a pointer to the\n** tcl object, the code in this file wraps it in an sqlite3_malloc'd \n** instance of the following struct so that if the destructor is not \n** correctly invoked it will be reported as an SQLite memory leak.\n*/\ntypedef struct F5tAuxData F5tAuxData;\nstruct F5tAuxData {\n  Tcl_Obj *pObj;\n};\n\nstatic int xTokenizeCb(\n  void *pCtx, \n  int tflags,\n  const char *zToken, int nToken, \n  int iStart, int iEnd\n){\n  F5tFunction *p = (F5tFunction*)pCtx;\n  Tcl_Obj *pEval = Tcl_DuplicateObj(p->pScript);\n  int rc;\n\n  Tcl_IncrRefCount(pEval);\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zToken, nToken));\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewIntObj(iStart));\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewIntObj(iEnd));\n\n  rc = Tcl_EvalObjEx(p->interp, pEval, 0);\n  Tcl_DecrRefCount(pEval);\n  if( rc==TCL_OK ){\n    rc = f5tResultToErrorCode(Tcl_GetStringResult(p->interp));\n  }\n\n  return rc;\n}\n\nstatic int SQLITE_TCLAPI xF5tApi(void*, Tcl_Interp*, int, Tcl_Obj *CONST []);\n\nstatic int xQueryPhraseCb(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts, \n  void *pCtx\n){\n  F5tFunction *p = (F5tFunction*)pCtx;\n  static sqlite3_int64 iCmd = 0;\n  Tcl_Obj *pEval;\n  int rc;\n\n  char zCmd[64];\n  F5tApi sApi;\n\n  sApi.pApi = pApi;\n  sApi.pFts = pFts;\n  sprintf(zCmd, \"f5t_2_%lld\", iCmd++);\n  Tcl_CreateObjCommand(p->interp, zCmd, xF5tApi, &sApi, 0);\n\n  pEval = Tcl_DuplicateObj(p->pScript);\n  Tcl_IncrRefCount(pEval);\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zCmd, -1));\n  rc = Tcl_EvalObjEx(p->interp, pEval, 0);\n  Tcl_DecrRefCount(pEval);\n  Tcl_DeleteCommand(p->interp, zCmd);\n\n  if( rc==TCL_OK ){\n    rc = f5tResultToErrorCode(Tcl_GetStringResult(p->interp));\n  }\n\n  return rc;\n}\n\nstatic void xSetAuxdataDestructor(void *p){\n  F5tAuxData *pData = (F5tAuxData*)p;\n  Tcl_DecrRefCount(pData->pObj);\n  sqlite3_free(pData);\n}\n\n/*\n**      api sub-command...\n**\n** Description...\n*/\nstatic int SQLITE_TCLAPI xF5tApi(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct Sub {\n    const char *zName;\n    int nArg;\n    const char *zMsg;\n  } aSub[] = {\n    { \"xColumnCount\",      0, \"\" },                   /*  0 */\n    { \"xRowCount\",         0, \"\" },                   /*  1 */\n    { \"xColumnTotalSize\",  1, \"COL\" },                /*  2 */\n    { \"xTokenize\",         2, \"TEXT SCRIPT\" },        /*  3 */\n    { \"xPhraseCount\",      0, \"\" },                   /*  4 */\n    { \"xPhraseSize\",       1, \"PHRASE\" },             /*  5 */\n    { \"xInstCount\",        0, \"\" },                   /*  6 */\n    { \"xInst\",             1, \"IDX\" },                /*  7 */\n    { \"xRowid\",            0, \"\" },                   /*  8 */\n    { \"xColumnText\",       1, \"COL\" },                /*  9 */\n    { \"xColumnSize\",       1, \"COL\" },                /* 10 */\n    { \"xQueryPhrase\",      2, \"PHRASE SCRIPT\" },      /* 11 */\n    { \"xSetAuxdata\",       1, \"VALUE\" },              /* 12 */\n    { \"xGetAuxdata\",       1, \"CLEAR\" },              /* 13 */\n    { \"xSetAuxdataInt\",    1, \"INTEGER\" },            /* 14 */\n    { \"xGetAuxdataInt\",    1, \"CLEAR\" },              /* 15 */\n    { \"xPhraseForeach\",    4, \"IPHRASE COLVAR OFFVAR SCRIPT\" }, /* 16 */\n    { \"xPhraseColumnForeach\", 3, \"IPHRASE COLVAR SCRIPT\" }, /* 17 */\n    { 0, 0, 0}\n  };\n\n  int rc;\n  int iSub = 0;\n  F5tApi *p = (F5tApi*)clientData;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUB-COMMAND\");\n    return TCL_ERROR;\n  }\n\n  rc = Tcl_GetIndexFromObjStruct(\n      interp, objv[1], aSub, sizeof(aSub[0]), \"SUB-COMMAND\", 0, &iSub\n  );\n  if( rc!=TCL_OK ) return rc;\n  if( aSub[iSub].nArg!=objc-2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, aSub[iSub].zMsg);\n    return TCL_ERROR;\n  }\n\n#define CASE(i,str) case i: assert( strcmp(aSub[i].zName, str)==0 );\n  switch( iSub ){\n    CASE(0, \"xColumnCount\") {\n      int nCol;\n      nCol = p->pApi->xColumnCount(p->pFts);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(nCol));\n      }\n      break;\n    }\n    CASE(1, \"xRowCount\") {\n      sqlite3_int64 nRow;\n      rc = p->pApi->xRowCount(p->pFts, &nRow);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nRow));\n      }\n      break;\n    }\n    CASE(2, \"xColumnTotalSize\") {\n      int iCol;\n      sqlite3_int64 nSize;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iCol) ) return TCL_ERROR;\n      rc = p->pApi->xColumnTotalSize(p->pFts, iCol, &nSize);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nSize));\n      }\n      break;\n    }\n    CASE(3, \"xTokenize\") {\n      int nText;\n      char *zText = Tcl_GetStringFromObj(objv[2], &nText);\n      F5tFunction ctx;\n      ctx.interp = interp;\n      ctx.pScript = objv[3];\n      rc = p->pApi->xTokenize(p->pFts, zText, nText, &ctx, xTokenizeCb);\n      if( rc==SQLITE_OK ){\n        Tcl_ResetResult(interp);\n      }\n      return rc;\n    }\n    CASE(4, \"xPhraseCount\") {\n      int nPhrase;\n      nPhrase = p->pApi->xPhraseCount(p->pFts);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(nPhrase));\n      }\n      break;\n    }\n    CASE(5, \"xPhraseSize\") {\n      int iPhrase;\n      int sz;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ){\n        return TCL_ERROR;\n      }\n      sz = p->pApi->xPhraseSize(p->pFts, iPhrase);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(sz));\n      }\n      break;\n    }\n    CASE(6, \"xInstCount\") {\n      int nInst;\n      rc = p->pApi->xInstCount(p->pFts, &nInst);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(nInst));\n      }\n      break;\n    }\n    CASE(7, \"xInst\") {\n      int iIdx, ip, ic, io;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iIdx) ){\n        return TCL_ERROR;\n      }\n      rc = p->pApi->xInst(p->pFts, iIdx, &ip, &ic, &io);\n      if( rc==SQLITE_OK ){\n        Tcl_Obj *pList = Tcl_NewObj();\n        Tcl_ListObjAppendElement(interp, pList, Tcl_NewIntObj(ip));\n        Tcl_ListObjAppendElement(interp, pList, Tcl_NewIntObj(ic));\n        Tcl_ListObjAppendElement(interp, pList, Tcl_NewIntObj(io));\n        Tcl_SetObjResult(interp, pList);\n      }\n      break;\n    }\n    CASE(8, \"xRowid\") {\n      sqlite3_int64 iRowid = p->pApi->xRowid(p->pFts);\n      Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iRowid));\n      break;\n    }\n    CASE(9, \"xColumnText\") {\n      const char *z = 0;\n      int n = 0;\n      int iCol;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iCol) ){\n        return TCL_ERROR;\n      }\n      rc = p->pApi->xColumnText(p->pFts, iCol, &z, &n);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewStringObj(z, n));\n      }\n      break;\n    }\n    CASE(10, \"xColumnSize\") {\n      int n = 0;\n      int iCol;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iCol) ){\n        return TCL_ERROR;\n      }\n      rc = p->pApi->xColumnSize(p->pFts, iCol, &n);\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(n));\n      }\n      break;\n    }\n    CASE(11, \"xQueryPhrase\") {\n      int iPhrase;\n      F5tFunction ctx;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ){\n        return TCL_ERROR;\n      }\n      ctx.interp = interp;\n      ctx.pScript = objv[3];\n      rc = p->pApi->xQueryPhrase(p->pFts, iPhrase, &ctx, xQueryPhraseCb);\n      if( rc==SQLITE_OK ){\n        Tcl_ResetResult(interp);\n      }\n      break;\n    }\n    CASE(12, \"xSetAuxdata\") {\n      F5tAuxData *pData = (F5tAuxData*)sqlite3_malloc(sizeof(F5tAuxData));\n      if( pData==0 ){\n        Tcl_AppendResult(interp, \"out of memory\", 0);\n        return TCL_ERROR;\n      }\n      pData->pObj = objv[2];\n      Tcl_IncrRefCount(pData->pObj);\n      rc = p->pApi->xSetAuxdata(p->pFts, pData, xSetAuxdataDestructor);\n      break;\n    }\n    CASE(13, \"xGetAuxdata\") {\n      F5tAuxData *pData;\n      int bClear;\n      if( Tcl_GetBooleanFromObj(interp, objv[2], &bClear) ){\n        return TCL_ERROR;\n      }\n      pData = (F5tAuxData*)p->pApi->xGetAuxdata(p->pFts, bClear);\n      if( pData==0 ){\n        Tcl_ResetResult(interp);\n      }else{\n        Tcl_SetObjResult(interp, pData->pObj);\n        if( bClear ){\n          xSetAuxdataDestructor((void*)pData);\n        }\n      }\n      break;\n    }\n\n    /* These two - xSetAuxdataInt and xGetAuxdataInt - are similar to the\n    ** xSetAuxdata and xGetAuxdata methods implemented above. The difference\n    ** is that they may only save an integer value as auxiliary data, and\n    ** do not specify a destructor function.  */\n    CASE(14, \"xSetAuxdataInt\") {\n      int iVal;\n      if( Tcl_GetIntFromObj(interp, objv[2], &iVal) ) return TCL_ERROR;\n      rc = p->pApi->xSetAuxdata(p->pFts, (void*)((char*)0 + iVal), 0);\n      break;\n    }\n    CASE(15, \"xGetAuxdataInt\") {\n      int iVal;\n      int bClear;\n      if( Tcl_GetBooleanFromObj(interp, objv[2], &bClear) ) return TCL_ERROR;\n      iVal = ((char*)p->pApi->xGetAuxdata(p->pFts, bClear) - (char*)0);\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal));\n      break;\n    }\n\n    CASE(16, \"xPhraseForeach\") {\n      int iPhrase;\n      int iCol;\n      int iOff;\n      const char *zColvar;\n      const char *zOffvar;\n      Tcl_Obj *pScript = objv[5];\n      Fts5PhraseIter iter;\n\n      if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ) return TCL_ERROR;\n      zColvar = Tcl_GetString(objv[3]);\n      zOffvar = Tcl_GetString(objv[4]);\n\n      rc = p->pApi->xPhraseFirst(p->pFts, iPhrase, &iter, &iCol, &iOff);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n        return TCL_ERROR;\n      }\n      for( ;iCol>=0; p->pApi->xPhraseNext(p->pFts, &iter, &iCol, &iOff) ){\n        Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0);\n        Tcl_SetVar2Ex(interp, zOffvar, 0, Tcl_NewIntObj(iOff), 0);\n        rc = Tcl_EvalObjEx(interp, pScript, 0);\n        if( rc==TCL_CONTINUE ) rc = TCL_OK;\n        if( rc!=TCL_OK ){\n          if( rc==TCL_BREAK ) rc = TCL_OK;\n          break;\n        }\n      }\n\n      break;\n    }\n\n    CASE(17, \"xPhraseColumnForeach\") {\n      int iPhrase;\n      int iCol;\n      const char *zColvar;\n      Tcl_Obj *pScript = objv[4];\n      Fts5PhraseIter iter;\n\n      if( Tcl_GetIntFromObj(interp, objv[2], &iPhrase) ) return TCL_ERROR;\n      zColvar = Tcl_GetString(objv[3]);\n\n      rc = p->pApi->xPhraseFirstColumn(p->pFts, iPhrase, &iter, &iCol);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n        return TCL_ERROR;\n      }\n      for( ; iCol>=0; p->pApi->xPhraseNextColumn(p->pFts, &iter, &iCol)){\n        Tcl_SetVar2Ex(interp, zColvar, 0, Tcl_NewIntObj(iCol), 0);\n        rc = Tcl_EvalObjEx(interp, pScript, 0);\n        if( rc==TCL_CONTINUE ) rc = TCL_OK;\n        if( rc!=TCL_OK ){\n          if( rc==TCL_BREAK ) rc = TCL_OK;\n          break;\n        }\n      }\n\n      break;\n    }\n\n    default: \n      assert( 0 );\n      break;\n  }\n#undef CASE\n\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\nstatic void xF5tFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  F5tFunction *p = (F5tFunction*)pApi->xUserData(pFts);\n  Tcl_Obj *pEval;                 /* Script to evaluate */\n  int i;\n  int rc;\n\n  static sqlite3_int64 iCmd = 0;\n  char zCmd[64];\n  F5tApi sApi;\n  sApi.pApi = pApi;\n  sApi.pFts = pFts;\n\n  sprintf(zCmd, \"f5t_%lld\", iCmd++);\n  Tcl_CreateObjCommand(p->interp, zCmd, xF5tApi, &sApi, 0);\n  pEval = Tcl_DuplicateObj(p->pScript);\n  Tcl_IncrRefCount(pEval);\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zCmd, -1));\n\n  for(i=0; i<nVal; i++){\n    Tcl_Obj *pObj = 0;\n    switch( sqlite3_value_type(apVal[i]) ){\n      case SQLITE_TEXT:\n        pObj = Tcl_NewStringObj((const char*)sqlite3_value_text(apVal[i]), -1);\n        break;\n      case SQLITE_BLOB:\n        pObj = Tcl_NewByteArrayObj(\n            sqlite3_value_blob(apVal[i]), sqlite3_value_bytes(apVal[i])\n        );\n        break;\n      case SQLITE_INTEGER:\n        pObj = Tcl_NewWideIntObj(sqlite3_value_int64(apVal[i]));\n        break;\n      case SQLITE_FLOAT:\n        pObj = Tcl_NewDoubleObj(sqlite3_value_double(apVal[i]));\n        break;\n      default:\n        pObj = Tcl_NewObj();\n        break;\n    }\n    Tcl_ListObjAppendElement(p->interp, pEval, pObj);\n  }\n\n  rc = Tcl_EvalObjEx(p->interp, pEval, TCL_GLOBAL_ONLY);\n  Tcl_DecrRefCount(pEval);\n  Tcl_DeleteCommand(p->interp, zCmd);\n\n  if( rc!=TCL_OK ){\n    sqlite3_result_error(pCtx, Tcl_GetStringResult(p->interp), -1);\n  }else{\n    Tcl_Obj *pVar = Tcl_GetObjResult(p->interp);\n    int n;\n    const char *zType = (pVar->typePtr ? pVar->typePtr->name : \"\");\n    char c = zType[0];\n    if( c=='b' && strcmp(zType,\"bytearray\")==0 && pVar->bytes==0 ){\n      /* Only return a BLOB type if the Tcl variable is a bytearray and\n      ** has no string representation. */\n      unsigned char *data = Tcl_GetByteArrayFromObj(pVar, &n);\n      sqlite3_result_blob(pCtx, data, n, SQLITE_TRANSIENT);\n    }else if( c=='b' && strcmp(zType,\"boolean\")==0 ){\n      Tcl_GetIntFromObj(0, pVar, &n);\n      sqlite3_result_int(pCtx, n);\n    }else if( c=='d' && strcmp(zType,\"double\")==0 ){\n      double r;\n      Tcl_GetDoubleFromObj(0, pVar, &r);\n      sqlite3_result_double(pCtx, r);\n    }else if( (c=='w' && strcmp(zType,\"wideInt\")==0) ||\n          (c=='i' && strcmp(zType,\"int\")==0) ){\n      Tcl_WideInt v;\n      Tcl_GetWideIntFromObj(0, pVar, &v);\n      sqlite3_result_int64(pCtx, v);\n    }else{\n      unsigned char *data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n);\n      sqlite3_result_text(pCtx, (char *)data, n, SQLITE_TRANSIENT);\n    }\n  }\n}\n\nstatic void xF5tDestroy(void *pCtx){\n  F5tFunction *p = (F5tFunction*)pCtx;\n  Tcl_DecrRefCount(p->pScript);\n  ckfree((char *)p);\n}\n\n/*\n**      sqlite3_fts5_create_function DB NAME SCRIPT\n**\n** Description...\n*/\nstatic int SQLITE_TCLAPI f5tCreateFunction(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char *zName;\n  Tcl_Obj *pScript;\n  sqlite3 *db = 0;\n  fts5_api *pApi = 0;\n  F5tFunction *pCtx = 0;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB NAME SCRIPT\");\n    return TCL_ERROR;\n  }\n  if( f5tDbAndApi(interp, objv[1], &db, &pApi) ) return TCL_ERROR;\n\n  zName = Tcl_GetString(objv[2]);\n  pScript = objv[3];\n  pCtx = (F5tFunction*)ckalloc(sizeof(F5tFunction));\n  pCtx->interp = interp;\n  pCtx->pScript = pScript;\n  Tcl_IncrRefCount(pScript);\n\n  rc = pApi->xCreateFunction(\n      pApi, zName, (void*)pCtx, xF5tFunction, xF5tDestroy\n  );\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, \"error: \", sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\ntypedef struct F5tTokenizeCtx F5tTokenizeCtx;\nstruct F5tTokenizeCtx {\n  Tcl_Obj *pRet;\n  int bSubst;\n  const char *zInput;\n};\n\nstatic int xTokenizeCb2(\n  void *pCtx, \n  int tflags,\n  const char *zToken, int nToken, \n  int iStart, int iEnd\n){\n  F5tTokenizeCtx *p = (F5tTokenizeCtx*)pCtx;\n  if( p->bSubst ){\n    Tcl_ListObjAppendElement(0, p->pRet, Tcl_NewStringObj(zToken, nToken));\n    Tcl_ListObjAppendElement(\n        0, p->pRet, Tcl_NewStringObj(&p->zInput[iStart], iEnd-iStart)\n    );\n  }else{\n    Tcl_ListObjAppendElement(0, p->pRet, Tcl_NewStringObj(zToken, nToken));\n    Tcl_ListObjAppendElement(0, p->pRet, Tcl_NewIntObj(iStart));\n    Tcl_ListObjAppendElement(0, p->pRet, Tcl_NewIntObj(iEnd));\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n**      sqlite3_fts5_tokenize DB TOKENIZER TEXT\n**\n** Description...\n*/\nstatic int SQLITE_TCLAPI f5tTokenize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char *zText;\n  int nText;\n  sqlite3 *db = 0;\n  fts5_api *pApi = 0;\n  Fts5Tokenizer *pTok = 0;\n  fts5_tokenizer tokenizer;\n  Tcl_Obj *pRet = 0;\n  void *pUserdata;\n  int rc;\n\n  int nArg;\n  const char **azArg;\n  F5tTokenizeCtx ctx;\n\n  if( objc!=4 && objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-subst? DB NAME TEXT\");\n    return TCL_ERROR;\n  }\n  if( objc==5 ){\n    char *zOpt = Tcl_GetString(objv[1]);\n    if( strcmp(\"-subst\", zOpt) ){\n      Tcl_AppendResult(interp, \"unrecognized option: \", zOpt, 0);\n      return TCL_ERROR;\n    }\n  }\n  if( f5tDbAndApi(interp, objv[objc-3], &db, &pApi) ) return TCL_ERROR;\n  if( Tcl_SplitList(interp, Tcl_GetString(objv[objc-2]), &nArg, &azArg) ){\n    return TCL_ERROR;\n  }\n  if( nArg==0 ){\n    Tcl_AppendResult(interp, \"no such tokenizer: \", 0);\n    Tcl_Free((void*)azArg);\n    return TCL_ERROR;\n  }\n  zText = Tcl_GetStringFromObj(objv[objc-1], &nText);\n\n  rc = pApi->xFindTokenizer(pApi, azArg[0], &pUserdata, &tokenizer);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, \"no such tokenizer: \", azArg[0], 0);\n    return TCL_ERROR;\n  }\n\n  rc = tokenizer.xCreate(pUserdata, &azArg[1], nArg-1, &pTok);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, \"error in tokenizer.xCreate()\", 0);\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n  ctx.bSubst = (objc==5);\n  ctx.pRet = pRet;\n  ctx.zInput = zText;\n  rc = tokenizer.xTokenize(\n      pTok, (void*)&ctx, FTS5_TOKENIZE_DOCUMENT, zText, nText, xTokenizeCb2\n  );\n  tokenizer.xDelete(pTok);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, \"error in tokenizer.xTokenize()\", 0);\n    Tcl_DecrRefCount(pRet);\n    return TCL_ERROR;\n  }\n\n\n  Tcl_Free((void*)azArg);\n  Tcl_SetObjResult(interp, pRet);\n  Tcl_DecrRefCount(pRet);\n  return TCL_OK;\n}\n\n/*************************************************************************\n** Start of tokenizer wrapper.\n*/\n\ntypedef struct F5tTokenizerContext F5tTokenizerContext;\ntypedef struct F5tTokenizerCb F5tTokenizerCb;\ntypedef struct F5tTokenizerModule F5tTokenizerModule;\ntypedef struct F5tTokenizerInstance F5tTokenizerInstance;\n\nstruct F5tTokenizerContext {\n  void *pCtx;\n  int (*xToken)(void*, int, const char*, int, int, int);\n};\n\nstruct F5tTokenizerModule {\n  Tcl_Interp *interp;\n  Tcl_Obj *pScript;\n  F5tTokenizerContext *pContext;\n};\n\nstruct F5tTokenizerInstance {\n  Tcl_Interp *interp;\n  Tcl_Obj *pScript;\n  F5tTokenizerContext *pContext;\n};\n\nstatic int f5tTokenizerCreate(\n  void *pCtx, \n  const char **azArg, \n  int nArg, \n  Fts5Tokenizer **ppOut\n){\n  F5tTokenizerModule *pMod = (F5tTokenizerModule*)pCtx;\n  Tcl_Obj *pEval;\n  int rc = TCL_OK;\n  int i;\n\n  pEval = Tcl_DuplicateObj(pMod->pScript);\n  Tcl_IncrRefCount(pEval);\n  for(i=0; rc==TCL_OK && i<nArg; i++){\n    Tcl_Obj *pObj = Tcl_NewStringObj(azArg[i], -1);\n    rc = Tcl_ListObjAppendElement(pMod->interp, pEval, pObj);\n  }\n\n  if( rc==TCL_OK ){\n    rc = Tcl_EvalObjEx(pMod->interp, pEval, TCL_GLOBAL_ONLY);\n  }\n  Tcl_DecrRefCount(pEval);\n\n  if( rc==TCL_OK ){\n    F5tTokenizerInstance *pInst;\n    pInst = (F5tTokenizerInstance*)ckalloc(sizeof(F5tTokenizerInstance));\n    memset(pInst, 0, sizeof(F5tTokenizerInstance));\n    pInst->interp = pMod->interp;\n    pInst->pScript = Tcl_GetObjResult(pMod->interp);\n    pInst->pContext = pMod->pContext;\n    Tcl_IncrRefCount(pInst->pScript);\n    *ppOut = (Fts5Tokenizer*)pInst;\n  }\n\n  return rc;\n}\n\n\nstatic void f5tTokenizerDelete(Fts5Tokenizer *p){\n  F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p;\n  Tcl_DecrRefCount(pInst->pScript);\n  ckfree((char *)pInst);\n}\n\nstatic int f5tTokenizerTokenize(\n  Fts5Tokenizer *p, \n  void *pCtx,\n  int flags,\n  const char *pText, int nText, \n  int (*xToken)(void*, int, const char*, int, int, int)\n){\n  F5tTokenizerInstance *pInst = (F5tTokenizerInstance*)p;\n  void *pOldCtx;\n  int (*xOldToken)(void*, int, const char*, int, int, int);\n  Tcl_Obj *pEval;\n  int rc;\n  const char *zFlags;\n\n  pOldCtx = pInst->pContext->pCtx;\n  xOldToken = pInst->pContext->xToken;\n\n  pInst->pContext->pCtx = pCtx;\n  pInst->pContext->xToken = xToken;\n\n  assert( \n      flags==FTS5_TOKENIZE_DOCUMENT\n   || flags==FTS5_TOKENIZE_AUX\n   || flags==FTS5_TOKENIZE_QUERY\n   || flags==(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)\n  );\n  pEval = Tcl_DuplicateObj(pInst->pScript);\n  Tcl_IncrRefCount(pEval);\n  switch( flags ){\n    case FTS5_TOKENIZE_DOCUMENT:\n      zFlags = \"document\";\n      break;\n    case FTS5_TOKENIZE_AUX:\n      zFlags = \"aux\";\n      break;\n    case FTS5_TOKENIZE_QUERY:\n      zFlags = \"query\";\n      break;\n    case (FTS5_TOKENIZE_PREFIX | FTS5_TOKENIZE_QUERY):\n      zFlags = \"prefixquery\";\n      break;\n    default:\n      assert( 0 );\n      zFlags = \"invalid\";\n      break;\n  }\n\n  Tcl_ListObjAppendElement(pInst->interp, pEval, Tcl_NewStringObj(zFlags, -1));\n  Tcl_ListObjAppendElement(pInst->interp, pEval, Tcl_NewStringObj(pText,nText));\n  rc = Tcl_EvalObjEx(pInst->interp, pEval, TCL_GLOBAL_ONLY);\n  Tcl_DecrRefCount(pEval);\n\n  pInst->pContext->pCtx = pOldCtx;\n  pInst->pContext->xToken = xOldToken;\n  return rc;\n}\n\n/*\n** sqlite3_fts5_token ?-colocated? TEXT START END\n*/\nstatic int SQLITE_TCLAPI f5tTokenizerReturn(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  F5tTokenizerContext *p = (F5tTokenizerContext*)clientData;\n  int iStart;\n  int iEnd;\n  int nToken;\n  int tflags = 0;\n  char *zToken;\n  int rc;\n\n  if( objc==5 ){\n    int nArg;\n    char *zArg = Tcl_GetStringFromObj(objv[1], &nArg);\n    if( nArg<=10 && nArg>=2 && memcmp(\"-colocated\", zArg, nArg)==0 ){\n      tflags |= FTS5_TOKEN_COLOCATED;\n    }else{\n      goto usage;\n    }\n  }else if( objc!=4 ){\n    goto usage;\n  }\n\n  zToken = Tcl_GetStringFromObj(objv[objc-3], &nToken);\n  if( Tcl_GetIntFromObj(interp, objv[objc-2], &iStart) \n   || Tcl_GetIntFromObj(interp, objv[objc-1], &iEnd) \n  ){\n    return TCL_ERROR;\n  }\n\n  if( p->xToken==0 ){\n    Tcl_AppendResult(interp, \n        \"sqlite3_fts5_token may only be used by tokenizer callback\", 0\n    );\n    return TCL_ERROR;\n  }\n\n  rc = p->xToken(p->pCtx, tflags, zToken, nToken, iStart, iEnd);\n  Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n\n usage:\n  Tcl_WrongNumArgs(interp, 1, objv, \"?-colocated? TEXT START END\");\n  return TCL_ERROR;\n}\n\nstatic void f5tDelTokenizer(void *pCtx){\n  F5tTokenizerModule *pMod = (F5tTokenizerModule*)pCtx;\n  Tcl_DecrRefCount(pMod->pScript);\n  ckfree((char *)pMod);\n}\n\n/*\n**      sqlite3_fts5_create_tokenizer DB NAME SCRIPT\n**\n** Register a tokenizer named NAME implemented by script SCRIPT. When\n** a tokenizer instance is created (fts5_tokenizer.xCreate), any tokenizer\n** arguments are appended to SCRIPT and the result executed.\n**\n** The value returned by (SCRIPT + args) is itself a tcl script. This \n** script - call it SCRIPT2 - is executed to tokenize text using the\n** tokenizer instance \"returned\" by SCRIPT. Specifically, to tokenize\n** text SCRIPT2 is invoked with a single argument appended to it - the\n** text to tokenize.\n**\n** SCRIPT2 should invoke the [sqlite3_fts5_token] command once for each\n** token within the tokenized text.\n*/\nstatic int SQLITE_TCLAPI f5tCreateTokenizer(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  F5tTokenizerContext *pContext = (F5tTokenizerContext*)clientData;\n  sqlite3 *db;\n  fts5_api *pApi;\n  char *zName;\n  Tcl_Obj *pScript;\n  fts5_tokenizer t;\n  F5tTokenizerModule *pMod;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB NAME SCRIPT\");\n    return TCL_ERROR;\n  }\n  if( f5tDbAndApi(interp, objv[1], &db, &pApi) ){\n    return TCL_ERROR;\n  }\n  zName = Tcl_GetString(objv[2]);\n  pScript = objv[3];\n\n  t.xCreate = f5tTokenizerCreate;\n  t.xTokenize = f5tTokenizerTokenize;\n  t.xDelete = f5tTokenizerDelete;\n\n  pMod = (F5tTokenizerModule*)ckalloc(sizeof(F5tTokenizerModule));\n  pMod->interp = interp;\n  pMod->pScript = pScript;\n  pMod->pContext = pContext;\n  Tcl_IncrRefCount(pScript);\n  rc = pApi->xCreateTokenizer(pApi, zName, (void*)pMod, &t, f5tDelTokenizer);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, \"error in fts5_api.xCreateTokenizer()\", 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\nstatic void SQLITE_TCLAPI xF5tFree(ClientData clientData){\n  ckfree(clientData);\n}\n\n/*\n**      sqlite3_fts5_may_be_corrupt BOOLEAN\n**\n** Set or clear the global \"may-be-corrupt\" flag. Return the old value.\n*/\nstatic int SQLITE_TCLAPI f5tMayBeCorrupt(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int bOld = sqlite3_fts5_may_be_corrupt;\n\n  if( objc!=2 && objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?BOOLEAN?\");\n    return TCL_ERROR;\n  }\n  if( objc==2 ){\n    int bNew;\n    if( Tcl_GetBooleanFromObj(interp, objv[1], &bNew) ) return TCL_ERROR;\n    sqlite3_fts5_may_be_corrupt = bNew;\n  }\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(bOld));\n  return TCL_OK;\n}\n\n\nstatic unsigned int f5t_fts5HashKey(int nSlot, const char *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  return (h % nSlot);\n}\n\nstatic int SQLITE_TCLAPI f5tTokenHash(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char *z;\n  int n;\n  unsigned int iVal;\n  int nSlot;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NSLOT TOKEN\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &nSlot) ){\n    return TCL_ERROR;\n  }\n  z = Tcl_GetStringFromObj(objv[2], &n);\n\n  iVal = f5t_fts5HashKey(nSlot, z, n);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal));\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI f5tRegisterMatchinfo(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db = 0;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( f5tDbPointer(interp, objv[1], &db) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3Fts5TestRegisterMatchinfo(db);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI f5tRegisterTok(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db = 0;\n  fts5_api *pApi = 0;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( f5tDbAndApi(interp, objv[1], &db, &pApi) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3Fts5TestRegisterTok(db, pApi);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Entry point.\n*/\nint Fts5tcl_Init(Tcl_Interp *interp){\n  static struct Cmd {\n    char *zName;\n    Tcl_ObjCmdProc *xProc;\n    int bTokenizeCtx;\n  } aCmd[] = {\n    { \"sqlite3_fts5_create_tokenizer\",   f5tCreateTokenizer, 1 },\n    { \"sqlite3_fts5_token\",              f5tTokenizerReturn, 1 },\n    { \"sqlite3_fts5_tokenize\",           f5tTokenize, 0 },\n    { \"sqlite3_fts5_create_function\",    f5tCreateFunction, 0 },\n    { \"sqlite3_fts5_may_be_corrupt\",     f5tMayBeCorrupt, 0 },\n    { \"sqlite3_fts5_token_hash\",         f5tTokenHash, 0 },\n    { \"sqlite3_fts5_register_matchinfo\", f5tRegisterMatchinfo, 0 },\n    { \"sqlite3_fts5_register_fts5tokenize\", f5tRegisterTok, 0 }\n  };\n  int i;\n  F5tTokenizerContext *pContext;\n\n  pContext = (F5tTokenizerContext*)ckalloc(sizeof(F5tTokenizerContext));\n  memset(pContext, 0, sizeof(*pContext));\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    struct Cmd *p = &aCmd[i];\n    void *pCtx = 0;\n    if( p->bTokenizeCtx ) pCtx = (void*)pContext;\n    Tcl_CreateObjCommand(interp, p->zName, p->xProc, pCtx, (i ? 0 : xF5tFree));\n  }\n\n  return TCL_OK;\n}\n#else  /* SQLITE_ENABLE_FTS5 */\nint Fts5tcl_Init(Tcl_Interp *interp){\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_FTS5 */\n#endif /* SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_test_mi.c",
    "content": "/*\n** 2015 Aug 04\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains test code only, it is not included in release \n** versions of FTS5. It contains the implementation of an FTS5 auxiliary\n** function very similar to the FTS4 function matchinfo():\n**\n**     https://www.sqlite.org/fts3.html#matchinfo\n**\n** Known differences are that:\n**\n**  1) this function uses the FTS5 definition of \"matchable phrase\", which\n**     excludes any phrases that are part of an expression sub-tree that\n**     does not match the current row. This comes up for MATCH queries \n**     such as:\n**\n**         \"a OR (b AND c)\"\n**\n**     In FTS4, if a single row contains instances of tokens \"a\" and \"c\", \n**     but not \"b\", all instances of \"c\" are considered matches. In FTS5,\n**     they are not (as the \"b AND c\" sub-tree does not match the current\n**     row.\n**\n**  2) For the values returned by 'x' that apply to all rows of the table, \n**     NEAR constraints are not considered. But for the number of hits in\n**     the current row, they are.\n**     \n** This file exports a single function that may be called to register the\n** matchinfo() implementation with a database handle:\n**\n**   int sqlite3Fts5TestRegisterMatchinfo(sqlite3 *db);\n*/\n\n\n#ifdef SQLITE_ENABLE_FTS5\n\n#include \"fts5.h\"\n#include <assert.h>\n#include <string.h>\n\ntypedef struct Fts5MatchinfoCtx Fts5MatchinfoCtx;\n\n#ifndef SQLITE_AMALGAMATION\ntypedef unsigned int u32;\n#endif\n\nstruct Fts5MatchinfoCtx {\n  int nCol;                       /* Number of cols in FTS5 table */\n  int nPhrase;                    /* Number of phrases in FTS5 query */\n  char *zArg;                     /* nul-term'd copy of 2nd arg */\n  int nRet;                       /* Number of elements in aRet[] */\n  u32 *aRet;                      /* Array of 32-bit unsigned ints to return */\n};\n\n\n\n/*\n** Return a pointer to the fts5_api pointer for database connection db.\n** If an error occurs, return NULL and leave an error in the database \n** handle (accessible using sqlite3_errcode()/errmsg()).\n*/\nstatic int fts5_api_from_db(sqlite3 *db, fts5_api **ppApi){\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n\n  *ppApi = 0;\n  rc = sqlite3_prepare(db, \"SELECT fts5(?1)\", -1, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_pointer(pStmt, 1, (void*)ppApi, \"fts5_api_ptr\", 0);\n    (void)sqlite3_step(pStmt);\n    rc = sqlite3_finalize(pStmt);\n  }\n\n  return rc;\n}\n\n\n/*\n** Argument f should be a flag accepted by matchinfo() (a valid character\n** in the string passed as the second argument). If it is not, -1 is \n** returned. Otherwise, if f is a valid matchinfo flag, the value returned\n** is the number of 32-bit integers added to the output array if the\n** table has nCol columns and the query nPhrase phrases.\n*/\nstatic int fts5MatchinfoFlagsize(int nCol, int nPhrase, char f){\n  int ret = -1;\n  switch( f ){\n    case 'p': ret = 1; break;\n    case 'c': ret = 1; break;\n    case 'x': ret = 3 * nCol * nPhrase; break;\n    case 'y': ret = nCol * nPhrase; break;\n    case 'b': ret = ((nCol + 31) / 32) * nPhrase; break;\n    case 'n': ret = 1; break;\n    case 'a': ret = nCol; break;\n    case 'l': ret = nCol; break;\n    case 's': ret = nCol; break;\n  }\n  return ret;\n}\n\nstatic int fts5MatchinfoIter(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  Fts5MatchinfoCtx *p,\n  int(*x)(const Fts5ExtensionApi*,Fts5Context*,Fts5MatchinfoCtx*,char,u32*)\n){\n  int i;\n  int n = 0;\n  int rc = SQLITE_OK;\n  char f;\n  for(i=0; (f = p->zArg[i]); i++){\n    rc = x(pApi, pFts, p, f, &p->aRet[n]);\n    if( rc!=SQLITE_OK ) break;\n    n += fts5MatchinfoFlagsize(p->nCol, p->nPhrase, f);\n  }\n  return rc;\n}\n\nstatic int fts5MatchinfoXCb(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  void *pUserData\n){\n  Fts5PhraseIter iter;\n  int iCol, iOff;\n  u32 *aOut = (u32*)pUserData;\n  int iPrev = -1;\n\n  for(pApi->xPhraseFirst(pFts, 0, &iter, &iCol, &iOff); \n      iCol>=0; \n      pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n  ){\n    aOut[iCol*3+1]++;\n    if( iCol!=iPrev ) aOut[iCol*3 + 2]++;\n    iPrev = iCol;\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int fts5MatchinfoGlobalCb(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  Fts5MatchinfoCtx *p,\n  char f,\n  u32 *aOut\n){\n  int rc = SQLITE_OK;\n  switch( f ){\n    case 'p':\n      aOut[0] = p->nPhrase; \n      break;\n\n    case 'c':\n      aOut[0] = p->nCol; \n      break;\n\n    case 'x': {\n      int i;\n      for(i=0; i<p->nPhrase && rc==SQLITE_OK; i++){\n        void *pPtr = (void*)&aOut[i * p->nCol * 3];\n        rc = pApi->xQueryPhrase(pFts, i, pPtr, fts5MatchinfoXCb);\n      }\n      break;\n    }\n\n    case 'n': {\n      sqlite3_int64 nRow;\n      rc = pApi->xRowCount(pFts, &nRow);\n      aOut[0] = (u32)nRow;\n      break;\n    }\n\n    case 'a': {\n      sqlite3_int64 nRow = 0;\n      rc = pApi->xRowCount(pFts, &nRow);\n      if( nRow==0 ){\n        memset(aOut, 0, sizeof(u32) * p->nCol);\n      }else{\n        int i;\n        for(i=0; rc==SQLITE_OK && i<p->nCol; i++){\n          sqlite3_int64 nToken;\n          rc = pApi->xColumnTotalSize(pFts, i, &nToken);\n          if( rc==SQLITE_OK){\n            aOut[i] = (u32)((2*nToken + nRow) / (2*nRow));\n          }\n        }\n      }\n      break;\n    }\n\n  }\n  return rc;\n}\n\nstatic int fts5MatchinfoLocalCb(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  Fts5MatchinfoCtx *p,\n  char f,\n  u32 *aOut\n){\n  int i;\n  int rc = SQLITE_OK;\n\n  switch( f ){\n    case 'b': {\n      int iPhrase;\n      int nInt = ((p->nCol + 31) / 32) * p->nPhrase;\n      for(i=0; i<nInt; i++) aOut[i] = 0;\n\n      for(iPhrase=0; iPhrase<p->nPhrase; iPhrase++){\n        Fts5PhraseIter iter;\n        int iCol;\n        for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n            iCol>=0; \n            pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n        ){\n          aOut[iPhrase * ((p->nCol+31)/32) + iCol/32] |= ((u32)1 << iCol%32);\n        }\n      }\n\n      break;\n    }\n\n    case 'x':\n    case 'y': {\n      int nMul = (f=='x' ? 3 : 1);\n      int iPhrase;\n\n      for(i=0; i<(p->nCol*p->nPhrase); i++) aOut[i*nMul] = 0;\n\n      for(iPhrase=0; iPhrase<p->nPhrase; iPhrase++){\n        Fts5PhraseIter iter;\n        int iOff, iCol;\n        for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff); \n            iOff>=0; \n            pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n        ){\n          aOut[nMul * (iCol + iPhrase * p->nCol)]++;\n        }\n      }\n\n      break;\n    }\n\n    case 'l': {\n      for(i=0; rc==SQLITE_OK && i<p->nCol; i++){\n        int nToken;\n        rc = pApi->xColumnSize(pFts, i, &nToken);\n        aOut[i] = (u32)nToken;\n      }\n      break;\n    }\n\n    case 's': {\n      int nInst;\n\n      memset(aOut, 0, sizeof(u32) * p->nCol);\n\n      rc = pApi->xInstCount(pFts, &nInst);\n      for(i=0; rc==SQLITE_OK && i<nInst; i++){\n        int iPhrase, iOff, iCol = 0;\n        int iNextPhrase;\n        int iNextOff;\n        u32 nSeq = 1;\n        int j;\n\n        rc = pApi->xInst(pFts, i, &iPhrase, &iCol, &iOff);\n        iNextPhrase = iPhrase+1;\n        iNextOff = iOff+pApi->xPhraseSize(pFts, 0);\n        for(j=i+1; rc==SQLITE_OK && j<nInst; j++){\n          int ip, ic, io;\n          rc = pApi->xInst(pFts, j, &ip, &ic, &io);\n          if( ic!=iCol || io>iNextOff ) break;\n          if( ip==iNextPhrase && io==iNextOff ){\n            nSeq++;\n            iNextPhrase = ip+1;\n            iNextOff = io + pApi->xPhraseSize(pFts, ip);\n          }\n        }\n\n        if( nSeq>aOut[iCol] ) aOut[iCol] = nSeq;\n      }\n\n      break;\n    }\n  }\n  return rc;\n}\n \nstatic Fts5MatchinfoCtx *fts5MatchinfoNew(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning error message */\n  const char *zArg                /* Matchinfo flag string */\n){\n  Fts5MatchinfoCtx *p;\n  int nCol;\n  int nPhrase;\n  int i;\n  int nInt;\n  int nByte;\n  int rc;\n\n  nCol = pApi->xColumnCount(pFts);\n  nPhrase = pApi->xPhraseCount(pFts);\n\n  nInt = 0;\n  for(i=0; zArg[i]; i++){\n    int n = fts5MatchinfoFlagsize(nCol, nPhrase, zArg[i]);\n    if( n<0 ){\n      char *zErr = sqlite3_mprintf(\"unrecognized matchinfo flag: %c\", zArg[i]);\n      sqlite3_result_error(pCtx, zErr, -1);\n      sqlite3_free(zErr);\n      return 0;\n    }\n    nInt += n;\n  }\n\n  nByte = sizeof(Fts5MatchinfoCtx)          /* The struct itself */\n         + sizeof(u32) * nInt               /* The p->aRet[] array */\n         + (i+1);                           /* The p->zArg string */\n  p = (Fts5MatchinfoCtx*)sqlite3_malloc(nByte);\n  if( p==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return 0;\n  }\n  memset(p, 0, nByte);\n\n  p->nCol = nCol;\n  p->nPhrase = nPhrase;\n  p->aRet = (u32*)&p[1];\n  p->nRet = nInt;\n  p->zArg = (char*)&p->aRet[nInt];\n  memcpy(p->zArg, zArg, i);\n\n  rc = fts5MatchinfoIter(pApi, pFts, p, fts5MatchinfoGlobalCb);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    sqlite3_free(p);\n    p = 0;\n  }\n\n  return p;\n}\n\nstatic void fts5MatchinfoFunc(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  const char *zArg;\n  Fts5MatchinfoCtx *p;\n  int rc = SQLITE_OK;\n\n  if( nVal>0 ){\n    zArg = (const char*)sqlite3_value_text(apVal[0]);\n  }else{\n    zArg = \"pcx\";\n  }\n\n  p = (Fts5MatchinfoCtx*)pApi->xGetAuxdata(pFts, 0);\n  if( p==0 || sqlite3_stricmp(zArg, p->zArg) ){\n    p = fts5MatchinfoNew(pApi, pFts, pCtx, zArg);\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = pApi->xSetAuxdata(pFts, p, sqlite3_free);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5MatchinfoIter(pApi, pFts, p, fts5MatchinfoLocalCb);\n  }\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }else{\n    /* No errors has occured, so return a copy of the array of integers. */\n    int nByte = p->nRet * sizeof(u32);\n    sqlite3_result_blob(pCtx, (void*)p->aRet, nByte, SQLITE_TRANSIENT);\n  }\n}\n\nint sqlite3Fts5TestRegisterMatchinfo(sqlite3 *db){\n  int rc;                         /* Return code */\n  fts5_api *pApi;                 /* FTS5 API functions */\n\n  /* Extract the FTS5 API pointer from the database handle. The \n  ** fts5_api_from_db() function above is copied verbatim from the \n  ** FTS5 documentation. Refer there for details. */\n  rc = fts5_api_from_db(db, &pApi);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* If fts5_api_from_db() returns NULL, then either FTS5 is not registered\n  ** with this database handle, or an error (OOM perhaps?) has occurred.\n  **\n  ** Also check that the fts5_api object is version 2 or newer.  \n  */ \n  if( pApi==0 || pApi->iVersion<2 ){\n    return SQLITE_ERROR;\n  }\n\n  /* Register the implementation of matchinfo() */\n  rc = pApi->xCreateFunction(pApi, \"matchinfo\", 0, fts5MatchinfoFunc, 0);\n\n  return rc;\n}\n\n#endif /* SQLITE_ENABLE_FTS5 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_test_tok.c",
    "content": "/*\n** 2013 Apr 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for the \"fts5tokenize\" virtual table module.\n** An fts5tokenize virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE <tbl> USING fts5tokenize(\n**       <tokenizer-name>, <arg-1>, ...\n**   );\n**\n** The table created has the following schema:\n**\n**   CREATE TABLE <tbl>(input HIDDEN, token, start, end, position)\n**\n** When queried, the query must include a WHERE clause of type:\n**\n**   input = <string>\n**\n** The virtual table module tokenizes this <string>, using the FTS3 \n** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE \n** statement and returns one row for each token in the result. With\n** fields set as follows:\n**\n**   input:   Always set to a copy of <string>\n**   token:   A token from the input.\n**   start:   Byte offset of the token within the input <string>.\n**   end:     Byte offset of the byte immediately following the end of the\n**            token within the input string.\n**   pos:     Token offset of token within input.\n**\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_FTS5)\n\n#include \"fts5.h\"\n#include <string.h>\n#include <assert.h>\n\ntypedef struct Fts5tokTable Fts5tokTable;\ntypedef struct Fts5tokCursor Fts5tokCursor;\ntypedef struct Fts5tokRow Fts5tokRow;\n\n/*\n** Virtual table structure.\n*/\nstruct Fts5tokTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  fts5_tokenizer tok;             /* Tokenizer functions */\n  Fts5Tokenizer *pTok;            /* Tokenizer instance */\n};\n\n/*\n** A container for a rows values.\n*/\nstruct Fts5tokRow {\n  char *zToken;\n  int iStart;\n  int iEnd;\n  int iPos;\n};\n\n/*\n** Virtual table cursor structure.\n*/\nstruct Fts5tokCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  int iRowid;                     /* Current 'rowid' value */\n  char *zInput;                   /* Input string */\n  int nRow;                       /* Number of entries in aRow[] */\n  Fts5tokRow *aRow;               /* Array of rows to return */\n};\n\nstatic void fts5tokDequote(char *z){\n  char q = z[0];\n\n  if( q=='[' || q=='\\'' || q=='\"' || q=='`' ){\n    int iIn = 1;\n    int iOut = 0;\n    if( q=='[' ) q = ']';  \n\n    while( z[iIn] ){\n      if( z[iIn]==q ){\n        if( z[iIn+1]!=q ){\n          /* Character iIn was the close quote. */\n          iIn++;\n          break;\n        }else{\n          /* Character iIn and iIn+1 form an escaped quote character. Skip\n          ** the input cursor past both and copy a single quote character \n          ** to the output buffer. */\n          iIn += 2;\n          z[iOut++] = q;\n        }\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** The second argument, argv[], is an array of pointers to nul-terminated\n** strings. This function makes a copy of the array and strings into a \n** single block of memory. It then dequotes any of the strings that appear\n** to be quoted.\n**\n** If successful, output parameter *pazDequote is set to point at the\n** array of dequoted strings and SQLITE_OK is returned. The caller is\n** responsible for eventually calling sqlite3_free() to free the array\n** in this case. Or, if an error occurs, an SQLite error code is returned.\n** The final value of *pazDequote is undefined in this case.\n*/\nstatic int fts5tokDequoteArray(\n  int argc,                       /* Number of elements in argv[] */\n  const char * const *argv,       /* Input array */\n  char ***pazDequote              /* Output array */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( argc==0 ){\n    *pazDequote = 0;\n  }else{\n    int i;\n    int nByte = 0;\n    char **azDequote;\n\n    for(i=0; i<argc; i++){\n      nByte += (int)(strlen(argv[i]) + 1);\n    }\n\n    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);\n    if( azDequote==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *pSpace = (char *)&azDequote[argc];\n      for(i=0; i<argc; i++){\n        int n = (int)strlen(argv[i]);\n        azDequote[i] = pSpace;\n        memcpy(pSpace, argv[i], n+1);\n        fts5tokDequote(pSpace);\n        pSpace += (n+1);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Schema of the tokenizer table.\n*/\n#define FTS3_TOK_SCHEMA \"CREATE TABLE x(input HIDDEN, token, start, end, position)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n**\n**   argv[0]: module name\n**   argv[1]: database name \n**   argv[2]: table name\n**   argv[3]: first argument (tokenizer name)\n*/\nstatic int fts5tokConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pCtx,                     /* Pointer to fts5_api object */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  fts5_api *pApi = (fts5_api*)pCtx;\n  Fts5tokTable *pTab = 0;\n  int rc;\n  char **azDequote = 0;\n  int nDequote = 0;\n\n  rc = sqlite3_declare_vtab(db, \n       \"CREATE TABLE x(input HIDDEN, token, start, end, position)\"\n  );\n\n  if( rc==SQLITE_OK ){\n    nDequote = argc-3;\n    rc = fts5tokDequoteArray(nDequote, &argv[3], &azDequote);\n  }\n\n  if( rc==SQLITE_OK ){\n    pTab = (Fts5tokTable*)sqlite3_malloc(sizeof(Fts5tokTable));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pTab, 0, sizeof(Fts5tokTable));\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    void *pTokCtx = 0;\n    const char *zModule = 0;\n    if( nDequote>0 ){\n      zModule = azDequote[0];\n    }\n\n    rc = pApi->xFindTokenizer(pApi, zModule, &pTokCtx, &pTab->tok);\n    if( rc==SQLITE_OK ){\n      const char **azArg = (const char **)&azDequote[1];\n      int nArg = nDequote>0 ? nDequote-1 : 0;\n      rc = pTab->tok.xCreate(pTokCtx, azArg, nArg, &pTab->pTok);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(pTab);\n    pTab = 0;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  sqlite3_free(azDequote);\n  return rc;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts5tokDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts5tokTable *pTab = (Fts5tokTable *)pVtab;\n  if( pTab->pTok ){\n    pTab->tok.xDelete(pTab->pTok);\n  }\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts5tokBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable \n     && pInfo->aConstraint[i].iColumn==0 \n     && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      pInfo->idxNum = 1;\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->estimatedCost = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  pInfo->idxNum = 0;\n  assert( pInfo->estimatedCost>1000000.0 );\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts5tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts5tokCursor *pCsr;\n\n  pCsr = (Fts5tokCursor *)sqlite3_malloc(sizeof(Fts5tokCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts5tokCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the tokenizer cursor passed as the only argument. As if it had\n** just been returned by fts5tokOpenMethod().\n*/\nstatic void fts5tokResetCursor(Fts5tokCursor *pCsr){\n  int i;\n  for(i=0; i<pCsr->nRow; i++){\n    sqlite3_free(pCsr->aRow[i].zToken);\n  }\n  sqlite3_free(pCsr->zInput);\n  sqlite3_free(pCsr->aRow);\n  pCsr->zInput = 0;\n  pCsr->aRow = 0;\n  pCsr->nRow = 0;\n  pCsr->iRowid = 0;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts5tokCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  fts5tokResetCursor(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts5tokNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  pCsr->iRowid++;\n  return SQLITE_OK;\n}\n\nstatic int fts5tokCb(\n  void *pCtx,         /* Pointer to Fts5tokCursor */\n  int tflags,         /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken, /* Pointer to buffer containing token */\n  int nToken,         /* Size of token in bytes */\n  int iStart,         /* Byte offset of token within input text */\n  int iEnd            /* Byte offset of end of token within input text */\n){\n  Fts5tokCursor *pCsr = (Fts5tokCursor*)pCtx;\n  Fts5tokRow *pRow;\n\n  if( (pCsr->nRow & (pCsr->nRow-1))==0 ){\n    int nNew = pCsr->nRow ? pCsr->nRow*2 : 32;\n    Fts5tokRow *aNew;\n    aNew = (Fts5tokRow*)sqlite3_realloc(pCsr->aRow, nNew*sizeof(Fts5tokRow));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    memset(&aNew[pCsr->nRow], 0, sizeof(Fts5tokRow)*(nNew-pCsr->nRow));\n    pCsr->aRow = aNew;\n  }\n\n  pRow = &pCsr->aRow[pCsr->nRow];\n  pRow->iStart = iStart;\n  pRow->iEnd = iEnd;\n  if( pCsr->nRow ){\n    pRow->iPos = pRow[-1].iPos + ((tflags & FTS5_TOKEN_COLOCATED) ? 0 : 1);\n  }\n  pRow->zToken = sqlite3_malloc(nToken+1);\n  if( pRow->zToken==0 ) return SQLITE_NOMEM;\n  memcpy(pRow->zToken, pToken, nToken);\n  pRow->zToken[nToken] = 0;\n  pCsr->nRow++;\n\n  return SQLITE_OK;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts5tokFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_ERROR;\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  Fts5tokTable *pTab = (Fts5tokTable *)(pCursor->pVtab);\n\n  fts5tokResetCursor(pCsr);\n  if( idxNum==1 ){\n    const char *zByte = (const char *)sqlite3_value_text(apVal[0]);\n    int nByte = sqlite3_value_bytes(apVal[0]);\n    pCsr->zInput = sqlite3_malloc(nByte+1);\n    if( pCsr->zInput==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memcpy(pCsr->zInput, zByte, nByte);\n      pCsr->zInput[nByte] = 0;\n      rc = pTab->tok.xTokenize(\n          pTab->pTok, (void*)pCsr, 0, zByte, nByte, fts5tokCb\n      );\n    }\n  }\n\n  if( rc!=SQLITE_OK ) return rc;\n  return fts5tokNextMethod(pCursor);\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts5tokEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  return (pCsr->iRowid>pCsr->nRow);\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts5tokColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  Fts5tokRow *pRow = &pCsr->aRow[pCsr->iRowid-1];\n\n  /* CREATE TABLE x(input, token, start, end, position) */\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_text(pCtx, pRow->zToken, -1, SQLITE_TRANSIENT);\n      break;\n    case 2:\n      sqlite3_result_int(pCtx, pRow->iStart);\n      break;\n    case 3:\n      sqlite3_result_int(pCtx, pRow->iEnd);\n      break;\n    default:\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, pRow->iPos);\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts5tokRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts5tokCursor *pCsr = (Fts5tokCursor *)pCursor;\n  *pRowid = (sqlite3_int64)pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts5tok module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nint sqlite3Fts5TestRegisterTok(sqlite3 *db, fts5_api *pApi){\n  static const sqlite3_module fts5tok_module = {\n     0,                           /* iVersion      */\n     fts5tokConnectMethod,        /* xCreate       */\n     fts5tokConnectMethod,        /* xConnect      */\n     fts5tokBestIndexMethod,      /* xBestIndex    */\n     fts5tokDisconnectMethod,     /* xDisconnect   */\n     fts5tokDisconnectMethod,     /* xDestroy      */\n     fts5tokOpenMethod,           /* xOpen         */\n     fts5tokCloseMethod,          /* xClose        */\n     fts5tokFilterMethod,         /* xFilter       */\n     fts5tokNextMethod,           /* xNext         */\n     fts5tokEofMethod,            /* xEof          */\n     fts5tokColumnMethod,         /* xColumn       */\n     fts5tokRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts5tokenize\", &fts5tok_module, (void*)pApi);\n  return rc;\n}\n\n#endif /* defined(SQLITE_TEST) && defined(SQLITE_ENABLE_FTS5) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_tokenize.c",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n#include \"fts5Int.h\"\n\n/**************************************************************************\n** Start of ascii tokenizer implementation.\n*/\n\n/*\n** For tokenizers with no \"unicode\" modifier, the set of token characters\n** is the same as the set of ASCII range alphanumeric characters. \n*/\nstatic unsigned char aAsciiTokenChar[128] = {\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00..0x0F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x10..0x1F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20..0x2F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30..0x3F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40..0x4F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x50..0x5F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60..0x6F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x70..0x7F */\n};\n\ntypedef struct AsciiTokenizer AsciiTokenizer;\nstruct AsciiTokenizer {\n  unsigned char aTokenChar[128];\n};\n\nstatic void fts5AsciiAddExceptions(\n  AsciiTokenizer *p, \n  const char *zArg, \n  int bTokenChars\n){\n  int i;\n  for(i=0; zArg[i]; i++){\n    if( (zArg[i] & 0x80)==0 ){\n      p->aTokenChar[(int)zArg[i]] = (unsigned char)bTokenChars;\n    }\n  }\n}\n\n/*\n** Delete a \"ascii\" tokenizer.\n*/\nstatic void fts5AsciiDelete(Fts5Tokenizer *p){\n  sqlite3_free(p);\n}\n\n/*\n** Create an \"ascii\" tokenizer.\n*/\nstatic int fts5AsciiCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;\n  AsciiTokenizer *p = 0;\n  UNUSED_PARAM(pUnused);\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = sqlite3_malloc(sizeof(AsciiTokenizer));\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int i;\n      memset(p, 0, sizeof(AsciiTokenizer));\n      memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          fts5AsciiAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          fts5AsciiAddExceptions(p, zArg, 0);\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        fts5AsciiDelete((Fts5Tokenizer*)p);\n        p = 0;\n      }\n    }\n  }\n\n  *ppOut = (Fts5Tokenizer*)p;\n  return rc;\n}\n\n\nstatic void asciiFold(char *aOut, const char *aIn, int nByte){\n  int i;\n  for(i=0; i<nByte; i++){\n    char c = aIn[i];\n    if( c>='A' && c<='Z' ) c += 32;\n    aOut[i] = c;\n  }\n}\n\n/*\n** Tokenize some text using the ascii tokenizer.\n*/\nstatic int fts5AsciiTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  int ie;\n  int is = 0;\n\n  char aFold[64];\n  int nFold = sizeof(aFold);\n  char *pFold = aFold;\n  unsigned char *a = p->aTokenChar;\n\n  UNUSED_PARAM(iUnused);\n\n  while( is<nText && rc==SQLITE_OK ){\n    int nByte;\n\n    /* Skip any leading divider characters. */\n    while( is<nText && ((pText[is]&0x80)==0 && a[(int)pText[is]]==0) ){\n      is++;\n    }\n    if( is==nText ) break;\n\n    /* Count the token characters */\n    ie = is+1;\n    while( ie<nText && ((pText[ie]&0x80) || a[(int)pText[ie]] ) ){\n      ie++;\n    }\n\n    /* Fold to lower case */\n    nByte = ie-is;\n    if( nByte>nFold ){\n      if( pFold!=aFold ) sqlite3_free(pFold);\n      pFold = sqlite3_malloc(nByte*2);\n      if( pFold==0 ){\n        rc = SQLITE_NOMEM;\n        break;\n      }\n      nFold = nByte*2;\n    }\n    asciiFold(pFold, &pText[is], nByte);\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, pFold, nByte, is, ie);\n    is = ie+1;\n  }\n  \n  if( pFold!=aFold ) sqlite3_free(pFold);\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of unicode61 tokenizer implementation.\n*/\n\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (unsigned char)(c&0xFF);                 \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (unsigned char)((c>>6)&0x1F);     \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (unsigned char)((c>>12)&0x0F);    \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (unsigned char)((c>>18) & 0x07);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>12) & 0x3F);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct Unicode61Tokenizer Unicode61Tokenizer;\nstruct Unicode61Tokenizer {\n  unsigned char aTokenChar[128];  /* ASCII range token characters */\n  char *aFold;                    /* Buffer to fold text into */\n  int nFold;                      /* Size of aFold[] in bytes */\n  int bRemoveDiacritic;           /* True if remove_diacritics=1 is set */\n  int nException;\n  int *aiException;\n};\n\nstatic int fts5UnicodeAddExceptions(\n  Unicode61Tokenizer *p,          /* Tokenizer object */\n  const char *z,                  /* Characters to treat as exceptions */\n  int bTokenChars                 /* 1 for 'tokenchars', 0 for 'separators' */\n){\n  int rc = SQLITE_OK;\n  int n = (int)strlen(z);\n  int *aNew;\n\n  if( n>0 ){\n    aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));\n    if( aNew ){\n      int nNew = p->nException;\n      const unsigned char *zCsr = (const unsigned char*)z;\n      const unsigned char *zTerm = (const unsigned char*)&z[n];\n      while( zCsr<zTerm ){\n        int iCode;\n        int bToken;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( iCode<128 ){\n          p->aTokenChar[iCode] = (unsigned char)bTokenChars;\n        }else{\n          bToken = sqlite3Fts5UnicodeIsalnum(iCode);\n          assert( (bToken==0 || bToken==1) ); \n          assert( (bTokenChars==0 || bTokenChars==1) );\n          if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){\n            int i;\n            for(i=0; i<nNew; i++){\n              if( aNew[i]>iCode ) break;\n            }\n            memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));\n            aNew[i] = iCode;\n            nNew++;\n          }\n        }\n      }\n      p->aiException = aNew;\n      p->nException = nNew;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int fts5UnicodeIsException(Unicode61Tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Delete a \"unicode61\" tokenizer.\n*/\nstatic void fts5UnicodeDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTok;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p->aFold);\n    sqlite3_free(p);\n  }\n  return;\n}\n\n/*\n** Create a \"unicode61\" tokenizer.\n*/\nstatic int fts5UnicodeCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Unicode61Tokenizer *p = 0;      /* New tokenizer object */ \n\n  UNUSED_PARAM(pUnused);\n\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));\n    if( p ){\n      int i;\n      memset(p, 0, sizeof(Unicode61Tokenizer));\n      memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));\n      p->bRemoveDiacritic = 1;\n      p->nFold = 64;\n      p->aFold = sqlite3_malloc(p->nFold * sizeof(char));\n      if( p->aFold==0 ){\n        rc = SQLITE_NOMEM;\n      }\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"remove_diacritics\") ){\n          if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){\n            rc = SQLITE_ERROR;\n          }\n          p->bRemoveDiacritic = (zArg[0]=='1');\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 0);\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      fts5UnicodeDelete((Fts5Tokenizer*)p);\n      p = 0;\n    }\n    *ppOut = (Fts5Tokenizer*)p;\n  }\n  return rc;\n}\n\n/*\n** Return true if, for the purposes of tokenizing with the tokenizer\n** passed as the first argument, codepoint iCode is considered a token \n** character (not a separator).\n*/\nstatic int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){\n  assert( (sqlite3Fts5UnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3Fts5UnicodeIsalnum(iCode) ^ fts5UnicodeIsException(p, iCode);\n}\n\nstatic int fts5UnicodeTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  unsigned char *a = p->aTokenChar;\n\n  unsigned char *zTerm = (unsigned char*)&pText[nText];\n  unsigned char *zCsr = (unsigned char *)pText;\n\n  /* Output buffer */\n  char *aFold = p->aFold;\n  int nFold = p->nFold;\n  const char *pEnd = &aFold[nFold-6];\n\n  UNUSED_PARAM(iUnused);\n\n  /* Each iteration of this loop gobbles up a contiguous run of separators,\n  ** then the next token.  */\n  while( rc==SQLITE_OK ){\n    int iCode;                    /* non-ASCII codepoint read from input */\n    char *zOut = aFold;\n    int is;\n    int ie;\n\n    /* Skip any separator characters. */\n    while( 1 ){\n      if( zCsr>=zTerm ) goto tokenize_done;\n      if( *zCsr & 0x80 ) {\n        /* A character outside of the ascii range. Skip past it if it is\n        ** a separator character. Or break out of the loop if it is not. */\n        is = zCsr - (unsigned char*)pText;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p, iCode) ){\n          goto non_ascii_tokenchar;\n        }\n      }else{\n        if( a[*zCsr] ){\n          is = zCsr - (unsigned char*)pText;\n          goto ascii_tokenchar;\n        }\n        zCsr++;\n      }\n    }\n\n    /* Run through the tokenchars. Fold them into the output buffer along\n    ** the way.  */\n    while( zCsr<zTerm ){\n\n      /* Grow the output buffer so that there is sufficient space to fit the\n      ** largest possible utf-8 character.  */\n      if( zOut>pEnd ){\n        aFold = sqlite3_malloc(nFold*2);\n        if( aFold==0 ){\n          rc = SQLITE_NOMEM;\n          goto tokenize_done;\n        }\n        zOut = &aFold[zOut - p->aFold];\n        memcpy(aFold, p->aFold, nFold);\n        sqlite3_free(p->aFold);\n        p->aFold = aFold;\n        p->nFold = nFold = nFold*2;\n        pEnd = &aFold[nFold-6];\n      }\n\n      if( *zCsr & 0x80 ){\n        /* An non-ascii-range character. Fold it into the output buffer if\n        ** it is a token character, or break out of the loop if it is not. */\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){\n non_ascii_tokenchar:\n          iCode = sqlite3Fts5UnicodeFold(iCode, p->bRemoveDiacritic);\n          if( iCode ) WRITE_UTF8(zOut, iCode);\n        }else{\n          break;\n        }\n      }else if( a[*zCsr]==0 ){\n        /* An ascii-range separator character. End of token. */\n        break; \n      }else{\n ascii_tokenchar:\n        if( *zCsr>='A' && *zCsr<='Z' ){\n          *zOut++ = *zCsr + 32;\n        }else{\n          *zOut++ = *zCsr;\n        }\n        zCsr++;\n      }\n      ie = zCsr - (unsigned char*)pText;\n    }\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, aFold, zOut-aFold, is, ie); \n  }\n  \n tokenize_done:\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of porter stemmer implementation.\n*/\n\n/* Any tokens larger than this (in bytes) are passed through without\n** stemming. */\n#define FTS5_PORTER_MAX_TOKEN 64\n\ntypedef struct PorterTokenizer PorterTokenizer;\nstruct PorterTokenizer {\n  fts5_tokenizer tokenizer;       /* Parent tokenizer module */\n  Fts5Tokenizer *pTokenizer;      /* Parent tokenizer instance */\n  char aBuf[FTS5_PORTER_MAX_TOKEN + 64];\n};\n\n/*\n** Delete a \"porter\" tokenizer.\n*/\nstatic void fts5PorterDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    PorterTokenizer *p = (PorterTokenizer*)pTok;\n    if( p->pTokenizer ){\n      p->tokenizer.xDelete(p->pTokenizer);\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Create a \"porter\" tokenizer.\n*/\nstatic int fts5PorterCreate(\n  void *pCtx, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  fts5_api *pApi = (fts5_api*)pCtx;\n  int rc = SQLITE_OK;\n  PorterTokenizer *pRet;\n  void *pUserdata = 0;\n  const char *zBase = \"unicode61\";\n\n  if( nArg>0 ){\n    zBase = azArg[0];\n  }\n\n  pRet = (PorterTokenizer*)sqlite3_malloc(sizeof(PorterTokenizer));\n  if( pRet ){\n    memset(pRet, 0, sizeof(PorterTokenizer));\n    rc = pApi->xFindTokenizer(pApi, zBase, &pUserdata, &pRet->tokenizer);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    int nArg2 = (nArg>0 ? nArg-1 : 0);\n    const char **azArg2 = (nArg2 ? &azArg[1] : 0);\n    rc = pRet->tokenizer.xCreate(pUserdata, azArg2, nArg2, &pRet->pTokenizer);\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5PorterDelete((Fts5Tokenizer*)pRet);\n    pRet = 0;\n  }\n  *ppOut = (Fts5Tokenizer*)pRet;\n  return rc;\n}\n\ntypedef struct PorterContext PorterContext;\nstruct PorterContext {\n  void *pCtx;\n  int (*xToken)(void*, int, const char*, int, int, int);\n  char *aBuf;\n};\n\ntypedef struct PorterRule PorterRule;\nstruct PorterRule {\n  const char *zSuffix;\n  int nSuffix;\n  int (*xCond)(char *zStem, int nStem);\n  const char *zOutput;\n  int nOutput;\n};\n\n#if 0\nstatic int fts5PorterApply(char *aBuf, int *pnBuf, PorterRule *aRule){\n  int ret = -1;\n  int nBuf = *pnBuf;\n  PorterRule *p;\n\n  for(p=aRule; p->zSuffix; p++){\n    assert( strlen(p->zSuffix)==p->nSuffix );\n    assert( strlen(p->zOutput)==p->nOutput );\n    if( nBuf<p->nSuffix ) continue;\n    if( 0==memcmp(&aBuf[nBuf - p->nSuffix], p->zSuffix, p->nSuffix) ) break;\n  }\n\n  if( p->zSuffix ){\n    int nStem = nBuf - p->nSuffix;\n    if( p->xCond==0 || p->xCond(aBuf, nStem) ){\n      memcpy(&aBuf[nStem], p->zOutput, p->nOutput);\n      *pnBuf = nStem + p->nOutput;\n      ret = p - aRule;\n    }\n  }\n\n  return ret;\n}\n#endif\n\nstatic int fts5PorterIsVowel(char c, int bYIsVowel){\n  return (\n      c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || (bYIsVowel && c=='y')\n  );\n}\n\nstatic int fts5PorterGobbleVC(char *zStem, int nStem, int bPrevCons){\n  int i;\n  int bCons = bPrevCons;\n\n  /* Scan for a vowel */\n  for(i=0; i<nStem; i++){\n    if( 0==(bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) break;\n  }\n\n  /* Scan for a consonent */\n  for(i++; i<nStem; i++){\n    if( (bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) return i+1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m > 0) */\nstatic int fts5Porter_MGt0(char *zStem, int nStem){\n  return !!fts5PorterGobbleVC(zStem, nStem, 0);\n}\n\n/* porter rule condition: (m > 1) */\nstatic int fts5Porter_MGt1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m = 1) */\nstatic int fts5Porter_MEq1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && 0==fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (*o) */\nstatic int fts5Porter_Ostar(char *zStem, int nStem){\n  if( zStem[nStem-1]=='w' || zStem[nStem-1]=='x' || zStem[nStem-1]=='y' ){\n    return 0;\n  }else{\n    int i;\n    int mask = 0;\n    int bCons = 0;\n    for(i=0; i<nStem; i++){\n      bCons = !fts5PorterIsVowel(zStem[i], bCons);\n      assert( bCons==0 || bCons==1 );\n      mask = (mask << 1) + bCons;\n    }\n    return ((mask & 0x0007)==0x0005);\n  }\n}\n\n/* porter rule condition: (m > 1 and (*S or *T)) */\nstatic int fts5Porter_MGt1_and_S_or_T(char *zStem, int nStem){\n  assert( nStem>0 );\n  return (zStem[nStem-1]=='s' || zStem[nStem-1]=='t') \n      && fts5Porter_MGt1(zStem, nStem);\n}\n\n/* porter rule condition: (*v*) */\nstatic int fts5Porter_Vowel(char *zStem, int nStem){\n  int i;\n  for(i=0; i<nStem; i++){\n    if( fts5PorterIsVowel(zStem[i], i>0) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n\n/**************************************************************************\n***************************************************************************\n** GENERATED CODE STARTS HERE (mkportersteps.tcl)\n*/\n\nstatic int fts5PorterStep4(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"al\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"ance\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ence\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>2 && 0==memcmp(\"er\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"ic\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>4 && 0==memcmp(\"able\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ible\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ant\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ement\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ment\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"ent\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>3 && 0==memcmp(\"ion\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1_and_S_or_T(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ou\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>3 && 0==memcmp(\"ism\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>3 && 0==memcmp(\"ate\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"iti\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ous\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>3 && 0==memcmp(\"ive\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>3 && 0==memcmp(\"ize\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"at\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ate\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'b': \n      if( nBuf>2 && 0==memcmp(\"bl\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ble\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"iz\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ize\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>7 && 0==memcmp(\"ational\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ate\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"tional\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"tion\", 4);\n          *pnBuf = nBuf - 6 + 4;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"enci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ence\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"anci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ance\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>4 && 0==memcmp(\"izer\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ize\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'g': \n      if( nBuf>4 && 0==memcmp(\"logi\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"log\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>3 && 0==memcmp(\"bli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ble\", 3);\n          *pnBuf = nBuf - 3 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"alli\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"al\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"entli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ent\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"eli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"e\", 1);\n          *pnBuf = nBuf - 3 + 1;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ousli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ous\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>7 && 0==memcmp(\"ization\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ize\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ation\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ate\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ator\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ate\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>5 && 0==memcmp(\"alism\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"iveness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ive\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"fulness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ful\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"ousness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ous\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"aliti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iviti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ive\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"biliti\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"ble\", 3);\n          *pnBuf = nBuf - 6 + 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep3(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>4 && 0==memcmp(\"ical\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ic\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>4 && 0==memcmp(\"ness\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"icate\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iciti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ful\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>5 && 0==memcmp(\"ative\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>5 && 0==memcmp(\"alize\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'e': \n      if( nBuf>3 && 0==memcmp(\"eed\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ee\", 2);\n          *pnBuf = nBuf - 3 + 2;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ed\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n          ret = 1;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ing\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n          ret = 1;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n/* \n** GENERATED CODE ENDS HERE (mkportersteps.tcl)\n***************************************************************************\n**************************************************************************/\n\nstatic void fts5PorterStep1A(char *aBuf, int *pnBuf){\n  int nBuf = *pnBuf;\n  if( aBuf[nBuf-1]=='s' ){\n    if( aBuf[nBuf-2]=='e' ){\n      if( (nBuf>4 && aBuf[nBuf-4]=='s' && aBuf[nBuf-3]=='s') \n       || (nBuf>3 && aBuf[nBuf-3]=='i' )\n      ){\n        *pnBuf = nBuf-2;\n      }else{\n        *pnBuf = nBuf-1;\n      }\n    }\n    else if( aBuf[nBuf-2]!='s' ){\n      *pnBuf = nBuf-1;\n    }\n  }\n}\n\nstatic int fts5PorterCb(\n  void *pCtx, \n  int tflags,\n  const char *pToken, \n  int nToken, \n  int iStart, \n  int iEnd\n){\n  PorterContext *p = (PorterContext*)pCtx;\n\n  char *aBuf;\n  int nBuf;\n\n  if( nToken>FTS5_PORTER_MAX_TOKEN || nToken<3 ) goto pass_through;\n  aBuf = p->aBuf;\n  nBuf = nToken;\n  memcpy(aBuf, pToken, nBuf);\n\n  /* Step 1. */\n  fts5PorterStep1A(aBuf, &nBuf);\n  if( fts5PorterStep1B(aBuf, &nBuf) ){\n    if( fts5PorterStep1B2(aBuf, &nBuf)==0 ){\n      char c = aBuf[nBuf-1];\n      if( fts5PorterIsVowel(c, 0)==0 \n       && c!='l' && c!='s' && c!='z' && c==aBuf[nBuf-2] \n      ){\n        nBuf--;\n      }else if( fts5Porter_MEq1(aBuf, nBuf) && fts5Porter_Ostar(aBuf, nBuf) ){\n        aBuf[nBuf++] = 'e';\n      }\n    }\n  }\n\n  /* Step 1C. */\n  if( aBuf[nBuf-1]=='y' && fts5Porter_Vowel(aBuf, nBuf-1) ){\n    aBuf[nBuf-1] = 'i';\n  }\n\n  /* Steps 2 through 4. */\n  fts5PorterStep2(aBuf, &nBuf);\n  fts5PorterStep3(aBuf, &nBuf);\n  fts5PorterStep4(aBuf, &nBuf);\n\n  /* Step 5a. */\n  assert( nBuf>0 );\n  if( aBuf[nBuf-1]=='e' ){\n    if( fts5Porter_MGt1(aBuf, nBuf-1) \n     || (fts5Porter_MEq1(aBuf, nBuf-1) && !fts5Porter_Ostar(aBuf, nBuf-1))\n    ){\n      nBuf--;\n    }\n  }\n\n  /* Step 5b. */\n  if( nBuf>1 && aBuf[nBuf-1]=='l' \n   && aBuf[nBuf-2]=='l' && fts5Porter_MGt1(aBuf, nBuf-1) \n  ){\n    nBuf--;\n  }\n\n  return p->xToken(p->pCtx, tflags, aBuf, nBuf, iStart, iEnd);\n\n pass_through:\n  return p->xToken(p->pCtx, tflags, pToken, nToken, iStart, iEnd);\n}\n\n/*\n** Tokenize using the porter tokenizer.\n*/\nstatic int fts5PorterTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int flags,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  PorterTokenizer *p = (PorterTokenizer*)pTokenizer;\n  PorterContext sCtx;\n  sCtx.xToken = xToken;\n  sCtx.pCtx = pCtx;\n  sCtx.aBuf = p->aBuf;\n  return p->tokenizer.xTokenize(\n      p->pTokenizer, (void*)&sCtx, flags, pText, nText, fts5PorterCb\n  );\n}\n\n/*\n** Register all built-in tokenizers with FTS5.\n*/\nint sqlite3Fts5TokenizerInit(fts5_api *pApi){\n  struct BuiltinTokenizer {\n    const char *zName;\n    fts5_tokenizer x;\n  } aBuiltin[] = {\n    { \"unicode61\", {fts5UnicodeCreate, fts5UnicodeDelete, fts5UnicodeTokenize}},\n    { \"ascii\",     {fts5AsciiCreate, fts5AsciiDelete, fts5AsciiTokenize }},\n    { \"porter\",    {fts5PorterCreate, fts5PorterDelete, fts5PorterTokenize }},\n  };\n  \n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateTokenizer(pApi,\n        aBuiltin[i].zName,\n        (void*)pApi,\n        &aBuiltin[i].x,\n        0\n    );\n  }\n\n  return rc;\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_unicode2.c",
    "content": "/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n\n#include <assert.h>\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nint sqlite3Fts5UnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  static const unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,\n    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,\n    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,\n    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,\n    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,\n    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,\n    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,\n    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,\n    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,\n    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,\n    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,\n    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,\n    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,\n    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,\n    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,\n    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,\n    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,\n    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,\n    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,\n    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,\n    0x380400F0,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int fts5_remove_diacritic(int c){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3896,  3912,  3928, \n     3968,  4008,  4040,  4106,  4138,  4170,  4202,  4234, \n     4266,  4296,  4312,  4344,  4408,  4424,  4472,  4504, \n     6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529, \n    61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, \n    61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, \n    62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, \n    62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, \n    62924, 63050, 63082, 63274, 63390, \n  };\n  char aChar[] = {\n    '\\0', 'a',  'c',  'e',  'i',  'n',  'o',  'u',  'y',  'y',  'a',  'c',  \n    'd',  'e',  'e',  'g',  'h',  'i',  'j',  'k',  'l',  'n',  'o',  'r',  \n    's',  't',  'u',  'u',  'w',  'y',  'z',  'o',  'u',  'a',  'i',  'o',  \n    'u',  'g',  'k',  'o',  'j',  'g',  'n',  'a',  'e',  'i',  'o',  'r',  \n    'u',  's',  't',  'h',  'a',  'e',  'o',  'y',  '\\0', '\\0', '\\0', '\\0', \n    '\\0', '\\0', '\\0', '\\0', 'a',  'b',  'd',  'd',  'e',  'f',  'g',  'h',  \n    'h',  'i',  'k',  'l',  'l',  'm',  'n',  'p',  'r',  'r',  's',  't',  \n    'u',  'v',  'w',  'w',  'x',  'y',  'z',  'h',  't',  'w',  'y',  'a',  \n    'e',  'i',  'o',  'u',  'y',  \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nint sqlite3Fts5UnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & (1 << (c-768))) :\n      (mask1 & (1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nint sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( bRemoveDiacritic ) ret = fts5_remove_diacritic(ret);\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_varint.c",
    "content": "/*\n** 2015 May 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Routines for varint serialization and deserialization.\n*/\n\n\n#include \"fts5Int.h\"\n\n/*\n** This is a copy of the sqlite3GetVarint32() routine from the SQLite core.\n** Except, this version does handle the single byte case that the core\n** version depends on being handled before its function is called.\n*/\nint sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case. Overwhelmingly the most common. */\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n  {\n    u64 v64;\n    u8 n;\n    p -= 2;\n    n = sqlite3Fts5GetVarint(p, &v64);\n    *v = (u32)v64;\n    assert( n>3 && n<=9 );\n    return n;\n  }\n}\n\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nu8 sqlite3Fts5GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above in calc'ing s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n#ifdef SQLITE_NOINLINE\n# define FTS5_NOINLINE SQLITE_NOINLINE\n#else\n# define FTS5_NOINLINE\n#endif\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int FTS5_NOINLINE fts5PutVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\n\nint sqlite3Fts5PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return fts5PutVarint64(p,v);\n}\n\n\nint sqlite3Fts5GetVarintLen(u32 iVal){\n#if 0\n  if( iVal<(1 << 7 ) ) return 1;\n#endif\n  assert( iVal>=(1 << 7) );\n  if( iVal<(1 << 14) ) return 2;\n  if( iVal<(1 << 21) ) return 3;\n  if( iVal<(1 << 28) ) return 4;\n  return 5;\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5_vocab.c",
    "content": "/*\n** 2015 May 08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite virtual table module implementing direct access to an\n** existing FTS5 index. The module may create several different types of \n** tables:\n**\n** col:\n**     CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));\n**\n**   One row for each term/column combination. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term within column $col. Field $cnt is set to the total number of \n**   instances of term $term in column $col (in any row of the fts5 table). \n**\n** row:\n**     CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));\n**\n**   One row for each term in the database. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term. Field $cnt is set to the total number of instances of term \n**   $term in the database.\n**\n** instance:\n**     CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));\n**\n**   One row for each term instance in the database. \n*/\n\n\n#include \"fts5Int.h\"\n\n\ntypedef struct Fts5VocabTable Fts5VocabTable;\ntypedef struct Fts5VocabCursor Fts5VocabCursor;\n\nstruct Fts5VocabTable {\n  sqlite3_vtab base;\n  char *zFts5Tbl;                 /* Name of fts5 table */\n  char *zFts5Db;                  /* Db containing fts5 table */\n  sqlite3 *db;                    /* Database handle */\n  Fts5Global *pGlobal;            /* FTS5 global object for this database */\n  int eType;                      /* FTS5_VOCAB_COL, ROW or INSTANCE */\n};\n\nstruct Fts5VocabCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Statement holding lock on pIndex */\n  Fts5Index *pIndex;              /* Associated FTS5 index */\n\n  int bEof;                       /* True if this cursor is at EOF */\n  Fts5IndexIter *pIter;           /* Term/rowid iterator object */\n\n  int nLeTerm;                    /* Size of zLeTerm in bytes */\n  char *zLeTerm;                  /* (term <= $zLeTerm) paramater, or NULL */\n\n  /* These are used by 'col' tables only */\n  Fts5Config *pConfig;            /* Fts5 table configuration */\n  int iCol;\n  i64 *aCnt;\n  i64 *aDoc;\n\n  /* Output values used by all tables. */\n  i64 rowid;                      /* This table's current rowid value */\n  Fts5Buffer term;                /* Current value of 'term' column */\n\n  /* Output values Used by 'instance' tables only */\n  i64 iInstPos;\n  int iInstOff;\n};\n\n#define FTS5_VOCAB_COL      0\n#define FTS5_VOCAB_ROW      1\n#define FTS5_VOCAB_INSTANCE 2\n\n#define FTS5_VOCAB_COL_SCHEMA  \"term, col, doc, cnt\"\n#define FTS5_VOCAB_ROW_SCHEMA  \"term, doc, cnt\"\n#define FTS5_VOCAB_INST_SCHEMA \"term, doc, col, offset\"\n\n/*\n** Bits for the mask used as the idxNum value by xBestIndex/xFilter.\n*/\n#define FTS5_VOCAB_TERM_EQ 0x01\n#define FTS5_VOCAB_TERM_GE 0x02\n#define FTS5_VOCAB_TERM_LE 0x04\n\n\n/*\n** Translate a string containing an fts5vocab table type to an \n** FTS5_VOCAB_XXX constant. If successful, set *peType to the output\n** value and return SQLITE_OK. Otherwise, set *pzErr to an error message\n** and return SQLITE_ERROR.\n*/\nstatic int fts5VocabTableType(const char *zType, char **pzErr, int *peType){\n  int rc = SQLITE_OK;\n  char *zCopy = sqlite3Fts5Strndup(&rc, zType, -1);\n  if( rc==SQLITE_OK ){\n    sqlite3Fts5Dequote(zCopy);\n    if( sqlite3_stricmp(zCopy, \"col\")==0 ){\n      *peType = FTS5_VOCAB_COL;\n    }else\n\n    if( sqlite3_stricmp(zCopy, \"row\")==0 ){\n      *peType = FTS5_VOCAB_ROW;\n    }else\n    if( sqlite3_stricmp(zCopy, \"instance\")==0 ){\n      *peType = FTS5_VOCAB_INSTANCE;\n    }else\n    {\n      *pzErr = sqlite3_mprintf(\"fts5vocab: unknown table type: %Q\", zCopy);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3_free(zCopy);\n  }\n\n  return rc;\n}\n\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5VocabDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5VocabDestroyMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5vocab\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**\n** then:\n**\n**   argv[3]   -> name of fts5 table\n**   argv[4]   -> type of fts5vocab table\n**\n** or, for tables in the TEMP schema only.\n**\n**   argv[3]   -> name of fts5 tables database\n**   argv[4]   -> name of fts5 table\n**   argv[5]   -> type of fts5vocab table\n*/\nstatic int fts5VocabInitVtab(\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Pointer to Fts5Global object */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  const char *azSchema[] = { \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_COL_SCHEMA  \")\", \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_ROW_SCHEMA  \")\",\n    \"CREATE TABlE vocab(\" FTS5_VOCAB_INST_SCHEMA \")\"\n  };\n\n  Fts5VocabTable *pRet = 0;\n  int rc = SQLITE_OK;             /* Return code */\n  int bDb;\n\n  bDb = (argc==6 && strlen(argv[1])==4 && memcmp(\"temp\", argv[1], 4)==0);\n\n  if( argc!=5 && bDb==0 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of vtable arguments\");\n    rc = SQLITE_ERROR;\n  }else{\n    int nByte;                      /* Bytes of space to allocate */\n    const char *zDb = bDb ? argv[3] : argv[1];\n    const char *zTab = bDb ? argv[4] : argv[3];\n    const char *zType = bDb ? argv[5] : argv[4];\n    int nDb = (int)strlen(zDb)+1; \n    int nTab = (int)strlen(zTab)+1;\n    int eType = 0;\n    \n    rc = fts5VocabTableType(zType, pzErr, &eType);\n    if( rc==SQLITE_OK ){\n      assert( eType>=0 && eType<ArraySize(azSchema) );\n      rc = sqlite3_declare_vtab(db, azSchema[eType]);\n    }\n\n    nByte = sizeof(Fts5VocabTable) + nDb + nTab;\n    pRet = sqlite3Fts5MallocZero(&rc, nByte);\n    if( pRet ){\n      pRet->pGlobal = (Fts5Global*)pAux;\n      pRet->eType = eType;\n      pRet->db = db;\n      pRet->zFts5Tbl = (char*)&pRet[1];\n      pRet->zFts5Db = &pRet->zFts5Tbl[nTab];\n      memcpy(pRet->zFts5Tbl, zTab, nTab);\n      memcpy(pRet->zFts5Db, zDb, nDb);\n      sqlite3Fts5Dequote(pRet->zFts5Tbl);\n      sqlite3Fts5Dequote(pRet->zFts5Db);\n    }\n  }\n\n  *ppVTab = (sqlite3_vtab*)pRet;\n  return rc;\n}\n\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5VocabInitVtab().\n*/\nstatic int fts5VocabConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5VocabCreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/* \n** Implementation of the xBestIndex method.\n**\n** Only constraints of the form:\n**\n**     term <= ?\n**     term == ?\n**     term >= ?\n**\n** are interpreted. Less-than and less-than-or-equal are treated \n** identically, as are greater-than and greater-than-or-equal.\n*/\nstatic int fts5VocabBestIndexMethod(\n  sqlite3_vtab *pUnused,\n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iTermEq = -1;\n  int iTermGe = -1;\n  int iTermLe = -1;\n  int idxNum = 0;\n  int nArg = 0;\n\n  UNUSED_PARAM(pUnused);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    if( p->usable==0 ) continue;\n    if( p->iColumn==0 ){          /* term column */\n      if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ) iTermEq = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LE ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LT ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GE ) iTermGe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GT ) iTermGe = i;\n    }\n  }\n\n  if( iTermEq>=0 ){\n    idxNum |= FTS5_VOCAB_TERM_EQ;\n    pInfo->aConstraintUsage[iTermEq].argvIndex = ++nArg;\n    pInfo->estimatedCost = 100;\n  }else{\n    pInfo->estimatedCost = 1000000;\n    if( iTermGe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_GE;\n      pInfo->aConstraintUsage[iTermGe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n    if( iTermLe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_LE;\n      pInfo->aConstraintUsage[iTermLe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n  }\n\n  /* This virtual table always delivers results in ascending order of\n  ** the \"term\" column (column 0). So if the user has requested this\n  ** specifically - \"ORDER BY term\" or \"ORDER BY term ASC\" - set the\n  ** sqlite3_index_info.orderByConsumed flag to tell the core the results\n  ** are already in sorted order.  */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  pInfo->idxNum = idxNum;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5VocabOpenMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_vtab_cursor **ppCsr\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;\n  Fts5Index *pIndex = 0;\n  Fts5Config *pConfig = 0;\n  Fts5VocabCursor *pCsr = 0;\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql = 0;\n\n  zSql = sqlite3Fts5Mprintf(&rc,\n      \"SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\",\n      pTab->zFts5Tbl, pTab->zFts5Db, pTab->zFts5Tbl, pTab->zFts5Tbl\n  );\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0);\n  }\n  sqlite3_free(zSql);\n  assert( rc==SQLITE_OK || pStmt==0 );\n  if( rc==SQLITE_ERROR ) rc = SQLITE_OK;\n\n  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    i64 iId = sqlite3_column_int64(pStmt, 0);\n    pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig);\n  }\n\n  if( rc==SQLITE_OK && pIndex==0 ){\n    rc = sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( rc==SQLITE_OK ){\n      pVTab->zErrMsg = sqlite3_mprintf(\n          \"no such fts5 table: %s.%s\", pTab->zFts5Db, pTab->zFts5Tbl\n      );\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor);\n    pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n\n  if( pCsr ){\n    pCsr->pIndex = pIndex;\n    pCsr->pStmt = pStmt;\n    pCsr->pConfig = pConfig;\n    pCsr->aCnt = (i64*)&pCsr[1];\n    pCsr->aDoc = &pCsr->aCnt[pConfig->nCol];\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic void fts5VocabResetCursor(Fts5VocabCursor *pCsr){\n  pCsr->rowid = 0;\n  sqlite3Fts5IterClose(pCsr->pIter);\n  pCsr->pIter = 0;\n  sqlite3_free(pCsr->zLeTerm);\n  pCsr->nLeTerm = -1;\n  pCsr->zLeTerm = 0;\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5VocabCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  fts5VocabResetCursor(pCsr);\n  sqlite3Fts5BufferFree(&pCsr->term);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts5VocabInstanceNewTerm(Fts5VocabCursor *pCsr){\n  int rc = SQLITE_OK;\n  \n  if( sqlite3Fts5IterEof(pCsr->pIter) ){\n    pCsr->bEof = 1;\n  }else{\n    const char *zTerm;\n    int nTerm;\n    zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n    if( pCsr->nLeTerm>=0 ){\n      int nCmp = MIN(nTerm, pCsr->nLeTerm);\n      int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n      if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n        pCsr->bEof = 1;\n      }\n    }\n\n    sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n  }\n  return rc;\n}\n\nstatic int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){\n  int eDetail = pCsr->pConfig->eDetail;\n  int rc = SQLITE_OK;\n  Fts5IndexIter *pIter = pCsr->pIter;\n  i64 *pp = &pCsr->iInstPos;\n  int *po = &pCsr->iInstOff;\n  \n  while( eDetail==FTS5_DETAIL_NONE\n      || sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp) \n  ){\n    pCsr->iInstPos = 0;\n    pCsr->iInstOff = 0;\n\n    rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n    if( rc==SQLITE_OK ){\n      rc = fts5VocabInstanceNewTerm(pCsr);\n      if( eDetail==FTS5_DETAIL_NONE ) break;\n    }\n    if( rc ){\n      pCsr->bEof = 1;\n      break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance the cursor to the next row in the table.\n*/\nstatic int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  int nCol = pCsr->pConfig->nCol;\n\n  pCsr->rowid++;\n\n  if( pTab->eType==FTS5_VOCAB_INSTANCE ){\n    return fts5VocabInstanceNext(pCsr);\n  }\n\n  if( pTab->eType==FTS5_VOCAB_COL ){\n    for(pCsr->iCol++; pCsr->iCol<nCol; pCsr->iCol++){\n      if( pCsr->aDoc[pCsr->iCol] ) break;\n    }\n  }\n\n  if( pTab->eType!=FTS5_VOCAB_COL || pCsr->iCol>=nCol ){\n    if( sqlite3Fts5IterEof(pCsr->pIter) ){\n      pCsr->bEof = 1;\n    }else{\n      const char *zTerm;\n      int nTerm;\n\n      zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n      if( pCsr->nLeTerm>=0 ){\n        int nCmp = MIN(nTerm, pCsr->nLeTerm);\n        int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n        if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n          pCsr->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n\n      sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n      memset(pCsr->aCnt, 0, nCol * sizeof(i64));\n      memset(pCsr->aDoc, 0, nCol * sizeof(i64));\n      pCsr->iCol = 0;\n\n      assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );\n      while( rc==SQLITE_OK ){\n        int eDetail = pCsr->pConfig->eDetail;\n        const u8 *pPos; int nPos;   /* Position list */\n        i64 iPos = 0;               /* 64-bit position read from poslist */\n        int iOff = 0;               /* Current offset within position list */\n\n        pPos = pCsr->pIter->pData;\n        nPos = pCsr->pIter->nData;\n\n        switch( pTab->eType ){\n          case FTS5_VOCAB_ROW:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                pCsr->aCnt[0]++;\n              }\n            }\n            pCsr->aDoc[0]++;\n            break;\n\n          case FTS5_VOCAB_COL:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              int iCol = -1;\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                int ii = FTS5_POS2COLUMN(iPos);\n                pCsr->aCnt[ii]++;\n                if( iCol!=ii ){\n                  if( ii>=nCol ){\n                    rc = FTS5_CORRUPT;\n                    break;\n                  }\n                  pCsr->aDoc[ii]++;\n                  iCol = ii;\n                }\n              }\n            }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){\n                assert_nc( iPos>=0 && iPos<nCol );\n                if( iPos>=nCol ){\n                  rc = FTS5_CORRUPT;\n                  break;\n                }\n                pCsr->aDoc[iPos]++;\n              }\n            }else{\n              assert( eDetail==FTS5_DETAIL_NONE );\n              pCsr->aDoc[0]++;\n            }\n            break;\n\n          default:\n            assert( pTab->eType==FTS5_VOCAB_INSTANCE );\n            break;\n        }\n\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n        }\n        if( pTab->eType==FTS5_VOCAB_INSTANCE ) break;\n\n        if( rc==SQLITE_OK ){\n          zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n          if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){\n            break;\n          }\n          if( sqlite3Fts5IterEof(pCsr->pIter) ) break;\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){\n    while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;\n    assert( pCsr->iCol<pCsr->pConfig->nCol );\n  }\n  return rc;\n}\n\n/*\n** This is the xFilter implementation for the virtual table.\n*/\nstatic int fts5VocabFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nUnused,                    /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eType = pTab->eType;\n  int rc = SQLITE_OK;\n\n  int iVal = 0;\n  int f = FTS5INDEX_QUERY_SCAN;\n  const char *zTerm = 0;\n  int nTerm = 0;\n\n  sqlite3_value *pEq = 0;\n  sqlite3_value *pGe = 0;\n  sqlite3_value *pLe = 0;\n\n  UNUSED_PARAM2(zUnused, nUnused);\n\n  fts5VocabResetCursor(pCsr);\n  if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];\n\n  if( pEq ){\n    zTerm = (const char *)sqlite3_value_text(pEq);\n    nTerm = sqlite3_value_bytes(pEq);\n    f = 0;\n  }else{\n    if( pGe ){\n      zTerm = (const char *)sqlite3_value_text(pGe);\n      nTerm = sqlite3_value_bytes(pGe);\n    }\n    if( pLe ){\n      const char *zCopy = (const char *)sqlite3_value_text(pLe);\n      pCsr->nLeTerm = sqlite3_value_bytes(pLe);\n      pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);\n      if( pCsr->zLeTerm==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1);\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);\n  }\n  if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){\n    rc = fts5VocabInstanceNewTerm(pCsr);\n  }\n  if( rc==SQLITE_OK \n   && !pCsr->bEof \n   && (eType!=FTS5_VOCAB_INSTANCE || pCsr->pConfig->eDetail!=FTS5_DETAIL_NONE)\n  ){\n    rc = fts5VocabNextMethod(pCursor);\n  }\n\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5VocabEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  return pCsr->bEof;\n}\n\nstatic int fts5VocabColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eDetail = pCsr->pConfig->eDetail;\n  int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;\n  i64 iVal = 0;\n\n  if( iCol==0 ){\n    sqlite3_result_text(\n        pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT\n    );\n  }else if( eType==FTS5_VOCAB_COL ){\n    assert( iCol==1 || iCol==2 || iCol==3 );\n    if( iCol==1 ){\n      if( eDetail!=FTS5_DETAIL_NONE ){\n        const char *z = pCsr->pConfig->azCol[pCsr->iCol];\n        sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n      }\n    }else if( iCol==2 ){\n      iVal = pCsr->aDoc[pCsr->iCol];\n    }else{\n      iVal = pCsr->aCnt[pCsr->iCol];\n    }\n  }else if( eType==FTS5_VOCAB_ROW ){\n    assert( iCol==1 || iCol==2 );\n    if( iCol==1 ){\n      iVal = pCsr->aDoc[0];\n    }else{\n      iVal = pCsr->aCnt[0];\n    }\n  }else{\n    assert( eType==FTS5_VOCAB_INSTANCE );\n    switch( iCol ){\n      case 1:\n        sqlite3_result_int64(pCtx, pCsr->pIter->iRowid);\n        break;\n      case 2: {\n        int ii = -1;\n        if( eDetail==FTS5_DETAIL_FULL ){\n          ii = FTS5_POS2COLUMN(pCsr->iInstPos);\n        }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n          ii = (int)pCsr->iInstPos;\n        }\n        if( ii>=0 && ii<pCsr->pConfig->nCol ){\n          const char *z = pCsr->pConfig->azCol[ii];\n          sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n        }\n        break;\n      }\n      default: {\n        assert( iCol==3 );\n        if( eDetail==FTS5_DETAIL_FULL ){\n          int ii = FTS5_POS2OFFSET(pCsr->iInstPos);\n          sqlite3_result_int(pCtx, ii);\n        }\n        break;\n      }\n    }\n  }\n\n  if( iVal>0 ) sqlite3_result_int64(pCtx, iVal);\n  return SQLITE_OK;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5VocabRowidMethod(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite_int64 *pRowid\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  *pRowid = pCsr->rowid;\n  return SQLITE_OK;\n}\n\nint sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){\n  static const sqlite3_module fts5Vocab = {\n    /* iVersion      */ 2,\n    /* xCreate       */ fts5VocabCreateMethod,\n    /* xConnect      */ fts5VocabConnectMethod,\n    /* xBestIndex    */ fts5VocabBestIndexMethod,\n    /* xDisconnect   */ fts5VocabDisconnectMethod,\n    /* xDestroy      */ fts5VocabDestroyMethod,\n    /* xOpen         */ fts5VocabOpenMethod,\n    /* xClose        */ fts5VocabCloseMethod,\n    /* xFilter       */ fts5VocabFilterMethod,\n    /* xNext         */ fts5VocabNextMethod,\n    /* xEof          */ fts5VocabEofMethod,\n    /* xColumn       */ fts5VocabColumnMethod,\n    /* xRowid        */ fts5VocabRowidMethod,\n    /* xUpdate       */ 0,\n    /* xBegin        */ 0,\n    /* xSync         */ 0,\n    /* xCommit       */ 0,\n    /* xRollback     */ 0,\n    /* xFindFunction */ 0,\n    /* xRename       */ 0,\n    /* xSavepoint    */ 0,\n    /* xRelease      */ 0,\n    /* xRollbackTo   */ 0,\n  };\n  void *p = (void*)pGlobal;\n\n  return sqlite3_create_module_v2(db, \"fts5vocab\", &fts5Vocab, p, 0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/fts5parse.y",
    "content": "/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n// All token codes are small integers with #defines that begin with \"TK_\"\n%token_prefix FTS5_\n\n// The type of the data attached to each token is Token.  This is also the\n// default type for non-terminals.\n//\n%token_type {Fts5Token}\n%default_type {Fts5Token}\n\n// The generated parser function takes a 4th argument as follows:\n%extra_argument {Fts5Parse *pParse}\n\n// This code runs whenever there is a syntax error\n//\n%syntax_error {\n  UNUSED_PARAM(yymajor); /* Silence a compiler warning */\n  sqlite3Fts5ParseError(\n    pParse, \"fts5: syntax error near \\\"%.*s\\\"\",TOKEN.n,TOKEN.p\n  );\n}\n%stack_overflow {\n  sqlite3Fts5ParseError(pParse, \"fts5: parser stack overflow\");\n}\n\n// The name of the generated procedure that implements the parser\n// is as follows:\n%name sqlite3Fts5Parser\n\n// The following text is included near the beginning of the C source\n// code file that implements the parser.\n//\n%include {\n#include \"fts5Int.h\"\n#include \"fts5parse.h\"\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define YYNOERRORRECOVERY 1\n\n/*\n** Make yytestcase() the same as testcase()\n*/\n#define yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define YYPARSEFREENOTNULL 1\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define YYMALLOCARGTYPE  u64\n\n} // end %include\n\n%left OR.\n%left AND.\n%left NOT.\n%left TERM.\n%left COLON.\n\ninput ::= expr(X). { sqlite3Fts5ParseFinished(pParse, X); }\n%destructor input { (void)pParse; }\n\n%type cnearset    {Fts5ExprNode*}\n%type expr        {Fts5ExprNode*}\n%type exprlist    {Fts5ExprNode*}\n%destructor cnearset { sqlite3Fts5ParseNodeFree($$); }\n%destructor expr     { sqlite3Fts5ParseNodeFree($$); }\n%destructor exprlist { sqlite3Fts5ParseNodeFree($$); }\n\n%type colset {Fts5Colset*}\n%destructor colset { sqlite3_free($$); }\n%type colsetlist {Fts5Colset*}\n%destructor colsetlist { sqlite3_free($$); }\n\ncolset(A) ::= MINUS LCP colsetlist(X) RCP. { \n    A = sqlite3Fts5ParseColsetInvert(pParse, X);\n}\ncolset(A) ::= LCP colsetlist(X) RCP. { A = X; }\ncolset(A) ::= STRING(X). {\n  A = sqlite3Fts5ParseColset(pParse, 0, &X);\n}\ncolset(A) ::= MINUS STRING(X). {\n  A = sqlite3Fts5ParseColset(pParse, 0, &X);\n  A = sqlite3Fts5ParseColsetInvert(pParse, A);\n}\n\ncolsetlist(A) ::= colsetlist(Y) STRING(X). { \n  A = sqlite3Fts5ParseColset(pParse, Y, &X); }\ncolsetlist(A) ::= STRING(X). { \n  A = sqlite3Fts5ParseColset(pParse, 0, &X); \n}\n\nexpr(A) ::= expr(X) AND expr(Y). {\n  A = sqlite3Fts5ParseNode(pParse, FTS5_AND, X, Y, 0);\n}\nexpr(A) ::= expr(X) OR expr(Y). {\n  A = sqlite3Fts5ParseNode(pParse, FTS5_OR, X, Y, 0);\n}\nexpr(A) ::= expr(X) NOT expr(Y). {\n  A = sqlite3Fts5ParseNode(pParse, FTS5_NOT, X, Y, 0);\n}\n\nexpr(A) ::= colset(X) COLON LP expr(Y) RP. {\n  sqlite3Fts5ParseSetColset(pParse, Y, X);\n  A = Y;\n}\nexpr(A) ::= LP expr(X) RP. {A = X;}\nexpr(A) ::= exprlist(X).   {A = X;}\n\nexprlist(A) ::= cnearset(X). {A = X;}\nexprlist(A) ::= exprlist(X) cnearset(Y). {\n  A = sqlite3Fts5ParseImplicitAnd(pParse, X, Y);\n}\n\ncnearset(A) ::= nearset(X). { \n  A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, X); \n}\ncnearset(A) ::= colset(X) COLON nearset(Y). { \n  A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, Y); \n  sqlite3Fts5ParseSetColset(pParse, A, X);\n}\n\n\n%type nearset     {Fts5ExprNearset*}\n%type nearphrases {Fts5ExprNearset*}\n%destructor nearset { sqlite3Fts5ParseNearsetFree($$); }\n%destructor nearphrases { sqlite3Fts5ParseNearsetFree($$); }\n\nnearset(A) ::= phrase(X). { A = sqlite3Fts5ParseNearset(pParse, 0, X); }\nnearset(A) ::= STRING(X) LP nearphrases(Y) neardist_opt(Z) RP. {\n  sqlite3Fts5ParseNear(pParse, &X);\n  sqlite3Fts5ParseSetDistance(pParse, Y, &Z);\n  A = Y;\n}\n\nnearphrases(A) ::= phrase(X). { \n  A = sqlite3Fts5ParseNearset(pParse, 0, X); \n}\nnearphrases(A) ::= nearphrases(X) phrase(Y). {\n  A = sqlite3Fts5ParseNearset(pParse, X, Y);\n}\n\n/*\n** The optional \", <integer>\" at the end of the NEAR() arguments.\n*/\nneardist_opt(A) ::= . { A.p = 0; A.n = 0; }\nneardist_opt(A) ::= COMMA STRING(X). { A = X; }\n\n/*\n** A phrase. A set of primitives connected by \"+\" operators. Examples:\n**\n**     \"the\" + \"quick brown\" + fo *\n**     \"the quick brown fo\" *\n**     the+quick+brown+fo*\n*/\n%type phrase {Fts5ExprPhrase*}\n%destructor phrase { sqlite3Fts5ParsePhraseFree($$); }\n\nphrase(A) ::= phrase(X) PLUS STRING(Y) star_opt(Z). { \n  A = sqlite3Fts5ParseTerm(pParse, X, &Y, Z);\n}\nphrase(A) ::= STRING(Y) star_opt(Z). { \n  A = sqlite3Fts5ParseTerm(pParse, 0, &Y, Z);\n}\n\n/*\n** Optional \"*\" character.\n*/\n%type star_opt {int}\n\nstar_opt(A) ::= STAR. { A = 1; }\nstar_opt(A) ::= . { A = 0; }\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/mkportersteps.tcl",
    "content": "#\n# 2014 Jun 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#-------------------------------------------------------------------------\n#\n# This script generates the implementations of the following C functions,\n# which are part of the porter tokenizer implementation:\n#\n#   static int fts5PorterStep1B(char *aBuf, int *pnBuf);\n#   static int fts5PorterStep1B2(char *aBuf, int *pnBuf);\n#   static int fts5PorterStep2(char *aBuf, int *pnBuf);\n#   static int fts5PorterStep3(char *aBuf, int *pnBuf);\n#   static int fts5PorterStep4(char *aBuf, int *pnBuf);\n#\n\nset O(Step1B2) {\n  { at  {} ate 1 }\n  { bl  {} ble 1 }\n  { iz  {} ize 1 }\n}\n\nset O(Step1B) {\n  { \"eed\"  fts5Porter_MGt0  \"ee\" 0 }\n  { \"ed\"   fts5Porter_Vowel \"\"   1 }\n  { \"ing\"  fts5Porter_Vowel \"\"   1 }\n}\n\nset O(Step2) {\n  { \"ational\" fts5Porter_MGt0 \"ate\" } \n  { \"tional\"  fts5Porter_MGt0 \"tion\" } \n  { \"enci\"    fts5Porter_MGt0 \"ence\" } \n  { \"anci\"    fts5Porter_MGt0 \"ance\" } \n  { \"izer\"    fts5Porter_MGt0 \"ize\" } \n  { \"logi\"    fts5Porter_MGt0 \"log\" }\n  { \"bli\"     fts5Porter_MGt0 \"ble\" }\n  { \"alli\"    fts5Porter_MGt0 \"al\" } \n  { \"entli\"   fts5Porter_MGt0 \"ent\" } \n  { \"eli\"     fts5Porter_MGt0 \"e\" } \n  { \"ousli\"   fts5Porter_MGt0 \"ous\" } \n  { \"ization\" fts5Porter_MGt0 \"ize\" } \n  { \"ation\"   fts5Porter_MGt0 \"ate\" } \n  { \"ator\"    fts5Porter_MGt0 \"ate\" } \n  { \"alism\"   fts5Porter_MGt0 \"al\" } \n  { \"iveness\" fts5Porter_MGt0 \"ive\" } \n  { \"fulness\" fts5Porter_MGt0 \"ful\" } \n  { \"ousness\" fts5Porter_MGt0 \"ous\" } \n  { \"aliti\"   fts5Porter_MGt0 \"al\" } \n  { \"iviti\"   fts5Porter_MGt0 \"ive\" } \n  { \"biliti\"  fts5Porter_MGt0 \"ble\" } \n}\n\nset O(Step3) {\n  { \"icate\" fts5Porter_MGt0 \"ic\" } \n  { \"ative\" fts5Porter_MGt0 \"\" } \n  { \"alize\" fts5Porter_MGt0 \"al\" } \n  { \"iciti\" fts5Porter_MGt0 \"ic\" } \n  { \"ical\" fts5Porter_MGt0 \"ic\" } \n  { \"ful\" fts5Porter_MGt0 \"\" } \n  { \"ness\" fts5Porter_MGt0 \"\" } \n}\n\nset O(Step4) {\n  { \"al\" fts5Porter_MGt1 \"\" } \n  { \"ance\" fts5Porter_MGt1 \"\" } \n  { \"ence\" fts5Porter_MGt1 \"\" } \n  { \"er\" fts5Porter_MGt1 \"\" } \n  { \"ic\" fts5Porter_MGt1 \"\" } \n  { \"able\" fts5Porter_MGt1 \"\" } \n  { \"ible\" fts5Porter_MGt1 \"\" } \n  { \"ant\" fts5Porter_MGt1 \"\" } \n  { \"ement\" fts5Porter_MGt1 \"\" } \n  { \"ment\" fts5Porter_MGt1 \"\" } \n  { \"ent\" fts5Porter_MGt1 \"\" } \n  { \"ion\" fts5Porter_MGt1_and_S_or_T \"\" } \n  { \"ou\"  fts5Porter_MGt1 \"\" } \n  { \"ism\" fts5Porter_MGt1 \"\" } \n  { \"ate\" fts5Porter_MGt1 \"\" } \n  { \"iti\" fts5Porter_MGt1 \"\" } \n  { \"ous\" fts5Porter_MGt1 \"\" } \n  { \"ive\" fts5Porter_MGt1 \"\" } \n  { \"ize\" fts5Porter_MGt1 \"\" } \n}\n\nproc sort_cb {lhs rhs} {\n  set L [string range [lindex $lhs 0] end-1 end-1]\n  set R [string range [lindex $rhs 0] end-1 end-1]\n  string compare $L $R\n}\n\nproc create_step_function {name data} {\n\n  set T(function) {\nstatic int fts5Porter${name}(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    ${switchbody}\n  }\n  return ret;\n}\n  }\n\n  set T(case) {\n    case '${k}': \n      ${ifstmts}\n      break;\n  }\n\n  set T(if_0_0_0) {\n      if( ${match} ){\n        *pnBuf = nBuf - $n;\n      }\n  }\n  set T(if_1_0_0) {\n      if( ${match} ){\n        if( ${cond} ){\n          *pnBuf = nBuf - $n;\n        }\n      }\n  }\n  set T(if_0_1_0) {\n      if( ${match} ){\n        ${memcpy}\n        *pnBuf = nBuf - $n + $nRep;\n      }\n  }\n  set T(if_1_1_0) {\n      if( ${match} ){\n        if( ${cond} ){\n          ${memcpy}\n          *pnBuf = nBuf - $n + $nRep;\n        }\n      }\n  }\n  set T(if_1_0_1) {\n      if( ${match} ){\n        if( ${cond} ){\n          *pnBuf = nBuf - $n;\n          ret = 1;\n        }\n      }\n  }\n  set T(if_0_1_1) {\n      if( ${match} ){\n        ${memcpy}\n        *pnBuf = nBuf - $n + $nRep;\n        ret = 1;\n      }\n  }\n  set T(if_1_1_1) {\n      if( ${match} ){\n        if( ${cond} ){\n          ${memcpy}\n          *pnBuf = nBuf - $n + $nRep;\n          ret = 1;\n        }\n      }\n  }\n\n  set switchbody \"\"\n\n  foreach I $data {\n    set k [string range [lindex $I 0] end-1 end-1]\n    lappend aCase($k) $I\n  }\n  foreach k [lsort [array names aCase]] {\n    set ifstmts \"\"\n    foreach I $aCase($k) {\n      set zSuffix [lindex $I 0]         ;# Suffix text for this rule\n      set zRep [lindex $I 2]            ;# Replacement text for rule \n      set xCond [lindex $I 1]           ;# Condition callback (or \"\")\n\n      set n [string length $zSuffix]\n      set nRep [string length $zRep]\n\n      set match \"nBuf>$n && 0==memcmp(\\\"$zSuffix\\\", &aBuf\\[nBuf-$n\\], $n)\"\n      set memcpy \"memcpy(&aBuf\\[nBuf-$n\\], \\\"$zRep\\\", $nRep);\"\n      set cond \"${xCond}(aBuf, nBuf-$n)\"\n\n      set bMemcpy [expr {$nRep>0}]\n      set bCond [expr {$xCond!=\"\"}]\n      set bRet [expr {[llength $I]>3 && [lindex $I 3]}]\n\n      set t $T(if_${bCond}_${bMemcpy}_${bRet})\n      lappend ifstmts [string trim [subst -nocommands $t]]\n    }\n\n    set ifstmts [join $ifstmts \"else \"]\n\n    append switchbody [subst -nocommands $T(case)]\n  }\n\n\n  puts [subst -nocommands $T(function)]\n}\n\n\nputs [string trim {\n/**************************************************************************\n***************************************************************************\n** GENERATED CODE STARTS HERE (mkportersteps.tcl)\n*/\n}]\nforeach step [array names O] {\n  create_step_function $step $O($step)\n}\nputs [string trim {\n/* \n** GENERATED CODE ENDS HERE (mkportersteps.tcl)\n***************************************************************************\n**************************************************************************/\n}]\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5_common.tcl",
    "content": "# 2014 Dec 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. .. test]\n}\nsource $testdir/tester.tcl\n\nifcapable !fts5 {\n  proc return_if_no_fts5 {} {\n    finish_test\n    return -code return\n  }\n  return\n} else {\n  proc return_if_no_fts5 {} {}\n}\n\ncatch { \n  sqlite3_fts5_may_be_corrupt 0 \n  reset_db\n}\n\nproc fts5_test_poslist {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xInstCount]} {incr i} {\n    lappend res [string map {{ } .} [$cmd xInst $i]]\n  }\n  set res\n}\n\nproc fts5_test_poslist2 {cmd} {\n  set res [list]\n\n  for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} {\n    $cmd xPhraseForeach $i c o {\n      lappend res $i.$c.$o\n    }\n  }\n\n  #set res\n  sort_poslist $res\n}\n\nproc fts5_test_collist {cmd} {\n  set res [list]\n\n  for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} {\n    $cmd xPhraseColumnForeach $i c { lappend res $i.$c }\n  }\n\n  set res\n}\n\nproc fts5_test_columnsize {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xColumnCount]} {incr i} {\n    lappend res [$cmd xColumnSize $i]\n  }\n  set res\n}\n\nproc fts5_test_columntext {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xColumnCount]} {incr i} {\n    lappend res [$cmd xColumnText $i]\n  }\n  set res\n}\n\nproc fts5_test_columntotalsize {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xColumnCount]} {incr i} {\n    lappend res [$cmd xColumnTotalSize $i]\n  }\n  set res\n}\n\nproc test_append_token {varname token iStart iEnd} {\n  upvar $varname var\n  lappend var $token\n  return \"SQLITE_OK\"\n}\nproc fts5_test_tokenize {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xColumnCount]} {incr i} {\n    set tokens [list]\n    $cmd xTokenize [$cmd xColumnText $i] [list test_append_token tokens]\n    lappend res $tokens\n  }\n  set res\n}\n\nproc fts5_test_rowcount {cmd} {\n  $cmd xRowCount\n}\n\nproc test_queryphrase_cb {cnt cmd} {\n  upvar $cnt L \n  for {set i 0} {$i < [$cmd xInstCount]} {incr i} {\n    foreach {ip ic io} [$cmd xInst $i] break\n    set A($ic) 1\n  }\n  foreach ic [array names A] {\n    lset L $ic [expr {[lindex $L $ic] + 1}]\n  }\n}\nproc fts5_test_queryphrase {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} {\n    set cnt [list]\n    for {set j 0} {$j < [$cmd xColumnCount]} {incr j} { lappend cnt 0 }\n    $cmd xQueryPhrase $i [list test_queryphrase_cb cnt]\n    lappend res $cnt\n  }\n  set res\n}\n\nproc fts5_test_phrasecount {cmd} {\n  $cmd xPhraseCount\n}\n\nproc fts5_test_all {cmd} {\n  set res [list]\n  lappend res columnsize      [fts5_test_columnsize $cmd]\n  lappend res columntext      [fts5_test_columntext $cmd]\n  lappend res columntotalsize [fts5_test_columntotalsize $cmd]\n  lappend res poslist         [fts5_test_poslist $cmd]\n  lappend res tokenize        [fts5_test_tokenize $cmd]\n  lappend res rowcount        [fts5_test_rowcount $cmd]\n  set res\n}\n\nproc fts5_aux_test_functions {db} {\n  foreach f {\n    fts5_test_columnsize\n    fts5_test_columntext\n    fts5_test_columntotalsize\n    fts5_test_poslist\n    fts5_test_poslist2\n    fts5_test_collist\n    fts5_test_tokenize\n    fts5_test_rowcount\n    fts5_test_all\n\n    fts5_test_queryphrase\n    fts5_test_phrasecount\n  } {\n    sqlite3_fts5_create_function $db $f $f\n  }\n}\n\nproc fts5_segcount {tbl} {\n  set N 0\n  foreach n [fts5_level_segs $tbl] { incr N $n }\n  set N\n}\n\nproc fts5_level_segs {tbl} {\n  set sql \"SELECT fts5_decode(rowid,block) aS r FROM ${tbl}_data WHERE rowid=10\"\n  set ret [list]\n  foreach L [lrange [db one $sql] 1 end] {\n    lappend ret [expr [llength $L] - 3]\n  }\n  set ret\n} \n\nproc fts5_level_segids {tbl} {\n  set sql \"SELECT fts5_decode(rowid,block) aS r FROM ${tbl}_data WHERE rowid=10\"\n  set ret [list]\n  foreach L [lrange [db one $sql] 1 end] {\n    set lvl [list]\n    foreach S [lrange $L 3 end] {\n      regexp {id=([1234567890]*)} $S -> segid\n      lappend lvl $segid\n    }\n    lappend ret $lvl\n  }\n  set ret\n}\n\nproc fts5_rnddoc {n} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc \"x[string map $map [format %.3d [expr int(rand()*1000)]]]\"\n  }\n  set doc\n}\n\n#-------------------------------------------------------------------------\n# Usage:\n#\n#   nearset aCol ?-pc VARNAME? ?-near N? ?-col C? -- phrase1 phrase2...\n#\n# This command is used to test if a document (set of column values) matches\n# the logical equivalent of a single FTS5 NEAR() clump and, if so, return\n# the equivalent of an FTS5 position list.\n#\n# Parameter $aCol is passed a list of the column values for the document\n# to test. Parameters $phrase1 and so on are the phrases.\n#\n# The result is a list of phrase hits. Each phrase hit is formatted as\n# three integers separated by \".\" characters, in the following format:\n#\n#   <phrase number> . <column number> . <token offset>\n#\n# Options:\n#\n#   -near N        (NEAR distance. Default 10)\n#   -col  C        (List of column indexes to match against)\n#   -pc   VARNAME  (variable in caller frame to use for phrase numbering)\n#   -dict VARNAME  (array in caller frame to use for synonyms)\n#\nproc nearset {aCol args} {\n\n  # Process the command line options.\n  #\n  set O(-near) 10\n  set O(-col)  {}\n  set O(-pc)   \"\"\n  set O(-dict) \"\"\n\n  set nOpt [lsearch -exact $args --]\n  if {$nOpt<0} { error \"no -- option\" }\n\n  # Set $lPhrase to be a list of phrases. $nPhrase its length.\n  set lPhrase [lrange $args [expr $nOpt+1] end]\n  set nPhrase [llength $lPhrase]\n\n  foreach {k v} [lrange $args 0 [expr $nOpt-1]] {\n    if {[info exists O($k)]==0} { error \"unrecognized option $k\" }\n    set O($k) $v\n  }\n\n  if {$O(-pc) == \"\"} {\n    set counter 0\n  } else {\n    upvar $O(-pc) counter\n  }\n\n  if {$O(-dict)!=\"\"} { upvar $O(-dict) aDict }\n\n  for {set j 0} {$j < [llength $aCol]} {incr j} {\n    for {set i 0} {$i < $nPhrase} {incr i} { \n      set A($j,$i) [list]\n    }\n  }\n\n  # Loop through each column of the current row.\n  for {set iCol 0} {$iCol < [llength $aCol]} {incr iCol} {\n\n    # If there is a column filter, test whether this column is excluded. If\n    # so, skip to the next iteration of this loop. Otherwise, set zCol to the\n    # column value and nToken to the number of tokens that comprise it.\n    if {$O(-col)!=\"\" && [lsearch $O(-col) $iCol]<0} continue\n    set zCol [lindex $aCol $iCol]\n    set nToken [llength $zCol]\n\n    # Each iteration of the following loop searches a substring of the \n    # column value for phrase matches. The last token of the substring\n    # is token $iLast of the column value. The first token is:\n    #\n    #   iFirst = ($iLast - $O(-near) - 1)\n    #\n    # where $sz is the length of the phrase being searched for. A phrase \n    # counts as matching the substring if its first token lies on or before\n    # $iLast and its last token on or after $iFirst.\n    #\n    # For example, if the query is \"NEAR(a+b c, 2)\" and the column value:\n    #\n    #   \"x x x x A B x x C x\"\n    #    0 1 2 3 4 5 6 7 8 9\"\n    #\n    # when (iLast==8 && iFirst=5) the range will contain both phrases and\n    # so both instances can be added to the output poslists.\n    #\n    set iLast [expr $O(-near) >= $nToken ? $nToken - 1 : $O(-near)]\n    for { } {$iLast < $nToken} {incr iLast} {\n\n      catch { array unset B }\n      \n      for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {\n        set p [lindex $lPhrase $iPhrase]\n        set nPm1 [expr {[llength $p] - 1}]\n        set iFirst [expr $iLast - $O(-near) - [llength $p]]\n\n        for {set i $iFirst} {$i <= $iLast} {incr i} {\n          set lCand [lrange $zCol $i [expr $i+$nPm1]]\n          set bMatch 1\n          foreach tok $p term $lCand {\n            if {[nearset_match aDict $tok $term]==0} { set bMatch 0 ; break }\n          }\n          if {$bMatch} { lappend B($iPhrase) $i }\n        }\n\n        if {![info exists B($iPhrase)]} break\n      }\n\n      if {$iPhrase==$nPhrase} {\n        for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {\n          set A($iCol,$iPhrase) [concat $A($iCol,$iPhrase) $B($iPhrase)]\n          set A($iCol,$iPhrase) [lsort -integer -uniq $A($iCol,$iPhrase)]\n        }\n      }\n    }\n  }\n\n  set res [list]\n  #puts [array names A]\n\n  for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {\n    for {set iCol 0} {$iCol < [llength $aCol]} {incr iCol} {\n      foreach a $A($iCol,$iPhrase) {\n        lappend res \"$counter.$iCol.$a\"\n      }\n    }\n    incr counter\n  }\n\n  #puts \"$aCol -> $res\"\n  sort_poslist $res\n}\n\nproc nearset_match {aDictVar tok term} {\n  if {[string match $tok $term]} { return 1 }\n\n  upvar $aDictVar aDict\n  if {[info exists aDict($tok)]} {\n    foreach s $aDict($tok) {\n      if {[string match $s $term]} { return 1 }\n    }\n  }\n  return 0;\n}\n\n#-------------------------------------------------------------------------\n# Usage:\n#\n#   sort_poslist LIST\n#\n# Sort a position list of the type returned by command [nearset]\n#\nproc sort_poslist {L} {\n  lsort -command instcompare $L\n}\nproc instcompare {lhs rhs} {\n  foreach {p1 c1 o1} [split $lhs .] {}\n  foreach {p2 c2 o2} [split $rhs .] {}\n\n  set res [expr $c1 - $c2]\n  if {$res==0} { set res [expr $o1 - $o2] }\n  if {$res==0} { set res [expr $p1 - $p2] }\n\n  return $res\n}\n\n#-------------------------------------------------------------------------\n# Logical operators used by the commands returned by fts5_tcl_expr().\n#\nproc AND {args} {\n  foreach a $args {\n    if {[llength $a]==0} { return [list] }\n  }\n  sort_poslist [concat {*}$args]\n}\nproc OR {args} {\n  sort_poslist [concat {*}$args]\n}\nproc NOT {a b} {\n  if {[llength $b]>0} { return [list] }\n  return $a\n}\n\n#-------------------------------------------------------------------------\n# This command is similar to [split], except that it also provides the\n# start and end offsets of each token. For example:\n#\n#   [fts5_tokenize_split \"abc d ef\"] -> {abc 0 3 d 4 5 ef 6 8}\n#\n\nproc gobble_whitespace {textvar} {\n  upvar $textvar t\n  regexp {([ ]*)(.*)} $t -> space t\n  return [string length $space]\n}\n\nproc gobble_text {textvar wordvar} {\n  upvar $textvar t\n  upvar $wordvar w\n  regexp {([^ ]*)(.*)} $t -> w t\n  return [string length $w]\n}\n\nproc fts5_tokenize_split {text} {\n  set token \"\"\n  set ret [list]\n  set iOff [gobble_whitespace text]\n  while {[set nToken [gobble_text text word]]} {\n    lappend ret $word $iOff [expr $iOff+$nToken]\n    incr iOff $nToken\n    incr iOff [gobble_whitespace text]\n  }\n\n  set ret\n}\n\n#-------------------------------------------------------------------------\n#\nproc foreach_detail_mode {prefix script} {\n  set saved $::testprefix\n  foreach d [list full col none] {\n    set s [string map [list %DETAIL% $d] $script]\n    set ::detail $d\n    set ::testprefix \"$prefix-$d\"\n    reset_db\n    uplevel $s\n    unset ::detail\n  }\n  set ::testprefix $saved\n}\n\nproc detail_check {} {\n  if {$::detail != \"none\" && $::detail!=\"full\" && $::detail!=\"col\"} {\n    error \"not in foreach_detail_mode {...} block\"\n  }\n}\nproc detail_is_none {} { detail_check ; expr {$::detail == \"none\"} }\nproc detail_is_col {}  { detail_check ; expr {$::detail == \"col\" } }\nproc detail_is_full {} { detail_check ; expr {$::detail == \"full\"} }\n\n\n#-------------------------------------------------------------------------\n# Convert a poslist of the type returned by fts5_test_poslist() to a \n# collist as returned by fts5_test_collist().\n#\nproc fts5_poslist2collist {poslist} {\n  set res [list]\n  foreach h $poslist {\n    regexp {(.*)\\.[1234567890]+} $h -> cand\n    lappend res $cand\n  }\n  set res [lsort -command fts5_collist_elem_compare -unique $res]\n  return $res\n}\n\n# Comparison function used by fts5_poslist2collist to sort collist entries.\nproc fts5_collist_elem_compare {a b} {\n  foreach {a1 a2} [split $a .] {}\n  foreach {b1 b2} [split $b .] {}\n\n  if {$a1==$b1} { return [expr $a2 - $b2] }\n  return [expr $a1 - $b1]\n}\n\n\n#--------------------------------------------------------------------------\n# Construct and return a tcl list equivalent to that returned by the SQL\n# query executed against database handle [db]:\n#\n#   SELECT \n#     rowid, \n#     fts5_test_poslist($tbl),\n#     fts5_test_collist($tbl) \n#   FROM $tbl('$expr')\n#   ORDER BY rowid $order;\n#\nproc fts5_query_data {expr tbl {order ASC} {aDictVar \"\"}} {\n\n  # Figure out the set of columns in the FTS5 table. This routine does\n  # not handle tables with UNINDEXED columns, but if it did, it would\n  # have to be here.\n  db eval \"PRAGMA table_info = $tbl\" x { lappend lCols $x(name) }\n\n  set d \"\"\n  if {$aDictVar != \"\"} {\n    upvar $aDictVar aDict\n    set d aDict\n  }\n\n  set cols \"\"\n  foreach e $lCols { append cols \", '$e'\" }\n  set tclexpr [db one [subst -novar {\n    SELECT fts5_expr_tcl( $expr, 'nearset $cols -dict $d -pc ::pc' [set cols] )\n  }]]\n\n  set res [list]\n  db eval \"SELECT rowid, * FROM $tbl ORDER BY rowid $order\" x {\n    set cols [list]\n    foreach col $lCols { lappend cols $x($col) }\n    \n    set ::pc 0\n    set rowdata [eval $tclexpr]\n    if {$rowdata != \"\"} { \n      lappend res $x(rowid) $rowdata [fts5_poslist2collist $rowdata]\n    }\n  }\n\n  set res\n}\n\n#-------------------------------------------------------------------------\n# Similar to [fts5_query_data], but omit the collist field.\n#\nproc fts5_poslist_data {expr tbl {order ASC} {aDictVar \"\"}} {\n  set res [list]\n\n  if {$aDictVar!=\"\"} {\n    upvar $aDictVar aDict\n    set dict aDict\n  } else {\n    set dict \"\"\n  }\n\n  foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order $dict] {\n    lappend res $rowid $poslist\n  }\n  set res\n}\n\nproc fts5_collist_data {expr tbl {order ASC} {aDictVar \"\"}} {\n  set res [list]\n\n  if {$aDictVar!=\"\"} {\n    upvar $aDictVar aDict\n    set dict aDict\n  } else {\n    set dict \"\"\n  }\n\n  foreach {rowid poslist collist} [fts5_query_data $expr $tbl $order $dict] {\n    lappend res $rowid $collist\n  }\n  set res\n}\n\n#-------------------------------------------------------------------------\n#\n\n# This command will only work inside a [foreach_detail_mode] block. It tests\n# whether or not expression $expr run on FTS5 table $tbl is supported by\n# the current mode. If so, 1 is returned. If not, 0.\n#\n#   detail=full    (all queries supported)\n#   detail=col     (all but phrase queries and NEAR queries)\n#   detail=none    (all but phrase queries, NEAR queries, and column filters)\n#\nproc fts5_expr_ok {expr tbl} {\n\n  if {![detail_is_full]} {\n    set nearset \"nearset_rc\"\n    if {[detail_is_col]} { set nearset \"nearset_rf\" }\n\n    set ::expr_not_ok 0\n    db eval \"PRAGMA table_info = $tbl\" x { lappend lCols $x(name) }\n\n    set cols \"\"\n    foreach e $lCols { append cols \", '$e'\" }\n    set ::pc 0\n    set tclexpr [db one [subst -novar {\n      SELECT fts5_expr_tcl( $expr, '[set nearset] $cols -pc ::pc' [set cols] )\n    }]]\n    eval $tclexpr\n    if {$::expr_not_ok} { return 0 }\n  }\n\n  return 1\n}\n\n# Helper for [fts5_expr_ok]\nproc nearset_rf {aCol args} {\n  set idx [lsearch -exact $args --]\n  if {$idx != [llength $args]-2 || [llength [lindex $args end]]!=1} {\n    set ::expr_not_ok 1\n  }\n  list\n}\n\n# Helper for [fts5_expr_ok]\nproc nearset_rc {aCol args} {\n  nearset_rf $aCol {*}$args\n  if {[lsearch $args -col]>=0} { \n    set ::expr_not_ok 1\n  }\n  list\n}\n\n\n#-------------------------------------------------------------------------\n# Code for a simple Tcl tokenizer that supports synonyms at query time.\n#\nproc tclnum_tokenize {mode tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n    if {$tflags == $mode && [info exists ::tclnum_syn($w)]} {\n      foreach s $::tclnum_syn($w)  { sqlite3_fts5_token -colo $s $iStart $iEnd }\n    }\n  }\n}\n\nproc tclnum_create {args} {\n  set mode query\n  if {[llength $args]} {\n    set mode [lindex $args 0]\n  }\n  if {$mode != \"query\" && $mode != \"document\"} { error \"bad mode: $mode\" }\n  return [list tclnum_tokenize $mode]\n}\n\nproc fts5_tclnum_register {db} {\n  foreach SYNDICT {\n    {zero  0}\n    {one   1 i}\n    {two   2 ii}\n    {three 3 iii}\n    {four  4 iv}\n    {five  5 v}\n    {six   6 vi}\n    {seven 7 vii}\n    {eight 8 viii}\n    {nine  9 ix}\n\n    {a1 a2 a3 a4 a5 a6 a7 a8 a9}\n    {b1 b2 b3 b4 b5 b6 b7 b8 b9}\n    {c1 c2 c3 c4 c5 c6 c7 c8 c9}\n  } {\n    foreach s $SYNDICT {\n      set o [list]\n      foreach x $SYNDICT {if {$x!=$s} {lappend o $x}}\n      set ::tclnum_syn($s) $o\n    }\n  }\n  sqlite3_fts5_create_tokenizer db tclnum tclnum_create\n}\n#\n# End of tokenizer code.\n#-------------------------------------------------------------------------\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5aa.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5aa\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $::testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, c);\n  SELECT name, sql FROM sqlite_master;\n} {\n  t1 {CREATE VIRTUAL TABLE t1 USING fts5(a, b, c)}\n  t1_data {CREATE TABLE 't1_data'(id INTEGER PRIMARY KEY, block BLOB)}\n  t1_idx {CREATE TABLE 't1_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID}\n  t1_content {CREATE TABLE 't1_content'(id INTEGER PRIMARY KEY, c0, c1, c2)}\n  t1_docsize {CREATE TABLE 't1_docsize'(id INTEGER PRIMARY KEY, sz BLOB)}\n  t1_config {CREATE TABLE 't1_config'(k PRIMARY KEY, v) WITHOUT ROWID}\n}\n\ndo_execsql_test 1.1 {\n  DROP TABLE t1;\n  SELECT name, sql FROM sqlite_master;\n} {\n}\n\n#-------------------------------------------------------------------------\n#\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%);\n}\ndo_execsql_test 2.1 {\n  INSERT INTO t1 VALUES('a b c', 'd e f');\n}\n\ndo_test 2.2 {\n  execsql { SELECT fts5_decode(id, block) FROM t1_data WHERE id==10 }\n} {/{{structure} {lvl=0 nMerge=0 nSeg=1 {id=[0123456789]* leaves=1..1}}}/}\n\nforeach w {a b c d e f} {\n  do_execsql_test 2.3.$w.asc {\n    SELECT rowid FROM t1 WHERE t1 MATCH $w;\n  } {1}\n  do_execsql_test 2.3.$w.desc {\n    SELECT rowid FROM t1 WHERE t1 MATCH $w ORDER BY rowid DESC;\n  } {1}\n}\n\ndo_execsql_test 2.4 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%);\n}\nforeach {i x y} {\n   1  {g f d b f} {h h e i a}\n   2  {f i g j e} {i j c f f}\n   3  {e e i f a} {e h f d f}\n   4  {h j f j i} {h a c f j}\n   5  {d b j c g} {f e i b e}\n   6  {a j a e e} {j d f d e}\n   7  {g i j c h} {j d h c a}\n   8  {j j i d d} {e e d f b}\n   9  {c j j d c} {h j i f g}\n   10 {b f h i a} {c f b b j}\n} {\n  do_execsql_test 3.$i.1 { INSERT INTO t1 VALUES($x, $y) }\n  do_execsql_test 3.$i.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n  if {[set_test_counter errors]} break\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\nforeach {i x y} {\n   1  {g f d b f} {h h e i a}\n   2  {f i g j e} {i j c f f}\n   3  {e e i f a} {e h f d f}\n   4  {h j f j i} {h a c f j}\n   5  {d b j c g} {f e i b e}\n   6  {a j a e e} {j d f d e}\n   7  {g i j c h} {j d h c a}\n   8  {j j i d d} {e e d f b}\n   9  {c j j d c} {h j i f g}\n   10 {b f h i a} {c f b b j}\n} {\n  do_execsql_test 4.$i.1 { INSERT INTO t1 VALUES($x, $y) }\n  do_execsql_test 4.$i.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n  if {[set_test_counter errors]} break\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\nforeach {i x y} {\n   1  {dd abc abc abc abcde} {aaa dd ddd ddd aab}\n   2  {dd aab d aaa b} {abcde c aaa aaa aaa}\n   3  {abcde dd b b dd} {abc abc d abc ddddd}\n   4  {aaa abcde dddd dddd abcde} {abc b b abcde abc}\n   5  {aab dddd d dddd c} {ddd abcde dddd abcde c}\n   6  {ddd dd b aab abcde} {d ddddd dddd c abc}\n   7  {d ddddd ddd c abcde} {c aab d abcde ddd}\n   8  {abcde aaa aab c c} {ddd c dddd b aaa}\n   9  {abcde aab ddddd c aab} {dddd dddd b c dd}\n   10 {ddd abcde dddd dd c} {dddd c c d abcde}\n} {\n  do_execsql_test 5.$i.1 { INSERT INTO t1 VALUES($x, $y) }\n  do_execsql_test 5.$i.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n  if {[set_test_counter errors]} break\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\ndo_execsql_test 6.1 {\n  INSERT  INTO t1(rowid, x, y) VALUES(22, 'a b c', 'c b a');\n  REPLACE INTO t1(rowid, x, y) VALUES(22, 'd e f', 'f e d');\n}\n\ndo_execsql_test 6.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check') \n}\n\ndo_execsql_test 6.3 {\n  REPLACE INTO t1(rowid, x, y) VALUES('22', 'l l l', 'l l l');\n}\n\ndo_execsql_test 6.4 {\n  REPLACE INTO t1(x, y) VALUES('x y z', 'x y z');\n}\n\ndo_execsql_test 6.5 {\n  INSERT INTO t1(t1) VALUES('integrity-check') \n}\n\ndo_execsql_test 6.6 {\n  SELECT rowid, * FROM t1;\n} {\n  22 {l l l} {l l l}\n  23 {x y z} {x y z}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nexpr srand(0)\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y,z);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\nproc doc {} {\n  set v [list aaa aab abc abcde b c d dd ddd dddd ddddd]\n  set ret [list]\n  for {set j 0} {$j < 20} {incr j} {\n    lappend ret [lindex $v [expr int(rand()*[llength $v])]]\n  }\n  return $ret\n}\n\nproc dump_structure {} {\n  db eval {SELECT fts5_decode(id, block) AS t FROM t1_data WHERE id=10} {\n    foreach lvl [lrange $t 1 end] {\n      set seg [string repeat . [expr [llength $lvl]-2]]\n      puts \"[lrange $lvl 0 1] $seg\"\n    }\n  }\n}\n\nfor {set i 1} {$i <= 10} {incr i} {\n  do_test 7.$i {\n    for {set j 0} {$j < 10} {incr j} {\n      set x [doc]\n      set y [doc]\n      set z [doc]\n      set rowid [expr int(rand() * 100)]\n      execsql { REPLACE INTO t1(rowid,x,y,z) VALUES($rowid, $x, $y, $z) }\n    }\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check'); }\n  } {}\n  if {[set_test_counter errors]} break\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, prefix=\"1,2,3\");\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\ndo_execsql_test 8.1 {\n  INSERT INTO t1 VALUES('the quick brown fox');\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\n\nexpr srand(0)\n\ndo_execsql_test 9.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y,z, prefix=\"1,2,3\");\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\nproc doc {} {\n  set v [list aaa aab abc abcde b c d dd ddd dddd ddddd]\n  set ret [list]\n  for {set j 0} {$j < 20} {incr j} {\n    lappend ret [lindex $v [expr int(rand()*[llength $v])]]\n  }\n  return $ret\n}\n\nproc dump_structure {} {\n  db eval {SELECT fts5_decode(id, block) AS t FROM t1_data WHERE id=10} {\n    foreach lvl [lrange $t 1 end] {\n      set seg [string repeat . [expr [llength $lvl]-2]]\n      puts \"[lrange $lvl 0 1] $seg\"\n    }\n  }\n}\n\nfor {set i 1} {$i <= 10} {incr i} {\n  do_test 9.$i {\n    for {set j 0} {$j < 100} {incr j} {\n      set x [doc]\n      set y [doc]\n      set z [doc]\n      set rowid [expr int(rand() * 100)]\n      execsql { REPLACE INTO t1(rowid,x,y,z) VALUES($rowid, $x, $y, $z) }\n    }\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check'); }\n  } {}\n  if {[set_test_counter errors]} break\n}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 10.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x,y, detail=%DETAIL%);\n}\nset d10 {\n   1  {g f d b f} {h h e i a}\n   2  {f i g j e} {i j c f f}\n   3  {e e i f a} {e h f d f}\n   4  {h j f j i} {h a c f j}\n   5  {d b j c g} {f e i b e}\n   6  {a j a e e} {j d f d e}\n   7  {g i j c h} {j d h c a}\n   8  {j j i d d} {e e d f b}\n   9  {c j j d c} {h j i f g}\n  10  {b f h i a} {c f b b j}\n}\nforeach {rowid x y} $d10 {\n  do_execsql_test 10.1.$rowid.1 { INSERT INTO t1 VALUES($x, $y) }\n  do_execsql_test 10.1.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n}\nforeach rowid {5 9 8 1 2 4 10 7 3 5 6} {\n  do_execsql_test 10.2.$rowid.1 { DELETE FROM t1 WHERE rowid = $rowid }\n  do_execsql_test 10.2.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n}\nforeach {rowid x y} $d10 {\n  do_execsql_test 10.3.$rowid.1 { INSERT INTO t1 VALUES($x, $y) }\n  do_execsql_test 10.3.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n}\n\ndo_execsql_test 10.4.1 { DELETE FROM t1 }\ndo_execsql_test 10.4.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n\n#-------------------------------------------------------------------------\n#\ndo_catchsql_test 11.1 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rank, detail=%DETAIL%);\n} {1 {reserved fts5 column name: rank}}\ndo_catchsql_test 11.2 {\n  CREATE VIRTUAL TABLE rank USING fts5(a, b, c, detail=%DETAIL%);\n} {1 {reserved fts5 table name: rank}}\ndo_catchsql_test 11.3 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b, c, rowid, detail=%DETAIL%);\n} {1 {reserved fts5 column name: rowid}}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 12.1 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x,y, detail=%DETAIL%);\n} {}\n\ndo_catchsql_test 12.2 {\n  SELECT t2 FROM t2 WHERE t2 MATCH '*stuff'\n} {1 {unknown special query: stuff}}\n\ndo_test 12.3 {\n  set res [db eval { SELECT t2 FROM t2 WHERE t2 MATCH '* reads ' }]\n  string is integer $res\n} {1}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 13.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t1(rowid, x) VALUES(1, 'o n e'), (2, 't w o');\n} {}\n\ndo_execsql_test 13.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'o';\n} {1 2}\n\ndo_execsql_test 13.4 {\n  DELETE FROM t1 WHERE rowid=2;\n} {}\n\ndo_execsql_test 13.5 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'o';\n} {1}\n\ndo_execsql_test 13.6 {\n  SELECT rowid FROM t1 WHERE t1 MATCH '\"\"';\n} {}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 14.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  WITH d(x,y) AS (\n    SELECT NULL, 'xyz xyz xyz xyz xyz xyz'\n    UNION ALL \n    SELECT NULL, 'xyz xyz xyz xyz xyz xyz' FROM d\n  )\n  INSERT INTO t1 SELECT * FROM d LIMIT 200;\n}\n\ndo_execsql_test 15.x {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\ndo_test 14.2 {\n  set nRow 0\n  db eval { SELECT * FROM t1 WHERE t1 MATCH 'xyz' } {\n    db eval {\n      BEGIN;\n        CREATE TABLE t2(a, b);\n      ROLLBACK;\n    }\n    incr nRow\n  }\n  set nRow\n} {200}\n\ndo_test 14.3 {\n  set nRow 0\n  db eval { BEGIN; }\n  db eval { SELECT * FROM t1 WHERE t1 MATCH 'xyz' } {\n    db eval {\n      SAVEPOINT aaa;\n        CREATE TABLE t2(a, b);\n      ROLLBACK TO aaa;\n      RELEASE aaa;\n    }\n    incr nRow\n  }\n  set nRow\n} {200}\n\ndo_execsql_test 15.0 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\ndo_execsql_test 15.1 {\n  UPDATE t1_content SET c1 = 'xyz xyz xyz xyz xyz abc' WHERE rowid = 1;\n}\ndo_catchsql_test 15.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 16.1 {\n  CREATE VIRTUAL TABLE n1 USING fts5(a);\n  INSERT INTO n1 VALUES('a b c d');\n}\n\nproc funk {} {\n  db eval { UPDATE n1_config SET v=50 WHERE k='version' }\n  set fd [db incrblob main n1_data block 10]\n  fconfigure $fd -encoding binary -translation binary\n  puts -nonewline $fd \"\\x44\\x45\"\n  close $fd\n}\ndb func funk funk\n\n# This test case corrupts the structure record within the first invocation\n# of function funk(). Which used to cause the bm25() function to throw an\n# exception. But since bm25() can now used the cached structure record,\n# it never sees the corruption introduced by funk() and so the following \n# statement no longer fails.\n#\ndo_catchsql_test 16.2 {\n  SELECT funk(), bm25(n1), funk() FROM n1 WHERE n1 MATCH 'a+b+c+d'\n} {0 {{} -1e-06 {}}}\n# {1 {SQL logic error}}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 17.1 {\n  CREATE VIRTUAL TABLE b2 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO b2 VALUES('a');\n  INSERT INTO b2 VALUES('b');\n  INSERT INTO b2 VALUES('c');\n}\n\ndo_test 17.2 {\n  set res [list]\n  db eval { SELECT * FROM b2 ORDER BY rowid ASC } {\n    lappend res [execsql { SELECT * FROM b2 ORDER BY rowid ASC }]\n  }\n  set res\n} {{a b c} {a b c} {a b c}}\n\nif {[string match n* %DETAIL%]==0} {\n  reset_db\n  do_execsql_test 17.3 {\n    CREATE VIRTUAL TABLE c2 USING fts5(x, y, detail=%DETAIL%);\n    INSERT INTO c2 VALUES('x x x', 'x x x');\n    SELECT rowid FROM c2 WHERE c2 MATCH 'y:x';\n  } {1}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 17.1 {\n  CREATE VIRTUAL TABLE uio USING fts5(ttt, detail=%DETAIL%);\n  INSERT INTO uio VALUES(NULL);\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  INSERT INTO uio SELECT NULL FROM uio;\n  SELECT count(*) FROM uio;\n} {256}\n\ndo_execsql_test 17.2 {\n  SELECT count(*) FROM uio WHERE rowid BETWEEN 8 AND 17\n} {10}\ndo_execsql_test 17.3 {\n  SELECT rowid FROM uio WHERE rowid BETWEEN 8 AND 17\n} {8 9 10 11 12 13 14 15 16 17}\ndo_execsql_test 17.4 {\n  SELECT rowid FROM uio WHERE rowid BETWEEN 8 AND 17 ORDER BY rowid DESC\n} {17 16 15 14 13 12 11 10 9 8}\ndo_execsql_test 17.5 {\n  SELECT count(*) FROM uio\n} {256}\n\ndo_execsql_test 17.6 {\n  INSERT INTO uio(rowid) VALUES(9223372036854775807);\n  INSERT INTO uio(rowid) VALUES(-9223372036854775808);\n  SELECT count(*) FROM uio;\n} {258}\ndo_execsql_test 17.7 {\n  SELECT min(rowid), max(rowid) FROM uio;\n} {-9223372036854775808 9223372036854775807}\n\ndo_execsql_test 17.8 {\n  INSERT INTO uio DEFAULT VALUES;\n  SELECT min(rowid), max(rowid), count(*) FROM uio;\n} {-9223372036854775808 9223372036854775807 259}\n\ndo_execsql_test 17.9 {\n  SELECT min(rowid), max(rowid), count(*) FROM uio WHERE rowid < 10;\n} {-9223372036854775808 9 10}\n\n#--------------------------------------------------------------------\n#\ndo_execsql_test 18.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n  CREATE VIRTUAL TABLE t2 USING fts5(c, d, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('abc*', NULL);\n  INSERT INTO t2 VALUES(1, 'abcdefg');\n}\ndo_execsql_test 18.2 {\n  SELECT t1.rowid, t2.rowid FROM t1, t2 WHERE t2 MATCH t1.a AND t1.rowid = t2.c\n} {1 1}\ndo_execsql_test 18.3 {\n  SELECT t1.rowid, t2.rowid FROM t2, t1 WHERE t2 MATCH t1.a AND t1.rowid = t2.c\n} {1 1}\n\n#--------------------------------------------------------------------\n# fts5 table in the temp schema.\n#\nreset_db\ndo_execsql_test 19.0 {\n  CREATE VIRTUAL TABLE temp.t1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('x y z');\n  INSERT INTO t1 VALUES('w x 1');\n  SELECT rowid FROM t1 WHERE t1 MATCH 'x';\n} {1 2}\n\n#--------------------------------------------------------------------\n# Test that 6 and 7 byte varints can be read.\n#\nreset_db\ndo_execsql_test 20.0 {\n  CREATE VIRTUAL TABLE temp.tmp USING fts5(x, detail=%DETAIL%);\n}\nset ::ids [list \\\n  0 [expr 1<<36] [expr 2<<36] [expr 1<<43] [expr 2<<43]\n]\ndo_test 20.1 {\n  foreach id $::ids {\n    execsql { INSERT INTO tmp(rowid, x) VALUES($id, 'x y z') }\n  }\n  execsql { SELECT rowid FROM tmp WHERE tmp MATCH 'y' }\n} $::ids\n\n#--------------------------------------------------------------------\n# Test that a DROP TABLE may be executed within a transaction that\n# writes to an FTS5 table.\n#\ndo_execsql_test 21.0 {\n  CREATE TEMP TABLE t8(a, b);\n  CREATE VIRTUAL TABLE ft USING fts5(x, detail=%DETAIL%);\n}\n\ndo_execsql_test 21.1 {\n  BEGIN;\n    INSERT INTO ft VALUES('a b c');\n    DROP TABLE t8;\n  COMMIT;\n}\n\ndo_execsql_test 22.0 {\n  CREATE VIRTUAL TABLE t9 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t9(rowid, x) VALUES(2, 'bbb');\n  BEGIN;\n    INSERT INTO t9(rowid, x) VALUES(1, 'aaa');\n    DELETE FROM t9 WHERE rowid = 2;\n    INSERT INTO t9(rowid, x) VALUES(3, 'bbb');\n  COMMIT;\n}\n\ndo_execsql_test 22.1 {\n  SELECT rowid FROM t9('a*')\n} {1}\n\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ab.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ab\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('hello', 'world');\n  INSERT INTO t1 VALUES('one two', 'three four');\n  INSERT INTO t1(rowid, a, b) VALUES(45, 'forty', 'five');\n}\n\ndo_execsql_test 1.1 {\n  SELECT * FROM t1 ORDER BY rowid DESC;\n} { forty five {one two} {three four} hello world }\n\ndo_execsql_test 1.2 {\n  SELECT rowid FROM t1 ORDER BY rowid DESC;\n} {45 2 1}\n\ndo_execsql_test 1.3 {\n  SELECT rowid FROM t1 ORDER BY rowid ASC;\n} {1 2 45}\n\ndo_execsql_test 1.4 {\n  SELECT * FROM t1 WHERE rowid=2;\n} {{one two} {three four}}\n\ndo_execsql_test 1.5 {\n  SELECT * FROM t1 WHERE rowid=2.01;\n} {}\n\ndo_execsql_test 1.6 {\n  SELECT * FROM t1 WHERE rowid=1.99;\n} {}\n\n#-------------------------------------------------------------------------\n\nreset_db\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  INSERT INTO t1 VALUES('one');\n  INSERT INTO t1 VALUES('two');\n  INSERT INTO t1 VALUES('three');\n}\n\ndo_catchsql_test 2.2 {\n  SELECT rowid, * FROM t1 WHERE t1 MATCH 'AND AND'\n} {1 {fts5: syntax error near \"AND\"}}\n\ndo_execsql_test 2.3 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'two' } {2 two}\ndo_execsql_test 2.4 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'three' } {3 three}\ndo_execsql_test 2.5 { SELECT rowid, * FROM t1 WHERE t1 MATCH 'one' } {1 one}\n\ndo_execsql_test 2.6 {\n  INSERT INTO t1 VALUES('a b c d e f g');\n  INSERT INTO t1 VALUES('b d e a a a i');\n  INSERT INTO t1 VALUES('x y z b c c c');\n}\n\nforeach {tn expr res} {\n  1  a    {5 4}\n  2  b    {6 5 4}\n  3  c    {6 4}\n  4  d    {5 4}\n  5  e    {5 4}\n  6  f    {4}\n  7  g    {4}\n  8  x    {6}\n  9  y    {6}\n  10 z    {6}\n} {\n  do_execsql_test 2.7.$tn.1 { \n    SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid DESC\n  } $res\n  do_execsql_test 2.7.$tn.2 { \n    SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid ASC\n  } [lsort -integer $res]\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a,b);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\nforeach {tn a b} {\n   1 {abashed abandons abase abash abaft} {abases abased}\n   2 {abasing abases abaft abated abandons} {abases abandoned}\n   3 {abatement abash abash abated abase} {abasements abashing}\n   4 {abaft abasements abase abasement abasing} {abasement abases}\n   5 {abaft abashing abatement abash abasements} {abandons abandoning}\n   6 {aback abate abasements abashes abandoned} {abasement abased}\n   7 {abandons abated abased aback abandoning} {abases abandoned}\n   8 {abashing abases abasement abaft abashing} {abashed abate}\n   9 {abash abase abate abashing abashed} {abandon abandoned}\n   10 {abate abandoning abandons abasement aback} {abandon abandoning}\n} {\n  do_execsql_test 3.1.$tn.1 { INSERT INTO t1 VALUES($a, $b) } \n  do_execsql_test 3.1.$tn.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\n}\n\nforeach {tn expr res} {\n  1 {abash} {9 5 3 1}\n  2 {abase} {9 4 3 1}\n  3 {abase + abash} {1}\n  4 {abash + abase} {9}\n  5 {abaft + abashing} {8 5}\n  6 {abandon + abandoning} {10}\n  7 {\"abashing abases abasement abaft abashing\"} {8}\n} {\n  do_execsql_test 3.2.$tn {\n    SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid DESC\n  } $res\n}\n\ndo_execsql_test 3.3 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'NEAR(aback abate, 2)'\n} {6}\n\nforeach {tn expr res} {\n  1 {abash} {1 3 5 9}\n  2 {abase} {1 3 4 9}\n  3 {abase + abash} {1}\n  4 {abash + abase} {9}\n  5 {abaft + abashing} {5 8}\n  6 {abandon + abandoning} {10}\n  7 {\"abashing abases abasement abaft abashing\"} {8}\n} {\n  do_execsql_test 3.4.$tn {\n    SELECT rowid FROM t1 WHERE t1 MATCH $expr\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Documents with more than 2M tokens.\n#\n\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE s1 USING fts5(x, detail=%DETAIL%);\n}\nforeach {tn doc} [list \\\n  1 [string repeat {a x } 1500000]       \\\n  2 \"[string repeat {a a } 1500000] x\"   \\\n] {\n  do_execsql_test 4.$tn { INSERT INTO s1 VALUES($doc) }\n}\n\ndo_execsql_test 4.3 {\n  SELECT rowid FROM s1 WHERE s1 MATCH 'x'\n} {1 2}\n\nif {[detail_is_full]} {\n  do_execsql_test 4.4 {\n    SELECT rowid FROM s1 WHERE s1 MATCH '\"a x\"'\n  } {1 2}\n}\n\ndo_execsql_test 4.5 {\n  SELECT rowid FROM s1 WHERE s1 MATCH 'a x'\n} {1 2}\n\n#-------------------------------------------------------------------------\n# Check that a special case of segment promotion works. The case is where\n# a new segment is written to level L, but the oldest segment within level\n# (L-2) is larger than it.\n#\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO s2(s2, rank) VALUES('pgsz', 32);\n  INSERT INTO s2(s2, rank) VALUES('automerge', 0);\n}\n\nproc rnddoc {n} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc [string map $map [format %.3d [expr int(rand()*1000)]]]\n  }\n  set doc\n}\ndb func rnddoc rnddoc\n\ndo_test 5.1 {\n  for {set i 1} {$i <= 65} {incr i} {\n    execsql { INSERT INTO s2 VALUES(rnddoc(10)) }\n  }\n  for {set i 1} {$i <= 63} {incr i} {\n    execsql { DELETE FROM s2 WHERE rowid = $i }\n  }\n  fts5_level_segs s2\n} {0 8}\n\ndo_test 5.2 {\n  execsql {\n    INSERT INTO s2(s2, rank) VALUES('automerge', 8);\n  }\n  for {set i 0} {$i < 7} {incr i} {\n    execsql { INSERT INTO s2 VALUES(rnddoc(50)) }\n  }\n  fts5_level_segs s2\n} {8 0 0}\n\n# Test also the other type of segment promotion - when a new segment is written\n# that is larger than segments immediately following it.\ndo_test 5.3 {\n  execsql {\n    DROP TABLE s2;\n    CREATE VIRTUAL TABLE s2 USING fts5(x, detail=%DETAIL%);\n    INSERT INTO s2(s2, rank) VALUES('pgsz', 32);\n    INSERT INTO s2(s2, rank) VALUES('automerge', 0);\n  }\n\n  for {set i 1} {$i <= 16} {incr i} {\n    execsql { INSERT INTO s2 VALUES(rnddoc(5)) }\n  }\n  fts5_level_segs s2\n} {0 1}\n\ndo_test 5.4 {\n  execsql { INSERT INTO s2 VALUES(rnddoc(160)) }\n  fts5_level_segs s2\n} {2 0}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE s3 USING fts5(x, detail=%DETAIL%);\n  BEGIN;\n    INSERT INTO s3 VALUES('a b c');\n    INSERT INTO s3 VALUES('A B C');\n}\n\ndo_execsql_test 6.1.1 {\n  SELECT rowid FROM s3 WHERE s3 MATCH 'a'\n} {1 2}\n\ndo_execsql_test 6.1.2 {\n  SELECT rowid FROM s3 WHERE s3 MATCH 'a' ORDER BY rowid DESC\n} {2 1}\n\ndo_execsql_test 6.2 {\n  COMMIT;\n}\n\ndo_execsql_test 6.3 {\n  SELECT rowid FROM s3 WHERE s3 MATCH 'a'\n} {1 2}\n\ndo_test 6.4 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n      INSERT INTO s3(s3) VALUES('optimize');\n    ROLLBACK;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n#\nset doc [string repeat \"a b c \" 500]\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n  INSERT INTO x1 VALUES($doc);\n}\n\n} ;# foreach_detail_mode...\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ac.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ac\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\nset data {\n    0   {p o q e z k z p n f y u z y n y}   {l o o l v v k}\n    1   {p k h h p y l l h i p v n}         {p p l u r i f a j g e r r x w}\n    2   {l s z j k i m p s}                 {l w e j t j e e i t w r o p o}\n    3   {x g y m y m h p}                   {k j j b r e y y a k y}\n    4   {q m a i y i z}                     {o w a g k x g j m w e u k}\n    5   {k o a w y b s z}                   {s g l m m l m g p}\n    6   {d a q i z h b l c p k j g k}       {p x u j x t v c z}\n    7   {f d a g o c t i}                   {w f c x l d r k i j}\n    8   {y g w u b q p o m j y b p a e k}   {r i d k y w o z q m a t p}\n    9   {r k o m c c j s x m x m x m q r}   {y r c a q d z k n x n}\n    10  {k j q m g q a j d}                 {d d e z g w h c d o o g x d}\n    11  {j z u m o y q j f w e e w t r j w} {g m o r x n t n w i f g l z f}\n    12  {s y w a w d o h x m k}             {c w k z b p o r a}\n    13  {u t h x e g s k n g i}             {f j w g c s r}\n    14  {b f i c s u z t k}                 {c k q s j u i z o}\n    15  {n a f n u s w h y n s i q e w}     {x g e g a s s h n}\n    16  {k s q e j n p}                     {t r j f t o e k k l m i}\n    17  {g d t u w r o p m n m n p h b o u} {h s w o s l j e}\n    18  {f l q y q q g e e x j r}           {n b r r g e i r t x q k}\n    19  {f i r g o a w e p i l o a w}       {e k r z t d g h g i b d i e m}\n    20  {l d u u f p y}                     {g o m m u x m g l j t t x x u}\n    21  {m c d k x i c z l}                 {m i a i e u h}\n    22  {w b f o c g x y j}                 {z d w x d f h i p}\n    23  {w u i u x t c h k i b}             {b y k h b v r t g j}\n    24  {h f d j s w s b a p k}             {a q y u z e y m m j q r}\n    25  {d i x y x x k i y f s d j h z p n} {l l q m e t c w g y h t s v g}\n    26  {g s q w t d k x g f m j p k y}     {r m b x e l t d}\n    27  {j l s q u g y v e c l o}           {m f l m m m h g x x l n c}\n    28  {c t j g v r s b z j}               {l c f y d t q n}\n    29  {e x z y w i h l}                   {b n b x e y q e n u m}\n    30  {g y y h j b w r}                   {q b q f u s k c k g r}\n    31  {g u l x l b r c m z b u c}         {k g t b x k x n t e z d h o}\n    32  {w g v l z f b z h p s c v h}       {g e w v m h k r g w a r f q}\n    33  {c g n f u d o y o b}               {e y o h x x y y i z s b h a j}\n    34  {v y h c q u u s q y x x k s q}     {d n r m y k n t i r n w e}\n    35  {o u c x l e b t a}                 {y b a x y f z x r}\n    36  {x p h l j a a u u j h}             {x o f s z m b c q p}\n    37  {k q t i c a q n m v v}             {v r z e f m y o}\n    38  {r w t t t t r v v o e p g h}       {l w x a g a u h y}\n    39  {o p v g v b a g o}                 {j t q c r b b g y z}\n    40  {f s o r o d t h q f x l}           {r d b m k i f s t d l m y x j w}\n    41  {t m o t m f m f}                   {i p i q j v n v m b q}\n    42  {t x w a r l w d t b c o d o}       {a h f h w z d n s}\n    43  {t u q c d g p q x j o l c x c}     {m n t o z z j a y}\n    44  {v d i i k b f s z r v r z y}       {g n q y s x x m b x c l w}\n    45  {p v v a c s z y e o l}             {m v t u d k m k q b d c v z r}\n    46  {f y k l d r q w r s t r e}         {h m v r r l r r t f q e x y}\n    47  {w l n l t y x}                     {n h s l a f c h u f l x x m v n o}\n    48  {t n v i k e b p z p d j j l i o}   {i v z p g u e j s i k n h w d c}\n    49  {z v x p n l t a j c}               {e j l e n c e t a d}\n    50  {w u b x u i v h a i y m m r p m s} {s r h d o g z y f f x e}\n    51  {d c c x b c a x g}                 {p r a j v u y}\n    52  {f w g r c o d l t u e z h i}       {j l l s s b j m}\n    53  {p m t f k i x}                     {u v y a z g w v v m x h i}\n    54  {l c z g l o j i c d e b}           {b f v y w u i b e i y}\n    55  {r h c x f x a d s}                 {z x y k f l r b q c v}\n    56  {v x x c y h z x b g m o q n c}     {h n b i t g h a q b c o r u}\n    57  {d g l o h t b s b r}               {n u e p t i m u}\n    58  {t d y e t d c w u o s w x f c h}   {i o s v y b r d r}\n    59  {l b a p q n d r}                   {k d c c d n y q h g a o p e x}\n    60  {f r z v m p k r}                   {x x r i s b a g f c}\n    61  {s a z i e r f i w c n y v z t k s} {y y i r y n l s b w i e k n}\n    62  {n x p r e x q r m v i b y}         {f o o z n b s r q j}\n    63  {y j s u j x o n r q t f}           {f v k n v x u s o a d e f e}\n    64  {u s i l y c x q}                   {r k c h p c h b o s s u s p b}\n    65  {m p i o s h o}                     {s w h u n d m n q t y k b w c}\n    66  {l d f g m x x x o}                 {s w d d f b y j j h h t i y p j o}\n    67  {c b m h f n v w n h}               {i r w i e x r w l z p x u g u l s}\n    68  {y a h u h i m a y q}               {d d r x h e v q n z y c j}\n    69  {c x f d x o n p o b r t b l p l}   {m i t k b x v f p t m l l y r o}\n    70  {u t l w w m s}                     {m f m o l t k o p e}\n    71  {f g q e l n d m z x q}             {z s i i i m f w w f n g p e q}\n    72  {n l h a v u o d f j d e x}         {v v s l f g d g r a j x i f z x}\n    73  {x v m v f i g q e w}               {r y s j i k m j j e d g r n o i f}\n    74  {g d y n o h p s y q z j d w n h w} {x o d l t j i b r d o r y}\n    75  {p g b i u r b e q d v o a g w m k} {q y z s f q o h}\n    76  {u z a q u f i f f b}               {b s p b a a d x r r i q f}\n    77  {w h h z t h p o a h h e e}         {h w r p h k z v y f r x}\n    78  {c a r k i a p u x}                 {f w l p t e m l}\n    79  {q q u k o t r k z}                 {f b m c w p s s o z}\n    80  {t i g v y q s r x m r x z e f}     {x o j w a u e y s j c b u p p r o}\n    81  {n j n h r l a r e o z w e}         {v o r r j a v b}\n    82  {i f i d k w d n h}                 {o i d z i z l m w s b q v u}\n    83  {m d g q q b k b w f q q p p}       {j m q f b y c i z k y q p l e a}\n    84  {m x o n y f g}                     {y c n x n q j i y c l h b r q z}\n    85  {v o z l n p c}                     {g n j n t b b x n c l d a g j v}\n    86  {z n a y f b t k k t d b z a v}     {r p c n r u k u}\n    87  {b q t x z e c w}                   {q a o a l o a h i m j r}\n    88  {j f h o x x a z g b a f a m i b}   {j z c z y x e x w t}\n    89  {t c t p r s u c q n}               {z x l i k n f q l n t}\n    90  {w t d q j g m r f k n}             {l e w f w w a l y q k i q t p c t}\n    91  {c b o k l i c b s j n m b l}       {y f p q o w g}\n    92  {f y d j o q t c c q m f j s t}     {f h e d y m o k}\n    93  {k x j r m a d o i z j}             {r t t t f e b r x i v j v g o}\n    94  {s f e a e t i h h d q p z t q}     {b k m k w h c}\n    95  {h b n j t k i h o q u}             {w n g i t o k c a m y p f l x c p}\n    96  {f c x p y r b m o l m o a}         {p c a q s u n n x d c f a o}\n    97  {u h h k m n k}                     {u b v n u a o c}\n    98  {s p e t c z d f n w f}             {l s f j b l c e s h}\n    99  {r c v w i v h a t a c v c r e}     {h h u m g o f b a e o}\n}\n\nforeach {tn2 sql} {\n  1  {}\n  2  {BEGIN}\n} {\n  reset_db\n  fts5_aux_test_functions db\n\n  do_execsql_test 1.$tn2.0 {\n    CREATE VIRTUAL TABLE xx USING fts5(x,y, detail=%DETAIL%);\n    INSERT INTO xx(xx, rank) VALUES('pgsz', 32);\n  }\n\n  execsql $sql\n\n  do_test 1.$tn2.1.1 {\n    foreach {id x y} $data {\n      execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) }\n    }\n    execsql { INSERT INTO xx(xx) VALUES('integrity-check') }\n  } {}\n\n\n  #-------------------------------------------------------------------------\n  #\n  do_execsql_test 1.$tn2.integrity {\n    INSERT INTO xx(xx) VALUES('integrity-check');\n  }\n\n  #-------------------------------------------------------------------------\n  #\n  foreach {tn expr} {\n    1.1 \"a   AND b\"\n    1.2 \"a   OR b\"\n    1.3 \"o\"\n    1.4 \"b q\"\n    1.5 \"e a e\"\n    1.6 \"m d g q q b k b w f q q p p\"\n    1.7 \"l o o l v v k\"\n    1.8 \"a\"\n    1.9 \"b\"\n    1.10 \"c\"\n    1.11 \"no\"\n    1.12 \"L O O L V V K\"\n    1.13 \"a AND b AND c\"\n    1.14 \"x:a\"\n\n    2.1 \"x:a\"\n    2.2 \"y:a\"\n    2.3 \"x:b\"\n    2.4 \"y:b\"\n\n    3.1 \"{x}:a\"\n    3.2 \"{y}:a\"\n    3.3 \"{x}:b\"\n    3.4 \"{y}:b\"\n\n    4.1 \"{x y}:a\"\n    4.2 \"{y x}:a\"\n    4.3 \"{x x}:b\"\n    4.4 \"{y y}:b\"\n\n    5.1 {{\"x\" \"y\"}:a}\n    5.2 {{\"y\" x}:a}\n    5.3 {{x \"x\"}:b}\n    5.4 {{\"y\" y}:b}\n\n    6.1 \"b + q\"\n    6.2 \"e + a + e\"\n    6.3 \"m + d + g + q + q + b + k + b + w + f + q + q + p + p\"\n    6.4 \"l + o + o + l + v + v + k\"\n    6.5 \"L + O + O + L + V + V + K\"\n\n    7.1 \"a+b AND c\"\n    7.2 \"d+c AND u\"\n    7.3 \"d+c AND u+d\"\n    7.4 \"a+b OR c\"\n    7.5 \"d+c OR u\"\n    7.6 \"d+c OR u+d\"\n\n    8.1 \"NEAR(a b)\"\n    8.2 \"NEAR(r c)\"\n    8.2 { NEAR(r c, 5) }\n    8.3 { NEAR(r c, 3) }\n    8.4 { NEAR(r c, 2) }\n    8.5 { NEAR(r c, 0) }\n    8.6 { NEAR(a b c) }\n    8.7 { NEAR(a b c, 8) }\n    8.8  { x : NEAR(r c) }\n    8.9  { y : NEAR(r c) }\n\n    9.1 { NEAR(r c) }\n    9.2 { NEAR(r c, 5) }\n    9.3 { NEAR(r c, 3) }\n    9.4 { NEAR(r c, 2) }\n    9.5 { NEAR(r c, 0) }\n    9.6 { NEAR(a b c) }\n    9.7 { NEAR(a b c, 8) }\n    9.8  { x : NEAR(r c) }\n    9.9  { y : NEAR(r c) }\n    9.10 { x : \"r c\" }\n    9.11 { y : \"r c\" }\n    9.12 { a AND b }\n    9.13 { a AND b AND c }\n    9.14a { a }\n    9.14b { a OR b }\n    9.15 { a OR b AND c }\n    9.16 { c AND b OR a }\n    9.17 { c AND (b OR a) }\n    9.18 { c NOT (b OR a) }\n    9.19 { (c NOT b) OR (a AND d) }\n  } {\n\n    if {[fts5_expr_ok $expr xx]==0} {\n      do_test 1.$tn2.$tn.OMITTED { list } [list]\n      continue\n    }\n\n    set res [fts5_query_data $expr xx]\n    do_execsql_test 1.$tn2.$tn.[llength $res].asc {\n      SELECT rowid, fts5_test_poslist(xx), fts5_test_collist(xx) \n      FROM xx WHERE xx match $expr\n    } $res\n\n    set res [fts5_query_data $expr xx DESC]\n    do_execsql_test 1.$tn2.$tn.[llength $res].desc {\n      SELECT rowid, fts5_test_poslist(xx), fts5_test_collist(xx) \n      FROM xx WHERE xx match $expr ORDER BY 1 DESC\n    } $res\n  }\n}\n\n}\n\ndo_execsql_test 2.1 {\n  SELECT fts5_expr_tcl('a AND b');\n} {{AND [nearset -- {a}] [nearset -- {b}]}}\n\ndo_test 2.2.1  { nearset {{a b c}} -- a } {0.0.0}\ndo_test 2.2.2  { nearset {{a b c}} -- c } {0.0.2}\n\nforeach {tn expr tclexpr} {\n  1 {a b} {AND [N $x -- {a}] [N $x -- {b}]}\n} {\n  do_execsql_test 2.3.$tn {\n    SELECT fts5_expr_tcl($expr, 'N $x')\n  } [list $tclexpr]\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ad.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# More specifically, the focus is on testing prefix queries, both with and\n# without prefix indexes.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ad\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE yy USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO yy VALUES('Changes the result to be', 'the list of all matching');\n  INSERT INTO yy VALUES('indices (or all  matching', 'values if -inline is');\n  INSERT INTO yy VALUES('specified as  well.) If', 'indices are returned, the');\n} {}\n\nforeach {tn match res} {\n  1 {c*} {1}\n  2 {i*} {3 2}\n  3 {t*} {3 1}\n  4 {r*} {3 1}\n} {\n  do_execsql_test 1.$tn {\n    SELECT rowid FROM yy WHERE yy MATCH $match ORDER BY rowid DESC\n  } $res\n}\n\nforeach {tn match res} {\n  5 {c*} {1}\n  6 {i*} {2 3}\n  7 {t*} {1 3}\n  8 {r*} {1 3}\n} {\n  do_execsql_test 1.$tn {\n    SELECT rowid FROM yy WHERE yy MATCH $match\n  } $res\n}\n\nforeach {T create} {\n  2 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  }\n  \n  3 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=\"1,2,3,4\", detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  }\n\n  4 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n    BEGIN;\n  }\n  \n  5 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=\"1,2,3,4\", detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n    BEGIN;\n  }\n\n} {\n\n  do_test $T.1 { \n    execsql { DROP TABLE IF EXISTS t1 }\n    execsql $create\n  } {}\n  \n  do_test $T.1 {\n    foreach {rowid a b} {\n      0   {fghij uvwxyz klmn pq uvwx}         {klmn f fgh uv fghij klmno}\n      1   {uv f abcd abcd fghi}               {pq klm uv uv fgh uv a}\n      2   {klmn klm pqrs fghij uv}            {f k uvw ab abcd pqr uv}\n      3   {ab pqrst a fghi ab pqr fg}         {k klmno a fg abcd}\n      4   {abcd pqrst uvwx a fgh}             {f klmno fghij kl pqrst}\n      5   {uvwxyz k abcde u a}                {uv k k kl klmn}\n      6   {uvwxyz k klmn pqrst uv}            {fghi pqrs abcde u k}\n      7   {uvwxy klmn u p pqrst fgh}          {p f fghi abcd uvw kl uv}\n      8   {f klmno pqrst uvwxy pqrst}         {uv abcde klm pq pqr}\n      9   {f abcde a uvwxyz pqrst}            {fghij abc k uvwx pqr fghij uvwxy}\n      10  {ab uv f fg pqrst uvwxy}            {fgh p uv k abc klm uvw}\n      11  {pq klmno a uvw abcde uvwxyz}       {fghij pq uvwxyz pqr fghi}\n      12  {fgh u pq fgh uvw}                  {uvw pqr f uvwxy uvwx}\n      13  {uvwx klmn f fgh abcd pqr}          {uvw k fg uv klm abcd}\n      14  {ab uvwx pqrst pqr uvwxyz pqrs}     {uvwxyz abcde ab ab uvw abcde}\n      15  {abc abcde uvwxyz abc kl k pqr}     {klm k k klmno u fgh}\n      16  {fghi abcd fghij uv uvwxyz ab uv}   {klmn pqr a uvw fghi}\n      17  {abc pqrst fghi uvwx uvw klmn fghi} {ab fg pqr pqrs p}\n      18  {pqr kl a fghij fgh fg kl}          {pqr uvwxyz uvw abcd uvwxyz}\n      19  {fghi fghi pqr kl fghi f}           {klmn u u klmno klmno}\n      20  {abc pqrst klmno kl pq uvwxy}       {abc k fghi pqrs klm}\n      21  {a pqr uvwxyz uv fghi a fgh}        {abc pqrs pqrst pq klm}\n      22  {klm abc uvwxyz klm pqrst}          {fghij k pq pqr u klm fghij}\n      23  {p klm uv p a a}                    {uvwxy klmn uvw abcde pq}\n      24  {uv fgh fg pq uvwxy u uvwxy}        {pqrs a uvw p uvwx uvwxyz fg}\n      25  {fghij fghi klmn abcd pq kl}        {fghi abcde pqrs abcd fgh uvwxy}\n      26  {pq fgh a abc klmno klmn}           {fgh p k p fg fghij}\n      27  {fg pq kl uvwx fghij pqrst klmn}    {abcd uvw abcd fghij f fghij}\n      28  {uvw fghi p fghij pq fgh uvwx}      {k fghij abcd uvwx pqr fghi}\n      29  {klm pq abcd pq f uvwxy}            {pqrst p fghij pqr p}\n      30  {ab uvwx fg uvwx klmn klm}          {klmn klmno fghij klmn klm}\n      31  {pq k pqr abcd a pqrs}              {abcd abcd uvw a abcd klmno ab}\n      32  {pqrst u abc pq klm}                {abc kl uvwxyz fghij u fghi p}\n      33  {f uvwxy u k f uvw uvwx}            {pqrs uvw fghi fg pqrst klm}\n      34  {pqrs pq fghij uvwxyz pqr}          {ab abc abc uvw f pq f}\n      35  {uvwxy ab uvwxy klmno kl pqrs}      {abcde uvw pqrs uvwx k k}\n      36  {uvwxyz k ab abcde abc uvw}         {uvw abcde uvw klmn uv klmn}\n      37  {k kl uv abcde uvwx fg u}           {u abc uvwxy k fg abcd}\n      38  {fghi pqrst fghi pqr pqrst uvwx}    {u uv uvwx fghi abcde}\n      39  {k pqrst k uvw fg pqrst fghij}      {uvwxy ab kl klmn uvwxyz abcde}\n      40  {fg uvwxy pqrs klmn uvwxyz klm p}   {k uv ab fghij fgh k pqrs}\n      41  {uvwx abc f pq uvwxy k}             {ab uvwxyz abc f fghij}\n      42  {uvwxy klmno uvwxyz uvwxyz pqrst}   {uv kl kl klmno k f abcde}\n      43  {abcde ab pqrs fg f fgh}            {abc fghij fghi k k}\n      44  {uvw abcd a ab pqrst klmn fg}       {pqrst u uvwx pqrst fghij f pqrst}\n      45  {uvwxy p kl uvwxyz ab pqrst fghi}   {abc f pqr fg a k}\n      46  {u p f a fgh}                       {a kl pq uv f}\n      47  {pqrs abc fghij fg abcde ab a}      {p ab uv pqrs kl fghi abcd}\n      48  {abcde uvwxy pqrst uv abc pqr uvwx} {uvwxy klm uvwxy uvwx k}\n      49  {fgh klm abcde klmno u}             {a f fghij f uvwxyz abc u}\n      50  {uv uvw uvwxyz uvwxyz uv ab}        {uvwx pq fg u k uvwxy}\n      51  {uvwxy pq p kl fghi}                {pqrs fghi pqrs abcde uvwxyz ab}\n      52  {pqr p uvwxy kl pqrs klmno fghij}   {ab abcde abc pqrst pqrs uv}\n      53  {fgh pqrst p a klmno}               {ab ab pqrst pqr kl pqrst}\n      54  {abcd klm ab uvw a fg u}            {f pqr f abcd uv}\n      55  {u fg uvwxyz k uvw}                 {abc pqrs f fghij fg pqrs uvwxy}\n      56  {klm fg p fghi fg a}                {uv a fghi uvwxyz a fghi}\n      57  {uvwxy k abcde fgh f fghi}          {f kl klmn f fghi klm}\n      58  {klm k fgh uvw fgh fghi}            {klmno uvwx u pqrst u}\n      59  {fghi pqr pqrst p uvw fghij}        {uv pqrst pqrs pq fghij klm}\n      60  {uvwx klm uvwxy uv klmn}            {p a a abc klmn ab k}\n      61  {uvwxy uvwx klm uvwx klm}           {pqrs ab ab uvwxyz fg}\n      62  {kl uv uv uvw fg kl k}              {abcde uvw fgh uvwxy klm}\n      63  {a abc fgh u klm abcd}              {fgh pqr uv klmn fghij}\n      64  {klmn k klmn klmno pqrs pqr}        {fg kl abcde klmno uvwxy kl pq}\n      65  {uvwxyz klm fghi abc abcde kl}      {uvwxy uvw uvwxyz uvwxyz pq pqrst}\n      66  {pq klm abc pqrst fgh f}            {u abcde pqrst abcde fg}\n      67  {u pqrst kl u uvw klmno}            {u pqr pqrs fgh u p}\n      68  {abc fghi uvwxy fgh k pq}           {uv p uvwx uvwxyz ab}\n      69  {klmno f uvwxyz uvwxy klmn fg ab}   {fgh kl a pqr abcd pqr}\n      70  {fghi pqrst pqrst uv a}             {uvwxy k p uvw uvwx a}\n      71  {a fghij f p uvw}                   {klm fg abcd abcde klmno pqrs}\n      72  {uv uvwx uvwx uvw klm}              {uv fghi klmno uvwxy uvw}\n      73  {kl uvwxy ab f pq klm u}            {uvwxy klmn klm abcd pq fg k}\n      74  {uvw pqrst abcd uvwxyz ab}          {fgh fgh klmn abc pq}\n      75  {uvwxyz klm pq abcd klmno pqr uvwxyz} {kl f a fg pqr klmn}\n      76  {uvw uvwxy pqr k pqrst kl}          {uvwxy abc uvw uvw u}\n      77  {fgh klm u uvwxyz f uvwxy abcde}    {uv abcde klmno u u ab}\n      78  {klmno abc pq pqr fgh}              {p uv abcd fgh abc u k}\n      79  {fg pqr uvw pq uvwx}                {uv uvw fghij pqrs fg p}\n      80  {abcd pqrs uvwx uvwxy uvwx}         {u uvw pqrst pqr abcde pqrs kl}\n      81  {uvwxyz klm pq uvwxy fghij}         {p pq klm fghij u a a}\n      82  {uvwx k uvwxyz klmno pqrst kl}      {abcde p f pqrst abcd uvwxyz p}\n      83  {abcd abcde klm pqrst uvwxyz}       {uvw pqrst u p uvwxyz a pqrs}\n      84  {k klm abc uv uvwxy klm klmn}       {k abc pqr a abc p kl}\n      85  {klmn abcd pqrs p pq klm a}         {klmn kl ab uvw pq}\n      86  {klmn a pqrs abc uvw pqrst}         {a pqr kl klm a k f}\n      87  {pqrs ab uvwx uvwxy a pqr f}        {fg klm uvwx pqr pqr}\n      88  {klmno ab k kl u uvwxyz}            {uv kl uvw fghi uv uvw}\n      89  {pq fghi pqrst klmn uvwxy abc pqrs} {fg f f fg abc abcde klm}\n      90  {kl a k fghi uvwx fghi u}           {ab uvw pqr fg a p abc}\n      91  {uvwx pqrs klmno ab fgh uvwx}       {pqr uvwx abc kl f klmno kl}\n      92  {fghij pq pqrs fghij f pqrst}       {u abcde fg pq pqr fgh k}\n      93  {fgh u pqrs abcde klmno abc}        {abc fg pqrst pqr abcde}\n      94  {uvwx p abc f pqr p}                {k pqrs kl klm abc fghi klm}\n      95  {kl p klmno uvwxyz klmn}            {fghi ab a fghi pqrs kl}\n      96  {pqr fgh pq uvwx a}                 {uvw klm klmno fg uvwxy uvwx}\n      97  {fg abc uvwxyz fghi pqrst pq}       {abc k a ab abcde f}\n      98  {uvwxy fghi uvwxy u abcde abcde uvw} {klmn uvwx pqrs uvw uvwxy abcde}\n      99  {pq fg fghi uvwx uvwx fghij uvwxy}  {klmn klmn f abc fg a}\n    } {\n      execsql {\n        INSERT INTO t1(rowid, a, b) VALUES($rowid, $a, $b);\n      }\n    }\n  } {}\n  \n  proc prefix_query {prefixlist} {\n    set ret [list]\n    db eval {SELECT rowid, a, b FROM t1 ORDER BY rowid DESC} {\n      set bMatch 1\n      foreach pref $prefixlist {\n        if { [lsearch -glob $a $pref]<0 && [lsearch -glob $b $pref]<0 } {\n          set bMatch 0\n          break\n        }\n      }\n      if {$bMatch} { lappend ret $rowid }\n    }\n    return $ret\n  }\n\n  do_execsql_test $T.integrity {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n  \n  foreach {bAsc sql} {\n    1 {SELECT rowid FROM t1 WHERE t1 MATCH $prefix}\n    0 {SELECT rowid FROM t1 WHERE t1 MATCH $prefix ORDER BY rowid DESC}\n  } {\n    foreach {tn prefix} {\n      1  {a*} 2 {ab*} 3 {abc*} 4 {abcd*} 5 {abcde*} \n      6  {f*} 7 {fg*} 8 {fgh*} 9 {fghi*} 10 {fghij*}\n      11 {k*} 12 {kl*} 13 {klm*} 14 {klmn*} 15 {klmno*}\n      16 {p*} 17 {pq*} 18 {pqr*} 19 {pqrs*} 20 {pqrst*}\n      21 {u*} 22 {uv*} 23 {uvw*} 24 {uvwx*} 25 {uvwxy*} 26 {uvwxyz*}\n      27 {x*}\n      28 {a f*} 29 {a* f*} 30 {a* fghij*}\n    } {\n      set res [prefix_query $prefix]\n      if {$bAsc} {\n        set res [lsort -integer -increasing $res]\n      }\n      set n [llength $res]\n      do_execsql_test $T.$bAsc.$tn.$n $sql $res\n    }\n  }\n\n  catchsql COMMIT\n}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ae.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ae\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1 VALUES('hello', 'world');\n  SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC;\n} {1}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1 VALUES('world', 'hello');\n  SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC;\n} {1 2}\n\ndo_execsql_test 1.3 {\n  INSERT INTO t1 VALUES('world', 'world');\n  SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC;\n} {1 2}\n\ndo_execsql_test 1.4.1 {\n  INSERT INTO t1 VALUES('hello', 'hello');\n}\n\ndo_execsql_test 1.4.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'hello' ORDER BY rowid ASC;\n} {1 2 4}\n\nfts5_aux_test_functions db\n\n#-------------------------------------------------------------------------\n# \ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t2 VALUES('u t l w w m s', 'm f m o l t k o p e');\n  INSERT INTO t2 VALUES('f g q e l n d m z x q', 'z s i i i m f w w f n g p');\n}\n\ndo_execsql_test 2.1 {\n  SELECT rowid, fts5_test_poslist(t2) FROM t2 \n  WHERE t2 MATCH 'm' ORDER BY rowid;\n} {\n  1 {0.0.5 0.1.0 0.1.2} \n  2 {0.0.7 0.1.5}\n}\n\ndo_execsql_test 2.2 {\n  SELECT rowid, fts5_test_poslist(t2) FROM t2 \n  WHERE t2 MATCH 'u OR q' ORDER BY rowid;\n} {\n  1 {0.0.0}\n  2 {1.0.2 1.0.10}\n}\n\nif {[detail_is_full]} {\n  do_execsql_test 2.3 {\n    SELECT rowid, fts5_test_poslist(t2) FROM t2 \n      WHERE t2 MATCH 'y:o' ORDER BY rowid;\n  } {\n    1 {0.1.3 0.1.7}\n  }\n}\n\n#-------------------------------------------------------------------------\n# \ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t3 VALUES( 'j f h o x x a z g b a f a m i b', 'j z c z y x w t');\n  INSERT INTO t3 VALUES( 'r c', '');\n}\n\nif {[detail_is_full]} {\n  do_execsql_test 3.1 {\n    SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(a b)';\n  } {\n    1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15}\n  }\n\n  do_execsql_test 3.2 {\n    SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'NEAR(r c)';\n  } {\n    2 {0.0.0 1.0.1}\n  }\n}\n\ndo_execsql_test 3.3 {\n  INSERT INTO t3 \n  VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o');\n  SELECT rowid, fts5_test_poslist(t3) \n  FROM t3 WHERE t3 MATCH 'a OR b AND c';\n} {\n  1 {0.0.6 1.0.9 0.0.10 0.0.12 1.0.15 2.1.2}\n  3 0.0.5 \n}\n\n#-------------------------------------------------------------------------\n# \ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t4 \n  VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o');\n}\n\ndo_execsql_test 4.1 {\n  SELECT rowid, fts5_test_poslist(t4) FROM t4 WHERE t4 MATCH 'a OR b AND c';\n} {\n  1 0.0.5\n}\n\n#-------------------------------------------------------------------------\n# Test that the xColumnSize() and xColumnAvgsize() APIs work.\n#\nreset_db\nfts5_aux_test_functions db\n\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE t5 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t5 VALUES('a b c d', 'e f g h i j');\n  INSERT INTO t5 VALUES('', 'a');\n  INSERT INTO t5 VALUES('a', '');\n}\ndo_execsql_test 5.2 {\n  SELECT rowid, fts5_test_columnsize(t5) FROM t5 WHERE t5 MATCH 'a'\n  ORDER BY rowid DESC;\n} {\n  3 {1 0}\n  2 {0 1}\n  1 {4 6}\n}\n\ndo_execsql_test 5.3 {\n  SELECT rowid, fts5_test_columntext(t5) FROM t5 WHERE t5 MATCH 'a'\n  ORDER BY rowid DESC;\n} {\n  3 {a {}}\n  2 {{} a}\n  1 {{a b c d} {e f g h i j}}\n}\n\ndo_execsql_test 5.4 {\n  SELECT rowid, fts5_test_columntotalsize(t5) FROM t5 WHERE t5 MATCH 'a'\n  ORDER BY rowid DESC;\n} {\n  3 {5 7}\n  2 {5 7}\n  1 {5 7}\n}\n\ndo_execsql_test 5.5 {\n  INSERT INTO t5 VALUES('x y z', 'v w x y z');\n  SELECT rowid, fts5_test_columntotalsize(t5) FROM t5 WHERE t5 MATCH 'a'\n  ORDER BY rowid DESC;\n} {\n  3 {8 12}\n  2 {8 12}\n  1 {8 12}\n}\n\n#-------------------------------------------------------------------------\n# Test the xTokenize() API\n#\nreset_db\nfts5_aux_test_functions db\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE t6 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t6 VALUES('There are more', 'things in heaven and earth');\n  INSERT INTO t6 VALUES(', Horatio, Than are', 'dreamt of in your philosophy.');\n}\n\ndo_execsql_test 6.2 {\n  SELECT rowid, fts5_test_tokenize(t6) FROM t6 WHERE t6 MATCH 't*'\n} {\n  1 {{there are more} {things in heaven and earth}}\n  2 {{horatio than are} {dreamt of in your philosophy}}\n}\n\n#-------------------------------------------------------------------------\n# Test the xQueryPhrase() API\n#\nreset_db\nfts5_aux_test_functions db\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE t7 USING fts5(x, y, detail=%DETAIL%);\n}\ndo_test 7.2 {\n  foreach {x y} {\n    {q i b w s a a e l o} {i b z a l f p t e u}\n    {b a z t a l o x d i} {b p a d b f h d w y}\n    {z m h n p p u i e g} {v h d v b x j j c z}\n    {a g i m v a u c b i} {p k s o t l r t b m}\n    {v v c j o d a s c p} {f f v o k p o f o g}\n  } {\n    execsql {INSERT INTO t7 VALUES($x, $y)}\n  }\n  execsql { SELECT count(*) FROM t7 }\n} {5}\n\nforeach {tn q res} {\n  1 a {{4 2}}\n  2 b {{3 4}}\n  3 c {{2 1}}\n  4 d {{2 2}}\n  5 {a AND b} {{4 2} {3 4}}\n  6 {a OR b OR c OR d} {{4 2} {3 4} {2 1} {2 2}}\n} {\n  do_execsql_test 7.3.$tn { \n    SELECT fts5_test_queryphrase(t7) FROM t7 WHERE t7 MATCH $q LIMIT 1\n  } [list $res]\n}\n\ndo_execsql_test 7.4 {\n  SELECT fts5_test_rowcount(t7) FROM t7 WHERE t7 MATCH 'a';\n} {5 5 5 5}\n\n#do_execsql_test 7.4 {\n#  SELECT rowid, bm25debug(t7) FROM t7 WHERE t7 MATCH 'a';\n#} {5 5 5 5}\n#\n\n#-------------------------------------------------------------------------\n#\ndo_test 8.1 {\n  execsql { CREATE VIRTUAL TABLE t8 USING fts5(x, y, detail=%DETAIL%) }\n  foreach {rowid x y} {\n     0 {A o}   {o o o C o o o o o o o o}\n     1 {o o B} {o o o C C o o o o o o o}\n     2 {A o o} {o o o o D D o o o o o o}\n     3 {o B}   {o o o o o D o o o o o o}\n     4 {E o G} {H o o o o o o o o o o o}\n     5 {F o G} {I o J o o o o o o o o o}\n     6 {E o o} {H o J o o o o o o o o o}\n     7 {o o o} {o o o o o o o o o o o o}\n     9 {o o o} {o o o o o o o o o o o o}\n  } {\n    execsql { INSERT INTO t8(rowid, x, y) VALUES($rowid, $x, $y) }\n  }\n} {}\n\nforeach {tn q res} {\n  1 {a} {0 2}\n  2 {b} {3 1}\n  3 {c} {1 0}\n  4 {d} {2 3}\n  5 {g AND (e OR f)} {5 4}\n  6 {j AND (h OR i)} {5 6}\n} {\n  do_execsql_test 8.2.$tn.1 {\n    SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY bm25(t8);\n  } $res\n\n  do_execsql_test 8.2.$tn.2 {\n    SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY +rank;\n  } $res\n\n  do_execsql_test 8.2.$tn.3 {\n    SELECT rowid FROM t8 WHERE t8 MATCH $q ORDER BY rank;\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Test xPhraseCount() for some different queries.\n#\ndo_test 9.1 {\n  execsql { CREATE VIRTUAL TABLE t9 USING fts5(x) }\n  foreach x {\n    \"a b c\" \"d e f\"\n  } {\n    execsql { INSERT INTO t9 VALUES($x) }\n  }\n} {}\n\nforeach {tn q cnt} {\n  1 {a AND b}      2\n  2 {a OR b}       2\n  3 {a OR b OR c}  3\n  4 {NEAR(a b)}    2\n} {\n  do_execsql_test 9.2.$tn {\n    SELECT fts5_test_phrasecount(t9) FROM t9 WHERE t9 MATCH $q LIMIT 1\n  } $cnt\n}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5af.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n# \n# More specifically, the tests in this file focus on the built-in \n# snippet() function.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5af\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=%DETAIL%);\n}\n\nproc do_snippet_test {tn doc match res} {\n\n  uplevel #0 [list set v1 $doc]\n  uplevel #0 [list set v2 $match]\n\n  do_execsql_test $tn.1 {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES($v1, NULL);\n    SELECT snippet(t1, -1, '[', ']', '...', 7) FROM t1 WHERE t1 MATCH $v2;\n  } [list $res]\n\n  do_execsql_test $tn.2 {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(NULL, $v1);\n    SELECT snippet(t1, -1, '[', ']', '...', 7) FROM t1 WHERE t1 MATCH $v2;\n  } [list $res]\n\n  do_execsql_test $tn.3 {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES($v1, NULL);\n    SELECT snippet(t1, -1, '[', ']', '...', 7) FROM t1 WHERE t1 MATCH $v2\n    ORDER BY rank DESC;\n  } [list $res]\n\n\n}\n\n\nforeach {tn doc res} {\n\n  1.1 {X o o o o o o} {[X] o o o o o o}\n  1.2 {o X o o o o o} {o [X] o o o o o}\n  1.3 {o o X o o o o} {o o [X] o o o o}\n  1.4 {o o o X o o o} {o o o [X] o o o}\n  1.5 {o o o o X o o} {o o o o [X] o o}\n  1.6 {o o o o o X o} {o o o o o [X] o}\n  1.7 {o o o o o o X} {o o o o o o [X]}\n\n  2.1 {X o o o o o o o} {[X] o o o o o o...}\n  2.2 {o X o o o o o o} {o [X] o o o o o...}\n  2.3 {o o X o o o o o} {o o [X] o o o o...}\n  2.4 {o o o X o o o o} {o o o [X] o o o...}\n  2.5 {o o o o X o o o} {o o o o [X] o o...}\n  2.6 {o o o o o X o o} {o o o o o [X] o...}\n  2.7 {o o o o o o X o} {o o o o o o [X]...}\n  2.8 {o o o o o o o X} {...o o o o o o [X]}\n\n  2.9  {o o o o o o o X o}       {...o o o o o [X] o}\n  2.10 {o o o o o o o X o o}     {...o o o o [X] o o}\n  2.11 {o o o o o o o X o o o}   {...o o o [X] o o o}\n  2.12 {o o o o o o o X o o o o} {...o o o [X] o o o...}\n\n\n  3.1 {X o o o o o o o o} {[X] o o o o o o...}\n  3.2 {o X o o o o o o o} {o [X] o o o o o...}\n  3.3 {o o X o o o o o o} {o o [X] o o o o...}\n  3.4 {o o o X o o o o o} {o o o [X] o o o...}\n\n  3.5 {o o o o o o o X o o o o} {...o o o [X] o o o...}\n  3.6 {o o o o o o o o X o o o} {...o o o [X] o o o}\n  3.7 {o o o o o o o o o X o o} {...o o o o [X] o o}\n  3.8 {o o o o o o o o o o X o} {...o o o o o [X] o}\n  3.9 {o o o o o o o o o o o X} {...o o o o o o [X]}\n\n  4.1 {X o o o o o X o o} {[X] o o o o o [X]...}\n  4.2 {o o o o o o o X o o o o o X o} {...[X] o o o o o [X]...}\n  4.3 {o o o o o o o o X o o o o o X} {...[X] o o o o o [X]}\n\n  5.1 {X o o o o X o o o} {[X] o o o o [X] o...}\n  5.2 {o o o o o o o X o o o o X o o} {...[X] o o o o [X] o...}\n  5.3 {o o o o o o o o X o o o o X o} {...[X] o o o o [X] o}\n  5.4 {o o o o o o o o o X o o o o X} {...o [X] o o o o [X]}\n\n  6.1 {X o o o X o o o} {[X] o o o [X] o o...}\n  6.2 {o X o o o X o o o} {o [X] o o o [X] o...}\n  6.3 {o o o o o o o X o o o X o o} {...o [X] o o o [X] o...}\n  6.4 {o o o o o o o o X o o o X o} {...o [X] o o o [X] o}\n  6.5 {o o o o o o o o o X o o o X} {...o o [X] o o o [X]}\n\n  7.1 {X o o X o o o o o} {[X] o o [X] o o o...}\n  7.2 {o X o o X o o o o} {o [X] o o [X] o o...}\n  7.3 {o o o o o o o X o o X o o o} {...o [X] o o [X] o o...}\n  7.4 {o o o o o o o o X o o X o o} {...o [X] o o [X] o o}\n  7.5 {o o o o o o o o o X o o X o} {...o o [X] o o [X] o}\n  7.6 {o o o o o o o o o o X o o X} {...o o o [X] o o [X]}\n\n  8.1 {o o o o o o o o o X o o o o o o o o o o o o o o o o X X X o o o}\n      {...o o [X] [X] [X] o o...}\n  8.2 {o o o o o o o. o o X o o o o o o o o o o o o o o o o X X X o o o} \n      {...o o [X] o o o o...}\n  8.3 {o o o o X o o o o o o o o o o o o o o o o o o o o o X X X o o o} \n      {o o o o [X] o o...}\n} {\n  do_snippet_test 1.$tn $doc X $res\n}\n\nif {[detail_is_full]} {\n  foreach {tn doc res} {\n    1.1 {X Y o o o o o} {[X Y] o o o o o}\n    1.2 {o X Y o o o o} {o [X Y] o o o o}\n    1.3 {o o X Y o o o} {o o [X Y] o o o}\n    1.4 {o o o X Y o o} {o o o [X Y] o o}\n    1.5 {o o o o X Y o} {o o o o [X Y] o}\n    1.6 {o o o o o X Y} {o o o o o [X Y]}\n\n    2.1 {X Y o o o o o o} {[X Y] o o o o o...}\n    2.2 {o X Y o o o o o} {o [X Y] o o o o...}\n    2.3 {o o X Y o o o o} {o o [X Y] o o o...}\n    2.4 {o o o o o o o X Y o o o} {...o o [X Y] o o o}\n    2.5 {o o o o o o o o X Y o o} {...o o o [X Y] o o}\n    2.6 {o o o o o o o o o X Y o} {...o o o o [X Y] o}\n    2.7 {o o o o o o o o o o X Y} {...o o o o o [X Y]}\n\n    3.1 {X Y o o o o o o o} {[X Y] o o o o o...}\n    3.2 {o X Y o o o o o o} {o [X Y] o o o o...}\n    3.3 {o o X Y o o o o o} {o o [X Y] o o o...}\n    3.4 {o o o o o o o X Y o o o o} {...o o [X Y] o o o...}\n    3.5 {o o o o o o o o X Y o o o} {...o o [X Y] o o o}\n    3.6 {o o o o o o o o o X Y o o} {...o o o [X Y] o o}\n    3.7 {o o o o o o o o o o X Y o} {...o o o o [X Y] o}\n    3.8 {o o o o o o o o o o o X Y} {...o o o o o [X Y]}\n  } {\n    do_snippet_test 2.$tn $doc \"X + Y\" $res\n  }\n}\n\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(a, b);\n  INSERT INTO x1 VALUES('xyz', '1 2 3 4 5 6 7 8 9 10 11 12 13');\n  SELECT snippet(x1, 1, '[', ']', '...', 5) FROM x1('xyz');\n} {\n  {1 2 3 4 5...}\n}\n\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE p1 USING fts5(a, b);\n  INSERT INTO p1 VALUES(\n    'x a a a a a a a a a a',\n    'a a a a a a a a a a a a a a a a a a a x'\n  );\n}\ndo_execsql_test 5.1 {\n  SELECT snippet(p1, 0, '[', ']', '...', 6) FROM p1('x');\n} {{[x] a a a a a...}}\n\n} ;# foreach_detail_mode \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ag.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ag\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# This file attempts to verify that the extension APIs work with \n# \"ORDER BY rank\" queries. This is done by comparing the results of\n# the fts5_test() function when run with queries of the form:\n#\n#      ... WHERE fts MATCH ? ORDER BY bm25(fts) [ASC|DESC]\n#\n# and\n#\n#      ... WHERE fts MATCH ? ORDER BY rank [ASC|DESC]\n#\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y, z, detail=%DETAIL%);\n}\n\ndo_test 1.1 {\n  foreach {x y z} {\n    {j s m y m r n l u k} {z k f u z g h s w g} {r n o s s b v n w w}\n    {m v g n d x q r r s} {q t d a q a v l h j} {s k l f s i n v q v}\n    {m f f d h h s o h a} {y e v r q i u m h d} {b c k q m z l z h n}\n    {j e m v k p e c j m} {m p v z d x l n i a} {v p u p m t p q i f}\n    {v r w l e e t d z p} {c s b w k m n k o u} {w g y f v w v w v p}\n    {k d g o u j p z n o} {t g e q l z i g b j} {f i q q j y h b g h}\n    {j s w x o t j b t m} {v a v v r t x c q a} {r t k x w u l h a g}\n    {j y b i u d e m d w} {y s o j h i n a u p} {n a g b u c w e b m}\n    {b c k s c w j p w b} {m o c o w o b d q q} {n t y o y z y r z e}\n    {p n q l e l h z q c} {n s e i h c v b b u} {m p d i t a o o f f}\n    {k c o n v e z l b m} {s m n i n s d e s u} {t a u e q d a o u c}\n    {h d t o i a g b b p} {k x c i g f g b b k} {x f i v n a n n j i}\n    {f z k r b u s k z e} {n z v z w l e r h t} {t i s v v a v p n s}\n    {k f e c t z r e f d} {f m g r c w q k b v} {v y s y f r b f e f}\n    {z r c t d q q h x b} {u c g z n z u v s s} {y t n f f x b f d x}\n    {u n p n u t i m e j} {p j j d m f k p m z} {d o l v c o e a h w}\n    {h o q w t f v i c y} {c q u n r z s l l q} {z x a q w s b w s y}\n    {y m s x k i m n x c} {b i a n v h z n k a} {w l q p b h h g d y}\n    {z v s j f p v l f w} {c s b i z e k i g c} {x b v d w j f e d z}\n    {r k k j e o m k g b} {h b d c h m y b t u} {u j s h k z c u d y}\n    {v h i v s y z i k l} {d t m w q w c a z p} {r s e s x v d w k b}\n    {u r e q j y h o o s} {x x z r x y t f j s} {k n h x i i u e c v}\n    {q l f d a p w l q o} {y z q w j o p b o v} {s u h z h f d f n l}\n    {q o e o x x l g q i} {j g m h q q w c d b} {o m d h w a g b f n}\n    {m x k t s s y l v a} {j x t c a u w b w g} {n f j b v x y p u t}\n    {u w k a q b u w k w} {a h j u o w f s k p} {j o f s h y t j h g}\n    {x v b l m t l m h l} {t p y i y i q b q a} {k o o z w a c h c f}\n    {j g c d k w b d t v} {a k v c m a v h v p} {i c a i j g h l j h}\n    {l m v l c z j b p b} {z p z f l n k i b a} {j v q k g i x g i b}\n    {m c i w u z m i s z} {i z r f n l q z k w} {x n b p b q r g i z}\n    {d g i o o x l f x d} {r t m f b n q y c b} {i u g k w x n m p o}\n    {t o s i q d z x d t} {v a k s q z j c o o} {z f n n r l y w v v}\n    {w k h d t l j g n n} {r z m v y b l n c u} {v b v s c l n k g v}\n    {m a g r a b u u n z} {u y l h v w v k b f} {x l p g i s j f x v}\n    {v s g x k z a k a r} {l t g v j q l k p l} {f h n a x t v s t y}\n    {z u v u x p s j y t} {g b q e e g l n w g} {e n p j i g j f u r}\n    {q z l t w o l m p e} {t s g h r p r o t z} {y b f a o n u m z g}\n    {d t w n y b o g f o} {d a j e r l g g s h} {d z e l w q l t h f}\n    {f l u w q v x j a h} {f n u l l d m h h w} {d x c c e r o d q j}\n    {b y f q s q f u l g} {u z w l f d b i a g} {m v q b g u o z e z}\n    {h z p t s e x i v m} {l h q m e o x x x j} {e e d n p r m g j f}\n    {k h s g o n s d a x} {u d t t s j o v h a} {z r b a e u v o e s}\n    {m b b g a f c p a t} {w c m j o d b l g e} {f p j p m o s y v j}\n    {c r n h d w c a b l} {s g e u s d n j b g} {b o n a x a b x y l}\n    {r h u x f c d z n o} {x y l g u m i i w d} {t f h b z v r s r g}\n    {t i o r b v g g p a} {d x l u q k m o s u} {j f h t u n z u k m}\n    {g j t y d c n j y g} {w e s k v c w i g t} {g a h r g v g h r o}\n    {e j l a q j g i n h} {d z k c u p n u p p} {t u e e v z v r r g}\n    {l j s g k j k h z l} {p v d a t x d e q u} {r l u z b m g k s j}\n    {i e y d u x d i n l} {p f z k m m w p u l} {z l p m r q w n d a}\n  } {\n    execsql { INSERT INTO t1 VALUES($x, $y, $z) }\n  }\n  set {} {}\n} {}\n\nfts5_aux_test_functions db\n\nproc do_fts5ag_test {tn E} {\n  set q1 {SELECT fts5_test_all(t1) FROM t1 WHERE t1 MATCH $E ORDER BY rank}\n  set q2 {SELECT fts5_test_all(t1) FROM t1 WHERE t1 MATCH $E ORDER BY bm25(t1)}\n\n  set res [execsql $q1]\n  set expected [execsql $q2]\n  uplevel [list do_test $tn.1 [list set {} $res] $expected]\n\n  append q1 \" DESC\"\n  append q2 \" DESC\"\n\n  set res [execsql $q1]\n  set expected [execsql $q2]\n  uplevel [list do_test $tn.2 [list set {} $res] $expected]\n}\n\nforeach {tn expr} {\n  2.1 a\n  2.2 b\n  2.3 c\n  2.4 d\n\n  3.0 {a AND b}\n  3.1 {a OR b}\n  3.2 {b OR c AND d}\n} {\n  do_fts5ag_test $tn $expr\n}\n\nif {[detail_is_full]} {\n  foreach {tn expr} {\n    4.1 {\"m m\"}\n    4.2 {e + s}\n    4.3 {NEAR(c d)}\n  } {\n    do_fts5ag_test $tn $expr\n  }\n}\n\n} ;# foreach_detail_mode\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ah.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ah\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\n#-------------------------------------------------------------------------\n# This file contains tests for very large doclists.\n#\n\nset Y [list]\nset W [list]\ndo_test 1.0 {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts5(a, detail=%DETAIL%) }\n  execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 128) }\n  set v {w w w w w w w w w w w w w w w w w w w w}\n  execsql { INSERT INTO t1(rowid, a) VALUES(0, $v) }\n  for {set i 1} {$i <= 10000} {incr i} {\n    set v {x x x x x x x x x x x x x x x x x x x x}\n    if {($i % 2139)==0} {lset v 3 Y ; lappend Y $i}\n    if {($i % 1577)==0} {lset v 5 W ; lappend W $i}\n    execsql { INSERT INTO t1 VALUES($v) }\n  }\n  set v {w w w w w w w w w w w w w w w w w w w w}\n  execsql { INSERT INTO t1 VALUES($v) }\n} {}\n\ndo_execsql_test 1.1.1 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'x AND w'\n} [lsort -integer -incr $W]\n\ndo_execsql_test 1.1.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'x* AND w*'\n} [lsort -integer -incr $W]\n\ndo_execsql_test 1.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'y AND x'\n} [lsort -integer -incr $Y]\n\ndo_execsql_test 1.3 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\nproc reads {} {\n  db one {SELECT t1 FROM t1 WHERE t1 MATCH '*reads'}\n}\n\nproc execsql_reads {sql} {\n  set nRead [reads]\n  execsql $sql\n  expr [reads] - $nRead\n}\n\ndo_test 1.4 {\n  set nRead [reads]\n  execsql { SELECT rowid FROM t1 WHERE t1 MATCH 'x' }\n  set nReadX [expr [reads] - $nRead]\n  #puts -nonewline \"(nReadX=$nReadX)\"\n  if {[detail_is_full]} { set expect 1000 }\n  if {[detail_is_col]}  { set expect 250 }\n  if {[detail_is_none]} { set expect 80 }\n\n  expr $nReadX>$expect\n} {1}\n\ndo_test 1.5 {\n  set fwd [execsql_reads {SELECT rowid FROM t1 WHERE t1 MATCH 'x' }]\n  set bwd [execsql_reads {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'x' ORDER BY 1 ASC \n  }]\n  expr {$bwd < $fwd + 12}\n} {1}\n\nforeach {tn q res} \"\n  1 { SELECT rowid FROM t1 WHERE t1 MATCH 'w + x'   }  [list $W]\n  2 { SELECT rowid FROM t1 WHERE t1 MATCH 'x + w'   }  [list $W]\n  3 { SELECT rowid FROM t1 WHERE t1 MATCH 'x AND w' }  [list $W]\n  4 { SELECT rowid FROM t1 WHERE t1 MATCH 'y AND x' }  [list $Y]\n\" {\n  if {[detail_is_full]==0 && ($tn==1 || $tn==2)} continue\n\n  if {[detail_is_full]} { set ratio 8 }\n  if {[detail_is_col]}  { set ratio 4 }\n  if {[detail_is_none]} { set ratio 2 }\n\n  do_test 1.6.$tn.1 {\n    set n [execsql_reads $q]\n    #puts -nonewline \"(n=$n nReadX=$nReadX)\"\n    expr {$n < ($nReadX / $ratio)}\n  } {1}\n\n  do_test 1.6.$tn.2 {\n    set n [execsql_reads \"$q ORDER BY rowid DESC\"]\n    #puts -nonewline \"(n=$n nReadX=$nReadX)\"\n    expr {$n < ($nReadX / $ratio)}\n  } {1}\n\n  do_execsql_test 1.6.$tn.3 $q [lsort -int -incr $res]\n  do_execsql_test 1.6.$tn.4 \"$q ORDER BY rowid DESC\" [lsort -int -decr $res]\n}\n\n#-------------------------------------------------------------------------\n# Now test that adding range constraints on the rowid field reduces the\n# number of pages loaded from disk.\n#\nforeach {tn fraction tail cnt} {\n  1  0.6 {rowid > 5000} 5000\n  2  0.2 {rowid > 9000} 1000\n  3  0.2 {rowid < 1000}  999\n  4  0.2 {rowid BETWEEN 4000 AND 5000}  1001\n  5  0.6 {rowid >= 5000} 5001\n  6  0.2 {rowid >= 9000} 1001\n  7  0.2 {rowid <= 1000} 1000\n  8  0.6 {rowid > '5000'} 5000\n  9  0.2 {rowid > '9000'} 1000\n  10 0.1 {rowid = 444} 1\n} {\n  set q \"SELECT rowid FROM t1 WHERE t1 MATCH 'x' AND $tail\"\n  set n [execsql_reads $q]\n  set ret [llength [execsql $q]]\n\n  # Because the position lists for 'x' are quite long in this db, the \n  # advantage is a bit smaller in detail=none mode. Update $fraction to \n  # reflect this.\n  if {[detail_is_none] && $fraction<0.5} { set fraction [expr $fraction*2] }\n\n  do_test \"1.7.$tn.asc.(n=$n ret=$ret)\" {\n    expr {$n < ($fraction*$nReadX) && $ret==$cnt}\n  } {1}\n\n  set q \"SELECT rowid FROM t1 WHERE t1 MATCH 'x' AND $tail ORDER BY rowid DESC\"\n  set n [execsql_reads $q]\n  set ret [llength [execsql $q]]\n  do_test \"1.7.$tn.desc.(n=$n ret=$ret)\" {\n    expr {$n < 2*$fraction*$nReadX && $ret==$cnt}\n  } {1}\n}\n\ndo_execsql_test 1.8.1 {\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND +rowid < 'text';\n} {10000}\ndo_execsql_test 1.8.2 {\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'x' AND rowid < 'text';\n} {10000}\n\n} ;# foreach_detail_mode\n\n#db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ai.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# Specifically, it tests transactions and savepoints\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ai\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=%DETAIL%);\n} {}\n\ndo_execsql_test 1.1 {\n  BEGIN;\n    INSERT INTO t1 VALUES('a b c');\n    INSERT INTO t1 VALUES('d e f');\n    SAVEPOINT one;\n      INSERT INTO t1 VALUES('g h i');\n      SAVEPOINT two;\n        INSERT INTO t1 VALUES('j k l');\n    ROLLBACK TO one;\n      INSERT INTO t1 VALUES('m n o');\n        SAVEPOINT two;\n        INSERT INTO t1 VALUES('p q r');\n    RELEASE one;\n    SAVEPOINT one;\n      INSERT INTO t1 VALUES('s t u');\n    ROLLBACK TO one;\n  COMMIT;\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5aj.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# Specifically, this tests that, provided the amount of data remains \n# constant, the FTS index does not grow indefinitely as rows are inserted \n# and deleted,\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5aj\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc doc {} {\n  set dict [list a b c d e f g h i j k l m n o p q r s t u v w x y z]\n  set res [list]\n  for {set i 0} {$i < 20} {incr i} {\n    lappend res [lindex $dict [expr int(rand() * 26)]]\n  }\n  set res\n}\n\nproc structure {} {\n  set val [db one {SELECT fts5_decode(rowid,block) FROM t1_data WHERE rowid=10}]\n  foreach lvl [lrange $val 1 end] {\n    lappend res [expr [llength $lvl]-2]\n  }\n  set res\n}\n\nexpr srand(0)\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 64);\n}\n\nfor {set iTest 0} {$iTest < 50000} {incr iTest} {\n  if {$iTest > 1000} { execsql { DELETE FROM t1 WHERE rowid=($iTest-1000) } }\n  set new [doc]\n  execsql { INSERT INTO t1 VALUES($new) }\n  if {$iTest==10000} { set sz1 [db one {SELECT count(*) FROM t1_data}] }\n  if {0==($iTest % 1000)} {\n    set sz [db one {SELECT count(*) FROM t1_data}]\n    set s [structure]\n    do_execsql_test 1.$iTest.$sz.{$s} {\n      INSERT INTO t1(t1) VALUES('integrity-check') \n    }\n  }\n}\n\ndo_execsql_test 2.0 { INSERT INTO t1(t1) VALUES('integrity-check') }\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ak.test",
    "content": "# 2014 November 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# Specifically, the auxiliary function \"highlight\".\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ak\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO ft1 VALUES('i d d a g i b g d d');\n  INSERT INTO ft1 VALUES('h d b j c c g a c a');\n  INSERT INTO ft1 VALUES('e j a e f h b f h h');\n  INSERT INTO ft1 VALUES('j f h d g h i b d f');\n  INSERT INTO ft1 VALUES('d c j d c j b c g e');\n  INSERT INTO ft1 VALUES('i a d e g j g d a a');\n  INSERT INTO ft1 VALUES('j f c e d a h j d b');\n  INSERT INTO ft1 VALUES('i c c f a d g h j e');\n  INSERT INTO ft1 VALUES('i d i g c d c h b f');\n  INSERT INTO ft1 VALUES('g d a e h a b c f j');\n\n  CREATE VIRTUAL TABLE ft2 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO ft2 VALUES('a b c d e f g h i j');\n}\n\ndo_execsql_test 1.2 {\n  SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e';\n} {\n  {[e] j a [e] f h b f h h}\n  {d c j d c j b c g [e]}\n  {i a d [e] g j g d a a}\n  {j f c [e] d a h j d b}\n  {i c c f a d g h j [e]}\n  {g d a [e] h a b c f j}\n}\n\ndo_execsql_test 1.3 {\n  SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e e e'\n} {\n  {[e] j a [e] f h b f h h}\n  {d c j d c j b c g [e]}\n  {i a d [e] g j g d a a}\n  {j f c [e] d a h j d b}\n  {i c c f a d g h j [e]}\n  {g d a [e] h a b c f j}\n}\n\ndo_execsql_test 1.4 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'f d'\n} {\n  {a b c [d] e [f] g h i j}\n}\n\ndo_execsql_test 1.5 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'd f'\n} {\n  {a b c [d] e [f] g h i j}\n}\n\n#-------------------------------------------------------------------------\n# Tests below this point require detail=full.\n#-------------------------------------------------------------------------\nif {[detail_is_full]==0} continue\n\n\ndo_execsql_test 2.1 {\n  SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'h + d';\n} {\n  {[h d] b j c c g a c a}\n  {j f [h d] g h i b d f} \n}\n\ndo_execsql_test 2.2 {\n  SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d';\n} {\n  {i [d d] a g i b g [d d]}\n}\n\ndo_execsql_test 2.3 {\n  SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'd + d d + d';\n} {\n  {i [d d] a g i b g [d d]}\n}\n\ndo_execsql_test 2.4 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c+d+e'\n} {{a [b c d e] f g h i j}}\n\ndo_execsql_test 2.5 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d e+f+g'\n} {\n  {a [b c d] [e f g] h i j}\n}\n\ndo_execsql_test 2.6 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c+d c'\n} {\n  {a [b c d] e f g h i j}\n}\n\ndo_execsql_test 2.7 {\n  SELECT highlight(ft2, 0, '[', ']') FROM ft2 WHERE ft2 MATCH 'b+c c+d+e'\n} {\n  {a [b c d e] f g h i j}\n}\n\n#-------------------------------------------------------------------------\n# The example from the docs.\n#\ndo_execsql_test 3.1 {\n  -- Assuming this:\n  CREATE VIRTUAL TABLE ft USING fts5(a, detail=%DETAIL%);\n  INSERT INTO ft VALUES('a b c x c d e');\n  INSERT INTO ft VALUES('a b c c d e');\n  INSERT INTO ft VALUES('a b c d e');\n\n  -- The following SELECT statement returns these three rows:\n  --   '[a b c] x [c d e]'\n  --   '[a b c] [c d e]'\n  --   '[a b c d e]'\n  SELECT highlight(ft, 0, '[', ']') FROM ft WHERE ft MATCH 'a+b+c AND c+d+e';\n} {\n  {[a b c] x [c d e]}\n  {[a b c] [c d e]}\n  {[a b c d e]}\n}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5al.test",
    "content": "# 2014 November 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# Specifically, this function tests the %_config table.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5al\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, detail=%DETAIL%);\n  SELECT * FROM ft1_config;\n} {version 4}\n\ndo_execsql_test 1.2 {\n  INSERT INTO ft1(ft1, rank) VALUES('pgsz', 32);\n  SELECT * FROM ft1_config;\n} {pgsz 32 version 4}\n\ndo_execsql_test 1.3 {\n  INSERT INTO ft1(ft1, rank) VALUES('pgsz', 64);\n  SELECT * FROM ft1_config;\n} {pgsz 64 version 4}\n\n#--------------------------------------------------------------------------\n# Test the logic for parsing the rank() function definition.\n#\nforeach {tn defn} {\n  1 \"fname()\"\n  2 \"fname(1)\"\n  3 \"fname(1,2)\"\n  4 \"fname(null,NULL,nUlL)\"\n  5 \"  fname    (   null  ,   NULL  ,  nUlL  )  \"\n  6 \"fname('abc')\"\n  7 \"fname('a''bc')\"\n  8 \"fname('''abc')\"\n  9 \"fname('abc''')\"\n\n  7 \"fname(  'a''bc'  )\"\n  8 \"fname('''abc'  )\"\n  9 \"fname(  'abc''' )\"\n\n  10 \"fname(X'1234ab')\"\n\n  11 \"myfunc(1.2)\"\n  12 \"myfunc(-1.0)\"\n  13 \"myfunc(.01,'abc')\"\n} {\n  do_execsql_test 2.1.$tn {\n    INSERT INTO ft1(ft1, rank) VALUES('rank', $defn);\n  }\n}\n\nforeach {tn defn} {\n  1 \"\"\n  2 \"fname\"\n  3 \"fname(X'234ab')\"\n  4 \"myfunc(-1.,'abc')\"\n} {\n  do_test 2.2.$tn {\n    catchsql { INSERT INTO ft1(ft1, rank) VALUES('rank', $defn) }\n  } {1 {SQL logic error}}\n}\n\n#-------------------------------------------------------------------------\n# Assorted tests of the tcl interface for creating extension functions.\n#\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('q w e r t y');\n  INSERT INTO t1 VALUES('y t r e w q');\n}\n\nproc argtest {cmd args} { return $args }\nsqlite3_fts5_create_function db argtest argtest\n\ndo_execsql_test 3.2.1 {\n  SELECT argtest(t1, 123) FROM t1 WHERE t1 MATCH 'q'\n} {123 123}\n\ndo_execsql_test 3.2.2 {\n  SELECT argtest(t1, 123, 456) FROM t1 WHERE t1 MATCH 'q'\n} {{123 456} {123 456}}\n\nproc rowidtest {cmd} { $cmd xRowid }\nsqlite3_fts5_create_function db rowidtest rowidtest\n\ndo_execsql_test 3.3.1 {\n  SELECT rowidtest(t1) FROM t1 WHERE t1 MATCH 'q'\n} {1 2}\n\nproc insttest {cmd} {\n  set res [list]\n  for {set i 0} {$i < [$cmd xInstCount]} {incr i} {\n    lappend res [$cmd xInst $i]\n  }\n  set res\n}\nsqlite3_fts5_create_function db insttest insttest\n\ndo_execsql_test 3.4.1 {\n  SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'q'\n} {\n  {{0 0 0}}\n  {{0 0 5}} \n}\n\nif {[detail_is_full]} {\n  do_execsql_test 3.4.2 {\n    SELECT insttest(t1) FROM t1 WHERE t1 MATCH 'r+e OR w'\n  } {\n    {{1 0 1}}\n    {{0 0 2} {1 0 4}} \n  }\n}\n\nproc coltest {cmd} {\n  list [$cmd xColumnSize 0] [$cmd xColumnText 0]\n}\nsqlite3_fts5_create_function db coltest coltest\n\ndo_execsql_test 3.5.1 {\n  SELECT coltest(t1) FROM t1 WHERE t1 MATCH 'q'\n} {\n  {6 {q w e r t y}}\n  {6 {y t r e w q}} \n}\n\n#-------------------------------------------------------------------------\n# Tests for remapping the \"rank\" column.\n#\n#   4.1.*: Mapped to a function with no arguments.\n#   4.2.*: Mapped to a function with one or more arguments.\n#\n\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO t2 VALUES('a s h g s b j m r h', 's b p a d b b a o e');\n  INSERT INTO t2 VALUES('r h n t a g r d d i', 'l d n j r c f t o q');\n  INSERT INTO t2 VALUES('q k n i k c a a e m', 'c h n j p g s c i t');\n  INSERT INTO t2 VALUES('h j g t r e l s g s', 'k q k c i i c k n s');\n  INSERT INTO t2 VALUES('b l k h d n n n m i', 'p t i a r b t q o l');\n  INSERT INTO t2 VALUES('k r i l j b g i p a', 't q c h a i m g n l');\n  INSERT INTO t2 VALUES('a e c q n m o m d g', 'l c t g i s q g q e');\n  INSERT INTO t2 VALUES('b o j h f o g b p e', 'r t l h s b g i c p');\n  INSERT INTO t2 VALUES('s q k f q b j g h f', 'n m a o p e i e k t');\n  INSERT INTO t2 VALUES('o q g g q c o k a b', 'r t k p t f t h p c');\n}\n\nproc firstinst {cmd} { \n  foreach {p c o} [$cmd xInst 0] {}\n  expr $c*100 + $o\n}\nsqlite3_fts5_create_function db firstinst firstinst\n\ndo_execsql_test 4.1.1 {\n  SELECT rowid, firstinst(t2) FROM t2 WHERE t2 MATCH 'a' ORDER BY rowid ASC\n} {\n  1 0 2 4 3 6   5  103\n  6 9 7 0 9 102 10 8\n}\n\ndo_execsql_test 4.1.2 {\n  SELECT rowid, rank FROM t2 \n  WHERE t2 MATCH 'a' AND rank MATCH 'firstinst()' \n  ORDER BY rowid ASC\n} {\n  1 0 2 4 3 6   5  103\n  6 9 7 0 9 102 10 8\n}\n\ndo_execsql_test 4.1.3 {\n  SELECT rowid, rank FROM t2 \n  WHERE t2 MATCH 'a' AND rank MATCH 'firstinst()'\n  ORDER BY rank DESC\n} {\n  5 103  9 102  6 9  10 8  3 6  2 4  1 0  7 0  \n}\n\ndo_execsql_test 4.1.4 {\n  INSERT INTO t2(t2, rank) VALUES('rank', 'firstinst()');\n  SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' ORDER BY rowid ASC\n} {\n  1 0 2 4 3 6   5  103\n  6 9 7 0 9 102 10 8\n}\n\ndo_execsql_test 4.1.5 {\n  SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' ORDER BY rank DESC\n} {\n  5 103  9 102  6 9  10 8  3 6  2 4  1 0  7 0  \n}\n\ndo_execsql_test 4.1.6 {\n  INSERT INTO t2(t2, rank) VALUES('rank', 'firstinst (    ) ');\n  SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' ORDER BY rank DESC\n} {\n  5 103  9 102  6 9  10 8  3 6  2 4   1 0  7 0  \n}\n\nproc rowidplus {cmd ival} { \n  expr [$cmd xRowid] + $ival\n}\nsqlite3_fts5_create_function db rowidplus rowidplus\n\nif {[detail_is_full]} {\n  do_execsql_test 4.2.1 {\n    INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(100) ');\n    SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g'\n  } {\n    10 110\n  }\n  do_execsql_test 4.2.2 {\n    INSERT INTO t2(t2, rank) VALUES('rank', 'rowidplus(111) ');\n    SELECT rowid, rank FROM t2 WHERE t2 MATCH 'o + q + g'\n  } {\n    10 121\n  }\n\n  do_execsql_test 4.2.3 {\n    SELECT rowid, rank FROM t2 \n      WHERE t2 MATCH 'o + q + g' AND rank MATCH 'rowidplus(112)'\n  } {\n    10 122\n  }\n}\n\nproc rowidmod {cmd imod} { \n  expr [$cmd xRowid] % $imod\n}\nsqlite3_fts5_create_function db rowidmod rowidmod\ndo_execsql_test 4.3.1 {\n  CREATE VIRTUAL TABLE t3 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t3 VALUES('a one');\n  INSERT INTO t3 VALUES('a two');\n  INSERT INTO t3 VALUES('a three');\n  INSERT INTO t3 VALUES('a four');\n  INSERT INTO t3 VALUES('a five');\n  INSERT INTO t3(t3, rank) VALUES('rank', 'bm25()');\n}\n\ndo_execsql_test 4.3.2 {\n  SELECT * FROM t3\n  WHERE t3 MATCH 'a' AND rank MATCH 'rowidmod(4)' \n  ORDER BY rank ASC\n} {\n  {a four} {a one} {a five} {a two} {a three}\n}\n\ndo_execsql_test 4.3.3 {\n  SELECT *, rank FROM t3\n  WHERE t3 MATCH 'a' AND rank MATCH 'rowidmod(3)' \n  ORDER BY rank ASC\n} {\n  {a three} 0 {a one} 1 {a four} 1 {a two} 2 {a five} 2 \n}\n\ndo_execsql_test 4.3.4 {\n  SELECT * FROM t3('a', 'rowidmod(4)') ORDER BY rank ASC;\n} {\n  {a four} {a one} {a five} {a two} {a three}\n}\n\ndo_execsql_test 4.3.5 {\n  SELECT *, rank FROM t3('a', 'rowidmod(3)') ORDER BY rank ASC\n} {\n  {a three} 0 {a one} 1 {a four} 1 {a two} 2 {a five} 2 \n}\n\ndo_catchsql_test 4.4.3 {\n  SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH 'xyz(3)' \n} {1 {no such function: xyz}}\ndo_catchsql_test 4.4.4 {\n  SELECT *, rank FROM t3 WHERE t3 MATCH 'a' AND rank MATCH NULL\n} {1 {parse error in rank function: }}\n\n} ;# foreach_detail_mode\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5alter.test",
    "content": "# 2015 Jun 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file focus on renaming FTS5 tables using the\n# \"ALTER TABLE ... RENAME TO ...\" command\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5alter\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test renaming regular, contentless and columnsize=0 FTS5 tables.\n#\ndo_execsql_test 1.1.0 {\n  CREATE VIRTUAL TABLE \"a x\" USING fts5(a, x);\n  INSERT INTO \"a x\" VALUES('a a a', 'x x x');\n  ALTER TABLE \"a x\" RENAME TO \"x y\";\n}\ndo_execsql_test 1.1.1 {\n  SELECT * FROM \"x y\";\n  SELECT rowid FROM \"x y\" WHERE \"x y\" MATCH 'a'\n} {{a a a} {x x x} 1}\n\ndo_execsql_test 1.2.0 {\n  CREATE VIRTUAL TABLE \"one/two\" USING fts5(one, columnsize=0);\n  INSERT INTO \"one/two\"(rowid, one) VALUES(456, 'd d d');\n  ALTER TABLE \"one/two\" RENAME TO \"three/four\";\n}\ndo_execsql_test 1.2.1 {\n  SELECT * FROM \"three/four\";\n  SELECT rowid FROM \"three/four\" WHERE \"three/four\" MATCH 'd'\n} {{d d d} 456}\n\ndo_execsql_test 1.3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(val, content='');\n  INSERT INTO t1(rowid, val) VALUES(-1, 'drop table');\n  INSERT INTO t1(rowid, val) VALUES(-2, 'drop view');\n  ALTER TABLE t1 RENAME TO t2;\n}\ndo_execsql_test 1.3.1 {\n  SELECT rowid, * FROM t2;\n  SELECT rowid FROM t2 WHERE t2 MATCH 'table'\n} {-2 {} -1 {} -1}\n\n#-------------------------------------------------------------------------\n# Test renaming an FTS5 table within a transaction.\n#\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE zz USING fts5(a);\n  INSERT INTO zz(rowid, a) VALUES(-56, 'a b c');\n  BEGIN;\n    INSERT INTO zz(rowid, a) VALUES(-22, 'a b c');\n    ALTER TABLE zz RENAME TO yy;\n    SELECT rowid FROM yy WHERE yy MATCH 'a + b + c';\n  COMMIT;\n} {-56 -22}\n\ndo_execsql_test 2.2 {\n  BEGIN;\n    ALTER TABLE yy RENAME TO ww;\n    INSERT INTO ww(rowid, a) VALUES(-11, 'a b c');\n    SELECT rowid FROM ww WHERE ww MATCH 'a + b + c';\n} {-56 -22 -11}\n\ndo_execsql_test 2.3 {\n  ROLLBACK;\n  SELECT rowid FROM yy WHERE yy MATCH 'a + b + c';\n} {-56 -22}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE abc USING fts5(a);\n  INSERT INTO abc(rowid, a) VALUES(1, 'a');\n  BEGIN;\n    INSERT INTO abc(rowid, a) VALUES(2, 'a');\n}\ndo_execsql_test 3.2 {\n    SELECT rowid FROM abc WHERE abc MATCH 'a';\n} {1 2}\n\ndo_execsql_test 3.3 {\n  COMMIT;\n  SELECT rowid FROM abc WHERE abc MATCH 'a';\n} {1 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5auto.test",
    "content": "# 2015 May 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file contains automatically generated tests for various types\n# of MATCH expressions.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5auto\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nset data {\n    -4026076\n    {n x w k b p x b n t t d s}     {f j j s p j o}               \n    {w v i y r}                     {i p y s}                     \n    {a o q v e n q r}               {q v g u c y a z y}           \n    3995120\n    {c}                             {e e w d t}                   \n    {x c p f w r s m l r b f d}     {g g u e}                     \n    {s n u t d v p d}               {b k v p m f}                 \n    -2913881\n    {k m}                           {a}                           \n    {w r j z n s l}                 {m j i w d t w e l}           \n    {z n c}                         {v f b m}                     \n    174082\n    {j}                             {q l w u k e q v r i}         \n    {j l}                           {u v w r s p e l}             \n    {p i k j k q c t g u s}         {g u y s m h q k g t e s o r} \n    3207399\n    {e t}                           {}                            \n    {p}                             {y v r b e k h d e v}         \n    {t m w z b g q t s d d h}       {o n v u i t o y k j}         \n    182399\n    {}                              {m o s o x d y f a x j z}     \n    {x n z r c d}                   {n r x i r}                   \n    {s v s}                         {a u}                         \n    768994\n    {e u t q v z q k j p u f j p}   {y c b}                       \n    {p s d}                         {k n w p m p p}               \n    {u o x s d}                     {f s g r d b d r m m m z y}   \n    3931037\n    {c j p x e}                     {c n k t h z o i}             \n    {}                              {r r p j k x w q}             \n    {o r d z d}                     {x}                           \n    3105748\n    {p x r u}                       {x i s w o t o g x m z i w}   \n    {q x m z}                       {h c j w b l y w x c o}       \n    {m b k v}                       {t v q i s a d x}             \n    -2501642\n    {o u d n w o m o o s n t r h}   {k p e u y p e z d j r y g}   \n    {v b b h d d q y j q j}         {a m w d t}                   \n    {y e f n}                       {a k x i x}                   \n    -1745680\n    {z u w j f d b f}               {j w i c g u d w e}           \n    {m f p v m a s p v c o s}       {s c r z o t w l b e a q}     \n    {m k q}                         {k b a v o}                   \n    -932328\n    {r v i u m q d r}               {f z u v h c m r f g}         \n    {r x r}                         {k p i d h h w h z u a x}     \n    {k m j p}                       {h l j a e u c i q x x f x g} \n    -3923818\n    {t t p b n u i h e c k}         {m z}                         \n    {v u d c}                       {v y y j s g}                 \n    {o a f k k q p h g x e n z x}   {h d w c o l}                 \n    -2145922\n    {z z l f a l g e d c d h}       {j b j p k o o u b q}         \n    {d i g q t f d r h k}           {n w g j c x r p t y f l c t} \n    {d o c u k f o}                 {r y s x z s p p h g t p y c} \n    4552917\n    {j w j y h l k u}               {n a}                         \n    {y h w c n k}                   {b}                           \n    {w}                             {z l r t s i m v c y}         \n    2292008\n    {q v q j w y y x u t}           {r q z n h a b o}             \n    {d q y}                         {y v o e j}                   \n    {}                              {a b h c d l p d x}           \n    1407892\n    {n j j u q d o a u c f}         {r d b w o q n g}             \n    {d e v w s}                     {v d v o u o x s l s j z y}   \n    {j y w h i f g i h m}           {v n z b n y}                 \n    -4412544\n    {g h h r s}                     {h e r e}                     \n    {n q s}                         {o p z r m l l t}             \n    {p}                             {f s u o b j}                 \n    1209110\n    {o a a z t t u h j}             {z z i r k r}                 \n    {i c x q w g v o x z i z p}     {q o g k i n z x e d v w v}   \n    {p f v b g f e d n p u c y k}   {q z z a i p a a s r e z}     \n    3448977\n    {i v}                           {l u x t b o k}               \n    {f h u v p}                     {k a o y j}                   \n    {d m k c j}                     {v c e r u e f i t}           \n    -4703774\n    {d h v w u z r e h x o l t}     {p s f y w y r q d a m w}     \n    {c h g c g j j f t b i c q}     {s e}                         \n    {c t q j g f}                   {v n r w y r a g e j d}       \n    2414151\n    {s o o s d s k q b f q v p e}   {j r o b t o p d l o o x}     \n    {d d k t v e}                   {}                            \n    {t v o d w}                     {w e q w h y c y y i j b a m} \n    -3342407\n    {m c h n e p d o c r w n t}     {j d k s p q l}               \n    {t g s r w x j l r z r}         {h}                           \n    {r q v x i r a n h s}           {m y p b v w r a u o g q r}   \n    -993951\n    {l n p u o j d x t u u c o j}   {k r n a r e k v i t o e}     \n    {q f t t a a c z v f}           {o n m p v f o e n}           \n    {h z h i p s b j z h}           {i t w m k c u g n i}         \n    1575251\n    {}                              {z s i j d o x j a r t}       \n    {h g j u j n v e n z}           {p z j n n f}                 \n    {s q q f d w r l y i z d o m}   {b a n d h t b y g h d}       \n    4263668\n    {q g t h f s}                   {s g x p f q z i s o f l i}   \n    {q k}                           {w v h a x n a r b}           \n    {m j a h o b i x k r w z q u}   {m t r g j o e q t m p u l}   \n    2487819\n    {m w g x r n e u t s r}         {b x a t u u j c r n}         \n    {j}                             {w f j r e e y l p}           \n    {o u h b}                       {o c a c a b v}               \n    167966\n    {o d b s d o a u m o x y}       {c}                           \n    {r w d o b v}                   {z e b}                       \n    {i n z a f g z o}               {m u b a g}                   \n    1948599\n    {n r g q d j s}                 {n k}                         \n    {l b p d v t k h y y}           {u m k e c}                   \n    {t b n y o t b}                 {j w c i r x x}               \n    2941631\n    {l d p l b g f}                 {e k e}                       \n    {p j}                           {m c s w t b k n l d x}       \n    {f o v y v l}                   {c w p s w j w c u t y}       \n    3561104\n    {d r j j r j i g p}             {u}                           \n    {g r j q}                       {z l p d s n f c h t d c v z} \n    {w r c f s x z y}               {g f o k g g}                 \n    -2223281\n    {y e t j j z f p o m m z}       {h k o g o}                   \n    {m x a t}                       {l q x l}                     \n    {r w k d l s y b}               {q g k b}                     \n    -4502874\n    {k k b x k l f}                 {r}                           \n    {}                              {q m z b k h k u n e z}       \n    {z q g y m y u}                 {}                            \n    1757599\n    {d p z j y u r}                 {z p l q w j t j}             \n    {n i r x r y j}                 {}                            \n    {h}                             {w t d q c x z z x e e}       \n    -4809589\n    {}                              {z p x u h i i n g}           \n    {w q s u d b f x n}             {l y k b b r x t i}           \n    {n d v j q o t o d p z e}       {u r y u v u c}               \n    1068408\n    {y e}                           {e g s k e w t p v o b k}     \n    {z c m s}                       {r u r u h n h b p q g b}     \n    {j k b l}                       {m c d t s r s q a d b o f}   \n    -1972554\n    {m s w}                         {d k v s a r k p a r i v}     \n    {g j z k p}                     {y k c v r e u o q f i b a}   \n    {i p i}                         {c z w c y b n z i v}         \n    -2052385\n    {}                              {x e u f f g n c i x n e i e} \n    {}                              {p s w d x p g}               \n    {}                              {s j a h n}                   \n    2805981\n    {m x g c w o e}                 {k g u y r y i u e g g}       \n    {f k j v t x p h x k u}         {w i}                         \n    {b l f z f v t n}               {i u d o d p h s m u}         \n    2507621\n    {}                              {u b n l x f n j t}           \n    {u r x l h}                     {h r l m r}                   \n    {d y e n b s q v t k n q q}     {x l t v w h a s k}           \n    -3138375\n    {e o f j y x u w v e w z}       {r d q g k n n v r c z n e w} \n    {l y i q z k j p u f q s k}     {c i l l i m a a g a z r x f} \n    {a v k h m q z b y n z}         {q g w c y r r o a}           \n    -457971\n    {j x a w e c s h f l f}         {q}                           \n    {j f v j u m d q r v v}         {x n v a w}                   \n    {i e h d h f u w t t z}         {v s u l s v o v i k n e}     \n    2265221\n    {z t c y w n y r t}             {n b a x s}                   \n    {q w a v}                       {a b s d x i g w t e z h}     \n    {t l}                           {j k r w f f y j o k u}       \n    -3941280\n    {r x t o z}                     {f j n z k}                   \n    {t x e b t d b k w i s}         {j t y h i h}                 \n    {y q g n g s u v c z j z n g}   {n n g t l p h}               \n    2084745\n    {z d z d}                       {j}                           \n    {o e k t b k a z l w}           {o p i h k c x}               \n    {c r b t i j f}                 {z e n m}                     \n    1265843\n    {}                              {j s g j j x u y}             \n    {u q t f}                       {g o g}                       \n    {w o j e d}                     {w q n a c t q x j}           \n    -2941116\n    {i n c u o}                     {f b}                         \n    {o m s q d o z a q}             {f s v o b b}                 \n    {o a z c h r}                   {j e w h b f z}               \n    -1265441\n    {p g z q v a o a x a}           {s t h}                       \n    {w i p o c}                     {s n d g f z w q o d v v l j} \n    {y f b i a s v}                 {u m o z k k s t s d p b l p} \n    -1989158\n    {r i c n}                       {r e w w i n z}               \n    {q u s y b w u g y g f o}       {y}                           \n    {d}                             {j x i b x u y d c p v a h}   \n    2391989\n    {b n w x w f q h p i}           {e u b b i n a i o c d g}     \n    {v a z o i e n l x l r}         {r u f o r k w m d w}         \n    {k s}                           {r f e j q p w}               \n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(a, b, c, d, e, f);\n} {}\n\nfts5_aux_test_functions db\n\nproc do_auto_test {tn tbl expr} {\n  foreach order {asc desc} {\n    set res [fts5_poslist_data $expr $tbl $order]\n    set testname \"$tn.[string range $order 0 0].rows=[expr [llength $res]/2]\"\n\n    set ::autotest_expr $expr\n    do_execsql_test $testname [subst -novar {\n      SELECT rowid, fts5_test_poslist([set tbl]) FROM [set tbl] \n      WHERE [set tbl] MATCH $::autotest_expr ORDER BY rowid [set order]\n    }] $res\n  }\n}\n\n#-------------------------------------------------------------------------\n#\n\nfor {set fold 0} {$fold < 3} {incr fold} {\n  switch $fold {\n    0 { set map {} }\n    1 { set map {\n      a a  b a  c b  d b  e c  f c  g d  h d  \n      i e  j e  k f  l f  m g  g g  o h  p h\n      q i  r i  s j  t j  u k  v k  w l  x l\n      y m  z m\n    }}\n\n    2 { set map {\n      a a  b a  c a  d a  e a  f a  g a  h a  \n      i b  j b  k b  l b  m b  g b  o b  p b\n      q c  r c  s c  t c  u c  v c  w c  x c\n    }}\n  }\n\n  execsql {\n    BEGIN;\n    DELETE FROM tt;\n  }\n  foreach {rowid a b c d e f} [string map $map $data] {\n  if {$rowid==-4703774} {\n    execsql {\n      INSERT INTO tt(rowid, a, b, c, d, e, f) \n      VALUES($rowid, $a, $b, $c, $d, $e, $f)\n    }\n    }\n  }\n  execsql COMMIT\n\n\n  foreach {tn expr} {\n    A.1 { {a} : x }\n    A.2 { {a b} : x }\n    A.3 { {a b f} : x }\n    A.4 { {f a b} : x }\n    A.5 { {f a b} : x y }\n    A.6 { {f a b} : x + y }\n    A.7 { {c a b} : x + c }\n    A.8 { {c d} : \"l m\" }\n    A.9 { {c e} : \"l m\" }\n    A.10 { {a b c a b c a b c f f e} : \"l m\" }\n\n    B.1 { a NOT b }\n    B.2 { a NOT a:b }\n    B.3 { a OR (b AND c) }\n    B.4 { a OR (b AND {a b c}:c) }\n    B.5 { a OR \"b c\" }\n    B.6 { a OR b OR c }\n\n    C.1 { a OR (b AND \"b c\") }\n    C.2 { a OR (b AND \"z c\") }\n  } {\n    do_auto_test 3.$fold.$tn tt $expr\n  }\n}\n\nproc replace_elems {list args} {\n  set ret $list\n  foreach {idx elem} $args {\n    set ret [lreplace $ret $idx $idx $elem]\n  }\n  set ret\n}\n\n#-------------------------------------------------------------------------\n#\nset bigdoc [string trim [string repeat \"a \" 1000]]\ndo_test 4.0 {\n  set a [replace_elems $bigdoc  50 x  950 x]\n  set b [replace_elems $bigdoc  20 y   21 x  887 x 888 y]\n  set c [replace_elems $bigdoc   1 z  444 z  789 z]\n  execsql {\n    CREATE VIRTUAL TABLE yy USING fts5(c1, c2, c3);\n    INSERT INTO yy(rowid, c1, c2, c3) VALUES(-56789, $a, $b, $c);\n    INSERT INTO yy(rowid, c1, c2, c3) VALUES(250, $a, $b, $c);\n  }\n} {}\n\nforeach {tn expr} {\n  1 x    \n  2 y    \n  3 z\n\n  4 {c1 : x} 5 {c2 : x} 6 {c3 : x}\n  7 {c1 : y} 8 {c2 : y} 9 {c3 : y}\n  10 {c1 : z} 11 {c2 : z} 12 {c3 : z}\n} {\n  do_auto_test 4.$tn yy $expr\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5aux.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the auxiliary function APIs.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5aux\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc inst {cmd i} { \n  $cmd xInst $i\n}\nsqlite3_fts5_create_function db inst inst\n\nproc colsize {cmd i} { \n  $cmd xColumnSize $i\n}\nsqlite3_fts5_create_function db colsize colsize\n\nproc totalsize {cmd i} { \n  $cmd xColumnTotalSize $i\n}\nsqlite3_fts5_create_function db totalsize totalsize\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a, b);\n  INSERT INTO f1 VALUES('one two', 'two one zero');\n  INSERT INTO f1 VALUES('one one', 'one one one');\n}\n\ndo_catchsql_test 1.1 {\n  SELECT inst(f1, -1) FROM f1 WHERE f1 MATCH 'two';\n} {1 SQLITE_RANGE}\ndo_catchsql_test 1.2 {\n  SELECT inst(f1, 0) FROM f1 WHERE f1 MATCH 'two';\n} {0 {{0 0 1}}}\ndo_catchsql_test 1.3 {\n  SELECT inst(f1, 1) FROM f1 WHERE f1 MATCH 'two';\n} {0 {{0 1 0}}}\ndo_catchsql_test 1.4 {\n  SELECT inst(f1, 2) FROM f1 WHERE f1 MATCH 'two';\n} {1 SQLITE_RANGE}\n\ndo_catchsql_test 2.1 {\n  SELECT colsize(f1, 2) FROM f1 WHERE f1 MATCH 'two';\n} {1 SQLITE_RANGE}\ndo_execsql_test 2.2 {\n  SELECT colsize(f1, 0), colsize(f1, 1) FROM f1 WHERE f1 MATCH 'zero';\n} {2 3}\ndo_execsql_test 2.3 {\n  SELECT colsize(f1, -1) FROM f1 WHERE f1 MATCH 'zero';\n} {5}\n\ndo_execsql_test 2.4.1 {\n  SELECT totalsize(f1, -1) FROM f1 WHERE f1 MATCH 'zero';\n} {10}\ndo_execsql_test 2.4.2 {\n  SELECT totalsize(f1, 0) FROM f1 WHERE f1 MATCH 'zero';\n} {4}\ndo_execsql_test 2.4.3 {\n  SELECT totalsize(f1, 1) FROM f1 WHERE f1 MATCH 'zero';\n} {6}\ndo_catchsql_test 2.4.4 {\n  SELECT totalsize(f1, 2) FROM f1 WHERE f1 MATCH 'zero';\n} {1 SQLITE_RANGE}\n\n#-------------------------------------------------------------------------\n# Test the xSet and xGetAuxdata APIs with a NULL destructor.\n#\nproc prevrowid {add cmd} {\n  set res [$cmd xGetAuxdataInt 0]\n  set r [$cmd xRowid]\n  $cmd xSetAuxdataInt $r\n  return [expr $res + $add]\n}\nsqlite3_fts5_create_function db prevrowid  [list prevrowid 0]\nsqlite3_fts5_create_function db prevrowid1 [list prevrowid 1]\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE e5 USING fts5(x);\n  INSERT INTO e5 VALUES('a b c');\n  INSERT INTO e5 VALUES('d e f');\n  INSERT INTO e5 VALUES('a b c');\n  INSERT INTO e5 VALUES('d e f');\n  INSERT INTO e5 VALUES('a b c');\n}\n\ndo_execsql_test 3.1 {\n  SELECT prevrowid(e5) || '+' || rowid FROM e5 WHERE e5 MATCH 'c'\n} {0+1   1+3   3+5}\n\ndo_execsql_test 3.2 {\n  SELECT prevrowid(e5) || '+' || prevrowid1(e5) || '+' || rowid \n  FROM e5 WHERE e5 MATCH 'e'\n} {0+1+2    2+3+4}\n\n#-------------------------------------------------------------------------\n# Test that if the xQueryPhrase callback returns other than SQLITE_OK,\n# the query is abandoned. And that if it returns an error code other than \n# SQLITE_DONE, the error is propagated back to the caller.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE e7 USING fts5(x);\n  INSERT INTO e7 VALUES('a x a');\n  INSERT INTO e7 VALUES('b x b');\n  INSERT INTO e7 VALUES('c x c');\n  INSERT INTO e7 VALUES('d x d');\n  INSERT INTO e7 VALUES('e x e');\n}\n\nproc xCallback {rowid code cmd} {\n  set r [$cmd xRowid]\n  lappend ::cb $r\n  if {$r==$rowid} { return $code }\n  return \"\"\n}\n\nproc phrasequery {cmd code} {\n  set ::cb [list]\n  $cmd xQueryPhrase 1 [list xCallback [$cmd xRowid] $code]\n  set ::cb\n}\n\nsqlite3_fts5_create_function db phrasequery phrasequery\n\ndo_execsql_test 4.1 {\n  SELECT phrasequery(e7, 'SQLITE_OK') FROM e7 WHERE e7 MATCH 'c x'\n} {{1 2 3 4 5}}\n\ndo_execsql_test 4.2 {\n  SELECT phrasequery(e7, 'SQLITE_DONE') FROM e7 WHERE e7 MATCH 'c x'\n} {{1 2 3}}\n\ndo_catchsql_test 4.3 {\n  SELECT phrasequery(e7, 'SQLITE_ERROR') FROM e7 WHERE e7 MATCH 'c x'\n} {1 SQLITE_ERROR}\n\n#-------------------------------------------------------------------------\n# Auxiliary function calls with many cursors in the global cursor list.\n#\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE e9 USING fts5(y);\n  INSERT INTO e9(rowid, y) VALUES(1, 'i iii');\n  INSERT INTO e9(rowid, y) VALUES(2, 'ii iv');\n  INSERT INTO e9(rowid, y) VALUES(3, 'ii');\n  INSERT INTO e9(rowid, y) VALUES(4, 'i iv');\n  INSERT INTO e9(rowid, y) VALUES(5, 'iii');\n}\n\nproc my_rowid {cmd} { $cmd xRowid }\nsqlite3_fts5_create_function db my_rowid my_rowid\n\nforeach {var q} {\n  s1 i\n  s2 ii\n  s3 iii\n  s4 iv\n} {\n  set sql \"SELECT my_rowid(e9) FROM e9 WHERE e9 MATCH '$q'\"\n  set $var [sqlite3_prepare db $sql -1 dummy]\n}\n\ndo_test 5.1.1 { sqlite3_step $s1 ; sqlite3_column_int $s1 0 } 1\ndo_test 5.1.2 { sqlite3_step $s2 ; sqlite3_column_int $s2 0 } 2\ndo_test 5.1.3 { sqlite3_step $s3 ; sqlite3_column_int $s3 0 } 1\ndo_test 5.1.4 { sqlite3_step $s4 ; sqlite3_column_int $s4 0 } 2\n\ndo_test 5.2.1 { sqlite3_step $s1 ; sqlite3_column_int $s1 0 } 4\ndo_test 5.2.2 { sqlite3_step $s2 ; sqlite3_column_int $s2 0 } 3\ndo_test 5.2.3 { sqlite3_step $s3 ; sqlite3_column_int $s3 0 } 5\ndo_test 5.2.4 { sqlite3_step $s4 ; sqlite3_column_int $s4 0 } 4\n\nsqlite3_finalize $s1\nsqlite3_finalize $s2\nsqlite3_finalize $s3\nsqlite3_finalize $s4\n\n#-------------------------------------------------------------------------\n# Passing an invalid first argument to an auxiliary function is detected.\n#\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE e11 USING fts5(y, z);\n  INSERT INTO e11(rowid, y, z) VALUES(1, 'a b', 45);\n  INSERT INTO e11(rowid, y, z) VALUES(2, 'b c', 46);\n}\n\ndo_catchsql_test 6.1 {\n  SELECT my_rowid(z) FROM e11 WHERE e11 MATCH 'b'\n} {1 {no such cursor: 45}}\n\ndo_catchsql_test 6.2 {\n  SELECT my_rowid(y) FROM e11 WHERE e11 MATCH 'b'\n} {1 {no such cursor: 0}}\n\n#-------------------------------------------------------------------------\n# Test passing an out-of-range phrase number to xPhraseSize (should \n# return 0).\n#\nproc my_phrasesize {cmd iPhrase} { $cmd xPhraseSize $iPhrase }\nsqlite3_fts5_create_function db my_phrasesize my_phrasesize\n\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a);\n  INSERT INTO t1 VALUES('a b c');\n}\ndo_execsql_test 7.2 {\n  SELECT \n    my_phrasesize(t1, -1),\n    my_phrasesize(t1, 0),\n    my_phrasesize(t1, 1),\n    my_phrasesize(t1, 2)\n  FROM t1 WHERE t1 MATCH 'a OR b+c'\n} {0 1 2 0}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(a);\n}\n\nforeach {tn lRow res} {\n  4  {\"a a a\" \"b\" \"a d\"} {\"[a] [a] [a]\" \"[a] d\"}\n  1  {\"b d\" \"a b\"}       {\"[b] [d]\" \"[a] b\"}\n  2  {\"d b\" \"a d\"}       {\"[d] [b]\" \"[a] d\"}\n  3  {\"a a d\"}           {\"[a] [a] d\"}\n} {\n  execsql { DELETE FROM x1 }\n  foreach row $lRow { execsql { INSERT INTO x1 VALUES($row) } }\n  do_execsql_test 8.$tn {\n    SELECT highlight(x1, 0, '[', ']') FROM x1 WHERE x1 MATCH 'a OR (b AND d)';\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Test the built-in bm25() demo.\n#\nreset_db\ndo_execsql_test 9.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b);\n  INSERT INTO t1 VALUES('a',   NULL);           -- 1\n  INSERT INTO t1 VALUES('a',   NULL);           -- 2\n  INSERT INTO t1 VALUES('a',   NULL);           -- 3\n  INSERT INTO t1 VALUES('a',   NULL);           -- 4\n  INSERT INTO t1 VALUES('a',   NULL);           -- 5\n  INSERT INTO t1 VALUES('a',   NULL);           -- 6\n  INSERT INTO t1 VALUES('a',   NULL);           -- 7\n  INSERT INTO t1 VALUES('a',   NULL);           -- 8\n  INSERT INTO t1 VALUES(NULL,  'a a b');        -- 9\n  INSERT INTO t1 VALUES(NULL,  'b b a');        -- 10\n}\n\ndo_execsql_test 9.2 {\n  SELECT rowid FROM t1('a AND b') ORDER BY rank;\n} {\n  10 9\n}\n\ndo_execsql_test 9.3 {\n  SELECT rowid FROM t1('b:a AND b:b') ORDER BY rank;\n} {\n  9 10\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5auxdata.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the fts5 xSetAuxdata() and xGetAuxdata() APIs.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5auxdata\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a, b);\n  INSERT INTO f1(rowid, a, b) VALUES(1, 'a', 'b1');\n  INSERT INTO f1(rowid, a, b) VALUES(2, 'a', 'b2');\n  INSERT INTO f1(rowid, a, b) VALUES(3, 'a', 'b3');\n  INSERT INTO f1(rowid, a, b) VALUES(4, 'a', 'b4');\n  INSERT INTO f1(rowid, a, b) VALUES(5, 'a', 'b5');\n}\n\nproc aux_function_1 {cmd tn} {\n  switch [$cmd xRowid] {\n    1 {\n      do_test $tn.1 [list $cmd xGetAuxdata 0 ] {}\n      $cmd xSetAuxdata \"one\"\n    }\n\n    2 {\n      do_test $tn.2 [list $cmd xGetAuxdata 0 ] {one}\n      $cmd xSetAuxdata \"two\"\n    }\n\n    3 {\n      do_test $tn.3 [list $cmd xGetAuxdata 0 ] {two}\n    }\n\n    4 {\n      do_test $tn.4 [list $cmd xGetAuxdata 1 ] {two}\n    }\n\n    5 {\n      do_test $tn.5 [list $cmd xGetAuxdata 0 ] {}\n    }\n  }\n}\n\nsqlite3_fts5_create_function db aux_function_1 aux_function_1\ndb eval { \n  SELECT aux_function_1(f1, 1) FROM f1 WHERE f1 MATCH 'a'\n  ORDER BY rowid ASC\n}\n\nproc aux_function_2 {cmd tn inst} {\n  if {$inst == \"A\"} {\n    switch [$cmd xRowid] {\n      1 {\n        do_test $tn.1.$inst [list $cmd xGetAuxdata 0 ] {}\n        $cmd xSetAuxdata \"one $inst\"\n      }\n      2 {\n        do_test $tn.2.$inst [list $cmd xGetAuxdata 0 ] \"one $inst\"\n        $cmd xSetAuxdata \"two $inst\"\n      }\n      3 {\n        do_test $tn.3.$inst [list $cmd xGetAuxdata 0 ] \"two $inst\"\n      }\n      4 {\n        do_test $tn.4.$inst [list $cmd xGetAuxdata 1 ] \"two $inst\"\n      }\n      5 {\n        do_test $tn.5.$inst [list $cmd xGetAuxdata 0 ] {}\n      }\n    }\n  } else {\n    switch [$cmd xRowid] {\n      1 {\n        do_test $tn.1.$inst [list $cmd xGetAuxdata 0 ] \"one A\"\n      }\n      2 {\n        do_test $tn.2.$inst [list $cmd xGetAuxdata 0 ] \"two A\"\n      }\n      3 {\n        do_test $tn.3.$inst [list $cmd xGetAuxdata 0 ] \"two A\"\n      }\n      4 {\n        do_test $tn.4.$inst [list $cmd xGetAuxdata 0 ] {}\n      }\n      5 {\n        do_test $tn.5.$inst [list $cmd xGetAuxdata 0 ] {}\n      }\n    }\n  }\n}\n\nsqlite3_fts5_create_function db aux_function_2 aux_function_2\ndb eval { \n  SELECT aux_function_2(f1, 2, 'A'), aux_function_2(f1, 2, 'B') \n  FROM f1 WHERE f1 MATCH 'a'\n  ORDER BY rowid ASC\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5bigpl.test",
    "content": "# 2015 April 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test is focused on really large position lists. Those that require\n# 4 or 5 byte position-list size varints. Because of the amount of memory\n# required, these tests only run on 64-bit platforms.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5bigpl\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nif { $tcl_platform(wordSize)<8 } {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts5(x) }\n\ndo_test 1.1 {\n  foreach t {a b c d e f g h i j} {\n    set doc [string repeat \"$t \" 1200000]\n    execsql { INSERT INTO t1 VALUES($doc) }\n  }\n  execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {}\n\ndo_test 1.2 {\n  execsql { DELETE FROM t1 }\n  foreach t {\"a b\" \"b a\" \"c d\" \"d c\"} {\n    set doc [string repeat \"$t \" 600000]\n    execsql { INSERT INTO t1 VALUES($doc) }\n  }\n  execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {}\n\n\n# 5-byte varint. This test takes 30 seconds or so on a 2014 workstation.\n# The generated database is roughly 635MiB.\n#\ndo_test 2.1...slow {\n  execsql { DELETE FROM t1 }\n  foreach t {a} {\n    set doc [string repeat \"$t \" 150000000]\n    execsql { INSERT INTO t1 VALUES($doc) }\n  }\n  execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5bigtok.test",
    "content": "# 2016 Jan 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5bigtok\nreturn_if_no_fts5\n\nproc rndterm {} {\n  set L [list a b c d e f g h i j k l m n o p q r s t u v w x y z]\n  set l [lindex $L [expr int(rand() * [llength $L])]]\n  string repeat $l [expr int(rand() * 5) + 60]\n}\n\nproc rnddoc {n} {\n  set res [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend res [rndterm]\n  }\n  set res\n}\n\nforeach_detail_mode $::testprefix {\n  db func rnddoc rnddoc\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n    CREATE VIRTUAL TABLE t1vocab USING fts5vocab(t1, row);\n\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )\n    INSERT INTO t1 SELECT rnddoc(3) FROM s;\n\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10 )\n    INSERT INTO t1 SELECT rnddoc(3) FROM s;\n  }\n\n  foreach v [db eval {SELECT term FROM t1vocab}] {\n    set res [db eval {SELECT rowid FROM t1($v)}]\n    do_execsql_test 1.[string range $v 0 0] {\n      SELECT rowid FROM t1($v) ORDER BY rowid DESC\n    } [lsort -integer -decr $res]\n  }\n\n  do_execsql_test 2.0 {\n    INSERT INTO t1(t1) VALUES('optimize');\n  }\n\n  foreach v [db eval {SELECT term FROM t1vocab}] {\n    set res [db eval {SELECT rowid FROM t1($v)}]\n    do_execsql_test 2.[string range $v 0 0] {\n      SELECT rowid FROM t1($v) ORDER BY rowid DESC\n    } [lsort -integer -decr $res]\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5colset.test",
    "content": "# 2016 August 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5colset\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $::testprefix {\n  if {[detail_is_none]} continue\n\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d, detail=%DETAIL%);\n    INSERT INTO t1 VALUES('a', 'b', 'c', 'd');  -- 1\n    INSERT INTO t1 VALUES('d', 'a', 'b', 'c');  -- 2\n    INSERT INTO t1 VALUES('c', 'd', 'a', 'b');  -- 3\n    INSERT INTO t1 VALUES('b', 'c', 'd', 'a');  -- 4\n  }\n\n  foreach {tn q res} {\n    1 \"a\"          {1 2 3 4}\n    2 \"{a}   : a\"  {1}\n    3 \"-{a}   : a\" {2 3 4}\n    4 \"- {a c} : a\" {2 4}\n    5 \" - {d d c} : a\" {1 2}\n    6 \"- {d c b a} : a\" {}\n    7 \"-{\\\"a\\\"} : b\" {1 2 3}\n    8 \"- c : a\" {1 2 4}\n    9 \"-c : a\"  {1 2 4}\n    10 \"-\\\"c\\\" : a\"  {1 2 4}\n  } {\n    do_execsql_test 1.$tn {\n      SELECT rowid FROM t1($q)\n    } $res\n  }\n\n  foreach {tn q res} {\n    0 {{a} : (a AND \":\")}     {}\n    1 \"{a b c} : (a AND d)\"   {2 3}\n    2 \"{a b c} : (a AND b:d)\" {3}\n    3 \"{a b c} : (a AND d:d)\" {}\n    4 \"{b} : ( {b a} : ( {c b a} : ( {d b c a} : ( d OR c ) ) ) )\" {3 4}\n    5 \"{a} : ( {b a} : ( {c b a} : ( {d b c a} : ( d OR c ) ) ) )\" {2 3}\n    6 \"{a} : ( {b a} : ( {c b} : ( {d b c a} : ( d OR c ) ) ) )\" {}\n    7 \"{a b c} : (b:a AND c:b)\" {2}\n  } {\n    do_execsql_test 2.$tn {\n      SELECT rowid FROM t1($q)\n    } $res\n  }\n\n  foreach {tn w res} {\n    0 \"a MATCH 'a'\" {1}\n    1 \"b MATCH 'a'\" {2}\n    2 \"b MATCH '{a b c} : a'\" {2}\n    3 \"b MATCH 'a OR b'\"      {1 2}\n    4 \"b MATCH 'a OR a:b'\"    {2}\n    5 \"b MATCH 'a OR b:b'\"    {1 2}\n  } {\n    do_execsql_test 3.$tn \"\n      SELECT rowid FROM t1 WHERE $w\n    \" $res\n  }\n\n  do_catchsql_test 4.1 {\n    SELECT * FROM t1 WHERE rowid MATCH 'a'\n  } {1 {unable to use function MATCH in the requested context}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5columnsize.test",
    "content": "# 2015 Jun 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on fts5 tables with the columnsize=0 option.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5columnsize\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Check that the option can be parsed and that the %_docsize table is\n# only created if it is set to true.\n#\nforeach {tn outcome stmt} {\n  1 0 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=0) }\n  2 1 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=1) }\n  3 0 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize='0') }\n  4 1 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize='1') }\n  5 2 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize='') }\n  6 2 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=2) }\n  7 1 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=0, columnsize=1) }\n  8 1 { CREATE VIRTUAL TABLE t1 USING fts5(x) }\n  9 2 { CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=11) }\n} {\n  execsql { \n    DROP TABLE IF EXISTS t1;\n  }\n  if {$outcome==2} {\n    do_catchsql_test 1.$tn.1 $stmt {1 {malformed columnsize=... directive}}\n  } else {\n    do_execsql_test 1.$tn.2 $stmt\n    do_execsql_test 1.$tn.3 {\n      SELECT count(*) FROM sqlite_master WHERE name = 't1_docsize'\n    } $outcome\n  }\n}\n\n#-------------------------------------------------------------------------\n# Run tests on a table with no %_content or %_docsize backing store.\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, columnsize=0, content='');\n}\ndo_catchsql_test 2.1 {\n  INSERT INTO t2 VALUES('a b c d e f');\n} {1 {datatype mismatch}}\ndo_execsql_test 2.2 {\n  INSERT INTO t2(rowid, x) VALUES(1, 'c d e f');\n  INSERT INTO t2(rowid, x) VALUES(2, 'c d e f g h');\n  INSERT INTO t2(rowid, x) VALUES(3, 'a b c d e f g h');\n} {}\ndo_execsql_test 2.3 {\n  SELECT rowid FROM t2 WHERE t2 MATCH 'b'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'h'; \n} {3 :: 1 2 3 :: 2 3}\ndo_execsql_test 2.4 {\n  INSERT INTO t2(t2, rowid, x) VALUES('delete', 2, 'c d e f g h');\n  SELECT rowid FROM t2 WHERE t2 MATCH 'b'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'h'; \n} {3 :: 1 3 :: 3}\ndo_execsql_test 2.5 {\n  INSERT INTO t2(t2) VALUES('delete-all');\n  SELECT rowid FROM t2 WHERE t2 MATCH 'b'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e'; SELECT '::';\n  SELECT rowid FROM t2 WHERE t2 MATCH 'h'; \n} {:: ::}\ndo_execsql_test 2.6 {\n  INSERT INTO t2(rowid, x) VALUES(1, 'o t t f');\n  INSERT INTO t2(rowid, x) VALUES(2, 'f s s e');\n  INSERT INTO t2(rowid, x) VALUES(3, 'n t e t');\n}\n\ndo_catchsql_test 2.7.1 {\n  SELECT rowid FROM t2\n} {1 {t2: table does not support scanning}}\ndo_catchsql_test 2.7.2 {\n  SELECT rowid FROM t2 WHERE rowid=2\n} {1 {t2: table does not support scanning}}\ndo_catchsql_test 2.7.3 {\n  SELECT rowid FROM t2 WHERE rowid BETWEEN 1 AND 3\n} {1 {t2: table does not support scanning}}\n\ndo_execsql_test 2.X {\n  DROP TABLE t2\n}\n\n#-------------------------------------------------------------------------\n# Test the xColumnSize() API\n#\nfts5_aux_test_functions db\n\ndo_execsql_test 3.1.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(x, y UNINDEXED, z, columnsize=0);\n  INSERT INTO t3 VALUES('a a', 'b b b', 'c');\n  INSERT INTO t3 VALUES('x a x', 'b b b y', '');\n}\ndo_execsql_test 3.1.1 {\n  SELECT rowid, fts5_test_columnsize(t3) FROM t3 WHERE t3 MATCH 'a'\n} {\n  1 {2 0 1} 2 {3 0 0}\n}\ndo_execsql_test 3.1.2 {\n  INSERT INTO t3 VALUES(NULL, NULL, 'a a a a');\n  DELETE FROM t3 WHERE rowid = 1;\n  SELECT rowid, fts5_test_columnsize(t3) FROM t3 WHERE t3 MATCH 'a'\n} {\n  2 {3 0 0} 3 {0 0 4}\n}\n\ndo_execsql_test 3.2.0 {\n  CREATE VIRTUAL TABLE t4 USING fts5(x, y UNINDEXED, z, columnsize=0, content='');\n  INSERT INTO t4(rowid, x, y, z) VALUES(1, 'a a', 'b b b', 'c');\n  INSERT INTO t4(rowid, x, y, z) VALUES(2, 'x a x', 'b b b y', '');\n}\ndo_execsql_test 3.2.1 {\n  SELECT rowid, fts5_test_columnsize(t4) FROM t4 WHERE t4 MATCH 'a'\n} {\n  1 {-1 0 -1} 2 {-1 0 -1}\n}\n\n#-------------------------------------------------------------------------\n# Test the integrity-check\n#\ndo_execsql_test 4.1.1 {\n  CREATE VIRTUAL TABLE t5 USING fts5(x, columnsize=0);\n  INSERT INTO t5 VALUES('1 2 3 4');\n  INSERT INTO t5 VALUES('2 4 6 8');\n}\n\ndo_execsql_test 4.1.2 {\n  INSERT INTO t5(t5) VALUES('integrity-check');\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5config.test",
    "content": "# 2015 Jan 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file focuses on the code in fts5_config.c, which is largely concerned\n# with parsing the various configuration and CREATE TABLE options.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5config\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Try different types of quote characters.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5('a', \"b\", [c], `d`);\n  PRAGMA table_info = t1;\n} {\n  0 a {} 0 {} 0 \n  1 b {} 0 {} 0 \n  2 c {} 0 {} 0 \n  3 d {} 0 {} 0\n}\n\n#-------------------------------------------------------------------------\n# Syntax errors in the prefix= option.\n#\nforeach {tn opt} {\n  1 {prefix=x}  \n  2 {prefix='x'}\n  3 {prefix='$'}\n  4 {prefix='1,2,'}\n  5 {prefix=',1'}\n  6 {prefix='1,2,3...'}\n  7 {prefix='1,2,3xyz'}\n} {\n  set res [list 1 {malformed prefix=... directive}]\n  do_catchsql_test 2.$tn \"CREATE VIRTUAL TABLE f1 USING fts5(x, $opt)\" $res\n}\n\n#-------------------------------------------------------------------------\n# Syntax errors in the 'rank' option.\n#\nforeach {tn val} {\n  1 \"f1(xyz)\"\n  2 \"f1(zyx)\"\n  3 \"f1(nzz)\"\n  4 \"f1(x'!!')\"\n  5 \"f1(x':;')\"\n  6 \"f1(x'[]')\"\n  7 \"f1(x'{}')\"\n  8 \"f1('abc)\"\n} {\n  do_catchsql_test 3.$tn {\n    INSERT INTO t1(t1, rank) VALUES('rank', $val);\n  } {1 {SQL logic error}}\n}\n\n#-------------------------------------------------------------------------\n# The parsing of SQL literals specified as part of 'rank' options.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE zzz USING fts5(one);\n  INSERT INTO zzz VALUES('a b c');\n}\nproc first {cmd A} { return $A }\nsqlite3_fts5_create_function db first first\n\nforeach {tn arg} {\n  1 \"123\"\n  2 \"'01234567890ABCDEF'\"\n  3 \"x'0123'\"\n  4 \"x'ABCD'\"\n  5 \"x'0123456789ABCDEF'\"\n  6 \"x'0123456789abcdef'\"\n  7 \"22.5\"\n  8 \"-91.5\"\n  9 \"-.5\"\n  10 \"''''\"\n  11 \"+.5\"\n} {\n  set func [string map {' ''} \"first($arg)\"]\n  do_execsql_test 4.1.$tn \"\n    INSERT INTO zzz(zzz, rank) VALUES('rank', '$func');\n    SELECT rank IS $arg FROM zzz WHERE zzz MATCH 'a + b + c'\n  \" 1\n}\n\ndo_execsql_test 4.2 {\n  INSERT INTO zzz(zzz, rank) VALUES('rank', 'f1()');\n} {}\n\n#-------------------------------------------------------------------------\n# Misquoting in tokenize= and other options. \n#\ndo_catchsql_test 5.1 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, tokenize=\"porter 'ascii\");\n} {1 {parse error in tokenize directive}} \n\ndo_catchsql_test 5.2 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, [y[]);\n} {0 {}}\n\ndo_catchsql_test 5.3 {\n  CREATE VIRTUAL TABLE yy USING fts5(x, [y]]);\n} {1 {unrecognized token: \"]\"}}\n\n#-------------------------------------------------------------------------\n# Errors in prefix= directives.\n#\ndo_catchsql_test 6.2 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, prefix='1, 2, 1001');\n} {1 {prefix length out of range (max 999)}}\ndo_catchsql_test 6.3 {\n  CREATE VIRTUAL TAbLE abc USING fts5(a, prefix='1, 2, 0000');\n} {1 {prefix length out of range (max 999)}}\ndo_catchsql_test 6.4 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, prefix='1  , 1000000');\n} {1 {prefix length out of range (max 999)}}\n\n#-------------------------------------------------------------------------\n# Duplicate tokenize= and other options.\n#\ndo_catchsql_test 7.1 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, tokenize=porter, tokenize=ascii);\n} {1 {multiple tokenize=... directives}}\ndo_catchsql_test 7.2 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, content=porter, content=ascii);\n} {1 {multiple content=... directives}}\ndo_catchsql_test 7.3 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, content_rowid=porter, content_rowid=a);\n} {1 {multiple content_rowid=... directives}}\n\n#-------------------------------------------------------------------------\n# Unrecognized option.\n#\ndo_catchsql_test 8.0 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, nosuchoption=123);\n} {1 {unrecognized option: \"nosuchoption\"}}\ndo_catchsql_test 8.1 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, \"nosuchoption\"=123);\n} {1 {parse error in \"\"nosuchoption\"=123\"}}\n\n#-------------------------------------------------------------------------\n# Errors in:\n#\n#   9.1.* 'pgsz' options.\n#   9.2.* 'automerge' options.\n#   9.3.* 'crisismerge' options.\n#   9.4.* a non-existant option.\n#   9.5.* 'hashsize' options.\n#\ndo_execsql_test 9.0 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, b);\n} {}\ndo_catchsql_test 9.1.1 {\n  INSERT INTO abc(abc, rank) VALUES('pgsz', -5);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.1.2 {\n  INSERT INTO abc(abc, rank) VALUES('pgsz', 50000000);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.1.3 {\n  INSERT INTO abc(abc, rank) VALUES('pgsz', 66.67);\n} {1 {SQL logic error}}\n\ndo_catchsql_test 9.2.1 {\n  INSERT INTO abc(abc, rank) VALUES('automerge', -5);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.2.2 {\n  INSERT INTO abc(abc, rank) VALUES('automerge', 50000000);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.2.3 {\n  INSERT INTO abc(abc, rank) VALUES('automerge', 66.67);\n} {1 {SQL logic error}}\ndo_execsql_test 9.2.4 {\n  INSERT INTO abc(abc, rank) VALUES('automerge', 1);\n} {}\n\ndo_catchsql_test 9.3.1 {\n  INSERT INTO abc(abc, rank) VALUES('crisismerge', -5);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.3.2 {\n  INSERT INTO abc(abc, rank) VALUES('crisismerge', 66.67);\n} {1 {SQL logic error}}\ndo_execsql_test 9.3.3 {\n  INSERT INTO abc(abc, rank) VALUES('crisismerge', 1);\n} {}\ndo_execsql_test 9.3.4 {\n  INSERT INTO abc(abc, rank) VALUES('crisismerge', 50000000);\n} {}\n\ndo_catchsql_test 9.4.1 {\n  INSERT INTO abc(abc, rank) VALUES('nosuchoption', 1);\n} {1 {SQL logic error}}\n\ndo_catchsql_test 9.5.1 {\n  INSERT INTO abc(abc, rank) VALUES('hashsize', 'not an integer');\n} {1 {SQL logic error}}\ndo_catchsql_test 9.5.2 {\n  INSERT INTO abc(abc, rank) VALUES('hashsize', -500000);\n} {1 {SQL logic error}}\ndo_catchsql_test 9.5.3 {\n  INSERT INTO abc(abc, rank) VALUES('hashsize', 500000);\n} {0 {}}\n\n#-------------------------------------------------------------------------\n# Too many prefix indexes. Maximum allowed is 31.\n#\nforeach {tn spec} {\n  1 {prefix=\"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32\"}\n  2 {prefix=\"1 2 3 4\", prefix=\"5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32\"}\n} {\n  set sql \"CREATE VIRTUAL TABLE xyz USING fts5(x, $spec)\"\n  do_catchsql_test 10.$tn $sql {1 {too many prefix indexes (max 31)}}\n}\n\n#-------------------------------------------------------------------------\n# errors in the detail= option.\n#\nforeach {tn opt} {\n  1 {detail=x}  \n  2 {detail='x'}\n  3 {detail='$'}\n  4 {detail='1,2,'}\n  5 {detail=',1'}\n  6 {detail=''}\n} {\n  set res [list 1 {malformed detail=... directive}]\n  do_catchsql_test 11.$tn \"CREATE VIRTUAL TABLE f1 USING fts5(x, $opt)\" $res\n}\n\ndo_catchsql_test 12.1 {\n  INSERT INTO t1(t1, rank) VALUES('rank', NULL);;\n} {1 {SQL logic error}}\n\n#-------------------------------------------------------------------------\n# errors in the 'usermerge' option\n#\ndo_execsql_test 13.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(ttt);\n}\nforeach {tn val} {\n  1     -1\n  2     4.2\n  3     17\n  4     1\n} {\n  set sql \"INSERT INTO tt(tt, rank) VALUES('usermerge', $val)\"\n  do_catchsql_test 13.$tn $sql {1 {SQL logic error}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5conflict.test",
    "content": "# 2015 October 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5conflict\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, a, b);\n  CREATE VIRTUAL TABLE ft USING fts5(a, b, content=t1, content_rowid=x);\n}\n\ndo_execsql_test 1.1 {\n  REPLACE INTO ft(rowid, a, b) VALUES(1, 'a b c', 'a b c');\n  REPLACE INTO t1              VALUES(1, 'a b c', 'a b c');\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO ft(ft) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.0 {\n  CREATE TABLE tbl(a INTEGER PRIMARY KEY, b, c);\n  CREATE VIRTUAL TABLE fts_idx USING fts5(b, c, content=tbl, content_rowid=a);\n  CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN\n    INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);\n  END;\n  CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN\n    INSERT INTO fts_idx(fts_idx, rowid, b, c) \n      VALUES('delete', old.a, old.b, old.c);\n  END;\n  CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN\n    INSERT INTO fts_idx(fts_idx, rowid, b, c) \n      VALUES('delete', old.a, old.b, old.c);\n    INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);\n  END;\n}\n\ndo_execsql_test 2.1 {\n  PRAGMA recursive_triggers = 1;\n  INSERT INTO tbl VALUES(1,   'x y z', '1 2 3');\n  INSERT INTO tbl VALUES(10,  'x y z', '1 2 3');\n  INSERT INTO tbl VALUES(100, 'x 1 z', '1 y 3');\n\n  UPDATE tbl SET b = '1 2 x' WHERE rowid=10;\n  REPLACE INTO tbl VALUES(1, '4 5 6', '3 2 1');\n  DELETE FROM tbl WHERE a=100;\n\n  INSERT INTO fts_idx(fts_idx) VALUES('integrity-check');\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5connect.test",
    "content": "# 2017 August 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\n\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5connect\n\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# The tests in this file test the outcome of a schema-reset happening \n# within the xConnect() method of an FTS5 table. At one point this\n# was causing a problem in SQLite. Each test proceeds as follows:\n#\n#   1. Connection [db] opens the db and reads from some unrelated, non-FTS5\n#      table causing SQLite to load the db schema into memory.\n#\n#   2. Connection [db2] opens the db and modifies the db schema.\n#\n#   3. Connection [db] reads or writes an existing fts5 table. That the\n#      schema has been modified is detected inside the fts5 xConnect() \n#      callback that is invoked by sqlite3_prepare(). \n#\n#   4. Verify that the statement in 3 has worked. SQLite should detect\n#      that the schema has changed and successfully prepare the \n#      statement against the new schema.\n#\n# Test plan:\n#\n#   1.*: Trigger the xConnect()/schema-reset using statements executed\n#        directly against an FTS5 table.\n#\n#   2.*: Using various statements executed by various BEFORE triggers.\n#\n#   3.*: Using various statements executed by various AFTER triggers.\n#\n#   4.*: Using various statements executed by various INSTEAD OF triggers.\n#\n\n\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(a, b);\n  CREATE TABLE abc(x INTEGER PRIMARY KEY);\n  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);\n\n  INSERT INTO ft1 VALUES('one', 'two');\n  INSERT INTO ft1 VALUES('three', 'four');\n}\n\nforeach {tn sql res} {\n  1 \"SELECT * FROM ft1\" {one two three four}\n  2 \"REPLACE INTO ft1(rowid, a, b) VALUES(1, 'five', 'six')\" {}\n  3 \"SELECT * FROM ft1\" {five six three four}\n  4 \"INSERT INTO ft1 VALUES('seven', 'eight')\" {}\n  5 \"SELECT * FROM ft1\" {five six three four seven eight}\n  6 \"DELETE FROM ft1 WHERE rowid=2\" {}\n  7 \"UPDATE ft1 SET b='nine' WHERE rowid=1\" {}\n  8 \"SELECT * FROM ft1\" {five nine seven eight}\n} {\n\n  catch { db close }\n  catch { db2 close }\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n\n  do_test 1.$tn.1 {\n    db eval { INSERT INTO abc DEFAULT VALUES }\n    db2 eval { CREATE TABLE newtable(x,y); DROP TABLE newtable }\n  } {}\n\n  do_execsql_test 1.$tn.2 $sql $res\n\n  do_execsql_test 1.$tn.3 {\n    INSERT INTO ft1(ft1) VALUES('integrity-check');\n  }\n}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE TABLE log(txt);\n\n  CREATE TRIGGER t2_ai AFTER INSERT ON t2 BEGIN\n    INSERT INTO ft2(rowid, a, b) VALUES(new.rowid, new.a, new.b);\n    INSERT INTO log VALUES('insert');\n  END;\n\n  CREATE TRIGGER t2_ad AFTER DELETE ON t2 BEGIN\n    DELETE FROM ft2 WHERE rowid = old.rowid;\n    INSERT INTO log VALUES('delete');\n  END;\n\n  CREATE TRIGGER t2_au AFTER UPDATE ON t2 BEGIN\n    UPDATE ft2 SET a=new.a, b=new.b WHERE rowid=new.rowid;\n    INSERT INTO log VALUES('update');\n  END;\n\n  INSERT INTO t2 VALUES('one', 'two');\n  INSERT INTO t2 VALUES('three', 'four');\n}\n\nforeach {tn sql res} {\n  1 \"SELECT * FROM t2\" {one two three four}\n  2 \"REPLACE INTO t2(rowid, a, b) VALUES(1, 'five', 'six')\" {}\n  3 \"SELECT * FROM ft2\" {five six three four}\n  4 \"INSERT INTO t2 VALUES('seven', 'eight')\" {}\n  5 \"SELECT * FROM ft2\" {five six three four seven eight}\n  6 \"DELETE FROM t2 WHERE rowid=2\" {}\n  7 \"UPDATE t2 SET b='nine' WHERE rowid=1\" {}\n  8 \"SELECT * FROM ft2\" {five nine seven eight}\n} {\n\n  catch { db close }\n  catch { db2 close }\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n\n  do_test 2.$tn.1 {\n    db eval { INSERT INTO abc DEFAULT VALUES }\n    db2 eval { CREATE TABLE newtable(x,y); DROP TABLE newtable }\n  } {}\n\n  do_execsql_test 2.$tn.2 $sql $res\n\n  do_execsql_test 2.$tn.3 {\n    INSERT INTO ft2(ft2) VALUES('integrity-check');\n  }\n}\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE ft3 USING fts5(a, b);\n  CREATE TABLE t3(a, b);\n\n  CREATE TRIGGER t3_ai BEFORE INSERT ON t3 BEGIN\n    INSERT INTO ft3(rowid, a, b) VALUES(new.rowid, new.a, new.b);\n    INSERT INTO log VALUES('insert');\n  END;\n\n  CREATE TRIGGER t3_ad BEFORE DELETE ON t3 BEGIN\n    DELETE FROM ft3 WHERE rowid = old.rowid;\n    INSERT INTO log VALUES('delete');\n  END;\n\n  CREATE TRIGGER t3_au BEFORE UPDATE ON t3 BEGIN\n    UPDATE ft3 SET a=new.a, b=new.b WHERE rowid=new.rowid;\n    INSERT INTO log VALUES('update');\n  END;\n\n  INSERT INTO t3(rowid, a, b) VALUES(1, 'one', 'two');\n  INSERT INTO t3(rowid, a, b) VALUES(2, 'three', 'four');\n}\n\nforeach {tn sql res} {\n  1 \"SELECT * FROM t3\" {one two three four}\n  2 \"REPLACE INTO t3(rowid, a, b) VALUES(1, 'five', 'six')\" {}\n  3 \"SELECT * FROM ft3\" {five six three four}\n  4 \"INSERT INTO t3(rowid, a, b) VALUES(3, 'seven', 'eight')\" {}\n  5 \"SELECT * FROM ft3\" {five six three four seven eight}\n  6 \"DELETE FROM t3 WHERE rowid=2\" {}\n  7 \"UPDATE t3 SET b='nine' WHERE rowid=1\" {}\n  8 \"SELECT * FROM ft3\" {five nine seven eight}\n} {\n\n  catch { db close }\n  catch { db2 close }\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n\n  do_test 3.$tn.1 {\n    db eval { INSERT INTO abc DEFAULT VALUES }\n    db2 eval { CREATE TABLE newtable(x,y); DROP TABLE newtable }\n  } {}\n\n  do_execsql_test 3.$tn.2 $sql $res\n\n  do_execsql_test 3.$tn.3 {\n    INSERT INTO ft3(ft3) VALUES('integrity-check');\n  }\n}\n\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE ft4 USING fts5(a, b);\n  CREATE VIEW v4 AS SELECT rowid, * FROM ft4;\n\n  CREATE TRIGGER t4_ai INSTEAD OF INSERT ON v4 BEGIN\n    INSERT INTO ft4(rowid, a, b) VALUES(new.rowid, new.a, new.b);\n    INSERT INTO log VALUES('insert');\n  END;\n\n  CREATE TRIGGER t4_ad INSTEAD OF DELETE ON v4 BEGIN\n    DELETE FROM ft4 WHERE rowid = old.rowid;\n    INSERT INTO log VALUES('delete');\n  END;\n\n  CREATE TRIGGER t4_au INSTEAD OF UPDATE ON v4 BEGIN\n    UPDATE ft4 SET a=new.a, b=new.b WHERE rowid=new.rowid;\n    INSERT INTO log VALUES('update');\n  END;\n\n  INSERT INTO ft4(rowid, a, b) VALUES(1, 'one', 'two');\n  INSERT INTO ft4(rowid, a, b) VALUES(2, 'three', 'four');\n}\n\nforeach {tn sql res} {\n  1 \"SELECT * FROM ft4\" {one two three four}\n  2 \"REPLACE INTO v4(rowid, a, b) VALUES(1, 'five', 'six')\" {}\n  3 \"SELECT * FROM ft4\" {five six three four}\n  4 \"INSERT INTO v4(rowid, a, b) VALUES(3, 'seven', 'eight')\" {}\n  5 \"SELECT * FROM ft4\" {five six three four seven eight}\n  6 \"DELETE FROM v4 WHERE rowid=2\" {}\n  7 \"UPDATE v4 SET b='nine' WHERE rowid=1\" {}\n  8 \"SELECT * FROM ft4\" {five nine seven eight}\n} {\n\n  catch { db close }\n  catch { db2 close }\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n\n  do_test 4.$tn.1 {\n    db eval { INSERT INTO abc DEFAULT VALUES }\n    db2 eval { CREATE TABLE newtable(x,y); DROP TABLE newtable }\n  } {}\n\n  do_execsql_test 4.$tn.2 $sql $res\n\n  do_execsql_test 4.$tn.3 {\n    INSERT INTO ft3(ft3) VALUES('integrity-check');\n  }\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5content.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the content= and content_rowid= options.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5content\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Contentless tables\n#\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a, b, content='');\n  INSERT INTO f1(rowid, a, b) VALUES(1, 'one',   'o n e');\n  INSERT INTO f1(rowid, a, b) VALUES(2, 'two',   't w o');\n  INSERT INTO f1(rowid, a, b) VALUES(3, 'three', 't h r e e');\n}\n\ndo_execsql_test 1.2 {\n  SELECT rowid FROM f1 WHERE f1 MATCH 'o';\n} {1 2}\n\ndo_execsql_test 1.3 {\n  INSERT INTO f1(a, b) VALUES('four',   'f o u r');\n  SELECT rowid FROM f1 WHERE f1 MATCH 'o';\n} {1 2 4}\n\ndo_execsql_test 1.4 {\n  SELECT rowid, a, b FROM f1 WHERE f1 MATCH 'o';\n} {1 {} {} 2 {} {} 4 {} {}}\n\ndo_execsql_test 1.5 {\n  SELECT rowid, highlight(f1, 0, '[', ']') FROM f1 WHERE f1 MATCH 'o';\n} {1 {} 2 {} 4 {}}\n\ndo_execsql_test 1.6 {\n  SELECT rowid, highlight(f1, 0, '[', ']') IS NULL FROM f1 WHERE f1 MATCH 'o';\n} {1 1 2 1 4 1}\n\ndo_execsql_test 1.7 {\n  SELECT rowid, snippet(f1, -1, '[', ']', '...', 5) IS NULL \n  FROM f1 WHERE f1 MATCH 'o';\n} {1 1 2 1 4 1}\n\ndo_execsql_test 1.8 {\n  SELECT rowid, snippet(f1, 1, '[', ']', '...', 5) IS NULL \n  FROM f1 WHERE f1 MATCH 'o';\n} {1 1 2 1 4 1}\n\ndo_execsql_test 1.9 {\n  SELECT rowid FROM f1;\n} {1 2 3 4}\n\ndo_execsql_test 1.10 {\n  SELECT * FROM f1;\n} {{} {}  {} {}  {} {}  {} {}}\n\ndo_execsql_test 1.11 {\n  SELECT rowid, a, b FROM f1 ORDER BY rowid ASC;\n} {1 {} {}  2 {} {}  3 {} {}  4 {} {}}\n\ndo_execsql_test 1.12 {\n  SELECT a IS NULL FROM f1;\n} {1 1 1 1}\n\ndo_catchsql_test 1.13 {\n  DELETE FROM f1 WHERE rowid = 2;\n} {1 {cannot DELETE from contentless fts5 table: f1}}\n\ndo_catchsql_test 1.14 {\n  UPDATE f1 SET a = 'a b c' WHERE rowid = 2;\n} {1 {cannot UPDATE contentless fts5 table: f1}}\n\ndo_execsql_test 1.15 {\n  INSERT INTO f1(f1, rowid, a, b) VALUES('delete', 2, 'two', 't w o');\n} {}\n\ndo_execsql_test 1.16 {\n  SELECT rowid FROM f1 WHERE f1 MATCH 'o';\n} {1 4}\n\ndo_execsql_test 1.17 {\n  SELECT rowid FROM f1;\n} {1 3 4}\n\n#-------------------------------------------------------------------------\n# External content tables\n#\nreset_db\ndo_execsql_test 2.1 {\n  -- Create a table. And an external content fts5 table to index it.\n  CREATE TABLE tbl(a INTEGER PRIMARY KEY, b, c);\n  CREATE VIRTUAL TABLE fts_idx USING fts5(b, c, content='tbl', content_rowid='a');\n\n  -- Triggers to keep the FTS index up to date.\n  CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN\n    INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);\n  END;\n  CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN\n    INSERT INTO fts_idx(fts_idx, rowid, b, c) \n        VALUES('delete', old.a, old.b, old.c);\n  END;\n  CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN\n    INSERT INTO fts_idx(fts_idx, rowid, b, c) \n        VALUES('delete', old.a, old.b, old.c);\n    INSERT INTO fts_idx(rowid, b, c) VALUES (new.a, new.b, new.c);\n  END;\n}\n\ndo_execsql_test 2.2 {\n  INSERT INTO tbl VALUES(1, 'one', 'o n e');\n  INSERT INTO tbl VALUES(NULL, 'two', 't w o');\n  INSERT INTO tbl VALUES(3, 'three', 't h r e e');\n}\n\ndo_execsql_test 2.3 {\n  INSERT INTO fts_idx(fts_idx) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.4 {\n  DELETE FROM tbl WHERE rowid=2;\n  INSERT INTO fts_idx(fts_idx) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.5 {\n  UPDATE tbl SET c = c || ' x y z';\n  INSERT INTO fts_idx(fts_idx) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.6 {\n  SELECT * FROM fts_idx WHERE fts_idx MATCH 't AND x';\n} {three {t h r e e x y z}}\n\ndo_execsql_test 2.7 {\n  SELECT highlight(fts_idx, 1, '[', ']') FROM fts_idx \n  WHERE fts_idx MATCH 't AND x';\n} {{[t] h r e e [x] y z}}\n\n#-------------------------------------------------------------------------\n# Quick tests of the 'delete-all' command.\n#\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t3 USING fts5(x, content='');\n  INSERT INTO t3 VALUES('a b c');\n  INSERT INTO t3 VALUES('d e f');\n}\n\ndo_execsql_test 3.2 {\n  SELECT count(*) FROM t3_docsize;\n  SELECT count(*) FROM t3_data;\n} {2 4}\n\ndo_execsql_test 3.3 {\n  INSERT INTO t3(t3) VALUES('delete-all');\n  SELECT count(*) FROM t3_docsize;\n  SELECT count(*) FROM t3_data;\n} {0 2}\n\ndo_execsql_test 3.4 {\n  INSERT INTO t3 VALUES('a b c');\n  INSERT INTO t3 VALUES('d e f');\n  SELECT rowid FROM t3 WHERE t3 MATCH 'e';\n} {2}\n\ndo_execsql_test 3.5 {\n  SELECT rowid FROM t3 WHERE t3 MATCH 'c';\n} {1}\n\ndo_execsql_test 3.6 {\n  SELECT count(*) FROM t3_docsize;\n  SELECT count(*) FROM t3_data;\n} {2 4}\n\ndo_execsql_test 3.7 {\n  CREATE VIRTUAL TABLE t4 USING fts5(x);\n} {}\ndo_catchsql_test 3.8 {\n  INSERT INTO t4(t4) VALUES('delete-all');\n} {1 {'delete-all' may only be used with a contentless or external content fts5 table}}\n\n#-------------------------------------------------------------------------\n# Test an external content table with a more interesting schema.\n#\ndo_execsql_test 4.1 {\n  CREATE TABLE x2(a, \"key col\" PRIMARY KEY, b, c) WITHOUT ROWID;\n  INSERT INTO x2 VALUES('a b',   1, 'c d' , 'e f');\n  INSERT INTO x2 VALUES('x y', -40, 'z z' , 'y x');\n\n  CREATE VIRTUAL TABLE t2 USING fts5(a, c, content=x2, content_rowid='key col');\n  INSERT INTO t2(t2) VALUES('rebuild');\n}\n\ndo_execsql_test 4.2 { SELECT rowid FROM t2 } {-40 1}\ndo_execsql_test 4.3 { SELECT rowid FROM t2 WHERE t2 MATCH 'c'} {}\ndo_execsql_test 4.4 { SELECT rowid FROM t2 WHERE t2 MATCH 'a'} {1}\ndo_execsql_test 4.5 { SELECT rowid FROM t2 WHERE t2 MATCH 'x'} {-40}\n\ndo_execsql_test 4.6 { INSERT INTO t2(t2) VALUES('integrity-check') } {}\n\ndo_execsql_test 4.7 { \n  DELETE FROM x2 WHERE \"key col\" = 1;\n  INSERT INTO t2(t2, rowid, a, c) VALUES('delete', 1, 'a b', 'e f');\n  INSERT INTO t2(t2) VALUES('integrity-check');\n}\n\ndo_execsql_test 4.8 { SELECT rowid FROM t2 WHERE t2 MATCH 'b'} {}\ndo_execsql_test 4.9 { SELECT rowid FROM t2 WHERE t2 MATCH 'y'} {-40}\n\n#-------------------------------------------------------------------------\n# Test that if the 'rowid' field of a 'delete' is not an integer, no\n# changes are made to the FTS index.\n#\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE t5 USING fts5(a, b, content=);\n  INSERT INTO t5(rowid, a, b) VALUES(-1, 'one',   'two');\n  INSERT INTO t5(rowid, a, b) VALUES( 0, 'three', 'four');\n  INSERT INTO t5(rowid, a, b) VALUES( 1, 'five',  'six');\n}\n\nset ::checksum [execsql {SELECT md5sum(id, block) FROM t5_data}]\n\ndo_execsql_test 5.1 {\n  INSERT INTO t5(t5, rowid, a, b) VALUES('delete', NULL, 'three', 'four');\n  SELECT md5sum(id, block) FROM t5_data;\n} $::checksum\n\n\n#-------------------------------------------------------------------------\n# Check that a contentless table can be dropped.\n#\nreset_db\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, y, content=\"\");\n  SELECT name FROM sqlite_master;\n} {xx xx_data xx_idx xx_docsize xx_config}\ndo_execsql_test 6.2 {\n  DROP TABLE xx;\n  SELECT name FROM sqlite_master;\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5corrupt.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that the FTS5 'integrity-check' command detects \n# inconsistencies (corruption) in the on-disk backing tables.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5corrupt\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n}\n\ndo_test 1.1 {\n  db transaction {\n    for {set i 1} {$i < 200} {incr i} {\n      set doc [list [string repeat x $i] [string repeat y $i]]\n      execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) }\n    }\n  }\n  fts5_level_segs t1\n} {1}\ndb_save\n\ndo_execsql_test 1.2 { INSERT INTO t1(t1) VALUES('integrity-check') }\nset segid [lindex [fts5_level_segids t1] 0]\n\ndo_test 1.3 {\n  execsql {\n    DELETE FROM t1_data WHERE rowid = fts5_rowid('segment', $segid, 4);\n  }\n  catchsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {1 {database disk image is malformed}}\n\ndo_test 1.4 {\n  db_restore_and_reopen\n  execsql {\n    UPDATE t1_data set block = X'00000000' || substr(block, 5) WHERE\n    rowid = fts5_rowid('segment', $segid, 4);\n  }\n  catchsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {1 {database disk image is malformed}}\n\ndb_restore_and_reopen\n#db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r}\n\n\n#--------------------------------------------------------------------\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x);\n  INSERT INTO t2(t2, rank) VALUES('pgsz', 64);\n}\ndb func rnddoc fts5_rnddoc\ndo_test 2.1 {\n  for {set i 0} {$i < 500} {incr i} {\n    execsql { INSERT INTO t2 VALUES(rnddoc(50)) }\n  }\n  execsql { INSERT INTO t2(t2) VALUES('integrity-check') }\n} {}\n\n#--------------------------------------------------------------------\n# A mundane test - missing row in the %_content table.\n#\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(x);\n  INSERT INTO t3 VALUES('one o');\n  INSERT INTO t3 VALUES('two e');\n  INSERT INTO t3 VALUES('three o');\n  INSERT INTO t3 VALUES('four e');\n  INSERT INTO t3 VALUES('five o');\n}\ndo_execsql_test 3.1 {\n  SELECT * FROM t3 WHERE t3 MATCH 'o'\n} {{one o} {three o} {five o}}\n\ndo_catchsql_test 3.1 {\n  DELETE FROM t3_content WHERE rowid = 3;\n  SELECT * FROM t3 WHERE t3 MATCH 'o';\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5corrupt2.test",
    "content": "# 2015 Apr 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that FTS5 handles corrupt databases (i.e. internal\n# inconsistencies in the backing tables) correctly. In this case \n# \"correctly\" means without crashing.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5corrupt2\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\nsqlite3_fts5_may_be_corrupt 1\n\n# Create a simple FTS5 table containing 100 documents. Each document \n# contains 10 terms, each of which start with the character \"x\".\n#\nexpr srand(0)\ndb func rnddoc fts5_rnddoc\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100)\n  INSERT INTO t1 SELECT rnddoc(10) FROM ii;\n}\nset mask [expr 31 << 31]\n\nif 0 {\n\n# Test 1:\n#\n#   For each page in the t1_data table, open a transaction and DELETE\n#   the t1_data entry. Then run:\n#\n#     * an integrity-check, and\n#     * unless the deleted block was a b-tree node, a query for \"t1 MATCH 'x*'\"\n#\n#   and check that the corruption is detected in both cases. The \n#   rollback the transaction.\n#\n# Test 2:\n#\n#   Same thing, except instead of deleting a row from t1_data, replace its\n#   blob content with integer value 14.\n#\nforeach {tno stmt} {\n  1 { DELETE FROM t1_data WHERE rowid=$rowid }\n  2 { UPDATE t1_data SET block=14 WHERE rowid=$rowid }\n} {\n  set tn 0\n  foreach rowid [db eval {SELECT rowid FROM t1_data WHERE rowid>10}] {\n    incr tn\n    #if {$tn!=224} continue\n  \n    do_test 1.$tno.$tn.1.$rowid {\n      execsql { BEGIN }\n      execsql $stmt\n      catchsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n    } {1 {database disk image is malformed}}\n  \n    if {($rowid & $mask)==0} {\n      # Node is a leaf node, not a b-tree node.\n      do_catchsql_test 1.$tno.$tn.2.$rowid {\n        SELECT rowid FROM t1 WHERE t1 MATCH 'x*'\n      } {1 {database disk image is malformed}}\n    }\n  \n    do_execsql_test 1.$tno.$tn.3.$rowid {\n      ROLLBACK;\n      INSERT INTO t1(t1) VALUES('integrity-check');\n    } {}\n  }\n}\n\n}\n\n# Using the same database as the 1.* tests.\n#\n# Run N-1 tests, where N is the number of bytes in the rightmost leaf page\n# of the fts index. For test $i, truncate the rightmost leafpage to $i\n# bytes. Then test both the integrity-check detects the corruption.\n#\n# Also tested is that \"MATCH 'x*'\" does not crash and sometimes reports\n# corruption. It may not report the db as corrupt because truncating the\n# final leaf to some sizes may create a valid leaf page.\n#\nset lrowid [db one {SELECT max(rowid) FROM t1_data WHERE (rowid & $mask)=0}] \nset nbyte [db one {SELECT length(block) FROM t1_data WHERE rowid=$lrowid}]\nset all [db eval {SELECT rowid FROM t1}]\nfor {set i [expr $nbyte-2]} {$i>=0} {incr i -1} {\n  do_execsql_test 2.$i.1 {\n    BEGIN;\n      UPDATE t1_data SET block = substr(block, 1, $i) WHERE rowid=$lrowid;\n  }\n\n  do_catchsql_test 2.$i.2 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  } {1 {database disk image is malformed}}\n\n  do_test 2.$i.3 {\n    set res [catchsql {SELECT rowid FROM t1 WHERE t1 MATCH 'x*'}]\n    expr {\n        $res==\"1 {database disk image is malformed}\" \n     || $res==\"0 {$all}\" \n    }\n  } 1\n\n  do_execsql_test 2.$i.4 {\n    ROLLBACK;\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Test that corruption in leaf page headers is detected by queries that use\n# doclist-indexes.\n#\nset doc \"A B C D E F G H I J \"\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE x3 USING fts5(tt);\n  INSERT INTO x3(x3, rank) VALUES('pgsz', 32);\n  WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<1000) \n  INSERT INTO x3 \n  SELECT ($doc || CASE WHEN (i%50)==0 THEN 'X' ELSE 'Y' END) FROM ii;\n}\n\nforeach {tn hdr} {\n  1 \"\\x00\\x00\\x00\\x00\"\n  2 \"\\xFF\\xFF\\xFF\\xFF\"\n  3 \"\\x44\\x45\"\n} {\n  set tn2 0\n  set nCorrupt 0\n  set nCorrupt2 0\n  foreach rowid [db eval {SELECT rowid FROM x3_data WHERE rowid>10}] {\n    if {$rowid & $mask} continue\n    incr tn2\n    do_test 3.$tn.$tn2.1 {\n      execsql BEGIN\n\n      set fd [db incrblob main x3_data block $rowid]\n      fconfigure $fd -encoding binary -translation binary\n      set existing [read $fd [string length $hdr]]\n      seek $fd 0\n      puts -nonewline $fd $hdr\n      close $fd\n\n      set res [catchsql {SELECT rowid FROM x3 WHERE x3 MATCH 'x AND a'}]\n      if {$res == \"1 {database disk image is malformed}\"} {incr nCorrupt}\n      set {} 1\n    } {1}\n\n    if {($tn2 % 10)==0 && $existing != $hdr} {\n      do_test 3.$tn.$tn2.2 {\n        catchsql { INSERT INTO x3(x3) VALUES('integrity-check') }\n      } {1 {database disk image is malformed}}\n    }\n\n    execsql ROLLBACK\n  }\n\n  do_test 3.$tn.x { expr $nCorrupt>0 } 1\n}\n\n#--------------------------------------------------------------------\n#\nset doc \"A B C D E F G H I J \"\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE x4 USING fts5(tt);\n  INSERT INTO x4(x4, rank) VALUES('pgsz', 32);\n  WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10) \n  INSERT INTO x4 \n  SELECT ($doc || CASE WHEN (i%50)==0 THEN 'X' ELSE 'Y' END) FROM ii;\n}\n\nforeach {tn nCut} {\n  1 1\n  2 10\n} {\n  set tn2 0\n  set nCorrupt 0\n  foreach rowid [db eval {SELECT rowid FROM x4_data WHERE rowid>10}] {\n    if {$rowid & $mask} continue\n    incr tn2\n    do_test 4.$tn.$tn2 {\n      execsql {\n        BEGIN;\n          UPDATE x4_data SET block = substr(block, 1, length(block)-$nCut) \n          WHERE id = $rowid;\n      }\n\n      set res [catchsql {\n        SELECT rowid FROM x4 WHERE x4 MATCH 'a' ORDER BY 1 DESC\n      }]\n      if {$res == \"1 {database disk image is malformed}\"} {incr nCorrupt}\n      set {} 1\n    } {1}\n\n    execsql ROLLBACK\n  }\n\n  # do_test 4.$tn.x { expr $nCorrupt>0 } 1\n}\n\nset doc [string repeat \"A B C \" 1000]\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE x5 USING fts5(tt);\n  INSERT INTO x5(x5, rank) VALUES('pgsz', 32);\n  WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10) \n  INSERT INTO x5 SELECT $doc FROM ii;\n}\n\nforeach {tn hdr} {\n  1 \"\\x00\\x01\"\n} {\n  set tn2 0\n  set nCorrupt 0\n  foreach rowid [db eval {SELECT rowid FROM x5_data WHERE rowid>10}] {\n    if {$rowid & $mask} continue\n    incr tn2\n    do_test 5.$tn.$tn2 {\n      execsql BEGIN\n\n      set fd [db incrblob main x5_data block $rowid]\n      fconfigure $fd -encoding binary -translation binary\n      puts -nonewline $fd $hdr\n      close $fd\n\n      catchsql { INSERT INTO x5(x5) VALUES('integrity-check') }\n      set {} {}\n    } {}\n\n    execsql ROLLBACK\n  }\n}\n\n#--------------------------------------------------------------------\nreset_db\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE x5 USING fts5(tt);\n  INSERT INTO x5 VALUES('a');\n  INSERT INTO x5 VALUES('a a');\n  INSERT INTO x5 VALUES('a a a');\n  INSERT INTO x5 VALUES('a a a a');\n\n  UPDATE x5_docsize SET sz = X'' WHERE id=3;\n}\nproc colsize {cmd i} { \n  $cmd xColumnSize $i\n}\nsqlite3_fts5_create_function db colsize colsize\n\ndo_catchsql_test 6.2 {\n  SELECT colsize(x5, 0) FROM x5 WHERE x5 MATCH 'a'\n} {1 SQLITE_CORRUPT_VTAB}\n\n\nsqlite3_fts5_may_be_corrupt 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5corrupt3.test",
    "content": "# 2015 Apr 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that FTS5 handles corrupt databases (i.e. internal\n# inconsistencies in the backing tables) correctly. In this case \n# \"correctly\" means without crashing.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5corrupt3\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\nsqlite3_fts5_may_be_corrupt 1\n\nproc create_t1 {} {\n  expr srand(0)\n  db func rnddoc fts5_rnddoc\n  db eval {\n    CREATE VIRTUAL TABLE t1 USING fts5(x);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 64);\n    WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100)\n      INSERT INTO t1 SELECT rnddoc(10) FROM ii;\n  }\n}\n\nif 1 {\n\n# Create a simple FTS5 table containing 100 documents. Each document \n# contains 10 terms, each of which start with the character \"x\".\n#\ndo_test 1.0 { create_t1 } {}\n\ndo_test 1.1 {\n  # Pick out the rowid of the right-most b-tree leaf in the new segment.\n  set rowid [db one {\n    SELECT max(rowid) FROM t1_data WHERE ((rowid>>31) & 0x0F)==1\n  }]\n  set L [db one {SELECT length(block) FROM t1_data WHERE rowid = $rowid}]\n  set {} {}\n} {} \n\nfor {set i 0} {$i < $L} {incr i} {\n  do_test 1.2.$i {\n    catchsql {\n      BEGIN;\n      UPDATE t1_data SET block = substr(block, 1, $i) WHERE id = $rowid;\n      INSERT INTO t1(t1) VALUES('integrity-check');\n    }\n  } {1 {database disk image is malformed}}\n  catchsql ROLLBACK\n}\n \n#-------------------------------------------------------------------------\n# Test that trailing bytes appended to the averages record are ignored.\n#\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x);\n  INSERT INTO t2 VALUES(rnddoc(10));\n  INSERT INTO t2 VALUES(rnddoc(10));\n  SELECT length(block) FROM t2_data WHERE id=1;\n} {2}\ndo_execsql_test 2.2 {\n  UPDATE t2_data SET block = block || 'abcd' WHERE id=1;\n  SELECT length(block) FROM t2_data WHERE id=1;\n} {6}\ndo_execsql_test 2.2 {\n  INSERT INTO t2 VALUES(rnddoc(10));\n  SELECT length(block) FROM t2_data WHERE id=1;\n} {2}\n\n\n#-------------------------------------------------------------------------\n# Test that missing leaf pages are recognized as corruption.\n#\nreset_db\ndo_test 3.0 { create_t1 } {}\n\ndo_execsql_test 3.1 {\n  SELECT count(*) FROM t1_data;\n} {105}\n\nproc do_3_test {tn} {\n  set i 0\n  foreach ::rowid [db eval \"SELECT rowid FROM t1_data WHERE rowid>100\"] {\n    incr i\n    do_test $tn.$i {\n      db eval BEGIN\n      db eval {DELETE FROM t1_data WHERE rowid = $::rowid}\n      list [\n        catch { db eval {SELECT rowid FROM t1 WHERE t1 MATCH 'x*'} } msg\n      ] $msg\n    } {1 {database disk image is malformed}}\n    catch { db eval ROLLBACK }\n  }\n}\n\ndo_3_test 3.2\n\ndo_execsql_test 3.3 {\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1(t1) VALUES('optimize');\n} {}\n\ndo_3_test 3.4\n\ndo_test 3.5 {\n  execsql { \n    DELETE FROM t1;\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 40);\n  }\n  for {set i 0} {$i < 1000} {incr i} {\n    set rnd [expr int(rand() * 1000)]\n    set doc [string repeat \"x$rnd \" [expr int(rand() * 3) + 1]]\n    execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) }\n  }\n} {}\n\ndo_3_test 3.6\n\ndo_test 3.7 {\n  execsql {\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 40);\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1(t1) VALUES('optimize');\n  }\n} {}\n\ndo_3_test 3.8\n\ndo_test 3.9 {\n  execsql { \n    DELETE FROM t1;\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  }\n  for {set i 0} {$i < 100} {incr i} {\n    set rnd [expr int(rand() * 100)]\n    set doc \"x[string repeat $rnd 20]\"\n    execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) }\n  }\n} {}\n\ndo_3_test 3.10\n\n#-------------------------------------------------------------------------\n# Test that segments that end unexpectedly are identified as corruption.\n#\nreset_db\ndo_test 4.0 {\n  execsql { \n    CREATE VIRTUAL TABLE t1 USING fts5(x);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  }\n  for {set i 0} {$i < 100} {incr i} {\n    set rnd [expr int(rand() * 100)]\n    set doc \"x[string repeat $rnd 20]\"\n    execsql { INSERT INTO t1(rowid, x) VALUES($i, $doc) }\n  }\n  execsql { INSERT INTO t1(t1) VALUES('optimize') }\n} {}\n\nset nErr 0\nfor {set i 1} {1} {incr i} {\n  set struct [db one {SELECT block FROM t1_data WHERE id=10}]\n  binary scan $struct c* var\n  set end [lindex $var end]\n  if {$end<=$i} break\n  lset var end [expr $end - $i]\n  set struct [binary format c* $var]\n\n  db close\n  sqlite3 db test.db\n\n  db eval {\n    BEGIN;\n    UPDATE t1_data SET block = $struct WHERE id=10;\n  }\n  do_test 4.1.$i {\n    incr nErr [catch { db eval { SELECT rowid FROM t1 WHERE t1 MATCH 'x*' } }]\n    set {} {}\n  } {}\n  catch { db eval ROLLBACK }\n}\ndo_test 4.1.x { expr $nErr>45 } 1\n\n#-------------------------------------------------------------------------\n#\n\n# The first argument passed to this command must be a binary blob \n# containing an FTS5 leaf page. This command returns a copy of this\n# blob, with the pgidx of the leaf page replaced by a single varint\n# containing value $iVal.\n#\nproc rewrite_pgidx {blob iVal} {\n  binary scan $blob SS off1 szLeaf\n  if {$iVal<0 || $iVal>=128} {\n    error \"$iVal out of range!\"\n  } else {\n    set pgidx [binary format c $iVal]\n  }\n\n  binary format a${szLeaf}a* $blob $pgidx\n}\n\nreset_db\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 40);\n  BEGIN;\n  INSERT INTO x1 VALUES('xaaa xabb xccc xcdd xeee xeff xggg xghh xiii xijj');\n  INSERT INTO x1 SELECT x FROM x1;\n  INSERT INTO x1 SELECT x FROM x1;\n  INSERT INTO x1 SELECT x FROM x1;\n  INSERT INTO x1 SELECT x FROM x1;\n  INSERT INTO x1(x1) VALUES('optimize');\n  COMMIT;\n}\n\n#db eval { SELECT fts5_decode(id, block) b from x1_data } { puts $b }\n#\ndb func rewrite_pgidx rewrite_pgidx  \nset i 0\nforeach rowid [db eval {SELECT rowid FROM x1_data WHERE rowid>100}] {\n  foreach val {2 100} {\n    do_test 5.2.$val.[incr i] {\n      catchsql {\n        BEGIN;\n        UPDATE x1_data SET block=rewrite_pgidx(block, $val) WHERE id=$rowid;\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xa*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xb*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xc*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xd*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xe*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xf*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xg*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xh*';\n        SELECT rowid FROM x1 WHERE x1 MATCH 'xi*';\n      }\n      set {} {}\n    } {}\n    catch { db eval ROLLBACK }\n  }\n}\n\n#------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 6.1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a);\n  INSERT INTO t1 VALUES('bbbbb ccccc');\n  SELECT quote(block) FROM t1_data WHERE rowid>100;\n} {X'000000180630626262626201020201056363636363010203040A'}\ndo_execsql_test 6.1.1 {\n  UPDATE t1_data SET block = \n  X'000000180630626262626201020201056161616161010203040A'\n  WHERE rowid>100;\n}\ndo_catchsql_test 6.1.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\n#-------\nreset_db\ndo_execsql_test 6.2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  INSERT INTO t1 VALUES('aa bb cc dd ee');\n  SELECT pgno, quote(term) FROM t1_idx;\n} {2 X'' 4 X'3064'}\ndo_execsql_test 6.2.1 {\n  UPDATE t1_idx SET term = X'3065' WHERE pgno=4;\n}\ndo_catchsql_test 6.2.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\n#-------\nreset_db\ndo_execsql_test 6.3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a);\n  INSERT INTO t1 VALUES('abc abcdef abcdefghi');\n  SELECT quote(block) FROM t1_data WHERE id>100;\n}    {X'0000001C043061626301020204036465660102030703676869010204040808'}\ndo_execsql_test 6.3.1 {\n  BEGIN;\n    UPDATE t1_data SET block = \n      X'0000001C043061626301020204036465660102035003676869010204040808'\n      ------------------------------------------^^---------------------\n    WHERE id>100;\n}\ndo_catchsql_test 6.3.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\ndo_execsql_test 6.3.3 {\n  ROLLBACK;\n  BEGIN;\n    UPDATE t1_data SET block = \n      X'0000001C043061626301020204036465660102030750676869010204040808'\n      --------------------------------------------^^-------------------\n    WHERE id>100;\n}\ndo_catchsql_test 6.3.3 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\ndo_execsql_test 6.3.4 {\n  ROLLBACK;\n  BEGIN;\n    UPDATE t1_data SET block = \n      X'0000001C043061626301020204036465660102030707676869010204040850'\n      --------------------------------------------------------------^^-\n    WHERE id>100;\n}\ndo_catchsql_test 6.3.5 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\ndo_execsql_test 6.3.6 {\n  ROLLBACK;\n  BEGIN;\n    UPDATE t1_data SET block = \n      X'0000001C503061626301020204036465660102030707676869010204040808'\n      ----------^^-----------------------------------------------------\n    WHERE id>100;\n}\ndo_catchsql_test 6.3.5 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\n\n#------------------------------------------------------------------------\n#\nreset_db\nproc rnddoc {n} {\n  set map [list a b c d]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc \"x[lindex $map [expr int(rand()*4)]]\"\n  }\n  set doc\n}\n\ndb func rnddoc rnddoc\ndo_test 7.0 {\n  execsql {\n    CREATE VIRTUAL TABLE t5 USING fts5(x);\n    INSERT INTO t5 VALUES( rnddoc(10000) );\n    INSERT INTO t5 VALUES( rnddoc(10000) );\n    INSERT INTO t5 VALUES( rnddoc(10000) );\n    INSERT INTO t5 VALUES( rnddoc(10000) );\n    INSERT INTO t5(t5) VALUES('optimize');\n  }\n} {}\n\ndo_test 7.1 {\n  foreach i [db eval { SELECT rowid FROM t5_data WHERE rowid>100 }] {\n    db eval BEGIN  \n    db eval {DELETE FROM t5_data WHERE rowid = $i}\n    set r [catchsql { INSERT INTO t5(t5) VALUES('integrity-check')} ]\n    if {$r != \"1 {database disk image is malformed}\"} { error $r }\n    db eval ROLLBACK  \n  }\n} {}\n\n}\n\n#------------------------------------------------------------------------\n# Corruption within the structure record.\n#\nreset_db\ndo_execsql_test 8.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y);\n  INSERT INTO t1 VALUES('one', 'two');\n}\n\ndo_test 9.1.1 {\n  set    blob \"12345678\"    ;# cookie\n  append blob \"0105\"        ;# 1 level, total of 5 segments\n  append blob \"06\"          ;# write counter\n  append blob \"0002\"        ;# first level has 0 segments merging, 2 other.\n  append blob \"450108\"      ;# first segment\n  execsql \"REPLACE INTO t1_data VALUES(10, X'$blob')\"\n} {}\ndo_catchsql_test 9.1.2 {\n  SELECT * FROM t1('one AND two');\n} {1 {database disk image is malformed}}\n\ndo_test 9.2.1 {\n  set    blob \"12345678\"    ;# cookie\n  append blob \"0205\"        ;# 2 levels, total of 5 segments\n  append blob \"06\"          ;# write counter\n  append blob \"0001\"        ;# first level has 0 segments merging, 1 other.\n  append blob \"450108\"      ;# first segment\n  execsql \"REPLACE INTO t1_data VALUES(10, X'$blob')\"\n} {}\ndo_catchsql_test 9.2.2 {\n  SELECT * FROM t1('one AND two');\n} {1 {database disk image is malformed}}\n\nsqlite3_fts5_may_be_corrupt 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5delete.test",
    "content": "# 2017 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5delete\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\nfts5_aux_test_functions db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<5000\n  )\n  INSERT INTO t1(rowid, x) SELECT i, (i/2)*2 FROM s;\n}\n\ndo_test 1.1 {\n  execsql BEGIN\n  for {set i 1} {$i<=5000} {incr i} {\n    if {$i % 2} {\n      execsql { INSERT INTO t1 VALUES($i) }\n    } else {\n      execsql { DELETE FROM t1 WHERE rowid = $i }\n    }\n  }\n  execsql COMMIT\n} {}\n\ndo_test 1.2 {\n  execsql { INSERT INTO t1(t1, rank) VALUES('usermerge', 2); }\n  for {set i 0} {$i < 5} {incr i} {\n    execsql { INSERT INTO t1(t1, rank) VALUES('merge', 1) }\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5detail.test",
    "content": "# 2015 December 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5detail\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nfts5_aux_test_functions db\n\n#--------------------------------------------------------------------------\n# Simple tests.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, detail=col);\n  INSERT INTO t1 VALUES('h d g', 'j b b g b', 'i e i d h g g'); -- 1\n  INSERT INTO t1 VALUES('h j d', 'j h d a h', 'f d d g g f b'); -- 2\n  INSERT INTO t1 VALUES('j c i', 'f f h e f', 'c j i j c h f'); -- 3\n  INSERT INTO t1 VALUES('e g g', 'g e d h i', 'e d b e g d c'); -- 4\n  INSERT INTO t1 VALUES('b c c', 'd i h a f', 'd i j f a b c'); -- 5\n  INSERT INTO t1 VALUES('e d e', 'b c j g d', 'a i f d h b d'); -- 6\n  INSERT INTO t1 VALUES('g h e', 'b c d i d', 'e f c i f i c'); -- 7\n  INSERT INTO t1 VALUES('c f j', 'j j i e a', 'h a c f d h e'); -- 8\n  INSERT INTO t1 VALUES('a h i', 'c i a f a', 'c f d h g d g'); -- 9\n  INSERT INTO t1 VALUES('j g g', 'e f e f f', 'h j b i c g e'); -- 10\n}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\nforeach {tn match res} {\n  1 \"a:a\" {9}\n  2 \"b:g\" {1 4 6}\n  3 \"c:h\" {1 3 6 8 9 10}\n} {\n  do_execsql_test 1.2.$tn.1 {\n    SELECT rowid FROM t1($match);\n  } $res\n\n  do_execsql_test 1.2.$tn.2 {\n    SELECT rowid FROM t1($match || '*');\n  } $res\n}\n\ndo_catchsql_test 1.3.1 {\n  SELECT rowid FROM t1('h + d');\n} {1 {fts5: phrase queries are not supported (detail!=full)}}\n\ndo_catchsql_test 1.3.2 {\n  SELECT rowid FROM t1('NEAR(h d)');\n} {1 {fts5: NEAR queries are not supported (detail!=full)}}\n\n\n#-------------------------------------------------------------------------\n# integrity-check with both detail= and prefix= options.\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, detail=col, prefix=\"1\");\n  INSERT INTO t2(a) VALUES('aa ab');\n}\n\n#db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t2_data} {puts $r}\n\ndo_execsql_test 2.1 {\n  INSERT INTO t2(t2) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.2 {\n  SELECT fts5_test_poslist(t2) FROM t2('aa');\n} {0.0.0}\n\ndo_execsql_test 2.3 {\n  SELECT fts5_test_collist(t2) FROM t2('aa');\n} {0.0}\n\nset ::pc 0\n#puts [nearset {{ax bx cx}} -pc ::pc -near 10 -- b*]\n#exit\n\n#-------------------------------------------------------------------------\n# Check that the xInstCount, xInst, xPhraseFirst and xPhraseNext APIs\n# work with detail=col tables.\n#\nset data {\n  1  {abb aca aca} {aba bab aab aac caa} {abc cbc ccb bcc bab ccb aca}\n  2  {bca aca acb} {ccb bcc bca aab bcc} {bab aaa aac cbb bba aca abc}\n  3  {cca abc cab} {aab aba bcc cac baa} {bab cbb acb aba aab ccc cca}\n  4  {ccb bcb aba} {aba bbb bcc cac bbb} {cbb aaa bca bcc aab cac aca}\n  5  {bca bbc cac} {aba cbb cac cca aca} {cab acb cbc ccb cac bbb bcb}\n  6  {acc bba cba} {bab bbc bbb bcb aca} {bca ccc cbb aca bac ccc ccb}\n  7  {aba bab aaa} {abb bca aac bcb bcc} {bcb bbc aba aaa cba abc acc}\n  8  {cab aba aaa} {ccb aca caa bbc bcc} {aaa abc ccb bbb cac cca abb}\n  9  {bcb bab bac} {bcb cba cac bbb abc} {aba aca cbb acb abb ccc ccb}\n  10 {aba aab ccc} {abc ccc bcc cab bbb} {aab bcc cbb ccc aaa bac baa}\n  11 {bab acb cba} {aac cab cab bca cbc} {aab cbc aac baa ccb acc cac}\n  12 {ccc cbb cbc} {aaa aab bcc aac bbc} {cbc cbc bac bac ccc bbc acc}\n  13 {cab bbc abc} {bbb bab bba aca bab} {baa bbb aab bbb ccb bbb ccc}\n  14 {bbc cab caa} {acb aac abb cba acc} {cba bba bba acb abc abb baa}\n  15 {aba cca bcc} {aaa acb abc aab ccb} {cca bcb acc aaa caa cca cbc}\n  16 {bcb bba aba} {cbc acb cab caa ccb} {aac aaa bbc cab cca cba abc}\n  17 {caa cbb acc} {ccb bcb bca aaa bcc} {bbb aca bcb bca cbc cbc cca}\n  18 {cbb bbc aac} {ccc bbc aaa aab baa} {cab cab cac cca bbc abc bbc}\n  19 {ccc acc aaa} {aab cbb bca cca caa} {bcb aca aca cab acc bac bcc}\n  20 {aab ccc bcb} {bbc cbb bbc aaa bcc} {cbc aab ccc aaa bcb bac cbc}\n  21 {aba cab ccc} {bbc cbc cba acc bbb} {acc aab aac acb aca bca acb}\n  22 {bcb bca baa} {cca bbc aca ccb cbb} {aab abc bbc aaa cab bcc bcc}\n  23 {cac cbb caa} {bbc aba bbb bcc ccb} {bbc bbb cab bbc cac abb acc}\n  24 {ccb acb caa} {cab bba cac bbc aac} {aac bca abc cab bca cab bcb}\n  25 {bbb aca bca} {bcb acc ccc cac aca} {ccc acb acc cac cac bba bbc}\n  26 {bab acc caa} {caa cab cac bac aca} {aba cac caa acc bac ccc aaa}\n  27 {bca bca aaa} {ccb aca bca aaa baa} {bab acc aaa cca cba cca bac}\n  28 {ccb cac cac} {bca abb bba bbc baa} {aca ccb aac cab ccc cab caa}\n  29 {abc bca cab} {cac cbc cbb ccc bcc} {bcc aaa aaa acc aac cac aac}\n  30 {aca acc acb} {aab aac cbb caa acb} {acb bbc bbc acc cbb bbc aac}\n  31 {aba aca baa} {aca bcc cab bab acb} {bcc acb baa bcb bbc acc aba}\n  32 {abb cbc caa} {cba abb bbb cbb aca} {bac aca caa cac caa ccb bbc}\n  33 {bcc bcb bcb} {cca cab cbc abb bab} {caa bbc aac bbb cab cba aaa}\n  34 {caa cab acc} {ccc ccc bcc acb bcc} {bac bba aca bcb bba bcb cac}\n  35 {bac bcb cba} {bcc acb bbc cba bab} {abb cbb abc abc bac acc cbb}\n  36 {cab bab ccb} {bca bba bab cca acc} {acc aab bcc bac acb cbb caa}\n  37 {aca cbc cab} {bba aac aca aac aaa} {baa cbb cba aba cab bca bcb}\n  38 {acb aab baa} {baa bab bca bbc bbb} {abc baa acc aba cab baa cac}\n  39 {bcb aac cba} {bcb baa caa cac bbc} {cbc ccc bab ccb bbb caa aba}\n  40 {cba ccb abc} {cbb caa cba aac bab} {cbb bbb bca bbb bac cac bca}\n}\n\nset data {\n  1  {abb aca aca} {aba bab aab aac caa} {abc cbc ccb bcc bab ccb aca}\n}\n\nproc matchdata {expr {bAsc 1}} {\n\n  set tclexpr [db one {\n    SELECT fts5_expr_tcl($expr, 'nearset $cols -pc ::pc', 'x', 'y', 'z')\n  }]\n  set res [list]\n\n  #puts \"$expr -> $tclexpr\"\n  foreach {id x y z} $::data {\n    set cols [list $x $y $z]\n    set ::pc 0\n    #set hits [lsort -command instcompare [eval $tclexpr]]\n    set hits [eval $tclexpr]\n    if {[llength $hits]>0} {\n      lappend res [list $id $hits]\n    }\n  }\n\n  if {$bAsc} {\n    set res [lsort -integer -increasing -index 0 $res]\n  } else {\n    set res [lsort -integer -decreasing -index 0 $res]\n  }\n\n  return [concat {*}$res]\n}\n\nforeach {tn tbl} {\n  1 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, detail=col) }\n  2 { CREATE VIRTUAL TABLE t3 USING fts5(x, y, z, detail=none) }\n} {\n  reset_db\n  fts5_aux_test_functions db\n  execsql $tbl\n  foreach {id x y z} $data {\n    execsql { INSERT INTO t3(rowid, x, y, z) VALUES($id, $x, $y, $z) }\n  }\n  foreach {tn2 expr} {\n    1 aaa    2 ccc    3 bab    4 aac\n    5 aa*    6 cc*    7 ba*    8 aa*\n    9 a*     10 b*   11 c*\n  } {\n\n    set res [matchdata $expr]\n\n    do_execsql_test 3.$tn.$tn2.1 {\n      SELECT rowid, fts5_test_poslist(t3) FROM t3($expr)\n    } $res\n\n    do_execsql_test 3.$tn.$tn2.2 {\n      SELECT rowid, fts5_test_poslist2(t3) FROM t3($expr)\n    } $res\n  }\n}\n\n#-------------------------------------------------------------------------\n# Simple tests for detail=none tables.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t4 USING fts5(a, b, c, detail=none);\n  INSERT INTO t4 VALUES('a b c', 'b c d', 'e f g');\n  INSERT INTO t4 VALUES('1 2 3', '4 5 6', '7 8 9');\n}\n\ndo_catchsql_test 4.1 {\n  SELECT * FROM t4('a:a')\n} {1 {fts5: column queries are not supported (detail=none)}}\n\n#-------------------------------------------------------------------------\n# Test that for the same content detail=none uses less space than \n# detail=col, and that detail=col uses less space than detail=full\n#\nreset_db\ndo_test 5.1 {\n  foreach {tbl detail} {t1 none t2 col t3 full} {\n    execsql \"CREATE VIRTUAL TABLE $tbl USING fts5(x, y, z, detail=$detail)\"\n    foreach {rowid x y z} $::data {\n      execsql \"INSERT INTO $tbl (rowid, x, y, z) VALUES(\\$rowid, \\$x, \\$y, \\$z)\"\n    }\n  }\n} {}\n\ndo_execsql_test 5.2 {\n  SELECT \n    (SELECT sum(length(block)) from t1_data) <\n    (SELECT sum(length(block)) from t2_data)\n} {1}\n\ndo_execsql_test 5.3 {\n  SELECT \n    (SELECT sum(length(block)) from t2_data) <\n    (SELECT sum(length(block)) from t3_data)\n} {1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5determin.test",
    "content": "# 2016 March 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n# Specifically, that the fts5 module is deterministic. At one point, when\n# segment ids were allocated using sqlite3_randomness(), this was not the\n# case.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5aa\nreturn_if_no_fts5 \n\nproc do_determin_test {tn} {\n  uplevel [list\n    do_execsql_test $tn {\n      SELECT (SELECT md5sum(id, block) FROM t1_data)==\n             (SELECT md5sum(id, block) FROM t2_data),\n             (SELECT md5sum(id, block) FROM t1_data)==\n             (SELECT md5sum(id, block) FROM t3_data)\n    } {1 1}\n  ]\n}\n\nforeach_detail_mode $::testprefix {\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix=\"1 2\", detail=%DETAIL%);\n    CREATE VIRTUAL TABLE t2 USING fts5(a, b, prefix=\"1 2\", detail=%DETAIL%);\n    CREATE VIRTUAL TABLE t3 USING fts5(a, b, prefix=\"1 2\", detail=%DETAIL%);\n  }\n\n  do_test 1.1 {\n    foreach t {t1 t2 t3} {\n      execsql [string map [list TBL $t] {\n        INSERT INTO TBL VALUES('a b c', 'd e f');\n        INSERT INTO TBL VALUES('c1 c2 c3', 'c1 c2 c3');\n        INSERT INTO TBL VALUES('xyzxyzxyz', 'xyzxyzxyz');\n      }]\n    }\n  } {}\n\n  do_determin_test 1.2\n\n  do_test 1.3 {\n    foreach t {t1 t2 t3} {\n      execsql [string map [list TBL $t] {\n        INSERT INTO TBL(TBL) VALUES('optimize');\n      }]\n    }\n  } {}\n\n  do_determin_test 1.4\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5dlidx.test",
    "content": "# 2015 April 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test is focused on uses of doclist-index records.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5dlidx\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nif { $tcl_platform(wordSize)<8 } {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\nproc do_fb_test {tn sql res} {\n  set res2 [lsort -integer -decr $res]\n  uplevel [list do_execsql_test $tn.1 $sql $res]\n  uplevel [list do_execsql_test $tn.2 \"$sql ORDER BY rowid DESC\" $res2]\n}\n\n# This test populates the FTS5 table with $nEntry entries. Rows are \n# numbered from 0 to ($nEntry-1). The rowid for row $i is:\n#\n#   ($iFirst + $i*$nStep)\n#\n# Each document is of the form \"a b c a b c a b c...\". If the row number ($i)\n# is an integer multiple of $spc1, then an \"x\" token is appended to the\n# document. If it is *also* a multiple of $spc2, a \"y\" token is also appended.\n#\nproc do_dlidx_test1 {tn spc1 spc2 nEntry iFirst nStep} {\n\n  do_execsql_test $tn.0 { DELETE FROM t1 }\n\n  set xdoc [list]\n  set ydoc [list]\n\n  execsql BEGIN\n  for {set i 0} {$i < $nEntry} {incr i} {\n    set rowid [expr $i * $nStep]\n    set doc [string trim [string repeat \"a b c \" 100]]\n    if {($i % $spc1)==0} {\n      lappend xdoc $rowid\n      append doc \" x\" \n      if {($i % $spc2)==0} { \n        lappend ydoc $rowid\n        append doc \" y\" \n      }\n    }\n    execsql { INSERT INTO t1(rowid, x) VALUES($rowid, $doc) }\n  }\n  execsql COMMIT\n\n  do_test $tn.1 {\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n  } {}\n  \n  do_fb_test $tn.3.1 { SELECT rowid FROM t1 WHERE t1 MATCH 'a AND x' } $xdoc\n  do_fb_test $tn.3.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'x AND a' } $xdoc\n  \n  do_fb_test $tn.4.1 { SELECT rowid FROM t1 WHERE t1 MATCH 'a AND y' } $ydoc\n  do_fb_test $tn.4.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'y AND a' } $ydoc\n  \n  if {[detail_is_full]} {\n    do_fb_test $tn.5.1 { \n      SELECT rowid FROM t1 WHERE t1 MATCH 'a + b + c + x' } $xdoc\n    do_fb_test $tn.5.2 { \n      SELECT rowid FROM t1 WHERE t1 MATCH 'b + c + x + y' } $ydoc\n  }\n}\n\n\nforeach {tn pgsz} {\n  1 32\n  2 200\n} {\n  do_execsql_test $tn.0 { \n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz);\n  }\n\n  do_dlidx_test1 1.$tn.1     10 100 10000 0 1000\n  do_dlidx_test1 1.$tn.2     10 10  10000 0 128\n  do_dlidx_test1 1.$tn.3     10 10  66    0 36028797018963970\n  do_dlidx_test1 1.$tn.4     10 10  50    0 150000000000000000\n  do_dlidx_test1 1.$tn.5     10 10  200   0 [expr 1<<55]\n  do_dlidx_test1 1.$tn.6      10 10  30    0 [expr 1<<58]\n}\n\nproc do_dlidx_test2 {tn nEntry iFirst nStep} {\n  set str [string repeat \"a \" 500]\n  execsql {\n    BEGIN;\n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n    INSERT INTO t1(t1, rank) VALUES('pgsz', 64);\n    INSERT INTO t1 VALUES('b a');\n\n    WITH iii(ii, i) AS (\n      SELECT 1,     $iFirst UNION ALL \n      SELECT ii+1, i+$nStep FROM iii WHERE ii<$nEntry\n    )\n    INSERT INTO t1(rowid,x) SELECT i, $str FROM iii;\n    COMMIT;\n  }\n\n  do_execsql_test $tn.1 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'b AND a'\n  } {1}\n  do_execsql_test $tn.2 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'b AND a' ORDER BY rowid DESC\n  } {1}\n}\n\ndo_dlidx_test2 2.1 [expr 20] [expr 1<<57] [expr (1<<57) + 128]\n\n#--------------------------------------------------------------------\n#\nreset_db\n\nset ::vocab [list \\\n  IteratorpItercurrentlypointstothefirstrowidofadoclist \\\n  Thereisadoclistindexassociatedwiththefinaltermonthecurrent \\\n  pageIfthecurrenttermisthelasttermonthepageloadthe \\\n  doclistindexfromdiskandinitializeaniteratoratpIterpDlidx \\\n  IteratorpItercurrentlypointstothefirstrowidofadoclist \\\n  Thereisadoclistindexassociatedwiththefinaltermonthecurrent \\\n  pageIfthecurrenttermisthelasttermonthepageloadthe \\\n  doclistindexfromdiskandinitializeaniteratoratpIterpDlidx \\\n]\nproc rnddoc {} {\n  global vocab\n  set nVocab [llength $vocab]\n  set ret [list]\n  for {set i 0} {$i < 64} {incr i} {\n    lappend ret [lindex $vocab [expr $i % $nVocab]]\n  }\n  set ret\n}\ndb func rnddoc rnddoc\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE abc USING fts5(a, detail=%DETAIL%);\n  INSERT INTO abc(abc, rank) VALUES('pgsz', 32);\n\n  INSERT INTO abc VALUES ( rnddoc() );\n  INSERT INTO abc VALUES ( rnddoc() );\n  INSERT INTO abc VALUES ( rnddoc() );\n  INSERT INTO abc VALUES ( rnddoc() );\n\n  INSERT INTO abc SELECT rnddoc() FROM abc;\n  INSERT INTO abc SELECT rnddoc() FROM abc;\n}\n\n\n\ndo_execsql_test 3.2 {\n  SELECT rowid FROM abc WHERE abc \n  MATCH 'IteratorpItercurrentlypointstothefirstrowidofadoclist' \n  ORDER BY rowid DESC;\n} {16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\n\ndo_execsql_test 3.3 {\n  INSERT INTO abc(abc) VALUES('integrity-check');\n  INSERT INTO abc(abc) VALUES('optimize');\n  INSERT INTO abc(abc) VALUES('integrity-check');\n}\n\nset v [lindex $vocab 0]\nset i 0\nforeach v $vocab {\n  do_execsql_test 3.4.[incr i] {\n    SELECT rowid FROM abc WHERE abc MATCH $v\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}\n}\n\n} ;# foreach_detail_mode\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5doclist.test",
    "content": "# 2015 April 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test is focused on edge cases in the doclist format.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5doclist\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------------\n# Create a table with 1000 columns. Then add some large documents to it.\n# All text is in the right most column of the table.\n#\ndo_test 1.0 {\n  set cols [list]\n  for {set i 0} {$i < 900} {incr i} { lappend cols \"x$i\" }\n  execsql \"CREATE VIRTUAL TABLE ccc USING fts5([join $cols ,])\"\n} {}\n\ndb func rnddoc fts5_rnddoc \ndo_execsql_test 1.1 {\n  WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<100)\n  INSERT INTO ccc(x899) SELECT rnddoc(500) FROM ii;\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO ccc(ccc) VALUES('integrity-check');\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5ea.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Test the fts5 expression parser directly using the fts5_expr() SQL\n# test function.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5ea\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc do_syntax_error_test {tn expr err} {\n  set ::se_expr $expr\n  do_catchsql_test $tn {SELECT fts5_expr($se_expr)} [list 1 $err]\n}\n\nproc do_syntax_test {tn expr res} {\n  set ::se_expr $expr\n  do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res]\n}\n\nforeach {tn expr res} {\n  1  {abc}                           {\"abc\"}\n  2  {abc def}                       {\"abc\" AND \"def\"}\n  3  {abc*}                          {\"abc\" *}\n  4  {\"abc def ghi\" *}               {\"abc\" + \"def\" + \"ghi\" *}\n  5  {one AND two}                   {\"one\" AND \"two\"}\n  6  {one+two}                       {\"one\" + \"two\"}\n  7  {one AND two OR three}          {(\"one\" AND \"two\") OR \"three\"}\n  8  {one OR two AND three}          {\"one\" OR (\"two\" AND \"three\")}\n  9  {NEAR(one two)}                 {NEAR(\"one\" \"two\", 10)}\n  10 {NEAR(\"one three\"* two, 5)}     {NEAR(\"one\" + \"three\" * \"two\", 5)}\n  11 {a OR b NOT c}                  {\"a\" OR (\"b\" NOT \"c\")}\n  12 \"\\x20one\\x20two\\x20three\"       {\"one\" AND \"two\" AND \"three\"}\n  13 \"\\x09one\\x0Atwo\\x0Dthree\"       {\"one\" AND \"two\" AND \"three\"}\n  14 {\"abc\"\"def\"}                    {\"abc\" + \"def\"}\n} {\n  do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res]\n}\n\nforeach {tn expr res} {\n  1 {c1:abc}                           \n    {c1 : \"abc\"}\n  2 {c2 : NEAR(one two) c1:\"hello world\"} \n    {c2 : NEAR(\"one\" \"two\", 10) AND c1 : \"hello\" + \"world\"}\n} {\n  do_execsql_test 2.$tn {SELECT fts5_expr($expr, 'c1', 'c2')} [list $res]\n}\n\nforeach {tn expr err} {\n  1 {AND}                          {fts5: syntax error near \"AND\"}\n  2 {abc def AND}                  {fts5: syntax error near \"\"}\n  3 {abc OR AND}                   {fts5: syntax error near \"AND\"}\n  4 {(a OR b) abc}                 {fts5: syntax error near \"abc\"}\n  5 {NEaR (a b)}                   {fts5: syntax error near \"NEaR\"}\n  6 {NEa (a b)}                    {fts5: syntax error near \"NEa\"}\n  7 {(a OR b) NOT c)}              {fts5: syntax error near \")\"}\n  8 {nosuch: a nosuch2: b}         {no such column: nosuch}\n  9 {addr: a nosuch2: b}           {no such column: nosuch2}\n  10 {NOT}                          {fts5: syntax error near \"NOT\"}\n  11 {a AND \"abc}                  {unterminated string}\n\n  12 {NEAR(a b, xyz)}              {expected integer, got \"xyz\"}\n  13 {NEAR(a b, // )}              {fts5: syntax error near \"/\"}\n  14 {NEAR(a b, \"xyz\" )}           {expected integer, got \"\"xyz\"\"}\n} {\n  do_catchsql_test 3.$tn {SELECT fts5_expr($expr, 'name', 'addr')} [list 1 $err]\n}\n\n#-------------------------------------------------------------------------\n# Experiment with a tokenizer that considers \" to be a token character.\n#\ndo_execsql_test 4.0 {\n  SELECT fts5_expr('a AND \"\"\"\"', 'x', 'tokenize=\"unicode61 tokenchars ''\"\"''\"');\n} {{\"a\" AND \"\"\"\"}}\n\n#-------------------------------------------------------------------------\n# Experiment with a tokenizer that considers \" to be a token character.\n#\ndo_catchsql_test 5.0 {\n  SELECT fts5_expr('abc | def');\n} {1 {fts5: syntax error near \"|\"}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5eb.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5eb\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc do_syntax_error_test {tn expr err} {\n  set ::se_expr $expr\n  do_catchsql_test $tn {SELECT fts5_expr($se_expr)} [list 1 $err]\n}\n\nproc do_syntax_test {tn expr res} {\n  set ::se_expr $expr\n  do_execsql_test $tn {SELECT fts5_expr($se_expr)} [list $res]\n}\n\nforeach {tn expr res} {\n  1  {abc}                            {\"abc\"}\n  2  {abc \"\"}                         {\"abc\"}\n  3  {\"\"}                             {}\n  4  {abc OR \"\"}                      {\"abc\" OR \"\"}\n  5  {abc NOT \"\"}                     {\"abc\" NOT \"\"}\n  6  {abc AND \"\"}                     {\"abc\" AND \"\"}\n  7  {\"\" OR abc}                      {\"\" OR \"abc\"}\n  8  {\"\" NOT abc}                     {\"\" NOT \"abc\"}\n  9  {\"\" AND abc}                     {\"\" AND \"abc\"}\n  10 {abc + \"\" + def}                 {\"abc\" + \"def\"}\n  11 {abc \"\" def}                     {\"abc\" AND \"def\"}\n  12 {r+e OR w}                       {\"r\" + \"e\" OR \"w\"}\n\n  13 {a AND b NOT c}                  {\"a\" AND (\"b\" NOT \"c\")}\n  14 {a OR b NOT c}                   {\"a\" OR (\"b\" NOT \"c\")}\n  15 {a NOT b AND c}                  {(\"a\" NOT \"b\") AND \"c\"}\n  16 {a NOT b OR c}                   {(\"a\" NOT \"b\") OR \"c\"}\n\n  17 {a AND b OR c}                   {(\"a\" AND \"b\") OR \"c\"}\n  18 {a OR b AND c}                   {\"a\" OR (\"b\" AND \"c\")}\n\n} {\n  do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res]\n}\n\ndo_catchsql_test 2.1 {\n  SELECT fts5_expr()\n} {1 {wrong number of arguments to function fts5_expr}}\n\ndo_catchsql_test 2.1 {\n  SELECT fts5_expr_tcl()\n} {1 {wrong number of arguments to function fts5_expr_tcl}}\n\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE e1 USING fts5(text, tokenize = 'porter unicode61');\n  INSERT INTO e1 VALUES (\"just a few words with a / inside\");\n}\ndo_execsql_test 3.1 {\n  SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '\"just\"' ORDER BY rank;\n} {1 -1e-06}\ndo_execsql_test 3.2 {\n  SELECT rowid FROM e1 WHERE e1 MATCH '\"/\" OR \"just\"'\n} 1\ndo_execsql_test 3.3 {\n  SELECT rowid, bm25(e1) FROM e1 WHERE e1 MATCH '\"/\" OR \"just\"' ORDER BY rank;\n} {1 -1e-06}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault1.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault1\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n# Simple tests:\n#\n#   1: CREATE VIRTUAL TABLE\n#   2: INSERT statement\n#   3: DELETE statement\n#   4: MATCH expressions\n#\n#\n\nfaultsim_save_and_close\ndo_faultsim_test 1 -faults ioerr-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix='1, 2, 3') }\n} -test {\n  faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}\n}\n\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix='1, 2, 3');\n}\nfaultsim_save_and_close\ndo_faultsim_test 2 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    INSERT INTO t1 VALUES('a b c', 'a bc def ghij klmno');\n  }\n} -test {\n  faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}\n}\n\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, prefix='1, 2, 3');\n  INSERT INTO t1 VALUES('a b c', 'a bc def ghij klmno');\n}\nfaultsim_save_and_close\ndo_faultsim_test 3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { DELETE FROM t1 }\n} -test {\n  faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}\n}\n\nreset_db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b);\n  INSERT INTO t2 VALUES('m f a jj th q gi ar',   'hj n h h sg j i m');\n  INSERT INTO t2 VALUES('nr s t g od j kf h',    'sb h aq rg op rb n nl');\n  INSERT INTO t2 VALUES('do h h pb p p q fr',    'c rj qs or cr a l i');\n  INSERT INTO t2 VALUES('lk gp t i lq mq qm p',  'h mr g f op ld aj h');\n  INSERT INTO t2 VALUES('ct d sq kc qi k f j',   'sn gh c of g s qt q');\n  INSERT INTO t2 VALUES('d ea d d om mp s ab',   'dm hg l df cm ft pa c');\n  INSERT INTO t2 VALUES('tc dk c jn n t sr ge',  'a a kn bc n i af h');\n  INSERT INTO t2 VALUES('ie ii d i b sa qo rf',  'a h m aq i b m fn');\n  INSERT INTO t2 VALUES('gs r fo a er m h li',   'tm c p gl eb ml q r');\n  INSERT INTO t2 VALUES('k fe fd rd a gi ho kk', 'ng m c r d ml rm r');\n}\nfaultsim_save_and_close\n\nforeach {tn expr res} {\n  1 { dk  }           7\n  2 { m f }           1\n  3 { f*  }           {1 3 4 5 6 8 9 10}\n  4 { m OR f }        {1 4 5 8 9 10}\n  5 { sn + gh }       {5}\n  6 { \"sn gh\" }       {5}\n  7 { NEAR(r a, 5) }  {9}\n  8 { m* f* }         {1 4 6 8 9 10}\n  9 { m* + f* }       {1 8}\n  10 { c NOT p }       {5 6 7 10}\n} {\n  do_faultsim_test 4.$tn -prep {\n    faultsim_restore_and_reopen\n  } -body \"\n    execsql { SELECT rowid FROM t2 WHERE t2 MATCH '$expr' }\n  \" -test \"\n    faultsim_test_result {[list 0 $res]} {1 {vtable constructor failed: t2}}\n  \"\n}\n\n\n#-------------------------------------------------------------------------\n# The following tests use a larger database populated with random data.\n#\n# The database page size is set to 512 bytes and the FTS5 page size left\n# at the default 1000 bytes. This means that reading a node may require\n# pulling an overflow page from disk, which is an extra opportunity for\n# an error to occur.\n#\nreset_db\ndo_execsql_test 5.0.1 { \n  PRAGMA main.page_size = 512;\n  CREATE VIRTUAL TABLE x1 USING fts5(a, b);\n  PRAGMA main.page_size;\n} {512}\n\nproc rnddoc {n} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc [string map $map [format %.3d [expr int(rand()*1000)]]]\n  }\n  set doc\n}\ndb func rnddoc rnddoc\n\ndo_execsql_test 5.0.2 {\n  WITH r(a, b) AS (\n    SELECT rnddoc(6), rnddoc(6) UNION ALL\n    SELECT rnddoc(6), rnddoc(6) FROM r\n  )\n  INSERT INTO x1 SELECT * FROM r LIMIT 10000;\n}\n\nset res [db one {\n  SELECT count(*) FROM x1 WHERE x1.a LIKE '%abc%' OR x1.b LIKE '%abc%'}\n]\n\ndo_faultsim_test 5.1 -faults oom* -body {\n  execsql { SELECT count(*) FROM x1 WHERE x1 MATCH 'abc' }\n} -test {\n  faultsim_test_result [list 0 $::res]\n}\ndo_faultsim_test 5.2 -faults oom* -body {\n  execsql { SELECT count(*) FROM x1 WHERE x1 MATCH 'abcd' }\n} -test {\n  faultsim_test_result [list 0 0]\n}\n\nproc test_astar {a b} {\n  return [expr { [regexp {a[^ ][^ ]} $a] || [regexp {a[^ ][^ ]} $b] }]\n}\ndb func test_astar test_astar\n\nset res [db one { SELECT count(*) FROM x1 WHERE test_astar(a, b) } ]\ndo_faultsim_test 5.3 -faults oom* -body {\n  execsql { SELECT count(*) FROM x1 WHERE x1 MATCH 'a*' }\n} -test {\n  faultsim_test_result [list 0 $::res]\n}\n\ndo_faultsim_test 5.4 -faults oom* -prep {\n  db close\n  sqlite3 db test.db\n} -body {\n  execsql { INSERT INTO x1 VALUES('a b c d', 'e f g h') }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\ndo_faultsim_test 5.5.1 -faults oom* -body {\n  execsql { \n    SELECT count(fts5_decode(rowid, block)) FROM x1_data WHERE rowid=1\n  }\n} -test {\n  faultsim_test_result [list 0 1]\n}\ndo_faultsim_test 5.5.2 -faults oom* -body {\n  execsql { \n    SELECT count(fts5_decode(rowid, block)) FROM x1_data WHERE rowid=10\n  }\n} -test {\n  faultsim_test_result [list 0 1]\n}\ndo_faultsim_test 5.5.3 -faults oom* -body {\n  execsql { \n    SELECT count(fts5_decode(rowid, block)) FROM x1_data WHERE rowid = (\n      SELECT min(rowid) FROM x1_data WHERE rowid>20\n    )\n  }\n} -test {\n  faultsim_test_result [list 0 1]\n}\ndo_faultsim_test 5.5.4 -faults oom* -body {\n  execsql { \n    SELECT count(fts5_decode(rowid, block)) FROM x1_data WHERE rowid = (\n      SELECT max(rowid) FROM x1_data \n    )\n  }\n} -test {\n  faultsim_test_result [list 0 1]\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('automerge', 0);\n\n  INSERT INTO x1 VALUES('a b c'); -- 1\n  INSERT INTO x1 VALUES('a b c'); -- 2\n  INSERT INTO x1 VALUES('a b c'); -- 3\n  INSERT INTO x1 VALUES('a b c'); -- 4\n  INSERT INTO x1 VALUES('a b c'); -- 5\n  INSERT INTO x1 VALUES('a b c'); -- 6\n  INSERT INTO x1 VALUES('a b c'); -- 7\n  INSERT INTO x1 VALUES('a b c'); -- 8\n  INSERT INTO x1 VALUES('a b c'); -- 9\n  INSERT INTO x1 VALUES('a b c'); -- 10\n  INSERT INTO x1 VALUES('a b c'); -- 11\n  INSERT INTO x1 VALUES('a b c'); -- 12\n  INSERT INTO x1 VALUES('a b c'); -- 13\n  INSERT INTO x1 VALUES('a b c'); -- 14\n  INSERT INTO x1 VALUES('a b c'); -- 15\n\n  SELECT count(*) FROM x1_data;\n} {17}\n\nfaultsim_save_and_close\n\ndo_faultsim_test 6.1 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO x1 VALUES('d e f') }\n} -test {\n  faultsim_test_result [list 0 {}]\n  if {$testrc==0} {\n    set nCnt [db one {SELECT count(*) FROM x1_data}]\n    if {$nCnt!=3} { error \"expected 3 entries but there are $nCnt\" }\n  }\n}\n\ndo_faultsim_test 6.2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO x1(x1, rank) VALUES('pgsz', 32) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\ndo_faultsim_test 6.3 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO x1(x1) VALUES('integrity-check') }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\ndo_faultsim_test 6.4 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO x1(x1) VALUES('optimize') }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n#-------------------------------------------------------------------------\n#\ndo_faultsim_test 7.0 -faults oom* -prep {\n  catch { db close }\n} -body {\n  sqlite3 db test.db\n} -test {\n  faultsim_test_result [list 0 {}] {1 {}} {1 {initialization of fts5 failed: }}\n}\n\n#-------------------------------------------------------------------------\n# A prefix query against a large document set.\n#\nproc rnddoc {n} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc \"x[string map $map [format %.3d [expr int(rand()*1000)]]]\"\n  }\n  set doc\n}\n\nreset_db\ndb func rnddoc rnddoc\n\ndo_test 8.0 {\n  execsql { CREATE VIRTUAL TABLE x1 USING fts5(a) }\n  set ::res [list]\n  for {set i 1} {$i<100} {incr i 1} {\n    execsql { INSERT INTO x1 VALUES( rnddoc(50) ) }\n    lappend ::res $i\n  }\n} {}\n\ndo_faultsim_test 8.1 -faults oom* -prep {\n} -body {\n  execsql { \n    SELECT rowid FROM x1 WHERE x1 MATCH 'x*'\n  }\n} -test {\n  faultsim_test_result [list 0 $::res]\n}\n\n#-------------------------------------------------------------------------\n# Segment promotion.\n#\ndo_test 9.0 {\n  reset_db\n  db func rnddoc fts5_rnddoc\n  execsql {\n    CREATE VIRTUAL TABLE s2 USING fts5(x);\n    INSERT INTO s2(s2, rank) VALUES('pgsz', 32);\n    INSERT INTO s2(s2, rank) VALUES('automerge', 0);\n  }\n\n  for {set i 1} {$i <= 16} {incr i} {\n    execsql { INSERT INTO s2 VALUES(rnddoc(5)) }\n  }\n  fts5_level_segs s2\n} {0 1}\nset insert_doc [db one {SELECT rnddoc(160)}]\nfaultsim_save_and_close\n\ndo_faultsim_test 9.1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO s2 VALUES($::insert_doc) }\n} -test {\n  faultsim_test_result {0 {}}\n  if {$testrc==0} {\n    set ls [fts5_level_segs s2]\n    if {$ls != \"2 0\"} { error \"fts5_level_segs says {$ls}\" }\n  }\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault2.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault2\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nset doc [string trim [string repeat \"x y z \" 200]]\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, x);\n  CREATE VIRTUAL TABLE x1 USING fts5(x, content='t1', content_rowid='a');\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n  WITH input(a,b) AS (\n    SELECT 1, $doc UNION ALL\n    SELECT a+1, ($doc || CASE WHEN (a+1)%100 THEN '' ELSE ' xyz' END) \n    FROM input WHERE a < 1000\n  )\n  INSERT INTO t1 SELECT * FROM input;\n\n  INSERT INTO x1(x1) VALUES('rebuild');\n}\n\ndo_faultsim_test 1.1 -faults oom-* -prep {\n} -body {\n  execsql { SELECT rowid FROM x1 WHERE x1 MATCH 'z AND xyz' }\n} -test {\n  faultsim_test_result {0 {100 200 300 400 500 600 700 800 900 1000}}\n}\n\ndo_faultsim_test 1.2 -faults oom-* -prep {\n} -body {\n  execsql { SELECT rowid FROM x1 WHERE x1 MATCH 'z + xyz' ORDER BY 1 DESC}\n} -test {\n  faultsim_test_result {0 {1000 900 800 700 600 500 400 300 200 100}}\n}\n\n#-------------------------------------------------------------------------\n# OOM within a query that accesses the in-memory hash table. \n#\nreset_db \ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE \"a b c\" USING fts5(a, b, c);\n  INSERT INTO \"a b c\" VALUES('one two', 'x x x', 'three four');\n  INSERT INTO \"a b c\" VALUES('nine ten', 'y y y', 'two two');\n}\n\ndo_faultsim_test 2.1 -faults oom-trans* -prep {\n  execsql {\n    BEGIN;\n      INSERT INTO \"a b c\" VALUES('one one', 'z z z', 'nine ten');\n  }\n} -body {\n  execsql { SELECT rowid FROM \"a b c\" WHERE \"a b c\" MATCH 'one' }\n} -test {\n  faultsim_test_result {0 {1 3}}\n  catchsql { ROLLBACK }\n}\n\n#-------------------------------------------------------------------------\n# OOM within an 'optimize' operation that writes multiple pages to disk.\n#\nreset_db \ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE zzz USING fts5(z);\n  INSERT INTO zzz(zzz, rank) VALUES('pgsz', 32);\n  INSERT INTO zzz VALUES('a b c d');\n  INSERT INTO zzz SELECT 'c d e f' FROM zzz;\n  INSERT INTO zzz SELECT 'e f g h' FROM zzz;\n  INSERT INTO zzz SELECT 'i j k l' FROM zzz;\n  INSERT INTO zzz SELECT 'l k m n' FROM zzz;\n  INSERT INTO zzz SELECT 'o p q r' FROM zzz;\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 3.1 -faults oom-trans* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT rowid FROM zzz }\n} -body {\n  execsql { INSERT INTO zzz(zzz) VALUES('optimize') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# OOM within an 'integrity-check' operation.\n#\nreset_db \ndb func rnddoc fts5_rnddoc\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE zzz USING fts5(z);\n  INSERT INTO zzz(zzz, rank) VALUES('pgsz', 32);\n  WITH ii(i) AS (SELECT 1 UNION SELECT i+1 FROM ii WHERE i<10)\n  INSERT INTO zzz SELECT rnddoc(10) || ' xccc' FROM ii;\n}\n\ndo_faultsim_test 4.1 -faults oom-trans* -prep {\n} -body {\n  execsql { INSERT INTO zzz(zzz) VALUES('integrity-check') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# OOM while parsing a tokenize=option\n#\nreset_db\nfaultsim_save_and_close\ndo_faultsim_test 5.0 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    CREATE VIRTUAL TABLE uio USING fts5(a, b, \n      tokenize=\"porter 'ascii'\",\n      content=\"another table\",\n      content_rowid=\"somecolumn\"\n    );\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault3.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault3\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# An OOM while resuming a partially completed segment merge.\n#\ndb func rnddoc fts5_rnddoc \ndo_test 1.0 {\n  expr srand(0)\n  execsql {\n    CREATE VIRTUAL TABLE xx USING fts5(x);\n    INSERT INTO xx(xx, rank) VALUES('pgsz', 32);\n    INSERT INTO xx(xx, rank) VALUES('automerge', 16);\n  }\n  for {set i 0} {$i < 10} {incr i} {\n    execsql {\n      BEGIN;\n        INSERT INTO xx(x) VALUES(rnddoc(20));\n        INSERT INTO xx(x) VALUES(rnddoc(20));\n        INSERT INTO xx(x) VALUES(rnddoc(20));\n      COMMIT\n    }\n  }\n\n  execsql {\n    INSERT INTO xx(xx, rank) VALUES('automerge', 2);\n    INSERT INTO xx(xx, rank) VALUES('merge', 50);\n  }\n} {}\nfaultsim_save_and_close\n\ndo_faultsim_test 1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO xx(xx, rank) VALUES('merge', 1) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n#-------------------------------------------------------------------------\n# An OOM while flushing an unusually large term to disk.\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE xx USING fts5(x);\n  INSERT INTO xx(xx, rank) VALUES('pgsz', 32);\n}\nfaultsim_save_and_close\n\nset    doc \"a long term abcdefghijklmnopqrstuvwxyz \"\nappend doc \"and then abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz \"\nappend doc [string repeat \"abcdefghijklmnopqrstuvwxyz\" 10]\n\ndo_faultsim_test 2 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO xx(x) VALUES ($::doc) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n#-------------------------------------------------------------------------\n# An OOM while flushing an unusually large term to disk.\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE xx USING fts5(x);\n}\nfaultsim_save_and_close\n\nset doc [fts5_rnddoc 1000]\ndo_faultsim_test 3.1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO xx(x) VALUES ($::doc) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\nset doc [string repeat \"abc \" 100]\ndo_faultsim_test 3.2 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO xx(x) VALUES ($::doc) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault4.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault4\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# An OOM while dropping an fts5 table.\n#\ndb func rnddoc fts5_rnddoc \ndo_test 1.0 {\n  execsql { CREATE VIRTUAL TABLE xx USING fts5(x) }\n} {}\nfaultsim_save_and_close\n\ndo_faultsim_test 1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM xx }\n} -body {\n  execsql { DROP TABLE xx }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n#-------------------------------------------------------------------------\n# An OOM while \"reseeking\" an FTS cursor.\n#\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE jj USING fts5(j);\n  INSERT INTO jj(rowid, j) VALUES(101, 'm t w t f s s');\n  INSERT INTO jj(rowid, j) VALUES(202, 't w t f s');\n  INSERT INTO jj(rowid, j) VALUES(303, 'w t f');\n  INSERT INTO jj(rowid, j) VALUES(404, 't');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 3 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM jj }\n} -body {\n  set res [list]\n  db eval { SELECT rowid FROM jj WHERE jj MATCH 't' } {\n    lappend res $rowid\n    if {$rowid==303} {\n      execsql { DELETE FROM jj WHERE rowid=404 }\n    }\n  }\n  set res\n} -test {\n  faultsim_test_result [list 0 {101 202 303}]\n}\n\n#-------------------------------------------------------------------------\n# An OOM within a special \"*reads\" query.\n#\nreset_db\ndb func rnddoc fts5_rnddoc\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n\n  WITH ii(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10 )\n  INSERT INTO x1 SELECT rnddoc(5) FROM ii;\n}\n\nset ::res [db eval {SELECT rowid, x1 FROM x1 WHERE x1 MATCH '*reads'}]\n\ndo_faultsim_test 4 -faults oom-* -body {\n  db eval {SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads'}\n} -test {\n  faultsim_test_result {0 {0 {} 3}}\n}\n\n#-------------------------------------------------------------------------\n# An OOM within a query that uses a custom rank function.\n#\nreset_db\ndo_execsql_test 5.0 {\n  PRAGMA encoding='utf16';\n  CREATE VIRTUAL TABLE x2 USING fts5(x);\n  INSERT INTO x2(rowid, x) VALUES(10, 'a b c'); -- 3\n  INSERT INTO x2(rowid, x) VALUES(20, 'a b c'); -- 6\n  INSERT INTO x2(rowid, x) VALUES(30, 'a b c'); -- 2\n  INSERT INTO x2(rowid, x) VALUES(40, 'a b c'); -- 5\n  INSERT INTO x2(rowid, x) VALUES(50, 'a b c'); -- 1\n}\n\nproc rowidmod {cmd mod} { \n  set row [$cmd xRowid]\n  expr {$row % $mod}\n}\nsqlite3_fts5_create_function db rowidmod rowidmod\n\ndo_faultsim_test 5.1 -faults oom-* -body {\n  db eval {\n    SELECT rowid || '-' || rank FROM x2 WHERE x2 MATCH 'b' AND \n    rank MATCH \"rowidmod('7')\" ORDER BY rank\n  }\n} -test {\n  faultsim_test_result {0 {50-1 30-2 10-3 40-5 20-6}}\n}\n\nproc rowidprefix {cmd prefix} { \n  set row [$cmd xRowid]\n  set {} \"${row}-${prefix}\"\n}\nsqlite3_fts5_create_function db rowidprefix rowidprefix\n\nset str [string repeat abcdefghijklmnopqrstuvwxyz 10]\ndo_faultsim_test 5.2 -faults oom-* -body {\n  db eval \"\n    SELECT rank, x FROM x2 WHERE x2 MATCH 'b' AND \n    rank MATCH 'rowidprefix(''$::str'')'\n    LIMIT 1\n  \"\n} -test {\n  faultsim_test_result \"0 {10-$::str {a b c}}\"\n}\n\n\n#-------------------------------------------------------------------------\n# OOM errors within auxiliary functions.\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE x3 USING fts5(xxx);\n  INSERT INTO x3 VALUES('a b c d c b a');\n  INSERT INTO x3 VALUES('a a a a a a a');\n  INSERT INTO x3 VALUES('a a a a a a a');\n}\n\ndo_faultsim_test 6.1 -faults oom-t* -body {\n  db eval { SELECT highlight(x3, 0, '*', '*') FROM x3 WHERE x3 MATCH 'c' }\n} -test {\n  faultsim_test_result {0 {{a b *c* d *c* b a}}}\n}\n\nproc firstinst {cmd} { \n  foreach {p c o} [$cmd xInst 0] {}\n  expr $c*100 + $o\n}\nsqlite3_fts5_create_function db firstinst firstinst\n\ndo_faultsim_test 6.2 -faults oom-t* -body {\n  db eval { SELECT firstinst(x3) FROM x3 WHERE x3 MATCH 'c' }\n} -test {\n  faultsim_test_result {0 2} {1 SQLITE_NOMEM}\n}\n\nproc previc {cmd} {\n  set res [$cmd xGetAuxdataInt 0]\n  $cmd xSetAuxdataInt [$cmd xInstCount]\n  return $res\n}\nsqlite3_fts5_create_function db previc  previc\n\ndo_faultsim_test 6.2 -faults oom-t* -body {\n  db eval { SELECT previc(x3) FROM x3 WHERE x3 MATCH 'a' }\n} -test {\n  faultsim_test_result {0 {0 2 7}} {1 SQLITE_NOMEM}\n}\n\n#-------------------------------------------------------------------------\n# OOM error when querying for a phrase with many tokens.\n#\nreset_db\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(x, y);\n  INSERT INTO tt VALUES('f b g b c b', 'f a d c c b');  -- 1\n  INSERT INTO tt VALUES('d a e f e d', 'f b b d e e');  -- 2\n  INSERT INTO tt VALUES('f b g a d c', 'e f c f a d');  -- 3\n  INSERT INTO tt VALUES('f f c d g f', 'f a e b g b');  -- 4\n  INSERT INTO tt VALUES('a g b d a g', 'e g a e a c');  -- 5\n  INSERT INTO tt VALUES('c d b d e f', 'f g e g e e');  -- 6\n  INSERT INTO tt VALUES('e g f f b c', 'f c e f g f');  -- 7\n  INSERT INTO tt VALUES('e g c f c e', 'f e e a f g');  -- 8\n  INSERT INTO tt VALUES('e a e b e e', 'd c c f f f');  -- 9\n  INSERT INTO tt VALUES('f a g g c c', 'e g d g c e');  -- 10\n  INSERT INTO tt VALUES('c d b a e f', 'f g e h e e');  -- 11\n\n  CREATE VIRTUAL TABLE tt2 USING fts5(o);\n  INSERT INTO tt2(rowid, o) SELECT rowid, x||' '||y FROM tt;\n  INSERT INTO tt2(rowid, o) VALUES(12, 'a b c d e f g h i j k l');\n}\n\ndo_faultsim_test 7.2 -faults oom-* -body {\n  db eval { SELECT rowid FROM tt WHERE tt MATCH 'f+g+e+g+e+e' }\n} -test {\n  faultsim_test_result {0 6} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 7.3 -faults oom-* -body {\n  db eval { SELECT rowid FROM tt WHERE tt MATCH 'NEAR(a b c d e f)' }\n} -test {\n  faultsim_test_result {0 11} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 7.4 -faults oom-t* -body {\n  db eval { SELECT rowid FROM tt2 WHERE tt2 MATCH '\"g c f c e f e e a f\"' }\n} -test {\n  faultsim_test_result {0 8} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 7.5 -faults oom-* -body {\n  db eval {SELECT rowid FROM tt2 WHERE tt2 MATCH 'NEAR(a b c d e f g h i j k)'}\n} -test {\n  faultsim_test_result {0 12} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 7.6 -faults oom-* -body {\n  db eval {SELECT rowid FROM tt WHERE tt MATCH 'y: \"c c\"'}\n} -test {\n  faultsim_test_result {0 {1 9}} {1 SQLITE_NOMEM}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(x);\n  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n  BEGIN;\n    INSERT INTO tt(rowid, x) VALUES(1, 'a b c d x x');\n    WITH ii(i) AS (SELECT 2 UNION ALL SELECT i+1 FROM ii WHERE i<99)\n      INSERT INTO tt(rowid, x) SELECT i, 'a b c x x d' FROM ii;\n    INSERT INTO tt(rowid, x) VALUES(100, 'a b c d x x');\n  COMMIT;\n}\n\ndo_faultsim_test 8.1 -faults oom-t* -body {\n  db eval { SELECT rowid FROM tt WHERE tt MATCH 'NEAR(a b c d, 2)' }\n} -test {\n  faultsim_test_result {0 {1 100}} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 8.2 -faults oom-t* -body {\n  db eval { SELECT count(*) FROM tt WHERE tt MATCH 'a OR d' }\n} -test {\n  faultsim_test_result {0 100} {1 SQLITE_NOMEM}\n}\n\n\n#-------------------------------------------------------------------------\n# Fault in NOT query.\n#\nreset_db\ndo_execsql_test 9.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(x);\n  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n  BEGIN;\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<200)\n      INSERT INTO tt(rowid, x) \n      SELECT i, CASE WHEN (i%50)==0 THEN 'a a a a a a' ELSE 'a x a x a x' END \n      FROM ii;\n  COMMIT;\n}\n\ndo_faultsim_test 9.1 -faults oom-* -body {\n  db eval { SELECT rowid FROM tt WHERE tt MATCH 'a NOT x' }\n} -test {\n  faultsim_test_result {0 {50 100 150 200}} {1 SQLITE_NOMEM}\n}\n\n#-------------------------------------------------------------------------\n# OOM in fts5_expr() SQL function.\n#\ndo_faultsim_test 10.1 -faults oom-t* -body {\n  db one { SELECT fts5_expr('a AND b NEAR(a b)') }\n} -test {\n  faultsim_test_result {0 {\"a\" AND \"b\" AND NEAR(\"a\" \"b\", 10)}} \n}\n\ndo_faultsim_test 10.2 -faults oom-t* -body {\n  db one { SELECT fts5_expr_tcl('x:\"a b c\" AND b NEAR(a b)', 'ns', 'x') }\n} -test {\n  set res {AND [ns -col 0 -- {a b c}] [ns -- {b}] [ns -near 10 -- {a} {b}]}\n  faultsim_test_result [list 0 $res]\n}\n\ndo_faultsim_test 10.3 -faults oom-t* -body {\n  db one { SELECT fts5_expr('x:a', 'x') }\n} -test {\n  faultsim_test_result {0 {x : \"a\"}}\n}\n\n#-------------------------------------------------------------------------\n# OOM while configuring 'rank' option.\n#\nreset_db\ndo_execsql_test 11.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x);\n}\ndo_faultsim_test 11.1 -faults oom-t* -body {\n  db eval { INSERT INTO ft(ft, rank) VALUES('rank', 'bm25(10.0, 5.0)') }\n} -test {\n  faultsim_test_result {0 {}} {1 {disk I/O error}}\n}\n\n#-------------------------------------------------------------------------\n# OOM while creating an fts5vocab table.\n#\nreset_db\ndo_execsql_test 12.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x);\n}\nfaultsim_save_and_close\ndo_faultsim_test 12.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM sqlite_master }\n} -body {\n  db eval { CREATE VIRTUAL TABLE vv USING fts5vocab(ft, 'row') }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\n#-------------------------------------------------------------------------\n# OOM while querying an fts5vocab table.\n#\nreset_db\ndo_execsql_test 13.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x);\n  INSERT INTO ft VALUES('a b');\n  CREATE VIRTUAL TABLE vv USING fts5vocab(ft, 'row');\n}\nfaultsim_save_and_close\ndo_faultsim_test 13.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM vv }\n} -body {\n  db eval { SELECT * FROM vv }\n} -test {\n  faultsim_test_result {0 {a 1 1 b 1 1}} \n}\n\n#-------------------------------------------------------------------------\n# OOM in multi-column token query.\n#\nreset_db\ndo_execsql_test 13.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x, y, z);\n  INSERT INTO ft(ft, rank) VALUES('pgsz', 32);\n  INSERT INTO ft VALUES(\n      'x x x x x x x x x x x x x x x x',\n      'y y y y y y y y y y y y y y y y',\n      'z z z z z z z z x x x x x x x x'\n  );\n  INSERT INTO ft SELECT * FROM ft;\n  INSERT INTO ft SELECT * FROM ft;\n  INSERT INTO ft SELECT * FROM ft;\n  INSERT INTO ft SELECT * FROM ft;\n}\nfaultsim_save_and_close\ndo_faultsim_test 13.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM ft }\n} -body {\n  db eval { SELECT rowid FROM ft WHERE ft MATCH '{x z}: x' }\n} -test {\n  faultsim_test_result {0 {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}}\n}\n\n#-------------------------------------------------------------------------\n# OOM in an \"ALTER TABLE RENAME TO\"\n#\nreset_db\ndo_execsql_test 14.0 {\n  CREATE VIRTUAL TABLE \"tbl one\" USING fts5(x, y, z);\n}\nfaultsim_save_and_close\ndo_faultsim_test 14.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM \"tbl one\" }\n} -body {\n  db eval { ALTER TABLE \"tbl one\" RENAME TO \"tbl two\" }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault5.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault5\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# OOM while creating an FTS5 table.\n#\ndo_faultsim_test 1.1 -faults oom-t* -prep {\n  db eval { DROP TABLE IF EXISTS abc }\n} -body {\n  db eval { CREATE VIRTUAL TABLE abc USING fts5(x,y) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n\n#-------------------------------------------------------------------------\n# OOM while writing a multi-tier doclist-index. And while running\n# integrity-check on the same.\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(x);\n  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 2.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM tt }\n} -body {\n  set str [string repeat \"abc \" 50]\n  db eval {\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)\n      INSERT INTO tt(rowid, x) SELECT i, $str FROM ii;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 2.2 -faults oom-t* -body {\n  db eval { INSERT INTO tt(tt) VALUES('integrity-check') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# OOM while scanning fts5vocab tables.\n#\nreset_db\ndo_test 3.0 {\n  execsql {\n    CREATE VIRTUAL TABLE tt USING fts5(x);\n    CREATE VIRTUAL TABLE tv USING fts5vocab(tt, 'row');\n\n    CREATE VIRTUAL TABLE tt2 USING fts5(x, detail=col);\n    CREATE VIRTUAL TABLE tv2 USING fts5vocab(tt2, 'col');\n\n    INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n    INSERT INTO tt2(tt2, rank) VALUES('pgsz', 32);\n    BEGIN;\n  }\n\n  for {set i 0} {$i < 20} {incr i} {\n    set str [string repeat \"$i \" 50]\n    execsql { INSERT INTO tt VALUES($str) }\n    execsql { INSERT INTO tt2 VALUES($str) }\n  }\n  execsql COMMIT\n} {}\n\ndo_faultsim_test 3.1 -faults oom-t* -body {\n  db eval {\n    SELECT term FROM tv;\n  }\n} -test {\n  faultsim_test_result {0 {0 1 10 11 12 13 14 15 16 17 18 19 2 3 4 5 6 7 8 9}}\n}\n\ndo_faultsim_test 3.2 -faults oom-t* -body {\n  db eval {\n    SELECT term FROM tv WHERE term BETWEEN '1' AND '2';\n  }\n} -test {\n  faultsim_test_result {0 {1 10 11 12 13 14 15 16 17 18 19 2}}\n}\n\ndo_execsql_test 3.3.0 {\n  SELECT * FROM tv2;\n} {\n  0 x 1 {} 1 x 1 {} 10 x 1 {} 11 x 1 {} 12 x 1 {} 13 x 1 {}        \n  14 x 1 {} 15 x 1 {} 16 x 1 {} 17 x 1 {} 18 x 1 {} 19  x 1 {}     \n  2 x 1 {} 3 x 1 {} 4 x 1 {} 5 x 1 {} 6 x 1 {} 7 x 1 {} 8 x 1 {}   \n  9 x 1 {}\n}\ndo_faultsim_test 3.3 -faults oom-t* -body {\n  db eval {\n    SELECT * FROM tv2;\n  }\n} -test {\n  faultsim_test_result [list 0 [list                                   \\\n      0 x 1 {} 1 x 1 {} 10 x 1 {} 11 x 1 {} 12 x 1 {} 13 x 1 {}        \\\n      14 x 1 {} 15 x 1 {} 16 x 1 {} 17 x 1 {} 18 x 1 {} 19  x 1 {}     \\\n      2 x 1 {} 3 x 1 {} 4 x 1 {} 5 x 1 {} 6 x 1 {} 7 x 1 {} 8 x 1 {}   \\\n      9 x 1 {}\n  ]]\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault6.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault6\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------------\n# OOM while rebuilding an FTS5 table.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(a, b);\n  INSERT INTO tt VALUES('c d c g g f', 'a a a d g a');\n  INSERT INTO tt VALUES('c d g b f d', 'b g e c g c');\n  INSERT INTO tt VALUES('c c f d e d', 'c e g d b c');\n  INSERT INTO tt VALUES('e a f c e f', 'g b a c d g');\n  INSERT INTO tt VALUES('c g f b b d', 'g c d c f g');\n  INSERT INTO tt VALUES('d a g a b b', 'g c g g c e');\n  INSERT INTO tt VALUES('e f a b c e', 'f d c d c c');\n  INSERT INTO tt VALUES('e c a g c d', 'b b g f f b');\n  INSERT INTO tt VALUES('g b d d e b', 'f f b d a c');\n  INSERT INTO tt VALUES('e a d a e d', 'c e a e f g');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 1.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { INSERT INTO tt(tt) VALUES('rebuild') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 1.2 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { REPLACE INTO tt(rowid, a, b) VALUES(6, 'x y z', 'l l l'); }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n\n#-------------------------------------------------------------------------\n# OOM within a special delete.\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(a, content=\"\");\n  INSERT INTO tt VALUES('c d c g g f');\n  INSERT INTO tt VALUES('c d g b f d');\n  INSERT INTO tt VALUES('c c f d e d');\n  INSERT INTO tt VALUES('e a f c e f');\n  INSERT INTO tt VALUES('c g f b b d');\n  INSERT INTO tt VALUES('d a g a b b');\n  INSERT INTO tt VALUES('e f a b c e');\n  INSERT INTO tt VALUES('e c a g c d');\n  INSERT INTO tt VALUES('g b d d e b');\n  INSERT INTO tt VALUES('e a d a e d');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 2.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { INSERT INTO tt(tt, rowid, a) VALUES('delete', 3, 'c d g b f d'); }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 2.2 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { INSERT INTO tt(tt) VALUES('delete-all') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 2.3 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { INSERT INTO tt VALUES('x y z') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# OOM in the ASCII tokenizer with very large tokens. \n#\n# Also the unicode tokenizer.\n#\nset t1 [string repeat wxyz 20]\nset t2 [string repeat wxyz 200]\nset t3 [string repeat wxyz 2000]\nset doc \"$t1 $t2 $t3\"\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE xyz USING fts5(c, tokenize=ascii, content=\"\");\n  CREATE VIRTUAL TABLE xyz2 USING fts5(c, content=\"\");\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 3.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM xyz }\n} -body {\n  db eval { INSERT INTO xyz VALUES($::doc) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 3.2 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM xyz2 }\n} -body {\n  db eval { INSERT INTO xyz2 VALUES($::doc) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# OOM while initializing a unicode61 tokenizer.\n#\nreset_db\nfaultsim_save_and_close\ndo_faultsim_test 4.1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { \n    CREATE VIRTUAL TABLE yu USING fts5(x, tokenize=\"unicode61 separators abc\");\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n#\n# 5.2.* OOM while running a query that includes synonyms and matchinfo().\n#\n# 5.3.* OOM while running a query that returns a row containing instances\n#       of more than 4 synonyms for a single term.\n#\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\nproc tcl_tokenize {tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n    if {$tflags==\"query\" && [string length $w]==1} {\n      for {set i 2} {$i < 7} {incr i} {\n        sqlite3_fts5_token -colo [string repeat $w $i] $iStart $iEnd\n      }\n    }\n  }\n}\nproc tcl_create {args} { return \"tcl_tokenize\" }\nreset_db\nsqlite3_fts5_create_tokenizer db tcl tcl_create\ndb func mit mit\nsqlite3_fts5_register_matchinfo db\ndo_test 5.0 {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=tcl) }\n  execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 32) }\n  foreach {rowid text} {\n    1 {aaaa cc b aaaaa cc aa} \n    2 {aa aa bb a bbb}\n    3 {bb aaaaa aaaaa b aaaa aaaaa}\n    4 {aa a b aaaa aa}\n    5 {aa b ccc aaaaa cc}\n    6 {aa aaaaa bbbb cc aaa}\n    7 {aaaaa aa aa ccccc bb}\n    8 {ccc bbbbb ccccc bbb c}\n    9 {cccccc bbbb a aaa cccc c}\n\n    20 {ddd f ddd eeeee fff ffff eeee ddd fff eeeee dddddd eeee}\n    21 {fffff eee dddd fffff dd ee ee eeeee eee eeeeee ee dd e}\n    22 {fffff d eeee dddd fffff dddddd ffff ddddd eeeee ee eee dddd ddddd}\n    23 {ddddd fff ddd eeeee ffff eeee ddd ff ff ffffff eeeeee dddd ffffff}\n    24 {eee dd ee dddd dddd eeeeee e eee fff ffff}\n    25 {ddddd ffffff dddddd fff ddd ddddd ddd f eeee fff dddd f}\n    26 {f ffff fff fff eeeeee dddd d dddddd ddddd eee ff eeeee}\n    27 {eee fff dddddd eeeee eeeee dddd ddddd ffff f eeeee eee dddddd ddddd d}\n    28 {dd ddddd d ddd d fff d dddd ee dddd ee ddd dddddd dddddd}\n    29 {eeee dddd ee dddd eeee dddd dd fffff f ddd eeeee ddd ee}\n    30 {ff ffffff eeeeee eeeee eee ffffff ff ffff f fffff eeeee}\n    31 {fffff eeeeee dddd eeee eeee eeeeee eee fffff d ddddd ffffff ffff dddddd}\n    32 {dddddd fffff ee eeeeee eeee ee fff dddd fff eeee ffffff eeeeee ffffff}\n    33 {ddddd eeee dd ffff dddddd fff eeee ddddd ffff eeee ddd}\n    34 {ee dddd ddddd dddddd eeee eeeeee f dd ee dddddd ffffff}\n    35 {ee dddd dd eeeeee ddddd eee d eeeeee dddddd eee dddd fffff}\n    36 {eee ffffff ffffff e fffff eeeee ff dddddd dddddd fff}\n    37 {eeeee fffff dddddd dddd ffffff fff f dd ee dd dd eeeee}\n    38 {eeeeee ee d ff eeeeee eeeeee eee eeeee ee ffffff dddd eeee dddddd ee}\n    39 {eeeeee ddd fffff e dddd ee eee eee ffffff ee f d dddd}\n    40 {ffffff dddddd eee ee ffffff eee eeee ddddd ee eeeeee f}\n    41 {ddd ddd fff fffff ee fffff f fff ddddd fffff}\n    42 {dddd ee ff d f ffffff fff ffffff ff dd dddddd f eeee}\n    43 {d dd fff fffff d f fff e dddd ee ee}\n    44 {ff ffff eee ddd d dd ffff dddd d eeee d eeeeee}\n    45 {eeee f eeeee ee e ffff f ddd e fff}\n    46 {ffff d ffff eeee ffff eeeee f ffff ddddd eee}\n    47 {dd dd dddddd ddddd fffff dddddd ddd ddddd eeeeee ffff eeee eee ee}\n    48 {ffff ffff e dddd ffffff dd dd dddd f fffff}\n    49 {ffffff d dddddd ffff eeeee f ffff ffff d dd fffff eeeee}\n\n    50 {x e}\n  } {\n    execsql { INSERT INTO t1(rowid, a) VALUES($rowid, $text) }\n  }\n} {}\n\nset res [list {*}{\n  1 {3 24 8 2 12 6}\n  5 {2 24 8 2 12 6}\n  6 {3 24 8 1 12 6}\n  7 {3 24 8 1 12 6}\n  9 {2 24 8 3 12 6}\n}]\ndo_execsql_test 5.1.1 {\n  SELECT rowid, mit(matchinfo(t1, 'x')) FROM t1 WHERE t1 MATCH 'a AND c'\n} $res\ndo_execsql_test 5.1.2 {\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'd e f'\n} 29\n\nfaultsim_save_and_close\ndo_faultsim_test 5.2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  sqlite3_fts5_create_tokenizer db tcl tcl_create\n  sqlite3_fts5_register_matchinfo db\n  db func mit mit\n} -body {\n  db eval { \n    SELECT rowid, mit(matchinfo(t1, 'x')) FROM t1 WHERE t1 MATCH 'a AND c'\n  }\n} -test {\n  faultsim_test_result [list 0 $::res]\n}\n\ndo_faultsim_test 5.3 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  sqlite3_fts5_create_tokenizer db tcl tcl_create\n} -body {\n  db eval { \n    SELECT count(*) FROM t1 WHERE t1 MATCH 'd AND e AND f'\n  }\n} -test {\n  faultsim_test_result {0 29}\n}\n\ndo_faultsim_test 5.4 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  sqlite3_fts5_create_tokenizer db tcl tcl_create\n} -body {\n  db eval { \n    SELECT count(*) FROM t1 WHERE t1 MATCH 'x + e'\n  }\n} -test {\n  faultsim_test_result {0 1}\n}\n\n#-------------------------------------------------------------------------\ncatch { db close }\ndo_faultsim_test 6 -faults oom* -prep {\n  sqlite_orig db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n} -test {\n  faultsim_test_result {0 {}} {1 {initialization of fts5 failed: }}\n  if {$testrc==0} {\n    db eval { CREATE VIRTUAL TABLE temp.t1 USING fts5(x) }\n  }\n  db close\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault7.test",
    "content": "# 2015 September 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault7\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nif 1 {\n\n#-------------------------------------------------------------------------\n# Test fault-injection on a query that uses xColumnSize() on columnsize=0\n# table.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=0);\n  INSERT INTO t1 VALUES('a b c d e f g');\n  INSERT INTO t1 VALUES('a b c d');\n  INSERT INTO t1 VALUES('a b c d e f g h i j');\n}\n\n\nfts5_aux_test_functions db\ndo_faultsim_test 1 -faults oom* -body {\n  execsql { SELECT fts5_test_columnsize(t1) FROM t1 WHERE t1 MATCH 'b' }\n} -test {\n  faultsim_test_result {0 {7 4 10}} {1 SQLITE_NOMEM}\n}\n\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection when a segment is promoted.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a);\n  INSERT INTO t2(t2, rank) VALUES('automerge', 0);\n  INSERT INTO t2(t2, rank) VALUES('crisismerge', 4);\n  INSERT INTO t2(t2, rank) VALUES('pgsz', 40);\n\n  INSERT INTO t2 VALUES('a b c');\n  INSERT INTO t2 VALUES('d e f');\n  INSERT INTO t2 VALUES('f e d');\n  INSERT INTO t2 VALUES('c b a');\n\n  INSERT INTO t2 VALUES('a b c');\n  INSERT INTO t2 VALUES('d e f');\n  INSERT INTO t2 VALUES('f e d');\n  INSERT INTO t2 VALUES('c b a');\n} {}\n\nfaultsim_save_and_close\ndo_faultsim_test 1 -faults oom-t* -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n    INSERT INTO t2 VALUES('c d c g g f');\n    INSERT INTO t2 VALUES('c d g b f d');\n    INSERT INTO t2 VALUES('c c f d e d');\n    INSERT INTO t2 VALUES('e a f c e f');\n    INSERT INTO t2 VALUES('c g f b b d');\n    INSERT INTO t2 VALUES('d a g a b b');\n    INSERT INTO t2 VALUES('e f a b c e');\n    INSERT INTO t2 VALUES('e c a g c d');\n    INSERT INTO t2 VALUES('g b d d e b');\n    INSERT INTO t2 VALUES('e a d a e d');\n  }\n} -body {\n  db eval COMMIT\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection when a segment is promoted.\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE xy USING fts5(x);\n  INSERT INTO xy(rowid, x) VALUES(1, '1 2 3');\n  INSERT INTO xy(rowid, x) VALUES(2, '2 3 4');\n  INSERT INTO xy(rowid, x) VALUES(3, '3 4 5');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 2.1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2 }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n# Test fault-injection when an empty expression is parsed.\n#\ndo_faultsim_test 2.2 -faults oom-* -body {\n  db eval { SELECT * FROM xy('\"\"') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault8.test",
    "content": "# 2015 September 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault8\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\n  fts5_aux_test_functions db\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n    INSERT INTO t1 VALUES('a b c d', '1 2 3 4');\n    INSERT INTO t1 VALUES('a b a b', NULL);\n    INSERT INTO t1 VALUES(NULL, '1 2 1 2');\n  }\n  \n  do_faultsim_test 1 -faults oom-* -body {\n    execsql { \n      SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2' \n    }\n  } -test {\n    faultsim_test_result {0 {1 {0.0.1 1.1.1} 2 {0.0.1 0.0.3} 3 {1.1.1 1.1.3}}} \\\n                         {1 SQLITE_NOMEM}\n  }\n  \n  do_faultsim_test 2 -faults oom-* -body {\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n  } -test {\n    faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  }\n\n  if {[detail_is_none]==0} {\n    do_faultsim_test 3 -faults oom-* -body {\n      execsql { SELECT rowid FROM t1('b:2') }\n    } -test {\n      faultsim_test_result {0 {1 3}} {1 SQLITE_NOMEM}\n    }\n  }\n\n} ;# foreach_detail_mode...\n\n\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE x2 USING fts5(a);\n  INSERT INTO x2(x2, rank) VALUES('crisismerge', 2);\n  INSERT INTO x2(x2, rank) VALUES('pgsz', 32);\n  INSERT INTO x2 VALUES('a b c d');\n  INSERT INTO x2 VALUES('e f g h');\n  INSERT INTO x2 VALUES('i j k l');\n  INSERT INTO x2 VALUES('m n o p');\n  INSERT INTO x2 VALUES('q r s t');\n  INSERT INTO x2 VALUES('u v w x');\n  INSERT INTO x2 VALUES('y z a b');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 4 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO x2(x2) VALUES('optimize') }\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fault9.test",
    "content": "# 2015 September 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5fault9\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\nfts5_aux_test_functions db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  WITH seq(s) AS ( SELECT 1 UNION ALL SELECT s+1 FROM seq WHERE s<50)\n  INSERT INTO t1 SELECT 'x x x y y y', 'a b c d e f' FROM seq;\n}\n\ndo_faultsim_test 1 -faults oom-* -body {\n  execsql { SELECT count(*) FROM t1('x AND y') }\n} -test {\n  faultsim_test_result {0 50}\n}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO t2(t2, rank) VALUES('pgsz', 32);\n  INSERT INTO t2 VALUES('abc cba', 'cba abc');\n  INSERT INTO t2 VALUES('abc cba', 'cba abc');\n  INSERT INTO t2 VALUES('abc cba', 'cba abc');\n\n  INSERT INTO t2 VALUES('axy cyx', 'cyx axy');\n  INSERT INTO t2 VALUES('axy cyx', 'cyx axy');\n  INSERT INTO t2 VALUES('axy cyx', 'cyx axy');\n}\n\ndo_faultsim_test 2 -faults oom-* -body {\n  execsql { SELECT count(*) FROM t2('a* AND c*') }\n} -test {\n  faultsim_test_result {0 6}\n}\n\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(a, detail=%DETAIL%);\n  INSERT INTO t3 VALUES('a x x a x a a a');\n  INSERT INTO t3 VALUES('x a a x a x x x');\n}\n\ndo_faultsim_test 3.1 -faults oom-* -body {\n  execsql { SELECT highlight(t3, 0, '[', ']') FROM t3('a') }\n} -test {\n  faultsim_test_result {0 {{[a] x x [a] x [a] [a] [a]} {x [a] [a] x [a] x x x}}}\n}\n\ndo_faultsim_test 3.2 -faults oom-t* -body {\n  execsql { SELECT fts5_test_poslist2(t3) FROM t3('x') }\n} -test {\n  faultsim_test_result \\\n      {0 {{0.0.1 0.0.2 0.0.4} {0.0.0 0.0.3 0.0.5 0.0.6 0.0.7}}} \\\n      {1 SQLITE_NOMEM}\n}\n\n#-------------------------------------------------------------------------\n# Test OOM injection with the xPhraseFirstColumn() API and a tokenizer\n# uses query synonyms.\n#\nfts5_tclnum_register db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t4 USING fts5(x, y, z, detail=%DETAIL%, tokenize=tclnum);\n  INSERT INTO t4 VALUES('one two three', '1 2 3', 'i ii iii');\n  INSERT INTO t4 VALUES('1 2 3', 'i ii iii', 'one two three');\n  INSERT INTO t4 VALUES('i ii iii', 'one two three', 'i ii iii');\n\n  INSERT INTO t4 VALUES('a1 a2 a3', 'a4 a5 a6', 'a7 a8 a9');\n  INSERT INTO t4 VALUES('b1 b2 b3', 'b4 b5 b6', 'b7 b8 b9');\n  INSERT INTO t4 VALUES('c1 c2 c3', 'c4 c5 c6', 'c7 c8 c9');\n}\n\ndo_faultsim_test 4.1 -faults oom-t* -body {\n  execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('2') }\n} -test {\n  faultsim_test_result \\\n      {0 {1 {0.0 0.1 0.2} 2 {0.0 0.1 0.2} 3 {0.0 0.1 0.2}}} {1 SQLITE_NOMEM}\n}\n\ndo_faultsim_test 4.2 -faults oom-t* -body {\n  execsql { SELECT rowid, fts5_test_collist(t4) FROM t4('a5 OR b5 OR c5') }\n} -test {\n  faultsim_test_result \\\n      {0 {4 {0.0 0.1 0.2} 5 {1.0 1.1 1.2} 6 {2.0 2.1 2.2}}} {1 SQLITE_NOMEM}\n}\n\n\n#-------------------------------------------------------------------------\n# An OOM within an \"ORDER BY rank\" query.\n#\ndb func rnddoc fts5_rnddoc \ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO xx VALUES ('def', 'abc ' || rnddoc(10));\n  INSERT INTO xx VALUES ('def', 'abc abc' || rnddoc(9));\n  INSERT INTO xx VALUES ('def', 'abc abc abc' || rnddoc(8));\n} {}\nfaultsim_save_and_close\n\ndo_faultsim_test 5 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM xx }\n} -body {\n  execsql { SELECT rowid FROM xx('abc AND def') ORDER BY rank }\n} -test {\n  faultsim_test_result [list 0 {3 2 1}]\n}\n\nset doc [string repeat \"xyz \" 500]\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE yy USING fts5(y, detail=%DETAIL%);\n  INSERT INTO yy(yy, rank) VALUES('pgsz', 64);\n  INSERT INTO yy VALUES ($doc);\n  INSERT INTO yy VALUES ('1 2 3');\n  INSERT INTO yy VALUES ('xyz');\n  UPDATE yy SET y = y WHERE rowid = 1;\n  UPDATE yy SET y = y WHERE rowid = 1;\n  UPDATE yy SET y = y WHERE rowid = 1;\n  UPDATE yy SET y = y WHERE rowid = 1;\n} {}\n\ndo_faultsim_test 6 -faults oom-* -body {\n  execsql { SELECT rowid FROM yy('xyz') }\n} -test {\n  faultsim_test_result [list 0 {1 3}]\n}\n\n\n} ;# foreach_detail_mode...\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5faultA.test",
    "content": "# 2016 February 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5faultA\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE o1 USING fts5(a, detail=%DETAIL%);\n    INSERT INTO o1(o1, rank) VALUES('pgsz', 32);\n  \n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )\n    INSERT INTO o1 SELECT 'A B C' FROM s;\n  \n    INSERT INTO o1 VALUES('A X C');\n  \n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )\n    INSERT INTO o1 SELECT 'A B C' FROM s;\n  }\n  \n  do_faultsim_test 1 -faults oom* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT rowid FROM o1('a NOT b') }\n  } -test {\n    faultsim_test_result {0 301}\n  }\n}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE o2 USING fts5(a);\n  \n  INSERT INTO o2 VALUES('A B C');\n  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 )\n  INSERT INTO o2 SELECT group_concat('A B C ') FROM s;\n}\n\ndo_faultsim_test 2 -faults oom* -prep {\n  sqlite3 db test.db\n} -body {\n  execsql { SELECT rowid FROM o2('a+b+c NOT xyz') }\n} -test {\n  faultsim_test_result {0 {1 2}}\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5faultB.test",
    "content": "# 2016 February 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5faultB\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\n\n#-------------------------------------------------------------------------\n# Errors while registering the matchinfo() demo function.\n#\ndo_faultsim_test 1 -faults oom* -prep {\n  sqlite3 db test.db\n} -body {\n  sqlite3_fts5_register_matchinfo db\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_ERROR} {1 SQLITE_NOMEM}\n}\n\n\n#-------------------------------------------------------------------------\n# Errors while executing the matchinfo() demo function.\n#\nreset_db\nsqlite3_fts5_register_matchinfo db\ndb func mit mit\ndo_execsql_test 2 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b);\n  INSERT INTO t1 VALUES('x y z', '1 2 3');\n  INSERT INTO t1 VALUES('x', '1 2 3 4 5 6 7');\n}\n\ndo_faultsim_test 2.1 -faults oom* -body {\n  execsql { SELECT mit(matchinfo(t1, 'a')) FROM t1('x') }\n} -test {\n  faultsim_test_result {0 {{2 5} {2 5}}} \n}\n\ndo_faultsim_test 2.2 -faults oom* -body {\n  execsql { SELECT mit(matchinfo(t1, 'l')) FROM t1('x') }\n} -test {\n  faultsim_test_result {0 {{3 3} {1 7}}} \n}\n\ndo_execsql_test 2.3 {\n  INSERT INTO t1 VALUES('a b c d e f', 'a b d e f c');\n  INSERT INTO t1 VALUES('l m b c a', 'n o a b c z');\n}\n\ndo_faultsim_test 2.4 -faults oom* -body {\n  execsql { SELECT mit(matchinfo(t1, 's')) FROM t1('a b c') }\n} -test {\n  faultsim_test_result {0 {{3 2} {2 3}}} \n}\n\n#-------------------------------------------------------------------------\n#\nreset_db \ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(z);\n}\n\ndo_faultsim_test 3.1 -faults oom* -body {\n  execsql {\n    SELECT rowid FROM x1('c') WHERE rowid>1;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_execsql_test 3.2 {\n  INSERT INTO x1 VALUES('a b c');\n  INSERT INTO x1 VALUES('b c d');\n  INSERT INTO x1 VALUES('c d e');\n  INSERT INTO x1 VALUES('d e f');\n}\ndo_faultsim_test 3.3 -faults oom* -body {\n  execsql {\n    SELECT rowid FROM x1('c') WHERE rowid>1;\n  }\n} -test {\n  faultsim_test_result {0 {2 3}}\n}\n\n#-------------------------------------------------------------------------\n# Test OOM injection with nested colsets.\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, d);\n  INSERT INTO t1 VALUES('a', 'b', 'c', 'd');  -- 1\n  INSERT INTO t1 VALUES('d', 'a', 'b', 'c');  -- 2\n  INSERT INTO t1 VALUES('c', 'd', 'a', 'b');  -- 3\n  INSERT INTO t1 VALUES('b', 'c', 'd', 'a');  -- 4\n}\ndo_faultsim_test 4.1 -faults oom* -body {\n  execsql { SELECT rowid FROM t1('{a b c} : (b:a AND c:b)'); }\n} -test {\n  faultsim_test_result {0 2}\n}\n\ndo_faultsim_test 4.2 -faults oom* -body {\n  execsql { SELECT rowid FROM t1('{a b c} : (a AND d)') }\n} -test {\n  faultsim_test_result {0 {2 3}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5faultD.test",
    "content": "# 2016 February 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file is focused on OOM errors.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/malloc_common.tcl\nset testprefix fts5faultA\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n  if {\"%DETAIL%\"==\"none\"} continue\n\n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE o1 USING fts5(a, b, c, detail=%DETAIL%);\n    INSERT INTO o1(o1, rank) VALUES('pgsz', 32);\n\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )\n    INSERT INTO o1 SELECT 'A', 'B', 'C' FROM s;\n\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )\n    INSERT INTO o1 SELECT 'C', 'A', 'B' FROM s;\n\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<60 )\n    INSERT INTO o1 SELECT 'B', 'C', 'A' FROM s;\n  }\n  \n  do_faultsim_test 1 -faults int* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT count(*) FROM o1('a') }\n  } -test {\n    faultsim_test_result {0 180} {1 {vtable constructor failed: o1}}\n  }\n\n  do_faultsim_test 2 -faults int* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT * FROM o1('a:a AND {b c}:b') ORDER BY rank }\n    expr 1\n  } -test {\n    faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}\n  }\n\n  do_faultsim_test 3 -faults int* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT * FROM o1('{b c}:b NOT a:a') ORDER BY rank }\n    expr 1\n  } -test {\n    faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}\n  }\n\n  do_faultsim_test 4 -faults int* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT * FROM o1('b:b OR a:a') }\n    expr 1\n  } -test {\n    faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}\n  }\n\n  do_faultsim_test 5 -faults int* -prep {\n    sqlite3 db test.db\n  } -body {\n    execsql { SELECT count(*) FROM o1('c:b') }\n    expr 1\n  } -test {\n    faultsim_test_result {0 1} {1 {vtable constructor failed: o1}}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5full.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that SQLITE_FULL is returned if the FTS5 table cannot find a free \n# segid to use. In practice this can only really happen when automerge and\n# crisismerge are both disabled.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5full\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE x8 USING fts5(i);\n  INSERT INTO x8(x8, rank) VALUES('automerge', 0);\n  INSERT INTO x8(x8, rank) VALUES('crisismerge', 100000);\n}\n\ndb func rnddoc fts5_rnddoc\ndo_test 1.1 {\n  list [catch {\n    for {set i 0} {$i < 2500} {incr i} {\n      execsql { INSERT INTO x8 VALUES( rnddoc(5) ); }\n    }\n  } msg] $msg\n} {1 {database or disk is full}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5fuzz1.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nreturn_if_no_fts5\nset testprefix fts5fuzz1\n\n\n#-------------------------------------------------------------------------\nreset_db\ndo_catchsql_test 1.1 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a\f b);\n} {/1 {parse error in.*}/}\n\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a, b);\n  INSERT INTO f1 VALUES('a b', 'c d');\n  INSERT INTO f1 VALUES('e f', 'a b');\n}\n\ndo_execsql_test 2.2.1 {\n  SELECT rowid FROM f1('\"\"');\n} {}\n\ndo_execsql_test 2.2.2 {\n  SELECT rowid FROM f1('\"\" AND a');\n} {}\n\n\ndo_execsql_test 2.2.3 {\n  SELECT rowid FROM f1('\"\" a');\n} {1 2}\n\ndo_execsql_test 2.2.4 {\n  SELECT rowid FROM f1('\"\" OR a');\n} {1 2}\n\ndo_execsql_test 2.3 {\n  SELECT a, b FROM f1('NEAR(\"\")');\n} {}\n\ndo_execsql_test 2.4 {\n  SELECT a, b FROM f1('NEAR(\"\", 5)');\n} {}\n\ndo_execsql_test 2.5 {\n  SELECT a, b FROM f1('NEAR(\"\" c, 5)');\n} {{a b} {c d}}\n\ndo_execsql_test 2.6 {\n  SELECT a, b FROM f1('NEAR(\"\" c d, 5)');\n} {{a b} {c d}}\n\ndo_execsql_test 2.7 {\n  SELECT a, b FROM f1('NEAR(c d, 5)');\n} {{a b} {c d}}\n\ndo_execsql_test 2.8 {\n  SELECT rowid FROM f1('NEAR(\"a\" \"b\", 5)');\n} {1 2}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 3.2 {\n  CREATE VIRTUAL TABLE f2 USING fts5(o, t, tokenize=\"ascii separators abc\");\n  SELECT * FROM f2('a+4');\n} {}\n\n\n\n#-------------------------------------------------------------------------\nreset_db\ndo_catchsql_test 4.1 {\n  CREATE VIRTUAL TABLE f2 USING fts5(o, t);\n  SELECT * FROM f2('(8 AND 9)`AND 10');\n} {1 {fts5: syntax error near \"`\"}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5hash.test",
    "content": "# 2015 April 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file are focused on the code in fts5_hash.c.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5hash\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Return a list of tokens (a vocabulary) that all share the same hash\n# key value. This can be used to test hash collisions.\n#\nproc build_vocab1 {args} {\n\n  set O(-nslot) 1024\n  set O(-nword)   20\n  set O(-hash)    88\n  set O(-prefix)  \"\"\n\n  if {[llength $args] % 2} { error \"bad args\" }\n  array set O2 $args\n  foreach {k v} $args {\n    if {[info exists O($k)]==0} { error \"bad option: $k\" }\n    set O($k) $v\n  }\n\n  set L [list]\n  while {[llength $L] < $O(-nword)} {\n    set t \"$O(-prefix)[random_token]\"\n    set h [sqlite3_fts5_token_hash $O(-nslot) $t]\n    if {$O(-hash)==$h} { lappend L $t }\n  }\n  return $L\n}\n\nproc random_token {} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set iVal [expr int(rand() * 2000000)]\n  return [string map $map $iVal]\n}\n\nproc random_doc {vocab nWord} {\n  set doc \"\"\n  set nVocab [llength $vocab]\n  for {set i 0} {$i<$nWord} {incr i} {\n    set j [expr {int(rand() * $nVocab)}]\n    lappend doc [lindex $vocab $j]\n  }\n  return $doc\n}\n\nforeach_detail_mode $testprefix {\n\n  set vocab [build_vocab1]\n  db func r random_doc \n  \n  do_execsql_test 1.0 {\n    CREATE VIRTUAL TABLE eee USING fts5(e, ee, detail=%DETAIL%);\n    BEGIN;\n      WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)\n      INSERT INTO eee SELECT r($vocab, 5), r($vocab, 7) FROM ii;\n      INSERT INTO eee(eee) VALUES('integrity-check');\n    COMMIT;\n    INSERT INTO eee(eee) VALUES('integrity-check');\n  }\n  \n  set hash [sqlite3_fts5_token_hash 1024 xyz]\n  set vocab [build_vocab1 -prefix xyz -hash $hash]\n  lappend vocab xyz\n  \n  do_execsql_test 1.1 {\n    CREATE VIRTUAL TABLE vocab USING fts5vocab(eee, 'row'); \n    BEGIN;\n  }\n  do_test 1.2 {\n    for {set i 1} {$i <= 100} {incr i} {\n      execsql { INSERT INTO eee VALUES( r($vocab, 5), r($vocab, 7) ) }\n    }\n  } {}\n    \n  do_test 1.3 {\n    db eval { SELECT term, doc FROM vocab } {\n      set nRow [db one {SELECT count(*) FROM eee WHERE eee MATCH $term}]\n      if {$nRow != $doc} {\n        error \"term=$term fts5vocab=$doc cnt=$nRow\"\n      }\n    }\n    set {} {}\n  } {}\n  \n  do_execsql_test 1.4 {\n    COMMIT;\n    INSERT INTO eee(eee) VALUES('integrity-check');\n  }\n\n  #-----------------------------------------------------------------------\n  # Add a small and very large token with the same hash value to an\n  # empty table. At one point this would provoke an asan error.\n  #\n  do_test 2.0 {\n    set big [string repeat 12345 40]\n    set hash [sqlite3_fts5_token_hash 1024 $big]\n    while {1} {\n      set small [random_token]\n      if {[sqlite3_fts5_token_hash 1024 $small]==$hash} break\n    }\n\n    execsql { CREATE VIRTUAL TABLE t2 USING fts5(x, detail=%DETAIL%) }\n    execsql {\n      INSERT INTO t2 VALUES($small || ' ' || $big);\n    }\n  } {}\n\n} ;# foreach_detail_mode\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5integrity.test",
    "content": "# 2015 Jan 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests focused on the integrity-check procedure.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5integrity\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE xx USING fts5(x);\n  INSERT INTO xx VALUES('term');\n}\ndo_execsql_test 1.1 {\n  INSERT INTO xx(xx) VALUES('integrity-check');\n}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE yy USING fts5(x, prefix=1);\n  INSERT INTO yy VALUES('term');\n}\ndo_execsql_test 2.1 {\n  INSERT INTO yy(yy) VALUES('integrity-check');\n}\n\n#--------------------------------------------------------------------\n#\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE zz USING fts5(z);\n  INSERT INTO zz(zz, rank) VALUES('pgsz', 32);\n  INSERT INTO zz VALUES('b b b b b b b b b b b b b b');\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz SELECT z FROM zz;\n  INSERT INTO zz(zz) VALUES('optimize');\n}\n\ndo_execsql_test 3.1 { INSERT INTO zz(zz) VALUES('integrity-check'); }\n\n#--------------------------------------------------------------------\n# Mess around with a docsize record. And the averages record. Then\n# check that integrity-check picks it up.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE aa USING fts5(zz);\n  INSERT INTO aa(zz) VALUES('a b c d e');\n  INSERT INTO aa(zz) VALUES('a b c d');\n  INSERT INTO aa(zz) VALUES('a b c');\n  INSERT INTO aa(zz) VALUES('a b');\n  INSERT INTO aa(zz) VALUES('a');\n  SELECT length(sz) FROM aa_docsize;\n} {1 1 1 1 1}\ndo_execsql_test 4.1 { \n  INSERT INTO aa(aa) VALUES('integrity-check'); \n}\n\ndo_catchsql_test 4.2 { \n  BEGIN;\n    UPDATE aa_docsize SET sz = X'44' WHERE rowid = 3;\n    INSERT INTO aa(aa) VALUES('integrity-check'); \n} {1 {database disk image is malformed}}\n\ndo_catchsql_test 4.3 { \n  ROLLBACK;\n  BEGIN;\n    UPDATE aa_data SET block = X'44' WHERE rowid = 1;\n    INSERT INTO aa(aa) VALUES('integrity-check'); \n} {1 {database disk image is malformed}}\n\ndo_catchsql_test 4.4 { \n  ROLLBACK;\n  BEGIN;\n    INSERT INTO aa_docsize VALUES(23, X'04');\n    INSERT INTO aa(aa) VALUES('integrity-check'); \n} {1 {database disk image is malformed}}\n\ndo_catchsql_test 4.5 { \n  ROLLBACK;\n  BEGIN;\n    INSERT INTO aa_docsize VALUES(23, X'00');\n    INSERT INTO aa_content VALUES(23, '');\n    INSERT INTO aa(aa) VALUES('integrity-check'); \n} {1 {database disk image is malformed}}\n\n#db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM zz_data} {puts $r}\n#exit\n\nexecsql { ROLLBACK }\n\n\n#-------------------------------------------------------------------------\n# Test that integrity-check works on a reasonably large db with many\n# different terms.\n\n# Document generator command.\nproc rnddoc {n} {\n  set doc [list]\n  for {set i 0} {$i<$n} {incr i} {\n    lappend doc [format %.5d [expr int(rand()*10000)]]\n  }\n  return $doc\n}\ndb func rnddoc rnddoc\n\nexpr srand(0)\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE gg USING fts5(a, prefix=\"1,2,3\");\n  INSERT INTO gg(gg, rank) VALUES('pgsz', 256);\n  INSERT INTO gg VALUES(rnddoc(20));\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n  INSERT INTO gg SELECT rnddoc(20) FROM gg;\n}\n\ndo_execsql_test 5.1 {\n  INSERT INTO gg(gg) VALUES('integrity-check');\n}\n\ndo_execsql_test 5.2 {\n  INSERT INTO gg(gg) VALUES('optimize');\n}\n\ndo_execsql_test 5.3 {\n  INSERT INTO gg(gg) VALUES('integrity-check');\n}\n\ndo_test 5.4.1 {\n  set ok 0\n  for {set i 0} {$i < 10000} {incr i} {\n    set T [format %.5d $i]\n    set res  [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC  }]\n    set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }]\n    if {$res == [lsort -integer $res2]} { incr ok }\n  }\n  set ok\n} {10000}\n\ndo_test 5.4.2 {\n  set ok 0\n  for {set i 0} {$i < 100} {incr i} {\n    set T \"[format %.3d $i]*\"\n    set res  [db eval { SELECT rowid FROM gg($T) ORDER BY rowid ASC  }]\n    set res2 [db eval { SELECT rowid FROM gg($T) ORDER BY rowid DESC }]\n    if {$res == [lsort -integer $res2]} { incr ok }\n  }\n  set ok\n} {100}\n\n#-------------------------------------------------------------------------\n# Similar to 5.*.\n#\nforeach {tn pgsz} {\n  1  32\n  2  36\n  3  40\n  4  44\n  5  48\n} {\n  do_execsql_test 6.$tn.1 {\n    DROP TABLE IF EXISTS hh;\n    CREATE VIRTUAL TABLE hh USING fts5(y);\n    INSERT INTO hh(hh, rank) VALUES('pgsz', $pgsz);\n\n    WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999)\n     INSERT INTO hh SELECT printf(\"%.3d%.3d%.3d %.3d%.3d%.3d\",i,i,i,i+1,i+1,i+1)\n     FROM s;\n\n    WITH s(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<999)\n     INSERT INTO hh SELECT printf(\"%.3d%.3d%.3d %.3d%.3d%.3d\",i,i,i,i+1,i+1,i+1)\n     FROM s;\n\n    INSERT INTO hh(hh) VALUES('optimize');\n  }\n\n  do_test 6.$tn.2 {\n    set ok 0\n    for {set i 0} {$i < 1000} {incr i} {\n      set T [format %.3d%.3d%.3d $i $i $i]\n      set res  [db eval { SELECT rowid FROM hh($T) ORDER BY rowid ASC  }]\n      set res2 [db eval { SELECT rowid FROM hh($T) ORDER BY rowid DESC }]\n      if {$res == [lsort -integer $res2]} { incr ok }\n    }\n    set ok\n  } {1000}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5lastrowid.test",
    "content": "# 2017 Feb 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests of the last_insert_rowid functionality with fts5.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5lastrowid\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(str);\n}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1 VALUES('one string');\n  INSERT INTO t1 VALUES('two string');\n  INSERT INTO t1 VALUES('three string');\n  SELECT last_insert_rowid();\n} {3}\n\ndo_execsql_test 1.2 {\n  BEGIN;\n    INSERT INTO t1 VALUES('one string');\n    INSERT INTO t1 VALUES('two string');\n    INSERT INTO t1 VALUES('three string');\n  COMMIT;\n  SELECT last_insert_rowid();\n} {6}\n\ndo_execsql_test 1.3 {\n  INSERT INTO t1(rowid, str) VALUES(-22, 'some more text');\n  SELECT last_insert_rowid();\n} {-22}\n\ndo_execsql_test 1.4 {\n  BEGIN;\n    INSERT INTO t1(rowid, str) VALUES(45, 'some more text');\n    INSERT INTO t1(rowid, str) VALUES(46, 'some more text');\n    INSERT INTO t1(rowid, str) VALUES(222, 'some more text');\n    SELECT last_insert_rowid();\n  COMMIT;\n  SELECT last_insert_rowid();\n} {222 222}\n\ndo_execsql_test 1.5 {\n  CREATE TABLE x1(x);\n  INSERT INTO x1 VALUES('john'), ('paul'), ('george'), ('ringo');\n  INSERT INTO t1 SELECT x FROM x1;\n  SELECT last_insert_rowid();\n} {226}\n\ndo_execsql_test 1.6 {\n  INSERT INTO t1(rowid, str) SELECT rowid+10, x FROM x1;\n  SELECT last_insert_rowid();\n} {14}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5leftjoin.test",
    "content": "# 2014 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5leftjoin\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE vt USING fts5(x);\n  INSERT INTO vt VALUES('abc');\n  INSERT INTO vt VALUES('xyz');\n\n  CREATE TABLE t1(a INTEGER PRIMARY KEY);\n  INSERT INTO t1 VALUES(1), (2);\n}\n\ndo_execsql_test 1.1 {\n  SELECT * FROM t1 LEFT JOIN (\n    SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc'\n  ) ON t1.a = rrr\n} {1 1 abc 2 {} {}}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1 LEFT JOIN vt ON (vt MATCH 'abc')\n} {1 abc 2 abc}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5matchinfo.test",
    "content": "# 2015 August 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5matchinfo\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 { finish_test ; return }\n\nforeach_detail_mode $testprefix {\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\nsqlite3_fts5_register_matchinfo db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(content, detail=%DETAIL%);\n} \n\ndo_execsql_test 1.1 {\n  INSERT INTO t1(content) VALUES('I wandered lonely as a cloud');\n  INSERT INTO t1(content) VALUES('That floats on high o''er vales and hills,');\n  INSERT INTO t1(content) VALUES('When all at once I saw a crowd,');\n  INSERT INTO t1(content) VALUES('A host, of golden daffodils,');\n  SELECT mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'I';\n} {{1 1 1 2 2} {1 1 1 2 2}}\n\n# Now create an FTS4 table that does not specify matchinfo=fts3.\n#\ndo_execsql_test 1.2 {\n  CREATE VIRTUAL TABLE t2 USING fts5(content, detail=%DETAIL%);\n  INSERT INTO t2 SELECT * FROM t1;\n  SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I';\n} {{1 1 1 2 2} {1 1 1 2 2}}\n\n\n#--------------------------------------------------------------------------\n# Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.\n#\n# The first argument - $tn - is a test identifier. This may be either a\n# full identifier (i.e. \"fts3matchinfo-1.1\") or, if global var $testprefix\n# is set, just the numeric component (i.e. \"1.1\").\n#\n# The second argument is the name of an FTSX table. The third is the \n# full text of a WHERE/MATCH expression to query the table for \n# (i.e. \"t1 MATCH 'abc'\"). The final argument - $results - should be a\n# key-value list (serialized array) with matchinfo() format specifiers\n# as keys, and the results of executing the statement:\n#\n#   SELECT matchinfo($tbl, '$key') FROM $tbl WHERE $expr\n#\n# For example:\n#\n#   CREATE VIRTUAL TABLE t1 USING fts4;\n#   INSERT INTO t1 VALUES('abc');\n#   INSERT INTO t1 VALUES('def');\n#   INSERT INTO t1 VALUES('abc abc');\n#\n#   do_matchinfo_test 1.1 t1 \"t1 MATCH 'abc'\" {\n#     n {3 3}\n#     p {1 1}\n#     c {1 1}\n#     x {{1 3 2} {2 3 2}}\n#   }\n#\n# If the $results list contains keys mapped to \"-\" instead of a matchinfo()\n# result, then this command computes the expected results based on other\n# mappings to test the matchinfo() function. For example, the command above\n# could be changed to:\n#\n#   do_matchinfo_test 1.1 t1 \"t1 MATCH 'abc'\" {\n#     n {3 3} p {1 1} c {1 1} x {{1 3 2} {2 3 2}}\n#     pcx -\n#   }\n#\n# And this command would compute the expected results for matchinfo(t1, 'pcx')\n# based on the results of matchinfo(t1, 'p'), matchinfo(t1, 'c') and \n# matchinfo(t1, 'x') in order to test 'pcx'.\n#\nproc do_matchinfo_test {tn tbl expr results} {\n\n  foreach {fmt res} $results {\n    if {$res == \"-\"} continue\n    set resarray($fmt) $res\n  }\n\n  set nRow 0\n  foreach {fmt res} [array get resarray] {\n    if {[llength $res]>$nRow} { set nRow [llength $res] }\n  }\n\n  # Construct expected results for any formats for which the caller \n  # supplied result is \"-\".\n  #\n  foreach {fmt res} $results {\n    if {$res == \"-\"} {\n      set res [list]\n      for {set iRow 0} {$iRow<$nRow} {incr iRow} {\n        set rowres [list]\n        foreach c [split $fmt \"\"] {\n          set rowres [concat $rowres [lindex $resarray($c) $iRow]]\n        }\n        lappend res $rowres\n      }\n      set resarray($fmt) $res\n    }\n  }\n\n  # Test each matchinfo() request individually.\n  #\n  foreach {fmt res} [array get resarray] {\n    set sql \"SELECT mit(matchinfo($tbl, '$fmt')) FROM $tbl WHERE $expr\"\n    do_execsql_test $tn.$fmt $sql [normalize2 $res]\n  }\n\n  # Test them all executed together (multiple invocations of matchinfo()).\n  #\n  set exprlist [list]\n  foreach {format res} [array get resarray] {\n    lappend exprlist \"mit(matchinfo($tbl, '$format'))\"\n  }\n  set allres [list]\n  for {set iRow 0} {$iRow<$nRow} {incr iRow} {\n    foreach {format res} [array get resarray] {\n      lappend allres [lindex $res $iRow]\n    }\n  }\n  set sql \"SELECT [join $exprlist ,] FROM $tbl WHERE $expr\"\n  do_execsql_test $tn.multi $sql [normalize2 $allres]\n}\nproc normalize2 {list_of_lists} {\n  set res [list]\n  foreach elem $list_of_lists {\n    lappend res [list {*}$elem]\n  }\n  return $res\n}\n\n# Similar to [do_matchinfo_test], except that this is a no-op if the FTS5\n# mode is not detail=full.\n#\nproc do_matchinfo_p_test {tn tbl expr results} {\n  if {[detail_is_full]} {\n    uplevel [list do_matchinfo_test $tn $tbl $expr $results]\n  }\n}\n\ndo_execsql_test 4.1.0 {\n  CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO t4 VALUES('a b c d e', 'f g h i j');\n  INSERT INTO t4 VALUES('f g h i j', 'a b c d e');\n}\n\ndo_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {\n  s {{3 0} {0 3}}\n}\n\ndo_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {\n  p {3 3}\n  x {\n    {1 1 1   0 1 1   1 1 1   0 1 1   1 1 1   0 1 1}\n    {0 1 1   1 1 1   0 1 1   1 1 1   0 1 1   1 1 1}\n  }\n}\n\ndo_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {\n  p {3 3}\n  c {2 2}\n  x {\n    {1 1 1   0 1 1   1 1 1   0 1 1   1 1 1   0 1 1}\n    {0 1 1   1 1 1   0 1 1   1 1 1   0 1 1   1 1 1}\n  }\n  n {2 2}\n  l {{5 5} {5 5}}\n  a {{5 5} {5 5}}\n\n  s {{3 0} {0 3}}\n\n  xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -\n  xpxsscplax -\n}\n\ndo_matchinfo_p_test 4.1.2 t4 {t4 MATCH '\"g h i\"'} {\n  p {1 1}\n  c {2 2}\n  x {\n    {0 1 1   1 1 1}\n    {1 1 1   0 1 1}\n  }\n  n {2 2}\n  l {{5 5} {5 5}}\n  a {{5 5} {5 5}}\n\n  s {{0 1} {1 0}}\n\n  xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -\n  sxsxs -\n}\n\ndo_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'}     { s {{2 0} {0 2}} }\ndo_matchinfo_p_test 4.1.4 t4 {t4 MATCH '\"a b\" c'} { s {{2 0} {0 2}} }\ndo_matchinfo_p_test 4.1.5 t4 {t4 MATCH 'a \"b c\"'} { s {{2 0} {0 2}} }\ndo_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'}     { s {{1 0} {0 1}} }\ndo_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} {\n  x { \n    {0 1 1  1 1 1  0 0 0  0 0 0} \n    {1 1 1  0 1 1  0 0 0  0 0 0}\n  }\n}\ndo_matchinfo_test 4.1.8 t4 {t4 MATCH 'f NOT abcd'} {\n  x { \n    {0 1 1  1 1 1  0 0 0  0 0 0}\n    {1 1 1  0 1 1  0 0 0  0 0 0}\n  }\n}\n\ndo_execsql_test 4.2.0 {\n  CREATE VIRTUAL TABLE t5 USING fts5(content, detail=%DETAIL%);\n  INSERT INTO t5 VALUES('a a a a a');\n  INSERT INTO t5 VALUES('a b a b a');\n  INSERT INTO t5 VALUES('c b c b c');\n  INSERT INTO t5 VALUES('x x x x x');\n}\ndo_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'}         { \n  x {{5 8 2   5 8 2} {3 8 2   3 8 2}}\n  s {2 1} \n}\ndo_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_p_test 4.2.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\ndo_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1} }\n\ndo_execsql_test 4.3.0 \"INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')\";\n\n# It used to be that the second 'a' token would be deferred. That doesn't\n# work any longer.\nif 0 {\n  do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { \n    x {{5 8 2   5 5 5} {3 8 2   3 5 5}}\n    s {2 1} \n  }\n}\n\ndo_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_p_test 4.3.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\ndo_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1 1} }\n\ndo_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') }\n\ndo_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'}         { s {2 1} }\ndo_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_p_test 4.4.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\n\ndo_execsql_test 4.5.0 {\n  CREATE VIRTUAL TABLE t6 USING fts5(a, b, c, detail=%DETAIL%);\n  INSERT INTO t6 VALUES('a', 'b', 'c');\n}\ndo_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'}       { s {{1 1 1}} }\n\n\n#-------------------------------------------------------------------------\n# Test the outcome of matchinfo() when used within a query that does not\n# use the full-text index (i.e. lookup by rowid or full-table scan).\n#\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE t10 USING fts5(content, detail=%DETAIL%);\n  INSERT INTO t10 VALUES('first record');\n  INSERT INTO t10 VALUES('second record');\n}\ndo_execsql_test 7.2 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10;\n} {blob 8 blob 8}\ndo_execsql_test 7.3 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10 WHERE rowid=1;\n} {blob 8}\ndo_execsql_test 7.4 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) \n  FROM t10 WHERE t10 MATCH 'record'\n} {blob 20 blob 20}\n\n#-------------------------------------------------------------------------\n# Test a special case - matchinfo('nxa') with many zero length documents. \n# Special because \"x\" internally uses a statement used by both \"n\" and \"a\". \n# This was causing a problem at one point in the obscure case where the\n# total number of bytes of data stored in an fts3 table was greater than\n# the number of rows. i.e. when the following query returns true:\n#\n#   SELECT sum(length(content)) < count(*) FROM fts4table;\n#\ndo_execsql_test 8.1 {\n  CREATE VIRTUAL TABLE t11 USING fts5(content, detail=%DETAIL%);\n  INSERT INTO t11(t11, rank) VALUES('pgsz', 32);\n  INSERT INTO t11 VALUES('quitealongstringoftext');\n  INSERT INTO t11 VALUES('anotherquitealongstringoftext');\n  INSERT INTO t11 VALUES('athirdlongstringoftext');\n  INSERT INTO t11 VALUES('andonemoreforgoodluck');\n}\ndo_test 8.2 {\n  for {set i 0} {$i < 200} {incr i} {\n    execsql { INSERT INTO t11 VALUES('') }\n  }\n  execsql { INSERT INTO t11(t11) VALUES('optimize') }\n} {}\ndo_execsql_test 8.3 {\n  SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'\n} {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}}\n\n#-------------------------------------------------------------------------\n\nif {[detail_is_full]} {\n  do_execsql_test 9.1 {\n    CREATE VIRTUAL TABLE t12 USING fts5(content, detail=%DETAIL%);\n    INSERT INTO t12 VALUES('a b c d');\n    SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';\n  } {{0 1 1 0 1 1 1 1 1}}\n  do_execsql_test 9.2 {\n    INSERT INTO t12 VALUES('a d c d');\n    SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';\n  } {\n    {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2}\n  }\n  do_execsql_test 9.3 {\n    INSERT INTO t12 VALUES('a d d a');\n    SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';\n  } {\n    {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3}\n  }\n}\n\n#---------------------------------------------------------------------------\n# Test for a memory leak\n#\ndo_execsql_test 10.1 {\n  DROP TABLE t10;\n  CREATE VIRTUAL TABLE t10 USING fts5(idx, value, detail=%DETAIL%);\n  INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');\n  SELECT t10.rowid, t10.*\n    FROM t10\n    JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x\n   WHERE t10 MATCH x.idx\n     AND matchinfo(t10) not null\n   GROUP BY t10.rowid\n   ORDER BY 1;\n} {1 1 one 2 2 two 3 3 three}\n  \n#---------------------------------------------------------------------------\n# Test the 'y' matchinfo flag\n#\nreset_db\nsqlite3_fts5_register_matchinfo db\ndo_execsql_test 11.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(x, y, detail=%DETAIL%);\n  INSERT INTO tt VALUES('c d a c d d', 'e a g b d a');   -- 1\n  INSERT INTO tt VALUES('c c g a e b', 'c g d g e c');   -- 2\n  INSERT INTO tt VALUES('b e f d e g', 'b a c b c g');   -- 3\n  INSERT INTO tt VALUES('a c f f g d', 'd b f d e g');   -- 4\n  INSERT INTO tt VALUES('g a c f c f', 'd g g b c c');   -- 5\n  INSERT INTO tt VALUES('g a c e b b', 'd b f b g g');   -- 6\n  INSERT INTO tt VALUES('f d a a f c', 'e e a d c f');   -- 7\n  INSERT INTO tt VALUES('a c b b g f', 'a b a e d f');   -- 8\n  INSERT INTO tt VALUES('b a f e c c', 'f d b b a b');   -- 9\n  INSERT INTO tt VALUES('f d c e a c', 'f a f a a f');   -- 10\n}\n\ndb func mit mit\nforeach {tn expr res} {\n  1 \"a\" {\n      1 {1 2}   2 {1 0}   3 {0 1}   4 {1 0}   5 {1 0}\n      6 {1 0}   7 {2 1}   8 {1 2}   9 {1 1}  10 {1 3}\n  }\n\n  2 \"b\" {\n      1 {0 1}   2 {1 0}   3 {1 2}   4 {0 1}   5 {0 1}\n      6 {2 2}             8 {2 1}   9 {1 3}            \n  }\n\n  3 \"y:a\" {\n      1 {0 2}             3 {0 1}                    \n                7 {0 1}   8 {0 2}   9 {0 1}  10 {0 3}\n  }\n\n  4 \"x:a\" {\n      1 {1 0}   2 {1 0}             4 {1 0}   5 {1 0}\n      6 {1 0}   7 {2 0}   8 {1 0}   9 {1 0}  10 {1 0}\n  }\n\n  5 \"a OR b\" {\n      1 {1 2 0 1}   2 {1 0 1 0}   3 {0 1 1 2}   4 {1 0 0 1}   5 {1 0 0 1}\n      6 {1 0 2 2}   7 {2 1 0 0}   8 {1 2 2 1}   9 {1 1 1 3}  10 {1 3 0 0}\n  }\n\n  6 \"a AND b\" {\n      1 {1 2 0 1}   2 {1 0 1 0}   3 {0 1 1 2}   4 {1 0 0 1}   5 {1 0 0 1}\n      6 {1 0 2 2}                 8 {1 2 2 1}   9 {1 1 1 3}              \n  }\n\n  7 \"a OR (a AND b)\" {\n      1 {1 2 1 2 0 1}   2 {1 0 1 0 1 0}   3 {0 1 0 1 1 2}   4 {1 0 1 0 0 1}   \n      5 {1 0 1 0 0 1}   6 {1 0 1 0 2 2}   7 {2 1 0 0 0 0}   8 {1 2 1 2 2 1}   \n      9 {1 1 1 1 1 3}  10 {1 3 0 0 0 0}\n  }\n\n} {\n\n  if {[string match *:* $expr] && [detail_is_none]} continue\n  do_execsql_test 11.1.$tn.1  {\n    SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr\n  } $res\n\n  set r2 [list]\n  foreach {rowid L} $res {\n    lappend r2 $rowid\n    set M [list]\n    foreach {a b} $L {\n      lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]\n    }\n    lappend r2 $M\n  }\n\n  do_execsql_test 11.1.$tn.2  {\n    SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr\n  } $r2\n\n  do_execsql_test 11.1.$tn.2  {\n    SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr\n  } $r2\n}\n\n#---------------------------------------------------------------------------\n# Test the 'b' matchinfo flag\n#\nreset_db\nsqlite3_fts5_register_matchinfo db\ndb func mit mit\n\ndo_test 12.0 {\n  set cols [list]\n  for {set i 0} {$i < 50} {incr i} { lappend cols \"c$i\" }\n  execsql \"CREATE VIRTUAL TABLE tt USING fts5([join $cols ,], detail=%DETAIL%)\"\n} {}\n\ndo_execsql_test 12.1 {\n  INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');\n  SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';\n} [list [list [expr 1<<4] [expr 1<<(45-32)]]]\n\n} ;# foreach_detail_mode\n\n#-------------------------------------------------------------------------\n# Test that a bad fts5() return is detected\n#\nreset_db\nproc xyz {} {}\ndb func fts5 -argcount 1 xyz\ndo_test 13.1 {\n  list [catch { sqlite3_fts5_register_matchinfo db } msg] $msg\n} {1 SQLITE_ERROR}\n\n#-------------------------------------------------------------------------\n# Test that an invalid matchinfo() flag is detected\n#\nreset_db\nsqlite3_fts5_register_matchinfo db\ndo_execsql_test 14.1 {\n  CREATE VIRTUAL TABLE x1 USING fts5(z);\n  INSERT INTO x1 VALUES('a b c a b c a b c');\n} {}\n\ndo_catchsql_test 14.2 {\n  SELECT matchinfo(x1, 'd') FROM x1('a b c');\n} {1 {unrecognized matchinfo flag: d}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5merge.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that focus on incremental merges of segments.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5merge\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndb func repeat [list string repeat]\n\n#-------------------------------------------------------------------------\n# Create an fts index so that:\n#\n#   * the index consists of two top-level segments\n#   * each segment contains records related to $nRowPerSeg rows\n#   * all rows consist of tokens \"x\" and \"y\" only.\n#\n# Then run ('merge', 1) until everything is completely merged.\n#\nproc do_merge1_test {testname nRowPerSeg} {\n  set ::nRowPerSeg [expr $nRowPerSeg]\n  do_execsql_test $testname.0 {\n    DROP TABLE IF EXISTS x8;\n    CREATE VIRTUAL TABLE x8 USING fts5(i);\n    INSERT INTO x8(x8, rank) VALUES('pgsz', 32);\n\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<$::nRowPerSeg)\n      INSERT INTO x8 SELECT repeat('x y ', i % 16) FROM ii;\n\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<$::nRowPerSeg)\n      INSERT INTO x8 SELECT repeat('x y ', i % 16) FROM ii;\n\n    INSERT INTO x8(x8, rank) VALUES('usermerge', 2);\n  }\n\n  for {set tn 1} {[lindex [fts5_level_segs x8] 0]>0} {incr tn} {\n    do_execsql_test $testname.$tn {\n      INSERT INTO x8(x8, rank) VALUES('merge', 1);\n      INSERT INTO x8(x8) VALUES('integrity-check');\n    }\n    if {$tn>5} break\n  }\n\n  do_test $testname.x [list expr \"$tn < 5\"] 1\n}\n\ndo_merge1_test 1.1   1\ndo_merge1_test 1.2   2\ndo_merge1_test 1.3   3\ndo_merge1_test 1.4   4\ndo_merge1_test 1.5  10\ndo_merge1_test 1.6  20\ndo_merge1_test 1.7 100\n\n#-------------------------------------------------------------------------\n#\nproc do_merge2_test {testname nRow} {\n  db func rnddoc fts5_rnddoc\n\n  do_execsql_test $testname.0 {\n    DROP TABLE IF EXISTS x8;\n    CREATE VIRTUAL TABLE x8 USING fts5(i);\n    INSERT INTO x8(x8, rank) VALUES('pgsz', 32);\n  }\n\n  set ::nRow $nRow\n  do_test $testname.1 {\n    for {set i 0} {$i < $::nRow} {incr i} {\n      execsql { INSERT INTO x8 VALUES( rnddoc(($i%16) + 5) ) }\n      while {[not_merged x8]} {\n        execsql {\n          INSERT INTO x8(x8, rank) VALUES('usermerge', 2);\n          INSERT INTO x8(x8, rank) VALUES('merge', 1);\n          INSERT INTO x8(x8, rank) VALUES('usermerge', 16);\n          INSERT INTO x8(x8) VALUES('integrity-check');\n        }\n      }\n    }\n  } {}\n}\nproc not_merged {tbl} {\n  set segs [fts5_level_segs $tbl]\n  foreach s $segs { if {$s>1} { return 1 } }\n  return 0\n}\n\ndo_merge2_test 2.1    5\ndo_merge2_test 2.2   10\ndo_merge2_test 2.3   20\n\n#-------------------------------------------------------------------------\n# Test that a merge will complete any merge that has already been\n# started, even if the number of input segments is less than the current\n# value of the 'usermerge' configuration parameter.\n#\ndb func rnddoc fts5_rnddoc\n\ndo_execsql_test 3.1 {\n  DROP TABLE IF EXISTS x8;\n  CREATE VIRTUAL TABLE x8 USING fts5(i);\n  INSERT INTO x8(x8, rank) VALUES('pgsz', 32);\n  INSERT INTO x8 VALUES(rnddoc(100));\n  INSERT INTO x8 VALUES(rnddoc(100));\n}\ndo_test 3.2 {\n  execsql {\n    INSERT INTO x8(x8, rank) VALUES('usermerge', 4);\n    INSERT INTO x8(x8, rank) VALUES('merge', 1);\n  }\n  fts5_level_segs x8\n} {2}\n\ndo_test 3.3 {\n  execsql {\n    INSERT INTO x8(x8, rank) VALUES('usermerge', 2);\n    INSERT INTO x8(x8, rank) VALUES('merge', 1);\n  }\n  fts5_level_segs x8\n} {2 1}\n\ndo_test 3.4 {\n  execsql { INSERT INTO x8(x8, rank) VALUES('usermerge', 4) }\n  while {[not_merged x8]} {\n    execsql { INSERT INTO x8(x8, rank) VALUES('merge', 1) }\n  }\n  fts5_level_segs x8\n} {0 1}\n\n#-------------------------------------------------------------------------\n#\nproc mydoc {} {\n  set x [lindex {a b c d e f g h i j} [expr int(rand()*10)]]\n  return [string repeat \"$x \" 30]\n}\ndb func mydoc mydoc\n\nproc mycount {} {\n  set res [list]\n  foreach x {a b c d e f g h i j} {\n    lappend res [db one {SELECT count(*) FROM x8 WHERE x8 MATCH $x}]\n  }\n  set res\n}\n\n  #1 32\nforeach {tn pgsz} {\n  2 1000\n} {\n  do_execsql_test 4.$tn.1 {\n    DROP TABLE IF EXISTS x8;\n    CREATE VIRTUAL TABLE x8 USING fts5(i);\n    INSERT INTO x8(x8, rank) VALUES('pgsz', $pgsz);\n  }\n\n  do_execsql_test 4.$tn.2 {\n    INSERT INTO x8(x8, rank) VALUES('merge', 1);\n  }\n\n  do_execsql_test 4.$tn.3 {\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)\n      INSERT INTO x8 SELECT mydoc() FROM ii;\n    WITH ii(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<100)\n      INSERT INTO x8 SELECT mydoc() FROM ii;\n    INSERT INTO x8(x8, rank) VALUES('usermerge', 2);\n  }\n\n  set expect [mycount]\n    for {set i 0} {$i < 20} {incr i} {\n      do_test 4.$tn.4.$i {\n        execsql { INSERT INTO x8(x8, rank) VALUES('merge', 1); }\n        mycount\n      } $expect\n      break\n    }\n#  db eval {SELECT fts5_decode(rowid, block) AS r FROM x8_data} { puts $r }\n}\n\n#-------------------------------------------------------------------------\n# Test that the 'merge' command does not modify the database if there is\n# no work to do. \n\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE x9 USING fts5(one, two);\n  INSERT INTO x9(x9, rank) VALUES('pgsz', 32);\n  INSERT INTO x9(x9, rank) VALUES('automerge', 2);\n  INSERT INTO x9(x9, rank) VALUES('usermerge', 2);\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n  INSERT INTO x9 VALUES(rnddoc(100), rnddoc(100));\n}\n\ndo_test 5.2 {\n  while 1 {\n    set nChange [db total_changes]\n    execsql { INSERT INTO x9(x9, rank) VALUES('merge', 1); }\n    set nChange [expr [db total_changes] - $nChange]\n    #puts $nChange\n    if {$nChange<2} break\n  }\n} {}\n\n\n#--------------------------------------------------------------------------\n# Test that running 'merge' on an empty database does not cause a \n# problem.\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE g1 USING fts5(a, b);\n}\ndo_execsql_test 6.1 {\n  INSERT INTO g1(g1, rank) VALUES('merge', 10);\n}\ndo_execsql_test 6.2 {\n  INSERT INTO g1(g1, rank) VALUES('merge', -10);\n}\ndo_execsql_test 6.3 {\n  INSERT INTO g1(g1) VALUES('integrity-check');\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5merge2.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that focus on incremental merges of segments.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5merge2\nreturn_if_no_fts5\n\nproc dump_structure {} {\n  db eval {SELECT fts5_decode(id, block) AS t FROM t1_data WHERE id=10} {\n    foreach lvl [lrange $t 1 end] {\n      set seg [string repeat . [expr [llength $lvl]-2]]\n      puts \"[lrange $lvl 0 1] $seg\"\n    }\n  }\n}\n\nforeach_detail_mode $testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  INSERT INTO t1(t1, rank) VALUES('crisismerge', 2);\n  INSERT INTO t1 VALUES('1 2 3 4');\n}\n\nexpr srand(0)\ndb func rnddoc fts5_rnddoc\ndo_test 1.1 {\n  for {set i 0} {$i < 100} {incr i} {\n    execsql {\n      BEGIN;\n        DELETE FROM t1 WHERE rowid = 1;\n        INSERT INTO t1(rowid, x) VALUES(1, '1 2 3 4');\n        INSERT INTO t1 VALUES(rnddoc(10));\n      COMMIT;\n    }\n  }\n} {}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5multiclient.test",
    "content": "# 2016 March 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nsource $testdir/lock_common.tcl\n\nset testprefix fts5multiclient\nreturn_if_no_fts5\n\nforeach_detail_mode $testprefix {\n\ndo_multiclient_test tn {\n\n  do_test 1.$tn.1 {\n    sql1 { CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%) }\n    sql1 { INSERT INTO t1 VALUES('a b c') }\n    sql2 { SELECT rowid FROM t1('b') }\n  } {1}\n\n  do_test 1.$tn.2 {\n    sql2 { INSERT INTO t1 VALUES('a b c') }\n    sql1 { SELECT rowid FROM t1('b') }\n  } {1 2}\n\n  do_test 1.$tn.3 {\n    sql2 { INSERT INTO t1 VALUES('a b c') }\n    sql1 { SELECT rowid FROM t1('b') }\n  } {1 2 3}\n\n  do_test 1.$tn.4 {\n    sql2 { INSERT INTO t1 VALUES('a b c') }\n    sql1 { INSERT INTO t1 VALUES('a b c') }\n    sql3 { INSERT INTO t1(t1) VALUES('integrity-check') }\n  } {}\n\n};# do_multiclient_test\n};# foreach_detail_mode\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5near.test",
    "content": "# 2014 Jan 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focused on the NEAR operator.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5near\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc do_near_test {tn doc near res} {\n  uplevel [list do_execsql_test $tn \"\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('$doc');\n    SELECT count(*) FROM t1 WHERE t1 MATCH '$near';\n  \" $res]\n}\n\nexecsql { \n  CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize = \"ascii tokenchars '.'\") \n}\n\ndo_near_test 1.1 \". . a . . . b . .\" { NEAR(a b, 5) } 1\ndo_near_test 1.2 \". . a . . . b . .\" { NEAR(a b, 4) } 1\ndo_near_test 1.3 \". . a . . . b . .\" { NEAR(a b, 3) } 1\ndo_near_test 1.4 \". . a . . . b . .\" { NEAR(a b, 2) } 0\n\ndo_near_test 1.5 \". . a . . . b . .\" { NEAR(b a, 5) } 1\ndo_near_test 1.6 \". . a . . . b . .\" { NEAR(b a, 4) } 1\ndo_near_test 1.7 \". . a . . . b . .\" { NEAR(b a, 3) } 1\ndo_near_test 1.8 \". . a . . . b . .\" { NEAR(b a, 2) } 0\n\ndo_near_test 1.9  \". a b . . . c . .\" { NEAR(\"a b\" c, 3) } 1\ndo_near_test 1.10 \". a b . . . c . .\" { NEAR(\"a b\" c, 2) } 0\ndo_near_test 1.11 \". a b . . . c . .\" { NEAR(c \"a b\", 3) } 1\ndo_near_test 1.12 \". a b . . . c . .\" { NEAR(c \"a b\", 2) } 0\n\ndo_near_test 1.13 \". a b . . . c d .\" { NEAR(a+b c+d, 3) } 1\ndo_near_test 1.14 \". a b . . . c d .\" { NEAR(a+b c+d, 2) } 0\ndo_near_test 1.15 \". a b . . . c d .\" { NEAR(c+d a+b, 3) } 1\ndo_near_test 1.16 \". a b . . . c d .\" { NEAR(c+d a+b, 2) } 0\n\ndo_near_test 1.17 \". a b . . . c d .\" { NEAR(a b c d, 5) } 1\ndo_near_test 1.18 \". a b . . . c d .\" { NEAR(a b c d, 4) } 0\ndo_near_test 1.19 \". a b . . . c d .\" { NEAR(a+b c d, 4) } 1\n\ndo_near_test 1.20 \"a b c d e f g h i\" { NEAR(b+c a+b+c+d i, 5) } 1\ndo_near_test 1.21 \"a b c d e f g h i\" { NEAR(b+c a+b+c+d i, 4) } 0\n\ndo_near_test 1.22 \"a b c d e f g h i\" { NEAR(a+b+c+d i b+c, 5) } 1\ndo_near_test 1.23 \"a b c d e f g h i\" { NEAR(a+b+c+d i b+c, 4) } 0\n\ndo_near_test 1.24 \"a b c d e f g h i\" { NEAR(i a+b+c+d b+c, 5) } 1\ndo_near_test 1.25 \"a b c d e f g h i\" { NEAR(i a+b+c+d b+c, 4) } 0\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5onepass.test",
    "content": "# 2015 Sep 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5onepass\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(content);\n  INSERT INTO ft(rowid, content) VALUES(1, '1 2 3');\n  INSERT INTO ft(rowid, content) VALUES(2, '4 5 6');\n  INSERT INTO ft(rowid, content) VALUES(3, '7 8 9');\n}\n\n#-------------------------------------------------------------------------\n# Check that UPDATE and DELETE statements that feature \"WHERE rowid=?\" or \n# or \"WHERE rowid=?\" clauses do not use statement journals. But that other\n# DELETE and UPDATE statements do.\n#\n# Note: \"MATCH ? AND rowid=?\" does use a statement journal.\n#\nforeach {tn sql uses} {\n  1.1 { DELETE FROM ft } 1\n  1.2 { DELETE FROM ft WHERE rowid=? } 0\n  1.3 { DELETE FROM ft WHERE rowid=? } 0\n  1.4 { DELETE FROM ft WHERE ft MATCH '1' } 1\n  1.5 { DELETE FROM ft WHERE ft MATCH '1' AND rowid=? } 1\n  1.6 { DELETE FROM ft WHERE ft MATCH '1' AND rowid=? } 1\n\n  2.1 { UPDATE ft SET content='a b c' } 1\n  2.2 { UPDATE ft SET content='a b c' WHERE rowid=? } 0\n  2.3 { UPDATE ft SET content='a b c' WHERE rowid=? } 0\n  2.4 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' } 1\n  2.5 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND rowid=? } 1\n  2.6 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND rowid=? } 1\n} {\n  do_test 1.$tn { sql_uses_stmt db $sql } $uses\n}\n\n#-------------------------------------------------------------------------\n# Check that putting a \"DELETE/UPDATE ... WHERE rowid=?\" statement in a\n# trigger program does not prevent the VM from using a statement \n# transaction. Even if the calling statement cannot hit a constraint.\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(x);\n\n  CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN\n    DELETE FROM ft WHERE rowid=new.x;\n  END;\n\n  CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN\n    UPDATE ft SET content = 'a b c' WHERE rowid=old.x;\n  END;\n\n  CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN\n    DELETE FROM ft WHERE rowid=old.x;\n  END;\n}\n\nforeach {tn sql uses} {\n  1 { INSERT INTO t1 VALUES(1)      } 1\n  2 { DELETE FROM t1 WHERE x=4      } 1\n  3 { UPDATE t1 SET x=10 WHERE x=11 } 1\n} {\n  do_test 2.$tn { sql_uses_stmt db $sql } $uses\n}\n\n#-------------------------------------------------------------------------\n# Test that an \"UPDATE ... WHERE rowid=?\" works and does not corrupt the\n# index when it strikes a constraint. Both inside and outside a \n# transaction.\n#\nforeach {tn tcl1 tcl2}  {\n  1 {} {}\n\n  2 {\n    execsql BEGIN\n  } {\n    if {[sqlite3_get_autocommit db]==1} { error \"transaction rolled back!\" }\n    execsql COMMIT\n  }\n} {\n\n  do_execsql_test 3.$tn.0 {\n    DROP TABLE IF EXISTS ft2;\n    CREATE VIRTUAL TABLE ft2 USING fts5(content);\n    INSERT INTO ft2(rowid, content) VALUES(1, 'a b c');\n    INSERT INTO ft2(rowid, content) VALUES(2, 'a b d');\n    INSERT INTO ft2(rowid, content) VALUES(3, 'a b e');\n  }\n\n  eval $tcl1\n  foreach {tn2 sql content} {\n    1 { UPDATE ft2 SET rowid=2 WHERE rowid=1 }\n      { 1 {a b c} 2 {a b d} 3 {a b e} }\n\n    2 { \n      INSERT INTO ft2(rowid, content) VALUES(4, 'a b f');\n      UPDATE ft2 SET rowid=5 WHERE rowid=4;\n      UPDATE ft2 SET rowid=3 WHERE rowid=5;\n    } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    3 {\n      UPDATE ft2 SET rowid=3 WHERE rowid=4;           -- matches 0 rows\n      UPDATE ft2 SET rowid=2 WHERE rowid=3;\n    } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    4 {\n      INSERT INTO ft2(rowid, content) VALUES(4, 'a b g');\n      UPDATE ft2 SET rowid=-1 WHERE rowid=4;\n      UPDATE ft2 SET rowid=3 WHERE rowid=-1;\n    } {-1 {a b g} 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    5 {\n      DELETE FROM ft2 WHERE rowid=451;\n      DELETE FROM ft2 WHERE rowid=-1;\n      UPDATE ft2 SET rowid = 2 WHERE rowid = 1;\n    } {1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n  } {\n    do_catchsql_test 3.$tn.$tn2.a $sql {1 {constraint failed}}\n    do_execsql_test  3.$tn.$tn2.b { SELECT rowid, content FROM ft2 } $content\n\n    do_execsql_test  3.$tn.$tn2.c { \n      INSERT INTO ft2(ft2) VALUES('integrity-check');\n    }\n  }\n  eval $tcl2\n}\n\n#-------------------------------------------------------------------------\n# Check that DELETE and UPDATE operations can be done without flushing\n# the in-memory hash table to disk.\n#\nreset_db\ndo_execsql_test 4.1.1 {\n  CREATE VIRTUAL TABLE ttt USING fts5(x);\n  BEGIN;\n    INSERT INTO ttt(rowid, x) VALUES(1, 'a b c');\n    INSERT INTO ttt(rowid, x) VALUES(2, 'a b c');\n    INSERT INTO ttt(rowid, x) VALUES(3, 'a b c');\n  COMMIT\n}\ndo_test 4.1.2 { fts5_level_segs ttt } {1}\n\ndo_execsql_test 4.2.1 {\n  BEGIN;\n    DELETE FROM ttt WHERE rowid=1;\n    DELETE FROM ttt WHERE rowid=3;\n    INSERT INTO ttt(rowid, x) VALUES(4, 'd e f');\n    INSERT INTO ttt(rowid, x) VALUES(5, 'd e f');\n  COMMIT;\n} {}\ndo_test 4.2.2 { fts5_level_segs ttt } {2}\n\n\ndo_execsql_test 4.3.1 {\n  BEGIN;\n    UPDATE ttt SET x = 'd e f' WHERE rowid = 2;\n    UPDATE ttt SET x = 'A B C' WHERE rowid = 4;\n    INSERT INTO ttt(rowid, x) VALUES(6, 'd e f');\n  COMMIT;\n} {}\ndo_test 4.2.2 { fts5_level_segs ttt } {3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5optimize.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5optimize\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n#\n# 1.* - Warm body tests for index optimization using ('optimize')\n#\n# 2.* - Warm body tests for index optimization using ('merge', -1)\n#\n\nproc rnddoc {nWord} {\n  set vocab {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n  set nVocab [llength $vocab]\n  set ret [list]\n  for {set i 0} {$i < $nWord} {incr i} {\n    lappend ret [lindex $vocab [expr {int(rand() * $nVocab)}]]\n  }\n  return $ret\n}\n\nforeach {tn nStep} {\n  1 2\n  2 10\n  3 50\n  4 500\n} {\n  reset_db\n  db func rnddoc rnddoc\n  do_execsql_test 1.$tn.1 {\n    CREATE VIRTUAL TABLE t1 USING fts5(x, y);\n  }\n  do_test 1.$tn.2 {\n    for {set i 0} {$i < $nStep} {incr i} {\n      execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }\n    }\n  } {}\n\n  do_execsql_test 1.$tn.3 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  do_execsql_test 1.$tn.4 {\n    INSERT INTO t1(t1) VALUES('optimize');\n  }\n\n  do_execsql_test 1.$tn.5 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  do_test 1.$tn.6 { fts5_segcount t1 } 1\n}\n\nforeach {tn nStep} {\n  1 2\n  2 10\n  3 50\n  4 500\n} {\n  reset_db\n  db func rnddoc rnddoc\n  do_execsql_test 1.$tn.1 {\n    CREATE VIRTUAL TABLE t1 USING fts5(x, y);\n  }\n  do_test 2.$tn.2 {\n    for {set i 0} {$i < $nStep} {incr i} {\n      execsql { INSERT INTO t1 VALUES( rnddoc(5), rnddoc(5) ) }\n    }\n  } {}\n\n  do_execsql_test 2.$tn.3 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  do_test 2.$tn.4 {\n    execsql { INSERT INTO t1(t1, rank) VALUES('merge', -1) }\n    while 1 {\n      set c [db total_changes]\n      execsql { INSERT INTO t1(t1, rank) VALUES('merge', 1) }\n      set c [expr [db total_changes]-$c]\n      if {$c<2} break\n    }\n  } {}\n\n  do_execsql_test 2.$tn.5 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  do_test 2.$tn.6 { fts5_segcount t1 } 1\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5phrase.test",
    "content": "# 2014 Jan 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focused on phrase queries.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5phrase\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(a, b, c);\n  INSERT INTO t3 VALUES('d e a', 'd i j j f', 'i j i e b f h'); -- 1\n  INSERT INTO t3 VALUES('g a e', 'f g i g a', 'h d g i g h c'); -- 2\n  INSERT INTO t3 VALUES('e a d', 'e i h a f', 'c e h i f b i'); -- 3\n  INSERT INTO t3 VALUES('a g c', 'd j d j c', 'c d f j i g j'); -- 4\n  INSERT INTO t3 VALUES('b c b', 'j g c d f', 'j c j d g f b'); -- 5\n  INSERT INTO t3 VALUES('j a d', 'e b i h h', 'c c f g d i d'); -- 6\n  INSERT INTO t3 VALUES('a d f', 'h g i i i', 'e a g c i f b'); -- 7\n  INSERT INTO t3 VALUES('g f d', 'f c g b j', 'b b h h h j j'); -- 8\n  INSERT INTO t3 VALUES('f h g', 'c j f g j', 'd h d f e b h'); -- 9\n  INSERT INTO t3 VALUES('f h d', 'c i a d b', 'g b j b a d e'); -- 10\n  INSERT INTO t3 VALUES('j h h', 'j i h a g', 'd e i e a g j'); -- 11\n  INSERT INTO t3 VALUES('a b e', 'h g a g c', 'h c a a d e g'); -- 12\n  INSERT INTO t3 VALUES('a j g', 'i h i f i', 'a g h j g i b'); -- 13\n  INSERT INTO t3 VALUES('j h e', 'f e d i e', 'i d c f e d c'); -- 14\n  INSERT INTO t3 VALUES('d j d', 'd b i a c', 'g d h i d b e'); -- 15\n  INSERT INTO t3 VALUES('h j e', 'e b b c f', 'j a f g h d j'); -- 16\n  INSERT INTO t3 VALUES('c b j', 'c a b a i', 'h f i d a d c'); -- 17\n  INSERT INTO t3 VALUES('e e d', 'i d f c c', 'g i d a f e a'); -- 18\n  INSERT INTO t3 VALUES('e i g', 'e a b i h', 'i f d d a d f'); -- 19\n  INSERT INTO t3 VALUES('h g f', 'b h h j d', 'i f d e g j a'); -- 20\n  INSERT INTO t3 VALUES('e h f', 'j c b c f', 'j a j g h a c'); -- 21\n  INSERT INTO t3 VALUES('d c h', 'b g i c e', 'i i c d e h i'); -- 22\n  INSERT INTO t3 VALUES('a h i', 'a g d f f', 'e f i i b b h'); -- 23\n  INSERT INTO t3 VALUES('d d g', 'c c b c g', 'g c h e b c e'); -- 24\n  INSERT INTO t3 VALUES('a b b', 'b f a d i', 'd a h a b c i'); -- 25\n  INSERT INTO t3 VALUES('a f d', 'a j e a h', 'j i h j a i f'); -- 26\n  INSERT INTO t3 VALUES('d j d', 'h a d i a', 'h h f j h g a'); -- 27\n  INSERT INTO t3 VALUES('g a e', 'd g f a g', 'i d b c g g j'); -- 28\n  INSERT INTO t3 VALUES('j e h', 'g h j h g', 'd a e j a a h'); -- 29\n  INSERT INTO t3 VALUES('e j e', 'g e j g c', 'f c e b e e a'); -- 30\n  INSERT INTO t3 VALUES('h f f', 'i j g e c', 'j j f c a i j'); -- 31\n  INSERT INTO t3 VALUES('a g c', 'c g d b i', 'g h c b a a f'); -- 32\n  INSERT INTO t3 VALUES('c h i', 'j d h e e', 'a h i d c c j'); -- 33\n  INSERT INTO t3 VALUES('d a c', 'e d d b j', 'c e b b h i h'); -- 34\n  INSERT INTO t3 VALUES('d f h', 'c a f c c', 'j b b c c j f'); -- 35\n  INSERT INTO t3 VALUES('b g h', 'g c c c f', 'c g c f h e e'); -- 36\n  INSERT INTO t3 VALUES('f e a', 'b h f j h', 'j g h f d g f'); -- 37\n  INSERT INTO t3 VALUES('h f a', 'a e i j g', 'f d a f d f c'); -- 38\n  INSERT INTO t3 VALUES('f i c', 'f i i i i', 'e c f d h j f'); -- 39\n  INSERT INTO t3 VALUES('h h d', 'd i e d i', 'd f e i a h a'); -- 40\n  INSERT INTO t3 VALUES('f g c', 'd a f c h', 'b b g j c e g'); -- 41\n  INSERT INTO t3 VALUES('h i h', 'h d j d e', 'e d b b i e g'); -- 42\n  INSERT INTO t3 VALUES('b h i', 'j e i d a', 'j j h e e c a'); -- 43\n  INSERT INTO t3 VALUES('g i g', 'f c c f d', 'a c i c a d a'); -- 44\n  INSERT INTO t3 VALUES('c c f', 'a b j d b', 'c a e g f e c'); -- 45\n  INSERT INTO t3 VALUES('d h j', 'g c b j d', 'e a h f h j g'); -- 46\n  INSERT INTO t3 VALUES('a a d', 'j e j a i', 'i d c f f f b'); -- 47\n  INSERT INTO t3 VALUES('b g j', 'e c i h f', 'd d h b g a d'); -- 48\n  INSERT INTO t3 VALUES('c i a', 'a c c c c', 'e h i e h i e'); -- 49\n  INSERT INTO t3 VALUES('f f c', 'f f b i i', 'f f a j e c i'); -- 50\n}\n\nproc pmatch {col expr} {\n  return [expr {[string first $expr $col]>=0}]\n}\ndb func pmatch pmatch\n\nforeach {tn cols tokens} {\n  1 a         \"c c\"\n  2 b         \"c c\"\n  3 c         \"c c\"\n  4 {a b c}   \"c c\"\n  5 {a b c}   \"b h\"\n  6 {a b}     \"b h\"\n  7 {a c}     \"b h\"\n  8 {c a}     \"b h\"\n  9 {c}       \"i e\"\n  10 {b}      \"i e\"\n  11 {a}      \"i e\"\n} {\n  set fts   \"{$cols}:[join $tokens +]\"\n  set where [list]\n  foreach c $cols { lappend where \"pmatch($c, '$tokens')\" }\n  set where [join $where \" OR \"]\n\n  set res [db eval \"SELECT rowid FROM t3 WHERE $where\"]\n  do_execsql_test \"1.$tn.$fts->([llength $res] rows)\" { \n    SELECT rowid FROM t3($fts) \n  } $res\n}\n\ndo_execsql_test 2.0 {\n  SELECT rowid,\n    highlight(t3, 0, '*', '*'),\n    highlight(t3, 1, '*', '*'),\n    highlight(t3, 2, '*', '*')\n  FROM t3('a:f+f')\n} {\n  31 {h *f f*} {i j g e c} {j j f c a i j} \n  50 {*f f* c} {f f b i i} {f f a j e c i}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5plan.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file focuses on testing the planner (xBestIndex function).\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5plan\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y);\n  CREATE VIRTUAL TABLE f1 USING fts5(ff);\n}\n\ndo_eqp_test 1.1 {\n  SELECT * FROM t1, f1 WHERE f1 MATCH t1.x\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SCAN TABLE f1 VIRTUAL TABLE INDEX 65537:}\n}\n\ndo_eqp_test 1.2 {\n  SELECT * FROM t1, f1 WHERE f1 > t1.x\n} {\n  0 0 1 {SCAN TABLE f1 VIRTUAL TABLE INDEX 0:}\n  0 1 0 {SCAN TABLE t1} \n}\n\ndo_eqp_test 1.3 {\n  SELECT * FROM f1 WHERE f1 MATCH ? ORDER BY ff\n} {\n  0 0 0 {SCAN TABLE f1 VIRTUAL TABLE INDEX 65537:}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\ndo_eqp_test 1.4 {\n  SELECT * FROM f1 ORDER BY rank\n} {\n  0 0 0 {SCAN TABLE f1 VIRTUAL TABLE INDEX 0:}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\ndo_eqp_test 1.5 {\n  SELECT * FROM f1 WHERE rank MATCH ?\n} {\n  0 0 0 {SCAN TABLE f1 VIRTUAL TABLE INDEX 2:}\n}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5porter.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the fts5 porter stemmer implementation.\n#\n#   http://tartarus.org/martin/PorterStemmer/\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5porter\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nset test_vocab {\n  a               a               aaron           aaron          \n  abaissiez       abaissiez       abandon         abandon        \n  abandoned       abandon         abase           abas           \n  abash           abash           abate           abat           \n  abated          abat            abatement       abat           \n  abatements      abat            abates          abat           \n  abbess          abbess          abbey           abbei          \n  abbeys          abbei           abbominable     abbomin        \n  abbot           abbot           abbots          abbot          \n  abbreviated     abbrevi         abed            ab             \n  abel            abel            aberga          aberga         \n  abergavenny     abergavenni     abet            abet           \n  abetting        abet            abhominable     abhomin        \n  abhor           abhor           abhorr          abhorr         \n  abhorred        abhor           abhorring       abhor          \n  abhors          abhor           abhorson        abhorson       \n  abide           abid            abides          abid           \n  abilities       abil            ability         abil           \n  abject          abject          abjectly        abjectli       \n  abjects         abject          abjur           abjur          \n  abjure          abjur           able            abl            \n  abler           abler           aboard          aboard         \n  abode           abod            aboded          abod           \n  abodements      abod            aboding         abod           \n  abominable      abomin          abominably      abomin         \n  abominations    abomin          abortive        abort          \n  abortives       abort           abound          abound         \n  abounding       abound          about           about          \n  above           abov            abr             abr            \n  abraham         abraham         abram           abram          \n  abreast         abreast         abridg          abridg         \n  abridge         abridg          abridged        abridg         \n  abridgment      abridg          abroach         abroach        \n  abroad          abroad          abrogate        abrog          \n  abrook          abrook          abrupt          abrupt         \n  abruption       abrupt          abruptly        abruptli       \n  absence         absenc          absent          absent         \n  absey           absei           absolute        absolut        \n  absolutely      absolut         absolv          absolv         \n  absolver        absolv          abstains        abstain        \n  abstemious      abstemi         abstinence      abstin         \n  abstract        abstract        absurd          absurd         \n  absyrtus        absyrtu         abundance       abund          \n  abundant        abund           abundantly      abundantli     \n  abus            abu             abuse           abus           \n  abused          abus            abuser          abus           \n  abuses          abus            abusing         abus           \n  abutting        abut            aby             abi            \n  abysm           abysm           ac              ac             \n  academe         academ          academes        academ         \n  accent          accent          accents         accent         \n  accept          accept          acceptable      accept         \n  acceptance      accept          accepted        accept         \n  accepts         accept          access          access         \n  accessary       accessari       accessible      access         \n  accidence       accid           accident        accid          \n  accidental      accident        accidentally    accident       \n  accidents       accid           accite          accit          \n  accited         accit           accites         accit          \n  acclamations    acclam          accommodate     accommod       \n  accommodated    accommod        accommodation   accommod       \n  accommodations  accommod        accommodo       accommodo      \n  accompanied     accompani       accompany       accompani      \n  accompanying    accompani       accomplices     accomplic      \n  accomplish      accomplish      accomplished    accomplish     \n  accomplishing   accomplish      accomplishment  accomplish     \n  accompt         accompt         accord          accord         \n  accordant       accord          accorded        accord         \n  accordeth       accordeth       according       accord         \n  accordingly     accordingli     accords         accord         \n  accost          accost          accosted        accost         \n  account         account         accountant      account        \n  accounted       account         accounts        account        \n  accoutred       accoutr         accoutrement    accoutr        \n  accoutrements   accoutr         accrue          accru          \n  accumulate      accumul         accumulated     accumul        \n  accumulation    accumul         accurs          accur          \n  accursed        accurs          accurst         accurst        \n  accus           accu            accusation      accus          \n  accusations     accus           accusative      accus          \n  accusativo      accusativo      accuse          accus          \n  accused         accus           accuser         accus          \n  accusers        accus           accuses         accus          \n  accuseth        accuseth        accusing        accus          \n  accustom        accustom        accustomed      accustom       \n  ace             ac              acerb           acerb          \n  ache            ach             acheron         acheron        \n  aches           ach             achiev          achiev         \n  achieve         achiev          achieved        achiev         \n  achievement     achiev          achievements    achiev         \n  achiever        achiev          achieves        achiev         \n  achieving       achiev          achilles        achil          \n  aching          ach             achitophel      achitophel     \n  acknowledg      acknowledg      acknowledge     acknowledg     \n  acknowledged    acknowledg      acknowledgment  acknowledg     \n  acknown         acknown         acold           acold          \n  aconitum        aconitum        acordo          acordo         \n  acorn           acorn           acquaint        acquaint       \n  acquaintance    acquaint        acquainted      acquaint       \n  acquaints       acquaint        acquir          acquir         \n  acquire         acquir          acquisition     acquisit       \n  acquit          acquit          acquittance     acquitt        \n  acquittances    acquitt         acquitted       acquit         \n  acre            acr             acres           acr            \n  across          across          act             act            \n  actaeon         actaeon         acted           act            \n  acting          act             action          action         \n  actions         action          actium          actium         \n  active          activ           actively        activ          \n  activity        activ           actor           actor          \n  actors          actor           acts            act            \n  actual          actual          acture          actur          \n  acute           acut            acutely         acut           \n  ad              ad              adage           adag           \n  adallas         adalla          adam            adam           \n  adamant         adam            add             add            \n  added           ad              adder           adder          \n  adders          adder           addeth          addeth         \n  addict          addict          addicted        addict         \n  addiction       addict          adding          ad             \n  addition        addit           additions       addit          \n  addle           addl            address         address        \n  addressing      address         addrest         addrest        \n  adds            add             adhere          adher          \n  adheres         adher           adieu           adieu          \n  adieus          adieu           adjacent        adjac          \n  adjoin          adjoin          adjoining       adjoin         \n  adjourn         adjourn         adjudg          adjudg         \n  adjudged        adjudg          adjunct         adjunct        \n  administer      administ        administration  administr      \n  admir           admir           admirable       admir          \n  admiral         admir           admiration      admir          \n  admire          admir           admired         admir          \n  admirer         admir           admiring        admir          \n  admiringly      admiringli      admission       admiss         \n  admit           admit           admits          admit          \n  admittance      admitt          admitted        admit          \n  admitting       admit           admonish        admonish       \n  admonishing     admonish        admonishment    admonish       \n  admonishments   admonish        admonition      admonit        \n  ado             ado             adonis          adoni          \n  adopt           adopt           adopted         adopt          \n  adoptedly       adoptedli       adoption        adopt          \n  adoptious       adopti          adopts          adopt          \n  ador            ador            adoration       ador           \n  adorations      ador            adore           ador           \n  adorer          ador            adores          ador           \n  adorest         adorest         adoreth         adoreth        \n  adoring         ador            adorn           adorn          \n  adorned         adorn           adornings       adorn          \n  adornment       adorn           adorns          adorn          \n  adown           adown           adramadio       adramadio      \n  adrian          adrian          adriana         adriana        \n  adriano         adriano         adriatic        adriat         \n  adsum           adsum           adulation       adul           \n  adulterate      adulter         adulterates     adulter        \n  adulterers      adulter         adulteress      adulteress     \n  adulteries      adulteri        adulterous      adulter        \n  adultery        adulteri        adultress       adultress      \n  advanc          advanc          advance         advanc         \n  advanced        advanc          advancement     advanc         \n  advancements    advanc          advances        advanc         \n  advancing       advanc          advantage       advantag       \n  advantageable   advantag        advantaged      advantag       \n  advantageous    advantag        advantages      advantag       \n  advantaging     advantag        advent          advent         \n  adventur        adventur        adventure       adventur       \n  adventures      adventur        adventuring     adventur       \n  adventurous     adventur        adventurously   adventur       \n  adversaries     adversari       adversary       adversari      \n  adverse         advers          adversely       advers         \n  adversities     advers          adversity       advers         \n  advertis        adverti         advertise       advertis       \n  advertised      advertis        advertisement   advertis       \n  advertising     advertis        advice          advic          \n  advis           advi            advise          advis          \n  advised         advis           advisedly       advisedli      \n  advises         advis           advisings       advis          \n  advocate        advoc           advocation      advoc          \n  aeacida         aeacida         aeacides        aeacid         \n  aedile          aedil           aediles         aedil          \n  aegeon          aegeon          aegion          aegion         \n  aegles          aegl            aemelia         aemelia        \n  aemilia         aemilia         aemilius        aemiliu        \n  aeneas          aenea           aeolus          aeolu          \n  aer             aer             aerial          aerial         \n  aery            aeri            aesculapius     aesculapiu     \n  aeson           aeson           aesop           aesop          \n  aetna           aetna           afar            afar           \n  afear           afear           afeard          afeard         \n  affability      affabl          affable         affabl         \n  affair          affair          affaire         affair         \n  affairs         affair          affect          affect         \n  affectation     affect          affectations    affect         \n  affected        affect          affectedly      affectedli     \n  affecteth       affecteth       affecting       affect         \n  affection       affect          affectionate    affection      \n  affectionately  affection       affections      affect         \n  affects         affect          affeer          affeer         \n  affianc         affianc         affiance        affianc        \n  affianced       affianc         affied          affi           \n  affin           affin           affined         affin          \n  affinity        affin           affirm          affirm         \n  affirmation     affirm          affirmatives    affirm         \n  afflict         afflict         afflicted       afflict        \n  affliction      afflict         afflictions     afflict        \n  afflicts        afflict         afford          afford         \n  affordeth       affordeth       affords         afford         \n  affray          affrai          affright        affright       \n  affrighted      affright        affrights       affright       \n  affront         affront         affronted       affront        \n  affy            affi            afield          afield         \n  afire           afir            afloat          afloat         \n  afoot           afoot           afore           afor           \n  aforehand       aforehand       aforesaid       aforesaid      \n  afraid          afraid          afresh          afresh         \n  afric           afric           africa          africa         \n  african         african         afront          afront         \n  after           after           afternoon       afternoon      \n  afterward       afterward       afterwards      afterward      \n  ag              ag              again           again          \n  against         against         agamemmon       agamemmon      \n  agamemnon       agamemnon       agate           agat           \n  agaz            agaz            age             ag             \n  aged            ag              agenor          agenor         \n  agent           agent           agents          agent          \n  ages            ag              aggravate       aggrav         \n  aggrief         aggrief         agile           agil           \n  agincourt       agincourt       agitation       agit           \n  aglet           aglet           agnize          agniz          \n  ago             ago             agone           agon           \n  agony           agoni           agree           agre           \n  agreed          agre            agreeing        agre           \n  agreement       agreement       agrees          agre           \n  agrippa         agrippa         aground         aground        \n  ague            agu             aguecheek       aguecheek      \n  agued           agu             agueface        aguefac        \n  agues           agu             ah              ah             \n  aha             aha             ahungry         ahungri        \n  ai              ai              aialvolio       aialvolio      \n  aiaria          aiaria          aid             aid            \n  aidance         aidanc          aidant          aidant         \n  aided           aid             aiding          aid            \n  aidless         aidless         aids            aid            \n  ail             ail             aim             aim            \n  aimed           aim             aimest          aimest         \n  aiming          aim             aims            aim            \n  ainsi           ainsi           aio             aio            \n  air             air             aired           air            \n  airless         airless         airs            air            \n  airy            airi            ajax            ajax           \n  akilling        akil            al              al             \n  alabaster       alabast         alack           alack          \n  alacrity        alacr           alarbus         alarbu         \n  alarm           alarm           alarms          alarm          \n  alarum          alarum          alarums         alarum         \n  alas            ala             alb             alb            \n  alban           alban           albans          alban          \n  albany          albani          albeit          albeit         \n  albion          albion          alchemist       alchemist      \n  alchemy         alchemi         alcibiades      alcibiad       \n  alcides         alcid           alder           alder          \n  alderman        alderman        aldermen        aldermen       \n  ale             al              alecto          alecto         \n  alehouse        alehous         alehouses       alehous        \n  alencon         alencon         alengon         alengon        \n  aleppo          aleppo          ales            al             \n  alewife         alewif          alexander       alexand        \n  alexanders      alexand         alexandria      alexandria     \n  alexandrian     alexandrian     alexas          alexa          \n  alias           alia            alice           alic           \n  alien           alien           aliena          aliena         \n  alight          alight          alighted        alight         \n  alights         alight          aliis           alii           \n  alike           alik            alisander       alisand        \n  alive           aliv            all             all            \n  alla            alla            allay           allai          \n  allayed         allai           allaying        allai          \n  allayment       allay           allayments      allay          \n  allays          allai           allegation      alleg          \n  allegations     alleg           allege          alleg          \n  alleged         alleg           allegiance      allegi         \n  allegiant       allegi          alley           allei          \n  alleys          allei           allhallowmas    allhallowma    \n  alliance        allianc         allicholy       allicholi      \n  allied          alli            allies          alli           \n  alligant        allig           alligator       allig          \n  allons          allon           allot           allot          \n  allots          allot           allotted        allot          \n  allottery       allotteri       allow           allow          \n  allowance       allow           allowed         allow          \n  allowing        allow           allows          allow          \n  allur           allur           allure          allur          \n  allurement      allur           alluring        allur          \n  allusion        allus           ally            alli           \n  allycholly      allycholli      almain          almain         \n  almanac         almanac         almanack        almanack       \n  almanacs        almanac         almighty        almighti       \n  almond          almond          almost          almost         \n  alms            alm             almsman         almsman        \n  aloes           alo             aloft           aloft          \n  alone           alon            along           along          \n  alonso          alonso          aloof           aloof          \n  aloud           aloud           alphabet        alphabet       \n  alphabetical    alphabet        alphonso        alphonso       \n  alps            alp             already         alreadi        \n  also            also            alt             alt            \n  altar           altar           altars          altar          \n  alter           alter           alteration      alter          \n  altered         alter           alters          alter          \n  althaea         althaea         although        although       \n  altitude        altitud         altogether      altogeth       \n  alton           alton           alway           alwai          \n  always          alwai           am              am             \n  amaimon         amaimon         amain           amain          \n  amaking         amak            amamon          amamon         \n  amaz            amaz            amaze           amaz           \n  amazed          amaz            amazedly        amazedli       \n  amazedness      amazed          amazement       amaz           \n  amazes          amaz            amazeth         amazeth        \n  amazing         amaz            amazon          amazon         \n  amazonian       amazonian       amazons         amazon         \n  ambassador      ambassador      ambassadors     ambassador     \n  amber           amber           ambiguides      ambiguid       \n  ambiguities     ambigu          ambiguous       ambigu         \n  ambition        ambit           ambitions       ambit          \n  ambitious       ambiti          ambitiously     ambiti         \n  amble           ambl            ambled          ambl           \n  ambles          ambl            ambling         ambl           \n  ambo            ambo            ambuscadoes     ambuscado      \n  ambush          ambush          amen            amen           \n  amend           amend           amended         amend          \n  amendment       amend           amends          amend          \n  amerce          amerc           america         america        \n  ames            am              amiable         amiabl         \n  amid            amid            amidst          amidst         \n  amiens          amien           amis            ami            \n  amiss           amiss           amities         amiti          \n  amity           amiti           amnipotent      amnipot        \n  among           among           amongst         amongst        \n  amorous         amor            amorously       amor           \n  amort           amort           amount          amount         \n  amounts         amount          amour           amour          \n  amphimacus      amphimacu       ample           ampl           \n  ampler          ampler          amplest         amplest        \n  amplified       amplifi         amplify         amplifi        \n  amply           ampli           ampthill        ampthil        \n  amurath         amurath         amyntas         amynta         \n  an              an              anatomiz        anatomiz       \n  anatomize       anatom          anatomy         anatomi        \n  ancestor        ancestor        ancestors       ancestor       \n  ancestry        ancestri        anchises        anchis         \n  anchor          anchor          anchorage       anchorag       \n  anchored        anchor          anchoring       anchor         \n  anchors         anchor          anchovies       anchovi        \n  ancient         ancient         ancientry       ancientri      \n  ancients        ancient         ancus           ancu           \n  and             and             andirons        andiron        \n  andpholus       andpholu        andren          andren         \n  andrew          andrew          andromache      andromach      \n  andronici       andronici       andronicus      andronicu      \n  anew            anew            ang             ang            \n  angel           angel           angelica        angelica       \n  angelical       angel           angelo          angelo         \n  angels          angel           anger           anger          \n  angerly         angerli         angers          anger          \n  anges           ang             angiers         angier         \n  angl            angl            anglais         anglai         \n  angle           angl            angler          angler         \n  angleterre      angleterr       angliae         anglia         \n  angling         angl            anglish         anglish        \n  angrily         angrili         angry           angri          \n  anguish         anguish         angus           angu           \n  animal          anim            animals         anim           \n  animis          animi           anjou           anjou          \n  ankle           ankl            anna            anna           \n  annals          annal           anne            ann            \n  annex           annex           annexed         annex          \n  annexions       annexion        annexment       annex          \n  annothanize     annothan        announces       announc        \n  annoy           annoi           annoyance       annoy          \n  annoying        annoi           annual          annual         \n  anoint          anoint          anointed        anoint         \n  anon            anon            another         anoth          \n  anselmo         anselmo         answer          answer         \n  answerable      answer          answered        answer         \n  answerest       answerest       answering       answer         \n  answers         answer          ant             ant            \n  ante            ant             antenor         antenor        \n  antenorides     antenorid       anteroom        anteroom       \n  anthem          anthem          anthems         anthem         \n  anthony         anthoni         anthropophagi   anthropophagi  \n  anthropophaginian anthropophaginian antiates        antiat         \n  antic           antic           anticipate      anticip        \n  anticipates     anticip         anticipatest    anticipatest   \n  anticipating    anticip         anticipation    anticip        \n  antick          antick          anticly         anticli        \n  antics          antic           antidote        antidot        \n  antidotes       antidot         antigonus       antigonu       \n  antiopa         antiopa         antipathy       antipathi      \n  antipholus      antipholu       antipholuses    antipholus     \n  antipodes       antipod         antiquary       antiquari      \n  antique         antiqu          antiquity       antiqu         \n  antium          antium          antoniad        antoniad       \n  antonio         antonio         antonius        antoniu        \n  antony          antoni          antres          antr           \n  anvil           anvil           any             ani            \n  anybody         anybodi         anyone          anyon          \n  anything        anyth           anywhere        anywher        \n  ap              ap              apace           apac           \n  apart           apart           apartment       apart          \n  apartments      apart           ape             ap             \n  apemantus       apemantu        apennines       apennin        \n  apes            ap              apiece          apiec          \n  apish           apish           apollinem       apollinem      \n  apollo          apollo          apollodorus     apollodoru     \n  apology         apolog          apoplex         apoplex        \n  apoplexy        apoplexi        apostle         apostl         \n  apostles        apostl          apostrophas     apostropha     \n  apoth           apoth           apothecary      apothecari     \n  appal           appal           appall          appal          \n  appalled        appal           appals          appal          \n  apparel         apparel         apparell        apparel        \n  apparelled      apparel         apparent        appar          \n  apparently      appar           apparition      apparit        \n  apparitions     apparit         appeach         appeach        \n  appeal          appeal          appeals         appeal         \n  appear          appear          appearance      appear         \n  appeared        appear          appeareth       appeareth      \n  appearing       appear          appears         appear         \n  appeas          appea           appease         appeas         \n  appeased        appeas          appelant        appel          \n  appele          appel           appelee         appele         \n  appeles         appel           appelez         appelez        \n  appellant       appel           appellants      appel          \n  appelons        appelon         appendix        appendix       \n  apperil         apperil         appertain       appertain      \n  appertaining    appertain       appertainings   appertain      \n  appertains      appertain       appertinent     appertin       \n  appertinents    appertin        appetite        appetit        \n  appetites       appetit         applaud         applaud        \n  applauded       applaud         applauding      applaud        \n  applause        applaus         applauses       applaus        \n  apple           appl            apples          appl           \n  appletart       appletart       appliance       applianc       \n  appliances      applianc        applications    applic         \n  applied         appli           applies         appli          \n  apply           appli           applying        appli          \n  appoint         appoint         appointed       appoint        \n  appointment     appoint         appointments    appoint        \n  appoints        appoint         apprehend       apprehend      \n  apprehended     apprehend       apprehends      apprehend      \n  apprehension    apprehens       apprehensions   apprehens      \n  apprehensive    apprehens       apprendre       apprendr       \n  apprenne        apprenn         apprenticehood  apprenticehood \n  appris          appri           approach        approach       \n  approachers     approach        approaches      approach       \n  approacheth     approacheth     approaching     approach       \n  approbation     approb          approof         approof        \n  appropriation   appropri        approv          approv         \n  approve         approv          approved        approv         \n  approvers       approv          approves        approv         \n  appurtenance    appurten        appurtenances   appurten       \n  apricocks       apricock        april           april          \n  apron           apron           aprons          apron          \n  apt             apt             apter           apter          \n  aptest          aptest          aptly           aptli          \n  aptness         apt             aqua            aqua           \n  aquilon         aquilon         aquitaine       aquitain       \n  arabia          arabia          arabian         arabian        \n  araise          arais           arbitrate       arbitr         \n  arbitrating     arbitr          arbitrator      arbitr         \n  arbitrement     arbitr          arbors          arbor          \n  arbour          arbour          arc             arc            \n  arch            arch            archbishop      archbishop     \n  archbishopric   archbishopr     archdeacon      archdeacon     \n  arched          arch            archelaus       archelau       \n  archer          archer          archers         archer         \n  archery         archeri         archibald       archibald      \n  archidamus      archidamu       architect       architect      \n  arcu            arcu            arde            ard            \n  arden           arden           ardent          ardent         \n  ardour          ardour          are             ar             \n  argal           argal           argier          argier         \n  argo            argo            argosies        argosi         \n  argosy          argosi          argu            argu           \n  argue           argu            argued          argu           \n  argues          argu            arguing         argu           \n  argument        argument        arguments       argument       \n  argus           argu            ariachne        ariachn        \n  ariadne         ariadn          ariel           ariel          \n  aries           ari             aright          aright         \n  arinado         arinado         arinies         arini          \n  arion           arion           arise           aris           \n  arises          aris            ariseth         ariseth        \n  arising         aris            aristode        aristod        \n  aristotle       aristotl        arithmetic      arithmet       \n  arithmetician   arithmetician   ark             ark            \n  arm             arm             arma            arma           \n  armado          armado          armadoes        armado         \n  armagnac        armagnac        arme            arm            \n  armed           arm             armenia         armenia        \n  armies          armi            armigero        armigero       \n  arming          arm             armipotent      armipot        \n  armor           armor           armour          armour         \n  armourer        armour          armourers       armour         \n  armours         armour          armoury         armouri        \n  arms            arm             army            armi           \n  arn             arn             aroint          aroint         \n  arose           aros            arouse          arous          \n  aroused         arous           arragon         arragon        \n  arraign         arraign         arraigned       arraign        \n  arraigning      arraign         arraignment     arraign        \n  arrant          arrant          arras           arra           \n  array           arrai           arrearages      arrearag       \n  arrest          arrest          arrested        arrest         \n  arrests         arrest          arriv           arriv          \n  arrival         arriv           arrivance       arriv          \n  arrive          arriv           arrived         arriv          \n  arrives         arriv           arriving        arriv          \n  arrogance       arrog           arrogancy       arrog          \n  arrogant        arrog           arrow           arrow          \n  arrows          arrow           art             art            \n  artemidorus     artemidoru      arteries        arteri         \n  arthur          arthur          article         articl         \n  articles        articl          articulate      articul        \n  artificer       artific         artificial      artifici       \n  artillery       artilleri       artire          artir          \n  artist          artist          artists         artist         \n  artless         artless         artois          artoi          \n  arts            art             artus           artu           \n  arviragus       arviragu        as              as             \n  asaph           asaph           ascanius        ascaniu        \n  ascend          ascend          ascended        ascend         \n  ascendeth       ascendeth       ascends         ascend         \n  ascension       ascens          ascent          ascent         \n  ascribe         ascrib          ascribes        ascrib         \n  ash             ash             asham           asham          \n  ashamed         asham           asher           asher          \n  ashes           ash             ashford         ashford        \n  ashore          ashor           ashouting       ashout         \n  ashy            ashi            asia            asia           \n  aside           asid            ask             ask            \n  askance         askanc          asked           ask            \n  asker           asker           asketh          asketh         \n  asking          ask             asks            ask            \n  aslant          aslant          asleep          asleep         \n  asmath          asmath          asp             asp            \n  aspect          aspect          aspects         aspect         \n  aspen           aspen           aspersion       aspers         \n  aspic           aspic           aspicious       aspici         \n  aspics          aspic           aspir           aspir          \n  aspiration      aspir           aspire          aspir          \n  aspiring        aspir           asquint         asquint        \n  ass             ass             assail          assail         \n  assailable      assail          assailant       assail         \n  assailants      assail          assailed        assail         \n  assaileth       assaileth       assailing       assail         \n  assails         assail          assassination   assassin       \n  assault         assault         assaulted       assault        \n  assaults        assault         assay           assai          \n  assaying        assai           assays          assai          \n  assemblance     assembl         assemble        assembl        \n  assembled       assembl         assemblies      assembl        \n  assembly        assembl         assent          assent         \n  asses           ass             assez           assez          \n  assign          assign          assigned        assign         \n  assigns         assign          assinico        assinico       \n  assist          assist          assistance      assist         \n  assistances     assist          assistant       assist         \n  assistants      assist          assisted        assist         \n  assisting       assist          associate       associ         \n  associated      associ          associates      associ         \n  assuage         assuag          assubjugate     assubjug       \n  assum           assum           assume          assum          \n  assumes         assum           assumption      assumpt        \n  assur           assur           assurance       assur          \n  assure          assur           assured         assur          \n  assuredly       assuredli       assures         assur          \n  assyrian        assyrian        astonish        astonish       \n  astonished      astonish        astraea         astraea        \n  astray          astrai          astrea          astrea         \n  astronomer      astronom        astronomers     astronom       \n  astronomical    astronom        astronomy       astronomi      \n  asunder         asund           at              at             \n  atalanta        atalanta        ate             at             \n  ates            at              athenian        athenian       \n  athenians       athenian        athens          athen          \n  athol           athol           athversary      athversari     \n  athwart         athwart         atlas           atla           \n  atomies         atomi           atomy           atomi          \n  atone           aton            atonement       aton           \n  atonements      aton            atropos         atropo         \n  attach          attach          attached        attach         \n  attachment      attach          attain          attain         \n  attainder       attaind         attains         attain         \n  attaint         attaint         attainted       attaint        \n  attainture      attaintur       attempt         attempt        \n  attemptable     attempt         attempted       attempt        \n  attempting      attempt         attempts        attempt        \n  attend          attend          attendance      attend         \n  attendant       attend          attendants      attend         \n  attended        attend          attendents      attend         \n  attendeth       attendeth       attending       attend         \n  attends         attend          attent          attent         \n  attention       attent          attentive       attent         \n  attentivenes    attentiven      attest          attest         \n  attested        attest          attir           attir          \n  attire          attir           attired         attir          \n  attires         attir           attorney        attornei       \n  attorneyed      attornei        attorneys       attornei       \n  attorneyship    attorneyship    attract         attract        \n  attraction      attract         attractive      attract        \n  attracts        attract         attribute       attribut       \n  attributed      attribut        attributes      attribut       \n  attribution     attribut        attributive     attribut       \n  atwain          atwain          au              au             \n  aubrey          aubrei          auburn          auburn         \n  aucun           aucun           audacious       audaci         \n  audaciously     audaci          audacity        audac          \n  audible         audibl          audience        audienc        \n  audis           audi            audit           audit          \n  auditor         auditor         auditors        auditor        \n  auditory        auditori        audre           audr           \n  audrey          audrei          aufidius        aufidiu        \n  aufidiuses      aufidius        auger           auger          \n  aught           aught           augment         augment        \n  augmentation    augment         augmented       augment        \n  augmenting      augment         augurer         augur          \n  augurers        augur           augures         augur          \n  auguring        augur           augurs          augur          \n  augury          auguri          august          august         \n  augustus        augustu         auld            auld           \n  aumerle         aumerl          aunchient       aunchient      \n  aunt            aunt            aunts           aunt           \n  auricular       auricular       aurora          aurora         \n  auspicious      auspici         aussi           aussi          \n  austere         auster          austerely       auster         \n  austereness     auster          austerity       auster         \n  austria         austria         aut             aut            \n  authentic       authent         author          author         \n  authorities     author          authority       author         \n  authorized      author          authorizing     author         \n  authors         author          autolycus       autolycu       \n  autre           autr            autumn          autumn         \n  auvergne        auvergn         avail           avail          \n  avails          avail           avarice         avaric         \n  avaricious      avarici         avaunt          avaunt         \n  ave             av              aveng           aveng          \n  avenge          aveng           avenged         aveng          \n  averring        aver            avert           avert          \n  aves            av              avez            avez           \n  avis            avi             avoid           avoid          \n  avoided         avoid           avoiding        avoid          \n  avoids          avoid           avoirdupois     avoirdupoi     \n  avouch          avouch          avouched        avouch         \n  avouches        avouch          avouchment      avouch         \n  avow            avow            aw              aw             \n  await           await           awaits          await          \n  awak            awak            awake           awak           \n  awaked          awak            awaken          awaken         \n  awakened        awaken          awakens         awaken         \n  awakes          awak            awaking         awak           \n  award           award           awards          award          \n  awasy           awasi           away            awai           \n  awe             aw              aweary          aweari         \n  aweless         aweless         awful           aw             \n  awhile          awhil           awkward         awkward        \n  awl             awl             awooing         awoo           \n  awork           awork           awry            awri           \n  axe             ax              axle            axl            \n  axletree        axletre         ay              ay             \n  aye             ay              ayez            ayez           \n  ayli            ayli            azur            azur           \n  azure           azur            b               b              \n  ba              ba              baa             baa            \n  babbl           babbl           babble          babbl          \n  babbling        babbl           babe            babe           \n  babes           babe            babies          babi           \n  baboon          baboon          baboons         baboon         \n  baby            babi            babylon         babylon        \n  bacare          bacar           bacchanals      bacchan        \n  bacchus         bacchu          bach            bach           \n  bachelor        bachelor        bachelors       bachelor       \n  back            back            backbite        backbit        \n  backbitten      backbitten      backing         back           \n  backs           back            backward        backward       \n  backwardly      backwardli      backwards       backward       \n  bacon           bacon           bacons          bacon          \n  bad             bad             bade            bade           \n  badge           badg            badged          badg           \n  badges          badg            badly           badli          \n  badness         bad             baes            bae            \n  baffl           baffl           baffle          baffl          \n  baffled         baffl           bag             bag            \n  baggage         baggag          bagot           bagot          \n  bagpipe         bagpip          bags            bag            \n  bail            bail            bailiff         bailiff        \n  baillez         baillez         baily           baili          \n  baisant         baisant         baisees         baise          \n  baiser          baiser          bait            bait           \n  baited          bait            baiting         bait           \n  baitings        bait            baits           bait           \n  bajazet         bajazet         bak             bak            \n  bake            bake            baked           bake           \n  baker           baker           bakers          baker          \n  bakes           bake            baking          bake           \n  bal             bal             balanc          balanc         \n  balance         balanc          balcony         balconi        \n  bald            bald            baldrick        baldrick       \n  bale            bale            baleful         bale           \n  balk            balk            ball            ball           \n  ballad          ballad          ballads         ballad         \n  ballast         ballast         ballasting      ballast        \n  ballet          ballet          ballow          ballow         \n  balls           ball            balm            balm           \n  balms           balm            balmy           balmi          \n  balsam          balsam          balsamum        balsamum       \n  balth           balth           balthasar       balthasar      \n  balthazar       balthazar       bames           bame           \n  ban             ban             banbury         banburi        \n  band            band            bandied         bandi          \n  banding         band            bandit          bandit         \n  banditti        banditti        banditto        banditto       \n  bands           band            bandy           bandi          \n  bandying        bandi           bane            bane           \n  banes           bane            bang            bang           \n  bangor          bangor          banish          banish         \n  banished        banish          banishers       banish         \n  banishment      banish          banister        banist         \n  bank            bank            bankrout        bankrout       \n  bankrupt        bankrupt        bankrupts       bankrupt       \n  banks           bank            banner          banner         \n  bannerets       banneret        banners         banner         \n  banning         ban             banns           bann           \n  banquet         banquet         banqueted       banquet        \n  banqueting      banquet         banquets        banquet        \n  banquo          banquo          bans            ban            \n  baptism         baptism         baptista        baptista       \n  baptiz          baptiz          bar             bar            \n  barbarian       barbarian       barbarians      barbarian      \n  barbarism       barbar          barbarous       barbar         \n  barbary         barbari         barbason        barbason       \n  barbed          barb            barber          barber         \n  barbermonger    barbermong      bard            bard           \n  bardolph        bardolph        bards           bard           \n  bare            bare            bared           bare           \n  barefac         barefac         barefaced       barefac        \n  barefoot        barefoot        bareheaded      barehead       \n  barely          bare            bareness        bare           \n  barful          bar             bargain         bargain        \n  bargains        bargain         barge           barg           \n  bargulus        bargulu         baring          bare           \n  bark            bark            barking         bark           \n  barkloughly     barkloughli     barks           bark           \n  barky           barki           barley          barlei         \n  barm            barm            barn            barn           \n  barnacles       barnacl         barnardine      barnardin      \n  barne           barn            barnes          barn           \n  barnet          barnet          barns           barn           \n  baron           baron           barons          baron          \n  barony          baroni          barr            barr           \n  barrabas        barraba         barrel          barrel         \n  barrels         barrel          barren          barren         \n  barrenly        barrenli        barrenness      barren         \n  barricado       barricado       barricadoes     barricado      \n  barrow          barrow          bars            bar            \n  barson          barson          barter          barter         \n  bartholomew     bartholomew     bas             ba             \n  basan           basan           base            base           \n  baseless        baseless        basely          base           \n  baseness        base            baser           baser          \n  bases           base            basest          basest         \n  bashful         bash            bashfulness     bash           \n  basilisco       basilisco       basilisk        basilisk       \n  basilisks       basilisk        basimecu        basimecu       \n  basin           basin           basingstoke     basingstok     \n  basins          basin           basis           basi           \n  bask            bask            basket          basket         \n  baskets         basket          bass            bass           \n  bassanio        bassanio        basset          basset         \n  bassianus       bassianu        basta           basta          \n  bastard         bastard         bastardizing    bastard        \n  bastardly       bastardli       bastards        bastard        \n  bastardy        bastardi        basted          bast           \n  bastes          bast            bastinado       bastinado      \n  basting         bast            bat             bat            \n  batailles       batail          batch           batch          \n  bate            bate            bated           bate           \n  bates           bate            bath            bath           \n  bathe           bath            bathed          bath           \n  bathing         bath            baths           bath           \n  bating          bate            batler          batler         \n  bats            bat             batt            batt           \n  battalia        battalia        battalions      battalion      \n  batten          batten          batter          batter         \n  battering       batter          batters         batter         \n  battery         batteri         battle          battl          \n  battled         battl           battlefield     battlefield    \n  battlements     battlement      battles         battl          \n  batty           batti           bauble          baubl          \n  baubles         baubl           baubling        baubl          \n  baulk           baulk           bavin           bavin          \n  bawcock         bawcock         bawd            bawd           \n  bawdry          bawdri          bawds           bawd           \n  bawdy           bawdi           bawl            bawl           \n  bawling         bawl            bay             bai            \n  baying          bai             baynard         baynard        \n  bayonne         bayonn          bays            bai            \n  be              be              beach           beach          \n  beached         beach           beachy          beachi         \n  beacon          beacon          bead            bead           \n  beaded          bead            beadle          beadl          \n  beadles         beadl           beads           bead           \n  beadsmen        beadsmen        beagle          beagl          \n  beagles         beagl           beak            beak           \n  beaks           beak            beam            beam           \n  beamed          beam            beams           beam           \n  bean            bean            beans           bean           \n  bear            bear            beard           beard          \n  bearded         beard           beardless       beardless      \n  beards          beard           bearer          bearer         \n  bearers         bearer          bearest         bearest        \n  beareth         beareth         bearing         bear           \n  bears           bear            beast           beast          \n  beastliest      beastliest      beastliness     beastli        \n  beastly         beastli         beasts          beast          \n  beat            beat            beated          beat           \n  beaten          beaten          beating         beat           \n  beatrice        beatric         beats           beat           \n  beau            beau            beaufort        beaufort       \n  beaumond        beaumond        beaumont        beaumont       \n  beauteous       beauteou        beautied        beauti         \n  beauties        beauti          beautified      beautifi       \n  beautiful       beauti          beautify        beautifi       \n  beauty          beauti          beaver          beaver         \n  beavers         beaver          became          becam          \n  because         becaus          bechanc         bechanc        \n  bechance        bechanc         bechanced       bechanc        \n  beck            beck            beckon          beckon         \n  beckons         beckon          becks           beck           \n  becom           becom           become          becom          \n  becomed         becom           becomes         becom          \n  becoming        becom           becomings       becom          \n  bed             bed             bedabbled       bedabbl        \n  bedash          bedash          bedaub          bedaub         \n  bedazzled       bedazzl         bedchamber      bedchamb       \n  bedclothes      bedcloth        bedded          bed            \n  bedeck          bedeck          bedecking       bedeck         \n  bedew           bedew           bedfellow       bedfellow      \n  bedfellows      bedfellow       bedford         bedford        \n  bedlam          bedlam          bedrench        bedrench       \n  bedrid          bedrid          beds            bed            \n  bedtime         bedtim          bedward         bedward        \n  bee             bee             beef            beef           \n  beefs           beef            beehives        beehiv         \n  been            been            beer            beer           \n  bees            bee             beest           beest          \n  beetle          beetl           beetles         beetl          \n  beeves          beev            befall          befal          \n  befallen        befallen        befalls         befal          \n  befell          befel           befits          befit          \n  befitted        befit           befitting       befit          \n  befor           befor           before          befor          \n  beforehand      beforehand      befortune       befortun       \n  befriend        befriend        befriended      befriend       \n  befriends       befriend        beg             beg            \n  began           began           beget           beget          \n  begets          beget           begetting       beget          \n  begg            begg            beggar          beggar         \n  beggared        beggar          beggarly        beggarli       \n  beggarman       beggarman       beggars         beggar         \n  beggary         beggari         begging         beg            \n  begin           begin           beginners       beginn         \n  beginning       begin           beginnings      begin          \n  begins          begin           begnawn         begnawn        \n  begone          begon           begot           begot          \n  begotten        begotten        begrimed        begrim         \n  begs            beg             beguil          beguil         \n  beguile         beguil          beguiled        beguil         \n  beguiles        beguil          beguiling       beguil         \n  begun           begun           behalf          behalf         \n  behalfs         behalf          behav           behav          \n  behaved         behav           behavedst       behavedst      \n  behavior        behavior        behaviors       behavior       \n  behaviour       behaviour       behaviours      behaviour      \n  behead          behead          beheaded        behead         \n  beheld          beheld          behest          behest         \n  behests         behest          behind          behind         \n  behold          behold          beholder        behold         \n  beholders       behold          beholdest       beholdest      \n  beholding       behold          beholds         behold         \n  behoof          behoof          behooffull      behoofful      \n  behooves        behoov          behove          behov          \n  behoves         behov           behowls         behowl         \n  being           be              bel             bel            \n  belarius        belariu         belch           belch          \n  belching        belch           beldam          beldam         \n  beldame         beldam          beldams         beldam         \n  belee           bele            belgia          belgia         \n  belie           beli            belied          beli           \n  belief          belief          beliest         beliest        \n  believ          believ          believe         believ         \n  believed        believ          believes        believ         \n  believest       believest       believing       believ         \n  belike          belik           bell            bell           \n  bellario        bellario        belle           bell           \n  bellied         belli           bellies         belli          \n  bellman         bellman         bellona         bellona        \n  bellow          bellow          bellowed        bellow         \n  bellowing       bellow          bellows         bellow         \n  bells           bell            belly           belli          \n  bellyful        belly           belman          belman         \n  belmont         belmont         belock          belock         \n  belong          belong          belonging       belong         \n  belongings      belong          belongs         belong         \n  belov           belov           beloved         belov          \n  beloving        belov           below           below          \n  belt            belt            belzebub        belzebub       \n  bemadding       bemad           bemet           bemet          \n  bemete          bemet           bemoan          bemoan         \n  bemoaned        bemoan          bemock          bemock         \n  bemoil          bemoil          bemonster       bemonst        \n  ben             ben             bench           bench          \n  bencher         bencher         benches         bench          \n  bend            bend            bended          bend           \n  bending         bend            bends           bend           \n  bene            bene            beneath         beneath        \n  benedicite      benedicit       benedick        benedick       \n  benediction     benedict        benedictus      benedictu      \n  benefactors     benefactor      benefice        benefic        \n  beneficial      benefici        benefit         benefit        \n  benefited       benefit         benefits        benefit        \n  benetted        benet           benevolence     benevol        \n  benevolences    benevol         benied          beni           \n  benison         benison         bennet          bennet         \n  bent            bent            bentii          bentii         \n  bentivolii      bentivolii      bents           bent           \n  benumbed        benumb          benvolio        benvolio       \n  bepaint         bepaint         bepray          beprai         \n  bequeath        bequeath        bequeathed      bequeath       \n  bequeathing     bequeath        bequest         bequest        \n  ber             ber             berard          berard         \n  berattle        berattl         beray           berai          \n  bere            bere            bereave         bereav         \n  bereaved        bereav          bereaves        bereav         \n  bereft          bereft          bergamo         bergamo        \n  bergomask       bergomask       berhym          berhym         \n  berhyme         berhym          berkeley        berkelei       \n  bermoothes      bermooth        bernardo        bernardo       \n  berod           berod           berowne         berown         \n  berri           berri           berries         berri          \n  berrord         berrord         berry           berri          \n  bertram         bertram         berwick         berwick        \n  bescreen        bescreen        beseech         beseech        \n  beseeched       beseech         beseechers      beseech        \n  beseeching      beseech         beseek          beseek         \n  beseem          beseem          beseemeth       beseemeth      \n  beseeming       beseem          beseems         beseem         \n  beset           beset           beshrew         beshrew        \n  beside          besid           besides         besid          \n  besieg          besieg          besiege         besieg         \n  besieged        besieg          beslubber       beslubb        \n  besmear         besmear         besmeared       besmear        \n  besmirch        besmirch        besom           besom          \n  besort          besort          besotted        besot          \n  bespake         bespak          bespeak         bespeak        \n  bespice         bespic          bespoke         bespok         \n  bespotted       bespot          bess            bess           \n  bessy           bessi           best            best           \n  bestained       bestain         bested          best           \n  bestial         bestial         bestir          bestir         \n  bestirr         bestirr         bestow          bestow         \n  bestowed        bestow          bestowing       bestow         \n  bestows         bestow          bestraught      bestraught     \n  bestrew         bestrew         bestrid         bestrid        \n  bestride        bestrid         bestrides       bestrid        \n  bet             bet             betake          betak          \n  beteem          beteem          bethink         bethink        \n  bethought       bethought       bethrothed      bethroth       \n  bethump         bethump         betid           betid          \n  betide          betid           betideth        betideth       \n  betime          betim           betimes         betim          \n  betoken         betoken         betook          betook         \n  betossed        betoss          betray          betrai         \n  betrayed        betrai          betraying       betrai         \n  betrays         betrai          betrims         betrim         \n  betroth         betroth         betrothed       betroth        \n  betroths        betroth         bett            bett           \n  betted          bet             better          better         \n  bettered        better          bettering       better         \n  betters         better          betting         bet            \n  bettre          bettr           between         between        \n  betwixt         betwixt         bevel           bevel          \n  beverage        beverag         bevis           bevi           \n  bevy            bevi            bewail          bewail         \n  bewailed        bewail          bewailing       bewail         \n  bewails         bewail          beware          bewar          \n  bewasted        bewast          beweep          beweep         \n  bewept          bewept          bewet           bewet          \n  bewhored        bewhor          bewitch         bewitch        \n  bewitched       bewitch         bewitchment     bewitch        \n  bewray          bewrai          beyond          beyond         \n  bezonian        bezonian        bezonians       bezonian       \n  bianca          bianca          bianco          bianco         \n  bias            bia             bibble          bibbl          \n  bickerings      bicker          bid             bid            \n  bidden          bidden          bidding         bid            \n  biddings        bid             biddy           biddi          \n  bide            bide            bides           bide           \n  biding          bide            bids            bid            \n  bien            bien            bier            bier           \n  bifold          bifold          big             big            \n  bigamy          bigami          biggen          biggen         \n  bigger          bigger          bigness         big            \n  bigot           bigot           bilberry        bilberri       \n  bilbo           bilbo           bilboes         bilbo          \n  bilbow          bilbow          bill            bill           \n  billeted        billet          billets         billet         \n  billiards       billiard        billing         bill           \n  billow          billow          billows         billow         \n  bills           bill            bin             bin            \n  bind            bind            bindeth         bindeth        \n  binding         bind            binds           bind           \n  biondello       biondello       birch           birch          \n  bird            bird            birding         bird           \n  birdlime        birdlim         birds           bird           \n  birnam          birnam          birth           birth          \n  birthday        birthdai        birthdom        birthdom       \n  birthplace      birthplac       birthright      birthright     \n  birthrights     birthright      births          birth          \n  bis             bi              biscuit         biscuit        \n  bishop          bishop          bishops         bishop         \n  bisson          bisson          bit             bit            \n  bitch           bitch           bite            bite           \n  biter           biter           bites           bite           \n  biting          bite            bits            bit            \n  bitt            bitt            bitten          bitten         \n  bitter          bitter          bitterest       bitterest      \n  bitterly        bitterli        bitterness      bitter         \n  blab            blab            blabb           blabb          \n  blabbing        blab            blabs           blab           \n  black           black           blackamoor      blackamoor     \n  blackamoors     blackamoor      blackberries    blackberri     \n  blackberry      blackberri      blacker         blacker        \n  blackest        blackest        blackfriars     blackfriar     \n  blackheath      blackheath      blackmere       blackmer       \n  blackness       black           blacks          black          \n  bladder         bladder         bladders        bladder        \n  blade           blade           bladed          blade          \n  blades          blade           blains          blain          \n  blam            blam            blame           blame          \n  blamed          blame           blameful        blame          \n  blameless       blameless       blames          blame          \n  blanc           blanc           blanca          blanca         \n  blanch          blanch          blank           blank          \n  blanket         blanket         blanks          blank          \n  blaspheme       blasphem        blaspheming     blasphem       \n  blasphemous     blasphem        blasphemy       blasphemi      \n  blast           blast           blasted         blast          \n  blasting        blast           blastments      blastment      \n  blasts          blast           blaz            blaz           \n  blaze           blaze           blazes          blaze          \n  blazing         blaze           blazon          blazon         \n  blazoned        blazon          blazoning       blazon         \n  bleach          bleach          bleaching       bleach         \n  bleak           bleak           blear           blear          \n  bleared         blear           bleat           bleat          \n  bleated         bleat           bleats          bleat          \n  bled            bled            bleed           bleed          \n  bleedest        bleedest        bleedeth        bleedeth       \n  bleeding        bleed           bleeds          bleed          \n  blemish         blemish         blemishes       blemish        \n  blench          blench          blenches        blench         \n  blend           blend           blended         blend          \n  blent           blent           bless           bless          \n  blessed         bless           blessedly       blessedli      \n  blessedness     blessed         blesses         bless          \n  blesseth        blesseth        blessing        bless          \n  blessings       bless           blest           blest          \n  blew            blew            blind           blind          \n  blinded         blind           blindfold       blindfold      \n  blinding        blind           blindly         blindli        \n  blindness       blind           blinds          blind          \n  blink           blink           blinking        blink          \n  bliss           bliss           blist           blist          \n  blister         blister         blisters        blister        \n  blithe          blith           blithild        blithild       \n  bloat           bloat           block           block          \n  blockish        blockish        blocks          block          \n  blois           bloi            blood           blood          \n  blooded         blood           bloodhound      bloodhound     \n  bloodied        bloodi          bloodier        bloodier       \n  bloodiest       bloodiest       bloodily        bloodili       \n  bloodless       bloodless       bloods          blood          \n  bloodshed       bloodsh         bloodshedding   bloodshed      \n  bloodstained    bloodstain      bloody          bloodi         \n  bloom           bloom           blooms          bloom          \n  blossom         blossom         blossoming      blossom        \n  blossoms        blossom         blot            blot           \n  blots           blot            blotted         blot           \n  blotting        blot            blount          blount         \n  blow            blow            blowed          blow           \n  blowers         blower          blowest         blowest        \n  blowing         blow            blown           blown          \n  blows           blow            blowse          blows          \n  blubb           blubb           blubber         blubber        \n  blubbering      blubber         blue            blue           \n  bluecaps        bluecap         bluest          bluest         \n  blunt           blunt           blunted         blunt          \n  blunter         blunter         bluntest        bluntest       \n  blunting        blunt           bluntly         bluntli        \n  bluntness       blunt           blunts          blunt          \n  blur            blur            blurr           blurr          \n  blurs           blur            blush           blush          \n  blushes         blush           blushest        blushest       \n  blushing        blush           blust           blust          \n  bluster         bluster         blusterer       bluster        \n  blusters        bluster         bo              bo             \n  boar            boar            board           board          \n  boarded         board           boarding        board          \n  boards          board           boarish         boarish        \n  boars           boar            boast           boast          \n  boasted         boast           boastful        boast          \n  boasting        boast           boasts          boast          \n  boat            boat            boats           boat           \n  boatswain       boatswain       bob             bob            \n  bobb            bobb            boblibindo      boblibindo     \n  bobtail         bobtail         bocchus         bocchu         \n  bode            bode            boded           bode           \n  bodements       bodement        bodes           bode           \n  bodg            bodg            bodied          bodi           \n  bodies          bodi            bodiless        bodiless       \n  bodily          bodili          boding          bode           \n  bodkin          bodkin          body            bodi           \n  bodykins        bodykin         bog             bog            \n  boggle          boggl           boggler         boggler        \n  bogs            bog             bohemia         bohemia        \n  bohemian        bohemian        bohun           bohun          \n  boil            boil            boiling         boil           \n  boils           boil            boist           boist          \n  boisterous      boister         boisterously    boister        \n  boitier         boitier         bold            bold           \n  bolden          bolden          bolder          bolder         \n  boldest         boldest         boldly          boldli         \n  boldness        bold            bolds           bold           \n  bolingbroke     bolingbrok      bolster         bolster        \n  bolt            bolt            bolted          bolt           \n  bolter          bolter          bolters         bolter         \n  bolting         bolt            bolts           bolt           \n  bombard         bombard         bombards        bombard        \n  bombast         bombast         bon             bon            \n  bona            bona            bond            bond           \n  bondage         bondag          bonded          bond           \n  bondmaid        bondmaid        bondman         bondman        \n  bondmen         bondmen         bonds           bond           \n  bondslave       bondslav        bone            bone           \n  boneless        boneless        bones           bone           \n  bonfire         bonfir          bonfires        bonfir         \n  bonjour         bonjour         bonne           bonn           \n  bonnet          bonnet          bonneted        bonnet         \n  bonny           bonni           bonos           bono           \n  bonto           bonto           bonville        bonvil         \n  bood            bood            book            book           \n  bookish         bookish         books           book           \n  boon            boon            boor            boor           \n  boorish         boorish         boors           boor           \n  boot            boot            booted          boot           \n  booties         booti           bootless        bootless       \n  boots           boot            booty           booti          \n  bor             bor             bora            bora           \n  borachio        borachio        bordeaux        bordeaux       \n  border          border          bordered        border         \n  borderers       border          borders         border         \n  bore            bore            boreas          borea          \n  bores           bore            boring          bore           \n  born            born            borne           born           \n  borough         borough         boroughs        borough        \n  borrow          borrow          borrowed        borrow         \n  borrower        borrow          borrowing       borrow         \n  borrows         borrow          bosko           bosko          \n  boskos          bosko           bosky           boski          \n  bosom           bosom           bosoms          bosom          \n  boson           boson           boss            boss           \n  bosworth        bosworth        botch           botch          \n  botcher         botcher         botches         botch          \n  botchy          botchi          both            both           \n  bots            bot             bottle          bottl          \n  bottled         bottl           bottles         bottl          \n  bottom          bottom          bottomless      bottomless     \n  bottoms         bottom          bouciqualt      bouciqualt     \n  bouge           boug            bough           bough          \n  boughs          bough           bought          bought         \n  bounce          bounc           bouncing        bounc          \n  bound           bound           bounded         bound          \n  bounden         bounden         boundeth        boundeth       \n  bounding        bound           boundless       boundless      \n  bounds          bound           bounteous       bounteou       \n  bounteously     bounteous       bounties        bounti         \n  bountiful       bounti          bountifully     bountifulli    \n  bounty          bounti          bourbier        bourbier       \n  bourbon         bourbon         bourchier       bourchier      \n  bourdeaux       bourdeaux       bourn           bourn          \n  bout            bout            bouts           bout           \n  bove            bove            bow             bow            \n  bowcase         bowcas          bowed           bow            \n  bowels          bowel           bower           bower          \n  bowing          bow             bowl            bowl           \n  bowler          bowler          bowling         bowl           \n  bowls           bowl            bows            bow            \n  bowsprit        bowsprit        bowstring       bowstr         \n  box             box             boxes           box            \n  boy             boi             boyet           boyet          \n  boyish          boyish          boys            boi            \n  brabant         brabant         brabantio       brabantio      \n  brabble         brabbl          brabbler        brabbler       \n  brac            brac            brace           brace          \n  bracelet        bracelet        bracelets       bracelet       \n  brach           brach           bracy           braci          \n  brag            brag            bragg           bragg          \n  braggardism     braggard        braggards       braggard       \n  braggart        braggart        braggarts       braggart       \n  bragged         brag            bragging        brag           \n  bragless        bragless        brags           brag           \n  braid           braid           braided         braid          \n  brain           brain           brained         brain          \n  brainford       brainford       brainish        brainish       \n  brainless       brainless       brains          brain          \n  brainsick       brainsick       brainsickly     brainsickli    \n  brake           brake           brakenbury      brakenburi     \n  brakes          brake           brambles        brambl         \n  bran            bran            branch          branch         \n  branches        branch          branchless      branchless     \n  brand           brand           branded         brand          \n  brandish        brandish        brandon         brandon        \n  brands          brand           bras            bra            \n  brass           brass           brassy          brassi         \n  brat            brat            brats           brat           \n  brav            brav            brave           brave          \n  braved          brave           bravely         brave          \n  braver          braver          bravery         braveri        \n  braves          brave           bravest         bravest        \n  braving         brave           brawl           brawl          \n  brawler         brawler         brawling        brawl          \n  brawls          brawl           brawn           brawn          \n  brawns          brawn           bray            brai           \n  braying         brai            braz            braz           \n  brazen          brazen          brazier         brazier        \n  breach          breach          breaches        breach         \n  bread           bread           breadth         breadth        \n  break           break           breaker         breaker        \n  breakfast       breakfast       breaking        break          \n  breaks          break           breast          breast         \n  breasted        breast          breasting       breast         \n  breastplate     breastplat      breasts         breast         \n  breath          breath          breathe         breath         \n  breathed        breath          breather        breather       \n  breathers       breather        breathes        breath         \n  breathest       breathest       breathing       breath         \n  breathless      breathless      breaths         breath         \n  brecknock       brecknock       bred            bred           \n  breech          breech          breeches        breech         \n  breeching       breech          breed           breed          \n  breeder         breeder         breeders        breeder        \n  breeding        breed           breeds          breed          \n  breese          brees           breeze          breez          \n  breff           breff           bretagne        bretagn        \n  brethen         brethen         bretheren       bretheren      \n  brethren        brethren        brevis          brevi          \n  brevity         breviti         brew            brew           \n  brewage         brewag          brewer          brewer         \n  brewers         brewer          brewing         brew           \n  brews           brew            briareus        briareu        \n  briars          briar           brib            brib           \n  bribe           bribe           briber          briber         \n  bribes          bribe           brick           brick          \n  bricklayer      bricklay        bricks          brick          \n  bridal          bridal          bride           bride          \n  bridegroom      bridegroom      bridegrooms     bridegroom     \n  brides          bride           bridge          bridg          \n  bridgenorth     bridgenorth     bridges         bridg          \n  bridget         bridget         bridle          bridl          \n  bridled         bridl           brief           brief          \n  briefer         briefer         briefest        briefest       \n  briefly         briefli         briefness       brief          \n  brier           brier           briers          brier          \n  brigandine      brigandin       bright          bright         \n  brighten        brighten        brightest       brightest      \n  brightly        brightli        brightness      bright         \n  brim            brim            brimful         brim           \n  brims           brim            brimstone       brimston       \n  brinded         brind           brine           brine          \n  bring           bring           bringer         bringer        \n  bringeth        bringeth        bringing        bring          \n  bringings       bring           brings          bring          \n  brinish         brinish         brink           brink          \n  brisk           brisk           brisky          briski         \n  bristle         bristl          bristled        bristl         \n  bristly         bristli         bristol         bristol        \n  bristow         bristow         britain         britain        \n  britaine        britain         britaines       britain        \n  british         british         briton          briton         \n  britons         briton          brittany        brittani       \n  brittle         brittl          broach          broach         \n  broached        broach          broad           broad          \n  broader         broader         broadsides      broadsid       \n  brocas          broca           brock           brock          \n  brogues         brogu           broil           broil          \n  broiling        broil           broils          broil          \n  broke           broke           broken          broken         \n  brokenly        brokenli        broker          broker         \n  brokers         broker          brokes          broke          \n  broking         broke           brooch          brooch         \n  brooches        brooch          brood           brood          \n  brooded         brood           brooding        brood          \n  brook           brook           brooks          brook          \n  broom           broom           broomstaff      broomstaff     \n  broth           broth           brothel         brothel        \n  brother         brother         brotherhood     brotherhood    \n  brotherhoods    brotherhood     brotherly       brotherli      \n  brothers        brother         broths          broth          \n  brought         brought         brow            brow           \n  brown           brown           browner         browner        \n  brownist        brownist        browny          browni         \n  brows           brow            browse          brows          \n  browsing        brows           bruis           brui           \n  bruise          bruis           bruised         bruis          \n  bruises         bruis           bruising        bruis          \n  bruit           bruit           bruited         bruit          \n  brundusium      brundusium      brunt           brunt          \n  brush           brush           brushes         brush          \n  brute           brute           brutish         brutish        \n  brutus          brutu           bubble          bubbl          \n  bubbles         bubbl           bubbling        bubbl          \n  bubukles        bubukl          buck            buck           \n  bucket          bucket          buckets         bucket         \n  bucking         buck            buckingham      buckingham     \n  buckle          buckl           buckled         buckl          \n  buckler         buckler         bucklers        buckler        \n  bucklersbury    bucklersburi    buckles         buckl          \n  buckram         buckram         bucks           buck           \n  bud             bud             budded          bud            \n  budding         bud             budge           budg           \n  budger          budger          budget          budget         \n  buds            bud             buff            buff           \n  buffet          buffet          buffeting       buffet         \n  buffets         buffet          bug             bug            \n  bugbear         bugbear         bugle           bugl           \n  bugs            bug             build           build          \n  builded         build           buildeth        buildeth       \n  building        build           buildings       build          \n  builds          build           built           built          \n  bulk            bulk            bulks           bulk           \n  bull            bull            bullcalf        bullcalf       \n  bullen          bullen          bullens         bullen         \n  bullet          bullet          bullets         bullet         \n  bullocks        bullock         bulls           bull           \n  bully           bulli           bulmer          bulmer         \n  bulwark         bulwark         bulwarks        bulwark        \n  bum             bum             bumbast         bumbast        \n  bump            bump            bumper          bumper         \n  bums            bum             bunch           bunch          \n  bunches         bunch           bundle          bundl          \n  bung            bung            bunghole        bunghol        \n  bungle          bungl           bunting         bunt           \n  buoy            buoi            bur             bur            \n  burbolt         burbolt         burd            burd           \n  burden          burden          burdened        burden         \n  burdening       burden          burdenous       burden         \n  burdens         burden          burgh           burgh          \n  burgher         burgher         burghers        burgher        \n  burglary        burglari        burgomasters    burgomast      \n  burgonet        burgonet        burgundy        burgundi       \n  burial          burial          buried          buri           \n  burier          burier          buriest         buriest        \n  burly           burli           burn            burn           \n  burned          burn            burnet          burnet         \n  burneth         burneth         burning         burn           \n  burnish         burnish         burns           burn           \n  burnt           burnt           burr            burr           \n  burrows         burrow          burs            bur            \n  burst           burst           bursting        burst          \n  bursts          burst           burthen         burthen        \n  burthens        burthen         burton          burton         \n  bury            buri            burying         buri           \n  bush            bush            bushels         bushel         \n  bushes          bush            bushy           bushi          \n  busied          busi            busily          busili         \n  busines         busin           business        busi           \n  businesses      busi            buskin          buskin         \n  busky           buski           buss            buss           \n  busses          buss            bussing         buss           \n  bustle          bustl           bustling        bustl          \n  busy            busi            but             but            \n  butcheed        butche          butcher         butcher        \n  butchered       butcher         butcheries      butcheri       \n  butcherly       butcherli       butchers        butcher        \n  butchery        butcheri        butler          butler         \n  butt            butt            butter          butter         \n  buttered        butter          butterflies     butterfli      \n  butterfly       butterfli       butterwoman     butterwoman    \n  buttery         butteri         buttock         buttock        \n  buttocks        buttock         button          button         \n  buttonhole      buttonhol       buttons         button         \n  buttress        buttress        buttry          buttri         \n  butts           butt            buxom           buxom          \n  buy             bui             buyer           buyer          \n  buying          bui             buys            bui            \n  buzz            buzz            buzzard         buzzard        \n  buzzards        buzzard         buzzers         buzzer         \n  buzzing         buzz            by              by             \n  bye             bye             byzantium       byzantium      \n  c               c               ca              ca             \n  cabbage         cabbag          cabileros       cabilero       \n  cabin           cabin           cabins          cabin          \n  cable           cabl            cables          cabl           \n  cackling        cackl           cacodemon       cacodemon      \n  caddis          caddi           caddisses       caddiss        \n  cade            cade            cadence         cadenc         \n  cadent          cadent          cades           cade           \n  cadmus          cadmu           caduceus        caduceu        \n  cadwal          cadwal          cadwallader     cadwallad      \n  caelius         caeliu          caelo           caelo          \n  caesar          caesar          caesarion       caesarion      \n  caesars         caesar          cage            cage           \n  caged           cage            cagion          cagion         \n  cain            cain            caithness       caith          \n  caitiff         caitiff         caitiffs        caitiff        \n  caius           caiu            cak             cak            \n  cake            cake            cakes           cake           \n  calaber         calab           calais          calai          \n  calamities      calam           calamity        calam          \n  calchas         calcha          calculate       calcul         \n  calen           calen           calendar        calendar       \n  calendars       calendar        calf            calf           \n  caliban         caliban         calibans        caliban        \n  calipolis       calipoli        cality          caliti         \n  caliver         caliv           call            call           \n  callat          callat          called          call           \n  callet          callet          calling         call           \n  calls           call            calm            calm           \n  calmest         calmest         calmly          calmli         \n  calmness        calm            calms           calm           \n  calpurnia       calpurnia       calumniate      calumni        \n  calumniating    calumni         calumnious      calumni        \n  calumny         calumni         calve           calv           \n  calved          calv            calves          calv           \n  calveskins      calveskin       calydon         calydon        \n  cam             cam             cambio          cambio         \n  cambria         cambria         cambric         cambric        \n  cambrics        cambric         cambridge       cambridg       \n  cambyses        cambys          came            came           \n  camel           camel           camelot         camelot        \n  camels          camel           camest          camest         \n  camillo         camillo         camlet          camlet         \n  camomile        camomil         camp            camp           \n  campeius        campeiu         camping         camp           \n  camps           camp            can             can            \n  canakin         canakin         canaries        canari         \n  canary          canari          cancel          cancel         \n  cancell         cancel          cancelled       cancel         \n  cancelling      cancel          cancels         cancel         \n  cancer          cancer          candidatus      candidatu      \n  candied         candi           candle          candl          \n  candles         candl           candlesticks    candlestick    \n  candy           candi           canidius        canidiu        \n  cank            cank            canker          canker         \n  cankerblossom   cankerblossom   cankers         canker         \n  cannibally      cannib          cannibals       cannib         \n  cannon          cannon          cannoneer       cannon         \n  cannons         cannon          cannot          cannot         \n  canon           canon           canoniz         canoniz        \n  canonize        canon           canonized       canon          \n  canons          canon           canopied        canopi         \n  canopies        canopi          canopy          canopi         \n  canst           canst           canstick        canstick       \n  canterbury      canterburi      cantle          cantl          \n  cantons         canton          canus           canu           \n  canvas          canva           canvass         canvass        \n  canzonet        canzonet        cap             cap            \n  capability      capabl          capable         capabl         \n  capacities      capac           capacity        capac          \n  caparison       caparison       capdv           capdv          \n  cape            cape            capel           capel          \n  capels          capel           caper           caper          \n  capers          caper           capet           capet          \n  caphis          caphi           capilet         capilet        \n  capitaine       capitain        capital         capit          \n  capite          capit           capitol         capitol        \n  capitulate      capitul         capocchia       capocchia      \n  capon           capon           capons          capon          \n  capp            capp            cappadocia      cappadocia     \n  capriccio       capriccio       capricious      caprici        \n  caps            cap             capt            capt           \n  captain         captain         captains        captain        \n  captainship     captainship     captious        captiou        \n  captivate       captiv          captivated      captiv         \n  captivates      captiv          captive         captiv         \n  captives        captiv          captivity       captiv         \n  captum          captum          capucius        capuciu        \n  capulet         capulet         capulets        capulet        \n  car             car             carack          carack         \n  caracks         carack          carat           carat          \n  caraways        carawai         carbonado       carbonado      \n  carbuncle       carbuncl        carbuncled      carbuncl       \n  carbuncles      carbuncl        carcanet        carcanet       \n  carcase         carcas          carcases        carcas         \n  carcass         carcass         carcasses       carcass        \n  card            card            cardecue        cardecu        \n  carded          card            carders         carder         \n  cardinal        cardin          cardinally      cardin         \n  cardinals       cardin          cardmaker       cardmak        \n  cards           card            carduus         carduu         \n  care            care            cared           care           \n  career          career          careers         career         \n  careful         care            carefully       carefulli      \n  careless        careless        carelessly      carelessli     \n  carelessness    careless        cares           care           \n  caret           caret           cargo           cargo          \n  carl            carl            carlisle        carlisl        \n  carlot          carlot          carman          carman         \n  carmen          carmen          carnal          carnal         \n  carnally        carnal          carnarvonshire  carnarvonshir  \n  carnation       carnat          carnations      carnat         \n  carol           carol           carous          carou          \n  carouse         carous          caroused        carous         \n  carouses        carous          carousing       carous         \n  carp            carp            carpenter       carpent        \n  carper          carper          carpet          carpet         \n  carpets         carpet          carping         carp           \n  carriage        carriag         carriages       carriag        \n  carried         carri           carrier         carrier        \n  carriers        carrier         carries         carri          \n  carrion         carrion         carrions        carrion        \n  carry           carri           carrying        carri          \n  cars            car             cart            cart           \n  carters         carter          carthage        carthag        \n  carts           cart            carv            carv           \n  carve           carv            carved          carv           \n  carver          carver          carves          carv           \n  carving         carv            cas             ca             \n  casa            casa            casaer          casaer         \n  casca           casca           case            case           \n  casement        casement        casements       casement       \n  cases           case            cash            cash           \n  cashier         cashier         casing          case           \n  cask            cask            casket          casket         \n  casketed        casket          caskets         casket         \n  casque          casqu           casques         casqu          \n  cassado         cassado         cassandra       cassandra      \n  cassibelan      cassibelan      cassio          cassio         \n  cassius         cassiu          cassocks        cassock        \n  cast            cast            castalion       castalion      \n  castaway        castawai        castaways       castawai       \n  casted          cast            caster          caster         \n  castigate       castig          castigation     castig         \n  castile         castil          castiliano      castiliano     \n  casting         cast            castle          castl          \n  castles         castl           casts           cast           \n  casual          casual          casually        casual         \n  casualties      casualti        casualty        casualti       \n  cat             cat             cataian         cataian        \n  catalogue       catalogu        cataplasm       cataplasm      \n  cataracts       cataract        catarrhs        catarrh        \n  catastrophe     catastroph      catch           catch          \n  catcher         catcher         catches         catch          \n  catching        catch           cate            cate           \n  catechising     catechis        catechism       catech         \n  catechize       catech          cater           cater          \n  caterpillars    caterpillar     caters          cater          \n  caterwauling    caterwaul       cates           cate           \n  catesby         catesbi         cathedral       cathedr        \n  catlike         catlik          catling         catl           \n  catlings        catl            cato            cato           \n  cats            cat             cattle          cattl          \n  caucasus        caucasu         caudle          caudl          \n  cauf            cauf            caught          caught         \n  cauldron        cauldron        caus            cau            \n  cause           caus            caused          caus           \n  causeless       causeless       causer          causer         \n  causes          caus            causest         causest        \n  causeth         causeth         cautel          cautel         \n  cautelous       cautel          cautels         cautel         \n  cauterizing     cauter          caution         caution        \n  cautions        caution         cavaleiro       cavaleiro      \n  cavalery        cavaleri        cavaliers       cavali         \n  cave            cave            cavern          cavern         \n  caverns         cavern          caves           cave           \n  caveto          caveto          caviary         caviari        \n  cavil           cavil           cavilling       cavil          \n  cawdor          cawdor          cawdron         cawdron        \n  cawing          caw             ce              ce             \n  ceas            cea             cease           ceas           \n  ceases          ceas            ceaseth         ceaseth        \n  cedar           cedar           cedars          cedar          \n  cedius          cediu           celebrate       celebr         \n  celebrated      celebr          celebrates      celebr         \n  celebration     celebr          celerity        celer          \n  celestial       celesti         celia           celia          \n  cell            cell            cellar          cellar         \n  cellarage       cellarag        celsa           celsa          \n  cement          cement          censer          censer         \n  censor          censor          censorinus      censorinu      \n  censur          censur          censure         censur         \n  censured        censur          censurers       censur         \n  censures        censur          censuring       censur         \n  centaur         centaur         centaurs        centaur        \n  centre          centr           cents           cent           \n  centuries       centuri         centurion       centurion      \n  centurions      centurion       century         centuri        \n  cerberus        cerberu         cerecloth       cerecloth      \n  cerements       cerement        ceremonial      ceremoni       \n  ceremonies      ceremoni        ceremonious     ceremoni       \n  ceremoniously   ceremoni        ceremony        ceremoni       \n  ceres           cere            cerns           cern           \n  certain         certain         certainer       certain        \n  certainly       certainli       certainties     certainti      \n  certainty       certainti       certes          cert           \n  certificate     certif          certified       certifi        \n  certifies       certifi         certify         certifi        \n  ces             ce              cesario         cesario        \n  cess            cess            cesse           cess           \n  cestern         cestern         cetera          cetera         \n  cette           cett            chaces          chace          \n  chaf            chaf            chafe           chafe          \n  chafed          chafe           chafes          chafe          \n  chaff           chaff           chaffless       chaffless      \n  chafing         chafe           chain           chain          \n  chains          chain           chair           chair          \n  chairs          chair           chalic          chalic         \n  chalice         chalic          chalices        chalic         \n  chalk           chalk           chalks          chalk          \n  chalky          chalki          challeng        challeng       \n  challenge       challeng        challenged      challeng       \n  challenger      challeng        challengers     challeng       \n  challenges      challeng        cham            cham           \n  chamber         chamber         chamberers      chamber        \n  chamberlain     chamberlain     chamberlains    chamberlain    \n  chambermaid     chambermaid     chambermaids    chambermaid    \n  chambers        chamber         chameleon       chameleon      \n  champ           champ           champagne       champagn       \n  champain        champain        champains       champain       \n  champion        champion        champions       champion       \n  chanc           chanc           chance          chanc          \n  chanced         chanc           chancellor      chancellor     \n  chances         chanc           chandler        chandler       \n  chang           chang           change          chang          \n  changeable      changeabl       changed         chang          \n  changeful       chang           changeling      changel        \n  changelings     changel         changer         changer        \n  changes         chang           changest        changest       \n  changing        chang           channel         channel        \n  channels        channel         chanson         chanson        \n  chant           chant           chanticleer     chanticl       \n  chanting        chant           chantries       chantri        \n  chantry         chantri         chants          chant          \n  chaos           chao            chap            chap           \n  chape           chape           chapel          chapel         \n  chapeless       chapeless       chapels         chapel         \n  chaplain        chaplain        chaplains       chaplain       \n  chapless        chapless        chaplet         chaplet        \n  chapmen         chapmen         chaps           chap           \n  chapter         chapter         character       charact        \n  charactered     charact         characterless   characterless  \n  characters      charact         charactery      characteri     \n  characts        charact         charbon         charbon        \n  chare           chare           chares          chare          \n  charg           charg           charge          charg          \n  charged         charg           chargeful       charg          \n  charges         charg           chargeth        chargeth       \n  charging        charg           chariest        chariest       \n  chariness       chari           charing         chare          \n  chariot         chariot         chariots        chariot        \n  charitable      charit          charitably      charit         \n  charities       chariti         charity         chariti        \n  charlemain      charlemain      charles         charl          \n  charm           charm           charmed         charm          \n  charmer         charmer         charmeth        charmeth       \n  charmian        charmian        charming        charm          \n  charmingly      charmingli      charms          charm          \n  charneco        charneco        charnel         charnel        \n  charolois       charoloi        charon          charon         \n  charter         charter         charters        charter        \n  chartreux       chartreux       chary           chari          \n  charybdis       charybdi        chas            cha            \n  chase           chase           chased          chase          \n  chaser          chaser          chaseth         chaseth        \n  chasing         chase           chaste          chast          \n  chastely        chast           chastis         chasti         \n  chastise        chastis         chastised       chastis        \n  chastisement    chastis         chastity        chastiti       \n  chat            chat            chatham         chatham        \n  chatillon       chatillon       chats           chat           \n  chatt           chatt           chattels        chattel        \n  chatter         chatter         chattering      chatter        \n  chattles        chattl          chaud           chaud          \n  chaunted        chaunt          chaw            chaw           \n  chawdron        chawdron        che             che            \n  cheap           cheap           cheapen         cheapen        \n  cheaper         cheaper         cheapest        cheapest       \n  cheaply         cheapli         cheapside       cheapsid       \n  cheat           cheat           cheated         cheat          \n  cheater         cheater         cheaters        cheater        \n  cheating        cheat           cheats          cheat          \n  check           check           checked         check          \n  checker         checker         checking        check          \n  checks          check           cheek           cheek          \n  cheeks          cheek           cheer           cheer          \n  cheered         cheer           cheerer         cheerer        \n  cheerful        cheer           cheerfully      cheerfulli     \n  cheering        cheer           cheerless       cheerless      \n  cheerly         cheerli         cheers          cheer          \n  cheese          chees           chequer         chequer        \n  cher            cher            cherish         cherish        \n  cherished       cherish         cherisher       cherish        \n  cherishes       cherish         cherishing      cherish        \n  cherries        cherri          cherry          cherri         \n  cherrypit       cherrypit       chertsey        chertsei       \n  cherub          cherub          cherubims       cherubim       \n  cherubin        cherubin        cherubins       cherubin       \n  cheshu          cheshu          chess           chess          \n  chest           chest           chester         chester        \n  chestnut        chestnut        chestnuts       chestnut       \n  chests          chest           chetas          cheta          \n  chev            chev            cheval          cheval         \n  chevalier       chevali         chevaliers      chevali        \n  cheveril        cheveril        chew            chew           \n  chewed          chew            chewet          chewet         \n  chewing         chew            chez            chez           \n  chi             chi             chick           chick          \n  chicken         chicken         chickens        chicken        \n  chicurmurco     chicurmurco     chid            chid           \n  chidden         chidden         chide           chide          \n  chiders         chider          chides          chide          \n  chiding         chide           chief           chief          \n  chiefest        chiefest        chiefly         chiefli        \n  chien           chien           child           child          \n  childed         child           childeric       childer        \n  childhood       childhood       childhoods      childhood      \n  childing        child           childish        childish       \n  childishness    childish        childlike       childlik       \n  childness       child           children        children       \n  chill           chill           chilling        chill          \n  chime           chime           chimes          chime          \n  chimney         chimnei         chimneypiece    chimneypiec    \n  chimneys        chimnei         chimurcho       chimurcho      \n  chin            chin            china           china          \n  chine           chine           chines          chine          \n  chink           chink           chinks          chink          \n  chins           chin            chipp           chipp          \n  chipper         chipper         chips           chip           \n  chiron          chiron          chirping        chirp          \n  chirrah         chirrah         chirurgeonly    chirurgeonli   \n  chisel          chisel          chitopher       chitoph        \n  chivalrous      chivalr         chivalry        chivalri       \n  choice          choic           choicely        choic          \n  choicest        choicest        choir           choir          \n  choirs          choir           chok            chok           \n  choke           choke           choked          choke          \n  chokes          choke           choking         choke          \n  choler          choler          choleric        choler         \n  cholers         choler          chollors        chollor        \n  choose          choos           chooser         chooser        \n  chooses         choos           chooseth        chooseth       \n  choosing        choos           chop            chop           \n  chopine         chopin          choplogic       choplog        \n  chopp           chopp           chopped         chop           \n  chopping        chop            choppy          choppi         \n  chops           chop            chopt           chopt          \n  chor            chor            choristers      chorist        \n  chorus          choru           chose           chose          \n  chosen          chosen          chough          chough         \n  choughs         chough          chrish          chrish         \n  christ          christ          christen        christen       \n  christendom     christendom     christendoms    christendom    \n  christening     christen        christenings    christen       \n  christian       christian       christianlike   christianlik   \n  christians      christian       christmas       christma       \n  christom        christom        christopher     christoph      \n  christophero    christophero    chronicle       chronicl       \n  chronicled      chronicl        chronicler      chronicl       \n  chroniclers     chronicl        chronicles      chronicl       \n  chrysolite      chrysolit       chuck           chuck          \n  chucks          chuck           chud            chud           \n  chuffs          chuff           church          church         \n  churches        church          churchman       churchman      \n  churchmen       churchmen       churchyard      churchyard     \n  churchyards     churchyard      churl           churl          \n  churlish        churlish        churlishly      churlishli     \n  churls          churl           churn           churn          \n  chus            chu             cicatrice       cicatric       \n  cicatrices      cicatric        cicely          cice           \n  cicero          cicero          ciceter         cicet          \n  ciel            ciel            ciitzens        ciitzen        \n  cilicia         cilicia         cimber          cimber         \n  cimmerian       cimmerian       cinable         cinabl         \n  cincture        cinctur         cinders         cinder         \n  cine            cine            cinna           cinna          \n  cinque          cinqu           cipher          cipher         \n  ciphers         cipher          circa           circa          \n  circe           circ            circle          circl          \n  circled         circl           circlets        circlet        \n  circling        circl           circuit         circuit        \n  circum          circum          circumcised     circumcis      \n  circumference   circumfer       circummur       circummur      \n  circumscrib     circumscrib     circumscribed   circumscrib    \n  circumscription circumscript    circumspect     circumspect    \n  circumstance    circumst        circumstanced   circumstanc    \n  circumstances   circumst        circumstantial  circumstanti   \n  circumvent      circumv         circumvention   circumvent     \n  cistern         cistern         citadel         citadel        \n  cital           cital           cite            cite           \n  cited           cite            cites           cite           \n  cities          citi            citing          cite           \n  citizen         citizen         citizens        citizen        \n  cittern         cittern         city            citi           \n  civet           civet           civil           civil          \n  civility        civil           civilly         civilli        \n  clack           clack           clad            clad           \n  claim           claim           claiming        claim          \n  claims          claim           clamb           clamb          \n  clamber         clamber         clammer         clammer        \n  clamor          clamor          clamorous       clamor         \n  clamors         clamor          clamour         clamour        \n  clamours        clamour         clang           clang          \n  clangor         clangor         clap            clap           \n  clapp           clapp           clapped         clap           \n  clapper         clapper         clapping        clap           \n  claps           clap            clare           clare          \n  clarence        clarenc         claret          claret         \n  claribel        claribel        clasp           clasp          \n  clasps          clasp           clatter         clatter        \n  claud           claud           claudio         claudio        \n  claudius        claudiu         clause          claus          \n  claw            claw            clawed          claw           \n  clawing         claw            claws           claw           \n  clay            clai            clays           clai           \n  clean           clean           cleanliest      cleanliest     \n  cleanly         cleanli         cleans          clean          \n  cleanse         cleans          cleansing       cleans         \n  clear           clear           clearer         clearer        \n  clearest        clearest        clearly         clearli        \n  clearness       clear           clears          clear          \n  cleave          cleav           cleaving        cleav          \n  clef            clef            cleft           cleft          \n  cleitus         cleitu          clemency        clemenc        \n  clement         clement         cleomenes       cleomen        \n  cleopatpa       cleopatpa       cleopatra       cleopatra      \n  clepeth         clepeth         clept           clept          \n  clerestories    clerestori      clergy          clergi         \n  clergyman       clergyman       clergymen       clergymen      \n  clerk           clerk           clerkly         clerkli        \n  clerks          clerk           clew            clew           \n  client          client          clients         client         \n  cliff           cliff           clifford        clifford       \n  cliffords       clifford        cliffs          cliff          \n  clifton         clifton         climate         climat         \n  climature       climatur        climb           climb          \n  climbed         climb           climber         climber        \n  climbeth        climbeth        climbing        climb          \n  climbs          climb           clime           clime          \n  cling           cling           clink           clink          \n  clinking        clink           clinquant       clinquant      \n  clip            clip            clipp           clipp          \n  clipper         clipper         clippeth        clippeth       \n  clipping        clip            clipt           clipt          \n  clitus          clitu           clo             clo            \n  cloak           cloak           cloakbag        cloakbag       \n  cloaks          cloak           clock           clock          \n  clocks          clock           clod            clod           \n  cloddy          cloddi          clodpole        clodpol        \n  clog            clog            clogging        clog           \n  clogs           clog            cloister        cloister       \n  cloistress      cloistress      cloquence       cloquenc       \n  clos            clo             close           close          \n  closed          close           closely         close          \n  closeness       close           closer          closer         \n  closes          close           closest         closest        \n  closet          closet          closing         close          \n  closure         closur          cloten          cloten         \n  clotens         cloten          cloth           cloth          \n  clothair        clothair        clotharius      clothariu      \n  clothe          cloth           clothes         cloth          \n  clothier        clothier        clothiers       clothier       \n  clothing        cloth           cloths          cloth          \n  clotpoles       clotpol         clotpoll        clotpol        \n  cloud           cloud           clouded         cloud          \n  cloudiness      cloudi          clouds          cloud          \n  cloudy          cloudi          clout           clout          \n  clouted         clout           clouts          clout          \n  cloven          cloven          clover          clover         \n  cloves          clove           clovest         clovest        \n  clowder         clowder         clown           clown          \n  clownish        clownish        clowns          clown          \n  cloy            cloi            cloyed          cloi           \n  cloying         cloi            cloyless        cloyless       \n  cloyment        cloyment        cloys           cloi           \n  club            club            clubs           club           \n  cluck           cluck           clung           clung          \n  clust           clust           clusters        cluster        \n  clutch          clutch          clyster         clyster        \n  cneius          cneiu           cnemies         cnemi          \n  co              co              coach           coach          \n  coaches         coach           coachmakers     coachmak       \n  coact           coact           coactive        coactiv        \n  coagulate       coagul          coal            coal           \n  coals           coal            coarse          coars          \n  coarsely        coars           coast           coast          \n  coasting        coast           coasts          coast          \n  coat            coat            coated          coat           \n  coats           coat            cobble          cobbl          \n  cobbled         cobbl           cobbler         cobbler        \n  cobham          cobham          cobloaf         cobloaf        \n  cobweb          cobweb          cobwebs         cobweb         \n  cock            cock            cockatrice      cockatric      \n  cockatrices     cockatric       cockle          cockl          \n  cockled         cockl           cockney         cocknei        \n  cockpit         cockpit         cocks           cock           \n  cocksure        cocksur         coctus          coctu          \n  cocytus         cocytu          cod             cod            \n  codding         cod             codling         codl           \n  codpiece        codpiec         codpieces       codpiec        \n  cods            cod             coelestibus     coelestibu     \n  coesar          coesar          coeur           coeur          \n  coffer          coffer          coffers         coffer         \n  coffin          coffin          coffins         coffin         \n  cog             cog             cogging         cog            \n  cogitation      cogit           cogitations     cogit          \n  cognition       cognit          cognizance      cogniz         \n  cogscomb        cogscomb        cohabitants     cohabit        \n  coher           coher           cohere          coher          \n  coherence       coher           coherent        coher          \n  cohorts         cohort          coif            coif           \n  coign           coign           coil            coil           \n  coin            coin            coinage         coinag         \n  coiner          coiner          coining         coin           \n  coins           coin            col             col            \n  colbrand        colbrand        colchos         colcho         \n  cold            cold            colder          colder         \n  coldest         coldest         coldly          coldli         \n  coldness        cold            coldspur        coldspur       \n  colebrook       colebrook       colic           colic          \n  collar          collar          collars         collar         \n  collateral      collater        colleagued      colleagu       \n  collect         collect         collected       collect        \n  collection      collect         college         colleg         \n  colleges        colleg          collied         colli          \n  collier         collier         colliers        collier        \n  collop          collop          collusion       collus         \n  colme           colm            colmekill       colmekil       \n  coloquintida    coloquintida    color           color          \n  colors          color           colossus        colossu        \n  colour          colour          colourable      colour         \n  coloured        colour          colouring       colour         \n  colours         colour          colt            colt           \n  colted          colt            colts           colt           \n  columbine       columbin        columbines      columbin       \n  colville        colvil          com             com            \n  comagene        comagen         comart          comart         \n  comb            comb            combat          combat         \n  combatant       combat          combatants      combat         \n  combated        combat          combating       combat         \n  combin          combin          combinate       combin         \n  combination     combin          combine         combin         \n  combined        combin          combless        combless       \n  combustion      combust         come            come           \n  comedian        comedian        comedians       comedian       \n  comedy          comedi          comeliness      comeli         \n  comely          come            comer           comer          \n  comers          comer           comes           come           \n  comest          comest          comet           comet          \n  cometh          cometh          comets          comet          \n  comfect         comfect         comfit          comfit         \n  comfits         comfit          comfort         comfort        \n  comfortable     comfort         comforted       comfort        \n  comforter       comfort         comforting      comfort        \n  comfortless     comfortless     comforts        comfort        \n  comic           comic           comical         comic          \n  coming          come            comings         come           \n  cominius        cominiu         comma           comma          \n  command         command         commande        command        \n  commanded       command         commander       command        \n  commanders      command         commanding      command        \n  commandment     command         commandments    command        \n  commands        command         comme           comm           \n  commenc         commenc         commence        commenc        \n  commenced       commenc         commencement    commenc        \n  commences       commenc         commencing      commenc        \n  commend         commend         commendable     commend        \n  commendation    commend         commendations   commend        \n  commended       commend         commending      commend        \n  commends        commend         comment         comment        \n  commentaries    commentari      commenting      comment        \n  comments        comment         commerce        commerc        \n  commingled      commingl        commiseration   commiser       \n  commission      commiss         commissioners   commission     \n  commissions     commiss         commit          commit         \n  commits         commit          committ         committ        \n  committed       commit          committing      commit         \n  commix          commix          commixed        commix         \n  commixtion      commixt         commixture      commixtur      \n  commodious      commodi         commodities     commod         \n  commodity       commod          common          common         \n  commonalty      commonalti      commoner        common         \n  commoners       common          commonly        commonli       \n  commons         common          commonweal      commonw        \n  commonwealth    commonwealth    commotion       commot         \n  commotions      commot          commune         commun         \n  communicat      communicat      communicate     commun         \n  communication   commun          communities     commun         \n  community       commun          comonty         comonti        \n  compact         compact         companies       compani        \n  companion       companion       companions      companion      \n  companionship   companionship   company         compani        \n  compar          compar          comparative     compar         \n  compare         compar          compared        compar         \n  comparing       compar          comparison      comparison     \n  comparisons     comparison      compartner      compartn       \n  compass         compass         compasses       compass        \n  compassing      compass         compassion      compass        \n  compassionate   compassion      compeers        compeer        \n  compel          compel          compell         compel         \n  compelled       compel          compelling      compel         \n  compels         compel          compensation    compens        \n  competence      compet          competency      compet         \n  competent       compet          competitor      competitor     \n  competitors     competitor      compil          compil         \n  compile         compil          compiled        compil         \n  complain        complain        complainer      complain       \n  complainest     complainest     complaining     complain       \n  complainings    complain        complains       complain       \n  complaint       complaint       complaints      complaint      \n  complement      complement      complements     complement     \n  complete        complet         complexion      complexion     \n  complexioned    complexion      complexions     complexion     \n  complices       complic         complies        compli         \n  compliment      compliment      complimental    compliment     \n  compliments     compliment      complot         complot        \n  complots        complot         complotted      complot        \n  comply          compli          compos          compo          \n  compose         compos          composed        compos         \n  composition     composit        compost         compost        \n  composture      compostur       composure       composur       \n  compound        compound        compounded      compound       \n  compounds       compound        comprehend      comprehend     \n  comprehended    comprehend      comprehends     comprehend     \n  compremises     compremis       compris         compri         \n  comprising      compris         compromis       compromi       \n  compromise      compromis       compt           compt          \n  comptible       comptibl        comptrollers    comptrol       \n  compulsatory    compulsatori    compulsion      compuls        \n  compulsive      compuls         compunctious    compuncti      \n  computation     comput          comrade         comrad         \n  comrades        comrad          comutual        comutu         \n  con             con             concave         concav         \n  concavities     concav          conceal         conceal        \n  concealed       conceal         concealing      conceal        \n  concealment     conceal         concealments    conceal        \n  conceals        conceal         conceit         conceit        \n  conceited       conceit         conceitless     conceitless    \n  conceits        conceit         conceiv         conceiv        \n  conceive        conceiv         conceived       conceiv        \n  conceives       conceiv         conceiving      conceiv        \n  conception      concept         conceptions     concept        \n  conceptious     concepti        concern         concern        \n  concernancy     concern         concerneth      concerneth     \n  concerning      concern         concernings     concern        \n  concerns        concern         conclave        conclav        \n  conclud         conclud         conclude        conclud        \n  concluded       conclud         concludes       conclud        \n  concluding      conclud         conclusion      conclus        \n  conclusions     conclus         concolinel      concolinel     \n  concord         concord         concubine       concubin       \n  concupiscible   concupisc       concupy         concupi        \n  concur          concur          concurring      concur         \n  concurs         concur          condemn         condemn        \n  condemnation    condemn         condemned       condemn        \n  condemning      condemn         condemns        condemn        \n  condescend      condescend      condign         condign        \n  condition       condit          conditionally   condition      \n  conditions      condit          condole         condol         \n  condolement     condol          condoling       condol         \n  conduce         conduc          conduct         conduct        \n  conducted       conduct         conducting      conduct        \n  conductor       conductor       conduit         conduit        \n  conduits        conduit         conected        conect         \n  coney           conei           confection      confect        \n  confectionary   confectionari   confections     confect        \n  confederacy     confederaci     confederate     confeder       \n  confederates    confeder        confer          confer         \n  conference      confer          conferr         conferr        \n  conferring      confer          confess         confess        \n  confessed       confess         confesses       confess        \n  confesseth      confesseth      confessing      confess        \n  confession      confess         confessions     confess        \n  confessor       confessor       confidence      confid         \n  confident       confid          confidently     confid         \n  confin          confin          confine         confin         \n  confined        confin          confineless     confineless    \n  confiners       confin          confines        confin         \n  confining       confin          confirm         confirm        \n  confirmation    confirm         confirmations   confirm        \n  confirmed       confirm         confirmer       confirm        \n  confirmers      confirm         confirming      confirm        \n  confirmities    confirm         confirms        confirm        \n  confiscate      confisc         confiscated     confisc        \n  confiscation    confisc         confixed        confix         \n  conflict        conflict        conflicting     conflict       \n  conflicts       conflict        confluence      confluenc      \n  conflux         conflux         conform         conform        \n  conformable     conform         confound        confound       \n  confounded      confound        confounding     confound       \n  confounds       confound        confront        confront       \n  confronted      confront        confus          confu          \n  confused        confus          confusedly      confusedli     \n  confusion       confus          confusions      confus         \n  confutation     confut          confutes        confut         \n  congeal         congeal         congealed       congeal        \n  congealment     congeal         congee          conge          \n  conger          conger          congest         congest        \n  congied         congi           congratulate    congratul      \n  congreeing      congre          congreeted      congreet       \n  congregate      congreg         congregated     congreg        \n  congregation    congreg         congregations   congreg        \n  congruent       congruent       congruing       congru         \n  conies          coni            conjectural     conjectur      \n  conjecture      conjectur       conjectures     conjectur      \n  conjoin         conjoin         conjoined       conjoin        \n  conjoins        conjoin         conjointly      conjointli     \n  conjunct        conjunct        conjunction     conjunct       \n  conjunctive     conjunct        conjur          conjur         \n  conjuration     conjur          conjurations    conjur         \n  conjure         conjur          conjured        conjur         \n  conjurer        conjur          conjurers       conjur         \n  conjures        conjur          conjuring       conjur         \n  conjuro         conjuro         conn            conn           \n  connected       connect         connive         conniv         \n  conqu           conqu           conquer         conquer        \n  conquered       conquer         conquering      conquer        \n  conqueror       conqueror       conquerors      conqueror      \n  conquers        conquer         conquest        conquest       \n  conquests       conquest        conquring       conqur         \n  conrade         conrad          cons            con            \n  consanguineous  consanguin      consanguinity   consanguin     \n  conscienc       conscienc       conscience      conscienc      \n  consciences     conscienc       conscionable    conscion       \n  consecrate      consecr         consecrated     consecr        \n  consecrations   consecr         consent         consent        \n  consented       consent         consenting      consent        \n  consents        consent         consequence     consequ        \n  consequences    consequ         consequently    consequ        \n  conserve        conserv         conserved       conserv        \n  conserves       conserv         consider        consid         \n  considerance    consider        considerate     consider       \n  consideration   consider        considerations  consider       \n  considered      consid          considering     consid         \n  considerings    consid          considers       consid         \n  consign         consign         consigning      consign        \n  consist         consist         consisteth      consisteth     \n  consisting      consist         consistory      consistori     \n  consists        consist         consolate       consol         \n  consolation     consol          consonancy      conson         \n  consonant       conson          consort         consort        \n  consorted       consort         consortest      consortest     \n  conspectuities  conspectu       conspir         conspir        \n  conspiracy      conspiraci      conspirant      conspir        \n  conspirator     conspir         conspirators    conspir        \n  conspire        conspir         conspired       conspir        \n  conspirers      conspir         conspires       conspir        \n  conspiring      conspir         constable       constabl       \n  constables      constabl        constance       constanc       \n  constancies     constanc        constancy       constanc       \n  constant        constant        constantine     constantin     \n  constantinople  constantinopl   constantly      constantli     \n  constellation   constel         constitution    constitut      \n  constrain       constrain       constrained     constrain      \n  constraineth    constraineth    constrains      constrain      \n  constraint      constraint      constring       constr         \n  construction    construct       construe        constru        \n  consul          consul          consuls         consul         \n  consulship      consulship      consulships     consulship     \n  consult         consult         consulting      consult        \n  consults        consult         consum          consum         \n  consume         consum          consumed        consum         \n  consumes        consum          consuming       consum         \n  consummate      consumm         consummation    consumm        \n  consumption     consumpt        consumptions    consumpt       \n  contagion       contagion       contagious      contagi        \n  contain         contain         containing      contain        \n  contains        contain         contaminate     contamin       \n  contaminated    contamin        contemn         contemn        \n  contemned       contemn         contemning      contemn        \n  contemns        contemn         contemplate     contempl       \n  contemplation   contempl        contemplative   contempl       \n  contempt        contempt        contemptible    contempt       \n  contempts       contempt        contemptuous    contemptu      \n  contemptuously  contemptu       contend         contend        \n  contended       contend         contending      contend        \n  contendon       contendon       content         content        \n  contenta        contenta        contented       content        \n  contenteth      contenteth      contention      content        \n  contentious     contenti        contentless     contentless    \n  contento        contento        contents        content        \n  contest         contest         contestation    contest        \n  continence      contin          continency      contin         \n  continent       contin          continents      contin         \n  continu         continu         continual       continu        \n  continually     continu         continuance     continu        \n  continuantly    continuantli    continuate      continu        \n  continue        continu         continued       continu        \n  continuer       continu         continues       continu        \n  continuing      continu         contract        contract       \n  contracted      contract        contracting     contract       \n  contraction     contract        contradict      contradict     \n  contradicted    contradict      contradiction   contradict     \n  contradicts     contradict      contraries      contrari       \n  contrarieties   contrarieti     contrariety     contrarieti    \n  contrarious     contrari        contrariously   contrari       \n  contrary        contrari        contre          contr          \n  contribution    contribut       contributors    contributor    \n  contrite        contrit         contriv         contriv        \n  contrive        contriv         contrived       contriv        \n  contriver       contriv         contrives       contriv        \n  contriving      contriv         control         control        \n  controll        control         controller      control        \n  controlling     control         controlment     control        \n  controls        control         controversy     controversi    \n  contumelious    contumeli       contumeliously  contumeli      \n  contumely       contum          contusions      contus         \n  convenience     conveni         conveniences    conveni        \n  conveniency     conveni         convenient      conveni        \n  conveniently    conveni         convented       convent        \n  conventicles    conventicl      convents        convent        \n  convers         conver          conversant      convers        \n  conversation    convers         conversations   convers        \n  converse        convers         conversed       convers        \n  converses       convers         conversing      convers        \n  conversion      convers         convert         convert        \n  converted       convert         convertest      convertest     \n  converting      convert         convertite      convertit      \n  convertites     convertit       converts        convert        \n  convey          convei          conveyance      convey         \n  conveyances     convey          conveyers       convey         \n  conveying       convei          convict         convict        \n  convicted       convict         convince        convinc        \n  convinced       convinc         convinces       convinc        \n  convive         conviv          convocation     convoc         \n  convoy          convoi          convulsions     convuls        \n  cony            coni            cook            cook           \n  cookery         cookeri         cooks           cook           \n  cool            cool            cooled          cool           \n  cooling         cool            cools           cool           \n  coop            coop            coops           coop           \n  cop             cop             copatain        copatain       \n  cope            cope            cophetua        cophetua       \n  copied          copi            copies          copi           \n  copious         copiou          copper          copper         \n  copperspur      copperspur      coppice         coppic         \n  copulation      copul           copulatives     copul          \n  copy            copi            cor             cor            \n  coragio         coragio         coral           coral          \n  coram           coram           corambus        corambu        \n  coranto         coranto         corantos        coranto        \n  corbo           corbo           cord            cord           \n  corded          cord            cordelia        cordelia       \n  cordial         cordial         cordis          cordi          \n  cords           cord            core            core           \n  corin           corin           corinth         corinth        \n  corinthian      corinthian      coriolanus      coriolanu      \n  corioli         corioli         cork            cork           \n  corky           corki           cormorant       cormor         \n  corn            corn            cornelia        cornelia       \n  cornelius       corneliu        corner          corner         \n  corners         corner          cornerstone     cornerston     \n  cornets         cornet          cornish         cornish        \n  corns           corn            cornuto         cornuto        \n  cornwall        cornwal         corollary       corollari      \n  coronal         coron           coronation      coron          \n  coronet         coronet         coronets        coronet        \n  corporal        corpor          corporals       corpor         \n  corporate       corpor          corpse          corps          \n  corpulent       corpul          correct         correct        \n  corrected       correct         correcting      correct        \n  correction      correct         correctioner    correction     \n  corrects        correct         correspondence  correspond     \n  correspondent   correspond      corresponding   correspond     \n  corresponsive   correspons      corrigible      corrig         \n  corrival        corriv          corrivals       corriv         \n  corroborate     corrobor        corrosive       corros         \n  corrupt         corrupt         corrupted       corrupt        \n  corrupter       corrupt         corrupters      corrupt        \n  corruptible     corrupt         corruptibly     corrupt        \n  corrupting      corrupt         corruption      corrupt        \n  corruptly       corruptli       corrupts        corrupt        \n  corse           cors            corses          cors           \n  corslet         corslet         cosmo           cosmo          \n  cost            cost            costard         costard        \n  costermongers   costermong      costlier        costlier       \n  costly          costli          costs           cost           \n  cot             cot             cote            cote           \n  coted           cote            cotsall         cotsal         \n  cotsole         cotsol          cotswold        cotswold       \n  cottage         cottag          cottages        cottag         \n  cotus           cotu            couch           couch          \n  couched         couch           couching        couch          \n  couchings       couch           coude           coud           \n  cough           cough           coughing        cough          \n  could           could           couldst         couldst        \n  coulter         coulter         council         council        \n  councillor      councillor      councils        council        \n  counsel         counsel         counsell        counsel        \n  counsellor      counsellor      counsellors     counsellor     \n  counselor       counselor       counselors      counselor      \n  counsels        counsel         count           count          \n  counted         count           countenanc      countenanc     \n  countenance     counten         countenances    counten        \n  counter         counter         counterchange   counterchang   \n  countercheck    countercheck    counterfeit     counterfeit    \n  counterfeited   counterfeit     counterfeiting  counterfeit    \n  counterfeitly   counterfeitli   counterfeits    counterfeit    \n  countermand     countermand     countermands    countermand    \n  countermines    countermin      counterpart     counterpart    \n  counterpoints   counterpoint    counterpois     counterpoi     \n  counterpoise    counterpois     counters        counter        \n  countervail     countervail     countess        countess       \n  countesses      countess        counties        counti         \n  counting        count           countless       countless      \n  countries       countri         countrv         countrv        \n  country         countri         countryman      countryman     \n  countrymen      countrymen      counts          count          \n  county          counti          couper          couper         \n  couple          coupl           coupled         coupl          \n  couplement      couplement      couples         coupl          \n  couplet         couplet         couplets        couplet        \n  cour            cour            courage         courag         \n  courageous      courag          courageously    courag         \n  courages        courag          courier         courier        \n  couriers        courier         couronne        couronn        \n  cours           cour            course          cours          \n  coursed         cours           courser         courser        \n  coursers        courser         courses         cours          \n  coursing        cours           court           court          \n  courted         court           courteous       courteou       \n  courteously     courteous       courtesan       courtesan      \n  courtesies      courtesi        courtesy        courtesi       \n  courtezan       courtezan       courtezans      courtezan      \n  courtier        courtier        courtiers       courtier       \n  courtlike       courtlik        courtly         courtli        \n  courtney        courtnei        courts          court          \n  courtship       courtship       cousin          cousin         \n  cousins         cousin          couterfeit      couterfeit     \n  coutume         coutum          covenant        coven          \n  covenants       coven           covent          covent         \n  coventry        coventri        cover           cover          \n  covered         cover           covering        cover          \n  coverlet        coverlet        covers          cover          \n  covert          covert          covertly        covertli       \n  coverture       covertur        covet           covet          \n  coveted         covet           coveting        covet          \n  covetings       covet           covetous        covet          \n  covetously      covet           covetousness    covet          \n  covets          covet           cow             cow            \n  coward          coward          cowarded        coward         \n  cowardice       cowardic        cowardly        cowardli       \n  cowards         coward          cowardship      cowardship     \n  cowish          cowish          cowl            cowl           \n  cowslip         cowslip         cowslips        cowslip        \n  cox             cox             coxcomb         coxcomb        \n  coxcombs        coxcomb         coy             coi            \n  coystrill       coystril        coz             coz            \n  cozen           cozen           cozenage        cozenag        \n  cozened         cozen           cozener         cozen          \n  cozeners        cozen           cozening        cozen          \n  coziers         cozier          crab            crab           \n  crabbed         crab            crabs           crab           \n  crack           crack           cracked         crack          \n  cracker         cracker         crackers        cracker        \n  cracking        crack           cracks          crack          \n  cradle          cradl           cradled         cradl          \n  cradles         cradl           craft           craft          \n  crafted         craft           craftied        crafti         \n  craftier        craftier        craftily        craftili       \n  crafts          craft           craftsmen       craftsmen      \n  crafty          crafti          cram            cram           \n  cramm           cramm           cramp           cramp          \n  cramps          cramp           crams           cram           \n  cranking        crank           cranks          crank          \n  cranmer         cranmer         crannied        cranni         \n  crannies        cranni          cranny          cranni         \n  crants          crant           crare           crare          \n  crash           crash           crassus         crassu         \n  crav            crav            crave           crave          \n  craved          crave           craven          craven         \n  cravens         craven          craves          crave          \n  craveth         craveth         craving         crave          \n  crawl           crawl           crawling        crawl          \n  crawls          crawl           craz            craz           \n  crazed          craze           crazy           crazi          \n  creaking        creak           cream           cream          \n  create          creat           created         creat          \n  creates         creat           creating        creat          \n  creation        creation        creator         creator        \n  creature        creatur         creatures       creatur        \n  credence        credenc         credent         credent        \n  credible        credibl         credit          credit         \n  creditor        creditor        creditors       creditor       \n  credo           credo           credulity       credul         \n  credulous       credul          creed           creed          \n  creek           creek           creeks          creek          \n  creep           creep           creeping        creep          \n  creeps          creep           crept           crept          \n  crescent        crescent        crescive        cresciv        \n  cressets        cresset         cressid         cressid        \n  cressida        cressida        cressids        cressid        \n  cressy          cressi          crest           crest          \n  crested         crest           crestfall       crestfal       \n  crestless       crestless       crests          crest          \n  cretan          cretan          crete           crete          \n  crevice         crevic          crew            crew           \n  crews           crew            crib            crib           \n  cribb           cribb           cribs           crib           \n  cricket         cricket         crickets        cricket        \n  cried           cri             criedst         criedst        \n  crier           crier           cries           cri            \n  criest          criest          crieth          crieth         \n  crime           crime           crimeful        crime          \n  crimeless       crimeless       crimes          crime          \n  criminal        crimin          crimson         crimson        \n  cringe          cring           cripple         crippl         \n  crisp           crisp           crisped         crisp          \n  crispian        crispian        crispianus      crispianu      \n  crispin         crispin         critic          critic         \n  critical        critic          critics         critic         \n  croak           croak           croaking        croak          \n  croaks          croak           crocodile       crocodil       \n  cromer          cromer          cromwell        cromwel        \n  crone           crone           crook           crook          \n  crookback       crookback       crooked         crook          \n  crooking        crook           crop            crop           \n  cropp           cropp           crosby          crosbi         \n  cross           cross           crossed         cross          \n  crosses         cross           crossest        crossest       \n  crossing        cross           crossings       cross          \n  crossly         crossli         crossness       cross          \n  crost           crost           crotchets       crotchet       \n  crouch          crouch          crouching       crouch         \n  crow            crow            crowd           crowd          \n  crowded         crowd           crowding        crowd          \n  crowds          crowd           crowflowers     crowflow       \n  crowing         crow            crowkeeper      crowkeep       \n  crown           crown           crowned         crown          \n  crowner         crowner         crownet         crownet        \n  crownets        crownet         crowning        crown          \n  crowns          crown           crows           crow           \n  crudy           crudi           cruel           cruel          \n  cruell          cruell          crueller        crueller       \n  cruelly         cruelli         cruels          cruel          \n  cruelty         cruelti         crum            crum           \n  crumble         crumbl          crumbs          crumb          \n  crupper         crupper         crusadoes       crusado        \n  crush           crush           crushed         crush          \n  crushest        crushest        crushing        crush          \n  crust           crust           crusts          crust          \n  crusty          crusti          crutch          crutch         \n  crutches        crutch          cry             cry            \n  crying          cry             crystal         crystal        \n  crystalline     crystallin      crystals        crystal        \n  cub             cub             cubbert         cubbert        \n  cubiculo        cubiculo        cubit           cubit          \n  cubs            cub             cuckold         cuckold        \n  cuckoldly       cuckoldli       cuckolds        cuckold        \n  cuckoo          cuckoo          cucullus        cucullu        \n  cudgel          cudgel          cudgeled        cudgel         \n  cudgell         cudgel          cudgelling      cudgel         \n  cudgels         cudgel          cue             cue            \n  cues            cue             cuff            cuff           \n  cuffs           cuff            cuique          cuiqu          \n  cull            cull            culling         cull           \n  cullion         cullion         cullionly       cullionli      \n  cullions        cullion         culpable        culpabl        \n  culverin        culverin        cum             cum            \n  cumber          cumber          cumberland      cumberland     \n  cunning         cun             cunningly       cunningli      \n  cunnings        cun             cuore           cuor           \n  cup             cup             cupbearer       cupbear        \n  cupboarding     cupboard        cupid           cupid          \n  cupids          cupid           cuppele         cuppel         \n  cups            cup             cur             cur            \n  curan           curan           curate          curat          \n  curb            curb            curbed          curb           \n  curbing         curb            curbs           curb           \n  curd            curd            curdied         curdi          \n  curds           curd            cure            cure           \n  cured           cure            cureless        cureless       \n  curer           curer           cures           cure           \n  curfew          curfew          curing          cure           \n  curio           curio           curiosity       curios         \n  curious         curiou          curiously       curious        \n  curl            curl            curled          curl           \n  curling         curl            curls           curl           \n  currance        curranc         currants        currant        \n  current         current         currents        current        \n  currish         currish         curry           curri          \n  curs            cur             curse           curs           \n  cursed          curs            curses          curs           \n  cursies         cursi           cursing         curs           \n  cursorary       cursorari       curst           curst          \n  curster         curster         curstest        curstest       \n  curstness       curst           cursy           cursi          \n  curtail         curtail         curtain         curtain        \n  curtains        curtain         curtal          curtal         \n  curtis          curti           curtle          curtl          \n  curtsied        curtsi          curtsies        curtsi         \n  curtsy          curtsi          curvet          curvet         \n  curvets         curvet          cushes          cush           \n  cushion         cushion         cushions        cushion        \n  custalorum      custalorum      custard         custard        \n  custody         custodi         custom          custom         \n  customary       customari       customed        custom         \n  customer        custom          customers       custom         \n  customs         custom          custure         custur         \n  cut             cut             cutler          cutler         \n  cutpurse        cutpurs         cutpurses       cutpurs        \n  cuts            cut             cutter          cutter         \n  cutting         cut             cuttle          cuttl          \n  cxsar           cxsar           cyclops         cyclop         \n  cydnus          cydnu           cygnet          cygnet         \n  cygnets         cygnet          cym             cym            \n  cymbals         cymbal          cymbeline       cymbelin       \n  cyme            cyme            cynic           cynic          \n  cynthia         cynthia         cypress         cypress        \n  cypriot         cypriot         cyprus          cypru          \n  cyrus           cyru            cytherea        cytherea       \n  d               d               dabbled         dabbl          \n  dace            dace            dad             dad            \n  daedalus        daedalu         daemon          daemon         \n  daff            daff            daffed          daf            \n  daffest         daffest         daffodils       daffodil       \n  dagger          dagger          daggers         dagger         \n  dagonet         dagonet         daily           daili          \n  daintier        daintier        dainties        dainti         \n  daintiest       daintiest       daintily        daintili       \n  daintiness      dainti          daintry         daintri        \n  dainty          dainti          daisied         daisi          \n  daisies         daisi           daisy           daisi          \n  dale            dale            dalliance       dallianc       \n  dallied         dalli           dallies         dalli          \n  dally           dalli           dallying        dalli          \n  dalmatians      dalmatian       dam             dam            \n  damage          damag           damascus        damascu        \n  damask          damask          damasked        damask         \n  dame            dame            dames           dame           \n  damm            damm            damn            damn           \n  damnable        damnabl         damnably        damnabl        \n  damnation       damnat          damned          damn           \n  damns           damn            damoiselle      damoisel       \n  damon           damon           damosella       damosella      \n  damp            damp            dams            dam            \n  damsel          damsel          damsons         damson         \n  dan             dan             danc            danc           \n  dance           danc            dancer          dancer         \n  dances          danc            dancing         danc           \n  dandle          dandl           dandy           dandi          \n  dane            dane            dang            dang           \n  danger          danger          dangerous       danger         \n  dangerously     danger          dangers         danger         \n  dangling        dangl           daniel          daniel         \n  danish          danish          dank            dank           \n  dankish         dankish         danskers        dansker        \n  daphne          daphn           dappled         dappl          \n  dapples         dappl           dar             dar            \n  dardan          dardan          dardanian       dardanian      \n  dardanius       dardaniu        dare            dare           \n  dared           dare            dareful         dare           \n  dares           dare            darest          darest         \n  daring          dare            darius          dariu          \n  dark            dark            darken          darken         \n  darkening       darken          darkens         darken         \n  darker          darker          darkest         darkest        \n  darkling        darkl           darkly          darkli         \n  darkness        dark            darling         darl           \n  darlings        darl            darnel          darnel         \n  darraign        darraign        dart            dart           \n  darted          dart            darter          darter         \n  dartford        dartford        darting         dart           \n  darts           dart            dash            dash           \n  dashes          dash            dashing         dash           \n  dastard         dastard         dastards        dastard        \n  dat             dat             datchet         datchet        \n  date            date            dated           date           \n  dateless        dateless        dates           date           \n  daub            daub            daughter        daughter       \n  daughters       daughter        daunt           daunt          \n  daunted         daunt           dauntless       dauntless      \n  dauphin         dauphin         daventry        daventri       \n  davy            davi            daw             daw            \n  dawn            dawn            dawning         dawn           \n  daws            daw             day             dai            \n  daylight        daylight        days            dai            \n  dazzle          dazzl           dazzled         dazzl          \n  dazzling        dazzl           de              de             \n  dead            dead            deadly          deadli         \n  deaf            deaf            deafing         deaf           \n  deafness        deaf            deafs           deaf           \n  deal            deal            dealer          dealer         \n  dealers         dealer          dealest         dealest        \n  dealing         deal            dealings        deal           \n  deals           deal            dealt           dealt          \n  dean            dean            deanery         deaneri        \n  dear            dear            dearer          dearer         \n  dearest         dearest         dearly          dearli         \n  dearness        dear            dears           dear           \n  dearth          dearth          dearths         dearth         \n  death           death           deathbed        deathb         \n  deathful        death           deaths          death          \n  deathsman       deathsman       deathsmen       deathsmen      \n  debarred        debar           debase          debas          \n  debate          debat           debated         debat          \n  debatement      debat           debateth        debateth       \n  debating        debat           debauch         debauch        \n  debile          debil           debility        debil          \n  debitor         debitor         debonair        debonair       \n  deborah         deborah         debosh          debosh         \n  debt            debt            debted          debt           \n  debtor          debtor          debtors         debtor         \n  debts           debt            debuty          debuti         \n  decay           decai           decayed         decai          \n  decayer         decay           decaying        decai          \n  decays          decai           deceas          decea          \n  decease         deceas          deceased        deceas         \n  deceit          deceit          deceitful       deceit         \n  deceits         deceit          deceiv          deceiv         \n  deceivable      deceiv          deceive         deceiv         \n  deceived        deceiv          deceiver        deceiv         \n  deceivers       deceiv          deceives        deceiv         \n  deceivest       deceivest       deceiveth       deceiveth      \n  deceiving       deceiv          december        decemb         \n  decent          decent          deceptious      decepti        \n  decerns         decern          decide          decid          \n  decides         decid           decimation      decim          \n  decipher        deciph          deciphers       deciph         \n  decision        decis           decius          deciu          \n  deck            deck            decking         deck           \n  decks           deck            deckt           deckt          \n  declare         declar          declares        declar         \n  declension      declens         declensions     declens        \n  declin          declin          decline         declin         \n  declined        declin          declines        declin         \n  declining       declin          decoct          decoct         \n  decorum         decorum         decreas         decrea         \n  decrease        decreas         decreasing      decreas        \n  decree          decre           decreed         decre          \n  decrees         decre           decrepit        decrepit       \n  dedicate        dedic           dedicated       dedic          \n  dedicates       dedic           dedication      dedic          \n  deed            deed            deedless        deedless       \n  deeds           deed            deem            deem           \n  deemed          deem            deep            deep           \n  deeper          deeper          deepest         deepest        \n  deeply          deepli          deeps           deep           \n  deepvow         deepvow         deer            deer           \n  deesse          deess           defac           defac          \n  deface          defac           defaced         defac          \n  defacer         defac           defacers        defac          \n  defacing        defac           defam           defam          \n  default         default         defeat          defeat         \n  defeated        defeat          defeats         defeat         \n  defeatures      defeatur        defect          defect         \n  defective       defect          defects         defect         \n  defence         defenc          defences        defenc         \n  defend          defend          defendant       defend         \n  defended        defend          defender        defend         \n  defenders       defend          defending       defend         \n  defends         defend          defense         defens         \n  defensible      defens          defensive       defens         \n  defer           defer           deferr          deferr         \n  defiance        defianc         deficient       defici         \n  defied          defi            defies          defi           \n  defil           defil           defile          defil          \n  defiler         defil           defiles         defil          \n  defiling        defil           define          defin          \n  definement      defin           definite        definit        \n  definitive      definit         definitively    definit        \n  deflow          deflow          deflower        deflow         \n  deflowered      deflow          deform          deform         \n  deformed        deform          deformities     deform         \n  deformity       deform          deftly          deftli         \n  defunct         defunct         defunction      defunct        \n  defuse          defus           defy            defi           \n  defying         defi            degenerate      degener        \n  degraded        degrad          degree          degre          \n  degrees         degre           deified         deifi          \n  deifying        deifi           deign           deign          \n  deigned         deign           deiphobus       deiphobu       \n  deities         deiti           deity           deiti          \n  deja            deja            deject          deject         \n  dejected        deject          delabreth       delabreth      \n  delay           delai           delayed         delai          \n  delaying        delai           delays          delai          \n  delectable      delect          deliberate      deliber        \n  delicate        delic           delicates       delic          \n  delicious       delici          deliciousness   delici         \n  delight         delight         delighted       delight        \n  delightful      delight         delights        delight        \n  delinquents     delinqu         deliv           deliv          \n  deliver         deliv           deliverance     deliver        \n  delivered       deliv           delivering      deliv          \n  delivers        deliv           delivery        deliveri       \n  delphos         delpho          deluded         delud          \n  deluding        delud           deluge          delug          \n  delve           delv            delver          delver         \n  delves          delv            demand          demand         \n  demanded        demand          demanding       demand         \n  demands         demand          demean          demean         \n  demeanor        demeanor        demeanour       demeanour      \n  demerits        demerit         demesnes        demesn         \n  demetrius       demetriu        demi            demi           \n  demigod         demigod         demise          demis          \n  demoiselles     demoisel        demon           demon          \n  demonstrable    demonstr        demonstrate     demonstr       \n  demonstrated    demonstr        demonstrating   demonstr       \n  demonstration   demonstr        demonstrative   demonstr       \n  demure          demur           demurely        demur          \n  demuring        demur           den             den            \n  denay           denai           deni            deni           \n  denial          denial          denials         denial         \n  denied          deni            denier          denier         \n  denies          deni            deniest         deniest        \n  denis           deni            denmark         denmark        \n  dennis          denni           denny           denni          \n  denote          denot           denoted         denot          \n  denotement      denot           denounc         denounc        \n  denounce        denounc         denouncing      denounc        \n  dens            den             denunciation    denunci        \n  deny            deni            denying         deni           \n  deo             deo             depart          depart         \n  departed        depart          departest       departest      \n  departing       depart          departure       departur       \n  depeche         depech          depend          depend         \n  dependant       depend          dependants      depend         \n  depended        depend          dependence      depend         \n  dependences     depend          dependency      depend         \n  dependent       depend          dependents      depend         \n  depender        depend          depending       depend         \n  depends         depend          deplore         deplor         \n  deploring       deplor          depopulate      depopul        \n  depos           depo            depose          depos          \n  deposed         depos           deposing        depos          \n  depositaries    depositari      deprav          deprav         \n  depravation     deprav          deprave         deprav         \n  depraved        deprav          depraves        deprav         \n  depress         depress         depriv          depriv         \n  deprive         depriv          depth           depth          \n  depths          depth           deputation      deput          \n  depute          deput           deputed         deput          \n  deputies        deputi          deputing        deput          \n  deputy          deputi          deracinate      deracin        \n  derby           derbi           dercetas        derceta        \n  dere            dere            derides         derid          \n  derision        deris           deriv           deriv          \n  derivation      deriv           derivative      deriv          \n  derive          deriv           derived         deriv          \n  derives         deriv           derogate        derog          \n  derogately      derog           derogation      derog          \n  des             de              desartless      desartless     \n  descant         descant         descend         descend        \n  descended       descend         descending      descend        \n  descends        descend         descension      descens        \n  descent         descent         descents        descent        \n  describe        describ         described       describ        \n  describes       describ         descried        descri         \n  description     descript        descriptions    descript       \n  descry          descri          desdemon        desdemon       \n  desdemona       desdemona       desert          desert         \n  deserts         desert          deserv          deserv         \n  deserve         deserv          deserved        deserv         \n  deservedly      deservedli      deserver        deserv         \n  deservers       deserv          deserves        deserv         \n  deservest       deservest       deserving       deserv         \n  deservings      deserv          design          design         \n  designment      design          designments     design         \n  designs         design          desir           desir          \n  desire          desir           desired         desir          \n  desirers        desir           desires         desir          \n  desirest        desirest        desiring        desir          \n  desirous        desir           desist          desist         \n  desk            desk            desolate        desol          \n  desolation      desol           desp            desp           \n  despair         despair         despairing      despair        \n  despairs        despair         despatch        despatch       \n  desperate       desper          desperately     desper         \n  desperation     desper          despis          despi          \n  despise         despis          despised        despis         \n  despiser        despis          despiseth       despiseth      \n  despising       despis          despite         despit         \n  despiteful      despit          despoiled       despoil        \n  dest            dest            destin          destin         \n  destined        destin          destinies       destini        \n  destiny         destini         destitute       destitut       \n  destroy         destroi         destroyed       destroi        \n  destroyer       destroy         destroyers      destroy        \n  destroying      destroi         destroys        destroi        \n  destruction     destruct        destructions    destruct       \n  det             det             detain          detain         \n  detains         detain          detect          detect         \n  detected        detect          detecting       detect         \n  detection       detect          detector        detector       \n  detects         detect          detention       detent         \n  determin        determin        determinate     determin       \n  determination   determin        determinations  determin       \n  determine       determin        determined      determin       \n  determines      determin        detest          detest         \n  detestable      detest          detested        detest         \n  detesting       detest          detests         detest         \n  detract         detract         detraction      detract        \n  detractions     detract         deucalion       deucalion      \n  deuce           deuc            deum            deum           \n  deux            deux            devant          devant         \n  devesting       devest          device          devic          \n  devices         devic           devil           devil          \n  devilish        devilish        devils          devil          \n  devis           devi            devise          devis          \n  devised         devis           devises         devis          \n  devising        devis           devoid          devoid         \n  devonshire      devonshir       devote          devot          \n  devoted         devot           devotion        devot          \n  devour          devour          devoured        devour         \n  devourers       devour          devouring       devour         \n  devours         devour          devout          devout         \n  devoutly        devoutli        dew             dew            \n  dewberries      dewberri        dewdrops        dewdrop        \n  dewlap          dewlap          dewlapp         dewlapp        \n  dews            dew             dewy            dewi           \n  dexter          dexter          dexteriously    dexteri        \n  dexterity       dexter          di              di             \n  diable          diabl           diablo          diablo         \n  diadem          diadem          dial            dial           \n  dialect         dialect         dialogue        dialogu        \n  dialogued       dialogu         dials           dial           \n  diameter        diamet          diamond         diamond        \n  diamonds        diamond         dian            dian           \n  diana           diana           diaper          diaper         \n  dibble          dibbl           dic             dic            \n  dice            dice            dicers          dicer          \n  dich            dich            dick            dick           \n  dickens         dicken          dickon          dickon         \n  dicky           dicki           dictator        dictat         \n  diction         diction         dictynna        dictynna       \n  did             did             diddle          diddl          \n  didest          didest          dido            dido           \n  didst           didst           die             die            \n  died            di              diedst          diedst         \n  dies            di              diest           diest          \n  diet            diet            dieted          diet           \n  dieter          dieter          dieu            dieu           \n  diff            diff            differ          differ         \n  difference      differ          differences     differ         \n  differency      differ          different       differ         \n  differing       differ          differs         differ         \n  difficile       difficil        difficult       difficult      \n  difficulties    difficulti      difficulty      difficulti     \n  diffidence      diffid          diffidences     diffid         \n  diffus          diffu           diffused        diffus         \n  diffusest       diffusest       dig             dig            \n  digest          digest          digested        digest         \n  digestion       digest          digestions      digest         \n  digg            digg            digging         dig            \n  dighton         dighton         dignified       dignifi        \n  dignifies       dignifi         dignify         dignifi        \n  dignities       digniti         dignity         digniti        \n  digress         digress         digressing      digress        \n  digression      digress         digs            dig            \n  digt            digt            dilate          dilat          \n  dilated         dilat           dilations       dilat          \n  dilatory        dilatori        dild            dild           \n  dildos          dildo           dilemma         dilemma        \n  dilemmas        dilemma         diligence       dilig          \n  diligent        dilig           diluculo        diluculo       \n  dim             dim             dimension       dimens         \n  dimensions      dimens          diminish        diminish       \n  diminishing     diminish        diminution      diminut        \n  diminutive      diminut         diminutives     diminut        \n  dimm            dimm            dimmed          dim            \n  dimming         dim             dimpled         dimpl          \n  dimples         dimpl           dims            dim            \n  din             din             dine            dine           \n  dined           dine            diner           diner          \n  dines           dine            ding            ding           \n  dining          dine            dinner          dinner         \n  dinners         dinner          dinnertime      dinnertim      \n  dint            dint            diomed          diom           \n  diomede         diomed          diomedes        diomed         \n  dion            dion            dip             dip            \n  dipp            dipp            dipping         dip            \n  dips            dip             dir             dir            \n  dire            dire            direct          direct         \n  directed        direct          directing       direct         \n  direction       direct          directions      direct         \n  directitude     directitud      directive       direct         \n  directly        directli        directs         direct         \n  direful         dire            direness        dire           \n  direst          direst          dirge           dirg           \n  dirges          dirg            dirt            dirt           \n  dirty           dirti           dis             di             \n  disability      disabl          disable         disabl         \n  disabled        disabl          disabling       disabl         \n  disadvantage    disadvantag     disagree        disagre        \n  disallow        disallow        disanimates     disanim        \n  disannul        disannul        disannuls       disannul       \n  disappointed    disappoint      disarm          disarm         \n  disarmed        disarm          disarmeth       disarmeth      \n  disarms         disarm          disaster        disast         \n  disasters       disast          disastrous      disastr        \n  disbench        disbench        disbranch       disbranch      \n  disburdened     disburden       disburs         disbur         \n  disburse        disburs         disbursed       disburs        \n  discandy        discandi        discandying     discandi       \n  discard         discard         discarded       discard        \n  discase         discas          discased        discas         \n  discern         discern         discerner       discern        \n  discerning      discern         discernings     discern        \n  discerns        discern         discharg        discharg       \n  discharge       discharg        discharged      discharg       \n  discharging     discharg        discipled       discipl        \n  disciples       discipl         disciplin       disciplin      \n  discipline      disciplin       disciplined     disciplin      \n  disciplines     disciplin       disclaim        disclaim       \n  disclaiming     disclaim        disclaims       disclaim       \n  disclos         disclo          disclose        disclos        \n  disclosed       disclos         discloses       disclos        \n  discolour       discolour       discoloured     discolour      \n  discolours      discolour       discomfit       discomfit      \n  discomfited     discomfit       discomfiture    discomfitur    \n  discomfort      discomfort      discomfortable  discomfort     \n  discommend      discommend      disconsolate    disconsol      \n  discontent      discont         discontented    discont        \n  discontentedly  discontentedli  discontenting   discont        \n  discontents     discont         discontinue     discontinu     \n  discontinued    discontinu      discord         discord        \n  discordant      discord         discords        discord        \n  discourse       discours        discoursed      discours       \n  discourser      discours        discourses      discours       \n  discoursive     discours        discourtesy     discourtesi    \n  discov          discov          discover        discov         \n  discovered      discov          discoverers     discover       \n  discoveries     discoveri       discovering     discov         \n  discovers       discov          discovery       discoveri      \n  discredit       discredit       discredited     discredit      \n  discredits      discredit       discreet        discreet       \n  discreetly      discreetli      discretion      discret        \n  discretions     discret         discuss         discuss        \n  disdain         disdain         disdained       disdain        \n  disdaineth      disdaineth      disdainful      disdain        \n  disdainfully    disdainfulli    disdaining      disdain        \n  disdains        disdain         disdnguish      disdnguish     \n  diseas          disea           disease         diseas         \n  diseased        diseas          diseases        diseas         \n  disedg          disedg          disembark       disembark      \n  disfigure       disfigur        disfigured      disfigur       \n  disfurnish      disfurnish      disgorge        disgorg        \n  disgrac         disgrac         disgrace        disgrac        \n  disgraced       disgrac         disgraceful     disgrac        \n  disgraces       disgrac         disgracing      disgrac        \n  disgracious     disgraci        disguis         disgui         \n  disguise        disguis         disguised       disguis        \n  disguiser       disguis         disguises       disguis        \n  disguising      disguis         dish            dish           \n  dishabited      dishabit        dishclout       dishclout      \n  dishearten      dishearten      disheartens     dishearten     \n  dishes          dish            dishonest       dishonest      \n  dishonestly     dishonestli     dishonesty      dishonesti     \n  dishonor        dishonor        dishonorable    dishonor       \n  dishonors       dishonor        dishonour       dishonour      \n  dishonourable   dishonour       dishonoured     dishonour      \n  dishonours      dishonour       disinherit      disinherit     \n  disinherited    disinherit      disjoin         disjoin        \n  disjoining      disjoin         disjoins        disjoin        \n  disjoint        disjoint        disjunction     disjunct       \n  dislik          dislik          dislike         dislik         \n  disliken        disliken        dislikes        dislik         \n  dislimns        dislimn         dislocate       disloc         \n  dislodg         dislodg         disloyal        disloy         \n  disloyalty      disloyalti      dismal          dismal         \n  dismantle       dismantl        dismantled      dismantl       \n  dismask         dismask         dismay          dismai         \n  dismayed        dismai          dismemb         dismemb        \n  dismember       dismemb         dismes          dism           \n  dismiss         dismiss         dismissed       dismiss        \n  dismissing      dismiss         dismission      dismiss        \n  dismount        dismount        dismounted      dismount       \n  disnatur        disnatur        disobedience    disobedi       \n  disobedient     disobedi        disobey         disobei        \n  disobeys        disobei         disorb          disorb         \n  disorder        disord          disordered      disord         \n  disorderly      disorderli      disorders       disord         \n  disparage       disparag        disparagement   disparag       \n  disparagements  disparag        dispark         dispark        \n  dispatch        dispatch        dispensation    dispens        \n  dispense        dispens         dispenses       dispens        \n  dispers         disper          disperse        dispers        \n  dispersed       dispers         dispersedly     dispersedli    \n  dispersing      dispers         dispiteous      dispit         \n  displac         displac         displace        displac        \n  displaced       displac         displant        displant       \n  displanting     displant        display         displai        \n  displayed       displai         displeas        displea        \n  displease       displeas        displeased      displeas       \n  displeasing     displeas        displeasure     displeasur     \n  displeasures    displeasur      disponge        dispong        \n  disport         disport         disports        disport        \n  dispos          dispo           dispose         dispos         \n  disposed        dispos          disposer        dispos         \n  disposing       dispos          disposition     disposit       \n  dispositions    disposit        dispossess      dispossess     \n  dispossessing   dispossess      disprais        disprai        \n  dispraise       disprais        dispraising     disprais       \n  dispraisingly   dispraisingli   dispropertied   disproperti    \n  disproportion   disproport      disproportioned disproport     \n  disprov         disprov         disprove        disprov        \n  disproved       disprov         dispursed       dispurs        \n  disputable      disput          disputation     disput         \n  disputations    disput          dispute         disput         \n  disputed        disput          disputes        disput         \n  disputing       disput          disquantity     disquant       \n  disquiet        disquiet        disquietly      disquietli     \n  disrelish       disrelish       disrobe         disrob         \n  disseat         disseat         dissemble       dissembl       \n  dissembled      dissembl        dissembler      dissembl       \n  dissemblers     dissembl        dissembling     dissembl       \n  dissembly       dissembl        dissension      dissens        \n  dissensions     dissens         dissentious     dissenti       \n  dissever        dissev          dissipation     dissip         \n  dissolute       dissolut        dissolutely     dissolut       \n  dissolution     dissolut        dissolutions    dissolut       \n  dissolv         dissolv         dissolve        dissolv        \n  dissolved       dissolv         dissolves       dissolv        \n  dissuade        dissuad         dissuaded       dissuad        \n  distaff         distaff         distaffs        distaff        \n  distain         distain         distains        distain        \n  distance        distanc         distant         distant        \n  distaste        distast         distasted       distast        \n  distasteful     distast         distemp         distemp        \n  distemper       distemp         distemperature  distemperatur  \n  distemperatures distemperatur   distempered     distemp        \n  distempering    distemp         distil          distil         \n  distill         distil          distillation    distil         \n  distilled       distil          distills        distil         \n  distilment      distil          distinct        distinct       \n  distinction     distinct        distinctly      distinctli     \n  distingue       distingu        distinguish     distinguish    \n  distinguishes   distinguish     distinguishment distinguish    \n  distract        distract        distracted      distract       \n  distractedly    distractedli    distraction     distract       \n  distractions    distract        distracts       distract       \n  distrain        distrain        distraught      distraught     \n  distress        distress        distressed      distress       \n  distresses      distress        distressful     distress       \n  distribute      distribut       distributed     distribut      \n  distribution    distribut       distrust        distrust       \n  distrustful     distrust        disturb         disturb        \n  disturbed       disturb         disturbers      disturb        \n  disturbing      disturb         disunite        disunit        \n  disvalued       disvalu         disvouch        disvouch       \n  dit             dit             ditch           ditch          \n  ditchers        ditcher         ditches         ditch          \n  dites           dite            ditties         ditti          \n  ditty           ditti           diurnal         diurnal        \n  div             div             dive            dive           \n  diver           diver           divers          diver          \n  diversely       divers          diversity       divers         \n  divert          divert          diverted        divert         \n  diverts         divert          dives           dive           \n  divest          divest          dividable       divid          \n  dividant        divid           divide          divid          \n  divided         divid           divides         divid          \n  divideth        divideth        divin           divin          \n  divination      divin           divine          divin          \n  divinely        divin           divineness      divin          \n  diviner         divin           divines         divin          \n  divinest        divinest        divining        divin          \n  divinity        divin           division        divis          \n  divisions       divis           divorc          divorc         \n  divorce         divorc          divorced        divorc         \n  divorcement     divorc          divorcing       divorc         \n  divulg          divulg          divulge         divulg         \n  divulged        divulg          divulging       divulg         \n  dizy            dizi            dizzy           dizzi          \n  do              do              doating         doat           \n  dobbin          dobbin          dock            dock           \n  docks           dock            doct            doct           \n  doctor          doctor          doctors         doctor         \n  doctrine        doctrin         document        document       \n  dodge           dodg            doe             doe            \n  doer            doer            doers           doer           \n  does            doe             doest           doest          \n  doff            doff            dog             dog            \n  dogberry        dogberri        dogfish         dogfish        \n  dogg            dogg            dogged          dog            \n  dogs            dog             doigts          doigt          \n  doing           do              doings          do             \n  doit            doit            doits           doit           \n  dolabella       dolabella       dole            dole           \n  doleful         dole            doll            doll           \n  dollar          dollar          dollars         dollar         \n  dolor           dolor           dolorous        dolor          \n  dolour          dolour          dolours         dolour         \n  dolphin         dolphin         dolt            dolt           \n  dolts           dolt            domestic        domest         \n  domestics       domest          dominance       domin          \n  dominations     domin           dominator       domin          \n  domine          domin           domineer        domin          \n  domineering     domin           dominical       domin          \n  dominion        dominion        dominions       dominion       \n  domitius        domitiu         dommelton       dommelton      \n  don             don             donalbain       donalbain      \n  donation        donat           donc            donc           \n  doncaster       doncast         done            done           \n  dong            dong            donn            donn           \n  donne           donn            donner          donner         \n  donnerai        donnerai        doom            doom           \n  doomsday        doomsdai        door            door           \n  doorkeeper      doorkeep        doors           door           \n  dorcas          dorca           doreus          doreu          \n  doricles        doricl          dormouse        dormous        \n  dorothy         dorothi         dorset          dorset         \n  dorsetshire     dorsetshir      dost            dost           \n  dotage          dotag           dotant          dotant         \n  dotard          dotard          dotards         dotard         \n  dote            dote            doted           dote           \n  doters          doter           dotes           dote           \n  doteth          doteth          doth            doth           \n  doting          dote            double          doubl          \n  doubled         doubl           doubleness      doubl          \n  doubler         doubler         doublet         doublet        \n  doublets        doublet         doubling        doubl          \n  doubly          doubli          doubt           doubt          \n  doubted         doubt           doubtful        doubt          \n  doubtfully      doubtfulli      doubting        doubt          \n  doubtless       doubtless       doubts          doubt          \n  doug            doug            dough           dough          \n  doughty         doughti         doughy          doughi         \n  douglas         dougla          dout            dout           \n  doute           dout            douts           dout           \n  dove            dove            dovehouse       dovehous       \n  dover           dover           doves           dove           \n  dow             dow             dowager         dowag          \n  dowdy           dowdi           dower           dower          \n  dowerless       dowerless       dowers          dower          \n  dowlas          dowla           dowle           dowl           \n  down            down            downfall        downfal        \n  downright       downright       downs           down           \n  downstairs      downstair       downtrod        downtrod       \n  downward        downward        downwards       downward       \n  downy           downi           dowries         dowri          \n  dowry           dowri           dowsabel        dowsabel       \n  doxy            doxi            dozed           doze           \n  dozen           dozen           dozens          dozen          \n  dozy            dozi            drab            drab           \n  drabbing        drab            drabs           drab           \n  drachma         drachma         drachmas        drachma        \n  draff           draff           drag            drag           \n  dragg           dragg           dragged         drag           \n  dragging        drag            dragon          dragon         \n  dragonish       dragonish       dragons         dragon         \n  drain           drain           drained         drain          \n  drains          drain           drake           drake          \n  dram            dram            dramatis        dramati        \n  drank           drank           draught         draught        \n  draughts        draught         drave           drave          \n  draw            draw            drawbridge      drawbridg      \n  drawer          drawer          drawers         drawer         \n  draweth         draweth         drawing         draw           \n  drawling        drawl           drawn           drawn          \n  draws           draw            drayman         drayman        \n  draymen         draymen         dread           dread          \n  dreaded         dread           dreadful        dread          \n  dreadfully      dreadfulli      dreading        dread          \n  dreads          dread           dream           dream          \n  dreamer         dreamer         dreamers        dreamer        \n  dreaming        dream           dreams          dream          \n  dreamt          dreamt          drearning       drearn         \n  dreary          dreari          dreg            dreg           \n  dregs           dreg            drench          drench         \n  drenched        drench          dress           dress          \n  dressed         dress           dresser         dresser        \n  dressing        dress           dressings       dress          \n  drest           drest           drew            drew           \n  dribbling       dribbl          dried           dri            \n  drier           drier           dries           dri            \n  drift           drift           drily           drili          \n  drink           drink           drinketh        drinketh       \n  drinking        drink           drinkings       drink          \n  drinks          drink           driv            driv           \n  drive           drive           drivelling      drivel         \n  driven          driven          drives          drive          \n  driveth         driveth         driving         drive          \n  drizzle         drizzl          drizzled        drizzl         \n  drizzles        drizzl          droit           droit          \n  drollery        drolleri        dromio          dromio         \n  dromios         dromio          drone           drone          \n  drones          drone           droop           droop          \n  droopeth        droopeth        drooping        droop          \n  droops          droop           drop            drop           \n  dropheir        dropheir        droplets        droplet        \n  dropp           dropp           dropper         dropper        \n  droppeth        droppeth        dropping        drop           \n  droppings       drop            drops           drop           \n  dropsied        dropsi          dropsies        dropsi         \n  dropsy          dropsi          dropt           dropt          \n  dross           dross           drossy          drossi         \n  drought         drought         drove           drove          \n  droven          droven          drovier         drovier        \n  drown           drown           drowned         drown          \n  drowning        drown           drowns          drown          \n  drows           drow            drowse          drows          \n  drowsily        drowsili        drowsiness      drowsi         \n  drowsy          drowsi          drudge          drudg          \n  drudgery        drudgeri        drudges         drudg          \n  drug            drug            drugg           drugg          \n  drugs           drug            drum            drum           \n  drumble         drumbl          drummer         drummer        \n  drumming        drum            drums           drum           \n  drunk           drunk           drunkard        drunkard       \n  drunkards       drunkard        drunken         drunken        \n  drunkenly       drunkenli       drunkenness     drunken        \n  dry             dry             dryness         dryness        \n  dst             dst             du              du             \n  dub             dub             dubb            dubb           \n  ducat           ducat           ducats          ducat          \n  ducdame         ducdam          duchess         duchess        \n  duchies         duchi           duchy           duchi          \n  duck            duck            ducking         duck           \n  ducks           duck            dudgeon         dudgeon        \n  due             due             duellist        duellist       \n  duello          duello          duer            duer           \n  dues            due             duff            duff           \n  dug             dug             dugs            dug            \n  duke            duke            dukedom         dukedom        \n  dukedoms        dukedom         dukes           duke           \n  dulcet          dulcet          dulche          dulch          \n  dull            dull            dullard         dullard        \n  duller          duller          dullest         dullest        \n  dulling         dull            dullness        dull           \n  dulls           dull            dully           dulli          \n  dulness         dul             duly            duli           \n  dumain          dumain          dumb            dumb           \n  dumbe           dumb            dumbly          dumbl          \n  dumbness        dumb            dump            dump           \n  dumps           dump            dun             dun            \n  duncan          duncan          dung            dung           \n  dungeon         dungeon         dungeons        dungeon        \n  dunghill        dunghil         dunghills       dunghil        \n  dungy           dungi           dunnest         dunnest        \n  dunsinane       dunsinan        dunsmore        dunsmor        \n  dunstable       dunstabl        dupp            dupp           \n  durance         duranc          during          dure           \n  durst           durst           dusky           duski          \n  dust            dust            dusted          dust           \n  dusty           dusti           dutch           dutch          \n  dutchman        dutchman        duteous         duteou         \n  duties          duti            dutiful         duti           \n  duty            duti            dwarf           dwarf          \n  dwarfish        dwarfish        dwell           dwell          \n  dwellers        dweller         dwelling        dwell          \n  dwells          dwell           dwelt           dwelt          \n  dwindle         dwindl          dy              dy             \n  dye             dye             dyed            dy             \n  dyer            dyer            dying           dy             \n  e               e               each            each           \n  eager           eager           eagerly         eagerli        \n  eagerness       eager           eagle           eagl           \n  eagles          eagl            eaning          ean            \n  eanlings        eanl            ear             ear            \n  earing          ear             earl            earl           \n  earldom         earldom         earlier         earlier        \n  earliest        earliest        earliness       earli          \n  earls           earl            early           earli          \n  earn            earn            earned          earn           \n  earnest         earnest         earnestly       earnestli      \n  earnestness     earnest         earns           earn           \n  ears            ear             earth           earth          \n  earthen         earthen         earthlier       earthlier      \n  earthly         earthli         earthquake      earthquak      \n  earthquakes     earthquak       earthy          earthi         \n  eas             ea              ease            eas            \n  eased           eas             easeful         eas            \n  eases           eas             easier          easier         \n  easiest         easiest         easiliest       easiliest      \n  easily          easili          easiness        easi           \n  easing          eas             east            east           \n  eastcheap       eastcheap       easter          easter         \n  eastern         eastern         eastward        eastward       \n  easy            easi            eat             eat            \n  eaten           eaten           eater           eater          \n  eaters          eater           eating          eat            \n  eats            eat             eaux            eaux           \n  eaves           eav             ebb             ebb            \n  ebbing          eb              ebbs            ebb            \n  ebon            ebon            ebony           eboni          \n  ebrew           ebrew           ecce            ecc            \n  echapper        echapp          echo            echo           \n  echoes          echo            eclips          eclip          \n  eclipse         eclips          eclipses        eclips         \n  ecolier         ecoli           ecoutez         ecoutez        \n  ecstacy         ecstaci         ecstasies       ecstasi        \n  ecstasy         ecstasi         ecus            ecu            \n  eden            eden            edg             edg            \n  edgar           edgar           edge            edg            \n  edged           edg             edgeless        edgeless       \n  edges           edg             edict           edict          \n  edicts          edict           edifice         edific         \n  edifices        edific          edified         edifi          \n  edifies         edifi           edition         edit           \n  edm             edm             edmund          edmund         \n  edmunds         edmund          edmundsbury     edmundsburi    \n  educate         educ            educated        educ           \n  education       educ            edward          edward         \n  eel             eel             eels            eel            \n  effect          effect          effected        effect         \n  effectless      effectless      effects         effect         \n  effectual       effectu         effectually     effectu        \n  effeminate      effemin         effigies        effigi         \n  effus           effu            effuse          effus          \n  effusion        effus           eftest          eftest         \n  egal            egal            egally          egal           \n  eget            eget            egeus           egeu           \n  egg             egg             eggs            egg            \n  eggshell        eggshel         eglamour        eglamour       \n  eglantine       eglantin        egma            egma           \n  ego             ego             egregious       egregi         \n  egregiously     egregi          egress          egress         \n  egypt           egypt           egyptian        egyptian       \n  egyptians       egyptian        eie             eie            \n  eight           eight           eighteen        eighteen       \n  eighth          eighth          eightpenny      eightpenni     \n  eighty          eighti          eisel           eisel          \n  either          either          eject           eject          \n  eke             ek              el              el             \n  elbe            elb             elbow           elbow          \n  elbows          elbow           eld             eld            \n  elder           elder           elders          elder          \n  eldest          eldest          eleanor         eleanor        \n  elect           elect           elected         elect          \n  election        elect           elegancy        eleg           \n  elegies         elegi           element         element        \n  elements        element         elephant        eleph          \n  elephants       eleph           elevated        elev           \n  eleven          eleven          eleventh        eleventh       \n  elf             elf             elflocks        elflock        \n  eliads          eliad           elinor          elinor         \n  elizabeth       elizabeth       ell             ell            \n  elle            ell             ellen           ellen          \n  elm             elm             eloquence       eloqu          \n  eloquent        eloqu           else            els            \n  elsewhere       elsewher        elsinore        elsinor        \n  eltham          eltham          elves           elv            \n  elvish          elvish          ely             eli            \n  elysium         elysium         em              em             \n  emballing       embal           embalm          embalm         \n  embalms         embalm          embark          embark         \n  embarked        embark          embarquements   embarqu        \n  embassade       embassad        embassage       embassag       \n  embassies       embassi         embassy         embassi        \n  embattailed     embattail       embattl         embattl        \n  embattle        embattl         embay           embai          \n  embellished     embellish       embers          ember          \n  emblaze         emblaz          emblem          emblem         \n  emblems         emblem          embodied        embodi         \n  embold          embold          emboldens       embolden       \n  emboss          emboss          embossed        emboss         \n  embounded       embound         embowel         embowel        \n  embowell        embowel         embrac          embrac         \n  embrace         embrac          embraced        embrac         \n  embracement     embrac          embracements    embrac         \n  embraces        embrac          embracing       embrac         \n  embrasures      embrasur        embroider       embroid        \n  embroidery      embroideri      emhracing       emhrac         \n  emilia          emilia          eminence        emin           \n  eminent         emin            eminently       emin           \n  emmanuel        emmanuel        emnity          emniti         \n  empale          empal           emperal         emper          \n  emperess        emperess        emperial        emperi         \n  emperor         emperor         empery          emperi         \n  emphasis        emphasi         empire          empir          \n  empirics        empir           empiricutic     empiricut      \n  empleached      empleach        employ          emploi         \n  employed        emploi          employer        employ         \n  employment      employ          employments     employ         \n  empoison        empoison        empress         empress        \n  emptied         empti           emptier         emptier        \n  empties         empti           emptiness       empti          \n  empty           empti           emptying        empti          \n  emulate         emul            emulation       emul           \n  emulations      emul            emulator        emul           \n  emulous         emul            en              en             \n  enact           enact           enacted         enact          \n  enacts          enact           enactures       enactur        \n  enamell         enamel          enamelled       enamel         \n  enamour         enamour         enamoured       enamour        \n  enanmour        enanmour        encamp          encamp         \n  encamped        encamp          encave          encav          \n  enceladus       enceladu        enchaf          enchaf         \n  enchafed        enchaf          enchant         enchant        \n  enchanted       enchant         enchanting      enchant        \n  enchantingly    enchantingli    enchantment     enchant        \n  enchantress     enchantress     enchants        enchant        \n  enchas          encha           encircle        encircl        \n  encircled       encircl         enclos          enclo          \n  enclose         enclos          enclosed        enclos         \n  encloses        enclos          encloseth       encloseth      \n  enclosing       enclos          enclouded       encloud        \n  encompass       encompass       encompassed     encompass      \n  encompasseth    encompasseth    encompassment   encompass      \n  encore          encor           encorporal      encorpor       \n  encount         encount         encounter       encount        \n  encountered     encount         encounters      encount        \n  encourage       encourag        encouraged      encourag       \n  encouragement   encourag        encrimsoned     encrimson      \n  encroaching     encroach        encumb          encumb         \n  end             end             endamage        endamag        \n  endamagement    endamag         endanger        endang         \n  endart          endart          endear          endear         \n  endeared        endear          endeavour       endeavour      \n  endeavours      endeavour       ended           end            \n  ender           ender           ending          end            \n  endings         end             endite          endit          \n  endless         endless         endow           endow          \n  endowed         endow           endowments      endow          \n  endows          endow           ends            end            \n  endu            endu            endue           endu           \n  endur           endur           endurance       endur          \n  endure          endur           endured         endur          \n  endures         endur           enduring        endur          \n  endymion        endymion        eneas           enea           \n  enemies         enemi           enemy           enemi          \n  enernies        enerni          enew            enew           \n  enfeebled       enfeebl         enfeebles       enfeebl        \n  enfeoff         enfeoff         enfetter        enfett         \n  enfoldings      enfold          enforc          enforc         \n  enforce         enforc          enforced        enforc         \n  enforcedly      enforcedli      enforcement     enforc         \n  enforces        enforc          enforcest       enforcest      \n  enfranched      enfranch        enfranchis      enfranchi      \n  enfranchise     enfranchis      enfranchised    enfranchis     \n  enfranchisement enfranchis      enfreed         enfre          \n  enfreedoming    enfreedom       engag           engag          \n  engage          engag           engaged         engag          \n  engagements     engag           engaging        engag          \n  engaol          engaol          engend          engend         \n  engender        engend          engenders       engend         \n  engilds         engild          engine          engin          \n  engineer        engin           enginer         engin          \n  engines         engin           engirt          engirt         \n  england         england         english         english        \n  englishman      englishman      englishmen      englishmen     \n  engluts         englut          englutted       englut         \n  engraffed       engraf          engraft         engraft        \n  engrafted       engraft         engrav          engrav         \n  engrave         engrav          engross         engross        \n  engrossed       engross         engrossest      engrossest     \n  engrossing      engross         engrossments    engross        \n  enguard         enguard         enigma          enigma         \n  enigmatical     enigmat         enjoin          enjoin         \n  enjoined        enjoin          enjoy           enjoi          \n  enjoyed         enjoi           enjoyer         enjoy          \n  enjoying        enjoi           enjoys          enjoi          \n  enkindle        enkindl         enkindled       enkindl        \n  enlard          enlard          enlarg          enlarg         \n  enlarge         enlarg          enlarged        enlarg         \n  enlargement     enlarg          enlargeth       enlargeth      \n  enlighten       enlighten       enlink          enlink         \n  enmesh          enmesh          enmities        enmiti         \n  enmity          enmiti          ennoble         ennobl         \n  ennobled        ennobl          enobarb         enobarb        \n  enobarbus       enobarbu        enon            enon           \n  enormity        enorm           enormous        enorm          \n  enough          enough          enow            enow           \n  enpatron        enpatron        enpierced       enpierc        \n  enquir          enquir          enquire         enquir         \n  enquired        enquir          enrag           enrag          \n  enrage          enrag           enraged         enrag          \n  enrages         enrag           enrank          enrank         \n  enrapt          enrapt          enrich          enrich         \n  enriched        enrich          enriches        enrich         \n  enridged        enridg          enrings         enr            \n  enrob           enrob           enrobe          enrob          \n  enroll          enrol           enrolled        enrol          \n  enrooted        enroot          enrounded       enround        \n  enschedul       enschedul       ensconce        ensconc        \n  ensconcing      ensconc         enseamed        enseam         \n  ensear          ensear          enseigne        enseign        \n  enseignez       enseignez       ensemble        ensembl        \n  enshelter       enshelt         enshielded      enshield       \n  enshrines       enshrin         ensign          ensign         \n  ensigns         ensign          enskied         enski          \n  ensman          ensman          ensnare         ensnar         \n  ensnared        ensnar          ensnareth       ensnareth      \n  ensteep         ensteep         ensu            ensu           \n  ensue           ensu            ensued          ensu           \n  ensues          ensu            ensuing         ensu           \n  enswathed       enswath         ent             ent            \n  entail          entail          entame          entam          \n  entangled       entangl         entangles       entangl        \n  entendre        entendr         enter           enter          \n  entered         enter           entering        enter          \n  enterprise      enterpris       enterprises     enterpris      \n  enters          enter           entertain       entertain      \n  entertained     entertain       entertainer     entertain      \n  entertaining    entertain       entertainment   entertain      \n  entertainments  entertain       enthrall        enthral        \n  enthralled      enthral         enthron         enthron        \n  enthroned       enthron         entice          entic          \n  enticements     entic           enticing        entic          \n  entire          entir           entirely        entir          \n  entitle         entitl          entitled        entitl         \n  entitling       entitl          entomb          entomb         \n  entombed        entomb          entrails        entrail        \n  entrance        entranc         entrances       entranc        \n  entrap          entrap          entrapp         entrapp        \n  entre           entr            entreat         entreat        \n  entreated       entreat         entreaties      entreati       \n  entreating      entreat         entreatments    entreat        \n  entreats        entreat         entreaty        entreati       \n  entrench        entrench        entry           entri          \n  entwist         entwist         envelop         envelop        \n  envenom         envenom         envenomed       envenom        \n  envenoms        envenom         envied          envi           \n  envies          envi            envious         enviou         \n  enviously       envious         environ         environ        \n  environed       environ         envoy           envoi          \n  envy            envi            envying         envi           \n  enwheel         enwheel         enwombed        enwomb         \n  enwraps         enwrap          ephesian        ephesian       \n  ephesians       ephesian        ephesus         ephesu         \n  epicure         epicur          epicurean       epicurean      \n  epicures        epicur          epicurism       epicur         \n  epicurus        epicuru         epidamnum       epidamnum      \n  epidaurus       epidauru        epigram         epigram        \n  epilepsy        epilepsi        epileptic       epilept        \n  epilogue        epilogu         epilogues       epilogu        \n  epistles        epistl          epistrophus     epistrophu     \n  epitaph         epitaph         epitaphs        epitaph        \n  epithet         epithet         epitheton       epitheton      \n  epithets        epithet         epitome         epitom         \n  equal           equal           equalities      equal          \n  equality        equal           equall          equal          \n  equally         equal           equalness       equal          \n  equals          equal           equinoctial     equinocti      \n  equinox         equinox         equipage        equipag        \n  equity          equiti          equivocal       equivoc        \n  equivocate      equivoc         equivocates     equivoc        \n  equivocation    equivoc         equivocator     equivoc        \n  er              er              erbear          erbear         \n  erbearing       erbear          erbears         erbear         \n  erbeat          erbeat          erblows         erblow         \n  erboard         erboard         erborne         erborn         \n  ercame          ercam           ercast          ercast         \n  ercharg         ercharg         ercharged       ercharg        \n  ercharging      ercharg         ercles          ercl           \n  ercome          ercom           ercover         ercov          \n  ercrows         ercrow          erdoing         erdo           \n  ere             er              erebus          erebu          \n  erect           erect           erected         erect          \n  erecting        erect           erection        erect          \n  erects          erect           erewhile        erewhil        \n  erflourish      erflourish      erflow          erflow         \n  erflowing       erflow          erflows         erflow         \n  erfraught       erfraught       erga            erga           \n  ergalled        ergal           erglanced       erglanc        \n  ergo            ergo            ergone          ergon          \n  ergrow          ergrow          ergrown         ergrown        \n  ergrowth        ergrowth        erhang          erhang         \n  erhanging       erhang          erhasty         erhasti        \n  erhear          erhear          erheard         erheard        \n  eringoes        eringo          erjoy           erjoi          \n  erleap          erleap          erleaps         erleap         \n  erleavens       erleaven        erlook          erlook         \n  erlooking       erlook          ermaster        ermast         \n  ermengare       ermengar        ermount         ermount        \n  ern             ern             ernight         ernight        \n  eros            ero             erpaid          erpaid         \n  erparted        erpart          erpast          erpast         \n  erpays          erpai           erpeer          erpeer         \n  erperch         erperch         erpicturing     erpictur       \n  erpingham       erpingham       erposting       erpost         \n  erpow           erpow           erpress         erpress        \n  erpressed       erpress         err             err            \n  errand          errand          errands         errand         \n  errant          errant          errate          errat          \n  erraught        erraught        erreaches       erreach        \n  erred           er              errest          errest         \n  erring          er              erroneous       erron          \n  error           error           errors          error          \n  errs            err             errule          errul          \n  errun           errun           erset           erset          \n  ershade         ershad          ershades        ershad         \n  ershine         ershin          ershot          ershot         \n  ersized         ersiz           erskip          erskip         \n  erslips         erslip          erspreads       erspread       \n  erst            erst            erstare         erstar         \n  erstep          erstep          erstunk         erstunk        \n  ersway          erswai          ersways         erswai         \n  erswell         erswel          erta            erta           \n  ertake          ertak           erteemed        erteem         \n  erthrow         erthrow         erthrown        erthrown       \n  erthrows        erthrow         ertook          ertook         \n  ertop           ertop           ertopping       ertop          \n  ertrip          ertrip          erturn          erturn         \n  erudition       erudit          eruption        erupt          \n  eruptions       erupt           ervalues        ervalu         \n  erwalk          erwalk          erwatch         erwatch        \n  erween          erween          erweens         erween         \n  erweigh         erweigh         erweighs        erweigh        \n  erwhelm         erwhelm         erwhelmed       erwhelm        \n  erworn          erworn          es              es             \n  escalus         escalu          escap           escap          \n  escape          escap           escaped         escap          \n  escapes         escap           eschew          eschew         \n  escoted         escot           esill           esil           \n  especial        especi          especially      especi         \n  esperance       esper           espials         espial         \n  espied          espi            espies          espi           \n  espous          espou           espouse         espous         \n  espy            espi            esquire         esquir         \n  esquires        esquir          essay           essai          \n  essays          essai           essence         essenc         \n  essential       essenti         essentially     essenti        \n  esses           ess             essex           essex          \n  est             est             establish       establish      \n  established     establish       estate          estat          \n  estates         estat           esteem          esteem         \n  esteemed        esteem          esteemeth       esteemeth      \n  esteeming       esteem          esteems         esteem         \n  estimable       estim           estimate        estim          \n  estimation      estim           estimations     estim          \n  estime          estim           estranged       estrang        \n  estridge        estridg         estridges       estridg        \n  et              et              etc             etc            \n  etceteras       etcetera        ete             et             \n  eternal         etern           eternally       etern          \n  eterne          etern           eternity        etern          \n  eterniz         eterniz         etes            et             \n  ethiop          ethiop          ethiope         ethiop         \n  ethiopes        ethiop          ethiopian       ethiopian      \n  etna            etna            eton            eton           \n  etre            etr             eunuch          eunuch         \n  eunuchs         eunuch          euphrates       euphrat        \n  euphronius      euphroniu       euriphile       euriphil       \n  europa          europa          europe          europ          \n  ev              ev              evade           evad           \n  evades          evad            evans           evan           \n  evasion         evas            evasions        evas           \n  eve             ev              even            even           \n  evening         even            evenly          evenli         \n  event           event           eventful        event          \n  events          event           ever            ever           \n  everlasting     everlast        everlastingly   everlastingli  \n  evermore        evermor         every           everi          \n  everyone        everyon         everything      everyth        \n  everywhere      everywher       evidence        evid           \n  evidences       evid            evident         evid           \n  evil            evil            evilly          evilli         \n  evils           evil            evitate         evit           \n  ewe             ew              ewer            ewer           \n  ewers           ewer            ewes            ew             \n  exact           exact           exacted         exact          \n  exactest        exactest        exacting        exact          \n  exaction        exact           exactions       exact          \n  exactly         exactli         exacts          exact          \n  exalt           exalt           exalted         exalt          \n  examin          examin          examination     examin         \n  examinations    examin          examine         examin         \n  examined        examin          examines        examin         \n  exampl          exampl          example         exampl         \n  exampled        exampl          examples        exampl         \n  exasperate      exasper         exasperates     exasper        \n  exceed          exce            exceeded        exceed         \n  exceedeth       exceedeth       exceeding       exceed         \n  exceedingly     exceedingli     exceeds         exce           \n  excel           excel           excelled        excel          \n  excellence      excel           excellencies    excel          \n  excellency      excel           excellent       excel          \n  excellently     excel           excelling       excel          \n  excels          excel           except          except         \n  excepted        except          excepting       except         \n  exception       except          exceptions      except         \n  exceptless      exceptless      excess          excess         \n  excessive       excess          exchang         exchang        \n  exchange        exchang         exchanged       exchang        \n  exchequer       exchequ         exchequers      exchequ        \n  excite          excit           excited         excit          \n  excitements     excit           excites         excit          \n  exclaim         exclaim         exclaims        exclaim        \n  exclamation     exclam          exclamations    exclam         \n  excludes        exclud          excommunicate   excommun       \n  excommunication excommun        excrement       excrement      \n  excrements      excrement       excursion       excurs         \n  excursions      excurs          excus           excu           \n  excusable       excus           excuse          excus          \n  excused         excus           excuses         excus          \n  excusez         excusez         excusing        excus          \n  execrable       execr           execrations     execr          \n  execute         execut          executed        execut         \n  executing       execut          execution       execut         \n  executioner     execution       executioners    execution      \n  executor        executor        executors       executor       \n  exempt          exempt          exempted        exempt         \n  exequies        exequi          exercise        exercis        \n  exercises       exercis         exeter          exet           \n  exeunt          exeunt          exhal           exhal          \n  exhalation      exhal           exhalations     exhal          \n  exhale          exhal           exhales         exhal          \n  exhaust         exhaust         exhibit         exhibit        \n  exhibiters      exhibit         exhibition      exhibit        \n  exhort          exhort          exhortation     exhort         \n  exigent         exig            exil            exil           \n  exile           exil            exiled          exil           \n  exion           exion           exist           exist          \n  exists          exist           exit            exit           \n  exits           exit            exorciser       exorcis        \n  exorcisms       exorc           exorcist        exorcist       \n  expect          expect          expectance      expect         \n  expectancy      expect          expectation     expect         \n  expectations    expect          expected        expect         \n  expecters       expect          expecting       expect         \n  expects         expect          expedience      expedi         \n  expedient       expedi          expediently     expedi         \n  expedition      expedit         expeditious     expediti       \n  expel           expel           expell          expel          \n  expelling       expel           expels          expel          \n  expend          expend          expense         expens         \n  expenses        expens          experienc       experienc      \n  experience      experi          experiences     experi         \n  experiment      experi          experimental    experiment     \n  experiments     experi          expert          expert         \n  expertness      expert          expiate         expiat         \n  expiation       expiat          expir           expir          \n  expiration      expir           expire          expir          \n  expired         expir           expires         expir          \n  expiring        expir           explication     explic         \n  exploit         exploit         exploits        exploit        \n  expos           expo            expose          expos          \n  exposing        expos           exposition      exposit        \n  expositor       expositor       expostulate     expostul       \n  expostulation   expostul        exposture       expostur       \n  exposure        exposur         expound         expound        \n  expounded       expound         express         express        \n  expressed       express         expresseth      expresseth     \n  expressing      express         expressive      express        \n  expressly       expressli       expressure      expressur      \n  expuls          expul           expulsion       expuls         \n  exquisite       exquisit        exsufflicate    exsuffl        \n  extant          extant          extemporal      extempor       \n  extemporally    extempor        extempore       extempor       \n  extend          extend          extended        extend         \n  extends         extend          extent          extent         \n  extenuate       extenu          extenuated      extenu         \n  extenuates      extenu          extenuation     extenu         \n  exterior        exterior        exteriorly      exteriorli     \n  exteriors       exterior        extermin        extermin       \n  extern          extern          external        extern         \n  extinct         extinct         extincted       extinct        \n  extincture      extinctur       extinguish      extinguish     \n  extirp          extirp          extirpate       extirp         \n  extirped        extirp          extol           extol          \n  extoll          extol           extolment       extol          \n  exton           exton           extort          extort         \n  extorted        extort          extortion       extort         \n  extortions      extort          extra           extra          \n  extract         extract         extracted       extract        \n  extracting      extract         extraordinarily extraordinarili\n  extraordinary   extraordinari   extraught       extraught      \n  extravagancy    extravag        extravagant     extravag       \n  extreme         extrem          extremely       extrem         \n  extremes        extrem          extremest       extremest      \n  extremities     extrem          extremity       extrem         \n  exuent          exuent          exult           exult          \n  exultation      exult           ey              ey             \n  eyas            eya             eyases          eyas           \n  eye             ey              eyeball         eyebal         \n  eyeballs        eyebal          eyebrow         eyebrow        \n  eyebrows        eyebrow         eyed            ei             \n  eyeless         eyeless         eyelid          eyelid         \n  eyelids         eyelid          eyes            ey             \n  eyesight        eyesight        eyestrings      eyestr         \n  eying           ei              eyne            eyn            \n  eyrie           eyri            fa              fa             \n  fabian          fabian          fable           fabl           \n  fables          fabl            fabric          fabric         \n  fabulous        fabul           fac             fac            \n  face            face            faced           face           \n  facere          facer           faces           face           \n  faciant         faciant         facile          facil          \n  facility        facil           facinerious     facineri       \n  facing          face            facit           facit          \n  fact            fact            faction         faction        \n  factionary      factionari      factions        faction        \n  factious        factiou         factor          factor         \n  factors         factor          faculties       faculti        \n  faculty         faculti         fade            fade           \n  faded           fade            fadeth          fadeth         \n  fadge           fadg            fading          fade           \n  fadings         fade            fadom           fadom          \n  fadoms          fadom           fagot           fagot          \n  fagots          fagot           fail            fail           \n  failing         fail            fails           fail           \n  fain            fain            faint           faint          \n  fainted         faint           fainter         fainter        \n  fainting        faint           faintly         faintli        \n  faintness       faint           faints          faint          \n  fair            fair            fairer          fairer         \n  fairest         fairest         fairies         fairi          \n  fairing         fair            fairings        fair           \n  fairly          fairli          fairness        fair           \n  fairs           fair            fairwell        fairwel        \n  fairy           fairi           fais            fai            \n  fait            fait            faites          fait           \n  faith           faith           faithful        faith          \n  faithfull       faithful        faithfully      faithfulli     \n  faithless       faithless       faiths          faith          \n  faitors         faitor          fal             fal            \n  falchion        falchion        falcon          falcon         \n  falconbridge    falconbridg     falconer        falcon         \n  falconers       falcon          fall            fall           \n  fallacy         fallaci         fallen          fallen         \n  falleth         falleth         falliable       falliabl       \n  fallible        fallibl         falling         fall           \n  fallow          fallow          fallows         fallow         \n  falls           fall            fally           falli          \n  falorous        falor           false           fals           \n  falsehood       falsehood       falsely         fals           \n  falseness       fals            falser          falser         \n  falsify         falsifi         falsing         fals           \n  falstaff        falstaff        falstaffs       falstaff       \n  falter          falter          fam             fam            \n  fame            fame            famed           fame           \n  familiar        familiar        familiarity     familiar       \n  familiarly      familiarli      familiars       familiar       \n  family          famili          famine          famin          \n  famish          famish          famished        famish         \n  famous          famou           famoused        famous         \n  famously        famous          fan             fan            \n  fanatical       fanat           fancies         fanci          \n  fancy           fanci           fane            fane           \n  fanes           fane            fang            fang           \n  fangled         fangl           fangless        fangless       \n  fangs           fang            fann            fann           \n  fanning         fan             fans            fan            \n  fantasied       fantasi         fantasies       fantasi        \n  fantastic       fantast         fantastical     fantast        \n  fantastically   fantast         fantasticoes    fantastico     \n  fantasy         fantasi         fap             fap            \n  far             far             farborough      farborough     \n  farced          farc            fardel          fardel         \n  fardels         fardel          fare            fare           \n  fares           fare            farewell        farewel        \n  farewells       farewel         fariner         farin          \n  faring          fare            farm            farm           \n  farmer          farmer          farmhouse       farmhous       \n  farms           farm            farre           farr           \n  farrow          farrow          farther         farther        \n  farthest        farthest        farthing        farth          \n  farthingale     farthingal      farthingales    farthingal     \n  farthings       farth           fartuous        fartuou        \n  fas             fa              fashion         fashion        \n  fashionable     fashion         fashioning      fashion        \n  fashions        fashion         fast            fast           \n  fasted          fast            fasten          fasten         \n  fastened        fasten          faster          faster         \n  fastest         fastest         fasting         fast           \n  fastly          fastli          fastolfe        fastolf        \n  fasts           fast            fat             fat            \n  fatal           fatal           fatally         fatal          \n  fate            fate            fated           fate           \n  fates           fate            father          father         \n  fathered        father          fatherless      fatherless     \n  fatherly        fatherli        fathers         father         \n  fathom          fathom          fathomless      fathomless     \n  fathoms         fathom          fatigate        fatig          \n  fatness         fat             fats            fat            \n  fatted          fat             fatter          fatter         \n  fattest         fattest         fatting         fat            \n  fatuus          fatuu           fauconbridge    fauconbridg    \n  faulconbridge   faulconbridg    fault           fault          \n  faultiness      faulti          faultless       faultless      \n  faults          fault           faulty          faulti         \n  fausse          fauss           fauste          faust          \n  faustuses       faustus         faut            faut           \n  favor           favor           favorable       favor          \n  favorably       favor           favors          favor          \n  favour          favour          favourable      favour         \n  favoured        favour          favouredly      favouredli     \n  favourer        favour          favourers       favour         \n  favouring       favour          favourite       favourit       \n  favourites      favourit        favours         favour         \n  favout          favout          fawn            fawn           \n  fawneth         fawneth         fawning         fawn           \n  fawns           fawn            fay             fai            \n  fe              fe              fealty          fealti         \n  fear            fear            feared          fear           \n  fearest         fearest         fearful         fear           \n  fearfull        fearful         fearfully       fearfulli      \n  fearfulness     fear            fearing         fear           \n  fearless        fearless        fears           fear           \n  feast           feast           feasted         feast          \n  feasting        feast           feasts          feast          \n  feat            feat            feated          feat           \n  feater          feater          feather         feather        \n  feathered       feather         feathers        feather        \n  featly          featli          feats           feat           \n  featur          featur          feature         featur         \n  featured        featur          featureless     featureless    \n  features        featur          february        februari       \n  fecks           feck            fed             fed            \n  fedary          fedari          federary        federari       \n  fee             fee             feeble          feebl          \n  feebled         feebl           feebleness      feebl          \n  feebling        feebl           feebly          feebli         \n  feed            feed            feeder          feeder         \n  feeders         feeder          feedeth         feedeth        \n  feeding         feed            feeds           feed           \n  feel            feel            feeler          feeler         \n  feeling         feel            feelingly       feelingli      \n  feels           feel            fees            fee            \n  feet            feet            fehemently      fehement       \n  feign           feign           feigned         feign          \n  feigning        feign           feil            feil           \n  feith           feith           felicitate      felicit        \n  felicity        felic           fell            fell           \n  fellest         fellest         fellies         felli          \n  fellow          fellow          fellowly        fellowli       \n  fellows         fellow          fellowship      fellowship     \n  fellowships     fellowship      fells           fell           \n  felon           felon           felonious       feloni         \n  felony          feloni          felt            felt           \n  female          femal           females         femal          \n  feminine        feminin         fen             fen            \n  fenc            fenc            fence           fenc           \n  fencer          fencer          fencing         fenc           \n  fends           fend            fennel          fennel         \n  fenny           fenni           fens            fen            \n  fenton          fenton          fer             fer            \n  ferdinand       ferdinand       fere            fere           \n  fernseed        fernse          ferrara         ferrara        \n  ferrers         ferrer          ferret          ferret         \n  ferry           ferri           ferryman        ferryman       \n  fertile         fertil          fertility       fertil         \n  fervency        fervenc         fervour         fervour        \n  fery            feri            fest            fest           \n  feste           fest            fester          fester         \n  festinate       festin          festinately     festin         \n  festival        festiv          festivals       festiv         \n  fet             fet             fetch           fetch          \n  fetches         fetch           fetching        fetch          \n  fetlock         fetlock         fetlocks        fetlock        \n  fett            fett            fetter          fetter         \n  fettering       fetter          fetters         fetter         \n  fettle          fettl           feu             feu            \n  feud            feud            fever           fever          \n  feverous        fever           fevers          fever          \n  few             few             fewer           fewer          \n  fewest          fewest          fewness         few            \n  fickle          fickl           fickleness      fickl          \n  fico            fico            fiction         fiction        \n  fiddle          fiddl           fiddler         fiddler        \n  fiddlestick     fiddlestick     fidele          fidel          \n  fidelicet       fidelicet       fidelity        fidel          \n  fidius          fidiu           fie             fie            \n  field           field           fielded         field          \n  fields          field           fiend           fiend          \n  fiends          fiend           fierce          fierc          \n  fiercely        fierc           fierceness      fierc          \n  fiery           fieri           fife            fife           \n  fifes           fife            fifteen         fifteen        \n  fifteens        fifteen         fifteenth       fifteenth      \n  fifth           fifth           fifty           fifti          \n  fiftyfold       fiftyfold       fig             fig            \n  fight           fight           fighter         fighter        \n  fightest        fightest        fighteth        fighteth       \n  fighting        fight           fights          fight          \n  figo            figo            figs            fig            \n  figur           figur           figure          figur          \n  figured         figur           figures         figur          \n  figuring        figur           fike            fike           \n  fil             fil             filberts        filbert        \n  filch           filch           filches         filch          \n  filching        filch           file            file           \n  filed           file            files           file           \n  filial          filial          filius          filiu          \n  fill            fill            filled          fill           \n  fillet          fillet          filling         fill           \n  fillip          fillip          fills           fill           \n  filly           filli           film            film           \n  fils            fil             filth           filth          \n  filths          filth           filthy          filthi         \n  fin             fin             finally         final          \n  finch           finch           find            find           \n  finder          finder          findeth         findeth        \n  finding         find            findings        find           \n  finds           find            fine            fine           \n  fineless        fineless        finely          fine           \n  finem           finem           fineness        fine           \n  finer           finer           fines           fine           \n  finest          finest          fing            fing           \n  finger          finger          fingering       finger         \n  fingers         finger          fingre          fingr          \n  fingres         fingr           finical         finic          \n  finish          finish          finished        finish         \n  finisher        finish          finless         finless        \n  finn            finn            fins            fin            \n  finsbury        finsburi        fir             fir            \n  firago          firago          fire            fire           \n  firebrand       firebrand       firebrands      firebrand      \n  fired           fire            fires           fire           \n  firework        firework        fireworks       firework       \n  firing          fire            firk            firk           \n  firm            firm            firmament       firmament      \n  firmly          firmli          firmness        firm           \n  first           first           firstlings      firstl         \n  fish            fish            fisher          fisher         \n  fishermen       fishermen       fishers         fisher         \n  fishes          fish            fishified       fishifi        \n  fishmonger      fishmong        fishpond        fishpond       \n  fisnomy         fisnomi         fist            fist           \n  fisting         fist            fists           fist           \n  fistula         fistula         fit             fit            \n  fitchew         fitchew         fitful          fit            \n  fitly           fitli           fitment         fitment        \n  fitness         fit             fits            fit            \n  fitted          fit             fitter          fitter         \n  fittest         fittest         fitteth         fitteth        \n  fitting         fit             fitzwater       fitzwat        \n  five            five            fivepence       fivep          \n  fives           five            fix             fix            \n  fixed           fix             fixes           fix            \n  fixeth          fixeth          fixing          fix            \n  fixture         fixtur          fl              fl             \n  flag            flag            flagging        flag           \n  flagon          flagon          flagons         flagon         \n  flags           flag            flail           flail          \n  flakes          flake           flaky           flaki          \n  flam            flam            flame           flame          \n  flamen          flamen          flamens         flamen         \n  flames          flame           flaming         flame          \n  flaminius       flaminiu        flanders        flander        \n  flannel         flannel         flap            flap           \n  flaring         flare           flash           flash          \n  flashes         flash           flashing        flash          \n  flask           flask           flat            flat           \n  flatly          flatli          flatness        flat           \n  flats           flat            flatt           flatt          \n  flatter         flatter         flattered       flatter        \n  flatterer       flatter         flatterers      flatter        \n  flatterest      flatterest      flatteries      flatteri       \n  flattering      flatter         flatters        flatter        \n  flattery        flatteri        flaunts         flaunt         \n  flavio          flavio          flavius         flaviu         \n  flaw            flaw            flaws           flaw           \n  flax            flax            flaxen          flaxen         \n  flay            flai            flaying         flai           \n  flea            flea            fleance         fleanc         \n  fleas           flea            flecked         fleck          \n  fled            fled            fledge          fledg          \n  flee            flee            fleec           fleec          \n  fleece          fleec           fleeces         fleec          \n  fleer           fleer           fleering        fleer          \n  fleers          fleer           fleet           fleet          \n  fleeter         fleeter         fleeting        fleet          \n  fleming         fleme           flemish         flemish        \n  flesh           flesh           fleshes         flesh          \n  fleshly         fleshli         fleshment       fleshment      \n  fleshmonger     fleshmong       flew            flew           \n  flexible        flexibl         flexure         flexur         \n  flibbertigibbet flibbertigibbet flickering      flicker        \n  flidge          flidg           fliers          flier          \n  flies           fli             flieth          flieth         \n  flight          flight          flights         flight         \n  flighty         flighti         flinch          flinch         \n  fling           fling           flint           flint          \n  flints          flint           flinty          flinti         \n  flirt           flirt           float           float          \n  floated         float           floating        float          \n  flock           flock           flocks          flock          \n  flood           flood           floodgates      floodgat       \n  floods          flood           floor           floor          \n  flora           flora           florence        florenc        \n  florentine      florentin       florentines     florentin      \n  florentius      florentiu       florizel        florizel       \n  flote           flote           floulish        floulish       \n  flour           flour           flourish        flourish       \n  flourishes      flourish        flourisheth     flourisheth    \n  flourishing     flourish        flout           flout          \n  flouted         flout           flouting        flout          \n  flouts          flout           flow            flow           \n  flowed          flow            flower          flower         \n  flowerets       floweret        flowers         flower         \n  flowing         flow            flown           flown          \n  flows           flow            fluellen        fluellen       \n  fluent          fluent          flung           flung          \n  flush           flush           flushing        flush          \n  fluster         fluster         flute           flute          \n  flutes          flute           flutter         flutter        \n  flux            flux            fluxive         fluxiv         \n  fly             fly             flying          fly            \n  fo              fo              foal            foal           \n  foals           foal            foam            foam           \n  foamed          foam            foaming         foam           \n  foams           foam            foamy           foami          \n  fob             fob             focative        foc            \n  fodder          fodder          foe             foe            \n  foeman          foeman          foemen          foemen         \n  foes            foe             fog             fog            \n  foggy           foggi           fogs            fog            \n  foh             foh             foi             foi            \n  foil            foil            foiled          foil           \n  foils           foil            foin            foin           \n  foining         foin            foins           foin           \n  fois            foi             foison          foison         \n  foisons         foison          foist           foist          \n  foix            foix            fold            fold           \n  folded          fold            folds           fold           \n  folio           folio           folk            folk           \n  folks           folk            follies         folli          \n  follow          follow          followed        follow         \n  follower        follow          followers       follow         \n  followest       followest       following       follow         \n  follows         follow          folly           folli          \n  fond            fond            fonder          fonder         \n  fondly          fondli          fondness        fond           \n  font            font            fontibell       fontibel       \n  food            food            fool            fool           \n  fooleries       fooleri         foolery         fooleri        \n  foolhardy       foolhardi       fooling         fool           \n  foolish         foolish         foolishly       foolishli      \n  foolishness     foolish         fools           fool           \n  foot            foot            football        footbal        \n  footboy         footboi         footboys        footboi        \n  footed          foot            footfall        footfal        \n  footing         foot            footman         footman        \n  footmen         footmen         footpath        footpath       \n  footsteps       footstep        footstool       footstool      \n  fopp            fopp            fopped          fop            \n  foppery         fopperi         foppish         foppish        \n  fops            fop             for             for            \n  forage          forag           foragers        forag          \n  forbade         forbad          forbear         forbear        \n  forbearance     forbear         forbears        forbear        \n  forbid          forbid          forbidden       forbidden      \n  forbiddenly     forbiddenli     forbids         forbid         \n  forbod          forbod          forborne        forborn        \n  forc            forc            force           forc           \n  forced          forc            forceful        forc           \n  forceless       forceless       forces          forc           \n  forcible        forcibl         forcibly        forcibl        \n  forcing         forc            ford            ford           \n  fordid          fordid          fordo           fordo          \n  fordoes         fordo           fordone         fordon         \n  fore            fore            forecast        forecast       \n  forefather      forefath        forefathers     forefath       \n  forefinger      forefing        forego          forego         \n  foregone        foregon         forehand        forehand       \n  forehead        forehead        foreheads       forehead       \n  forehorse       forehors        foreign         foreign        \n  foreigner       foreign         foreigners      foreign        \n  foreknowing     foreknow        foreknowledge   foreknowledg   \n  foremost        foremost        forenamed       forenam        \n  forenoon        forenoon        forerun         forerun        \n  forerunner      forerunn        forerunning     forerun        \n  foreruns        forerun         foresaid        foresaid       \n  foresaw         foresaw         foresay         foresai        \n  foresee         forese          foreseeing      forese         \n  foresees        forese          foreshow        foreshow       \n  foreskirt       foreskirt       forespent       foresp         \n  forest          forest          forestall       forestal       \n  forestalled     forestal        forester        forest         \n  foresters       forest          forests         forest         \n  foretell        foretel         foretelling     foretel        \n  foretells       foretel         forethink       forethink      \n  forethought     forethought     foretold        foretold       \n  forever         forev           foreward        foreward       \n  forewarn        forewarn        forewarned      forewarn       \n  forewarning     forewarn        forfeit         forfeit        \n  forfeited       forfeit         forfeiters      forfeit        \n  forfeiting      forfeit         forfeits        forfeit        \n  forfeiture      forfeitur       forfeitures     forfeitur      \n  forfend         forfend         forfended       forfend        \n  forg            forg            forgave         forgav         \n  forge           forg            forged          forg           \n  forgeries       forgeri         forgery         forgeri        \n  forges          forg            forget          forget         \n  forgetful       forget          forgetfulness   forget         \n  forgetive       forget          forgets         forget         \n  forgetting      forget          forgive         forgiv         \n  forgiven        forgiven        forgiveness     forgiv         \n  forgo           forgo           forgoing        forgo          \n  forgone         forgon          forgot          forgot         \n  forgotten       forgotten       fork            fork           \n  forked          fork            forks           fork           \n  forlorn         forlorn         form            form           \n  formal          formal          formally        formal         \n  formed          form            former          former         \n  formerly        formerli        formless        formless       \n  forms           form            fornication     fornic         \n  fornications    fornic          fornicatress    fornicatress   \n  forres          forr            forrest         forrest        \n  forsake         forsak          forsaken        forsaken       \n  forsaketh       forsaketh       forslow         forslow        \n  forsook         forsook         forsooth        forsooth       \n  forspent        forspent        forspoke        forspok        \n  forswear        forswear        forswearing     forswear       \n  forswore        forswor         forsworn        forsworn       \n  fort            fort            forted          fort           \n  forth           forth           forthcoming     forthcom       \n  forthlight      forthlight      forthright      forthright     \n  forthwith       forthwith       fortification   fortif         \n  fortifications  fortif          fortified       fortifi        \n  fortifies       fortifi         fortify         fortifi        \n  fortinbras      fortinbra       fortitude       fortitud       \n  fortnight       fortnight       fortress        fortress       \n  fortresses      fortress        forts           fort           \n  fortun          fortun          fortuna         fortuna        \n  fortunate       fortun          fortunately     fortun         \n  fortune         fortun          fortuned        fortun         \n  fortunes        fortun          fortward        fortward       \n  forty           forti           forum           forum          \n  forward         forward         forwarding      forward        \n  forwardness     forward         forwards        forward        \n  forwearied      forweari        fosset          fosset         \n  fost            fost            foster          foster         \n  fostered        foster          fought          fought         \n  foughten        foughten        foul            foul           \n  fouler          fouler          foulest         foulest        \n  foully          foulli          foulness        foul           \n  found           found           foundation      foundat        \n  foundations     foundat         founded         found          \n  founder         founder         fount           fount          \n  fountain        fountain        fountains       fountain       \n  founts          fount           four            four           \n  fourscore       fourscor        fourteen        fourteen       \n  fourth          fourth          foutra          foutra         \n  fowl            fowl            fowler          fowler         \n  fowling         fowl            fowls           fowl           \n  fox             fox             foxes           fox            \n  foxship         foxship         fracted         fract          \n  fraction        fraction        fractions       fraction       \n  fragile         fragil          fragment        fragment       \n  fragments       fragment        fragrant        fragrant       \n  frail           frail           frailer         frailer        \n  frailties       frailti         frailty         frailti        \n  fram            fram            frame           frame          \n  framed          frame           frames          frame          \n  frampold        frampold        fran            fran           \n  francais        francai         france          franc          \n  frances         franc           franchise       franchis       \n  franchised      franchis        franchisement   franchis       \n  franchises      franchis        franciae        francia        \n  francis         franci          francisca       francisca      \n  franciscan      franciscan      francisco       francisco      \n  frank           frank           franker         franker        \n  frankfort       frankfort       franklin        franklin       \n  franklins       franklin        frankly         frankli        \n  frankness       frank           frantic         frantic        \n  franticly       franticli       frateretto      frateretto     \n  fratrum         fratrum         fraud           fraud          \n  fraudful        fraud           fraught         fraught        \n  fraughtage      fraughtag       fraughting      fraught        \n  fray            frai            frays           frai           \n  freckl          freckl          freckled        freckl         \n  freckles        freckl          frederick       frederick      \n  free            free            freed           freed          \n  freedom         freedom         freedoms        freedom        \n  freehearted     freeheart       freelier        freelier       \n  freely          freeli          freeman         freeman        \n  freemen         freemen         freeness        freeness       \n  freer           freer           frees           free           \n  freestone       freeston        freetown        freetown       \n  freeze          freez           freezes         freez          \n  freezing        freez           freezings       freez          \n  french          french          frenchman       frenchman      \n  frenchmen       frenchmen       frenchwoman     frenchwoman    \n  frenzy          frenzi          frequent        frequent       \n  frequents       frequent        fresh           fresh          \n  fresher         fresher         freshes         fresh          \n  freshest        freshest        freshly         freshli        \n  freshness       fresh           fret            fret           \n  fretful         fret            frets           fret           \n  fretted         fret            fretten         fretten        \n  fretting        fret            friar           friar          \n  friars          friar           friday          fridai         \n  fridays         fridai          friend          friend         \n  friended        friend          friending       friend         \n  friendless      friendless      friendliness    friendli       \n  friendly        friendli        friends         friend         \n  friendship      friendship      friendships     friendship     \n  frieze          friez           fright          fright         \n  frighted        fright          frightened      frighten       \n  frightful       fright          frighting       fright         \n  frights         fright          fringe          fring          \n  fringed         fring           frippery        fripperi       \n  frisk           frisk           fritters        fritter        \n  frivolous       frivol          fro             fro            \n  frock           frock           frog            frog           \n  frogmore        frogmor         froissart       froissart      \n  frolic          frolic          from            from           \n  front           front           fronted         front          \n  frontier        frontier        frontiers       frontier       \n  fronting        front           frontlet        frontlet       \n  fronts          front           frost           frost          \n  frosts          frost           frosty          frosti         \n  froth           froth           froward         froward        \n  frown           frown           frowning        frown          \n  frowningly      frowningli      frowns          frown          \n  froze           froze           frozen          frozen         \n  fructify        fructifi        frugal          frugal         \n  fruit           fruit           fruiterer       fruiter        \n  fruitful        fruit           fruitfully      fruitfulli     \n  fruitfulness    fruit           fruition        fruition       \n  fruitless       fruitless       fruits          fruit          \n  frush           frush           frustrate       frustrat       \n  frutify         frutifi         fry             fry            \n  fubb            fubb            fuel            fuel           \n  fugitive        fugit           fulfil          fulfil         \n  fulfill         fulfil          fulfilling      fulfil         \n  fulfils         fulfil          full            full           \n  fullam          fullam          fuller          fuller         \n  fullers         fuller          fullest         fullest        \n  fullness        full            fully           fulli          \n  fulness         ful             fulsome         fulsom         \n  fulvia          fulvia          fum             fum            \n  fumble          fumbl           fumbles         fumbl          \n  fumblest        fumblest        fumbling        fumbl          \n  fume            fume            fumes           fume           \n  fuming          fume            fumiter         fumit          \n  fumitory        fumitori        fun             fun            \n  function        function        functions       function       \n  fundamental     fundament       funeral         funer          \n  funerals        funer           fur             fur            \n  furbish         furbish         furies          furi           \n  furious         furiou          furlongs        furlong        \n  furnace         furnac          furnaces        furnac         \n  furnish         furnish         furnished       furnish        \n  furnishings     furnish         furniture       furnitur       \n  furnival        furniv          furor           furor          \n  furr            furr            furrow          furrow         \n  furrowed        furrow          furrows         furrow         \n  furth           furth           further         further        \n  furtherance     further         furtherer       further        \n  furthermore     furthermor      furthest        furthest       \n  fury            furi            furze           furz           \n  furzes          furz            fust            fust           \n  fustian         fustian         fustilarian     fustilarian    \n  fusty           fusti           fut             fut            \n  future          futur           futurity        futur          \n  g               g               gabble          gabbl          \n  gaberdine       gaberdin        gabriel         gabriel        \n  gad             gad             gadding         gad            \n  gads            gad             gadshill        gadshil        \n  gag             gag             gage            gage           \n  gaged           gage            gagg            gagg           \n  gaging          gage            gagne           gagn           \n  gain            gain            gained          gain           \n  gainer          gainer          gaingiving      gaingiv        \n  gains           gain            gainsaid        gainsaid       \n  gainsay         gainsai         gainsaying      gainsai        \n  gainsays        gainsai         gainst          gainst         \n  gait            gait            gaited          gait           \n  galathe         galath          gale            gale           \n  galen           galen           gales           gale           \n  gall            gall            gallant         gallant        \n  gallantly       gallantli       gallantry       gallantri      \n  gallants        gallant         galled          gall           \n  gallery         galleri         galley          gallei         \n  galleys         gallei          gallia          gallia         \n  gallian         gallian         galliard        galliard       \n  galliasses      galliass        gallimaufry     gallimaufri    \n  galling         gall            gallons         gallon         \n  gallop          gallop          galloping       gallop         \n  gallops         gallop          gallow          gallow         \n  galloway        gallowai        gallowglasses   gallowglass    \n  gallows         gallow          gallowses       gallows        \n  galls           gall            gallus          gallu          \n  gam             gam             gambol          gambol         \n  gambold         gambold         gambols         gambol         \n  gamboys         gamboi          game            game           \n  gamers          gamer           games           game           \n  gamesome        gamesom         gamester        gamest         \n  gaming          game            gammon          gammon         \n  gamut           gamut           gan             gan            \n  gangren         gangren         ganymede        ganymed        \n  gaol            gaol            gaoler          gaoler         \n  gaolers         gaoler          gaols           gaol           \n  gap             gap             gape            gape           \n  gapes           gape            gaping          gape           \n  gar             gar             garb            garb           \n  garbage         garbag          garboils        garboil        \n  garcon          garcon          gard            gard           \n  garde           gard            garden          garden         \n  gardener        garden          gardeners       garden         \n  gardens         garden          gardez          gardez         \n  gardiner        gardin          gardon          gardon         \n  gargantua       gargantua       gargrave        gargrav        \n  garish          garish          garland         garland        \n  garlands        garland         garlic          garlic         \n  garment         garment         garments        garment        \n  garmet          garmet          garner          garner         \n  garners         garner          garnish         garnish        \n  garnished       garnish         garret          garret         \n  garrison        garrison        garrisons       garrison       \n  gart            gart            garter          garter         \n  garterd         garterd         gartering       garter         \n  garters         garter          gascony         gasconi        \n  gash            gash            gashes          gash           \n  gaskins         gaskin          gasp            gasp           \n  gasping         gasp            gasted          gast           \n  gastness        gast            gat             gat            \n  gate            gate            gated           gate           \n  gates           gate            gath            gath           \n  gather          gather          gathered        gather         \n  gathering       gather          gathers         gather         \n  gatories        gatori          gatory          gatori         \n  gaud            gaud            gaudeo          gaudeo         \n  gaudy           gaudi           gauge           gaug           \n  gaul            gaul            gaultree        gaultre        \n  gaunt           gaunt           gauntlet        gauntlet       \n  gauntlets       gauntlet        gav             gav            \n  gave            gave            gavest          gavest         \n  gawded          gawd            gawds           gawd           \n  gawsey          gawsei          gay             gai            \n  gayness         gay             gaz             gaz            \n  gaze            gaze            gazed           gaze           \n  gazer           gazer           gazers          gazer          \n  gazes           gaze            gazeth          gazeth         \n  gazing          gaze            gear            gear           \n  geck            geck            geese           gees           \n  geffrey         geffrei         geld            geld           \n  gelded          geld            gelding         geld           \n  gelida          gelida          gelidus         gelidu         \n  gelt            gelt            gem             gem            \n  geminy          gemini          gems            gem            \n  gen             gen             gender          gender         \n  genders         gender          general         gener          \n  generally       gener           generals        gener          \n  generation      gener           generations     gener          \n  generative      gener           generosity      generos        \n  generous        gener           genitive        genit          \n  genitivo        genitivo        genius          geniu          \n  gennets         gennet          genoa           genoa          \n  genoux          genoux          gens            gen            \n  gent            gent            gentilhomme     gentilhomm     \n  gentility       gentil          gentle          gentl          \n  gentlefolks     gentlefolk      gentleman       gentleman      \n  gentlemanlike   gentlemanlik    gentlemen       gentlemen      \n  gentleness      gentl           gentler         gentler        \n  gentles         gentl           gentlest        gentlest       \n  gentlewoman     gentlewoman     gentlewomen     gentlewomen    \n  gently          gentli          gentry          gentri         \n  george          georg           gerard          gerard         \n  germaines       germain         germains        germain        \n  german          german          germane         german         \n  germans         german          germany         germani        \n  gertrude        gertrud         gest            gest           \n  gests           gest            gesture         gestur         \n  gestures        gestur          get             get            \n  getrude         getrud          gets            get            \n  getter          getter          getting         get            \n  ghastly         ghastli         ghost           ghost          \n  ghosted         ghost           ghostly         ghostli        \n  ghosts          ghost           gi              gi             \n  giant           giant           giantess        giantess       \n  giantlike       giantlik        giants          giant          \n  gib             gib             gibber          gibber         \n  gibbet          gibbet          gibbets         gibbet         \n  gibe            gibe            giber           giber          \n  gibes           gibe            gibing          gibe           \n  gibingly        gibingli        giddily         giddili        \n  giddiness       giddi           giddy           giddi          \n  gift            gift            gifts           gift           \n  gig             gig             giglets         giglet         \n  giglot          giglot          gilbert         gilbert        \n  gild            gild            gilded          gild           \n  gilding         gild            gilliams        gilliam        \n  gillian         gillian         gills           gill           \n  gillyvors       gillyvor        gilt            gilt           \n  gimmal          gimmal          gimmers         gimmer         \n  gin             gin             ging            ging           \n  ginger          ginger          gingerbread     gingerbread    \n  gingerly        gingerli        ginn            ginn           \n  gins            gin             gioucestershire gioucestershir \n  gipes           gipe            gipsies         gipsi          \n  gipsy           gipsi           gird            gird           \n  girded          gird            girdle          girdl          \n  girdled         girdl           girdles         girdl          \n  girdling        girdl           girl            girl           \n  girls           girl            girt            girt           \n  girth           girth           gis             gi             \n  giv             giv             give            give           \n  given           given           giver           giver          \n  givers          giver           gives           give           \n  givest          givest          giveth          giveth         \n  giving          give            givings         give           \n  glad            glad            gladded         glad           \n  gladding        glad            gladly          gladli         \n  gladness        glad            glamis          glami          \n  glanc           glanc           glance          glanc          \n  glanced         glanc           glances         glanc          \n  glancing        glanc           glanders        glander        \n  glansdale       glansdal        glare           glare          \n  glares          glare           glass           glass          \n  glasses         glass           glassy          glassi         \n  glaz            glaz            glazed          glaze          \n  gleams          gleam           glean           glean          \n  gleaned         glean           gleaning        glean          \n  gleeful         gleeful         gleek           gleek          \n  gleeking        gleek           gleeks          gleek          \n  glend           glend           glendower       glendow        \n  glib            glib            glide           glide          \n  glided          glide           glides          glide          \n  glideth         glideth         gliding         glide          \n  glimmer         glimmer         glimmering      glimmer        \n  glimmers        glimmer         glimpse         glimps         \n  glimpses        glimps          glist           glist          \n  glistening      glisten         glister         glister        \n  glistering      glister         glisters        glister        \n  glitt           glitt           glittering      glitter        \n  globe           globe           globes          globe          \n  glooming        gloom           gloomy          gloomi         \n  glories         glori           glorified       glorifi        \n  glorify         glorifi         glorious        gloriou        \n  gloriously      glorious        glory           glori          \n  glose           glose           gloss           gloss          \n  glosses         gloss           glou            glou           \n  glouceste       gloucest        gloucester      gloucest       \n  gloucestershire gloucestershir  glove           glove          \n  glover          glover          gloves          glove          \n  glow            glow            glowed          glow           \n  glowing         glow            glowworm        glowworm       \n  gloz            gloz            gloze           gloze          \n  glozes          gloze           glu             glu            \n  glue            glue            glued           glu            \n  glues           glue            glut            glut           \n  glutt           glutt           glutted         glut           \n  glutton         glutton         gluttoning      glutton        \n  gluttony        gluttoni        gnarled         gnarl          \n  gnarling        gnarl           gnat            gnat           \n  gnats           gnat            gnaw            gnaw           \n  gnawing         gnaw            gnawn           gnawn          \n  gnaws           gnaw            go              go             \n  goad            goad            goaded          goad           \n  goads           goad            goal            goal           \n  goat            goat            goatish         goatish        \n  goats           goat            gobbets         gobbet         \n  gobbo           gobbo           goblet          goblet         \n  goblets         goblet          goblin          goblin         \n  goblins         goblin          god             god            \n  godded          god             godden          godden         \n  goddess         goddess         goddesses       goddess        \n  goddild         goddild         godfather       godfath        \n  godfathers      godfath         godhead         godhead        \n  godlike         godlik          godliness       godli          \n  godly           godli           godmother       godmoth        \n  gods            god             godson          godson         \n  goer            goer            goers           goer           \n  goes            goe             goest           goest          \n  goeth           goeth           goffe           goff           \n  gogs            gog             going           go             \n  gold            gold            golden          golden         \n  goldenly        goldenli        goldsmith       goldsmith      \n  goldsmiths      goldsmith       golgotha        golgotha       \n  goliases        golias          goliath         goliath        \n  gon             gon             gondola         gondola        \n  gondolier       gondoli         gone            gone           \n  goneril         goneril         gong            gong           \n  gonzago         gonzago         gonzalo         gonzalo        \n  good            good            goodfellow      goodfellow     \n  goodlier        goodlier        goodliest       goodliest      \n  goodly          goodli          goodman         goodman        \n  goodness        good            goodnight       goodnight      \n  goodrig         goodrig         goods           good           \n  goodwife        goodwif         goodwill        goodwil        \n  goodwin         goodwin         goodwins        goodwin        \n  goodyear        goodyear        goodyears       goodyear       \n  goose           goos            gooseberry      gooseberri     \n  goosequills     goosequil       goot            goot           \n  gor             gor             gorbellied      gorbelli       \n  gorboduc        gorboduc        gordian         gordian        \n  gore            gore            gored           gore           \n  gorg            gorg            gorge           gorg           \n  gorgeous        gorgeou         gorget          gorget         \n  gorging         gorg            gorgon          gorgon         \n  gormandize      gormand         gormandizing    gormand        \n  gory            gori            gosling         gosl           \n  gospel          gospel          gospels         gospel         \n  goss            goss            gossamer        gossam         \n  gossip          gossip          gossiping       gossip         \n  gossiplike      gossiplik       gossips         gossip         \n  got             got             goth            goth           \n  goths           goth            gotten          gotten         \n  gourd           gourd           gout            gout           \n  gouts           gout            gouty           gouti          \n  govern          govern          governance      govern         \n  governed        govern          governess       gover          \n  government      govern          governor        governor       \n  governors       governor        governs         govern         \n  gower           gower           gown            gown           \n  gowns           gown            grac            grac           \n  grace           grace           graced          grace          \n  graceful        grace           gracefully      gracefulli     \n  graceless       graceless       graces          grace          \n  gracing         grace           gracious        graciou        \n  graciously      gracious        gradation       gradat         \n  graff           graff           graffing        graf           \n  graft           graft           grafted         graft          \n  grafters        grafter         grain           grain          \n  grained         grain           grains          grain          \n  gramercies      gramerci        gramercy        gramerci       \n  grammar         grammar         grand           grand          \n  grandam         grandam         grandame        grandam        \n  grandchild      grandchild      grande          grand          \n  grandeur        grandeur        grandfather     grandfath      \n  grandjurors     grandjuror      grandmother     grandmoth      \n  grandpre        grandpr         grandsir        grandsir       \n  grandsire       grandsir        grandsires      grandsir       \n  grange          grang           grant           grant          \n  granted         grant           granting        grant          \n  grants          grant           grape           grape          \n  grapes          grape           grapple         grappl         \n  grapples        grappl          grappling       grappl         \n  grasp           grasp           grasped         grasp          \n  grasps          grasp           grass           grass          \n  grasshoppers    grasshopp       grassy          grassi         \n  grate           grate           grated          grate          \n  grateful        grate           grates          grate          \n  gratiano        gratiano        gratify         gratifi        \n  gratii          gratii          gratillity      gratil         \n  grating         grate           gratis          grati          \n  gratitude       gratitud        gratulate       gratul         \n  grav            grav            grave           grave          \n  gravediggers    gravedigg       gravel          gravel         \n  graveless       graveless       gravell         gravel         \n  gravely         grave           graven          graven         \n  graveness       grave           graver          graver         \n  graves          grave           gravest         gravest        \n  gravestone      graveston       gravities       graviti        \n  gravity         graviti         gravy           gravi          \n  gray            grai            graymalkin      graymalkin     \n  graz            graz            graze           graze          \n  grazed          graze           grazing         graze          \n  grease          greas           greases         greas          \n  greasily        greasili        greasy          greasi         \n  great           great           greater         greater        \n  greatest        greatest        greatly         greatli        \n  greatness       great           grecian         grecian        \n  grecians        grecian         gree            gree           \n  greece          greec           greed           greed          \n  greedily        greedili        greediness      greedi         \n  greedy          greedi          greeing         gree           \n  greek           greek           greekish        greekish       \n  greeks          greek           green           green          \n  greener         greener         greenly         greenli        \n  greens          green           greensleeves    greensleev     \n  greenwich       greenwich       greenwood       greenwood      \n  greet           greet           greeted         greet          \n  greeting        greet           greetings       greet          \n  greets          greet           greg            greg           \n  gregory         gregori         gremio          gremio         \n  grew            grew            grey            grei           \n  greybeard       greybeard       greybeards      greybeard      \n  greyhound       greyhound       greyhounds      greyhound      \n  grief           grief           griefs          grief          \n  griev           griev           grievance       grievanc       \n  grievances      grievanc        grieve          griev          \n  grieved         griev           grieves         griev          \n  grievest        grievest        grieving        griev          \n  grievingly      grievingli      grievous        grievou        \n  grievously      grievous        griffin         griffin        \n  griffith        griffith        grim            grim           \n  grime           grime           grimly          grimli         \n  grin            grin            grind           grind          \n  grinding        grind           grindstone      grindston      \n  grinning        grin            grip            grip           \n  gripe           gripe           gripes          gripe          \n  griping         gripe           grise           grise          \n  grisly          grisli          grissel         grissel        \n  grize           grize           grizzle         grizzl         \n  grizzled        grizzl          groan           groan          \n  groaning        groan           groans          groan          \n  groat           groat           groats          groat          \n  groin           groin           groom           groom          \n  grooms          groom           grop            grop           \n  groping         grope           gros            gro            \n  gross           gross           grosser         grosser        \n  grossly         grossli         grossness       gross          \n  ground          ground          grounded        ground         \n  groundlings     groundl         grounds         ground         \n  grove           grove           grovel          grovel         \n  grovelling      grovel          groves          grove          \n  grow            grow            groweth         groweth        \n  growing         grow            grown           grown          \n  grows           grow            growth          growth         \n  grub            grub            grubb           grubb          \n  grubs           grub            grudge          grudg          \n  grudged         grudg           grudges         grudg          \n  grudging        grudg           gruel           gruel          \n  grumble         grumbl          grumblest       grumblest      \n  grumbling       grumbl          grumblings      grumbl         \n  grumio          grumio          grund           grund          \n  grunt           grunt           gualtier        gualtier       \n  guard           guard           guardage        guardag        \n  guardant        guardant        guarded         guard          \n  guardian        guardian        guardians       guardian       \n  guards          guard           guardsman       guardsman      \n  gud             gud             gudgeon         gudgeon        \n  guerdon         guerdon         guerra          guerra         \n  guess           guess           guesses         guess          \n  guessingly      guessingli      guest           guest          \n  guests          guest           guiana          guiana         \n  guichard        guichard        guide           guid           \n  guided          guid            guider          guider         \n  guiderius       guideriu        guides          guid           \n  guiding         guid            guidon          guidon         \n  guienne         guienn          guil            guil           \n  guildenstern    guildenstern    guilders        guilder        \n  guildford       guildford       guildhall       guildhal       \n  guile           guil            guiled          guil           \n  guileful        guil            guilfords       guilford       \n  guilt           guilt           guiltian        guiltian       \n  guiltier        guiltier        guiltily        guiltili       \n  guiltiness      guilti          guiltless       guiltless      \n  guilts          guilt           guilty          guilti         \n  guinea          guinea          guinever        guinev         \n  guise           guis            gul             gul            \n  gules           gule            gulf            gulf           \n  gulfs           gulf            gull            gull           \n  gulls           gull            gum             gum            \n  gumm            gumm            gums            gum            \n  gun             gun             gunner          gunner         \n  gunpowder       gunpowd         guns            gun            \n  gurnet          gurnet          gurney          gurnei         \n  gust            gust            gusts           gust           \n  gusty           gusti           guts            gut            \n  gutter          gutter          guy             gui            \n  guynes          guyn            guysors         guysor         \n  gypsy           gypsi           gyve            gyve           \n  gyved           gyve            gyves           gyve           \n  h               h               ha              ha             \n  haberdasher     haberdash       habiliment      habili         \n  habiliments     habili          habit           habit          \n  habitation      habit           habited         habit          \n  habits          habit           habitude        habitud        \n  hack            hack            hacket          hacket         \n  hackney         hacknei         hacks           hack           \n  had             had             hadst           hadst          \n  haec            haec            haeres          haer           \n  hag             hag             hagar           hagar          \n  haggard         haggard         haggards        haggard        \n  haggish         haggish         haggled         haggl          \n  hags            hag             hail            hail           \n  hailed          hail            hailstone       hailston       \n  hailstones      hailston        hair            hair           \n  hairless        hairless        hairs           hair           \n  hairy           hairi           hal             hal            \n  halberd         halberd         halberds        halberd        \n  halcyon         halcyon         hale            hale           \n  haled           hale            hales           hale           \n  half            half            halfcan         halfcan        \n  halfpence       halfpenc        halfpenny       halfpenni      \n  halfpennyworth  halfpennyworth  halfway         halfwai        \n  halidom         halidom         hall            hall           \n  halloa          halloa          halloing        hallo          \n  hallond         hallond         halloo          halloo         \n  hallooing       halloo          hallow          hallow         \n  hallowed        hallow          hallowmas       hallowma       \n  hallown         hallown         hals            hal            \n  halt            halt            halter          halter         \n  halters         halter          halting         halt           \n  halts           halt            halves          halv           \n  ham             ham             hames           hame           \n  hamlet          hamlet          hammer          hammer         \n  hammered        hammer          hammering       hammer         \n  hammers         hammer          hamper          hamper         \n  hampton         hampton         hams            ham            \n  hamstring       hamstr          hand            hand           \n  handed          hand            handful         hand           \n  handicraft      handicraft      handicraftsmen  handicraftsmen \n  handing         hand            handiwork       handiwork      \n  handkercher     handkerch       handkerchers    handkerch      \n  handkerchief    handkerchief    handle          handl          \n  handled         handl           handles         handl          \n  handless        handless        handlest        handlest       \n  handling        handl           handmaid        handmaid       \n  handmaids       handmaid        hands           hand           \n  handsaw         handsaw         handsome        handsom        \n  handsomely      handsom         handsomeness    handsom        \n  handwriting     handwrit        handy           handi          \n  hang            hang            hanged          hang           \n  hangers         hanger          hangeth         hangeth        \n  hanging         hang            hangings        hang           \n  hangman         hangman         hangmen         hangmen        \n  hangs           hang            hannibal        hannib         \n  hap             hap             hapless         hapless        \n  haply           hapli           happ            happ           \n  happen          happen          happened        happen         \n  happier         happier         happies         happi          \n  happiest        happiest        happily         happili        \n  happiness       happi           happy           happi          \n  haps            hap             harbinger       harbing        \n  harbingers      harbing         harbor          harbor         \n  harbour         harbour         harbourage      harbourag      \n  harbouring      harbour         harbours        harbour        \n  harcourt        harcourt        hard            hard           \n  harder          harder          hardest         hardest        \n  hardiest        hardiest        hardiment       hardiment      \n  hardiness       hardi           hardly          hardli         \n  hardness        hard            hardocks        hardock        \n  hardy           hardi           hare            hare           \n  harelip         harelip         hares           hare           \n  harfleur        harfleur        hark            hark           \n  harlot          harlot          harlotry        harlotri       \n  harlots         harlot          harm            harm           \n  harmed          harm            harmful         harm           \n  harming         harm            harmless        harmless       \n  harmonious      harmoni         harmony         harmoni        \n  harms           harm            harness         har            \n  harp            harp            harper          harper         \n  harpier         harpier         harping         harp           \n  harpy           harpi           harried         harri          \n  harrow          harrow          harrows         harrow         \n  harry           harri           harsh           harsh          \n  harshly         harshli         harshness       harsh          \n  hart            hart            harts           hart           \n  harum           harum           harvest         harvest        \n  has             ha              hast            hast           \n  haste           hast            hasted          hast           \n  hasten          hasten          hastes          hast           \n  hastily         hastili         hasting         hast           \n  hastings        hast            hasty           hasti          \n  hat             hat             hatch           hatch          \n  hatches         hatch           hatchet         hatchet        \n  hatching        hatch           hatchment       hatchment      \n  hate            hate            hated           hate           \n  hateful         hate            hater           hater          \n  haters          hater           hates           hate           \n  hateth          hateth          hatfield        hatfield       \n  hath            hath            hating          hate           \n  hatred          hatr            hats            hat            \n  haud            haud            hauf            hauf           \n  haught          haught          haughtiness     haughti        \n  haughty         haughti         haunch          haunch         \n  haunches        haunch          haunt           haunt          \n  haunted         haunt           haunting        haunt          \n  haunts          haunt           hautboy         hautboi        \n  hautboys        hautboi         have            have           \n  haven           haven           havens          haven          \n  haver           haver           having          have           \n  havings         have            havior          havior         \n  haviour         haviour         havoc           havoc          \n  hawk            hawk            hawking         hawk           \n  hawks           hawk            hawthorn        hawthorn       \n  hawthorns       hawthorn        hay             hai            \n  hazard          hazard          hazarded        hazard         \n  hazards         hazard          hazel           hazel          \n  hazelnut        hazelnut        he              he             \n  head            head            headborough     headborough    \n  headed          head            headier         headier        \n  heading         head            headland        headland       \n  headless        headless        headlong        headlong       \n  heads           head            headsman        headsman       \n  headstrong      headstrong      heady           headi          \n  heal            heal            healed          heal           \n  healing         heal            heals           heal           \n  health          health          healthful       health         \n  healths         health          healthsome      healthsom      \n  healthy         healthi         heap            heap           \n  heaping         heap            heaps           heap           \n  hear            hear            heard           heard          \n  hearer          hearer          hearers         hearer         \n  hearest         hearest         heareth         heareth        \n  hearing         hear            hearings        hear           \n  heark           heark           hearken         hearken        \n  hearkens        hearken         hears           hear           \n  hearsay         hearsai         hearse          hears          \n  hearsed         hears           hearst          hearst         \n  heart           heart           heartache       heartach       \n  heartbreak      heartbreak      heartbreaking   heartbreak     \n  hearted         heart           hearten         hearten        \n  hearth          hearth          hearths         hearth         \n  heartily        heartili        heartiness      hearti         \n  heartless       heartless       heartlings      heartl         \n  heartly         heartli         hearts          heart          \n  heartsick       heartsick       heartstrings    heartstr       \n  hearty          hearti          heat            heat           \n  heated          heat            heath           heath          \n  heathen         heathen         heathenish      heathenish     \n  heating         heat            heats           heat           \n  heauties        heauti          heav            heav           \n  heave           heav            heaved          heav           \n  heaven          heaven          heavenly        heavenli       \n  heavens         heaven          heaves          heav           \n  heavier         heavier         heaviest        heaviest       \n  heavily         heavili         heaviness       heavi          \n  heaving         heav            heavings        heav           \n  heavy           heavi           hebona          hebona         \n  hebrew          hebrew          hecate          hecat          \n  hectic          hectic          hector          hector         \n  hectors         hector          hecuba          hecuba         \n  hedg            hedg            hedge           hedg           \n  hedgehog        hedgehog        hedgehogs       hedgehog       \n  hedges          hedg            heed            heed           \n  heeded          heed            heedful         heed           \n  heedfull        heedful         heedfully       heedfulli      \n  heedless        heedless        heel            heel           \n  heels           heel            hefted          heft           \n  hefts           heft            heifer          heifer         \n  heifers         heifer          heigh           heigh          \n  height          height          heighten        heighten       \n  heinous         heinou          heinously       heinous        \n  heir            heir            heiress         heiress        \n  heirless        heirless        heirs           heir           \n  held            held            helen           helen          \n  helena          helena          helenus         helenu         \n  helias          helia           helicons        helicon        \n  hell            hell            hellespont      hellespont     \n  hellfire        hellfir         hellish         hellish        \n  helm            helm            helmed          helm           \n  helmet          helmet          helmets         helmet         \n  helms           helm            help            help           \n  helper          helper          helpers         helper         \n  helpful         help            helping         help           \n  helpless        helpless        helps           help           \n  helter          helter          hem             hem            \n  heme            heme            hemlock         hemlock        \n  hemm            hemm            hemp            hemp           \n  hempen          hempen          hems            hem            \n  hen             hen             hence           henc           \n  henceforth      henceforth      henceforward    henceforward   \n  henchman        henchman        henri           henri          \n  henricus        henricu         henry           henri          \n  hens            hen             hent            hent           \n  henton          henton          her             her            \n  herald          herald          heraldry        heraldri       \n  heralds         herald          herb            herb           \n  herbert         herbert         herblets        herblet        \n  herbs           herb            herculean       herculean      \n  hercules        hercul          herd            herd           \n  herds           herd            herdsman        herdsman       \n  herdsmen        herdsmen        here            here           \n  hereabout       hereabout       hereabouts      hereabout      \n  hereafter       hereaft         hereby          herebi         \n  hereditary      hereditari      hereford        hereford       \n  herefordshire   herefordshir    herein          herein         \n  hereof          hereof          heresies        heresi         \n  heresy          heresi          heretic         heret          \n  heretics        heret           hereto          hereto         \n  hereupon        hereupon        heritage        heritag        \n  heritier        heriti          hermes          herm           \n  hermia          hermia          hermione        hermion        \n  hermit          hermit          hermitage       hermitag       \n  hermits         hermit          herne           hern           \n  hero            hero            herod           herod          \n  herods          herod           heroes          hero           \n  heroic          heroic          heroical        heroic         \n  herring         her             herrings        her            \n  hers            her             herself         herself        \n  hesperides      hesperid        hesperus        hesperu        \n  hest            hest            hests           hest           \n  heure           heur            heureux         heureux        \n  hew             hew             hewgh           hewgh          \n  hewing          hew             hewn            hewn           \n  hews            hew             hey             hei            \n  heyday          heydai          hibocrates      hibocr         \n  hic             hic             hiccups         hiccup         \n  hick            hick            hid             hid            \n  hidden          hidden          hide            hide           \n  hideous         hideou          hideously       hideous        \n  hideousness     hideous         hides           hide           \n  hidest          hidest          hiding          hide           \n  hie             hie             hied            hi             \n  hiems           hiem            hies            hi             \n  hig             hig             high            high           \n  higher          higher          highest         highest        \n  highly          highli          highmost        highmost       \n  highness        high            hight           hight          \n  highway         highwai         highways        highwai        \n  hilding         hild            hildings        hild           \n  hill            hill            hillo           hillo          \n  hilloa          hilloa          hills           hill           \n  hilt            hilt            hilts           hilt           \n  hily            hili            him             him            \n  himself         himself         hinc            hinc           \n  hinckley        hincklei        hind            hind           \n  hinder          hinder          hindered        hinder         \n  hinders         hinder          hindmost        hindmost       \n  hinds           hind            hing            hing           \n  hinge           hing            hinges          hing           \n  hint            hint            hip             hip            \n  hipp            hipp            hipparchus      hipparchu      \n  hippolyta       hippolyta       hips            hip            \n  hir             hir             hire            hire           \n  hired           hire            hiren           hiren          \n  hirtius         hirtiu          his             hi             \n  hisperia        hisperia        hiss            hiss           \n  hisses          hiss            hissing         hiss           \n  hist            hist            historical      histor         \n  history         histori         hit             hit            \n  hither          hither          hitherto        hitherto       \n  hitherward      hitherward      hitherwards     hitherward     \n  hits            hit             hitting         hit            \n  hive            hive            hives           hive           \n  hizzing         hizz            ho              ho             \n  hoa             hoa             hoar            hoar           \n  hoard           hoard           hoarded         hoard          \n  hoarding        hoard           hoars           hoar           \n  hoarse          hoars           hoary           hoari          \n  hob             hob             hobbididence    hobbidid       \n  hobby           hobbi           hobbyhorse      hobbyhors      \n  hobgoblin       hobgoblin       hobnails        hobnail        \n  hoc             hoc             hod             hod            \n  hodge           hodg            hog             hog            \n  hogs            hog             hogshead        hogshead       \n  hogsheads       hogshead        hois            hoi            \n  hoise           hois            hoist           hoist          \n  hoisted         hoist           hoists          hoist          \n  holborn         holborn         hold            hold           \n  holden          holden          holder          holder         \n  holdeth         holdeth         holdfast        holdfast       \n  holding         hold            holds           hold           \n  hole            hole            holes           hole           \n  holidam         holidam         holidame        holidam        \n  holiday         holidai         holidays        holidai        \n  holier          holier          holiest         holiest        \n  holily          holili          holiness        holi           \n  holla           holla           holland         holland        \n  hollander       holland         hollanders      holland        \n  holloa          holloa          holloaing       holloa         \n  hollow          hollow          hollowly        hollowli       \n  hollowness      hollow          holly           holli          \n  holmedon        holmedon        holofernes      holofern       \n  holp            holp            holy            holi           \n  homage          homag           homager         homag          \n  home            home            homely          home           \n  homes           home            homespuns       homespun       \n  homeward        homeward        homewards       homeward       \n  homicide        homicid         homicides       homicid        \n  homily          homili          hominem         hominem        \n  hommes          homm            homo            homo           \n  honest          honest          honester        honest         \n  honestest       honestest       honestly        honestli       \n  honesty         honesti         honey           honei          \n  honeycomb       honeycomb       honeying        honei          \n  honeyless       honeyless       honeysuckle     honeysuckl     \n  honeysuckles    honeysuckl      honi            honi           \n  honneur         honneur         honor           honor          \n  honorable       honor           honorably       honor          \n  honorato        honorato        honorificabilitudinitatibus honorificabilitudinitatibu\n  honors          honor           honour          honour         \n  honourable      honour          honourably      honour         \n  honoured        honour          honourest       honourest      \n  honourible      honour          honouring       honour         \n  honours         honour          hoo             hoo            \n  hood            hood            hooded          hood           \n  hoodman         hoodman         hoods           hood           \n  hoodwink        hoodwink        hoof            hoof           \n  hoofs           hoof            hook            hook           \n  hooking         hook            hooks           hook           \n  hoop            hoop            hoops           hoop           \n  hoot            hoot            hooted          hoot           \n  hooting         hoot            hoots           hoot           \n  hop             hop             hope            hope           \n  hopeful         hope            hopeless        hopeless       \n  hopes           hope            hopest          hopest         \n  hoping          hope            hopkins         hopkin         \n  hoppedance      hopped          hor             hor            \n  horace          horac           horatio         horatio        \n  horizon         horizon         horn            horn           \n  hornbook        hornbook        horned          horn           \n  horner          horner          horning         horn           \n  hornpipes       hornpip         horns           horn           \n  horologe        horolog         horrible        horribl        \n  horribly        horribl         horrid          horrid         \n  horrider        horrid          horridly        horridli       \n  horror          horror          horrors         horror         \n  hors            hor             horse           hors           \n  horseback       horseback       horsed          hors           \n  horsehairs      horsehair       horseman        horseman       \n  horsemanship    horsemanship    horsemen        horsemen       \n  horses          hors            horseway        horsewai       \n  horsing         hors            hortensio       hortensio      \n  hortensius      hortensiu       horum           horum          \n  hose            hose            hospitable      hospit         \n  hospital        hospit          hospitality     hospit         \n  host            host            hostage         hostag         \n  hostages        hostag          hostess         hostess        \n  hostile         hostil          hostility       hostil         \n  hostilius       hostiliu        hosts           host           \n  hot             hot             hotly           hotli          \n  hotspur         hotspur         hotter          hotter         \n  hottest         hottest         hound           hound          \n  hounds          hound           hour            hour           \n  hourly          hourli          hours           hour           \n  hous            hou             house           hous           \n  household       household       householder     household      \n  householders    household       households      household      \n  housekeeper     housekeep       housekeepers    housekeep      \n  housekeeping    housekeep       houseless       houseless      \n  houses          hous            housewife       housewif       \n  housewifery     housewiferi     housewives      housew         \n  hovel           hovel           hover           hover          \n  hovered         hover           hovering        hover          \n  hovers          hover           how             how            \n  howbeit         howbeit         howe            how            \n  howeer          howeer          however         howev          \n  howl            howl            howled          howl           \n  howlet          howlet          howling         howl           \n  howls           howl            howsoe          howso          \n  howsoever       howsoev         howsome         howsom         \n  hoxes           hox             hoy             hoi            \n  hoyday          hoydai          hubert          hubert         \n  huddled         huddl           huddling        huddl          \n  hue             hue             hued            hu             \n  hues            hue             hug             hug            \n  huge            huge            hugely          huge           \n  hugeness        huge            hugg            hugg           \n  hugger          hugger          hugh            hugh           \n  hugs            hug             hujus           huju           \n  hulk            hulk            hulks           hulk           \n  hull            hull            hulling         hull           \n  hullo           hullo           hum             hum            \n  human           human           humane          human          \n  humanely        human           humanity        human          \n  humble          humbl           humbled         humbl          \n  humbleness      humbl           humbler         humbler        \n  humbles         humbl           humblest        humblest       \n  humbling        humbl           humbly          humbl          \n  hume            hume            humh            humh           \n  humidity        humid           humility        humil          \n  humming         hum             humor           humor          \n  humorous        humor           humors          humor          \n  humour          humour          humourists      humourist      \n  humours         humour          humphrey        humphrei       \n  humphry         humphri         hums            hum            \n  hundred         hundr           hundreds        hundr          \n  hundredth       hundredth       hung            hung           \n  hungarian       hungarian       hungary         hungari        \n  hunger          hunger          hungerford      hungerford     \n  hungerly        hungerli        hungry          hungri         \n  hunt            hunt            hunted          hunt           \n  hunter          hunter          hunters         hunter         \n  hunteth         hunteth         hunting         hunt           \n  huntington      huntington      huntress        huntress       \n  hunts           hunt            huntsman        huntsman       \n  huntsmen        huntsmen        hurdle          hurdl          \n  hurl            hurl            hurling         hurl           \n  hurls           hurl            hurly           hurli          \n  hurlyburly      hurlyburli      hurricano       hurricano      \n  hurricanoes     hurricano       hurried         hurri          \n  hurries         hurri           hurry           hurri          \n  hurt            hurt            hurting         hurt           \n  hurtled         hurtl           hurtless        hurtless       \n  hurtling        hurtl           hurts           hurt           \n  husband         husband         husbanded       husband        \n  husbandless     husbandless     husbandry       husbandri      \n  husbands        husband         hush            hush           \n  hushes          hush            husht           husht          \n  husks           husk            huswife         huswif         \n  huswifes        huswif          hutch           hutch          \n  hybla           hybla           hydra           hydra          \n  hyen            hyen            hymen           hymen          \n  hymenaeus       hymenaeu        hymn            hymn           \n  hymns           hymn            hyperboles      hyperbol       \n  hyperbolical    hyperbol        hyperion        hyperion       \n  hypocrisy       hypocrisi       hypocrite       hypocrit       \n  hypocrites      hypocrit        hyrcan          hyrcan         \n  hyrcania        hyrcania        hyrcanian       hyrcanian      \n  hyssop          hyssop          hysterica       hysterica      \n  i               i               iachimo         iachimo        \n  iaculis         iaculi          iago            iago           \n  iament          iament          ibat            ibat           \n  icarus          icaru           ice             ic             \n  iceland         iceland         ici             ici            \n  icicle          icicl           icicles         icicl          \n  icy             ici             idea            idea           \n  ideas           idea            idem            idem           \n  iden            iden            ides            id             \n  idiot           idiot           idiots          idiot          \n  idle            idl             idleness        idl            \n  idles           idl             idly            idli           \n  idol            idol            idolatrous      idolatr        \n  idolatry        idolatri        ield            ield           \n  if              if              ifs             if             \n  ignis           igni            ignoble         ignobl         \n  ignobly         ignobl          ignominious     ignomini       \n  ignominy        ignomini        ignomy          ignomi         \n  ignorance       ignor           ignorant        ignor          \n  ii              ii              iii             iii            \n  iiii            iiii            il              il             \n  ilbow           ilbow           ild             ild            \n  ilion           ilion           ilium           ilium          \n  ill             ill             illegitimate    illegitim      \n  illiterate      illiter         illness         ill            \n  illo            illo            ills            ill            \n  illume          illum           illumin         illumin        \n  illuminate      illumin         illumineth      illumineth     \n  illusion        illus           illusions       illus          \n  illustrate      illustr         illustrated     illustr        \n  illustrious     illustri        illyria         illyria        \n  illyrian        illyrian        ils             il             \n  im              im              image           imag           \n  imagery         imageri         images          imag           \n  imagin          imagin          imaginary       imaginari      \n  imagination     imagin          imaginations    imagin         \n  imagine         imagin          imagining       imagin         \n  imaginings      imagin          imbar           imbar          \n  imbecility      imbecil         imbrue          imbru          \n  imitari         imitari         imitate         imit           \n  imitated        imit            imitation       imit           \n  imitations      imit            immaculate      immacul        \n  immanity        imman           immask          immask         \n  immaterial      immateri        immediacy       immediaci      \n  immediate       immedi          immediately     immedi         \n  imminence       immin           imminent        immin          \n  immoderate      immoder         immoderately    immoder        \n  immodest        immodest        immoment        immoment       \n  immortal        immort          immortaliz      immortaliz     \n  immortally      immort          immur           immur          \n  immured         immur           immures         immur          \n  imogen          imogen          imp             imp            \n  impaint         impaint         impair          impair         \n  impairing       impair          impale          impal          \n  impaled         impal           impanelled      impanel        \n  impart          impart          imparted        impart         \n  impartial       imparti         impartment      impart         \n  imparts         impart          impasted        impast         \n  impatience      impati          impatient       impati         \n  impatiently     impati          impawn          impawn         \n  impeach         impeach         impeached       impeach        \n  impeachment     impeach         impeachments    impeach        \n  impedes         imped           impediment      impedi         \n  impediments     impedi          impenetrable    impenetr       \n  imperator       imper           imperceiverant  imperceiver    \n  imperfect       imperfect       imperfection    imperfect      \n  imperfections   imperfect       imperfectly     imperfectli    \n  imperial        imperi          imperious       imperi         \n  imperiously     imperi          impertinency    impertin       \n  impertinent     impertin        impeticos       impetico       \n  impetuosity     impetuos        impetuous       impetu         \n  impieties       impieti         impiety         impieti        \n  impious         impiou          implacable      implac         \n  implements      implement       implies         impli          \n  implor          implor          implorators     implor         \n  implore         implor          implored        implor         \n  imploring       implor          impon           impon          \n  import          import          importance      import         \n  importancy      import          important       import         \n  importantly     importantli     imported        import         \n  importeth       importeth       importing       import         \n  importless      importless      imports         import         \n  importun        importun        importunacy     importunaci    \n  importunate     importun        importune       importun       \n  importunes      importun        importunity     importun       \n  impos           impo            impose          impos          \n  imposed         impos           imposition      imposit        \n  impositions     imposit         impossibilities imposs         \n  impossibility   imposs          impossible      imposs         \n  imposthume      imposthum       impostor        impostor       \n  impostors       impostor        impotence       impot          \n  impotent        impot           impounded       impound        \n  impregnable     impregn         imprese         impres         \n  impress         impress         impressed       impress        \n  impressest      impressest      impression      impress        \n  impressure      impressur       imprimendum     imprimendum    \n  imprimis        imprimi         imprint         imprint        \n  imprinted       imprint         imprison        imprison       \n  imprisoned      imprison        imprisoning     imprison       \n  imprisonment    imprison        improbable      improb         \n  improper        improp          improve         improv         \n  improvident     improvid        impudence       impud          \n  impudency       impud           impudent        impud          \n  impudently      impud           impudique       impudiqu       \n  impugn          impugn          impugns         impugn         \n  impure          impur           imputation      imput          \n  impute          imput           in              in             \n  inaccessible    inaccess        inaidable       inaid          \n  inaudible       inaud           inauspicious    inauspici      \n  incaged         incag           incantations    incant         \n  incapable       incap           incardinate     incardin       \n  incarnadine     incarnadin      incarnate       incarn         \n  incarnation     incarn          incens          incen          \n  incense         incens          incensed        incens         \n  incensement     incens          incenses        incens         \n  incensing       incens          incertain       incertain      \n  incertainties   incertainti     incertainty     incertainti    \n  incessant       incess          incessantly     incessantli    \n  incest          incest          incestuous      incestu        \n  inch            inch            incharitable    incharit       \n  inches          inch            incidency       incid          \n  incident        incid           incision        incis          \n  incite          incit           incites         incit          \n  incivil         incivil         incivility      incivil        \n  inclin          inclin          inclinable      inclin         \n  inclination     inclin          incline         inclin         \n  inclined        inclin          inclines        inclin         \n  inclining       inclin          inclips         inclip         \n  include         includ          included        includ         \n  includes        includ          inclusive       inclus         \n  incomparable    incompar        incomprehensible incomprehens   \n  inconsiderate   inconsider      inconstancy     inconst        \n  inconstant      inconst         incontinency    incontin       \n  incontinent     incontin        incontinently   incontin       \n  inconvenience   inconveni       inconveniences  inconveni      \n  inconvenient    inconveni       incony          inconi         \n  incorporate     incorpor        incorps         incorp         \n  incorrect       incorrect       increas         increa         \n  increase        increas         increases       increas        \n  increaseth      increaseth      increasing      increas        \n  incredible      incred          incredulous     incredul       \n  incur           incur           incurable       incur          \n  incurr          incurr          incurred        incur          \n  incursions      incurs          ind             ind            \n  inde            ind             indebted        indebt         \n  indeed          inde            indent          indent         \n  indented        indent          indenture       indentur       \n  indentures      indentur        index           index          \n  indexes         index           india           india          \n  indian          indian          indict          indict         \n  indicted        indict          indictment      indict         \n  indies          indi            indifferency    indiffer       \n  indifferent     indiffer        indifferently   indiffer       \n  indigent        indig           indigest        indigest       \n  indigested      indigest        indign          indign         \n  indignation     indign          indignations    indign         \n  indigne         indign          indignities     indign         \n  indignity       indign          indirect        indirect       \n  indirection     indirect        indirections    indirect       \n  indirectly      indirectli      indiscreet      indiscreet     \n  indiscretion    indiscret       indispos        indispo        \n  indisposition   indisposit      indissoluble    indissolubl    \n  indistinct      indistinct      indistinguish   indistinguish  \n  indistinguishable indistinguish   indited         indit          \n  individable     individ         indrench        indrench       \n  indu            indu            indubitate      indubit        \n  induc           induc           induce          induc          \n  induced         induc           inducement      induc          \n  induction       induct          inductions      induct         \n  indue           indu            indued          indu           \n  indues          indu            indulgence      indulg         \n  indulgences     indulg          indulgent       indulg         \n  indurance       indur           industrious     industri       \n  industriously   industri        industry        industri       \n  inequality      inequ           inestimable     inestim        \n  inevitable      inevit          inexecrable     inexecr        \n  inexorable      inexor          inexplicable    inexplic       \n  infallible      infal           infallibly      infal          \n  infamonize      infamon         infamous        infam          \n  infamy          infami          infancy         infanc         \n  infant          infant          infants         infant         \n  infect          infect          infected        infect         \n  infecting       infect          infection       infect         \n  infections      infect          infectious      infecti        \n  infectiously    infecti         infects         infect         \n  infer           infer           inference       infer          \n  inferior        inferior        inferiors       inferior       \n  infernal        infern          inferr          inferr         \n  inferreth       inferreth       inferring       infer          \n  infest          infest          infidel         infidel        \n  infidels        infidel         infinite        infinit        \n  infinitely      infinit         infinitive      infinit        \n  infirm          infirm          infirmities     infirm         \n  infirmity       infirm          infixed         infix          \n  infixing        infix           inflam          inflam         \n  inflame         inflam          inflaming       inflam         \n  inflammation    inflamm         inflict         inflict        \n  infliction      inflict         influence       influenc       \n  influences      influenc        infold          infold         \n  inform          inform          informal        inform         \n  information     inform          informations    inform         \n  informed        inform          informer        inform         \n  informs         inform          infortunate     infortun       \n  infring         infr            infringe        infring        \n  infringed       infring         infus           infu           \n  infuse          infus           infused         infus          \n  infusing        infus           infusion        infus          \n  ingener         ingen           ingenious       ingeni         \n  ingeniously     ingeni          inglorious      inglori        \n  ingots          ingot           ingraffed       ingraf         \n  ingraft         ingraft         ingrate         ingrat         \n  ingrated        ingrat          ingrateful      ingrat         \n  ingratitude     ingratitud      ingratitudes    ingratitud     \n  ingredient      ingredi         ingredients     ingredi        \n  ingross         ingross         inhabit         inhabit        \n  inhabitable     inhabit         inhabitants     inhabit        \n  inhabited       inhabit         inhabits        inhabit        \n  inhearse        inhears         inhearsed       inhears        \n  inherent        inher           inherit         inherit        \n  inheritance     inherit         inherited       inherit        \n  inheriting      inherit         inheritor       inheritor      \n  inheritors      inheritor       inheritrix      inheritrix     \n  inherits        inherit         inhibited       inhibit        \n  inhibition      inhibit         inhoop          inhoop         \n  inhuman         inhuman         iniquities      iniqu          \n  iniquity        iniqu           initiate        initi          \n  injointed       injoint         injunction      injunct        \n  injunctions     injunct         injur           injur          \n  injure          injur           injurer         injur          \n  injuries        injuri          injurious       injuri         \n  injury          injuri          injustice       injustic       \n  ink             ink             inkhorn         inkhorn        \n  inkle           inkl            inkles          inkl           \n  inkling         inkl            inky            inki           \n  inlaid          inlaid          inland          inland         \n  inlay           inlai           inly            inli           \n  inmost          inmost          inn             inn            \n  inner           inner           innkeeper       innkeep        \n  innocence       innoc           innocency       innoc          \n  innocent        innoc           innocents       innoc          \n  innovation      innov           innovator       innov          \n  inns            inn             innumerable     innumer        \n  inoculate       inocul          inordinate      inordin        \n  inprimis        inprimi         inquir          inquir         \n  inquire         inquir          inquiry         inquiri        \n  inquisition     inquisit        inquisitive     inquisit       \n  inroads         inroad          insane          insan          \n  insanie         insani          insatiate       insati         \n  insconce        insconc         inscrib         inscrib        \n  inscription     inscript        inscriptions    inscript       \n  inscroll        inscrol         inscrutable     inscrut        \n  insculp         insculp         insculpture     insculptur     \n  insensible      insens          inseparable     insepar        \n  inseparate      insepar         insert          insert         \n  inserted        insert          inset           inset          \n  inshell         inshel          inshipp         inshipp        \n  inside          insid           insinewed       insinew        \n  insinuate       insinu          insinuateth     insinuateth    \n  insinuating     insinu          insinuation     insinu         \n  insisted        insist          insisting       insist         \n  insisture       insistur        insociable      insoci         \n  insolence       insol           insolent        insol          \n  insomuch        insomuch        inspir          inspir         \n  inspiration     inspir          inspirations    inspir         \n  inspire         inspir          inspired        inspir         \n  install         instal          installed       instal         \n  instalment      instal          instance        instanc        \n  instances       instanc         instant         instant        \n  instantly       instantli       instate         instat         \n  instead         instead         insteeped       insteep        \n  instigate       instig          instigated      instig         \n  instigation     instig          instigations    instig         \n  instigator      instig          instinct        instinct       \n  instinctively   instinct        institute       institut       \n  institutions    institut        instruct        instruct       \n  instructed      instruct        instruction     instruct       \n  instructions    instruct        instructs       instruct       \n  instrument      instrument      instrumental    instrument     \n  instruments     instrument      insubstantial   insubstanti    \n  insufficience   insuffici       insufficiency   insuffici      \n  insult          insult          insulted        insult         \n  insulting       insult          insultment      insult         \n  insults         insult          insupportable   insupport      \n  insuppressive   insuppress      insurrection    insurrect      \n  insurrections   insurrect       int             int            \n  integer         integ           integritas      integrita      \n  integrity       integr          intellect       intellect      \n  intellects      intellect       intellectual    intellectu     \n  intelligence    intellig        intelligencer   intelligenc    \n  intelligencing  intelligenc     intelligent     intellig       \n  intelligis      intelligi       intelligo       intelligo      \n  intemperance    intemper        intemperate     intemper       \n  intend          intend          intended        intend         \n  intendeth       intendeth       intending       intend         \n  intendment      intend          intends         intend         \n  intenible       inten           intent          intent         \n  intention       intent          intentively     intent         \n  intents         intent          inter           inter          \n  intercept       intercept       intercepted     intercept      \n  intercepter     intercept       interception    intercept      \n  intercepts      intercept       intercession    intercess      \n  intercessors    intercessor     interchained    interchain     \n  interchang      interchang      interchange     interchang     \n  interchangeably interchang      interchangement interchang     \n  interchanging   interchang      interdiction    interdict      \n  interest        interest        interim         interim        \n  interims        interim         interior        interior       \n  interjections   interject       interjoin       interjoin      \n  interlude       interlud        intermingle     intermingl     \n  intermission    intermiss       intermissive    intermiss      \n  intermit        intermit        intermix        intermix       \n  intermixed      intermix        interpose       interpos       \n  interposer      interpos        interposes      interpos       \n  interpret       interpret       interpretation  interpret      \n  interpreted     interpret       interpreter     interpret      \n  interpreters    interpret       interprets      interpret      \n  interr          interr          interred        inter          \n  interrogatories interrogatori   interrupt       interrupt      \n  interrupted     interrupt       interrupter     interrupt      \n  interruptest    interruptest    interruption    interrupt      \n  interrupts      interrupt       intertissued    intertissu     \n  intervallums    intervallum     interview       interview      \n  intestate       intest          intestine       intestin       \n  intil           intil           intimate        intim          \n  intimation      intim           intitled        intitl         \n  intituled       intitul         into            into           \n  intolerable     intoler         intoxicates     intox          \n  intreasured     intreasur       intreat         intreat        \n  intrench        intrench        intrenchant     intrench       \n  intricate       intric          intrinse        intrins        \n  intrinsicate    intrins         intrude         intrud         \n  intruder        intrud          intruding       intrud         \n  intrusion       intrus          inundation      inund          \n  inure           inur            inurn           inurn          \n  invade          invad           invades         invad          \n  invasion        invas           invasive        invas          \n  invectively     invect          invectives      invect         \n  inveigled       inveigl         invent          invent         \n  invented        invent          invention       invent         \n  inventions      invent          inventor        inventor       \n  inventorially   inventori       inventoried     inventori      \n  inventors       inventor        inventory       inventori      \n  inverness       inver           invert          invert         \n  invest          invest          invested        invest         \n  investing       invest          investments     invest         \n  inveterate      inveter         invincible      invinc         \n  inviolable      inviol          invised         invis          \n  invisible       invis           invitation      invit          \n  invite          invit           invited         invit          \n  invites         invit           inviting        invit          \n  invitis         inviti          invocate        invoc          \n  invocation      invoc           invoke          invok          \n  invoked         invok           invulnerable    invulner       \n  inward          inward          inwardly        inwardli       \n  inwardness      inward          inwards         inward         \n  ionia           ionia           ionian          ionian         \n  ipse            ips             ipswich         ipswich        \n  ira             ira             irae            ira            \n  iras            ira             ire             ir             \n  ireful          ir              ireland         ireland        \n  iris            iri             irish           irish          \n  irishman        irishman        irishmen        irishmen       \n  irks            irk             irksome         irksom         \n  iron            iron            irons           iron           \n  irreconcil      irreconcil      irrecoverable   irrecover      \n  irregular       irregular       irregulous      irregul        \n  irreligious     irreligi        irremovable     irremov        \n  irreparable     irrepar         irresolute      irresolut      \n  irrevocable     irrevoc         is              is             \n  isabel          isabel          isabella        isabella       \n  isbel           isbel           isbels          isbel          \n  iscariot        iscariot        ise             is             \n  ish             ish             isidore         isidor         \n  isis            isi             island          island         \n  islander        island          islanders       island         \n  islands         island          isle            isl            \n  isles           isl             israel          israel         \n  issu            issu            issue           issu           \n  issued          issu            issueless       issueless      \n  issues          issu            issuing         issu           \n  ist             ist             ista            ista           \n  it              it              italian         italian        \n  italy           itali           itch            itch           \n  itches          itch            itching         itch           \n  item            item            items           item           \n  iteration       iter            ithaca          ithaca         \n  its             it              itself          itself         \n  itshall         itshal          iv              iv             \n  ivory           ivori           ivy             ivi            \n  iwis            iwi             ix              ix             \n  j               j               jacet           jacet          \n  jack            jack            jackanapes      jackanap       \n  jacks           jack            jacksauce       jacksauc       \n  jackslave       jackslav        jacob           jacob          \n  jade            jade            jaded           jade           \n  jades           jade            jail            jail           \n  jakes           jake            jamany          jamani         \n  james           jame            jamy            jami           \n  jane            jane            jangled         jangl          \n  jangling        jangl           january         januari        \n  janus           janu            japhet          japhet         \n  jaquenetta      jaquenetta      jaques          jaqu           \n  jar             jar             jarring         jar            \n  jars            jar             jarteer         jarteer        \n  jasons          jason           jaunce          jaunc          \n  jauncing        jaunc           jaundice        jaundic        \n  jaundies        jaundi          jaw             jaw            \n  jawbone         jawbon          jaws            jaw            \n  jay             jai             jays            jai            \n  jc              jc              je              je             \n  jealous         jealou          jealousies      jealousi       \n  jealousy        jealousi        jeer            jeer           \n  jeering         jeer            jelly           jelli          \n  jenny           jenni           jeopardy        jeopardi       \n  jephtha         jephtha         jephthah        jephthah       \n  jerkin          jerkin          jerkins         jerkin         \n  jerks           jerk            jeronimy        jeronimi       \n  jerusalem       jerusalem       jeshu           jeshu          \n  jesses          jess            jessica         jessica        \n  jest            jest            jested          jest           \n  jester          jester          jesters         jester         \n  jesting         jest            jests           jest           \n  jesu            jesu            jesus           jesu           \n  jet             jet             jets            jet            \n  jew             jew             jewel           jewel          \n  jeweller        jewel           jewels          jewel          \n  jewess          jewess          jewish          jewish         \n  jewry           jewri           jews            jew            \n  jezebel         jezebel         jig             jig            \n  jigging         jig             jill            jill           \n  jills           jill            jingling        jingl          \n  joan            joan            job             job            \n  jockey          jockei          jocund          jocund         \n  jog             jog             jogging         jog            \n  john            john            johns           john           \n  join            join            joinder         joinder        \n  joined          join            joiner          joiner         \n  joineth         joineth         joins           join           \n  joint           joint           jointed         joint          \n  jointing        joint           jointly         jointli        \n  jointress       jointress       joints          joint          \n  jointure        jointur         jollity         jolliti        \n  jolly           jolli           jolt            jolt           \n  joltheads       jolthead        jordan          jordan         \n  joseph          joseph          joshua          joshua         \n  jot             jot             jour            jour           \n  jourdain        jourdain        journal         journal        \n  journey         journei         journeying      journei        \n  journeyman      journeyman      journeymen      journeymen     \n  journeys        journei         jove            jove           \n  jovem           jovem           jovial          jovial         \n  jowl            jowl            jowls           jowl           \n  joy             joi             joyed           joi            \n  joyful          joy             joyfully        joyfulli       \n  joyless         joyless         joyous          joyou          \n  joys            joi             juan            juan           \n  jud             jud             judas           juda           \n  judases         judas           jude            jude           \n  judg            judg            judge           judg           \n  judged          judg            judgement       judgement      \n  judges          judg            judgest         judgest        \n  judging         judg            judgment        judgment       \n  judgments       judgment        judicious       judici         \n  jug             jug             juggle          juggl          \n  juggled         juggl           juggler         juggler        \n  jugglers        juggler         juggling        juggl          \n  jugs            jug             juice           juic           \n  juiced          juic            jul             jul            \n  jule            jule            julia           julia          \n  juliet          juliet          julietta        julietta       \n  julio           julio           julius          juliu          \n  july            juli            jump            jump           \n  jumpeth         jumpeth         jumping         jump           \n  jumps           jump            june            june           \n  junes           june            junior          junior         \n  junius          juniu           junkets         junket         \n  juno            juno            jupiter         jupit          \n  jure            jure            jurement        jurement       \n  jurisdiction    jurisdict       juror           juror          \n  jurors          juror           jury            juri           \n  jurymen         jurymen         just            just           \n  justeius        justeiu         justest         justest        \n  justice         justic          justicer        justic         \n  justicers       justic          justices        justic         \n  justification   justif          justified       justifi        \n  justify         justifi         justle          justl          \n  justled         justl           justles         justl          \n  justling        justl           justly          justli         \n  justness        just            justs           just           \n  jutting         jut             jutty           jutti          \n  juvenal         juven           kam             kam            \n  kate            kate            kated           kate           \n  kates           kate            katharine       katharin       \n  katherina       katherina       katherine       katherin       \n  kecksies        kecksi          keech           keech          \n  keel            keel            keels           keel           \n  keen            keen            keenness        keen           \n  keep            keep            keepdown        keepdown       \n  keeper          keeper          keepers         keeper         \n  keepest         keepest         keeping         keep           \n  keeps           keep            keiser          keiser         \n  ken             ken             kendal          kendal         \n  kennel          kennel          kent            kent           \n  kentish         kentish         kentishman      kentishman     \n  kentishmen      kentishmen      kept            kept           \n  kerchief        kerchief        kerely          kere           \n  kern            kern            kernal          kernal         \n  kernel          kernel          kernels         kernel         \n  kerns           kern            kersey          kersei         \n  kettle          kettl           kettledrum      kettledrum     \n  kettledrums     kettledrum      key             kei            \n  keys            kei             kibe            kibe           \n  kibes           kibe            kick            kick           \n  kicked          kick            kickshaws       kickshaw       \n  kickshawses     kickshaws       kicky           kicki          \n  kid             kid             kidney          kidnei         \n  kikely          kike            kildare         kildar         \n  kill            kill            killed          kill           \n  killer          killer          killeth         killeth        \n  killing         kill            killingworth    killingworth   \n  kills           kill            kiln            kiln           \n  kimbolton       kimbolton       kin             kin            \n  kind            kind            kinder          kinder         \n  kindest         kindest         kindle          kindl          \n  kindled         kindl           kindless        kindless       \n  kindlier        kindlier        kindling        kindl          \n  kindly          kindli          kindness        kind           \n  kindnesses      kind            kindred         kindr          \n  kindreds        kindr           kinds           kind           \n  kine            kine            king            king           \n  kingdom         kingdom         kingdoms        kingdom        \n  kingly          kingli          kings           king           \n  kinred          kinr            kins            kin            \n  kinsman         kinsman         kinsmen         kinsmen        \n  kinswoman       kinswoman       kirtle          kirtl          \n  kirtles         kirtl           kiss            kiss           \n  kissed          kiss            kisses          kiss           \n  kissing         kiss            kitchen         kitchen        \n  kitchens        kitchen         kite            kite           \n  kites           kite            kitten          kitten         \n  kj              kj              kl              kl             \n  klll            klll            knack           knack          \n  knacks          knack           knapp           knapp          \n  knav            knav            knave           knave          \n  knaveries       knaveri         knavery         knaveri        \n  knaves          knave           knavish         knavish        \n  knead           knead           kneaded         knead          \n  kneading        knead           knee            knee           \n  kneel           kneel           kneeling        kneel          \n  kneels          kneel           knees           knee           \n  knell           knell           knew            knew           \n  knewest         knewest         knife           knife          \n  knight          knight          knighted        knight         \n  knighthood      knighthood      knighthoods     knighthood     \n  knightly        knightli        knights         knight         \n  knit            knit            knits           knit           \n  knitters        knitter         knitteth        knitteth       \n  knives          knive           knobs           knob           \n  knock           knock           knocking        knock          \n  knocks          knock           knog            knog           \n  knoll           knoll           knot            knot           \n  knots           knot            knotted         knot           \n  knotty          knotti          know            know           \n  knower          knower          knowest         knowest        \n  knowing         know            knowingly       knowingli      \n  knowings        know            knowledge       knowledg       \n  known           known           knows           know           \n  l               l               la              la             \n  laban           laban           label           label          \n  labell          label           labienus        labienu        \n  labio           labio           labor           labor          \n  laboring        labor           labors          labor          \n  labour          labour          laboured        labour         \n  labourer        labour          labourers       labour         \n  labouring       labour          labours         labour         \n  laboursome      laboursom       labras          labra          \n  labyrinth       labyrinth       lac             lac            \n  lace            lace            laced           lace           \n  lacedaemon      lacedaemon      laces           lace           \n  lacies          laci            lack            lack           \n  lackbeard       lackbeard       lacked          lack           \n  lackey          lackei          lackeying       lackei         \n  lackeys         lackei          lacking         lack           \n  lacks           lack            lad             lad            \n  ladder          ladder          ladders         ladder         \n  lade            lade            laden           laden          \n  ladies          ladi            lading          lade           \n  lads            lad             lady            ladi           \n  ladybird        ladybird        ladyship        ladyship       \n  ladyships       ladyship        laer            laer           \n  laertes         laert           lafeu           lafeu          \n  lag             lag             lagging         lag            \n  laid            laid            lain            lain           \n  laissez         laissez         lake            lake           \n  lakes           lake            lakin           lakin          \n  lam             lam             lamb            lamb           \n  lambert         lambert         lambkin         lambkin        \n  lambkins        lambkin         lambs           lamb           \n  lame            lame            lamely          lame           \n  lameness        lame            lament          lament         \n  lamentable      lament          lamentably      lament         \n  lamentation     lament          lamentations    lament         \n  lamented        lament          lamenting       lament         \n  lamentings      lament          laments         lament         \n  lames           lame            laming          lame           \n  lammas          lamma           lammastide      lammastid      \n  lamound         lamound         lamp            lamp           \n  lampass         lampass         lamps           lamp           \n  lanc            lanc            lancaster       lancast        \n  lance           lanc            lances          lanc           \n  lanceth         lanceth         lanch           lanch          \n  land            land            landed          land           \n  landing         land            landless        landless       \n  landlord        landlord        landmen         landmen        \n  lands           land            lane            lane           \n  lanes           lane            langage         langag         \n  langley         langlei         langton         langton        \n  language        languag         languageless    languageless   \n  languages       languag         langues         langu          \n  languish        languish        languished      languish       \n  languishes      languish        languishing     languish       \n  languishings    languish        languishment    languish       \n  languor         languor         lank            lank           \n  lantern         lantern         lanterns        lantern        \n  lanthorn        lanthorn        lap             lap            \n  lapis           lapi            lapland         lapland        \n  lapp            lapp            laps            lap            \n  lapse           laps            lapsed          laps           \n  lapsing         laps            lapwing         lapw           \n  laquais         laquai          larded          lard           \n  larder          larder          larding         lard           \n  lards           lard            large           larg           \n  largely         larg            largeness       larg           \n  larger          larger          largess         largess        \n  largest         largest         lark            lark           \n  larks           lark            larron          larron         \n  lartius         lartiu          larum           larum          \n  larums          larum           las             la             \n  lascivious      lascivi         lash            lash           \n  lass            lass            lasses          lass           \n  last            last            lasted          last           \n  lasting         last            lastly          lastli         \n  lasts           last            latch           latch          \n  latches         latch           late            late           \n  lated           late            lately          late           \n  later           later           latest          latest         \n  lath            lath            latin           latin          \n  latten          latten          latter          latter         \n  lattice         lattic          laud            laud           \n  laudable        laudabl         laudis          laudi          \n  laugh           laugh           laughable       laughabl       \n  laughed         laugh           laugher         laugher        \n  laughest        laughest        laughing        laugh          \n  laughs          laugh           laughter        laughter       \n  launce          launc           launcelot       launcelot      \n  launces         launc           launch          launch         \n  laund           laund           laundress       laundress      \n  laundry         laundri         laur            laur           \n  laura           laura           laurel          laurel         \n  laurels         laurel          laurence        laurenc        \n  laus            lau             lavache         lavach         \n  lave            lave            lavee           lave           \n  lavender        lavend          lavina          lavina         \n  lavinia         lavinia         lavish          lavish         \n  lavishly        lavishli        lavolt          lavolt         \n  lavoltas        lavolta         law             law            \n  lawful          law             lawfully        lawfulli       \n  lawless         lawless         lawlessly       lawlessli      \n  lawn            lawn            lawns           lawn           \n  lawrence        lawrenc         laws            law            \n  lawyer          lawyer          lawyers         lawyer         \n  lay             lai             layer           layer          \n  layest          layest          laying          lai            \n  lays            lai             lazar           lazar          \n  lazars          lazar           lazarus         lazaru         \n  lazy            lazi            lc              lc             \n  ld              ld              ldst            ldst           \n  le              le              lead            lead           \n  leaden          leaden          leader          leader         \n  leaders         leader          leadest         leadest        \n  leading         lead            leads           lead           \n  leaf            leaf            leagu           leagu          \n  league          leagu           leagued         leagu          \n  leaguer         leaguer         leagues         leagu          \n  leah            leah            leak            leak           \n  leaky           leaki           lean            lean           \n  leander         leander         leaner          leaner         \n  leaning         lean            leanness        lean           \n  leans           lean            leap            leap           \n  leaped          leap            leaping         leap           \n  leaps           leap            leapt           leapt          \n  lear            lear            learn           learn          \n  learned         learn           learnedly       learnedli      \n  learning        learn           learnings       learn          \n  learns          learn           learnt          learnt         \n  leas            lea             lease           leas           \n  leases          leas            leash           leash          \n  leasing         leas            least           least          \n  leather         leather         leathern        leathern       \n  leav            leav            leave           leav           \n  leaven          leaven          leavening       leaven         \n  leaver          leaver          leaves          leav           \n  leaving         leav            leavy           leavi          \n  lecher          lecher          lecherous       lecher         \n  lechers         lecher          lechery         lecheri        \n  lecon           lecon           lecture         lectur         \n  lectures        lectur          led             led            \n  leda            leda            leech           leech          \n  leeches         leech           leek            leek           \n  leeks           leek            leer            leer           \n  leers           leer            lees            lee            \n  leese           lees            leet            leet           \n  leets           leet            left            left           \n  leg             leg             legacies        legaci         \n  legacy          legaci          legate          legat          \n  legatine        legatin         lege            lege           \n  legerity        leger           leges           lege           \n  legg            legg            legion          legion         \n  legions         legion          legitimate      legitim        \n  legitimation    legitim         legs            leg            \n  leicester       leicest         leicestershire  leicestershir  \n  leiger          leiger          leigers         leiger         \n  leisure         leisur          leisurely       leisur         \n  leisures        leisur          leman           leman          \n  lemon           lemon           lena            lena           \n  lend            lend            lender          lender         \n  lending         lend            lendings        lend           \n  lends           lend            length          length         \n  lengthen        lengthen        lengthens       lengthen       \n  lengths         length          lenity          leniti         \n  lennox          lennox          lent            lent           \n  lenten          lenten          lentus          lentu          \n  leo             leo             leon            leon           \n  leonardo        leonardo        leonati         leonati        \n  leonato         leonato         leonatus        leonatu        \n  leontes         leont           leopard         leopard        \n  leopards        leopard         leper           leper          \n  leperous        leper           lepidus         lepidu         \n  leprosy         leprosi         lequel          lequel         \n  lers            ler             les             le             \n  less            less            lessen          lessen         \n  lessens         lessen          lesser          lesser         \n  lesson          lesson          lessoned        lesson         \n  lessons         lesson          lest            lest           \n  lestrake        lestrak         let             let            \n  lethargied      lethargi        lethargies      lethargi       \n  lethargy        lethargi        lethe           leth           \n  lets            let             lett            lett           \n  letter          letter          letters         letter         \n  letting         let             lettuce         lettuc         \n  leur            leur            leve            leve           \n  level           level           levell          level          \n  levelled        level           levels          level          \n  leven           leven           levers          lever          \n  leviathan       leviathan       leviathans      leviathan      \n  levied          levi            levies          levi           \n  levity          leviti          levy            levi           \n  levying         levi            lewd            lewd           \n  lewdly          lewdli          lewdness        lewd           \n  lewdsters       lewdster        lewis           lewi           \n  liable          liabl           liar            liar           \n  liars           liar            libbard         libbard        \n  libelling       libel           libels          libel          \n  liberal         liber           liberality      liber          \n  liberte         libert          liberties       liberti        \n  libertine       libertin        libertines      libertin       \n  liberty         liberti         library         librari        \n  libya           libya           licence         licenc         \n  licens          licen           license         licens         \n  licentious      licenti         lichas          licha          \n  licio           licio           lick            lick           \n  licked          lick            licker          licker         \n  lictors         lictor          lid             lid            \n  lids            lid             lie             lie            \n  lied            li              lief            lief           \n  liefest         liefest         liege           lieg           \n  liegeman        liegeman        liegemen        liegemen       \n  lien            lien            lies            li             \n  liest           liest           lieth           lieth          \n  lieu            lieu            lieutenant      lieuten        \n  lieutenantry    lieutenantri    lieutenants     lieuten        \n  lieve           liev            life            life           \n  lifeblood       lifeblood       lifeless        lifeless       \n  lifelings       lifel           lift            lift           \n  lifted          lift            lifter          lifter         \n  lifteth         lifteth         lifting         lift           \n  lifts           lift            lig             lig            \n  ligarius        ligariu         liggens         liggen         \n  light           light           lighted         light          \n  lighten         lighten         lightens        lighten        \n  lighter         lighter         lightest        lightest       \n  lightly         lightli         lightness       light          \n  lightning       lightn          lightnings      lightn         \n  lights          light           lik             lik            \n  like            like            liked           like           \n  likeliest       likeliest       likelihood      likelihood     \n  likelihoods     likelihood      likely          like           \n  likeness        like            liker           liker          \n  likes           like            likest          likest         \n  likewise        likewis         liking          like           \n  likings         like            lilies          lili           \n  lily            lili            lim             lim            \n  limander        limand          limb            limb           \n  limbeck         limbeck         limbecks        limbeck        \n  limber          limber          limbo           limbo          \n  limbs           limb            lime            lime           \n  limed           lime            limehouse       limehous       \n  limekilns       limekiln        limit           limit          \n  limitation      limit           limited         limit          \n  limits          limit           limn            limn           \n  limp            limp            limping         limp           \n  limps           limp            lin             lin            \n  lincoln         lincoln         lincolnshire    lincolnshir    \n  line            line            lineal          lineal         \n  lineally        lineal          lineament       lineament      \n  lineaments      lineament       lined           line           \n  linen           linen           linens          linen          \n  lines           line            ling            ling           \n  lingare         lingar          linger          linger         \n  lingered        linger          lingers         linger         \n  linguist        linguist        lining          line           \n  link            link            links           link           \n  linsey          linsei          linstock        linstock       \n  linta           linta           lion            lion           \n  lionel          lionel          lioness         lioness        \n  lions           lion            lip             lip            \n  lipp            lipp            lips            lip            \n  lipsbury        lipsburi        liquid          liquid         \n  liquor          liquor          liquorish       liquorish      \n  liquors         liquor          lirra           lirra          \n  lisbon          lisbon          lisp            lisp           \n  lisping         lisp            list            list           \n  listen          listen          listening       listen         \n  lists           list            literatured     literatur      \n  lither          lither          litter          litter         \n  little          littl           littlest        littlest       \n  liv             liv             live            live           \n  lived           live            livelier        liveli         \n  livelihood      livelihood      livelong        livelong       \n  lively          live            liver           liver          \n  liveries        liveri          livers          liver          \n  livery          liveri          lives           live           \n  livest          livest          liveth          liveth         \n  livia           livia           living          live           \n  livings         live            lizard          lizard         \n  lizards         lizard          ll              ll             \n  lll             lll             llous           llou           \n  lnd             lnd             lo              lo             \n  loa             loa             loach           loach          \n  load            load            loaden          loaden         \n  loading         load            loads           load           \n  loaf            loaf            loam            loam           \n  loan            loan            loath           loath          \n  loathe          loath           loathed         loath          \n  loather         loather         loathes         loath          \n  loathing        loath           loathly         loathli        \n  loathness       loath           loathsome       loathsom       \n  loathsomeness   loathsom        loathsomest     loathsomest    \n  loaves          loav            lob             lob            \n  lobbies         lobbi           lobby           lobbi          \n  local           local           lochaber        lochab         \n  lock            lock            locked          lock           \n  locking         lock            lockram         lockram        \n  locks           lock            locusts         locust         \n  lode            lode            lodg            lodg           \n  lodge           lodg            lodged          lodg           \n  lodgers         lodger          lodges          lodg           \n  lodging         lodg            lodgings        lodg           \n  lodovico        lodovico        lodowick        lodowick       \n  lofty           lofti           log             log            \n  logger          logger          loggerhead      loggerhead     \n  loggerheads     loggerhead      loggets         logget         \n  logic           logic           logs            log            \n  loins           loin            loiter          loiter         \n  loiterer        loiter          loiterers       loiter         \n  loitering       loiter          lolling         loll           \n  lolls           loll            lombardy        lombardi       \n  london          london          londoners       london         \n  lone            lone            loneliness      loneli         \n  lonely          lone            long            long           \n  longaville      longavil        longboat        longboat       \n  longed          long            longer          longer         \n  longest         longest         longeth         longeth        \n  longing         long            longings        long           \n  longly          longli          longs           long           \n  longtail        longtail        loo             loo            \n  loof            loof            look            look           \n  looked          look            looker          looker         \n  lookers         looker          lookest         lookest        \n  looking         look            looks           look           \n  loon            loon            loop            loop           \n  loos            loo             loose           loos           \n  loosed          loos            loosely         loos           \n  loosen          loosen          loosing         loos           \n  lop             lop             lopp            lopp           \n  loquitur        loquitur        lord            lord           \n  lorded          lord            lording         lord           \n  lordings        lord            lordliness      lordli         \n  lordly          lordli          lords           lord           \n  lordship        lordship        lordships       lordship       \n  lorenzo         lorenzo         lorn            lorn           \n  lorraine        lorrain         lorship         lorship        \n  los             lo              lose            lose           \n  loser           loser           losers          loser          \n  loses           lose            losest          losest         \n  loseth          loseth          losing          lose           \n  loss            loss            losses          loss           \n  lost            lost            lot             lot            \n  lots            lot             lott            lott           \n  lottery         lotteri         loud            loud           \n  louder          louder          loudly          loudli         \n  lour            lour            loureth         loureth        \n  louring         lour            louse           lous           \n  louses          lous            lousy           lousi          \n  lout            lout            louted          lout           \n  louts           lout            louvre          louvr          \n  lov             lov             love            love           \n  loved           love            lovedst         lovedst        \n  lovel           lovel           lovelier        loveli         \n  loveliness      loveli          lovell          lovel          \n  lovely          love            lover           lover          \n  lovered         lover           lovers          lover          \n  loves           love            lovest          lovest         \n  loveth          loveth          loving          love           \n  lovingly        lovingli        low             low            \n  lowe            low             lower           lower          \n  lowest          lowest          lowing          low            \n  lowliness       lowli           lowly           lowli          \n  lown            lown            lowness         low            \n  loyal           loyal           loyally         loyal          \n  loyalties       loyalti         loyalty         loyalti        \n  lozel           lozel           lt              lt             \n  lubber          lubber          lubberly        lubberli       \n  luc             luc             luccicos        luccico        \n  luce            luce            lucentio        lucentio       \n  luces           luce            lucetta         lucetta        \n  luciana         luciana         lucianus        lucianu        \n  lucifer         lucif           lucifier        lucifi         \n  lucilius        luciliu         lucina          lucina         \n  lucio           lucio           lucius          luciu          \n  luck            luck            luckier         luckier        \n  luckiest        luckiest        luckily         luckili        \n  luckless        luckless        lucky           lucki          \n  lucre           lucr            lucrece         lucrec         \n  lucretia        lucretia        lucullius       luculliu       \n  lucullus        lucullu         lucy            luci           \n  lud             lud             ludlow          ludlow         \n  lug             lug             lugg            lugg           \n  luggage         luggag          luke            luke           \n  lukewarm        lukewarm        lull            lull           \n  lulla           lulla           lullaby         lullabi        \n  lulls           lull            lumbert         lumbert        \n  lump            lump            lumpish         lumpish        \n  luna            luna            lunacies        lunaci         \n  lunacy          lunaci          lunatic         lunat          \n  lunatics        lunat           lunes           lune           \n  lungs           lung            lupercal        luperc         \n  lurch           lurch           lure            lure           \n  lurk            lurk            lurketh         lurketh        \n  lurking         lurk            lurks           lurk           \n  luscious        lusciou         lush            lush           \n  lust            lust            lusted          lust           \n  luster          luster          lustful         lust           \n  lustier         lustier         lustiest        lustiest       \n  lustig          lustig          lustihood       lustihood      \n  lustily         lustili         lustre          lustr          \n  lustrous        lustrou         lusts           lust           \n  lusty           lusti           lute            lute           \n  lutes           lute            lutestring      lutestr        \n  lutheran        lutheran        luxurious       luxuri         \n  luxuriously     luxuri          luxury          luxuri         \n  ly              ly              lycaonia        lycaonia       \n  lycurguses      lycurgus        lydia           lydia          \n  lye             lye             lyen            lyen           \n  lying           ly              lym             lym            \n  lymoges         lymog           lynn            lynn           \n  lysander        lysand          m               m              \n  ma              ma              maan            maan           \n  mab             mab             macbeth         macbeth        \n  maccabaeus      maccabaeu       macdonwald      macdonwald     \n  macduff         macduff         mace            mace           \n  macedon         macedon         maces           mace           \n  machiavel       machiavel       machination     machin         \n  machinations    machin          machine         machin         \n  mack            mack            macmorris       macmorri       \n  maculate        macul           maculation      macul          \n  mad             mad             madam           madam          \n  madame          madam           madams          madam          \n  madcap          madcap          madded          mad            \n  madding         mad             made            made           \n  madeira         madeira         madly           madli          \n  madman          madman          madmen          madmen         \n  madness         mad             madonna         madonna        \n  madrigals       madrig          mads            mad            \n  maecenas        maecena         maggot          maggot         \n  maggots         maggot          magic           magic          \n  magical         magic           magician        magician       \n  magistrate      magistr         magistrates     magistr        \n  magnanimity     magnanim        magnanimous     magnanim       \n  magni           magni           magnifi         magnifi        \n  magnificence    magnific        magnificent     magnific       \n  magnifico       magnifico       magnificoes     magnifico      \n  magnus          magnu           mahomet         mahomet        \n  mahu            mahu            maid            maid           \n  maiden          maiden          maidenhead      maidenhead     \n  maidenheads     maidenhead      maidenhood      maidenhood     \n  maidenhoods     maidenhood      maidenliest     maidenliest    \n  maidenly        maidenli        maidens         maiden         \n  maidhood        maidhood        maids           maid           \n  mail            mail            mailed          mail           \n  mails           mail            maim            maim           \n  maimed          maim            maims           maim           \n  main            main            maincourse      maincours      \n  maine           main            mainly          mainli         \n  mainmast        mainmast        mains           main           \n  maintain        maintain        maintained      maintain       \n  maintains       maintain        maintenance     mainten        \n  mais            mai             maison          maison         \n  majestas        majesta         majestee        majeste        \n  majestic        majest          majestical      majest         \n  majestically    majest          majesties       majesti        \n  majesty         majesti         major           major          \n  majority        major           mak             mak            \n  make            make            makeless        makeless       \n  maker           maker           makers          maker          \n  makes           make            makest          makest         \n  maketh          maketh          making          make           \n  makings         make            mal             mal            \n  mala            mala            maladies        maladi         \n  malady          maladi          malapert        malapert       \n  malcolm         malcolm         malcontent      malcont        \n  malcontents     malcont         male            male           \n  maledictions    maledict        malefactions    malefact       \n  malefactor      malefactor      malefactors     malefactor     \n  males           male            malevolence     malevol        \n  malevolent      malevol         malhecho        malhecho       \n  malice          malic           malicious       malici         \n  maliciously     malici          malign          malign         \n  malignancy      malign          malignant       malign         \n  malignantly     malignantli     malkin          malkin         \n  mall            mall            mallard         mallard        \n  mallet          mallet          mallows         mallow         \n  malmsey         malmsei         malt            malt           \n  maltworms       maltworm        malvolio        malvolio       \n  mamillius       mamilliu        mammering       mammer         \n  mammet          mammet          mammets         mammet         \n  mammock         mammock         man             man            \n  manacle         manacl          manacles        manacl         \n  manage          manag           managed         manag          \n  manager         manag           managing        manag          \n  manakin         manakin         manchus         manchu         \n  mandate         mandat          mandragora      mandragora     \n  mandrake        mandrak         mandrakes       mandrak        \n  mane            mane            manent          manent         \n  manes           mane            manet           manet          \n  manfully        manfulli        mangle          mangl          \n  mangled         mangl           mangles         mangl          \n  mangling        mangl           mangy           mangi          \n  manhood         manhood         manhoods        manhood        \n  manifest        manifest        manifested      manifest       \n  manifests       manifest        manifold        manifold       \n  manifoldly      manifoldli      manka           manka          \n  mankind         mankind         manlike         manlik         \n  manly           manli           mann            mann           \n  manna           manna           manner          manner         \n  mannerly        mannerli        manners         manner         \n  manningtree     manningtre      mannish         mannish        \n  manor           manor           manors          manor          \n  mans            man             mansion         mansion        \n  mansionry       mansionri       mansions        mansion        \n  manslaughter    manslaught      mantle          mantl          \n  mantled         mantl           mantles         mantl          \n  mantua          mantua          mantuan         mantuan        \n  manual          manual          manure          manur          \n  manured         manur           manus           manu           \n  many            mani            map             map            \n  mapp            mapp            maps            map            \n  mar             mar             marble          marbl          \n  marbled         marbl           marcade         marcad         \n  marcellus       marcellu        march           march          \n  marches         march           marcheth        marcheth       \n  marching        march           marchioness     marchio        \n  marchpane       marchpan        marcians        marcian        \n  marcius         marciu          marcus          marcu          \n  mardian         mardian         mare            mare           \n  mares           mare            marg            marg           \n  margarelon      margarelon      margaret        margaret       \n  marge           marg            margent         margent        \n  margery         margeri         maria           maria          \n  marian          marian          mariana         mariana        \n  maries          mari            marigold        marigold       \n  mariner         marin           mariners        marin          \n  maritime        maritim         marjoram        marjoram       \n  mark            mark            marked          mark           \n  market          market          marketable      market         \n  marketplace     marketplac      markets         market         \n  marking         mark            markman         markman        \n  marks           mark            marl            marl           \n  marle           marl            marmoset        marmoset       \n  marquess        marquess        marquis         marqui         \n  marr            marr            marriage        marriag        \n  marriages       marriag         married         marri          \n  marries         marri           marring         mar            \n  marrow          marrow          marrowless      marrowless     \n  marrows         marrow          marry           marri          \n  marrying        marri           mars            mar            \n  marseilles      marseil         marsh           marsh          \n  marshal         marshal         marshalsea      marshalsea     \n  marshalship     marshalship     mart            mart           \n  marted          mart            martem          martem         \n  martext         martext         martial         martial        \n  martin          martin          martino         martino        \n  martius         martiu          martlemas       martlema       \n  martlet         martlet         marts           mart           \n  martyr          martyr          martyrs         martyr         \n  marullus        marullu         marv            marv           \n  marvel          marvel          marvell         marvel         \n  marvellous      marvel          marvellously    marvel         \n  marvels         marvel          mary            mari           \n  mas             ma              masculine       masculin       \n  masham          masham          mask            mask           \n  masked          mask            masker          masker         \n  maskers         masker          masking         mask           \n  masks           mask            mason           mason          \n  masonry         masonri         masons          mason          \n  masque          masqu           masquers        masquer        \n  masques         masqu           masquing        masqu          \n  mass            mass            massacre        massacr        \n  massacres       massacr         masses          mass           \n  massy           massi           mast            mast           \n  mastcr          mastcr          master          master         \n  masterdom       masterdom       masterest       masterest      \n  masterless      masterless      masterly        masterli       \n  masterpiece     masterpiec      masters         master         \n  mastership      mastership      mastic          mastic         \n  mastiff         mastiff         mastiffs        mastiff        \n  masts           mast            match           match          \n  matches         match           matcheth        matcheth       \n  matching        match           matchless       matchless      \n  mate            mate            mated           mate           \n  mater           mater           material        materi         \n  mates           mate            mathematics     mathemat       \n  matin           matin           matron          matron         \n  matrons         matron          matter          matter         \n  matters         matter          matthew         matthew        \n  mattock         mattock         mattress        mattress       \n  mature          matur           maturity        matur          \n  maud            maud            maudlin         maudlin        \n  maugre          maugr           maul            maul           \n  maund           maund           mauri           mauri          \n  mauritania      mauritania      mauvais         mauvai         \n  maw             maw             maws            maw            \n  maxim           maxim           may             mai            \n  mayday          maydai          mayest          mayest         \n  mayor           mayor           maypole         maypol         \n  mayst           mayst           maz             maz            \n  maze            maze            mazed           maze           \n  mazes           maze            mazzard         mazzard        \n  me              me              meacock         meacock        \n  mead            mead            meadow          meadow         \n  meadows         meadow          meads           mead           \n  meagre          meagr           meal            meal           \n  meals           meal            mealy           meali          \n  mean            mean            meanders        meander        \n  meaner          meaner          meanest         meanest        \n  meaneth         meaneth         meaning         mean           \n  meanings        mean            meanly          meanli         \n  means           mean            meant           meant          \n  meantime        meantim         meanwhile       meanwhil       \n  measles         measl           measur          measur         \n  measurable      measur          measure         measur         \n  measured        measur          measureless     measureless    \n  measures        measur          measuring       measur         \n  meat            meat            meats           meat           \n  mechanic        mechan          mechanical      mechan         \n  mechanicals     mechan          mechanics       mechan         \n  mechante        mechant         med             med            \n  medal           medal           meddle          meddl          \n  meddler         meddler         meddling        meddl          \n  mede            mede            medea           medea          \n  media           media           mediation       mediat         \n  mediators       mediat          medice          medic          \n  medicinal       medicin         medicine        medicin        \n  medicines       medicin         meditate        medit          \n  meditates       medit           meditating      medit          \n  meditation      medit           meditations     medit          \n  mediterranean   mediterranean   mediterraneum   mediterraneum  \n  medlar          medlar          medlars         medlar         \n  meed            meed            meeds           meed           \n  meek            meek            meekly          meekli         \n  meekness        meek            meet            meet           \n  meeter          meeter          meetest         meetest        \n  meeting         meet            meetings        meet           \n  meetly          meetli          meetness        meet           \n  meets           meet            meg             meg            \n  mehercle        mehercl         meilleur        meilleur       \n  meiny           meini           meisen          meisen         \n  melancholies    melancholi      melancholy      melancholi     \n  melford         melford         mell            mell           \n  mellifluous     melliflu        mellow          mellow         \n  mellowing       mellow          melodious       melodi         \n  melody          melodi          melt            melt           \n  melted          melt            melteth         melteth        \n  melting         melt            melts           melt           \n  melun           melun           member          member         \n  members         member          memento         memento        \n  memorable       memor           memorandums     memorandum     \n  memorial        memori          memorials       memori         \n  memories        memori          memoriz         memoriz        \n  memorize        memor           memory          memori         \n  memphis         memphi          men             men            \n  menac           menac           menace          menac          \n  menaces         menac           menaphon        menaphon       \n  menas           mena            mend            mend           \n  mended          mend            mender          mender         \n  mending         mend            mends           mend           \n  menecrates      menecr          menelaus        menelau        \n  menenius        meneniu         mental          mental         \n  menteith        menteith        mention         mention        \n  mentis          menti           menton          menton         \n  mephostophilus  mephostophilu   mer             mer            \n  mercatante      mercatant       mercatio        mercatio       \n  mercenaries     mercenari       mercenary       mercenari      \n  mercer          mercer          merchandise     merchandis     \n  merchandized    merchand        merchant        merchant       \n  merchants       merchant        mercies         merci          \n  merciful        merci           mercifully      mercifulli     \n  merciless       merciless       mercurial       mercuri        \n  mercuries       mercuri         mercury         mercuri        \n  mercutio        mercutio        mercy           merci          \n  mere            mere            mered           mere           \n  merely          mere            merest          merest         \n  meridian        meridian        merit           merit          \n  merited         merit           meritorious     meritori       \n  merits          merit           merlin          merlin         \n  mermaid         mermaid         mermaids        mermaid        \n  merops          merop           merrier         merrier        \n  merriest        merriest        merrily         merrili        \n  merriman        merriman        merriment       merriment      \n  merriments      merriment       merriness       merri          \n  merry           merri           mervailous      mervail        \n  mes             me              mesh            mesh           \n  meshes          mesh            mesopotamia     mesopotamia    \n  mess            mess            message         messag         \n  messages        messag          messala         messala        \n  messaline       messalin        messenger       messeng        \n  messengers      messeng         messes          mess           \n  messina         messina         met             met            \n  metal           metal           metals          metal          \n  metamorphis     metamorphi      metamorphoses   metamorphos    \n  metaphor        metaphor        metaphysical    metaphys       \n  metaphysics     metaphys        mete            mete           \n  metellus        metellu         meteor          meteor         \n  meteors         meteor          meteyard        meteyard       \n  metheglin       metheglin       metheglins      metheglin      \n  methink         methink         methinks        methink        \n  method          method          methods         method         \n  methought       methought       methoughts      methought      \n  metre           metr            metres          metr           \n  metropolis      metropoli       mette           mett           \n  mettle          mettl           mettled         mettl          \n  meus            meu             mew             mew            \n  mewed           mew             mewling         mewl           \n  mexico          mexico          mi              mi             \n  mice            mice            michael         michael        \n  michaelmas      michaelma       micher          micher         \n  miching         mich            mickle          mickl          \n  microcosm       microcosm       mid             mid            \n  midas           mida            middest         middest        \n  middle          middl           middleham       middleham      \n  midnight        midnight        midriff         midriff        \n  midst           midst           midsummer       midsumm        \n  midway          midwai          midwife         midwif         \n  midwives        midwiv          mienne          mienn          \n  might           might           mightful        might          \n  mightier        mightier        mightiest       mightiest      \n  mightily        mightili        mightiness      mighti         \n  mightst         mightst         mighty          mighti         \n  milan           milan           milch           milch          \n  mild            mild            milder          milder         \n  mildest         mildest         mildew          mildew         \n  mildews         mildew          mildly          mildli         \n  mildness        mild            mile            mile           \n  miles           mile            milford         milford        \n  militarist      militarist      military        militari       \n  milk            milk            milking         milk           \n  milkmaid        milkmaid        milks           milk           \n  milksops        milksop         milky           milki          \n  mill            mill            mille           mill           \n  miller          miller          milliner        millin         \n  million         million         millioned       million        \n  millions        million         mills           mill           \n  millstones      millston        milo            milo           \n  mimic           mimic           minc            minc           \n  mince           minc            minces          minc           \n  mincing         minc            mind            mind           \n  minded          mind            minding         mind           \n  mindless        mindless        minds           mind           \n  mine            mine            mineral         miner          \n  minerals        miner           minerva         minerva        \n  mines           mine            mingle          mingl          \n  mingled         mingl           mingling        mingl          \n  minikin         minikin         minim           minim          \n  minime          minim           minimo          minimo         \n  minimus         minimu          mining          mine           \n  minion          minion          minions         minion         \n  minist          minist          minister        minist         \n  ministers       minist          ministration    ministr        \n  minnow          minnow          minnows         minnow         \n  minola          minola          minority        minor          \n  minos           mino            minotaurs       minotaur       \n  minstrel        minstrel        minstrels       minstrel       \n  minstrelsy      minstrelsi      mint            mint           \n  mints           mint            minute          minut          \n  minutely        minut           minutes         minut          \n  minx            minx            mio             mio            \n  mir             mir             mirable         mirabl         \n  miracle         miracl          miracles        miracl         \n  miraculous      miracul         miranda         miranda        \n  mire            mire            mirror          mirror         \n  mirrors         mirror          mirth           mirth          \n  mirthful        mirth           miry            miri           \n  mis             mi              misadventur     misadventur    \n  misadventure    misadventur     misanthropos    misanthropo    \n  misapplied      misappli        misbecame       misbecam       \n  misbecom        misbecom        misbecome       misbecom       \n  misbegot        misbegot        misbegotten     misbegotten    \n  misbeliever     misbeliev       misbelieving    misbeliev      \n  misbhav         misbhav         miscall         miscal         \n  miscalled       miscal          miscarried      miscarri       \n  miscarries      miscarri        miscarry        miscarri       \n  miscarrying     miscarri        mischance       mischanc       \n  mischances      mischanc        mischief        mischief       \n  mischiefs       mischief        mischievous     mischiev       \n  misconceived    misconceiv      misconst        misconst       \n  misconster      misconst        misconstruction misconstruct   \n  misconstrued    misconstru      misconstrues    misconstru     \n  miscreant       miscreant       miscreate       miscreat       \n  misdeed         misde           misdeeds        misde          \n  misdemean       misdemean       misdemeanours   misdemeanour   \n  misdoubt        misdoubt        misdoubteth     misdoubteth    \n  misdoubts       misdoubt        misenum         misenum        \n  miser           miser           miserable       miser          \n  miserably       miser           misericorde     misericord     \n  miseries        miseri          misers          miser          \n  misery          miseri          misfortune      misfortun      \n  misfortunes     misfortun       misgive         misgiv         \n  misgives        misgiv          misgiving       misgiv         \n  misgoverned     misgovern       misgovernment   misgovern      \n  misgraffed      misgraf         misguide        misguid        \n  mishap          mishap          mishaps         mishap         \n  misheard        misheard        misinterpret    misinterpret   \n  mislead         mislead         misleader       mislead        \n  misleaders      mislead         misleading      mislead        \n  misled          misl            mislike         mislik         \n  misord          misord          misplac         misplac        \n  misplaced       misplac         misplaces       misplac        \n  mispris         mispri          misprised       mispris        \n  misprision      mispris         misprizing      mispriz        \n  misproud        misproud        misquote        misquot        \n  misreport       misreport       miss            miss           \n  missed          miss            misses          miss           \n  misshap         misshap         misshapen       misshapen      \n  missheathed     missheath       missing         miss           \n  missingly       missingli       missions        mission        \n  missive         missiv          missives        missiv         \n  misspoke        misspok         mist            mist           \n  mista           mista           mistak          mistak         \n  mistake         mistak          mistaken        mistaken       \n  mistakes        mistak          mistaketh       mistaketh      \n  mistaking       mistak          mistakings      mistak         \n  mistemp         mistemp         mistempered     mistemp        \n  misterm         misterm         mistful         mist           \n  misthink        misthink        misthought      misthought     \n  mistletoe       mistleto        mistook         mistook        \n  mistreadings    mistread        mistress        mistress       \n  mistresses      mistress        mistresss       mistresss      \n  mistriship      mistriship      mistrust        mistrust       \n  mistrusted      mistrust        mistrustful     mistrust       \n  mistrusting     mistrust        mists           mist           \n  misty           misti           misus           misu           \n  misuse          misus           misused         misus          \n  misuses         misus           mites           mite           \n  mithridates     mithrid         mitigate        mitig          \n  mitigation      mitig           mix             mix            \n  mixed           mix             mixture         mixtur         \n  mixtures        mixtur          mm              mm             \n  mnd             mnd             moan            moan           \n  moans           moan            moat            moat           \n  moated          moat            mobled          mobl           \n  mock            mock            mockable        mockabl        \n  mocker          mocker          mockeries       mockeri        \n  mockers         mocker          mockery         mockeri        \n  mocking         mock            mocks           mock           \n  mockvater       mockvat         mockwater       mockwat        \n  model           model           modena          modena         \n  moderate        moder           moderately      moder          \n  moderation      moder           modern          modern         \n  modest          modest          modesties       modesti        \n  modestly        modestli        modesty         modesti        \n  modicums        modicum         modo            modo           \n  module          modul           moe             moe            \n  moi             moi             moiety          moieti         \n  moist           moist           moisten         moisten        \n  moisture        moistur         moldwarp        moldwarp       \n  mole            mole            molehill        molehil        \n  moles           mole            molest          molest         \n  molestation     molest          mollification   mollif         \n  mollis          molli           molten          molten         \n  molto           molto           mome            mome           \n  moment          moment          momentary       momentari      \n  moming          mome            mon             mon            \n  monachum        monachum        monarch         monarch        \n  monarchies      monarchi        monarchize      monarch        \n  monarcho        monarcho        monarchs        monarch        \n  monarchy        monarchi        monast          monast         \n  monastery       monasteri       monastic        monast         \n  monday          mondai          monde           mond           \n  money           monei           moneys          monei          \n  mong            mong            monger          monger         \n  mongers         monger          monging         mong           \n  mongrel         mongrel         mongrels        mongrel        \n  mongst          mongst          monk            monk           \n  monkey          monkei          monkeys         monkei         \n  monks           monk            monmouth        monmouth       \n  monopoly        monopoli        mons            mon            \n  monsieur        monsieur        monsieurs       monsieur       \n  monster         monster         monsters        monster        \n  monstrous       monstrou        monstrously     monstrous      \n  monstrousness   monstrous       monstruosity    monstruos      \n  montacute       montacut        montage         montag         \n  montague        montagu         montagues       montagu        \n  montano         montano         montant         montant        \n  montez          montez          montferrat      montferrat     \n  montgomery      montgomeri      month           month          \n  monthly         monthli         months          month          \n  montjoy         montjoi         monument        monument       \n  monumental      monument        monuments       monument       \n  mood            mood            moods           mood           \n  moody           moodi           moon            moon           \n  moonbeams       moonbeam        moonish         moonish        \n  moonlight       moonlight       moons           moon           \n  moonshine       moonshin        moonshines      moonshin       \n  moor            moor            moorfields      moorfield      \n  moors           moor            moorship        moorship       \n  mop             mop             mope            mope           \n  moping          mope            mopping         mop            \n  mopsa           mopsa           moral           moral          \n  moraler         moral           morality        moral          \n  moralize        moral           mordake         mordak         \n  more            more            moreover        moreov         \n  mores           more            morgan          morgan         \n  mori            mori            morisco         morisco        \n  morn            morn            morning         morn           \n  mornings        morn            morocco         morocco        \n  morris          morri           morrow          morrow         \n  morrows         morrow          morsel          morsel         \n  morsels         morsel          mort            mort           \n  mortal          mortal          mortality       mortal         \n  mortally        mortal          mortals         mortal         \n  mortar          mortar          mortgaged       mortgag        \n  mortified       mortifi         mortifying      mortifi        \n  mortimer        mortim          mortimers       mortim         \n  mortis          morti           mortise         mortis         \n  morton          morton          mose            mose           \n  moss            moss            mossgrown       mossgrown      \n  most            most            mote            mote           \n  moth            moth            mother          mother         \n  mothers         mother          moths           moth           \n  motion          motion          motionless      motionless     \n  motions         motion          motive          motiv          \n  motives         motiv           motley          motlei         \n  mots            mot             mought          mought         \n  mould           mould           moulded         mould          \n  mouldeth        mouldeth        moulds          mould          \n  mouldy          mouldi          moult           moult          \n  moulten         moulten         mounch          mounch         \n  mounseur        mounseur        mounsieur       mounsieur      \n  mount           mount           mountain        mountain       \n  mountaineer     mountain        mountaineers    mountain       \n  mountainous     mountain        mountains       mountain       \n  mountant        mountant        mountanto       mountanto      \n  mountebank      mountebank      mountebanks     mountebank     \n  mounted         mount           mounteth        mounteth       \n  mounting        mount           mounts          mount          \n  mourn           mourn           mourned         mourn          \n  mourner         mourner         mourners        mourner        \n  mournful        mourn           mournfully      mournfulli     \n  mourning        mourn           mourningly      mourningli     \n  mournings       mourn           mourns          mourn          \n  mous            mou             mouse           mous           \n  mousetrap       mousetrap       mousing         mous           \n  mouth           mouth           mouthed         mouth          \n  mouths          mouth           mov             mov            \n  movables        movabl          move            move           \n  moveable        moveabl         moveables       moveabl        \n  moved           move            mover           mover          \n  movers          mover           moves           move           \n  moveth          moveth          moving          move           \n  movingly        movingli        movousus        movousu        \n  mow             mow             mowbray         mowbrai        \n  mower           mower           mowing          mow            \n  mows            mow             moy             moi            \n  moys            moi             moyses          moys           \n  mrs             mr              much            much           \n  muck            muck            mud             mud            \n  mudded          mud             muddied         muddi          \n  muddy           muddi           muffins         muffin         \n  muffl           muffl           muffle          muffl          \n  muffled         muffl           muffler         muffler        \n  muffling        muffl           mugger          mugger         \n  mugs            mug             mulberries      mulberri       \n  mulberry        mulberri        mule            mule           \n  mules           mule            muleteers       mulet          \n  mulier          mulier          mulieres        mulier         \n  muliteus        muliteu         mull            mull           \n  mulmutius       mulmutiu        multiplied      multipli       \n  multiply        multipli        multiplying     multipli       \n  multipotent     multipot        multitude       multitud       \n  multitudes      multitud        multitudinous   multitudin     \n  mum             mum             mumble          mumbl          \n  mumbling        mumbl           mummers         mummer         \n  mummy           mummi           mun             mun            \n  munch           munch           muniments       muniment       \n  munition        munit           murd            murd           \n  murder          murder          murdered        murder         \n  murderer        murder          murderers       murder         \n  murdering       murder          murderous       murder         \n  murders         murder          mure            mure           \n  murk            murk            murkiest        murkiest       \n  murky           murki           murmur          murmur         \n  murmurers       murmur          murmuring       murmur         \n  murrain         murrain         murray          murrai         \n  murrion         murrion         murther         murther        \n  murtherer       murther         murtherers      murther        \n  murthering      murther         murtherous      murther        \n  murthers        murther         mus             mu             \n  muscadel        muscadel        muscovites      muscovit       \n  muscovits       muscovit        muscovy         muscovi        \n  muse            muse            muses           muse           \n  mush            mush            mushrooms       mushroom       \n  music           music           musical         music          \n  musician        musician        musicians       musician       \n  musics          music           musing          muse           \n  musings         muse            musk            musk           \n  musket          musket          muskets         musket         \n  muskos          musko           muss            muss           \n  mussel          mussel          mussels         mussel         \n  must            must            mustachio       mustachio      \n  mustard         mustard         mustardseed     mustardse      \n  muster          muster          mustering       muster         \n  musters         muster          musty           musti          \n  mutability      mutabl          mutable         mutabl         \n  mutation        mutat           mutations       mutat          \n  mute            mute            mutes           mute           \n  mutest          mutest          mutine          mutin          \n  mutineer        mutin           mutineers       mutin          \n  mutines         mutin           mutinies        mutini         \n  mutinous        mutin           mutiny          mutini         \n  mutius          mutiu           mutter          mutter         \n  muttered        mutter          mutton          mutton         \n  muttons         mutton          mutual          mutual         \n  mutualities     mutual          mutually        mutual         \n  muzzl           muzzl           muzzle          muzzl          \n  muzzled         muzzl           mv              mv             \n  mww             mww             my              my             \n  mynheers        mynheer         myrmidon        myrmidon       \n  myrmidons       myrmidon        myrtle          myrtl          \n  myself          myself          myst            myst           \n  mysteries       mysteri         mystery         mysteri        \n  n               n               nag             nag            \n  nage            nage            nags            nag            \n  naiads          naiad           nail            nail           \n  nails           nail            nak             nak            \n  naked           nake            nakedness       naked          \n  nal             nal             nam             nam            \n  name            name            named           name           \n  nameless        nameless        namely          name           \n  names           name            namest          namest         \n  naming          name            nan             nan            \n  nance           nanc            nap             nap            \n  nape            nape            napes           nape           \n  napkin          napkin          napkins         napkin         \n  naples          napl            napless         napless        \n  napping         nap             naps            nap            \n  narbon          narbon          narcissus       narcissu       \n  narines         narin           narrow          narrow         \n  narrowly        narrowli        naso            naso           \n  nasty           nasti           nathaniel       nathaniel      \n  natifs          natif           nation          nation         \n  nations         nation          native          nativ          \n  nativity        nativ           natur           natur          \n  natural         natur           naturalize      natur          \n  naturally       natur           nature          natur          \n  natured         natur           natures         natur          \n  natus           natu            naught          naught         \n  naughtily       naughtili       naughty         naughti        \n  navarre         navarr          nave            nave           \n  navel           navel           navigation      navig          \n  navy            navi            nay             nai            \n  nayward         nayward         nayword         nayword        \n  nazarite        nazarit         ne              ne             \n  neaf            neaf            neamnoins       neamnoin       \n  neanmoins       neanmoin        neapolitan      neapolitan     \n  neapolitans     neapolitan      near            near           \n  nearer          nearer          nearest         nearest        \n  nearly          nearli          nearness        near           \n  neat            neat            neatly          neatli         \n  neb             neb             nebour          nebour         \n  nebuchadnezzar  nebuchadnezzar  nec             nec            \n  necessaries     necessari       necessarily     necessarili    \n  necessary       necessari       necessitied     necess         \n  necessities     necess          necessity       necess         \n  neck            neck            necklace        necklac        \n  necks           neck            nectar          nectar         \n  ned             ned             nedar           nedar          \n  need            need            needed          need           \n  needer          needer          needful         need           \n  needfull        needful         needing         need           \n  needle          needl           needles         needl          \n  needless        needless        needly          needli         \n  needs           need            needy           needi          \n  neer            neer            neeze           neez           \n  nefas           nefa            negation        negat          \n  negative        neg             negatives       neg            \n  neglect         neglect         neglected       neglect        \n  neglecting      neglect         neglectingly    neglectingli   \n  neglection      neglect         negligence      neglig         \n  negligent       neglig          negotiate       negoti         \n  negotiations    negoti          negro           negro          \n  neigh           neigh           neighbors       neighbor       \n  neighbour       neighbour       neighbourhood   neighbourhood  \n  neighbouring    neighbour       neighbourly     neighbourli    \n  neighbours      neighbour       neighing        neigh          \n  neighs          neigh           neither         neither        \n  nell            nell            nemean          nemean         \n  nemesis         nemesi          neoptolemus     neoptolemu     \n  nephew          nephew          nephews         nephew         \n  neptune         neptun          ner             ner            \n  nereides        nereid          nerissa         nerissa        \n  nero            nero            neroes          nero           \n  ners            ner             nerve           nerv           \n  nerves          nerv            nervii          nervii         \n  nervy           nervi           nessus          nessu          \n  nest            nest            nestor          nestor         \n  nests           nest            net             net            \n  nether          nether          netherlands     netherland     \n  nets            net             nettle          nettl          \n  nettled         nettl           nettles         nettl          \n  neuter          neuter          neutral         neutral        \n  nev             nev             never           never          \n  nevil           nevil           nevils          nevil          \n  new             new             newborn         newborn        \n  newer           newer           newest          newest         \n  newgate         newgat          newly           newli          \n  newness         new             news            new            \n  newsmongers     newsmong        newt            newt           \n  newts           newt            next            next           \n  nibbling        nibbl           nicanor         nicanor        \n  nice            nice            nicely          nice           \n  niceness        nice            nicer           nicer          \n  nicety          niceti          nicholas        nichola        \n  nick            nick            nickname        nicknam        \n  nicks           nick            niece           niec           \n  nieces          niec            niggard         niggard        \n  niggarding      niggard         niggardly       niggardli      \n  nigh            nigh            night           night          \n  nightcap        nightcap        nightcaps       nightcap       \n  nighted         night           nightgown       nightgown      \n  nightingale     nightingal      nightingales    nightingal     \n  nightly         nightli         nightmare       nightmar       \n  nights          night           nightwork       nightwork      \n  nihil           nihil           nile            nile           \n  nill            nill            nilus           nilu           \n  nimble          nimbl           nimbleness      nimbl          \n  nimbler         nimbler         nimbly          nimbl          \n  nine            nine            nineteen        nineteen       \n  ning            ning            ningly          ningli         \n  ninny           ninni           ninth           ninth          \n  ninus           ninu            niobe           niob           \n  niobes          niob            nip             nip            \n  nipp            nipp            nipping         nip            \n  nipple          nippl           nips            nip            \n  nit             nit             nly             nly            \n  nnight          nnight          nnights         nnight         \n  no              no              noah            noah           \n  nob             nob             nobility        nobil          \n  nobis           nobi            noble           nobl           \n  nobleman        nobleman        noblemen        noblemen       \n  nobleness       nobl            nobler          nobler         \n  nobles          nobl            noblesse        nobless        \n  noblest         noblest         nobly           nobli          \n  nobody          nobodi          noces           noce           \n  nod             nod             nodded          nod            \n  nodding         nod             noddle          noddl          \n  noddles         noddl           noddy           noddi          \n  nods            nod             noes            noe            \n  nointed         noint           nois            noi            \n  noise           nois            noiseless       noiseless      \n  noisemaker      noisemak        noises          nois           \n  noisome         noisom          nole            nole           \n  nominate        nomin           nominated       nomin          \n  nomination      nomin           nominativo      nominativo     \n  non             non             nonage          nonag          \n  nonce           nonc            none            none           \n  nonino          nonino          nonny           nonni          \n  nonpareil       nonpareil       nonsuits        nonsuit        \n  nony            noni            nook            nook           \n  nooks           nook            noon            noon           \n  noonday         noondai         noontide        noontid        \n  nor             nor             norbery         norberi        \n  norfolk         norfolk         norman          norman         \n  normandy        normandi        normans         norman         \n  north           north           northampton     northampton    \n  northamptonshire northamptonshir northerly       northerli      \n  northern        northern        northgate       northgat       \n  northumberland  northumberland  northumberlands northumberland \n  northward       northward       norway          norwai         \n  norways         norwai          norwegian       norwegian      \n  norweyan        norweyan        nos             no             \n  nose            nose            nosegays        nosegai        \n  noseless        noseless        noses           nose           \n  noster          noster          nostra          nostra         \n  nostril         nostril         nostrils        nostril        \n  not             not             notable         notabl         \n  notably         notabl          notary          notari         \n  notch           notch           note            note           \n  notebook        notebook        noted           note           \n  notedly         notedli         notes           note           \n  notest          notest          noteworthy      noteworthi     \n  nothing         noth            nothings        noth           \n  notice          notic           notify          notifi         \n  noting          note            notion          notion         \n  notorious       notori          notoriously     notori         \n  notre           notr            notwithstanding notwithstand   \n  nought          nought          noun            noun           \n  nouns           noun            nourish         nourish        \n  nourished       nourish         nourisher       nourish        \n  nourishes       nourish         nourisheth      nourisheth     \n  nourishing      nourish         nourishment     nourish        \n  nous            nou             novel           novel          \n  novelties       novelti         novelty         novelti        \n  noverbs         noverb          novi            novi           \n  novice          novic           novices         novic          \n  novum           novum           now             now            \n  nowhere         nowher          noyance         noyanc         \n  ns              ns              nt              nt             \n  nubibus         nubibu          numa            numa           \n  numb            numb            number          number         \n  numbered        number          numbering       number         \n  numberless      numberless      numbers         number         \n  numbness        numb            nun             nun            \n  nuncio          nuncio          nuncle          nuncl          \n  nunnery         nunneri         nuns            nun            \n  nuntius         nuntiu          nuptial         nuptial        \n  nurs            nur             nurse           nurs           \n  nursed          nurs            nurser          nurser         \n  nursery         nurseri         nurses          nurs           \n  nurseth         nurseth         nursh           nursh          \n  nursing         nurs            nurtur          nurtur         \n  nurture         nurtur          nut             nut            \n  nuthook         nuthook         nutmeg          nutmeg         \n  nutmegs         nutmeg          nutriment       nutriment      \n  nuts            nut             nutshell        nutshel        \n  ny              ny              nym             nym            \n  nymph           nymph           nymphs          nymph          \n  o               o               oak             oak            \n  oaken           oaken           oaks            oak            \n  oared           oar             oars            oar            \n  oatcake         oatcak          oaten           oaten          \n  oath            oath            oathable        oathabl        \n  oaths           oath            oats            oat            \n  ob              ob              obduracy        obduraci       \n  obdurate        obdur           obedience       obedi          \n  obedient        obedi           obeisance       obeis          \n  oberon          oberon          obey            obei           \n  obeyed          obei            obeying         obei           \n  obeys           obei            obidicut        obidicut       \n  object          object          objected        object         \n  objections      object          objects         object         \n  oblation        oblat           oblations       oblat          \n  obligation      oblig           obligations     oblig          \n  obliged         oblig           oblique         obliqu         \n  oblivion        oblivion        oblivious       oblivi         \n  obloquy         obloqui         obscene         obscen         \n  obscenely       obscen          obscur          obscur         \n  obscure         obscur          obscured        obscur         \n  obscurely       obscur          obscures        obscur         \n  obscuring       obscur          obscurity       obscur         \n  obsequies       obsequi         obsequious      obsequi        \n  obsequiously    obsequi         observ          observ         \n  observance      observ          observances     observ         \n  observancy      observ          observant       observ         \n  observants      observ          observation     observ         \n  observe         observ          observed        observ         \n  observer        observ          observers       observ         \n  observing       observ          observingly     observingli    \n  obsque          obsqu           obstacle        obstacl        \n  obstacles       obstacl         obstinacy       obstinaci      \n  obstinate       obstin          obstinately     obstin         \n  obstruct        obstruct        obstruction     obstruct       \n  obstructions    obstruct        obtain          obtain         \n  obtained        obtain          obtaining       obtain         \n  occasion        occas           occasions       occas          \n  occident        occid           occidental      occident       \n  occulted        occult          occupat         occupat        \n  occupation      occup           occupations     occup          \n  occupied        occupi          occupies        occupi         \n  occupy          occupi          occurrence      occurr         \n  occurrences     occurr          occurrents      occurr         \n  ocean           ocean           oceans          ocean          \n  octavia         octavia         octavius        octaviu        \n  ocular          ocular          od              od             \n  odd             odd             oddest          oddest         \n  oddly           oddli           odds            odd            \n  ode             od              odes            od             \n  odious          odiou           odoriferous     odorifer       \n  odorous         odor            odour           odour          \n  odours          odour           ods             od             \n  oeillades       oeillad         oes             oe             \n  oeuvres         oeuvr           of              of             \n  ofephesus       ofephesu        off             off            \n  offal           offal           offence         offenc         \n  offenceful      offenc          offences        offenc         \n  offend          offend          offended        offend         \n  offendendo      offendendo      offender        offend         \n  offenders       offend          offendeth       offendeth      \n  offending       offend          offendress      offendress     \n  offends         offend          offense         offens         \n  offenseless     offenseless     offenses        offens         \n  offensive       offens          offer           offer          \n  offered         offer           offering        offer          \n  offerings       offer           offers          offer          \n  offert          offert          offic           offic          \n  office          offic           officed         offic          \n  officer         offic           officers        offic          \n  offices         offic           official        offici         \n  officious       offici          offspring       offspr         \n  oft             oft             often           often          \n  oftener         often           oftentimes      oftentim       \n  oh              oh              oil             oil            \n  oils            oil             oily            oili           \n  old             old             oldcastle       oldcastl       \n  olden           olden           older           older          \n  oldest          oldest          oldness         old            \n  olive           oliv            oliver          oliv           \n  olivers         oliv            olives          oliv           \n  olivia          olivia          olympian        olympian       \n  olympus         olympu          oman            oman           \n  omans           oman            omen            omen           \n  ominous         omin            omission        omiss          \n  omit            omit            omittance       omitt          \n  omitted         omit            omitting        omit           \n  omne            omn             omnes           omn            \n  omnipotent      omnipot         on              on             \n  once            onc             one             on             \n  ones            on              oneyers         oney           \n  ongles          ongl            onion           onion          \n  onions          onion           only            onli           \n  onset           onset           onward          onward         \n  onwards         onward          oo              oo             \n  ooze            ooz             oozes           ooz            \n  oozy            oozi            op              op             \n  opal            opal            ope             op             \n  open            open            opener          open           \n  opening         open            openly          openli         \n  openness        open            opens           open           \n  operant         oper            operate         oper           \n  operation       oper            operations      oper           \n  operative       oper            opes            op             \n  oph             oph             ophelia         ophelia        \n  opinion         opinion         opinions        opinion        \n  opportune       opportun        opportunities   opportun       \n  opportunity     opportun        oppos           oppo           \n  oppose          oppos           opposed         oppos          \n  opposeless      opposeless      opposer         oppos          \n  opposers        oppos           opposes         oppos          \n  opposing        oppos           opposite        opposit        \n  opposites       opposit         opposition      opposit        \n  oppositions     opposit         oppress         oppress        \n  oppressed       oppress         oppresses       oppress        \n  oppresseth      oppresseth      oppressing      oppress        \n  oppression      oppress         oppressor       oppressor      \n  opprest         opprest         opprobriously   opprobri       \n  oppugnancy      oppugn          opulency        opul           \n  opulent         opul            or              or             \n  oracle          oracl           oracles         oracl          \n  orange          orang           oration         orat           \n  orator          orat            orators         orat           \n  oratory         oratori         orb             orb            \n  orbed           orb             orbs            orb            \n  orchard         orchard         orchards        orchard        \n  ord             ord             ordain          ordain         \n  ordained        ordain          ordaining       ordain         \n  order           order           ordered         order          \n  ordering        order           orderless       orderless      \n  orderly         orderli         orders          order          \n  ordinance       ordin           ordinant        ordin          \n  ordinaries      ordinari        ordinary        ordinari       \n  ordnance        ordnanc         ords            ord            \n  ordure          ordur           ore             or             \n  organ           organ           organs          organ          \n  orgillous       orgil           orient          orient         \n  orifex          orifex          origin          origin         \n  original        origin          orisons         orison         \n  ork             ork             orlando         orlando        \n  orld            orld            orleans         orlean         \n  ornament        ornament        ornaments       ornament       \n  orodes          orod            orphan          orphan         \n  orphans         orphan          orpheus         orpheu         \n  orsino          orsino          ort             ort            \n  orthography     orthographi     orts            ort            \n  oscorbidulchos  oscorbidulcho   osier           osier          \n  osiers          osier           osprey          osprei         \n  osr             osr             osric           osric          \n  ossa            ossa            ost             ost            \n  ostent          ostent          ostentare       ostentar       \n  ostentation     ostent          ostents         ostent         \n  ostler          ostler          ostlers         ostler         \n  ostrich         ostrich         osw             osw            \n  oswald          oswald          othello         othello        \n  other           other           othergates      otherg         \n  others          other           otherwhere      otherwher      \n  otherwhiles     otherwhil       otherwise       otherwis       \n  otter           otter           ottoman         ottoman        \n  ottomites       ottomit         oublie          oubli          \n  ouches          ouch            ought           ought          \n  oui             oui             ounce           ounc           \n  ounces          ounc            ouphes          ouph           \n  our             our             ours            our            \n  ourself         ourself         ourselves       ourselv        \n  ousel           ousel           out             out            \n  outbids         outbid          outbrave        outbrav        \n  outbraves       outbrav         outbreak        outbreak       \n  outcast         outcast         outcries        outcri         \n  outcry          outcri          outdar          outdar         \n  outdare         outdar          outdares        outdar         \n  outdone         outdon          outfac          outfac         \n  outface         outfac          outfaced        outfac         \n  outfacing       outfac          outfly          outfli         \n  outfrown        outfrown        outgo           outgo          \n  outgoes         outgo           outgrown        outgrown       \n  outjest         outjest         outlaw          outlaw         \n  outlawry        outlawri        outlaws         outlaw         \n  outliv          outliv          outlive         outliv         \n  outlives        outliv          outliving       outliv         \n  outlook         outlook         outlustres      outlustr       \n  outpriz         outpriz         outrage         outrag         \n  outrageous      outrag          outrages        outrag         \n  outran          outran          outright        outright       \n  outroar         outroar         outrun          outrun         \n  outrunning      outrun          outruns         outrun         \n  outscold        outscold        outscorn        outscorn       \n  outsell         outsel          outsells        outsel         \n  outside         outsid          outsides        outsid         \n  outspeaks       outspeak        outsport        outsport       \n  outstare        outstar         outstay         outstai        \n  outstood        outstood        outstretch      outstretch     \n  outstretched    outstretch      outstrike       outstrik       \n  outstrip        outstrip        outstripped     outstrip       \n  outswear        outswear        outvenoms       outvenom       \n  outward         outward         outwardly       outwardli      \n  outwards        outward         outwear         outwear        \n  outweighs       outweigh        outwent         outwent        \n  outworn         outworn         outworths       outworth       \n  oven            oven            over            over           \n  overawe         overaw          overbear        overbear       \n  overblown       overblown       overboard       overboard      \n  overbold        overbold        overborne       overborn       \n  overbulk        overbulk        overbuys        overbui        \n  overcame        overcam         overcast        overcast       \n  overcharg       overcharg       overcharged     overcharg      \n  overcome        overcom         overcomes       overcom        \n  overdone        overdon         overearnest     overearnest    \n  overfar         overfar         overflow        overflow       \n  overflown       overflown       overglance      overgl         \n  overgo          overgo          overgone        overgon        \n  overgorg        overgorg        overgrown       overgrown      \n  overhead        overhead        overhear        overhear       \n  overheard       overheard       overhold        overhold       \n  overjoyed       overjoi         overkind        overkind       \n  overland        overland        overleather     overleath      \n  overlive        overl           overlook        overlook       \n  overlooking     overlook        overlooks       overlook       \n  overmaster      overmast        overmounting    overmount      \n  overmuch        overmuch        overpass        overpass       \n  overpeer        overp           overpeering     overp          \n  overplus        overplu         overrul         overrul        \n  overrun         overrun         overscutch      overscutch     \n  overset         overset         overshades      overshad       \n  overshine       overshin        overshines      overshin       \n  overshot        overshot        oversights      oversight      \n  overspread      overspread      overstain       overstain      \n  overswear       overswear       overt           overt          \n  overta          overta          overtake        overtak        \n  overtaketh      overtaketh      overthrow       overthrow      \n  overthrown      overthrown      overthrows      overthrow      \n  overtook        overtook        overtopp        overtopp       \n  overture        overtur         overturn        overturn       \n  overwatch       overwatch       overween        overween       \n  overweening     overween        overweigh       overweigh      \n  overwhelm       overwhelm       overwhelming    overwhelm      \n  overworn        overworn        ovid            ovid           \n  ovidius         ovidiu          ow              ow             \n  owe             ow              owed            ow             \n  owedst          owedst          owen            owen           \n  owes            ow              owest           owest          \n  oweth           oweth           owing           ow             \n  owl             owl             owls            owl            \n  own             own             owner           owner          \n  owners          owner           owning          own            \n  owns            own             owy             owi            \n  ox              ox              oxen            oxen           \n  oxford          oxford          oxfordshire     oxfordshir     \n  oxlips          oxlip           oyes            oy             \n  oyster          oyster          p               p              \n  pabble          pabbl           pabylon         pabylon        \n  pac             pac             pace            pace           \n  paced           pace            paces           pace           \n  pacified        pacifi          pacify          pacifi         \n  pacing          pace            pack            pack           \n  packet          packet          packets         packet         \n  packhorses      packhors        packing         pack           \n  packings        pack            packs           pack           \n  packthread      packthread      pacorus         pacoru         \n  paction         paction         pad             pad            \n  paddle          paddl           paddling        paddl          \n  paddock         paddock         padua           padua          \n  pagan           pagan           pagans          pagan          \n  page            page            pageant         pageant        \n  pageants        pageant         pages           page           \n  pah             pah             paid            paid           \n  pail            pail            pailfuls        pail           \n  pails           pail            pain            pain           \n  pained          pain            painful         pain           \n  painfully       painfulli       pains           pain           \n  paint           paint           painted         paint          \n  painter         painter         painting        paint          \n  paintings       paint           paints          paint          \n  pair            pair            paired          pair           \n  pairs           pair            pajock          pajock         \n  pal             pal             palabras        palabra        \n  palace          palac           palaces         palac          \n  palamedes       palamed         palate          palat          \n  palates         palat           palatine        palatin        \n  palating        palat           pale            pale           \n  paled           pale            paleness        pale           \n  paler           paler           pales           pale           \n  palestine       palestin        palfrey         palfrei        \n  palfreys        palfrei         palisadoes      palisado       \n  pall            pall            pallabris       pallabri       \n  pallas          palla           pallets         pallet         \n  palm            palm            palmer          palmer         \n  palmers         palmer          palms           palm           \n  palmy           palmi           palpable        palpabl        \n  palsied         palsi           palsies         palsi          \n  palsy           palsi           palt            palt           \n  palter          palter          paltry          paltri         \n  paly            pali            pamp            pamp           \n  pamper          pamper          pamphlets       pamphlet       \n  pan             pan             pancackes       pancack        \n  pancake         pancak          pancakes        pancak         \n  pandar          pandar          pandars         pandar         \n  pandarus        pandaru         pander          pander         \n  panderly        panderli        panders         pander         \n  pandulph        pandulph        panel           panel          \n  pang            pang            panging         pang           \n  pangs           pang            pannier         pannier        \n  pannonians      pannonian       pansa           pansa          \n  pansies         pansi           pant            pant           \n  pantaloon       pantaloon       panted          pant           \n  pantheon        pantheon        panther         panther        \n  panthino        panthino        panting         pant           \n  pantingly       pantingli       pantler         pantler        \n  pantry          pantri          pants           pant           \n  pap             pap             papal           papal          \n  paper           paper           papers          paper          \n  paphlagonia     paphlagonia     paphos          papho          \n  papist          papist          paps            pap            \n  par             par             parable         parabl         \n  paracelsus      paracelsu       paradise        paradis        \n  paradox         paradox         paradoxes       paradox        \n  paragon         paragon         paragons        paragon        \n  parallel        parallel        parallels       parallel       \n  paramour        paramour        paramours       paramour       \n  parapets        parapet         paraquito       paraquito      \n  parasite        parasit         parasites       parasit        \n  parca           parca           parcel          parcel         \n  parcell         parcel          parcels         parcel         \n  parch           parch           parched         parch          \n  parching        parch           parchment       parchment      \n  pard            pard            pardon          pardon         \n  pardona         pardona         pardoned        pardon         \n  pardoner        pardon          pardoning       pardon         \n  pardonne        pardonn         pardonner       pardonn        \n  pardonnez       pardonnez       pardons         pardon         \n  pare            pare            pared           pare           \n  parel           parel           parent          parent         \n  parentage       parentag        parents         parent         \n  parfect         parfect         paring          pare           \n  parings         pare            paris           pari           \n  parish          parish          parishioners    parishion      \n  parisians       parisian        paritors        paritor        \n  park            park            parks           park           \n  parle           parl            parler          parler         \n  parles          parl            parley          parlei         \n  parlez          parlez          parliament      parliament     \n  parlors         parlor          parlour         parlour        \n  parlous         parlou          parmacity       parmac         \n  parolles        parol           parricide       parricid       \n  parricides      parricid        parrot          parrot         \n  parrots         parrot          parsley         parslei        \n  parson          parson          part            part           \n  partake         partak          partaken        partaken       \n  partaker        partak          partakers       partak         \n  parted          part            parthia         parthia        \n  parthian        parthian        parthians       parthian       \n  parti           parti           partial         partial        \n  partialize      partial         partially       partial        \n  participate     particip        participation   particip       \n  particle        particl         particular      particular     \n  particularities particular      particularize   particular     \n  particularly    particularli    particulars     particular     \n  parties         parti           parting         part           \n  partisan        partisan        partisans       partisan       \n  partition       partit          partizan        partizan       \n  partlet         partlet         partly          partli         \n  partner         partner         partners        partner        \n  partridge       partridg        parts           part           \n  party           parti           pas             pa             \n  pash            pash            pashed          pash           \n  pashful         pash            pass            pass           \n  passable        passabl         passado         passado        \n  passage         passag          passages        passag         \n  passant         passant         passed          pass           \n  passenger       passeng         passengers      passeng        \n  passes          pass            passeth         passeth        \n  passing         pass            passio          passio         \n  passion         passion         passionate      passion        \n  passioning      passion         passions        passion        \n  passive         passiv          passport        passport       \n  passy           passi           past            past           \n  paste           past            pasterns        pastern        \n  pasties         pasti           pastime         pastim         \n  pastimes        pastim          pastoral        pastor         \n  pastorals       pastor          pastors         pastor         \n  pastry          pastri          pasture         pastur         \n  pastures        pastur          pasty           pasti          \n  pat             pat             patay           patai          \n  patch           patch           patchery        patcheri       \n  patches         patch           pate            pate           \n  pated           pate            patent          patent         \n  patents         patent          paternal        patern         \n  pates           pate            path            path           \n  pathetical      pathet          paths           path           \n  pathway         pathwai         pathways        pathwai        \n  patience        patienc         patient         patient        \n  patiently       patient         patients        patient        \n  patines         patin           patrician       patrician      \n  patricians      patrician       patrick         patrick        \n  patrimony       patrimoni       patroclus       patroclu       \n  patron          patron          patronage       patronag       \n  patroness       patro           patrons         patron         \n  patrum          patrum          patter          patter         \n  pattern         pattern         patterns        pattern        \n  pattle          pattl           pauca           pauca          \n  paucas          pauca           paul            paul           \n  paulina         paulina         paunch          paunch         \n  paunches        paunch          pause           paus           \n  pauser          pauser          pauses          paus           \n  pausingly       pausingli       pauvres         pauvr          \n  pav             pav             paved           pave           \n  pavement        pavement        pavilion        pavilion       \n  pavilions       pavilion        pavin           pavin          \n  paw             paw             pawn            pawn           \n  pawns           pawn            paws            paw            \n  pax             pax             pay             pai            \n  payest          payest          paying          pai            \n  payment         payment         payments        payment        \n  pays            pai             paysan          paysan         \n  paysans         paysan          pe              pe             \n  peace           peac            peaceable       peaceabl       \n  peaceably       peaceabl        peaceful        peac           \n  peacemakers     peacemak        peaces          peac           \n  peach           peach           peaches         peach          \n  peacock         peacock         peacocks        peacock        \n  peak            peak            peaking         peak           \n  peal            peal            peals           peal           \n  pear            pear            peard           peard          \n  pearl           pearl           pearls          pearl          \n  pears           pear            peas            pea            \n  peasant         peasant         peasantry       peasantri      \n  peasants        peasant         peascod         peascod        \n  pease           peas            peaseblossom    peaseblossom   \n  peat            peat            peaten          peaten         \n  peating         peat            pebble          pebbl          \n  pebbled         pebbl           pebbles         pebbl          \n  peck            peck            pecks           peck           \n  peculiar        peculiar        pecus           pecu           \n  pedant          pedant          pedantical      pedant         \n  pedascule       pedascul        pede            pede           \n  pedestal        pedest          pedigree        pedigre        \n  pedlar          pedlar          pedlars         pedlar         \n  pedro           pedro           peds            ped            \n  peel            peel            peep            peep           \n  peeped          peep            peeping         peep           \n  peeps           peep            peer            peer           \n  peereth         peereth         peering         peer           \n  peerless        peerless        peers           peer           \n  peesel          peesel          peevish         peevish        \n  peevishly       peevishli       peflur          peflur         \n  peg             peg             pegasus         pegasu         \n  pegs            peg             peise           peis           \n  peised          peis            peize           peiz           \n  pelf            pelf            pelican         pelican        \n  pelion          pelion          pell            pell           \n  pella           pella           pelleted        pellet         \n  peloponnesus    peloponnesu     pelt            pelt           \n  pelting         pelt            pembroke        pembrok        \n  pen             pen             penalties       penalti        \n  penalty         penalti         penance         penanc         \n  pence           penc            pencil          pencil         \n  pencill         pencil          pencils         pencil         \n  pendant         pendant         pendent         pendent        \n  pendragon       pendragon       pendulous       pendul         \n  penelope        penelop         penetrable      penetr         \n  penetrate       penetr          penetrative     penetr         \n  penitence       penit           penitent        penit          \n  penitential     penitenti       penitently      penit          \n  penitents       penit           penker          penker         \n  penknife        penknif         penn            penn           \n  penned          pen             penning         pen            \n  pennons         pennon          penny           penni          \n  pennyworth      pennyworth      pennyworths     pennyworth     \n  pens            pen             pense           pens           \n  pension         pension         pensioners      pension        \n  pensive         pensiv          pensived        pensiv         \n  pensively       pensiv          pent            pent           \n  pentecost       pentecost       penthesilea     penthesilea    \n  penthouse       penthous        penurious       penuri         \n  penury          penuri          peopl           peopl          \n  people          peopl           peopled         peopl          \n  peoples         peopl           pepin           pepin          \n  pepper          pepper          peppercorn      peppercorn     \n  peppered        pepper          per             per            \n  peradventure    peradventur     peradventures   peradventur    \n  perceiv         perceiv         perceive        perceiv        \n  perceived       perceiv         perceives       perceiv        \n  perceiveth      perceiveth      perch           perch          \n  perchance       perchanc        percies         perci          \n  percussion      percuss         percy           perci          \n  perdie          perdi           perdita         perdita        \n  perdition       perdit          perdonato       perdonato      \n  perdu           perdu           perdurable      perdur         \n  perdurably      perdur          perdy           perdi          \n  pere            pere            peregrinate     peregrin       \n  peremptorily    peremptorili    peremptory      peremptori     \n  perfect         perfect         perfected       perfect        \n  perfecter       perfect         perfectest      perfectest     \n  perfection      perfect         perfections     perfect        \n  perfectly       perfectli       perfectness     perfect        \n  perfidious      perfidi         perfidiously    perfidi        \n  perforce        perforc         perform         perform        \n  performance     perform         performances    perform        \n  performed       perform         performer       perform        \n  performers      perform         performing      perform        \n  performs        perform         perfum          perfum         \n  perfume         perfum          perfumed        perfum         \n  perfumer        perfum          perfumes        perfum         \n  perge           perg            perhaps         perhap         \n  periapts        periapt         perigort        perigort       \n  perigouna       perigouna       peril           peril          \n  perilous        peril           perils          peril          \n  period          period          periods         period         \n  perish          perish          perished        perish         \n  perishest       perishest       perisheth       perisheth      \n  perishing       perish          periwig         periwig        \n  perjur          perjur          perjure         perjur         \n  perjured        perjur          perjuries       perjuri        \n  perjury         perjuri         perk            perk           \n  perkes          perk            permafoy        permafoi       \n  permanent       perman          permission      permiss        \n  permissive      permiss         permit          permit         \n  permitted       permit          pernicious      pernici        \n  perniciously    pernici         peroration      peror          \n  perpend         perpend         perpendicular   perpendicular  \n  perpendicularly perpendicularli perpetual       perpetu        \n  perpetually     perpetu         perpetuity      perpetu        \n  perplex         perplex         perplexed       perplex        \n  perplexity      perplex         pers            per            \n  persecuted      persecut        persecutions    persecut       \n  persecutor      persecutor      perseus         perseu         \n  persever        persev          perseverance    persever       \n  persevers       persev          persia          persia         \n  persian         persian         persist         persist        \n  persisted       persist         persistency     persist        \n  persistive      persist         persists        persist        \n  person          person          personae        persona        \n  personage       personag        personages      personag       \n  personal        person          personally      person         \n  personate       person          personated      person         \n  personates      person          personating     person         \n  persons         person          perspective     perspect       \n  perspectively   perspect        perspectives    perspect       \n  perspicuous     perspicu        persuade        persuad        \n  persuaded       persuad         persuades       persuad        \n  persuading      persuad         persuasion      persuas        \n  persuasions     persuas         pert            pert           \n  pertain         pertain         pertaining      pertain        \n  pertains        pertain         pertaunt        pertaunt       \n  pertinent       pertin          pertly          pertli         \n  perturb         perturb         perturbation    perturb        \n  perturbations   perturb         perturbed       perturb        \n  perus           peru            perusal         perus          \n  peruse          perus           perused         perus          \n  perusing        perus           perverse        pervers        \n  perversely      pervers         perverseness    pervers        \n  pervert         pervert         perverted       pervert        \n  peseech         peseech         pest            pest           \n  pester          pester          pestiferous     pestifer       \n  pestilence      pestil          pestilent       pestil         \n  pet             pet             petar           petar          \n  peter           peter           petit           petit          \n  petition        petit           petitionary     petitionari    \n  petitioner      petition        petitioners     petition       \n  petitions       petit           peto            peto           \n  petrarch        petrarch        petruchio       petruchio      \n  petter          petter          petticoat       petticoat      \n  petticoats      petticoat       pettiness       petti          \n  pettish         pettish         pettitoes       pettito        \n  petty           petti           peu             peu            \n  pew             pew             pewter          pewter         \n  pewterer        pewter          phaethon        phaethon       \n  phaeton         phaeton         phantasime      phantasim      \n  phantasimes     phantasim       phantasma       phantasma      \n  pharamond       pharamond       pharaoh         pharaoh        \n  pharsalia       pharsalia       pheasant        pheasant       \n  pheazar         pheazar         phebe           phebe          \n  phebes          phebe           pheebus         pheebu         \n  pheeze          pheez           phibbus         phibbu         \n  philadelphos    philadelpho     philario        philario       \n  philarmonus     philarmonu      philemon        philemon       \n  philip          philip          philippan       philippan      \n  philippe        philipp         philippi        philippi       \n  phillida        phillida        philo           philo          \n  philomel        philomel        philomela       philomela      \n  philosopher     philosoph       philosophers    philosoph      \n  philosophical   philosoph       philosophy      philosophi     \n  philostrate     philostr        philotus        philotu        \n  phlegmatic      phlegmat        phoebe          phoeb          \n  phoebus         phoebu          phoenicia       phoenicia      \n  phoenicians     phoenician      phoenix         phoenix        \n  phorbus         phorbu          photinus        photinu        \n  phrase          phrase          phraseless      phraseless     \n  phrases         phrase          phrygia         phrygia        \n  phrygian        phrygian        phrynia         phrynia        \n  physic          physic          physical        physic         \n  physician       physician       physicians      physician      \n  physics         physic          pia             pia            \n  pibble          pibbl           pible           pibl           \n  picardy         picardi         pick            pick           \n  pickaxe         pickax          pickaxes        pickax         \n  pickbone        pickbon         picked          pick           \n  pickers         picker          picking         pick           \n  pickle          pickl           picklock        picklock       \n  pickpurse       pickpurs        picks           pick           \n  pickt           pickt           pickthanks      pickthank      \n  pictur          pictur          picture         pictur         \n  pictured        pictur          pictures        pictur         \n  pid             pid             pie             pie            \n  piec            piec            piece           piec           \n  pieces          piec            piecing         piec           \n  pied            pi              piedness        pied           \n  pier            pier            pierc           pierc          \n  pierce          pierc           pierced         pierc          \n  pierces         pierc           pierceth        pierceth       \n  piercing        pierc           piercy          pierci         \n  piers           pier            pies            pi             \n  piety           pieti           pig             pig            \n  pigeon          pigeon          pigeons         pigeon         \n  pight           pight           pigmy           pigmi          \n  pigrogromitus   pigrogromitu    pike            pike           \n  pikes           pike            pil             pil            \n  pilate          pilat           pilates         pilat          \n  pilchers        pilcher         pile            pile           \n  piles           pile            pilf            pilf           \n  pilfering       pilfer          pilgrim         pilgrim        \n  pilgrimage      pilgrimag       pilgrims        pilgrim        \n  pill            pill            pillage         pillag         \n  pillagers       pillag          pillar          pillar         \n  pillars         pillar          pillicock       pillicock      \n  pillory         pillori         pillow          pillow         \n  pillows         pillow          pills           pill           \n  pilot           pilot           pilots          pilot          \n  pimpernell      pimpernel       pin             pin            \n  pinch           pinch           pinched         pinch          \n  pinches         pinch           pinching        pinch          \n  pindarus        pindaru         pine            pine           \n  pined           pine            pines           pine           \n  pinfold         pinfold         pining          pine           \n  pinion          pinion          pink            pink           \n  pinn            pinn            pinnace         pinnac         \n  pins            pin             pinse           pins           \n  pint            pint            pintpot         pintpot        \n  pioned          pion            pioneers        pioneer        \n  pioner          pioner          pioners         pioner         \n  pious           piou            pip             pip            \n  pipe            pipe            piper           piper          \n  pipers          piper           pipes           pipe           \n  piping          pipe            pippin          pippin         \n  pippins         pippin          pirate          pirat          \n  pirates         pirat           pisa            pisa           \n  pisanio         pisanio         pish            pish           \n  pismires        pismir          piss            piss           \n  pissing         piss            pistol          pistol         \n  pistols         pistol          pit             pit            \n  pitch           pitch           pitched         pitch          \n  pitcher         pitcher         pitchers        pitcher        \n  pitchy          pitchi          piteous         piteou         \n  piteously       piteous         pitfall         pitfal         \n  pith            pith            pithless        pithless       \n  pithy           pithi           pitie           piti           \n  pitied          piti            pities          piti           \n  pitiful         piti            pitifully       pitifulli      \n  pitiless        pitiless        pits            pit            \n  pittance        pittanc         pittie          pitti          \n  pittikins       pittikin        pity            piti           \n  pitying         piti            pius            piu            \n  plac            plac            place           place          \n  placed          place           placentio       placentio      \n  places          place           placeth         placeth        \n  placid          placid          placing         place          \n  plack           plack           placket         placket        \n  plackets        placket         plagu           plagu          \n  plague          plagu           plagued         plagu          \n  plagues         plagu           plaguing        plagu          \n  plaguy          plagui          plain           plain          \n  plainer         plainer         plainest        plainest       \n  plaining        plain           plainings       plain          \n  plainly         plainli         plainness       plain          \n  plains          plain           plainsong       plainsong      \n  plaintful       plaint          plaintiff       plaintiff      \n  plaintiffs      plaintiff       plaints         plaint         \n  planched        planch          planet          planet         \n  planetary       planetari       planets         planet         \n  planks          plank           plant           plant          \n  plantage        plantag         plantagenet     plantagenet    \n  plantagenets    plantagenet     plantain        plantain       \n  plantation      plantat         planted         plant          \n  planteth        planteth        plants          plant          \n  plash           plash           plashy          plashi         \n  plast           plast           plaster         plaster        \n  plasterer       plaster         plat            plat           \n  plate           plate           plated          plate          \n  plates          plate           platform        platform       \n  platforms       platform        plats           plat           \n  platted         plat            plausible       plausibl       \n  plausive        plausiv         plautus         plautu         \n  play            plai            played          plai           \n  player          player          players         player         \n  playeth         playeth         playfellow      playfellow     \n  playfellows     playfellow      playhouse       playhous       \n  playing         plai            plays           plai           \n  plea            plea            pleach          pleach         \n  pleached        pleach          plead           plead          \n  pleaded         plead           pleader         pleader        \n  pleaders        pleader         pleading        plead          \n  pleads          plead           pleas           plea           \n  pleasance       pleasanc        pleasant        pleasant       \n  pleasantly      pleasantli      please          pleas          \n  pleased         pleas           pleaser         pleaser        \n  pleasers        pleaser         pleases         pleas          \n  pleasest        pleasest        pleaseth        pleaseth       \n  pleasing        pleas           pleasure        pleasur        \n  pleasures       pleasur         plebeians       plebeian       \n  plebeii         plebeii         plebs           pleb           \n  pledge          pledg           pledges         pledg          \n  pleines         plein           plenitude       plenitud       \n  plenteous       plenteou        plenteously     plenteous      \n  plenties        plenti          plentiful       plenti         \n  plentifully     plentifulli     plenty          plenti         \n  pless           pless           plessed         pless          \n  plessing        pless           pliant          pliant         \n  plied           pli             plies           pli            \n  plight          plight          plighted        plight         \n  plighter        plighter        plod            plod           \n  plodded         plod            plodders        plodder        \n  plodding        plod            plods           plod           \n  plood           plood           ploody          ploodi         \n  plot            plot            plots           plot           \n  plotted         plot            plotter         plotter        \n  plough          plough          ploughed        plough         \n  ploughman       ploughman       ploughmen       ploughmen      \n  plow            plow            plows           plow           \n  pluck           pluck           plucked         pluck          \n  plucker         plucker         plucking        pluck          \n  plucks          pluck           plue            plue           \n  plum            plum            plume           plume          \n  plumed          plume           plumes          plume          \n  plummet         plummet         plump           plump          \n  plumpy          plumpi          plums           plum           \n  plung           plung           plunge          plung          \n  plunged         plung           plural          plural         \n  plurisy         plurisi         plus            plu            \n  pluto           pluto           plutus          plutu          \n  ply             ply             po              po             \n  pocket          pocket          pocketing       pocket         \n  pockets         pocket          pocky           pocki          \n  pody            podi            poem            poem           \n  poesy           poesi           poet            poet           \n  poetical        poetic          poetry          poetri         \n  poets           poet            poictiers       poictier       \n  poinards        poinard         poins           poin           \n  point           point           pointblank      pointblank     \n  pointed         point           pointing        point          \n  points          point           pois            poi            \n  poise           pois            poising         pois           \n  poison          poison          poisoned        poison         \n  poisoner        poison          poisoning       poison         \n  poisonous       poison          poisons         poison         \n  poke            poke            poking          poke           \n  pol             pol             polack          polack         \n  polacks         polack          poland          poland         \n  pold            pold            pole            pole           \n  poleaxe         poleax          polecat         polecat        \n  polecats        polecat         polemon         polemon        \n  poles           pole            poli            poli           \n  policies        polici          policy          polici         \n  polish          polish          polished        polish         \n  politic         polit           politician      politician     \n  politicians     politician      politicly       politicli      \n  polixenes       polixen         poll            poll           \n  polluted        pollut          pollution       pollut         \n  polonius        poloniu         poltroons       poltroon       \n  polusion        polus           polydamus       polydamu       \n  polydore        polydor         polyxena        polyxena       \n  pomander        pomand          pomegranate     pomegran       \n  pomewater       pomewat         pomfret         pomfret        \n  pomgarnet       pomgarnet       pommel          pommel         \n  pomp            pomp            pompeius        pompeiu        \n  pompey          pompei          pompion         pompion        \n  pompous         pompou          pomps           pomp           \n  pond            pond            ponder          ponder         \n  ponderous       ponder          ponds           pond           \n  poniard         poniard         poniards        poniard        \n  pont            pont            pontic          pontic         \n  pontifical      pontif          ponton          ponton         \n  pooh            pooh            pool            pool           \n  poole           pool            poop            poop           \n  poor            poor            poorer          poorer         \n  poorest         poorest         poorly          poorli         \n  pop             pop             pope            pope           \n  popedom         popedom         popilius        popiliu        \n  popingay        popingai        popish          popish         \n  popp            popp            poppy           poppi          \n  pops            pop             popular         popular        \n  popularity      popular         populous        popul          \n  porch           porch           porches         porch          \n  pore            pore            poring          pore           \n  pork            pork            porn            porn           \n  porpentine      porpentin       porridge        porridg        \n  porringer       porring         port            port           \n  portable        portabl         portage         portag         \n  portal          portal          portance        portanc        \n  portcullis      portculli       portend         portend        \n  portends        portend         portent         portent        \n  portentous      portent         portents        portent        \n  porter          porter          porters         porter         \n  portia          portia          portion         portion        \n  portly          portli          portotartarossa portotartarossa\n  portrait        portrait        portraiture     portraitur     \n  ports           port            portugal        portug         \n  pose            pose            posied          posi           \n  posies          posi            position        posit          \n  positive        posit           positively      posit          \n  posse           poss            possess         possess        \n  possessed       possess         possesses       possess        \n  possesseth      possesseth      possessing      possess        \n  possession      possess         possessions     possess        \n  possessor       possessor       posset          posset         \n  possets         posset          possibilities   possibl        \n  possibility     possibl         possible        possibl        \n  possibly        possibl         possitable      possit         \n  post            post            poste           post           \n  posted          post            posterior       posterior      \n  posteriors      posterior       posterity       poster         \n  postern         postern         posterns        postern        \n  posters         poster          posthorse       posthors       \n  posthorses      posthors        posthumus       posthumu       \n  posting         post            postmaster      postmast       \n  posts           post            postscript      postscript     \n  posture         postur          postures        postur         \n  posy            posi            pot             pot            \n  potable         potabl          potations       potat          \n  potato          potato          potatoes        potato         \n  potch           potch           potency         potenc         \n  potent          potent          potentates      potent         \n  potential       potenti         potently        potent         \n  potents         potent          pothecary       pothecari      \n  pother          pother          potion          potion         \n  potions         potion          potpan          potpan         \n  pots            pot             potter          potter         \n  potting         pot             pottle          pottl          \n  pouch           pouch           poulter         poulter        \n  poultice        poultic         poultney        poultnei       \n  pouncet         pouncet         pound           pound          \n  pounds          pound           pour            pour           \n  pourest         pourest         pouring         pour           \n  pourquoi        pourquoi        pours           pour           \n  pout            pout            poverty         poverti        \n  pow             pow             powd            powd           \n  powder          powder          power           power          \n  powerful        power           powerfully      powerfulli     \n  powerless       powerless       powers          power          \n  pox             pox             poys            poi            \n  poysam          poysam          prabbles        prabbl         \n  practic         practic         practice        practic        \n  practiced       practic         practicer       practic        \n  practices       practic         practicing      practic        \n  practis         practi          practisants     practis        \n  practise        practis         practiser       practis        \n  practisers      practis         practises       practis        \n  practising      practis         praeclarissimus praeclarissimu \n  praemunire      praemunir       praetor         praetor        \n  praetors        praetor         pragging        prag           \n  prague          pragu           prain           prain          \n  prains          prain           prais           prai           \n  praise          prais           praised         prais          \n  praises         prais           praisest        praisest       \n  praiseworthy    praiseworthi    praising        prais          \n  prancing        pranc           prank           prank          \n  pranks          prank           prat            prat           \n  prate           prate           prated          prate          \n  prater          prater          prating         prate          \n  prattle         prattl          prattler        prattler       \n  prattling       prattl          prave           prave          \n  prawls          prawl           prawns          prawn          \n  pray            prai            prayer          prayer         \n  prayers         prayer          praying         prai           \n  prays           prai            pre             pre            \n  preach          preach          preached        preach         \n  preachers       preacher        preaches        preach         \n  preaching       preach          preachment      preachment     \n  pread           pread           preambulate     preambul       \n  precedence      preced          precedent       preced         \n  preceding       preced          precept         precept        \n  preceptial      precepti        precepts        precept        \n  precinct        precinct        precious        preciou        \n  preciously      precious        precipice       precipic       \n  precipitating   precipit        precipitation   precipit       \n  precise         precis          precisely       precis         \n  preciseness     precis          precisian       precisian      \n  precor          precor          precurse        precurs        \n  precursors      precursor       predeceased     predeceas      \n  predecessor     predecessor     predecessors    predecessor    \n  predestinate    predestin       predicament     predica        \n  predict         predict         prediction      predict        \n  predictions     predict         predominance    predomin       \n  predominant     predomin        predominate     predomin       \n  preeches        preech          preeminence     preemin        \n  preface         prefac          prefer          prefer         \n  preferment      prefer          preferments     prefer         \n  preferr         preferr         preferreth      preferreth     \n  preferring      prefer          prefers         prefer         \n  prefiguring     prefigur        prefix          prefix         \n  prefixed        prefix          preformed       preform        \n  pregnancy       pregnanc        pregnant        pregnant       \n  pregnantly      pregnantli      prejudicates    prejud         \n  prejudice       prejudic        prejudicial     prejudici      \n  prelate         prelat          premeditated    premedit       \n  premeditation   premedit        premised        premis         \n  premises        premis          prenez          prenez         \n  prenominate     prenomin        prentice        prentic        \n  prentices       prentic         preordinance    preordin       \n  prepar          prepar          preparation     prepar         \n  preparations    prepar          prepare         prepar         \n  prepared        prepar          preparedly      preparedli     \n  prepares        prepar          preparing       prepar         \n  prepost         prepost         preposterous    preposter      \n  preposterously  preposter       prerogatifes    prerogatif     \n  prerogative     prerog          prerogatived    prerogativ     \n  presage         presag          presagers       presag         \n  presages        presag          presageth       presageth      \n  presaging       presag          prescience      prescienc      \n  prescribe       prescrib        prescript       prescript      \n  prescription    prescript       prescriptions   prescript      \n  prescripts      prescript       presence        presenc        \n  presences       presenc         present         present        \n  presentation    present         presented       present        \n  presenter       present         presenters      present        \n  presenteth      presenteth      presenting      present        \n  presently       present         presentment     present        \n  presents        present         preserv         preserv        \n  preservation    preserv         preservative    preserv        \n  preserve        preserv         preserved       preserv        \n  preserver       preserv         preservers      preserv        \n  preserving      preserv         president       presid         \n  press           press           pressed         press          \n  presser         presser         presses         press          \n  pressing        press           pressure        pressur        \n  pressures       pressur         prest           prest          \n  prester         prester         presume         presum         \n  presumes        presum          presuming       presum         \n  presumption     presumpt        presumptuous    presumptu      \n  presuppos       presuppo        pret            pret           \n  pretence        pretenc         pretences       pretenc        \n  pretend         pretend         pretended       pretend        \n  pretending      pretend         pretense        pretens        \n  pretext         pretext         pretia          pretia         \n  prettier        prettier        prettiest       prettiest      \n  prettily        prettili        prettiness      pretti         \n  pretty          pretti          prevail         prevail        \n  prevailed       prevail         prevaileth      prevaileth     \n  prevailing      prevail         prevailment     prevail        \n  prevails        prevail         prevent         prevent        \n  prevented       prevent         prevention      prevent        \n  preventions     prevent         prevents        prevent        \n  prey            prei            preyful         prey           \n  preys           prei            priam           priam          \n  priami          priami          priamus         priamu         \n  pribbles        pribbl          price           price          \n  prick           prick           pricked         prick          \n  pricket         pricket         pricking        prick          \n  pricks          prick           pricksong       pricksong      \n  pride           pride           prides          pride          \n  pridge          pridg           prie            prie           \n  pried           pri             prief           prief          \n  pries           pri             priest          priest         \n  priesthood      priesthood      priests         priest         \n  prig            prig            primal          primal         \n  prime           prime           primer          primer         \n  primero         primero         primest         primest        \n  primitive       primit          primo           primo          \n  primogenity     primogen        primrose        primros        \n  primroses       primros         primy           primi          \n  prince          princ           princely        princ          \n  princes         princ           princess        princess       \n  principal       princip         principalities  princip        \n  principality    princip         principle       principl       \n  principles      principl        princox         princox        \n  prings          pring           print           print          \n  printed         print           printing        print          \n  printless       printless       prints          print          \n  prioress        prioress        priories        priori         \n  priority        prioriti        priory          priori         \n  priscian        priscian        prison          prison         \n  prisoner        prison          prisoners       prison         \n  prisonment      prison          prisonnier      prisonni       \n  prisons         prison          pristine        pristin        \n  prithe          prith           prithee         prithe         \n  privacy         privaci         private         privat         \n  privately       privat          privates        privat         \n  privilage       privilag        privileg        privileg       \n  privilege       privileg        privileged      privileg       \n  privileges      privileg        privilegio      privilegio     \n  privily         privili         privity         priviti        \n  privy           privi           priz            priz           \n  prize           prize           prized          prize          \n  prizer          prizer          prizes          prize          \n  prizest         prizest         prizing         prize          \n  pro             pro             probable        probabl        \n  probal          probal          probation       probat         \n  proceed         proce           proceeded       proceed        \n  proceeders      proceed         proceeding      proceed        \n  proceedings     proceed         proceeds        proce          \n  process         process         procession      process        \n  proclaim        proclaim        proclaimed      proclaim       \n  proclaimeth     proclaimeth     proclaims       proclaim       \n  proclamation    proclam         proclamations   proclam        \n  proconsul       proconsul       procrastinate   procrastin     \n  procreant       procreant       procreants      procreant      \n  procreation     procreat        procrus         procru         \n  proculeius      proculeiu       procur          procur         \n  procurator      procur          procure         procur         \n  procured        procur          procures        procur         \n  procuring       procur          prodigal        prodig         \n  prodigality     prodig          prodigally      prodig         \n  prodigals       prodig          prodigies       prodigi        \n  prodigious      prodigi         prodigiously    prodigi        \n  prodigy         prodigi         proditor        proditor       \n  produc          produc          produce         produc         \n  produced        produc          produces        produc         \n  producing       produc          proface         profac         \n  profan          profan          profanation     profan         \n  profane         profan          profaned        profan         \n  profanely       profan          profaneness     profan         \n  profaners       profan          profaning       profan         \n  profess         profess         professed       profess        \n  professes       profess         profession      profess        \n  professions     profess         professors      professor      \n  proffer         proffer         proffered       proffer        \n  profferer       proffer         proffers        proffer        \n  proficient      profici         profit          profit         \n  profitable      profit          profitably      profit         \n  profited        profit          profiting       profit         \n  profitless      profitless      profits         profit         \n  profound        profound        profoundest     profoundest    \n  profoundly      profoundli      progenitors     progenitor     \n  progeny         progeni         progne          progn          \n  prognosticate   prognost        prognostication prognost       \n  progress        progress        progression     progress       \n  prohibit        prohibit        prohibition     prohibit       \n  project         project         projection      project        \n  projects        project         prolixious      prolixi        \n  prolixity       prolix          prologue        prologu        \n  prologues       prologu         prolong         prolong        \n  prolongs        prolong         promethean      promethean     \n  prometheus      prometheu       promis          promi          \n  promise         promis          promised        promis         \n  promises        promis          promiseth       promiseth      \n  promising       promis          promontory      promontori     \n  promotion       promot          promotions      promot         \n  prompt          prompt          prompted        prompt         \n  promptement     promptement     prompter        prompter       \n  prompting       prompt          prompts         prompt         \n  prompture       promptur        promulgate      promulg        \n  prone           prone           prononcer       prononc        \n  prononcez       prononcez       pronoun         pronoun        \n  pronounc        pronounc        pronounce       pronounc       \n  pronounced      pronounc        pronouncing     pronounc       \n  pronouns        pronoun         proof           proof          \n  proofs          proof           prop            prop           \n  propagate       propag          propagation     propag         \n  propend         propend         propension      propens        \n  proper          proper          properer        proper         \n  properly        properli        propertied      properti       \n  properties      properti        property        properti       \n  prophecies      propheci        prophecy        propheci       \n  prophesied      prophesi        prophesier      prophesi       \n  prophesy        prophesi        prophesying     prophesi       \n  prophet         prophet         prophetess      prophetess     \n  prophetic       prophet         prophetically   prophet        \n  prophets        prophet         propinquity     propinqu       \n  propontic       propont         proportion      proport        \n  proportionable  proportion      proportions     proport        \n  propos          propo           propose         propos         \n  proposed        propos          proposer        propos         \n  proposes        propos          proposing       propos         \n  proposition     proposit        propositions    proposit       \n  propounded      propound        propp           propp          \n  propre          propr           propriety       proprieti      \n  props           prop            propugnation    propugn        \n  prorogue        prorogu         prorogued       prorogu        \n  proscription    proscript       proscriptions   proscript      \n  prose           prose           prosecute       prosecut       \n  prosecution     prosecut        proselytes      proselyt       \n  proserpina      proserpina      prosp           prosp          \n  prospect        prospect        prosper         prosper        \n  prosperity      prosper         prospero        prospero       \n  prosperous      prosper         prosperously    prosper        \n  prospers        prosper         prostitute      prostitut      \n  prostrate       prostrat        protect         protect        \n  protected       protect         protection      protect        \n  protector       protector       protectors      protector      \n  protectorship   protectorship   protectress     protectress    \n  protects        protect         protest         protest        \n  protestation    protest         protestations   protest        \n  protested       protest         protester       protest        \n  protesting      protest         protests        protest        \n  proteus         proteu          protheus        protheu        \n  protract        protract        protractive     protract       \n  proud           proud           prouder         prouder        \n  proudest        proudest        proudlier       proudlier      \n  proudly         proudli         prouds          proud          \n  prov            prov            provand         provand        \n  prove           prove           proved          prove          \n  provender       provend         proverb         proverb        \n  proverbs        proverb         proves          prove          \n  proveth         proveth         provide         provid         \n  provided        provid          providence      provid         \n  provident       provid          providently     provid         \n  provider        provid          provides        provid         \n  province        provinc         provinces       provinc        \n  provincial      provinci        proving         prove          \n  provision       provis          proviso         proviso        \n  provocation     provoc          provok          provok         \n  provoke         provok          provoked        provok         \n  provoker        provok          provokes        provok         \n  provoketh       provoketh       provoking       provok         \n  provost         provost         prowess         prowess        \n  prudence        prudenc         prudent         prudent        \n  prun            prun            prune           prune          \n  prunes          prune           pruning         prune          \n  pry             pry             prying          pry            \n  psalm           psalm           psalmist        psalmist       \n  psalms          psalm           psalteries      psalteri       \n  ptolemies       ptolemi         ptolemy         ptolemi        \n  public          public          publican        publican       \n  publication     public          publicly        publicli       \n  publicola       publicola       publish         publish        \n  published       publish         publisher       publish        \n  publishing      publish         publius         publiu         \n  pucelle         pucel           puck            puck           \n  pudder          pudder          pudding         pud            \n  puddings        pud             puddle          puddl          \n  puddled         puddl           pudency         pudenc         \n  pueritia        pueritia        puff            puff           \n  puffing         puf             puffs           puff           \n  pugging         pug             puis            pui            \n  puissance       puissanc        puissant        puissant       \n  puke            puke            puking          puke           \n  pulcher         pulcher         puling          pule           \n  pull            pull            puller          puller         \n  pullet          pullet          pulling         pull           \n  pulls           pull            pulpit          pulpit         \n  pulpiter        pulpit          pulpits         pulpit         \n  pulse           puls            pulsidge        pulsidg        \n  pump            pump            pumpion         pumpion        \n  pumps           pump            pun             pun            \n  punched         punch           punish          punish         \n  punished        punish          punishes        punish         \n  punishment      punish          punishments     punish         \n  punk            punk            punto           punto          \n  puny            puni            pupil           pupil          \n  pupils          pupil           puppet          puppet         \n  puppets         puppet          puppies         puppi          \n  puppy           puppi           pur             pur            \n  purblind        purblind        purchas         purcha         \n  purchase        purchas         purchased       purchas        \n  purchases       purchas         purchaseth      purchaseth     \n  purchasing      purchas         pure            pure           \n  purely          pure            purer           purer          \n  purest          purest          purg            purg           \n  purgation       purgat          purgative       purg           \n  purgatory       purgatori       purge           purg           \n  purged          purg            purgers         purger         \n  purging         purg            purifies        purifi         \n  purifying       purifi          puritan         puritan        \n  purity          puriti          purlieus        purlieu        \n  purple          purpl           purpled         purpl          \n  purples         purpl           purport         purport        \n  purpos          purpo           purpose         purpos         \n  purposed        purpos          purposely       purpos         \n  purposes        purpos          purposeth       purposeth      \n  purposing       purpos          purr            purr           \n  purs            pur             purse           purs           \n  pursents        pursent         purses          purs           \n  pursu           pursu           pursue          pursu          \n  pursued         pursu           pursuers        pursuer        \n  pursues         pursu           pursuest        pursuest       \n  pursueth        pursueth        pursuing        pursu          \n  pursuit         pursuit         pursuivant      pursuiv        \n  pursuivants     pursuiv         pursy           pursi          \n  purus           puru            purveyor        purveyor       \n  push            push            pushes          push           \n  pusillanimity   pusillanim      put             put            \n  putrefy         putrefi         putrified       putrifi        \n  puts            put             putter          putter         \n  putting         put             puttock         puttock        \n  puzzel          puzzel          puzzle          puzzl          \n  puzzled         puzzl           puzzles         puzzl          \n  py              py              pygmalion       pygmalion      \n  pygmies         pygmi           pygmy           pygmi          \n  pyramid         pyramid         pyramides       pyramid        \n  pyramids        pyramid         pyramis         pyrami         \n  pyramises       pyramis         pyramus         pyramu         \n  pyrenean        pyrenean        pyrrhus         pyrrhu         \n  pythagoras      pythagora       qu              qu             \n  quadrangle      quadrangl       quae            quae           \n  quaff           quaff           quaffing        quaf           \n  quagmire        quagmir         quail           quail          \n  quailing        quail           quails          quail          \n  quaint          quaint          quaintly        quaintli       \n  quak            quak            quake           quak           \n  quakes          quak            qualification   qualif         \n  qualified       qualifi         qualifies       qualifi        \n  qualify         qualifi         qualifying      qualifi        \n  qualite         qualit          qualities       qualiti        \n  quality         qualiti         qualm           qualm          \n  qualmish        qualmish        quam            quam           \n  quand           quand           quando          quando         \n  quantities      quantiti        quantity        quantiti       \n  quare           quar            quarrel         quarrel        \n  quarrell        quarrel         quarreller      quarrel        \n  quarrelling     quarrel         quarrelous      quarrel        \n  quarrels        quarrel         quarrelsome     quarrelsom     \n  quarries        quarri          quarry          quarri         \n  quart           quart           quarter         quarter        \n  quartered       quarter         quartering      quarter        \n  quarters        quarter         quarts          quart          \n  quasi           quasi           quat            quat           \n  quatch          quatch          quay            quai           \n  que             que             quean           quean          \n  queas           quea            queasiness      queasi         \n  queasy          queasi          queen           queen          \n  queens          queen           quell           quell          \n  queller         queller         quench          quench         \n  quenched        quench          quenching       quench         \n  quenchless      quenchless      quern           quern          \n  quest           quest           questant        questant       \n  question        question        questionable    question       \n  questioned      question        questioning     question       \n  questionless    questionless    questions       question       \n  questrists      questrist       quests          quest          \n  queubus         queubu          qui             qui            \n  quick           quick           quicken         quicken        \n  quickens        quicken         quicker         quicker        \n  quicklier       quicklier       quickly         quickli        \n  quickness       quick           quicksand       quicksand      \n  quicksands      quicksand       quicksilverr    quicksilverr   \n  quid            quid            quiddities      quidditi       \n  quiddits        quiddit         quier           quier          \n  quiet           quiet           quieter         quieter        \n  quietly         quietli         quietness       quiet          \n  quietus         quietu          quill           quill          \n  quillets        quillet         quills          quill          \n  quilt           quilt           quinapalus      quinapalu      \n  quince          quinc           quinces         quinc          \n  quintain        quintain        quintessence    quintess       \n  quintus         quintu          quip            quip           \n  quips           quip            quire           quir           \n  quiring         quir            quirk           quirk          \n  quirks          quirk           quis            qui            \n  quit            quit            quite           quit           \n  quits           quit            quittance       quittanc       \n  quitted         quit            quitting        quit           \n  quiver          quiver          quivering       quiver         \n  quivers         quiver          quo             quo            \n  quod            quod            quoifs          quoif          \n  quoint          quoint          quoit           quoit          \n  quoits          quoit           quondam         quondam        \n  quoniam         quoniam         quote           quot           \n  quoted          quot            quotes          quot           \n  quoth           quoth           quotidian       quotidian      \n  r               r               rabbit          rabbit         \n  rabble          rabbl           rabblement      rabblement     \n  race            race            rack            rack           \n  rackers         racker          racket          racket         \n  rackets         racket          racking         rack           \n  racks           rack            radiance        radianc        \n  radiant         radiant         radish          radish         \n  rafe            rafe            raft            raft           \n  rag             rag             rage            rage           \n  rages           rage            rageth          rageth         \n  ragg            ragg            ragged          rag            \n  raggedness      ragged          raging          rage           \n  ragozine        ragozin         rags            rag            \n  rah             rah             rail            rail           \n  railed          rail            railer          railer         \n  railest         railest         raileth         raileth        \n  railing         rail            rails           rail           \n  raiment         raiment         rain            rain           \n  rainbow         rainbow         raineth         raineth        \n  raining         rain            rainold         rainold        \n  rains           rain            rainy           raini          \n  rais            rai             raise           rais           \n  raised          rais            raises          rais           \n  raising         rais            raisins         raisin         \n  rak             rak             rake            rake           \n  rakers          raker           rakes           rake           \n  ral             ral             rald            rald           \n  ralph           ralph           ram             ram            \n  rambures        rambur          ramm            ramm           \n  rampallian      rampallian      rampant         rampant        \n  ramping         ramp            rampir          rampir         \n  ramps           ramp            rams            ram            \n  ramsey          ramsei          ramston         ramston        \n  ran             ran             rance           ranc           \n  rancorous       rancor          rancors         rancor         \n  rancour         rancour         random          random         \n  rang            rang            range           rang           \n  ranged          rang            rangers         ranger         \n  ranges          rang            ranging         rang           \n  rank            rank            ranker          ranker         \n  rankest         rankest         ranking         rank           \n  rankle          rankl           rankly          rankli         \n  rankness        rank            ranks           rank           \n  ransack         ransack         ransacking      ransack        \n  ransom          ransom          ransomed        ransom         \n  ransoming       ransom          ransomless      ransomless     \n  ransoms         ransom          rant            rant           \n  ranting         rant            rap             rap            \n  rape            rape            rapes           rape           \n  rapier          rapier          rapiers         rapier         \n  rapine          rapin           raps            rap            \n  rapt            rapt            rapture         raptur         \n  raptures        raptur          rar             rar            \n  rare            rare            rarely          rare           \n  rareness        rare            rarer           rarer          \n  rarest          rarest          rarities        rariti         \n  rarity          rariti          rascal          rascal         \n  rascalliest     rascalliest     rascally        rascal         \n  rascals         rascal          rased           rase           \n  rash            rash            rasher          rasher         \n  rashly          rashli          rashness        rash           \n  rat             rat             ratcatcher      ratcatch       \n  ratcliff        ratcliff        rate            rate           \n  rated           rate            rately          rate           \n  rates           rate            rather          rather         \n  ratherest       ratherest       ratified        ratifi         \n  ratifiers       ratifi          ratify          ratifi         \n  rating          rate            rational        ration         \n  ratolorum       ratolorum       rats            rat            \n  ratsbane        ratsban         rattle          rattl          \n  rattles         rattl           rattling        rattl          \n  rature          ratur           raught          raught         \n  rav             rav             rave            rave           \n  ravel           ravel           raven           raven          \n  ravening        raven           ravenous        raven          \n  ravens          raven           ravenspurgh     ravenspurgh    \n  raves           rave            ravin           ravin          \n  raving          rave            ravish          ravish         \n  ravished        ravish          ravisher        ravish         \n  ravishing       ravish          ravishments     ravish         \n  raw             raw             rawer           rawer          \n  rawly           rawli           rawness         raw            \n  ray             rai             rayed           rai            \n  rays            rai             raz             raz            \n  raze            raze            razed           raze           \n  razes           raze            razeth          razeth         \n  razing          raze            razor           razor          \n  razorable       razor           razors          razor          \n  razure          razur           re              re             \n  reach           reach           reaches         reach          \n  reacheth        reacheth        reaching        reach          \n  read            read            reader          reader         \n  readiest        readiest        readily         readili        \n  readiness       readi           reading         read           \n  readins         readin          reads           read           \n  ready           readi           real            real           \n  really          realli          realm           realm          \n  realms          realm           reap            reap           \n  reapers         reaper          reaping         reap           \n  reaps           reap            rear            rear           \n  rears           rear            rearward        rearward       \n  reason          reason          reasonable      reason         \n  reasonably      reason          reasoned        reason         \n  reasoning       reason          reasonless      reasonless     \n  reasons         reason          reave           reav           \n  rebate          rebat           rebato          rebato         \n  rebeck          rebeck          rebel           rebel          \n  rebell          rebel           rebelling       rebel          \n  rebellion       rebellion       rebellious      rebelli        \n  rebels          rebel           rebound         rebound        \n  rebuk           rebuk           rebuke          rebuk          \n  rebukeable      rebuk           rebuked         rebuk          \n  rebukes         rebuk           rebus           rebu           \n  recall          recal           recant          recant         \n  recantation     recant          recanter        recant         \n  recanting       recant          receipt         receipt        \n  receipts        receipt         receiv          receiv         \n  receive         receiv          received        receiv         \n  receiver        receiv          receives        receiv         \n  receivest       receivest       receiveth       receiveth      \n  receiving       receiv          receptacle      receptacl      \n  rechate         rechat          reciprocal      reciproc       \n  reciprocally    reciproc        recite          recit          \n  recited         recit           reciterai       reciterai      \n  reck            reck            recking         reck           \n  reckless        reckless        reckon          reckon         \n  reckoned        reckon          reckoning       reckon         \n  reckonings      reckon          recks           reck           \n  reclaim         reclaim         reclaims        reclaim        \n  reclusive       reclus          recognizance    recogniz       \n  recognizances   recogniz        recoil          recoil         \n  recoiling       recoil          recollected     recollect      \n  recomforted     recomfort       recomforture    recomfortur    \n  recommend       recommend       recommended     recommend      \n  recommends      recommend       recompens       recompen       \n  recompense      recompens       reconcil        reconcil       \n  reconcile       reconcil        reconciled      reconcil       \n  reconcilement   reconcil        reconciler      reconcil       \n  reconciles      reconcil        reconciliation  reconcili      \n  record          record          recordation     record         \n  recorded        record          recorder        record         \n  recorders       record          records         record         \n  recount         recount         recounted       recount        \n  recounting      recount         recountments    recount        \n  recounts        recount         recourse        recours        \n  recov           recov           recover         recov          \n  recoverable     recover         recovered       recov          \n  recoveries      recoveri        recovers        recov          \n  recovery        recoveri        recreant        recreant       \n  recreants       recreant        recreate        recreat        \n  recreation      recreat         rectify         rectifi        \n  rector          rector          rectorship      rectorship     \n  recure          recur           recured         recur          \n  red             red             redbreast       redbreast      \n  redder          redder          reddest         reddest        \n  rede            rede            redeem          redeem         \n  redeemed        redeem          redeemer        redeem         \n  redeeming       redeem          redeems         redeem         \n  redeliver       redeliv         redemption      redempt        \n  redime          redim           redness         red            \n  redoubled       redoubl         redoubted       redoubt        \n  redound         redound         redress         redress        \n  redressed       redress         redresses       redress        \n  reduce          reduc           reechy          reechi         \n  reed            reed            reeds           reed           \n  reek            reek            reeking         reek           \n  reeks           reek            reeky           reeki          \n  reel            reel            reeleth         reeleth        \n  reeling         reel            reels           reel           \n  refell          refel           refer           refer          \n  reference       refer           referr          referr         \n  referred        refer           refigured       refigur        \n  refin           refin           refined         refin          \n  reflect         reflect         reflecting      reflect        \n  reflection      reflect         reflex          reflex         \n  reform          reform          reformation     reform         \n  reformed        reform          refractory      refractori     \n  refrain         refrain         refresh         refresh        \n  refreshing      refresh         reft            reft           \n  refts           reft            refuge          refug          \n  refus           refu            refusal         refus          \n  refuse          refus           refused         refus          \n  refusest        refusest        refusing        refus          \n  reg             reg             regal           regal          \n  regalia         regalia         regan           regan          \n  regard          regard          regardance      regard         \n  regarded        regard          regardfully     regardfulli    \n  regarding       regard          regards         regard         \n  regenerate      regener         regent          regent         \n  regentship      regentship      regia           regia          \n  regiment        regiment        regiments       regiment       \n  regina          regina          region          region         \n  regions         region          regist          regist         \n  register        regist          registers       regist         \n  regreet         regreet         regreets        regreet        \n  regress         regress         reguerdon       reguerdon      \n  regular         regular         rehears         rehear         \n  rehearsal       rehears         rehearse        rehears        \n  reign           reign           reigned         reign          \n  reignier        reignier        reigning        reign          \n  reigns          reign           rein            rein           \n  reinforc        reinforc        reinforce       reinforc       \n  reinforcement   reinforc        reins           rein           \n  reiterate       reiter          reject          reject         \n  rejected        reject          rejoic          rejoic         \n  rejoice         rejoic          rejoices        rejoic         \n  rejoiceth       rejoiceth       rejoicing       rejoic         \n  rejoicingly     rejoicingli     rejoindure      rejoindur      \n  rejourn         rejourn         rel             rel            \n  relapse         relaps          relate          relat          \n  relates         relat           relation        relat          \n  relations       relat           relative        rel            \n  releas          relea           release         releas         \n  released        releas          releasing       releas         \n  relent          relent          relenting       relent         \n  relents         relent          reliances       relianc        \n  relics          relic           relief          relief         \n  reliev          reliev          relieve         reliev         \n  relieved        reliev          relieves        reliev         \n  relieving       reliev          religion        religion       \n  religions       religion        religious       religi         \n  religiously     religi          relinquish      relinquish     \n  reliques        reliqu          reliquit        reliquit       \n  relish          relish          relume          relum          \n  rely            reli            relying         reli           \n  remain          remain          remainder       remaind        \n  remainders      remaind         remained        remain         \n  remaineth       remaineth       remaining       remain         \n  remains         remain          remark          remark         \n  remarkable      remark          remediate       remedi         \n  remedied        remedi          remedies        remedi         \n  remedy          remedi          rememb          rememb         \n  remember        rememb          remembered      rememb         \n  remembers       rememb          remembrance     remembr        \n  remembrancer    remembranc      remembrances    remembr        \n  remercimens     remercimen      remiss          remiss         \n  remission       remiss          remissness      remiss         \n  remit           remit           remnant         remnant        \n  remnants        remnant         remonstrance    remonstr       \n  remorse         remors          remorseful      remors         \n  remorseless     remorseless     remote          remot          \n  remotion        remot           remov           remov          \n  remove          remov           removed         remov          \n  removedness     removed         remover         remov          \n  removes         remov           removing        remov          \n  remunerate      remuner         remuneration    remuner        \n  rence           renc            rend            rend           \n  render          render          rendered        render         \n  renders         render          rendezvous      rendezv        \n  renegado        renegado        renege          reneg          \n  reneges         reneg           renew           renew          \n  renewed         renew           renewest        renewest       \n  renounce        renounc         renouncement    renounc        \n  renouncing      renounc         renowmed        renowm         \n  renown          renown          renowned        renown         \n  rent            rent            rents           rent           \n  repaid          repaid          repair          repair         \n  repaired        repair          repairing       repair         \n  repairs         repair          repass          repass         \n  repast          repast          repasture       repastur       \n  repay           repai           repaying        repai          \n  repays          repai           repeal          repeal         \n  repealing       repeal          repeals         repeal         \n  repeat          repeat          repeated        repeat         \n  repeating       repeat          repeats         repeat         \n  repel           repel           repent          repent         \n  repentance      repent          repentant       repent         \n  repented        repent          repenting       repent         \n  repents         repent          repetition      repetit        \n  repetitions     repetit         repin           repin          \n  repine          repin           repining        repin          \n  replant         replant         replenish       replenish      \n  replenished     replenish       replete         replet         \n  replication     replic          replied         repli          \n  replies         repli           repliest        repliest       \n  reply           repli           replying        repli          \n  report          report          reported        report         \n  reporter        report          reportest       reportest      \n  reporting       report          reportingly     reportingli    \n  reports         report          reposal         repos          \n  repose          repos           reposeth        reposeth       \n  reposing        repos           repossess       repossess      \n  reprehend       reprehend       reprehended     reprehend      \n  reprehending    reprehend       represent       repres         \n  representing    repres          reprieve        repriev        \n  reprieves       repriev         reprisal        repris         \n  reproach        reproach        reproaches      reproach       \n  reproachful     reproach        reproachfully   reproachfulli  \n  reprobate       reprob          reprobation     reprob         \n  reproof         reproof         reprov          reprov         \n  reprove         reprov          reproveable     reprov         \n  reproves        reprov          reproving       reprov         \n  repugn          repugn          repugnancy      repugn         \n  repugnant       repugn          repulse         repuls         \n  repulsed        repuls          repurchas       repurcha       \n  repured         repur           reputation      reput          \n  repute          reput           reputed         reput          \n  reputeless      reputeless      reputes         reput          \n  reputing        reput           request         request        \n  requested       request         requesting      request        \n  requests        request         requiem         requiem        \n  requir          requir          require         requir         \n  required        requir          requires        requir         \n  requireth       requireth       requiring       requir         \n  requisite       requisit        requisites      requisit       \n  requit          requit          requital        requit         \n  requite         requit          requited        requit         \n  requites        requit          rer             rer            \n  rere            rere            rers            rer            \n  rescu           rescu           rescue          rescu          \n  rescued         rescu           rescues         rescu          \n  rescuing        rescu           resemblance     resembl        \n  resemble        resembl         resembled       resembl        \n  resembles       resembl         resembleth      resembleth     \n  resembling      resembl         reserv          reserv         \n  reservation     reserv          reserve         reserv         \n  reserved        reserv          reserves        reserv         \n  reside          resid           residence       resid          \n  resident        resid           resides         resid          \n  residing        resid           residue         residu         \n  resign          resign          resignation     resign         \n  resist          resist          resistance      resist         \n  resisted        resist          resisting       resist         \n  resists         resist          resolute        resolut        \n  resolutely      resolut         resolutes       resolut        \n  resolution      resolut         resolv          resolv         \n  resolve         resolv          resolved        resolv         \n  resolvedly      resolvedli      resolves        resolv         \n  resolveth       resolveth       resort          resort         \n  resorted        resort          resounding      resound        \n  resounds        resound         respeaking      respeak        \n  respect         respect         respected       respect        \n  respecting      respect         respective      respect        \n  respectively    respect         respects        respect        \n  respice         respic          respite         respit         \n  respites        respit          responsive      respons        \n  respose         respos          ress            ress           \n  rest            rest            rested          rest           \n  resteth         resteth         restful         rest           \n  resting         rest            restitution     restitut       \n  restless        restless        restor          restor         \n  restoration     restor          restorative     restor         \n  restore         restor          restored        restor         \n  restores        restor          restoring       restor         \n  restrain        restrain        restrained      restrain       \n  restraining     restrain        restrains       restrain       \n  restraint       restraint       rests           rest           \n  resty           resti           resum           resum          \n  resume          resum           resumes         resum          \n  resurrections   resurrect       retail          retail         \n  retails         retail          retain          retain         \n  retainers       retain          retaining       retain         \n  retell          retel           retention       retent         \n  retentive       retent          retinue         retinu         \n  retir           retir           retire          retir          \n  retired         retir           retirement      retir          \n  retires         retir           retiring        retir          \n  retold          retold          retort          retort         \n  retorts         retort          retourne        retourn        \n  retract         retract         retreat         retreat        \n  retrograde      retrograd       rets            ret            \n  return          return          returned        return         \n  returnest       returnest       returneth       returneth      \n  returning       return          returns         return         \n  revania         revania         reveal          reveal         \n  reveals         reveal          revel           revel          \n  reveler         revel           revell          revel          \n  reveller        revel           revellers       revel          \n  revelling       revel           revelry         revelri        \n  revels          revel           reveng          reveng         \n  revenge         reveng          revenged        reveng         \n  revengeful      reveng          revengement     reveng         \n  revenger        reveng          revengers       reveng         \n  revenges        reveng          revenging       reveng         \n  revengingly     revengingli     revenue         revenu         \n  revenues        revenu          reverb          reverb         \n  reverberate     reverber        reverbs         reverb         \n  reverenc        reverenc        reverence       rever          \n  reverend        reverend        reverent        rever          \n  reverently      rever           revers          rever          \n  reverse         revers          reversion       revers         \n  reverted        revert          review          review         \n  reviewest       reviewest       revil           revil          \n  revile          revil           revisits        revisit        \n  reviv           reviv           revive          reviv          \n  revives         reviv           reviving        reviv          \n  revok           revok           revoke          revok          \n  revokement      revok           revolt          revolt         \n  revolted        revolt          revolting       revolt         \n  revolts         revolt          revolution      revolut        \n  revolutions     revolut         revolve         revolv         \n  revolving       revolv          reward          reward         \n  rewarded        reward          rewarder        reward         \n  rewarding       reward          rewards         reward         \n  reword          reword          reworded        reword         \n  rex             rex             rey             rei            \n  reynaldo        reynaldo        rford           rford          \n  rful            rful            rfull           rfull          \n  rhapsody        rhapsodi        rheims          rheim          \n  rhenish         rhenish         rhesus          rhesu          \n  rhetoric        rhetor          rheum           rheum          \n  rheumatic       rheumat         rheums          rheum          \n  rheumy          rheumi          rhinoceros      rhinocero      \n  rhodes          rhode           rhodope         rhodop         \n  rhubarb         rhubarb         rhym            rhym           \n  rhyme           rhyme           rhymers         rhymer         \n  rhymes          rhyme           rhyming         rhyme          \n  rialto          rialto          rib             rib            \n  ribald          ribald          riband          riband         \n  ribands         riband          ribaudred       ribaudr        \n  ribb            ribb            ribbed          rib            \n  ribbon          ribbon          ribbons         ribbon         \n  ribs            rib             rice            rice           \n  rich            rich            richard         richard        \n  richer          richer          riches          rich           \n  richest         richest         richly          richli         \n  richmond        richmond        richmonds       richmond       \n  rid             rid             riddance        riddanc        \n  ridden          ridden          riddle          riddl          \n  riddles         riddl           riddling        riddl          \n  ride            ride            rider           rider          \n  riders          rider           rides           ride           \n  ridest          ridest          rideth          rideth         \n  ridge           ridg            ridges          ridg           \n  ridiculous      ridicul         riding          ride           \n  rids            rid             rien            rien           \n  ries            ri              rifle           rifl           \n  rift            rift            rifted          rift           \n  rig             rig             rigg            rigg           \n  riggish         riggish         right           right          \n  righteous       righteou        righteously     righteous      \n  rightful        right           rightfully      rightfulli     \n  rightly         rightli         rights          right          \n  rigol           rigol           rigorous        rigor          \n  rigorously      rigor           rigour          rigour         \n  ril             ril             rim             rim            \n  rin             rin             rinaldo         rinaldo        \n  rind            rind            ring            ring           \n  ringing         ring            ringleader      ringlead       \n  ringlets        ringlet         rings           ring           \n  ringwood        ringwood        riot            riot           \n  rioter          rioter          rioting         riot           \n  riotous         riotou          riots           riot           \n  rip             rip             ripe            ripe           \n  ripely          ripe            ripen           ripen          \n  ripened         ripen           ripeness        ripe           \n  ripening        ripen           ripens          ripen          \n  riper           riper           ripest          ripest         \n  riping          ripe            ripp            ripp           \n  ripping         rip             rise            rise           \n  risen           risen           rises           rise           \n  riseth          riseth          rish            rish           \n  rising          rise            rite            rite           \n  rites           rite            rivage          rivag          \n  rival           rival           rivality        rival          \n  rivall          rival           rivals          rival          \n  rive            rive            rived           rive           \n  rivelled        rivel           river           river          \n  rivers          river           rivet           rivet          \n  riveted         rivet           rivets          rivet          \n  rivo            rivo            rj              rj             \n  rless           rless           road            road           \n  roads           road            roam            roam           \n  roaming         roam            roan            roan           \n  roar            roar            roared          roar           \n  roarers         roarer          roaring         roar           \n  roars           roar            roast           roast          \n  roasted         roast           rob             rob            \n  roba            roba            robas           roba           \n  robb            robb            robbed          rob            \n  robber          robber          robbers         robber         \n  robbery         robberi         robbing         rob            \n  robe            robe            robed           robe           \n  robert          robert          robes           robe           \n  robin           robin           robs            rob            \n  robustious      robusti         rochester       rochest        \n  rochford        rochford        rock            rock           \n  rocks           rock            rocky           rocki          \n  rod             rod             rode            rode           \n  roderigo        roderigo        rods            rod            \n  roe             roe             roes            roe            \n  roger           roger           rogero          rogero         \n  rogue           rogu            roguery         rogueri        \n  rogues          rogu            roguish         roguish        \n  roi             roi             roisting        roist          \n  roll            roll            rolled          roll           \n  rolling         roll            rolls           roll           \n  rom             rom             romage          romag          \n  roman           roman           romano          romano         \n  romanos         romano          romans          roman          \n  rome            rome            romeo           romeo          \n  romish          romish          rondure         rondur         \n  ronyon          ronyon          rood            rood           \n  roof            roof            roofs           roof           \n  rook            rook            rooks           rook           \n  rooky           rooki           room            room           \n  rooms           room            root            root           \n  rooted          root            rootedly        rootedli       \n  rooteth         rooteth         rooting         root           \n  roots           root            rope            rope           \n  ropery          roperi          ropes           rope           \n  roping          rope            ros             ro             \n  rosalind        rosalind        rosalinda       rosalinda      \n  rosalinde       rosalind        rosaline        rosalin        \n  roscius         rosciu          rose            rose           \n  rosed           rose            rosemary        rosemari       \n  rosencrantz     rosencrantz     roses           rose           \n  ross            ross            rosy            rosi           \n  rot             rot             rote            rote           \n  roted           rote            rother          rother         \n  rotherham       rotherham       rots            rot            \n  rotted          rot             rotten          rotten         \n  rottenness      rotten          rotting         rot            \n  rotundity       rotund          rouen           rouen          \n  rough           rough           rougher         rougher        \n  roughest        roughest        roughly         roughli        \n  roughness       rough           round           round          \n  rounded         round           roundel         roundel        \n  rounder         rounder         roundest        roundest       \n  rounding        round           roundly         roundli        \n  rounds          round           roundure        roundur        \n  rous            rou             rouse           rous           \n  roused          rous            rousillon       rousillon      \n  rously          rousli          roussi          roussi         \n  rout            rout            routed          rout           \n  routs           rout            rove            rove           \n  rover           rover           row             row            \n  rowel           rowel           rowland         rowland        \n  rowlands        rowland         roy             roi            \n  royal           royal           royalize        royal          \n  royally         royal           royalties       royalti        \n  royalty         royalti         roynish         roynish        \n  rs              rs              rt              rt             \n  rub             rub             rubb            rubb           \n  rubbing         rub             rubbish         rubbish        \n  rubies          rubi            rubious         rubiou         \n  rubs            rub             ruby            rubi           \n  rud             rud             rudand          rudand         \n  rudder          rudder          ruddiness       ruddi          \n  ruddock         ruddock         ruddy           ruddi          \n  rude            rude            rudely          rude           \n  rudeness        rude            ruder           ruder          \n  rudesby         rudesbi         rudest          rudest         \n  rudiments       rudiment        rue             rue            \n  rued            ru              ruff            ruff           \n  ruffian         ruffian         ruffians        ruffian        \n  ruffle          ruffl           ruffling        ruffl          \n  ruffs           ruff            rug             rug            \n  rugby           rugbi           rugemount       rugemount      \n  rugged          rug             ruin            ruin           \n  ruinate         ruinat          ruined          ruin           \n  ruining         ruin            ruinous         ruinou         \n  ruins           ruin            rul             rul            \n  rule            rule            ruled           rule           \n  ruler           ruler           rulers          ruler          \n  rules           rule            ruling          rule           \n  rumble          rumbl           ruminaies       ruminai        \n  ruminat         ruminat         ruminate        rumin          \n  ruminated       rumin           ruminates       rumin          \n  rumination      rumin           rumor           rumor          \n  rumour          rumour          rumourer        rumour         \n  rumours         rumour          rump            rump           \n  run             run             runagate        runag          \n  runagates       runag           runaway         runawai        \n  runaways        runawai         rung            rung           \n  runn            runn            runner          runner         \n  runners         runner          running         run            \n  runs            run             rupture         ruptur         \n  ruptures        ruptur          rural           rural          \n  rush            rush            rushes          rush           \n  rushing         rush            rushling        rushl          \n  rushy           rushi           russet          russet         \n  russia          russia          russian         russian        \n  russians        russian         rust            rust           \n  rusted          rust            rustic          rustic         \n  rustically      rustic          rustics         rustic         \n  rustle          rustl           rustling        rustl          \n  rusts           rust            rusty           rusti          \n  rut             rut             ruth            ruth           \n  ruthful         ruth            ruthless        ruthless       \n  rutland         rutland         ruttish         ruttish        \n  ry              ry              rye             rye            \n  rything         ryth            s               s              \n  sa              sa              saba            saba           \n  sabbath         sabbath         sable           sabl           \n  sables          sabl            sack            sack           \n  sackbuts        sackbut         sackcloth       sackcloth      \n  sacked          sack            sackerson       sackerson      \n  sacks           sack            sacrament       sacrament      \n  sacred          sacr            sacrific        sacrif         \n  sacrifice       sacrific        sacrificers     sacrific       \n  sacrifices      sacrific        sacrificial     sacrifici      \n  sacrificing     sacrif          sacrilegious    sacrilegi      \n  sacring         sacr            sad             sad            \n  sadder          sadder          saddest         saddest        \n  saddle          saddl           saddler         saddler        \n  saddles         saddl           sadly           sadli          \n  sadness         sad             saf             saf            \n  safe            safe            safeguard       safeguard      \n  safely          safe            safer           safer          \n  safest          safest          safeties        safeti         \n  safety          safeti          saffron         saffron        \n  sag             sag             sage            sage           \n  sagittary       sagittari       said            said           \n  saidst          saidst          sail            sail           \n  sailing         sail            sailmaker       sailmak        \n  sailor          sailor          sailors         sailor         \n  sails           sail            sain            sain           \n  saint           saint           sainted         saint          \n  saintlike       saintlik        saints          saint          \n  saith           saith           sake            sake           \n  sakes           sake            sala            sala           \n  salad           salad           salamander      salamand       \n  salary          salari          sale            sale           \n  salerio         salerio         salicam         salicam        \n  salique         saliqu          salisbury       salisburi      \n  sall            sall            sallet          sallet         \n  sallets         sallet          sallies         salli          \n  sallow          sallow          sally           salli          \n  salmon          salmon          salmons         salmon         \n  salt            salt            salter          salter         \n  saltiers        saltier         saltness        salt           \n  saltpetre       saltpetr        salutation      salut          \n  salutations     salut           salute          salut          \n  saluted         salut           salutes         salut          \n  saluteth        saluteth        salv            salv           \n  salvation       salvat          salve           salv           \n  salving         salv            same            same           \n  samingo         samingo         samp            samp           \n  sampire         sampir          sample          sampl          \n  sampler         sampler         sampson         sampson        \n  samson          samson          samsons         samson         \n  sancta          sancta          sanctified      sanctifi       \n  sanctifies      sanctifi        sanctify        sanctifi       \n  sanctimonies    sanctimoni      sanctimonious   sanctimoni     \n  sanctimony      sanctimoni      sanctities      sanctiti       \n  sanctity        sanctiti        sanctuarize     sanctuar       \n  sanctuary       sanctuari       sand            sand           \n  sandal          sandal          sandbag         sandbag        \n  sanded          sand            sands           sand           \n  sandy           sandi           sandys          sandi          \n  sang            sang            sanguine        sanguin        \n  sanguis         sangui          sanity          saniti         \n  sans            san             santrailles     santrail       \n  sap             sap             sapient         sapient        \n  sapit           sapit           sapless         sapless        \n  sapling         sapl            sapphire        sapphir        \n  sapphires       sapphir         saracens        saracen        \n  sarcenet        sarcenet        sard            sard           \n  sardians        sardian         sardinia        sardinia       \n  sardis          sardi           sarum           sarum          \n  sat             sat             satan           satan          \n  satchel         satchel         sate            sate           \n  sated           sate            satiate         satiat         \n  satiety         satieti         satin           satin          \n  satire          satir           satirical       satir          \n  satis           sati            satisfaction    satisfact      \n  satisfied       satisfi         satisfies       satisfi        \n  satisfy         satisfi         satisfying      satisfi        \n  saturday        saturdai        saturdays       saturdai       \n  saturn          saturn          saturnine       saturnin       \n  saturninus      saturninu       satyr           satyr          \n  satyrs          satyr           sauc            sauc           \n  sauce           sauc            sauced          sauc           \n  saucers         saucer          sauces          sauc           \n  saucily         saucili         sauciness       sauci          \n  saucy           sauci           sauf            sauf           \n  saunder         saunder         sav             sav            \n  savage          savag           savagely        savag          \n  savageness      savag           savagery        savageri       \n  savages         savag           save            save           \n  saved           save            saves           save           \n  saving          save            saviour         saviour        \n  savory          savori          savour          savour         \n  savouring       savour          savours         savour         \n  savoury         savouri         savoy           savoi          \n  saw             saw             sawed           saw            \n  sawest          sawest          sawn            sawn           \n  sawpit          sawpit          saws            saw            \n  sawyer          sawyer          saxons          saxon          \n  saxony          saxoni          saxton          saxton         \n  say             sai             sayest          sayest         \n  saying          sai             sayings         sai            \n  says            sai             sayst           sayst          \n  sblood          sblood          sc              sc             \n  scab            scab            scabbard        scabbard       \n  scabs           scab            scaffold        scaffold       \n  scaffoldage     scaffoldag      scal            scal           \n  scald           scald           scalded         scald          \n  scalding        scald           scale           scale          \n  scaled          scale           scales          scale          \n  scaling         scale           scall           scall          \n  scalp           scalp           scalps          scalp          \n  scaly           scali           scamble         scambl         \n  scambling       scambl          scamels         scamel         \n  scan            scan            scandal         scandal        \n  scandaliz       scandaliz       scandalous      scandal        \n  scandy          scandi          scann           scann          \n  scant           scant           scanted         scant          \n  scanter         scanter         scanting        scant          \n  scantling       scantl          scants          scant          \n  scap            scap            scape           scape          \n  scaped          scape           scapes          scape          \n  scapeth         scapeth         scar            scar           \n  scarce          scarc           scarcely        scarc          \n  scarcity        scarciti        scare           scare          \n  scarecrow       scarecrow       scarecrows      scarecrow      \n  scarf           scarf           scarfed         scarf          \n  scarfs          scarf           scaring         scare          \n  scarlet         scarlet         scarr           scarr          \n  scarre          scarr           scars           scar           \n  scarus          scaru           scath           scath          \n  scathe          scath           scathful        scath          \n  scatt           scatt           scatter         scatter        \n  scattered       scatter         scattering      scatter        \n  scatters        scatter         scelera         scelera        \n  scelerisque     scelerisqu      scene           scene          \n  scenes          scene           scent           scent          \n  scented         scent           scept           scept          \n  scepter         scepter         sceptre         sceptr         \n  sceptred        sceptr          sceptres        sceptr         \n  schedule        schedul         schedules       schedul        \n  scholar         scholar         scholarly       scholarli      \n  scholars        scholar         school          school         \n  schoolboy       schoolboi       schoolboys      schoolboi      \n  schoolfellows   schoolfellow    schooling       school         \n  schoolmaster    schoolmast      schoolmasters   schoolmast     \n  schools         school          sciatica        sciatica       \n  sciaticas       sciatica        science         scienc         \n  sciences        scienc          scimitar        scimitar       \n  scion           scion           scions          scion          \n  scissors        scissor         scoff           scoff          \n  scoffer         scoffer         scoffing        scof           \n  scoffs          scoff           scoggin         scoggin        \n  scold           scold           scolding        scold          \n  scolds          scold           sconce          sconc          \n  scone           scone           scope           scope          \n  scopes          scope           scorch          scorch         \n  scorched        scorch          score           score          \n  scored          score           scores          score          \n  scoring         score           scorn           scorn          \n  scorned         scorn           scornful        scorn          \n  scornfully      scornfulli      scorning        scorn          \n  scorns          scorn           scorpion        scorpion       \n  scorpions       scorpion        scot            scot           \n  scotch          scotch          scotches        scotch         \n  scotland        scotland        scots           scot           \n  scottish        scottish        scoundrels      scoundrel      \n  scour           scour           scoured         scour          \n  scourg          scourg          scourge         scourg         \n  scouring        scour           scout           scout          \n  scouts          scout           scowl           scowl          \n  scrap           scrap           scrape          scrape         \n  scraping        scrape          scraps          scrap          \n  scratch         scratch         scratches       scratch        \n  scratching      scratch         scream          scream         \n  screams         scream          screech         screech        \n  screeching      screech         screen          screen         \n  screens         screen          screw           screw          \n  screws          screw           scribbl         scribbl        \n  scribbled       scribbl         scribe          scribe         \n  scribes         scribe          scrimers        scrimer        \n  scrip           scrip           scrippage       scrippag       \n  scripture       scriptur        scriptures      scriptur       \n  scrivener       scriven         scroll          scroll         \n  scrolls         scroll          scroop          scroop         \n  scrowl          scrowl          scroyles        scroyl         \n  scrubbed        scrub           scruple         scrupl         \n  scruples        scrupl          scrupulous      scrupul        \n  scuffles        scuffl          scuffling       scuffl         \n  scullion        scullion        sculls          scull          \n  scum            scum            scurril         scurril        \n  scurrility      scurril         scurrilous      scurril        \n  scurvy          scurvi          scuse           scuse          \n  scut            scut            scutcheon       scutcheon      \n  scutcheons      scutcheon       scylla          scylla         \n  scythe          scyth           scythed         scyth          \n  scythia         scythia         scythian        scythian       \n  sdeath          sdeath          se              se             \n  sea             sea             seacoal         seacoal        \n  seafaring       seafar          seal            seal           \n  sealed          seal            sealing         seal           \n  seals           seal            seam            seam           \n  seamen          seamen          seamy           seami          \n  seaport         seaport         sear            sear           \n  searce          searc           search          search         \n  searchers       searcher        searches        search         \n  searcheth       searcheth       searching       search         \n  seared          sear            seas            sea            \n  seasick         seasick         seaside         seasid         \n  season          season          seasoned        season         \n  seasons         season          seat            seat           \n  seated          seat            seats           seat           \n  sebastian       sebastian       second          second         \n  secondarily     secondarili     secondary       secondari      \n  seconded        second          seconds         second         \n  secrecy         secreci         secret          secret         \n  secretaries     secretari       secretary       secretari      \n  secretly        secretli        secrets         secret         \n  sect            sect            sectary         sectari        \n  sects           sect            secundo         secundo        \n  secure          secur           securely        secur          \n  securing        secur           security        secur          \n  sedg            sedg            sedge           sedg           \n  sedges          sedg            sedgy           sedgi          \n  sedition        sedit           seditious       sediti         \n  seduc           seduc           seduce          seduc          \n  seduced         seduc           seducer         seduc          \n  seducing        seduc           see             see            \n  seed            seed            seeded          seed           \n  seedness        seed            seeds           seed           \n  seedsman        seedsman        seein           seein          \n  seeing          see             seek            seek           \n  seeking         seek            seeks           seek           \n  seel            seel            seeling         seel           \n  seely           seeli           seem            seem           \n  seemed          seem            seemers         seemer         \n  seemest         seemest         seemeth         seemeth        \n  seeming         seem            seemingly       seemingli      \n  seemly          seemli          seems           seem           \n  seen            seen            seer            seer           \n  sees            see             seese           sees           \n  seest           seest           seethe          seeth          \n  seethes         seeth           seething        seeth          \n  seeting         seet            segregation     segreg         \n  seigneur        seigneur        seigneurs       seigneur       \n  seiz            seiz            seize           seiz           \n  seized          seiz            seizes          seiz           \n  seizeth         seizeth         seizing         seiz           \n  seizure         seizur          seld            seld           \n  seldom          seldom          select          select         \n  seleucus        seleucu         self            self           \n  selfsame        selfsam         sell            sell           \n  seller          seller          selling         sell           \n  sells           sell            selves          selv           \n  semblable       semblabl        semblably       semblabl       \n  semblance       semblanc        semblances      semblanc       \n  semblative      sembl           semi            semi           \n  semicircle      semicircl       semiramis       semirami       \n  semper          semper          sempronius      semproniu      \n  senate          senat           senator         senat          \n  senators        senat           send            send           \n  sender          sender          sendeth         sendeth        \n  sending         send            sends           send           \n  seneca          seneca          senior          senior         \n  seniory         seniori         senis           seni           \n  sennet          sennet          senoys          senoi          \n  sense           sens            senseless       senseless      \n  senses          sens            sensible        sensibl        \n  sensibly        sensibl         sensual         sensual        \n  sensuality      sensual         sent            sent           \n  sentenc         sentenc         sentence        sentenc        \n  sentences       sentenc         sententious     sententi       \n  sentinel        sentinel        sentinels       sentinel       \n  separable       separ           separate        separ          \n  separated       separ           separates       separ          \n  separation      separ           septentrion     septentrion    \n  sepulchre       sepulchr        sepulchres      sepulchr       \n  sepulchring     sepulchr        sequel          sequel         \n  sequence        sequenc         sequent         sequent        \n  sequest         sequest         sequester       sequest        \n  sequestration   sequestr        sere            sere           \n  serenis         sereni          serge           serg           \n  sergeant        sergeant        serious         seriou         \n  seriously       serious         sermon          sermon         \n  sermons         sermon          serpent         serpent        \n  serpentine      serpentin       serpents        serpent        \n  serpigo         serpigo         serv            serv           \n  servant         servant         servanted       servant        \n  servants        servant         serve           serv           \n  served          serv            server          server         \n  serves          serv            serveth         serveth        \n  service         servic          serviceable     servic         \n  services        servic          servile         servil         \n  servility       servil          servilius       serviliu       \n  serving         serv            servingman      servingman     \n  servingmen      servingmen      serviteur       serviteur      \n  servitor        servitor        servitors       servitor       \n  servitude       servitud        sessa           sessa          \n  session         session         sessions        session        \n  sestos          sesto           set             set            \n  setebos         setebo          sets            set            \n  setter          setter          setting         set            \n  settle          settl           settled         settl          \n  settlest        settlest        settling        settl          \n  sev             sev             seven           seven          \n  sevenfold       sevenfold       sevennight      sevennight     \n  seventeen       seventeen       seventh         seventh        \n  seventy         seventi         sever           sever          \n  several         sever           severally       sever          \n  severals        sever           severe          sever          \n  severed         sever           severely        sever          \n  severest        severest        severing        sever          \n  severity        sever           severn          severn         \n  severs          sever           sew             sew            \n  seward          seward          sewer           sewer          \n  sewing          sew             sex             sex            \n  sexes           sex             sexton          sexton         \n  sextus          sextu           seymour         seymour        \n  seyton          seyton          sfoot           sfoot          \n  sh              sh              shackle         shackl         \n  shackles        shackl          shade           shade          \n  shades          shade           shadow          shadow         \n  shadowed        shadow          shadowing       shadow         \n  shadows         shadow          shadowy         shadowi        \n  shady           shadi           shafalus        shafalu        \n  shaft           shaft           shafts          shaft          \n  shag            shag            shak            shak           \n  shake           shake           shaked          shake          \n  shaken          shaken          shakes          shake          \n  shaking         shake           shales          shale          \n  shall           shall           shallenge       shalleng       \n  shallow         shallow         shallowest      shallowest     \n  shallowly       shallowli       shallows        shallow        \n  shalt           shalt           sham            sham           \n  shambles        shambl          shame           shame          \n  shamed          shame           shameful        shame          \n  shamefully      shamefulli      shameless       shameless      \n  shames          shame           shamest         shamest        \n  shaming         shame           shank           shank          \n  shanks          shank           shap            shap           \n  shape           shape           shaped          shape          \n  shapeless       shapeless       shapen          shapen         \n  shapes          shape           shaping         shape          \n  shar            shar            shard           shard          \n  sharded         shard           shards          shard          \n  share           share           shared          share          \n  sharers         sharer          shares          share          \n  sharing         share           shark           shark          \n  sharp           sharp           sharpen         sharpen        \n  sharpened       sharpen         sharpens        sharpen        \n  sharper         sharper         sharpest        sharpest       \n  sharply         sharpli         sharpness       sharp          \n  sharps          sharp           shatter         shatter        \n  shav            shav            shave           shave          \n  shaven          shaven          shaw            shaw           \n  she             she             sheaf           sheaf          \n  sheal           sheal           shear           shear          \n  shearers        shearer         shearing        shear          \n  shearman        shearman        shears          shear          \n  sheath          sheath          sheathe         sheath         \n  sheathed        sheath          sheathes        sheath         \n  sheathing       sheath          sheaved         sheav          \n  sheaves         sheav           shed            shed           \n  shedding        shed            sheds           shed           \n  sheen           sheen           sheep           sheep          \n  sheepcote       sheepcot        sheepcotes      sheepcot       \n  sheeps          sheep           sheepskins      sheepskin      \n  sheer           sheer           sheet           sheet          \n  sheeted         sheet           sheets          sheet          \n  sheffield       sheffield       shelf           shelf          \n  shell           shell           shells          shell          \n  shelt           shelt           shelter         shelter        \n  shelters        shelter         shelves         shelv          \n  shelving        shelv           shelvy          shelvi         \n  shent           shent           shepherd        shepherd       \n  shepherdes      shepherd        shepherdess     shepherdess    \n  shepherdesses   shepherdess     shepherds       shepherd       \n  sher            sher            sheriff         sheriff        \n  sherris         sherri          shes            she            \n  sheweth         sheweth         shield          shield         \n  shielded        shield          shields         shield         \n  shift           shift           shifted         shift          \n  shifting        shift           shifts          shift          \n  shilling        shill           shillings       shill          \n  shin            shin            shine           shine          \n  shines          shine           shineth         shineth        \n  shining         shine           shins           shin           \n  shiny           shini           ship            ship           \n  shipboard       shipboard       shipman         shipman        \n  shipmaster      shipmast        shipmen         shipmen        \n  shipp           shipp           shipped         ship           \n  shipping        ship            ships           ship           \n  shipt           shipt           shipwreck       shipwreck      \n  shipwrecking    shipwreck       shipwright      shipwright     \n  shipwrights     shipwright      shire           shire          \n  shirley         shirlei         shirt           shirt          \n  shirts          shirt           shive           shive          \n  shiver          shiver          shivering       shiver         \n  shivers         shiver          shoal           shoal          \n  shoals          shoal           shock           shock          \n  shocks          shock           shod            shod           \n  shoe            shoe            shoeing         shoe           \n  shoemaker       shoemak         shoes           shoe           \n  shog            shog            shone           shone          \n  shook           shook           shoon           shoon          \n  shoot           shoot           shooter         shooter        \n  shootie         shooti          shooting        shoot          \n  shoots          shoot           shop            shop           \n  shops           shop            shore           shore          \n  shores          shore           shorn           shorn          \n  short           short           shortcake       shortcak       \n  shorten         shorten         shortened       shorten        \n  shortens        shorten         shorter         shorter        \n  shortly         shortli         shortness       short          \n  shot            shot            shotten         shotten        \n  shoughs         shough          should          should         \n  shoulder        shoulder        shouldering     shoulder       \n  shoulders       shoulder        shouldst        shouldst       \n  shout           shout           shouted         shout          \n  shouting        shout           shouts          shout          \n  shov            shov            shove           shove          \n  shovel          shovel          shovels         shovel         \n  show            show            showed          show           \n  shower          shower          showers         shower         \n  showest         showest         showing         show           \n  shown           shown           shows           show           \n  shreds          shred           shrew           shrew          \n  shrewd          shrewd          shrewdly        shrewdli       \n  shrewdness      shrewd          shrewish        shrewish       \n  shrewishly      shrewishli      shrewishness    shrewish       \n  shrews          shrew           shrewsbury      shrewsburi     \n  shriek          shriek          shrieking       shriek         \n  shrieks         shriek          shrieve         shriev         \n  shrift          shrift          shrill          shrill         \n  shriller        shriller        shrills         shrill         \n  shrilly         shrilli         shrimp          shrimp         \n  shrine          shrine          shrink          shrink         \n  shrinking       shrink          shrinks         shrink         \n  shriv           shriv           shrive          shrive         \n  shriver         shriver         shrives         shrive         \n  shriving        shrive          shroud          shroud         \n  shrouded        shroud          shrouding       shroud         \n  shrouds         shroud          shrove          shrove         \n  shrow           shrow           shrows          shrow          \n  shrub           shrub           shrubs          shrub          \n  shrug           shrug           shrugs          shrug          \n  shrunk          shrunk          shudd           shudd          \n  shudders        shudder         shuffl          shuffl         \n  shuffle         shuffl          shuffled        shuffl         \n  shuffling       shuffl          shun            shun           \n  shunless        shunless        shunn           shunn          \n  shunned         shun            shunning        shun           \n  shuns           shun            shut            shut           \n  shuts           shut            shuttle         shuttl         \n  shy             shy             shylock         shylock        \n  si              si              sibyl           sibyl          \n  sibylla         sibylla         sibyls          sibyl          \n  sicil           sicil           sicilia         sicilia        \n  sicilian        sicilian        sicilius        siciliu        \n  sicils          sicil           sicily          sicili         \n  sicinius        siciniu         sick            sick           \n  sicken          sicken          sickens         sicken         \n  sicker          sicker          sickle          sickl          \n  sicklemen       sicklemen       sicklied        sickli         \n  sickliness      sickli          sickly          sickli         \n  sickness        sick            sicles          sicl           \n  sicyon          sicyon          side            side           \n  sided           side            sides           side           \n  siege           sieg            sieges          sieg           \n  sienna          sienna          sies            si             \n  sieve           siev            sift            sift           \n  sifted          sift            sigeia          sigeia         \n  sigh            sigh            sighed          sigh           \n  sighing         sigh            sighs           sigh           \n  sight           sight           sighted         sight          \n  sightless       sightless       sightly         sightli        \n  sights          sight           sign            sign           \n  signal          signal          signet          signet         \n  signieur        signieur        significant     signific       \n  significants    signific        signified       signifi        \n  signifies       signifi         signify         signifi        \n  signifying      signifi         signior         signior        \n  signiories      signiori        signiors        signior        \n  signiory        signiori        signor          signor         \n  signories       signori         signs           sign           \n  signum          signum          silenc          silenc         \n  silence         silenc          silenced        silenc         \n  silencing       silenc          silent          silent         \n  silently        silent          silius          siliu          \n  silk            silk            silken          silken         \n  silkman         silkman         silks           silk           \n  silliest        silliest        silliness       silli          \n  silling         sill            silly           silli          \n  silva           silva           silver          silver         \n  silvered        silver          silverly        silverli       \n  silvia          silvia          silvius         silviu         \n  sima            sima            simile          simil          \n  similes         simil           simois          simoi          \n  simon           simon           simony          simoni         \n  simp            simp            simpcox         simpcox        \n  simple          simpl           simpleness      simpl          \n  simpler         simpler         simples         simpl          \n  simplicity      simplic         simply          simpli         \n  simular         simular         simulation      simul          \n  sin             sin             since           sinc           \n  sincere         sincer          sincerely       sincer         \n  sincerity       sincer          sinel           sinel          \n  sinew           sinew           sinewed         sinew          \n  sinews          sinew           sinewy          sinewi         \n  sinful          sin             sinfully        sinfulli       \n  sing            sing            singe           sing           \n  singeing        sing            singer          singer         \n  singes          sing            singeth         singeth        \n  singing         sing            single          singl          \n  singled         singl           singleness      singl          \n  singly          singli          sings           sing           \n  singular        singular        singulariter    singularit     \n  singularities   singular        singularity     singular       \n  singuled        singul          sinister        sinist         \n  sink            sink            sinking         sink           \n  sinks           sink            sinn            sinn           \n  sinner          sinner          sinners         sinner         \n  sinning         sin             sinon           sinon          \n  sins            sin             sip             sip            \n  sipping         sip             sir             sir            \n  sire            sire            siren           siren          \n  sirrah          sirrah          sirs            sir            \n  sist            sist            sister          sister         \n  sisterhood      sisterhood      sisterly        sisterli       \n  sisters         sister          sit             sit            \n  sith            sith            sithence        sithenc        \n  sits            sit             sitting         sit            \n  situate         situat          situation       situat         \n  situations      situat          siward          siward         \n  six             six             sixpence        sixpenc        \n  sixpences       sixpenc         sixpenny        sixpenni       \n  sixteen         sixteen         sixth           sixth          \n  sixty           sixti           siz             siz            \n  size            size            sizes           size           \n  sizzle          sizzl           skains          skain          \n  skamble         skambl          skein           skein          \n  skelter         skelter         skies           ski            \n  skilful         skil            skilfully       skilfulli      \n  skill           skill           skilless        skilless       \n  skillet         skillet         skillful        skill          \n  skills          skill           skim            skim           \n  skimble         skimbl          skin            skin           \n  skinker         skinker         skinny          skinni         \n  skins           skin            skip            skip           \n  skipp           skipp           skipper         skipper        \n  skipping        skip            skirmish        skirmish       \n  skirmishes      skirmish        skirr           skirr          \n  skirted         skirt           skirts          skirt          \n  skittish        skittish        skulking        skulk          \n  skull           skull           skulls          skull          \n  sky             sky             skyey           skyei          \n  skyish          skyish          slab            slab           \n  slack           slack           slackly         slackli        \n  slackness       slack           slain           slain          \n  slake           slake           sland           sland          \n  slander         slander         slandered       slander        \n  slanderer       slander         slanderers      slander        \n  slandering      slander         slanderous      slander        \n  slanders        slander         slash           slash          \n  slaught         slaught         slaughter       slaughter      \n  slaughtered     slaughter       slaughterer     slaughter      \n  slaughterman    slaughterman    slaughtermen    slaughtermen   \n  slaughterous    slaughter       slaughters      slaughter      \n  slave           slave           slaver          slaver         \n  slavery         slaveri         slaves          slave          \n  slavish         slavish         slay            slai           \n  slayeth         slayeth         slaying         slai           \n  slays           slai            sleave          sleav          \n  sledded         sled            sleek           sleek          \n  sleekly         sleekli         sleep           sleep          \n  sleeper         sleeper         sleepers        sleeper        \n  sleepest        sleepest        sleeping        sleep          \n  sleeps          sleep           sleepy          sleepi         \n  sleeve          sleev           sleeves         sleev          \n  sleid           sleid           sleided         sleid          \n  sleight         sleight         sleights        sleight        \n  slender         slender         slenderer       slender        \n  slenderly       slenderli       slept           slept          \n  slew            slew            slewest         slewest        \n  slice           slice           slid            slid           \n  slide           slide           slides          slide          \n  sliding         slide           slight          slight         \n  slighted        slight          slightest       slightest      \n  slightly        slightli        slightness      slight         \n  slights         slight          slily           slili          \n  slime           slime           slimy           slimi          \n  slings          sling           slink           slink          \n  slip            slip            slipp           slipp          \n  slipper         slipper         slippers        slipper        \n  slippery        slipperi        slips           slip           \n  slish           slish           slit            slit           \n  sliver          sliver          slobb           slobb          \n  slomber         slomber         slop            slop           \n  slope           slope           slops           slop           \n  sloth           sloth           slothful        sloth          \n  slough          slough          slovenly        slovenli       \n  slovenry        slovenri        slow            slow           \n  slower          slower          slowly          slowli         \n  slowness        slow            slubber         slubber        \n  slug            slug            sluggard        sluggard       \n  sluggardiz      sluggardiz      sluggish        sluggish       \n  sluic           sluic           slumb           slumb          \n  slumber         slumber         slumbers        slumber        \n  slumbery        slumberi        slunk           slunk          \n  slut            slut            sluts           slut           \n  sluttery        slutteri        sluttish        sluttish       \n  sluttishness    sluttish        sly             sly            \n  slys            sly             smack           smack          \n  smacking        smack           smacks          smack          \n  small           small           smaller         smaller        \n  smallest        smallest        smallness       small          \n  smalus          smalu           smart           smart          \n  smarting        smart           smartly         smartli        \n  smatch          smatch          smatter         smatter        \n  smear           smear           smell           smell          \n  smelling        smell           smells          smell          \n  smelt           smelt           smil            smil           \n  smile           smile           smiled          smile          \n  smiles          smile           smilest         smilest        \n  smilets         smilet          smiling         smile          \n  smilingly       smilingli       smirch          smirch         \n  smirched        smirch          smit            smit           \n  smite           smite           smites          smite          \n  smith           smith           smithfield      smithfield     \n  smock           smock           smocks          smock          \n  smok            smok            smoke           smoke          \n  smoked          smoke           smokes          smoke          \n  smoking         smoke           smoky           smoki          \n  smooth          smooth          smoothed        smooth         \n  smoothing       smooth          smoothly        smoothli       \n  smoothness      smooth          smooths         smooth         \n  smote           smote           smoth           smoth          \n  smother         smother         smothered       smother        \n  smothering      smother         smug            smug           \n  smulkin         smulkin         smutch          smutch         \n  snaffle         snaffl          snail           snail          \n  snails          snail           snake           snake          \n  snakes          snake           snaky           snaki          \n  snap            snap            snapp           snapp          \n  snapper         snapper         snar            snar           \n  snare           snare           snares          snare          \n  snarl           snarl           snarleth        snarleth       \n  snarling        snarl           snatch          snatch         \n  snatchers       snatcher        snatches        snatch         \n  snatching       snatch          sneak           sneak          \n  sneaking        sneak           sneap           sneap          \n  sneaping        sneap           sneck           sneck          \n  snip            snip            snipe           snipe          \n  snipt           snipt           snore           snore          \n  snores          snore           snoring         snore          \n  snorting        snort           snout           snout          \n  snow            snow            snowballs       snowbal        \n  snowed          snow            snowy           snowi          \n  snuff           snuff           snuffs          snuff          \n  snug            snug            so              so             \n  soak            soak            soaking         soak           \n  soaks           soak            soar            soar           \n  soaring         soar            soars           soar           \n  sob             sob             sobbing         sob            \n  sober           sober           soberly         soberli        \n  sobriety        sobrieti        sobs            sob            \n  sociable        sociabl         societies       societi        \n  society         societi         socks           sock           \n  socrates        socrat          sod             sod            \n  sodden          sodden          soe             soe            \n  soever          soever          soft            soft           \n  soften          soften          softens         soften         \n  softer          softer          softest         softest        \n  softly          softli          softness        soft           \n  soil            soil            soiled          soil           \n  soilure         soilur          soit            soit           \n  sojourn         sojourn         sol             sol            \n  sola            sola            solace          solac          \n  solanio         solanio         sold            sold           \n  soldat          soldat          solder          solder         \n  soldest         soldest         soldier         soldier        \n  soldiers        soldier         soldiership     soldiership    \n  sole            sole            solely          sole           \n  solem           solem           solemn          solemn         \n  solemness       solem           solemnities     solemn         \n  solemnity       solemn          solemniz        solemniz       \n  solemnize       solemn          solemnized      solemn         \n  solemnly        solemnli        soles           sole           \n  solicit         solicit         solicitation    solicit        \n  solicited       solicit         soliciting      solicit        \n  solicitings     solicit         solicitor       solicitor      \n  solicits        solicit         solid           solid          \n  solidares       solidar         solidity        solid          \n  solinus         solinu          solitary        solitari       \n  solomon         solomon         solon           solon          \n  solum           solum           solus           solu           \n  solyman         solyman         some            some           \n  somebody        somebodi        someone         someon         \n  somerset        somerset        somerville      somervil       \n  something       someth          sometime        sometim        \n  sometimes       sometim         somever         somev          \n  somewhat        somewhat        somewhere       somewher       \n  somewhither     somewhith       somme           somm           \n  son             son             sonance         sonanc         \n  song            song            songs           song           \n  sonnet          sonnet          sonneting       sonnet         \n  sonnets         sonnet          sons            son            \n  sont            sont            sonties         sonti          \n  soon            soon            sooner          sooner         \n  soonest         soonest         sooth           sooth          \n  soothe          sooth           soothers        soother        \n  soothing        sooth           soothsay        soothsai       \n  soothsayer      soothsay        sooty           sooti          \n  sop             sop             sophister       sophist        \n  sophisticated   sophist         sophy           sophi          \n  sops            sop             sorcerer        sorcer         \n  sorcerers       sorcer          sorceress       sorceress      \n  sorceries       sorceri         sorcery         sorceri        \n  sore            sore            sorel           sorel          \n  sorely          sore            sorer           sorer          \n  sores           sore            sorrier         sorrier        \n  sorriest        sorriest        sorrow          sorrow         \n  sorrowed        sorrow          sorrowest       sorrowest      \n  sorrowful       sorrow          sorrowing       sorrow         \n  sorrows         sorrow          sorry           sorri          \n  sort            sort            sortance        sortanc        \n  sorted          sort            sorting         sort           \n  sorts           sort            sossius         sossiu         \n  sot             sot             soto            soto           \n  sots            sot             sottish         sottish        \n  soud            soud            sought          sought         \n  soul            soul            sould           sould          \n  soulless        soulless        souls           soul           \n  sound           sound           sounded         sound          \n  sounder         sounder         soundest        soundest       \n  sounding        sound           soundless       soundless      \n  soundly         soundli         soundness       sound          \n  soundpost       soundpost       sounds          sound          \n  sour            sour            source          sourc          \n  sources         sourc           sourest         sourest        \n  sourly          sourli          sours           sour           \n  sous            sou             souse           sous           \n  south           south           southam         southam        \n  southampton     southampton     southerly       southerli      \n  southern        southern        southward       southward      \n  southwark       southwark       southwell       southwel       \n  souviendrai     souviendrai     sov             sov            \n  sovereign       sovereign       sovereignest    sovereignest   \n  sovereignly     sovereignli     sovereignty     sovereignti    \n  sovereignvours  sovereignvour   sow             sow            \n  sowing          sow             sowl            sowl           \n  sowter          sowter          space           space          \n  spaces          space           spacious        spaciou        \n  spade           spade           spades          spade          \n  spain           spain           spak            spak           \n  spake           spake           spakest         spakest        \n  span            span            spangle         spangl         \n  spangled        spangl          spaniard        spaniard       \n  spaniel         spaniel         spaniels        spaniel        \n  spanish         spanish         spann           spann          \n  spans           span            spar            spar           \n  spare           spare           spares          spare          \n  sparing         spare           sparingly       sparingli      \n  spark           spark           sparkle         sparkl         \n  sparkles        sparkl          sparkling       sparkl         \n  sparks          spark           sparrow         sparrow        \n  sparrows        sparrow         sparta          sparta         \n  spartan         spartan         spavin          spavin         \n  spavins         spavin          spawn           spawn          \n  speak           speak           speaker         speaker        \n  speakers        speaker         speakest        speakest       \n  speaketh        speaketh        speaking        speak          \n  speaks          speak           spear           spear          \n  speargrass      speargrass      spears          spear          \n  special         special         specialities    special        \n  specially       special         specialties     specialti      \n  specialty       specialti       specify         specifi        \n  speciously      specious        spectacle       spectacl       \n  spectacled      spectacl        spectacles      spectacl       \n  spectators      spectat         spectatorship   spectatorship  \n  speculation     specul          speculations    specul         \n  speculative     specul          sped            sped           \n  speech          speech          speeches        speech         \n  speechless      speechless      speed           speed          \n  speeded         speed           speedier        speedier       \n  speediest       speediest       speedily        speedili       \n  speediness      speedi          speeding        speed          \n  speeds          speed           speedy          speedi         \n  speens          speen           spell           spell          \n  spelling        spell           spells          spell          \n  spelt           spelt           spencer         spencer        \n  spend           spend           spendest        spendest       \n  spending        spend           spends          spend          \n  spendthrift     spendthrift     spent           spent          \n  sperato         sperato         sperm           sperm          \n  spero           spero           sperr           sperr          \n  spher           spher           sphere          sphere         \n  sphered         sphere          spheres         sphere         \n  spherical       spheric         sphery          spheri         \n  sphinx          sphinx          spice           spice          \n  spiced          spice           spicery         spiceri        \n  spices          spice           spider          spider         \n  spiders         spider          spied           spi            \n  spies           spi             spieth          spieth         \n  spightfully     spightfulli     spigot          spigot         \n  spill           spill           spilling        spill          \n  spills          spill           spilt           spilt          \n  spilth          spilth          spin            spin           \n  spinii          spinii          spinners        spinner        \n  spinster        spinster        spinsters       spinster       \n  spire           spire           spirit          spirit         \n  spirited        spirit          spiritless      spiritless     \n  spirits         spirit          spiritual       spiritu        \n  spiritualty     spiritualti     spirt           spirt          \n  spit            spit            spital          spital         \n  spite           spite           spited          spite          \n  spiteful        spite           spites          spite          \n  spits           spit            spitted         spit           \n  spitting        spit            splay           splai          \n  spleen          spleen          spleenful       spleen         \n  spleens         spleen          spleeny         spleeni        \n  splendour       splendour       splenitive      splenit        \n  splinter        splinter        splinters       splinter       \n  split           split           splits          split          \n  splitted        split           splitting       split          \n  spoil           spoil           spoils          spoil          \n  spok            spok            spoke           spoke          \n  spoken          spoken          spokes          spoke          \n  spokesman       spokesman       sponge          spong          \n  spongy          spongi          spoon           spoon          \n  spoons          spoon           sport           sport          \n  sportful        sport           sporting        sport          \n  sportive        sportiv         sports          sport          \n  spot            spot            spotless        spotless       \n  spots           spot            spotted         spot           \n  spousal         spousal         spouse          spous          \n  spout           spout           spouting        spout          \n  spouts          spout           sprag           sprag          \n  sprang          sprang          sprat           sprat          \n  sprawl          sprawl          spray           sprai          \n  sprays          sprai           spread          spread         \n  spreading       spread          spreads         spread         \n  sprighted       spright         sprightful      spright        \n  sprightly       sprightli       sprigs          sprig          \n  spring          spring          springe         spring         \n  springes        spring          springeth       springeth      \n  springhalt      springhalt      springing       spring         \n  springs         spring          springtime      springtim      \n  sprinkle        sprinkl         sprinkles       sprinkl        \n  sprite          sprite          sprited         sprite         \n  spritely        sprite          sprites         sprite         \n  spriting        sprite          sprout          sprout         \n  spruce          spruce          sprung          sprung         \n  spun            spun            spur            spur           \n  spurio          spurio          spurn           spurn          \n  spurns          spurn           spurr           spurr          \n  spurrer         spurrer         spurring        spur           \n  spurs           spur            spy             spy            \n  spying          spy             squabble        squabbl        \n  squadron        squadron        squadrons       squadron       \n  squand          squand          squar           squar          \n  square          squar           squarer         squarer        \n  squares         squar           squash          squash         \n  squeak          squeak          squeaking       squeak         \n  squeal          squeal          squealing       squeal         \n  squeezes        squeez          squeezing       squeez         \n  squele          squel           squier          squier         \n  squints         squint          squiny          squini         \n  squire          squir           squires         squir          \n  squirrel        squirrel        st              st             \n  stab            stab            stabb           stabb          \n  stabbed         stab            stabbing        stab           \n  stable          stabl           stableness      stabl          \n  stables         stabl           stablish        stablish       \n  stablishment    stablish        stabs           stab           \n  stacks          stack           staff           staff          \n  stafford        stafford        staffords       stafford       \n  staffordshire   staffordshir    stag            stag           \n  stage           stage           stages          stage          \n  stagger         stagger         staggering      stagger        \n  staggers        stagger         stags           stag           \n  staid           staid           staider         staider        \n  stain           stain           stained         stain          \n  staines         stain           staineth        staineth       \n  staining        stain           stainless       stainless      \n  stains          stain           stair           stair          \n  stairs          stair           stake           stake          \n  stakes          stake           stale           stale          \n  staled          stale           stalk           stalk          \n  stalking        stalk           stalks          stalk          \n  stall           stall           stalling        stall          \n  stalls          stall           stamford        stamford       \n  stammer         stammer         stamp           stamp          \n  stamped         stamp           stamps          stamp          \n  stanch          stanch          stanchless      stanchless     \n  stand           stand           standard        standard       \n  standards       standard        stander         stander        \n  standers        stander         standest        standest       \n  standeth        standeth        standing        stand          \n  stands          stand           staniel         staniel        \n  stanley         stanlei         stanze          stanz          \n  stanzo          stanzo          stanzos         stanzo         \n  staple          stapl           staples         stapl          \n  star            star            stare           stare          \n  stared          stare           stares          stare          \n  staring         stare           starings        stare          \n  stark           stark           starkly         starkli        \n  starlight       starlight       starling        starl          \n  starr           starr           starry          starri         \n  stars           star            start           start          \n  started         start           starting        start          \n  startingly      startingli      startle         startl         \n  startles        startl          starts          start          \n  starv           starv           starve          starv          \n  starved         starv           starvelackey    starvelackei   \n  starveling      starvel         starveth        starveth       \n  starving        starv           state           state          \n  statelier       stateli         stately         state          \n  states          state           statesman       statesman      \n  statesmen       statesmen       statilius       statiliu       \n  station         station         statist         statist        \n  statists        statist         statue          statu          \n  statues         statu           stature         statur         \n  statures        statur          statute         statut         \n  statutes        statut          stave           stave          \n  staves          stave           stay            stai           \n  stayed          stai            stayest         stayest        \n  staying         stai            stays           stai           \n  stead           stead           steaded         stead          \n  steadfast       steadfast       steadier        steadier       \n  steads          stead           steal           steal          \n  stealer         stealer         stealers        stealer        \n  stealing        steal           steals          steal          \n  stealth         stealth         stealthy        stealthi       \n  steed           steed           steeds          steed          \n  steel           steel           steeled         steel          \n  steely          steeli          steep           steep          \n  steeped         steep           steeple         steepl         \n  steeples        steepl          steeps          steep          \n  steepy          steepi          steer           steer          \n  steerage        steerag         steering        steer          \n  steers          steer           stelled         stell          \n  stem            stem            stemming        stem           \n  stench          stench          step            step           \n  stepdame        stepdam         stephano        stephano       \n  stephen         stephen         stepmothers     stepmoth       \n  stepp           stepp           stepping        step           \n  steps           step            sterile         steril         \n  sterility       steril          sterling        sterl          \n  stern           stern           sternage        sternag        \n  sterner         sterner         sternest        sternest       \n  sternness       stern           steterat        steterat       \n  stew            stew            steward         steward        \n  stewards        steward         stewardship     stewardship    \n  stewed          stew            stews           stew           \n  stick           stick           sticking        stick          \n  stickler        stickler        sticks          stick          \n  stiff           stiff           stiffen         stiffen        \n  stiffly         stiffli         stifle          stifl          \n  stifled         stifl           stifles         stifl          \n  stigmatic       stigmat         stigmatical     stigmat        \n  stile           stile           still           still          \n  stiller         stiller         stillest        stillest       \n  stillness       still           stilly          stilli         \n  sting           sting           stinging        sting          \n  stingless       stingless       stings          sting          \n  stink           stink           stinking        stink          \n  stinkingly      stinkingli      stinks          stink          \n  stint           stint           stinted         stint          \n  stints          stint           stir            stir           \n  stirr           stirr           stirred         stir           \n  stirrer         stirrer         stirrers        stirrer        \n  stirreth        stirreth        stirring        stir           \n  stirrup         stirrup         stirrups        stirrup        \n  stirs           stir            stitchery       stitcheri      \n  stitches        stitch          stithied        stithi         \n  stithy          stithi          stoccadoes      stoccado       \n  stoccata        stoccata        stock           stock          \n  stockfish       stockfish       stocking        stock          \n  stockings       stock           stockish        stockish       \n  stocks          stock           stog            stog           \n  stogs           stog            stoics          stoic          \n  stokesly        stokesli        stol            stol           \n  stole           stole           stolen          stolen         \n  stolest         stolest         stomach         stomach        \n  stomachers      stomach         stomaching      stomach        \n  stomachs        stomach         ston            ston           \n  stone           stone           stonecutter     stonecutt      \n  stones          stone           stonish         stonish        \n  stony           stoni           stood           stood          \n  stool           stool           stools          stool          \n  stoop           stoop           stooping        stoop          \n  stoops          stoop           stop            stop           \n  stope           stope           stopp           stopp          \n  stopped         stop            stopping        stop           \n  stops           stop            stor            stor           \n  store           store           storehouse      storehous      \n  storehouses     storehous       stores          store          \n  stories         stori           storm           storm          \n  stormed         storm           storming        storm          \n  storms          storm           stormy          stormi         \n  story           stori           stoup           stoup          \n  stoups          stoup           stout           stout          \n  stouter         stouter         stoutly         stoutli        \n  stoutness       stout           stover          stover         \n  stow            stow            stowage         stowag         \n  stowed          stow            strachy         strachi        \n  stragglers      straggler       straggling      straggl        \n  straight        straight        straightest     straightest    \n  straightway     straightwai     strain          strain         \n  strained        strain          straining       strain         \n  strains         strain          strait          strait         \n  straited        strait          straiter        straiter       \n  straitly        straitli        straitness      strait         \n  straits         strait          strand          strand         \n  strange         strang          strangely       strang         \n  strangeness     strang          stranger        stranger       \n  strangers       stranger        strangest       strangest      \n  strangle        strangl         strangled       strangl        \n  strangler       strangler       strangles       strangl        \n  strangling      strangl         strappado       strappado      \n  straps          strap           stratagem       stratagem      \n  stratagems      stratagem       stratford       stratford      \n  strato          strato          straw           straw          \n  strawberries    strawberri      strawberry      strawberri     \n  straws          straw           strawy          strawi         \n  stray           strai           straying        strai          \n  strays          strai           streak          streak         \n  streaks         streak          stream          stream         \n  streamers       streamer        streaming       stream         \n  streams         stream          streching       strech         \n  street          street          streets         street         \n  strength        strength        strengthen      strengthen     \n  strengthened    strengthen      strengthless    strengthless   \n  strengths       strength        stretch         stretch        \n  stretched       stretch         stretches       stretch        \n  stretching      stretch         strew           strew          \n  strewing        strew           strewings       strew          \n  strewments      strewment       stricken        stricken       \n  strict          strict          stricter        stricter       \n  strictest       strictest       strictly        strictli       \n  stricture       strictur        stride          stride         \n  strides         stride          striding        stride         \n  strife          strife          strifes         strife         \n  strik           strik           strike          strike         \n  strikers        striker         strikes         strike         \n  strikest        strikest        striking        strike         \n  string          string          stringless      stringless     \n  strings         string          strip           strip          \n  stripes         stripe          stripling       stripl         \n  striplings      stripl          stripp          stripp         \n  stripping       strip           striv           striv          \n  strive          strive          strives         strive         \n  striving        strive          strok           strok          \n  stroke          stroke          strokes         stroke         \n  strond          strond          stronds         strond         \n  strong          strong          stronger        stronger       \n  strongest       strongest       strongly        strongli       \n  strooke         strook          strossers       strosser       \n  strove          strove          strown          strown         \n  stroy           stroi           struck          struck         \n  strucken        strucken        struggle        struggl        \n  struggles       struggl         struggling      struggl        \n  strumpet        strumpet        strumpeted      strumpet       \n  strumpets       strumpet        strung          strung         \n  strut           strut           struts          strut          \n  strutted        strut           strutting       strut          \n  stubble         stubbl          stubborn        stubborn       \n  stubbornest     stubbornest     stubbornly      stubbornli     \n  stubbornness    stubborn        stuck           stuck          \n  studded         stud            student         student        \n  students        student         studied         studi          \n  studies         studi           studious        studiou        \n  studiously      studious        studs           stud           \n  study           studi           studying        studi          \n  stuff           stuff           stuffing        stuf           \n  stuffs          stuff           stumble         stumbl         \n  stumbled        stumbl          stumblest       stumblest      \n  stumbling       stumbl          stump           stump          \n  stumps          stump           stung           stung          \n  stupefy         stupefi         stupid          stupid         \n  stupified       stupifi         stuprum         stuprum        \n  sturdy          sturdi          sty             sty            \n  styga           styga           stygian         stygian        \n  styl            styl            style           style          \n  styx            styx            su              su             \n  sub             sub             subcontracted   subcontract    \n  subdu           subdu           subdue          subdu          \n  subdued         subdu           subduements     subduement     \n  subdues         subdu           subduing        subdu          \n  subject         subject         subjected       subject        \n  subjection      subject         subjects        subject        \n  submerg         submerg         submission      submiss        \n  submissive      submiss         submit          submit         \n  submits         submit          submitting      submit         \n  suborn          suborn          subornation     suborn         \n  suborned        suborn          subscrib        subscrib       \n  subscribe       subscrib        subscribed      subscrib       \n  subscribes      subscrib        subscription    subscript      \n  subsequent      subsequ         subsidies       subsidi        \n  subsidy         subsidi         subsist         subsist        \n  subsisting      subsist         substance       substanc       \n  substances      substanc        substantial     substanti      \n  substitute      substitut       substituted     substitut      \n  substitutes     substitut       substitution    substitut      \n  subtile         subtil          subtilly        subtilli       \n  subtle          subtl           subtleties      subtleti       \n  subtlety        subtleti        subtly          subtli         \n  subtractors     subtractor      suburbs         suburb         \n  subversion      subvers         subverts        subvert        \n  succedant       succed          succeed         succe          \n  succeeded       succeed         succeeders      succeed        \n  succeeding      succeed         succeeds        succe          \n  success         success         successantly    successantli   \n  successes       success         successful      success        \n  successfully    successfulli    succession      success        \n  successive      success         successively    success        \n  successor       successor       successors      successor      \n  succour         succour         succours        succour        \n  such            such            suck            suck           \n  sucker          sucker          suckers         sucker         \n  sucking         suck            suckle          suckl          \n  sucks           suck            sudden          sudden         \n  suddenly        suddenli        sue             sue            \n  sued            su              suerly          suerli         \n  sues            sue             sueth           sueth          \n  suff            suff            suffer          suffer         \n  sufferance      suffer          sufferances     suffer         \n  suffered        suffer          suffering       suffer         \n  suffers         suffer          suffic          suffic         \n  suffice         suffic          sufficed        suffic         \n  suffices        suffic          sufficeth       sufficeth      \n  sufficiency     suffici         sufficient      suffici        \n  sufficiently    suffici         sufficing       suffic         \n  sufficit        sufficit        suffigance      suffig         \n  suffocate       suffoc          suffocating     suffoc         \n  suffocation     suffoc          suffolk         suffolk        \n  suffrage        suffrag         suffrages       suffrag        \n  sug             sug             sugar           sugar          \n  sugarsop        sugarsop        suggest         suggest        \n  suggested       suggest         suggesting      suggest        \n  suggestion      suggest         suggestions     suggest        \n  suggests        suggest         suis            sui            \n  suit            suit            suitable        suitabl        \n  suited          suit            suiting         suit           \n  suitor          suitor          suitors         suitor         \n  suits           suit            suivez          suivez         \n  sullen          sullen          sullens         sullen         \n  sullied         sulli           sullies         sulli          \n  sully           sulli           sulph           sulph          \n  sulpherous      sulpher         sulphur         sulphur        \n  sulphurous      sulphur         sultan          sultan         \n  sultry          sultri          sum             sum            \n  sumless         sumless         summ            summ           \n  summa           summa           summary         summari        \n  summer          summer          summers         summer         \n  summit          summit          summon          summon         \n  summoners       summon          summons         summon         \n  sumpter         sumpter         sumptuous       sumptuou       \n  sumptuously     sumptuous       sums            sum            \n  sun             sun             sunbeams        sunbeam        \n  sunburning      sunburn         sunburnt        sunburnt       \n  sund            sund            sunday          sundai         \n  sundays         sundai          sunder          sunder         \n  sunders         sunder          sundry          sundri         \n  sung            sung            sunk            sunk           \n  sunken          sunken          sunny           sunni          \n  sunrising       sunris          suns            sun            \n  sunset          sunset          sunshine        sunshin        \n  sup             sup             super           super          \n  superficial     superfici       superficially   superfici      \n  superfluity     superflu        superfluous     superflu       \n  superfluously   superflu        superflux       superflux      \n  superior        superior        supernal        supern         \n  supernatural    supernatur      superpraise     superprais     \n  superscript     superscript     superscription  superscript    \n  superserviceable superservic     superstition    superstit      \n  superstitious   superstiti      superstitiously superstiti     \n  supersubtle     supersubtl      supervise       supervis       \n  supervisor      supervisor      supp            supp           \n  supper          supper          suppers         supper         \n  suppertime      suppertim       supping         sup            \n  supplant        supplant        supple          suppl          \n  suppler         suppler         suppliance      supplianc      \n  suppliant       suppliant       suppliants      suppliant      \n  supplicant      supplic         supplication    supplic        \n  supplications   supplic         supplie         suppli         \n  supplied        suppli          supplies        suppli         \n  suppliest       suppliest       supply          suppli         \n  supplyant       supplyant       supplying       suppli         \n  supplyment      supplyment      support         support        \n  supportable     support         supportance     support        \n  supported       support         supporter       support        \n  supporters      support         supporting      support        \n  supportor       supportor       suppos          suppo          \n  supposal        suppos          suppose         suppos         \n  supposed        suppos          supposes        suppos         \n  supposest       supposest       supposing       suppos         \n  supposition     supposit        suppress        suppress       \n  suppressed      suppress        suppresseth     suppresseth    \n  supremacy       supremaci       supreme         suprem         \n  sups            sup             sur             sur            \n  surance         suranc          surcease        surceas        \n  surd            surd            sure            sure           \n  surecard        surecard        surely          sure           \n  surer           surer           surest          surest         \n  sureties        sureti          surety          sureti         \n  surfeit         surfeit         surfeited       surfeit        \n  surfeiter       surfeit         surfeiting      surfeit        \n  surfeits        surfeit         surge           surg           \n  surgeon         surgeon         surgeons        surgeon        \n  surgere         surger          surgery         surgeri        \n  surges          surg            surly           surli          \n  surmis          surmi           surmise         surmis         \n  surmised        surmis          surmises        surmis         \n  surmount        surmount        surmounted      surmount       \n  surmounts       surmount        surnam          surnam         \n  surname         surnam          surnamed        surnam         \n  surpasseth      surpasseth      surpassing      surpass        \n  surplice        surplic         surplus         surplu         \n  surpris         surpri          surprise        surpris        \n  surprised       surpris         surrender       surrend        \n  surrey          surrei          surreys         surrei         \n  survey          survei          surveyest       surveyest      \n  surveying       survei          surveyor        surveyor       \n  surveyors       surveyor        surveys         survei         \n  survive         surviv          survives        surviv         \n  survivor        survivor        susan           susan          \n  suspect         suspect         suspected       suspect        \n  suspecting      suspect         suspects        suspect        \n  suspend         suspend         suspense        suspens        \n  suspicion       suspicion       suspicions      suspicion      \n  suspicious      suspici         suspiration     suspir         \n  suspire         suspir          sust            sust           \n  sustain         sustain         sustaining      sustain        \n  sutler          sutler          sutton          sutton         \n  suum            suum            swabber         swabber        \n  swaddling       swaddl          swag            swag           \n  swagg           swagg           swagger         swagger        \n  swaggerer       swagger         swaggerers      swagger        \n  swaggering      swagger         swain           swain          \n  swains          swain           swallow         swallow        \n  swallowed       swallow         swallowing      swallow        \n  swallows        swallow         swam            swam           \n  swan            swan            swans           swan           \n  sward           sward           sware           sware          \n  swarm           swarm           swarming        swarm          \n  swart           swart           swarth          swarth         \n  swarths         swarth          swarthy         swarthi        \n  swashers        swasher         swashing        swash          \n  swath           swath           swathing        swath          \n  swathling       swathl          sway            swai           \n  swaying         swai            sways           swai           \n  swear           swear           swearer         swearer        \n  swearers        swearer         swearest        swearest       \n  swearing        swear           swearings       swear          \n  swears          swear           sweat           sweat          \n  sweaten         sweaten         sweating        sweat          \n  sweats          sweat           sweaty          sweati         \n  sweep           sweep           sweepers        sweeper        \n  sweeps          sweep           sweet           sweet          \n  sweeten         sweeten         sweetens        sweeten        \n  sweeter         sweeter         sweetest        sweetest       \n  sweetheart      sweetheart      sweeting        sweet          \n  sweetly         sweetli         sweetmeats      sweetmeat      \n  sweetness       sweet           sweets          sweet          \n  swell           swell           swelling        swell          \n  swellings       swell           swells          swell          \n  swelter         swelter         sweno           sweno          \n  swept           swept           swerve          swerv          \n  swerver         swerver         swerving        swerv          \n  swift           swift           swifter         swifter        \n  swiftest        swiftest        swiftly         swiftli        \n  swiftness       swift           swill           swill          \n  swills          swill           swim            swim           \n  swimmer         swimmer         swimmers        swimmer        \n  swimming        swim            swims           swim           \n  swine           swine           swineherds      swineherd      \n  swing           swing           swinge          swing          \n  swinish         swinish         swinstead       swinstead      \n  switches        switch          swits           swit           \n  switzers        switzer         swol            swol           \n  swoll           swoll           swoln           swoln          \n  swoon           swoon           swooned         swoon          \n  swooning        swoon           swoons          swoon          \n  swoop           swoop           swoopstake      swoopstak      \n  swor            swor            sword           sword          \n  sworder         sworder         swords          sword          \n  swore           swore           sworn           sworn          \n  swounded        swound          swounds         swound         \n  swum            swum            swung           swung          \n  sy              sy              sycamore        sycamor        \n  sycorax         sycorax         sylla           sylla          \n  syllable        syllabl         syllables       syllabl        \n  syllogism       syllog          symbols         symbol         \n  sympathise      sympathis       sympathiz       sympathiz      \n  sympathize      sympath         sympathized     sympath        \n  sympathy        sympathi        synagogue       synagogu       \n  synod           synod           synods          synod          \n  syracuse        syracus         syracusian      syracusian     \n  syracusians     syracusian      syria           syria          \n  syrups          syrup           t               t              \n  ta              ta              taber           taber          \n  table           tabl            tabled          tabl           \n  tables          tabl            tablet          tablet         \n  tabor           tabor           taborer         tabor          \n  tabors          tabor           tabourines      tabourin       \n  taciturnity     taciturn        tack            tack           \n  tackle          tackl           tackled         tackl          \n  tackles         tackl           tackling        tackl          \n  tacklings       tackl           taddle          taddl          \n  tadpole         tadpol          taffeta         taffeta        \n  taffety         taffeti         tag             tag            \n  tagrag          tagrag          tah             tah            \n  tail            tail            tailor          tailor         \n  tailors         tailor          tails           tail           \n  taint           taint           tainted         taint          \n  tainting        taint           taints          taint          \n  tainture        taintur         tak             tak            \n  take            take            taken           taken          \n  taker           taker           takes           take           \n  takest          takest          taketh          taketh         \n  taking          take            tal             tal            \n  talbot          talbot          talbotites      talbotit       \n  talbots         talbot          tale            tale           \n  talent          talent          talents         talent         \n  taleporter      taleport        tales           tale           \n  talk            talk            talked          talk           \n  talker          talker          talkers         talker         \n  talkest         talkest         talking         talk           \n  talks           talk            tall            tall           \n  taller          taller          tallest         tallest        \n  tallies         talli           tallow          tallow         \n  tally           talli           talons          talon          \n  tam             tam             tambourines     tambourin      \n  tame            tame            tamed           tame           \n  tamely          tame            tameness        tame           \n  tamer           tamer           tames           tame           \n  taming          tame            tamora          tamora         \n  tamworth        tamworth        tan             tan            \n  tang            tang            tangle          tangl          \n  tangled         tangl           tank            tank           \n  tanlings        tanl            tann            tann           \n  tanned          tan             tanner          tanner         \n  tanquam         tanquam         tanta           tanta          \n  tantaene        tantaen         tap             tap            \n  tape            tape            taper           taper          \n  tapers          taper           tapestries      tapestri       \n  tapestry        tapestri        taphouse        taphous        \n  tapp            tapp            tapster         tapster        \n  tapsters        tapster         tar             tar            \n  tardied         tardi           tardily         tardili        \n  tardiness       tardi           tardy           tardi          \n  tarentum        tarentum        targe           targ           \n  targes          targ            target          target         \n  targets         target          tarpeian        tarpeian       \n  tarquin         tarquin         tarquins        tarquin        \n  tarr            tarr            tarre           tarr           \n  tarriance       tarrianc        tarried         tarri          \n  tarries         tarri           tarry           tarri          \n  tarrying        tarri           tart            tart           \n  tartar          tartar          tartars         tartar         \n  tartly          tartli          tartness        tart           \n  task            task            tasker          tasker         \n  tasking         task            tasks           task           \n  tassel          tassel          taste           tast           \n  tasted          tast            tastes          tast           \n  tasting         tast            tatt            tatt           \n  tatter          tatter          tattered        tatter         \n  tatters         tatter          tattle          tattl          \n  tattling        tattl           tattlings       tattl          \n  taught          taught          taunt           taunt          \n  taunted         taunt           taunting        taunt          \n  tauntingly      tauntingli      taunts          taunt          \n  taurus          tauru           tavern          tavern         \n  taverns         tavern          tavy            tavi           \n  tawdry          tawdri          tawny           tawni          \n  tax             tax             taxation        taxat          \n  taxations       taxat           taxes           tax            \n  taxing          tax             tc              tc             \n  te              te              teach           teach          \n  teacher         teacher         teachers        teacher        \n  teaches         teach           teachest        teachest       \n  teacheth        teacheth        teaching        teach          \n  team            team            tear            tear           \n  tearful         tear            tearing         tear           \n  tears           tear            tearsheet       tearsheet      \n  teat            teat            tedious         tediou         \n  tediously       tedious         tediousness     tedious        \n  teem            teem            teeming         teem           \n  teems           teem            teen            teen           \n  teeth           teeth           teipsum         teipsum        \n  telamon         telamon         telamonius      telamoniu      \n  tell            tell            teller          teller         \n  telling         tell            tells           tell           \n  tellus          tellu           temp            temp           \n  temper          temper          temperality     temper         \n  temperance      temper          temperate       temper         \n  temperately     temper          tempers         temper         \n  tempest         tempest         tempests        tempest        \n  tempestuous     tempestu        temple          templ          \n  temples         templ           temporal        tempor         \n  temporary       temporari       temporiz        temporiz       \n  temporize       tempor          temporizer      tempor         \n  temps           temp            tempt           tempt          \n  temptation      temptat         temptations     temptat        \n  tempted         tempt           tempter         tempter        \n  tempters        tempter         tempteth        tempteth       \n  tempting        tempt           tempts          tempt          \n  ten             ten             tenable         tenabl         \n  tenant          tenant          tenantius       tenantiu       \n  tenantless      tenantless      tenants         tenant         \n  tench           tench           tend            tend           \n  tendance        tendanc         tended          tend           \n  tender          tender          tendered        tender         \n  tenderly        tenderli        tenderness      tender         \n  tenders         tender          tending         tend           \n  tends           tend            tenedos         tenedo         \n  tenement        tenement        tenements       tenement       \n  tenfold         tenfold         tennis          tenni          \n  tenour          tenour          tenours         tenour         \n  tens            ten             tent            tent           \n  tented          tent            tenth           tenth          \n  tenths          tenth           tents           tent           \n  tenure          tenur           tenures         tenur          \n  tercel          tercel          tereus          tereu          \n  term            term            termagant       termag         \n  termed          term            terminations    termin         \n  termless        termless        terms           term           \n  terra           terra           terrace         terrac         \n  terram          terram          terras          terra          \n  terre           terr            terrene         terren         \n  terrestrial     terrestri       terrible        terribl        \n  terribly        terribl         territories     territori      \n  territory       territori       terror          terror         \n  terrors         terror          tertian         tertian        \n  tertio          tertio          test            test           \n  testament       testament       tested          test           \n  tester          tester          testern         testern        \n  testify         testifi         testimonied     testimoni      \n  testimonies     testimoni       testimony       testimoni      \n  testiness       testi           testril         testril        \n  testy           testi           tetchy          tetchi         \n  tether          tether          tetter          tetter         \n  tevil           tevil           tewksbury       tewksburi      \n  text            text            tgv             tgv            \n  th              th              thaes           thae           \n  thames          thame           than            than           \n  thane           thane           thanes          thane          \n  thank           thank           thanked         thank          \n  thankful        thank           thankfully      thankfulli     \n  thankfulness    thank           thanking        thank          \n  thankings       thank           thankless       thankless      \n  thanks          thank           thanksgiving    thanksgiv      \n  thasos          thaso           that            that           \n  thatch          thatch          thaw            thaw           \n  thawing         thaw            thaws           thaw           \n  the             the             theatre         theatr         \n  theban          theban          thebes          thebe          \n  thee            thee            theft           theft          \n  thefts          theft           thein           thein          \n  their           their           theirs          their          \n  theise          theis           them            them           \n  theme           theme           themes          theme          \n  themselves      themselv        then            then           \n  thence          thenc           thenceforth     thenceforth    \n  theoric         theoric         there           there          \n  thereabout      thereabout      thereabouts     thereabout     \n  thereafter      thereaft        thereat         thereat        \n  thereby         therebi         therefore       therefor       \n  therein         therein         thereof         thereof        \n  thereon         thereon         thereto         thereto        \n  thereunto       thereunto       thereupon       thereupon      \n  therewith       therewith       therewithal     therewith      \n  thersites       thersit         these           these          \n  theseus         theseu          thessalian      thessalian     \n  thessaly        thessali        thetis          theti          \n  thews           thew            they            thei           \n  thick           thick           thicken         thicken        \n  thickens        thicken         thicker         thicker        \n  thickest        thickest        thicket         thicket        \n  thickskin       thickskin       thief           thief          \n  thievery        thieveri        thieves         thiev          \n  thievish        thievish        thigh           thigh          \n  thighs          thigh           thimble         thimbl         \n  thimbles        thimbl          thin            thin           \n  thine           thine           thing           thing          \n  things          thing           think           think          \n  thinkest        thinkest        thinking        think          \n  thinkings       think           thinks          think          \n  thinkst         thinkst         thinly          thinli         \n  third           third           thirdly         thirdli        \n  thirds          third           thirst          thirst         \n  thirsting       thirst          thirsts         thirst         \n  thirsty         thirsti         thirteen        thirteen       \n  thirties        thirti          thirtieth       thirtieth      \n  thirty          thirti          this            thi            \n  thisby          thisbi          thisne          thisn          \n  thistle         thistl          thistles        thistl         \n  thither         thither         thitherward     thitherward    \n  thoas           thoa            thomas          thoma          \n  thorn           thorn           thorns          thorn          \n  thorny          thorni          thorough        thorough       \n  thoroughly      thoroughli      those           those          \n  thou            thou            though          though         \n  thought         thought         thoughtful      thought        \n  thoughts        thought         thousand        thousand       \n  thousands       thousand        thracian        thracian       \n  thraldom        thraldom        thrall          thrall         \n  thralled        thrall          thralls         thrall         \n  thrash          thrash          thrasonical     thrason        \n  thread          thread          threadbare      threadbar      \n  threaden        threaden        threading       thread         \n  threat          threat          threaten        threaten       \n  threatening     threaten        threatens       threaten       \n  threatest       threatest       threats         threat         \n  three           three           threefold       threefold      \n  threepence      threepenc       threepile       threepil       \n  threes          three           threescore      threescor      \n  thresher        thresher        threshold       threshold      \n  threw           threw           thrice          thrice         \n  thrift          thrift          thriftless      thriftless     \n  thrifts         thrift          thrifty         thrifti        \n  thrill          thrill          thrilling       thrill         \n  thrills         thrill          thrive          thrive         \n  thrived         thrive          thrivers        thriver        \n  thrives         thrive          thriving        thrive         \n  throat          throat          throats         throat         \n  throbbing       throb           throbs          throb          \n  throca          throca          throe           throe          \n  throes          throe           thromuldo       thromuldo      \n  thron           thron           throne          throne         \n  throned         throne          thrones         throne         \n  throng          throng          thronging       throng         \n  throngs         throng          throstle        throstl        \n  throttle        throttl         through         through        \n  throughfare     throughfar      throughfares    throughfar     \n  throughly       throughli       throughout      throughout     \n  throw           throw           thrower         thrower        \n  throwest        throwest        throwing        throw          \n  thrown          thrown          throws          throw          \n  thrum           thrum           thrumm          thrumm         \n  thrush          thrush          thrust          thrust         \n  thrusteth       thrusteth       thrusting       thrust         \n  thrusts         thrust          thumb           thumb          \n  thumbs          thumb           thump           thump          \n  thund           thund           thunder         thunder        \n  thunderbolt     thunderbolt     thunderbolts    thunderbolt    \n  thunderer       thunder         thunders        thunder        \n  thunderstone    thunderston     thunderstroke   thunderstrok   \n  thurio          thurio          thursday        thursdai       \n  thus            thu             thwack          thwack         \n  thwart          thwart          thwarted        thwart         \n  thwarting       thwart          thwartings      thwart         \n  thy             thy             thyme           thyme          \n  thymus          thymu           thyreus         thyreu         \n  thyself         thyself         ti              ti             \n  tib             tib             tiber           tiber          \n  tiberio         tiberio         tibey           tibei          \n  ticed           tice            tick            tick           \n  tickl           tickl           tickle          tickl          \n  tickled         tickl           tickles         tickl          \n  tickling        tickl           ticklish        ticklish       \n  tiddle          tiddl           tide            tide           \n  tides           tide            tidings         tide           \n  tidy            tidi            tie             tie            \n  tied            ti              ties            ti             \n  tiff            tiff            tiger           tiger          \n  tigers          tiger           tight           tight          \n  tightly         tightli         tike            tike           \n  til             til             tile            tile           \n  till            till            tillage         tillag         \n  tilly           tilli           tilt            tilt           \n  tilter          tilter          tilth           tilth          \n  tilting         tilt            tilts           tilt           \n  tiltyard        tiltyard        tim             tim            \n  timandra        timandra        timber          timber         \n  time            time            timeless        timeless       \n  timelier        timeli          timely          time           \n  times           time            timon           timon          \n  timor           timor           timorous        timor          \n  timorously      timor           tinct           tinct          \n  tincture        tinctur         tinctures       tinctur        \n  tinder          tinder          tingling        tingl          \n  tinker          tinker          tinkers         tinker         \n  tinsel          tinsel          tiny            tini           \n  tip             tip             tipp            tipp           \n  tippling        tippl           tips            tip            \n  tipsy           tipsi           tiptoe          tipto          \n  tir             tir             tire            tire           \n  tired           tire            tires           tire           \n  tirest          tirest          tiring          tire           \n  tirra           tirra           tirrits         tirrit         \n  tis             ti              tish            tish           \n  tisick          tisick          tissue          tissu          \n  titan           titan           titania         titania        \n  tithe           tith            tithed          tith           \n  tithing         tith            titinius        titiniu        \n  title           titl            titled          titl           \n  titleless       titleless       titles          titl           \n  tittle          tittl           tittles         tittl          \n  titular         titular         titus           titu           \n  tn              tn              to              to             \n  toad            toad            toads           toad           \n  toadstool       toadstool       toast           toast          \n  toasted         toast           toasting        toast          \n  toasts          toast           toaze           toaz           \n  toby            tobi            tock            tock           \n  tod             tod             today           todai          \n  todpole         todpol          tods            tod            \n  toe             toe             toes            toe            \n  tofore          tofor           toge            toge           \n  toged           toge            together        togeth         \n  toil            toil            toiled          toil           \n  toiling         toil            toils           toil           \n  token           token           tokens          token          \n  told            told            toledo          toledo         \n  tolerable       toler           toll            toll           \n  tolling         toll            tom             tom            \n  tomb            tomb            tombe           tomb           \n  tombed          tomb            tombless        tombless       \n  tomboys         tomboi          tombs           tomb           \n  tomorrow        tomorrow        tomyris         tomyri         \n  ton             ton             tongs           tong           \n  tongu           tongu           tongue          tongu          \n  tongued         tongu           tongueless      tongueless     \n  tongues         tongu           tonight         tonight        \n  too             too             took            took           \n  tool            tool            tools           tool           \n  tooth           tooth           toothache       toothach       \n  toothpick       toothpick       toothpicker     toothpick      \n  top             top             topas           topa           \n  topful          top             topgallant      topgal         \n  topless         topless         topmast         topmast        \n  topp            topp            topping         top            \n  topple          toppl           topples         toppl          \n  tops            top             topsail         topsail        \n  topsy           topsi           torch           torch          \n  torchbearer     torchbear       torchbearers    torchbear      \n  torcher         torcher         torches         torch          \n  torchlight      torchlight      tore            tore           \n  torment         torment         tormenta        tormenta       \n  tormente        torment         tormented       torment        \n  tormenting      torment         tormentors      tormentor      \n  torments        torment         torn            torn           \n  torrent         torrent         tortive         tortiv         \n  tortoise        tortois         tortur          tortur         \n  torture         tortur          tortured        tortur         \n  torturer        tortur          torturers       tortur         \n  tortures        tortur          torturest       torturest      \n  torturing       tortur          toryne          toryn          \n  toss            toss            tossed          toss           \n  tosseth         tosseth         tossing         toss           \n  tot             tot             total           total          \n  totally         total           tott            tott           \n  tottered        totter          totters         totter         \n  tou             tou             touch           touch          \n  touched         touch           touches         touch          \n  toucheth        toucheth        touching        touch          \n  touchstone      touchston       tough           tough          \n  tougher         tougher         toughness       tough          \n  touraine        tourain         tournaments     tournament     \n  tours           tour            tous            tou            \n  tout            tout            touze           touz           \n  tow             tow             toward          toward         \n  towardly        towardli        towards         toward         \n  tower           tower           towering        tower          \n  towers          tower           town            town           \n  towns           town            township        township       \n  townsman        townsman        townsmen        townsmen       \n  towton          towton          toy             toi            \n  toys            toi             trace           trace          \n  traces          trace           track           track          \n  tract           tract           tractable       tractabl       \n  trade           trade           traded          trade          \n  traders         trader          trades          trade          \n  tradesman       tradesman       tradesmen       tradesmen      \n  trading         trade           tradition       tradit         \n  traditional     tradit          traduc          traduc         \n  traduced        traduc          traducement     traduc         \n  traffic         traffic         traffickers     traffick       \n  traffics        traffic         tragedian       tragedian      \n  tragedians      tragedian       tragedies       tragedi        \n  tragedy         tragedi         tragic          tragic         \n  tragical        tragic          trail           trail          \n  train           train           trained         train          \n  training        train           trains          train          \n  trait           trait           traitor         traitor        \n  traitorly       traitorli       traitorous      traitor        \n  traitorously    traitor         traitors        traitor        \n  traitress       traitress       traject         traject        \n  trammel         trammel         trample         trampl         \n  trampled        trampl          trampling       trampl         \n  tranc           tranc           trance          tranc          \n  tranio          tranio          tranquil        tranquil       \n  tranquillity    tranquil        transcendence   transcend      \n  transcends      transcend       transferred     transfer       \n  transfigur      transfigur      transfix        transfix       \n  transform       transform       transformation  transform      \n  transformations transform       transformed     transform      \n  transgress      transgress      transgresses    transgress     \n  transgressing   transgress      transgression   transgress     \n  translate       translat        translated      translat       \n  translates      translat        translation     translat       \n  transmigrates   transmigr       transmutation   transmut       \n  transparent     transpar        transport       transport      \n  transportance   transport       transported     transport      \n  transporting    transport       transports      transport      \n  transpose       transpos        transshape      transshap      \n  trap            trap            trapp           trapp          \n  trappings       trap            traps           trap           \n  trash           trash           travail         travail        \n  travails        travail         travel          travel         \n  traveler        travel          traveling       travel         \n  travell         travel          travelled       travel         \n  traveller       travel          travellers      travel         \n  travellest      travellest      travelling      travel         \n  travels         travel          travers         traver         \n  traverse        travers         tray            trai           \n  treacherous     treacher        treacherously   treacher       \n  treachers       treacher        treachery       treacheri      \n  tread           tread           treading        tread          \n  treads          tread           treason         treason        \n  treasonable     treason         treasonous      treason        \n  treasons        treason         treasure        treasur        \n  treasurer       treasur         treasures       treasur        \n  treasuries      treasuri        treasury        treasuri       \n  treat           treat           treaties        treati         \n  treatise        treatis         treats          treat          \n  treaty          treati          treble          trebl          \n  trebled         trebl           trebles         trebl          \n  trebonius       treboniu        tree            tree           \n  trees           tree            tremble         trembl         \n  trembled        trembl          trembles        trembl         \n  tremblest       tremblest       trembling       trembl         \n  tremblingly     tremblingli     tremor          tremor         \n  trempling       trempl          trench          trench         \n  trenchant       trenchant       trenched        trench         \n  trencher        trencher        trenchering     trencher       \n  trencherman     trencherman     trenchers       trencher       \n  trenches        trench          trenching       trench         \n  trent           trent           tres            tre            \n  trespass        trespass        trespasses      trespass       \n  tressel         tressel         tresses         tress          \n  treys           trei            trial           trial          \n  trials          trial           trib            trib           \n  tribe           tribe           tribes          tribe          \n  tribulation     tribul          tribunal        tribun         \n  tribune         tribun          tribunes        tribun         \n  tributaries     tributari       tributary       tributari      \n  tribute         tribut          tributes        tribut         \n  trice           trice           trick           trick          \n  tricking        trick           trickling       trickl         \n  tricks          trick           tricksy         tricksi        \n  trident         trident         tried           tri            \n  trier           trier           trifle          trifl          \n  trifled         trifl           trifler         trifler        \n  trifles         trifl           trifling        trifl          \n  trigon          trigon          trill           trill          \n  trim            trim            trimly          trimli         \n  trimm           trimm           trimmed         trim           \n  trimming        trim            trims           trim           \n  trinculo        trinculo        trinculos       trinculo       \n  trinkets        trinket         trip            trip           \n  tripartite      tripartit       tripe           tripe          \n  triple          tripl           triplex         triplex        \n  tripoli         tripoli         tripolis        tripoli        \n  tripp           tripp           tripping        trip           \n  trippingly      trippingli      trips           trip           \n  tristful        trist           triton          triton         \n  triumph         triumph         triumphant      triumphant     \n  triumphantly    triumphantli    triumpher       triumpher      \n  triumphers      triumpher       triumphing      triumph        \n  triumphs        triumph         triumvir        triumvir       \n  triumvirate     triumvir        triumvirs       triumvir       \n  triumviry       triumviri       trivial         trivial        \n  troat           troat           trod            trod           \n  trodden         trodden         troiant         troiant        \n  troien          troien          troilus         troilu         \n  troiluses       troilus         trojan          trojan         \n  trojans         trojan          troll           troll          \n  tromperies      tromperi        trompet         trompet        \n  troop           troop           trooping        troop          \n  troops          troop           trop            trop           \n  trophies        trophi          trophy          trophi         \n  tropically      tropic          trot            trot           \n  troth           troth           trothed         troth          \n  troths          troth           trots           trot           \n  trotting        trot            trouble         troubl         \n  troubled        troubl          troubler        troubler       \n  troubles        troubl          troublesome     troublesom     \n  troublest       troublest       troublous       troublou       \n  trough          trough          trout           trout          \n  trouts          trout           trovato         trovato        \n  trow            trow            trowel          trowel         \n  trowest         trowest         troy            troi           \n  troyan          troyan          troyans         troyan         \n  truant          truant          truce           truce          \n  truckle         truckl          trudge          trudg          \n  true            true            trueborn        trueborn       \n  truepenny       truepenni       truer           truer          \n  truest          truest          truie           truie          \n  trull           trull           trulls          trull          \n  truly           truli           trump           trump          \n  trumpery        trumperi        trumpet         trumpet        \n  trumpeter       trumpet         trumpeters      trumpet        \n  trumpets        trumpet         truncheon       truncheon      \n  truncheoners    truncheon       trundle         trundl         \n  trunk           trunk           trunks          trunk          \n  trust           trust           trusted         trust          \n  truster         truster         trusters        truster        \n  trusting        trust           trusts          trust          \n  trusty          trusti          truth           truth          \n  truths          truth           try             try            \n  ts              ts              tu              tu             \n  tuae            tuae            tub             tub            \n  tubal           tubal           tubs            tub            \n  tuck            tuck            tucket          tucket         \n  tuesday         tuesdai         tuft            tuft           \n  tufts           tuft            tug             tug            \n  tugg            tugg            tugging         tug            \n  tuition         tuition         tullus          tullu          \n  tully           tulli           tumble          tumbl          \n  tumbled         tumbl           tumbler         tumbler        \n  tumbling        tumbl           tumult          tumult         \n  tumultuous      tumultu         tun             tun            \n  tune            tune            tuneable        tuneabl        \n  tuned           tune            tuners          tuner          \n  tunes           tune            tunis           tuni           \n  tuns            tun             tupping         tup            \n  turban          turban          turbans         turban         \n  turbulence      turbul          turbulent       turbul         \n  turd            turd            turf            turf           \n  turfy           turfi           turk            turk           \n  turkey          turkei          turkeys         turkei         \n  turkish         turkish         turks           turk           \n  turlygod        turlygod        turmoil         turmoil        \n  turmoiled       turmoil         turn            turn           \n  turnbull        turnbul         turncoat        turncoat       \n  turncoats       turncoat        turned          turn           \n  turneth         turneth         turning         turn           \n  turnips         turnip          turns           turn           \n  turph           turph           turpitude       turpitud       \n  turquoise       turquois        turret          turret         \n  turrets         turret          turtle          turtl          \n  turtles         turtl           turvy           turvi          \n  tuscan          tuscan          tush            tush           \n  tut             tut             tutor           tutor          \n  tutored         tutor           tutors          tutor          \n  tutto           tutto           twain           twain          \n  twang           twang           twangling       twangl         \n  twas            twa             tway            twai           \n  tweaks          tweak           tween           tween          \n  twelfth         twelfth         twelve          twelv          \n  twelvemonth     twelvemonth     twentieth       twentieth      \n  twenty          twenti          twere           twere          \n  twice           twice           twig            twig           \n  twiggen         twiggen         twigs           twig           \n  twilight        twilight        twill           twill          \n  twilled         twill           twin            twin           \n  twine           twine           twink           twink          \n  twinkle         twinkl          twinkled        twinkl         \n  twinkling       twinkl          twinn           twinn          \n  twins           twin            twire           twire          \n  twist           twist           twisted         twist          \n  twit            twit            twits           twit           \n  twitting        twit            twixt           twixt          \n  two             two             twofold         twofold        \n  twopence        twopenc         twopences       twopenc        \n  twos            two             twould          twould         \n  tyb             tyb             tybalt          tybalt         \n  tybalts         tybalt          tyburn          tyburn         \n  tying           ty              tyke            tyke           \n  tymbria         tymbria         type            type           \n  types           type            typhon          typhon         \n  tyrannical      tyrann          tyrannically    tyrann         \n  tyrannize       tyrann          tyrannous       tyrann         \n  tyranny         tyranni         tyrant          tyrant         \n  tyrants         tyrant          tyrian          tyrian         \n  tyrrel          tyrrel          u               u              \n  ubique          ubiqu           udders          udder          \n  udge            udg             uds             ud             \n  uglier          uglier          ugliest         ugliest        \n  ugly            ugli            ulcer           ulcer          \n  ulcerous        ulcer           ulysses         ulyss          \n  um              um              umber           umber          \n  umbra           umbra           umbrage         umbrag         \n  umfrevile       umfrevil        umpire          umpir          \n  umpires         umpir           un              un             \n  unable          unabl           unaccommodated  unaccommod     \n  unaccompanied   unaccompani     unaccustom      unaccustom     \n  unaching        unach           unacquainted    unacquaint     \n  unactive        unact           unadvis         unadvi         \n  unadvised       unadvis         unadvisedly     unadvisedli    \n  unagreeable     unagre          unanel          unanel         \n  unanswer        unansw          unappeas        unappea        \n  unapproved      unapprov        unapt           unapt          \n  unaptness       unapt           unarm           unarm          \n  unarmed         unarm           unarms          unarm          \n  unassail        unassail        unassailable    unassail       \n  unattainted     unattaint       unattempted     unattempt      \n  unattended      unattend        unauspicious    unauspici      \n  unauthorized    unauthor        unavoided       unavoid        \n  unawares        unawar          unback          unback         \n  unbak           unbak           unbanded        unband         \n  unbar           unbar           unbarb          unbarb         \n  unbashful       unbash          unbated         unbat          \n  unbatter        unbatt          unbecoming      unbecom        \n  unbefitting     unbefit         unbegot         unbegot        \n  unbegotten      unbegotten      unbelieved      unbeliev       \n  unbend          unbend          unbent          unbent         \n  unbewail        unbewail        unbid           unbid          \n  unbidden        unbidden        unbind          unbind         \n  unbinds         unbind          unbitted        unbit          \n  unbless         unbless         unblest         unblest        \n  unbloodied      unbloodi        unblown         unblown        \n  unbodied        unbodi          unbolt          unbolt         \n  unbolted        unbolt          unbonneted      unbonnet       \n  unbookish       unbookish       unborn          unborn         \n  unbosom         unbosom         unbound         unbound        \n  unbounded       unbound         unbow           unbow          \n  unbowed         unbow           unbrac          unbrac         \n  unbraced        unbrac          unbraided       unbraid        \n  unbreathed      unbreath        unbred          unbr           \n  unbreech        unbreech        unbridled       unbridl        \n  unbroke         unbrok          unbruis         unbrui         \n  unbruised       unbruis         unbuckle        unbuckl        \n  unbuckles       unbuckl         unbuckling      unbuckl        \n  unbuild         unbuild         unburden        unburden       \n  unburdens       unburden        unburied        unburi         \n  unburnt         unburnt         unburthen       unburthen      \n  unbutton        unbutton        unbuttoning     unbutton       \n  uncapable       uncap           uncape          uncap          \n  uncase          uncas           uncasing        uncas          \n  uncaught        uncaught        uncertain       uncertain      \n  uncertainty     uncertainti     unchain         unchain        \n  unchanging      unchang         uncharge        uncharg        \n  uncharged       uncharg         uncharitably    uncharit       \n  unchary         unchari         unchaste        unchast        \n  uncheck         uncheck         unchilded       unchild        \n  uncivil         uncivil         unclaim         unclaim        \n  unclasp         unclasp         uncle           uncl           \n  unclean         unclean         uncleanliness   uncleanli      \n  uncleanly       uncleanli       uncleanness     unclean        \n  uncles          uncl            unclew          unclew         \n  unclog          unclog          uncoined        uncoin         \n  uncolted        uncolt          uncomeliness    uncomeli       \n  uncomfortable   uncomfort       uncompassionate uncompassion   \n  uncomprehensive uncomprehens    unconfinable    unconfin       \n  unconfirm       unconfirm       unconfirmed     unconfirm      \n  unconquer       unconqu         unconquered     unconqu        \n  unconsidered    unconsid        unconstant      unconst        \n  unconstrain     unconstrain     unconstrained   unconstrain    \n  uncontemn       uncontemn       uncontroll      uncontrol      \n  uncorrected     uncorrect       uncounted       uncount        \n  uncouple        uncoupl         uncourteous     uncourt        \n  uncouth         uncouth         uncover         uncov          \n  uncovered       uncov           uncropped       uncrop         \n  uncross         uncross         uncrown         uncrown        \n  unction         unction         unctuous        unctuou        \n  uncuckolded     uncuckold       uncurable       uncur          \n  uncurbable      uncurb          uncurbed        uncurb         \n  uncurls         uncurl          uncurrent       uncurr         \n  uncurse         uncurs          undaunted       undaunt        \n  undeaf          undeaf          undeck          undeck         \n  undeeded        undeed          under           under          \n  underbearing    underbear       underborne      underborn      \n  undercrest      undercrest      underfoot       underfoot      \n  undergo         undergo         undergoes       undergo        \n  undergoing      undergo         undergone       undergon       \n  underground     underground     underhand       underhand      \n  underlings      underl          undermine       undermin       \n  underminers     undermin        underneath      underneath     \n  underprizing    underpr         underprop       underprop      \n  understand      understand      understandeth   understandeth  \n  understanding   understand      understandings  understand     \n  understands     understand      understood      understood     \n  underta         underta         undertake       undertak       \n  undertakeing    undertak        undertaker      undertak       \n  undertakes      undertak        undertaking     undertak       \n  undertakings    undertak        undertook       undertook      \n  undervalu       undervalu       undervalued     undervalu      \n  underwent       underw          underwrit       underwrit      \n  underwrite      underwrit       undescried      undescri       \n  undeserved      undeserv        undeserver      undeserv       \n  undeservers     undeserv        undeserving     undeserv       \n  undetermin      undetermin      undid           undid          \n  undinted        undint          undiscernible   undiscern      \n  undiscover      undiscov        undishonoured   undishonour    \n  undispos        undispo         undistinguishable undistinguish  \n  undistinguished undistinguish   undividable     undivid        \n  undivided       undivid         undivulged      undivulg       \n  undo            undo            undoes          undo           \n  undoing         undo            undone          undon          \n  undoubted       undoubt         undoubtedly     undoubtedli    \n  undream         undream         undress         undress        \n  undressed       undress         undrown         undrown        \n  unduteous       undut           undutiful       unduti         \n  une             un              uneared         unear          \n  unearned        unearn          unearthly       unearthli      \n  uneasines       uneasin         uneasy          uneasi         \n  uneath          uneath          uneducated      uneduc         \n  uneffectual     uneffectu       unelected       unelect        \n  unequal         unequ           uneven          uneven         \n  unexamin        unexamin        unexecuted      unexecut       \n  unexpected      unexpect        unexperienc     unexperienc    \n  unexperient     unexperi        unexpressive    unexpress      \n  unfair          unfair          unfaithful      unfaith        \n  unfallible      unfal           unfam           unfam          \n  unfashionable   unfashion       unfasten        unfasten       \n  unfather        unfath          unfathered      unfath         \n  unfed           unf             unfeed          unfe           \n  unfeeling       unfeel          unfeigned       unfeign        \n  unfeignedly     unfeignedli     unfellowed      unfellow       \n  unfelt          unfelt          unfenced        unfenc         \n  unfilial        unfili          unfill          unfil          \n  unfinish        unfinish        unfirm          unfirm         \n  unfit           unfit           unfitness       unfit          \n  unfix           unfix           unfledg         unfledg        \n  unfold          unfold          unfolded        unfold         \n  unfoldeth       unfoldeth       unfolding       unfold         \n  unfolds         unfold          unfool          unfool         \n  unforc          unforc          unforced        unforc         \n  unforfeited     unforfeit       unfortified     unfortifi      \n  unfortunate     unfortun        unfought        unfought       \n  unfrequented    unfrequ         unfriended      unfriend       \n  unfurnish       unfurnish       ungain          ungain         \n  ungalled        ungal           ungart          ungart         \n  ungarter        ungart          ungenitur       ungenitur      \n  ungentle        ungentl         ungentleness    ungentl        \n  ungently        ungent          ungird          ungird         \n  ungodly         ungodli         ungor           ungor          \n  ungot           ungot           ungotten        ungotten       \n  ungovern        ungovern        ungracious      ungraci        \n  ungrateful      ungrat          ungravely       ungrav         \n  ungrown         ungrown         unguarded       unguard        \n  unguem          unguem          unguided        unguid         \n  unhack          unhack          unhair          unhair         \n  unhallow        unhallow        unhallowed      unhallow       \n  unhand          unhand          unhandled       unhandl        \n  unhandsome      unhandsom       unhang          unhang         \n  unhappied       unhappi         unhappily       unhappili      \n  unhappiness     unhappi         unhappy         unhappi        \n  unhardened      unharden        unharm          unharm         \n  unhatch         unhatch         unheard         unheard        \n  unhearts        unheart         unheedful       unheed         \n  unheedfully     unheedfulli     unheedy         unheedi        \n  unhelpful       unhelp          unhidden        unhidden       \n  unholy          unholi          unhop           unhop          \n  unhopefullest   unhopefullest   unhorse         unhors         \n  unhospitable    unhospit        unhous          unhou          \n  unhoused        unhous          unhurtful       unhurt         \n  unicorn         unicorn         unicorns        unicorn        \n  unimproved      unimprov        uninhabitable   uninhabit      \n  uninhabited     uninhabit       unintelligent   unintellig     \n  union           union           unions          union          \n  unite           unit            united          unit           \n  unity           uniti           universal       univers        \n  universe        univers         universities    univers        \n  university      univers         unjointed       unjoint        \n  unjust          unjust          unjustice       unjustic       \n  unjustly        unjustli        unkennel        unkennel       \n  unkept          unkept          unkind          unkind         \n  unkindest       unkindest       unkindly        unkindli       \n  unkindness      unkind          unking          unk            \n  unkinglike      unkinglik       unkiss          unkiss         \n  unknit          unknit          unknowing       unknow         \n  unknown         unknown         unlace          unlac          \n  unlaid          unlaid          unlawful        unlaw          \n  unlawfully      unlawfulli      unlearn         unlearn        \n  unlearned       unlearn         unless          unless         \n  unlesson        unlesson        unletter        unlett         \n  unlettered      unlett          unlick          unlick         \n  unlike          unlik           unlikely        unlik          \n  unlimited       unlimit         unlineal        unlin          \n  unlink          unlink          unload          unload         \n  unloaded        unload          unloading       unload         \n  unloads         unload          unlock          unlock         \n  unlocks         unlock          unlook          unlook         \n  unlooked        unlook          unloos          unloo          \n  unloose         unloos          unlov           unlov          \n  unloving        unlov           unluckily       unluckili      \n  unlucky         unlucki         unmade          unmad          \n  unmake          unmak           unmanly         unmanli        \n  unmann          unmann          unmanner        unmann         \n  unmannerd       unmannerd       unmannerly      unmannerli     \n  unmarried       unmarri         unmask          unmask         \n  unmasked        unmask          unmasking       unmask         \n  unmasks         unmask          unmast          unmast         \n  unmatch         unmatch         unmatchable     unmatch        \n  unmatched       unmatch         unmeasurable    unmeasur       \n  unmeet          unmeet          unmellowed      unmellow       \n  unmerciful      unmerci         unmeritable     unmerit        \n  unmeriting      unmerit         unminded        unmind         \n  unmindfull      unmindful       unmingled       unmingl        \n  unmitigable     unmitig         unmitigated     unmitig        \n  unmix           unmix           unmoan          unmoan         \n  unmov           unmov           unmoved         unmov          \n  unmoving        unmov           unmuffles       unmuffl        \n  unmuffling      unmuffl         unmusical       unmus          \n  unmuzzle        unmuzzl         unmuzzled       unmuzzl        \n  unnatural       unnatur         unnaturally     unnatur        \n  unnaturalness   unnatur         unnecessarily   unnecessarili  \n  unnecessary     unnecessari     unneighbourly   unneighbourli  \n  unnerved        unnerv          unnoble         unnobl         \n  unnoted         unnot           unnumb          unnumb         \n  unnumber        unnumb          unowed          unow           \n  unpack          unpack          unpaid          unpaid         \n  unparagon       unparagon       unparallel      unparallel     \n  unpartial       unparti         unpath          unpath         \n  unpaved         unpav           unpay           unpai          \n  unpeaceable     unpeac          unpeg           unpeg          \n  unpeople        unpeopl         unpeopled       unpeopl        \n  unperfect       unperfect       unperfectness   unperfect      \n  unpick          unpick          unpin           unpin          \n  unpink          unpink          unpitied        unpiti         \n  unpitifully     unpitifulli     unplagu         unplagu        \n  unplausive      unplaus         unpleas         unplea         \n  unpleasant      unpleas         unpleasing      unpleas        \n  unpolicied      unpolici        unpolish        unpolish       \n  unpolished      unpolish        unpolluted      unpollut       \n  unpossess       unpossess       unpossessing    unpossess      \n  unpossible      unposs          unpractis       unpracti       \n  unpregnant      unpregn         unpremeditated  unpremedit     \n  unprepar        unprepar        unprepared      unprepar       \n  unpress         unpress         unprevailing    unprevail      \n  unprevented     unprev          unpriz          unpriz         \n  unprizable      unpriz          unprofitable    unprofit       \n  unprofited      unprofit        unproper        unprop         \n  unproperly      unproperli      unproportion    unproport      \n  unprovide       unprovid        unprovided      unprovid       \n  unprovident     unprovid        unprovokes      unprovok       \n  unprun          unprun          unpruned        unprun         \n  unpublish       unpublish       unpurged        unpurg         \n  unpurpos        unpurpo         unqualitied     unqual         \n  unqueen         unqueen         unquestion      unquest        \n  unquestionable  unquestion      unquiet         unquiet        \n  unquietly       unquietli       unquietness     unquiet        \n  unraised        unrais          unrak           unrak          \n  unread          unread          unready         unreadi        \n  unreal          unreal          unreasonable    unreason       \n  unreasonably    unreason        unreclaimed     unreclaim      \n  unreconciled    unreconcil      unreconciliable unreconcili    \n  unrecounted     unrecount       unrecuring      unrecur        \n  unregarded      unregard        unregist        unregist       \n  unrelenting     unrel           unremovable     unremov        \n  unremovably     unremov         unreprievable   unrepriev      \n  unresolv        unresolv        unrespected     unrespect      \n  unrespective    unrespect       unrest          unrest         \n  unrestor        unrestor        unrestrained    unrestrain     \n  unreveng        unreveng        unreverend      unreverend     \n  unreverent      unrever         unrevers        unrev          \n  unrewarded      unreward        unrighteous     unright        \n  unrightful      unright         unripe          unrip          \n  unripp          unripp          unrivall        unrival        \n  unroll          unrol           unroof          unroof         \n  unroosted       unroost         unroot          unroot         \n  unrough         unrough         unruly          unruli         \n  unsafe          unsaf           unsaluted       unsalut        \n  unsanctified    unsanctifi      unsatisfied     unsatisfi      \n  unsavoury       unsavouri       unsay           unsai          \n  unscalable      unscal          unscann         unscann        \n  unscarr         unscarr         unschool        unschool       \n  unscorch        unscorch        unscour         unscour        \n  unscratch       unscratch       unseal          unseal         \n  unseam          unseam          unsearch        unsearch       \n  unseason        unseason        unseasonable    unseason       \n  unseasonably    unseason        unseasoned      unseason       \n  unseconded      unsecond        unsecret        unsecret       \n  unseduc         unseduc         unseeing        unse           \n  unseeming       unseem          unseemly        unseemli       \n  unseen          unseen          unseminar       unseminar      \n  unseparable     unsepar         unserviceable   unservic       \n  unset           unset           unsettle        unsettl        \n  unsettled       unsettl         unsever         unsev          \n  unsex           unsex           unshak          unshak         \n  unshaked        unshak          unshaken        unshaken       \n  unshaped        unshap          unshapes        unshap         \n  unsheath        unsheath        unsheathe       unsheath       \n  unshorn         unshorn         unshout         unshout        \n  unshown         unshown         unshrinking     unshrink       \n  unshrubb        unshrubb        unshunn         unshunn        \n  unshunnable     unshunn         unsifted        unsift         \n  unsightly       unsightli       unsinew         unsinew        \n  unsisting       unsist          unskilful       unskil         \n  unskilfully     unskilfulli     unskillful      unskil         \n  unslipping      unslip          unsmirched      unsmirch       \n  unsoil          unsoil          unsolicited     unsolicit      \n  unsorted        unsort          unsought        unsought       \n  unsound         unsound         unsounded       unsound        \n  unspeak         unspeak         unspeakable     unspeak        \n  unspeaking      unspeak         unsphere        unspher        \n  unspoke         unspok          unspoken        unspoken       \n  unspotted       unspot          unsquar         unsquar        \n  unstable        unstabl         unstaid         unstaid        \n  unstain         unstain         unstained       unstain        \n  unstanched      unstanch        unstate         unstat         \n  unsteadfast     unsteadfast     unstooping      unstoop        \n  unstringed      unstring        unstuff         unstuff        \n  unsubstantial   unsubstanti     unsuitable      unsuit         \n  unsuiting       unsuit          unsullied       unsulli        \n  unsunn          unsunn          unsur           unsur          \n  unsure          unsur           unsuspected     unsuspect      \n  unsway          unswai          unswayable      unsway         \n  unswayed        unswai          unswear         unswear        \n  unswept         unswept         unsworn         unsworn        \n  untainted       untaint         untalk          untalk         \n  untangle        untangl         untangled       untangl        \n  untasted        untast          untaught        untaught       \n  untempering     untemp          untender        untend         \n  untent          untent          untented        untent         \n  unthankful      unthank         unthankfulness  unthank        \n  unthink         unthink         unthought       unthought      \n  unthread        unthread        unthrift        unthrift       \n  unthrifts       unthrift        unthrifty       unthrifti      \n  untie           unti            untied          unti           \n  until           until           untimber        untimb         \n  untimely        untim           untir           untir          \n  untirable       untir           untired         untir          \n  untitled        untitl          unto            unto           \n  untold          untold          untouch         untouch        \n  untoward        untoward        untowardly      untowardli     \n  untraded        untrad          untrain         untrain        \n  untrained       untrain         untread         untread        \n  untreasur       untreasur       untried         untri          \n  untrimmed       untrim          untrod          untrod         \n  untrodden       untrodden       untroubled      untroubl       \n  untrue          untru           untrussing      untruss        \n  untruth         untruth         untruths        untruth        \n  untucked        untuck          untun           untun          \n  untune          untun           untuneable      untun          \n  untutor         untutor         untutored       untutor        \n  untwine         untwin          unurg           unurg          \n  unus            unu             unused          unus           \n  unusual         unusu           unvalued        unvalu         \n  unvanquish      unvanquish      unvarnish       unvarnish      \n  unveil          unveil          unveiling       unveil         \n  unvenerable     unvener         unvex           unvex          \n  unviolated      unviol          unvirtuous      unvirtu        \n  unvisited       unvisit         unvulnerable    unvulner       \n  unwares         unwar           unwarily        unwarili       \n  unwash          unwash          unwatch         unwatch        \n  unwearied       unweari         unwed           unw            \n  unwedgeable     unwedg          unweeded        unweed         \n  unweighed       unweigh         unweighing      unweigh        \n  unwelcome       unwelcom        unwept          unwept         \n  unwhipp         unwhipp         unwholesome     unwholesom     \n  unwieldy        unwieldi        unwilling       unwil          \n  unwillingly     unwillingli     unwillingness   unwilling      \n  unwind          unwind          unwiped         unwip          \n  unwise          unwis           unwisely        unwis          \n  unwish          unwish          unwished        unwish         \n  unwitted        unwit           unwittingly     unwittingli    \n  unwonted        unwont          unwooed         unwoo          \n  unworthier      unworthi        unworthiest     unworthiest    \n  unworthily      unworthili      unworthiness    unworthi       \n  unworthy        unworthi        unwrung         unwrung        \n  unyok           unyok           unyoke          unyok          \n  up              up              upbraid         upbraid        \n  upbraided       upbraid         upbraidings     upbraid        \n  upbraids        upbraid         uphoarded       uphoard        \n  uphold          uphold          upholdeth       upholdeth      \n  upholding       uphold          upholds         uphold         \n  uplift          uplift          uplifted        uplift         \n  upmost          upmost          upon            upon           \n  upper           upper           uprear          uprear         \n  upreared        uprear          upright         upright        \n  uprighteously   upright         uprightness     upright        \n  uprise          upris           uprising        upris          \n  uproar          uproar          uproars         uproar         \n  uprous          uprou           upshoot         upshoot        \n  upshot          upshot          upside          upsid          \n  upspring        upspr           upstairs        upstair        \n  upstart         upstart         upturned        upturn         \n  upward          upward          upwards         upward         \n  urchin          urchin          urchinfield     urchinfield    \n  urchins         urchin          urg             urg            \n  urge            urg             urged           urg            \n  urgent          urgent          urges           urg            \n  urgest          urgest          urging          urg            \n  urinal          urin            urinals         urin           \n  urine           urin            urn             urn            \n  urns            urn             urs             ur             \n  ursa            ursa            ursley          urslei         \n  ursula          ursula          urswick         urswick        \n  us              us              usage           usag           \n  usance          usanc           usances         usanc          \n  use             us              used            us             \n  useful          us              useless         useless        \n  user            user            uses            us             \n  usest           usest           useth           useth          \n  usher           usher           ushered         usher          \n  ushering        usher           ushers          usher          \n  using           us              usual           usual          \n  usually         usual           usurer          usur           \n  usurers         usur            usuries         usuri          \n  usuring         usur            usurp           usurp          \n  usurpation      usurp           usurped         usurp          \n  usurper         usurp           usurpers        usurp          \n  usurping        usurp           usurpingly      usurpingli     \n  usurps          usurp           usury           usuri          \n  ut              ut              utensil         utensil        \n  utensils        utensil         utility         util           \n  utmost          utmost          utt             utt            \n  utter           utter           utterance       utter          \n  uttered         utter           uttereth        uttereth       \n  uttering        utter           utterly         utterli        \n  uttermost       uttermost       utters          utter          \n  uy              uy              v               v              \n  va              va              vacancy         vacanc         \n  vacant          vacant          vacation        vacat          \n  vade            vade            vagabond        vagabond       \n  vagabonds       vagabond        vagram          vagram         \n  vagrom          vagrom          vail            vail           \n  vailed          vail            vailing         vail           \n  vaillant        vaillant        vain            vain           \n  vainer          vainer          vainglory       vainglori      \n  vainly          vainli          vainness        vain           \n  vais            vai             valanc          valanc         \n  valance         valanc          vale            vale           \n  valence         valenc          valentine       valentin       \n  valentinus      valentinu       valentio        valentio       \n  valeria         valeria         valerius        valeriu        \n  vales           vale            valiant         valiant        \n  valiantly       valiantli       valiantness     valiant        \n  validity        valid           vallant         vallant        \n  valley          vallei          valleys         vallei         \n  vally           valli           valor           valor          \n  valorous        valor           valorously      valor          \n  valour          valour          valu            valu           \n  valuation       valuat          value           valu           \n  valued          valu            valueless       valueless      \n  values          valu            valuing         valu           \n  vane            vane            vanish          vanish         \n  vanished        vanish          vanishes        vanish         \n  vanishest       vanishest       vanishing       vanish         \n  vanities        vaniti          vanity          vaniti         \n  vanquish        vanquish        vanquished      vanquish       \n  vanquisher      vanquish        vanquishest     vanquishest    \n  vanquisheth     vanquisheth     vant            vant           \n  vantage         vantag          vantages        vantag         \n  vantbrace       vantbrac        vapians         vapian         \n  vapor           vapor           vaporous        vapor          \n  vapour          vapour          vapours         vapour         \n  vara            vara            variable        variabl        \n  variance        varianc         variation       variat         \n  variations      variat          varied          vari           \n  variest         variest         variety         varieti        \n  varld           varld           varlet          varlet         \n  varletry        varletri        varlets         varlet         \n  varletto        varletto        varnish         varnish        \n  varrius         varriu          varro           varro          \n  vary            vari            varying         vari           \n  vassal          vassal          vassalage       vassalag       \n  vassals         vassal          vast            vast           \n  vastidity       vastid          vasty           vasti          \n  vat             vat             vater           vater          \n  vaudemont       vaudemont       vaughan         vaughan        \n  vault           vault           vaultages       vaultag        \n  vaulted         vault           vaulting        vault          \n  vaults          vault           vaulty          vaulti         \n  vaumond         vaumond         vaunt           vaunt          \n  vaunted         vaunt           vaunter         vaunter        \n  vaunting        vaunt           vauntingly      vauntingli     \n  vaunts          vaunt           vauvado         vauvado        \n  vaux            vaux            vaward          vaward         \n  ve              ve              veal            veal           \n  vede            vede            vehemence       vehem          \n  vehemency       vehem           vehement        vehement       \n  vehor           vehor           veil            veil           \n  veiled          veil            veiling         veil           \n  vein            vein            veins           vein           \n  vell            vell            velure          velur          \n  velutus         velutu          velvet          velvet         \n  vendible        vendibl         venerable       vener          \n  venereal        vener           venetia         venetia        \n  venetian        venetian        venetians       venetian       \n  veneys          venei           venge           veng           \n  vengeance       vengeanc        vengeances      vengeanc       \n  vengeful        veng            veni            veni           \n  venial          venial          venice          venic          \n  venison         venison         venit           venit          \n  venom           venom           venomous        venom          \n  venomously      venom           vent            vent           \n  ventages        ventag          vented          vent           \n  ventidius       ventidiu        ventricle       ventricl       \n  vents           vent            ventur          ventur         \n  venture         ventur          ventured        ventur         \n  ventures        ventur          venturing       ventur         \n  venturous       ventur          venue           venu           \n  venus           venu            venuto          venuto         \n  ver             ver             verb            verb           \n  verba           verba           verbal          verbal         \n  verbatim        verbatim        verbosity       verbos         \n  verdict         verdict         verdun          verdun         \n  verdure         verdur          vere            vere           \n  verefore        verefor         verg            verg           \n  verge           verg            vergers         verger         \n  verges          verg            verier          verier         \n  veriest         veriest         verified        verifi         \n  verify          verifi          verily          verili         \n  veritable       verit           verite          verit          \n  verities        veriti          verity          veriti         \n  vermilion       vermilion       vermin          vermin         \n  vernon          vernon          verona          verona         \n  veronesa        veronesa        versal          versal         \n  verse           vers            verses          vers           \n  versing         vers            vert            vert           \n  very            veri            vesper          vesper         \n  vessel          vessel          vessels         vessel         \n  vestal          vestal          vestments       vestment       \n  vesture         vestur          vetch           vetch          \n  vetches         vetch           veux            veux           \n  vex             vex             vexation        vexat          \n  vexations       vexat           vexed           vex            \n  vexes           vex             vexest          vexest         \n  vexeth          vexeth          vexing          vex            \n  vi              vi              via             via            \n  vial            vial            vials           vial           \n  viand           viand           viands          viand          \n  vic             vic             vicar           vicar          \n  vice            vice            vicegerent      viceger        \n  vicentio        vicentio        viceroy         viceroi        \n  viceroys        viceroi         vices           vice           \n  vici            vici            vicious         viciou         \n  viciousness     vicious         vict            vict           \n  victims         victim          victor          victor         \n  victoress       victoress       victories       victori        \n  victorious      victori         victors         victor         \n  victory         victori         victual         victual        \n  victuall        victual         victuals        victual        \n  videlicet       videlicet       video           video          \n  vides           vide            videsne         videsn         \n  vidi            vidi            vie             vie            \n  vied            vi              vienna          vienna         \n  view            view            viewest         viewest        \n  vieweth         vieweth         viewing         view           \n  viewless        viewless        views           view           \n  vigil           vigil           vigilance       vigil          \n  vigilant        vigil           vigitant        vigit          \n  vigour          vigour          vii             vii            \n  viii            viii            vile            vile           \n  vilely          vile            vileness        vile           \n  viler           viler           vilest          vilest         \n  vill            vill            village         villag         \n  villager        villag          villagery       villageri      \n  villages        villag          villain         villain        \n  villainies      villaini        villainous      villain        \n  villainously    villain         villains        villain        \n  villainy        villaini        villanies       villani        \n  villanous       villan          villany         villani        \n  villiago        villiago        villian         villian        \n  villianda       villianda       villians        villian        \n  vinaigre        vinaigr         vincentio       vincentio      \n  vincere         vincer          vindicative     vindic         \n  vine            vine            vinegar         vinegar        \n  vines           vine            vineyard        vineyard       \n  vineyards       vineyard        vint            vint           \n  vintner         vintner         viol            viol           \n  viola           viola           violate         violat         \n  violated        violat          violates        violat         \n  violation       violat          violator        violat         \n  violence        violenc         violent         violent        \n  violenta        violenta        violenteth      violenteth     \n  violently       violent         violet          violet         \n  violets         violet          viper           viper          \n  viperous        viper           vipers          viper          \n  vir             vir             virgilia        virgilia       \n  virgin          virgin          virginal        virgin         \n  virginalling    virginal        virginity       virgin         \n  virginius       virginiu        virgins         virgin         \n  virgo           virgo           virtue          virtu          \n  virtues         virtu           virtuous        virtuou        \n  virtuously      virtuous        visag           visag          \n  visage          visag           visages         visag          \n  visard          visard          viscount        viscount       \n  visible         visibl          visibly         visibl         \n  vision          vision          visions         vision         \n  visit           visit           visitation      visit          \n  visitations     visit           visited         visit          \n  visiting        visit           visitings       visit          \n  visitor         visitor         visitors        visitor        \n  visits          visit           visor           visor          \n  vita            vita            vitae           vita           \n  vital           vital           vitement        vitement       \n  vitruvio        vitruvio        vitx            vitx           \n  viva            viva            vivant          vivant         \n  vive            vive            vixen           vixen          \n  viz             viz             vizaments       vizament       \n  vizard          vizard          vizarded        vizard         \n  vizards         vizard          vizor           vizor          \n  vlouting        vlout           vocation        vocat          \n  vocativo        vocativo        vocatur         vocatur        \n  voce            voce            voic            voic           \n  voice           voic            voices          voic           \n  void            void            voided          void           \n  voiding         void            voke            voke           \n  volable         volabl          volant          volant         \n  volivorco       volivorco       volley          vollei         \n  volquessen      volquessen      volsce          volsc          \n  volsces         volsc           volscian        volscian       \n  volscians       volscian        volt            volt           \n  voltemand       voltemand       volubility      volubl         \n  voluble         volubl          volume          volum          \n  volumes         volum           volumnia        volumnia       \n  volumnius       volumniu        voluntaries     voluntari      \n  voluntary       voluntari       voluptuously    voluptu        \n  voluptuousness  voluptu         vomissement     vomiss         \n  vomit           vomit           vomits          vomit          \n  vor             vor             vore            vore           \n  vortnight       vortnight       vot             vot            \n  votaries        votari          votarist        votarist       \n  votarists       votarist        votary          votari         \n  votre           votr            vouch           vouch          \n  voucher         voucher         vouchers        voucher        \n  vouches         vouch           vouching        vouch          \n  vouchsaf        vouchsaf        vouchsafe       vouchsaf       \n  vouchsafed      vouchsaf        vouchsafes      vouchsaf       \n  vouchsafing     vouchsaf        voudrais        voudrai        \n  vour            vour            vous            vou            \n  voutsafe        voutsaf         vow             vow            \n  vowed           vow             vowel           vowel          \n  vowels          vowel           vowing          vow            \n  vows            vow             vox             vox            \n  voyage          voyag           voyages         voyag          \n  vraiment        vraiment        vulcan          vulcan         \n  vulgar          vulgar          vulgarly        vulgarli       \n  vulgars         vulgar          vulgo           vulgo          \n  vulnerable      vulner          vulture         vultur         \n  vultures        vultur          vurther         vurther        \n  w               w               wad             wad            \n  waddled         waddl           wade            wade           \n  waded           wade            wafer           wafer          \n  waft            waft            waftage         waftag         \n  wafting         waft            wafts           waft           \n  wag             wag             wage            wage           \n  wager           wager           wagers          wager          \n  wages           wage            wagging         wag            \n  waggish         waggish         waggling        waggl          \n  waggon          waggon          waggoner        waggon         \n  wagon           wagon           wagoner         wagon          \n  wags            wag             wagtail         wagtail        \n  wail            wail            wailful         wail           \n  wailing         wail            wails           wail           \n  wain            wain            wainropes       wainrop        \n  wainscot        wainscot        waist           waist          \n  wait            wait            waited          wait           \n  waiter          waiter          waiteth         waiteth        \n  waiting         wait            waits           wait           \n  wak             wak             wake            wake           \n  waked           wake            wakefield       wakefield      \n  waken           waken           wakened         waken          \n  wakes           wake            wakest          wakest         \n  waking          wake            wales           wale           \n  walk            walk            walked          walk           \n  walking         walk            walks           walk           \n  wall            wall            walled          wall           \n  wallet          wallet          wallets         wallet         \n  wallon          wallon          walloon         walloon        \n  wallow          wallow          walls           wall           \n  walnut          walnut          walter          walter         \n  wan             wan             wand            wand           \n  wander          wander          wanderer        wander         \n  wanderers       wander          wandering       wander         \n  wanders         wander          wands           wand           \n  wane            wane            waned           wane           \n  wanes           wane            waning          wane           \n  wann            wann            want            want           \n  wanted          want            wanteth         wanteth        \n  wanting         want            wanton          wanton         \n  wantonly        wantonli        wantonness      wanton         \n  wantons         wanton          wants           want           \n  wappen          wappen          war             war            \n  warble          warbl           warbling        warbl          \n  ward            ward            warded          ward           \n  warden          warden          warder          warder         \n  warders         warder          wardrobe        wardrob        \n  wardrop         wardrop         wards           ward           \n  ware            ware            wares           ware           \n  warily          warili          warkworth       warkworth      \n  warlike         warlik          warm            warm           \n  warmed          warm            warmer          warmer         \n  warming         warm            warms           warm           \n  warmth          warmth          warn            warn           \n  warned          warn            warning         warn           \n  warnings        warn            warns           warn           \n  warp            warp            warped          warp           \n  warr            warr            warrant         warrant        \n  warranted       warrant         warranteth      warranteth     \n  warrantise      warrantis       warrantize      warrant        \n  warrants        warrant         warranty        warranti       \n  warren          warren          warrener        warren         \n  warring         war             warrior         warrior        \n  warriors        warrior         wars            war            \n  wart            wart            warwick         warwick        \n  warwickshire    warwickshir     wary            wari           \n  was             wa              wash            wash           \n  washed          wash            washer          washer         \n  washes          wash            washford        washford       \n  washing         wash            wasp            wasp           \n  waspish         waspish         wasps           wasp           \n  wassail         wassail         wassails        wassail        \n  wast            wast            waste           wast           \n  wasted          wast            wasteful        wast           \n  wasters         waster          wastes          wast           \n  wasting         wast            wat             wat            \n  watch           watch           watched         watch          \n  watchers        watcher         watches         watch          \n  watchful        watch           watching        watch          \n  watchings       watch           watchman        watchman       \n  watchmen        watchmen        watchword       watchword      \n  water           water           waterdrops      waterdrop      \n  watered         water           waterfly        waterfli       \n  waterford       waterford       watering        water          \n  waterish        waterish        waterpots       waterpot       \n  waterrugs       waterrug        waters          water          \n  waterton        waterton        watery          wateri         \n  wav             wav             wave            wave           \n  waved           wave            waver           waver          \n  waverer         waver           wavering        waver          \n  waves           wave            waving          wave           \n  waw             waw             wawl            wawl           \n  wax             wax             waxed           wax            \n  waxen           waxen           waxes           wax            \n  waxing          wax             way             wai            \n  waylaid         waylaid         waylay          waylai         \n  ways            wai             wayward         wayward        \n  waywarder       wayward         waywardness     wayward        \n  we              we              weak            weak           \n  weaken          weaken          weakens         weaken         \n  weaker          weaker          weakest         weakest        \n  weakling        weakl           weakly          weakli         \n  weakness        weak            weal            weal           \n  wealsmen        wealsmen        wealth          wealth         \n  wealthiest      wealthiest      wealthily       wealthili      \n  wealthy         wealthi         wealtlly        wealtlli       \n  wean            wean            weapon          weapon         \n  weapons         weapon          wear            wear           \n  wearer          wearer          wearers         wearer         \n  wearied         weari           wearies         weari          \n  weariest        weariest        wearily         wearili        \n  weariness       weari           wearing         wear           \n  wearisome       wearisom        wears           wear           \n  weary           weari           weasel          weasel         \n  weather         weather         weathercock     weathercock    \n  weathers        weather         weav            weav           \n  weave           weav            weaver          weaver         \n  weavers         weaver          weaves          weav           \n  weaving         weav            web             web            \n  wed             wed             wedded          wed            \n  wedding         wed             wedg            wedg           \n  wedged          wedg            wedges          wedg           \n  wedlock         wedlock         wednesday       wednesdai      \n  weed            weed            weeded          weed           \n  weeder          weeder          weeding         weed           \n  weeds           weed            weedy           weedi          \n  week            week            weeke           week           \n  weekly          weekli          weeks           week           \n  ween            ween            weening         ween           \n  weep            weep            weeper          weeper         \n  weeping         weep            weepingly       weepingli      \n  weepings        weep            weeps           weep           \n  weet            weet            weigh           weigh          \n  weighed         weigh           weighing        weigh          \n  weighs          weigh           weight          weight         \n  weightier       weightier       weightless      weightless     \n  weights         weight          weighty         weighti        \n  weird           weird           welcom          welcom         \n  welcome         welcom          welcomer        welcom         \n  welcomes        welcom          welcomest       welcomest      \n  welfare         welfar          welkin          welkin         \n  well            well            wells           well           \n  welsh           welsh           welshman        welshman       \n  welshmen        welshmen        welshwomen      welshwomen     \n  wench           wench           wenches         wench          \n  wenching        wench           wend            wend           \n  went            went            wept            wept           \n  weraday         weradai         were            were           \n  wert            wert            west            west           \n  western         western         westminster     westminst      \n  westmoreland    westmoreland    westward        westward       \n  wet             wet             wether          wether         \n  wetting         wet             wezand          wezand         \n  whale           whale           whales          whale          \n  wharf           wharf           wharfs          wharf          \n  what            what            whate           whate          \n  whatever        whatev          whatsoe         whatso         \n  whatsoever      whatsoev        whatsome        whatsom        \n  whe             whe             wheat           wheat          \n  wheaten         wheaten         wheel           wheel          \n  wheeling        wheel           wheels          wheel          \n  wheer           wheer           wheeson         wheeson        \n  wheezing        wheez           whelk           whelk          \n  whelks          whelk           whelm           whelm          \n  whelp           whelp           whelped         whelp          \n  whelps          whelp           when            when           \n  whenas          whena           whence          whenc          \n  whencesoever    whencesoev      whene           whene          \n  whenever        whenev          whensoever      whensoev       \n  where           where           whereabout      whereabout     \n  whereas         wherea          whereat         whereat        \n  whereby         wherebi         wherefore       wherefor       \n  wherein         wherein         whereinto       whereinto      \n  whereof         whereof         whereon         whereon        \n  whereout        whereout        whereso         whereso        \n  wheresoe        whereso         wheresoever     wheresoev      \n  wheresome       wheresom        whereto         whereto        \n  whereuntil      whereuntil      whereunto       whereunto      \n  whereupon       whereupon       wherever        wherev         \n  wherewith       wherewith       wherewithal     wherewith      \n  whet            whet            whether         whether        \n  whetstone       whetston        whetted         whet           \n  whew            whew            whey            whei           \n  which           which           whiff           whiff          \n  whiffler        whiffler        while           while          \n  whiles          while           whilst          whilst         \n  whin            whin            whine           whine          \n  whined          whine           whinid          whinid         \n  whining         whine           whip            whip           \n  whipp           whipp           whippers        whipper        \n  whipping        whip            whips           whip           \n  whipster        whipster        whipstock       whipstock      \n  whipt           whipt           whirl           whirl          \n  whirled         whirl           whirligig       whirligig      \n  whirling        whirl           whirlpool       whirlpool      \n  whirls          whirl           whirlwind       whirlwind      \n  whirlwinds      whirlwind       whisp           whisp          \n  whisper         whisper         whispering      whisper        \n  whisperings     whisper         whispers        whisper        \n  whist           whist           whistle         whistl         \n  whistles        whistl          whistling       whistl         \n  whit            whit            white           white          \n  whitehall       whitehal        whitely         white          \n  whiteness       white           whiter          whiter         \n  whites          white           whitest         whitest        \n  whither         whither         whiting         white          \n  whitmore        whitmor         whitsters       whitster       \n  whitsun         whitsun         whittle         whittl         \n  whizzing        whizz           who             who            \n  whoa            whoa            whoe            whoe           \n  whoever         whoever         whole           whole          \n  wholesom        wholesom        wholesome       wholesom       \n  wholly          wholli          whom            whom           \n  whoobub         whoobub         whoop           whoop          \n  whooping        whoop           whor            whor           \n  whore           whore           whoremaster     whoremast      \n  whoremasterly   whoremasterli   whoremonger     whoremong      \n  whores          whore           whoreson        whoreson       \n  whoresons       whoreson        whoring         whore          \n  whorish         whorish         whose           whose          \n  whoso           whoso           whosoe          whoso          \n  whosoever       whosoev         why             why            \n  wi              wi              wick            wick           \n  wicked          wick            wickednes       wickedn        \n  wickedness      wicked          wicket          wicket         \n  wicky           wicki           wid             wid            \n  wide            wide            widens          widen          \n  wider           wider           widow           widow          \n  widowed         widow           widower         widow          \n  widowhood       widowhood       widows          widow          \n  wield           wield           wife            wife           \n  wight           wight           wights          wight          \n  wild            wild            wildcats        wildcat        \n  wilder          wilder          wilderness      wilder         \n  wildest         wildest         wildfire        wildfir        \n  wildly          wildli          wildness        wild           \n  wilds           wild            wiles           wile           \n  wilful          wil             wilfull         wilful         \n  wilfully        wilfulli        wilfulnes       wilfuln        \n  wilfulness      wil             will            will           \n  willed          will            willers         willer         \n  willeth         willeth         william         william        \n  williams        william         willing         will           \n  willingly       willingli       willingness     willing        \n  willoughby      willoughbi      willow          willow         \n  wills           will            wilt            wilt           \n  wiltshire       wiltshir        wimpled         wimpl          \n  win             win             wince           winc           \n  winch           winch           winchester      winchest       \n  wincot          wincot          wind            wind           \n  winded          wind            windgalls       windgal        \n  winding         wind            windlasses      windlass       \n  windmill        windmil         window          window         \n  windows         window          windpipe        windpip        \n  winds           wind            windsor         windsor        \n  windy           windi           wine            wine           \n  wing            wing            winged          wing           \n  wingfield       wingfield       wingham         wingham        \n  wings           wing            wink            wink           \n  winking         wink            winks           wink           \n  winner          winner          winners         winner         \n  winning         win             winnow          winnow         \n  winnowed        winnow          winnows         winnow         \n  wins            win             winter          winter         \n  winterly        winterli        winters         winter         \n  wip             wip             wipe            wipe           \n  wiped           wipe            wipes           wipe           \n  wiping          wipe            wire            wire           \n  wires           wire            wiry            wiri           \n  wisdom          wisdom          wisdoms         wisdom         \n  wise            wise            wiselier        wiseli         \n  wisely          wise            wiser           wiser          \n  wisest          wisest          wish            wish           \n  wished          wish            wisher          wisher         \n  wishers         wisher          wishes          wish           \n  wishest         wishest         wisheth         wisheth        \n  wishful         wish            wishing         wish           \n  wishtly         wishtli         wisp            wisp           \n  wist            wist            wit             wit            \n  witb            witb            witch           witch          \n  witchcraft      witchcraft      witches         witch          \n  witching        witch           with            with           \n  withal          withal          withdraw        withdraw       \n  withdrawing     withdraw        withdrawn       withdrawn      \n  withdrew        withdrew        wither          wither         \n  withered        wither          withering       wither         \n  withers         wither          withheld        withheld       \n  withhold        withhold        withholds       withhold       \n  within          within          withold         withold        \n  without         without         withstand       withstand      \n  withstanding    withstand       withstood       withstood      \n  witless         witless         witness         wit            \n  witnesses       wit             witnesseth      witnesseth     \n  witnessing      wit             wits            wit            \n  witted          wit             wittenberg      wittenberg     \n  wittiest        wittiest        wittily         wittili        \n  witting         wit             wittingly       wittingli      \n  wittol          wittol          wittolly        wittolli       \n  witty           witti           wiv             wiv            \n  wive            wive            wived           wive           \n  wives           wive            wiving          wive           \n  wizard          wizard          wizards         wizard         \n  wo              wo              woe             woe            \n  woeful          woeful          woefull         woeful         \n  woefullest      woefullest      woes            woe            \n  woful           woful           wolf            wolf           \n  wolfish         wolfish         wolsey          wolsei         \n  wolves          wolv            wolvish         wolvish        \n  woman           woman           womanhood       womanhood      \n  womanish        womanish        womankind       womankind      \n  womanly         womanli         womb            womb           \n  wombs           womb            womby           wombi          \n  women           women           won             won            \n  woncot          woncot          wond            wond           \n  wonder          wonder          wondered        wonder         \n  wonderful       wonder          wonderfully     wonderfulli    \n  wondering       wonder          wonders         wonder         \n  wondrous        wondrou         wondrously      wondrous       \n  wont            wont            wonted          wont           \n  woo             woo             wood            wood           \n  woodbine        woodbin         woodcock        woodcock       \n  woodcocks       woodcock        wooden          wooden         \n  woodland        woodland        woodman         woodman        \n  woodmonger      woodmong        woods           wood           \n  woodstock       woodstock       woodville       woodvil        \n  wooed           woo             wooer           wooer          \n  wooers          wooer           wooes           wooe           \n  woof            woof            wooing          woo            \n  wooingly        wooingli        wool            wool           \n  woollen         woollen         woolly          woolli         \n  woolsack        woolsack        woolsey         woolsei        \n  woolward        woolward        woos            woo            \n  wor             wor             worcester       worcest        \n  word            word            words           word           \n  wore            wore            worins          worin          \n  work            work            workers         worker         \n  working         work            workings        work           \n  workman         workman         workmanly       workmanli      \n  workmanship     workmanship     workmen         workmen        \n  works           work            worky           worki          \n  world           world           worldlings      worldl         \n  worldly         worldli         worlds          world          \n  worm            worm            worms           worm           \n  wormwood        wormwood        wormy           wormi          \n  worn            worn            worried         worri          \n  worries         worri           worry           worri          \n  worrying        worri           worse           wors           \n  worser          worser          worship         worship        \n  worshipful      worship         worshipfully    worshipfulli   \n  worshipp        worshipp        worshipper      worshipp       \n  worshippers     worshipp        worshippest     worshippest    \n  worships        worship         worst           worst          \n  worsted         worst           wort            wort           \n  worth           worth           worthied        worthi         \n  worthier        worthier        worthies        worthi         \n  worthiest       worthiest       worthily        worthili       \n  worthiness      worthi          worthless       worthless      \n  worths          worth           worthy          worthi         \n  worts           wort            wot             wot            \n  wots            wot             wotting         wot            \n  wouid           wouid           would           would          \n  wouldest        wouldest        wouldst         wouldst        \n  wound           wound           wounded         wound          \n  wounding        wound           woundings       wound          \n  woundless       woundless       wounds          wound          \n  wouns           woun            woven           woven          \n  wow             wow             wrack           wrack          \n  wrackful        wrack           wrangle         wrangl         \n  wrangler        wrangler        wranglers       wrangler       \n  wrangling       wrangl          wrap            wrap           \n  wrapp           wrapp           wraps           wrap           \n  wrapt           wrapt           wrath           wrath          \n  wrathful        wrath           wrathfully      wrathfulli     \n  wraths          wrath           wreak           wreak          \n  wreakful        wreak           wreaks          wreak          \n  wreath          wreath          wreathed        wreath         \n  wreathen        wreathen        wreaths         wreath         \n  wreck           wreck           wrecked         wreck          \n  wrecks          wreck           wren            wren           \n  wrench          wrench          wrenching       wrench         \n  wrens           wren            wrest           wrest          \n  wrested         wrest           wresting        wrest          \n  wrestle         wrestl          wrestled        wrestl         \n  wrestler        wrestler        wrestling       wrestl         \n  wretch          wretch          wretchcd        wretchcd       \n  wretched        wretch          wretchedness    wretched       \n  wretches        wretch          wring           wring          \n  wringer         wringer         wringing        wring          \n  wrings          wring           wrinkle         wrinkl         \n  wrinkled        wrinkl          wrinkles        wrinkl         \n  wrist           wrist           wrists          wrist          \n  writ            writ            write           write          \n  writer          writer          writers         writer         \n  writes          write           writhled        writhl         \n  writing         write           writings        write          \n  writs           writ            written         written        \n  wrong           wrong           wronged         wrong          \n  wronger         wronger         wrongful        wrong          \n  wrongfully      wrongfulli      wronging        wrong          \n  wrongly         wrongli         wrongs          wrong          \n  wronk           wronk           wrote           wrote          \n  wroth           wroth           wrought         wrought        \n  wrung           wrung           wry             wry            \n  wrying          wry             wt              wt             \n  wul             wul             wye             wye            \n  x               x               xanthippe       xanthipp       \n  xi              xi              xii             xii            \n  xiii            xiii            xiv             xiv            \n  xv              xv              y               y              \n  yard            yard            yards           yard           \n  yare            yare            yarely          yare           \n  yarn            yarn            yaughan         yaughan        \n  yaw             yaw             yawn            yawn           \n  yawning         yawn            ycleped         yclepe         \n  ycliped         yclipe          ye              ye             \n  yea             yea             yead            yead           \n  year            year            yearly          yearli         \n  yearn           yearn           yearns          yearn          \n  years           year            yeas            yea            \n  yeast           yeast           yedward         yedward        \n  yell            yell            yellow          yellow         \n  yellowed        yellow          yellowing       yellow         \n  yellowness      yellow          yellows         yellow         \n  yells           yell            yelping         yelp           \n  yeoman          yeoman          yeomen          yeomen         \n  yerk            yerk            yes             ye             \n  yesterday       yesterdai       yesterdays      yesterdai      \n  yesternight     yesternight     yesty           yesti          \n  yet             yet             yew             yew            \n  yicld           yicld           yield           yield          \n  yielded         yield           yielder         yielder        \n  yielders        yielder         yielding        yield          \n  yields          yield           yok             yok            \n  yoke            yoke            yoked           yoke           \n  yokefellow      yokefellow      yokes           yoke           \n  yoketh          yoketh          yon             yon            \n  yond            yond            yonder          yonder         \n  yongrey         yongrei         yore            yore           \n  yorick          yorick          york            york           \n  yorkists        yorkist         yorks           york           \n  yorkshire       yorkshir        you             you            \n  young           young           younger         younger        \n  youngest        youngest        youngling       youngl         \n  younglings      youngl          youngly         youngli        \n  younker         younker         your            your           \n  yours           your            yourself        yourself       \n  yourselves      yourselv        youth           youth          \n  youthful        youth           youths          youth          \n  youtli          youtli          zanies          zani           \n  zany            zani            zeal            zeal           \n  zealous         zealou          zeals           zeal           \n  zed             zed             zenelophon      zenelophon     \n  zenith          zenith          zephyrs         zephyr         \n  zir             zir             zo              zo             \n  zodiac          zodiac          zodiacs         zodiac         \n  zone            zone            zounds          zound          \n  zwagger         zwagger                                        \n}\n\n\nset i 0\nforeach {in out} $test_vocab {\n  do_test \"1.$i.($in -> $out)\" {\n    lindex [sqlite3_fts5_tokenize db porter $in] 0\n  } $out\n  incr i\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5porter2.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the fts5 porter stemmer implementation.\n#\n# These are extra tests added to those in fts5porter.test in order to\n# improve test coverage of the porter stemmer implementation.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5porter2\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nset test_vocab {\n  tion          tion\n  ation         ation\n  vation        vation\n  avation       avat\n  vion          vion\n  ion           ion\n  relational    relat\n  relation      relat\n  relate        relat\n  zzz           zzz\n  ii            ii\n  iiing         ii\n  xtional       xtional\n  xenci         xenci\n  xlogi         xlogi\n  realization   realiz\n  realize       realiz\n  xization      xizat\n  capitalism    capit\n  talism        talism\n  xiveness      xive\n  xfulness      xful\n  xousness      xous\n  xical         xical\n  xicate        xicat\n  xicity        xiciti\n  ies           ie\n  eed           e\n  eing           e\n  s             s\n}\n\nset i 0\nforeach {in out} $test_vocab {\n  do_test \"1.$i.($in -> $out)\" {\n    lindex [sqlite3_fts5_tokenize db porter $in] 0\n  } $out\n  incr i\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5prefix.test",
    "content": "# 2015 Jan 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests focused on prefix indexes.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5prefix\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, prefix=1);\n  INSERT INTO xx VALUES('one two three');\n  INSERT INTO xx VALUES('four five six');\n  INSERT INTO xx VALUES('seven eight nine ten');\n}\n\ndo_execsql_test 1.1 {\n  SELECT rowid FROM xx WHERE xx MATCH 't*'\n} {1 3}\n\n\n#-------------------------------------------------------------------------\n# Check that prefix indexes really do index n-character prefixes, not \n# n-byte prefixes. Use the ascii tokenizer so as not to be confused by\n# diacritic removal.\n#\ndo_execsql_test 2.0 { \n  CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize = ascii, prefix = 2) \n}\n\ndo_test 2.1 {\n  foreach {rowid string} {\n    1 \"\\xCA\\xCB\\xCC\\xCD\"\n    2 \"\\u1234\\u5678\\u4321\\u8765\"\n  } {\n    execsql { INSERT INTO t1(rowid, x) VALUES($rowid, $string) }\n  }\n} {}\n\ndo_execsql_test 2.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\nforeach {tn q res} {\n  1 \"SELECT rowid FROM t1 WHERE t1 MATCH '\\xCA\\xCB*'\" 1\n  2 \"SELECT rowid FROM t1 WHERE t1 MATCH '\\u1234\\u5678*'\" 2\n} {\n  do_execsql_test 2.3.$tn $q $res\n}\n\n#-------------------------------------------------------------------------\n# Check that prefix queries with:\n#\n#   * a column filter, and\n#   * no prefix index.\n#\n# work Ok.\n#\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(a, b, c);\n  INSERT INTO t3(t3, rank) VALUES('pgsz', 32);\n  BEGIN;\n    INSERT INTO t3 VALUES('acb ccc bba', 'cca bba bca', 'bbc ccc bca'); -- 1\n    INSERT INTO t3 VALUES('cbb cac cab', 'abb aac bba', 'aab ccc cac'); -- 2\n    INSERT INTO t3 VALUES('aac bcb aac', 'acb bcb caa', 'aca bab bca'); -- 3\n    INSERT INTO t3 VALUES('aab ccb ccc', 'aca cba cca', 'aca aac cbb'); -- 4\n    INSERT INTO t3 VALUES('bac aab bab', 'ccb bac cba', 'acb aba abb'); -- 5\n    INSERT INTO t3 VALUES('bab abc ccb', 'acb cba abb', 'cbb aaa cab'); -- 6\n    INSERT INTO t3 VALUES('cbb bbc baa', 'aab aca baa', 'bcc cca aca'); -- 7\n    INSERT INTO t3 VALUES('abc bba abb', 'cac abc cba', 'acc aac cac'); -- 8\n    INSERT INTO t3 VALUES('bbc bbc cab', 'bcb ccb cba', 'bcc cac acb'); -- 9\n  COMMIT;\n}\n\nforeach {tn match res} {\n  1 \"a : c*\" {1 2 4 6 7 9}\n  2 \"b : c*\" {1 3 4 5 6 8 9}\n  3 \"c : c*\" {1 2 4 6 7 8 9}\n  4 \"a : b*\" {1 3 5 6 7 8 9}\n  5 \"b : b*\" {1 2 3 5 7 9}\n  6 \"c : b*\" {1 3 7 9}\n  7 \"a : a*\" {1 3 4 5 6 8}\n  8 \"b : a*\" {2 3 4 6 7 8}\n  9 \"c : a*\" {2 3 4 5 6 7 8 9}\n} {\n  do_execsql_test 3.1.$tn {\n    SELECT rowid FROM t3($match)\n  } $res\n}\n\ndo_test 3.2 {\n  expr srand(0)\n  execsql { DELETE FROM t3 }\n  for {set i 0} {$i < 1000} {incr i} {\n    set a [fts5_rnddoc 3]\n    set b [fts5_rnddoc 8]\n    set c [fts5_rnddoc 20]\n    execsql { INSERT INTO t3 VALUES($a, $b, $c) }\n  }\n  execsql { INSERT INTO t3(t3) VALUES('integrity-check') }\n} {}\n\nproc gmatch {col pattern} {\n  expr {[lsearch -glob $col $pattern]>=0}\n}\ndb func gmatch gmatch\n\nproc ghl {col pattern} {\n  foreach t $col {\n    if {[string match $pattern $t]} {\n      lappend res \"*$t*\"\n    } else {\n      lappend res $t\n    }\n  }\n  set res\n}\ndb func ghl ghl\n\nset COLS(a) 0\nset COLS(b) 1\nset COLS(c) 2\n\nfor {set x 0} {$x<2} {incr x} {\n  foreach {tn pattern} {\n    1  {xa*}\n    2  {xb*}\n    3  {xc*}\n    4  {xd*}\n    5  {xe*}\n    6  {xf*}\n    7  {xg*}\n    8  {xh*}\n    9  {xi*}\n    10 {xj*}\n  } {\n    foreach col {a b c} {\n\n      # Check that the list of returned rowids is correct.\n      #\n      set res [db eval \"SELECT rowid FROM t3 WHERE gmatch($col, '$pattern')\"]\n      set query \"$col : $pattern\"\n      do_execsql_test 3.3.$x.$tn.$col.rowid {\n        SELECT rowid FROM t3($query);\n      } $res\n\n      # Check that the highlight() function works.\n      #\n      set res [db eval \\\n        \"SELECT ghl($col, '$pattern') FROM t3 WHERE gmatch($col, '$pattern')\"\n      ]\n      set idx $COLS($col)\n      do_execsql_test 3.3.$x.$tn.$col.highlight {\n        SELECT highlight(t3, $idx, '*', '*') FROM t3($query);\n      } $res\n    }\n\n    foreach colset {{a b} {b c} {c a} {a c} {b a}} {\n      # Check that the list of returned rowids is correct.\n      #\n      foreach {col1 col2} $colset {}\n      set expr \"gmatch($col1, '$pattern') OR gmatch($col2, '$pattern')\"\n      set res [db eval \"SELECT rowid FROM t3 WHERE $expr\"]\n      set query \"{$colset} : $pattern\"\n      do_execsql_test 3.3.$x.$tn.{$colset}.rowid {\n        SELECT rowid FROM t3($query);\n      } $res\n\n      set resq    \"SELECT ghl($col1, '$pattern'), ghl($col2, '$pattern')\"\n      append resq \" FROM t3 WHERE $expr\"\n      set res [db eval $resq]\n      set idx1 $COLS($col1)\n      set idx2 $COLS($col2)\n      do_execsql_test 3.3.$x.$tn.{$colset}.highlight {\n        SELECT highlight(t3, $idx1, '*', '*'), highlight(t3, $idx2, '*', '*')\n          FROM t3($query)\n      } $res\n    }\n  }\n  execsql { INSERT INTO t3(t3) VALUES('optimize') }\n  execsql { INSERT INTO t3(t3) VALUES('integrity-check') }\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(c1, c2);\n  INSERT INTO t2 VALUES('xa xb', 'xb xa');\n\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 2\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 4\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 8\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 16\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 32\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 64\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 128\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 256\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 512\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 1024\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 2048\n  INSERT INTO t2 SELECT c1||' '||c1, c2||' '||c2 FROM t2; -- 4096\n\n  SELECT count(*) FROM t2('x*');\n} {4096}\n\ndo_execsql_test 4.1 {\n  UPDATE t2 SET c2 = 'ya yb';\n  SELECT count(*) FROM t2('c1:x*');\n  SELECT count(*) FROM t2('c2:x*');\n} {4096 0}\n\ndo_execsql_test 4.2 {\n  UPDATE t2 SET c2 = 'xa';\n  SELECT count(*) FROM t2('c1:x*');\n  SELECT count(*) FROM t2('c2:x*');\n} {4096 4096}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nproc rnddoc {n} {\n  set map [list a b c d]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc \"x[lindex $map [expr int(rand()*4)]]\"\n  }\n  set doc\n}\nset cols [list]\nfor {set i 1} {$i<250} {incr i} { \n  lappend cols \"c$i\" \n  lappend vals \"'[rnddoc 10]'\"\n}\n\ndo_test 5.0 {\n  execsql \"CREATE VIRTUAL TABLE t4 USING fts5([join $cols ,])\"\n  execsql {INSERT INTO t4(t4, rank) VALUES('pgsz', 32)}\n  execsql \"INSERT INTO t4 VALUES([join $vals ,])\"\n  execsql \"INSERT INTO t4 VALUES([join $vals ,])\"\n  execsql \"INSERT INTO t4 VALUES([join $vals ,])\"\n  execsql \"INSERT INTO t4 VALUES([join $vals ,])\"\n} {}\n\nproc gmatch {col pattern} {\n  expr {[lsearch -glob $col $pattern]>=0}\n}\ndb func gmatch gmatch\nforeach {tn col pattern} {\n  1 c100 {xa*}\n  2 c200 {xb*}\n} {\n  set res [db eval \"SELECT rowid FROM t4 WHERE gmatch($col, \\$pattern)\"]\n  set query \"$col : $pattern\"\n  do_execsql_test 5.$tn { SELECT rowid FROM t4($query) } $res\n}\n\nreset_db\ndb func fts5_rnddoc fts5_rnddoc\ndo_test 6.0 {\n  execsql {\n    CREATE VIRTUAL TABLE t5 USING fts5(x, y);\n    INSERT INTO t5 VALUES( fts5_rnddoc(10000), fts5_rnddoc(10000) );\n    INSERT INTO t5 VALUES( fts5_rnddoc(10000), fts5_rnddoc(10000) );\n    INSERT INTO t5 VALUES( fts5_rnddoc(10000), fts5_rnddoc(10000) );\n    INSERT INTO t5 VALUES( fts5_rnddoc(10000), fts5_rnddoc(10000) );\n  }\n} {}\n\nproc gmatch {col pattern} {\n  expr {[lsearch -glob $col $pattern]>=0}\n}\ndb func gmatch gmatch\nforeach {tn col pattern} {\n  1 y {xa*}\n  2 y {xb*}\n  3 y {xc*}\n  4 x {xa*}\n  5 x {xb*}\n  6 x {xc*}\n} {\n  set res [db eval \"SELECT rowid FROM t5 WHERE gmatch($col, \\$pattern)\"]\n  set query \"$col : $pattern\"\n  do_execsql_test 6.$tn { SELECT rowid FROM t5($query) } $res\n}\n\n#-------------------------------------------------------------------------\n# Check that the various ways of creating prefix indexes produce the\n# same database on disk.\n#\nsave_prng_state\nforeach {tn create} {\n  1 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix=\"1,2,3\") }\n  2 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix=\"1 2 3\") }\n  3 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix=1, prefix=2, prefix=3) }\n  4 { CREATE VIRTUAL TABLE tt USING fts5(x, y, prefix=\"1 2\", prefix=3) }\n} {\n  execsql { DROP TABLE IF EXISTS tt }\n  restore_prng_state\n  execsql $create\n  execsql {\n    INSERT INTO tt VALUES('cc b ggg ccc aa eee hh', 'aa g b hh a e');\n    INSERT INTO tt VALUES('cc bb cc gg j g cc', 'ii jjj ggg jjj cc cc');\n    INSERT INTO tt VALUES('h eee cc h iii', 'aaa iii dd iii dd');\n    INSERT INTO tt VALUES('jjj hh eee c e b gg', 'j bbb jj ddd jj');\n    INSERT INTO tt VALUES('ii hhh aaa ff c hhh iii', 'j cc hh bb e');\n    INSERT INTO tt VALUES('e fff hhh i aaa', 'g b aa gg c aa dd');\n    INSERT INTO tt VALUES('i aaa ccc gg hhh aa h', 'j bbb bbb d ff');\n    INSERT INTO tt VALUES('g f gg ff ff jjj d', 'jjj d j fff fff ee j');\n    INSERT INTO tt VALUES('a cc e ccc jjj c', 'ccc iii d bb a eee g');\n    INSERT INTO tt VALUES('jj hh hh bb bbb gg', 'j c jjj bb iii f');\n    INSERT INTO tt VALUES('a ggg g cc ccc aa', 'jjj j j aaa c');\n    INSERT INTO tt VALUES('ddd j dd b i', 'aaa bbb iii ggg ff ccc ddd');\n    INSERT INTO tt VALUES('jj ii hh c ii h gg', 'hhh bbb ddd bbb hh g ggg');\n    INSERT INTO tt VALUES('aa hhh ccc h ggg ccc', 'iii d jj a ff ii');\n  }\n\n  #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM tt_data} {puts $r}\n\n  if {$tn==1} {\n    set ::checksum [execsql {SELECT md5sum(id, block) FROM tt_data}]\n  } else {\n    do_execsql_test 7.$tn {\n      SELECT md5sum(id, block) FROM tt_data\n    } [list $::checksum]\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5query.test",
    "content": "# 2015 October 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5query\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nfor {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} {\n  reset_db\n  do_test 1.$tn.1 {\n    execsql {\n      CREATE VIRTUAL TABLE t1 USING fts5(x);\n      INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz);\n      BEGIN;\n    }\n    foreach x [list aaa bbb ccc ddd eee fff ggg hhh iii jjj] {\n      set doc [string repeat \"$x \" 30]\n      execsql { INSERT INTO t1 VALUES($doc) }\n    }\n    execsql COMMIT\n  } {}\n\n  do_execsql_test 1.$tn.2 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  set ret 1\n  foreach x [list a b c d e f g h i j] {\n    do_execsql_test 1.$tn.3.$ret {\n      SELECT rowid FROM t1 WHERE t1 MATCH $x || '*';\n    } $ret\n    incr ret\n  }\n}\n\nfor {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} {\n  reset_db\n  do_test 2.$tn.1 {\n    execsql {\n      CREATE VIRTUAL TABLE t1 USING fts5(x);\n      INSERT INTO t1(t1, rank) VALUES('pgsz', $pgsz);\n      BEGIN;\n    }\n    foreach x [list bbb ddd fff hhh jjj lll nnn ppp rrr ttt] {\n      set doc [string repeat \"$x \" 30]\n      execsql { INSERT INTO t1 VALUES($doc) }\n    }\n    execsql COMMIT\n  } {}\n\n  do_execsql_test 1.$tn.2 {\n    INSERT INTO t1(t1) VALUES('integrity-check');\n  }\n\n  set ret 1\n  foreach x [list a c e g i k m o q s u] {\n    do_execsql_test 2.$tn.3.$ret {\n      SELECT rowid FROM t1 WHERE t1 MATCH $x || '*';\n    } {}\n    incr ret\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5rank.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file focuses on testing queries that use the \"rank\" column.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5rank\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------------\n# \"ORDER BY rank\" + highlight() + large poslists.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE xyz USING fts5(z);\n}\ndo_test 1.1 {\n  set doc [string trim [string repeat \"x y \" 500]]\n  execsql { INSERT INTO xyz VALUES($doc) }\n} {}\ndo_execsql_test 1.2 {\n  SELECT highlight(xyz, 0, '[', ']') FROM xyz WHERE xyz MATCH 'x' ORDER BY rank\n} [list [string map {x [x]} $doc]]\n\ndo_execsql_test 1.3 {\n  SELECT highlight(xyz, 0, '[', ']') FROM xyz\n  WHERE xyz MATCH 'x AND y' ORDER BY rank\n} [list [string map {x [x] y [y]} $doc]]\n\n#-------------------------------------------------------------------------\n# Check that the 'rank' option really is persistent.\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(a);\n  INSERT INTO tt VALUES('a x x x x');\n  INSERT INTO tt VALUES('x x a a a');\n  INSERT INTO tt VALUES('x a a x x');\n}\n\nproc firstinst {cmd} { \n  foreach {p c o} [$cmd xInst 0] {}\n  return $o\n}\nsqlite3_fts5_create_function db firstinst firstinst\n\ndo_execsql_test 2.1 {\n  SELECT rowid FROM tt('a') ORDER BY rank;\n} {2 3 1}\n\ndo_execsql_test 2.2 {\n  SELECT rowid FROM tt('a', 'firstinst()') ORDER BY rank;\n} {1 3 2}\n\ndo_execsql_test 2.3 {\n  INSERT INTO tt(tt, rank) VALUES('rank', 'firstinst()');\n  SELECT rowid FROM tt('a') ORDER BY rank;\n} {1 3 2}\n\ndo_test 2.4 {\n  sqlite3 db2 test.db\n  catchsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2\n} {1 {no such function: firstinst}}\n\ndo_test 2.5 {\n  db2 close\n  sqlite3 db2 test.db\n  sqlite3_fts5_create_function db2 firstinst firstinst\n  execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2\n} {1 3 2}\n\ndo_test 2.6 {\n  execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db2\n} {1 3 2}\n\ndo_test 2.7 {\n  execsql { SELECT rowid FROM tt('a') ORDER BY rank; } db\n} {1 3 2}\n\ndb2 close\n\n#--------------------------------------------------------------------------\n# At one point there was a problem with queries such as:\n#\n#   ... MATCH 'x OR y' ORDER BY rank;\n#\n# if there were zero occurrences of token 'y' in the dataset. The\n# following tests verify that that problem has been addressed.\n#\nforeach_detail_mode $::testprefix {\n  do_execsql_test 3.1.0 {\n    CREATE VIRTUAL TABLE y1 USING fts5(z, detail=%DETAIL%);\n    INSERT INTO y1 VALUES('test xyz');\n    INSERT INTO y1 VALUES('test test xyz test');\n    INSERT INTO y1 VALUES('test test xyz');\n  }\n\n  do_execsql_test 3.1.1 {\n    SELECT rowid FROM y1('test OR tset');\n  } {1 2 3}\n\n  do_execsql_test 3.1.2 {\n    SELECT rowid FROM y1('test OR tset') ORDER BY bm25(y1)\n  } {2 3 1}\n\n  do_execsql_test 3.1.3 {\n    SELECT rowid FROM y1('test OR tset') ORDER BY +rank\n  } {2 3 1}\n\n  do_execsql_test 3.1.4 {\n    SELECT rowid FROM y1('test OR tset') ORDER BY rank\n  } {2 3 1}\n\n  do_execsql_test 3.1.5 {\n    SELECT rowid FROM y1('test OR xyz') ORDER BY rank\n  } {3 2 1}\n\n\n  do_execsql_test 3.2.1 {\n    CREATE VIRTUAL TABLE z1 USING fts5(a, detail=%DETAIL%);\n    INSERT INTO z1 VALUES('wrinkle in time');\n    SELECT * FROM z1 WHERE z1 MATCH 'wrinkle in time OR a wrinkle in time';\n  } {{wrinkle in time}}\n}\n\ndo_execsql_test 4.1 {\n  DROP TABLE IF EXISTS VTest;\n  CREATE virtual TABLE VTest USING FTS5(\n    Title, AUthor, tokenize ='porter unicode61 remove_diacritics 1', \n    columnsize='1', detail=full\n  );\n  INSERT INTO VTest (Title, Author) VALUES ('wrinkle in time', 'Bill Smith');\n\n  SELECT * FROM VTest WHERE \n  VTest MATCH 'wrinkle in time OR a wrinkle in time' ORDER BY rank;\n} {{wrinkle in time} {Bill Smith}}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5rebuild.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5rebuild\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE f1 USING fts5(a, b);\n  INSERT INTO f1(a, b) VALUES('one',   'o n e');\n  INSERT INTO f1(a, b) VALUES('two',   't w o');\n  INSERT INTO f1(a, b) VALUES('three', 't h r e e');\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO f1(f1) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 1.3 {\n  INSERT INTO f1(f1) VALUES('rebuild');\n} {}\n\ndo_execsql_test 1.4 {\n  INSERT INTO f1(f1) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 1.5 {\n  DELETE FROM f1_data;\n} {}\n\ndo_catchsql_test 1.6 {\n  INSERT INTO f1(f1) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\ndo_execsql_test 1.7 {\n  INSERT INTO f1(f1) VALUES('rebuild');\n  INSERT INTO f1(f1) VALUES('integrity-check');\n} {}\n\n\n#-------------------------------------------------------------------------\n# Check that 'rebuild' may not be used with a contentless table.\n#\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE nc USING fts5(doc, content=);\n}\n\ndo_catchsql_test 2.2 {\n  INSERT INTO nc(nc) VALUES('rebuild');\n} {1 {'rebuild' may not be used with a contentless fts5 table}}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5restart.test",
    "content": "# 2015 April 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file focuses on testing the planner (xBestIndex function).\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5restart\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE f1 USING fts5(ff);\n}\n\n#-------------------------------------------------------------------------\n# Run the 'optimize' command. Check that it does not disturb ongoing\n# full-text queries.\n#\ndo_test 1.1 {\n  for {set i 1} {$i < 1000} {incr i} {\n    execsql { INSERT INTO f1 VALUES('a b c d e') }\n    lappend lRowid $i\n  }\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT rowid FROM f1 WHERE f1 MATCH 'c';\n} $lRowid\n\ndo_test 1.3 {\n  set res [list]\n  db eval { SELECT rowid FROM f1 WHERE f1 MATCH 'c' } {\n    if {$rowid == 100} {\n      execsql { INSERT INTO f1(f1) VALUES('optimize') }\n    }\n    lappend res $rowid\n  }\n  set res\n} $lRowid\n\ndo_test 1.4.1 {\n  sqlite3 db2 test.db\n  set res [list]\n  db2 eval { SELECT rowid FROM f1 WHERE f1 MATCH 'c' } {\n    if {$rowid == 100} {\n      set cres [catchsql { INSERT INTO f1(f1) VALUES('optimize') }]\n    }\n    lappend res $rowid\n  }\n  set res\n} $lRowid\n\ndo_test 1.4.2 {\n  db2 close\n  set cres\n} {1 {database is locked}}\n\n#-------------------------------------------------------------------------\n# Open a couple of cursors. Then close them in the same order.\n#\ndo_test 2.1 {\n  set ::s1 [sqlite3_prepare db \"SELECT rowid FROM f1 WHERE f1 MATCH 'b'\" -1 X]\n  set ::s2 [sqlite3_prepare db \"SELECT rowid FROM f1 WHERE f1 MATCH 'c'\" -1 X]\n\n  sqlite3_step $::s1\n} {SQLITE_ROW}\ndo_test 2.2 {\n  sqlite3_step $::s2\n} {SQLITE_ROW}\n\ndo_test 2.1 {\n  sqlite3_finalize $::s1\n  sqlite3_finalize $::s2\n} {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# Copy data between two FTS5 tables.\n#\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE f2 USING fts5(gg);\n  INSERT INTO f2 SELECT ff FROM f1 WHERE f1 MATCH 'b+c+d';\n}\ndo_execsql_test 3.2 {\n  SELECT rowid FROM f2 WHERE f2 MATCH 'a+b+c+d+e'\n} $lRowid\n\n#-------------------------------------------------------------------------\n# Remove the row that an FTS5 cursor is currently pointing to. And \n# various other similar things. Check that this does not disturb \n# ongoing scans.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE n4 USING fts5(n);\n  INSERT INTO n4(rowid, n) VALUES(100, '1 2 3 4 5');\n  INSERT INTO n4(rowid, n) VALUES(200, '1 2 3 4');\n  INSERT INTO n4(rowid, n) VALUES(300, '2 3 4');\n  INSERT INTO n4(rowid, n) VALUES(400, '2 3');\n  INSERT INTO n4(rowid, n) VALUES(500, '3');\n}\n\ndo_test 4.1 {\n  set res [list]\n  db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' } {\n    if {$rowid==300} {\n      execsql { DELETE FROM n4 WHERE rowid=300 }\n    }\n    lappend res $rowid\n  }\n  set res\n} {100 200 300 400 500}\n\ndo_test 4.2 {\n  execsql { INSERT INTO n4(rowid, n) VALUES(300, '2 3 4') }\n  set res [list]\n  db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' ORDER BY rowid DESC} {\n    if {$rowid==300} {\n      execsql { DELETE FROM n4 WHERE rowid=300 }\n    }\n    lappend res $rowid\n  }\n  set res\n} {500 400 300 200 100}\n\ndo_test 4.3 {\n  execsql { INSERT INTO n4(rowid, n) VALUES(300, '2 3 4') }\n  set res [list]\n  db eval { SELECT rowid FROM n4 WHERE n4 MATCH '3' ORDER BY rowid DESC} {\n    if {$rowid==300} {\n      execsql { DELETE FROM n4  }\n    }\n    lappend res $rowid\n  }\n  set res\n} {500 400 300}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5rowid.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests of the scalar fts5_rowid() and fts5_decode() functions.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5rowid\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_catchsql_test 1.1 {\n  SELECT fts5_rowid()\n} {1 {should be: fts5_rowid(subject, ....)}}\n\ndo_catchsql_test 1.2 {\n  SELECT fts5_rowid('segment')\n} {1 {should be: fts5_rowid('segment', segid, pgno))}}\n\ndo_execsql_test 1.3 {\n  SELECT fts5_rowid('segment', 1, 1)\n} {137438953473}\n\ndo_catchsql_test 1.4 {\n  SELECT fts5_rowid('nosucharg');\n} {1 {first arg to fts5_rowid() must be 'segment'}} \n\n\n#-------------------------------------------------------------------------\n# Tests of the fts5_decode() function.\n#\nreset_db\ndo_execsql_test 2.1 { \n  CREATE VIRTUAL TABLE x1 USING fts5(a, b);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n} {}\n\nproc rnddoc {n} {\n  set map [list 0 a  1 b  2 c  3 d  4 e  5 f  6 g  7 h  8 i  9 j]\n  set doc [list]\n  for {set i 0} {$i < $n} {incr i} {\n    lappend doc [string map $map [format %.3d [expr int(rand()*100)]]]\n  }\n  set doc\n}\ndb func rnddoc rnddoc\n\ndo_execsql_test 2.2 {\n  WITH r(a, b) AS (\n    SELECT rnddoc(6), rnddoc(6) UNION ALL\n    SELECT rnddoc(6), rnddoc(6) FROM r\n  )\n  INSERT INTO x1 SELECT * FROM r LIMIT 10000;\n  DELETE FROM x1 WHERE (rowid%2);\n}\n\nset res [db one {SELECT count(*) FROM x1_data}]\ndo_execsql_test 2.3 {\n  SELECT count(fts5_decode(rowid, block)) FROM x1_data;\n} $res\ndo_execsql_test 2.4 {\n  UPDATE x1_data SET block = X'';\n  SELECT count(fts5_decode(rowid, block)) FROM x1_data;\n} $res\n\ndo_execsql_test 2.5 {\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 1024);\n  INSERT INTO x1(x1) VALUES('rebuild');\n}\n\nset res [db one {SELECT count(*) FROM x1_data}]\ndo_execsql_test 2.6 {\n  SELECT count(fts5_decode(rowid, block)) FROM x1_data;\n} $res\n\n# This is really a corruption test...\n#do_execsql_test 2.7 {\n#  UPDATE x1_data SET block = X'';\n#  SELECT count(fts5_decode(rowid, block)) FROM x1_data;\n#} $res\n\ndo_execsql_test 2.8 {\n  SELECT fts5_decode(fts5_rowid('segment', 1000, 1), X'AB')\n} {corrupt}\n\n#-------------------------------------------------------------------------\n# Tests with very large tokens.\n#\nset strlist [list \\\n  \"[string repeat x 400]\"                       \\\n  \"[string repeat x 300][string repeat w 100]\"  \\\n  \"[string repeat x 300][string repeat y 100]\"  \\\n  \"[string repeat x 300][string repeat z 600]\"  \\\n]\ndo_test 3.0 {\n  execsql {\n    BEGIN;\n    CREATE VIRTUAL TABLE x2 USING fts5(a);\n  }\n  foreach str $strlist { execsql { INSERT INTO x2 VALUES($str) } }\n  execsql COMMIT\n} {}\n\nfor {set tn 0} {$tn<[llength $strlist]} {incr tn} {\n  set str [lindex $strlist $tn]\n  do_execsql_test 3.1.$tn {\n    SELECT rowid FROM x2 WHERE x2 MATCH $str\n  } [expr $tn+1]\n}\n\nset res [db one {SELECT count(*) FROM x2_data}]\ndo_execsql_test 3.2 {\n  SELECT count(fts5_decode(rowid, block)) FROM x2_data;\n} $res\n\n#-------------------------------------------------------------------------\n# Leaf pages with no terms or rowids at all.\n#\nset strlist [list \\\n  \"[string repeat {w } 400]\"  \\\n  \"[string repeat {x } 400]\"  \\\n  \"[string repeat {y } 400]\"  \\\n  \"[string repeat {z } 400]\"  \\\n]\ndo_test 4.0 {\n  execsql {\n    BEGIN;\n    CREATE VIRTUAL TABLE x3 USING fts5(a);\n    INSERT INTO x3(x3, rank) VALUES('pgsz', 32);\n  }\n  foreach str $strlist { execsql { INSERT INTO x3 VALUES($str) } }\n  execsql COMMIT\n} {}\n\nfor {set tn 0} {$tn<[llength $strlist]} {incr tn} {\n  set str [lindex $strlist $tn]\n  do_execsql_test 4.1.$tn {\n    SELECT rowid FROM x3 WHERE x3 MATCH $str\n  } [expr $tn+1]\n}\n\nset res [db one {SELECT count(*) FROM x3_data}]\ndo_execsql_test 4.2 {\n  SELECT count(fts5_decode(rowid, block)) FROM x3_data;\n} $res\n\n#-------------------------------------------------------------------------\n# Position lists with large values.\n#\nset strlist [list \\\n  \"[string repeat {w } 400]a\"  \\\n  \"[string repeat {x } 400]a\"  \\\n  \"[string repeat {y } 400]a\"  \\\n  \"[string repeat {z } 400]a\"  \\\n]\ndo_test 5.0 {\n  execsql {\n    BEGIN;\n    CREATE VIRTUAL TABLE x4 USING fts5(a);\n    INSERT INTO x4(x4, rank) VALUES('pgsz', 32);\n  }\n  foreach str $strlist { execsql { INSERT INTO x4 VALUES($str) } }\n  execsql COMMIT\n} {}\n\ndo_execsql_test 5.1 {\n  SELECT rowid FROM x4 WHERE x4 MATCH 'a'\n} {1 2 3 4}\n\nset res [db one {SELECT count(*) FROM x4_data}]\ndo_execsql_test 5.2 {\n  SELECT count(fts5_decode(rowid, block)) FROM x4_data;\n} $res\n\n#-------------------------------------------------------------------------\n#\n\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE x5 USING fts5(x, detail=none);\n  INSERT INTO x5(x5, rank) VALUES('pgsz', 32);\n  INSERT INTO x5 VALUES('a b c d e f');\n  INSERT INTO x5 VALUES('a b c d e f');\n  INSERT INTO x5 VALUES('a b c d e f');\n  BEGIN;\n    WITH s(i) AS (\n      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100\n    ) INSERT INTO x5 SELECT 'a b c d e f' FROM s;\n  COMMIT;\n  SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;\n} {32}\n\ndo_execsql_test 6.1 {\n  DELETE FROM x5 WHERE rowid <= 2;\n  SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;\n} {34}\n\ndo_execsql_test 6.2 {\n  UPDATE x5 SET x='a b c d e f' WHERE rowid=3;\n  SELECT count(fts5_decode_none(rowid, block)) FROM x5_data;\n} {36}\n\n#db eval {SELECT rowid, fts5_decode_none(rowid, block) aS r FROM x5_data} {puts $r}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5simple.test",
    "content": "# 2015 September 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5simple\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nif 1 {\n\n#-------------------------------------------------------------------------\n#\nset doc \"x x [string repeat {y } 50]z z\"\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  BEGIN;\n    INSERT INTO t1 VALUES($doc);\n  COMMIT;\n}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  INSERT INTO t1 VALUES('a b c');\n  INSERT INTO t1 VALUES('d e f');\n  INSERT INTO t1(t1) VALUES('optimize');\n}\n\ndo_execsql_test 2.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, prefix='1,2');\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  BEGIN;\n  INSERT INTO t1 VALUES('one');\n  SELECT * FROM t1 WHERE t1 MATCH 'o*';\n} {one}\n\ndo_execsql_test 3.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE t11 USING fts5(content);\n  INSERT INTO t11(t11, rank) VALUES('pgsz', 32);\n  INSERT INTO t11 VALUES('another');\n  INSERT INTO t11 VALUES('string');\n  INSERT INTO t11 VALUES('of');\n  INSERT INTO t11 VALUES('text');\n}\ndo_test 4.2 {\n  execsql { INSERT INTO t11(t11) VALUES('optimize') }\n} {}\ndo_execsql_test 4.3 {\n  INSERT INTO t11(t11) VALUES('integrity-check');\n} {}\n\n#db eval { SELECT fts5_decode(rowid, block) as x FROM t11_data } { puts $x }\n\n#-------------------------------------------------------------------------\nreset_db\nset doc [string repeat \"x y \" 5]\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE yy USING fts5(content);\n  INSERT INTO yy(yy, rank) VALUES('pgsz', 32);\n  BEGIN;\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n    INSERT INTO yy VALUES($doc);\n  COMMIT;\n}\n\ndo_execsql_test 5.2 {\n  SELECT rowid FROM yy WHERE yy MATCH 'y' ORDER BY rowid ASC\n} {1 2 3 4 5 6 7 8}\n\ndo_execsql_test 5.3 {\n  SELECT rowid FROM yy WHERE yy MATCH 'y' ORDER BY rowid DESC\n} {8 7 6 5 4 3 2 1}\n\n#db eval { SELECT fts5_decode(rowid, block) as x FROM yy_data } { puts $x }\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE tt USING fts5(content);\n  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n  INSERT INTO tt VALUES('aa');\n}\n\ndo_execsql_test 5.2 {\n  SELECT rowid FROM tt WHERE tt MATCH 'a*';\n} {1}\n\ndo_execsql_test 5.3 {\n  DELETE FROM tt;\n  BEGIN;\n    INSERT INTO tt VALUES('aa');\n    INSERT INTO tt VALUES('ab');\n  COMMIT;\n} {}\n\ndo_execsql_test 5.4 {\n  SELECT rowid FROM tt WHERE tt MATCH 'a*';\n} {1 2}\n\ndo_execsql_test 5.5 {\n  DELETE FROM tt;\n  BEGIN;\n    INSERT INTO tt VALUES('aa');\n    INSERT INTO tt VALUES('ab');\n    INSERT INTO tt VALUES('aa');\n    INSERT INTO tt VALUES('ab');\n    INSERT INTO tt VALUES('aa');\n    INSERT INTO tt VALUES('ab');\n    INSERT INTO tt VALUES('aa');\n    INSERT INTO tt VALUES('ab');\n  COMMIT;\n  SELECT rowid FROM tt WHERE tt MATCH 'a*';\n} {1 2 3 4 5 6 7 8}\n\ndo_execsql_test 5.6 {\n  INSERT INTO tt(tt) VALUES('integrity-check');\n}\n\nreset_db\ndo_execsql_test 5.7 {\n  CREATE VIRTUAL TABLE tt USING fts5(content);\n  INSERT INTO tt(tt, rank) VALUES('pgsz', 32);\n  INSERT INTO tt VALUES('aa ab ac ad ae af');\n}\n\ndo_execsql_test 5.8 {\n  SELECT rowid FROM tt WHERE tt MATCH 'a*';\n} {1}\n\n#-------------------------------------------------------------------------\n\nreset_db\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE xyz USING fts5(x, y, z);\n  INSERT INTO xyz VALUES('x', 'y', 'z');\n}\n\ndo_catchsql_test 6.2 { \n  SELECT * FROM xyz WHERE xyz MATCH '' \n} {1 {fts5: syntax error near \"\"}}\ndo_catchsql_test 6.3 { \n  SELECT * FROM xyz WHERE xyz MATCH NULL \n} {1 {fts5: syntax error near \"\"}}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(content);\n  INSERT INTO ft2(rowid, content) VALUES(1, 'a b c');\n  INSERT INTO ft2(rowid, content) VALUES(2, 'a b d');\n} \n\ndo_catchsql_test 7.2 {\n  BEGIN;\n    UPDATE ft2 SET rowid=2 WHERE rowid=1;\n} {1 {constraint failed}} \n\ndo_execsql_test 7.3 {\n  COMMIT;\n  INSERT INTO ft2(ft2) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 7.4 {\n  SELECT * FROM ft2;\n} {{a b c} {a b d}}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(content);\n  INSERT INTO ft2(rowid, content) VALUES(1, 'a b');\n}\n\ndo_execsql_test 8.2 {\n  BEGIN;\n    INSERT INTO ft2(rowid, content) VALUES(4, 'a x');\n}\n\ndo_execsql_test 8.3 {\n  INSERT INTO ft2(ft2) VALUES('integrity-check');\n}\n\n#-------------------------------------------------------------------------\n# Check that the \"table function\" syntax works.\n#\nreset_db\ndo_execsql_test 9.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(content);\n  INSERT INTO ft2(rowid, content) VALUES(1, 'a b');\n  INSERT INTO ft2(rowid, content) VALUES(2, 'a b c d');\n  INSERT INTO ft2(rowid, content) VALUES(3, 'c d e f');\n}\n\ndo_execsql_test 9.2 {\n  SELECT rowid FROM ft2('a');\n} {1 2}\n\ndo_execsql_test 9.3 {\n  SELECT rowid FROM ft2('b AND c');\n} {2}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 10.0 {\n  CREATE VIRTUAL TABLE t3 USING fts5(a, b, c);\n  INSERT INTO t3 VALUES('bac aab bab', 'c bac c', 'acb aba abb'); -- 1\n  INSERT INTO t3 VALUES('bab abc c', 'acb c abb', 'c aaa c');     -- 2\n}\n\ndo_execsql_test 10.1 {\n  SELECT rowid FROM t3('c: c*');\n} {2}\n\ndo_execsql_test 10.2 {\n  SELECT rowid FROM t3('b: acb');\n} {2}\n\n#-------------------------------------------------------------------------\n# Test that character 0x1A is allowed in fts5 barewords.\n#\ndo_test 11.0 {\n  execsql \"CREATE VIRTUAL TABLE t4 USING fts5(x, tokenize=\\\"ascii tokenchars '\\x1A'\\\")\"\n  execsql \"\n    INSERT INTO t4 VALUES('a b c \\x1A');\n    INSERT INTO t4 VALUES('a b c d\\x1A');\n    INSERT INTO t4 VALUES('a b c \\x1Ag');\n    INSERT INTO t4 VALUES('a b c d');\n  \"\n} {}\n\ndo_test 11.1 {\n  execsql \"SELECT rowid FROM t4('\\x1A')\"\n} {1}\ndo_test 11.2 {\n  execsql \"SELECT rowid FROM t4('\\x1A*')\"\n} {1 3}\ndo_test 11.3 {\n  execsql \"SELECT rowid FROM t4('d\\x1A')\"\n} {2}\n\ndo_test 11.4 {\n  catchsql \"SELECT rowid FROM t4('d\\x1B')\"\n} {/fts5: syntax error/}\ndo_test 11.5 {\n  catchsql \"SELECT rowid FROM t4('d\\x19')\"\n} {/fts5: syntax error/}\n\n#-------------------------------------------------------------------------\n#\ndo_test 12.1 {\n  execsql {\n    CREATE VIRTUAL TABLE xx USING fts5(x,y);\n    BEGIN;\n      INSERT INTO xx VALUES('1 2 3', 'a b c');\n  }\n} {}\n\ndo_execsql_test 12.2 {\n  SELECT rowid FROM xx('x:a');\n  COMMIT;\n} {}\n\n#-------------------------------------------------------------------------\n# Try an UPDATE OR REPLACE query.\n#\ndo_execsql_test 13.1 {\n  CREATE VIRTUAL TABLE xy USING fts5(x);\n  INSERT INTO xy(rowid, x) VALUES(1, '1 2 3');\n  INSERT INTO xy(rowid, x) VALUES(2, '2 3 4');\n  INSERT INTO xy(rowid, x) VALUES(3, '3 4 5');\n}\n\ndo_execsql_test 13.2 {\n  UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2;\n  SELECT rowid, x FROM xy;\n} {\n  1 {1 2 3}\n  3 {2 3 4}\n}\n\ndo_execsql_test 13.3 {\n  INSERT INTO xy(xy) VALUES('integrity-check');\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 14.1 {\n  CREATE VIRTUAL TABLE ttt USING fts5(x);\n  BEGIN;\n    INSERT INTO ttt(rowid, x) VALUES(1, 'a b c');\n    INSERT INTO ttt(rowid, x) VALUES(2, 'a b c');\n    INSERT INTO ttt(rowid, x) VALUES(3, 'a b c');\n  COMMIT;\n}\ndo_test 14.2 { \n  fts5_level_segs ttt \n} {1}\n\n#-------------------------------------------------------------------------\ndb func rnddoc fts5_rnddoc\ndo_execsql_test 14.3 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n\n  WITH ii(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM ii WHERE i<10 )\n  INSERT INTO x1 SELECT rnddoc(5) FROM ii;\n}\n\ndo_execsql_test 14.4 {\n  SELECT rowid, x, x1 FROM x1 WHERE x1 MATCH '*reads'\n} {0 {} 3}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 15.0 {\n  CREATE VIRTUAL TABLE x2 USING fts5(x, prefix=1);\n  INSERT INTO x2 VALUES('ab');\n}\n\ndo_execsql_test 15.1 {\n  INSERT INTO x2(x2) VALUES('integrity-check');\n}\n\n#-------------------------------------------------------------------------\nforeach_detail_mode $testprefix {\n  reset_db\n  fts5_aux_test_functions db\n  do_execsql_test 16.0 {\n    CREATE VIRTUAL TABLE x3 USING fts5(x, detail=%DETAIL%);\n    INSERT INTO x3 VALUES('a b c d e f');\n  }\n  do_execsql_test 16.1 {\n    SELECT fts5_test_poslist(x3) FROM x3('(a NOT b) OR c');\n  } {2.0.2}\n\n  do_execsql_test 16.1 {\n    SELECT fts5_test_poslist(x3) FROM x3('a OR c');\n  } {{0.0.0 1.0.2}}\n}\n\n}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 17.0 {\n  CREATE VIRTUAL TABLE x3 USING fts5(x);\n  INSERT INTO x3 VALUES('a b c');\n}\n\ndo_execsql_test 17.1 {\n  SELECT rowid FROM x3('b AND d');\n}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 18.1 {\n  CREATE VIRTUAL TABLE x4 USING fts5(x);\n  SELECT rowid FROM x4('\"\"');\n}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 19.1 {\n  CREATE VIRTUAL TABLE x1 USING fts5(a,b,c);\n}\n\ndo_catchsql_test 19.2 {\n  SELECT * FROM x1 WHERE x1 MATCH 'c0 AND (c1 AND (c2 AND (c3 AND (c4 AND (c5 AND (c6 AND (c7 AND (c8 AND (c9 AND (c10 AND (c11 AND (c12 AND (c13 AND (c14 AND (c15 AND (c16 AND (c17 AND (c18 AND (c19 AND (c20 AND (c21 AND (c22 AND (c23 AND (c24 AND (c25 AND (c26 AND (c27 AND (c28 AND (c29 AND (c30 AND (c31 AND (c32 AND (c33 AND (c34 AND (c35 AND (c36 AND (c37 AND (c38 AND (c39 AND (c40 AND (c41 AND (c42 AND (c43 AND (c44 AND (c45 AND (c46 AND (c47 AND (c48 AND (c49 AND (c50 AND (c51 AND (c52 AND (c53 AND (c54 AND (c55 AND (c56 AND (c57 AND (c58 AND (c59 AND (c60 AND (c61 AND (c62 AND (c63 AND (c64 AND (c65 AND (c66 AND (c67 AND (c68 AND (c69 AND (c70 AND (c71 AND (c72 AND (c73 AND (c74 AND (c75 AND (c76 AND (c77 AND (c78 AND (c79 AND (c80 AND (c81 AND (c82 AND (c83 AND (c84 AND (c85 AND (c86 AND (c87 AND (c88 AND (c89 AND (c90 AND (c91 AND (c92 AND (c93 AND (c94 AND (c95 AND (c96 AND (c97 AND (c98 AND (c99 AND (c100 AND (c101 AND (c102 AND (c103 AND (c104 AND (c105 AND (c106 AND (c107 AND (c108 AND (c109 AND (c110 AND (c111 AND (c112 AND (c113 AND (c114 AND (c115 AND (c116 AND (c117 AND (c118 AND (c119 AND (c120 AND (c121 AND (c122 AND (c123 AND (c124 AND (c125 AND (c126 AND (c127 AND (c128 AND (c129 AND (c130 AND (c131 AND (c132 AND (c133 AND (c134 AND (c135 AND (c136 AND (c137 AND (c138 AND (c139 AND (c140 AND (c141 AND (c142 AND (c143 AND (c144 AND (c145 AND (c146 AND (c147 AND (c148 AND (c149 AND (c150 AND (c151 AND (c152 AND (c153 AND (c154 AND (c155 AND (c156 AND (c157 AND (c158 AND (c159 AND (c160 AND (c161 AND (c162 AND (c163 AND (c164 AND (c165 AND (c166 AND (c167 AND (c168 AND (c169 AND (c170 AND (c171 AND (c172 AND (c173 AND (c174 AND (c175 AND (c176 AND (c177 AND (c178 AND (c179 AND (c180 AND (c181 AND (c182 AND (c183 AND (c184 AND (c185 AND (c186 AND (c187 AND (c188 AND (c189 AND (c190 AND (c191 AND (c192 AND (c193 AND (c194 AND (c195 AND (c196 AND (c197 AND (c198 AND (c199 AND c200)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))';\n} {1 {fts5: parser stack overflow}}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 20.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n  INSERT INTO x1(rowid, x) VALUES(11111, 'onetwothree');\n}\ndo_test 20.1 {\n  for {set i 1} {$i <= 200} {incr i} {\n    execsql { INSERT INTO x1(rowid, x) VALUES($i, 'one two three'); }\n  }\n  execsql { INSERT INTO x1(x1) VALUES('optimize'); }\n  execsql { DELETE FROM x1 WHERE rowid = 4; }\n} {}\ndo_execsql_test 20.2 {\n  INSERT INTO x1(x1) VALUES('optimize');\n  INSERT INTO x1(x1) VALUES('integrity-check');\n} {}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 20.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(x1, rank) VALUES('pgsz', 32);\n  INSERT INTO x1(rowid, x) VALUES(11111, 'onetwothree');\n}\ndo_test 20.1 {\n  for {set i 1} {$i <= 200} {incr i} {\n    execsql { INSERT INTO x1(rowid, x) VALUES($i, 'one two three'); }\n  }\n  execsql { INSERT INTO x1(x1) VALUES('optimize'); }\n  execsql { DELETE FROM x1 WHERE rowid = 4; }\n} {}\ndo_execsql_test 20.2 {\n  INSERT INTO x1(x1) VALUES('optimize');\n  INSERT INTO x1(x1) VALUES('integrity-check');\n} {}\n\n#-------------------------------------------------------------------------\nreset_db\nset doc \"a b [string repeat x 100000]\"\ndo_execsql_test 21.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1(rowid, x) VALUES(11111, $doc);\n  INSERT INTO x1(rowid, x) VALUES(11112, $doc);\n}\ndo_execsql_test 21.1 {\n  INSERT INTO x1(x1) VALUES('integrity-check');\n}\ndo_execsql_test 21.2 {\n  SELECT rowid FROM x1($doc);\n} {11111 11112}\ndo_execsql_test 21.3 {\n  DELETE FROM x1 WHERE rowid=11111;\n  INSERT INTO x1(x1) VALUES('integrity-check');\n  SELECT rowid FROM x1($doc);\n} {11112}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5simple2.test",
    "content": "# 2015 September 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5simple2\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  INSERT INTO t1 VALUES('a b c');\n}\ndo_execsql_test 1.1 {\n  SELECT rowid FROM t1('c a b')\n} {1}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  BEGIN;\n    INSERT INTO t1 VALUES('b c d');\n    INSERT INTO t1 VALUES('b c d');\n  COMMIT;\n}\ndo_execsql_test 2.1 {\n  SELECT rowid FROM t1('b c d')\n} {1 2}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  BEGIN;\n    INSERT INTO t1 VALUES('b c d');\n    INSERT INTO t1 VALUES('b c d');\n}\ndo_execsql_test 3.1 {\n  SELECT rowid FROM t1('b c d'); COMMIT;\n} {1 2}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  BEGIN;\n    INSERT INTO t1 VALUES('a1 b1 c1');\n    INSERT INTO t1 VALUES('a2 b2 c2');\n    INSERT INTO t1 VALUES('a3 b3 c3');\n  COMMIT;\n}\ndo_execsql_test 4.1 {\n  SELECT rowid FROM t1('b*');\n} {1 2 3}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  BEGIN;\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  INSERT INTO t1 VALUES('a2 b2 c2');\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  COMMIT;\n}\ndo_execsql_test 5.1 { SELECT rowid FROM t1('b*') } {1 2 3}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=full);\n  BEGIN;\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  COMMIT;\n}\n\ndo_execsql_test 6.1 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 2 1}\ndo_execsql_test 6.2 { SELECT rowid FROM t1('b1') ORDER BY rowid DESC } {3 2 1}\ndo_execsql_test 6.3 { SELECT rowid FROM t1('c1') ORDER BY rowid DESC } {3 2 1}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  BEGIN;\n  INSERT INTO t1 VALUES('a1 b1');\n  INSERT INTO t1 VALUES('a1 b2');\n  COMMIT;\n}\ndo_execsql_test 7.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {2 1}\ndo_execsql_test 7.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {2 1}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  INSERT INTO t1 VALUES('a2 b2 c2');\n  INSERT INTO t1 VALUES('a1 b1 c1');\n}\ndo_execsql_test 8.0.1 { SELECT rowid FROM t1('b*') } {1 2 3}\ndo_execsql_test 8.0.2 { SELECT rowid FROM t1('a1') } {1 3}\ndo_execsql_test 8.0.3 { SELECT rowid FROM t1('c2') } {2}\n\ndo_execsql_test 8.0.4 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {3 2 1}\ndo_execsql_test 8.0.5 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 1}\ndo_execsql_test 8.0.8 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC } {2}\n\ndo_execsql_test 8.1.0 { INSERT INTO t1(t1) VALUES('optimize') }\n\ndo_execsql_test 8.1.1 { SELECT rowid FROM t1('b*') } {1 2 3}\ndo_execsql_test 8.1.2 { SELECT rowid FROM t1('a1') } {1 3}\ndo_execsql_test 8.1.3 { SELECT rowid FROM t1('c2') } {2}\n\ndo_execsql_test 8.2.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC} {3 2 1}\ndo_execsql_test 8.2.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC} {3 1}\ndo_execsql_test 8.2.3 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC} {2}\n\n#--------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 9.0.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  INSERT INTO t1 VALUES('a1 b1 c1');\n  INSERT INTO t1 VALUES('a2 b2 c2');\n  INSERT INTO t1 VALUES('a1 b1 c1');\n}\ndo_execsql_test 9.0.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {}\n\nreset_db\ndo_execsql_test 9.1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=none);\n  INSERT INTO t1 VALUES('a1 b1 c1', 'x y z');\n  INSERT INTO t1 VALUES('a2 b2 c2', '1 2 3');\n  INSERT INTO t1 VALUES('a1 b1 c1', 'x 2 z');\n}\ndo_execsql_test 9.2.1 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {}\n\n#--------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 10.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  INSERT INTO t1 VALUES('b1');\n  INSERT INTO t1 VALUES('b1');\n  DELETE FROM t1 WHERE rowid=1;\n}\n\ndo_execsql_test 10.1 {\n  SELECT rowid FROM t1('b1');\n} {2}\n\ndo_execsql_test 10.2 {\n  SELECT rowid FROM t1('b1') ORDER BY rowid DESC;\n} {2}\n\ndo_execsql_test 10.3 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n} {}\n\n#--------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 11.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=none);\n  INSERT INTO t1(t1, rank) VALUES('pgsz', 32);\n  WITH d(x,y) AS (\n    SELECT NULL, 'xyz' UNION ALL SELECT NULL, 'xyz' FROM d\n  )\n  INSERT INTO t1 SELECT * FROM d LIMIT 23;\n}\n\n#db eval { SELECT rowid AS r, quote(block) AS b FROM t1_data } { puts \"$r: $b\" }\ndo_execsql_test 11.2 {\n  SELECT rowid FROM t1;\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23}\n\ndo_execsql_test 11.3 {\n  SELECT rowid FROM t1('xyz');\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23}\n\ndo_execsql_test 11.4 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 12.0 {\n  CREATE VIRTUAL TABLE yy USING fts5(x, detail=none);\n  INSERT INTO yy VALUES('in if');\n  INSERT INTO yy VALUES('if');\n} {}\n\ndo_execsql_test 12.1 {\n  SELECT rowid FROM yy('i*');\n} {1 2}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 13.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, prefix=1, detail=none);\n} {}\nforeach {rowid a} {\n  0   {f}\n  1   {u}\n  2   {k}\n  3   {a}\n  4   {a}\n  5   {u}\n  6   {u}\n  7   {u}\n  8   {f}\n  9   {f}\n  10  {a}\n  11  {p}\n  12  {f}\n  13  {u}\n  14  {a}\n  15  {a}\n} {\n  do_execsql_test 13.1.$rowid {\n    INSERT INTO t1(rowid, a) VALUES($rowid, $a);\n  }\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nfts5_aux_test_functions db\ndo_execsql_test 14.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);\n  INSERT INTO t1 VALUES('a b c d');\n} {}\n\ndo_execsql_test 14.1 {\n  SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank;\n} {0.0.1}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 15.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=none);\n  BEGIN;\n    INSERT INTO t1(rowid, x) VALUES(1, 'sqlite');\n    INSERT INTO t1(rowid, x) VALUES(2, 'sqlite'); \n  COMMIT;\n} {}\n\ndo_test 15.1 {\n  execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {}\n\ndo_test 15.2 {\n  execsql { DELETE FROM t1 }\n} {}\n\ndo_execsql_test 15.3.1 {\n  SELECT rowid FROM t1('sqlite');\n} {}\n\ndo_execsql_test 15.3.2 {\n  SELECT rowid FROM t1('sqlite') ORDER BY rowid DESC;\n} {}\n\ndo_test 15.4 {\n  execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n} {}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 16.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, detail=none);\n  BEGIN;\n    INSERT INTO t2(rowid, x) VALUES(1, 'a b c');\n    INSERT INTO t2(rowid, x) VALUES(456, 'a b c');\n    INSERT INTO t2(rowid, x) VALUES(1000, 'a b c');\n  COMMIT;\n  UPDATE t2 SET x=x;\n}\n\ndo_execsql_test 16.1 {\n  INSERT INTO t2(t2) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 16.2 {\n  SELECT rowid FROM t2('b') ORDER BY rowid DESC\n} {1000 456 1}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 16.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, detail=none);\n  BEGIN;\n    INSERT INTO t2(rowid, x) VALUES(1, 'a b c');\n    INSERT INTO t2(rowid, x) VALUES(456, 'a b c');\n    INSERT INTO t2(rowid, x) VALUES(1000, 'a b c');\n  COMMIT;\n  UPDATE t2 SET x=x;\n  DELETE FROM t2;\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 17.0 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, y);\n  BEGIN;\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n  COMMIT;\n}\ndo_execsql_test 17.1 { SELECT * FROM t2('y:a*') WHERE rowid BETWEEN 10 AND 20 }\ndo_execsql_test 17.2 {\n  BEGIN;\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n    SELECT * FROM t2('y:a*') WHERE rowid BETWEEN 10 AND 20 ;\n}\ndo_execsql_test 17.3 {\n  COMMIT\n}\n\nreset_db\ndo_execsql_test 17.4 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x, y);\n  BEGIN;\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n    INSERT INTO t2 VALUES('a aa aaa', 'b bb bbb');\n    SELECT * FROM t2('y:a*') WHERE rowid>66;\n}\ndo_execsql_test 17.5 { SELECT * FROM t2('x:b* OR y:a*') }\ndo_execsql_test 17.5 { COMMIT ; SELECT * FROM t2('x:b* OR y:a*') }\ndo_execsql_test 17.6 { \n  SELECT * FROM t2('x:b* OR y:a*') WHERE rowid>55\n}\n\n#db eval {SELECT rowid, fts5_decode_none(rowid, block) aS r FROM t2_data} {puts $r}\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5simple3.test",
    "content": "# 2015 September 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5simple3\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nfts5_aux_test_functions db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, c, detail=col);\n  INSERT INTO t1 VALUES('a', 'b', 'c');\n  INSERT INTO t1 VALUES('x', 'x', 'x');\n}\n\ndo_execsql_test 1.1 {\n  SELECT rowid, fts5_test_collist(t1) FROM t1('a:a');\n} {1 0.0}\n\ndo_execsql_test 1.2 {\n  SELECT rowid, fts5_test_collist(t1) FROM t1('b:x');\n} {2 0.1}\n\ndo_execsql_test 1.3 {\n  SELECT rowid, fts5_test_collist(t1) FROM t1('b:a');\n} {}\n\n#-------------------------------------------------------------------------\n# Create detail=col and detail=full tables with 998 columns.\n#\nforeach_detail_mode $testprefix {\n  if {[detail_is_none]} continue\n\n  do_test 2.1 {\n    execsql { DROP TABLE IF EXISTS t2 }\n    set cols [list]\n    set vals [list]\n    for {set i 1} {$i <= 998} {incr i} {\n      lappend cols \"c$i\"\n      lappend vals \"'val$i'\"\n    }\n    execsql \"CREATE VIRTUAL TABLE t2 USING fts5(detail=%DETAIL%,[join $cols ,])\"\n  } {}\n  \n  do_test 2.2 {\n    execsql \"INSERT INTO t2 VALUES([join $vals ,])\"\n  } {}\n  \n  foreach {tn q res} {\n    1 { c1:val1 }     1\n    2 { c300:val300 } 1\n    3 { c300:val1 } {}\n    4 { c1:val300 } {}\n  } {\n    do_execsql_test 2.3.$tn {\n      SELECT rowid FROM t2($q)\n    } $res\n  }\n}\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE x3 USING fts5(one);\n  INSERT INTO x3 VALUES('a b c');\n  INSERT INTO x3 VALUES('c b a');\n  INSERT INTO x3 VALUES('o t t');\n  SELECT * FROM x3('x OR y OR z');\n}\n\n#-------------------------------------------------------------------------\n# Test that a crash occuring when the second or subsequent tokens in a\n# phrase matched zero rows has been fixed.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  INSERT INTO t1 VALUES('ab');\n  INSERT INTO t1 VALUES('cd');\n  INSERT INTO t1 VALUES('ab cd');\n  INSERT INTO t1 VALUES('ab cdXXX');\n  INSERT INTO t1 VALUES('abXXX cd');\n}\ndo_execsql_test 4.1 {\n  SELECT * FROM t1('\"ab cd\" OR \"ab cd\" *');\n} {{ab cd} {ab cdXXX}}\ndo_execsql_test 4.2 {\n  SELECT * FROM t1('\"xy zz\" OR \"ab cd\" *');\n} {{ab cd} {ab cdXXX}}\ndo_execsql_test 4.3 {\n  SELECT * FROM t1('\"xy zz\" OR \"xy zz\" *');\n}\ndo_execsql_test 4.4 {\n  SELECT * FROM t1('\"ab cd\" OR \"xy zz\" *');\n} {{ab cd}}\ndo_execsql_test 4.5 {\n  CREATE VIRTUAL TABLE t2 USING fts5(x);\n  INSERT INTO t2 VALUES('ab');\n  INSERT INTO t2 VALUES('cd');\n  INSERT INTO t2 VALUES('ef');\n} \ndo_execsql_test 4.6 {\n  SELECT * FROM t2('ab + xyz');\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5synonym.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on custom tokenizers that support synonyms.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5synonym\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc tcl_create {args} { return \"tcl_tokenize\" }\n\nforeach_detail_mode $testprefix {\n\n#-------------------------------------------------------------------------\n# Warm body test for the code in fts5_tcl.c.\n#\nfts5_tclnum_register db\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = \"tclnum document\", detail=%DETAIL%);\n  INSERT INTO ft VALUES('abc def ghi');\n  INSERT INTO ft VALUES('jkl mno pqr');\n  SELECT rowid, x FROM ft WHERE ft MATCH 'def';\n  SELECT x, rowid FROM ft WHERE ft MATCH 'pqr';\n} {1 {abc def ghi} {jkl mno pqr} 2}\n\n#-------------------------------------------------------------------------\n# Test a tokenizer that supports synonyms by adding extra entries to the\n# FTS index.\n#\nreset_db\nfts5_tclnum_register db\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(\n      x, tokenize = \"tclnum document\", detail=%DETAIL%\n  );\n  INSERT INTO ft VALUES('one two three');\n  INSERT INTO ft VALUES('four five six');\n  INSERT INTO ft VALUES('eight nine ten');\n} {}\n\nforeach {tn expr res} {\n  1 \"3\" 1\n  2 \"eight OR 8 OR 5\" {2 3}\n  3 \"10\" {}\n  4 \"1*\" {1}\n  5 \"1 + 2\" {1}\n} {\n  if {![fts5_expr_ok $expr ft]} continue\n  do_execsql_test 2.1.$tn {\n    SELECT rowid FROM ft WHERE ft MATCH $expr\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Test some broken tokenizers:\n#\n#   3.1.*: A tokenizer that declares the very first token to be colocated.\n#\n#   3.2.*: A tokenizer that reports two identical tokens at the same position.\n#          This is allowed.\n#\nreset_db\nsqlite3_fts5_create_tokenizer db tcl tcl_create\nproc tcl_tokenize {tflags text} {\n  set bColo 1\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    if {$bColo} {\n      sqlite3_fts5_token -colo $w $iStart $iEnd\n      set bColo 0\n    } {\n      sqlite3_fts5_token $w $iStart $iEnd\n    }\n  }\n}\ndo_execsql_test 3.1.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = tcl);\n  INSERT INTO ft VALUES('one two three');\n  CREATE VIRTUAL TABLE vv USING fts5vocab(ft, row);\n  SELECT * FROM vv;\n} {\n  one 1 1   three 1 1   two 1 1\n}\n\ndo_execsql_test 3.1.1 {\n  INSERT INTO ft(ft) VALUES('integrity-check');\n} {}\n\nproc tcl_tokenize {tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n  }\n}\n\ndo_execsql_test 3.1.2 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one two three'\n} {1}\n\nreset_db\nsqlite3_fts5_create_tokenizer db tcl tcl_create\nproc tcl_tokenize {tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n    sqlite3_fts5_token -colo $w $iStart $iEnd\n  }\n}\ndo_execsql_test 3.2.0 {\n  CREATE VIRTUAL TABLE ft USING fts5(x, tokenize = tcl);\n  INSERT INTO ft VALUES('one one two three');\n  CREATE VIRTUAL TABLE vv USING fts5vocab(ft, row);\n  SELECT * FROM vv;\n} {\n  one 1 4   three 1 2   two 1 2\n}\ndo_execsql_test 3.2.1 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one';\n} {1}\ndo_execsql_test 3.2.2 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one two three';\n} {1}\ndo_execsql_test 3.2.3 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one + one + two + three';\n} {1}\ndo_execsql_test 3.2.4 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one two two three';\n} {1}\ndo_execsql_test 3.2.5 {\n  SELECT rowid FROM ft WHERE ft MATCH 'one + two + two + three';\n} {}\n\n#-------------------------------------------------------------------------\n# Check that expressions with synonyms can be parsed and executed.\n#\nreset_db\nfts5_tclnum_register db\n\nforeach {tn expr res} {\n  1  {abc}                           {\"abc\"}\n  2  {one}                           {\"one\"|\"i\"|\"1\"}\n  3  {3}                             {\"3\"|\"iii\"|\"three\"}\n  4  {3*}                            {\"3\" *}\n} {\n  do_execsql_test 4.1.$tn {\n    SELECT fts5_expr($expr, 'tokenize=tclnum')\n  } [list $res]\n}\n\ndo_execsql_test 4.2.1 {\n  CREATE VIRTUAL TABLE xx USING fts5(x, tokenize=tclnum, detail=%DETAIL%);\n  INSERT INTO xx VALUES('one two');\n  INSERT INTO xx VALUES('three four');\n}\n\ndo_execsql_test 4.2.2 {\n  SELECT rowid FROM xx WHERE xx MATCH '2'\n} {1}\n\ndo_execsql_test 4.2.3 {\n  SELECT rowid FROM xx WHERE xx MATCH '3'\n} {2}\n\ndo_test 5.0 {\n  execsql { \n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, tokenize=tclnum, detail=%DETAIL%)\n  }\n  foreach {rowid a b} {\n    1 {four v 4 i three} {1 3 five five 4 one}\n    2 {5 1 3 4 i} {2 2 v two 4}\n    3 {5 i 5 2 four 4 1} {iii ii five two 1}\n    4 {ii four 4 one 5 three five} {one 5 1 iii 4 3}\n    5 {three i v i four 4 1} {ii five five five iii}\n    6 {4 2 ii two 2 iii} {three 1 four 4 iv 1 iv}\n    7 {ii ii two three 2 5} {iii i ii iii iii one one}\n    8 {2 ii i two 3 three 2} {two iv v iii 3 five}\n    9 {i 2 iv 3 five four v} {iii 4 three i three ii 1}\n  } {\n    execsql { INSERT INTO t1(rowid, a, b) VALUES($rowid, $a, $b) }\n  }\n} {}\n\n\nforeach {tn q res} {\n  1 {one} {\n    1 {four v 4 [i] three} {[1] 3 five five 4 [one]}\n    2 {5 [1] 3 4 [i]} {2 2 v two 4}\n    3 {5 [i] 5 2 four 4 [1]} {iii ii five two [1]}\n    4 {ii four 4 [one] 5 three five} {[one] 5 [1] iii 4 3}\n    5 {three [i] v [i] four 4 [1]} {ii five five five iii}\n    6 {4 2 ii two 2 iii} {three [1] four 4 iv [1] iv}\n    7 {ii ii two three 2 5} {iii [i] ii iii iii [one] [one]}\n    8 {2 ii [i] two 3 three 2} {two iv v iii 3 five}\n    9 {[i] 2 iv 3 five four v} {iii 4 three [i] three ii [1]}\n  }\n  2 {five four} {\n    1 {[four] [v] [4] i three} {1 3 [five] [five] [4] one}\n    2 {[5] 1 3 [4] i} {2 2 [v] two [4]}\n    3 {[5] i [5] 2 [four] [4] 1} {iii ii [five] two 1}\n    4 {ii [four] [4] one [5] three [five]} {one [5] 1 iii [4] 3}\n    5 {three i [v] i [four] [4] 1} {ii [five] [five] [five] iii}\n    8 {2 ii i two 3 three 2} {two [iv] [v] iii 3 [five]}\n    9 {i 2 [iv] 3 [five] [four] [v]} {iii [4] three i three ii 1}\n  }\n  3 {one OR two OR iii OR 4 OR v} {\n    1 {[four] [v] [4] [i] [three]} {[1] [3] [five] [five] [4] [one]}\n    2 {[5] [1] [3] [4] [i]} {[2] [2] [v] [two] [4]}\n    3 {[5] [i] [5] [2] [four] [4] [1]} {[iii] [ii] [five] [two] [1]}\n    4 {[ii] [four] [4] [one] [5] [three] [five]} {[one] [5] [1] [iii] [4] [3]}\n    5 {[three] [i] [v] [i] [four] [4] [1]} {[ii] [five] [five] [five] [iii]}\n    6 {[4] [2] [ii] [two] [2] [iii]} {[three] [1] [four] [4] [iv] [1] [iv]}\n    7 {[ii] [ii] [two] [three] [2] [5]} {[iii] [i] [ii] [iii] [iii] [one] [one]}\n    8 {[2] [ii] [i] [two] [3] [three] [2]} {[two] [iv] [v] [iii] [3] [five]}\n    9 {[i] [2] [iv] [3] [five] [four] [v]} {[iii] [4] [three] [i] [three] [ii] [1]}\n  }\n\n  4 {5 + 1} {\n    2 {[5 1] 3 4 i} {2 2 v two 4} \n    3 {[5 i] 5 2 four 4 1} {iii ii five two 1} \n    4 {ii four 4 one 5 three five} {one [5 1] iii 4 3} \n    5 {three i [v i] four 4 1} {ii five five five iii}\n  }\n\n  5 {one + two + three} {\n    7 {ii ii two three 2 5} {iii [i ii iii] iii one one}\n    8 {2 ii [i two 3] three 2} {two iv v iii 3 five}\n  }\n\n  6 {\"v v\"} {\n    1 {four v 4 i three} {1 3 [five five] 4 one}\n    5 {three i v i four 4 1} {ii [five five five] iii}\n  }\n} {\n  if {![fts5_expr_ok $q t1]} continue\n  do_execsql_test 5.1.$tn {\n    SELECT rowid, highlight(t1, 0, '[', ']'), highlight(t1, 1, '[', ']')\n    FROM t1 WHERE t1 MATCH $q\n  } $res\n}\n\n# Test that the xQueryPhrase() API works with synonyms.\n#\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\nsqlite3_fts5_register_matchinfo db\n\nforeach {tn q res} {\n  1 {one} {\n      1 {1 11 7 2 12 6}     2 {2 11 7 0 12 6} \n      3 {2 11 7 1 12 6}     4 {1 11 7 2 12 6} \n      5 {3 11 7 0 12 6}     6 {0 11 7 2 12 6} \n      7 {0 11 7 3 12 6}     8 {1 11 7 0 12 6} \n      9 {1 11 7 2 12 6}\n  }\n} {\n  do_execsql_test 5.2.$tn {\n    SELECT rowid, mit(matchinfo(t1, 'x')) FROM t1 WHERE t1 MATCH $q\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Test terms with more than 4 synonyms.\n#\nreset_db\nsqlite3_fts5_create_tokenizer db tcl tcl_create\nproc tcl_tokenize {tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n    if {$tflags==\"query\" && [string length $w]==1} {\n      for {set i 2} {$i<=10} {incr i} {\n        sqlite3_fts5_token -colo [string repeat $w $i] $iStart $iEnd\n      }\n    }\n  }\n}\n\ndo_execsql_test 6.0.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize=tcl, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('yy xx qq');\n  INSERT INTO t1 VALUES('yy xx xx');\n}\nif {[fts5_expr_ok \"NEAR(y q)\" t1]} {\n  do_execsql_test 6.0.2 {\n    SELECT * FROM t1 WHERE t1 MATCH 'NEAR(y q)';\n  } {{yy xx qq}}\n}\n\ndo_test 6.0.3 {\n  execsql { \n    CREATE VIRTUAL TABLE t2 USING fts5(a, b, tokenize=tcl, detail=%DETAIL%)\n  }\n  foreach {rowid a b} {\n    1 {yyyy vvvvv qq oo yyyyyy vvvv eee} {ffff uu r qq aaaa}\n    2 {ww oooooo bbbbb ssssss mm} {ffffff yy iiii rr s ccc qqqqq}\n    3 {zzzz llll gggggg cccc uu} {hhhhhh aaaa ppppp rr ee jjjj}\n    4 {r f i rrrrrr ww hhh} {aa yyy t x aaaaa ii}\n    5 {fffff mm vvvv ooo ffffff kkkk tttt} {cccccc bb e zzz d n}\n    6 {iii dddd hh qqqq ddd ooo} {ttt d c b aaaaaa qqqq}\n    7 {jjjj rrrr v zzzzz u tt t} {ppppp pp dddd mm hhh uuu}\n    8 {gggg rrrrrr kkkk vvvv gggg jjjjjj b} {dddddd jj r w cccc wwwwww ss}\n    9 {kkkkk qqq oooo e tttttt mmm} {e ss qqqqqq hhhh llllll gg}\n  } {\n    execsql { INSERT INTO t2(rowid, a, b) VALUES($rowid, $a, $b) }\n  }\n} {}\n\nforeach {tn q res} {\n  1 {a} {\n    1 {yyyy vvvvv qq oo yyyyyy vvvv eee} {ffff uu r qq [aaaa]}\n    3 {zzzz llll gggggg cccc uu} {hhhhhh [aaaa] ppppp rr ee jjjj}\n    4 {r f i rrrrrr ww hhh} {[aa] yyy t x [aaaaa] ii}\n    6 {iii dddd hh qqqq ddd ooo} {ttt d c b [aaaaaa] qqqq}\n  }\n\n  2 {a AND q} {\n    1 {yyyy vvvvv [qq] oo yyyyyy vvvv eee} {ffff uu r [qq] [aaaa]}\n    6 {iii dddd hh [qqqq] ddd ooo} {ttt d c b [aaaaaa] [qqqq]}\n  }\n\n  3 {o OR (q AND a)} {\n    1 {yyyy vvvvv [qq] [oo] yyyyyy vvvv eee} {ffff uu r [qq] [aaaa]}\n    2 {ww [oooooo] bbbbb ssssss mm} {ffffff yy iiii rr s ccc qqqqq}\n    5 {fffff mm vvvv [ooo] ffffff kkkk tttt} {cccccc bb e zzz d n}\n    6 {iii dddd hh [qqqq] ddd [ooo]} {ttt d c b [aaaaaa] [qqqq]}\n    9 {kkkkk qqq [oooo] e tttttt mmm} {e ss qqqqqq hhhh llllll gg}\n  }\n\n  4 {NEAR(q y, 20)} {\n    1 {[yyyy] vvvvv [qq] oo [yyyyyy] vvvv eee} {ffff uu r qq aaaa}\n    2 {ww oooooo bbbbb ssssss mm} {ffffff [yy] iiii rr s ccc [qqqqq]}\n  }\n} {\n  if {![fts5_expr_ok $q t2]} continue\n\n  do_execsql_test 6.1.$tn.asc {\n    SELECT rowid, highlight(t2, 0, '[', ']'), highlight(t2, 1, '[', ']')\n    FROM t2 WHERE t2 MATCH $q\n  } $res\n\n  set res2 [list]\n  foreach {rowid a b} $res {\n    set res2 [concat [list $rowid $a $b] $res2]\n  }\n\n  do_execsql_test 6.1.$tn.desc {\n    SELECT rowid, highlight(t2, 0, '[', ']'), highlight(t2, 1, '[', ']')\n    FROM t2 WHERE t2 MATCH $q ORDER BY rowid DESC\n  } $res2\n}\n\ndo_execsql_test 6.2.1 {\n  INSERT INTO t2(rowid, a, b) VALUES(13,\n      'x xx xxx xxxx xxxxx xxxxxx xxxxxxx', 'y yy yyy yyyy yyyyy yyyyyy yyyyyyy'\n  );\n  SELECT rowid, highlight(t2, 0, '<', '>'), highlight(t2, 1, '(', ')')\n  FROM t2 WHERE t2 MATCH 'x OR y'\n} {\n  1 {<yyyy> vvvvv qq oo <yyyyyy> vvvv eee} {ffff uu r qq aaaa}\n  2 {ww oooooo bbbbb ssssss mm} {ffffff (yy) iiii rr s ccc qqqqq}\n  4 {r f i rrrrrr ww hhh} {aa (yyy) t (x) aaaaa ii}\n  13 {<x> <xx> <xxx> <xxxx> <xxxxx> <xxxxxx> <xxxxxxx>}\n     {(y) (yy) (yyy) (yyyy) (yyyyy) (yyyyyy) (yyyyyyy)}\n}\n\n#-------------------------------------------------------------------------\n# Test that the xColumnSize() API is not confused by colocated tokens.\n#\nreset_db\nsqlite3_fts5_create_tokenizer db tcl tcl_create\nfts5_aux_test_functions db\nproc tcl_tokenize {tflags text} {\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n    if {[string length $w]==1} {\n      for {set i 2} {$i<=10} {incr i} {\n        sqlite3_fts5_token -colo [string repeat $w $i] $iStart $iEnd\n      }\n    }\n  }\n}\n\ndo_execsql_test 7.0.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, columnsize=1, tokenize=tcl, detail=%DETAIL%);\n  INSERT INTO t1 VALUES('0 2 3', '4 5 6 7');\n  INSERT INTO t1 VALUES('8 9', '0 0 0 0 0 0 0 0 0 0');\n  SELECT fts5_test_columnsize(t1) FROM t1 WHERE t1 MATCH '000 AND 00 AND 0';\n} {{3 4} {2 10}}\n\ndo_execsql_test 7.0.2 {\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\ndo_execsql_test 7.1.1 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a, b, columnsize=0, tokenize=tcl, detail=%DETAIL%);\n  INSERT INTO t2 VALUES('0 2 3', '4 5 6 7');\n  INSERT INTO t2 VALUES('8 9', '0 0 0 0 0 0 0 0 0 0');\n  SELECT fts5_test_columnsize(t2) FROM t2 WHERE t2 MATCH '000 AND 00 AND 0';\n} {{3 4} {2 10}}\n\ndo_execsql_test 7.1.2 {\n  INSERT INTO t2(t2) VALUES('integrity-check');\n}\n\n} ;# foreach_detail_mode\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5synonym2.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on custom tokenizers that support synonyms.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5synonym2\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach tok {query document} {\nforeach_detail_mode $testprefix {\n\nfts5_tclnum_register db\nfts5_aux_test_functions db\n\nproc fts5_test_bothlist {cmd} {\n\n  for {set i 0} {$i < [$cmd xPhraseCount]} {incr i} {\n    set bFirst 1\n    $cmd xPhraseColumnForeach $i c { \n      lappend CL $i.$c \n      if {$bFirst} { $cmd xPhraseForeach $i c o { lappend PL $i.$c.$o } }\n      set bFirst 0\n    }\n  }\n\n  list [sort_poslist $PL] $CL\n}\nsqlite3_fts5_create_function db fts5_test_bothlist fts5_test_bothlist\n\nproc fts5_rowid {cmd} { expr [$cmd xColumnText -1] }\nsqlite3_fts5_create_function db fts5_rowid fts5_rowid\n\ndo_execsql_test 1.$tok.0.1 \"\n  CREATE VIRTUAL TABLE ss USING fts5(a, b, \n       tokenize='tclnum $tok', detail=%DETAIL%);\n  INSERT INTO ss(ss, rank) VALUES('rank', 'fts5_rowid()');\n\"\n\ndo_execsql_test 1.$tok.0.2 {\n  INSERT INTO ss VALUES('5 5 five seven 3 seven i', '2 1 5 0 two 1 i');\n  INSERT INTO ss VALUES('six ix iii 7 i vii iii', 'one seven nine 4 9 1 vi');\n  INSERT INTO ss VALUES('6 viii i five six zero seven', '5 v iii iv iv 3');\n  INSERT INTO ss VALUES('9 ii six 8 1 6', 'six 4 iv iv 7');\n  INSERT INTO ss VALUES('1 5 4 eight ii iv iii', 'nine 2 eight ix v vii');\n  INSERT INTO ss VALUES('one 7 seven six 2 two', '1 2 four 7 4 3 4');\n  INSERT INTO ss VALUES('eight iv 4 nine vii six 1', '5 6 v one zero 4');\n  INSERT INTO ss VALUES('v 9 8 iii 4', '9 4 seven two vi vii');\n  INSERT INTO ss VALUES('3 ix two 9 0 nine i', 'five ii nine two viii i five');\n  INSERT INTO ss VALUES('six iii 9 two eight 2', 'nine i nine vii nine');\n  INSERT INTO ss VALUES('6 three zero seven vii five', '8 vii ix 0 7 seven');\n  INSERT INTO ss VALUES('8 vii 8 7 3 4', 'eight iii four viii nine iv three');\n  INSERT INTO ss VALUES('4 v 7 two 0 one 8', 'vii 1 two five i zero 9');\n  INSERT INTO ss VALUES('3 ii vii vi eight', '8 4 ix one three eight');\n  INSERT INTO ss VALUES('iv eight seven 6 9 seven', 'one vi two five seven');\n  INSERT INTO ss VALUES('i i 5 i v vii eight', '2 seven i 2 2 four');\n  INSERT INTO ss VALUES('0 i iii nine 3 ix five', '0 eight iv 0 six 2');\n  INSERT INTO ss VALUES('iv vii three 3 9 one 8', '2 ii 6 eight ii six six');\n  INSERT INTO ss VALUES('eight one two nine six', '8 9 3 viii vi');\n  INSERT INTO ss VALUES('one 0 four ii eight one 3', 'iii eight vi vi vi');\n  INSERT INTO ss VALUES('4 0 eight 0 0', '1 four one vii seven ii');\n  INSERT INTO ss VALUES('1 zero nine 2 2', 'viii iv two vi nine v iii');\n  INSERT INTO ss VALUES('5 five viii four four vi', '8 five 7 vii 6 4');\n  INSERT INTO ss VALUES('7 ix four 8 vii', 'nine three nine ii ix vii');\n  INSERT INTO ss VALUES('nine iv v i 0 v', 'two iv vii six i ix 4');\n  INSERT INTO ss VALUES('one v v one viii 3 8', '2 1 3 five iii');\n  INSERT INTO ss VALUES('six ii 5 nine 4 viii seven', 'eight i ix ix 7 four');\n  INSERT INTO ss VALUES('9 ii two seven three 7 0', 'six viii seven 7 five');\n  INSERT INTO ss VALUES('five two 4 viii nine', '9 7 nine zero 1 two one');\n  INSERT INTO ss VALUES('viii 8 iii i ii 8 3', '4 2 7 v 8 8');\n  INSERT INTO ss VALUES('four vii 4 iii zero 0 vii', '3 viii iii zero 9 i');\n  INSERT INTO ss VALUES('0 seven v five i five v', 'one 4 2 ix 9');\n  INSERT INTO ss VALUES('two 5 two two ix 4 1', '3 nine ii v nine 3 five');\n  INSERT INTO ss VALUES('five 5 7 4 6 vii', 'three 2 ix 2 8 6');\n  INSERT INTO ss VALUES('six iii vi iv seven eight', '8 six 7 0 4');\n  INSERT INTO ss VALUES('vi vi iv 3 0 one one', '9 6 eight ix iv');\n  INSERT INTO ss VALUES('7 2 2 iii 0', '0 0 seven 1 nine');\n  INSERT INTO ss VALUES('8 6 iv six ii', 'iv 6 3 4 ii five');\n  INSERT INTO ss VALUES('0 two two seven ii', 'vii ix four 4 zero vi vi');\n  INSERT INTO ss VALUES('2 one eight 8 9 7', 'vi 3 0 3 vii');\n  INSERT INTO ss VALUES('iii ii ix iv three', 'vi i 6 1 two');\n  INSERT INTO ss VALUES('eight four nine 8 seven', 'one three i nine iii one');\n  INSERT INTO ss VALUES('iii seven five ix 8', 'ii 7 seven 0 four ii');\n  INSERT INTO ss VALUES('four 0 1 5 two', 'iii 9 5 ii ii 2 4');\n  INSERT INTO ss VALUES('iii nine four vi 8 five six', 'i i ii seven vi vii');\n  INSERT INTO ss VALUES('eight vii eight six 3', 'i vii 1 six 9 vii');\n  INSERT INTO ss VALUES('9 0 viii viii five', 'i 1 viii ix 3 4');\n  INSERT INTO ss VALUES('three nine 5 nine viii four zero', 'ii i 1 5 2 viii');\n  INSERT INTO ss VALUES('5 vii three 9 four', 'three five one 7 2 eight one');\n}\n\nforeach {tn expr} {\n  2.1 \"one OR two OR three OR four\"\n\n  1.1 \"one\"   1.2 \"two\"   1.3 \"three\"   1.4 \"four\"\n  1.5 \"v\"     1.6 \"vi\"    1.7 \"vii\"     1.8 \"viii\"\n  1.9 \"9\"    1.10 \"0\"    1.11 \"1\"      1.12 \"2\"\n\n  2.1 \"one OR two OR three OR four\"\n  2.2 \"(one AND two) OR (three AND four)\"\n  2.3 \"(one AND two) OR (three AND four) NOT five\"\n  2.4 \"(one AND two) NOT 6\"\n\n  3.1 \"b:one AND a:two\"\n  3.2 \"b:one OR a:two\"\n  3.3 \"a:one OR b:1 OR {a b} : i\"\n\n  4.1 \"NEAR(one two, 2)\"\n  4.2 \"NEAR(one two three, 2)\"\n  4.3 \"NEAR(eight nine, 1) OR NEAR(six seven, 1)\"\n} {\n  if {[fts5_expr_ok $expr ss]==0} {\n    do_test 1.$tok.$tn.OMITTED { list } [list]\n    continue\n  }\n\n  set res [fts5_query_data $expr ss ASC ::tclnum_syn]\n  do_execsql_test 1.$tok.$tn.[llength $res].asc.1 {\n    SELECT rowid, fts5_test_poslist2(ss), fts5_test_collist(ss) FROM ss($expr)\n  } $res\n\n  do_execsql_test 1.$tok.$tn.[llength $res].asc.2 {\n    SELECT rowid, fts5_test_poslist(ss), fts5_test_collist(ss) FROM ss($expr)\n  } $res\n\n  do_execsql_test 1.$tok.$tn.[llength $res].asc.2 {\n    SELECT rowid, fts5_test_poslist2(ss), fts5_test_collist(ss) FROM ss($expr)\n    ORDER BY rank ASC\n  } $res\n\n  set res2 [list]\n  foreach {a b c} $res { lappend res2 $a $c $b }\n  do_execsql_test 1.$tok.$tn.[llength $res].asc.3 {\n    SELECT rowid, fts5_test_collist(ss), fts5_test_poslist2(ss) FROM ss($expr)\n  } $res2\n\n  set res3 [list]\n  foreach {a b c} $res { lappend res3 $a [list $b $c] }\n  do_execsql_test 1.$tok.$tn.[llength $res].asc.3 {\n    SELECT rowid, fts5_test_bothlist(ss) FROM ss($expr)\n  } $res3\n\n\n}\n\n}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5tok1.test",
    "content": "# 2016 Jan 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nifcapable !fts5 { finish_test ; return }\nset ::testprefix fts5tok1\n\n\nsqlite3_fts5_register_fts5tokenize db\n\n#-------------------------------------------------------------------------\n# Simple test cases. Using the default (ascii) tokenizer.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5tokenize(ascii);\n  CREATE VIRTUAL TABLE t2 USING fts5tokenize();\n  CREATE VIRTUAL TABLE t3 USING fts5tokenize(\n      ascii, 'separators', 'xyz', tokenchars, ''''\n  );\n}\n\nforeach {tn tbl} {1 t1 2 t2 3 t3} {\n  do_execsql_test 1.$tn.1 \"SELECT input, * FROM $tbl ('one two three')\" {\n    {one two three} one   0  3 0 \n    {one two three} two   4  7 1 \n    {one two three} three 8 13 2\n  }\n\n  do_execsql_test 1.$tn.2 \"\n    SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'\n  \" {\n    one two three\n  }\n}\n\ndo_execsql_test 1.4 {\n  SELECT token FROM t3 WHERE input = '1x2x3x'\n} {1 2 3}\n\ndo_execsql_test 1.5 {\n  SELECT token FROM t1 WHERE input = '1x2x3x'\n} {1x2x3x}\n\ndo_execsql_test 1.6 {\n  SELECT token FROM t3 WHERE input = '1''2x3x'\n} {1'2 3}\n\ndo_execsql_test 1.7 {\n  SELECT token FROM t3 WHERE input = ''\n} {}\n\ndo_execsql_test 1.8 {\n  SELECT token FROM t3 WHERE input = NULL\n} {}\n\ndo_execsql_test 1.9 {\n  SELECT input, * FROM t3 WHERE input = 123\n} {123 123 0 3 0}\n\ndo_execsql_test 1.10 {\n  SELECT input, * FROM t1 WHERE input = 'a b c' AND token = 'b';\n} {\n  {a b c} b 2 3 1\n}\n\ndo_execsql_test 1.11 {\n  SELECT input, * FROM t1 WHERE token = 'b' AND input = 'a b c';\n} {\n  {a b c} b 2 3 1\n}\n\ndo_execsql_test 1.12 {\n  SELECT input, * FROM t1 WHERE input < 'b' AND input = 'a b c';\n} {\n  {a b c} a 0 1 0 \n  {a b c} b 2 3 1 \n  {a b c} c 4 5 2\n}\n\ndo_execsql_test 1.13.1 {\n  CREATE TABLE c1(x);\n  INSERT INTO c1(x) VALUES('a b c');\n  INSERT INTO c1(x) VALUES('d e f');\n}\ndo_execsql_test 1.13.2 {\n  SELECT c1.*, input, t1.* FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid;\n} {\n  {a b c} {a b c} a 0 1 0 \n  {d e f} {d e f} e 2 3 1 \n}\n\n\n#-------------------------------------------------------------------------\n# Error cases.\n#\ndo_catchsql_test 2.0 {\n  CREATE VIRTUAL TABLE tX USING fts5tokenize(nosuchtokenizer);\n} {1 {vtable constructor failed: tX}}\n\ndo_catchsql_test 2.1 {\n  CREATE VIRTUAL TABLE t4 USING fts5tokenize;\n  SELECT * FROM t4;\n} {1 {SQL logic error}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5tok2.test",
    "content": "# 2016 Jan 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nifcapable !fts5||!fts3 { finish_test ; return }\nset ::testprefix fts5tok2\n\nsqlite3_fts5_register_fts5tokenize db\n\n#-------------------------------------------------------------------------\n# Simple test cases. Using the default (ascii) tokenizer.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t5 USING fts5tokenize(unicode61);\n  CREATE VIRTUAL TABLE t3 USING fts3tokenize(unicode61);\n}\n\ndo_test 1.1 {\n  array unset -nocomplain A\n\n  for {set i 1} {$i < 65536} {incr i} {\n    set input [format \"abc%cxyz\" $i]\n      set expect [execsql {\n        SELECT input, token, start, end FROM t3 WHERE input=$input\n    }]\n\n    incr A([llength $expect])\n\n    set res [execsql {\n      SELECT input, token, start, end FROM t5($input)\n    }]\n    if {$res != $expect} {error \"failed at i=$i\"}\n  }\n} {}\n\ndo_test 1.1.nTokenChars=$A(4).nSeparators=$A(8) {} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5tokenizer.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the built-in fts5 tokenizers. \n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5tokenizer\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize=porter);\n  DROP TABLE ft1;\n}\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize='porter');\n  DROP TABLE ft1;\n}\ndo_execsql_test 1.2 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = porter);\n  DROP TABLE ft1;\n}\ndo_execsql_test 1.3 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'porter');\n  DROP TABLE ft1;\n}\ndo_execsql_test 1.4 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'porter ascii');\n  DROP TABLE ft1;\n}\n\ndo_catchsql_test 1.5 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'nosuch');\n} {1 {no such tokenizer: nosuch}}\n\ndo_catchsql_test 1.6 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize = 'porter nosuch');\n} {1 {error in tokenizer constructor}}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE ft1 USING fts5(x, tokenize=porter);\n  INSERT INTO ft1 VALUES('embedded databases');\n}\ndo_execsql_test 2.1 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'embedding' } 1\ndo_execsql_test 2.2 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'database' } 1\ndo_execsql_test 2.3 { \n  SELECT rowid FROM ft1 WHERE ft1 MATCH 'database embedding' \n} 1\n\nproc tcl_create {args} { \n  set ::targs $args\n  error \"failed\" \n}\nsqlite3_fts5_create_tokenizer db tcl tcl_create\n\nforeach {tn directive expected} {\n  1 {tokenize='tcl a b c'}             {a b c}\n  2 {tokenize='tcl ''d'' ''e'' ''f'''} {d e f}\n  3 {tokenize=\"tcl 'g' 'h' 'i'\"}       {g h i}\n  4 {tokenize = tcl}                   {}\n} {\n  do_catchsql_test 3.$tn.1 \"\n    CREATE VIRTUAL TABLE ft2 USING fts5(x, $directive)\n  \" {1 {error in tokenizer constructor}}\n  do_test 3.$tn.2 { set ::targs } $expected\n}\n\ndo_catchsql_test 4.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(x, tokenize = tcl abc);\n} {1 {parse error in \"tokenize = tcl abc\"}}\ndo_catchsql_test 4.2 {\n  CREATE VIRTUAL TABLE ft2 USING fts5(x y)\n} {1 {unrecognized column option: y}}\n\n#-------------------------------------------------------------------------\n# Test the \"separators\" and \"tokenchars\" options a bit.\n#\nforeach {tn tokenizer} {1 ascii 2 unicode61} {\n  reset_db\n  set T \"$tokenizer tokenchars ',.:' separators 'xyz'\"\n  execsql \"CREATE VIRTUAL TABLE t1 USING fts5(x, tokenize = \\\"$T\\\")\"\n  do_execsql_test 5.$tn.1 {\n    INSERT INTO t1 VALUES('abcxdefyghizjkl.mno,pqr:stu/vwx+yz');\n  }\n  foreach {tn2 token res} {\n    1 abc 1     2 def 1     3 ghi 1    4 jkl {}\n    5 mno {}    6 pqr {}    7 stu {}   8 jkl.mno,pqr:stu 1\n    9 vw  1\n  } {\n    do_execsql_test 5.$tn.2.$tn2 \"\n      SELECT rowid FROM t1 WHERE t1 MATCH '\\\"$token\\\"'\n    \" $res\n  }\n}\n\n#-------------------------------------------------------------------------\n# Miscellaneous tests for the ascii tokenizer.\n#\n# 5.1.*: Test that the ascii tokenizer ignores non-ASCII characters in the\n#        'separators' option. But unicode61 does not.\n#\n# 5.2.*: An option without an argument is an error.\n#\n\ndo_test 5.1.1 {\n  execsql \"\n    CREATE VIRTUAL TABLE a1 USING fts5(x, tokenize=`ascii separators '\\u1234'`);\n    INSERT INTO a1 VALUES('abc\\u1234def');\n  \"\n  execsql { SELECT rowid FROM a1 WHERE a1 MATCH 'def' } \n} {}\n\ndo_test 5.1.2 {\n  execsql \"\n    CREATE VIRTUAL TABLE a2 USING fts5(\n        x, tokenize=`unicode61 separators '\\u1234'`);\n    INSERT INTO a2 VALUES('abc\\u1234def');\n  \"\n  execsql { SELECT rowid FROM a2 WHERE a2 MATCH 'def' } \n} {1}\n\ndo_catchsql_test 5.2 {\n  CREATE VIRTUAL TABLE a3 USING fts5(x, y, tokenize = 'ascii tokenchars');\n} {1 {error in tokenizer constructor}}\ndo_catchsql_test 5.3 {\n  CREATE VIRTUAL TABLE a3 USING fts5(x, y, tokenize = 'ascii opt arg');\n} {1 {error in tokenizer constructor}}\n\n#-------------------------------------------------------------------------\n# Test that the ASCII and unicode61 tokenizers both handle SQLITE_DONE \n# correctly.\n#\n\nproc test_token_cb {varname token iStart iEnd} {\n  upvar $varname var\n  lappend var $token\n  if {[llength $var]==3} { return \"SQLITE_DONE\" }\n  return \"SQLITE_OK\"\n}\n\nproc tokenize {cmd} {\n  set res [list]\n  $cmd xTokenize [$cmd xColumnText 0] [list test_token_cb res]\n  set res\n}\nsqlite3_fts5_create_function db tokenize tokenize\n\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(a, tokenize=ascii);\n  INSERT INTO x1 VALUES('q w e r t y');\n  INSERT INTO x1 VALUES('y t r e w q');\n  SELECT tokenize(x1) FROM x1 WHERE x1 MATCH 'e AND r';\n} {\n  {q w e} {y t r}\n}\n\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE x2 USING fts5(a, tokenize=unicode61);\n  INSERT INTO x2 VALUES('q w e r t y');\n  INSERT INTO x2 VALUES('y t r e w q');\n  SELECT tokenize(x2) FROM x2 WHERE x2 MATCH 'e AND r';\n} {\n  {q w e} {y t r}\n}\n\n\n#-------------------------------------------------------------------------\n# Miscellaneous tests for the unicode tokenizer.\n#\ndo_catchsql_test 6.1 {\n  CREATE VIRTUAL TABLE a3 USING fts5(x, y, tokenize = 'unicode61 tokenchars');\n} {1 {error in tokenizer constructor}}\ndo_catchsql_test 6.2 {\n  CREATE VIRTUAL TABLE a3 USING fts5(x, y, tokenize = 'unicode61 a b');\n} {1 {error in tokenizer constructor}}\ndo_catchsql_test 6.3 {\n  CREATE VIRTUAL TABLE a3 USING fts5(\n    x, y, tokenize = 'unicode61 remove_diacritics 2'\n  );\n} {1 {error in tokenizer constructor}}\ndo_catchsql_test 6.4 {\n  CREATE VIRTUAL TABLE a3 USING fts5(\n    x, y, tokenize = 'unicode61 remove_diacritics 10'\n  );\n} {1 {error in tokenizer constructor}}\n\n#-------------------------------------------------------------------------\n# Porter tokenizer with very large tokens.\n#\nset a [string repeat a 100]\nset b [string repeat b 500]\nset c [string repeat c 1000]\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE e5 USING fts5(x, tokenize=porter);\n  INSERT INTO e5 VALUES($a || ' ' || $b);\n  INSERT INTO e5 VALUES($b || ' ' || $c);\n  INSERT INTO e5 VALUES($c || ' ' || $a);\n}\n\ndo_execsql_test 7.1 {SELECT rowid FROM e5 WHERE e5 MATCH $a} { 1 3 }\ndo_execsql_test 7.2 {SELECT rowid FROM e5 WHERE e5 MATCH $b} { 1 2 }\ndo_execsql_test 7.3 {SELECT rowid FROM e5 WHERE e5 MATCH $c} { 2 3 }\n\n#-------------------------------------------------------------------------\n# Test the 'separators' option with the unicode61 tokenizer.\n#\ndo_execsql_test 8.1 {\n  BEGIN;\n  CREATE VIRTUAL TABLE e6 USING fts5(x,\n    tokenize=\"unicode61 separators ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n  );\n  INSERT INTO e6 VALUES('theAquickBbrownCfoxDjumpedWoverXtheYlazyZdog');\n  CREATE VIRTUAL TABLE e7 USING fts5vocab(e6, 'row');\n  SELECT term FROM e7;\n  ROLLBACK;\n} {\n  brown dog fox jumped lazy over quick the\n}\n\ndo_execsql_test 8.2 [subst {\n  BEGIN;\n  CREATE VIRTUAL TABLE e6 USING fts5(x,\n    tokenize=\"unicode61 separators '\\u0E01\\u0E02\\u0E03\\u0E04\\u0E05\\u0E06\\u0E07'\"\n  );\n  INSERT INTO e6 VALUES('the\\u0E01quick\\u0E01brown\\u0E01fox\\u0E01' \n                     || 'jumped\\u0E01over\\u0E01the\\u0E01lazy\\u0E01dog'\n  );\n  INSERT INTO e6 VALUES('\\u0E08\\u0E07\\u0E09');\n  CREATE VIRTUAL TABLE e7 USING fts5vocab(e6, 'row');\n  SELECT term FROM e7;\n  ROLLBACK;\n}] [subst {\n  brown dog fox jumped lazy over quick the \\u0E08 \\u0E09\n}]\n\n# Test that the porter tokenizer correctly passes arguments through to\n# its parent tokenizer.\ndo_execsql_test 8.3 {\n  BEGIN;\n  CREATE VIRTUAL TABLE e6 USING fts5(x,\n    tokenize=\"porter unicode61 separators ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n  );\n  INSERT INTO e6 VALUES('theAquickBbrownCfoxDjumpedWoverXtheYlazyZdog');\n  CREATE VIRTUAL TABLE e7 USING fts5vocab(e6, 'row');\n  SELECT term FROM e7;\n  ROLLBACK;\n} {\n  brown dog fox jump lazi over quick the\n}\n\n#-------------------------------------------------------------------------\n# Check that the FTS5_TOKENIZE_PREFIX flag is passed to the tokenizer\n# implementation.\n#\nreset_db\nproc tcl_create {args} { return \"tcl_tokenize\" }\nsqlite3_fts5_create_tokenizer db tcl tcl_create\nset ::flags [list]\nproc tcl_tokenize {tflags text} {\n  lappend ::flags $tflags\n  foreach {w iStart iEnd} [fts5_tokenize_split $text] {\n    sqlite3_fts5_token $w $iStart $iEnd\n  }\n}\n\ndo_execsql_test 9.1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, tokenize=tcl);\n  INSERT INTO t1 VALUES('abc');\n  INSERT INTO t1 VALUES('xyz');\n} {}\ndo_test 9.1.2 { set ::flags } {document document}\n\nset ::flags [list]\ndo_execsql_test 9.2.1 { SELECT * FROM t1('abc'); } {abc}\ndo_test 9.2.2 { set ::flags } {query}\n\nset ::flags [list]\ndo_execsql_test 9.3.1 { SELECT * FROM t1('ab*'); } {abc}\ndo_test 9.3.2 { set ::flags } {prefixquery}\n\nset ::flags [list]\ndo_execsql_test 9.4.1 { SELECT * FROM t1('\"abc xyz\" *'); } {}\ndo_test 9.4.2 { set ::flags } {prefixquery}\n\nset ::flags [list]\ndo_execsql_test 9.5.1 { SELECT * FROM t1('\"abc xyz*\"'); } {}\ndo_test 9.5.2 { set ::flags } {query}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5unicode.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the fts5 tokenizers\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5unicode\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc tokenize_test {tn tokenizer input output} {\n  uplevel [list do_test $tn [subst -nocommands {\n    set ret {}\n    foreach {z s e} [sqlite3_fts5_tokenize db {$tokenizer} {$input}] {\n      lappend ret [set z]\n    }\n    set ret\n  }] [list {*}$output]]\n}\n\nforeach {tn t} {1 ascii 2 unicode61} {\n  tokenize_test 1.$tn.0 $t {A B C D} {a b c d}\n  tokenize_test 1.$tn.1 $t {May you share freely,} {may you share freely}\n  tokenize_test 1.$tn.2 $t {..May...you.shAre.freely} {may you share freely}\n  tokenize_test 1.$tn.3 $t {} {}\n}\n\n#-------------------------------------------------------------------------\n# Check that \"unicode61\" really is the default tokenizer.\n#\n\ndo_execsql_test 2.0 \"\n  CREATE VIRTUAL TABLE t1 USING fts5(x);\n  CREATE VIRTUAL TABLE t2 USING fts5(x, tokenize = unicode61);\n  CREATE VIRTUAL TABLE t3 USING fts5(x, tokenize = ascii);\n  INSERT INTO t1 VALUES('\\xC0\\xC8\\xCC');\n  INSERT INTO t2 VALUES('\\xC0\\xC8\\xCC');\n  INSERT INTO t3 VALUES('\\xC0\\xC8\\xCC');\n\"\ndo_execsql_test 2.1 \"\n  SELECT 't1' FROM t1 WHERE t1 MATCH '\\xE0\\xE8\\xEC';\n  SELECT 't2' FROM t2 WHERE t2 MATCH '\\xE0\\xE8\\xEC';\n  SELECT 't3' FROM t3 WHERE t3 MATCH '\\xE0\\xE8\\xEC';\n\" {t1 t2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5unicode2.test",
    "content": "# 2012 May 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# The tests in this file focus on testing the \"unicode\" FTS tokenizer.\n#\n# This is a modified copy of FTS4 test file \"fts4_unicode.test\".\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5unicode2\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc do_unicode_token_test {tn input res} {\n  uplevel [list do_test $tn [list \\\n    sqlite3_fts5_tokenize -subst db \"unicode61 remove_diacritics 0\" $input\n  ] [list {*}$res]]\n}\n\nproc do_unicode_token_test2 {tn input res} {\n  uplevel [list do_test $tn [list \\\n    sqlite3_fts5_tokenize -subst db \"unicode61\" $input\n  ] [list {*}$res]]\n}\n\nproc do_unicode_token_test3 {tn args} {\n  set tokenizer [concat unicode61 {*}[lrange $args 0 end-2]]\n  set input [lindex $args end-1]\n  set res [lindex $args end]\n  uplevel [list do_test $tn [list \\\n    sqlite3_fts5_tokenize -subst db $tokenizer $input\n  ] [list {*}$res]]\n}\n\ndo_unicode_token_test 1.0 {a B c D} {a a b B c c d D}\n\ndo_unicode_token_test 1.1 \"\\uC4 \\uD6 \\uDC\" \\\n    \"\\uE4 \\uC4 \\uF6 \\uD6 \\uFC \\uDC\"\n\ndo_unicode_token_test 1.2 \"x\\uC4x x\\uD6x x\\uDCx\" \\\n    \"x\\uE4x x\\uC4x x\\uF6x x\\uD6x x\\uFCx x\\uDCx\"\n\n# 0x00DF is a small \"sharp s\". 0x1E9E is a capital sharp s.\ndo_unicode_token_test 1.3 \"\\uDF\" \"\\uDF \\uDF\"\ndo_unicode_token_test 1.4 \"\\u1E9E\" \"\\uDF \\u1E9E\"\n\ndo_unicode_token_test 1.5 \"The quick brown fox\" {\n  the The quick quick brown brown fox fox\n}\ndo_unicode_token_test 1.6 \"The\\u00bfquick\\u224ebrown\\u2263fox\" {\n  the The quick quick brown brown fox fox\n}\n\ndo_unicode_token_test2 1.7  {a B c D} {a a b B c c d D}\ndo_unicode_token_test2 1.8  \"\\uC4 \\uD6 \\uDC\" \"a \\uC4 o \\uD6 u \\uDC\"\n\ndo_unicode_token_test2 1.9  \"x\\uC4x x\\uD6x x\\uDCx\" \\\n    \"xax x\\uC4x xox x\\uD6x xux x\\uDCx\"\n\n# Check that diacritics are removed if remove_diacritics=1 is specified.\n# And that they do not break tokens.\ndo_unicode_token_test2 1.10 \"xx\\u0301xx\" \"xxxx xx\\u301xx\"\n\n# Title-case mappings work\ndo_unicode_token_test 1.11 \"\\u01c5\" \"\\u01c6 \\u01c5\"\n\ndo_unicode_token_test 1.12 \"\\u00C1abc\\u00C2 \\u00D1def\\u00C3\" \\\n    \"\\u00E1abc\\u00E2 \\u00C1abc\\u00C2 \\u00F1def\\u00E3 \\u00D1def\\u00C3\"\n\ndo_unicode_token_test 1.13 \"\\u00A2abc\\u00A3 \\u00A4def\\u00A5\" \\\n    \"abc abc def def\"\n\n#-------------------------------------------------------------------------\n#\nset docs [list {\n  Enhance the INSERT syntax to allow multiple rows to be inserted via the\n  VALUES clause.\n} {\n  Enhance the CREATE VIRTUAL TABLE command to support the IF NOT EXISTS clause.\n} {\n  Added the sqlite3_stricmp() interface as a counterpart to sqlite3_strnicmp().\n} {\n  Added the sqlite3_db_readonly() interface.\n} {\n  Added the SQLITE_FCNTL_PRAGMA file control, giving VFS implementations the\n  ability to add new PRAGMA statements or to override built-in PRAGMAs.  \n} {\n  Queries of the form: \"SELECT max(x), y FROM table\" returns the value of y on\n  the same row that contains the maximum x value.\n} {\n  Added support for the FTS4 languageid option.\n} {\n  Documented support for the FTS4 content option. This feature has actually\n  been in the code since version 3.7.9 but is only now considered to be\n  officially supported.  \n} {\n  Pending statements no longer block ROLLBACK. Instead, the pending statement\n  will return SQLITE_ABORT upon next access after the ROLLBACK.  \n} {\n  Improvements to the handling of CSV inputs in the command-line shell\n} {\n  Fix a bug introduced in version 3.7.10 that might cause a LEFT JOIN to be\n  incorrectly converted into an INNER JOIN if the WHERE clause indexable terms\n  connected by OR.  \n}]\n\nset map(a) [list \"\\u00C4\" \"\\u00E4\"]  ; # LATIN LETTER A WITH DIAERESIS\nset map(e) [list \"\\u00CB\" \"\\u00EB\"]  ; # LATIN LETTER E WITH DIAERESIS\nset map(i) [list \"\\u00CF\" \"\\u00EF\"]  ; # LATIN LETTER I WITH DIAERESIS\nset map(o) [list \"\\u00D6\" \"\\u00F6\"]  ; # LATIN LETTER O WITH DIAERESIS\nset map(u) [list \"\\u00DC\" \"\\u00FC\"]  ; # LATIN LETTER U WITH DIAERESIS\nset map(y) [list \"\\u0178\" \"\\u00FF\"]  ; # LATIN LETTER Y WITH DIAERESIS\nset map(h) [list \"\\u1E26\" \"\\u1E27\"]  ; # LATIN LETTER H WITH DIAERESIS\nset map(w) [list \"\\u1E84\" \"\\u1E85\"]  ; # LATIN LETTER W WITH DIAERESIS\nset map(x) [list \"\\u1E8C\" \"\\u1E8D\"]  ; # LATIN LETTER X WITH DIAERESIS\nforeach k [array names map] {\n  lappend mappings [string toupper $k] [lindex $map($k) 0] \n  lappend mappings $k [lindex $map($k) 1]\n}\nproc mapdoc {doc} { \n  set doc [regsub -all {[[:space:]]+} $doc \" \"]\n  string map $::mappings [string trim $doc] \n}\n\ndo_test 2.0 {\n  execsql { CREATE VIRTUAL TABLE t2 USING fts5(tokenize=unicode61, x); }\n  foreach doc $docs {\n    set d [mapdoc $doc]\n    execsql { INSERT INTO t2 VALUES($d) }\n  }\n} {}\n\ndo_test 2.1 {\n  set q [mapdoc \"row\"]\n  execsql { SELECT * FROM t2 WHERE t2 MATCH $q }\n} [list [mapdoc {\n  Queries of the form: \"SELECT max(x), y FROM table\" returns the value of y on\n  the same row that contains the maximum x value.\n}]]\n\nforeach {tn query snippet} {\n  2 \"row\" {\n     ...returns the value of y on the same [row] that contains \n     the maximum x value.\n  }\n  3 \"ROW\" {\n     ...returns the value of y on the same [row] that contains \n     the maximum x value.\n  }\n  4 \"rollback\" {\n     Pending statements no longer block [ROLLBACK]. Instead, the pending\n     statement will return SQLITE_ABORT upon...\n  }\n  5 \"rOllback\" {\n     Pending statements no longer block [ROLLBACK]. Instead, the pending\n     statement will return SQLITE_ABORT upon...\n  }\n  6 \"lang*\" {\n     Added support for the FTS4 [languageid] option.\n  }\n} {\n  do_test 2.$tn {\n    set q [mapdoc $query]\n    execsql { \n      SELECT snippet(t2, -1, '[', ']', '...', 15) FROM t2 WHERE t2 MATCH $q \n    }\n  } [list [mapdoc $snippet]]\n}\n\n#-------------------------------------------------------------------------\n# Make sure the unicode61 tokenizer does not crash if it is passed a \n# NULL pointer.\nreset_db\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(tokenize=unicode61, x, y);\n  INSERT INTO t1 VALUES(NULL, 'a b c');\n}\n\ndo_execsql_test 3.2 {\n  SELECT snippet(t1, -1, '[', ']', '...', 15) FROM t1 WHERE t1 MATCH 'b'\n} {{a [b] c}}\n\ndo_execsql_test 3.3 {\n  BEGIN;\n  DELETE FROM t1;\n  INSERT INTO t1 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 VALUES('a b c', NULL);\n  INSERT INTO t1 VALUES('a x c', NULL);\n  COMMIT;\n}\n\ndo_execsql_test 3.4 {\n  SELECT * FROM t1 WHERE t1 MATCH 'a b';\n} {{a b c} {}}\n\n#-------------------------------------------------------------------------\n#\nreset_db\n\ndo_test 4.1 {\n  set a \"abc\\uFFFEdef\"\n  set b \"abc\\uD800def\"\n  set c \"\\uFFFEdef\"\n  set d \"\\uD800def\"\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts5(tokenize=unicode61, x);\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n\n  execsql \"CREATE VIRTUAL TABLE t8 USING fts5(\n      a, b, tokenize=\\\"unicode61 separators '\\uFFFE\\uD800\\u00BF'\\\"\n  )\"\n} {}\n\ndo_test 4.2 {\n  set a [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0x62}]\n  set b [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0x62}]\n  set c [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]\n  set d [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]\n  execsql {\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n} {}\n\ndo_test 4.3 {\n  set a [binary format c* {0xF7 0xBF 0xBF 0xBF}]\n  set b [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF}]\n  set c [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF}]\n  set d [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF}]\n  execsql {\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n} {}\n\ndo_test 4.4 {\n  sqlite3_exec_hex db {\n    CREATE VIRTUAL TABLE t9 USING fts5(a, b, \n      tokenize=\"unicode61 separators '%C09004'\"\n    );\n    INSERT INTO t9(a) VALUES('abc%88def %89ghi%90');\n  }\n} {0 {}}\n\n\n#-------------------------------------------------------------------------\n\ndo_unicode_token_test3 5.1 {tokenchars {}} {\n  sqlite3_reset sqlite3_column_int\n} {\n  sqlite3 sqlite3 \n  reset reset \n  sqlite3 sqlite3 \n  column column \n  int int\n}\n\ndo_unicode_token_test3 5.2 {tokenchars _} {\n  sqlite3_reset sqlite3_column_int\n} {\n  sqlite3_reset sqlite3_reset \n  sqlite3_column_int sqlite3_column_int\n}\n\ndo_unicode_token_test3 5.3 {separators xyz} {\n  Laotianxhorseyrunszfast\n} {\n  laotian Laotian\n  horse horse\n  runs runs\n  fast fast\n}\n\ndo_unicode_token_test3 5.4 {tokenchars xyz} {\n  Laotianxhorseyrunszfast\n} {\n  laotianxhorseyrunszfast Laotianxhorseyrunszfast\n}\n\ndo_unicode_token_test3 5.5 {tokenchars _} {separators zyx} {\n  sqlite3_resetxsqlite3_column_intyhonda_phantom\n} {\n  sqlite3_reset sqlite3_reset \n  sqlite3_column_int sqlite3_column_int\n  honda_phantom honda_phantom\n}\n\ndo_unicode_token_test3 5.6 \"separators \\u05D1\" \"abc\\u05D1def\" {\n  abc abc def def\n}\n\ndo_unicode_token_test3 5.7                             \\\n  \"tokenchars \\u2444\\u2445\"                            \\\n  \"separators \\u05D0\\u05D1\\u05D2\"                      \\\n  \"\\u2444fre\\u2445sh\\u05D0water\\u05D2fish.\\u2445timer\" \\\n  [list                                                \\\n    \\u2444fre\\u2445sh \\u2444fre\\u2445sh              \\\n    water water                                      \\\n    fish fish                                        \\\n    \\u2445timer \\u2445timer                          \\\n  ]\n\n# Check that it is not possible to add a standalone diacritic codepoint \n# to either separators or tokenchars.\ndo_unicode_token_test3 5.8 \"separators \\u0301\" \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"helloworld hello\\u0301world helloworld helloworld\"\n\ndo_unicode_token_test3 5.9 \"tokenchars \\u0301\" \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"helloworld hello\\u0301world helloworld helloworld\"\n\ndo_unicode_token_test3 5.10 \"separators \\u0301\" \\\n  \"remove_diacritics 0\"                        \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"hello\\u0301world hello\\u0301world helloworld helloworld\"\n\ndo_unicode_token_test3 5.11 \"tokenchars \\u0301\" \\\n  \"remove_diacritics 0\"                         \\\n  \"hello\\u0301world \\u0301helloworld\"           \\\n  \"hello\\u0301world hello\\u0301world helloworld helloworld\"\n\n#-------------------------------------------------------------------------\n\nproc do_tokenize {tokenizer txt} {\n  set res [list]\n  foreach {b c} [sqlite3_fts5_tokenize -subst db $tokenizer $txt] {\n    lappend res $b\n  }\n  set res\n}\n\n# Argument $lCodepoint must be a list of codepoints (integers) that \n# correspond to whitespace characters. This command creates a string\n# $W from the codepoints, then tokenizes \"${W}hello{$W}world${W}\" \n# using tokenizer $tokenizer. The test passes if the tokenizer successfully\n# extracts the two 5 character tokens.\n#\nproc do_isspace_test {tn tokenizer lCp} {\n  set whitespace [format [string repeat %c [llength $lCp]] {*}$lCp] \n  set txt \"${whitespace}hello${whitespace}world${whitespace}\"\n  uplevel [list do_test $tn [list do_tokenize $tokenizer $txt] {hello world}]\n}\n\nset tokenizers [list unicode61]\n#ifcapable icu { lappend tokenizers icu }\n\n# Some tests to check that the tokenizers can both identify white-space \n# codepoints. All codepoints tested below are of type \"Zs\" in the\n# UnicodeData.txt file.\nforeach T $tokenizers {\n  do_isspace_test 6.$T.1 $T    32\n  do_isspace_test 6.$T.2 $T    160\n  do_isspace_test 6.$T.3 $T    5760\n  do_isspace_test 6.$T.4 $T    6158\n  do_isspace_test 6.$T.5 $T    8192\n  do_isspace_test 6.$T.6 $T    8193\n  do_isspace_test 6.$T.7 $T    8194\n  do_isspace_test 6.$T.8 $T    8195\n  do_isspace_test 6.$T.9 $T    8196\n  do_isspace_test 6.$T.10 $T    8197\n  do_isspace_test 6.$T.11 $T    8198\n  do_isspace_test 6.$T.12 $T    8199\n  do_isspace_test 6.$T.13 $T    8200\n  do_isspace_test 6.$T.14 $T    8201\n  do_isspace_test 6.$T.15 $T    8202\n  do_isspace_test 6.$T.16 $T    8239\n  do_isspace_test 6.$T.17 $T    8287\n  do_isspace_test 6.$T.18 $T   12288\n\n  do_isspace_test 6.$T.19 $T   {32 160 5760 6158}\n  do_isspace_test 6.$T.20 $T   {8192 8193 8194 8195}\n  do_isspace_test 6.$T.21 $T   {8196 8197 8198 8199}\n  do_isspace_test 6.$T.22 $T   {8200 8201 8202 8239}\n  do_isspace_test 6.$T.23 $T   {8287 12288}\n}\n\n\n#-------------------------------------------------------------------------\n# Test that the private use ranges are treated as alphanumeric.\n#\nforeach {tn1 c} {\n  1 \\ue000 2 \\ue001 3 \\uf000 4 \\uf8fe 5 \\uf8ff\n} {\n  foreach {tn2 config res} {\n    1 \"\"             \"hello*world hello*world\"\n    2 \"separators *\" \"hello hello world world\"\n  } {\n    set config [string map [list * $c] $config]\n    set input  [string map [list * $c] \"hello*world\"]\n    set output [string map [list * $c] $res]\n    do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output\n  }\n}\n\n#-------------------------------------------------------------------------\n# Cursory test of remove_diacritics=0.\n#\n# 00C4;LATIN CAPITAL LETTER A WITH DIAERESIS\n# 00D6;LATIN CAPITAL LETTER O WITH DIAERESIS\n# 00E4;LATIN SMALL LETTER A WITH DIAERESIS\n# 00F6;LATIN SMALL LETTER O WITH DIAERESIS\n#\ndo_execsql_test 8.1.1 \"\n  CREATE VIRTUAL TABLE t3 USING fts5(\n    content, tokenize='unicode61 remove_diacritics 1'\n  );\n  INSERT INTO t3 VALUES('o');\n  INSERT INTO t3 VALUES('a');\n  INSERT INTO t3 VALUES('O');\n  INSERT INTO t3 VALUES('A');\n  INSERT INTO t3 VALUES('\\xD6');\n  INSERT INTO t3 VALUES('\\xC4');\n  INSERT INTO t3 VALUES('\\xF6');\n  INSERT INTO t3 VALUES('\\xE4');\n\"\ndo_execsql_test 8.1.2 {\n  SELECT rowid FROM t3 WHERE t3 MATCH 'o' ORDER BY rowid ASC;\n} {1 3 5 7}\ndo_execsql_test 8.1.3 {\n  SELECT rowid FROM t3 WHERE t3 MATCH 'a' ORDER BY rowid ASC;\n} {2 4 6 8}\ndo_execsql_test 8.2.1 {\n  CREATE VIRTUAL TABLE t4 USING fts5(\n    content, tokenize='unicode61 remove_diacritics 0'\n  );\n  INSERT INTO t4 SELECT * FROM t3 ORDER BY rowid ASC;\n}\ndo_execsql_test 8.2.2 {\n  SELECT rowid FROM t4 WHERE t4 MATCH 'o' ORDER BY rowid ASC;\n} {1 3}\ndo_execsql_test 8.2.3 {\n  SELECT rowid FROM t4 WHERE t4 MATCH 'a' ORDER BY rowid ASC;\n} {2 4}\n\n#-------------------------------------------------------------------------\n#\nif 0 {\nforeach {tn sql} {\n  1 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 [tokenchars= .]);\n    CREATE VIRTUAL TABLE t6 USING fts4(\n        tokenize=unicode61 [tokenchars==\"] \"tokenchars=[]\");\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 [separators=x\\xC4]);\n  }\n  2 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 \"tokenchars= .\");\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 \"tokenchars=[=\"\"]\");\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 \"separators=x\\xC4\");\n  }\n  3 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 'tokenchars= .');\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 'tokenchars==\"[]');\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 'separators=x\\xC4');\n  }\n  4 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 `tokenchars= .`);\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 `tokenchars=[=\"]`);\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 `separators=x\\xC4`);\n  }\n} {\n  do_execsql_test 9.$tn.0 { \n    DROP TABLE IF EXISTS t5;\n    DROP TABLE IF EXISTS t5aux;\n    DROP TABLE IF EXISTS t6;\n    DROP TABLE IF EXISTS t6aux;\n    DROP TABLE IF EXISTS t7;\n    DROP TABLE IF EXISTS t7aux;\n  }\n  do_execsql_test 9.$tn.1 $sql\n\n  do_execsql_test 9.$tn.2 {\n    CREATE VIRTUAL TABLE t5aux USING fts4aux(t5);\n    INSERT INTO t5 VALUES('one two three/four.five.six');\n    SELECT * FROM t5aux;\n  } {\n    four.five.six   * 1 1 four.five.six   0 1 1 \n    {one two three} * 1 1 {one two three} 0 1 1\n  }\n\n  do_execsql_test 9.$tn.3 {\n    CREATE VIRTUAL TABLE t6aux USING fts4aux(t6);\n    INSERT INTO t6 VALUES('alpha=beta\"gamma/delta[epsilon]zeta');\n    SELECT * FROM t6aux;\n  } {\n    {alpha=beta\"gamma}   * 1 1 {alpha=beta\"gamma} 0 1 1 \n    {delta[epsilon]zeta} * 1 1 {delta[epsilon]zeta} 0 1 1\n  }\n\n  do_execsql_test 9.$tn.4 {\n    CREATE VIRTUAL TABLE t7aux USING fts4aux(t7);\n    INSERT INTO t7 VALUES('alephxbeth\\xC4gimel');\n    SELECT * FROM t7aux;\n  } {\n    aleph * 1 1 aleph 0 1 1 \n    beth  * 1 1 beth  0 1 1 \n    gimel * 1 1 gimel 0 1 1\n  }\n}\n\n# Check that multiple options are handled correctly.\n#\ndo_execsql_test 10.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61\n    \"tokenchars=xyz\" \"tokenchars=.=\" \"separators=.=\" \"separators=xy\"\n    \"separators=a\" \"separators=a\" \"tokenchars=a\" \"tokenchars=a\"\n  );\n\n  INSERT INTO t1 VALUES('oneatwoxthreeyfour');\n  INSERT INTO t1 VALUES('a.single=word');\n  CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);\n  SELECT * FROM t1aux;\n} {\n  .single=word * 1 1 .single=word 0 1 1 \n  four         * 1 1 four         0 1 1 \n  one          * 1 1 one          0 1 1 \n  three        * 1 1 three        0 1 1 \n  two          * 1 1 two          0 1 1\n}\n\n# Test that case folding happens after tokenization, not before.\n#\ndo_execsql_test 10.2 {\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61 \"separators=aB\");\n  INSERT INTO t2 VALUES('oneatwoBthree');\n  INSERT INTO t2 VALUES('onebtwoAthree');\n  CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);\n  SELECT * FROM t2aux;\n} {\n  one           * 1 1 one           0 1 1 \n  onebtwoathree * 1 1 onebtwoathree 0 1 1 \n  three         * 1 1 three         0 1 1 \n  two           * 1 1 two           0 1 1\n}\n\n# Test that the tokenchars and separators options work with the \n# fts3tokenize table.\n#\ndo_execsql_test 11.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts3tokenize(\n    \"unicode61\", \"tokenchars=@.\", \"separators=1234567890\"\n  );\n  SELECT token FROM ft1 WHERE input = 'berlin@street123sydney.road';\n} {\n  berlin@street sydney.road\n}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5unicode3.test",
    "content": "# 2014 Dec 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests focusing on the fts5 tokenizers\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nproc fts3_unicode_path {file} {\n  file join [file dirname [info script]] .. .. fts3 unicode $file\n}\n\nsource [fts3_unicode_path parseunicode.tcl]\nset testprefix fts5unicode3\n\nset CF [fts3_unicode_path CaseFolding.txt]\nset UD [fts3_unicode_path UnicodeData.txt]\n\ntl_load_casefolding_txt $CF\nforeach x [an_load_unicodedata_text $UD] {\n  set aNotAlnum($x) 1\n}\n\nforeach {y} [rd_load_unicodedata_text $UD] {\n  foreach {code ascii} $y {}\n  if {$ascii==\"\"} {\n    set int 0\n  } else {\n    binary scan $ascii c int\n  }\n  set aDiacritic($code) $int\n}\n\nproc tcl_fold {i {bRemoveDiacritic 0}} {\n  global tl_lookup_table\n  global aDiacritic\n\n  if {[info exists tl_lookup_table($i)]} {\n    set i $tl_lookup_table($i)\n  }\n  if {$bRemoveDiacritic && [info exists aDiacritic($i)]} {\n    set i $aDiacritic($i)\n  }\n  expr $i\n}\ndb func tcl_fold tcl_fold\n\nproc tcl_isalnum {i} {\n  global aNotAlnum\n  expr {![info exists aNotAlnum($i)]}\n}\ndb func tcl_isalnum tcl_isalnum\n\n\ndo_catchsql_test 1.0.1 {\n  SELECT fts5_isalnum(1, 2, 3);\n} {1 {wrong number of arguments to function fts5_isalnum}}\ndo_catchsql_test 1.0.2 {\n  SELECT fts5_fold();\n} {1 {wrong number of arguments to function fts5_fold}}\ndo_catchsql_test 1.0.3 {\n  SELECT fts5_fold(1,2,3);\n} {1 {wrong number of arguments to function fts5_fold}}\n\ndo_execsql_test 1.1 {\n  WITH ii(i) AS (\n    SELECT -1\n    UNION ALL\n    SELECT i+1 FROM ii WHERE i<100000\n  )\n  SELECT count(*), min(i) FROM ii WHERE fts5_fold(i)!=CAST(tcl_fold(i) AS int);\n} {0 {}}\n\ndo_execsql_test 1.2 {\n  WITH ii(i) AS (\n    SELECT -1\n    UNION ALL\n    SELECT i+1 FROM ii WHERE i<100000\n  )\n  SELECT count(*), min(i) FROM ii \n  WHERE fts5_fold(i,1)!=CAST(tcl_fold(i,1) AS int);\n} {0 {}}\n\ndo_execsql_test 1.3 {\n  WITH ii(i) AS (\n    SELECT -1\n    UNION ALL\n    SELECT i+1 FROM ii WHERE i<100000\n  )\n  SELECT count(*), min(i) FROM ii \n  WHERE fts5_isalnum(i)!=CAST(tcl_isalnum(i) AS int);\n} {0 {}}\n\ndo_test 1.4 {\n  set str {CREATE VIRTUAL TABLE f3 USING fts5(a, tokenize=}\n  append str {\"unicode61 separators '}\n  for {set i 700} {$i<900} {incr i} {\n    append str [format %c $i]\n  }\n  append str {'\");}\n  execsql $str\n} {}\ndo_test 1.5 {\n  set str {CREATE VIRTUAL TABLE f5 USING fts5(a, tokenize=}\n  append str {\"unicode61 tokenchars '}\n  for {set i 700} {$i<900} {incr i} {\n    append str [format %c $i]\n  }\n  append str {'\");}\n  execsql $str\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5unindexed.test",
    "content": "# 2015 Apr 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file focus on \"unindexed\" columns.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5unindexed\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b UNINDEXED);\n  INSERT INTO t1 VALUES('a b c', 'd e f');\n  INSERT INTO t1 VALUES('g h i', 'j k l');\n} {}\n\ndo_execsql_test 1.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'b' } {1}\ndo_execsql_test 1.3 { SELECT rowid FROM t1 WHERE t1 MATCH 'e' } {}\n\ndo_execsql_test 1.4 { INSERT INTO t1(t1) VALUES('integrity-check') } {}\ndo_execsql_test 1.5 { INSERT INTO t1(t1) VALUES('rebuild') } {}\ndo_execsql_test 1.6 { INSERT INTO t1(t1) VALUES('integrity-check') } {}\n\ndo_execsql_test 1.7 { SELECT rowid FROM t1 WHERE t1 MATCH 'b' } {1}\ndo_execsql_test 1.8 { SELECT rowid FROM t1 WHERE t1 MATCH 'e' } {}\n\ndo_execsql_test 1.9 { DELETE FROM t1 WHERE t1 MATCH 'b' } {}\n\ndo_execsql_test 1.10 { INSERT INTO t1(t1) VALUES('integrity-check') } {}\ndo_execsql_test 1.11 { INSERT INTO t1(t1) VALUES('rebuild') } {}\ndo_execsql_test 1.12 { INSERT INTO t1(t1) VALUES('integrity-check') } {}\n\ndo_execsql_test 1.13 { SELECT rowid FROM t1 WHERE t1 MATCH 'i' } {2}\ndo_execsql_test 1.14 { SELECT rowid FROM t1 WHERE t1 MATCH 'l' } {}\n\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE t2 USING fts5(a UNINDEXED, b UNINDEXED);\n  INSERT INTO t1 VALUES('a b c', 'd e f');\n  INSERT INTO t1 VALUES('g h i', 'j k l');\n  SELECT rowid FROM t2_data;\n} {1 10}\ndo_execsql_test 2.2 {\n  INSERT INTO t2(t2) VALUES('rebuild');\n  INSERT INTO t2(t2) VALUES('integrity-check');\n  SELECT rowid FROM t2_data;\n} {1 10}\n\ndo_execsql_test 3.1 {\n  CREATE TABLE x4(i INTEGER PRIMARY KEY, a, b, c);\n  CREATE VIRTUAL TABLE t4 USING fts5(a, b UNINDEXED, c, content=x4);\n  INSERT INTO x4 VALUES(10, 'a b c', 'd e f', 'g h i');\n  INSERT INTO x4 VALUES(20, 'j k l', 'm n o', 'p q r');\n  INSERT INTO t4(t4) VALUES('rebuild');\n  INSERT INTO t4(t4) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 3.2 {\n  INSERT INTO t4(t4, rowid, a, b, c) VALUES('delete', 20, 'j k l', '', 'p q r');\n  DELETE FROM x4 WHERE rowid=20;\n  INSERT INTO t4(t4) VALUES('integrity-check');\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5update.test",
    "content": "# 2016 Jan 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS5 module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5update\n\n# If SQLITE_ENABLE_FTS5 is not defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nset docs {\n  \"eight zero iv eight 7\"            \"ix one 8 one three ii one\"        \n  \"1 9 9 three viii\"                 \"5 zero ii 6 nine ix 3\"            \n  \"3 zero 5 2 seven nine\"            \"two eight viii eight 1\"           \n  \"4 six two 5 9 vii\"                \"viii ii four 8 i i iv\"            \n  \"vii 0 iv seven 7 viii\"            \"five 1 nine vi seven\"             \n  \"1 zero zero iii 1\"                \"one one six 6 nine seven\"         \n  \"one v 4 zero 4 iii ii\"            \"2 3 eight six ix\"                 \n  \"six iv 7 three 5\"                 \"ix zero 0 8 ii 7 3\"               \n  \"four six nine 2 vii 3\"            \"five viii 5 8 0 7\"                \n}\n\nforeach_detail_mode $::testprefix {\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);\n} {}\n\ndo_test 1.1 {\n  foreach {a b} $docs {\n    execsql {INSERT INTO t1 VALUES($a, $b)}\n  }\n} {}\n\nproc update {iRowid iA iB} {\n  set a [lindex $::docs $iA]\n  set b [lindex $::docs $iB]\n  execsql { UPDATE t1 SET a=$a, b=$b WHERE rowid=$iRowid }\n}\n\nset nDoc [llength $::docs]\nforeach n {1 5 10 50 100} {\n  do_test 1.2.$n {\n    execsql BEGIN\n    for {set i 1} {$i <= 1000} {incr i} {\n      set iRowid [expr {int(rand() * ($nDoc/2)) + 1}]\n      set iA [expr {int(rand() * $nDoc)}]\n      set iB [expr {int(rand() * $nDoc)}]\n      update $iRowid $iA $iB\n\n      if {($i % $n)==0} {\n        execsql { COMMIT; BEGIN }\n      }\n\n      if {($i % $n)==100} {\n        execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n      }\n    }\n    execsql COMMIT\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n  } {}\n}\n\ndo_execsql_test 1.3 {\n  UPDATE t1 SET a=a AND b=b;\n  INSERT INTO t1(t1) VALUES('integrity-check');\n}\n\ndo_test 1.4 {\n  execsql { INSERT INTO t1(t1, rank) VALUES('pgsz', 32) }\n  for {set i 0} {$i < 50} {incr i} {\n    execsql { UPDATE t1 SET a=a AND b=b }\n    execsql { INSERT INTO t1(t1) VALUES('integrity-check') }\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Lots of deletes/inserts of the same document with the same rowid.\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE x2 USING fts5(x, detail=%DETAIL%);\n  INSERT INTO x2(x2, rank) VALUES('crisismerge', 2);\n  INSERT INTO x2 VALUES('a b c');\n  INSERT INTO x2 VALUES('a b c');\n}\ndo_test 2.1 {\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql { DELETE FROM x2 WHERE rowid = 2 }\n    execsql { INSERT INTO x2(rowid, x) VALUES(2, 'a b c') }\n  }\n} {}\ndo_execsql_test 2.1.integrity {\n  INSERT INTO x2(x2) VALUES('integrity-check');\n}\n\ndo_test 2.2 {\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql { UPDATE x2 SET x=x WHERE rowid=2 }\n  }\n} {}\ndo_execsql_test 2.2.integrity {\n  INSERT INTO x2(x2) VALUES('integrity-check');\n}\n\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5version.test",
    "content": "# 2015 Apr 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file focus on testing that unrecognized file-format\n# versions are detected and reported.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5version\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(one);\n  INSERT INTO t1 VALUES('a b c d');\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1_config WHERE k='version'\n} {version 4}\n\ndo_execsql_test 1.3 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'a';\n} {1}\n\ndo_execsql_test 1.4 {\n  UPDATE t1_config set v=5 WHERE k='version';\n} \n\ndo_test 1.5 {\n  db close\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }\n} {1 {invalid fts5 file format (found 5, expected 4) - run 'rebuild'}}\n\ndo_test 1.6 {\n  db close\n  sqlite3 db test.db\n  catchsql { INSERT INTO t1 VALUES('x y z') }\n} {1 {invalid fts5 file format (found 5, expected 4) - run 'rebuild'}}\n\ndo_test 1.7 {\n  execsql { DELETE FROM t1_config WHERE k='version' }\n  db close\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'a' }\n} {1 {invalid fts5 file format (found 0, expected 4) - run 'rebuild'}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5vocab.test",
    "content": "# 2015 Apr 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file focus on testing the fts5vocab module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5vocab\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\nforeach_detail_mode $testprefix {\n\nproc null_list_entries {iFirst nInterval L} {\n  for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} {\n    lset L $i {}\n  }\n  return $L\n}\n\nproc star_from_row {L} {\n  if {[detail_is_full]==0} {\n    set L [null_list_entries 2 3 $L]\n  }\n  return $L\n}\n\nproc star_from_col {L} {\n  if {[detail_is_col]} {\n    set L [null_list_entries 3 4 $L]\n  }\n  if {[detail_is_none]} {\n    set L [null_list_entries 1 4 $L]\n    set L [null_list_entries 3 4 $L]\n  }\n  return $L\n}\n\nproc row_to_col {L} {\n  if {[detail_is_none]==0} { error \"this is for detail=none mode\" }\n  set ret [list]\n  foreach {a b c} $L {\n    lappend ret $a {} $b {}\n  }\n  set ret\n}\n\nif 1 {\n\ndo_execsql_test 1.1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%);\n  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row');\n  PRAGMA table_info = v1;\n} {\n  0 term {} 0 {} 0\n  1 doc {} 0 {} 0\n  2 cnt {} 0 {} 0\n}\n\ndo_execsql_test 1.1.2 {\n  CREATE VIRTUAL TABLE v2 USING fts5vocab(t1, 'col');\n  PRAGMA table_info = v2;\n} {\n  0 term {} 0 {} 0\n  1 col {} 0 {} 0\n  2 doc {} 0 {} 0\n  3 cnt {} 0 {} 0\n}\n\ndo_execsql_test 1.2.1 { SELECT * FROM v1 } { }\ndo_execsql_test 1.2.2 { SELECT * FROM v2 } { }\n\ndo_execsql_test 1.3 {\n  INSERT INTO t1 VALUES('x y z');\n  INSERT INTO t1 VALUES('x x x');\n}\n\ndo_execsql_test 1.4.1 {\n  SELECT * FROM v1;\n} [star_from_row {x 2 4  y 1 1  z 1 1}]\n\ndo_execsql_test 1.4.2 {\n  SELECT * FROM v2;\n} [star_from_col {x one 2 4  y one 1 1  z one 1 1}]\n\ndo_execsql_test 1.5.1 {\n  BEGIN;\n    INSERT INTO t1 VALUES('a b c');\n    SELECT * FROM v1 WHERE term<'d';\n} [star_from_row {a 1 1   b 1 1   c 1 1}]\n\ndo_execsql_test 1.5.2 {\n    SELECT * FROM v2 WHERE term<'d';\n  COMMIT;\n} [star_from_col {a one 1 1  b one 1 1  c one 1 1}]\n\ndo_execsql_test 1.6 {\n  DELETE FROM t1 WHERE one = 'a b c';\n  SELECT * FROM v1;\n} [star_from_row {x 2 4  y 1 1  z 1 1}]\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE tt USING fts5(a, b, detail=%DETAIL%);\n  INSERT INTO tt VALUES('d g b f d f', 'f c e c d a');\n  INSERT INTO tt VALUES('f a e a a b', 'e d c f d d');\n  INSERT INTO tt VALUES('b c a a a b', 'f f c c b c');\n  INSERT INTO tt VALUES('f d c a c e', 'd g d e g d');\n  INSERT INTO tt VALUES('g d e f a g x', 'f f d a a b');\n  INSERT INTO tt VALUES('g c f b c g', 'a g f d c b');\n  INSERT INTO tt VALUES('c e c f g b', 'f e d b g a');\n  INSERT INTO tt VALUES('g d e f d e', 'a c d b a g');\n  INSERT INTO tt VALUES('e f a c c b', 'b f e a f d y');\n  INSERT INTO tt VALUES('c c a a c f', 'd g a e b g');\n}\n\nset res_row [star_from_row {\n  a 10 20   b 9 14   c 9 20   d 9 19   \n  e 8 13   f 10 20   g 7 14   x 1 1   \n  y 1 1\n}]\nset res_col [star_from_col {\n  a a 6 11    a b 7 9\n  b a 6 7     b b 7 7 \n  c a 6 12    c b 5 8 \n  d a 4 6     d b 9 13 \n  e a 6 7     e b 6 6 \n  f a 9 10    f b 7 10 \n  g a 5 7     g b 5 7\n  x a 1 1     y b 1 1\n}]\nif {[detail_is_none]} {\n  set res_col [row_to_col $res_row]\n}\n\nforeach {tn tbl resname} {\n  1 \"fts5vocab(tt, 'col')\" res_col\n  2 \"fts5vocab(tt, 'row')\" res_row\n  3 \"fts5vocab(tt, \\\"row\\\")\" res_row\n  4 \"fts5vocab(tt, [row])\" res_row\n  5 \"fts5vocab(tt, `row`)\" res_row\n\n  6 \"fts5vocab('tt', 'row')\" res_row\n  7 \"fts5vocab(\\\"tt\\\", \\\"row\\\")\" res_row\n  8 \"fts5vocab([tt], [row])\" res_row\n  9 \"fts5vocab(`tt`, `row`)\" res_row\n} {\n  do_execsql_test 2.$tn \"\n    DROP TABLE IF EXISTS tv;\n    CREATE VIRTUAL TABLE tv USING $tbl;\n    SELECT * FROM tv;\n  \" [set $resname]\n}\n\n#-------------------------------------------------------------------------\n# Test errors in the CREATE VIRTUAL TABLE statement.\n#\nforeach {tn sql} {\n  1 { CREATE VIRTUAL TABLE aa USING fts5vocab() }\n  2 { CREATE VIRTUAL TABLE aa USING fts5vocab(x) }\n  3 { CREATE VIRTUAL TABLE aa USING fts5vocab(x,y,z) }\n  4 { CREATE VIRTUAL TABLE temp.aa USING fts5vocab(x,y,z,y) }\n} {\n  do_catchsql_test 3.$tn $sql {1 {wrong number of vtable arguments}}\n}\n\ndo_catchsql_test 4.0 {\n  CREATE VIRTUAL TABLE cc USING fts5vocab(tbl, unknown);\n} {1 {fts5vocab: unknown table type: 'unknown'}}\n\ndo_catchsql_test 4.1 {\n  ATTACH 'test.db' AS aux;\n  CREATE VIRTUAL TABLE aux.cc USING fts5vocab(main, tbl, row);\n} {1 {wrong number of vtable arguments}}\n\n#-------------------------------------------------------------------------\n# Test fts5vocab tables created in the temp schema. \n#\nreset_db\nforcedelete test.db2\ndo_execsql_test 5.0 {\n  ATTACH 'test.db2' AS aux;\n  CREATE VIRTUAL TABLE t1 USING fts5(x, detail=%DETAIL%);\n  CREATE VIRTUAL TABLE temp.t1 USING fts5(x, detail=%DETAIL%);\n  CREATE VIRTUAL TABLE aux.t1 USING fts5(x, detail=%DETAIL%);\n\n  INSERT INTO main.t1 VALUES('a b c');\n  INSERT INTO main.t1 VALUES('d e f');\n  INSERT INTO main.t1 VALUES('a e c');\n\n  INSERT INTO temp.t1 VALUES('1 2 3');\n  INSERT INTO temp.t1 VALUES('4 5 6');\n  INSERT INTO temp.t1 VALUES('1 5 3');\n\n  INSERT INTO aux.t1 VALUES('x y z');\n  INSERT INTO aux.t1 VALUES('m n o');\n  INSERT INTO aux.t1 VALUES('x n z');\n}\n\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE temp.vm  USING fts5vocab(main, t1, row);\n  CREATE VIRTUAL TABLE temp.vt1 USING fts5vocab(t1, row);\n  CREATE VIRTUAL TABLE temp.vt2 USING fts5vocab(temp, t1, row);\n  CREATE VIRTUAL TABLE temp.va  USING fts5vocab(aux, t1, row);\n}\n\ndo_execsql_test 5.2 { SELECT * FROM vm } [star_from_row {\n  a 2 2 b 1 1 c 2 2 d 1 1 e 2 2 f 1 1\n}]\ndo_execsql_test 5.3 { SELECT * FROM vt1 } [star_from_row {\n  1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1\n}]\ndo_execsql_test 5.4 { SELECT * FROM vt2 } [star_from_row {\n  1 2 2 2 1 1 3 2 2 4 1 1 5 2 2 6 1 1\n}]\ndo_execsql_test 5.5 { SELECT * FROM va } [star_from_row {\n  m 1 1 n 2 2 o 1 1 x 2 2 y 1 1 z 2 2\n}]\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 6.0 {\n  CREATE TABLE iii(iii);\n  CREATE TABLE jjj(x);\n}\n\ndo_catchsql_test 6.1 {\n  CREATE VIRTUAL TABLE vocab1 USING fts5vocab(iii, row);\n  SELECT * FROM vocab1;\n} {1 {no such fts5 table: main.iii}}\n\ndo_catchsql_test 6.2 {\n  CREATE VIRTUAL TABLE vocab2 USING fts5vocab(jjj, row);\n  SELECT * FROM vocab2;\n} {1 {no such fts5 table: main.jjj}}\n\ndo_catchsql_test 6.2 {\n  CREATE VIRTUAL TABLE vocab3 USING fts5vocab(lll, row);\n  SELECT * FROM vocab3;\n} {1 {no such fts5 table: main.lll}}\n\n#-------------------------------------------------------------------------\n# Test single term queries on fts5vocab tables (i.e. those with term=?\n# constraints in the WHERE clause).\n#\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE tx USING fts5(one, two, detail=%DETAIL%);\n  INSERT INTO tx VALUES('g a ggg g a b eee',      'cc d aa ff g ee');\n  INSERT INTO tx VALUES('dd fff i a i jjj',       'f fff hh jj e f');\n  INSERT INTO tx VALUES('ggg a f f fff dd aa',    'd ggg f f j gg ddd');\n  INSERT INTO tx VALUES('e bb h jjj ii gg',       'e aa e f c fff');\n  INSERT INTO tx VALUES('j ff aa a h',            'h a j bbb bb');\n  INSERT INTO tx VALUES('cc i ff c d f',          'dd ii fff f c cc d');\n  INSERT INTO tx VALUES('jjj g i bb cc eee',      'hhh iii aaa b bbb aaa');\n  INSERT INTO tx VALUES('hhh hhh hhh bb fff f',   'fff gg aa ii h a');\n  INSERT INTO tx VALUES('b c cc aaa iii ggg f',   'iii ff ee a ff c cc');\n  INSERT INTO tx VALUES('hhh b hhh aaa j i i',    'dd ee ee aa bbb iii');\n  INSERT INTO tx VALUES('hh dd h b g ff i',       'ccc bb cc ccc f a d');\n  INSERT INTO tx VALUES('g d b ggg jj',           'fff jj ff jj g gg ee');\n  INSERT INTO tx VALUES('g ee ggg ggg cc bb eee', 'aa j jjj bbb dd eee ff');\n  INSERT INTO tx VALUES('c jjj hh ddd dd h',      'e aaa h jjj gg');\n\n  CREATE VIRTUAL TABLE txr USING fts5vocab(tx, row);\n  CREATE VIRTUAL TABLE txc USING fts5vocab(tx, col);\n}\n\nproc cont {L elem} {\n  set n 0\n  foreach e $L { if {$elem==$e} {incr n} }\n  set n\n}\ndb func cont cont\n\nforeach {term} {\n  a aa aaa\n  b bb bbb\n  c cc ccc\n  d dd ddd\n  e ee eee\n  f ff fff\n  g gg ggg\n  h hh hhh\n  i ii iii\n  j jj jjj\n} {\n  set resr [db eval {\n    SELECT $term, \n      sum(cont(one || ' ' || two, $term) > 0),\n      sum(cont(one || ' ' || two, $term))\n    FROM tx\n  }]\n  if {[lindex $resr 1]==0} {set resr [list]}\n\n  set r1 [db eval {\n    SELECT $term, 'one', sum(cont(one, $term)>0), sum(cont(one, $term)) FROM tx\n  }]\n  if {[lindex $r1 2]==0} {set r1 [list]}\n\n  set r2 [db eval {\n    SELECT $term, 'two', sum(cont(two, $term)>0), sum(cont(two, $term)) FROM tx\n  }]\n  if {[lindex $r2 2]==0} {set r2 [list]}\n\n  set resc [concat $r1 $r2]\n\n  set resc [star_from_col $resc]\n  set resr [star_from_row $resr]\n  if {[detail_is_none]} { set resc [row_to_col $resr] }\n  do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc\n  do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr\n}\n\ndo_execsql_test 7.1 {\n  CREATE TABLE txr_c AS SELECT * FROM txr;\n  CREATE TABLE txc_c AS SELECT * FROM txc;\n}\n\n# Test range queries on the fts5vocab tables created above.\n#\nforeach {tn a b} {\n  1   a   jjj\n  2   bb  j\n  3   ccc ddd\n  4   dd  xyz\n  5   xzy dd\n  6   h   hh\n} {\n  do_execsql_test 7.2.$tn.1 {\n    SELECT * FROM txr WHERE term>=$a\n  } [db eval {SELECT * FROM txr_c WHERE term>=$a}]\n  do_execsql_test 7.2.$tn.2 {\n    SELECT * FROM txr WHERE term<=$b\n  } [db eval {SELECT * FROM txr_c WHERE term <=$b}]\n  do_execsql_test 7.2.$tn.3 {\n    SELECT * FROM txr WHERE term>=$a AND term<=$b\n  } [db eval {SELECT * FROM txr_c WHERE term>=$a AND term <=$b}]\n\n  do_execsql_test 7.2.$tn.4 {\n    SELECT * FROM txc WHERE term>=$a\n  } [db eval {SELECT * FROM txc_c WHERE term>=$a}]\n  do_execsql_test 7.2.$tn.5 {\n    SELECT * FROM txc WHERE term<=$b\n  } [db eval {SELECT * FROM txc_c WHERE term <=$b}]\n  do_execsql_test 7.2.$tn.6 {\n    SELECT * FROM txc WHERE term>=$a AND term<=$b\n  } [db eval {SELECT * FROM txc_c WHERE term>=$a AND term <=$b}]\n\n  do_execsql_test 7.2.$tn.7 {\n    SELECT * FROM txr WHERE term>$a\n  } [db eval {SELECT * FROM txr_c WHERE term>$a}]\n  do_execsql_test 7.2.$tn.8 {\n    SELECT * FROM txr WHERE term<$b\n  } [db eval {SELECT * FROM txr_c WHERE term<$b}]\n  do_execsql_test 7.2.$tn.9 {\n    SELECT * FROM txr WHERE term>$a AND term<$b\n  } [db eval {SELECT * FROM txr_c WHERE term>$a AND term <$b}]\n\n  do_execsql_test 7.2.$tn.10 {\n    SELECT * FROM txc WHERE term>$a\n  } [db eval {SELECT * FROM txc_c WHERE term>$a}]\n  do_execsql_test 7.2.$tn.11 {\n    SELECT * FROM txc WHERE term<$b\n  } [db eval {SELECT * FROM txc_c WHERE term<$b}]\n  do_execsql_test 7.2.$tn.12 {\n    SELECT * FROM txc WHERE term>$a AND term<$b\n  } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}]\n}\n\ndo_execsql_test 7.3.1 {\n  SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term;\n} {30}\n\nif {![detail_is_none]} {\n  do_execsql_test 7.3.2 {\n    SELECT count(*) FROM txc, txc_c\n      WHERE txc.term = txc_c.term AND txc.col=txc_c.col;\n  } {57}\n}\n\n}\n\n#-------------------------------------------------------------------------\n# Test the fts5vocab tables response to a specific types of corruption:\n# where the fts5 index contains hits for columns that do not exist.\n#\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE x1 USING fts5(a, b, c, detail=%DETAIL%);\n  INSERT INTO x1 VALUES('a b c', 'd e f', 'g h i');\n  INSERT INTO x1 VALUES('g h i', 'a b c', 'd e f');\n  INSERT INTO x1 VALUES('d e f', 'g h i', 'a b c');\n  CREATE VIRTUAL TABLE x1_r USING fts5vocab(x1, row);\n  CREATE VIRTUAL TABLE x1_c USING fts5vocab(x1, col);\n}\n\nset resr [star_from_row {a 3 3 b 3 3 c 3 3 d 3 3 e 3 3 f 3 3 g 3 3 h 3 3 i 3 3}]\nset resc [star_from_col {\n  a a 1 1 a b 1 1 a c 1 1 b a 1 1 \n  b b 1 1 b c 1 1 c a 1 1 c b 1 1 \n  c c 1 1 d a 1 1 d b 1 1 d c 1 1\n  e a 1 1 e b 1 1 e c 1 1 f a 1 1 \n  f b 1 1 f c 1 1 g a 1 1 g b 1 1 \n  g c 1 1 h a 1 1 h b 1 1 h c 1 1 \n  i a 1 1 i b 1 1 i c 1 1\n}]\nif {[detail_is_none]} { set resc [row_to_col $resr] }\n\ndo_execsql_test 8.1.1 { SELECT * FROM x1_r; } $resr\ndo_execsql_test 8.1.2 { SELECT * FROM x1_c } $resc\n\ndo_execsql_test 8.2 {\n  PRAGMA writable_schema = 1;\n  UPDATE sqlite_master \n  SET sql = 'CREATE VIRTUAL TABLE x1 USING fts5(a, detail=%DETAIL%)'\n  WHERE name = 'x1';\n}\ndb close\nsqlite3 db test.db\nsqlite3_fts5_may_be_corrupt 1\n\ndo_execsql_test 8.2.1 { SELECT * FROM x1_r } $resr\n\nif {[detail_is_none]} {\n  do_execsql_test 8.2.2 { SELECT * FROM x1_c } $resc\n} else {\n  do_catchsql_test 8.2.2 { \n    SELECT * FROM x1_c \n  } {1 {database disk image is malformed}}\n}\n\nsqlite3_fts5_may_be_corrupt 0\n}\n\n#-------------------------------------------------------------------------\n# Test that both \"ORDER BY term\" and \"ORDER BY term DESC\" work.\n#\nreset_db\ndo_execsql_test 9.1 {\n  CREATE VIRTUAL TABLE x1 USING fts5(x);\n  INSERT INTO x1 VALUES('def ABC ghi');\n  INSERT INTO x1 VALUES('DEF abc GHI');\n}\n\ndo_execsql_test 9.2 {\n  CREATE VIRTUAL TABLE rrr USING fts5vocab(x1, row);\n  SELECT * FROM rrr\n} {\n  abc 2 2 def 2 2 ghi 2 2\n}\ndo_execsql_test 9.3 {\n  SELECT * FROM rrr ORDER BY term ASC\n} {\n  abc 2 2 def 2 2 ghi 2 2\n}\ndo_execsql_test 9.4 {\n  SELECT * FROM rrr ORDER BY term DESC\n} {\n  ghi 2 2 def 2 2 abc 2 2 \n}\ndo_test 9.5 {\n  set e2 [db eval { EXPLAIN SELECT * FROM rrr ORDER BY term ASC }]\n  expr [lsearch $e2 SorterSort]<0\n} 1\ndo_test 9.6 {\n  set e2 [db eval { EXPLAIN SELECT * FROM rrr ORDER BY term DESC }]\n  expr [lsearch $e2 SorterSort]<0\n} 0\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/test/fts5vocab2.test",
    "content": "# 2017 August 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file focus on testing the fts5vocab module.\n#\n\nsource [file join [file dirname [info script]] fts5_common.tcl]\nset testprefix fts5vocab\n\n# If SQLITE_ENABLE_FTS5 is defined, omit this file.\nifcapable !fts5 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b);\n  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, instance);\n\n  INSERT INTO t1 VALUES('one two', 'two three');\n  INSERT INTO t1 VALUES('three four', 'four five five five');\n}\n\ndo_execsql_test 1.1 {\n  SELECT * FROM v1;\n} {\n  five  2 b 1\n  five  2 b 2\n  five  2 b 3\n  four  2 a 1\n  four  2 b 0\n  one   1 a 0\n  three 1 b 1\n  three 2 a 0\n  two   1 a 1\n  two   1 b 0\n}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM v1 WHERE term='three';\n} {\n  three 1 b 1\n  three 2 a 0\n}\n\ndo_execsql_test 1.3 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=2;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  one   1 a 0\n  three 1 b 1\n  two   1 a 1\n  two   1 b 0\n}\n\ndo_execsql_test 1.4 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=1;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  five  2 b 1\n  five  2 b 2\n  five  2 b 3\n  four  2 a 1\n  four  2 b 0\n  three 2 a 0\n}\n\ndo_execsql_test 1.5 {\n  DELETE FROM t1;\n  SELECT * FROM v1;\n} {\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 2.0 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS v1;\n\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=column);\n  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, instance);\n\n  INSERT INTO t1 VALUES('one two', 'two three');\n  INSERT INTO t1 VALUES('three four', 'four five five five');\n}\n\ndo_execsql_test 2.1 {\n  SELECT * FROM v1;\n} {\n  five  2 b {}\n  four  2 a {}\n  four  2 b {}\n  one   1 a {}\n  three 1 b {}\n  three 2 a {}\n  two   1 a {}\n  two   1 b {}\n}\n\ndo_execsql_test 2.2 {\n  SELECT * FROM v1 WHERE term='three';\n} {\n  three 1 b {}\n  three 2 a {}\n}\n\ndo_execsql_test 2.3 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=2;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  one   1 a {}\n  three 1 b {}\n  two   1 a {}\n  two   1 b {}\n}\n\ndo_execsql_test 2.4 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=1;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  five  2 b {}\n  four  2 a {}\n  four  2 b {}\n  three 2 a {}\n}\n\ndo_execsql_test 2.5 {\n  DELETE FROM t1;\n  SELECT * FROM v1;\n} {\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 3.0 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS v1;\n\n  CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=none);\n  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, instance);\n\n  INSERT INTO t1 VALUES('one two', 'two three');\n  INSERT INTO t1 VALUES('three four', 'four five five five');\n}\n\ndo_execsql_test 3.1 {\n  SELECT * FROM v1;\n} {\n  five  2 {} {}\n  four  2 {} {}\n  one   1 {} {}\n  three 1 {} {}\n  three 2 {} {}\n  two   1 {} {}\n}\n\ndo_execsql_test 3.2 {\n  SELECT * FROM v1 WHERE term='three';\n} {\n  three 1 {} {}\n  three 2 {} {}\n}\n\ndo_execsql_test 3.3 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=2;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  one   1 {} {}\n  three 1 {} {}\n  two   1 {} {}\n}\n\ndo_execsql_test 3.4 {\n  BEGIN;\n    DELETE FROM t1 WHERE rowid=1;\n    SELECT * FROM v1;\n  ROLLBACK;\n} {\n  five  2 {} {}\n  four  2 {} {}\n  three 2 {} {}\n}\n\ndo_execsql_test 3.5 {\n  DELETE FROM t1;\n  SELECT * FROM v1;\n} {\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/tool/fts5speed.tcl",
    "content": "\n\nset Q {\n  {1   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'enron'\"}\n  {25  \"SELECT count(*) FROM t1 WHERE t1 MATCH 'hours'\"}\n  {300 \"SELECT count(*) FROM t1 WHERE t1 MATCH 'acid'\"}\n  {100 \"SELECT count(*) FROM t1 WHERE t1 MATCH 'loaned OR mobility OR popcore OR sunk'\"}\n  {100 \"SELECT count(*) FROM t1 WHERE t1 MATCH 'enron AND myapps'\"}\n  {1   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'en* AND my*'\"}\n\n  {1   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'c:t*'\"}\n  {1   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t* OR b:t* OR c:t* OR d:t* OR e:t* OR f:t* OR g:t*'\"}\n  {1   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'a:t*'\"}\n  {2   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'c:the'\"}\n\n  {2   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes OR e:holmes OR f:holmes OR g:holmes'\" }\n  {2   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes AND e:holmes AND f:holmes AND g:holmes'\" }\n  {4   \"SELECT count(*) FROM t1 WHERE t1 MATCH 'd:holmes NOT e:holmes'\" }\n}\n\nproc usage {} {\n  global Q\n  puts stderr \"Usage: $::argv0 DATABASE QUERY\"\n  puts stderr \"\"\n  for {set i 1} {$i <= [llength $Q]} {incr i} {\n    puts stderr \"       $i. [lindex $Q [expr $i-1]]\"\n  }\n  puts stderr \"\"\n  exit -1\n}\n\n\nset nArg [llength $argv]\nif {$nArg!=2 && $nArg!=3} usage\nset database [lindex $argv 0]\nset iquery [lindex $argv 1]\nif {$iquery<1 || $iquery>[llength $Q]} usage\nset nRepeat 0\nif {$nArg==3} { set nRepeat [lindex $argv 2] }\n\n\nsqlite3 db $database\ncatch { load_static_extension db fts5 }\n\nincr iquery -1\nset sql [lindex $Q $iquery 1]\nif {$nRepeat==0} {\n  set nRepeat [lindex $Q $iquery 0]\n}\n\nputs \"sql:     $sql\"\nputs \"nRepeat: $nRepeat\"\nif {[regexp matchinfo $sql]} {\n  sqlite3_fts5_register_matchinfo db\n  db eval $sql \n} else {\n  puts \"result:  [db eval $sql]\"\n}\n\nfor {set i 1} {$i < $nRepeat} {incr i} {\n  db eval $sql\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/tool/fts5txt2db.tcl",
    "content": "##########################################################################\n# 2016 Jan 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\nproc process_cmdline {} { \n  cmdline::process ::A $::argv {\n    {fts5                 \"use fts5 (this is the default)\"}\n    {fts4                 \"use fts4\"}\n    {colsize   \"10 10 10\" \"list of column sizes\"}\n    {tblname   \"t1\"       \"table name to create\"}\n    {detail    \"full\"     \"Fts5 detail mode to use\"}\n    {repeat    1          \"Load each file this many times\"}\n    {prefix    \"\"         \"Fts prefix= option\"}\n    {trans     1          \"True to use a transaction\"}\n    database\n    file...\n  } {\n  This script is designed to create fts4/5 tables with more than one column.\n  The -colsize option should be set to a Tcl list of integer values, one for\n  each column in the table. Each value is the number of tokens that will be\n  inserted into the column value for each row. For example, setting the -colsize\n  option to \"5 10\" creates an FTS table with 2 columns, with roughly 5 and 10\n  tokens per row in each, respectively.\n  \n  Each \"FILE\" argument should be a text file. The contents of these text files\n  is split on whitespace characters to form a list of tokens. The first N1\n  tokens are used for the first column of the first row, where N1 is the first\n  element of the -colsize list. The next N2 are used for the second column of\n  the first row, and so on. Rows are added to the table until the entire list\n  of tokens is exhausted.\n  }\n}\n\n###########################################################################\n###########################################################################\n# Command line options processor. This is generic code that can be copied\n# between scripts.\n#\nnamespace eval cmdline {\n  proc cmdline_error {O E {msg \"\"}} {\n    if {$msg != \"\"} {\n      puts stderr \"Error: $msg\"\n      puts stderr \"\"\n    }\n  \n    set L [list]\n    foreach o $O {\n      if {[llength $o]==1} {\n        lappend L [string toupper $o]\n      }\n    }\n  \n    puts stderr \"Usage: $::argv0 ?SWITCHES? $L\"\n    puts stderr \"\"\n    puts stderr \"Switches are:\"\n    foreach o $O {\n      if {[llength $o]==3} {\n        foreach {a b c} $o {}\n        puts stderr [format \"    -%-15s %s (default \\\"%s\\\")\" \"$a VAL\" $c $b]\n      } elseif {[llength $o]==2} {\n        foreach {a b} $o {}\n        puts stderr [format \"    -%-15s %s\" $a $b]\n      }\n    }\n    puts stderr \"\"\n    puts stderr $E\n    exit -1\n  }\n  \n  proc process {avar lArgs O E} {\n    upvar $avar A\n    set zTrailing \"\"       ;# True if ... is present in $O\n    set lPosargs [list]\n  \n    # Populate A() with default values. Also, for each switch in the command\n    # line spec, set an entry in the idx() array as follows:\n    #\n    #  {tblname t1 \"table name to use\"}  \n    #      -> [set idx(-tblname) {tblname t1 \"table name to use\"}  \n    #\n    # For each position parameter, append its name to $lPosargs. If the ...\n    # specifier is present, set $zTrailing to the name of the prefix.\n    #\n    foreach o $O {\n      set nm [lindex $o 0]\n      set nArg [llength $o]\n      switch -- $nArg {\n        1 {\n          if {[string range $nm end-2 end]==\"...\"} {\n            set zTrailing [string range $nm 0 end-3]\n          } else {\n            lappend lPosargs $nm\n          }\n        }\n        2 {\n          set A($nm) 0\n          set idx(-$nm) $o\n        }\n        3 {\n          set A($nm) [lindex $o 1]\n          set idx(-$nm) $o\n        }\n        default {\n          error \"Error in command line specification\"\n        }\n      }\n    }\n  \n    # Set explicitly specified option values\n    #\n    set nArg [llength $lArgs]\n    for {set i 0} {$i < $nArg} {incr i} {\n      set opt [lindex $lArgs $i]\n      if {[string range $opt 0 0]!=\"-\" || $opt==\"--\"} break\n      set c [array names idx \"${opt}*\"]\n      if {[llength $c]==0} { cmdline_error $O $E \"Unrecognized option: $opt\"}\n      if {[llength $c]>1}  { cmdline_error $O $E \"Ambiguous option: $opt\"}\n  \n      if {[llength $idx($c)]==3} {\n        if {$i==[llength $lArgs]-1} {\n          cmdline_error $O $E \"Option requires argument: $c\" \n        }\n        incr i\n        set A([lindex $idx($c) 0]) [lindex $lArgs $i]\n      } else {\n        set A([lindex $idx($c) 0]) 1\n      }\n    }\n  \n    # Deal with position arguments.\n    #\n    set nPosarg [llength $lPosargs]\n    set nRem [expr $nArg - $i]\n    if {$nRem < $nPosarg || ($zTrailing==\"\" && $nRem > $nPosarg)} {\n      cmdline_error $O $E\n    }\n    for {set j 0} {$j < $nPosarg} {incr j} {\n      set A([lindex $lPosargs $j]) [lindex $lArgs [expr $j+$i]]\n    }\n    if {$zTrailing!=\"\"} {\n      set A($zTrailing) [lrange $lArgs [expr $j+$i] end]\n    }\n  }\n} ;# namespace eval cmdline\n# End of command line options processor.\n###########################################################################\n###########################################################################\n\nprocess_cmdline\n\n# If -fts4 was specified, use fts4. Otherwise, fts5.\nif {$A(fts4)} {\n  set A(fts) fts4\n} else {\n  set A(fts) fts5\n}\n\nsqlite3 db $A(database)\n\n# Create the FTS table in the db. Return a list of the table columns.\n#\nproc create_table {} {\n  global A\n  set cols [list a b c d e f g h i j k l m n o p q r s t u v w x y z]\n\n  set nCol [llength $A(colsize)]\n  set cols [lrange $cols 0 [expr $nCol-1]]\n\n  set sql    \"CREATE VIRTUAL TABLE IF NOT EXISTS $A(tblname) USING $A(fts) (\"\n  append sql [join $cols ,]\n  if {$A(fts)==\"fts5\"} { append sql \",detail=$A(detail)\" }\n  append sql \", prefix='$A(prefix)');\"\n\n  db eval $sql\n  return $cols\n}\n\n# Return a list of tokens from the named file.\n#\nproc readfile {file} {\n  set fd [open $file]\n  set data [read $fd]\n  close $fd\n  split $data\n}\n\nproc repeat {L n} {\n  set res [list]\n  for {set i 0} {$i < $n} {incr i} {\n    set res [concat $res $L]\n  }\n  set res\n}\n\n\n# Load all the data into a big list of tokens.\n#\nset tokens [list]\nforeach f $A(file) {\n  set tokens [concat $tokens [repeat [readfile $f] $A(repeat)]]\n}\n\nset N [llength $tokens]\nset i 0\nset cols [create_table]\nset sql \"INSERT INTO $A(tblname) VALUES(\\$R([lindex $cols 0])\"\nforeach c [lrange $cols 1 end] {\n  append sql \", \\$R($c)\"\n}\nappend sql \")\"\n\nif {$A(trans)} { db eval BEGIN }\n  while {$i < $N} {\n    foreach c $cols s $A(colsize) {\n      set R($c) [lrange $tokens $i [expr $i+$s-1]]\n      incr i $s\n    }\n    db eval $sql\n  }\nif {$A(trans)} { db eval COMMIT }\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/tool/loadfts5.tcl",
    "content": "\n\nproc loadfile {f} {\n  set fd [open $f]\n  set data [read $fd]\n  close $fd\n  return $data\n}\n\nset ::nRow 0\nset ::nRowPerDot 1000\n\nproc load_hierachy {dir} {\n  foreach f [glob -nocomplain -dir $dir *] {\n    if {$::O(limit) && $::nRow>=$::O(limit)} break\n    if {[file isdir $f]} {\n      load_hierachy $f\n    } else {\n      db eval { INSERT INTO t1 VALUES($f, loadfile($f)) }\n      incr ::nRow\n\n      if {$::O(trans) && ($::nRow % $::O(trans))==0} {\n        db eval { COMMIT }\n        db eval { INSERT INTO t1(t1) VALUES('integrity-check') }\n        db eval { BEGIN }\n      }\n\n      if {($::nRow % $::nRowPerDot)==0} {\n        puts -nonewline .\n        if {($::nRow % (65*$::nRowPerDot))==0} { puts \"\" }\n        flush stdout\n      }\n\n    }\n  }\n}\n\nproc usage {} {\n  puts stderr \"Usage: $::argv0 ?SWITCHES? DATABASE PATH\"\n  puts stderr \"\"\n  puts stderr \"Switches are:\"\n  puts stderr \"  -fts4        (use fts4 instead of fts5)\"\n  puts stderr \"  -fts5        (use fts5)\"\n  puts stderr \"  -porter      (use porter tokenizer)\"\n  puts stderr \"  -delete      (delete the database file before starting)\"\n  puts stderr \"  -limit N     (load no more than N documents)\"\n  puts stderr \"  -automerge N (set the automerge parameter to N)\"\n  puts stderr \"  -crisismerge N (set the crisismerge parameter to N)\"\n  puts stderr \"  -prefix PREFIX (comma separated prefix= argument)\"\n  puts stderr \"  -trans N     (commit after N inserts - 0 == never)\"\n  puts stderr \"  -hashsize N  (set the fts5 hashsize parameter to N)\"\n  puts stderr \"  -detail MODE (detail mode for fts5 tables)\"\n  exit 1\n}\n\nset O(vtab)       fts5\nset O(tok)        \"\"\nset O(limit)      0\nset O(delete)     0\nset O(automerge)  -1\nset O(crisismerge)  -1\nset O(prefix)     \"\"\nset O(trans)      0\nset O(hashsize)   -1\nset O(detail)     full\n\nif {[llength $argv]<2} usage\nset nOpt [expr {[llength $argv]-2}]\nfor {set i 0} {$i < $nOpt} {incr i} {\n  set arg [lindex $argv $i]\n  switch -- [lindex $argv $i] {\n    -fts4 {\n      set O(vtab) fts4\n    }\n\n    -fts5 {\n      set O(vtab) fts5\n    }\n\n    -porter {\n      set O(tok) \", tokenize=porter\"\n    }\n\n    -delete {\n      set O(delete) 1\n    }\n\n    -limit {\n      if { [incr i]>=$nOpt } usage\n      set O(limit) [lindex $argv $i]\n    }\n\n    -trans {\n      if { [incr i]>=$nOpt } usage\n      set O(trans) [lindex $argv $i]\n    }\n    \n    -automerge {\n      if { [incr i]>=$nOpt } usage\n      set O(automerge) [lindex $argv $i]\n    }\n\n    -crisismerge {\n      if { [incr i]>=$nOpt } usage\n      set O(crisismerge) [lindex $argv $i]\n    }\n\n    -prefix {\n      if { [incr i]>=$nOpt } usage\n      set O(prefix) [lindex $argv $i]\n    }\n\n    -hashsize {\n      if { [incr i]>=$nOpt } usage\n      set O(hashsize) [lindex $argv $i]\n    }\n\n    -detail {\n      if { [incr i]>=$nOpt } usage\n      set O(detail) [lindex $argv $i]\n    }\n\n    default {\n      usage\n    }\n  }\n}\n\nset dbfile [lindex $argv end-1]\nif {$O(delete)} { file delete -force $dbfile }\nsqlite3 db $dbfile\ncatch { load_static_extension db fts5 }\ndb func loadfile loadfile\ndb eval \"PRAGMA page_size=4096\"\n\ndb eval BEGIN\n  set pref \"\"\n  if {$O(prefix)!=\"\"} { set pref \", prefix='$O(prefix)'\" }\n  if {$O(vtab)==\"fts5\"} {\n    append pref \", detail=$O(detail)\"\n  }\n  catch {\n    db eval \"CREATE VIRTUAL TABLE t1 USING $O(vtab) (path, content$O(tok)$pref)\"\n    db eval \"INSERT INTO t1(t1, rank) VALUES('pgsz', 4050);\"\n  }\n\n  if {$O(hashsize)>=0} {\n    catch {\n      db eval \"INSERT INTO t1(t1, rank) VALUES('hashsize', $O(hashsize));\"\n    }\n  }\n\n\n  if {$O(automerge)>=0} {\n    if {$O(vtab) == \"fts5\"} {\n      db eval { INSERT INTO t1(t1, rank) VALUES('automerge', $O(automerge)) }\n    } else {\n      db eval { INSERT INTO t1(t1) VALUES('automerge=' || $O(automerge)) }\n    }\n  }\n  if {$O(crisismerge)>=0} {\n    if {$O(vtab) == \"fts5\"} {\n      db eval {INSERT INTO t1(t1, rank) VALUES('crisismerge', $O(crisismerge))}\n    } else {\n    }\n  }\n  load_hierachy [lindex $argv end]\ndb eval COMMIT\nputs \"\"\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/tool/mkfts5c.tcl",
    "content": "#!/bin/sh\n# restart with tclsh \\\nexec tclsh \"$0\" \"$@\"\n\nset srcdir [file dirname [file dirname [info script]]]\nset G(src) [string map [list %dir% $srcdir] {\n  %dir%/fts5.h\n  %dir%/fts5Int.h\n  fts5parse.h\n  fts5parse.c\n  %dir%/fts5_aux.c\n  %dir%/fts5_buffer.c\n  %dir%/fts5_config.c\n  %dir%/fts5_expr.c\n  %dir%/fts5_hash.c\n  %dir%/fts5_index.c\n  %dir%/fts5_main.c\n  %dir%/fts5_storage.c\n  %dir%/fts5_tokenize.c\n  %dir%/fts5_unicode2.c\n  %dir%/fts5_varint.c\n  %dir%/fts5_vocab.c\n}]\n\nset G(hdr) {\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) \n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n}\n\nset G(footer) {\n    \n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */\n}\n\n#-------------------------------------------------------------------------\n# Read and return the entire contents of text file $zFile from disk.\n#\nproc readfile {zFile} {\n  set fd [open $zFile]\n  set data [read $fd]\n  close $fd\n  return $data\n}\n\n#-------------------------------------------------------------------------\n# This command returns a string identifying the current sqlite version -\n# the equivalent of the SQLITE_SOURCE_ID string.\n#\nproc fts5_source_id {zDir} {\n  set top [file dirname [file dirname $zDir]]\n  set uuid [string trim [readfile [file join $top manifest.uuid]]]\n\n  set L [split [readfile [file join $top manifest]]] \n  set date [lindex $L [expr [lsearch -exact $L D]+1]]\n  set date [string range $date 0 [string last . $date]-1]\n  set date [string map {T { }} $date]\n\n  return \"fts5: $date $uuid\"\n}\n\nproc fts5c_init {zOut} {\n  global G\n  set G(fd) stdout\n  set G(fd) [open $zOut w]\n\n  puts -nonewline $G(fd) $G(hdr)\n}\n\nproc fts5c_printfile {zIn} {\n  global G\n  set data [readfile $zIn]\n  set zTail [file tail $zIn]\n  puts $G(fd) \"#line 1 \\\"$zTail\\\"\"\n\n  set sub_map [list --FTS5-SOURCE-ID-- [fts5_source_id $::srcdir]]\n  if {$zTail==\"fts5parse.c\"} {\n    lappend sub_map yy fts5yy YY fts5YY TOKEN FTS5TOKEN\n  }\n\n  foreach line [split $data \"\\n\"] {\n    if {[regexp {^#include.*fts5} $line]} {\n      set line \"/* $line */\"\n    } elseif { \n         ![regexp { sqlite3Fts5Init\\(} $line] \n       && [regexp {^(const )?[a-zA-Z][a-zA-Z0-9]* [*]?sqlite3Fts5} $line]\n    } {\n      set line \"static $line\"\n    }\n    set line [string map $sub_map $line]\n    puts $G(fd) $line\n  }\n}\n\nproc fts5c_close {} {\n  global G\n  puts -nonewline $G(fd) $G(footer)\n  if {$G(fd)!=\"stdout\"} {\n    close $G(fd)\n  }\n}\n\n\nfts5c_init fts5.c\nforeach f $G(src) { fts5c_printfile $f }\nfts5c_close\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/fts5/tool/showfts5.tcl",
    "content": "\n\n\n#-------------------------------------------------------------------------\n# Process command line arguments.\n#\nproc usage {} {\n  puts stderr \"usage: $::argv0 ?OPTIONS? database table\"\n  puts stderr \"\"\n  puts stderr \"  -nterm                (count number of terms in each segment)\"\n  puts stderr \"  -segments             (output segment contents)\"\n  puts stderr \"\"\n  exit 1\n}\n\nset O(nterm) 0\nset O(segments) 0\n\nif {[llength $argv]<2} usage\nforeach a [lrange $argv 0 end-2] {\n  switch -- $a {\n    -nterm {\n      set O(nterm) 1\n    }\n\n    -segments {\n      set O(segments) 1\n    }\n\n    default {\n      usage\n    }\n  }\n}\n\nset database [lindex $argv end-1]\nset tbl [lindex $argv end]\n\n\n#-------------------------------------------------------------------------\n# Count the number of terms in each segment of fts5 table $tbl. Store the\n# counts in the array variable in the parent context named by parameter\n# $arrayname, indexed by segment-id. Example:\n#\n#   count_terms fts_tbl A\n#   foreach {k v} [array get A] { puts \"segid=$k nTerm=$v\" }\n#\nproc count_terms {tbl arrayname} {\n  upvar A $arrayname\n  array unset A\n  db eval \"SELECT fts5_decode(rowid, block) AS d FROM ${tbl}_data\" {\n    set desc [lindex $d 0]\n    if {[regexp {^segid=([0-9]*)} $desc -> id]} {\n      foreach i [lrange $d 1 end] {\n        if {[string match {term=*} $i]} { incr A($id) }\n      }\n    }\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# Start of main program.\n#\nsqlite3 db $database\ncatch { load_static_extension db fts5 }\n\nif {$O(nterm)} { count_terms $tbl A }\n\ndb eval \"SELECT fts5_decode(rowid, block) AS d FROM ${tbl}_data WHERE id=10\" {\n  foreach lvl [lrange $d 1 end] {\n    puts [lrange $lvl 0 2]\n\n    foreach seg [lrange $lvl 3 end] {\n      if {$::O(nterm)} {\n        regexp {^id=([0-9]*)} $seg -> id\n        set nTerm 0\n        catch { set nTerm $A($id) }\n        puts [format \"        % -28s    nTerm=%d\" $seg $nTerm]\n      } else {\n        puts [format \"        % -28s\" $seg]\n      }\n    }\n  }\n}\n\nif {$O(segments)} {\n  puts \"\"\n  db eval \"SELECT fts5_decode(rowid, block) AS d FROM ${tbl}_data WHERE id>10\" {\n    puts $d\n  }\n}\n\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/icu/README.txt",
    "content": "\nThis directory contains source code for the SQLite \"ICU\" extension, an\nintegration of the \"International Components for Unicode\" library with\nSQLite. Documentation follows.\n\n    1. Features\n    \n        1.1  SQL Scalars upper() and lower()\n        1.2  Unicode Aware LIKE Operator\n        1.3  ICU Collation Sequences\n        1.4  SQL REGEXP Operator\n    \n    2. Compilation and Usage\n    \n    3. Bugs, Problems and Security Issues\n    \n        3.1  The \"case_sensitive_like\" Pragma\n        3.2  The SQLITE_MAX_LIKE_PATTERN_LENGTH Macro\n        3.3  Collation Sequence Security Issue\n\n\n1. FEATURES\n\n  1.1  SQL Scalars upper() and lower()\n\n    SQLite's built-in implementations of these two functions only \n    provide case mapping for the 26 letters used in the English\n    language. The ICU based functions provided by this extension\n    provide case mapping, where defined, for the full range of \n    unicode characters.\n\n    ICU provides two types of case mapping, \"general\" case mapping and\n    \"language specific\". Refer to ICU documentation for the differences\n    between the two. Specifically:\n\n       http://www.icu-project.org/userguide/caseMappings.html\n       http://www.icu-project.org/userguide/posix.html#case_mappings\n\n    To utilise \"general\" case mapping, the upper() or lower() scalar \n    functions are invoked with one argument:\n\n        upper('ABC') -> 'abc'\n        lower('abc') -> 'ABC'\n\n    To access ICU \"language specific\" case mapping, upper() or lower()\n    should be invoked with two arguments. The second argument is the name\n    of the locale to use. Passing an empty string (\"\") or SQL NULL value\n    as the second argument is the same as invoking the 1 argument version\n    of upper() or lower():\n\n        lower('I', 'en_us') -> 'i'\n        lower('I', 'tr_tr') -> 'ı' (small dotless i)\n\n  1.2  Unicode Aware LIKE Operator\n\n    Similarly to the upper() and lower() functions, the built-in SQLite LIKE\n    operator understands case equivalence for the 26 letters of the English\n    language alphabet. The implementation of LIKE included in this\n    extension uses the ICU function u_foldCase() to provide case\n    independent comparisons for the full range of unicode characters.  \n\n    The U_FOLD_CASE_DEFAULT flag is passed to u_foldCase(), meaning the\n    dotless 'I' character used in the Turkish language is considered\n    to be in the same equivalence class as the dotted 'I' character\n    used by many languages (including English).\n\n  1.3  ICU Collation Sequences\n\n    A special SQL scalar function, icu_load_collation() is provided that \n    may be used to register ICU collation sequences with SQLite. It\n    is always called with exactly two arguments, the ICU locale \n    identifying the collation sequence to ICU, and the name of the\n    SQLite collation sequence to create. For example, to create an\n    SQLite collation sequence named \"turkish\" using Turkish language\n    sorting rules, the SQL statement:\n\n        SELECT icu_load_collation('tr_TR', 'turkish');\n\n    Or, for Australian English:\n\n        SELECT icu_load_collation('en_AU', 'australian');\n\n    The identifiers \"turkish\" and \"australian\" may then be used\n    as collation sequence identifiers in SQL statements:\n\n        CREATE TABLE aust_turkish_penpals(\n          australian_penpal_name TEXT COLLATE australian,\n          turkish_penpal_name    TEXT COLLATE turkish\n        );\n  \n  1.4 SQL REGEXP Operator\n\n    This extension provides an implementation of the SQL binary\n    comparision operator \"REGEXP\", based on the regular expression functions\n    provided by the ICU library. The syntax of the operator is as described\n    in SQLite documentation:\n\n        <string> REGEXP <re-pattern>\n\n    This extension uses the ICU defaults for regular expression matching\n    behavior. Specifically, this means that:\n\n        * Matching is case-sensitive,\n        * Regular expression comments are not allowed within patterns, and\n        * The '^' and '$' characters match the beginning and end of the\n          <string> argument, not the beginning and end of lines within\n          the <string> argument.\n\n    Even more specifically, the value passed to the \"flags\" parameter\n    of ICU C function uregex_open() is 0.\n\n\n2  COMPILATION AND USAGE\n\n  The easiest way to compile and use the ICU extension is to build\n  and use it as a dynamically loadable SQLite extension. To do this\n  using gcc on *nix:\n\n    gcc -shared icu.c `icu-config --ldflags` -o libSqliteIcu.so\n\n  You may need to add \"-I\" flags so that gcc can find sqlite3ext.h\n  and sqlite3.h. The resulting shared lib, libSqliteIcu.so, may be\n  loaded into sqlite in the same way as any other dynamically loadable\n  extension.\n\n\n3 BUGS, PROBLEMS AND SECURITY ISSUES\n\n  3.1 The \"case_sensitive_like\" Pragma\n\n    This extension does not work well with the \"case_sensitive_like\"\n    pragma. If this pragma is used before the ICU extension is loaded,\n    then the pragma has no effect. If the pragma is used after the ICU\n    extension is loaded, then SQLite ignores the ICU implementation and\n    always uses the built-in LIKE operator.\n\n    The ICU extension LIKE operator is always case insensitive.\n\n  3.2 The SQLITE_MAX_LIKE_PATTERN_LENGTH Macro\n\n    Passing very long patterns to the built-in SQLite LIKE operator can\n    cause excessive CPU usage. To curb this problem, SQLite defines the\n    SQLITE_MAX_LIKE_PATTERN_LENGTH macro as the maximum length of a\n    pattern in bytes (irrespective of encoding). The default value is\n    defined in internal header file \"limits.h\".\n    \n    The ICU extension LIKE implementation suffers from the same \n    problem and uses the same solution. However, since the ICU extension\n    code does not include the SQLite file \"limits.h\", modifying\n    the default value therein does not affect the ICU extension.\n    The default value of SQLITE_MAX_LIKE_PATTERN_LENGTH used by\n    the ICU extension LIKE operator is 50000, defined in source \n    file \"icu.c\".\n\n  3.3 Collation Sequence Security Issue\n\n    Internally, SQLite assumes that indices stored in database files\n    are sorted according to the collation sequence indicated by the\n    SQL schema. Changing the definition of a collation sequence after\n    an index has been built is therefore equivalent to database\n    corruption. The SQLite library is not very well tested under\n    these conditions, and may contain potential buffer overruns\n    or other programming errors that could be exploited by a malicious\n    programmer.\n\n    If the ICU extension is used in an environment where potentially\n    malicious users may execute arbitrary SQL (i.e. gears), they\n    should be prevented from invoking the icu_load_collation() function,\n    possibly using the authorisation callback.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/icu/icu.c",
    "content": "/*\n** 2007 May 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $\n**\n** This file implements an integration between the ICU library \n** (\"International Components for Unicode\", an open-source library \n** for handling unicode data) and SQLite. The integration uses \n** ICU to provide the following to SQLite:\n**\n**   * An implementation of the SQL regexp() function (and hence REGEXP\n**     operator) using the ICU uregex_XX() APIs.\n**\n**   * Implementations of the SQL scalar upper() and lower() functions\n**     for case mapping.\n**\n**   * Integration of ICU and SQLite collation sequences.\n**\n**   * An implementation of the LIKE operator that uses ICU to \n**     provide case-independent matching.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)\n\n/* Include ICU headers */\n#include <unicode/utypes.h>\n#include <unicode/uregex.h>\n#include <unicode/ustring.h>\n#include <unicode/ucol.h>\n\n#include <assert.h>\n\n#ifndef SQLITE_CORE\n  #include \"sqlite3ext.h\"\n  SQLITE_EXTENSION_INIT1\n#else\n  #include \"sqlite3.h\"\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Version of sqlite3_free() that is always a function, never a macro.\n*/\nstatic void xFree(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character. It is copied here from SQLite source\n** code file utf8.c.\n*/\nstatic const unsigned char icuUtf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define SQLITE_ICU_READ_UTF8(zIn, c)                       \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = icuUtf8Trans1[c-0xc0];                             \\\n    while( (*zIn & 0xc0)==0x80 ){                          \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n  }\n\n#define SQLITE_ICU_SKIP_UTF8(zIn)                          \\\n  assert( *zIn );                                          \\\n  if( *(zIn++)>=0xc0 ){                                    \\\n    while( (*zIn & 0xc0)==0x80 ){zIn++;}                   \\\n  }\n\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a \"LIKE\" expression. Return true (1) if they are the same and \n** false (0) if they are different.\n*/\nstatic int icuLikeCompare(\n  const uint8_t *zPattern,   /* LIKE pattern */\n  const uint8_t *zString,    /* The UTF-8 string to compare against */\n  const UChar32 uEsc         /* The escape character */\n){\n  static const uint32_t MATCH_ONE = (uint32_t)'_';\n  static const uint32_t MATCH_ALL = (uint32_t)'%';\n\n  int prevEscape = 0;     /* True if the previous character was uEsc */\n\n  while( 1 ){\n\n    /* Read (and consume) the next character from the input pattern. */\n    uint32_t uPattern;\n    SQLITE_ICU_READ_UTF8(zPattern, uPattern);\n    if( uPattern==0 ) break;\n\n    /* There are now 4 possibilities:\n    **\n    **     1. uPattern is an unescaped match-all character \"%\",\n    **     2. uPattern is an unescaped match-one character \"_\",\n    **     3. uPattern is an unescaped escape character, or\n    **     4. uPattern is to be handled as an ordinary character\n    */\n    if( !prevEscape && uPattern==MATCH_ALL ){\n      /* Case 1. */\n      uint8_t c;\n\n      /* Skip any MATCH_ALL or MATCH_ONE characters that follow a\n      ** MATCH_ALL. For each MATCH_ONE, skip one character in the \n      ** test string.\n      */\n      while( (c=*zPattern) == MATCH_ALL || c == MATCH_ONE ){\n        if( c==MATCH_ONE ){\n          if( *zString==0 ) return 0;\n          SQLITE_ICU_SKIP_UTF8(zString);\n        }\n        zPattern++;\n      }\n\n      if( *zPattern==0 ) return 1;\n\n      while( *zString ){\n        if( icuLikeCompare(zPattern, zString, uEsc) ){\n          return 1;\n        }\n        SQLITE_ICU_SKIP_UTF8(zString);\n      }\n      return 0;\n\n    }else if( !prevEscape && uPattern==MATCH_ONE ){\n      /* Case 2. */\n      if( *zString==0 ) return 0;\n      SQLITE_ICU_SKIP_UTF8(zString);\n\n    }else if( !prevEscape && uPattern==(uint32_t)uEsc){\n      /* Case 3. */\n      prevEscape = 1;\n\n    }else{\n      /* Case 4. */\n      uint32_t uString;\n      SQLITE_ICU_READ_UTF8(zString, uString);\n      uString = (uint32_t)u_foldCase((UChar32)uString, U_FOLD_CASE_DEFAULT);\n      uPattern = (uint32_t)u_foldCase((UChar32)uPattern, U_FOLD_CASE_DEFAULT);\n      if( uString!=uPattern ){\n        return 0;\n      }\n      prevEscape = 0;\n    }\n  }\n\n  return *zString==0;\n}\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B, A). If there is an escape character E, \n**\n**       A LIKE B ESCAPE E\n**\n** is mapped to like(B, A, E).\n*/\nstatic void icuLikeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA = sqlite3_value_text(argv[0]);\n  const unsigned char *zB = sqlite3_value_text(argv[1]);\n  UChar32 uEsc = 0;\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    int nE= sqlite3_value_bytes(argv[2]);\n    const unsigned char *zE = sqlite3_value_text(argv[2]);\n    int i = 0;\n    if( zE==0 ) return;\n    U8_NEXT(zE, i, nE, uEsc);\n    if( i!=nE){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n  }\n\n  if( zA && zB ){\n    sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));\n  }\n}\n\n/*\n** This function is called when an ICU function called from within\n** the implementation of an SQL scalar function returns an error.\n**\n** The scalar function context passed as the first argument is \n** loaded with an error message based on the following two args.\n*/\nstatic void icuFunctionError(\n  sqlite3_context *pCtx,       /* SQLite scalar function context */\n  const char *zName,           /* Name of ICU function that failed */\n  UErrorCode e                 /* Error code returned by ICU function */\n){\n  char zBuf[128];\n  sqlite3_snprintf(128, zBuf, \"ICU error: %s(): %s\", zName, u_errorName(e));\n  zBuf[127] = '\\0';\n  sqlite3_result_error(pCtx, zBuf, -1);\n}\n\n/*\n** Function to delete compiled regexp objects. Registered as\n** a destructor function with sqlite3_set_auxdata().\n*/\nstatic void icuRegexpDelete(void *p){\n  URegularExpression *pExpr = (URegularExpression *)p;\n  uregex_close(pExpr);\n}\n\n/*\n** Implementation of SQLite REGEXP operator. This scalar function takes\n** two arguments. The first is a regular expression pattern to compile\n** the second is a string to match against that pattern. If either \n** argument is an SQL NULL, then NULL Is returned. Otherwise, the result\n** is 1 if the string matches the pattern, or 0 otherwise.\n**\n** SQLite maps the regexp() function to the regexp() operator such\n** that the following two are equivalent:\n**\n**     zString REGEXP zPattern\n**     regexp(zPattern, zString)\n**\n** Uses the following ICU regexp APIs:\n**\n**     uregex_open()\n**     uregex_matches()\n**     uregex_close()\n*/\nstatic void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  UErrorCode status = U_ZERO_ERROR;\n  URegularExpression *pExpr;\n  UBool res;\n  const UChar *zString = sqlite3_value_text16(apArg[1]);\n\n  (void)nArg;  /* Unused parameter */\n\n  /* If the left hand side of the regexp operator is NULL, \n  ** then the result is also NULL. \n  */\n  if( !zString ){\n    return;\n  }\n\n  pExpr = sqlite3_get_auxdata(p, 0);\n  if( !pExpr ){\n    const UChar *zPattern = sqlite3_value_text16(apArg[0]);\n    if( !zPattern ){\n      return;\n    }\n    pExpr = uregex_open(zPattern, -1, 0, 0, &status);\n\n    if( U_SUCCESS(status) ){\n      sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);\n    }else{\n      assert(!pExpr);\n      icuFunctionError(p, \"uregex_open\", status);\n      return;\n    }\n  }\n\n  /* Configure the text that the regular expression operates on. */\n  uregex_setText(pExpr, zString, -1, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_setText\", status);\n    return;\n  }\n\n  /* Attempt the match */\n  res = uregex_matches(pExpr, 0, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_matches\", status);\n    return;\n  }\n\n  /* Set the text that the regular expression operates on to a NULL\n  ** pointer. This is not really necessary, but it is tidier than \n  ** leaving the regular expression object configured with an invalid\n  ** pointer after this function returns.\n  */\n  uregex_setText(pExpr, 0, 0, &status);\n\n  /* Return 1 or 0. */\n  sqlite3_result_int(p, res ? 1 : 0);\n}\n\n/*\n** Implementations of scalar functions for case mapping - upper() and \n** lower(). Function upper() converts its input to upper-case (ABC).\n** Function lower() converts to lower-case (abc).\n**\n** ICU provides two types of case mapping, \"general\" case mapping and\n** \"language specific\". Refer to ICU documentation for the differences\n** between the two.\n**\n** To utilise \"general\" case mapping, the upper() or lower() scalar \n** functions are invoked with one argument:\n**\n**     upper('ABC') -> 'abc'\n**     lower('abc') -> 'ABC'\n**\n** To access ICU \"language specific\" case mapping, upper() or lower()\n** should be invoked with two arguments. The second argument is the name\n** of the locale to use. Passing an empty string (\"\") or SQL NULL value\n** as the second argument is the same as invoking the 1 argument version\n** of upper() or lower().\n**\n**     lower('I', 'en_us') -> 'i'\n**     lower('I', 'tr_tr') -> '\\u131' (small dotless i)\n**\n** http://www.icu-project.org/userguide/posix.html#case_mappings\n*/\nstatic void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  const UChar *zInput;            /* Pointer to input string */\n  UChar *zOutput = 0;             /* Pointer to output buffer */\n  int nInput;                     /* Size of utf-16 input string in bytes */\n  int nOut;                       /* Size of output buffer in bytes */\n  int cnt;\n  int bToUpper;                   /* True for toupper(), false for tolower() */\n  UErrorCode status;\n  const char *zLocale = 0;\n\n  assert(nArg==1 || nArg==2);\n  bToUpper = (sqlite3_user_data(p)!=0);\n  if( nArg==2 ){\n    zLocale = (const char *)sqlite3_value_text(apArg[1]);\n  }\n\n  zInput = sqlite3_value_text16(apArg[0]);\n  if( !zInput ){\n    return;\n  }\n  nOut = nInput = sqlite3_value_bytes16(apArg[0]);\n  if( nOut==0 ){\n    sqlite3_result_text16(p, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(cnt=0; cnt<2; cnt++){\n    UChar *zNew = sqlite3_realloc(zOutput, nOut);\n    if( zNew==0 ){\n      sqlite3_free(zOutput);\n      sqlite3_result_error_nomem(p);\n      return;\n    }\n    zOutput = zNew;\n    status = U_ZERO_ERROR;\n    if( bToUpper ){\n      nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }else{\n      nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }\n\n    if( U_SUCCESS(status) ){\n      sqlite3_result_text16(p, zOutput, nOut, xFree);\n    }else if( status==U_BUFFER_OVERFLOW_ERROR ){\n      assert( cnt==0 );\n      continue;\n    }else{\n      icuFunctionError(p, bToUpper ? \"u_strToUpper\" : \"u_strToLower\", status);\n    }\n    return;\n  }\n  assert( 0 );     /* Unreachable */\n}\n\n/*\n** Collation sequence destructor function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic void icuCollationDel(void *pCtx){\n  UCollator *p = (UCollator *)pCtx;\n  ucol_close(p);\n}\n\n/*\n** Collation sequence comparison function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic int icuCollationColl(\n  void *pCtx,\n  int nLeft,\n  const void *zLeft,\n  int nRight,\n  const void *zRight\n){\n  UCollationResult res;\n  UCollator *p = (UCollator *)pCtx;\n  res = ucol_strcoll(p, (UChar *)zLeft, nLeft/2, (UChar *)zRight, nRight/2);\n  switch( res ){\n    case UCOL_LESS:    return -1;\n    case UCOL_GREATER: return +1;\n    case UCOL_EQUAL:   return 0;\n  }\n  assert(!\"Unexpected return value from ucol_strcoll()\");\n  return 0;\n}\n\n/*\n** Implementation of the scalar function icu_load_collation().\n**\n** This scalar function is used to add ICU collation based collation \n** types to an SQLite database connection. It is intended to be called\n** as follows:\n**\n**     SELECT icu_load_collation(<locale>, <collation-name>);\n**\n** Where <locale> is a string containing an ICU locale identifier (i.e.\n** \"en_AU\", \"tr_TR\" etc.) and <collation-name> is the name of the\n** collation sequence to create.\n*/\nstatic void icuLoadCollation(\n  sqlite3_context *p, \n  int nArg, \n  sqlite3_value **apArg\n){\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(p);\n  UErrorCode status = U_ZERO_ERROR;\n  const char *zLocale;      /* Locale identifier - (eg. \"jp_JP\") */\n  const char *zName;        /* SQL Collation sequence name (eg. \"japanese\") */\n  UCollator *pUCollator;    /* ICU library collation object */\n  int rc;                   /* Return code from sqlite3_create_collation_x() */\n\n  assert(nArg==2);\n  (void)nArg; /* Unused parameter */\n  zLocale = (const char *)sqlite3_value_text(apArg[0]);\n  zName = (const char *)sqlite3_value_text(apArg[1]);\n\n  if( !zLocale || !zName ){\n    return;\n  }\n\n  pUCollator = ucol_open(zLocale, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"ucol_open\", status);\n    return;\n  }\n  assert(p);\n\n  rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, \n      icuCollationColl, icuCollationDel\n  );\n  if( rc!=SQLITE_OK ){\n    ucol_close(pUCollator);\n    sqlite3_result_error(p, \"Error registering collation function\", -1);\n  }\n}\n\n/*\n** Register the ICU extension functions with database db.\n*/\nint sqlite3IcuInit(sqlite3 *db){\n  static const struct IcuScalar {\n    const char *zName;                        /* Function name */\n    unsigned char nArg;                       /* Number of arguments */\n    unsigned short enc;                       /* Optimal text encoding */\n    unsigned char iContext;                   /* sqlite3_user_data() context */\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } scalars[] = {\n    {\"icu_load_collation\",  2, SQLITE_UTF8,                1, icuLoadCollation},\n    {\"regexp\", 2, SQLITE_ANY|SQLITE_DETERMINISTIC,         0, icuRegexpFunc},\n    {\"lower\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"lower\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"like\",   2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n    {\"like\",   3, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n  };\n  int rc = SQLITE_OK;\n  int i;\n\n  \n  for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){\n    const struct IcuScalar *p = &scalars[i];\n    rc = sqlite3_create_function(\n        db, p->zName, p->nArg, p->enc, \n        p->iContext ? (void*)db : (void*)0,\n        p->xFunc, 0, 0\n    );\n  }\n\n  return rc;\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_icu_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3IcuInit(db);\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/icu/sqliteicu.h",
    "content": "/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** ICU extension.  All it does is declare the sqlite3IcuInit() interface.\n*/\n#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint sqlite3IcuInit(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/Makefile",
    "content": "#\n# This Makefile is designed for use with main.mk in the root directory of\n# this project. After including main.mk, the users makefile should contain:\n#\n#    LSMDIR=$(TOP)/ext/lsm1/\n#    LSMOPTS=-fPIC\n#    include $(LSMDIR)/Makefile\n#\n# The most useful targets are [lsmtest] and [lsm.so].\n#\n\nLSMOBJ    = \\\n  lsm_ckpt.o \\\n  lsm_file.o \\\n  lsm_log.o \\\n  lsm_main.o \\\n  lsm_mem.o \\\n  lsm_mutex.o \\\n  lsm_shared.o \\\n  lsm_sorted.o \\\n  lsm_str.o \\\n  lsm_tree.o \\\n  lsm_unix.o \\\n  lsm_win32.o \\\n  lsm_varint.o \\\n  lsm_vtab.o\n\nLSMHDR   = \\\n  $(LSMDIR)/lsm.h \\\n  $(LSMDIR)/lsmInt.h\n\nLSMTESTSRC = $(LSMDIR)/lsm-test/lsmtest1.c $(LSMDIR)/lsm-test/lsmtest2.c     \\\n             $(LSMDIR)/lsm-test/lsmtest3.c $(LSMDIR)/lsm-test/lsmtest4.c     \\\n             $(LSMDIR)/lsm-test/lsmtest5.c $(LSMDIR)/lsm-test/lsmtest6.c     \\\n             $(LSMDIR)/lsm-test/lsmtest7.c $(LSMDIR)/lsm-test/lsmtest8.c     \\\n             $(LSMDIR)/lsm-test/lsmtest9.c                                   \\\n             $(LSMDIR)/lsm-test/lsmtest_datasource.c \\\n             $(LSMDIR)/lsm-test/lsmtest_func.c $(LSMDIR)/lsm-test/lsmtest_io.c  \\\n             $(LSMDIR)/lsm-test/lsmtest_main.c $(LSMDIR)/lsm-test/lsmtest_mem.c \\\n             $(LSMDIR)/lsm-test/lsmtest_tdb.c $(LSMDIR)/lsm-test/lsmtest_tdb3.c \\\n             $(LSMDIR)/lsm-test/lsmtest_util.c $(LSMDIR)/lsm-test/lsmtest_win32.c\n\n\n# all: lsm.so\n\nLSMOPTS += -DLSM_MUTEX_PTHREADS=1 -I$(LSMDIR)\n\nlsm.so:\t$(LSMOBJ)\n\t$(TCCX) -shared -o lsm.so $(LSMOBJ)\n\n%.o:\t$(LSMDIR)/%.c $(LSMHDR) sqlite3.h\n\t$(TCCX) $(LSMOPTS) -c $<\n\t\nlsmtest$(EXE): $(LSMOBJ) $(LSMTESTSRC) $(LSMTESTHDR) sqlite3.o\n\t# $(TCPPX) -c $(TOP)/lsm-test/lsmtest_tdb2.cc\n\t$(TCCX) $(LSMOPTS) $(LSMTESTSRC) $(LSMOBJ) sqlite3.o -o lsmtest$(EXE) $(THREADLIB)\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/Makefile.msc",
    "content": "#\n# This Makefile is designed for use with Makefile.msc in the root directory\n# of this project.  The Makefile.msc should contain:\n#\n#    LSMDIR=$(TOP)\\ext\\lsm1\n#    !INCLUDE $(LSMDIR)\\Makefile.msc\n#\n# The most useful targets are [lsmtest.exe] and [lsm.dll].\n#\n\nLSMOBJ    = \\\n  lsm_ckpt.lo \\\n  lsm_file.lo \\\n  lsm_log.lo \\\n  lsm_main.lo \\\n  lsm_mem.lo \\\n  lsm_mutex.lo \\\n  lsm_shared.lo \\\n  lsm_sorted.lo \\\n  lsm_str.lo \\\n  lsm_tree.lo \\\n  lsm_unix.lo \\\n  lsm_win32.lo \\\n  lsm_varint.lo \\\n  lsm_vtab.lo\n\nLSMHDR   = \\\n  $(LSMDIR)\\lsm.h \\\n  $(LSMDIR)\\lsmInt.h\n\nLSMTESTSRC = $(LSMDIR)\\lsm-test\\lsmtest1.c $(LSMDIR)\\lsm-test\\lsmtest2.c     \\\n             $(LSMDIR)\\lsm-test\\lsmtest3.c $(LSMDIR)\\lsm-test\\lsmtest4.c     \\\n             $(LSMDIR)\\lsm-test\\lsmtest5.c $(LSMDIR)\\lsm-test\\lsmtest6.c     \\\n             $(LSMDIR)\\lsm-test\\lsmtest7.c $(LSMDIR)\\lsm-test\\lsmtest8.c     \\\n             $(LSMDIR)\\lsm-test\\lsmtest9.c                                   \\\n             $(LSMDIR)\\lsm-test\\lsmtest_datasource.c \\\n             $(LSMDIR)\\lsm-test\\lsmtest_func.c $(LSMDIR)\\lsm-test\\lsmtest_io.c  \\\n             $(LSMDIR)\\lsm-test\\lsmtest_main.c $(LSMDIR)\\lsm-test\\lsmtest_mem.c \\\n             $(LSMDIR)\\lsm-test\\lsmtest_tdb.c $(LSMDIR)\\lsm-test\\lsmtest_tdb3.c \\\n             $(LSMDIR)\\lsm-test\\lsmtest_util.c $(LSMDIR)\\lsm-test\\lsmtest_win32.c\n\n# all: lsm.dll lsmtest.exe\n\nLSMOPTS = $(NO_WARN) -DLSM_MUTEX_WIN32=1 -I$(LSMDIR)\n\n!IF $(DEBUG)>2\nLSMOPTS = $(LSMOPTS) -DLSM_DEBUG=1\n!ENDIF\n\n!IF $(MEMDEBUG)!=0\nLSMOPTS = $(LSMOPTS) -DLSM_DEBUG_MEM=1\n!ENDIF\n\nlsm_ckpt.lo:\t$(LSMDIR)\\lsm_ckpt.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_ckpt.c\n\nlsm_file.lo:\t$(LSMDIR)\\lsm_file.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_file.c\n\nlsm_log.lo:\t$(LSMDIR)\\lsm_log.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_log.c\n\nlsm_main.lo:\t$(LSMDIR)\\lsm_main.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_main.c\n\nlsm_mem.lo:\t$(LSMDIR)\\lsm_mem.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_mem.c\n\nlsm_mutex.lo:\t$(LSMDIR)\\lsm_mutex.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_mutex.c\n\nlsm_shared.lo:\t$(LSMDIR)\\lsm_shared.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_shared.c\n\nlsm_sorted.lo:\t$(LSMDIR)\\lsm_sorted.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_sorted.c\n\nlsm_str.lo:\t$(LSMDIR)\\lsm_str.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_str.c\n\nlsm_tree.lo:\t$(LSMDIR)\\lsm_tree.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_tree.c\n\nlsm_unix.lo:\t$(LSMDIR)\\lsm_unix.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_unix.c\n\nlsm_win32.lo:\t$(LSMDIR)\\lsm_win32.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_win32.c\n\nlsm_varint.lo:\t$(LSMDIR)\\lsm_varint.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_varint.c\n\nlsm_vtab.lo:\t$(LSMDIR)\\lsm_vtab.c $(LSMHDR) $(SQLITE3H)\n\t$(LTCOMPILE) $(LSMOPTS) -c $(LSMDIR)\\lsm_vtab.c\n\nlsm.dll:\t$(LSMOBJ)\n\t$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ $(LSMOBJ)\n\tcopy /Y $@ $(LSMDIR)\\$@\n\nlsmtest.exe: $(LSMOBJ) $(LSMTESTSRC) $(LSMTESTHDR) $(LIBOBJ)\n\t$(LTLINK) $(LSMOPTS) $(LSMTESTSRC) /link $(LSMOBJ) $(LIBOBJ)\n\tcopy /Y $@ $(LSMDIR)\\$@\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/README",
    "content": "\n\nOrganization of test case files:\n\n  lsmtest1.c: Data tests. Tests that perform many inserts and deletes on a \n              database file, then verify that the contents of the database can\n              be queried.\n\n  lsmtest2.c: Crash tests. Tests that attempt to verify that the database \n              recovers correctly following an application or system crash.\n\n  lsmtest3.c: Rollback tests. Tests that focus on the explicit rollback of\n              transactions and sub-transactions.\n\n  lsmtest4.c: Multi-client tests.\n\n  lsmtest5.c: Multi-client tests with a different thread for each client.\n\n  lsmtest6.c: OOM injection tests.\n\n  lsmtest7.c: API tests.\n\n  lsmtest8.c: Writer crash tests. Tests in this file attempt to verify that\n              the system recovers and other clients proceed unaffected if\n              a process fails in the middle of a write transaction.\n\n              The difference from lsmtest2.c is that this file tests\n              live-recovery (recovery from a failure that occurs while other\n              clients are still running) whereas lsmtest2.c tests recovery\n              from a system or power failure.\n\n  lsmtest9.c: More data tests. These focus on testing that calling\n              lsm_work(nMerge=1) to compact the database does not corrupt it.\n              In other words, that databases containing block-redirects\n              can be read and written.\n\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest.h",
    "content": "\n#ifndef __WRAPPER_INT_H_\n#define __WRAPPER_INT_H_\n\n#include \"lsmtest_tdb.h\"\n#include \"sqlite3.h\"\n#include \"lsm.h\"\n\n#include <assert.h>\n#include <stdarg.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n#ifndef _WIN32\n# include <unistd.h>\n#endif\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <ctype.h>\n#include <stdlib.h>\n#include <errno.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef _WIN32\n# include \"windows.h\"\n# define gettimeofday win32GetTimeOfDay\n# define F_OK  (0)\n# define sleep(sec) Sleep(1000 * (sec))\n# define usleep(usec) Sleep(((usec) + 999) / 1000)\n# ifdef _MSC_VER\n#  include <io.h>\n#  define snprintf _snprintf\n#  define fsync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))\n#  define fdatasync(fd) FlushFileBuffers((HANDLE)_get_osfhandle((fd)))\n#  define __va_copy(dst,src) ((dst) = (src))\n#  define ftruncate(fd,sz) ((_chsize_s((fd), (sz))==0) ? 0 : -1)\n# else\n#  error Unsupported C compiler for Windows.\n# endif\nint win32GetTimeOfDay(struct timeval *, void *);\n#endif\n\n#ifndef _LSM_INT_H\ntypedef unsigned int  u32;\ntypedef unsigned char u8;\ntypedef long long int i64;\ntypedef unsigned long long int u64;\n#endif\n\n\n#define ArraySize(x) ((int)(sizeof(x) / sizeof((x)[0])))\n\n#define MIN(x,y) ((x)<(y) ? (x) : (y))\n#define MAX(x,y) ((x)>(y) ? (x) : (y))\n\n#define unused_parameter(x) (void)(x)\n\n#define TESTDB_DEFAULT_PAGE_SIZE   4096\n#define TESTDB_DEFAULT_CACHE_SIZE  2048\n\n#ifndef _O_BINARY\n# define _O_BINARY (0)\n#endif\n\n/*\n** Ideally, these should be in wrapper.c. But they are here instead so that \n** they can be used by the C++ database wrappers in wrapper2.cc.\n*/\ntypedef struct DatabaseMethods DatabaseMethods;\nstruct TestDb {\n  DatabaseMethods const *pMethods;          /* Database methods */\n  const char *zLibrary;                     /* Library name for tdb_open() */\n};\nstruct DatabaseMethods {\n  int (*xClose)(TestDb *);\n  int (*xWrite)(TestDb *, void *, int , void *, int);\n  int (*xDelete)(TestDb *, void *, int);\n  int (*xDeleteRange)(TestDb *, void *, int, void *, int);\n  int (*xFetch)(TestDb *, void *, int, void **, int *);\n  int (*xScan)(TestDb *, void *, int, void *, int, void *, int,\n    void (*)(void *, void *, int , void *, int)\n  );\n  int (*xBegin)(TestDb *, int);\n  int (*xCommit)(TestDb *, int);\n  int (*xRollback)(TestDb *, int);\n};\n\n/* \n** Functions in wrapper2.cc (a C++ source file). wrapper2.cc contains the\n** wrapper for Kyoto Cabinet. Kyoto cabinet has a C API, but\n** the primary interface is the C++ API.\n*/\nint test_kc_open(const char*, const char *zFilename, int bClear, TestDb **ppDb);\nint test_kc_close(TestDb *);\nint test_kc_write(TestDb *, void *, int , void *, int);\nint test_kc_delete(TestDb *, void *, int);\nint test_kc_delete_range(TestDb *, void *, int, void *, int);\nint test_kc_fetch(TestDb *, void *, int, void **, int *);\nint test_kc_scan(TestDb *, void *, int, void *, int, void *, int,\n  void (*)(void *, void *, int , void *, int)\n);\n\nint test_mdb_open(const char*, const char *zFile, int bClear, TestDb **ppDb);\nint test_mdb_close(TestDb *);\nint test_mdb_write(TestDb *, void *, int , void *, int);\nint test_mdb_delete(TestDb *, void *, int);\nint test_mdb_fetch(TestDb *, void *, int, void **, int *);\nint test_mdb_scan(TestDb *, void *, int, void *, int, void *, int,\n  void (*)(void *, void *, int , void *, int)\n);\n\n/* \n** Functions in wrapper3.c. This file contains the tdb wrapper for lsm.\n** The wrapper for lsm is a bit more involved than the others, as it \n** includes code for a couple of different lsm configurations, and for\n** various types of fault injection and robustness testing.\n*/\nint test_lsm_open(const char*, const char *zFile, int bClear, TestDb **ppDb);\nint test_lsm_lomem_open(const char*, const char*, int bClear, TestDb **ppDb);\nint test_lsm_zip_open(const char*, const char*, int bClear, TestDb **ppDb);\nint test_lsm_small_open(const char*, const char*, int bClear, TestDb **ppDb);\nint test_lsm_mt2(const char*, const char *zFile, int bClear, TestDb **ppDb);\nint test_lsm_mt3(const char*, const char *zFile, int bClear, TestDb **ppDb);\n\nint tdb_lsm_configure(lsm_db *, const char *);\n\n/* Functions in lsmtest_tdb4.c */\nint test_bt_open(const char*, const char *zFile, int bClear, TestDb **ppDb);\nint test_fbt_open(const char*, const char *zFile, int bClear, TestDb **ppDb);\nint test_fbts_open(const char*, const char *zFile, int bClear, TestDb **ppDb);\n\n\n/* Functions in testutil.c. */\nint  testPrngInit(void);\nu32  testPrngValue(u32 iVal);\nvoid testPrngArray(u32 iVal, u32 *aOut, int nOut);\nvoid testPrngString(u32 iVal, char *aOut, int nOut);\n\nvoid testErrorInit(int argc, char **);\nvoid testPrintError(const char *zFormat, ...);\nvoid testPrintUsage(const char *zArgs);\nvoid testPrintFUsage(const char *zFormat, ...);\nvoid testTimeInit(void);\nint  testTimeGet(void);\n\n/* Functions in testmem.c. */\nvoid testMallocInstall(lsm_env *pEnv);\nvoid testMallocUninstall(lsm_env *pEnv);\nvoid testMallocCheck(lsm_env *pEnv, int *, int *, FILE *);\nvoid testMallocOom(lsm_env *pEnv, int, int, void(*)(void*), void *);\nvoid testMallocOomEnable(lsm_env *pEnv, int);\n\n/* lsmtest.c */\nTestDb *testOpen(const char *zSystem, int, int *pRc);\nvoid testReopen(TestDb **ppDb, int *pRc);\nvoid testClose(TestDb **ppDb);\n\nvoid testFetch(TestDb *, void *, int, void *, int, int *);\nvoid testWrite(TestDb *, void *, int, void *, int, int *);\nvoid testDelete(TestDb *, void *, int, int *);\nvoid testDeleteRange(TestDb *, void *, int, void *, int, int *);\nvoid testWriteStr(TestDb *, const char *, const char *zVal, int *pRc);\nvoid testFetchStr(TestDb *, const char *, const char *, int *pRc);\n\nvoid testBegin(TestDb *pDb, int iTrans, int *pRc);\nvoid testCommit(TestDb *pDb, int iTrans, int *pRc);\n\nvoid test_failed(void);\n\nchar *testMallocPrintf(const char *zFormat, ...);\nchar *testMallocVPrintf(const char *zFormat, va_list ap);\nint testGlobMatch(const char *zPattern, const char *zStr);\n\nvoid testScanCompare(TestDb *, TestDb *, int, void *, int, void *, int, int *);\nvoid testFetchCompare(TestDb *, TestDb *, void *, int, int *);\n\nvoid *testMalloc(int);\nvoid *testMallocCopy(void *pCopy, int nByte);\nvoid *testRealloc(void *, int);\nvoid testFree(void *);\n\n/* lsmtest_bt.c */\nint do_bt(int nArg, char **azArg);\n\n/* testio.c */\nint testVfsConfigureDb(TestDb *pDb);\n\n/* testfunc.c */\nint do_show(int nArg, char **azArg);\nint do_work(int nArg, char **azArg);\n\n/* testio.c */\nint do_io(int nArg, char **azArg);\n\n/* lsmtest2.c */\nvoid do_crash_test(const char *zPattern, int *pRc);\nint do_rollback_test(int nArg, char **azArg);\n\n/* test3.c */\nvoid test_rollback(const char *zSystem, const char *zPattern, int *pRc);\n\n/* test4.c */\nvoid test_mc(const char *zSystem, const char *zPattern, int *pRc);\n\n/* test5.c */\nvoid test_mt(const char *zSystem, const char *zPattern, int *pRc);\n\n/* lsmtest6.c */\nvoid test_oom(const char *zPattern, int *pRc);\nvoid testDeleteLsmdb(const char *zFile);\n\nvoid testSaveDb(const char *zFile, const char *zAuxExt);\nvoid testRestoreDb(const char *zFile, const char *zAuxExt);\nvoid testCopyLsmdb(const char *zFrom, const char *zTo);\n\n/* lsmtest7.c */\nvoid test_api(const char *zPattern, int *pRc);\n\n/* lsmtest8.c */\nvoid do_writer_crash_test(const char *zPattern, int *pRc);\n\n/*************************************************************************\n** Interface to functionality in test_datasource.c.\n*/\ntypedef struct Datasource Datasource;\ntypedef struct DatasourceDefn DatasourceDefn;\n\nstruct DatasourceDefn {\n  int eType;                      /* A TEST_DATASOURCE_* value */\n  int nMinKey;                    /* Minimum key size */\n  int nMaxKey;                    /* Maximum key size */\n  int nMinVal;                    /* Minimum value size */\n  int nMaxVal;                    /* Maximum value size */\n};\n\n#define TEST_DATASOURCE_RANDOM    1\n#define TEST_DATASOURCE_SEQUENCE  2\n\nchar *testDatasourceName(const DatasourceDefn *);\nDatasource *testDatasourceNew(const DatasourceDefn *);\nvoid testDatasourceFree(Datasource *);\nvoid testDatasourceEntry(Datasource *, int, void **, int *, void **, int *);\n/* End of test_datasource.c interface.\n*************************************************************************/\nvoid testDatasourceFetch(\n  TestDb *pDb,                    /* Database handle */\n  Datasource *pData,\n  int iKey,\n  int *pRc                        /* IN/OUT: Error code */\n);\n\nvoid testWriteDatasource(TestDb *, Datasource *, int, int *);\nvoid testWriteDatasourceRange(TestDb *, Datasource *, int, int, int *);\nvoid testDeleteDatasource(TestDb *, Datasource *, int, int *);\nvoid testDeleteDatasourceRange(TestDb *, Datasource *, int, int, int *);\n\n\n/* test1.c */\nvoid test_data_1(const char *, const char *, int *pRc);\nvoid test_data_2(const char *, const char *, int *pRc);\nvoid test_data_3(const char *, const char *, int *pRc);\nvoid testDbContents(TestDb *, Datasource *, int, int, int, int, int, int *);\nvoid testCaseProgress(int, int, int, int *);\nint testCaseNDot(void);\n\nvoid testCompareDb(Datasource *, int, int, TestDb *, TestDb *, int *);\nint testControlDb(TestDb **ppDb);\n\ntypedef struct CksumDb CksumDb;\nCksumDb *testCksumArrayNew(Datasource *, int, int, int);\nchar *testCksumArrayGet(CksumDb *, int);\nvoid testCksumArrayFree(CksumDb *);\nvoid testCaseStart(int *pRc, char *zFmt, ...);\nvoid testCaseFinish(int rc);\nvoid testCaseSkip(void);\nint testCaseBegin(int *, const char *, const char *, ...);\n\n#define TEST_CKSUM_BYTES 29\nint testCksumDatabase(TestDb *pDb, char *zOut);\nint testCountDatabase(TestDb *pDb);\nvoid testCompareInt(int, int, int *);\nvoid testCompareStr(const char *z1, const char *z2, int *pRc);\n\n/* lsmtest9.c */\nvoid test_data_4(const char *, const char *, int *pRc);\n\n\n/*\n** Similar to the Tcl_GetIndexFromObjStruct() Tcl library function.\n*/\n#define testArgSelect(w,x,y,z) testArgSelectX(w,x,sizeof(w[0]),y,z)\nint testArgSelectX(void *, const char *, int, const char *, int *);\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest1.c",
    "content": "\n#include \"lsmtest.h\"\n\n#define DATA_SEQUENTIAL TEST_DATASOURCE_SEQUENCE\n#define DATA_RANDOM     TEST_DATASOURCE_RANDOM\n\ntypedef struct Datatest1 Datatest1;\ntypedef struct Datatest2 Datatest2;\n\n/*\n** An instance of the following structure contains parameters used to\n** customize the test function in this file. Test procedure:\n**\n**   1. Create a data-source based on the \"datasource definition\" vars.\n**\n**   2. Insert nRow key value pairs into the database.\n**\n**   3. Delete all keys from the database. Deletes are done in the same \n**      order as the inserts.\n**\n** During steps 2 and 3 above, after each Datatest1.nVerify inserts or\n** deletes, the following:\n**\n**   a. Run Datasource.nTest key lookups and check the results are as expected.\n**\n**   b. If Datasource.bTestScan is true, run a handful (8) of range\n**      queries (scanning forwards and backwards). Check that the results\n**      are as expected.\n**\n**   c. Close and reopen the database. Then run (a) and (b) again.\n*/\nstruct Datatest1 {\n  /* Datasource definition */\n  DatasourceDefn defn;\n\n  /* Test procedure parameters */\n  int nRow;                       /* Number of rows to insert then delete */\n  int nVerify;                    /* How often to verify the db contents */\n  int nTest;                      /* Number of keys to test (0==all) */\n  int bTestScan;                  /* True to do scan tests */\n};\n\n/*\n** An instance of the following data structure is used to describe the\n** second type of test case in this file. The chief difference between \n** these tests and those described by Datatest1 is that these tests also\n** experiment with range-delete operations. Tests proceed as follows:\n**\n**     1. Open the datasource described by Datatest2.defn. \n**\n**     2. Open a connection on an empty database.\n**\n**     3. Do this Datatest2.nIter times:\n**\n**        a) Insert Datatest2.nWrite key-value pairs from the datasource.\n**\n**        b) Select two pseudo-random keys and use them as the start\n**           and end points of a range-delete operation.\n**\n**        c) Verify that the contents of the database are as expected (see\n**           below for details).\n**\n**        d) Close and then reopen the database handle.\n**\n**        e) Verify that the contents of the database are still as expected.\n**\n** The inserts and range deletes are run twice - once on the database being\n** tested and once using a control system (sqlite3, kc etc. - something that \n** works). In order to verify that the contents of the db being tested are\n** correct, the test runs a bunch of scans and lookups on both the test and\n** control databases. If the results are the same, the test passes.\n*/\nstruct Datatest2 {\n  DatasourceDefn defn;\n  int nRange;\n  int nWrite;                     /* Number of writes per iteration */\n  int nIter;                      /* Total number of iterations to run */\n};\n\n/*\n** Generate a unique name for the test case pTest with database system\n** zSystem.\n*/\nstatic char *getName(const char *zSystem, int bRecover, Datatest1 *pTest){\n  char *zRet;\n  char *zData;\n  zData = testDatasourceName(&pTest->defn);\n  zRet = testMallocPrintf(\"data.%s.%s.rec=%d.%d.%d\", \n      zSystem, zData, bRecover, pTest->nRow, pTest->nVerify\n  );\n  testFree(zData);\n  return zRet;\n}\n\nint testControlDb(TestDb **ppDb){\n#ifdef HAVE_KYOTOCABINET\n  return tdb_open(\"kyotocabinet\", \"tmp.db\", 1, ppDb);\n#else\n  return tdb_open(\"sqlite3\", \"\", 1, ppDb);\n#endif\n}\n\nvoid testDatasourceFetch(\n  TestDb *pDb,                    /* Database handle */\n  Datasource *pData,\n  int iKey,\n  int *pRc                        /* IN/OUT: Error code */\n){\n  void *pKey; int nKey;           /* Database key to query for */\n  void *pVal; int nVal;           /* Expected result of query */\n\n  testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);\n  testFetch(pDb, pKey, nKey, pVal, nVal, pRc);\n}\n\n/*\n** This function is called to test that the contents of database pDb\n** are as expected. In this case, expected is defined as containing\n** key-value pairs iFirst through iLast, inclusive, from data source \n** pData. In other words, a loop like the following could be used to\n** construct a database with identical contents from scratch.\n**\n**   for(i=iFirst; i<=iLast; i++){\n**     testDatasourceEntry(pData, i, &pKey, &nKey, &pVal, &nVal);\n**     // insert (pKey, nKey) -> (pVal, nVal) into database\n**   }\n**\n** The key domain consists of keys 0 to (nRow-1), inclusive, from\n** data source pData. For both scan and lookup tests, keys are selected\n** pseudo-randomly from within this set.\n**\n** This function runs nLookupTest lookup tests and nScanTest scan tests.\n**\n** A lookup test consists of selecting a key from the domain and querying\n** pDb for it. The test fails if the presence of the key and, if present,\n** the associated value do not match the expectations defined above.\n**\n** A scan test involves selecting a key from the domain and running\n** the following queries:\n**\n**   1. Scan all keys equal to or greater than the key, in ascending order.\n**   2. Scan all keys equal to or smaller than the key, in descending order.\n**\n** Additionally, if nLookupTest is greater than zero, the following are\n** run once:\n**\n**   1. Scan all keys in the db, in ascending order.\n**   2. Scan all keys in the db, in descending order.\n**\n** As you would assume, the test fails if the returned values do not match\n** expectations.\n*/\nvoid testDbContents(\n  TestDb *pDb,                    /* Database handle being tested */\n  Datasource *pData,              /* pDb contains data from here */\n  int nRow,                       /* Size of key domain */\n  int iFirst,                     /* Index of first key from pData in pDb */\n  int iLast,                      /* Index of last key from pData in pDb */\n  int nLookupTest,                /* Number of lookup tests to run */\n  int nScanTest,                  /* Number of scan tests to run */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int j;\n  int rc = *pRc;\n\n  if( rc==0 && nScanTest ){\n    TestDb *pDb2 = 0;\n\n    /* Open a control db (i.e. one that we assume works) */\n    rc = testControlDb(&pDb2);\n\n    for(j=iFirst; rc==0 && j<=iLast; j++){\n      void *pKey; int nKey;         /* Database key to insert */\n      void *pVal; int nVal;         /* Database value to insert */\n      testDatasourceEntry(pData, j, &pKey, &nKey, &pVal, &nVal);\n      rc = tdb_write(pDb2, pKey, nKey, pVal, nVal);\n    }\n\n    if( rc==0 ){\n      int iKey1;\n      int iKey2;\n      void *pKey1; int nKey1;       /* Start key */\n      void *pKey2; int nKey2;       /* Final key */\n\n      iKey1 = testPrngValue((iFirst<<8) + (iLast<<16)) % nRow;\n      iKey2 = testPrngValue((iLast<<8) + (iFirst<<16)) % nRow;\n      testDatasourceEntry(pData, iKey1, &pKey2, &nKey1, 0, 0);\n      pKey1 = testMalloc(nKey1+1);\n      memcpy(pKey1, pKey2, nKey1+1);\n      testDatasourceEntry(pData, iKey2, &pKey2, &nKey2, 0, 0);\n\n      testScanCompare(pDb2, pDb, 0, 0, 0,         0, 0,         &rc);\n      testScanCompare(pDb2, pDb, 0, 0, 0,         pKey2, nKey2, &rc);\n      testScanCompare(pDb2, pDb, 0, pKey1, nKey1, 0, 0,         &rc);\n      testScanCompare(pDb2, pDb, 0, pKey1, nKey1, pKey2, nKey2, &rc);\n      testScanCompare(pDb2, pDb, 1, 0, 0,         0, 0,         &rc);\n      testScanCompare(pDb2, pDb, 1, 0, 0,         pKey2, nKey2, &rc);\n      testScanCompare(pDb2, pDb, 1, pKey1, nKey1, 0, 0,         &rc);\n      testScanCompare(pDb2, pDb, 1, pKey1, nKey1, pKey2, nKey2, &rc);\n      testFree(pKey1);\n    }\n    tdb_close(pDb2);\n  }\n\n  /* Test some lookups. */\n  for(j=0; rc==0 && j<nLookupTest; j++){\n    int iKey;                     /* Datasource key to test */\n    void *pKey; int nKey;         /* Database key to query for */\n    void *pVal; int nVal;         /* Expected result of query */\n\n    if( nLookupTest>=nRow ){\n      iKey = j;\n    }else{\n      iKey = testPrngValue(j + (iFirst<<8) + (iLast<<16)) % nRow;\n    }\n\n    testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);\n    if( iFirst>iKey || iKey>iLast ){\n      pVal = 0;\n      nVal = -1;\n    }\n\n    testFetch(pDb, pKey, nKey, pVal, nVal, &rc);\n  }\n\n  *pRc = rc;\n}\n\n/*\n** This function should be called during long running test cases to output\n** the progress dots (...) to stdout.\n*/\nvoid testCaseProgress(int i, int n, int nDot, int *piDot){\n  int iDot = *piDot;\n  while( iDot < ( ((nDot*2+1) * i) / (n*2) ) ){\n    printf(\".\");\n    fflush(stdout);\n    iDot++;\n  }\n  *piDot = iDot;\n}\n\nint testCaseNDot(void){ return 20; }\n\n#if 0\nstatic void printScanCb(\n    void *pCtx, void *pKey, int nKey, void *pVal, int nVal\n){\n  printf(\"%s\\n\", (char *)pKey);\n  fflush(stdout);\n}\n#endif\n\nvoid testReopenRecover(TestDb **ppDb, int *pRc){\n  if( *pRc==0 ){\n    const char *zLib = tdb_library_name(*ppDb);\n    const char *zDflt = tdb_default_db(zLib);\n    testCopyLsmdb(zDflt, \"bak.db\");\n    testClose(ppDb);\n    testCopyLsmdb(\"bak.db\", zDflt);\n    *pRc = tdb_open(zLib, 0, 0, ppDb);\n  }\n}\n\n\nstatic void doDataTest1(\n  const char *zSystem,            /* Database system to test */\n  int bRecover,\n  Datatest1 *p,                   /* Structure containing test parameters */\n  int *pRc                        /* OUT: Error code */\n){\n  int i;\n  int iDot;\n  int rc = LSM_OK;\n  Datasource *pData;\n  TestDb *pDb;\n\n  /* Start the test case, open a database and allocate the datasource. */\n  pDb = testOpen(zSystem, 1, &rc);\n  pData = testDatasourceNew(&p->defn);\n\n  i = 0;\n  iDot = 0;\n  while( rc==LSM_OK && i<p->nRow ){\n\n    /* Insert some data */\n    testWriteDatasourceRange(pDb, pData, i, p->nVerify, &rc);\n    i += p->nVerify;\n\n    /* Check that the db content is correct. */\n    testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);\n\n    if( bRecover ){\n      testReopenRecover(&pDb, &rc);\n    }else{\n      testReopen(&pDb, &rc);\n    }\n\n    /* Check that the db content is still correct. */\n    testDbContents(pDb, pData, p->nRow, 0, i-1, p->nTest, p->bTestScan, &rc);\n\n    /* Update the progress dots... */\n    testCaseProgress(i, p->nRow, testCaseNDot()/2, &iDot);\n  }\n\n  i = 0;\n  iDot = 0;\n  while( rc==LSM_OK && i<p->nRow ){\n\n    /* Delete some entries */\n    testDeleteDatasourceRange(pDb, pData, i, p->nVerify, &rc);\n    i += p->nVerify;\n\n    /* Check that the db content is correct. */\n    testDbContents(pDb, pData, p->nRow, i, p->nRow-1,p->nTest,p->bTestScan,&rc);\n\n    /* Close and reopen the database. */\n    if( bRecover ){\n      testReopenRecover(&pDb, &rc);\n    }else{\n      testReopen(&pDb, &rc);\n    }\n\n    /* Check that the db content is still correct. */\n    testDbContents(pDb, pData, p->nRow, i, p->nRow-1,p->nTest,p->bTestScan,&rc);\n\n    /* Update the progress dots... */\n    testCaseProgress(i, p->nRow, testCaseNDot()/2, &iDot);\n  }\n\n  /* Free the datasource, close the database and finish the test case. */\n  testDatasourceFree(pData);\n  tdb_close(pDb);\n  testCaseFinish(rc);\n  *pRc = rc;\n}\n\n\nvoid test_data_1(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Datatest1 aTest[] = {\n    { {DATA_RANDOM,     500,600,   1000,2000},     1000,  100,  10,  0},\n    { {DATA_RANDOM,     20,25,     100,200},       1000,  250, 1000, 1},\n    { {DATA_RANDOM,     8,10,      100,200},       1000,  250, 1000, 1},\n    { {DATA_RANDOM,     8,10,      10,20},         1000,  250, 1000, 1},\n    { {DATA_RANDOM,     8,10,      1000,2000},     1000,  250, 1000, 1},\n    { {DATA_RANDOM,     8,100,     10000,20000},    100,   25,  100, 1},\n    { {DATA_RANDOM,     80,100,    10,20},         1000,  250, 1000, 1},\n    { {DATA_RANDOM,     5000,6000, 10,20},          100,   25,  100, 1},\n    { {DATA_SEQUENTIAL, 5,10,      10,20},         1000,  250, 1000, 1},\n    { {DATA_SEQUENTIAL, 5,10,      100,200},       1000,  250, 1000, 1},\n    { {DATA_SEQUENTIAL, 5,10,      1000,2000},     1000,  250, 1000, 1},\n    { {DATA_SEQUENTIAL, 5,100,     10000,20000},    100,   25,  100, 1},\n    { {DATA_RANDOM,     10,10,     100,100},     100000, 1000,  100, 0},\n    { {DATA_SEQUENTIAL, 10,10,     100,100},     100000, 1000,  100, 0},\n  };\n\n  int i;\n  int bRecover;\n\n  for(bRecover=0; bRecover<2; bRecover++){\n    if( bRecover==1 && memcmp(zSystem, \"lsm\", 3) ) break;\n    for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){\n      char *zName = getName(zSystem, bRecover, &aTest[i]);\n      if( testCaseBegin(pRc, zPattern, \"%s\", zName) ){\n        doDataTest1(zSystem, bRecover, &aTest[i], pRc);\n      }\n      testFree(zName);\n    }\n  }\n}\n\nvoid testCompareDb(\n  Datasource *pData,\n  int nData,\n  int iSeed,\n  TestDb *pControl,\n  TestDb *pDb,\n  int *pRc\n){\n  int i;\n\n  static int nCall = 0;\n  nCall++;\n\n  testScanCompare(pControl, pDb, 0, 0, 0,         0, 0,         pRc);\n  testScanCompare(pControl, pDb, 1, 0, 0,         0, 0,         pRc);\n\n  if( *pRc==0 ){\n    int iKey1;\n    int iKey2;\n    void *pKey1; int nKey1;       /* Start key */\n    void *pKey2; int nKey2;       /* Final key */\n\n    iKey1 = testPrngValue(iSeed) % nData;\n    iKey2 = testPrngValue(iSeed+1) % nData;\n    testDatasourceEntry(pData, iKey1, &pKey2, &nKey1, 0, 0);\n    pKey1 = testMalloc(nKey1+1);\n    memcpy(pKey1, pKey2, nKey1+1);\n    testDatasourceEntry(pData, iKey2, &pKey2, &nKey2, 0, 0);\n\n    testScanCompare(pControl, pDb, 0, 0, 0,         pKey2, nKey2, pRc);\n    testScanCompare(pControl, pDb, 0, pKey1, nKey1, 0, 0,         pRc);\n    testScanCompare(pControl, pDb, 0, pKey1, nKey1, pKey2, nKey2, pRc);\n    testScanCompare(pControl, pDb, 1, 0, 0,         pKey2, nKey2, pRc);\n    testScanCompare(pControl, pDb, 1, pKey1, nKey1, 0, 0,         pRc);\n    testScanCompare(pControl, pDb, 1, pKey1, nKey1, pKey2, nKey2, pRc);\n    testFree(pKey1);\n  }\n\n  for(i=0; i<nData && *pRc==0; i++){\n    void *pKey; int nKey;\n    testDatasourceEntry(pData, i, &pKey, &nKey, 0, 0);\n    testFetchCompare(pControl, pDb, pKey, nKey, pRc);\n  }\n}\n\nstatic void doDataTest2(\n  const char *zSystem,            /* Database system to test */\n  int bRecover,\n  Datatest2 *p,                   /* Structure containing test parameters */\n  int *pRc                        /* OUT: Error code */\n){\n  TestDb *pDb;\n  TestDb *pControl;\n  Datasource *pData;\n  int i;\n  int rc = LSM_OK;\n  int iDot = 0;\n\n  /* Start the test case, open a database and allocate the datasource. */\n  pDb = testOpen(zSystem, 1, &rc);\n  pData = testDatasourceNew(&p->defn);\n  rc = testControlDb(&pControl);\n\n  if( tdb_lsm(pDb) ){\n    int nBuf = 32 * 1024 * 1024;\n    lsm_config(tdb_lsm(pDb), LSM_CONFIG_AUTOFLUSH, &nBuf);\n  }\n\n  for(i=0; rc==0 && i<p->nIter; i++){\n    void *pKey1; int nKey1;\n    void *pKey2; int nKey2;\n    int ii;\n    int nRange = MIN(p->nIter*p->nWrite, p->nRange);\n\n    for(ii=0; rc==0 && ii<p->nWrite; ii++){\n      int iKey = (i*p->nWrite + ii) % p->nRange;\n      testWriteDatasource(pControl, pData, iKey, &rc);\n      testWriteDatasource(pDb, pData, iKey, &rc);\n    }\n\n    testDatasourceEntry(pData, i+1000000, &pKey1, &nKey1, 0, 0);\n    pKey1 = testMallocCopy(pKey1, nKey1);\n    testDatasourceEntry(pData, i+2000000, &pKey2, &nKey2, 0, 0);\n\n    testDeleteRange(pDb, pKey1, nKey1, pKey2, nKey2, &rc);\n    testDeleteRange(pControl, pKey1, nKey1, pKey2, nKey2, &rc);\n    testFree(pKey1);\n\n    testCompareDb(pData, nRange, i, pControl, pDb, &rc);\n    if( bRecover ){\n      testReopenRecover(&pDb, &rc);\n    }else{\n      testReopen(&pDb, &rc);\n    }\n    testCompareDb(pData, nRange, i, pControl, pDb, &rc);\n\n    /* Update the progress dots... */\n    testCaseProgress(i, p->nIter, testCaseNDot(), &iDot);\n  }\n\n  testClose(&pDb);\n  testClose(&pControl);\n  testDatasourceFree(pData);\n  testCaseFinish(rc);\n  *pRc = rc;\n}\n\nstatic char *getName2(const char *zSystem, int bRecover, Datatest2 *pTest){\n  char *zRet;\n  char *zData;\n  zData = testDatasourceName(&pTest->defn);\n  zRet = testMallocPrintf(\"data2.%s.%s.rec=%d.%d.%d.%d\", \n      zSystem, zData, bRecover, pTest->nRange, pTest->nWrite, pTest->nIter\n  );\n  testFree(zData);\n  return zRet;\n}\n\nvoid test_data_2(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Datatest2 aTest[] = {\n      /* defn,                                 nRange, nWrite, nIter */\n    { {DATA_RANDOM,     20,25,     100,200},   10000,  10,     50   },\n    { {DATA_RANDOM,     20,25,     100,200},   10000,  200,    50   },\n    { {DATA_RANDOM,     20,25,     100,200},   100,    10,     1000 },\n    { {DATA_RANDOM,     20,25,     100,200},   100,    200,    50   },\n  };\n\n  int i;\n  int bRecover;\n\n  for(bRecover=0; bRecover<2; bRecover++){\n    if( bRecover==1 && memcmp(zSystem, \"lsm\", 3) ) break;\n    for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){\n      char *zName = getName2(zSystem, bRecover, &aTest[i]);\n      if( testCaseBegin(pRc, zPattern, \"%s\", zName) ){\n        doDataTest2(zSystem, bRecover, &aTest[i], pRc);\n      }\n      testFree(zName);\n    }\n  }\n}\n\n/*************************************************************************\n** Test case data3.*\n*/\n\ntypedef struct Datatest3 Datatest3;\nstruct Datatest3 {\n  int nRange;                     /* Keys are between 1 and this value, incl. */\n  int nIter;                      /* Number of iterations */\n  int nWrite;                     /* Number of writes per iteration */\n  int nDelete;                    /* Number of deletes per iteration */\n\n  int nValMin;                    /* Minimum value size for writes */\n  int nValMax;                    /* Maximum value size for writes */\n};\n\nvoid testPutU32(u8 *aBuf, u32 iVal){\n  aBuf[0] = (iVal >> 24) & 0xFF;\n  aBuf[1] = (iVal >> 16) & 0xFF;\n  aBuf[2] = (iVal >>  8) & 0xFF;\n  aBuf[3] = (iVal >>  0) & 0xFF;\n}\n\nvoid dt3PutKey(u8 *aBuf, int iKey){\n  assert( iKey<100000 && iKey>=0 );\n  sprintf((char *)aBuf, \"%.5d\", iKey);\n}\n\nstatic void doDataTest3(\n  const char *zSystem,            /* Database system to test */\n  Datatest3 *p,                   /* Structure containing test parameters */\n  int *pRc                        /* OUT: Error code */\n){\n  int iDot = 0;\n  int rc = *pRc;\n  TestDb *pDb;\n  u8 *abPresent;                  /* Array of boolean */\n  char *aVal;                     /* Buffer to hold values */\n  int i;\n  u32 iSeq = 10;                  /* prng counter */\n\n  abPresent = (u8 *)testMalloc(p->nRange+1);\n  aVal = (char *)testMalloc(p->nValMax+1);\n  pDb = testOpen(zSystem, 1, &rc);\n\n  for(i=0; i<p->nIter && rc==0; i++){\n    int ii;\n\n    testCaseProgress(i, p->nIter, testCaseNDot(), &iDot);\n\n    /* Perform nWrite inserts */\n    for(ii=0; ii<p->nWrite; ii++){\n      u8 aKey[6];\n      u32 iKey;\n      int nVal;\n\n      iKey = (testPrngValue(iSeq++) % p->nRange) + 1;\n      nVal = (testPrngValue(iSeq++) % (p->nValMax - p->nValMin)) + p->nValMin;\n      testPrngString(testPrngValue(iSeq++), aVal, nVal);\n      dt3PutKey(aKey, iKey);\n\n      testWrite(pDb, aKey, sizeof(aKey)-1, aVal, nVal, &rc);\n      abPresent[iKey] = 1;\n    }\n\n    /* Perform nDelete deletes */\n    for(ii=0; ii<p->nDelete; ii++){\n      u8 aKey1[6];\n      u8 aKey2[6];\n      u32 iKey;\n\n      iKey = (testPrngValue(iSeq++) % p->nRange) + 1;\n      dt3PutKey(aKey1, iKey-1);\n      dt3PutKey(aKey2, iKey+1);\n\n      testDeleteRange(pDb, aKey1, sizeof(aKey1)-1, aKey2, sizeof(aKey2)-1, &rc);\n      abPresent[iKey] = 0;\n    }\n\n    testReopen(&pDb, &rc);\n\n    for(ii=1; rc==0 && ii<=p->nRange; ii++){\n      int nDbVal;\n      void *pDbVal;\n      u8 aKey[6];\n      int dbrc;\n\n      dt3PutKey(aKey, ii);\n      dbrc = tdb_fetch(pDb, aKey, sizeof(aKey)-1, &pDbVal, &nDbVal);\n      testCompareInt(0, dbrc, &rc);\n\n      if( abPresent[ii] ){\n        testCompareInt(1, (nDbVal>0), &rc);\n      }else{\n        testCompareInt(1, (nDbVal<0), &rc);\n      }\n    }\n  }\n\n  testClose(&pDb);\n  testCaseFinish(rc);\n  *pRc = rc;\n}\n\nstatic char *getName3(const char *zSystem, Datatest3 *p){\n  return testMallocPrintf(\"data3.%s.%d.%d.%d.%d.(%d..%d)\",\n      zSystem, p->nRange, p->nIter, p->nWrite, p->nDelete, \n      p->nValMin, p->nValMax\n  );\n}\n\nvoid test_data_3(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Datatest3 aTest[] = {\n    /* nRange, nIter, nWrite, nDelete, nValMin, nValMax */\n    {  100,    1000,  5,      5,       50,      100 },\n    {  100,    1000,  2,      2,        5,       10 },\n  };\n\n  int i;\n\n  for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){\n    char *zName = getName3(zSystem, &aTest[i]);\n    if( testCaseBegin(pRc, zPattern, \"%s\", zName) ){\n      doDataTest3(zSystem, &aTest[i], pRc);\n    }\n    testFree(zName);\n  }\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest2.c",
    "content": "\n/*\n** This file contains tests related to recovery following application \n** and system crashes (power failures) while writing to the database.\n*/\n\n#include \"lsmtest.h\"\n\n/*\n** Structure used by testCksumDatabase() to accumulate checksum values in.\n*/\ntypedef struct Cksum Cksum;\nstruct Cksum {\n  int nRow;\n  int cksum1;\n  int cksum2;\n};\n\n/*\n** tdb_scan() callback used by testCksumDatabase()\n*/\nstatic void scanCksumDb(\n  void *pCtx, \n  void *pKey, int nKey,\n  void *pVal, int nVal\n){\n  Cksum *p = (Cksum *)pCtx;\n  int i;\n\n  p->nRow++;\n  for(i=0; i<nKey; i++){\n    p->cksum1 += ((u8 *)pKey)[i];\n    p->cksum2 += p->cksum1;\n  }\n  for(i=0; i<nVal; i++){\n    p->cksum1 += ((u8 *)pVal)[i];\n    p->cksum2 += p->cksum1;\n  }\n}\n\n/*\n** tdb_scan() callback used by testCountDatabase()\n*/\nstatic void scanCountDb(\n  void *pCtx, \n  void *pKey, int nKey,\n  void *pVal, int nVal\n){\n  Cksum *p = (Cksum *)pCtx;\n  p->nRow++;\n\n  unused_parameter(pKey);\n  unused_parameter(nKey);\n  unused_parameter(pVal);\n  unused_parameter(nVal);\n}\n\n\n/*\n** Iterate through the entire contents of database pDb. Write a checksum\n** string based on the db contents into buffer zOut before returning. A\n** checksum string is at most 29 (TEST_CKSUM_BYTES) bytes in size:\n**\n**    * 32-bit integer (10 bytes)\n**    * 1 space        (1 byte)\n**    * 32-bit hex     (8 bytes)\n**    * 1 space        (1 byte)\n**    * 32-bit hex     (8 bytes)\n**    * nul-terminator (1 byte)\n**\n** The number of entries in the database is returned.\n*/\nint testCksumDatabase(\n  TestDb *pDb,                    /* Database handle */\n  char *zOut                      /* Buffer to write checksum to */\n){\n  Cksum cksum;\n  memset(&cksum, 0, sizeof(Cksum));\n  tdb_scan(pDb, (void *)&cksum, 0, 0, 0, 0, 0, scanCksumDb);\n  sprintf(zOut, \"%d %x %x\", \n      cksum.nRow, (u32)cksum.cksum1, (u32)cksum.cksum2\n  );\n  assert( strlen(zOut)<TEST_CKSUM_BYTES );\n  return cksum.nRow;\n}\n\nint testCountDatabase(TestDb *pDb){\n  Cksum cksum;\n  memset(&cksum, 0, sizeof(Cksum));\n  tdb_scan(pDb, (void *)&cksum, 0, 0, 0, 0, 0, scanCountDb);\n  return cksum.nRow;\n}\n\n/*\n** This function is a no-op if *pRc is not 0 when it is called.\n**\n** Otherwise, the two nul-terminated strings z1 and z1 are compared. If\n** they are the same, the function returns without doing anything. Otherwise,\n** an error message is printed, *pRc is set to 1 and the test_failed()\n** function called.\n*/\nvoid testCompareStr(const char *z1, const char *z2, int *pRc){\n  if( *pRc==0 ){\n    if( strcmp(z1, z2) ){\n      testPrintError(\"testCompareStr: \\\"%s\\\" != \\\"%s\\\"\\n\", z1, z2);\n      *pRc = 1;\n      test_failed();\n    }\n  }\n}\n\n/*\n** This function is a no-op if *pRc is not 0 when it is called.\n**\n** Otherwise, the two integers i1 and i2 are compared. If they are equal,\n** the function returns without doing anything. Otherwise, an error message \n** is printed, *pRc is set to 1 and the test_failed() function called.\n*/\nvoid testCompareInt(int i1, int i2, int *pRc){\n  if( *pRc==0 && i1!=i2 ){\n    testPrintError(\"testCompareInt: %d != %d\\n\", i1, i2);\n    *pRc = 1;\n    test_failed();\n  }\n}\n\nvoid testCaseStart(int *pRc, char *zFmt, ...){\n  va_list ap;\n  va_start(ap, zFmt);\n  vprintf(zFmt, ap);\n  printf(\" ...\");\n  va_end(ap);\n  *pRc = 0;\n  fflush(stdout);\n}\n\n/*\n** This function is a no-op if *pRc is non-zero when it is called. Zero\n** is returned in this case.\n**\n** Otherwise, the zFmt (a printf style format string) and following arguments \n** are used to create a test case name. If zPattern is NULL or a glob pattern\n** that matches the test case name, 1 is returned and the test case started.\n** Otherwise, zero is returned and the test case does not start.\n*/\nint testCaseBegin(int *pRc, const char *zPattern, const char *zFmt, ...){\n  int res = 0;\n  if( *pRc==0 ){\n    char *zTest;\n    va_list ap;\n\n    va_start(ap, zFmt);\n    zTest = testMallocVPrintf(zFmt, ap);\n    va_end(ap);\n    if( zPattern==0 || testGlobMatch(zPattern, zTest) ){\n      printf(\"%-50s ...\", zTest);\n      res = 1;\n    }\n    testFree(zTest);\n    fflush(stdout);\n  }\n\n  return res;\n}\n\nvoid testCaseFinish(int rc){\n  if( rc==0 ){\n    printf(\"Ok\\n\");\n  }else{\n    printf(\"FAILED\\n\");\n  }\n  fflush(stdout);\n}\n\nvoid testCaseSkip(){\n  printf(\"Skipped\\n\");\n}\n\nvoid testSetupSavedLsmdb(\n  const char *zCfg,\n  const char *zFile,\n  Datasource *pData,\n  int nRow,\n  int *pRc\n){\n  if( *pRc==0 ){\n    int rc;\n    TestDb *pDb;\n    rc = tdb_lsm_open(zCfg, zFile, 1, &pDb);\n    if( rc==0 ){\n      testWriteDatasourceRange(pDb, pData, 0, nRow, &rc);\n      testClose(&pDb);\n      if( rc==0 ) testSaveDb(zFile, \"log\");\n    }\n    *pRc = rc;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is non-zero when it is called.\n**\n** Open the LSM database identified by zFile and compute its checksum\n** (a string, as returned by testCksumDatabase()). If the checksum is\n** identical to zExpect1 or, if it is not NULL, zExpect2, the test passes.\n** Otherwise, print an error message and set *pRc to 1.\n*/\nstatic void testCompareCksumLsmdb(\n  const char *zFile,              /* Path to LSM database */\n  int bCompress,                  /* True if db is compressed */\n  const char *zExpect1,           /* Expected checksum 1 */\n  const char *zExpect2,           /* Expected checksum 2 (or NULL) */\n  int *pRc                        /* IN/OUT: Test case error code */\n){\n  if( *pRc==0 ){\n    char zCksum[TEST_CKSUM_BYTES];\n    TestDb *pDb;\n\n    *pRc = tdb_lsm_open((bCompress?\"compression=1 mmap=0\":\"\"), zFile, 0, &pDb);\n    testCksumDatabase(pDb, zCksum);\n    testClose(&pDb);\n\n    if( *pRc==0 ){\n      int r1 = 0;\n      int r2 = -1;\n\n      r1 = strcmp(zCksum, zExpect1);\n      if( zExpect2 ) r2 = strcmp(zCksum, zExpect2);\n      if( r1 && r2 ){\n        if( zExpect2 ){\n          testPrintError(\"testCompareCksumLsmdb: \\\"%s\\\" != (\\\"%s\\\" OR \\\"%s\\\")\",\n              zCksum, zExpect1, zExpect2\n          );\n        }else{\n          testPrintError(\"testCompareCksumLsmdb: \\\"%s\\\" != \\\"%s\\\"\",\n              zCksum, zExpect1\n          );\n        }\n        *pRc = 1;\n        test_failed();\n      }\n    }\n  }\n}\n\n#if 0 /* not used */\nstatic void testCompareCksumBtdb(\n  const char *zFile,              /* Path to LSM database */\n  const char *zExpect1,           /* Expected checksum 1 */\n  const char *zExpect2,           /* Expected checksum 2 (or NULL) */\n  int *pRc                        /* IN/OUT: Test case error code */\n){\n  if( *pRc==0 ){\n    char zCksum[TEST_CKSUM_BYTES];\n    TestDb *pDb;\n\n    *pRc = tdb_open(\"bt\", zFile, 0, &pDb);\n    testCksumDatabase(pDb, zCksum);\n    testClose(&pDb);\n\n    if( *pRc==0 ){\n      int r1 = 0;\n      int r2 = -1;\n\n      r1 = strcmp(zCksum, zExpect1);\n      if( zExpect2 ) r2 = strcmp(zCksum, zExpect2);\n      if( r1 && r2 ){\n        if( zExpect2 ){\n          testPrintError(\"testCompareCksumLsmdb: \\\"%s\\\" != (\\\"%s\\\" OR \\\"%s\\\")\",\n              zCksum, zExpect1, zExpect2\n          );\n        }else{\n          testPrintError(\"testCompareCksumLsmdb: \\\"%s\\\" != \\\"%s\\\"\",\n              zCksum, zExpect1\n          );\n        }\n        *pRc = 1;\n        test_failed();\n      }\n    }\n  }\n}\n#endif /* not used */\n\n/* Above this point are reusable test routines. Not clear that they\n** should really be in this file.\n*************************************************************************/\n\n/*\n** This test verifies that if a system crash occurs while doing merge work\n** on the db, no data is lost.\n*/\nstatic void crash_test1(int bCompress, int *pRc){\n  const char *DBNAME = \"testdb.lsm\";\n  const DatasourceDefn defn = {TEST_DATASOURCE_RANDOM, 12, 16, 200, 200};\n\n  const int nRow = 5000;          /* Database size */\n  const int nIter = 200;          /* Number of test iterations */\n  const int nWork = 20;           /* Maximum lsm_work() calls per iteration */\n  const int nPage = 15;           /* Pages per lsm_work call */\n\n  int i;\n  int iDot = 0;\n  Datasource *pData;\n  CksumDb *pCksumDb;\n  TestDb *pDb;\n  char *zCfg;\n\n  const char *azConfig[2] = {\n    \"page_size=1024 block_size=65536 autoflush=16384 safety=2 mmap=0\", \n    \"page_size=1024 block_size=65536 autoflush=16384 safety=2 \"\n    \" compression=1 mmap=0\"\n  };\n  assert( bCompress==0 || bCompress==1 );\n\n  /* Allocate datasource. And calculate the expected checksums. */\n  pData = testDatasourceNew(&defn);\n  pCksumDb = testCksumArrayNew(pData, nRow, nRow, 1);\n\n  /* Setup and save the initial database. */\n\n  zCfg = testMallocPrintf(\"%s automerge=7\", azConfig[bCompress]);\n  testSetupSavedLsmdb(zCfg, DBNAME, pData, 5000, pRc);\n  testFree(zCfg);\n\n  for(i=0; i<nIter && *pRc==0; i++){\n    int iWork;\n    int testrc = 0;\n\n    testCaseProgress(i, nIter, testCaseNDot(), &iDot);\n\n    /* Restore and open the database. */\n    testRestoreDb(DBNAME, \"log\");\n    testrc = tdb_lsm_open(azConfig[bCompress], DBNAME, 0, &pDb);\n    assert( testrc==0 );\n\n    /* Call lsm_work() on the db */\n    tdb_lsm_prepare_sync_crash(pDb, 1 + (i%(nWork*2)));\n    for(iWork=0; testrc==0 && iWork<nWork; iWork++){\n      int nWrite = 0;\n      lsm_db *db = tdb_lsm(pDb);\n      testrc = lsm_work(db, 0, nPage, &nWrite);\n      /* assert( testrc!=0 || nWrite>0 ); */\n      if( testrc==0 ) testrc = lsm_checkpoint(db, 0);\n    }\n    tdb_close(pDb);\n\n    /* Check that the database content is still correct */\n    testCompareCksumLsmdb(DBNAME, \n        bCompress, testCksumArrayGet(pCksumDb, nRow), 0, pRc);\n  }\n\n  testCksumArrayFree(pCksumDb);\n  testDatasourceFree(pData);\n}\n\n/*\n** This test verifies that if a system crash occurs while committing a\n** transaction to the log file, no earlier transactions are lost or damaged.\n*/\nstatic void crash_test2(int bCompress, int *pRc){\n  const char *DBNAME = \"testdb.lsm\";\n  const DatasourceDefn defn = {TEST_DATASOURCE_RANDOM, 12, 16, 1000, 1000};\n\n  const int nIter = 200;\n  const int nInsert = 20;\n\n  int i;\n  int iDot = 0;\n  Datasource *pData;\n  CksumDb *pCksumDb;\n  TestDb *pDb;\n\n  /* Allocate datasource. And calculate the expected checksums. */\n  pData = testDatasourceNew(&defn);\n  pCksumDb = testCksumArrayNew(pData, 100, 100+nInsert, 1);\n\n  /* Setup and save the initial database. */\n  testSetupSavedLsmdb(\"\", DBNAME, pData, 100, pRc);\n\n  for(i=0; i<nIter && *pRc==0; i++){\n    int iIns;\n    int testrc = 0;\n\n    testCaseProgress(i, nIter, testCaseNDot(), &iDot);\n\n    /* Restore and open the database. */\n    testRestoreDb(DBNAME, \"log\");\n    testrc = tdb_lsm_open(\"safety=2\", DBNAME, 0, &pDb);\n    assert( testrc==0 );\n\n    /* Insert nInsert records into the database. Crash midway through. */\n    tdb_lsm_prepare_sync_crash(pDb, 1 + (i%(nInsert+2)));\n    for(iIns=0; iIns<nInsert; iIns++){\n      void *pKey; int nKey;\n      void *pVal; int nVal;\n\n      testDatasourceEntry(pData, 100+iIns, &pKey, &nKey, &pVal, &nVal);\n      testrc = tdb_write(pDb, pKey, nKey, pVal, nVal);\n      if( testrc ) break;\n    }\n    tdb_close(pDb);\n\n    /* Check that no data was lost when the system crashed. */\n    testCompareCksumLsmdb(DBNAME, bCompress,\n      testCksumArrayGet(pCksumDb, 100 + iIns),\n      testCksumArrayGet(pCksumDb, 100 + iIns + 1),\n      pRc\n    );\n  }\n\n  testDatasourceFree(pData);\n  testCksumArrayFree(pCksumDb);\n}\n\n\n/*\n** This test verifies that if a system crash occurs when checkpointing\n** the database, data is not lost (assuming that any writes not synced\n** to the db have been synced into the log file).\n*/\nstatic void crash_test3(int bCompress, int *pRc){\n  const char *DBNAME = \"testdb.lsm\";\n  const int nIter = 100;\n  const DatasourceDefn defn = {TEST_DATASOURCE_RANDOM, 12, 16, 1000, 1000};\n\n  int i;\n  int iDot = 0;\n  Datasource *pData;\n  CksumDb *pCksumDb;\n  TestDb *pDb;\n\n  /* Allocate datasource. And calculate the expected checksums. */\n  pData = testDatasourceNew(&defn);\n  pCksumDb = testCksumArrayNew(pData, 110, 150, 10);\n\n  /* Setup and save the initial database. */\n  testSetupSavedLsmdb(\"\", DBNAME, pData, 100, pRc);\n\n  for(i=0; i<nIter && *pRc==0; i++){\n    int iOpen;\n    testCaseProgress(i, nIter, testCaseNDot(), &iDot);\n    testRestoreDb(DBNAME, \"log\");\n\n    for(iOpen=0; iOpen<5; iOpen++){\n      /* Open the database. Insert 10 more records. */\n      pDb = testOpen(\"lsm\", 0, pRc);\n      testWriteDatasourceRange(pDb, pData, 100+iOpen*10, 10, pRc);\n\n      /* Schedule a crash simulation then close the db. */\n      tdb_lsm_prepare_sync_crash(pDb, 1 + (i%2));\n      tdb_close(pDb);\n\n      /* Open the database and check that the crash did not cause any\n      ** data loss.  */\n      testCompareCksumLsmdb(DBNAME, bCompress,\n        testCksumArrayGet(pCksumDb, 110 + iOpen*10), 0,\n        pRc\n      );\n    }\n  }\n\n  testDatasourceFree(pData);\n  testCksumArrayFree(pCksumDb);\n}\n\nvoid do_crash_test(const char *zPattern, int *pRc){\n  struct Test {\n    const char *zTest;\n    void (*x)(int, int *);\n    int bCompress;\n  } aTest [] = {\n    { \"crash.lsm.1\",     crash_test1, 0 },\n#ifdef HAVE_ZLIB\n    { \"crash.lsm_zip.1\", crash_test1, 1 },\n#endif\n    { \"crash.lsm.2\",     crash_test2, 0 },\n    { \"crash.lsm.3\",     crash_test3, 0 },\n  };\n  int i;\n\n  for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){\n    struct Test *p = &aTest[i];\n    if( testCaseBegin(pRc, zPattern, \"%s\", p->zTest) ){\n      p->x(p->bCompress, pRc);\n      testCaseFinish(*pRc);\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest3.c",
    "content": "\n\n/*\n** This file contains tests related to the explicit rollback of database\n** transactions and sub-transactions.\n*/\n\n\n/*\n** Repeat 2000 times (until the db contains 100,000 entries):\n**\n**   1. Open a transaction and insert 500 rows, opening a nested \n**      sub-transaction each 100 rows.\n**\n**   2. Roll back to each sub-transaction savepoint. Check the database\n**      checksum looks Ok.\n**\n**   3. Every second iteration, roll back the main transaction. Check the\n**      db checksum is correct. Every other iteration, commit the main\n**      transaction (increasing the size of the db by 100 rows).\n*/\n\n\n#include \"lsmtest.h\"\n\nstruct CksumDb {\n  int nFirst;\n  int nLast;\n  int nStep;\n  char **azCksum;\n};\n\nCksumDb *testCksumArrayNew(\n  Datasource *pData, \n  int nFirst, \n  int nLast, \n  int nStep\n){\n  TestDb *pDb;\n  CksumDb *pRet;\n  int i;\n  int nEntry;\n  int rc = 0;\n\n  assert( nLast>=nFirst && ((nLast-nFirst)%nStep)==0 );\n \n  pRet = malloc(sizeof(CksumDb));\n  memset(pRet, 0, sizeof(CksumDb));\n  pRet->nFirst = nFirst;\n  pRet->nLast = nLast;\n  pRet->nStep = nStep;\n  nEntry = 1 + ((nLast - nFirst) / nStep);\n\n  /* Allocate space so that azCksum is an array of nEntry pointers to\n  ** buffers each TEST_CKSUM_BYTES in size.  */\n  pRet->azCksum = (char **)malloc(nEntry * (sizeof(char *) + TEST_CKSUM_BYTES));\n  for(i=0; i<nEntry; i++){\n    char *pStart = (char *)(&pRet->azCksum[nEntry]);\n    pRet->azCksum[i] = &pStart[i * TEST_CKSUM_BYTES];\n  }\n\n  tdb_open(\"lsm\", \"tempdb.lsm\", 1, &pDb);\n  testWriteDatasourceRange(pDb, pData, 0, nFirst, &rc);\n  for(i=0; i<nEntry; i++){\n    testCksumDatabase(pDb, pRet->azCksum[i]);\n    if( i==nEntry ) break;\n    testWriteDatasourceRange(pDb, pData, nFirst+i*nStep, nStep, &rc);\n  }\n\n  tdb_close(pDb);\n\n  return pRet;\n}\n\nchar *testCksumArrayGet(CksumDb *p, int nRow){\n  int i;\n  assert( nRow>=p->nFirst );\n  assert( nRow<=p->nLast );\n  assert( ((nRow-p->nFirst) % p->nStep)==0 );\n\n  i = (nRow - p->nFirst) / p->nStep;\n  return p->azCksum[i];\n}\n\nvoid testCksumArrayFree(CksumDb *p){\n  free(p->azCksum);\n  memset(p, 0x55, sizeof(*p));\n  free(p);\n}\n\n/* End of CksumDb code.\n**************************************************************************/\n\n/*\n** Test utility function. Write key-value pair $i from datasource pData \n** into database pDb.\n*/\nvoid testWriteDatasource(TestDb *pDb, Datasource *pData, int i, int *pRc){\n  void *pKey; int nKey;\n  void *pVal; int nVal;\n  testDatasourceEntry(pData, i, &pKey, &nKey, &pVal, &nVal);\n  testWrite(pDb, pKey, nKey, pVal, nVal, pRc);\n}\n\n/*\n** Test utility function. Delete datasource pData key $i from database pDb.\n*/\nvoid testDeleteDatasource(TestDb *pDb, Datasource *pData, int i, int *pRc){\n  void *pKey; int nKey;\n  testDatasourceEntry(pData, i, &pKey, &nKey, 0, 0);\n  testDelete(pDb, pKey, nKey, pRc);\n}\n\n/*\n** This function inserts nWrite key/value pairs into database pDb - the\n** nWrite key value pairs starting at iFirst from data source pData.\n*/\nvoid testWriteDatasourceRange(\n  TestDb *pDb,                    /* Database to write to */\n  Datasource *pData,              /* Data source to read values from */\n  int iFirst,                     /* Index of first key/value pair */\n  int nWrite,                     /* Number of key/value pairs to write */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;\n  for(i=0; i<nWrite; i++){\n    testWriteDatasource(pDb, pData, iFirst+i, pRc);\n  }\n}\n\nvoid testDeleteDatasourceRange(\n  TestDb *pDb,                    /* Database to write to */\n  Datasource *pData,              /* Data source to read keys from */\n  int iFirst,                     /* Index of first key */\n  int nWrite,                     /* Number of keys to delete */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;\n  for(i=0; i<nWrite; i++){\n    testDeleteDatasource(pDb, pData, iFirst+i, pRc);\n  }\n}\n\nstatic char *getName(const char *zSystem){ \n  char *zRet; \n  zRet = testMallocPrintf(\"rollback.%s\", zSystem);\n  return zRet;\n}\n\nstatic int rollback_test_1(\n  const char *zSystem,\n  Datasource *pData\n){\n  const int nRepeat = 100;\n\n  TestDb *pDb;\n  int rc;\n  int i;\n  CksumDb *pCksum;\n  char *zName;\n\n  zName = getName(zSystem);\n  testCaseStart(&rc, zName);\n  testFree(zName);\n\n  pCksum = testCksumArrayNew(pData, 0, nRepeat*100, 100);\n  pDb = 0;\n  rc = tdb_open(zSystem, 0, 1, &pDb);\n  if( pDb && tdb_transaction_support(pDb)==0 ){\n    testCaseSkip();\n    goto skip_rollback_test;\n  }\n\n  for(i=0; i<nRepeat && rc==0; i++){\n    char zCksum[TEST_CKSUM_BYTES];\n    int nCurrent = (((i+1)/2) * 100);\n    int nDbRow;\n    int iTrans;\n\n    /* Check that the database is the expected size. */\n    nDbRow = testCountDatabase(pDb);\n    testCompareInt(nCurrent, nDbRow, &rc);\n\n    for(iTrans=2; iTrans<=6 && rc==0; iTrans++){\n      tdb_begin(pDb, iTrans);\n      testWriteDatasourceRange(pDb, pData, nCurrent, 100, &rc);\n      nCurrent += 100;\n    }\n\n    testCksumDatabase(pDb, zCksum);\n    testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);\n\n    for(iTrans=6; iTrans>2 && rc==0; iTrans--){\n      tdb_rollback(pDb, iTrans);\n      nCurrent -= 100;\n      testCksumDatabase(pDb, zCksum);\n      testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);\n    }\n\n    if( i%2 ){\n      tdb_rollback(pDb, 0);\n      nCurrent -= 100;\n      testCksumDatabase(pDb, zCksum);\n      testCompareStr(zCksum, testCksumArrayGet(pCksum, nCurrent), &rc);\n    }else{\n      tdb_commit(pDb, 0);\n    }\n  }\n  testCaseFinish(rc);\n\n skip_rollback_test:\n  tdb_close(pDb);\n  testCksumArrayFree(pCksum);\n  return rc;\n}\n\nvoid test_rollback(\n  const char *zSystem, \n  const char *zPattern, \n  int *pRc\n){\n  if( *pRc==0 ){\n    int bRun = 1;\n\n    if( zPattern ){\n      char *zName = getName(zSystem);\n      bRun = testGlobMatch(zPattern, zName);\n      testFree(zName);\n    }\n\n    if( bRun ){\n      DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 10, 15, 50, 100 };\n      Datasource *pData = testDatasourceNew(&defn);\n      *pRc = rollback_test_1(zSystem, pData);\n      testDatasourceFree(pData);\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest4.c",
    "content": "\n/*\n** This file contains test cases involving multiple database clients.\n*/\n\n#include \"lsmtest.h\"\n\n/*\n** The following code implements test cases \"mc1.*\".\n**\n** This test case uses one writer and $nReader readers. All connections\n** are driven by a single thread. All connections are opened at the start\n** of the test and remain open until the test is finished.\n**\n** The test consists of $nStep steps. Each step the following is performed:\n**\n**   1. The writer inserts $nWriteStep records into the db.\n**\n**   2. The writer checks that the contents of the db are as expected.\n**\n**   3. Each reader that currently has an open read transaction also checks\n**      that the contents of the db are as expected (according to the snapshot\n**      the read transaction is reading - see below).\n**\n** After step 1, reader 1 opens a read transaction. After step 2, reader\n** 2 opens a read transaction, and so on. At step ($nReader+1), reader 1\n** closes the current read transaction and opens a new one. And so on.\n** The result is that at step N (for N > $nReader), there exists a reader\n** with an open read transaction reading the snapshot committed following\n** steps (N-$nReader-1) to N. \n*/\ntypedef struct Mctest Mctest;\nstruct Mctest {\n  DatasourceDefn defn;            /* Datasource to use */\n  int nStep;                      /* Total number of steps in test */\n  int nWriteStep;                 /* Number of rows to insert each step */\n  int nReader;                    /* Number of read connections */\n};\nstatic void do_mc_test(\n  const char *zSystem,            /* Database system to test */\n  Mctest *pTest,\n  int *pRc                        /* IN/OUT: return code */\n){\n  const int nDomain = pTest->nStep * pTest->nWriteStep;\n  Datasource *pData;              /* Source of data */\n  TestDb *pDb;                    /* First database connection (writer) */\n  int iReader;                    /* Used to iterate through aReader */\n  int iStep;                      /* Current step in test */\n  int iDot = 0;                   /* Current step in test */\n\n  /* Array of reader connections */\n  struct Reader {\n    TestDb *pDb;                  /* Connection handle */\n    int iLast;                    /* Current snapshot contains keys 0..iLast */\n  } *aReader;\n\n  /* Create a data source */\n  pData = testDatasourceNew(&pTest->defn);\n\n  /* Open the writer connection */\n  pDb = testOpen(zSystem, 1, pRc);\n\n  /* Allocate aReader */\n  aReader = (struct Reader *)testMalloc(sizeof(aReader[0]) * pTest->nReader);\n  for(iReader=0; iReader<pTest->nReader; iReader++){\n    aReader[iReader].pDb = testOpen(zSystem, 0, pRc);\n  }\n\n  for(iStep=0; iStep<pTest->nStep; iStep++){\n    int iLast;\n    int iBegin;                   /* Start read trans using aReader[iBegin] */\n\n    /* Insert nWriteStep more records into the database */\n    int iFirst = iStep*pTest->nWriteStep;\n    testWriteDatasourceRange(pDb, pData, iFirst, pTest->nWriteStep, pRc);\n\n    /* Check that the db is Ok according to the writer */\n    iLast = (iStep+1) * pTest->nWriteStep - 1;\n    testDbContents(pDb, pData, nDomain, 0, iLast, iLast, 1, pRc);\n\n    /* Have reader (iStep % nReader) open a read transaction here. */\n    iBegin = (iStep % pTest->nReader);\n    if( iBegin<iStep ) tdb_commit(aReader[iBegin].pDb, 0);\n    tdb_begin(aReader[iBegin].pDb, 1);\n    aReader[iBegin].iLast = iLast;\n\n    /* Check that the db is Ok for each open reader */\n    for(iReader=0; iReader<pTest->nReader && aReader[iReader].iLast; iReader++){\n      iLast = aReader[iReader].iLast;\n      testDbContents(\n          aReader[iReader].pDb, pData, nDomain, 0, iLast, iLast, 1, pRc\n      );\n    }\n\n    /* Report progress */\n    testCaseProgress(iStep, pTest->nStep, testCaseNDot(), &iDot);\n  }\n\n  /* Close all readers */\n  for(iReader=0; iReader<pTest->nReader; iReader++){\n    testClose(&aReader[iReader].pDb);\n  }\n  testFree(aReader);\n\n  /* Close the writer-connection and free the datasource */\n  testClose(&pDb);\n  testDatasourceFree(pData);\n}\n\n\nvoid test_mc(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;\n  Mctest aTest[] = {\n    { { TEST_DATASOURCE_RANDOM, 10,10, 100,100 }, 100, 10, 5 },\n  };\n\n  for(i=0; i<ArraySize(aTest); i++){\n    if( testCaseBegin(pRc, zPattern, \"mc1.%s.%d\", zSystem, i) ){\n      do_mc_test(zSystem, &aTest[i], pRc);\n      testCaseFinish(*pRc);\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest5.c",
    "content": "\n/*\n** This file is broken into three semi-autonomous parts:\n**\n**   1. The database functions.\n**   2. The thread wrappers.\n**   3. The implementation of the mt1.* tests.\n*/\n\n/*************************************************************************\n** DATABASE CONTENTS:\n**\n**   The database contains up to N key/value pairs, where N is some large \n**   number (say 10,000,000). Keys are integer values between 0 and (N-1).\n**   The value associated with each key is a pseudo-random blob of data.\n**\n**   Key/value pair keys are encoded as the two bytes \"k.\" followed by a \n**   10-digit decimal number. i.e. key 45 -> \"k.0000000045\".\n**\n**   As well as the key/value pairs, the database also contains checksum \n**   entries. The checksums form a hierarchy - for every F key/value\n**   entries there is one level 1 checksum. And for each F level 1 checksums\n**   there is one level 2 checksum. And so on.\n**\n**   Checksum keys are encoded as the two byte \"c.\" followed by the \n**   checksum level, followed by a 10 digit decimal number containing\n**   the value of the first key that contributes to the checksum value.\n**   For example, assuming F==10, the level 1 checksum that spans keys\n**   10 to 19 is \"c.1.0000000010\".\n**\n**   Clients may perform one of two operations on the database: a read\n**   or a write.\n** \n** READ OPERATIONS:\n**\n**   A read operation scans a range of F key/value pairs. It computes\n**   the expected checksum and then compares the computed value to the\n**   actual value stored in the level 1 checksum entry. It then scans \n**   the group of F level 1 checksums, and compares the computed checksum \n**   to the associated level 2 checksum value, and so on until the \n**   highest level checksum value has been verified.\n**\n**   If a checksum ever fails to match the expected value, the test \n**   has failed.\n**\n** WRITE OPERATIONS:\n**\n**   A write operation involves writing (possibly clobbering) a single\n**   key/value pair. The associated level 1 checksum is then recalculated\n**   updated. Then the level 2 checksum, and so on until the highest\n**   level checksum has been modified.\n**\n**   All updates occur inside a single transaction.\n**\n** INTERFACE:\n**\n**   The interface used by test cases to read and write the db consists\n**   of type DbParameters and the following functions:\n**\n**       dbReadOperation()\n**       dbWriteOperation()\n*/\n\n#include \"lsmtest.h\"\n\ntypedef struct DbParameters DbParameters;\nstruct DbParameters {\n  int nFanout;                    /* Checksum fanout (F) */\n  int nKey;                       /* Size of key space (N) */\n};\n\n#define DB_KEY_BYTES          (2+5+10+1)\n\n/*\n** Argument aBuf[] must point to a buffer at least DB_KEY_BYTES in size.\n** This function populates the buffer with a nul-terminated key string \n** corresponding to key iKey.\n*/\nstatic void dbFormatKey(\n  DbParameters *pParam,\n  int iLevel,\n  int iKey,                       /* Key value */\n  char *aBuf                      /* Write key string here */\n){\n  if( iLevel==0 ){\n    snprintf(aBuf, DB_KEY_BYTES, \"k.%.10d\", iKey);\n  }else{\n    int f = 1;\n    int i;\n    for(i=0; i<iLevel; i++) f = f * pParam->nFanout;\n    snprintf(aBuf, DB_KEY_BYTES, \"c.%d.%.10d\", iLevel, f*(iKey/f));\n  }\n}\n\n/*\n** Argument aBuf[] must point to a buffer at least DB_KEY_BYTES in size.\n** This function populates the buffer with the string representation of\n** checksum value iVal.\n*/\nstatic void dbFormatCksumValue(u32 iVal, char *aBuf){\n  snprintf(aBuf, DB_KEY_BYTES, \"%.10u\", iVal);\n}\n\n/*\n** Return the highest level of checksum in the database described\n** by *pParam.\n*/\nstatic int dbMaxLevel(DbParameters *pParam){\n  int iMax;\n  int n = 1;\n  for(iMax=0; n<pParam->nKey; iMax++){\n    n = n * pParam->nFanout;\n  }\n  return iMax;\n}\n\nstatic void dbCksum(\n  void *pCtx,                     /* IN/OUT: Pointer to u32 containing cksum */\n  void *pKey, int nKey,           /* Database key. Unused. */\n  void *pVal, int nVal            /* Database value. Checksum this. */\n){\n  u8 *aVal = (u8 *)pVal;\n  u32 *pCksum = (u32 *)pCtx;\n  u32 cksum = *pCksum;\n  int i;\n\n  unused_parameter(pKey);\n  unused_parameter(nKey);\n\n  for(i=0; i<nVal; i++){\n    cksum += (cksum<<3) + (int)aVal[i];\n  }\n\n  *pCksum = cksum;\n}\n\n/*\n** Compute the value of the checksum stored on level iLevel that contains\n** data from key iKey by scanning the pParam->nFanout entries at level \n** iLevel-1.\n*/\nstatic u32 dbComputeCksum(\n  DbParameters *pParam,           /* Database parameters */\n  TestDb *pDb,                    /* Database connection handle */\n  int iLevel,                     /* Level of checksum to compute */\n  int iKey,                       /* Compute checksum for this key */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  u32 cksum = 0;\n  if( *pRc==0 ){\n    int nFirst;\n    int nLast;\n    int iFirst = 0;\n    int iLast = 0;\n    int i;\n    int f = 1;\n    char zFirst[DB_KEY_BYTES];\n    char zLast[DB_KEY_BYTES];\n\n    assert( iLevel>=1 );\n    for(i=0; i<iLevel; i++) f = f * pParam->nFanout;\n\n    iFirst = f*(iKey/f);\n    iLast = iFirst + f - 1;\n    dbFormatKey(pParam, iLevel-1, iFirst, zFirst);\n    dbFormatKey(pParam, iLevel-1, iLast, zLast);\n    nFirst = strlen(zFirst);\n    nLast = strlen(zLast);\n\n    *pRc = tdb_scan(pDb, (u32*)&cksum, 0, zFirst, nFirst, zLast, nLast,dbCksum);\n  }\n\n  return cksum;\n}\n\nstatic void dbReadOperation(\n  DbParameters *pParam,           /* Database parameters */\n  TestDb *pDb,                    /* Database connection handle */\n  void (*xDelay)(void *),\n  void *pDelayCtx,\n  int iKey,                       /* Key to read */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  const int iMax = dbMaxLevel(pParam);\n  int i;\n\n  if( tdb_transaction_support(pDb) ) testBegin(pDb, 1, pRc);\n  for(i=1; *pRc==0 && i<=iMax; i++){\n    char zCksum[DB_KEY_BYTES];\n    char zKey[DB_KEY_BYTES];\n    u32 iCksum = 0;\n\n    iCksum = dbComputeCksum(pParam, pDb, i, iKey, pRc);\n    if( iCksum ){\n      if( xDelay && i==1 ) xDelay(pDelayCtx);\n      dbFormatCksumValue(iCksum, zCksum);\n      dbFormatKey(pParam, i, iKey, zKey);\n      testFetchStr(pDb, zKey, zCksum, pRc);\n    }\n  }\n  if( tdb_transaction_support(pDb) ) testCommit(pDb, 0, pRc);\n}\n\nstatic int dbWriteOperation(\n  DbParameters *pParam,           /* Database parameters */\n  TestDb *pDb,                    /* Database connection handle */\n  int iKey,                       /* Key to write to */\n  const char *zValue,             /* Nul-terminated value to write */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  const int iMax = dbMaxLevel(pParam);\n  char zKey[DB_KEY_BYTES];\n  int i;\n  int rc;\n\n  assert( iKey>=0 && iKey<pParam->nKey );\n  dbFormatKey(pParam, 0, iKey, zKey);\n\n  /* Open a write transaction. This may fail - SQLITE4_BUSY */\n  if( *pRc==0 && tdb_transaction_support(pDb) ){\n    rc = tdb_begin(pDb, 2);\n    if( rc==5 ) return 0;\n    *pRc = rc;\n  }\n\n  testWriteStr(pDb, zKey, zValue, pRc);\n  for(i=1; i<=iMax; i++){\n    char zCksum[DB_KEY_BYTES];\n    u32 iCksum = 0;\n\n    iCksum = dbComputeCksum(pParam, pDb, i, iKey, pRc);\n    dbFormatCksumValue(iCksum, zCksum);\n    dbFormatKey(pParam, i, iKey, zKey);\n    testWriteStr(pDb, zKey, zCksum, pRc);\n  }\n  if( tdb_transaction_support(pDb) ) testCommit(pDb, 0, pRc);\n  return 1;\n}\n\n/*************************************************************************\n** The following block contains testXXX() functions that implement a\n** wrapper around the systems native multi-thread support. There are no\n** synchronization primitives - just functions to launch and join \n** threads. Wrapper functions are:\n**\n**    testThreadSupport()\n**\n**    testThreadInit()\n**    testThreadShutdown()\n**    testThreadLaunch()\n**    testThreadWait()\n**\n**    testThreadSetHalt()\n**    testThreadGetHalt()\n**    testThreadSetResult()\n**    testThreadGetResult()\n**\n**    testThreadEnterMutex()\n**    testThreadLeaveMutex()\n*/\ntypedef struct ThreadSet ThreadSet;\n#ifdef LSM_MUTEX_PTHREADS\n\n#include <pthread.h>\n#include <unistd.h>\n\ntypedef struct Thread Thread;\nstruct Thread {\n  int rc;\n  char *zMsg;\n  pthread_t id;\n  void (*xMain)(ThreadSet *, int, void *);\n  void *pCtx;\n  ThreadSet *pThreadSet;\n};\n\nstruct ThreadSet {\n  int bHalt;                      /* Halt flag */\n  int nThread;                    /* Number of threads */\n  Thread *aThread;                /* Array of Thread structures */\n  pthread_mutex_t mutex;          /* Mutex used for cheating */\n};\n\n/*\n** Return true if this build supports threads, or false otherwise. If\n** this function returns false, no other testThreadXXX() functions should\n** be called.\n*/\nstatic int testThreadSupport(){ return 1; }\n\n/*\n** Allocate and return a thread-set handle with enough space allocated\n** to handle up to nMax threads. Each call to this function should be\n** matched by a call to testThreadShutdown() to delete the object.\n*/\nstatic ThreadSet *testThreadInit(int nMax){\n  int nByte;                      /* Total space to allocate */\n  ThreadSet *p;                   /* Return value */\n\n  nByte = sizeof(ThreadSet) + sizeof(struct Thread) * nMax;\n  p = (ThreadSet *)testMalloc(nByte);\n  p->nThread = nMax;\n  p->aThread = (Thread *)&p[1];\n  pthread_mutex_init(&p->mutex, 0);\n\n  return p;\n}\n\n/*\n** Delete a thread-set object and release all resources held by it.\n*/\nstatic void testThreadShutdown(ThreadSet *p){\n  int i;\n  for(i=0; i<p->nThread; i++){\n    testFree(p->aThread[i].zMsg);\n  }\n  pthread_mutex_destroy(&p->mutex);\n  testFree(p);\n}\n\nstatic void *ttMain(void *pArg){\n  Thread *pThread = (Thread *)pArg;\n  int iThread;\n  iThread = (pThread - pThread->pThreadSet->aThread);\n  pThread->xMain(pThread->pThreadSet, iThread, pThread->pCtx);\n  return 0;\n}\n\n/*\n** Launch a new thread.\n*/\nstatic int testThreadLaunch(\n  ThreadSet *p,\n  int iThread,\n  void (*xMain)(ThreadSet *, int, void *),\n  void *pCtx\n){\n  int rc;\n  Thread *pThread;\n\n  assert( iThread>=0 && iThread<p->nThread );\n\n  pThread = &p->aThread[iThread];\n  assert( pThread->pThreadSet==0 );\n  pThread->xMain = xMain;\n  pThread->pCtx = pCtx;\n  pThread->pThreadSet = p;\n  rc = pthread_create(&pThread->id, 0, ttMain, (void *)pThread);\n\n  return rc;\n}\n\n/*\n** Set the thread-set \"halt\" flag.\n*/\nstatic void testThreadSetHalt(ThreadSet *pThreadSet){\n  pThreadSet->bHalt = 1;\n}\n\n/*\n** Return the current value of the thread-set \"halt\" flag.\n*/\nstatic int testThreadGetHalt(ThreadSet *pThreadSet){\n  return pThreadSet->bHalt;\n}\n\nstatic void testThreadSleep(ThreadSet *pThreadSet, int nMs){\n  int nRem = nMs;\n  while( nRem>0 && testThreadGetHalt(pThreadSet)==0 ){\n    usleep(50000);\n    nRem -= 50;\n  }\n}\n\n/*\n** Wait for all threads launched to finish before returning. If nMs\n** is greater than zero, set the \"halt\" flag to tell all threads\n** to halt after waiting nMs milliseconds.\n*/\nstatic void testThreadWait(ThreadSet *pThreadSet, int nMs){\n  int i;\n\n  testThreadSleep(pThreadSet, nMs);\n  testThreadSetHalt(pThreadSet);\n  for(i=0; i<pThreadSet->nThread; i++){\n    Thread *pThread = &pThreadSet->aThread[i];\n    if( pThread->xMain ){\n      pthread_join(pThread->id, 0);\n    }\n  }\n}\n\n/*\n** Set the result for thread iThread. \n*/\nstatic void testThreadSetResult(\n  ThreadSet *pThreadSet,          /* Thread-set handle */\n  int iThread,                    /* Set result for this thread */\n  int rc,                         /* Result error code */\n  char *zFmt,                     /* Result string format */\n  ...                             /* Result string formatting args... */\n){\n  va_list ap;\n\n  testFree(pThreadSet->aThread[iThread].zMsg);\n  pThreadSet->aThread[iThread].rc = rc;\n  pThreadSet->aThread[iThread].zMsg = 0;\n  if( zFmt ){\n    va_start(ap, zFmt);\n    pThreadSet->aThread[iThread].zMsg = testMallocVPrintf(zFmt, ap);\n    va_end(ap);\n  }\n}\n\n/*\n** Retrieve the result for thread iThread. \n*/\nstatic int testThreadGetResult(\n  ThreadSet *pThreadSet,          /* Thread-set handle */\n  int iThread,                    /* Get result for this thread */\n  const char **pzRes              /* OUT: Pointer to result string */\n){\n  if( pzRes ) *pzRes = pThreadSet->aThread[iThread].zMsg;\n  return pThreadSet->aThread[iThread].rc;\n}\n\n/*\n** Enter and leave the test case mutex.\n*/\n#if 0\nstatic void testThreadEnterMutex(ThreadSet *p){\n  pthread_mutex_lock(&p->mutex);\n}\nstatic void testThreadLeaveMutex(ThreadSet *p){\n  pthread_mutex_unlock(&p->mutex);\n}\n#endif\n#endif\n\n#if !defined(LSM_MUTEX_PTHREADS)\nstatic int testThreadSupport(){ return 0; }\n\n#define testThreadInit(a) 0\n#define testThreadShutdown(a)\n#define testThreadLaunch(a,b,c,d) 0\n#define testThreadWait(a,b)\n#define testThreadSetHalt(a)\n#define testThreadGetHalt(a) 0\n#define testThreadGetResult(a,b,c) 0\n#define testThreadSleep(a,b) 0\n\nstatic void testThreadSetResult(ThreadSet *a, int b, int c, char *d, ...){\n  unused_parameter(a);\n  unused_parameter(b);\n  unused_parameter(c);\n  unused_parameter(d);\n}\n#endif\n/* End of threads wrapper.\n*************************************************************************/\n\n/*************************************************************************\n** Below this point is the third part of this file - the implementation\n** of the mt1.* tests.\n*/\ntypedef struct Mt1Test Mt1Test;\nstruct Mt1Test {\n  DbParameters param;             /* Description of database to read/write */\n  int nReadwrite;                 /* Number of read/write threads */\n  int nFastReader;                /* Number of fast reader threads */\n  int nSlowReader;                /* Number of slow reader threads */\n  int nMs;                        /* How long to run for */\n  const char *zSystem;            /* Database system to test */\n};\n\ntypedef struct Mt1DelayCtx Mt1DelayCtx;\nstruct Mt1DelayCtx {\n  ThreadSet *pSet;                /* Threadset to sleep within */\n  int nMs;                        /* Sleep in ms */\n};\n\nstatic void xMt1Delay(void *pCtx){\n  Mt1DelayCtx *p = (Mt1DelayCtx *)pCtx;\n  testThreadSleep(p->pSet, p->nMs);\n}\n\n#define MT1_THREAD_RDWR 0\n#define MT1_THREAD_SLOW 1\n#define MT1_THREAD_FAST 2\n\nstatic void xMt1Work(lsm_db *pDb, void *pCtx){\n#if 0\n  char *z = 0;\n  lsm_info(pDb, LSM_INFO_DB_STRUCTURE, &z);\n  printf(\"%s\\n\", z);\n  fflush(stdout);\n#endif\n}\n\n/*\n** This is the main() proc for all threads in test case \"mt1\".\n*/\nstatic void mt1Main(ThreadSet *pThreadSet, int iThread, void *pCtx){\n  Mt1Test *p = (Mt1Test *)pCtx;   /* Test parameters */\n  Mt1DelayCtx delay;\n  int nRead = 0;                  /* Number of calls to dbReadOperation() */\n  int nWrite = 0;                 /* Number of completed database writes */\n  int rc = 0;                     /* Error code */\n  int iPrng;                      /* Prng argument variable */\n  TestDb *pDb;                    /* Database handle */\n  int eType;\n\n  delay.pSet = pThreadSet;\n  delay.nMs = 0;\n  if( iThread<p->nReadwrite ){\n    eType = MT1_THREAD_RDWR;\n  }else if( iThread<(p->nReadwrite+p->nFastReader) ){\n    eType = MT1_THREAD_FAST;\n  }else{\n    eType = MT1_THREAD_SLOW;\n    delay.nMs = (p->nMs / 20);\n  }\n\n  /* Open a new database connection. Initialize the pseudo-random number\n  ** argument based on the thread number.  */\n  iPrng = testPrngValue(iThread);\n  pDb = testOpen(p->zSystem, 0, &rc);\n\n  if( rc==0 ){\n    tdb_lsm_config_work_hook(pDb, xMt1Work, 0);\n  }\n\n  /* Loop until either an error occurs or some other thread sets the\n  ** halt flag.  */\n  while( rc==0 && testThreadGetHalt(pThreadSet)==0 ){\n    int iKey;\n\n    /* Perform a read operation on an arbitrarily selected key. */\n    iKey = (testPrngValue(iPrng++) % p->param.nKey);\n    dbReadOperation(&p->param, pDb, xMt1Delay, (void *)&delay, iKey, &rc);\n    if( rc ) continue;\n    nRead++;\n\n    /* Attempt to write an arbitrary key value pair (and update the associated\n    ** checksum entries). dbWriteOperation() returns 1 if the write is\n    ** successful, or 0 if it failed with an LSM_BUSY error.  */\n    if( eType==MT1_THREAD_RDWR ){\n      char aValue[50];\n      char aRnd[25];\n\n      iKey = (testPrngValue(iPrng++) % p->param.nKey);\n      testPrngString(iPrng, aRnd, sizeof(aRnd));\n      iPrng += sizeof(aRnd);\n      snprintf(aValue, sizeof(aValue), \"%d.%s\", iThread, aRnd);\n      nWrite += dbWriteOperation(&p->param, pDb, iKey, aValue, &rc);\n    }\n  }\n  testClose(&pDb);\n\n  /* If an error has occured, set the thread error code and the threadset \n  ** halt flag to tell the other test threads to halt. Otherwise, set the\n  ** thread error code to 0 and post a message with the number of read\n  ** and write operations completed.  */\n  if( rc ){\n    testThreadSetResult(pThreadSet, iThread, rc, 0);\n    testThreadSetHalt(pThreadSet);\n  }else{\n    testThreadSetResult(pThreadSet, iThread, 0, \"r/w: %d/%d\", nRead, nWrite);\n  }\n}\n\nstatic void do_test_mt1(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Mt1Test aTest[] = {\n    /* param, nReadwrite, nFastReader, nSlowReader, nMs, zSystem */\n    { {10, 1000},     4, 0, 0,   10000,   0 },\n    { {10, 1000},     4, 4, 2,   100000,  0 },\n    { {10, 100000},   4, 0, 0,   10000,   0 },\n    { {10, 100000},   4, 4, 2,   100000,  0 },\n  };\n  int i;\n\n  for(i=0; *pRc==0 && i<ArraySize(aTest); i++){\n    Mt1Test *p = &aTest[i];\n    int bRun = testCaseBegin(pRc, zPattern, \n        \"mt1.%s.db=%d,%d.ms=%d.rdwr=%d.fast=%d.slow=%d\", \n        zSystem, p->param.nFanout, p->param.nKey, \n        p->nMs, p->nReadwrite, p->nFastReader, p->nSlowReader\n    );\n    if( bRun ){\n      TestDb *pDb;\n      ThreadSet *pSet;\n      int iThread;\n      int nThread;\n\n      p->zSystem = zSystem;\n      pDb = testOpen(zSystem, 1, pRc);\n\n      nThread = p->nReadwrite + p->nFastReader + p->nSlowReader;\n      pSet = testThreadInit(nThread);\n      for(iThread=0; *pRc==0 && iThread<nThread; iThread++){\n        testThreadLaunch(pSet, iThread, mt1Main, (void *)p);\n      }\n\n      testThreadWait(pSet, p->nMs);\n      for(iThread=0; *pRc==0 && iThread<nThread; iThread++){\n        *pRc = testThreadGetResult(pSet, iThread, 0);\n      }\n      testCaseFinish(*pRc);\n\n      for(iThread=0; *pRc==0 && iThread<nThread; iThread++){\n        const char *zMsg = 0;\n        *pRc = testThreadGetResult(pSet, iThread, &zMsg);\n        printf(\"  Info: thread %d (%d): %s\\n\", iThread, *pRc, zMsg);\n      }\n\n      testThreadShutdown(pSet);\n      testClose(&pDb);\n    }\n  }\n}\n\nvoid test_mt(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( testThreadSupport()==0 ) return;\n  do_test_mt1(zSystem, zPattern, pRc);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest6.c",
    "content": "\n#include \"lsmtest.h\"\n\ntypedef struct OomTest OomTest;\nstruct OomTest {\n  lsm_env *pEnv;\n  int iNext;                      /* Next value to pass to testMallocOom() */\n  int nFail;                      /* Number of OOM events injected */\n  int bEnable;\n  int rc;                         /* Test case error code */\n};\n\nstatic void testOomStart(OomTest *p){\n  memset(p, 0, sizeof(OomTest));\n  p->iNext = 1;\n  p->bEnable = 1;\n  p->nFail = 1;\n  p->pEnv = tdb_lsm_env();\n}\n\nstatic void xOomHook(OomTest *p){\n  p->nFail++;\n}\n\nstatic int testOomContinue(OomTest *p){\n  if( p->rc!=0 || (p->iNext>1 && p->nFail==0) ){\n    return 0;\n  }\n  p->nFail = 0;\n  testMallocOom(p->pEnv, p->iNext, 0, (void (*)(void*))xOomHook, (void *)p);\n  return 1;\n}\n\nstatic void testOomEnable(OomTest *p, int bEnable){\n  p->bEnable = bEnable;\n  testMallocOomEnable(p->pEnv, bEnable);\n}\n\nstatic void testOomNext(OomTest *p){\n  p->iNext++;\n}\n\nstatic int testOomHit(OomTest *p){\n  return (p->nFail>0);\n}\n\nstatic int testOomFinish(OomTest *p){\n  return p->rc;\n}\n\nstatic void testOomAssert(OomTest *p, int bVal){\n  if( bVal==0 ){\n    test_failed();\n    p->rc = 1;\n  }\n}\n\n/*\n** Test that the error code matches the state of the OomTest object passed\n** as the first argument. Specifically, check that rc is LSM_NOMEM if an \n** OOM error has already been injected, or LSM_OK if not.\n*/\nstatic void testOomAssertRc(OomTest *p, int rc){\n  testOomAssert(p, rc==LSM_OK || rc==LSM_NOMEM);\n  testOomAssert(p, testOomHit(p)==(rc==LSM_NOMEM) || p->bEnable==0 );\n}\n\nstatic void testOomOpen(\n  OomTest *pOom,\n  const char *zName,\n  lsm_db **ppDb,\n  int *pRc\n){\n  if( *pRc==LSM_OK ){\n    int rc;\n    rc = lsm_new(tdb_lsm_env(), ppDb);\n    if( rc==LSM_OK ) rc = lsm_open(*ppDb, zName);\n    testOomAssertRc(pOom, rc);\n    *pRc = rc;\n  }\n}\n\nstatic void testOomFetch(\n  OomTest *pOom,\n  lsm_db *pDb,\n  void *pKey, int nKey,\n  void *pVal, int nVal,\n  int *pRc\n){\n  testOomAssertRc(pOom, *pRc);\n  if( *pRc==LSM_OK ){\n    lsm_cursor *pCsr;\n    int rc;\n\n    rc = lsm_csr_open(pDb, &pCsr);\n    if( rc==LSM_OK ) rc = lsm_csr_seek(pCsr, pKey, nKey, 0);\n    testOomAssertRc(pOom, rc);\n\n    if( rc==LSM_OK ){\n      const void *p; int n;\n      testOomAssert(pOom, lsm_csr_valid(pCsr));\n\n      rc = lsm_csr_key(pCsr, &p, &n);\n      testOomAssertRc(pOom, rc);\n      testOomAssert(pOom, rc!=LSM_OK || (n==nKey && memcmp(pKey, p, nKey)==0) );\n    }\n\n    if( rc==LSM_OK ){\n      const void *p; int n;\n      testOomAssert(pOom, lsm_csr_valid(pCsr));\n\n      rc = lsm_csr_value(pCsr, &p, &n);\n      testOomAssertRc(pOom, rc);\n      testOomAssert(pOom, rc!=LSM_OK || (n==nVal && memcmp(pVal, p, nVal)==0) );\n    }\n\n    lsm_csr_close(pCsr);\n    *pRc = rc;\n  }\n}\n\nstatic void testOomWrite(\n  OomTest *pOom,\n  lsm_db *pDb,\n  void *pKey, int nKey,\n  void *pVal, int nVal,\n  int *pRc\n){\n  testOomAssertRc(pOom, *pRc);\n  if( *pRc==LSM_OK ){\n    int rc;\n\n    rc = lsm_insert(pDb, pKey, nKey, pVal, nVal);\n    testOomAssertRc(pOom, rc);\n\n    *pRc = rc;\n  }\n}\n\n\nstatic void testOomFetchStr(\n  OomTest *pOom,\n  lsm_db *pDb,\n  const char *zKey,\n  const char *zVal,\n  int *pRc\n){\n  int nKey = strlen(zKey);\n  int nVal = strlen(zVal);\n  testOomFetch(pOom, pDb, (void *)zKey, nKey, (void *)zVal, nVal, pRc);\n}\n\nstatic void testOomFetchData(\n  OomTest *pOom,\n  lsm_db *pDb,\n  Datasource *pData,\n  int iKey,\n  int *pRc\n){\n  void *pKey; int nKey;\n  void *pVal; int nVal;\n  testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);\n  testOomFetch(pOom, pDb, pKey, nKey, pVal, nVal, pRc);\n}\n\nstatic void testOomWriteStr(\n  OomTest *pOom,\n  lsm_db *pDb,\n  const char *zKey,\n  const char *zVal,\n  int *pRc\n){\n  int nKey = strlen(zKey);\n  int nVal = strlen(zVal);\n  testOomWrite(pOom, pDb, (void *)zKey, nKey, (void *)zVal, nVal, pRc);\n}\n\nstatic void testOomWriteData(\n  OomTest *pOom,\n  lsm_db *pDb,\n  Datasource *pData,\n  int iKey,\n  int *pRc\n){\n  void *pKey; int nKey;\n  void *pVal; int nVal;\n  testDatasourceEntry(pData, iKey, &pKey, &nKey, &pVal, &nVal);\n  testOomWrite(pOom, pDb, pKey, nKey, pVal, nVal, pRc);\n}\n\nstatic void testOomScan(\n  OomTest *pOom, \n  lsm_db *pDb, \n  int bReverse,\n  const void *pKey, int nKey,\n  int nScan,\n  int *pRc\n){\n  if( *pRc==0 ){\n    int rc;\n    int iScan = 0;\n    lsm_cursor *pCsr;\n    int (*xAdvance)(lsm_cursor *) = 0;\n    \n\n    rc = lsm_csr_open(pDb, &pCsr);\n    testOomAssertRc(pOom, rc);\n\n    if( rc==LSM_OK ){\n      if( bReverse ){\n        rc = lsm_csr_seek(pCsr, pKey, nKey, LSM_SEEK_LE);\n        xAdvance = lsm_csr_prev;\n      }else{\n        rc = lsm_csr_seek(pCsr, pKey, nKey, LSM_SEEK_GE);\n        xAdvance = lsm_csr_next;\n      }\n    }\n    testOomAssertRc(pOom, rc);\n\n    while( rc==LSM_OK && lsm_csr_valid(pCsr) && iScan<nScan ){\n      const void *p; int n;\n\n      rc = lsm_csr_key(pCsr, &p, &n);\n      testOomAssertRc(pOom, rc);\n      if( rc==LSM_OK ){\n        rc = lsm_csr_value(pCsr, &p, &n);\n        testOomAssertRc(pOom, rc);\n      }\n      if( rc==LSM_OK ){\n        rc = xAdvance(pCsr);\n        testOomAssertRc(pOom, rc);\n      }\n      iScan++;\n    }\n\n    lsm_csr_close(pCsr);\n    *pRc = rc;\n  }\n}\n\n#define LSMTEST6_TESTDB \"testdb.lsm\" \n\nvoid testDeleteLsmdb(const char *zFile){\n  char *zLog = testMallocPrintf(\"%s-log\", zFile);\n  char *zShm = testMallocPrintf(\"%s-shm\", zFile);\n  unlink(zFile);\n  unlink(zLog);\n  unlink(zShm);\n  testFree(zLog);\n  testFree(zShm);\n}\n\nstatic void copy_file(const char *zFrom, const char *zTo, int isDatabase){\n\n  if( access(zFrom, F_OK) ){\n    unlink(zTo);\n  }else{\n    int fd1;\n    int fd2;\n    off_t sz;\n    off_t i;\n    struct stat buf;\n    u8 *aBuf;\n\n    fd1 = open(zFrom, O_RDONLY | _O_BINARY, 0644);\n    fd2 = open(zTo, O_RDWR | O_CREAT | _O_BINARY, 0644);\n\n    fstat(fd1, &buf);\n    sz = buf.st_size;\n    ftruncate(fd2, sz);\n\n    aBuf = testMalloc(4096);\n    for(i=0; i<sz; i+=4096){\n      int bLockPage = isDatabase && i == 0;\n      int nByte = MIN((bLockPage ? 4066 : 4096), sz - i);\n      memset(aBuf, 0, 4096);\n      read(fd1, aBuf, nByte);\n      write(fd2, aBuf, nByte);\n      if( bLockPage ){\n        lseek(fd1, 4096, SEEK_SET);\n        lseek(fd2, 4096, SEEK_SET);\n      }\n    }\n    testFree(aBuf);\n\n    close(fd1);\n    close(fd2);\n  }\n}\n\nvoid testCopyLsmdb(const char *zFrom, const char *zTo){\n  char *zLog1 = testMallocPrintf(\"%s-log\", zFrom);\n  char *zLog2 = testMallocPrintf(\"%s-log\", zTo);\n  char *zShm1 = testMallocPrintf(\"%s-shm\", zFrom);\n  char *zShm2 = testMallocPrintf(\"%s-shm\", zTo);\n\n  unlink(zShm2);\n  unlink(zLog2);\n  unlink(zTo);\n  copy_file(zFrom, zTo, 1);\n  copy_file(zLog1, zLog2, 0);\n  copy_file(zShm1, zShm2, 0);\n\n  testFree(zLog1); testFree(zLog2); testFree(zShm1); testFree(zShm2);\n}\n\n/*\n** File zFile is the path to a database. This function makes backups\n** of the database file and its log as follows:\n**\n**     cp $(zFile)         $(zFile)-save\n**     cp $(zFile)-$(zAux) $(zFile)-save-$(zAux)\n**\n** Function testRestoreDb() can be used to copy the files back in the\n** other direction.\n*/\nvoid testSaveDb(const char *zFile, const char *zAux){\n  char *zLog = testMallocPrintf(\"%s-%s\", zFile, zAux);\n  char *zFileSave = testMallocPrintf(\"%s-save\", zFile);\n  char *zLogSave = testMallocPrintf(\"%s-%s-save\", zFile, zAux);\n\n  unlink(zFileSave);\n  unlink(zLogSave);\n  copy_file(zFile, zFileSave, 1);\n  copy_file(zLog, zLogSave, 0);\n\n  testFree(zLog); testFree(zFileSave); testFree(zLogSave);\n}\n\n/*\n** File zFile is the path to a database. This function restores\n** a backup of the database made by a previous call to testSaveDb().\n** Specifically, it does the equivalent of:\n**\n**     cp $(zFile)-save         $(zFile)\n**     cp $(zFile)-save-$(zAux) $(zFile)-$(zAux)\n*/\nvoid testRestoreDb(const char *zFile, const char *zAux){\n  char *zLog = testMallocPrintf(\"%s-%s\", zFile, zAux);\n  char *zFileSave = testMallocPrintf(\"%s-save\", zFile);\n  char *zLogSave = testMallocPrintf(\"%s-%s-save\", zFile, zAux);\n\n  copy_file(zFileSave, zFile, 1);\n  copy_file(zLogSave, zLog, 0);\n\n  testFree(zLog); testFree(zFileSave); testFree(zLogSave);\n}\n\n\nstatic int lsmWriteStr(lsm_db *pDb, const char *zKey, const char *zVal){\n  int nKey = strlen(zKey);\n  int nVal = strlen(zVal);\n  return lsm_insert(pDb, (void *)zKey, nKey, (void *)zVal, nVal);\n}\n\nstatic void setup_delete_db(void){\n  testDeleteLsmdb(LSMTEST6_TESTDB);\n}\n\n/*\n** Create a small database. With the following content:\n**\n**    \"one\"   -> \"one\"\n**    \"two\"   -> \"four\"\n**    \"three\" -> \"nine\"\n**    \"four\"  -> \"sixteen\"\n**    \"five\"  -> \"twentyfive\"\n**    \"six\"   -> \"thirtysix\"\n**    \"seven\" -> \"fourtynine\"\n**    \"eight\" -> \"sixtyfour\"\n*/\nstatic void setup_populate_db(void){\n  const char *azStr[] = {\n    \"one\",   \"one\",\n    \"two\",   \"four\",\n    \"three\", \"nine\",\n    \"four\",  \"sixteen\",\n    \"five\",  \"twentyfive\",\n    \"six\",   \"thirtysix\",\n    \"seven\", \"fourtynine\",\n    \"eight\", \"sixtyfour\",\n  };\n  int rc;\n  int ii;\n  lsm_db *pDb;\n\n  testDeleteLsmdb(LSMTEST6_TESTDB);\n\n  rc = lsm_new(tdb_lsm_env(), &pDb);\n  if( rc==LSM_OK ) rc = lsm_open(pDb, LSMTEST6_TESTDB);\n\n  for(ii=0; rc==LSM_OK && ii<ArraySize(azStr); ii+=2){\n    rc = lsmWriteStr(pDb, azStr[ii], azStr[ii+1]);\n  }\n  lsm_close(pDb);\n\n  testSaveDb(LSMTEST6_TESTDB, \"log\");\n  assert( rc==LSM_OK );\n}\n\nstatic Datasource *getDatasource(void){\n  const DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 10, 15, 200, 250 };\n  return testDatasourceNew(&defn);\n}\n\n/*\n** Set up a database file with the following properties:\n**\n**   * Page size is 1024 bytes.\n**   * Block size is 64 KB.\n**   * Contains 5000 key-value pairs starting at 0 from the\n**     datasource returned getDatasource().\n*/\nstatic void setup_populate_db2(void){\n  Datasource *pData;\n  int ii;\n  int rc;\n  int nBlocksize = 64*1024;\n  int nPagesize = 1024;\n  int nWritebuffer = 4*1024;\n  lsm_db *pDb;\n\n  testDeleteLsmdb(LSMTEST6_TESTDB);\n  rc = lsm_new(tdb_lsm_env(), &pDb);\n  if( rc==LSM_OK ) rc = lsm_open(pDb, LSMTEST6_TESTDB);\n\n  lsm_config(pDb, LSM_CONFIG_BLOCK_SIZE, &nBlocksize); \n  lsm_config(pDb, LSM_CONFIG_PAGE_SIZE, &nPagesize); \n  lsm_config(pDb, LSM_CONFIG_AUTOFLUSH, &nWritebuffer); \n\n  pData = getDatasource();\n  for(ii=0; rc==LSM_OK && ii<5000; ii++){\n    void *pKey; int nKey;\n    void *pVal; int nVal;\n    testDatasourceEntry(pData, ii, &pKey, &nKey, &pVal, &nVal);\n    lsm_insert(pDb, pKey, nKey, pVal, nVal);\n  }\n  testDatasourceFree(pData);\n  lsm_close(pDb);\n\n  testSaveDb(LSMTEST6_TESTDB, \"log\");\n  assert( rc==LSM_OK );\n}\n\n/*\n** Test the results of OOM conditions in lsm_new().\n*/\nstatic void simple_oom_1(OomTest *pOom){\n  int rc;\n  lsm_db *pDb;\n\n  rc = lsm_new(tdb_lsm_env(), &pDb);\n  testOomAssertRc(pOom, rc);\n\n  lsm_close(pDb);\n}\n\n/*\n** Test the results of OOM conditions in lsm_open().\n*/\nstatic void simple_oom_2(OomTest *pOom){\n  int rc;\n  lsm_db *pDb;\n\n  rc = lsm_new(tdb_lsm_env(), &pDb);\n  if( rc==LSM_OK ){\n    rc = lsm_open(pDb, \"testdb.lsm\");\n  }\n  testOomAssertRc(pOom, rc);\n\n  lsm_close(pDb);\n}\n\n/*\n** Test the results of OOM conditions in simple fetch operations.\n*/\nstatic void simple_oom_3(OomTest *pOom){\n  int rc = LSM_OK;\n  lsm_db *pDb;\n\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n\n  testOomFetchStr(pOom, pDb, \"four\",  \"sixteen\",    &rc);\n  testOomFetchStr(pOom, pDb, \"seven\", \"fourtynine\", &rc);\n  testOomFetchStr(pOom, pDb, \"one\",   \"one\",        &rc);\n  testOomFetchStr(pOom, pDb, \"eight\", \"sixtyfour\",  &rc);\n\n  lsm_close(pDb);\n}\n\n/*\n** Test the results of OOM conditions in simple write operations.\n*/\nstatic void simple_oom_4(OomTest *pOom){\n  int rc = LSM_OK;\n  lsm_db *pDb;\n\n  testDeleteLsmdb(LSMTEST6_TESTDB);\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n\n  testOomWriteStr(pOom, pDb, \"123\", \"onetwothree\", &rc);\n  testOomWriteStr(pOom, pDb, \"456\", \"fourfivesix\", &rc);\n  testOomWriteStr(pOom, pDb, \"789\", \"seveneightnine\", &rc);\n  testOomWriteStr(pOom, pDb, \"123\", \"teneleventwelve\", &rc);\n  testOomWriteStr(pOom, pDb, \"456\", \"fourteenfifteensixteen\", &rc);\n\n  lsm_close(pDb);\n}\n\nstatic void simple_oom_5(OomTest *pOom){\n  Datasource *pData = getDatasource();\n  int rc = LSM_OK;\n  lsm_db *pDb;\n\n  testRestoreDb(LSMTEST6_TESTDB, \"log\");\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n\n  testOomFetchData(pOom, pDb, pData, 3333, &rc);\n  testOomFetchData(pOom, pDb, pData, 0, &rc);\n  testOomFetchData(pOom, pDb, pData, 4999, &rc);\n\n  lsm_close(pDb);\n  testDatasourceFree(pData);\n}\n\nstatic void simple_oom_6(OomTest *pOom){\n  Datasource *pData = getDatasource();\n  int rc = LSM_OK;\n  lsm_db *pDb;\n\n  testRestoreDb(LSMTEST6_TESTDB, \"log\");\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n\n  testOomWriteData(pOom, pDb, pData, 5000, &rc);\n  testOomWriteData(pOom, pDb, pData, 5001, &rc);\n  testOomWriteData(pOom, pDb, pData, 5002, &rc);\n  testOomFetchData(pOom, pDb, pData, 5001, &rc);\n  testOomFetchData(pOom, pDb, pData, 1234, &rc);\n\n  lsm_close(pDb);\n  testDatasourceFree(pData);\n}\n\nstatic void simple_oom_7(OomTest *pOom){\n  Datasource *pData = getDatasource();\n  int rc = LSM_OK;\n  lsm_db *pDb;\n\n  testRestoreDb(LSMTEST6_TESTDB, \"log\");\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n  testOomScan(pOom, pDb, 0, \"abc\", 3, 20, &rc);\n  lsm_close(pDb);\n  testDatasourceFree(pData);\n}\n\nstatic void simple_oom_8(OomTest *pOom){\n  Datasource *pData = getDatasource();\n  int rc = LSM_OK;\n  lsm_db *pDb;\n  testRestoreDb(LSMTEST6_TESTDB, \"log\");\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb, &rc);\n  testOomScan(pOom, pDb, 1, \"xyz\", 3, 20, &rc);\n  lsm_close(pDb);\n  testDatasourceFree(pData);\n}\n\n/*\n** This test case has two clients connected to a database. The first client\n** hits an OOM while writing to the database. Check that the second \n** connection is still able to query the db following the OOM.\n*/\nstatic void simple_oom2_1(OomTest *pOom){\n  const int nRecord = 100;        /* Number of records initially in db */\n  const int nIns = 10;            /* Number of records inserted with OOM */\n\n  Datasource *pData = getDatasource();\n  int rc = LSM_OK;\n  lsm_db *pDb1;\n  lsm_db *pDb2;\n  int i;\n\n  testDeleteLsmdb(LSMTEST6_TESTDB);\n\n  /* Open the two connections. Initialize the in-memory tree so that it\n  ** contains 100 records. Do all this with OOM injection disabled. */\n  testOomEnable(pOom, 0);\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb1, &rc);\n  testOomOpen(pOom, LSMTEST6_TESTDB, &pDb2, &rc);\n  for(i=0; i<nRecord; i++){\n    testOomWriteData(pOom, pDb1, pData, i, &rc);\n  }\n  testOomEnable(pOom, 1);\n  assert( rc==0 );\n\n  /* Insert 10 more records using pDb1. Stop when an OOM is encountered. */\n  for(i=nRecord; i<nRecord+nIns; i++){\n    testOomWriteData(pOom, pDb1, pData, i, &rc);\n    if( rc ) break;\n  }\n  testOomAssertRc(pOom, rc);\n\n  /* Switch off OOM injection. Write a few rows using pDb2. Then check\n  ** that the database may be successfully queried.  */\n  testOomEnable(pOom, 0);\n  rc = 0;\n  for(; i<nRecord+nIns && rc==0; i++){\n    testOomWriteData(pOom, pDb2, pData, i, &rc);\n  }\n  for(i=0; i<nRecord+nIns; i++) testOomFetchData(pOom, pDb2, pData, i, &rc);\n  testOomEnable(pOom, 1);\n\n  lsm_close(pDb1);\n  lsm_close(pDb2);\n  testDatasourceFree(pData);\n}\n\n\nstatic void do_test_oom1(const char *zPattern, int *pRc){\n  struct SimpleOom {\n    const char *zName;\n    void (*xSetup)(void);\n    void (*xFunc)(OomTest *);\n  } aSimple[] = {\n    { \"oom1.lsm.1\", setup_delete_db,    simple_oom_1 },\n    { \"oom1.lsm.2\", setup_delete_db,    simple_oom_2 },\n    { \"oom1.lsm.3\", setup_populate_db,  simple_oom_3 },\n    { \"oom1.lsm.4\", setup_delete_db,    simple_oom_4 },\n    { \"oom1.lsm.5\", setup_populate_db2, simple_oom_5 },\n    { \"oom1.lsm.6\", setup_populate_db2, simple_oom_6 },\n    { \"oom1.lsm.7\", setup_populate_db2, simple_oom_7 },\n    { \"oom1.lsm.8\", setup_populate_db2, simple_oom_8 },\n\n    { \"oom2.lsm.1\", setup_delete_db,    simple_oom2_1 },\n  };\n  int i;\n\n  for(i=0; i<ArraySize(aSimple); i++){\n    if( *pRc==0 && testCaseBegin(pRc, zPattern, \"%s\", aSimple[i].zName) ){\n      OomTest t;\n\n      if( aSimple[i].xSetup ){\n        aSimple[i].xSetup();\n      }\n\n      for(testOomStart(&t); testOomContinue(&t); testOomNext(&t)){\n        aSimple[i].xFunc(&t);\n      }\n\n      printf(\"(%d injections).\", t.iNext-2);\n      testCaseFinish( (*pRc = testOomFinish(&t)) );\n      testMallocOom(tdb_lsm_env(), 0, 0, 0, 0);\n    }\n  }\n}\n\nvoid test_oom(\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  do_test_oom1(zPattern, pRc);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest7.c",
    "content": "\n\n#include \"lsmtest.h\"\n\n\n/*\n** Test that the rules for when lsm_csr_next() and lsm_csr_prev() are\n** enforced. Specifically:\n**\n**   * Both functions always return LSM_MISUSE if the cursor is at EOF\n**     when they are called.\n**\n**   * lsm_csr_next() may only be used after lsm_csr_seek(LSM_SEEK_GE) or \n**     lsm_csr_first(). \n**\n**   * lsm_csr_prev() may only be used after lsm_csr_seek(LSM_SEEK_LE) or \n**     lsm_csr_last().\n*/\nstatic void do_test_api1_lsm(lsm_db *pDb, int *pRc){\n  int ret;\n  lsm_cursor *pCsr;\n  lsm_cursor *pCsr2;\n  int nKey;\n  const void *pKey;\n\n  ret = lsm_csr_open(pDb, &pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_seek(pCsr, \"jjj\", 3, LSM_SEEK_GE);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_seek(pCsr, \"jjj\", 3, LSM_SEEK_LE);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n\n  ret = lsm_csr_seek(pCsr, \"jjj\", 3, LSM_SEEK_LEFAST);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_key(pCsr, &pKey, &nKey);\n  testCompareInt(LSM_OK, ret, pRc);\n\n  ret = lsm_csr_open(pDb, &pCsr2);\n  testCompareInt(LSM_OK, ret, pRc);\n\n  ret = lsm_csr_seek(pCsr2, pKey, nKey, LSM_SEEK_EQ);\n  testCompareInt(LSM_OK, ret, pRc);\n  testCompareInt(1, lsm_csr_valid(pCsr2), pRc);\n  ret = lsm_csr_next(pCsr2);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n  ret = lsm_csr_prev(pCsr2);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  lsm_csr_close(pCsr2);\n\n  ret = lsm_csr_first(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_last(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_first(pCsr);\n  while( lsm_csr_valid(pCsr) ){\n    ret = lsm_csr_next(pCsr);\n    testCompareInt(LSM_OK, ret, pRc);\n  }\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  ret = lsm_csr_last(pCsr);\n  while( lsm_csr_valid(pCsr) ){\n    ret = lsm_csr_prev(pCsr);\n    testCompareInt(LSM_OK, ret, pRc);\n  }\n  ret = lsm_csr_prev(pCsr);\n  testCompareInt(LSM_OK, ret, pRc);\n  ret = lsm_csr_next(pCsr);\n  testCompareInt(LSM_MISUSE, ret, pRc);\n\n  lsm_csr_close(pCsr);\n}\n\nstatic void do_test_api1(const char *zPattern, int *pRc){\n  if( testCaseBegin(pRc, zPattern, \"api1.lsm\") ){\n    const DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 10, 15, 200, 250 };\n    Datasource *pData;\n    TestDb *pDb;\n    int rc = 0;\n\n    pDb = testOpen(\"lsm_lomem\", 1, &rc);\n    pData = testDatasourceNew(&defn);\n    testWriteDatasourceRange(pDb, pData, 0, 1000, pRc);\n\n    do_test_api1_lsm(tdb_lsm(pDb), pRc);\n\n    testDatasourceFree(pData);\n    testClose(&pDb);\n\n    testCaseFinish(*pRc);\n  }\n}\n\nstatic lsm_db *newLsmConnection(\n  const char *zDb, \n  int nPgsz, \n  int nBlksz,\n  int *pRc\n){\n  lsm_db *db = 0;\n  if( *pRc==0 ){\n    int n1 = nPgsz;\n    int n2 = nBlksz;\n    *pRc = lsm_new(tdb_lsm_env(), &db);\n    if( *pRc==0 ){\n      if( n1 ) lsm_config(db, LSM_CONFIG_PAGE_SIZE, &n1);\n      if( n2 ) lsm_config(db, LSM_CONFIG_BLOCK_SIZE, &n2);\n      *pRc = lsm_open(db, \"testdb.lsm\");\n    }\n  }\n  return db;\n}\n\nstatic void testPagesize(lsm_db *db, int nPgsz, int nBlksz, int *pRc){\n  if( *pRc==0 ){\n    int n1 = 0;\n    int n2 = 0;\n\n    lsm_config(db, LSM_CONFIG_PAGE_SIZE, &n1);\n    lsm_config(db, LSM_CONFIG_BLOCK_SIZE, &n2);\n\n    testCompareInt(n1, nPgsz, pRc);\n    testCompareInt(n2, nBlksz, pRc);\n  }\n}\n\n/*\n** Test case \"api2\" tests that the default page and block sizes of a \n** database may only be modified before lsm_open() is called. And that\n** after lsm_open() is called lsm_config() may be used to read the \n** actual page and block size of the db.\n*/\nstatic void do_test_api2(const char *zPattern, int *pRc){\n  if( *pRc==0 && testCaseBegin(pRc, zPattern, \"api2.lsm\") ){\n    lsm_db *db1 = 0;\n    lsm_db *db2 = 0;\n\n    testDeleteLsmdb(\"testdb.lsm\");\n    db1 = newLsmConnection(\"testdb.lsm\", 0, 0, pRc);\n    testPagesize(db1, 4096, 1024, pRc);\n    db2 = newLsmConnection(\"testdb.lsm\", 1024, 64*1024, pRc);\n    testPagesize(db2, 4096, 1024, pRc);\n    lsm_close(db1);\n    lsm_close(db2);\n\n    testDeleteLsmdb(\"testdb.lsm\");\n    db1 = newLsmConnection(\"testdb.lsm\", 1024, 64*1024, pRc);\n    testPagesize(db1, 1024, 64*1024, pRc);\n    db2 = newLsmConnection(\"testdb.lsm\", 0, 0, pRc);\n    testPagesize(db2, 1024, 64*1024, pRc);\n    lsm_close(db1);\n    lsm_close(db2);\n\n    testDeleteLsmdb(\"testdb.lsm\");\n    db1 = newLsmConnection(\"testdb.lsm\", 8192, 2*1024, pRc);\n    testPagesize(db1, 8192, 2*1024, pRc);\n    db2 = newLsmConnection(\"testdb.lsm\", 1024, 64*1024, pRc);\n    testPagesize(db2, 8192, 2*1024, pRc);\n    lsm_close(db1);\n    lsm_close(db2);\n\n    testCaseFinish(*pRc);\n  }\n}\n\nvoid test_api(\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  do_test_api1(zPattern, pRc);\n  do_test_api2(zPattern, pRc);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest8.c",
    "content": "\n/*\n** This file contains test cases to verify that \"live-recovery\" following\n** a mid-transaction failure of a writer process.\n*/\n\n\n/* \n** This test file includes lsmInt.h to get access to the definition of the\n** ShmHeader structure. This is required to cause strategic damage to the\n** shared memory header as part of recovery testing.\n*/\n#include \"lsmInt.h\"\n\n#include \"lsmtest.h\"\n\ntypedef struct SetupStep SetupStep;\nstruct SetupStep {\n  int bFlush;                     /* Flush to disk and checkpoint */\n  int iInsStart;                  /* First key-value from ds to insert */\n  int nIns;                       /* Number of rows to insert */\n  int iDelStart;                  /* First key from ds to delete */\n  int nDel;                       /* Number of rows to delete */\n};\n\nstatic void doSetupStep(\n  TestDb *pDb, \n  Datasource *pData, \n  const SetupStep *pStep, \n  int *pRc\n){\n  testWriteDatasourceRange(pDb, pData, pStep->iInsStart, pStep->nIns, pRc);\n  testDeleteDatasourceRange(pDb, pData, pStep->iDelStart, pStep->nDel, pRc);\n  if( *pRc==0 ){\n    int nSave = -1;\n    int nBuf = 64;\n    lsm_db *db = tdb_lsm(pDb);\n\n    lsm_config(db, LSM_CONFIG_AUTOFLUSH, &nSave);\n    lsm_config(db, LSM_CONFIG_AUTOFLUSH, &nBuf);\n    lsm_begin(db, 1);\n    lsm_commit(db, 0);\n    lsm_config(db, LSM_CONFIG_AUTOFLUSH, &nSave);\n\n    *pRc = lsm_work(db, 0, 0, 0);\n    if( *pRc==0 ){\n      *pRc = lsm_checkpoint(db, 0);\n    }\n  }\n}\n\nstatic void doSetupStepArray(\n  TestDb *pDb, \n  Datasource *pData, \n  const SetupStep *aStep, \n  int nStep\n){\n  int i;\n  for(i=0; i<nStep; i++){\n    int rc = 0;\n    doSetupStep(pDb, pData, &aStep[i], &rc);\n    assert( rc==0 );\n  }\n}\n\nstatic void setupDatabase1(TestDb *pDb, Datasource **ppData){\n  const SetupStep aStep[] = {\n    { 0,                                  1,     2000, 0, 0 },\n    { 1,                                  0,     0, 0, 0 },\n    { 0,                                  10001, 1000, 0, 0 },\n  };\n  const DatasourceDefn defn = {TEST_DATASOURCE_RANDOM, 12, 16, 100, 500};\n  Datasource *pData;\n\n  pData = testDatasourceNew(&defn);\n  doSetupStepArray(pDb, pData, aStep, ArraySize(aStep));\n  if( ppData ){\n    *ppData = pData;\n  }else{\n    testDatasourceFree(pData);\n  }\n}\n\n#include <stdio.h>\nvoid testReadFile(const char *zFile, int iOff, void *pOut, int nByte, int *pRc){\n  if( *pRc==0 ){\n    FILE *fd;\n    fd = fopen(zFile, \"rb\");\n    if( fd==0 ){\n      *pRc = 1;\n    }else{\n      if( 0!=fseek(fd, iOff, SEEK_SET) ){\n        *pRc = 1;\n      }else{\n        assert( nByte>=0 );\n        if( (size_t)nByte!=fread(pOut, 1, nByte, fd) ){\n          *pRc = 1;\n        }\n      }\n      fclose(fd);\n    }\n  }\n}\n\nvoid testWriteFile(\n  const char *zFile, \n  int iOff, \n  void *pOut, \n  int nByte, \n  int *pRc\n){\n  if( *pRc==0 ){\n    FILE *fd;\n    fd = fopen(zFile, \"r+b\");\n    if( fd==0 ){\n      *pRc = 1;\n    }else{\n      if( 0!=fseek(fd, iOff, SEEK_SET) ){\n        *pRc = 1;\n      }else{\n        assert( nByte>=0 );\n        if( (size_t)nByte!=fwrite(pOut, 1, nByte, fd) ){\n          *pRc = 1;\n        }\n      }\n      fclose(fd);\n    }\n  }\n}\n\nstatic ShmHeader *getShmHeader(const char *zDb){\n  int rc = 0;\n  char *zShm = testMallocPrintf(\"%s-shm\", zDb);\n  ShmHeader *pHdr;\n\n  pHdr = testMalloc(sizeof(ShmHeader));\n  testReadFile(zShm, 0, (void *)pHdr, sizeof(ShmHeader), &rc);\n  assert( rc==0 );\n\n  return pHdr;\n}\n\n/*\n** This function makes a copy of the three files associated with LSM \n** database zDb (i.e. if zDb is \"test.db\", it makes copies of \"test.db\",\n** \"test.db-log\" and \"test.db-shm\").\n**\n** It then opens a new database connection to the copy with the xLock() call\n** instrumented so that it appears that some other process already connected\n** to the db (holding a shared lock on DMS2). This prevents recovery from\n** running. Then:\n**\n**    1) Check that the checksum of the database is zCksum. \n**    2) Write a few keys to the database. Then delete the same keys. \n**    3) Check that the checksum is zCksum.\n**    4) Flush the db to disk and run a checkpoint. \n**    5) Check once more that the checksum is still zCksum.\n*/\nstatic void doLiveRecovery(const char *zDb, const char *zCksum, int *pRc){\n  if( *pRc==LSM_OK ){\n    const DatasourceDefn defn = {TEST_DATASOURCE_RANDOM, 20, 25, 100, 500};\n    Datasource *pData;\n    const char *zCopy = \"testcopy.lsm\";\n    char zCksum2[TEST_CKSUM_BYTES];\n    TestDb *pDb = 0;\n    int rc;\n\n    pData = testDatasourceNew(&defn);\n\n    testCopyLsmdb(zDb, zCopy);\n    rc = tdb_lsm_open(\"test_no_recovery=1\", zCopy, 0, &pDb);\n    if( rc==0 ){\n      ShmHeader *pHdr;\n      lsm_db *db;\n      testCksumDatabase(pDb, zCksum2);\n      testCompareStr(zCksum, zCksum2, &rc);\n\n      testWriteDatasourceRange(pDb, pData, 1, 10, &rc);\n      testDeleteDatasourceRange(pDb, pData, 1, 10, &rc);\n\n      /* Test that the two tree-headers are now consistent. */\n      pHdr = getShmHeader(zCopy);\n      if( rc==0 && memcmp(&pHdr->hdr1, &pHdr->hdr2, sizeof(pHdr->hdr1)) ){\n        rc = 1;\n      }\n      testFree(pHdr);\n\n      if( rc==0 ){\n        int nBuf = 64;\n        db = tdb_lsm(pDb);\n        lsm_config(db, LSM_CONFIG_AUTOFLUSH, &nBuf);\n        lsm_begin(db, 1);\n        lsm_commit(db, 0);\n        rc = lsm_work(db, 0, 0, 0);\n      }\n\n      testCksumDatabase(pDb, zCksum2);\n      testCompareStr(zCksum, zCksum2, &rc);\n    }\n\n    testDatasourceFree(pData);\n    testClose(&pDb);\n    testDeleteLsmdb(zCopy);\n    *pRc = rc;\n  }\n}\n\nstatic void doWriterCrash1(int *pRc){\n  const int nWrite = 2000;\n  const int nStep = 10;\n  const int iWriteStart = 20000;\n  int rc = 0;\n  TestDb *pDb = 0;\n  Datasource *pData = 0;\n\n  rc = tdb_lsm_open(\"autowork=0\", \"testdb.lsm\", 1, &pDb);\n  if( rc==0 ){\n    int iDot = 0;\n    char zCksum[TEST_CKSUM_BYTES];\n    int i;\n    setupDatabase1(pDb, &pData);\n    testCksumDatabase(pDb, zCksum);\n    testBegin(pDb, 2, &rc);\n    for(i=0; rc==0 && i<nWrite; i+=nStep){\n      testCaseProgress(i, nWrite, testCaseNDot(), &iDot);\n      testWriteDatasourceRange(pDb, pData, iWriteStart+i, nStep, &rc);\n      doLiveRecovery(\"testdb.lsm\", zCksum, &rc);\n    }\n  }\n  testCommit(pDb, 0, &rc);\n  testClose(&pDb);\n  testDatasourceFree(pData);\n  *pRc = rc;\n}\n\n/*\n** This test case verifies that inconsistent tree-headers in shared-memory\n** are resolved correctly. \n*/\nstatic void doWriterCrash2(int *pRc){\n  int rc = 0;\n  TestDb *pDb = 0;\n  Datasource *pData = 0;\n\n  rc = tdb_lsm_open(\"autowork=0\", \"testdb.lsm\", 1, &pDb);\n  if( rc==0 ){\n    ShmHeader *pHdr1;\n    ShmHeader *pHdr2;\n    char zCksum1[TEST_CKSUM_BYTES];\n    char zCksum2[TEST_CKSUM_BYTES];\n\n    pHdr1 = testMalloc(sizeof(ShmHeader));\n    pHdr2 = testMalloc(sizeof(ShmHeader));\n    setupDatabase1(pDb, &pData);\n\n    /* Grab a copy of the shared-memory header. And the db checksum */\n    testReadFile(\"testdb.lsm-shm\", 0, (void *)pHdr1, sizeof(ShmHeader), &rc);\n    testCksumDatabase(pDb, zCksum1);\n\n    /* Modify the database */\n    testBegin(pDb, 2, &rc);\n    testWriteDatasourceRange(pDb, pData, 30000, 200, &rc);\n    testCommit(pDb, 0, &rc);\n\n    /* Grab a second copy of the shared-memory header. And the db checksum */\n    testReadFile(\"testdb.lsm-shm\", 0, (void *)pHdr2, sizeof(ShmHeader), &rc);\n    testCksumDatabase(pDb, zCksum2);\n    doLiveRecovery(\"testdb.lsm\", zCksum2, &rc);\n\n    /* If both tree-headers are valid, tree-header-1 is used. */\n    memcpy(&pHdr2->hdr1, &pHdr1->hdr1, sizeof(pHdr1->hdr1));\n    pHdr2->bWriter = 1;\n    testWriteFile(\"testdb.lsm-shm\", 0, (void *)pHdr2, sizeof(ShmHeader), &rc);\n    doLiveRecovery(\"testdb.lsm\", zCksum1, &rc);\n\n    /* If both tree-headers are valid, tree-header-1 is used. */\n    memcpy(&pHdr2->hdr1, &pHdr2->hdr2, sizeof(pHdr1->hdr1));\n    memcpy(&pHdr2->hdr2, &pHdr1->hdr1, sizeof(pHdr1->hdr1));\n    pHdr2->bWriter = 1;\n    testWriteFile(\"testdb.lsm-shm\", 0, (void *)pHdr2, sizeof(ShmHeader), &rc);\n    doLiveRecovery(\"testdb.lsm\", zCksum2, &rc);\n\n    /* If tree-header 1 is invalid, tree-header-2 is used */\n    memcpy(&pHdr2->hdr2, &pHdr2->hdr1, sizeof(pHdr1->hdr1));\n    pHdr2->hdr1.aCksum[0] = 5;\n    pHdr2->hdr1.aCksum[0] = 6;\n    pHdr2->bWriter = 1;\n    testWriteFile(\"testdb.lsm-shm\", 0, (void *)pHdr2, sizeof(ShmHeader), &rc);\n    doLiveRecovery(\"testdb.lsm\", zCksum2, &rc);\n\n    /* If tree-header 2 is invalid, tree-header-1 is used */\n    memcpy(&pHdr2->hdr1, &pHdr2->hdr2, sizeof(pHdr1->hdr1));\n    pHdr2->hdr2.aCksum[0] = 5;\n    pHdr2->hdr2.aCksum[0] = 6;\n    pHdr2->bWriter = 1;\n    testWriteFile(\"testdb.lsm-shm\", 0, (void *)pHdr2, sizeof(ShmHeader), &rc);\n    doLiveRecovery(\"testdb.lsm\", zCksum2, &rc);\n\n    testFree(pHdr1);\n    testFree(pHdr2);\n    testClose(&pDb);\n  }\n\n  *pRc = rc;\n}\n\nvoid do_writer_crash_test(const char *zPattern, int *pRc){\n  struct Test {\n    const char *zName;\n    void (*xFunc)(int *);\n  } aTest[] = {\n    { \"writercrash1.lsm\", doWriterCrash1 },\n    { \"writercrash2.lsm\", doWriterCrash2 },\n  };\n  int i;\n  for(i=0; i<ArraySize(aTest); i++){\n    struct Test *p = &aTest[i];\n    if( testCaseBegin(pRc, zPattern, p->zName) ){\n      p->xFunc(pRc);\n      testCaseFinish(*pRc);\n    }\n  }\n\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest9.c",
    "content": "\n#include \"lsmtest.h\"\n\n#define DATA_SEQUENTIAL TEST_DATASOURCE_SEQUENCE\n#define DATA_RANDOM     TEST_DATASOURCE_RANDOM\n\ntypedef struct Datatest4 Datatest4;\n\n/*\n** Test overview:\n**\n**   1. Insert (Datatest4.nRec) records into a database.\n**\n**   2. Repeat (Datatest4.nRepeat) times:\n**\n**      2a. Delete 2/3 of the records in the database.\n**\n**      2b. Run lsm_work(nMerge=1).\n**\n**      2c. Insert as many records as were deleted in 2a.\n**\n**      2d. Check database content is as expected.\n**\n**      2e. If (Datatest4.bReopen) is true, close and reopen the database.\n*/\nstruct Datatest4 {\n  /* Datasource definition */\n  DatasourceDefn defn;\n\n  int nRec;\n  int nRepeat;\n  int bReopen;\n};\n\nstatic void doDataTest4(\n  const char *zSystem,            /* Database system to test */\n  Datatest4 *p,                   /* Structure containing test parameters */\n  int *pRc                        /* OUT: Error code */\n){\n  lsm_db *db = 0;\n  TestDb *pDb;\n  TestDb *pControl;\n  Datasource *pData;\n  int i;\n  int rc = 0;\n  int iDot = 0;\n  int bMultiThreaded = 0;         /* True for MT LSM database */\n\n  int nRecOn3 = (p->nRec / 3);\n  int iData = 0;\n\n  /* Start the test case, open a database and allocate the datasource. */\n  rc = testControlDb(&pControl);\n  pDb = testOpen(zSystem, 1, &rc);\n  pData = testDatasourceNew(&p->defn);\n  if( rc==0 ){\n    db = tdb_lsm(pDb);\n    bMultiThreaded = tdb_lsm_multithread(pDb);\n  }\n\n  testWriteDatasourceRange(pControl, pData, iData, nRecOn3*3, &rc);\n  testWriteDatasourceRange(pDb,      pData, iData, nRecOn3*3, &rc);\n\n  for(i=0; rc==0 && i<p->nRepeat; i++){\n\n    testDeleteDatasourceRange(pControl, pData, iData, nRecOn3*2, &rc);\n    testDeleteDatasourceRange(pDb,      pData, iData, nRecOn3*2, &rc);\n\n    if( db ){\n      int nDone;\n#if 0\n      fprintf(stderr, \"lsm_work() start...\\n\"); fflush(stderr);\n#endif\n      do {\n        nDone = 0;\n        rc = lsm_work(db, 1, (1<<30), &nDone);\n      }while( rc==0 && nDone>0 );\n      if( bMultiThreaded && rc==LSM_BUSY ) rc = LSM_OK;\n#if 0 \n      fprintf(stderr, \"lsm_work() done...\\n\"); fflush(stderr);\n#endif\n    }\n\nif( i+1<p->nRepeat ){\n    iData += (nRecOn3*2);\n    testWriteDatasourceRange(pControl, pData, iData+nRecOn3, nRecOn3*2, &rc);\n    testWriteDatasourceRange(pDb,      pData, iData+nRecOn3, nRecOn3*2, &rc);\n\n    testCompareDb(pData, nRecOn3*3, iData, pControl, pDb, &rc);\n\n    /* If Datatest4.bReopen is true, close and reopen the database */\n    if( p->bReopen ){\n      testReopen(&pDb, &rc);\n      if( rc==0 ) db = tdb_lsm(pDb);\n    }\n}\n\n    /* Update the progress dots... */\n    testCaseProgress(i, p->nRepeat, testCaseNDot(), &iDot);\n  }\n\n  testClose(&pDb);\n  testClose(&pControl);\n  testDatasourceFree(pData);\n  testCaseFinish(rc);\n  *pRc = rc;\n}\n\nstatic char *getName4(const char *zSystem, Datatest4 *pTest){\n  char *zRet;\n  char *zData;\n  zData = testDatasourceName(&pTest->defn);\n  zRet = testMallocPrintf(\"data4.%s.%s.%d.%d.%d\", \n      zSystem, zData, pTest->nRec, pTest->nRepeat, pTest->bReopen\n  );\n  testFree(zData);\n  return zRet;\n}\n\nvoid test_data_4(\n  const char *zSystem,            /* Database system name */\n  const char *zPattern,           /* Run test cases that match this pattern */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Datatest4 aTest[] = {\n      /* defn,                                 nRec, nRepeat, bReopen */\n    { {DATA_RANDOM,     20,25,     500,600}, 10000,      10,       0   },\n    { {DATA_RANDOM,     20,25,     500,600}, 10000,      10,       1   },\n  };\n\n  int i;\n\n  for(i=0; *pRc==LSM_OK && i<ArraySize(aTest); i++){\n    char *zName = getName4(zSystem, &aTest[i]);\n    if( testCaseBegin(pRc, zPattern, \"%s\", zName) ){\n      doDataTest4(zSystem, &aTest[i], pRc);\n    }\n    testFree(zName);\n  }\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_bt.c",
    "content": "\n#include \"lsmtest.h\"\n#include \"bt.h\"\n\nint do_bt(int nArg, char **azArg){\n  struct Option {\n    const char *zName;\n    int bPgno;\n    int eOpt;\n  } aOpt [] = { \n    { \"dbhdr\",          0, BT_INFO_HDRDUMP },\n    { \"filename\",       0, BT_INFO_FILENAME },\n    { \"block_freelist\", 0, BT_INFO_BLOCK_FREELIST },\n    { \"page_freelist\",  0, BT_INFO_PAGE_FREELIST },\n    { \"filename\",       0, BT_INFO_FILENAME },\n    { \"page\",           1, BT_INFO_PAGEDUMP },\n    { \"page_ascii\",     1, BT_INFO_PAGEDUMP_ASCII },\n    { \"leaks\",          0, BT_INFO_PAGE_LEAKS },\n    { 0, 0 } \n  };\n  int iOpt;\n  int rc;\n  bt_info buf;\n  char *zOpt;\n  char *zFile;\n\n  bt_db *db = 0;\n\n  if( nArg<2 ){\n    testPrintUsage(\"FILENAME OPTION ...\");\n    return -1;\n  }\n  zFile = azArg[0];\n  zOpt = azArg[1];\n\n  rc = testArgSelect(aOpt, \"option\", zOpt, &iOpt);\n  if( rc!=0 ) return rc;\n  if( nArg!=2+aOpt[iOpt].bPgno ){\n    testPrintFUsage(\"FILENAME %s %s\", zOpt, aOpt[iOpt].bPgno ? \"PGNO\" : \"\");\n    return -4;\n  }\n\n  rc = sqlite4BtNew(sqlite4_env_default(), 0, &db);\n  if( rc!=SQLITE4_OK ){\n    testPrintError(\"sqlite4BtNew() failed: %d\", rc);\n    return -2;\n  }\n  rc = sqlite4BtOpen(db, zFile);\n  if( rc!=SQLITE4_OK ){\n    testPrintError(\"sqlite4BtOpen() failed: %d\", rc);\n    return -3;\n  }\n\n  buf.eType = aOpt[iOpt].eOpt;\n  buf.pgno = 0;\n  sqlite4_buffer_init(&buf.output, 0);\n\n  if( aOpt[iOpt].bPgno ){\n    buf.pgno = (u32)atoi(azArg[2]);\n  }\n\n  rc = sqlite4BtControl(db, BT_CONTROL_INFO, &buf);\n  if( rc!=SQLITE4_OK ){\n    testPrintError(\"sqlite4BtControl() failed: %d\\n\", rc);\n    return -4;\n  }\n\n  printf(\"%s\\n\", (char*)buf.output.p);\n  sqlite4_buffer_clear(&buf.output);\n  return 0;\n}\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_datasource.c",
    "content": "\n\n#include \"lsmtest.h\"\n\nstruct Datasource {\n  int eType;\n\n  int nMinKey;\n  int nMaxKey;\n  int nMinVal;\n  int nMaxVal;\n\n  char *aKey;\n  char *aVal;\n};\n\nvoid testDatasourceEntry(\n  Datasource *p, \n  int iData, \n  void **ppKey, int *pnKey,\n  void **ppVal, int *pnVal\n){\n  assert( (ppKey==0)==(pnKey==0) );\n  assert( (ppVal==0)==(pnVal==0) );\n\n  if( ppKey ){\n    int nKey = 0;\n    switch( p->eType ){\n      case TEST_DATASOURCE_RANDOM: {\n        int nRange = (1 + p->nMaxKey - p->nMinKey);\n        nKey = (int)( testPrngValue((u32)iData) % nRange ) + p->nMinKey; \n        testPrngString((u32)iData, p->aKey, nKey);\n        break;\n      }\n      case TEST_DATASOURCE_SEQUENCE:\n        nKey = sprintf(p->aKey, \"%012d\", iData);\n        break;\n    }\n    *ppKey = p->aKey;\n    *pnKey = nKey;\n  }\n  if( ppVal ){\n    u32 nVal = testPrngValue((u32)iData)%(1+p->nMaxVal-p->nMinVal)+p->nMinVal;\n    testPrngString((u32)~iData, p->aVal, (int)nVal);\n    *ppVal = p->aVal;\n    *pnVal = (int)nVal;\n  }\n}\n\nvoid testDatasourceFree(Datasource *p){\n  testFree(p);\n}\n\n/*\n** Return a pointer to a nul-terminated string that corresponds to the\n** contents of the datasource-definition passed as the first argument.\n** The caller should eventually free the returned pointer using testFree().\n*/\nchar *testDatasourceName(const DatasourceDefn *p){\n  char *zRet;\n  zRet = testMallocPrintf(\"%s.(%d-%d).(%d-%d)\",\n      (p->eType==TEST_DATASOURCE_SEQUENCE ? \"seq\" : \"rnd\"),\n      p->nMinKey, p->nMaxKey,\n      p->nMinVal, p->nMaxVal\n  );\n  return zRet;\n}\n\nDatasource *testDatasourceNew(const DatasourceDefn *pDefn){\n  Datasource *p;\n  int nMinKey; \n  int nMaxKey;\n  int nMinVal;\n  int nMaxVal; \n\n  if( pDefn->eType==TEST_DATASOURCE_SEQUENCE ){\n    nMinKey = 128;\n    nMaxKey = 128;\n  }else{\n    nMinKey = MAX(0, pDefn->nMinKey);\n    nMaxKey = MAX(nMinKey, pDefn->nMaxKey);\n  }\n  nMinVal = MAX(0, pDefn->nMinVal);\n  nMaxVal = MAX(nMinVal, pDefn->nMaxVal);\n\n  p = (Datasource *)testMalloc(sizeof(Datasource) + nMaxKey + nMaxVal + 1);\n  p->eType = pDefn->eType;\n  p->nMinKey = nMinKey;\n  p->nMinVal = nMinVal;\n  p->nMaxKey = nMaxKey;\n  p->nMaxVal = nMaxVal;\n  \n  p->aKey = (char *)&p[1];\n  p->aVal = &p->aKey[nMaxKey];\n  return p;\n};\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_func.c",
    "content": "\n#include \"lsmtest.h\"\n\n\nint do_work(int nArg, char **azArg){\n  struct Option {\n    const char *zName;\n  } aOpt [] = {\n    { \"-nmerge\" },\n    { \"-nkb\" },\n    { 0 }\n  };\n\n  lsm_db *pDb;\n  int rc;\n  int i;\n  const char *zDb;\n  int nMerge = 1;\n  int nKB = (1<<30);\n\n  if( nArg==0 ) goto usage;\n  zDb = azArg[nArg-1];\n  for(i=0; i<(nArg-1); i++){\n    int iSel;\n    rc = testArgSelect(aOpt, \"option\", azArg[i], &iSel);\n    if( rc ) return rc;\n    switch( iSel ){\n      case 0:\n        i++;\n        if( i==(nArg-1) ) goto usage;\n        nMerge = atoi(azArg[i]);\n        break;\n      case 1:\n        i++;\n        if( i==(nArg-1) ) goto usage;\n        nKB = atoi(azArg[i]);\n        break;\n    }\n  }\n\n  rc = lsm_new(0, &pDb);\n  if( rc!=LSM_OK ){\n    testPrintError(\"lsm_open(): rc=%d\\n\", rc);\n  }else{\n    rc = lsm_open(pDb, zDb);\n    if( rc!=LSM_OK ){\n      testPrintError(\"lsm_open(): rc=%d\\n\", rc);\n    }else{\n      int n = -1;\n      lsm_config(pDb, LSM_CONFIG_BLOCK_SIZE, &n);\n      n = n*2;\n      lsm_config(pDb, LSM_CONFIG_AUTOCHECKPOINT, &n);\n\n      rc = lsm_work(pDb, nMerge, nKB, 0);\n      if( rc!=LSM_OK ){\n        testPrintError(\"lsm_work(): rc=%d\\n\", rc);\n      }\n    }\n  }\n  if( rc==LSM_OK ){\n    rc = lsm_checkpoint(pDb, 0);\n  }\n\n  lsm_close(pDb);\n  return rc;\n\n usage:\n  testPrintUsage(\"?-optimize? ?-n N? DATABASE\");\n  return -1;\n}\n\n\n/*\n**   lsmtest show ?-config LSM-CONFIG? DATABASE ?COMMAND ?PGNO??\n*/\nint do_show(int nArg, char **azArg){\n  lsm_db *pDb;\n  int rc;\n  const char *zDb;\n\n  int eOpt = LSM_INFO_DB_STRUCTURE;\n  unsigned int iPg = 0;\n  int bConfig = 0;\n  const char *zConfig = \"\";\n\n  struct Option {\n    const char *zName;\n    int bConfig;\n    int eOpt;\n  } aOpt [] = { \n    { \"array\",       0, LSM_INFO_ARRAY_STRUCTURE },\n    { \"array-pages\", 0, LSM_INFO_ARRAY_PAGES },\n    { \"blocksize\",   1, LSM_CONFIG_BLOCK_SIZE },\n    { \"pagesize\",    1, LSM_CONFIG_PAGE_SIZE },\n    { \"freelist\",    0, LSM_INFO_FREELIST },\n    { \"page-ascii\",  0, LSM_INFO_PAGE_ASCII_DUMP },\n    { \"page-hex\",    0, LSM_INFO_PAGE_HEX_DUMP },\n    { 0, 0 } \n  };\n\n  char *z = 0; \n  int iDb = 0;                    /* Index of DATABASE in azArg[] */\n\n  /* Check if there is a \"-config\" option: */\n  if( nArg>2 && strlen(azArg[0])>1 \n   && memcmp(azArg[0], \"-config\", strlen(azArg[0]))==0\n  ){\n    zConfig = azArg[1];\n    iDb = 2;\n  }\n  if( nArg<(iDb+1) ) goto usage;\n\n  if( nArg>(iDb+1) ){\n    rc = testArgSelect(aOpt, \"option\", azArg[iDb+1], &eOpt);\n    if( rc!=0 ) return rc;\n    bConfig = aOpt[eOpt].bConfig;\n    eOpt = aOpt[eOpt].eOpt;\n    if( (bConfig==0 && eOpt==LSM_INFO_FREELIST)\n     || (bConfig==1 && eOpt==LSM_CONFIG_BLOCK_SIZE)\n     || (bConfig==1 && eOpt==LSM_CONFIG_PAGE_SIZE)\n    ){\n      if( nArg!=(iDb+2) ) goto usage;\n    }else{\n      if( nArg!=(iDb+3) ) goto usage;\n      iPg = atoi(azArg[iDb+2]);\n    }\n  }\n  zDb = azArg[iDb];\n\n  rc = lsm_new(0, &pDb);\n  tdb_lsm_configure(pDb, zConfig);\n  if( rc!=LSM_OK ){\n    testPrintError(\"lsm_new(): rc=%d\\n\", rc);\n  }else{\n    rc = lsm_open(pDb, zDb);\n    if( rc!=LSM_OK ){\n      testPrintError(\"lsm_open(): rc=%d\\n\", rc);\n    }\n  }\n\n  if( rc==LSM_OK ){\n    if( bConfig==0 ){\n      switch( eOpt ){\n        case LSM_INFO_DB_STRUCTURE:\n        case LSM_INFO_FREELIST:\n          rc = lsm_info(pDb, eOpt, &z);\n          break;\n        case LSM_INFO_ARRAY_STRUCTURE:\n        case LSM_INFO_ARRAY_PAGES:\n        case LSM_INFO_PAGE_ASCII_DUMP:\n        case LSM_INFO_PAGE_HEX_DUMP:\n          rc = lsm_info(pDb, eOpt, iPg, &z);\n          break;\n        default:\n          assert( !\"no chance\" );\n      }\n\n      if( rc==LSM_OK ){\n        printf(\"%s\\n\", z ? z : \"\");\n        fflush(stdout);\n      }\n      lsm_free(lsm_get_env(pDb), z);\n    }else{\n      int iRes = -1;\n      lsm_config(pDb, eOpt, &iRes);\n      printf(\"%d\\n\", iRes);\n      fflush(stdout);\n    }\n  }\n\n  lsm_close(pDb);\n  return rc;\n\n usage:\n  testPrintUsage(\"DATABASE ?array|page-ascii|page-hex PGNO?\");\n  return -1;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_io.c",
    "content": "\n/*\n** SUMMARY\n**\n**   This file implements the 'io' subcommand of the test program. It is used\n**   for testing the performance of various combinations of write() and fsync()\n**   system calls. All operations occur on a single file, which may or may not\n**   exist when a test is started.\n**\n**   A test consists of a series of commands. Each command is either a write\n**   or an fsync. A write is specified as \"<amount>@<offset>\", where <amount>\n**   is the amount of data written, and <offset> is the offset of the file\n**   to write to. An <amount> or an <offset> is specified as an integer number\n**   of bytes. Or, if postfixed with a \"K\", \"M\" or \"G\", an integer number of\n**   KB, MB or GB, respectively. An fsync is simply \"S\". All commands are\n**   case-insensitive.\n**\n**   Example test program:\n**\n**        2M@6M 1492K@4M S 4096@4K S\n**\n**   This program writes 2 MB of data starting at the offset 6MB offset of\n**   the file, followed by 1492 KB of data written at the 4MB offset of the\n**   file, followed by a call to fsync(), a write of 4KB of data at byte\n**   offset 4096, and finally another call to fsync().\n**\n**   Commands may either be specified on the command line (one command per\n**   command line argument) or read from stdin. Commands read from stdin\n**   must be separated by white-space.\n**\n** COMMAND LINE INVOCATION\n**\n**   The sub-command implemented in this file must be invoked with at least\n**   two arguments - the path to the file to write to and the page-size to\n**   use for writing. If there are more than two arguments, then each\n**   subsequent argument is assumed to be a test command. If there are exactly\n**   two arguments, the test commands are read from stdin.\n**\n**   A write command does not result in a single call to system call write().\n**   Instead, the specified region is written sequentially using one or\n**   more calls to write(), each of which writes not more than one page of\n**   data. For example, if the page-size is 4KB, the command \"2M@6M\" results\n**   in 512 calls to write(), each of which writes 4KB of data.\n**\n** EXAMPLES\n**\n**   Two equivalent examples:\n**\n**     $ lsmtest io testfile.db 4KB 2M@6M 1492K@4M S 4096@4K S\n**     3544K written in 129 ms\n**     $ echo \"2M@6M 1492K@4M S 4096@4K S\" | lsmtest io testfile.db 4096 \n**     3544K written in 127 ms\n**\n*/\n\n#include \"lsmtest.h\"\n\ntypedef struct IoContext IoContext;\n\nstruct IoContext {\n  int fd;\n  int nWrite;\n};\n\n/*\n** As isspace(3)\n*/\nstatic int safe_isspace(char c){\n  if( c&0x80) return 0;\n  return isspace(c);\n}\n\n/*\n** As isdigit(3)\n*/\nstatic int safe_isdigit(char c){\n  if( c&0x80) return 0;\n  return isdigit(c);\n}\n\nstatic i64 getNextSize(char *zIn, char **pzOut, int *pRc){\n  i64 iRet = 0;\n  if( *pRc==0 ){\n    char *z = zIn;\n\n    if( !safe_isdigit(*z) ){\n      *pRc = 1;\n      return 0;\n    }\n\n    /* Process digits */\n    while( safe_isdigit(*z) ){\n      iRet = iRet*10 + (*z - '0');\n      z++;\n    }\n\n    /* Process suffix */\n    switch( *z ){\n      case 'k': case 'K':\n        iRet = iRet * 1024;\n        z++;\n        break;\n\n      case 'm': case 'M':\n        iRet = iRet * 1024 * 1024;\n        z++;\n        break;\n\n      case 'g': case 'G':\n        iRet = iRet * 1024 * 1024 * 1024;\n        z++;\n        break;\n    }\n\n    if( pzOut ) *pzOut = z;\n  }\n  return iRet;\n}\n\nstatic int doOneCmd(\n  IoContext *pCtx,\n  u8 *aData,\n  int pgsz,\n  char *zCmd,\n  char **pzOut\n){\n  char c;\n  char *z = zCmd;\n\n  while( safe_isspace(*z) ) z++;\n  c = *z;\n\n  if( c==0 ){\n    if( pzOut ) *pzOut = z;\n    return 0;\n  }\n\n  if( c=='s' || c=='S' ){\n    if( pzOut ) *pzOut = &z[1];\n    return fdatasync(pCtx->fd);\n  }\n\n  if( safe_isdigit(c) ){\n    i64 iOff = 0;\n    int nByte = 0;\n    int rc = 0;\n    int nPg;\n    int iPg;\n\n    nByte = (int)getNextSize(z, &z, &rc);\n    if( rc || *z!='@' ) goto bad_command;\n    z++;\n    iOff = getNextSize(z, &z, &rc);\n    if( rc || (safe_isspace(*z)==0 && *z!='\\0') ) goto bad_command;\n    if( pzOut ) *pzOut = z;\n\n    nPg = (nByte+pgsz-1) / pgsz;\n    lseek(pCtx->fd, (off_t)iOff, SEEK_SET);\n    for(iPg=0; iPg<nPg; iPg++){\n      write(pCtx->fd, aData, pgsz);\n    }\n    pCtx->nWrite += nByte/1024;\n\n    return 0;\n  }\n\n bad_command:\n  testPrintError(\"unrecognized command: %s\", zCmd);\n  return 1;\n}\n\nstatic int readStdin(char **pzOut){\n  int nAlloc = 128;\n  char *zOut = 0;\n  int nOut = 0;\n\n  while( !feof(stdin) ){\n    int nRead;\n\n    nAlloc = nAlloc*2;\n    zOut = realloc(zOut, nAlloc);\n    nRead = fread(&zOut[nOut], 1, nAlloc-nOut-1, stdin);\n\n    if( nRead==0 ) break;\n    nOut += nRead;\n    zOut[nOut] = '\\0';\n  }\n\n  *pzOut = zOut;\n  return 0;\n}\n\nint do_io(int nArg, char **azArg){\n  IoContext ctx;\n  int pgsz;\n  char *zFile;\n  char *zPgsz;\n  int i;\n  int rc = 0;\n\n  char *zStdin = 0;\n  char *z;\n\n  u8 *aData;\n\n  memset(&ctx, 0, sizeof(IoContext));\n  if( nArg<2 ){\n    testPrintUsage(\"FILE PGSZ ?CMD-1 ...?\");\n    return -1;\n  }\n  zFile = azArg[0];\n  zPgsz = azArg[1];\n\n  pgsz = (int)getNextSize(zPgsz, 0, &rc);\n  if( pgsz<=0 ){\n    testPrintError(\"Ridiculous page size: %d\", pgsz);\n    return -1;\n  }\n  aData = malloc(pgsz);\n  memset(aData, 0x77, pgsz);\n\n  ctx.fd = open(zFile, O_RDWR|O_CREAT|_O_BINARY, 0644);\n  if( ctx.fd<0 ){\n    perror(\"open: \");\n    return -1;\n  }\n\n  if( nArg==2 ){\n    readStdin(&zStdin);\n    testTimeInit();\n    z = zStdin;\n    while( *z && rc==0 ){\n      rc = doOneCmd(&ctx, aData, pgsz, z, &z);\n    }\n  }else{\n    testTimeInit();\n    for(i=2; i<nArg; i++){\n      rc = doOneCmd(&ctx, aData, pgsz, azArg[i], 0);\n    }\n  }\n\n  printf(\"%dK written in %d ms\\n\", ctx.nWrite, testTimeGet());\n\n  free(zStdin);\n  close(ctx.fd);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_main.c",
    "content": "\n#include \"lsmtest.h\"\n#include <sqlite3.h>\n\nvoid test_failed(){ \n  assert( 0 );\n  return; \n}\n\n#define testSetError(rc) testSetErrorFunc(rc, pRc, __FILE__, __LINE__)\nstatic void testSetErrorFunc(int rc, int *pRc, const char *zFile, int iLine){\n  if( rc ){\n    *pRc = rc;\n    fprintf(stderr, \"FAILED (%s:%d) rc=%d \", zFile, iLine, rc);\n    test_failed();\n  }\n}\n\nstatic int lsm_memcmp(u8 *a, u8 *b, int c){\n  int i;\n  for(i=0; i<c; i++){\n    if( a[i]!=b[i] ) return a[i] - b[i];\n  }\n  return 0;\n}\n\n/*\n** A test utility function.\n*/\nvoid testFetch(\n  TestDb *pDb,                    /* Database handle */\n  void *pKey, int nKey,           /* Key to query database for */\n  void *pVal, int nVal,           /* Expected value */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==0 ){\n    void *pDbVal;\n    int nDbVal;\n    int rc;\n\n    static int nCall = 0; nCall++;\n\n    rc = tdb_fetch(pDb, pKey, nKey, &pDbVal, &nDbVal);\n    testSetError(rc);\n    if( rc==0 && (nVal!=nDbVal || (nVal>0 && lsm_memcmp(pVal, pDbVal, nVal))) ){\n      testSetError(1);\n    }\n  }\n}\n\nvoid testWrite(\n  TestDb *pDb,                    /* Database handle */\n  void *pKey, int nKey,           /* Key to query database for */\n  void *pVal, int nVal,           /* Value to write */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==0 ){\n    int rc;\nstatic int nCall = 0;\nnCall++;\n    rc = tdb_write(pDb, pKey, nKey, pVal, nVal);\n    testSetError(rc);\n  }\n}\nvoid testDelete(\n  TestDb *pDb,                    /* Database handle */\n  void *pKey, int nKey,           /* Key to query database for */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==0 ){\n    int rc;\n    *pRc = rc = tdb_delete(pDb, pKey, nKey);\n    testSetError(rc);\n  }\n}\nvoid testDeleteRange(\n  TestDb *pDb,                    /* Database handle */\n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2,\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==0 ){\n    int rc;\n    *pRc = rc = tdb_delete_range(pDb, pKey1, nKey1, pKey2, nKey2);\n    testSetError(rc);\n  }\n}\n\nvoid testBegin(TestDb *pDb, int iTrans, int *pRc){\n  if( *pRc==0 ){\n    int rc;\n    rc = tdb_begin(pDb, iTrans);\n    testSetError(rc);\n  }\n}\nvoid testCommit(TestDb *pDb, int iTrans, int *pRc){\n  if( *pRc==0 ){\n    int rc;\n    rc = tdb_commit(pDb, iTrans);\n    testSetError(rc);\n  }\n}\n#if 0 /* unused */\nstatic void testRollback(TestDb *pDb, int iTrans, int *pRc){\n  if( *pRc==0 ){\n    int rc;\n    rc = tdb_rollback(pDb, iTrans);\n    testSetError(rc);\n  }\n}\n#endif\n\nvoid testWriteStr(\n  TestDb *pDb,                    /* Database handle */\n  const char *zKey,               /* Key to query database for */\n  const char *zVal,               /* Value to write */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int nVal = (zVal ? strlen(zVal) : 0);\n  testWrite(pDb, (void *)zKey, strlen(zKey), (void *)zVal, nVal, pRc);\n}\n\n#if 0 /* unused */\nstatic void testDeleteStr(TestDb *pDb, const char *zKey, int *pRc){\n  testDelete(pDb, (void *)zKey, strlen(zKey), pRc);\n}\n#endif\nvoid testFetchStr(\n  TestDb *pDb,                    /* Database handle */\n  const char *zKey,               /* Key to query database for */\n  const char *zVal,               /* Value to write */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int nVal = (zVal ? strlen(zVal) : 0);\n  testFetch(pDb, (void *)zKey, strlen(zKey), (void *)zVal, nVal, pRc);\n}\n\nvoid testFetchCompare(\n  TestDb *pControl, \n  TestDb *pDb, \n  void *pKey, int nKey, \n  int *pRc\n){\n  int rc;\n  void *pDbVal1;\n  void *pDbVal2;\n  int nDbVal1;\n  int nDbVal2;\n\n  static int nCall = 0;\n  nCall++;\n\n  rc = tdb_fetch(pControl, pKey, nKey, &pDbVal1, &nDbVal1);\n  testSetError(rc);\n\n  rc = tdb_fetch(pDb, pKey, nKey, &pDbVal2, &nDbVal2);\n  testSetError(rc);\n\n  if( *pRc==0 \n   && (nDbVal1!=nDbVal2 || (nDbVal1>0 && memcmp(pDbVal1, pDbVal2, nDbVal1)))\n  ){\n    testSetError(1);\n  }\n}\n\ntypedef struct ScanResult ScanResult;\nstruct ScanResult {\n  TestDb *pDb;\n\n  int nRow;\n  u32 cksum1;\n  u32 cksum2;\n  void *pKey1; int nKey1;\n  void *pKey2; int nKey2;\n\n  int bReverse;\n  int nPrevKey;\n  u8 aPrevKey[256];\n};\n\nstatic int keyCompare(void *pKey1, int nKey1, void *pKey2, int nKey2){\n  int res;\n  res = memcmp(pKey1, pKey2, MIN(nKey1, nKey2));\n  if( res==0 ){\n    res = nKey1 - nKey2;\n  }\n  return res;\n}\n\nint test_scan_debug = 0;\n\nstatic void scanCompareCb(\n  void *pCtx, \n  void *pKey, int nKey,\n  void *pVal, int nVal\n){\n  ScanResult *p = (ScanResult *)pCtx;\n  u8 *aKey = (u8 *)pKey;\n  u8 *aVal = (u8 *)pVal;\n  int i;\n\n  if( test_scan_debug ){\n    printf(\"%d: %.*s\\n\", p->nRow, nKey, (char *)pKey);\n    fflush(stdout);\n  }\n#if 0\n  if( test_scan_debug ) printf(\"%.20s\\n\", (char *)pVal);\n#endif\n\n#if 0\n  /* Check tdb_fetch() matches */\n  int rc = 0;\n  testFetch(p->pDb, pKey, nKey, pVal, nVal, &rc);\n  assert( rc==0 );\n#endif\n\n  /* Update the checksum data */\n  p->nRow++;\n  for(i=0; i<nKey; i++){\n    p->cksum1 += ((int)aKey[i] << (i&0x0F));\n    p->cksum2 += p->cksum1;\n  }\n  for(i=0; i<nVal; i++){\n    p->cksum1 += ((int)aVal[i] << (i&0x0F));\n    p->cksum2 += p->cksum1;\n  }\n\n  /* Check that the delivered row is not out of order. */\n  if( nKey<(int)sizeof(p->aPrevKey) ){\n    if( p->nPrevKey ){\n      int res = keyCompare(p->aPrevKey, p->nPrevKey, pKey, nKey);\n      if( (res<0 && p->bReverse) || (res>0 && p->bReverse==0) ){\n        testPrintError(\"Returned key out of order at %s:%d\\n\", \n            __FILE__, __LINE__\n        );\n      }\n    }\n\n    p->nPrevKey = nKey;\n    memcpy(p->aPrevKey, pKey, MIN(p->nPrevKey, nKey));\n  }\n\n  /* Check that the delivered row is within range. */\n  if( p->pKey1 && (\n      (memcmp(p->pKey1, pKey, MIN(p->nKey1, nKey))>0)\n   || (memcmp(p->pKey1, pKey, MIN(p->nKey1, nKey))==0 && p->nKey1>nKey)\n  )){\n    testPrintError(\"Returned key too small at %s:%d\\n\", __FILE__, __LINE__);\n  }\n  if( p->pKey2 && (\n      (memcmp(p->pKey2, pKey, MIN(p->nKey2, nKey))<0)\n   || (memcmp(p->pKey2, pKey, MIN(p->nKey2, nKey))==0 && p->nKey2<nKey)\n  )){\n    testPrintError(\"Returned key too large at %s:%d\\n\", __FILE__, __LINE__);\n  }\n\n}\n\n/*\n** Scan the contents of the two databases. Check that they match.\n*/\nvoid testScanCompare(\n  TestDb *pDb1,                   /* Control (trusted) database */\n  TestDb *pDb2,                   /* Database being tested */\n  int bReverse,\n  void *pKey1, int nKey1, \n  void *pKey2, int nKey2, \n  int *pRc\n){\n  static int nCall = 0; nCall++;\n  if( *pRc==0 ){\n    ScanResult res1;\n    ScanResult res2;\n    void *pRes1 = (void *)&res1;\n    void *pRes2 = (void *)&res2;\n\n    memset(&res1, 0, sizeof(ScanResult));\n    memset(&res2, 0, sizeof(ScanResult));\n\n    res1.pDb = pDb1;\n    res1.nKey1 = nKey1; res1.pKey1 = pKey1;\n    res1.nKey2 = nKey2; res1.pKey2 = pKey2;\n    res1.bReverse = bReverse;\n    res2.pDb = pDb2;\n    res2.nKey1 = nKey1; res2.pKey1 = pKey1;\n    res2.nKey2 = nKey2; res2.pKey2 = pKey2;\n    res2.bReverse = bReverse;\n\n    tdb_scan(pDb1, pRes1, bReverse, pKey1, nKey1, pKey2, nKey2, scanCompareCb);\nif( test_scan_debug ) printf(\"\\n\\n\\n\");\n    tdb_scan(pDb2, pRes2, bReverse, pKey1, nKey1, pKey2, nKey2, scanCompareCb);\nif( test_scan_debug ) printf(\"\\n\\n\\n\");\n\n    if( res1.nRow!=res2.nRow \n     || res1.cksum1!=res2.cksum1 \n     || res1.cksum2!=res2.cksum2\n    ){\n      printf(\"expected: %d %X %X\\n\", res1.nRow, res1.cksum1, res1.cksum2);\n      printf(\"got:      %d %X %X\\n\", res2.nRow, res2.cksum1, res2.cksum2);\n      testSetError(1);\n      *pRc = 1;\n    }\n  }\n}\n\nvoid testClose(TestDb **ppDb){\n  tdb_close(*ppDb);\n  *ppDb = 0;\n}\n\nTestDb *testOpen(const char *zSystem, int bClear, int *pRc){\n  TestDb *pDb = 0;\n  if( *pRc==0 ){\n    int rc;\n    rc = tdb_open(zSystem, 0, bClear, &pDb);\n    if( rc!=0 ){\n      testSetError(rc);\n      *pRc = rc;\n    }\n  }\n  return pDb;\n}\n\nvoid testReopen(TestDb **ppDb, int *pRc){\n  if( *pRc==0 ){\n    const char *zLib;\n    zLib = tdb_library_name(*ppDb);\n    testClose(ppDb);\n    *pRc = tdb_open(zLib, 0, 0, ppDb);\n  }\n}\n\n\n#if 0 /* unused */\nstatic void testSystemSelect(const char *zSys, int *piSel, int *pRc){\n  if( *pRc==0 ){\n    struct SysName { const char *zName; } *aName;\n    int nSys;\n    int i;\n\n    for(nSys=0; tdb_system_name(nSys); nSys++);\n    aName = malloc(sizeof(struct SysName) * (nSys+1));\n    for(i=0; i<=nSys; i++){\n      aName[i].zName = tdb_system_name(i);\n    }\n\n    *pRc = testArgSelect(aName, \"db\", zSys, piSel);\n    free(aName);\n  }\n}\n#endif\n\nchar *testMallocVPrintf(const char *zFormat, va_list ap){\n  int nByte;\n  va_list copy;\n  char *zRet;\n\n  __va_copy(copy, ap);\n  nByte = vsnprintf(0, 0, zFormat, copy);\n  va_end(copy);\n\n  assert( nByte>=0 );\n  zRet = (char *)testMalloc(nByte+1);\n  vsnprintf(zRet, nByte+1, zFormat, ap);\n  return zRet;\n}\n\nchar *testMallocPrintf(const char *zFormat, ...){\n  va_list ap;\n  char *zRet;\n\n  va_start(ap, zFormat);\n  zRet = testMallocVPrintf(zFormat, ap);\n  va_end(ap);\n\n  return zRet;\n}\n\n\n/*\n** A wrapper around malloc(3).\n**\n** This function should be used for all allocations made by test procedures.\n** It has the following properties:\n**\n**   * Test code may assume that allocations may not fail.\n**   * Returned memory is always zeroed.\n**\n** Allocations made using testMalloc() should be freed using testFree().\n*/\nvoid *testMalloc(int n){\n  u8 *p = (u8*)malloc(n + 8);\n  memset(p, 0, n+8);\n  *(int*)p = n;\n  return (void*)&p[8];\n}\n\nvoid *testMallocCopy(void *pCopy, int nByte){\n  void *pRet = testMalloc(nByte);\n  memcpy(pRet, pCopy, nByte);\n  return pRet;\n}\n\nvoid *testRealloc(void *ptr, int n){\n  if( ptr ){\n    u8 *p = (u8*)ptr - 8;\n    int nOrig =  *(int*)p;\n    p = (u8*)realloc(p, n+8);\n    if( nOrig<n ){\n      memset(&p[8+nOrig], 0, n-nOrig);\n    }\n    *(int*)p = n;\n    return (void*)&p[8];\n  }\n  return testMalloc(n);\n}\n\n/*\n** Free an allocation made by an earlier call to testMalloc().\n*/\nvoid testFree(void *ptr){\n  if( ptr ){\n    u8 *p = (u8*)ptr - 8;\n    memset(p, 0x55, *(int*)p + 8);\n    free(p);\n  }\n}\n\n/*\n** String zPattern contains a glob pattern. Return true if zStr matches \n** the pattern, or false if it does not.\n*/\nint testGlobMatch(const char *zPattern, const char *zStr){\n  int i = 0;\n  int j = 0;\n\n  while( zPattern[i] ){\n    char p = zPattern[i];\n\n    if( p=='*' || p=='%' ){\n      do {\n        if( testGlobMatch(&zPattern[i+1], &zStr[j]) ) return 1;\n      }while( zStr[j++] );\n      return 0;\n    }\n\n    if( zStr[j]==0 || (p!='?' && p!=zStr[j]) ){\n      /* Match failed. */\n      return 0;\n    }\n\n    j++;\n    i++;\n  }\n\n  return (zPattern[i]==0 && zStr[j]==0);\n}\n\n/* \n** End of test utilities \n**************************************************************************/\n\nint do_test(int nArg, char **azArg){\n  int j;\n  int rc;\n  int nFail = 0;\n  const char *zPattern = 0;\n\n  if( nArg>1 ){\n    testPrintError(\"Usage: test ?PATTERN?\\n\");\n    return 1;\n  }\n  if( nArg==1 ){\n    zPattern = azArg[0];\n  }\n\n  for(j=0; tdb_system_name(j); j++){\n    rc = 0;\n\n    test_data_1(tdb_system_name(j), zPattern, &rc);\n    test_data_2(tdb_system_name(j), zPattern, &rc);\n    test_data_3(tdb_system_name(j), zPattern, &rc);\n    test_data_4(tdb_system_name(j), zPattern, &rc);\n    test_rollback(tdb_system_name(j), zPattern, &rc);\n    test_mc(tdb_system_name(j), zPattern, &rc);\n    test_mt(tdb_system_name(j), zPattern, &rc);\n\n    if( rc ) nFail++;\n  }\n\n  rc = 0;\n  test_oom(zPattern, &rc);\n  if( rc ) nFail++;\n\n  rc = 0;\n  test_api(zPattern, &rc);\n  if( rc ) nFail++;\n\n  rc = 0;\n  do_crash_test(zPattern, &rc);\n  if( rc ) nFail++;\n\n  rc = 0;\n  do_writer_crash_test(zPattern, &rc);\n  if( rc ) nFail++;\n\n  return (nFail!=0);\n}\n\nstatic lsm_db *configure_lsm_db(TestDb *pDb){\n  lsm_db *pLsm;\n  pLsm = tdb_lsm(pDb);\n  if( pLsm ){\n    tdb_lsm_config_str(pDb, \"mmap=1 autowork=1 automerge=4 worker_automerge=4\");\n  }\n  return pLsm;\n}\n\ntypedef struct WriteHookEvent WriteHookEvent;\nstruct WriteHookEvent {\n  i64 iOff;\n  int nData;\n  int nUs;\n};\nWriteHookEvent prev = {0, 0, 0};\n\nstatic void flushPrev(FILE *pOut){\n  if( prev.nData ){\n    fprintf(pOut, \"w %s %lld %d %d\\n\", \"d\", prev.iOff, prev.nData, prev.nUs);\n    prev.nData = 0;\n  }\n}\n\n#if 0 /* unused */\nstatic void do_speed_write_hook2(\n  void *pCtx,\n  int bLog,\n  i64 iOff,\n  int nData,\n  int nUs\n){\n  FILE *pOut = (FILE *)pCtx;\n  if( bLog ) return;\n\n  if( prev.nData && nData && iOff==prev.iOff+prev.nData ){\n    prev.nData += nData;\n    prev.nUs += nUs;\n  }else{\n    flushPrev(pOut);\n    if( nData==0 ){\n      fprintf(pOut, \"s %s 0 0 %d\\n\", (bLog ? \"l\" : \"d\"), nUs);\n    }else{\n      prev.iOff = iOff;\n      prev.nData = nData;\n      prev.nUs = nUs;\n    }\n  }\n}\n#endif\n\n#define ST_REPEAT  0\n#define ST_WRITE   1\n#define ST_PAUSE   2\n#define ST_FETCH   3\n#define ST_SCAN    4\n#define ST_NSCAN   5\n#define ST_KEYSIZE 6\n#define ST_VALSIZE 7\n#define ST_TRANS   8\n\n\nstatic void print_speed_test_help(){\n  printf(\n\"\\n\"\n\"Repeat the following $repeat times:\\n\"\n\"  1. Insert $write key-value pairs. One transaction for each write op.\\n\"\n\"  2. Pause for $pause ms.\\n\"\n\"  3. Perform $fetch queries on the database.\\n\"\n\"\\n\"\n\"  Keys are $keysize bytes in size. Values are $valsize bytes in size\\n\"\n\"  Both keys and values are pseudo-randomly generated\\n\"\n\"\\n\"\n\"Options are:\\n\"\n\"  -repeat  $repeat                 (default value 10)\\n\"\n\"  -write   $write                  (default value 10000)\\n\"\n\"  -pause   $pause                  (default value 0)\\n\"\n\"  -fetch   $fetch                  (default value 0)\\n\"\n\"  -keysize $keysize                (default value 12)\\n\"\n\"  -valsize $valsize                (default value 100)\\n\"\n\"  -system  $system                 (default value \\\"lsm\\\")\\n\"\n\"  -trans   $trans                  (default value 0)\\n\"\n\"\\n\"\n);\n}\n\nint do_speed_test2(int nArg, char **azArg){\n  struct Option {\n    const char *zOpt;\n    int eVal;\n    int iDefault;\n  } aOpt[] = {\n    { \"-repeat\",  ST_REPEAT,    10},\n    { \"-write\",   ST_WRITE,  10000},\n    { \"-pause\",   ST_PAUSE,      0},\n    { \"-fetch\",   ST_FETCH,      0},\n    { \"-scan\",    ST_SCAN,       0},\n    { \"-nscan\",   ST_NSCAN,      0},\n    { \"-keysize\", ST_KEYSIZE,   12},\n    { \"-valsize\", ST_VALSIZE,  100},\n    { \"-trans\",   ST_TRANS,      0},\n    { \"-system\",  -1,            0},\n    { \"help\",     -2,            0},\n    {0, 0, 0}\n  };\n  int i;\n  int aParam[9];\n  int rc = 0;\n  int bReadonly = 0;\n  int nContent = 0;\n\n  TestDb *pDb;\n  Datasource *pData;\n  DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 0, 0, 0, 0 };\n  char *zSystem = \"\";\n  int bLsm = 1;\n  FILE *pLog = 0;\n\n#ifdef NDEBUG\n  /* If NDEBUG is defined, disable the dynamic memory related checks in\n  ** lsmtest_mem.c. They slow things down.  */\n  testMallocUninstall(tdb_lsm_env());\n#endif\n\n  /* Initialize aParam[] with default values. */\n  for(i=0; i<ArraySize(aOpt); i++){\n    if( aOpt[i].zOpt ) aParam[aOpt[i].eVal] = aOpt[i].iDefault;\n  }\n\n  /* Process the command line switches. */\n  for(i=0; i<nArg; i+=2){\n    int iSel;\n    rc = testArgSelect(aOpt, \"switch\", azArg[i], &iSel);\n    if( rc ){\n      return rc;\n    }\n    if( aOpt[iSel].eVal==-2 ){\n      print_speed_test_help();\n      return 0;\n    }\n    if( i+1==nArg ){\n      testPrintError(\"option %s requires an argument\\n\", aOpt[iSel].zOpt);\n      return 1;\n    }\n    if( aOpt[iSel].eVal>=0 ){\n      aParam[aOpt[iSel].eVal] = atoi(azArg[i+1]);\n    }else{\n      zSystem = azArg[i+1];\n      bLsm = 0;\n#if 0\n      for(j=0; zSystem[j]; j++){\n        if( zSystem[j]=='=' ) bLsm = 1;\n      }\n#endif\n    }\n  }\n  \n  printf(\"#\");\n  for(i=0; i<ArraySize(aOpt); i++){\n    if( aOpt[i].zOpt ){\n      if( aOpt[i].eVal>=0 ){\n        printf(\" %s=%d\", &aOpt[i].zOpt[1], aParam[aOpt[i].eVal]);\n      }else if( aOpt[i].eVal==-1 ){\n        printf(\" %s=\\\"%s\\\"\", &aOpt[i].zOpt[1], zSystem);\n      }\n    }\n  }\n  printf(\"\\n\");\n\n  defn.nMinKey = defn.nMaxKey = aParam[ST_KEYSIZE];\n  defn.nMinVal = defn.nMaxVal = aParam[ST_VALSIZE];\n  pData = testDatasourceNew(&defn);\n\n  if( aParam[ST_WRITE]==0 ){\n    bReadonly = 1;\n  }\n\n  if( bLsm ){\n    rc = tdb_lsm_open(zSystem, \"testdb.lsm\", !bReadonly, &pDb);\n  }else{\n    pDb = testOpen(zSystem, !bReadonly, &rc);\n  }\n  if( rc!=0 ) return rc;\n  if( bReadonly ){\n    nContent = testCountDatabase(pDb);\n  }\n\n#if 0\n  pLog = fopen(\"/tmp/speed.log\", \"w\");\n  tdb_lsm_write_hook(pDb, do_speed_write_hook2, (void *)pLog);\n#endif\n\n  for(i=0; i<aParam[ST_REPEAT] && rc==0; i++){\n    int msWrite, msFetch;\n    int iFetch;\n    int nWrite = aParam[ST_WRITE];\n\n    if( bReadonly ){\n      msWrite = 0;\n    }else{\n      testTimeInit();\n\n      if( aParam[ST_TRANS] ) testBegin(pDb, 2, &rc);\n      testWriteDatasourceRange(pDb, pData, i*nWrite, nWrite, &rc);\n      if( aParam[ST_TRANS] ) testCommit(pDb, 0, &rc);\n\n      msWrite = testTimeGet();\n      nContent += nWrite;\n    }\n\n    if( aParam[ST_PAUSE] ){\n      if( aParam[ST_PAUSE]/1000 ) sleep(aParam[ST_PAUSE]/1000);\n      if( aParam[ST_PAUSE]%1000 ) usleep(1000 * (aParam[ST_PAUSE]%1000));\n    }\n\n    if( aParam[ST_FETCH] ){\n      testTimeInit();\n      if( aParam[ST_TRANS] ) testBegin(pDb, 1, &rc);\n      for(iFetch=0; iFetch<aParam[ST_FETCH]; iFetch++){\n        int iKey = testPrngValue(i*nWrite+iFetch) % nContent;\n#ifndef NDEBUG\n        testDatasourceFetch(pDb, pData, iKey, &rc);\n#else\n        void *pKey; int nKey;           /* Database key to query for */\n        void *pVal; int nVal;           /* Result of query */\n\n        testDatasourceEntry(pData, iKey, &pKey, &nKey, 0, 0);\n        rc = tdb_fetch(pDb, pKey, nKey, &pVal, &nVal);\n        if( rc==0 && nVal<0 ) rc = 1;\n        if( rc ) break;\n#endif\n      }\n      if( aParam[ST_TRANS] ) testCommit(pDb, 0, &rc);\n      msFetch = testTimeGet();\n    }else{\n      msFetch = 0;\n    }\n\n    if( i==(aParam[ST_REPEAT]-1) ){\n      testTimeInit();\n      testClose(&pDb);\n      msWrite += testTimeGet();\n    }\n\n    printf(\"%d %d %d\\n\", i, msWrite, msFetch);\n    fflush(stdout);\n  }\n\n  testClose(&pDb);\n  testDatasourceFree(pData);\n\n  if( pLog ){\n    flushPrev(pLog);\n    fclose(pLog);\n  }\n  return rc;\n}\n\nint do_speed_tests(int nArg, char **azArg){\n\n  struct DbSystem {\n    const char *zLibrary;\n    const char *zColor;\n  } aSys[] = {\n    { \"sqlite3\",      \"black\" },\n    { \"leveldb\",      \"blue\" },\n    { \"lsm\",          \"red\" },\n    { \"lsm_mt2\",      \"orange\" },\n    { \"lsm_mt3\",      \"purple\" },\n    { \"kyotocabinet\", \"green\" },\n    {0, 0}\n  };\n\n  int i;\n  int j;\n  int rc;\n  int nSleep = 0;                 /* ms of rest allowed between INSERT tests */\n  int nRow = 0;                   /* Number of rows to insert into database */\n  int nStep;                      /* Measure INSERT time after this many rows */\n  int nSelStep;                   /* Measure SELECT time after this many rows */\n  int nSelTest;                   /* Number of SELECTs to run for timing */\n  int doReadTest = 1;\n  int doWriteTest = 1;\n\n  int *aTime;                     /* INSERT timing data */\n  int *aWrite;                    /* Writes per nStep inserts */\n  int *aSelTime;                  /* SELECT timing data */\n  int isFirst = 1;\n  int bSleep = 0;\n\n  /* File to write gnuplot script to. */\n  const char *zOut = \"lsmtest_speed.gnuplot\";\n\n  u32 sys_mask = 0;\n\n  testMallocUninstall(tdb_lsm_env());\n\n  for(i=0; i<nArg; i++){\n    struct Opt { \n      const char *zOpt; \n      int isSwitch;\n    } aOpt[] = {\n      { \"sqlite3\" , 0},\n      { \"leveldb\" , 0},\n      { \"lsm\" , 0},\n      { \"lsm_mt2\" , 0},\n      { \"lsm_mt3\" , 0},\n      { \"kyotocabinet\" , 0},\n      { \"-rows\"     , 1},\n      { \"-sleep\"    , 2},\n      { \"-testmode\" , 3},\n      { \"-out\"      , 4},\n      { 0, 0}\n    };\n    int iSel;\n\n    rc = testArgSelect(aOpt, \"argument\", azArg[i], &iSel);\n    if( rc ) return rc;\n\n    if( aOpt[iSel].isSwitch ){\n      i++;\n\n      if( i>=nArg ){\n        testPrintError(\"option %s requires an argument\\n\", aOpt[iSel].zOpt);\n        return 1;\n      }\n      if( aOpt[iSel].isSwitch==1 ){\n        nRow = atoi(azArg[i]);\n      }\n      if( aOpt[iSel].isSwitch==2 ){\n        nSleep = atoi(azArg[i]);\n      }\n      if( aOpt[iSel].isSwitch==3 ){\n        struct Mode {\n          const char *zMode;\n          int doReadTest;\n          int doWriteTest;\n        } aMode[] = {{\"ro\", 1, 0} , {\"rw\", 1, 1}, {\"wo\", 0, 1}, {0, 0, 0}};\n        int iMode;\n        rc = testArgSelect(aMode, \"option\", azArg[i], &iMode);\n        if( rc ) return rc;\n        doReadTest = aMode[iMode].doReadTest;\n        doWriteTest = aMode[iMode].doWriteTest;\n      }\n      if( aOpt[iSel].isSwitch==4 ){\n        /* The \"-out FILE\" switch. This option is used to specify a file to\n        ** write the gnuplot script to. */\n        zOut = azArg[i];\n      }\n    }else{\n      /* A db name */\n      rc = testArgSelect(aOpt, \"system\", azArg[i], &iSel);\n      if( rc ) return rc;\n      sys_mask |= (1<<iSel);\n    }\n  }\n\n  if( sys_mask==0 ) sys_mask = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3);\n  nRow = MAX(nRow, 100000);\n  nStep = nRow/100;\n  nSelStep = nRow/10;\n  nSelTest = (nSelStep > 100000) ? 100000 : nSelStep;\n\n  aTime = malloc(sizeof(int) * ArraySize(aSys) * nRow/nStep);\n  aWrite = malloc(sizeof(int) * nRow/nStep);\n  aSelTime = malloc(sizeof(int) * ArraySize(aSys) * nRow/nSelStep);\n\n  /* This loop collects the INSERT speed data. */\n  if( doWriteTest ){\n    printf(\"Writing output to file \\\"%s\\\".\\n\",  zOut);\n\n    for(j=0; aSys[j].zLibrary; j++){\n      FILE *pLog = 0;\n      TestDb *pDb;                  /* Database being tested */\n      lsm_db *pLsm;\n      int iDot = 0;\n  \n      if( ((1<<j)&sys_mask)==0 ) continue;\n      if( bSleep && nSleep ) sqlite3_sleep(nSleep);\n      bSleep = 1;\n\n      testCaseBegin(&rc, 0, \"speed.insert.%s\", aSys[j].zLibrary);\n\n      rc = tdb_open(aSys[j].zLibrary, 0, 1, &pDb);\n      if( rc ) return rc;\n\n      pLsm = configure_lsm_db(pDb);\n#if 0\n      pLog = fopen(\"/tmp/speed.log\", \"w\");\n      tdb_lsm_write_hook(pDb, do_speed_write_hook2, (void *)pLog);\n#endif\n  \n      testTimeInit();\n      for(i=0; i<nRow; i+=nStep){\n        int iStep;\n        int nWrite1 = 0, nWrite2 = 0;\n        testCaseProgress(i, nRow, testCaseNDot(), &iDot);\n        if( pLsm ) lsm_info(pLsm, LSM_INFO_NWRITE, &nWrite1);\n        for(iStep=0; iStep<nStep; iStep++){\n          u32 aKey[4];                  /* 16-byte key */\n          u32 aVal[25];                 /* 100 byte value */\n          testPrngArray(i+iStep, aKey, ArraySize(aKey));\n          testPrngArray(i+iStep, aVal, ArraySize(aVal));\n          rc = tdb_write(pDb, aKey, sizeof(aKey), aVal, sizeof(aVal));\n        }\n        aTime[(j*nRow+i)/nStep] = testTimeGet();\n        if( pLsm ) lsm_info(pLsm, LSM_INFO_NWRITE, &nWrite2);\n        aWrite[i/nStep] = nWrite2 - nWrite1;\n      }\n\n      tdb_close(pDb);\n      if( pLog ) fclose(pLog);\n      testCaseFinish(rc);\n    }\n  }\n\n  /* This loop collects the SELECT speed data. */\n  if( doReadTest ){\n    for(j=0; aSys[j].zLibrary; j++){\n      int iDot = 0;\n      TestDb *pDb;                  /* Database being tested */\n\n      if( ((1<<j)&sys_mask)==0 ) continue;\n      if( bSleep && nSleep ) sqlite3_sleep(nSleep);\n      bSleep = 1;\n\n      testCaseBegin(&rc, 0, \"speed.select.%s\", aSys[j].zLibrary);\n\n      if( doWriteTest ){\n        rc = tdb_open(aSys[j].zLibrary, 0, 1, &pDb);\n        if( rc ) return rc;\n        configure_lsm_db(pDb);\n\n        for(i=0; i<nRow; i+=nSelStep){\n          int iStep;\n          int iSel;\n          testCaseProgress(i, nRow, testCaseNDot(), &iDot);\n          for(iStep=0; iStep<nSelStep; iStep++){\n            u32 aKey[4];                  /* 16-byte key */\n            u32 aVal[25];                 /* 100 byte value */\n            testPrngArray(i+iStep, aKey, ArraySize(aKey));\n            testPrngArray(i+iStep, aVal, ArraySize(aVal));\n            rc = tdb_write(pDb, aKey, sizeof(aKey), aVal, sizeof(aVal));\n          }\n    \n          testTimeInit();\n          for(iSel=0; iSel<nSelTest; iSel++){\n            void *pDummy;\n            int nDummy;\n            u32 iKey;\n            u32 aKey[4];                  /* 16-byte key */\n    \n            iKey = testPrngValue(iSel) % (i+nSelStep);\n            testPrngArray(iKey, aKey, ArraySize(aKey));\n            rc = tdb_fetch(pDb, aKey, sizeof(aKey), &pDummy, &nDummy);\n          }\n          aSelTime[(j*nRow+i)/nSelStep] = testTimeGet();\n          tdb_fetch(pDb, 0, 0, 0, 0);\n        }\n      }else{\n        int t;\n        int iSel;\n\n        rc = tdb_open(aSys[j].zLibrary, 0, 0, &pDb);\n        configure_lsm_db(pDb);\n\n        testTimeInit();\n        for(iSel=0; rc==LSM_OK && iSel<nSelTest; iSel++){\n          void *pDummy;\n          int nDummy;\n          u32 iKey;\n          u32 aKey[4];                  /* 16-byte key */\n#ifndef NDEBUG\n          u32 aVal[25];                 /* 100 byte value */\n#endif\n\n          testCaseProgress(iSel, nSelTest, testCaseNDot(), &iDot);\n    \n          iKey = testPrngValue(iSel) % nRow;\n          testPrngArray(iKey, aKey, ArraySize(aKey));\n          rc = tdb_fetch(pDb, aKey, sizeof(aKey), &pDummy, &nDummy);\n\n#ifndef NDEBUG\n          testPrngArray(iKey, aVal, ArraySize(aVal));\n          assert( nDummy==100 && memcmp(aVal, pDummy, 100)==0 );\n#endif\n        }\n        if( rc!=LSM_OK ) return rc;\n\n        t = testTimeGet();\n        tdb_fetch(pDb, 0, 0, 0, 0);\n\n        printf(\"%s: %d selects/second\\n\", \n            aSys[j].zLibrary, (int)((double)nSelTest*1000.0/t)\n        );\n      }\n\n      tdb_close(pDb);\n      testCaseFinish(rc);\n    }\n  }\n\n\n  if( doWriteTest ){\n    FILE *pOut = fopen(zOut, \"w\");\n    if( !pOut ){\n      printf(\"fopen(\\\"%s\\\", \\\"w\\\"): %s\\n\", zOut, strerror(errno));\n      return 1;\n    }\n\n    fprintf(pOut, \"set xlabel \\\"Rows Inserted\\\"\\n\");\n    fprintf(pOut, \"set ylabel \\\"Inserts per second\\\"\\n\");\n    if( doReadTest ){\n      fprintf(pOut, \"set y2label \\\"Selects per second\\\"\\n\");\n    }else if( sys_mask==(1<<2) ){\n      fprintf(pOut, \"set y2label \\\"Page writes per insert\\\"\\n\");\n    }\n    fprintf(pOut, \"set yrange [0:*]\\n\");\n    fprintf(pOut, \"set y2range [0:*]\\n\");\n    fprintf(pOut, \"set xrange [%d:*]\\n\", MAX(nStep, nRow/20) );\n    fprintf(pOut, \"set ytics nomirror\\n\");\n    fprintf(pOut, \"set y2tics nomirror\\n\");\n    fprintf(pOut, \"set key box lw 0.01\\n\");\n    fprintf(pOut, \"plot \");\n  \n    for(j=0; aSys[j].zLibrary; j++){\n      if( (1<<j)&sys_mask ){\n        const char *zLib = aSys[j].zLibrary;\n        fprintf(pOut, \"%s\\\"-\\\" ti \\\"%s INSERT\\\" with lines lc rgb \\\"%s\\\" \", \n            (isFirst?\"\":\", \"), zLib, aSys[j].zColor\n        );\n        if( doReadTest ){\n          fprintf(pOut, \", \\\"-\\\" ti \\\"%s SELECT\\\" \"\n                 \"axis x1y2 with points lw 3 lc rgb \\\"%s\\\"\"\n              , zLib, aSys[j].zColor\n          );\n        }\n        isFirst = 0;\n      }\n    }\n\n    assert( strcmp(aSys[2].zLibrary, \"lsm\")==0 );\n    if( sys_mask==(1<<2) && !doReadTest ){\n      fprintf(pOut, \", \\\"-\\\" ti \\\"lsm pages written\\\" \"\n        \"axis x1y2 with boxes lw 1 lc rgb \\\"grey\\\"\"\n      );\n    }\n  \n    fprintf(pOut, \"\\n\");\n  \n    for(j=0; aSys[j].zLibrary; j++){\n      if( ((1<<j)&sys_mask)==0 ) continue;\n      fprintf(pOut, \"# Rows    Inserts per second\\n\");\n      for(i=0; i<nRow; i+=nStep){\n        int iTime = aTime[(j*nRow+i)/nStep];\n        int ips = (int)((i+nStep)*1000.0 / (double)iTime);\n        fprintf(pOut, \"%d %d\\n\", i+nStep, ips);\n      }\n      fprintf(pOut, \"end\\n\");\n  \n      if( doReadTest ){\n        fprintf(pOut, \"# Rows    Selects per second\\n\");\n        for(i=0; i<nRow; i+=nSelStep){\n          int sps = (int)(nSelTest*1000.0/(double)aSelTime[(j*nRow+i)/nSelStep]);\n          fprintf(pOut, \"%d %d\\n\", i+nSelStep, sps);\n        }\n        fprintf(pOut, \"end\\n\");\n      }else if( sys_mask==(1<<2) ){\n        for(i=0; i<(nRow/nStep); i++){\n          fprintf(pOut, \"%d %f\\n\", i*nStep, (double)aWrite[i] / (double)nStep);\n        }\n        fprintf(pOut, \"end\\n\");\n      }\n    }\n  \n    fprintf(pOut, \"pause -1\\n\");\n    fclose(pOut);\n  }\n\n  free(aTime);\n  free(aSelTime);\n  free(aWrite);\n  testMallocInstall(tdb_lsm_env());\n  return 0;\n}\n\n/*\n** Usage: lsmtest random ?N?\n**\n** This command prints a sequence of zero or more numbers from the PRNG\n** system to stdout. If the \"N\" argument is missing, values the first 10\n** values (i=0, i=1, ... i=9) are printed. Otherwise, the first N.\n**\n** This was added to verify that the PRNG values do not change between\n** runs of the lsmtest program.\n*/\nint do_random_tests(int nArg, char **azArg){\n  int i;\n  int nRand;\n  if( nArg==0 ){\n    nRand = 10;\n  }else if( nArg==1 ){\n    nRand = atoi(azArg[0]);\n  }else{\n    testPrintError(\"Usage: random ?N?\\n\");\n    return -1;\n  }\n  for(i=0; i<nRand; i++){\n    printf(\"0x%x\\n\", testPrngValue(i));\n  }\n  return 0;\n}\n\nstatic int testFormatSize(char *aBuf, int nBuf, i64 nByte){\n  int res;\n  if( nByte<(1<<10) ){\n    res = snprintf(aBuf, nBuf, \"%d byte\", (int)nByte);\n  }else if( nByte<(1<<20) ){\n    res = snprintf(aBuf, nBuf, \"%dK\", (int)(nByte/(1<<10)));\n  }else{\n    res = snprintf(aBuf, nBuf, \"%dM\", (int)(nByte/(1<<20)));\n  }\n  return res;\n}\n\nstatic i64 testReadSize(char *z){\n  int n = strlen(z);\n  char c = z[n-1];\n  i64 nMul = 1;\n\n  switch( c ){\n    case 'g': case 'G':\n      nMul = (1<<30);\n      break;\n\n    case 'm': case 'M':\n      nMul = (1<<20);\n      break;\n\n    case 'k': case 'K':\n      nMul = (1<<10);\n      break;\n\n    default:\n      nMul = 1;\n  }\n\n  return nMul * (i64)atoi(z);\n} \n\n/*\n** Usage: lsmtest writespeed FILESIZE BLOCKSIZE SYNCSIZE\n*/\nstatic int do_writer_test(int nArg, char **azArg){\n  int nBlock;\n  int nSize;\n  int i;\n  int fd;\n  int ms;\n  char aFilesize[32];\n  char aBlockSize[32];\n\n  char *aPage;\n  int *aOrder;\n  int nSync;\n\n  i64 filesize;\n  i64 blocksize;\n  i64 syncsize;\n  int nPage = 4096;\n\n  /* How long to sleep before running a trial (in ms). */\n#if 0\n  const int nSleep = 10000;\n#endif\n  const int nSleep = 0;\n\n  if( nArg!=3 ){\n    testPrintUsage(\"FILESIZE BLOCKSIZE SYNCSIZE\");\n    return -1;\n  }\n\n  filesize = testReadSize(azArg[0]);\n  blocksize = testReadSize(azArg[1]);\n  syncsize = testReadSize(azArg[2]);\n\n  nBlock = (int)(filesize / blocksize);\n  nSize = (int)blocksize;\n  nSync = (int)(syncsize / blocksize);\n\n  aPage = (char *)malloc(4096);\n  aOrder = (int *)malloc(nBlock * sizeof(int));\n  for(i=0; i<nBlock; i++) aOrder[i] = i;\n  for(i=0; i<(nBlock*25); i++){\n    int tmp;\n    u32 a = testPrngValue(i);\n    u32 b = testPrngValue(a);\n    a = a % nBlock;\n    b = b % nBlock;\n    tmp = aOrder[a];\n    aOrder[a] = aOrder[b];\n    aOrder[b] = tmp;\n  }\n\n  testFormatSize(aFilesize, sizeof(aFilesize), (i64)nBlock * (i64)nSize);\n  testFormatSize(aBlockSize, sizeof(aFilesize), nSize);\n\n  printf(\"Testing writing a %s file using %s blocks. \", aFilesize, aBlockSize);\n  if( nSync==1 ){\n    printf(\"Sync after each block.\\n\");\n  }else{\n    printf(\"Sync after each %d blocks.\\n\", nSync);\n  }\n\n  printf(\"Preparing file... \");\n  fflush(stdout);\n  unlink(\"writer.out\");\n  fd = open(\"writer.out\", O_RDWR|O_CREAT|_O_BINARY, 0664);\n  if( fd<0 ){\n    testPrintError(\"open(): %d - %s\\n\", errno, strerror(errno));\n    return -1;\n  }\n  testTimeInit();\n  for(i=0; i<nBlock; i++){\n    int iPg;\n    memset(aPage, i&0xFF, nPage);\n    for(iPg=0; iPg<(nSize/nPage); iPg++){\n      write(fd, aPage, nPage);\n    }\n  }\n  fsync(fd);\n  printf(\"ok (%d ms)\\n\", testTimeGet());\n\n  for(i=0; i<5; i++){\n    int j;\n\n    sqlite3_sleep(nSleep);\n    printf(\"Now writing sequentially...  \");\n    fflush(stdout);\n\n    lseek(fd, 0, SEEK_SET);\n    testTimeInit();\n    for(j=0; j<nBlock; j++){\n      int iPg;\n      if( ((j+1)%nSync)==0 ) fdatasync(fd);\n      memset(aPage, j&0xFF, nPage);\n      for(iPg=0; iPg<(nSize/nPage); iPg++){\n        write(fd, aPage, nPage);\n      }\n    }\n    fdatasync(fd);\n    ms = testTimeGet();\n    printf(\"%d ms\\n\", ms);\n    sqlite3_sleep(nSleep);\n    printf(\"Now in an arbitrary order... \");\n\n    fflush(stdout);\n    testTimeInit();\n    for(j=0; j<nBlock; j++){\n      int iPg;\n      if( ((j+1)%nSync)==0 ) fdatasync(fd);\n      lseek(fd, aOrder[j]*nSize, SEEK_SET);\n      memset(aPage, j&0xFF, nPage);\n      for(iPg=0; iPg<(nSize/nPage); iPg++){\n        write(fd, aPage, nPage);\n      }\n    }\n    fdatasync(fd);\n    ms = testTimeGet();\n    printf(\"%d ms\\n\", ms);\n  }\n\n  close(fd);\n  free(aPage);\n  free(aOrder);\n\n  return 0;\n}\n\nstatic void do_insert_work_hook(lsm_db *db, void *p){\n  char *z = 0;\n  lsm_info(db, LSM_INFO_DB_STRUCTURE, &z);\n  if( z ){\n    printf(\"%s\\n\", z);\n    fflush(stdout);\n    lsm_free(lsm_get_env(db), z);\n  }\n\n  unused_parameter(p);\n}\n\ntypedef struct InsertWriteHook InsertWriteHook;\nstruct InsertWriteHook {\n  FILE *pOut;\n  int bLog;\n  i64 iOff;\n  int nData;\n};\n\nstatic void flushHook(InsertWriteHook *pHook){\n  if( pHook->nData ){\n    fprintf(pHook->pOut, \"write %s %d %d\\n\", \n        (pHook->bLog ? \"log\" : \"db\"), (int)pHook->iOff, pHook->nData\n    );\n    pHook->nData = 0;\n    fflush(pHook->pOut);\n  }\n}\n\nstatic void do_insert_write_hook(\n  void *pCtx,\n  int bLog,\n  i64 iOff,\n  int nData,\n  int nUs\n){\n  InsertWriteHook *pHook = (InsertWriteHook *)pCtx;\n  if( bLog ) return;\n\n  if( nData==0 ){\n    flushHook(pHook);\n    fprintf(pHook->pOut, \"sync %s\\n\", (bLog ? \"log\" : \"db\"));\n  }else if( pHook->nData \n         && bLog==pHook->bLog \n         && iOff==(pHook->iOff+pHook->nData) \n  ){\n    pHook->nData += nData;\n  }else{\n    flushHook(pHook);\n    pHook->bLog = bLog;\n    pHook->iOff = iOff;\n    pHook->nData = nData;\n  }\n}\n\nstatic int do_replay(int nArg, char **azArg){\n  char aBuf[4096];\n  FILE *pInput;\n  FILE *pClose = 0;\n  const char *zDb;\n\n  lsm_env *pEnv;\n  lsm_file *pOut;\n  int rc;\n\n  if( nArg!=2 ){\n    testPrintError(\"Usage: replay WRITELOG FILE\\n\");\n    return 1;\n  }\n\n  if( strcmp(azArg[0], \"-\")==0 ){\n    pInput = stdin;\n  }else{\n    pClose = pInput = fopen(azArg[0], \"r\");\n  }\n  zDb = azArg[1];\n  pEnv = tdb_lsm_env();\n  rc = pEnv->xOpen(pEnv, zDb, 0, &pOut);\n  if( rc!=LSM_OK ) return rc;\n\n  while( feof(pInput)==0 ){\n    char zLine[80];\n    fgets(zLine, sizeof(zLine)-1, pInput);\n    zLine[sizeof(zLine)-1] = '\\0';\n\n    if( 0==memcmp(\"sync db\", zLine, 7) ){\n      rc = pEnv->xSync(pOut);\n      if( rc!=0 ) break;\n    }else{\n      int iOff;\n      int nData;\n      int nMatch;\n      nMatch = sscanf(zLine, \"write db %d %d\", &iOff, &nData);\n      if( nMatch==2 ){\n        int i;\n        for(i=0; i<nData; i+=sizeof(aBuf)){\n          memset(aBuf, i&0xFF, sizeof(aBuf));\n          rc = pEnv->xWrite(pOut, iOff+i, aBuf, sizeof(aBuf));\n          if( rc!=0 ) break;\n        }\n      }\n    }\n  }\n  if( pClose ) fclose(pClose);\n  pEnv->xClose(pOut);\n\n  return rc;\n}\n\nstatic int do_insert(int nArg, char **azArg){\n  const char *zDb = \"lsm\";\n  TestDb *pDb = 0;\n  int i;\n  int rc;\n  const int nRow = 1 * 1000 * 1000;\n\n  DatasourceDefn defn = { TEST_DATASOURCE_RANDOM, 8, 15, 80, 150 };\n  Datasource *pData = 0;\n\n  if( nArg>1 ){\n    testPrintError(\"Usage: insert ?DATABASE?\\n\");\n    return 1;\n  }\n  if( nArg==1 ){ zDb = azArg[0]; }\n\n  testMallocUninstall(tdb_lsm_env());\n  for(i=0; zDb[i] && zDb[i]!='='; i++);\n  if( zDb[i] ){\n    rc = tdb_lsm_open(zDb, \"testdb.lsm\", 1, &pDb);\n  }else{\n    rc = tdb_open(zDb, 0, 1, &pDb);\n  }\n\n  if( rc!=0 ){\n    testPrintError(\"Error opening db \\\"%s\\\": %d\\n\", zDb, rc);\n  }else{\n    InsertWriteHook hook;\n    memset(&hook, 0, sizeof(hook));\n    hook.pOut = fopen(\"writelog.txt\", \"w\");\n\n    pData = testDatasourceNew(&defn);\n    tdb_lsm_config_work_hook(pDb, do_insert_work_hook, 0);\n    tdb_lsm_write_hook(pDb, do_insert_write_hook, (void *)&hook);\n\n    if( rc==0 ){\n      for(i=0; i<nRow; i++){\n        void *pKey; int nKey;     /* Database key to insert */\n        void *pVal; int nVal;     /* Database value to insert */\n        testDatasourceEntry(pData, i, &pKey, &nKey, &pVal, &nVal);\n        tdb_write(pDb, pKey, nKey, pVal, nVal);\n      }\n    }\n\n    testDatasourceFree(pData);\n    tdb_close(pDb);\n    flushHook(&hook);\n    fclose(hook.pOut);\n  }\n  testMallocInstall(tdb_lsm_env());\n\n  return rc;\n}\n\nstatic int st_do_show(int a, char **b)      { return do_show(a, b); }\nstatic int st_do_work(int a, char **b)      { return do_work(a, b); }\nstatic int st_do_io(int a, char **b)        { return do_io(a, b); }\n\n#ifdef __linux__\n#include <sys/time.h>\n#include <sys/resource.h>\n\nstatic void lsmtest_rusage_report(void){\n  struct rusage r;\n  memset(&r, 0, sizeof(r));\n\n  getrusage(RUSAGE_SELF, &r);\n  printf(\"# getrusage: { ru_maxrss %d ru_oublock %d ru_inblock %d }\\n\", \n      (int)r.ru_maxrss, (int)r.ru_oublock, (int)r.ru_inblock\n  );\n}\n#else\nstatic void lsmtest_rusage_report(void){\n  /* no-op */\n}\n#endif\n\nint main(int argc, char **argv){\n  struct TestFunc {\n    const char *zName;\n    int bRusageReport;\n    int (*xFunc)(int, char **);\n  } aTest[] = {\n    {\"random\",      1, do_random_tests},\n    {\"writespeed\",  1, do_writer_test},\n    {\"io\",          1, st_do_io},\n\n    {\"insert\",      1, do_insert},\n    {\"replay\",      1, do_replay},\n\n    {\"speed\",       1, do_speed_tests},\n    {\"speed2\",      1, do_speed_test2},\n    {\"show\",        0, st_do_show},\n    {\"work\",        1, st_do_work},\n    {\"test\",        1, do_test},\n\n    {0, 0}\n  };\n  int rc;                         /* Return Code */\n  int iFunc;                      /* Index into aTest[] */\n\n  int nLeakAlloc = 0;             /* Allocations leaked by lsm */\n  int nLeakByte = 0;              /* Bytes leaked by lsm */\n\n#ifdef LSM_DEBUG_MEM\n  FILE *pReport = 0;              /* lsm malloc() report file */\n  const char *zReport = \"malloc.txt generated\";\n#else\n  const char *zReport = \"malloc.txt NOT generated\";\n#endif\n\n  testMallocInstall(tdb_lsm_env());\n\n  if( argc<2 ){\n    testPrintError(\"Usage: %s sub-command ?args...?\\n\", argv[0]);\n    return -1;\n  }\n\n  /* Initialize error reporting */\n  testErrorInit(argc, argv);\n\n  /* Initialize PRNG system */\n  testPrngInit();\n\n  rc = testArgSelect(aTest, \"sub-command\", argv[1], &iFunc);\n  if( rc==0 ){\n    rc = aTest[iFunc].xFunc(argc-2, &argv[2]);\n  }\n\n#ifdef LSM_DEBUG_MEM\n  pReport = fopen(\"malloc.txt\", \"w\");\n  testMallocCheck(tdb_lsm_env(), &nLeakAlloc, &nLeakByte, pReport);\n  fclose(pReport);\n#else\n  testMallocCheck(tdb_lsm_env(), &nLeakAlloc, &nLeakByte, 0);\n#endif\n\n  if( nLeakAlloc ){\n    testPrintError(\"Leaked %d bytes in %d allocations (%s)\\n\", \n        nLeakByte, nLeakAlloc, zReport\n    );\n    if( rc==0 ) rc = -1;\n  }\n  testMallocUninstall(tdb_lsm_env());\n\n  if( aTest[iFunc].bRusageReport ){\n    lsmtest_rusage_report();\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_mem.c",
    "content": "\n#include <stdio.h>\n#include <assert.h>\n#include <string.h>\n\n#define ArraySize(x) ((int)(sizeof(x) / sizeof((x)[0])))\n\n#define MIN(x,y) ((x)<(y) ? (x) : (y))\n\ntypedef unsigned int  u32;\ntypedef unsigned char u8;\ntypedef long long int i64;\ntypedef unsigned long long int u64;\n\n#if defined(__GLIBC__) && defined(LSM_DEBUG_MEM)\n  extern int backtrace(void**,int);\n  extern void backtrace_symbols_fd(void*const*,int,int);\n# define TM_BACKTRACE 12\n#else\n# define backtrace(A,B) 1\n# define backtrace_symbols_fd(A,B,C)\n#endif\n\n\ntypedef struct TmBlockHdr TmBlockHdr;\ntypedef struct TmAgg TmAgg;\ntypedef struct TmGlobal TmGlobal;\n\nstruct TmGlobal {\n  /* Linked list of all currently outstanding allocations. And a table of\n  ** all allocations, past and present, indexed by backtrace() info.  */\n  TmBlockHdr *pFirst;\n#ifdef TM_BACKTRACE\n  TmAgg *aHash[10000];\n#endif\n\n  /* Underlying malloc/realloc/free functions */\n  void *(*xMalloc)(int);          /* underlying malloc(3) function */\n  void *(*xRealloc)(void *, int); /* underlying realloc(3) function */\n  void (*xFree)(void *);          /* underlying free(3) function */\n\n  /* Mutex to protect pFirst and aHash */\n  void (*xEnterMutex)(TmGlobal*); /* Call this to enter the mutex */\n  void (*xLeaveMutex)(TmGlobal*); /* Call this to leave mutex */\n  void (*xDelMutex)(TmGlobal*);   /* Call this to delete mutex */\n  void *pMutex;                   /* Mutex handle */\n\n  void *(*xSaveMalloc)(void *, size_t);\n  void *(*xSaveRealloc)(void *, void *, size_t);\n  void (*xSaveFree)(void *, void *);\n\n  /* OOM injection scheduling. If nCountdown is greater than zero when a \n  ** malloc attempt is made, it is decremented. If this means nCountdown \n  ** transitions from 1 to 0, then the allocation fails. If bPersist is true \n  ** when this happens, nCountdown is then incremented back to 1 (so that the \n  ** next attempt fails too).  \n  */\n  int nCountdown;\n  int bPersist;\n  int bEnable;\n  void (*xHook)(void *);\n  void *pHookCtx;\n};\n\nstruct TmBlockHdr {\n  TmBlockHdr *pNext;\n  TmBlockHdr *pPrev;\n  int nByte;\n#ifdef TM_BACKTRACE\n  TmAgg *pAgg;\n#endif\n  u32 iForeGuard;\n};\n\n#ifdef TM_BACKTRACE\nstruct TmAgg {\n  int nAlloc;                     /* Number of allocations at this path */\n  int nByte;                      /* Total number of bytes allocated */\n  int nOutAlloc;                  /* Number of outstanding allocations */\n  int nOutByte;                   /* Number of outstanding bytes */\n  void *aFrame[TM_BACKTRACE];     /* backtrace() output */\n  TmAgg *pNext;                   /* Next object in hash-table collision */\n};\n#endif\n\n#define FOREGUARD 0x80F5E153\n#define REARGUARD 0xE4676B53\nstatic const u32 rearguard = REARGUARD;\n\n#define ROUND8(x) (((x)+7)&~7)\n\n#define BLOCK_HDR_SIZE (ROUND8( sizeof(TmBlockHdr) ))\n\nstatic void lsmtest_oom_error(void){\n  static int nErr = 0;\n  nErr++;\n}\n\nstatic void tmEnterMutex(TmGlobal *pTm){\n  pTm->xEnterMutex(pTm);\n}\nstatic void tmLeaveMutex(TmGlobal *pTm){\n  pTm->xLeaveMutex(pTm);\n}\n\nstatic void *tmMalloc(TmGlobal *pTm, int nByte){\n  TmBlockHdr *pNew;               /* New allocation header block */\n  u8 *pUser;                      /* Return value */\n  int nReq;                       /* Total number of bytes requested */\n\n  assert( sizeof(rearguard)==4 );\n  nReq = BLOCK_HDR_SIZE + nByte + 4;\n  pNew = (TmBlockHdr *)pTm->xMalloc(nReq);\n  memset(pNew, 0, sizeof(TmBlockHdr));\n\n  tmEnterMutex(pTm);\n  assert( pTm->nCountdown>=0 );\n  assert( pTm->bPersist==0 || pTm->bPersist==1 );\n\n  if( pTm->bEnable && pTm->nCountdown==1 ){\n    /* Simulate an OOM error. */\n    lsmtest_oom_error();\n    pTm->xFree(pNew);\n    pTm->nCountdown = pTm->bPersist;\n    if( pTm->xHook ) pTm->xHook(pTm->pHookCtx);\n    pUser = 0;\n  }else{\n    if( pTm->bEnable && pTm->nCountdown ) pTm->nCountdown--;\n\n    pNew->iForeGuard = FOREGUARD;\n    pNew->nByte = nByte;\n    pNew->pNext = pTm->pFirst;\n\n    if( pTm->pFirst ){\n      pTm->pFirst->pPrev = pNew;\n    }\n    pTm->pFirst = pNew;\n\n    pUser = &((u8 *)pNew)[BLOCK_HDR_SIZE];\n    memset(pUser, 0x56, nByte);\n    memcpy(&pUser[nByte], &rearguard, 4);\n\n#ifdef TM_BACKTRACE\n    {\n      TmAgg *pAgg;\n      int i;\n      u32 iHash = 0;\n      void *aFrame[TM_BACKTRACE];\n      memset(aFrame, 0, sizeof(aFrame));\n      backtrace(aFrame, TM_BACKTRACE);\n\n      for(i=0; i<ArraySize(aFrame); i++){\n        iHash += (u64)(aFrame[i]) + (iHash<<3);\n      }\n      iHash = iHash % ArraySize(pTm->aHash);\n\n      for(pAgg=pTm->aHash[iHash]; pAgg; pAgg=pAgg->pNext){\n        if( memcmp(pAgg->aFrame, aFrame, sizeof(aFrame))==0 ) break;\n      }\n      if( !pAgg ){\n        pAgg = (TmAgg *)pTm->xMalloc(sizeof(TmAgg));\n        memset(pAgg, 0, sizeof(TmAgg));\n        memcpy(pAgg->aFrame, aFrame, sizeof(aFrame));\n        pAgg->pNext = pTm->aHash[iHash];\n        pTm->aHash[iHash] = pAgg;\n      }\n      pAgg->nAlloc++;\n      pAgg->nByte += nByte;\n      pAgg->nOutAlloc++;\n      pAgg->nOutByte += nByte;\n      pNew->pAgg = pAgg;\n    }\n#endif\n  }\n\n  tmLeaveMutex(pTm);\n  return pUser;\n}\n\nstatic void tmFree(TmGlobal *pTm, void *p){\n  if( p ){\n    TmBlockHdr *pHdr;\n    u8 *pUser = (u8 *)p;\n\n    tmEnterMutex(pTm);\n    pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);\n    assert( pHdr->iForeGuard==FOREGUARD );\n    assert( 0==memcmp(&pUser[pHdr->nByte], &rearguard, 4) );\n\n    if( pHdr->pPrev ){\n      assert( pHdr->pPrev->pNext==pHdr );\n      pHdr->pPrev->pNext = pHdr->pNext;\n    }else{\n      assert( pHdr==pTm->pFirst );\n      pTm->pFirst = pHdr->pNext;\n    }\n    if( pHdr->pNext ){\n      assert( pHdr->pNext->pPrev==pHdr );\n      pHdr->pNext->pPrev = pHdr->pPrev;\n    }\n\n#ifdef TM_BACKTRACE\n    pHdr->pAgg->nOutAlloc--;\n    pHdr->pAgg->nOutByte -= pHdr->nByte;\n#endif\n\n    tmLeaveMutex(pTm);\n    memset(pUser, 0x58, pHdr->nByte);\n    memset(pHdr, 0x57, sizeof(TmBlockHdr));\n    pTm->xFree(pHdr);\n  }\n}\n\nstatic void *tmRealloc(TmGlobal *pTm, void *p, int nByte){\n  void *pNew;\n\n  pNew = tmMalloc(pTm, nByte);\n  if( pNew && p ){\n    TmBlockHdr *pHdr;\n    u8 *pUser = (u8 *)p;\n    pHdr = (TmBlockHdr *)(pUser - BLOCK_HDR_SIZE);\n    memcpy(pNew, p, MIN(nByte, pHdr->nByte));\n    tmFree(pTm, p);\n  }\n  return pNew;\n}\n\nstatic void tmMallocOom(\n  TmGlobal *pTm, \n  int nCountdown, \n  int bPersist,\n  void (*xHook)(void *),\n  void *pHookCtx\n){\n  assert( nCountdown>=0 );\n  assert( bPersist==0 || bPersist==1 );\n  pTm->nCountdown = nCountdown;\n  pTm->bPersist = bPersist;\n  pTm->xHook = xHook;\n  pTm->pHookCtx = pHookCtx;\n  pTm->bEnable = 1;\n}\n\nstatic void tmMallocOomEnable(\n  TmGlobal *pTm, \n  int bEnable\n){\n  pTm->bEnable = bEnable;\n}\n\nstatic void tmMallocCheck(\n  TmGlobal *pTm,\n  int *pnLeakAlloc,\n  int *pnLeakByte,\n  FILE *pFile\n){\n  TmBlockHdr *pHdr;\n  int nLeak = 0;\n  int nByte = 0;\n\n  if( pTm==0 ) return;\n\n  for(pHdr=pTm->pFirst; pHdr; pHdr=pHdr->pNext){\n    nLeak++; \n    nByte += pHdr->nByte;\n  }\n  if( pnLeakAlloc ) *pnLeakAlloc = nLeak;\n  if( pnLeakByte ) *pnLeakByte = nByte;\n\n#ifdef TM_BACKTRACE\n  if( pFile ){\n    int i;\n    fprintf(pFile, \"LEAKS\\n\");\n    for(i=0; i<ArraySize(pTm->aHash); i++){\n      TmAgg *pAgg;\n      for(pAgg=pTm->aHash[i]; pAgg; pAgg=pAgg->pNext){\n        if( pAgg->nOutAlloc ){\n          int j;\n          fprintf(pFile, \"%d %d \", pAgg->nOutByte, pAgg->nOutAlloc);\n          for(j=0; j<TM_BACKTRACE; j++){\n            fprintf(pFile, \"%p \", pAgg->aFrame[j]);\n          }\n          fprintf(pFile, \"\\n\");\n        }\n      }\n    }\n    fprintf(pFile, \"\\nALLOCATIONS\\n\");\n    for(i=0; i<ArraySize(pTm->aHash); i++){\n      TmAgg *pAgg;\n      for(pAgg=pTm->aHash[i]; pAgg; pAgg=pAgg->pNext){\n        int j;\n        fprintf(pFile, \"%d %d \", pAgg->nByte, pAgg->nAlloc);\n        for(j=0; j<TM_BACKTRACE; j++) fprintf(pFile, \"%p \", pAgg->aFrame[j]);\n        fprintf(pFile, \"\\n\");\n      }\n    }\n  }\n#else\n  (void)pFile;\n#endif\n}\n\n\n#include \"lsm.h\"\n#include \"stdlib.h\"\n\ntypedef struct LsmMutex LsmMutex;\nstruct LsmMutex {\n  lsm_env *pEnv;\n  lsm_mutex *pMutex;\n};\n\nstatic void tmLsmMutexEnter(TmGlobal *pTm){\n  LsmMutex *p = (LsmMutex *)pTm->pMutex;\n  p->pEnv->xMutexEnter(p->pMutex);\n}\nstatic void tmLsmMutexLeave(TmGlobal *pTm){\n  LsmMutex *p = (LsmMutex *)(pTm->pMutex);\n  p->pEnv->xMutexLeave(p->pMutex);\n}\nstatic void tmLsmMutexDel(TmGlobal *pTm){\n  LsmMutex *p = (LsmMutex *)pTm->pMutex;\n  pTm->xFree(p);\n}\nstatic void *tmLsmMalloc(int n){ return malloc(n); }\nstatic void tmLsmFree(void *ptr){ free(ptr); }\nstatic void *tmLsmRealloc(void *ptr, int n){ return realloc(ptr, n); }\n\nstatic void *tmLsmEnvMalloc(lsm_env *p, size_t n){ \n  return tmMalloc((TmGlobal *)(p->pMemCtx), n); \n}\nstatic void tmLsmEnvFree(lsm_env *p, void *ptr){ \n  tmFree((TmGlobal *)(p->pMemCtx), ptr); \n}\nstatic void *tmLsmEnvRealloc(lsm_env *p, void *ptr, size_t n){ \n  return tmRealloc((TmGlobal *)(p->pMemCtx), ptr, n);\n}\n\nvoid testMallocInstall(lsm_env *pEnv){\n  TmGlobal *pGlobal;\n  LsmMutex *pMutex;\n  assert( pEnv->pMemCtx==0 );\n\n  /* Allocate and populate a TmGlobal structure. */\n  pGlobal = (TmGlobal *)tmLsmMalloc(sizeof(TmGlobal));\n  memset(pGlobal, 0, sizeof(TmGlobal));\n  pGlobal->xMalloc = tmLsmMalloc;\n  pGlobal->xRealloc = tmLsmRealloc;\n  pGlobal->xFree = tmLsmFree;\n  pMutex = (LsmMutex *)pGlobal->xMalloc(sizeof(LsmMutex));\n  pMutex->pEnv = pEnv;\n  pEnv->xMutexStatic(pEnv, LSM_MUTEX_HEAP, &pMutex->pMutex);\n  pGlobal->xEnterMutex = tmLsmMutexEnter;\n  pGlobal->xLeaveMutex = tmLsmMutexLeave;\n  pGlobal->xDelMutex = tmLsmMutexDel;\n  pGlobal->pMutex = (void *)pMutex;\n\n  pGlobal->xSaveMalloc = pEnv->xMalloc;\n  pGlobal->xSaveRealloc = pEnv->xRealloc;\n  pGlobal->xSaveFree = pEnv->xFree;\n\n  /* Set up pEnv to the use the new TmGlobal */\n  pEnv->pMemCtx = (void *)pGlobal;\n  pEnv->xMalloc = tmLsmEnvMalloc;\n  pEnv->xRealloc = tmLsmEnvRealloc;\n  pEnv->xFree = tmLsmEnvFree;\n}\n\nvoid testMallocUninstall(lsm_env *pEnv){\n  TmGlobal *p = (TmGlobal *)pEnv->pMemCtx;\n  pEnv->pMemCtx = 0;\n  if( p ){\n    pEnv->xMalloc = p->xSaveMalloc;\n    pEnv->xRealloc = p->xSaveRealloc;\n    pEnv->xFree = p->xSaveFree;\n    p->xDelMutex(p);\n    tmLsmFree(p);\n  }\n}\n\nvoid testMallocCheck(\n  lsm_env *pEnv,\n  int *pnLeakAlloc,\n  int *pnLeakByte,\n  FILE *pFile\n){\n  if( pEnv->pMemCtx==0 ){\n    *pnLeakAlloc = 0;\n    *pnLeakByte = 0;\n  }else{\n    tmMallocCheck((TmGlobal *)(pEnv->pMemCtx), pnLeakAlloc, pnLeakByte, pFile);\n  }\n}\n\nvoid testMallocOom(\n  lsm_env *pEnv, \n  int nCountdown, \n  int bPersist,\n  void (*xHook)(void *),\n  void *pHookCtx\n){\n  TmGlobal *pTm = (TmGlobal *)(pEnv->pMemCtx);\n  tmMallocOom(pTm, nCountdown, bPersist, xHook, pHookCtx);\n}\n\nvoid testMallocOomEnable(lsm_env *pEnv, int bEnable){\n  TmGlobal *pTm = (TmGlobal *)(pEnv->pMemCtx);\n  tmMallocOomEnable(pTm, bEnable);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_tdb.c",
    "content": "\n/*\n** This program attempts to test the correctness of some facets of the \n** LSM database library. Specifically, that the contents of the database\n** are maintained correctly during a series of inserts and deletes.\n*/\n\n\n#include \"lsmtest_tdb.h\"\n#include \"lsm.h\"\n\n#include \"lsmtest.h\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#ifndef _WIN32\n# include <unistd.h>\n#endif\n#include <stdio.h>\n\n\ntypedef struct SqlDb SqlDb;\n\nstatic int error_transaction_function(TestDb *p, int iLevel){ \n  unused_parameter(p);\n  unused_parameter(iLevel);\n  return -1; \n}\n\n\n/*************************************************************************\n** Begin wrapper for LevelDB.\n*/\n#ifdef HAVE_LEVELDB\n\n#include <leveldb/c.h>\n\ntypedef struct LevelDb LevelDb;\nstruct LevelDb {\n  TestDb base;\n  leveldb_t *db;\n  leveldb_options_t *pOpt;\n  leveldb_writeoptions_t *pWriteOpt;\n  leveldb_readoptions_t *pReadOpt;\n\n  char *pVal;\n};\n\nstatic int test_leveldb_close(TestDb *pTestDb){\n  LevelDb *pDb = (LevelDb *)pTestDb;\n\n  leveldb_close(pDb->db);\n  leveldb_writeoptions_destroy(pDb->pWriteOpt);\n  leveldb_readoptions_destroy(pDb->pReadOpt);\n  leveldb_options_destroy(pDb->pOpt);\n  free(pDb->pVal);\n  free(pDb);\n\n  return 0;\n}\n\nstatic int test_leveldb_write(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void *pVal, \n  int nVal\n){\n  LevelDb *pDb = (LevelDb *)pTestDb;\n  char *zErr = 0;\n  leveldb_put(pDb->db, pDb->pWriteOpt, pKey, nKey, pVal, nVal, &zErr);\n  return (zErr!=0);\n}\n\nstatic int test_leveldb_delete(TestDb *pTestDb, void *pKey, int nKey){\n  LevelDb *pDb = (LevelDb *)pTestDb;\n  char *zErr = 0;\n  leveldb_delete(pDb->db, pDb->pWriteOpt, pKey, nKey, &zErr);\n  return (zErr!=0);\n}\n\nstatic int test_leveldb_fetch(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void **ppVal, \n  int *pnVal\n){\n  LevelDb *pDb = (LevelDb *)pTestDb;\n  char *zErr = 0;\n  size_t nVal = 0;\n\n  if( pKey==0 ) return 0;\n  free(pDb->pVal);\n  pDb->pVal = leveldb_get(pDb->db, pDb->pReadOpt, pKey, nKey, &nVal, &zErr);\n  *ppVal = (void *)(pDb->pVal);\n  if( pDb->pVal==0 ){\n    *pnVal = -1;\n  }else{\n    *pnVal = (int)nVal;\n  }\n\n  return (zErr!=0);\n}\n\nstatic int test_leveldb_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pKey1, int nKey1,         /* Start of search */\n  void *pKey2, int nKey2,         /* End of search */\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  LevelDb *pDb = (LevelDb *)pTestDb;\n  leveldb_iterator_t *iter;\n\n  iter = leveldb_create_iterator(pDb->db, pDb->pReadOpt);\n\n  if( bReverse==0 ){\n    if( pKey1 ){\n      leveldb_iter_seek(iter, pKey1, nKey1);\n    }else{\n      leveldb_iter_seek_to_first(iter);\n    }\n  }else{\n    if( pKey2 ){\n      leveldb_iter_seek(iter, pKey2, nKey2);\n\n      if( leveldb_iter_valid(iter)==0 ){\n        leveldb_iter_seek_to_last(iter);\n      }else{\n        const char *k; size_t n;\n        int res;\n        k = leveldb_iter_key(iter, &n);\n        res = memcmp(k, pKey2, MIN(n, nKey2));\n        if( res==0 ) res = n - nKey2;\n        assert( res>=0 );\n        if( res>0 ){\n          leveldb_iter_prev(iter);\n        }\n      }\n    }else{\n      leveldb_iter_seek_to_last(iter);\n    }\n  }\n\n\n  while( leveldb_iter_valid(iter) ){\n    const char *k; size_t n;\n    const char *v; size_t n2;\n    int res;\n\n    k = leveldb_iter_key(iter, &n);\n    if( bReverse==0 && pKey2 ){\n      res = memcmp(k, pKey2, MIN(n, nKey2));\n      if( res==0 ) res = n - nKey2;\n      if( res>0 ) break;\n    }\n    if( bReverse!=0 && pKey1 ){\n      res = memcmp(k, pKey1, MIN(n, nKey1));\n      if( res==0 ) res = n - nKey1;\n      if( res<0 ) break;\n    }\n\n    v = leveldb_iter_value(iter, &n2);\n\n    xCallback(pCtx, (void *)k, n, (void *)v, n2);\n\n    if( bReverse==0 ){\n      leveldb_iter_next(iter);\n    }else{\n      leveldb_iter_prev(iter);\n    }\n  }\n\n  leveldb_iter_destroy(iter);\n  return 0;\n}\n\nstatic int test_leveldb_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  static const DatabaseMethods LeveldbMethods = {\n    test_leveldb_close,\n    test_leveldb_write,\n    test_leveldb_delete,\n    0,\n    test_leveldb_fetch,\n    test_leveldb_scan,\n    error_transaction_function,\n    error_transaction_function,\n    error_transaction_function\n  };\n\n  LevelDb *pLevelDb;\n  char *zErr = 0;\n\n  if( bClear ){\n    char *zCmd = sqlite3_mprintf(\"rm -rf %s\\n\", zFilename);\n    system(zCmd);\n    sqlite3_free(zCmd);\n  }\n\n  pLevelDb = (LevelDb *)malloc(sizeof(LevelDb));\n  memset(pLevelDb, 0, sizeof(LevelDb));\n\n  pLevelDb->pOpt = leveldb_options_create();\n  leveldb_options_set_create_if_missing(pLevelDb->pOpt, 1);\n  pLevelDb->pWriteOpt = leveldb_writeoptions_create();\n  pLevelDb->pReadOpt = leveldb_readoptions_create();\n\n  pLevelDb->db = leveldb_open(pLevelDb->pOpt, zFilename, &zErr);\n\n  if( zErr ){\n    test_leveldb_close((TestDb *)pLevelDb);\n    *ppDb = 0;\n    return 1;\n  }\n\n  *ppDb = (TestDb *)pLevelDb;\n  pLevelDb->base.pMethods = &LeveldbMethods;\n  return 0;\n}\n#endif  /* HAVE_LEVELDB */\n/* \n** End wrapper for LevelDB.\n*************************************************************************/\n\n#ifdef HAVE_KYOTOCABINET\nstatic int kc_close(TestDb *pTestDb){\n  return test_kc_close(pTestDb);\n}\n\nstatic int kc_write(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void *pVal, \n  int nVal\n){\n  return test_kc_write(pTestDb, pKey, nKey, pVal, nVal);\n}\n\nstatic int kc_delete(TestDb *pTestDb, void *pKey, int nKey){\n  return test_kc_delete(pTestDb, pKey, nKey);\n}\n\nstatic int kc_delete_range(\n  TestDb *pTestDb, \n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2\n){\n  return test_kc_delete_range(pTestDb, pKey1, nKey1, pKey2, nKey2);\n}\n\nstatic int kc_fetch(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void **ppVal, \n  int *pnVal\n){\n  if( pKey==0 ) return LSM_OK;\n  return test_kc_fetch(pTestDb, pKey, nKey, ppVal, pnVal);\n}\n\nstatic int kc_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pFirst, int nFirst,\n  void *pLast, int nLast,\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  return test_kc_scan(\n      pTestDb, pCtx, bReverse, pFirst, nFirst, pLast, nLast, xCallback\n  );\n}\n\nstatic int kc_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  static const DatabaseMethods KcdbMethods = {\n    kc_close,\n    kc_write,\n    kc_delete,\n    kc_delete_range,\n    kc_fetch,\n    kc_scan,\n    error_transaction_function,\n    error_transaction_function,\n    error_transaction_function\n  };\n\n  int rc;\n  TestDb *pTestDb = 0;\n\n  rc = test_kc_open(zFilename, bClear, &pTestDb);\n  if( rc!=0 ){\n    *ppDb = 0;\n    return rc;\n  }\n  pTestDb->pMethods = &KcdbMethods;\n  *ppDb = pTestDb;\n  return 0;\n}\n#endif /* HAVE_KYOTOCABINET */\n/* \n** End wrapper for Kyoto cabinet.\n*************************************************************************/\n\n#ifdef HAVE_MDB\nstatic int mdb_close(TestDb *pTestDb){\n  return test_mdb_close(pTestDb);\n}\n\nstatic int mdb_write(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void *pVal, \n  int nVal\n){\n  return test_mdb_write(pTestDb, pKey, nKey, pVal, nVal);\n}\n\nstatic int mdb_delete(TestDb *pTestDb, void *pKey, int nKey){\n  return test_mdb_delete(pTestDb, pKey, nKey);\n}\n\nstatic int mdb_fetch(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void **ppVal, \n  int *pnVal\n){\n  if( pKey==0 ) return LSM_OK;\n  return test_mdb_fetch(pTestDb, pKey, nKey, ppVal, pnVal);\n}\n\nstatic int mdb_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pFirst, int nFirst,\n  void *pLast, int nLast,\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  return test_mdb_scan(\n      pTestDb, pCtx, bReverse, pFirst, nFirst, pLast, nLast, xCallback\n  );\n}\n\nstatic int mdb_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  static const DatabaseMethods KcdbMethods = {\n    mdb_close,\n    mdb_write,\n    mdb_delete,\n    0,\n    mdb_fetch,\n    mdb_scan,\n    error_transaction_function,\n    error_transaction_function,\n    error_transaction_function\n  };\n\n  int rc;\n  TestDb *pTestDb = 0;\n\n  rc = test_mdb_open(zSpec, zFilename, bClear, &pTestDb);\n  if( rc!=0 ){\n    *ppDb = 0;\n    return rc;\n  }\n  pTestDb->pMethods = &KcdbMethods;\n  *ppDb = pTestDb;\n  return 0;\n}\n#endif /* HAVE_MDB */\n\n/*************************************************************************\n** Begin wrapper for SQLite.\n*/\n\n/*\n** nOpenTrans:\n**   The number of open nested transactions, in the same sense as used\n**   by the tdb_begin/commit/rollback and SQLite 4 KV interfaces. If this\n**   value is 0, there are no transactions open at all. If it is 1, then\n**   there is a read transaction. If it is 2 or greater, then there are\n**   (nOpenTrans-1) nested write transactions open.\n*/\nstruct SqlDb {\n  TestDb base;\n  sqlite3 *db;\n  sqlite3_stmt *pInsert;\n  sqlite3_stmt *pDelete;\n  sqlite3_stmt *pDeleteRange;\n  sqlite3_stmt *pFetch;\n  sqlite3_stmt *apScan[8];\n\n  int nOpenTrans;\n\n  /* Used by sql_fetch() to allocate space for results */\n  int nAlloc;\n  u8 *aAlloc;\n};\n\nstatic int sql_close(TestDb *pTestDb){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  sqlite3_finalize(pDb->pInsert);\n  sqlite3_finalize(pDb->pDelete);\n  sqlite3_finalize(pDb->pDeleteRange);\n  sqlite3_finalize(pDb->pFetch);\n  sqlite3_finalize(pDb->apScan[0]);\n  sqlite3_finalize(pDb->apScan[1]);\n  sqlite3_finalize(pDb->apScan[2]);\n  sqlite3_finalize(pDb->apScan[3]);\n  sqlite3_finalize(pDb->apScan[4]);\n  sqlite3_finalize(pDb->apScan[5]);\n  sqlite3_finalize(pDb->apScan[6]);\n  sqlite3_finalize(pDb->apScan[7]);\n  sqlite3_close(pDb->db);\n  free((char *)pDb->aAlloc);\n  free((char *)pDb);\n  return SQLITE_OK;\n}\n\nstatic int sql_write(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void *pVal, \n  int nVal\n){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  sqlite3_bind_blob(pDb->pInsert, 1, pKey, nKey, SQLITE_STATIC);\n  sqlite3_bind_blob(pDb->pInsert, 2, pVal, nVal, SQLITE_STATIC);\n  sqlite3_step(pDb->pInsert);\n  return sqlite3_reset(pDb->pInsert);\n}\n\nstatic int sql_delete(TestDb *pTestDb, void *pKey, int nKey){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  sqlite3_bind_blob(pDb->pDelete, 1, pKey, nKey, SQLITE_STATIC);\n  sqlite3_step(pDb->pDelete);\n  return sqlite3_reset(pDb->pDelete);\n}\n\nstatic int sql_delete_range(\n  TestDb *pTestDb, \n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2\n){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  sqlite3_bind_blob(pDb->pDeleteRange, 1, pKey1, nKey1, SQLITE_STATIC);\n  sqlite3_bind_blob(pDb->pDeleteRange, 2, pKey2, nKey2, SQLITE_STATIC);\n  sqlite3_step(pDb->pDeleteRange);\n  return sqlite3_reset(pDb->pDeleteRange);\n}\n\nstatic int sql_fetch(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void **ppVal, \n  int *pnVal\n){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  int rc;\n\n  sqlite3_reset(pDb->pFetch);\n  if( pKey==0 ){\n    assert( ppVal==0 );\n    assert( pnVal==0 );\n    return LSM_OK;\n  }\n\n  sqlite3_bind_blob(pDb->pFetch, 1, pKey, nKey, SQLITE_STATIC);\n  rc = sqlite3_step(pDb->pFetch);\n  if( rc==SQLITE_ROW ){\n    int nVal = sqlite3_column_bytes(pDb->pFetch, 0);\n    u8 *aVal = (void *)sqlite3_column_blob(pDb->pFetch, 0);\n\n    if( nVal>pDb->nAlloc ){\n      free(pDb->aAlloc);\n      pDb->aAlloc = (u8 *)malloc(nVal*2);\n      pDb->nAlloc = nVal*2;\n    }\n    memcpy(pDb->aAlloc, aVal, nVal);\n    *pnVal = nVal;\n    *ppVal = (void *)pDb->aAlloc;\n  }else{\n    *pnVal = -1;\n    *ppVal = 0;\n  }\n\n  rc = sqlite3_reset(pDb->pFetch);\n  return rc;\n}\n\nstatic int sql_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pFirst, int nFirst,\n  void *pLast, int nLast,\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  sqlite3_stmt *pScan;\n\n  assert( bReverse==1 || bReverse==0 );\n  pScan = pDb->apScan[(pFirst==0) + (pLast==0)*2 + bReverse*4];\n\n  if( pFirst ) sqlite3_bind_blob(pScan, 1, pFirst, nFirst, SQLITE_STATIC);\n  if( pLast ) sqlite3_bind_blob(pScan, 2, pLast, nLast, SQLITE_STATIC);\n\n  while( SQLITE_ROW==sqlite3_step(pScan) ){\n    void *pKey; int nKey;\n    void *pVal; int nVal;\n\n    nKey = sqlite3_column_bytes(pScan, 0);\n    pKey = (void *)sqlite3_column_blob(pScan, 0);\n    nVal = sqlite3_column_bytes(pScan, 1);\n    pVal = (void *)sqlite3_column_blob(pScan, 1);\n\n    xCallback(pCtx, pKey, nKey, pVal, nVal);\n  }\n  return sqlite3_reset(pScan);\n}\n\nstatic int sql_begin(TestDb *pTestDb, int iLevel){\n  int i;\n  SqlDb *pDb = (SqlDb *)pTestDb;\n\n  /* iLevel==0 is a no-op */\n  if( iLevel==0 ) return 0;\n\n  /* If there are no transactions at all open, open a read transaction. */\n  if( pDb->nOpenTrans==0 ){\n    int rc = sqlite3_exec(pDb->db, \n        \"BEGIN; SELECT * FROM sqlite_master LIMIT 1;\" , 0, 0, 0\n    );\n    if( rc!=0 ) return rc;\n    pDb->nOpenTrans = 1;\n  }\n\n  /* Open any required write transactions */\n  for(i=pDb->nOpenTrans; i<iLevel; i++){\n    char *zSql = sqlite3_mprintf(\"SAVEPOINT x%d\", i);\n    int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  pDb->nOpenTrans = iLevel;\n  return 0;\n}\n\nstatic int sql_commit(TestDb *pTestDb, int iLevel){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  assert( iLevel>=0 );\n\n  /* Close the read transaction if requested. */\n  if( pDb->nOpenTrans>=1 && iLevel==0 ){\n    int rc = sqlite3_exec(pDb->db, \"COMMIT\", 0, 0, 0);\n    if( rc!=0 ) return rc;\n    pDb->nOpenTrans = 0;\n  }\n\n  /* Close write transactions as required */\n  if( pDb->nOpenTrans>iLevel ){\n    char *zSql = sqlite3_mprintf(\"RELEASE x%d\", iLevel);\n    int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    if( rc!=0 ) return rc;\n  }\n\n  pDb->nOpenTrans = iLevel;\n  return 0;\n}\n\nstatic int sql_rollback(TestDb *pTestDb, int iLevel){\n  SqlDb *pDb = (SqlDb *)pTestDb;\n  assert( iLevel>=0 );\n\n  if( pDb->nOpenTrans>=1 && iLevel==0 ){\n    /* Close the read transaction if requested. */\n    int rc = sqlite3_exec(pDb->db, \"ROLLBACK\", 0, 0, 0);\n    if( rc!=0 ) return rc;\n  }else if( pDb->nOpenTrans>1 && iLevel==1 ){\n    /* Or, rollback and close the top-level write transaction */\n    int rc = sqlite3_exec(pDb->db, \"ROLLBACK TO x1; RELEASE x1;\", 0, 0, 0);\n    if( rc!=0 ) return rc;\n  }else{\n    /* Or, just roll back some nested transactions */\n    char *zSql = sqlite3_mprintf(\"ROLLBACK TO x%d\", iLevel-1);\n    int rc = sqlite3_exec(pDb->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    if( rc!=0 ) return rc;\n  }\n\n  pDb->nOpenTrans = iLevel;\n  return 0;\n}\n\nstatic int sql_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  static const DatabaseMethods SqlMethods = {\n    sql_close,\n    sql_write,\n    sql_delete,\n    sql_delete_range,\n    sql_fetch,\n    sql_scan,\n    sql_begin,\n    sql_commit,\n    sql_rollback\n  };\n  const char *zCreate = \"CREATE TABLE IF NOT EXISTS t1(k PRIMARY KEY, v)\";\n  const char *zInsert = \"REPLACE INTO t1 VALUES(?, ?)\";\n  const char *zDelete = \"DELETE FROM t1 WHERE k = ?\";\n  const char *zRange = \"DELETE FROM t1 WHERE k>? AND k<?\";\n  const char *zFetch  = \"SELECT v FROM t1 WHERE k = ?\";\n\n  const char *zScan0  = \"SELECT * FROM t1 WHERE k BETWEEN ?1 AND ?2 ORDER BY k\";\n  const char *zScan1  = \"SELECT * FROM t1 WHERE k <= ?2 ORDER BY k\";\n  const char *zScan2  = \"SELECT * FROM t1 WHERE k >= ?1 ORDER BY k\";\n  const char *zScan3  = \"SELECT * FROM t1 ORDER BY k\";\n\n  const char *zScan4  = \n    \"SELECT * FROM t1 WHERE k BETWEEN ?1 AND ?2 ORDER BY k DESC\";\n  const char *zScan5  = \"SELECT * FROM t1 WHERE k <= ?2 ORDER BY k DESC\";\n  const char *zScan6  = \"SELECT * FROM t1 WHERE k >= ?1 ORDER BY k DESC\";\n  const char *zScan7  = \"SELECT * FROM t1 ORDER BY k DESC\";\n\n  int rc;\n  SqlDb *pDb;\n  char *zPragma;\n\n  if( bClear && zFilename && zFilename[0] ){\n    unlink(zFilename);\n  }\n\n  pDb = (SqlDb *)malloc(sizeof(SqlDb));\n  memset(pDb, 0, sizeof(SqlDb));\n  pDb->base.pMethods = &SqlMethods;\n\n  if( 0!=(rc = sqlite3_open(zFilename, &pDb->db))\n   || 0!=(rc = sqlite3_exec(pDb->db, zCreate, 0, 0, 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zInsert, -1, &pDb->pInsert, 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zDelete, -1, &pDb->pDelete, 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zRange, -1, &pDb->pDeleteRange, 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zFetch, -1, &pDb->pFetch, 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan0, -1, &pDb->apScan[0], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan1, -1, &pDb->apScan[1], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan2, -1, &pDb->apScan[2], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan3, -1, &pDb->apScan[3], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan4, -1, &pDb->apScan[4], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan5, -1, &pDb->apScan[5], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan6, -1, &pDb->apScan[6], 0))\n   || 0!=(rc = sqlite3_prepare_v2(pDb->db, zScan7, -1, &pDb->apScan[7], 0))\n  ){\n    *ppDb = 0;\n    sql_close((TestDb *)pDb);\n    return rc;\n  }\n\n  zPragma = sqlite3_mprintf(\"PRAGMA page_size=%d\", TESTDB_DEFAULT_PAGE_SIZE);\n  sqlite3_exec(pDb->db, zPragma, 0, 0, 0);\n  sqlite3_free(zPragma);\n  zPragma = sqlite3_mprintf(\"PRAGMA cache_size=%d\", TESTDB_DEFAULT_CACHE_SIZE);\n  sqlite3_exec(pDb->db, zPragma, 0, 0, 0);\n  sqlite3_free(zPragma);\n\n  /* sqlite3_exec(pDb->db, \"PRAGMA locking_mode=EXCLUSIVE\", 0, 0, 0); */\n  sqlite3_exec(pDb->db, \"PRAGMA synchronous=OFF\", 0, 0, 0);\n  sqlite3_exec(pDb->db, \"PRAGMA journal_mode=WAL\", 0, 0, 0);\n  sqlite3_exec(pDb->db, \"PRAGMA wal_autocheckpoint=4096\", 0, 0, 0);\n  if( zSpec ){\n    rc = sqlite3_exec(pDb->db, zSpec, 0, 0, 0);\n    if( rc!=SQLITE_OK ){\n      sql_close((TestDb *)pDb);\n      return rc;\n    }\n  }\n\n  *ppDb = (TestDb *)pDb;\n  return 0;\n}\n/* \n** End wrapper for SQLite.\n*************************************************************************/\n\n/*************************************************************************\n** Begin exported functions.\n*/\nstatic struct Lib {\n  const char *zName;\n  const char *zDefaultDb;\n  int (*xOpen)(const char *, const char *zFilename, int bClear, TestDb **ppDb);\n} aLib[] = {\n  { \"sqlite3\",      \"testdb.sqlite\",    sql_open },\n  { \"lsm_small\",    \"testdb.lsm_small\", test_lsm_small_open },\n  { \"lsm_lomem\",    \"testdb.lsm_lomem\", test_lsm_lomem_open },\n#ifdef HAVE_ZLIB\n  { \"lsm_zip\",      \"testdb.lsm_zip\",   test_lsm_zip_open },\n#endif\n  { \"lsm\",          \"testdb.lsm\",       test_lsm_open },\n#ifdef LSM_MUTEX_PTHREADS\n  { \"lsm_mt2\",      \"testdb.lsm_mt2\",   test_lsm_mt2 },\n  { \"lsm_mt3\",      \"testdb.lsm_mt3\",   test_lsm_mt3 },\n#endif\n#ifdef HAVE_LEVELDB\n  { \"leveldb\",      \"testdb.leveldb\",   test_leveldb_open },\n#endif\n#ifdef HAVE_KYOTOCABINET\n  { \"kyotocabinet\", \"testdb.kc\",        kc_open },\n#endif\n#ifdef HAVE_MDB\n  { \"mdb\", \"./testdb.mdb\",        mdb_open }\n#endif\n};\n\nconst char *tdb_system_name(int i){\n  if( i<0 || i>=ArraySize(aLib) ) return 0;\n  return aLib[i].zName;\n}\n\nconst char *tdb_default_db(const char *zSys){\n  int i;\n  for(i=0; i<ArraySize(aLib); i++){\n    if( strcmp(aLib[i].zName, zSys)==0 ) return aLib[i].zDefaultDb;\n  }\n  return 0;\n}\n\nint tdb_open(const char *zLib, const char *zDb, int bClear, TestDb **ppDb){\n  int i;\n  int rc = 1;\n  const char *zSpec = 0;\n\n  int nLib = 0;\n  while( zLib[nLib] && zLib[nLib]!=' ' ){\n    nLib++;\n  }\n  zSpec = &zLib[nLib];\n  while( *zSpec==' ' ) zSpec++;\n  if( *zSpec=='\\0' ) zSpec = 0;\n\n  for(i=0; i<ArraySize(aLib); i++){\n    if( (int)strlen(aLib[i].zName)==nLib\n        && 0==memcmp(zLib, aLib[i].zName, nLib) ){\n      rc = aLib[i].xOpen(zSpec, (zDb ? zDb : aLib[i].zDefaultDb), bClear, ppDb);\n      if( rc==0 ){\n        (*ppDb)->zLibrary = aLib[i].zName;\n      }\n      break;\n    }\n  }\n\n  if( rc ){\n    /* Failed to find the requested database library. Return an error. */\n    *ppDb = 0;\n  }\n  return rc;\n}\n\nint tdb_close(TestDb *pDb){\n  if( pDb ){\n    return pDb->pMethods->xClose(pDb);\n  }\n  return 0;\n}\n\nint tdb_write(TestDb *pDb, void *pKey, int nKey, void *pVal, int nVal){\n  return pDb->pMethods->xWrite(pDb, pKey, nKey, pVal, nVal);\n}\n\nint tdb_delete(TestDb *pDb, void *pKey, int nKey){\n  return pDb->pMethods->xDelete(pDb, pKey, nKey);\n}\n\nint tdb_delete_range(\n    TestDb *pDb, void *pKey1, int nKey1, void *pKey2, int nKey2\n){\n  return pDb->pMethods->xDeleteRange(pDb, pKey1, nKey1, pKey2, nKey2);\n}\n\nint tdb_fetch(TestDb *pDb, void *pKey, int nKey, void **ppVal, int *pnVal){\n  return pDb->pMethods->xFetch(pDb, pKey, nKey, ppVal, pnVal);\n}\n\nint tdb_scan(\n  TestDb *pDb,                    /* Database handle */\n  void *pCtx,                     /* Context pointer to pass to xCallback */\n  int bReverse,                   /* True to scan in reverse order */\n  void *pKey1, int nKey1,         /* Start of search */\n  void *pKey2, int nKey2,         /* End of search */\n  void (*xCallback)(void *pCtx, void *pKey, int nKey, void *pVal, int nVal)\n){\n  return pDb->pMethods->xScan(\n      pDb, pCtx, bReverse, pKey1, nKey1, pKey2, nKey2, xCallback\n  );\n}\n\nint tdb_begin(TestDb *pDb, int iLevel){\n  return pDb->pMethods->xBegin(pDb, iLevel);\n}\nint tdb_commit(TestDb *pDb, int iLevel){\n  return pDb->pMethods->xCommit(pDb, iLevel);\n}\nint tdb_rollback(TestDb *pDb, int iLevel){\n  return pDb->pMethods->xRollback(pDb, iLevel);\n}\n\nint tdb_transaction_support(TestDb *pDb){\n  return (pDb->pMethods->xBegin != error_transaction_function);\n}\n\nconst char *tdb_library_name(TestDb *pDb){\n  return pDb->zLibrary;\n}\n\n/* \n** End exported functions.\n*************************************************************************/\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_tdb.h",
    "content": "\n/*\n** This file is the interface to a very simple database library used for\n** testing. The interface is similar to that of the LSM. The main virtue \n** of this library is that the same API may be used to access a key-value\n** store implemented by LSM, SQLite or another database system. Which \n** makes it easy to use for correctness and performance tests.\n*/\n\n#ifndef __WRAPPER_H_\n#define __WRAPPER_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"lsm.h\"\n\ntypedef struct TestDb TestDb;\n\n/*\n** Open a new database connection. The first argument is the name of the\n** database library to use. e.g. something like:\n**\n**     \"sqlite3\"\n**     \"lsm\"\n**\n** See function tdb_system_name() for a list of available database systems.\n**\n** The second argument is the name of the database to open (e.g. a filename).\n**\n** If the third parameter is non-zero, then any existing database by the\n** name of zDb is removed before opening a new one. If it is zero, then an\n** existing database may be opened.\n*/\nint tdb_open(const char *zLibrary, const char *zDb, int bClear, TestDb **ppDb);\n\n/*\n** Close a database handle.\n*/\nint tdb_close(TestDb *pDb);\n\n/*\n** Write a new key/value into the database.\n*/\nint tdb_write(TestDb *pDb, void *pKey, int nKey, void *pVal, int nVal);\n\n/*\n** Delete a key from the database.\n*/\nint tdb_delete(TestDb *pDb, void *pKey, int nKey);\n\n/*\n** Delete a range of keys from the database.\n*/\nint tdb_delete_range(TestDb *, void *pKey1, int nKey1, void *pKey2, int nKey2);\n\n/*\n** Query the database for key (pKey/nKey). If no entry is found, set *ppVal\n** to 0 and *pnVal to -1 before returning. Otherwise, set *ppVal and *pnVal\n** to a pointer to and size of the value associated with (pKey/nKey).\n*/\nint tdb_fetch(TestDb *pDb, void *pKey, int nKey, void **ppVal, int *pnVal);\n\n/*\n** Open and close nested transactions. Currently, these functions only \n** work for SQLite3 and LSM systems. Use the tdb_transaction_support() \n** function to determine if a given TestDb handle supports these methods.\n**\n** These functions and the iLevel parameter follow the same conventions as\n** the SQLite 4 transaction interface. Note that this is slightly different\n** from the way LSM does things. As follows:\n**\n** tdb_begin():\n**   A successful call to tdb_begin() with (iLevel>1) guarantees that \n**   there are at least (iLevel-1) write transactions open. If iLevel==1,\n**   then it guarantees that at least a read-transaction is open. Calling\n**   tdb_begin() with iLevel==0 is a no-op.\n**\n** tdb_commit():\n**   A successful call to tdb_commit() with (iLevel>1) guarantees that \n**   there are at most (iLevel-1) write transactions open. If iLevel==1,\n**   then it guarantees that there are no write transactions open (although\n**   a read-transaction may remain open).  Calling tdb_commit() with \n**   iLevel==0 ensures that all transactions, read or write, have been \n**   closed and committed.\n**\n** tdb_rollback():\n**   This call is similar to tdb_commit(), except that instead of committing\n**   transactions, it reverts them. For example, calling tdb_rollback() with\n**   iLevel==2 ensures that there is at most one write transaction open, and\n**   restores the database to the state that it was in when that transaction\n**   was opened.\n**\n**   In other words, tdb_commit() just closes transactions - tdb_rollback()\n**   closes transactions and then restores the database to the state it\n**   was in before those transactions were even opened.\n*/\nint tdb_begin(TestDb *pDb, int iLevel);\nint tdb_commit(TestDb *pDb, int iLevel);\nint tdb_rollback(TestDb *pDb, int iLevel);\n\n/*\n** Return true if transactions are supported, or false otherwise.\n*/\nint tdb_transaction_support(TestDb *pDb);\n\n/*\n** Return the name of the database library (as passed to tdb_open()) used\n** by the handled passed as the first argument.\n*/\nconst char *tdb_library_name(TestDb *pDb);\n\n/*\n** Scan a range of database keys. Invoke the callback function for each\n** key visited.\n*/\nint tdb_scan(\n  TestDb *pDb,                    /* Database handle */\n  void *pCtx,                     /* Context pointer to pass to xCallback */\n  int bReverse,                   /* True to scan in reverse order */\n  void *pKey1, int nKey1,         /* Start of search */\n  void *pKey2, int nKey2,         /* End of search */\n  void (*xCallback)(void *pCtx, void *pKey, int nKey, void *pVal, int nVal)\n);\n\nconst char *tdb_system_name(int i);\nconst char *tdb_default_db(const char *zSys);\n\nint tdb_lsm_open(const char *zCfg, const char *zDb, int bClear, TestDb **ppDb);\n\n/*\n** If the TestDb handle passed as an argument is a wrapper around an LSM\n** database, return the LSM handle. Otherwise, if the argument is some other\n** database system, return NULL.\n*/\nlsm_db *tdb_lsm(TestDb *pDb);\n\n/*\n** Return true if the db passed as an argument is a multi-threaded LSM\n** connection.\n*/\nint tdb_lsm_multithread(TestDb *pDb);\n\n/*\n** Return a pointer to the lsm_env object used by all lsm database\n** connections initialized as a copy of the object returned by \n** lsm_default_env(). It may be modified (e.g. to override functions)\n** if the caller can guarantee that it is not already in use.\n*/\nlsm_env *tdb_lsm_env(void);\n\n/*\n** The following functions only work with LSM database handles. It is\n** illegal to call them with any other type of database handle specified\n** as an argument.\n*/\nvoid tdb_lsm_enable_log(TestDb *pDb, int bEnable);\nvoid tdb_lsm_application_crash(TestDb *pDb);\nvoid tdb_lsm_prepare_system_crash(TestDb *pDb);\nvoid tdb_lsm_system_crash(TestDb *pDb);\nvoid tdb_lsm_prepare_sync_crash(TestDb *pDb, int iSync);\n\n\nvoid tdb_lsm_safety(TestDb *pDb, int eMode);\nvoid tdb_lsm_config_work_hook(TestDb *pDb, void (*)(lsm_db *, void *), void *);\nvoid tdb_lsm_write_hook(TestDb *, void(*)(void*,int,lsm_i64,int,int), void*);\nint tdb_lsm_config_str(TestDb *pDb, const char *zStr);\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_tdb2.cc",
    "content": "\n\n#include \"lsmtest.h\"\n#include <stdlib.h>\n\n#ifdef HAVE_KYOTOCABINET\n#include \"kcpolydb.h\"\nextern \"C\" {\n  struct KcDb {\n    TestDb base;\n    kyotocabinet::TreeDB* db;\n    char *pVal;\n  };\n}\n\nint test_kc_open(const char *zFilename, int bClear, TestDb **ppDb){\n  KcDb *pKcDb;\n  int ok;\n  int rc = 0;\n\n  if( bClear ){\n    char *zCmd = sqlite3_mprintf(\"rm -rf %s\\n\", zFilename);\n    system(zCmd);\n    sqlite3_free(zCmd);\n  }\n\n  pKcDb = (KcDb *)malloc(sizeof(KcDb));\n  memset(pKcDb, 0, sizeof(KcDb));\n\n\n  pKcDb->db = new kyotocabinet::TreeDB();\n  pKcDb->db->tune_page(TESTDB_DEFAULT_PAGE_SIZE);\n  pKcDb->db->tune_page_cache(\n      TESTDB_DEFAULT_PAGE_SIZE * TESTDB_DEFAULT_CACHE_SIZE\n  );\n  ok = pKcDb->db->open(zFilename,\n      kyotocabinet::PolyDB::OWRITER | kyotocabinet::PolyDB::OCREATE\n  );\n  if( ok==0 ){\n    free(pKcDb);\n    pKcDb = 0;\n    rc = 1;\n  }\n\n  *ppDb = (TestDb *)pKcDb;\n  return rc;\n}\n\nint test_kc_close(TestDb *pDb){\n  KcDb *pKcDb = (KcDb *)pDb;\n  if( pKcDb->pVal ){\n    delete [] pKcDb->pVal;\n  }\n  pKcDb->db->close();\n  delete pKcDb->db;\n  free(pKcDb);\n  return 0;\n}\n\nint test_kc_write(TestDb *pDb, void *pKey, int nKey, void *pVal, int nVal){\n  KcDb *pKcDb = (KcDb *)pDb;\n  int ok;\n\n  ok = pKcDb->db->set((const char *)pKey, nKey, (const char *)pVal, nVal);\n  return (ok ? 0 : 1);\n}\n\nint test_kc_delete(TestDb *pDb, void *pKey, int nKey){\n  KcDb *pKcDb = (KcDb *)pDb;\n  int ok;\n\n  ok = pKcDb->db->remove((const char *)pKey, nKey);\n  return (ok ? 0 : 1);\n}\n\nint test_kc_delete_range(\n  TestDb *pDb, \n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2\n){\n  int res;\n  KcDb *pKcDb = (KcDb *)pDb;\n  kyotocabinet::DB::Cursor* pCur = pKcDb->db->cursor();\n\n  if( pKey1 ){\n    res = pCur->jump((const char *)pKey1, nKey1);\n  }else{\n    res = pCur->jump();\n  }\n\n  while( 1 ){\n    const char *pKey; size_t nKey;\n    const char *pVal; size_t nVal;\n\n    pKey = pCur->get(&nKey, &pVal, &nVal);\n    if( pKey==0 ) break;\n\n#ifndef NDEBUG\n    if( pKey1 ){\n      res = memcmp(pKey, pKey1, MIN((size_t)nKey1, nKey));\n      assert( res>0 || (res==0 && nKey>nKey1) );\n    }\n#endif\n\n    if( pKey2 ){\n      res = memcmp(pKey, pKey2, MIN((size_t)nKey2, nKey));\n      if( res>0 || (res==0 && (size_t)nKey2<nKey) ){\n        delete [] pKey;\n        break;\n      }\n    }\n    pCur->remove();\n    delete [] pKey;\n  }\n\n  delete pCur;\n  return 0;\n}\n\nint test_kc_fetch(\n  TestDb *pDb, \n  void *pKey, \n  int nKey, \n  void **ppVal,\n  int *pnVal\n){\n  KcDb *pKcDb = (KcDb *)pDb;\n  size_t nVal;\n\n  if( pKcDb->pVal ){\n    delete [] pKcDb->pVal;\n    pKcDb->pVal = 0;\n  }\n\n  pKcDb->pVal = pKcDb->db->get((const char *)pKey, nKey, &nVal);\n  if( pKcDb->pVal ){\n    *ppVal = pKcDb->pVal;\n    *pnVal = nVal;\n  }else{\n    *ppVal = 0;\n    *pnVal = -1;\n  }\n\n  return 0;\n}\n\nint test_kc_scan(\n  TestDb *pDb,                    /* Database handle */\n  void *pCtx,                     /* Context pointer to pass to xCallback */\n  int bReverse,                   /* True for a reverse order scan */\n  void *pKey1, int nKey1,         /* Start of search */\n  void *pKey2, int nKey2,         /* End of search */\n  void (*xCallback)(void *pCtx, void *pKey, int nKey, void *pVal, int nVal)\n){\n  KcDb *pKcDb = (KcDb *)pDb;\n  kyotocabinet::DB::Cursor* pCur = pKcDb->db->cursor();\n  int res;\n\n  if( bReverse==0 ){\n    if( pKey1 ){\n      res = pCur->jump((const char *)pKey1, nKey1);\n    }else{\n      res = pCur->jump();\n    }\n  }else{\n    if( pKey2 ){\n      res = pCur->jump_back((const char *)pKey2, nKey2);\n    }else{\n      res = pCur->jump_back();\n    }\n  }\n\n  while( res ){\n    const char *pKey; size_t nKey;\n    const char *pVal; size_t nVal;\n    pKey = pCur->get(&nKey, &pVal, &nVal);\n\n    if( bReverse==0 && pKey2 ){\n      res = memcmp(pKey, pKey2, MIN((size_t)nKey2, nKey));\n      if( res>0 || (res==0 && (size_t)nKey2<nKey) ){\n        delete [] pKey;\n        break;\n      }\n    }else if( bReverse!=0 && pKey1 ){\n      res = memcmp(pKey, pKey1, MIN((size_t)nKey1, nKey));\n      if( res<0 || (res==0 && (size_t)nKey1>nKey) ){\n        delete [] pKey;\n        break;\n      }\n    }\n\n    xCallback(pCtx, (void *)pKey, (int)nKey, (void *)pVal, (int)nVal);\n    delete [] pKey;\n\n    if( bReverse ){\n      res = pCur->step_back();\n    }else{\n      res = pCur->step();\n    }\n  }\n\n  delete pCur;\n  return 0;\n}\n#endif /* HAVE_KYOTOCABINET */\n\n#ifdef HAVE_MDB \n#include \"lmdb.h\"\n\nextern \"C\" {\n  struct MdbDb {\n    TestDb base;\n    MDB_env *env;\n    MDB_dbi dbi;\n  };\n}\n\nint test_mdb_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  MDB_txn *txn;\n  MdbDb *pMdb;\n  int rc;\n\n  if( bClear ){\n    char *zCmd = sqlite3_mprintf(\"rm -rf %s\\n\", zFilename);\n    system(zCmd);\n    sqlite3_free(zCmd);\n  }\n\n  pMdb = (MdbDb *)malloc(sizeof(MdbDb));\n  memset(pMdb, 0, sizeof(MdbDb));\n\n  rc = mdb_env_create(&pMdb->env);\n  if( rc==0 ) rc = mdb_env_set_mapsize(pMdb->env, 1*1024*1024*1024);\n  if( rc==0 ) rc = mdb_env_open(pMdb->env, zFilename, MDB_NOSYNC|MDB_NOSUBDIR, 0600);\n  if( rc==0 ) rc = mdb_txn_begin(pMdb->env, NULL, 0, &txn);\n  if( rc==0 ){\n    rc = mdb_open(txn, NULL, 0, &pMdb->dbi);\n    mdb_txn_commit(txn);\n  }\n\n  *ppDb = (TestDb *)pMdb;\n  return rc;\n}\n\nint test_mdb_close(TestDb *pDb){\n  MdbDb *pMdb = (MdbDb *)pDb;\n\n  mdb_close(pMdb->env, pMdb->dbi);\n  mdb_env_close(pMdb->env);\n  free(pMdb);\n  return 0;\n}\n\nint test_mdb_write(TestDb *pDb, void *pKey, int nKey, void *pVal, int nVal){\n  int rc;\n  MdbDb *pMdb = (MdbDb *)pDb;\n  MDB_val val;\n  MDB_val key;\n  MDB_txn *txn;\n\n  val.mv_size = nVal; \n  val.mv_data = pVal;\n  key.mv_size = nKey; \n  key.mv_data = pKey;\n\n  rc = mdb_txn_begin(pMdb->env, NULL, 0, &txn);\n  if( rc==0 ){\n    rc = mdb_put(txn, pMdb->dbi, &key, &val, 0);\n    if( rc==0 ){\n      rc = mdb_txn_commit(txn);\n    }else{\n      mdb_txn_abort(txn);\n    }\n  }\n  \n  return rc;\n}\n\nint test_mdb_delete(TestDb *pDb, void *pKey, int nKey){\n  int rc;\n  MdbDb *pMdb = (MdbDb *)pDb;\n  MDB_val key;\n  MDB_txn *txn;\n\n  key.mv_size = nKey; \n  key.mv_data = pKey;\n  rc = mdb_txn_begin(pMdb->env, NULL, 0, &txn);\n  if( rc==0 ){\n    rc = mdb_del(txn, pMdb->dbi, &key, 0);\n    if( rc==0 ){\n      rc = mdb_txn_commit(txn);\n    }else{\n      mdb_txn_abort(txn);\n    }\n  }\n  \n  return rc;\n}\n\nint test_mdb_fetch(\n  TestDb *pDb, \n  void *pKey, \n  int nKey, \n  void **ppVal,\n  int *pnVal\n){\n  int rc;\n  MdbDb *pMdb = (MdbDb *)pDb;\n  MDB_val key;\n  MDB_txn *txn;\n\n  key.mv_size = nKey;\n  key.mv_data = pKey;\n\n  rc = mdb_txn_begin(pMdb->env, NULL, MDB_RDONLY, &txn);\n  if( rc==0 ){\n    MDB_val val = {0, 0};\n    rc = mdb_get(txn, pMdb->dbi, &key, &val);\n    if( rc==MDB_NOTFOUND ){\n      rc = 0;\n      *ppVal = 0;\n      *pnVal = -1;\n    }else{\n      *ppVal = val.mv_data;\n      *pnVal = val.mv_size;\n    }\n    mdb_txn_commit(txn);\n  }\n\n  return rc;\n}\n\nint test_mdb_scan(\n  TestDb *pDb,                    /* Database handle */\n  void *pCtx,                     /* Context pointer to pass to xCallback */\n  int bReverse,                   /* True for a reverse order scan */\n  void *pKey1, int nKey1,         /* Start of search */\n  void *pKey2, int nKey2,         /* End of search */\n  void (*xCallback)(void *pCtx, void *pKey, int nKey, void *pVal, int nVal)\n){\n  MdbDb *pMdb = (MdbDb *)pDb;\n  int rc;\n  MDB_cursor_op op = bReverse ? MDB_PREV : MDB_NEXT;\n  MDB_txn *txn;\n\n  rc = mdb_txn_begin(pMdb->env, NULL, MDB_RDONLY, &txn);\n  if( rc==0 ){\n    MDB_cursor *csr;\n    MDB_val key = {0, 0};\n    MDB_val val = {0, 0};\n\n    rc = mdb_cursor_open(txn, pMdb->dbi, &csr);\n    if( rc==0 ){\n      while( mdb_cursor_get(csr, &key, &val, op)==0 ){\n        xCallback(pCtx, key.mv_data, key.mv_size, val.mv_data, val.mv_size);\n      }\n      mdb_cursor_close(csr);\n    }\n  }\n\n  return rc;\n}\n\n#endif /* HAVE_MDB */\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_tdb3.c",
    "content": "\n#include \"lsmtest_tdb.h\"\n#include \"lsm.h\"\n#include \"lsmtest.h\"\n\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#ifndef _WIN32\n# include <unistd.h>\n#endif\n#include <stdio.h>\n\n#ifndef _WIN32\n# include <sys/time.h>\n#endif\n\ntypedef struct LsmDb LsmDb;\ntypedef struct LsmWorker LsmWorker;\ntypedef struct LsmFile LsmFile;\n\n#define LSMTEST_DFLT_MT_MAX_CKPT (8*1024)\n#define LSMTEST_DFLT_MT_MIN_CKPT (2*1024)\n\n#ifdef LSM_MUTEX_PTHREADS\n#include <pthread.h>\n\n#define LSMTEST_THREAD_CKPT      1\n#define LSMTEST_THREAD_WORKER    2\n#define LSMTEST_THREAD_WORKER_AC 3\n\n/*\n** There are several different types of worker threads that run in different\n** test configurations, depending on the value of LsmWorker.eType.\n**\n**   1. Checkpointer.\n**   2. Worker with auto-checkpoint.\n**   3. Worker without auto-checkpoint.\n*/\nstruct LsmWorker {\n  LsmDb *pDb;                     /* Main database structure */\n  lsm_db *pWorker;                /* Worker database handle */\n  pthread_t worker_thread;        /* Worker thread */\n  pthread_cond_t worker_cond;     /* Condition var the worker waits on */\n  pthread_mutex_t worker_mutex;   /* Mutex used with worker_cond */\n  int bDoWork;                    /* Set to true by client when there is work */\n  int worker_rc;                  /* Store error code here */\n  int eType;                      /* LSMTEST_THREAD_XXX constant */\n  int bBlock;\n};\n#else\nstruct LsmWorker { int worker_rc; int bBlock; };\n#endif\n\nstatic void mt_shutdown(LsmDb *);\n\nlsm_env *tdb_lsm_env(void){\n  static int bInit = 0;\n  static lsm_env env;\n  if( bInit==0 ){\n    memcpy(&env, lsm_default_env(), sizeof(env));\n    bInit = 1;\n  }\n  return &env;\n}\n\ntypedef struct FileSector FileSector;\ntypedef struct FileData FileData;\n\nstruct FileSector {\n  u8 *aOld;                       /* Old data for this sector */\n};\n\nstruct FileData {\n  int nSector;                    /* Allocated size of apSector[] array */\n  FileSector *aSector;            /* Array of file sectors */\n};\n\n/*\n** bPrepareCrash:\n**   If non-zero, the file wrappers maintain enough in-memory data to\n**   simulate the effect of a power-failure on the file-system (i.e. that\n**   unsynced sectors may be written, not written, or overwritten with\n**   arbitrary data when the crash occurs).\n**\n** bCrashed:\n**   Set to true after a crash is simulated. Once this variable is true, all\n**   VFS methods other than xClose() return LSM_IOERR as soon as they are\n**   called (without affecting the contents of the file-system).\n**\n** env:\n**   The environment object used by all lsm_db* handles opened by this\n**   object (i.e. LsmDb.db plus any worker connections). Variable env.pVfsCtx\n**   always points to the containing LsmDb structure.\n*/\nstruct LsmDb {\n  TestDb base;                    /* Base class - methods table */\n  lsm_env env;                    /* Environment used by connection db */\n  char *zName;                    /* Database file name */\n  lsm_db *db;                     /* LSM database handle */\n\n  lsm_cursor *pCsr;               /* Cursor held open during read transaction */\n  void *pBuf;                     /* Buffer for tdb_fetch() output */\n  int nBuf;                       /* Allocated (not used) size of pBuf */\n\n  /* Crash testing related state */\n  int bCrashed;                   /* True once a crash has occurred */\n  int nAutoCrash;                 /* Number of syncs until a crash */\n  int bPrepareCrash;              /* True to store writes in memory */\n\n  /* Unsynced data (while crash testing) */\n  int szSector;                   /* Assumed size of disk sectors (512B) */\n  FileData aFile[2];              /* Database and log file data */\n\n  /* Other test instrumentation */\n  int bNoRecovery;                /* If true, assume DMS2 is locked */\n\n  /* Work hook redirection */\n  void (*xWork)(lsm_db *, void *);\n  void *pWorkCtx;\n\n  /* IO logging hook */\n  void (*xWriteHook)(void *, int, lsm_i64, int, int);\n  void *pWriteCtx;\n  \n  /* Worker threads (for lsm_mt) */\n  int nMtMinCkpt;\n  int nMtMaxCkpt;\n  int eMode;\n  int nWorker;\n  LsmWorker *aWorker;\n};\n\n#define LSMTEST_MODE_SINGLETHREAD    1\n#define LSMTEST_MODE_BACKGROUND_CKPT 2\n#define LSMTEST_MODE_BACKGROUND_WORK 3\n#define LSMTEST_MODE_BACKGROUND_BOTH 4\n\n/*************************************************************************\n**************************************************************************\n** Begin test VFS code.\n*/\n\nstruct LsmFile {\n  lsm_file *pReal;                /* Real underlying file */\n  int bLog;                       /* True for log file. False for db file */\n  LsmDb *pDb;                     /* Database handle that uses this file */\n};\n\nstatic int testEnvFullpath(\n  lsm_env *pEnv,                  /* Environment for current LsmDb */\n  const char *zFile,              /* Relative path name */\n  char *zOut,                     /* Output buffer */\n  int *pnOut                      /* IN/OUT: Size of output buffer */\n){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  return pRealEnv->xFullpath(pRealEnv, zFile, zOut, pnOut);\n}\n\nstatic int testEnvOpen(\n  lsm_env *pEnv,                  /* Environment for current LsmDb */\n  const char *zFile,              /* Name of file to open */\n  int flags,\n  lsm_file **ppFile               /* OUT: New file handle object */\n){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmDb *pDb = (LsmDb *)pEnv->pVfsCtx;\n  int rc;                         /* Return Code */\n  LsmFile *pRet;                  /* The new file handle */\n  int nFile;                      /* Length of string zFile in bytes */\n\n  nFile = strlen(zFile);\n  pRet = (LsmFile *)testMalloc(sizeof(LsmFile));\n  pRet->pDb = pDb;\n  pRet->bLog = (nFile > 4 && 0==memcmp(\"-log\", &zFile[nFile-4], 4));\n\n  rc = pRealEnv->xOpen(pRealEnv, zFile, flags, &pRet->pReal);\n  if( rc!=LSM_OK ){\n    testFree(pRet);\n    pRet = 0;\n  }\n\n  *ppFile = (lsm_file *)pRet;\n  return rc;\n}\n\nstatic int testEnvRead(lsm_file *pFile, lsm_i64 iOff, void *pData, int nData){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  if( p->pDb->bCrashed ) return LSM_IOERR;\n  return pRealEnv->xRead(p->pReal, iOff, pData, nData);\n}\n\nstatic int testEnvWrite(lsm_file *pFile, lsm_i64 iOff, void *pData, int nData){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  LsmDb *pDb = p->pDb;\n\n  if( pDb->bCrashed ) return LSM_IOERR;\n\n  if( pDb->bPrepareCrash ){\n    FileData *pData2 = &pDb->aFile[p->bLog];\n    int iFirst;                 \n    int iLast;\n    int iSector;\n\n    iFirst = (int)(iOff / pDb->szSector);\n    iLast =  (int)((iOff + nData - 1) / pDb->szSector);\n\n    if( pData2->nSector<(iLast+1) ){\n      int nNew = ( ((iLast + 1) + 63) / 64 ) * 64;\n      assert( nNew>iLast );\n      pData2->aSector = (FileSector *)testRealloc(\n          pData2->aSector, nNew*sizeof(FileSector)\n      );\n      memset(&pData2->aSector[pData2->nSector], \n          0, (nNew - pData2->nSector) * sizeof(FileSector)\n      );\n      pData2->nSector = nNew;\n    }\n\n    for(iSector=iFirst; iSector<=iLast; iSector++){\n      if( pData2->aSector[iSector].aOld==0 ){\n        u8 *aOld = (u8 *)testMalloc(pDb->szSector);\n        pRealEnv->xRead(\n            p->pReal, (lsm_i64)iSector*pDb->szSector, aOld, pDb->szSector\n        );\n        pData2->aSector[iSector].aOld = aOld;\n      }\n    }\n  }\n\n  if( pDb->xWriteHook ){\n    int rc;\n    int nUs;\n    struct timeval t1;\n    struct timeval t2;\n\n    gettimeofday(&t1, 0);\n    assert( nData>0 );\n    rc = pRealEnv->xWrite(p->pReal, iOff, pData, nData);\n    gettimeofday(&t2, 0);\n\n    nUs = (t2.tv_sec - t1.tv_sec) * 1000000 + (t2.tv_usec - t1.tv_usec);\n    pDb->xWriteHook(pDb->pWriteCtx, p->bLog, iOff, nData, nUs);\n    return rc;\n  }\n\n  return pRealEnv->xWrite(p->pReal, iOff, pData, nData);\n}\n\nstatic void doSystemCrash(LsmDb *pDb);\n\nstatic int testEnvSync(lsm_file *pFile){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  LsmDb *pDb = p->pDb;\n  FileData *pData = &pDb->aFile[p->bLog];\n  int i;\n\n  if( pDb->bCrashed ) return LSM_IOERR;\n\n  if( pDb->nAutoCrash ){\n    pDb->nAutoCrash--;\n    if( pDb->nAutoCrash==0 ){\n      doSystemCrash(pDb);\n      pDb->bCrashed = 1;\n      return LSM_IOERR;\n    }\n  }\n\n  if( pDb->bPrepareCrash ){\n    for(i=0; i<pData->nSector; i++){\n      testFree(pData->aSector[i].aOld);\n      pData->aSector[i].aOld = 0;\n    }\n  }\n\n  if( pDb->xWriteHook ){\n    int rc;\n    int nUs;\n    struct timeval t1;\n    struct timeval t2;\n\n    gettimeofday(&t1, 0);\n    rc = pRealEnv->xSync(p->pReal);\n    gettimeofday(&t2, 0);\n\n    nUs = (t2.tv_sec - t1.tv_sec) * 1000000 + (t2.tv_usec - t1.tv_usec);\n    pDb->xWriteHook(pDb->pWriteCtx, p->bLog, 0, 0, nUs);\n    return rc;\n  }\n\n  return pRealEnv->xSync(p->pReal);\n}\n\nstatic int testEnvTruncate(lsm_file *pFile, lsm_i64 iOff){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  if( p->pDb->bCrashed ) return LSM_IOERR;\n  return pRealEnv->xTruncate(p->pReal, iOff);\n}\n\nstatic int testEnvSectorSize(lsm_file *pFile){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  return pRealEnv->xSectorSize(p->pReal);\n}\n\nstatic int testEnvRemap(\n  lsm_file *pFile, \n  lsm_i64 iMin, \n  void **ppOut,\n  lsm_i64 *pnOut\n){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  return pRealEnv->xRemap(p->pReal, iMin, ppOut, pnOut);\n}\n\nstatic int testEnvFileid(\n  lsm_file *pFile, \n  void *ppOut,\n  int *pnOut\n){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n  return pRealEnv->xFileid(p->pReal, ppOut, pnOut);\n}\n\nstatic int testEnvClose(lsm_file *pFile){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  LsmFile *p = (LsmFile *)pFile;\n\n  pRealEnv->xClose(p->pReal);\n  testFree(p);\n  return LSM_OK;\n}\n\nstatic int testEnvUnlink(lsm_env *pEnv, const char *zFile){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  unused_parameter(pEnv);\n  return pRealEnv->xUnlink(pRealEnv, zFile);\n}\n\nstatic int testEnvLock(lsm_file *pFile, int iLock, int eType){\n  LsmFile *p = (LsmFile *)pFile;\n  lsm_env *pRealEnv = tdb_lsm_env();\n\n  if( iLock==2 && eType==LSM_LOCK_EXCL && p->pDb->bNoRecovery ){\n    return LSM_BUSY;\n  }\n  return pRealEnv->xLock(p->pReal, iLock, eType);\n}\n\nstatic int testEnvTestLock(lsm_file *pFile, int iLock, int nLock, int eType){\n  LsmFile *p = (LsmFile *)pFile;\n  lsm_env *pRealEnv = tdb_lsm_env();\n\n  if( iLock==2 && eType==LSM_LOCK_EXCL && p->pDb->bNoRecovery ){\n    return LSM_BUSY;\n  }\n  return pRealEnv->xTestLock(p->pReal, iLock, nLock, eType);\n}\n\nstatic int testEnvShmMap(lsm_file *pFile, int iRegion, int sz, void **pp){\n  LsmFile *p = (LsmFile *)pFile;\n  lsm_env *pRealEnv = tdb_lsm_env();\n  return pRealEnv->xShmMap(p->pReal, iRegion, sz, pp);\n}\n\nstatic void testEnvShmBarrier(void){\n}\n\nstatic int testEnvShmUnmap(lsm_file *pFile, int bDel){\n  LsmFile *p = (LsmFile *)pFile;\n  lsm_env *pRealEnv = tdb_lsm_env();\n  return pRealEnv->xShmUnmap(p->pReal, bDel);\n}\n\nstatic int testEnvSleep(lsm_env *pEnv, int us){\n  lsm_env *pRealEnv = tdb_lsm_env();\n  return pRealEnv->xSleep(pRealEnv, us);\n}\n\nstatic void doSystemCrash(LsmDb *pDb){\n  lsm_env *pEnv = tdb_lsm_env();\n  int iFile;\n  int iSeed = pDb->aFile[0].nSector + pDb->aFile[1].nSector;\n\n  char *zFile = pDb->zName;\n  char *zFree = 0;\n\n  for(iFile=0; iFile<2; iFile++){\n    lsm_file *pFile = 0;\n    int i;\n\n    pEnv->xOpen(pEnv, zFile, 0, &pFile);\n    for(i=0; i<pDb->aFile[iFile].nSector; i++){\n      u8 *aOld = pDb->aFile[iFile].aSector[i].aOld;\n      if( aOld ){\n        int iOpt = testPrngValue(iSeed++) % 3;\n        switch( iOpt ){\n          case 0:\n            break;\n\n          case 1:\n            testPrngArray(iSeed++, (u32 *)aOld, pDb->szSector/4);\n            /* Fall-through */\n\n          case 2:\n            pEnv->xWrite(\n                pFile, (lsm_i64)i * pDb->szSector, aOld, pDb->szSector\n            );\n            break;\n        }\n        testFree(aOld);\n        pDb->aFile[iFile].aSector[i].aOld = 0;\n      }\n    }\n    pEnv->xClose(pFile);\n    zFree = zFile = sqlite3_mprintf(\"%s-log\", pDb->zName);\n  }\n\n  sqlite3_free(zFree);\n}\n/*\n** End test VFS code.\n**************************************************************************\n*************************************************************************/\n\n/*************************************************************************\n**************************************************************************\n** Begin test compression hooks.\n*/\n\n#ifdef HAVE_ZLIB\n#include <zlib.h>\n\nstatic int testZipBound(void *pCtx, int nSrc){\n  return compressBound(nSrc);\n}\n\nstatic int testZipCompress(\n  void *pCtx,                     /* Context pointer */\n  char *aOut, int *pnOut,         /* OUT: Buffer containing compressed data */\n  const char *aIn, int nIn        /* Buffer containing input data */\n){\n  uLongf n = *pnOut;              /* In/out buffer size for compress() */\n  int rc;                         /* compress() return code */\n \n  rc = compress((Bytef*)aOut, &n, (Bytef*)aIn, nIn);\n  *pnOut = n;\n  return (rc==Z_OK ? 0 : LSM_ERROR);\n}\n\nstatic int testZipUncompress(\n  void *pCtx,                     /* Context pointer */\n  char *aOut, int *pnOut,         /* OUT: Buffer containing uncompressed data */\n  const char *aIn, int nIn        /* Buffer containing input data */\n){\n  uLongf n = *pnOut;              /* In/out buffer size for uncompress() */\n  int rc;                         /* uncompress() return code */\n\n  rc = uncompress((Bytef*)aOut, &n, (Bytef*)aIn, nIn);\n  *pnOut = n;\n  return (rc==Z_OK ? 0 : LSM_ERROR);\n}\n\nstatic int testConfigureCompression(lsm_db *pDb){\n  static lsm_compress zip = {\n    0,                            /* Context pointer (unused) */\n    1,                            /* Id value */\n    testZipBound,                 /* xBound method */\n    testZipCompress,              /* xCompress method */\n    testZipUncompress             /* xUncompress method */\n  };\n  return lsm_config(pDb, LSM_CONFIG_SET_COMPRESSION, &zip);\n}\n#endif /* ifdef HAVE_ZLIB */\n\n/*\n** End test compression hooks.\n**************************************************************************\n*************************************************************************/\n\nstatic int test_lsm_close(TestDb *pTestDb){\n  int i;\n  int rc = LSM_OK;\n  LsmDb *pDb = (LsmDb *)pTestDb;\n\n  lsm_csr_close(pDb->pCsr);\n  lsm_close(pDb->db);\n\n  /* If this is a multi-threaded database, wait on the worker threads. */\n  mt_shutdown(pDb);\n  for(i=0; i<pDb->nWorker && rc==LSM_OK; i++){\n    rc = pDb->aWorker[i].worker_rc;\n  }\n\n  for(i=0; i<pDb->aFile[0].nSector; i++){\n    testFree(pDb->aFile[0].aSector[i].aOld);\n  }\n  testFree(pDb->aFile[0].aSector);\n  for(i=0; i<pDb->aFile[1].nSector; i++){\n    testFree(pDb->aFile[1].aSector[i].aOld);\n  }\n  testFree(pDb->aFile[1].aSector);\n\n  memset(pDb, sizeof(LsmDb), 0x11);\n  testFree((char *)pDb->pBuf);\n  testFree((char *)pDb);\n  return rc;\n}\n\nstatic void mt_signal_worker(LsmDb*, int);\n\nstatic int waitOnCheckpointer(LsmDb *pDb, lsm_db *db){\n  int nSleep = 0;\n  int nKB;\n  int rc;\n\n  do {\n    nKB = 0;\n    rc = lsm_info(db, LSM_INFO_CHECKPOINT_SIZE, &nKB);\n    if( rc!=LSM_OK || nKB<pDb->nMtMaxCkpt ) break;\n#ifdef LSM_MUTEX_PTHREADS\n    mt_signal_worker(pDb, \n        (pDb->eMode==LSMTEST_MODE_BACKGROUND_CKPT ? 0 : 1)\n    );\n#endif\n    usleep(5000);\n    nSleep += 5;\n  }while( 1 );\n\n#if 0\n    if( nSleep ) printf(\"# waitOnCheckpointer(): nSleep=%d\\n\", nSleep);\n#endif\n\n  return rc;\n}\n\nstatic int waitOnWorker(LsmDb *pDb){\n  int rc;\n  int nLimit = -1;\n  int nSleep = 0;\n\n  rc = lsm_config(pDb->db, LSM_CONFIG_AUTOFLUSH, &nLimit);\n  do {\n    int nOld, nNew, rc2;\n    rc2 = lsm_info(pDb->db, LSM_INFO_TREE_SIZE, &nOld, &nNew);\n    if( rc2!=LSM_OK ) return rc2;\n    if( nOld==0 || nNew<(nLimit/2) ) break;\n#ifdef LSM_MUTEX_PTHREADS\n    mt_signal_worker(pDb, 0);\n#endif\n    usleep(5000);\n    nSleep += 5;\n  }while( 1 );\n\n#if 0\n  if( nSleep ) printf(\"# waitOnWorker(): nSleep=%d\\n\", nSleep);\n#endif\n\n  return rc;\n}\n\nstatic int test_lsm_write(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void *pVal,\n  int nVal\n){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n  int rc = LSM_OK;\n\n  if( pDb->eMode==LSMTEST_MODE_BACKGROUND_CKPT ){\n    rc = waitOnCheckpointer(pDb, pDb->db);\n  }else if( \n      pDb->eMode==LSMTEST_MODE_BACKGROUND_WORK\n   || pDb->eMode==LSMTEST_MODE_BACKGROUND_BOTH \n  ){\n    rc = waitOnWorker(pDb);\n  }\n\n  if( rc==LSM_OK ){\n    rc = lsm_insert(pDb->db, pKey, nKey, pVal, nVal);\n  }\n  return rc;\n}\n\nstatic int test_lsm_delete(TestDb *pTestDb, void *pKey, int nKey){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n  return lsm_delete(pDb->db, pKey, nKey);\n}\n\nstatic int test_lsm_delete_range(\n  TestDb *pTestDb, \n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2\n){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n  return lsm_delete_range(pDb->db, pKey1, nKey1, pKey2, nKey2);\n}\n\nstatic int test_lsm_fetch(\n  TestDb *pTestDb, \n  void *pKey, \n  int nKey, \n  void **ppVal, \n  int *pnVal\n){\n  int rc;\n  LsmDb *pDb = (LsmDb *)pTestDb;\n  lsm_cursor *csr;\n\n  if( pKey==0 ) return LSM_OK;\n\n  rc = lsm_csr_open(pDb->db, &csr);\n  if( rc!=LSM_OK ) return rc;\n\n  rc = lsm_csr_seek(csr, pKey, nKey, LSM_SEEK_EQ);\n  if( rc==LSM_OK ){\n    if( lsm_csr_valid(csr) ){\n      const void *pVal; int nVal;\n      rc = lsm_csr_value(csr, &pVal, &nVal);\n      if( nVal>pDb->nBuf ){\n        testFree(pDb->pBuf);\n        pDb->pBuf = testMalloc(nVal*2);\n        pDb->nBuf = nVal*2;\n      }\n      memcpy(pDb->pBuf, pVal, nVal);\n      *ppVal = pDb->pBuf;\n      *pnVal = nVal;\n    }else{\n      *ppVal = 0;\n      *pnVal = -1;\n    }\n  }\n  lsm_csr_close(csr);\n  return rc;\n}\n\nstatic int test_lsm_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pFirst, int nFirst,\n  void *pLast, int nLast,\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n  lsm_cursor *csr;\n  int rc;\n\n  rc = lsm_csr_open(pDb->db, &csr);\n  if( rc!=LSM_OK ) return rc;\n\n  if( bReverse ){\n    if( pLast ){\n      rc = lsm_csr_seek(csr, pLast, nLast, LSM_SEEK_LE);\n    }else{\n      rc = lsm_csr_last(csr);\n    }\n  }else{\n    if( pFirst ){\n      rc = lsm_csr_seek(csr, pFirst, nFirst, LSM_SEEK_GE);\n    }else{\n      rc = lsm_csr_first(csr);\n    }\n  }\n\n  while( rc==LSM_OK && lsm_csr_valid(csr) ){\n    const void *pKey; int nKey;\n    const void *pVal; int nVal;\n    int cmp;\n\n    lsm_csr_key(csr, &pKey, &nKey);\n    lsm_csr_value(csr, &pVal, &nVal);\n\n    if( bReverse && pFirst ){\n      cmp = memcmp(pFirst, pKey, MIN(nKey, nFirst));\n      if( cmp>0 || (cmp==0 && nFirst>nKey) ) break;\n    }else if( bReverse==0 && pLast ){\n      cmp = memcmp(pLast, pKey, MIN(nKey, nLast));\n      if( cmp<0 || (cmp==0 && nLast<nKey) ) break;\n    }\n\n    xCallback(pCtx, (void *)pKey, nKey, (void *)pVal, nVal);\n\n    if( bReverse ){\n      rc = lsm_csr_prev(csr);\n    }else{\n      rc = lsm_csr_next(csr);\n    }\n  }\n\n  lsm_csr_close(csr);\n  return rc;\n}\n\nstatic int test_lsm_begin(TestDb *pTestDb, int iLevel){\n  int rc = LSM_OK;\n  LsmDb *pDb = (LsmDb *)pTestDb;\n\n  /* iLevel==0 is a no-op. */\n  if( iLevel==0 ) return 0;\n\n  if( pDb->pCsr==0 ) rc = lsm_csr_open(pDb->db, &pDb->pCsr);\n  if( rc==LSM_OK && iLevel>1 ){\n    rc = lsm_begin(pDb->db, iLevel-1);\n  }\n\n  return rc;\n}\nstatic int test_lsm_commit(TestDb *pTestDb, int iLevel){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n\n  /* If iLevel==0, close any open read transaction */\n  if( iLevel==0 && pDb->pCsr ){\n    lsm_csr_close(pDb->pCsr);\n    pDb->pCsr = 0;\n  }\n\n  /* If iLevel==0, close any open read transaction */\n  return lsm_commit(pDb->db, MAX(0, iLevel-1));\n}\nstatic int test_lsm_rollback(TestDb *pTestDb, int iLevel){\n  LsmDb *pDb = (LsmDb *)pTestDb;\n\n  /* If iLevel==0, close any open read transaction */\n  if( iLevel==0 && pDb->pCsr ){\n    lsm_csr_close(pDb->pCsr);\n    pDb->pCsr = 0;\n  }\n\n  return lsm_rollback(pDb->db, MAX(0, iLevel-1));\n}\n\n/*\n** A log message callback registered with lsm connections. Prints all \n** messages to stderr.\n*/\nstatic void xLog(void *pCtx, int rc, const char *z){\n  unused_parameter(rc);\n  /* fprintf(stderr, \"lsm: rc=%d \\\"%s\\\"\\n\", rc, z); */\n  if( pCtx ) fprintf(stderr, \"%s: \", (char *)pCtx);\n  fprintf(stderr, \"%s\\n\", z);\n  fflush(stderr);\n}\n\nstatic void xWorkHook(lsm_db *db, void *pArg){\n  LsmDb *p = (LsmDb *)pArg;\n  if( p->xWork ) p->xWork(db, p->pWorkCtx);\n}\n\n#define TEST_NO_RECOVERY -1\n#define TEST_COMPRESSION -3\n\n#define TEST_MT_MODE     -2\n#define TEST_MT_MIN_CKPT -4\n#define TEST_MT_MAX_CKPT -5\n\nint test_lsm_config_str(\n  LsmDb *pLsm,\n  lsm_db *db, \n  int bWorker,\n  const char *zStr,\n  int *pnThread\n){\n  struct CfgParam {\n    const char *zParam;\n    int bWorker;\n    int eParam;\n  } aParam[] = {\n    { \"autoflush\",        0, LSM_CONFIG_AUTOFLUSH },\n    { \"page_size\",        0, LSM_CONFIG_PAGE_SIZE },\n    { \"block_size\",       0, LSM_CONFIG_BLOCK_SIZE },\n    { \"safety\",           0, LSM_CONFIG_SAFETY },\n    { \"autowork\",         0, LSM_CONFIG_AUTOWORK },\n    { \"autocheckpoint\",   0, LSM_CONFIG_AUTOCHECKPOINT },\n    { \"mmap\",             0, LSM_CONFIG_MMAP },\n    { \"use_log\",          0, LSM_CONFIG_USE_LOG },\n    { \"automerge\",        0, LSM_CONFIG_AUTOMERGE },\n    { \"max_freelist\",     0, LSM_CONFIG_MAX_FREELIST },\n    { \"multi_proc\",       0, LSM_CONFIG_MULTIPLE_PROCESSES },\n    { \"worker_automerge\", 1, LSM_CONFIG_AUTOMERGE },\n    { \"test_no_recovery\", 0, TEST_NO_RECOVERY },\n    { \"bg_min_ckpt\",      0, TEST_NO_RECOVERY },\n\n    { \"mt_mode\",          0, TEST_MT_MODE },\n    { \"mt_min_ckpt\",      0, TEST_MT_MIN_CKPT },\n    { \"mt_max_ckpt\",      0, TEST_MT_MAX_CKPT },\n\n#ifdef HAVE_ZLIB\n    { \"compression\",      0, TEST_COMPRESSION },\n#endif\n    { 0, 0 }\n  };\n  const char *z = zStr;\n  int nThread = 1;\n\n  if( zStr==0 ) return 0;\n\n  assert( db );\n  while( z[0] ){\n    const char *zStart;\n\n    /* Skip whitespace */\n    while( *z==' ' ) z++;\n    zStart = z;\n\n    while( *z && *z!='=' ) z++;\n    if( *z ){\n      int eParam;\n      int i;\n      int iVal;\n      int iMul = 1;\n      int rc;\n      char zParam[32];\n      int nParam = z-zStart;\n      if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error;\n\n      memcpy(zParam, zStart, nParam);\n      zParam[nParam] = '\\0';\n      rc = testArgSelect(aParam, \"param\", zParam, &i);\n      if( rc!=0 ) return rc;\n      eParam = aParam[i].eParam;\n\n      z++;\n      zStart = z;\n      while( *z>='0' && *z<='9' ) z++;\n      if( *z=='k' || *z=='K' ){\n        iMul = 1;\n        z++;\n      }else if( *z=='M' || *z=='M' ){\n        iMul = 1024;\n        z++;\n      }\n      nParam = z-zStart;\n      if( nParam==0 || nParam>sizeof(zParam)-1 ) goto syntax_error;\n      memcpy(zParam, zStart, nParam);\n      zParam[nParam] = '\\0';\n      iVal = atoi(zParam) * iMul;\n\n      if( eParam>0 ){\n        if( bWorker || aParam[i].bWorker==0 ){\n          lsm_config(db, eParam, &iVal);\n        }\n      }else{\n        switch( eParam ){\n          case TEST_NO_RECOVERY:\n            if( pLsm ) pLsm->bNoRecovery = iVal;\n            break;\n          case TEST_MT_MODE:\n            if( pLsm ) nThread = iVal;\n            break;\n          case TEST_MT_MIN_CKPT:\n            if( pLsm && iVal>0 ) pLsm->nMtMinCkpt = iVal*1024;\n            break;\n          case TEST_MT_MAX_CKPT:\n            if( pLsm && iVal>0 ) pLsm->nMtMaxCkpt = iVal*1024;\n            break;\n#ifdef HAVE_ZLIB\n          case TEST_COMPRESSION:\n            testConfigureCompression(db);\n            break;\n#endif\n        }\n      }\n    }else if( z!=zStart ){\n      goto syntax_error;\n    }\n  }\n\n  if( pnThread ) *pnThread = nThread;\n  if( pLsm && pLsm->nMtMaxCkpt < pLsm->nMtMinCkpt ){\n    pLsm->nMtMinCkpt = pLsm->nMtMaxCkpt;\n  }\n\n  return 0;\n syntax_error:\n  testPrintError(\"syntax error at: \\\"%s\\\"\\n\", z);\n  return 1;\n}\n\nint tdb_lsm_config_str(TestDb *pDb, const char *zStr){\n  int rc = 0;\n  if( tdb_lsm(pDb) ){\n#ifdef LSM_MUTEX_PTHREADS\n    int i;\n#endif\n    LsmDb *pLsm = (LsmDb *)pDb;\n\n    rc = test_lsm_config_str(pLsm, pLsm->db, 0, zStr, 0);\n#ifdef LSM_MUTEX_PTHREADS\n    for(i=0; rc==0 && i<pLsm->nWorker; i++){\n      rc = test_lsm_config_str(0, pLsm->aWorker[i].pWorker, 1, zStr, 0);\n    }\n#endif\n  }\n  return rc;\n}\n\nint tdb_lsm_configure(lsm_db *db, const char *zConfig){\n  return test_lsm_config_str(0, db, 0, zConfig, 0);\n}\n\nstatic int testLsmStartWorkers(LsmDb *, int, const char *, const char *);\n\nstatic int testLsmOpen(\n  const char *zCfg,\n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  static const DatabaseMethods LsmMethods = {\n    test_lsm_close,\n    test_lsm_write,\n    test_lsm_delete,\n    test_lsm_delete_range,\n    test_lsm_fetch,\n    test_lsm_scan,\n    test_lsm_begin,\n    test_lsm_commit,\n    test_lsm_rollback\n  };\n\n  int rc;\n  int nFilename;\n  LsmDb *pDb;\n\n  /* If the bClear flag is set, delete any existing database. */\n  assert( zFilename);\n  if( bClear ) testDeleteLsmdb(zFilename);\n  nFilename = strlen(zFilename);\n\n  pDb = (LsmDb *)testMalloc(sizeof(LsmDb) + nFilename + 1);\n  memset(pDb, 0, sizeof(LsmDb));\n  pDb->base.pMethods = &LsmMethods;\n  pDb->zName = (char *)&pDb[1];\n  memcpy(pDb->zName, zFilename, nFilename + 1);\n\n  /* Default the sector size used for crash simulation to 512 bytes. \n  ** Todo: There should be an OS method to obtain this value - just as\n  ** there is in SQLite. For now, LSM assumes that it is smaller than\n  ** the page size (default 4KB).\n  */\n  pDb->szSector = 256;\n\n  /* Default values for the mt_min_ckpt and mt_max_ckpt parameters. */\n  pDb->nMtMinCkpt = LSMTEST_DFLT_MT_MIN_CKPT;\n  pDb->nMtMaxCkpt = LSMTEST_DFLT_MT_MAX_CKPT;\n\n  memcpy(&pDb->env, tdb_lsm_env(), sizeof(lsm_env));\n  pDb->env.pVfsCtx = (void *)pDb;\n  pDb->env.xFullpath = testEnvFullpath;\n  pDb->env.xOpen = testEnvOpen;\n  pDb->env.xRead = testEnvRead;\n  pDb->env.xWrite = testEnvWrite;\n  pDb->env.xTruncate = testEnvTruncate;\n  pDb->env.xSync = testEnvSync;\n  pDb->env.xSectorSize = testEnvSectorSize;\n  pDb->env.xRemap = testEnvRemap;\n  pDb->env.xFileid = testEnvFileid;\n  pDb->env.xClose = testEnvClose;\n  pDb->env.xUnlink = testEnvUnlink;\n  pDb->env.xLock = testEnvLock;\n  pDb->env.xTestLock = testEnvTestLock;\n  pDb->env.xShmBarrier = testEnvShmBarrier;\n  pDb->env.xShmMap = testEnvShmMap;\n  pDb->env.xShmUnmap = testEnvShmUnmap;\n  pDb->env.xSleep = testEnvSleep;\n\n  rc = lsm_new(&pDb->env, &pDb->db);\n  if( rc==LSM_OK ){\n    int nThread = 1;\n    lsm_config_log(pDb->db, xLog, 0);\n    lsm_config_work_hook(pDb->db, xWorkHook, (void *)pDb);\n\n    rc = test_lsm_config_str(pDb, pDb->db, 0, zCfg, &nThread);\n    if( rc==LSM_OK ) rc = lsm_open(pDb->db, zFilename);\n\n    pDb->eMode = nThread;\n#ifdef LSM_MUTEX_PTHREADS\n    if( rc==LSM_OK && nThread>1 ){\n      testLsmStartWorkers(pDb, nThread, zFilename, zCfg);\n    }\n#endif\n\n    if( rc!=LSM_OK ){\n      test_lsm_close((TestDb *)pDb);\n      pDb = 0;\n    }\n  }\n\n  *ppDb = (TestDb *)pDb;\n  return rc;\n}\n\nint test_lsm_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  return testLsmOpen(zSpec, zFilename, bClear, ppDb);\n}\n\nint test_lsm_small_open(\n  const char *zSpec, \n  const char *zFile, \n  int bClear, \n  TestDb **ppDb\n){\n  const char *zCfg = \"page_size=256 block_size=64 mmap=1024\";\n  return testLsmOpen(zCfg, zFile, bClear, ppDb);\n}\n\nint test_lsm_lomem_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n    /* \"max_freelist=4 autocheckpoint=32\" */\n  const char *zCfg = \n    \"page_size=256 block_size=64 autoflush=16 \"\n    \"autocheckpoint=32\"\n    \"mmap=0 \"\n  ;\n  return testLsmOpen(zCfg, zFilename, bClear, ppDb);\n}\n\nint test_lsm_zip_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  const char *zCfg = \n    \"page_size=256 block_size=64 autoflush=16 \"\n    \"autocheckpoint=32 compression=1 mmap=0 \"\n  ;\n  return testLsmOpen(zCfg, zFilename, bClear, ppDb);\n}\n\nlsm_db *tdb_lsm(TestDb *pDb){\n  if( pDb->pMethods->xClose==test_lsm_close ){\n    return ((LsmDb *)pDb)->db;\n  }\n  return 0;\n}\n\nint tdb_lsm_multithread(TestDb *pDb){\n  int ret = 0;\n  if( tdb_lsm(pDb) ){\n    ret = ((LsmDb*)pDb)->eMode!=LSMTEST_MODE_SINGLETHREAD;\n  }\n  return ret;\n}\n\nvoid tdb_lsm_enable_log(TestDb *pDb, int bEnable){\n  lsm_db *db = tdb_lsm(pDb);\n  if( db ){\n    lsm_config_log(db, (bEnable ? xLog : 0), (void *)\"client\");\n  }\n}\n\nvoid tdb_lsm_application_crash(TestDb *pDb){\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->bCrashed = 1;\n  }\n}\n\nvoid tdb_lsm_prepare_system_crash(TestDb *pDb){\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->bPrepareCrash = 1;\n  }\n}\n\nvoid tdb_lsm_system_crash(TestDb *pDb){\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->bCrashed = 1;\n    doSystemCrash(p);\n  }\n}\n\nvoid tdb_lsm_safety(TestDb *pDb, int eMode){\n  assert( eMode==LSM_SAFETY_OFF \n       || eMode==LSM_SAFETY_NORMAL \n       || eMode==LSM_SAFETY_FULL \n  );\n  if( tdb_lsm(pDb) ){\n    int iParam = eMode;\n    LsmDb *p = (LsmDb *)pDb;\n    lsm_config(p->db, LSM_CONFIG_SAFETY, &iParam);\n  }\n}\n\nvoid tdb_lsm_prepare_sync_crash(TestDb *pDb, int iSync){\n  assert( iSync>0 );\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->nAutoCrash = iSync;\n    p->bPrepareCrash = 1;\n  }\n}\n\nvoid tdb_lsm_config_work_hook(\n  TestDb *pDb, \n  void (*xWork)(lsm_db *, void *), \n  void *pWorkCtx\n){\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->xWork = xWork;\n    p->pWorkCtx = pWorkCtx;\n  }\n}\n\nvoid tdb_lsm_write_hook(\n  TestDb *pDb, \n  void (*xWrite)(void *, int, lsm_i64, int, int),\n  void *pWriteCtx\n){\n  if( tdb_lsm(pDb) ){\n    LsmDb *p = (LsmDb *)pDb;\n    p->xWriteHook = xWrite;\n    p->pWriteCtx = pWriteCtx;\n  }\n}\n\nint tdb_lsm_open(const char *zCfg, const char *zDb, int bClear, TestDb **ppDb){\n  return testLsmOpen(zCfg, zDb, bClear, ppDb);\n}\n\n#ifdef LSM_MUTEX_PTHREADS\n\n/*\n** Signal worker thread iWorker that there may be work to do.\n*/\nstatic void mt_signal_worker(LsmDb *pDb, int iWorker){\n  LsmWorker *p = &pDb->aWorker[iWorker];\n  pthread_mutex_lock(&p->worker_mutex);\n  p->bDoWork = 1;\n  pthread_cond_signal(&p->worker_cond);\n  pthread_mutex_unlock(&p->worker_mutex);\n}\n\n/*\n** This routine is used as the main() for all worker threads.\n*/\nstatic void *worker_main(void *pArg){\n  LsmWorker *p = (LsmWorker *)pArg;\n  lsm_db *pWorker;                /* Connection to access db through */\n\n  pthread_mutex_lock(&p->worker_mutex);\n  while( (pWorker = p->pWorker) ){\n    int rc = LSM_OK;\n\n    /* Do some work. If an error occurs, exit. */\n\n    pthread_mutex_unlock(&p->worker_mutex);\n    if( p->eType==LSMTEST_THREAD_CKPT ){\n      int nKB = 0;\n      rc = lsm_info(pWorker, LSM_INFO_CHECKPOINT_SIZE, &nKB);\n      if( rc==LSM_OK && nKB>=p->pDb->nMtMinCkpt ){\n        rc = lsm_checkpoint(pWorker, 0);\n      }\n    }else{\n      int nWrite;\n      do {\n\n        if( p->eType==LSMTEST_THREAD_WORKER ){\n          waitOnCheckpointer(p->pDb, pWorker);\n        }\n\n        nWrite = 0;\n        rc = lsm_work(pWorker, 0, 256, &nWrite);\n\n        if( p->eType==LSMTEST_THREAD_WORKER && nWrite ){\n          mt_signal_worker(p->pDb, 1);\n        }\n      }while( nWrite && p->pWorker );\n    }\n    pthread_mutex_lock(&p->worker_mutex);\n\n    if( rc!=LSM_OK && rc!=LSM_BUSY ){\n      p->worker_rc = rc;\n      break;\n    }\n\n    /* The thread will wake up when it is signaled either because another\n    ** thread has created some work for this one or because the connection\n    ** is being closed.  */\n    if( p->pWorker && p->bDoWork==0 ){\n      pthread_cond_wait(&p->worker_cond, &p->worker_mutex);\n    }\n    p->bDoWork = 0;\n  }\n  pthread_mutex_unlock(&p->worker_mutex);\n  \n  return 0;\n}\n\n\nstatic void mt_stop_worker(LsmDb *pDb, int iWorker){\n  LsmWorker *p = &pDb->aWorker[iWorker];\n  if( p->pWorker ){\n    void *pDummy;\n    lsm_db *pWorker;\n\n    /* Signal the worker to stop */\n    pthread_mutex_lock(&p->worker_mutex);\n    pWorker = p->pWorker;\n    p->pWorker = 0;\n    pthread_cond_signal(&p->worker_cond);\n    pthread_mutex_unlock(&p->worker_mutex);\n\n    /* Join the worker thread. */\n    pthread_join(p->worker_thread, &pDummy);\n\n    /* Free resources allocated in mt_start_worker() */\n    pthread_cond_destroy(&p->worker_cond);\n    pthread_mutex_destroy(&p->worker_mutex);\n    lsm_close(pWorker);\n  }\n}\n\nstatic void mt_shutdown(LsmDb *pDb){\n  int i;\n  for(i=0; i<pDb->nWorker; i++){\n    mt_stop_worker(pDb, i);\n  }\n}\n\n/*\n** This callback is invoked by LSM when the client database writes to\n** the database file (i.e. to flush the contents of the in-memory tree).\n** This implies there may be work to do on the database, so signal\n** the worker threads.\n*/\nstatic void mt_client_work_hook(lsm_db *db, void *pArg){\n  LsmDb *pDb = (LsmDb *)pArg;     /* LsmDb database handle */\n\n  /* Invoke the user level work-hook, if any. */\n  if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx);\n\n  /* Wake up worker thread 0. */\n  mt_signal_worker(pDb, 0);\n}\n\nstatic void mt_worker_work_hook(lsm_db *db, void *pArg){\n  LsmDb *pDb = (LsmDb *)pArg;     /* LsmDb database handle */\n\n  /* Invoke the user level work-hook, if any. */\n  if( pDb->xWork ) pDb->xWork(db, pDb->pWorkCtx);\n}\n\n/*\n** Launch worker thread iWorker for database connection pDb.\n*/\nstatic int mt_start_worker(\n  LsmDb *pDb,                     /* Main database structure */\n  int iWorker,                    /* Worker number to start */\n  const char *zFilename,          /* File name of database to open */\n  const char *zCfg,               /* Connection configuration string */\n  int eType                       /* Type of worker thread */\n){\n  int rc = 0;                     /* Return code */\n  LsmWorker *p;                   /* Object to initialize */\n\n  assert( iWorker<pDb->nWorker );\n  assert( eType==LSMTEST_THREAD_CKPT \n       || eType==LSMTEST_THREAD_WORKER \n       || eType==LSMTEST_THREAD_WORKER_AC \n  );\n\n  p = &pDb->aWorker[iWorker];\n  p->eType = eType;\n  p->pDb = pDb;\n\n  /* Open the worker connection */\n  if( rc==0 ) rc = lsm_new(&pDb->env, &p->pWorker);\n  if( zCfg ){\n    test_lsm_config_str(pDb, p->pWorker, 1, zCfg, 0);\n  }\n  if( rc==0 ) rc = lsm_open(p->pWorker, zFilename);\n  lsm_config_log(p->pWorker, xLog, (void *)\"worker\");\n\n  /* Configure the work-hook */\n  if( rc==0 ){\n    lsm_config_work_hook(p->pWorker, mt_worker_work_hook, (void *)pDb);\n  }\n\n  if( eType==LSMTEST_THREAD_WORKER ){\n    test_lsm_config_str(0, p->pWorker, 1, \"autocheckpoint=0\", 0);\n  }\n\n  /* Kick off the worker thread. */\n  if( rc==0 ) rc = pthread_cond_init(&p->worker_cond, 0);\n  if( rc==0 ) rc = pthread_mutex_init(&p->worker_mutex, 0);\n  if( rc==0 ) rc = pthread_create(&p->worker_thread, 0, worker_main, (void *)p);\n\n  return rc;\n}\n\n\nstatic int testLsmStartWorkers(\n  LsmDb *pDb, int eModel, const char *zFilename, const char *zCfg\n){\n  int rc;\n\n  if( eModel<1 || eModel>4 ) return 1;\n  if( eModel==1 ) return 0;\n\n  /* Configure a work-hook for the client connection. Worker 0 is signalled\n  ** every time the users connection writes to the database.  */\n  lsm_config_work_hook(pDb->db, mt_client_work_hook, (void *)pDb);\n\n  /* Allocate space for two worker connections. They may not both be\n  ** used, but both are allocated.  */\n  pDb->aWorker = (LsmWorker *)testMalloc(sizeof(LsmWorker) * 2);\n  memset(pDb->aWorker, 0, sizeof(LsmWorker) * 2);\n\n  switch( eModel ){\n    case LSMTEST_MODE_BACKGROUND_CKPT:\n      pDb->nWorker = 1;\n      test_lsm_config_str(0, pDb->db, 0, \"autocheckpoint=0\", 0);\n      rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_CKPT);\n      break;\n\n    case LSMTEST_MODE_BACKGROUND_WORK:\n      pDb->nWorker = 1;\n      test_lsm_config_str(0, pDb->db, 0, \"autowork=0\", 0);\n      rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_WORKER_AC);\n      break;\n\n    case LSMTEST_MODE_BACKGROUND_BOTH:\n      pDb->nWorker = 2;\n      test_lsm_config_str(0, pDb->db, 0, \"autowork=0\", 0);\n      rc = mt_start_worker(pDb, 0, zFilename, zCfg, LSMTEST_THREAD_WORKER);\n      if( rc==0 ){\n        rc = mt_start_worker(pDb, 1, zFilename, zCfg, LSMTEST_THREAD_CKPT);\n      }\n      break;\n  }\n\n  return rc;\n}\n\n\nint test_lsm_mt2(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  const char *zCfg = \"mt_mode=2\";\n  return testLsmOpen(zCfg, zFilename, bClear, ppDb);\n}\n\nint test_lsm_mt3(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  const char *zCfg = \"mt_mode=4\";\n  return testLsmOpen(zCfg, zFilename, bClear, ppDb);\n}\n\n#else\nstatic void mt_shutdown(LsmDb *pDb) { \n  unused_parameter(pDb); \n}\nint test_lsm_mt(const char *zFilename, int bClear, TestDb **ppDb){\n  unused_parameter(zFilename);\n  unused_parameter(bClear);\n  unused_parameter(ppDb);\n  testPrintError(\"threads unavailable - recompile with LSM_MUTEX_PTHREADS\\n\");\n  return 1;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_tdb4.c",
    "content": "\n/*\n** This file contains the TestDb bt wrapper.\n*/\n\n#include \"lsmtest_tdb.h\"\n#include \"lsmtest.h\"\n#include <unistd.h>\n#include \"bt.h\"\n\n#include <pthread.h>\n\ntypedef struct BtDb BtDb;\ntypedef struct BtFile BtFile;\n\n/* Background checkpointer interface (see implementations below). */\ntypedef struct bt_ckpter bt_ckpter;\nstatic int bgc_attach(BtDb *pDb, const char*);\nstatic int bgc_detach(BtDb *pDb);\n\n/*\n** Each database or log file opened by a database handle is wrapped by\n** an object of the following type.\n*/\nstruct BtFile {\n  BtDb *pBt;                      /* Database handle that opened this file */\n  bt_env *pVfs;                   /* Underlying VFS */\n  bt_file *pFile;                 /* File handle belonging to underlying VFS */\n  int nSectorSize;                /* Size of sectors in bytes */\n  int nSector;                    /* Allocated size of nSector array */\n  u8 **apSector;                  /* Original sector data */\n};\n\n/*\n** nCrashSync:\n**   If this value is non-zero, then a \"crash-test\" is running. If\n**   nCrashSync==1, then the crash is simulated during the very next \n**   call to the xSync() VFS method (on either the db or log file).\n**   If nCrashSync==2, the following call to xSync(), and so on.\n**\n** bCrash:\n**   After a crash is simulated, this variable is set. Any subsequent\n**   attempts to write to a file or modify the file system in any way \n**   fail once this is set. All the caller can do is close the connection.\n**\n** bFastInsert:\n**   If this variable is set to true, then a BT_CONTROL_FAST_INSERT_OP\n**   control is issued before each callto BtReplace() or BtCsrOpen().\n*/\nstruct BtDb {\n  TestDb base;                    /* Base class */\n  bt_db *pBt;                     /* bt database handle */\n  sqlite4_env *pEnv;              /* SQLite environment (for malloc/free) */\n  bt_env *pVfs;                   /* Underlying VFS */\n  int bFastInsert;                /* True to use fast-insert */\n\n  /* Space for bt_fetch() results */\n  u8 *aBuffer;                    /* Space to store results */\n  int nBuffer;                    /* Allocated size of aBuffer[] in bytes */\n  int nRef;\n\n  /* Background checkpointer used by mt connections */\n  bt_ckpter *pCkpter;\n\n  /* Stuff used for crash test simulation */\n  BtFile *apFile[2];              /* Database and log files used by pBt */\n  bt_env env;                     /* Private VFS for this object */\n  int nCrashSync;                 /* Number of syncs until crash (see above) */\n  int bCrash;                     /* True once a crash has been simulated */\n};\n\nstatic int btVfsFullpath(\n  sqlite4_env *pEnv, \n  bt_env *pVfs, \n  const char *z, \n  char **pzOut\n){\n  BtDb *pBt = (BtDb*)pVfs->pVfsCtx;\n  if( pBt->bCrash ) return SQLITE4_IOERR;\n  return pBt->pVfs->xFullpath(pEnv, pBt->pVfs, z, pzOut);\n}\n\nstatic int btVfsOpen(\n  sqlite4_env *pEnv, \n  bt_env *pVfs, \n  const char *zFile, \n  int flags, bt_file **ppFile\n){\n  BtFile *p;\n  BtDb *pBt = (BtDb*)pVfs->pVfsCtx;\n  int rc;\n\n  if( pBt->bCrash ) return SQLITE4_IOERR;\n\n  p = (BtFile*)testMalloc(sizeof(BtFile));\n  if( !p ) return SQLITE4_NOMEM;\n  if( flags & BT_OPEN_DATABASE ){\n    pBt->apFile[0] = p;\n  }else if( flags & BT_OPEN_LOG ){\n    pBt->apFile[1] = p;\n  }\n  if( (flags & BT_OPEN_SHARED)==0 ){\n    p->pBt = pBt; \n  }\n  p->pVfs = pBt->pVfs; \n\n  rc = pBt->pVfs->xOpen(pEnv, pVfs, zFile, flags, &p->pFile);\n  if( rc!=SQLITE4_OK ){\n    testFree(p);\n    p = 0;\n  }else{\n    pBt->nRef++;\n  }\n\n  *ppFile = (bt_file*)p;\n  return rc;\n}\n\nstatic int btVfsSize(bt_file *pFile, sqlite4_int64 *piRes){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xSize(p->pFile, piRes);\n}\n\nstatic int btVfsRead(bt_file *pFile, sqlite4_int64 iOff, void *pBuf, int nBuf){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xRead(p->pFile, iOff, pBuf, nBuf);\n}\n\nstatic int btFlushSectors(BtFile *p, int iFile){\n  sqlite4_int64 iSz;\n  int rc;\n  int i;\n  u8 *aTmp = 0;\n\n  rc = p->pBt->pVfs->xSize(p->pFile, &iSz);\n  for(i=0; rc==SQLITE4_OK && i<p->nSector; i++){\n    if( p->pBt->bCrash && p->apSector[i] ){\n\n      /* The system is simulating a crash. There are three choices for\n      ** this sector:\n      **\n      **   1) Leave it as it is (simulating a successful write),\n      **   2) Restore the original data (simulating a lost write),\n      **   3) Populate the disk sector with garbage data.\n      */\n      sqlite4_int64 iSOff = p->nSectorSize*i;\n      int nWrite = MIN(p->nSectorSize, iSz - iSOff);\n\n      if( nWrite ){\n        u8 *aWrite = 0;\n        int iOpt = (testPrngValue(i) % 3) + 1;\n        if( iOpt==1 ){\n          aWrite = p->apSector[i];\n        }else if( iOpt==3 ){\n          if( aTmp==0 ) aTmp = testMalloc(p->nSectorSize);\n          aWrite = aTmp;\n          testPrngArray(i*13, (u32*)aWrite, nWrite/sizeof(u32));\n        }\n\n#if 0\nfprintf(stderr, \"handle sector %d of %s with %s\\n\", i, \n    iFile==0 ? \"db\" : \"log\",\n    iOpt==1 ? \"rollback\" : iOpt==2 ? \"write\" : \"omit\"\n);\nfflush(stderr);\n#endif\n\n        if( aWrite ){\n          rc = p->pBt->pVfs->xWrite(p->pFile, iSOff, aWrite, nWrite);\n        }\n      }\n    }\n    testFree(p->apSector[i]);\n    p->apSector[i] = 0;\n  }\n\n  testFree(aTmp);\n  return rc;\n}\n\nstatic int btSaveSectors(BtFile *p, sqlite4_int64 iOff, int nBuf){\n  int rc;\n  sqlite4_int64 iSz;              /* Size of file on disk */\n  int iFirst;                     /* First sector affected */\n  int iSector;                    /* Current sector */\n  int iLast;                      /* Last sector affected */\n\n  if( p->nSectorSize==0 ){\n    p->nSectorSize = p->pBt->pVfs->xSectorSize(p->pFile);\n    if( p->nSectorSize<512 ) p->nSectorSize = 512;\n  }\n  iLast = (iOff+nBuf-1) / p->nSectorSize;\n  iFirst = iOff / p->nSectorSize;\n\n  rc = p->pBt->pVfs->xSize(p->pFile, &iSz);\n  for(iSector=iFirst; rc==SQLITE4_OK && iSector<=iLast; iSector++){\n    int nRead;\n    sqlite4_int64 iSOff = iSector * p->nSectorSize;\n    u8 *aBuf = testMalloc(p->nSectorSize);\n    nRead = MIN(p->nSectorSize, (iSz - iSOff));\n    if( nRead>0 ){\n      rc = p->pBt->pVfs->xRead(p->pFile, iSOff, aBuf, nRead);\n    }\n\n    while( rc==SQLITE4_OK && iSector>=p->nSector ){\n      int nNew = p->nSector + 32;\n      u8 **apNew = (u8**)testMalloc(nNew * sizeof(u8*));\n      memcpy(apNew, p->apSector, p->nSector*sizeof(u8*));\n      testFree(p->apSector);\n      p->apSector = apNew;\n      p->nSector = nNew;\n    }\n\n    p->apSector[iSector] = aBuf;\n  }\n\n  return rc;\n}\n\nstatic int btVfsWrite(bt_file *pFile, sqlite4_int64 iOff, void *pBuf, int nBuf){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  if( p->pBt && p->pBt->nCrashSync ){\n    btSaveSectors(p, iOff, nBuf);\n  }\n  return p->pVfs->xWrite(p->pFile, iOff, pBuf, nBuf);\n}\n\nstatic int btVfsTruncate(bt_file *pFile, sqlite4_int64 iOff){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xTruncate(p->pFile, iOff);\n}\n\nstatic int btVfsSync(bt_file *pFile){\n  int rc = SQLITE4_OK;\n  BtFile *p = (BtFile*)pFile;\n  BtDb *pBt = p->pBt;\n\n  if( pBt ){\n    if( pBt->bCrash ) return SQLITE4_IOERR;\n    if( pBt->nCrashSync ){\n      pBt->nCrashSync--;\n      pBt->bCrash = (pBt->nCrashSync==0);\n      if( pBt->bCrash ){\n        btFlushSectors(pBt->apFile[0], 0);\n        btFlushSectors(pBt->apFile[1], 1);\n        rc = SQLITE4_IOERR;\n      }else{\n        btFlushSectors(p, 0);\n      }\n    }\n  }\n\n  if( rc==SQLITE4_OK ){\n    rc = p->pVfs->xSync(p->pFile);\n  }\n  return rc;\n}\n\nstatic int btVfsSectorSize(bt_file *pFile){\n  BtFile *p = (BtFile*)pFile;\n  return p->pVfs->xSectorSize(p->pFile);\n}\n\nstatic void btDeref(BtDb *p){\n  p->nRef--;\n  assert( p->nRef>=0 );\n  if( p->nRef<=0 ) testFree(p);\n}\n\nstatic int btVfsClose(bt_file *pFile){\n  BtFile *p = (BtFile*)pFile;\n  BtDb *pBt = p->pBt;\n  int rc;\n  if( pBt ){\n    btFlushSectors(p, 0);\n    if( p==pBt->apFile[0] ) pBt->apFile[0] = 0;\n    if( p==pBt->apFile[1] ) pBt->apFile[1] = 0;\n  }\n  testFree(p->apSector);\n  rc = p->pVfs->xClose(p->pFile);\n#if 0\n  btDeref(p->pBt);\n#endif\n  testFree(p);\n  return rc;\n}\n\nstatic int btVfsUnlink(sqlite4_env *pEnv, bt_env *pVfs, const char *zFile){\n  BtDb *pBt = (BtDb*)pVfs->pVfsCtx;\n  if( pBt->bCrash ) return SQLITE4_IOERR;\n  return pBt->pVfs->xUnlink(pEnv, pBt->pVfs, zFile);\n}\n\nstatic int btVfsLock(bt_file *pFile, int iLock, int eType){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xLock(p->pFile, iLock, eType);\n}\n\nstatic int btVfsTestLock(bt_file *pFile, int iLock, int nLock, int eType){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xTestLock(p->pFile, iLock, nLock, eType);\n}\n\nstatic int btVfsShmMap(bt_file *pFile, int iChunk, int sz, void **ppOut){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xShmMap(p->pFile, iChunk, sz, ppOut);\n}\n\nstatic void btVfsShmBarrier(bt_file *pFile){\n  BtFile *p = (BtFile*)pFile;\n  return p->pVfs->xShmBarrier(p->pFile);\n}\n\nstatic int btVfsShmUnmap(bt_file *pFile, int bDelete){\n  BtFile *p = (BtFile*)pFile;\n  if( p->pBt && p->pBt->bCrash ) return SQLITE4_IOERR;\n  return p->pVfs->xShmUnmap(p->pFile, bDelete);\n}\n\nstatic int bt_close(TestDb *pTestDb){\n  BtDb *p = (BtDb*)pTestDb;\n  int rc = sqlite4BtClose(p->pBt);\n  free(p->aBuffer);\n  if( p->apFile[0] ) p->apFile[0]->pBt = 0;\n  if( p->apFile[1] ) p->apFile[1]->pBt = 0;\n  bgc_detach(p);\n  testFree(p);\n  return rc;\n}\n\nstatic int btMinTransaction(BtDb *p, int iMin, int *piLevel){\n  int iLevel;\n  int rc = SQLITE4_OK;\n\n  iLevel = sqlite4BtTransactionLevel(p->pBt);\n  if( iLevel<iMin ){ \n    rc = sqlite4BtBegin(p->pBt, iMin); \n    *piLevel = iLevel;\n  }else{\n    *piLevel = -1;\n  }\n\n  return rc;\n}\nstatic int btRestoreTransaction(BtDb *p, int iLevel, int rcin){\n  int rc = rcin;\n  if( iLevel>=0 ){\n    if( rc==SQLITE4_OK ){\n      rc = sqlite4BtCommit(p->pBt, iLevel);\n    }else{\n      sqlite4BtRollback(p->pBt, iLevel);\n    }\n    assert( iLevel==sqlite4BtTransactionLevel(p->pBt) );\n  }\n  return rc;\n}\n\nstatic int bt_write(TestDb *pTestDb, void *pK, int nK, void *pV, int nV){\n  BtDb *p = (BtDb*)pTestDb;\n  int iLevel;\n  int rc;\n\n  rc = btMinTransaction(p, 2, &iLevel);\n  if( rc==SQLITE4_OK ){\n    if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);\n    rc = sqlite4BtReplace(p->pBt, pK, nK, pV, nV);\n    rc = btRestoreTransaction(p, iLevel, rc);\n  }\n  return rc;\n}\n\nstatic int bt_delete(TestDb *pTestDb, void *pK, int nK){\n  return bt_write(pTestDb, pK, nK, 0, -1);\n}\n\nstatic int bt_delete_range(\n  TestDb *pTestDb, \n  void *pKey1, int nKey1,\n  void *pKey2, int nKey2\n){\n  BtDb *p = (BtDb*)pTestDb;\n  bt_cursor *pCsr = 0;\n  int rc = SQLITE4_OK;\n  int iLevel;\n\n  rc = btMinTransaction(p, 2, &iLevel);\n  if( rc==SQLITE4_OK ){\n    if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);\n    rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);\n  }\n  while( rc==SQLITE4_OK ){\n    const void *pK;\n    int n;\n    int nCmp;\n    int res;\n\n    rc = sqlite4BtCsrSeek(pCsr, pKey1, nKey1, BT_SEEK_GE);\n    if( rc==SQLITE4_INEXACT ) rc = SQLITE4_OK;\n    if( rc!=SQLITE4_OK ) break;\n\n    rc = sqlite4BtCsrKey(pCsr, &pK, &n);\n    if( rc!=SQLITE4_OK ) break;\n\n    nCmp = MIN(n, nKey1);\n    res = memcmp(pKey1, pK, nCmp);\n    assert( res<0 || (res==0 && nKey1<=n) );\n    if( res==0 && nKey1==n ){\n      rc = sqlite4BtCsrNext(pCsr);\n      if( rc!=SQLITE4_OK ) break;\n      rc = sqlite4BtCsrKey(pCsr, &pK, &n);\n      if( rc!=SQLITE4_OK ) break;\n    }\n\n    nCmp = MIN(n, nKey2);\n    res = memcmp(pKey2, pK, nCmp);\n    if( res<0 || (res==0 && nKey2<=n) ) break;\n    \n    rc = sqlite4BtDelete(pCsr);\n  }\n  if( rc==SQLITE4_NOTFOUND ) rc = SQLITE4_OK;\n\n  sqlite4BtCsrClose(pCsr);\n\n  rc = btRestoreTransaction(p, iLevel, rc);\n  return rc;\n}\n\nstatic int bt_fetch(\n  TestDb *pTestDb, \n  void *pK, int nK, \n  void **ppVal, int *pnVal\n){\n  BtDb *p = (BtDb*)pTestDb;\n  bt_cursor *pCsr = 0;\n  int iLevel;\n  int rc = SQLITE4_OK;\n\n  iLevel = sqlite4BtTransactionLevel(p->pBt);\n  if( iLevel==0 ){ \n    rc = sqlite4BtBegin(p->pBt, 1); \n    if( rc!=SQLITE4_OK ) return rc;\n  }\n\n  if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);\n  rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);\n  if( rc==SQLITE4_OK ){\n    rc = sqlite4BtCsrSeek(pCsr, pK, nK, BT_SEEK_EQ);\n    if( rc==SQLITE4_OK ){\n      const void *pV = 0;\n      int nV = 0;\n      rc = sqlite4BtCsrData(pCsr, 0, -1, &pV, &nV);\n      if( rc==SQLITE4_OK ){\n        if( nV>p->nBuffer ){\n          free(p->aBuffer);\n          p->aBuffer = (u8*)malloc(nV*2);\n          p->nBuffer = nV*2;\n        }\n        memcpy(p->aBuffer, pV, nV);\n        *pnVal = nV;\n        *ppVal = (void*)(p->aBuffer);\n      }\n\n    }else if( rc==SQLITE4_INEXACT || rc==SQLITE4_NOTFOUND ){\n      *ppVal = 0;\n      *pnVal = -1;\n      rc = SQLITE4_OK;\n    }\n    sqlite4BtCsrClose(pCsr);\n  }\n\n  if( iLevel==0 ) sqlite4BtCommit(p->pBt, 0); \n  return rc;\n}\n\nstatic int bt_scan(\n  TestDb *pTestDb,\n  void *pCtx,\n  int bReverse,\n  void *pFirst, int nFirst,\n  void *pLast, int nLast,\n  void (*xCallback)(void *, void *, int , void *, int)\n){\n  BtDb *p = (BtDb*)pTestDb;\n  bt_cursor *pCsr = 0;\n  int rc;\n  int iLevel;\n\n  rc = btMinTransaction(p, 1, &iLevel);\n\n  if( rc==SQLITE4_OK ){\n    if( p->bFastInsert ) sqlite4BtControl(p->pBt, BT_CONTROL_FAST_INSERT_OP, 0);\n    rc = sqlite4BtCsrOpen(p->pBt, 0, &pCsr);\n  }\n  if( rc==SQLITE4_OK ){\n    if( bReverse ){\n      if( pLast ){\n        rc = sqlite4BtCsrSeek(pCsr, pLast, nLast, BT_SEEK_LE);\n      }else{\n        rc = sqlite4BtCsrLast(pCsr);\n      }\n    }else{\n      rc = sqlite4BtCsrSeek(pCsr, pFirst, nFirst, BT_SEEK_GE);\n    }\n    if( rc==SQLITE4_INEXACT ) rc = SQLITE4_OK;\n\n    while( rc==SQLITE4_OK ){\n      const void *pK = 0; int nK = 0;\n      const void *pV = 0; int nV = 0;\n\n      rc = sqlite4BtCsrKey(pCsr, &pK, &nK);\n      if( rc==SQLITE4_OK ){\n        rc = sqlite4BtCsrData(pCsr, 0, -1, &pV, &nV);\n      }\n\n      if( rc!=SQLITE4_OK ) break;\n      if( bReverse ){\n        if( pFirst ){\n          int res;\n          int nCmp = MIN(nK, nFirst);\n          res = memcmp(pFirst, pK, nCmp);\n          if( res>0 || (res==0 && nK<nFirst) ) break;\n        }\n      }else{\n        if( pLast ){\n          int res;\n          int nCmp = MIN(nK, nLast);\n          res = memcmp(pLast, pK, nCmp);\n          if( res<0 || (res==0 && nK>nLast) ) break;\n        }\n      }\n\n      xCallback(pCtx, (void*)pK, nK, (void*)pV, nV);\n      if( bReverse ){\n        rc = sqlite4BtCsrPrev(pCsr);\n      }else{\n        rc = sqlite4BtCsrNext(pCsr);\n      }\n    }\n    if( rc==SQLITE4_NOTFOUND ) rc = SQLITE4_OK;\n\n    sqlite4BtCsrClose(pCsr);\n  }\n\n  rc = btRestoreTransaction(p, iLevel, rc);\n  return rc;\n}\n\nstatic int bt_begin(TestDb *pTestDb, int iLvl){\n  BtDb *p = (BtDb*)pTestDb;\n  int rc = sqlite4BtBegin(p->pBt, iLvl);\n  return rc;\n}\n\nstatic int bt_commit(TestDb *pTestDb, int iLvl){\n  BtDb *p = (BtDb*)pTestDb;\n  int rc = sqlite4BtCommit(p->pBt, iLvl);\n  return rc;\n}\n\nstatic int bt_rollback(TestDb *pTestDb, int iLvl){\n  BtDb *p = (BtDb*)pTestDb;\n  int rc = sqlite4BtRollback(p->pBt, iLvl);\n  return rc;\n}\n\nstatic int testParseOption(\n  const char **pzIn,              /* IN/OUT: pointer to next option */\n  const char **pzOpt,             /* OUT: nul-terminated option name */\n  const char **pzArg,             /* OUT: nul-terminated option argument */\n  char *pSpace                    /* Temporary space for output params */\n){\n  const char *p = *pzIn;\n  const char *pStart;\n  int n;\n\n  char *pOut = pSpace;\n\n  while( *p==' ' ) p++;\n  pStart = p;\n  while( *p && *p!='=' ) p++;\n  if( *p==0 ) return 1;\n\n  n = (p - pStart);\n  memcpy(pOut, pStart, n);\n  *pzOpt = pOut;\n  pOut += n;\n  *pOut++ = '\\0';\n\n  p++;\n  pStart = p;\n  while( *p && *p!=' ' ) p++;\n  n = (p - pStart);\n\n  memcpy(pOut, pStart, n);\n  *pzArg = pOut;\n  pOut += n;\n  *pOut++ = '\\0';\n\n  *pzIn = p;\n  return 0;\n}\n\nstatic int testParseInt(const char *z, int *piVal){\n  int i = 0;\n  const char *p = z;\n\n  while( *p>='0' && *p<='9' ){\n    i = i*10 + (*p - '0');\n    p++;\n  }\n  if( *p=='K' || *p=='k' ){\n    i = i * 1024;\n    p++;\n  }else if( *p=='M' || *p=='m' ){\n    i = i * 1024 * 1024;\n    p++;\n  }\n\n  if( *p ) return SQLITE4_ERROR;\n  *piVal = i;\n  return SQLITE4_OK;\n}\n\nstatic int testBtConfigure(BtDb *pDb, const char *zCfg, int *pbMt){\n  int rc = SQLITE4_OK;\n\n  if( zCfg ){\n    struct CfgParam {\n      const char *zParam;\n      int eParam;\n    } aParam[] = {\n      { \"safety\",         BT_CONTROL_SAFETY },\n      { \"autockpt\",       BT_CONTROL_AUTOCKPT },\n      { \"multiproc\",      BT_CONTROL_MULTIPROC },\n      { \"blksz\",          BT_CONTROL_BLKSZ },\n      { \"pagesz\",         BT_CONTROL_PAGESZ },\n      { \"mt\",             -1 },\n      { \"fastinsert\",     -2 },\n      { 0, 0 }\n    };\n    const char *z = zCfg;\n    int n = strlen(z);\n    char *aSpace;\n    const char *zOpt;\n    const char *zArg;\n\n    aSpace = (char*)testMalloc(n+2);\n    while( rc==SQLITE4_OK && 0==testParseOption(&z, &zOpt, &zArg, aSpace) ){\n      int i;\n      int iVal;\n      rc = testArgSelect(aParam, \"param\", zOpt, &i);\n      if( rc!=SQLITE4_OK ) break;\n\n      rc = testParseInt(zArg, &iVal);\n      if( rc!=SQLITE4_OK ) break;\n\n      switch( aParam[i].eParam ){\n        case -1:\n          *pbMt = iVal;\n          break;\n        case -2:\n          pDb->bFastInsert = 1;\n          break;\n        default:\n          rc = sqlite4BtControl(pDb->pBt, aParam[i].eParam, (void*)&iVal);\n          break;\n      }\n    }\n    testFree(aSpace);\n  }\n\n  return rc;\n}\n\n\nint test_bt_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n\n  static const DatabaseMethods SqlMethods = {\n    bt_close,\n    bt_write,\n    bt_delete,\n    bt_delete_range,\n    bt_fetch,\n    bt_scan,\n    bt_begin,\n    bt_commit,\n    bt_rollback\n  };\n  BtDb *p = 0;\n  bt_db *pBt = 0;\n  int rc;\n  sqlite4_env *pEnv = sqlite4_env_default();\n\n  if( bClear && zFilename && zFilename[0] ){\n    char *zLog = sqlite3_mprintf(\"%s-wal\", zFilename);\n    unlink(zFilename);\n    unlink(zLog);\n    sqlite3_free(zLog);\n  }\n  \n  rc = sqlite4BtNew(pEnv, 0, &pBt);\n  if( rc==SQLITE4_OK ){\n    int mt = 0;                   /* True for multi-threaded connection */\n\n    p = (BtDb*)testMalloc(sizeof(BtDb));\n    p->base.pMethods = &SqlMethods;\n    p->pBt = pBt;\n    p->pEnv = pEnv;\n    p->nRef = 1;\n\n    p->env.pVfsCtx = (void*)p;\n    p->env.xFullpath = btVfsFullpath;\n    p->env.xOpen = btVfsOpen;\n    p->env.xSize = btVfsSize;\n    p->env.xRead = btVfsRead;\n    p->env.xWrite = btVfsWrite;\n    p->env.xTruncate = btVfsTruncate;\n    p->env.xSync = btVfsSync;\n    p->env.xSectorSize = btVfsSectorSize;\n    p->env.xClose = btVfsClose;\n    p->env.xUnlink = btVfsUnlink;\n    p->env.xLock = btVfsLock;\n    p->env.xTestLock = btVfsTestLock;\n    p->env.xShmMap = btVfsShmMap;\n    p->env.xShmBarrier = btVfsShmBarrier;\n    p->env.xShmUnmap = btVfsShmUnmap;\n\n    sqlite4BtControl(pBt, BT_CONTROL_GETVFS, (void*)&p->pVfs);\n    sqlite4BtControl(pBt, BT_CONTROL_SETVFS, (void*)&p->env);\n\n    rc = testBtConfigure(p, zSpec, &mt);\n    if( rc==SQLITE4_OK ){\n      rc = sqlite4BtOpen(pBt, zFilename);\n    }\n\n    if( rc==SQLITE4_OK && mt ){\n      int nAuto = 0;\n      rc = bgc_attach(p, zSpec);\n      sqlite4BtControl(pBt, BT_CONTROL_AUTOCKPT, (void*)&nAuto);\n    }\n  }\n\n  if( rc!=SQLITE4_OK && p ){\n    bt_close(&p->base);\n  }\n\n  *ppDb = &p->base;\n  return rc;\n}\n\nint test_fbt_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  return test_bt_open(\"fast=1\", zFilename, bClear, ppDb);\n}\n\nint test_fbts_open(\n  const char *zSpec, \n  const char *zFilename, \n  int bClear, \n  TestDb **ppDb\n){\n  return test_bt_open(\"fast=1 blksz=32K pagesz=512\", zFilename, bClear, ppDb);\n}\n\n\nvoid tdb_bt_prepare_sync_crash(TestDb *pTestDb, int iSync){\n  BtDb *p = (BtDb*)pTestDb;\n  assert( pTestDb->pMethods->xClose==bt_close );\n  assert( p->bCrash==0 );\n  p->nCrashSync = iSync;\n}\n\nbt_db *tdb_bt(TestDb *pDb){\n  if( pDb->pMethods->xClose==bt_close ){\n    return ((BtDb *)pDb)->pBt;\n  }\n  return 0;\n}\n\n/*************************************************************************\n** Beginning of code for background checkpointer.\n*/\n\nstruct bt_ckpter {\n  sqlite4_buffer file;            /* File name */\n  sqlite4_buffer spec;            /* Options */\n  int nLogsize;                   /* Minimum log size to checkpoint */\n  int nRef;                       /* Number of clients */\n\n  int bDoWork;                    /* Set by client threads */\n  pthread_t ckpter_thread;        /* Checkpointer thread */\n  pthread_cond_t ckpter_cond;     /* Condition var the ckpter waits on */\n  pthread_mutex_t ckpter_mutex;   /* Mutex used with ckpter_cond */\n\n  bt_ckpter *pNext;               /* Next object in list at gBgc.pCkpter */\n};\n\nstatic struct GlobalBackgroundCheckpointer {\n  bt_ckpter *pCkpter;             /* Linked list of checkpointers */\n} gBgc;\n\nstatic void *bgc_main(void *pArg){\n  BtDb *pDb = 0;\n  int rc;\n  int mt;\n  bt_ckpter *pCkpter = (bt_ckpter*)pArg;\n\n  rc = test_bt_open(\"\", (char*)pCkpter->file.p, 0, (TestDb**)&pDb);\n  assert( rc==SQLITE4_OK );\n  rc = testBtConfigure(pDb, (char*)pCkpter->spec.p, &mt);\n\n  while( pCkpter->nRef>0 ){\n    bt_db *db = pDb->pBt;\n    int nLog = 0;\n\n    sqlite4BtBegin(db, 1);\n    sqlite4BtCommit(db, 0);\n    sqlite4BtControl(db, BT_CONTROL_LOGSIZE, (void*)&nLog);\n\n    if( nLog>=pCkpter->nLogsize ){\n      int rc;\n      bt_checkpoint ckpt;\n      memset(&ckpt, 0, sizeof(bt_checkpoint));\n      ckpt.nFrameBuffer = nLog/2;\n      rc = sqlite4BtControl(db, BT_CONTROL_CHECKPOINT, (void*)&ckpt);\n      assert( rc==SQLITE4_OK );\n      sqlite4BtControl(db, BT_CONTROL_LOGSIZE, (void*)&nLog);\n    }\n\n    /* The thread will wake up when it is signaled either because another\n    ** thread has created some work for this one or because the connection\n    ** is being closed.  */\n    pthread_mutex_lock(&pCkpter->ckpter_mutex);\n    if( pCkpter->bDoWork==0 ){\n      pthread_cond_wait(&pCkpter->ckpter_cond, &pCkpter->ckpter_mutex);\n    }\n    pCkpter->bDoWork = 0;\n    pthread_mutex_unlock(&pCkpter->ckpter_mutex);\n  }\n\n  if( pDb ) bt_close((TestDb*)pDb);\n  return 0;\n}\n\nstatic void bgc_logsize_cb(void *pCtx, int nLogsize){\n  bt_ckpter *p = (bt_ckpter*)pCtx;\n  if( nLogsize>=p->nLogsize ){\n    pthread_mutex_lock(&p->ckpter_mutex);\n    p->bDoWork = 1;\n    pthread_cond_signal(&p->ckpter_cond);\n    pthread_mutex_unlock(&p->ckpter_mutex);\n  }\n}\n\nstatic int bgc_attach(BtDb *pDb, const char *zSpec){\n  int rc;\n  int n;\n  bt_info info;\n  bt_ckpter *pCkpter;\n\n  /* Figure out the full path to the database opened by handle pDb. */\n  info.eType = BT_INFO_FILENAME;\n  info.pgno = 0;\n  sqlite4_buffer_init(&info.output, 0);\n  rc = sqlite4BtControl(pDb->pBt, BT_CONTROL_INFO, (void*)&info);\n  if( rc!=SQLITE4_OK ) return rc;\n\n  sqlite4_mutex_enter(sqlite4_mutex_alloc(pDb->pEnv, SQLITE4_MUTEX_STATIC_KV));\n\n  /* Search for an existing bt_ckpter object. */\n  n = info.output.n;\n  for(pCkpter=gBgc.pCkpter; pCkpter; pCkpter=pCkpter->pNext){\n    if( n==pCkpter->file.n && 0==memcmp(info.output.p, pCkpter->file.p, n) ){\n      break;\n    }\n  }\n\n  /* Failed to find a suitable checkpointer. Create a new one. */\n  if( pCkpter==0 ){\n    bt_logsizecb cb;\n\n    pCkpter = testMalloc(sizeof(bt_ckpter));\n    memcpy(&pCkpter->file, &info.output, sizeof(sqlite4_buffer));\n    info.output.p = 0;\n    pCkpter->pNext = gBgc.pCkpter;\n    pCkpter->nLogsize = 1000;\n    gBgc.pCkpter = pCkpter;\n    pCkpter->nRef = 1;\n\n    sqlite4_buffer_init(&pCkpter->spec, 0);\n    rc = sqlite4_buffer_set(&pCkpter->spec, zSpec, strlen(zSpec)+1);\n    assert( rc==SQLITE4_OK );\n\n    /* Kick off the checkpointer thread. */\n    if( rc==0 ) rc = pthread_cond_init(&pCkpter->ckpter_cond, 0);\n    if( rc==0 ) rc = pthread_mutex_init(&pCkpter->ckpter_mutex, 0);\n    if( rc==0 ){\n      rc = pthread_create(&pCkpter->ckpter_thread, 0, bgc_main, (void*)pCkpter);\n    }\n    assert( rc==0 ); /* todo: Fix this */\n\n    /* Set up the logsize callback for the client thread */\n    cb.pCtx = (void*)pCkpter;\n    cb.xLogsize = bgc_logsize_cb;\n    sqlite4BtControl(pDb->pBt, BT_CONTROL_LOGSIZECB, (void*)&cb);\n  }else{\n    pCkpter->nRef++;\n  }\n\n  /* Assuming a checkpointer was encountered or effected, attach the \n  ** connection to it.  */\n  if( pCkpter ){\n    pDb->pCkpter = pCkpter;\n  }\n\n  sqlite4_mutex_leave(sqlite4_mutex_alloc(pDb->pEnv, SQLITE4_MUTEX_STATIC_KV));\n  sqlite4_buffer_clear(&info.output);\n  return rc;\n}\n\nstatic int bgc_detach(BtDb *pDb){\n  int rc = SQLITE4_OK;\n  bt_ckpter *pCkpter = pDb->pCkpter;\n  if( pCkpter ){\n    int bShutdown = 0;            /* True if this is the last reference */\n\n    sqlite4_mutex_enter(sqlite4_mutex_alloc(pDb->pEnv,SQLITE4_MUTEX_STATIC_KV));\n    pCkpter->nRef--;\n    if( pCkpter->nRef==0 ){\n      bt_ckpter **pp;\n\n      *pp = pCkpter->pNext;\n      for(pp=&gBgc.pCkpter; *pp!=pCkpter; pp=&((*pp)->pNext));\n      bShutdown = 1;\n    }\n    sqlite4_mutex_leave(sqlite4_mutex_alloc(pDb->pEnv,SQLITE4_MUTEX_STATIC_KV));\n\n    if( bShutdown ){\n      void *pDummy;\n\n      /* Signal the checkpointer thread. */\n      pthread_mutex_lock(&pCkpter->ckpter_mutex);\n      pCkpter->bDoWork = 1;\n      pthread_cond_signal(&pCkpter->ckpter_cond);\n      pthread_mutex_unlock(&pCkpter->ckpter_mutex);\n\n      /* Join the checkpointer thread. */\n      pthread_join(pCkpter->ckpter_thread, &pDummy);\n      pthread_cond_destroy(&pCkpter->ckpter_cond);\n      pthread_mutex_destroy(&pCkpter->ckpter_mutex);\n\n      sqlite4_buffer_clear(&pCkpter->file);\n      sqlite4_buffer_clear(&pCkpter->spec);\n      testFree(pCkpter);\n    }\n\n    pDb->pCkpter = 0;\n  }\n  return rc;\n}\n\n/*\n** End of background checkpointer.\n*************************************************************************/\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_util.c",
    "content": "\n#include \"lsmtest.h\"\n#include <stdarg.h>\n#include <stdio.h>\n#include <string.h>\n#ifndef _WIN32\n# include <sys/time.h>\n#endif\n\n/*\n** Global variables used within this module.\n*/\nstatic struct TestutilGlobal {\n  char **argv;\n  int argc;\n} g = {0, 0};\n\nstatic struct TestutilRnd {\n  unsigned int aRand1[2048];          /* Bits 0..10 */\n  unsigned int aRand2[2048];          /* Bits 11..21 */\n  unsigned int aRand3[1024];          /* Bits 22..31 */\n} r;\n\n/*************************************************************************\n** The following block is a copy of the implementation of SQLite function\n** sqlite3_randomness. This version has two important differences:\n**\n**   1. It always uses the same seed. So the sequence of random data output\n**      is the same for every run of the program.\n**\n**   2. It is not threadsafe.\n*/\nstatic struct sqlite3PrngType {\n  unsigned char i, j;             /* State variables */\n  unsigned char s[256];           /* State variables */\n} sqlite3Prng = {\n    0xAF, 0x28,\n  {\n    0x71, 0xF5, 0xB4, 0x6E, 0x80, 0xAB, 0x1D, 0xB8, \n    0xFB, 0xB7, 0x49, 0xBF, 0xFF, 0x72, 0x2D, 0x14, \n    0x79, 0x09, 0xE3, 0x78, 0x76, 0xB0, 0x2C, 0x0A, \n    0x8E, 0x23, 0xEE, 0xDF, 0xE0, 0x9A, 0x2F, 0x67, \n    0xE1, 0xBE, 0x0E, 0xA7, 0x08, 0x97, 0xEB, 0x77, \n    0x78, 0xBA, 0x9D, 0xCA, 0x49, 0x4C, 0x60, 0x9A, \n    0xF6, 0xBD, 0xDA, 0x7F, 0xBC, 0x48, 0x58, 0x52, \n    0xE5, 0xCD, 0x83, 0x72, 0x23, 0x52, 0xFF, 0x6D, \n    0xEF, 0x0F, 0x82, 0x29, 0xA0, 0x83, 0x3F, 0x7D, \n    0xA4, 0x88, 0x31, 0xE7, 0x88, 0x92, 0x3B, 0x9B, \n    0x3B, 0x2C, 0xC2, 0x4C, 0x71, 0xA2, 0xB0, 0xEA, \n    0x36, 0xD0, 0x00, 0xF1, 0xD3, 0x39, 0x17, 0x5D, \n    0x2A, 0x7A, 0xE4, 0xAD, 0xE1, 0x64, 0xCE, 0x0F, \n    0x9C, 0xD9, 0xF5, 0xED, 0xB0, 0x22, 0x5E, 0x62, \n    0x97, 0x02, 0xA3, 0x8C, 0x67, 0x80, 0xFC, 0x88, \n    0x14, 0x0B, 0x15, 0x10, 0x0F, 0xC7, 0x40, 0xD4, \n    0xF1, 0xF9, 0x0E, 0x1A, 0xCE, 0xB9, 0x1E, 0xA1, \n    0x72, 0x8E, 0xD7, 0x78, 0x39, 0xCD, 0xF4, 0x5D, \n    0x2A, 0x59, 0x26, 0x34, 0xF2, 0x73, 0x0B, 0xA0, \n    0x02, 0x51, 0x2C, 0x03, 0xA3, 0xA7, 0x43, 0x13, \n    0xE8, 0x98, 0x2B, 0xD2, 0x53, 0xF8, 0xEE, 0x91, \n    0x7D, 0xE7, 0xE3, 0xDA, 0xD5, 0xBB, 0xC0, 0x92, \n    0x9D, 0x98, 0x01, 0x2C, 0xF9, 0xB9, 0xA0, 0xEB, \n    0xCF, 0x32, 0xFA, 0x01, 0x49, 0xA5, 0x1D, 0x9A, \n    0x76, 0x86, 0x3F, 0x40, 0xD4, 0x89, 0x8F, 0x9C, \n    0xE2, 0xE3, 0x11, 0x31, 0x37, 0xB2, 0x49, 0x28, \n    0x35, 0xC0, 0x99, 0xB6, 0xD0, 0xBC, 0x66, 0x35, \n    0xF7, 0x83, 0x5B, 0xD7, 0x37, 0x1A, 0x2B, 0x18, \n    0xA6, 0xFF, 0x8D, 0x7C, 0x81, 0xA8, 0xFC, 0x9E, \n    0xC4, 0xEC, 0x80, 0xD0, 0x98, 0xA7, 0x76, 0xCC, \n    0x9C, 0x2F, 0x7B, 0xFF, 0x8E, 0x0E, 0xBB, 0x90, \n    0xAE, 0x13, 0x06, 0xF5, 0x1C, 0x4E, 0x52, 0xF7\n  }\n};\n\n/* Generate and return single random byte */\nstatic unsigned char randomByte(void){\n  unsigned char t;\n  sqlite3Prng.i++;\n  t = sqlite3Prng.s[sqlite3Prng.i];\n  sqlite3Prng.j += t;\n  sqlite3Prng.s[sqlite3Prng.i] = sqlite3Prng.s[sqlite3Prng.j];\n  sqlite3Prng.s[sqlite3Prng.j] = t;\n  t += sqlite3Prng.s[sqlite3Prng.i];\n  return sqlite3Prng.s[t];\n}\n\n/*\n** Return N random bytes.\n*/\nstatic void randomBlob(int nBuf, unsigned char *zBuf){\n  int i;\n  for(i=0; i<nBuf; i++){\n    zBuf[i] = randomByte();\n  }\n}\n/*\n** End of code copied from SQLite.\n*************************************************************************/\n\n\nint testPrngInit(void){\n  randomBlob(sizeof(r.aRand1), (unsigned char *)r.aRand1);\n  randomBlob(sizeof(r.aRand2), (unsigned char *)r.aRand2);\n  randomBlob(sizeof(r.aRand3), (unsigned char *)r.aRand3);\n  return 0;\n}\n\nunsigned int testPrngValue(unsigned int iVal){\n  return\n    r.aRand1[iVal & 0x000007FF] ^\n    r.aRand2[(iVal>>11) & 0x000007FF] ^\n    r.aRand3[(iVal>>22) & 0x000003FF]\n  ;\n}\n\nvoid testPrngArray(unsigned int iVal, unsigned int *aOut, int nOut){\n  int i;\n  for(i=0; i<nOut; i++){\n    aOut[i] = testPrngValue(iVal+i);\n  }\n}\n\nvoid testPrngString(unsigned int iVal, char *aOut, int nOut){\n  int i;\n  for(i=0; i<(nOut-1); i++){\n    aOut[i] = 'a' + (testPrngValue(iVal+i) % 26);\n  }\n  aOut[i] = '\\0';\n}\n\nvoid testErrorInit(int argc, char **argv){\n  g.argc = argc;\n  g.argv = argv;\n}\n\nvoid testPrintError(const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  vfprintf(stderr, zFormat, ap);\n  va_end(ap);\n}\n\nvoid testPrintFUsage(const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  fprintf(stderr, \"Usage: %s %s \", g.argv[0], g.argv[1]);\n  vfprintf(stderr, zFormat, ap);\n  fprintf(stderr, \"\\n\");\n  va_end(ap);\n}\n\nvoid testPrintUsage(const char *zArgs){\n  testPrintError(\"Usage: %s %s %s\\n\", g.argv[0], g.argv[1], zArgs);\n}\n\n\nstatic void argError(void *aData, const char *zType, int sz, const char *zArg){\n  struct Entry { const char *zName; };\n  struct Entry *pEntry;\n  const char *zPrev = 0;\n\n  testPrintError(\"unrecognized %s \\\"%s\\\": must be \", zType, zArg);\n  for(pEntry=(struct Entry *)aData; \n      pEntry->zName; \n      pEntry=(struct Entry *)&((unsigned char *)pEntry)[sz]\n  ){\n    if( zPrev ){ testPrintError(\"%s, \", zPrev); }\n    zPrev = pEntry->zName;\n  }\n  testPrintError(\"or %s\\n\", zPrev);\n}\n\nint testArgSelectX(\n  void *aData, \n  const char *zType, \n  int sz, \n  const char *zArg, \n  int *piOut\n){\n  struct Entry { const char *zName; };\n  struct Entry *pEntry;\n  int nArg = strlen(zArg);\n\n  int i = 0;\n  int iOut = -1;\n  int nOut = 0;\n\n  for(pEntry=(struct Entry *)aData; \n      pEntry->zName; \n      pEntry=(struct Entry *)&((unsigned char *)pEntry)[sz]\n  ){\n    int nName = strlen(pEntry->zName);\n    if( nArg<=nName && memcmp(pEntry->zName, zArg, nArg)==0 ){\n      iOut = i;\n      if( nName==nArg ){\n        nOut = 1;\n        break;\n      }\n      nOut++;\n    }\n    i++;\n  }\n\n  if( nOut!=1 ){\n    argError(aData, zType, sz, zArg);\n  }else{\n    *piOut = iOut;\n  }\n  return (nOut!=1);\n}\n\nstruct timeval zero_time;\n\nvoid testTimeInit(void){\n  gettimeofday(&zero_time, 0);\n}\n\nint testTimeGet(void){\n  struct timeval now;\n  gettimeofday(&now, 0);\n  return\n    (((int)now.tv_sec - (int)zero_time.tv_sec)*1000) +\n    (((int)now.tv_usec - (int)zero_time.tv_usec)/1000);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm-test/lsmtest_win32.c",
    "content": "\n#include \"lsmtest.h\"\n\n#ifdef _WIN32\n\n#define TICKS_PER_SECOND      (10000000)\n#define TICKS_PER_MICROSECOND (10)\n#define TICKS_UNIX_EPOCH      (116444736000000000LL)\n\nint win32GetTimeOfDay(\n  struct timeval *tp,\n  void *tzp\n){\n  FILETIME fileTime;\n  ULONGLONG ticks;\n  ULONGLONG unixTicks;\n\n  unused_parameter(tzp);\n  memset(&fileTime, 0, sizeof(FILETIME));\n  GetSystemTimeAsFileTime(&fileTime);\n  ticks = (ULONGLONG)fileTime.dwHighDateTime << 32;\n  ticks |= (ULONGLONG)fileTime.dwLowDateTime;\n  unixTicks = ticks - TICKS_UNIX_EPOCH;\n  tp->tv_sec = (long)(unixTicks / TICKS_PER_SECOND);\n  unixTicks -= ((ULONGLONG)tp->tv_sec * TICKS_PER_SECOND);\n  tp->tv_usec = (long)(unixTicks / TICKS_PER_MICROSECOND);\n\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm.h",
    "content": "/*\n** 2011-08-10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file defines the LSM API.\n*/\n#ifndef _LSM_H\n#define _LSM_H\n#include <stddef.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Opaque handle types.\n*/\ntypedef struct lsm_compress lsm_compress;   /* Compression library functions */\ntypedef struct lsm_compress_factory lsm_compress_factory;\ntypedef struct lsm_cursor lsm_cursor;       /* Database cursor handle */\ntypedef struct lsm_db lsm_db;               /* Database connection handle */\ntypedef struct lsm_env lsm_env;             /* Runtime environment */\ntypedef struct lsm_file lsm_file;           /* OS file handle */\ntypedef struct lsm_mutex lsm_mutex;         /* Mutex handle */\n\n/* 64-bit integer type used for file offsets. */\ntypedef long long int lsm_i64;              /* 64-bit signed integer type */\n\n/* Candidate values for the 3rd argument to lsm_env.xLock() */\n#define LSM_LOCK_UNLOCK 0\n#define LSM_LOCK_SHARED 1\n#define LSM_LOCK_EXCL   2\n\n/* Flags for lsm_env.xOpen() */\n#define LSM_OPEN_READONLY 0x0001\n\n/*\n** CAPI: Database Runtime Environment\n**\n** Run-time environment used by LSM\n*/\nstruct lsm_env {\n  int nByte;                 /* Size of this structure in bytes */\n  int iVersion;              /* Version number of this structure (1) */\n  /****** file i/o ***********************************************/\n  void *pVfsCtx;\n  int (*xFullpath)(lsm_env*, const char *, char *, int *);\n  int (*xOpen)(lsm_env*, const char *, int flags, lsm_file **);\n  int (*xRead)(lsm_file *, lsm_i64, void *, int);\n  int (*xWrite)(lsm_file *, lsm_i64, void *, int);\n  int (*xTruncate)(lsm_file *, lsm_i64);\n  int (*xSync)(lsm_file *);\n  int (*xSectorSize)(lsm_file *);\n  int (*xRemap)(lsm_file *, lsm_i64, void **, lsm_i64*);\n  int (*xFileid)(lsm_file *, void *pBuf, int *pnBuf);\n  int (*xClose)(lsm_file *);\n  int (*xUnlink)(lsm_env*, const char *);\n  int (*xLock)(lsm_file*, int, int);\n  int (*xTestLock)(lsm_file*, int, int, int);\n  int (*xShmMap)(lsm_file*, int, int, void **);\n  void (*xShmBarrier)(void);\n  int (*xShmUnmap)(lsm_file*, int);\n  /****** memory allocation ****************************************/\n  void *pMemCtx;\n  void *(*xMalloc)(lsm_env*, size_t);            /* malloc(3) function */\n  void *(*xRealloc)(lsm_env*, void *, size_t);   /* realloc(3) function */\n  void (*xFree)(lsm_env*, void *);               /* free(3) function */\n  size_t (*xSize)(lsm_env*, void *);             /* xSize function */\n  /****** mutexes ****************************************************/\n  void *pMutexCtx;\n  int (*xMutexStatic)(lsm_env*,int,lsm_mutex**); /* Obtain a static mutex */\n  int (*xMutexNew)(lsm_env*, lsm_mutex**);       /* Get a new dynamic mutex */\n  void (*xMutexDel)(lsm_mutex *);           /* Delete an allocated mutex */\n  void (*xMutexEnter)(lsm_mutex *);         /* Grab a mutex */\n  int (*xMutexTry)(lsm_mutex *);            /* Attempt to obtain a mutex */\n  void (*xMutexLeave)(lsm_mutex *);         /* Leave a mutex */\n  int (*xMutexHeld)(lsm_mutex *);           /* Return true if mutex is held */\n  int (*xMutexNotHeld)(lsm_mutex *);        /* Return true if mutex not held */\n  /****** other ****************************************************/\n  int (*xSleep)(lsm_env*, int microseconds);\n\n  /* New fields may be added in future releases, in which case the\n  ** iVersion value will increase. */\n};\n\n/* \n** Values that may be passed as the second argument to xMutexStatic. \n*/\n#define LSM_MUTEX_GLOBAL 1\n#define LSM_MUTEX_HEAP   2\n\n/*\n** CAPI: LSM Error Codes\n*/\n#define LSM_OK         0\n#define LSM_ERROR      1\n#define LSM_BUSY       5\n#define LSM_NOMEM      7\n#define LSM_READONLY   8\n#define LSM_IOERR     10\n#define LSM_CORRUPT   11\n#define LSM_FULL      13\n#define LSM_CANTOPEN  14\n#define LSM_PROTOCOL  15\n#define LSM_MISUSE    21\n\n#define LSM_MISMATCH  50\n\n\n#define LSM_IOERR_NOENT (LSM_IOERR | (1<<8))\n\n/* \n** CAPI: Creating and Destroying Database Connection Handles\n**\n** Open and close a database connection handle.\n*/\nint lsm_new(lsm_env*, lsm_db **ppDb);\nint lsm_close(lsm_db *pDb);\n\n/* \n** CAPI: Connecting to a Database\n*/\nint lsm_open(lsm_db *pDb, const char *zFilename);\n\n/*\n** CAPI: Obtaining pointers to database environments\n**\n** Return a pointer to the environment used by the database connection \n** passed as the first argument. Assuming the argument is valid, this \n** function always returns a valid environment pointer - it cannot fail.\n*/\nlsm_env *lsm_get_env(lsm_db *pDb);\n\n/*\n** The lsm_default_env() function returns a pointer to the default LSM\n** environment for the current platform.\n*/\nlsm_env *lsm_default_env(void);\n\n\n/*\n** CAPI: Configuring a database connection.\n**\n** The lsm_config() function is used to configure a database connection.\n*/\nint lsm_config(lsm_db *, int, ...);\n\n/*\n** The following values may be passed as the second argument to lsm_config().\n**\n** LSM_CONFIG_AUTOFLUSH:\n**   A read/write integer parameter. \n**\n**   This value determines the amount of data allowed to accumulate in a\n**   live in-memory tree before it is marked as old. After committing a\n**   transaction, a connection checks if the size of the live in-memory tree,\n**   including data structure overhead, is greater than the value of this\n**   option in KB. If it is, and there is not already an old in-memory tree,\n**   the live in-memory tree is marked as old.\n**\n**   The maximum allowable value is 1048576 (1GB). There is no minimum \n**   value. If this parameter is set to zero, then an attempt is made to\n**   mark the live in-memory tree as old after each transaction is committed.\n**\n**   The default value is 1024 (1MB).\n**\n** LSM_CONFIG_PAGE_SIZE:\n**   A read/write integer parameter. This parameter may only be set before\n**   lsm_open() has been called.\n**\n** LSM_CONFIG_BLOCK_SIZE:\n**   A read/write integer parameter. \n**\n**   This parameter may only be set before lsm_open() has been called. It\n**   must be set to a power of two between 64 and 65536, inclusive (block \n**   sizes between 64KB and 64MB).\n**\n**   If the connection creates a new database, the block size of the new\n**   database is set to the value of this option in KB. After lsm_open()\n**   has been called, querying this parameter returns the actual block\n**   size of the opened database.\n**\n**   The default value is 1024 (1MB blocks).\n**\n** LSM_CONFIG_SAFETY:\n**   A read/write integer parameter. Valid values are 0, 1 (the default) \n**   and 2. This parameter determines how robust the database is in the\n**   face of a system crash (e.g. a power failure or operating system \n**   crash). As follows:\n**\n**     0 (off):    No robustness. A system crash may corrupt the database.\n**\n**     1 (normal): Some robustness. A system crash may not corrupt the\n**                 database file, but recently committed transactions may\n**                 be lost following recovery.\n**\n**     2 (full):   Full robustness. A system crash may not corrupt the\n**                 database file. Following recovery the database file\n**                 contains all successfully committed transactions.\n**\n** LSM_CONFIG_AUTOWORK:\n**   A read/write integer parameter.\n**\n** LSM_CONFIG_AUTOCHECKPOINT:\n**   A read/write integer parameter.\n**\n**   If this option is set to non-zero value N, then a checkpoint is\n**   automatically attempted after each N KB of data have been written to \n**   the database file.\n**\n**   The amount of uncheckpointed data already written to the database file\n**   is a global parameter. After performing database work (writing to the\n**   database file), the process checks if the total amount of uncheckpointed \n**   data exceeds the value of this paramter. If so, a checkpoint is performed.\n**   This means that this option may cause the connection to perform a \n**   checkpoint even if the current connection has itself written very little\n**   data into the database file.\n**\n**   The default value is 2048 (checkpoint every 2MB).\n**\n** LSM_CONFIG_MMAP:\n**   A read/write integer parameter. If this value is set to 0, then the \n**   database file is accessed using ordinary read/write IO functions. Or,\n**   if it is set to 1, then the database file is memory mapped and accessed\n**   that way. If this parameter is set to any value N greater than 1, then\n**   up to the first N KB of the file are memory mapped, and any remainder\n**   accessed using read/write IO.\n**\n**   The default value is 1 on 64-bit platforms and 32768 on 32-bit platforms.\n**   \n**\n** LSM_CONFIG_USE_LOG:\n**   A read/write boolean parameter. True (the default) to use the log\n**   file normally. False otherwise.\n**\n** LSM_CONFIG_AUTOMERGE:\n**   A read/write integer parameter. The minimum number of segments to\n**   merge together at a time. Default value 4.\n**\n** LSM_CONFIG_MAX_FREELIST:\n**   A read/write integer parameter. The maximum number of free-list \n**   entries that are stored in a database checkpoint (the others are\n**   stored elsewhere in the database).\n**\n**   There is no reason for an application to configure or query this\n**   parameter. It is only present because configuring a small value\n**   makes certain parts of the lsm code easier to test.\n**\n** LSM_CONFIG_MULTIPLE_PROCESSES:\n**   A read/write boolean parameter. This parameter may only be set before\n**   lsm_open() has been called. If true, the library uses shared-memory\n**   and posix advisory locks to co-ordinate access by clients from within\n**   multiple processes. Otherwise, if false, all database clients must be \n**   located in the same process. The default value is true.\n**\n** LSM_CONFIG_SET_COMPRESSION:\n**   Set the compression methods used to compress and decompress database\n**   content. The argument to this option should be a pointer to a structure\n**   of type lsm_compress. The lsm_config() method takes a copy of the \n**   structures contents.\n**\n**   This option may only be used before lsm_open() is called. Invoking it\n**   after lsm_open() has been called results in an LSM_MISUSE error.\n**\n** LSM_CONFIG_GET_COMPRESSION:\n**   Query the compression methods used to compress and decompress database\n**   content.\n**\n** LSM_CONFIG_SET_COMPRESSION_FACTORY:\n**   Configure a factory method to be invoked in case of an LSM_MISMATCH\n**   error.\n**\n** LSM_CONFIG_READONLY:\n**   A read/write boolean parameter. This parameter may only be set before\n**   lsm_open() is called.\n*/\n#define LSM_CONFIG_AUTOFLUSH                1\n#define LSM_CONFIG_PAGE_SIZE                2\n#define LSM_CONFIG_SAFETY                   3\n#define LSM_CONFIG_BLOCK_SIZE               4\n#define LSM_CONFIG_AUTOWORK                 5\n#define LSM_CONFIG_MMAP                     7\n#define LSM_CONFIG_USE_LOG                  8\n#define LSM_CONFIG_AUTOMERGE                9\n#define LSM_CONFIG_MAX_FREELIST            10\n#define LSM_CONFIG_MULTIPLE_PROCESSES      11\n#define LSM_CONFIG_AUTOCHECKPOINT          12\n#define LSM_CONFIG_SET_COMPRESSION         13\n#define LSM_CONFIG_GET_COMPRESSION         14\n#define LSM_CONFIG_SET_COMPRESSION_FACTORY 15\n#define LSM_CONFIG_READONLY                16\n\n#define LSM_SAFETY_OFF    0\n#define LSM_SAFETY_NORMAL 1\n#define LSM_SAFETY_FULL   2\n\n/*\n** CAPI: Compression and/or Encryption Hooks\n*/\nstruct lsm_compress {\n  void *pCtx;\n  unsigned int iId;\n  int (*xBound)(void *, int nSrc);\n  int (*xCompress)(void *, char *, int *, const char *, int);\n  int (*xUncompress)(void *, char *, int *, const char *, int);\n  void (*xFree)(void *pCtx);\n};\n\nstruct lsm_compress_factory {\n  void *pCtx;\n  int (*xFactory)(void *, lsm_db *, unsigned int);\n  void (*xFree)(void *pCtx);\n};\n\n#define LSM_COMPRESSION_EMPTY 0\n#define LSM_COMPRESSION_NONE  1\n\n/*\n** CAPI: Allocating and Freeing Memory\n**\n** Invoke the memory allocation functions that belong to environment\n** pEnv. Or the system defaults if no memory allocation functions have \n** been registered.\n*/\nvoid *lsm_malloc(lsm_env*, size_t);\nvoid *lsm_realloc(lsm_env*, void *, size_t);\nvoid lsm_free(lsm_env*, void *);\n\n/*\n** CAPI: Querying a Connection For Operational Data\n**\n** Query a database connection for operational statistics or data.\n*/\nint lsm_info(lsm_db *, int, ...);\n\nint lsm_get_user_version(lsm_db *, unsigned int *);\nint lsm_set_user_version(lsm_db *, unsigned int);\n\n/*\n** The following values may be passed as the second argument to lsm_info().\n**\n** LSM_INFO_NWRITE:\n**   The third parameter should be of type (int *). The location pointed\n**   to by the third parameter is set to the number of 4KB pages written to\n**   the database file during the lifetime of this connection. \n**\n** LSM_INFO_NREAD:\n**   The third parameter should be of type (int *). The location pointed\n**   to by the third parameter is set to the number of 4KB pages read from\n**   the database file during the lifetime of this connection.\n**\n** LSM_INFO_DB_STRUCTURE:\n**   The third argument should be of type (char **). The location pointed\n**   to is populated with a pointer to a nul-terminated string containing\n**   the string representation of a Tcl data-structure reflecting the \n**   current structure of the database file. Specifically, the current state\n**   of the worker snapshot. The returned string should be eventually freed \n**   by the caller using lsm_free().\n**\n**   The returned list contains one element for each level in the database,\n**   in order from most to least recent. Each element contains a \n**   single element for each segment comprising the corresponding level,\n**   starting with the lhs segment, then each of the rhs segments (if any)\n**   in order from most to least recent.\n**\n**   Each segment element is itself a list of 4 integer values, as follows:\n**\n**   <ol><li> First page of segment\n**       <li> Last page of segment\n**       <li> Root page of segment (if applicable)\n**       <li> Total number of pages in segment\n**   </ol>\n**\n** LSM_INFO_ARRAY_STRUCTURE:\n**   There should be two arguments passed following this option (i.e. a \n**   total of four arguments passed to lsm_info()). The first argument \n**   should be the page number of the first page in a database array \n**   (perhaps obtained from an earlier INFO_DB_STRUCTURE call). The second \n**   trailing argument should be of type (char **). The location pointed \n**   to is populated with a pointer to a nul-terminated string that must \n**   be eventually freed using lsm_free() by the caller.\n**\n**   The output string contains the text representation of a Tcl list of\n**   integers. Each pair of integers represent a range of pages used by\n**   the identified array. For example, if the array occupies database\n**   pages 993 to 1024, then pages 2048 to 2777, then the returned string\n**   will be \"993 1024 2048 2777\".\n**\n**   If the specified integer argument does not correspond to the first\n**   page of any database array, LSM_ERROR is returned and the output\n**   pointer is set to a NULL value.\n**\n** LSM_INFO_LOG_STRUCTURE:\n**   The third argument should be of type (char **). The location pointed\n**   to is populated with a pointer to a nul-terminated string containing\n**   the string representation of a Tcl data-structure. The returned \n**   string should be eventually freed by the caller using lsm_free().\n**\n**   The Tcl structure returned is a list of six integers that describe\n**   the current structure of the log file.\n**\n** LSM_INFO_ARRAY_PAGES:\n**\n** LSM_INFO_PAGE_ASCII_DUMP:\n**   As with LSM_INFO_ARRAY_STRUCTURE, there should be two arguments passed\n**   with calls that specify this option - an integer page number and a\n**   (char **) used to return a nul-terminated string that must be later\n**   freed using lsm_free(). In this case the output string is populated\n**   with a human-readable description of the page content.\n**\n**   If the page cannot be decoded, it is not an error. In this case the\n**   human-readable output message will report the systems failure to \n**   interpret the page data.\n**\n** LSM_INFO_PAGE_HEX_DUMP:\n**   This argument is similar to PAGE_ASCII_DUMP, except that keys and\n**   values are represented using hexadecimal notation instead of ascii.\n**\n** LSM_INFO_FREELIST:\n**   The third argument should be of type (char **). The location pointed\n**   to is populated with a pointer to a nul-terminated string containing\n**   the string representation of a Tcl data-structure. The returned \n**   string should be eventually freed by the caller using lsm_free().\n**\n**   The Tcl structure returned is a list containing one element for each\n**   free block in the database. The element itself consists of two \n**   integers - the block number and the id of the snapshot that freed it.\n**\n** LSM_INFO_CHECKPOINT_SIZE:\n**   The third argument should be of type (int *). The location pointed to\n**   by this argument is populated with the number of KB written to the\n**   database file since the most recent checkpoint.\n**\n** LSM_INFO_TREE_SIZE:\n**   If this value is passed as the second argument to an lsm_info() call, it\n**   should be followed by two arguments of type (int *) (for a total of four\n**   arguments).\n**\n**   At any time, there are either one or two tree structures held in shared\n**   memory that new database clients will access (there may also be additional\n**   tree structures being used by older clients - this API does not provide\n**   information on them). One tree structure - the current tree - is used to\n**   accumulate new data written to the database. The other tree structure -\n**   the old tree - is a read-only tree holding older data and may be flushed \n**   to disk at any time.\n** \n**   Assuming no error occurs, the location pointed to by the first of the two\n**   (int *) arguments is set to the size of the old in-memory tree in KB.\n**   The second is set to the size of the current, or live in-memory tree.\n**\n** LSM_INFO_COMPRESSION_ID:\n**   This value should be followed by a single argument of type \n**   (unsigned int *). If successful, the location pointed to is populated \n**   with the database compression id before returning.\n*/\n#define LSM_INFO_NWRITE           1\n#define LSM_INFO_NREAD            2\n#define LSM_INFO_DB_STRUCTURE     3\n#define LSM_INFO_LOG_STRUCTURE    4\n#define LSM_INFO_ARRAY_STRUCTURE  5\n#define LSM_INFO_PAGE_ASCII_DUMP  6\n#define LSM_INFO_PAGE_HEX_DUMP    7\n#define LSM_INFO_FREELIST         8\n#define LSM_INFO_ARRAY_PAGES      9\n#define LSM_INFO_CHECKPOINT_SIZE 10\n#define LSM_INFO_TREE_SIZE       11\n#define LSM_INFO_FREELIST_SIZE   12\n#define LSM_INFO_COMPRESSION_ID  13\n\n\n/* \n** CAPI: Opening and Closing Write Transactions\n**\n** These functions are used to open and close transactions and nested \n** sub-transactions.\n**\n** The lsm_begin() function is used to open transactions and sub-transactions. \n** A successful call to lsm_begin() ensures that there are at least iLevel \n** nested transactions open. To open a top-level transaction, pass iLevel=1. \n** To open a sub-transaction within the top-level transaction, iLevel=2. \n** Passing iLevel=0 is a no-op.\n**\n** lsm_commit() is used to commit transactions and sub-transactions. A\n** successful call to lsm_commit() ensures that there are at most iLevel \n** nested transactions open. To commit a top-level transaction, pass iLevel=0. \n** To commit all sub-transactions inside the main transaction, pass iLevel=1.\n**\n** Function lsm_rollback() is used to roll back transactions and\n** sub-transactions. A successful call to lsm_rollback() restores the database \n** to the state it was in when the iLevel'th nested sub-transaction (if any) \n** was first opened. And then closes transactions to ensure that there are \n** at most iLevel nested transactions open. Passing iLevel=0 rolls back and \n** closes the top-level transaction. iLevel=1 also rolls back the top-level \n** transaction, but leaves it open. iLevel=2 rolls back the sub-transaction \n** nested directly inside the top-level transaction (and leaves it open).\n*/\nint lsm_begin(lsm_db *pDb, int iLevel);\nint lsm_commit(lsm_db *pDb, int iLevel);\nint lsm_rollback(lsm_db *pDb, int iLevel);\n\n/* \n** CAPI: Writing to a Database\n**\n** Write a new value into the database. If a value with a duplicate key \n** already exists it is replaced.\n*/\nint lsm_insert(lsm_db*, const void *pKey, int nKey, const void *pVal, int nVal);\n\n/*\n** Delete a value from the database. No error is returned if the specified\n** key value does not exist in the database.\n*/\nint lsm_delete(lsm_db *, const void *pKey, int nKey);\n\n/*\n** Delete all database entries with keys that are greater than (pKey1/nKey1) \n** and smaller than (pKey2/nKey2). Note that keys (pKey1/nKey1) and\n** (pKey2/nKey2) themselves, if they exist in the database, are not deleted.\n**\n** Return LSM_OK if successful, or an LSM error code otherwise.\n*/\nint lsm_delete_range(lsm_db *, \n    const void *pKey1, int nKey1, const void *pKey2, int nKey2\n);\n\n/*\n** CAPI: Explicit Database Work and Checkpointing\n**\n** This function is called by a thread to work on the database structure.\n*/\nint lsm_work(lsm_db *pDb, int nMerge, int nKB, int *pnWrite);\n\nint lsm_flush(lsm_db *pDb);\n\n/*\n** Attempt to checkpoint the current database snapshot. Return an LSM\n** error code if an error occurs or LSM_OK otherwise.\n**\n** If the current snapshot has already been checkpointed, calling this \n** function is a no-op. In this case if pnKB is not NULL, *pnKB is\n** set to 0. Or, if the current snapshot is successfully checkpointed\n** by this function and pbKB is not NULL, *pnKB is set to the number\n** of bytes written to the database file since the previous checkpoint\n** (the same measure as returned by the LSM_INFO_CHECKPOINT_SIZE query).\n*/\nint lsm_checkpoint(lsm_db *pDb, int *pnKB);\n\n/*\n** CAPI: Opening and Closing Database Cursors\n**\n** Open and close a database cursor.\n*/\nint lsm_csr_open(lsm_db *pDb, lsm_cursor **ppCsr);\nint lsm_csr_close(lsm_cursor *pCsr);\n\n/* \n** CAPI: Positioning Database Cursors\n**\n** If the fourth parameter is LSM_SEEK_EQ, LSM_SEEK_GE or LSM_SEEK_LE,\n** this function searches the database for an entry with key (pKey/nKey). \n** If an error occurs, an LSM error code is returned. Otherwise, LSM_OK.\n**\n** If no error occurs and the requested key is present in the database, the\n** cursor is left pointing to the entry with the specified key. Or, if the \n** specified key is not present in the database the state of the cursor \n** depends on the value passed as the final parameter, as follows:\n**\n** LSM_SEEK_EQ:\n**   The cursor is left at EOF (invalidated). A call to lsm_csr_valid()\n**   returns non-zero.\n**\n** LSM_SEEK_LE:\n**   The cursor is left pointing to the largest key in the database that\n**   is smaller than (pKey/nKey). If the database contains no keys smaller\n**   than (pKey/nKey), the cursor is left at EOF.\n**\n** LSM_SEEK_GE:\n**   The cursor is left pointing to the smallest key in the database that\n**   is larger than (pKey/nKey). If the database contains no keys larger\n**   than (pKey/nKey), the cursor is left at EOF.\n**\n** If the fourth parameter is LSM_SEEK_LEFAST, this function searches the\n** database in a similar manner to LSM_SEEK_LE, with two differences:\n**\n** <ol><li>Even if a key can be found (the cursor is not left at EOF), the\n** lsm_csr_value() function may not be used (attempts to do so return\n** LSM_MISUSE).\n**\n** <li>The key that the cursor is left pointing to may be one that has \n** been recently deleted from the database. In this case it is\n** guaranteed that the returned key is larger than any key currently \n** in the database that is less than or equal to (pKey/nKey).\n** </ol>\n**\n** LSM_SEEK_LEFAST requests are intended to be used to allocate database\n** keys.\n*/\nint lsm_csr_seek(lsm_cursor *pCsr, const void *pKey, int nKey, int eSeek);\n\nint lsm_csr_first(lsm_cursor *pCsr);\nint lsm_csr_last(lsm_cursor *pCsr);\n\n/*\n** Advance the specified cursor to the next or previous key in the database.\n** Return LSM_OK if successful, or an LSM error code otherwise.\n**\n** Functions lsm_csr_seek(), lsm_csr_first() and lsm_csr_last() are \"seek\"\n** functions. Whether or not lsm_csr_next and lsm_csr_prev may be called\n** successfully also depends on the most recent seek function called on\n** the cursor. Specifically:\n**\n** <ul>\n** <li> At least one seek function must have been called on the cursor.\n** <li> To call lsm_csr_next(), the most recent call to a seek function must\n** have been either lsm_csr_first() or a call to lsm_csr_seek() specifying\n** LSM_SEEK_GE.\n** <li> To call lsm_csr_prev(), the most recent call to a seek function must\n** have been either lsm_csr_last() or a call to lsm_csr_seek() specifying\n** LSM_SEEK_LE.\n** </ul>\n**\n** Otherwise, if the above conditions are not met when lsm_csr_next or \n** lsm_csr_prev is called, LSM_MISUSE is returned and the cursor position\n** remains unchanged.\n*/\nint lsm_csr_next(lsm_cursor *pCsr);\nint lsm_csr_prev(lsm_cursor *pCsr);\n\n/*\n** Values that may be passed as the fourth argument to lsm_csr_seek().\n*/\n#define LSM_SEEK_LEFAST   -2\n#define LSM_SEEK_LE       -1\n#define LSM_SEEK_EQ        0\n#define LSM_SEEK_GE        1\n\n/* \n** CAPI: Extracting Data From Database Cursors\n**\n** Retrieve data from a database cursor.\n*/\nint lsm_csr_valid(lsm_cursor *pCsr);\nint lsm_csr_key(lsm_cursor *pCsr, const void **ppKey, int *pnKey);\nint lsm_csr_value(lsm_cursor *pCsr, const void **ppVal, int *pnVal);\n\n/*\n** If no error occurs, this function compares the database key passed via\n** the pKey/nKey arguments with the key that the cursor passed as the first\n** argument currently points to. If the cursors key is less than, equal to\n** or greater than pKey/nKey, *piRes is set to less than, equal to or greater\n** than zero before returning. LSM_OK is returned in this case.\n**\n** Or, if an error occurs, an LSM error code is returned and the final \n** value of *piRes is undefined. If the cursor does not point to a valid\n** key when this function is called, LSM_MISUSE is returned.\n*/\nint lsm_csr_cmp(lsm_cursor *pCsr, const void *pKey, int nKey, int *piRes);\n\n/*\n** CAPI: Change these!!\n**\n** Configure a callback to which debugging and other messages should \n** be directed. Only useful for debugging lsm.\n*/\nvoid lsm_config_log(lsm_db *, void (*)(void *, int, const char *), void *);\n\n/*\n** Configure a callback that is invoked if the database connection ever\n** writes to the database file.\n*/\nvoid lsm_config_work_hook(lsm_db *, void (*)(lsm_db *, void *), void *);\n\n/* ENDOFAPI */\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* ifndef _LSM_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsmInt.h",
    "content": "/*\n** 2011-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Internal structure definitions for the LSM module.\n*/\n#ifndef _LSM_INT_H\n#define _LSM_INT_H\n\n#include \"lsm.h\"\n#include <assert.h>\n#include <string.h>\n\n#include <stdarg.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <ctype.h>\n\n#ifdef _WIN32\n# ifdef _MSC_VER\n#  define snprintf _snprintf\n# endif\n#else\n# include <unistd.h>\n#endif\n\n#ifdef NDEBUG\n# ifdef LSM_DEBUG_EXPENSIVE\n#  undef LSM_DEBUG_EXPENSIVE\n# endif\n# ifdef LSM_DEBUG\n#  undef LSM_DEBUG\n# endif\n#else\n# ifndef LSM_DEBUG\n#  define LSM_DEBUG\n# endif\n#endif\n\n/*\n** Default values for various data structure parameters. These may be\n** overridden by calls to lsm_config().\n*/\n#define LSM_DFLT_PAGE_SIZE          (4 * 1024)\n#define LSM_DFLT_BLOCK_SIZE         (1 * 1024 * 1024)\n#define LSM_DFLT_AUTOFLUSH          (1 * 1024 * 1024)\n#define LSM_DFLT_AUTOCHECKPOINT     (i64)(2 * 1024 * 1024)\n#define LSM_DFLT_AUTOWORK           1\n#define LSM_DFLT_LOG_SIZE           (128*1024)\n#define LSM_DFLT_AUTOMERGE          4\n#define LSM_DFLT_SAFETY             LSM_SAFETY_NORMAL\n#define LSM_DFLT_MMAP               (LSM_IS_64_BIT ? 1 : 32768)\n#define LSM_DFLT_MULTIPLE_PROCESSES 1\n#define LSM_DFLT_USE_LOG            1\n\n/* Initial values for log file checksums. These are only used if the \n** database file does not contain a valid checkpoint.  */\n#define LSM_CKSUM0_INIT 42\n#define LSM_CKSUM1_INIT 42\n\n/* \"mmap\" mode is currently only used in environments with 64-bit address \n** spaces. The following macro is used to test for this.  */\n#define LSM_IS_64_BIT (sizeof(void*)==8)\n\n#define LSM_AUTOWORK_QUANT 32\n\ntypedef struct Database Database;\ntypedef struct DbLog DbLog;\ntypedef struct FileSystem FileSystem;\ntypedef struct Freelist Freelist;\ntypedef struct FreelistEntry FreelistEntry;\ntypedef struct Level Level;\ntypedef struct LogMark LogMark;\ntypedef struct LogRegion LogRegion;\ntypedef struct LogWriter LogWriter;\ntypedef struct LsmString LsmString;\ntypedef struct Mempool Mempool;\ntypedef struct Merge Merge;\ntypedef struct MergeInput MergeInput;\ntypedef struct MetaPage MetaPage;\ntypedef struct MultiCursor MultiCursor;\ntypedef struct Page Page;\ntypedef struct Redirect Redirect;\ntypedef struct Segment Segment;\ntypedef struct SegmentMerger SegmentMerger;\ntypedef struct ShmChunk ShmChunk;\ntypedef struct ShmHeader ShmHeader;\ntypedef struct ShmReader ShmReader;\ntypedef struct Snapshot Snapshot;\ntypedef struct TransMark TransMark;\ntypedef struct Tree Tree;\ntypedef struct TreeCursor TreeCursor;\ntypedef struct TreeHeader TreeHeader;\ntypedef struct TreeMark TreeMark;\ntypedef struct TreeRoot TreeRoot;\n\n#ifndef _SQLITEINT_H_\ntypedef unsigned char u8;\ntypedef unsigned short int u16;\ntypedef unsigned int u32;\ntypedef lsm_i64 i64;\ntypedef unsigned long long int u64;\n#endif\n\n/* A page number is a 64-bit integer. */\ntypedef i64 Pgno;\n\n#ifdef LSM_DEBUG\nint lsmErrorBkpt(int);\n#else\n# define lsmErrorBkpt(x) (x)\n#endif\n\n#define LSM_PROTOCOL_BKPT lsmErrorBkpt(LSM_PROTOCOL)\n#define LSM_IOERR_BKPT    lsmErrorBkpt(LSM_IOERR)\n#define LSM_NOMEM_BKPT    lsmErrorBkpt(LSM_NOMEM)\n#define LSM_CORRUPT_BKPT  lsmErrorBkpt(LSM_CORRUPT)\n#define LSM_MISUSE_BKPT   lsmErrorBkpt(LSM_MISUSE)\n\n#define unused_parameter(x) (void)(x)\n#define array_size(x) (sizeof(x)/sizeof(x[0]))\n\n\n/* The size of each shared-memory chunk */\n#define LSM_SHM_CHUNK_SIZE (32*1024)\n\n/* The number of bytes reserved at the start of each shm chunk for MM. */\n#define LSM_SHM_CHUNK_HDR  (sizeof(ShmChunk))\n\n/* The number of available read locks. */\n#define LSM_LOCK_NREADER   6\n\n/* The number of available read-write client locks. */\n#define LSM_LOCK_NRWCLIENT   16\n\n/* Lock definitions. \n*/\n#define LSM_LOCK_DMS1         1   /* Serialize connect/disconnect ops */\n#define LSM_LOCK_DMS2         2   /* Read-write connections */\n#define LSM_LOCK_DMS3         3   /* Read-only connections */\n#define LSM_LOCK_WRITER       4\n#define LSM_LOCK_WORKER       5\n#define LSM_LOCK_CHECKPOINTER 6\n#define LSM_LOCK_ROTRANS      7\n#define LSM_LOCK_READER(i)    ((i) + LSM_LOCK_ROTRANS + 1)\n#define LSM_LOCK_RWCLIENT(i)  ((i) + LSM_LOCK_READER(LSM_LOCK_NREADER))\n\n#define LSM_N_LOCK LSM_LOCK_RWCLIENT(LSM_LOCK_NRWCLIENT)\n\n/*\n** Meta-page size and usable size.\n*/\n#define LSM_META_PAGE_SIZE 4096\n\n#define LSM_META_RW_PAGE_SIZE (LSM_META_PAGE_SIZE - LSM_N_LOCK)\n\n/*\n** Hard limit on the number of free-list entries that may be stored in \n** a checkpoint (the remainder are stored as a system record in the LSM).\n** See also LSM_CONFIG_MAX_FREELIST.\n*/\n#define LSM_MAX_FREELIST_ENTRIES 24\n\n#define LSM_MAX_BLOCK_REDIRECTS 16\n\n#define LSM_ATTEMPTS_BEFORE_PROTOCOL 10000\n\n\n/*\n** Each entry stored in the LSM (or in-memory tree structure) has an\n** associated mask of the following flags.\n*/\n#define LSM_START_DELETE 0x01     /* Start of open-ended delete range */\n#define LSM_END_DELETE   0x02     /* End of open-ended delete range */\n#define LSM_POINT_DELETE 0x04     /* Delete this key */\n#define LSM_INSERT       0x08     /* Insert this key and value */\n#define LSM_SEPARATOR    0x10     /* True if entry is separator key only */\n#define LSM_SYSTEMKEY    0x20     /* True if entry is a system key (FREELIST) */\n\n#define LSM_CONTIGUOUS   0x40     /* Used in lsm_tree.c */\n\n/*\n** A string that can grow by appending.\n*/\nstruct LsmString {\n  lsm_env *pEnv;              /* Run-time environment */\n  int n;                      /* Size of string.  -1 indicates error */\n  int nAlloc;                 /* Space allocated for z[] */\n  char *z;                    /* The string content */\n};\n\ntypedef struct LsmFile LsmFile;\nstruct LsmFile {\n  lsm_file *pFile;\n  LsmFile *pNext;\n};\n\n/*\n** An instance of the following type is used to store an ordered list of\n** u32 values. \n**\n** Note: This is a place-holder implementation. It should be replaced by\n** a version that avoids making a single large allocation when the array\n** contains a large number of values. For this reason, the internals of \n** this object should only manipulated by the intArrayXXX() functions in \n** lsm_tree.c.\n*/\ntypedef struct IntArray IntArray;\nstruct IntArray {\n  int nAlloc;\n  int nArray;\n  u32 *aArray;\n};\n\nstruct Redirect {\n  int n;                          /* Number of redirects */\n  struct RedirectEntry {\n    int iFrom;\n    int iTo;\n  } *a;\n};\n\n/*\n** An instance of this structure represents a point in the history of the\n** tree structure to roll back to. Refer to comments in lsm_tree.c for \n** details.\n*/\nstruct TreeMark {\n  u32 iRoot;                      /* Offset of root node in shm file */\n  u32 nHeight;                    /* Current height of tree structure */\n  u32 iWrite;                     /* Write offset in shm file */\n  u32 nChunk;                     /* Number of chunks in shared-memory file */\n  u32 iFirst;                     /* First chunk in linked list */\n  u32 iNextShmid;                 /* Next id to allocate */\n  int iRollback;                  /* Index in lsm->rollback to revert to */\n};\n\n/*\n** An instance of this structure represents a point in the database log.\n*/\nstruct LogMark {\n  i64 iOff;                       /* Offset into log (see lsm_log.c) */\n  int nBuf;                       /* Size of in-memory buffer here */\n  u8 aBuf[8];                     /* Bytes of content in aBuf[] */\n  u32 cksum0;                     /* Checksum 0 at offset (iOff-nBuf) */\n  u32 cksum1;                     /* Checksum 1 at offset (iOff-nBuf) */\n};\n\nstruct TransMark {\n  TreeMark tree;\n  LogMark log;\n};\n\n/*\n** A structure that defines the start and end offsets of a region in the\n** log file. The size of the region in bytes is (iEnd - iStart), so if\n** iEnd==iStart the region is zero bytes in size.\n*/\nstruct LogRegion {\n  i64 iStart;                     /* Start of region in log file */\n  i64 iEnd;                       /* End of region in log file */\n};\n\nstruct DbLog {\n  u32 cksum0;                     /* Checksum 0 at offset iOff */\n  u32 cksum1;                     /* Checksum 1 at offset iOff */\n  i64 iSnapshotId;                /* Log space has been reclaimed to this ss */\n  LogRegion aRegion[3];           /* Log file regions (see docs in lsm_log.c) */\n};\n\nstruct TreeRoot {\n  u32 iRoot;\n  u32 nHeight;\n  u32 nByte;                      /* Total size of this tree in bytes */\n  u32 iTransId;\n};\n\n/*\n** Tree header structure. \n*/\nstruct TreeHeader {\n  u32 iUsedShmid;                 /* Id of first shm chunk used by this tree */\n  u32 iNextShmid;                 /* Shm-id of next chunk allocated */\n  u32 iFirst;                     /* Chunk number of smallest shm-id */\n  u32 nChunk;                     /* Number of chunks in shared-memory file */\n  TreeRoot root;                  /* Root and height of current tree */\n  u32 iWrite;                     /* Write offset in shm file */\n  TreeRoot oldroot;               /* Root and height of the previous tree */\n  u32 iOldShmid;                  /* Last shm-id used by previous tree */\n  u32 iUsrVersion;                /* get/set_user_version() value */\n  i64 iOldLog;                    /* Log offset associated with old tree */\n  u32 oldcksum0;\n  u32 oldcksum1;\n  DbLog log;                      /* Current layout of log file */ \n  u32 aCksum[2];                  /* Checksums 1 and 2. */\n};\n\n/*\n** Database handle structure.\n**\n** mLock:\n**   A bitmask representing the locks currently held by the connection.\n**   An LSM database supports N distinct locks, where N is some number less\n**   than or equal to 32. Locks are numbered starting from 1 (see the \n**   definitions for LSM_LOCK_WRITER and co.).\n**\n**   The least significant 32-bits in mLock represent EXCLUSIVE locks. The\n**   most significant are SHARED locks. So, if a connection holds a SHARED\n**   lock on lock region iLock, then the following is true:\n**\n**       (mLock & ((iLock+32-1) << 1))\n**\n**   Or for an EXCLUSIVE lock:\n**\n**       (mLock & ((iLock-1) << 1))\n** \n** pCsr:\n**   Points to the head of a linked list that contains all currently open\n**   cursors. Once this list becomes empty, the user has no outstanding\n**   cursors and the database handle can be successfully closed.\n**\n** pCsrCache:\n**   This list contains cursor objects that have been closed using\n**   lsm_csr_close(). Each time a cursor is closed, it is shifted from \n**   the pCsr list to this list. When a new cursor is opened, this list\n**   is inspected to see if there exists a cursor object that can be\n**   reused. This is an optimization only.\n*/\nstruct lsm_db {\n\n  /* Database handle configuration */\n  lsm_env *pEnv;                            /* runtime environment */\n  int (*xCmp)(void *, int, void *, int);    /* Compare function */\n\n  /* Values configured by calls to lsm_config */\n  int eSafety;                    /* LSM_SAFETY_OFF, NORMAL or FULL */\n  int bAutowork;                  /* Configured by LSM_CONFIG_AUTOWORK */\n  int nTreeLimit;                 /* Configured by LSM_CONFIG_AUTOFLUSH */\n  int nMerge;                     /* Configured by LSM_CONFIG_AUTOMERGE */\n  int bUseLog;                    /* Configured by LSM_CONFIG_USE_LOG */\n  int nDfltPgsz;                  /* Configured by LSM_CONFIG_PAGE_SIZE */\n  int nDfltBlksz;                 /* Configured by LSM_CONFIG_BLOCK_SIZE */\n  int nMaxFreelist;               /* Configured by LSM_CONFIG_MAX_FREELIST */\n  int iMmap;                      /* Configured by LSM_CONFIG_MMAP */\n  i64 nAutockpt;                  /* Configured by LSM_CONFIG_AUTOCHECKPOINT */\n  int bMultiProc;                 /* Configured by L_C_MULTIPLE_PROCESSES */\n  int bReadonly;                  /* Configured by LSM_CONFIG_READONLY */\n  lsm_compress compress;          /* Compression callbacks */\n  lsm_compress_factory factory;   /* Compression callback factory */\n\n  /* Sub-system handles */\n  FileSystem *pFS;                /* On-disk portion of database */\n  Database *pDatabase;            /* Database shared data */\n\n  int iRwclient;                  /* Read-write client lock held (-1 == none) */\n\n  /* Client transaction context */\n  Snapshot *pClient;              /* Client snapshot */\n  int iReader;                    /* Read lock held (-1 == unlocked) */\n  int bRoTrans;                   /* True if a read-only db trans is open */\n  MultiCursor *pCsr;              /* List of all open cursors */\n  LogWriter *pLogWriter;          /* Context for writing to the log file */\n  int nTransOpen;                 /* Number of opened write transactions */\n  int nTransAlloc;                /* Allocated size of aTrans[] array */\n  TransMark *aTrans;              /* Array of marks for transaction rollback */\n  IntArray rollback;              /* List of tree-nodes to roll back */\n  int bDiscardOld;                /* True if lsmTreeDiscardOld() was called */\n\n  MultiCursor *pCsrCache;         /* List of all closed cursors */\n\n  /* Worker context */\n  Snapshot *pWorker;              /* Worker snapshot (or NULL) */\n  Freelist *pFreelist;            /* See sortedNewToplevel() */\n  int bUseFreelist;               /* True to use pFreelist */\n  int bIncrMerge;                 /* True if currently doing a merge */\n\n  int bInFactory;                 /* True if within factory.xFactory() */\n\n  /* Debugging message callback */\n  void (*xLog)(void *, int, const char *);\n  void *pLogCtx;\n\n  /* Work done notification callback */\n  void (*xWork)(lsm_db *, void *);\n  void *pWorkCtx;\n\n  u64 mLock;                      /* Mask of current locks. See lsmShmLock(). */\n  lsm_db *pNext;                  /* Next connection to same database */\n\n  int nShm;                       /* Size of apShm[] array */\n  void **apShm;                   /* Shared memory chunks */\n  ShmHeader *pShmhdr;             /* Live shared-memory header */\n  TreeHeader treehdr;             /* Local copy of tree-header */\n  u32 aSnapshot[LSM_META_PAGE_SIZE / sizeof(u32)];\n};\n\nstruct Segment {\n  Pgno iFirst;                     /* First page of this run */\n  Pgno iLastPg;                    /* Last page of this run */\n  Pgno iRoot;                      /* Root page number (if any) */\n  int nSize;                       /* Size of this run in pages */\n\n  Redirect *pRedirect;             /* Block redirects (or NULL) */\n};\n\n/*\n** iSplitTopic/pSplitKey/nSplitKey:\n**   If nRight>0, this buffer contains a copy of the largest key that has\n**   already been written to the left-hand-side of the level.\n*/\nstruct Level {\n  Segment lhs;                    /* Left-hand (main) segment */\n  int nRight;                     /* Size of apRight[] array */\n  Segment *aRhs;                  /* Old segments being merged into this */\n  int iSplitTopic;                /* Split key topic (if nRight>0) */\n  void *pSplitKey;                /* Pointer to split-key (if nRight>0) */\n  int nSplitKey;                  /* Number of bytes in split-key */\n\n  u16 iAge;                       /* Number of times data has been written */\n  u16 flags;                      /* Mask of LEVEL_XXX bits */\n  Merge *pMerge;                  /* Merge operation currently underway */\n  Level *pNext;                   /* Next level in tree */\n};\n\n/*\n** The Level.flags field is set to a combination of the following bits.\n**\n** LEVEL_FREELIST_ONLY:\n**   Set if the level consists entirely of free-list entries. \n**\n** LEVEL_INCOMPLETE:\n**   This is set while a new toplevel level is being constructed. It is\n**   never set for any level other than a new toplevel.\n*/\n#define LEVEL_FREELIST_ONLY      0x0001\n#define LEVEL_INCOMPLETE         0x0002\n\n\n/*\n** A structure describing an ongoing merge. There is an instance of this\n** structure for every Level currently undergoing a merge in the worker\n** snapshot.\n**\n** It is assumed that code that uses an instance of this structure has\n** access to the associated Level struct.\n**\n** iOutputOff:\n**   The byte offset to write to next within the last page of the \n**   output segment.\n*/\nstruct MergeInput {\n  Pgno iPg;                       /* Page on which next input is stored */\n  int iCell;                      /* Cell containing next input to merge */\n};\nstruct Merge {\n  int nInput;                     /* Number of input runs being merged */\n  MergeInput *aInput;             /* Array nInput entries in size */\n  MergeInput splitkey;            /* Location in file of current splitkey */\n  int nSkip;                      /* Number of separators entries to skip */\n  int iOutputOff;                 /* Write offset on output page */\n  Pgno iCurrentPtr;               /* Current pointer value */\n};\n\n/* \n** The first argument to this macro is a pointer to a Segment structure.\n** Returns true if the structure instance indicates that the separators\n** array is valid.\n*/\n#define segmentHasSeparators(pSegment) ((pSegment)->sep.iFirst>0)\n\n/*\n** The values that accompany the lock held by a database reader.\n*/\nstruct ShmReader {\n  u32 iTreeId;\n  i64 iLsmId;\n};\n\n/*\n** An instance of this structure is stored in the first shared-memory\n** page. The shared-memory header.\n**\n** bWriter:\n**   Immediately after opening a write transaction taking the WRITER lock, \n**   each writer client sets this flag. It is cleared right before the \n**   WRITER lock is relinquished. If a subsequent writer finds that this\n**   flag is already set when a write transaction is opened, this indicates\n**   that a previous writer failed mid-transaction.\n**\n** iMetaPage:\n**   If the database file does not contain a valid, synced, checkpoint, this\n**   value is set to 0. Otherwise, it is set to the meta-page number that\n**   contains the most recently written checkpoint (either 1 or 2).\n**\n** hdr1, hdr2:\n**   The two copies of the in-memory tree header. Two copies are required\n**   in case a writer fails while updating one of them.\n*/\nstruct ShmHeader {\n  u32 aSnap1[LSM_META_PAGE_SIZE / 4];\n  u32 aSnap2[LSM_META_PAGE_SIZE / 4];\n  u32 bWriter;\n  u32 iMetaPage;\n  TreeHeader hdr1;\n  TreeHeader hdr2;\n  ShmReader aReader[LSM_LOCK_NREADER];\n};\n\n/*\n** An instance of this structure is stored at the start of each shared-memory\n** chunk except the first (which is the header chunk - see above).\n*/\nstruct ShmChunk {\n  u32 iShmid;\n  u32 iNext;\n};\n\n/*\n** Maximum number of shared-memory chunks allowed in the *-shm file. Since\n** each shared-memory chunk is 32KB in size, this is a theoretical limit only.\n*/\n#define LSM_MAX_SHMCHUNKS  (1<<30)\n\n/* Return true if shm-sequence \"a\" is larger than or equal to \"b\" */\n#define shm_sequence_ge(a, b) (((u32)a-(u32)b) < LSM_MAX_SHMCHUNKS)\n\n#define LSM_APPLIST_SZ 4\n\n/*\n** An instance of the following structure stores the in-memory part of\n** the current free block list. This structure is to the free block list\n** as the in-memory tree is to the users database content. The contents \n** of the free block list is found by merging the in-memory components \n** with those stored in the LSM, just as the contents of the database is\n** found by merging the in-memory tree with the user data entries in the\n** LSM.\n**\n** Each FreelistEntry structure in the array represents either an insert\n** or delete operation on the free-list. For deletes, the FreelistEntry.iId\n** field is set to -1. For inserts, it is set to zero or greater. \n**\n** The array of FreelistEntry structures is always sorted in order of\n** block number (ascending).\n**\n** When the in-memory free block list is written into the LSM, each insert\n** operation is written separately. The entry key is the bitwise inverse\n** of the block number as a 32-bit big-endian integer. This is done so that\n** the entries in the LSM are sorted in descending order of block id. \n** The associated value is the snapshot id, formated as a varint.\n*/\nstruct Freelist {\n  FreelistEntry *aEntry;          /* Free list entries */\n  int nEntry;                     /* Number of valid slots in aEntry[] */\n  int nAlloc;                     /* Allocated size of aEntry[] */\n};\nstruct FreelistEntry {\n  u32 iBlk;                       /* Block number */\n  i64 iId;                        /* Largest snapshot id to use this block */\n};\n\n/*\n** A snapshot of a database. A snapshot contains all the information required\n** to read or write a database file on disk. See the description of struct\n** Database below for futher details.\n*/\nstruct Snapshot {\n  Database *pDatabase;            /* Database this snapshot belongs to */\n  u32 iCmpId;                     /* Id of compression scheme */\n  Level *pLevel;                  /* Pointer to level 0 of snapshot (or NULL) */\n  i64 iId;                        /* Snapshot id */\n  i64 iLogOff;                    /* Log file offset */\n  Redirect redirect;              /* Block redirection array */\n\n  /* Used by worker snapshots only */\n  int nBlock;                     /* Number of blocks in database file */\n  Pgno aiAppend[LSM_APPLIST_SZ];  /* Append point list */\n  Freelist freelist;              /* Free block list */\n  u32 nWrite;                     /* Total number of pages written to disk */\n};\n#define LSM_INITIAL_SNAPSHOT_ID 11\n\n/*\n** Functions from file \"lsm_ckpt.c\".\n*/\nint lsmCheckpointWrite(lsm_db *, u32 *);\nint lsmCheckpointLevels(lsm_db *, int, void **, int *);\nint lsmCheckpointLoadLevels(lsm_db *pDb, void *pVal, int nVal);\n\nint lsmCheckpointRecover(lsm_db *);\nint lsmCheckpointDeserialize(lsm_db *, int, u32 *, Snapshot **);\n\nint lsmCheckpointLoadWorker(lsm_db *pDb);\nint lsmCheckpointStore(lsm_db *pDb, int);\n\nint lsmCheckpointLoad(lsm_db *pDb, int *);\nint lsmCheckpointLoadOk(lsm_db *pDb, int);\nint lsmCheckpointClientCacheOk(lsm_db *);\n\nu32 lsmCheckpointNBlock(u32 *);\ni64 lsmCheckpointId(u32 *, int);\nu32 lsmCheckpointNWrite(u32 *, int);\ni64 lsmCheckpointLogOffset(u32 *);\nint lsmCheckpointPgsz(u32 *);\nint lsmCheckpointBlksz(u32 *);\nvoid lsmCheckpointLogoffset(u32 *aCkpt, DbLog *pLog);\nvoid lsmCheckpointZeroLogoffset(lsm_db *);\n\nint lsmCheckpointSaveWorker(lsm_db *pDb, int);\nint lsmDatabaseFull(lsm_db *pDb);\nint lsmCheckpointSynced(lsm_db *pDb, i64 *piId, i64 *piLog, u32 *pnWrite);\n\nint lsmCheckpointSize(lsm_db *db, int *pnByte);\n\nint lsmInfoCompressionId(lsm_db *db, u32 *piCmpId);\n\n/* \n** Functions from file \"lsm_tree.c\".\n*/\nint lsmTreeNew(lsm_env *, int (*)(void *, int, void *, int), Tree **ppTree);\nvoid lsmTreeRelease(lsm_env *, Tree *);\nint lsmTreeInit(lsm_db *);\nint lsmTreeRepair(lsm_db *);\n\nvoid lsmTreeMakeOld(lsm_db *pDb);\nvoid lsmTreeDiscardOld(lsm_db *pDb);\nint lsmTreeHasOld(lsm_db *pDb);\n\nint lsmTreeSize(lsm_db *);\nint lsmTreeEndTransaction(lsm_db *pDb, int bCommit);\nint lsmTreeLoadHeader(lsm_db *pDb, int *);\nint lsmTreeLoadHeaderOk(lsm_db *, int);\n\nint lsmTreeInsert(lsm_db *pDb, void *pKey, int nKey, void *pVal, int nVal);\nint lsmTreeDelete(lsm_db *db, void *pKey1, int nKey1, void *pKey2, int nKey2);\nvoid lsmTreeRollback(lsm_db *pDb, TreeMark *pMark);\nvoid lsmTreeMark(lsm_db *pDb, TreeMark *pMark);\n\nint lsmTreeCursorNew(lsm_db *pDb, int, TreeCursor **);\nvoid lsmTreeCursorDestroy(TreeCursor *);\n\nint lsmTreeCursorSeek(TreeCursor *pCsr, void *pKey, int nKey, int *pRes);\nint lsmTreeCursorNext(TreeCursor *pCsr);\nint lsmTreeCursorPrev(TreeCursor *pCsr);\nint lsmTreeCursorEnd(TreeCursor *pCsr, int bLast);\nvoid lsmTreeCursorReset(TreeCursor *pCsr);\nint lsmTreeCursorKey(TreeCursor *pCsr, int *pFlags, void **ppKey, int *pnKey);\nint lsmTreeCursorFlags(TreeCursor *pCsr);\nint lsmTreeCursorValue(TreeCursor *pCsr, void **ppVal, int *pnVal);\nint lsmTreeCursorValid(TreeCursor *pCsr);\nint lsmTreeCursorSave(TreeCursor *pCsr);\n\nvoid lsmFlagsToString(int flags, char *zFlags);\n\n/* \n** Functions from file \"mem.c\".\n*/\nvoid *lsmMalloc(lsm_env*, size_t);\nvoid lsmFree(lsm_env*, void *);\nvoid *lsmRealloc(lsm_env*, void *, size_t);\nvoid *lsmReallocOrFree(lsm_env*, void *, size_t);\nvoid *lsmReallocOrFreeRc(lsm_env *, void *, size_t, int *);\n\nvoid *lsmMallocZeroRc(lsm_env*, size_t, int *);\nvoid *lsmMallocRc(lsm_env*, size_t, int *);\n\nvoid *lsmMallocZero(lsm_env *pEnv, size_t);\nchar *lsmMallocStrdup(lsm_env *pEnv, const char *);\n\n/* \n** Functions from file \"lsm_mutex.c\".\n*/\nint lsmMutexStatic(lsm_env*, int, lsm_mutex **);\nint lsmMutexNew(lsm_env*, lsm_mutex **);\nvoid lsmMutexDel(lsm_env*, lsm_mutex *);\nvoid lsmMutexEnter(lsm_env*, lsm_mutex *);\nint lsmMutexTry(lsm_env*, lsm_mutex *);\nvoid lsmMutexLeave(lsm_env*, lsm_mutex *);\n\n#ifndef NDEBUG\nint lsmMutexHeld(lsm_env *, lsm_mutex *);\nint lsmMutexNotHeld(lsm_env *, lsm_mutex *);\n#endif\n\n/**************************************************************************\n** Start of functions from \"lsm_file.c\".\n*/\nint lsmFsOpen(lsm_db *, const char *, int);\nint lsmFsOpenLog(lsm_db *, int *);\nvoid lsmFsCloseLog(lsm_db *);\nvoid lsmFsClose(FileSystem *);\n\nint lsmFsUnmap(FileSystem *);\n\nint lsmFsConfigure(lsm_db *db);\n\nint lsmFsBlockSize(FileSystem *);\nvoid lsmFsSetBlockSize(FileSystem *, int);\nint lsmFsMoveBlock(FileSystem *pFS, Segment *pSeg, int iTo, int iFrom);\n\nint lsmFsPageSize(FileSystem *);\nvoid lsmFsSetPageSize(FileSystem *, int);\n\nint lsmFsFileid(lsm_db *pDb, void **ppId, int *pnId);\n\n/* Creating, populating, gobbling and deleting sorted runs. */\nvoid lsmFsGobble(lsm_db *, Segment *, Pgno *, int);\nint lsmFsSortedDelete(FileSystem *, Snapshot *, int, Segment *);\nint lsmFsSortedFinish(FileSystem *, Segment *);\nint lsmFsSortedAppend(FileSystem *, Snapshot *, Level *, int, Page **);\nint lsmFsSortedPadding(FileSystem *, Snapshot *, Segment *);\n\n/* Functions to retrieve the lsm_env pointer from a FileSystem or Page object */\nlsm_env *lsmFsEnv(FileSystem *);\nlsm_env *lsmPageEnv(Page *);\nFileSystem *lsmPageFS(Page *);\n\nint lsmFsSectorSize(FileSystem *);\n\nvoid lsmSortedSplitkey(lsm_db *, Level *, int *);\n\n/* Reading sorted run content. */\nint lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg);\nint lsmFsDbPageGet(FileSystem *, Segment *, Pgno, Page **);\nint lsmFsDbPageNext(Segment *, Page *, int eDir, Page **);\n\nu8 *lsmFsPageData(Page *, int *);\nint lsmFsPageRelease(Page *);\nint lsmFsPagePersist(Page *);\nvoid lsmFsPageRef(Page *);\nPgno lsmFsPageNumber(Page *);\n\nint lsmFsNRead(FileSystem *);\nint lsmFsNWrite(FileSystem *);\n\nint lsmFsMetaPageGet(FileSystem *, int, int, MetaPage **);\nint lsmFsMetaPageRelease(MetaPage *);\nu8 *lsmFsMetaPageData(MetaPage *, int *);\n\n#ifdef LSM_DEBUG\nint lsmFsDbPageIsLast(Segment *pSeg, Page *pPg);\nint lsmFsIntegrityCheck(lsm_db *);\n#endif\n\nPgno lsmFsRedirectPage(FileSystem *, Redirect *, Pgno);\n\nint lsmFsPageWritable(Page *);\n\n/* Functions to read, write and sync the log file. */\nint lsmFsWriteLog(FileSystem *pFS, i64 iOff, LsmString *pStr);\nint lsmFsSyncLog(FileSystem *pFS);\nint lsmFsReadLog(FileSystem *pFS, i64 iOff, int nRead, LsmString *pStr);\nint lsmFsTruncateLog(FileSystem *pFS, i64 nByte);\nint lsmFsTruncateDb(FileSystem *pFS, i64 nByte);\nint lsmFsCloseAndDeleteLog(FileSystem *pFS);\n\nLsmFile *lsmFsDeferClose(FileSystem *pFS);\n\n/* And to sync the db file */\nint lsmFsSyncDb(FileSystem *, int);\n\nvoid lsmFsFlushWaiting(FileSystem *, int *);\n\n/* Used by lsm_info(ARRAY_STRUCTURE) and lsm_config(MMAP) */\nint lsmInfoArrayStructure(lsm_db *pDb, int bBlock, Pgno iFirst, char **pzOut);\nint lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut);\nint lsmConfigMmap(lsm_db *pDb, int *piParam);\n\nint lsmEnvOpen(lsm_env *, const char *, int, lsm_file **);\nint lsmEnvClose(lsm_env *pEnv, lsm_file *pFile);\nint lsmEnvLock(lsm_env *pEnv, lsm_file *pFile, int iLock, int eLock);\nint lsmEnvTestLock(lsm_env *pEnv, lsm_file *pFile, int iLock, int nLock, int);\n\nint lsmEnvShmMap(lsm_env *, lsm_file *, int, int, void **); \nvoid lsmEnvShmBarrier(lsm_env *);\nvoid lsmEnvShmUnmap(lsm_env *, lsm_file *, int);\n\nvoid lsmEnvSleep(lsm_env *, int);\n\nint lsmFsReadSyncedId(lsm_db *db, int, i64 *piVal);\n\nint lsmFsSegmentContainsPg(FileSystem *pFS, Segment *, Pgno, int *);\n\nvoid lsmFsPurgeCache(FileSystem *);\n\n/*\n** End of functions from \"lsm_file.c\".\n**************************************************************************/\n\n/* \n** Functions from file \"lsm_sorted.c\".\n*/\nint lsmInfoPageDump(lsm_db *, Pgno, int, char **);\nvoid lsmSortedCleanup(lsm_db *);\nint lsmSortedAutoWork(lsm_db *, int nUnit);\n\nint lsmSortedWalkFreelist(lsm_db *, int, int (*)(void *, int, i64), void *);\n\nint lsmSaveWorker(lsm_db *, int);\n\nint lsmFlushTreeToDisk(lsm_db *pDb);\n\nvoid lsmSortedRemap(lsm_db *pDb);\n\nvoid lsmSortedFreeLevel(lsm_env *pEnv, Level *);\n\nint lsmSortedAdvanceAll(lsm_db *pDb);\n\nint lsmSortedLoadMerge(lsm_db *, Level *, u32 *, int *);\nint lsmSortedLoadFreelist(lsm_db *pDb, void **, int *);\n\nvoid *lsmSortedSplitKey(Level *pLevel, int *pnByte);\n\nvoid lsmSortedSaveTreeCursors(lsm_db *);\n\nint lsmMCursorNew(lsm_db *, MultiCursor **);\nvoid lsmMCursorClose(MultiCursor *, int);\nint lsmMCursorSeek(MultiCursor *, int, void *, int , int);\nint lsmMCursorFirst(MultiCursor *);\nint lsmMCursorPrev(MultiCursor *);\nint lsmMCursorLast(MultiCursor *);\nint lsmMCursorValid(MultiCursor *);\nint lsmMCursorNext(MultiCursor *);\nint lsmMCursorKey(MultiCursor *, void **, int *);\nint lsmMCursorValue(MultiCursor *, void **, int *);\nint lsmMCursorType(MultiCursor *, int *);\nlsm_db *lsmMCursorDb(MultiCursor *);\nvoid lsmMCursorFreeCache(lsm_db *);\n\nint lsmSaveCursors(lsm_db *pDb);\nint lsmRestoreCursors(lsm_db *pDb);\n\nvoid lsmSortedDumpStructure(lsm_db *pDb, Snapshot *, int, int, const char *);\nvoid lsmFsDumpBlocklists(lsm_db *);\n\nvoid lsmSortedExpandBtreePage(Page *pPg, int nOrig);\n\nvoid lsmPutU32(u8 *, u32);\nu32 lsmGetU32(u8 *);\nu64 lsmGetU64(u8 *);\n\n/*\n** Functions from \"lsm_varint.c\".\n*/\nint lsmVarintPut32(u8 *, int);\nint lsmVarintGet32(u8 *, int *);\nint lsmVarintPut64(u8 *aData, i64 iVal);\nint lsmVarintGet64(const u8 *aData, i64 *piVal);\n\nint lsmVarintLen32(int);\nint lsmVarintSize(u8 c);\n\n/* \n** Functions from file \"main.c\".\n*/\nvoid lsmLogMessage(lsm_db *, int, const char *, ...);\nint lsmInfoFreelist(lsm_db *pDb, char **pzOut);\n\n/*\n** Functions from file \"lsm_log.c\".\n*/\nint lsmLogBegin(lsm_db *pDb);\nint lsmLogWrite(lsm_db *, int, void *, int, void *, int);\nint lsmLogCommit(lsm_db *);\nvoid lsmLogEnd(lsm_db *pDb, int bCommit);\nvoid lsmLogTell(lsm_db *, LogMark *);\nvoid lsmLogSeek(lsm_db *, LogMark *);\nvoid lsmLogClose(lsm_db *);\n\nint lsmLogRecover(lsm_db *);\nint lsmInfoLogStructure(lsm_db *pDb, char **pzVal);\n\n/* Valid values for the second argument to lsmLogWrite(). */\n#define LSM_WRITE        0x06\n#define LSM_DELETE       0x08\n#define LSM_DRANGE       0x0A\n\n/**************************************************************************\n** Functions from file \"lsm_shared.c\".\n*/\n\nint lsmDbDatabaseConnect(lsm_db*, const char *);\nvoid lsmDbDatabaseRelease(lsm_db *);\n\nint lsmBeginReadTrans(lsm_db *);\nint lsmBeginWriteTrans(lsm_db *);\nint lsmBeginFlush(lsm_db *);\n\nint lsmDetectRoTrans(lsm_db *db, int *);\nint lsmBeginRoTrans(lsm_db *db);\n\nint lsmBeginWork(lsm_db *);\nvoid lsmFinishWork(lsm_db *, int, int *);\n\nint lsmFinishRecovery(lsm_db *);\nvoid lsmFinishReadTrans(lsm_db *);\nint lsmFinishWriteTrans(lsm_db *, int);\nint lsmFinishFlush(lsm_db *, int);\n\nint lsmSnapshotSetFreelist(lsm_db *, int *, int);\n\nSnapshot *lsmDbSnapshotClient(lsm_db *);\nSnapshot *lsmDbSnapshotWorker(lsm_db *);\n\nvoid lsmSnapshotSetCkptid(Snapshot *, i64);\n\nLevel *lsmDbSnapshotLevel(Snapshot *);\nvoid lsmDbSnapshotSetLevel(Snapshot *, Level *);\n\nvoid lsmDbRecoveryComplete(lsm_db *, int);\n\nint lsmBlockAllocate(lsm_db *, int, int *);\nint lsmBlockFree(lsm_db *, int);\nint lsmBlockRefree(lsm_db *, int);\n\nvoid lsmFreelistDeltaBegin(lsm_db *);\nvoid lsmFreelistDeltaEnd(lsm_db *);\nint lsmFreelistDelta(lsm_db *pDb);\n\nDbLog *lsmDatabaseLog(lsm_db *pDb);\n\n#ifdef LSM_DEBUG\n  int lsmHoldingClientMutex(lsm_db *pDb);\n  int lsmShmAssertLock(lsm_db *db, int iLock, int eOp);\n  int lsmShmAssertWorker(lsm_db *db);\n#endif\n\nvoid lsmFreeSnapshot(lsm_env *, Snapshot *);\n\n\n/* Candidate values for the 3rd argument to lsmShmLock() */\n#define LSM_LOCK_UNLOCK 0\n#define LSM_LOCK_SHARED 1\n#define LSM_LOCK_EXCL   2\n\nint lsmShmCacheChunks(lsm_db *db, int nChunk);\nint lsmShmLock(lsm_db *db, int iLock, int eOp, int bBlock);\nint lsmShmTestLock(lsm_db *db, int iLock, int nLock, int eOp);\nvoid lsmShmBarrier(lsm_db *db);\n\n#ifdef LSM_DEBUG\nvoid lsmShmHasLock(lsm_db *db, int iLock, int eOp);\n#else\n# define lsmShmHasLock(x,y,z)\n#endif\n\nint lsmReadlock(lsm_db *, i64 iLsm, u32 iShmMin, u32 iShmMax);\n\nint lsmLsmInUse(lsm_db *db, i64 iLsmId, int *pbInUse);\nint lsmTreeInUse(lsm_db *db, u32 iLsmId, int *pbInUse);\nint lsmFreelistAppend(lsm_env *pEnv, Freelist *p, int iBlk, i64 iId);\n\nint lsmDbMultiProc(lsm_db *);\nvoid lsmDbDeferredClose(lsm_db *, lsm_file *, LsmFile *);\nLsmFile *lsmDbRecycleFd(lsm_db *);\n\nint lsmWalkFreelist(lsm_db *, int, int (*)(void *, int, i64), void *);\n\nint lsmCheckCompressionId(lsm_db *, u32);\n\n\n/**************************************************************************\n** functions in lsm_str.c\n*/\nvoid lsmStringInit(LsmString*, lsm_env *pEnv);\nint lsmStringExtend(LsmString*, int);\nint lsmStringAppend(LsmString*, const char *, int);\nvoid lsmStringVAppendf(LsmString*, const char *zFormat, va_list, va_list);\nvoid lsmStringAppendf(LsmString*, const char *zFormat, ...);\nvoid lsmStringClear(LsmString*);\nchar *lsmMallocPrintf(lsm_env*, const char*, ...);\nint lsmStringBinAppend(LsmString *pStr, const u8 *a, int n);\n\nint lsmStrlen(const char *zName);\n\n\n\n/* \n** Round up a number to the next larger multiple of 8.  This is used\n** to force 8-byte alignment on 64-bit architectures.\n*/\n#define ROUND8(x)     (((x)+7)&~7)\n\n#define LSM_MIN(x,y) ((x)>(y) ? (y) : (x))\n#define LSM_MAX(x,y) ((x)>(y) ? (x) : (y))\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_ckpt.c",
    "content": "/*\n** 2011-09-11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to read and write checkpoints.\n**\n** A checkpoint represents the database layout at a single point in time.\n** It includes a log offset. When an existing database is opened, the\n** current state is determined by reading the newest checkpoint and updating\n** it with all committed transactions from the log that follow the specified\n** offset.\n*/\n#include \"lsmInt.h\"\n\n/*\n** CHECKPOINT BLOB FORMAT:\n**\n** A checkpoint blob is a series of unsigned 32-bit integers stored in\n** big-endian byte order. As follows:\n**\n**   Checkpoint header (see the CKPT_HDR_XXX #defines):\n**\n**     1. The checkpoint id MSW.\n**     2. The checkpoint id LSW.\n**     3. The number of integer values in the entire checkpoint, including \n**        the two checksum values.\n**     4. The compression scheme id.\n**     5. The total number of blocks in the database.\n**     6. The block size.\n**     7. The number of levels.\n**     8. The nominal database page size.\n**     9. The number of pages (in total) written to the database file.\n**\n**   Log pointer:\n**\n**     1. The log offset MSW.\n**     2. The log offset LSW.\n**     3. Log checksum 0.\n**     4. Log checksum 1.\n**\n**     Note that the \"log offset\" is not the literal byte offset. Instead,\n**     it is the byte offset multiplied by 2, with least significant bit\n**     toggled each time the log pointer value is changed. This is to make\n**     sure that this field changes each time the log pointer is updated,\n**     even if the log file itself is disabled. See lsmTreeMakeOld().\n**\n**     See ckptExportLog() and ckptImportLog().\n**\n**   Append points:\n**\n**     8 integers (4 * 64-bit page numbers). See ckptExportAppendlist().\n**\n**   For each level in the database, a level record. Formatted as follows:\n**\n**     0. Age of the level (least significant 16-bits). And flags mask (most\n**        significant 16-bits).\n**     1. The number of right-hand segments (nRight, possibly 0),\n**     2. Segment record for left-hand segment (8 integers defined below),\n**     3. Segment record for each right-hand segment (8 integers defined below),\n**     4. If nRight>0, The number of segments involved in the merge\n**     5. if nRight>0, Current nSkip value (see Merge structure defn.),\n**     6. For each segment in the merge:\n**        5a. Page number of next cell to read during merge (this field\n**            is 64-bits - 2 integers)\n**        5b. Cell number of next cell to read during merge\n**     7. Page containing current split-key (64-bits - 2 integers).\n**     8. Cell within page containing current split-key.\n**     9. Current pointer value (64-bits - 2 integers).\n**\n**   The block redirect array:\n**\n**     1. Number of redirections (maximum LSM_MAX_BLOCK_REDIRECTS).\n**     2. For each redirection:\n**        a. \"from\" block number\n**        b. \"to\" block number\n**\n**   The in-memory freelist entries. Each entry is either an insert or a\n**   delete. The in-memory freelist is to the free-block-list as the\n**   in-memory tree is to the users database content.\n**\n**     1. Number of free-list entries stored in checkpoint header.\n**     2. Number of free blocks (in total).\n**     3. Total number of blocks freed during database lifetime.\n**     4. For each entry:\n**        2a. Block number of free block.\n**        2b. A 64-bit integer (MSW followed by LSW). -1 for a delete entry,\n**            or the associated checkpoint id for an insert.\n**\n**   The checksum:\n**\n**     1. Checksum value 1.\n**     2. Checksum value 2.\n**\n** In the above, a segment record consists of the following four 64-bit \n** fields (converted to 2 * u32 by storing the MSW followed by LSW):\n**\n**     1. First page of array,\n**     2. Last page of array,\n**     3. Root page of array (or 0),\n**     4. Size of array in pages.\n*/\n\n/*\n** LARGE NUMBERS OF LEVEL RECORDS:\n**\n** A limit on the number of rhs segments that may be present in the database\n** file. Defining this limit ensures that all level records fit within\n** the 4096 byte limit for checkpoint blobs.\n**\n** The number of right-hand-side segments in a database is counted as \n** follows:\n**\n**   * For each level in the database not undergoing a merge, add 1.\n**\n**   * For each level in the database that is undergoing a merge, add \n**     the number of segments on the rhs of the level.\n**\n** A level record not undergoing a merge is 10 integers. A level record \n** with nRhs rhs segments and (nRhs+1) input segments (i.e. including the \n** separators from the next level) is (11*nRhs+20) integers. The maximum\n** per right-hand-side level is therefore 21 integers. So the maximum\n** size of all level records in a checkpoint is 21*40=820 integers.\n**\n** TODO: Before pointer values were changed from 32 to 64 bits, the above\n** used to come to 420 bytes - leaving significant space for a free-list\n** prefix. No more. To fix this, reduce the size of the level records in\n** a db snapshot, and improve management of the free-list tail in \n** lsm_sorted.c. \n*/\n#define LSM_MAX_RHS_SEGMENTS 40\n\n/*\n** LARGE NUMBERS OF FREELIST ENTRIES:\n**\n** There is also a limit (LSM_MAX_FREELIST_ENTRIES - defined in lsmInt.h)\n** on the number of free-list entries stored in a checkpoint. Since each \n** free-list entry consists of 3 integers, the maximum free-list size is \n** 3*100=300 integers. Combined with the limit on rhs segments defined\n** above, this ensures that a checkpoint always fits within a 4096 byte\n** meta page.\n**\n** If the database contains more than 100 free blocks, the \"overflow\" flag\n** in the checkpoint header is set and the remainder are stored in the\n** system FREELIST entry in the LSM (along with user data). The value\n** accompanying the FREELIST key in the LSM is, like a checkpoint, an array\n** of 32-bit big-endian integers. As follows:\n**\n**     For each entry:\n**       a. Block number of free block.\n**       b. MSW of associated checkpoint id.\n**       c. LSW of associated checkpoint id.\n**\n** The number of entries is not required - it is implied by the size of the\n** value blob containing the integer array.\n**\n** Note that the limit defined by LSM_MAX_FREELIST_ENTRIES is a hard limit.\n** The actual value used may be configured using LSM_CONFIG_MAX_FREELIST.\n*/\n\n/*\n** The argument to this macro must be of type u32. On a little-endian\n** architecture, it returns the u32 value that results from interpreting\n** the 4 bytes as a big-endian value. On a big-endian architecture, it\n** returns the value that would be produced by intepreting the 4 bytes\n** of the input value as a little-endian integer.\n*/\n#define BYTESWAP32(x) ( \\\n   (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \\\n + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \\\n)\n\nstatic const int one = 1;\n#define LSM_LITTLE_ENDIAN (*(u8 *)(&one))\n\n/* Sizes, in integers, of various parts of the checkpoint. */\n#define CKPT_HDR_SIZE         9\n#define CKPT_LOGPTR_SIZE      4\n#define CKPT_APPENDLIST_SIZE  (LSM_APPLIST_SZ * 2)\n\n/* A #define to describe each integer in the checkpoint header. */\n#define CKPT_HDR_ID_MSW   0\n#define CKPT_HDR_ID_LSW   1\n#define CKPT_HDR_NCKPT    2\n#define CKPT_HDR_CMPID    3\n#define CKPT_HDR_NBLOCK   4\n#define CKPT_HDR_BLKSZ    5\n#define CKPT_HDR_NLEVEL   6\n#define CKPT_HDR_PGSZ     7\n#define CKPT_HDR_NWRITE   8\n\n#define CKPT_HDR_LO_MSW     9\n#define CKPT_HDR_LO_LSW    10\n#define CKPT_HDR_LO_CKSUM1 11\n#define CKPT_HDR_LO_CKSUM2 12\n\ntypedef struct CkptBuffer CkptBuffer;\n\n/*\n** Dynamic buffer used to accumulate data for a checkpoint.\n*/\nstruct CkptBuffer {\n  lsm_env *pEnv;\n  int nAlloc;\n  u32 *aCkpt;\n};\n\n/*\n** Calculate the checksum of the checkpoint specified by arguments aCkpt and\n** nCkpt. Store the checksum in *piCksum1 and *piCksum2 before returning.\n**\n** The value of the nCkpt parameter includes the two checksum values at\n** the end of the checkpoint. They are not used as inputs to the checksum \n** calculation. The checksum is based on the array of (nCkpt-2) integers\n** at aCkpt[].\n*/\nstatic void ckptChecksum(u32 *aCkpt, u32 nCkpt, u32 *piCksum1, u32 *piCksum2){\n  u32 i;\n  u32 cksum1 = 1;\n  u32 cksum2 = 2;\n\n  if( nCkpt % 2 ){\n    cksum1 += aCkpt[nCkpt-3] & 0x0000FFFF;\n    cksum2 += aCkpt[nCkpt-3] & 0xFFFF0000;\n  }\n\n  for(i=0; (i+3)<nCkpt; i+=2){\n    cksum1 += cksum2 + aCkpt[i];\n    cksum2 += cksum1 + aCkpt[i+1];\n  }\n\n  *piCksum1 = cksum1;\n  *piCksum2 = cksum2;\n}\n\n/*\n** Set integer iIdx of the checkpoint accumulating in buffer *p to iVal.\n*/\nstatic void ckptSetValue(CkptBuffer *p, int iIdx, u32 iVal, int *pRc){\n  if( *pRc ) return;\n  if( iIdx>=p->nAlloc ){\n    int nNew = LSM_MAX(8, iIdx*2);\n    p->aCkpt = (u32 *)lsmReallocOrFree(p->pEnv, p->aCkpt, nNew*sizeof(u32));\n    if( !p->aCkpt ){\n      *pRc = LSM_NOMEM_BKPT;\n      return;\n    }\n    p->nAlloc = nNew;\n  }\n  p->aCkpt[iIdx] = iVal;\n}\n\n/*\n** Argument aInt points to an array nInt elements in size. Switch the \n** endian-ness of each element of the array.\n*/\nstatic void ckptChangeEndianness(u32 *aInt, int nInt){\n  if( LSM_LITTLE_ENDIAN ){\n    int i;\n    for(i=0; i<nInt; i++) aInt[i] = BYTESWAP32(aInt[i]);\n  }\n}\n\n/*\n** Object *p contains a checkpoint in native byte-order. The checkpoint is\n** nCkpt integers in size, not including any checksum. This function sets\n** the two checksum elements of the checkpoint accordingly.\n*/\nstatic void ckptAddChecksum(CkptBuffer *p, int nCkpt, int *pRc){\n  if( *pRc==LSM_OK ){\n    u32 aCksum[2] = {0, 0};\n    ckptChecksum(p->aCkpt, nCkpt+2, &aCksum[0], &aCksum[1]);\n    ckptSetValue(p, nCkpt, aCksum[0], pRc);\n    ckptSetValue(p, nCkpt+1, aCksum[1], pRc);\n  }\n}\n\nstatic void ckptAppend64(CkptBuffer *p, int *piOut, i64 iVal, int *pRc){\n  int iOut = *piOut;\n  ckptSetValue(p, iOut++, (iVal >> 32) & 0xFFFFFFFF, pRc);\n  ckptSetValue(p, iOut++, (iVal & 0xFFFFFFFF), pRc);\n  *piOut = iOut;\n}\n\nstatic i64 ckptRead64(u32 *a){\n  return (((i64)a[0]) << 32) + (i64)a[1];\n}\n\nstatic i64 ckptGobble64(u32 *a, int *piIn){\n  int iIn = *piIn;\n  *piIn += 2;\n  return ckptRead64(&a[iIn]);\n}\n\n\n/*\n** Append a 6-value segment record corresponding to pSeg to the checkpoint \n** buffer passed as the third argument.\n*/\nstatic void ckptExportSegment(\n  Segment *pSeg, \n  CkptBuffer *p, \n  int *piOut, \n  int *pRc\n){\n  ckptAppend64(p, piOut, pSeg->iFirst, pRc);\n  ckptAppend64(p, piOut, pSeg->iLastPg, pRc);\n  ckptAppend64(p, piOut, pSeg->iRoot, pRc);\n  ckptAppend64(p, piOut, pSeg->nSize, pRc);\n}\n\nstatic void ckptExportLevel(\n  Level *pLevel,                  /* Level object to serialize */\n  CkptBuffer *p,                  /* Append new level record to this ckpt */\n  int *piOut,                     /* IN/OUT: Size of checkpoint so far */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int iOut = *piOut;\n  Merge *pMerge;\n\n  pMerge = pLevel->pMerge;\n  ckptSetValue(p, iOut++, (u32)pLevel->iAge + (u32)(pLevel->flags<<16), pRc);\n  ckptSetValue(p, iOut++, pLevel->nRight, pRc);\n  ckptExportSegment(&pLevel->lhs, p, &iOut, pRc);\n\n  assert( (pLevel->nRight>0)==(pMerge!=0) );\n  if( pMerge ){\n    int i;\n    for(i=0; i<pLevel->nRight; i++){\n      ckptExportSegment(&pLevel->aRhs[i], p, &iOut, pRc);\n    }\n    assert( pMerge->nInput==pLevel->nRight \n         || pMerge->nInput==pLevel->nRight+1 \n    );\n    ckptSetValue(p, iOut++, pMerge->nInput, pRc);\n    ckptSetValue(p, iOut++, pMerge->nSkip, pRc);\n    for(i=0; i<pMerge->nInput; i++){\n      ckptAppend64(p, &iOut, pMerge->aInput[i].iPg, pRc);\n      ckptSetValue(p, iOut++, pMerge->aInput[i].iCell, pRc);\n    }\n    ckptAppend64(p, &iOut, pMerge->splitkey.iPg, pRc);\n    ckptSetValue(p, iOut++, pMerge->splitkey.iCell, pRc);\n    ckptAppend64(p, &iOut, pMerge->iCurrentPtr, pRc);\n  }\n\n  *piOut = iOut;\n}\n\n/*\n** Populate the log offset fields of the checkpoint buffer. 4 values.\n*/\nstatic void ckptExportLog(\n  lsm_db *pDb, \n  int bFlush,\n  CkptBuffer *p, \n  int *piOut, \n  int *pRc\n){\n  int iOut = *piOut;\n\n  assert( iOut==CKPT_HDR_LO_MSW );\n\n  if( bFlush ){\n    i64 iOff = pDb->treehdr.iOldLog;\n    ckptAppend64(p, &iOut, iOff, pRc);\n    ckptSetValue(p, iOut++, pDb->treehdr.oldcksum0, pRc);\n    ckptSetValue(p, iOut++, pDb->treehdr.oldcksum1, pRc);\n  }else{\n    for(; iOut<=CKPT_HDR_LO_CKSUM2; iOut++){\n      ckptSetValue(p, iOut, pDb->pShmhdr->aSnap2[iOut], pRc);\n    }\n  }\n\n  assert( *pRc || iOut==CKPT_HDR_LO_CKSUM2+1 );\n  *piOut = iOut;\n}\n\nstatic void ckptExportAppendlist(\n  lsm_db *db,                     /* Database connection */\n  CkptBuffer *p,                  /* Checkpoint buffer to write to */\n  int *piOut,                     /* IN/OUT: Offset within checkpoint buffer */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;\n  Pgno *aiAppend = db->pWorker->aiAppend;\n\n  for(i=0; i<LSM_APPLIST_SZ; i++){\n    ckptAppend64(p, piOut, aiAppend[i], pRc);\n  }\n};\n\nstatic int ckptExportSnapshot( \n  lsm_db *pDb,                    /* Connection handle */\n  int bLog,                       /* True to update log-offset fields */\n  i64 iId,                        /* Checkpoint id */\n  int bCksum,                     /* If true, include checksums */\n  void **ppCkpt,                  /* OUT: Buffer containing checkpoint */\n  int *pnCkpt                     /* OUT: Size of checkpoint in bytes */\n){\n  int rc = LSM_OK;                /* Return Code */\n  FileSystem *pFS = pDb->pFS;     /* File system object */\n  Snapshot *pSnap = pDb->pWorker; /* Worker snapshot */\n  int nLevel = 0;                 /* Number of levels in checkpoint */\n  int iLevel;                     /* Used to count out nLevel levels */\n  int iOut = 0;                   /* Current offset in aCkpt[] */\n  Level *pLevel;                  /* Level iterator */\n  int i;                          /* Iterator used while serializing freelist */\n  CkptBuffer ckpt;\n\n  /* Initialize the output buffer */\n  memset(&ckpt, 0, sizeof(CkptBuffer));\n  ckpt.pEnv = pDb->pEnv;\n  iOut = CKPT_HDR_SIZE;\n\n  /* Write the log offset into the checkpoint. */\n  ckptExportLog(pDb, bLog, &ckpt, &iOut, &rc);\n\n  /* Write the append-point list */\n  ckptExportAppendlist(pDb, &ckpt, &iOut, &rc);\n\n  /* Figure out how many levels will be written to the checkpoint. */\n  for(pLevel=lsmDbSnapshotLevel(pSnap); pLevel; pLevel=pLevel->pNext) nLevel++;\n\n  /* Serialize nLevel levels. */\n  iLevel = 0;\n  for(pLevel=lsmDbSnapshotLevel(pSnap); iLevel<nLevel; pLevel=pLevel->pNext){\n    ckptExportLevel(pLevel, &ckpt, &iOut, &rc);\n    iLevel++;\n  }\n\n  /* Write the block-redirect list */\n  ckptSetValue(&ckpt, iOut++, pSnap->redirect.n, &rc);\n  for(i=0; i<pSnap->redirect.n; i++){\n    ckptSetValue(&ckpt, iOut++, pSnap->redirect.a[i].iFrom, &rc);\n    ckptSetValue(&ckpt, iOut++, pSnap->redirect.a[i].iTo, &rc);\n  }\n\n  /* Write the freelist */\n  assert( pSnap->freelist.nEntry<=pDb->nMaxFreelist );\n  if( rc==LSM_OK ){\n    int nFree = pSnap->freelist.nEntry;\n    ckptSetValue(&ckpt, iOut++, nFree, &rc);\n    for(i=0; i<nFree; i++){\n      FreelistEntry *p = &pSnap->freelist.aEntry[i];\n      ckptSetValue(&ckpt, iOut++, p->iBlk, &rc);\n      ckptSetValue(&ckpt, iOut++, (p->iId >> 32) & 0xFFFFFFFF, &rc);\n      ckptSetValue(&ckpt, iOut++, p->iId & 0xFFFFFFFF, &rc);\n    }\n  }\n\n  /* Write the checkpoint header */\n  assert( iId>=0 );\n  assert( pSnap->iCmpId==pDb->compress.iId\n       || pSnap->iCmpId==LSM_COMPRESSION_EMPTY \n  );\n  ckptSetValue(&ckpt, CKPT_HDR_ID_MSW, (u32)(iId>>32), &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_ID_LSW, (u32)(iId&0xFFFFFFFF), &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_NCKPT, iOut+2, &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_CMPID, pDb->compress.iId, &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_NBLOCK, pSnap->nBlock, &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_BLKSZ, lsmFsBlockSize(pFS), &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_NLEVEL, nLevel, &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_PGSZ, lsmFsPageSize(pFS), &rc);\n  ckptSetValue(&ckpt, CKPT_HDR_NWRITE, pSnap->nWrite, &rc);\n\n  if( bCksum ){\n    ckptAddChecksum(&ckpt, iOut, &rc);\n  }else{\n    ckptSetValue(&ckpt, iOut, 0, &rc);\n    ckptSetValue(&ckpt, iOut+1, 0, &rc);\n  }\n  iOut += 2;\n  assert( iOut<=1024 );\n\n#ifdef LSM_LOG_FREELIST\n  lsmLogMessage(pDb, rc, \n      \"ckptExportSnapshot(): id=%lld freelist: %d\", iId, pSnap->freelist.nEntry\n  );\n  for(i=0; i<pSnap->freelist.nEntry; i++){\n  lsmLogMessage(pDb, rc, \n      \"ckptExportSnapshot(): iBlk=%d id=%lld\", \n      pSnap->freelist.aEntry[i].iBlk,\n      pSnap->freelist.aEntry[i].iId\n  );\n  }\n#endif\n\n  *ppCkpt = (void *)ckpt.aCkpt;\n  if( pnCkpt ) *pnCkpt = sizeof(u32)*iOut;\n  return rc;\n}\n\n\n/*\n** Helper function for ckptImport().\n*/\nstatic void ckptNewSegment(\n  u32 *aIn,\n  int *piIn,\n  Segment *pSegment               /* Populate this structure */\n){\n  assert( pSegment->iFirst==0 && pSegment->iLastPg==0 );\n  assert( pSegment->nSize==0 && pSegment->iRoot==0 );\n  pSegment->iFirst = ckptGobble64(aIn, piIn);\n  pSegment->iLastPg = ckptGobble64(aIn, piIn);\n  pSegment->iRoot = ckptGobble64(aIn, piIn);\n  pSegment->nSize = (int)ckptGobble64(aIn, piIn);\n  assert( pSegment->iFirst );\n}\n\nstatic int ckptSetupMerge(lsm_db *pDb, u32 *aInt, int *piIn, Level *pLevel){\n  Merge *pMerge;                  /* Allocated Merge object */\n  int nInput;                     /* Number of input segments in merge */\n  int iIn = *piIn;                /* Next value to read from aInt[] */\n  int i;                          /* Iterator variable */\n  int nByte;                      /* Number of bytes to allocate */\n\n  /* Allocate the Merge object. If malloc() fails, return LSM_NOMEM. */\n  nInput = (int)aInt[iIn++];\n  nByte = sizeof(Merge) + sizeof(MergeInput) * nInput;\n  pMerge = (Merge *)lsmMallocZero(pDb->pEnv, nByte);\n  if( !pMerge ) return LSM_NOMEM_BKPT;\n  pLevel->pMerge = pMerge;\n\n  /* Populate the Merge object. */\n  pMerge->aInput = (MergeInput *)&pMerge[1];\n  pMerge->nInput = nInput;\n  pMerge->iOutputOff = -1;\n  pMerge->nSkip = (int)aInt[iIn++];\n  for(i=0; i<nInput; i++){\n    pMerge->aInput[i].iPg = ckptGobble64(aInt, &iIn);\n    pMerge->aInput[i].iCell = (int)aInt[iIn++];\n  }\n  pMerge->splitkey.iPg = ckptGobble64(aInt, &iIn);\n  pMerge->splitkey.iCell = (int)aInt[iIn++];\n  pMerge->iCurrentPtr = ckptGobble64(aInt, &iIn);\n\n  /* Set *piIn and return LSM_OK. */\n  *piIn = iIn;\n  return LSM_OK;\n}\n\n\nstatic int ckptLoadLevels(\n  lsm_db *pDb,\n  u32 *aIn, \n  int *piIn, \n  int nLevel,\n  Level **ppLevel\n){\n  int i;\n  int rc = LSM_OK;\n  Level *pRet = 0;\n  Level **ppNext;\n  int iIn = *piIn;\n\n  ppNext = &pRet;\n  for(i=0; rc==LSM_OK && i<nLevel; i++){\n    int iRight;\n    Level *pLevel;\n\n    /* Allocate space for the Level structure and Level.apRight[] array */\n    pLevel = (Level *)lsmMallocZeroRc(pDb->pEnv, sizeof(Level), &rc);\n    if( rc==LSM_OK ){\n      pLevel->iAge = (u16)(aIn[iIn] & 0x0000FFFF);\n      pLevel->flags = (u16)((aIn[iIn]>>16) & 0x0000FFFF);\n      iIn++;\n      pLevel->nRight = aIn[iIn++];\n      if( pLevel->nRight ){\n        int nByte = sizeof(Segment) * pLevel->nRight;\n        pLevel->aRhs = (Segment *)lsmMallocZeroRc(pDb->pEnv, nByte, &rc);\n      }\n      if( rc==LSM_OK ){\n        *ppNext = pLevel;\n        ppNext = &pLevel->pNext;\n\n        /* Allocate the main segment */\n        ckptNewSegment(aIn, &iIn, &pLevel->lhs);\n\n        /* Allocate each of the right-hand segments, if any */\n        for(iRight=0; iRight<pLevel->nRight; iRight++){\n          ckptNewSegment(aIn, &iIn, &pLevel->aRhs[iRight]);\n        }\n\n        /* Set up the Merge object, if required */\n        if( pLevel->nRight>0 ){\n          rc = ckptSetupMerge(pDb, aIn, &iIn, pLevel);\n        }\n      }\n    }\n  }\n\n  if( rc!=LSM_OK ){\n    /* An OOM must have occurred. Free any level structures allocated and\n    ** return the error to the caller. */\n    lsmSortedFreeLevel(pDb->pEnv, pRet);\n    pRet = 0;\n  }\n\n  *ppLevel = pRet;\n  *piIn = iIn;\n  return rc;\n}\n\n\nint lsmCheckpointLoadLevels(lsm_db *pDb, void *pVal, int nVal){\n  int rc = LSM_OK;\n  if( nVal>0 ){\n    u32 *aIn;\n\n    aIn = lsmMallocRc(pDb->pEnv, nVal, &rc);\n    if( aIn ){\n      Level *pLevel = 0;\n      Level *pParent;\n\n      int nIn;\n      int nLevel;\n      int iIn = 1;\n      memcpy(aIn, pVal, nVal);\n      nIn = nVal / sizeof(u32);\n\n      ckptChangeEndianness(aIn, nIn);\n      nLevel = aIn[0];\n      rc = ckptLoadLevels(pDb, aIn, &iIn, nLevel, &pLevel);\n      lsmFree(pDb->pEnv, aIn);\n      assert( rc==LSM_OK || pLevel==0 );\n      if( rc==LSM_OK ){\n        pParent = lsmDbSnapshotLevel(pDb->pWorker);\n        assert( pParent );\n        while( pParent->pNext ) pParent = pParent->pNext;\n        pParent->pNext = pLevel;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return the data for the LEVELS record.\n**\n** The size of the checkpoint that can be stored in the database header\n** must not exceed 1024 32-bit integers. Normally, it does not. However,\n** if it does, part of the checkpoint must be stored in the LSM. This\n** routine returns that part.\n*/\nint lsmCheckpointLevels(\n  lsm_db *pDb,                    /* Database handle */\n  int nLevel,                     /* Number of levels to write to blob */\n  void **paVal,                   /* OUT: Pointer to LEVELS blob */\n  int *pnVal                      /* OUT: Size of LEVELS blob in bytes */\n){\n  Level *p;                       /* Used to iterate through levels */\n  int nAll= 0;\n  int rc;\n  int i;\n  int iOut;\n  CkptBuffer ckpt;\n  assert( nLevel>0 );\n\n  for(p=lsmDbSnapshotLevel(pDb->pWorker); p; p=p->pNext) nAll++;\n\n  assert( nAll>nLevel );\n  nAll -= nLevel;\n  for(p=lsmDbSnapshotLevel(pDb->pWorker); p && nAll>0; p=p->pNext) nAll--;\n\n  memset(&ckpt, 0, sizeof(CkptBuffer));\n  ckpt.pEnv = pDb->pEnv;\n\n  ckptSetValue(&ckpt, 0, nLevel, &rc);\n  iOut = 1;\n  for(i=0; rc==LSM_OK && i<nLevel; i++){\n    ckptExportLevel(p, &ckpt, &iOut, &rc);\n    p = p->pNext;\n  }\n  assert( rc!=LSM_OK || p==0 );\n\n  if( rc==LSM_OK ){\n    ckptChangeEndianness(ckpt.aCkpt, iOut);\n    *paVal = (void *)ckpt.aCkpt;\n    *pnVal = iOut * sizeof(u32);\n  }else{\n    *pnVal = 0;\n    *paVal = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Read the checkpoint id from meta-page pPg.\n*/\nstatic i64 ckptLoadId(MetaPage *pPg){\n  i64 ret = 0;\n  if( pPg ){\n    int nData;\n    u8 *aData = lsmFsMetaPageData(pPg, &nData);\n    ret = (((i64)lsmGetU32(&aData[CKPT_HDR_ID_MSW*4])) << 32) + \n          ((i64)lsmGetU32(&aData[CKPT_HDR_ID_LSW*4]));\n  }\n  return ret;\n}\n\n/*\n** Return true if the buffer passed as an argument contains a valid\n** checkpoint.\n*/\nstatic int ckptChecksumOk(u32 *aCkpt){\n  u32 nCkpt = aCkpt[CKPT_HDR_NCKPT];\n  u32 cksum1;\n  u32 cksum2;\n\n  if( nCkpt<CKPT_HDR_NCKPT || nCkpt>(LSM_META_RW_PAGE_SIZE)/sizeof(u32) ){\n    return 0;\n  }\n  ckptChecksum(aCkpt, nCkpt, &cksum1, &cksum2);\n  return (cksum1==aCkpt[nCkpt-2] && cksum2==aCkpt[nCkpt-1]);\n}\n\n/*\n** Attempt to load a checkpoint from meta page iMeta.\n**\n** This function is a no-op if *pRc is set to any value other than LSM_OK\n** when it is called. If an error occurs, *pRc is set to an LSM error code\n** before returning.\n**\n** If no error occurs and the checkpoint is successfully loaded, copy it to\n** ShmHeader.aSnap1[] and ShmHeader.aSnap2[], and set ShmHeader.iMetaPage \n** to indicate its origin. In this case return 1. Or, if the checkpoint \n** cannot be loaded (because the checksum does not compute), return 0.\n*/\nstatic int ckptTryLoad(lsm_db *pDb, MetaPage *pPg, u32 iMeta, int *pRc){\n  int bLoaded = 0;                /* Return value */\n  if( *pRc==LSM_OK ){\n    int rc = LSM_OK;              /* Error code */\n    u32 *aCkpt = 0;               /* Pointer to buffer containing checkpoint */\n    u32 nCkpt;                    /* Number of elements in aCkpt[] */\n    int nData;                    /* Bytes of data in aData[] */\n    u8 *aData;                    /* Meta page data */\n   \n    aData = lsmFsMetaPageData(pPg, &nData);\n    nCkpt = (u32)lsmGetU32(&aData[CKPT_HDR_NCKPT*sizeof(u32)]);\n    if( nCkpt<=nData/sizeof(u32) && nCkpt>CKPT_HDR_NCKPT ){\n      aCkpt = (u32 *)lsmMallocRc(pDb->pEnv, nCkpt*sizeof(u32), &rc);\n    }\n    if( aCkpt ){\n      memcpy(aCkpt, aData, nCkpt*sizeof(u32));\n      ckptChangeEndianness(aCkpt, nCkpt);\n      if( ckptChecksumOk(aCkpt) ){\n        ShmHeader *pShm = pDb->pShmhdr;\n        memcpy(pShm->aSnap1, aCkpt, nCkpt*sizeof(u32));\n        memcpy(pShm->aSnap2, aCkpt, nCkpt*sizeof(u32));\n        memcpy(pDb->aSnapshot, aCkpt, nCkpt*sizeof(u32));\n        pShm->iMetaPage = iMeta;\n        bLoaded = 1;\n      }\n    }\n\n    lsmFree(pDb->pEnv, aCkpt);\n    *pRc = rc;\n  }\n  return bLoaded;\n}\n\n/*\n** Initialize the shared-memory header with an empty snapshot. This function\n** is called when no valid snapshot can be found in the database header.\n*/\nstatic void ckptLoadEmpty(lsm_db *pDb){\n  u32 aCkpt[] = {\n    0,                       /* CKPT_HDR_ID_MSW */\n    10,                      /* CKPT_HDR_ID_LSW */\n    0,                       /* CKPT_HDR_NCKPT */\n    LSM_COMPRESSION_EMPTY,   /* CKPT_HDR_CMPID */\n    0,                       /* CKPT_HDR_NBLOCK */\n    0,                       /* CKPT_HDR_BLKSZ */\n    0,                       /* CKPT_HDR_NLEVEL */\n    0,                       /* CKPT_HDR_PGSZ */\n    0,                       /* CKPT_HDR_NWRITE */\n    0, 0, 1234, 5678,        /* The log pointer and initial checksum */\n    0,0,0,0, 0,0,0,0,        /* The append list */\n    0,                       /* The redirected block list */\n    0,                       /* The free block list */\n    0, 0                     /* Space for checksum values */\n  };\n  u32 nCkpt = array_size(aCkpt);\n  ShmHeader *pShm = pDb->pShmhdr;\n\n  aCkpt[CKPT_HDR_NCKPT] = nCkpt;\n  aCkpt[CKPT_HDR_BLKSZ] = pDb->nDfltBlksz;\n  aCkpt[CKPT_HDR_PGSZ] = pDb->nDfltPgsz;\n  ckptChecksum(aCkpt, array_size(aCkpt), &aCkpt[nCkpt-2], &aCkpt[nCkpt-1]);\n\n  memcpy(pShm->aSnap1, aCkpt, nCkpt*sizeof(u32));\n  memcpy(pShm->aSnap2, aCkpt, nCkpt*sizeof(u32));\n  memcpy(pDb->aSnapshot, aCkpt, nCkpt*sizeof(u32));\n}\n\n/*\n** This function is called as part of database recovery to initialize the\n** ShmHeader.aSnap1[] and ShmHeader.aSnap2[] snapshots.\n*/\nint lsmCheckpointRecover(lsm_db *pDb){\n  int rc = LSM_OK;                /* Return Code */\n  i64 iId1;                       /* Id of checkpoint on meta-page 1 */\n  i64 iId2;                       /* Id of checkpoint on meta-page 2 */\n  int bLoaded = 0;                /* True once checkpoint has been loaded */\n  int cmp;                        /* True if (iId2>iId1) */\n  MetaPage *apPg[2] = {0, 0};     /* Meta-pages 1 and 2 */\n\n  rc = lsmFsMetaPageGet(pDb->pFS, 0, 1, &apPg[0]);\n  if( rc==LSM_OK ) rc = lsmFsMetaPageGet(pDb->pFS, 0, 2, &apPg[1]);\n\n  iId1 = ckptLoadId(apPg[0]);\n  iId2 = ckptLoadId(apPg[1]);\n  cmp = (iId2 > iId1);\n  bLoaded = ckptTryLoad(pDb, apPg[cmp?1:0], (cmp?2:1), &rc);\n  if( bLoaded==0 ){\n    bLoaded = ckptTryLoad(pDb, apPg[cmp?0:1], (cmp?1:2), &rc);\n  }\n\n  /* The database does not contain a valid checkpoint. Initialize the shared\n  ** memory header with an empty checkpoint.  */\n  if( bLoaded==0 ){\n    ckptLoadEmpty(pDb);\n  }\n\n  lsmFsMetaPageRelease(apPg[0]);\n  lsmFsMetaPageRelease(apPg[1]);\n\n  return rc;\n}\n\n/* \n** Store the snapshot in pDb->aSnapshot[] in meta-page iMeta.\n*/\nint lsmCheckpointStore(lsm_db *pDb, int iMeta){\n  MetaPage *pPg = 0;\n  int rc;\n\n  assert( iMeta==1 || iMeta==2 );\n  rc = lsmFsMetaPageGet(pDb->pFS, 1, iMeta, &pPg);\n  if( rc==LSM_OK ){\n    u8 *aData;\n    int nData;\n    int nCkpt;\n\n    nCkpt = (int)pDb->aSnapshot[CKPT_HDR_NCKPT];\n    aData = lsmFsMetaPageData(pPg, &nData);\n    memcpy(aData, pDb->aSnapshot, nCkpt*sizeof(u32));\n    ckptChangeEndianness((u32 *)aData, nCkpt);\n    rc = lsmFsMetaPageRelease(pPg);\n  }\n      \n  return rc;\n}\n\n/*\n** Copy the current client snapshot from shared-memory to pDb->aSnapshot[].\n*/\nint lsmCheckpointLoad(lsm_db *pDb, int *piRead){\n  int nRem = LSM_ATTEMPTS_BEFORE_PROTOCOL;\n  ShmHeader *pShm = pDb->pShmhdr;\n  while( (nRem--)>0 ){\n    int nInt;\n\n    nInt = pShm->aSnap1[CKPT_HDR_NCKPT];\n    if( nInt<=(LSM_META_RW_PAGE_SIZE / sizeof(u32)) ){\n      memcpy(pDb->aSnapshot, pShm->aSnap1, nInt*sizeof(u32));\n      if( ckptChecksumOk(pDb->aSnapshot) ){\n        if( piRead ) *piRead = 1;\n        return LSM_OK;\n      }\n    }\n\n    nInt = pShm->aSnap2[CKPT_HDR_NCKPT];\n    if( nInt<=(LSM_META_RW_PAGE_SIZE / sizeof(u32)) ){\n      memcpy(pDb->aSnapshot, pShm->aSnap2, nInt*sizeof(u32));\n      if( ckptChecksumOk(pDb->aSnapshot) ){\n        if( piRead ) *piRead = 2;\n        return LSM_OK;\n      }\n    }\n\n    lsmShmBarrier(pDb);\n  }\n  return LSM_PROTOCOL_BKPT;\n}\n\nint lsmInfoCompressionId(lsm_db *db, u32 *piCmpId){\n  int rc;\n\n  assert( db->pClient==0 && db->pWorker==0 );\n  rc = lsmCheckpointLoad(db, 0);\n  if( rc==LSM_OK ){\n    *piCmpId = db->aSnapshot[CKPT_HDR_CMPID];\n  }\n\n  return rc;\n}\n\nint lsmCheckpointLoadOk(lsm_db *pDb, int iSnap){\n  u32 *aShm;\n  assert( iSnap==1 || iSnap==2 );\n  aShm = (iSnap==1) ? pDb->pShmhdr->aSnap1 : pDb->pShmhdr->aSnap2;\n  return (lsmCheckpointId(pDb->aSnapshot, 0)==lsmCheckpointId(aShm, 0) );\n}\n\nint lsmCheckpointClientCacheOk(lsm_db *pDb){\n  return ( pDb->pClient \n        && pDb->pClient->iId==lsmCheckpointId(pDb->aSnapshot, 0)\n        && pDb->pClient->iId==lsmCheckpointId(pDb->pShmhdr->aSnap1, 0)\n        && pDb->pClient->iId==lsmCheckpointId(pDb->pShmhdr->aSnap2, 0)\n  );\n}\n\nint lsmCheckpointLoadWorker(lsm_db *pDb){\n  int rc;\n  ShmHeader *pShm = pDb->pShmhdr;\n  int nInt1;\n  int nInt2;\n\n  /* Must be holding the WORKER lock to do this. Or DMS2. */\n  assert( \n      lsmShmAssertLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_EXCL) \n   || lsmShmAssertLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_EXCL) \n  );\n\n  /* Check that the two snapshots match. If not, repair them. */\n  nInt1 = pShm->aSnap1[CKPT_HDR_NCKPT];\n  nInt2 = pShm->aSnap2[CKPT_HDR_NCKPT];\n  if( nInt1!=nInt2 || memcmp(pShm->aSnap1, pShm->aSnap2, nInt2*sizeof(u32)) ){\n    if( ckptChecksumOk(pShm->aSnap1) ){\n      memcpy(pShm->aSnap2, pShm->aSnap1, sizeof(u32)*nInt1);\n    }else if( ckptChecksumOk(pShm->aSnap2) ){\n      memcpy(pShm->aSnap1, pShm->aSnap2, sizeof(u32)*nInt2);\n    }else{\n      return LSM_PROTOCOL_BKPT;\n    }\n  }\n\n  rc = lsmCheckpointDeserialize(pDb, 1, pShm->aSnap1, &pDb->pWorker);\n  if( pDb->pWorker ) pDb->pWorker->pDatabase = pDb->pDatabase;\n\n  if( rc==LSM_OK ){\n    rc = lsmCheckCompressionId(pDb, pDb->pWorker->iCmpId);\n  }\n\n#if 0\n  assert( rc!=LSM_OK || lsmFsIntegrityCheck(pDb) );\n#endif\n  return rc;\n}\n\nint lsmCheckpointDeserialize(\n  lsm_db *pDb, \n  int bInclFreelist,              /* If true, deserialize free-list */\n  u32 *aCkpt, \n  Snapshot **ppSnap\n){\n  int rc = LSM_OK;\n  Snapshot *pNew;\n\n  pNew = (Snapshot *)lsmMallocZeroRc(pDb->pEnv, sizeof(Snapshot), &rc);\n  if( rc==LSM_OK ){\n    Level *pLvl;\n    int nFree;\n    int i;\n    int nLevel = (int)aCkpt[CKPT_HDR_NLEVEL];\n    int iIn = CKPT_HDR_SIZE + CKPT_APPENDLIST_SIZE + CKPT_LOGPTR_SIZE;\n\n    pNew->iId = lsmCheckpointId(aCkpt, 0);\n    pNew->nBlock = aCkpt[CKPT_HDR_NBLOCK];\n    pNew->nWrite = aCkpt[CKPT_HDR_NWRITE];\n    rc = ckptLoadLevels(pDb, aCkpt, &iIn, nLevel, &pNew->pLevel);\n    pNew->iLogOff = lsmCheckpointLogOffset(aCkpt);\n    pNew->iCmpId = aCkpt[CKPT_HDR_CMPID];\n\n    /* Make a copy of the append-list */\n    for(i=0; i<LSM_APPLIST_SZ; i++){\n      u32 *a = &aCkpt[CKPT_HDR_SIZE + CKPT_LOGPTR_SIZE + i*2];\n      pNew->aiAppend[i] = ckptRead64(a);\n    }\n\n    /* Read the block-redirect list */\n    pNew->redirect.n = aCkpt[iIn++];\n    if( pNew->redirect.n ){\n      pNew->redirect.a = lsmMallocZeroRc(pDb->pEnv, \n          (sizeof(struct RedirectEntry) * LSM_MAX_BLOCK_REDIRECTS), &rc\n      );\n      if( rc==LSM_OK ){\n        for(i=0; i<pNew->redirect.n; i++){\n          pNew->redirect.a[i].iFrom = aCkpt[iIn++];\n          pNew->redirect.a[i].iTo = aCkpt[iIn++];\n        }\n      }\n      for(pLvl=pNew->pLevel; pLvl->pNext; pLvl=pLvl->pNext);\n      if( pLvl->nRight ){\n        pLvl->aRhs[pLvl->nRight-1].pRedirect = &pNew->redirect;\n      }else{\n        pLvl->lhs.pRedirect = &pNew->redirect;\n      }\n    }\n\n    /* Copy the free-list */\n    if( rc==LSM_OK && bInclFreelist ){\n      nFree = aCkpt[iIn++];\n      if( nFree ){\n        pNew->freelist.aEntry = (FreelistEntry *)lsmMallocZeroRc(\n            pDb->pEnv, sizeof(FreelistEntry)*nFree, &rc\n        );\n        if( rc==LSM_OK ){\n          int j;\n          for(j=0; j<nFree; j++){\n            FreelistEntry *p = &pNew->freelist.aEntry[j];\n            p->iBlk = aCkpt[iIn++];\n            p->iId = ((i64)(aCkpt[iIn])<<32) + aCkpt[iIn+1];\n            iIn += 2;\n          }\n          pNew->freelist.nEntry = pNew->freelist.nAlloc = nFree;\n        }\n      }\n    }\n  }\n\n  if( rc!=LSM_OK ){\n    lsmFreeSnapshot(pDb->pEnv, pNew);\n    pNew = 0;\n  }\n\n  *ppSnap = pNew;\n  return rc;\n}\n\n/*\n** Connection pDb must be the worker connection in order to call this\n** function. It returns true if the database already contains the maximum\n** number of levels or false otherwise.\n**\n** This is used when flushing the in-memory tree to disk. If the database\n** is already full, then the caller should invoke lsm_work() or similar\n** until it is not full before creating a new level by flushing the in-memory\n** tree to disk. Limiting the number of levels in the database ensures that\n** the records describing them always fit within the checkpoint blob.\n*/\nint lsmDatabaseFull(lsm_db *pDb){\n  Level *p;\n  int nRhs = 0;\n\n  assert( lsmShmAssertLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_EXCL) );\n  assert( pDb->pWorker );\n\n  for(p=pDb->pWorker->pLevel; p; p=p->pNext){\n    nRhs += (p->nRight ? p->nRight : 1);\n  }\n\n  return (nRhs >= LSM_MAX_RHS_SEGMENTS);\n}\n\n/*\n** The connection passed as the only argument is currently the worker\n** connection. Some work has been performed on the database by the connection,\n** but no new snapshot has been written into shared memory.\n**\n** This function updates the shared-memory worker and client snapshots with\n** the new snapshot produced by the work performed by pDb.\n**\n** If successful, LSM_OK is returned. Otherwise, if an error occurs, an LSM\n** error code is returned.\n*/\nint lsmCheckpointSaveWorker(lsm_db *pDb, int bFlush){\n  Snapshot *pSnap = pDb->pWorker;\n  ShmHeader *pShm = pDb->pShmhdr;\n  void *p = 0;\n  int n = 0;\n  int rc;\n\n  pSnap->iId++;\n  rc = ckptExportSnapshot(pDb, bFlush, pSnap->iId, 1, &p, &n);\n  if( rc!=LSM_OK ) return rc;\n  assert( ckptChecksumOk((u32 *)p) );\n\n  assert( n<=LSM_META_RW_PAGE_SIZE );\n  memcpy(pShm->aSnap2, p, n);\n  lsmShmBarrier(pDb);\n  memcpy(pShm->aSnap1, p, n);\n  lsmFree(pDb->pEnv, p);\n\n  /* assert( lsmFsIntegrityCheck(pDb) ); */\n  return LSM_OK;\n}\n\n/*\n** This function is used to determine the snapshot-id of the most recently\n** checkpointed snapshot. Variable ShmHeader.iMetaPage indicates which of\n** the two meta-pages said snapshot resides on (if any). \n**\n** If successful, this function loads the snapshot from the meta-page, \n** verifies its checksum and sets *piId to the snapshot-id before returning\n** LSM_OK. Or, if the checksum attempt fails, *piId is set to zero and\n** LSM_OK returned. If an error occurs, an LSM error code is returned and\n** the final value of *piId is undefined.\n*/\nint lsmCheckpointSynced(lsm_db *pDb, i64 *piId, i64 *piLog, u32 *pnWrite){\n  int rc = LSM_OK;\n  MetaPage *pPg;\n  u32 iMeta;\n\n  iMeta = pDb->pShmhdr->iMetaPage;\n  if( iMeta==1 || iMeta==2 ){\n    rc = lsmFsMetaPageGet(pDb->pFS, 0, iMeta, &pPg);\n    if( rc==LSM_OK ){\n      int nCkpt;\n      int nData;\n      u8 *aData; \n\n      aData = lsmFsMetaPageData(pPg, &nData);\n      assert( nData==LSM_META_RW_PAGE_SIZE );\n      nCkpt = lsmGetU32(&aData[CKPT_HDR_NCKPT*sizeof(u32)]);\n      if( nCkpt<(LSM_META_RW_PAGE_SIZE/sizeof(u32)) ){\n        u32 *aCopy = lsmMallocRc(pDb->pEnv, sizeof(u32) * nCkpt, &rc);\n        if( aCopy ){\n          memcpy(aCopy, aData, nCkpt*sizeof(u32));\n          ckptChangeEndianness(aCopy, nCkpt);\n          if( ckptChecksumOk(aCopy) ){\n            if( piId ) *piId = lsmCheckpointId(aCopy, 0);\n            if( piLog ) *piLog = (lsmCheckpointLogOffset(aCopy) >> 1);\n            if( pnWrite ) *pnWrite = aCopy[CKPT_HDR_NWRITE];\n          }\n          lsmFree(pDb->pEnv, aCopy);\n        }\n      }\n      lsmFsMetaPageRelease(pPg);\n    }\n  }\n\n  if( (iMeta!=1 && iMeta!=2) || rc!=LSM_OK || pDb->pShmhdr->iMetaPage!=iMeta ){\n    if( piId ) *piId = 0;\n    if( piLog ) *piLog = 0;\n    if( pnWrite ) *pnWrite = 0;\n  }\n  return rc;\n}\n\n/*\n** Return the checkpoint-id of the checkpoint array passed as the first\n** argument to this function. If the second argument is true, then assume\n** that the checkpoint is made up of 32-bit big-endian integers. If it\n** is false, assume that the integers are in machine byte order.\n*/\ni64 lsmCheckpointId(u32 *aCkpt, int bDisk){\n  i64 iId;\n  if( bDisk ){\n    u8 *aData = (u8 *)aCkpt;\n    iId = (((i64)lsmGetU32(&aData[CKPT_HDR_ID_MSW*4])) << 32);\n    iId += ((i64)lsmGetU32(&aData[CKPT_HDR_ID_LSW*4]));\n  }else{\n    iId = ((i64)aCkpt[CKPT_HDR_ID_MSW] << 32) + (i64)aCkpt[CKPT_HDR_ID_LSW];\n  }\n  return iId;\n}\n\nu32 lsmCheckpointNBlock(u32 *aCkpt){\n  return aCkpt[CKPT_HDR_NBLOCK];\n}\n\nu32 lsmCheckpointNWrite(u32 *aCkpt, int bDisk){\n  if( bDisk ){\n    return lsmGetU32((u8 *)&aCkpt[CKPT_HDR_NWRITE]);\n  }else{\n    return aCkpt[CKPT_HDR_NWRITE];\n  }\n}\n\ni64 lsmCheckpointLogOffset(u32 *aCkpt){\n  return ((i64)aCkpt[CKPT_HDR_LO_MSW] << 32) + (i64)aCkpt[CKPT_HDR_LO_LSW];\n}\n\nint lsmCheckpointPgsz(u32 *aCkpt){ return (int)aCkpt[CKPT_HDR_PGSZ]; }\n\nint lsmCheckpointBlksz(u32 *aCkpt){ return (int)aCkpt[CKPT_HDR_BLKSZ]; }\n\nvoid lsmCheckpointLogoffset(\n  u32 *aCkpt,\n  DbLog *pLog\n){ \n  pLog->aRegion[2].iStart = (lsmCheckpointLogOffset(aCkpt) >> 1);\n\n  pLog->cksum0 = aCkpt[CKPT_HDR_LO_CKSUM1];\n  pLog->cksum1 = aCkpt[CKPT_HDR_LO_CKSUM2];\n  pLog->iSnapshotId = lsmCheckpointId(aCkpt, 0);\n}\n\nvoid lsmCheckpointZeroLogoffset(lsm_db *pDb){\n  u32 nCkpt;\n\n  nCkpt = pDb->aSnapshot[CKPT_HDR_NCKPT];\n  assert( nCkpt>CKPT_HDR_NCKPT );\n  assert( nCkpt==pDb->pShmhdr->aSnap1[CKPT_HDR_NCKPT] );\n  assert( 0==memcmp(pDb->aSnapshot, pDb->pShmhdr->aSnap1, nCkpt*sizeof(u32)) );\n  assert( 0==memcmp(pDb->aSnapshot, pDb->pShmhdr->aSnap2, nCkpt*sizeof(u32)) );\n\n  pDb->aSnapshot[CKPT_HDR_LO_MSW] = 0;\n  pDb->aSnapshot[CKPT_HDR_LO_LSW] = 0;\n  ckptChecksum(pDb->aSnapshot, nCkpt, \n      &pDb->aSnapshot[nCkpt-2], &pDb->aSnapshot[nCkpt-1]\n  );\n\n  memcpy(pDb->pShmhdr->aSnap1, pDb->aSnapshot, nCkpt*sizeof(u32));\n  memcpy(pDb->pShmhdr->aSnap2, pDb->aSnapshot, nCkpt*sizeof(u32));\n}\n\n/*\n** Set the output variable to the number of KB of data written into the\n** database file since the most recent checkpoint.\n*/\nint lsmCheckpointSize(lsm_db *db, int *pnKB){\n  int rc = LSM_OK;\n  u32 nSynced;\n\n  /* Set nSynced to the number of pages that had been written when the \n  ** database was last checkpointed. */\n  rc = lsmCheckpointSynced(db, 0, 0, &nSynced);\n\n  if( rc==LSM_OK ){\n    u32 nPgsz = db->pShmhdr->aSnap1[CKPT_HDR_PGSZ];\n    u32 nWrite = db->pShmhdr->aSnap1[CKPT_HDR_NWRITE];\n    *pnKB = (int)(( ((i64)(nWrite - nSynced) * nPgsz) + 1023) / 1024);\n  }\n\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_file.c",
    "content": "/*\n** 2011-08-26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** NORMAL DATABASE FILE FORMAT\n**\n** The following database file format concepts are used by the code in\n** this file to read and write the database file.\n**\n** Pages:\n**\n**   A database file is divided into pages. The first 8KB of the file consists\n**   of two 4KB meta-pages. The meta-page size is not configurable. The \n**   remainder of the file is made up of database pages. The default database\n**   page size is 4KB. Database pages are aligned to page-size boundaries,\n**   so if the database page size is larger than 8KB there is a gap between\n**   the end of the meta pages and the start of the database pages.\n**\n**   Database pages are numbered based on their position in the file. Page N\n**   begins at byte offset ((N-1)*pgsz). This means that page 1 does not \n**   exist - since it would always overlap with the meta pages. If the \n**   page-size is (say) 512 bytes, then the first usable page in the database\n**   is page 33.\n**\n**   It is assumed that the first two meta pages and the data that follows\n**   them are located on different disk sectors. So that if a power failure \n**   while writing to a meta page there is no risk of damage to the other\n**   meta page or any other part of the database file. TODO: This may need\n**   to be revisited.\n**\n** Blocks:\n**\n**   The database file is also divided into blocks. The default block size is\n**   1MB. When writing to the database file, an attempt is made to write data\n**   in contiguous block-sized chunks.\n**\n**   The first and last page on each block are special in that they are 4 \n**   bytes smaller than all other pages. This is because the last four bytes \n**   of space on the first and last pages of each block are reserved for\n**   pointers to other blocks (i.e. a 32-bit block number).\n**\n** Runs:\n**\n**   A run is a sequence of pages that the upper layer uses to store a \n**   sorted array of database keys (and accompanying data - values, FC \n**   pointers and so on). Given a page within a run, it is possible to\n**   navigate to the next page in the run as follows:\n**\n**     a) if the current page is not the last in a block, the next page \n**        in the run is located immediately after the current page, OR\n**\n**     b) if the current page is the last page in a block, the next page \n**        in the run is the first page on the block identified by the\n**        block pointer stored in the last 4 bytes of the current block.\n**\n**   It is possible to navigate to the previous page in a similar fashion,\n**   using the block pointer embedded in the last 4 bytes of the first page\n**   of each block as required.\n**\n**   The upper layer is responsible for identifying by page number the \n**   first and last page of any run that it needs to navigate - there are\n**   no \"end-of-run\" markers stored or identified by this layer. This is\n**   necessary as clients reading different database snapshots may access \n**   different subsets of a run.\n**\n** THE LOG FILE \n**\n** This file opens and closes the log file. But it does not contain any\n** logic related to the log file format. Instead, it exports the following\n** functions that are used by the code in lsm_log.c to read and write the\n** log file:\n**\n**     lsmFsOpenLog\n**     lsmFsWriteLog\n**     lsmFsSyncLog\n**     lsmFsReadLog\n**     lsmFsTruncateLog\n**     lsmFsCloseAndDeleteLog\n**\n** COMPRESSED DATABASE FILE FORMAT\n**\n** The compressed database file format is very similar to the normal format.\n** The file still begins with two 4KB meta-pages (which are never compressed).\n** It is still divided into blocks.\n**\n** The first and last four bytes of each block are reserved for 32-bit \n** pointer values. Similar to the way four bytes are carved from the end of \n** the first and last page of each block in uncompressed databases. From\n** the point of view of the upper layer, all pages are the same size - this\n** is different from the uncompressed format where the first and last pages\n** on each block are 4 bytes smaller than the others.\n**\n** Pages are stored in variable length compressed form, as follows:\n**\n**     * 3-byte size field containing the size of the compressed page image\n**       in bytes. The most significant bit of each byte of the size field\n**       is always set. The remaining 7 bits are used to store a 21-bit\n**       integer value (in big-endian order - the first byte in the field\n**       contains the most significant 7 bits). Since the maximum allowed \n**       size of a compressed page image is (2^17 - 1) bytes, there are\n**       actually 4 unused bits in the size field.\n**\n**       In other words, if the size of the compressed page image is nSz,\n**       the header can be serialized as follows:\n**\n**         u8 aHdr[3]\n**         aHdr[0] = 0x80 | (u8)(nSz >> 14);\n**         aHdr[1] = 0x80 | (u8)(nSz >>  7);\n**         aHdr[2] = 0x80 | (u8)(nSz >>  0);\n**\n**     * Compressed page image.\n**\n**     * A second copy of the 3-byte record header.\n**\n** A page number is a byte offset into the database file. So the smallest\n** possible page number is 8192 (immediately after the two meta-pages).\n** The first and root page of a segment are identified by a page number\n** corresponding to the byte offset of the first byte in the corresponding\n** page record. The last page of a segment is identified by the byte offset\n** of the last byte in its record.\n**\n** Unlike uncompressed pages, compressed page records may span blocks.\n**\n** Sometimes, in order to avoid touching sectors that contain synced data\n** when writing, it is necessary to insert unused space between compressed\n** page records. This can be done as follows:\n**\n**     * For less than 6 bytes of empty space, the first and last byte\n**       of the free space contain the total number of free bytes. For\n**       example:\n**\n**         Block of 4 free bytes: 0x04 0x?? 0x?? 0x04\n**         Block of 2 free bytes: 0x02 0x02\n**         A single free byte:    0x01\n**\n**     * For 6 or more bytes of empty space, a record similar to a \n**       compressed page record is added to the segment. A padding record\n**       is distinguished from a compressed page record by the most \n**       significant bit of the second byte of the size field, which is\n**       cleared instead of set. \n*/\n#include \"lsmInt.h\"\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n\n/*\n** File-system object. Each database connection allocates a single instance\n** of the following structure. It is used for all access to the database and\n** log files.\n**\n** The database file may be accessed via two methods - using mmap() or using\n** read() and write() calls. In the general case both methods are used - a\n** prefix of the file is mapped into memory and the remainder accessed using\n** read() and write(). This is helpful when accessing very large files (or\n** files that may grow very large during the lifetime of a database\n** connection) on systems with 32-bit address spaces. However, it also requires\n** that this object manage two distinct types of Page objects simultaneously -\n** those that carry pointers to the mapped file and those that carry arrays\n** populated by read() calls.\n**\n** pFree:\n**   The head of a singly-linked list that containing currently unused Page \n**   structures suitable for use as mmap-page handles. Connected by the\n**   Page.pFreeNext pointers.\n**\n** pMapped:\n**   The head of a singly-linked list that contains all pages that currently\n**   carry pointers to the mapped region. This is used if the region is\n**   every remapped - the pointers carried by existing pages can be adjusted\n**   to account for the remapping. Connected by the Page.pMappedNext pointers.\n**\n** pWaiting:\n**   When the upper layer wishes to append a new b-tree page to a segment,\n**   it allocates a Page object that carries a malloc'd block of memory -\n**   regardless of the mmap-related configuration. The page is not assigned\n**   a page number at first. When the upper layer has finished constructing\n**   the page contents, it calls lsmFsPagePersist() to assign a page number\n**   to it. At this point it is likely that N pages have been written to the\n**   segment, the (N+1)th page is still outstanding and the b-tree page is\n**   assigned page number (N+2). To avoid writing page (N+2) before page \n**   (N+1), the recently completed b-tree page is held in the singly linked\n**   list headed by pWaiting until page (N+1) has been written. \n**\n**   Function lsmFsFlushWaiting() is responsible for eventually writing \n**   waiting pages to disk.\n**\n** apHash/nHash:\n**   Hash table used to store all Page objects that carry malloc'd arrays,\n**   except those b-tree pages that have not yet been assigned page numbers.\n**   Once they have been assigned page numbers - they are added to this\n**   hash table.\n**\n**   Hash table overflow chains are connected using the Page.pHashNext\n**   pointers.\n**\n** pLruFirst, pLruLast:\n**   The first and last entries in a doubly-linked list of pages. This\n**   list contains all pages with malloc'd data that are present in the\n**   hash table and have a ref-count of zero.\n*/\nstruct FileSystem {\n  lsm_db *pDb;                    /* Database handle that owns this object */\n  lsm_env *pEnv;                  /* Environment pointer */\n  char *zDb;                      /* Database file name */\n  char *zLog;                     /* Database file name */\n  int nMetasize;                  /* Size of meta pages in bytes */\n  int nMetaRwSize;                /* Read/written size of meta pages in bytes */\n  int nPagesize;                  /* Database page-size in bytes */\n  int nBlocksize;                 /* Database block-size in bytes */\n\n  /* r/w file descriptors for both files. */\n  LsmFile *pLsmFile;              /* Used after lsm_close() to link into list */\n  lsm_file *fdDb;                 /* Database file */\n  lsm_file *fdLog;                /* Log file */\n  int szSector;                   /* Database file sector size */\n\n  /* If this is a compressed database, a pointer to the compression methods.\n  ** For an uncompressed database, a NULL pointer.  */\n  lsm_compress *pCompress;\n  u8 *aIBuffer;                   /* Buffer to compress to */\n  u8 *aOBuffer;                   /* Buffer to uncompress from */\n  int nBuffer;                    /* Allocated size of above buffers in bytes */\n\n  /* mmap() page related things */\n  i64 nMapLimit;                  /* Maximum bytes of file to map */\n  void *pMap;                     /* Current mapping of database file */\n  i64 nMap;                       /* Bytes mapped at pMap */\n  Page *pFree;                    /* Unused Page structures */\n  Page *pMapped;                  /* List of Page structs that point to pMap */\n\n  /* Page cache parameters for non-mmap() pages */\n  int nCacheMax;                  /* Configured cache size (in pages) */\n  int nCacheAlloc;                /* Current cache size (in pages) */\n  Page *pLruFirst;                /* Head of the LRU list */\n  Page *pLruLast;                 /* Tail of the LRU list */\n  int nHash;                      /* Number of hash slots in hash table */\n  Page **apHash;                  /* nHash Hash slots */\n  Page *pWaiting;                 /* b-tree pages waiting to be written */\n\n  /* Statistics */\n  int nOut;                       /* Number of outstanding pages */\n  int nWrite;                     /* Total number of pages written */\n  int nRead;                      /* Total number of pages read */\n};\n\n/*\n** Database page handle.\n**\n** pSeg:\n**   When lsmFsSortedAppend() is called on a compressed database, the new\n**   page is not assigned a page number or location in the database file\n**   immediately. Instead, these are assigned by the lsmFsPagePersist() call\n**   right before it writes the compressed page image to disk.\n**\n**   The lsmFsSortedAppend() function sets the pSeg pointer to point to the\n**   segment that the new page will be a part of. It is unset by\n**   lsmFsPagePersist() after the page is written to disk.\n*/\nstruct Page {\n  u8 *aData;                      /* Buffer containing page data */\n  int nData;                      /* Bytes of usable data at aData[] */\n  Pgno iPg;                       /* Page number */\n  int nRef;                       /* Number of outstanding references */\n  int flags;                      /* Combination of PAGE_XXX flags */\n  Page *pHashNext;                /* Next page in hash table slot */\n  Page *pLruNext;                 /* Next page in LRU list */\n  Page *pLruPrev;                 /* Previous page in LRU list */\n  FileSystem *pFS;                /* File system that owns this page */\n\n  /* Only used in compressed database mode: */\n  int nCompress;                  /* Compressed size (or 0 for uncomp. db) */\n  int nCompressPrev;              /* Compressed size of prev page */\n  Segment *pSeg;                  /* Segment this page will be written to */\n\n  /* Pointers for singly linked lists */\n  Page *pWaitingNext;             /* Next page in FileSystem.pWaiting list */\n  Page *pFreeNext;                /* Next page in FileSystem.pFree list */\n  Page *pMappedNext;              /* Next page in FileSystem.pMapped list */\n};\n\n/*\n** Meta-data page handle. There are two meta-data pages at the start of\n** the database file, each FileSystem.nMetasize bytes in size.\n*/\nstruct MetaPage {\n  int iPg;                        /* Either 1 or 2 */\n  int bWrite;                     /* Write back to db file on release */\n  u8 *aData;                      /* Pointer to buffer */\n  FileSystem *pFS;                /* FileSystem that owns this page */\n};\n\n/* \n** Values for LsmPage.flags \n*/\n#define PAGE_DIRTY   0x00000001   /* Set if page is dirty */\n#define PAGE_FREE    0x00000002   /* Set if Page.aData requires lsmFree() */\n#define PAGE_HASPREV 0x00000004   /* Set if page is first on uncomp. block */\n\n/*\n** Number of pgsz byte pages omitted from the start of block 1. The start\n** of block 1 contains two 4096 byte meta pages (8192 bytes in total).\n*/\n#define BLOCK1_HDR_SIZE(pgsz)  LSM_MAX(1, 8192/(pgsz))\n\n/*\n** If NDEBUG is not defined, set a breakpoint in function lsmIoerrBkpt()\n** to catch IO errors (any error returned by a VFS method). \n*/\n#ifndef NDEBUG\nstatic void lsmIoerrBkpt(void){\n  static int nErr = 0;\n  nErr++;\n}\nstatic int IOERR_WRAPPER(int rc){\n  if( rc!=LSM_OK ) lsmIoerrBkpt();\n  return rc;\n}\n#else\n# define IOERR_WRAPPER(rc) (rc)\n#endif\n\n#ifdef NDEBUG\n# define assert_lists_are_ok(x)\n#else\nstatic Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash);\n\nstatic void assert_lists_are_ok(FileSystem *pFS){\n#if 0\n  Page *p;\n\n  assert( pFS->nMapLimit>=0 );\n\n  /* Check that all pages in the LRU list have nRef==0, pointers to buffers\n  ** in heap memory, and corresponding entries in the hash table.  */\n  for(p=pFS->pLruFirst; p; p=p->pLruNext){\n    assert( p==pFS->pLruFirst || p->pLruPrev!=0 );\n    assert( p==pFS->pLruLast || p->pLruNext!=0 );\n    assert( p->pLruPrev==0 || p->pLruPrev->pLruNext==p );\n    assert( p->pLruNext==0 || p->pLruNext->pLruPrev==p );\n    assert( p->nRef==0 );\n    assert( p->flags & PAGE_FREE );\n    assert( p==fsPageFindInHash(pFS, p->iPg, 0) );\n  }\n#endif\n}\n#endif\n\n/*\n** Wrappers around the VFS methods of the lsm_env object:\n**\n**     lsmEnvOpen()\n**     lsmEnvRead()\n**     lsmEnvWrite()\n**     lsmEnvSync()\n**     lsmEnvSectorSize()\n**     lsmEnvClose()\n**     lsmEnvTruncate()\n**     lsmEnvUnlink()\n**     lsmEnvRemap()\n*/\nint lsmEnvOpen(lsm_env *pEnv, const char *zFile, int flags, lsm_file **ppNew){\n  return pEnv->xOpen(pEnv, zFile, flags, ppNew);\n}\n\nstatic int lsmEnvRead(\n  lsm_env *pEnv, \n  lsm_file *pFile, \n  lsm_i64 iOff, \n  void *pRead, \n  int nRead\n){\n  return IOERR_WRAPPER( pEnv->xRead(pFile, iOff, pRead, nRead) );\n}\n\nstatic int lsmEnvWrite(\n  lsm_env *pEnv, \n  lsm_file *pFile, \n  lsm_i64 iOff, \n  const void *pWrite, \n  int nWrite\n){\n  return IOERR_WRAPPER( pEnv->xWrite(pFile, iOff, (void *)pWrite, nWrite) );\n}\n\nstatic int lsmEnvSync(lsm_env *pEnv, lsm_file *pFile){\n  return IOERR_WRAPPER( pEnv->xSync(pFile) );\n}\n\nstatic int lsmEnvSectorSize(lsm_env *pEnv, lsm_file *pFile){\n  return pEnv->xSectorSize(pFile);\n}\n\nint lsmEnvClose(lsm_env *pEnv, lsm_file *pFile){\n  return IOERR_WRAPPER( pEnv->xClose(pFile) );\n}\n\nstatic int lsmEnvTruncate(lsm_env *pEnv, lsm_file *pFile, lsm_i64 nByte){\n  return IOERR_WRAPPER( pEnv->xTruncate(pFile, nByte) );\n}\n\nstatic int lsmEnvUnlink(lsm_env *pEnv, const char *zDel){\n  return IOERR_WRAPPER( pEnv->xUnlink(pEnv, zDel) );\n}\n\nstatic int lsmEnvRemap(\n  lsm_env *pEnv, \n  lsm_file *pFile, \n  i64 szMin,\n  void **ppMap,\n  i64 *pszMap\n){\n  return pEnv->xRemap(pFile, szMin, ppMap, pszMap);\n}\n\nint lsmEnvLock(lsm_env *pEnv, lsm_file *pFile, int iLock, int eLock){\n  if( pFile==0 ) return LSM_OK;\n  return pEnv->xLock(pFile, iLock, eLock);\n}\n\nint lsmEnvTestLock(\n  lsm_env *pEnv, \n  lsm_file *pFile, \n  int iLock, \n  int nLock, \n  int eLock\n){\n  return pEnv->xTestLock(pFile, iLock, nLock, eLock);\n}\n\nint lsmEnvShmMap(\n  lsm_env *pEnv, \n  lsm_file *pFile, \n  int iChunk, \n  int sz, \n  void **ppOut\n){\n  return pEnv->xShmMap(pFile, iChunk, sz, ppOut);\n}\n\nvoid lsmEnvShmBarrier(lsm_env *pEnv){\n  pEnv->xShmBarrier();\n}\n\nvoid lsmEnvShmUnmap(lsm_env *pEnv, lsm_file *pFile, int bDel){\n  pEnv->xShmUnmap(pFile, bDel);\n}\n\nvoid lsmEnvSleep(lsm_env *pEnv, int nUs){\n  pEnv->xSleep(pEnv, nUs);\n}\n\n\n/*\n** Write the contents of string buffer pStr into the log file, starting at\n** offset iOff.\n*/\nint lsmFsWriteLog(FileSystem *pFS, i64 iOff, LsmString *pStr){\n  assert( pFS->fdLog );\n  return lsmEnvWrite(pFS->pEnv, pFS->fdLog, iOff, pStr->z, pStr->n);\n}\n\n/*\n** fsync() the log file.\n*/\nint lsmFsSyncLog(FileSystem *pFS){\n  assert( pFS->fdLog );\n  return lsmEnvSync(pFS->pEnv, pFS->fdLog);\n}\n\n/*\n** Read nRead bytes of data starting at offset iOff of the log file. Append\n** the results to string buffer pStr.\n*/\nint lsmFsReadLog(FileSystem *pFS, i64 iOff, int nRead, LsmString *pStr){\n  int rc;                         /* Return code */\n  assert( pFS->fdLog );\n  rc = lsmStringExtend(pStr, nRead);\n  if( rc==LSM_OK ){\n    rc = lsmEnvRead(pFS->pEnv, pFS->fdLog, iOff, &pStr->z[pStr->n], nRead);\n    pStr->n += nRead;\n  }\n  return rc;\n}\n\n/*\n** Truncate the log file to nByte bytes in size.\n*/\nint lsmFsTruncateLog(FileSystem *pFS, i64 nByte){\n  if( pFS->fdLog==0 ) return LSM_OK;\n  return lsmEnvTruncate(pFS->pEnv, pFS->fdLog, nByte);\n}\n\n/*\n** Truncate the db file to nByte bytes in size.\n*/\nint lsmFsTruncateDb(FileSystem *pFS, i64 nByte){\n  if( pFS->fdDb==0 ) return LSM_OK;\n  return lsmEnvTruncate(pFS->pEnv, pFS->fdDb, nByte);\n}\n\n/*\n** Close the log file. Then delete it from the file-system. This function\n** is called during database shutdown only.\n*/\nint lsmFsCloseAndDeleteLog(FileSystem *pFS){\n  char *zDel;\n\n  if( pFS->fdLog ){\n    lsmEnvClose(pFS->pEnv, pFS->fdLog );\n    pFS->fdLog = 0;\n  }\n\n  zDel = lsmMallocPrintf(pFS->pEnv, \"%s-log\", pFS->zDb);\n  if( zDel ){\n    lsmEnvUnlink(pFS->pEnv, zDel);\n    lsmFree(pFS->pEnv, zDel);\n  }\n  return LSM_OK;\n}\n\n/*\n** Return true if page iReal of the database should be accessed using mmap.\n** False otherwise.\n*/\nstatic int fsMmapPage(FileSystem *pFS, Pgno iReal){\n  return ((i64)iReal*pFS->nPagesize <= pFS->nMapLimit);\n}\n\n/*\n** Given that there are currently nHash slots in the hash table, return \n** the hash key for file iFile, page iPg.\n*/\nstatic int fsHashKey(int nHash, Pgno iPg){\n  return (iPg % nHash);\n}\n\n/*\n** This is a helper function for lsmFsOpen(). It opens a single file on\n** disk (either the database or log file).\n*/\nstatic lsm_file *fsOpenFile(\n  FileSystem *pFS,                /* File system object */\n  int bReadonly,                  /* True to open this file read-only */\n  int bLog,                       /* True for log, false for db */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  lsm_file *pFile = 0;\n  if( *pRc==LSM_OK ){\n    int flags = (bReadonly ? LSM_OPEN_READONLY : 0);\n    const char *zPath = (bLog ? pFS->zLog : pFS->zDb);\n\n    *pRc = lsmEnvOpen(pFS->pEnv, zPath, flags, &pFile);\n  }\n  return pFile;\n}\n\n/*\n** If it is not already open, this function opens the log file. It returns\n** LSM_OK if successful (or if the log file was already open) or an LSM\n** error code otherwise.\n**\n** The log file must be opened before any of the following may be called:\n**\n**     lsmFsWriteLog\n**     lsmFsSyncLog\n**     lsmFsReadLog\n*/\nint lsmFsOpenLog(lsm_db *db, int *pbOpen){\n  int rc = LSM_OK;\n  FileSystem *pFS = db->pFS;\n\n  if( 0==pFS->fdLog ){ \n    pFS->fdLog = fsOpenFile(pFS, db->bReadonly, 1, &rc); \n\n    if( rc==LSM_IOERR_NOENT && db->bReadonly ){\n      rc = LSM_OK;\n    }\n  }\n\n  if( pbOpen ) *pbOpen = (pFS->fdLog!=0);\n  return rc;\n}\n\n/*\n** Close the log file, if it is open.\n*/\nvoid lsmFsCloseLog(lsm_db *db){\n  FileSystem *pFS = db->pFS;\n  if( pFS->fdLog ){\n    lsmEnvClose(pFS->pEnv, pFS->fdLog);\n    pFS->fdLog = 0;\n  }\n}\n\n/*\n** Open a connection to a database stored within the file-system.\n**\n** If parameter bReadonly is true, then open a read-only file-descriptor\n** on the database file. It is possible that bReadonly will be false even\n** if the user requested that pDb be opened read-only. This is because the\n** file-descriptor may later on be recycled by a read-write connection.\n** If the db file can be opened for read-write access, it always is. Parameter\n** bReadonly is only ever true if it has already been determined that the\n** db can only be opened for read-only access.\n**\n** Return LSM_OK if successful or an lsm error code otherwise.\n*/\nint lsmFsOpen(\n  lsm_db *pDb,                    /* Database connection to open fd for */\n  const char *zDb,                /* Full path to database file */\n  int bReadonly                   /* True to open db file read-only */\n){\n  FileSystem *pFS;\n  int rc = LSM_OK;\n  int nDb = strlen(zDb);\n  int nByte;\n\n  assert( pDb->pFS==0 );\n  assert( pDb->pWorker==0 && pDb->pClient==0 );\n\n  nByte = sizeof(FileSystem) + nDb+1 + nDb+4+1;\n  pFS = (FileSystem *)lsmMallocZeroRc(pDb->pEnv, nByte, &rc);\n  if( pFS ){\n    LsmFile *pLsmFile;\n    pFS->zDb = (char *)&pFS[1];\n    pFS->zLog = &pFS->zDb[nDb+1];\n    pFS->nPagesize = LSM_DFLT_PAGE_SIZE;\n    pFS->nBlocksize = LSM_DFLT_BLOCK_SIZE;\n    pFS->nMetasize = LSM_META_PAGE_SIZE;\n    pFS->nMetaRwSize = LSM_META_RW_PAGE_SIZE;\n    pFS->pDb = pDb;\n    pFS->pEnv = pDb->pEnv;\n\n    /* Make a copy of the database and log file names. */\n    memcpy(pFS->zDb, zDb, nDb+1);\n    memcpy(pFS->zLog, zDb, nDb);\n    memcpy(&pFS->zLog[nDb], \"-log\", 5);\n\n    /* Allocate the hash-table here. At some point, it should be changed\n    ** so that it can grow dynamicly. */\n    pFS->nCacheMax = 2048*1024 / pFS->nPagesize;\n    pFS->nHash = 4096;\n    pFS->apHash = lsmMallocZeroRc(pDb->pEnv, sizeof(Page *) * pFS->nHash, &rc);\n\n    /* Open the database file */\n    pLsmFile = lsmDbRecycleFd(pDb);\n    if( pLsmFile ){\n      pFS->pLsmFile = pLsmFile;\n      pFS->fdDb = pLsmFile->pFile;\n      memset(pLsmFile, 0, sizeof(LsmFile));\n    }else{\n      pFS->pLsmFile = lsmMallocZeroRc(pDb->pEnv, sizeof(LsmFile), &rc);\n      if( rc==LSM_OK ){\n        pFS->fdDb = fsOpenFile(pFS, bReadonly, 0, &rc);\n      }\n    }\n\n    if( rc!=LSM_OK ){\n      lsmFsClose(pFS);\n      pFS = 0;\n    }else{\n      pFS->szSector = lsmEnvSectorSize(pFS->pEnv, pFS->fdDb);\n    }\n  }\n\n  pDb->pFS = pFS;\n  return rc;\n}\n\n/*\n** Configure the file-system object according to the current values of\n** the LSM_CONFIG_MMAP and LSM_CONFIG_SET_COMPRESSION options.\n*/\nint lsmFsConfigure(lsm_db *db){\n  FileSystem *pFS = db->pFS;\n  if( pFS ){\n    lsm_env *pEnv = pFS->pEnv;\n    Page *pPg;\n\n    assert( pFS->nOut==0 );\n    assert( pFS->pWaiting==0 );\n    assert( pFS->pMapped==0 );\n\n    /* Reset any compression/decompression buffers already allocated */\n    lsmFree(pEnv, pFS->aIBuffer);\n    lsmFree(pEnv, pFS->aOBuffer);\n    pFS->nBuffer = 0;\n\n    /* Unmap the file, if it is currently mapped */\n    if( pFS->pMap ){\n      lsmEnvRemap(pEnv, pFS->fdDb, -1, &pFS->pMap, &pFS->nMap);\n      pFS->nMapLimit = 0;\n    }\n\n    /* Free all allocated page structures */\n    pPg = pFS->pLruFirst;\n    while( pPg ){\n      Page *pNext = pPg->pLruNext;\n      assert( pPg->flags & PAGE_FREE );\n      lsmFree(pEnv, pPg->aData);\n      lsmFree(pEnv, pPg);\n      pPg = pNext;\n    }\n\n    pPg = pFS->pFree;\n    while( pPg ){\n      Page *pNext = pPg->pFreeNext;\n      lsmFree(pEnv, pPg);\n      pPg = pNext;\n    }\n\n    /* Zero pointers that point to deleted page objects */\n    pFS->nCacheAlloc = 0;\n    pFS->pLruFirst = 0;\n    pFS->pLruLast = 0;\n    pFS->pFree = 0;\n    if( pFS->apHash ){\n      memset(pFS->apHash, 0, pFS->nHash*sizeof(pFS->apHash[0]));\n    }\n\n    /* Configure the FileSystem object */\n    if( db->compress.xCompress ){\n      pFS->pCompress = &db->compress;\n      pFS->nMapLimit = 0;\n    }else{\n      pFS->pCompress = 0;\n      if( db->iMmap==1 ){\n        /* Unlimited */\n        pFS->nMapLimit = (i64)1 << 60;\n      }else{\n        /* iMmap is a limit in KB. Set nMapLimit to the same value in bytes. */\n        pFS->nMapLimit = (i64)db->iMmap * 1024;\n      }\n    }\n  }\n\n  return LSM_OK;\n}\n\n/*\n** Close and destroy a FileSystem object.\n*/\nvoid lsmFsClose(FileSystem *pFS){\n  if( pFS ){\n    Page *pPg;\n    lsm_env *pEnv = pFS->pEnv;\n\n    assert( pFS->nOut==0 );\n    pPg = pFS->pLruFirst;\n    while( pPg ){\n      Page *pNext = pPg->pLruNext;\n      if( pPg->flags & PAGE_FREE ) lsmFree(pEnv, pPg->aData);\n      lsmFree(pEnv, pPg);\n      pPg = pNext;\n    }\n\n    pPg = pFS->pFree;\n    while( pPg ){\n      Page *pNext = pPg->pFreeNext;\n      if( pPg->flags & PAGE_FREE ) lsmFree(pEnv, pPg->aData);\n      lsmFree(pEnv, pPg);\n      pPg = pNext;\n    }\n\n    if( pFS->fdDb ) lsmEnvClose(pFS->pEnv, pFS->fdDb );\n    if( pFS->fdLog ) lsmEnvClose(pFS->pEnv, pFS->fdLog );\n    lsmFree(pEnv, pFS->pLsmFile);\n    lsmFree(pEnv, pFS->apHash);\n    lsmFree(pEnv, pFS->aIBuffer);\n    lsmFree(pEnv, pFS->aOBuffer);\n    lsmFree(pEnv, pFS);\n  }\n}\n\n/*\n** This function is called when closing a database handle (i.e. lsm_close()) \n** if there exist other connections to the same database within this process.\n** In that case the file-descriptor open on the database file is not closed\n** when the FileSystem object is destroyed, as this would cause any POSIX\n** locks held by the other connections to be silently dropped (see \"man close\"\n** for details). Instead, the file-descriptor is stored in a list by the\n** lsm_shared.c module until it is either closed or reused.\n**\n** This function returns a pointer to an object that can be linked into\n** the list described above. The returned object now 'owns' the database\n** file descriptr, so that when the FileSystem object is destroyed, it\n** will not be closed. \n**\n** This function may be called at most once in the life-time of a \n** FileSystem object. The results of any operations involving the database \n** file descriptor are undefined once this function has been called.\n**\n** None of this is necessary on non-POSIX systems. But we do it anyway in\n** the name of using as similar code as possible on all platforms.\n*/\nLsmFile *lsmFsDeferClose(FileSystem *pFS){\n  LsmFile *p = pFS->pLsmFile;\n  assert( p->pNext==0 );\n  p->pFile = pFS->fdDb;\n  pFS->fdDb = 0;\n  pFS->pLsmFile = 0;\n  return p;\n}\n\n/*\n** Allocate a buffer and populate it with the output of the xFileid() \n** method of the database file handle. If successful, set *ppId to point \n** to the buffer and *pnId to the number of bytes in the buffer and return\n** LSM_OK. Otherwise, set *ppId and *pnId to zero and return an LSM\n** error code.\n*/\nint lsmFsFileid(lsm_db *pDb, void **ppId, int *pnId){\n  lsm_env *pEnv = pDb->pEnv;\n  FileSystem *pFS = pDb->pFS;\n  int rc;\n  int nId = 0;\n  void *pId;\n\n  rc = pEnv->xFileid(pFS->fdDb, 0, &nId);\n  pId = lsmMallocZeroRc(pEnv, nId, &rc);\n  if( rc==LSM_OK ) rc = pEnv->xFileid(pFS->fdDb, pId, &nId);\n\n  if( rc!=LSM_OK ){\n    lsmFree(pEnv, pId);\n    pId = 0;\n    nId = 0;\n  }\n\n  *ppId = pId;\n  *pnId = nId;\n  return rc;\n}\n\n/*\n** Return the nominal page-size used by this file-system. Actual pages\n** may be smaller or larger than this value.\n*/\nint lsmFsPageSize(FileSystem *pFS){\n  return pFS->nPagesize;\n}\n\n/*\n** Return the block-size used by this file-system.\n*/\nint lsmFsBlockSize(FileSystem *pFS){\n  return pFS->nBlocksize;\n}\n\n/*\n** Configure the nominal page-size used by this file-system. Actual \n** pages may be smaller or larger than this value.\n*/\nvoid lsmFsSetPageSize(FileSystem *pFS, int nPgsz){\n  pFS->nPagesize = nPgsz;\n  pFS->nCacheMax = 2048*1024 / pFS->nPagesize;\n}\n\n/*\n** Configure the block-size used by this file-system. \n*/\nvoid lsmFsSetBlockSize(FileSystem *pFS, int nBlocksize){\n  pFS->nBlocksize = nBlocksize;\n}\n\n/*\n** Return the page number of the first page on block iBlock. Blocks are\n** numbered starting from 1.\n**\n** For a compressed database, page numbers are byte offsets. The first\n** page on each block is the byte offset immediately following the 4-byte\n** \"previous block\" pointer at the start of each block.\n*/\nstatic Pgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){\n  Pgno iPg;\n  if( pFS->pCompress ){\n    if( iBlock==1 ){\n      iPg = pFS->nMetasize * 2 + 4;\n    }else{\n      iPg = pFS->nBlocksize * (Pgno)(iBlock-1) + 4;\n    }\n  }else{\n    const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n    if( iBlock==1 ){\n      iPg = 1 + ((pFS->nMetasize*2 + pFS->nPagesize - 1) / pFS->nPagesize);\n    }else{\n      iPg = 1 + (iBlock-1) * nPagePerBlock;\n    }\n  }\n  return iPg;\n}\n\n/*\n** Return the page number of the last page on block iBlock. Blocks are\n** numbered starting from 1.\n**\n** For a compressed database, page numbers are byte offsets. The first\n** page on each block is the byte offset of the byte immediately before \n** the 4-byte \"next block\" pointer at the end of each block.\n*/\nstatic Pgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){\n  if( pFS->pCompress ){\n    return pFS->nBlocksize * (Pgno)iBlock - 1 - 4;\n  }else{\n    const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n    return iBlock * nPagePerBlock;\n  }\n}\n\n/*\n** Return the block number of the block that page iPg is located on. \n** Blocks are numbered starting from 1.\n*/\nstatic int fsPageToBlock(FileSystem *pFS, Pgno iPg){\n  if( pFS->pCompress ){\n    return (int)((iPg / pFS->nBlocksize) + 1);\n  }else{\n    return (int)(1 + ((iPg-1) / (pFS->nBlocksize / pFS->nPagesize)));\n  }\n}\n\n/*\n** Return true if page iPg is the last page on its block.\n**\n** This function is only called in non-compressed database mode.\n*/\nstatic int fsIsLast(FileSystem *pFS, Pgno iPg){\n  const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n  assert( !pFS->pCompress );\n  return ( iPg && (iPg % nPagePerBlock)==0 );\n}\n\n/*\n** Return true if page iPg is the first page on its block.\n**\n** This function is only called in non-compressed database mode.\n*/\nstatic int fsIsFirst(FileSystem *pFS, Pgno iPg){\n  const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n  assert( !pFS->pCompress );\n  return ( (iPg % nPagePerBlock)==1\n        || (iPg<nPagePerBlock && iPg==fsFirstPageOnBlock(pFS, 1))\n  );\n}\n\n/*\n** Given a page reference, return a pointer to the buffer containing the \n** pages contents. If parameter pnData is not NULL, set *pnData to the size\n** of the buffer in bytes before returning.\n*/\nu8 *lsmFsPageData(Page *pPage, int *pnData){\n  if( pnData ){\n    *pnData = pPage->nData;\n  }\n  return pPage->aData;\n}\n\n/*\n** Return the page number of a page.\n*/\nPgno lsmFsPageNumber(Page *pPage){\n  /* assert( (pPage->flags & PAGE_DIRTY)==0 ); */\n  return pPage ? pPage->iPg : 0;\n}\n\n/*\n** Page pPg is currently part of the LRU list belonging to pFS. Remove\n** it from the list. pPg->pLruNext and pPg->pLruPrev are cleared by this\n** operation.\n*/\nstatic void fsPageRemoveFromLru(FileSystem *pFS, Page *pPg){\n  assert( pPg->pLruNext || pPg==pFS->pLruLast );\n  assert( pPg->pLruPrev || pPg==pFS->pLruFirst );\n  if( pPg->pLruNext ){\n    pPg->pLruNext->pLruPrev = pPg->pLruPrev;\n  }else{\n    pFS->pLruLast = pPg->pLruPrev;\n  }\n  if( pPg->pLruPrev ){\n    pPg->pLruPrev->pLruNext = pPg->pLruNext;\n  }else{\n    pFS->pLruFirst = pPg->pLruNext;\n  }\n  pPg->pLruPrev = 0;\n  pPg->pLruNext = 0;\n}\n\n/*\n** Page pPg is not currently part of the LRU list belonging to pFS. Add it.\n*/\nstatic void fsPageAddToLru(FileSystem *pFS, Page *pPg){\n  assert( pPg->pLruNext==0 && pPg->pLruPrev==0 );\n  pPg->pLruPrev = pFS->pLruLast;\n  if( pPg->pLruPrev ){\n    pPg->pLruPrev->pLruNext = pPg;\n  }else{\n    pFS->pLruFirst = pPg;\n  }\n  pFS->pLruLast = pPg;\n}\n\n/*\n** Page pPg is currently stored in the apHash/nHash hash table. Remove it.\n*/\nstatic void fsPageRemoveFromHash(FileSystem *pFS, Page *pPg){\n  int iHash;\n  Page **pp;\n\n  iHash = fsHashKey(pFS->nHash, pPg->iPg);\n  for(pp=&pFS->apHash[iHash]; *pp!=pPg; pp=&(*pp)->pHashNext);\n  *pp = pPg->pHashNext;\n  pPg->pHashNext = 0;\n}\n\n/*\n** Free a Page object allocated by fsPageBuffer().\n*/\nstatic void fsPageBufferFree(Page *pPg){\n  pPg->pFS->nCacheAlloc--;\n  lsmFree(pPg->pFS->pEnv, pPg->aData);\n  lsmFree(pPg->pFS->pEnv, pPg);\n}\n\n\n/*\n** Purge the cache of all non-mmap pages with nRef==0.\n*/\nvoid lsmFsPurgeCache(FileSystem *pFS){\n  Page *pPg;\n\n  pPg = pFS->pLruFirst;\n  while( pPg ){\n    Page *pNext = pPg->pLruNext;\n    assert( pPg->flags & PAGE_FREE );\n    fsPageRemoveFromHash(pFS, pPg);\n    fsPageBufferFree(pPg);\n    pPg = pNext;\n  }\n  pFS->pLruFirst = 0;\n  pFS->pLruLast = 0;\n\n  assert( pFS->nCacheAlloc<=pFS->nOut && pFS->nCacheAlloc>=0 );\n}\n\n/*\n** Search the hash-table for page iPg. If an entry is round, return a pointer\n** to it. Otherwise, return NULL.\n**\n** Either way, if argument piHash is not NULL set *piHash to the hash slot\n** number that page iPg would be stored in before returning.\n*/\nstatic Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash){\n  Page *p;                        /* Return value */\n  int iHash = fsHashKey(pFS->nHash, iPg);\n\n  if( piHash ) *piHash = iHash;\n  for(p=pFS->apHash[iHash]; p; p=p->pHashNext){\n    if( p->iPg==iPg) break;\n  }\n  return p;\n}\n\n/*\n** Allocate and return a non-mmap Page object. If there are already \n** nCacheMax such Page objects outstanding, try to recycle an existing \n** Page instead.\n*/\nstatic int fsPageBuffer(\n  FileSystem *pFS, \n  Page **ppOut\n){\n  int rc = LSM_OK;\n  Page *pPage = 0;\n  if( pFS->pLruFirst==0 || pFS->nCacheAlloc<pFS->nCacheMax ){\n    /* Allocate a new Page object */\n    pPage = lsmMallocZero(pFS->pEnv, sizeof(Page));\n    if( !pPage ){\n      rc = LSM_NOMEM_BKPT;\n    }else{\n      pPage->aData = (u8 *)lsmMalloc(pFS->pEnv, pFS->nPagesize);\n      if( !pPage->aData ){\n        lsmFree(pFS->pEnv, pPage);\n        rc = LSM_NOMEM_BKPT;\n        pPage = 0;\n      }else{\n        pFS->nCacheAlloc++;\n      }\n    }\n  }else{\n    /* Reuse an existing Page object */\n    u8 *aData;\n    pPage = pFS->pLruFirst;\n    aData = pPage->aData;\n    fsPageRemoveFromLru(pFS, pPage);\n    fsPageRemoveFromHash(pFS, pPage);\n\n    memset(pPage, 0, sizeof(Page));\n    pPage->aData = aData;\n  }\n\n  if( pPage ){\n    pPage->flags = PAGE_FREE;\n  }\n  *ppOut = pPage;\n  return rc;\n}\n\n/*\n** Assuming *pRc is initially LSM_OK, attempt to ensure that the \n** memory-mapped region is at least iSz bytes in size. If it is not already,\n** iSz bytes in size, extend it and update the pointers associated with any\n** outstanding Page objects.\n**\n** If *pRc is not LSM_OK when this function is called, it is a no-op. \n** Otherwise, *pRc is set to an lsm error code if an error occurs, or\n** left unmodified otherwise.\n**\n** This function is never called in compressed database mode.\n*/\nstatic void fsGrowMapping(\n  FileSystem *pFS,                /* File system object */\n  i64 iSz,                        /* Minimum size to extend mapping to */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  assert( pFS->pCompress==0 );\n  assert( PAGE_HASPREV==4 );\n\n  if( *pRc==LSM_OK && iSz>pFS->nMap ){\n    int rc;\n    u8 *aOld = pFS->pMap;\n    rc = lsmEnvRemap(pFS->pEnv, pFS->fdDb, iSz, &pFS->pMap, &pFS->nMap);\n    if( rc==LSM_OK && pFS->pMap!=aOld ){\n      Page *pFix;\n      i64 iOff = (u8 *)pFS->pMap - aOld;\n      for(pFix=pFS->pMapped; pFix; pFix=pFix->pMappedNext){\n        pFix->aData += iOff;\n      }\n      lsmSortedRemap(pFS->pDb);\n    }\n    *pRc = rc;\n  }\n}\n\n/*\n** If it is mapped, unmap the database file.\n*/\nint lsmFsUnmap(FileSystem *pFS){\n  int rc = LSM_OK;\n  if( pFS ){\n    rc = lsmEnvRemap(pFS->pEnv, pFS->fdDb, -1, &pFS->pMap, &pFS->nMap);\n  }\n  return rc;\n}\n\n/*\n** fsync() the database file.\n*/\nint lsmFsSyncDb(FileSystem *pFS, int nBlock){\n  return lsmEnvSync(pFS->pEnv, pFS->fdDb);\n}\n\n/*\n** If block iBlk has been redirected according to the redirections in the\n** object passed as the first argument, return the destination block to\n** which it is redirected. Otherwise, return a copy of iBlk.\n*/\nstatic int fsRedirectBlock(Redirect *p, int iBlk){\n  if( p ){\n    int i;\n    for(i=0; i<p->n; i++){\n      if( iBlk==p->a[i].iFrom ) return p->a[i].iTo;\n    }\n  }\n  assert( iBlk!=0 );\n  return iBlk;\n}\n\n/*\n** If page iPg has been redirected according to the redirections in the\n** object passed as the second argument, return the destination page to\n** which it is redirected. Otherwise, return a copy of iPg.\n*/\nPgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, Pgno iPg){\n  Pgno iReal = iPg;\n\n  if( pRedir ){\n    const int nPagePerBlock = (\n        pFS->pCompress ? pFS->nBlocksize : (pFS->nBlocksize / pFS->nPagesize)\n    );\n    int iBlk = fsPageToBlock(pFS, iPg);\n    int i;\n    for(i=0; i<pRedir->n; i++){\n      int iFrom = pRedir->a[i].iFrom;\n      if( iFrom>iBlk ) break;\n      if( iFrom==iBlk ){\n        int iTo = pRedir->a[i].iTo;\n        iReal = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;\n        if( iTo==1 ){\n          iReal += (fsFirstPageOnBlock(pFS, 1)-1);\n        }\n        break;\n      }\n    }\n  }\n\n  assert( iReal!=0 );\n  return iReal;\n}\n\n/* Required by the circular fsBlockNext<->fsPageGet dependency. */\nstatic int fsPageGet(FileSystem *, Segment *, Pgno, int, Page **, int *);\n\n/*\n** Parameter iBlock is a database file block. This function reads the value \n** stored in the blocks \"next block\" pointer and stores it in *piNext.\n** LSM_OK is returned if everything is successful, or an LSM error code\n** otherwise.\n*/\nstatic int fsBlockNext(\n  FileSystem *pFS,                /* File-system object handle */\n  Segment *pSeg,                  /* Use this segment for block redirects */\n  int iBlock,                     /* Read field from this block */\n  int *piNext                     /* OUT: Next block in linked list */\n){\n  int rc;\n  int iRead;                      /* Read block from here */\n  \n  if( pSeg ){\n    iRead = fsRedirectBlock(pSeg->pRedirect, iBlock);\n  }else{\n    iRead = iBlock;\n  }\n\n  assert( pFS->nMapLimit==0 || pFS->pCompress==0 );\n  if( pFS->pCompress ){\n    i64 iOff;                     /* File offset to read data from */\n    u8 aNext[4];                  /* 4-byte pointer read from db file */\n\n    iOff = (i64)iRead * pFS->nBlocksize - sizeof(aNext);\n    rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff, aNext, sizeof(aNext));\n    if( rc==LSM_OK ){\n      *piNext = (int)lsmGetU32(aNext);\n    }\n  }else{\n    const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n    Page *pLast;\n    rc = fsPageGet(pFS, 0, iRead*nPagePerBlock, 0, &pLast, 0);\n    if( rc==LSM_OK ){\n      *piNext = lsmGetU32(&pLast->aData[pFS->nPagesize-4]);\n      lsmFsPageRelease(pLast);\n    }\n  }\n\n  if( pSeg ){\n    *piNext = fsRedirectBlock(pSeg->pRedirect, *piNext);\n  }\n  return rc;\n}\n\n/*\n** Return the page number of the last page on the same block as page iPg.\n*/\nPgno fsLastPageOnPagesBlock(FileSystem *pFS, Pgno iPg){\n  return fsLastPageOnBlock(pFS, fsPageToBlock(pFS, iPg));\n}\n\n/*\n** Read nData bytes of data from offset iOff of the database file into\n** buffer aData. If this means reading past the end of a block, follow\n** the block pointer to the next block and continue reading.\n**\n** Offset iOff is an absolute offset - not subject to any block redirection.\n** However any block pointer followed is. Use pSeg->pRedirect in this case.\n**\n** This function is only called in compressed database mode.\n*/\nstatic int fsReadData(\n  FileSystem *pFS,                /* File-system handle */\n  Segment *pSeg,                  /* Block redirection */\n  i64 iOff,                       /* Read data from this offset */\n  u8 *aData,                      /* Buffer to read data into */\n  int nData                       /* Number of bytes to read */\n){\n  i64 iEob;                       /* End of block */\n  int nRead;\n  int rc;\n\n  assert( pFS->pCompress );\n\n  iEob = fsLastPageOnPagesBlock(pFS, iOff) + 1;\n  nRead = (int)LSM_MIN(iEob - iOff, nData);\n\n  rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff, aData, nRead);\n  if( rc==LSM_OK && nRead!=nData ){\n    int iBlk;\n\n    rc = fsBlockNext(pFS, pSeg, fsPageToBlock(pFS, iOff), &iBlk);\n    if( rc==LSM_OK ){\n      i64 iOff2 = fsFirstPageOnBlock(pFS, iBlk);\n      rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff2, &aData[nRead], nData-nRead);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Parameter iBlock is a database file block. This function reads the value \n** stored in the blocks \"previous block\" pointer and stores it in *piPrev.\n** LSM_OK is returned if everything is successful, or an LSM error code\n** otherwise.\n*/\nstatic int fsBlockPrev(\n  FileSystem *pFS,                /* File-system object handle */\n  Segment *pSeg,                  /* Use this segment for block redirects */\n  int iBlock,                     /* Read field from this block */\n  int *piPrev                     /* OUT: Previous block in linked list */\n){\n  int rc = LSM_OK;                /* Return code */\n\n  assert( pFS->nMapLimit==0 || pFS->pCompress==0 );\n  assert( iBlock>0 );\n\n  if( pFS->pCompress ){\n    i64 iOff = fsFirstPageOnBlock(pFS, iBlock) - 4;\n    u8 aPrev[4];                  /* 4-byte pointer read from db file */\n    rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff, aPrev, sizeof(aPrev));\n    if( rc==LSM_OK ){\n      Redirect *pRedir = (pSeg ? pSeg->pRedirect : 0);\n      *piPrev = fsRedirectBlock(pRedir, (int)lsmGetU32(aPrev));\n    }\n  }else{\n    assert( 0 );\n  }\n  return rc;\n}\n\n/*\n** Encode and decode routines for record size fields.\n*/\nstatic void putRecordSize(u8 *aBuf, int nByte, int bFree){\n  aBuf[0] = (u8)(nByte >> 14) | 0x80;\n  aBuf[1] = ((u8)(nByte >>  7) & 0x7F) | (bFree ? 0x00 : 0x80);\n  aBuf[2] = (u8)nByte | 0x80;\n}\nstatic int getRecordSize(u8 *aBuf, int *pbFree){\n  int nByte;\n  nByte  = (aBuf[0] & 0x7F) << 14;\n  nByte += (aBuf[1] & 0x7F) << 7;\n  nByte += (aBuf[2] & 0x7F);\n  *pbFree = !(aBuf[1] & 0x80);\n  return nByte;\n}\n\n/*\n** Subtract iSub from database file offset iOff and set *piRes to the\n** result. If doing so means passing the start of a block, follow the\n** block pointer stored in the first 4 bytes of the block.\n**\n** Offset iOff is an absolute offset - not subject to any block redirection.\n** However any block pointer followed is. Use pSeg->pRedirect in this case.\n**\n** Return LSM_OK if successful or an lsm error code if an error occurs.\n*/\nstatic int fsSubtractOffset(\n  FileSystem *pFS, \n  Segment *pSeg,\n  i64 iOff, \n  int iSub, \n  i64 *piRes\n){\n  i64 iStart;\n  int iBlk = 0;\n  int rc;\n\n  assert( pFS->pCompress );\n\n  iStart = fsFirstPageOnBlock(pFS, fsPageToBlock(pFS, iOff));\n  if( (iOff-iSub)>=iStart ){\n    *piRes = (iOff-iSub);\n    return LSM_OK;\n  }\n\n  rc = fsBlockPrev(pFS, pSeg, fsPageToBlock(pFS, iOff), &iBlk);\n  *piRes = fsLastPageOnBlock(pFS, iBlk) - iSub + (iOff - iStart + 1);\n  return rc;\n}\n\n/*\n** Add iAdd to database file offset iOff and set *piRes to the\n** result. If doing so means passing the end of a block, follow the\n** block pointer stored in the last 4 bytes of the block.\n**\n** Offset iOff is an absolute offset - not subject to any block redirection.\n** However any block pointer followed is. Use pSeg->pRedirect in this case.\n**\n** Return LSM_OK if successful or an lsm error code if an error occurs.\n*/\nstatic int fsAddOffset(\n  FileSystem *pFS, \n  Segment *pSeg,\n  i64 iOff, \n  int iAdd, \n  i64 *piRes\n){\n  i64 iEob;\n  int iBlk;\n  int rc;\n\n  assert( pFS->pCompress );\n\n  iEob = fsLastPageOnPagesBlock(pFS, iOff);\n  if( (iOff+iAdd)<=iEob ){\n    *piRes = (iOff+iAdd);\n    return LSM_OK;\n  }\n\n  rc = fsBlockNext(pFS, pSeg, fsPageToBlock(pFS, iOff), &iBlk);\n  *piRes = fsFirstPageOnBlock(pFS, iBlk) + iAdd - (iEob - iOff + 1);\n  return rc;\n}\n\n/*\n** If it is not already allocated, allocate either the FileSystem.aOBuffer (if\n** bWrite is true) or the FileSystem.aIBuffer (if bWrite is false). Return\n** LSM_OK if successful if the attempt to allocate memory fails.\n*/\nstatic int fsAllocateBuffer(FileSystem *pFS, int bWrite){\n  u8 **pp;                        /* Pointer to either aIBuffer or aOBuffer */\n\n  assert( pFS->pCompress );\n\n  /* If neither buffer has been allocated, figure out how large they\n  ** should be. Store this value in FileSystem.nBuffer.  */\n  if( pFS->nBuffer==0 ){\n    assert( pFS->aIBuffer==0 && pFS->aOBuffer==0 );\n    pFS->nBuffer = pFS->pCompress->xBound(pFS->pCompress->pCtx, pFS->nPagesize);\n    if( pFS->nBuffer<(pFS->szSector+6) ){\n      pFS->nBuffer = pFS->szSector+6;\n    }\n  }\n\n  pp = (bWrite ? &pFS->aOBuffer : &pFS->aIBuffer);\n  if( *pp==0 ){\n    *pp = lsmMalloc(pFS->pEnv, LSM_MAX(pFS->nBuffer, pFS->nPagesize));\n    if( *pp==0 ) return LSM_NOMEM_BKPT;\n  }\n\n  return LSM_OK;\n}\n\n/*\n** This function is only called in compressed database mode. It reads and\n** uncompresses the compressed data for page pPg from the database and\n** populates the pPg->aData[] buffer and pPg->nCompress field.\n**\n** It is possible that instead of a page record, there is free space\n** at offset pPg->iPgno. In this case no data is read from the file, but\n** output variable *pnSpace is set to the total number of free bytes.\n**\n** LSM_OK is returned if successful, or an LSM error code otherwise.\n*/\nstatic int fsReadPagedata(\n  FileSystem *pFS,                /* File-system handle */\n  Segment *pSeg,                  /* pPg is part of this segment */\n  Page *pPg,                      /* Page to read and uncompress data for */\n  int *pnSpace                    /* OUT: Total bytes of free space */\n){\n  lsm_compress *p = pFS->pCompress;\n  i64 iOff = pPg->iPg;\n  u8 aSz[3];\n  int rc;\n\n  assert( p && pPg->nCompress==0 );\n\n  if( fsAllocateBuffer(pFS, 0) ) return LSM_NOMEM;\n\n  rc = fsReadData(pFS, pSeg, iOff, aSz, sizeof(aSz));\n\n  if( rc==LSM_OK ){\n    int bFree;\n    if( aSz[0] & 0x80 ){\n      pPg->nCompress = (int)getRecordSize(aSz, &bFree);\n    }else{\n      pPg->nCompress = (int)aSz[0] - sizeof(aSz)*2;\n      bFree = 1;\n    }\n    if( bFree ){\n      if( pnSpace ){\n        *pnSpace = pPg->nCompress + sizeof(aSz)*2;\n      }else{\n        rc = LSM_CORRUPT_BKPT;\n      }\n    }else{\n      rc = fsAddOffset(pFS, pSeg, iOff, 3, &iOff);\n      if( rc==LSM_OK ){\n        if( pPg->nCompress>pFS->nBuffer ){\n          rc = LSM_CORRUPT_BKPT;\n        }else{\n          rc = fsReadData(pFS, pSeg, iOff, pFS->aIBuffer, pPg->nCompress);\n        }\n        if( rc==LSM_OK ){\n          int n = pFS->nPagesize;\n          rc = p->xUncompress(p->pCtx, \n              (char *)pPg->aData, &n, \n              (const char *)pFS->aIBuffer, pPg->nCompress\n          );\n          if( rc==LSM_OK && n!=pPg->pFS->nPagesize ){\n            rc = LSM_CORRUPT_BKPT;\n          }\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return a handle for a database page.\n**\n** If this file-system object is accessing a compressed database it may be\n** that there is no page record at database file offset iPg. Instead, there\n** may be a free space record. In this case, set *ppPg to NULL and *pnSpace\n** to the total number of free bytes before returning.\n**\n** If no error occurs, LSM_OK is returned. Otherwise, an lsm error code.\n*/\nstatic int fsPageGet(\n  FileSystem *pFS,                /* File-system handle */\n  Segment *pSeg,                  /* Block redirection to use (or NULL) */\n  Pgno iPg,                       /* Page id */\n  int noContent,                  /* True to not load content from disk */\n  Page **ppPg,                    /* OUT: New page handle */\n  int *pnSpace                    /* OUT: Bytes of free space */\n){\n  Page *p;\n  int iHash;\n  int rc = LSM_OK;\n\n  /* In most cases iReal is the same as iPg. Except, if pSeg->pRedirect is \n  ** not NULL, and the block containing iPg has been redirected, then iReal\n  ** is the page number after redirection.  */\n  Pgno iReal = lsmFsRedirectPage(pFS, (pSeg ? pSeg->pRedirect : 0), iPg);\n\n  assert_lists_are_ok(pFS);\n  assert( iPg>=fsFirstPageOnBlock(pFS, 1) );\n  assert( iReal>=fsFirstPageOnBlock(pFS, 1) );\n  *ppPg = 0;\n\n  /* Search the hash-table for the page */\n  p = fsPageFindInHash(pFS, iReal, &iHash);\n\n  if( p ){\n    assert( p->flags & PAGE_FREE );\n    if( p->nRef==0 ) fsPageRemoveFromLru(pFS, p);\n  }else{\n\n    if( fsMmapPage(pFS, iReal) ){\n      i64 iEnd = (i64)iReal * pFS->nPagesize;\n      fsGrowMapping(pFS, iEnd, &rc);\n      if( rc!=LSM_OK ) return rc;\n\n      if( pFS->pFree ){\n        p = pFS->pFree;\n        pFS->pFree = p->pFreeNext;\n        assert( p->nRef==0 );\n      }else{\n        p = lsmMallocZeroRc(pFS->pEnv, sizeof(Page), &rc);\n        if( rc ) return rc;\n        p->pFS = pFS;\n      }\n      p->aData = &((u8 *)pFS->pMap)[pFS->nPagesize * (iReal-1)];\n      p->iPg = iReal;\n\n      /* This page now carries a pointer to the mapping. Link it in to\n      ** the FileSystem.pMapped list.  */\n      assert( p->pMappedNext==0 );\n      p->pMappedNext = pFS->pMapped;\n      pFS->pMapped = p;\n\n      assert( pFS->pCompress==0 );\n      assert( (p->flags & PAGE_FREE)==0 );\n    }else{\n      rc = fsPageBuffer(pFS, &p);\n      if( rc==LSM_OK ){\n        int nSpace = 0;\n        p->iPg = iReal;\n        p->nRef = 0;\n        p->pFS = pFS;\n        assert( p->flags==0 || p->flags==PAGE_FREE );\n\n#ifdef LSM_DEBUG\n        memset(p->aData, 0x56, pFS->nPagesize);\n#endif\n        assert( p->pLruNext==0 && p->pLruPrev==0 );\n        if( noContent==0 ){\n          if( pFS->pCompress ){\n            rc = fsReadPagedata(pFS, pSeg, p, &nSpace);\n          }else{\n            int nByte = pFS->nPagesize;\n            i64 iOff = (i64)(iReal-1) * pFS->nPagesize;\n            rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff, p->aData, nByte);\n          }\n          pFS->nRead++;\n        }\n\n        /* If the xRead() call was successful (or not attempted), link the\n        ** page into the page-cache hash-table. Otherwise, if it failed,\n        ** free the buffer. */\n        if( rc==LSM_OK && nSpace==0 ){\n          p->pHashNext = pFS->apHash[iHash];\n          pFS->apHash[iHash] = p;\n        }else{\n          fsPageBufferFree(p);\n          p = 0;\n          if( pnSpace ) *pnSpace = nSpace;\n        }\n      }\n    }\n\n    assert( (rc==LSM_OK && (p || (pnSpace && *pnSpace)))\n         || (rc!=LSM_OK && p==0) \n    );\n  }\n\n  if( rc==LSM_OK && p ){\n    if( pFS->pCompress==0 && (fsIsLast(pFS, iReal) || fsIsFirst(pFS, iReal)) ){\n      p->nData = pFS->nPagesize - 4;\n      if( fsIsFirst(pFS, iReal) && p->nRef==0 ){\n        p->aData += 4;\n        p->flags |= PAGE_HASPREV;\n      }\n    }else{\n      p->nData = pFS->nPagesize;\n    }\n    pFS->nOut += (p->nRef==0);\n    p->nRef++;\n  }\n  *ppPg = p;\n  return rc;\n}\n\n/*\n** Read the 64-bit checkpoint id of the checkpoint currently stored on meta\n** page iMeta of the database file. If no error occurs, store the id value\n** in *piVal and return LSM_OK. Otherwise, return an LSM error code and leave\n** *piVal unmodified.\n**\n** If a checkpointer connection is currently updating meta-page iMeta, or an\n** earlier checkpointer crashed while doing so, the value read into *piVal\n** may be garbage. It is the callers responsibility to deal with this.\n*/\nint lsmFsReadSyncedId(lsm_db *db, int iMeta, i64 *piVal){\n  FileSystem *pFS = db->pFS;\n  int rc = LSM_OK;\n\n  assert( iMeta==1 || iMeta==2 );\n  if( pFS->nMapLimit>0 ){\n    fsGrowMapping(pFS, iMeta*LSM_META_PAGE_SIZE, &rc);\n    if( rc==LSM_OK ){\n      *piVal = (i64)lsmGetU64(&((u8 *)pFS->pMap)[(iMeta-1)*LSM_META_PAGE_SIZE]);\n    }\n  }else{\n    MetaPage *pMeta = 0;\n    rc = lsmFsMetaPageGet(pFS, 0, iMeta, &pMeta);\n    if( rc==LSM_OK ){\n      *piVal = (i64)lsmGetU64(pMeta->aData);\n      lsmFsMetaPageRelease(pMeta);\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** Return true if the first or last page of segment pRun falls between iFirst\n** and iLast, inclusive, and pRun is not equal to pIgnore.\n*/\nstatic int fsRunEndsBetween(\n  Segment *pRun, \n  Segment *pIgnore, \n  Pgno iFirst, \n  Pgno iLast\n){\n  return (pRun!=pIgnore && (\n        (pRun->iFirst>=iFirst && pRun->iFirst<=iLast)\n     || (pRun->iLastPg>=iFirst && pRun->iLastPg<=iLast)\n  ));\n}\n\n/*\n** Return true if level pLevel contains a segment other than pIgnore for\n** which the first or last page is between iFirst and iLast, inclusive.\n*/\nstatic int fsLevelEndsBetween(\n  Level *pLevel, \n  Segment *pIgnore, \n  Pgno iFirst, \n  Pgno iLast\n){\n  int i;\n\n  if( fsRunEndsBetween(&pLevel->lhs, pIgnore, iFirst, iLast) ){\n    return 1;\n  }\n  for(i=0; i<pLevel->nRight; i++){\n    if( fsRunEndsBetween(&pLevel->aRhs[i], pIgnore, iFirst, iLast) ){\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Block iBlk is no longer in use by segment pIgnore. If it is not in use\n** by any other segment, move it to the free block list.\n*/\nstatic int fsFreeBlock(\n  FileSystem *pFS,                /* File system object */\n  Snapshot *pSnapshot,            /* Worker snapshot */\n  Segment *pIgnore,               /* Ignore this run when searching */\n  int iBlk                        /* Block number of block to free */\n){\n  int rc = LSM_OK;                /* Return code */\n  Pgno iFirst;                    /* First page on block iBlk */\n  Pgno iLast;                     /* Last page on block iBlk */\n  Level *pLevel;                  /* Used to iterate through levels */\n\n  int iIn;                        /* Used to iterate through append points */\n  int iOut = 0;                   /* Used to output append points */\n  Pgno *aApp = pSnapshot->aiAppend;\n\n  iFirst = fsFirstPageOnBlock(pFS, iBlk);\n  iLast = fsLastPageOnBlock(pFS, iBlk);\n\n  /* Check if any other run in the snapshot has a start or end page \n  ** within this block. If there is such a run, return early. */\n  for(pLevel=lsmDbSnapshotLevel(pSnapshot); pLevel; pLevel=pLevel->pNext){\n    if( fsLevelEndsBetween(pLevel, pIgnore, iFirst, iLast) ){\n      return LSM_OK;\n    }\n  }\n\n  /* Remove any entries that lie on this block from the append-list. */\n  for(iIn=0; iIn<LSM_APPLIST_SZ; iIn++){\n    if( aApp[iIn]<iFirst || aApp[iIn]>iLast ){\n      aApp[iOut++] = aApp[iIn];\n    }\n  }\n  while( iOut<LSM_APPLIST_SZ ) aApp[iOut++] = 0;\n\n  if( rc==LSM_OK ){\n    rc = lsmBlockFree(pFS->pDb, iBlk);\n  }\n  return rc;\n}\n\n/*\n** Delete or otherwise recycle the blocks currently occupied by run pDel.\n*/\nint lsmFsSortedDelete(\n  FileSystem *pFS, \n  Snapshot *pSnapshot,\n  int bZero,                      /* True to zero the Segment structure */\n  Segment *pDel\n){\n  if( pDel->iFirst ){\n    int rc = LSM_OK;\n\n    int iBlk;\n    int iLastBlk;\n\n    iBlk = fsPageToBlock(pFS, pDel->iFirst);\n    iLastBlk = fsPageToBlock(pFS, pDel->iLastPg);\n\n    /* Mark all blocks currently used by this sorted run as free */\n    while( iBlk && rc==LSM_OK ){\n      int iNext = 0;\n      if( iBlk!=iLastBlk ){\n        rc = fsBlockNext(pFS, pDel, iBlk, &iNext);\n      }else if( bZero==0 && pDel->iLastPg!=fsLastPageOnBlock(pFS, iLastBlk) ){\n        break;\n      }\n      rc = fsFreeBlock(pFS, pSnapshot, pDel, iBlk);\n      iBlk = iNext;\n    }\n\n    if( pDel->pRedirect ){\n      assert( pDel->pRedirect==&pSnapshot->redirect );\n      pSnapshot->redirect.n = 0;\n    }\n\n    if( bZero ) memset(pDel, 0, sizeof(Segment));\n  }\n  return LSM_OK;\n}\n\n/*\n** aPgno is an array containing nPgno page numbers. Return the smallest page\n** number from the array that falls on block iBlk. Or, if none of the pages\n** in aPgno[] fall on block iBlk, return 0.\n*/\nstatic Pgno firstOnBlock(FileSystem *pFS, int iBlk, Pgno *aPgno, int nPgno){\n  Pgno iRet = 0;\n  int i;\n  for(i=0; i<nPgno; i++){\n    Pgno iPg = aPgno[i];\n    if( fsPageToBlock(pFS, iPg)==iBlk && (iRet==0 || iPg<iRet) ){\n      iRet = iPg;\n    }\n  }\n  return iRet;\n}\n\n#ifndef NDEBUG\n/*\n** Return true if page iPg, which is a part of segment p, lies on\n** a redirected block. \n*/\nstatic int fsPageRedirects(FileSystem *pFS, Segment *p, Pgno iPg){\n  return (iPg!=0 && iPg!=lsmFsRedirectPage(pFS, p->pRedirect, iPg));\n}\n\n/*\n** Return true if the second argument is not NULL and any of the first\n** last or root pages lie on a redirected block. \n*/\nstatic int fsSegmentRedirects(FileSystem *pFS, Segment *p){\n  return (p && (\n      fsPageRedirects(pFS, p, p->iFirst)\n   || fsPageRedirects(pFS, p, p->iRoot)\n   || fsPageRedirects(pFS, p, p->iLastPg)\n  ));\n}\n#endif\n\n/*\n** Argument aPgno is an array of nPgno page numbers. All pages belong to\n** the segment pRun. This function gobbles from the start of the run to the\n** first page that appears in aPgno[] (i.e. so that the aPgno[] entry is\n** the new first page of the run).\n*/\nvoid lsmFsGobble(\n  lsm_db *pDb,\n  Segment *pRun, \n  Pgno *aPgno,\n  int nPgno\n){\n  int rc = LSM_OK;\n  FileSystem *pFS = pDb->pFS;\n  Snapshot *pSnapshot = pDb->pWorker;\n  int iBlk;\n\n  assert( pRun->nSize>0 );\n  assert( 0==fsSegmentRedirects(pFS, pRun) );\n  assert( nPgno>0 && 0==fsPageRedirects(pFS, pRun, aPgno[0]) );\n\n  iBlk = fsPageToBlock(pFS, pRun->iFirst);\n  pRun->nSize += (int)(pRun->iFirst - fsFirstPageOnBlock(pFS, iBlk));\n\n  while( rc==LSM_OK ){\n    int iNext = 0;\n    Pgno iFirst = firstOnBlock(pFS, iBlk, aPgno, nPgno);\n    if( iFirst ){\n      pRun->iFirst = iFirst;\n      break;\n    }\n    rc = fsBlockNext(pFS, pRun, iBlk, &iNext);\n    if( rc==LSM_OK ) rc = fsFreeBlock(pFS, pSnapshot, pRun, iBlk);\n    pRun->nSize -= (int)(\n        1 + fsLastPageOnBlock(pFS, iBlk) - fsFirstPageOnBlock(pFS, iBlk)\n    );\n    iBlk = iNext;\n  }\n\n  pRun->nSize -= (int)(pRun->iFirst - fsFirstPageOnBlock(pFS, iBlk));\n  assert( pRun->nSize>0 );\n}\n\n/*\n** This function is only used in compressed database mode.\n**\n** Argument iPg is the page number (byte offset) of a page within segment\n** pSeg. The page record, including all headers, is nByte bytes in size.\n** Before returning, set *piNext to the page number of the next page in\n** the segment, or to zero if iPg is the last.\n**\n** In other words, do:\n**\n**   *piNext = iPg + nByte;\n**\n** But take block overflow and redirection into account.\n*/\nstatic int fsNextPageOffset(\n  FileSystem *pFS,                /* File system object */\n  Segment *pSeg,                  /* Segment to move within */\n  Pgno iPg,                       /* Offset of current page */\n  int nByte,                      /* Size of current page including headers */\n  Pgno *piNext                    /* OUT: Offset of next page. Or zero (EOF) */\n){\n  Pgno iNext;\n  int rc;\n\n  assert( pFS->pCompress );\n\n  rc = fsAddOffset(pFS, pSeg, iPg, nByte-1, &iNext);\n  if( pSeg && iNext==pSeg->iLastPg ){\n    iNext = 0;\n  }else if( rc==LSM_OK ){\n    rc = fsAddOffset(pFS, pSeg, iNext, 1, &iNext);\n  }\n\n  *piNext = iNext;\n  return rc;\n}\n\n/*\n** This function is only used in compressed database mode.\n**\n** Argument iPg is the page number of a pagethat appears in segment pSeg.\n** This function determines the page number of the previous page in the\n** same run. *piPrev is set to the previous page number before returning.\n**\n** LSM_OK is returned if no error occurs. Otherwise, an lsm error code.\n** If any value other than LSM_OK is returned, then the final value of\n** *piPrev is undefined.\n*/\nstatic int fsGetPageBefore(\n  FileSystem *pFS, \n  Segment *pSeg, \n  Pgno iPg, \n  Pgno *piPrev\n){\n  u8 aSz[3];\n  int rc;\n  i64 iRead;\n\n  assert( pFS->pCompress );\n\n  rc = fsSubtractOffset(pFS, pSeg, iPg, sizeof(aSz), &iRead);\n  if( rc==LSM_OK ) rc = fsReadData(pFS, pSeg, iRead, aSz, sizeof(aSz));\n\n  if( rc==LSM_OK ){\n    int bFree;\n    int nSz;\n    if( aSz[2] & 0x80 ){\n      nSz = getRecordSize(aSz, &bFree) + sizeof(aSz)*2;\n    }else{\n      nSz = (int)(aSz[2] & 0x7F);\n      bFree = 1;\n    }\n    rc = fsSubtractOffset(pFS, pSeg, iPg, nSz, piPrev);\n  }\n\n  return rc;\n}\n\n/*\n** The first argument to this function is a valid reference to a database\n** file page that is part of a sorted run. If parameter eDir is -1, this \n** function attempts to locate and load the previous page in the same run. \n** Or, if eDir is +1, it attempts to find the next page in the same run.\n** The results of passing an eDir value other than positive or negative one\n** are undefined.\n**\n** If parameter pRun is not NULL then it must point to the run that page\n** pPg belongs to. In this case, if pPg is the first or last page of the\n** run, and the request is for the previous or next page, respectively,\n** *ppNext is set to NULL before returning LSM_OK. If pRun is NULL, then it\n** is assumed that the next or previous page, as requested, exists.\n**\n** If the previous/next page does exist and is successfully loaded, *ppNext\n** is set to point to it and LSM_OK is returned. Otherwise, if an error \n** occurs, *ppNext is set to NULL and and lsm error code returned.\n**\n** Page references returned by this function should be released by the \n** caller using lsmFsPageRelease().\n*/\nint lsmFsDbPageNext(Segment *pRun, Page *pPg, int eDir, Page **ppNext){\n  int rc = LSM_OK;\n  FileSystem *pFS = pPg->pFS;\n  Pgno iPg = pPg->iPg;\n\n  assert( 0==fsSegmentRedirects(pFS, pRun) );\n  if( pFS->pCompress ){\n    int nSpace = pPg->nCompress + 2*3;\n\n    do {\n      if( eDir>0 ){\n        rc = fsNextPageOffset(pFS, pRun, iPg, nSpace, &iPg);\n      }else{\n        if( iPg==pRun->iFirst ){\n          iPg = 0;\n        }else{\n          rc = fsGetPageBefore(pFS, pRun, iPg, &iPg);\n        }\n      }\n\n      nSpace = 0;\n      if( iPg!=0 ){\n        rc = fsPageGet(pFS, pRun, iPg, 0, ppNext, &nSpace);\n        assert( (*ppNext==0)==(rc!=LSM_OK || nSpace>0) );\n      }else{\n        *ppNext = 0;\n      }\n    }while( nSpace>0 && rc==LSM_OK );\n\n  }else{\n    Redirect *pRedir = pRun ? pRun->pRedirect : 0;\n    assert( eDir==1 || eDir==-1 );\n    if( eDir<0 ){\n      if( pRun && iPg==pRun->iFirst ){\n        *ppNext = 0;\n        return LSM_OK;\n      }else if( fsIsFirst(pFS, iPg) ){\n        assert( pPg->flags & PAGE_HASPREV );\n        iPg = fsLastPageOnBlock(pFS, lsmGetU32(&pPg->aData[-4]));\n      }else{\n        iPg--;\n      }\n    }else{\n      if( pRun ){\n        if( iPg==pRun->iLastPg ){\n          *ppNext = 0;\n          return LSM_OK;\n        }\n      }\n\n      if( fsIsLast(pFS, iPg) ){\n        int iBlk = fsRedirectBlock(\n            pRedir, lsmGetU32(&pPg->aData[pFS->nPagesize-4])\n        );\n        iPg = fsFirstPageOnBlock(pFS, iBlk);\n      }else{\n        iPg++;\n      }\n    }\n    rc = fsPageGet(pFS, pRun, iPg, 0, ppNext, 0);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called when creating a new segment to determine if the\n** first part of it can be written following an existing segment on an\n** already allocated block. If it is possible, the page number of the first\n** page to use for the new segment is returned. Otherwise zero.\n**\n** If argument pLvl is not NULL, then this function will not attempt to\n** start the new segment immediately following any segment that is part\n** of the right-hand-side of pLvl.\n*/\nstatic Pgno findAppendPoint(FileSystem *pFS, Level *pLvl){\n  int i;\n  Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;\n  Pgno iRet = 0;\n\n  for(i=LSM_APPLIST_SZ-1; iRet==0 && i>=0; i--){\n    if( (iRet = aiAppend[i]) ){\n      if( pLvl ){\n        int iBlk = fsPageToBlock(pFS, iRet);\n        int j;\n        for(j=0; iRet && j<pLvl->nRight; j++){\n          if( fsPageToBlock(pFS, pLvl->aRhs[j].iLastPg)==iBlk ){\n            iRet = 0;\n          }\n        }\n      }\n      if( iRet ) aiAppend[i] = 0;\n    }\n  }\n  return iRet;\n}\n\n/*\n** Append a page to the left-hand-side of pLvl. Set the ref-count to 1 and\n** return a pointer to it. The page is writable until either \n** lsmFsPagePersist() is called on it or the ref-count drops to zero.\n*/\nint lsmFsSortedAppend(\n  FileSystem *pFS, \n  Snapshot *pSnapshot,\n  Level *pLvl,\n  int bDefer,\n  Page **ppOut\n){\n  int rc = LSM_OK;\n  Page *pPg = 0;\n  Pgno iApp = 0;\n  Pgno iNext = 0;\n  Segment *p = &pLvl->lhs;\n  Pgno iPrev = p->iLastPg;\n\n  *ppOut = 0;\n  assert( p->pRedirect==0 );\n\n  if( pFS->pCompress || bDefer ){\n    /* In compressed database mode the page is not assigned a page number\n    ** or location in the database file at this point. This will be done\n    ** by the lsmFsPagePersist() call.  */\n    rc = fsPageBuffer(pFS, &pPg);\n    if( rc==LSM_OK ){\n      pPg->pFS = pFS;\n      pPg->pSeg = p;\n      pPg->iPg = 0;\n      pPg->flags |= PAGE_DIRTY;\n      pPg->nData = pFS->nPagesize;\n      assert( pPg->aData );\n      if( pFS->pCompress==0 ) pPg->nData -= 4;\n\n      pPg->nRef = 1;\n      pFS->nOut++;\n    }\n  }else{\n    if( iPrev==0 ){\n      iApp = findAppendPoint(pFS, pLvl);\n    }else if( fsIsLast(pFS, iPrev) ){\n      int iNext2;\n      rc = fsBlockNext(pFS, 0, fsPageToBlock(pFS, iPrev), &iNext2);\n      if( rc!=LSM_OK ) return rc;\n      iApp = fsFirstPageOnBlock(pFS, iNext2);\n    }else{\n      iApp = iPrev + 1;\n    }\n\n    /* If this is the first page allocated, or if the page allocated is the\n    ** last in the block, also allocate the next block here.  */\n    if( iApp==0 || fsIsLast(pFS, iApp) ){\n      int iNew;                     /* New block number */\n\n      rc = lsmBlockAllocate(pFS->pDb, 0, &iNew);\n      if( rc!=LSM_OK ) return rc;\n      if( iApp==0 ){\n        iApp = fsFirstPageOnBlock(pFS, iNew);\n      }else{\n        iNext = fsFirstPageOnBlock(pFS, iNew);\n      }\n    }\n\n    /* Grab the new page. */\n    pPg = 0;\n    rc = fsPageGet(pFS, 0, iApp, 1, &pPg, 0);\n    assert( rc==LSM_OK || pPg==0 );\n\n    /* If this is the first or last page of a block, fill in the pointer \n     ** value at the end of the new page. */\n    if( rc==LSM_OK ){\n      p->nSize++;\n      p->iLastPg = iApp;\n      if( p->iFirst==0 ) p->iFirst = iApp;\n      pPg->flags |= PAGE_DIRTY;\n\n      if( fsIsLast(pFS, iApp) ){\n        lsmPutU32(&pPg->aData[pFS->nPagesize-4], fsPageToBlock(pFS, iNext));\n      }else if( fsIsFirst(pFS, iApp) ){\n        lsmPutU32(&pPg->aData[-4], fsPageToBlock(pFS, iPrev));\n      }\n    }\n  }\n\n  *ppOut = pPg;\n  return rc;\n}\n\n/*\n** Mark the segment passed as the second argument as finished. Once a segment\n** is marked as finished it is not possible to append any further pages to \n** it.\n**\n** Return LSM_OK if successful or an lsm error code if an error occurs.\n*/\nint lsmFsSortedFinish(FileSystem *pFS, Segment *p){\n  int rc = LSM_OK;\n  if( p && p->iLastPg ){\n    assert( p->pRedirect==0 );\n\n    /* Check if the last page of this run happens to be the last of a block.\n    ** If it is, then an extra block has already been allocated for this run.\n    ** Shift this extra block back to the free-block list. \n    **\n    ** Otherwise, add the first free page in the last block used by the run\n    ** to the lAppend list.\n    */\n    if( fsLastPageOnPagesBlock(pFS, p->iLastPg)!=p->iLastPg ){\n      int i;\n      Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;\n      for(i=0; i<LSM_APPLIST_SZ; i++){\n        if( aiAppend[i]==0 ){\n          aiAppend[i] = p->iLastPg+1;\n          break;\n        }\n      }\n    }else if( pFS->pCompress==0 ){\n      Page *pLast;\n      rc = fsPageGet(pFS, 0, p->iLastPg, 0, &pLast, 0);\n      if( rc==LSM_OK ){\n        int iBlk = (int)lsmGetU32(&pLast->aData[pFS->nPagesize-4]);\n        lsmBlockRefree(pFS->pDb, iBlk);\n        lsmFsPageRelease(pLast);\n      }\n    }else{\n      int iBlk = 0;\n      rc = fsBlockNext(pFS, p, fsPageToBlock(pFS, p->iLastPg), &iBlk);\n      if( rc==LSM_OK ){\n        lsmBlockRefree(pFS->pDb, iBlk);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Obtain a reference to page number iPg.\n**\n** Return LSM_OK if successful, or an lsm error code if an error occurs.\n*/\nint lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, Pgno iPg, Page **ppPg){\n  return fsPageGet(pFS, pSeg, iPg, 0, ppPg, 0);\n}\n\n/*\n** Obtain a reference to the last page in the segment passed as the \n** second argument.\n**\n** Return LSM_OK if successful, or an lsm error code if an error occurs.\n*/\nint lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg){\n  int rc;\n  Pgno iPg = pSeg->iLastPg;\n  if( pFS->pCompress ){\n    int nSpace;\n    iPg++;\n    do {\n      nSpace = 0;\n      rc = fsGetPageBefore(pFS, pSeg, iPg, &iPg);\n      if( rc==LSM_OK ){\n        rc = fsPageGet(pFS, pSeg, iPg, 0, ppPg, &nSpace);\n      }\n    }while( rc==LSM_OK && nSpace>0 );\n\n  }else{\n    rc = fsPageGet(pFS, pSeg, iPg, 0, ppPg, 0);\n  }\n  return rc;\n}\n\n/*\n** Return a reference to meta-page iPg. If successful, LSM_OK is returned\n** and *ppPg populated with the new page reference. The reference should\n** be released by the caller using lsmFsPageRelease().\n**\n** Otherwise, if an error occurs, *ppPg is set to NULL and an LSM error \n** code is returned.\n*/\nint lsmFsMetaPageGet(\n  FileSystem *pFS,                /* File-system connection */\n  int bWrite,                     /* True for write access, false for read */\n  int iPg,                        /* Either 1 or 2 */\n  MetaPage **ppPg                 /* OUT: Pointer to MetaPage object */\n){\n  int rc = LSM_OK;\n  MetaPage *pPg;\n  assert( iPg==1 || iPg==2 );\n\n  pPg = lsmMallocZeroRc(pFS->pEnv, sizeof(Page), &rc);\n\n  if( pPg ){\n    i64 iOff = (iPg-1) * pFS->nMetasize;\n    if( pFS->nMapLimit>0 ){\n      fsGrowMapping(pFS, 2*pFS->nMetasize, &rc);\n      pPg->aData = (u8 *)(pFS->pMap) + iOff;\n    }else{\n      pPg->aData = lsmMallocRc(pFS->pEnv, pFS->nMetasize, &rc);\n      if( rc==LSM_OK && bWrite==0 ){\n        rc = lsmEnvRead(\n            pFS->pEnv, pFS->fdDb, iOff, pPg->aData, pFS->nMetaRwSize\n        );\n      }\n#ifndef NDEBUG\n      /* pPg->aData causes an uninitialized access via a downstreadm write().\n         After discussion on this list, this memory should not, for performance\n         reasons, be memset. However, tracking down \"real\" misuse is more\n         difficult with this \"false\" positive, so it is set when NDEBUG.\n      */\n      else if( rc==LSM_OK ){\n        memset( pPg->aData, 0x77, pFS->nMetasize );\n      }\n#endif\n    }\n\n    if( rc!=LSM_OK ){\n      if( pFS->nMapLimit==0 ) lsmFree(pFS->pEnv, pPg->aData);\n      lsmFree(pFS->pEnv, pPg);\n      pPg = 0;\n    }else{\n      pPg->iPg = iPg;\n      pPg->bWrite = bWrite;\n      pPg->pFS = pFS;\n    }\n  }\n\n  *ppPg = pPg;\n  return rc;\n}\n\n/*\n** Release a meta-page reference obtained via a call to lsmFsMetaPageGet().\n*/\nint lsmFsMetaPageRelease(MetaPage *pPg){\n  int rc = LSM_OK;\n  if( pPg ){\n    FileSystem *pFS = pPg->pFS;\n\n    if( pFS->nMapLimit==0 ){\n      if( pPg->bWrite ){\n        i64 iOff = (pPg->iPg==2 ? pFS->nMetasize : 0);\n        int nWrite = pFS->nMetaRwSize;\n        rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iOff, pPg->aData, nWrite);\n      }\n      lsmFree(pFS->pEnv, pPg->aData);\n    }\n\n    lsmFree(pFS->pEnv, pPg);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to a buffer containing the data associated with the\n** meta-page passed as the first argument. If parameter pnData is not NULL,\n** set *pnData to the size of the meta-page in bytes before returning.\n*/\nu8 *lsmFsMetaPageData(MetaPage *pPg, int *pnData){\n  if( pnData ) *pnData = pPg->pFS->nMetaRwSize;\n  return pPg->aData;\n}\n\n/*\n** Return true if page is currently writable. This is used in assert() \n** statements only.\n*/\n#ifndef NDEBUG\nint lsmFsPageWritable(Page *pPg){\n  return (pPg->flags & PAGE_DIRTY) ? 1 : 0;\n}\n#endif\n\n/*\n** This is called when block iFrom is being redirected to iTo. If page \n** number (*piPg) lies on block iFrom, then calculate the equivalent\n** page on block iTo and set *piPg to this value before returning.\n*/\nstatic void fsMovePage(\n  FileSystem *pFS,                /* File system object */\n  int iTo,                        /* Destination block */\n  int iFrom,                      /* Source block */\n  Pgno *piPg                      /* IN/OUT: Page number */\n){\n  Pgno iPg = *piPg;\n  if( iFrom==fsPageToBlock(pFS, iPg) ){\n    const int nPagePerBlock = (\n        pFS->pCompress ? pFS ->nBlocksize : (pFS->nBlocksize / pFS->nPagesize)\n    );\n    *piPg = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;\n  }\n}\n\n/*\n** Copy the contents of block iFrom to block iTo. \n**\n** It is safe to assume that there are no outstanding references to pages \n** on block iTo. And that block iFrom is not currently being written. In\n** other words, the data can be read and written directly.\n*/\nint lsmFsMoveBlock(FileSystem *pFS, Segment *pSeg, int iTo, int iFrom){\n  Snapshot *p = pFS->pDb->pWorker;\n  int rc = LSM_OK;\n  int i;\n  i64 nMap;\n\n  i64 iFromOff = (i64)(iFrom-1) * pFS->nBlocksize;\n  i64 iToOff = (i64)(iTo-1) * pFS->nBlocksize;\n  \n  assert( iTo!=1 );\n  assert( iFrom>iTo );\n\n  /* Grow the mapping as required. */\n  nMap = LSM_MIN(pFS->nMapLimit, (i64)iFrom * pFS->nBlocksize);\n  fsGrowMapping(pFS, nMap, &rc);\n\n  if( rc==LSM_OK ){\n    const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);\n    int nSz = pFS->nPagesize;\n    u8 *aBuf = 0;\n    u8 *aData = 0;\n\n    for(i=0; rc==LSM_OK && i<nPagePerBlock; i++){\n      i64 iOff = iFromOff + i*nSz;\n\n      /* Set aData to point to a buffer containing the from page */\n      if( (iOff+nSz)<=pFS->nMapLimit ){\n        u8 *aMap = (u8 *)(pFS->pMap);\n        aData = &aMap[iOff];\n      }else{\n        if( aBuf==0 ){\n          aBuf = (u8 *)lsmMallocRc(pFS->pEnv, nSz, &rc);\n          if( aBuf==0 ) break;\n        }\n        aData = aBuf;\n        rc = lsmEnvRead(pFS->pEnv, pFS->fdDb, iOff, aData, nSz);\n      }\n\n      /* Copy aData to the to page */\n      if( rc==LSM_OK ){\n        iOff = iToOff + i*nSz;\n        if( (iOff+nSz)<=pFS->nMapLimit ){\n          u8 *aMap = (u8 *)(pFS->pMap);\n          memcpy(&aMap[iOff], aData, nSz);\n        }else{\n          rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iOff, aData, nSz);\n        }\n      }\n    }\n    lsmFree(pFS->pEnv, aBuf);\n    lsmFsPurgeCache(pFS);\n  }\n\n  /* Update append-point list if necessary */\n  for(i=0; i<LSM_APPLIST_SZ; i++){\n    fsMovePage(pFS, iTo, iFrom, &p->aiAppend[i]);\n  }\n\n  /* Update the Segment structure itself */\n  fsMovePage(pFS, iTo, iFrom, &pSeg->iFirst);\n  fsMovePage(pFS, iTo, iFrom, &pSeg->iLastPg);\n  fsMovePage(pFS, iTo, iFrom, &pSeg->iRoot);\n\n  return rc;\n}\n\n/*\n** Append raw data to a segment. Return the database file offset that the\n** data is written to (this may be used as the page number if the data\n** being appended is a new page record).\n**\n** This function is only used in compressed database mode.\n*/\nstatic Pgno fsAppendData(\n  FileSystem *pFS,                /* File-system handle */\n  Segment *pSeg,                  /* Segment to append to */\n  const u8 *aData,                /* Buffer containing data to write */\n  int nData,                      /* Size of buffer aData[] in bytes */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  Pgno iRet = 0;\n  int rc = *pRc;\n  assert( pFS->pCompress );\n  if( rc==LSM_OK ){\n    int nRem = 0;\n    int nWrite = 0;\n    Pgno iLastOnBlock;\n    Pgno iApp = pSeg->iLastPg+1;\n\n    /* If this is the first data written into the segment, find an append-point\n    ** or allocate a new block.  */\n    if( iApp==1 ){\n      pSeg->iFirst = iApp = findAppendPoint(pFS, 0);\n      if( iApp==0 ){\n        int iBlk;\n        rc = lsmBlockAllocate(pFS->pDb, 0, &iBlk);\n        pSeg->iFirst = iApp = fsFirstPageOnBlock(pFS, iBlk);\n      }\n    }\n    iRet = iApp;\n\n    /* Write as much data as is possible at iApp (usually all of it). */\n    iLastOnBlock = fsLastPageOnPagesBlock(pFS, iApp);\n    if( rc==LSM_OK ){\n      int nSpace = (int)(iLastOnBlock - iApp + 1);\n      nWrite = LSM_MIN(nData, nSpace);\n      nRem = nData - nWrite;\n      assert( nWrite>=0 );\n      if( nWrite!=0 ){\n        rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iApp, aData, nWrite);\n      }\n      iApp += nWrite;\n    }\n\n    /* If required, allocate a new block and write the rest of the data\n    ** into it. Set the next and previous block pointers to link the new\n    ** block to the old.  */\n    assert( nRem<=0 || (iApp-1)==iLastOnBlock );\n    if( rc==LSM_OK && (iApp-1)==iLastOnBlock ){\n      u8 aPtr[4];                 /* Space to serialize a u32 */\n      int iBlk;                   /* New block number */\n\n      if( nWrite>0 ){\n        /* Allocate a new block. */\n        rc = lsmBlockAllocate(pFS->pDb, 0, &iBlk);\n\n        /* Set the \"next\" pointer on the old block */\n        if( rc==LSM_OK ){\n          assert( iApp==(fsPageToBlock(pFS, iApp)*pFS->nBlocksize)-4 );\n          lsmPutU32(aPtr, iBlk);\n          rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iApp, aPtr, sizeof(aPtr));\n        }\n\n        /* Set the \"prev\" pointer on the new block */\n        if( rc==LSM_OK ){\n          Pgno iWrite;\n          lsmPutU32(aPtr, fsPageToBlock(pFS, iApp));\n          iWrite = fsFirstPageOnBlock(pFS, iBlk);\n          rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iWrite-4, aPtr, sizeof(aPtr));\n          if( nRem>0 ) iApp = iWrite;\n        }\n      }else{\n        /* The next block is already allocated. */\n        assert( nRem>0 );\n        assert( pSeg->pRedirect==0 );\n        rc = fsBlockNext(pFS, 0, fsPageToBlock(pFS, iApp), &iBlk);\n        iRet = iApp = fsFirstPageOnBlock(pFS, iBlk);\n      }\n\n      /* Write the remaining data into the new block */\n      if( rc==LSM_OK && nRem>0 ){\n        rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iApp, &aData[nWrite], nRem);\n        iApp += nRem;\n      }\n    }\n\n    pSeg->iLastPg = iApp-1;\n    *pRc = rc;\n  }\n\n  return iRet;\n}\n\n/*\n** This function is only called in compressed database mode. It \n** compresses the contents of page pPg and writes the result to the \n** buffer at pFS->aOBuffer. The size of the compressed data is stored in\n** pPg->nCompress.\n**\n** If buffer pFS->aOBuffer[] has not been allocated then this function\n** allocates it. If this fails, LSM_NOMEM is returned. Otherwise, LSM_OK.\n*/\nstatic int fsCompressIntoBuffer(FileSystem *pFS, Page *pPg){\n  lsm_compress *p = pFS->pCompress;\n\n  if( fsAllocateBuffer(pFS, 1) ) return LSM_NOMEM;\n  assert( pPg->nData==pFS->nPagesize );\n\n  pPg->nCompress = pFS->nBuffer;\n  return p->xCompress(p->pCtx, \n      (char *)pFS->aOBuffer, &pPg->nCompress, \n      (const char *)pPg->aData, pPg->nData\n  );\n}\n\n/*\n** Append a new page to segment pSeg. Set output variable *piNew to the\n** page number of the new page before returning.\n**\n** If the new page is the last on its block, then the 'next' block that\n** will be used by the segment is allocated here too. In this case output\n** variable *piNext is set to the block number of the next block.\n**\n** If the new page is the first on its block but not the first in the\n** entire segment, set output variable *piPrev to the block number of\n** the previous block in the segment.\n**\n** LSM_OK is returned if successful, or an lsm error code otherwise. If\n** any value other than LSM_OK is returned, then the final value of all\n** output variables is undefined.\n*/\nstatic int fsAppendPage(\n  FileSystem *pFS, \n  Segment *pSeg,\n  Pgno *piNew,\n  int *piPrev,\n  int *piNext\n){\n  Pgno iPrev = pSeg->iLastPg;\n  int rc;\n  assert( iPrev!=0 );\n\n  *piPrev = 0;\n  *piNext = 0;\n\n  if( fsIsLast(pFS, iPrev) ){\n    /* Grab the first page on the next block (which has already be\n    ** allocated). In this case set *piPrev to tell the caller to set\n    ** the \"previous block\" pointer in the first 4 bytes of the page.\n    */\n    int iNext;\n    int iBlk = fsPageToBlock(pFS, iPrev);\n    assert( pSeg->pRedirect==0 );\n    rc = fsBlockNext(pFS, 0, iBlk, &iNext);\n    if( rc!=LSM_OK ) return rc;\n    *piNew = fsFirstPageOnBlock(pFS, iNext);\n    *piPrev = iBlk;\n  }else{\n    *piNew = iPrev+1;\n    if( fsIsLast(pFS, *piNew) ){\n      /* Allocate the next block here. */\n      int iBlk;\n      rc = lsmBlockAllocate(pFS->pDb, 0, &iBlk);\n      if( rc!=LSM_OK ) return rc;\n      *piNext = iBlk;\n    }\n  }\n\n  pSeg->nSize++;\n  pSeg->iLastPg = *piNew;\n  return LSM_OK;\n}\n\n/*\n** Flush all pages in the FileSystem.pWaiting list to disk.\n*/\nvoid lsmFsFlushWaiting(FileSystem *pFS, int *pRc){\n  int rc = *pRc;\n  Page *pPg;\n\n  pPg = pFS->pWaiting;\n  pFS->pWaiting = 0;\n\n  while( pPg ){\n    Page *pNext = pPg->pWaitingNext;\n    if( rc==LSM_OK ) rc = lsmFsPagePersist(pPg);\n    assert( pPg->nRef==1 );\n    lsmFsPageRelease(pPg);\n    pPg = pNext;\n  }\n  *pRc = rc;\n}\n\n/*\n** If there exists a hash-table entry associated with page iPg, remove it.\n*/\nstatic void fsRemoveHashEntry(FileSystem *pFS, Pgno iPg){\n  Page *p;\n  int iHash = fsHashKey(pFS->nHash, iPg);\n\n  for(p=pFS->apHash[iHash]; p && p->iPg!=iPg; p=p->pHashNext);\n\n  if( p ){\n    assert( p->nRef==0 || (p->flags & PAGE_FREE)==0 );\n    fsPageRemoveFromHash(pFS, p);\n    p->iPg = 0;\n    iHash = fsHashKey(pFS->nHash, 0);\n    p->pHashNext = pFS->apHash[iHash];\n    pFS->apHash[iHash] = p;\n  }\n}\n\n/*\n** If the page passed as an argument is dirty, update the database file\n** (or mapping of the database file) with its current contents and mark\n** the page as clean.\n**\n** Return LSM_OK if the operation is a success, or an LSM error code\n** otherwise.\n*/\nint lsmFsPagePersist(Page *pPg){\n  int rc = LSM_OK;\n  if( pPg && (pPg->flags & PAGE_DIRTY) ){\n    FileSystem *pFS = pPg->pFS;\n\n    if( pFS->pCompress ){\n      int iHash;                  /* Hash key of assigned page number */\n      u8 aSz[3];                  /* pPg->nCompress as a 24-bit big-endian */\n      assert( pPg->pSeg && pPg->iPg==0 && pPg->nCompress==0 );\n\n      /* Compress the page image. */\n      rc = fsCompressIntoBuffer(pFS, pPg);\n\n      /* Serialize the compressed size into buffer aSz[] */\n      putRecordSize(aSz, pPg->nCompress, 0);\n\n      /* Write the serialized page record into the database file. */\n      pPg->iPg = fsAppendData(pFS, pPg->pSeg, aSz, sizeof(aSz), &rc);\n      fsAppendData(pFS, pPg->pSeg, pFS->aOBuffer, pPg->nCompress, &rc);\n      fsAppendData(pFS, pPg->pSeg, aSz, sizeof(aSz), &rc);\n\n      /* Now that it has a page number, insert the page into the hash table */\n      iHash = fsHashKey(pFS->nHash, pPg->iPg);\n      pPg->pHashNext = pFS->apHash[iHash];\n      pFS->apHash[iHash] = pPg;\n\n      pPg->pSeg->nSize += (sizeof(aSz) * 2) + pPg->nCompress;\n\n      pPg->flags &= ~PAGE_DIRTY;\n      pFS->nWrite++;\n    }else{\n\n      if( pPg->iPg==0 ){\n        /* No page number has been assigned yet. This occurs with pages used\n        ** in the b-tree hierarchy. They were not assigned page numbers when\n        ** they were created as doing so would cause this call to\n        ** lsmFsPagePersist() to write an out-of-order page. Instead a page \n        ** number is assigned here so that the page data will be appended\n        ** to the current segment.\n        */\n        Page **pp;\n        int iPrev = 0;\n        int iNext = 0;\n        int iHash;\n\n        assert( pPg->pSeg->iFirst );\n        assert( pPg->flags & PAGE_FREE );\n        assert( (pPg->flags & PAGE_HASPREV)==0 );\n        assert( pPg->nData==pFS->nPagesize-4 );\n\n        rc = fsAppendPage(pFS, pPg->pSeg, &pPg->iPg, &iPrev, &iNext);\n        if( rc!=LSM_OK ) return rc;\n\n        assert( pPg->flags & PAGE_FREE );\n        iHash = fsHashKey(pFS->nHash, pPg->iPg);\n        fsRemoveHashEntry(pFS, pPg->iPg);\n        pPg->pHashNext = pFS->apHash[iHash];\n        pFS->apHash[iHash] = pPg;\n        assert( pPg->pHashNext==0 || pPg->pHashNext->iPg!=pPg->iPg );\n\n        if( iPrev ){\n          assert( iNext==0 );\n          memmove(&pPg->aData[4], pPg->aData, pPg->nData);\n          lsmPutU32(pPg->aData, iPrev);\n          pPg->flags |= PAGE_HASPREV;\n          pPg->aData += 4;\n        }else if( iNext ){\n          assert( iPrev==0 );\n          lsmPutU32(&pPg->aData[pPg->nData], iNext);\n        }else{\n          int nData = pPg->nData;\n          pPg->nData += 4;\n          lsmSortedExpandBtreePage(pPg, nData);\n        }\n\n        pPg->nRef++;\n        for(pp=&pFS->pWaiting; *pp; pp=&(*pp)->pWaitingNext);\n        *pp = pPg;\n        assert( pPg->pWaitingNext==0 );\n\n      }else{\n        i64 iOff;                   /* Offset to write within database file */\n\n        iOff = (i64)pFS->nPagesize * (i64)(pPg->iPg-1);\n        if( fsMmapPage(pFS, pPg->iPg)==0 ){\n          u8 *aData = pPg->aData - (pPg->flags & PAGE_HASPREV);\n          rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iOff, aData, pFS->nPagesize);\n        }else if( pPg->flags & PAGE_FREE ){\n          fsGrowMapping(pFS, iOff + pFS->nPagesize, &rc);\n          if( rc==LSM_OK ){\n            u8 *aTo = &((u8 *)(pFS->pMap))[iOff];\n            u8 *aFrom = pPg->aData - (pPg->flags & PAGE_HASPREV);\n            memcpy(aTo, aFrom, pFS->nPagesize);\n            lsmFree(pFS->pEnv, aFrom);\n            pFS->nCacheAlloc--;\n            pPg->aData = aTo + (pPg->flags & PAGE_HASPREV);\n            pPg->flags &= ~PAGE_FREE;\n            fsPageRemoveFromHash(pFS, pPg);\n            pPg->pMappedNext = pFS->pMapped;\n            pFS->pMapped = pPg;\n          }\n        }\n\n        lsmFsFlushWaiting(pFS, &rc);\n        pPg->flags &= ~PAGE_DIRTY;\n        pFS->nWrite++;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** For non-compressed databases, this function is a no-op. For compressed\n** databases, it adds a padding record to the segment passed as the third\n** argument.\n**\n** The size of the padding records is selected so that the last byte \n** written is the last byte of a disk sector. This means that if a \n** snapshot is taken and checkpointed, subsequent worker processes will\n** not write to any sector that contains checkpointed data.\n*/\nint lsmFsSortedPadding(\n  FileSystem *pFS, \n  Snapshot *pSnapshot,\n  Segment *pSeg\n){\n  int rc = LSM_OK;\n  if( pFS->pCompress ){\n    Pgno iLast2;\n    Pgno iLast = pSeg->iLastPg;     /* Current last page of segment */\n    int nPad;                       /* Bytes of padding required */\n    u8 aSz[3];\n\n    iLast2 = (1 + iLast/pFS->szSector) * pFS->szSector - 1;\n    assert( fsPageToBlock(pFS, iLast)==fsPageToBlock(pFS, iLast2) );\n    nPad = (int)(iLast2 - iLast);\n\n    if( iLast2>fsLastPageOnPagesBlock(pFS, iLast) ){\n      nPad -= 4;\n    }\n    assert( nPad>=0 );\n\n    if( nPad>=6 ){\n      pSeg->nSize += nPad;\n      nPad -= 6;\n      putRecordSize(aSz, nPad, 1);\n      fsAppendData(pFS, pSeg, aSz, sizeof(aSz), &rc);\n      memset(pFS->aOBuffer, 0, nPad);\n      fsAppendData(pFS, pSeg, pFS->aOBuffer, nPad, &rc);\n      fsAppendData(pFS, pSeg, aSz, sizeof(aSz), &rc);\n    }else if( nPad>0 ){\n      u8 aBuf[5] = {0,0,0,0,0};\n      aBuf[0] = (u8)nPad;\n      aBuf[nPad-1] = (u8)nPad;\n      fsAppendData(pFS, pSeg, aBuf, nPad, &rc);\n    }\n\n    assert( rc!=LSM_OK \n        || pSeg->iLastPg==fsLastPageOnPagesBlock(pFS, pSeg->iLastPg)\n        || ((pSeg->iLastPg + 1) % pFS->szSector)==0\n    );\n  }\n\n  return rc;\n}\n\n\n/*\n** Increment the reference count on the page object passed as the first\n** argument.\n*/\nvoid lsmFsPageRef(Page *pPg){\n  if( pPg ){\n    pPg->nRef++;\n  }\n}\n\n/*\n** Release a page-reference obtained using fsPageGet().\n*/\nint lsmFsPageRelease(Page *pPg){\n  int rc = LSM_OK;\n  if( pPg ){\n    assert( pPg->nRef>0 );\n    pPg->nRef--;\n    if( pPg->nRef==0 ){\n      FileSystem *pFS = pPg->pFS;\n      rc = lsmFsPagePersist(pPg);\n      pFS->nOut--;\n\n      assert( pPg->pFS->pCompress \n           || fsIsFirst(pPg->pFS, pPg->iPg)==0 \n           || (pPg->flags & PAGE_HASPREV)\n      );\n      pPg->aData -= (pPg->flags & PAGE_HASPREV);\n      pPg->flags &= ~PAGE_HASPREV;\n\n      if( (pPg->flags & PAGE_FREE)==0 ){\n        /* Removed from mapped list */\n        Page **pp;\n        for(pp=&pFS->pMapped; (*pp)!=pPg; pp=&(*pp)->pMappedNext);\n        *pp = pPg->pMappedNext;\n        pPg->pMappedNext = 0;\n\n        /* Add to free list */\n        pPg->pFreeNext = pFS->pFree;\n        pFS->pFree = pPg;\n      }else{\n        fsPageAddToLru(pFS, pPg);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return the total number of pages read from the database file.\n*/\nint lsmFsNRead(FileSystem *pFS){ return pFS->nRead; }\n\n/*\n** Return the total number of pages written to the database file.\n*/\nint lsmFsNWrite(FileSystem *pFS){ return pFS->nWrite; }\n\n/*\n** Return a copy of the environment pointer used by the file-system object.\n*/\nlsm_env *lsmFsEnv(FileSystem *pFS){ \n  return pFS->pEnv; \n}\n\n/*\n** Return a copy of the environment pointer used by the file-system object\n** to which this page belongs.\n*/\nlsm_env *lsmPageEnv(Page *pPg) { \n  return pPg->pFS->pEnv; \n}\n\n/*\n** Return a pointer to the file-system object associated with the Page\n** passed as the only argument.\n*/\nFileSystem *lsmPageFS(Page *pPg){\n  return pPg->pFS;\n}\n\n/*\n** Return the sector-size as reported by the log file handle.\n*/\nint lsmFsSectorSize(FileSystem *pFS){\n  return pFS->szSector;\n}\n\n/*\n** Helper function for lsmInfoArrayStructure().\n*/\nstatic Segment *startsWith(Segment *pRun, Pgno iFirst){\n  return (iFirst==pRun->iFirst) ? pRun : 0;\n}\n\n/*\n** Return the segment that starts with page iFirst, if any. If no such segment\n** can be found, return NULL.\n*/\nstatic Segment *findSegment(Snapshot *pWorker, Pgno iFirst){\n  Level *pLvl;                    /* Used to iterate through db levels */\n  Segment *pSeg = 0;              /* Pointer to segment to return */\n\n  for(pLvl=lsmDbSnapshotLevel(pWorker); pLvl && pSeg==0; pLvl=pLvl->pNext){\n    if( 0==(pSeg = startsWith(&pLvl->lhs, iFirst)) ){\n      int i;\n      for(i=0; i<pLvl->nRight; i++){\n        if( (pSeg = startsWith(&pLvl->aRhs[i], iFirst)) ) break;\n      }\n    }\n  }\n\n  return pSeg;\n}\n\n/*\n** This function implements the lsm_info(LSM_INFO_ARRAY_STRUCTURE) request.\n** If successful, *pzOut is set to point to a nul-terminated string \n** containing the array structure and LSM_OK is returned. The caller should\n** eventually free the string using lsmFree().\n**\n** If an error occurs, *pzOut is set to NULL and an LSM error code returned.\n*/\nint lsmInfoArrayStructure(\n  lsm_db *pDb, \n  int bBlock,                     /* True for block numbers only */\n  Pgno iFirst,\n  char **pzOut\n){\n  int rc = LSM_OK;\n  Snapshot *pWorker;              /* Worker snapshot */\n  Segment *pArray = 0;            /* Array to report on */\n  int bUnlock = 0;\n\n  *pzOut = 0;\n  if( iFirst==0 ) return LSM_ERROR;\n\n  /* Obtain the worker snapshot */\n  pWorker = pDb->pWorker;\n  if( !pWorker ){\n    rc = lsmBeginWork(pDb);\n    if( rc!=LSM_OK ) return rc;\n    pWorker = pDb->pWorker;\n    bUnlock = 1;\n  }\n\n  /* Search for the array that starts on page iFirst */\n  pArray = findSegment(pWorker, iFirst);\n\n  if( pArray==0 ){\n    /* Could not find the requested array. This is an error. */\n    rc = LSM_ERROR;\n  }else{\n    FileSystem *pFS = pDb->pFS;\n    LsmString str;\n    int iBlk;\n    int iLastBlk;\n   \n    iBlk = fsPageToBlock(pFS, pArray->iFirst);\n    iLastBlk = fsPageToBlock(pFS, pArray->iLastPg);\n\n    lsmStringInit(&str, pDb->pEnv);\n    if( bBlock ){\n      lsmStringAppendf(&str, \"%d\", iBlk);\n      while( iBlk!=iLastBlk ){\n        fsBlockNext(pFS, pArray, iBlk, &iBlk);\n        lsmStringAppendf(&str, \" %d\", iBlk);\n      }\n    }else{\n      lsmStringAppendf(&str, \"%d\", pArray->iFirst);\n      while( iBlk!=iLastBlk ){\n        lsmStringAppendf(&str, \" %d\", fsLastPageOnBlock(pFS, iBlk));\n        fsBlockNext(pFS, pArray, iBlk, &iBlk);\n        lsmStringAppendf(&str, \" %d\", fsFirstPageOnBlock(pFS, iBlk));\n      }\n      lsmStringAppendf(&str, \" %d\", pArray->iLastPg);\n    }\n\n    *pzOut = str.z;\n  }\n\n  if( bUnlock ){\n    int rcwork = LSM_BUSY;\n    lsmFinishWork(pDb, 0, &rcwork);\n  }\n  return rc;\n}\n\nint lsmFsSegmentContainsPg(\n  FileSystem *pFS, \n  Segment *pSeg, \n  Pgno iPg, \n  int *pbRes\n){\n  Redirect *pRedir = pSeg->pRedirect;\n  int rc = LSM_OK;\n  int iBlk;\n  int iLastBlk;\n  int iPgBlock;                   /* Block containing page iPg */\n\n  iPgBlock = fsPageToBlock(pFS, pSeg->iFirst);\n  iBlk = fsRedirectBlock(pRedir, fsPageToBlock(pFS, pSeg->iFirst));\n  iLastBlk = fsRedirectBlock(pRedir, fsPageToBlock(pFS, pSeg->iLastPg));\n\n  while( iBlk!=iLastBlk && iBlk!=iPgBlock && rc==LSM_OK ){\n    rc = fsBlockNext(pFS, pSeg, iBlk, &iBlk);\n  }\n\n  *pbRes = (iBlk==iPgBlock);\n  return rc;\n}\n\n/*\n** This function implements the lsm_info(LSM_INFO_ARRAY_PAGES) request.\n** If successful, *pzOut is set to point to a nul-terminated string \n** containing the array structure and LSM_OK is returned. The caller should\n** eventually free the string using lsmFree().\n**\n** If an error occurs, *pzOut is set to NULL and an LSM error code returned.\n*/\nint lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut){\n  int rc = LSM_OK;\n  Snapshot *pWorker;              /* Worker snapshot */\n  Segment *pSeg = 0;              /* Array to report on */\n  int bUnlock = 0;\n\n  *pzOut = 0;\n  if( iFirst==0 ) return LSM_ERROR;\n\n  /* Obtain the worker snapshot */\n  pWorker = pDb->pWorker;\n  if( !pWorker ){\n    rc = lsmBeginWork(pDb);\n    if( rc!=LSM_OK ) return rc;\n    pWorker = pDb->pWorker;\n    bUnlock = 1;\n  }\n\n  /* Search for the array that starts on page iFirst */\n  pSeg = findSegment(pWorker, iFirst);\n\n  if( pSeg==0 ){\n    /* Could not find the requested array. This is an error. */\n    rc = LSM_ERROR;\n  }else{\n    Page *pPg = 0;\n    FileSystem *pFS = pDb->pFS;\n    LsmString str;\n\n    lsmStringInit(&str, pDb->pEnv);\n    rc = lsmFsDbPageGet(pFS, pSeg, iFirst, &pPg);\n    while( rc==LSM_OK && pPg ){\n      Page *pNext = 0;\n      lsmStringAppendf(&str, \" %lld\", lsmFsPageNumber(pPg));\n      rc = lsmFsDbPageNext(pSeg, pPg, 1, &pNext);\n      lsmFsPageRelease(pPg);\n      pPg = pNext;\n    }\n\n    if( rc!=LSM_OK ){\n      lsmFree(pDb->pEnv, str.z);\n    }else{\n      *pzOut = str.z;\n    }\n  }\n\n  if( bUnlock ){\n    int rcwork = LSM_BUSY;\n    lsmFinishWork(pDb, 0, &rcwork);\n  }\n  return rc;\n}\n\n/*\n** The following macros are used by the integrity-check code. Associated with\n** each block in the database is an 8-bit bit mask (the entry in the aUsed[]\n** array). As the integrity-check meanders through the database, it sets the\n** following bits to indicate how each block is used.\n**\n** INTEGRITY_CHECK_FIRST_PG:\n**   First page of block is in use by sorted run.\n**\n** INTEGRITY_CHECK_LAST_PG:\n**   Last page of block is in use by sorted run.\n**\n** INTEGRITY_CHECK_USED:\n**   At least one page of the block is in use by a sorted run.\n**\n** INTEGRITY_CHECK_FREE:\n**   The free block list contains an entry corresponding to this block.\n*/\n#define INTEGRITY_CHECK_FIRST_PG 0x01\n#define INTEGRITY_CHECK_LAST_PG  0x02\n#define INTEGRITY_CHECK_USED     0x04\n#define INTEGRITY_CHECK_FREE     0x08\n\n/*\n** Helper function for lsmFsIntegrityCheck()\n*/\nstatic void checkBlocks(\n  FileSystem *pFS, \n  Segment *pSeg,\n  int bExtra,                     /* If true, count the \"next\" block if any */\n  int nUsed,\n  u8 *aUsed\n){\n  if( pSeg ){\n    if( pSeg && pSeg->nSize>0 ){\n      int rc;\n      int iBlk;                   /* Current block (during iteration) */\n      int iLastBlk;               /* Last block of segment */\n      int iFirstBlk;              /* First block of segment */\n      int bLastIsLastOnBlock;     /* True iLast is the last on its block */\n\n      assert( 0==fsSegmentRedirects(pFS, pSeg) );\n      iBlk = iFirstBlk = fsPageToBlock(pFS, pSeg->iFirst);\n      iLastBlk = fsPageToBlock(pFS, pSeg->iLastPg);\n\n      bLastIsLastOnBlock = (fsLastPageOnBlock(pFS, iLastBlk)==pSeg->iLastPg);\n      assert( iBlk>0 );\n\n      do {\n        /* iBlk is a part of this sorted run. */\n        aUsed[iBlk-1] |= INTEGRITY_CHECK_USED;\n\n        /* If the first page of this block is also part of the segment,\n        ** set the flag to indicate that the first page of iBlk is in use.  \n        */\n        if( fsFirstPageOnBlock(pFS, iBlk)==pSeg->iFirst || iBlk!=iFirstBlk ){\n          assert( (aUsed[iBlk-1] & INTEGRITY_CHECK_FIRST_PG)==0 );\n          aUsed[iBlk-1] |= INTEGRITY_CHECK_FIRST_PG;\n        }\n\n        /* Unless the sorted run finishes before the last page on this block, \n        ** the last page of this block is also in use.  */\n        if( iBlk!=iLastBlk || bLastIsLastOnBlock ){\n          assert( (aUsed[iBlk-1] & INTEGRITY_CHECK_LAST_PG)==0 );\n          aUsed[iBlk-1] |= INTEGRITY_CHECK_LAST_PG;\n        }\n\n        /* Special case. The sorted run being scanned is the output run of\n        ** a level currently undergoing an incremental merge. The sorted\n        ** run ends on the last page of iBlk, but the next block has already\n        ** been allocated. So mark it as in use as well.  */\n        if( iBlk==iLastBlk && bLastIsLastOnBlock && bExtra ){\n          int iExtra = 0;\n          rc = fsBlockNext(pFS, pSeg, iBlk, &iExtra);\n          assert( rc==LSM_OK );\n\n          assert( aUsed[iExtra-1]==0 );\n          aUsed[iExtra-1] |= INTEGRITY_CHECK_USED;\n          aUsed[iExtra-1] |= INTEGRITY_CHECK_FIRST_PG;\n          aUsed[iExtra-1] |= INTEGRITY_CHECK_LAST_PG;\n        }\n\n        /* Move on to the next block in the sorted run. Or set iBlk to zero\n        ** in order to break out of the loop if this was the last block in\n        ** the run.  */\n        if( iBlk==iLastBlk ){\n          iBlk = 0;\n        }else{\n          rc = fsBlockNext(pFS, pSeg, iBlk, &iBlk);\n          assert( rc==LSM_OK );\n        }\n      }while( iBlk );\n    }\n  }\n}\n\ntypedef struct CheckFreelistCtx CheckFreelistCtx;\nstruct CheckFreelistCtx {\n  u8 *aUsed;\n  int nBlock;\n};\nstatic int checkFreelistCb(void *pCtx, int iBlk, i64 iSnapshot){\n  CheckFreelistCtx *p = (CheckFreelistCtx *)pCtx;\n\n  assert( iBlk>=1 );\n  assert( iBlk<=p->nBlock );\n  assert( p->aUsed[iBlk-1]==0 );\n  p->aUsed[iBlk-1] = INTEGRITY_CHECK_FREE;\n  return 0;\n}\n\n/*\n** This function checks that all blocks in the database file are accounted\n** for. For each block, exactly one of the following must be true:\n**\n**   + the block is part of a sorted run, or\n**   + the block is on the free-block list\n**\n** This function also checks that there are no references to blocks with\n** out-of-range block numbers.\n**\n** If no errors are found, non-zero is returned. If an error is found, an\n** assert() fails.\n*/\nint lsmFsIntegrityCheck(lsm_db *pDb){\n  CheckFreelistCtx ctx;\n  FileSystem *pFS = pDb->pFS;\n  int i;\n  int rc;\n  Freelist freelist = {0, 0, 0};\n  u8 *aUsed;\n  Level *pLevel;\n  Snapshot *pWorker = pDb->pWorker;\n  int nBlock = pWorker->nBlock;\n\n#if 0 \n  static int nCall = 0;\n  nCall++;\n  printf(\"%d calls\\n\", nCall);\n#endif\n\n  aUsed = lsmMallocZero(pDb->pEnv, nBlock);\n  if( aUsed==0 ){\n    /* Malloc has failed. Since this function is only called within debug\n    ** builds, this probably means the user is running an OOM injection test.\n    ** Regardless, it will not be possible to run the integrity-check at this\n    ** time, so assume the database is Ok and return non-zero. */\n    return 1;\n  }\n\n  for(pLevel=pWorker->pLevel; pLevel; pLevel=pLevel->pNext){\n    int j;\n    checkBlocks(pFS, &pLevel->lhs, (pLevel->nRight!=0), nBlock, aUsed);\n    for(j=0; j<pLevel->nRight; j++){\n      checkBlocks(pFS, &pLevel->aRhs[j], 0, nBlock, aUsed);\n    }\n  }\n\n  /* Mark all blocks in the free-list as used */\n  ctx.aUsed = aUsed;\n  ctx.nBlock = nBlock;\n  rc = lsmWalkFreelist(pDb, 0, checkFreelistCb, (void *)&ctx);\n\n  if( rc==LSM_OK ){\n    for(i=0; i<nBlock; i++) assert( aUsed[i]!=0 );\n  }\n\n  lsmFree(pDb->pEnv, aUsed);\n  lsmFree(pDb->pEnv, freelist.aEntry);\n\n  return 1;\n}\n\n#ifndef NDEBUG\n/*\n** Return true if pPg happens to be the last page in segment pSeg. Or false\n** otherwise. This function is only invoked as part of assert() conditions.\n*/\nint lsmFsDbPageIsLast(Segment *pSeg, Page *pPg){\n  if( pPg->pFS->pCompress ){\n    Pgno iNext = 0;\n    int rc;\n    rc = fsNextPageOffset(pPg->pFS, pSeg, pPg->iPg, pPg->nCompress+6, &iNext);\n    return (rc!=LSM_OK || iNext==0);\n  }\n  return (pPg->iPg==pSeg->iLastPg);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_log.c",
    "content": "/*\n** 2011-08-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of LSM database logging. Logging\n** has one purpose in LSM - to make transactions durable.\n**\n** When data is written to an LSM database, it is initially stored in an\n** in-memory tree structure. Since this structure is in volatile memory,\n** if a power failure or application crash occurs it may be lost. To\n** prevent loss of data in this case, each time a record is written to the\n** in-memory tree an equivalent record is appended to the log on disk.\n** If a power failure or application crash does occur, data can be recovered\n** by reading the log.\n**\n** A log file consists of the following types of records representing data\n** written into the database:\n**\n**   LOG_WRITE:  A key-value pair written to the database.\n**   LOG_DELETE: A delete key issued to the database.\n**   LOG_COMMIT: A transaction commit.\n**\n** And the following types of records for ancillary purposes..\n**\n**   LOG_EOF:    A record indicating the end of a log file.\n**   LOG_PAD1:   A single byte padding record.\n**   LOG_PAD2:   An N byte padding record (N>1).\n**   LOG_JUMP:   A pointer to another offset within the log file.\n**\n** Each transaction written to the log contains one or more LOG_WRITE and/or\n** LOG_DELETE records, followed by a LOG_COMMIT record. The LOG_COMMIT record\n** contains an 8-byte checksum based on all previous data written to the\n** log file.\n**\n** LOG CHECKSUMS & RECOVERY\n**\n**   Checksums are found in two types of log records: LOG_COMMIT and\n**   LOG_CKSUM records. In order to recover content from a log, a client\n**   reads each record from the start of the log, calculating a checksum as\n**   it does. Each time a LOG_COMMIT or LOG_CKSUM is encountered, the \n**   recovery process verifies that the checksum stored in the log \n**   matches the calculated checksum. If it does not, the recovery process\n**   can stop reading the log.\n**\n**   If a recovery process reads records (other than COMMIT or CKSUM) \n**   consisting of at least LSM_CKSUM_MAXDATA bytes, then the next record in\n**   the log must be either a LOG_CKSUM or LOG_COMMIT record. If it is\n**   not, the recovery process also stops reading the log.\n**\n**   To recover the log file, it must be read twice. The first time to \n**   determine the location of the last valid commit record. And the second\n**   time to load data into the in-memory tree.\n**\n**   Todo: Surely there is a better way...\n**\n** LOG WRAPPING\n**\n**   If the log file were never deleted or wrapped, it would be possible to\n**   read it from start to end each time is required recovery (i.e each time\n**   the number of database clients changes from 0 to 1). Effectively reading\n**   the entire history of the database each time. This would quickly become \n**   inefficient. Additionally, since the log file would grow without bound,\n**   it wastes storage space.\n**\n**   Instead, part of each checkpoint written into the database file contains \n**   a log offset (and other information required to read the log starting at\n**   at this offset) at which to begin recovery. Offset $O.\n**\n**   Once a checkpoint has been written and synced into the database file, it\n**   is guaranteed that no recovery process will need to read any data before\n**   offset $O of the log file. It is therefore safe to begin overwriting\n**   any data that occurs before offset $O.\n**\n**   This implementation separates the log into three regions mapped into\n**   the log file - regions 0, 1 and 2. During recovery, regions are read\n**   in ascending order (i.e. 0, then 1, then 2). Each region is zero or\n**   more bytes in size.\n**\n**     |---1---|..|--0--|.|--2--|....\n**\n**   New records are always appended to the end of region 2.\n**\n**   Initially (when it is empty), all three regions are zero bytes in size.\n**   Each of them are located at the beginning of the file. As records are\n**   added to the log, region 2 grows, so that the log consists of a zero\n**   byte region 1, followed by a zero byte region 0, followed by an N byte\n**   region 2. After one or more checkpoints have been written to disk, \n**   the start point of region 2 is moved to $O. For example:\n**\n**     A) ||.........|--2--|....\n**   \n**   (both regions 0 and 1 are 0 bytes in size at offset 0).\n**\n**   Eventually, the log wraps around to write new records into the start.\n**   At this point, region 2 is renamed to region 0. Region 0 is renamed\n**   to region 2. After appending a few records to the new region 2, the\n**   log file looks like this:\n**\n**     B) ||--2--|...|--0--|....\n**\n**   (region 1 is still 0 bytes in size, located at offset 0).\n**\n**   Any checkpoints made at this point may reduce the size of region 0.\n**   However, if they do not, and region 2 expands so that it is about to\n**   overwrite the start of region 0, then region 2 is renamed to region 1,\n**   and a new region 2 created at the end of the file following the existing\n**   region 0.\n**\n**     C) |---1---|..|--0--|.|-2-|\n**\n**   In this state records are appended to region 2 until checkpoints have\n**   contracted regions 0 AND 1 UNTil they are both zero bytes in size. They \n**   are then shifted to the start of the log file, leaving the system in \n**   the equivalent of state A above.\n**\n**   Alternatively, state B may transition directly to state A if the size\n**   of region 0 is reduced to zero bytes before region 2 threatens to \n**   encroach upon it.\n**\n** LOG_PAD1 & LOG_PAD2 RECORDS\n**\n**   PAD1 and PAD2 records may appear in a log file at any point. They allow\n**   a process writing the log file align the beginning of transactions with \n**   the beginning of disk sectors, which increases robustness.\n**\n** RECORD FORMATS:\n**\n**   LOG_EOF:    * A single 0x00 byte.\n**\n**   LOG_PAD1:   * A single 0x01 byte.\n**\n**   LOG_PAD2:   * A single 0x02 byte, followed by\n**               * The number of unused bytes (N) as a varint,\n**               * An N byte block of unused space.\n**\n**   LOG_COMMIT: * A single 0x03 byte.\n**               * An 8-byte checksum.\n**\n**   LOG_JUMP:   * A single 0x04 byte.\n**               * Absolute file offset to jump to, encoded as a varint.\n**\n**   LOG_WRITE:  * A single 0x06 or 0x07 byte, \n**               * The number of bytes in the key, encoded as a varint, \n**               * The number of bytes in the value, encoded as a varint, \n**               * If the first byte was 0x07, an 8 byte checksum.\n**               * The key data,\n**               * The value data.\n**\n**   LOG_DELETE: * A single 0x08 or 0x09 byte, \n**               * The number of bytes in the key, encoded as a varint, \n**               * If the first byte was 0x09, an 8 byte checksum.\n**               * The key data.\n**\n**   Varints are as described in lsm_varint.c (SQLite 4 format).\n**\n** CHECKSUMS:\n**\n**   The checksum is calculated using two 32-bit unsigned integers, s0 and\n**   s1. The initial value for both is 42. It is updated each time a record\n**   is written into the log file by treating the encoded (binary) record as \n**   an array of 32-bit little-endian integers. Then, if x[] is the integer\n**   array, updating the checksum accumulators as follows:\n**\n**     for i from 0 to n-1 step 2:\n**       s0 += x[i] + s1;\n**       s1 += x[i+1] + s0;\n**     endfor\n**\n**   If the record is not an even multiple of 8-bytes in size it is padded\n**   with zeroes to make it so before the checksum is updated.\n**\n**   The checksum stored in a COMMIT, WRITE or DELETE is based on all bytes\n**   up to the start of the 8-byte checksum itself, including the COMMIT,\n**   WRITE or DELETE fields that appear before the checksum in the record.\n**\n** VARINT FORMAT\n**\n** See lsm_varint.c.\n*/\n\n#ifndef _LSM_INT_H\n# include \"lsmInt.h\"\n#endif\n\n/* Log record types */\n#define LSM_LOG_EOF          0x00\n#define LSM_LOG_PAD1         0x01\n#define LSM_LOG_PAD2         0x02\n#define LSM_LOG_COMMIT       0x03\n#define LSM_LOG_JUMP         0x04\n\n#define LSM_LOG_WRITE        0x06\n#define LSM_LOG_WRITE_CKSUM  0x07\n\n#define LSM_LOG_DELETE       0x08\n#define LSM_LOG_DELETE_CKSUM 0x09\n\n#define LSM_LOG_DRANGE       0x0A\n#define LSM_LOG_DRANGE_CKSUM 0x0B\n\n/* Require a checksum every 32KB. */\n#define LSM_CKSUM_MAXDATA (32*1024)\n\n/* Do not wrap a log file smaller than this in bytes. */\n#define LSM_MIN_LOGWRAP      (128*1024)\n\n/*\n** szSector:\n**   Commit records must be aligned to end on szSector boundaries. If\n**   the safety-mode is set to NORMAL or OFF, this value is 1. Otherwise,\n**   if the safety-mode is set to FULL, it is the size of the file-system\n**   sectors as reported by lsmFsSectorSize().\n*/\nstruct LogWriter {\n  u32 cksum0;                     /* Checksum 0 at offset iOff */\n  u32 cksum1;                     /* Checksum 1 at offset iOff */\n  int iCksumBuf;                  /* Bytes of buf that have been checksummed */\n  i64 iOff;                       /* Offset at start of buffer buf */\n  int szSector;                   /* Sector size for this transaction */\n  LogRegion jump;                 /* Avoid writing to this region */\n  i64 iRegion1End;                /* End of first region written by trans */\n  i64 iRegion2Start;              /* Start of second regions written by trans */\n  LsmString buf;                  /* Buffer containing data not yet written */\n};\n\n/*\n** Return the result of interpreting the first 4 bytes in buffer aIn as \n** a 32-bit unsigned little-endian integer.\n*/\nstatic u32 getU32le(u8 *aIn){\n  return ((u32)aIn[3] << 24) \n       + ((u32)aIn[2] << 16) \n       + ((u32)aIn[1] << 8) \n       + ((u32)aIn[0]);\n}\n\n\n/*\n** This function is the same as logCksum(), except that pointer \"a\" need\n** not be aligned to an 8-byte boundary or padded with zero bytes. This\n** version is slower, but sometimes more convenient to use.\n*/\nstatic void logCksumUnaligned(\n  char *z,                        /* Input buffer */\n  int n,                          /* Size of input buffer in bytes */\n  u32 *pCksum0,                   /* IN/OUT: Checksum value 1 */\n  u32 *pCksum1                    /* IN/OUT: Checksum value 2 */\n){\n  u8 *a = (u8 *)z;\n  u32 cksum0 = *pCksum0;\n  u32 cksum1 = *pCksum1;\n  int nIn = (n/8) * 8;\n  int i;\n\n  assert( n>0 );\n  for(i=0; i<nIn; i+=8){\n    cksum0 += getU32le(&a[i]) + cksum1;\n    cksum1 += getU32le(&a[i+4]) + cksum0;\n  }\n\n  if( nIn!=n ){\n    u8 aBuf[8] = {0, 0, 0, 0, 0, 0, 0, 0};\n    assert( (n-nIn)<8 && n>nIn );\n    memcpy(aBuf, &a[nIn], n-nIn);\n    cksum0 += getU32le(aBuf) + cksum1;\n    cksum1 += getU32le(&aBuf[4]) + cksum0;\n  }\n\n  *pCksum0 = cksum0;\n  *pCksum1 = cksum1;\n}\n\n/*\n** Update pLog->cksum0 and pLog->cksum1 so that the first nBuf bytes in the \n** write buffer (pLog->buf) are included in the checksum.\n*/\nstatic void logUpdateCksum(LogWriter *pLog, int nBuf){\n  assert( (pLog->iCksumBuf % 8)==0 );\n  assert( pLog->iCksumBuf<=nBuf );\n  assert( (nBuf % 8)==0 || nBuf==pLog->buf.n );\n  if( nBuf>pLog->iCksumBuf ){\n    logCksumUnaligned(\n        &pLog->buf.z[pLog->iCksumBuf], nBuf-pLog->iCksumBuf, \n        &pLog->cksum0, &pLog->cksum1\n    );\n  }\n  pLog->iCksumBuf = nBuf;\n}\n\nstatic i64 firstByteOnSector(LogWriter *pLog, i64 iOff){\n  return (iOff / pLog->szSector) * pLog->szSector;\n}\nstatic i64 lastByteOnSector(LogWriter *pLog, i64 iOff){\n  return firstByteOnSector(pLog, iOff) + pLog->szSector - 1;\n}\n\n/*\n** If possible, reclaim log file space. Log file space is reclaimed after\n** a snapshot that points to the same data in the database file is synced\n** into the db header.\n*/\nstatic int logReclaimSpace(lsm_db *pDb){\n  int rc;\n  int iMeta;\n  int bRotrans;                   /* True if there exists some ro-trans */\n\n  /* Test if there exists some other connection with a read-only transaction\n  ** open. If there does, then log file space may not be reclaimed.  */\n  rc = lsmDetectRoTrans(pDb, &bRotrans);\n  if( rc!=LSM_OK || bRotrans ) return rc;\n\n  iMeta = (int)pDb->pShmhdr->iMetaPage;\n  if( iMeta==1 || iMeta==2 ){\n    DbLog *pLog = &pDb->treehdr.log;\n    i64 iSyncedId;\n\n    /* Read the snapshot-id of the snapshot stored on meta-page iMeta. Note\n    ** that in theory, the value read is untrustworthy (due to a race \n    ** condition - see comments above lsmFsReadSyncedId()). So it is only \n    ** ever used to conclude that no log space can be reclaimed. If it seems\n    ** to indicate that it may be possible to reclaim log space, a\n    ** second call to lsmCheckpointSynced() (which does return trustworthy\n    ** values) is made below to confirm.  */\n    rc = lsmFsReadSyncedId(pDb, iMeta, &iSyncedId);\n\n    if( rc==LSM_OK && pLog->iSnapshotId!=iSyncedId ){\n      i64 iSnapshotId = 0;\n      i64 iOff = 0;\n      rc = lsmCheckpointSynced(pDb, &iSnapshotId, &iOff, 0);\n      if( rc==LSM_OK && pLog->iSnapshotId<iSnapshotId ){\n        int iRegion;\n        for(iRegion=0; iRegion<3; iRegion++){\n          LogRegion *p = &pLog->aRegion[iRegion];\n          if( iOff>=p->iStart && iOff<=p->iEnd ) break;\n          p->iStart = 0;\n          p->iEnd = 0;\n        }\n        assert( iRegion<3 );\n        pLog->aRegion[iRegion].iStart = iOff;\n        pLog->iSnapshotId = iSnapshotId;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called when a write-transaction is first opened. It\n** is assumed that the caller is holding the client-mutex when it is \n** called.\n**\n** Before returning, this function allocates the LogWriter object that\n** will be used to write to the log file during the write transaction.\n** LSM_OK is returned if no error occurs, otherwise an LSM error code.\n*/\nint lsmLogBegin(lsm_db *pDb){\n  int rc = LSM_OK;\n  LogWriter *pNew;\n  LogRegion *aReg;\n\n  if( pDb->bUseLog==0 ) return LSM_OK;\n\n  /* If the log file has not yet been opened, open it now. Also allocate\n  ** the LogWriter structure, if it has not already been allocated.  */\n  rc = lsmFsOpenLog(pDb, 0);\n  if( pDb->pLogWriter==0 ){\n    pNew = lsmMallocZeroRc(pDb->pEnv, sizeof(LogWriter), &rc);\n    if( pNew ){\n      lsmStringInit(&pNew->buf, pDb->pEnv);\n      rc = lsmStringExtend(&pNew->buf, 2);\n    }\n    pDb->pLogWriter = pNew;\n  }else{\n    pNew = pDb->pLogWriter;\n    assert( (u8 *)(&pNew[1])==(u8 *)(&((&pNew->buf)[1])) );\n    memset(pNew, 0, ((u8 *)&pNew->buf) - (u8 *)pNew);\n    pNew->buf.n = 0;\n  }\n\n  if( rc==LSM_OK ){\n    /* The following call detects whether or not a new snapshot has been \n    ** synced into the database file. If so, it updates the contents of\n    ** the pDb->treehdr.log structure to reclaim any space in the log\n    ** file that is no longer required. \n    **\n    ** TODO: Calling this every transaction is overkill. And since the \n    ** call has to read and checksum a snapshot from the database file,\n    ** it is expensive. It would be better to figure out a way so that\n    ** this is only called occasionally - say for every 32KB written to \n    ** the log file.\n    */\n    rc = logReclaimSpace(pDb);\n  }\n  if( rc!=LSM_OK ){\n    lsmLogClose(pDb);\n    return rc;\n  }\n\n  /* Set the effective sector-size for this transaction. Sectors are assumed\n  ** to be one byte in size if the safety-mode is OFF or NORMAL, or as\n  ** reported by lsmFsSectorSize if it is FULL.  */\n  if( pDb->eSafety==LSM_SAFETY_FULL ){\n    pNew->szSector = lsmFsSectorSize(pDb->pFS);\n    assert( pNew->szSector>0 );\n  }else{\n    pNew->szSector = 1;\n  }\n\n  /* There are now three scenarios:\n  **\n  **   1) Regions 0 and 1 are both zero bytes in size and region 2 begins\n  **      at a file offset greater than LSM_MIN_LOGWRAP. In this case, wrap\n  **      around to the start and write data into the start of the log file. \n  **\n  **   2) Region 1 is zero bytes in size and region 2 occurs earlier in the \n  **      file than region 0. In this case, append data to region 2, but\n  **      remember to jump over region 1 if required.\n  **\n  **   3) Region 2 is the last in the file. Append to it.\n  */\n  aReg = &pDb->treehdr.log.aRegion[0];\n\n  assert( aReg[0].iEnd==0 || aReg[0].iEnd>aReg[0].iStart );\n  assert( aReg[1].iEnd==0 || aReg[1].iEnd>aReg[1].iStart );\n\n  pNew->cksum0 = pDb->treehdr.log.cksum0;\n  pNew->cksum1 = pDb->treehdr.log.cksum1;\n\n  if( aReg[0].iEnd==0 && aReg[1].iEnd==0 && aReg[2].iStart>=LSM_MIN_LOGWRAP ){\n    /* Case 1. Wrap around to the start of the file. Write an LSM_LOG_JUMP \n    ** into the log file in this case. Pad it out to 8 bytes using a PAD2\n    ** record so that the checksums can be updated immediately.  */\n    u8 aJump[] = { \n      LSM_LOG_PAD2, 0x04, 0x00, 0x00, 0x00, 0x00, LSM_LOG_JUMP, 0x00 \n    };\n\n    lsmStringBinAppend(&pNew->buf, aJump, sizeof(aJump));\n    logUpdateCksum(pNew, pNew->buf.n);\n    rc = lsmFsWriteLog(pDb->pFS, aReg[2].iEnd, &pNew->buf);\n    pNew->iCksumBuf = pNew->buf.n = 0;\n\n    aReg[2].iEnd += 8;\n    pNew->jump = aReg[0] = aReg[2];\n    aReg[2].iStart = aReg[2].iEnd = 0;\n  }else if( aReg[1].iEnd==0 && aReg[2].iEnd<aReg[0].iEnd ){\n    /* Case 2. */\n    pNew->iOff = aReg[2].iEnd;\n    pNew->jump = aReg[0];\n  }else{\n    /* Case 3. */\n    assert( aReg[2].iStart>=aReg[0].iEnd && aReg[2].iStart>=aReg[1].iEnd );\n    pNew->iOff = aReg[2].iEnd;\n  }\n\n  if( pNew->jump.iStart ){\n    i64 iRound;\n    assert( pNew->jump.iStart>pNew->iOff );\n\n    iRound = firstByteOnSector(pNew, pNew->jump.iStart);\n    if( iRound>pNew->iOff ) pNew->jump.iStart = iRound;\n    pNew->jump.iEnd = lastByteOnSector(pNew, pNew->jump.iEnd);\n  }\n\n  assert( pDb->pLogWriter==pNew );\n  return rc;\n}\n\n/*\n** This function is called when a write-transaction is being closed.\n** Parameter bCommit is true if the transaction is being committed,\n** or false otherwise. The caller must hold the client-mutex to call\n** this function.\n**\n** A call to this function deletes the LogWriter object allocated by\n** lsmLogBegin(). If the transaction is being committed, the shared state\n** in *pLog is updated before returning.\n*/\nvoid lsmLogEnd(lsm_db *pDb, int bCommit){\n  DbLog *pLog;\n  LogWriter *p;\n  p = pDb->pLogWriter;\n\n  if( p==0 ) return;\n  pLog = &pDb->treehdr.log;\n\n  if( bCommit ){\n    pLog->aRegion[2].iEnd = p->iOff;\n    pLog->cksum0 = p->cksum0;\n    pLog->cksum1 = p->cksum1;\n    if( p->iRegion1End ){\n      /* This happens when the transaction had to jump over some other\n      ** part of the log.  */\n      assert( pLog->aRegion[1].iEnd==0 );\n      assert( pLog->aRegion[2].iStart<p->iRegion1End );\n      pLog->aRegion[1].iStart = pLog->aRegion[2].iStart;\n      pLog->aRegion[1].iEnd = p->iRegion1End;\n      pLog->aRegion[2].iStart = p->iRegion2Start;\n    }\n  }\n}\n\nstatic int jumpIfRequired(\n  lsm_db *pDb,\n  LogWriter *pLog,\n  int nReq,\n  int *pbJump\n){\n  /* Determine if it is necessary to add an LSM_LOG_JUMP to jump over the\n  ** jump region before writing the LSM_LOG_WRITE or DELETE record. This\n  ** is necessary if there is insufficient room between the current offset\n  ** and the jump region to fit the new WRITE/DELETE record and the largest\n  ** possible JUMP record with up to 7 bytes of padding (a total of 17 \n  ** bytes).  */\n  if( (pLog->jump.iStart > (pLog->iOff + pLog->buf.n))\n   && (pLog->jump.iStart < (pLog->iOff + pLog->buf.n + (nReq + 17))) \n  ){\n    int rc;                       /* Return code */\n    i64 iJump;                    /* Offset to jump to */\n    u8 aJump[10];                 /* Encoded jump record */\n    int nJump;                    /* Valid bytes in aJump[] */\n    int nPad;                     /* Bytes of padding required */\n\n    /* Serialize the JUMP record */\n    iJump = pLog->jump.iEnd+1;\n    aJump[0] = LSM_LOG_JUMP;\n    nJump = 1 + lsmVarintPut64(&aJump[1], iJump);\n\n    /* Adding padding to the contents of the buffer so that it will be a \n    ** multiple of 8 bytes in size after the JUMP record is appended. This\n    ** is not strictly required, it just makes the keeping the running \n    ** checksum up to date in this file a little simpler.  */\n    nPad = (pLog->buf.n + nJump) % 8;\n    if( nPad ){\n      u8 aPad[7] = {0,0,0,0,0,0,0};\n      nPad = 8-nPad;\n      if( nPad==1 ){\n        aPad[0] = LSM_LOG_PAD1;\n      }else{\n        aPad[0] = LSM_LOG_PAD2;\n        aPad[1] = (u8)(nPad-2);\n      }\n      rc = lsmStringBinAppend(&pLog->buf, aPad, nPad);\n      if( rc!=LSM_OK ) return rc;\n    }\n\n    /* Append the JUMP record to the buffer. Then flush the buffer to disk\n    ** and update the checksums. The next write to the log file (assuming\n    ** there is no transaction rollback) will be to offset iJump (just past\n    ** the jump region).  */\n    rc = lsmStringBinAppend(&pLog->buf, aJump, nJump);\n    if( rc!=LSM_OK ) return rc;\n    assert( (pLog->buf.n % 8)==0 );\n    rc = lsmFsWriteLog(pDb->pFS, pLog->iOff, &pLog->buf);\n    if( rc!=LSM_OK ) return rc;\n    logUpdateCksum(pLog, pLog->buf.n);\n    pLog->iRegion1End = (pLog->iOff + pLog->buf.n);\n    pLog->iRegion2Start = iJump;\n    pLog->iOff = iJump;\n    pLog->iCksumBuf = pLog->buf.n = 0;\n    if( pbJump ) *pbJump = 1;\n  }\n\n  return LSM_OK;\n}\n\nstatic int logCksumAndFlush(lsm_db *pDb){\n  int rc;                         /* Return code */\n  LogWriter *pLog = pDb->pLogWriter;\n\n  /* Calculate the checksum value. Append it to the buffer. */\n  logUpdateCksum(pLog, pLog->buf.n);\n  lsmPutU32((u8 *)&pLog->buf.z[pLog->buf.n], pLog->cksum0);\n  pLog->buf.n += 4;\n  lsmPutU32((u8 *)&pLog->buf.z[pLog->buf.n], pLog->cksum1);\n  pLog->buf.n += 4;\n\n  /* Write the contents of the buffer to disk. */\n  rc = lsmFsWriteLog(pDb->pFS, pLog->iOff, &pLog->buf);\n  pLog->iOff += pLog->buf.n;\n  pLog->iCksumBuf = pLog->buf.n = 0;\n\n  return rc;\n}\n\n/*\n** Write the contents of the log-buffer to disk. Then write either a CKSUM\n** or COMMIT record, depending on the value of parameter eType.\n*/\nstatic int logFlush(lsm_db *pDb, int eType){\n  int rc;\n  int nReq;\n  LogWriter *pLog = pDb->pLogWriter;\n  \n  assert( eType==LSM_LOG_COMMIT );\n  assert( pLog );\n\n  /* Commit record is always 9 bytes in size. */\n  nReq = 9;\n  if( eType==LSM_LOG_COMMIT && pLog->szSector>1 ) nReq += pLog->szSector + 17;\n  rc = jumpIfRequired(pDb, pLog, nReq, 0);\n\n  /* If this is a COMMIT, add padding to the log so that the COMMIT record\n  ** is aligned against the end of a disk sector. In other words, add padding\n  ** so that the first byte following the COMMIT record lies on a different\n  ** sector.  */\n  if( eType==LSM_LOG_COMMIT && pLog->szSector>1 ){\n    int nPad;                     /* Bytes of padding to add */\n\n    /* Determine the value of nPad. */\n    nPad = ((pLog->iOff + pLog->buf.n + 9) % pLog->szSector);\n    if( nPad ) nPad = pLog->szSector - nPad;\n    rc = lsmStringExtend(&pLog->buf, nPad);\n    if( rc!=LSM_OK ) return rc;\n\n    while( nPad ){\n      if( nPad==1 ){\n        pLog->buf.z[pLog->buf.n++] = LSM_LOG_PAD1;\n        nPad = 0;\n      }else{\n        int n = LSM_MIN(200, nPad-2);\n        pLog->buf.z[pLog->buf.n++] = LSM_LOG_PAD2;\n        pLog->buf.z[pLog->buf.n++] = (char)n;\n        nPad -= 2;\n        memset(&pLog->buf.z[pLog->buf.n], 0x2B, n);\n        pLog->buf.n += n;\n        nPad -= n;\n      }\n    }\n  }\n\n  /* Make sure there is room in the log-buffer to add the CKSUM or COMMIT\n  ** record. Then add the first byte of it.  */\n  rc = lsmStringExtend(&pLog->buf, 9);\n  if( rc!=LSM_OK ) return rc;\n  pLog->buf.z[pLog->buf.n++] = (char)eType;\n  memset(&pLog->buf.z[pLog->buf.n], 0, 8);\n\n  rc = logCksumAndFlush(pDb);\n\n  /* If this is a commit and synchronous=full, sync the log to disk. */\n  if( rc==LSM_OK && eType==LSM_LOG_COMMIT && pDb->eSafety==LSM_SAFETY_FULL ){\n    rc = lsmFsSyncLog(pDb->pFS);\n  }\n  return rc;\n}\n\n/*\n** Append an LSM_LOG_WRITE (if nVal>=0) or LSM_LOG_DELETE (if nVal<0) \n** record to the database log.\n*/\nint lsmLogWrite(\n  lsm_db *pDb,                    /* Database handle */\n  int eType,\n  void *pKey, int nKey,           /* Database key to write to log */\n  void *pVal, int nVal            /* Database value (or nVal<0) to write */\n){\n  int rc = LSM_OK;\n  LogWriter *pLog;                /* Log object to write to */\n  int nReq;                       /* Bytes of space required in log */\n  int bCksum = 0;                 /* True to embed a checksum in this record */\n\n  assert( eType==LSM_WRITE || eType==LSM_DELETE || eType==LSM_DRANGE );\n  assert( LSM_LOG_WRITE==LSM_WRITE );\n  assert( LSM_LOG_DELETE==LSM_DELETE );\n  assert( LSM_LOG_DRANGE==LSM_DRANGE );\n  assert( (eType==LSM_LOG_DELETE)==(nVal<0) );\n\n  if( pDb->bUseLog==0 ) return LSM_OK;\n  pLog = pDb->pLogWriter;\n\n  /* Determine how many bytes of space are required, assuming that a checksum\n  ** will be embedded in this record (even though it may not be).  */\n  nReq = 1 + lsmVarintLen32(nKey) + 8 + nKey;\n  if( eType!=LSM_LOG_DELETE ) nReq += lsmVarintLen32(nVal) + nVal;\n\n  /* Jump over the jump region if required. Set bCksum to true to tell the\n  ** code below to include a checksum in the record if either (a) writing\n  ** this record would mean that more than LSM_CKSUM_MAXDATA bytes of data\n  ** have been written to the log since the last checksum, or (b) the jump\n  ** is taken.  */\n  rc = jumpIfRequired(pDb, pLog, nReq, &bCksum);\n  if( (pLog->buf.n+nReq) > LSM_CKSUM_MAXDATA ) bCksum = 1;\n\n  if( rc==LSM_OK ){\n    rc = lsmStringExtend(&pLog->buf, nReq);\n  }\n  if( rc==LSM_OK ){\n    u8 *a = (u8 *)&pLog->buf.z[pLog->buf.n];\n    \n    /* Write the record header - the type byte followed by either 1 (for\n    ** DELETE) or 2 (for WRITE) varints.  */\n    assert( LSM_LOG_WRITE_CKSUM == (LSM_LOG_WRITE | 0x0001) );\n    assert( LSM_LOG_DELETE_CKSUM == (LSM_LOG_DELETE | 0x0001) );\n    assert( LSM_LOG_DRANGE_CKSUM == (LSM_LOG_DRANGE | 0x0001) );\n    *(a++) = (u8)eType | (u8)bCksum;\n    a += lsmVarintPut32(a, nKey);\n    if( eType!=LSM_LOG_DELETE ) a += lsmVarintPut32(a, nVal);\n\n    if( bCksum ){\n      pLog->buf.n = (a - (u8 *)pLog->buf.z);\n      rc = logCksumAndFlush(pDb);\n      a = (u8 *)&pLog->buf.z[pLog->buf.n];\n    }\n\n    memcpy(a, pKey, nKey);\n    a += nKey;\n    if( eType!=LSM_LOG_DELETE ){\n      memcpy(a, pVal, nVal);\n      a += nVal;\n    }\n    pLog->buf.n = a - (u8 *)pLog->buf.z;\n    assert( pLog->buf.n<=pLog->buf.nAlloc );\n  }\n\n  return rc;\n}\n\n/*\n** Append an LSM_LOG_COMMIT record to the database log.\n*/\nint lsmLogCommit(lsm_db *pDb){\n  if( pDb->bUseLog==0 ) return LSM_OK;\n  return logFlush(pDb, LSM_LOG_COMMIT);\n}\n\n/*\n** Store the current offset and other checksum related information in the\n** structure *pMark. Later, *pMark can be passed to lsmLogSeek() to \"rewind\"\n** the LogWriter object to the current log file offset. This is used when\n** rolling back savepoint transactions.\n*/\nvoid lsmLogTell(\n  lsm_db *pDb,                    /* Database handle */\n  LogMark *pMark                  /* Populate this object with current offset */\n){\n  LogWriter *pLog;\n  int nCksum;\n\n  if( pDb->bUseLog==0 ) return;\n  pLog = pDb->pLogWriter;\n  nCksum = pLog->buf.n & 0xFFFFFFF8;\n  logUpdateCksum(pLog, nCksum);\n  assert( pLog->iCksumBuf==nCksum );\n  pMark->nBuf = pLog->buf.n - nCksum;\n  memcpy(pMark->aBuf, &pLog->buf.z[nCksum], pMark->nBuf);\n\n  pMark->iOff = pLog->iOff + pLog->buf.n;\n  pMark->cksum0 = pLog->cksum0;\n  pMark->cksum1 = pLog->cksum1;\n}\n\n/*\n** Seek (rewind) back to the log file offset stored by an ealier call to\n** lsmLogTell() in *pMark.\n*/\nvoid lsmLogSeek(\n  lsm_db *pDb,                    /* Database handle */\n  LogMark *pMark                  /* Object containing log offset to seek to */\n){\n  LogWriter *pLog;\n\n  if( pDb->bUseLog==0 ) return;\n  pLog = pDb->pLogWriter;\n\n  assert( pMark->iOff<=pLog->iOff+pLog->buf.n );\n  if( (pMark->iOff & 0xFFFFFFF8)>=pLog->iOff ){\n    pLog->buf.n = (int)(pMark->iOff - pLog->iOff);\n    pLog->iCksumBuf = (pLog->buf.n & 0xFFFFFFF8);\n  }else{\n    pLog->buf.n = pMark->nBuf;\n    memcpy(pLog->buf.z, pMark->aBuf, pMark->nBuf);\n    pLog->iCksumBuf = 0;\n    pLog->iOff = pMark->iOff - pMark->nBuf;\n  }\n  pLog->cksum0 = pMark->cksum0;\n  pLog->cksum1 = pMark->cksum1;\n\n  if( pMark->iOff > pLog->iRegion1End ) pLog->iRegion1End = 0;\n  if( pMark->iOff > pLog->iRegion2Start ) pLog->iRegion2Start = 0;\n}\n\n/*\n** This function does the work for an lsm_info(LOG_STRUCTURE) request.\n*/\nint lsmInfoLogStructure(lsm_db *pDb, char **pzVal){\n  int rc = LSM_OK;\n  char *zVal = 0;\n\n  /* If there is no read or write transaction open, read the latest \n  ** tree-header from shared-memory to report on. If necessary, update\n  ** it based on the contents of the database header.  \n  **\n  ** No locks are taken here - these are passive read operations only.\n  */\n  if( pDb->pCsr==0 && pDb->nTransOpen==0 ){\n    rc = lsmTreeLoadHeader(pDb, 0);\n    if( rc==LSM_OK ) rc = logReclaimSpace(pDb);\n  }\n\n  if( rc==LSM_OK ){\n    DbLog *pLog = &pDb->treehdr.log;\n    zVal = lsmMallocPrintf(pDb->pEnv, \n        \"%d %d %d %d %d %d\", \n        (int)pLog->aRegion[0].iStart, (int)pLog->aRegion[0].iEnd,\n        (int)pLog->aRegion[1].iStart, (int)pLog->aRegion[1].iEnd,\n        (int)pLog->aRegion[2].iStart, (int)pLog->aRegion[2].iEnd\n    );\n    if( !zVal ) rc = LSM_NOMEM_BKPT;\n  }\n\n  *pzVal = zVal;\n  return rc;\n}\n\n/*************************************************************************\n** Begin code for log recovery.\n*/\n\ntypedef struct LogReader LogReader;\nstruct LogReader {\n  FileSystem *pFS;                /* File system to read from */\n  i64 iOff;                       /* File offset at end of buf content */\n  int iBuf;                       /* Current read offset in buf */\n  LsmString buf;                  /* Buffer containing file content */\n\n  int iCksumBuf;                  /* Offset in buf corresponding to cksum[01] */\n  u32 cksum0;                     /* Checksum 0 at offset iCksumBuf */\n  u32 cksum1;                     /* Checksum 1 at offset iCksumBuf */\n};\n\nstatic void logReaderBlob(\n  LogReader *p,                   /* Log reader object */\n  LsmString *pBuf,                /* Dynamic storage, if required */\n  int nBlob,                      /* Number of bytes to read */\n  u8 **ppBlob,                    /* OUT: Pointer to blob read */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  static const int LOG_READ_SIZE = 512;\n  int rc = *pRc;                  /* Return code */\n  int nReq = nBlob;               /* Bytes required */\n\n  while( rc==LSM_OK && nReq>0 ){\n    int nAvail;                   /* Bytes of data available in p->buf */\n    if( p->buf.n==p->iBuf ){\n      int nCksum;                 /* Total bytes requiring checksum */\n      int nCarry = 0;             /* Total bytes requiring checksum */\n\n      nCksum = p->iBuf - p->iCksumBuf;\n      if( nCksum>0 ){\n        nCarry = nCksum % 8;\n        nCksum = ((nCksum / 8) * 8);\n        if( nCksum>0 ){\n          logCksumUnaligned(\n              &p->buf.z[p->iCksumBuf], nCksum, &p->cksum0, &p->cksum1\n          );\n        }\n      }\n      if( nCarry>0 ) memcpy(p->buf.z, &p->buf.z[p->iBuf-nCarry], nCarry);\n      p->buf.n = nCarry;\n      p->iBuf = nCarry;\n\n      rc = lsmFsReadLog(p->pFS, p->iOff, LOG_READ_SIZE, &p->buf);\n      if( rc!=LSM_OK ) break;\n      p->iCksumBuf = 0;\n      p->iOff += LOG_READ_SIZE;\n    }\n\n    nAvail = p->buf.n - p->iBuf;\n    if( ppBlob && nReq==nBlob && nBlob<=nAvail ){\n      *ppBlob = (u8 *)&p->buf.z[p->iBuf];\n      p->iBuf += nBlob;\n      nReq = 0;\n    }else{\n      int nCopy = LSM_MIN(nAvail, nReq);\n      if( nBlob==nReq ){\n        pBuf->n = 0;\n      }\n      rc = lsmStringBinAppend(pBuf, (u8 *)&p->buf.z[p->iBuf], nCopy);\n      nReq -= nCopy;\n      p->iBuf += nCopy;\n      if( nReq==0 && ppBlob ){\n        *ppBlob = (u8*)pBuf->z;\n      }\n    }\n  }\n\n  *pRc = rc;\n}\n\nstatic void logReaderVarint(\n  LogReader *p, \n  LsmString *pBuf,\n  int *piVal,                     /* OUT: Value read from log */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==LSM_OK ){\n    u8 *aVarint;\n    if( p->buf.n==p->iBuf ){\n      logReaderBlob(p, 0, 10, &aVarint, pRc);\n      if( LSM_OK==*pRc ) p->iBuf -= (10 - lsmVarintGet32(aVarint, piVal));\n    }else{\n      logReaderBlob(p, pBuf, lsmVarintSize(p->buf.z[p->iBuf]), &aVarint, pRc);\n      if( LSM_OK==*pRc ) lsmVarintGet32(aVarint, piVal);\n    }\n  }\n}\n\nstatic void logReaderByte(LogReader *p, u8 *pByte, int *pRc){\n  u8 *pPtr = 0;\n  logReaderBlob(p, 0, 1, &pPtr, pRc);\n  if( pPtr ) *pByte = *pPtr;\n}\n\nstatic void logReaderCksum(LogReader *p, LsmString *pBuf, int *pbEof, int *pRc){\n  if( *pRc==LSM_OK ){\n    u8 *pPtr = 0;\n    u32 cksum0, cksum1;\n    int nCksum = p->iBuf - p->iCksumBuf;\n\n    /* Update in-memory (expected) checksums */\n    assert( nCksum>=0 );\n    logCksumUnaligned(&p->buf.z[p->iCksumBuf], nCksum, &p->cksum0, &p->cksum1);\n    p->iCksumBuf = p->iBuf + 8;\n    logReaderBlob(p, pBuf, 8, &pPtr, pRc);\n    assert( pPtr || *pRc );\n\n    /* Read the checksums from the log file. Set *pbEof if they do not match. */\n    if( pPtr ){\n      cksum0 = lsmGetU32(pPtr);\n      cksum1 = lsmGetU32(&pPtr[4]);\n      *pbEof = (cksum0!=p->cksum0 || cksum1!=p->cksum1);\n      p->iCksumBuf = p->iBuf;\n    }\n  }\n}\n\nstatic void logReaderInit(\n  lsm_db *pDb,                    /* Database handle */\n  DbLog *pLog,                    /* Log object associated with pDb */\n  int bInitBuf,                   /* True if p->buf is uninitialized */\n  LogReader *p                    /* Initialize this LogReader object */\n){\n  p->pFS = pDb->pFS;\n  p->iOff = pLog->aRegion[2].iStart;\n  p->cksum0 = pLog->cksum0;\n  p->cksum1 = pLog->cksum1;\n  if( bInitBuf ){ lsmStringInit(&p->buf, pDb->pEnv); }\n  p->buf.n = 0;\n  p->iCksumBuf = 0;\n  p->iBuf = 0;\n}\n\n/*\n** This function is called after reading the header of a LOG_DELETE or\n** LOG_WRITE record. Parameter nByte is the total size of the key and\n** value that follow the header just read. Return true if the size and\n** position of the record indicate that it should contain a checksum.\n*/\nstatic int logRequireCksum(LogReader *p, int nByte){\n  return ((p->iBuf + nByte - p->iCksumBuf) > LSM_CKSUM_MAXDATA);\n}\n\n/*\n** Recover the contents of the log file.\n*/\nint lsmLogRecover(lsm_db *pDb){\n  LsmString buf1;                 /* Key buffer */\n  LsmString buf2;                 /* Value buffer */\n  LogReader reader;               /* Log reader object */\n  int rc = LSM_OK;                /* Return code */\n  int nCommit = 0;                /* Number of transactions to recover */\n  int iPass;\n  int nJump = 0;                  /* Number of LSM_LOG_JUMP records in pass 0 */\n  DbLog *pLog;\n  int bOpen;\n\n  rc = lsmFsOpenLog(pDb, &bOpen);\n  if( rc!=LSM_OK ) return rc;\n\n  rc = lsmTreeInit(pDb);\n  if( rc!=LSM_OK ) return rc;\n\n  pLog = &pDb->treehdr.log;\n  lsmCheckpointLogoffset(pDb->pShmhdr->aSnap2, pLog);\n\n  logReaderInit(pDb, pLog, 1, &reader);\n  lsmStringInit(&buf1, pDb->pEnv);\n  lsmStringInit(&buf2, pDb->pEnv);\n\n  /* The outer for() loop runs at most twice. The first iteration is to \n  ** count the number of committed transactions in the log. The second \n  ** iterates through those transactions and updates the in-memory tree \n  ** structure with their contents.  */\n  if( bOpen ){\n    for(iPass=0; iPass<2 && rc==LSM_OK; iPass++){\n      int bEof = 0;\n\n      while( rc==LSM_OK && !bEof ){\n        u8 eType = 0;\n        logReaderByte(&reader, &eType, &rc);\n\n        switch( eType ){\n          case LSM_LOG_PAD1:\n            break;\n\n          case LSM_LOG_PAD2: {\n            int nPad;\n            logReaderVarint(&reader, &buf1, &nPad, &rc);\n            logReaderBlob(&reader, &buf1, nPad, 0, &rc);\n            break;\n          }\n\n          case LSM_LOG_DRANGE:\n          case LSM_LOG_DRANGE_CKSUM:\n          case LSM_LOG_WRITE:\n          case LSM_LOG_WRITE_CKSUM: {\n            int nKey;\n            int nVal;\n            u8 *aVal;\n            logReaderVarint(&reader, &buf1, &nKey, &rc);\n            logReaderVarint(&reader, &buf2, &nVal, &rc);\n\n            if( eType==LSM_LOG_WRITE_CKSUM || eType==LSM_LOG_DRANGE_CKSUM ){\n              logReaderCksum(&reader, &buf1, &bEof, &rc);\n            }else{\n              bEof = logRequireCksum(&reader, nKey+nVal);\n            }\n            if( bEof ) break;\n\n            logReaderBlob(&reader, &buf1, nKey, 0, &rc);\n            logReaderBlob(&reader, &buf2, nVal, &aVal, &rc);\n            if( iPass==1 && rc==LSM_OK ){ \n              if( eType==LSM_LOG_WRITE || eType==LSM_LOG_WRITE_CKSUM ){\n                rc = lsmTreeInsert(pDb, (u8 *)buf1.z, nKey, aVal, nVal);\n              }else{\n                rc = lsmTreeDelete(pDb, (u8 *)buf1.z, nKey, aVal, nVal);\n              }\n            }\n            break;\n          }\n\n          case LSM_LOG_DELETE:\n          case LSM_LOG_DELETE_CKSUM: {\n            int nKey; u8 *aKey;\n            logReaderVarint(&reader, &buf1, &nKey, &rc);\n\n            if( eType==LSM_LOG_DELETE_CKSUM ){\n              logReaderCksum(&reader, &buf1, &bEof, &rc);\n            }else{\n              bEof = logRequireCksum(&reader, nKey);\n            }\n            if( bEof ) break;\n\n            logReaderBlob(&reader, &buf1, nKey, &aKey, &rc);\n            if( iPass==1 && rc==LSM_OK ){ \n              rc = lsmTreeInsert(pDb, aKey, nKey, NULL, -1);\n            }\n            break;\n          }\n\n          case LSM_LOG_COMMIT:\n            logReaderCksum(&reader, &buf1, &bEof, &rc);\n            if( bEof==0 ){\n              nCommit++;\n              assert( nCommit>0 || iPass==1 );\n              if( nCommit==0 ) bEof = 1;\n            }\n            break;\n\n          case LSM_LOG_JUMP: {\n            int iOff = 0;\n            logReaderVarint(&reader, &buf1, &iOff, &rc);\n            if( rc==LSM_OK ){\n              if( iPass==1 ){\n                if( pLog->aRegion[2].iStart==0 ){\n                  assert( pLog->aRegion[1].iStart==0 );\n                  pLog->aRegion[1].iEnd = reader.iOff;\n                }else{\n                  assert( pLog->aRegion[0].iStart==0 );\n                  pLog->aRegion[0].iStart = pLog->aRegion[2].iStart;\n                  pLog->aRegion[0].iEnd = reader.iOff-reader.buf.n+reader.iBuf;\n                }\n                pLog->aRegion[2].iStart = iOff;\n              }else{\n                if( (nJump++)==2 ){\n                  bEof = 1;\n                }\n              }\n\n              reader.iOff = iOff;\n              reader.buf.n = reader.iBuf;\n            }\n            break;\n          }\n\n          default:\n            /* Including LSM_LOG_EOF */\n            bEof = 1;\n            break;\n        }\n      }\n\n      if( rc==LSM_OK && iPass==0 ){\n        if( nCommit==0 ){\n          if( pLog->aRegion[2].iStart==0 ){\n            iPass = 1;\n          }else{\n            pLog->aRegion[2].iStart = 0;\n            iPass = -1;\n            lsmCheckpointZeroLogoffset(pDb);\n          }\n        }\n        logReaderInit(pDb, pLog, 0, &reader);\n        nCommit = nCommit * -1;\n      }\n    }\n  }\n\n  /* Initialize DbLog object */\n  if( rc==LSM_OK ){\n    pLog->aRegion[2].iEnd = reader.iOff - reader.buf.n + reader.iBuf;\n    pLog->cksum0 = reader.cksum0;\n    pLog->cksum1 = reader.cksum1;\n  }\n\n  if( rc==LSM_OK ){\n    rc = lsmFinishRecovery(pDb);\n  }else{\n    lsmFinishRecovery(pDb);\n  }\n\n  if( pDb->bRoTrans ){\n    lsmFsCloseLog(pDb);\n  }\n\n  lsmStringClear(&buf1);\n  lsmStringClear(&buf2);\n  lsmStringClear(&reader.buf);\n  return rc;\n}\n\nvoid lsmLogClose(lsm_db *db){\n  if( db->pLogWriter ){\n    lsmFree(db->pEnv, db->pLogWriter->buf.z);\n    lsmFree(db->pEnv, db->pLogWriter);\n    db->pLogWriter = 0;\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_main.c",
    "content": "/*\n** 2011-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** The main interface to the LSM module.\n*/\n#include \"lsmInt.h\"\n\n\n#ifdef LSM_DEBUG\n/*\n** This function returns a copy of its only argument.\n**\n** When the library is built with LSM_DEBUG defined, this function is called\n** whenever an error code is generated (not propagated - generated). So\n** if the library is mysteriously returning (say) LSM_IOERR, a breakpoint\n** may be set in this function to determine why.\n*/\nint lsmErrorBkpt(int rc){\n  /* Set breakpoint here! */\n  return rc;\n}\n\n/*\n** This function contains various assert() statements that test that the\n** lsm_db structure passed as an argument is internally consistent.\n*/\nstatic void assert_db_state(lsm_db *pDb){\n\n  /* If there is at least one cursor or a write transaction open, the database\n  ** handle must be holding a pointer to a client snapshot. And the reverse \n  ** - if there are no open cursors and no write transactions then there must \n  ** not be a client snapshot.  */\n  \n  assert( (pDb->pCsr!=0||pDb->nTransOpen>0)==(pDb->iReader>=0||pDb->bRoTrans) );\n\n  assert( (pDb->iReader<0 && pDb->bRoTrans==0) || pDb->pClient!=0 );\n\n  assert( pDb->nTransOpen>=0 );\n}\n#else\n# define assert_db_state(x) \n#endif\n\n/*\n** The default key-compare function.\n*/\nstatic int xCmp(void *p1, int n1, void *p2, int n2){\n  int res;\n  res = memcmp(p1, p2, LSM_MIN(n1, n2));\n  if( res==0 ) res = (n1-n2);\n  return res;\n}\n\nstatic void xLog(void *pCtx, int rc, const char *z){\n  (void)(rc);\n  (void)(pCtx);\n  fprintf(stderr, \"%s\\n\", z);\n  fflush(stderr);\n}\n\n/*\n** Allocate a new db handle.\n*/\nint lsm_new(lsm_env *pEnv, lsm_db **ppDb){\n  lsm_db *pDb;\n\n  /* If the user did not provide an environment, use the default. */\n  if( pEnv==0 ) pEnv = lsm_default_env();\n  assert( pEnv );\n\n  /* Allocate the new database handle */\n  *ppDb = pDb = (lsm_db *)lsmMallocZero(pEnv, sizeof(lsm_db));\n  if( pDb==0 ) return LSM_NOMEM_BKPT;\n\n  /* Initialize the new object */\n  pDb->pEnv = pEnv;\n  pDb->nTreeLimit = LSM_DFLT_AUTOFLUSH;\n  pDb->nAutockpt = LSM_DFLT_AUTOCHECKPOINT;\n  pDb->bAutowork = LSM_DFLT_AUTOWORK;\n  pDb->eSafety = LSM_DFLT_SAFETY;\n  pDb->xCmp = xCmp;\n  pDb->nDfltPgsz = LSM_DFLT_PAGE_SIZE;\n  pDb->nDfltBlksz = LSM_DFLT_BLOCK_SIZE;\n  pDb->nMerge = LSM_DFLT_AUTOMERGE;\n  pDb->nMaxFreelist = LSM_MAX_FREELIST_ENTRIES;\n  pDb->bUseLog = LSM_DFLT_USE_LOG;\n  pDb->iReader = -1;\n  pDb->iRwclient = -1;\n  pDb->bMultiProc = LSM_DFLT_MULTIPLE_PROCESSES;\n  pDb->iMmap = LSM_DFLT_MMAP;\n  pDb->xLog = xLog;\n  pDb->compress.iId = LSM_COMPRESSION_NONE;\n  return LSM_OK;\n}\n\nlsm_env *lsm_get_env(lsm_db *pDb){\n  assert( pDb->pEnv );\n  return pDb->pEnv;\n}\n\n/*\n** If database handle pDb is currently holding a client snapshot, but does\n** not have any open cursors or write transactions, release it.\n*/\nstatic void dbReleaseClientSnapshot(lsm_db *pDb){\n  if( pDb->nTransOpen==0 && pDb->pCsr==0 ){\n    lsmFinishReadTrans(pDb);\n  }\n}\n\nstatic int getFullpathname(\n  lsm_env *pEnv, \n  const char *zRel,\n  char **pzAbs\n){\n  int nAlloc = 0;\n  char *zAlloc = 0;\n  int nReq = 0;\n  int rc;\n\n  do{\n    nAlloc = nReq;\n    rc = pEnv->xFullpath(pEnv, zRel, zAlloc, &nReq);\n    if( nReq>nAlloc ){\n      zAlloc = lsmReallocOrFreeRc(pEnv, zAlloc, nReq, &rc);\n    }\n  }while( nReq>nAlloc && rc==LSM_OK );\n\n  if( rc!=LSM_OK ){\n    lsmFree(pEnv, zAlloc);\n    zAlloc = 0;\n  }\n  *pzAbs = zAlloc;\n  return rc;\n}\n\n/*\n** Check that the bits in the db->mLock mask are consistent with the\n** value stored in db->iRwclient. An assert shall fail otherwise.\n*/\nstatic void assertRwclientLockValue(lsm_db *db){\n#ifndef NDEBUG\n  u64 msk;                        /* Mask of mLock bits for RWCLIENT locks */\n  u64 rwclient = 0;               /* Bit corresponding to db->iRwclient */\n\n  if( db->iRwclient>=0 ){\n    rwclient = ((u64)1 << (LSM_LOCK_RWCLIENT(db->iRwclient)-1));\n  }\n  msk  = ((u64)1 << (LSM_LOCK_RWCLIENT(LSM_LOCK_NRWCLIENT)-1)) - 1;\n  msk -= (((u64)1 << (LSM_LOCK_RWCLIENT(0)-1)) - 1);\n\n  assert( (db->mLock & msk)==rwclient );\n#endif\n}\n\n/*\n** Open a new connection to database zFilename.\n*/\nint lsm_open(lsm_db *pDb, const char *zFilename){\n  int rc;\n\n  if( pDb->pDatabase ){\n    rc = LSM_MISUSE;\n  }else{\n    char *zFull;\n\n    /* Translate the possibly relative pathname supplied by the user into\n    ** an absolute pathname. This is required because the supplied path\n    ** is used (either directly or with \"-log\" appended to it) for more \n    ** than one purpose - to open both the database and log files, and \n    ** perhaps to unlink the log file during disconnection. An absolute\n    ** path is required to ensure that the correct files are operated\n    ** on even if the application changes the cwd.  */\n    rc = getFullpathname(pDb->pEnv, zFilename, &zFull);\n    assert( rc==LSM_OK || zFull==0 );\n\n    /* Connect to the database. */\n    if( rc==LSM_OK ){\n      rc = lsmDbDatabaseConnect(pDb, zFull);\n    }\n\n    if( pDb->bReadonly==0 ){\n      /* Configure the file-system connection with the page-size and block-size\n      ** of this database. Even if the database file is zero bytes in size\n      ** on disk, these values have been set in shared-memory by now, and so \n      ** are guaranteed not to change during the lifetime of this connection.  \n      */\n      if( rc==LSM_OK && LSM_OK==(rc = lsmCheckpointLoad(pDb, 0)) ){\n        lsmFsSetPageSize(pDb->pFS, lsmCheckpointPgsz(pDb->aSnapshot));\n        lsmFsSetBlockSize(pDb->pFS, lsmCheckpointBlksz(pDb->aSnapshot));\n      }\n    }\n\n    lsmFree(pDb->pEnv, zFull);\n    assertRwclientLockValue(pDb);\n  }\n\n  assert( pDb->bReadonly==0 || pDb->bReadonly==1 );\n  assert( rc!=LSM_OK || (pDb->pShmhdr==0)==(pDb->bReadonly==1) );\n\n  return rc;\n}\n\nint lsm_close(lsm_db *pDb){\n  int rc = LSM_OK;\n  if( pDb ){\n    assert_db_state(pDb);\n    if( pDb->pCsr || pDb->nTransOpen ){\n      rc = LSM_MISUSE_BKPT;\n    }else{\n      lsmMCursorFreeCache(pDb);\n      lsmFreeSnapshot(pDb->pEnv, pDb->pClient);\n      pDb->pClient = 0;\n\n      assertRwclientLockValue(pDb);\n\n      lsmDbDatabaseRelease(pDb);\n      lsmLogClose(pDb);\n      lsmFsClose(pDb->pFS);\n      /* assert( pDb->mLock==0 ); */\n      \n      /* Invoke any destructors registered for the compression or \n      ** compression factory callbacks.  */\n      if( pDb->factory.xFree ) pDb->factory.xFree(pDb->factory.pCtx);\n      if( pDb->compress.xFree ) pDb->compress.xFree(pDb->compress.pCtx);\n\n      lsmFree(pDb->pEnv, pDb->rollback.aArray);\n      lsmFree(pDb->pEnv, pDb->aTrans);\n      lsmFree(pDb->pEnv, pDb->apShm);\n      lsmFree(pDb->pEnv, pDb);\n    }\n  }\n  return rc;\n}\n\nint lsm_config(lsm_db *pDb, int eParam, ...){\n  int rc = LSM_OK;\n  va_list ap;\n  va_start(ap, eParam);\n\n  switch( eParam ){\n    case LSM_CONFIG_AUTOFLUSH: {\n      /* This parameter is read and written in KB. But all internal \n      ** processing is done in bytes.  */\n      int *piVal = va_arg(ap, int *);\n      int iVal = *piVal;\n      if( iVal>=0 && iVal<=(1024*1024) ){\n        pDb->nTreeLimit = iVal*1024;\n      }\n      *piVal = (pDb->nTreeLimit / 1024);\n      break;\n    }\n\n    case LSM_CONFIG_AUTOWORK: {\n      int *piVal = va_arg(ap, int *);\n      if( *piVal>=0 ){\n        pDb->bAutowork = *piVal;\n      }\n      *piVal = pDb->bAutowork;\n      break;\n    }\n\n    case LSM_CONFIG_AUTOCHECKPOINT: {\n      /* This parameter is read and written in KB. But all internal processing\n      ** (including the lsm_db.nAutockpt variable) is done in bytes.  */\n      int *piVal = va_arg(ap, int *);\n      if( *piVal>=0 ){\n        int iVal = *piVal;\n        pDb->nAutockpt = (i64)iVal * 1024;\n      }\n      *piVal = (int)(pDb->nAutockpt / 1024);\n      break;\n    }\n\n    case LSM_CONFIG_PAGE_SIZE: {\n      int *piVal = va_arg(ap, int *);\n      if( pDb->pDatabase ){\n        /* If lsm_open() has been called, this is a read-only parameter. \n        ** Set the output variable to the page-size according to the \n        ** FileSystem object.  */\n        *piVal = lsmFsPageSize(pDb->pFS);\n      }else{\n        if( *piVal>=256 && *piVal<=65536 && ((*piVal-1) & *piVal)==0 ){\n          pDb->nDfltPgsz = *piVal;\n        }else{\n          *piVal = pDb->nDfltPgsz;\n        }\n      }\n      break;\n    }\n\n    case LSM_CONFIG_BLOCK_SIZE: {\n      /* This parameter is read and written in KB. But all internal \n      ** processing is done in bytes.  */\n      int *piVal = va_arg(ap, int *);\n      if( pDb->pDatabase ){\n        /* If lsm_open() has been called, this is a read-only parameter. \n        ** Set the output variable to the block-size in KB according to the \n        ** FileSystem object.  */\n        *piVal = lsmFsBlockSize(pDb->pFS) / 1024;\n      }else{\n        int iVal = *piVal;\n        if( iVal>=64 && iVal<=65536 && ((iVal-1) & iVal)==0 ){\n          pDb->nDfltBlksz = iVal * 1024;\n        }else{\n          *piVal = pDb->nDfltBlksz / 1024;\n        }\n      }\n      break;\n    }\n\n    case LSM_CONFIG_SAFETY: {\n      int *piVal = va_arg(ap, int *);\n      if( *piVal>=0 && *piVal<=2 ){\n        pDb->eSafety = *piVal;\n      }\n      *piVal = pDb->eSafety;\n      break;\n    }\n\n    case LSM_CONFIG_MMAP: {\n      int *piVal = va_arg(ap, int *);\n      if( pDb->iReader<0 && *piVal>=0 ){\n        pDb->iMmap = *piVal;\n        rc = lsmFsConfigure(pDb);\n      }\n      *piVal = pDb->iMmap;\n      break;\n    }\n\n    case LSM_CONFIG_USE_LOG: {\n      int *piVal = va_arg(ap, int *);\n      if( pDb->nTransOpen==0 && (*piVal==0 || *piVal==1) ){\n        pDb->bUseLog = *piVal;\n      }\n      *piVal = pDb->bUseLog;\n      break;\n    }\n\n    case LSM_CONFIG_AUTOMERGE: {\n      int *piVal = va_arg(ap, int *);\n      if( *piVal>1 ) pDb->nMerge = *piVal;\n      *piVal = pDb->nMerge;\n      break;\n    }\n\n    case LSM_CONFIG_MAX_FREELIST: {\n      int *piVal = va_arg(ap, int *);\n      if( *piVal>=2 && *piVal<=LSM_MAX_FREELIST_ENTRIES ){\n        pDb->nMaxFreelist = *piVal;\n      }\n      *piVal = pDb->nMaxFreelist;\n      break;\n    }\n\n    case LSM_CONFIG_MULTIPLE_PROCESSES: {\n      int *piVal = va_arg(ap, int *);\n      if( pDb->pDatabase ){\n        /* If lsm_open() has been called, this is a read-only parameter. \n        ** Set the output variable to true if this connection is currently\n        ** in multi-process mode.  */\n        *piVal = lsmDbMultiProc(pDb);\n      }else{\n        pDb->bMultiProc = *piVal = (*piVal!=0);\n      }\n      break;\n    }\n\n    case LSM_CONFIG_READONLY: {\n      int *piVal = va_arg(ap, int *);\n      /* If lsm_open() has been called, this is a read-only parameter. */\n      if( pDb->pDatabase==0 && *piVal>=0 ){\n        pDb->bReadonly = *piVal = (*piVal!=0);\n      }\n      *piVal = pDb->bReadonly;\n      break;\n    }\n\n    case LSM_CONFIG_SET_COMPRESSION: {\n      lsm_compress *p = va_arg(ap, lsm_compress *);\n      if( pDb->iReader>=0 && pDb->bInFactory==0 ){\n        /* May not change compression schemes with an open transaction */\n        rc = LSM_MISUSE_BKPT;\n      }else{\n        if( pDb->compress.xFree ){\n          /* Invoke any destructor belonging to the current compression. */\n          pDb->compress.xFree(pDb->compress.pCtx);\n        }\n        if( p->xBound==0 ){\n          memset(&pDb->compress, 0, sizeof(lsm_compress));\n          pDb->compress.iId = LSM_COMPRESSION_NONE;\n        }else{\n          memcpy(&pDb->compress, p, sizeof(lsm_compress));\n        }\n        rc = lsmFsConfigure(pDb);\n      }\n      break;\n    }\n\n    case LSM_CONFIG_SET_COMPRESSION_FACTORY: {\n      lsm_compress_factory *p = va_arg(ap, lsm_compress_factory *);\n      if( pDb->factory.xFree ){\n        /* Invoke any destructor belonging to the current factory. */\n        pDb->factory.xFree(pDb->factory.pCtx);\n      }\n      memcpy(&pDb->factory, p, sizeof(lsm_compress_factory));\n      break;\n    }\n\n    case LSM_CONFIG_GET_COMPRESSION: {\n      lsm_compress *p = va_arg(ap, lsm_compress *);\n      memcpy(p, &pDb->compress, sizeof(lsm_compress));\n      break;\n    }\n\n    default:\n      rc = LSM_MISUSE;\n      break;\n  }\n\n  va_end(ap);\n  return rc;\n}\n\nvoid lsmAppendSegmentList(LsmString *pStr, char *zPre, Segment *pSeg){\n  lsmStringAppendf(pStr, \"%s{%d %d %d %d}\", zPre, \n        pSeg->iFirst, pSeg->iLastPg, pSeg->iRoot, pSeg->nSize\n  );\n}\n\nstatic int infoGetWorker(lsm_db *pDb, Snapshot **pp, int *pbUnlock){\n  int rc = LSM_OK;\n\n  assert( *pbUnlock==0 );\n  if( !pDb->pWorker ){\n    rc = lsmBeginWork(pDb);\n    if( rc!=LSM_OK ) return rc;\n    *pbUnlock = 1;\n  }\n  if( pp ) *pp = pDb->pWorker;\n  return rc;\n}\n\nstatic void infoFreeWorker(lsm_db *pDb, int bUnlock){\n  if( bUnlock ){\n    int rcdummy = LSM_BUSY;\n    lsmFinishWork(pDb, 0, &rcdummy);\n  }\n}\n\nint lsmStructList(\n  lsm_db *pDb,                    /* Database handle */\n  char **pzOut                    /* OUT: Nul-terminated string (tcl list) */\n){\n  Level *pTopLevel = 0;           /* Top level of snapshot to report on */\n  int rc = LSM_OK;\n  Level *p;\n  LsmString s;\n  Snapshot *pWorker;              /* Worker snapshot */\n  int bUnlock = 0;\n\n  /* Obtain the worker snapshot */\n  rc = infoGetWorker(pDb, &pWorker, &bUnlock);\n  if( rc!=LSM_OK ) return rc;\n\n  /* Format the contents of the snapshot as text */\n  pTopLevel = lsmDbSnapshotLevel(pWorker);\n  lsmStringInit(&s, pDb->pEnv);\n  for(p=pTopLevel; rc==LSM_OK && p; p=p->pNext){\n    int i;\n    lsmStringAppendf(&s, \"%s{%d\", (s.n ? \" \" : \"\"), (int)p->iAge);\n    lsmAppendSegmentList(&s, \" \", &p->lhs);\n    for(i=0; rc==LSM_OK && i<p->nRight; i++){\n      lsmAppendSegmentList(&s, \" \", &p->aRhs[i]);\n    }\n    lsmStringAppend(&s, \"}\", 1);\n  }\n  rc = s.n>=0 ? LSM_OK : LSM_NOMEM;\n\n  /* Release the snapshot and return */\n  infoFreeWorker(pDb, bUnlock);\n  *pzOut = s.z;\n  return rc;\n}\n\nstatic int infoFreelistCb(void *pCtx, int iBlk, i64 iSnapshot){\n  LsmString *pStr = (LsmString *)pCtx;\n  lsmStringAppendf(pStr, \"%s{%d %lld}\", (pStr->n?\" \":\"\"), iBlk, iSnapshot);\n  return 0;\n}\n\nint lsmInfoFreelist(lsm_db *pDb, char **pzOut){\n  Snapshot *pWorker;              /* Worker snapshot */\n  int bUnlock = 0;\n  LsmString s;\n  int rc;\n\n  /* Obtain the worker snapshot */\n  rc = infoGetWorker(pDb, &pWorker, &bUnlock);\n  if( rc!=LSM_OK ) return rc;\n\n  lsmStringInit(&s, pDb->pEnv);\n  rc = lsmWalkFreelist(pDb, 0, infoFreelistCb, &s);\n  if( rc!=LSM_OK ){\n    lsmFree(pDb->pEnv, s.z);\n  }else{\n    *pzOut = s.z;\n  }\n\n  /* Release the snapshot and return */\n  infoFreeWorker(pDb, bUnlock);\n  return rc;\n}\n\nstatic int infoTreeSize(lsm_db *db, int *pnOldKB, int *pnNewKB){\n  ShmHeader *pShm = db->pShmhdr;\n  TreeHeader *p = &pShm->hdr1;\n\n  /* The following code suffers from two race conditions, as it accesses and\n  ** trusts the contents of shared memory without verifying checksums:\n  **\n  **   * The two values read - TreeHeader.root.nByte and oldroot.nByte - are \n  **     32-bit fields. It is assumed that reading from one of these\n  **     is atomic - that it is not possible to read a partially written\n  **     garbage value. However the two values may be mutually inconsistent. \n  **\n  **   * TreeHeader.iLogOff is a 64-bit value. And lsmCheckpointLogOffset()\n  **     reads a 64-bit value from a snapshot stored in shared memory. It\n  **     is assumed that in each case it is possible to read a partially\n  **     written garbage value. If this occurs, then the value returned\n  **     for the size of the \"old\" tree may reflect the size of an \"old\"\n  **     tree that was recently flushed to disk.\n  **\n  ** Given the context in which this function is called (as a result of an\n  ** lsm_info(LSM_INFO_TREE_SIZE) request), neither of these are considered to\n  ** be problems.\n  */\n  *pnNewKB = ((int)p->root.nByte + 1023) / 1024;\n  if( p->iOldShmid ){\n    if( p->iOldLog==lsmCheckpointLogOffset(pShm->aSnap1) ){\n      *pnOldKB = 0;\n    }else{\n      *pnOldKB = ((int)p->oldroot.nByte + 1023) / 1024;\n    }\n  }else{\n    *pnOldKB = 0;\n  }\n\n  return LSM_OK;\n}\n\nint lsm_info(lsm_db *pDb, int eParam, ...){\n  int rc = LSM_OK;\n  va_list ap;\n  va_start(ap, eParam);\n\n  switch( eParam ){\n    case LSM_INFO_NWRITE: {\n      int *piVal = va_arg(ap, int *);\n      *piVal = lsmFsNWrite(pDb->pFS);\n      break;\n    }\n\n    case LSM_INFO_NREAD: {\n      int *piVal = va_arg(ap, int *);\n      *piVal = lsmFsNRead(pDb->pFS);\n      break;\n    }\n\n    case LSM_INFO_DB_STRUCTURE: {\n      char **pzVal = va_arg(ap, char **);\n      rc = lsmStructList(pDb, pzVal);\n      break;\n    }\n\n    case LSM_INFO_ARRAY_STRUCTURE: {\n      Pgno pgno = va_arg(ap, Pgno);\n      char **pzVal = va_arg(ap, char **);\n      rc = lsmInfoArrayStructure(pDb, 0, pgno, pzVal);\n      break;\n    }\n\n    case LSM_INFO_ARRAY_PAGES: {\n      Pgno pgno = va_arg(ap, Pgno);\n      char **pzVal = va_arg(ap, char **);\n      rc = lsmInfoArrayPages(pDb, pgno, pzVal);\n      break;\n    }\n\n    case LSM_INFO_PAGE_HEX_DUMP:\n    case LSM_INFO_PAGE_ASCII_DUMP: {\n      Pgno pgno = va_arg(ap, Pgno);\n      char **pzVal = va_arg(ap, char **);\n      int bUnlock = 0;\n      rc = infoGetWorker(pDb, 0, &bUnlock);\n      if( rc==LSM_OK ){\n        int bHex = (eParam==LSM_INFO_PAGE_HEX_DUMP);\n        rc = lsmInfoPageDump(pDb, pgno, bHex, pzVal);\n      }\n      infoFreeWorker(pDb, bUnlock);\n      break;\n    }\n\n    case LSM_INFO_LOG_STRUCTURE: {\n      char **pzVal = va_arg(ap, char **);\n      rc = lsmInfoLogStructure(pDb, pzVal);\n      break;\n    }\n\n    case LSM_INFO_FREELIST: {\n      char **pzVal = va_arg(ap, char **);\n      rc = lsmInfoFreelist(pDb, pzVal);\n      break;\n    }\n\n    case LSM_INFO_CHECKPOINT_SIZE: {\n      int *pnKB = va_arg(ap, int *);\n      rc = lsmCheckpointSize(pDb, pnKB);\n      break;\n    }\n\n    case LSM_INFO_TREE_SIZE: {\n      int *pnOld = va_arg(ap, int *);\n      int *pnNew = va_arg(ap, int *);\n      rc = infoTreeSize(pDb, pnOld, pnNew);\n      break;\n    }\n\n    case LSM_INFO_COMPRESSION_ID: {\n      unsigned int *piOut = va_arg(ap, unsigned int *);\n      if( pDb->pClient ){\n        *piOut = pDb->pClient->iCmpId;\n      }else{\n        rc = lsmInfoCompressionId(pDb, piOut);\n      }\n      break;\n    }\n\n    default:\n      rc = LSM_MISUSE;\n      break;\n  }\n\n  va_end(ap);\n  return rc;\n}\n\nstatic int doWriteOp(\n  lsm_db *pDb,\n  int bDeleteRange,\n  const void *pKey, int nKey,     /* Key to write or delete */\n  const void *pVal, int nVal      /* Value to write. Or nVal==-1 for a delete */\n){\n  int rc = LSM_OK;                /* Return code */\n  int bCommit = 0;                /* True to commit before returning */\n\n  if( pDb->nTransOpen==0 ){\n    bCommit = 1;\n    rc = lsm_begin(pDb, 1);\n  }\n\n  if( rc==LSM_OK ){\n    int eType = (bDeleteRange ? LSM_DRANGE : (nVal>=0?LSM_WRITE:LSM_DELETE));\n    rc = lsmLogWrite(pDb, eType, (void *)pKey, nKey, (void *)pVal, nVal);\n  }\n\n  lsmSortedSaveTreeCursors(pDb);\n\n  if( rc==LSM_OK ){\n    int pgsz = lsmFsPageSize(pDb->pFS);\n    int nQuant = LSM_AUTOWORK_QUANT * pgsz;\n    int nBefore;\n    int nAfter;\n    int nDiff;\n\n    if( nQuant>pDb->nTreeLimit ){\n      nQuant = pDb->nTreeLimit;\n    }\n\n    nBefore = lsmTreeSize(pDb);\n    if( bDeleteRange ){\n      rc = lsmTreeDelete(pDb, (void *)pKey, nKey, (void *)pVal, nVal);\n    }else{\n      rc = lsmTreeInsert(pDb, (void *)pKey, nKey, (void *)pVal, nVal);\n    }\n\n    nAfter = lsmTreeSize(pDb);\n    nDiff = (nAfter/nQuant) - (nBefore/nQuant);\n    if( rc==LSM_OK && pDb->bAutowork && nDiff!=0 ){\n      rc = lsmSortedAutoWork(pDb, nDiff * LSM_AUTOWORK_QUANT);\n    }\n  }\n\n  /* If a transaction was opened at the start of this function, commit it. \n  ** Or, if an error has occurred, roll it back.  */\n  if( bCommit ){\n    if( rc==LSM_OK ){\n      rc = lsm_commit(pDb, 0);\n    }else{\n      lsm_rollback(pDb, 0);\n    }\n  }\n\n  return rc;\n}\n\n/* \n** Write a new value into the database.\n*/\nint lsm_insert(\n  lsm_db *db,                     /* Database connection */\n  const void *pKey, int nKey,     /* Key to write or delete */\n  const void *pVal, int nVal      /* Value to write. Or nVal==-1 for a delete */\n){\n  return doWriteOp(db, 0, pKey, nKey, pVal, nVal);\n}\n\n/*\n** Delete a value from the database. \n*/\nint lsm_delete(lsm_db *db, const void *pKey, int nKey){\n  return doWriteOp(db, 0, pKey, nKey, 0, -1);\n}\n\n/*\n** Delete a range of database keys.\n*/\nint lsm_delete_range(\n  lsm_db *db,                     /* Database handle */\n  const void *pKey1, int nKey1,   /* Lower bound of range to delete */\n  const void *pKey2, int nKey2    /* Upper bound of range to delete */\n){\n  int rc = LSM_OK;\n  if( db->xCmp((void *)pKey1, nKey1, (void *)pKey2, nKey2)<0 ){\n    rc = doWriteOp(db, 1, pKey1, nKey1, pKey2, nKey2);\n  }\n  return rc;\n}\n\n/*\n** Open a new cursor handle. \n**\n** If there are currently no other open cursor handles, and no open write\n** transaction, open a read transaction here.\n*/\nint lsm_csr_open(lsm_db *pDb, lsm_cursor **ppCsr){\n  int rc = LSM_OK;                /* Return code */\n  MultiCursor *pCsr = 0;          /* New cursor object */\n\n  /* Open a read transaction if one is not already open. */\n  assert_db_state(pDb);\n\n  if( pDb->pShmhdr==0 ){\n    assert( pDb->bReadonly );\n    rc = lsmBeginRoTrans(pDb);\n  }else if( pDb->iReader<0 ){\n    rc = lsmBeginReadTrans(pDb);\n  }\n\n  /* Allocate the multi-cursor. */\n  if( rc==LSM_OK ){\n    rc = lsmMCursorNew(pDb, &pCsr);\n  }\n\n  /* If an error has occured, set the output to NULL and delete any partially\n  ** allocated cursor. If this means there are no open cursors, release the\n  ** client snapshot.  */\n  if( rc!=LSM_OK ){\n    lsmMCursorClose(pCsr, 0);\n    dbReleaseClientSnapshot(pDb);\n  }\n\n  assert_db_state(pDb);\n  *ppCsr = (lsm_cursor *)pCsr;\n  return rc;\n}\n\n/*\n** Close a cursor opened using lsm_csr_open().\n*/\nint lsm_csr_close(lsm_cursor *p){\n  if( p ){\n    lsm_db *pDb = lsmMCursorDb((MultiCursor *)p);\n    assert_db_state(pDb);\n    lsmMCursorClose((MultiCursor *)p, 1);\n    dbReleaseClientSnapshot(pDb);\n    assert_db_state(pDb);\n  }\n  return LSM_OK;\n}\n\n/*\n** Attempt to seek the cursor to the database entry specified by pKey/nKey.\n** If an error occurs (e.g. an OOM or IO error), return an LSM error code.\n** Otherwise, return LSM_OK.\n*/\nint lsm_csr_seek(lsm_cursor *pCsr, const void *pKey, int nKey, int eSeek){\n  return lsmMCursorSeek((MultiCursor *)pCsr, 0, (void *)pKey, nKey, eSeek);\n}\n\nint lsm_csr_next(lsm_cursor *pCsr){\n  return lsmMCursorNext((MultiCursor *)pCsr);\n}\n\nint lsm_csr_prev(lsm_cursor *pCsr){\n  return lsmMCursorPrev((MultiCursor *)pCsr);\n}\n\nint lsm_csr_first(lsm_cursor *pCsr){\n  return lsmMCursorFirst((MultiCursor *)pCsr);\n}\n\nint lsm_csr_last(lsm_cursor *pCsr){\n  return lsmMCursorLast((MultiCursor *)pCsr);\n}\n\nint lsm_csr_valid(lsm_cursor *pCsr){\n  return lsmMCursorValid((MultiCursor *)pCsr);\n}\n\nint lsm_csr_key(lsm_cursor *pCsr, const void **ppKey, int *pnKey){\n  return lsmMCursorKey((MultiCursor *)pCsr, (void **)ppKey, pnKey);\n}\n\nint lsm_csr_value(lsm_cursor *pCsr, const void **ppVal, int *pnVal){\n  return lsmMCursorValue((MultiCursor *)pCsr, (void **)ppVal, pnVal);\n}\n\nvoid lsm_config_log(\n  lsm_db *pDb, \n  void (*xLog)(void *, int, const char *), \n  void *pCtx\n){\n  pDb->xLog = xLog;\n  pDb->pLogCtx = pCtx;\n}\n\nvoid lsm_config_work_hook(\n  lsm_db *pDb, \n  void (*xWork)(lsm_db *, void *), \n  void *pCtx\n){\n  pDb->xWork = xWork;\n  pDb->pWorkCtx = pCtx;\n}\n\nvoid lsmLogMessage(lsm_db *pDb, int rc, const char *zFormat, ...){\n  if( pDb->xLog ){\n    LsmString s;\n    va_list ap, ap2;\n    lsmStringInit(&s, pDb->pEnv);\n    va_start(ap, zFormat);\n    va_start(ap2, zFormat);\n    lsmStringVAppendf(&s, zFormat, ap, ap2);\n    va_end(ap);\n    va_end(ap2);\n    pDb->xLog(pDb->pLogCtx, rc, s.z);\n    lsmStringClear(&s);\n  }\n}\n\nint lsm_begin(lsm_db *pDb, int iLevel){\n  int rc;\n\n  assert_db_state( pDb );\n  rc = (pDb->bReadonly ? LSM_READONLY : LSM_OK);\n\n  /* A value less than zero means open one more transaction. */\n  if( iLevel<0 ) iLevel = pDb->nTransOpen + 1;\n  if( iLevel>pDb->nTransOpen ){\n    int i;\n\n    /* Extend the pDb->aTrans[] array if required. */\n    if( rc==LSM_OK && pDb->nTransAlloc<iLevel ){\n      TransMark *aNew;            /* New allocation */\n      int nByte = sizeof(TransMark) * (iLevel+1);\n      aNew = (TransMark *)lsmRealloc(pDb->pEnv, pDb->aTrans, nByte);\n      if( !aNew ){\n        rc = LSM_NOMEM;\n      }else{\n        nByte = sizeof(TransMark) * (iLevel+1 - pDb->nTransAlloc);\n        memset(&aNew[pDb->nTransAlloc], 0, nByte);\n        pDb->nTransAlloc = iLevel+1;\n        pDb->aTrans = aNew;\n      }\n    }\n\n    if( rc==LSM_OK && pDb->nTransOpen==0 ){\n      rc = lsmBeginWriteTrans(pDb);\n    }\n\n    if( rc==LSM_OK ){\n      for(i=pDb->nTransOpen; i<iLevel; i++){\n        lsmTreeMark(pDb, &pDb->aTrans[i].tree);\n        lsmLogTell(pDb, &pDb->aTrans[i].log);\n      }\n      pDb->nTransOpen = iLevel;\n    }\n  }\n\n  return rc;\n}\n\nint lsm_commit(lsm_db *pDb, int iLevel){\n  int rc = LSM_OK;\n\n  assert_db_state( pDb );\n\n  /* A value less than zero means close the innermost nested transaction. */\n  if( iLevel<0 ) iLevel = LSM_MAX(0, pDb->nTransOpen - 1);\n\n  if( iLevel<pDb->nTransOpen ){\n    if( iLevel==0 ){\n      int rc2;\n      /* Commit the transaction to disk. */\n      if( rc==LSM_OK ) rc = lsmLogCommit(pDb);\n      if( rc==LSM_OK && pDb->eSafety==LSM_SAFETY_FULL ){\n        rc = lsmFsSyncLog(pDb->pFS);\n      }\n      rc2 = lsmFinishWriteTrans(pDb, (rc==LSM_OK));\n      if( rc==LSM_OK ) rc = rc2;\n    }\n    pDb->nTransOpen = iLevel;\n  }\n  dbReleaseClientSnapshot(pDb);\n  return rc;\n}\n\nint lsm_rollback(lsm_db *pDb, int iLevel){\n  int rc = LSM_OK;\n  assert_db_state( pDb );\n\n  if( pDb->nTransOpen ){\n    /* A value less than zero means close the innermost nested transaction. */\n    if( iLevel<0 ) iLevel = LSM_MAX(0, pDb->nTransOpen - 1);\n\n    if( iLevel<=pDb->nTransOpen ){\n      TransMark *pMark = &pDb->aTrans[(iLevel==0 ? 0 : iLevel-1)];\n      lsmTreeRollback(pDb, &pMark->tree);\n      if( iLevel ) lsmLogSeek(pDb, &pMark->log);\n      pDb->nTransOpen = iLevel;\n    }\n\n    if( pDb->nTransOpen==0 ){\n      lsmFinishWriteTrans(pDb, 0);\n    }\n    dbReleaseClientSnapshot(pDb);\n  }\n\n  return rc;\n}\n\nint lsm_get_user_version(lsm_db *pDb, unsigned int *piUsr){\n  int rc = LSM_OK;                /* Return code */\n\n  /* Open a read transaction if one is not already open. */\n  assert_db_state(pDb);\n  if( pDb->pShmhdr==0 ){\n    assert( pDb->bReadonly );\n    rc = lsmBeginRoTrans(pDb);\n  }else if( pDb->iReader<0 ){\n    rc = lsmBeginReadTrans(pDb);\n  }\n\n  /* Allocate the multi-cursor. */\n  if( rc==LSM_OK ){\n    *piUsr = pDb->treehdr.iUsrVersion;\n  }\n\n  dbReleaseClientSnapshot(pDb);\n  assert_db_state(pDb);\n  return rc;\n}\n\nint lsm_set_user_version(lsm_db *pDb, unsigned int iUsr){\n  int rc = LSM_OK;                /* Return code */\n  int bCommit = 0;                /* True to commit before returning */\n\n  if( pDb->nTransOpen==0 ){\n    bCommit = 1;\n    rc = lsm_begin(pDb, 1);\n  }\n\n  if( rc==LSM_OK ){\n    pDb->treehdr.iUsrVersion = iUsr;\n  }\n\n  /* If a transaction was opened at the start of this function, commit it. \n  ** Or, if an error has occurred, roll it back.  */\n  if( bCommit ){\n    if( rc==LSM_OK ){\n      rc = lsm_commit(pDb, 0);\n    }else{\n      lsm_rollback(pDb, 0);\n    }\n  }\n\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_mem.c",
    "content": "/*\n** 2011-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Helper routines for memory allocation.\n*/\n#include \"lsmInt.h\"\n\n/*\n** The following routines are called internally by LSM sub-routines. In\n** this case a valid environment pointer must be supplied.\n*/\nvoid *lsmMalloc(lsm_env *pEnv, size_t N){\n  assert( pEnv );\n  return pEnv->xMalloc(pEnv, N);\n}\nvoid lsmFree(lsm_env *pEnv, void *p){\n  assert( pEnv );\n  pEnv->xFree(pEnv, p);\n}\nvoid *lsmRealloc(lsm_env *pEnv, void *p, size_t N){\n  assert( pEnv );\n  return pEnv->xRealloc(pEnv, p, N);\n}\n\n/*\n** Core memory allocation routines for LSM.\n*/\nvoid *lsm_malloc(lsm_env *pEnv, size_t N){\n  return lsmMalloc(pEnv ? pEnv : lsm_default_env(), N);\n}\nvoid lsm_free(lsm_env *pEnv, void *p){\n  lsmFree(pEnv ? pEnv : lsm_default_env(), p);\n}\nvoid *lsm_realloc(lsm_env *pEnv, void *p, size_t N){\n  return lsmRealloc(pEnv ? pEnv : lsm_default_env(), p, N);\n}\n\nvoid *lsmMallocZero(lsm_env *pEnv, size_t N){\n  void *pRet;\n  assert( pEnv );\n  pRet = lsmMalloc(pEnv, N);\n  if( pRet ) memset(pRet, 0, N);\n  return pRet;\n}\n\nvoid *lsmMallocRc(lsm_env *pEnv, size_t N, int *pRc){\n  void *pRet = 0;\n  if( *pRc==LSM_OK ){\n    pRet = lsmMalloc(pEnv, N);\n    if( pRet==0 ){\n      *pRc = LSM_NOMEM_BKPT;\n    }\n  }\n  return pRet;\n}\n\nvoid *lsmMallocZeroRc(lsm_env *pEnv, size_t N, int *pRc){\n  void *pRet = 0;\n  if( *pRc==LSM_OK ){\n    pRet = lsmMallocZero(pEnv, N);\n    if( pRet==0 ){\n      *pRc = LSM_NOMEM_BKPT;\n    }\n  }\n  return pRet;\n}\n\nvoid *lsmReallocOrFree(lsm_env *pEnv, void *p, size_t N){\n  void *pNew;\n  pNew = lsm_realloc(pEnv, p, N);\n  if( !pNew ) lsm_free(pEnv, p);\n  return pNew;\n}\n\nvoid *lsmReallocOrFreeRc(lsm_env *pEnv, void *p, size_t N, int *pRc){\n  void *pRet = 0;\n  if( *pRc ){\n    lsmFree(pEnv, p);\n  }else{\n    pRet = lsmReallocOrFree(pEnv, p, N);\n    if( !pRet ) *pRc = LSM_NOMEM_BKPT;\n  }\n  return pRet;\n}\n\nchar *lsmMallocStrdup(lsm_env *pEnv, const char *zIn){\n  int nByte;\n  char *zRet;\n  nByte = strlen(zIn);\n  zRet = lsmMalloc(pEnv, nByte+1);\n  if( zRet ){\n    memcpy(zRet, zIn, nByte+1);\n  }\n  return zRet;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_mutex.c",
    "content": "/*\n** 2012-01-30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Mutex functions for LSM.\n*/\n#include \"lsmInt.h\"\n\n/*\n** Allocate a new mutex.\n*/\nint lsmMutexNew(lsm_env *pEnv, lsm_mutex **ppNew){\n  return pEnv->xMutexNew(pEnv, ppNew);\n}\n\n/*\n** Return a handle for one of the static mutexes.\n*/\nint lsmMutexStatic(lsm_env *pEnv, int iMutex, lsm_mutex **ppStatic){\n  return pEnv->xMutexStatic(pEnv, iMutex, ppStatic);\n}\n\n/*\n** Free a mutex allocated by lsmMutexNew().\n*/\nvoid lsmMutexDel(lsm_env *pEnv, lsm_mutex *pMutex){\n  if( pMutex ) pEnv->xMutexDel(pMutex);\n}\n\n/*\n** Enter a mutex.\n*/\nvoid lsmMutexEnter(lsm_env *pEnv, lsm_mutex *pMutex){\n  pEnv->xMutexEnter(pMutex);\n}\n\n/*\n** Attempt to enter a mutex, but do not block. If successful, return zero.\n** Otherwise, if the mutex is already held by some other thread and is not\n** entered, return non zero.\n**\n** Each successful call to this function must be matched by a call to\n** lsmMutexLeave().\n*/\nint lsmMutexTry(lsm_env *pEnv, lsm_mutex *pMutex){\n  return pEnv->xMutexTry(pMutex);\n}\n\n/*\n** Leave a mutex.\n*/\nvoid lsmMutexLeave(lsm_env *pEnv, lsm_mutex *pMutex){\n  pEnv->xMutexLeave(pMutex);\n}\n\n#ifndef NDEBUG\n/*\n** Return non-zero if the mutex passed as the second argument is held\n** by the calling thread, or zero otherwise. If the implementation is not \n** able to tell if the mutex is held by the caller, it should return\n** non-zero.\n**\n** This function is only used as part of assert() statements.\n*/\nint lsmMutexHeld(lsm_env *pEnv, lsm_mutex *pMutex){\n  return pEnv->xMutexHeld ? pEnv->xMutexHeld(pMutex) : 1;\n}\n\n/*\n** Return non-zero if the mutex passed as the second argument is not \n** held by the calling thread, or zero otherwise. If the implementation \n** is not able to tell if the mutex is held by the caller, it should \n** return non-zero.\n**\n** This function is only used as part of assert() statements.\n*/\nint lsmMutexNotHeld(lsm_env *pEnv, lsm_mutex *pMutex){\n  return pEnv->xMutexNotHeld ? pEnv->xMutexNotHeld(pMutex) : 1;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_shared.c",
    "content": "/*\n** 2012-01-23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Utilities used to help multiple LSM clients to coexist within the\n** same process space.\n*/\n#include \"lsmInt.h\"\n\n/*\n** Global data. All global variables used by code in this file are grouped\n** into the following structure instance.\n**\n** pDatabase:\n**   Linked list of all Database objects allocated within this process.\n**   This list may not be traversed without holding the global mutex (see\n**   functions enterGlobalMutex() and leaveGlobalMutex()).\n*/\nstatic struct SharedData {\n  Database *pDatabase;            /* Linked list of all Database objects */\n} gShared;\n\n/*\n** Database structure. There is one such structure for each distinct \n** database accessed by this process. They are stored in the singly linked \n** list starting at global variable gShared.pDatabase. Database objects are \n** reference counted. Once the number of connections to the associated\n** database drops to zero, they are removed from the linked list and deleted.\n**\n** pFile:\n**   In multi-process mode, this file descriptor is used to obtain locks \n**   and to access shared-memory. In single process mode, its only job is\n**   to hold the exclusive lock on the file.\n**   \n*/\nstruct Database {\n  /* Protected by the global mutex (enterGlobalMutex/leaveGlobalMutex): */\n  char *zName;                    /* Canonical path to database file */\n  int nName;                      /* strlen(zName) */\n  int nDbRef;                     /* Number of associated lsm_db handles */\n  Database *pDbNext;              /* Next Database structure in global list */\n\n  /* Protected by the local mutex (pClientMutex) */\n  int bReadonly;                  /* True if Database.pFile is read-only */\n  int bMultiProc;                 /* True if running in multi-process mode */\n  lsm_file *pFile;                /* Used for locks/shm in multi-proc mode */\n  LsmFile *pLsmFile;              /* List of deferred closes */\n  lsm_mutex *pClientMutex;        /* Protects the apShmChunk[] and pConn */\n  int nShmChunk;                  /* Number of entries in apShmChunk[] array */\n  void **apShmChunk;              /* Array of \"shared\" memory regions */\n  lsm_db *pConn;                  /* List of connections to this db. */\n};\n\n/*\n** Functions to enter and leave the global mutex. This mutex is used\n** to protect the global linked-list headed at gShared.pDatabase.\n*/\nstatic int enterGlobalMutex(lsm_env *pEnv){\n  lsm_mutex *p;\n  int rc = lsmMutexStatic(pEnv, LSM_MUTEX_GLOBAL, &p);\n  if( rc==LSM_OK ) lsmMutexEnter(pEnv, p);\n  return rc;\n}\nstatic void leaveGlobalMutex(lsm_env *pEnv){\n  lsm_mutex *p;\n  lsmMutexStatic(pEnv, LSM_MUTEX_GLOBAL, &p);\n  lsmMutexLeave(pEnv, p);\n}\n\n#ifdef LSM_DEBUG\nstatic int holdingGlobalMutex(lsm_env *pEnv){\n  lsm_mutex *p;\n  lsmMutexStatic(pEnv, LSM_MUTEX_GLOBAL, &p);\n  return lsmMutexHeld(pEnv, p);\n}\n#endif\n\n#if 0\nstatic void assertNotInFreelist(Freelist *p, int iBlk){\n  int i; \n  for(i=0; i<p->nEntry; i++){\n    assert( p->aEntry[i].iBlk!=iBlk );\n  }\n}\n#else\n# define assertNotInFreelist(x,y)\n#endif\n\n/*\n** Append an entry to the free-list. If (iId==-1), this is a delete.\n*/\nint freelistAppend(lsm_db *db, u32 iBlk, i64 iId){\n  lsm_env *pEnv = db->pEnv;\n  Freelist *p;\n  int i; \n\n  assert( iId==-1 || iId>=0 );\n  p = db->bUseFreelist ? db->pFreelist : &db->pWorker->freelist;\n\n  /* Extend the space allocated for the freelist, if required */\n  assert( p->nAlloc>=p->nEntry );\n  if( p->nAlloc==p->nEntry ){\n    int nNew; \n    int nByte; \n    FreelistEntry *aNew;\n\n    nNew = (p->nAlloc==0 ? 4 : p->nAlloc*2);\n    nByte = sizeof(FreelistEntry) * nNew;\n    aNew = (FreelistEntry *)lsmRealloc(pEnv, p->aEntry, nByte);\n    if( !aNew ) return LSM_NOMEM_BKPT;\n    p->nAlloc = nNew;\n    p->aEntry = aNew;\n  }\n\n  for(i=0; i<p->nEntry; i++){\n    assert( i==0 || p->aEntry[i].iBlk > p->aEntry[i-1].iBlk );\n    if( p->aEntry[i].iBlk>=iBlk ) break;\n  }\n\n  if( i<p->nEntry && p->aEntry[i].iBlk==iBlk ){\n    /* Clobber an existing entry */\n    p->aEntry[i].iId = iId;\n  }else{\n    /* Insert a new entry into the list */\n    int nByte = sizeof(FreelistEntry)*(p->nEntry-i);\n    memmove(&p->aEntry[i+1], &p->aEntry[i], nByte);\n    p->aEntry[i].iBlk = iBlk;\n    p->aEntry[i].iId = iId;\n    p->nEntry++;\n  }\n\n  return LSM_OK;\n}\n\n/*\n** This function frees all resources held by the Database structure passed\n** as the only argument.\n*/\nstatic void freeDatabase(lsm_env *pEnv, Database *p){\n  assert( holdingGlobalMutex(pEnv) );\n  if( p ){\n    /* Free the mutexes */\n    lsmMutexDel(pEnv, p->pClientMutex);\n\n    if( p->pFile ){\n      lsmEnvClose(pEnv, p->pFile);\n    }\n\n    /* Free the array of shm pointers */\n    lsmFree(pEnv, p->apShmChunk);\n\n    /* Free the memory allocated for the Database struct itself */\n    lsmFree(pEnv, p);\n  }\n}\n\ntypedef struct DbTruncateCtx DbTruncateCtx;\nstruct DbTruncateCtx {\n  int nBlock;\n  i64 iInUse;\n};\n\nstatic int dbTruncateCb(void *pCtx, int iBlk, i64 iSnapshot){\n  DbTruncateCtx *p = (DbTruncateCtx *)pCtx;\n  if( iBlk!=p->nBlock || (p->iInUse>=0 && iSnapshot>=p->iInUse) ) return 1;\n  p->nBlock--;\n  return 0;\n}\n\nstatic int dbTruncate(lsm_db *pDb, i64 iInUse){\n  int rc = LSM_OK;\n#if 0\n  int i;\n  DbTruncateCtx ctx;\n\n  assert( pDb->pWorker );\n  ctx.nBlock = pDb->pWorker->nBlock;\n  ctx.iInUse = iInUse;\n\n  rc = lsmWalkFreelist(pDb, 1, dbTruncateCb, (void *)&ctx);\n  for(i=ctx.nBlock+1; rc==LSM_OK && i<=pDb->pWorker->nBlock; i++){\n    rc = freelistAppend(pDb, i, -1);\n  }\n\n  if( rc==LSM_OK ){\n#ifdef LSM_LOG_FREELIST\n    if( ctx.nBlock!=pDb->pWorker->nBlock ){\n      lsmLogMessage(pDb, 0, \n          \"dbTruncate(): truncated db to %d blocks\",ctx.nBlock\n      );\n    }\n#endif\n    pDb->pWorker->nBlock = ctx.nBlock;\n  }\n#endif\n  return rc;\n}\n\n\n/*\n** This function is called during database shutdown (when the number of\n** connections drops from one to zero). It truncates the database file\n** to as small a size as possible without truncating away any blocks that\n** contain data.\n*/\nstatic int dbTruncateFile(lsm_db *pDb){\n  int rc;\n\n  assert( pDb->pWorker==0 );\n  assert( lsmShmAssertLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_EXCL) );\n  rc = lsmCheckpointLoadWorker(pDb);\n\n  if( rc==LSM_OK ){\n    DbTruncateCtx ctx;\n\n    /* Walk the database free-block-list in reverse order. Set ctx.nBlock\n    ** to the block number of the last block in the database that actually\n    ** contains data. */\n    ctx.nBlock = pDb->pWorker->nBlock;\n    ctx.iInUse = -1;\n    rc = lsmWalkFreelist(pDb, 1, dbTruncateCb, (void *)&ctx);\n\n    /* If the last block that contains data is not already the last block in\n    ** the database file, truncate the database file so that it is. */\n    if( rc==LSM_OK ){\n      rc = lsmFsTruncateDb(\n          pDb->pFS, (i64)ctx.nBlock*lsmFsBlockSize(pDb->pFS)\n      );\n    }\n  }\n\n  lsmFreeSnapshot(pDb->pEnv, pDb->pWorker);\n  pDb->pWorker = 0;\n  return rc;\n}\n\nstatic void doDbDisconnect(lsm_db *pDb){\n  int rc;\n\n  if( pDb->bReadonly ){\n    lsmShmLock(pDb, LSM_LOCK_DMS3, LSM_LOCK_UNLOCK, 0);\n  }else{\n    /* Block for an exclusive lock on DMS1. This lock serializes all calls\n    ** to doDbConnect() and doDbDisconnect() across all processes.  */\n    rc = lsmShmLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_EXCL, 1);\n    if( rc==LSM_OK ){\n\n      lsmShmLock(pDb, LSM_LOCK_DMS2, LSM_LOCK_UNLOCK, 0);\n\n      /* Try an exclusive lock on DMS2. If successful, this is the last\n      ** connection to the database. In this case flush the contents of the\n      ** in-memory tree to disk and write a checkpoint.  */\n      rc = lsmShmTestLock(pDb, LSM_LOCK_DMS2, 1, LSM_LOCK_EXCL);\n      if( rc==LSM_OK ){\n        rc = lsmShmTestLock(pDb, LSM_LOCK_CHECKPOINTER, 1, LSM_LOCK_EXCL);\n      }\n      if( rc==LSM_OK ){\n        int bReadonly = 0;        /* True if there exist read-only conns. */\n\n        /* Flush the in-memory tree, if required. If there is data to flush,\n        ** this will create a new client snapshot in Database.pClient. The\n        ** checkpoint (serialization) of this snapshot may be written to disk\n        ** by the following block.  \n        **\n        ** There is no need to take a WRITER lock here. That there are no \n        ** other locks on DMS2 guarantees that there are no other read-write\n        ** connections at this time (and the lock on DMS1 guarantees that\n        ** no new ones may appear).\n        */\n        rc = lsmTreeLoadHeader(pDb, 0);\n        if( rc==LSM_OK && (lsmTreeHasOld(pDb) || lsmTreeSize(pDb)>0) ){\n          rc = lsmFlushTreeToDisk(pDb);\n        }\n\n        /* Now check if there are any read-only connections. If there are,\n        ** then do not truncate the db file or unlink the shared-memory \n        ** region.  */\n        if( rc==LSM_OK ){\n          rc = lsmShmTestLock(pDb, LSM_LOCK_DMS3, 1, LSM_LOCK_EXCL);\n          if( rc==LSM_BUSY ){\n            bReadonly = 1;\n            rc = LSM_OK;\n          }\n        }\n\n        /* Write a checkpoint to disk. */\n        if( rc==LSM_OK ){\n          rc = lsmCheckpointWrite(pDb, 0);\n        }\n\n        /* If the checkpoint was written successfully, delete the log file\n        ** and, if possible, truncate the database file.  */\n        if( rc==LSM_OK ){\n          int bRotrans = 0;\n          Database *p = pDb->pDatabase;\n\n          /* The log file may only be deleted if there are no clients \n          ** read-only clients running rotrans transactions.  */\n          rc = lsmDetectRoTrans(pDb, &bRotrans);\n          if( rc==LSM_OK && bRotrans==0 ){\n            lsmFsCloseAndDeleteLog(pDb->pFS);\n          }\n\n          /* The database may only be truncated if there exist no read-only\n          ** clients - either connected or running rotrans transactions. */\n          if( bReadonly==0 && bRotrans==0 ){\n            lsmFsUnmap(pDb->pFS);\n            dbTruncateFile(pDb);\n            if( p->pFile && p->bMultiProc ){\n              lsmEnvShmUnmap(pDb->pEnv, p->pFile, 1);\n            }\n          }\n        }\n      }\n    }\n\n    if( pDb->iRwclient>=0 ){\n      lsmShmLock(pDb, LSM_LOCK_RWCLIENT(pDb->iRwclient), LSM_LOCK_UNLOCK, 0);\n      pDb->iRwclient = -1;\n    }\n\n    lsmShmLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_UNLOCK, 0);\n  }\n  pDb->pShmhdr = 0;\n}\n\nstatic int doDbConnect(lsm_db *pDb){\n  const int nUsMax = 100000;      /* Max value for nUs */\n  int nUs = 1000;                 /* us to wait between DMS1 attempts */\n  int rc;\n\n  /* Obtain a pointer to the shared-memory header */\n  assert( pDb->pShmhdr==0 );\n  assert( pDb->bReadonly==0 );\n\n  /* Block for an exclusive lock on DMS1. This lock serializes all calls\n  ** to doDbConnect() and doDbDisconnect() across all processes.  */\n  while( 1 ){\n    rc = lsmShmLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_EXCL, 1);\n    if( rc!=LSM_BUSY ) break;\n    lsmEnvSleep(pDb->pEnv, nUs);\n    nUs = nUs * 2;\n    if( nUs>nUsMax ) nUs = nUsMax;\n  }\n  if( rc==LSM_OK ){\n    rc = lsmShmCacheChunks(pDb, 1);\n  }\n  if( rc!=LSM_OK ) return rc;\n  pDb->pShmhdr = (ShmHeader *)pDb->apShm[0];\n\n  /* Try an exclusive lock on DMS2/DMS3. If successful, this is the first \n  ** and only connection to the database. In this case initialize the \n  ** shared-memory and run log file recovery.  */\n  assert( LSM_LOCK_DMS3==1+LSM_LOCK_DMS2 );\n  rc = lsmShmTestLock(pDb, LSM_LOCK_DMS2, 2, LSM_LOCK_EXCL);\n  if( rc==LSM_OK ){\n    memset(pDb->pShmhdr, 0, sizeof(ShmHeader));\n    rc = lsmCheckpointRecover(pDb);\n    if( rc==LSM_OK ){\n      rc = lsmLogRecover(pDb);\n    }\n    if( rc==LSM_OK ){\n      ShmHeader *pShm = pDb->pShmhdr;\n      pShm->aReader[0].iLsmId = lsmCheckpointId(pShm->aSnap1, 0);\n      pShm->aReader[0].iTreeId = pDb->treehdr.iUsedShmid;\n    }\n  }else if( rc==LSM_BUSY ){\n    rc = LSM_OK;\n  }\n\n  /* Take a shared lock on DMS2. In multi-process mode this lock \"cannot\" \n  ** fail, as connections may only hold an exclusive lock on DMS2 if they \n  ** first hold an exclusive lock on DMS1. And this connection is currently \n  ** holding the exclusive lock on DSM1. \n  **\n  ** However, if some other connection has the database open in single-process\n  ** mode, this operation will fail. In this case, return the error to the\n  ** caller - the attempt to connect to the db has failed.\n  */\n  if( rc==LSM_OK ){\n    rc = lsmShmLock(pDb, LSM_LOCK_DMS2, LSM_LOCK_SHARED, 0);\n  }\n\n  /* If anything went wrong, unlock DMS2. Otherwise, try to take an exclusive\n  ** lock on one of the LSM_LOCK_RWCLIENT() locks. Unlock DMS1 in any case. */\n  if( rc!=LSM_OK ){\n    pDb->pShmhdr = 0;\n  }else{\n    int i;\n    for(i=0; i<LSM_LOCK_NRWCLIENT; i++){\n      int rc2 = lsmShmLock(pDb, LSM_LOCK_RWCLIENT(i), LSM_LOCK_EXCL, 0);\n      if( rc2==LSM_OK ) pDb->iRwclient = i;\n      if( rc2!=LSM_BUSY ){\n        rc = rc2;\n        break;\n      }\n    }\n  }\n  lsmShmLock(pDb, LSM_LOCK_DMS1, LSM_LOCK_UNLOCK, 0);\n\n  return rc;\n}\n\nstatic int dbOpenSharedFd(lsm_env *pEnv, Database *p, int bRoOk){\n  int rc;\n\n  rc = lsmEnvOpen(pEnv, p->zName, 0, &p->pFile);\n  if( rc==LSM_IOERR && bRoOk ){\n    rc = lsmEnvOpen(pEnv, p->zName, LSM_OPEN_READONLY, &p->pFile);\n    p->bReadonly = 1;\n  }\n\n  return rc;\n}\n\n/*\n** Return a reference to the shared Database handle for the database \n** identified by canonical path zName. If this is the first connection to\n** the named database, a new Database object is allocated. Otherwise, a\n** pointer to an existing object is returned.\n**\n** If successful, *ppDatabase is set to point to the shared Database \n** structure and LSM_OK returned. Otherwise, *ppDatabase is set to NULL\n** and and LSM error code returned.\n**\n** Each successful call to this function should be (eventually) matched\n** by a call to lsmDbDatabaseRelease().\n*/\nint lsmDbDatabaseConnect(\n  lsm_db *pDb,                    /* Database handle */\n  const char *zName               /* Full-path to db file */\n){\n  lsm_env *pEnv = pDb->pEnv;\n  int rc;                         /* Return code */\n  Database *p = 0;                /* Pointer returned via *ppDatabase */\n  int nName = lsmStrlen(zName);\n\n  assert( pDb->pDatabase==0 );\n  rc = enterGlobalMutex(pEnv);\n  if( rc==LSM_OK ){\n\n    /* Search the global list for an existing object. TODO: Need something\n    ** better than the memcmp() below to figure out if a given Database\n    ** object represents the requested file.  */\n    for(p=gShared.pDatabase; p; p=p->pDbNext){\n      if( nName==p->nName && 0==memcmp(zName, p->zName, nName) ) break;\n    }\n\n    /* If no suitable Database object was found, allocate a new one. */\n    if( p==0 ){\n      p = (Database *)lsmMallocZeroRc(pEnv, sizeof(Database)+nName+1, &rc);\n\n      /* If the allocation was successful, fill in other fields and\n      ** allocate the client mutex. */ \n      if( rc==LSM_OK ){\n        p->bMultiProc = pDb->bMultiProc;\n        p->zName = (char *)&p[1];\n        p->nName = nName;\n        memcpy((void *)p->zName, zName, nName+1);\n        rc = lsmMutexNew(pEnv, &p->pClientMutex);\n      }\n\n      /* If nothing has gone wrong so far, open the shared fd. And if that\n      ** succeeds and this connection requested single-process mode, \n      ** attempt to take the exclusive lock on DMS2.  */\n      if( rc==LSM_OK ){\n        int bReadonly = (pDb->bReadonly && pDb->bMultiProc);\n        rc = dbOpenSharedFd(pDb->pEnv, p, bReadonly);\n      }\n\n      if( rc==LSM_OK && p->bMultiProc==0 ){\n        /* Hold an exclusive lock DMS1 while grabbing DMS2. This ensures\n        ** that any ongoing call to doDbDisconnect() (even one in another\n        ** process) is finished before proceeding.  */\n        assert( p->bReadonly==0 );\n        rc = lsmEnvLock(pDb->pEnv, p->pFile, LSM_LOCK_DMS1, LSM_LOCK_EXCL);\n        if( rc==LSM_OK ){\n          rc = lsmEnvLock(pDb->pEnv, p->pFile, LSM_LOCK_DMS2, LSM_LOCK_EXCL);\n          lsmEnvLock(pDb->pEnv, p->pFile, LSM_LOCK_DMS1, LSM_LOCK_UNLOCK);\n        }\n      }\n\n      if( rc==LSM_OK ){\n        p->pDbNext = gShared.pDatabase;\n        gShared.pDatabase = p;\n      }else{\n        freeDatabase(pEnv, p);\n        p = 0;\n      }\n    }\n\n    if( p ){\n      p->nDbRef++;\n    }\n    leaveGlobalMutex(pEnv);\n\n    if( p ){\n      lsmMutexEnter(pDb->pEnv, p->pClientMutex);\n      pDb->pNext = p->pConn;\n      p->pConn = pDb;\n      lsmMutexLeave(pDb->pEnv, p->pClientMutex);\n    }\n  }\n\n  pDb->pDatabase = p;\n  if( rc==LSM_OK ){\n    assert( p );\n    rc = lsmFsOpen(pDb, zName, p->bReadonly);\n  }\n\n  /* If the db handle is read-write, then connect to the system now. Run\n  ** recovery as necessary. Or, if this is a read-only database handle,\n  ** defer attempting to connect to the system until a read-transaction\n  ** is opened.  */\n  if( pDb->bReadonly==0 ){\n    if( rc==LSM_OK ){\n      rc = lsmFsConfigure(pDb);\n    }\n    if( rc==LSM_OK ){\n      rc = doDbConnect(pDb);\n    }\n  }\n\n  return rc;\n}\n\nstatic void dbDeferClose(lsm_db *pDb){\n  if( pDb->pFS ){\n    LsmFile *pLsmFile;\n    Database *p = pDb->pDatabase;\n    pLsmFile = lsmFsDeferClose(pDb->pFS);\n    pLsmFile->pNext = p->pLsmFile;\n    p->pLsmFile = pLsmFile;\n  }\n}\n\nLsmFile *lsmDbRecycleFd(lsm_db *db){\n  LsmFile *pRet;\n  Database *p = db->pDatabase;\n  lsmMutexEnter(db->pEnv, p->pClientMutex);\n  if( (pRet = p->pLsmFile)!=0 ){\n    p->pLsmFile = pRet->pNext;\n  }\n  lsmMutexLeave(db->pEnv, p->pClientMutex);\n  return pRet;\n}\n\n/*\n** Release a reference to a Database object obtained from \n** lsmDbDatabaseConnect(). There should be exactly one call to this function \n** for each successful call to Find().\n*/\nvoid lsmDbDatabaseRelease(lsm_db *pDb){\n  Database *p = pDb->pDatabase;\n  if( p ){\n    lsm_db **ppDb;\n\n    if( pDb->pShmhdr ){\n      doDbDisconnect(pDb);\n    }\n\n    lsmFsUnmap(pDb->pFS);\n    lsmMutexEnter(pDb->pEnv, p->pClientMutex);\n    for(ppDb=&p->pConn; *ppDb!=pDb; ppDb=&((*ppDb)->pNext));\n    *ppDb = pDb->pNext;\n    dbDeferClose(pDb);\n    lsmMutexLeave(pDb->pEnv, p->pClientMutex);\n\n    enterGlobalMutex(pDb->pEnv);\n    p->nDbRef--;\n    if( p->nDbRef==0 ){\n      LsmFile *pIter;\n      LsmFile *pNext;\n      Database **pp;\n\n      /* Remove the Database structure from the linked list. */\n      for(pp=&gShared.pDatabase; *pp!=p; pp=&((*pp)->pDbNext));\n      *pp = p->pDbNext;\n\n      /* If they were allocated from the heap, free the shared memory chunks */\n      if( p->bMultiProc==0 ){\n        int i;\n        for(i=0; i<p->nShmChunk; i++){\n          lsmFree(pDb->pEnv, p->apShmChunk[i]);\n        }\n      }\n\n      /* Close any outstanding file descriptors */\n      for(pIter=p->pLsmFile; pIter; pIter=pNext){\n        pNext = pIter->pNext;\n        lsmEnvClose(pDb->pEnv, pIter->pFile);\n        lsmFree(pDb->pEnv, pIter);\n      }\n      freeDatabase(pDb->pEnv, p);\n    }\n    leaveGlobalMutex(pDb->pEnv);\n  }\n}\n\nLevel *lsmDbSnapshotLevel(Snapshot *pSnapshot){\n  return pSnapshot->pLevel;\n}\n\nvoid lsmDbSnapshotSetLevel(Snapshot *pSnap, Level *pLevel){\n  pSnap->pLevel = pLevel;\n}\n\n/* TODO: Shuffle things around to get rid of this */\nstatic int firstSnapshotInUse(lsm_db *, i64 *);\n\n/* \n** Context object used by the lsmWalkFreelist() utility. \n*/\ntypedef struct WalkFreelistCtx WalkFreelistCtx;\nstruct WalkFreelistCtx {\n  lsm_db *pDb;\n  int bReverse;\n  Freelist *pFreelist;\n  int iFree;\n  int (*xUsr)(void *, int, i64);  /* User callback function */\n  void *pUsrctx;                  /* User callback context */\n  int bDone;                      /* Set to true after xUsr() returns true */\n};\n\n/* \n** Callback used by lsmWalkFreelist().\n*/\nstatic int walkFreelistCb(void *pCtx, int iBlk, i64 iSnapshot){\n  WalkFreelistCtx *p = (WalkFreelistCtx *)pCtx;\n  const int iDir = (p->bReverse ? -1 : 1);\n  Freelist *pFree = p->pFreelist;\n\n  assert( p->bDone==0 );\n  assert( iBlk>=0 );\n  if( pFree ){\n    while( (p->iFree < pFree->nEntry) && p->iFree>=0 ){\n      FreelistEntry *pEntry = &pFree->aEntry[p->iFree];\n      if( (p->bReverse==0 && pEntry->iBlk>(u32)iBlk)\n       || (p->bReverse!=0 && pEntry->iBlk<(u32)iBlk)\n      ){\n        break;\n      }else{\n        p->iFree += iDir;\n        if( pEntry->iId>=0 \n            && p->xUsr(p->pUsrctx, pEntry->iBlk, pEntry->iId) \n          ){\n          p->bDone = 1;\n          return 1;\n        }\n        if( pEntry->iBlk==(u32)iBlk ) return 0;\n      }\n    }\n  }\n\n  if( p->xUsr(p->pUsrctx, iBlk, iSnapshot) ){\n    p->bDone = 1;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** The database handle passed as the first argument must be the worker\n** connection. This function iterates through the contents of the current\n** free block list, invoking the supplied callback once for each list\n** element.\n**\n** The difference between this function and lsmSortedWalkFreelist() is\n** that lsmSortedWalkFreelist() only considers those free-list elements\n** stored within the LSM. This function also merges in any in-memory \n** elements.\n*/\nint lsmWalkFreelist(\n  lsm_db *pDb,                    /* Database handle (must be worker) */\n  int bReverse,                   /* True to iterate from largest to smallest */\n  int (*x)(void *, int, i64),     /* Callback function */\n  void *pCtx                      /* First argument to pass to callback */\n){\n  const int iDir = (bReverse ? -1 : 1);\n  int rc;\n  int iCtx;\n\n  WalkFreelistCtx ctx[2];\n\n  ctx[0].pDb = pDb;\n  ctx[0].bReverse = bReverse;\n  ctx[0].pFreelist = &pDb->pWorker->freelist;\n  if( ctx[0].pFreelist && bReverse ){\n    ctx[0].iFree = ctx[0].pFreelist->nEntry-1;\n  }else{\n    ctx[0].iFree = 0;\n  }\n  ctx[0].xUsr = walkFreelistCb;\n  ctx[0].pUsrctx = (void *)&ctx[1];\n  ctx[0].bDone = 0;\n\n  ctx[1].pDb = pDb;\n  ctx[1].bReverse = bReverse;\n  ctx[1].pFreelist = pDb->pFreelist;\n  if( ctx[1].pFreelist && bReverse ){\n    ctx[1].iFree = ctx[1].pFreelist->nEntry-1;\n  }else{\n    ctx[1].iFree = 0;\n  }\n  ctx[1].xUsr = x;\n  ctx[1].pUsrctx = pCtx;\n  ctx[1].bDone = 0;\n\n  rc = lsmSortedWalkFreelist(pDb, bReverse, walkFreelistCb, (void *)&ctx[0]);\n\n  if( ctx[0].bDone==0 ){\n    for(iCtx=0; iCtx<2; iCtx++){\n      int i;\n      WalkFreelistCtx *p = &ctx[iCtx];\n      for(i=p->iFree; \n          p->pFreelist && rc==LSM_OK && i<p->pFreelist->nEntry && i>=0;\n          i += iDir\n         ){\n        FreelistEntry *pEntry = &p->pFreelist->aEntry[i];\n        if( pEntry->iId>=0 && p->xUsr(p->pUsrctx, pEntry->iBlk, pEntry->iId) ){\n          return LSM_OK;\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n\ntypedef struct FindFreeblockCtx FindFreeblockCtx;\nstruct FindFreeblockCtx {\n  i64 iInUse;\n  int iRet;\n  int bNotOne;\n};\n\nstatic int findFreeblockCb(void *pCtx, int iBlk, i64 iSnapshot){\n  FindFreeblockCtx *p = (FindFreeblockCtx *)pCtx;\n  if( iSnapshot<p->iInUse && (iBlk!=1 || p->bNotOne==0) ){\n    p->iRet = iBlk;\n    return 1;\n  }\n  return 0;\n}\n\nstatic int findFreeblock(lsm_db *pDb, i64 iInUse, int bNotOne, int *piRet){\n  int rc;                         /* Return code */\n  FindFreeblockCtx ctx;           /* Context object */\n\n  ctx.iInUse = iInUse;\n  ctx.iRet = 0;\n  ctx.bNotOne = bNotOne;\n  rc = lsmWalkFreelist(pDb, 0, findFreeblockCb, (void *)&ctx);\n  *piRet = ctx.iRet;\n\n  return rc;\n}\n\n/*\n** Allocate a new database file block to write data to, either by extending\n** the database file or by recycling a free-list entry. The worker snapshot \n** must be held in order to call this function.\n**\n** If successful, *piBlk is set to the block number allocated and LSM_OK is\n** returned. Otherwise, *piBlk is zeroed and an lsm error code returned.\n*/\nint lsmBlockAllocate(lsm_db *pDb, int iBefore, int *piBlk){\n  Snapshot *p = pDb->pWorker;\n  int iRet = 0;                   /* Block number of allocated block */\n  int rc = LSM_OK;\n  i64 iInUse = 0;                 /* Snapshot id still in use */\n  i64 iSynced = 0;                /* Snapshot id synced to disk */\n\n  assert( p );\n\n#ifdef LSM_LOG_FREELIST\n  {\n    static int nCall = 0;\n    char *zFree = 0;\n    nCall++;\n    rc = lsmInfoFreelist(pDb, &zFree);\n    if( rc!=LSM_OK ) return rc;\n    lsmLogMessage(pDb, 0, \"lsmBlockAllocate(): %d freelist: %s\", nCall, zFree);\n    lsmFree(pDb->pEnv, zFree);\n  }\n#endif\n\n  /* Set iInUse to the smallest snapshot id that is either:\n  **\n  **   * Currently in use by a database client,\n  **   * May be used by a database client in the future, or\n  **   * Is the most recently checkpointed snapshot (i.e. the one that will\n  **     be used following recovery if a failure occurs at this point).\n  */\n  rc = lsmCheckpointSynced(pDb, &iSynced, 0, 0);\n  if( rc==LSM_OK && iSynced==0 ) iSynced = p->iId;\n  iInUse = iSynced;\n  if( rc==LSM_OK && pDb->iReader>=0 ){\n    assert( pDb->pClient );\n    iInUse = LSM_MIN(iInUse, pDb->pClient->iId);\n  }\n  if( rc==LSM_OK ) rc = firstSnapshotInUse(pDb, &iInUse);\n\n#ifdef LSM_LOG_FREELIST\n  {\n    lsmLogMessage(pDb, 0, \"lsmBlockAllocate(): \"\n        \"snapshot-in-use: %lld (iSynced=%lld) (client-id=%lld)\", \n        iInUse, iSynced, (pDb->iReader>=0 ? pDb->pClient->iId : 0)\n    );\n  }\n#endif\n\n\n  /* Unless there exists a read-only transaction (which prevents us from\n  ** recycling any blocks regardless, query the free block list for a \n  ** suitable block to reuse. \n  **\n  ** It might seem more natural to check for a read-only transaction at\n  ** the start of this function. However, it is better do wait until after\n  ** the call to lsmCheckpointSynced() to do so.\n  */\n  if( rc==LSM_OK ){\n    int bRotrans;\n    rc = lsmDetectRoTrans(pDb, &bRotrans);\n\n    if( rc==LSM_OK && bRotrans==0 ){\n      rc = findFreeblock(pDb, iInUse, (iBefore>0), &iRet);\n    }\n  }\n\n  if( iBefore>0 && (iRet<=0 || iRet>=iBefore) ){\n    iRet = 0;\n\n  }else if( rc==LSM_OK ){\n    /* If a block was found in the free block list, use it and remove it from \n    ** the list. Otherwise, if no suitable block was found, allocate one from\n    ** the end of the file.  */\n    if( iRet>0 ){\n#ifdef LSM_LOG_FREELIST\n      lsmLogMessage(pDb, 0, \n          \"reusing block %d (snapshot-in-use=%lld)\", iRet, iInUse);\n#endif\n      rc = freelistAppend(pDb, iRet, -1);\n      if( rc==LSM_OK ){\n        rc = dbTruncate(pDb, iInUse);\n      }\n    }else{\n      iRet = ++(p->nBlock);\n#ifdef LSM_LOG_FREELIST\n      lsmLogMessage(pDb, 0, \"extending file to %d blocks\", iRet);\n#endif\n    }\n  }\n\n  assert( iBefore>0 || iRet>0 || rc!=LSM_OK );\n  *piBlk = iRet;\n  return rc;\n}\n\n/*\n** Free a database block. The worker snapshot must be held in order to call \n** this function.\n**\n** If successful, LSM_OK is returned. Otherwise, an lsm error code (e.g. \n** LSM_NOMEM).\n*/\nint lsmBlockFree(lsm_db *pDb, int iBlk){\n  Snapshot *p = pDb->pWorker;\n  assert( lsmShmAssertWorker(pDb) );\n\n#ifdef LSM_LOG_FREELIST\n  lsmLogMessage(pDb, LSM_OK, \"lsmBlockFree(): Free block %d\", iBlk);\n#endif\n\n  return freelistAppend(pDb, iBlk, p->iId);\n}\n\n/*\n** Refree a database block. The worker snapshot must be held in order to call \n** this function.\n**\n** Refreeing is required when a block is allocated using lsmBlockAllocate()\n** but then not used. This function is used to push the block back onto\n** the freelist. Refreeing a block is different from freeing is, as a refreed\n** block may be reused immediately. Whereas a freed block can not be reused \n** until (at least) after the next checkpoint.\n*/\nint lsmBlockRefree(lsm_db *pDb, int iBlk){\n  int rc = LSM_OK;                /* Return code */\n\n#ifdef LSM_LOG_FREELIST\n  lsmLogMessage(pDb, LSM_OK, \"lsmBlockRefree(): Refree block %d\", iBlk);\n#endif\n\n  rc = freelistAppend(pDb, iBlk, 0);\n  return rc;\n}\n\n/*\n** If required, copy a database checkpoint from shared memory into the\n** database itself.\n**\n** The WORKER lock must not be held when this is called. This is because\n** this function may indirectly call fsync(). And the WORKER lock should\n** not be held that long (in case it is required by a client flushing an\n** in-memory tree to disk).\n*/\nint lsmCheckpointWrite(lsm_db *pDb, u32 *pnWrite){\n  int rc;                         /* Return Code */\n  u32 nWrite = 0;\n\n  assert( pDb->pWorker==0 );\n  assert( 1 || pDb->pClient==0 );\n  assert( lsmShmAssertLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_UNLOCK) );\n\n  rc = lsmShmLock(pDb, LSM_LOCK_CHECKPOINTER, LSM_LOCK_EXCL, 0);\n  if( rc!=LSM_OK ) return rc;\n\n  rc = lsmCheckpointLoad(pDb, 0);\n  if( rc==LSM_OK ){\n    int nBlock = lsmCheckpointNBlock(pDb->aSnapshot);\n    ShmHeader *pShm = pDb->pShmhdr;\n    int bDone = 0;                /* True if checkpoint is already stored */\n\n    /* Check if this checkpoint has already been written to the database\n    ** file. If so, set variable bDone to true.  */\n    if( pShm->iMetaPage ){\n      MetaPage *pPg;              /* Meta page */\n      u8 *aData;                  /* Meta-page data buffer */\n      int nData;                  /* Size of aData[] in bytes */\n      i64 iCkpt;                  /* Id of checkpoint just loaded */\n      i64 iDisk = 0;              /* Id of checkpoint already stored in db */\n      iCkpt = lsmCheckpointId(pDb->aSnapshot, 0);\n      rc = lsmFsMetaPageGet(pDb->pFS, 0, pShm->iMetaPage, &pPg);\n      if( rc==LSM_OK ){\n        aData = lsmFsMetaPageData(pPg, &nData);\n        iDisk = lsmCheckpointId((u32 *)aData, 1);\n        nWrite = lsmCheckpointNWrite((u32 *)aData, 1);\n        lsmFsMetaPageRelease(pPg);\n      }\n      bDone = (iDisk>=iCkpt);\n    }\n\n    if( rc==LSM_OK && bDone==0 ){\n      int iMeta = (pShm->iMetaPage % 2) + 1;\n      if( pDb->eSafety!=LSM_SAFETY_OFF ){\n        rc = lsmFsSyncDb(pDb->pFS, nBlock);\n      }\n      if( rc==LSM_OK ) rc = lsmCheckpointStore(pDb, iMeta);\n      if( rc==LSM_OK && pDb->eSafety!=LSM_SAFETY_OFF){\n        rc = lsmFsSyncDb(pDb->pFS, 0);\n      }\n      if( rc==LSM_OK ){\n        pShm->iMetaPage = iMeta;\n        nWrite = lsmCheckpointNWrite(pDb->aSnapshot, 0) - nWrite;\n      }\n#ifdef LSM_LOG_WORK\n      lsmLogMessage(pDb, 0, \"finish checkpoint %d\", \n          (int)lsmCheckpointId(pDb->aSnapshot, 0)\n      );\n#endif\n    }\n  }\n\n  lsmShmLock(pDb, LSM_LOCK_CHECKPOINTER, LSM_LOCK_UNLOCK, 0);\n  if( pnWrite && rc==LSM_OK ) *pnWrite = nWrite;\n  return rc;\n}\n\nint lsmBeginWork(lsm_db *pDb){\n  int rc;\n\n  /* Attempt to take the WORKER lock */\n  rc = lsmShmLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_EXCL, 0);\n\n  /* Deserialize the current worker snapshot */\n  if( rc==LSM_OK ){\n    rc = lsmCheckpointLoadWorker(pDb);\n  }\n  return rc;\n}\n\nvoid lsmFreeSnapshot(lsm_env *pEnv, Snapshot *p){\n  if( p ){\n    lsmSortedFreeLevel(pEnv, p->pLevel);\n    lsmFree(pEnv, p->freelist.aEntry);\n    lsmFree(pEnv, p->redirect.a);\n    lsmFree(pEnv, p);\n  }\n}\n\n/*\n** Attempt to populate one of the read-lock slots to contain lock values\n** iLsm/iShm. Or, if such a slot exists already, this function is a no-op.\n**\n** It is not an error if no slot can be populated because the write-lock\n** cannot be obtained. If any other error occurs, return an LSM error code.\n** Otherwise, LSM_OK.\n**\n** This function is called at various points to try to ensure that there\n** always exists at least one read-lock slot that can be used by a read-only\n** client. And so that, in the usual case, there is an \"exact match\" available\n** whenever a read transaction is opened by any client. At present this\n** function is called when:\n**\n**    * A write transaction that called lsmTreeDiscardOld() is committed, and\n**    * Whenever the working snapshot is updated (i.e. lsmFinishWork()).\n*/\nstatic int dbSetReadLock(lsm_db *db, i64 iLsm, u32 iShm){\n  int rc = LSM_OK;\n  ShmHeader *pShm = db->pShmhdr;\n  int i;\n\n  /* Check if there is already a slot containing the required values. */\n  for(i=0; i<LSM_LOCK_NREADER; i++){\n    ShmReader *p = &pShm->aReader[i];\n    if( p->iLsmId==iLsm && p->iTreeId==iShm ) return LSM_OK;\n  }\n\n  /* Iterate through all read-lock slots, attempting to take a write-lock\n  ** on each of them. If a write-lock succeeds, populate the locked slot\n  ** with the required values and break out of the loop.  */\n  for(i=0; rc==LSM_OK && i<LSM_LOCK_NREADER; i++){\n    rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_EXCL, 0);\n    if( rc==LSM_BUSY ){\n      rc = LSM_OK;\n    }else{\n      ShmReader *p = &pShm->aReader[i];\n      p->iLsmId = iLsm;\n      p->iTreeId = iShm;\n      lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_UNLOCK, 0);\n      break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Release the read-lock currently held by connection db.\n*/\nint dbReleaseReadlock(lsm_db *db){\n  int rc = LSM_OK;\n  if( db->iReader>=0 ){\n    rc = lsmShmLock(db, LSM_LOCK_READER(db->iReader), LSM_LOCK_UNLOCK, 0);\n    db->iReader = -1;\n  }\n  db->bRoTrans = 0;\n  return rc;\n}\n\n\n/*\n** Argument bFlush is true if the contents of the in-memory tree has just\n** been flushed to disk. The significance of this is that once the snapshot\n** created to hold the updated state of the database is synced to disk, log\n** file space can be recycled.\n*/\nvoid lsmFinishWork(lsm_db *pDb, int bFlush, int *pRc){\n  int rc = *pRc;\n  assert( rc!=0 || pDb->pWorker );\n  if( pDb->pWorker ){\n    /* If no error has occurred, serialize the worker snapshot and write\n    ** it to shared memory.  */\n    if( rc==LSM_OK ){\n      rc = lsmSaveWorker(pDb, bFlush);\n    }\n\n    /* Assuming no error has occurred, update a read lock slot with the\n    ** new snapshot id (see comments above function dbSetReadLock()).  */\n    if( rc==LSM_OK ){\n      if( pDb->iReader<0 ){\n        rc = lsmTreeLoadHeader(pDb, 0);\n      }\n      if( rc==LSM_OK ){\n        rc = dbSetReadLock(pDb, pDb->pWorker->iId, pDb->treehdr.iUsedShmid);\n      }\n    }\n\n    /* Free the snapshot object. */\n    lsmFreeSnapshot(pDb->pEnv, pDb->pWorker);\n    pDb->pWorker = 0;\n  }\n\n  lsmShmLock(pDb, LSM_LOCK_WORKER, LSM_LOCK_UNLOCK, 0);\n  *pRc = rc;\n}\n\n/*\n** Called when recovery is finished.\n*/\nint lsmFinishRecovery(lsm_db *pDb){\n  lsmTreeEndTransaction(pDb, 1);\n  return LSM_OK;\n}\n\n/*\n** Check if the currently configured compression functions\n** (LSM_CONFIG_SET_COMPRESSION) are compatible with a database that has its\n** compression id set to iReq. Compression routines are compatible if iReq\n** is zero (indicating the database is empty), or if it is equal to the \n** compression id of the configured compression routines.\n**\n** If the check shows that the current compression are incompatible and there\n** is a compression factory registered, give it a chance to install new\n** compression routines.\n**\n** If, after any registered factory is invoked, the compression functions\n** are still incompatible, return LSM_MISMATCH. Otherwise, LSM_OK.\n*/\nint lsmCheckCompressionId(lsm_db *pDb, u32 iReq){\n  if( iReq!=LSM_COMPRESSION_EMPTY && pDb->compress.iId!=iReq ){\n    if( pDb->factory.xFactory ){\n      pDb->bInFactory = 1;\n      pDb->factory.xFactory(pDb->factory.pCtx, pDb, iReq);\n      pDb->bInFactory = 0;\n    }\n    if( pDb->compress.iId!=iReq ){\n      /* Incompatible */\n      return LSM_MISMATCH;\n    }\n  }\n  /* Compatible */\n  return LSM_OK;\n}\n\n/*\n** Begin a read transaction. This function is a no-op if the connection\n** passed as the only argument already has an open read transaction.\n*/\nint lsmBeginReadTrans(lsm_db *pDb){\n  const int MAX_READLOCK_ATTEMPTS = 10;\n  const int nMaxAttempt = (pDb->bRoTrans ? 1 : MAX_READLOCK_ATTEMPTS);\n\n  int rc = LSM_OK;                /* Return code */\n  int iAttempt = 0;\n\n  assert( pDb->pWorker==0 );\n\n  while( rc==LSM_OK && pDb->iReader<0 && (iAttempt++)<nMaxAttempt ){\n    int iTreehdr = 0;\n    int iSnap = 0;\n    assert( pDb->pCsr==0 && pDb->nTransOpen==0 );\n\n    /* Load the in-memory tree header. */\n    rc = lsmTreeLoadHeader(pDb, &iTreehdr);\n\n    /* Load the database snapshot */\n    if( rc==LSM_OK ){\n      if( lsmCheckpointClientCacheOk(pDb)==0 ){\n        lsmFreeSnapshot(pDb->pEnv, pDb->pClient);\n        pDb->pClient = 0;\n        lsmMCursorFreeCache(pDb);\n        lsmFsPurgeCache(pDb->pFS);\n        rc = lsmCheckpointLoad(pDb, &iSnap);\n      }else{\n        iSnap = 1;\n      }\n    }\n\n    /* Take a read-lock on the tree and snapshot just loaded. Then check\n    ** that the shared-memory still contains the same values. If so, proceed.\n    ** Otherwise, relinquish the read-lock and retry the whole procedure\n    ** (starting with loading the in-memory tree header).  */\n    if( rc==LSM_OK ){\n      u32 iShmMax = pDb->treehdr.iUsedShmid;\n      u32 iShmMin = pDb->treehdr.iNextShmid+1-LSM_MAX_SHMCHUNKS;\n      rc = lsmReadlock(\n          pDb, lsmCheckpointId(pDb->aSnapshot, 0), iShmMin, iShmMax\n      );\n      if( rc==LSM_OK ){\n        if( lsmTreeLoadHeaderOk(pDb, iTreehdr)\n         && lsmCheckpointLoadOk(pDb, iSnap)\n        ){\n          /* Read lock has been successfully obtained. Deserialize the \n          ** checkpoint just loaded. TODO: This will be removed after \n          ** lsm_sorted.c is changed to work directly from the serialized\n          ** version of the snapshot.  */\n          if( pDb->pClient==0 ){\n            rc = lsmCheckpointDeserialize(pDb, 0, pDb->aSnapshot,&pDb->pClient);\n          }\n          assert( (rc==LSM_OK)==(pDb->pClient!=0) );\n          assert( pDb->iReader>=0 );\n\n          /* Check that the client has the right compression hooks loaded.\n          ** If not, set rc to LSM_MISMATCH.  */\n          if( rc==LSM_OK ){\n            rc = lsmCheckCompressionId(pDb, pDb->pClient->iCmpId);\n          }\n        }else{\n          rc = dbReleaseReadlock(pDb);\n        }\n      }\n\n      if( rc==LSM_BUSY ){\n        rc = LSM_OK;\n      }\n    }\n#if 0\nif( rc==LSM_OK && pDb->pClient ){\n  fprintf(stderr, \n      \"reading %p: snapshot:%d used-shmid:%d trans-id:%d iOldShmid=%d\\n\",\n      (void *)pDb,\n      (int)pDb->pClient->iId, (int)pDb->treehdr.iUsedShmid, \n      (int)pDb->treehdr.root.iTransId,\n      (int)pDb->treehdr.iOldShmid\n  );\n}\n#endif\n  }\n\n  if( rc==LSM_OK ){\n    rc = lsmShmCacheChunks(pDb, pDb->treehdr.nChunk);\n  }\n  if( rc!=LSM_OK ){\n    dbReleaseReadlock(pDb);\n  }\n  if( pDb->pClient==0 && rc==LSM_OK ) rc = LSM_BUSY;\n  return rc;\n}\n\n/*\n** This function is used by a read-write connection to determine if there\n** are currently one or more read-only transactions open on the database\n** (in this context a read-only transaction is one opened by a read-only\n** connection on a non-live database).\n**\n** If no error occurs, LSM_OK is returned and *pbExists is set to true if\n** some other connection has a read-only transaction open, or false \n** otherwise. If an error occurs an LSM error code is returned and the final\n** value of *pbExist is undefined.\n*/\nint lsmDetectRoTrans(lsm_db *db, int *pbExist){\n  int rc;\n\n  /* Only a read-write connection may use this function. */\n  assert( db->bReadonly==0 );\n\n  rc = lsmShmTestLock(db, LSM_LOCK_ROTRANS, 1, LSM_LOCK_EXCL);\n  if( rc==LSM_BUSY ){\n    *pbExist = 1;\n    rc = LSM_OK;\n  }else{\n    *pbExist = 0;\n  }\n\n  return rc;\n}\n\n/*\n** db is a read-only database handle in the disconnected state. This function\n** attempts to open a read-transaction on the database. This may involve\n** connecting to the database system (opening shared memory etc.).\n*/\nint lsmBeginRoTrans(lsm_db *db){\n  int rc = LSM_OK;\n\n  assert( db->bReadonly && db->pShmhdr==0 );\n  assert( db->iReader<0 );\n\n  if( db->bRoTrans==0 ){\n\n    /* Attempt a shared-lock on DMS1. */\n    rc = lsmShmLock(db, LSM_LOCK_DMS1, LSM_LOCK_SHARED, 0);\n    if( rc!=LSM_OK ) return rc;\n\n    rc = lsmShmTestLock(\n        db, LSM_LOCK_RWCLIENT(0), LSM_LOCK_NREADER, LSM_LOCK_SHARED\n    );\n    if( rc==LSM_OK ){\n      /* System is not live. Take a SHARED lock on the ROTRANS byte and\n      ** release DMS1. Locking ROTRANS tells all read-write clients that they\n      ** may not recycle any disk space from within the database or log files,\n      ** as a read-only client may be using it.  */\n      rc = lsmShmLock(db, LSM_LOCK_ROTRANS, LSM_LOCK_SHARED, 0);\n      lsmShmLock(db, LSM_LOCK_DMS1, LSM_LOCK_UNLOCK, 0);\n\n      if( rc==LSM_OK ){\n        db->bRoTrans = 1;\n        rc = lsmShmCacheChunks(db, 1);\n        if( rc==LSM_OK ){\n          db->pShmhdr = (ShmHeader *)db->apShm[0];\n          memset(db->pShmhdr, 0, sizeof(ShmHeader));\n          rc = lsmCheckpointRecover(db);\n          if( rc==LSM_OK ){\n            rc = lsmLogRecover(db);\n          }\n        }\n      }\n    }else if( rc==LSM_BUSY ){\n      /* System is live! */\n      rc = lsmShmLock(db, LSM_LOCK_DMS3, LSM_LOCK_SHARED, 0);\n      lsmShmLock(db, LSM_LOCK_DMS1, LSM_LOCK_UNLOCK, 0);\n      if( rc==LSM_OK ){\n        rc = lsmShmCacheChunks(db, 1);\n        if( rc==LSM_OK ){\n          db->pShmhdr = (ShmHeader *)db->apShm[0];\n        }\n      }\n    }\n\n    if( rc==LSM_OK ){\n      rc = lsmBeginReadTrans(db);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Close the currently open read transaction.\n*/\nvoid lsmFinishReadTrans(lsm_db *pDb){\n\n  /* Worker connections should not be closing read transactions. And\n  ** read transactions should only be closed after all cursors and write\n  ** transactions have been closed. Finally pClient should be non-NULL\n  ** only iff pDb->iReader>=0.  */\n  assert( pDb->pWorker==0 );\n  assert( pDb->pCsr==0 && pDb->nTransOpen==0 );\n\n  if( pDb->bRoTrans ){\n    int i;\n    for(i=0; i<pDb->nShm; i++){\n      lsmFree(pDb->pEnv, pDb->apShm[i]);\n    }\n    lsmFree(pDb->pEnv, pDb->apShm);\n    pDb->apShm = 0;\n    pDb->nShm = 0;\n    pDb->pShmhdr = 0;\n\n    lsmShmLock(pDb, LSM_LOCK_ROTRANS, LSM_LOCK_UNLOCK, 0);\n  }\n  dbReleaseReadlock(pDb);\n}\n\n/*\n** Open a write transaction.\n*/\nint lsmBeginWriteTrans(lsm_db *pDb){\n  int rc = LSM_OK;                /* Return code */\n  ShmHeader *pShm = pDb->pShmhdr; /* Shared memory header */\n\n  assert( pDb->nTransOpen==0 );\n  assert( pDb->bDiscardOld==0 );\n  assert( pDb->bReadonly==0 );\n\n  /* If there is no read-transaction open, open one now. */\n  if( pDb->iReader<0 ){\n    rc = lsmBeginReadTrans(pDb);\n  }\n\n  /* Attempt to take the WRITER lock */\n  if( rc==LSM_OK ){\n    rc = lsmShmLock(pDb, LSM_LOCK_WRITER, LSM_LOCK_EXCL, 0);\n  }\n\n  /* If the previous writer failed mid-transaction, run emergency rollback. */\n  if( rc==LSM_OK && pShm->bWriter ){\n    rc = lsmTreeRepair(pDb);\n    if( rc==LSM_OK ) pShm->bWriter = 0;\n  }\n\n  /* Check that this connection is currently reading from the most recent\n  ** version of the database. If not, return LSM_BUSY.  */\n  if( rc==LSM_OK && memcmp(&pShm->hdr1, &pDb->treehdr, sizeof(TreeHeader)) ){\n    rc = LSM_BUSY;\n  }\n\n  if( rc==LSM_OK ){\n    rc = lsmLogBegin(pDb);\n  }\n\n  /* If everything was successful, set the \"transaction-in-progress\" flag\n  ** and return LSM_OK. Otherwise, if some error occurred, relinquish the \n  ** WRITER lock and return an error code.  */\n  if( rc==LSM_OK ){\n    TreeHeader *p = &pDb->treehdr;\n    pShm->bWriter = 1;\n    p->root.iTransId++;\n    if( lsmTreeHasOld(pDb) && p->iOldLog==pDb->pClient->iLogOff ){\n      lsmTreeDiscardOld(pDb);\n      pDb->bDiscardOld = 1;\n    }\n  }else{\n    lsmShmLock(pDb, LSM_LOCK_WRITER, LSM_LOCK_UNLOCK, 0);\n    if( pDb->pCsr==0 ) lsmFinishReadTrans(pDb);\n  }\n  return rc;\n}\n\n/*\n** End the current write transaction. The connection is left with an open\n** read transaction. It is an error to call this if there is no open write \n** transaction.\n**\n** If the transaction was committed, then a commit record has already been\n** written into the log file when this function is called. Or, if the\n** transaction was rolled back, both the log file and in-memory tree \n** structure have already been restored. In either case, this function \n** merely releases locks and other resources held by the write-transaction.\n**\n** LSM_OK is returned if successful, or an LSM error code otherwise.\n*/\nint lsmFinishWriteTrans(lsm_db *pDb, int bCommit){\n  int rc = LSM_OK;\n  int bFlush = 0;\n\n  lsmLogEnd(pDb, bCommit);\n  if( rc==LSM_OK && bCommit && lsmTreeSize(pDb)>pDb->nTreeLimit ){\n    bFlush = 1;\n    lsmTreeMakeOld(pDb);\n  }\n  lsmTreeEndTransaction(pDb, bCommit);\n\n  if( rc==LSM_OK ){\n    if( bFlush && pDb->bAutowork ){\n      rc = lsmSortedAutoWork(pDb, 1);\n    }else if( bCommit && pDb->bDiscardOld ){\n      rc = dbSetReadLock(pDb, pDb->pClient->iId, pDb->treehdr.iUsedShmid);\n    }\n  }\n  pDb->bDiscardOld = 0;\n  lsmShmLock(pDb, LSM_LOCK_WRITER, LSM_LOCK_UNLOCK, 0);\n\n  if( bFlush && pDb->bAutowork==0 && pDb->xWork ){\n    pDb->xWork(pDb, pDb->pWorkCtx);\n  }\n  return rc;\n}\n\n\n/*\n** Return non-zero if the caller is holding the client mutex.\n*/\n#ifdef LSM_DEBUG\nint lsmHoldingClientMutex(lsm_db *pDb){\n  return lsmMutexHeld(pDb->pEnv, pDb->pDatabase->pClientMutex);\n}\n#endif\n\nstatic int slotIsUsable(ShmReader *p, i64 iLsm, u32 iShmMin, u32 iShmMax){\n  return( \n      p->iLsmId && p->iLsmId<=iLsm \n      && shm_sequence_ge(iShmMax, p->iTreeId)\n      && shm_sequence_ge(p->iTreeId, iShmMin)\n  );\n}\n\n/*\n** Obtain a read-lock on database version identified by the combination\n** of snapshot iLsm and tree iTree. Return LSM_OK if successful, or\n** an LSM error code otherwise.\n*/\nint lsmReadlock(lsm_db *db, i64 iLsm, u32 iShmMin, u32 iShmMax){\n  int rc = LSM_OK;\n  ShmHeader *pShm = db->pShmhdr;\n  int i;\n\n  assert( db->iReader<0 );\n  assert( shm_sequence_ge(iShmMax, iShmMin) );\n\n  /* This is a no-op if the read-only transaction flag is set. */\n  if( db->bRoTrans ){\n    db->iReader = 0;\n    return LSM_OK;\n  }\n\n  /* Search for an exact match. */\n  for(i=0; db->iReader<0 && rc==LSM_OK && i<LSM_LOCK_NREADER; i++){\n    ShmReader *p = &pShm->aReader[i];\n    if( p->iLsmId==iLsm && p->iTreeId==iShmMax ){\n      rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_SHARED, 0);\n      if( rc==LSM_OK && p->iLsmId==iLsm && p->iTreeId==iShmMax ){\n        db->iReader = i;\n      }else if( rc==LSM_BUSY ){\n        rc = LSM_OK;\n      }\n    }\n  }\n\n  /* Try to obtain a write-lock on each slot, in order. If successful, set\n  ** the slot values to iLsm/iTree.  */\n  for(i=0; db->iReader<0 && rc==LSM_OK && i<LSM_LOCK_NREADER; i++){\n    rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_EXCL, 0);\n    if( rc==LSM_BUSY ){\n      rc = LSM_OK;\n    }else{\n      ShmReader *p = &pShm->aReader[i];\n      p->iLsmId = iLsm;\n      p->iTreeId = iShmMax;\n      rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_SHARED, 0);\n      assert( rc!=LSM_BUSY );\n      if( rc==LSM_OK ) db->iReader = i;\n    }\n  }\n\n  /* Search for any usable slot */\n  for(i=0; db->iReader<0 && rc==LSM_OK && i<LSM_LOCK_NREADER; i++){\n    ShmReader *p = &pShm->aReader[i];\n    if( slotIsUsable(p, iLsm, iShmMin, iShmMax) ){\n      rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_SHARED, 0);\n      if( rc==LSM_OK && slotIsUsable(p, iLsm, iShmMin, iShmMax) ){\n        db->iReader = i;\n      }else if( rc==LSM_BUSY ){\n        rc = LSM_OK;\n      }\n    }\n  }\n\n  if( rc==LSM_OK && db->iReader<0 ){\n    rc = LSM_BUSY;\n  }\n  return rc;\n}\n\n/*\n** This is used to check if there exists a read-lock locking a particular\n** version of either the in-memory tree or database file. \n**\n** If iLsmId is non-zero, then it is a snapshot id. If there exists a \n** read-lock using this snapshot or newer, set *pbInUse to true. Or,\n** if there is no such read-lock, set it to false.\n**\n** Or, if iLsmId is zero, then iShmid is a shared-memory sequence id.\n** Search for a read-lock using this sequence id or newer. etc.\n*/\nstatic int isInUse(lsm_db *db, i64 iLsmId, u32 iShmid, int *pbInUse){\n  ShmHeader *pShm = db->pShmhdr;\n  int i;\n  int rc = LSM_OK;\n\n  for(i=0; rc==LSM_OK && i<LSM_LOCK_NREADER; i++){\n    ShmReader *p = &pShm->aReader[i];\n    if( p->iLsmId ){\n      if( (iLsmId!=0 && p->iLsmId!=0 && iLsmId>=p->iLsmId) \n       || (iLsmId==0 && shm_sequence_ge(p->iTreeId, iShmid))\n      ){\n        rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_EXCL, 0);\n        if( rc==LSM_OK ){\n          p->iLsmId = 0;\n          lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_UNLOCK, 0);\n        }\n      }\n    }\n  }\n\n  if( rc==LSM_BUSY ){\n    *pbInUse = 1;\n    return LSM_OK;\n  }\n  *pbInUse = 0;\n  return rc;\n}\n\n/*\n** This function is called by worker connections to determine the smallest\n** snapshot id that is currently in use by a database client. The worker\n** connection uses this result to determine whether or not it is safe to\n** recycle a database block.\n*/\nstatic int firstSnapshotInUse(\n  lsm_db *db,                     /* Database handle */\n  i64 *piInUse                    /* IN/OUT: Smallest snapshot id in use */\n){\n  ShmHeader *pShm = db->pShmhdr;\n  i64 iInUse = *piInUse;\n  int i;\n\n  assert( iInUse>0 );\n  for(i=0; i<LSM_LOCK_NREADER; i++){\n    ShmReader *p = &pShm->aReader[i];\n    if( p->iLsmId ){\n      i64 iThis = p->iLsmId;\n      if( iThis!=0 && iInUse>iThis ){\n        int rc = lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_EXCL, 0);\n        if( rc==LSM_OK ){\n          p->iLsmId = 0;\n          lsmShmLock(db, LSM_LOCK_READER(i), LSM_LOCK_UNLOCK, 0);\n        }else if( rc==LSM_BUSY ){\n          iInUse = iThis;\n        }else{\n          /* Some error other than LSM_BUSY. Return the error code to\n          ** the caller in this case.  */\n          return rc;\n        }\n      }\n    }\n  }\n\n  *piInUse = iInUse;\n  return LSM_OK;\n}\n\nint lsmTreeInUse(lsm_db *db, u32 iShmid, int *pbInUse){\n  if( db->treehdr.iUsedShmid==iShmid ){\n    *pbInUse = 1;\n    return LSM_OK;\n  }\n  return isInUse(db, 0, iShmid, pbInUse);\n}\n\nint lsmLsmInUse(lsm_db *db, i64 iLsmId, int *pbInUse){\n  if( db->pClient && db->pClient->iId<=iLsmId ){\n    *pbInUse = 1;\n    return LSM_OK;\n  }\n  return isInUse(db, iLsmId, 0, pbInUse);\n}\n\n/*\n** This function may only be called after a successful call to\n** lsmDbDatabaseConnect(). It returns true if the connection is in\n** multi-process mode, or false otherwise.\n*/\nint lsmDbMultiProc(lsm_db *pDb){\n  return pDb->pDatabase && pDb->pDatabase->bMultiProc;\n}\n\n\n/*************************************************************************\n**************************************************************************\n**************************************************************************\n**************************************************************************\n**************************************************************************\n*************************************************************************/\n\n/*\n** Ensure that database connection db has cached pointers to at least the \n** first nChunk chunks of shared memory.\n*/\nint lsmShmCacheChunks(lsm_db *db, int nChunk){\n  int rc = LSM_OK;\n  if( nChunk>db->nShm ){\n    static const int NINCR = 16;\n    Database *p = db->pDatabase;\n    lsm_env *pEnv = db->pEnv;\n    int nAlloc;\n    int i;\n\n    /* Ensure that the db->apShm[] array is large enough. If an attempt to\n    ** allocate memory fails, return LSM_NOMEM immediately. The apShm[] array\n    ** is always extended in multiples of 16 entries - so the actual allocated\n    ** size can be inferred from nShm.  */ \n    nAlloc = ((db->nShm + NINCR - 1) / NINCR) * NINCR;\n    while( nChunk>=nAlloc ){\n      void **apShm;\n      nAlloc += NINCR;\n      apShm = lsmRealloc(pEnv, db->apShm, sizeof(void*)*nAlloc);\n      if( !apShm ) return LSM_NOMEM_BKPT;\n      db->apShm = apShm;\n    }\n\n    if( db->bRoTrans ){\n      for(i=db->nShm; rc==LSM_OK && i<nChunk; i++){\n        db->apShm[i] = lsmMallocZeroRc(pEnv, LSM_SHM_CHUNK_SIZE, &rc);\n        db->nShm++;\n      }\n\n    }else{\n\n      /* Enter the client mutex */\n      lsmMutexEnter(pEnv, p->pClientMutex);\n\n      /* Extend the Database objects apShmChunk[] array if necessary. Using the\n       ** same pattern as for the lsm_db.apShm[] array above.  */\n      nAlloc = ((p->nShmChunk + NINCR - 1) / NINCR) * NINCR;\n      while( nChunk>=nAlloc ){\n        void **apShm;\n        nAlloc +=  NINCR;\n        apShm = lsmRealloc(pEnv, p->apShmChunk, sizeof(void*)*nAlloc);\n        if( !apShm ){\n          rc = LSM_NOMEM_BKPT;\n          break;\n        }\n        p->apShmChunk = apShm;\n      }\n\n      for(i=db->nShm; rc==LSM_OK && i<nChunk; i++){\n        if( i>=p->nShmChunk ){\n          void *pChunk = 0;\n          if( p->bMultiProc==0 ){\n            /* Single process mode */\n            pChunk = lsmMallocZeroRc(pEnv, LSM_SHM_CHUNK_SIZE, &rc);\n          }else{\n            /* Multi-process mode */\n            rc = lsmEnvShmMap(pEnv, p->pFile, i, LSM_SHM_CHUNK_SIZE, &pChunk);\n          }\n          if( rc==LSM_OK ){\n            p->apShmChunk[i] = pChunk;\n            p->nShmChunk++;\n          }\n        }\n        if( rc==LSM_OK ){\n          db->apShm[i] = p->apShmChunk[i];\n          db->nShm++;\n        }\n      }\n\n      /* Release the client mutex */\n      lsmMutexLeave(pEnv, p->pClientMutex);\n    }\n  }\n\n  return rc;\n}\n\nstatic int lockSharedFile(lsm_env *pEnv, Database *p, int iLock, int eOp){\n  int rc = LSM_OK;\n  if( p->bMultiProc ){\n    rc = lsmEnvLock(pEnv, p->pFile, iLock, eOp);\n  }\n  return rc;\n}\n\n/*\n** Test if it would be possible for connection db to obtain a lock of type\n** eType on the nLock locks starting at iLock. If so, return LSM_OK. If it\n** would not be possible to obtain the lock due to a lock held by another\n** connection, return LSM_BUSY. If an IO or other error occurs (i.e. in the \n** lsm_env.xTestLock function), return some other LSM error code.\n**\n** Note that this function never actually locks the database - it merely\n** queries the system to see if there exists a lock that would prevent\n** it from doing so.\n*/\nint lsmShmTestLock(\n  lsm_db *db,\n  int iLock,\n  int nLock,\n  int eOp\n){\n  int rc = LSM_OK;\n  lsm_db *pIter;\n  Database *p = db->pDatabase;\n  int i;\n  u64 mask = 0;\n\n  for(i=iLock; i<(iLock+nLock); i++){\n    mask |= ((u64)1 << (iLock-1));\n    if( eOp==LSM_LOCK_EXCL ) mask |= ((u64)1 << (iLock+32-1));\n  }\n\n  lsmMutexEnter(db->pEnv, p->pClientMutex);\n  for(pIter=p->pConn; pIter; pIter=pIter->pNext){\n    if( pIter!=db && (pIter->mLock & mask) ){\n      assert( pIter!=db );\n      break;\n    }\n  }\n\n  if( pIter ){\n    rc = LSM_BUSY;\n  }else if( p->bMultiProc ){\n    rc = lsmEnvTestLock(db->pEnv, p->pFile, iLock, nLock, eOp);\n  }\n\n  lsmMutexLeave(db->pEnv, p->pClientMutex);\n  return rc;\n}\n\n/*\n** Attempt to obtain the lock identified by the iLock and bExcl parameters.\n** If successful, return LSM_OK. If the lock cannot be obtained because \n** there exists some other conflicting lock, return LSM_BUSY. If some other\n** error occurs, return an LSM error code.\n**\n** Parameter iLock must be one of LSM_LOCK_WRITER, WORKER or CHECKPOINTER,\n** or else a value returned by the LSM_LOCK_READER macro.\n*/\nint lsmShmLock(\n  lsm_db *db, \n  int iLock,\n  int eOp,                        /* One of LSM_LOCK_UNLOCK, SHARED or EXCL */\n  int bBlock                      /* True for a blocking lock */\n){\n  lsm_db *pIter;\n  const u64 me = ((u64)1 << (iLock-1));\n  const u64 ms = ((u64)1 << (iLock+32-1));\n  int rc = LSM_OK;\n  Database *p = db->pDatabase;\n\n  assert( eOp!=LSM_LOCK_EXCL || p->bReadonly==0 );\n  assert( iLock>=1 && iLock<=LSM_LOCK_RWCLIENT(LSM_LOCK_NRWCLIENT-1) );\n  assert( LSM_LOCK_RWCLIENT(LSM_LOCK_NRWCLIENT-1)<=32 );\n  assert( eOp==LSM_LOCK_UNLOCK || eOp==LSM_LOCK_SHARED || eOp==LSM_LOCK_EXCL );\n\n  /* Check for a no-op. Proceed only if this is not one of those. */\n  if( (eOp==LSM_LOCK_UNLOCK && (db->mLock & (me|ms))!=0)\n   || (eOp==LSM_LOCK_SHARED && (db->mLock & (me|ms))!=ms)\n   || (eOp==LSM_LOCK_EXCL   && (db->mLock & me)==0)\n  ){\n    int nExcl = 0;                /* Number of connections holding EXCLUSIVE */\n    int nShared = 0;              /* Number of connections holding SHARED */\n    lsmMutexEnter(db->pEnv, p->pClientMutex);\n\n    /* Figure out the locks currently held by this process on iLock, not\n    ** including any held by connection db.  */\n    for(pIter=p->pConn; pIter; pIter=pIter->pNext){\n      assert( (pIter->mLock & me)==0 || (pIter->mLock & ms)!=0 );\n      if( pIter!=db ){\n        if( pIter->mLock & me ){\n          nExcl++;\n        }else if( pIter->mLock & ms ){\n          nShared++;\n        }\n      }\n    }\n    assert( nExcl==0 || nExcl==1 );\n    assert( nExcl==0 || nShared==0 );\n    assert( nExcl==0 || (db->mLock & (me|ms))==0 );\n\n    switch( eOp ){\n      case LSM_LOCK_UNLOCK:\n        if( nShared==0 ){\n          lockSharedFile(db->pEnv, p, iLock, LSM_LOCK_UNLOCK);\n        }\n        db->mLock &= ~(me|ms);\n        break;\n\n      case LSM_LOCK_SHARED:\n        if( nExcl ){\n          rc = LSM_BUSY;\n        }else{\n          if( nShared==0 ){\n            rc = lockSharedFile(db->pEnv, p, iLock, LSM_LOCK_SHARED);\n          }\n          if( rc==LSM_OK ){\n            db->mLock |= ms;\n            db->mLock &= ~me;\n          }\n        }\n        break;\n\n      default:\n        assert( eOp==LSM_LOCK_EXCL );\n        if( nExcl || nShared ){\n          rc = LSM_BUSY;\n        }else{\n          rc = lockSharedFile(db->pEnv, p, iLock, LSM_LOCK_EXCL);\n          if( rc==LSM_OK ){\n            db->mLock |= (me|ms);\n          }\n        }\n        break;\n    }\n\n    lsmMutexLeave(db->pEnv, p->pClientMutex);\n  }\n\n  return rc;\n}\n\n#ifdef LSM_DEBUG\n\nint shmLockType(lsm_db *db, int iLock){\n  const u64 me = ((u64)1 << (iLock-1));\n  const u64 ms = ((u64)1 << (iLock+32-1));\n\n  if( db->mLock & me ) return LSM_LOCK_EXCL;\n  if( db->mLock & ms ) return LSM_LOCK_SHARED;\n  return LSM_LOCK_UNLOCK;\n}\n\n/*\n** The arguments passed to this function are similar to those passed to\n** the lsmShmLock() function. However, instead of obtaining a new lock \n** this function returns true if the specified connection already holds \n** (or does not hold) such a lock, depending on the value of eOp. As\n** follows:\n**\n**   (eOp==LSM_LOCK_UNLOCK) -> true if db has no lock on iLock\n**   (eOp==LSM_LOCK_SHARED) -> true if db has at least a SHARED lock on iLock.\n**   (eOp==LSM_LOCK_EXCL)   -> true if db has an EXCLUSIVE lock on iLock.\n*/\nint lsmShmAssertLock(lsm_db *db, int iLock, int eOp){\n  int ret = 0;\n  int eHave;\n\n  assert( iLock>=1 && iLock<=LSM_LOCK_READER(LSM_LOCK_NREADER-1) );\n  assert( iLock<=16 );\n  assert( eOp==LSM_LOCK_UNLOCK || eOp==LSM_LOCK_SHARED || eOp==LSM_LOCK_EXCL );\n\n  eHave = shmLockType(db, iLock);\n\n  switch( eOp ){\n    case LSM_LOCK_UNLOCK:\n      ret = (eHave==LSM_LOCK_UNLOCK);\n      break;\n    case LSM_LOCK_SHARED:\n      ret = (eHave!=LSM_LOCK_UNLOCK);\n      break;\n    case LSM_LOCK_EXCL:\n      ret = (eHave==LSM_LOCK_EXCL);\n      break;\n    default:\n      assert( !\"bad eOp value passed to lsmShmAssertLock()\" );\n      break;\n  }\n\n  return ret;\n}\n\nint lsmShmAssertWorker(lsm_db *db){\n  return lsmShmAssertLock(db, LSM_LOCK_WORKER, LSM_LOCK_EXCL) && db->pWorker;\n}\n\n/*\n** This function does not contribute to library functionality, and is not\n** included in release builds. It is intended to be called from within\n** an interactive debugger.\n**\n** When called, this function prints a single line of human readable output\n** to stdout describing the locks currently held by the connection. For \n** example:\n**\n**     (gdb) call print_db_locks(pDb)\n**     (shared on dms2) (exclusive on writer) \n*/\nvoid print_db_locks(lsm_db *db){\n  int iLock;\n  for(iLock=0; iLock<16; iLock++){\n    int bOne = 0;\n    const char *azLock[] = {0, \"shared\", \"exclusive\"};\n    const char *azName[] = {\n      0, \"dms1\", \"dms2\", \"writer\", \"worker\", \"checkpointer\",\n      \"reader0\", \"reader1\", \"reader2\", \"reader3\", \"reader4\", \"reader5\"\n    };\n    int eHave = shmLockType(db, iLock);\n    if( azLock[eHave] ){\n      printf(\"%s(%s on %s)\", (bOne?\" \":\"\"), azLock[eHave], azName[iLock]);\n      bOne = 1;\n    }\n  }\n  printf(\"\\n\");\n}\nvoid print_all_db_locks(lsm_db *db){\n  lsm_db *p;\n  for(p=db->pDatabase->pConn; p; p=p->pNext){\n    printf(\"%s connection %p \", ((p==db)?\"*\":\"\"), p);\n    print_db_locks(p);\n  }\n}\n#endif\n\nvoid lsmShmBarrier(lsm_db *db){\n  lsmEnvShmBarrier(db->pEnv);\n}\n\nint lsm_checkpoint(lsm_db *pDb, int *pnKB){\n  int rc;                         /* Return code */\n  u32 nWrite = 0;                 /* Number of pages checkpointed */\n\n  /* Attempt the checkpoint. If successful, nWrite is set to the number of\n  ** pages written between this and the previous checkpoint.  */\n  rc = lsmCheckpointWrite(pDb, &nWrite);\n\n  /* If required, calculate the output variable (KB of data checkpointed). \n  ** Set it to zero if an error occured.  */\n  if( pnKB ){\n    int nKB = 0;\n    if( rc==LSM_OK && nWrite ){\n      nKB = (((i64)nWrite * lsmFsPageSize(pDb->pFS)) + 1023) / 1024;\n    }\n    *pnKB = nKB;\n  }\n\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_sorted.c",
    "content": "/*\n** 2011-08-14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** PAGE FORMAT:\n**\n**   The maximum page size is 65536 bytes.\n**\n**   Since all records are equal to or larger than 2 bytes in size, and \n**   some space within the page is consumed by the page footer, there must\n**   be less than 2^15 records on each page.\n**\n**   Each page ends with a footer that describes the pages contents. This\n**   footer serves as similar purpose to the page header in an SQLite database.\n**   A footer is used instead of a header because it makes it easier to\n**   populate a new page based on a sorted list of key/value pairs.\n**\n**   The footer consists of the following values (starting at the end of\n**   the page and continuing backwards towards the start). All values are\n**   stored as unsigned big-endian integers.\n**\n**     * Number of records on page (2 bytes).\n**     * Flags field (2 bytes).\n**     * Left-hand pointer value (8 bytes).\n**     * The starting offset of each record (2 bytes per record).\n**\n**   Records may span pages. Unless it happens to be an exact fit, the part\n**   of the final record that starts on page X that does not fit on page X\n**   is stored at the start of page (X+1). This means there may be pages where\n**   (N==0). And on most pages the first record that starts on the page will\n**   not start at byte offset 0. For example:\n**\n**      aaaaa bbbbb ccc <footer>    cc eeeee fffff g <footer>    gggg....\n**\n** RECORD FORMAT:\n** \n**   The first byte of the record is a flags byte. It is a combination\n**   of the following flags (defined in lsmInt.h):\n**\n**       LSM_START_DELETE\n**       LSM_END_DELETE \n**       LSM_POINT_DELETE\n**       LSM_INSERT    \n**       LSM_SEPARATOR\n**       LSM_SYSTEMKEY\n**\n**   Immediately following the type byte is a pointer to the smallest key \n**   in the next file that is larger than the key in the current record. The \n**   pointer is encoded as a varint. When added to the 32-bit page number \n**   stored in the footer, it is the page number of the page that contains the\n**   smallest key in the next sorted file that is larger than this key. \n**\n**   Next is the number of bytes in the key, encoded as a varint.\n**\n**   If the LSM_INSERT flag is set, the number of bytes in the value, as\n**   a varint, is next.\n**\n**   Finally, the blob of data containing the key, and for LSM_INSERT\n**   records, the value as well.\n*/\n\n#ifndef _LSM_INT_H\n# include \"lsmInt.h\"\n#endif\n\n#define LSM_LOG_STRUCTURE 0\n#define LSM_LOG_DATA      0\n\n/*\n** Macros to help decode record types.\n*/\n#define rtTopic(eType)       ((eType) & LSM_SYSTEMKEY)\n#define rtIsDelete(eType)    (((eType) & 0x0F)==LSM_POINT_DELETE)\n\n#define rtIsSeparator(eType) (((eType) & LSM_SEPARATOR)!=0)\n#define rtIsWrite(eType)     (((eType) & LSM_INSERT)!=0)\n#define rtIsSystem(eType)    (((eType) & LSM_SYSTEMKEY)!=0)\n\n/*\n** The following macros are used to access a page footer.\n*/\n#define SEGMENT_NRECORD_OFFSET(pgsz)        ((pgsz) - 2)\n#define SEGMENT_FLAGS_OFFSET(pgsz)          ((pgsz) - 2 - 2)\n#define SEGMENT_POINTER_OFFSET(pgsz)        ((pgsz) - 2 - 2 - 8)\n#define SEGMENT_CELLPTR_OFFSET(pgsz, iCell) ((pgsz) - 2 - 2 - 8 - 2 - (iCell)*2)\n\n#define SEGMENT_EOF(pgsz, nEntry) SEGMENT_CELLPTR_OFFSET(pgsz, nEntry)\n\n#define SEGMENT_BTREE_FLAG     0x0001\n#define PGFTR_SKIP_NEXT_FLAG   0x0002\n#define PGFTR_SKIP_THIS_FLAG   0x0004\n\n\n#ifndef LSM_SEGMENTPTR_FREE_THRESHOLD\n# define LSM_SEGMENTPTR_FREE_THRESHOLD 1024\n#endif\n\ntypedef struct SegmentPtr SegmentPtr;\ntypedef struct Blob Blob;\n\nstruct Blob {\n  lsm_env *pEnv;\n  void *pData;\n  int nData;\n  int nAlloc;\n};\n\n/*\n** A SegmentPtr object may be used for one of two purposes:\n**\n**   * To iterate and/or seek within a single Segment (the combination of a \n**     main run and an optional sorted run).\n**\n**   * To iterate through the separators array of a segment.\n*/\nstruct SegmentPtr {\n  Level *pLevel;                /* Level object segment is part of */\n  Segment *pSeg;                /* Segment to access */\n\n  /* Current page. See segmentPtrLoadPage(). */\n  Page *pPg;                    /* Current page */\n  u16 flags;                    /* Copy of page flags field */\n  int nCell;                    /* Number of cells on pPg */\n  Pgno iPtr;                    /* Base cascade pointer */\n\n  /* Current cell. See segmentPtrLoadCell() */\n  int iCell;                    /* Current record within page pPg */\n  int eType;                    /* Type of current record */\n  Pgno iPgPtr;                  /* Cascade pointer offset */\n  void *pKey; int nKey;         /* Key associated with current record */\n  void *pVal; int nVal;         /* Current record value (eType==WRITE only) */\n\n  /* Blobs used to allocate buffers for pKey and pVal as required */\n  Blob blob1;\n  Blob blob2;\n};\n\n/*\n** Used to iterate through the keys stored in a b-tree hierarchy from start\n** to finish. Only First() and Next() operations are required.\n**\n**   btreeCursorNew()\n**   btreeCursorFirst()\n**   btreeCursorNext()\n**   btreeCursorFree()\n**   btreeCursorPosition()\n**   btreeCursorRestore()\n*/\ntypedef struct BtreePg BtreePg;\ntypedef struct BtreeCursor BtreeCursor;\nstruct BtreePg {\n  Page *pPage;\n  int iCell;\n};\nstruct BtreeCursor {\n  Segment *pSeg;                  /* Iterate through this segments btree */\n  FileSystem *pFS;                /* File system to read pages from */\n  int nDepth;                     /* Allocated size of aPg[] */\n  int iPg;                        /* Current entry in aPg[]. -1 -> EOF. */\n  BtreePg *aPg;                   /* Pages from root to current location */\n\n  /* Cache of current entry. pKey==0 for EOF. */\n  void *pKey;\n  int nKey;\n  int eType;\n  Pgno iPtr;\n\n  /* Storage for key, if not local */\n  Blob blob;\n};\n\n\n/*\n** A cursor used for merged searches or iterations through up to one\n** Tree structure and any number of sorted files.\n**\n**   lsmMCursorNew()\n**   lsmMCursorSeek()\n**   lsmMCursorNext()\n**   lsmMCursorPrev()\n**   lsmMCursorFirst()\n**   lsmMCursorLast()\n**   lsmMCursorKey()\n**   lsmMCursorValue()\n**   lsmMCursorValid()\n**\n** iFree:\n**   This variable is only used by cursors providing input data for a\n**   new top-level segment. Such cursors only ever iterate forwards, not\n**   backwards.\n*/\nstruct MultiCursor {\n  lsm_db *pDb;                    /* Connection that owns this cursor */\n  MultiCursor *pNext;             /* Next cursor owned by connection pDb */\n  int flags;                      /* Mask of CURSOR_XXX flags */\n\n  int eType;                      /* Cache of current key type */\n  Blob key;                       /* Cache of current key (or NULL) */\n  Blob val;                       /* Cache of current value */\n\n  /* All the component cursors: */\n  TreeCursor *apTreeCsr[2];       /* Up to two tree cursors */\n  int iFree;                      /* Next element of free-list (-ve for eof) */\n  SegmentPtr *aPtr;               /* Array of segment pointers */\n  int nPtr;                       /* Size of array aPtr[] */\n  BtreeCursor *pBtCsr;            /* b-tree cursor (db writes only) */\n\n  /* Comparison results */\n  int nTree;                      /* Size of aTree[] array */\n  int *aTree;                     /* Array of comparison results */\n\n  /* Used by cursors flushing the in-memory tree only */\n  void *pSystemVal;               /* Pointer to buffer to free */\n\n  /* Used by worker cursors only */\n  Pgno *pPrevMergePtr;\n};\n\n/*\n** The following constants are used to assign integers to each component\n** cursor of a multi-cursor.\n*/\n#define CURSOR_DATA_TREE0     0   /* Current tree cursor (apTreeCsr[0]) */\n#define CURSOR_DATA_TREE1     1   /* The \"old\" tree, if any (apTreeCsr[1]) */\n#define CURSOR_DATA_SYSTEM    2   /* Free-list entries (new-toplevel only) */\n#define CURSOR_DATA_SEGMENT   3   /* First segment pointer (aPtr[0]) */\n\n/*\n** CURSOR_IGNORE_DELETE\n**   If set, this cursor will not visit SORTED_DELETE keys.\n**\n** CURSOR_FLUSH_FREELIST\n**   This cursor is being used to create a new toplevel. It should also \n**   iterate through the contents of the in-memory free block list.\n**\n** CURSOR_IGNORE_SYSTEM\n**   If set, this cursor ignores system keys.\n**\n** CURSOR_NEXT_OK\n**   Set if it is Ok to call lsm_csr_next().\n**\n** CURSOR_PREV_OK\n**   Set if it is Ok to call lsm_csr_prev().\n**\n** CURSOR_READ_SEPARATORS\n**   Set if this cursor should visit the separator keys in segment \n**   aPtr[nPtr-1].\n**\n** CURSOR_SEEK_EQ\n**   Cursor has undergone a successful lsm_csr_seek(LSM_SEEK_EQ) operation.\n**   The key and value are stored in MultiCursor.key and MultiCursor.val\n**   respectively.\n*/\n#define CURSOR_IGNORE_DELETE    0x00000001\n#define CURSOR_FLUSH_FREELIST   0x00000002\n#define CURSOR_IGNORE_SYSTEM    0x00000010\n#define CURSOR_NEXT_OK          0x00000020\n#define CURSOR_PREV_OK          0x00000040\n#define CURSOR_READ_SEPARATORS  0x00000080\n#define CURSOR_SEEK_EQ          0x00000100\n\ntypedef struct MergeWorker MergeWorker;\ntypedef struct Hierarchy Hierarchy;\n\nstruct Hierarchy {\n  Page **apHier;\n  int nHier;\n};\n\n/*\n** aSave:\n**   When mergeWorkerNextPage() is called to advance to the next page in\n**   the output segment, if the bStore flag for an element of aSave[] is\n**   true, it is cleared and the corresponding iPgno value is set to the \n**   page number of the page just completed.\n**\n**   aSave[0] is used to record the pointer value to be pushed into the\n**   b-tree hierarchy. aSave[1] is used to save the page number of the\n**   page containing the indirect key most recently written to the b-tree.\n**   see mergeWorkerPushHierarchy() for details.\n*/\nstruct MergeWorker {\n  lsm_db *pDb;                    /* Database handle */\n  Level *pLevel;                  /* Worker snapshot Level being merged */\n  MultiCursor *pCsr;              /* Cursor to read new segment contents from */\n  int bFlush;                     /* True if this is an in-memory tree flush */\n  Hierarchy hier;                 /* B-tree hierarchy under construction */\n  Page *pPage;                    /* Current output page */\n  int nWork;                      /* Number of calls to mergeWorkerNextPage() */\n  Pgno *aGobble;                  /* Gobble point for each input segment */\n\n  Pgno iIndirect;\n  struct SavedPgno {\n    Pgno iPgno;\n    int bStore;\n  } aSave[2];\n};\n\n#ifdef LSM_DEBUG_EXPENSIVE\nstatic int assertPointersOk(lsm_db *, Segment *, Segment *, int);\nstatic int assertBtreeOk(lsm_db *, Segment *);\nstatic void assertRunInOrder(lsm_db *pDb, Segment *pSeg);\n#else\n#define assertRunInOrder(x,y)\n#define assertBtreeOk(x,y)\n#endif\n\n\nstruct FilePage { u8 *aData; int nData; };\nstatic u8 *fsPageData(Page *pPg, int *pnData){\n  *pnData = ((struct FilePage *)(pPg))->nData;\n  return ((struct FilePage *)(pPg))->aData;\n}\n/*UNUSED static u8 *fsPageDataPtr(Page *pPg){\n  return ((struct FilePage *)(pPg))->aData;\n}*/\n\n/*\n** Write nVal as a 16-bit unsigned big-endian integer into buffer aOut.\n*/\nvoid lsmPutU16(u8 *aOut, u16 nVal){\n  aOut[0] = (u8)((nVal>>8) & 0xFF);\n  aOut[1] = (u8)(nVal & 0xFF);\n}\n\nvoid lsmPutU32(u8 *aOut, u32 nVal){\n  aOut[0] = (u8)((nVal>>24) & 0xFF);\n  aOut[1] = (u8)((nVal>>16) & 0xFF);\n  aOut[2] = (u8)((nVal>> 8) & 0xFF);\n  aOut[3] = (u8)((nVal    ) & 0xFF);\n}\n\nint lsmGetU16(u8 *aOut){\n  return (aOut[0] << 8) + aOut[1];\n}\n\nu32 lsmGetU32(u8 *aOut){\n  return ((u32)aOut[0] << 24) \n       + ((u32)aOut[1] << 16) \n       + ((u32)aOut[2] << 8) \n       + ((u32)aOut[3]);\n}\n\nu64 lsmGetU64(u8 *aOut){\n  return ((u64)aOut[0] << 56) \n       + ((u64)aOut[1] << 48) \n       + ((u64)aOut[2] << 40) \n       + ((u64)aOut[3] << 32) \n       + ((u64)aOut[4] << 24)\n       + ((u32)aOut[5] << 16) \n       + ((u32)aOut[6] << 8) \n       + ((u32)aOut[7]);\n}\n\nvoid lsmPutU64(u8 *aOut, u64 nVal){\n  aOut[0] = (u8)((nVal>>56) & 0xFF);\n  aOut[1] = (u8)((nVal>>48) & 0xFF);\n  aOut[2] = (u8)((nVal>>40) & 0xFF);\n  aOut[3] = (u8)((nVal>>32) & 0xFF);\n  aOut[4] = (u8)((nVal>>24) & 0xFF);\n  aOut[5] = (u8)((nVal>>16) & 0xFF);\n  aOut[6] = (u8)((nVal>> 8) & 0xFF);\n  aOut[7] = (u8)((nVal    ) & 0xFF);\n}\n\nstatic int sortedBlobGrow(lsm_env *pEnv, Blob *pBlob, int nData){\n  assert( pBlob->pEnv==pEnv || (pBlob->pEnv==0 && pBlob->pData==0) );\n  if( pBlob->nAlloc<nData ){\n    pBlob->pData = lsmReallocOrFree(pEnv, pBlob->pData, nData);\n    if( !pBlob->pData ) return LSM_NOMEM_BKPT;\n    pBlob->nAlloc = nData;\n    pBlob->pEnv = pEnv;\n  }\n  return LSM_OK;\n}\n\nstatic int sortedBlobSet(lsm_env *pEnv, Blob *pBlob, void *pData, int nData){\n  if( sortedBlobGrow(pEnv, pBlob, nData) ) return LSM_NOMEM;\n  memcpy(pBlob->pData, pData, nData);\n  pBlob->nData = nData;\n  return LSM_OK;\n}\n\n#if 0\nstatic int sortedBlobCopy(Blob *pDest, Blob *pSrc){\n  return sortedBlobSet(pDest, pSrc->pData, pSrc->nData);\n}\n#endif\n\nstatic void sortedBlobFree(Blob *pBlob){\n  assert( pBlob->pEnv || pBlob->pData==0 );\n  if( pBlob->pData ) lsmFree(pBlob->pEnv, pBlob->pData);\n  memset(pBlob, 0, sizeof(Blob));\n}\n\nstatic int sortedReadData(\n  Segment *pSeg,\n  Page *pPg,\n  int iOff,\n  int nByte,\n  void **ppData,\n  Blob *pBlob\n){\n  int rc = LSM_OK;\n  int iEnd;\n  int nData;\n  int nCell;\n  u8 *aData;\n\n  aData = fsPageData(pPg, &nData);\n  nCell = lsmGetU16(&aData[SEGMENT_NRECORD_OFFSET(nData)]);\n  iEnd = SEGMENT_EOF(nData, nCell);\n  assert( iEnd>0 && iEnd<nData );\n\n  if( iOff+nByte<=iEnd ){\n    *ppData = (void *)&aData[iOff];\n  }else{\n    int nRem = nByte;\n    int i = iOff;\n    u8 *aDest;\n\n    /* Make sure the blob is big enough to store the value being loaded. */\n    rc = sortedBlobGrow(lsmPageEnv(pPg), pBlob, nByte);\n    if( rc!=LSM_OK ) return rc;\n    pBlob->nData = nByte;\n    aDest = (u8 *)pBlob->pData;\n    *ppData = pBlob->pData;\n\n    /* Increment the pointer pages ref-count. */\n    lsmFsPageRef(pPg);\n\n    while( rc==LSM_OK ){\n      Page *pNext;\n      int flags;\n\n      /* Copy data from pPg into the output buffer. */\n      int nCopy = LSM_MIN(nRem, iEnd-i);\n      if( nCopy>0 ){\n        memcpy(&aDest[nByte-nRem], &aData[i], nCopy);\n        nRem -= nCopy;\n        i += nCopy;\n        assert( nRem==0 || i==iEnd );\n      }\n      assert( nRem>=0 );\n      if( nRem==0 ) break;\n      i -= iEnd;\n\n      /* Grab the next page in the segment */\n\n      do {\n        rc = lsmFsDbPageNext(pSeg, pPg, 1, &pNext);\n        if( rc==LSM_OK && pNext==0 ){\n          rc = LSM_CORRUPT_BKPT;\n        }\n        if( rc ) break;\n        lsmFsPageRelease(pPg);\n        pPg = pNext;\n        aData = fsPageData(pPg, &nData);\n        flags = lsmGetU16(&aData[SEGMENT_FLAGS_OFFSET(nData)]);\n      }while( flags&SEGMENT_BTREE_FLAG );\n\n      iEnd = SEGMENT_EOF(nData, lsmGetU16(&aData[nData-2]));\n      assert( iEnd>0 && iEnd<nData );\n    }\n\n    lsmFsPageRelease(pPg);\n  }\n\n  return rc;\n}\n\nstatic int pageGetNRec(u8 *aData, int nData){\n  return (int)lsmGetU16(&aData[SEGMENT_NRECORD_OFFSET(nData)]);\n}\n\nstatic Pgno pageGetPtr(u8 *aData, int nData){\n  return (Pgno)lsmGetU64(&aData[SEGMENT_POINTER_OFFSET(nData)]);\n}\n\nstatic int pageGetFlags(u8 *aData, int nData){\n  return (int)lsmGetU16(&aData[SEGMENT_FLAGS_OFFSET(nData)]);\n}\n\nstatic u8 *pageGetCell(u8 *aData, int nData, int iCell){\n  return &aData[lsmGetU16(&aData[SEGMENT_CELLPTR_OFFSET(nData, iCell)])];\n}\n\n/*\n** Return the number of cells on page pPg.\n*/\nstatic int pageObjGetNRec(Page *pPg){\n  int nData;\n  u8 *aData = lsmFsPageData(pPg, &nData);\n  return pageGetNRec(aData, nData);\n}\n\n/*\n** Return the decoded (possibly relative) pointer value stored in cell \n** iCell from page aData/nData.\n*/\nstatic Pgno pageGetRecordPtr(u8 *aData, int nData, int iCell){\n  Pgno iRet;                      /* Return value */\n  u8 *aCell;                      /* Pointer to cell iCell */\n\n  assert( iCell<pageGetNRec(aData, nData) && iCell>=0 );\n  aCell = pageGetCell(aData, nData, iCell);\n  lsmVarintGet64(&aCell[1], &iRet);\n  return iRet;\n}\n\nstatic u8 *pageGetKey(\n  Segment *pSeg,                  /* Segment pPg belongs to */\n  Page *pPg,                      /* Page to read from */\n  int iCell,                      /* Index of cell on page to read */\n  int *piTopic,                   /* OUT: Topic associated with this key */\n  int *pnKey,                     /* OUT: Size of key in bytes */\n  Blob *pBlob                     /* If required, use this for dynamic memory */\n){\n  u8 *pKey;\n  int nDummy;\n  int eType;\n  u8 *aData;\n  int nData;\n\n  aData = fsPageData(pPg, &nData);\n\n  assert( !(pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG) );\n  assert( iCell<pageGetNRec(aData, nData) );\n\n  pKey = pageGetCell(aData, nData, iCell);\n  eType = *pKey++;\n  pKey += lsmVarintGet32(pKey, &nDummy);\n  pKey += lsmVarintGet32(pKey, pnKey);\n  if( rtIsWrite(eType) ){\n    pKey += lsmVarintGet32(pKey, &nDummy);\n  }\n  *piTopic = rtTopic(eType);\n\n  sortedReadData(pSeg, pPg, pKey-aData, *pnKey, (void **)&pKey, pBlob);\n  return pKey;\n}\n\nstatic int pageGetKeyCopy(\n  lsm_env *pEnv,                  /* Environment handle */\n  Segment *pSeg,                  /* Segment pPg belongs to */\n  Page *pPg,                      /* Page to read from */\n  int iCell,                      /* Index of cell on page to read */\n  int *piTopic,                   /* OUT: Topic associated with this key */\n  Blob *pBlob                     /* If required, use this for dynamic memory */\n){\n  int rc = LSM_OK;\n  int nKey;\n  u8 *aKey;\n\n  aKey = pageGetKey(pSeg, pPg, iCell, piTopic, &nKey, pBlob);\n  assert( (void *)aKey!=pBlob->pData || nKey==pBlob->nData );\n  if( (void *)aKey!=pBlob->pData ){\n    rc = sortedBlobSet(pEnv, pBlob, aKey, nKey);\n  }\n\n  return rc;\n}\n\nstatic Pgno pageGetBtreeRef(Page *pPg, int iKey){\n  Pgno iRef;\n  u8 *aData;\n  int nData;\n  u8 *aCell;\n\n  aData = fsPageData(pPg, &nData);\n  aCell = pageGetCell(aData, nData, iKey);\n  assert( aCell[0]==0 );\n  aCell++;\n  aCell += lsmVarintGet64(aCell, &iRef);\n  lsmVarintGet64(aCell, &iRef);\n  assert( iRef>0 );\n  return iRef;\n}\n\n#define GETVARINT64(a, i) (((i)=((u8*)(a))[0])<=240?1:lsmVarintGet64((a), &(i)))\n#define GETVARINT32(a, i) (((i)=((u8*)(a))[0])<=240?1:lsmVarintGet32((a), &(i)))\n\nstatic int pageGetBtreeKey(\n  Segment *pSeg,                  /* Segment page pPg belongs to */\n  Page *pPg,\n  int iKey, \n  Pgno *piPtr, \n  int *piTopic, \n  void **ppKey,\n  int *pnKey,\n  Blob *pBlob\n){\n  u8 *aData;\n  int nData;\n  u8 *aCell;\n  int eType;\n\n  aData = fsPageData(pPg, &nData);\n  assert( SEGMENT_BTREE_FLAG & pageGetFlags(aData, nData) );\n  assert( iKey>=0 && iKey<pageGetNRec(aData, nData) );\n\n  aCell = pageGetCell(aData, nData, iKey);\n  eType = *aCell++;\n  aCell += GETVARINT64(aCell, *piPtr);\n\n  if( eType==0 ){\n    int rc;\n    Pgno iRef;                  /* Page number of referenced page */\n    Page *pRef;\n    aCell += GETVARINT64(aCell, iRef);\n    rc = lsmFsDbPageGet(lsmPageFS(pPg), pSeg, iRef, &pRef);\n    if( rc!=LSM_OK ) return rc;\n    pageGetKeyCopy(lsmPageEnv(pPg), pSeg, pRef, 0, &eType, pBlob);\n    lsmFsPageRelease(pRef);\n    *ppKey = pBlob->pData;\n    *pnKey = pBlob->nData;\n  }else{\n    aCell += GETVARINT32(aCell, *pnKey);\n    *ppKey = aCell;\n  }\n  if( piTopic ) *piTopic = rtTopic(eType);\n\n  return LSM_OK;\n}\n\nstatic int btreeCursorLoadKey(BtreeCursor *pCsr){\n  int rc = LSM_OK;\n  if( pCsr->iPg<0 ){\n    pCsr->pKey = 0;\n    pCsr->nKey = 0;\n    pCsr->eType = 0;\n  }else{\n    Pgno dummy;\n    int iPg = pCsr->iPg;\n    int iCell = pCsr->aPg[iPg].iCell;\n    while( iCell<0 && (--iPg)>=0 ){\n      iCell = pCsr->aPg[iPg].iCell-1;\n    }\n    if( iPg<0 || iCell<0 ) return LSM_CORRUPT_BKPT;\n\n    rc = pageGetBtreeKey(\n        pCsr->pSeg,\n        pCsr->aPg[iPg].pPage, iCell,\n        &dummy, &pCsr->eType, &pCsr->pKey, &pCsr->nKey, &pCsr->blob\n    );\n    pCsr->eType |= LSM_SEPARATOR;\n  }\n\n  return rc;\n}\n\nstatic int btreeCursorPtr(u8 *aData, int nData, int iCell){\n  int nCell;\n\n  nCell = pageGetNRec(aData, nData);\n  if( iCell>=nCell ){\n    return (int)pageGetPtr(aData, nData);\n  }\n  return (int)pageGetRecordPtr(aData, nData, iCell);\n}\n\nstatic int btreeCursorNext(BtreeCursor *pCsr){\n  int rc = LSM_OK;\n\n  BtreePg *pPg = &pCsr->aPg[pCsr->iPg];\n  int nCell; \n  u8 *aData;\n  int nData;\n\n  assert( pCsr->iPg>=0 );\n  assert( pCsr->iPg==pCsr->nDepth-1 );\n\n  aData = fsPageData(pPg->pPage, &nData);\n  nCell = pageGetNRec(aData, nData);\n  assert( pPg->iCell<=nCell );\n  pPg->iCell++;\n  if( pPg->iCell==nCell ){\n    Pgno iLoad;\n\n    /* Up to parent. */\n    lsmFsPageRelease(pPg->pPage);\n    pPg->pPage = 0;\n    pCsr->iPg--;\n    while( pCsr->iPg>=0 ){\n      pPg = &pCsr->aPg[pCsr->iPg];\n      aData = fsPageData(pPg->pPage, &nData);\n      if( pPg->iCell<pageGetNRec(aData, nData) ) break;\n      lsmFsPageRelease(pPg->pPage);\n      pCsr->iPg--;\n    }\n\n    /* Read the key */\n    rc = btreeCursorLoadKey(pCsr);\n\n    /* Unless the cursor is at EOF, descend to cell -1 (yes, negative one) of \n    ** the left-most most descendent. */\n    if( pCsr->iPg>=0 ){\n      pCsr->aPg[pCsr->iPg].iCell++;\n\n      iLoad = btreeCursorPtr(aData, nData, pPg->iCell);\n      do {\n        Page *pLoad;\n        pCsr->iPg++;\n        rc = lsmFsDbPageGet(pCsr->pFS, pCsr->pSeg, iLoad, &pLoad);\n        pCsr->aPg[pCsr->iPg].pPage = pLoad;\n        pCsr->aPg[pCsr->iPg].iCell = 0;\n        if( rc==LSM_OK ){\n          if( pCsr->iPg==(pCsr->nDepth-1) ) break;\n          aData = fsPageData(pLoad, &nData);\n          iLoad = btreeCursorPtr(aData, nData, 0);\n        }\n      }while( rc==LSM_OK && pCsr->iPg<(pCsr->nDepth-1) );\n      pCsr->aPg[pCsr->iPg].iCell = -1;\n    }\n\n  }else{\n    rc = btreeCursorLoadKey(pCsr);\n  }\n\n  if( rc==LSM_OK && pCsr->iPg>=0 ){\n    aData = fsPageData(pCsr->aPg[pCsr->iPg].pPage, &nData);\n    pCsr->iPtr = btreeCursorPtr(aData, nData, pCsr->aPg[pCsr->iPg].iCell+1);\n  }\n\n  return rc;\n}\n\nstatic void btreeCursorFree(BtreeCursor *pCsr){\n  if( pCsr ){\n    int i;\n    lsm_env *pEnv = lsmFsEnv(pCsr->pFS);\n    for(i=0; i<=pCsr->iPg; i++){\n      lsmFsPageRelease(pCsr->aPg[i].pPage);\n    }\n    sortedBlobFree(&pCsr->blob);\n    lsmFree(pEnv, pCsr->aPg);\n    lsmFree(pEnv, pCsr);\n  }\n}\n\nstatic int btreeCursorFirst(BtreeCursor *pCsr){\n  int rc;\n\n  Page *pPg = 0;\n  FileSystem *pFS = pCsr->pFS;\n  int iPg = (int)pCsr->pSeg->iRoot;\n\n  do {\n    rc = lsmFsDbPageGet(pFS, pCsr->pSeg, iPg, &pPg);\n    assert( (rc==LSM_OK)==(pPg!=0) );\n    if( rc==LSM_OK ){\n      u8 *aData;\n      int nData;\n      int flags;\n\n      aData = fsPageData(pPg, &nData);\n      flags = pageGetFlags(aData, nData);\n      if( (flags & SEGMENT_BTREE_FLAG)==0 ) break;\n\n      if( (pCsr->nDepth % 8)==0 ){\n        int nNew = pCsr->nDepth + 8;\n        pCsr->aPg = (BtreePg *)lsmReallocOrFreeRc(\n            lsmFsEnv(pFS), pCsr->aPg, sizeof(BtreePg) * nNew, &rc\n        );\n        if( rc==LSM_OK ){\n          memset(&pCsr->aPg[pCsr->nDepth], 0, sizeof(BtreePg) * 8);\n        }\n      }\n\n      if( rc==LSM_OK ){\n        assert( pCsr->aPg[pCsr->nDepth].iCell==0 );\n        pCsr->aPg[pCsr->nDepth].pPage = pPg;\n        pCsr->nDepth++;\n        iPg = (int)pageGetRecordPtr(aData, nData, 0);\n      }\n    }\n  }while( rc==LSM_OK );\n  lsmFsPageRelease(pPg);\n  pCsr->iPg = pCsr->nDepth-1;\n\n  if( rc==LSM_OK && pCsr->nDepth ){\n    pCsr->aPg[pCsr->iPg].iCell = -1;\n    rc = btreeCursorNext(pCsr);\n  }\n\n  return rc;\n}\n\nstatic void btreeCursorPosition(BtreeCursor *pCsr, MergeInput *p){\n  if( pCsr->iPg>=0 ){\n    p->iPg = lsmFsPageNumber(pCsr->aPg[pCsr->iPg].pPage);\n    p->iCell = ((pCsr->aPg[pCsr->iPg].iCell + 1) << 8) + pCsr->nDepth;\n  }else{\n    p->iPg = 0;\n    p->iCell = 0;\n  }\n}\n\nstatic void btreeCursorSplitkey(BtreeCursor *pCsr, MergeInput *p){\n  int iCell = pCsr->aPg[pCsr->iPg].iCell;\n  if( iCell>=0 ){\n    p->iCell = iCell;\n    p->iPg = lsmFsPageNumber(pCsr->aPg[pCsr->iPg].pPage);\n  }else{\n    int i;\n    for(i=pCsr->iPg-1; i>=0; i--){\n      if( pCsr->aPg[i].iCell>0 ) break;\n    }\n    assert( i>=0 );\n    p->iCell = pCsr->aPg[i].iCell-1;\n    p->iPg = lsmFsPageNumber(pCsr->aPg[i].pPage);\n  }\n}\n\nstatic int sortedKeyCompare(\n  int (*xCmp)(void *, int, void *, int),\n  int iLhsTopic, void *pLhsKey, int nLhsKey,\n  int iRhsTopic, void *pRhsKey, int nRhsKey\n){\n  int res = iLhsTopic - iRhsTopic;\n  if( res==0 ){\n    res = xCmp(pLhsKey, nLhsKey, pRhsKey, nRhsKey);\n  }\n  return res;\n}\n\nstatic int btreeCursorRestore(\n  BtreeCursor *pCsr, \n  int (*xCmp)(void *, int, void *, int),\n  MergeInput *p\n){\n  int rc = LSM_OK;\n\n  if( p->iPg ){\n    lsm_env *pEnv = lsmFsEnv(pCsr->pFS);\n    int iCell;                    /* Current cell number on leaf page */\n    Pgno iLeaf;                   /* Page number of current leaf page */\n    int nDepth;                   /* Depth of b-tree structure */\n    Segment *pSeg = pCsr->pSeg;\n\n    /* Decode the MergeInput structure */\n    iLeaf = p->iPg;\n    nDepth = (p->iCell & 0x00FF);\n    iCell = (p->iCell >> 8) - 1;\n\n    /* Allocate the BtreeCursor.aPg[] array */\n    assert( pCsr->aPg==0 );\n    pCsr->aPg = (BtreePg *)lsmMallocZeroRc(pEnv, sizeof(BtreePg) * nDepth, &rc);\n\n    /* Populate the last entry of the aPg[] array */\n    if( rc==LSM_OK ){\n      Page **pp = &pCsr->aPg[nDepth-1].pPage;\n      pCsr->iPg = nDepth-1;\n      pCsr->nDepth = nDepth;\n      pCsr->aPg[pCsr->iPg].iCell = iCell;\n      rc = lsmFsDbPageGet(pCsr->pFS, pSeg, iLeaf, pp);\n    }\n\n    /* Populate any other aPg[] array entries */\n    if( rc==LSM_OK && nDepth>1 ){\n      Blob blob = {0,0,0};\n      void *pSeek;\n      int nSeek;\n      int iTopicSeek;\n      int iPg = 0;\n      int iLoad = (int)pSeg->iRoot;\n      Page *pPg = pCsr->aPg[nDepth-1].pPage;\n \n      if( pageObjGetNRec(pPg)==0 ){\n        /* This can happen when pPg is the right-most leaf in the b-tree.\n        ** In this case, set the iTopicSeek/pSeek/nSeek key to a value\n        ** greater than any real key.  */\n        assert( iCell==-1 );\n        iTopicSeek = 1000;\n        pSeek = 0;\n        nSeek = 0;\n      }else{\n        Pgno dummy;\n        rc = pageGetBtreeKey(pSeg, pPg,\n            0, &dummy, &iTopicSeek, &pSeek, &nSeek, &pCsr->blob\n        );\n      }\n\n      do {\n        Page *pPg2;\n        rc = lsmFsDbPageGet(pCsr->pFS, pSeg, iLoad, &pPg2);\n        assert( rc==LSM_OK || pPg2==0 );\n        if( rc==LSM_OK ){\n          u8 *aData;                  /* Buffer containing page data */\n          int nData;                  /* Size of aData[] in bytes */\n          int iMin;\n          int iMax;\n          int iCell2;\n\n          aData = fsPageData(pPg2, &nData);\n          assert( (pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG) );\n\n          iLoad = (int)pageGetPtr(aData, nData);\n          iCell2 = pageGetNRec(aData, nData); \n          iMax = iCell2-1;\n          iMin = 0;\n\n          while( iMax>=iMin ){\n            int iTry = (iMin+iMax)/2;\n            void *pKey; int nKey;         /* Key for cell iTry */\n            int iTopic;                   /* Topic for key pKeyT/nKeyT */\n            Pgno iPtr;                    /* Pointer for cell iTry */\n            int res;                      /* (pSeek - pKeyT) */\n\n            rc = pageGetBtreeKey(\n                pSeg, pPg2, iTry, &iPtr, &iTopic, &pKey, &nKey, &blob\n            );\n            if( rc!=LSM_OK ) break;\n\n            res = sortedKeyCompare(\n                xCmp, iTopicSeek, pSeek, nSeek, iTopic, pKey, nKey\n            );\n            assert( res!=0 );\n\n            if( res<0 ){\n              iLoad = (int)iPtr;\n              iCell2 = iTry;\n              iMax = iTry-1;\n            }else{\n              iMin = iTry+1;\n            }\n          }\n\n          pCsr->aPg[iPg].pPage = pPg2;\n          pCsr->aPg[iPg].iCell = iCell2;\n          iPg++;\n          assert( iPg!=nDepth-1 \n               || lsmFsRedirectPage(pCsr->pFS, pSeg->pRedirect, iLoad)==iLeaf\n          );\n        }\n      }while( rc==LSM_OK && iPg<(nDepth-1) );\n      sortedBlobFree(&blob);\n    }\n\n    /* Load the current key and pointer */\n    if( rc==LSM_OK ){\n      BtreePg *pBtreePg;\n      u8 *aData;\n      int nData;\n\n      pBtreePg = &pCsr->aPg[pCsr->iPg];\n      aData = fsPageData(pBtreePg->pPage, &nData);\n      pCsr->iPtr = btreeCursorPtr(aData, nData, pBtreePg->iCell+1);\n      if( pBtreePg->iCell<0 ){\n        Pgno dummy;\n        int i;\n        for(i=pCsr->iPg-1; i>=0; i--){\n          if( pCsr->aPg[i].iCell>0 ) break;\n        }\n        assert( i>=0 );\n        rc = pageGetBtreeKey(pSeg,\n            pCsr->aPg[i].pPage, pCsr->aPg[i].iCell-1,\n            &dummy, &pCsr->eType, &pCsr->pKey, &pCsr->nKey, &pCsr->blob\n        );\n        pCsr->eType |= LSM_SEPARATOR;\n\n      }else{\n        rc = btreeCursorLoadKey(pCsr);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int btreeCursorNew(\n  lsm_db *pDb,\n  Segment *pSeg,\n  BtreeCursor **ppCsr\n){\n  int rc = LSM_OK;\n  BtreeCursor *pCsr;\n  \n  assert( pSeg->iRoot );\n  pCsr = lsmMallocZeroRc(pDb->pEnv, sizeof(BtreeCursor), &rc);\n  if( pCsr ){\n    pCsr->pFS = pDb->pFS;\n    pCsr->pSeg = pSeg;\n    pCsr->iPg = -1;\n  }\n\n  *ppCsr = pCsr;\n  return rc;\n}\n\nstatic void segmentPtrSetPage(SegmentPtr *pPtr, Page *pNext){\n  lsmFsPageRelease(pPtr->pPg);\n  if( pNext ){\n    int nData;\n    u8 *aData = fsPageData(pNext, &nData);\n    pPtr->nCell = pageGetNRec(aData, nData);\n    pPtr->flags = (u16)pageGetFlags(aData, nData);\n    pPtr->iPtr = pageGetPtr(aData, nData);\n  }\n  pPtr->pPg = pNext;\n}\n\n/*\n** Load a new page into the SegmentPtr object pPtr.\n*/\nstatic int segmentPtrLoadPage(\n  FileSystem *pFS,\n  SegmentPtr *pPtr,              /* Load page into this SegmentPtr object */\n  int iNew                       /* Page number of new page */\n){\n  Page *pPg = 0;                 /* The new page */\n  int rc;                        /* Return Code */\n\n  rc = lsmFsDbPageGet(pFS, pPtr->pSeg, iNew, &pPg);\n  assert( rc==LSM_OK || pPg==0 );\n  segmentPtrSetPage(pPtr, pPg);\n\n  return rc;\n}\n\nstatic int segmentPtrReadData(\n  SegmentPtr *pPtr,\n  int iOff,\n  int nByte,\n  void **ppData,\n  Blob *pBlob\n){\n  return sortedReadData(pPtr->pSeg, pPtr->pPg, iOff, nByte, ppData, pBlob);\n}\n\nstatic int segmentPtrNextPage(\n  SegmentPtr *pPtr,              /* Load page into this SegmentPtr object */\n  int eDir                       /* +1 for next(), -1 for prev() */\n){\n  Page *pNext;                   /* New page to load */\n  int rc;                        /* Return code */\n\n  assert( eDir==1 || eDir==-1 );\n  assert( pPtr->pPg );\n  assert( pPtr->pSeg || eDir>0 );\n\n  rc = lsmFsDbPageNext(pPtr->pSeg, pPtr->pPg, eDir, &pNext);\n  assert( rc==LSM_OK || pNext==0 );\n  segmentPtrSetPage(pPtr, pNext);\n  return rc;\n}\n\nstatic int segmentPtrLoadCell(\n  SegmentPtr *pPtr,              /* Load page into this SegmentPtr object */\n  int iNew                       /* Cell number of new cell */\n){\n  int rc = LSM_OK;\n  if( pPtr->pPg ){\n    u8 *aData;                    /* Pointer to page data buffer */\n    int iOff;                     /* Offset in aData[] to read from */\n    int nPgsz;                    /* Size of page (aData[]) in bytes */\n\n    assert( iNew<pPtr->nCell );\n    pPtr->iCell = iNew;\n    aData = fsPageData(pPtr->pPg, &nPgsz);\n    iOff = lsmGetU16(&aData[SEGMENT_CELLPTR_OFFSET(nPgsz, pPtr->iCell)]);\n    pPtr->eType = aData[iOff];\n    iOff++;\n    iOff += GETVARINT64(&aData[iOff], pPtr->iPgPtr);\n    iOff += GETVARINT32(&aData[iOff], pPtr->nKey);\n    if( rtIsWrite(pPtr->eType) ){\n      iOff += GETVARINT32(&aData[iOff], pPtr->nVal);\n    }\n    assert( pPtr->nKey>=0 );\n\n    rc = segmentPtrReadData(\n        pPtr, iOff, pPtr->nKey, &pPtr->pKey, &pPtr->blob1\n    );\n    if( rc==LSM_OK && rtIsWrite(pPtr->eType) ){\n      rc = segmentPtrReadData(\n          pPtr, iOff+pPtr->nKey, pPtr->nVal, &pPtr->pVal, &pPtr->blob2\n      );\n    }else{\n      pPtr->nVal = 0;\n      pPtr->pVal = 0;\n    }\n  }\n\n  return rc;\n}\n\n\nstatic Segment *sortedSplitkeySegment(Level *pLevel){\n  Merge *pMerge = pLevel->pMerge;\n  MergeInput *p = &pMerge->splitkey;\n  Segment *pSeg;\n  int i;\n\n  for(i=0; i<pMerge->nInput; i++){\n    if( p->iPg==pMerge->aInput[i].iPg ) break;\n  }\n  if( pMerge->nInput==(pLevel->nRight+1) && i>=(pMerge->nInput-1) ){\n    pSeg = &pLevel->pNext->lhs;\n  }else{\n    pSeg = &pLevel->aRhs[i];\n  }\n\n  return pSeg;\n}\n\nstatic void sortedSplitkey(lsm_db *pDb, Level *pLevel, int *pRc){\n  Segment *pSeg;\n  Page *pPg = 0;\n  lsm_env *pEnv = pDb->pEnv;      /* Environment handle */\n  int rc = *pRc;\n  Merge *pMerge = pLevel->pMerge;\n\n  pSeg = sortedSplitkeySegment(pLevel);\n  if( rc==LSM_OK ){\n    rc = lsmFsDbPageGet(pDb->pFS, pSeg, pMerge->splitkey.iPg, &pPg);\n  }\n  if( rc==LSM_OK ){\n    int iTopic;\n    Blob blob = {0, 0, 0, 0};\n    u8 *aData;\n    int nData;\n  \n    aData = lsmFsPageData(pPg, &nData);\n    if( pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG ){\n      void *pKey;\n      int nKey;\n      Pgno dummy;\n      rc = pageGetBtreeKey(pSeg,\n          pPg, pMerge->splitkey.iCell, &dummy, &iTopic, &pKey, &nKey, &blob\n      );\n      if( rc==LSM_OK && blob.pData!=pKey ){\n        rc = sortedBlobSet(pEnv, &blob, pKey, nKey);\n      }\n    }else{\n      rc = pageGetKeyCopy(\n          pEnv, pSeg, pPg, pMerge->splitkey.iCell, &iTopic, &blob\n      );\n    }\n\n    pLevel->iSplitTopic = iTopic;\n    pLevel->pSplitKey = blob.pData;\n    pLevel->nSplitKey = blob.nData;\n    lsmFsPageRelease(pPg);\n  }\n\n  *pRc = rc;\n}\n\n/*\n** Reset a segment cursor. Also free its buffers if they are nThreshold\n** bytes or larger in size.\n*/\nstatic void segmentPtrReset(SegmentPtr *pPtr, int nThreshold){\n  lsmFsPageRelease(pPtr->pPg);\n  pPtr->pPg = 0;\n  pPtr->nCell = 0;\n  pPtr->pKey = 0;\n  pPtr->nKey = 0;\n  pPtr->pVal = 0;\n  pPtr->nVal = 0;\n  pPtr->eType = 0;\n  pPtr->iCell = 0;\n  if( pPtr->blob1.nAlloc>=nThreshold ) sortedBlobFree(&pPtr->blob1);\n  if( pPtr->blob2.nAlloc>=nThreshold ) sortedBlobFree(&pPtr->blob2);\n}\n\nstatic int segmentPtrIgnoreSeparators(MultiCursor *pCsr, SegmentPtr *pPtr){\n  return (pCsr->flags & CURSOR_READ_SEPARATORS)==0\n      || (pPtr!=&pCsr->aPtr[pCsr->nPtr-1]);\n}\n\nstatic int segmentPtrAdvance(\n  MultiCursor *pCsr, \n  SegmentPtr *pPtr,\n  int bReverse\n){\n  int eDir = (bReverse ? -1 : 1);\n  Level *pLvl = pPtr->pLevel;\n  do {\n    int rc;\n    int iCell;                    /* Number of new cell in page */\n    int svFlags = 0;              /* SegmentPtr.eType before advance */\n\n    iCell = pPtr->iCell + eDir;\n    assert( pPtr->pPg );\n    assert( iCell<=pPtr->nCell && iCell>=-1 );\n\n    if( bReverse && pPtr->pSeg!=&pPtr->pLevel->lhs ){\n      svFlags = pPtr->eType;\n      assert( svFlags );\n    }\n\n    if( iCell>=pPtr->nCell || iCell<0 ){\n      do {\n        rc = segmentPtrNextPage(pPtr, eDir); \n      }while( rc==LSM_OK \n           && pPtr->pPg \n           && (pPtr->nCell==0 || (pPtr->flags & SEGMENT_BTREE_FLAG) ) \n      );\n      if( rc!=LSM_OK ) return rc;\n      iCell = bReverse ? (pPtr->nCell-1) : 0;\n    }\n    rc = segmentPtrLoadCell(pPtr, iCell);\n    if( rc!=LSM_OK ) return rc;\n\n    if( svFlags && pPtr->pPg ){\n      int res = sortedKeyCompare(pCsr->pDb->xCmp,\n          rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey,\n          pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey\n      );\n      if( res<0 ) segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n    }\n\n    if( pPtr->pPg==0 && (svFlags & LSM_END_DELETE) ){\n      Segment *pSeg = pPtr->pSeg;\n      rc = lsmFsDbPageGet(pCsr->pDb->pFS, pSeg, pSeg->iFirst, &pPtr->pPg);\n      if( rc!=LSM_OK ) return rc;\n      pPtr->eType = LSM_START_DELETE | LSM_POINT_DELETE;\n      pPtr->eType |= (pLvl->iSplitTopic ? LSM_SYSTEMKEY : 0);\n      pPtr->pKey = pLvl->pSplitKey;\n      pPtr->nKey = pLvl->nSplitKey;\n    }\n\n  }while( pCsr \n       && pPtr->pPg \n       && segmentPtrIgnoreSeparators(pCsr, pPtr)\n       && rtIsSeparator(pPtr->eType)\n  );\n\n  return LSM_OK;\n}\n\nstatic void segmentPtrEndPage(\n  FileSystem *pFS, \n  SegmentPtr *pPtr, \n  int bLast, \n  int *pRc\n){\n  if( *pRc==LSM_OK ){\n    Segment *pSeg = pPtr->pSeg;\n    Page *pNew = 0;\n    if( bLast ){\n      *pRc = lsmFsDbPageLast(pFS, pSeg, &pNew);\n    }else{\n      *pRc = lsmFsDbPageGet(pFS, pSeg, pSeg->iFirst, &pNew);\n    }\n    segmentPtrSetPage(pPtr, pNew);\n  }\n}\n\n\n/*\n** Try to move the segment pointer passed as the second argument so that it\n** points at either the first (bLast==0) or last (bLast==1) cell in the valid\n** region of the segment defined by pPtr->iFirst and pPtr->iLast.\n**\n** Return LSM_OK if successful or an lsm error code if something goes\n** wrong (IO error, OOM etc.).\n*/\nstatic int segmentPtrEnd(MultiCursor *pCsr, SegmentPtr *pPtr, int bLast){\n  Level *pLvl = pPtr->pLevel;\n  int rc = LSM_OK;\n  FileSystem *pFS = pCsr->pDb->pFS;\n  int bIgnore;\n\n  segmentPtrEndPage(pFS, pPtr, bLast, &rc);\n  while( rc==LSM_OK && pPtr->pPg \n      && (pPtr->nCell==0 || (pPtr->flags & SEGMENT_BTREE_FLAG))\n  ){\n    rc = segmentPtrNextPage(pPtr, (bLast ? -1 : 1));\n  }\n\n  if( rc==LSM_OK && pPtr->pPg ){\n    rc = segmentPtrLoadCell(pPtr, bLast ? (pPtr->nCell-1) : 0);\n    if( rc==LSM_OK && bLast && pPtr->pSeg!=&pLvl->lhs ){\n      int res = sortedKeyCompare(pCsr->pDb->xCmp,\n          rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey,\n          pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey\n      );\n      if( res<0 ) segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n    }\n  }\n  \n  bIgnore = segmentPtrIgnoreSeparators(pCsr, pPtr);\n  if( rc==LSM_OK && pPtr->pPg && bIgnore && rtIsSeparator(pPtr->eType) ){\n    rc = segmentPtrAdvance(pCsr, pPtr, bLast);\n  }\n\n#if 0\n  if( bLast && rc==LSM_OK && pPtr->pPg\n   && pPtr->pSeg==&pLvl->lhs \n   && pLvl->nRight && (pPtr->eType & LSM_START_DELETE)\n  ){\n    pPtr->iCell++;\n    pPtr->eType = LSM_END_DELETE | (pLvl->iSplitTopic);\n    pPtr->pKey = pLvl->pSplitKey;\n    pPtr->nKey = pLvl->nSplitKey;\n    pPtr->pVal = 0;\n    pPtr->nVal = 0;\n  }\n#endif\n\n  return rc;\n}\n\nstatic void segmentPtrKey(SegmentPtr *pPtr, void **ppKey, int *pnKey){\n  assert( pPtr->pPg );\n  *ppKey = pPtr->pKey;\n  *pnKey = pPtr->nKey;\n}\n\n#if 0 /* NOT USED */\nstatic char *keyToString(lsm_env *pEnv, void *pKey, int nKey){\n  int i;\n  u8 *aKey = (u8 *)pKey;\n  char *zRet = (char *)lsmMalloc(pEnv, nKey+1);\n\n  for(i=0; i<nKey; i++){\n    zRet[i] = (char)(isalnum(aKey[i]) ? aKey[i] : '.');\n  }\n  zRet[nKey] = '\\0';\n  return zRet;\n}\n#endif\n\n#if 0 /* NOT USED */\n/*\n** Check that the page that pPtr currently has loaded is the correct page\n** to search for key (pKey/nKey). If it is, return 1. Otherwise, an assert\n** fails and this function does not return.\n*/\nstatic int assertKeyLocation(\n  MultiCursor *pCsr, \n  SegmentPtr *pPtr, \n  void *pKey, int nKey\n){\n  lsm_env *pEnv = lsmFsEnv(pCsr->pDb->pFS);\n  Blob blob = {0, 0, 0};\n  int eDir;\n  int iTopic = 0;                 /* TODO: Fix me */\n\n  for(eDir=-1; eDir<=1; eDir+=2){\n    Page *pTest = pPtr->pPg;\n\n    lsmFsPageRef(pTest);\n    while( pTest ){\n      Segment *pSeg = pPtr->pSeg;\n      Page *pNext;\n\n      int rc = lsmFsDbPageNext(pSeg, pTest, eDir, &pNext);\n      lsmFsPageRelease(pTest);\n      if( rc ) return 1;\n      pTest = pNext;\n\n      if( pTest ){\n        int nData;\n        u8 *aData = fsPageData(pTest, &nData);\n        int nCell = pageGetNRec(aData, nData);\n        int flags = pageGetFlags(aData, nData);\n        if( nCell && 0==(flags&SEGMENT_BTREE_FLAG) ){\n          int nPgKey;\n          int iPgTopic;\n          u8 *pPgKey;\n          int res;\n          int iCell;\n\n          iCell = ((eDir < 0) ? (nCell-1) : 0);\n          pPgKey = pageGetKey(pSeg, pTest, iCell, &iPgTopic, &nPgKey, &blob);\n          res = iTopic - iPgTopic;\n          if( res==0 ) res = pCsr->pDb->xCmp(pKey, nKey, pPgKey, nPgKey);\n          if( (eDir==1 && res>0) || (eDir==-1 && res<0) ){\n            /* Taking this branch means something has gone wrong. */\n            char *zMsg = lsmMallocPrintf(pEnv, \"Key \\\"%s\\\" is not on page %d\", \n                keyToString(pEnv, pKey, nKey), lsmFsPageNumber(pPtr->pPg)\n            );\n            fprintf(stderr, \"%s\\n\", zMsg);\n            assert( !\"assertKeyLocation() failed\" );\n          }\n          lsmFsPageRelease(pTest);\n          pTest = 0;\n        }\n      }\n    }\n  }\n\n  sortedBlobFree(&blob);\n  return 1;\n}\n#endif\n\n#ifndef NDEBUG\nstatic int assertSeekResult(\n  MultiCursor *pCsr,\n  SegmentPtr *pPtr,\n  int iTopic,\n  void *pKey,\n  int nKey,\n  int eSeek\n){\n  if( pPtr->pPg ){\n    int res;\n    res = sortedKeyCompare(pCsr->pDb->xCmp, iTopic, pKey, nKey,\n        rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey\n    );\n\n    if( eSeek==LSM_SEEK_EQ ) return (res==0);\n    if( eSeek==LSM_SEEK_LE ) return (res>=0);\n    if( eSeek==LSM_SEEK_GE ) return (res<=0);\n  }\n\n  return 1;\n}\n#endif\n\nstatic int segmentPtrSearchOversized(\n  MultiCursor *pCsr,              /* Cursor context */\n  SegmentPtr *pPtr,               /* Pointer to seek */\n  int iTopic,                     /* Topic of key to search for */\n  void *pKey, int nKey            /* Key to seek to */\n){\n  int (*xCmp)(void *, int, void *, int) = pCsr->pDb->xCmp;\n  int rc = LSM_OK;\n\n  /* If the OVERSIZED flag is set, then there is no pointer in the\n  ** upper level to the next page in the segment that contains at least\n  ** one key. So compare the largest key on the current page with the\n  ** key being sought (pKey/nKey). If (pKey/nKey) is larger, advance\n  ** to the next page in the segment that contains at least one key. \n  */\n  while( rc==LSM_OK && (pPtr->flags & PGFTR_SKIP_NEXT_FLAG) ){\n    u8 *pLastKey;\n    int nLastKey;\n    int iLastTopic;\n    int res;                      /* Result of comparison */\n    Page *pNext;\n\n    /* Load the last key on the current page. */\n    pLastKey = pageGetKey(pPtr->pSeg,\n        pPtr->pPg, pPtr->nCell-1, &iLastTopic, &nLastKey, &pPtr->blob1\n    );\n\n    /* If the loaded key is >= than (pKey/nKey), break out of the loop.\n    ** If (pKey/nKey) is present in this array, it must be on the current \n    ** page.  */\n    res = sortedKeyCompare(\n        xCmp, iLastTopic, pLastKey, nLastKey, iTopic, pKey, nKey\n    );\n    if( res>=0 ) break;\n\n    /* Advance to the next page that contains at least one key. */\n    pNext = pPtr->pPg;\n    lsmFsPageRef(pNext);\n    while( 1 ){\n      Page *pLoad;\n      u8 *aData; int nData;\n\n      rc = lsmFsDbPageNext(pPtr->pSeg, pNext, 1, &pLoad);\n      lsmFsPageRelease(pNext);\n      pNext = pLoad;\n      if( pNext==0 ) break;\n\n      assert( rc==LSM_OK );\n      aData = lsmFsPageData(pNext, &nData);\n      if( (pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG)==0\n       && pageGetNRec(aData, nData)>0\n      ){\n        break;\n      }\n    }\n    if( pNext==0 ) break;\n    segmentPtrSetPage(pPtr, pNext);\n\n    /* This should probably be an LSM_CORRUPT error. */\n    assert( rc!=LSM_OK || (pPtr->flags & PGFTR_SKIP_THIS_FLAG) );\n  }\n\n  return rc;\n}\n\nstatic int ptrFwdPointer(\n  Page *pPage,\n  int iCell,\n  Segment *pSeg,\n  Pgno *piPtr,\n  int *pbFound\n){\n  Page *pPg = pPage;\n  int iFirst = iCell;\n  int rc = LSM_OK;\n\n  do {\n    Page *pNext = 0;\n    u8 *aData;\n    int nData;\n\n    aData = lsmFsPageData(pPg, &nData);\n    if( (pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG)==0 ){\n      int i;\n      int nCell = pageGetNRec(aData, nData);\n      for(i=iFirst; i<nCell; i++){\n        u8 eType = *pageGetCell(aData, nData, i);\n        if( (eType & LSM_START_DELETE)==0 ){\n          *pbFound = 1;\n          *piPtr = pageGetRecordPtr(aData, nData, i) + pageGetPtr(aData, nData);\n          lsmFsPageRelease(pPg);\n          return LSM_OK;\n        }\n      }\n    }\n\n    rc = lsmFsDbPageNext(pSeg, pPg, 1, &pNext);\n    lsmFsPageRelease(pPg);\n    pPg = pNext;\n    iFirst = 0;\n  }while( pPg && rc==LSM_OK );\n  lsmFsPageRelease(pPg);\n\n  *pbFound = 0;\n  return rc;\n}\n\nstatic int sortedRhsFirst(MultiCursor *pCsr, Level *pLvl, SegmentPtr *pPtr){\n  int rc;\n  rc = segmentPtrEnd(pCsr, pPtr, 0);\n  while( pPtr->pPg && rc==LSM_OK ){\n    int res = sortedKeyCompare(pCsr->pDb->xCmp,\n        pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey,\n        rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey\n    );\n    if( res<=0 ) break;\n    rc = segmentPtrAdvance(pCsr, pPtr, 0);\n  }\n  return rc;\n}\n\n\n/*\n** This function is called as part of a SEEK_GE op on a multi-cursor if the \n** FC pointer read from segment *pPtr comes from an entry with the \n** LSM_START_DELETE flag set. In this case the pointer value cannot be \n** trusted. Instead, the pointer that should be followed is that associated\n** with the next entry in *pPtr that does not have LSM_START_DELETE set.\n**\n** Why the pointers can't be trusted:\n**\n**\n**\n** TODO: This is a stop-gap solution:\n** \n**   At the moment, this function is called from within segmentPtrSeek(), \n**   as part of the initial lsmMCursorSeek() call. However, consider a \n**   database where the following has occurred:\n**\n**      1. A range delete removes keys 1..9999 using a range delete.\n**      2. Keys 1 through 9999 are reinserted.\n**      3. The levels containing the ops in 1. and 2. above are merged. Call\n**         this level N. Level N contains FC pointers to level N+1.\n**\n**   Then, if the user attempts to query for (key>=2 LIMIT 10), the \n**   lsmMCursorSeek() call will iterate through 9998 entries searching for a \n**   pointer down to the level N+1 that is never actually used. It would be\n**   much better if the multi-cursor could do this lazily - only seek to the\n**   level (N+1) page after the user has moved the cursor on level N passed\n**   the big range-delete.\n*/\nstatic int segmentPtrFwdPointer(\n  MultiCursor *pCsr,              /* Multi-cursor pPtr belongs to */\n  SegmentPtr *pPtr,               /* Segment-pointer to extract FC ptr from */\n  Pgno *piPtr                     /* OUT: FC pointer value */\n){\n  Level *pLvl = pPtr->pLevel;\n  Level *pNext = pLvl->pNext;\n  Page *pPg = pPtr->pPg;\n  int rc;\n  int bFound;\n  Pgno iOut = 0;\n\n  if( pPtr->pSeg==&pLvl->lhs || pPtr->pSeg==&pLvl->aRhs[pLvl->nRight-1] ){\n    if( pNext==0 \n        || (pNext->nRight==0 && pNext->lhs.iRoot)\n        || (pNext->nRight!=0 && pNext->aRhs[0].iRoot)\n      ){\n      /* Do nothing. The pointer will not be used anyway. */\n      return LSM_OK;\n    }\n  }else{\n    if( pPtr[1].pSeg->iRoot ){\n      return LSM_OK;\n    }\n  }\n\n  /* Search for a pointer within the current segment. */\n  lsmFsPageRef(pPg);\n  rc = ptrFwdPointer(pPg, pPtr->iCell, pPtr->pSeg, &iOut, &bFound);\n\n  if( rc==LSM_OK && bFound==0 ){\n    /* This case happens when pPtr points to the left-hand-side of a segment\n    ** currently undergoing an incremental merge. In this case, jump to the\n    ** oldest segment in the right-hand-side of the same level and continue\n    ** searching. But - do not consider any keys smaller than the levels\n    ** split-key. */\n    SegmentPtr ptr;\n\n    if( pPtr->pLevel->nRight==0 || pPtr->pSeg!=&pPtr->pLevel->lhs ){\n      return LSM_CORRUPT_BKPT;\n    }\n\n    memset(&ptr, 0, sizeof(SegmentPtr));\n    ptr.pLevel = pPtr->pLevel;\n    ptr.pSeg = &ptr.pLevel->aRhs[ptr.pLevel->nRight-1];\n    rc = sortedRhsFirst(pCsr, ptr.pLevel, &ptr);\n    if( rc==LSM_OK ){\n      rc = ptrFwdPointer(ptr.pPg, ptr.iCell, ptr.pSeg, &iOut, &bFound);\n      ptr.pPg = 0;\n    }\n    segmentPtrReset(&ptr, 0);\n  }\n\n  *piPtr = iOut;\n  return rc;\n}\n\nstatic int segmentPtrSeek(\n  MultiCursor *pCsr,              /* Cursor context */\n  SegmentPtr *pPtr,               /* Pointer to seek */\n  int iTopic,                     /* Key topic to seek to */\n  void *pKey, int nKey,           /* Key to seek to */\n  int eSeek,                      /* Search bias - see above */\n  int *piPtr,                     /* OUT: FC pointer */\n  int *pbStop\n){\n  int (*xCmp)(void *, int, void *, int) = pCsr->pDb->xCmp;\n  int res = 0;                        /* Result of comparison operation */\n  int rc = LSM_OK;\n  int iMin;\n  int iMax;\n  Pgno iPtrOut = 0;\n\n  /* If the current page contains an oversized entry, then there are no\n  ** pointers to one or more of the subsequent pages in the sorted run.\n  ** The following call ensures that the segment-ptr points to the correct \n  ** page in this case.  */\n  rc = segmentPtrSearchOversized(pCsr, pPtr, iTopic, pKey, nKey);\n  iPtrOut = pPtr->iPtr;\n\n  /* Assert that this page is the right page of this segment for the key\n  ** that we are searching for. Do this by loading page (iPg-1) and testing\n  ** that pKey/nKey is greater than all keys on that page, and then by \n  ** loading (iPg+1) and testing that pKey/nKey is smaller than all\n  ** the keys it houses.  \n  **\n  ** TODO: With range-deletes in the tree, the test described above may fail.\n  */\n#if 0\n  assert( assertKeyLocation(pCsr, pPtr, pKey, nKey) );\n#endif\n\n  assert( pPtr->nCell>0 \n       || pPtr->pSeg->nSize==1 \n       || lsmFsDbPageIsLast(pPtr->pSeg, pPtr->pPg)\n  );\n  if( pPtr->nCell==0 ){\n    segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n  }else{\n    iMin = 0;\n    iMax = pPtr->nCell-1;\n\n    while( 1 ){\n      int iTry = (iMin+iMax)/2;\n      void *pKeyT; int nKeyT;       /* Key for cell iTry */\n      int iTopicT;\n\n      assert( iTry<iMax || iMin==iMax );\n\n      rc = segmentPtrLoadCell(pPtr, iTry);\n      if( rc!=LSM_OK ) break;\n\n      segmentPtrKey(pPtr, &pKeyT, &nKeyT);\n      iTopicT = rtTopic(pPtr->eType);\n\n      res = sortedKeyCompare(xCmp, iTopicT, pKeyT, nKeyT, iTopic, pKey, nKey);\n      if( res<=0 ){\n        iPtrOut = pPtr->iPtr + pPtr->iPgPtr;\n      }\n\n      if( res==0 || iMin==iMax ){\n        break;\n      }else if( res>0 ){\n        iMax = LSM_MAX(iTry-1, iMin);\n      }else{\n        iMin = iTry+1;\n      }\n    }\n\n    if( rc==LSM_OK ){\n      assert( res==0 || (iMin==iMax && iMin>=0 && iMin<pPtr->nCell) );\n      if( res ){\n        rc = segmentPtrLoadCell(pPtr, iMin);\n      }\n      assert( rc!=LSM_OK || res>0 || iPtrOut==(pPtr->iPtr + pPtr->iPgPtr) );\n\n      if( rc==LSM_OK ){\n        switch( eSeek ){\n          case LSM_SEEK_EQ: {\n            int eType = pPtr->eType;\n            if( (res<0 && (eType & LSM_START_DELETE))\n             || (res>0 && (eType & LSM_END_DELETE))\n             || (res==0 && (eType & LSM_POINT_DELETE))\n            ){\n              *pbStop = 1;\n            }else if( res==0 && (eType & LSM_INSERT) ){\n              lsm_env *pEnv = pCsr->pDb->pEnv;\n              *pbStop = 1;\n              pCsr->eType = pPtr->eType;\n              rc = sortedBlobSet(pEnv, &pCsr->key, pPtr->pKey, pPtr->nKey);\n              if( rc==LSM_OK ){\n                rc = sortedBlobSet(pEnv, &pCsr->val, pPtr->pVal, pPtr->nVal);\n              }\n              pCsr->flags |= CURSOR_SEEK_EQ;\n            }\n            segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n            break;\n          }\n          case LSM_SEEK_LE:\n            if( res>0 ) rc = segmentPtrAdvance(pCsr, pPtr, 1);\n            break;\n          case LSM_SEEK_GE: {\n            /* Figure out if we need to 'skip' the pointer forward or not */\n            if( (res<=0 && (pPtr->eType & LSM_START_DELETE)) \n             || (res>0  && (pPtr->eType & LSM_END_DELETE)) \n            ){\n              rc = segmentPtrFwdPointer(pCsr, pPtr, &iPtrOut);\n            }\n            if( res<0 && rc==LSM_OK ){\n              rc = segmentPtrAdvance(pCsr, pPtr, 0);\n            }\n            break;\n          }\n        }\n      }\n    }\n\n    /* If the cursor seek has found a separator key, and this cursor is\n    ** supposed to ignore separators keys, advance to the next entry.  */\n    if( rc==LSM_OK && pPtr->pPg\n     && segmentPtrIgnoreSeparators(pCsr, pPtr) \n     && rtIsSeparator(pPtr->eType)\n    ){\n      assert( eSeek!=LSM_SEEK_EQ );\n      rc = segmentPtrAdvance(pCsr, pPtr, eSeek==LSM_SEEK_LE);\n    }\n  }\n\n  assert( rc!=LSM_OK || assertSeekResult(pCsr,pPtr,iTopic,pKey,nKey,eSeek) );\n  *piPtr = (int)iPtrOut;\n  return rc;\n}\n\nstatic int seekInBtree(\n  MultiCursor *pCsr,              /* Multi-cursor object */\n  Segment *pSeg,                  /* Seek within this segment */\n  int iTopic,\n  void *pKey, int nKey,           /* Key to seek to */\n  Pgno *aPg,                      /* OUT: Page numbers */\n  Page **ppPg                     /* OUT: Leaf (sorted-run) page reference */\n){\n  int i = 0;\n  int rc;\n  int iPg;\n  Page *pPg = 0;\n  Blob blob = {0, 0, 0};\n\n  iPg = (int)pSeg->iRoot;\n  do {\n    Pgno *piFirst = 0;\n    if( aPg ){\n      aPg[i++] = iPg;\n      piFirst = &aPg[i];\n    }\n\n    rc = lsmFsDbPageGet(pCsr->pDb->pFS, pSeg, iPg, &pPg);\n    assert( rc==LSM_OK || pPg==0 );\n    if( rc==LSM_OK ){\n      u8 *aData;                  /* Buffer containing page data */\n      int nData;                  /* Size of aData[] in bytes */\n      int iMin;\n      int iMax;\n      int nRec;\n      int flags;\n\n      aData = fsPageData(pPg, &nData);\n      flags = pageGetFlags(aData, nData);\n      if( (flags & SEGMENT_BTREE_FLAG)==0 ) break;\n\n      iPg = (int)pageGetPtr(aData, nData);\n      nRec = pageGetNRec(aData, nData);\n\n      iMin = 0;\n      iMax = nRec-1;\n      while( iMax>=iMin ){\n        int iTry = (iMin+iMax)/2;\n        void *pKeyT; int nKeyT;       /* Key for cell iTry */\n        int iTopicT;                  /* Topic for key pKeyT/nKeyT */\n        Pgno iPtr;                    /* Pointer associated with cell iTry */\n        int res;                      /* (pKey - pKeyT) */\n\n        rc = pageGetBtreeKey(\n            pSeg, pPg, iTry, &iPtr, &iTopicT, &pKeyT, &nKeyT, &blob\n        );\n        if( rc!=LSM_OK ) break;\n        if( piFirst && pKeyT==blob.pData ){\n          *piFirst = pageGetBtreeRef(pPg, iTry);\n          piFirst = 0;\n          i++;\n        }\n\n        res = sortedKeyCompare(\n            pCsr->pDb->xCmp, iTopic, pKey, nKey, iTopicT, pKeyT, nKeyT\n        );\n        if( res<0 ){\n          iPg = (int)iPtr;\n          iMax = iTry-1;\n        }else{\n          iMin = iTry+1;\n        }\n      }\n      lsmFsPageRelease(pPg);\n      pPg = 0;\n    }\n  }while( rc==LSM_OK );\n\n  sortedBlobFree(&blob);\n  assert( (rc==LSM_OK)==(pPg!=0) );\n  if( ppPg ){\n    *ppPg = pPg;\n  }else{\n    lsmFsPageRelease(pPg);\n  }\n  return rc;\n}\n\nstatic int seekInSegment(\n  MultiCursor *pCsr, \n  SegmentPtr *pPtr,\n  int iTopic,\n  void *pKey, int nKey,\n  int iPg,                        /* Page to search */\n  int eSeek,                      /* Search bias - see above */\n  int *piPtr,                     /* OUT: FC pointer */\n  int *pbStop                     /* OUT: Stop search flag */\n){\n  int iPtr = iPg;\n  int rc = LSM_OK;\n\n  if( pPtr->pSeg->iRoot ){\n    Page *pPg;\n    assert( pPtr->pSeg->iRoot!=0 );\n    rc = seekInBtree(pCsr, pPtr->pSeg, iTopic, pKey, nKey, 0, &pPg);\n    if( rc==LSM_OK ) segmentPtrSetPage(pPtr, pPg);\n  }else{\n    if( iPtr==0 ){\n      iPtr = (int)pPtr->pSeg->iFirst;\n    }\n    if( rc==LSM_OK ){\n      rc = segmentPtrLoadPage(pCsr->pDb->pFS, pPtr, iPtr);\n    }\n  }\n\n  if( rc==LSM_OK ){\n    rc = segmentPtrSeek(pCsr, pPtr, iTopic, pKey, nKey, eSeek, piPtr, pbStop);\n  }\n  return rc;\n}\n\n/*\n** Seek each segment pointer in the array of (pLvl->nRight+1) at aPtr[].\n**\n** pbStop:\n**   This parameter is only significant if parameter eSeek is set to\n**   LSM_SEEK_EQ. In this case, it is set to true before returning if\n**   the seek operation is finished. This can happen in two ways:\n**   \n**     a) A key matching (pKey/nKey) is found, or\n**     b) A point-delete or range-delete deleting the key is found.\n**\n**   In case (a), the multi-cursor CURSOR_SEEK_EQ flag is set and the pCsr->key\n**   and pCsr->val blobs populated before returning.\n*/\nstatic int seekInLevel(\n  MultiCursor *pCsr,              /* Sorted cursor object to seek */\n  SegmentPtr *aPtr,               /* Pointer to array of (nRhs+1) SPs */\n  int eSeek,                      /* Search bias - see above */\n  int iTopic,                     /* Key topic to search for */\n  void *pKey, int nKey,           /* Key to search for */\n  Pgno *piPgno,                   /* IN/OUT: fraction cascade pointer (or 0) */\n  int *pbStop                     /* OUT: See above */\n){\n  Level *pLvl = aPtr[0].pLevel;   /* Level to seek within */\n  int rc = LSM_OK;                /* Return code */\n  int iOut = 0;                   /* Pointer to return to caller */\n  int res = -1;                   /* Result of xCmp(pKey, split) */\n  int nRhs = pLvl->nRight;        /* Number of right-hand-side segments */\n  int bStop = 0;\n\n  /* If this is a composite level (one currently undergoing an incremental\n  ** merge), figure out if the search key is larger or smaller than the\n  ** levels split-key.  */\n  if( nRhs ){\n    res = sortedKeyCompare(pCsr->pDb->xCmp, iTopic, pKey, nKey, \n        pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey\n    );\n  }\n\n  /* If (res<0), then key pKey/nKey is smaller than the split-key (or this\n  ** is not a composite level and there is no split-key). Search the \n  ** left-hand-side of the level in this case.  */\n  if( res<0 ){\n    int iPtr = 0;\n    if( nRhs==0 ) iPtr = (int)*piPgno;\n\n    rc = seekInSegment(\n        pCsr, &aPtr[0], iTopic, pKey, nKey, iPtr, eSeek, &iOut, &bStop\n    );\n    if( rc==LSM_OK && nRhs>0 && eSeek==LSM_SEEK_GE && aPtr[0].pPg==0 ){\n      res = 0;\n    }\n  }\n  \n  if( res>=0 ){\n    int bHit = 0;                 /* True if at least one rhs is not EOF */\n    int iPtr = (int)*piPgno;\n    int i;\n    for(i=1; rc==LSM_OK && i<=nRhs && bStop==0; i++){\n      SegmentPtr *pPtr = &aPtr[i];\n      iOut = 0;\n      rc = seekInSegment(\n          pCsr, pPtr, iTopic, pKey, nKey, iPtr, eSeek, &iOut, &bStop\n      );\n      iPtr = iOut;\n\n      /* If the segment-pointer has settled on a key that is smaller than\n      ** the splitkey, invalidate the segment-pointer.  */\n      if( pPtr->pPg ){\n        res = sortedKeyCompare(pCsr->pDb->xCmp, \n            rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey, \n            pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey\n        );\n        if( res<0 ){\n          if( pPtr->eType & LSM_START_DELETE ){\n            pPtr->eType &= ~LSM_INSERT;\n            pPtr->pKey = pLvl->pSplitKey;\n            pPtr->nKey = pLvl->nSplitKey;\n            pPtr->pVal = 0;\n            pPtr->nVal = 0;\n          }else{\n            segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n          }\n        }\n      }\n\n      if( aPtr[i].pKey ) bHit = 1;\n    }\n\n    if( rc==LSM_OK && eSeek==LSM_SEEK_LE && bHit==0 ){\n      rc = segmentPtrEnd(pCsr, &aPtr[0], 1);\n    }\n  }\n\n  assert( eSeek==LSM_SEEK_EQ || bStop==0 );\n  *piPgno = iOut;\n  *pbStop = bStop;\n  return rc;\n}\n\nstatic void multiCursorGetKey(\n  MultiCursor *pCsr, \n  int iKey,\n  int *peType,                    /* OUT: Key type (SORTED_WRITE etc.) */\n  void **ppKey,                   /* OUT: Pointer to buffer containing key */\n  int *pnKey                      /* OUT: Size of *ppKey in bytes */\n){\n  int nKey = 0;\n  void *pKey = 0;\n  int eType = 0;\n\n  switch( iKey ){\n    case CURSOR_DATA_TREE0:\n    case CURSOR_DATA_TREE1: {\n      TreeCursor *pTreeCsr = pCsr->apTreeCsr[iKey-CURSOR_DATA_TREE0];\n      if( lsmTreeCursorValid(pTreeCsr) ){\n        lsmTreeCursorKey(pTreeCsr, &eType, &pKey, &nKey);\n      }\n      break;\n    }\n\n    case CURSOR_DATA_SYSTEM: {\n      Snapshot *pWorker = pCsr->pDb->pWorker;\n      if( pWorker && (pCsr->flags & CURSOR_FLUSH_FREELIST) ){\n        int nEntry = pWorker->freelist.nEntry;\n        if( pCsr->iFree < (nEntry*2) ){\n          FreelistEntry *aEntry = pWorker->freelist.aEntry;\n          int i = nEntry - 1 - (pCsr->iFree / 2);\n          u32 iKey2 = 0;\n\n          if( (pCsr->iFree % 2) ){\n            eType = LSM_END_DELETE|LSM_SYSTEMKEY;\n            iKey2 = aEntry[i].iBlk-1;\n          }else if( aEntry[i].iId>=0 ){\n            eType = LSM_INSERT|LSM_SYSTEMKEY;\n            iKey2 = aEntry[i].iBlk;\n\n            /* If the in-memory entry immediately before this one was a\n             ** DELETE, and the block number is one greater than the current\n             ** block number, mark this entry as an \"end-delete-range\". */\n            if( i<(nEntry-1) && aEntry[i+1].iBlk==iKey2+1 && aEntry[i+1].iId<0 ){\n              eType |= LSM_END_DELETE;\n            }\n\n          }else{\n            eType = LSM_START_DELETE|LSM_SYSTEMKEY;\n            iKey2 = aEntry[i].iBlk + 1;\n          }\n\n          /* If the in-memory entry immediately after this one is a\n          ** DELETE, and the block number is one less than the current\n          ** key, mark this entry as an \"start-delete-range\".  */\n          if( i>0 && aEntry[i-1].iBlk==iKey2-1 && aEntry[i-1].iId<0 ){\n            eType |= LSM_START_DELETE;\n          }\n\n          pKey = pCsr->pSystemVal;\n          nKey = 4;\n          lsmPutU32(pKey, ~iKey2);\n        }\n      }\n      break;\n    }\n\n    default: {\n      int iPtr = iKey - CURSOR_DATA_SEGMENT;\n      assert( iPtr>=0 );\n      if( iPtr==pCsr->nPtr ){\n        if( pCsr->pBtCsr ){\n          pKey = pCsr->pBtCsr->pKey;\n          nKey = pCsr->pBtCsr->nKey;\n          eType = pCsr->pBtCsr->eType;\n        }\n      }else if( iPtr<pCsr->nPtr ){\n        SegmentPtr *pPtr = &pCsr->aPtr[iPtr];\n        if( pPtr->pPg ){\n          pKey = pPtr->pKey;\n          nKey = pPtr->nKey;\n          eType = pPtr->eType;\n        }\n      }\n      break;\n    }\n  }\n\n  if( peType ) *peType = eType;\n  if( pnKey ) *pnKey = nKey;\n  if( ppKey ) *ppKey = pKey;\n}\n\nstatic int sortedDbKeyCompare(\n  MultiCursor *pCsr,\n  int iLhsFlags, void *pLhsKey, int nLhsKey,\n  int iRhsFlags, void *pRhsKey, int nRhsKey\n){\n  int (*xCmp)(void *, int, void *, int) = pCsr->pDb->xCmp;\n  int res;\n\n  /* Compare the keys, including the system flag. */\n  res = sortedKeyCompare(xCmp, \n    rtTopic(iLhsFlags), pLhsKey, nLhsKey,\n    rtTopic(iRhsFlags), pRhsKey, nRhsKey\n  );\n\n  /* If a key has the LSM_START_DELETE flag set, but not the LSM_INSERT or\n  ** LSM_POINT_DELETE flags, it is considered a delta larger. This prevents\n  ** the beginning of an open-ended set from masking a database entry or\n  ** delete at a lower level.  */\n  if( res==0 && (pCsr->flags & CURSOR_IGNORE_DELETE) ){\n    const int m = LSM_POINT_DELETE|LSM_INSERT|LSM_END_DELETE |LSM_START_DELETE;\n    int iDel1 = 0;\n    int iDel2 = 0;\n\n    if( LSM_START_DELETE==(iLhsFlags & m) ) iDel1 = +1;\n    if( LSM_END_DELETE  ==(iLhsFlags & m) ) iDel1 = -1;\n    if( LSM_START_DELETE==(iRhsFlags & m) ) iDel2 = +1;\n    if( LSM_END_DELETE  ==(iRhsFlags & m) ) iDel2 = -1;\n\n    res = (iDel1 - iDel2);\n  }\n\n  return res;\n}\n\nstatic void multiCursorDoCompare(MultiCursor *pCsr, int iOut, int bReverse){\n  int i1;\n  int i2;\n  int iRes;\n  void *pKey1; int nKey1; int eType1;\n  void *pKey2; int nKey2; int eType2;\n  const int mul = (bReverse ? -1 : 1);\n\n  assert( pCsr->aTree && iOut<pCsr->nTree );\n  if( iOut>=(pCsr->nTree/2) ){\n    i1 = (iOut - pCsr->nTree/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pCsr->aTree[iOut*2];\n    i2 = pCsr->aTree[iOut*2+1];\n  }\n\n  multiCursorGetKey(pCsr, i1, &eType1, &pKey1, &nKey1);\n  multiCursorGetKey(pCsr, i2, &eType2, &pKey2, &nKey2);\n\n  if( pKey1==0 ){\n    iRes = i2;\n  }else if( pKey2==0 ){\n    iRes = i1;\n  }else{\n    int res;\n\n    /* Compare the keys */\n    res = sortedDbKeyCompare(pCsr,\n        eType1, pKey1, nKey1, eType2, pKey2, nKey2\n    );\n\n    res = res * mul;\n    if( res==0 ){\n      /* The two keys are identical. Normally, this means that the key from\n      ** the newer run clobbers the old. However, if the newer key is a\n      ** separator key, or a range-delete-boundary only, do not allow it\n      ** to clobber an older entry.  */\n      int nc1 = (eType1 & (LSM_INSERT|LSM_POINT_DELETE))==0;\n      int nc2 = (eType2 & (LSM_INSERT|LSM_POINT_DELETE))==0;\n      iRes = (nc1 > nc2) ? i2 : i1;\n    }else if( res<0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pCsr->aTree[iOut] = iRes;\n}\n\n/*\n** This function advances segment pointer iPtr belonging to multi-cursor\n** pCsr forward (bReverse==0) or backward (bReverse!=0).\n**\n** If the segment pointer points to a segment that is part of a composite\n** level, then the following special case is handled.\n**\n**   * If iPtr is the lhs of a composite level, and the cursor is being\n**     advanced forwards, and segment iPtr is at EOF, move all pointers\n**     that correspond to rhs segments of the same level to the first\n**     key in their respective data.\n*/\nstatic int segmentCursorAdvance(\n  MultiCursor *pCsr, \n  int iPtr,\n  int bReverse\n){\n  int rc;\n  SegmentPtr *pPtr = &pCsr->aPtr[iPtr];\n  Level *pLvl = pPtr->pLevel;\n  int bComposite;                 /* True if pPtr is part of composite level */\n\n  /* Advance the segment-pointer object. */\n  rc = segmentPtrAdvance(pCsr, pPtr, bReverse);\n  if( rc!=LSM_OK ) return rc;\n\n  bComposite = (pLvl->nRight>0 && pCsr->nPtr>pLvl->nRight);\n  if( bComposite && pPtr->pPg==0 ){\n    int bFix = 0;\n    if( (bReverse==0)==(pPtr->pSeg==&pLvl->lhs) ){\n      int i;\n      if( bReverse ){\n        SegmentPtr *pLhs = &pCsr->aPtr[iPtr - 1 - (pPtr->pSeg - pLvl->aRhs)];\n        for(i=0; i<pLvl->nRight; i++){\n          if( pLhs[i+1].pPg ) break;\n        }\n        if( i==pLvl->nRight ){\n          bFix = 1;\n          rc = segmentPtrEnd(pCsr, pLhs, 1);\n        }\n      }else{\n        bFix = 1;\n        for(i=0; rc==LSM_OK && i<pLvl->nRight; i++){\n          rc = sortedRhsFirst(pCsr, pLvl, &pCsr->aPtr[iPtr+1+i]);\n        }\n      }\n    }\n\n    if( bFix ){\n      int i;\n      for(i=pCsr->nTree-1; i>0; i--){\n        multiCursorDoCompare(pCsr, i, bReverse);\n      }\n    }\n  }\n\n#if 0\n  if( bComposite && pPtr->pSeg==&pLvl->lhs       /* lhs of composite level */\n   && bReverse==0                                /* csr advanced forwards */\n   && pPtr->pPg==0                               /* segment at EOF */\n  ){\n    int i;\n    for(i=0; rc==LSM_OK && i<pLvl->nRight; i++){\n      rc = sortedRhsFirst(pCsr, pLvl, &pCsr->aPtr[iPtr+1+i]);\n    }\n    for(i=pCsr->nTree-1; i>0; i--){\n      multiCursorDoCompare(pCsr, i, 0);\n    }\n  }\n#endif\n\n  return rc;\n}\n\nstatic void mcursorFreeComponents(MultiCursor *pCsr){\n  int i;\n  lsm_env *pEnv = pCsr->pDb->pEnv;\n\n  /* Close the tree cursor, if any. */\n  lsmTreeCursorDestroy(pCsr->apTreeCsr[0]);\n  lsmTreeCursorDestroy(pCsr->apTreeCsr[1]);\n\n  /* Reset the segment pointers */\n  for(i=0; i<pCsr->nPtr; i++){\n    segmentPtrReset(&pCsr->aPtr[i], 0);\n  }\n\n  /* And the b-tree cursor, if any */\n  btreeCursorFree(pCsr->pBtCsr);\n\n  /* Free allocations */\n  lsmFree(pEnv, pCsr->aPtr);\n  lsmFree(pEnv, pCsr->aTree);\n  lsmFree(pEnv, pCsr->pSystemVal);\n\n  /* Zero fields */\n  pCsr->nPtr = 0;\n  pCsr->aPtr = 0;\n  pCsr->nTree = 0;\n  pCsr->aTree = 0;\n  pCsr->pSystemVal = 0;\n  pCsr->apTreeCsr[0] = 0;\n  pCsr->apTreeCsr[1] = 0;\n  pCsr->pBtCsr = 0;\n}\n\nvoid lsmMCursorFreeCache(lsm_db *pDb){\n  MultiCursor *p;\n  MultiCursor *pNext;\n  for(p=pDb->pCsrCache; p; p=pNext){\n    pNext = p->pNext;\n    lsmMCursorClose(p, 0);\n  }\n  pDb->pCsrCache = 0;\n}\n\n/*\n** Close the cursor passed as the first argument.\n**\n** If the bCache parameter is true, then shift the cursor to the pCsrCache\n** list for possible reuse instead of actually deleting it.\n*/\nvoid lsmMCursorClose(MultiCursor *pCsr, int bCache){\n  if( pCsr ){\n    lsm_db *pDb = pCsr->pDb;\n    MultiCursor **pp;             /* Iterator variable */\n\n    /* The cursor may or may not be currently part of the linked list \n    ** starting at lsm_db.pCsr. If it is, extract it.  */\n    for(pp=&pDb->pCsr; *pp; pp=&((*pp)->pNext)){\n      if( *pp==pCsr ){\n        *pp = pCsr->pNext;\n        break;\n      }\n    }\n\n    if( bCache ){\n      int i;                      /* Used to iterate through segment-pointers */\n\n      /* Release any page references held by this cursor. */\n      assert( !pCsr->pBtCsr );\n      for(i=0; i<pCsr->nPtr; i++){\n        SegmentPtr *pPtr = &pCsr->aPtr[i];\n        lsmFsPageRelease(pPtr->pPg);\n        pPtr->pPg = 0;\n      }\n\n      /* Reset the tree cursors */\n      lsmTreeCursorReset(pCsr->apTreeCsr[0]);\n      lsmTreeCursorReset(pCsr->apTreeCsr[1]);\n\n      /* Add the cursor to the pCsrCache list */\n      pCsr->pNext = pDb->pCsrCache;\n      pDb->pCsrCache = pCsr;\n    }else{\n      /* Free the allocation used to cache the current key, if any. */\n      sortedBlobFree(&pCsr->key);\n      sortedBlobFree(&pCsr->val);\n\n      /* Free the component cursors */\n      mcursorFreeComponents(pCsr);\n\n      /* Free the cursor structure itself */\n      lsmFree(pDb->pEnv, pCsr);\n    }\n  }\n}\n\n#define TREE_NONE 0\n#define TREE_OLD  1\n#define TREE_BOTH 2\n\n/*\n** Parameter eTree is one of TREE_OLD or TREE_BOTH.\n*/\nstatic int multiCursorAddTree(MultiCursor *pCsr, Snapshot *pSnap, int eTree){\n  int rc = LSM_OK;\n  lsm_db *db = pCsr->pDb;\n\n  /* Add a tree cursor on the 'old' tree, if it exists. */\n  if( eTree!=TREE_NONE \n   && lsmTreeHasOld(db) \n   && db->treehdr.iOldLog!=pSnap->iLogOff \n  ){\n    rc = lsmTreeCursorNew(db, 1, &pCsr->apTreeCsr[1]);\n  }\n\n  /* Add a tree cursor on the 'current' tree, if required. */\n  if( rc==LSM_OK && eTree==TREE_BOTH ){\n    rc = lsmTreeCursorNew(db, 0, &pCsr->apTreeCsr[0]);\n  }\n\n  return rc;\n}\n\nstatic int multiCursorAddRhs(MultiCursor *pCsr, Level *pLvl){\n  int i;\n  int nRhs = pLvl->nRight;\n\n  assert( pLvl->nRight>0 );\n  assert( pCsr->aPtr==0 );\n  pCsr->aPtr = lsmMallocZero(pCsr->pDb->pEnv, sizeof(SegmentPtr) * nRhs);\n  if( !pCsr->aPtr ) return LSM_NOMEM_BKPT;\n  pCsr->nPtr = nRhs;\n\n  for(i=0; i<nRhs; i++){\n    pCsr->aPtr[i].pSeg = &pLvl->aRhs[i];\n    pCsr->aPtr[i].pLevel = pLvl;\n  }\n\n  return LSM_OK;\n}\n\nstatic void multiCursorAddOne(MultiCursor *pCsr, Level *pLvl, int *pRc){\n  if( *pRc==LSM_OK ){\n    int iPtr = pCsr->nPtr;\n    int i;\n    pCsr->aPtr[iPtr].pLevel = pLvl;\n    pCsr->aPtr[iPtr].pSeg = &pLvl->lhs;\n    iPtr++;\n    for(i=0; i<pLvl->nRight; i++){\n      pCsr->aPtr[iPtr].pLevel = pLvl;\n      pCsr->aPtr[iPtr].pSeg = &pLvl->aRhs[i];\n      iPtr++;\n    }\n\n    if( pLvl->nRight && pLvl->pSplitKey==0 ){\n      sortedSplitkey(pCsr->pDb, pLvl, pRc);\n    }\n    pCsr->nPtr = iPtr;\n  }\n}\n\nstatic int multiCursorAddAll(MultiCursor *pCsr, Snapshot *pSnap){\n  Level *pLvl;\n  int nPtr = 0;\n  int rc = LSM_OK;\n\n  for(pLvl=pSnap->pLevel; pLvl; pLvl=pLvl->pNext){\n    /* If the LEVEL_INCOMPLETE flag is set, then this function is being\n    ** called (indirectly) from within a sortedNewToplevel() call to\n    ** construct pLvl. In this case ignore pLvl - this cursor is going to\n    ** be used to retrieve a freelist entry from the LSM, and the partially\n    ** complete level may confuse it.  */\n    if( pLvl->flags & LEVEL_INCOMPLETE ) continue;\n    nPtr += (1 + pLvl->nRight);\n  }\n\n  assert( pCsr->aPtr==0 );\n  pCsr->aPtr = lsmMallocZeroRc(pCsr->pDb->pEnv, sizeof(SegmentPtr) * nPtr, &rc);\n\n  for(pLvl=pSnap->pLevel; pLvl; pLvl=pLvl->pNext){\n    if( (pLvl->flags & LEVEL_INCOMPLETE)==0 ){\n      multiCursorAddOne(pCsr, pLvl, &rc);\n    }\n  }\n\n  return rc;\n}\n\nstatic int multiCursorInit(MultiCursor *pCsr, Snapshot *pSnap){\n  int rc;\n  rc = multiCursorAddAll(pCsr, pSnap);\n  if( rc==LSM_OK ){\n    rc = multiCursorAddTree(pCsr, pSnap, TREE_BOTH);\n  }\n  pCsr->flags |= (CURSOR_IGNORE_SYSTEM | CURSOR_IGNORE_DELETE);\n  return rc;\n}\n\nstatic MultiCursor *multiCursorNew(lsm_db *db, int *pRc){\n  MultiCursor *pCsr;\n  pCsr = (MultiCursor *)lsmMallocZeroRc(db->pEnv, sizeof(MultiCursor), pRc);\n  if( pCsr ){\n    pCsr->pNext = db->pCsr;\n    db->pCsr = pCsr;\n    pCsr->pDb = db;\n  }\n  return pCsr;\n}\n\n\nvoid lsmSortedRemap(lsm_db *pDb){\n  MultiCursor *pCsr;\n  for(pCsr=pDb->pCsr; pCsr; pCsr=pCsr->pNext){\n    int iPtr;\n    if( pCsr->pBtCsr ){\n      btreeCursorLoadKey(pCsr->pBtCsr);\n    }\n    for(iPtr=0; iPtr<pCsr->nPtr; iPtr++){\n      segmentPtrLoadCell(&pCsr->aPtr[iPtr], pCsr->aPtr[iPtr].iCell);\n    }\n  }\n}\n\nstatic void multiCursorReadSeparators(MultiCursor *pCsr){\n  if( pCsr->nPtr>0 ){\n    pCsr->flags |= CURSOR_READ_SEPARATORS;\n  }\n}\n\n/*\n** Have this cursor skip over SORTED_DELETE entries.\n*/\nstatic void multiCursorIgnoreDelete(MultiCursor *pCsr){\n  if( pCsr ) pCsr->flags |= CURSOR_IGNORE_DELETE;\n}\n\n/*\n** If the free-block list is not empty, then have this cursor visit a key\n** with (a) the system bit set, and (b) the key \"FREELIST\" and (c) a value \n** blob containing the serialized free-block list.\n*/\nstatic int multiCursorVisitFreelist(MultiCursor *pCsr){\n  int rc = LSM_OK;\n  pCsr->flags |= CURSOR_FLUSH_FREELIST;\n  pCsr->pSystemVal = lsmMallocRc(pCsr->pDb->pEnv, 4 + 8, &rc);\n  return rc;\n}\n\n/*\n** Allocate and return a new database cursor.\n**\n** This method should only be called to allocate user cursors. As it may\n** recycle a cursor from lsm_db.pCsrCache.\n*/\nint lsmMCursorNew(\n  lsm_db *pDb,                    /* Database handle */\n  MultiCursor **ppCsr             /* OUT: Allocated cursor */\n){\n  MultiCursor *pCsr = 0;\n  int rc = LSM_OK;\n\n  if( pDb->pCsrCache ){\n    int bOld;                     /* True if there is an old in-memory tree */\n\n    /* Remove a cursor from the pCsrCache list and add it to the open list. */\n    pCsr = pDb->pCsrCache;\n    pDb->pCsrCache = pCsr->pNext;\n    pCsr->pNext = pDb->pCsr;\n    pDb->pCsr = pCsr;\n\n    /* The cursor can almost be used as is, except that the old in-memory\n    ** tree cursor may be present and not required, or required and not\n    ** present. Fix this if required.  */\n    bOld = (lsmTreeHasOld(pDb) && pDb->treehdr.iOldLog!=pDb->pClient->iLogOff);\n    if( !bOld && pCsr->apTreeCsr[1] ){\n      lsmTreeCursorDestroy(pCsr->apTreeCsr[1]);\n      pCsr->apTreeCsr[1] = 0;\n    }else if( bOld && !pCsr->apTreeCsr[1] ){\n      rc = lsmTreeCursorNew(pDb, 1, &pCsr->apTreeCsr[1]);\n    }\n\n    pCsr->flags = (CURSOR_IGNORE_SYSTEM | CURSOR_IGNORE_DELETE);\n\n  }else{\n    pCsr = multiCursorNew(pDb, &rc);\n    if( rc==LSM_OK ) rc = multiCursorInit(pCsr, pDb->pClient);\n  }\n\n  if( rc!=LSM_OK ){\n    lsmMCursorClose(pCsr, 0);\n    pCsr = 0;\n  }\n  assert( (rc==LSM_OK)==(pCsr!=0) );\n  *ppCsr = pCsr;\n  return rc;\n}\n\nstatic int multiCursorGetVal(\n  MultiCursor *pCsr, \n  int iVal, \n  void **ppVal, \n  int *pnVal\n){\n  int rc = LSM_OK;\n\n  *ppVal = 0;\n  *pnVal = 0;\n\n  switch( iVal ){\n    case CURSOR_DATA_TREE0:\n    case CURSOR_DATA_TREE1: {\n      TreeCursor *pTreeCsr = pCsr->apTreeCsr[iVal-CURSOR_DATA_TREE0];\n      if( lsmTreeCursorValid(pTreeCsr) ){\n        lsmTreeCursorValue(pTreeCsr, ppVal, pnVal);\n      }else{\n        *ppVal = 0;\n        *pnVal = 0;\n      }\n      break;\n    }\n\n    case CURSOR_DATA_SYSTEM: {\n      Snapshot *pWorker = pCsr->pDb->pWorker;\n      if( pWorker \n       && (pCsr->iFree % 2)==0\n       && pCsr->iFree < (pWorker->freelist.nEntry*2)\n      ){\n        int iEntry = pWorker->freelist.nEntry - 1 - (pCsr->iFree / 2);\n        u8 *aVal = &((u8 *)(pCsr->pSystemVal))[4];\n        lsmPutU64(aVal, pWorker->freelist.aEntry[iEntry].iId);\n        *ppVal = aVal;\n        *pnVal = 8;\n      }\n      break;\n    }\n\n    default: {\n      int iPtr = iVal-CURSOR_DATA_SEGMENT;\n      if( iPtr<pCsr->nPtr ){\n        SegmentPtr *pPtr = &pCsr->aPtr[iPtr];\n        if( pPtr->pPg ){\n          *ppVal = pPtr->pVal;\n          *pnVal = pPtr->nVal;\n        }\n      }\n    }\n  }\n\n  assert( rc==LSM_OK || (*ppVal==0 && *pnVal==0) );\n  return rc;\n}\n\nstatic int multiCursorAdvance(MultiCursor *pCsr, int bReverse);\n\n/*\n** This function is called by worker connections to walk the part of the\n** free-list stored within the LSM data structure.\n*/\nint lsmSortedWalkFreelist(\n  lsm_db *pDb,                    /* Database handle */\n  int bReverse,                   /* True to iterate from largest to smallest */\n  int (*x)(void *, int, i64),     /* Callback function */\n  void *pCtx                      /* First argument to pass to callback */\n){\n  MultiCursor *pCsr;              /* Cursor used to read db */\n  int rc = LSM_OK;                /* Return Code */\n  Snapshot *pSnap = 0;\n\n  assert( pDb->pWorker );\n  if( pDb->bIncrMerge ){\n    rc = lsmCheckpointDeserialize(pDb, 0, pDb->pShmhdr->aSnap1, &pSnap);\n    if( rc!=LSM_OK ) return rc;\n  }else{\n    pSnap = pDb->pWorker;\n  }\n\n  pCsr = multiCursorNew(pDb, &rc);\n  if( pCsr ){\n    rc = multiCursorAddAll(pCsr, pSnap);\n    pCsr->flags |= CURSOR_IGNORE_DELETE;\n  }\n  \n  if( rc==LSM_OK ){\n    if( bReverse==0 ){\n      rc = lsmMCursorLast(pCsr);\n    }else{\n      rc = lsmMCursorSeek(pCsr, 1, \"\", 0, LSM_SEEK_GE);\n    }\n\n    while( rc==LSM_OK && lsmMCursorValid(pCsr) && rtIsSystem(pCsr->eType) ){\n      void *pKey; int nKey;\n      void *pVal = 0; int nVal = 0;\n\n      rc = lsmMCursorKey(pCsr, &pKey, &nKey);\n      if( rc==LSM_OK ) rc = lsmMCursorValue(pCsr, &pVal, &nVal);\n      if( rc==LSM_OK && (nKey!=4 || nVal!=8) ) rc = LSM_CORRUPT_BKPT;\n\n      if( rc==LSM_OK ){\n        int iBlk;\n        i64 iSnap;\n        iBlk = (int)(~(lsmGetU32((u8 *)pKey)));\n        iSnap = (i64)lsmGetU64((u8 *)pVal);\n        if( x(pCtx, iBlk, iSnap) ) break;\n        rc = multiCursorAdvance(pCsr, !bReverse);\n      }\n    }\n  }\n\n  lsmMCursorClose(pCsr, 0);\n  if( pSnap!=pDb->pWorker ){\n    lsmFreeSnapshot(pDb->pEnv, pSnap);\n  }\n\n  return rc;\n}\n\nint lsmSortedLoadFreelist(\n  lsm_db *pDb,                    /* Database handle (must be worker) */\n  void **ppVal,                   /* OUT: Blob containing LSM free-list */\n  int *pnVal                      /* OUT: Size of *ppVal blob in bytes */\n){\n  MultiCursor *pCsr;              /* Cursor used to retreive free-list */\n  int rc = LSM_OK;                /* Return Code */\n\n  assert( pDb->pWorker );\n  assert( *ppVal==0 && *pnVal==0 );\n\n  pCsr = multiCursorNew(pDb, &rc);\n  if( pCsr ){\n    rc = multiCursorAddAll(pCsr, pDb->pWorker);\n    pCsr->flags |= CURSOR_IGNORE_DELETE;\n  }\n  \n  if( rc==LSM_OK ){\n    rc = lsmMCursorLast(pCsr);\n    if( rc==LSM_OK \n     && rtIsWrite(pCsr->eType) && rtIsSystem(pCsr->eType)\n     && pCsr->key.nData==8 \n     && 0==memcmp(pCsr->key.pData, \"FREELIST\", 8)\n    ){\n      void *pVal; int nVal;         /* Value read from database */\n      rc = lsmMCursorValue(pCsr, &pVal, &nVal);\n      if( rc==LSM_OK ){\n        *ppVal = lsmMallocRc(pDb->pEnv, nVal, &rc);\n        if( *ppVal ){\n          memcpy(*ppVal, pVal, nVal);\n          *pnVal = nVal;\n        }\n      }\n    }\n\n    lsmMCursorClose(pCsr, 0);\n  }\n\n  return rc;\n}\n\nstatic int multiCursorAllocTree(MultiCursor *pCsr){\n  int rc = LSM_OK;\n  if( pCsr->aTree==0 ){\n    int nByte;                    /* Bytes of space to allocate */\n    int nMin;                     /* Total number of cursors being merged */\n\n    nMin = CURSOR_DATA_SEGMENT + pCsr->nPtr + (pCsr->pBtCsr!=0);\n    pCsr->nTree = 2;\n    while( pCsr->nTree<nMin ){\n      pCsr->nTree = pCsr->nTree*2;\n    }\n\n    nByte = sizeof(int)*pCsr->nTree*2;\n    pCsr->aTree = (int *)lsmMallocZeroRc(pCsr->pDb->pEnv, nByte, &rc);\n  }\n  return rc;\n}\n\nstatic void multiCursorCacheKey(MultiCursor *pCsr, int *pRc){\n  if( *pRc==LSM_OK ){\n    void *pKey;\n    int nKey;\n    multiCursorGetKey(pCsr, pCsr->aTree[1], &pCsr->eType, &pKey, &nKey);\n    *pRc = sortedBlobSet(pCsr->pDb->pEnv, &pCsr->key, pKey, nKey);\n  }\n}\n\n#ifdef LSM_DEBUG_EXPENSIVE\nstatic void assertCursorTree(MultiCursor *pCsr){\n  int bRev = !!(pCsr->flags & CURSOR_PREV_OK);\n  int *aSave = pCsr->aTree;\n  int nSave = pCsr->nTree;\n  int rc;\n\n  pCsr->aTree = 0;\n  pCsr->nTree = 0;\n  rc = multiCursorAllocTree(pCsr);\n  if( rc==LSM_OK ){\n    int i;\n    for(i=pCsr->nTree-1; i>0; i--){\n      multiCursorDoCompare(pCsr, i, bRev);\n    }\n\n    assert( nSave==pCsr->nTree \n        && 0==memcmp(aSave, pCsr->aTree, sizeof(int)*nSave)\n    );\n\n    lsmFree(pCsr->pDb->pEnv, pCsr->aTree);\n  }\n\n  pCsr->aTree = aSave;\n  pCsr->nTree = nSave;\n}\n#else\n# define assertCursorTree(x)\n#endif\n\nstatic int mcursorLocationOk(MultiCursor *pCsr, int bDeleteOk){\n  int eType = pCsr->eType;\n  int iKey;\n  int i;\n  int rdmask;\n  \n  assert( pCsr->flags & (CURSOR_NEXT_OK|CURSOR_PREV_OK) );\n  assertCursorTree(pCsr);\n\n  rdmask = (pCsr->flags & CURSOR_NEXT_OK) ? LSM_END_DELETE : LSM_START_DELETE;\n\n  /* If the cursor does not currently point to an actual database key (i.e.\n  ** it points to a delete key, or the start or end of a range-delete), and\n  ** the CURSOR_IGNORE_DELETE flag is set, skip past this entry.  */\n  if( (pCsr->flags & CURSOR_IGNORE_DELETE) && bDeleteOk==0 ){\n    if( (eType & LSM_INSERT)==0 ) return 0;\n  }\n\n  /* If the cursor points to a system key (free-list entry), and the\n  ** CURSOR_IGNORE_SYSTEM flag is set, skip thie entry.  */\n  if( (pCsr->flags & CURSOR_IGNORE_SYSTEM) && rtTopic(eType)!=0 ){\n    return 0;\n  }\n\n#ifndef NDEBUG\n  /* This block fires assert() statements to check one of the assumptions\n  ** in the comment below - that if the lhs sub-cursor of a level undergoing\n  ** a merge is valid, then all the rhs sub-cursors must be at EOF. \n  **\n  ** Also assert that all rhs sub-cursors are either at EOF or point to\n  ** a key that is not less than the level split-key.  */\n  for(i=0; i<pCsr->nPtr; i++){\n    SegmentPtr *pPtr = &pCsr->aPtr[i];\n    Level *pLvl = pPtr->pLevel;\n    if( pLvl->nRight && pPtr->pPg ){\n      if( pPtr->pSeg==&pLvl->lhs ){\n        int j;\n        for(j=0; j<pLvl->nRight; j++) assert( pPtr[j+1].pPg==0 );\n      }else{\n        int res = sortedKeyCompare(pCsr->pDb->xCmp, \n            rtTopic(pPtr->eType), pPtr->pKey, pPtr->nKey,\n            pLvl->iSplitTopic, pLvl->pSplitKey, pLvl->nSplitKey\n        );\n        assert( res>=0 );\n      }\n    }\n  }\n#endif\n\n  /* Now check if this key has already been deleted by a range-delete. If \n  ** so, skip past it.\n  **\n  ** Assume, for the moment, that the tree contains no levels currently \n  ** undergoing incremental merge, and that this cursor is iterating forwards\n  ** through the database keys. The cursor currently points to a key in\n  ** level L. This key has already been deleted if any of the sub-cursors\n  ** that point to levels newer than L (or to the in-memory tree) point to\n  ** a key greater than the current key with the LSM_END_DELETE flag set.\n  **\n  ** Or, if the cursor is iterating backwards through data keys, if any\n  ** such sub-cursor points to a key smaller than the current key with the\n  ** LSM_START_DELETE flag set.\n  **\n  ** Why it works with levels undergoing a merge too:\n  **\n  ** When a cursor iterates forwards, the sub-cursors for the rhs of a \n  ** level are only activated once the lhs reaches EOF. So when iterating\n  ** forwards, the keys visited are the same as if the level was completely\n  ** merged.\n  **\n  ** If the cursor is iterating backwards, then the lhs sub-cursor is not \n  ** initialized until the last of the rhs sub-cursors has reached EOF.\n  ** Additionally, if the START_DELETE flag is set on the last entry (in\n  ** reverse order - so the entry with the smallest key) of a rhs sub-cursor,\n  ** then a pseudo-key equal to the levels split-key with the END_DELETE\n  ** flag set is visited by the sub-cursor.\n  */ \n  iKey = pCsr->aTree[1];\n  for(i=0; i<iKey; i++){\n    int csrflags;\n    multiCursorGetKey(pCsr, i, &csrflags, 0, 0);\n    if( (rdmask & csrflags) ){\n      const int SD_ED = (LSM_START_DELETE|LSM_END_DELETE);\n      if( (csrflags & SD_ED)==SD_ED \n       || (pCsr->flags & CURSOR_IGNORE_DELETE)==0\n      ){\n        void *pKey; int nKey;\n        multiCursorGetKey(pCsr, i, 0, &pKey, &nKey);\n        if( 0==sortedKeyCompare(pCsr->pDb->xCmp,\n              rtTopic(eType), pCsr->key.pData, pCsr->key.nData,\n              rtTopic(csrflags), pKey, nKey\n        )){\n          continue;\n        }\n      }\n      return 0;\n    }\n  }\n\n  /* The current cursor position is one this cursor should visit. Return 1. */\n  return 1;\n}\n\nstatic int multiCursorSetupTree(MultiCursor *pCsr, int bRev){\n  int rc;\n\n  rc = multiCursorAllocTree(pCsr);\n  if( rc==LSM_OK ){\n    int i;\n    for(i=pCsr->nTree-1; i>0; i--){\n      multiCursorDoCompare(pCsr, i, bRev);\n    }\n  }\n\n  assertCursorTree(pCsr);\n  multiCursorCacheKey(pCsr, &rc);\n\n  if( rc==LSM_OK && mcursorLocationOk(pCsr, 0)==0 ){\n    rc = multiCursorAdvance(pCsr, bRev);\n  }\n  return rc;\n}\n\n\nstatic int multiCursorEnd(MultiCursor *pCsr, int bLast){\n  int rc = LSM_OK;\n  int i;\n\n  pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK);\n  pCsr->flags |= (bLast ? CURSOR_PREV_OK : CURSOR_NEXT_OK);\n  pCsr->iFree = 0;\n\n  /* Position the two in-memory tree cursors */\n  for(i=0; rc==LSM_OK && i<2; i++){\n    if( pCsr->apTreeCsr[i] ){\n      rc = lsmTreeCursorEnd(pCsr->apTreeCsr[i], bLast);\n    }\n  }\n\n  for(i=0; rc==LSM_OK && i<pCsr->nPtr; i++){\n    SegmentPtr *pPtr = &pCsr->aPtr[i];\n    Level *pLvl = pPtr->pLevel;\n    int iRhs;\n    int bHit = 0;\n\n    if( bLast ){\n      for(iRhs=0; iRhs<pLvl->nRight && rc==LSM_OK; iRhs++){\n        rc = segmentPtrEnd(pCsr, &pPtr[iRhs+1], 1);\n        if( pPtr[iRhs+1].pPg ) bHit = 1;\n      }\n      if( bHit==0 && rc==LSM_OK ){\n        rc = segmentPtrEnd(pCsr, pPtr, 1);\n      }else{\n        segmentPtrReset(pPtr, LSM_SEGMENTPTR_FREE_THRESHOLD);\n      }\n    }else{\n      int bLhs = (pPtr->pSeg==&pLvl->lhs);\n      assert( pPtr->pSeg==&pLvl->lhs || pPtr->pSeg==&pLvl->aRhs[0] );\n\n      if( bLhs ){\n        rc = segmentPtrEnd(pCsr, pPtr, 0);\n        if( pPtr->pKey ) bHit = 1;\n      }\n      for(iRhs=0; iRhs<pLvl->nRight && rc==LSM_OK; iRhs++){\n        if( bHit ){\n          segmentPtrReset(&pPtr[iRhs+1], LSM_SEGMENTPTR_FREE_THRESHOLD);\n        }else{\n          rc = sortedRhsFirst(pCsr, pLvl, &pPtr[iRhs+bLhs]);\n        }\n      }\n    }\n    i += pLvl->nRight;\n  }\n\n  /* And the b-tree cursor, if applicable */\n  if( rc==LSM_OK && pCsr->pBtCsr ){\n    assert( bLast==0 );\n    rc = btreeCursorFirst(pCsr->pBtCsr);\n  }\n\n  if( rc==LSM_OK ){\n    rc = multiCursorSetupTree(pCsr, bLast);\n  }\n  \n  return rc;\n}\n\n\nint mcursorSave(MultiCursor *pCsr){\n  int rc = LSM_OK;\n  if( pCsr->aTree ){\n    int iTree = pCsr->aTree[1];\n    if( iTree==CURSOR_DATA_TREE0 || iTree==CURSOR_DATA_TREE1 ){\n      multiCursorCacheKey(pCsr, &rc);\n    }\n  }\n  mcursorFreeComponents(pCsr);\n  return rc;\n}\n\nint mcursorRestore(lsm_db *pDb, MultiCursor *pCsr){\n  int rc;\n  rc = multiCursorInit(pCsr, pDb->pClient);\n  if( rc==LSM_OK && pCsr->key.pData ){\n    rc = lsmMCursorSeek(pCsr, \n         rtTopic(pCsr->eType), pCsr->key.pData, pCsr->key.nData, +1\n    );\n  }\n  return rc;\n}\n\nint lsmSaveCursors(lsm_db *pDb){\n  int rc = LSM_OK;\n  MultiCursor *pCsr;\n\n  for(pCsr=pDb->pCsr; rc==LSM_OK && pCsr; pCsr=pCsr->pNext){\n    rc = mcursorSave(pCsr);\n  }\n  return rc;\n}\n\nint lsmRestoreCursors(lsm_db *pDb){\n  int rc = LSM_OK;\n  MultiCursor *pCsr;\n\n  for(pCsr=pDb->pCsr; rc==LSM_OK && pCsr; pCsr=pCsr->pNext){\n    rc = mcursorRestore(pDb, pCsr);\n  }\n  return rc;\n}\n\nint lsmMCursorFirst(MultiCursor *pCsr){\n  return multiCursorEnd(pCsr, 0);\n}\n\nint lsmMCursorLast(MultiCursor *pCsr){\n  return multiCursorEnd(pCsr, 1);\n}\n\nlsm_db *lsmMCursorDb(MultiCursor *pCsr){\n  return pCsr->pDb;\n}\n\nvoid lsmMCursorReset(MultiCursor *pCsr){\n  int i;\n  lsmTreeCursorReset(pCsr->apTreeCsr[0]);\n  lsmTreeCursorReset(pCsr->apTreeCsr[1]);\n  for(i=0; i<pCsr->nPtr; i++){\n    segmentPtrReset(&pCsr->aPtr[i], LSM_SEGMENTPTR_FREE_THRESHOLD);\n  }\n  pCsr->key.nData = 0;\n}\n\nstatic int treeCursorSeek(\n  MultiCursor *pCsr,\n  TreeCursor *pTreeCsr, \n  void *pKey, int nKey, \n  int eSeek,\n  int *pbStop\n){\n  int rc = LSM_OK;\n  if( pTreeCsr ){\n    int res = 0;\n    lsmTreeCursorSeek(pTreeCsr, pKey, nKey, &res);\n    switch( eSeek ){\n      case LSM_SEEK_EQ: {\n        int eType = lsmTreeCursorFlags(pTreeCsr);\n        if( (res<0 && (eType & LSM_START_DELETE))\n         || (res>0 && (eType & LSM_END_DELETE))\n         || (res==0 && (eType & LSM_POINT_DELETE))\n        ){\n          *pbStop = 1;\n        }else if( res==0 && (eType & LSM_INSERT) ){\n          lsm_env *pEnv = pCsr->pDb->pEnv;\n          void *p; int n;         /* Key/value from tree-cursor */\n          *pbStop = 1;\n          pCsr->flags |= CURSOR_SEEK_EQ;\n          rc = lsmTreeCursorKey(pTreeCsr, &pCsr->eType, &p, &n);\n          if( rc==LSM_OK ) rc = sortedBlobSet(pEnv, &pCsr->key, p, n);\n          if( rc==LSM_OK ) rc = lsmTreeCursorValue(pTreeCsr, &p, &n);\n          if( rc==LSM_OK ) rc = sortedBlobSet(pEnv, &pCsr->val, p, n);\n        }\n        lsmTreeCursorReset(pTreeCsr);\n        break;\n      }\n      case LSM_SEEK_GE:\n        if( res<0 && lsmTreeCursorValid(pTreeCsr) ){\n          lsmTreeCursorNext(pTreeCsr);\n        }\n        break;\n      default:\n        if( res>0 ){\n          assert( lsmTreeCursorValid(pTreeCsr) );\n          lsmTreeCursorPrev(pTreeCsr);\n        }\n        break;\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Seek the cursor.\n*/\nint lsmMCursorSeek(\n  MultiCursor *pCsr, \n  int iTopic, \n  void *pKey, int nKey, \n  int eSeek\n){\n  int eESeek = eSeek;             /* Effective eSeek parameter */\n  int bStop = 0;                  /* Set to true to halt search operation */\n  int rc = LSM_OK;                /* Return code */\n  int iPtr = 0;                   /* Used to iterate through pCsr->aPtr[] */\n  Pgno iPgno = 0;                 /* FC pointer value */\n\n  assert( pCsr->apTreeCsr[0]==0 || iTopic==0 );\n  assert( pCsr->apTreeCsr[1]==0 || iTopic==0 );\n\n  if( eESeek==LSM_SEEK_LEFAST ) eESeek = LSM_SEEK_LE;\n\n  assert( eESeek==LSM_SEEK_EQ || eESeek==LSM_SEEK_LE || eESeek==LSM_SEEK_GE );\n  assert( (pCsr->flags & CURSOR_FLUSH_FREELIST)==0 );\n  assert( pCsr->nPtr==0 || pCsr->aPtr[0].pLevel );\n\n  pCsr->flags &= ~(CURSOR_NEXT_OK | CURSOR_PREV_OK | CURSOR_SEEK_EQ);\n  rc = treeCursorSeek(pCsr, pCsr->apTreeCsr[0], pKey, nKey, eESeek, &bStop);\n  if( rc==LSM_OK && bStop==0 ){\n    rc = treeCursorSeek(pCsr, pCsr->apTreeCsr[1], pKey, nKey, eESeek, &bStop);\n  }\n\n  /* Seek all segment pointers. */\n  for(iPtr=0; iPtr<pCsr->nPtr && rc==LSM_OK && bStop==0; iPtr++){\n    SegmentPtr *pPtr = &pCsr->aPtr[iPtr];\n    assert( pPtr->pSeg==&pPtr->pLevel->lhs );\n    rc = seekInLevel(pCsr, pPtr, eESeek, iTopic, pKey, nKey, &iPgno, &bStop);\n    iPtr += pPtr->pLevel->nRight;\n  }\n\n  if( eSeek!=LSM_SEEK_EQ ){\n    if( rc==LSM_OK ){\n      rc = multiCursorAllocTree(pCsr);\n    }\n    if( rc==LSM_OK ){\n      int i;\n      for(i=pCsr->nTree-1; i>0; i--){\n        multiCursorDoCompare(pCsr, i, eESeek==LSM_SEEK_LE);\n      }\n      if( eSeek==LSM_SEEK_GE ) pCsr->flags |= CURSOR_NEXT_OK;\n      if( eSeek==LSM_SEEK_LE ) pCsr->flags |= CURSOR_PREV_OK;\n    }\n\n    multiCursorCacheKey(pCsr, &rc);\n    if( rc==LSM_OK && eSeek!=LSM_SEEK_LEFAST && 0==mcursorLocationOk(pCsr, 0) ){\n      switch( eESeek ){\n        case LSM_SEEK_EQ:\n          lsmMCursorReset(pCsr);\n          break;\n        case LSM_SEEK_GE:\n          rc = lsmMCursorNext(pCsr);\n          break;\n        default:\n          rc = lsmMCursorPrev(pCsr);\n          break;\n      }\n    }\n  }\n\n  return rc;\n}\n\nint lsmMCursorValid(MultiCursor *pCsr){\n  int res = 0;\n  if( pCsr->flags & CURSOR_SEEK_EQ ){\n    res = 1;\n  }else if( pCsr->aTree ){\n    int iKey = pCsr->aTree[1];\n    if( iKey==CURSOR_DATA_TREE0 || iKey==CURSOR_DATA_TREE1 ){\n      res = lsmTreeCursorValid(pCsr->apTreeCsr[iKey-CURSOR_DATA_TREE0]);\n    }else{\n      void *pKey; \n      multiCursorGetKey(pCsr, iKey, 0, &pKey, 0);\n      res = pKey!=0;\n    }\n  }\n  return res;\n}\n\nstatic int mcursorAdvanceOk(\n  MultiCursor *pCsr, \n  int bReverse,\n  int *pRc\n){\n  void *pNew;                     /* Pointer to buffer containing new key */\n  int nNew;                       /* Size of buffer pNew in bytes */\n  int eNewType;                   /* Type of new record */\n\n  if( *pRc ) return 1;\n\n  /* Check the current key value. If it is not greater than (if bReverse==0)\n  ** or less than (if bReverse!=0) the key currently cached in pCsr->key, \n  ** then the cursor has not yet been successfully advanced.  \n  */\n  multiCursorGetKey(pCsr, pCsr->aTree[1], &eNewType, &pNew, &nNew);\n  if( pNew ){\n    int typemask = (pCsr->flags & CURSOR_IGNORE_DELETE) ? ~(0) : LSM_SYSTEMKEY;\n    int res = sortedDbKeyCompare(pCsr,\n      eNewType & typemask, pNew, nNew, \n      pCsr->eType & typemask, pCsr->key.pData, pCsr->key.nData\n    );\n\n    if( (bReverse==0 && res<=0) || (bReverse!=0 && res>=0) ){\n      return 0;\n    }\n\n    multiCursorCacheKey(pCsr, pRc);\n    assert( pCsr->eType==eNewType );\n\n    /* If this cursor is configured to skip deleted keys, and the current\n    ** cursor points to a SORTED_DELETE entry, then the cursor has not been \n    ** successfully advanced.  \n    **\n    ** Similarly, if the cursor is configured to skip system keys and the\n    ** current cursor points to a system key, it has not yet been advanced.\n    */\n    if( *pRc==LSM_OK && 0==mcursorLocationOk(pCsr, 0) ) return 0;\n  }\n  return 1;\n}\n\nstatic void flCsrAdvance(MultiCursor *pCsr){\n  assert( pCsr->flags & CURSOR_FLUSH_FREELIST );\n  if( pCsr->iFree % 2 ){\n    pCsr->iFree++;\n  }else{\n    int nEntry = pCsr->pDb->pWorker->freelist.nEntry;\n    FreelistEntry *aEntry = pCsr->pDb->pWorker->freelist.aEntry;\n\n    int i = nEntry - 1 - (pCsr->iFree / 2);\n\n    /* If the current entry is a delete and the \"end-delete\" key will not\n    ** be attached to the next entry, increment iFree by 1 only. */\n    if( aEntry[i].iId<0 ){\n      while( 1 ){\n        if( i==0 || aEntry[i-1].iBlk!=aEntry[i].iBlk-1 ){\n          pCsr->iFree--;\n          break;\n        }\n        if( aEntry[i-1].iId>=0 ) break;\n        pCsr->iFree += 2;\n        i--;\n      }\n    }\n    pCsr->iFree += 2;\n  }\n}\n\nstatic int multiCursorAdvance(MultiCursor *pCsr, int bReverse){\n  int rc = LSM_OK;                /* Return Code */\n  if( lsmMCursorValid(pCsr) ){\n    do {\n      int iKey = pCsr->aTree[1];\n\n      assertCursorTree(pCsr);\n\n      /* If this multi-cursor is advancing forwards, and the sub-cursor\n      ** being advanced is the one that separator keys may be being read\n      ** from, record the current absolute pointer value.  */\n      if( pCsr->pPrevMergePtr ){\n        if( iKey==(CURSOR_DATA_SEGMENT+pCsr->nPtr) ){\n          assert( pCsr->pBtCsr );\n          *pCsr->pPrevMergePtr = pCsr->pBtCsr->iPtr;\n        }else if( pCsr->pBtCsr==0 && pCsr->nPtr>0\n               && iKey==(CURSOR_DATA_SEGMENT+pCsr->nPtr-1) \n        ){\n          SegmentPtr *pPtr = &pCsr->aPtr[iKey-CURSOR_DATA_SEGMENT];\n          *pCsr->pPrevMergePtr = pPtr->iPtr+pPtr->iPgPtr;\n        }\n      }\n\n      if( iKey==CURSOR_DATA_TREE0 || iKey==CURSOR_DATA_TREE1 ){\n        TreeCursor *pTreeCsr = pCsr->apTreeCsr[iKey-CURSOR_DATA_TREE0];\n        if( bReverse ){\n          rc = lsmTreeCursorPrev(pTreeCsr);\n        }else{\n          rc = lsmTreeCursorNext(pTreeCsr);\n        }\n      }else if( iKey==CURSOR_DATA_SYSTEM ){\n        assert( pCsr->flags & CURSOR_FLUSH_FREELIST );\n        assert( bReverse==0 );\n        flCsrAdvance(pCsr);\n      }else if( iKey==(CURSOR_DATA_SEGMENT+pCsr->nPtr) ){\n        assert( bReverse==0 && pCsr->pBtCsr );\n        rc = btreeCursorNext(pCsr->pBtCsr);\n      }else{\n        rc = segmentCursorAdvance(pCsr, iKey-CURSOR_DATA_SEGMENT, bReverse);\n      }\n      if( rc==LSM_OK ){\n        int i;\n        for(i=(iKey+pCsr->nTree)/2; i>0; i=i/2){\n          multiCursorDoCompare(pCsr, i, bReverse);\n        }\n        assertCursorTree(pCsr);\n      }\n    }while( mcursorAdvanceOk(pCsr, bReverse, &rc)==0 );\n  }\n  return rc;\n}\n\nint lsmMCursorNext(MultiCursor *pCsr){\n  if( (pCsr->flags & CURSOR_NEXT_OK)==0 ) return LSM_MISUSE_BKPT;\n  return multiCursorAdvance(pCsr, 0);\n}\n\nint lsmMCursorPrev(MultiCursor *pCsr){\n  if( (pCsr->flags & CURSOR_PREV_OK)==0 ) return LSM_MISUSE_BKPT;\n  return multiCursorAdvance(pCsr, 1);\n}\n\nint lsmMCursorKey(MultiCursor *pCsr, void **ppKey, int *pnKey){\n  if( (pCsr->flags & CURSOR_SEEK_EQ) || pCsr->aTree==0 ){\n    *pnKey = pCsr->key.nData;\n    *ppKey = pCsr->key.pData;\n  }else{\n    int iKey = pCsr->aTree[1];\n\n    if( iKey==CURSOR_DATA_TREE0 || iKey==CURSOR_DATA_TREE1 ){\n      TreeCursor *pTreeCsr = pCsr->apTreeCsr[iKey-CURSOR_DATA_TREE0];\n      lsmTreeCursorKey(pTreeCsr, 0, ppKey, pnKey);\n    }else{\n      int nKey;\n\n#ifndef NDEBUG\n      void *pKey;\n      int eType;\n      multiCursorGetKey(pCsr, iKey, &eType, &pKey, &nKey);\n      assert( eType==pCsr->eType );\n      assert( nKey==pCsr->key.nData );\n      assert( memcmp(pKey, pCsr->key.pData, nKey)==0 );\n#endif\n\n      nKey = pCsr->key.nData;\n      if( nKey==0 ){\n        *ppKey = 0;\n      }else{\n        *ppKey = pCsr->key.pData;\n      }\n      *pnKey = nKey; \n    }\n  }\n  return LSM_OK;\n}\n\n/*\n** Compare the current key that cursor csr points to with pKey/nKey. Set\n** *piRes to the result and return LSM_OK.\n*/\nint lsm_csr_cmp(lsm_cursor *csr, const void *pKey, int nKey, int *piRes){\n  MultiCursor *pCsr = (MultiCursor *)csr;\n  void *pCsrkey; int nCsrkey;\n  int rc;\n  rc = lsmMCursorKey(pCsr, &pCsrkey, &nCsrkey);\n  if( rc==LSM_OK ){\n    int (*xCmp)(void *, int, void *, int) = pCsr->pDb->xCmp;\n    *piRes = sortedKeyCompare(xCmp, 0, pCsrkey, nCsrkey, 0, (void *)pKey, nKey);\n  }\n  return rc;\n}\n\nint lsmMCursorValue(MultiCursor *pCsr, void **ppVal, int *pnVal){\n  void *pVal;\n  int nVal;\n  int rc;\n  if( (pCsr->flags & CURSOR_SEEK_EQ) || pCsr->aTree==0 ){\n    rc = LSM_OK;\n    nVal = pCsr->val.nData;\n    pVal = pCsr->val.pData;\n  }else{\n\n    assert( pCsr->aTree );\n    assert( mcursorLocationOk(pCsr, (pCsr->flags & CURSOR_IGNORE_DELETE)) );\n\n    rc = multiCursorGetVal(pCsr, pCsr->aTree[1], &pVal, &nVal);\n    if( pVal && rc==LSM_OK ){\n      rc = sortedBlobSet(pCsr->pDb->pEnv, &pCsr->val, pVal, nVal);\n      pVal = pCsr->val.pData;\n    }\n\n    if( rc!=LSM_OK ){\n      pVal = 0;\n      nVal = 0;\n    }\n  }\n  *ppVal = pVal;\n  *pnVal = nVal;\n  return rc;\n}\n\nint lsmMCursorType(MultiCursor *pCsr, int *peType){\n  assert( pCsr->aTree );\n  multiCursorGetKey(pCsr, pCsr->aTree[1], peType, 0, 0);\n  return LSM_OK;\n}\n\n/*\n** Buffer aData[], size nData, is assumed to contain a valid b-tree \n** hierarchy page image. Return the offset in aData[] of the next free\n** byte in the data area (where a new cell may be written if there is\n** space).\n*/\nstatic int mergeWorkerPageOffset(u8 *aData, int nData){\n  int nRec;\n  int iOff;\n  int nKey;\n  int eType;\n\n  nRec = lsmGetU16(&aData[SEGMENT_NRECORD_OFFSET(nData)]);\n  iOff = lsmGetU16(&aData[SEGMENT_CELLPTR_OFFSET(nData, nRec-1)]);\n  eType = aData[iOff++];\n  assert( eType==0 \n       || eType==(LSM_SYSTEMKEY|LSM_SEPARATOR) \n       || eType==(LSM_SEPARATOR)\n  );\n\n  iOff += lsmVarintGet32(&aData[iOff], &nKey);\n  iOff += lsmVarintGet32(&aData[iOff], &nKey);\n\n  return iOff + (eType ? nKey : 0);\n}\n\n/*\n** Following a checkpoint operation, database pages that are part of the\n** checkpointed state of the LSM are deemed read-only. This includes the\n** right-most page of the b-tree hierarchy of any separators array under\n** construction, and all pages between it and the b-tree root, inclusive.\n** This is a problem, as when further pages are appended to the separators\n** array, entries must be added to the indicated b-tree hierarchy pages.\n**\n** This function copies all such b-tree pages to new locations, so that\n** they can be modified as required.\n**\n** The complication is that not all database pages are the same size - due\n** to the way the file.c module works some (the first and last in each block)\n** are 4 bytes smaller than the others.\n*/\nstatic int mergeWorkerMoveHierarchy(\n  MergeWorker *pMW,               /* Merge worker */\n  int bSep                        /* True for separators run */\n){\n  lsm_db *pDb = pMW->pDb;         /* Database handle */\n  int rc = LSM_OK;                /* Return code */\n  int i;\n  Page **apHier = pMW->hier.apHier;\n  int nHier = pMW->hier.nHier;\n\n  for(i=0; rc==LSM_OK && i<nHier; i++){\n    Page *pNew = 0;\n    rc = lsmFsSortedAppend(pDb->pFS, pDb->pWorker, pMW->pLevel, 1, &pNew);\n    assert( rc==LSM_OK );\n\n    if( rc==LSM_OK ){\n      u8 *a1; int n1;\n      u8 *a2; int n2;\n\n      a1 = fsPageData(pNew, &n1);\n      a2 = fsPageData(apHier[i], &n2);\n\n      assert( n1==n2 || n1+4==n2 );\n\n      if( n1==n2 ){\n        memcpy(a1, a2, n2);\n      }else{\n        int nEntry = pageGetNRec(a2, n2);\n        int iEof1 = SEGMENT_EOF(n1, nEntry);\n        int iEof2 = SEGMENT_EOF(n2, nEntry);\n\n        memcpy(a1, a2, iEof2 - 4);\n        memcpy(&a1[iEof1], &a2[iEof2], n2 - iEof2);\n      }\n\n      lsmFsPageRelease(apHier[i]);\n      apHier[i] = pNew;\n\n#if 0\n      assert( n1==n2 || n1+4==n2 || n2+4==n1 );\n      if( n1>=n2 ){\n        /* If n1 (size of the new page) is equal to or greater than n2 (the\n        ** size of the old page), then copy the data into the new page. If\n        ** n1==n2, this could be done with a single memcpy(). However, \n        ** since sometimes n1>n2, the page content and footer must be copied \n        ** separately. */\n        int nEntry = pageGetNRec(a2, n2);\n        int iEof1 = SEGMENT_EOF(n1, nEntry);\n        int iEof2 = SEGMENT_EOF(n2, nEntry);\n        memcpy(a1, a2, iEof2);\n        memcpy(&a1[iEof1], &a2[iEof2], n2 - iEof2);\n        lsmFsPageRelease(apHier[i]);\n        apHier[i] = pNew;\n      }else{\n        lsmPutU16(&a1[SEGMENT_FLAGS_OFFSET(n1)], SEGMENT_BTREE_FLAG);\n        lsmPutU16(&a1[SEGMENT_NRECORD_OFFSET(n1)], 0);\n        lsmPutU64(&a1[SEGMENT_POINTER_OFFSET(n1)], 0);\n        i = i - 1;\n        lsmFsPageRelease(pNew);\n      }\n#endif\n    }\n  }\n\n#ifdef LSM_DEBUG\n  if( rc==LSM_OK ){\n    for(i=0; i<nHier; i++) assert( lsmFsPageWritable(apHier[i]) );\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Allocate and populate the MergeWorker.apHier[] array.\n*/\nstatic int mergeWorkerLoadHierarchy(MergeWorker *pMW){\n  int rc = LSM_OK;\n  Segment *pSeg;\n  Hierarchy *p;\n \n  pSeg = &pMW->pLevel->lhs;\n  p = &pMW->hier;\n\n  if( p->apHier==0 && pSeg->iRoot!=0 ){\n    FileSystem *pFS = pMW->pDb->pFS;\n    lsm_env *pEnv = pMW->pDb->pEnv;\n    Page **apHier = 0;\n    int nHier = 0;\n    int iPg = (int)pSeg->iRoot;\n\n    do {\n      Page *pPg = 0;\n      u8 *aData;\n      int nData;\n      int flags;\n\n      rc = lsmFsDbPageGet(pFS, pSeg, iPg, &pPg);\n      if( rc!=LSM_OK ) break;\n\n      aData = fsPageData(pPg, &nData);\n      flags = pageGetFlags(aData, nData);\n      if( flags&SEGMENT_BTREE_FLAG ){\n        Page **apNew = (Page **)lsmRealloc(\n            pEnv, apHier, sizeof(Page *)*(nHier+1)\n        );\n        if( apNew==0 ){\n          rc = LSM_NOMEM_BKPT;\n          break;\n        }\n        apHier = apNew;\n        memmove(&apHier[1], &apHier[0], sizeof(Page *) * nHier);\n        nHier++;\n\n        apHier[0] = pPg;\n        iPg = (int)pageGetPtr(aData, nData);\n      }else{\n        lsmFsPageRelease(pPg);\n        break;\n      }\n    }while( 1 );\n\n    if( rc==LSM_OK ){\n      u8 *aData;\n      int nData;\n      aData = fsPageData(apHier[0], &nData);\n      pMW->aSave[0].iPgno = pageGetPtr(aData, nData);\n      p->nHier = nHier;\n      p->apHier = apHier;\n      rc = mergeWorkerMoveHierarchy(pMW, 0);\n    }else{\n      int i;\n      for(i=0; i<nHier; i++){\n        lsmFsPageRelease(apHier[i]);\n      }\n      lsmFree(pEnv, apHier);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** B-tree pages use almost the same format as regular pages. The \n** differences are:\n**\n**   1. The record format is (usually, see below) as follows:\n**\n**         + Type byte (always SORTED_SEPARATOR or SORTED_SYSTEM_SEPARATOR),\n**         + Absolute pointer value (varint),\n**         + Number of bytes in key (varint),\n**         + Blob containing key data.\n**\n**   2. All pointer values are stored as absolute values (not offsets \n**      relative to the footer pointer value).\n**\n**   3. Each pointer that is part of a record points to a page that \n**      contains keys smaller than the records key (note: not \"equal to or\n**      smaller than - smaller than\").\n**\n**   4. The pointer in the page footer of a b-tree page points to a page\n**      that contains keys equal to or larger than the largest key on the\n**      b-tree page.\n**\n** The reason for having the page footer pointer point to the right-child\n** (instead of the left) is that doing things this way makes the \n** mergeWorkerMoveHierarchy() operation less complicated (since the pointers \n** that need to be updated are all stored as fixed-size integers within the \n** page footer, not varints in page records).\n**\n** Records may not span b-tree pages. If this function is called to add a\n** record larger than (page-size / 4) bytes, then a pointer to the indexed\n** array page that contains the main record is added to the b-tree instead.\n** In this case the record format is:\n**\n**         + 0x00 byte (1 byte) \n**         + Absolute pointer value (varint),\n**         + Absolute page number of page containing key (varint).\n**\n** See function seekInBtree() for the code that traverses b-tree pages.\n*/\n\nstatic int mergeWorkerBtreeWrite(\n  MergeWorker *pMW,\n  u8 eType,\n  Pgno iPtr,\n  Pgno iKeyPg,\n  void *pKey,\n  int nKey\n){\n  Hierarchy *p = &pMW->hier;\n  lsm_db *pDb = pMW->pDb;         /* Database handle */\n  int rc = LSM_OK;                /* Return Code */\n  int iLevel;                     /* Level of b-tree hierachy to write to */\n  int nData;                      /* Size of aData[] in bytes */\n  u8 *aData;                      /* Page data for level iLevel */\n  int iOff;                       /* Offset on b-tree page to write record to */\n  int nRec;                       /* Initial number of records on b-tree page */\n\n  /* iKeyPg should be zero for an ordinary b-tree key, or non-zero for an\n  ** indirect key. The flags byte for an indirect key is 0x00.  */\n  assert( (eType==0)==(iKeyPg!=0) );\n\n  /* The MergeWorker.apHier[] array contains the right-most leaf of the b-tree\n  ** hierarchy, the root node, and all nodes that lie on the path between.\n  ** apHier[0] is the right-most leaf and apHier[pMW->nHier-1] is the current\n  ** root page.\n  **\n  ** This loop searches for a node with enough space to store the key on,\n  ** starting with the leaf and iterating up towards the root. When the loop\n  ** exits, the key may be written to apHier[iLevel].  */\n  for(iLevel=0; iLevel<=p->nHier; iLevel++){\n    int nByte;                    /* Number of free bytes required */\n\n    if( iLevel==p->nHier ){\n      /* Extend the array and allocate a new root page. */\n      Page **aNew;\n      aNew = (Page **)lsmRealloc(\n          pMW->pDb->pEnv, p->apHier, sizeof(Page *)*(p->nHier+1)\n      );\n      if( !aNew ){\n        return LSM_NOMEM_BKPT;\n      }\n      p->apHier = aNew;\n    }else{\n      Page *pOld;\n      int nFree;\n\n      /* If the key will fit on this page, break out of the loop here.\n      ** The new entry will be written to page apHier[iLevel]. */\n      pOld = p->apHier[iLevel];\n      assert( lsmFsPageWritable(pOld) );\n      aData = fsPageData(pOld, &nData);\n      if( eType==0 ){\n        nByte = 2 + 1 + lsmVarintLen32((int)iPtr) + lsmVarintLen32((int)iKeyPg);\n      }else{\n        nByte = 2 + 1 + lsmVarintLen32((int)iPtr) + lsmVarintLen32(nKey) + nKey;\n      }\n      nRec = pageGetNRec(aData, nData);\n      nFree = SEGMENT_EOF(nData, nRec) - mergeWorkerPageOffset(aData, nData);\n      if( nByte<=nFree ) break;\n\n      /* Otherwise, this page is full. Set the right-hand-child pointer\n      ** to iPtr and release it.  */\n      lsmPutU64(&aData[SEGMENT_POINTER_OFFSET(nData)], iPtr);\n      assert( lsmFsPageNumber(pOld)==0 );\n      rc = lsmFsPagePersist(pOld);\n      if( rc==LSM_OK ){\n        iPtr = lsmFsPageNumber(pOld);\n        lsmFsPageRelease(pOld);\n      }\n    }\n\n    /* Allocate a new page for apHier[iLevel]. */\n    p->apHier[iLevel] = 0;\n    if( rc==LSM_OK ){\n      rc = lsmFsSortedAppend(\n          pDb->pFS, pDb->pWorker, pMW->pLevel, 1, &p->apHier[iLevel]\n      );\n    }\n    if( rc!=LSM_OK ) return rc;\n\n    aData = fsPageData(p->apHier[iLevel], &nData);\n    memset(aData, 0, nData);\n    lsmPutU16(&aData[SEGMENT_FLAGS_OFFSET(nData)], SEGMENT_BTREE_FLAG);\n    lsmPutU16(&aData[SEGMENT_NRECORD_OFFSET(nData)], 0);\n\n    if( iLevel==p->nHier ){\n      p->nHier++;\n      break;\n    }\n  }\n\n  /* Write the key into page apHier[iLevel]. */\n  aData = fsPageData(p->apHier[iLevel], &nData);\n  iOff = mergeWorkerPageOffset(aData, nData);\n  nRec = pageGetNRec(aData, nData);\n  lsmPutU16(&aData[SEGMENT_CELLPTR_OFFSET(nData, nRec)], (u16)iOff);\n  lsmPutU16(&aData[SEGMENT_NRECORD_OFFSET(nData)], (u16)(nRec+1));\n  if( eType==0 ){\n    aData[iOff++] = 0x00;\n    iOff += lsmVarintPut32(&aData[iOff], (int)iPtr);\n    iOff += lsmVarintPut32(&aData[iOff], (int)iKeyPg);\n  }else{\n    aData[iOff++] = eType;\n    iOff += lsmVarintPut32(&aData[iOff], (int)iPtr);\n    iOff += lsmVarintPut32(&aData[iOff], nKey);\n    memcpy(&aData[iOff], pKey, nKey);\n  }\n\n  return rc;\n}\n\nstatic int mergeWorkerBtreeIndirect(MergeWorker *pMW){\n  int rc = LSM_OK;\n  if( pMW->iIndirect ){\n    Pgno iKeyPg = pMW->aSave[1].iPgno;\n    rc = mergeWorkerBtreeWrite(pMW, 0, pMW->iIndirect, iKeyPg, 0, 0);\n    pMW->iIndirect = 0;\n  }\n  return rc;\n}\n\n/*\n** Append the database key (iTopic/pKey/nKey) to the b-tree under \n** construction. This key has not yet been written to a segment page.\n** The pointer that will accompany the new key in the b-tree - that\n** points to the completed segment page that contains keys smaller than\n** (pKey/nKey) is currently stored in pMW->aSave[0].iPgno.\n*/\nstatic int mergeWorkerPushHierarchy(\n  MergeWorker *pMW,               /* Merge worker object */\n  int iTopic,                     /* Topic value for this key */\n  void *pKey,                     /* Pointer to key buffer */\n  int nKey                        /* Size of pKey buffer in bytes */\n){\n  int rc = LSM_OK;                /* Return Code */\n  Pgno iPtr;                      /* Pointer value to accompany pKey/nKey */\n\n  assert( pMW->aSave[0].bStore==0 );\n  assert( pMW->aSave[1].bStore==0 );\n  rc = mergeWorkerBtreeIndirect(pMW);\n\n  /* Obtain the absolute pointer value to store along with the key in the\n  ** page body. This pointer points to a page that contains keys that are\n  ** smaller than pKey/nKey.  */\n  iPtr = pMW->aSave[0].iPgno;\n  assert( iPtr!=0 );\n\n  /* Determine if the indirect format should be used. */\n  if( (nKey*4 > lsmFsPageSize(pMW->pDb->pFS)) ){\n    pMW->iIndirect = iPtr;\n    pMW->aSave[1].bStore = 1;\n  }else{\n    rc = mergeWorkerBtreeWrite(\n        pMW, (u8)(iTopic | LSM_SEPARATOR), iPtr, 0, pKey, nKey\n    );\n  }\n\n  /* Ensure that the SortedRun.iRoot field is correct. */\n  return rc;\n}\n\nstatic int mergeWorkerFinishHierarchy(\n  MergeWorker *pMW                /* Merge worker object */\n){\n  int i;                          /* Used to loop through apHier[] */\n  int rc = LSM_OK;                /* Return code */\n  Pgno iPtr;                      /* New right-hand-child pointer value */\n\n  iPtr = pMW->aSave[0].iPgno;\n  for(i=0; i<pMW->hier.nHier && rc==LSM_OK; i++){\n    Page *pPg = pMW->hier.apHier[i];\n    int nData;                    /* Size of aData[] in bytes */\n    u8 *aData;                    /* Page data for pPg */\n\n    aData = fsPageData(pPg, &nData);\n    lsmPutU64(&aData[SEGMENT_POINTER_OFFSET(nData)], iPtr);\n\n    rc = lsmFsPagePersist(pPg);\n    iPtr = lsmFsPageNumber(pPg);\n    lsmFsPageRelease(pPg);\n  }\n\n  if( pMW->hier.nHier ){\n    pMW->pLevel->lhs.iRoot = iPtr;\n    lsmFree(pMW->pDb->pEnv, pMW->hier.apHier);\n    pMW->hier.apHier = 0;\n    pMW->hier.nHier = 0;\n  }\n\n  return rc;\n}\n\nstatic int mergeWorkerAddPadding(\n  MergeWorker *pMW                /* Merge worker object */\n){\n  FileSystem *pFS = pMW->pDb->pFS;\n  return lsmFsSortedPadding(pFS, pMW->pDb->pWorker, &pMW->pLevel->lhs);\n}\n\n/*\n** Release all page references currently held by the merge-worker passed\n** as the only argument. Unless an error has occurred, all pages have\n** already been released.\n*/\nstatic void mergeWorkerReleaseAll(MergeWorker *pMW){\n  int i;\n  lsmFsPageRelease(pMW->pPage);\n  pMW->pPage = 0;\n\n  for(i=0; i<pMW->hier.nHier; i++){\n    lsmFsPageRelease(pMW->hier.apHier[i]);\n    pMW->hier.apHier[i] = 0;\n  }\n  lsmFree(pMW->pDb->pEnv, pMW->hier.apHier);\n  pMW->hier.apHier = 0;\n  pMW->hier.nHier = 0;\n}\n\nstatic int keyszToSkip(FileSystem *pFS, int nKey){\n  int nPgsz;                /* Nominal database page size */\n  nPgsz = lsmFsPageSize(pFS);\n  return LSM_MIN(((nKey * 4) / nPgsz), 3);\n}\n\n/*\n** Release the reference to the current output page of merge-worker *pMW\n** (reference pMW->pPage). Set the page number values in aSave[] as \n** required (see comments above struct MergeWorker for details).\n*/\nstatic int mergeWorkerPersistAndRelease(MergeWorker *pMW){\n  int rc;\n  int i;\n\n  assert( pMW->pPage || (pMW->aSave[0].bStore==0 && pMW->aSave[1].bStore==0) );\n\n  /* Persist the page */\n  rc = lsmFsPagePersist(pMW->pPage);\n\n  /* If required, save the page number. */\n  for(i=0; i<2; i++){\n    if( pMW->aSave[i].bStore ){\n      pMW->aSave[i].iPgno = lsmFsPageNumber(pMW->pPage);\n      pMW->aSave[i].bStore = 0;\n    }\n  }\n\n  /* Release the completed output page. */\n  lsmFsPageRelease(pMW->pPage);\n  pMW->pPage = 0;\n  return rc;\n}\n\n/*\n** Advance to the next page of an output run being populated by merge-worker\n** pMW. The footer of the new page is initialized to indicate that it contains\n** zero records. The flags field is cleared. The page footer pointer field\n** is set to iFPtr.\n**\n** If successful, LSM_OK is returned. Otherwise, an error code.\n*/\nstatic int mergeWorkerNextPage(\n  MergeWorker *pMW,               /* Merge worker object to append page to */\n  Pgno iFPtr                      /* Pointer value for footer of new page */\n){\n  int rc = LSM_OK;                /* Return code */\n  Page *pNext = 0;                /* New page appended to run */\n  lsm_db *pDb = pMW->pDb;         /* Database handle */\n\n  rc = lsmFsSortedAppend(pDb->pFS, pDb->pWorker, pMW->pLevel, 0, &pNext);\n  assert( rc || pMW->pLevel->lhs.iFirst>0 || pMW->pDb->compress.xCompress );\n\n  if( rc==LSM_OK ){\n    u8 *aData;                    /* Data buffer belonging to page pNext */\n    int nData;                    /* Size of aData[] in bytes */\n\n    rc = mergeWorkerPersistAndRelease(pMW);\n\n    pMW->pPage = pNext;\n    pMW->pLevel->pMerge->iOutputOff = 0;\n    aData = fsPageData(pNext, &nData);\n    lsmPutU16(&aData[SEGMENT_NRECORD_OFFSET(nData)], 0);\n    lsmPutU16(&aData[SEGMENT_FLAGS_OFFSET(nData)], 0);\n    lsmPutU64(&aData[SEGMENT_POINTER_OFFSET(nData)], iFPtr);\n    pMW->nWork++;\n  }\n\n  return rc;\n}\n\n/*\n** Write a blob of data into an output segment being populated by a \n** merge-worker object. If argument bSep is true, write into the separators\n** array. Otherwise, the main array.\n**\n** This function is used to write the blobs of data for keys and values.\n*/\nstatic int mergeWorkerData(\n  MergeWorker *pMW,               /* Merge worker object */\n  int bSep,                       /* True to write to separators run */\n  int iFPtr,                      /* Footer ptr for new pages */\n  u8 *aWrite,                     /* Write data from this buffer */\n  int nWrite                      /* Size of aWrite[] in bytes */\n){\n  int rc = LSM_OK;                /* Return code */\n  int nRem = nWrite;              /* Number of bytes still to write */\n\n  while( rc==LSM_OK && nRem>0 ){\n    Merge *pMerge = pMW->pLevel->pMerge;\n    int nCopy;                    /* Number of bytes to copy */\n    u8 *aData;                    /* Pointer to buffer of current output page */\n    int nData;                    /* Size of aData[] in bytes */\n    int nRec;                     /* Number of records on current output page */\n    int iOff;                     /* Offset in aData[] to write to */\n\n    assert( lsmFsPageWritable(pMW->pPage) );\n   \n    aData = fsPageData(pMW->pPage, &nData);\n    nRec = pageGetNRec(aData, nData);\n    iOff = pMerge->iOutputOff;\n    nCopy = LSM_MIN(nRem, SEGMENT_EOF(nData, nRec) - iOff);\n\n    memcpy(&aData[iOff], &aWrite[nWrite-nRem], nCopy);\n    nRem -= nCopy;\n\n    if( nRem>0 ){\n      rc = mergeWorkerNextPage(pMW, iFPtr);\n    }else{\n      pMerge->iOutputOff = iOff + nCopy;\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** The MergeWorker passed as the only argument is working to merge two or\n** more existing segments together (not to flush an in-memory tree). It\n** has not yet written the first key to the first page of the output.\n*/\nstatic int mergeWorkerFirstPage(MergeWorker *pMW){\n  int rc = LSM_OK;                /* Return code */\n  Page *pPg = 0;                  /* First page of run pSeg */\n  int iFPtr = 0;                  /* Pointer value read from footer of pPg */\n  MultiCursor *pCsr = pMW->pCsr;\n\n  assert( pMW->pPage==0 );\n\n  if( pCsr->pBtCsr ){\n    rc = LSM_OK;\n    iFPtr = (int)pMW->pLevel->pNext->lhs.iFirst;\n  }else if( pCsr->nPtr>0 ){\n    Segment *pSeg;\n    pSeg = pCsr->aPtr[pCsr->nPtr-1].pSeg;\n    rc = lsmFsDbPageGet(pMW->pDb->pFS, pSeg, pSeg->iFirst, &pPg);\n    if( rc==LSM_OK ){\n      u8 *aData;                    /* Buffer for page pPg */\n      int nData;                    /* Size of aData[] in bytes */\n      aData = fsPageData(pPg, &nData);\n      iFPtr = (int)pageGetPtr(aData, nData);\n      lsmFsPageRelease(pPg);\n    }\n  }\n\n  if( rc==LSM_OK ){\n    rc = mergeWorkerNextPage(pMW, iFPtr);\n    if( pCsr->pPrevMergePtr ) *pCsr->pPrevMergePtr = iFPtr;\n    pMW->aSave[0].bStore = 1;\n  }\n\n  return rc;\n}\n\nstatic int mergeWorkerWrite(\n  MergeWorker *pMW,               /* Merge worker object to write into */\n  int eType,                      /* One of SORTED_SEPARATOR, WRITE or DELETE */\n  void *pKey, int nKey,           /* Key value */\n  void *pVal, int nVal,           /* Value value */\n  int iPtr                        /* Absolute value of page pointer, or 0 */\n){\n  int rc = LSM_OK;                /* Return code */\n  Merge *pMerge;                  /* Persistent part of level merge state */\n  int nHdr;                       /* Space required for this record header */\n  Page *pPg;                      /* Page to write to */\n  u8 *aData;                      /* Data buffer for page pWriter->pPage */\n  int nData = 0;                  /* Size of buffer aData[] in bytes */\n  int nRec = 0;                   /* Number of records on page pPg */\n  int iFPtr = 0;                  /* Value of pointer in footer of pPg */\n  int iRPtr = 0;                  /* Value of pointer written into record */\n  int iOff = 0;                   /* Current write offset within page pPg */\n  Segment *pSeg;                  /* Segment being written */\n  int flags = 0;                  /* If != 0, flags value for page footer */\n  int bFirst = 0;                 /* True for first key of output run */\n\n  pMerge = pMW->pLevel->pMerge;    \n  pSeg = &pMW->pLevel->lhs;\n\n  if( pSeg->iFirst==0 && pMW->pPage==0 ){\n    rc = mergeWorkerFirstPage(pMW);\n    bFirst = 1;\n  }\n  pPg = pMW->pPage;\n  if( pPg ){\n    aData = fsPageData(pPg, &nData);\n    nRec = pageGetNRec(aData, nData);\n    iFPtr = (int)pageGetPtr(aData, nData);\n    iRPtr = iPtr - iFPtr;\n  }\n     \n  /* Figure out how much space is required by the new record. The space\n  ** required is divided into two sections: the header and the body. The\n  ** header consists of the intial varint fields. The body are the blobs \n  ** of data that correspond to the key and value data. The entire header \n  ** must be stored on the page. The body may overflow onto the next and\n  ** subsequent pages.\n  **\n  ** The header space is:\n  **\n  **     1) record type - 1 byte.\n  **     2) Page-pointer-offset - 1 varint\n  **     3) Key size - 1 varint\n  **     4) Value size - 1 varint (only if LSM_INSERT flag is set)\n  */\n  if( rc==LSM_OK ){\n    nHdr = 1 + lsmVarintLen32(iRPtr) + lsmVarintLen32(nKey);\n    if( rtIsWrite(eType) ) nHdr += lsmVarintLen32(nVal);\n\n    /* If the entire header will not fit on page pPg, or if page pPg is \n    ** marked read-only, advance to the next page of the output run. */\n    iOff = pMerge->iOutputOff;\n    if( iOff<0 || pPg==0 || iOff+nHdr > SEGMENT_EOF(nData, nRec+1) ){\n      iFPtr = (int)*pMW->pCsr->pPrevMergePtr;\n      iRPtr = iPtr - iFPtr;\n      iOff = 0;\n      nRec = 0;\n      rc = mergeWorkerNextPage(pMW, iFPtr);\n      pPg = pMW->pPage;\n    }\n  }\n\n  /* If this record header will be the first on the page, and the page is \n  ** not the very first in the entire run, add a copy of the key to the\n  ** b-tree hierarchy.\n  */\n  if( rc==LSM_OK && nRec==0 && bFirst==0 ){\n    assert( pMerge->nSkip>=0 );\n\n    if( pMerge->nSkip==0 ){\n      rc = mergeWorkerPushHierarchy(pMW, rtTopic(eType), pKey, nKey);\n      assert( pMW->aSave[0].bStore==0 );\n      pMW->aSave[0].bStore = 1;\n      pMerge->nSkip = keyszToSkip(pMW->pDb->pFS, nKey);\n    }else{\n      pMerge->nSkip--;\n      flags = PGFTR_SKIP_THIS_FLAG;\n    }\n\n    if( pMerge->nSkip ) flags |= PGFTR_SKIP_NEXT_FLAG;\n  }\n\n  /* Update the output segment */\n  if( rc==LSM_OK ){\n    aData = fsPageData(pPg, &nData);\n\n    /* Update the page footer. */\n    lsmPutU16(&aData[SEGMENT_NRECORD_OFFSET(nData)], (u16)(nRec+1));\n    lsmPutU16(&aData[SEGMENT_CELLPTR_OFFSET(nData, nRec)], (u16)iOff);\n    if( flags ) lsmPutU16(&aData[SEGMENT_FLAGS_OFFSET(nData)], (u16)flags);\n\n    /* Write the entry header into the current page. */\n    aData[iOff++] = (u8)eType;                                           /* 1 */\n    iOff += lsmVarintPut32(&aData[iOff], iRPtr);                         /* 2 */\n    iOff += lsmVarintPut32(&aData[iOff], nKey);                          /* 3 */\n    if( rtIsWrite(eType) ) iOff += lsmVarintPut32(&aData[iOff], nVal);   /* 4 */\n    pMerge->iOutputOff = iOff;\n\n    /* Write the key and data into the segment. */\n    assert( iFPtr==pageGetPtr(aData, nData) );\n    rc = mergeWorkerData(pMW, 0, iFPtr+iRPtr, pKey, nKey);\n    if( rc==LSM_OK && rtIsWrite(eType) ){\n      if( rc==LSM_OK ){\n        rc = mergeWorkerData(pMW, 0, iFPtr+iRPtr, pVal, nVal);\n      }\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** Free all resources allocated by mergeWorkerInit().\n*/\nstatic void mergeWorkerShutdown(MergeWorker *pMW, int *pRc){\n  int i;                          /* Iterator variable */\n  int rc = *pRc;\n  MultiCursor *pCsr = pMW->pCsr;\n\n  /* Unless the merge has finished, save the cursor position in the\n  ** Merge.aInput[] array. See function mergeWorkerInit() for the \n  ** code to restore a cursor position based on aInput[].  */\n  if( rc==LSM_OK && pCsr && lsmMCursorValid(pCsr) ){\n    Merge *pMerge = pMW->pLevel->pMerge;\n    int bBtree = (pCsr->pBtCsr!=0);\n    int iPtr;\n\n    /* pMerge->nInput==0 indicates that this is a FlushTree() operation. */\n    assert( pMerge->nInput==0 || pMW->pLevel->nRight>0 );\n    assert( pMerge->nInput==0 || pMerge->nInput==(pCsr->nPtr+bBtree) );\n\n    for(i=0; i<(pMerge->nInput-bBtree); i++){\n      SegmentPtr *pPtr = &pCsr->aPtr[i];\n      if( pPtr->pPg ){\n        pMerge->aInput[i].iPg = lsmFsPageNumber(pPtr->pPg);\n        pMerge->aInput[i].iCell = pPtr->iCell;\n      }else{\n        pMerge->aInput[i].iPg = 0;\n        pMerge->aInput[i].iCell = 0;\n      }\n    }\n    if( bBtree && pMerge->nInput ){\n      assert( i==pCsr->nPtr );\n      btreeCursorPosition(pCsr->pBtCsr, &pMerge->aInput[i]);\n    }\n\n    /* Store the location of the split-key */\n    iPtr = pCsr->aTree[1] - CURSOR_DATA_SEGMENT;\n    if( iPtr<pCsr->nPtr ){\n      pMerge->splitkey = pMerge->aInput[iPtr];\n    }else{\n      btreeCursorSplitkey(pCsr->pBtCsr, &pMerge->splitkey);\n    }\n    \n    pMerge->iOutputOff = -1;\n  }\n\n  lsmMCursorClose(pCsr, 0);\n\n  /* Persist and release the output page. */\n  if( rc==LSM_OK ) rc = mergeWorkerPersistAndRelease(pMW);\n  if( rc==LSM_OK ) rc = mergeWorkerBtreeIndirect(pMW);\n  if( rc==LSM_OK ) rc = mergeWorkerFinishHierarchy(pMW);\n  if( rc==LSM_OK ) rc = mergeWorkerAddPadding(pMW);\n  lsmFsFlushWaiting(pMW->pDb->pFS, &rc);\n  mergeWorkerReleaseAll(pMW);\n\n  lsmFree(pMW->pDb->pEnv, pMW->aGobble);\n  pMW->aGobble = 0;\n  pMW->pCsr = 0;\n\n  *pRc = rc;\n}\n\n/*\n** The cursor passed as the first argument is being used as the input for\n** a merge operation. When this function is called, *piFlags contains the\n** database entry flags for the current entry. The entry about to be written\n** to the output.\n**\n** Note that this function only has to work for cursors configured to \n** iterate forwards (not backwards).\n*/\nstatic void mergeRangeDeletes(MultiCursor *pCsr, int *piVal, int *piFlags){\n  int f = *piFlags;\n  int iKey = pCsr->aTree[1];\n  int i;\n\n  assert( pCsr->flags & CURSOR_NEXT_OK );\n  if( pCsr->flags & CURSOR_IGNORE_DELETE ){\n    /* The ignore-delete flag is set when the output of the merge will form\n    ** the oldest level in the database. In this case there is no point in\n    ** retaining any range-delete flags.  */\n    assert( (f & LSM_POINT_DELETE)==0 );\n    f &= ~(LSM_START_DELETE|LSM_END_DELETE);\n  }else{\n    for(i=0; i<(CURSOR_DATA_SEGMENT + pCsr->nPtr); i++){\n      if( i!=iKey ){\n        int eType;\n        void *pKey;\n        int nKey;\n        int res;\n        multiCursorGetKey(pCsr, i, &eType, &pKey, &nKey);\n\n        if( pKey ){\n          res = sortedKeyCompare(pCsr->pDb->xCmp, \n              rtTopic(pCsr->eType), pCsr->key.pData, pCsr->key.nData,\n              rtTopic(eType), pKey, nKey\n          );\n          assert( res<=0 );\n          if( res==0 ){\n            if( (f & (LSM_INSERT|LSM_POINT_DELETE))==0 ){\n              if( eType & LSM_INSERT ){\n                f |= LSM_INSERT;\n                *piVal = i;\n              }\n              else if( eType & LSM_POINT_DELETE ){\n                f |= LSM_POINT_DELETE;\n              }\n            }\n            f |= (eType & (LSM_END_DELETE|LSM_START_DELETE));\n          }\n\n          if( i>iKey && (eType & LSM_END_DELETE) && res<0 ){\n            if( f & (LSM_INSERT|LSM_POINT_DELETE) ){\n              f |= (LSM_END_DELETE|LSM_START_DELETE);\n            }else{\n              f = 0;\n            }\n            break;\n          }\n        }\n      }\n    }\n\n    assert( (f & LSM_INSERT)==0 || (f & LSM_POINT_DELETE)==0 );\n    if( (f & LSM_START_DELETE) \n     && (f & LSM_END_DELETE) \n     && (f & LSM_POINT_DELETE )\n    ){\n      f = 0;\n    }\n  }\n\n  *piFlags = f;\n}\n\nstatic int mergeWorkerStep(MergeWorker *pMW){\n  lsm_db *pDb = pMW->pDb;       /* Database handle */\n  MultiCursor *pCsr;            /* Cursor to read input data from */\n  int rc = LSM_OK;              /* Return code */\n  int eType;                    /* SORTED_SEPARATOR, WRITE or DELETE */\n  void *pKey; int nKey;         /* Key */\n  Pgno iPtr;\n  int iVal;\n\n  pCsr = pMW->pCsr;\n\n  /* Pull the next record out of the source cursor. */\n  lsmMCursorKey(pCsr, &pKey, &nKey);\n  eType = pCsr->eType;\n\n  /* Figure out if the output record may have a different pointer value\n  ** than the previous. This is the case if the current key is identical to\n  ** a key that appears in the lowest level run being merged. If so, set \n  ** iPtr to the absolute pointer value. If not, leave iPtr set to zero, \n  ** indicating that the output pointer value should be a copy of the pointer \n  ** value written with the previous key.  */\n  iPtr = (pCsr->pPrevMergePtr ? *pCsr->pPrevMergePtr : 0);\n  if( pCsr->pBtCsr ){\n    BtreeCursor *pBtCsr = pCsr->pBtCsr;\n    if( pBtCsr->pKey ){\n      int res = rtTopic(pBtCsr->eType) - rtTopic(eType);\n      if( res==0 ) res = pDb->xCmp(pBtCsr->pKey, pBtCsr->nKey, pKey, nKey);\n      if( 0==res ) iPtr = pBtCsr->iPtr;\n      assert( res>=0 );\n    }\n  }else if( pCsr->nPtr ){\n    SegmentPtr *pPtr = &pCsr->aPtr[pCsr->nPtr-1];\n    if( pPtr->pPg\n     && 0==pDb->xCmp(pPtr->pKey, pPtr->nKey, pKey, nKey)\n    ){\n      iPtr = pPtr->iPtr+pPtr->iPgPtr;\n    }\n  }\n\n  iVal = pCsr->aTree[1];\n  mergeRangeDeletes(pCsr, &iVal, &eType);\n\n  if( eType!=0 ){\n    if( pMW->aGobble ){\n      int iGobble = pCsr->aTree[1] - CURSOR_DATA_SEGMENT;\n      if( iGobble<pCsr->nPtr && iGobble>=0 ){\n        SegmentPtr *pGobble = &pCsr->aPtr[iGobble];\n        if( (pGobble->flags & PGFTR_SKIP_THIS_FLAG)==0 ){\n          pMW->aGobble[iGobble] = lsmFsPageNumber(pGobble->pPg);\n        }\n      }\n    }\n\n    /* If this is a separator key and we know that the output pointer has not\n    ** changed, there is no point in writing an output record. Otherwise,\n    ** proceed. */\n    if( rc==LSM_OK && (rtIsSeparator(eType)==0 || iPtr!=0) ){\n      /* Write the record into the main run. */\n      void *pVal; int nVal;\n      rc = multiCursorGetVal(pCsr, iVal, &pVal, &nVal);\n      if( pVal && rc==LSM_OK ){\n        assert( nVal>=0 );\n        rc = sortedBlobSet(pDb->pEnv, &pCsr->val, pVal, nVal);\n        pVal = pCsr->val.pData;\n      }\n      if( rc==LSM_OK ){\n        rc = mergeWorkerWrite(pMW, eType, pKey, nKey, pVal, nVal, (int)iPtr);\n      }\n    }\n  }\n\n  /* Advance the cursor to the next input record (assuming one exists). */\n  assert( lsmMCursorValid(pMW->pCsr) );\n  if( rc==LSM_OK ) rc = lsmMCursorNext(pMW->pCsr);\n\n  return rc;\n}\n\nstatic int mergeWorkerDone(MergeWorker *pMW){\n  return pMW->pCsr==0 || !lsmMCursorValid(pMW->pCsr);\n}\n\nstatic void sortedFreeLevel(lsm_env *pEnv, Level *p){\n  if( p ){\n    lsmFree(pEnv, p->pSplitKey);\n    lsmFree(pEnv, p->pMerge);\n    lsmFree(pEnv, p->aRhs);\n    lsmFree(pEnv, p);\n  }\n}\n\nstatic void sortedInvokeWorkHook(lsm_db *pDb){\n  if( pDb->xWork ){\n    pDb->xWork(pDb, pDb->pWorkCtx);\n  }\n}\n\nstatic int sortedNewToplevel(\n  lsm_db *pDb,                    /* Connection handle */\n  int eTree,                      /* One of the TREE_XXX constants */\n  int *pnWrite                    /* OUT: Number of database pages written */\n){\n  int rc = LSM_OK;                /* Return Code */\n  MultiCursor *pCsr = 0;\n  Level *pNext = 0;               /* The current top level */\n  Level *pNew;                    /* The new level itself */\n  Segment *pLinked = 0;           /* Delete separators from this segment */\n  Level *pDel = 0;                /* Delete this entire level */\n  int nWrite = 0;                 /* Number of database pages written */\n  Freelist freelist;\n\n  if( eTree!=TREE_NONE ){\n    rc = lsmShmCacheChunks(pDb, pDb->treehdr.nChunk);\n  }\n\n  assert( pDb->bUseFreelist==0 );\n  pDb->pFreelist = &freelist;\n  pDb->bUseFreelist = 1;\n  memset(&freelist, 0, sizeof(freelist));\n\n  /* Allocate the new level structure to write to. */\n  pNext = lsmDbSnapshotLevel(pDb->pWorker);\n  pNew = (Level *)lsmMallocZeroRc(pDb->pEnv, sizeof(Level), &rc);\n  if( pNew ){\n    pNew->pNext = pNext;\n    lsmDbSnapshotSetLevel(pDb->pWorker, pNew);\n  }\n\n  /* Create a cursor to gather the data required by the new segment. The new\n  ** segment contains everything in the tree and pointers to the next segment\n  ** in the database (if any).  */\n  pCsr = multiCursorNew(pDb, &rc);\n  if( pCsr ){\n    pCsr->pDb = pDb;\n    rc = multiCursorVisitFreelist(pCsr);\n    if( rc==LSM_OK ){\n      rc = multiCursorAddTree(pCsr, pDb->pWorker, eTree);\n    }\n    if( rc==LSM_OK && pNext && pNext->pMerge==0 ){\n      if( (pNext->flags & LEVEL_FREELIST_ONLY) ){\n        pDel = pNext;\n        pCsr->aPtr = lsmMallocZeroRc(pDb->pEnv, sizeof(SegmentPtr), &rc);\n        multiCursorAddOne(pCsr, pNext, &rc);\n      }else if( eTree!=TREE_NONE && pNext->lhs.iRoot ){\n        pLinked = &pNext->lhs;\n        rc = btreeCursorNew(pDb, pLinked, &pCsr->pBtCsr);\n      }\n    }\n\n    /* If this will be the only segment in the database, discard any delete\n    ** markers present in the in-memory tree.  */\n    if( pNext==0 ){\n      multiCursorIgnoreDelete(pCsr);\n    }\n  }\n\n  if( rc!=LSM_OK ){\n    lsmMCursorClose(pCsr, 0);\n  }else{\n    Pgno iLeftPtr = 0;\n    Merge merge;                  /* Merge object used to create new level */\n    MergeWorker mergeworker;      /* MergeWorker object for the same purpose */\n\n    memset(&merge, 0, sizeof(Merge));\n    memset(&mergeworker, 0, sizeof(MergeWorker));\n\n    pNew->pMerge = &merge;\n    pNew->flags |= LEVEL_INCOMPLETE;\n    mergeworker.pDb = pDb;\n    mergeworker.pLevel = pNew;\n    mergeworker.pCsr = pCsr;\n    pCsr->pPrevMergePtr = &iLeftPtr;\n\n    /* Mark the separators array for the new level as a \"phantom\". */\n    mergeworker.bFlush = 1;\n\n    /* Do the work to create the new merged segment on disk */\n    if( rc==LSM_OK ) rc = lsmMCursorFirst(pCsr);\n    while( rc==LSM_OK && mergeWorkerDone(&mergeworker)==0 ){\n      rc = mergeWorkerStep(&mergeworker);\n    }\n    mergeWorkerShutdown(&mergeworker, &rc);\n    assert( rc!=LSM_OK || mergeworker.nWork==0 || pNew->lhs.iFirst );\n    if( rc==LSM_OK && pNew->lhs.iFirst ){\n      rc = lsmFsSortedFinish(pDb->pFS, &pNew->lhs);\n    }\n    nWrite = mergeworker.nWork;\n    pNew->flags &= ~LEVEL_INCOMPLETE;\n    if( eTree==TREE_NONE ){\n      pNew->flags |= LEVEL_FREELIST_ONLY;\n    }\n    pNew->pMerge = 0;\n  }\n\n  if( rc!=LSM_OK || pNew->lhs.iFirst==0 ){\n    assert( rc!=LSM_OK || pDb->pWorker->freelist.nEntry==0 );\n    lsmDbSnapshotSetLevel(pDb->pWorker, pNext);\n    sortedFreeLevel(pDb->pEnv, pNew);\n  }else{\n    if( pLinked ){\n      pLinked->iRoot = 0;\n    }else if( pDel ){\n      assert( pNew->pNext==pDel );\n      pNew->pNext = pDel->pNext;\n      lsmFsSortedDelete(pDb->pFS, pDb->pWorker, 1, &pDel->lhs);\n      sortedFreeLevel(pDb->pEnv, pDel);\n    }\n\n#if LSM_LOG_STRUCTURE\n    lsmSortedDumpStructure(pDb, pDb->pWorker, LSM_LOG_DATA, 0, \"new-toplevel\");\n#endif\n\n    if( freelist.nEntry ){\n      Freelist *p = &pDb->pWorker->freelist;\n      lsmFree(pDb->pEnv, p->aEntry);\n      memcpy(p, &freelist, sizeof(freelist));\n      freelist.aEntry = 0;\n    }else{\n      pDb->pWorker->freelist.nEntry = 0;\n    }\n\n    assertBtreeOk(pDb, &pNew->lhs);\n    sortedInvokeWorkHook(pDb);\n  }\n\n  if( pnWrite ) *pnWrite = nWrite;\n  pDb->pWorker->nWrite += nWrite;\n  pDb->pFreelist = 0;\n  pDb->bUseFreelist = 0;\n  lsmFree(pDb->pEnv, freelist.aEntry);\n  return rc;\n}\n\n/*\n** The nMerge levels in the LSM beginning with pLevel consist of a\n** left-hand-side segment only. Replace these levels with a single new\n** level consisting of a new empty segment on the left-hand-side and the\n** nMerge segments from the replaced levels on the right-hand-side.\n**\n** Also, allocate and populate a Merge object and set Level.pMerge to\n** point to it.\n*/\nstatic int sortedMergeSetup(\n  lsm_db *pDb,                    /* Database handle */\n  Level *pLevel,                  /* First level to merge */\n  int nMerge,                     /* Merge this many levels together */\n  Level **ppNew                   /* New, merged, level */\n){\n  int rc = LSM_OK;                /* Return Code */\n  Level *pNew;                    /* New Level object */\n  int bUseNext = 0;               /* True to link in next separators */\n  Merge *pMerge;                  /* New Merge object */\n  int nByte;                      /* Bytes of space allocated at pMerge */\n\n#ifdef LSM_DEBUG\n  int iLevel;\n  Level *pX = pLevel;\n  for(iLevel=0; iLevel<nMerge; iLevel++){\n    assert( pX->nRight==0 );\n    pX = pX->pNext;\n  }\n#endif\n\n  /* Allocate the new Level object */\n  pNew = (Level *)lsmMallocZeroRc(pDb->pEnv, sizeof(Level), &rc);\n  if( pNew ){\n    pNew->aRhs = (Segment *)lsmMallocZeroRc(pDb->pEnv, \n                                        nMerge * sizeof(Segment), &rc);\n  }\n\n  /* Populate the new Level object */\n  if( rc==LSM_OK ){\n    Level *pNext = 0;             /* Level following pNew */\n    int i;\n    int bFreeOnly = 1;\n    Level *pTopLevel;\n    Level *p = pLevel;\n    Level **pp;\n    pNew->nRight = nMerge;\n    pNew->iAge = pLevel->iAge+1;\n    for(i=0; i<nMerge; i++){\n      assert( p->nRight==0 );\n      pNext = p->pNext;\n      pNew->aRhs[i] = p->lhs;\n      if( (p->flags & LEVEL_FREELIST_ONLY)==0 ) bFreeOnly = 0;\n      sortedFreeLevel(pDb->pEnv, p);\n      p = pNext;\n    }\n\n    if( bFreeOnly ) pNew->flags |= LEVEL_FREELIST_ONLY;\n\n    /* Replace the old levels with the new. */\n    pTopLevel = lsmDbSnapshotLevel(pDb->pWorker);\n    pNew->pNext = p;\n    for(pp=&pTopLevel; *pp!=pLevel; pp=&((*pp)->pNext));\n    *pp = pNew;\n    lsmDbSnapshotSetLevel(pDb->pWorker, pTopLevel);\n\n    /* Determine whether or not the next separators will be linked in */\n    if( pNext && pNext->pMerge==0 && pNext->lhs.iRoot && pNext \n     && (bFreeOnly==0 || (pNext->flags & LEVEL_FREELIST_ONLY))\n    ){\n      bUseNext = 1;\n    }\n  }\n\n  /* Allocate the merge object */\n  nByte = sizeof(Merge) + sizeof(MergeInput) * (nMerge + bUseNext);\n  pMerge = (Merge *)lsmMallocZeroRc(pDb->pEnv, nByte, &rc);\n  if( pMerge ){\n    pMerge->aInput = (MergeInput *)&pMerge[1];\n    pMerge->nInput = nMerge + bUseNext;\n    pNew->pMerge = pMerge;\n  }\n\n  *ppNew = pNew;\n  return rc;\n}\n\nstatic int mergeWorkerInit(\n  lsm_db *pDb,                    /* Db connection to do merge work */\n  Level *pLevel,                  /* Level to work on merging */\n  MergeWorker *pMW                /* Object to initialize */\n){\n  int rc = LSM_OK;                /* Return code */\n  Merge *pMerge = pLevel->pMerge; /* Persistent part of merge state */\n  MultiCursor *pCsr = 0;          /* Cursor opened for pMW */\n  Level *pNext = pLevel->pNext;   /* Next level in LSM */\n\n  assert( pDb->pWorker );\n  assert( pLevel->pMerge );\n  assert( pLevel->nRight>0 );\n\n  memset(pMW, 0, sizeof(MergeWorker));\n  pMW->pDb = pDb;\n  pMW->pLevel = pLevel;\n  pMW->aGobble = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno) * pLevel->nRight, &rc);\n\n  /* Create a multi-cursor to read the data to write to the new\n  ** segment. The new segment contains:\n  **\n  **   1. Records from LHS of each of the nMerge levels being merged.\n  **   2. Separators from either the last level being merged, or the\n  **      separators attached to the LHS of the following level, or neither.\n  **\n  ** If the new level is the lowest (oldest) in the db, discard any\n  ** delete keys. Key annihilation.\n  */\n  pCsr = multiCursorNew(pDb, &rc);\n  if( pCsr ){\n    pCsr->flags |= CURSOR_NEXT_OK;\n    rc = multiCursorAddRhs(pCsr, pLevel);\n  }\n  if( rc==LSM_OK && pMerge->nInput > pLevel->nRight ){\n    rc = btreeCursorNew(pDb, &pNext->lhs, &pCsr->pBtCsr);\n  }else if( pNext ){\n    multiCursorReadSeparators(pCsr);\n  }else{\n    multiCursorIgnoreDelete(pCsr);\n  }\n\n  assert( rc!=LSM_OK || pMerge->nInput==(pCsr->nPtr+(pCsr->pBtCsr!=0)) );\n  pMW->pCsr = pCsr;\n\n  /* Load the b-tree hierarchy into memory. */\n  if( rc==LSM_OK ) rc = mergeWorkerLoadHierarchy(pMW);\n  if( rc==LSM_OK && pMW->hier.nHier==0 ){\n    pMW->aSave[0].iPgno = pLevel->lhs.iFirst;\n  }\n\n  /* Position the cursor. */\n  if( rc==LSM_OK ){\n    pCsr->pPrevMergePtr = &pMerge->iCurrentPtr;\n    if( pLevel->lhs.iFirst==0 ){\n      /* The output array is still empty. So position the cursor at the very \n      ** start of the input.  */\n      rc = multiCursorEnd(pCsr, 0);\n    }else{\n      /* The output array is non-empty. Position the cursor based on the\n      ** page/cell data saved in the Merge.aInput[] array.  */\n      int i;\n      for(i=0; rc==LSM_OK && i<pCsr->nPtr; i++){\n        MergeInput *pInput = &pMerge->aInput[i];\n        if( pInput->iPg ){\n          SegmentPtr *pPtr;\n          assert( pCsr->aPtr[i].pPg==0 );\n          pPtr = &pCsr->aPtr[i];\n          rc = segmentPtrLoadPage(pDb->pFS, pPtr, (int)pInput->iPg);\n          if( rc==LSM_OK && pPtr->nCell>0 ){\n            rc = segmentPtrLoadCell(pPtr, pInput->iCell);\n          }\n        }\n      }\n\n      if( rc==LSM_OK && pCsr->pBtCsr ){\n        int (*xCmp)(void *, int, void *, int) = pCsr->pDb->xCmp;\n        assert( i==pCsr->nPtr );\n        rc = btreeCursorRestore(pCsr->pBtCsr, xCmp, &pMerge->aInput[i]);\n      }\n\n      if( rc==LSM_OK ){\n        rc = multiCursorSetupTree(pCsr, 0);\n      }\n    }\n    pCsr->flags |= CURSOR_NEXT_OK;\n  }\n\n  return rc;\n}\n\nstatic int sortedBtreeGobble(\n  lsm_db *pDb,                    /* Worker connection */\n  MultiCursor *pCsr,              /* Multi-cursor being used for a merge */\n  int iGobble                     /* pCsr->aPtr[] entry to operate on */\n){\n  int rc = LSM_OK;\n  if( rtTopic(pCsr->eType)==0 ){\n    Segment *pSeg = pCsr->aPtr[iGobble].pSeg;\n    Pgno *aPg;\n    int nPg;\n\n    /* Seek from the root of the b-tree to the segment leaf that may contain\n    ** a key equal to the one multi-cursor currently points to. Record the\n    ** page number of each b-tree page and the leaf. The segment may be\n    ** gobbled up to (but not including) the first of these page numbers.\n    */\n    assert( pSeg->iRoot>0 );\n    aPg = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno)*32, &rc);\n    if( rc==LSM_OK ){\n      rc = seekInBtree(pCsr, pSeg, \n          rtTopic(pCsr->eType), pCsr->key.pData, pCsr->key.nData, aPg, 0\n      ); \n    }\n\n    if( rc==LSM_OK ){\n      for(nPg=0; aPg[nPg]; nPg++);\n      lsmFsGobble(pDb, pSeg, aPg, nPg);\n    }\n\n    lsmFree(pDb->pEnv, aPg);\n  }\n  return rc;\n}\n\n/*\n** Argument p points to a level of age N. Return the number of levels in\n** the linked list starting at p that have age=N (always at least 1).\n*/\nstatic int sortedCountLevels(Level *p){\n  int iAge = p->iAge;\n  int nRet = 0;\n  do {\n    nRet++;\n    p = p->pNext;\n  }while( p && p->iAge==iAge );\n  return nRet;\n}\n\nstatic int sortedSelectLevel(lsm_db *pDb, int nMerge, Level **ppOut){\n  Level *pTopLevel = lsmDbSnapshotLevel(pDb->pWorker);\n  int rc = LSM_OK;\n  Level *pLevel = 0;            /* Output value */\n  Level *pBest = 0;             /* Best level to work on found so far */\n  int nBest;                    /* Number of segments merged at pBest */\n  Level *pThis = 0;             /* First in run of levels with age=iAge */\n  int nThis = 0;                /* Number of levels starting at pThis */\n\n  assert( nMerge>=1 );\n  nBest = LSM_MAX(1, nMerge-1);\n\n  /* Find the longest contiguous run of levels not currently undergoing a \n  ** merge with the same age in the structure. Or the level being merged\n  ** with the largest number of right-hand segments. Work on it. */\n  for(pLevel=pTopLevel; pLevel; pLevel=pLevel->pNext){\n    if( pLevel->nRight==0 && pThis && pLevel->iAge==pThis->iAge ){\n      nThis++;\n    }else{\n      if( nThis>nBest ){\n        if( (pLevel->iAge!=pThis->iAge+1)\n         || (pLevel->nRight==0 && sortedCountLevels(pLevel)<=pDb->nMerge)\n        ){\n          pBest = pThis;\n          nBest = nThis;\n        }\n      }\n      if( pLevel->nRight ){\n        if( pLevel->nRight>nBest ){\n          nBest = pLevel->nRight;\n          pBest = pLevel;\n        }\n        nThis = 0;\n        pThis = 0;\n      }else{\n        pThis = pLevel;\n        nThis = 1;\n      }\n    }\n  }\n  if( nThis>nBest ){\n    assert( pThis );\n    pBest = pThis;\n    nBest = nThis;\n  }\n\n  if( pBest==0 && nMerge==1 ){\n    int nFree = 0;\n    int nUsr = 0;\n    for(pLevel=pTopLevel; pLevel; pLevel=pLevel->pNext){\n      assert( !pLevel->nRight );\n      if( pLevel->flags & LEVEL_FREELIST_ONLY ){\n        nFree++;\n      }else{\n        nUsr++;\n      }\n    }\n    if( nUsr>1 ){\n      pBest = pTopLevel;\n      nBest = nFree + nUsr;\n    }\n  }\n\n  if( pBest ){\n    if( pBest->nRight==0 ){\n      rc = sortedMergeSetup(pDb, pBest, nBest, ppOut);\n    }else{\n      *ppOut = pBest;\n    }\n  }\n\n  return rc;\n}\n\nstatic int sortedDbIsFull(lsm_db *pDb){\n  Level *pTop = lsmDbSnapshotLevel(pDb->pWorker);\n\n  if( lsmDatabaseFull(pDb) ) return 1;\n  if( pTop && pTop->iAge==0\n   && (pTop->nRight || sortedCountLevels(pTop)>=pDb->nMerge)\n  ){\n    return 1;\n  }\n  return 0;\n}\n\ntypedef struct MoveBlockCtx MoveBlockCtx;\nstruct MoveBlockCtx {\n  int iSeen;                      /* Previous free block on list */\n  int iFrom;                      /* Total number of blocks in file */\n};\n\nstatic int moveBlockCb(void *pCtx, int iBlk, i64 iSnapshot){\n  MoveBlockCtx *p = (MoveBlockCtx *)pCtx;\n  assert( p->iFrom==0 );\n  if( iBlk==(p->iSeen-1) ){\n    p->iSeen = iBlk;\n    return 0;\n  }\n  p->iFrom = p->iSeen-1;\n  return 1;\n}\n\n/*\n** This function is called to further compact a database for which all \n** of the content has already been merged into a single segment. If \n** possible, it moves the contents of a single block from the end of the\n** file to a free-block that lies closer to the start of the file (allowing\n** the file to be eventually truncated).\n*/\nstatic int sortedMoveBlock(lsm_db *pDb, int *pnWrite){\n  Snapshot *p = pDb->pWorker;\n  Level *pLvl = lsmDbSnapshotLevel(p);\n  int iFrom;                      /* Block to move */\n  int iTo;                        /* Destination to move block to */\n  int rc;                         /* Return code */\n\n  MoveBlockCtx sCtx;\n\n  assert( pLvl->pNext==0 && pLvl->nRight==0 );\n  assert( p->redirect.n<=LSM_MAX_BLOCK_REDIRECTS );\n\n  *pnWrite = 0;\n\n  /* Check that the redirect array is not already full. If it is, return\n  ** without moving any database content.  */\n  if( p->redirect.n>=LSM_MAX_BLOCK_REDIRECTS ) return LSM_OK;\n\n  /* Find the last block of content in the database file. Do this by \n  ** traversing the free-list in reverse (descending block number) order.\n  ** The first block not on the free list is the one that will be moved.\n  ** Since the db consists of a single segment, there is no ambiguity as\n  ** to which segment the block belongs to.  */\n  sCtx.iSeen = p->nBlock+1;\n  sCtx.iFrom = 0;\n  rc = lsmWalkFreelist(pDb, 1, moveBlockCb, &sCtx);\n  if( rc!=LSM_OK || sCtx.iFrom==0 ) return rc;\n  iFrom = sCtx.iFrom;\n\n  /* Find the first free block in the database, ignoring block 1. Block\n  ** 1 is tricky as it is smaller than the other blocks.  */\n  rc = lsmBlockAllocate(pDb, iFrom, &iTo);\n  if( rc!=LSM_OK || iTo==0 ) return rc;\n  assert( iTo!=1 && iTo<iFrom );\n\n  rc = lsmFsMoveBlock(pDb->pFS, &pLvl->lhs, iTo, iFrom);\n  if( rc==LSM_OK ){\n    if( p->redirect.a==0 ){\n      int nByte = sizeof(struct RedirectEntry) * LSM_MAX_BLOCK_REDIRECTS;\n      p->redirect.a = lsmMallocZeroRc(pDb->pEnv, nByte, &rc);\n    }\n    if( rc==LSM_OK ){\n\n      /* Check if the block just moved was already redirected. */\n      int i;\n      for(i=0; i<p->redirect.n; i++){\n        if( p->redirect.a[i].iTo==iFrom ) break;\n      }\n\n      if( i==p->redirect.n ){\n        /* Block iFrom was not already redirected. Add a new array entry. */\n        memmove(&p->redirect.a[1], &p->redirect.a[0], \n            sizeof(struct RedirectEntry) * p->redirect.n\n            );\n        p->redirect.a[0].iFrom = iFrom;\n        p->redirect.a[0].iTo = iTo;\n        p->redirect.n++;\n      }else{\n        /* Block iFrom was already redirected. Overwrite existing entry. */\n        p->redirect.a[i].iTo = iTo;\n      }\n\n      rc = lsmBlockFree(pDb, iFrom);\n\n      *pnWrite = lsmFsBlockSize(pDb->pFS) / lsmFsPageSize(pDb->pFS);\n      pLvl->lhs.pRedirect = &p->redirect;\n    }\n  }\n\n#if LSM_LOG_STRUCTURE\n  if( rc==LSM_OK ){\n    char aBuf[64];\n    sprintf(aBuf, \"move-block %d/%d\", p->redirect.n-1, LSM_MAX_BLOCK_REDIRECTS);\n    lsmSortedDumpStructure(pDb, pDb->pWorker, LSM_LOG_DATA, 0, aBuf);\n  }\n#endif\n  return rc;\n}\n\n/*\n*/\nstatic int mergeInsertFreelistSegments(\n  lsm_db *pDb, \n  int nFree,\n  MergeWorker *pMW\n){\n  int rc = LSM_OK;\n  if( nFree>0 ){\n    MultiCursor *pCsr = pMW->pCsr;\n    Level *pLvl = pMW->pLevel;\n    SegmentPtr *aNew1;\n    Segment *aNew2;\n\n    Level *pIter;\n    Level *pNext;\n    int i = 0;\n\n    aNew1 = (SegmentPtr *)lsmMallocZeroRc(\n        pDb->pEnv, sizeof(SegmentPtr) * (pCsr->nPtr+nFree), &rc\n    );\n    if( rc ) return rc;\n    memcpy(&aNew1[nFree], pCsr->aPtr, sizeof(SegmentPtr)*pCsr->nPtr);\n    pCsr->nPtr += nFree;\n    lsmFree(pDb->pEnv, pCsr->aTree);\n    lsmFree(pDb->pEnv, pCsr->aPtr);\n    pCsr->aTree = 0;\n    pCsr->aPtr = aNew1;\n\n    aNew2 = (Segment *)lsmMallocZeroRc(\n        pDb->pEnv, sizeof(Segment) * (pLvl->nRight+nFree), &rc\n    );\n    if( rc ) return rc;\n    memcpy(&aNew2[nFree], pLvl->aRhs, sizeof(Segment)*pLvl->nRight);\n    pLvl->nRight += nFree;\n    lsmFree(pDb->pEnv, pLvl->aRhs);\n    pLvl->aRhs = aNew2;\n\n    for(pIter=pDb->pWorker->pLevel; rc==LSM_OK && pIter!=pLvl; pIter=pNext){\n      Segment *pSeg = &pLvl->aRhs[i];\n      memcpy(pSeg, &pIter->lhs, sizeof(Segment));\n\n      pCsr->aPtr[i].pSeg = pSeg;\n      pCsr->aPtr[i].pLevel = pLvl;\n      rc = segmentPtrEnd(pCsr, &pCsr->aPtr[i], 0);\n\n      pDb->pWorker->pLevel = pNext = pIter->pNext;\n      sortedFreeLevel(pDb->pEnv, pIter);\n      i++;\n    }\n    assert( i==nFree );\n    assert( rc!=LSM_OK || pDb->pWorker->pLevel==pLvl );\n\n    for(i=nFree; i<pCsr->nPtr; i++){\n      pCsr->aPtr[i].pSeg = &pLvl->aRhs[i];\n    }\n\n    lsmFree(pDb->pEnv, pMW->aGobble);\n    pMW->aGobble = 0;\n  }\n  return rc;\n}\n\nstatic int sortedWork(\n  lsm_db *pDb,                    /* Database handle. Must be worker. */\n  int nWork,                      /* Number of pages of work to do */\n  int nMerge,                     /* Try to merge this many levels at once */\n  int bFlush,                     /* Set if call is to make room for a flush */\n  int *pnWrite                    /* OUT: Actual number of pages written */\n){\n  int rc = LSM_OK;                /* Return Code */\n  int nRemaining = nWork;         /* Units of work to do before returning */\n  Snapshot *pWorker = pDb->pWorker;\n\n  assert( pWorker );\n  if( lsmDbSnapshotLevel(pWorker)==0 ) return LSM_OK;\n\n  while( nRemaining>0 ){\n    Level *pLevel = 0;\n\n    /* Find a level to work on. */\n    rc = sortedSelectLevel(pDb, nMerge, &pLevel);\n    assert( rc==LSM_OK || pLevel==0 );\n\n    if( pLevel==0 ){\n      int nDone = 0;\n      Level *pTopLevel = lsmDbSnapshotLevel(pDb->pWorker);\n      if( bFlush==0 && nMerge==1 && pTopLevel && pTopLevel->pNext==0 ){\n        rc = sortedMoveBlock(pDb, &nDone);\n      }\n      nRemaining -= nDone;\n\n      /* Could not find any work to do. Finished. */\n      if( nDone==0 ) break;\n    }else{\n      int bSave = 0;\n      Freelist freelist = {0, 0, 0};\n      MergeWorker mergeworker;    /* State used to work on the level merge */\n\n      assert( pDb->bIncrMerge==0 );\n      assert( pDb->pFreelist==0 && pDb->bUseFreelist==0 );\n\n      pDb->bIncrMerge = 1;\n      rc = mergeWorkerInit(pDb, pLevel, &mergeworker);\n      assert( mergeworker.nWork==0 );\n      \n      while( rc==LSM_OK \n          && 0==mergeWorkerDone(&mergeworker) \n          && (mergeworker.nWork<nRemaining || pDb->bUseFreelist)\n      ){\n        int eType = rtTopic(mergeworker.pCsr->eType);\n        rc = mergeWorkerStep(&mergeworker);\n\n        /* If the cursor now points at the first entry past the end of the\n        ** user data (i.e. either to EOF or to the first free-list entry\n        ** that will be added to the run), then check if it is possible to\n        ** merge in any free-list entries that are either in-memory or in\n        ** free-list-only blocks.  */\n        if( rc==LSM_OK && nMerge==1 && eType==0\n         && (rtTopic(mergeworker.pCsr->eType) || mergeWorkerDone(&mergeworker))\n        ){\n          int nFree = 0;          /* Number of free-list-only levels to merge */\n          Level *pLvl;\n          assert( pDb->pFreelist==0 && pDb->bUseFreelist==0 );\n\n          /* Now check if all levels containing data newer than this one\n          ** are single-segment free-list only levels. If so, they will be\n          ** merged in now.  */\n          for(pLvl=pDb->pWorker->pLevel; \n              pLvl!=mergeworker.pLevel && (pLvl->flags & LEVEL_FREELIST_ONLY); \n              pLvl=pLvl->pNext\n          ){\n            assert( pLvl->nRight==0 );\n            nFree++;\n          }\n          if( pLvl==mergeworker.pLevel ){\n\n            rc = mergeInsertFreelistSegments(pDb, nFree, &mergeworker);\n            if( rc==LSM_OK ){\n              rc = multiCursorVisitFreelist(mergeworker.pCsr);\n            }\n            if( rc==LSM_OK ){\n              rc = multiCursorSetupTree(mergeworker.pCsr, 0);\n              pDb->pFreelist = &freelist;\n              pDb->bUseFreelist = 1;\n            }\n          }\n        }\n      }\n      nRemaining -= LSM_MAX(mergeworker.nWork, 1);\n\n      if( rc==LSM_OK ){\n        /* Check if the merge operation is completely finished. If not,\n        ** gobble up (declare eligible for recycling) any pages from rhs\n        ** segments for which the content has been completely merged into \n        ** the lhs of the level.  */\n        if( mergeWorkerDone(&mergeworker)==0 ){\n          int i;\n          for(i=0; i<pLevel->nRight; i++){\n            SegmentPtr *pGobble = &mergeworker.pCsr->aPtr[i];\n            if( pGobble->pSeg->iRoot ){\n              rc = sortedBtreeGobble(pDb, mergeworker.pCsr, i);\n            }else if( mergeworker.aGobble[i] ){\n              lsmFsGobble(pDb, pGobble->pSeg, &mergeworker.aGobble[i], 1);\n            }\n          }\n        }else{\n          int i;\n          int bEmpty;\n          mergeWorkerShutdown(&mergeworker, &rc);\n          bEmpty = (pLevel->lhs.iFirst==0);\n\n          if( bEmpty==0 && rc==LSM_OK ){\n            rc = lsmFsSortedFinish(pDb->pFS, &pLevel->lhs);\n          }\n\n          if( pDb->bUseFreelist ){\n            Freelist *p = &pDb->pWorker->freelist;\n            lsmFree(pDb->pEnv, p->aEntry);\n            memcpy(p, &freelist, sizeof(freelist));\n            pDb->bUseFreelist = 0;\n            pDb->pFreelist = 0;\n            bSave = 1;\n          }\n\n          for(i=0; i<pLevel->nRight; i++){\n            lsmFsSortedDelete(pDb->pFS, pWorker, 1, &pLevel->aRhs[i]);\n          }\n\n          if( bEmpty ){\n            /* If the new level is completely empty, remove it from the \n            ** database snapshot. This can only happen if all input keys were\n            ** annihilated. Since keys are only annihilated if the new level\n            ** is the last in the linked list (contains the most ancient of\n            ** database content), this guarantees that pLevel->pNext==0.  */ \n            Level *pTop;          /* Top level of worker snapshot */\n            Level **pp;           /* Read/write iterator for Level.pNext list */\n\n            assert( pLevel->pNext==0 );\n\n            /* Remove the level from the worker snapshot. */\n            pTop = lsmDbSnapshotLevel(pWorker);\n            for(pp=&pTop; *pp!=pLevel; pp=&((*pp)->pNext));\n            *pp = pLevel->pNext;\n            lsmDbSnapshotSetLevel(pWorker, pTop);\n\n            /* Free the Level structure. */\n            sortedFreeLevel(pDb->pEnv, pLevel);\n          }else{\n\n            /* Free the separators of the next level, if required. */\n            if( pLevel->pMerge->nInput > pLevel->nRight ){\n              assert( pLevel->pNext->lhs.iRoot );\n              pLevel->pNext->lhs.iRoot = 0;\n            }\n\n            /* Zero the right-hand-side of pLevel */\n            lsmFree(pDb->pEnv, pLevel->aRhs);\n            pLevel->nRight = 0;\n            pLevel->aRhs = 0;\n\n            /* Free the Merge object */\n            lsmFree(pDb->pEnv, pLevel->pMerge);\n            pLevel->pMerge = 0;\n          }\n\n          if( bSave && rc==LSM_OK ){\n            pDb->bIncrMerge = 0;\n            rc = lsmSaveWorker(pDb, 0);\n          }\n        }\n      }\n\n      /* Clean up the MergeWorker object initialized above. If no error\n      ** has occurred, invoke the work-hook to inform the application that\n      ** the database structure has changed. */\n      mergeWorkerShutdown(&mergeworker, &rc);\n      pDb->bIncrMerge = 0;\n      if( rc==LSM_OK ) sortedInvokeWorkHook(pDb);\n\n#if LSM_LOG_STRUCTURE\n      lsmSortedDumpStructure(pDb, pDb->pWorker, LSM_LOG_DATA, 0, \"work\");\n#endif\n      assertBtreeOk(pDb, &pLevel->lhs);\n      assertRunInOrder(pDb, &pLevel->lhs);\n\n      /* If bFlush is true and the database is no longer considered \"full\",\n      ** break out of the loop even if nRemaining is still greater than\n      ** zero. The caller has an in-memory tree to flush to disk.  */\n      if( bFlush && sortedDbIsFull(pDb)==0 ) break;\n    }\n  }\n\n  if( pnWrite ) *pnWrite = (nWork - nRemaining);\n  pWorker->nWrite += (nWork - nRemaining);\n\n#ifdef LSM_LOG_WORK\n  lsmLogMessage(pDb, rc, \"sortedWork(): %d pages\", (nWork-nRemaining));\n#endif\n  return rc;\n}\n\n/*\n** The database connection passed as the first argument must be a worker\n** connection. This function checks if there exists an \"old\" in-memory tree\n** ready to be flushed to disk. If so, true is returned. Otherwise false.\n**\n** If an error occurs, *pRc is set to an LSM error code before returning.\n** It is assumed that *pRc is set to LSM_OK when this function is called.\n*/\nstatic int sortedTreeHasOld(lsm_db *pDb, int *pRc){\n  int rc = LSM_OK;\n  int bRet = 0;\n\n  assert( pDb->pWorker );\n  if( *pRc==LSM_OK ){\n    if( rc==LSM_OK \n        && pDb->treehdr.iOldShmid\n        && pDb->treehdr.iOldLog!=pDb->pWorker->iLogOff \n      ){\n      bRet = 1;\n    }else{\n      bRet = 0;\n    }\n    *pRc = rc;\n  }\n  assert( *pRc==LSM_OK || bRet==0 );\n  return bRet;\n}\n\n/*\n** Create a new free-list only top-level segment. Return LSM_OK if successful\n** or an LSM error code if some error occurs.\n*/\nstatic int sortedNewFreelistOnly(lsm_db *pDb){\n  return sortedNewToplevel(pDb, TREE_NONE, 0);\n}\n\nint lsmSaveWorker(lsm_db *pDb, int bFlush){\n  Snapshot *p = pDb->pWorker;\n  if( p->freelist.nEntry>pDb->nMaxFreelist ){\n    int rc = sortedNewFreelistOnly(pDb);\n    if( rc!=LSM_OK ) return rc;\n  }\n  return lsmCheckpointSaveWorker(pDb, bFlush);\n}\n\nstatic int doLsmSingleWork(\n  lsm_db *pDb, \n  int bShutdown,\n  int nMerge,                     /* Minimum segments to merge together */\n  int nPage,                      /* Number of pages to write to disk */\n  int *pnWrite,                   /* OUT: Pages actually written to disk */\n  int *pbCkpt                     /* OUT: True if an auto-checkpoint is req. */\n){\n  Snapshot *pWorker;              /* Worker snapshot */\n  int rc = LSM_OK;                /* Return code */\n  int bDirty = 0;\n  int nMax = nPage;               /* Maximum pages to write to disk */\n  int nRem = nPage;\n  int bCkpt = 0;\n\n  assert( nPage>0 );\n\n  /* Open the worker 'transaction'. It will be closed before this function\n  ** returns.  */\n  assert( pDb->pWorker==0 );\n  rc = lsmBeginWork(pDb);\n  if( rc!=LSM_OK ) return rc;\n  pWorker = pDb->pWorker;\n\n  /* If this connection is doing auto-checkpoints, set nMax (and nRem) so\n  ** that this call stops writing when the auto-checkpoint is due. The\n  ** caller will do the checkpoint, then possibly call this function again. */\n  if( bShutdown==0 && pDb->nAutockpt ){\n    u32 nSync;\n    u32 nUnsync;\n    int nPgsz;\n\n    lsmCheckpointSynced(pDb, 0, 0, &nSync);\n    nUnsync = lsmCheckpointNWrite(pDb->pShmhdr->aSnap1, 0);\n    nPgsz = lsmCheckpointPgsz(pDb->pShmhdr->aSnap1);\n\n    nMax = (int)LSM_MIN(nMax, (pDb->nAutockpt/nPgsz) - (int)(nUnsync-nSync));\n    if( nMax<nRem ){\n      bCkpt = 1;\n      nRem = LSM_MAX(nMax, 0);\n    }\n  }\n\n  /* If there exists in-memory data ready to be flushed to disk, attempt\n  ** to flush it now.  */\n  if( pDb->nTransOpen==0 ){\n    rc = lsmTreeLoadHeader(pDb, 0);\n  }\n  if( sortedTreeHasOld(pDb, &rc) ){\n    /* sortedDbIsFull() returns non-zero if either (a) there are too many\n    ** levels in total in the db, or (b) there are too many levels with the\n    ** the same age in the db. Either way, call sortedWork() to merge \n    ** existing segments together until this condition is cleared.  */\n    if( sortedDbIsFull(pDb) ){\n      int nPg = 0;\n      rc = sortedWork(pDb, nRem, nMerge, 1, &nPg);\n      nRem -= nPg;\n      assert( rc!=LSM_OK || nRem<=0 || !sortedDbIsFull(pDb) );\n      bDirty = 1;\n    }\n\n    if( rc==LSM_OK && nRem>0 ){\n      int nPg = 0;\n      rc = sortedNewToplevel(pDb, TREE_OLD, &nPg);\n      nRem -= nPg;\n      if( rc==LSM_OK ){\n        if( pDb->nTransOpen>0 ){\n          lsmTreeDiscardOld(pDb);\n        }\n        rc = lsmSaveWorker(pDb, 1);\n        bDirty = 0;\n      }\n    }\n  }\n\n  /* If nPage is still greater than zero, do some merging. */\n  if( rc==LSM_OK && nRem>0 && bShutdown==0 ){\n    int nPg = 0;\n    rc = sortedWork(pDb, nRem, nMerge, 0, &nPg);\n    nRem -= nPg;\n    if( nPg ) bDirty = 1;\n  }\n\n  /* If the in-memory part of the free-list is too large, write a new \n  ** top-level containing just the in-memory free-list entries to disk. */\n  if( rc==LSM_OK && pDb->pWorker->freelist.nEntry > pDb->nMaxFreelist ){\n    int nPg = 0;\n    while( rc==LSM_OK && lsmDatabaseFull(pDb) ){\n      rc = sortedWork(pDb, 16, nMerge, 1, &nPg);\n      nRem -= nPg;\n    }\n    if( rc==LSM_OK ){\n      rc = sortedNewFreelistOnly(pDb);\n    }\n    nRem -= nPg;\n    if( nPg ) bDirty = 1;\n  }\n\n  if( rc==LSM_OK ){\n    *pnWrite = (nMax - nRem);\n    *pbCkpt = (bCkpt && nRem<=0);\n    if( nMerge==1 && pDb->nAutockpt>0 && *pnWrite>0\n     && pWorker->pLevel \n     && pWorker->pLevel->nRight==0 \n     && pWorker->pLevel->pNext==0 \n    ){\n      *pbCkpt = 1;\n    }\n  }\n\n  if( rc==LSM_OK && bDirty ){\n    lsmFinishWork(pDb, 0, &rc);\n  }else{\n    int rcdummy = LSM_BUSY;\n    lsmFinishWork(pDb, 0, &rcdummy);\n    *pnWrite = 0;\n  }\n  assert( pDb->pWorker==0 );\n  return rc;\n}\n\nstatic int doLsmWork(lsm_db *pDb, int nMerge, int nPage, int *pnWrite){\n  int rc = LSM_OK;                /* Return code */\n  int nWrite = 0;                 /* Number of pages written */\n\n  assert( nMerge>=1 );\n\n  if( nPage!=0 ){\n    int bCkpt = 0;\n    do {\n      int nThis = 0;\n      int nReq = (nPage>=0) ? (nPage-nWrite) : ((int)0x7FFFFFFF);\n\n      bCkpt = 0;\n      rc = doLsmSingleWork(pDb, 0, nMerge, nReq, &nThis, &bCkpt);\n      nWrite += nThis;\n      if( rc==LSM_OK && bCkpt ){\n        rc = lsm_checkpoint(pDb, 0);\n      }\n    }while( rc==LSM_OK && bCkpt && (nWrite<nPage || nPage<0) );\n  }\n\n  if( pnWrite ){\n    if( rc==LSM_OK ){\n      *pnWrite = nWrite;\n    }else{\n      *pnWrite = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Perform work to merge database segments together.\n*/\nint lsm_work(lsm_db *pDb, int nMerge, int nKB, int *pnWrite){\n  int rc;                         /* Return code */\n  int nPgsz;                      /* Nominal page size in bytes */\n  int nPage;                      /* Equivalent of nKB in pages */\n  int nWrite = 0;                 /* Number of pages written */\n\n  /* This function may not be called if pDb has an open read or write\n  ** transaction. Return LSM_MISUSE if an application attempts this.  */\n  if( pDb->nTransOpen || pDb->pCsr ) return LSM_MISUSE_BKPT;\n  if( nMerge<=0 ) nMerge = pDb->nMerge;\n\n  lsmFsPurgeCache(pDb->pFS);\n\n  /* Convert from KB to pages */\n  nPgsz = lsmFsPageSize(pDb->pFS);\n  if( nKB>=0 ){\n    nPage = ((i64)nKB * 1024 + nPgsz - 1) / nPgsz;\n  }else{\n    nPage = -1;\n  }\n\n  rc = doLsmWork(pDb, nMerge, nPage, &nWrite);\n  \n  if( pnWrite ){\n    /* Convert back from pages to KB */\n    *pnWrite = (int)(((i64)nWrite * 1024 + nPgsz - 1) / nPgsz);\n  }\n  return rc;\n}\n\nint lsm_flush(lsm_db *db){\n  int rc;\n\n  if( db->nTransOpen>0 || db->pCsr ){\n    rc = LSM_MISUSE_BKPT;\n  }else{\n    rc = lsmBeginWriteTrans(db);\n    if( rc==LSM_OK ){\n      lsmFlushTreeToDisk(db);\n      lsmTreeDiscardOld(db);\n      lsmTreeMakeOld(db);\n      lsmTreeDiscardOld(db);\n    }\n\n    if( rc==LSM_OK ){\n      rc = lsmFinishWriteTrans(db, 1);\n    }else{\n      lsmFinishWriteTrans(db, 0);\n    }\n    lsmFinishReadTrans(db);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called in auto-work mode to perform merging work on\n** the data structure. It performs enough merging work to prevent the\n** height of the tree from growing indefinitely assuming that roughly\n** nUnit database pages worth of data have been written to the database\n** (i.e. the in-memory tree) since the last call.\n*/\nint lsmSortedAutoWork(\n  lsm_db *pDb,                    /* Database handle */\n  int nUnit                       /* Pages of data written to in-memory tree */\n){\n  int rc = LSM_OK;                /* Return code */\n  int nDepth = 0;                 /* Current height of tree (longest path) */\n  Level *pLevel;                  /* Used to iterate through levels */\n  int bRestore = 0;\n\n  assert( pDb->pWorker==0 );\n  assert( pDb->nTransOpen>0 );\n\n  /* Determine how many units of work to do before returning. One unit of\n  ** work is achieved by writing one page (~4KB) of merged data.  */\n  for(pLevel=lsmDbSnapshotLevel(pDb->pClient); pLevel; pLevel=pLevel->pNext){\n    /* nDepth += LSM_MAX(1, pLevel->nRight); */\n    nDepth += 1;\n  }\n  if( lsmTreeHasOld(pDb) ){\n    nDepth += 1;\n    bRestore = 1;\n    rc = lsmSaveCursors(pDb);\n    if( rc!=LSM_OK ) return rc;\n  }\n\n  if( nDepth>0 ){\n    int nRemaining;               /* Units of work to do before returning */\n\n    nRemaining = nUnit * nDepth;\n#ifdef LSM_LOG_WORK\n    lsmLogMessage(pDb, rc, \"lsmSortedAutoWork(): %d*%d = %d pages\", \n        nUnit, nDepth, nRemaining);\n#endif\n    assert( nRemaining>=0 );\n    rc = doLsmWork(pDb, pDb->nMerge, nRemaining, 0);\n    if( rc==LSM_BUSY ) rc = LSM_OK;\n\n    if( bRestore && pDb->pCsr ){\n      lsmMCursorFreeCache(pDb);\n      lsmFreeSnapshot(pDb->pEnv, pDb->pClient);\n      pDb->pClient = 0;\n      if( rc==LSM_OK ){\n        rc = lsmCheckpointLoad(pDb, 0);\n      }\n      if( rc==LSM_OK ){\n        rc = lsmCheckpointDeserialize(pDb, 0, pDb->aSnapshot, &pDb->pClient);\n      }\n      if( rc==LSM_OK ){\n        rc = lsmRestoreCursors(pDb);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is only called during system shutdown. The contents of\n** any in-memory trees present (old or current) are written out to disk.\n*/\nint lsmFlushTreeToDisk(lsm_db *pDb){\n  int rc;\n\n  rc = lsmBeginWork(pDb);\n  while( rc==LSM_OK && sortedDbIsFull(pDb) ){\n    rc = sortedWork(pDb, 256, pDb->nMerge, 1, 0);\n  }\n\n  if( rc==LSM_OK ){\n    rc = sortedNewToplevel(pDb, TREE_BOTH, 0);\n  }\n\n  lsmFinishWork(pDb, 1, &rc);\n  return rc;\n}\n\n/*\n** Return a string representation of the segment passed as the only argument.\n** Space for the returned string is allocated using lsmMalloc(), and should\n** be freed by the caller using lsmFree().\n*/\nstatic char *segToString(lsm_env *pEnv, Segment *pSeg, int nMin){\n  int nSize = pSeg->nSize;\n  Pgno iRoot = pSeg->iRoot;\n  Pgno iFirst = pSeg->iFirst;\n  Pgno iLast = pSeg->iLastPg;\n  char *z;\n\n  char *z1;\n  char *z2;\n  int nPad;\n\n  z1 = lsmMallocPrintf(pEnv, \"%d.%d\", iFirst, iLast);\n  if( iRoot ){\n    z2 = lsmMallocPrintf(pEnv, \"root=%d\", iRoot);\n  }else{\n    z2 = lsmMallocPrintf(pEnv, \"size=%d\", nSize);\n  }\n\n  nPad = nMin - 2 - strlen(z1) - 1 - strlen(z2);\n  nPad = LSM_MAX(0, nPad);\n\n  if( iRoot ){\n    z = lsmMallocPrintf(pEnv, \"/%s %*s%s\\\\\", z1, nPad, \"\", z2);\n  }else{\n    z = lsmMallocPrintf(pEnv, \"|%s %*s%s|\", z1, nPad, \"\", z2);\n  }\n  lsmFree(pEnv, z1);\n  lsmFree(pEnv, z2);\n\n  return z;\n}\n\nstatic int fileToString(\n  lsm_db *pDb,                    /* For xMalloc() */\n  char *aBuf, \n  int nBuf, \n  int nMin,\n  Segment *pSeg\n){\n  int i = 0;\n  if( pSeg ){\n    char *zSeg;\n\n    zSeg = segToString(pDb->pEnv, pSeg, nMin);\n    snprintf(&aBuf[i], nBuf-i, \"%s\", zSeg);\n    i += strlen(&aBuf[i]);\n    lsmFree(pDb->pEnv, zSeg);\n\n#ifdef LSM_LOG_FREELIST\n    lsmInfoArrayStructure(pDb, 1, pSeg->iFirst, &zSeg);\n    snprintf(&aBuf[i], nBuf-1, \"    (%s)\", zSeg);\n    i += strlen(&aBuf[i]);\n    lsmFree(pDb->pEnv, zSeg);\n#endif\n    aBuf[nBuf] = 0;\n  }else{\n    aBuf[0] = '\\0';\n  }\n\n  return i;\n}\n\nvoid sortedDumpPage(lsm_db *pDb, Segment *pRun, Page *pPg, int bVals){\n  Blob blob = {0, 0, 0};         /* Blob used for keys */\n  LsmString s;\n  int i;\n\n  int nRec;\n  int iPtr;\n  int flags;\n  u8 *aData;\n  int nData;\n\n  aData = fsPageData(pPg, &nData);\n\n  nRec = pageGetNRec(aData, nData);\n  iPtr = (int)pageGetPtr(aData, nData);\n  flags = pageGetFlags(aData, nData);\n\n  lsmStringInit(&s, pDb->pEnv);\n  lsmStringAppendf(&s,\"nCell=%d iPtr=%d flags=%d {\", nRec, iPtr, flags);\n  if( flags&SEGMENT_BTREE_FLAG ) iPtr = 0;\n\n  for(i=0; i<nRec; i++){\n    Page *pRef = 0;               /* Pointer to page iRef */\n    int iChar;\n    u8 *aKey; int nKey = 0;       /* Key */\n    u8 *aVal = 0; int nVal = 0;   /* Value */\n    int iTopic;\n    u8 *aCell;\n    int iPgPtr;\n    int eType;\n\n    aCell = pageGetCell(aData, nData, i);\n    eType = *aCell++;\n    assert( (flags & SEGMENT_BTREE_FLAG) || eType!=0 );\n    aCell += lsmVarintGet32(aCell, &iPgPtr);\n\n    if( eType==0 ){\n      Pgno iRef;                  /* Page number of referenced page */\n      aCell += lsmVarintGet64(aCell, &iRef);\n      lsmFsDbPageGet(pDb->pFS, pRun, iRef, &pRef);\n      aKey = pageGetKey(pRun, pRef, 0, &iTopic, &nKey, &blob);\n    }else{\n      aCell += lsmVarintGet32(aCell, &nKey);\n      if( rtIsWrite(eType) ) aCell += lsmVarintGet32(aCell, &nVal);\n      sortedReadData(0, pPg, (aCell-aData), nKey+nVal, (void **)&aKey, &blob);\n      aVal = &aKey[nKey];\n      iTopic = eType;\n    }\n\n    lsmStringAppendf(&s, \"%s%2X:\", (i==0?\"\":\" \"), iTopic);\n    for(iChar=0; iChar<nKey; iChar++){\n      lsmStringAppendf(&s, \"%c\", isalnum(aKey[iChar]) ? aKey[iChar] : '.');\n    }\n    if( nVal>0 && bVals ){\n      lsmStringAppendf(&s, \"##\");\n      for(iChar=0; iChar<nVal; iChar++){\n        lsmStringAppendf(&s, \"%c\", isalnum(aVal[iChar]) ? aVal[iChar] : '.');\n      }\n    }\n\n    lsmStringAppendf(&s, \" %d\", iPgPtr+iPtr);\n    lsmFsPageRelease(pRef);\n  }\n  lsmStringAppend(&s, \"}\", 1);\n\n  lsmLogMessage(pDb, LSM_OK, \"      Page %d: %s\", lsmFsPageNumber(pPg), s.z);\n  lsmStringClear(&s);\n\n  sortedBlobFree(&blob);\n}\n\nstatic void infoCellDump(\n  lsm_db *pDb,                    /* Database handle */\n  Segment *pSeg,                  /* Segment page belongs to */\n  int bIndirect,                  /* True to follow indirect refs */\n  Page *pPg,\n  int iCell,\n  int *peType,\n  int *piPgPtr,\n  u8 **paKey, int *pnKey,\n  u8 **paVal, int *pnVal,\n  Blob *pBlob\n){\n  u8 *aData; int nData;           /* Page data */\n  u8 *aKey; int nKey = 0;         /* Key */\n  u8 *aVal = 0; int nVal = 0;     /* Value */\n  int eType;\n  int iPgPtr;\n  Page *pRef = 0;                 /* Pointer to page iRef */\n  u8 *aCell;\n\n  aData = fsPageData(pPg, &nData);\n\n  aCell = pageGetCell(aData, nData, iCell);\n  eType = *aCell++;\n  aCell += lsmVarintGet32(aCell, &iPgPtr);\n\n  if( eType==0 ){\n    int dummy;\n    Pgno iRef;                  /* Page number of referenced page */\n    aCell += lsmVarintGet64(aCell, &iRef);\n    if( bIndirect ){\n      lsmFsDbPageGet(pDb->pFS, pSeg, iRef, &pRef);\n      pageGetKeyCopy(pDb->pEnv, pSeg, pRef, 0, &dummy, pBlob);\n      aKey = (u8 *)pBlob->pData;\n      nKey = pBlob->nData;\n      lsmFsPageRelease(pRef);\n    }else{\n      aKey = (u8 *)\"<indirect>\";\n      nKey = 11;\n    }\n  }else{\n    aCell += lsmVarintGet32(aCell, &nKey);\n    if( rtIsWrite(eType) ) aCell += lsmVarintGet32(aCell, &nVal);\n    sortedReadData(pSeg, pPg, (aCell-aData), nKey+nVal, (void **)&aKey, pBlob);\n    aVal = &aKey[nKey];\n  }\n\n  if( peType ) *peType = eType;\n  if( piPgPtr ) *piPgPtr = iPgPtr;\n  if( paKey ) *paKey = aKey;\n  if( paVal ) *paVal = aVal;\n  if( pnKey ) *pnKey = nKey;\n  if( pnVal ) *pnVal = nVal;\n}\n\nstatic int infoAppendBlob(LsmString *pStr, int bHex, u8 *z, int n){\n  int iChar;\n  for(iChar=0; iChar<n; iChar++){\n    if( bHex ){\n      lsmStringAppendf(pStr, \"%02X\", z[iChar]);\n    }else{\n      lsmStringAppendf(pStr, \"%c\", isalnum(z[iChar]) ?z[iChar] : '.');\n    }\n  }\n  return LSM_OK;\n}\n\n#define INFO_PAGE_DUMP_DATA     0x01\n#define INFO_PAGE_DUMP_VALUES   0x02\n#define INFO_PAGE_DUMP_HEX      0x04\n#define INFO_PAGE_DUMP_INDIRECT 0x08\n\nstatic int infoPageDump(\n  lsm_db *pDb,                    /* Database handle */\n  Pgno iPg,                       /* Page number of page to dump */\n  int flags,\n  char **pzOut                    /* OUT: lsmMalloc'd string */\n){\n  int rc = LSM_OK;                /* Return code */\n  Page *pPg = 0;                  /* Handle for page iPg */\n  int i, j;                       /* Loop counters */\n  const int perLine = 16;         /* Bytes per line in the raw hex dump */\n  Segment *pSeg = 0;\n  Snapshot *pSnap;\n\n  int bValues = (flags & INFO_PAGE_DUMP_VALUES);\n  int bHex = (flags & INFO_PAGE_DUMP_HEX);\n  int bData = (flags & INFO_PAGE_DUMP_DATA);\n  int bIndirect = (flags & INFO_PAGE_DUMP_INDIRECT);\n\n  *pzOut = 0;\n  if( iPg==0 ) return LSM_ERROR;\n\n  assert( pDb->pClient || pDb->pWorker );\n  pSnap = pDb->pClient;\n  if( pSnap==0 ) pSnap = pDb->pWorker;\n  if( pSnap->redirect.n>0 ){\n    Level *pLvl;\n    int bUse = 0;\n    for(pLvl=pSnap->pLevel; pLvl->pNext; pLvl=pLvl->pNext);\n    pSeg = (pLvl->nRight==0 ? &pLvl->lhs : &pLvl->aRhs[pLvl->nRight-1]);\n    rc = lsmFsSegmentContainsPg(pDb->pFS, pSeg, iPg, &bUse);\n    if( bUse==0 ){\n      pSeg = 0;\n    }\n  }\n\n  /* iPg is a real page number (not subject to redirection). So it is safe \n  ** to pass a NULL in place of the segment pointer as the second argument\n  ** to lsmFsDbPageGet() here.  */\n  if( rc==LSM_OK ){\n    rc = lsmFsDbPageGet(pDb->pFS, 0, iPg, &pPg);\n  }\n\n  if( rc==LSM_OK ){\n    Blob blob = {0, 0, 0, 0};\n    int nKeyWidth = 0;\n    LsmString str;\n    int nRec;\n    int iPtr;\n    int flags2;\n    int iCell;\n    u8 *aData; int nData;         /* Page data and size thereof */\n\n    aData = fsPageData(pPg, &nData);\n    nRec = pageGetNRec(aData, nData);\n    iPtr = (int)pageGetPtr(aData, nData);\n    flags2 = pageGetFlags(aData, nData);\n\n    lsmStringInit(&str, pDb->pEnv);\n    lsmStringAppendf(&str, \"Page : %lld  (%d bytes)\\n\", iPg, nData);\n    lsmStringAppendf(&str, \"nRec : %d\\n\", nRec);\n    lsmStringAppendf(&str, \"iPtr : %d\\n\", iPtr);\n    lsmStringAppendf(&str, \"flags: %04x\\n\", flags2);\n    lsmStringAppendf(&str, \"\\n\");\n\n    for(iCell=0; iCell<nRec; iCell++){\n      int nKey;\n      infoCellDump(\n          pDb, pSeg, bIndirect, pPg, iCell, 0, 0, 0, &nKey, 0, 0, &blob\n      );\n      if( nKey>nKeyWidth ) nKeyWidth = nKey;\n    }\n    if( bHex ) nKeyWidth = nKeyWidth * 2;\n\n    for(iCell=0; iCell<nRec; iCell++){\n      u8 *aKey; int nKey = 0;       /* Key */\n      u8 *aVal; int nVal = 0;       /* Value */\n      int iPgPtr;\n      int eType;\n      Pgno iAbsPtr;\n      char zFlags[8];\n\n      infoCellDump(pDb, pSeg, bIndirect, pPg, iCell, &eType, &iPgPtr,\n          &aKey, &nKey, &aVal, &nVal, &blob\n      );\n      iAbsPtr = iPgPtr + ((flags2 & SEGMENT_BTREE_FLAG) ? 0 : iPtr);\n\n      lsmFlagsToString(eType, zFlags);\n      lsmStringAppendf(&str, \"%s %d (%s) \", \n          zFlags, iAbsPtr, (rtTopic(eType) ? \"sys\" : \"usr\")\n      );\n      infoAppendBlob(&str, bHex, aKey, nKey); \n      if( nVal>0 && bValues ){\n        lsmStringAppendf(&str, \"%*s\", nKeyWidth - (nKey*(1+bHex)), \"\");\n        lsmStringAppendf(&str, \" \");\n        infoAppendBlob(&str, bHex, aVal, nVal); \n      }\n      if( rtTopic(eType) ){\n        int iBlk = (int)~lsmGetU32(aKey);\n        lsmStringAppendf(&str, \"  (block=%d\", iBlk);\n        if( nVal>0 ){\n          i64 iSnap = lsmGetU64(aVal);\n          lsmStringAppendf(&str, \" snapshot=%lld\", iSnap);\n        }\n        lsmStringAppendf(&str, \")\");\n      }\n      lsmStringAppendf(&str, \"\\n\");\n    }\n\n    if( bData ){\n      lsmStringAppendf(&str, \"\\n-------------------\" \n          \"-------------------------------------------------------------\\n\");\n      lsmStringAppendf(&str, \"Page %d\\n\",\n          iPg, (iPg-1)*nData, iPg*nData - 1);\n      for(i=0; i<nData; i += perLine){\n        lsmStringAppendf(&str, \"%04x: \", i);\n        for(j=0; j<perLine; j++){\n          if( i+j>nData ){\n            lsmStringAppendf(&str, \"   \");\n          }else{\n            lsmStringAppendf(&str, \"%02x \", aData[i+j]);\n          }\n        }\n        lsmStringAppendf(&str, \"  \");\n        for(j=0; j<perLine; j++){\n          if( i+j>nData ){\n            lsmStringAppendf(&str, \" \");\n          }else{\n            lsmStringAppendf(&str,\"%c\", isprint(aData[i+j]) ? aData[i+j] : '.');\n          }\n        }\n        lsmStringAppendf(&str,\"\\n\");\n      }\n    }\n\n    *pzOut = str.z;\n    sortedBlobFree(&blob);\n    lsmFsPageRelease(pPg);\n  }\n\n  return rc;\n}\n\nint lsmInfoPageDump(\n  lsm_db *pDb,                    /* Database handle */\n  Pgno iPg,                       /* Page number of page to dump */\n  int bHex,                       /* True to output key/value in hex form */\n  char **pzOut                    /* OUT: lsmMalloc'd string */\n){\n  int flags = INFO_PAGE_DUMP_DATA | INFO_PAGE_DUMP_VALUES;\n  if( bHex ) flags |= INFO_PAGE_DUMP_HEX;\n  return infoPageDump(pDb, iPg, flags, pzOut);\n}\n\nvoid sortedDumpSegment(lsm_db *pDb, Segment *pRun, int bVals){\n  assert( pDb->xLog );\n  if( pRun && pRun->iFirst ){\n    int flags = (bVals ? INFO_PAGE_DUMP_VALUES : 0);\n    char *zSeg;\n    Page *pPg;\n\n    zSeg = segToString(pDb->pEnv, pRun, 0);\n    lsmLogMessage(pDb, LSM_OK, \"Segment: %s\", zSeg);\n    lsmFree(pDb->pEnv, zSeg);\n\n    lsmFsDbPageGet(pDb->pFS, pRun, pRun->iFirst, &pPg);\n    while( pPg ){\n      Page *pNext;\n      char *z = 0;\n      infoPageDump(pDb, lsmFsPageNumber(pPg), flags, &z);\n      lsmLogMessage(pDb, LSM_OK, \"%s\", z);\n      lsmFree(pDb->pEnv, z);\n#if 0\n      sortedDumpPage(pDb, pRun, pPg, bVals);\n#endif\n      lsmFsDbPageNext(pRun, pPg, 1, &pNext);\n      lsmFsPageRelease(pPg);\n      pPg = pNext;\n    }\n  }\n}\n\n/*\n** Invoke the log callback zero or more times with messages that describe\n** the current database structure.\n*/\nvoid lsmSortedDumpStructure(\n  lsm_db *pDb,                    /* Database handle (used for xLog callback) */\n  Snapshot *pSnap,                /* Snapshot to dump */\n  int bKeys,                      /* Output the keys from each segment */\n  int bVals,                      /* Output the values from each segment */\n  const char *zWhy                /* Caption to print near top of dump */\n){\n  Snapshot *pDump = pSnap;\n  Level *pTopLevel;\n  char *zFree = 0;\n\n  assert( pSnap );\n  pTopLevel = lsmDbSnapshotLevel(pDump);\n  if( pDb->xLog && pTopLevel ){\n    static int nCall = 0;\n    Level *pLevel;\n    int iLevel = 0;\n\n    nCall++;\n    lsmLogMessage(pDb, LSM_OK, \"Database structure %d (%s)\", nCall, zWhy);\n\n#if 0\n    if( nCall==1031 || nCall==1032 ) bKeys=1;\n#endif\n\n    for(pLevel=pTopLevel; pLevel; pLevel=pLevel->pNext){\n      char zLeft[1024];\n      char zRight[1024];\n      int i = 0;\n\n      Segment *aLeft[24];  \n      Segment *aRight[24];\n\n      int nLeft = 0;\n      int nRight = 0;\n\n      Segment *pSeg = &pLevel->lhs;\n      aLeft[nLeft++] = pSeg;\n\n      for(i=0; i<pLevel->nRight; i++){\n        aRight[nRight++] = &pLevel->aRhs[i];\n      }\n\n#ifdef LSM_LOG_FREELIST\n      if( nRight ){\n        memmove(&aRight[1], aRight, sizeof(aRight[0])*nRight);\n        aRight[0] = 0;\n        nRight++;\n      }\n#endif\n\n      for(i=0; i<nLeft || i<nRight; i++){\n        int iPad = 0;\n        char zLevel[32];\n        zLeft[0] = '\\0';\n        zRight[0] = '\\0';\n\n        if( i<nLeft ){ \n          fileToString(pDb, zLeft, sizeof(zLeft), 24, aLeft[i]); \n        }\n        if( i<nRight ){ \n          fileToString(pDb, zRight, sizeof(zRight), 24, aRight[i]); \n        }\n\n        if( i==0 ){\n          snprintf(zLevel, sizeof(zLevel), \"L%d: (age=%d) (flags=%.4x)\",\n              iLevel, (int)pLevel->iAge, (int)pLevel->flags\n          );\n        }else{\n          zLevel[0] = '\\0';\n        }\n\n        if( nRight==0 ){\n          iPad = 10;\n        }\n\n        lsmLogMessage(pDb, LSM_OK, \"% 25s % *s% -35s %s\", \n            zLevel, iPad, \"\", zLeft, zRight\n        );\n      }\n\n      iLevel++;\n    }\n\n    if( bKeys ){\n      for(pLevel=pTopLevel; pLevel; pLevel=pLevel->pNext){\n        int i;\n        sortedDumpSegment(pDb, &pLevel->lhs, bVals);\n        for(i=0; i<pLevel->nRight; i++){\n          sortedDumpSegment(pDb, &pLevel->aRhs[i], bVals);\n        }\n      }\n    }\n  }\n\n  lsmInfoFreelist(pDb, &zFree);\n  lsmLogMessage(pDb, LSM_OK, \"Freelist: %s\", zFree);\n  lsmFree(pDb->pEnv, zFree);\n\n  assert( lsmFsIntegrityCheck(pDb) );\n}\n\nvoid lsmSortedFreeLevel(lsm_env *pEnv, Level *pLevel){\n  Level *pNext;\n  Level *p;\n\n  for(p=pLevel; p; p=pNext){\n    pNext = p->pNext;\n    sortedFreeLevel(pEnv, p);\n  }\n}\n\nvoid lsmSortedSaveTreeCursors(lsm_db *pDb){\n  MultiCursor *pCsr;\n  for(pCsr=pDb->pCsr; pCsr; pCsr=pCsr->pNext){\n    lsmTreeCursorSave(pCsr->apTreeCsr[0]);\n    lsmTreeCursorSave(pCsr->apTreeCsr[1]);\n  }\n}\n\nvoid lsmSortedExpandBtreePage(Page *pPg, int nOrig){\n  u8 *aData;\n  int nData;\n  int nEntry;\n  int iHdr;\n\n  aData = lsmFsPageData(pPg, &nData);\n  nEntry = pageGetNRec(aData, nOrig);\n  iHdr = SEGMENT_EOF(nOrig, nEntry);\n  memmove(&aData[iHdr + (nData-nOrig)], &aData[iHdr], nOrig-iHdr);\n}\n\n#ifdef LSM_DEBUG_EXPENSIVE\nstatic void assertRunInOrder(lsm_db *pDb, Segment *pSeg){\n  Page *pPg = 0;\n  Blob blob1 = {0, 0, 0, 0};\n  Blob blob2 = {0, 0, 0, 0};\n\n  lsmFsDbPageGet(pDb->pFS, pSeg, pSeg->iFirst, &pPg);\n  while( pPg ){\n    u8 *aData; int nData;\n    Page *pNext;\n\n    aData = lsmFsPageData(pPg, &nData);\n    if( 0==(pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG) ){\n      int i;\n      int nRec = pageGetNRec(aData, nData);\n      for(i=0; i<nRec; i++){\n        int iTopic1, iTopic2;\n        pageGetKeyCopy(pDb->pEnv, pSeg, pPg, i, &iTopic1, &blob1);\n\n        if( i==0 && blob2.nData ){\n          assert( sortedKeyCompare(\n                pDb->xCmp, iTopic2, blob2.pData, blob2.nData,\n                iTopic1, blob1.pData, blob1.nData\n          )<0 );\n        }\n\n        if( i<(nRec-1) ){\n          pageGetKeyCopy(pDb->pEnv, pSeg, pPg, i+1, &iTopic2, &blob2);\n          assert( sortedKeyCompare(\n                pDb->xCmp, iTopic1, blob1.pData, blob1.nData,\n                iTopic2, blob2.pData, blob2.nData\n          )<0 );\n        }\n      }\n    }\n\n    lsmFsDbPageNext(pSeg, pPg, 1, &pNext);\n    lsmFsPageRelease(pPg);\n    pPg = pNext;\n  }\n\n  sortedBlobFree(&blob1);\n  sortedBlobFree(&blob2);\n}\n#endif\n\n#ifdef LSM_DEBUG_EXPENSIVE\n/*\n** This function is only included in the build if LSM_DEBUG_EXPENSIVE is \n** defined. Its only purpose is to evaluate various assert() statements to \n** verify that the database is well formed in certain respects.\n**\n** More specifically, it checks that the array pOne contains the required \n** pointers to pTwo. Array pTwo must be a main array. pOne may be either a \n** separators array or another main array. If pOne does not contain the \n** correct set of pointers, an assert() statement fails.\n*/\nstatic int assertPointersOk(\n  lsm_db *pDb,                    /* Database handle */\n  Segment *pOne,                  /* Segment containing pointers */\n  Segment *pTwo,                  /* Segment containing pointer targets */\n  int bRhs                        /* True if pTwo may have been Gobble()d */\n){\n  int rc = LSM_OK;                /* Error code */\n  SegmentPtr ptr1;                /* Iterates through pOne */\n  SegmentPtr ptr2;                /* Iterates through pTwo */\n  Pgno iPrev;\n\n  assert( pOne && pTwo );\n\n  memset(&ptr1, 0, sizeof(ptr1));\n  memset(&ptr2, 0, sizeof(ptr1));\n  ptr1.pSeg = pOne;\n  ptr2.pSeg = pTwo;\n  segmentPtrEndPage(pDb->pFS, &ptr1, 0, &rc);\n  segmentPtrEndPage(pDb->pFS, &ptr2, 0, &rc);\n\n  /* Check that the footer pointer of the first page of pOne points to\n  ** the first page of pTwo. */\n  iPrev = pTwo->iFirst;\n  if( ptr1.iPtr!=iPrev && !bRhs ){\n    assert( 0 );\n  }\n\n  if( rc==LSM_OK && ptr1.nCell>0 ){\n    rc = segmentPtrLoadCell(&ptr1, 0);\n  }\n      \n  while( rc==LSM_OK && ptr2.pPg ){\n    Pgno iThis;\n\n    /* Advance to the next page of segment pTwo that contains at least\n    ** one cell. Break out of the loop if the iterator reaches EOF.  */\n    do{\n      rc = segmentPtrNextPage(&ptr2, 1);\n      assert( rc==LSM_OK );\n    }while( rc==LSM_OK && ptr2.pPg && ptr2.nCell==0 );\n    if( rc!=LSM_OK || ptr2.pPg==0 ) break;\n    iThis = lsmFsPageNumber(ptr2.pPg);\n\n    if( (ptr2.flags & (PGFTR_SKIP_THIS_FLAG|SEGMENT_BTREE_FLAG))==0 ){\n\n      /* Load the first cell in the array pTwo page. */\n      rc = segmentPtrLoadCell(&ptr2, 0);\n\n      /* Iterate forwards through pOne, searching for a key that matches the\n      ** key ptr2.pKey/nKey. This key should have a pointer to the page that\n      ** ptr2 currently points to. */\n      while( rc==LSM_OK ){\n        int res = rtTopic(ptr1.eType) - rtTopic(ptr2.eType);\n        if( res==0 ){\n          res = pDb->xCmp(ptr1.pKey, ptr1.nKey, ptr2.pKey, ptr2.nKey);\n        }\n\n        if( res<0 ){\n          assert( bRhs || ptr1.iPtr+ptr1.iPgPtr==iPrev );\n        }else if( res>0 ){\n          assert( 0 );\n        }else{\n          assert( ptr1.iPtr+ptr1.iPgPtr==iThis );\n          iPrev = iThis;\n          break;\n        }\n\n        rc = segmentPtrAdvance(0, &ptr1, 0);\n        if( ptr1.pPg==0 ){\n          assert( 0 );\n        }\n      }\n    }\n  }\n\n  segmentPtrReset(&ptr1, 0);\n  segmentPtrReset(&ptr2, 0);\n  return LSM_OK;\n}\n\n/*\n** This function is only included in the build if LSM_DEBUG_EXPENSIVE is \n** defined. Its only purpose is to evaluate various assert() statements to \n** verify that the database is well formed in certain respects.\n**\n** More specifically, it checks that the b-tree embedded in array pRun\n** contains the correct keys. If not, an assert() fails.\n*/\nstatic int assertBtreeOk(\n  lsm_db *pDb,\n  Segment *pSeg\n){\n  int rc = LSM_OK;                /* Return code */\n  if( pSeg->iRoot ){\n    Blob blob = {0, 0, 0};        /* Buffer used to cache overflow keys */\n    FileSystem *pFS = pDb->pFS;   /* File system to read from */\n    Page *pPg = 0;                /* Main run page */\n    BtreeCursor *pCsr = 0;        /* Btree cursor */\n\n    rc = btreeCursorNew(pDb, pSeg, &pCsr);\n    if( rc==LSM_OK ){\n      rc = btreeCursorFirst(pCsr);\n    }\n    if( rc==LSM_OK ){\n      rc = lsmFsDbPageGet(pFS, pSeg, pSeg->iFirst, &pPg);\n    }\n\n    while( rc==LSM_OK ){\n      Page *pNext;\n      u8 *aData;\n      int nData;\n      int flags;\n\n      rc = lsmFsDbPageNext(pSeg, pPg, 1, &pNext);\n      lsmFsPageRelease(pPg);\n      pPg = pNext;\n      if( pPg==0 ) break;\n      aData = fsPageData(pPg, &nData);\n      flags = pageGetFlags(aData, nData);\n      if( rc==LSM_OK \n       && 0==((SEGMENT_BTREE_FLAG|PGFTR_SKIP_THIS_FLAG) & flags)\n       && 0!=pageGetNRec(aData, nData)\n      ){\n        u8 *pKey;\n        int nKey;\n        int iTopic;\n        pKey = pageGetKey(pSeg, pPg, 0, &iTopic, &nKey, &blob);\n        assert( nKey==pCsr->nKey && 0==memcmp(pKey, pCsr->pKey, nKey) );\n        assert( lsmFsPageNumber(pPg)==pCsr->iPtr );\n        rc = btreeCursorNext(pCsr);\n      }\n    }\n    assert( rc!=LSM_OK || pCsr->pKey==0 );\n\n    if( pPg ) lsmFsPageRelease(pPg);\n\n    btreeCursorFree(pCsr);\n    sortedBlobFree(&blob);\n  }\n\n  return rc;\n}\n#endif /* ifdef LSM_DEBUG_EXPENSIVE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_str.c",
    "content": "/*\n** 2012-04-27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Dynamic string functions.\n*/\n#include \"lsmInt.h\"\n\n/*\n** Turn bulk and uninitialized memory into an LsmString object\n*/\nvoid lsmStringInit(LsmString *pStr, lsm_env *pEnv){\n  memset(pStr, 0, sizeof(pStr[0]));\n  pStr->pEnv = pEnv;\n}\n\n/*\n** Increase the memory allocated for holding the string.  Realloc as needed.\n**\n** If a memory allocation error occurs, set pStr->n to -1 and free the existing\n** allocation.  If a prior memory allocation has occurred, this routine is a\n** no-op.\n*/\nint lsmStringExtend(LsmString *pStr, int nNew){\n  assert( nNew>0 );\n  if( pStr->n<0 ) return LSM_NOMEM;\n  if( pStr->n + nNew >= pStr->nAlloc ){\n    int nAlloc = pStr->n + nNew + 100;\n    char *zNew = lsmRealloc(pStr->pEnv, pStr->z, nAlloc);\n    if( zNew==0 ){\n      lsmFree(pStr->pEnv, pStr->z);\n      nAlloc = 0;\n      pStr->n = -1;\n    }\n    pStr->nAlloc = nAlloc;\n    pStr->z = zNew;\n  }\n  return (pStr->z ? LSM_OK : LSM_NOMEM_BKPT);\n}\n\n/*\n** Clear an LsmString object, releasing any allocated memory that it holds.\n** This also clears the error indication (if any).\n*/\nvoid lsmStringClear(LsmString *pStr){\n  lsmFree(pStr->pEnv, pStr->z);\n  lsmStringInit(pStr, pStr->pEnv);\n}\n\n/*\n** Append N bytes of text to the end of an LsmString object.  If\n** N is negative, append the entire string.\n**\n** If the string is in an error state, this routine is a no-op.\n*/\nint lsmStringAppend(LsmString *pStr, const char *z, int N){\n  int rc;\n  if( N<0 ) N = (int)strlen(z);\n  rc = lsmStringExtend(pStr, N+1);\n  if( pStr->nAlloc ){\n    memcpy(pStr->z+pStr->n, z, N+1);\n    pStr->n += N;\n  }\n  return rc;\n}\n\nint lsmStringBinAppend(LsmString *pStr, const u8 *a, int n){\n  int rc;\n  rc = lsmStringExtend(pStr, n);\n  if( pStr->nAlloc ){\n    memcpy(pStr->z+pStr->n, a, n);\n    pStr->n += n;\n  }\n  return rc;\n}\n\n/*\n** Append printf-formatted content to an LsmString.\n*/\nvoid lsmStringVAppendf(\n  LsmString *pStr, \n  const char *zFormat, \n  va_list ap1,\n  va_list ap2\n){\n#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__<199901L)) && \\\n    !defined(__APPLE__)\n  extern int vsnprintf(char *str, size_t size, const char *format, va_list ap)\n    /* Compatibility crutch for C89 compilation mode. sqlite3_vsnprintf()\n       does not work identically and causes test failures if used here.\n       For the time being we are assuming that the target has vsnprintf(),\n       but that is not guaranteed to be the case for pure C89 platforms.\n    */;\n#endif\n  int nWrite;\n  int nAvail;\n\n  nAvail = pStr->nAlloc - pStr->n;\n  nWrite = vsnprintf(pStr->z + pStr->n, nAvail, zFormat, ap1);\n\n  if( nWrite>=nAvail ){\n    lsmStringExtend(pStr, nWrite+1);\n    if( pStr->nAlloc==0 ) return;\n    nWrite = vsnprintf(pStr->z + pStr->n, nWrite+1, zFormat, ap2);\n  }\n\n  pStr->n += nWrite;\n  pStr->z[pStr->n] = 0;\n}\n\nvoid lsmStringAppendf(LsmString *pStr, const char *zFormat, ...){\n  va_list ap, ap2;\n  va_start(ap, zFormat);\n  va_start(ap2, zFormat);\n  lsmStringVAppendf(pStr, zFormat, ap, ap2);\n  va_end(ap);\n  va_end(ap2);\n}\n\nint lsmStrlen(const char *zName){\n  int nRet = 0;\n  while( zName[nRet] ) nRet++;\n  return nRet;\n}\n\n/*\n** Write into memory obtained from lsm_malloc().\n*/\nchar *lsmMallocPrintf(lsm_env *pEnv, const char *zFormat, ...){\n  LsmString s;\n  va_list ap, ap2;\n  lsmStringInit(&s, pEnv);\n  va_start(ap, zFormat);\n  va_start(ap2, zFormat);\n  lsmStringVAppendf(&s, zFormat, ap, ap2);\n  va_end(ap);\n  va_end(ap2);\n  if( s.n<0 ) return 0;\n  return (char *)lsmReallocOrFree(pEnv, s.z, s.n+1);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_tree.c",
    "content": "/*\n** 2011-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of an in-memory tree structure.\n**\n** Technically the tree is a B-tree of order 4 (in the Knuth sense - each \n** node may have up to 4 children). Keys are stored within B-tree nodes by\n** reference. This may be slightly slower than a conventional red-black\n** tree, but it is simpler. It is also an easier structure to modify to \n** create a version that supports nested transaction rollback.\n**\n** This tree does not currently support a delete operation. One is not \n** required. When LSM deletes a key from a database, it inserts a DELETE\n** marker into the data structure. As a result, although the value associated\n** with a key stored in the in-memory tree structure may be modified, no\n** keys are ever removed. \n*/\n\n/*\n** MVCC NOTES\n**\n**   The in-memory tree structure supports SQLite-style MVCC. This means\n**   that while one client is writing to the tree structure, other clients\n**   may still be querying an older snapshot of the tree.\n**\n**   One way to implement this is to use an append-only b-tree. In this \n**   case instead of modifying nodes in-place, a copy of the node is made\n**   and the required modifications made to the copy. The parent of the\n**   node is then modified (to update the pointer so that it points to\n**   the new copy), which causes a copy of the parent to be made, and so on.\n**   This means that each time the tree is written to a new root node is\n**   created. A snapshot is identified by the root node that it uses.\n**\n**   The problem with the above is that each time the tree is written to,\n**   a copy of the node structure modified and all of its ancestor nodes\n**   is made. This may prove excessive with large tree structures.\n**\n**   To reduce this overhead, the data structure used for a tree node is\n**   designed so that it may be edited in place exactly once without \n**   affecting existing users. In other words, the node structure is capable\n**   of storing two separate versions of the node at the same time.\n**   When a node is to be edited, if the node structure already contains \n**   two versions, a copy is made as in the append-only approach. Or, if\n**   it only contains a single version, it is edited in place.\n**\n**   This reduces the overhead so that, roughly, one new node structure\n**   must be allocated for each write (on top of those allocations that \n**   would have been required by a non-MVCC tree). Logic: Assume that at \n**   any time, 50% of nodes in the tree already contain 2 versions. When\n**   a new entry is written to a node, there is a 50% chance that a copy\n**   of the node will be required. And a 25% chance that a copy of its \n**   parent is required. And so on.\n**\n** ROLLBACK\n**\n**   The in-memory tree also supports transaction and sub-transaction \n**   rollback. In order to rollback to point in time X, the following is\n**   necessary:\n**\n**     1. All memory allocated since X must be freed, and \n**     2. All \"v2\" data adding to nodes that existed at X should be zeroed.\n**     3. The root node must be restored to its X value.\n**\n**   The Mempool object used to allocate memory for the tree supports \n**   operation (1) - see the lsmPoolMark() and lsmPoolRevert() functions.\n**\n**   To support (2), all nodes that have v2 data are part of a singly linked \n**   list, sorted by the age of the v2 data (nodes that have had data added \n**   most recently are at the end of the list). So to zero all v2 data added\n**   since X, the linked list is traversed from the first node added following\n**   X onwards.\n**\n*/\n\n#ifndef _LSM_INT_H\n# include \"lsmInt.h\"\n#endif\n\n#include <string.h>\n\n#define MAX_DEPTH 32\n\ntypedef struct TreeKey TreeKey;\ntypedef struct TreeNode TreeNode;\ntypedef struct TreeLeaf TreeLeaf;\ntypedef struct NodeVersion NodeVersion;\n\nstruct TreeOld {\n  u32 iShmid;                     /* Last shared-memory chunk in use by old */\n  u32 iRoot;                      /* Offset of root node in shm file */\n  u32 nHeight;                    /* Height of tree structure */\n};\n\n#if 0\n/*\n** assert() that a TreeKey.flags value is sane. Usage:\n**\n**   assert( lsmAssertFlagsOk(pTreeKey->flags) );\n*/\nstatic int lsmAssertFlagsOk(u8 keyflags){\n  /* At least one flag must be set. Otherwise, what is this key doing? */\n  assert( keyflags!=0 );\n\n  /* The POINT_DELETE and INSERT flags cannot both be set. */\n  assert( (keyflags & LSM_POINT_DELETE)==0 || (keyflags & LSM_INSERT)==0 );\n\n  /* If both the START_DELETE and END_DELETE flags are set, then the INSERT\n  ** flag must also be set. In other words - the three DELETE flags cannot\n  ** all be set */\n  assert( (keyflags & LSM_END_DELETE)==0 \n       || (keyflags & LSM_START_DELETE)==0 \n       || (keyflags & LSM_POINT_DELETE)==0 \n  );\n\n  return 1;\n}\n#endif\nstatic int assert_delete_ranges_match(lsm_db *);\nstatic int treeCountEntries(lsm_db *db);\n\n/*\n** Container for a key-value pair. Within the *-shm file, each key/value\n** pair is stored in a single allocation (which may not actually be \n** contiguous in memory). Layout is the TreeKey structure, followed by\n** the nKey bytes of key blob, followed by the nValue bytes of value blob\n** (if nValue is non-negative).\n*/\nstruct TreeKey {\n  int nKey;                       /* Size of pKey in bytes */\n  int nValue;                     /* Size of pValue. Or negative. */\n  u8 flags;                       /* Various LSM_XXX flags */\n};\n\n#define TKV_KEY(p) ((void *)&(p)[1])\n#define TKV_VAL(p) ((void *)(((u8 *)&(p)[1]) + (p)->nKey))\n\n/*\n** A single tree node. A node structure may contain up to 3 key/value\n** pairs. Internal (non-leaf) nodes have up to 4 children.\n**\n** TODO: Update the format of this to be more compact. Get it working\n** first though...\n*/\nstruct TreeNode {\n  u32 aiKeyPtr[3];                /* Array of pointers to TreeKey objects */\n\n  /* The following fields are present for interior nodes only, not leaves. */\n  u32 aiChildPtr[4];              /* Array of pointers to child nodes */\n\n  /* The extra child pointer slot. */\n  u32 iV2;                        /* Transaction number of v2 */\n  u8 iV2Child;                    /* apChild[] entry replaced by pV2Ptr */\n  u32 iV2Ptr;                     /* Substitute pointer */\n};\n\nstruct TreeLeaf {\n  u32 aiKeyPtr[3];                /* Array of pointers to TreeKey objects */\n};\n\ntypedef struct TreeBlob TreeBlob;\nstruct TreeBlob {\n  int n;\n  u8 *a;\n};\n\n/*\n** Cursor for searching a tree structure.\n**\n** If a cursor does not point to any element (a.k.a. EOF), then the\n** TreeCursor.iNode variable is set to a negative value. Otherwise, the\n** cursor currently points to key aiCell[iNode] on node apTreeNode[iNode].\n**\n** Entries in the apTreeNode[] and aiCell[] arrays contain the node and\n** index of the TreeNode.apChild[] pointer followed to descend to the \n** current element. Hence apTreeNode[0] always contains the root node of\n** the tree.\n*/\nstruct TreeCursor {\n  lsm_db *pDb;                    /* Database handle for this cursor */\n  TreeRoot *pRoot;                /* Root node and height of tree to access */\n  int iNode;                      /* Cursor points at apTreeNode[iNode] */\n  TreeNode *apTreeNode[MAX_DEPTH];/* Current position in tree */\n  u8 aiCell[MAX_DEPTH];           /* Current position in tree */\n  TreeKey *pSave;                 /* Saved key */\n  TreeBlob blob;                  /* Dynamic storage for a key */\n};\n\n/*\n** A value guaranteed to be larger than the largest possible transaction\n** id (TreeHeader.iTransId).\n*/\n#define WORKING_VERSION (1<<30)\n\nstatic int tblobGrow(lsm_db *pDb, TreeBlob *p, int n, int *pRc){\n  if( n>p->n ){\n    lsmFree(pDb->pEnv, p->a);\n    p->a = lsmMallocRc(pDb->pEnv, n, pRc);\n    p->n = n;\n  }\n  return (p->a==0);\n}\nstatic void tblobFree(lsm_db *pDb, TreeBlob *p){\n  lsmFree(pDb->pEnv, p->a);\n}\n\n\n/***********************************************************************\n** Start of IntArray methods.  */\n/*\n** Append value iVal to the contents of IntArray *p. Return LSM_OK if \n** successful, or LSM_NOMEM if an OOM condition is encountered.\n*/\nstatic int intArrayAppend(lsm_env *pEnv, IntArray *p, u32 iVal){\n  assert( p->nArray<=p->nAlloc );\n  if( p->nArray>=p->nAlloc ){\n    u32 *aNew;\n    int nNew = p->nArray ? p->nArray*2 : 128;\n    aNew = lsmRealloc(pEnv, p->aArray, nNew*sizeof(u32));\n    if( !aNew ) return LSM_NOMEM_BKPT;\n    p->aArray = aNew;\n    p->nAlloc = nNew;\n  }\n\n  p->aArray[p->nArray++] = iVal;\n  return LSM_OK;\n}\n\n/*\n** Zero the IntArray object.\n*/\nstatic void intArrayFree(lsm_env *pEnv, IntArray *p){\n  p->nArray = 0;\n}\n\n/*\n** Return the number of entries currently in the int-array object.\n*/\nstatic int intArraySize(IntArray *p){\n  return p->nArray;\n}\n\n/*\n** Return a copy of the iIdx'th entry in the int-array.\n*/\nstatic u32 intArrayEntry(IntArray *p, int iIdx){\n  return p->aArray[iIdx];\n}\n\n/*\n** Truncate the int-array so that all but the first nVal values are \n** discarded.\n*/\nstatic void intArrayTruncate(IntArray *p, int nVal){\n  p->nArray = nVal;\n}\n/* End of IntArray methods.\n***********************************************************************/\n\nstatic int treeKeycmp(void *p1, int n1, void *p2, int n2){\n  int res;\n  res = memcmp(p1, p2, LSM_MIN(n1, n2));\n  if( res==0 ) res = (n1-n2);\n  return res;\n}\n\n/*\n** The pointer passed as the first argument points to an interior node,\n** not a leaf. This function returns the offset of the iCell'th child\n** sub-tree of the node.\n*/\nstatic u32 getChildPtr(TreeNode *p, int iVersion, int iCell){\n  assert( iVersion>=0 );\n  assert( iCell>=0 && iCell<=array_size(p->aiChildPtr) );\n  if( p->iV2 && p->iV2<=(u32)iVersion && iCell==p->iV2Child ) return p->iV2Ptr;\n  return p->aiChildPtr[iCell];\n}\n\n/*\n** Given an offset within the *-shm file, return the associated chunk number.\n*/\nstatic int treeOffsetToChunk(u32 iOff){\n  assert( LSM_SHM_CHUNK_SIZE==(1<<15) );\n  return (int)(iOff>>15);\n}\n\n#define treeShmptrUnsafe(pDb, iPtr) \\\n(&((u8*)((pDb)->apShm[(iPtr)>>15]))[(iPtr) & (LSM_SHM_CHUNK_SIZE-1)])\n\n/*\n** Return a pointer to the mapped memory location associated with *-shm \n** file offset iPtr.\n*/\nstatic void *treeShmptr(lsm_db *pDb, u32 iPtr){\n\n  assert( (iPtr>>15)<(u32)pDb->nShm );\n  assert( pDb->apShm[iPtr>>15] );\n\n  return iPtr ? treeShmptrUnsafe(pDb, iPtr) : 0;\n}\n\nstatic ShmChunk * treeShmChunk(lsm_db *pDb, int iChunk){\n  return (ShmChunk *)(pDb->apShm[iChunk]);\n}\n\nstatic ShmChunk * treeShmChunkRc(lsm_db *pDb, int iChunk, int *pRc){\n  assert( *pRc==LSM_OK );\n  if( iChunk<pDb->nShm || LSM_OK==(*pRc = lsmShmCacheChunks(pDb, iChunk+1)) ){\n    return (ShmChunk *)(pDb->apShm[iChunk]);\n  }\n  return 0;\n}\n\n\n#ifndef NDEBUG\nstatic void assertIsWorkingChild(\n  lsm_db *db, \n  TreeNode *pNode, \n  TreeNode *pParent, \n  int iCell\n){\n  TreeNode *p;\n  u32 iPtr = getChildPtr(pParent, WORKING_VERSION, iCell);\n  p = treeShmptr(db, iPtr);\n  assert( p==pNode );\n}\n#else\n# define assertIsWorkingChild(w,x,y,z)\n#endif\n\n/* Values for the third argument to treeShmkey(). */\n#define TKV_LOADKEY  1\n#define TKV_LOADVAL  2\n\nstatic TreeKey *treeShmkey(\n  lsm_db *pDb,                    /* Database handle */\n  u32 iPtr,                       /* Shmptr to TreeKey struct */\n  int eLoad,                      /* Either zero or a TREEKEY_LOADXXX value */\n  TreeBlob *pBlob,                /* Used if dynamic memory is required */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  TreeKey *pRet;\n\n  assert( eLoad==TKV_LOADKEY || eLoad==TKV_LOADVAL );\n  pRet = (TreeKey *)treeShmptr(pDb, iPtr);\n  if( pRet ){\n    int nReq;                     /* Bytes of space required at pRet */\n    int nAvail;                   /* Bytes of space available at pRet */\n\n    nReq = sizeof(TreeKey) + pRet->nKey;\n    if( eLoad==TKV_LOADVAL && pRet->nValue>0 ){\n      nReq += pRet->nValue;\n    }\n    assert( LSM_SHM_CHUNK_SIZE==(1<<15) );\n    nAvail = LSM_SHM_CHUNK_SIZE - (iPtr & (LSM_SHM_CHUNK_SIZE-1));\n\n    if( nAvail<nReq ){\n      if( tblobGrow(pDb, pBlob, nReq, pRc)==0 ){\n        int nLoad = 0;\n        while( *pRc==LSM_OK ){\n          ShmChunk *pChunk;\n          void *p = treeShmptr(pDb, iPtr);\n          int n = LSM_MIN(nAvail, nReq-nLoad);\n\n          memcpy(&pBlob->a[nLoad], p, n);\n          nLoad += n;\n          if( nLoad==nReq ) break;\n\n          pChunk = treeShmChunk(pDb, treeOffsetToChunk(iPtr));\n          assert( pChunk );\n          iPtr = (pChunk->iNext * LSM_SHM_CHUNK_SIZE) + LSM_SHM_CHUNK_HDR;\n          nAvail = LSM_SHM_CHUNK_SIZE - LSM_SHM_CHUNK_HDR;\n        }\n      }\n      pRet = (TreeKey *)(pBlob->a);\n    }\n  }\n\n  return pRet;\n}\n\n#if defined(LSM_DEBUG) && defined(LSM_EXPENSIVE_ASSERT)\nvoid assert_leaf_looks_ok(TreeNode *pNode){\n  assert( pNode->apKey[1] );\n}\n\nvoid assert_node_looks_ok(TreeNode *pNode, int nHeight){\n  if( pNode ){\n    assert( pNode->apKey[1] );\n    if( nHeight>1 ){\n      int i;\n      assert( getChildPtr(pNode, WORKING_VERSION, 1) );\n      assert( getChildPtr(pNode, WORKING_VERSION, 2) );\n      for(i=0; i<4; i++){\n        assert_node_looks_ok(getChildPtr(pNode, WORKING_VERSION, i), nHeight-1);\n      }\n    }\n  }\n}\n\n/*\n** Run various assert() statements to check that the working-version of the\n** tree is correct in the following respects:\n**\n**   * todo...\n*/\nvoid assert_tree_looks_ok(int rc, Tree *pTree){\n}\n#else\n# define assert_tree_looks_ok(x,y)\n#endif\n\nvoid lsmFlagsToString(int flags, char *zFlags){\n\n  zFlags[0] = (flags & LSM_END_DELETE)   ? ']' : '.';\n\n  /* Only one of LSM_POINT_DELETE, LSM_INSERT and LSM_SEPARATOR should ever\n  ** be set. If this is not true, write a '?' to the output.  */\n  switch( flags & (LSM_POINT_DELETE|LSM_INSERT|LSM_SEPARATOR) ){\n    case 0:                zFlags[1] = '.'; break;\n    case LSM_POINT_DELETE: zFlags[1] = '-'; break;\n    case LSM_INSERT:       zFlags[1] = '+'; break;\n    case LSM_SEPARATOR:    zFlags[1] = '^'; break;\n    default:               zFlags[1] = '?'; break;\n  }\n\n  zFlags[2] = (flags & LSM_SYSTEMKEY)    ? '*' : '.';\n  zFlags[3] = (flags & LSM_START_DELETE) ? '[' : '.';\n  zFlags[4] = '\\0';\n}\n\n#ifdef LSM_DEBUG\n\n/*\n** Pointer pBlob points to a buffer containing a blob of binary data\n** nBlob bytes long. Append the contents of this blob to *pStr, with\n** each octet represented by a 2-digit hexadecimal number. For example,\n** if the input blob is three bytes in size and contains {0x01, 0x44, 0xFF},\n** then \"0144ff\" is appended to *pStr.\n*/\nstatic void lsmAppendStrBlob(LsmString *pStr, void *pBlob, int nBlob){\n  int i;\n  lsmStringExtend(pStr, nBlob*2);\n  if( pStr->nAlloc==0 ) return;\n  for(i=0; i<nBlob; i++){\n    u8 c = ((u8*)pBlob)[i];\n    if( c>='a' && c<='z' ){\n      pStr->z[pStr->n++] = c;\n    }else if( c!=0 || nBlob==1 || i!=(nBlob-1) ){\n      pStr->z[pStr->n++] = \"0123456789abcdef\"[(c>>4)&0xf];\n      pStr->z[pStr->n++] = \"0123456789abcdef\"[c&0xf];\n    }\n  }\n  pStr->z[pStr->n] = 0;\n}\n\n#if 0  /* NOT USED */\n/*\n** Append nIndent space (0x20) characters to string *pStr.\n*/\nstatic void lsmAppendIndent(LsmString *pStr, int nIndent){\n  int i;\n  lsmStringExtend(pStr, nIndent);\n  for(i=0; i<nIndent; i++) lsmStringAppend(pStr, \" \", 1);\n}\n#endif\n\nstatic void strAppendFlags(LsmString *pStr, u8 flags){\n  char zFlags[8];\n\n  lsmFlagsToString(flags, zFlags);\n  zFlags[4] = ':';\n\n  lsmStringAppend(pStr, zFlags, 5);\n}\n\nvoid dump_node_contents(\n  lsm_db *pDb,\n  u32 iNode,                      /* Print out the contents of this node */\n  char *zPath,                    /* Path from root to this node */\n  int nPath,                      /* Number of bytes in zPath */\n  int nHeight                     /* Height: (0==leaf) (1==parent-of-leaf) */\n){\n  const char *zSpace = \"                                           \";\n  int i;\n  int rc = LSM_OK;\n  LsmString s;\n  TreeNode *pNode;\n  TreeBlob b = {0, 0};\n\n  pNode = (TreeNode *)treeShmptr(pDb, iNode);\n\n  if( nHeight==0 ){\n    /* Append the nIndent bytes of space to string s. */\n    lsmStringInit(&s, pDb->pEnv);\n\n    /* Append each key to string s. */\n    for(i=0; i<3; i++){\n      u32 iPtr = pNode->aiKeyPtr[i];\n      if( iPtr ){\n        TreeKey *pKey = treeShmkey(pDb, pNode->aiKeyPtr[i],TKV_LOADKEY, &b,&rc);\n        strAppendFlags(&s, pKey->flags);\n        lsmAppendStrBlob(&s, TKV_KEY(pKey), pKey->nKey);\n        lsmStringAppend(&s, \"     \", -1);\n      }\n    }\n\n    printf(\"% 6d %.*sleaf%.*s: %s\\n\", \n        iNode, nPath, zPath, 20-nPath-4, zSpace, s.z\n    );\n    lsmStringClear(&s);\n  }else{\n    for(i=0; i<4 && nHeight>0; i++){\n      u32 iPtr = getChildPtr(pNode, pDb->treehdr.root.iTransId, i);\n      zPath[nPath] = (char)(i+'0');\n      zPath[nPath+1] = '/';\n\n      if( iPtr ){\n        dump_node_contents(pDb, iPtr, zPath, nPath+2, nHeight-1);\n      }\n      if( i!=3 && pNode->aiKeyPtr[i] ){\n        TreeKey *pKey = treeShmkey(pDb, pNode->aiKeyPtr[i], TKV_LOADKEY,&b,&rc);\n        lsmStringInit(&s, pDb->pEnv);\n        strAppendFlags(&s, pKey->flags);\n        lsmAppendStrBlob(&s, TKV_KEY(pKey), pKey->nKey);\n        printf(\"% 6d %.*s%.*s: %s\\n\", \n            iNode, nPath+1, zPath, 20-nPath-1, zSpace, s.z);\n        lsmStringClear(&s);\n      }\n    }\n  }\n\n  tblobFree(pDb, &b);\n}\n\nvoid dump_tree_contents(lsm_db *pDb, const char *zCaption){\n  char zPath[64];\n  TreeRoot *p = &pDb->treehdr.root;\n  printf(\"\\n%s\\n\", zCaption);\n  zPath[0] = '/';\n  if( p->iRoot ){\n    dump_node_contents(pDb, p->iRoot, zPath, 1, p->nHeight-1);\n  }\n  fflush(stdout);\n}\n\n#endif\n\n/*\n** Initialize a cursor object, the space for which has already been\n** allocated.\n*/\nstatic void treeCursorInit(lsm_db *pDb, int bOld, TreeCursor *pCsr){\n  memset(pCsr, 0, sizeof(TreeCursor));\n  pCsr->pDb = pDb;\n  if( bOld ){\n    pCsr->pRoot = &pDb->treehdr.oldroot;\n  }else{\n    pCsr->pRoot = &pDb->treehdr.root;\n  }\n  pCsr->iNode = -1;\n}\n\n/*\n** Return a pointer to the mapping of the TreeKey object that the cursor\n** is pointing to. \n*/\nstatic TreeKey *csrGetKey(TreeCursor *pCsr, TreeBlob *pBlob, int *pRc){\n  TreeKey *pRet;\n  lsm_db *pDb = pCsr->pDb;\n  u32 iPtr = pCsr->apTreeNode[pCsr->iNode]->aiKeyPtr[pCsr->aiCell[pCsr->iNode]];\n\n  assert( iPtr );\n  pRet = (TreeKey*)treeShmptrUnsafe(pDb, iPtr);\n  if( !(pRet->flags & LSM_CONTIGUOUS) ){\n    pRet = treeShmkey(pDb, iPtr, TKV_LOADVAL, pBlob, pRc);\n  }\n\n  return pRet;\n}\n\n/*\n** Save the current position of tree cursor pCsr.\n*/\nint lsmTreeCursorSave(TreeCursor *pCsr){\n  int rc = LSM_OK;\n  if( pCsr && pCsr->pSave==0 ){\n    int iNode = pCsr->iNode;\n    if( iNode>=0 ){\n      pCsr->pSave = csrGetKey(pCsr, &pCsr->blob, &rc);\n    }\n    pCsr->iNode = -1;\n  }\n  return rc;\n}\n\n/*\n** Restore the position of a saved tree cursor.\n*/\nstatic int treeCursorRestore(TreeCursor *pCsr, int *pRes){\n  int rc = LSM_OK;\n  if( pCsr->pSave ){\n    TreeKey *pKey = pCsr->pSave;\n    pCsr->pSave = 0;\n    if( pRes ){\n      rc = lsmTreeCursorSeek(pCsr, TKV_KEY(pKey), pKey->nKey, pRes);\n    }\n  }\n  return rc;\n}\n\n/*\n** Allocate nByte bytes of space within the *-shm file. If successful, \n** return LSM_OK and set *piPtr to the offset within the file at which\n** the allocated space is located.\n*/\nstatic u32 treeShmalloc(lsm_db *pDb, int bAlign, int nByte, int *pRc){\n  u32 iRet = 0;\n  if( *pRc==LSM_OK ){\n    const static int CHUNK_SIZE = LSM_SHM_CHUNK_SIZE;\n    const static int CHUNK_HDR = LSM_SHM_CHUNK_HDR;\n    u32 iWrite;                   /* Current write offset */\n    u32 iEof;                     /* End of current chunk */\n    int iChunk;                   /* Current chunk */\n\n    assert( nByte <= (CHUNK_SIZE-CHUNK_HDR) );\n\n    /* Check if there is enough space on the current chunk to fit the\n    ** new allocation. If not, link in a new chunk and put the new\n    ** allocation at the start of it.  */\n    iWrite = pDb->treehdr.iWrite;\n    if( bAlign ){\n      iWrite = (iWrite + 3) & ~0x0003;\n      assert( (iWrite % 4)==0 );\n    }\n\n    assert( iWrite );\n    iChunk = treeOffsetToChunk(iWrite-1);\n    iEof = (iChunk+1) * CHUNK_SIZE;\n    assert( iEof>=iWrite && (iEof-iWrite)<(u32)CHUNK_SIZE );\n    if( (iWrite+nByte)>iEof ){\n      ShmChunk *pHdr;           /* Header of chunk just finished (iChunk) */\n      ShmChunk *pFirst;         /* Header of chunk treehdr.iFirst */\n      ShmChunk *pNext;          /* Header of new chunk */\n      int iNext = 0;            /* Next chunk */\n      int rc = LSM_OK;\n\n      pFirst = treeShmChunk(pDb, pDb->treehdr.iFirst);\n\n      assert( shm_sequence_ge(pDb->treehdr.iUsedShmid, pFirst->iShmid) );\n      assert( (pDb->treehdr.iNextShmid+1-pDb->treehdr.nChunk)==pFirst->iShmid );\n\n      /* Check if the chunk at the start of the linked list is still in\n      ** use. If not, reuse it. If so, allocate a new chunk by appending\n      ** to the *-shm file.  */\n      if( pDb->treehdr.iUsedShmid!=pFirst->iShmid ){\n        int bInUse;\n        rc = lsmTreeInUse(pDb, pFirst->iShmid, &bInUse);\n        if( rc!=LSM_OK ){\n          *pRc = rc;\n          return 0;\n        }\n        if( bInUse==0 ){\n          iNext = pDb->treehdr.iFirst;\n          pDb->treehdr.iFirst = pFirst->iNext;\n          assert( pDb->treehdr.iFirst );\n        }\n      }\n      if( iNext==0 ) iNext = pDb->treehdr.nChunk++;\n\n      /* Set the header values for the new chunk */\n      pNext = treeShmChunkRc(pDb, iNext, &rc);\n      if( pNext ){\n        pNext->iNext = 0;\n        pNext->iShmid = (pDb->treehdr.iNextShmid++);\n      }else{\n        *pRc = rc;\n        return 0;\n      }\n\n      /* Set the header values for the chunk just finished */\n      pHdr = (ShmChunk *)treeShmptr(pDb, iChunk*CHUNK_SIZE);\n      pHdr->iNext = iNext;\n\n      /* Advance to the next chunk */\n      iWrite = iNext * CHUNK_SIZE + CHUNK_HDR;\n    }\n\n    /* Allocate space at iWrite. */\n    iRet = iWrite;\n    pDb->treehdr.iWrite = iWrite + nByte;\n    pDb->treehdr.root.nByte += nByte;\n  }\n  return iRet;\n}\n\n/*\n** Allocate and zero nByte bytes of space within the *-shm file.\n*/\nstatic void *treeShmallocZero(lsm_db *pDb, int nByte, u32 *piPtr, int *pRc){\n  u32 iPtr;\n  void *p;\n  iPtr = treeShmalloc(pDb, 1, nByte, pRc);\n  p = treeShmptr(pDb, iPtr);\n  if( p ){\n    assert( *pRc==LSM_OK );\n    memset(p, 0, nByte);\n    *piPtr = iPtr;\n  }\n  return p;\n}\n\nstatic TreeNode *newTreeNode(lsm_db *pDb, u32 *piPtr, int *pRc){\n  return treeShmallocZero(pDb, sizeof(TreeNode), piPtr, pRc);\n}\n\nstatic TreeLeaf *newTreeLeaf(lsm_db *pDb, u32 *piPtr, int *pRc){\n  return treeShmallocZero(pDb, sizeof(TreeLeaf), piPtr, pRc);\n}\n\nstatic TreeKey *newTreeKey(\n  lsm_db *pDb, \n  u32 *piPtr, \n  void *pKey, int nKey,           /* Key data */\n  void *pVal, int nVal,           /* Value data (or nVal<0 for delete) */\n  int *pRc\n){\n  TreeKey *p;\n  u32 iPtr;\n  u32 iEnd;\n  int nRem;\n  u8 *a;\n  int n;\n\n  /* Allocate space for the TreeKey structure itself */\n  *piPtr = iPtr = treeShmalloc(pDb, 1, sizeof(TreeKey), pRc);\n  p = treeShmptr(pDb, iPtr);\n  if( *pRc ) return 0;\n  p->nKey = nKey;\n  p->nValue = nVal;\n\n  /* Allocate and populate the space required for the key and value. */\n  n = nRem = nKey;\n  a = (u8 *)pKey;\n  while( a ){\n    while( nRem>0 ){\n      u8 *aAlloc;\n      int nAlloc;\n      u32 iWrite;\n\n      iWrite = (pDb->treehdr.iWrite & (LSM_SHM_CHUNK_SIZE-1));\n      iWrite = LSM_MAX(iWrite, LSM_SHM_CHUNK_HDR);\n      nAlloc = LSM_MIN((LSM_SHM_CHUNK_SIZE-iWrite), (u32)nRem);\n\n      aAlloc = treeShmptr(pDb, treeShmalloc(pDb, 0, nAlloc, pRc));\n      if( aAlloc==0 ) break;\n      memcpy(aAlloc, &a[n-nRem], nAlloc);\n      nRem -= nAlloc;\n    }\n    a = pVal;\n    n = nRem = nVal;\n    pVal = 0;\n  }\n\n  iEnd = iPtr + sizeof(TreeKey) + nKey + LSM_MAX(0, nVal);\n  if( (iPtr & ~(LSM_SHM_CHUNK_SIZE-1))!=(iEnd & ~(LSM_SHM_CHUNK_SIZE-1)) ){\n    p->flags = 0;\n  }else{\n    p->flags = LSM_CONTIGUOUS;\n  }\n\n  if( *pRc ) return 0;\n#if 0\n  printf(\"store: %d %s\\n\", (int)iPtr, (char *)pKey);\n#endif\n  return p;\n}\n\nstatic TreeNode *copyTreeNode(\n  lsm_db *pDb, \n  TreeNode *pOld, \n  u32 *piNew, \n  int *pRc\n){\n  TreeNode *pNew;\n\n  pNew = newTreeNode(pDb, piNew, pRc);\n  if( pNew ){\n    memcpy(pNew->aiKeyPtr, pOld->aiKeyPtr, sizeof(pNew->aiKeyPtr));\n    memcpy(pNew->aiChildPtr, pOld->aiChildPtr, sizeof(pNew->aiChildPtr));\n    if( pOld->iV2 ) pNew->aiChildPtr[pOld->iV2Child] = pOld->iV2Ptr;\n  }\n  return pNew;\n}\n\nstatic TreeNode *copyTreeLeaf(\n  lsm_db *pDb, \n  TreeLeaf *pOld, \n  u32 *piNew, \n  int *pRc\n){\n  TreeLeaf *pNew;\n  pNew = newTreeLeaf(pDb, piNew, pRc);\n  if( pNew ){\n    memcpy(pNew, pOld, sizeof(TreeLeaf));\n  }\n  return (TreeNode *)pNew;\n}\n\n/*\n** The tree cursor passed as the second argument currently points to an \n** internal node (not a leaf). Specifically, to a sub-tree pointer. This\n** function replaces the sub-tree that the cursor currently points to\n** with sub-tree pNew.\n**\n** The sub-tree may be replaced either by writing the \"v2 data\" on the\n** internal node, or by allocating a new TreeNode structure and then \n** calling this function on the parent of the internal node.\n*/\nstatic int treeUpdatePtr(lsm_db *pDb, TreeCursor *pCsr, u32 iNew){\n  int rc = LSM_OK;\n  if( pCsr->iNode<0 ){\n    /* iNew is the new root node */\n    pDb->treehdr.root.iRoot = iNew;\n  }else{\n    /* If this node already has version 2 content, allocate a copy and\n    ** update the copy with the new pointer value. Otherwise, store the\n    ** new pointer as v2 data within the current node structure.  */\n\n    TreeNode *p;                  /* The node to be modified */\n    int iChildPtr;                /* apChild[] entry to modify */\n\n    p = pCsr->apTreeNode[pCsr->iNode];\n    iChildPtr = pCsr->aiCell[pCsr->iNode];\n\n    if( p->iV2 ){\n      /* The \"allocate new TreeNode\" option */\n      u32 iCopy;\n      TreeNode *pCopy;\n      pCopy = copyTreeNode(pDb, p, &iCopy, &rc);\n      if( pCopy ){\n        assert( rc==LSM_OK );\n        pCopy->aiChildPtr[iChildPtr] = iNew;\n        pCsr->iNode--;\n        rc = treeUpdatePtr(pDb, pCsr, iCopy);\n      }\n    }else{\n      /* The \"v2 data\" option */\n      u32 iPtr;\n      assert( pDb->treehdr.root.iTransId>0 );\n\n      if( pCsr->iNode ){\n        iPtr = getChildPtr(\n            pCsr->apTreeNode[pCsr->iNode-1], \n            pDb->treehdr.root.iTransId, pCsr->aiCell[pCsr->iNode-1]\n        );\n      }else{\n        iPtr = pDb->treehdr.root.iRoot;\n      }\n      rc = intArrayAppend(pDb->pEnv, &pDb->rollback, iPtr);\n\n      if( rc==LSM_OK ){\n        p->iV2 = pDb->treehdr.root.iTransId;\n        p->iV2Child = (u8)iChildPtr;\n        p->iV2Ptr = iNew;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Cursor pCsr points at a node that is part of pTree. This function\n** inserts a new key and optionally child node pointer into that node.\n**\n** The position into which the new key and pointer are inserted is\n** determined by the iSlot parameter. The new key will be inserted to\n** the left of the key currently stored in apKey[iSlot]. Or, if iSlot is\n** greater than the index of the rightmost key in the node.\n**\n** Pointer pLeftPtr points to a child tree that contains keys that are\n** smaller than pTreeKey.\n*/\nstatic int treeInsert(\n  lsm_db *pDb,                    /* Database handle */\n  TreeCursor *pCsr,               /* Cursor indicating path to insert at */\n  u32 iLeftPtr,                   /* Left child pointer */\n  u32 iTreeKey,                   /* Location of key to insert */\n  u32 iRightPtr,                  /* Right child pointer */\n  int iSlot                       /* Position to insert key into */\n){\n  int rc = LSM_OK;\n  TreeNode *pNode = pCsr->apTreeNode[pCsr->iNode];\n\n  /* Check if the node is currently full. If so, split pNode in two and\n  ** call this function recursively to add a key to the parent. Otherwise, \n  ** insert the new key directly into pNode.  */\n  assert( pNode->aiKeyPtr[1] );\n  if( pNode->aiKeyPtr[0] && pNode->aiKeyPtr[2] ){\n    u32 iLeft; TreeNode *pLeft;   /* New left-hand sibling node */\n    u32 iRight; TreeNode *pRight; /* New right-hand sibling node */\n\n    pLeft = newTreeNode(pDb, &iLeft, &rc);\n    pRight = newTreeNode(pDb, &iRight, &rc);\n    if( rc ) return rc;\n\n    pLeft->aiChildPtr[1] = getChildPtr(pNode, WORKING_VERSION, 0);\n    pLeft->aiKeyPtr[1] = pNode->aiKeyPtr[0];\n    pLeft->aiChildPtr[2] = getChildPtr(pNode, WORKING_VERSION, 1);\n\n    pRight->aiChildPtr[1] = getChildPtr(pNode, WORKING_VERSION, 2);\n    pRight->aiKeyPtr[1] = pNode->aiKeyPtr[2];\n    pRight->aiChildPtr[2] = getChildPtr(pNode, WORKING_VERSION, 3);\n\n    if( pCsr->iNode==0 ){\n      /* pNode is the root of the tree. Grow the tree by one level. */\n      u32 iRoot; TreeNode *pRoot; /* New root node */\n\n      pRoot = newTreeNode(pDb, &iRoot, &rc);\n      pRoot->aiKeyPtr[1] = pNode->aiKeyPtr[1];\n      pRoot->aiChildPtr[1] = iLeft;\n      pRoot->aiChildPtr[2] = iRight;\n\n      pDb->treehdr.root.iRoot = iRoot;\n      pDb->treehdr.root.nHeight++;\n    }else{\n\n      pCsr->iNode--;\n      rc = treeInsert(pDb, pCsr, \n          iLeft, pNode->aiKeyPtr[1], iRight, pCsr->aiCell[pCsr->iNode]\n      );\n    }\n\n    assert( pLeft->iV2==0 );\n    assert( pRight->iV2==0 );\n    switch( iSlot ){\n      case 0:\n        pLeft->aiKeyPtr[0] = iTreeKey;\n        pLeft->aiChildPtr[0] = iLeftPtr;\n        if( iRightPtr ) pLeft->aiChildPtr[1] = iRightPtr;\n        break;\n      case 1:\n        pLeft->aiChildPtr[3] = (iRightPtr ? iRightPtr : pLeft->aiChildPtr[2]);\n        pLeft->aiKeyPtr[2] = iTreeKey;\n        pLeft->aiChildPtr[2] = iLeftPtr;\n        break;\n      case 2:\n        pRight->aiKeyPtr[0] = iTreeKey;\n        pRight->aiChildPtr[0] = iLeftPtr;\n        if( iRightPtr ) pRight->aiChildPtr[1] = iRightPtr;\n        break;\n      case 3:\n        pRight->aiChildPtr[3] = (iRightPtr ? iRightPtr : pRight->aiChildPtr[2]);\n        pRight->aiKeyPtr[2] = iTreeKey;\n        pRight->aiChildPtr[2] = iLeftPtr;\n        break;\n    }\n\n  }else{\n    TreeNode *pNew;\n    u32 *piKey;\n    u32 *piChild;\n    u32 iStore = 0;\n    u32 iNew = 0;\n    int i;\n\n    /* Allocate a new version of node pNode. */\n    pNew = newTreeNode(pDb, &iNew, &rc);\n    if( rc ) return rc;\n\n    piKey = pNew->aiKeyPtr;\n    piChild = pNew->aiChildPtr;\n\n    for(i=0; i<iSlot; i++){\n      if( pNode->aiKeyPtr[i] ){\n        *(piKey++) = pNode->aiKeyPtr[i];\n        *(piChild++) = getChildPtr(pNode, WORKING_VERSION, i);\n      }\n    }\n\n    *piKey++ = iTreeKey;\n    *piChild++ = iLeftPtr;\n\n    iStore = iRightPtr;\n    for(i=iSlot; i<3; i++){\n      if( pNode->aiKeyPtr[i] ){\n        *(piKey++) = pNode->aiKeyPtr[i];\n        *(piChild++) = iStore ? iStore : getChildPtr(pNode, WORKING_VERSION, i);\n        iStore = 0;\n      }\n    }\n\n    if( iStore ){\n      *piChild = iStore;\n    }else{\n      *piChild = getChildPtr(pNode, WORKING_VERSION, \n          (pNode->aiKeyPtr[2] ? 3 : 2)\n      );\n    }\n    pCsr->iNode--;\n    rc = treeUpdatePtr(pDb, pCsr, iNew);\n  }\n\n  return rc;\n}\n\nstatic int treeInsertLeaf(\n  lsm_db *pDb,                    /* Database handle */\n  TreeCursor *pCsr,               /* Cursor structure */\n  u32 iTreeKey,                   /* Key pointer to insert */\n  int iSlot                       /* Insert key to the left of this */\n){\n  int rc = LSM_OK;                /* Return code */\n  TreeNode *pLeaf = pCsr->apTreeNode[pCsr->iNode];\n  TreeLeaf *pNew;\n  u32 iNew;\n\n  assert( iSlot>=0 && iSlot<=4 );\n  assert( pCsr->iNode>0 );\n  assert( pLeaf->aiKeyPtr[1] );\n\n  pCsr->iNode--;\n\n  pNew = newTreeLeaf(pDb, &iNew, &rc);\n  if( pNew ){\n    if( pLeaf->aiKeyPtr[0] && pLeaf->aiKeyPtr[2] ){\n      /* The leaf is full. Split it in two. */\n      TreeLeaf *pRight;\n      u32 iRight;\n      pRight = newTreeLeaf(pDb, &iRight, &rc);\n      if( pRight ){\n        assert( rc==LSM_OK );\n        pNew->aiKeyPtr[1] = pLeaf->aiKeyPtr[0];\n        pRight->aiKeyPtr[1] = pLeaf->aiKeyPtr[2];\n        switch( iSlot ){\n          case 0: pNew->aiKeyPtr[0] = iTreeKey; break;\n          case 1: pNew->aiKeyPtr[2] = iTreeKey; break;\n          case 2: pRight->aiKeyPtr[0] = iTreeKey; break;\n          case 3: pRight->aiKeyPtr[2] = iTreeKey; break;\n        }\n\n        rc = treeInsert(pDb, pCsr, iNew, pLeaf->aiKeyPtr[1], iRight, \n            pCsr->aiCell[pCsr->iNode]\n        );\n      }\n    }else{\n      int iOut = 0;\n      int i;\n      for(i=0; i<4; i++){\n        if( i==iSlot ) pNew->aiKeyPtr[iOut++] = iTreeKey;\n        if( i<3 && pLeaf->aiKeyPtr[i] ){\n          pNew->aiKeyPtr[iOut++] = pLeaf->aiKeyPtr[i];\n        }\n      }\n      rc = treeUpdatePtr(pDb, pCsr, iNew);\n    }\n  }\n\n  return rc;\n}\n\nvoid lsmTreeMakeOld(lsm_db *pDb){\n\n  /* A write transaction must be open. Otherwise the code below that\n  ** assumes (pDb->pClient->iLogOff) is current may malfunction. \n  **\n  ** Update: currently this assert fails due to lsm_flush(), which does\n  ** not set nTransOpen.\n  */\n  assert( /* pDb->nTransOpen>0 && */ pDb->iReader>=0 );\n\n  if( pDb->treehdr.iOldShmid==0 ){\n    pDb->treehdr.iOldLog = (pDb->treehdr.log.aRegion[2].iEnd << 1);\n    pDb->treehdr.iOldLog |= (~(pDb->pClient->iLogOff) & (i64)0x0001);\n\n    pDb->treehdr.oldcksum0 = pDb->treehdr.log.cksum0;\n    pDb->treehdr.oldcksum1 = pDb->treehdr.log.cksum1;\n    pDb->treehdr.iOldShmid = pDb->treehdr.iNextShmid-1;\n    memcpy(&pDb->treehdr.oldroot, &pDb->treehdr.root, sizeof(TreeRoot));\n\n    pDb->treehdr.root.iTransId = 1;\n    pDb->treehdr.root.iRoot = 0;\n    pDb->treehdr.root.nHeight = 0;\n    pDb->treehdr.root.nByte = 0;\n  }\n}\n\nvoid lsmTreeDiscardOld(lsm_db *pDb){\n  assert( lsmShmAssertLock(pDb, LSM_LOCK_WRITER, LSM_LOCK_EXCL) \n       || lsmShmAssertLock(pDb, LSM_LOCK_DMS2, LSM_LOCK_EXCL) \n  );\n  pDb->treehdr.iUsedShmid = pDb->treehdr.iOldShmid;\n  pDb->treehdr.iOldShmid = 0;\n}\n\nint lsmTreeHasOld(lsm_db *pDb){\n  return pDb->treehdr.iOldShmid!=0;\n}\n\n/*\n** This function is called during recovery to initialize the \n** tree header. Only the database connections private copy of the tree-header\n** is initialized here - it will be copied into shared memory if log file\n** recovery is successful.\n*/\nint lsmTreeInit(lsm_db *pDb){\n  ShmChunk *pOne;\n  int rc = LSM_OK;\n\n  memset(&pDb->treehdr, 0, sizeof(TreeHeader));\n  pDb->treehdr.root.iTransId = 1;\n  pDb->treehdr.iFirst = 1;\n  pDb->treehdr.nChunk = 2;\n  pDb->treehdr.iWrite = LSM_SHM_CHUNK_SIZE + LSM_SHM_CHUNK_HDR;\n  pDb->treehdr.iNextShmid = 2;\n  pDb->treehdr.iUsedShmid = 1;\n\n  pOne = treeShmChunkRc(pDb, 1, &rc);\n  if( pOne ){\n    pOne->iNext = 0;\n    pOne->iShmid = 1;\n  }\n  return rc;\n}\n\nstatic void treeHeaderChecksum(\n  TreeHeader *pHdr, \n  u32 *aCksum\n){\n  u32 cksum1 = 0x12345678;\n  u32 cksum2 = 0x9ABCDEF0;\n  u32 *a = (u32 *)pHdr;\n  int i;\n\n  assert( (offsetof(TreeHeader, aCksum) + sizeof(u32)*2)==sizeof(TreeHeader) );\n  assert( (sizeof(TreeHeader) % (sizeof(u32)*2))==0 );\n\n  for(i=0; i<(offsetof(TreeHeader, aCksum) / sizeof(u32)); i+=2){\n    cksum1 += a[i];\n    cksum2 += (cksum1 + a[i+1]);\n  }\n  aCksum[0] = cksum1;\n  aCksum[1] = cksum2;\n}\n\n/*\n** Return true if the checksum stored in TreeHeader object *pHdr is \n** consistent with the contents of its other fields.\n*/\nstatic int treeHeaderChecksumOk(TreeHeader *pHdr){\n  u32 aCksum[2];\n  treeHeaderChecksum(pHdr, aCksum);\n  return (0==memcmp(aCksum, pHdr->aCksum, sizeof(aCksum)));\n}\n\n/*\n** This type is used by functions lsmTreeRepair() and treeSortByShmid() to\n** make relinking the linked list of shared-memory chunks easier.\n*/\ntypedef struct ShmChunkLoc ShmChunkLoc;\nstruct ShmChunkLoc {\n  ShmChunk *pShm;\n  u32 iLoc;\n};\n\n/*\n** This function checks that the linked list of shared memory chunks \n** that starts at chunk db->treehdr.iFirst:\n**\n**   1) Includes all chunks in the shared-memory region, and\n**   2) Links them together in order of ascending shm-id.\n**\n** If no error occurs and the conditions above are met, LSM_OK is returned.\n**\n** If either of the conditions are untrue, LSM_CORRUPT is returned. Or, if\n** an error is encountered before the checks are completed, another LSM error\n** code (i.e. LSM_IOERR or LSM_NOMEM) may be returned.\n*/\nstatic int treeCheckLinkedList(lsm_db *db){\n  int rc = LSM_OK;\n  int nVisit = 0;\n  ShmChunk *p;\n\n  p = treeShmChunkRc(db, db->treehdr.iFirst, &rc);\n  while( rc==LSM_OK && p ){\n    if( p->iNext ){\n      if( p->iNext>=db->treehdr.nChunk ){\n        rc = LSM_CORRUPT_BKPT;\n      }else{\n        ShmChunk *pNext = treeShmChunkRc(db, p->iNext, &rc);\n        if( rc==LSM_OK ){\n          if( pNext->iShmid!=p->iShmid+1 ){\n            rc = LSM_CORRUPT_BKPT;\n          }\n          p = pNext;\n        }\n      }\n    }else{\n      p = 0;\n    }\n    nVisit++;\n  }\n\n  if( rc==LSM_OK && (u32)nVisit!=db->treehdr.nChunk-1 ){\n    rc = LSM_CORRUPT_BKPT;\n  }\n  return rc;\n}\n\n/*\n** Iterate through the current in-memory tree. If there are any v2-pointers\n** with transaction ids larger than db->treehdr.iTransId, zero them.\n*/\nstatic int treeRepairPtrs(lsm_db *db){\n  int rc = LSM_OK;\n\n  if( db->treehdr.root.nHeight>1 ){\n    TreeCursor csr;               /* Cursor used to iterate through tree */\n    u32 iTransId = db->treehdr.root.iTransId;\n\n    /* Initialize the cursor structure. Also decrement the nHeight variable\n    ** in the tree-header. This will prevent the cursor from visiting any\n    ** leaf nodes.  */\n    db->treehdr.root.nHeight--;\n    treeCursorInit(db, 0, &csr);\n\n    rc = lsmTreeCursorEnd(&csr, 0);\n    while( rc==LSM_OK && lsmTreeCursorValid(&csr) ){\n      TreeNode *pNode = csr.apTreeNode[csr.iNode];\n      if( pNode->iV2>iTransId ){\n        pNode->iV2Child = 0;\n        pNode->iV2Ptr = 0;\n        pNode->iV2 = 0;\n      }\n      rc = lsmTreeCursorNext(&csr);\n    }\n    tblobFree(csr.pDb, &csr.blob);\n\n    db->treehdr.root.nHeight++;\n  }\n\n  return rc;\n}\n\nstatic int treeRepairList(lsm_db *db){\n  int rc = LSM_OK;\n  int i;\n  ShmChunk *p;\n  ShmChunk *pMin = 0;\n  u32 iMin = 0;\n\n  /* Iterate through all shm chunks. Find the smallest shm-id present in\n  ** the shared-memory region. */\n  for(i=1; rc==LSM_OK && (u32)i<db->treehdr.nChunk; i++){\n    p = treeShmChunkRc(db, i, &rc);\n    if( p && (pMin==0 || shm_sequence_ge(pMin->iShmid, p->iShmid)) ){\n      pMin = p;\n      iMin = i;\n    }\n  }\n\n  /* Fix the shm-id values on any chunks with a shm-id greater than or \n  ** equal to treehdr.iNextShmid. Then do a merge-sort of all chunks to \n  ** fix the ShmChunk.iNext pointers.\n  */\n  if( rc==LSM_OK ){\n    int nSort;\n    int nByte;\n    u32 iPrevShmid;\n    ShmChunkLoc *aSort;\n\n    /* Allocate space for a merge sort. */\n    nSort = 1;\n    while( (u32)nSort < (db->treehdr.nChunk-1) ) nSort = nSort * 2;\n    nByte = sizeof(ShmChunkLoc) * nSort * 2;\n    aSort = lsmMallocZeroRc(db->pEnv, nByte, &rc);\n    iPrevShmid = pMin->iShmid;\n\n    /* Fix all shm-ids, if required. */\n    if( rc==LSM_OK ){\n      iPrevShmid = pMin->iShmid-1;\n      for(i=1; (u32)i<db->treehdr.nChunk; i++){\n        p = treeShmChunk(db, i);\n        aSort[i-1].pShm = p;\n        aSort[i-1].iLoc = i;\n        if( (u32)i!=db->treehdr.iFirst ){\n          if( shm_sequence_ge(p->iShmid, db->treehdr.iNextShmid) ){\n            p->iShmid = iPrevShmid--;\n          }\n        }\n      }\n      if( iMin!=db->treehdr.iFirst ){\n        p = treeShmChunk(db, db->treehdr.iFirst);\n        p->iShmid = iPrevShmid;\n      }\n    }\n\n    if( rc==LSM_OK ){\n      ShmChunkLoc *aSpace = &aSort[nSort];\n      for(i=0; i<nSort; i++){\n        if( aSort[i].pShm ){\n          assert( shm_sequence_ge(aSort[i].pShm->iShmid, iPrevShmid) );\n          assert( aSpace[aSort[i].pShm->iShmid - iPrevShmid].pShm==0 );\n          aSpace[aSort[i].pShm->iShmid - iPrevShmid] = aSort[i];\n        }\n      }\n\n      if( aSpace[nSort-1].pShm ) aSpace[nSort-1].pShm->iNext = 0;\n      for(i=0; i<nSort-1; i++){\n        if( aSpace[i].pShm ){\n          aSpace[i].pShm->iNext = aSpace[i+1].iLoc;\n        }\n      }\n\n      rc = treeCheckLinkedList(db);\n      lsmFree(db->pEnv, aSort);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is called as part of opening a write-transaction if the\n** writer-flag is already set - indicating that the previous writer \n** failed before ending its transaction.\n*/\nint lsmTreeRepair(lsm_db *db){\n  int rc = LSM_OK;\n  TreeHeader hdr;\n  ShmHeader *pHdr = db->pShmhdr;\n\n  /* Ensure that the two tree-headers are consistent. Copy one over the other\n  ** if necessary. Prefer the data from a tree-header for which the checksum\n  ** computes. Or, if they both compute, prefer tree-header-1.  */\n  if( memcmp(&pHdr->hdr1, &pHdr->hdr2, sizeof(TreeHeader)) ){\n    if( treeHeaderChecksumOk(&pHdr->hdr1) ){\n      memcpy(&pHdr->hdr2, &pHdr->hdr1, sizeof(TreeHeader));\n    }else{\n      memcpy(&pHdr->hdr1, &pHdr->hdr2, sizeof(TreeHeader));\n    }\n  }\n\n  /* Save the connections current copy of the tree-header. It will be \n  ** restored before returning.  */\n  memcpy(&hdr, &db->treehdr, sizeof(TreeHeader));\n\n  /* Walk the tree. Zero any v2 pointers with a transaction-id greater than\n  ** the transaction-id currently in the tree-headers.  */\n  rc = treeRepairPtrs(db);\n\n  /* Repair the linked list of shared-memory chunks. */\n  if( rc==LSM_OK ){\n    rc = treeRepairList(db);\n  }\n\n  memcpy(&db->treehdr, &hdr, sizeof(TreeHeader));\n  return rc;\n}\n\nstatic void treeOverwriteKey(lsm_db *db, TreeCursor *pCsr, u32 iKey, int *pRc){\n  if( *pRc==LSM_OK ){\n    TreeRoot *p = &db->treehdr.root;\n    TreeNode *pNew;\n    u32 iNew;\n    TreeNode *pNode = pCsr->apTreeNode[pCsr->iNode];\n    int iCell = pCsr->aiCell[pCsr->iNode];\n\n    /* Create a copy of this node */\n    if( (pCsr->iNode>0 && (u32)pCsr->iNode==(p->nHeight-1)) ){\n      pNew = copyTreeLeaf(db, (TreeLeaf *)pNode, &iNew, pRc);\n    }else{\n      pNew = copyTreeNode(db, pNode, &iNew, pRc);\n    }\n\n    if( pNew ){\n      /* Modify the value in the new version */\n      pNew->aiKeyPtr[iCell] = iKey;\n\n      /* Change the pointer in the parent (if any) to point at the new \n       ** TreeNode */\n      pCsr->iNode--;\n      treeUpdatePtr(db, pCsr, iNew);\n    }\n  }\n}\n\nstatic int treeNextIsEndDelete(lsm_db *db, TreeCursor *pCsr){\n  int iNode = pCsr->iNode;\n  int iCell = pCsr->aiCell[iNode]+1;\n\n  /* Cursor currently points to a leaf node. */\n  assert( (u32)pCsr->iNode==(db->treehdr.root.nHeight-1) );\n\n  while( iNode>=0 ){\n    TreeNode *pNode = pCsr->apTreeNode[iNode];\n    if( iCell<3 && pNode->aiKeyPtr[iCell] ){\n      int rc = LSM_OK;\n      TreeKey *pKey = treeShmptr(db, pNode->aiKeyPtr[iCell]);\n      assert( rc==LSM_OK );\n      return ((pKey->flags & LSM_END_DELETE) ? 1 : 0);\n    }\n    iNode--;\n    iCell = pCsr->aiCell[iNode];\n  }\n\n  return 0;\n}\n\nstatic int treePrevIsStartDelete(lsm_db *db, TreeCursor *pCsr){\n  int iNode = pCsr->iNode;\n\n  /* Cursor currently points to a leaf node. */\n  assert( (u32)pCsr->iNode==(db->treehdr.root.nHeight-1) );\n\n  while( iNode>=0 ){\n    TreeNode *pNode = pCsr->apTreeNode[iNode];\n    int iCell = pCsr->aiCell[iNode]-1;\n    if( iCell>=0 && pNode->aiKeyPtr[iCell] ){\n      int rc = LSM_OK;\n      TreeKey *pKey = treeShmptr(db, pNode->aiKeyPtr[iCell]);\n      assert( rc==LSM_OK );\n      return ((pKey->flags & LSM_START_DELETE) ? 1 : 0);\n    }\n    iNode--;\n  }\n\n  return 0;\n}\n\n\nstatic int treeInsertEntry(\n  lsm_db *pDb,                    /* Database handle */\n  int flags,                      /* Flags associated with entry */\n  void *pKey,                     /* Pointer to key data */\n  int nKey,                       /* Size of key data in bytes */\n  void *pVal,                     /* Pointer to value data (or NULL) */\n  int nVal                        /* Bytes in value data (or -ve for delete) */\n){\n  int rc = LSM_OK;                /* Return Code */\n  TreeKey *pTreeKey;              /* New key-value being inserted */\n  u32 iTreeKey;\n  TreeRoot *p = &pDb->treehdr.root;\n  TreeCursor csr;                 /* Cursor to seek to pKey/nKey */\n  int res = 0;                    /* Result of seek operation on csr */\n\n  assert( nVal>=0 || pVal==0 );\n  assert_tree_looks_ok(LSM_OK, pTree);\n  assert( flags==LSM_INSERT       || flags==LSM_POINT_DELETE \n       || flags==LSM_START_DELETE || flags==LSM_END_DELETE \n  );\n  assert( (flags & LSM_CONTIGUOUS)==0 );\n#if 0\n  dump_tree_contents(pDb, \"before\");\n#endif\n\n  if( p->iRoot ){\n    TreeKey *pRes;                /* Key at end of seek operation */\n    treeCursorInit(pDb, 0, &csr);\n\n    /* Seek to the leaf (or internal node) that the new key belongs on */\n    rc = lsmTreeCursorSeek(&csr, pKey, nKey, &res);\n    pRes = csrGetKey(&csr, &csr.blob, &rc);\n    if( rc!=LSM_OK ) return rc;\n    assert( pRes );\n\n    if( flags==LSM_START_DELETE ){\n      /* When inserting a start-delete-range entry, if the key that\n      ** occurs immediately before the new entry is already a START_DELETE,\n      ** then the new entry is not required.  */\n      if( (res<=0 && (pRes->flags & LSM_START_DELETE))\n       || (res>0  && treePrevIsStartDelete(pDb, &csr))\n      ){ \n        goto insert_entry_out;\n      }\n    }else if( flags==LSM_END_DELETE ){\n      /* When inserting an start-delete-range entry, if the key that\n      ** occurs immediately after the new entry is already an END_DELETE,\n      ** then the new entry is not required.  */\n      if( (res<0  && treeNextIsEndDelete(pDb, &csr))\n       || (res>=0 && (pRes->flags & LSM_END_DELETE))\n      ){\n        goto insert_entry_out;\n      }\n    }\n\n    if( res==0 && (flags & (LSM_END_DELETE|LSM_START_DELETE)) ){\n      if( pRes->flags & LSM_INSERT ){\n        nVal = pRes->nValue;\n        pVal = TKV_VAL(pRes);\n      }\n      flags = flags | pRes->flags;\n    }\n\n    if( flags & (LSM_INSERT|LSM_POINT_DELETE) ){\n      if( (res<0 && (pRes->flags & LSM_START_DELETE))\n       || (res>0 && (pRes->flags & LSM_END_DELETE)) \n      ){\n        flags = flags | (LSM_END_DELETE|LSM_START_DELETE);\n      }else if( res==0 ){\n        flags = flags | (pRes->flags & (LSM_END_DELETE|LSM_START_DELETE));\n      }\n    }\n  }else{\n    memset(&csr, 0, sizeof(TreeCursor));\n  }\n\n  /* Allocate and populate a new key-value pair structure */\n  pTreeKey = newTreeKey(pDb, &iTreeKey, pKey, nKey, pVal, nVal, &rc);\n  if( rc!=LSM_OK ) return rc;\n  assert( pTreeKey->flags==0 || pTreeKey->flags==LSM_CONTIGUOUS );\n  pTreeKey->flags |= flags;\n\n  if( p->iRoot==0 ){\n    /* The tree is completely empty. Add a new root node and install\n    ** (pKey/nKey) as the middle entry. Even though it is a leaf at the\n    ** moment, use newTreeNode() to allocate the node (i.e. allocate enough\n    ** space for the fields used by interior nodes). This is because the\n    ** treeInsert() routine may convert this node to an interior node. */\n    TreeNode *pRoot = newTreeNode(pDb, &p->iRoot, &rc);\n    if( rc==LSM_OK ){\n      assert( p->nHeight==0 );\n      pRoot->aiKeyPtr[1] = iTreeKey;\n      p->nHeight = 1;\n    }\n  }else{\n    if( res==0 ){\n      /* The search found a match within the tree. */\n      treeOverwriteKey(pDb, &csr, iTreeKey, &rc);\n    }else{\n      /* The cursor now points to the leaf node into which the new entry should\n      ** be inserted. There may or may not be a free slot within the leaf for\n      ** the new key-value pair. \n      **\n      ** iSlot is set to the index of the key within pLeaf that the new key\n      ** should be inserted to the left of (or to a value 1 greater than the\n      ** index of the rightmost key if the new key is larger than all keys\n      ** currently stored in the node).\n      */\n      int iSlot = csr.aiCell[csr.iNode] + (res<0);\n      if( csr.iNode==0 ){\n        rc = treeInsert(pDb, &csr, 0, iTreeKey, 0, iSlot);\n      }else{\n        rc = treeInsertLeaf(pDb, &csr, iTreeKey, iSlot);\n      }\n    }\n  }\n\n#if 0\n  dump_tree_contents(pDb, \"after\");\n#endif\n insert_entry_out:\n  tblobFree(pDb, &csr.blob);\n  assert_tree_looks_ok(rc, pTree);\n  return rc;\n}\n\n/*\n** Insert a new entry into the in-memory tree.\n**\n** If the value of the 5th parameter, nVal, is negative, then a delete-marker\n** is inserted into the tree. In this case the value pointer, pVal, must be\n** NULL.\n*/\nint lsmTreeInsert(\n  lsm_db *pDb,                    /* Database handle */\n  void *pKey,                     /* Pointer to key data */\n  int nKey,                       /* Size of key data in bytes */\n  void *pVal,                     /* Pointer to value data (or NULL) */\n  int nVal                        /* Bytes in value data (or -ve for delete) */\n){\n  int flags;\n  if( nVal<0 ){\n    flags = LSM_POINT_DELETE;\n  }else{\n    flags = LSM_INSERT;\n  }\n\n  return treeInsertEntry(pDb, flags, pKey, nKey, pVal, nVal);\n}\n\nstatic int treeDeleteEntry(lsm_db *db, TreeCursor *pCsr, u32 iNewptr){\n  TreeRoot *p = &db->treehdr.root;\n  TreeNode *pNode = pCsr->apTreeNode[pCsr->iNode];\n  int iSlot = pCsr->aiCell[pCsr->iNode];\n  int bLeaf;\n  int rc = LSM_OK;\n\n  assert( pNode->aiKeyPtr[1] );\n  assert( pNode->aiKeyPtr[iSlot] );\n  assert( iSlot==0 || iSlot==1 || iSlot==2 );\n  assert( ((u32)pCsr->iNode==(db->treehdr.root.nHeight-1))==(iNewptr==0) );\n\n  bLeaf = ((u32)pCsr->iNode==(p->nHeight-1) && p->nHeight>1);\n  \n  if( pNode->aiKeyPtr[0] || pNode->aiKeyPtr[2] ){\n    /* There are currently at least 2 keys on this node. So just create\n    ** a new copy of the node with one of the keys removed. If the node\n    ** happens to be the root node of the tree, allocate an entire \n    ** TreeNode structure instead of just a TreeLeaf.  */\n    TreeNode *pNew;\n    u32 iNew;\n\n    if( bLeaf ){\n      pNew = (TreeNode *)newTreeLeaf(db, &iNew, &rc);\n    }else{\n      pNew = newTreeNode(db, &iNew, &rc);\n    }\n    if( pNew ){\n      int i;\n      int iOut = 1;\n      for(i=0; i<4; i++){\n        if( i==iSlot ){\n          i++;\n          if( bLeaf==0 ) pNew->aiChildPtr[iOut] = iNewptr;\n          if( i<3 ) pNew->aiKeyPtr[iOut] = pNode->aiKeyPtr[i];\n          iOut++;\n        }else if( bLeaf || p->nHeight==1 ){\n          if( i<3 && pNode->aiKeyPtr[i] ){\n            pNew->aiKeyPtr[iOut++] = pNode->aiKeyPtr[i];\n          }\n        }else{\n          if( getChildPtr(pNode, WORKING_VERSION, i) ){\n            pNew->aiChildPtr[iOut] = getChildPtr(pNode, WORKING_VERSION, i);\n            if( i<3 ) pNew->aiKeyPtr[iOut] = pNode->aiKeyPtr[i];\n            iOut++;\n          }\n        }\n      }\n      assert( iOut<=4 );\n      assert( bLeaf || pNew->aiChildPtr[0]==0 );\n      pCsr->iNode--;\n      rc = treeUpdatePtr(db, pCsr, iNew);\n    }\n\n  }else if( pCsr->iNode==0 ){\n    /* Removing the only key in the root node. iNewptr is the new root. */\n    assert( iSlot==1 );\n    db->treehdr.root.iRoot = iNewptr;\n    db->treehdr.root.nHeight--;\n\n  }else{\n    /* There is only one key on this node and the node is not the root\n    ** node. Find a peer for this node. Then redistribute the contents of\n    ** the peer and the parent cell between the parent and either one or\n    ** two new nodes.  */\n    TreeNode *pParent;            /* Parent tree node */\n    int iPSlot;\n    u32 iPeer;                    /* Pointer to peer leaf node */\n    int iDir;\n    TreeNode *pPeer;              /* The peer leaf node */\n    TreeNode *pNew1; u32 iNew1;   /* First new leaf node */\n\n    assert( iSlot==1 );\n\n    pParent = pCsr->apTreeNode[pCsr->iNode-1];\n    iPSlot = pCsr->aiCell[pCsr->iNode-1];\n\n    if( iPSlot>0 && getChildPtr(pParent, WORKING_VERSION, iPSlot-1) ){\n      iDir = -1;\n    }else{\n      iDir = +1;\n    }\n    iPeer = getChildPtr(pParent, WORKING_VERSION, iPSlot+iDir);\n    pPeer = (TreeNode *)treeShmptr(db, iPeer);\n    assertIsWorkingChild(db, pNode, pParent, iPSlot);\n\n    /* Allocate the first new leaf node. This is always required. */\n    if( bLeaf ){\n      pNew1 = (TreeNode *)newTreeLeaf(db, &iNew1, &rc);\n    }else{\n      pNew1 = (TreeNode *)newTreeNode(db, &iNew1, &rc);\n    }\n\n    if( pPeer->aiKeyPtr[0] && pPeer->aiKeyPtr[2] ){\n      /* Peer node is completely full. This means that two new leaf nodes\n      ** and a new parent node are required. */\n\n      TreeNode *pNew2; u32 iNew2; /* Second new leaf node */\n      TreeNode *pNewP; u32 iNewP; /* New parent node */\n\n      if( bLeaf ){\n        pNew2 = (TreeNode *)newTreeLeaf(db, &iNew2, &rc);\n      }else{\n        pNew2 = (TreeNode *)newTreeNode(db, &iNew2, &rc);\n      }\n      pNewP = copyTreeNode(db, pParent, &iNewP, &rc);\n\n      if( iDir==-1 ){\n        pNew1->aiKeyPtr[1] = pPeer->aiKeyPtr[0];\n        if( bLeaf==0 ){\n          pNew1->aiChildPtr[1] = getChildPtr(pPeer, WORKING_VERSION, 0);\n          pNew1->aiChildPtr[2] = getChildPtr(pPeer, WORKING_VERSION, 1);\n        }\n\n        pNewP->aiChildPtr[iPSlot-1] = iNew1;\n        pNewP->aiKeyPtr[iPSlot-1] = pPeer->aiKeyPtr[1];\n        pNewP->aiChildPtr[iPSlot] = iNew2;\n\n        pNew2->aiKeyPtr[0] = pPeer->aiKeyPtr[2];\n        pNew2->aiKeyPtr[1] = pParent->aiKeyPtr[iPSlot-1];\n        if( bLeaf==0 ){\n          pNew2->aiChildPtr[0] = getChildPtr(pPeer, WORKING_VERSION, 2);\n          pNew2->aiChildPtr[1] = getChildPtr(pPeer, WORKING_VERSION, 3);\n          pNew2->aiChildPtr[2] = iNewptr;\n        }\n      }else{\n        pNew1->aiKeyPtr[1] = pParent->aiKeyPtr[iPSlot];\n        if( bLeaf==0 ){\n          pNew1->aiChildPtr[1] = iNewptr;\n          pNew1->aiChildPtr[2] = getChildPtr(pPeer, WORKING_VERSION, 0);\n        }\n\n        pNewP->aiChildPtr[iPSlot] = iNew1;\n        pNewP->aiKeyPtr[iPSlot] = pPeer->aiKeyPtr[0];\n        pNewP->aiChildPtr[iPSlot+1] = iNew2;\n\n        pNew2->aiKeyPtr[0] = pPeer->aiKeyPtr[1];\n        pNew2->aiKeyPtr[1] = pPeer->aiKeyPtr[2];\n        if( bLeaf==0 ){\n          pNew2->aiChildPtr[0] = getChildPtr(pPeer, WORKING_VERSION, 1);\n          pNew2->aiChildPtr[1] = getChildPtr(pPeer, WORKING_VERSION, 2);\n          pNew2->aiChildPtr[2] = getChildPtr(pPeer, WORKING_VERSION, 3);\n        }\n      }\n      assert( pCsr->iNode>=1 );\n      pCsr->iNode -= 2;\n      if( rc==LSM_OK ){\n        assert( pNew1->aiKeyPtr[1] && pNew2->aiKeyPtr[1] );\n        rc = treeUpdatePtr(db, pCsr, iNewP);\n      }\n    }else{\n      int iKOut = 0;\n      int iPOut = 0;\n      int i;\n\n      pCsr->iNode--;\n\n      if( iDir==1 ){\n        pNew1->aiKeyPtr[iKOut++] = pParent->aiKeyPtr[iPSlot];\n        if( bLeaf==0 ) pNew1->aiChildPtr[iPOut++] = iNewptr;\n      }\n      for(i=0; i<3; i++){\n        if( pPeer->aiKeyPtr[i] ){\n          pNew1->aiKeyPtr[iKOut++] = pPeer->aiKeyPtr[i];\n        }\n      }\n      if( bLeaf==0 ){\n        for(i=0; i<4; i++){\n          if( getChildPtr(pPeer, WORKING_VERSION, i) ){\n            pNew1->aiChildPtr[iPOut++] = getChildPtr(pPeer, WORKING_VERSION, i);\n          }\n        }\n      }\n      if( iDir==-1 ){\n        iPSlot--;\n        pNew1->aiKeyPtr[iKOut++] = pParent->aiKeyPtr[iPSlot];\n        if( bLeaf==0 ) pNew1->aiChildPtr[iPOut++] = iNewptr;\n        pCsr->aiCell[pCsr->iNode] = (u8)iPSlot;\n      }\n\n      rc = treeDeleteEntry(db, pCsr, iNew1);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Delete a range of keys from the tree structure (i.e. the lsm_delete_range()\n** function, not lsm_delete()).\n**\n** This is a two step process: \n**\n**     1) Remove all entries currently stored in the tree that have keys\n**        that fall into the deleted range.\n**\n**        TODO: There are surely good ways to optimize this step - removing \n**        a range of keys from a b-tree. But for now, this function removes\n**        them one at a time using the usual approach.\n**\n**     2) Unless the largest key smaller than or equal to (pKey1/nKey1) is\n**        already marked as START_DELETE, insert a START_DELETE key. \n**        Similarly, unless the smallest key greater than or equal to\n**        (pKey2/nKey2) is already START_END, insert a START_END key.\n*/\nint lsmTreeDelete(\n  lsm_db *db,\n  void *pKey1, int nKey1,         /* Start of range */\n  void *pKey2, int nKey2          /* End of range */\n){\n  int rc = LSM_OK;\n  int bDone = 0;\n  TreeRoot *p = &db->treehdr.root;\n  TreeBlob blob = {0, 0};\n\n  /* The range must be sensible - that (key1 < key2). */\n  assert( treeKeycmp(pKey1, nKey1, pKey2, nKey2)<0 );\n  assert( assert_delete_ranges_match(db) );\n\n#if 0\n  static int nCall = 0;\n  printf(\"\\n\");\n  nCall++;\n  printf(\"%d delete %s .. %s\\n\", nCall, (char *)pKey1, (char *)pKey2);\n  dump_tree_contents(db, \"before delete\");\n#endif\n\n  /* Step 1. This loop runs until the tree contains no keys within the\n  ** range being deleted. Or until an error occurs. */\n  while( bDone==0 && rc==LSM_OK ){\n    int res;\n    TreeCursor csr;               /* Cursor to seek to first key in range */\n    void *pDel; int nDel;         /* Key to (possibly) delete this iteration */\n#ifndef NDEBUG\n    int nEntry = treeCountEntries(db);\n#endif\n\n    /* Seek the cursor to the first entry in the tree greater than pKey1. */\n    treeCursorInit(db, 0, &csr);\n    lsmTreeCursorSeek(&csr, pKey1, nKey1, &res);\n    if( res<=0 && lsmTreeCursorValid(&csr) ) lsmTreeCursorNext(&csr);\n\n    /* If there is no such entry, or if it is greater than pKey2, then the\n    ** tree now contains no keys in the range being deleted. In this case\n    ** break out of the loop.  */\n    bDone = 1;\n    if( lsmTreeCursorValid(&csr) ){\n      lsmTreeCursorKey(&csr, 0, &pDel, &nDel);\n      if( treeKeycmp(pDel, nDel, pKey2, nKey2)<0 ) bDone = 0;\n    }\n\n    if( bDone==0 ){\n      if( (u32)csr.iNode==(p->nHeight-1) ){\n        /* The element to delete already lies on a leaf node */\n        rc = treeDeleteEntry(db, &csr, 0);\n      }else{\n        /* 1. Overwrite the current key with a copy of the next key in the \n        **    tree (key N).\n        **\n        ** 2. Seek to key N (cursor will stop at the internal node copy of\n        **    N). Move to the next key (original copy of N). Delete\n        **    this entry. \n        */\n        u32 iKey;\n        TreeKey *pKey;\n        int iNode = csr.iNode;\n        lsmTreeCursorNext(&csr);\n        assert( (u32)csr.iNode==(p->nHeight-1) );\n\n        iKey = csr.apTreeNode[csr.iNode]->aiKeyPtr[csr.aiCell[csr.iNode]];\n        lsmTreeCursorPrev(&csr);\n\n        treeOverwriteKey(db, &csr, iKey, &rc);\n        pKey = treeShmkey(db, iKey, TKV_LOADKEY, &blob, &rc);\n        if( pKey ){\n          rc = lsmTreeCursorSeek(&csr, TKV_KEY(pKey), pKey->nKey, &res);\n        }\n        if( rc==LSM_OK ){\n          assert( res==0 && csr.iNode==iNode );\n          rc = lsmTreeCursorNext(&csr);\n          if( rc==LSM_OK ){\n            rc = treeDeleteEntry(db, &csr, 0);\n          }\n        }\n      }\n    }\n\n    /* Clean up any memory allocated by the cursor. */\n    tblobFree(db, &csr.blob);\n#if 0\n    dump_tree_contents(db, \"ddd delete\");\n#endif\n    assert( bDone || treeCountEntries(db)==(nEntry-1) );\n  }\n\n#if 0\n  dump_tree_contents(db, \"during delete\");\n#endif\n\n  /* Now insert the START_DELETE and END_DELETE keys. */\n  if( rc==LSM_OK ){\n    rc = treeInsertEntry(db, LSM_START_DELETE, pKey1, nKey1, 0, -1);\n  }\n#if 0\n  dump_tree_contents(db, \"during delete 2\");\n#endif\n  if( rc==LSM_OK ){\n    rc = treeInsertEntry(db, LSM_END_DELETE, pKey2, nKey2, 0, -1);\n  }\n\n#if 0\n  dump_tree_contents(db, \"after delete\");\n#endif\n\n  tblobFree(db, &blob);\n  assert( assert_delete_ranges_match(db) );\n  return rc;\n}\n\n/*\n** Return, in bytes, the amount of memory currently used by the tree \n** structure.\n*/\nint lsmTreeSize(lsm_db *pDb){\n  return pDb->treehdr.root.nByte;\n}\n\n/*\n** Open a cursor on the in-memory tree pTree.\n*/\nint lsmTreeCursorNew(lsm_db *pDb, int bOld, TreeCursor **ppCsr){\n  TreeCursor *pCsr;\n  *ppCsr = pCsr = lsmMalloc(pDb->pEnv, sizeof(TreeCursor));\n  if( pCsr ){\n    treeCursorInit(pDb, bOld, pCsr);\n    return LSM_OK;\n  }\n  return LSM_NOMEM_BKPT;\n}\n\n/*\n** Close an in-memory tree cursor.\n*/\nvoid lsmTreeCursorDestroy(TreeCursor *pCsr){\n  if( pCsr ){\n    tblobFree(pCsr->pDb, &pCsr->blob);\n    lsmFree(pCsr->pDb->pEnv, pCsr);\n  }\n}\n\nvoid lsmTreeCursorReset(TreeCursor *pCsr){\n  if( pCsr ){\n    pCsr->iNode = -1;\n    pCsr->pSave = 0;\n  }\n}\n\n#ifndef NDEBUG\nstatic int treeCsrCompare(TreeCursor *pCsr, void *pKey, int nKey, int *pRc){\n  TreeKey *p;\n  int cmp = 0;\n  assert( pCsr->iNode>=0 );\n  p = csrGetKey(pCsr, &pCsr->blob, pRc);\n  if( p ){\n    cmp = treeKeycmp(TKV_KEY(p), p->nKey, pKey, nKey);\n  }\n  return cmp;\n}\n#endif\n\n\n/*\n** Attempt to seek the cursor passed as the first argument to key (pKey/nKey)\n** in the tree structure. If an exact match for the key is found, leave the\n** cursor pointing to it and set *pRes to zero before returning. If an\n** exact match cannot be found, do one of the following:\n**\n**   * Leave the cursor pointing to the smallest element in the tree that \n**     is larger than the key and set *pRes to +1, or\n**\n**   * Leave the cursor pointing to the largest element in the tree that \n**     is smaller than the key and set *pRes to -1, or\n**\n**   * If the tree is empty, leave the cursor at EOF and set *pRes to -1.\n*/\nint lsmTreeCursorSeek(TreeCursor *pCsr, void *pKey, int nKey, int *pRes){\n  int rc = LSM_OK;                /* Return code */\n  lsm_db *pDb = pCsr->pDb;\n  TreeRoot *pRoot = pCsr->pRoot;\n  u32 iNodePtr;                   /* Location of current node in search */\n\n  /* Discard any saved position data */\n  treeCursorRestore(pCsr, 0);\n\n  iNodePtr = pRoot->iRoot;\n  if( iNodePtr==0 ){\n    /* Either an error occurred or the tree is completely empty. */\n    assert( rc!=LSM_OK || pRoot->iRoot==0 );\n    *pRes = -1;\n    pCsr->iNode = -1;\n  }else{\n    TreeBlob b = {0, 0};\n    int res = 0;                  /* Result of comparison function */\n    int iNode = -1;\n    while( iNodePtr ){\n      TreeNode *pNode;            /* Node at location iNodePtr */\n      int iTest;                  /* Index of second key to test (0 or 2) */\n      u32 iTreeKey;\n      TreeKey *pTreeKey;          /* Key to compare against */\n\n      pNode = (TreeNode *)treeShmptrUnsafe(pDb, iNodePtr);\n      iNode++;\n      pCsr->apTreeNode[iNode] = pNode;\n\n      /* Compare (pKey/nKey) with the key in the middle slot of B-tree node\n      ** pNode. The middle slot is never empty. If the comparison is a match,\n      ** then the search is finished. Break out of the loop. */\n      pTreeKey = (TreeKey*)treeShmptrUnsafe(pDb, pNode->aiKeyPtr[1]);\n      if( !(pTreeKey->flags & LSM_CONTIGUOUS) ){\n        pTreeKey = treeShmkey(pDb, pNode->aiKeyPtr[1], TKV_LOADKEY, &b, &rc);\n        if( rc!=LSM_OK ) break;\n      }\n      res = treeKeycmp((void *)&pTreeKey[1], pTreeKey->nKey, pKey, nKey);\n      if( res==0 ){\n        pCsr->aiCell[iNode] = 1;\n        break;\n      }\n\n      /* Based on the results of the previous comparison, compare (pKey/nKey)\n      ** to either the left or right key of the B-tree node, if such a key\n      ** exists. */\n      iTest = (res>0 ? 0 : 2);\n      iTreeKey = pNode->aiKeyPtr[iTest];\n      if( iTreeKey ){\n        pTreeKey = (TreeKey*)treeShmptrUnsafe(pDb, iTreeKey);\n        if( !(pTreeKey->flags & LSM_CONTIGUOUS) ){\n          pTreeKey = treeShmkey(pDb, iTreeKey, TKV_LOADKEY, &b, &rc);\n          if( rc ) break;\n        }\n        res = treeKeycmp((void *)&pTreeKey[1], pTreeKey->nKey, pKey, nKey);\n        if( res==0 ){\n          pCsr->aiCell[iNode] = (u8)iTest;\n          break;\n        }\n      }else{\n        iTest = 1;\n      }\n\n      if( (u32)iNode<(pRoot->nHeight-1) ){\n        iNodePtr = getChildPtr(pNode, pRoot->iTransId, iTest + (res<0));\n      }else{\n        iNodePtr = 0;\n      }\n      pCsr->aiCell[iNode] = (u8)(iTest + (iNodePtr && (res<0)));\n    }\n\n    *pRes = res;\n    pCsr->iNode = iNode;\n    tblobFree(pDb, &b);\n  }\n\n  /* assert() that *pRes has been set properly */\n#ifndef NDEBUG\n  if( rc==LSM_OK && lsmTreeCursorValid(pCsr) ){\n    int cmp = treeCsrCompare(pCsr, pKey, nKey, &rc);\n    assert( rc!=LSM_OK || *pRes==cmp || (*pRes ^ cmp)>0 );\n  }\n#endif\n\n  return rc;\n}\n\nint lsmTreeCursorNext(TreeCursor *pCsr){\n#ifndef NDEBUG\n  TreeKey *pK1;\n  TreeBlob key1 = {0, 0};\n#endif\n  lsm_db *pDb = pCsr->pDb;\n  TreeRoot *pRoot = pCsr->pRoot;\n  const int iLeaf = pRoot->nHeight-1;\n  int iCell; \n  int rc = LSM_OK; \n  TreeNode *pNode; \n\n  /* Restore the cursor position, if required */\n  int iRestore = 0;\n  treeCursorRestore(pCsr, &iRestore);\n  if( iRestore>0 ) return LSM_OK;\n\n  /* Save a pointer to the current key. This is used in an assert() at the\n  ** end of this function - to check that the 'next' key really is larger\n  ** than the current key. */\n#ifndef NDEBUG\n  pK1 = csrGetKey(pCsr, &key1, &rc);\n  if( rc!=LSM_OK ) return rc;\n#endif\n\n  assert( lsmTreeCursorValid(pCsr) );\n  assert( pCsr->aiCell[pCsr->iNode]<3 );\n\n  pNode = pCsr->apTreeNode[pCsr->iNode];\n  iCell = ++pCsr->aiCell[pCsr->iNode];\n\n  /* If the current node is not a leaf, and the current cell has sub-tree\n  ** associated with it, descend to the left-most key on the left-most\n  ** leaf of the sub-tree.  */\n  if( pCsr->iNode<iLeaf && getChildPtr(pNode, pRoot->iTransId, iCell) ){\n    do {\n      u32 iNodePtr;\n      pCsr->iNode++;\n      iNodePtr = getChildPtr(pNode, pRoot->iTransId, iCell);\n      pNode = (TreeNode *)treeShmptr(pDb, iNodePtr);\n      pCsr->apTreeNode[pCsr->iNode] = pNode;\n      iCell = pCsr->aiCell[pCsr->iNode] = (pNode->aiKeyPtr[0]==0);\n    }while( pCsr->iNode < iLeaf );\n  }\n\n  /* Otherwise, the next key is found by following pointer up the tree \n  ** until there is a key immediately to the right of the pointer followed \n  ** to reach the sub-tree containing the current key. */\n  else if( iCell>=3 || pNode->aiKeyPtr[iCell]==0 ){\n    while( (--pCsr->iNode)>=0 ){\n      iCell = pCsr->aiCell[pCsr->iNode];\n      if( iCell<3 && pCsr->apTreeNode[pCsr->iNode]->aiKeyPtr[iCell] ) break;\n    }\n  }\n\n#ifndef NDEBUG\n  if( pCsr->iNode>=0 ){\n    TreeKey *pK2 = csrGetKey(pCsr, &pCsr->blob, &rc);\n    assert( rc||treeKeycmp(TKV_KEY(pK2),pK2->nKey,TKV_KEY(pK1),pK1->nKey)>=0 );\n  }\n  tblobFree(pDb, &key1);\n#endif\n\n  return rc;\n}\n\nint lsmTreeCursorPrev(TreeCursor *pCsr){\n#ifndef NDEBUG\n  TreeKey *pK1;\n  TreeBlob key1 = {0, 0};\n#endif\n  lsm_db *pDb = pCsr->pDb;\n  TreeRoot *pRoot = pCsr->pRoot;\n  const int iLeaf = pRoot->nHeight-1;\n  int iCell; \n  int rc = LSM_OK; \n  TreeNode *pNode; \n\n  /* Restore the cursor position, if required */\n  int iRestore = 0;\n  treeCursorRestore(pCsr, &iRestore);\n  if( iRestore<0 ) return LSM_OK;\n\n  /* Save a pointer to the current key. This is used in an assert() at the\n  ** end of this function - to check that the 'next' key really is smaller\n  ** than the current key. */\n#ifndef NDEBUG\n  pK1 = csrGetKey(pCsr, &key1, &rc);\n  if( rc!=LSM_OK ) return rc;\n#endif\n\n  assert( lsmTreeCursorValid(pCsr) );\n  pNode = pCsr->apTreeNode[pCsr->iNode];\n  iCell = pCsr->aiCell[pCsr->iNode];\n  assert( iCell>=0 && iCell<3 );\n\n  /* If the current node is not a leaf, and the current cell has sub-tree\n  ** associated with it, descend to the right-most key on the right-most\n  ** leaf of the sub-tree.  */\n  if( pCsr->iNode<iLeaf && getChildPtr(pNode, pRoot->iTransId, iCell) ){\n    do {\n      u32 iNodePtr;\n      pCsr->iNode++;\n      iNodePtr = getChildPtr(pNode, pRoot->iTransId, iCell);\n      pNode = (TreeNode *)treeShmptr(pDb, iNodePtr);\n      if( rc!=LSM_OK ) break;\n      pCsr->apTreeNode[pCsr->iNode] = pNode;\n      iCell = 1 + (pNode->aiKeyPtr[2]!=0) + (pCsr->iNode < iLeaf);\n      pCsr->aiCell[pCsr->iNode] = (u8)iCell;\n    }while( pCsr->iNode < iLeaf );\n  }\n\n  /* Otherwise, the next key is found by following pointer up the tree until\n  ** there is a key immediately to the left of the pointer followed to reach\n  ** the sub-tree containing the current key. */\n  else{\n    do {\n      iCell = pCsr->aiCell[pCsr->iNode]-1;\n      if( iCell>=0 && pCsr->apTreeNode[pCsr->iNode]->aiKeyPtr[iCell] ) break;\n    }while( (--pCsr->iNode)>=0 );\n    pCsr->aiCell[pCsr->iNode] = (u8)iCell;\n  }\n\n#ifndef NDEBUG\n  if( pCsr->iNode>=0 ){\n    TreeKey *pK2 = csrGetKey(pCsr, &pCsr->blob, &rc);\n    assert( rc || treeKeycmp(TKV_KEY(pK2),pK2->nKey,TKV_KEY(pK1),pK1->nKey)<0 );\n  }\n  tblobFree(pDb, &key1);\n#endif\n\n  return rc;\n}\n\n/*\n** Move the cursor to the first (bLast==0) or last (bLast!=0) entry in the\n** in-memory tree.\n*/\nint lsmTreeCursorEnd(TreeCursor *pCsr, int bLast){\n  lsm_db *pDb = pCsr->pDb;\n  TreeRoot *pRoot = pCsr->pRoot;\n  int rc = LSM_OK;\n\n  u32 iNodePtr;\n  pCsr->iNode = -1;\n\n  /* Discard any saved position data */\n  treeCursorRestore(pCsr, 0);\n\n  iNodePtr = pRoot->iRoot;\n  while( iNodePtr ){\n    int iCell;\n    TreeNode *pNode;\n\n    pNode = (TreeNode *)treeShmptr(pDb, iNodePtr);\n    if( rc ) break;\n\n    if( bLast ){\n      iCell = ((pNode->aiKeyPtr[2]==0) ? 2 : 3);\n    }else{\n      iCell = ((pNode->aiKeyPtr[0]==0) ? 1 : 0);\n    }\n    pCsr->iNode++;\n    pCsr->apTreeNode[pCsr->iNode] = pNode;\n\n    if( (u32)pCsr->iNode<pRoot->nHeight-1 ){\n      iNodePtr = getChildPtr(pNode, pRoot->iTransId, iCell);\n    }else{\n      iNodePtr = 0;\n    }\n    pCsr->aiCell[pCsr->iNode] = (u8)(iCell - (iNodePtr==0 && bLast));\n  }\n\n  return rc;\n}\n\nint lsmTreeCursorFlags(TreeCursor *pCsr){\n  int flags = 0;\n  if( pCsr && pCsr->iNode>=0 ){\n    int rc = LSM_OK;\n    TreeKey *pKey = (TreeKey *)treeShmptrUnsafe(pCsr->pDb,\n        pCsr->apTreeNode[pCsr->iNode]->aiKeyPtr[pCsr->aiCell[pCsr->iNode]]\n    );\n    assert( rc==LSM_OK );\n    flags = (pKey->flags & ~LSM_CONTIGUOUS);\n  }\n  return flags;\n}\n\nint lsmTreeCursorKey(TreeCursor *pCsr, int *pFlags, void **ppKey, int *pnKey){\n  TreeKey *pTreeKey;\n  int rc = LSM_OK;\n\n  assert( lsmTreeCursorValid(pCsr) );\n\n  pTreeKey = pCsr->pSave;\n  if( !pTreeKey ){\n    pTreeKey = csrGetKey(pCsr, &pCsr->blob, &rc);\n  }\n  if( rc==LSM_OK ){\n    *pnKey = pTreeKey->nKey;\n    if( pFlags ) *pFlags = pTreeKey->flags;\n    *ppKey = (void *)&pTreeKey[1];\n  }\n\n  return rc;\n}\n\nint lsmTreeCursorValue(TreeCursor *pCsr, void **ppVal, int *pnVal){\n  int res = 0;\n  int rc;\n\n  rc = treeCursorRestore(pCsr, &res);\n  if( res==0 ){\n    TreeKey *pTreeKey = csrGetKey(pCsr, &pCsr->blob, &rc);\n    if( rc==LSM_OK ){\n      if( pTreeKey->flags & LSM_INSERT ){\n        *pnVal = pTreeKey->nValue;\n        *ppVal = TKV_VAL(pTreeKey);\n      }else{\n        *ppVal = 0;\n        *pnVal = -1;\n      }\n    }\n  }else{\n    *ppVal = 0;\n    *pnVal = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Return true if the cursor currently points to a valid entry. \n*/\nint lsmTreeCursorValid(TreeCursor *pCsr){\n  return (pCsr && (pCsr->pSave || pCsr->iNode>=0));\n}\n\n/*\n** Store a mark in *pMark. Later on, a call to lsmTreeRollback() with a\n** pointer to the same TreeMark structure may be used to roll the tree\n** contents back to their current state.\n*/\nvoid lsmTreeMark(lsm_db *pDb, TreeMark *pMark){\n  pMark->iRoot = pDb->treehdr.root.iRoot;\n  pMark->nHeight = pDb->treehdr.root.nHeight;\n  pMark->iWrite = pDb->treehdr.iWrite;\n  pMark->nChunk = pDb->treehdr.nChunk;\n  pMark->iNextShmid = pDb->treehdr.iNextShmid;\n  pMark->iRollback = intArraySize(&pDb->rollback);\n}\n\n/*\n** Roll back to mark pMark. Structure *pMark should have been previously\n** populated by a call to lsmTreeMark().\n*/\nvoid lsmTreeRollback(lsm_db *pDb, TreeMark *pMark){\n  int iIdx;\n  int nIdx;\n  u32 iNext;\n  ShmChunk *pChunk;\n  u32 iChunk;\n  u32 iShmid;\n\n  /* Revert all required v2 pointers. */\n  nIdx = intArraySize(&pDb->rollback);\n  for(iIdx = pMark->iRollback; iIdx<nIdx; iIdx++){\n    TreeNode *pNode;\n    pNode = treeShmptr(pDb, intArrayEntry(&pDb->rollback, iIdx));\n    assert( pNode );\n    pNode->iV2 = 0;\n    pNode->iV2Child = 0;\n    pNode->iV2Ptr = 0;\n  }\n  intArrayTruncate(&pDb->rollback, pMark->iRollback);\n\n  /* Restore the free-chunk list. */\n  assert( pMark->iWrite!=0 );\n  iChunk = treeOffsetToChunk(pMark->iWrite-1);\n  pChunk = treeShmChunk(pDb, iChunk);\n  iNext = pChunk->iNext;\n  pChunk->iNext = 0;\n\n  pChunk = treeShmChunk(pDb, pDb->treehdr.iFirst);\n  iShmid = pChunk->iShmid-1;\n\n  while( iNext ){\n    u32 iFree = iNext;            /* Current chunk being rollback-freed */\n    ShmChunk *pFree;              /* Pointer to chunk iFree */\n\n    pFree = treeShmChunk(pDb, iFree);\n    iNext = pFree->iNext;\n\n    if( iFree<pMark->nChunk ){\n      pFree->iNext = pDb->treehdr.iFirst;\n      pFree->iShmid = iShmid--;\n      pDb->treehdr.iFirst = iFree;\n    }\n  }\n\n  /* Restore the tree-header fields */\n  pDb->treehdr.root.iRoot = pMark->iRoot;\n  pDb->treehdr.root.nHeight = pMark->nHeight;\n  pDb->treehdr.iWrite = pMark->iWrite;\n  pDb->treehdr.nChunk = pMark->nChunk;\n  pDb->treehdr.iNextShmid = pMark->iNextShmid;\n}\n\n/*\n** Load the in-memory tree header from shared-memory into pDb->treehdr.\n** If the header cannot be loaded, return LSM_PROTOCOL.\n**\n** If the header is successfully loaded and parameter piRead is not NULL,\n** is is set to 1 if the header was loaded from ShmHeader.hdr1, or 2 if\n** the header was loaded from ShmHeader.hdr2.\n*/\nint lsmTreeLoadHeader(lsm_db *pDb, int *piRead){\n  int nRem = LSM_ATTEMPTS_BEFORE_PROTOCOL;\n  while( (nRem--)>0 ){\n    ShmHeader *pShm = pDb->pShmhdr;\n\n    memcpy(&pDb->treehdr, &pShm->hdr1, sizeof(TreeHeader));\n    if( treeHeaderChecksumOk(&pDb->treehdr) ){\n      if( piRead ) *piRead = 1;\n      return LSM_OK;\n    }\n    memcpy(&pDb->treehdr, &pShm->hdr2, sizeof(TreeHeader));\n    if( treeHeaderChecksumOk(&pDb->treehdr) ){\n      if( piRead ) *piRead = 2;\n      return LSM_OK;\n    }\n\n    lsmShmBarrier(pDb);\n  }\n  return LSM_PROTOCOL_BKPT;\n}\n\nint lsmTreeLoadHeaderOk(lsm_db *pDb, int iRead){\n  TreeHeader *p = (iRead==1) ? &pDb->pShmhdr->hdr1 : &pDb->pShmhdr->hdr2;\n  assert( iRead==1 || iRead==2 );\n  return (0==memcmp(pDb->treehdr.aCksum, p->aCksum, sizeof(u32)*2));\n}\n\n/*\n** This function is called to conclude a transaction. If argument bCommit\n** is true, the transaction is committed. Otherwise it is rolled back.\n*/\nint lsmTreeEndTransaction(lsm_db *pDb, int bCommit){\n  ShmHeader *pShm = pDb->pShmhdr;\n\n  treeHeaderChecksum(&pDb->treehdr, pDb->treehdr.aCksum);\n  memcpy(&pShm->hdr2, &pDb->treehdr, sizeof(TreeHeader));\n  lsmShmBarrier(pDb);\n  memcpy(&pShm->hdr1, &pDb->treehdr, sizeof(TreeHeader));\n  pShm->bWriter = 0;\n  intArrayFree(pDb->pEnv, &pDb->rollback);\n\n  return LSM_OK;\n}\n\n#ifndef NDEBUG\nstatic int assert_delete_ranges_match(lsm_db *db){\n  int prev = 0;\n  TreeBlob blob = {0, 0};\n  TreeCursor csr;               /* Cursor used to iterate through tree */\n  int rc;\n\n  treeCursorInit(db, 0, &csr);\n  for( rc = lsmTreeCursorEnd(&csr, 0);\n       rc==LSM_OK && lsmTreeCursorValid(&csr);\n       rc = lsmTreeCursorNext(&csr)\n  ){\n    TreeKey *pKey = csrGetKey(&csr, &blob, &rc);\n    if( rc!=LSM_OK ) break;\n    assert( ((prev&LSM_START_DELETE)==0)==((pKey->flags&LSM_END_DELETE)==0) );\n    prev = pKey->flags;\n  }\n\n  tblobFree(csr.pDb, &csr.blob);\n  tblobFree(csr.pDb, &blob);\n\n  return 1;\n}\n\nstatic int treeCountEntries(lsm_db *db){\n  TreeCursor csr;               /* Cursor used to iterate through tree */\n  int rc;\n  int nEntry = 0;\n\n  treeCursorInit(db, 0, &csr);\n  for( rc = lsmTreeCursorEnd(&csr, 0);\n       rc==LSM_OK && lsmTreeCursorValid(&csr);\n       rc = lsmTreeCursorNext(&csr)\n  ){\n    nEntry++;\n  }\n\n  tblobFree(csr.pDb, &csr.blob);\n\n  return nEntry;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_unix.c",
    "content": "/*\n** 2011-12-03\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Unix-specific run-time environment implementation for LSM.\n*/\n\n#ifndef _WIN32\n\n#if defined(__GNUC__) || defined(__TINYC__)\n/* workaround for ftruncate() visibility on gcc. */\n# ifndef _XOPEN_SOURCE\n#  define _XOPEN_SOURCE 500\n# endif\n#endif\n\n#include <unistd.h>\n#include <sys/types.h>\n\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <assert.h>\n#include <string.h>\n\n#include <stdlib.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <ctype.h>\n\n#include <unistd.h>\n#include <errno.h>\n\n#include <sys/mman.h>\n#include \"lsmInt.h\"\n\n/* There is no fdatasync() call on Android */\n#ifdef __ANDROID__\n# define fdatasync(x) fsync(x)\n#endif\n\n/*\n** An open file is an instance of the following object\n*/\ntypedef struct PosixFile PosixFile;\nstruct PosixFile {\n  lsm_env *pEnv;                  /* The run-time environment */\n  const char *zName;              /* Full path to file */\n  int fd;                         /* The open file descriptor */\n  int shmfd;                      /* Shared memory file-descriptor */\n  void *pMap;                     /* Pointer to mapping of file fd */\n  off_t nMap;                     /* Size of mapping at pMap in bytes */\n  int nShm;                       /* Number of entries in array apShm[] */\n  void **apShm;                   /* Array of 32K shared memory segments */\n};\n\nstatic char *posixShmFile(PosixFile *p){\n  char *zShm;\n  int nName = strlen(p->zName);\n  zShm = (char *)lsmMalloc(p->pEnv, nName+4+1);\n  if( zShm ){\n    memcpy(zShm, p->zName, nName);\n    memcpy(&zShm[nName], \"-shm\", 5);\n  }\n  return zShm;\n}\n\nstatic int lsmPosixOsOpen(\n  lsm_env *pEnv,\n  const char *zFile,\n  int flags,\n  lsm_file **ppFile\n){\n  int rc = LSM_OK;\n  PosixFile *p;\n\n  p = lsm_malloc(pEnv, sizeof(PosixFile));\n  if( p==0 ){\n    rc = LSM_NOMEM;\n  }else{\n    int bReadonly = (flags & LSM_OPEN_READONLY);\n    int oflags = (bReadonly ? O_RDONLY : (O_RDWR|O_CREAT));\n    memset(p, 0, sizeof(PosixFile));\n    p->zName = zFile;\n    p->pEnv = pEnv;\n    p->fd = open(zFile, oflags, 0644);\n    if( p->fd<0 ){\n      lsm_free(pEnv, p);\n      p = 0;\n      if( errno==ENOENT ){\n        rc = lsmErrorBkpt(LSM_IOERR_NOENT);\n      }else{\n        rc = LSM_IOERR_BKPT;\n      }\n    }\n  }\n\n  *ppFile = (lsm_file *)p;\n  return rc;\n}\n\nstatic int lsmPosixOsWrite(\n  lsm_file *pFile,                /* File to write to */\n  lsm_i64 iOff,                   /* Offset to write to */\n  void *pData,                    /* Write data from this buffer */\n  int nData                       /* Bytes of data to write */\n){\n  int rc = LSM_OK;\n  PosixFile *p = (PosixFile *)pFile;\n  off_t offset;\n\n  offset = lseek(p->fd, (off_t)iOff, SEEK_SET);\n  if( offset!=iOff ){\n    rc = LSM_IOERR_BKPT;\n  }else{\n    ssize_t prc = write(p->fd, pData, (size_t)nData);\n    if( prc<0 ) rc = LSM_IOERR_BKPT;\n  }\n\n  return rc;\n}\n\nstatic int lsmPosixOsTruncate(\n  lsm_file *pFile,                /* File to write to */\n  lsm_i64 nSize                   /* Size to truncate file to */\n){\n  PosixFile *p = (PosixFile *)pFile;\n  int rc = LSM_OK;                /* Return code */\n  int prc;                        /* Posix Return Code */\n  struct stat sStat;              /* Result of fstat() invocation */\n  \n  prc = fstat(p->fd, &sStat);\n  if( prc==0 && sStat.st_size>nSize ){\n    prc = ftruncate(p->fd, (off_t)nSize);\n  }\n  if( prc<0 ) rc = LSM_IOERR_BKPT;\n\n  return rc;\n}\n\nstatic int lsmPosixOsRead(\n  lsm_file *pFile,                /* File to read from */\n  lsm_i64 iOff,                   /* Offset to read from */\n  void *pData,                    /* Read data into this buffer */\n  int nData                       /* Bytes of data to read */\n){\n  int rc = LSM_OK;\n  PosixFile *p = (PosixFile *)pFile;\n  off_t offset;\n\n  offset = lseek(p->fd, (off_t)iOff, SEEK_SET);\n  if( offset!=iOff ){\n    rc = LSM_IOERR_BKPT;\n  }else{\n    ssize_t prc = read(p->fd, pData, (size_t)nData);\n    if( prc<0 ){ \n      rc = LSM_IOERR_BKPT;\n    }else if( prc<nData ){\n      memset(&((u8 *)pData)[prc], 0, nData - prc);\n    }\n\n  }\n\n  return rc;\n}\n\nstatic int lsmPosixOsSync(lsm_file *pFile){\n  int rc = LSM_OK;\n\n#ifndef LSM_NO_SYNC\n  PosixFile *p = (PosixFile *)pFile;\n  int prc = 0;\n\n  if( p->pMap ){\n    prc = msync(p->pMap, p->nMap, MS_SYNC);\n  }\n  if( prc==0 ) prc = fdatasync(p->fd);\n  if( prc<0 ) rc = LSM_IOERR_BKPT;\n#else\n  (void)pFile;\n#endif\n\n  return rc;\n}\n\nstatic int lsmPosixOsSectorSize(lsm_file *pFile){\n  return 512;\n}\n\nstatic int lsmPosixOsRemap(\n  lsm_file *pFile, \n  lsm_i64 iMin, \n  void **ppOut,\n  lsm_i64 *pnOut\n){\n  off_t iSz;\n  int prc;\n  PosixFile *p = (PosixFile *)pFile;\n  struct stat buf;\n\n  /* If the file is between 0 and 2MB in size, extend it in chunks of 256K.\n  ** Thereafter, in chunks of 1MB at a time.  */\n  const int aIncrSz[] = {256*1024, 1024*1024};\n  int nIncrSz = aIncrSz[iMin>(2*1024*1024)];\n\n  if( p->pMap ){\n    munmap(p->pMap, p->nMap);\n    *ppOut = p->pMap = 0;\n    *pnOut = p->nMap = 0;\n  }\n\n  if( iMin>=0 ){\n    memset(&buf, 0, sizeof(buf));\n    prc = fstat(p->fd, &buf);\n    if( prc!=0 ) return LSM_IOERR_BKPT;\n    iSz = buf.st_size;\n    if( iSz<iMin ){\n      iSz = ((iMin + nIncrSz-1) / nIncrSz) * nIncrSz;\n      prc = ftruncate(p->fd, iSz);\n      if( prc!=0 ) return LSM_IOERR_BKPT;\n    }\n\n    p->pMap = mmap(0, iSz, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd, 0);\n    p->nMap = iSz;\n  }\n\n  *ppOut = p->pMap;\n  *pnOut = p->nMap;\n  return LSM_OK;\n}\n\nstatic int lsmPosixOsFullpath(\n  lsm_env *pEnv,\n  const char *zName,\n  char *zOut,\n  int *pnOut\n){\n  int nBuf = *pnOut;\n  int nReq;\n\n  if( zName[0]!='/' ){\n    char *z;\n    char *zTmp;\n    int nTmp = 512;\n    zTmp = lsmMalloc(pEnv, nTmp);\n    while( zTmp ){\n      z = getcwd(zTmp, nTmp);\n      if( z || errno!=ERANGE ) break;\n      nTmp = nTmp*2;\n      zTmp = lsmReallocOrFree(pEnv, zTmp, nTmp);\n    }\n    if( zTmp==0 ) return LSM_NOMEM_BKPT;\n    if( z==0 ) return LSM_IOERR_BKPT;\n    assert( z==zTmp );\n\n    nTmp = strlen(zTmp);\n    nReq = nTmp + 1 + strlen(zName) + 1;\n    if( nReq<=nBuf ){\n      memcpy(zOut, zTmp, nTmp);\n      zOut[nTmp] = '/';\n      memcpy(&zOut[nTmp+1], zName, strlen(zName)+1);\n    }\n    lsmFree(pEnv, zTmp);\n  }else{\n    nReq = strlen(zName)+1;\n    if( nReq<=nBuf ){\n      memcpy(zOut, zName, strlen(zName)+1);\n    }\n  }\n\n  *pnOut = nReq;\n  return LSM_OK;\n}\n\nstatic int lsmPosixOsFileid(\n  lsm_file *pFile, \n  void *pBuf,\n  int *pnBuf\n){\n  int prc;\n  int nBuf;\n  int nReq;\n  PosixFile *p = (PosixFile *)pFile;\n  struct stat buf;\n\n  nBuf = *pnBuf;\n  nReq = (sizeof(buf.st_dev) + sizeof(buf.st_ino));\n  *pnBuf = nReq;\n  if( nReq>nBuf ) return LSM_OK;\n\n  memset(&buf, 0, sizeof(buf));\n  prc = fstat(p->fd, &buf);\n  if( prc!=0 ) return LSM_IOERR_BKPT;\n\n  memcpy(pBuf, &buf.st_dev, sizeof(buf.st_dev));\n  memcpy(&(((u8 *)pBuf)[sizeof(buf.st_dev)]), &buf.st_ino, sizeof(buf.st_ino));\n  return LSM_OK;\n}\n\nstatic int lsmPosixOsUnlink(lsm_env *pEnv, const char *zFile){\n  int prc = unlink(zFile);\n  return prc ? LSM_IOERR_BKPT : LSM_OK;\n}\n\nstatic int lsmPosixOsLock(lsm_file *pFile, int iLock, int eType){\n  int rc = LSM_OK;\n  PosixFile *p = (PosixFile *)pFile;\n  static const short aType[3] = { F_UNLCK, F_RDLCK, F_WRLCK };\n  struct flock lock;\n\n  assert( aType[LSM_LOCK_UNLOCK]==F_UNLCK );\n  assert( aType[LSM_LOCK_SHARED]==F_RDLCK );\n  assert( aType[LSM_LOCK_EXCL]==F_WRLCK );\n  assert( eType>=0 && eType<array_size(aType) );\n  assert( iLock>0 && iLock<=32 );\n\n  memset(&lock, 0, sizeof(lock));\n  lock.l_whence = SEEK_SET;\n  lock.l_len = 1;\n  lock.l_type = aType[eType];\n  lock.l_start = (4096-iLock);\n\n  if( fcntl(p->fd, F_SETLK, &lock) ){\n    int e = errno;\n    if( e==EACCES || e==EAGAIN ){\n      rc = LSM_BUSY;\n    }else{\n      rc = LSM_IOERR_BKPT;\n    }\n  }\n\n  return rc;\n}\n\nstatic int lsmPosixOsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){\n  int rc = LSM_OK;\n  PosixFile *p = (PosixFile *)pFile;\n  static const short aType[3] = { 0, F_RDLCK, F_WRLCK };\n  struct flock lock;\n\n  assert( eType==LSM_LOCK_SHARED || eType==LSM_LOCK_EXCL );\n  assert( aType[LSM_LOCK_SHARED]==F_RDLCK );\n  assert( aType[LSM_LOCK_EXCL]==F_WRLCK );\n  assert( eType>=0 && eType<array_size(aType) );\n  assert( iLock>0 && iLock<=32 );\n\n  memset(&lock, 0, sizeof(lock));\n  lock.l_whence = SEEK_SET;\n  lock.l_len = nLock;\n  lock.l_type = aType[eType];\n  lock.l_start = (4096-iLock-nLock+1);\n\n  if( fcntl(p->fd, F_GETLK, &lock) ){\n    rc = LSM_IOERR_BKPT;\n  }else if( lock.l_type!=F_UNLCK ){\n    rc = LSM_BUSY;\n  }\n\n  return rc;\n}\n\nstatic int lsmPosixOsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){\n  PosixFile *p = (PosixFile *)pFile;\n\n  *ppShm = 0;\n  assert( sz==LSM_SHM_CHUNK_SIZE );\n  if( iChunk>=p->nShm ){\n    int i;\n    void **apNew;\n    int nNew = iChunk+1;\n    off_t nReq = nNew * LSM_SHM_CHUNK_SIZE;\n    struct stat sStat;\n\n    /* If the shared-memory file has not been opened, open it now. */\n    if( p->shmfd<=0 ){\n      char *zShm = posixShmFile(p);\n      if( !zShm ) return LSM_NOMEM_BKPT;\n      p->shmfd = open(zShm, O_RDWR|O_CREAT, 0644);\n      lsmFree(p->pEnv, zShm);\n      if( p->shmfd<0 ){ \n        return LSM_IOERR_BKPT;\n      }\n    }\n\n    /* If the shared-memory file is not large enough to contain the \n    ** requested chunk, cause it to grow.  */\n    if( fstat(p->shmfd, &sStat) ){\n      return LSM_IOERR_BKPT;\n    }\n    if( sStat.st_size<nReq ){\n      if( ftruncate(p->shmfd, nReq) ){\n        return LSM_IOERR_BKPT;\n      }\n    }\n\n    apNew = (void **)lsmRealloc(p->pEnv, p->apShm, sizeof(void *) * nNew);\n    if( !apNew ) return LSM_NOMEM_BKPT;\n    for(i=p->nShm; i<nNew; i++){\n      apNew[i] = 0;\n    }\n    p->apShm = apNew;\n    p->nShm = nNew;\n  }\n\n  if( p->apShm[iChunk]==0 ){\n    p->apShm[iChunk] = mmap(0, LSM_SHM_CHUNK_SIZE, \n        PROT_READ|PROT_WRITE, MAP_SHARED, p->shmfd, iChunk*LSM_SHM_CHUNK_SIZE\n    );\n    if( p->apShm[iChunk]==0 ) return LSM_IOERR_BKPT;\n  }\n\n  *ppShm = p->apShm[iChunk];\n  return LSM_OK;\n}\n\nstatic void lsmPosixOsShmBarrier(void){\n}\n\nstatic int lsmPosixOsShmUnmap(lsm_file *pFile, int bDelete){\n  PosixFile *p = (PosixFile *)pFile;\n  if( p->shmfd>0 ){\n    int i;\n    for(i=0; i<p->nShm; i++){\n      if( p->apShm[i] ){\n        munmap(p->apShm[i], LSM_SHM_CHUNK_SIZE);\n        p->apShm[i] = 0;\n      }\n    }\n    close(p->shmfd);\n    p->shmfd = 0;\n    if( bDelete ){\n      char *zShm = posixShmFile(p);\n      if( zShm ) unlink(zShm);\n      lsmFree(p->pEnv, zShm);\n    }\n  }\n  return LSM_OK;\n}\n\n\nstatic int lsmPosixOsClose(lsm_file *pFile){\n   PosixFile *p = (PosixFile *)pFile;\n   lsmPosixOsShmUnmap(pFile, 0);\n   if( p->pMap ) munmap(p->pMap, p->nMap);\n   close(p->fd);\n   lsm_free(p->pEnv, p->apShm);\n   lsm_free(p->pEnv, p);\n   return LSM_OK;\n}\n\nstatic int lsmPosixOsSleep(lsm_env *pEnv, int us){\n#if 0\n  /* Apparently on Android usleep() returns void */\n  if( usleep(us) ) return LSM_IOERR;\n#endif\n  usleep(us);\n  return LSM_OK;\n}\n\n/****************************************************************************\n** Memory allocation routines.\n*/\n#define BLOCK_HDR_SIZE ROUND8( sizeof(size_t) )\n\nstatic void *lsmPosixOsMalloc(lsm_env *pEnv, size_t N){\n  unsigned char * m;\n  N += BLOCK_HDR_SIZE;\n  m = (unsigned char *)malloc(N);\n  *((size_t*)m) = N;\n  return m + BLOCK_HDR_SIZE;\n}\n\nstatic void lsmPosixOsFree(lsm_env *pEnv, void *p){\n  if(p){\n    free( ((unsigned char *)p) - BLOCK_HDR_SIZE );\n  }\n}\n\nstatic void *lsmPosixOsRealloc(lsm_env *pEnv, void *p, size_t N){\n  unsigned char * m = (unsigned char *)p;\n  if(1>N){\n    lsmPosixOsFree( pEnv, p );\n    return NULL;\n  }else if(NULL==p){\n    return lsmPosixOsMalloc(pEnv, N);\n  }else{\n    void * re = NULL;\n    m -= BLOCK_HDR_SIZE;\n#if 0 /* arguable: don't shrink */\n    size_t * sz = (size_t*)m;\n    if(*sz >= (size_t)N){\n      return p;\n    }\n#endif\n    re = realloc( m, N + BLOCK_HDR_SIZE );\n    if(re){\n      m = (unsigned char *)re;\n      *((size_t*)m) = N;\n      return m + BLOCK_HDR_SIZE;\n    }else{\n      return NULL;\n    }\n  }\n}\n\nstatic size_t lsmPosixOsMSize(lsm_env *pEnv, void *p){\n  unsigned char * m = (unsigned char *)p;\n  return *((size_t*)(m-BLOCK_HDR_SIZE));\n}\n#undef BLOCK_HDR_SIZE\n\n\n#ifdef LSM_MUTEX_PTHREADS \n/*************************************************************************\n** Mutex methods for pthreads based systems.  If LSM_MUTEX_PTHREADS is\n** missing then a no-op implementation of mutexes found in lsm_mutex.c\n** will be used instead.\n*/\n#include <pthread.h>\n\ntypedef struct PthreadMutex PthreadMutex;\nstruct PthreadMutex {\n  lsm_env *pEnv;\n  pthread_mutex_t mutex;\n#ifdef LSM_DEBUG\n  pthread_t owner;\n#endif\n};\n\n#ifdef LSM_DEBUG\n# define LSM_PTHREAD_STATIC_MUTEX { 0, PTHREAD_MUTEX_INITIALIZER, 0 }\n#else\n# define LSM_PTHREAD_STATIC_MUTEX { 0, PTHREAD_MUTEX_INITIALIZER }\n#endif\n\nstatic int lsmPosixOsMutexStatic(\n  lsm_env *pEnv,\n  int iMutex,\n  lsm_mutex **ppStatic\n){\n  static PthreadMutex sMutex[2] = {\n    LSM_PTHREAD_STATIC_MUTEX,\n    LSM_PTHREAD_STATIC_MUTEX\n  };\n\n  assert( iMutex==LSM_MUTEX_GLOBAL || iMutex==LSM_MUTEX_HEAP );\n  assert( LSM_MUTEX_GLOBAL==1 && LSM_MUTEX_HEAP==2 );\n\n  *ppStatic = (lsm_mutex *)&sMutex[iMutex-1];\n  return LSM_OK;\n}\n\nstatic int lsmPosixOsMutexNew(lsm_env *pEnv, lsm_mutex **ppNew){\n  PthreadMutex *pMutex;           /* Pointer to new mutex */\n  pthread_mutexattr_t attr;       /* Attributes object */\n\n  pMutex = (PthreadMutex *)lsmMallocZero(pEnv, sizeof(PthreadMutex));\n  if( !pMutex ) return LSM_NOMEM_BKPT;\n\n  pMutex->pEnv = pEnv;\n  pthread_mutexattr_init(&attr);\n  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);\n  pthread_mutex_init(&pMutex->mutex, &attr);\n  pthread_mutexattr_destroy(&attr);\n\n  *ppNew = (lsm_mutex *)pMutex;\n  return LSM_OK;\n}\n\nstatic void lsmPosixOsMutexDel(lsm_mutex *p){\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n  pthread_mutex_destroy(&pMutex->mutex);\n  lsmFree(pMutex->pEnv, pMutex);\n}\n\nstatic void lsmPosixOsMutexEnter(lsm_mutex *p){\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n  pthread_mutex_lock(&pMutex->mutex);\n\n#ifdef LSM_DEBUG\n  assert( !pthread_equal(pMutex->owner, pthread_self()) );\n  pMutex->owner = pthread_self();\n  assert( pthread_equal(pMutex->owner, pthread_self()) );\n#endif\n}\n\nstatic int lsmPosixOsMutexTry(lsm_mutex *p){\n  int ret;\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n  ret = pthread_mutex_trylock(&pMutex->mutex);\n#ifdef LSM_DEBUG\n  if( ret==0 ){\n    assert( !pthread_equal(pMutex->owner, pthread_self()) );\n    pMutex->owner = pthread_self();\n    assert( pthread_equal(pMutex->owner, pthread_self()) );\n  }\n#endif\n  return ret;\n}\n\nstatic void lsmPosixOsMutexLeave(lsm_mutex *p){\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n#ifdef LSM_DEBUG\n  assert( pthread_equal(pMutex->owner, pthread_self()) );\n  pMutex->owner = 0;\n  assert( !pthread_equal(pMutex->owner, pthread_self()) );\n#endif\n  pthread_mutex_unlock(&pMutex->mutex);\n}\n\n#ifdef LSM_DEBUG\nstatic int lsmPosixOsMutexHeld(lsm_mutex *p){\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n  return pMutex ? pthread_equal(pMutex->owner, pthread_self()) : 1;\n}\nstatic int lsmPosixOsMutexNotHeld(lsm_mutex *p){\n  PthreadMutex *pMutex = (PthreadMutex *)p;\n  return pMutex ? !pthread_equal(pMutex->owner, pthread_self()) : 1;\n}\n#endif\n/*\n** End of pthreads mutex implementation.\n*************************************************************************/\n#else\n/*************************************************************************\n** Noop mutex implementation\n*/\ntypedef struct NoopMutex NoopMutex;\nstruct NoopMutex {\n  lsm_env *pEnv;                  /* Environment handle (for xFree()) */\n  int bHeld;                      /* True if mutex is held */\n  int bStatic;                    /* True for a static mutex */\n};\nstatic NoopMutex aStaticNoopMutex[2] = {\n  {0, 0, 1},\n  {0, 0, 1},\n};\n\nstatic int lsmPosixOsMutexStatic(\n  lsm_env *pEnv,\n  int iMutex,\n  lsm_mutex **ppStatic\n){\n  assert( iMutex>=1 && iMutex<=(int)array_size(aStaticNoopMutex) );\n  *ppStatic = (lsm_mutex *)&aStaticNoopMutex[iMutex-1];\n  return LSM_OK;\n}\nstatic int lsmPosixOsMutexNew(lsm_env *pEnv, lsm_mutex **ppNew){\n  NoopMutex *p;\n  p = (NoopMutex *)lsmMallocZero(pEnv, sizeof(NoopMutex));\n  if( p ) p->pEnv = pEnv;\n  *ppNew = (lsm_mutex *)p;\n  return (p ? LSM_OK : LSM_NOMEM_BKPT);\n}\nstatic void lsmPosixOsMutexDel(lsm_mutex *pMutex)  { \n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bStatic==0 && p->pEnv );\n  lsmFree(p->pEnv, p);\n}\nstatic void lsmPosixOsMutexEnter(lsm_mutex *pMutex){ \n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==0 );\n  p->bHeld = 1;\n}\nstatic int lsmPosixOsMutexTry(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==0 );\n  p->bHeld = 1;\n  return 0;\n}\nstatic void lsmPosixOsMutexLeave(lsm_mutex *pMutex){ \n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==1 );\n  p->bHeld = 0;\n}\n#ifdef LSM_DEBUG\nstatic int lsmPosixOsMutexHeld(lsm_mutex *pMutex){ \n  NoopMutex *p = (NoopMutex *)pMutex;\n  return p ? p->bHeld : 1;\n}\nstatic int lsmPosixOsMutexNotHeld(lsm_mutex *pMutex){ \n  NoopMutex *p = (NoopMutex *)pMutex;\n  return p ? !p->bHeld : 1;\n}\n#endif\n/***************************************************************************/\n#endif /* else LSM_MUTEX_NONE */\n\n/* Without LSM_DEBUG, the MutexHeld tests are never called */\n#ifndef LSM_DEBUG\n# define lsmPosixOsMutexHeld    0\n# define lsmPosixOsMutexNotHeld 0\n#endif\n\nlsm_env *lsm_default_env(void){\n  static lsm_env posix_env = {\n    sizeof(lsm_env),         /* nByte */\n    1,                       /* iVersion */\n    /***** file i/o ******************/\n    0,                       /* pVfsCtx */\n    lsmPosixOsFullpath,      /* xFullpath */\n    lsmPosixOsOpen,          /* xOpen */\n    lsmPosixOsRead,          /* xRead */\n    lsmPosixOsWrite,         /* xWrite */\n    lsmPosixOsTruncate,      /* xTruncate */\n    lsmPosixOsSync,          /* xSync */\n    lsmPosixOsSectorSize,    /* xSectorSize */\n    lsmPosixOsRemap,         /* xRemap */\n    lsmPosixOsFileid,        /* xFileid */\n    lsmPosixOsClose,         /* xClose */\n    lsmPosixOsUnlink,        /* xUnlink */\n    lsmPosixOsLock,          /* xLock */\n    lsmPosixOsTestLock,      /* xTestLock */\n    lsmPosixOsShmMap,        /* xShmMap */\n    lsmPosixOsShmBarrier,    /* xShmBarrier */\n    lsmPosixOsShmUnmap,      /* xShmUnmap */\n    /***** memory allocation *********/\n    0,                       /* pMemCtx */\n    lsmPosixOsMalloc,        /* xMalloc */\n    lsmPosixOsRealloc,       /* xRealloc */\n    lsmPosixOsFree,          /* xFree */\n    lsmPosixOsMSize,         /* xSize */\n    /***** mutexes *********************/\n    0,                       /* pMutexCtx */\n    lsmPosixOsMutexStatic,   /* xMutexStatic */\n    lsmPosixOsMutexNew,      /* xMutexNew */\n    lsmPosixOsMutexDel,      /* xMutexDel */\n    lsmPosixOsMutexEnter,    /* xMutexEnter */\n    lsmPosixOsMutexTry,      /* xMutexTry */\n    lsmPosixOsMutexLeave,    /* xMutexLeave */\n    lsmPosixOsMutexHeld,     /* xMutexHeld */\n    lsmPosixOsMutexNotHeld,  /* xMutexNotHeld */\n    /***** other *********************/\n    lsmPosixOsSleep,         /* xSleep */\n  };\n  return &posix_env;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_varint.c",
    "content": "\n/*\n** 2012-02-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** SQLite4-compatible varint implementation.\n*/\n#include \"lsmInt.h\"\n\n/*************************************************************************\n** The following is a copy of the varint.c module from SQLite 4.\n*/\n\n/*\n** Decode the varint in z[].  Write the integer value into *pResult and\n** return the number of bytes in the varint.\n*/\nstatic int lsmSqlite4GetVarint64(const unsigned char *z, u64 *pResult){\n  unsigned int x;\n  if( z[0]<=240 ){\n    *pResult = z[0];\n    return 1;\n  }\n  if( z[0]<=248 ){\n    *pResult = (z[0]-241)*256 + z[1] + 240;\n    return 2;\n  }\n  if( z[0]==249 ){\n    *pResult = 2288 + 256*z[1] + z[2];\n    return 3;\n  }\n  if( z[0]==250 ){\n    *pResult = (z[1]<<16) + (z[2]<<8) + z[3];\n    return 4;\n  }\n  x = (z[1]<<24) + (z[2]<<16) + (z[3]<<8) + z[4];\n  if( z[0]==251 ){\n    *pResult = x;\n    return 5;\n  }\n  if( z[0]==252 ){\n    *pResult = (((u64)x)<<8) + z[5];\n    return 6;\n  }\n  if( z[0]==253 ){\n    *pResult = (((u64)x)<<16) + (z[5]<<8) + z[6];\n    return 7;\n  }\n  if( z[0]==254 ){\n    *pResult = (((u64)x)<<24) + (z[5]<<16) + (z[6]<<8) + z[7];\n    return 8;\n  }\n  *pResult = (((u64)x)<<32) +\n               (0xffffffff & ((z[5]<<24) + (z[6]<<16) + (z[7]<<8) + z[8]));\n  return 9;\n}\n\n/*\n** Write a 32-bit unsigned integer as 4 big-endian bytes.\n*/\nstatic void lsmVarintWrite32(unsigned char *z, unsigned int y){\n  z[0] = (unsigned char)(y>>24);\n  z[1] = (unsigned char)(y>>16);\n  z[2] = (unsigned char)(y>>8);\n  z[3] = (unsigned char)(y);\n}\n\n/*\n** Write a varint into z[].  The buffer z[] must be at least 9 characters\n** long to accommodate the largest possible varint.  Return the number of\n** bytes of z[] used.\n*/\nstatic int lsmSqlite4PutVarint64(unsigned char *z, u64 x){\n  unsigned int w, y;\n  if( x<=240 ){\n    z[0] = (unsigned char)x;\n    return 1;\n  }\n  if( x<=2287 ){\n    y = (unsigned int)(x - 240);\n    z[0] = (unsigned char)(y/256 + 241);\n    z[1] = (unsigned char)(y%256);\n    return 2;\n  }\n  if( x<=67823 ){\n    y = (unsigned int)(x - 2288);\n    z[0] = 249;\n    z[1] = (unsigned char)(y/256);\n    z[2] = (unsigned char)(y%256);\n    return 3;\n  }\n  y = (unsigned int)x;\n  w = (unsigned int)(x>>32);\n  if( w==0 ){\n    if( y<=16777215 ){\n      z[0] = 250;\n      z[1] = (unsigned char)(y>>16);\n      z[2] = (unsigned char)(y>>8);\n      z[3] = (unsigned char)(y);\n      return 4;\n    }\n    z[0] = 251;\n    lsmVarintWrite32(z+1, y);\n    return 5;\n  }\n  if( w<=255 ){\n    z[0] = 252;\n    z[1] = (unsigned char)w;\n    lsmVarintWrite32(z+2, y);\n    return 6;\n  }\n  if( w<=32767 ){\n    z[0] = 253;\n    z[1] = (unsigned char)(w>>8);\n    z[2] = (unsigned char)w;\n    lsmVarintWrite32(z+3, y);\n    return 7;\n  }\n  if( w<=16777215 ){\n    z[0] = 254;\n    z[1] = (unsigned char)(w>>16);\n    z[2] = (unsigned char)(w>>8);\n    z[3] = (unsigned char)w;\n    lsmVarintWrite32(z+4, y);\n    return 8;\n  }\n  z[0] = 255;\n  lsmVarintWrite32(z+1, w);\n  lsmVarintWrite32(z+5, y);\n  return 9;\n}\n\n/*\n** End of SQLite 4 code.\n*************************************************************************/\n\nint lsmVarintPut64(u8 *aData, i64 iVal){\n  return lsmSqlite4PutVarint64(aData, (u64)iVal);\n}\n\nint lsmVarintGet64(const u8 *aData, i64 *piVal){\n  return lsmSqlite4GetVarint64(aData, (u64 *)piVal);\n}\n\nint lsmVarintPut32(u8 *aData, int iVal){\n  return lsmSqlite4PutVarint64(aData, (u64)iVal);\n}\n\nint lsmVarintGet32(u8 *z, int *piVal){\n  u64 i;\n  int ret;\n\n  if( z[0]<=240 ){\n    *piVal = z[0];\n    return 1;\n  }\n  if( z[0]<=248 ){\n    *piVal = (z[0]-241)*256 + z[1] + 240;\n    return 2;\n  }\n  if( z[0]==249 ){\n    *piVal = 2288 + 256*z[1] + z[2];\n    return 3;\n  }\n  if( z[0]==250 ){\n    *piVal = (z[1]<<16) + (z[2]<<8) + z[3];\n    return 4;\n  }\n\n  ret = lsmSqlite4GetVarint64(z, &i);\n  *piVal = (int)i;\n  return ret;\n}\n\nint lsmVarintLen32(int n){\n  u8 aData[9];\n  return lsmVarintPut32(aData, n);\n}\n\n/*\n** The argument is the first byte of a varint. This function returns the\n** total number of bytes in the entire varint (including the first byte).\n*/\nint lsmVarintSize(u8 c){\n  if( c<241 ) return 1;\n  if( c<249 ) return 2;\n  return (int)(c - 246);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_vtab.c",
    "content": "/*\n** 2015-11-16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a virtual table for SQLite3 around the LSM\n** storage engine from SQLite4.\n**\n** USAGE\n**\n**   CREATE VIRTUAL TABLE demo USING lsm1(filename,key,keytype,value1,...);\n**\n** The filename parameter is the name of the LSM database file, which is\n** separate and distinct from the SQLite3 database file.\n**\n** The keytype must be one of: UINT, TEXT, BLOB.  All keys must be of that\n** one type.  \"UINT\" means unsigned integer.  The values may be of any\n** SQLite datatype: BLOB, TEXT, INTEGER, FLOAT, or NULL.\n**\n** The virtual table contains read-only hidden columns:\n**\n**     lsm1_key\t      A BLOB which is the raw LSM key.  If the \"keytype\"\n**                    is BLOB or TEXT then this column is exactly the\n**                    same as the key.  For the UINT keytype, this column\n**                    will be a variable-length integer encoding of the key.\n**\n**     lsm1_value     A BLOB which is the raw LSM value.  All of the value\n**                    columns are packed into this BLOB using the encoding\n**                    described below.\n**\n** Attempts to write values into the lsm1_key and lsm1_value columns are\n** silently ignored.\n**\n** EXAMPLE\n**\n** The virtual table declared this way:\n**\n**    CREATE VIRTUAL TABLE demo2 USING lsm1('x.lsm',id,UINT,a,b,c,d);\n**\n** Results in a new virtual table named \"demo2\" that acts as if it has\n** the following schema:\n**\n**    CREATE TABLE demo2(\n**      id UINT PRIMARY KEY ON CONFLICT REPLACE,\n**      a ANY,\n**      b ANY,\n**      c ANY,\n**      d ANY,\n**      lsm1_key BLOB HIDDEN,\n**      lsm1_value BLOB HIDDEN\n**    ) WITHOUT ROWID;\n**\n** \n**\n** INTERNALS\n**\n** The key encoding for BLOB and TEXT is just a copy of the blob or text.\n** UTF-8 is used for text.  The key encoding for UINT is the variable-length\n** integer format at https://sqlite.org/src4/doc/trunk/www/varint.wiki.\n**\n** The values are encoded as a single blob (since that is what lsm stores as\n** its content).  There is a \"type integer\" followed by \"content\" for each\n** value, alternating back and forth.  The content might be empty.\n**\n**    TYPE1  CONTENT1  TYPE2  CONTENT2  TYPE3  CONTENT3 ....\n**\n** Each \"type integer\" is encoded as a variable-length integer in the\n** format of the link above.  Let the type integer be T.  The actual\n** datatype is an integer 0-5 equal to T%6.  Values 1 through 5 correspond\n** to SQLITE_INTEGER through SQLITE_NULL.  The size of the content in bytes\n** is T/6.  Type value 0 means that the value is an integer whose actual\n** values is T/6 and there is no content.  The type-value-0 integer format\n** only works for integers in the range of 0 through 40.\n**\n** There is no content for NULL or type-0 integers.  For BLOB and TEXT\n** values, the content is the blob data or the UTF-8 text data.  For\n** non-negative integers X, the content is a variable-length integer X*2.\n** For negative integers Y, the content is varaible-length integer (1-Y)*2+1.\n** For FLOAT values, the content is the IEEE754 floating point value in\n** native byte-order.  This means that FLOAT values will be corrupted when\n** database file is moved between big-endian and little-endian machines.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include \"lsm.h\"\n#include <assert.h>\n#include <string.h>\n\n/* Forward declaration of subclasses of virtual table objects */\ntypedef struct lsm1_vtab lsm1_vtab;\ntypedef struct lsm1_cursor lsm1_cursor;\ntypedef struct lsm1_vblob lsm1_vblob;\n\n/* Primitive types */\ntypedef unsigned char u8;\ntypedef unsigned int u32;\ntypedef sqlite3_uint64 u64;\n\n/* An open connection to an LSM table */\nstruct lsm1_vtab {\n  sqlite3_vtab base;          /* Base class - must be first */\n  lsm_db *pDb;                /* Open connection to the LSM table */\n  u8 keyType;                 /* SQLITE_BLOB, _TEXT, or _INTEGER */\n  u32 nVal;                   /* Number of value columns */\n};\n\n\n/* lsm1_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\nstruct lsm1_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  lsm_cursor *pLsmCur;       /* The LSM cursor */\n  u8 isDesc;                 /* 0: scan forward.  1: scan reverse */\n  u8 atEof;                  /* True if the scan is complete */\n  u8 bUnique;                /* True if no more than one row of output */\n  u8 *zData;                 /* Content of the current row */\n  u32 nData;                 /* Number of bytes in the current row */\n  u8 *aeType;                /* Types for all column values */\n  u32 *aiOfst;               /* Offsets to the various fields */\n  u32 *aiLen;                /* Length of each field */\n  u8 *pKey2;                 /* Loop termination key, or NULL */\n  u32 nKey2;                 /* Length of the loop termination key */\n};\n\n/* An extensible buffer object.\n**\n** Content can be appended.  Space to hold new content is automatically\n** allocated.\n*/\nstruct lsm1_vblob {\n  u8 *a;             /* Space to hold content, from sqlite3_malloc64() */\n  u64 n;             /* Bytes of space used */\n  u64 nAlloc;        /* Bytes of space allocated */\n  u8 errNoMem;       /* True if a memory allocation error has been seen */\n};\n\n#if defined(__GNUC__)\n#  define LSM1_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define LSM1_NOINLINE  __declspec(noinline)\n#else\n#  define LSM1_NOINLINE\n#endif\n\n\n/* Increase the available space in the vblob object so that it can hold\n** at least N more bytes.  Return the number of errors.\n*/\nstatic int lsm1VblobEnlarge(lsm1_vblob *p, u32 N){\n  if( p->n+N>p->nAlloc ){\n    if( p->errNoMem ) return 1;\n    p->nAlloc += N + (p->nAlloc ? p->nAlloc : N);\n    p->a = sqlite3_realloc64(p->a, p->nAlloc);\n    if( p->a==0 ){\n      p->n = 0;\n      p->nAlloc = 0;\n      p->errNoMem = 1;\n      return 1;\n    }\n    p->nAlloc = sqlite3_msize(p->a);\n  }\n  return 0;\n}\n\n/* Append N bytes to a vblob after first enlarging it */\nstatic LSM1_NOINLINE void lsm1VblobEnlargeAndAppend(\n  lsm1_vblob *p,\n  const u8 *pData,\n  u32 N\n){\n  if( p->n+N>p->nAlloc && lsm1VblobEnlarge(p, N) ) return;\n  memcpy(p->a+p->n, pData, N);\n  p->n += N;\n}\n\n/* Append N bytes to a vblob */\nstatic void lsm1VblobAppend(lsm1_vblob *p, const u8 *pData, u32 N){\n  sqlite3_int64 n = p->n;\n  if( n+N>p->nAlloc ){\n    lsm1VblobEnlargeAndAppend(p, pData, N);\n  }else{\n    p->n += N;\n    memcpy(p->a+n, pData, N);\n  }\n}\n\n/* append text to a vblob */\nstatic void lsm1VblobAppendText(lsm1_vblob *p, const char *z){\n  lsm1VblobAppend(p, (u8*)z, (u32)strlen(z));\n}\n\n/* Dequote the string */\nstatic void lsm1Dequote(char *z){\n  int j;\n  char cQuote = z[0];\n  size_t i, n;\n\n  if( cQuote!='\\'' && cQuote!='\"' ) return;\n  n = strlen(z);\n  if( n<2 || z[n-1]!=z[0] ) return;\n  for(i=1, j=0; i<n-1; i++){\n    if( z[i]==cQuote && z[i+1]==cQuote ) i++;\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n}\n\n\n/*\n** The lsm1Connect() method is invoked to create a new\n** lsm1_vtab that describes the virtual table.\n*/\nstatic int lsm1Connect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  lsm1_vtab *pNew;\n  int rc;\n  char *zFilename;\n  u8 keyType = 0;\n  int i;\n  lsm1_vblob sql;\n  static const char *azTypes[] = { \"UINT\",         \"TEXT\",     \"BLOB\" };\n  static const u8 aeTypes[] =    { SQLITE_INTEGER, SQLITE_TEXT, SQLITE_BLOB };\n  static const char *azArgName[] = {\"filename\", \"key\", \"key type\", \"value1\" };\n\n  for(i=0; i<sizeof(azArgName)/sizeof(azArgName[0]); i++){\n    if( argc<i+4 || argv[i+3]==0 || argv[i+3][0]==0 ){\n      *pzErr = sqlite3_mprintf(\"%s (%r) argument missing\",\n                               azArgName[i], i+1);\n      return SQLITE_ERROR;\n    }\n  }\n  for(i=0; i<sizeof(azTypes)/sizeof(azTypes[0]); i++){\n    if( sqlite3_stricmp(azTypes[i],argv[5])==0 ){\n      keyType = aeTypes[i];\n      break;\n    }\n  }\n  if( keyType==0 ){\n    *pzErr = sqlite3_mprintf(\"key type should be INT, TEXT, or BLOB\");\n    return SQLITE_ERROR;\n  }\n  *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n  pNew = (lsm1_vtab*)*ppVtab;\n  if( pNew==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pNew, 0, sizeof(*pNew));\n  pNew->keyType = keyType;\n  rc = lsm_new(0, &pNew->pDb);\n  if( rc ){\n    *pzErr = sqlite3_mprintf(\"lsm_new failed with error code %d\",  rc);\n    rc = SQLITE_ERROR;\n    goto connect_failed;\n  }\n  zFilename = sqlite3_mprintf(\"%s\", argv[3]);\n  lsm1Dequote(zFilename);\n  rc = lsm_open(pNew->pDb, zFilename);\n  sqlite3_free(zFilename);\n  if( rc ){\n    *pzErr = sqlite3_mprintf(\"lsm_open failed with %d\", rc);\n    rc = SQLITE_ERROR;\n    goto connect_failed;\n  }\n\n  memset(&sql, 0, sizeof(sql));\n  lsm1VblobAppendText(&sql, \"CREATE TABLE x(\");\n  lsm1VblobAppendText(&sql, argv[4]);\n  lsm1VblobAppendText(&sql, \" \");\n  lsm1VblobAppendText(&sql, argv[5]);\n  lsm1VblobAppendText(&sql, \" PRIMARY KEY\");\n  for(i=6; i<argc; i++){\n    lsm1VblobAppendText(&sql, \", \");\n    lsm1VblobAppendText(&sql, argv[i]);\n    pNew->nVal++;\n  }\n  lsm1VblobAppendText(&sql, \n      \", lsm1_command HIDDEN\"\n      \", lsm1_key HIDDEN\"\n      \", lsm1_value HIDDEN) WITHOUT ROWID\");\n  lsm1VblobAppend(&sql, (u8*)\"\", 1);\n  if( sql.errNoMem ){\n    rc = SQLITE_NOMEM;\n    goto connect_failed;\n  }\n  rc = sqlite3_declare_vtab(db, (const char*)sql.a);\n  sqlite3_free(sql.a);\n\nconnect_failed:\n  if( rc!=SQLITE_OK ){\n    if( pNew ){\n      if( pNew->pDb ) lsm_close(pNew->pDb);\n      sqlite3_free(pNew);\n    }\n    *ppVtab = 0;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for lsm1_cursor objects.\n*/\nstatic int lsm1Disconnect(sqlite3_vtab *pVtab){\n  lsm1_vtab *p = (lsm1_vtab*)pVtab;\n  lsm_close(p->pDb);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new lsm1_cursor object.\n*/\nstatic int lsm1Open(sqlite3_vtab *pVtab, sqlite3_vtab_cursor **ppCursor){\n  lsm1_vtab *p = (lsm1_vtab*)pVtab;\n  lsm1_cursor *pCur;\n  int rc;\n  pCur = sqlite3_malloc64( sizeof(*pCur)\n                 + p->nVal*(sizeof(pCur->aiOfst)+sizeof(pCur->aiLen)+1) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->aiOfst = (u32*)&pCur[1];\n  pCur->aiLen = &pCur->aiOfst[p->nVal];\n  pCur->aeType = (u8*)&pCur->aiLen[p->nVal];\n  *ppCursor = &pCur->base;\n  rc = lsm_csr_open(p->pDb, &pCur->pLsmCur);\n  if( rc==LSM_OK ){\n    rc = SQLITE_OK;\n  }else{\n    sqlite3_free(pCur);\n    *ppCursor = 0;\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** Destructor for a lsm1_cursor.\n*/\nstatic int lsm1Close(sqlite3_vtab_cursor *cur){\n  lsm1_cursor *pCur = (lsm1_cursor*)cur;\n  sqlite3_free(pCur->pKey2);\n  lsm_csr_close(pCur->pLsmCur);\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a lsm1_cursor to its next row of output.\n*/\nstatic int lsm1Next(sqlite3_vtab_cursor *cur){\n  lsm1_cursor *pCur = (lsm1_cursor*)cur;\n  int rc = LSM_OK;\n  if( pCur->bUnique ){\n    pCur->atEof = 1;\n  }else{\n    if( pCur->isDesc ){\n      rc = lsm_csr_prev(pCur->pLsmCur);\n    }else{\n      rc = lsm_csr_next(pCur->pLsmCur);\n    }\n    if( rc==LSM_OK && lsm_csr_valid(pCur->pLsmCur)==0 ){\n      pCur->atEof = 1;\n    }\n    if( pCur->pKey2 && pCur->atEof==0 ){\n      const u8 *pVal;\n      u32 nVal;\n      assert( pCur->isDesc==0 );\n      rc = lsm_csr_key(pCur->pLsmCur, (const void**)&pVal, (int*)&nVal);\n      if( rc==LSM_OK ){\n        u32 len = pCur->nKey2;\n        int c;\n        if( len>nVal ) len = nVal;\n        c = memcmp(pVal, pCur->pKey2, len);\n        if( c==0 ) c = nVal - pCur->nKey2;\n        if( c>0 ) pCur->atEof = 1;\n      }\n    }\n    pCur->zData = 0;\n  }\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int lsm1Eof(sqlite3_vtab_cursor *cur){\n  lsm1_cursor *pCur = (lsm1_cursor*)cur;\n  return pCur->atEof;\n}\n\n/*\n** Rowids are not supported by the underlying virtual table.  So always\n** return 0 for the rowid.\n*/\nstatic int lsm1Rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  *pRowid = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Type prefixes on LSM keys\n*/\n#define LSM1_TYPE_NEGATIVE   0\n#define LSM1_TYPE_POSITIVE   1\n#define LSM1_TYPE_TEXT       2\n#define LSM1_TYPE_BLOB       3\n\n/*\n** Write a 32-bit unsigned integer as 4 big-endian bytes.\n*/\nstatic void varintWrite32(unsigned char *z, unsigned int y){\n  z[0] = (unsigned char)(y>>24);\n  z[1] = (unsigned char)(y>>16);\n  z[2] = (unsigned char)(y>>8);\n  z[3] = (unsigned char)(y);\n}\n\n/*\n** Write a varint into z[].  The buffer z[] must be at least 9 characters\n** long to accommodate the largest possible varint.  Return the number of\n** bytes of z[] used.\n*/\nstatic int lsm1PutVarint64(unsigned char *z, sqlite3_uint64 x){\n  unsigned int w, y;\n  if( x<=240 ){\n    z[0] = (unsigned char)x;\n    return 1;\n  }\n  if( x<=2287 ){\n    y = (unsigned int)(x - 240);\n    z[0] = (unsigned char)(y/256 + 241);\n    z[1] = (unsigned char)(y%256);\n    return 2;\n  }\n  if( x<=67823 ){\n    y = (unsigned int)(x - 2288);\n    z[0] = 249;\n    z[1] = (unsigned char)(y/256);\n    z[2] = (unsigned char)(y%256);\n    return 3;\n  }\n  y = (unsigned int)x;\n  w = (unsigned int)(x>>32);\n  if( w==0 ){\n    if( y<=16777215 ){\n      z[0] = 250;\n      z[1] = (unsigned char)(y>>16);\n      z[2] = (unsigned char)(y>>8);\n      z[3] = (unsigned char)(y);\n      return 4;\n    }\n    z[0] = 251;\n    varintWrite32(z+1, y);\n    return 5;\n  }\n  if( w<=255 ){\n    z[0] = 252;\n    z[1] = (unsigned char)w;\n    varintWrite32(z+2, y);\n    return 6;\n  }\n  if( w<=65535 ){\n    z[0] = 253;\n    z[1] = (unsigned char)(w>>8);\n    z[2] = (unsigned char)w;\n    varintWrite32(z+3, y);\n    return 7;\n  }\n  if( w<=16777215 ){\n    z[0] = 254;\n    z[1] = (unsigned char)(w>>16);\n    z[2] = (unsigned char)(w>>8);\n    z[3] = (unsigned char)w;\n    varintWrite32(z+4, y);\n    return 8;\n  }\n  z[0] = 255;\n  varintWrite32(z+1, w);\n  varintWrite32(z+5, y);\n  return 9;\n}\n\n/* Append non-negative integer x as a variable-length integer.\n*/\nstatic void lsm1VblobAppendVarint(lsm1_vblob *p, sqlite3_uint64 x){\n  sqlite3_int64 n = p->n;\n  if( n+9>p->nAlloc && lsm1VblobEnlarge(p, 9) ) return;\n  p->n += lsm1PutVarint64(p->a+p->n, x);\n}\n\n/*\n** Decode the varint in the first n bytes z[].  Write the integer value\n** into *pResult and return the number of bytes in the varint.\n**\n** If the decode fails because there are not enough bytes in z[] then\n** return 0;\n*/\nstatic int lsm1GetVarint64(\n  const unsigned char *z,\n  int n,\n  sqlite3_uint64 *pResult\n){\n  unsigned int x;\n  if( n<1 ) return 0;\n  if( z[0]<=240 ){\n    *pResult = z[0];\n    return 1;\n  }\n  if( z[0]<=248 ){\n    if( n<2 ) return 0;\n    *pResult = (z[0]-241)*256 + z[1] + 240;\n    return 2;\n  }\n  if( n<z[0]-246 ) return 0;\n  if( z[0]==249 ){\n    *pResult = 2288 + 256*z[1] + z[2];\n    return 3;\n  }\n  if( z[0]==250 ){\n    *pResult = (z[1]<<16) + (z[2]<<8) + z[3];\n    return 4;\n  }\n  x = (z[1]<<24) + (z[2]<<16) + (z[3]<<8) + z[4];\n  if( z[0]==251 ){\n    *pResult = x;\n    return 5;\n  }\n  if( z[0]==252 ){\n    *pResult = (((sqlite3_uint64)x)<<8) + z[5];\n    return 6;\n  }\n  if( z[0]==253 ){\n    *pResult = (((sqlite3_uint64)x)<<16) + (z[5]<<8) + z[6];\n    return 7;\n  }\n  if( z[0]==254 ){\n    *pResult = (((sqlite3_uint64)x)<<24) + (z[5]<<16) + (z[6]<<8) + z[7];\n    return 8;\n  }\n  *pResult = (((sqlite3_uint64)x)<<32) +\n               (0xffffffff & ((z[5]<<24) + (z[6]<<16) + (z[7]<<8) + z[8]));\n  return 9;\n}\n\n/* Encoded a signed integer as a varint.  Numbers close to zero uses fewer\n** bytes than numbers far away from zero.  However, the result is not in\n** lexicographical order.\n**\n** Encoding:  Non-negative integer X is encoding as an unsigned\n** varint X*2.  Negative integer Y is encoding as an unsigned\n** varint (1-Y)*2 + 1.\n*/\nstatic int lsm1PutSignedVarint64(u8 *z, sqlite3_int64 v){\n  sqlite3_uint64 u;\n  if( v>=0 ){\n    u = (sqlite3_uint64)v;\n    return lsm1PutVarint64(z, u*2);\n  }else{\n    u = (sqlite3_uint64)(-1-v);\n    return lsm1PutVarint64(z, u*2+1);\n  }\n}\n\n/* Decoded a signed varint. */\nstatic int lsm1GetSignedVarint64(\n  const unsigned char *z,\n  int n,\n  sqlite3_int64 *pResult\n){\n  sqlite3_uint64 u = 0;\n  n = lsm1GetVarint64(z, n, &u);\n  if( u&1 ){\n    *pResult = -1 - (sqlite3_int64)(u>>1);\n  }else{\n    *pResult = (sqlite3_int64)(u>>1);\n  }\n  return n;\n}\n\n\n/*\n** Read the value part of the key-value pair and decode it into columns.\n*/\nstatic int lsm1DecodeValues(lsm1_cursor *pCur){\n  lsm1_vtab *pTab = (lsm1_vtab*)(pCur->base.pVtab);\n  int i, n;\n  int rc;\n  u8 eType;\n  sqlite3_uint64 v;\n\n  if( pCur->zData ) return 1;\n  rc = lsm_csr_value(pCur->pLsmCur, (const void**)&pCur->zData,\n                     (int*)&pCur->nData);\n  if( rc ) return 0;\n  for(i=n=0; i<pTab->nVal; i++){\n    v = 0;\n    n += lsm1GetVarint64(pCur->zData+n, pCur->nData-n, &v);\n    pCur->aeType[i] = eType = (u8)(v%6);\n    if( eType==0 ){\n      pCur->aiOfst[i] = (u32)(v/6);\n      pCur->aiLen[i] = 0;\n    }else{ \n      pCur->aiOfst[i] = n;\n      n += (pCur->aiLen[i] = (u32)(v/6));\n    }\n    if( n>pCur->nData ) break;\n  }\n  if( i<pTab->nVal ){\n    pCur->zData = 0;\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Return values of columns for the row at which the lsm1_cursor\n** is currently pointing.\n*/\nstatic int lsm1Column(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  lsm1_cursor *pCur = (lsm1_cursor*)cur;\n  lsm1_vtab *pTab = (lsm1_vtab*)(cur->pVtab);\n  if( i==0 ){\n    /* The key column */\n    const void *pVal;\n    int nVal;\n    if( lsm_csr_key(pCur->pLsmCur, &pVal, &nVal)==LSM_OK ){\n      if( pTab->keyType==SQLITE_BLOB ){\n        sqlite3_result_blob(ctx, pVal, nVal, SQLITE_TRANSIENT);\n      }else if( pTab->keyType==SQLITE_TEXT ){\n        sqlite3_result_text(ctx,(const char*)pVal, nVal, SQLITE_TRANSIENT);\n      }else{\n        const unsigned char *z = (const unsigned char*)pVal;\n        sqlite3_uint64 v1;\n        lsm1GetVarint64(z, nVal, &v1);\n        sqlite3_result_int64(ctx, (sqlite3_int64)v1);\n      }\n    }\n  }else if( i>pTab->nVal ){\n    if( i==pTab->nVal+2 ){  /* lsm1_key */\n      const void *pVal;\n      int nVal;\n      if( lsm_csr_key(pCur->pLsmCur, &pVal, &nVal)==LSM_OK ){\n        sqlite3_result_blob(ctx, pVal, nVal, SQLITE_TRANSIENT);\n      }\n    }else if( i==pTab->nVal+3 ){  /* lsm1_value */\n      const void *pVal;\n      int nVal;\n      if( lsm_csr_value(pCur->pLsmCur, &pVal, &nVal)==LSM_OK ){\n        sqlite3_result_blob(ctx, pVal, nVal, SQLITE_TRANSIENT);\n      }\n    }\n  }else if( lsm1DecodeValues(pCur) ){\n    /* The i-th value column (where leftmost is 1) */\n    const u8 *zData;\n    u32 nData;\n    i--;\n    zData = pCur->zData + pCur->aiOfst[i];\n    nData = pCur->aiLen[i];\n    switch( pCur->aeType[i] ){\n      case 0: {  /* in-line integer */\n        sqlite3_result_int(ctx, pCur->aiOfst[i]);\n        break;\n      }\n      case SQLITE_INTEGER: {\n        sqlite3_int64 v;\n        lsm1GetSignedVarint64(zData, nData, &v);\n        sqlite3_result_int64(ctx, v);\n        break;\n      }\n      case SQLITE_FLOAT: {\n        double v;\n        if( nData==sizeof(v) ){\n          memcpy(&v, zData, sizeof(v));\n          sqlite3_result_double(ctx, v);\n        }\n        break;\n      }\n      case SQLITE_TEXT: {\n        sqlite3_result_text(ctx, (const char*)zData, nData, SQLITE_TRANSIENT);\n        break;\n      }\n      case SQLITE_BLOB: {\n        sqlite3_result_blob(ctx, zData, nData, SQLITE_TRANSIENT);\n        break;\n      }\n      default: {\n         /* A NULL.  Do nothing */\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Parameter \"pValue\" contains an SQL value that is to be used as\n** a key in an LSM table.  The type of the key is determined by\n** \"keyType\".  Extract the raw bytes used for the key in LSM1.\n*/\nstatic void lsm1KeyFromValue(\n  int keyType,                 /* The key type */\n  sqlite3_value *pValue,       /* The key value */\n  u8 *pBuf,                    /* Storage space for a generated key */\n  const u8 **ppKey,            /* OUT: the bytes of the key */\n  int *pnKey                   /* OUT: size of the key */\n){\n  if( keyType==SQLITE_BLOB ){\n    *ppKey = (const u8*)sqlite3_value_blob(pValue);\n    *pnKey = sqlite3_value_bytes(pValue);\n  }else if( keyType==SQLITE_TEXT ){\n    *ppKey = (const u8*)sqlite3_value_text(pValue);\n    *pnKey = sqlite3_value_bytes(pValue);\n  }else{\n    sqlite3_int64 v = sqlite3_value_int64(pValue);\n    if( v<0 ) v = 0;\n    *pnKey = lsm1PutVarint64(pBuf, v);\n    *ppKey = pBuf;\n  }\n}\n\n/* Move to the first row to return.\n*/\nstatic int lsm1Filter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  lsm1_cursor *pCur = (lsm1_cursor *)pVtabCursor;\n  lsm1_vtab *pTab = (lsm1_vtab*)(pCur->base.pVtab);\n  int rc = LSM_OK;\n  int seekType = -1;\n  const u8 *pVal = 0;\n  int nVal;\n  u8 keyType = pTab->keyType;\n  u8 aKey1[16];\n\n  pCur->atEof = 1;\n  sqlite3_free(pCur->pKey2);\n  pCur->pKey2 = 0;\n  if( idxNum<99 ){\n    lsm1KeyFromValue(keyType, argv[0], aKey1, &pVal, &nVal);\n  }\n  switch( idxNum ){\n    case 0: {   /* key==argv[0] */\n      assert( argc==1 );\n      seekType = LSM_SEEK_EQ;\n      pCur->isDesc = 0;\n      pCur->bUnique = 1;\n      break;\n    }\n    case 1: {  /* key>=argv[0] AND key<=argv[1] */\n      u8 aKey[12];\n      seekType = LSM_SEEK_GE;\n      pCur->isDesc = 0;\n      pCur->bUnique = 0;\n      if( keyType==SQLITE_INTEGER ){\n        sqlite3_int64 v = sqlite3_value_int64(argv[1]);\n        if( v<0 ) v = 0;\n        pCur->nKey2 = lsm1PutVarint64(aKey, (sqlite3_uint64)v);\n        pCur->pKey2 = sqlite3_malloc( pCur->nKey2 );\n        if( pCur->pKey2==0 ) return SQLITE_NOMEM;\n        memcpy(pCur->pKey2, aKey, pCur->nKey2);\n      }else{\n        pCur->nKey2 = sqlite3_value_bytes(argv[1]);\n        pCur->pKey2 = sqlite3_malloc( pCur->nKey2 );\n        if( pCur->pKey2==0 ) return SQLITE_NOMEM;\n        if( keyType==SQLITE_BLOB ){\n          memcpy(pCur->pKey2, sqlite3_value_blob(argv[1]), pCur->nKey2);\n        }else{\n          memcpy(pCur->pKey2, sqlite3_value_text(argv[1]), pCur->nKey2);\n        }\n      }\n      break;\n    }\n    case 2: {  /* key>=argv[0] */\n      seekType = LSM_SEEK_GE;\n      pCur->isDesc = 0;\n      pCur->bUnique = 0;\n      break;\n    }\n    case 3: {  /* key<=argv[0] */\n      seekType = LSM_SEEK_LE;\n      pCur->isDesc = 1;\n      pCur->bUnique = 0;\n      break;\n    }\n    default: { /* full table scan */\n      pCur->isDesc = 0;\n      pCur->bUnique = 0;\n      break;\n    }\n  }\n  if( pVal ){\n    rc = lsm_csr_seek(pCur->pLsmCur, pVal, nVal, seekType);\n  }else{\n    rc = lsm_csr_first(pCur->pLsmCur);\n  }\n  if( rc==LSM_OK && lsm_csr_valid(pCur->pLsmCur)!=0 ){\n    pCur->atEof = 0;\n  }\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}\n\n/*\n** Only comparisons against the key are allowed.  The idxNum defines\n** which comparisons are available:\n**\n**     0        key==?1\n**     1        key>=?1 AND key<=?2\n**     2        key>?1 or key>=?1\n**     3        key<?1 or key<=?1\n**    99        Full table scan only\n*/\nstatic int lsm1BestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                 /* Loop over constraints */\n  int idxNum = 99;       /* The query plan */\n  int nArg = 0;          /* Number of arguments to xFilter */\n  int argIdx = -1;       /* Index of the key== constraint, or -1 if none */\n  int iIdx2 = -1;        /* The index of the second key */\n  int omit1 = 0;\n  int omit2 = 0;\n\n  const struct sqlite3_index_constraint *pConstraint;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint && idxNum<16; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->iColumn!=0 ) continue;\n    switch( pConstraint->op ){\n      case SQLITE_INDEX_CONSTRAINT_EQ: {\n        if( idxNum>0 ){\n          argIdx = i;\n          iIdx2 = -1;\n          idxNum = 0;\n          omit1 = 1;\n        }\n        break;\n      }\n      case SQLITE_INDEX_CONSTRAINT_GE:\n      case SQLITE_INDEX_CONSTRAINT_GT: {\n        if( idxNum==99 ){\n          argIdx = i;\n          idxNum = 2;\n          omit1 = pConstraint->op==SQLITE_INDEX_CONSTRAINT_GE;\n        }else if( idxNum==3 ){\n          iIdx2 = idxNum;\n          omit2 = omit1;\n          argIdx = i;\n          idxNum = 1;\n          omit1 = pConstraint->op==SQLITE_INDEX_CONSTRAINT_GE;\n        }\n        break;\n      }\n      case SQLITE_INDEX_CONSTRAINT_LE:\n      case SQLITE_INDEX_CONSTRAINT_LT: {\n        if( idxNum==99 ){\n          argIdx = i;\n          idxNum = 3;\n          omit1 = pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE;\n        }else if( idxNum==2 ){\n          iIdx2 = i;\n          idxNum = 1;\n          omit1 = pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE;\n        }\n        break;\n      }\n    }\n  }\n  if( argIdx>=0 ){\n    pIdxInfo->aConstraintUsage[argIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[argIdx].omit = omit1;\n  }\n  if( iIdx2>=0 ){\n    pIdxInfo->aConstraintUsage[iIdx2].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[iIdx2].omit = omit2;\n  }\n  if( idxNum==0 ){\n    pIdxInfo->estimatedCost = (double)1;\n    pIdxInfo->estimatedRows = 1;\n    pIdxInfo->orderByConsumed = 1;\n  }else if( idxNum==1 ){\n    pIdxInfo->estimatedCost = (double)100;\n    pIdxInfo->estimatedRows = 100;\n  }else if( idxNum<99 ){\n    pIdxInfo->estimatedCost = (double)5000;\n    pIdxInfo->estimatedRows = 5000;\n  }else{\n    /* Full table scan */\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n  }\n  pIdxInfo->idxNum = idxNum;\n  return SQLITE_OK;\n}\n\n/*\n** The xUpdate method is normally used for INSERT, REPLACE, UPDATE, and\n** DELETE.  But this virtual table only supports INSERT and REPLACE.\n** DELETE is accomplished by inserting a record with a value of NULL.\n** UPDATE is achieved by using REPLACE.\n*/\nint lsm1Update(\n  sqlite3_vtab *pVTab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  lsm1_vtab *p = (lsm1_vtab*)pVTab;\n  int nKey, nKey2;\n  int i;\n  int rc = LSM_OK;\n  const u8 *pKey, *pKey2;\n  unsigned char aKey[16];\n  unsigned char pSpace[16];\n  lsm1_vblob val;\n\n  if( argc==1 ){\n    /* DELETE the record whose key is argv[0] */\n    lsm1KeyFromValue(p->keyType, argv[0], aKey, &pKey, &nKey);\n    lsm_delete(p->pDb, pKey, nKey);\n    return SQLITE_OK;\n  }\n\n  if( sqlite3_value_type(argv[0])!=SQLITE_NULL ){\n    /* An UPDATE */\n    lsm1KeyFromValue(p->keyType, argv[0], aKey, &pKey, &nKey);\n    lsm1KeyFromValue(p->keyType, argv[1], pSpace, &pKey2, &nKey2);\n    if( nKey!=nKey2 || memcmp(pKey, pKey2, nKey)!=0 ){\n      /* The UPDATE changes the PRIMARY KEY value.  DELETE the old key */\n      lsm_delete(p->pDb, pKey, nKey);\n    }\n    /* Fall through into the INSERT case to complete the UPDATE */\n  }\n\n  /* \"INSERT INTO tab(lsm1_command) VALUES('....')\" is used to implement\n  ** special commands.\n  */\n  if( sqlite3_value_type(argv[3+p->nVal])!=SQLITE_NULL ){\n    return SQLITE_OK;\n  }\n  lsm1KeyFromValue(p->keyType, argv[2], aKey, &pKey, &nKey);\n  memset(&val, 0, sizeof(val));\n  for(i=0; i<p->nVal; i++){\n    sqlite3_value *pArg = argv[3+i];\n    u8 eType = sqlite3_value_type(pArg);\n    switch( eType ){\n      case SQLITE_NULL: {\n        lsm1VblobAppendVarint(&val, SQLITE_NULL);\n        break;\n      }\n      case SQLITE_INTEGER: {\n        sqlite3_int64 v = sqlite3_value_int64(pArg);\n        if( v>=0 && v<=240/6 ){\n          lsm1VblobAppendVarint(&val, v*6);\n        }else{\n          int n = lsm1PutSignedVarint64(pSpace, v);\n          lsm1VblobAppendVarint(&val, SQLITE_INTEGER + n*6);\n          lsm1VblobAppend(&val, pSpace, n);\n        }\n        break;\n      }\n      case SQLITE_FLOAT: {\n        double r = sqlite3_value_double(pArg);\n        lsm1VblobAppendVarint(&val, SQLITE_FLOAT + 8*6);\n        lsm1VblobAppend(&val, (u8*)&r, sizeof(r));\n        break;\n      }\n      case SQLITE_BLOB: {\n        int n = sqlite3_value_bytes(pArg);\n        lsm1VblobAppendVarint(&val, n*6 + SQLITE_BLOB);\n        lsm1VblobAppend(&val, sqlite3_value_blob(pArg), n);\n        break;\n      }\n      case SQLITE_TEXT: {\n        int n = sqlite3_value_bytes(pArg);\n        lsm1VblobAppendVarint(&val, n*6 + SQLITE_TEXT);\n        lsm1VblobAppend(&val, sqlite3_value_text(pArg), n);\n        break;\n      }\n    }\n  }\n  if( val.errNoMem ){\n    return SQLITE_NOMEM;\n  }\n  rc = lsm_insert(p->pDb, pKey, nKey, val.a, val.n);\n  sqlite3_free(val.a);\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}      \n\n/* Begin a transaction\n*/\nstatic int lsm1Begin(sqlite3_vtab *pVtab){\n  lsm1_vtab *p = (lsm1_vtab*)pVtab;\n  int rc = lsm_begin(p->pDb, 1);\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}\n\n/* Phase 1 of a transaction commit.\n*/\nstatic int lsm1Sync(sqlite3_vtab *pVtab){\n  return SQLITE_OK;\n}\n\n/* Commit a transaction\n*/\nstatic int lsm1Commit(sqlite3_vtab *pVtab){\n  lsm1_vtab *p = (lsm1_vtab*)pVtab;\n  int rc = lsm_commit(p->pDb, 0);\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}\n\n/* Rollback a transaction\n*/\nstatic int lsm1Rollback(sqlite3_vtab *pVtab){\n  lsm1_vtab *p = (lsm1_vtab*)pVtab;\n  int rc = lsm_rollback(p->pDb, 0);\n  return rc==LSM_OK ? SQLITE_OK : SQLITE_ERROR;\n}\n\n/*\n** This following structure defines all the methods for the \n** generate_lsm1 virtual table.\n*/\nstatic sqlite3_module lsm1Module = {\n  0,                       /* iVersion */\n  lsm1Connect,             /* xCreate */\n  lsm1Connect,             /* xConnect */\n  lsm1BestIndex,           /* xBestIndex */\n  lsm1Disconnect,          /* xDisconnect */\n  lsm1Disconnect,          /* xDestroy */\n  lsm1Open,                /* xOpen - open a cursor */\n  lsm1Close,               /* xClose - close a cursor */\n  lsm1Filter,              /* xFilter - configure scan constraints */\n  lsm1Next,                /* xNext - advance a cursor */\n  lsm1Eof,                 /* xEof - check for end of scan */\n  lsm1Column,              /* xColumn - read data */\n  lsm1Rowid,               /* xRowid - read data */\n  lsm1Update,              /* xUpdate */\n  lsm1Begin,               /* xBegin */\n  lsm1Sync,                /* xSync */\n  lsm1Commit,              /* xCommit */\n  lsm1Rollback,            /* xRollback */\n  0,                       /* xFindMethod */\n  0,                       /* xRename */\n};\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_lsm_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_create_module(db, \"lsm1\", &lsm1Module, 0);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/lsm_win32.c",
    "content": "/*\n** 2011-12-03\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Win32-specific run-time environment implementation for LSM.\n*/\n\n#ifdef _WIN32\n\n#include <assert.h>\n#include <string.h>\n\n#include <stdlib.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <ctype.h>\n\n#include \"windows.h\"\n\n#include \"lsmInt.h\"\n\n/*\n** An open file is an instance of the following object\n*/\ntypedef struct Win32File Win32File;\nstruct Win32File {\n  lsm_env *pEnv;                  /* The run-time environment */\n  const char *zName;              /* Full path to file */\n\n  HANDLE hFile;                   /* Open file handle */\n  HANDLE hShmFile;                /* File handle for *-shm file */\n\n  SYSTEM_INFO sysInfo;            /* Operating system information */\n  HANDLE hMap;                    /* File handle for mapping */\n  LPVOID pMap;                    /* Pointer to mapping of file fd */\n  size_t nMap;                    /* Size of mapping at pMap in bytes */\n  int nShm;                       /* Number of entries in ahShm[]/apShm[] */\n  LPHANDLE ahShm;                 /* Array of handles for shared mappings */\n  LPVOID *apShm;                  /* Array of 32K shared memory segments */\n};\n\nstatic char *win32ShmFile(Win32File *pWin32File){\n  char *zShm;\n  int nName = strlen(pWin32File->zName);\n  zShm = (char *)lsmMallocZero(pWin32File->pEnv, nName+4+1);\n  if( zShm ){\n    memcpy(zShm, pWin32File->zName, nName);\n    memcpy(&zShm[nName], \"-shm\", 5);\n  }\n  return zShm;\n}\n\nstatic int win32Sleep(int us){\n  Sleep((us + 999) / 1000);\n  return LSM_OK;\n}\n\n/*\n** The number of times that an I/O operation will be retried following a\n** locking error - probably caused by antivirus software.  Also the initial\n** delay before the first retry.  The delay increases linearly with each\n** retry.\n*/\n#ifndef LSM_WIN32_IOERR_RETRY\n# define LSM_WIN32_IOERR_RETRY 10\n#endif\n#ifndef LSM_WIN32_IOERR_RETRY_DELAY\n# define LSM_WIN32_IOERR_RETRY_DELAY 25000\n#endif\nstatic int win32IoerrRetry = LSM_WIN32_IOERR_RETRY;\nstatic int win32IoerrRetryDelay = LSM_WIN32_IOERR_RETRY_DELAY;\n\n/*\n** The \"win32IoerrCanRetry1\" macro is used to determine if a particular\n** I/O error code obtained via GetLastError() is eligible to be retried.\n** It must accept the error code DWORD as its only argument and should\n** return non-zero if the error code is transient in nature and the\n** operation responsible for generating the original error might succeed\n** upon being retried.  The argument to this macro should be a variable.\n**\n** Additionally, a macro named \"win32IoerrCanRetry2\" may be defined.  If\n** it is defined, it will be consulted only when the macro\n** \"win32IoerrCanRetry1\" returns zero.  The \"win32IoerrCanRetry2\" macro\n** is completely optional and may be used to include additional error\n** codes in the set that should result in the failing I/O operation being\n** retried by the caller.  If defined, the \"win32IoerrCanRetry2\" macro\n** must exhibit external semantics identical to those of the\n** \"win32IoerrCanRetry1\" macro.\n*/\n#if !defined(win32IoerrCanRetry1)\n#define win32IoerrCanRetry1(a) (((a)==ERROR_ACCESS_DENIED)        || \\\n                                ((a)==ERROR_SHARING_VIOLATION)    || \\\n                                ((a)==ERROR_LOCK_VIOLATION)       || \\\n                                ((a)==ERROR_DEV_NOT_EXIST)        || \\\n                                ((a)==ERROR_NETNAME_DELETED)      || \\\n                                ((a)==ERROR_SEM_TIMEOUT)          || \\\n                                ((a)==ERROR_NETWORK_UNREACHABLE))\n#endif\n\n/*\n** If an I/O error occurs, invoke this routine to see if it should be\n** retried.  Return TRUE to retry.  Return FALSE to give up with an\n** error.\n*/\nstatic int win32RetryIoerr(\n  lsm_env *pEnv,\n  int *pnRetry\n){\n  DWORD lastErrno;\n  if( *pnRetry>=win32IoerrRetry ){\n    return 0;\n  }\n  lastErrno = GetLastError();\n  if( win32IoerrCanRetry1(lastErrno) ){\n    win32Sleep(win32IoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#if defined(win32IoerrCanRetry2)\n  else if( win32IoerrCanRetry2(lastErrno) ){\n    win32Sleep(win32IoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#endif\n  return 0;\n}\n\n/*\n** Convert a UTF-8 string to Microsoft Unicode.\n**\n** Space to hold the returned string is obtained from lsmMalloc().\n*/\nstatic LPWSTR win32Utf8ToUnicode(lsm_env *pEnv, const char *zText){\n  int nChar;\n  LPWSTR zWideText;\n\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zText, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideText = lsmMallocZero(pEnv, nChar * sizeof(WCHAR));\n  if( zWideText==0 ){\n    return 0;\n  }\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText, nChar);\n  if( nChar==0 ){\n    lsmFree(pEnv, zWideText);\n    zWideText = 0;\n  }\n  return zWideText;\n}\n\n/*\n** Convert a Microsoft Unicode string to UTF-8.\n**\n** Space to hold the returned string is obtained from lsmMalloc().\n*/\nstatic char *win32UnicodeToUtf8(lsm_env *pEnv, LPCWSTR zWideText){\n  int nByte;\n  char *zText;\n\n  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = lsmMallocZero(pEnv, nByte);\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = WideCharToMultiByte(CP_UTF8, 0, zWideText, -1, zText, nByte, 0, 0);\n  if( nByte == 0 ){\n    lsmFree(pEnv, zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n#if !defined(win32IsNotFound)\n#define win32IsNotFound(a) (((a)==ERROR_FILE_NOT_FOUND)  || \\\n                            ((a)==ERROR_PATH_NOT_FOUND))\n#endif\n\nstatic int win32Open(\n  lsm_env *pEnv,\n  const char *zFile,\n  int flags,\n  LPHANDLE phFile\n){\n  int rc;\n  LPWSTR zConverted;\n\n  zConverted = win32Utf8ToUnicode(pEnv, zFile);\n  if( zConverted==0 ){\n    rc = LSM_NOMEM_BKPT;\n  }else{\n    int bReadonly = (flags & LSM_OPEN_READONLY);\n    DWORD dwDesiredAccess;\n    DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;\n    DWORD dwCreationDisposition;\n    DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;\n    HANDLE hFile;\n    int nRetry = 0;\n    if( bReadonly ){\n      dwDesiredAccess = GENERIC_READ;\n      dwCreationDisposition = OPEN_EXISTING;\n    }else{\n      dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;\n      dwCreationDisposition = OPEN_ALWAYS;\n    }\n    while( (hFile = CreateFileW((LPCWSTR)zConverted,\n                                dwDesiredAccess,\n                                dwShareMode, NULL,\n                                dwCreationDisposition,\n                                dwFlagsAndAttributes,\n                                NULL))==INVALID_HANDLE_VALUE &&\n                                win32RetryIoerr(pEnv, &nRetry) ){\n      /* Noop */\n    }\n    lsmFree(pEnv, zConverted);\n    if( hFile!=INVALID_HANDLE_VALUE ){\n      *phFile = hFile;\n      rc = LSM_OK;\n    }else{\n      if( win32IsNotFound(GetLastError()) ){\n        rc = lsmErrorBkpt(LSM_IOERR_NOENT);\n      }else{\n        rc = LSM_IOERR_BKPT;\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int lsmWin32OsOpen(\n  lsm_env *pEnv,\n  const char *zFile,\n  int flags,\n  lsm_file **ppFile\n){\n  int rc = LSM_OK;\n  Win32File *pWin32File;\n\n  pWin32File = lsmMallocZero(pEnv, sizeof(Win32File));\n  if( pWin32File==0 ){\n    rc = LSM_NOMEM_BKPT;\n  }else{\n    HANDLE hFile = NULL;\n\n    rc = win32Open(pEnv, zFile, flags, &hFile);\n    if( rc==LSM_OK ){\n      memset(&pWin32File->sysInfo, 0, sizeof(SYSTEM_INFO));\n      GetSystemInfo(&pWin32File->sysInfo);\n      pWin32File->pEnv = pEnv;\n      pWin32File->zName = zFile;\n      pWin32File->hFile = hFile;\n    }else{\n      lsmFree(pEnv, pWin32File);\n      pWin32File = 0;\n    }\n  }\n  *ppFile = (lsm_file *)pWin32File;\n  return rc;\n}\n\nstatic int lsmWin32OsWrite(\n  lsm_file *pFile, /* File to write to */\n  lsm_i64 iOff,    /* Offset to write to */\n  void *pData,     /* Write data from this buffer */\n  int nData        /* Bytes of data to write */\n){\n  Win32File *pWin32File = (Win32File *)pFile;\n  OVERLAPPED overlapped;  /* The offset for WriteFile. */\n  u8 *aRem = (u8 *)pData; /* Data yet to be written */\n  int nRem = nData;       /* Number of bytes yet to be written */\n  int nRetry = 0;         /* Number of retrys */\n\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(iOff & 0XFFFFFFFF);\n  overlapped.OffsetHigh = (LONG)((iOff>>32) & 0x7FFFFFFF);\n  while( nRem>0 ){\n    DWORD nWrite = 0; /* Bytes written using WriteFile */\n    if( !WriteFile(pWin32File->hFile, aRem, nRem, &nWrite, &overlapped) ){\n      if( win32RetryIoerr(pWin32File->pEnv, &nRetry) ) continue;\n      break;\n    }\n    assert( nWrite==0 || nWrite<=(DWORD)nRem );\n    if( nWrite==0 || nWrite>(DWORD)nRem ){\n      break;\n    }\n    iOff += nWrite;\n    overlapped.Offset = (LONG)(iOff & 0xFFFFFFFF);\n    overlapped.OffsetHigh = (LONG)((iOff>>32) & 0x7FFFFFFF);\n    aRem += nWrite;\n    nRem -= nWrite;\n  }\n  if( nRem!=0 ) return LSM_IOERR_BKPT;\n  return LSM_OK;\n}\n\nstatic int win32Truncate(\n  HANDLE hFile,\n  lsm_i64 nSize\n){\n  LARGE_INTEGER offset;\n  offset.QuadPart = nSize;\n  if( !SetFilePointerEx(hFile, offset, 0, FILE_BEGIN) ){\n    return LSM_IOERR_BKPT;\n  }\n  if (!SetEndOfFile(hFile) ){\n    return LSM_IOERR_BKPT;\n  }\n  return LSM_OK;\n}\n\nstatic int lsmWin32OsTruncate(\n  lsm_file *pFile, /* File to write to */\n  lsm_i64 nSize    /* Size to truncate file to */\n){\n  Win32File *pWin32File = (Win32File *)pFile;\n  return win32Truncate(pWin32File->hFile, nSize);\n}\n\nstatic int lsmWin32OsRead(\n  lsm_file *pFile, /* File to read from */\n  lsm_i64 iOff,    /* Offset to read from */\n  void *pData,     /* Read data into this buffer */\n  int nData        /* Bytes of data to read */\n){\n  Win32File *pWin32File = (Win32File *)pFile;\n  OVERLAPPED overlapped; /* The offset for ReadFile */\n  DWORD nRead = 0;       /* Bytes read using ReadFile */\n  int nRetry = 0;        /* Number of retrys */\n\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(iOff & 0XFFFFFFFF);\n  overlapped.OffsetHigh = (LONG)((iOff>>32) & 0X7FFFFFFF);\n  while( !ReadFile(pWin32File->hFile, pData, nData, &nRead, &overlapped) &&\n         GetLastError()!=ERROR_HANDLE_EOF ){\n    if( win32RetryIoerr(pWin32File->pEnv, &nRetry) ) continue;\n    return LSM_IOERR_BKPT;\n  }\n  if( nRead<(DWORD)nData ){\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pData)[nRead], 0, nData - nRead);\n  }\n  return LSM_OK;\n}\n\nstatic int lsmWin32OsSync(lsm_file *pFile){\n  int rc = LSM_OK;\n\n#ifndef LSM_NO_SYNC\n  Win32File *pWin32File = (Win32File *)pFile;\n\n  if( pWin32File->pMap!=NULL ){\n    if( !FlushViewOfFile(pWin32File->pMap, 0) ){\n      rc = LSM_IOERR_BKPT;\n    }\n  }\n  if( rc==LSM_OK && !FlushFileBuffers(pWin32File->hFile) ){\n    rc = LSM_IOERR_BKPT;\n  }\n#else\n  unused_parameter(pFile);\n#endif\n\n  return rc;\n}\n\nstatic int lsmWin32OsSectorSize(lsm_file *pFile){\n  return 512;\n}\n\nstatic void win32Unmap(Win32File *pWin32File){\n  if( pWin32File->pMap!=NULL ){\n    UnmapViewOfFile(pWin32File->pMap);\n    pWin32File->pMap = NULL;\n    pWin32File->nMap = 0;\n  }\n  if( pWin32File->hMap!=NULL ){\n    CloseHandle(pWin32File->hMap);\n    pWin32File->hMap = NULL;\n  }\n}\n\nstatic int lsmWin32OsRemap(\n  lsm_file *pFile,\n  lsm_i64 iMin,\n  void **ppOut,\n  lsm_i64 *pnOut\n){\n  Win32File *pWin32File = (Win32File *)pFile;\n\n  /* If the file is between 0 and 2MB in size, extend it in chunks of 256K.\n  ** Thereafter, in chunks of 1MB at a time.  */\n  const int aIncrSz[] = {256*1024, 1024*1024};\n  int nIncrSz = aIncrSz[iMin>(2*1024*1024)];\n\n  *ppOut = NULL;\n  *pnOut = 0;\n\n  win32Unmap(pWin32File);\n  if( iMin>=0 ){\n    LARGE_INTEGER fileSize;\n    DWORD dwSizeHigh;\n    DWORD dwSizeLow;\n    HANDLE hMap;\n    LPVOID pMap;\n    memset(&fileSize, 0, sizeof(LARGE_INTEGER));\n    if( !GetFileSizeEx(pWin32File->hFile, &fileSize) ){\n      return LSM_IOERR_BKPT;\n    }\n    assert( fileSize.QuadPart>=0 );\n    if( fileSize.QuadPart<iMin ){\n      int rc;\n      fileSize.QuadPart = ((iMin + nIncrSz-1) / nIncrSz) * nIncrSz;\n      rc = lsmWin32OsTruncate(pFile, fileSize.QuadPart);\n      if( rc!=LSM_OK ){\n        return rc;\n      }\n    }\n    dwSizeLow = (DWORD)(fileSize.QuadPart & 0xFFFFFFFF);\n    dwSizeHigh = (DWORD)((fileSize.QuadPart & 0x7FFFFFFFFFFFFFFF) >> 32);\n    hMap = CreateFileMappingW(pWin32File->hFile, NULL, PAGE_READWRITE,\n                              dwSizeHigh, dwSizeLow, NULL);\n    if( hMap==NULL ){\n      return LSM_IOERR_BKPT;\n    }\n    pWin32File->hMap = hMap;\n    assert( fileSize.QuadPart<=0xFFFFFFFF );\n    pMap = MapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0,\n                         (SIZE_T)fileSize.QuadPart);\n    if( pMap==NULL ){\n      return LSM_IOERR_BKPT;\n    }\n    pWin32File->pMap = pMap;\n    pWin32File->nMap = (SIZE_T)fileSize.QuadPart;\n  }\n  *ppOut = pWin32File->pMap;\n  *pnOut = pWin32File->nMap;\n  return LSM_OK;\n}\n\nstatic BOOL win32IsDriveLetterAndColon(\n  const char *zPathname\n){\n  return ( isalpha(zPathname[0]) && zPathname[1]==':' );\n}\n\nstatic int lsmWin32OsFullpath(\n  lsm_env *pEnv,\n  const char *zName,\n  char *zOut,\n  int *pnOut\n){\n  DWORD nByte;\n  void *zConverted;\n  LPWSTR zTempWide;\n  char *zTempUtf8;\n\n  if( zName[0]=='/' && win32IsDriveLetterAndColon(zName+1) ){\n    zName++;\n  }\n  zConverted = win32Utf8ToUnicode(pEnv, zName);\n  if( zConverted==0 ){\n    return LSM_NOMEM_BKPT;\n  }\n  nByte = GetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);\n  if( nByte==0 ){\n    lsmFree(pEnv, zConverted);\n    return LSM_IOERR_BKPT;\n  }\n  nByte += 3;\n  zTempWide = lsmMallocZero(pEnv, nByte * sizeof(zTempWide[0]));\n  if( zTempWide==0 ){\n    lsmFree(pEnv, zConverted);\n    return LSM_NOMEM_BKPT;\n  }\n  nByte = GetFullPathNameW((LPCWSTR)zConverted, nByte, zTempWide, 0);\n  if( nByte==0 ){\n    lsmFree(pEnv, zConverted);\n    lsmFree(pEnv, zTempWide);\n    return LSM_IOERR_BKPT;\n  }\n  lsmFree(pEnv, zConverted);\n  zTempUtf8 = win32UnicodeToUtf8(pEnv, zTempWide);\n  lsmFree(pEnv, zTempWide);\n  if( zTempUtf8 ){\n    int nOut = *pnOut;\n    int nLen = strlen(zTempUtf8) + 1;\n    if( nLen<=nOut ){\n      snprintf(zOut, nOut, \"%s\", zTempUtf8);\n    }\n    lsmFree(pEnv, zTempUtf8);\n    *pnOut = nLen;\n    return LSM_OK;\n  }else{\n    return LSM_NOMEM_BKPT;\n  }\n}\n\nstatic int lsmWin32OsFileid(\n  lsm_file *pFile,\n  void *pBuf,\n  int *pnBuf\n){\n  int nBuf;\n  int nReq;\n  u8 *pBuf2 = (u8 *)pBuf;\n  Win32File *pWin32File = (Win32File *)pFile;\n  BY_HANDLE_FILE_INFORMATION fileInfo;\n\n  nBuf = *pnBuf;\n  nReq = (sizeof(fileInfo.dwVolumeSerialNumber) +\n          sizeof(fileInfo.nFileIndexHigh) +\n          sizeof(fileInfo.nFileIndexLow));\n  *pnBuf = nReq;\n  if( nReq>nBuf ) return LSM_OK;\n  memset(&fileInfo, 0, sizeof(BY_HANDLE_FILE_INFORMATION));\n  if( !GetFileInformationByHandle(pWin32File->hFile, &fileInfo) ){\n    return LSM_IOERR_BKPT;\n  }\n  nReq = sizeof(fileInfo.dwVolumeSerialNumber);\n  memcpy(pBuf2, &fileInfo.dwVolumeSerialNumber, nReq);\n  pBuf2 += nReq;\n  nReq = sizeof(fileInfo.nFileIndexHigh);\n  memcpy(pBuf, &fileInfo.nFileIndexHigh, nReq);\n  pBuf2 += nReq;\n  nReq = sizeof(fileInfo.nFileIndexLow);\n  memcpy(pBuf2, &fileInfo.nFileIndexLow, nReq);\n  return LSM_OK;\n}\n\nstatic int win32Delete(\n  lsm_env *pEnv,\n  const char *zFile\n){\n  int rc;\n  LPWSTR zConverted;\n\n  zConverted = win32Utf8ToUnicode(pEnv, zFile);\n  if( zConverted==0 ){\n    rc = LSM_NOMEM_BKPT;\n  }else{\n    int nRetry = 0;\n    DWORD attr;\n\n    do {\n      attr = GetFileAttributesW(zConverted);\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        rc = LSM_IOERR_BKPT;\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = LSM_IOERR_BKPT; /* Files only. */\n        break;\n      }\n      if ( DeleteFileW(zConverted) ){\n        rc = LSM_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !win32RetryIoerr(pEnv, &nRetry) ){\n        rc = LSM_IOERR_BKPT; /* No more retries. */\n        break;\n      }\n    }while( 1 );\n  }\n  lsmFree(pEnv, zConverted);\n  return rc;\n}\n\nstatic int lsmWin32OsUnlink(lsm_env *pEnv, const char *zFile){\n  return win32Delete(pEnv, zFile);\n}\n\n#if !defined(win32IsLockBusy)\n#define win32IsLockBusy(a) (((a)==ERROR_LOCK_VIOLATION) || \\\n                            ((a)==ERROR_IO_PENDING))\n#endif\n\nstatic int win32LockFile(\n  Win32File *pWin32File,\n  int iLock,\n  int nLock,\n  int eType\n){\n  OVERLAPPED ovlp;\n\n  assert( LSM_LOCK_UNLOCK==0 );\n  assert( LSM_LOCK_SHARED==1 );\n  assert( LSM_LOCK_EXCL==2 );\n  assert( eType>=LSM_LOCK_UNLOCK && eType<=LSM_LOCK_EXCL );\n  assert( nLock>=0 );\n  assert( iLock>0 && iLock<=32 );\n\n  memset(&ovlp, 0, sizeof(OVERLAPPED));\n  ovlp.Offset = (4096-iLock-nLock+1);\n  if( eType>LSM_LOCK_UNLOCK ){\n    DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;\n    if( eType>=LSM_LOCK_EXCL ) flags |= LOCKFILE_EXCLUSIVE_LOCK;\n    if( !LockFileEx(pWin32File->hFile, flags, 0, (DWORD)nLock, 0, &ovlp) ){\n      if( win32IsLockBusy(GetLastError()) ){\n        return LSM_BUSY;\n      }else{\n        return LSM_IOERR_BKPT;\n      }\n    }\n  }else{\n    if( !UnlockFileEx(pWin32File->hFile, 0, (DWORD)nLock, 0, &ovlp) ){\n      return LSM_IOERR_BKPT;\n    }\n  }\n  return LSM_OK;\n}\n\nstatic int lsmWin32OsLock(lsm_file *pFile, int iLock, int eType){\n  Win32File *pWin32File = (Win32File *)pFile;\n  return win32LockFile(pWin32File, iLock, 1, eType);\n}\n\nstatic int lsmWin32OsTestLock(lsm_file *pFile, int iLock, int nLock, int eType){\n  int rc;\n  Win32File *pWin32File = (Win32File *)pFile;\n  rc = win32LockFile(pWin32File, iLock, nLock, eType);\n  if( rc!=LSM_OK ) return rc;\n  win32LockFile(pWin32File, iLock, nLock, LSM_LOCK_UNLOCK);\n  return LSM_OK;\n}\n\nstatic int lsmWin32OsShmMap(lsm_file *pFile, int iChunk, int sz, void **ppShm){\n  int rc;\n  Win32File *pWin32File = (Win32File *)pFile;\n  int iOffset = iChunk * sz;\n  int iOffsetShift = iOffset % pWin32File->sysInfo.dwAllocationGranularity;\n  int nNew = iChunk + 1;\n  lsm_i64 nReq = nNew * sz;\n\n  *ppShm = NULL;\n  assert( sz>=0 );\n  assert( sz==LSM_SHM_CHUNK_SIZE );\n  if( iChunk>=pWin32File->nShm ){\n    LPHANDLE ahNew;\n    LPVOID *apNew;\n    LARGE_INTEGER fileSize;\n\n    /* If the shared-memory file has not been opened, open it now. */\n    if( pWin32File->hShmFile==NULL ){\n      char *zShm = win32ShmFile(pWin32File);\n      if( !zShm ) return LSM_NOMEM_BKPT;\n      rc = win32Open(pWin32File->pEnv, zShm, 0, &pWin32File->hShmFile);\n      lsmFree(pWin32File->pEnv, zShm);\n      if( rc!=LSM_OK ){\n        return rc;\n      }\n    }\n\n    /* If the shared-memory file is not large enough to contain the\n    ** requested chunk, cause it to grow.  */\n    memset(&fileSize, 0, sizeof(LARGE_INTEGER));\n    if( !GetFileSizeEx(pWin32File->hShmFile, &fileSize) ){\n      return LSM_IOERR_BKPT;\n    }\n    assert( fileSize.QuadPart>=0 );\n    if( fileSize.QuadPart<nReq ){\n      rc = win32Truncate(pWin32File->hShmFile, nReq);\n      if( rc!=LSM_OK ){\n        return rc;\n      }\n    }\n\n    ahNew = (LPHANDLE)lsmMallocZero(pWin32File->pEnv, sizeof(HANDLE) * nNew);\n    if( !ahNew ) return LSM_NOMEM_BKPT;\n    apNew = (LPVOID *)lsmMallocZero(pWin32File->pEnv, sizeof(LPVOID) * nNew);\n    if( !apNew ){\n      lsmFree(pWin32File->pEnv, ahNew);\n      return LSM_NOMEM_BKPT;\n    }\n    memcpy(ahNew, pWin32File->ahShm, sizeof(HANDLE) * pWin32File->nShm);\n    memcpy(apNew, pWin32File->apShm, sizeof(LPVOID) * pWin32File->nShm);\n    lsmFree(pWin32File->pEnv, pWin32File->ahShm);\n    pWin32File->ahShm = ahNew;\n    lsmFree(pWin32File->pEnv, pWin32File->apShm);\n    pWin32File->apShm = apNew;\n    pWin32File->nShm = nNew;\n  }\n\n  if( pWin32File->ahShm[iChunk]==NULL ){\n    HANDLE hMap;\n    assert( nReq<=0xFFFFFFFF );\n    hMap = CreateFileMappingW(pWin32File->hShmFile, NULL, PAGE_READWRITE, 0,\n                              (DWORD)nReq, NULL);\n    if( hMap==NULL ){\n      return LSM_IOERR_BKPT;\n    }\n    pWin32File->ahShm[iChunk] = hMap;\n  }\n  if( pWin32File->apShm[iChunk]==NULL ){\n    LPVOID pMap;\n    pMap = MapViewOfFile(pWin32File->ahShm[iChunk],\n                         FILE_MAP_WRITE | FILE_MAP_READ, 0,\n                         iOffset - iOffsetShift, sz + iOffsetShift);\n    if( pMap==NULL ){\n      return LSM_IOERR_BKPT;\n    }\n    pWin32File->apShm[iChunk] = pMap;\n  }\n  if( iOffsetShift!=0 ){\n    char *p = (char *)pWin32File->apShm[iChunk];\n    *ppShm = (void *)&p[iOffsetShift];\n  }else{\n    *ppShm = pWin32File->apShm[iChunk];\n  }\n  return LSM_OK;\n}\n\nstatic void lsmWin32OsShmBarrier(void){\n  MemoryBarrier();\n}\n\nstatic int lsmWin32OsShmUnmap(lsm_file *pFile, int bDelete){\n  Win32File *pWin32File = (Win32File *)pFile;\n\n  if( pWin32File->hShmFile!=NULL ){\n    int i;\n    for(i=0; i<pWin32File->nShm; i++){\n      if( pWin32File->apShm[i]!=NULL ){\n        UnmapViewOfFile(pWin32File->apShm[i]);\n        pWin32File->apShm[i] = NULL;\n      }\n      if( pWin32File->ahShm[i]!=NULL ){\n        CloseHandle(pWin32File->ahShm[i]);\n        pWin32File->ahShm[i] = NULL;\n      }\n    }\n    CloseHandle(pWin32File->hShmFile);\n    pWin32File->hShmFile = NULL;\n    if( bDelete ){\n      char *zShm = win32ShmFile(pWin32File);\n      if( zShm ){ win32Delete(pWin32File->pEnv, zShm); }\n      lsmFree(pWin32File->pEnv, zShm);\n    }\n  }\n  return LSM_OK;\n}\n\n#define MX_CLOSE_ATTEMPT 3\nstatic int lsmWin32OsClose(lsm_file *pFile){\n  int rc;\n  int nRetry = 0;\n  Win32File *pWin32File = (Win32File *)pFile;\n  lsmWin32OsShmUnmap(pFile, 0);\n  win32Unmap(pWin32File);\n  do{\n    if( pWin32File->hFile==NULL ){\n      rc = LSM_IOERR_BKPT;\n      break;\n    }\n    rc = CloseHandle(pWin32File->hFile);\n    if( rc ){\n      pWin32File->hFile = NULL;\n      rc = LSM_OK;\n      break;\n    }\n    if( ++nRetry>=MX_CLOSE_ATTEMPT ){\n      rc = LSM_IOERR_BKPT;\n      break;\n    }\n  }while( 1 );\n  lsmFree(pWin32File->pEnv, pWin32File->ahShm);\n  lsmFree(pWin32File->pEnv, pWin32File->apShm);\n  lsmFree(pWin32File->pEnv, pWin32File);\n  return rc;\n}\n\nstatic int lsmWin32OsSleep(lsm_env *pEnv, int us){\n  unused_parameter(pEnv);\n  return win32Sleep(us);\n}\n\n/****************************************************************************\n** Memory allocation routines.\n*/\n\nstatic void *lsmWin32OsMalloc(lsm_env *pEnv, size_t N){\n  assert( HeapValidate(GetProcessHeap(), 0, NULL) );\n  return HeapAlloc(GetProcessHeap(), 0, (SIZE_T)N);\n}\n\nstatic void lsmWin32OsFree(lsm_env *pEnv, void *p){\n  assert( HeapValidate(GetProcessHeap(), 0, NULL) );\n  if( p ){\n    HeapFree(GetProcessHeap(), 0, p);\n  }\n}\n\nstatic void *lsmWin32OsRealloc(lsm_env *pEnv, void *p, size_t N){\n  unsigned char *m = (unsigned char *)p;\n  assert( HeapValidate(GetProcessHeap(), 0, NULL) );\n  if( 1>N ){\n    lsmWin32OsFree(pEnv, p);\n    return NULL;\n  }else if( NULL==p ){\n    return lsmWin32OsMalloc(pEnv, N);\n  }else{\n#if 0 /* arguable: don't shrink */\n    SIZE_T sz = HeapSize(GetProcessHeap(), 0, m);\n    if( sz>=(SIZE_T)N ){\n      return p;\n    }\n#endif\n    return HeapReAlloc(GetProcessHeap(), 0, m, N);\n  }\n}\n\nstatic size_t lsmWin32OsMSize(lsm_env *pEnv, void *p){\n  assert( HeapValidate(GetProcessHeap(), 0, NULL) );\n  return (size_t)HeapSize(GetProcessHeap(), 0, p);\n}\n\n\n#ifdef LSM_MUTEX_WIN32\n/*************************************************************************\n** Mutex methods for Win32 based systems.  If LSM_MUTEX_WIN32 is\n** missing then a no-op implementation of mutexes found below will be\n** used instead.\n*/\n#include \"windows.h\"\n\ntypedef struct Win32Mutex Win32Mutex;\nstruct Win32Mutex {\n  lsm_env *pEnv;\n  CRITICAL_SECTION mutex;\n#ifdef LSM_DEBUG\n  DWORD owner;\n#endif\n};\n\n#ifndef WIN32_MUTEX_INITIALIZER\n# define WIN32_MUTEX_INITIALIZER { 0 }\n#endif\n\n#ifdef LSM_DEBUG\n# define LSM_WIN32_STATIC_MUTEX { 0, WIN32_MUTEX_INITIALIZER, 0 }\n#else\n# define LSM_WIN32_STATIC_MUTEX { 0, WIN32_MUTEX_INITIALIZER }\n#endif\n\nstatic int lsmWin32OsMutexStatic(\n  lsm_env *pEnv,\n  int iMutex,\n  lsm_mutex **ppStatic\n){\n  static volatile LONG initialized = 0;\n  static Win32Mutex sMutex[2] = {\n    LSM_WIN32_STATIC_MUTEX,\n    LSM_WIN32_STATIC_MUTEX\n  };\n\n  assert( iMutex==LSM_MUTEX_GLOBAL || iMutex==LSM_MUTEX_HEAP );\n  assert( LSM_MUTEX_GLOBAL==1 && LSM_MUTEX_HEAP==2 );\n\n  if( InterlockedCompareExchange(&initialized, 1, 0)==0 ){\n    int i;\n    for(i=0; i<array_size(sMutex); i++){\n      InitializeCriticalSection(&sMutex[i].mutex);\n    }\n  }\n  *ppStatic = (lsm_mutex *)&sMutex[iMutex-1];\n  return LSM_OK;\n}\n\nstatic int lsmWin32OsMutexNew(lsm_env *pEnv, lsm_mutex **ppNew){\n  Win32Mutex *pMutex;           /* Pointer to new mutex */\n\n  pMutex = (Win32Mutex *)lsmMallocZero(pEnv, sizeof(Win32Mutex));\n  if( !pMutex ) return LSM_NOMEM_BKPT;\n\n  pMutex->pEnv = pEnv;\n  InitializeCriticalSection(&pMutex->mutex);\n\n  *ppNew = (lsm_mutex *)pMutex;\n  return LSM_OK;\n}\n\nstatic void lsmWin32OsMutexDel(lsm_mutex *p){\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n  DeleteCriticalSection(&pMutex->mutex);\n  lsmFree(pMutex->pEnv, pMutex);\n}\n\nstatic void lsmWin32OsMutexEnter(lsm_mutex *p){\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n  EnterCriticalSection(&pMutex->mutex);\n\n#ifdef LSM_DEBUG\n  assert( pMutex->owner!=GetCurrentThreadId() );\n  pMutex->owner = GetCurrentThreadId();\n  assert( pMutex->owner==GetCurrentThreadId() );\n#endif\n}\n\nstatic int lsmWin32OsMutexTry(lsm_mutex *p){\n  BOOL bRet;\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n  bRet = TryEnterCriticalSection(&pMutex->mutex);\n#ifdef LSM_DEBUG\n  if( bRet ){\n    assert( pMutex->owner!=GetCurrentThreadId() );\n    pMutex->owner = GetCurrentThreadId();\n    assert( pMutex->owner==GetCurrentThreadId() );\n  }\n#endif\n  return !bRet;\n}\n\nstatic void lsmWin32OsMutexLeave(lsm_mutex *p){\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n#ifdef LSM_DEBUG\n  assert( pMutex->owner==GetCurrentThreadId() );\n  pMutex->owner = 0;\n  assert( pMutex->owner!=GetCurrentThreadId() );\n#endif\n  LeaveCriticalSection(&pMutex->mutex);\n}\n\n#ifdef LSM_DEBUG\nstatic int lsmWin32OsMutexHeld(lsm_mutex *p){\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n  return pMutex ? pMutex->owner==GetCurrentThreadId() : 1;\n}\nstatic int lsmWin32OsMutexNotHeld(lsm_mutex *p){\n  Win32Mutex *pMutex = (Win32Mutex *)p;\n  return pMutex ? pMutex->owner!=GetCurrentThreadId() : 1;\n}\n#endif\n/*\n** End of Win32 mutex implementation.\n*************************************************************************/\n#else\n/*************************************************************************\n** Noop mutex implementation\n*/\ntypedef struct NoopMutex NoopMutex;\nstruct NoopMutex {\n  lsm_env *pEnv;                  /* Environment handle (for xFree()) */\n  int bHeld;                      /* True if mutex is held */\n  int bStatic;                    /* True for a static mutex */\n};\nstatic NoopMutex aStaticNoopMutex[2] = {\n  {0, 0, 1},\n  {0, 0, 1},\n};\n\nstatic int lsmWin32OsMutexStatic(\n  lsm_env *pEnv,\n  int iMutex,\n  lsm_mutex **ppStatic\n){\n  assert( iMutex>=1 && iMutex<=(int)array_size(aStaticNoopMutex) );\n  *ppStatic = (lsm_mutex *)&aStaticNoopMutex[iMutex-1];\n  return LSM_OK;\n}\nstatic int lsmWin32OsMutexNew(lsm_env *pEnv, lsm_mutex **ppNew){\n  NoopMutex *p;\n  p = (NoopMutex *)lsmMallocZero(pEnv, sizeof(NoopMutex));\n  if( p ) p->pEnv = pEnv;\n  *ppNew = (lsm_mutex *)p;\n  return (p ? LSM_OK : LSM_NOMEM_BKPT);\n}\nstatic void lsmWin32OsMutexDel(lsm_mutex *pMutex)  {\n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bStatic==0 && p->pEnv );\n  lsmFree(p->pEnv, p);\n}\nstatic void lsmWin32OsMutexEnter(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==0 );\n  p->bHeld = 1;\n}\nstatic int lsmWin32OsMutexTry(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==0 );\n  p->bHeld = 1;\n  return 0;\n}\nstatic void lsmWin32OsMutexLeave(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  assert( p->bHeld==1 );\n  p->bHeld = 0;\n}\n#ifdef LSM_DEBUG\nstatic int lsmWin32OsMutexHeld(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  return p ? p->bHeld : 1;\n}\nstatic int lsmWin32OsMutexNotHeld(lsm_mutex *pMutex){\n  NoopMutex *p = (NoopMutex *)pMutex;\n  return p ? !p->bHeld : 1;\n}\n#endif\n/***************************************************************************/\n#endif /* else LSM_MUTEX_NONE */\n\n/* Without LSM_DEBUG, the MutexHeld tests are never called */\n#ifndef LSM_DEBUG\n# define lsmWin32OsMutexHeld    0\n# define lsmWin32OsMutexNotHeld 0\n#endif\n\nlsm_env *lsm_default_env(void){\n  static lsm_env win32_env = {\n    sizeof(lsm_env),         /* nByte */\n    1,                       /* iVersion */\n    /***** file i/o ******************/\n    0,                       /* pVfsCtx */\n    lsmWin32OsFullpath,      /* xFullpath */\n    lsmWin32OsOpen,          /* xOpen */\n    lsmWin32OsRead,          /* xRead */\n    lsmWin32OsWrite,         /* xWrite */\n    lsmWin32OsTruncate,      /* xTruncate */\n    lsmWin32OsSync,          /* xSync */\n    lsmWin32OsSectorSize,    /* xSectorSize */\n    lsmWin32OsRemap,         /* xRemap */\n    lsmWin32OsFileid,        /* xFileid */\n    lsmWin32OsClose,         /* xClose */\n    lsmWin32OsUnlink,        /* xUnlink */\n    lsmWin32OsLock,          /* xLock */\n    lsmWin32OsTestLock,      /* xTestLock */\n    lsmWin32OsShmMap,        /* xShmMap */\n    lsmWin32OsShmBarrier,    /* xShmBarrier */\n    lsmWin32OsShmUnmap,      /* xShmUnmap */\n    /***** memory allocation *********/\n    0,                       /* pMemCtx */\n    lsmWin32OsMalloc,        /* xMalloc */\n    lsmWin32OsRealloc,       /* xRealloc */\n    lsmWin32OsFree,          /* xFree */\n    lsmWin32OsMSize,         /* xSize */\n    /***** mutexes *********************/\n    0,                       /* pMutexCtx */\n    lsmWin32OsMutexStatic,   /* xMutexStatic */\n    lsmWin32OsMutexNew,      /* xMutexNew */\n    lsmWin32OsMutexDel,      /* xMutexDel */\n    lsmWin32OsMutexEnter,    /* xMutexEnter */\n    lsmWin32OsMutexTry,      /* xMutexTry */\n    lsmWin32OsMutexLeave,    /* xMutexLeave */\n    lsmWin32OsMutexHeld,     /* xMutexHeld */\n    lsmWin32OsMutexNotHeld,  /* xMutexNotHeld */\n    /***** other *********************/\n    lsmWin32OsSleep,         /* xSleep */\n  };\n  return &win32_env;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/test/lsm1_common.tcl",
    "content": "# 2014 Dec 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. .. test]\n}\nsource $testdir/tester.tcl\n\n# Check if the lsm1 extension has been compiled.\nif {$::tcl_platform(platform) == \"windows\"} {\n  set lsm1 lsm.dll\n} else {\n  set lsm1 lsm.so\n}\n\nif {[file exists [file join .. $lsm1]]} {\n  proc return_if_no_lsm1 {} {}\n} else {\n  proc return_if_no_lsm1 {} {\n    finish_test\n    return -code return\n  }\n  return\n}\n\nproc load_lsm1_vtab {db} {\n  db enable_load_extension 1\n  db eval {SELECT load_extension('../lsm')}\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/lsm1/test/lsm1_simple.test",
    "content": "# 2017 July 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the lsm1 virtual table module.\n#\n\nsource [file join [file dirname [info script]] lsm1_common.tcl]\nset testprefix lsm1_simple\nreturn_if_no_lsm1\nload_lsm1_vtab db\n\nforcedelete testlsm.db\n\ndo_execsql_test 100 {\n  CREATE VIRTUAL TABLE x1 USING lsm1(testlsm.db,a,UINT,b,c,d);\n  PRAGMA table_info(x1);\n} {\n  0 a UINT 1 {} 1 \n  1 b {} 0 {} 0 \n  2 c {} 0 {} 0 \n  3 d {} 0 {} 0\n}\n\ndo_execsql_test 110 {\n  INSERT INTO x1(a,b,c,d) VALUES(15, 11, 22, 33),(8,'banjo',x'333231',NULL),\n      (12,NULL,3.25,-559281390);\n  SELECT a, quote(b), quote(c), quote(d) FROM x1;\n} {8 'banjo' X'333231' NULL 12 NULL 3.25 -559281390 15 11 22 33}\ndo_execsql_test 111 {\n  SELECT a, quote(lsm1_key), quote(lsm1_value) FROM x1;\n} {8 X'08' X'2162616E6A6F1633323105' 12 X'0C' X'05320000000000000A401FFB42ABE9DB' 15 X'0F' X'4284C6'}\n\ndo_execsql_test 120 {\n  UPDATE x1 SET d = d+1.0 WHERE a=15;\n  SELECT a, quote(b), quote(c), quote(d) FROM x1;\n} {8 'banjo' X'333231' NULL 12 NULL 3.25 -559281390 15 11 22 34.0}\n\ndo_execsql_test 130 {\n  UPDATE x1 SET a=123456789 WHERE a=12;\n  SELECT a, quote(b), quote(c), quote(d) FROM x1;\n} {8 'banjo' X'333231' NULL 15 11 22 34.0 123456789 NULL 3.25 -559281390}\ndo_execsql_test 131 {\n  SELECT quote(lsm1_key), printf('0x%x',a) FROM x1 WHERE a > 100000000;\n} {X'FB075BCD15' 0x75bcd15}\n\ndo_execsql_test 140 {\n  DELETE FROM x1 WHERE a=15;\n  SELECT a, quote(b), quote(c), quote(d) FROM x1;\n} {8 'banjo' X'333231' NULL 123456789 NULL 3.25 -559281390}\n\ndo_test 150 {\n  lsort [glob testlsm.db*]\n} {testlsm.db testlsm.db-log testlsm.db-shm}\n\ndb close\ndo_test 160 {\n  lsort [glob testlsm.db*]\n} {testlsm.db}\n\nforcedelete testlsm.db\nforcedelete test.db\nsqlite3 db test.db\nload_lsm1_vtab db\n\n\ndo_execsql_test 200 {\n  CREATE VIRTUAL TABLE x1 USING lsm1(testlsm.db,a,TEXT,b,c,d);\n  PRAGMA table_info(x1);\n} {\n  0 a TEXT 1 {} 1 \n  1 b {} 0 {} 0 \n  2 c {} 0 {} 0 \n  3 d {} 0 {} 0\n}\ndo_execsql_test 210 {\n  INSERT INTO x1(a,b,c,d) VALUES(15, 11, 22, 33),(8,'banjo',x'333231',NULL),\n      (12,NULL,3.25,-559281390);\n  SELECT quote(a), quote(b), quote(c), quote(d), '|' FROM x1;\n} {'12' NULL 3.25 -559281390 | '15' 11 22 33 | '8' 'banjo' X'333231' NULL |}\ndo_execsql_test 211 {\n  SELECT quote(a), quote(lsm1_key), quote(lsm1_value), '|' FROM x1;\n} {'12' X'3132' X'05320000000000000A401FFB42ABE9DB' | '15' X'3135' X'4284C6' | '8' X'38' X'2162616E6A6F1633323105' |}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/README.md",
    "content": "## Miscellaneous Extensions\n\nThis folder contains a collection of smaller loadable extensions.\nSee <https://www.sqlite.org/loadext.html> for instructions on how\nto compile and use loadable extensions.\nEach extension in this folder is implemented in a single file of C code.\n\nEach source file contains a description in its header comment.  See the\nheader comments for details about each extension.  Additional notes are\nas follows:\n\n  *  **carray.c** &mdash;  This module implements the\n     [carray](https://www.sqlite.org/carray.html) table-valued function.\n     It is a good example of how to go about implementing a custom\n     [table-valued function](https://www.sqlite.org/vtab.html#tabfunc2).\n\n  *  **dbdump.c** &mdash;  This is not actually a loadable extension, but\n     rather a library that implements an approximate equivalent to the\n     \".dump\" command of the\n     [command-line shell](https://www.sqlite.org/cli.html).\n\n  *  **memvfs.c** &mdash;  This file implements a custom\n     [VFS](https://www.sqlite.org/vfs.html) that stores an entire database\n     file in a single block of RAM.  It serves as a good example of how\n     to implement a simple custom VFS.\n\n  *  **rot13.c** &mdash;  This file implements the very simple rot13()\n     substitution function.  This file makes a good template for implementing\n     new custom SQL functions for SQLite.\n\n  *  **series.c** &mdash;  This is an implementation of the\n     \"generate_series\" [virtual table](https://www.sqlite.org/vtab.html).\n     It can make a good template for new custom virtual table implementations.\n\n  *  **shathree.c** &mdash;  An implementation of the sha3() and\n     sha3_query() SQL functions.  The file is named \"shathree.c\" instead\n     of \"sha3.c\" because the default entry point names in SQLite are based\n     on the source filename with digits removed, so if we used the name\n     \"sha3.c\" then the entry point would conflict with the prior \"sha1.c\"\n     extension.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/amatch.c",
    "content": "/*\n** 2013-03-14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code for a demonstration virtual table that finds\n** \"approximate matches\" - strings from a finite set that are nearly the\n** same as a single input string.  The virtual table is called \"amatch\".\n**\n** A amatch virtual table is created like this:\n**\n**     CREATE VIRTUAL TABLE f USING approximate_match(\n**        vocabulary_table=<tablename>,      -- V\n**        vocabulary_word=<columnname>,      -- W\n**        vocabulary_language=<columnname>,  -- L\n**        edit_distances=<edit-cost-table>\n**     );\n**\n** When it is created, the new amatch table must be supplied with the\n** the name of a table V and columns V.W and V.L such that \n**\n**     SELECT W FROM V WHERE L=$language\n**\n** returns the allowed vocabulary for the match.  If the \"vocabulary_language\"\n** or L columnname is left unspecified or is an empty string, then no\n** filtering of the vocabulary by language is performed. \n**\n** For efficiency, it is essential that the vocabulary table be indexed:\n**\n**     CREATE vocab_index ON V(W)\n**\n** A separate edit-cost-table provides scoring information that defines \n** what it means for one string to be \"close\" to another.\n**\n** The edit-cost-table must contain exactly four columns (more precisely,\n** the statement \"SELECT * FROM <edit-cost-table>\" must return records\n** that consist of four columns). It does not matter what the columns are\n** named. \n**\n** Each row in the edit-cost-table represents a single character\n** transformation going from user input to the vocabulary. The leftmost \n** column of the row (column 0) contains an integer identifier of the\n** language to which the transformation rule belongs (see \"MULTIPLE LANGUAGES\"\n** below). The second column of the row (column 1) contains the input\n** character or characters - the characters of user input. The third \n** column contains characters as they appear in the vocabulary table.\n** And the fourth column contains the integer cost of making the\n** transformation. For example:\n**\n**    CREATE TABLE f_data(iLang, cFrom, cTo, Cost);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, '', 'a', 100);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, 'b', '', 87);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, 'o', 'oe', 38);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, 'oe', 'o', 40);\n**\n** The first row inserted into the edit-cost-table by the SQL script\n** above indicates that the cost of having an extra 'a' in the vocabulary\n** table that is missing in the user input 100.  (All costs are integers.\n** Overall cost must not exceed 16777216.)  The second INSERT statement \n** creates a rule saying that the cost of having a single letter 'b' in\n** user input which is missing in the vocabulary table is 87.  The third\n** INSERT statement mean that the cost of matching an 'o' in user input \n** against an 'oe' in the vocabulary table is 38.  And so forth.\n**\n** The following rules are special:\n**\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, '?', '', 97);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, '', '?', 98);\n**    INSERT INTO f_data(iLang, cFrom, cTo, Cost) VALUES(0, '?', '?', 99);\n**\n** The '?' to '' rule is the cost of having any single character in the input\n** that is not found in the vocabular.  The '' to '?' rule is the cost of\n** having a character in the vocabulary table that is missing from input.\n** And the '?' to '?' rule is the cost of doing an arbitrary character\n** substitution.  These three generic rules apply across all languages.\n** In other words, the iLang field is ignored for the generic substitution\n** rules.  If more than one cost is given for a generic substitution rule,\n** then the lowest cost is used.\n**\n** Once it has been created, the amatch virtual table can be queried\n** as follows:\n**\n**    SELECT word, distance FROM f\n**     WHERE word MATCH 'abcdefg'\n**       AND distance<200;\n**\n** This query outputs the strings contained in the T(F) field that\n** are close to \"abcdefg\" and in order of increasing distance.  No string\n** is output more than once.  If there are multiple ways to transform the\n** target string (\"abcdefg\") into a string in the vocabulary table then\n** the lowest cost transform is the one that is returned.  In this example,\n** the search is limited to strings with a total distance of less than 200.\n**\n** For efficiency, it is important to put tight bounds on the distance.\n** The time and memory space needed to perform this query is exponential\n** in the maximum distance.  A good rule of thumb is to limit the distance\n** to no more than 1.5 or 2 times the maximum cost of any rule in the\n** edit-cost-table.\n**\n** The amatch is a read-only table.  Any attempt to DELETE, INSERT, or\n** UPDATE on a amatch table will throw an error.\n**\n** It is important to put some kind of a limit on the amatch output.  This\n** can be either in the form of a LIMIT clause at the end of the query,\n** or better, a \"distance<NNN\" constraint where NNN is some number.  The\n** running time and memory requirement is exponential in the value of NNN \n** so you want to make sure that NNN is not too big.  A value of NNN that\n** is about twice the average transformation cost seems to give good results.\n**\n** The amatch table can be useful for tasks such as spelling correction.\n** Suppose all allowed words are in table vocabulary(w).  Then one would create\n** an amatch virtual table like this:\n**\n**   CREATE VIRTUAL TABLE ex1 USING amatch(\n**       vocabtable=vocabulary,\n**       vocabcolumn=w,\n**       edit_distances=ec1\n**   );\n**\n** Then given an input word $word, look up close spellings this way:\n**\n**   SELECT word, distance FROM ex1\n**    WHERE word MATCH $word AND distance<200;\n**\n** MULTIPLE LANGUAGES\n**\n** Normally, the \"iLang\" value associated with all character transformations\n** in the edit-cost-table is zero. However, if required, the amatch \n** virtual table allows multiple languages to be defined. Each query uses \n** only a single iLang value.   This allows, for example, a single \n** amatch table to support multiple languages.\n**\n** By default, only the rules with iLang=0 are used. To specify an \n** alternative language, a \"language = ?\" expression must be added to the\n** WHERE clause of a SELECT, where ? is the integer identifier of the desired \n** language. For example:\n**\n**   SELECT word, distance FROM ex1\n**    WHERE word MATCH $word\n**      AND distance<=200\n**      AND language=1 -- Specify use language 1 instead of 0\n**\n** If no \"language = ?\" constraint is specified in the WHERE clause, language\n** 0 is used.\n**\n** LIMITS\n**\n** The maximum language number is 2147483647.  The maximum length of either\n** of the strings in the second or third column of the amatch data table\n** is 50 bytes.  The maximum cost on a rule is 1000.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stdio.h>\n#include <ctype.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Forward declaration of objects used by this implementation\n*/\ntypedef struct amatch_vtab amatch_vtab;\ntypedef struct amatch_cursor amatch_cursor;\ntypedef struct amatch_rule amatch_rule;\ntypedef struct amatch_word amatch_word;\ntypedef struct amatch_avl amatch_avl;\n\n\n/*****************************************************************************\n** AVL Tree implementation\n*/\n/*\n** Objects that want to be members of the AVL tree should embedded an\n** instance of this structure.\n*/\nstruct amatch_avl {\n  amatch_word *pWord;   /* Points to the object being stored in the tree */\n  char *zKey;           /* Key.  zero-terminated string.  Must be unique */\n  amatch_avl *pBefore;  /* Other elements less than zKey */\n  amatch_avl *pAfter;   /* Other elements greater than zKey */\n  amatch_avl *pUp;      /* Parent element */\n  short int height;     /* Height of this node.  Leaf==1 */\n  short int imbalance;  /* Height difference between pBefore and pAfter */\n};\n\n/* Recompute the amatch_avl.height and amatch_avl.imbalance fields for p.\n** Assume that the children of p have correct heights.\n*/\nstatic void amatchAvlRecomputeHeight(amatch_avl *p){\n  short int hBefore = p->pBefore ? p->pBefore->height : 0;\n  short int hAfter = p->pAfter ? p->pAfter->height : 0;\n  p->imbalance = hBefore - hAfter;  /* -: pAfter higher.  +: pBefore higher */\n  p->height = (hBefore>hAfter ? hBefore : hAfter)+1;\n}\n\n/*\n**     P                B\n**    / \\              / \\\n**   B   Z    ==>     X   P\n**  / \\                  / \\\n** X   Y                Y   Z\n**\n*/\nstatic amatch_avl *amatchAvlRotateBefore(amatch_avl *pP){\n  amatch_avl *pB = pP->pBefore;\n  amatch_avl *pY = pB->pAfter;\n  pB->pUp = pP->pUp;\n  pB->pAfter = pP;\n  pP->pUp = pB;\n  pP->pBefore = pY;\n  if( pY ) pY->pUp = pP;\n  amatchAvlRecomputeHeight(pP);\n  amatchAvlRecomputeHeight(pB);\n  return pB;\n}\n\n/*\n**     P                A\n**    / \\              / \\\n**   X   A    ==>     P   Z\n**      / \\          / \\\n**     Y   Z        X   Y\n**\n*/\nstatic amatch_avl *amatchAvlRotateAfter(amatch_avl *pP){\n  amatch_avl *pA = pP->pAfter;\n  amatch_avl *pY = pA->pBefore;\n  pA->pUp = pP->pUp;\n  pA->pBefore = pP;\n  pP->pUp = pA;\n  pP->pAfter = pY;\n  if( pY ) pY->pUp = pP;\n  amatchAvlRecomputeHeight(pP);\n  amatchAvlRecomputeHeight(pA);\n  return pA;\n}\n\n/*\n** Return a pointer to the pBefore or pAfter pointer in the parent\n** of p that points to p.  Or if p is the root node, return pp.\n*/\nstatic amatch_avl **amatchAvlFromPtr(amatch_avl *p, amatch_avl **pp){\n  amatch_avl *pUp = p->pUp;\n  if( pUp==0 ) return pp;\n  if( pUp->pAfter==p ) return &pUp->pAfter;\n  return &pUp->pBefore;\n}\n\n/*\n** Rebalance all nodes starting with p and working up to the root.\n** Return the new root.\n*/\nstatic amatch_avl *amatchAvlBalance(amatch_avl *p){\n  amatch_avl *pTop = p;\n  amatch_avl **pp;\n  while( p ){\n    amatchAvlRecomputeHeight(p);\n    if( p->imbalance>=2 ){\n      amatch_avl *pB = p->pBefore;\n      if( pB->imbalance<0 ) p->pBefore = amatchAvlRotateAfter(pB);\n      pp = amatchAvlFromPtr(p,&p);\n      p = *pp = amatchAvlRotateBefore(p);\n    }else if( p->imbalance<=(-2) ){\n      amatch_avl *pA = p->pAfter;\n      if( pA->imbalance>0 ) p->pAfter = amatchAvlRotateBefore(pA);\n      pp = amatchAvlFromPtr(p,&p);\n      p = *pp = amatchAvlRotateAfter(p);\n    }\n    pTop = p;\n    p = p->pUp;\n  }\n  return pTop;\n}\n\n/* Search the tree rooted at p for an entry with zKey.  Return a pointer\n** to the entry or return NULL.\n*/\nstatic amatch_avl *amatchAvlSearch(amatch_avl *p, const char *zKey){\n  int c;\n  while( p && (c = strcmp(zKey, p->zKey))!=0 ){\n    p = (c<0) ? p->pBefore : p->pAfter;\n  }\n  return p;\n}\n\n/* Find the first node (the one with the smallest key).\n*/\nstatic amatch_avl *amatchAvlFirst(amatch_avl *p){\n  if( p ) while( p->pBefore ) p = p->pBefore;\n  return p;\n}\n\n#if 0 /* NOT USED */\n/* Return the node with the next larger key after p.\n*/\nstatic amatch_avl *amatchAvlNext(amatch_avl *p){\n  amatch_avl *pPrev = 0;\n  while( p && p->pAfter==pPrev ){\n    pPrev = p;\n    p = p->pUp;\n  }\n  if( p && pPrev==0 ){\n    p = amatchAvlFirst(p->pAfter);\n  }\n  return p;\n}\n#endif\n\n#if 0 /* NOT USED */\n/* Verify AVL tree integrity\n*/\nstatic int amatchAvlIntegrity(amatch_avl *pHead){\n  amatch_avl *p;\n  if( pHead==0 ) return 1;\n  if( (p = pHead->pBefore)!=0 ){\n    assert( p->pUp==pHead );\n    assert( amatchAvlIntegrity(p) );\n    assert( strcmp(p->zKey, pHead->zKey)<0 );\n    while( p->pAfter ) p = p->pAfter;\n    assert( strcmp(p->zKey, pHead->zKey)<0 );\n  }\n  if( (p = pHead->pAfter)!=0 ){\n    assert( p->pUp==pHead );\n    assert( amatchAvlIntegrity(p) );\n    assert( strcmp(p->zKey, pHead->zKey)>0 );\n    p = amatchAvlFirst(p);\n    assert( strcmp(p->zKey, pHead->zKey)>0 );\n  }\n  return 1;\n}\nstatic int amatchAvlIntegrity2(amatch_avl *pHead){\n  amatch_avl *p, *pNext;\n  for(p=amatchAvlFirst(pHead); p; p=pNext){\n    pNext = amatchAvlNext(p);\n    if( pNext==0 ) break;\n    assert( strcmp(p->zKey, pNext->zKey)<0 );\n  }\n  return 1;\n}\n#endif\n\n/* Insert a new node pNew.  Return NULL on success.  If the key is not\n** unique, then do not perform the insert but instead leave pNew unchanged\n** and return a pointer to an existing node with the same key.\n*/\nstatic amatch_avl *amatchAvlInsert(amatch_avl **ppHead, amatch_avl *pNew){\n  int c;\n  amatch_avl *p = *ppHead;\n  if( p==0 ){\n    p = pNew;\n    pNew->pUp = 0;\n  }else{\n    while( p ){\n      c = strcmp(pNew->zKey, p->zKey);\n      if( c<0 ){\n        if( p->pBefore ){\n          p = p->pBefore;\n        }else{\n          p->pBefore = pNew;\n          pNew->pUp = p;\n          break;\n        }\n      }else if( c>0 ){\n        if( p->pAfter ){\n          p = p->pAfter;\n        }else{\n          p->pAfter = pNew;\n          pNew->pUp = p;\n          break;\n        }\n      }else{\n        return p;\n      }\n    }\n  }\n  pNew->pBefore = 0;\n  pNew->pAfter = 0;\n  pNew->height = 1;\n  pNew->imbalance = 0;\n  *ppHead = amatchAvlBalance(p);\n  /* assert( amatchAvlIntegrity(*ppHead) ); */\n  /* assert( amatchAvlIntegrity2(*ppHead) ); */\n  return 0;\n}\n\n/* Remove node pOld from the tree.  pOld must be an element of the tree or\n** the AVL tree will become corrupt.\n*/\nstatic void amatchAvlRemove(amatch_avl **ppHead, amatch_avl *pOld){\n  amatch_avl **ppParent;\n  amatch_avl *pBalance = 0;\n  /* assert( amatchAvlSearch(*ppHead, pOld->zKey)==pOld ); */\n  ppParent = amatchAvlFromPtr(pOld, ppHead);\n  if( pOld->pBefore==0 && pOld->pAfter==0 ){\n    *ppParent = 0;\n    pBalance = pOld->pUp;\n  }else if( pOld->pBefore && pOld->pAfter ){\n    amatch_avl *pX, *pY;\n    pX = amatchAvlFirst(pOld->pAfter);\n    *amatchAvlFromPtr(pX, 0) = pX->pAfter;\n    if( pX->pAfter ) pX->pAfter->pUp = pX->pUp;\n    pBalance = pX->pUp;\n    pX->pAfter = pOld->pAfter;\n    if( pX->pAfter ){\n      pX->pAfter->pUp = pX;\n    }else{\n      assert( pBalance==pOld );\n      pBalance = pX;\n    }\n    pX->pBefore = pY = pOld->pBefore;\n    if( pY ) pY->pUp = pX;\n    pX->pUp = pOld->pUp;\n    *ppParent = pX;\n  }else if( pOld->pBefore==0 ){\n    *ppParent = pBalance = pOld->pAfter;\n    pBalance->pUp = pOld->pUp;\n  }else if( pOld->pAfter==0 ){\n    *ppParent = pBalance = pOld->pBefore;\n    pBalance->pUp = pOld->pUp;\n  }\n  *ppHead = amatchAvlBalance(pBalance);\n  pOld->pUp = 0;\n  pOld->pBefore = 0;\n  pOld->pAfter = 0;\n  /* assert( amatchAvlIntegrity(*ppHead) ); */\n  /* assert( amatchAvlIntegrity2(*ppHead) ); */\n}\n/*\n** End of the AVL Tree implementation\n******************************************************************************/\n\n\n/*\n** Various types.\n**\n** amatch_cost is the \"cost\" of an edit operation.\n**\n** amatch_len is the length of a matching string.  \n**\n** amatch_langid is an ruleset identifier.\n*/\ntypedef int amatch_cost;\ntypedef signed char amatch_len;\ntypedef int amatch_langid;\n\n/*\n** Limits\n*/\n#define AMATCH_MX_LENGTH          50  /* Maximum length of a rule string */\n#define AMATCH_MX_LANGID  2147483647  /* Maximum rule ID */\n#define AMATCH_MX_COST          1000  /* Maximum single-rule cost */\n\n/*\n** A match or partial match\n*/\nstruct amatch_word {\n  amatch_word *pNext;   /* Next on a list of all amatch_words */\n  amatch_avl sCost;     /* Linkage of this node into the cost tree */\n  amatch_avl sWord;     /* Linkage of this node into the word tree */\n  amatch_cost rCost;    /* Cost of the match so far */\n  int iSeq;             /* Sequence number */\n  char zCost[10];       /* Cost key (text rendering of rCost) */\n  short int nMatch;     /* Input characters matched */\n  char zWord[4];        /* Text of the word.  Extra space appended as needed */\n};\n\n/*\n** Each transformation rule is stored as an instance of this object.\n** All rules are kept on a linked list sorted by rCost.\n*/\nstruct amatch_rule {\n  amatch_rule *pNext;      /* Next rule in order of increasing rCost */\n  char *zFrom;             /* Transform from (a string from user input) */\n  amatch_cost rCost;       /* Cost of this transformation */\n  amatch_langid iLang;     /* The langauge to which this rule belongs */\n  amatch_len nFrom, nTo;   /* Length of the zFrom and zTo strings */\n  char zTo[4];             /* Tranform to V.W value (extra space appended) */\n};\n\n/* \n** A amatch virtual-table object \n*/\nstruct amatch_vtab {\n  sqlite3_vtab base;         /* Base class - must be first */\n  char *zClassName;          /* Name of this class.  Default: \"amatch\" */\n  char *zDb;                 /* Name of database.  (ex: \"main\") */\n  char *zSelf;               /* Name of this virtual table */\n  char *zCostTab;            /* Name of edit-cost-table */\n  char *zVocabTab;           /* Name of vocabulary table */\n  char *zVocabWord;          /* Name of vocabulary table word column */\n  char *zVocabLang;          /* Name of vocabulary table language column */\n  amatch_rule *pRule;        /* All active rules in this amatch */\n  amatch_cost rIns;          /* Generic insertion cost  '' -> ? */\n  amatch_cost rDel;          /* Generic deletion cost  ? -> '' */\n  amatch_cost rSub;          /* Generic substitution cost ? -> ? */\n  sqlite3 *db;               /* The database connection */\n  sqlite3_stmt *pVCheck;     /* Query to check zVocabTab */\n  int nCursor;               /* Number of active cursors */\n};\n\n/* A amatch cursor object */\nstruct amatch_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3_int64 iRowid;      /* The rowid of the current word */\n  amatch_langid iLang;       /* Use this language ID */\n  amatch_cost rLimit;        /* Maximum cost of any term */\n  int nBuf;                  /* Space allocated for zBuf */\n  int oomErr;                /* True following an OOM error */\n  int nWord;                 /* Number of amatch_word objects */\n  char *zBuf;                /* Temp-use buffer space */\n  char *zInput;              /* Input word to match against */\n  amatch_vtab *pVtab;        /* The virtual table this cursor belongs to */\n  amatch_word *pAllWords;    /* List of all amatch_word objects */\n  amatch_word *pCurrent;     /* Most recent solution */\n  amatch_avl *pCost;         /* amatch_word objects keyed by iCost */\n  amatch_avl *pWord;         /* amatch_word objects keyed by zWord */\n};\n\n/*\n** The two input rule lists are both sorted in order of increasing\n** cost.  Merge them together into a single list, sorted by cost, and\n** return a pointer to the head of that list.\n*/\nstatic amatch_rule *amatchMergeRules(amatch_rule *pA, amatch_rule *pB){\n  amatch_rule head;\n  amatch_rule *pTail;\n\n  pTail =  &head;\n  while( pA && pB ){\n    if( pA->rCost<=pB->rCost ){\n      pTail->pNext = pA;\n      pTail = pA;\n      pA = pA->pNext;\n    }else{\n      pTail->pNext = pB;\n      pTail = pB;\n      pB = pB->pNext;\n    }\n  }\n  if( pA==0 ){\n    pTail->pNext = pB;\n  }else{\n    pTail->pNext = pA;\n  }\n  return head.pNext;\n}\n\n/*\n** Statement pStmt currently points to a row in the amatch data table. This\n** function allocates and populates a amatch_rule structure according to\n** the content of the row.\n**\n** If successful, *ppRule is set to point to the new object and SQLITE_OK\n** is returned. Otherwise, *ppRule is zeroed, *pzErr may be set to point\n** to an error message and an SQLite error code returned.\n*/\nstatic int amatchLoadOneRule(\n  amatch_vtab *p,                 /* Fuzzer virtual table handle */\n  sqlite3_stmt *pStmt,            /* Base rule on statements current row */\n  amatch_rule **ppRule,           /* OUT: New rule object */\n  char **pzErr                    /* OUT: Error message */\n){\n  sqlite3_int64 iLang = sqlite3_column_int64(pStmt, 0);\n  const char *zFrom = (const char *)sqlite3_column_text(pStmt, 1);\n  const char *zTo = (const char *)sqlite3_column_text(pStmt, 2);\n  amatch_cost rCost = sqlite3_column_int(pStmt, 3);\n\n  int rc = SQLITE_OK;             /* Return code */\n  int nFrom;                      /* Size of string zFrom, in bytes */\n  int nTo;                        /* Size of string zTo, in bytes */\n  amatch_rule *pRule = 0;         /* New rule object to return */\n\n  if( zFrom==0 ) zFrom = \"\";\n  if( zTo==0 ) zTo = \"\";\n  nFrom = (int)strlen(zFrom);\n  nTo = (int)strlen(zTo);\n\n  /* Silently ignore null transformations */\n  if( strcmp(zFrom, zTo)==0 ){\n    if( zFrom[0]=='?' && zFrom[1]==0 ){\n      if( p->rSub==0 || p->rSub>rCost ) p->rSub = rCost;\n    }\n    *ppRule = 0;\n    return SQLITE_OK;\n  }\n\n  if( rCost<=0 || rCost>AMATCH_MX_COST ){\n    *pzErr = sqlite3_mprintf(\"%s: cost must be between 1 and %d\", \n        p->zClassName, AMATCH_MX_COST\n    );\n    rc = SQLITE_ERROR;\n  }else\n  if( nFrom>AMATCH_MX_LENGTH || nTo>AMATCH_MX_LENGTH ){\n    *pzErr = sqlite3_mprintf(\"%s: maximum string length is %d\", \n        p->zClassName, AMATCH_MX_LENGTH\n    );\n    rc = SQLITE_ERROR;    \n  }else\n  if( iLang<0 || iLang>AMATCH_MX_LANGID ){\n    *pzErr = sqlite3_mprintf(\"%s: iLang must be between 0 and %d\", \n        p->zClassName, AMATCH_MX_LANGID\n    );\n    rc = SQLITE_ERROR;    \n  }else\n  if( strcmp(zFrom,\"\")==0 && strcmp(zTo,\"?\")==0 ){\n    if( p->rIns==0 || p->rIns>rCost ) p->rIns = rCost;\n  }else\n  if( strcmp(zFrom,\"?\")==0 && strcmp(zTo,\"\")==0 ){\n    if( p->rDel==0 || p->rDel>rCost ) p->rDel = rCost;\n  }else\n  {\n    pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );\n    if( pRule==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pRule, 0, sizeof(*pRule));\n      pRule->zFrom = &pRule->zTo[nTo+1];\n      pRule->nFrom = (amatch_len)nFrom;\n      memcpy(pRule->zFrom, zFrom, nFrom+1);\n      memcpy(pRule->zTo, zTo, nTo+1);\n      pRule->nTo = (amatch_len)nTo;\n      pRule->rCost = rCost;\n      pRule->iLang = (int)iLang;\n    }\n  }\n\n  *ppRule = pRule;\n  return rc;\n}\n\n/*\n** Free all the content in the edit-cost-table\n*/\nstatic void amatchFreeRules(amatch_vtab *p){\n  while( p->pRule ){\n    amatch_rule *pRule = p->pRule;\n    p->pRule = pRule->pNext;\n    sqlite3_free(pRule);\n  }\n  p->pRule = 0;\n}\n\n/*\n** Load the content of the amatch data table into memory.\n*/\nstatic int amatchLoadRules(\n  sqlite3 *db,                    /* Database handle */\n  amatch_vtab *p,                 /* Virtual amatch table to configure */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* SELECT used to read from rules table */\n  amatch_rule *pHead = 0;\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", p->zDb, p->zCostTab);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int rc2;                      /* finalize() return code */\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s: %s\", p->zClassName, sqlite3_errmsg(db));\n    }else if( sqlite3_column_count(pStmt)!=4 ){\n      *pzErr = sqlite3_mprintf(\"%s: %s has %d columns, expected 4\",\n          p->zClassName, p->zCostTab, sqlite3_column_count(pStmt)\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n        amatch_rule *pRule = 0;\n        rc = amatchLoadOneRule(p, pStmt, &pRule, pzErr);\n        if( pRule ){\n          pRule->pNext = pHead;\n          pHead = pRule;\n        }\n      }\n    }\n    rc2 = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  sqlite3_free(zSql);\n\n  /* All rules are now in a singly linked list starting at pHead. This\n  ** block sorts them by cost and then sets amatch_vtab.pRule to point to \n  ** point to the head of the sorted list.\n  */\n  if( rc==SQLITE_OK ){\n    unsigned int i;\n    amatch_rule *pX;\n    amatch_rule *a[15];\n    for(i=0; i<sizeof(a)/sizeof(a[0]); i++) a[i] = 0;\n    while( (pX = pHead)!=0 ){\n      pHead = pX->pNext;\n      pX->pNext = 0;\n      for(i=0; a[i] && i<sizeof(a)/sizeof(a[0])-1; i++){\n        pX = amatchMergeRules(a[i], pX);\n        a[i] = 0;\n      }\n      a[i] = amatchMergeRules(a[i], pX);\n    }\n    for(pX=a[0], i=1; i<sizeof(a)/sizeof(a[0]); i++){\n      pX = amatchMergeRules(a[i], pX);\n    }\n    p->pRule = amatchMergeRules(p->pRule, pX);\n  }else{\n    /* An error has occurred. Setting p->pRule to point to the head of the\n    ** allocated list ensures that the list will be cleaned up in this case.\n    */\n    assert( p->pRule==0 );\n    p->pRule = pHead;\n  }\n\n  return rc;\n}\n\n/*\n** This function converts an SQL quoted string into an unquoted string\n** and returns a pointer to a buffer allocated using sqlite3_malloc() \n** containing the result. The caller should eventually free this buffer\n** using sqlite3_free.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic char *amatchDequote(const char *zIn){\n  int nIn;                        /* Size of input string, in bytes */\n  char *zOut;                     /* Output (dequoted) string */\n\n  nIn = (int)strlen(zIn);\n  zOut = sqlite3_malloc(nIn+1);\n  if( zOut ){\n    char q = zIn[0];              /* Quote character (if any ) */\n\n    if( q!='[' && q!= '\\'' && q!='\"' && q!='`' ){\n      memcpy(zOut, zIn, nIn+1);\n    }else{\n      int iOut = 0;               /* Index of next byte to write to output */\n      int iIn;                    /* Index of next byte to read from input */\n\n      if( q=='[' ) q = ']';\n      for(iIn=1; iIn<nIn; iIn++){\n        if( zIn[iIn]==q ) iIn++;\n        zOut[iOut++] = zIn[iIn];\n      }\n    }\n    assert( (int)strlen(zOut)<=nIn );\n  }\n  return zOut;\n}\n\n/*\n** Deallocate the pVCheck prepared statement.\n*/\nstatic void amatchVCheckClear(amatch_vtab *p){\n  if( p->pVCheck ){\n    sqlite3_finalize(p->pVCheck);\n    p->pVCheck = 0;\n  }\n}\n\n/*\n** Deallocate an amatch_vtab object\n*/\nstatic void amatchFree(amatch_vtab *p){\n  if( p ){\n    amatchFreeRules(p);\n    amatchVCheckClear(p);\n    sqlite3_free(p->zClassName);\n    sqlite3_free(p->zDb);\n    sqlite3_free(p->zCostTab);\n    sqlite3_free(p->zVocabTab);\n    sqlite3_free(p->zVocabWord);\n    sqlite3_free(p->zVocabLang);\n    sqlite3_free(p->zSelf);\n    memset(p, 0, sizeof(*p));\n    sqlite3_free(p);\n  }\n}\n\n/*\n** xDisconnect/xDestroy method for the amatch module.\n*/\nstatic int amatchDisconnect(sqlite3_vtab *pVtab){\n  amatch_vtab *p = (amatch_vtab*)pVtab;\n  assert( p->nCursor==0 );\n  amatchFree(p);\n  return SQLITE_OK;\n}\n\n/*\n** Check to see if the argument is of the form:\n**\n**       KEY = VALUE\n**\n** If it is, return a pointer to the first character of VALUE.\n** If not, return NULL.  Spaces around the = are ignored.\n*/\nstatic const char *amatchValueOfKey(const char *zKey, const char *zStr){\n  int nKey = (int)strlen(zKey);\n  int nStr = (int)strlen(zStr);\n  int i;\n  if( nStr<nKey+1 ) return 0;\n  if( memcmp(zStr, zKey, nKey)!=0 ) return 0;\n  for(i=nKey; isspace((unsigned char)zStr[i]); i++){}\n  if( zStr[i]!='=' ) return 0;\n  i++;\n  while( isspace((unsigned char)zStr[i]) ){ i++; }\n  return zStr+i;\n}\n\n/*\n** xConnect/xCreate method for the amatch module. Arguments are:\n**\n**   argv[0]    -> module name  (\"approximate_match\")\n**   argv[1]    -> database name\n**   argv[2]    -> table name\n**   argv[3...] -> arguments\n*/\nstatic int amatchConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc = SQLITE_OK;             /* Return code */\n  amatch_vtab *pNew = 0;          /* New virtual table */\n  const char *zModule = argv[0];\n  const char *zDb = argv[1];\n  const char *zVal;\n  int i;\n\n  (void)pAux;\n  *ppVtab = 0;\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return SQLITE_NOMEM;\n  rc = SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(*pNew));\n  pNew->db = db;\n  pNew->zClassName = sqlite3_mprintf(\"%s\", zModule);\n  if( pNew->zClassName==0 ) goto amatchConnectError;\n  pNew->zDb = sqlite3_mprintf(\"%s\", zDb);\n  if( pNew->zDb==0 ) goto amatchConnectError;\n  pNew->zSelf = sqlite3_mprintf(\"%s\", argv[2]);\n  if( pNew->zSelf==0 ) goto amatchConnectError;\n  for(i=3; i<argc; i++){\n    zVal = amatchValueOfKey(\"vocabulary_table\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zVocabTab);\n      pNew->zVocabTab = amatchDequote(zVal);\n      if( pNew->zVocabTab==0 ) goto amatchConnectError;\n      continue;\n    }\n    zVal = amatchValueOfKey(\"vocabulary_word\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zVocabWord);\n      pNew->zVocabWord = amatchDequote(zVal);\n      if( pNew->zVocabWord==0 ) goto amatchConnectError;\n      continue;\n    }\n    zVal = amatchValueOfKey(\"vocabulary_language\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zVocabLang);\n      pNew->zVocabLang = amatchDequote(zVal);\n      if( pNew->zVocabLang==0 ) goto amatchConnectError;\n      continue;\n    }\n    zVal = amatchValueOfKey(\"edit_distances\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zCostTab);\n      pNew->zCostTab = amatchDequote(zVal);\n      if( pNew->zCostTab==0 ) goto amatchConnectError;\n      continue;\n    }\n    *pzErr = sqlite3_mprintf(\"unrecognized argument: [%s]\\n\", argv[i]);\n    amatchFree(pNew);\n    *ppVtab = 0;\n    return SQLITE_ERROR;\n  }\n  rc = SQLITE_OK;\n  if( pNew->zCostTab==0 ){\n    *pzErr = sqlite3_mprintf(\"no edit_distances table specified\");\n    rc = SQLITE_ERROR;\n  }else{\n    rc = amatchLoadRules(db, pNew, pzErr);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_declare_vtab(db,\n           \"CREATE TABLE x(word,distance,language,\"\n           \"command HIDDEN,nword HIDDEN)\"\n         );\n#define AMATCH_COL_WORD       0\n#define AMATCH_COL_DISTANCE   1\n#define AMATCH_COL_LANGUAGE   2\n#define AMATCH_COL_COMMAND    3\n#define AMATCH_COL_NWORD      4\n  }\n  if( rc!=SQLITE_OK ){\n    amatchFree(pNew);\n  }\n  *ppVtab = &pNew->base;\n  return rc;\n\namatchConnectError:\n  amatchFree(pNew);\n  return rc;\n}\n\n/*\n** Open a new amatch cursor.\n*/\nstatic int amatchOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  amatch_vtab *p = (amatch_vtab*)pVTab;\n  amatch_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->pVtab = p;\n  *ppCursor = &pCur->base;\n  p->nCursor++;\n  return SQLITE_OK;\n}\n\n/*\n** Free up all the memory allocated by a cursor.  Set it rLimit to 0\n** to indicate that it is at EOF.\n*/\nstatic void amatchClearCursor(amatch_cursor *pCur){\n  amatch_word *pWord, *pNextWord;\n  for(pWord=pCur->pAllWords; pWord; pWord=pNextWord){\n    pNextWord = pWord->pNext;\n    sqlite3_free(pWord);\n  }\n  pCur->pAllWords = 0;\n  sqlite3_free(pCur->zInput);\n  pCur->zInput = 0;\n  sqlite3_free(pCur->zBuf);\n  pCur->zBuf = 0;\n  pCur->nBuf = 0;\n  pCur->pCost = 0;\n  pCur->pWord = 0;\n  pCur->pCurrent = 0;\n  pCur->rLimit = 1000000;\n  pCur->iLang = 0;\n  pCur->nWord = 0;\n}\n\n/*\n** Close a amatch cursor.\n*/\nstatic int amatchClose(sqlite3_vtab_cursor *cur){\n  amatch_cursor *pCur = (amatch_cursor *)cur;\n  amatchClearCursor(pCur);\n  pCur->pVtab->nCursor--;\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Render a 24-bit unsigned integer as a 4-byte base-64 number.\n*/\nstatic void amatchEncodeInt(int x, char *z){\n  static const char a[] = \n    \"0123456789\"\n    \"ABCDEFGHIJ\"\n    \"KLMNOPQRST\"\n    \"UVWXYZ^abc\"\n    \"defghijklm\"\n    \"nopqrstuvw\"\n    \"xyz~\";\n  z[0] = a[(x>>18)&0x3f];\n  z[1] = a[(x>>12)&0x3f];\n  z[2] = a[(x>>6)&0x3f];\n  z[3] = a[x&0x3f];\n}\n\n/*\n** Write the zCost[] field for a amatch_word object\n*/\nstatic void amatchWriteCost(amatch_word *pWord){\n  amatchEncodeInt(pWord->rCost, pWord->zCost);\n  amatchEncodeInt(pWord->iSeq, pWord->zCost+4);\n  pWord->zCost[8] = 0;\n}\n\n/* Circumvent compiler warnings about the use of strcpy() by supplying\n** our own implementation.\n*/\nstatic void amatchStrcpy(char *dest, const char *src){\n  while( (*(dest++) = *(src++))!=0 ){}\n}\nstatic void amatchStrcat(char *dest, const char *src){\n  while( *dest ) dest++;\n  amatchStrcpy(dest, src);\n}\n\n/*\n** Add a new amatch_word object to the queue.\n**\n** If a prior amatch_word object with the same zWord, and nMatch\n** already exists, update its rCost (if the new rCost is less) but\n** otherwise leave it unchanged.  Do not add a duplicate.\n**\n** Do nothing if the cost exceeds threshold.\n*/\nstatic void amatchAddWord(\n  amatch_cursor *pCur,\n  amatch_cost rCost,\n  int nMatch,\n  const char *zWordBase,\n  const char *zWordTail\n){\n  amatch_word *pWord;\n  amatch_avl *pNode;\n  amatch_avl *pOther;\n  int nBase, nTail;\n  char zBuf[4];\n  \n  if( rCost>pCur->rLimit ){\n    return;\n  }\n  nBase = (int)strlen(zWordBase);\n  nTail = (int)strlen(zWordTail);\n  if( nBase+nTail+3>pCur->nBuf ){\n    pCur->nBuf = nBase+nTail+100;\n    pCur->zBuf = sqlite3_realloc(pCur->zBuf, pCur->nBuf);\n    if( pCur->zBuf==0 ){\n      pCur->nBuf = 0;\n      return;\n    }\n  }\n  amatchEncodeInt(nMatch, zBuf);\n  memcpy(pCur->zBuf, zBuf+2, 2);\n  memcpy(pCur->zBuf+2, zWordBase, nBase);\n  memcpy(pCur->zBuf+2+nBase, zWordTail, nTail+1);\n  pNode = amatchAvlSearch(pCur->pWord, pCur->zBuf);\n  if( pNode ){\n    pWord = pNode->pWord;\n    if( pWord->rCost>rCost ){\n#ifdef AMATCH_TRACE_1\n      printf(\"UPDATE [%s][%.*s^%s] %d (\\\"%s\\\" \\\"%s\\\")\\n\",\n             pWord->zWord+2, pWord->nMatch, pCur->zInput, pCur->zInput,\n             pWord->rCost, pWord->zWord, pWord->zCost);\n#endif\n      amatchAvlRemove(&pCur->pCost, &pWord->sCost);\n      pWord->rCost = rCost;\n      amatchWriteCost(pWord);\n#ifdef AMATCH_TRACE_1\n      printf(\"  ---> %d (\\\"%s\\\" \\\"%s\\\")\\n\",\n             pWord->rCost, pWord->zWord, pWord->zCost);\n#endif\n      pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost);\n      assert( pOther==0 ); (void)pOther;\n    }\n    return;\n  }\n  pWord = sqlite3_malloc( sizeof(*pWord) + nBase + nTail - 1 );\n  if( pWord==0 ) return;\n  memset(pWord, 0, sizeof(*pWord));\n  pWord->rCost = rCost;\n  pWord->iSeq = pCur->nWord++;\n  amatchWriteCost(pWord);\n  pWord->nMatch = (short)nMatch;\n  pWord->pNext = pCur->pAllWords;\n  pCur->pAllWords = pWord;\n  pWord->sCost.zKey = pWord->zCost;\n  pWord->sCost.pWord = pWord;\n  pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost);\n  assert( pOther==0 ); (void)pOther;\n  pWord->sWord.zKey = pWord->zWord;\n  pWord->sWord.pWord = pWord;\n  amatchStrcpy(pWord->zWord, pCur->zBuf);\n  pOther = amatchAvlInsert(&pCur->pWord, &pWord->sWord);\n  assert( pOther==0 ); (void)pOther;\n#ifdef AMATCH_TRACE_1\n  printf(\"INSERT [%s][%.*s^%s] %d (\\\"%s\\\" \\\"%s\\\")\\n\", pWord->zWord+2,\n       pWord->nMatch, pCur->zInput, pCur->zInput+pWord->nMatch, rCost,\n       pWord->zWord, pWord->zCost);\n#endif\n}\n\n\n/*\n** Advance a cursor to its next row of output\n*/\nstatic int amatchNext(sqlite3_vtab_cursor *cur){\n  amatch_cursor *pCur = (amatch_cursor*)cur;\n  amatch_word *pWord = 0;\n  amatch_avl *pNode;\n  int isMatch = 0;\n  amatch_vtab *p = pCur->pVtab;\n  int nWord;\n  int rc;\n  int i;\n  const char *zW;\n  amatch_rule *pRule;\n  char *zBuf = 0;\n  char nBuf = 0;\n  char zNext[8];\n  char zNextIn[8];\n  int nNextIn;\n\n  if( p->pVCheck==0 ){\n    char *zSql;\n    if( p->zVocabLang && p->zVocabLang[0] ){\n      zSql = sqlite3_mprintf(\n          \"SELECT \\\"%w\\\" FROM \\\"%w\\\"\",\n          \" WHERE \\\"%w\\\">=?1 AND \\\"%w\\\"=?2\"\n          \" ORDER BY 1\",\n          p->zVocabWord, p->zVocabTab,\n          p->zVocabWord, p->zVocabLang\n      );\n    }else{\n      zSql = sqlite3_mprintf(\n          \"SELECT \\\"%w\\\" FROM \\\"%w\\\"\"\n          \" WHERE \\\"%w\\\">=?1\"\n          \" ORDER BY 1\",\n          p->zVocabWord, p->zVocabTab,\n          p->zVocabWord\n      );\n    }\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &p->pVCheck, 0);\n    sqlite3_free(zSql);\n    if( rc ) return rc;\n  }\n  sqlite3_bind_int(p->pVCheck, 2, pCur->iLang);\n\n  do{\n    pNode = amatchAvlFirst(pCur->pCost);\n    if( pNode==0 ){\n      pWord = 0;\n      break;\n    }\n    pWord = pNode->pWord;\n    amatchAvlRemove(&pCur->pCost, &pWord->sCost);\n\n#ifdef AMATCH_TRACE_1\n    printf(\"PROCESS [%s][%.*s^%s] %d (\\\"%s\\\" \\\"%s\\\")\\n\",\n       pWord->zWord+2, pWord->nMatch, pCur->zInput, pCur->zInput+pWord->nMatch,\n       pWord->rCost, pWord->zWord, pWord->zCost);\n#endif\n    nWord = (int)strlen(pWord->zWord+2);\n    if( nWord+20>nBuf ){\n      nBuf = (char)(nWord+100);\n      zBuf = sqlite3_realloc(zBuf, nBuf);\n      if( zBuf==0 ) return SQLITE_NOMEM;\n    }\n    amatchStrcpy(zBuf, pWord->zWord+2);\n    zNext[0] = 0;\n    zNextIn[0] = pCur->zInput[pWord->nMatch];\n    if( zNextIn[0] ){\n      for(i=1; i<=4 && (pCur->zInput[pWord->nMatch+i]&0xc0)==0x80; i++){\n        zNextIn[i] = pCur->zInput[pWord->nMatch+i];\n      }\n      zNextIn[i] = 0;\n      nNextIn = i;\n    }else{\n      nNextIn = 0;\n    }\n\n    if( zNextIn[0] && zNextIn[0]!='*' ){\n      sqlite3_reset(p->pVCheck);\n      amatchStrcat(zBuf, zNextIn);\n      sqlite3_bind_text(p->pVCheck, 1, zBuf, nWord+nNextIn, SQLITE_STATIC);\n      rc = sqlite3_step(p->pVCheck);\n      if( rc==SQLITE_ROW ){\n        zW = (const char*)sqlite3_column_text(p->pVCheck, 0);\n        if( strncmp(zBuf, zW, nWord+nNextIn)==0 ){\n          amatchAddWord(pCur, pWord->rCost, pWord->nMatch+nNextIn, zBuf, \"\");\n        }\n      }\n      zBuf[nWord] = 0;\n    }\n\n    while( 1 ){\n      amatchStrcpy(zBuf+nWord, zNext);\n      sqlite3_reset(p->pVCheck);\n      sqlite3_bind_text(p->pVCheck, 1, zBuf, -1, SQLITE_TRANSIENT);\n      rc = sqlite3_step(p->pVCheck);\n      if( rc!=SQLITE_ROW ) break;\n      zW = (const char*)sqlite3_column_text(p->pVCheck, 0);\n      amatchStrcpy(zBuf+nWord, zNext);\n      if( strncmp(zW, zBuf, nWord)!=0 ) break;\n      if( (zNextIn[0]=='*' && zNextIn[1]==0)\n       || (zNextIn[0]==0 && zW[nWord]==0)\n      ){\n        isMatch = 1;\n        zNextIn[0] = 0;\n        nNextIn = 0;\n        break;\n      }\n      zNext[0] = zW[nWord];\n      for(i=1; i<=4 && (zW[nWord+i]&0xc0)==0x80; i++){\n        zNext[i] = zW[nWord+i];\n      }\n      zNext[i] = 0;\n      zBuf[nWord] = 0;\n      if( p->rIns>0 ){\n        amatchAddWord(pCur, pWord->rCost+p->rIns, pWord->nMatch, \n                      zBuf, zNext);\n      }\n      if( p->rSub>0 ){\n        amatchAddWord(pCur, pWord->rCost+p->rSub, pWord->nMatch+nNextIn, \n                      zBuf, zNext);\n      }\n      if( p->rIns<0 && p->rSub<0 ) break;\n      zNext[i-1]++;  /* FIX ME */\n    }\n    sqlite3_reset(p->pVCheck);\n\n    if( p->rDel>0 ){\n      zBuf[nWord] = 0;\n      amatchAddWord(pCur, pWord->rCost+p->rDel, pWord->nMatch+nNextIn,\n                    zBuf, \"\");\n    }\n\n    for(pRule=p->pRule; pRule; pRule=pRule->pNext){\n      if( pRule->iLang!=pCur->iLang ) continue;\n      if( strncmp(pRule->zFrom, pCur->zInput+pWord->nMatch, pRule->nFrom)==0 ){\n        amatchAddWord(pCur, pWord->rCost+pRule->rCost,\n                      pWord->nMatch+pRule->nFrom, pWord->zWord+2, pRule->zTo);\n      }\n    }\n  }while( !isMatch );\n  pCur->pCurrent = pWord;\n  sqlite3_free(zBuf);\n  return SQLITE_OK;\n}\n\n/*\n** Called to \"rewind\" a cursor back to the beginning so that\n** it starts its output over again.  Always called at least once\n** prior to any amatchColumn, amatchRowid, or amatchEof call.\n*/\nstatic int amatchFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  amatch_cursor *pCur = (amatch_cursor *)pVtabCursor;\n  const char *zWord = \"*\";\n  int idx;\n\n  amatchClearCursor(pCur);\n  idx = 0;\n  if( idxNum & 1 ){\n    zWord = (const char*)sqlite3_value_text(argv[0]);\n    idx++;\n  }\n  if( idxNum & 2 ){\n    pCur->rLimit = (amatch_cost)sqlite3_value_int(argv[idx]);\n    idx++;\n  }\n  if( idxNum & 4 ){\n    pCur->iLang = (amatch_cost)sqlite3_value_int(argv[idx]);\n    idx++;\n  }\n  pCur->zInput = sqlite3_mprintf(\"%s\", zWord);\n  if( pCur->zInput==0 ) return SQLITE_NOMEM;\n  amatchAddWord(pCur, 0, 0, \"\", \"\");\n  amatchNext(pVtabCursor);\n\n  return SQLITE_OK;\n}\n\n/*\n** Only the word and distance columns have values.  All other columns\n** return NULL\n*/\nstatic int amatchColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  amatch_cursor *pCur = (amatch_cursor*)cur;\n  switch( i ){\n    case AMATCH_COL_WORD: {\n      sqlite3_result_text(ctx, pCur->pCurrent->zWord+2, -1, SQLITE_STATIC);\n      break;\n    }\n    case AMATCH_COL_DISTANCE: {\n      sqlite3_result_int(ctx, pCur->pCurrent->rCost);\n      break;\n    }\n    case AMATCH_COL_LANGUAGE: {\n      sqlite3_result_int(ctx, pCur->iLang);\n      break;\n    }\n    case AMATCH_COL_NWORD: {\n      sqlite3_result_int(ctx, pCur->nWord);\n      break;\n    }\n    default: {\n      sqlite3_result_null(ctx);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The rowid.\n*/\nstatic int amatchRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  amatch_cursor *pCur = (amatch_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** EOF indicator\n*/\nstatic int amatchEof(sqlite3_vtab_cursor *cur){\n  amatch_cursor *pCur = (amatch_cursor*)cur;\n  return pCur->pCurrent==0;\n}\n\n/*\n** Search for terms of these forms:\n**\n**   (A)    word MATCH $str\n**   (B1)   distance < $value\n**   (B2)   distance <= $value\n**   (C)    language == $language\n**\n** The distance< and distance<= are both treated as distance<=.\n** The query plan number is a bit vector:\n**\n**   bit 1:   Term of the form (A) found\n**   bit 2:   Term like (B1) or (B2) found\n**   bit 3:   Term like (C) found\n**\n** If bit-1 is set, $str is always in filter.argv[0].  If bit-2 is set\n** then $value is in filter.argv[0] if bit-1 is clear and is in \n** filter.argv[1] if bit-1 is set.  If bit-3 is set, then $ruleid is\n** in filter.argv[0] if bit-1 and bit-2 are both zero, is in\n** filter.argv[1] if exactly one of bit-1 and bit-2 are set, and is in\n** filter.argv[2] if both bit-1 and bit-2 are set.\n*/\nstatic int amatchBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int iPlan = 0;\n  int iDistTerm = -1;\n  int iLangTerm = -1;\n  int i;\n  const struct sqlite3_index_constraint *pConstraint;\n\n  (void)tab;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( (iPlan & 1)==0 \n     && pConstraint->iColumn==0\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH\n    ){\n      iPlan |= 1;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n    }\n    if( (iPlan & 2)==0\n     && pConstraint->iColumn==1\n     && (pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT\n           || pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE)\n    ){\n      iPlan |= 2;\n      iDistTerm = i;\n    }\n    if( (iPlan & 4)==0\n     && pConstraint->iColumn==2\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= 4;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      iLangTerm = i;\n    }\n  }\n  if( iPlan & 2 ){\n    pIdxInfo->aConstraintUsage[iDistTerm].argvIndex = 1+((iPlan&1)!=0);\n  }\n  if( iPlan & 4 ){\n    int idx = 1;\n    if( iPlan & 1 ) idx++;\n    if( iPlan & 2 ) idx++;\n    pIdxInfo->aConstraintUsage[iLangTerm].argvIndex = idx;\n  }\n  pIdxInfo->idxNum = iPlan;\n  if( pIdxInfo->nOrderBy==1\n   && pIdxInfo->aOrderBy[0].iColumn==1\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  pIdxInfo->estimatedCost = (double)10000;\n   \n  return SQLITE_OK;\n}\n\n/*\n** The xUpdate() method.  \n**\n** This implementation disallows DELETE and UPDATE.  The only thing\n** allowed is INSERT into the \"command\" column.\n*/\nstatic int amatchUpdate(\n  sqlite3_vtab *pVTab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  amatch_vtab *p = (amatch_vtab*)pVTab;\n  const unsigned char *zCmd;\n  (void)pRowid;\n  if( argc==1 ){\n    pVTab->zErrMsg = sqlite3_mprintf(\"DELETE from %s is not allowed\", \n                                      p->zSelf);\n    return SQLITE_ERROR;\n  }\n  if( sqlite3_value_type(argv[0])!=SQLITE_NULL ){\n    pVTab->zErrMsg = sqlite3_mprintf(\"UPDATE of %s is not allowed\", \n                                      p->zSelf);\n    return SQLITE_ERROR;\n  }\n  if( sqlite3_value_type(argv[2+AMATCH_COL_WORD])!=SQLITE_NULL\n   || sqlite3_value_type(argv[2+AMATCH_COL_DISTANCE])!=SQLITE_NULL\n   || sqlite3_value_type(argv[2+AMATCH_COL_LANGUAGE])!=SQLITE_NULL\n  ){\n    pVTab->zErrMsg = sqlite3_mprintf(\n            \"INSERT INTO %s allowed for column [command] only\", p->zSelf);\n    return SQLITE_ERROR;\n  }\n  zCmd = sqlite3_value_text(argv[2+AMATCH_COL_COMMAND]);\n  if( zCmd==0 ) return SQLITE_OK;\n  \n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that implements the \"approximate_match\".\n*/\nstatic sqlite3_module amatchModule = {\n  0,                      /* iVersion */\n  amatchConnect,          /* xCreate */\n  amatchConnect,          /* xConnect */\n  amatchBestIndex,        /* xBestIndex */\n  amatchDisconnect,       /* xDisconnect */\n  amatchDisconnect,       /* xDestroy */\n  amatchOpen,             /* xOpen - open a cursor */\n  amatchClose,            /* xClose - close a cursor */\n  amatchFilter,           /* xFilter - configure scan constraints */\n  amatchNext,             /* xNext - advance a cursor */\n  amatchEof,              /* xEof - check for end of scan */\n  amatchColumn,           /* xColumn - read data */\n  amatchRowid,            /* xRowid - read data */\n  amatchUpdate,           /* xUpdate */\n  0,                      /* xBegin */\n  0,                      /* xSync */\n  0,                      /* xCommit */\n  0,                      /* xRollback */\n  0,                      /* xFindMethod */\n  0,                      /* xRename */\n  0,                      /* xSavepoint */\n  0,                      /* xRelease */\n  0                       /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Register the amatch virtual table\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_amatch_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Not used */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"approximate_match\", &amatchModule, 0);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/anycollseq.c",
    "content": "/*\n** 2017-04-16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a run-time loadable extension to SQLite that\n** registers a sqlite3_collation_needed() callback to register a fake\n** collating function for any unknown collating sequence.  The fake\n** collating function works like BINARY.\n**\n** This extension can be used to load schemas that contain one or more\n** unknown collating sequences.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <string.h>\n\nstatic int anyCollFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ) rc = nKey1 - nKey2;\n  return rc;\n}\n\nstatic void anyCollNeeded(\n  void *NotUsed,\n  sqlite3 *db,\n  int eTextRep,\n  const char *zCollName\n){\n  sqlite3_create_collation(db, zCollName, eTextRep, 0, anyCollFunc); \n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_anycollseq_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_collation_needed(db, 0, anyCollNeeded);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/carray.c",
    "content": "/*\n** 2016-06-29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates how to create a table-valued-function that\n** returns the values in a C-language array.\n** Examples:\n**\n**      SELECT * FROM carray($ptr,5)\n**\n** The query above returns 5 integers contained in a C-language array\n** at the address $ptr.  $ptr is a pointer to the array of integers.\n** The pointer value must be assigned to $ptr using the\n** sqlite3_bind_pointer() interface with a pointer type of \"carray\".\n** For example:\n**\n**    static int aX[] = { 53, 9, 17, 2231, 4, 99 };\n**    int i = sqlite3_bind_parameter_index(pStmt, \"$ptr\");\n**    sqlite3_bind_value(pStmt, i, aX, \"carray\", 0);\n**\n** There is an optional third parameter to determine the datatype of\n** the C-language array.  Allowed values of the third parameter are\n** 'int32', 'int64', 'double', 'char*'.  Example:\n**\n**      SELECT * FROM carray($ptr,10,'char*');\n**\n** The default value of the third parameter is 'int32'.\n**\n** HOW IT WORKS\n**\n** The carray \"function\" is really a virtual table with the\n** following schema:\n**\n**     CREATE TABLE carray(\n**       value,\n**       pointer HIDDEN,\n**       count HIDDEN,\n**       ctype TEXT HIDDEN\n**     );\n**\n** If the hidden columns \"pointer\" and \"count\" are unconstrained, then \n** the virtual table has no rows.  Otherwise, the virtual table interprets\n** the integer value of \"pointer\" as a pointer to the array and \"count\"\n** as the number of elements in the array.  The virtual table steps through\n** the array, element by element.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Allowed datatypes\n*/\n#define CARRAY_INT32    0\n#define CARRAY_INT64    1\n#define CARRAY_DOUBLE   2\n#define CARRAY_TEXT     3\n\n/*\n** Names of types\n*/\nstatic const char *azType[] = { \"int32\", \"int64\", \"double\", \"char*\" };\n\n\n/* carray_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct carray_cursor carray_cursor;\nstruct carray_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3_int64 iRowid;      /* The rowid */\n  void *pPtr;                /* Pointer to the array of values */\n  sqlite3_int64 iCnt;        /* Number of integers in the array */\n  unsigned char eType;       /* One of the CARRAY_type values */\n};\n\n/*\n** The carrayConnect() method is invoked to create a new\n** carray_vtab that describes the carray virtual table.\n**\n** Think of this routine as the constructor for carray_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the carray_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against carray will look like.\n*/\nstatic int carrayConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define CARRAY_COLUMN_VALUE   0\n#define CARRAY_COLUMN_POINTER 1\n#define CARRAY_COLUMN_COUNT   2\n#define CARRAY_COLUMN_CTYPE   3\n\n  rc = sqlite3_declare_vtab(db,\n     \"CREATE TABLE x(value,pointer hidden,count hidden,ctype hidden)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for carray_cursor objects.\n*/\nstatic int carrayDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new carray_cursor object.\n*/\nstatic int carrayOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  carray_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a carray_cursor.\n*/\nstatic int carrayClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a carray_cursor to its next row of output.\n*/\nstatic int carrayNext(sqlite3_vtab_cursor *cur){\n  carray_cursor *pCur = (carray_cursor*)cur;\n  pCur->iRowid++;\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the carray_cursor\n** is currently pointing.\n*/\nstatic int carrayColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  carray_cursor *pCur = (carray_cursor*)cur;\n  sqlite3_int64 x = 0;\n  switch( i ){\n    case CARRAY_COLUMN_POINTER:   return SQLITE_OK;\n    case CARRAY_COLUMN_COUNT:     x = pCur->iCnt;   break;\n    case CARRAY_COLUMN_CTYPE: {\n      sqlite3_result_text(ctx, azType[pCur->eType], -1, SQLITE_STATIC);\n      return SQLITE_OK;\n    }\n    default: {\n      switch( pCur->eType ){\n        case CARRAY_INT32: {\n          int *p = (int*)pCur->pPtr;\n          sqlite3_result_int(ctx, p[pCur->iRowid-1]);\n          return SQLITE_OK;\n        }\n        case CARRAY_INT64: {\n          sqlite3_int64 *p = (sqlite3_int64*)pCur->pPtr;\n          sqlite3_result_int64(ctx, p[pCur->iRowid-1]);\n          return SQLITE_OK;\n        }\n        case CARRAY_DOUBLE: {\n          double *p = (double*)pCur->pPtr;\n          sqlite3_result_double(ctx, p[pCur->iRowid-1]);\n          return SQLITE_OK;\n        }\n        case CARRAY_TEXT: {\n          const char **p = (const char**)pCur->pPtr;\n          sqlite3_result_text(ctx, p[pCur->iRowid-1], -1, SQLITE_TRANSIENT);\n          return SQLITE_OK;\n        }\n      }\n    }\n  }\n  sqlite3_result_int64(ctx, x);\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int carrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  carray_cursor *pCur = (carray_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int carrayEof(sqlite3_vtab_cursor *cur){\n  carray_cursor *pCur = (carray_cursor*)cur;\n  return pCur->iRowid>pCur->iCnt;\n}\n\n/*\n** This method is called to \"rewind\" the carray_cursor object back\n** to the first row of output.\n*/\nstatic int carrayFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  carray_cursor *pCur = (carray_cursor *)pVtabCursor;\n  if( idxNum ){\n    pCur->pPtr = sqlite3_value_pointer(argv[0], \"carray\");\n    pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0;\n    if( idxNum<3 ){\n      pCur->eType = CARRAY_INT32;\n    }else{\n      unsigned char i;\n      const char *zType = (const char*)sqlite3_value_text(argv[2]);\n      for(i=0; i<sizeof(azType)/sizeof(azType[0]); i++){\n        if( sqlite3_stricmp(zType, azType[i])==0 ) break;\n      }\n      if( i>=sizeof(azType)/sizeof(azType[0]) ){\n        pVtabCursor->pVtab->zErrMsg = sqlite3_mprintf(\n          \"unknown datatype: %Q\", zType);\n        return SQLITE_ERROR;\n      }else{\n        pCur->eType = i;\n      }\n    }\n  }else{\n    pCur->pPtr = 0;\n    pCur->iCnt = 0;\n  }\n  pCur->iRowid = 1;\n  return SQLITE_OK;\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the carray virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n**\n** In this implementation idxNum is used to represent the\n** query plan.  idxStr is unused.\n**\n** idxNum is 2 if the pointer= and count= constraints exist,\n** 3 if the ctype= constraint also exists, and is 0 otherwise.\n** If idxNum is 0, then carray becomes an empty table.\n*/\nstatic int carrayBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                 /* Loop over constraints */\n  int ptrIdx = -1;       /* Index of the pointer= constraint, or -1 if none */\n  int cntIdx = -1;       /* Index of the count= constraint, or -1 if none */\n  int ctypeIdx = -1;     /* Index of the ctype= constraint, or -1 if none */\n\n  const struct sqlite3_index_constraint *pConstraint;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case CARRAY_COLUMN_POINTER:\n        ptrIdx = i;\n        break;\n      case CARRAY_COLUMN_COUNT:\n        cntIdx = i;\n        break;\n      case CARRAY_COLUMN_CTYPE:\n        ctypeIdx = i;\n        break;\n    }\n  }\n  if( ptrIdx>=0 && cntIdx>=0 ){\n    pIdxInfo->aConstraintUsage[ptrIdx].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[ptrIdx].omit = 1;\n    pIdxInfo->aConstraintUsage[cntIdx].argvIndex = 2;\n    pIdxInfo->aConstraintUsage[cntIdx].omit = 1;\n    pIdxInfo->estimatedCost = (double)1;\n    pIdxInfo->estimatedRows = 100;\n    pIdxInfo->idxNum = 2;\n    if( ctypeIdx>=0 ){\n      pIdxInfo->aConstraintUsage[ctypeIdx].argvIndex = 3;\n      pIdxInfo->aConstraintUsage[ctypeIdx].omit = 1;\n      pIdxInfo->idxNum = 3;\n    }\n  }else{\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n    pIdxInfo->idxNum = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** carray virtual table.\n*/\nstatic sqlite3_module carrayModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  carrayConnect,             /* xConnect */\n  carrayBestIndex,           /* xBestIndex */\n  carrayDisconnect,          /* xDisconnect */\n  0,                         /* xDestroy */\n  carrayOpen,                /* xOpen - open a cursor */\n  carrayClose,               /* xClose - close a cursor */\n  carrayFilter,              /* xFilter - configure scan constraints */\n  carrayNext,                /* xNext - advance a cursor */\n  carrayEof,                 /* xEof - check for end of scan */\n  carrayColumn,              /* xColumn - read data */\n  carrayRowid,               /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n};\n\n/*\n** For testing purpose in the TCL test harness, we need a method for\n** setting the pointer value.  The inttoptr(X) SQL function accomplishes\n** this.  Tcl script will bind an integer to X and the inttoptr() SQL\n** function will use sqlite3_result_pointer() to convert that integer into\n** a pointer.\n**\n** This is for testing on TCL only.\n*/\n#ifdef SQLITE_TEST\nstatic void inttoptrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  void *p;\n  sqlite3_int64 i64;\n  i64 = sqlite3_value_int64(argv[0]);\n  if( sizeof(i64)==sizeof(p) ){\n    memcpy(&p, &i64, sizeof(p));\n  }else{\n    int i32 = i64 & 0xffffffff;\n    memcpy(&p, &i32, sizeof(p));\n  }\n  sqlite3_result_pointer(context, p, \"carray\", 0);\n}\n#endif /* SQLITE_TEST */\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_carray_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"carray\", &carrayModule, 0);\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"inttoptr\", 1, SQLITE_UTF8, 0,\n                                 inttoptrFunc, 0, 0);\n  }\n#endif /* SQLITE_TEST */\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/closure.c",
    "content": "/*\n** 2013-04-16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code for a virtual table that finds the transitive\n** closure of a parent/child relationship in a real table.  The virtual \n** table is called \"transitive_closure\".\n**\n** A transitive_closure virtual table is created like this:\n**\n**     CREATE VIRTUAL TABLE x USING transitive_closure(\n**        tablename=<tablename>,      -- T\n**        idcolumn=<columnname>,      -- X\n**        parentcolumn=<columnname>   -- P\n**     );\n**\n** When it is created, the new transitive_closure table may be supplied \n** with default values for the name of a table T and columns T.X and T.P.\n** The T.X and T.P columns must contain integers.  The ideal case is for \n** T.X to be the INTEGER PRIMARY KEY.  The T.P column should reference\n** the T.X column. The row referenced by T.P is the parent of the current row.\n**\n** The tablename, idcolumn, and parentcolumn supplied by the CREATE VIRTUAL\n** TABLE statement may be overridden in individual queries by including\n** terms like tablename='newtable', idcolumn='id2', or \n** parentcolumn='parent3' in the WHERE clause of the query.\n**\n** For efficiency, it is essential that there be an index on the P column:\n**\n**    CREATE Tidx1 ON T(P)\n**\n** Suppose a specific instance of the closure table is as follows:\n**\n**    CREATE VIRTUAL TABLE ct1 USING transitive_closure(\n**       tablename='group',\n**       idcolumn='groupId',\n**       parentcolumn='parentId'\n**    );\n**\n** Such an instance of the transitive_closure virtual table would be\n** appropriate for walking a tree defined using a table like this, for example:\n**\n**    CREATE TABLE group(\n**      groupId INTEGER PRIMARY KEY,\n**      parentId INTEGER REFERENCES group\n**    );\n**    CREATE INDEX group_idx1 ON group(parentId);\n**\n** The group table above would presumably have other application-specific\n** fields.  The key point here is that rows of the group table form a\n** tree.  The purpose of the ct1 virtual table is to easily extract\n** branches of that tree.\n**\n** Once it has been created, the ct1 virtual table can be queried\n** as follows:\n**\n**    SELECT * FROM element\n**     WHERE element.groupId IN (SELECT id FROM ct1 WHERE root=?1);\n**\n** The above query will return all elements that are part of group ?1\n** or children of group ?1 or grand-children of ?1 and so forth for all\n** descendents of group ?1.  The same query can be formulated as a join:\n**\n**    SELECT element.* FROM element, ct1\n**     WHERE element.groupid=ct1.id\n**       AND ct1.root=?1;\n**\n** The depth of the transitive_closure (the number of generations of\n** parent/child relations to follow) can be limited by setting \"depth\"\n** column in the WHERE clause.  So, for example, the following query\n** finds only children and grandchildren but no further descendents:\n**\n**    SELECT element.* FROM element, ct1\n**     WHERE element.groupid=ct1.id\n**       AND ct1.root=?1\n**       AND ct1.depth<=2;\n**\n** The \"ct1.depth<=2\" term could be a strict equality \"ct1.depth=2\" in\n** order to find only the grandchildren of ?1, not ?1 itself or the\n** children of ?1.\n** \n** The root=?1 term must be supplied in WHERE clause or else the query\n** of the ct1 virtual table will return an empty set.  The tablename,\n** idcolumn, and parentcolumn attributes can be overridden in the WHERE\n** clause if desired.  So, for example, the ct1 table could be repurposed\n** to find ancestors rather than descendents by inverting the roles of\n** the idcolumn and parentcolumn:\n**\n**    SELECT element.* FROM element, ct1\n**     WHERE element.groupid=ct1.id\n**       AND ct1.root=?1\n**       AND ct1.idcolumn='parentId'\n**       AND ct1.parentcolumn='groupId';\n**\n** Multiple calls to ct1 could be combined.  For example, the following\n** query finds all elements that \"cousins\" of groupId ?1.  That is to say\n** elements where the groupId is a grandchild of the grandparent of ?1.\n** (This definition of \"cousins\" also includes siblings and self.)\n**\n**    SELECT element.* FROM element, ct1\n**     WHERE element.groupId=ct1.id\n**       AND ct1.depth=2\n**       AND ct1.root IN (SELECT id FROM ct1\n**                         WHERE root=?1\n**                           AND depth=2\n**                           AND idcolumn='parentId'\n**                           AND parentcolumn='groupId');\n**\n** In our example, the group.groupId column is unique and thus the\n** subquery will return exactly one row.  For that reason, the IN\n** operator could be replaced by \"=\" to get the same result.  But\n** in the general case where the idcolumn is not unique, an IN operator\n** would be required for this kind of query.\n**\n** Note that because the tablename, idcolumn, and parentcolumn can\n** all be specified in the query, it is possible for an application\n** to define a single transitive_closure virtual table for use on lots\n** of different hierarchy tables.  One might say:\n**\n**     CREATE VIRTUAL TABLE temp.closure USING transitive_closure;\n**\n** As each database connection is being opened.  Then the application\n** would always have a \"closure\" virtual table handy to use for querying.\n**\n**    SELECT element.* FROM element, closure\n**     WHERE element.groupid=ct1.id\n**       AND closure.root=?1\n**       AND closure.tablename='group'\n**       AND closure.idname='groupId'\n**       AND closure.parentname='parentId';\n**\n** See the documentation at http://www.sqlite.org/loadext.html for information\n** on how to compile and use loadable extensions such as this one.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stdio.h>\n#include <ctype.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Forward declaration of objects used by this implementation\n*/\ntypedef struct closure_vtab closure_vtab;\ntypedef struct closure_cursor closure_cursor;\ntypedef struct closure_queue closure_queue;\ntypedef struct closure_avl closure_avl;\n\n/*****************************************************************************\n** AVL Tree implementation\n*/\n/*\n** Objects that want to be members of the AVL tree should embedded an\n** instance of this structure.\n*/\nstruct closure_avl {\n  sqlite3_int64 id;     /* Id of this entry in the table */\n  int iGeneration;      /* Which generation is this entry part of */\n  closure_avl *pList;   /* A linked list of nodes */\n  closure_avl *pBefore; /* Other elements less than id */\n  closure_avl *pAfter;  /* Other elements greater than id */\n  closure_avl *pUp;     /* Parent element */\n  short int height;     /* Height of this node.  Leaf==1 */\n  short int imbalance;  /* Height difference between pBefore and pAfter */\n};\n\n/* Recompute the closure_avl.height and closure_avl.imbalance fields for p.\n** Assume that the children of p have correct heights.\n*/\nstatic void closureAvlRecomputeHeight(closure_avl *p){\n  short int hBefore = p->pBefore ? p->pBefore->height : 0;\n  short int hAfter = p->pAfter ? p->pAfter->height : 0;\n  p->imbalance = hBefore - hAfter;  /* -: pAfter higher.  +: pBefore higher */\n  p->height = (hBefore>hAfter ? hBefore : hAfter)+1;\n}\n\n/*\n**     P                B\n**    / \\              / \\\n**   B   Z    ==>     X   P\n**  / \\                  / \\\n** X   Y                Y   Z\n**\n*/\nstatic closure_avl *closureAvlRotateBefore(closure_avl *pP){\n  closure_avl *pB = pP->pBefore;\n  closure_avl *pY = pB->pAfter;\n  pB->pUp = pP->pUp;\n  pB->pAfter = pP;\n  pP->pUp = pB;\n  pP->pBefore = pY;\n  if( pY ) pY->pUp = pP;\n  closureAvlRecomputeHeight(pP);\n  closureAvlRecomputeHeight(pB);\n  return pB;\n}\n\n/*\n**     P                A\n**    / \\              / \\\n**   X   A    ==>     P   Z\n**      / \\          / \\\n**     Y   Z        X   Y\n**\n*/\nstatic closure_avl *closureAvlRotateAfter(closure_avl *pP){\n  closure_avl *pA = pP->pAfter;\n  closure_avl *pY = pA->pBefore;\n  pA->pUp = pP->pUp;\n  pA->pBefore = pP;\n  pP->pUp = pA;\n  pP->pAfter = pY;\n  if( pY ) pY->pUp = pP;\n  closureAvlRecomputeHeight(pP);\n  closureAvlRecomputeHeight(pA);\n  return pA;\n}\n\n/*\n** Return a pointer to the pBefore or pAfter pointer in the parent\n** of p that points to p.  Or if p is the root node, return pp.\n*/\nstatic closure_avl **closureAvlFromPtr(closure_avl *p, closure_avl **pp){\n  closure_avl *pUp = p->pUp;\n  if( pUp==0 ) return pp;\n  if( pUp->pAfter==p ) return &pUp->pAfter;\n  return &pUp->pBefore;\n}\n\n/*\n** Rebalance all nodes starting with p and working up to the root.\n** Return the new root.\n*/\nstatic closure_avl *closureAvlBalance(closure_avl *p){\n  closure_avl *pTop = p;\n  closure_avl **pp;\n  while( p ){\n    closureAvlRecomputeHeight(p);\n    if( p->imbalance>=2 ){\n      closure_avl *pB = p->pBefore;\n      if( pB->imbalance<0 ) p->pBefore = closureAvlRotateAfter(pB);\n      pp = closureAvlFromPtr(p,&p);\n      p = *pp = closureAvlRotateBefore(p);\n    }else if( p->imbalance<=(-2) ){\n      closure_avl *pA = p->pAfter;\n      if( pA->imbalance>0 ) p->pAfter = closureAvlRotateBefore(pA);\n      pp = closureAvlFromPtr(p,&p);\n      p = *pp = closureAvlRotateAfter(p);\n    }\n    pTop = p;\n    p = p->pUp;\n  }\n  return pTop;\n}\n\n/* Search the tree rooted at p for an entry with id.  Return a pointer\n** to the entry or return NULL.\n*/\nstatic closure_avl *closureAvlSearch(closure_avl *p, sqlite3_int64 id){\n  while( p && id!=p->id ){\n    p = (id<p->id) ? p->pBefore : p->pAfter;\n  }\n  return p;\n}\n\n/* Find the first node (the one with the smallest key).\n*/\nstatic closure_avl *closureAvlFirst(closure_avl *p){\n  if( p ) while( p->pBefore ) p = p->pBefore;\n  return p;\n}\n\n/* Return the node with the next larger key after p.\n*/\nclosure_avl *closureAvlNext(closure_avl *p){\n  closure_avl *pPrev = 0;\n  while( p && p->pAfter==pPrev ){\n    pPrev = p;\n    p = p->pUp;\n  }\n  if( p && pPrev==0 ){\n    p = closureAvlFirst(p->pAfter);\n  }\n  return p;\n}\n\n/* Insert a new node pNew.  Return NULL on success.  If the key is not\n** unique, then do not perform the insert but instead leave pNew unchanged\n** and return a pointer to an existing node with the same key.\n*/\nstatic closure_avl *closureAvlInsert(\n  closure_avl **ppHead,  /* Head of the tree */\n  closure_avl *pNew      /* New node to be inserted */\n){\n  closure_avl *p = *ppHead;\n  if( p==0 ){\n    p = pNew;\n    pNew->pUp = 0;\n  }else{\n    while( p ){\n      if( pNew->id<p->id ){\n        if( p->pBefore ){\n          p = p->pBefore;\n        }else{\n          p->pBefore = pNew;\n          pNew->pUp = p;\n          break;\n        }\n      }else if( pNew->id>p->id ){\n        if( p->pAfter ){\n          p = p->pAfter;\n        }else{\n          p->pAfter = pNew;\n          pNew->pUp = p;\n          break;\n        }\n      }else{\n        return p;\n      }\n    }\n  }\n  pNew->pBefore = 0;\n  pNew->pAfter = 0;\n  pNew->height = 1;\n  pNew->imbalance = 0;\n  *ppHead = closureAvlBalance(p);\n  return 0;\n}\n\n/* Walk the tree can call xDestroy on each node\n*/\nstatic void closureAvlDestroy(closure_avl *p, void (*xDestroy)(closure_avl*)){\n  if( p ){\n    closureAvlDestroy(p->pBefore, xDestroy);\n    closureAvlDestroy(p->pAfter, xDestroy);\n    xDestroy(p);\n  }\n}\n/*\n** End of the AVL Tree implementation\n******************************************************************************/\n\n/* \n** A closure virtual-table object \n*/\nstruct closure_vtab {\n  sqlite3_vtab base;         /* Base class - must be first */\n  char *zDb;                 /* Name of database.  (ex: \"main\") */\n  char *zSelf;               /* Name of this virtual table */\n  char *zTableName;          /* Name of table holding parent/child relation */\n  char *zIdColumn;           /* Name of ID column of zTableName */\n  char *zParentColumn;       /* Name of PARENT column in zTableName */\n  sqlite3 *db;               /* The database connection */\n  int nCursor;               /* Number of pending cursors */\n};\n\n/* A closure cursor object */\nstruct closure_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  closure_vtab *pVtab;       /* The virtual table this cursor belongs to */\n  char *zTableName;          /* Name of table holding parent/child relation */\n  char *zIdColumn;           /* Name of ID column of zTableName */\n  char *zParentColumn;       /* Name of PARENT column in zTableName */\n  closure_avl *pCurrent;     /* Current element of output */\n  closure_avl *pClosure;     /* The complete closure tree */\n};\n\n/* A queue of AVL nodes */\nstruct closure_queue {\n  closure_avl *pFirst;       /* Oldest node on the queue */\n  closure_avl *pLast;        /* Youngest node on the queue */\n};\n\n/*\n** Add a node to the end of the queue\n*/\nstatic void queuePush(closure_queue *pQueue, closure_avl *pNode){\n  pNode->pList = 0;\n  if( pQueue->pLast ){\n    pQueue->pLast->pList = pNode;\n  }else{\n    pQueue->pFirst = pNode;\n  }\n  pQueue->pLast = pNode;\n}\n\n/*\n** Extract the oldest element (the front element) from the queue.\n*/\nstatic closure_avl *queuePull(closure_queue *pQueue){\n  closure_avl *p = pQueue->pFirst;\n  if( p ){\n    pQueue->pFirst = p->pList;\n    if( pQueue->pFirst==0 ) pQueue->pLast = 0;\n  }\n  return p;\n}\n\n/*\n** This function converts an SQL quoted string into an unquoted string\n** and returns a pointer to a buffer allocated using sqlite3_malloc() \n** containing the result. The caller should eventually free this buffer\n** using sqlite3_free.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic char *closureDequote(const char *zIn){\n  int nIn;                        /* Size of input string, in bytes */\n  char *zOut;                     /* Output (dequoted) string */\n\n  nIn = (int)strlen(zIn);\n  zOut = sqlite3_malloc(nIn+1);\n  if( zOut ){\n    char q = zIn[0];              /* Quote character (if any ) */\n\n    if( q!='[' && q!= '\\'' && q!='\"' && q!='`' ){\n      memcpy(zOut, zIn, nIn+1);\n    }else{\n      int iOut = 0;               /* Index of next byte to write to output */\n      int iIn;                    /* Index of next byte to read from input */\n\n      if( q=='[' ) q = ']';\n      for(iIn=1; iIn<nIn; iIn++){\n        if( zIn[iIn]==q ) iIn++;\n        zOut[iOut++] = zIn[iIn];\n      }\n    }\n    assert( (int)strlen(zOut)<=nIn );\n  }\n  return zOut;\n}\n\n/*\n** Deallocate an closure_vtab object\n*/\nstatic void closureFree(closure_vtab *p){\n  if( p ){\n    sqlite3_free(p->zDb);\n    sqlite3_free(p->zSelf);\n    sqlite3_free(p->zTableName);\n    sqlite3_free(p->zIdColumn);\n    sqlite3_free(p->zParentColumn);\n    memset(p, 0, sizeof(*p));\n    sqlite3_free(p);\n  }\n}\n\n/*\n** xDisconnect/xDestroy method for the closure module.\n*/\nstatic int closureDisconnect(sqlite3_vtab *pVtab){\n  closure_vtab *p = (closure_vtab*)pVtab;\n  assert( p->nCursor==0 );\n  closureFree(p);\n  return SQLITE_OK;\n}\n\n/*\n** Check to see if the argument is of the form:\n**\n**       KEY = VALUE\n**\n** If it is, return a pointer to the first character of VALUE.\n** If not, return NULL.  Spaces around the = are ignored.\n*/\nstatic const char *closureValueOfKey(const char *zKey, const char *zStr){\n  int nKey = (int)strlen(zKey);\n  int nStr = (int)strlen(zStr);\n  int i;\n  if( nStr<nKey+1 ) return 0;\n  if( memcmp(zStr, zKey, nKey)!=0 ) return 0;\n  for(i=nKey; isspace((unsigned char)zStr[i]); i++){}\n  if( zStr[i]!='=' ) return 0;\n  i++;\n  while( isspace((unsigned char)zStr[i]) ){ i++; }\n  return zStr+i;\n}\n\n/*\n** xConnect/xCreate method for the closure module. Arguments are:\n**\n**   argv[0]    -> module name  (\"transitive_closure\")\n**   argv[1]    -> database name\n**   argv[2]    -> table name\n**   argv[3...] -> arguments\n*/\nstatic int closureConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc = SQLITE_OK;              /* Return code */\n  closure_vtab *pNew = 0;          /* New virtual table */\n  const char *zDb = argv[1];\n  const char *zVal;\n  int i;\n\n  (void)pAux;\n  *ppVtab = 0;\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return SQLITE_NOMEM;\n  rc = SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(*pNew));\n  pNew->db = db;\n  pNew->zDb = sqlite3_mprintf(\"%s\", zDb);\n  if( pNew->zDb==0 ) goto closureConnectError;\n  pNew->zSelf = sqlite3_mprintf(\"%s\", argv[2]);\n  if( pNew->zSelf==0 ) goto closureConnectError;\n  for(i=3; i<argc; i++){\n    zVal = closureValueOfKey(\"tablename\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zTableName);\n      pNew->zTableName = closureDequote(zVal);\n      if( pNew->zTableName==0 ) goto closureConnectError;\n      continue;\n    }\n    zVal = closureValueOfKey(\"idcolumn\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zIdColumn);\n      pNew->zIdColumn = closureDequote(zVal);\n      if( pNew->zIdColumn==0 ) goto closureConnectError;\n      continue;\n    }\n    zVal = closureValueOfKey(\"parentcolumn\", argv[i]);\n    if( zVal ){\n      sqlite3_free(pNew->zParentColumn);\n      pNew->zParentColumn = closureDequote(zVal);\n      if( pNew->zParentColumn==0 ) goto closureConnectError;\n      continue;\n    }\n    *pzErr = sqlite3_mprintf(\"unrecognized argument: [%s]\\n\", argv[i]);\n    closureFree(pNew);\n    *ppVtab = 0;\n    return SQLITE_ERROR;\n  }\n  rc = sqlite3_declare_vtab(db,\n         \"CREATE TABLE x(id,depth,root HIDDEN,tablename HIDDEN,\"\n                        \"idcolumn HIDDEN,parentcolumn HIDDEN)\"\n       );\n#define CLOSURE_COL_ID              0\n#define CLOSURE_COL_DEPTH           1\n#define CLOSURE_COL_ROOT            2\n#define CLOSURE_COL_TABLENAME       3\n#define CLOSURE_COL_IDCOLUMN        4\n#define CLOSURE_COL_PARENTCOLUMN    5\n  if( rc!=SQLITE_OK ){\n    closureFree(pNew);\n  }\n  *ppVtab = &pNew->base;\n  return rc;\n\nclosureConnectError:\n  closureFree(pNew);\n  return rc;\n}\n\n/*\n** Open a new closure cursor.\n*/\nstatic int closureOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  closure_vtab *p = (closure_vtab*)pVTab;\n  closure_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->pVtab = p;\n  *ppCursor = &pCur->base;\n  p->nCursor++;\n  return SQLITE_OK;\n}\n\n/*\n** Free up all the memory allocated by a cursor.  Set it rLimit to 0\n** to indicate that it is at EOF.\n*/\nstatic void closureClearCursor(closure_cursor *pCur){\n  closureAvlDestroy(pCur->pClosure, (void(*)(closure_avl*))sqlite3_free);\n  sqlite3_free(pCur->zTableName);\n  sqlite3_free(pCur->zIdColumn);\n  sqlite3_free(pCur->zParentColumn);\n  pCur->zTableName = 0;\n  pCur->zIdColumn = 0;\n  pCur->zParentColumn = 0;\n  pCur->pCurrent = 0;\n  pCur->pClosure = 0;\n}\n\n/*\n** Close a closure cursor.\n*/\nstatic int closureClose(sqlite3_vtab_cursor *cur){\n  closure_cursor *pCur = (closure_cursor *)cur;\n  closureClearCursor(pCur);\n  pCur->pVtab->nCursor--;\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Advance a cursor to its next row of output\n*/\nstatic int closureNext(sqlite3_vtab_cursor *cur){\n  closure_cursor *pCur = (closure_cursor*)cur;\n  pCur->pCurrent = closureAvlNext(pCur->pCurrent);\n  return SQLITE_OK;\n}\n\n/*\n** Allocate and insert a node\n*/\nstatic int closureInsertNode(\n  closure_queue *pQueue,  /* Add new node to this queue */\n  closure_cursor *pCur,   /* The cursor into which to add the node */\n  sqlite3_int64 id,       /* The node ID */\n  int iGeneration         /* The generation number for this node */\n){\n  closure_avl *pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(*pNew));\n  pNew->id = id;\n  pNew->iGeneration = iGeneration;\n  closureAvlInsert(&pCur->pClosure, pNew);\n  queuePush(pQueue, pNew);\n  return SQLITE_OK;\n}\n\n/*\n** Called to \"rewind\" a cursor back to the beginning so that\n** it starts its output over again.  Always called at least once\n** prior to any closureColumn, closureRowid, or closureEof call.\n**\n** This routine actually computes the closure.\n**\n** See the comment at the beginning of closureBestIndex() for a \n** description of the meaning of idxNum.  The idxStr parameter is\n** not used.\n*/\nstatic int closureFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  closure_cursor *pCur = (closure_cursor *)pVtabCursor;\n  closure_vtab *pVtab = pCur->pVtab;\n  sqlite3_int64 iRoot;\n  int mxGen = 999999999;\n  char *zSql;\n  sqlite3_stmt *pStmt;\n  closure_avl *pAvl;\n  int rc = SQLITE_OK;\n  const char *zTableName = pVtab->zTableName;\n  const char *zIdColumn = pVtab->zIdColumn;\n  const char *zParentColumn = pVtab->zParentColumn;\n  closure_queue sQueue;\n\n  (void)idxStr;  /* Unused parameter */\n  (void)argc;    /* Unused parameter */\n  closureClearCursor(pCur);\n  memset(&sQueue, 0, sizeof(sQueue));\n  if( (idxNum & 1)==0 ){\n    /* No root=$root in the WHERE clause.  Return an empty set */\n    return SQLITE_OK;\n  }\n  iRoot = sqlite3_value_int64(argv[0]);\n  if( (idxNum & 0x000f0)!=0 ){\n    mxGen = sqlite3_value_int(argv[(idxNum>>4)&0x0f]);\n    if( (idxNum & 0x00002)!=0 ) mxGen--;\n  }\n  if( (idxNum & 0x00f00)!=0 ){\n    zTableName = (const char*)sqlite3_value_text(argv[(idxNum>>8)&0x0f]);\n    pCur->zTableName = sqlite3_mprintf(\"%s\", zTableName);\n  }\n  if( (idxNum & 0x0f000)!=0 ){\n    zIdColumn = (const char*)sqlite3_value_text(argv[(idxNum>>12)&0x0f]);\n    pCur->zIdColumn = sqlite3_mprintf(\"%s\", zIdColumn);\n  }\n  if( (idxNum & 0x0f0000)!=0 ){\n    zParentColumn = (const char*)sqlite3_value_text(argv[(idxNum>>16)&0x0f]);\n    pCur->zParentColumn = sqlite3_mprintf(\"%s\", zParentColumn);\n  }\n\n  zSql = sqlite3_mprintf(\n       \"SELECT \\\"%w\\\".\\\"%w\\\" FROM \\\"%w\\\" WHERE \\\"%w\\\".\\\"%w\\\"=?1\",\n       zTableName, zIdColumn, zTableName, zTableName, zParentColumn);\n  if( zSql==0 ){\n    return SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare_v2(pVtab->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      sqlite3_free(pVtab->base.zErrMsg);\n      pVtab->base.zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pVtab->db));\n      return rc;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = closureInsertNode(&sQueue, pCur, iRoot, 0);\n  }\n  while( (pAvl = queuePull(&sQueue))!=0 ){\n    if( pAvl->iGeneration>=mxGen ) continue;\n    sqlite3_bind_int64(pStmt, 1, pAvl->id);\n    while( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){\n      if( sqlite3_column_type(pStmt,0)==SQLITE_INTEGER ){\n        sqlite3_int64 iNew = sqlite3_column_int64(pStmt, 0);\n        if( closureAvlSearch(pCur->pClosure, iNew)==0 ){\n          rc = closureInsertNode(&sQueue, pCur, iNew, pAvl->iGeneration+1);\n        }\n      }\n    }\n    sqlite3_reset(pStmt);\n  }\n  sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ){\n    pCur->pCurrent = closureAvlFirst(pCur->pClosure);\n  }\n\n  return rc;\n}\n\n/*\n** Only the word and distance columns have values.  All other columns\n** return NULL\n*/\nstatic int closureColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  closure_cursor *pCur = (closure_cursor*)cur;\n  switch( i ){\n    case CLOSURE_COL_ID: {\n      sqlite3_result_int64(ctx, pCur->pCurrent->id);\n      break;\n    }\n    case CLOSURE_COL_DEPTH: {\n      sqlite3_result_int(ctx, pCur->pCurrent->iGeneration);\n      break;\n    }\n    case CLOSURE_COL_ROOT: {\n      sqlite3_result_null(ctx);\n      break;\n    }\n    case CLOSURE_COL_TABLENAME: {\n      sqlite3_result_text(ctx,\n         pCur->zTableName ? pCur->zTableName : pCur->pVtab->zTableName,\n         -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case CLOSURE_COL_IDCOLUMN: {\n      sqlite3_result_text(ctx,\n         pCur->zIdColumn ? pCur->zIdColumn : pCur->pVtab->zIdColumn,\n         -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case CLOSURE_COL_PARENTCOLUMN: {\n      sqlite3_result_text(ctx,\n         pCur->zParentColumn ? pCur->zParentColumn : pCur->pVtab->zParentColumn,\n         -1, SQLITE_TRANSIENT);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The rowid.  For the closure table, this is the same as the \"id\" column.\n*/\nstatic int closureRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  closure_cursor *pCur = (closure_cursor*)cur;\n  *pRowid = pCur->pCurrent->id;\n  return SQLITE_OK;\n}\n\n/*\n** EOF indicator\n*/\nstatic int closureEof(sqlite3_vtab_cursor *cur){\n  closure_cursor *pCur = (closure_cursor*)cur;\n  return pCur->pCurrent==0;\n}\n\n/*\n** Search for terms of these forms:\n**\n**   (A)    root = $root\n**   (B1)   depth < $depth\n**   (B2)   depth <= $depth\n**   (B3)   depth = $depth\n**   (C)    tablename = $tablename\n**   (D)    idcolumn = $idcolumn\n**   (E)    parentcolumn = $parentcolumn\n**\n** \n**\n**   idxNum       meaning\n**   ----------   ------------------------------------------------------\n**   0x00000001   Term of the form (A) found\n**   0x00000002   The term of bit-2 is like (B1)\n**   0x000000f0   Index in filter.argv[] of $depth.  0 if not used.\n**   0x00000f00   Index in filter.argv[] of $tablename.  0 if not used.\n**   0x0000f000   Index in filter.argv[] of $idcolumn.  0 if not used\n**   0x000f0000   Index in filter.argv[] of $parentcolumn.  0 if not used.\n**\n** There must be a term of type (A).  If there is not, then the index type\n** is 0 and the query will return an empty set.\n*/\nstatic int closureBestIndex(\n  sqlite3_vtab *pTab,             /* The virtual table */\n  sqlite3_index_info *pIdxInfo    /* Information about the query */\n){\n  int iPlan = 0;\n  int i;\n  int idx = 1;\n  int seenMatch = 0;\n  const struct sqlite3_index_constraint *pConstraint;\n  closure_vtab *pVtab = (closure_vtab*)pTab;\n  double rCost = 10000000.0;\n\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->iColumn==CLOSURE_COL_ROOT\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      seenMatch = 1;\n    }\n    if( pConstraint->usable==0 ) continue;\n    if( (iPlan & 1)==0 \n     && pConstraint->iColumn==CLOSURE_COL_ROOT\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= 1;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      rCost /= 100.0;\n    }\n    if( (iPlan & 0x0000f0)==0\n     && pConstraint->iColumn==CLOSURE_COL_DEPTH\n     && (pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT\n           || pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE\n           || pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ)\n    ){\n      iPlan |= idx<<4;\n      pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;\n      if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ) iPlan |= 0x000002;\n      rCost /= 5.0;\n    }\n    if( (iPlan & 0x000f00)==0\n     && pConstraint->iColumn==CLOSURE_COL_TABLENAME\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= idx<<8;\n      pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      rCost /= 5.0;\n    }\n    if( (iPlan & 0x00f000)==0\n     && pConstraint->iColumn==CLOSURE_COL_IDCOLUMN\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= idx<<12;\n      pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n    }\n    if( (iPlan & 0x0f0000)==0\n     && pConstraint->iColumn==CLOSURE_COL_PARENTCOLUMN\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= idx<<16;\n      pIdxInfo->aConstraintUsage[i].argvIndex = ++idx;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n    }\n  }\n  if( (pVtab->zTableName==0    && (iPlan & 0x000f00)==0)\n   || (pVtab->zIdColumn==0     && (iPlan & 0x00f000)==0)\n   || (pVtab->zParentColumn==0 && (iPlan & 0x0f0000)==0)\n  ){\n    /* All of tablename, idcolumn, and parentcolumn must be specified\n    ** in either the CREATE VIRTUAL TABLE or in the WHERE clause constraints\n    ** or else the result is an empty set. */\n    iPlan = 0;\n  }\n  pIdxInfo->idxNum = iPlan;\n  if( pIdxInfo->nOrderBy==1\n   && pIdxInfo->aOrderBy[0].iColumn==CLOSURE_COL_ID\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  if( seenMatch && (iPlan&1)==0 ) rCost *= 1e30;\n  pIdxInfo->estimatedCost = rCost;\n   \n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that implements the \"transitive_closure\".\n*/\nstatic sqlite3_module closureModule = {\n  0,                      /* iVersion */\n  closureConnect,         /* xCreate */\n  closureConnect,         /* xConnect */\n  closureBestIndex,       /* xBestIndex */\n  closureDisconnect,      /* xDisconnect */\n  closureDisconnect,      /* xDestroy */\n  closureOpen,            /* xOpen - open a cursor */\n  closureClose,           /* xClose - close a cursor */\n  closureFilter,          /* xFilter - configure scan constraints */\n  closureNext,            /* xNext - advance a cursor */\n  closureEof,             /* xEof - check for end of scan */\n  closureColumn,          /* xColumn - read data */\n  closureRowid,           /* xRowid - read data */\n  0,                      /* xUpdate */\n  0,                      /* xBegin */\n  0,                      /* xSync */\n  0,                      /* xCommit */\n  0,                      /* xRollback */\n  0,                      /* xFindMethod */\n  0,                      /* xRename */\n  0,                      /* xSavepoint */\n  0,                      /* xRelease */\n  0                       /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Register the closure virtual table\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_closure_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"transitive_closure\", &closureModule, 0);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/completion.c",
    "content": "/*\n** 2017-07-10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements an eponymous virtual table that returns suggested\n** completions for a partial SQL input.\n**\n** Suggested usage:\n**\n**     SELECT DISTINCT candidate COLLATE nocase\n**       FROM completion($prefix,$wholeline)\n**      ORDER BY 1;\n**\n** The two query parameters are optional.  $prefix is the text of the\n** current word being typed and that is to be completed.  $wholeline is\n** the complete input line, used for context.\n**\n** The raw completion() table might return the same candidate multiple\n** times, for example if the same column name is used to two or more\n** tables.  And the candidates are returned in an arbitrary order.  Hence,\n** the DISTINCT and ORDER BY are recommended.\n**\n** This virtual table operates at the speed of human typing, and so there\n** is no attempt to make it fast.  Even a slow implementation will be much\n** faster than any human can type.\n**\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <ctype.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* completion_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a completion virtual table\n*/\ntypedef struct completion_vtab completion_vtab;\nstruct completion_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  sqlite3 *db;        /* Database connection for this completion vtab */\n};\n\n/* completion_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct completion_cursor completion_cursor;\nstruct completion_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3 *db;               /* Database connection for this cursor */\n  int nPrefix, nLine;        /* Number of bytes in zPrefix and zLine */\n  char *zPrefix;             /* The prefix for the word we want to complete */\n  char *zLine;               /* The whole that we want to complete */\n  const char *zCurrentRow;   /* Current output row */\n  sqlite3_stmt *pStmt;       /* Current statement */\n  sqlite3_int64 iRowid;      /* The rowid */\n  int ePhase;                /* Current phase */\n  int j;                     /* inter-phase counter */\n};\n\n/* Values for ePhase:\n*/\n#define COMPLETION_FIRST_PHASE   1\n#define COMPLETION_KEYWORDS      1\n#define COMPLETION_PRAGMAS       2\n#define COMPLETION_FUNCTIONS     3\n#define COMPLETION_COLLATIONS    4\n#define COMPLETION_INDEXES       5\n#define COMPLETION_TRIGGERS      6\n#define COMPLETION_DATABASES     7\n#define COMPLETION_TABLES        8\n#define COMPLETION_COLUMNS       9\n#define COMPLETION_MODULES       10\n#define COMPLETION_EOF           11\n\n/*\n** The completionConnect() method is invoked to create a new\n** completion_vtab that describes the completion virtual table.\n**\n** Think of this routine as the constructor for completion_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the completion_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against completion will look like.\n*/\nstatic int completionConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  completion_vtab *pNew;\n  int rc;\n\n  (void)(pAux);    /* Unused parameter */\n  (void)(argc);    /* Unused parameter */\n  (void)(argv);    /* Unused parameter */\n  (void)(pzErr);   /* Unused parameter */\n\n/* Column numbers */\n#define COMPLETION_COLUMN_CANDIDATE 0  /* Suggested completion of the input */\n#define COMPLETION_COLUMN_PREFIX    1  /* Prefix of the word to be completed */\n#define COMPLETION_COLUMN_WHOLELINE 2  /* Entire line seen so far */\n#define COMPLETION_COLUMN_PHASE     3  /* ePhase - used for debugging only */\n\n  rc = sqlite3_declare_vtab(db,\n      \"CREATE TABLE x(\"\n      \"  candidate TEXT,\"\n      \"  prefix TEXT HIDDEN,\"\n      \"  wholeline TEXT HIDDEN,\"\n      \"  phase INT HIDDEN\"        /* Used for debugging only */\n      \")\");\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->db = db;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for completion_cursor objects.\n*/\nstatic int completionDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new completion_cursor object.\n*/\nstatic int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  completion_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->db = ((completion_vtab*)p)->db;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the completion_cursor.\n*/\nstatic void completionCursorReset(completion_cursor *pCur){\n  sqlite3_free(pCur->zPrefix);   pCur->zPrefix = 0;  pCur->nPrefix = 0;\n  sqlite3_free(pCur->zLine);     pCur->zLine = 0;    pCur->nLine = 0;\n  sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;\n  pCur->j = 0;\n}\n\n/*\n** Destructor for a completion_cursor.\n*/\nstatic int completionClose(sqlite3_vtab_cursor *cur){\n  completionCursorReset((completion_cursor*)cur);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/*\n** All SQL keywords understood by SQLite\n*/\nstatic const char *completionKwrds[] = {\n  \"ABORT\", \"ACTION\", \"ADD\", \"AFTER\", \"ALL\", \"ALTER\", \"ANALYZE\", \"AND\", \"AS\",\n  \"ASC\", \"ATTACH\", \"AUTOINCREMENT\", \"BEFORE\", \"BEGIN\", \"BETWEEN\", \"BY\",\n  \"CASCADE\", \"CASE\", \"CAST\", \"CHECK\", \"COLLATE\", \"COLUMN\", \"COMMIT\",\n  \"CONFLICT\", \"CONSTRAINT\", \"CREATE\", \"CROSS\", \"CURRENT_DATE\",\n  \"CURRENT_TIME\", \"CURRENT_TIMESTAMP\", \"DATABASE\", \"DEFAULT\", \"DEFERRABLE\",\n  \"DEFERRED\", \"DELETE\", \"DESC\", \"DETACH\", \"DISTINCT\", \"DROP\", \"EACH\",\n  \"ELSE\", \"END\", \"ESCAPE\", \"EXCEPT\", \"EXCLUSIVE\", \"EXISTS\", \"EXPLAIN\",\n  \"FAIL\", \"FOR\", \"FOREIGN\", \"FROM\", \"FULL\", \"GLOB\", \"GROUP\", \"HAVING\", \"IF\",\n  \"IGNORE\", \"IMMEDIATE\", \"IN\", \"INDEX\", \"INDEXED\", \"INITIALLY\", \"INNER\",\n  \"INSERT\", \"INSTEAD\", \"INTERSECT\", \"INTO\", \"IS\", \"ISNULL\", \"JOIN\", \"KEY\",\n  \"LEFT\", \"LIKE\", \"LIMIT\", \"MATCH\", \"NATURAL\", \"NO\", \"NOT\", \"NOTNULL\",\n  \"NULL\", \"OF\", \"OFFSET\", \"ON\", \"OR\", \"ORDER\", \"OUTER\", \"PLAN\", \"PRAGMA\",\n  \"PRIMARY\", \"QUERY\", \"RAISE\", \"RECURSIVE\", \"REFERENCES\", \"REGEXP\",\n  \"REINDEX\", \"RELEASE\", \"RENAME\", \"REPLACE\", \"RESTRICT\", \"RIGHT\",\n  \"ROLLBACK\", \"ROW\", \"SAVEPOINT\", \"SELECT\", \"SET\", \"TABLE\", \"TEMP\",\n  \"TEMPORARY\", \"THEN\", \"TO\", \"TRANSACTION\", \"TRIGGER\", \"UNION\", \"UNIQUE\",\n  \"UPDATE\", \"USING\", \"VACUUM\", \"VALUES\", \"VIEW\", \"VIRTUAL\", \"WHEN\", \"WHERE\",\n  \"WITH\", \"WITHOUT\",\n};\n#define completionKwCount \\\n   (int)(sizeof(completionKwrds)/sizeof(completionKwrds[0]))\n\n/*\n** Advance a completion_cursor to its next row of output.\n**\n** The ->ePhase, ->j, and ->pStmt fields of the completion_cursor object\n** record the current state of the scan.  This routine sets ->zCurrentRow\n** to the current row of output and then returns.  If no more rows remain,\n** then ->ePhase is set to COMPLETION_EOF which will signal the virtual\n** table that has reached the end of its scan.\n**\n** The current implementation just lists potential identifiers and\n** keywords and filters them by zPrefix.  Future enhancements should\n** take zLine into account to try to restrict the set of identifiers and\n** keywords based on what would be legal at the current point of input.\n*/\nstatic int completionNext(sqlite3_vtab_cursor *cur){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  int eNextPhase = 0;  /* Next phase to try if current phase reaches end */\n  int iCol = -1;       /* If >=0, step pCur->pStmt and use the i-th column */\n  pCur->iRowid++;\n  while( pCur->ePhase!=COMPLETION_EOF ){\n    switch( pCur->ePhase ){\n      case COMPLETION_KEYWORDS: {\n        if( pCur->j >= completionKwCount ){\n          pCur->zCurrentRow = 0;\n          pCur->ePhase = COMPLETION_DATABASES;\n        }else{\n          pCur->zCurrentRow = completionKwrds[pCur->j++];\n        }\n        iCol = -1;\n        break;\n      }\n      case COMPLETION_DATABASES: {\n        if( pCur->pStmt==0 ){\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1,\n                             &pCur->pStmt, 0);\n        }\n        iCol = 1;\n        eNextPhase = COMPLETION_TABLES;\n        break;\n      }\n      case COMPLETION_TABLES: {\n        if( pCur->pStmt==0 ){\n          sqlite3_stmt *pS2;\n          char *zSql = 0;\n          const char *zSep = \"\";\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1, &pS2, 0);\n          while( sqlite3_step(pS2)==SQLITE_ROW ){\n            const char *zDb = (const char*)sqlite3_column_text(pS2, 1);\n            zSql = sqlite3_mprintf(\n               \"%z%s\"\n               \"SELECT name FROM \\\"%w\\\".sqlite_master\"\n               \" WHERE type='table'\",\n               zSql, zSep, zDb\n            );\n            if( zSql==0 ) return SQLITE_NOMEM;\n            zSep = \" UNION \";\n          }\n          sqlite3_finalize(pS2);\n          sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);\n          sqlite3_free(zSql);\n        }\n        iCol = 0;\n        eNextPhase = COMPLETION_COLUMNS;\n        break;\n      }\n      case COMPLETION_COLUMNS: {\n        if( pCur->pStmt==0 ){\n          sqlite3_stmt *pS2;\n          char *zSql = 0;\n          const char *zSep = \"\";\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1, &pS2, 0);\n          while( sqlite3_step(pS2)==SQLITE_ROW ){\n            const char *zDb = (const char*)sqlite3_column_text(pS2, 1);\n            zSql = sqlite3_mprintf(\n               \"%z%s\"\n               \"SELECT pti.name FROM \\\"%w\\\".sqlite_master AS sm\"\n                       \" JOIN pragma_table_info(sm.name,%Q) AS pti\"\n               \" WHERE sm.type='table'\",\n               zSql, zSep, zDb, zDb\n            );\n            if( zSql==0 ) return SQLITE_NOMEM;\n            zSep = \" UNION \";\n          }\n          sqlite3_finalize(pS2);\n          sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);\n          sqlite3_free(zSql);\n        }\n        iCol = 0;\n        eNextPhase = COMPLETION_EOF;\n        break;\n      }\n    }\n    if( iCol<0 ){\n      /* This case is when the phase presets zCurrentRow */\n      if( pCur->zCurrentRow==0 ) continue;\n    }else{\n      if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){\n        /* Extract the next row of content */\n        pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);\n      }else{\n        /* When all rows are finished, advance to the next phase */\n        sqlite3_finalize(pCur->pStmt);\n        pCur->pStmt = 0;\n        pCur->ePhase = eNextPhase;\n        continue;\n      }\n    }\n    if( pCur->nPrefix==0 ) break;\n    if( sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0 ){\n      break;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the completion_cursor\n** is currently pointing.\n*/\nstatic int completionColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  switch( i ){\n    case COMPLETION_COLUMN_CANDIDATE: {\n      sqlite3_result_text(ctx, pCur->zCurrentRow, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_PREFIX: {\n      sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_WHOLELINE: {\n      sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_PHASE: {\n      sqlite3_result_int(ctx, pCur->ePhase);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int completionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int completionEof(sqlite3_vtab_cursor *cur){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  return pCur->ePhase >= COMPLETION_EOF;\n}\n\n/*\n** This method is called to \"rewind\" the completion_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to completionColumn() or completionRowid() or \n** completionEof().\n*/\nstatic int completionFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  completion_cursor *pCur = (completion_cursor *)pVtabCursor;\n  int iArg = 0;\n  (void)(idxStr);   /* Unused parameter */\n  (void)(argc);     /* Unused parameter */\n  completionCursorReset(pCur);\n  if( idxNum & 1 ){\n    pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);\n    if( pCur->nPrefix>0 ){\n      pCur->zPrefix = sqlite3_mprintf(\"%s\", sqlite3_value_text(argv[iArg]));\n      if( pCur->zPrefix==0 ) return SQLITE_NOMEM;\n    }\n    iArg++;\n  }\n  if( idxNum & 2 ){\n    pCur->nLine = sqlite3_value_bytes(argv[iArg]);\n    if( pCur->nLine>0 ){\n      pCur->zLine = sqlite3_mprintf(\"%s\", sqlite3_value_text(argv[iArg]));\n      if( pCur->zLine==0 ) return SQLITE_NOMEM;\n    }\n    iArg++;\n  }\n  if( pCur->zLine!=0 && pCur->zPrefix==0 ){\n    int i = pCur->nLine;\n    while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){\n      i--;\n    }\n    pCur->nPrefix = pCur->nLine - i;\n    if( pCur->nPrefix>0 ){\n      pCur->zPrefix = sqlite3_mprintf(\"%.*s\", pCur->nPrefix, pCur->zLine + i);\n      if( pCur->zPrefix==0 ) return SQLITE_NOMEM;\n    }\n  }\n  pCur->iRowid = 0;\n  pCur->ePhase = COMPLETION_FIRST_PHASE;\n  return completionNext(pVtabCursor);\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the completion virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n**\n** There are two hidden parameters that act as arguments to the table-valued\n** function:  \"prefix\" and \"wholeline\".  Bit 0 of idxNum is set if \"prefix\"\n** is available and bit 1 is set if \"wholeline\" is available.\n*/\nstatic int completionBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                 /* Loop over constraints */\n  int idxNum = 0;        /* The query plan bitmask */\n  int prefixIdx = -1;    /* Index of the start= constraint, or -1 if none */\n  int wholelineIdx = -1; /* Index of the stop= constraint, or -1 if none */\n  int nArg = 0;          /* Number of arguments that completeFilter() expects */\n  const struct sqlite3_index_constraint *pConstraint;\n\n  (void)(tab);    /* Unused parameter */\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case COMPLETION_COLUMN_PREFIX:\n        prefixIdx = i;\n        idxNum |= 1;\n        break;\n      case COMPLETION_COLUMN_WHOLELINE:\n        wholelineIdx = i;\n        idxNum |= 2;\n        break;\n    }\n  }\n  if( prefixIdx>=0 ){\n    pIdxInfo->aConstraintUsage[prefixIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[prefixIdx].omit = 1;\n  }\n  if( wholelineIdx>=0 ){\n    pIdxInfo->aConstraintUsage[wholelineIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[wholelineIdx].omit = 1;\n  }\n  pIdxInfo->idxNum = idxNum;\n  pIdxInfo->estimatedCost = (double)5000 - 1000*nArg;\n  pIdxInfo->estimatedRows = 500 - 100*nArg;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** completion virtual table.\n*/\nstatic sqlite3_module completionModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  completionConnect,         /* xConnect */\n  completionBestIndex,       /* xBestIndex */\n  completionDisconnect,      /* xDisconnect */\n  0,                         /* xDestroy */\n  completionOpen,            /* xOpen - open a cursor */\n  completionClose,           /* xClose - close a cursor */\n  completionFilter,          /* xFilter - configure scan constraints */\n  completionNext,            /* xNext - advance a cursor */\n  completionEof,             /* xEof - check for end of scan */\n  completionColumn,          /* xColumn - read data */\n  completionRowid,           /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\nint sqlite3CompletionVtabInit(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"completion\", &completionModule, 0);\n#endif\n  return rc;\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_completion_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)(pzErrMsg);  /* Unused parameter */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3CompletionVtabInit(db);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/compress.c",
    "content": "/*\n** 2014-06-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements SQL compression functions\n** compress() and uncompress() using ZLIB.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <zlib.h>\n\n/*\n** Implementation of the \"compress(X)\" SQL function.  The input X is\n** compressed using zLib and the output is returned.\n**\n** The output is a BLOB that begins with a variable-length integer that\n** is the input size in bytes (the size of X before compression).  The\n** variable-length integer is implemented as 1 to 5 bytes.  There are\n** seven bits per integer stored in the lower seven bits of each byte.\n** More significant bits occur first.  The most significant bit (0x80)\n** is a flag to indicate the end of the integer.\n*/\nstatic void compressFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *pIn;\n  unsigned char *pOut;\n  unsigned int nIn;\n  unsigned long int nOut;\n  unsigned char x[8];\n  int rc;\n  int i, j;\n\n  pIn = sqlite3_value_blob(argv[0]);\n  nIn = sqlite3_value_bytes(argv[0]);\n  nOut = 13 + nIn + (nIn+999)/1000;\n  pOut = sqlite3_malloc( nOut+5 );\n  for(i=4; i>=0; i--){\n    x[i] = (nIn >> (7*(4-i)))&0x7f;\n  }\n  for(i=0; i<4 && x[i]==0; i++){}\n  for(j=0; i<=4; i++, j++) pOut[j] = x[i];\n  pOut[j-1] |= 0x80;\n  rc = compress(&pOut[j], &nOut, pIn, nIn);\n  if( rc==Z_OK ){\n    sqlite3_result_blob(context, pOut, nOut+j, sqlite3_free);\n  }else{\n    sqlite3_free(pOut);\n  }\n}\n\n/*\n** Implementation of the \"uncompress(X)\" SQL function.  The argument X\n** is a blob which was obtained from compress(Y).  The output will be\n** the value Y.\n*/\nstatic void uncompressFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *pIn;\n  unsigned char *pOut;\n  unsigned int nIn;\n  unsigned long int nOut;\n  int rc;\n  int i;\n\n  pIn = sqlite3_value_blob(argv[0]);\n  nIn = sqlite3_value_bytes(argv[0]);\n  nOut = 0;\n  for(i=0; i<nIn && i<5; i++){\n    nOut = (nOut<<7) | (pIn[i]&0x7f);\n    if( (pIn[i]&0x80)!=0 ){ i++; break; }\n  }\n  pOut = sqlite3_malloc( nOut+1 );\n  rc = uncompress(pOut, &nOut, &pIn[i], nIn-i);\n  if( rc==Z_OK ){\n    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);\n  }else{\n    sqlite3_free(pOut);\n  }\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_compress_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"compress\", 1, SQLITE_UTF8, 0,\n                               compressFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"uncompress\", 1, SQLITE_UTF8, 0,\n                                 uncompressFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/csv.c",
    "content": "/*\n** 2016-05-28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of an SQLite virtual table for\n** reading CSV files.\n**\n** Usage:\n**\n**    .load ./csv\n**    CREATE VIRTUAL TABLE temp.csv USING csv(filename=FILENAME);\n**    SELECT * FROM csv;\n**\n** The columns are named \"c1\", \"c2\", \"c3\", ... by default.  But the\n** application can define its own CREATE TABLE statement as an additional\n** parameter.  For example:\n**\n**    CREATE VIRTUAL TABLE temp.csv2 USING csv(\n**       filename = \"../http.log\",\n**       schema = \"CREATE TABLE x(date,ipaddr,url,referrer,userAgent)\"\n**    );\n**\n** Instead of specifying a file, the text of the CSV can be loaded using\n** the data= parameter.\n**\n** If the columns=N parameter is supplied, then the CSV file is assumed to have\n** N columns.  If the columns parameter is omitted, the CSV file is opened\n** as soon as the virtual table is constructed and the first row of the CSV\n** is read in order to count the tables.\n**\n** Some extra debugging features (used for testing virtual tables) are available\n** if this module is compiled with -DSQLITE_TEST.\n*/\n#include <sqlite3ext.h>\nSQLITE_EXTENSION_INIT1\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include <stdio.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define CSV_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define CSV_NOINLINE  __declspec(noinline)\n#else\n#  define CSV_NOINLINE\n#endif\n\n\n/* Max size of the error message in a CsvReader */\n#define CSV_MXERR 200\n\n/* Size of the CsvReader input buffer */\n#define CSV_INBUFSZ 1024\n\n/* A context object used when read a CSV file. */\ntypedef struct CsvReader CsvReader;\nstruct CsvReader {\n  FILE *in;              /* Read the CSV text from this input stream */\n  char *z;               /* Accumulated text for a field */\n  int n;                 /* Number of bytes in z */\n  int nAlloc;            /* Space allocated for z[] */\n  int nLine;             /* Current line number */\n  int bNotFirst;         /* True if prior text has been seen */\n  int cTerm;             /* Character that terminated the most recent field */\n  size_t iIn;            /* Next unread character in the input buffer */\n  size_t nIn;            /* Number of characters in the input buffer */\n  char *zIn;             /* The input buffer */\n  char zErr[CSV_MXERR];  /* Error message */\n};\n\n/* Initialize a CsvReader object */\nstatic void csv_reader_init(CsvReader *p){\n  p->in = 0;\n  p->z = 0;\n  p->n = 0;\n  p->nAlloc = 0;\n  p->nLine = 0;\n  p->bNotFirst = 0;\n  p->nIn = 0;\n  p->zIn = 0;\n  p->zErr[0] = 0;\n}\n\n/* Close and reset a CsvReader object */\nstatic void csv_reader_reset(CsvReader *p){\n  if( p->in ){\n    fclose(p->in);\n    sqlite3_free(p->zIn);\n  }\n  sqlite3_free(p->z);\n  csv_reader_init(p);\n}\n\n/* Report an error on a CsvReader */\nstatic void csv_errmsg(CsvReader *p, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);\n  va_end(ap);\n}\n\n/* Open the file associated with a CsvReader\n** Return the number of errors.\n*/\nstatic int csv_reader_open(\n  CsvReader *p,               /* The reader to open */\n  const char *zFilename,      /* Read from this filename */\n  const char *zData           /*  ... or use this data */\n){\n  if( zFilename ){\n    p->zIn = sqlite3_malloc( CSV_INBUFSZ );\n    if( p->zIn==0 ){\n      csv_errmsg(p, \"out of memory\");\n      return 1;\n    }\n    p->in = fopen(zFilename, \"rb\");\n    if( p->in==0 ){\n      csv_reader_reset(p);\n      csv_errmsg(p, \"cannot open '%s' for reading\", zFilename);\n      return 1;\n    }\n  }else{\n    assert( p->in==0 );\n    p->zIn = (char*)zData;\n    p->nIn = strlen(zData);\n  }\n  return 0;\n}\n\n/* The input buffer has overflowed.  Refill the input buffer, then\n** return the next character\n*/\nstatic CSV_NOINLINE int csv_getc_refill(CsvReader *p){\n  size_t got;\n\n  assert( p->iIn>=p->nIn );  /* Only called on an empty input buffer */\n  assert( p->in!=0 );        /* Only called if reading froma file */\n\n  got = fread(p->zIn, 1, CSV_INBUFSZ, p->in);\n  if( got==0 ) return EOF;\n  p->nIn = got;\n  p->iIn = 1;\n  return p->zIn[0];\n}\n\n/* Return the next character of input.  Return EOF at end of input. */\nstatic int csv_getc(CsvReader *p){\n  if( p->iIn >= p->nIn ){\n    if( p->in!=0 ) return csv_getc_refill(p);\n    return EOF;\n  }\n  return ((unsigned char*)p->zIn)[p->iIn++];\n}\n\n/* Increase the size of p->z and append character c to the end. \n** Return 0 on success and non-zero if there is an OOM error */\nstatic CSV_NOINLINE int csv_resize_and_append(CsvReader *p, char c){\n  char *zNew;\n  int nNew = p->nAlloc*2 + 100;\n  zNew = sqlite3_realloc64(p->z, nNew);\n  if( zNew ){\n    p->z = zNew;\n    p->nAlloc = nNew;\n    p->z[p->n++] = c;\n    return 0;\n  }else{\n    csv_errmsg(p, \"out of memory\");\n    return 1;\n  }\n}\n\n/* Append a single character to the CsvReader.z[] array.\n** Return 0 on success and non-zero if there is an OOM error */\nstatic int csv_append(CsvReader *p, char c){\n  if( p->n>=p->nAlloc-1 ) return csv_resize_and_append(p, c);\n  p->z[p->n++] = c;\n  return 0;\n}\n\n/* Read a single field of CSV text.  Compatible with rfc4180 and extended\n** with the option of having a separator other than \",\".\n**\n**   +  Input comes from p->in.\n**   +  Store results in p->z of length p->n.  Space to hold p->z comes\n**      from sqlite3_malloc64().\n**   +  Keep track of the line number in p->nLine.\n**   +  Store the character that terminates the field in p->cTerm.  Store\n**      EOF on end-of-file.\n**\n** Return \"\" at EOF.  Return 0 on an OOM error.\n*/\nstatic char *csv_read_one_field(CsvReader *p){\n  int c;\n  p->n = 0;\n  c = csv_getc(p);\n  if( c==EOF ){\n    p->cTerm = EOF;\n    return \"\";\n  }\n  if( c=='\"' ){\n    int pc, ppc;\n    int startLine = p->nLine;\n    pc = ppc = 0;\n    while( 1 ){\n      c = csv_getc(p);\n      if( c<='\"' || pc=='\"' ){\n        if( c=='\\n' ) p->nLine++;\n        if( c=='\"' ){\n          if( pc=='\"' ){\n            pc = 0;\n            continue;\n          }\n        }\n        if( (c==',' && pc=='\"')\n         || (c=='\\n' && pc=='\"')\n         || (c=='\\n' && pc=='\\r' && ppc=='\"')\n         || (c==EOF && pc=='\"')\n        ){\n          do{ p->n--; }while( p->z[p->n]!='\"' );\n          p->cTerm = (char)c;\n          break;\n        }\n        if( pc=='\"' && c!='\\r' ){\n          csv_errmsg(p, \"line %d: unescaped %c character\", p->nLine, '\"');\n          break;\n        }\n        if( c==EOF ){\n          csv_errmsg(p, \"line %d: unterminated %c-quoted field\\n\",\n                     startLine, '\"');\n          p->cTerm = (char)c;\n          break;\n        }\n      }\n      if( csv_append(p, (char)c) ) return 0;\n      ppc = pc;\n      pc = c;\n    }\n  }else{\n    /* If this is the first field being parsed and it begins with the\n    ** UTF-8 BOM  (0xEF BB BF) then skip the BOM */\n    if( (c&0xff)==0xef && p->bNotFirst==0 ){\n      csv_append(p, (char)c);\n      c = csv_getc(p);\n      if( (c&0xff)==0xbb ){\n        csv_append(p, (char)c);\n        c = csv_getc(p);\n        if( (c&0xff)==0xbf ){\n          p->bNotFirst = 1;\n          p->n = 0;\n          return csv_read_one_field(p);\n        }\n      }\n    }\n    while( c>',' || (c!=EOF && c!=',' && c!='\\n') ){\n      if( csv_append(p, (char)c) ) return 0;\n      c = csv_getc(p);\n    }\n    if( c=='\\n' ){\n      p->nLine++;\n      if( p->n>0 && p->z[p->n-1]=='\\r' ) p->n--;\n    }\n    p->cTerm = (char)c;\n  }\n  if( p->z ) p->z[p->n] = 0;\n  p->bNotFirst = 1;\n  return p->z;\n}\n\n\n/* Forward references to the various virtual table methods implemented\n** in this file. */\nstatic int csvtabCreate(sqlite3*, void*, int, const char*const*, \n                           sqlite3_vtab**,char**);\nstatic int csvtabConnect(sqlite3*, void*, int, const char*const*, \n                           sqlite3_vtab**,char**);\nstatic int csvtabBestIndex(sqlite3_vtab*,sqlite3_index_info*);\nstatic int csvtabDisconnect(sqlite3_vtab*);\nstatic int csvtabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**);\nstatic int csvtabClose(sqlite3_vtab_cursor*);\nstatic int csvtabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                          int argc, sqlite3_value **argv);\nstatic int csvtabNext(sqlite3_vtab_cursor*);\nstatic int csvtabEof(sqlite3_vtab_cursor*);\nstatic int csvtabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int);\nstatic int csvtabRowid(sqlite3_vtab_cursor*,sqlite3_int64*);\n\n/* An instance of the CSV virtual table */\ntypedef struct CsvTable {\n  sqlite3_vtab base;              /* Base class.  Must be first */\n  char *zFilename;                /* Name of the CSV file */\n  char *zData;                    /* Raw CSV data in lieu of zFilename */\n  long iStart;                    /* Offset to start of data in zFilename */\n  int nCol;                       /* Number of columns in the CSV file */\n  unsigned int tstFlags;          /* Bit values used for testing */\n} CsvTable;\n\n/* Allowed values for tstFlags */\n#define CSVTEST_FIDX  0x0001      /* Pretend that constrained searchs cost less*/\n\n/* A cursor for the CSV virtual table */\ntypedef struct CsvCursor {\n  sqlite3_vtab_cursor base;       /* Base class.  Must be first */\n  CsvReader rdr;                  /* The CsvReader object */\n  char **azVal;                   /* Value of the current row */\n  int *aLen;                      /* Length of each entry */\n  sqlite3_int64 iRowid;           /* The current rowid.  Negative for EOF */\n} CsvCursor;\n\n/* Transfer error message text from a reader into a CsvTable */\nstatic void csv_xfer_error(CsvTable *pTab, CsvReader *pRdr){\n  sqlite3_free(pTab->base.zErrMsg);\n  pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", pRdr->zErr);\n}\n\n/*\n** This method is the destructor fo a CsvTable object.\n*/\nstatic int csvtabDisconnect(sqlite3_vtab *pVtab){\n  CsvTable *p = (CsvTable*)pVtab;\n  sqlite3_free(p->zFilename);\n  sqlite3_free(p->zData);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/* Skip leading whitespace.  Return a pointer to the first non-whitespace\n** character, or to the zero terminator if the string has only whitespace */\nstatic const char *csv_skip_whitespace(const char *z){\n  while( isspace((unsigned char)z[0]) ) z++;\n  return z;\n}\n\n/* Remove trailing whitespace from the end of string z[] */\nstatic void csv_trim_whitespace(char *z){\n  size_t n = strlen(z);\n  while( n>0 && isspace((unsigned char)z[n]) ) n--;\n  z[n] = 0;\n}\n\n/* Dequote the string */\nstatic void csv_dequote(char *z){\n  int j;\n  char cQuote = z[0];\n  size_t i, n;\n\n  if( cQuote!='\\'' && cQuote!='\"' ) return;\n  n = strlen(z);\n  if( n<2 || z[n-1]!=z[0] ) return;\n  for(i=1, j=0; i<n-1; i++){\n    if( z[i]==cQuote && z[i+1]==cQuote ) i++;\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n}\n\n/* Check to see if the string is of the form:  \"TAG = VALUE\" with optional\n** whitespace before and around tokens.  If it is, return a pointer to the\n** first character of VALUE.  If it is not, return NULL.\n*/\nstatic const char *csv_parameter(const char *zTag, int nTag, const char *z){\n  z = csv_skip_whitespace(z);\n  if( strncmp(zTag, z, nTag)!=0 ) return 0;\n  z = csv_skip_whitespace(z+nTag);\n  if( z[0]!='=' ) return 0;\n  return csv_skip_whitespace(z+1);\n}\n\n/* Decode a parameter that requires a dequoted string.\n**\n** Return 1 if the parameter is seen, or 0 if not.  1 is returned\n** even if there is an error.  If an error occurs, then an error message\n** is left in p->zErr.  If there are no errors, p->zErr[0]==0.\n*/\nstatic int csv_string_parameter(\n  CsvReader *p,            /* Leave the error message here, if there is one */\n  const char *zParam,      /* Parameter we are checking for */\n  const char *zArg,        /* Raw text of the virtual table argment */\n  char **pzVal             /* Write the dequoted string value here */\n){\n  const char *zValue;\n  zValue = csv_parameter(zParam,(int)strlen(zParam),zArg);\n  if( zValue==0 ) return 0;\n  p->zErr[0] = 0;\n  if( *pzVal ){\n    csv_errmsg(p, \"more than one '%s' parameter\", zParam);\n    return 1;\n  }\n  *pzVal = sqlite3_mprintf(\"%s\", zValue);\n  if( *pzVal==0 ){\n    csv_errmsg(p, \"out of memory\");\n    return 1;\n  }\n  csv_trim_whitespace(*pzVal);\n  csv_dequote(*pzVal);\n  return 1;\n}\n\n\n/* Return 0 if the argument is false and 1 if it is true.  Return -1 if\n** we cannot really tell.\n*/\nstatic int csv_boolean(const char *z){\n  if( sqlite3_stricmp(\"yes\",z)==0\n   || sqlite3_stricmp(\"on\",z)==0\n   || sqlite3_stricmp(\"true\",z)==0\n   || (z[0]=='1' && z[1]==0)\n  ){\n    return 1;\n  }\n  if( sqlite3_stricmp(\"no\",z)==0\n   || sqlite3_stricmp(\"off\",z)==0\n   || sqlite3_stricmp(\"false\",z)==0\n   || (z[0]=='0' && z[1]==0)\n  ){\n    return 0;\n  }\n  return -1;\n}\n\n\n/*\n** Parameters:\n**    filename=FILENAME          Name of file containing CSV content\n**    data=TEXT                  Direct CSV content.\n**    schema=SCHEMA              Alternative CSV schema.\n**    header=YES|NO              First row of CSV defines the names of\n**                               columns if \"yes\".  Default \"no\".\n**    columns=N                  Assume the CSV file contains N columns.\n**\n** Only available if compiled with SQLITE_TEST:\n**    \n**    testflags=N                Bitmask of test flags.  Optional\n**\n** If schema= is omitted, then the columns are named \"c0\", \"c1\", \"c2\",\n** and so forth.  If columns=N is omitted, then the file is opened and\n** the number of columns in the first row is counted to determine the\n** column count.  If header=YES, then the first row is skipped.\n*/\nstatic int csvtabConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  CsvTable *pNew = 0;        /* The CsvTable object to construct */\n  int bHeader = -1;          /* header= flags.  -1 means not seen yet */\n  int rc = SQLITE_OK;        /* Result code from this routine */\n  int i, j;                  /* Loop counters */\n#ifdef SQLITE_TEST\n  int tstFlags = 0;          /* Value for testflags=N parameter */\n#endif\n  int nCol = -99;            /* Value of the columns= parameter */\n  CsvReader sRdr;            /* A CSV file reader used to store an error\n                             ** message and/or to count the number of columns */\n  static const char *azParam[] = {\n     \"filename\", \"data\", \"schema\", \n  };\n  char *azPValue[3];         /* Parameter values */\n# define CSV_FILENAME (azPValue[0])\n# define CSV_DATA     (azPValue[1])\n# define CSV_SCHEMA   (azPValue[2])\n\n\n  assert( sizeof(azPValue)==sizeof(azParam) );\n  memset(&sRdr, 0, sizeof(sRdr));\n  memset(azPValue, 0, sizeof(azPValue));\n  for(i=3; i<argc; i++){\n    const char *z = argv[i];\n    const char *zValue;\n    for(j=0; j<sizeof(azParam)/sizeof(azParam[0]); j++){\n      if( csv_string_parameter(&sRdr, azParam[j], z, &azPValue[j]) ) break;\n    }\n    if( j<sizeof(azParam)/sizeof(azParam[0]) ){\n      if( sRdr.zErr[0] ) goto csvtab_connect_error;\n    }else\n    if( (zValue = csv_parameter(\"header\",6,z))!=0 ){\n      int x;\n      if( bHeader>=0 ){\n        csv_errmsg(&sRdr, \"more than one 'header' parameter\");\n        goto csvtab_connect_error;\n      }\n      x = csv_boolean(zValue);\n      if( x==1 ){\n        bHeader = 1;\n      }else if( x==0 ){\n        bHeader = 0;\n      }else{\n        csv_errmsg(&sRdr, \"unrecognized argument to 'header': %s\", zValue);\n        goto csvtab_connect_error;\n      }\n    }else\n#ifdef SQLITE_TEST\n    if( (zValue = csv_parameter(\"testflags\",9,z))!=0 ){\n      tstFlags = (unsigned int)atoi(zValue);\n    }else\n#endif\n    if( (zValue = csv_parameter(\"columns\",7,z))!=0 ){\n      if( nCol>0 ){\n        csv_errmsg(&sRdr, \"more than one 'columns' parameter\");\n        goto csvtab_connect_error;\n      }\n      nCol = atoi(zValue);\n      if( nCol<=0 ){\n        csv_errmsg(&sRdr, \"must have at least one column\");\n        goto csvtab_connect_error;\n      }\n    }else\n    {\n      csv_errmsg(&sRdr, \"unrecognized parameter '%s'\", z);\n      goto csvtab_connect_error;\n    }\n  }\n  if( (CSV_FILENAME==0)==(CSV_DATA==0) ){\n    csv_errmsg(&sRdr, \"must either filename= or data= but not both\");\n    goto csvtab_connect_error;\n  }\n  if( nCol<=0 && csv_reader_open(&sRdr, CSV_FILENAME, CSV_DATA) ){\n    goto csvtab_connect_error;\n  }\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  *ppVtab = (sqlite3_vtab*)pNew;\n  if( pNew==0 ) goto csvtab_connect_oom;\n  memset(pNew, 0, sizeof(*pNew));\n  if( nCol>0 ){\n    pNew->nCol = nCol;\n  }else{\n    do{\n      const char *z = csv_read_one_field(&sRdr);\n      if( z==0 ) goto csvtab_connect_oom;\n      pNew->nCol++;\n    }while( sRdr.cTerm==',' );\n  }\n  pNew->zFilename = CSV_FILENAME;  CSV_FILENAME = 0;\n  pNew->zData = CSV_DATA;          CSV_DATA = 0;\n#ifdef SQLITE_TEST\n  pNew->tstFlags = tstFlags;\n#endif\n  pNew->iStart = bHeader==1 ? ftell(sRdr.in) : 0;\n  csv_reader_reset(&sRdr);\n  if( CSV_SCHEMA==0 ){\n    char *zSep = \"\";\n    CSV_SCHEMA = sqlite3_mprintf(\"CREATE TABLE x(\");\n    if( CSV_SCHEMA==0 ) goto csvtab_connect_oom;\n    for(i=0; i<pNew->nCol; i++){\n      CSV_SCHEMA = sqlite3_mprintf(\"%z%sc%d TEXT\",CSV_SCHEMA, zSep, i);\n      zSep = \",\";\n    }\n    CSV_SCHEMA = sqlite3_mprintf(\"%z);\", CSV_SCHEMA);\n  }\n  rc = sqlite3_declare_vtab(db, CSV_SCHEMA);\n  if( rc ) goto csvtab_connect_error;\n  for(i=0; i<sizeof(azPValue)/sizeof(azPValue[0]); i++){\n    sqlite3_free(azPValue[i]);\n  }\n  return SQLITE_OK;\n\ncsvtab_connect_oom:\n  rc = SQLITE_NOMEM;\n  csv_errmsg(&sRdr, \"out of memory\");\n\ncsvtab_connect_error:\n  if( pNew ) csvtabDisconnect(&pNew->base);\n  for(i=0; i<sizeof(azPValue)/sizeof(azPValue[0]); i++){\n    sqlite3_free(azPValue[i]);\n  }\n  if( sRdr.zErr[0] ){\n    sqlite3_free(*pzErr);\n    *pzErr = sqlite3_mprintf(\"%s\", sRdr.zErr);\n  }\n  csv_reader_reset(&sRdr);\n  if( rc==SQLITE_OK ) rc = SQLITE_ERROR;\n  return rc;\n}\n\n/*\n** Reset the current row content held by a CsvCursor.\n*/\nstatic void csvtabCursorRowReset(CsvCursor *pCur){\n  CsvTable *pTab = (CsvTable*)pCur->base.pVtab;\n  int i;\n  for(i=0; i<pTab->nCol; i++){\n    sqlite3_free(pCur->azVal[i]);\n    pCur->azVal[i] = 0;\n    pCur->aLen[i] = 0;\n  }\n}\n\n/*\n** The xConnect and xCreate methods do the same thing, but they must be\n** different so that the virtual table is not an eponymous virtual table.\n*/\nstatic int csvtabCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n return csvtabConnect(db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** Destructor for a CsvCursor.\n*/\nstatic int csvtabClose(sqlite3_vtab_cursor *cur){\n  CsvCursor *pCur = (CsvCursor*)cur;\n  csvtabCursorRowReset(pCur);\n  csv_reader_reset(&pCur->rdr);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new CsvTable cursor object.\n*/\nstatic int csvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  CsvTable *pTab = (CsvTable*)p;\n  CsvCursor *pCur;\n  size_t nByte;\n  nByte = sizeof(*pCur) + (sizeof(char*)+sizeof(int))*pTab->nCol;\n  pCur = sqlite3_malloc64( nByte );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, nByte);\n  pCur->azVal = (char**)&pCur[1];\n  pCur->aLen = (int*)&pCur->azVal[pTab->nCol];\n  *ppCursor = &pCur->base;\n  if( csv_reader_open(&pCur->rdr, pTab->zFilename, pTab->zData) ){\n    csv_xfer_error(pTab, &pCur->rdr);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a CsvCursor to its next row of input.\n** Set the EOF marker if we reach the end of input.\n*/\nstatic int csvtabNext(sqlite3_vtab_cursor *cur){\n  CsvCursor *pCur = (CsvCursor*)cur;\n  CsvTable *pTab = (CsvTable*)cur->pVtab;\n  int i = 0;\n  char *z;\n  do{\n    z = csv_read_one_field(&pCur->rdr);\n    if( z==0 ){\n      csv_xfer_error(pTab, &pCur->rdr);\n      break;\n    }\n    if( i<pTab->nCol ){\n      if( pCur->aLen[i] < pCur->rdr.n+1 ){\n        char *zNew = sqlite3_realloc64(pCur->azVal[i], pCur->rdr.n+1);\n        if( zNew==0 ){\n          csv_errmsg(&pCur->rdr, \"out of memory\");\n          csv_xfer_error(pTab, &pCur->rdr);\n          break;\n        }\n        pCur->azVal[i] = zNew;\n        pCur->aLen[i] = pCur->rdr.n+1;\n      }\n      memcpy(pCur->azVal[i], z, pCur->rdr.n+1);\n      i++;\n    }\n  }while( pCur->rdr.cTerm==',' );\n  if( z==0 || (pCur->rdr.cTerm==EOF && i<pTab->nCol) ){\n    pCur->iRowid = -1;\n  }else{\n    pCur->iRowid++;\n    while( i<pTab->nCol ){\n      sqlite3_free(pCur->azVal[i]);\n      pCur->azVal[i] = 0;\n      pCur->aLen[i] = 0;\n      i++;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the CsvCursor\n** is currently pointing.\n*/\nstatic int csvtabColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  CsvCursor *pCur = (CsvCursor*)cur;\n  CsvTable *pTab = (CsvTable*)cur->pVtab;\n  if( i>=0 && i<pTab->nCol && pCur->azVal[i]!=0 ){\n    sqlite3_result_text(ctx, pCur->azVal[i], -1, SQLITE_STATIC);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.\n*/\nstatic int csvtabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  CsvCursor *pCur = (CsvCursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int csvtabEof(sqlite3_vtab_cursor *cur){\n  CsvCursor *pCur = (CsvCursor*)cur;\n  return pCur->iRowid<0;\n}\n\n/*\n** Only a full table scan is supported.  So xFilter simply rewinds to\n** the beginning.\n*/\nstatic int csvtabFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  CsvCursor *pCur = (CsvCursor*)pVtabCursor;\n  CsvTable *pTab = (CsvTable*)pVtabCursor->pVtab;\n  pCur->iRowid = 0;\n  if( pCur->rdr.in==0 ){\n    assert( pCur->rdr.zIn==pTab->zData );\n    assert( pTab->iStart>=0 );\n    assert( (size_t)pTab->iStart<=pCur->rdr.nIn );\n    pCur->rdr.iIn = pTab->iStart;\n  }else{\n    fseek(pCur->rdr.in, pTab->iStart, SEEK_SET);\n    pCur->rdr.iIn = 0;\n    pCur->rdr.nIn = 0;\n  }\n  return csvtabNext(pVtabCursor);\n}\n\n/*\n** Only a forward full table scan is supported.  xBestIndex is mostly\n** a no-op.  If CSVTEST_FIDX is set, then the presence of equality\n** constraints lowers the estimated cost, which is fiction, but is useful\n** for testing certain kinds of virtual table behavior.\n*/\nstatic int csvtabBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  pIdxInfo->estimatedCost = 1000000;\n#ifdef SQLITE_TEST\n  if( (((CsvTable*)tab)->tstFlags & CSVTEST_FIDX)!=0 ){\n    /* The usual (and sensible) case is to always do a full table scan.\n    ** The code in this branch only runs when testflags=1.  This code\n    ** generates an artifical and unrealistic plan which is useful\n    ** for testing virtual table logic but is not helpful to real applications.\n    **\n    ** Any ==, LIKE, or GLOB constraint is marked as usable by the virtual\n    ** table (even though it is not) and the cost of running the virtual table\n    ** is reduced from 1 million to just 10.  The constraints are *not* marked\n    ** as omittable, however, so the query planner should still generate a\n    ** plan that gives a correct answer, even if they plan is not optimal.\n    */\n    int i;\n    int nConst = 0;\n    for(i=0; i<pIdxInfo->nConstraint; i++){\n      unsigned char op;\n      if( pIdxInfo->aConstraint[i].usable==0 ) continue;\n      op = pIdxInfo->aConstraint[i].op;\n      if( op==SQLITE_INDEX_CONSTRAINT_EQ \n       || op==SQLITE_INDEX_CONSTRAINT_LIKE\n       || op==SQLITE_INDEX_CONSTRAINT_GLOB\n      ){\n        pIdxInfo->estimatedCost = 10;\n        pIdxInfo->aConstraintUsage[nConst].argvIndex = nConst+1;\n        nConst++;\n      }\n    }\n  }\n#endif\n  return SQLITE_OK;\n}\n\n\nstatic sqlite3_module CsvModule = {\n  0,                       /* iVersion */\n  csvtabCreate,            /* xCreate */\n  csvtabConnect,           /* xConnect */\n  csvtabBestIndex,         /* xBestIndex */\n  csvtabDisconnect,        /* xDisconnect */\n  csvtabDisconnect,        /* xDestroy */\n  csvtabOpen,              /* xOpen - open a cursor */\n  csvtabClose,             /* xClose - close a cursor */\n  csvtabFilter,            /* xFilter - configure scan constraints */\n  csvtabNext,              /* xNext - advance a cursor */\n  csvtabEof,               /* xEof - check for end of scan */\n  csvtabColumn,            /* xColumn - read data */\n  csvtabRowid,             /* xRowid - read data */\n  0,                       /* xUpdate */\n  0,                       /* xBegin */\n  0,                       /* xSync */\n  0,                       /* xCommit */\n  0,                       /* xRollback */\n  0,                       /* xFindMethod */\n  0,                       /* xRename */\n};\n\n#ifdef SQLITE_TEST\n/*\n** For virtual table testing, make a version of the CSV virtual table\n** available that has an xUpdate function.  But the xUpdate always returns\n** SQLITE_READONLY since the CSV file is not really writable.\n*/\nstatic int csvtabUpdate(sqlite3_vtab *p,int n,sqlite3_value**v,sqlite3_int64*x){\n  return SQLITE_READONLY;\n}\nstatic sqlite3_module CsvModuleFauxWrite = {\n  0,                       /* iVersion */\n  csvtabCreate,            /* xCreate */\n  csvtabConnect,           /* xConnect */\n  csvtabBestIndex,         /* xBestIndex */\n  csvtabDisconnect,        /* xDisconnect */\n  csvtabDisconnect,        /* xDestroy */\n  csvtabOpen,              /* xOpen - open a cursor */\n  csvtabClose,             /* xClose - close a cursor */\n  csvtabFilter,            /* xFilter - configure scan constraints */\n  csvtabNext,              /* xNext - advance a cursor */\n  csvtabEof,               /* xEof - check for end of scan */\n  csvtabColumn,            /* xColumn - read data */\n  csvtabRowid,             /* xRowid - read data */\n  csvtabUpdate,            /* xUpdate */\n  0,                       /* xBegin */\n  0,                       /* xSync */\n  0,                       /* xCommit */\n  0,                       /* xRollback */\n  0,                       /* xFindMethod */\n  0,                       /* xRename */\n};\n#endif /* SQLITE_TEST */\n\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\n/* \n** This routine is called when the extension is loaded.  The new\n** CSV virtual table module is registered with the calling database\n** connection.\n*/\nint sqlite3_csv_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\t\n  int rc;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_create_module(db, \"csv\", &CsvModule, 0);\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_module(db, \"csv_wr\", &CsvModuleFauxWrite, 0);\n  }\n#endif\n  return rc;\n#else\n  return SQLITE_OK;\n#endif\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/dbdump.c",
    "content": "/*\n** 2016-03-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file implements a C-language subroutine that converts the content\n** of an SQLite database into UTF-8 text SQL statements that can be used\n** to exactly recreate the original database.  ROWID values are preserved.\n**\n** A prototype of the implemented subroutine is this:\n**\n**   int sqlite3_db_dump(\n**          sqlite3 *db,\n**          const char *zSchema,\n**          const char *zTable,\n**          void (*xCallback)(void*, const char*),\n**          void *pArg\n**   );\n**\n** The db parameter is the database connection.  zSchema is the schema within\n** that database which is to be dumped.  Usually the zSchema is \"main\" but\n** can also be \"temp\" or any ATTACH-ed database.  If zTable is not NULL, then\n** only the content of that one table is dumped.  If zTable is NULL, then all\n** tables are dumped.\n**\n** The generate text is passed to xCallback() in multiple calls.  The second\n** argument to xCallback() is a copy of the pArg parameter.  The first\n** argument is some of the output text that this routine generates.  The\n** signature to xCallback() is designed to make it compatible with fputs().\n**\n** The sqlite3_db_dump() subroutine returns SQLITE_OK on success or some error\n** code if it encounters a problem.\n**\n** If this file is compiled with -DDBDUMP_STANDALONE then a \"main()\" routine\n** is included so that this routine becomes a command-line utility.  The\n** command-line utility takes two or three arguments which are the name\n** of the database file, the schema, and optionally the table, forming the\n** first three arguments of a single call to the library routine.\n*/\n#include \"sqlite3.h\"\n#include <stdarg.h>\n#include <string.h>\n#include <ctype.h>\n\n/*\n** The state of the dump process.\n*/\ntypedef struct DState DState;\nstruct DState {\n  sqlite3 *db;                /* The database connection */\n  int nErr;                   /* Number of errors seen so far */\n  int rc;                     /* Error code */\n  int writableSchema;                    /* True if in writable_schema mode */\n  int (*xCallback)(const char*,void*);   /* Send output here */\n  void *pArg;                            /* Argument to xCallback() */\n};\n\n/*\n** A variable length string to which one can append text.\n*/\ntypedef struct DText DText;\nstruct DText {\n  char *z;           /* The text */\n  int n;             /* Number of bytes of content in z[] */\n  int nAlloc;        /* Number of bytes allocated to z[] */\n};\n\n/*\n** Initialize and destroy a DText object\n*/\nstatic void initText(DText *p){\n  memset(p, 0, sizeof(*p));\n}\nstatic void freeText(DText *p){\n  sqlite3_free(p->z);\n  initText(p);\n}\n\n/* zIn is either a pointer to a NULL-terminated string in memory obtained\n** from malloc(), or a NULL pointer. The string pointed to by zAppend is\n** added to zIn, and the result returned in memory obtained from malloc().\n** zIn, if it was not NULL, is freed.\n**\n** If the third argument, quote, is not '\\0', then it is used as a\n** quote character for zAppend.\n*/\nstatic void appendText(DText *p, char const *zAppend, char quote){\n  int len;\n  int i;\n  int nAppend = (int)(strlen(zAppend) & 0x3fffffff);\n\n  len = nAppend+p->n+1;\n  if( quote ){\n    len += 2;\n    for(i=0; i<nAppend; i++){\n      if( zAppend[i]==quote ) len++;\n    }\n  }\n\n  if( p->n+len>=p->nAlloc ){\n    char *zNew;\n    p->nAlloc = p->nAlloc*2 + len + 20;\n    zNew = sqlite3_realloc(p->z, p->nAlloc);\n    if( zNew==0 ){\n      freeText(p);\n      return;\n    }\n    p->z = zNew;\n  }\n\n  if( quote ){\n    char *zCsr = p->z+p->n;\n    *zCsr++ = quote;\n    for(i=0; i<nAppend; i++){\n      *zCsr++ = zAppend[i];\n      if( zAppend[i]==quote ) *zCsr++ = quote;\n    }\n    *zCsr++ = quote;\n    p->n = (int)(zCsr - p->z);\n    *zCsr = '\\0';\n  }else{\n    memcpy(p->z+p->n, zAppend, nAppend);\n    p->n += nAppend;\n    p->z[p->n] = '\\0';\n  }\n}\n\n/*\n** Attempt to determine if identifier zName needs to be quoted, either\n** because it contains non-alphanumeric characters, or because it is an\n** SQLite keyword.  Be conservative in this estimate:  When in doubt assume\n** that quoting is required.\n**\n** Return '\"' if quoting is required.  Return 0 if no quoting is required.\n*/\nstatic char quoteChar(const char *zName){\n  /* All SQLite keywords, in alphabetical order */\n  static const char *azKeywords[] = {\n    \"ABORT\", \"ACTION\", \"ADD\", \"AFTER\", \"ALL\", \"ALTER\", \"ANALYZE\", \"AND\", \"AS\",\n    \"ASC\", \"ATTACH\", \"AUTOINCREMENT\", \"BEFORE\", \"BEGIN\", \"BETWEEN\", \"BY\",\n    \"CASCADE\", \"CASE\", \"CAST\", \"CHECK\", \"COLLATE\", \"COLUMN\", \"COMMIT\",\n    \"CONFLICT\", \"CONSTRAINT\", \"CREATE\", \"CROSS\", \"CURRENT_DATE\",\n    \"CURRENT_TIME\", \"CURRENT_TIMESTAMP\", \"DATABASE\", \"DEFAULT\", \"DEFERRABLE\",\n    \"DEFERRED\", \"DELETE\", \"DESC\", \"DETACH\", \"DISTINCT\", \"DROP\", \"EACH\",\n    \"ELSE\", \"END\", \"ESCAPE\", \"EXCEPT\", \"EXCLUSIVE\", \"EXISTS\", \"EXPLAIN\",\n    \"FAIL\", \"FOR\", \"FOREIGN\", \"FROM\", \"FULL\", \"GLOB\", \"GROUP\", \"HAVING\", \"IF\",\n    \"IGNORE\", \"IMMEDIATE\", \"IN\", \"INDEX\", \"INDEXED\", \"INITIALLY\", \"INNER\",\n    \"INSERT\", \"INSTEAD\", \"INTERSECT\", \"INTO\", \"IS\", \"ISNULL\", \"JOIN\", \"KEY\",\n    \"LEFT\", \"LIKE\", \"LIMIT\", \"MATCH\", \"NATURAL\", \"NO\", \"NOT\", \"NOTNULL\",\n    \"NULL\", \"OF\", \"OFFSET\", \"ON\", \"OR\", \"ORDER\", \"OUTER\", \"PLAN\", \"PRAGMA\",\n    \"PRIMARY\", \"QUERY\", \"RAISE\", \"RECURSIVE\", \"REFERENCES\", \"REGEXP\",\n    \"REINDEX\", \"RELEASE\", \"RENAME\", \"REPLACE\", \"RESTRICT\", \"RIGHT\",\n    \"ROLLBACK\", \"ROW\", \"SAVEPOINT\", \"SELECT\", \"SET\", \"TABLE\", \"TEMP\",\n    \"TEMPORARY\", \"THEN\", \"TO\", \"TRANSACTION\", \"TRIGGER\", \"UNION\", \"UNIQUE\",\n    \"UPDATE\", \"USING\", \"VACUUM\", \"VALUES\", \"VIEW\", \"VIRTUAL\", \"WHEN\", \"WHERE\",\n    \"WITH\", \"WITHOUT\",\n  };\n  int i, lwr, upr, mid, c;\n  if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '\"';\n  for(i=0; zName[i]; i++){\n    if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '\"';\n  }\n  lwr = 0;\n  upr = sizeof(azKeywords)/sizeof(azKeywords[0]) - 1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    c = sqlite3_stricmp(azKeywords[mid], zName);\n    if( c==0 ) return '\"';\n    if( c<0 ){\n      lwr = mid+1;\n    }else{\n      upr = mid-1;\n    }\n  }\n  return 0;\n}\n\n\n/*\n** Release memory previously allocated by tableColumnList().\n*/\nstatic void freeColumnList(char **azCol){\n  int i;\n  for(i=1; azCol[i]; i++){\n    sqlite3_free(azCol[i]);\n  }\n  /* azCol[0] is a static string */\n  sqlite3_free(azCol);\n}\n\n/*\n** Return a list of pointers to strings which are the names of all\n** columns in table zTab.   The memory to hold the names is dynamically\n** allocated and must be released by the caller using a subsequent call\n** to freeColumnList().\n**\n** The azCol[0] entry is usually NULL.  However, if zTab contains a rowid\n** value that needs to be preserved, then azCol[0] is filled in with the\n** name of the rowid column.\n**\n** The first regular column in the table is azCol[1].  The list is terminated\n** by an entry with azCol[i]==0.\n*/\nstatic char **tableColumnList(DState *p, const char *zTab){\n  char **azCol = 0;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql;\n  int nCol = 0;\n  int nAlloc = 0;\n  int nPK = 0;       /* Number of PRIMARY KEY columns seen */\n  int isIPK = 0;     /* True if one PRIMARY KEY column of type INTEGER */\n  int preserveRowid = 1;\n  int rc;\n\n  zSql = sqlite3_mprintf(\"PRAGMA table_info=%Q\", zTab);\n  if( zSql==0 ) return 0;\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ) return 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    if( nCol>=nAlloc-2 ){\n      char **azNew;\n      nAlloc = nAlloc*2 + nCol + 10;\n      azNew = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));\n      if( azNew==0 ) goto col_oom;\n      azCol = azNew;\n      azCol[0] = 0;\n    }\n    azCol[++nCol] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 1));\n    if( azCol[nCol]==0 ) goto col_oom;\n    if( sqlite3_column_int(pStmt, 5) ){\n      nPK++;\n      if( nPK==1\n       && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),\n                          \"INTEGER\")==0 \n      ){\n        isIPK = 1;\n      }else{\n        isIPK = 0;\n      }\n    }\n  }\n  sqlite3_finalize(pStmt);\n  pStmt = 0;\n  azCol[nCol+1] = 0;\n\n  /* The decision of whether or not a rowid really needs to be preserved\n  ** is tricky.  We never need to preserve a rowid for a WITHOUT ROWID table\n  ** or a table with an INTEGER PRIMARY KEY.  We are unable to preserve\n  ** rowids on tables where the rowid is inaccessible because there are other\n  ** columns in the table named \"rowid\", \"_rowid_\", and \"oid\".\n  */\n  if( isIPK ){\n    /* If a single PRIMARY KEY column with type INTEGER was seen, then it\n    ** might be an alise for the ROWID.  But it might also be a WITHOUT ROWID\n    ** table or a INTEGER PRIMARY KEY DESC column, neither of which are\n    ** ROWID aliases.  To distinguish these cases, check to see if\n    ** there is a \"pk\" entry in \"PRAGMA index_list\".  There will be\n    ** no \"pk\" index if the PRIMARY KEY really is an alias for the ROWID.\n    */\n    zSql = sqlite3_mprintf(\"SELECT 1 FROM pragma_index_list(%Q)\"\n                           \" WHERE origin='pk'\", zTab);\n    if( zSql==0 ) goto col_oom;\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      freeColumnList(azCol);\n      return 0;\n    }\n    rc = sqlite3_step(pStmt);\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    preserveRowid = rc==SQLITE_ROW;\n  }\n  if( preserveRowid ){\n    /* Only preserve the rowid if we can find a name to use for the\n    ** rowid */\n    static char *azRowid[] = { \"rowid\", \"_rowid_\", \"oid\" };\n    int i, j;\n    for(j=0; j<3; j++){\n      for(i=1; i<=nCol; i++){\n        if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break;\n      }\n      if( i>nCol ){\n        /* At this point, we know that azRowid[j] is not the name of any\n        ** ordinary column in the table.  Verify that azRowid[j] is a valid\n        ** name for the rowid before adding it to azCol[0].  WITHOUT ROWID\n        ** tables will fail this last check */\n        int rc;\n        rc = sqlite3_table_column_metadata(p->db,0,zTab,azRowid[j],0,0,0,0,0);\n        if( rc==SQLITE_OK ) azCol[0] = azRowid[j];\n        break;\n      }\n    }\n  }\n  return azCol;\n\ncol_oom:\n  sqlite3_finalize(pStmt);\n  freeColumnList(azCol);\n  p->nErr++;\n  p->rc = SQLITE_NOMEM;\n  return 0;\n}\n\n/*\n** Send mprintf-formatted content to the output callback.\n*/\nstatic void output_formatted(DState *p, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  p->xCallback(z, p->pArg);\n  sqlite3_free(z);\n}\n\n/*\n** Find a string that is not found anywhere in z[].  Return a pointer\n** to that string.\n**\n** Try to use zA and zB first.  If both of those are already found in z[]\n** then make up some string and store it in the buffer zBuf.\n*/\nstatic const char *unused_string(\n  const char *z,                    /* Result must not appear anywhere in z */\n  const char *zA, const char *zB,   /* Try these first */\n  char *zBuf                        /* Space to store a generated string */\n){\n  unsigned i = 0;\n  if( strstr(z, zA)==0 ) return zA;\n  if( strstr(z, zB)==0 ) return zB;\n  do{\n    sqlite3_snprintf(20,zBuf,\"(%s%u)\", zA, i++);\n  }while( strstr(z,zBuf)!=0 );\n  return zBuf;\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n** Additionallly , escape the \"\\n\" and \"\\r\" characters so that they do not\n** get corrupted by end-of-line translation facilities in some operating\n** systems.\n*/\nstatic void output_quoted_escaped_string(DState *p, const char *z){\n  int i;\n  char c;\n  for(i=0; (c = z[i])!=0 && c!='\\'' && c!='\\n' && c!='\\r'; i++){}\n  if( c==0 ){\n    output_formatted(p,\"'%s'\",z);\n  }else{\n    const char *zNL = 0;\n    const char *zCR = 0;\n    int nNL = 0;\n    int nCR = 0;\n    char zBuf1[20], zBuf2[20];\n    for(i=0; z[i]; i++){\n      if( z[i]=='\\n' ) nNL++;\n      if( z[i]=='\\r' ) nCR++;\n    }\n    if( nNL ){\n      p->xCallback(\"replace(\", p->pArg);\n      zNL = unused_string(z, \"\\\\n\", \"\\\\012\", zBuf1);\n    }\n    if( nCR ){\n      p->xCallback(\"replace(\", p->pArg);\n      zCR = unused_string(z, \"\\\\r\", \"\\\\015\", zBuf2);\n    }\n    p->xCallback(\"'\", p->pArg);\n    while( *z ){\n      for(i=0; (c = z[i])!=0 && c!='\\n' && c!='\\r' && c!='\\''; i++){}\n      if( c=='\\'' ) i++;\n      if( i ){\n        output_formatted(p, \"%.*s\", i, z);\n        z += i;\n      }\n      if( c=='\\'' ){\n        p->xCallback(\"'\", p->pArg);\n        continue;\n      }\n      if( c==0 ){\n        break;\n      }\n      z++;\n      if( c=='\\n' ){\n        p->xCallback(zNL, p->pArg);\n        continue;\n      }\n      p->xCallback(zCR, p->pArg);\n    }\n    p->xCallback(\"'\", p->pArg);\n    if( nCR ){\n      output_formatted(p, \",'%s',char(13))\", zCR);\n    }\n    if( nNL ){\n      output_formatted(p, \",'%s',char(10))\", zNL);\n    }\n  }\n}\n\n/*\n** This is an sqlite3_exec callback routine used for dumping the database.\n** Each row received by this callback consists of a table name,\n** the table type (\"index\" or \"table\") and SQL to create the table.\n** This routine should print text sufficient to recreate the table.\n*/\nstatic int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){\n  int rc;\n  const char *zTable;\n  const char *zType;\n  const char *zSql;\n  DState *p = (DState*)pArg;\n  sqlite3_stmt *pStmt;\n\n  (void)azCol;\n  if( nArg!=3 ) return 1;\n  zTable = azArg[0];\n  zType = azArg[1];\n  zSql = azArg[2];\n\n  if( strcmp(zTable, \"sqlite_sequence\")==0 ){\n    p->xCallback(\"DELETE FROM sqlite_sequence;\\n\", p->pArg);\n  }else if( sqlite3_strglob(\"sqlite_stat?\", zTable)==0 ){\n    p->xCallback(\"ANALYZE sqlite_master;\\n\", p->pArg);\n  }else if( strncmp(zTable, \"sqlite_\", 7)==0 ){\n    return 0;\n  }else if( strncmp(zSql, \"CREATE VIRTUAL TABLE\", 20)==0 ){\n    if( !p->writableSchema ){\n      p->xCallback(\"PRAGMA writable_schema=ON;\\n\", p->pArg);\n      p->writableSchema = 1;\n    }\n    output_formatted(p,\n       \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n       \"VALUES('table','%q','%q',0,'%q');\",\n       zTable, zTable, zSql);\n    return 0;\n  }else{\n    if( sqlite3_strglob(\"CREATE TABLE ['\\\"]*\", zSql)==0 ){\n      p->xCallback(\"CREATE TABLE IF NOT EXISTS \", p->pArg);\n      p->xCallback(zSql+13, p->pArg);\n    }else{\n      p->xCallback(zSql, p->pArg);\n    }\n    p->xCallback(\";\\n\", p->pArg);\n  }\n\n  if( strcmp(zType, \"table\")==0 ){\n    DText sSelect;\n    DText sTable;\n    char **azCol;\n    int i;\n    int nCol;\n\n    azCol = tableColumnList(p, zTable);\n    if( azCol==0 ) return 0;\n\n    initText(&sTable);\n    appendText(&sTable, \"INSERT INTO \", 0);\n\n    /* Always quote the table name, even if it appears to be pure ascii,\n    ** in case it is a keyword. Ex:  INSERT INTO \"table\" ... */\n    appendText(&sTable, zTable, quoteChar(zTable));\n\n    /* If preserving the rowid, add a column list after the table name.\n    ** In other words:  \"INSERT INTO tab(rowid,a,b,c,...) VALUES(...)\"\n    ** instead of the usual \"INSERT INTO tab VALUES(...)\".\n    */\n    if( azCol[0] ){\n      appendText(&sTable, \"(\", 0);\n      appendText(&sTable, azCol[0], 0);\n      for(i=1; azCol[i]; i++){\n        appendText(&sTable, \",\", 0);\n        appendText(&sTable, azCol[i], quoteChar(azCol[i]));\n      }\n      appendText(&sTable, \")\", 0);\n    }\n    appendText(&sTable, \" VALUES(\", 0);\n\n    /* Build an appropriate SELECT statement */\n    initText(&sSelect);\n    appendText(&sSelect, \"SELECT \", 0);\n    if( azCol[0] ){\n      appendText(&sSelect, azCol[0], 0);\n      appendText(&sSelect, \",\", 0);\n    }\n    for(i=1; azCol[i]; i++){\n      appendText(&sSelect, azCol[i], quoteChar(azCol[i]));\n      if( azCol[i+1] ){\n        appendText(&sSelect, \",\", 0);\n      }\n    }\n    nCol = i;\n    if( azCol[0]==0 ) nCol--;\n    freeColumnList(azCol);\n    appendText(&sSelect, \" FROM \", 0);\n    appendText(&sSelect, zTable, quoteChar(zTable));\n\n    rc = sqlite3_prepare_v2(p->db, sSelect.z, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      p->nErr++;\n      if( p->rc==SQLITE_OK ) p->rc = rc;\n    }else{\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        p->xCallback(sTable.z, p->pArg);\n        for(i=0; i<nCol; i++){\n          if( i ) p->xCallback(\",\", p->pArg);\n          switch( sqlite3_column_type(pStmt,i) ){\n            case SQLITE_INTEGER: {\n              output_formatted(p, \"%lld\", sqlite3_column_int64(pStmt,i));\n              break;\n            }\n            case SQLITE_FLOAT: {\n              double r = sqlite3_column_double(pStmt,i);\n              output_formatted(p, \"%!.20g\", r);\n              break;\n            }\n            case SQLITE_NULL: {\n              p->xCallback(\"NULL\", p->pArg);\n              break;\n            }\n            case SQLITE_TEXT: {\n              output_quoted_escaped_string(p, \n                   (const char*)sqlite3_column_text(pStmt,i));\n              break;\n            }\n            case SQLITE_BLOB: {\n              int nByte = sqlite3_column_bytes(pStmt,i);\n              unsigned char *a = (unsigned char*)sqlite3_column_blob(pStmt,i);\n              int j;\n              p->xCallback(\"x'\", p->pArg);\n              for(j=0; j<nByte; j++){\n                char zWord[3];\n                zWord[0] = \"0123456789abcdef\"[(a[j]>>4)&15];\n                zWord[1] = \"0123456789abcdef\"[a[j]&15];\n                zWord[2] = 0;\n                p->xCallback(zWord, p->pArg);\n              }\n              p->xCallback(\"'\", p->pArg);\n              break;\n            }\n          }\n        }\n        p->xCallback(\");\\n\", p->pArg);\n      }\n    }\n    sqlite3_finalize(pStmt);\n    freeText(&sTable);\n    freeText(&sSelect);\n  }\n  return 0;\n}\n\n\n/*\n** Execute a query statement that will generate SQL output.  Print\n** the result columns, comma-separated, on a line and then add a\n** semicolon terminator to the end of that line.\n**\n** If the number of columns is 1 and that column contains text \"--\"\n** then write the semicolon on a separate line.  That way, if a\n** \"--\" comment occurs at the end of the statement, the comment\n** won't consume the semicolon terminator.\n*/\nstatic void output_sql_from_query(\n  DState *p,               /* Query context */\n  const char *zSelect,     /* SELECT statement to extract content */\n  ...\n){\n  sqlite3_stmt *pSelect;\n  int rc;\n  int nResult;\n  int i;\n  const char *z;\n  char *zSql;\n  va_list ap;\n  va_start(ap, zSelect);\n  zSql = sqlite3_vmprintf(zSelect, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    p->rc = SQLITE_NOMEM;\n    p->nErr++;\n    return;\n  }\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pSelect, 0);\n  sqlite3_free(zSql);\n  if( rc!=SQLITE_OK || !pSelect ){\n    output_formatted(p, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n    p->nErr++;\n    return;\n  }\n  rc = sqlite3_step(pSelect);\n  nResult = sqlite3_column_count(pSelect);\n  while( rc==SQLITE_ROW ){\n    z = (const char*)sqlite3_column_text(pSelect, 0);\n    p->xCallback(z, p->pArg);\n    for(i=1; i<nResult; i++){\n      p->xCallback(\",\", p->pArg);\n      p->xCallback((const char*)sqlite3_column_text(pSelect,i), p->pArg);\n    }\n    if( z==0 ) z = \"\";\n    while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;\n    if( z[0] ){\n      p->xCallback(\"\\n;\\n\", p->pArg);\n    }else{\n      p->xCallback(\";\\n\", p->pArg);\n    }\n    rc = sqlite3_step(pSelect);\n  }\n  rc = sqlite3_finalize(pSelect);\n  if( rc!=SQLITE_OK ){\n    output_formatted(p, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                     sqlite3_errmsg(p->db));\n    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;\n  }\n}\n\n/*\n** Run zQuery.  Use dump_callback() as the callback routine so that\n** the contents of the query are output as SQL statements.\n**\n** If we get a SQLITE_CORRUPT error, rerun the query after appending\n** \"ORDER BY rowid DESC\" to the end.\n*/\nstatic void run_schema_dump_query(\n  DState *p,\n  const char *zQuery,\n  ...\n){\n  char *zErr = 0;\n  char *z;\n  va_list ap;\n  va_start(ap, zQuery);\n  z = sqlite3_vmprintf(zQuery, ap);\n  va_end(ap); \n  sqlite3_exec(p->db, z, dump_callback, p, &zErr);\n  sqlite3_free(z);\n  if( zErr ){\n    output_formatted(p, \"/****** %s ******/\\n\", zErr);\n    sqlite3_free(zErr);\n    p->nErr++;\n    zErr = 0;\n  }\n}\n\n/*\n** Convert an SQLite database into SQL statements that will recreate that\n** database.\n*/\nint sqlite3_db_dump(\n  sqlite3 *db,               /* The database connection */\n  const char *zSchema,       /* Which schema to dump.  Usually \"main\". */\n  const char *zTable,        /* Which table to dump.  NULL means everything. */\n  int (*xCallback)(const char*,void*),   /* Output sent to this callback */\n  void *pArg                             /* Second argument of the callback */\n){\n  DState x;\n  memset(&x, 0, sizeof(x));\n  x.rc = sqlite3_exec(db, \"BEGIN\", 0, 0, 0);\n  if( x.rc ) return x.rc;\n  x.db = db;\n  x.xCallback = xCallback;\n  x.pArg = pArg;\n  xCallback(\"PRAGMA foreign_keys=OFF;\\nBEGIN TRANSACTION;\\n\", pArg);\n  if( zTable==0 ){\n    run_schema_dump_query(&x,\n      \"SELECT name, type, sql FROM \\\"%w\\\".sqlite_master \"\n      \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\",\n      zSchema\n    );\n    run_schema_dump_query(&x,\n      \"SELECT name, type, sql FROM \\\"%w\\\".sqlite_master \"\n      \"WHERE name=='sqlite_sequence'\", zSchema\n    );\n    output_sql_from_query(&x,\n      \"SELECT sql FROM sqlite_master \"\n      \"WHERE sql NOT NULL AND type IN ('index','trigger','view')\", 0\n    );\n  }else{\n    run_schema_dump_query(&x,\n      \"SELECT name, type, sql FROM \\\"%w\\\".sqlite_master \"\n      \"WHERE tbl_name=%Q COLLATE nocase AND type=='table'\"\n      \"  AND sql NOT NULL\",\n      zSchema, zTable\n    );\n    output_sql_from_query(&x,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master \"\n      \"WHERE sql NOT NULL\"\n      \"  AND type IN ('index','trigger','view')\"\n      \"  AND tbl_name=%Q COLLATE nocase\",\n      zSchema, zTable\n    ); \n  }\n  if( x.writableSchema ){\n    xCallback(\"PRAGMA writable_schema=OFF;\\n\", pArg);\n  }\n  xCallback(x.nErr ? \"ROLLBACK; -- due to errors\\n\" : \"COMMIT;\\n\", pArg);\n  sqlite3_exec(db, \"COMMIT\", 0, 0, 0);\n  return x.rc;\n}\n\n\n\n/* The generic subroutine is above.  The code the follows implements\n** the command-line interface.\n*/\n#ifdef DBDUMP_STANDALONE\n#include <stdio.h>\n\n/*\n** Command-line interface\n*/\nint main(int argc, char **argv){\n  sqlite3 *db;\n  const char *zDb;\n  const char *zSchema;\n  const char *zTable = 0;\n  int rc;\n\n  if( argc<2 || argc>4 ){\n    fprintf(stderr, \"Usage: %s DATABASE ?SCHEMA? ?TABLE?\\n\", argv[0]);\n    return 1;\n  }\n  zDb = argv[1];\n  zSchema = argc>=3 ? argv[2] : \"main\";\n  zTable = argc==4 ? argv[3] : 0;\n\n  rc = sqlite3_open(zDb, &db);\n  if( rc ){\n    fprintf(stderr, \"Cannot open \\\"%s\\\": %s\\n\", zDb, sqlite3_errmsg(db));\n    sqlite3_close(db);\n    return 1;\n  }\n  rc = sqlite3_db_dump(db, zSchema, zTable, \n          (int(*)(const char*,void*))fputs, (void*)stdout);\n  if( rc ){\n    fprintf(stderr, \"Error: sqlite3_db_dump() returns %d\\n\", rc);\n  }\n  sqlite3_close(db);\n  return rc!=SQLITE_OK;  \n}\n#endif /* DBDUMP_STANDALONE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/eval.c",
    "content": "/*\n** 2014-11-10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements SQL function eval() which runs\n** SQL statements recursively.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <string.h>\n\n/*\n** Structure used to accumulate the output\n*/\nstruct EvalResult {\n  char *z;               /* Accumulated output */\n  const char *zSep;      /* Separator */\n  int szSep;             /* Size of the separator string */\n  sqlite3_int64 nAlloc;  /* Number of bytes allocated for z[] */\n  sqlite3_int64 nUsed;   /* Number of bytes of z[] actually used */\n};\n\n/*\n** Callback from sqlite_exec() for the eval() function.\n*/\nstatic int callback(void *pCtx, int argc, char **argv, char **colnames){\n  struct EvalResult *p = (struct EvalResult*)pCtx;\n  int i; \n  for(i=0; i<argc; i++){\n    const char *z = argv[i] ? argv[i] : \"\";\n    size_t sz = strlen(z);\n    if( (sqlite3_int64)sz+p->nUsed+p->szSep+1 > p->nAlloc ){\n      char *zNew;\n      p->nAlloc = p->nAlloc*2 + sz + p->szSep + 1;\n      /* Using sqlite3_realloc64() would be better, but it is a recent\n      ** addition and will cause a segfault if loaded by an older version\n      ** of SQLite.  */\n      zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc(p->z, (int)p->nAlloc) : 0;\n      if( zNew==0 ){\n        sqlite3_free(p->z);\n        memset(p, 0, sizeof(*p));\n        return 1;\n      }\n      p->z = zNew;\n    }\n    if( p->nUsed>0 ){\n      memcpy(&p->z[p->nUsed], p->zSep, p->szSep);\n      p->nUsed += p->szSep;\n    }\n    memcpy(&p->z[p->nUsed], z, sz);\n    p->nUsed += sz;\n  }\n  return 0;\n}\n\n/*\n** Implementation of the eval(X) and eval(X,Y) SQL functions.\n**\n** Evaluate the SQL text in X.  Return the results, using string\n** Y as the separator.  If Y is omitted, use a single space character.\n*/\nstatic void sqlEvalFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zSql;\n  sqlite3 *db;\n  char *zErr = 0;\n  int rc;\n  struct EvalResult x;\n\n  memset(&x, 0, sizeof(x));\n  x.zSep = \" \";\n  zSql = (const char*)sqlite3_value_text(argv[0]);\n  if( zSql==0 ) return;\n  if( argc>1 ){\n    x.zSep = (const char*)sqlite3_value_text(argv[1]);\n    if( x.zSep==0 ) return;\n  }\n  x.szSep = (int)strlen(x.zSep);\n  db = sqlite3_context_db_handle(context);\n  rc = sqlite3_exec(db, zSql, callback, &x, &zErr);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n  }else if( x.zSep==0 ){\n    sqlite3_result_error_nomem(context);\n    sqlite3_free(x.z);\n  }else{\n    sqlite3_result_text(context, x.z, (int)x.nUsed, sqlite3_free);\n  }\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_eval_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"eval\", 1, SQLITE_UTF8, 0,\n                               sqlEvalFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"eval\", 2, SQLITE_UTF8, 0,\n                                 sqlEvalFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/fileio.c",
    "content": "/*\n** 2014-06-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements SQL functions readfile() and\n** writefile().\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <stdio.h>\n\n/*\n** Implementation of the \"readfile(X)\" SQL function.  The entire content\n** of the file named X is read and returned as a BLOB.  NULL is returned\n** if the file does not exist or is unreadable.\n*/\nstatic void readfileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zName;\n  FILE *in;\n  long nIn;\n  void *pBuf;\n\n  (void)(argc);  /* Unused parameter */\n  zName = (const char*)sqlite3_value_text(argv[0]);\n  if( zName==0 ) return;\n  in = fopen(zName, \"rb\");\n  if( in==0 ) return;\n  fseek(in, 0, SEEK_END);\n  nIn = ftell(in);\n  rewind(in);\n  pBuf = sqlite3_malloc( nIn );\n  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){\n    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);\n  }else{\n    sqlite3_free(pBuf);\n  }\n  fclose(in);\n}\n\n/*\n** Implementation of the \"writefile(X,Y)\" SQL function.  The argument Y\n** is written into file X.  The number of bytes written is returned.  Or\n** NULL is returned if something goes wrong, such as being unable to open\n** file X for writing.\n*/\nstatic void writefileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  FILE *out;\n  const char *z;\n  sqlite3_int64 rc;\n  const char *zFile;\n\n  (void)(argc);  /* Unused parameter */\n  zFile = (const char*)sqlite3_value_text(argv[0]);\n  if( zFile==0 ) return;\n  out = fopen(zFile, \"wb\");\n  if( out==0 ) return;\n  z = (const char*)sqlite3_value_blob(argv[1]);\n  if( z==0 ){\n    rc = 0;\n  }else{\n    rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);\n  }\n  fclose(out);\n  sqlite3_result_int64(context, rc);\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fileio_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"readfile\", 1, SQLITE_UTF8, 0,\n                               readfileFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"writefile\", 2, SQLITE_UTF8, 0,\n                                 writefileFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/fuzzer.c",
    "content": "/*\n** 2011 March 24\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Code for a demonstration virtual table that generates variations\n** on an input word at increasing edit distances from the original.\n**\n** A fuzzer virtual table is created like this:\n**\n**     CREATE VIRTUAL TABLE f USING fuzzer(<fuzzer-data-table>);\n**\n** When it is created, the new fuzzer table must be supplied with the\n** name of a \"fuzzer data table\", which must reside in the same database\n** file as the new fuzzer table. The fuzzer data table contains the various\n** transformations and their costs that the fuzzer logic uses to generate\n** variations.\n**\n** The fuzzer data table must contain exactly four columns (more precisely,\n** the statement \"SELECT * FROM <fuzzer_data_table>\" must return records\n** that consist of four columns). It does not matter what the columns are\n** named. \n**\n** Each row in the fuzzer data table represents a single character\n** transformation. The left most column of the row (column 0) contains an\n** integer value - the identifier of the ruleset to which the transformation\n** rule belongs (see \"MULTIPLE RULE SETS\" below). The second column of the\n** row (column 0) contains the input character or characters. The third \n** column contains the output character or characters. And the fourth column\n** contains the integer cost of making the transformation. For example:\n**\n**    CREATE TABLE f_data(ruleset, cFrom, cTo, Cost);\n**    INSERT INTO f_data(ruleset, cFrom, cTo, Cost) VALUES(0, '', 'a', 100);\n**    INSERT INTO f_data(ruleset, cFrom, cTo, Cost) VALUES(0, 'b', '', 87);\n**    INSERT INTO f_data(ruleset, cFrom, cTo, Cost) VALUES(0, 'o', 'oe', 38);\n**    INSERT INTO f_data(ruleset, cFrom, cTo, Cost) VALUES(0, 'oe', 'o', 40);\n**\n** The first row inserted into the fuzzer data table by the SQL script\n** above indicates that the cost of inserting a letter 'a' is 100.  (All \n** costs are integers.  We recommend that costs be scaled so that the \n** average cost is around 100.) The second INSERT statement creates a rule\n** saying that the cost of deleting a single letter 'b' is 87.  The third\n** and fourth INSERT statements mean that the cost of transforming a\n** single letter \"o\" into the two-letter sequence \"oe\" is 38 and that the\n** cost of transforming \"oe\" back into \"o\" is 40.\n**\n** The contents of the fuzzer data table are loaded into main memory when\n** a fuzzer table is first created, and may be internally reloaded by the\n** system at any subsequent time. Therefore, the fuzzer data table should be \n** populated before the fuzzer table is created and not modified thereafter.\n** If you do need to modify the contents of the fuzzer data table, it is\n** recommended that the associated fuzzer table be dropped, the fuzzer data\n** table edited, and the fuzzer table recreated within a single transaction.\n** Alternatively, the fuzzer data table can be edited then the database\n** connection can be closed and reopened.\n**\n** Once it has been created, the fuzzer table can be queried as follows:\n**\n**    SELECT word, distance FROM f\n**     WHERE word MATCH 'abcdefg'\n**       AND distance<200;\n**\n** This first query outputs the string \"abcdefg\" and all strings that\n** can be derived from that string by appling the specified transformations.\n** The strings are output together with their total transformation cost\n** (called \"distance\") and appear in order of increasing cost.  No string\n** is output more than once.  If there are multiple ways to transform the\n** target string into the output string then the lowest cost transform is\n** the one that is returned.  In the example, the search is limited to \n** strings with a total distance of less than 200.\n**\n** The fuzzer is a read-only table.  Any attempt to DELETE, INSERT, or\n** UPDATE on a fuzzer table will throw an error.\n**\n** It is important to put some kind of a limit on the fuzzer output.  This\n** can be either in the form of a LIMIT clause at the end of the query,\n** or better, a \"distance<NNN\" constraint where NNN is some number.  The\n** running time and memory requirement is exponential in the value of NNN \n** so you want to make sure that NNN is not too big.  A value of NNN that\n** is about twice the average transformation cost seems to give good results.\n**\n** The fuzzer table can be useful for tasks such as spelling correction.\n** Suppose there is a second table vocabulary(w) where the w column contains\n** all correctly spelled words.   Let $word be a word you want to look up.\n**\n**   SELECT vocabulary.w FROM f, vocabulary\n**    WHERE f.word MATCH $word\n**      AND f.distance<=200\n**      AND f.word=vocabulary.w\n**    LIMIT 20\n**\n** The query above gives the 20 closest words to the $word being tested.\n** (Note that for good performance, the vocubulary.w column should be\n** indexed.)\n**\n** A similar query can be used to find all words in the dictionary that\n** begin with some prefix $prefix:\n**\n**   SELECT vocabulary.w FROM f, vocabulary\n**    WHERE f.word MATCH $prefix\n**      AND f.distance<=200\n**      AND vocabulary.w BETWEEN f.word AND (f.word || x'F7BFBFBF')\n**    LIMIT 50\n**\n** This last query will show up to 50 words out of the vocabulary that\n** match or nearly match the $prefix.\n**\n** MULTIPLE RULE SETS\n**\n** Normally, the \"ruleset\" value associated with all character transformations\n** in the fuzzer data table is zero. However, if required, the fuzzer table\n** allows multiple rulesets to be defined. Each query uses only a single\n** ruleset. This allows, for example, a single fuzzer table to support \n** multiple languages.\n**\n** By default, only the rules from ruleset 0 are used. To specify an \n** alternative ruleset, a \"ruleset = ?\" expression must be added to the\n** WHERE clause of a SELECT, where ? is the identifier of the desired \n** ruleset. For example:\n**\n**   SELECT vocabulary.w FROM f, vocabulary\n**    WHERE f.word MATCH $word\n**      AND f.distance<=200\n**      AND f.word=vocabulary.w\n**      AND f.ruleset=1  -- Specify the ruleset to use here\n**    LIMIT 20\n**\n** If no \"ruleset = ?\" constraint is specified in the WHERE clause, ruleset \n** 0 is used.\n**\n** LIMITS\n**\n** The maximum ruleset number is 2147483647.  The maximum length of either\n** of the strings in the second or third column of the fuzzer data table\n** is 50 bytes.  The maximum cost on a rule is 1000.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n/* If SQLITE_DEBUG is not defined, disable assert statements. */\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)\n# define NDEBUG\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stdio.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Forward declaration of objects used by this implementation\n*/\ntypedef struct fuzzer_vtab fuzzer_vtab;\ntypedef struct fuzzer_cursor fuzzer_cursor;\ntypedef struct fuzzer_rule fuzzer_rule;\ntypedef struct fuzzer_seen fuzzer_seen;\ntypedef struct fuzzer_stem fuzzer_stem;\n\n/*\n** Various types.\n**\n** fuzzer_cost is the \"cost\" of an edit operation.\n**\n** fuzzer_len is the length of a matching string.  \n**\n** fuzzer_ruleid is an ruleset identifier.\n*/\ntypedef int fuzzer_cost;\ntypedef signed char fuzzer_len;\ntypedef int fuzzer_ruleid;\n\n/*\n** Limits\n*/\n#define FUZZER_MX_LENGTH           50   /* Maximum length of a rule string */\n#define FUZZER_MX_RULEID   2147483647   /* Maximum rule ID */\n#define FUZZER_MX_COST           1000   /* Maximum single-rule cost */\n#define FUZZER_MX_OUTPUT_LENGTH   100   /* Maximum length of an output string */\n\n\n/*\n** Each transformation rule is stored as an instance of this object.\n** All rules are kept on a linked list sorted by rCost.\n*/\nstruct fuzzer_rule {\n  fuzzer_rule *pNext;         /* Next rule in order of increasing rCost */\n  char *zFrom;                /* Transform from */\n  fuzzer_cost rCost;          /* Cost of this transformation */\n  fuzzer_len nFrom, nTo;      /* Length of the zFrom and zTo strings */\n  fuzzer_ruleid iRuleset;     /* The rule set to which this rule belongs */\n  char zTo[4];                /* Transform to (extra space appended) */\n};\n\n/*\n** A stem object is used to generate variants.  It is also used to record\n** previously generated outputs.\n**\n** Every stem is added to a hash table as it is output.  Generation of\n** duplicate stems is suppressed.\n**\n** Active stems (those that might generate new outputs) are kepts on a linked\n** list sorted by increasing cost.  The cost is the sum of rBaseCost and\n** pRule->rCost.\n*/\nstruct fuzzer_stem {\n  char *zBasis;              /* Word being fuzzed */\n  const fuzzer_rule *pRule;  /* Current rule to apply */\n  fuzzer_stem *pNext;        /* Next stem in rCost order */\n  fuzzer_stem *pHash;        /* Next stem with same hash on zBasis */\n  fuzzer_cost rBaseCost;     /* Base cost of getting to zBasis */\n  fuzzer_cost rCostX;        /* Precomputed rBaseCost + pRule->rCost */\n  fuzzer_len nBasis;         /* Length of the zBasis string */\n  fuzzer_len n;              /* Apply pRule at this character offset */\n};\n\n/* \n** A fuzzer virtual-table object \n*/\nstruct fuzzer_vtab {\n  sqlite3_vtab base;         /* Base class - must be first */\n  char *zClassName;          /* Name of this class.  Default: \"fuzzer\" */\n  fuzzer_rule *pRule;        /* All active rules in this fuzzer */\n  int nCursor;               /* Number of active cursors */\n};\n\n#define FUZZER_HASH  4001    /* Hash table size */\n#define FUZZER_NQUEUE  20    /* Number of slots on the stem queue */\n\n/* A fuzzer cursor object */\nstruct fuzzer_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3_int64 iRowid;      /* The rowid of the current word */\n  fuzzer_vtab *pVtab;        /* The virtual table this cursor belongs to */\n  fuzzer_cost rLimit;        /* Maximum cost of any term */\n  fuzzer_stem *pStem;        /* Stem with smallest rCostX */\n  fuzzer_stem *pDone;        /* Stems already processed to completion */\n  fuzzer_stem *aQueue[FUZZER_NQUEUE];  /* Queue of stems with higher rCostX */\n  int mxQueue;               /* Largest used index in aQueue[] */\n  char *zBuf;                /* Temporary use buffer */\n  int nBuf;                  /* Bytes allocated for zBuf */\n  int nStem;                 /* Number of stems allocated */\n  int iRuleset;              /* Only process rules from this ruleset */\n  fuzzer_rule nullRule;      /* Null rule used first */\n  fuzzer_stem *apHash[FUZZER_HASH]; /* Hash of previously generated terms */\n};\n\n/*\n** The two input rule lists are both sorted in order of increasing\n** cost.  Merge them together into a single list, sorted by cost, and\n** return a pointer to the head of that list.\n*/\nstatic fuzzer_rule *fuzzerMergeRules(fuzzer_rule *pA, fuzzer_rule *pB){\n  fuzzer_rule head;\n  fuzzer_rule *pTail;\n\n  pTail =  &head;\n  while( pA && pB ){\n    if( pA->rCost<=pB->rCost ){\n      pTail->pNext = pA;\n      pTail = pA;\n      pA = pA->pNext;\n    }else{\n      pTail->pNext = pB;\n      pTail = pB;\n      pB = pB->pNext;\n    }\n  }\n  if( pA==0 ){\n    pTail->pNext = pB;\n  }else{\n    pTail->pNext = pA;\n  }\n  return head.pNext;\n}\n\n/*\n** Statement pStmt currently points to a row in the fuzzer data table. This\n** function allocates and populates a fuzzer_rule structure according to\n** the content of the row.\n**\n** If successful, *ppRule is set to point to the new object and SQLITE_OK\n** is returned. Otherwise, *ppRule is zeroed, *pzErr may be set to point\n** to an error message and an SQLite error code returned.\n*/\nstatic int fuzzerLoadOneRule(\n  fuzzer_vtab *p,                 /* Fuzzer virtual table handle */\n  sqlite3_stmt *pStmt,            /* Base rule on statements current row */\n  fuzzer_rule **ppRule,           /* OUT: New rule object */\n  char **pzErr                    /* OUT: Error message */\n){\n  sqlite3_int64 iRuleset = sqlite3_column_int64(pStmt, 0);\n  const char *zFrom = (const char *)sqlite3_column_text(pStmt, 1);\n  const char *zTo = (const char *)sqlite3_column_text(pStmt, 2);\n  int nCost = sqlite3_column_int(pStmt, 3);\n\n  int rc = SQLITE_OK;             /* Return code */\n  int nFrom;                      /* Size of string zFrom, in bytes */\n  int nTo;                        /* Size of string zTo, in bytes */\n  fuzzer_rule *pRule = 0;         /* New rule object to return */\n\n  if( zFrom==0 ) zFrom = \"\";\n  if( zTo==0 ) zTo = \"\";\n  nFrom = (int)strlen(zFrom);\n  nTo = (int)strlen(zTo);\n\n  /* Silently ignore null transformations */\n  if( strcmp(zFrom, zTo)==0 ){\n    *ppRule = 0;\n    return SQLITE_OK;\n  }\n\n  if( nCost<=0 || nCost>FUZZER_MX_COST ){\n    *pzErr = sqlite3_mprintf(\"%s: cost must be between 1 and %d\", \n        p->zClassName, FUZZER_MX_COST\n    );\n    rc = SQLITE_ERROR;\n  }else\n  if( nFrom>FUZZER_MX_LENGTH || nTo>FUZZER_MX_LENGTH ){\n    *pzErr = sqlite3_mprintf(\"%s: maximum string length is %d\", \n        p->zClassName, FUZZER_MX_LENGTH\n    );\n    rc = SQLITE_ERROR;    \n  }else\n  if( iRuleset<0 || iRuleset>FUZZER_MX_RULEID ){\n    *pzErr = sqlite3_mprintf(\"%s: ruleset must be between 0 and %d\", \n        p->zClassName, FUZZER_MX_RULEID\n    );\n    rc = SQLITE_ERROR;    \n  }else{\n\n    pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );\n    if( pRule==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pRule, 0, sizeof(*pRule));\n      pRule->zFrom = pRule->zTo;\n      pRule->zFrom += nTo + 1;\n      pRule->nFrom = (fuzzer_len)nFrom;\n      memcpy(pRule->zFrom, zFrom, nFrom+1);\n      memcpy(pRule->zTo, zTo, nTo+1);\n      pRule->nTo = (fuzzer_len)nTo;\n      pRule->rCost = nCost;\n      pRule->iRuleset = (int)iRuleset;\n    }\n  }\n\n  *ppRule = pRule;\n  return rc;\n}\n\n/*\n** Load the content of the fuzzer data table into memory.\n*/\nstatic int fuzzerLoadRules(\n  sqlite3 *db,                    /* Database handle */\n  fuzzer_vtab *p,                 /* Virtual fuzzer table to configure */\n  const char *zDb,                /* Database containing rules data */\n  const char *zData,              /* Table containing rules data */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* SELECT used to read from rules table */\n  fuzzer_rule *pHead = 0;\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", zDb, zData);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int rc2;                      /* finalize() return code */\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s: %s\", p->zClassName, sqlite3_errmsg(db));\n    }else if( sqlite3_column_count(pStmt)!=4 ){\n      *pzErr = sqlite3_mprintf(\"%s: %s has %d columns, expected 4\",\n          p->zClassName, zData, sqlite3_column_count(pStmt)\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n        fuzzer_rule *pRule = 0;\n        rc = fuzzerLoadOneRule(p, pStmt, &pRule, pzErr);\n        if( pRule ){\n          pRule->pNext = pHead;\n          pHead = pRule;\n        }\n      }\n    }\n    rc2 = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  sqlite3_free(zSql);\n\n  /* All rules are now in a singly linked list starting at pHead. This\n  ** block sorts them by cost and then sets fuzzer_vtab.pRule to point to \n  ** point to the head of the sorted list.\n  */\n  if( rc==SQLITE_OK ){\n    unsigned int i;\n    fuzzer_rule *pX;\n    fuzzer_rule *a[15];\n    for(i=0; i<sizeof(a)/sizeof(a[0]); i++) a[i] = 0;\n    while( (pX = pHead)!=0 ){\n      pHead = pX->pNext;\n      pX->pNext = 0;\n      for(i=0; a[i] && i<sizeof(a)/sizeof(a[0])-1; i++){\n        pX = fuzzerMergeRules(a[i], pX);\n        a[i] = 0;\n      }\n      a[i] = fuzzerMergeRules(a[i], pX);\n    }\n    for(pX=a[0], i=1; i<sizeof(a)/sizeof(a[0]); i++){\n      pX = fuzzerMergeRules(a[i], pX);\n    }\n    p->pRule = fuzzerMergeRules(p->pRule, pX);\n  }else{\n    /* An error has occurred. Setting p->pRule to point to the head of the\n    ** allocated list ensures that the list will be cleaned up in this case.\n    */\n    assert( p->pRule==0 );\n    p->pRule = pHead;\n  }\n\n  return rc;\n}\n\n/*\n** This function converts an SQL quoted string into an unquoted string\n** and returns a pointer to a buffer allocated using sqlite3_malloc() \n** containing the result. The caller should eventually free this buffer\n** using sqlite3_free.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic char *fuzzerDequote(const char *zIn){\n  int nIn;                        /* Size of input string, in bytes */\n  char *zOut;                     /* Output (dequoted) string */\n\n  nIn = (int)strlen(zIn);\n  zOut = sqlite3_malloc(nIn+1);\n  if( zOut ){\n    char q = zIn[0];              /* Quote character (if any ) */\n\n    if( q!='[' && q!= '\\'' && q!='\"' && q!='`' ){\n      memcpy(zOut, zIn, nIn+1);\n    }else{\n      int iOut = 0;               /* Index of next byte to write to output */\n      int iIn;                    /* Index of next byte to read from input */\n\n      if( q=='[' ) q = ']';\n      for(iIn=1; iIn<nIn; iIn++){\n        if( zIn[iIn]==q ) iIn++;\n        zOut[iOut++] = zIn[iIn];\n      }\n    }\n    assert( (int)strlen(zOut)<=nIn );\n  }\n  return zOut;\n}\n\n/*\n** xDisconnect/xDestroy method for the fuzzer module.\n*/\nstatic int fuzzerDisconnect(sqlite3_vtab *pVtab){\n  fuzzer_vtab *p = (fuzzer_vtab*)pVtab;\n  assert( p->nCursor==0 );\n  while( p->pRule ){\n    fuzzer_rule *pRule = p->pRule;\n    p->pRule = pRule->pNext;\n    sqlite3_free(pRule);\n  }\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** xConnect/xCreate method for the fuzzer module. Arguments are:\n**\n**   argv[0]   -> module name  (\"fuzzer\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[3]   -> fuzzer rule table name\n*/\nstatic int fuzzerConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc = SQLITE_OK;             /* Return code */\n  fuzzer_vtab *pNew = 0;          /* New virtual table */\n  const char *zModule = argv[0];\n  const char *zDb = argv[1];\n\n  if( argc!=4 ){\n    *pzErr = sqlite3_mprintf(\n        \"%s: wrong number of CREATE VIRTUAL TABLE arguments\", zModule\n    );\n    rc = SQLITE_ERROR;\n  }else{\n    int nModule;                  /* Length of zModule, in bytes */\n\n    nModule = (int)strlen(zModule);\n    pNew = sqlite3_malloc( sizeof(*pNew) + nModule + 1);\n    if( pNew==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *zTab;                 /* Dequoted name of fuzzer data table */\n\n      memset(pNew, 0, sizeof(*pNew));\n      pNew->zClassName = (char*)&pNew[1];\n      memcpy(pNew->zClassName, zModule, nModule+1);\n\n      zTab = fuzzerDequote(argv[3]);\n      if( zTab==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        rc = fuzzerLoadRules(db, pNew, zDb, zTab, pzErr);\n        sqlite3_free(zTab);\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_declare_vtab(db, \"CREATE TABLE x(word,distance,ruleset)\");\n      }\n      if( rc!=SQLITE_OK ){\n        fuzzerDisconnect((sqlite3_vtab *)pNew);\n        pNew = 0;\n      }\n    }\n  }\n\n  *ppVtab = (sqlite3_vtab *)pNew;\n  return rc;\n}\n\n/*\n** Open a new fuzzer cursor.\n*/\nstatic int fuzzerOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  fuzzer_vtab *p = (fuzzer_vtab*)pVTab;\n  fuzzer_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->pVtab = p;\n  *ppCursor = &pCur->base;\n  p->nCursor++;\n  return SQLITE_OK;\n}\n\n/*\n** Free all stems in a list.\n*/\nstatic void fuzzerClearStemList(fuzzer_stem *pStem){\n  while( pStem ){\n    fuzzer_stem *pNext = pStem->pNext;\n    sqlite3_free(pStem);\n    pStem = pNext;\n  }\n}\n\n/*\n** Free up all the memory allocated by a cursor.  Set it rLimit to 0\n** to indicate that it is at EOF.\n*/\nstatic void fuzzerClearCursor(fuzzer_cursor *pCur, int clearHash){\n  int i;\n  fuzzerClearStemList(pCur->pStem);\n  fuzzerClearStemList(pCur->pDone);\n  for(i=0; i<FUZZER_NQUEUE; i++) fuzzerClearStemList(pCur->aQueue[i]);\n  pCur->rLimit = (fuzzer_cost)0;\n  if( clearHash && pCur->nStem ){\n    pCur->mxQueue = 0;\n    pCur->pStem = 0;\n    pCur->pDone = 0;\n    memset(pCur->aQueue, 0, sizeof(pCur->aQueue));\n    memset(pCur->apHash, 0, sizeof(pCur->apHash));\n  }\n  pCur->nStem = 0;\n}\n\n/*\n** Close a fuzzer cursor.\n*/\nstatic int fuzzerClose(sqlite3_vtab_cursor *cur){\n  fuzzer_cursor *pCur = (fuzzer_cursor *)cur;\n  fuzzerClearCursor(pCur, 0);\n  sqlite3_free(pCur->zBuf);\n  pCur->pVtab->nCursor--;\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Compute the current output term for a fuzzer_stem.\n*/\nstatic int fuzzerRender(\n  fuzzer_stem *pStem,   /* The stem to be rendered */\n  char **pzBuf,         /* Write results into this buffer.  realloc if needed */\n  int *pnBuf            /* Size of the buffer */\n){\n  const fuzzer_rule *pRule = pStem->pRule;\n  int n;                          /* Size of output term without nul-term */\n  char *z;                        /* Buffer to assemble output term in */\n\n  n = pStem->nBasis + pRule->nTo - pRule->nFrom;\n  if( (*pnBuf)<n+1 ){\n    (*pzBuf) = sqlite3_realloc((*pzBuf), n+100);\n    if( (*pzBuf)==0 ) return SQLITE_NOMEM;\n    (*pnBuf) = n+100;\n  }\n  n = pStem->n;\n  z = *pzBuf;\n  if( n<0 ){\n    memcpy(z, pStem->zBasis, pStem->nBasis+1);\n  }else{\n    memcpy(z, pStem->zBasis, n);\n    memcpy(&z[n], pRule->zTo, pRule->nTo);\n    memcpy(&z[n+pRule->nTo], &pStem->zBasis[n+pRule->nFrom], \n           pStem->nBasis-n-pRule->nFrom+1);\n  }\n\n  assert( z[pStem->nBasis + pRule->nTo - pRule->nFrom]==0 );\n  return SQLITE_OK;\n}\n\n/*\n** Compute a hash on zBasis.\n*/\nstatic unsigned int fuzzerHash(const char *z){\n  unsigned int h = 0;\n  while( *z ){ h = (h<<3) ^ (h>>29) ^ *(z++); }\n  return h % FUZZER_HASH;\n}\n\n/*\n** Current cost of a stem\n*/\nstatic fuzzer_cost fuzzerCost(fuzzer_stem *pStem){\n  return pStem->rCostX = pStem->rBaseCost + pStem->pRule->rCost;\n}\n\n#if 0\n/*\n** Print a description of a fuzzer_stem on stderr.\n*/\nstatic void fuzzerStemPrint(\n  const char *zPrefix,\n  fuzzer_stem *pStem,\n  const char *zSuffix\n){\n  if( pStem->n<0 ){\n    fprintf(stderr, \"%s[%s](%d)-->self%s\",\n       zPrefix,\n       pStem->zBasis, pStem->rBaseCost,\n       zSuffix\n    );\n  }else{\n    char *zBuf = 0;\n    int nBuf = 0;\n    if( fuzzerRender(pStem, &zBuf, &nBuf)!=SQLITE_OK ) return;\n    fprintf(stderr, \"%s[%s](%d)-->{%s}(%d)%s\",\n      zPrefix,\n      pStem->zBasis, pStem->rBaseCost, zBuf, pStem->,\n      zSuffix\n    );\n    sqlite3_free(zBuf);\n  }\n}\n#endif\n\n/*\n** Return 1 if the string to which the cursor is point has already\n** been emitted.  Return 0 if not.  Return -1 on a memory allocation\n** failures.\n*/\nstatic int fuzzerSeen(fuzzer_cursor *pCur, fuzzer_stem *pStem){\n  unsigned int h;\n  fuzzer_stem *pLookup;\n\n  if( fuzzerRender(pStem, &pCur->zBuf, &pCur->nBuf)==SQLITE_NOMEM ){\n    return -1;\n  }\n  h = fuzzerHash(pCur->zBuf);\n  pLookup = pCur->apHash[h];\n  while( pLookup && strcmp(pLookup->zBasis, pCur->zBuf)!=0 ){\n    pLookup = pLookup->pHash;\n  }\n  return pLookup!=0;\n}\n\n/*\n** If argument pRule is NULL, this function returns false.\n**\n** Otherwise, it returns true if rule pRule should be skipped. A rule \n** should be skipped if it does not belong to rule-set iRuleset, or if\n** applying it to stem pStem would create a string longer than \n** FUZZER_MX_OUTPUT_LENGTH bytes.\n*/\nstatic int fuzzerSkipRule(\n  const fuzzer_rule *pRule,       /* Determine whether or not to skip this */\n  fuzzer_stem *pStem,             /* Stem rule may be applied to */\n  int iRuleset                    /* Rule-set used by the current query */\n){\n  return pRule && (\n      (pRule->iRuleset!=iRuleset)\n   || (pStem->nBasis + pRule->nTo - pRule->nFrom)>FUZZER_MX_OUTPUT_LENGTH\n  );\n}\n\n/*\n** Advance a fuzzer_stem to its next value.   Return 0 if there are\n** no more values that can be generated by this fuzzer_stem.  Return\n** -1 on a memory allocation failure.\n*/\nstatic int fuzzerAdvance(fuzzer_cursor *pCur, fuzzer_stem *pStem){\n  const fuzzer_rule *pRule;\n  while( (pRule = pStem->pRule)!=0 ){\n    assert( pRule==&pCur->nullRule || pRule->iRuleset==pCur->iRuleset );\n    while( pStem->n < pStem->nBasis - pRule->nFrom ){\n      pStem->n++;\n      if( pRule->nFrom==0\n       || memcmp(&pStem->zBasis[pStem->n], pRule->zFrom, pRule->nFrom)==0\n      ){\n        /* Found a rewrite case.  Make sure it is not a duplicate */\n        int rc = fuzzerSeen(pCur, pStem);\n        if( rc<0 ) return -1;\n        if( rc==0 ){\n          fuzzerCost(pStem);\n          return 1;\n        }\n      }\n    }\n    pStem->n = -1;\n    do{\n      pRule = pRule->pNext;\n    }while( fuzzerSkipRule(pRule, pStem, pCur->iRuleset) );\n    pStem->pRule = pRule;\n    if( pRule && fuzzerCost(pStem)>pCur->rLimit ) pStem->pRule = 0;\n  }\n  return 0;\n}\n\n/*\n** The two input stem lists are both sorted in order of increasing\n** rCostX.  Merge them together into a single list, sorted by rCostX, and\n** return a pointer to the head of that new list.\n*/\nstatic fuzzer_stem *fuzzerMergeStems(fuzzer_stem *pA, fuzzer_stem *pB){\n  fuzzer_stem head;\n  fuzzer_stem *pTail;\n\n  pTail =  &head;\n  while( pA && pB ){\n    if( pA->rCostX<=pB->rCostX ){\n      pTail->pNext = pA;\n      pTail = pA;\n      pA = pA->pNext;\n    }else{\n      pTail->pNext = pB;\n      pTail = pB;\n      pB = pB->pNext;\n    }\n  }\n  if( pA==0 ){\n    pTail->pNext = pB;\n  }else{\n    pTail->pNext = pA;\n  }\n  return head.pNext;\n}\n\n/*\n** Load pCur->pStem with the lowest-cost stem.  Return a pointer\n** to the lowest-cost stem.\n*/\nstatic fuzzer_stem *fuzzerLowestCostStem(fuzzer_cursor *pCur){\n  fuzzer_stem *pBest, *pX;\n  int iBest;\n  int i;\n\n  if( pCur->pStem==0 ){\n    iBest = -1;\n    pBest = 0;\n    for(i=0; i<=pCur->mxQueue; i++){\n      pX = pCur->aQueue[i];\n      if( pX==0 ) continue;\n      if( pBest==0 || pBest->rCostX>pX->rCostX ){\n        pBest = pX;\n        iBest = i;\n      }\n    } \n    if( pBest ){\n      pCur->aQueue[iBest] = pBest->pNext;\n      pBest->pNext = 0;\n      pCur->pStem = pBest;\n    }\n  }\n  return pCur->pStem;\n}\n\n/*\n** Insert pNew into queue of pending stems.  Then find the stem\n** with the lowest rCostX and move it into pCur->pStem.\n** list.  The insert is done such the pNew is in the correct order\n** according to fuzzer_stem.zBaseCost+fuzzer_stem.pRule->rCost.\n*/\nstatic fuzzer_stem *fuzzerInsert(fuzzer_cursor *pCur, fuzzer_stem *pNew){\n  fuzzer_stem *pX;\n  int i;\n\n  /* If pCur->pStem exists and is greater than pNew, then make pNew\n  ** the new pCur->pStem and insert the old pCur->pStem instead.\n  */\n  if( (pX = pCur->pStem)!=0 && pX->rCostX>pNew->rCostX ){\n    pNew->pNext = 0;\n    pCur->pStem = pNew;\n    pNew = pX;\n  }\n\n  /* Insert the new value */\n  pNew->pNext = 0;\n  pX = pNew;\n  for(i=0; i<=pCur->mxQueue; i++){\n    if( pCur->aQueue[i] ){\n      pX = fuzzerMergeStems(pX, pCur->aQueue[i]);\n      pCur->aQueue[i] = 0;\n    }else{\n      pCur->aQueue[i] = pX;\n      break;\n    }\n  }\n  if( i>pCur->mxQueue ){\n    if( i<FUZZER_NQUEUE ){\n      pCur->mxQueue = i;\n      pCur->aQueue[i] = pX;\n    }else{\n      assert( pCur->mxQueue==FUZZER_NQUEUE-1 );\n      pX = fuzzerMergeStems(pX, pCur->aQueue[FUZZER_NQUEUE-1]);\n      pCur->aQueue[FUZZER_NQUEUE-1] = pX;\n    }\n  }\n\n  return fuzzerLowestCostStem(pCur);\n}\n\n/*\n** Allocate a new fuzzer_stem.  Add it to the hash table but do not\n** link it into either the pCur->pStem or pCur->pDone lists.\n*/\nstatic fuzzer_stem *fuzzerNewStem(\n  fuzzer_cursor *pCur,\n  const char *zWord,\n  fuzzer_cost rBaseCost\n){\n  fuzzer_stem *pNew;\n  fuzzer_rule *pRule;\n  unsigned int h;\n\n  pNew = sqlite3_malloc( sizeof(*pNew) + (int)strlen(zWord) + 1 );\n  if( pNew==0 ) return 0;\n  memset(pNew, 0, sizeof(*pNew));\n  pNew->zBasis = (char*)&pNew[1];\n  pNew->nBasis = (fuzzer_len)strlen(zWord);\n  memcpy(pNew->zBasis, zWord, pNew->nBasis+1);\n  pRule = pCur->pVtab->pRule;\n  while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){\n    pRule = pRule->pNext;\n  }\n  pNew->pRule = pRule;\n  pNew->n = -1;\n  pNew->rBaseCost = pNew->rCostX = rBaseCost;\n  h = fuzzerHash(pNew->zBasis);\n  pNew->pHash = pCur->apHash[h];\n  pCur->apHash[h] = pNew;\n  pCur->nStem++;\n  return pNew;\n}\n\n\n/*\n** Advance a cursor to its next row of output\n*/\nstatic int fuzzerNext(sqlite3_vtab_cursor *cur){\n  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;\n  int rc;\n  fuzzer_stem *pStem, *pNew;\n\n  pCur->iRowid++;\n\n  /* Use the element the cursor is currently point to to create\n  ** a new stem and insert the new stem into the priority queue.\n  */\n  pStem = pCur->pStem;\n  if( pStem->rCostX>0 ){\n    rc = fuzzerRender(pStem, &pCur->zBuf, &pCur->nBuf);\n    if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM;\n    pNew = fuzzerNewStem(pCur, pCur->zBuf, pStem->rCostX);\n    if( pNew ){\n      if( fuzzerAdvance(pCur, pNew)==0 ){\n        pNew->pNext = pCur->pDone;\n        pCur->pDone = pNew;\n      }else{\n        if( fuzzerInsert(pCur, pNew)==pNew ){\n          return SQLITE_OK;\n        }\n      }\n    }else{\n      return SQLITE_NOMEM;\n    }\n  }\n\n  /* Adjust the priority queue so that the first element of the\n  ** stem list is the next lowest cost word.\n  */\n  while( (pStem = pCur->pStem)!=0 ){\n    int res = fuzzerAdvance(pCur, pStem);\n    if( res<0 ){\n      return SQLITE_NOMEM;\n    }else if( res>0 ){\n      pCur->pStem = 0;\n      pStem = fuzzerInsert(pCur, pStem);\n      if( (rc = fuzzerSeen(pCur, pStem))!=0 ){\n        if( rc<0 ) return SQLITE_NOMEM;\n        continue;\n      }\n      return SQLITE_OK;  /* New word found */\n    }\n    pCur->pStem = 0;\n    pStem->pNext = pCur->pDone;\n    pCur->pDone = pStem;\n    if( fuzzerLowestCostStem(pCur) ){\n      rc = fuzzerSeen(pCur, pCur->pStem);\n      if( rc<0 ) return SQLITE_NOMEM;\n      if( rc==0 ){\n        return SQLITE_OK;\n      }\n    }\n  }\n\n  /* Reach this point only if queue has been exhausted and there is\n  ** nothing left to be output. */\n  pCur->rLimit = (fuzzer_cost)0;\n  return SQLITE_OK;\n}\n\n/*\n** Called to \"rewind\" a cursor back to the beginning so that\n** it starts its output over again.  Always called at least once\n** prior to any fuzzerColumn, fuzzerRowid, or fuzzerEof call.\n*/\nstatic int fuzzerFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  fuzzer_cursor *pCur = (fuzzer_cursor *)pVtabCursor;\n  const char *zWord = \"\";\n  fuzzer_stem *pStem;\n  int idx;\n\n  fuzzerClearCursor(pCur, 1);\n  pCur->rLimit = 2147483647;\n  idx = 0;\n  if( idxNum & 1 ){\n    zWord = (const char*)sqlite3_value_text(argv[0]);\n    idx++;\n  }\n  if( idxNum & 2 ){\n    pCur->rLimit = (fuzzer_cost)sqlite3_value_int(argv[idx]);\n    idx++;\n  }\n  if( idxNum & 4 ){\n    pCur->iRuleset = (fuzzer_cost)sqlite3_value_int(argv[idx]);\n    idx++;\n  }\n  pCur->nullRule.pNext = pCur->pVtab->pRule;\n  pCur->nullRule.rCost = 0;\n  pCur->nullRule.nFrom = 0;\n  pCur->nullRule.nTo = 0;\n  pCur->nullRule.zFrom = \"\";\n  pCur->iRowid = 1;\n  assert( pCur->pStem==0 );\n\n  /* If the query term is longer than FUZZER_MX_OUTPUT_LENGTH bytes, this\n  ** query will return zero rows.  */\n  if( (int)strlen(zWord)<FUZZER_MX_OUTPUT_LENGTH ){\n    pCur->pStem = pStem = fuzzerNewStem(pCur, zWord, (fuzzer_cost)0);\n    if( pStem==0 ) return SQLITE_NOMEM;\n    pStem->pRule = &pCur->nullRule;\n    pStem->n = pStem->nBasis;\n  }else{\n    pCur->rLimit = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Only the word and distance columns have values.  All other columns\n** return NULL\n*/\nstatic int fuzzerColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;\n  if( i==0 ){\n    /* the \"word\" column */\n    if( fuzzerRender(pCur->pStem, &pCur->zBuf, &pCur->nBuf)==SQLITE_NOMEM ){\n      return SQLITE_NOMEM;\n    }\n    sqlite3_result_text(ctx, pCur->zBuf, -1, SQLITE_TRANSIENT);\n  }else if( i==1 ){\n    /* the \"distance\" column */\n    sqlite3_result_int(ctx, pCur->pStem->rCostX);\n  }else{\n    /* All other columns are NULL */\n    sqlite3_result_null(ctx);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The rowid.\n*/\nstatic int fuzzerRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** When the fuzzer_cursor.rLimit value is 0 or less, that is a signal\n** that the cursor has nothing more to output.\n*/\nstatic int fuzzerEof(sqlite3_vtab_cursor *cur){\n  fuzzer_cursor *pCur = (fuzzer_cursor*)cur;\n  return pCur->rLimit<=(fuzzer_cost)0;\n}\n\n/*\n** Search for terms of these forms:\n**\n**   (A)    word MATCH $str\n**   (B1)   distance < $value\n**   (B2)   distance <= $value\n**   (C)    ruleid == $ruleid\n**\n** The distance< and distance<= are both treated as distance<=.\n** The query plan number is a bit vector:\n**\n**   bit 1:   Term of the form (A) found\n**   bit 2:   Term like (B1) or (B2) found\n**   bit 3:   Term like (C) found\n**\n** If bit-1 is set, $str is always in filter.argv[0].  If bit-2 is set\n** then $value is in filter.argv[0] if bit-1 is clear and is in \n** filter.argv[1] if bit-1 is set.  If bit-3 is set, then $ruleid is\n** in filter.argv[0] if bit-1 and bit-2 are both zero, is in\n** filter.argv[1] if exactly one of bit-1 and bit-2 are set, and is in\n** filter.argv[2] if both bit-1 and bit-2 are set.\n*/\nstatic int fuzzerBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int iPlan = 0;\n  int iDistTerm = -1;\n  int iRulesetTerm = -1;\n  int i;\n  int seenMatch = 0;\n  const struct sqlite3_index_constraint *pConstraint;\n  double rCost = 1e12;\n\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->iColumn==0\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n      seenMatch = 1;\n    }\n    if( pConstraint->usable==0 ) continue;\n    if( (iPlan & 1)==0 \n     && pConstraint->iColumn==0\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH\n    ){\n      iPlan |= 1;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      rCost /= 1e6;\n    }\n    if( (iPlan & 2)==0\n     && pConstraint->iColumn==1\n     && (pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT\n           || pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE)\n    ){\n      iPlan |= 2;\n      iDistTerm = i;\n      rCost /= 10.0;\n    }\n    if( (iPlan & 4)==0\n     && pConstraint->iColumn==2\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= 4;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      iRulesetTerm = i;\n      rCost /= 10.0;\n    }\n  }\n  if( iPlan & 2 ){\n    pIdxInfo->aConstraintUsage[iDistTerm].argvIndex = 1+((iPlan&1)!=0);\n  }\n  if( iPlan & 4 ){\n    int idx = 1;\n    if( iPlan & 1 ) idx++;\n    if( iPlan & 2 ) idx++;\n    pIdxInfo->aConstraintUsage[iRulesetTerm].argvIndex = idx;\n  }\n  pIdxInfo->idxNum = iPlan;\n  if( pIdxInfo->nOrderBy==1\n   && pIdxInfo->aOrderBy[0].iColumn==1\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  if( seenMatch && (iPlan&1)==0 ) rCost = 1e99;\n  pIdxInfo->estimatedCost = rCost;\n   \n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that implements the \"fuzzer\".\n*/\nstatic sqlite3_module fuzzerModule = {\n  0,                           /* iVersion */\n  fuzzerConnect,\n  fuzzerConnect,\n  fuzzerBestIndex,\n  fuzzerDisconnect, \n  fuzzerDisconnect,\n  fuzzerOpen,                  /* xOpen - open a cursor */\n  fuzzerClose,                 /* xClose - close a cursor */\n  fuzzerFilter,                /* xFilter - configure scan constraints */\n  fuzzerNext,                  /* xNext - advance a cursor */\n  fuzzerEof,                   /* xEof - check for end of scan */\n  fuzzerColumn,                /* xColumn - read data */\n  fuzzerRowid,                 /* xRowid - read data */\n  0,                           /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_fuzzer_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"fuzzer\", &fuzzerModule, 0);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/ieee754.c",
    "content": "/*\n** 2013-04-17\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements functions for the exact display\n** and input of IEEE754 Binary64 floating-point numbers.\n**\n**   ieee754(X)\n**   ieee754(Y,Z)\n**\n** In the first form, the value X should be a floating-point number.\n** The function will return a string of the form 'ieee754(Y,Z)' where\n** Y and Z are integers such that X==Y*pow(2,Z).\n**\n** In the second form, Y and Z are integers which are the mantissa and\n** base-2 exponent of a new floating point number.  The function returns\n** a floating-point value equal to Y*pow(2,Z).\n**\n** Examples:\n**\n**     ieee754(2.0)       ->     'ieee754(2,0)'\n**     ieee754(45.25)     ->     'ieee754(181,-2)'\n**     ieee754(2, 0)      ->     2.0\n**     ieee754(181, -2)   ->     45.25\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n/*\n** Implementation of the ieee754() function\n*/\nstatic void ieee754func(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  if( argc==1 ){\n    sqlite3_int64 m, a;\n    double r;\n    int e;\n    int isNeg;\n    char zResult[100];\n    assert( sizeof(m)==sizeof(r) );\n    if( sqlite3_value_type(argv[0])!=SQLITE_FLOAT ) return;\n    r = sqlite3_value_double(argv[0]);\n    if( r<0.0 ){\n      isNeg = 1;\n      r = -r;\n    }else{\n      isNeg = 0;\n    }\n    memcpy(&a,&r,sizeof(a));\n    if( a==0 ){\n      e = 0;\n      m = 0;\n    }else{\n      e = a>>52;\n      m = a & ((((sqlite3_int64)1)<<52)-1);\n      m |= ((sqlite3_int64)1)<<52;\n      while( e<1075 && m>0 && (m&1)==0 ){\n        m >>= 1;\n        e++;\n      }\n      if( isNeg ) m = -m;\n    }\n    sqlite3_snprintf(sizeof(zResult), zResult, \"ieee754(%lld,%d)\",\n                     m, e-1075);\n    sqlite3_result_text(context, zResult, -1, SQLITE_TRANSIENT);\n  }else if( argc==2 ){\n    sqlite3_int64 m, e, a;\n    double r;\n    int isNeg = 0;\n    m = sqlite3_value_int64(argv[0]);\n    e = sqlite3_value_int64(argv[1]);\n    if( m<0 ){\n      isNeg = 1;\n      m = -m;\n      if( m<0 ) return;\n    }else if( m==0 && e>1000 && e<1000 ){\n      sqlite3_result_double(context, 0.0);\n      return;\n    }\n    while( (m>>32)&0xffe00000 ){\n      m >>= 1;\n      e++;\n    }\n    while( m!=0 && ((m>>32)&0xfff00000)==0 ){\n      m <<= 1;\n      e--;\n    }\n    e += 1075;\n    if( e<0 ) e = m = 0;\n    if( e>0x7ff ) e = 0x7ff;\n    a = m & ((((sqlite3_int64)1)<<52)-1);\n    a |= e<<52;\n    if( isNeg ) a |= ((sqlite3_uint64)1)<<63;\n    memcpy(&r, &a, sizeof(r));\n    sqlite3_result_double(context, r);\n  }\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_ieee_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"ieee754\", 1, SQLITE_UTF8, 0,\n                               ieee754func, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"ieee754\", 2, SQLITE_UTF8, 0,\n                                 ieee754func, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/json1.c",
    "content": "/*\n** 2015-08-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements JSON functions.  The interface is\n** modeled after MySQL JSON functions:\n**\n**     https://dev.mysql.com/doc/refman/5.7/en/json.html\n**\n** For the time being, all JSON is stored as pure text.  (We might add\n** a JSONB type in the future which stores a binary encoding of JSON in\n** a BLOB, but there is no support for JSONB in the current implementation.\n** This implementation parses JSON text at 250 MB/s, so it is hard to see\n** how JSONB might improve on that.)\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)\n#if !defined(SQLITEINT_H)\n#include \"sqlite3ext.h\"\n#endif\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef LARGEST_INT64\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** Versions of isspace(), isalnum() and isdigit() to which it is safe\n** to pass signed char values.\n*/\n#ifdef sqlite3Isdigit\n   /* Use the SQLite core versions if this routine is part of the\n   ** SQLite amalgamation */\n#  define safe_isdigit(x)  sqlite3Isdigit(x)\n#  define safe_isalnum(x)  sqlite3Isalnum(x)\n#  define safe_isxdigit(x) sqlite3Isxdigit(x)\n#else\n   /* Use the standard library for separate compilation */\n#include <ctype.h>  /* amalgamator: keep */\n#  define safe_isdigit(x)  isdigit((unsigned char)(x))\n#  define safe_isalnum(x)  isalnum((unsigned char)(x))\n#  define safe_isxdigit(x) isxdigit((unsigned char)(x))\n#endif\n\n/*\n** Growing our own isspace() routine this way is twice as fast as\n** the library isspace() function, resulting in a 7% overall performance\n** increase for the parser.  (Ubuntu14.10 gcc 4.8.4 x64 with -Os).\n*/\nstatic const char jsonIsSpace[] = {\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 1, 1, 0, 0, 1, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  1, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n};\n#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])\n\n#ifndef SQLITE_AMALGAMATION\n  /* Unsigned integer types.  These are already defined in the sqliteInt.h,\n  ** but the definitions need to be repeated for separate compilation. */\n  typedef sqlite3_uint64 u64;\n  typedef unsigned int u32;\n  typedef unsigned short int u16;\n  typedef unsigned char u8;\n#endif\n\n/* Objects */\ntypedef struct JsonString JsonString;\ntypedef struct JsonNode JsonNode;\ntypedef struct JsonParse JsonParse;\n\n/* An instance of this object represents a JSON string\n** under construction.  Really, this is a generic string accumulator\n** that can be and is used to create strings other than JSON.\n*/\nstruct JsonString {\n  sqlite3_context *pCtx;   /* Function context - put error messages here */\n  char *zBuf;              /* Append JSON content here */\n  u64 nAlloc;              /* Bytes of storage available in zBuf[] */\n  u64 nUsed;               /* Bytes of zBuf[] currently used */\n  u8 bStatic;              /* True if zBuf is static space */\n  u8 bErr;                 /* True if an error has been encountered */\n  char zSpace[100];        /* Initial static space */\n};\n\n/* JSON type values\n*/\n#define JSON_NULL     0\n#define JSON_TRUE     1\n#define JSON_FALSE    2\n#define JSON_INT      3\n#define JSON_REAL     4\n#define JSON_STRING   5\n#define JSON_ARRAY    6\n#define JSON_OBJECT   7\n\n/* The \"subtype\" set for JSON values */\n#define JSON_SUBTYPE  74    /* Ascii for \"J\" */\n\n/*\n** Names of the various JSON types:\n*/\nstatic const char * const jsonType[] = {\n  \"null\", \"true\", \"false\", \"integer\", \"real\", \"text\", \"array\", \"object\"\n};\n\n/* Bit values for the JsonNode.jnFlag field\n*/\n#define JNODE_RAW     0x01         /* Content is raw, not JSON encoded */\n#define JNODE_ESCAPE  0x02         /* Content is text with \\ escapes */\n#define JNODE_REMOVE  0x04         /* Do not output */\n#define JNODE_REPLACE 0x08         /* Replace with JsonNode.u.iReplace */\n#define JNODE_PATCH   0x10         /* Patch with JsonNode.u.pPatch */\n#define JNODE_APPEND  0x20         /* More ARRAY/OBJECT entries at u.iAppend */\n#define JNODE_LABEL   0x40         /* Is a label of an object */\n\n\n/* A single node of parsed JSON\n*/\nstruct JsonNode {\n  u8 eType;              /* One of the JSON_ type values */\n  u8 jnFlags;            /* JNODE flags */\n  u32 n;                 /* Bytes of content, or number of sub-nodes */\n  union {\n    const char *zJContent; /* Content for INT, REAL, and STRING */\n    u32 iAppend;           /* More terms for ARRAY and OBJECT */\n    u32 iKey;              /* Key for ARRAY objects in json_tree() */\n    u32 iReplace;          /* Replacement content for JNODE_REPLACE */\n    JsonNode *pPatch;      /* Node chain of patch for JNODE_PATCH */\n  } u;\n};\n\n/* A completely parsed JSON string\n*/\nstruct JsonParse {\n  u32 nNode;         /* Number of slots of aNode[] used */\n  u32 nAlloc;        /* Number of slots of aNode[] allocated */\n  JsonNode *aNode;   /* Array of nodes containing the parse */\n  const char *zJson; /* Original JSON string */\n  u32 *aUp;          /* Index of parent of each node */\n  u8 oom;            /* Set to true if out of memory */\n  u8 nErr;           /* Number of errors seen */\n  u16 iDepth;        /* Nesting depth */\n  int nJson;         /* Length of the zJson string in bytes */\n};\n\n/*\n** Maximum nesting depth of JSON for this implementation.\n**\n** This limit is needed to avoid a stack overflow in the recursive\n** descent parser.  A depth of 2000 is far deeper than any sane JSON\n** should go.\n*/\n#define JSON_MAX_DEPTH  2000\n\n/**************************************************************************\n** Utility routines for dealing with JsonString objects\n**************************************************************************/\n\n/* Set the JsonString object to an empty string\n*/\nstatic void jsonZero(JsonString *p){\n  p->zBuf = p->zSpace;\n  p->nAlloc = sizeof(p->zSpace);\n  p->nUsed = 0;\n  p->bStatic = 1;\n}\n\n/* Initialize the JsonString object\n*/\nstatic void jsonInit(JsonString *p, sqlite3_context *pCtx){\n  p->pCtx = pCtx;\n  p->bErr = 0;\n  jsonZero(p);\n}\n\n\n/* Free all allocated memory and reset the JsonString object back to its\n** initial state.\n*/\nstatic void jsonReset(JsonString *p){\n  if( !p->bStatic ) sqlite3_free(p->zBuf);\n  jsonZero(p);\n}\n\n\n/* Report an out-of-memory (OOM) condition \n*/\nstatic void jsonOom(JsonString *p){\n  p->bErr = 1;\n  sqlite3_result_error_nomem(p->pCtx);\n  jsonReset(p);\n}\n\n/* Enlarge pJson->zBuf so that it can hold at least N more bytes.\n** Return zero on success.  Return non-zero on an OOM error\n*/\nstatic int jsonGrow(JsonString *p, u32 N){\n  u64 nTotal = N<p->nAlloc ? p->nAlloc*2 : p->nAlloc+N+10;\n  char *zNew;\n  if( p->bStatic ){\n    if( p->bErr ) return 1;\n    zNew = sqlite3_malloc64(nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    memcpy(zNew, p->zBuf, (size_t)p->nUsed);\n    p->zBuf = zNew;\n    p->bStatic = 0;\n  }else{\n    zNew = sqlite3_realloc64(p->zBuf, nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    p->zBuf = zNew;\n  }\n  p->nAlloc = nTotal;\n  return SQLITE_OK;\n}\n\n/* Append N bytes from zIn onto the end of the JsonString string.\n*/\nstatic void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){\n  if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;\n  memcpy(p->zBuf+p->nUsed, zIn, N);\n  p->nUsed += N;\n}\n\n/* Append formatted text (not to exceed N bytes) to the JsonString.\n*/\nstatic void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){\n  va_list ap;\n  if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return;\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap);\n  va_end(ap);\n  p->nUsed += (int)strlen(p->zBuf+p->nUsed);\n}\n\n/* Append a single character\n*/\nstatic void jsonAppendChar(JsonString *p, char c){\n  if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return;\n  p->zBuf[p->nUsed++] = c;\n}\n\n/* Append a comma separator to the output buffer, if the previous\n** character is not '[' or '{'.\n*/\nstatic void jsonAppendSeparator(JsonString *p){\n  char c;\n  if( p->nUsed==0 ) return;\n  c = p->zBuf[p->nUsed-1];\n  if( c!='[' && c!='{' ) jsonAppendChar(p, ',');\n}\n\n/* Append the N-byte string in zIn to the end of the JsonString string\n** under construction.  Enclose the string in \"...\" and escape\n** any double-quotes or backslash characters contained within the\n** string.\n*/\nstatic void jsonAppendString(JsonString *p, const char *zIn, u32 N){\n  u32 i;\n  if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return;\n  p->zBuf[p->nUsed++] = '\"';\n  for(i=0; i<N; i++){\n    unsigned char c = ((unsigned const char*)zIn)[i];\n    if( c=='\"' || c=='\\\\' ){\n      json_simple_escape:\n      if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n    }else if( c<=0x1f ){\n      static const char aSpecial[] = {\n         0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,\n         0, 0, 0, 0, 0, 0, 0, 0,   0,   0,   0, 0,   0,   0, 0, 0\n      };\n      assert( sizeof(aSpecial)==32 );\n      assert( aSpecial['\\b']=='b' );\n      assert( aSpecial['\\f']=='f' );\n      assert( aSpecial['\\n']=='n' );\n      assert( aSpecial['\\r']=='r' );\n      assert( aSpecial['\\t']=='t' );\n      if( aSpecial[c] ){\n        c = aSpecial[c];\n        goto json_simple_escape;\n      }\n      if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n      p->zBuf[p->nUsed++] = 'u';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0' + (c>>4);\n      c = \"0123456789abcdef\"[c&0xf];\n    }\n    p->zBuf[p->nUsed++] = c;\n  }\n  p->zBuf[p->nUsed++] = '\"';\n  assert( p->nUsed<p->nAlloc );\n}\n\n/*\n** Append a function parameter value to the JSON string under \n** construction.\n*/\nstatic void jsonAppendValue(\n  JsonString *p,                 /* Append to this JSON string */\n  sqlite3_value *pValue          /* Value to append */\n){\n  switch( sqlite3_value_type(pValue) ){\n    case SQLITE_NULL: {\n      jsonAppendRaw(p, \"null\", 4);\n      break;\n    }\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      jsonAppendRaw(p, z, n);\n      break;\n    }\n    case SQLITE_TEXT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){\n        jsonAppendRaw(p, z, n);\n      }else{\n        jsonAppendString(p, z, n);\n      }\n      break;\n    }\n    default: {\n      if( p->bErr==0 ){\n        sqlite3_result_error(p->pCtx, \"JSON cannot hold BLOB values\", -1);\n        p->bErr = 2;\n        jsonReset(p);\n      }\n      break;\n    }\n  }\n}\n\n\n/* Make the JSON in p the result of the SQL function.\n*/\nstatic void jsonResult(JsonString *p){\n  if( p->bErr==0 ){\n    sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, \n                          p->bStatic ? SQLITE_TRANSIENT : sqlite3_free,\n                          SQLITE_UTF8);\n    jsonZero(p);\n  }\n  assert( p->bStatic );\n}\n\n/**************************************************************************\n** Utility routines for dealing with JsonNode and JsonParse objects\n**************************************************************************/\n\n/*\n** Return the number of consecutive JsonNode slots need to represent\n** the parsed JSON at pNode.  The minimum answer is 1.  For ARRAY and\n** OBJECT types, the number might be larger.\n**\n** Appended elements are not counted.  The value returned is the number\n** by which the JsonNode counter should increment in order to go to the\n** next peer value.\n*/\nstatic u32 jsonNodeSize(JsonNode *pNode){\n  return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1;\n}\n\n/*\n** Reclaim all memory allocated by a JsonParse object.  But do not\n** delete the JsonParse object itself.\n*/\nstatic void jsonParseReset(JsonParse *pParse){\n  sqlite3_free(pParse->aNode);\n  pParse->aNode = 0;\n  pParse->nNode = 0;\n  pParse->nAlloc = 0;\n  sqlite3_free(pParse->aUp);\n  pParse->aUp = 0;\n}\n\n/*\n** Free a JsonParse object that was obtained from sqlite3_malloc().\n*/\nstatic void jsonParseFree(JsonParse *pParse){\n  jsonParseReset(pParse);\n  sqlite3_free(pParse);\n}\n\n/*\n** Convert the JsonNode pNode into a pure JSON string and\n** append to pOut.  Subsubstructure is also included.  Return\n** the number of JsonNode objects that are encoded.\n*/\nstatic void jsonRenderNode(\n  JsonNode *pNode,               /* The node to render */\n  JsonString *pOut,              /* Write JSON here */\n  sqlite3_value **aReplace       /* Replacement values */\n){\n  if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){\n    if( pNode->jnFlags & JNODE_REPLACE ){\n      jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);\n      return;\n    }\n    pNode = pNode->u.pPatch;\n  }\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      jsonAppendRaw(pOut, \"null\", 4);\n      break;\n    }\n    case JSON_TRUE: {\n      jsonAppendRaw(pOut, \"true\", 4);\n      break;\n    }\n    case JSON_FALSE: {\n      jsonAppendRaw(pOut, \"false\", 5);\n      break;\n    }\n    case JSON_STRING: {\n      if( pNode->jnFlags & JNODE_RAW ){\n        jsonAppendString(pOut, pNode->u.zJContent, pNode->n);\n        break;\n      }\n      /* Fall through into the next case */\n    }\n    case JSON_REAL:\n    case JSON_INT: {\n      jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n);\n      break;\n    }\n    case JSON_ARRAY: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '[');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n          }\n          j += jsonNodeSize(&pNode[j]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, ']');\n      break;\n    }\n    case JSON_OBJECT: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '{');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n            jsonAppendChar(pOut, ':');\n            jsonRenderNode(&pNode[j+1], pOut, aReplace);\n          }\n          j += 1 + jsonNodeSize(&pNode[j+1]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, '}');\n      break;\n    }\n  }\n}\n\n/*\n** Return a JsonNode and all its descendents as a JSON string.\n*/\nstatic void jsonReturnJson(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  JsonString s;\n  jsonInit(&s, pCtx);\n  jsonRenderNode(pNode, &s, aReplace);\n  jsonResult(&s);\n  sqlite3_result_subtype(pCtx, JSON_SUBTYPE);\n}\n\n/*\n** Make the JsonNode the return value of the function.\n*/\nstatic void jsonReturn(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      sqlite3_result_null(pCtx);\n      break;\n    }\n    case JSON_TRUE: {\n      sqlite3_result_int(pCtx, 1);\n      break;\n    }\n    case JSON_FALSE: {\n      sqlite3_result_int(pCtx, 0);\n      break;\n    }\n    case JSON_INT: {\n      sqlite3_int64 i = 0;\n      const char *z = pNode->u.zJContent;\n      if( z[0]=='-' ){ z++; }\n      while( z[0]>='0' && z[0]<='9' ){\n        unsigned v = *(z++) - '0';\n        if( i>=LARGEST_INT64/10 ){\n          if( i>LARGEST_INT64/10 ) goto int_as_real;\n          if( z[0]>='0' && z[0]<='9' ) goto int_as_real;\n          if( v==9 ) goto int_as_real;\n          if( v==8 ){\n            if( pNode->u.zJContent[0]=='-' ){\n              sqlite3_result_int64(pCtx, SMALLEST_INT64);\n              goto int_done;\n            }else{\n              goto int_as_real;\n            }\n          }\n        }\n        i = i*10 + v;\n      }\n      if( pNode->u.zJContent[0]=='-' ){ i = -i; }\n      sqlite3_result_int64(pCtx, i);\n      int_done:\n      break;\n      int_as_real: /* fall through to real */;\n    }\n    case JSON_REAL: {\n      double r;\n#ifdef SQLITE_AMALGAMATION\n      const char *z = pNode->u.zJContent;\n      sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);\n#else\n      r = strtod(pNode->u.zJContent, 0);\n#endif\n      sqlite3_result_double(pCtx, r);\n      break;\n    }\n    case JSON_STRING: {\n#if 0 /* Never happens because JNODE_RAW is only set by json_set(),\n      ** json_insert() and json_replace() and those routines do not\n      ** call jsonReturn() */\n      if( pNode->jnFlags & JNODE_RAW ){\n        sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n,\n                            SQLITE_TRANSIENT);\n      }else \n#endif\n      assert( (pNode->jnFlags & JNODE_RAW)==0 );\n      if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){\n        /* JSON formatted without any backslash-escapes */\n        sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2,\n                            SQLITE_TRANSIENT);\n      }else{\n        /* Translate JSON formatted string into raw text */\n        u32 i;\n        u32 n = pNode->n;\n        const char *z = pNode->u.zJContent;\n        char *zOut;\n        u32 j;\n        zOut = sqlite3_malloc( n+1 );\n        if( zOut==0 ){\n          sqlite3_result_error_nomem(pCtx);\n          break;\n        }\n        for(i=1, j=0; i<n-1; i++){\n          char c = z[i];\n          if( c!='\\\\' ){\n            zOut[j++] = c;\n          }else{\n            c = z[++i];\n            if( c=='u' ){\n              u32 v = 0, k;\n              for(k=0; k<4; i++, k++){\n                assert( i<n-2 );\n                c = z[i+1];\n                assert( safe_isxdigit(c) );\n                if( c<='9' ) v = v*16 + c - '0';\n                else if( c<='F' ) v = v*16 + c - 'A' + 10;\n                else v = v*16 + c - 'a' + 10;\n              }\n              if( v==0 ) break;\n              if( v<=0x7f ){\n                zOut[j++] = (char)v;\n              }else if( v<=0x7ff ){\n                zOut[j++] = (char)(0xc0 | (v>>6));\n                zOut[j++] = 0x80 | (v&0x3f);\n              }else{\n                zOut[j++] = (char)(0xe0 | (v>>12));\n                zOut[j++] = 0x80 | ((v>>6)&0x3f);\n                zOut[j++] = 0x80 | (v&0x3f);\n              }\n            }else{\n              if( c=='b' ){\n                c = '\\b';\n              }else if( c=='f' ){\n                c = '\\f';\n              }else if( c=='n' ){\n                c = '\\n';\n              }else if( c=='r' ){\n                c = '\\r';\n              }else if( c=='t' ){\n                c = '\\t';\n              }\n              zOut[j++] = c;\n            }\n          }\n        }\n        zOut[j] = 0;\n        sqlite3_result_text(pCtx, zOut, j, sqlite3_free);\n      }\n      break;\n    }\n    case JSON_ARRAY:\n    case JSON_OBJECT: {\n      jsonReturnJson(pNode, pCtx, aReplace);\n      break;\n    }\n  }\n}\n\n/* Forward reference */\nstatic int jsonParseAddNode(JsonParse*,u32,u32,const char*);\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define JSON_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define JSON_NOINLINE  __declspec(noinline)\n#else\n#  define JSON_NOINLINE\n#endif\n\n\nstatic JSON_NOINLINE int jsonParseAddNodeExpand(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  u32 nNew;\n  JsonNode *pNew;\n  assert( pParse->nNode>=pParse->nAlloc );\n  if( pParse->oom ) return -1;\n  nNew = pParse->nAlloc*2 + 10;\n  pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);\n  if( pNew==0 ){\n    pParse->oom = 1;\n    return -1;\n  }\n  pParse->nAlloc = nNew;\n  pParse->aNode = pNew;\n  assert( pParse->nNode<pParse->nAlloc );\n  return jsonParseAddNode(pParse, eType, n, zContent);\n}\n\n/*\n** Create a new JsonNode instance based on the arguments and append that\n** instance to the JsonParse.  Return the index in pParse->aNode[] of the\n** new node, or -1 if a memory allocation fails.\n*/\nstatic int jsonParseAddNode(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  JsonNode *p;\n  if( pParse->nNode>=pParse->nAlloc ){\n    return jsonParseAddNodeExpand(pParse, eType, n, zContent);\n  }\n  p = &pParse->aNode[pParse->nNode];\n  p->eType = (u8)eType;\n  p->jnFlags = 0;\n  p->n = n;\n  p->u.zJContent = zContent;\n  return pParse->nNode++;\n}\n\n/*\n** Return true if z[] begins with 4 (or more) hexadecimal digits\n*/\nstatic int jsonIs4Hex(const char *z){\n  int i;\n  for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;\n  return 1;\n}\n\n/*\n** Parse a single JSON value which begins at pParse->zJson[i].  Return the\n** index of the first character past the end of the value parsed.\n**\n** Return negative for a syntax error.  Special cases:  return -2 if the\n** first non-whitespace character is '}' and return -3 if the first\n** non-whitespace character is ']'.\n*/\nstatic int jsonParseValue(JsonParse *pParse, u32 i){\n  char c;\n  u32 j;\n  int iThis;\n  int x;\n  JsonNode *pNode;\n  const char *z = pParse->zJson;\n  while( safe_isspace(z[i]) ){ i++; }\n  if( (c = z[i])=='{' ){\n    /* Parse object */\n    iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      if( x<0 ){\n        pParse->iDepth--;\n        if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      if( pParse->oom ) return -1;\n      pNode = &pParse->aNode[pParse->nNode-1];\n      if( pNode->eType!=JSON_STRING ) return -1;\n      pNode->jnFlags |= JNODE_LABEL;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      if( z[j]!=':' ) return -1;\n      j++;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ) return -1;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!='}' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='[' ){\n    /* Parse array */\n    iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ){\n        if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!=']' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='\"' ){\n    /* Parse string */\n    u8 jnFlags = 0;\n    j = i+1;\n    for(;;){\n      c = z[j];\n      if( (c & ~0x1f)==0 ){\n        /* Control characters are not allowed in strings */\n        return -1;\n      }\n      if( c=='\\\\' ){\n        c = z[++j];\n        if( c=='\"' || c=='\\\\' || c=='/' || c=='b' || c=='f'\n           || c=='n' || c=='r' || c=='t'\n           || (c=='u' && jsonIs4Hex(z+j+1)) ){\n          jnFlags = JNODE_ESCAPE;\n        }else{\n          return -1;\n        }\n      }else if( c=='\"' ){\n        break;\n      }\n      j++;\n    }\n    jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]);\n    if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags;\n    return j+1;\n  }else if( c=='n'\n         && strncmp(z+i,\"null\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return i+4;\n  }else if( c=='t'\n         && strncmp(z+i,\"true\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n    return i+4;\n  }else if( c=='f'\n         && strncmp(z+i,\"false\",5)==0\n         && !safe_isalnum(z[i+5]) ){\n    jsonParseAddNode(pParse, JSON_FALSE, 0, 0);\n    return i+5;\n  }else if( c=='-' || (c>='0' && c<='9') ){\n    /* Parse number */\n    u8 seenDP = 0;\n    u8 seenE = 0;\n    assert( '-' < '0' );\n    if( c<='0' ){\n      j = c=='-' ? i+1 : i;\n      if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1;\n    }\n    j = i+1;\n    for(;; j++){\n      c = z[j];\n      if( c>='0' && c<='9' ) continue;\n      if( c=='.' ){\n        if( z[j-1]=='-' ) return -1;\n        if( seenDP ) return -1;\n        seenDP = 1;\n        continue;\n      }\n      if( c=='e' || c=='E' ){\n        if( z[j-1]<'0' ) return -1;\n        if( seenE ) return -1;\n        seenDP = seenE = 1;\n        c = z[j+1];\n        if( c=='+' || c=='-' ){\n          j++;\n          c = z[j+1];\n        }\n        if( c<'0' || c>'9' ) return -1;\n        continue;\n      }\n      break;\n    }\n    if( z[j-1]<'0' ) return -1;\n    jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,\n                        j - i, &z[i]);\n    return j;\n  }else if( c=='}' ){\n    return -2;  /* End of {...} */\n  }else if( c==']' ){\n    return -3;  /* End of [...] */\n  }else if( c==0 ){\n    return 0;   /* End of file */\n  }else{\n    return -1;  /* Syntax error */\n  }\n}\n\n/*\n** Parse a complete JSON string.  Return 0 on success or non-zero if there\n** are any errors.  If an error occurs, free all memory associated with\n** pParse.\n**\n** pParse is uninitialized when this routine is called.\n*/\nstatic int jsonParse(\n  JsonParse *pParse,           /* Initialize and fill this JsonParse object */\n  sqlite3_context *pCtx,       /* Report errors here */\n  const char *zJson            /* Input JSON text to be parsed */\n){\n  int i;\n  memset(pParse, 0, sizeof(*pParse));\n  if( zJson==0 ) return 1;\n  pParse->zJson = zJson;\n  i = jsonParseValue(pParse, 0);\n  if( pParse->oom ) i = -1;\n  if( i>0 ){\n    assert( pParse->iDepth==0 );\n    while( safe_isspace(zJson[i]) ) i++;\n    if( zJson[i] ) i = -1;\n  }\n  if( i<=0 ){\n    if( pCtx!=0 ){\n      if( pParse->oom ){\n        sqlite3_result_error_nomem(pCtx);\n      }else{\n        sqlite3_result_error(pCtx, \"malformed JSON\", -1);\n      }\n    }\n    jsonParseReset(pParse);\n    return 1;\n  }\n  return 0;\n}\n\n/* Mark node i of pParse as being a child of iParent.  Call recursively\n** to fill in all the descendants of node i.\n*/\nstatic void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){\n  JsonNode *pNode = &pParse->aNode[i];\n  u32 j;\n  pParse->aUp[i] = iParent;\n  switch( pNode->eType ){\n    case JSON_ARRAY: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){\n        jsonParseFillInParentage(pParse, i+j, i);\n      }\n      break;\n    }\n    case JSON_OBJECT: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){\n        pParse->aUp[i+j] = i;\n        jsonParseFillInParentage(pParse, i+j+1, i);\n      }\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n}\n\n/*\n** Compute the parentage of all nodes in a completed parse.\n*/\nstatic int jsonParseFindParents(JsonParse *pParse){\n  u32 *aUp;\n  assert( pParse->aUp==0 );\n  aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );\n  if( aUp==0 ){\n    pParse->oom = 1;\n    return SQLITE_NOMEM;\n  }\n  jsonParseFillInParentage(pParse, 0, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Magic number used for the JSON parse cache in sqlite3_get_auxdata()\n*/\n#define JSON_CACHE_ID  (-429938)\n\n/*\n** Obtain a complete parse of the JSON found in the first argument\n** of the argv array.  Use the sqlite3_get_auxdata() cache for this\n** parse if it is available.  If the cache is not available or if it\n** is no longer valid, parse the JSON again and return the new parse,\n** and also register the new parse so that it will be available for\n** future sqlite3_get_auxdata() calls.\n*/\nstatic JsonParse *jsonParseCached(\n  sqlite3_context *pCtx,\n  sqlite3_value **argv\n){\n  const char *zJson = (const char*)sqlite3_value_text(argv[0]);\n  int nJson = sqlite3_value_bytes(argv[0]);\n  JsonParse *p;\n  if( zJson==0 ) return 0;\n  p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);\n  if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){\n    p->nErr = 0;\n    return p; /* The cached entry matches, so return it */\n  }\n  p = sqlite3_malloc( sizeof(*p) + nJson + 1 );\n  if( p==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return 0;\n  }\n  memset(p, 0, sizeof(*p));\n  p->zJson = (char*)&p[1];\n  memcpy((char*)p->zJson, zJson, nJson+1);\n  if( jsonParse(p, pCtx, p->zJson) ){\n    sqlite3_free(p);\n    return 0;\n  }\n  p->nJson = nJson;\n  sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree);\n  return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);\n}\n\n/*\n** Compare the OBJECT label at pNode against zKey,nKey.  Return true on\n** a match.\n*/\nstatic int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){\n  if( pNode->jnFlags & JNODE_RAW ){\n    if( pNode->n!=nKey ) return 0;\n    return strncmp(pNode->u.zJContent, zKey, nKey)==0;\n  }else{\n    if( pNode->n!=nKey+2 ) return 0;\n    return strncmp(pNode->u.zJContent+1, zKey, nKey)==0;\n  }\n}\n\n/* forward declaration */\nstatic JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**);\n\n/*\n** Search along zPath to find the node specified.  Return a pointer\n** to that node, or NULL if zPath is malformed or if there is no such\n** node.\n**\n** If pApnd!=0, then try to append new nodes to complete zPath if it is\n** possible to do so and if no existing node corresponds to zPath.  If\n** new nodes are appended *pApnd is set to 1.\n*/\nstatic JsonNode *jsonLookupStep(\n  JsonParse *pParse,      /* The JSON to search */\n  u32 iRoot,              /* Begin the search at this node */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  const char **pzErr      /* Make *pzErr point to any syntax error in zPath */\n){\n  u32 i, j, nKey;\n  const char *zKey;\n  JsonNode *pRoot = &pParse->aNode[iRoot];\n  if( zPath[0]==0 ) return pRoot;\n  if( zPath[0]=='.' ){\n    if( pRoot->eType!=JSON_OBJECT ) return 0;\n    zPath++;\n    if( zPath[0]=='\"' ){\n      zKey = zPath + 1;\n      for(i=1; zPath[i] && zPath[i]!='\"'; i++){}\n      nKey = i-1;\n      if( zPath[i] ){\n        i++;\n      }else{\n        *pzErr = zPath;\n        return 0;\n      }\n    }else{\n      zKey = zPath;\n      for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}\n      nKey = i;\n    }\n    if( nKey==0 ){\n      *pzErr = zPath;\n      return 0;\n    }\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n ){\n        if( jsonLabelCompare(pRoot+j, zKey, nKey) ){\n          return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr);\n        }\n        j++;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( pApnd ){\n      u32 iStart, iLabel;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      iLabel = jsonParseAddNode(pParse, JSON_STRING, i, zPath);\n      zPath += i;\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n        pParse->aNode[iLabel].jnFlags |= JNODE_RAW;\n      }\n      return pNode;\n    }\n  }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){\n    if( pRoot->eType!=JSON_ARRAY ) return 0;\n    i = 0;\n    j = 1;\n    while( safe_isdigit(zPath[j]) ){\n      i = i*10 + zPath[j] - '0';\n      j++;\n    }\n    if( zPath[j]!=']' ){\n      *pzErr = zPath;\n      return 0;\n    }\n    zPath += j + 1;\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){\n        if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( j<=pRoot->n ){\n      return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr);\n    }\n    if( i==0 && pApnd ){\n      u32 iStart;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0);\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n      }\n      return pNode;\n    }\n  }else{\n    *pzErr = zPath;\n  }\n  return 0;\n}\n\n/*\n** Append content to pParse that will complete zPath.  Return a pointer\n** to the inserted node, or return NULL if the append fails.\n*/\nstatic JsonNode *jsonLookupAppend(\n  JsonParse *pParse,     /* Append content to the JSON parse */\n  const char *zPath,     /* Description of content to append */\n  int *pApnd,            /* Set this flag to 1 */\n  const char **pzErr     /* Make this point to any syntax error */\n){\n  *pApnd = 1;\n  if( zPath[0]==0 ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1];\n  }\n  if( zPath[0]=='.' ){\n    jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n  }else if( strncmp(zPath,\"[0]\",3)==0 ){\n    jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n  }else{\n    return 0;\n  }\n  if( pParse->oom ) return 0;\n  return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr);\n}\n\n/*\n** Return the text of a syntax error message on a JSON path.  Space is\n** obtained from sqlite3_malloc().\n*/\nstatic char *jsonPathSyntaxError(const char *zErr){\n  return sqlite3_mprintf(\"JSON path error near '%q'\", zErr);\n}\n\n/*\n** Do a node lookup using zPath.  Return a pointer to the node on success.\n** Return NULL if not found or if there is an error.\n**\n** On an error, write an error message into pCtx and increment the\n** pParse->nErr counter.\n**\n** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if\n** nodes are appended.\n*/\nstatic JsonNode *jsonLookup(\n  JsonParse *pParse,      /* The JSON to search */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  sqlite3_context *pCtx   /* Report errors here, if not NULL */\n){\n  const char *zErr = 0;\n  JsonNode *pNode = 0;\n  char *zMsg;\n\n  if( zPath==0 ) return 0;\n  if( zPath[0]!='$' ){\n    zErr = zPath;\n    goto lookup_err;\n  }\n  zPath++;\n  pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr);\n  if( zErr==0 ) return pNode;\n\nlookup_err:\n  pParse->nErr++;\n  assert( zErr!=0 && pCtx!=0 );\n  zMsg = jsonPathSyntaxError(zErr);\n  if( zMsg ){\n    sqlite3_result_error(pCtx, zMsg, -1);\n    sqlite3_free(zMsg);\n  }else{\n    sqlite3_result_error_nomem(pCtx);\n  }\n  return 0;\n}\n\n\n/*\n** Report the wrong number of arguments for json_insert(), json_replace()\n** or json_set().\n*/\nstatic void jsonWrongNumArgs(\n  sqlite3_context *pCtx,\n  const char *zFuncName\n){\n  char *zMsg = sqlite3_mprintf(\"json_%s() needs an odd number of arguments\",\n                               zFuncName);\n  sqlite3_result_error(pCtx, zMsg, -1);\n  sqlite3_free(zMsg);     \n}\n\n/*\n** Mark all NULL entries in the Object passed in as JNODE_REMOVE.\n*/\nstatic void jsonRemoveAllNulls(JsonNode *pNode){\n  int i, n;\n  assert( pNode->eType==JSON_OBJECT );\n  n = pNode->n;\n  for(i=2; i<=n; i += jsonNodeSize(&pNode[i])+1){\n    switch( pNode[i].eType ){\n      case JSON_NULL:\n        pNode[i].jnFlags |= JNODE_REMOVE;\n        break;\n      case JSON_OBJECT:\n        jsonRemoveAllNulls(&pNode[i]);\n        break;\n    }\n  }\n}\n\n\n/****************************************************************************\n** SQL functions used for testing and debugging\n****************************************************************************/\n\n#ifdef SQLITE_DEBUG\n/*\n** The json_parse(JSON) function returns a string which describes\n** a parse of the JSON provided.  Or it returns NULL if JSON is not\n** well-formed.\n*/\nstatic void jsonParseFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString s;       /* Output string - not real JSON */\n  JsonParse x;        /* The parse */\n  u32 i;\n\n  assert( argc==1 );\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  jsonParseFindParents(&x);\n  jsonInit(&s, ctx);\n  for(i=0; i<x.nNode; i++){\n    const char *zType;\n    if( x.aNode[i].jnFlags & JNODE_LABEL ){\n      assert( x.aNode[i].eType==JSON_STRING );\n      zType = \"label\";\n    }else{\n      zType = jsonType[x.aNode[i].eType];\n    }\n    jsonPrintf(100, &s,\"node %3u: %7s n=%-4d up=%-4d\",\n               i, zType, x.aNode[i].n, x.aUp[i]);\n    if( x.aNode[i].u.zJContent!=0 ){\n      jsonAppendRaw(&s, \" \", 1);\n      jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n);\n    }\n    jsonAppendRaw(&s, \"\\n\", 1);\n  }\n  jsonParseReset(&x);\n  jsonResult(&s);\n}\n\n/*\n** The json_test1(JSON) function return true (1) if the input is JSON\n** text generated by another json function.  It returns (0) if the input\n** is not known to be JSON.\n*/\nstatic void jsonTest1Func(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAM(argc);\n  sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);\n}\n#endif /* SQLITE_DEBUG */\n\n/****************************************************************************\n** Scalar SQL function implementations\n****************************************************************************/\n\n/*\n** Implementation of the json_QUOTE(VALUE) function.  Return a JSON value\n** corresponding to the SQL value input.  Mostly this means putting \n** double-quotes around strings and returning the unquoted string \"null\"\n** when given a NULL input.\n*/\nstatic void jsonQuoteFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString jx;\n  UNUSED_PARAM(argc);\n\n  jsonInit(&jx, ctx);\n  jsonAppendValue(&jx, argv[0]);\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n/*\n** Implementation of the json_array(VALUE,...) function.  Return a JSON\n** array that contains all values given in arguments.  Or if any argument\n** is a BLOB, throw an error.\n*/\nstatic void jsonArrayFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=0; i<argc; i++){\n    jsonAppendSeparator(&jx);\n    jsonAppendValue(&jx, argv[i]);\n  }\n  jsonAppendChar(&jx, ']');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_array_length(JSON)\n** json_array_length(JSON, PATH)\n**\n** Return the number of elements in the top-level JSON array.  \n** Return 0 if the input is not a well-formed JSON array.\n*/\nstatic void jsonArrayLengthFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  sqlite3_int64 n = 0;\n  u32 i;\n  JsonNode *pNode;\n\n  p = jsonParseCached(ctx, argv);\n  if( p==0 ) return;\n  assert( p->nNode );\n  if( argc==2 ){\n    const char *zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n  }else{\n    pNode = p->aNode;\n  }\n  if( pNode==0 ){\n    return;\n  }\n  if( pNode->eType==JSON_ARRAY ){\n    assert( (pNode->jnFlags & JNODE_APPEND)==0 );\n    for(i=1; i<=pNode->n; n++){\n      i += jsonNodeSize(&pNode[i]);\n    }\n  }\n  sqlite3_result_int64(ctx, n);\n}\n\n/*\n** json_extract(JSON, PATH, ...)\n**\n** Return the element described by PATH.  Return NULL if there is no\n** PATH element.  If there are multiple PATHs, then return a JSON array\n** with the result from each path.  Throw an error if the JSON or any PATH\n** is malformed.\n*/\nstatic void jsonExtractFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  JsonString jx;\n  int i;\n\n  if( argc<2 ) return;\n  p = jsonParseCached(ctx, argv);\n  if( p==0 ) return;\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=1; i<argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n    if( p->nErr ) break;\n    if( argc>2 ){\n      jsonAppendSeparator(&jx);\n      if( pNode ){\n        jsonRenderNode(pNode, &jx, 0);\n      }else{\n        jsonAppendRaw(&jx, \"null\", 4);\n      }\n    }else if( pNode ){\n      jsonReturn(pNode, ctx, 0);\n    }\n  }\n  if( argc>2 && i==argc ){\n    jsonAppendChar(&jx, ']');\n    jsonResult(&jx);\n    sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n  }\n  jsonReset(&jx);\n}\n\n/* This is the RFC 7396 MergePatch algorithm.\n*/\nstatic JsonNode *jsonMergePatch(\n  JsonParse *pParse,   /* The JSON parser that contains the TARGET */\n  u32 iTarget,         /* Node of the TARGET in pParse */\n  JsonNode *pPatch     /* The PATCH */\n){\n  u32 i, j;\n  u32 iRoot;\n  JsonNode *pTarget;\n  if( pPatch->eType!=JSON_OBJECT ){\n    return pPatch;\n  }\n  assert( iTarget>=0 && iTarget<pParse->nNode );\n  pTarget = &pParse->aNode[iTarget];\n  assert( (pPatch->jnFlags & JNODE_APPEND)==0 );\n  if( pTarget->eType!=JSON_OBJECT ){\n    jsonRemoveAllNulls(pPatch);\n    return pPatch;\n  }\n  iRoot = iTarget;\n  for(i=1; i<pPatch->n; i += jsonNodeSize(&pPatch[i+1])+1){\n    u32 nKey;\n    const char *zKey;\n    assert( pPatch[i].eType==JSON_STRING );\n    assert( pPatch[i].jnFlags & JNODE_LABEL );\n    nKey = pPatch[i].n;\n    zKey = pPatch[i].u.zJContent;\n    assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n    for(j=1; j<pTarget->n; j += jsonNodeSize(&pTarget[j+1])+1 ){\n      assert( pTarget[j].eType==JSON_STRING );\n      assert( pTarget[j].jnFlags & JNODE_LABEL );\n      assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n      if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){\n        if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break;\n        if( pPatch[i+1].eType==JSON_NULL ){\n          pTarget[j+1].jnFlags |= JNODE_REMOVE;\n        }else{\n          JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]);\n          if( pNew==0 ) return 0;\n          pTarget = &pParse->aNode[iTarget];\n          if( pNew!=&pTarget[j+1] ){\n            pTarget[j+1].u.pPatch = pNew;\n            pTarget[j+1].jnFlags |= JNODE_PATCH;\n          }\n        }\n        break;\n      }\n    }\n    if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){\n      int iStart, iPatch;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      jsonParseAddNode(pParse, JSON_STRING, nKey, zKey);\n      iPatch = jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n      if( pParse->oom ) return 0;\n      jsonRemoveAllNulls(pPatch);\n      pTarget = &pParse->aNode[iTarget];\n      pParse->aNode[iRoot].jnFlags |= JNODE_APPEND;\n      pParse->aNode[iRoot].u.iAppend = iStart - iRoot;\n      iRoot = iStart;\n      pParse->aNode[iPatch].jnFlags |= JNODE_PATCH;\n      pParse->aNode[iPatch].u.pPatch = &pPatch[i+1];\n    }\n  }\n  return pTarget;\n}\n\n/*\n** Implementation of the json_mergepatch(JSON1,JSON2) function.  Return a JSON\n** object that is the result of running the RFC 7396 MergePatch() algorithm\n** on the two arguments.\n*/\nstatic void jsonPatchFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;     /* The JSON that is being patched */\n  JsonParse y;     /* The patch */\n  JsonNode *pResult;   /* The result of the merge */\n\n  UNUSED_PARAM(argc);\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){\n    jsonParseReset(&x);\n    return;\n  }\n  pResult = jsonMergePatch(&x, 0, y.aNode);\n  assert( pResult!=0 || x.oom );\n  if( pResult ){\n    jsonReturnJson(pResult, ctx, 0);\n  }else{\n    sqlite3_result_error_nomem(ctx);\n  }\n  jsonParseReset(&x);\n  jsonParseReset(&y);\n}\n\n\n/*\n** Implementation of the json_object(NAME,VALUE,...) function.  Return a JSON\n** object that contains all name/value given in arguments.  Or if any name\n** is not a string or if any value is a BLOB, throw an error.\n*/\nstatic void jsonObjectFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n  const char *z;\n  u32 n;\n\n  if( argc&1 ){\n    sqlite3_result_error(ctx, \"json_object() requires an even number \"\n                                  \"of arguments\", -1);\n    return;\n  }\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '{');\n  for(i=0; i<argc; i+=2){\n    if( sqlite3_value_type(argv[i])!=SQLITE_TEXT ){\n      sqlite3_result_error(ctx, \"json_object() labels must be TEXT\", -1);\n      jsonReset(&jx);\n      return;\n    }\n    jsonAppendSeparator(&jx);\n    z = (const char*)sqlite3_value_text(argv[i]);\n    n = (u32)sqlite3_value_bytes(argv[i]);\n    jsonAppendString(&jx, z, n);\n    jsonAppendChar(&jx, ':');\n    jsonAppendValue(&jx, argv[i+1]);\n  }\n  jsonAppendChar(&jx, '}');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_remove(JSON, PATH, ...)\n**\n** Remove the named elements from JSON and return the result.  malformed\n** JSON or PATH arguments result in an error.\n*/\nstatic void jsonRemoveFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    if( zPath==0 ) goto remove_done;\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto remove_done;\n    if( pNode ) pNode->jnFlags |= JNODE_REMOVE;\n  }\n  if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){\n    jsonReturnJson(x.aNode, ctx, 0);\n  }\nremove_done:\n  jsonParseReset(&x);\n}\n\n/*\n** json_replace(JSON, PATH, VALUE, ...)\n**\n** Replace the value at PATH with VALUE.  If PATH does not already exist,\n** this routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonReplaceFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, \"replace\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto replace_err;\n    if( pNode ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\nreplace_err:\n  jsonParseReset(&x);\n}\n\n/*\n** json_set(JSON, PATH, VALUE, ...)\n**\n** Set the value at PATH to VALUE.  Create the PATH if it does not already\n** exist.  Overwrite existing values that do exist.\n** If JSON or PATH is malformed, throw an error.\n**\n** json_insert(JSON, PATH, VALUE, ...)\n**\n** Create PATH and initialize it to VALUE.  If PATH already exists, this\n** routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonSetFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n  int bApnd;\n  int bIsSet = *(int*)sqlite3_user_data(ctx);\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, bIsSet ? \"set\" : \"insert\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    bApnd = 0;\n    pNode = jsonLookup(&x, zPath, &bApnd, ctx);\n    if( x.oom ){\n      sqlite3_result_error_nomem(ctx);\n      goto jsonSetDone;\n    }else if( x.nErr ){\n      goto jsonSetDone;\n    }else if( pNode && (bApnd || bIsSet) ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\njsonSetDone:\n  jsonParseReset(&x);\n}\n\n/*\n** json_type(JSON)\n** json_type(JSON, PATH)\n**\n** Return the top-level \"type\" of a JSON string.  Throw an error if\n** either the JSON or PATH inputs are not well-formed.\n*/\nstatic void jsonTypeFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  const char *zPath;\n  JsonNode *pNode;\n\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  if( argc==2 ){\n    zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n  }else{\n    pNode = x.aNode;\n  }\n  if( pNode ){\n    sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC);\n  }\n  jsonParseReset(&x);\n}\n\n/*\n** json_valid(JSON)\n**\n** Return 1 if JSON is a well-formed JSON string according to RFC-7159.\n** Return 0 otherwise.\n*/\nstatic void jsonValidFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  int rc = 0;\n\n  UNUSED_PARAM(argc);\n  if( jsonParse(&x, 0, (const char*)sqlite3_value_text(argv[0]))==0 ){\n    rc = 1;\n  }\n  jsonParseReset(&x);\n  sqlite3_result_int(ctx, rc);\n}\n\n\n/****************************************************************************\n** Aggregate SQL function implementations\n****************************************************************************/\n/*\n** json_group_array(VALUE)\n**\n** Return a JSON array composed of all values in the aggregate.\n*/\nstatic void jsonArrayStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '[');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    jsonAppendValue(pStr, argv[0]);\n  }\n}\nstatic void jsonArrayFinal(sqlite3_context *ctx){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    pStr->pCtx = ctx;\n    jsonAppendChar(pStr, ']');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"[]\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n/*\n** json_group_obj(NAME,VALUE)\n**\n** Return a JSON object composed of all names and values in the aggregate.\n*/\nstatic void jsonObjectStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  const char *z;\n  u32 n;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '{');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    z = (const char*)sqlite3_value_text(argv[0]);\n    n = (u32)sqlite3_value_bytes(argv[0]);\n    jsonAppendString(pStr, z, n);\n    jsonAppendChar(pStr, ':');\n    jsonAppendValue(pStr, argv[1]);\n  }\n}\nstatic void jsonObjectFinal(sqlite3_context *ctx){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    jsonAppendChar(pStr, '}');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"{}\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/****************************************************************************\n** The json_each virtual table\n****************************************************************************/\ntypedef struct JsonEachCursor JsonEachCursor;\nstruct JsonEachCursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  u32 iRowid;                /* The rowid */\n  u32 iBegin;                /* The first node of the scan */\n  u32 i;                     /* Index in sParse.aNode[] of current row */\n  u32 iEnd;                  /* EOF when i equals or exceeds this value */\n  u8 eType;                  /* Type of top-level element */\n  u8 bRecursive;             /* True for json_tree().  False for json_each() */\n  char *zJson;               /* Input JSON */\n  char *zRoot;               /* Path by which to filter zJson */\n  JsonParse sParse;          /* Parse of the input JSON */\n};\n\n/* Constructor for the json_each virtual table */\nstatic int jsonEachConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define JEACH_KEY     0\n#define JEACH_VALUE   1\n#define JEACH_TYPE    2\n#define JEACH_ATOM    3\n#define JEACH_ID      4\n#define JEACH_PARENT  5\n#define JEACH_FULLKEY 6\n#define JEACH_PATH    7\n#define JEACH_JSON    8\n#define JEACH_ROOT    9\n\n  UNUSED_PARAM(pzErr);\n  UNUSED_PARAM(argv);\n  UNUSED_PARAM(argc);\n  UNUSED_PARAM(pAux);\n  rc = sqlite3_declare_vtab(db, \n     \"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,\"\n                    \"json HIDDEN,root HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/* destructor for json_each virtual table */\nstatic int jsonEachDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_each(). */\nstatic int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  JsonEachCursor *pCur;\n\n  UNUSED_PARAM(p);\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_tree(). */\nstatic int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  int rc = jsonEachOpenEach(p, ppCursor);\n  if( rc==SQLITE_OK ){\n    JsonEachCursor *pCur = (JsonEachCursor*)*ppCursor;\n    pCur->bRecursive = 1;\n  }\n  return rc;\n}\n\n/* Reset a JsonEachCursor back to its original state.  Free any memory\n** held. */\nstatic void jsonEachCursorReset(JsonEachCursor *p){\n  sqlite3_free(p->zJson);\n  sqlite3_free(p->zRoot);\n  jsonParseReset(&p->sParse);\n  p->iRowid = 0;\n  p->i = 0;\n  p->iEnd = 0;\n  p->eType = 0;\n  p->zJson = 0;\n  p->zRoot = 0;\n}\n\n/* Destructor for a jsonEachCursor object */\nstatic int jsonEachClose(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  jsonEachCursorReset(p);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/* Return TRUE if the jsonEachCursor object has been advanced off the end\n** of the JSON object */\nstatic int jsonEachEof(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  return p->i >= p->iEnd;\n}\n\n/* Advance the cursor to the next element for json_tree() */\nstatic int jsonEachNext(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  if( p->bRecursive ){\n    if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++;\n    p->i++;\n    p->iRowid++;\n    if( p->i<p->iEnd ){\n      u32 iUp = p->sParse.aUp[p->i];\n      JsonNode *pUp = &p->sParse.aNode[iUp];\n      p->eType = pUp->eType;\n      if( pUp->eType==JSON_ARRAY ){\n        if( iUp==p->i-1 ){\n          pUp->u.iKey = 0;\n        }else{\n          pUp->u.iKey++;\n        }\n      }\n    }\n  }else{\n    switch( p->eType ){\n      case JSON_ARRAY: {\n        p->i += jsonNodeSize(&p->sParse.aNode[p->i]);\n        p->iRowid++;\n        break;\n      }\n      case JSON_OBJECT: {\n        p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]);\n        p->iRowid++;\n        break;\n      }\n      default: {\n        p->i = p->iEnd;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Append the name of the path for element i to pStr\n*/\nstatic void jsonEachComputePath(\n  JsonEachCursor *p,       /* The cursor */\n  JsonString *pStr,        /* Write the path here */\n  u32 i                    /* Path to this element */\n){\n  JsonNode *pNode, *pUp;\n  u32 iUp;\n  if( i==0 ){\n    jsonAppendChar(pStr, '$');\n    return;\n  }\n  iUp = p->sParse.aUp[i];\n  jsonEachComputePath(p, pStr, iUp);\n  pNode = &p->sParse.aNode[i];\n  pUp = &p->sParse.aNode[iUp];\n  if( pUp->eType==JSON_ARRAY ){\n    jsonPrintf(30, pStr, \"[%d]\", pUp->u.iKey);\n  }else{\n    assert( pUp->eType==JSON_OBJECT );\n    if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--;\n    assert( pNode->eType==JSON_STRING );\n    assert( pNode->jnFlags & JNODE_LABEL );\n    jsonPrintf(pNode->n+1, pStr, \".%.*s\", pNode->n-2, pNode->u.zJContent+1);\n  }\n}\n\n/* Return the value of a column */\nstatic int jsonEachColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  JsonNode *pThis = &p->sParse.aNode[p->i];\n  switch( i ){\n    case JEACH_KEY: {\n      if( p->i==0 ) break;\n      if( p->eType==JSON_OBJECT ){\n        jsonReturn(pThis, ctx, 0);\n      }else if( p->eType==JSON_ARRAY ){\n        u32 iKey;\n        if( p->bRecursive ){\n          if( p->iRowid==0 ) break;\n          iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey;\n        }else{\n          iKey = p->iRowid;\n        }\n        sqlite3_result_int64(ctx, (sqlite3_int64)iKey);\n      }\n      break;\n    }\n    case JEACH_VALUE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_TYPE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_ATOM: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      if( pThis->eType>=JSON_ARRAY ) break;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_ID: {\n      sqlite3_result_int64(ctx, \n         (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0));\n      break;\n    }\n    case JEACH_PARENT: {\n      if( p->i>p->iBegin && p->bRecursive ){\n        sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]);\n      }\n      break;\n    }\n    case JEACH_FULLKEY: {\n      JsonString x;\n      jsonInit(&x, ctx);\n      if( p->bRecursive ){\n        jsonEachComputePath(p, &x, p->i);\n      }else{\n        if( p->zRoot ){\n          jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));\n        }else{\n          jsonAppendChar(&x, '$');\n        }\n        if( p->eType==JSON_ARRAY ){\n          jsonPrintf(30, &x, \"[%d]\", p->iRowid);\n        }else{\n          jsonPrintf(pThis->n, &x, \".%.*s\", pThis->n-2, pThis->u.zJContent+1);\n        }\n      }\n      jsonResult(&x);\n      break;\n    }\n    case JEACH_PATH: {\n      if( p->bRecursive ){\n        JsonString x;\n        jsonInit(&x, ctx);\n        jsonEachComputePath(p, &x, p->sParse.aUp[p->i]);\n        jsonResult(&x);\n        break;\n      }\n      /* For json_each() path and root are the same so fall through\n      ** into the root case */\n    }\n    default: {\n      const char *zRoot = p->zRoot;\n      if( zRoot==0 ) zRoot = \"$\";\n      sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_JSON: {\n      assert( i==JEACH_JSON );\n      sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Return the current rowid value */\nstatic int jsonEachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  *pRowid = p->iRowid;\n  return SQLITE_OK;\n}\n\n/* The query strategy is to look for an equality constraint on the json\n** column.  Without such a constraint, the table cannot operate.  idxNum is\n** 1 if the constraint is found, 3 if the constraint and zRoot are found,\n** and 0 otherwise.\n*/\nstatic int jsonEachBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;\n  int jsonIdx = -1;\n  int rootIdx = -1;\n  const struct sqlite3_index_constraint *pConstraint;\n\n  UNUSED_PARAM(tab);\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case JEACH_JSON:   jsonIdx = i;    break;\n      case JEACH_ROOT:   rootIdx = i;    break;\n      default:           /* no-op */     break;\n    }\n  }\n  if( jsonIdx<0 ){\n    pIdxInfo->idxNum = 0;\n    pIdxInfo->estimatedCost = 1e99;\n  }else{\n    pIdxInfo->estimatedCost = 1.0;\n    pIdxInfo->aConstraintUsage[jsonIdx].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[jsonIdx].omit = 1;\n    if( rootIdx<0 ){\n      pIdxInfo->idxNum = 1;\n    }else{\n      pIdxInfo->aConstraintUsage[rootIdx].argvIndex = 2;\n      pIdxInfo->aConstraintUsage[rootIdx].omit = 1;\n      pIdxInfo->idxNum = 3;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Start a search on a new JSON string */\nstatic int jsonEachFilter(\n  sqlite3_vtab_cursor *cur,\n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  const char *z;\n  const char *zRoot = 0;\n  sqlite3_int64 n;\n\n  UNUSED_PARAM(idxStr);\n  UNUSED_PARAM(argc);\n  jsonEachCursorReset(p);\n  if( idxNum==0 ) return SQLITE_OK;\n  z = (const char*)sqlite3_value_text(argv[0]);\n  if( z==0 ) return SQLITE_OK;\n  n = sqlite3_value_bytes(argv[0]);\n  p->zJson = sqlite3_malloc64( n+1 );\n  if( p->zJson==0 ) return SQLITE_NOMEM;\n  memcpy(p->zJson, z, (size_t)n+1);\n  if( jsonParse(&p->sParse, 0, p->zJson) ){\n    int rc = SQLITE_NOMEM;\n    if( p->sParse.oom==0 ){\n      sqlite3_free(cur->pVtab->zErrMsg);\n      cur->pVtab->zErrMsg = sqlite3_mprintf(\"malformed JSON\");\n      if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR;\n    }\n    jsonEachCursorReset(p);\n    return rc;\n  }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){\n    jsonEachCursorReset(p);\n    return SQLITE_NOMEM;\n  }else{\n    JsonNode *pNode = 0;\n    if( idxNum==3 ){\n      const char *zErr = 0;\n      zRoot = (const char*)sqlite3_value_text(argv[1]);\n      if( zRoot==0 ) return SQLITE_OK;\n      n = sqlite3_value_bytes(argv[1]);\n      p->zRoot = sqlite3_malloc64( n+1 );\n      if( p->zRoot==0 ) return SQLITE_NOMEM;\n      memcpy(p->zRoot, zRoot, (size_t)n+1);\n      if( zRoot[0]!='$' ){\n        zErr = zRoot;\n      }else{\n        pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr);\n      }\n      if( zErr ){\n        sqlite3_free(cur->pVtab->zErrMsg);\n        cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr);\n        jsonEachCursorReset(p);\n        return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;\n      }else if( pNode==0 ){\n        return SQLITE_OK;\n      }\n    }else{\n      pNode = p->sParse.aNode;\n    }\n    p->iBegin = p->i = (int)(pNode - p->sParse.aNode);\n    p->eType = pNode->eType;\n    if( p->eType>=JSON_ARRAY ){\n      pNode->u.iKey = 0;\n      p->iEnd = p->i + pNode->n + 1;\n      if( p->bRecursive ){\n        p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType;\n        if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){\n          p->i--;\n        }\n      }else{\n        p->i++;\n      }\n    }else{\n      p->iEnd = p->i+1;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* The methods of the json_each virtual table */\nstatic sqlite3_module jsonEachModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenEach,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n\n/* The methods of the json_tree virtual table. */\nstatic sqlite3_module jsonTreeModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenTree,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/****************************************************************************\n** The following routines are the only publically visible identifiers in this\n** file.  Call the following routines in order to register the various SQL\n** functions and the virtual table implemented by this file.\n****************************************************************************/\n\nint sqlite3Json1Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  unsigned int i;\n  static const struct {\n     const char *zName;\n     int nArg;\n     int flag;\n     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"json\",                 1, 0,   jsonRemoveFunc        },\n    { \"json_array\",          -1, 0,   jsonArrayFunc         },\n    { \"json_array_length\",    1, 0,   jsonArrayLengthFunc   },\n    { \"json_array_length\",    2, 0,   jsonArrayLengthFunc   },\n    { \"json_extract\",        -1, 0,   jsonExtractFunc       },\n    { \"json_insert\",         -1, 0,   jsonSetFunc           },\n    { \"json_object\",         -1, 0,   jsonObjectFunc        },\n    { \"json_patch\",           2, 0,   jsonPatchFunc         },\n    { \"json_quote\",           1, 0,   jsonQuoteFunc         },\n    { \"json_remove\",         -1, 0,   jsonRemoveFunc        },\n    { \"json_replace\",        -1, 0,   jsonReplaceFunc       },\n    { \"json_set\",            -1, 1,   jsonSetFunc           },\n    { \"json_type\",            1, 0,   jsonTypeFunc          },\n    { \"json_type\",            2, 0,   jsonTypeFunc          },\n    { \"json_valid\",           1, 0,   jsonValidFunc         },\n\n#if SQLITE_DEBUG\n    /* DEBUG and TESTING functions */\n    { \"json_parse\",           1, 0,   jsonParseFunc         },\n    { \"json_test1\",           1, 0,   jsonTest1Func         },\n#endif\n  };\n  static const struct {\n     const char *zName;\n     int nArg;\n     void (*xStep)(sqlite3_context*,int,sqlite3_value**);\n     void (*xFinal)(sqlite3_context*);\n  } aAgg[] = {\n    { \"json_group_array\",     1,   jsonArrayStep,   jsonArrayFinal  },\n    { \"json_group_object\",    2,   jsonObjectStep,  jsonObjectFinal },\n  };\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static const struct {\n     const char *zName;\n     sqlite3_module *pModule;\n  } aMod[] = {\n    { \"json_each\",            &jsonEachModule               },\n    { \"json_tree\",            &jsonTreeModule               },\n  };\n#endif\n  for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, \n                                 (void*)&aFunc[i].flag,\n                                 aFunc[i].xFunc, 0, 0);\n  }\n  for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,\n                                 0, aAgg[i].xStep, aAgg[i].xFinal);\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);\n  }\n#endif\n  return rc;\n}\n\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_json_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return sqlite3Json1Init(db);\n}\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/memvfs.c",
    "content": "/*\n** 2016-09-07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an in-memory read-only VFS implementation.  The application\n** supplies a block of memory which is the database file, and this VFS\n** uses that block of memory.\n**\n** Because there is no place to store journals and no good way to lock\n** the \"file\", this VFS is read-only.\n**\n** USAGE:\n**\n**    sqlite3_open_v2(\"file:/whatever?ptr=0xf05538&sz=14336\", &db,\n**                    SQLITE_OPEN_READONLY | SQLITE_OPEN_URI,\n**                    \"memvfs\");\n**\n** The ptr= and sz= query parameters are required or the open will fail.\n** The ptr= parameter gives the memory address of the buffer holding the\n** read-only database and sz= gives the size of the database.  The parameter\n** values may be in hexadecimal or decimal.  The filename is ignored.\n*/\n#include <sqlite3ext.h>\nSQLITE_EXTENSION_INIT1\n#include <string.h>\n#include <assert.h>\n\n\n/*\n** Forward declaration of objects used by this utility\n*/\ntypedef struct sqlite3_vfs MemVfs;\ntypedef struct MemFile MemFile;\n\n/* Access to a lower-level VFS that (might) implement dynamic loading,\n** access to randomness, etc.\n*/\n#define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData))\n\n/* An open file */\nstruct MemFile {\n  sqlite3_file base;              /* IO methods */\n  sqlite3_int64 sz;               /* Size of the file */\n  unsigned char *aData;           /* content of the file */\n};\n\n/*\n** Methods for MemFile\n*/\nstatic int memClose(sqlite3_file*);\nstatic int memRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int memWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int memTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int memSync(sqlite3_file*, int flags);\nstatic int memFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int memLock(sqlite3_file*, int);\nstatic int memUnlock(sqlite3_file*, int);\nstatic int memCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int memFileControl(sqlite3_file*, int op, void *pArg);\nstatic int memSectorSize(sqlite3_file*);\nstatic int memDeviceCharacteristics(sqlite3_file*);\nstatic int memShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\nstatic int memShmLock(sqlite3_file*, int offset, int n, int flags);\nstatic void memShmBarrier(sqlite3_file*);\nstatic int memShmUnmap(sqlite3_file*, int deleteFlag);\nstatic int memFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\nstatic int memUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n\n/*\n** Methods for MemVfs\n*/\nstatic int memOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int memDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int memAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int memFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *memDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void memDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*memDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void);\nstatic void memDlClose(sqlite3_vfs*, void*);\nstatic int memRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int memSleep(sqlite3_vfs*, int microseconds);\nstatic int memCurrentTime(sqlite3_vfs*, double*);\nstatic int memGetLastError(sqlite3_vfs*, int, char *);\nstatic int memCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\n\nstatic sqlite3_vfs mem_vfs = {\n  2,                           /* iVersion */\n  0,                           /* szOsFile (set when registered) */\n  1024,                        /* mxPathname */\n  0,                           /* pNext */\n  \"memvfs\",                    /* zName */\n  0,                           /* pAppData (set when registered) */ \n  memOpen,                     /* xOpen */\n  memDelete,                   /* xDelete */\n  memAccess,                   /* xAccess */\n  memFullPathname,             /* xFullPathname */\n  memDlOpen,                   /* xDlOpen */\n  memDlError,                  /* xDlError */\n  memDlSym,                    /* xDlSym */\n  memDlClose,                  /* xDlClose */\n  memRandomness,               /* xRandomness */\n  memSleep,                    /* xSleep */\n  memCurrentTime,              /* xCurrentTime */\n  memGetLastError,             /* xGetLastError */\n  memCurrentTimeInt64          /* xCurrentTimeInt64 */\n};\n\nstatic const sqlite3_io_methods mem_io_methods = {\n  3,                              /* iVersion */\n  memClose,                      /* xClose */\n  memRead,                       /* xRead */\n  memWrite,                      /* xWrite */\n  memTruncate,                   /* xTruncate */\n  memSync,                       /* xSync */\n  memFileSize,                   /* xFileSize */\n  memLock,                       /* xLock */\n  memUnlock,                     /* xUnlock */\n  memCheckReservedLock,          /* xCheckReservedLock */\n  memFileControl,                /* xFileControl */\n  memSectorSize,                 /* xSectorSize */\n  memDeviceCharacteristics,      /* xDeviceCharacteristics */\n  memShmMap,                     /* xShmMap */\n  memShmLock,                    /* xShmLock */\n  memShmBarrier,                 /* xShmBarrier */\n  memShmUnmap,                   /* xShmUnmap */\n  memFetch,                      /* xFetch */\n  memUnfetch                     /* xUnfetch */\n};\n\n\n\n/*\n** Close an mem-file.\n**\n** The pData pointer is owned by the application, so there is nothing\n** to free.\n*/\nstatic int memClose(sqlite3_file *pFile){\n  return SQLITE_OK;\n}\n\n/*\n** Read data from an mem-file.\n*/\nstatic int memRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  MemFile *p = (MemFile *)pFile;\n  memcpy(zBuf, p->aData+iOfst, iAmt);\n  return SQLITE_OK;\n}\n\n/*\n** Write data to an mem-file.\n*/\nstatic int memWrite(\n  sqlite3_file *pFile,\n  const void *z,\n  int iAmt,\n  sqlite_int64 iOfst\n){\n  return SQLITE_READONLY;\n}\n\n/*\n** Truncate an mem-file.\n*/\nstatic int memTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  return SQLITE_READONLY;\n}\n\n/*\n** Sync an mem-file.\n*/\nstatic int memSync(sqlite3_file *pFile, int flags){\n  return SQLITE_READONLY;\n}\n\n/*\n** Return the current file-size of an mem-file.\n*/\nstatic int memFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  MemFile *p = (MemFile *)pFile;\n  *pSize = p->sz;\n  return SQLITE_OK;\n}\n\n/*\n** Lock an mem-file.\n*/\nstatic int memLock(sqlite3_file *pFile, int eLock){\n  return SQLITE_READONLY;\n}\n\n/*\n** Unlock an mem-file.\n*/\nstatic int memUnlock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an mem-file.\n*/\nstatic int memCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n\n/*\n** File control method. For custom operations on an mem-file.\n*/\nstatic int memFileControl(sqlite3_file *pFile, int op, void *pArg){\n  MemFile *p = (MemFile *)pFile;\n  int rc = SQLITE_NOTFOUND;\n  if( op==SQLITE_FCNTL_VFSNAME ){\n    *(char**)pArg = sqlite3_mprintf(\"mem(%p,%lld)\", p->aData, p->sz);\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an mem-file.\n*/\nstatic int memSectorSize(sqlite3_file *pFile){\n  return 1024;\n}\n\n/*\n** Return the device characteristic flags supported by an mem-file.\n*/\nstatic int memDeviceCharacteristics(sqlite3_file *pFile){\n  return SQLITE_IOCAP_IMMUTABLE;\n}\n\n/* Create a shared memory file mapping */\nstatic int memShmMap(\n  sqlite3_file *pFile,\n  int iPg,\n  int pgsz,\n  int bExtend,\n  void volatile **pp\n){\n  return SQLITE_READONLY;\n}\n\n/* Perform locking on a shared-memory segment */\nstatic int memShmLock(sqlite3_file *pFile, int offset, int n, int flags){\n  return SQLITE_READONLY;\n}\n\n/* Memory barrier operation on shared memory */\nstatic void memShmBarrier(sqlite3_file *pFile){\n  return;\n}\n\n/* Unmap a shared memory segment */\nstatic int memShmUnmap(sqlite3_file *pFile, int deleteFlag){\n  return SQLITE_OK;\n}\n\n/* Fetch a page of a memory-mapped file */\nstatic int memFetch(\n  sqlite3_file *pFile,\n  sqlite3_int64 iOfst,\n  int iAmt,\n  void **pp\n){\n  MemFile *p = (MemFile *)pFile;\n  *pp = (void*)(p->aData + iOfst);\n  return SQLITE_OK;\n}\n\n/* Release a memory-mapped page */\nstatic int memUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){\n  return SQLITE_OK;\n}\n\n/*\n** Open an mem file handle.\n*/\nstatic int memOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  MemFile *p = (MemFile*)pFile;\n  memset(p, 0, sizeof(*p));\n  if( (flags & SQLITE_OPEN_MAIN_DB)==0 ) return SQLITE_CANTOPEN;\n  p->aData = (unsigned char*)sqlite3_uri_int64(zName,\"ptr\",0);\n  if( p->aData==0 ) return SQLITE_CANTOPEN;\n  p->sz = sqlite3_uri_int64(zName,\"sz\",0);\n  if( p->sz<0 ) return SQLITE_CANTOPEN;\n  pFile->pMethods = &mem_io_methods;\n  return SQLITE_OK;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int memDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  return SQLITE_READONLY;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int memAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  /* The spec says there are three possible values for flags.  But only\n  ** two of them are actually used */\n  assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );\n  if( flags==SQLITE_ACCESS_READWRITE ){\n    *pResOut = 0;\n  }else{\n    *pResOut = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int memFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  sqlite3_snprintf(nOut, zOut, \"%s\", zPath);\n  return SQLITE_OK;\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *memDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return ORIGVFS(pVfs)->xDlOpen(ORIGVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void memDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  ORIGVFS(pVfs)->xDlError(ORIGVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*memDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return ORIGVFS(pVfs)->xDlSym(ORIGVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void memDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  ORIGVFS(pVfs)->xDlClose(ORIGVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int memRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return ORIGVFS(pVfs)->xRandomness(ORIGVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int memSleep(sqlite3_vfs *pVfs, int nMicro){\n  return ORIGVFS(pVfs)->xSleep(ORIGVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int memCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return ORIGVFS(pVfs)->xCurrentTime(ORIGVFS(pVfs), pTimeOut);\n}\n\nstatic int memGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return ORIGVFS(pVfs)->xGetLastError(ORIGVFS(pVfs), a, b);\n}\nstatic int memCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){\n  return ORIGVFS(pVfs)->xCurrentTimeInt64(ORIGVFS(pVfs), p);\n}\n\n#ifdef MEMVFS_TEST\n/*\n**       memload(FILENAME)\n**\n** This an SQL function used to help in testing the memvfs VFS.  The\n** function reads the content of a file into memory and then returns\n** a string that gives the locate and size of the in-memory buffer.\n*/\n#include <stdio.h>\nstatic void memvfsMemloadFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  unsigned char *p;\n  sqlite3_int64 sz;\n  FILE *in;\n  const char *zFilename = (const char*)sqlite3_value_text(argv[0]);\n  char zReturn[100];\n\n  if( zFilename==0 ) return;\n  in = fopen(zFilename, \"rb\");\n  if( in==0 ) return;\n  fseek(in, 0, SEEK_END);\n  sz = ftell(in);\n  rewind(in);\n  p = sqlite3_malloc( sz );\n  if( p==0 ){\n    fclose(in);\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  fread(p, sz, 1, in);\n  fclose(in);\n  sqlite3_snprintf(sizeof(zReturn),zReturn,\"ptr=%lld&sz=%lld\",\n                   (sqlite3_int64)p, sz);\n  sqlite3_result_text(context, zReturn, -1, SQLITE_TRANSIENT);\n}\n/* Called for each new database connection */\nstatic int memvfsRegister(\n  sqlite3 *db,\n  const char **pzErrMsg,\n  const struct sqlite3_api_routines *pThunk\n){\n  return sqlite3_create_function(db, \"memload\", 1, SQLITE_UTF8, 0,\n                                 memvfsMemloadFunc, 0, 0);\n}\n#endif /* MEMVFS_TEST */\n\n  \n#ifdef _WIN32\n__declspec(dllexport)\n#endif\n/* \n** This routine is called when the extension is loaded.\n** Register the new VFS.\n*/\nint sqlite3_memvfs_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  mem_vfs.pAppData = sqlite3_vfs_find(0);\n  mem_vfs.szOsFile = sizeof(MemFile);\n  rc = sqlite3_vfs_register(&mem_vfs, 1);\n#ifdef MEMVFS_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_auto_extension((void(*)(void))memvfsRegister);\n  }\n#endif\n  if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY;\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/mmapwarm.c",
    "content": "/*\n** 2017-09-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n*/\n\n#include \"sqlite3.h\"\n\n\n/*\n** This function is used to touch each page of a mapping of a memory\n** mapped SQLite database. Assuming that the system has sufficient free\n** memory and supports sufficiently large mappings, this causes the OS \n** to cache the entire database in main memory, making subsequent \n** database accesses faster.\n**\n** If the second parameter to this function is not NULL, it is the name of\n** the specific database to operate on (i.e. \"main\" or the name of an\n** attached database).\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n** It is not considered an error if the file is not memory-mapped, or if\n** the mapping does not span the entire file. If an error does occur, a\n** transaction may be left open on the database file.\n**\n** It is illegal to call this function when the database handle has an \n** open transaction. SQLITE_MISUSE is returned in this case.\n*/\nint sqlite3_mmap_warm(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_OK;\n  char *zSql = 0;\n  int pgsz = 0;\n  int nTotal = 0;\n\n  if( 0==sqlite3_get_autocommit(db) ) return SQLITE_MISUSE;\n\n  /* Open a read-only transaction on the file in question */\n  zSql = sqlite3_mprintf(\"BEGIN; SELECT * FROM %s%q%ssqlite_master\", \n      (zDb ? \"'\" : \"\"), (zDb ? zDb : \"\"), (zDb ? \"'.\" : \"\")\n  );\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_exec(db, zSql, 0, 0, 0);\n  sqlite3_free(zSql);\n\n  /* Find the SQLite page size of the file */\n  if( rc==SQLITE_OK ){\n    zSql = sqlite3_mprintf(\"PRAGMA %s%q%spage_size\", \n        (zDb ? \"'\" : \"\"), (zDb ? zDb : \"\"), (zDb ? \"'.\" : \"\")\n    );\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_stmt *pPgsz = 0;\n      rc = sqlite3_prepare_v2(db, zSql, -1, &pPgsz, 0);\n      sqlite3_free(zSql);\n      if( rc==SQLITE_OK ){\n        if( sqlite3_step(pPgsz)==SQLITE_ROW ){\n          pgsz = sqlite3_column_int(pPgsz, 0);\n        }\n        rc = sqlite3_finalize(pPgsz);\n      }\n      if( rc==SQLITE_OK && pgsz==0 ){\n        rc = SQLITE_ERROR;\n      }\n    }\n  }\n\n  /* Touch each mmap'd page of the file */\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_file *pFd = 0;\n    rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_FILE_POINTER, &pFd);\n    if( rc==SQLITE_OK && pFd->pMethods->iVersion>=3 ){\n      sqlite3_int64 iPg = 1;\n      sqlite3_io_methods const *p = pFd->pMethods;\n      while( 1 ){\n        unsigned char *pMap;\n        rc = p->xFetch(pFd, pgsz*iPg, pgsz, (void**)&pMap);\n        if( rc!=SQLITE_OK || pMap==0 ) break;\n\n        nTotal += pMap[0];\n        nTotal += pMap[pgsz-1];\n\n        rc = p->xUnfetch(pFd, pgsz*iPg, (void*)pMap);\n        if( rc!=SQLITE_OK ) break;\n        iPg++;\n      }\n      sqlite3_log(SQLITE_OK, \n          \"sqlite3_mmap_warm_cache: Warmed up %d pages of %s\", iPg==1?0:iPg,\n          sqlite3_db_filename(db, zDb)\n      );\n    }\n\n    rc2 = sqlite3_exec(db, \"END\", 0, 0, 0);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/nextchar.c",
    "content": "/*\n** 2013-02-28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code to implement the next_char(A,T,F,W,C) SQL function.\n**\n** The next_char(A,T,F,W,C) function finds all valid \"next\" characters for\n** string A given the vocabulary in T.F.  If the W value exists and is a\n** non-empty string, then it is an SQL expression that limits the entries\n** in T.F that will be considered.  If C exists and is a non-empty string,\n** then it is the name of the collating sequence to use for comparison.  If\n** \n** Only the first three arguments are required.  If the C parameter is \n** omitted or is NULL or is an empty string, then the default collating \n** sequence of T.F is used for comparision.  If the W parameter is omitted\n** or is NULL or is an empty string, then no filtering of the output is\n** done.\n**\n** The T.F column should be indexed using collation C or else this routine\n** will be quite slow.\n**\n** For example, suppose an application has a dictionary like this:\n**\n**   CREATE TABLE dictionary(word TEXT UNIQUE);\n**\n** Further suppose that for user keypad entry, it is desired to disable\n** (gray out) keys that are not valid as the next character.  If the\n** the user has previously entered (say) 'cha' then to find all allowed\n** next characters (and thereby determine when keys should not be grayed\n** out) run the following query:\n**\n**   SELECT next_char('cha','dictionary','word');\n**\n** IMPLEMENTATION NOTES:\n**\n** The next_char function is implemented using recursive SQL that makes\n** use of the table name and column name as part of a query.  If either\n** the table name or column name are keywords or contain special characters,\n** then they should be escaped.  For example:\n**\n**   SELECT next_char('cha','[dictionary]','[word]');\n**\n** This also means that the table name can be a subquery:\n**\n**   SELECT next_char('cha','(SELECT word AS w FROM dictionary)','w');\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <string.h>\n\n/*\n** A structure to hold context of the next_char() computation across\n** nested function calls.\n*/\ntypedef struct nextCharContext nextCharContext;\nstruct nextCharContext {\n  sqlite3 *db;                      /* Database connection */\n  sqlite3_stmt *pStmt;              /* Prepared statement used to query */\n  const unsigned char *zPrefix;     /* Prefix to scan */\n  int nPrefix;                      /* Size of zPrefix in bytes */\n  int nAlloc;                       /* Space allocated to aResult */\n  int nUsed;                        /* Space used in aResult */\n  unsigned int *aResult;            /* Array of next characters */\n  int mallocFailed;                 /* True if malloc fails */\n  int otherError;                   /* True for any other failure */\n};\n\n/*\n** Append a result character if the character is not already in the\n** result.\n*/\nstatic void nextCharAppend(nextCharContext *p, unsigned c){\n  int i;\n  for(i=0; i<p->nUsed; i++){\n    if( p->aResult[i]==c ) return;\n  }\n  if( p->nUsed+1 > p->nAlloc ){\n    unsigned int *aNew;\n    int n = p->nAlloc*2 + 30;\n    aNew = sqlite3_realloc(p->aResult, n*sizeof(unsigned int));\n    if( aNew==0 ){\n      p->mallocFailed = 1;\n      return;\n    }else{\n      p->aResult = aNew;\n      p->nAlloc = n;\n    }\n  }\n  p->aResult[p->nUsed++] = c;\n}\n\n/*\n** Write a character into z[] as UTF8.  Return the number of bytes needed\n** to hold the character\n*/\nstatic int writeUtf8(unsigned char *z, unsigned c){\n  if( c<0x00080 ){\n    z[0] = (unsigned char)(c&0xff);\n    return 1;\n  }\n  if( c<0x00800 ){\n    z[0] = 0xC0 + (unsigned char)((c>>6)&0x1F);\n    z[1] = 0x80 + (unsigned char)(c & 0x3F);\n    return 2;\n  }\n  if( c<0x10000 ){\n    z[0] = 0xE0 + (unsigned char)((c>>12)&0x0F);\n    z[1] = 0x80 + (unsigned char)((c>>6) & 0x3F);\n    z[2] = 0x80 + (unsigned char)(c & 0x3F);\n    return 3;\n  }\n  z[0] = 0xF0 + (unsigned char)((c>>18) & 0x07);\n  z[1] = 0x80 + (unsigned char)((c>>12) & 0x3F);\n  z[2] = 0x80 + (unsigned char)((c>>6) & 0x3F);\n  z[3] = 0x80 + (unsigned char)(c & 0x3F);\n  return 4;\n}\n\n/*\n** Read a UTF8 character out of z[] and write it into *pOut.  Return\n** the number of bytes in z[] that were used to construct the character.\n*/\nstatic int readUtf8(const unsigned char *z, unsigned *pOut){\n  static const unsigned char validBits[] = {\n    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n    0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n  };\n  unsigned c = z[0];\n  if( c<0xc0 ){\n    *pOut = c;\n    return 1;\n  }else{\n    int n = 1;\n    c = validBits[c-0xc0];\n    while( (z[n] & 0xc0)==0x80 ){\n      c = (c<<6) + (0x3f & z[n++]);\n    }\n    if( c<0x80 || (c&0xFFFFF800)==0xD800 || (c&0xFFFFFFFE)==0xFFFE ){\n      c = 0xFFFD;\n    }\n    *pOut = c;\n    return n;\n  }\n}\n\n/*\n** The nextCharContext structure has been set up.  Add all \"next\" characters\n** to the result set.\n*/\nstatic void findNextChars(nextCharContext *p){\n  unsigned cPrev = 0;\n  unsigned char zPrev[8];\n  int n, rc;\n  \n  for(;;){\n    sqlite3_bind_text(p->pStmt, 1, (char*)p->zPrefix, p->nPrefix,\n                      SQLITE_STATIC);\n    n = writeUtf8(zPrev, cPrev+1);\n    sqlite3_bind_text(p->pStmt, 2, (char*)zPrev, n, SQLITE_STATIC);\n    rc = sqlite3_step(p->pStmt);\n    if( rc==SQLITE_DONE ){\n      sqlite3_reset(p->pStmt);\n      return;\n    }else if( rc!=SQLITE_ROW ){\n      p->otherError = rc;\n      return;\n    }else{\n      const unsigned char *zOut = sqlite3_column_text(p->pStmt, 0);\n      unsigned cNext;\n      n = readUtf8(zOut+p->nPrefix, &cNext);\n      sqlite3_reset(p->pStmt);\n      nextCharAppend(p, cNext);\n      cPrev = cNext;\n      if( p->mallocFailed ) return;\n    }\n  }\n}\n\n\n/*\n** next_character(A,T,F,W)\n**\n** Return a string composted of all next possible characters after\n** A for elements of T.F.  If W is supplied, then it is an SQL expression\n** that limits the elements in T.F that are considered.\n*/\nstatic void nextCharFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  nextCharContext c;\n  const unsigned char *zTable = sqlite3_value_text(argv[1]);\n  const unsigned char *zField = sqlite3_value_text(argv[2]);\n  const unsigned char *zWhere;\n  const unsigned char *zCollName;\n  char *zWhereClause = 0;\n  char *zColl = 0;\n  char *zSql;\n  int rc;\n\n  memset(&c, 0, sizeof(c));\n  c.db = sqlite3_context_db_handle(context);\n  c.zPrefix = sqlite3_value_text(argv[0]);\n  c.nPrefix = sqlite3_value_bytes(argv[0]);\n  if( zTable==0 || zField==0 || c.zPrefix==0 ) return;\n  if( argc>=4\n   && (zWhere = sqlite3_value_text(argv[3]))!=0\n   && zWhere[0]!=0\n  ){\n    zWhereClause = sqlite3_mprintf(\"AND (%s)\", zWhere);\n    if( zWhereClause==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }else{\n    zWhereClause = \"\";\n  }\n  if( argc>=5\n   && (zCollName = sqlite3_value_text(argv[4]))!=0\n   && zCollName[0]!=0 \n  ){\n    zColl = sqlite3_mprintf(\"collate \\\"%w\\\"\", zCollName);\n    if( zColl==0 ){\n      sqlite3_result_error_nomem(context);\n      if( zWhereClause[0] ) sqlite3_free(zWhereClause);\n      return;\n    }\n  }else{\n    zColl = \"\";\n  }\n  zSql = sqlite3_mprintf(\n    \"SELECT %s FROM %s\"\n    \" WHERE %s>=(?1 || ?2) %s\"\n    \"   AND %s<=(?1 || char(1114111)) %s\" /* 1114111 == 0x10ffff */\n    \"   %s\"\n    \" ORDER BY 1 %s ASC LIMIT 1\",\n    zField, zTable, zField, zColl, zField, zColl, zWhereClause, zColl\n  );\n  if( zWhereClause[0] ) sqlite3_free(zWhereClause);\n  if( zColl[0] ) sqlite3_free(zColl);\n  if( zSql==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n\n  rc = sqlite3_prepare_v2(c.db, zSql, -1, &c.pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ){\n    sqlite3_result_error(context, sqlite3_errmsg(c.db), -1);\n    return;\n  }\n  findNextChars(&c);\n  if( c.mallocFailed ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    unsigned char *pRes;\n    pRes = sqlite3_malloc( c.nUsed*4 + 1 );\n    if( pRes==0 ){\n      sqlite3_result_error_nomem(context);\n    }else{\n      int i;\n      int n = 0;\n      for(i=0; i<c.nUsed; i++){\n        n += writeUtf8(pRes+n, c.aResult[i]);\n      }\n      pRes[n] = 0;\n      sqlite3_result_text(context, (const char*)pRes, n, sqlite3_free);\n    }\n  }\n  sqlite3_finalize(c.pStmt);\n  sqlite3_free(c.aResult);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_nextchar_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"next_char\", 3, SQLITE_UTF8, 0,\n                               nextCharFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"next_char\", 4, SQLITE_UTF8, 0,\n                                 nextCharFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"next_char\", 5, SQLITE_UTF8, 0,\n                                 nextCharFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/percentile.c",
    "content": "/*\n** 2013-05-28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code to implement the percentile(Y,P) SQL function\n** as described below:\n**\n**   (1)  The percentile(Y,P) function is an aggregate function taking\n**        exactly two arguments.\n**\n**   (2)  If the P argument to percentile(Y,P) is not the same for every\n**        row in the aggregate then an error is thrown.  The word \"same\"\n**        in the previous sentence means that the value differ by less\n**        than 0.001.\n**\n**   (3)  If the P argument to percentile(Y,P) evaluates to anything other\n**        than a number in the range of 0.0 to 100.0 inclusive then an\n**        error is thrown.\n**\n**   (4)  If any Y argument to percentile(Y,P) evaluates to a value that\n**        is not NULL and is not numeric then an error is thrown.\n**\n**   (5)  If any Y argument to percentile(Y,P) evaluates to plus or minus\n**        infinity then an error is thrown.  (SQLite always interprets NaN\n**        values as NULL.)\n**\n**   (6)  Both Y and P in percentile(Y,P) can be arbitrary expressions,\n**        including CASE WHEN expressions.\n**\n**   (7)  The percentile(Y,P) aggregate is able to handle inputs of at least\n**        one million (1,000,000) rows.\n**\n**   (8)  If there are no non-NULL values for Y, then percentile(Y,P)\n**        returns NULL.\n**\n**   (9)  If there is exactly one non-NULL value for Y, the percentile(Y,P)\n**        returns the one Y value.\n**\n**  (10)  If there N non-NULL values of Y where N is two or more and\n**        the Y values are ordered from least to greatest and a graph is\n**        drawn from 0 to N-1 such that the height of the graph at J is\n**        the J-th Y value and such that straight lines are drawn between\n**        adjacent Y values, then the percentile(Y,P) function returns\n**        the height of the graph at P*(N-1)/100.\n**\n**  (11)  The percentile(Y,P) function always returns either a floating\n**        point number or NULL.\n**\n**  (12)  The percentile(Y,P) is implemented as a single C99 source-code\n**        file that compiles into a shared-library or DLL that can be loaded\n**        into SQLite using the sqlite3_load_extension() interface.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <stdlib.h>\n\n/* The following object is the session context for a single percentile()\n** function.  We have to remember all input Y values until the very end.\n** Those values are accumulated in the Percentile.a[] array.\n*/\ntypedef struct Percentile Percentile;\nstruct Percentile {\n  unsigned nAlloc;     /* Number of slots allocated for a[] */\n  unsigned nUsed;      /* Number of slots actually used in a[] */\n  double rPct;         /* 1.0 more than the value for P */\n  double *a;           /* Array of Y values */\n};\n\n/*\n** Return TRUE if the input floating-point number is an infinity.\n*/\nstatic int isInfinity(double r){\n  sqlite3_uint64 u;\n  assert( sizeof(u)==sizeof(r) );\n  memcpy(&u, &r, sizeof(u));\n  return ((u>>52)&0x7ff)==0x7ff;\n}\n\n/*\n** Return TRUE if two doubles differ by 0.001 or less\n*/\nstatic int sameValue(double a, double b){\n  a -= b;\n  return a>=-0.001 && a<=0.001;\n}\n\n/*\n** The \"step\" function for percentile(Y,P) is called once for each\n** input row.\n*/\nstatic void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){\n  Percentile *p;\n  double rPct;\n  int eType;\n  double y;\n  assert( argc==2 );\n\n  /* Requirement 3:  P must be a number between 0 and 100 */\n  eType = sqlite3_value_numeric_type(argv[1]);\n  rPct = sqlite3_value_double(argv[1]);\n  if( (eType!=SQLITE_INTEGER && eType!=SQLITE_FLOAT) ||\n      ((rPct = sqlite3_value_double(argv[1]))<0.0 || rPct>100.0) ){\n    sqlite3_result_error(pCtx, \"2nd argument to percentile() is not \"\n                         \"a number between 0.0 and 100.0\", -1);\n    return;\n  }\n\n  /* Allocate the session context. */\n  p = (Percentile*)sqlite3_aggregate_context(pCtx, sizeof(*p));\n  if( p==0 ) return;\n\n  /* Remember the P value.  Throw an error if the P value is different\n  ** from any prior row, per Requirement (2). */\n  if( p->rPct==0.0 ){\n    p->rPct = rPct+1.0;\n  }else if( !sameValue(p->rPct,rPct+1.0) ){\n    sqlite3_result_error(pCtx, \"2nd argument to percentile() is not the \"\n                               \"same for all input rows\", -1);\n    return;\n  }\n\n  /* Ignore rows for which Y is NULL */\n  eType = sqlite3_value_type(argv[0]);\n  if( eType==SQLITE_NULL ) return;\n\n  /* If not NULL, then Y must be numeric.  Otherwise throw an error.\n  ** Requirement 4 */\n  if( eType!=SQLITE_INTEGER && eType!=SQLITE_FLOAT ){\n    sqlite3_result_error(pCtx, \"1st argument to percentile() is not \"\n                               \"numeric\", -1);\n    return;\n  }\n\n  /* Throw an error if the Y value is infinity or NaN */\n  y = sqlite3_value_double(argv[0]);\n  if( isInfinity(y) ){\n    sqlite3_result_error(pCtx, \"Inf input to percentile()\", -1);\n    return;\n  }\n\n  /* Allocate and store the Y */\n  if( p->nUsed>=p->nAlloc ){\n    unsigned n = p->nAlloc*2 + 250;\n    double *a = sqlite3_realloc(p->a, sizeof(double)*n);\n    if( a==0 ){\n      sqlite3_free(p->a);\n      memset(p, 0, sizeof(*p));\n      sqlite3_result_error_nomem(pCtx);\n      return;\n    }\n    p->nAlloc = n;\n    p->a = a;\n  }\n  p->a[p->nUsed++] = y;\n}\n\n/*\n** Compare to doubles for sorting using qsort()\n*/\nstatic int SQLITE_CDECL doubleCmp(const void *pA, const void *pB){\n  double a = *(double*)pA;\n  double b = *(double*)pB;\n  if( a==b ) return 0;\n  if( a<b ) return -1;\n  return +1;\n}\n\n/*\n** Called to compute the final output of percentile() and to clean\n** up all allocated memory.\n*/\nstatic void percentFinal(sqlite3_context *pCtx){\n  Percentile *p;\n  unsigned i1, i2;\n  double v1, v2;\n  double ix, vx;\n  p = (Percentile*)sqlite3_aggregate_context(pCtx, 0);\n  if( p==0 ) return;\n  if( p->a==0 ) return;\n  if( p->nUsed ){\n    qsort(p->a, p->nUsed, sizeof(double), doubleCmp);\n    ix = (p->rPct-1.0)*(p->nUsed-1)*0.01;\n    i1 = (unsigned)ix;\n    i2 = ix==(double)i1 || i1==p->nUsed-1 ? i1 : i1+1;\n    v1 = p->a[i1];\n    v2 = p->a[i2];\n    vx = v1 + (v2-v1)*(ix-i1);\n    sqlite3_result_double(pCtx, vx);\n  }\n  sqlite3_free(p->a);\n  memset(p, 0, sizeof(*p));\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_percentile_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"percentile\", 2, SQLITE_UTF8, 0,\n                               0, percentStep, percentFinal);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/regexp.c",
    "content": "/*\n** 2012-11-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** The code in this file implements a compact but reasonably\n** efficient regular-expression matcher for posix extended regular\n** expressions against UTF8 text.\n**\n** This file is an SQLite extension.  It registers a single function\n** named \"regexp(A,B)\" where A is the regular expression and B is the\n** string to be matched.  By registering this function, SQLite will also\n** then implement the \"B regexp A\" operator.  Note that with the function\n** the regular expression comes first, but with the operator it comes\n** second.\n**\n**  The following regular expression syntax is supported:\n**\n**     X*      zero or more occurrences of X\n**     X+      one or more occurrences of X\n**     X?      zero or one occurrences of X\n**     X{p,q}  between p and q occurrences of X\n**     (X)     match X\n**     X|Y     X or Y\n**     ^X      X occurring at the beginning of the string\n**     X$      X occurring at the end of the string\n**     .       Match any single character\n**     \\c      Character c where c is one of \\{}()[]|*+?.\n**     \\c      C-language escapes for c in afnrtv.  ex: \\t or \\n\n**     \\uXXXX  Where XXXX is exactly 4 hex digits, unicode value XXXX\n**     \\xXX    Where XX is exactly 2 hex digits, unicode value XX\n**     [abc]   Any single character from the set abc\n**     [^abc]  Any single character not in the set abc\n**     [a-z]   Any single character in the range a-z\n**     [^a-z]  Any single character not in the range a-z\n**     \\b      Word boundary\n**     \\w      Word character.  [A-Za-z0-9_]\n**     \\W      Non-word character\n**     \\d      Digit\n**     \\D      Non-digit\n**     \\s      Whitespace character\n**     \\S      Non-whitespace character\n**\n** A nondeterministic finite automaton (NFA) is used for matching, so the\n** performance is bounded by O(N*M) where N is the size of the regular\n** expression and M is the size of the input string.  The matcher never\n** exhibits exponential behavior.  Note that the X{p,q} operator expands\n** to p copies of X following by q-p copies of X? and that the size of the\n** regular expression in the O(N*M) performance bound is computed after\n** this expansion.\n*/\n#include <string.h>\n#include <stdlib.h>\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n/*\n** The following #defines change the names of some functions implemented in\n** this file to prevent name collisions with C-library functions of the\n** same name.\n*/\n#define re_match   sqlite3re_match\n#define re_compile sqlite3re_compile\n#define re_free    sqlite3re_free\n\n/* The end-of-input character */\n#define RE_EOF            0    /* End of input */\n\n/* The NFA is implemented as sequence of opcodes taken from the following\n** set.  Each opcode has a single integer argument.\n*/\n#define RE_OP_MATCH       1    /* Match the one character in the argument */\n#define RE_OP_ANY         2    /* Match any one character.  (Implements \".\") */\n#define RE_OP_ANYSTAR     3    /* Special optimized version of .* */\n#define RE_OP_FORK        4    /* Continue to both next and opcode at iArg */\n#define RE_OP_GOTO        5    /* Jump to opcode at iArg */\n#define RE_OP_ACCEPT      6    /* Halt and indicate a successful match */\n#define RE_OP_CC_INC      7    /* Beginning of a [...] character class */\n#define RE_OP_CC_EXC      8    /* Beginning of a [^...] character class */\n#define RE_OP_CC_VALUE    9    /* Single value in a character class */\n#define RE_OP_CC_RANGE   10    /* Range of values in a character class */\n#define RE_OP_WORD       11    /* Perl word character [A-Za-z0-9_] */\n#define RE_OP_NOTWORD    12    /* Not a perl word character */\n#define RE_OP_DIGIT      13    /* digit:  [0-9] */\n#define RE_OP_NOTDIGIT   14    /* Not a digit */\n#define RE_OP_SPACE      15    /* space:  [ \\t\\n\\r\\v\\f] */\n#define RE_OP_NOTSPACE   16    /* Not a digit */\n#define RE_OP_BOUNDARY   17    /* Boundary between word and non-word */\n\n/* Each opcode is a \"state\" in the NFA */\ntypedef unsigned short ReStateNumber;\n\n/* Because this is an NFA and not a DFA, multiple states can be active at\n** once.  An instance of the following object records all active states in\n** the NFA.  The implementation is optimized for the common case where the\n** number of actives states is small.\n*/\ntypedef struct ReStateSet {\n  unsigned nState;            /* Number of current states */\n  ReStateNumber *aState;      /* Current states */\n} ReStateSet;\n\n/* An input string read one character at a time.\n*/\ntypedef struct ReInput ReInput;\nstruct ReInput {\n  const unsigned char *z;  /* All text */\n  int i;                   /* Next byte to read */\n  int mx;                  /* EOF when i>=mx */\n};\n\n/* A compiled NFA (or an NFA that is in the process of being compiled) is\n** an instance of the following object.\n*/\ntypedef struct ReCompiled ReCompiled;\nstruct ReCompiled {\n  ReInput sIn;                /* Regular expression text */\n  const char *zErr;           /* Error message to return */\n  char *aOp;                  /* Operators for the virtual machine */\n  int *aArg;                  /* Arguments to each operator */\n  unsigned (*xNextChar)(ReInput*);  /* Next character function */\n  unsigned char zInit[12];    /* Initial text to match */\n  int nInit;                  /* Number of characters in zInit */\n  unsigned nState;            /* Number of entries in aOp[] and aArg[] */\n  unsigned nAlloc;            /* Slots allocated for aOp[] and aArg[] */\n};\n\n/* Add a state to the given state set if it is not already there */\nstatic void re_add_state(ReStateSet *pSet, int newState){\n  unsigned i;\n  for(i=0; i<pSet->nState; i++) if( pSet->aState[i]==newState ) return;\n  pSet->aState[pSet->nState++] = (ReStateNumber)newState;\n}\n\n/* Extract the next unicode character from *pzIn and return it.  Advance\n** *pzIn to the first byte past the end of the character returned.  To\n** be clear:  this routine converts utf8 to unicode.  This routine is \n** optimized for the common case where the next character is a single byte.\n*/\nstatic unsigned re_next_char(ReInput *p){\n  unsigned c;\n  if( p->i>=p->mx ) return 0;\n  c = p->z[p->i++];\n  if( c>=0x80 ){\n    if( (c&0xe0)==0xc0 && p->i<p->mx && (p->z[p->i]&0xc0)==0x80 ){\n      c = (c&0x1f)<<6 | (p->z[p->i++]&0x3f);\n      if( c<0x80 ) c = 0xfffd;\n    }else if( (c&0xf0)==0xe0 && p->i+1<p->mx && (p->z[p->i]&0xc0)==0x80\n           && (p->z[p->i+1]&0xc0)==0x80 ){\n      c = (c&0x0f)<<12 | ((p->z[p->i]&0x3f)<<6) | (p->z[p->i+1]&0x3f);\n      p->i += 2;\n      if( c<=0x3ff || (c>=0xd800 && c<=0xdfff) ) c = 0xfffd;\n    }else if( (c&0xf8)==0xf0 && p->i+3<p->mx && (p->z[p->i]&0xc0)==0x80\n           && (p->z[p->i+1]&0xc0)==0x80 && (p->z[p->i+2]&0xc0)==0x80 ){\n      c = (c&0x07)<<18 | ((p->z[p->i]&0x3f)<<12) | ((p->z[p->i+1]&0x3f)<<6)\n                       | (p->z[p->i+2]&0x3f);\n      p->i += 3;\n      if( c<=0xffff || c>0x10ffff ) c = 0xfffd;\n    }else{\n      c = 0xfffd;\n    }\n  }\n  return c;\n}\nstatic unsigned re_next_char_nocase(ReInput *p){\n  unsigned c = re_next_char(p);\n  if( c>='A' && c<='Z' ) c += 'a' - 'A';\n  return c;\n}\n\n/* Return true if c is a perl \"word\" character:  [A-Za-z0-9_] */\nstatic int re_word_char(int c){\n  return (c>='0' && c<='9') || (c>='a' && c<='z')\n      || (c>='A' && c<='Z') || c=='_';\n}\n\n/* Return true if c is a \"digit\" character:  [0-9] */\nstatic int re_digit_char(int c){\n  return (c>='0' && c<='9');\n}\n\n/* Return true if c is a perl \"space\" character:  [ \\t\\r\\n\\v\\f] */\nstatic int re_space_char(int c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\n\n/* Run a compiled regular expression on the zero-terminated input\n** string zIn[].  Return true on a match and false if there is no match.\n*/\nstatic int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){\n  ReStateSet aStateSet[2], *pThis, *pNext;\n  ReStateNumber aSpace[100];\n  ReStateNumber *pToFree;\n  unsigned int i = 0;\n  unsigned int iSwap = 0;\n  int c = RE_EOF+1;\n  int cPrev = 0;\n  int rc = 0;\n  ReInput in;\n\n  in.z = zIn;\n  in.i = 0;\n  in.mx = nIn>=0 ? nIn : (int)strlen((char const*)zIn);\n\n  /* Look for the initial prefix match, if there is one. */\n  if( pRe->nInit ){\n    unsigned char x = pRe->zInit[0];\n    while( in.i+pRe->nInit<=in.mx \n     && (zIn[in.i]!=x ||\n         strncmp((const char*)zIn+in.i, (const char*)pRe->zInit, pRe->nInit)!=0)\n    ){\n      in.i++;\n    }\n    if( in.i+pRe->nInit>in.mx ) return 0;\n  }\n\n  if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){\n    pToFree = 0;\n    aStateSet[0].aState = aSpace;\n  }else{\n    pToFree = sqlite3_malloc( sizeof(ReStateNumber)*2*pRe->nState );\n    if( pToFree==0 ) return -1;\n    aStateSet[0].aState = pToFree;\n  }\n  aStateSet[1].aState = &aStateSet[0].aState[pRe->nState];\n  pNext = &aStateSet[1];\n  pNext->nState = 0;\n  re_add_state(pNext, 0);\n  while( c!=RE_EOF && pNext->nState>0 ){\n    cPrev = c;\n    c = pRe->xNextChar(&in);\n    pThis = pNext;\n    pNext = &aStateSet[iSwap];\n    iSwap = 1 - iSwap;\n    pNext->nState = 0;\n    for(i=0; i<pThis->nState; i++){\n      int x = pThis->aState[i];\n      switch( pRe->aOp[x] ){\n        case RE_OP_MATCH: {\n          if( pRe->aArg[x]==c ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_ANY: {\n          re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_WORD: {\n          if( re_word_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_NOTWORD: {\n          if( !re_word_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_DIGIT: {\n          if( re_digit_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_NOTDIGIT: {\n          if( !re_digit_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_SPACE: {\n          if( re_space_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_NOTSPACE: {\n          if( !re_space_char(c) ) re_add_state(pNext, x+1);\n          break;\n        }\n        case RE_OP_BOUNDARY: {\n          if( re_word_char(c)!=re_word_char(cPrev) ) re_add_state(pThis, x+1);\n          break;\n        }\n        case RE_OP_ANYSTAR: {\n          re_add_state(pNext, x);\n          re_add_state(pThis, x+1);\n          break;\n        }\n        case RE_OP_FORK: {\n          re_add_state(pThis, x+pRe->aArg[x]);\n          re_add_state(pThis, x+1);\n          break;\n        }\n        case RE_OP_GOTO: {\n          re_add_state(pThis, x+pRe->aArg[x]);\n          break;\n        }\n        case RE_OP_ACCEPT: {\n          rc = 1;\n          goto re_match_end;\n        }\n        case RE_OP_CC_INC:\n        case RE_OP_CC_EXC: {\n          int j = 1;\n          int n = pRe->aArg[x];\n          int hit = 0;\n          for(j=1; j>0 && j<n; j++){\n            if( pRe->aOp[x+j]==RE_OP_CC_VALUE ){\n              if( pRe->aArg[x+j]==c ){\n                hit = 1;\n                j = -1;\n              }\n            }else{\n              if( pRe->aArg[x+j]<=c && pRe->aArg[x+j+1]>=c ){\n                hit = 1;\n                j = -1;\n              }else{\n                j++;\n              }\n            }\n          }\n          if( pRe->aOp[x]==RE_OP_CC_EXC ) hit = !hit;\n          if( hit ) re_add_state(pNext, x+n);\n          break;            \n        }\n      }\n    }\n  }\n  for(i=0; i<pNext->nState; i++){\n    if( pRe->aOp[pNext->aState[i]]==RE_OP_ACCEPT ){ rc = 1; break; }\n  }\nre_match_end:\n  sqlite3_free(pToFree);\n  return rc;\n}\n\n/* Resize the opcode and argument arrays for an RE under construction.\n*/\nstatic int re_resize(ReCompiled *p, int N){\n  char *aOp;\n  int *aArg;\n  aOp = sqlite3_realloc(p->aOp, N*sizeof(p->aOp[0]));\n  if( aOp==0 ) return 1;\n  p->aOp = aOp;\n  aArg = sqlite3_realloc(p->aArg, N*sizeof(p->aArg[0]));\n  if( aArg==0 ) return 1;\n  p->aArg = aArg;\n  p->nAlloc = N;\n  return 0;\n}\n\n/* Insert a new opcode and argument into an RE under construction.  The\n** insertion point is just prior to existing opcode iBefore.\n*/\nstatic int re_insert(ReCompiled *p, int iBefore, int op, int arg){\n  int i;\n  if( p->nAlloc<=p->nState && re_resize(p, p->nAlloc*2) ) return 0;\n  for(i=p->nState; i>iBefore; i--){\n    p->aOp[i] = p->aOp[i-1];\n    p->aArg[i] = p->aArg[i-1];\n  }\n  p->nState++;\n  p->aOp[iBefore] = (char)op;\n  p->aArg[iBefore] = arg;\n  return iBefore;\n}\n\n/* Append a new opcode and argument to the end of the RE under construction.\n*/\nstatic int re_append(ReCompiled *p, int op, int arg){\n  return re_insert(p, p->nState, op, arg);\n}\n\n/* Make a copy of N opcodes starting at iStart onto the end of the RE\n** under construction.\n*/\nstatic void re_copy(ReCompiled *p, int iStart, int N){\n  if( p->nState+N>=p->nAlloc && re_resize(p, p->nAlloc*2+N) ) return;\n  memcpy(&p->aOp[p->nState], &p->aOp[iStart], N*sizeof(p->aOp[0]));\n  memcpy(&p->aArg[p->nState], &p->aArg[iStart], N*sizeof(p->aArg[0]));\n  p->nState += N;\n}\n\n/* Return true if c is a hexadecimal digit character:  [0-9a-fA-F]\n** If c is a hex digit, also set *pV = (*pV)*16 + valueof(c).  If\n** c is not a hex digit *pV is unchanged.\n*/\nstatic int re_hex(int c, int *pV){\n  if( c>='0' && c<='9' ){\n    c -= '0';\n  }else if( c>='a' && c<='f' ){\n    c -= 'a' - 10;\n  }else if( c>='A' && c<='F' ){\n    c -= 'A' - 10;\n  }else{\n    return 0;\n  }\n  *pV = (*pV)*16 + (c & 0xff);\n  return 1;\n}\n\n/* A backslash character has been seen, read the next character and\n** return its interpretation.\n*/\nstatic unsigned re_esc_char(ReCompiled *p){\n  static const char zEsc[] = \"afnrtv\\\\()*.+?[$^{|}]\";\n  static const char zTrans[] = \"\\a\\f\\n\\r\\t\\v\";\n  int i, v = 0;\n  char c;\n  if( p->sIn.i>=p->sIn.mx ) return 0;\n  c = p->sIn.z[p->sIn.i];\n  if( c=='u' && p->sIn.i+4<p->sIn.mx ){\n    const unsigned char *zIn = p->sIn.z + p->sIn.i;\n    if( re_hex(zIn[1],&v)\n     && re_hex(zIn[2],&v)\n     && re_hex(zIn[3],&v)\n     && re_hex(zIn[4],&v)\n    ){\n      p->sIn.i += 5;\n      return v;\n    }\n  }\n  if( c=='x' && p->sIn.i+2<p->sIn.mx ){\n    const unsigned char *zIn = p->sIn.z + p->sIn.i;\n    if( re_hex(zIn[1],&v)\n     && re_hex(zIn[2],&v)\n    ){\n      p->sIn.i += 3;\n      return v;\n    }\n  }\n  for(i=0; zEsc[i] && zEsc[i]!=c; i++){}\n  if( zEsc[i] ){\n    if( i<6 ) c = zTrans[i];\n    p->sIn.i++;\n  }else{\n    p->zErr = \"unknown \\\\ escape\";\n  }\n  return c;\n}\n\n/* Forward declaration */\nstatic const char *re_subcompile_string(ReCompiled*);\n\n/* Peek at the next byte of input */\nstatic unsigned char rePeek(ReCompiled *p){\n  return p->sIn.i<p->sIn.mx ? p->sIn.z[p->sIn.i] : 0;\n}\n\n/* Compile RE text into a sequence of opcodes.  Continue up to the\n** first unmatched \")\" character, then return.  If an error is found,\n** return a pointer to the error message string.\n*/\nstatic const char *re_subcompile_re(ReCompiled *p){\n  const char *zErr;\n  int iStart, iEnd, iGoto;\n  iStart = p->nState;\n  zErr = re_subcompile_string(p);\n  if( zErr ) return zErr;\n  while( rePeek(p)=='|' ){\n    iEnd = p->nState;\n    re_insert(p, iStart, RE_OP_FORK, iEnd + 2 - iStart);\n    iGoto = re_append(p, RE_OP_GOTO, 0);\n    p->sIn.i++;\n    zErr = re_subcompile_string(p);\n    if( zErr ) return zErr;\n    p->aArg[iGoto] = p->nState - iGoto;\n  }\n  return 0;\n}\n\n/* Compile an element of regular expression text (anything that can be\n** an operand to the \"|\" operator).  Return NULL on success or a pointer\n** to the error message if there is a problem.\n*/\nstatic const char *re_subcompile_string(ReCompiled *p){\n  int iPrev = -1;\n  int iStart;\n  unsigned c;\n  const char *zErr;\n  while( (c = p->xNextChar(&p->sIn))!=0 ){\n    iStart = p->nState;\n    switch( c ){\n      case '|':\n      case '$': \n      case ')': {\n        p->sIn.i--;\n        return 0;\n      }\n      case '(': {\n        zErr = re_subcompile_re(p);\n        if( zErr ) return zErr;\n        if( rePeek(p)!=')' ) return \"unmatched '('\";\n        p->sIn.i++;\n        break;\n      }\n      case '.': {\n        if( rePeek(p)=='*' ){\n          re_append(p, RE_OP_ANYSTAR, 0);\n          p->sIn.i++;\n        }else{ \n          re_append(p, RE_OP_ANY, 0);\n        }\n        break;\n      }\n      case '*': {\n        if( iPrev<0 ) return \"'*' without operand\";\n        re_insert(p, iPrev, RE_OP_GOTO, p->nState - iPrev + 1);\n        re_append(p, RE_OP_FORK, iPrev - p->nState + 1);\n        break;\n      }\n      case '+': {\n        if( iPrev<0 ) return \"'+' without operand\";\n        re_append(p, RE_OP_FORK, iPrev - p->nState);\n        break;\n      }\n      case '?': {\n        if( iPrev<0 ) return \"'?' without operand\";\n        re_insert(p, iPrev, RE_OP_FORK, p->nState - iPrev+1);\n        break;\n      }\n      case '{': {\n        int m = 0, n = 0;\n        int sz, j;\n        if( iPrev<0 ) return \"'{m,n}' without operand\";\n        while( (c=rePeek(p))>='0' && c<='9' ){ m = m*10 + c - '0'; p->sIn.i++; }\n        n = m;\n        if( c==',' ){\n          p->sIn.i++;\n          n = 0;\n          while( (c=rePeek(p))>='0' && c<='9' ){ n = n*10 + c-'0'; p->sIn.i++; }\n        }\n        if( c!='}' ) return \"unmatched '{'\";\n        if( n>0 && n<m ) return \"n less than m in '{m,n}'\";\n        p->sIn.i++;\n        sz = p->nState - iPrev;\n        if( m==0 ){\n          if( n==0 ) return \"both m and n are zero in '{m,n}'\";\n          re_insert(p, iPrev, RE_OP_FORK, sz+1);\n          n--;\n        }else{\n          for(j=1; j<m; j++) re_copy(p, iPrev, sz);\n        }\n        for(j=m; j<n; j++){\n          re_append(p, RE_OP_FORK, sz+1);\n          re_copy(p, iPrev, sz);\n        }\n        if( n==0 && m>0 ){\n          re_append(p, RE_OP_FORK, -sz);\n        }\n        break;\n      }\n      case '[': {\n        int iFirst = p->nState;\n        if( rePeek(p)=='^' ){\n          re_append(p, RE_OP_CC_EXC, 0);\n          p->sIn.i++;\n        }else{\n          re_append(p, RE_OP_CC_INC, 0);\n        }\n        while( (c = p->xNextChar(&p->sIn))!=0 ){\n          if( c=='[' && rePeek(p)==':' ){\n            return \"POSIX character classes not supported\";\n          }\n          if( c=='\\\\' ) c = re_esc_char(p);\n          if( rePeek(p)=='-' ){\n            re_append(p, RE_OP_CC_RANGE, c);\n            p->sIn.i++;\n            c = p->xNextChar(&p->sIn);\n            if( c=='\\\\' ) c = re_esc_char(p);\n            re_append(p, RE_OP_CC_RANGE, c);\n          }else{\n            re_append(p, RE_OP_CC_VALUE, c);\n          }\n          if( rePeek(p)==']' ){ p->sIn.i++; break; }\n        }\n        if( c==0 ) return \"unclosed '['\";\n        p->aArg[iFirst] = p->nState - iFirst;\n        break;\n      }\n      case '\\\\': {\n        int specialOp = 0;\n        switch( rePeek(p) ){\n          case 'b': specialOp = RE_OP_BOUNDARY;   break;\n          case 'd': specialOp = RE_OP_DIGIT;      break;\n          case 'D': specialOp = RE_OP_NOTDIGIT;   break;\n          case 's': specialOp = RE_OP_SPACE;      break;\n          case 'S': specialOp = RE_OP_NOTSPACE;   break;\n          case 'w': specialOp = RE_OP_WORD;       break;\n          case 'W': specialOp = RE_OP_NOTWORD;    break;\n        }\n        if( specialOp ){\n          p->sIn.i++;\n          re_append(p, specialOp, 0);\n        }else{\n          c = re_esc_char(p);\n          re_append(p, RE_OP_MATCH, c);\n        }\n        break;\n      }\n      default: {\n        re_append(p, RE_OP_MATCH, c);\n        break;\n      }\n    }\n    iPrev = iStart;\n  }\n  return 0;\n}\n\n/* Free and reclaim all the memory used by a previously compiled\n** regular expression.  Applications should invoke this routine once\n** for every call to re_compile() to avoid memory leaks.\n*/\nvoid re_free(ReCompiled *pRe){\n  if( pRe ){\n    sqlite3_free(pRe->aOp);\n    sqlite3_free(pRe->aArg);\n    sqlite3_free(pRe);\n  }\n}\n\n/*\n** Compile a textual regular expression in zIn[] into a compiled regular\n** expression suitable for us by re_match() and return a pointer to the\n** compiled regular expression in *ppRe.  Return NULL on success or an\n** error message if something goes wrong.\n*/\nconst char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){\n  ReCompiled *pRe;\n  const char *zErr;\n  int i, j;\n\n  *ppRe = 0;\n  pRe = sqlite3_malloc( sizeof(*pRe) );\n  if( pRe==0 ){\n    return \"out of memory\";\n  }\n  memset(pRe, 0, sizeof(*pRe));\n  pRe->xNextChar = noCase ? re_next_char_nocase : re_next_char;\n  if( re_resize(pRe, 30) ){\n    re_free(pRe);\n    return \"out of memory\";\n  }\n  if( zIn[0]=='^' ){\n    zIn++;\n  }else{\n    re_append(pRe, RE_OP_ANYSTAR, 0);\n  }\n  pRe->sIn.z = (unsigned char*)zIn;\n  pRe->sIn.i = 0;\n  pRe->sIn.mx = (int)strlen(zIn);\n  zErr = re_subcompile_re(pRe);\n  if( zErr ){\n    re_free(pRe);\n    return zErr;\n  }\n  if( rePeek(pRe)=='$' && pRe->sIn.i+1>=pRe->sIn.mx ){\n    re_append(pRe, RE_OP_MATCH, RE_EOF);\n    re_append(pRe, RE_OP_ACCEPT, 0);\n    *ppRe = pRe;\n  }else if( pRe->sIn.i>=pRe->sIn.mx ){\n    re_append(pRe, RE_OP_ACCEPT, 0);\n    *ppRe = pRe;\n  }else{\n    re_free(pRe);\n    return \"unrecognized character\";\n  }\n\n  /* The following is a performance optimization.  If the regex begins with\n  ** \".*\" (if the input regex lacks an initial \"^\") and afterwards there are\n  ** one or more matching characters, enter those matching characters into\n  ** zInit[].  The re_match() routine can then search ahead in the input \n  ** string looking for the initial match without having to run the whole\n  ** regex engine over the string.  Do not worry able trying to match\n  ** unicode characters beyond plane 0 - those are very rare and this is\n  ** just an optimization. */\n  if( pRe->aOp[0]==RE_OP_ANYSTAR ){\n    for(j=0, i=1; j<sizeof(pRe->zInit)-2 && pRe->aOp[i]==RE_OP_MATCH; i++){\n      unsigned x = pRe->aArg[i];\n      if( x<=127 ){\n        pRe->zInit[j++] = (unsigned char)x;\n      }else if( x<=0xfff ){\n        pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));\n        pRe->zInit[j++] = 0x80 | (x&0x3f);\n      }else if( x<=0xffff ){\n        pRe->zInit[j++] = (unsigned char)(0xd0 | (x>>12));\n        pRe->zInit[j++] = 0x80 | ((x>>6)&0x3f);\n        pRe->zInit[j++] = 0x80 | (x&0x3f);\n      }else{\n        break;\n      }\n    }\n    if( j>0 && pRe->zInit[j-1]==0 ) j--;\n    pRe->nInit = j;\n  }\n  return pRe->zErr;\n}\n\n/*\n** Implementation of the regexp() SQL function.  This function implements\n** the build-in REGEXP operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A REGEXP B\n**\n** is implemented as regexp(B,A).\n*/\nstatic void re_sql_func(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  ReCompiled *pRe;          /* Compiled regular expression */\n  const char *zPattern;     /* The regular expression */\n  const unsigned char *zStr;/* String being searched */\n  const char *zErr;         /* Compile error message */\n  int setAux = 0;           /* True to invoke sqlite3_set_auxdata() */\n\n  pRe = sqlite3_get_auxdata(context, 0);\n  if( pRe==0 ){\n    zPattern = (const char*)sqlite3_value_text(argv[0]);\n    if( zPattern==0 ) return;\n    zErr = re_compile(&pRe, zPattern, 0);\n    if( zErr ){\n      re_free(pRe);\n      sqlite3_result_error(context, zErr, -1);\n      return;\n    }\n    if( pRe==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    setAux = 1;\n  }\n  zStr = (const unsigned char*)sqlite3_value_text(argv[1]);\n  if( zStr!=0 ){\n    sqlite3_result_int(context, re_match(pRe, zStr, -1));\n  }\n  if( setAux ){\n    sqlite3_set_auxdata(context, 0, pRe, (void(*)(void*))re_free);\n  }\n}\n\n/*\n** Invoke this routine to register the regexp() function with the\n** SQLite database connection.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_regexp_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_create_function(db, \"regexp\", 2, SQLITE_UTF8, 0,\n                                 re_sql_func, 0, 0);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/remember.c",
    "content": "/*\n** 2016-08-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates how to create an SQL function that is a pass-through\n** for integer values (it returns a copy of its argument) but also saves the\n** value that is passed through into a C-language variable.  The address of\n** the C-language variable is supplied as the second argument.\n**\n** This allows, for example, a counter to incremented and the original\n** value retrieved, atomically, using a single statement:\n**\n**    UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID\n**\n** Prepare the above statement once.  Then to use it, bind the address\n** of the output variable to $PTR using sqlite3_bind_pointer() with a\n** pointer type of \"carray\" and bind the id of the counter to $ID and\n** run the prepared statement.\n**\n** This implementation of the remember() function uses a \"carray\"\n** pointer so that it can share pointers with the carray() extension.\n**\n** One can imagine doing similar things with floating-point values and\n** strings, but this demonstration extension will stick to using just\n** integers.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n\n/*\n**      remember(V,PTR)\n**\n** Return the integer value V.  Also save the value of V in a\n** C-language variable whose address is PTR.\n*/\nstatic void rememberFunc(\n  sqlite3_context *pCtx,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_int64 v;\n  sqlite3_int64 *ptr;\n  assert( argc==2 );\n  v = sqlite3_value_int64(argv[0]);\n  ptr = sqlite3_value_pointer(argv[1], \"carray\");\n  if( ptr ) *ptr = v;\n  sqlite3_result_int64(pCtx, v);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_remember_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_create_function(db, \"remember\", 2, SQLITE_UTF8, 0,\n                               rememberFunc, 0, 0);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/rot13.c",
    "content": "/*\n** 2013-05-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements a rot13() function and a rot13\n** collating sequence.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n/*\n** Perform rot13 encoding on a single ASCII character.\n*/\nstatic unsigned char rot13(unsigned char c){\n  if( c>='a' && c<='z' ){\n    c += 13;\n    if( c>'z' ) c -= 26;\n  }else if( c>='A' && c<='Z' ){\n    c += 13;\n    if( c>'Z' ) c -= 26;\n  }\n  return c;\n}\n\n/*\n** Implementation of the rot13() function.\n**\n** Rotate ASCII alphabetic characters by 13 character positions.  \n** Non-ASCII characters are unchanged.  rot13(rot13(X)) should always\n** equal X.\n*/\nstatic void rot13func(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;\n  int nIn;\n  unsigned char *zOut;\n  char *zToFree = 0;\n  int i;\n  char zTemp[100];\n  assert( argc==1 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  zIn = (const unsigned char*)sqlite3_value_text(argv[0]);\n  nIn = sqlite3_value_bytes(argv[0]);\n  if( nIn<sizeof(zTemp)-1 ){\n    zOut = zTemp;\n  }else{\n    zOut = zToFree = sqlite3_malloc( nIn+1 );\n    if( zOut==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }\n  for(i=0; i<nIn; i++) zOut[i] = rot13(zIn[i]);\n  zOut[i] = 0;\n  sqlite3_result_text(context, (char*)zOut, i, SQLITE_TRANSIENT);\n  sqlite3_free(zToFree);\n}\n\n/*\n** Implement the rot13 collating sequence so that if\n**\n**      x=y COLLATE rot13\n**\n** Then \n**\n**      rot13(x)=rot13(y) COLLATE binary\n*/\nstatic int rot13CollFunc(\n  void *notUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  const char *zA = (const char*)pKey1;\n  const char *zB = (const char*)pKey2;\n  int i, x;\n  for(i=0; i<nKey1 && i<nKey2; i++){\n    x = (int)rot13(zA[i]) - (int)rot13(zB[i]);\n    if( x!=0 ) return x;\n  }\n  return nKey1 - nKey2;\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_rot_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"rot13\", 1, SQLITE_UTF8, 0,\n                               rot13func, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_collation(db, \"rot13\", SQLITE_UTF8, 0, rot13CollFunc);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/scrub.c",
    "content": "/*\n** 2016-05-05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file implements a utility function (and a utility program) that\n** makes a copy of an SQLite database while simultaneously zeroing out all\n** deleted content.\n**\n** Normally (when PRAGMA secure_delete=OFF, which is the default) when SQLite\n** deletes content, it does not overwrite the deleted content but rather marks\n** the region of the file that held that content as being reusable.  This can\n** cause deleted content to recoverable from the database file.  This stale\n** content is removed by the VACUUM command, but VACUUM can be expensive for\n** large databases.  When in PRAGMA secure_delete=ON mode, the deleted content\n** is zeroed, but secure_delete=ON has overhead as well.\n**\n** This utility attempts to make a copy of a complete SQLite database where\n** all of the deleted content is zeroed out in the copy, and it attempts to\n** do so while being faster than running VACUUM.\n**\n** Usage:\n**\n**   int sqlite3_scrub_backup(\n**       const char *zSourceFile,   // Source database filename\n**       const char *zDestFile,     // Destination database filename\n**       char **pzErrMsg            // Write error message here\n**   );\n**\n** Simply call the API above specifying the filename of the source database\n** and the name of the backup copy.  The source database must already exist\n** and can be in active use. (A read lock is held during the backup.)  The\n** destination file should not previously exist.  If the pzErrMsg parameter\n** is non-NULL and if an error occurs, then an error message might be written\n** into memory obtained from sqlite3_malloc() and *pzErrMsg made to point to\n** that error message.  But if the error is an OOM, the error might not be\n** reported.  The routine always returns non-zero if there is an error.\n**\n** If compiled with -DSCRUB_STANDALONE then a main() procedure is added and\n** this file becomes a standalone program that can be run as follows:\n**\n**      ./sqlite3scrub SOURCE DEST\n*/\n#include \"sqlite3.h\"\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n\ntypedef struct ScrubState ScrubState;\ntypedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\n\n\n/* State information for a scrub-and-backup operation */\nstruct ScrubState {\n  const char *zSrcFile;    /* Name of the source file */\n  const char *zDestFile;   /* Name of the destination file */\n  int rcErr;               /* Error code */\n  char *zErr;              /* Error message text */\n  sqlite3 *dbSrc;          /* Source database connection */\n  sqlite3_file *pSrc;      /* Source file handle */\n  sqlite3 *dbDest;         /* Destination database connection */\n  sqlite3_file *pDest;     /* Destination file handle */\n  u32 szPage;              /* Page size */\n  u32 szUsable;            /* Usable bytes on each page */\n  u32 nPage;               /* Number of pages */\n  u32 iLastPage;           /* Page number of last page written so far*/\n  u8 *page1;               /* Content of page 1 */\n};\n\n/* Store an error message */\nstatic void scrubBackupErr(ScrubState *p, const char *zFormat, ...){\n  va_list ap;\n  sqlite3_free(p->zErr);\n  va_start(ap, zFormat);\n  p->zErr = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( p->rcErr==0 ) p->rcErr = SQLITE_ERROR;\n}\n\n/* Allocate memory to hold a single page of content */\nstatic u8 *scrubBackupAllocPage(ScrubState *p){\n  u8 *pPage;\n  if( p->rcErr ) return 0;\n  pPage = sqlite3_malloc( p->szPage );\n  if( pPage==0 ) p->rcErr = SQLITE_NOMEM;\n  return pPage;\n}\n\n/* Read a page from the source database into memory.  Use the memory\n** provided by pBuf if not NULL or allocate a new page if pBuf==NULL.\n*/\nstatic u8 *scrubBackupRead(ScrubState *p, int pgno, u8 *pBuf){\n  int rc;\n  sqlite3_int64 iOff;\n  u8 *pOut = pBuf;\n  if( p->rcErr ) return 0;\n  if( pOut==0 ){\n    pOut = scrubBackupAllocPage(p);\n    if( pOut==0 ) return 0;\n  }\n  iOff = (pgno-1)*(sqlite3_int64)p->szPage;\n  rc = p->pSrc->pMethods->xRead(p->pSrc, pOut, p->szPage, iOff);\n  if( rc!=SQLITE_OK ){\n    if( pBuf==0 ) sqlite3_free(pOut);\n    pOut = 0;\n    scrubBackupErr(p, \"read failed for page %d\", pgno);\n    p->rcErr = SQLITE_IOERR;\n  }\n  return pOut;  \n}\n\n/* Write a page to the destination database */\nstatic void scrubBackupWrite(ScrubState *p, int pgno, const u8 *pData){\n  int rc;\n  sqlite3_int64 iOff;\n  if( p->rcErr ) return;\n  iOff = (pgno-1)*(sqlite3_int64)p->szPage;\n  rc = p->pDest->pMethods->xWrite(p->pDest, pData, p->szPage, iOff);\n  if( rc!=SQLITE_OK ){\n    scrubBackupErr(p, \"write failed for page %d\", pgno);\n    p->rcErr = SQLITE_IOERR;\n  }\n  if( pgno>p->iLastPage ) p->iLastPage = pgno;\n}\n\n/* Prepare a statement against the \"db\" database. */\nstatic sqlite3_stmt *scrubBackupPrepare(\n  ScrubState *p,      /* Backup context */\n  sqlite3 *db,        /* Database to prepare against */\n  const char *zSql    /* SQL statement */\n){\n  sqlite3_stmt *pStmt;\n  if( p->rcErr ) return 0;\n  p->rcErr = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( p->rcErr ){\n    scrubBackupErr(p, \"SQL error \\\"%s\\\" on \\\"%s\\\"\",\n                   sqlite3_errmsg(db), zSql);\n    sqlite3_finalize(pStmt);\n    return 0;\n  }\n  return pStmt;\n}\n\n\n/* Open the source database file */\nstatic void scrubBackupOpenSrc(ScrubState *p){\n  sqlite3_stmt *pStmt;\n  int rc;\n  /* Open the source database file */\n  p->rcErr = sqlite3_open_v2(p->zSrcFile, &p->dbSrc,\n                 SQLITE_OPEN_READWRITE |\n                 SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0);\n  if( p->rcErr ){\n    scrubBackupErr(p, \"cannot open source database: %s\",\n                      sqlite3_errmsg(p->dbSrc));\n    return;\n  }\n  p->rcErr = sqlite3_exec(p->dbSrc, \"SELECT 1 FROM sqlite_master; BEGIN;\",\n                          0, 0, 0);\n  if( p->rcErr ){\n    scrubBackupErr(p,\n       \"cannot start a read transaction on the source database: %s\",\n       sqlite3_errmsg(p->dbSrc));\n    return;\n  }\n  rc = sqlite3_wal_checkpoint_v2(p->dbSrc, \"main\", SQLITE_CHECKPOINT_FULL,\n                                 0, 0);\n  if( rc ){\n    scrubBackupErr(p, \"cannot checkpoint the source database\");\n    return;\n  }\n  pStmt = scrubBackupPrepare(p, p->dbSrc, \"PRAGMA page_size\");\n  if( pStmt==0 ) return;\n  rc = sqlite3_step(pStmt);\n  if( rc==SQLITE_ROW ){\n    p->szPage = sqlite3_column_int(pStmt, 0);\n  }else{\n    scrubBackupErr(p, \"unable to determine the page size\");\n  }\n  sqlite3_finalize(pStmt);\n  if( p->rcErr ) return;\n  pStmt = scrubBackupPrepare(p, p->dbSrc, \"PRAGMA page_count\");\n  if( pStmt==0 ) return;\n  rc = sqlite3_step(pStmt);\n  if( rc==SQLITE_ROW ){\n    p->nPage = sqlite3_column_int(pStmt, 0);\n  }else{\n    scrubBackupErr(p, \"unable to determine the size of the source database\");\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_file_control(p->dbSrc, \"main\", SQLITE_FCNTL_FILE_POINTER, &p->pSrc);\n  if( p->pSrc==0 || p->pSrc->pMethods==0 ){\n    scrubBackupErr(p, \"cannot get the source file handle\");\n    p->rcErr = SQLITE_ERROR;\n  }\n}\n\n/* Create and open the destination file */\nstatic void scrubBackupOpenDest(ScrubState *p){\n  sqlite3_stmt *pStmt;\n  int rc;\n  char *zSql;\n  if( p->rcErr ) return;\n  p->rcErr = sqlite3_open_v2(p->zDestFile, &p->dbDest,\n                 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n                 SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0);\n  if( p->rcErr ){\n    scrubBackupErr(p, \"cannot open destination database: %s\",\n                      sqlite3_errmsg(p->dbDest));\n    return;\n  }\n  zSql = sqlite3_mprintf(\"PRAGMA page_size(%u);\", p->szPage);\n  if( zSql==0 ){\n    p->rcErr = SQLITE_NOMEM;\n    return;\n  }\n  p->rcErr = sqlite3_exec(p->dbDest, zSql, 0, 0, 0);\n  sqlite3_free(zSql);\n  if( p->rcErr ){\n    scrubBackupErr(p,\n       \"cannot set the page size on the destination database: %s\",\n       sqlite3_errmsg(p->dbDest));\n    return;\n  }\n  sqlite3_exec(p->dbDest, \"PRAGMA journal_mode=OFF;\", 0, 0, 0);\n  p->rcErr = sqlite3_exec(p->dbDest, \"BEGIN EXCLUSIVE;\", 0, 0, 0);\n  if( p->rcErr ){\n    scrubBackupErr(p,\n       \"cannot start a write transaction on the destination database: %s\",\n       sqlite3_errmsg(p->dbDest));\n    return;\n  }\n  pStmt = scrubBackupPrepare(p, p->dbDest, \"PRAGMA page_count;\");\n  if( pStmt==0 ) return;\n  rc = sqlite3_step(pStmt);\n  if( rc!=SQLITE_ROW ){\n    scrubBackupErr(p, \"cannot measure the size of the destination\");\n  }else if( sqlite3_column_int(pStmt, 0)>1 ){\n    scrubBackupErr(p, \"destination database is not empty - holds %d pages\",\n                   sqlite3_column_int(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_file_control(p->dbDest, \"main\", SQLITE_FCNTL_FILE_POINTER, &p->pDest);\n  if( p->pDest==0 || p->pDest->pMethods==0 ){\n    scrubBackupErr(p, \"cannot get the destination file handle\");\n    p->rcErr = SQLITE_ERROR;\n  }\n}\n\n/* Read a 32-bit big-endian integer */\nstatic u32 scrubBackupInt32(const u8 *a){\n  u32 v = a[3];\n  v += ((u32)a[2])<<8;\n  v += ((u32)a[1])<<16;\n  v += ((u32)a[0])<<24;\n  return v;\n}\n\n/* Read a 16-bit big-endian integer */\nstatic u32 scrubBackupInt16(const u8 *a){\n  return (a[0]<<8) + a[1];\n}\n\n/*\n** Read a varint.  Put the value in *pVal and return the number of bytes.\n*/\nstatic int scrubBackupVarint(const u8 *z, sqlite3_int64 *pVal){\n  sqlite3_int64 v = 0;\n  int i;\n  for(i=0; i<8; i++){\n    v = (v<<7) + (z[i]&0x7f);\n    if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; }\n  }\n  v = (v<<8) + (z[i]&0xff);\n  *pVal = v;\n  return 9;\n}\n\n/*\n** Return the number of bytes in a varint.\n*/\nstatic int scrubBackupVarintSize(const u8 *z){\n  int i;\n  for(i=0; i<8; i++){\n    if( (z[i]&0x80)==0 ){ return i+1; }\n  }\n  return 9;\n}\n\n/*\n** Copy the freelist trunk page given, and all its descendents,\n** zeroing out as much as possible in the process.\n*/\nstatic void scrubBackupFreelist(ScrubState *p, int pgno, u32 nFree){\n  u8 *a, *aBuf;\n  u32 n, mx;\n\n  if( p->rcErr ) return;\n  aBuf = scrubBackupAllocPage(p);\n  if( aBuf==0 ) return;\n \n  while( pgno && nFree){\n    a = scrubBackupRead(p, pgno, aBuf);\n    if( a==0 ) break;\n    n = scrubBackupInt32(&a[4]);\n    mx = p->szUsable/4 - 2;\n    if( n<mx ){\n      memset(&a[n*4+8], 0, 4*(mx-n));\n    }\n    scrubBackupWrite(p, pgno, a);\n    pgno = scrubBackupInt32(a);\n#if 0\n    /* There is really no point in copying the freelist leaf pages.\n    ** Simply leave them uninitialized in the destination database.  The\n    ** OS filesystem should zero those pages for us automatically.\n    */\n    for(i=0; i<n && nFree; i++){\n      u32 iLeaf = scrubBackupInt32(&a[i*4+8]);\n      if( aZero==0 ){\n        aZero = scrubBackupAllocPage(p);\n        if( aZero==0 ){ pgno = 0; break; }\n        memset(aZero, 0, p->szPage);\n      }\n      scrubBackupWrite(p, iLeaf, aZero);\n      nFree--;\n    }\n#endif\n  }\n  sqlite3_free(aBuf);\n}\n\n/*\n** Copy an overflow chain from source to destination.  Zero out any\n** unused tail at the end of the overflow chain.\n*/\nstatic void scrubBackupOverflow(ScrubState *p, int pgno, u32 nByte){\n  u8 *a, *aBuf;\n\n  aBuf = scrubBackupAllocPage(p);\n  if( aBuf==0 ) return;\n  while( nByte>0 && pgno!=0 ){\n    a = scrubBackupRead(p, pgno, aBuf);\n    if( a==0 ) break;\n    if( nByte >= (p->szUsable)-4 ){\n      nByte -= (p->szUsable) - 4;\n    }else{\n      u32 x = (p->szUsable - 4) - nByte;\n      u32 i = p->szUsable - x;\n      memset(&a[i], 0, x);\n      nByte = 0;\n    }\n    scrubBackupWrite(p, pgno, a);\n    pgno = scrubBackupInt32(a);\n  }\n  sqlite3_free(aBuf);      \n}\n   \n\n/*\n** Copy B-Tree page pgno, and all of its children, from source to destination.\n** Zero out deleted content during the copy.\n*/\nstatic void scrubBackupBtree(ScrubState *p, int pgno, int iDepth){\n  u8 *a;\n  u32 i, n, pc;\n  u32 nCell;\n  u32 nPrefix;\n  u32 szHdr;\n  u32 iChild;\n  u8 *aTop;\n  u8 *aCell;\n  u32 x, y;\n  int ln = 0;\n\n  \n  if( p->rcErr ) return;\n  if( iDepth>50 ){\n    scrubBackupErr(p, \"corrupt: b-tree too deep at page %d\", pgno);\n    return;\n  }\n  if( pgno==1 ){\n    a = p->page1;\n  }else{\n    a = scrubBackupRead(p, pgno, 0);\n    if( a==0 ) return;\n  }\n  nPrefix = pgno==1 ? 100 : 0;\n  aTop = &a[nPrefix];\n  szHdr = 8 + 4*(aTop[0]==0x02 || aTop[0]==0x05);\n  aCell = aTop + szHdr;\n  nCell = scrubBackupInt16(&aTop[3]);\n\n  /* Zero out the gap between the cell index and the start of the\n  ** cell content area */\n  x = scrubBackupInt16(&aTop[5]);  /* First byte of cell content area */\n  if( x>p->szUsable ){ ln=__LINE__; goto btree_corrupt; }\n  y = szHdr + nPrefix + nCell*2;\n  if( y>x ){ ln=__LINE__; goto btree_corrupt; }\n  if( y<x ) memset(a+y, 0, x-y);  /* Zero the gap */\n\n  /* Zero out all the free blocks */  \n  pc = scrubBackupInt16(&aTop[1]);\n  if( pc>0 && pc<x ){ ln=__LINE__; goto btree_corrupt; }\n  while( pc ){\n    if( pc>(p->szUsable)-4 ){ ln=__LINE__; goto btree_corrupt; }\n    n = scrubBackupInt16(&a[pc+2]);\n    if( pc+n>(p->szUsable) ){ ln=__LINE__; goto btree_corrupt; }\n    if( n>4 ) memset(&a[pc+4], 0, n-4);\n    x = scrubBackupInt16(&a[pc]);\n    if( x<pc+4 && x>0 ){ ln=__LINE__; goto btree_corrupt; }\n    pc = x;\n  }\n\n  /* Write this one page */\n  scrubBackupWrite(p, pgno, a);\n\n  /* Walk the tree and process child pages */\n  for(i=0; i<nCell; i++){\n    u32 X, M, K, nLocal;\n    sqlite3_int64 P;\n    pc = scrubBackupInt16(&aCell[i*2]);\n    if( pc <= szHdr ){ ln=__LINE__; goto btree_corrupt; }\n    if( pc > p->szUsable-3 ){ ln=__LINE__; goto btree_corrupt; }\n    if( aTop[0]==0x05 || aTop[0]==0x02 ){\n      if( pc+4 > p->szUsable ){ ln=__LINE__; goto btree_corrupt; }\n      iChild = scrubBackupInt32(&a[pc]);\n      pc += 4;\n      scrubBackupBtree(p, iChild, iDepth+1);\n      if( aTop[0]==0x05 ) continue;\n    }\n    pc += scrubBackupVarint(&a[pc], &P);\n    if( pc >= p->szUsable ){ ln=__LINE__; goto btree_corrupt; }\n    if( aTop[0]==0x0d ){\n      X = p->szUsable - 35;\n    }else{\n      X = ((p->szUsable - 12)*64/255) - 23;\n    }\n    if( P<=X ){\n      /* All content is local.  No overflow */\n      continue;\n    }\n    M = ((p->szUsable - 12)*32/255)-23;\n    K = M + ((P-M)%(p->szUsable-4));\n    if( aTop[0]==0x0d ){\n      pc += scrubBackupVarintSize(&a[pc]);\n      if( pc > (p->szUsable-4) ){ ln=__LINE__; goto btree_corrupt; }\n    }\n    nLocal = K<=X ? K : M;\n    if( pc+nLocal > p->szUsable-4 ){ ln=__LINE__; goto btree_corrupt; }\n    iChild = scrubBackupInt32(&a[pc+nLocal]);\n    scrubBackupOverflow(p, iChild, P-nLocal);\n  }\n\n  /* Walk the right-most tree */\n  if( aTop[0]==0x05 || aTop[0]==0x02 ){\n    iChild = scrubBackupInt32(&aTop[8]);\n    scrubBackupBtree(p, iChild, iDepth+1);\n  }\n\n  /* All done */\n  if( pgno>1 ) sqlite3_free(a);\n  return;\n\nbtree_corrupt:\n  scrubBackupErr(p, \"corruption on page %d of source database (errid=%d)\",\n                 pgno, ln);\n  if( pgno>1 ) sqlite3_free(a);  \n}\n\n/*\n** Copy all ptrmap pages from source to destination.\n** This routine is only called if the source database is in autovacuum\n** or incremental vacuum mode.\n*/\nstatic void scrubBackupPtrmap(ScrubState *p){\n  u32 pgno = 2;\n  u32 J = p->szUsable/5;\n  u32 iLock = (1073742335/p->szPage)+1;\n  u8 *a, *pBuf;\n  if( p->rcErr ) return;\n  pBuf = scrubBackupAllocPage(p);\n  if( pBuf==0 ) return;\n  while( pgno<=p->nPage ){\n    a = scrubBackupRead(p, pgno, pBuf);\n    if( a==0 ) break;\n    scrubBackupWrite(p, pgno, a);\n    pgno += J+1;\n    if( pgno==iLock ) pgno++;\n  }\n  sqlite3_free(pBuf);\n}\n\nint sqlite3_scrub_backup(\n  const char *zSrcFile,    /* Source file */\n  const char *zDestFile,   /* Destination file */\n  char **pzErr             /* Write error here if non-NULL */\n){\n  ScrubState s;\n  u32 n, i;\n  sqlite3_stmt *pStmt;\n\n  memset(&s, 0, sizeof(s));\n  s.zSrcFile = zSrcFile;\n  s.zDestFile = zDestFile;\n\n  /* Open both source and destination databases */\n  scrubBackupOpenSrc(&s);\n  scrubBackupOpenDest(&s);\n\n  /* Read in page 1 */\n  s.page1 = scrubBackupRead(&s, 1, 0);\n  if( s.page1==0 ) goto scrub_abort;\n  s.szUsable = s.szPage - s.page1[20];\n\n  /* Copy the freelist */    \n  n = scrubBackupInt32(&s.page1[36]);\n  i = scrubBackupInt32(&s.page1[32]);\n  if( n ) scrubBackupFreelist(&s, i, n);\n\n  /* Copy ptrmap pages */\n  n = scrubBackupInt32(&s.page1[52]);\n  if( n ) scrubBackupPtrmap(&s);\n\n  /* Copy all of the btrees */\n  scrubBackupBtree(&s, 1, 0);\n  pStmt = scrubBackupPrepare(&s, s.dbSrc,\n       \"SELECT rootpage FROM sqlite_master WHERE coalesce(rootpage,0)>0\");\n  if( pStmt==0 ) goto scrub_abort;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    i = (u32)sqlite3_column_int(pStmt, 0);\n    scrubBackupBtree(&s, i, 0);\n  }\n  sqlite3_finalize(pStmt);\n\n  /* If the last page of the input db file is a free-list leaf, then the\n  ** backup file on disk is still smaller than the size indicated within \n  ** the database header. In this case, write a page of zeroes to the \n  ** last page of the backup database so that SQLite does not mistakenly\n  ** think the db is corrupt.  */\n  if( s.iLastPage<s.nPage ){\n    u8 *aZero = scrubBackupAllocPage(&s);\n    if( aZero ){\n      memset(aZero, 0, s.szPage);\n      scrubBackupWrite(&s, s.nPage, aZero);\n      sqlite3_free(aZero);\n    }\n  }\n\nscrub_abort:    \n  /* Close the destination database without closing the transaction. If we\n  ** commit, page zero will be overwritten. */\n  sqlite3_close(s.dbDest);\n\n  /* But do close out the read-transaction on the source database */\n  sqlite3_exec(s.dbSrc, \"COMMIT;\", 0, 0, 0);\n  sqlite3_close(s.dbSrc);\n  sqlite3_free(s.page1);\n  if( pzErr ){\n    *pzErr = s.zErr;\n  }else{\n    sqlite3_free(s.zErr);\n  }\n  return s.rcErr;\n}   \n\n#ifdef SCRUB_STANDALONE\n/* Error and warning log */\nstatic void errorLogCallback(void *pNotUsed, int iErr, const char *zMsg){\n  const char *zType;\n  switch( iErr&0xff ){\n    case SQLITE_WARNING: zType = \"WARNING\";  break;\n    case SQLITE_NOTICE:  zType = \"NOTICE\";   break;\n    default:             zType = \"ERROR\";    break;\n  }\n  fprintf(stderr, \"%s: %s\\n\", zType, zMsg);\n}\n\n/* The main() routine when this utility is run as a stand-alone program */\nint main(int argc, char **argv){\n  char *zErr = 0;\n  int rc;\n  if( argc!=3 ){\n    fprintf(stderr,\"Usage: %s SOURCE DESTINATION\\n\", argv[0]);\n    exit(1);\n  }\n  sqlite3_config(SQLITE_CONFIG_LOG, errorLogCallback, 0);\n  rc = sqlite3_scrub_backup(argv[1], argv[2], &zErr);\n  if( rc==SQLITE_NOMEM ){\n    fprintf(stderr, \"%s: out of memory\\n\", argv[0]);\n    exit(1);\n  }\n  if( zErr ){\n    fprintf(stderr, \"%s: %s\\n\", argv[0], zErr);\n    sqlite3_free(zErr);\n    exit(1);\n  }\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/series.c",
    "content": "/*\n** 2015-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates how to create a table-valued-function using\n** a virtual table.  This demo implements the generate_series() function\n** which gives similar results to the eponymous function in PostgreSQL.\n** Examples:\n**\n**      SELECT * FROM generate_series(0,100,5);\n**\n** The query above returns integers from 0 through 100 counting by steps\n** of 5.\n**\n**      SELECT * FROM generate_series(0,100);\n**\n** Integers from 0 through 100 with a step size of 1.\n**\n**      SELECT * FROM generate_series(20) LIMIT 10;\n**\n** Integers 20 through 29.\n**\n** HOW IT WORKS\n**\n** The generate_series \"function\" is really a virtual table with the\n** following schema:\n**\n**     CREATE TABLE generate_series(\n**       value,\n**       start HIDDEN,\n**       stop HIDDEN,\n**       step HIDDEN\n**     );\n**\n** Function arguments in queries against this virtual table are translated\n** into equality constraints against successive hidden columns.  In other\n** words, the following pairs of queries are equivalent to each other:\n**\n**    SELECT * FROM generate_series(0,100,5);\n**    SELECT * FROM generate_series WHERE start=0 AND stop=100 AND step=5;\n**\n**    SELECT * FROM generate_series(0,100);\n**    SELECT * FROM generate_series WHERE start=0 AND stop=100;\n**\n**    SELECT * FROM generate_series(20) LIMIT 10;\n**    SELECT * FROM generate_series WHERE start=20 LIMIT 10;\n**\n** The generate_series virtual table implementation leaves the xCreate method\n** set to NULL.  This means that it is not possible to do a CREATE VIRTUAL\n** TABLE command with \"generate_series\" as the USING argument.  Instead, there\n** is a single generate_series virtual table that is always available without\n** having to be created first.\n**\n** The xBestIndex method looks for equality constraints against the hidden\n** start, stop, and step columns, and if present, it uses those constraints\n** to bound the sequence of generated values.  If the equality constraints\n** are missing, it uses 0 for start, 4294967295 for stop, and 1 for step.\n** xBestIndex returns a small cost when both start and stop are available,\n** and a very large cost if either start or stop are unavailable.  This\n** encourages the query planner to order joins such that the bounds of the\n** series are well-defined.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n\n/* series_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct series_cursor series_cursor;\nstruct series_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  int isDesc;                /* True to count down rather than up */\n  sqlite3_int64 iRowid;      /* The rowid */\n  sqlite3_int64 iValue;      /* Current value (\"value\") */\n  sqlite3_int64 mnValue;     /* Mimimum value (\"start\") */\n  sqlite3_int64 mxValue;     /* Maximum value (\"stop\") */\n  sqlite3_int64 iStep;       /* Increment (\"step\") */\n};\n\n/*\n** The seriesConnect() method is invoked to create a new\n** series_vtab that describes the generate_series virtual table.\n**\n** Think of this routine as the constructor for series_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the series_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against generate_series will look like.\n*/\nstatic int seriesConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define SERIES_COLUMN_VALUE 0\n#define SERIES_COLUMN_START 1\n#define SERIES_COLUMN_STOP  2\n#define SERIES_COLUMN_STEP  3\n\n  rc = sqlite3_declare_vtab(db,\n     \"CREATE TABLE x(value,start hidden,stop hidden,step hidden)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for series_cursor objects.\n*/\nstatic int seriesDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new series_cursor object.\n*/\nstatic int seriesOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  series_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a series_cursor.\n*/\nstatic int seriesClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a series_cursor to its next row of output.\n*/\nstatic int seriesNext(sqlite3_vtab_cursor *cur){\n  series_cursor *pCur = (series_cursor*)cur;\n  if( pCur->isDesc ){\n    pCur->iValue -= pCur->iStep;\n  }else{\n    pCur->iValue += pCur->iStep;\n  }\n  pCur->iRowid++;\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the series_cursor\n** is currently pointing.\n*/\nstatic int seriesColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  series_cursor *pCur = (series_cursor*)cur;\n  sqlite3_int64 x = 0;\n  switch( i ){\n    case SERIES_COLUMN_START:  x = pCur->mnValue; break;\n    case SERIES_COLUMN_STOP:   x = pCur->mxValue; break;\n    case SERIES_COLUMN_STEP:   x = pCur->iStep;   break;\n    default:                   x = pCur->iValue;  break;\n  }\n  sqlite3_result_int64(ctx, x);\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row. In this implementation, the\n** first row returned is assigned rowid value 1, and each subsequent\n** row a value 1 more than that of the previous.\n*/\nstatic int seriesRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  series_cursor *pCur = (series_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int seriesEof(sqlite3_vtab_cursor *cur){\n  series_cursor *pCur = (series_cursor*)cur;\n  if( pCur->isDesc ){\n    return pCur->iValue < pCur->mnValue;\n  }else{\n    return pCur->iValue > pCur->mxValue;\n  }\n}\n\n/* True to cause run-time checking of the start=, stop=, and/or step= \n** parameters.  The only reason to do this is for testing the\n** constraint checking logic for virtual tables in the SQLite core.\n*/\n#ifndef SQLITE_SERIES_CONSTRAINT_VERIFY\n# define SQLITE_SERIES_CONSTRAINT_VERIFY 0\n#endif\n\n/*\n** This method is called to \"rewind\" the series_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to seriesColumn() or seriesRowid() or \n** seriesEof().\n**\n** The query plan selected by seriesBestIndex is passed in the idxNum\n** parameter.  (idxStr is not used in this implementation.)  idxNum\n** is a bitmask showing which constraints are available:\n**\n**    1:    start=VALUE\n**    2:    stop=VALUE\n**    4:    step=VALUE\n**\n** Also, if bit 8 is set, that means that the series should be output\n** in descending order rather than in ascending order.\n**\n** This routine should initialize the cursor and position it so that it\n** is pointing at the first row, or pointing off the end of the table\n** (so that seriesEof() will return true) if the table is empty.\n*/\nstatic int seriesFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  series_cursor *pCur = (series_cursor *)pVtabCursor;\n  int i = 0;\n  if( idxNum & 1 ){\n    pCur->mnValue = sqlite3_value_int64(argv[i++]);\n  }else{\n    pCur->mnValue = 0;\n  }\n  if( idxNum & 2 ){\n    pCur->mxValue = sqlite3_value_int64(argv[i++]);\n  }else{\n    pCur->mxValue = 0xffffffff;\n  }\n  if( idxNum & 4 ){\n    pCur->iStep = sqlite3_value_int64(argv[i++]);\n    if( pCur->iStep<1 ) pCur->iStep = 1;\n  }else{\n    pCur->iStep = 1;\n  }\n  if( idxNum & 8 ){\n    pCur->isDesc = 1;\n    pCur->iValue = pCur->mxValue;\n    if( pCur->iStep>0 ){\n      pCur->iValue -= (pCur->mxValue - pCur->mnValue)%pCur->iStep;\n    }\n  }else{\n    pCur->isDesc = 0;\n    pCur->iValue = pCur->mnValue;\n  }\n  pCur->iRowid = 1;\n  return SQLITE_OK;\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the generate_series virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n**\n** In this implementation idxNum is used to represent the\n** query plan.  idxStr is unused.\n**\n** The query plan is represented by bits in idxNum:\n**\n**  (1)  start = $value  -- constraint exists\n**  (2)  stop = $value   -- constraint exists\n**  (4)  step = $value   -- constraint exists\n**  (8)  output in descending order\n*/\nstatic int seriesBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                 /* Loop over constraints */\n  int idxNum = 0;        /* The query plan bitmask */\n  int startIdx = -1;     /* Index of the start= constraint, or -1 if none */\n  int stopIdx = -1;      /* Index of the stop= constraint, or -1 if none */\n  int stepIdx = -1;      /* Index of the step= constraint, or -1 if none */\n  int nArg = 0;          /* Number of arguments that seriesFilter() expects */\n\n  const struct sqlite3_index_constraint *pConstraint;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case SERIES_COLUMN_START:\n        startIdx = i;\n        idxNum |= 1;\n        break;\n      case SERIES_COLUMN_STOP:\n        stopIdx = i;\n        idxNum |= 2;\n        break;\n      case SERIES_COLUMN_STEP:\n        stepIdx = i;\n        idxNum |= 4;\n        break;\n    }\n  }\n  if( startIdx>=0 ){\n    pIdxInfo->aConstraintUsage[startIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[startIdx].omit= !SQLITE_SERIES_CONSTRAINT_VERIFY;\n  }\n  if( stopIdx>=0 ){\n    pIdxInfo->aConstraintUsage[stopIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[stopIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;\n  }\n  if( stepIdx>=0 ){\n    pIdxInfo->aConstraintUsage[stepIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[stepIdx].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;\n  }\n  if( (idxNum & 3)==3 ){\n    /* Both start= and stop= boundaries are available.  This is the \n    ** the preferred case */\n    pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));\n    pIdxInfo->estimatedRows = 1000;\n    if( pIdxInfo->nOrderBy==1 ){\n      if( pIdxInfo->aOrderBy[0].desc ) idxNum |= 8;\n      pIdxInfo->orderByConsumed = 1;\n    }\n  }else{\n    /* If either boundary is missing, we have to generate a huge span\n    ** of numbers.  Make this case very expensive so that the query\n    ** planner will work hard to avoid it. */\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n  }\n  pIdxInfo->idxNum = idxNum;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** generate_series virtual table.\n*/\nstatic sqlite3_module seriesModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  seriesConnect,             /* xConnect */\n  seriesBestIndex,           /* xBestIndex */\n  seriesDisconnect,          /* xDisconnect */\n  0,                         /* xDestroy */\n  seriesOpen,                /* xOpen - open a cursor */\n  seriesClose,               /* xClose - close a cursor */\n  seriesFilter,              /* xFilter - configure scan constraints */\n  seriesNext,                /* xNext - advance a cursor */\n  seriesEof,                 /* xEof - check for end of scan */\n  seriesColumn,              /* xColumn - read data */\n  seriesRowid,               /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_series_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3_libversion_number()<3008012 ){\n    *pzErrMsg = sqlite3_mprintf(\n        \"generate_series() requires SQLite 3.8.12 or later\");\n    return SQLITE_ERROR;\n  }\n  rc = sqlite3_create_module(db, \"generate_series\", &seriesModule, 0);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/sha1.c",
    "content": "/*\n** 2017-01-27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements a functions that compute SHA1 hashes.\n** Two SQL functions are implemented:\n**\n**     sha1(X)\n**     sha1_query(Y)\n**\n** The sha1(X) function computes the SHA1 hash of the input X, or NULL if\n** X is NULL.\n**\n** The sha1_query(Y) function evalutes all queries in the SQL statements of Y\n** and returns a hash of their results.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <stdarg.h>\n\n/******************************************************************************\n** The Hash Engine\n*/\n/* Context for the SHA1 hash */\ntypedef struct SHA1Context SHA1Context;\nstruct SHA1Context {\n  unsigned int state[5];\n  unsigned int count[2];\n  unsigned char buffer[64];\n};\n\n\n#if __GNUC__ && (defined(__i386__) || defined(__x86_64__))\n/*\n * GCC by itself only generates left rotates.  Use right rotates if\n * possible to be kinder to dinky implementations with iterative rotate\n * instructions.\n */\n#define SHA_ROT(op, x, k) \\\n        ({ unsigned int y; asm(op \" %1,%0\" : \"=r\" (y) : \"I\" (k), \"0\" (x)); y; })\n#define rol(x,k) SHA_ROT(\"roll\", x, k)\n#define ror(x,k) SHA_ROT(\"rorl\", x, k)\n\n#else\n/* Generic C equivalent */\n#define SHA_ROT(x,l,r) ((x) << (l) | (x) >> (r))\n#define rol(x,k) SHA_ROT(x,k,32-(k))\n#define ror(x,k) SHA_ROT(x,32-(k),k)\n#endif\n\n\n#define blk0le(i) (block[i] = (ror(block[i],8)&0xFF00FF00) \\\n    |(rol(block[i],8)&0x00FF00FF))\n#define blk0be(i) block[i]\n#define blk(i) (block[i&15] = rol(block[(i+13)&15]^block[(i+8)&15] \\\n    ^block[(i+2)&15]^block[i&15],1))\n\n/*\n * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1\n *\n * Rl0() for little-endian and Rb0() for big-endian.  Endianness is\n * determined at run-time.\n */\n#define Rl0(v,w,x,y,z,i) \\\n    z+=((w&(x^y))^y)+blk0le(i)+0x5A827999+rol(v,5);w=ror(w,2);\n#define Rb0(v,w,x,y,z,i) \\\n    z+=((w&(x^y))^y)+blk0be(i)+0x5A827999+rol(v,5);w=ror(w,2);\n#define R1(v,w,x,y,z,i) \\\n    z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=ror(w,2);\n#define R2(v,w,x,y,z,i) \\\n    z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=ror(w,2);\n#define R3(v,w,x,y,z,i) \\\n    z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=ror(w,2);\n#define R4(v,w,x,y,z,i) \\\n    z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=ror(w,2);\n\n/*\n * Hash a single 512-bit block. This is the core of the algorithm.\n */\nvoid SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){\n  unsigned int qq[5]; /* a, b, c, d, e; */\n  static int one = 1;\n  unsigned int block[16];\n  memcpy(block, buffer, 64);\n  memcpy(qq,state,5*sizeof(unsigned int));\n\n#define a qq[0]\n#define b qq[1]\n#define c qq[2]\n#define d qq[3]\n#define e qq[4]\n\n  /* Copy p->state[] to working vars */\n  /*\n  a = state[0];\n  b = state[1];\n  c = state[2];\n  d = state[3];\n  e = state[4];\n  */\n\n  /* 4 rounds of 20 operations each. Loop unrolled. */\n  if( 1 == *(unsigned char*)&one ){\n    Rl0(a,b,c,d,e, 0); Rl0(e,a,b,c,d, 1); Rl0(d,e,a,b,c, 2); Rl0(c,d,e,a,b, 3);\n    Rl0(b,c,d,e,a, 4); Rl0(a,b,c,d,e, 5); Rl0(e,a,b,c,d, 6); Rl0(d,e,a,b,c, 7);\n    Rl0(c,d,e,a,b, 8); Rl0(b,c,d,e,a, 9); Rl0(a,b,c,d,e,10); Rl0(e,a,b,c,d,11);\n    Rl0(d,e,a,b,c,12); Rl0(c,d,e,a,b,13); Rl0(b,c,d,e,a,14); Rl0(a,b,c,d,e,15);\n  }else{\n    Rb0(a,b,c,d,e, 0); Rb0(e,a,b,c,d, 1); Rb0(d,e,a,b,c, 2); Rb0(c,d,e,a,b, 3);\n    Rb0(b,c,d,e,a, 4); Rb0(a,b,c,d,e, 5); Rb0(e,a,b,c,d, 6); Rb0(d,e,a,b,c, 7);\n    Rb0(c,d,e,a,b, 8); Rb0(b,c,d,e,a, 9); Rb0(a,b,c,d,e,10); Rb0(e,a,b,c,d,11);\n    Rb0(d,e,a,b,c,12); Rb0(c,d,e,a,b,13); Rb0(b,c,d,e,a,14); Rb0(a,b,c,d,e,15);\n  }\n  R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);\n  R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);\n  R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);\n  R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);\n  R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);\n  R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);\n  R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);\n  R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);\n  R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);\n  R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);\n  R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);\n  R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);\n  R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);\n  R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);\n  R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);\n  R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);\n\n  /* Add the working vars back into context.state[] */\n  state[0] += a;\n  state[1] += b;\n  state[2] += c;\n  state[3] += d;\n  state[4] += e;\n\n#undef a\n#undef b\n#undef c\n#undef d\n#undef e\n}\n\n\n/* Initialize a SHA1 context */\nstatic void hash_init(SHA1Context *p){\n  /* SHA1 initialization constants */\n  p->state[0] = 0x67452301;\n  p->state[1] = 0xEFCDAB89;\n  p->state[2] = 0x98BADCFE;\n  p->state[3] = 0x10325476;\n  p->state[4] = 0xC3D2E1F0;\n  p->count[0] = p->count[1] = 0;\n}\n\n/* Add new content to the SHA1 hash */\nstatic void hash_step(\n  SHA1Context *p,                 /* Add content to this context */\n  const unsigned char *data,      /* Data to be added */\n  unsigned int len                /* Number of bytes in data */\n){\n  unsigned int i, j;\n\n  j = p->count[0];\n  if( (p->count[0] += len << 3) < j ){\n    p->count[1] += (len>>29)+1;\n  }\n  j = (j >> 3) & 63;\n  if( (j + len) > 63 ){\n    (void)memcpy(&p->buffer[j], data, (i = 64-j));\n    SHA1Transform(p->state, p->buffer);\n    for(; i + 63 < len; i += 64){\n      SHA1Transform(p->state, &data[i]);\n    }\n    j = 0;\n  }else{\n    i = 0;\n  }\n  (void)memcpy(&p->buffer[j], &data[i], len - i);\n}\n\n/* Compute a string using sqlite3_vsnprintf() and hash it */\nstatic void hash_step_vformat(\n  SHA1Context *p,                 /* Add content to this context */\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  int n;\n  char zBuf[50];\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap);\n  va_end(ap);\n  n = (int)strlen(zBuf);\n  hash_step(p, (unsigned char*)zBuf, n);\n}\n\n\n/* Add padding and compute the message digest.  Render the\n** message digest as lower-case hexadecimal and put it into\n** zOut[].  zOut[] must be at least 41 bytes long. */\nstatic void hash_finish(\n  SHA1Context *p,           /* The SHA1 context to finish and render */\n  char *zOut                /* Store hexadecimal hash here */\n){\n  unsigned int i;\n  unsigned char finalcount[8];\n  unsigned char digest[20];\n  static const char zEncode[] = \"0123456789abcdef\";\n\n  for (i = 0; i < 8; i++){\n    finalcount[i] = (unsigned char)((p->count[(i >= 4 ? 0 : 1)]\n       >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */\n  }\n  hash_step(p, (const unsigned char *)\"\\200\", 1);\n  while ((p->count[0] & 504) != 448){\n    hash_step(p, (const unsigned char *)\"\\0\", 1);\n  }\n  hash_step(p, finalcount, 8);  /* Should cause a SHA1Transform() */\n  for (i = 0; i < 20; i++){\n    digest[i] = (unsigned char)((p->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);\n  }\n  for(i=0; i<20; i++){\n    zOut[i*2] = zEncode[(digest[i]>>4)&0xf];\n    zOut[i*2+1] = zEncode[digest[i] & 0xf];\n  }\n  zOut[i*2]= 0;\n}\n/* End of the hashing logic\n*****************************************************************************/\n\n/*\n** Implementation of the sha1(X) function.\n**\n** Return a lower-case hexadecimal rendering of the SHA1 hash of the\n** argument X.  If X is a BLOB, it is hashed as is.  For all other\n** types of input, X is converted into a UTF-8 string and the string\n** is hash without the trailing 0x00 terminator.  The hash of a NULL\n** value is NULL.\n*/\nstatic void sha1Func(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  SHA1Context cx;\n  int eType = sqlite3_value_type(argv[0]);\n  int nByte = sqlite3_value_bytes(argv[0]);\n  char zOut[44];\n\n  assert( argc==1 );\n  if( eType==SQLITE_NULL ) return;\n  hash_init(&cx);\n  if( eType==SQLITE_BLOB ){\n    hash_step(&cx, sqlite3_value_blob(argv[0]), nByte);\n  }else{\n    hash_step(&cx, sqlite3_value_text(argv[0]), nByte);\n  }\n  hash_finish(&cx, zOut);\n  sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT);\n}\n\n/*\n** Implementation of the sha1_query(SQL) function.\n**\n** This function compiles and runs the SQL statement(s) given in the\n** argument. The results are hashed using SHA1 and that hash is returned.\n**\n** The original SQL text is included as part of the hash.\n**\n** The hash is not just a concatenation of the outputs.  Each query\n** is delimited and each row and value within the query is delimited,\n** with all values being marked with their datatypes.\n*/\nstatic void sha1QueryFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zSql = (const char*)sqlite3_value_text(argv[0]);\n  sqlite3_stmt *pStmt = 0;\n  int nCol;                   /* Number of columns in the result set */\n  int i;                      /* Loop counter */\n  int rc;\n  int n;\n  const char *z;\n  SHA1Context cx;\n  char zOut[44];\n\n  assert( argc==1 );\n  if( zSql==0 ) return;\n  hash_init(&cx);\n  while( zSql[0] ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql);\n    if( rc ){\n      char *zMsg = sqlite3_mprintf(\"error SQL statement [%s]: %s\",\n                                   zSql, sqlite3_errmsg(db));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    if( !sqlite3_stmt_readonly(pStmt) ){\n      char *zMsg = sqlite3_mprintf(\"non-query: [%s]\", sqlite3_sql(pStmt));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    z = sqlite3_sql(pStmt);\n    n = (int)strlen(z);\n    hash_step_vformat(&cx,\"S%d:\",n);\n    hash_step(&cx,(unsigned char*)z,n);\n\n    /* Compute a hash over the result of the query */\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      hash_step(&cx,(const unsigned char*)\"R\",1);\n      for(i=0; i<nCol; i++){\n        switch( sqlite3_column_type(pStmt,i) ){\n          case SQLITE_NULL: {\n            hash_step(&cx, (const unsigned char*)\"N\",1);\n            break;\n          }\n          case SQLITE_INTEGER: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            sqlite3_int64 v = sqlite3_column_int64(pStmt,i);\n            memcpy(&u, &v, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'I';\n            hash_step(&cx, x, 9);\n            break;\n          }\n          case SQLITE_FLOAT: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            double r = sqlite3_column_double(pStmt,i);\n            memcpy(&u, &r, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'F';\n            hash_step(&cx,x,9);\n            break;\n          }\n          case SQLITE_TEXT: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_text(pStmt, i);\n            hash_step_vformat(&cx,\"T%d:\",n2);\n            hash_step(&cx, z2, n2);\n            break;\n          }\n          case SQLITE_BLOB: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_blob(pStmt, i);\n            hash_step_vformat(&cx,\"B%d:\",n2);\n            hash_step(&cx, z2, n2);\n            break;\n          }\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }\n  hash_finish(&cx, zOut);\n  sqlite3_result_text(context, zOut, 40, SQLITE_TRANSIENT);\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_sha_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"sha1\", 1, SQLITE_UTF8, 0,\n                               sha1Func, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha1_query\", 1, SQLITE_UTF8, 0,\n                                 sha1QueryFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/shathree.c",
    "content": "/*\n** 2017-03-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements a functions that compute SHA1 hashes.\n** Two SQL functions are implemented:\n**\n**     sha3(X,SIZE)\n**     sha3_query(Y,SIZE)\n**\n** The sha3(X) function computes the SHA3 hash of the input X, or NULL if\n** X is NULL.\n**\n** The sha3_query(Y) function evalutes all queries in the SQL statements of Y\n** and returns a hash of their results.\n**\n** The SIZE argument is optional.  If omitted, the SHA3-256 hash algorithm\n** is used.  If SIZE is included it must be one of the integers 224, 256,\n** 384, or 512, to determine SHA3 hash variant that is computed.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <stdarg.h>\ntypedef sqlite3_uint64 u64;\n\n/******************************************************************************\n** The Hash Engine\n*/\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSHA3_BYTEORDER=0 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SHA3_BYTEORDER\n# if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n     defined(__arm__)\n#   define SHA3_BYTEORDER    1234\n# elif defined(sparc)    || defined(__ppc__)\n#   define SHA3_BYTEORDER    4321\n# else\n#   define SHA3_BYTEORDER 0\n# endif\n#endif\n\n\n/*\n** State structure for a SHA3 hash in progress\n*/\ntypedef struct SHA3Context SHA3Context;\nstruct SHA3Context {\n  union {\n    u64 s[25];                /* Keccak state. 5x5 lines of 64 bits each */\n    unsigned char x[1600];    /* ... or 1600 bytes */\n  } u;\n  unsigned nRate;        /* Bytes of input accepted per Keccak iteration */\n  unsigned nLoaded;      /* Input bytes loaded into u.x[] so far this cycle */\n  unsigned ixMask;       /* Insert next input into u.x[nLoaded^ixMask]. */\n};\n\n/*\n** A single step of the Keccak mixing function for a 1600-bit state\n*/\nstatic void KeccakF1600Step(SHA3Context *p){\n  int i;\n  u64 B0, B1, B2, B3, B4;\n  u64 C0, C1, C2, C3, C4;\n  u64 D0, D1, D2, D3, D4;\n  static const u64 RC[] = {\n    0x0000000000000001ULL,  0x0000000000008082ULL,\n    0x800000000000808aULL,  0x8000000080008000ULL,\n    0x000000000000808bULL,  0x0000000080000001ULL,\n    0x8000000080008081ULL,  0x8000000000008009ULL,\n    0x000000000000008aULL,  0x0000000000000088ULL,\n    0x0000000080008009ULL,  0x000000008000000aULL,\n    0x000000008000808bULL,  0x800000000000008bULL,\n    0x8000000000008089ULL,  0x8000000000008003ULL,\n    0x8000000000008002ULL,  0x8000000000000080ULL,\n    0x000000000000800aULL,  0x800000008000000aULL,\n    0x8000000080008081ULL,  0x8000000000008080ULL,\n    0x0000000080000001ULL,  0x8000000080008008ULL\n  };\n# define A00 (p->u.s[0])\n# define A01 (p->u.s[1])\n# define A02 (p->u.s[2])\n# define A03 (p->u.s[3])\n# define A04 (p->u.s[4])\n# define A10 (p->u.s[5])\n# define A11 (p->u.s[6])\n# define A12 (p->u.s[7])\n# define A13 (p->u.s[8])\n# define A14 (p->u.s[9])\n# define A20 (p->u.s[10])\n# define A21 (p->u.s[11])\n# define A22 (p->u.s[12])\n# define A23 (p->u.s[13])\n# define A24 (p->u.s[14])\n# define A30 (p->u.s[15])\n# define A31 (p->u.s[16])\n# define A32 (p->u.s[17])\n# define A33 (p->u.s[18])\n# define A34 (p->u.s[19])\n# define A40 (p->u.s[20])\n# define A41 (p->u.s[21])\n# define A42 (p->u.s[22])\n# define A43 (p->u.s[23])\n# define A44 (p->u.s[24])\n# define ROL64(a,x) ((a<<x)|(a>>(64-x)))\n\n  for(i=0; i<24; i+=4){\n    C0 = A00^A10^A20^A30^A40;\n    C1 = A01^A11^A21^A31^A41;\n    C2 = A02^A12^A22^A32^A42;\n    C3 = A03^A13^A23^A33^A43;\n    C4 = A04^A14^A24^A34^A44;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A11^D1), 44);\n    B2 = ROL64((A22^D2), 43);\n    B3 = ROL64((A33^D3), 21);\n    B4 = ROL64((A44^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i];\n    A11 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A20^D0), 3);\n    B3 = ROL64((A31^D1), 45);\n    B4 = ROL64((A42^D2), 61);\n    B0 = ROL64((A03^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A20 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A40^D0), 18);\n    B0 = ROL64((A01^D1), 1);\n    B1 = ROL64((A12^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A34^D4), 8);\n    A40 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A10^D0), 36);\n    B2 = ROL64((A21^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A43^D3), 56);\n    B0 = ROL64((A04^D4), 27);\n    A10 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A30^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A02^D2), 62);\n    B1 = ROL64((A13^D3), 55);\n    B2 = ROL64((A24^D4), 39);\n    A30 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A20^A40^A10^A30;\n    C1 = A11^A31^A01^A21^A41;\n    C2 = A22^A42^A12^A32^A02;\n    C3 = A33^A03^A23^A43^A13;\n    C4 = A44^A14^A34^A04^A24;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A31^D1), 44);\n    B2 = ROL64((A12^D2), 43);\n    B3 = ROL64((A43^D3), 21);\n    B4 = ROL64((A24^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+1];\n    A31 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A40^D0), 3);\n    B3 = ROL64((A21^D1), 45);\n    B4 = ROL64((A02^D2), 61);\n    B0 = ROL64((A33^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A40 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A30^D0), 18);\n    B0 = ROL64((A11^D1), 1);\n    B1 = ROL64((A42^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A04^D4), 8);\n    A30 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A20^D0), 36);\n    B2 = ROL64((A01^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A13^D3), 56);\n    B0 = ROL64((A44^D4), 27);\n    A20 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A10^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A22^D2), 62);\n    B1 = ROL64((A03^D3), 55);\n    B2 = ROL64((A34^D4), 39);\n    A10 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A40^A30^A20^A10;\n    C1 = A31^A21^A11^A01^A41;\n    C2 = A12^A02^A42^A32^A22;\n    C3 = A43^A33^A23^A13^A03;\n    C4 = A24^A14^A04^A44^A34;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A21^D1), 44);\n    B2 = ROL64((A42^D2), 43);\n    B3 = ROL64((A13^D3), 21);\n    B4 = ROL64((A34^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+2];\n    A21 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A30^D0), 3);\n    B3 = ROL64((A01^D1), 45);\n    B4 = ROL64((A22^D2), 61);\n    B0 = ROL64((A43^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A30 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A10^D0), 18);\n    B0 = ROL64((A31^D1), 1);\n    B1 = ROL64((A02^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A44^D4), 8);\n    A10 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A40^D0), 36);\n    B2 = ROL64((A11^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A03^D3), 56);\n    B0 = ROL64((A24^D4), 27);\n    A40 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A20^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A12^D2), 62);\n    B1 = ROL64((A33^D3), 55);\n    B2 = ROL64((A04^D4), 39);\n    A20 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A30^A10^A40^A20;\n    C1 = A21^A01^A31^A11^A41;\n    C2 = A42^A22^A02^A32^A12;\n    C3 = A13^A43^A23^A03^A33;\n    C4 = A34^A14^A44^A24^A04;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A01^D1), 44);\n    B2 = ROL64((A02^D2), 43);\n    B3 = ROL64((A03^D3), 21);\n    B4 = ROL64((A04^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+3];\n    A01 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A10^D0), 3);\n    B3 = ROL64((A11^D1), 45);\n    B4 = ROL64((A12^D2), 61);\n    B0 = ROL64((A13^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A10 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A20^D0), 18);\n    B0 = ROL64((A21^D1), 1);\n    B1 = ROL64((A22^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A24^D4), 8);\n    A20 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A30^D0), 36);\n    B2 = ROL64((A31^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A33^D3), 56);\n    B0 = ROL64((A34^D4), 27);\n    A30 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A40^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A42^D2), 62);\n    B1 = ROL64((A43^D3), 55);\n    B2 = ROL64((A44^D4), 39);\n    A40 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n  }\n}\n\n/*\n** Initialize a new hash.  iSize determines the size of the hash\n** in bits and should be one of 224, 256, 384, or 512.  Or iSize\n** can be zero to use the default hash size of 256 bits.\n*/\nstatic void SHA3Init(SHA3Context *p, int iSize){\n  memset(p, 0, sizeof(*p));\n  if( iSize>=128 && iSize<=512 ){\n    p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;\n  }else{\n    p->nRate = (1600 - 2*256)/8;\n  }\n#if SHA3_BYTEORDER==1234\n  /* Known to be little-endian at compile-time. No-op */\n#elif SHA3_BYTEORDER==4321\n  p->ixMask = 7;  /* Big-endian */\n#else\n  {\n    static unsigned int one = 1;\n    if( 1==*(unsigned char*)&one ){\n      /* Little endian.  No byte swapping. */\n      p->ixMask = 0;\n    }else{\n      /* Big endian.  Byte swap. */\n      p->ixMask = 7;\n    }\n  }\n#endif\n}\n\n/*\n** Make consecutive calls to the SHA3Update function to add new content\n** to the hash\n*/\nstatic void SHA3Update(\n  SHA3Context *p,\n  const unsigned char *aData,\n  unsigned int nData\n){\n  unsigned int i = 0;\n#if SHA3_BYTEORDER==1234\n  if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){\n    for(; i+7<nData; i+=8){\n      p->u.s[p->nLoaded/8] ^= *(u64*)&aData[i];\n      p->nLoaded += 8;\n      if( p->nLoaded>=p->nRate ){\n        KeccakF1600Step(p);\n        p->nLoaded = 0;\n      }\n    }\n  }\n#endif\n  for(; i<nData; i++){\n#if SHA3_BYTEORDER==1234\n    p->u.x[p->nLoaded] ^= aData[i];\n#elif SHA3_BYTEORDER==4321\n    p->u.x[p->nLoaded^0x07] ^= aData[i];\n#else\n    p->u.x[p->nLoaded^p->ixMask] ^= aData[i];\n#endif\n    p->nLoaded++;\n    if( p->nLoaded==p->nRate ){\n      KeccakF1600Step(p);\n      p->nLoaded = 0;\n    }\n  }\n}\n\n/*\n** After all content has been added, invoke SHA3Final() to compute\n** the final hash.  The function returns a pointer to the binary\n** hash value.\n*/\nstatic unsigned char *SHA3Final(SHA3Context *p){\n  unsigned int i;\n  if( p->nLoaded==p->nRate-1 ){\n    const unsigned char c1 = 0x86;\n    SHA3Update(p, &c1, 1);\n  }else{\n    const unsigned char c2 = 0x06;\n    const unsigned char c3 = 0x80;\n    SHA3Update(p, &c2, 1);\n    p->nLoaded = p->nRate - 1;\n    SHA3Update(p, &c3, 1);\n  }\n  for(i=0; i<p->nRate; i++){\n    p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];\n  }\n  return &p->u.x[p->nRate];\n}\n/* End of the hashing logic\n*****************************************************************************/\n\n/*\n** Implementation of the sha3(X,SIZE) function.\n**\n** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default\n** size is 256.  If X is a BLOB, it is hashed as is.  \n** For all other non-NULL types of input, X is converted into a UTF-8 string\n** and the string is hashed without the trailing 0x00 terminator.  The hash\n** of a NULL value is NULL.\n*/\nstatic void sha3Func(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  SHA3Context cx;\n  int eType = sqlite3_value_type(argv[0]);\n  int nByte = sqlite3_value_bytes(argv[0]);\n  int iSize;\n  if( argc==1 ){\n    iSize = 256;\n  }else{\n    iSize = sqlite3_value_int(argv[1]);\n    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){\n      sqlite3_result_error(context, \"SHA3 size should be one of: 224 256 \"\n                                    \"384 512\", -1);\n      return;\n    }\n  }\n  if( eType==SQLITE_NULL ) return;\n  SHA3Init(&cx, iSize);\n  if( eType==SQLITE_BLOB ){\n    SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte);\n  }else{\n    SHA3Update(&cx, sqlite3_value_text(argv[0]), nByte);\n  }\n  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);\n}\n\n/* Compute a string using sqlite3_vsnprintf() with a maximum length\n** of 50 bytes and add it to the hash.\n*/\nstatic void hash_step_vformat(\n  SHA3Context *p,                 /* Add content to this context */\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  int n;\n  char zBuf[50];\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap);\n  va_end(ap);\n  n = (int)strlen(zBuf);\n  SHA3Update(p, (unsigned char*)zBuf, n);\n}\n\n/*\n** Implementation of the sha3_query(SQL,SIZE) function.\n**\n** This function compiles and runs the SQL statement(s) given in the\n** argument. The results are hashed using a SIZE-bit SHA3.  The default\n** size is 256.\n**\n** The format of the byte stream that is hashed is summarized as follows:\n**\n**       S<n>:<sql>\n**       R\n**       N\n**       I<int>\n**       F<ieee-float>\n**       B<size>:<bytes>\n**       T<size>:<text>\n**\n** <sql> is the original SQL text for each statement run and <n> is\n** the size of that text.  The SQL text is UTF-8.  A single R character\n** occurs before the start of each row.  N means a NULL value.\n** I mean an 8-byte little-endian integer <int>.  F is a floating point\n** number with an 8-byte little-endian IEEE floating point value <ieee-float>.\n** B means blobs of <size> bytes.  T means text rendered as <size>\n** bytes of UTF-8.  The <n> and <size> values are expressed as an ASCII\n** text integers.\n**\n** For each SQL statement in the X input, there is one S segment.  Each\n** S segment is followed by zero or more R segments, one for each row in the\n** result set.  After each R, there are one or more N, I, F, B, or T segments,\n** one for each column in the result set.  Segments are concatentated directly\n** with no delimiters of any kind.\n*/\nstatic void sha3QueryFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zSql = (const char*)sqlite3_value_text(argv[0]);\n  sqlite3_stmt *pStmt = 0;\n  int nCol;                   /* Number of columns in the result set */\n  int i;                      /* Loop counter */\n  int rc;\n  int n;\n  const char *z;\n  SHA3Context cx;\n  int iSize;\n\n  if( argc==1 ){\n    iSize = 256;\n  }else{\n    iSize = sqlite3_value_int(argv[1]);\n    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){\n      sqlite3_result_error(context, \"SHA3 size should be one of: 224 256 \"\n                                    \"384 512\", -1);\n      return;\n    }\n  }\n  if( zSql==0 ) return;\n  SHA3Init(&cx, iSize);\n  while( zSql[0] ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql);\n    if( rc ){\n      char *zMsg = sqlite3_mprintf(\"error SQL statement [%s]: %s\",\n                                   zSql, sqlite3_errmsg(db));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    if( !sqlite3_stmt_readonly(pStmt) ){\n      char *zMsg = sqlite3_mprintf(\"non-query: [%s]\", sqlite3_sql(pStmt));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    z = sqlite3_sql(pStmt);\n    n = (int)strlen(z);\n    hash_step_vformat(&cx,\"S%d:\",n);\n    SHA3Update(&cx,(unsigned char*)z,n);\n\n    /* Compute a hash over the result of the query */\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      SHA3Update(&cx,(const unsigned char*)\"R\",1);\n      for(i=0; i<nCol; i++){\n        switch( sqlite3_column_type(pStmt,i) ){\n          case SQLITE_NULL: {\n            SHA3Update(&cx, (const unsigned char*)\"N\",1);\n            break;\n          }\n          case SQLITE_INTEGER: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            sqlite3_int64 v = sqlite3_column_int64(pStmt,i);\n            memcpy(&u, &v, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'I';\n            SHA3Update(&cx, x, 9);\n            break;\n          }\n          case SQLITE_FLOAT: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            double r = sqlite3_column_double(pStmt,i);\n            memcpy(&u, &r, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'F';\n            SHA3Update(&cx,x,9);\n            break;\n          }\n          case SQLITE_TEXT: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_text(pStmt, i);\n            hash_step_vformat(&cx,\"T%d:\",n2);\n            SHA3Update(&cx, z2, n2);\n            break;\n          }\n          case SQLITE_BLOB: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_blob(pStmt, i);\n            hash_step_vformat(&cx,\"B%d:\",n2);\n            SHA3Update(&cx, z2, n2);\n            break;\n          }\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }\n  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);\n}\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_shathree_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"sha3\", 1, SQLITE_UTF8, 0,\n                               sha3Func, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3\", 2, SQLITE_UTF8, 0,\n                                 sha3Func, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3_query\", 1, SQLITE_UTF8, 0,\n                                 sha3QueryFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3_query\", 2, SQLITE_UTF8, 0,\n                                 sha3QueryFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/showauth.c",
    "content": "/*\n** 2014-09-21\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension adds a debug \"authorizer\" callback to the database\n** connection.  The callback merely writes the authorization request to\n** standard output and returns SQLITE_OK.\n**\n** This extension can be used (for example) in the command-line shell to\n** trace the operation of the authorizer.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <stdio.h>\n\n/*\n** Display the authorization request\n*/\nstatic int authCallback(\n  void *pClientData,\n  int op,\n  const char *z1,\n  const char *z2,\n  const char *z3,\n  const char *z4\n){\n  const char *zOp;\n  char zOpSpace[50];\n  switch( op ){\n    case SQLITE_CREATE_INDEX:        zOp = \"CREATE_INDEX\";        break;\n    case SQLITE_CREATE_TABLE:        zOp = \"CREATE_TABLE\";        break;\n    case SQLITE_CREATE_TEMP_INDEX:   zOp = \"CREATE_TEMP_INDEX\";   break;\n    case SQLITE_CREATE_TEMP_TABLE:   zOp = \"CREATE_TEMP_TABLE\";   break;\n    case SQLITE_CREATE_TEMP_TRIGGER: zOp = \"CREATE_TEMP_TRIGGER\"; break;\n    case SQLITE_CREATE_TEMP_VIEW:    zOp = \"CREATE_TEMP_VIEW\";    break;\n    case SQLITE_CREATE_TRIGGER:      zOp = \"CREATE_TRIGGER\";      break;\n    case SQLITE_CREATE_VIEW:         zOp = \"CREATE_VIEW\";         break;\n    case SQLITE_DELETE:              zOp = \"DELETE\";              break;\n    case SQLITE_DROP_INDEX:          zOp = \"DROP_INDEX\";          break;\n    case SQLITE_DROP_TABLE:          zOp = \"DROP_TABLE\";          break;\n    case SQLITE_DROP_TEMP_INDEX:     zOp = \"DROP_TEMP_INDEX\";     break;\n    case SQLITE_DROP_TEMP_TABLE:     zOp = \"DROP_TEMP_TABLE\";     break;\n    case SQLITE_DROP_TEMP_TRIGGER:   zOp = \"DROP_TEMP_TRIGGER\";   break;\n    case SQLITE_DROP_TEMP_VIEW:      zOp = \"DROP_TEMP_VIEW\";      break;\n    case SQLITE_DROP_TRIGGER:        zOp = \"DROP_TRIGGER\";        break;\n    case SQLITE_DROP_VIEW:           zOp = \"DROP_VIEW\";           break;\n    case SQLITE_INSERT:              zOp = \"INSERT\";              break;\n    case SQLITE_PRAGMA:              zOp = \"PRAGMA\";              break;\n    case SQLITE_READ:                zOp = \"READ\";                break;\n    case SQLITE_SELECT:              zOp = \"SELECT\";              break;\n    case SQLITE_TRANSACTION:         zOp = \"TRANSACTION\";         break;\n    case SQLITE_UPDATE:              zOp = \"UPDATE\";              break;\n    case SQLITE_ATTACH:              zOp = \"ATTACH\";              break;\n    case SQLITE_DETACH:              zOp = \"DETACH\";              break;\n    case SQLITE_ALTER_TABLE:         zOp = \"ALTER_TABLE\";         break;\n    case SQLITE_REINDEX:             zOp = \"REINDEX\";             break;\n    case SQLITE_ANALYZE:             zOp = \"ANALYZE\";             break;\n    case SQLITE_CREATE_VTABLE:       zOp = \"CREATE_VTABLE\";       break;\n    case SQLITE_DROP_VTABLE:         zOp = \"DROP_VTABLE\";         break;\n    case SQLITE_FUNCTION:            zOp = \"FUNCTION\";            break;\n    case SQLITE_SAVEPOINT:           zOp = \"SAVEPOINT\";           break;\n    case SQLITE_COPY:                zOp = \"COPY\";                break;\n    case SQLITE_RECURSIVE:           zOp = \"RECURSIVE\";           break;\n\n\n    default: {\n      sqlite3_snprintf(sizeof(zOpSpace), zOpSpace, \"%d\", op);\n      zOp = zOpSpace;\n      break;\n    }\n  }\n  if( z1==0 ) z1 = \"NULL\";\n  if( z2==0 ) z2 = \"NULL\";\n  if( z3==0 ) z3 = \"NULL\";\n  if( z4==0 ) z4 = \"NULL\";\n  printf(\"AUTH: %s,%s,%s,%s,%s\\n\", zOp, z1, z2, z3, z4);\n  return SQLITE_OK;\n}\n\n\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_showauth_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_set_authorizer(db, authCallback, 0);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/spellfix.c",
    "content": "/*\n** 2012 April 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements the spellfix1 VIRTUAL TABLE that can be used\n** to search a large vocabulary for close matches.  See separate\n** documentation (http://www.sqlite.org/spellfix1.html) for details.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n#ifndef SQLITE_AMALGAMATION\n# include <string.h>\n# include <stdio.h>\n# include <stdlib.h>\n# include <assert.h>\n# define ALWAYS(X)  1\n# define NEVER(X)   0\n  typedef unsigned char u8;\n  typedef unsigned short u16;\n#endif\n#include <ctype.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Character classes for ASCII characters:\n**\n**   0   ''        Silent letters:   H W\n**   1   'A'       Any vowel:   A E I O U (Y)\n**   2   'B'       A bilabeal stop or fricative:  B F P V W\n**   3   'C'       Other fricatives or back stops:  C G J K Q S X Z\n**   4   'D'       Alveolar stops:  D T\n**   5   'H'       Letter H at the beginning of a word\n**   6   'L'       Glide:  L\n**   7   'R'       Semivowel:  R\n**   8   'M'       Nasals:  M N\n**   9   'Y'       Letter Y at the beginning of a word.\n**   10  '9'       Digits: 0 1 2 3 4 5 6 7 8 9\n**   11  ' '       White space\n**   12  '?'       Other.\n*/\n#define CCLASS_SILENT         0\n#define CCLASS_VOWEL          1\n#define CCLASS_B              2\n#define CCLASS_C              3\n#define CCLASS_D              4\n#define CCLASS_H              5\n#define CCLASS_L              6\n#define CCLASS_R              7\n#define CCLASS_M              8\n#define CCLASS_Y              9\n#define CCLASS_DIGIT         10\n#define CCLASS_SPACE         11\n#define CCLASS_OTHER         12\n\n/*\n** The following table gives the character class for non-initial ASCII\n** characters.\n*/\nstatic const unsigned char midClass[] = {\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_SPACE,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_SPACE,    /*   */ CCLASS_SPACE,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_SPACE,\n /* ! */ CCLASS_OTHER,    /* \" */ CCLASS_OTHER,   /* # */ CCLASS_OTHER,\n /* $ */ CCLASS_OTHER,    /* % */ CCLASS_OTHER,   /* & */ CCLASS_OTHER,\n /* ' */ CCLASS_SILENT,   /* ( */ CCLASS_OTHER,   /* ) */ CCLASS_OTHER,\n /* * */ CCLASS_OTHER,    /* + */ CCLASS_OTHER,   /* , */ CCLASS_OTHER,\n /* - */ CCLASS_OTHER,    /* . */ CCLASS_OTHER,   /* / */ CCLASS_OTHER,\n /* 0 */ CCLASS_DIGIT,    /* 1 */ CCLASS_DIGIT,   /* 2 */ CCLASS_DIGIT,\n /* 3 */ CCLASS_DIGIT,    /* 4 */ CCLASS_DIGIT,   /* 5 */ CCLASS_DIGIT,\n /* 6 */ CCLASS_DIGIT,    /* 7 */ CCLASS_DIGIT,   /* 8 */ CCLASS_DIGIT,\n /* 9 */ CCLASS_DIGIT,    /* : */ CCLASS_OTHER,   /* ; */ CCLASS_OTHER,\n /* < */ CCLASS_OTHER,    /* = */ CCLASS_OTHER,   /* > */ CCLASS_OTHER,\n /* ? */ CCLASS_OTHER,    /* @ */ CCLASS_OTHER,   /* A */ CCLASS_VOWEL,\n /* B */ CCLASS_B,        /* C */ CCLASS_C,       /* D */ CCLASS_D,\n /* E */ CCLASS_VOWEL,    /* F */ CCLASS_B,       /* G */ CCLASS_C,\n /* H */ CCLASS_SILENT,   /* I */ CCLASS_VOWEL,   /* J */ CCLASS_C,\n /* K */ CCLASS_C,        /* L */ CCLASS_L,       /* M */ CCLASS_M,\n /* N */ CCLASS_M,        /* O */ CCLASS_VOWEL,   /* P */ CCLASS_B,\n /* Q */ CCLASS_C,        /* R */ CCLASS_R,       /* S */ CCLASS_C,\n /* T */ CCLASS_D,        /* U */ CCLASS_VOWEL,   /* V */ CCLASS_B,\n /* W */ CCLASS_B,        /* X */ CCLASS_C,       /* Y */ CCLASS_VOWEL,\n /* Z */ CCLASS_C,        /* [ */ CCLASS_OTHER,   /* \\ */ CCLASS_OTHER,\n /* ] */ CCLASS_OTHER,    /* ^ */ CCLASS_OTHER,   /* _ */ CCLASS_OTHER,\n /* ` */ CCLASS_OTHER,    /* a */ CCLASS_VOWEL,   /* b */ CCLASS_B,\n /* c */ CCLASS_C,        /* d */ CCLASS_D,       /* e */ CCLASS_VOWEL,\n /* f */ CCLASS_B,        /* g */ CCLASS_C,       /* h */ CCLASS_SILENT,\n /* i */ CCLASS_VOWEL,    /* j */ CCLASS_C,       /* k */ CCLASS_C,\n /* l */ CCLASS_L,        /* m */ CCLASS_M,       /* n */ CCLASS_M,\n /* o */ CCLASS_VOWEL,    /* p */ CCLASS_B,       /* q */ CCLASS_C,\n /* r */ CCLASS_R,        /* s */ CCLASS_C,       /* t */ CCLASS_D,\n /* u */ CCLASS_VOWEL,    /* v */ CCLASS_B,       /* w */ CCLASS_B,\n /* x */ CCLASS_C,        /* y */ CCLASS_VOWEL,   /* z */ CCLASS_C,\n /* { */ CCLASS_OTHER,    /* | */ CCLASS_OTHER,   /* } */ CCLASS_OTHER,\n /* ~ */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   \n};\n/* \n** This tables gives the character class for ASCII characters that form the\n** initial character of a word.  The only difference from midClass is with\n** the letters H, W, and Y.\n*/\nstatic const unsigned char initClass[] = {\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_SPACE,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_SPACE,    /*   */ CCLASS_SPACE,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_OTHER,\n /*   */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   /*   */ CCLASS_SPACE,\n /* ! */ CCLASS_OTHER,    /* \" */ CCLASS_OTHER,   /* # */ CCLASS_OTHER,\n /* $ */ CCLASS_OTHER,    /* % */ CCLASS_OTHER,   /* & */ CCLASS_OTHER,\n /* ' */ CCLASS_OTHER,    /* ( */ CCLASS_OTHER,   /* ) */ CCLASS_OTHER,\n /* * */ CCLASS_OTHER,    /* + */ CCLASS_OTHER,   /* , */ CCLASS_OTHER,\n /* - */ CCLASS_OTHER,    /* . */ CCLASS_OTHER,   /* / */ CCLASS_OTHER,\n /* 0 */ CCLASS_DIGIT,    /* 1 */ CCLASS_DIGIT,   /* 2 */ CCLASS_DIGIT,\n /* 3 */ CCLASS_DIGIT,    /* 4 */ CCLASS_DIGIT,   /* 5 */ CCLASS_DIGIT,\n /* 6 */ CCLASS_DIGIT,    /* 7 */ CCLASS_DIGIT,   /* 8 */ CCLASS_DIGIT,\n /* 9 */ CCLASS_DIGIT,    /* : */ CCLASS_OTHER,   /* ; */ CCLASS_OTHER,\n /* < */ CCLASS_OTHER,    /* = */ CCLASS_OTHER,   /* > */ CCLASS_OTHER,\n /* ? */ CCLASS_OTHER,    /* @ */ CCLASS_OTHER,   /* A */ CCLASS_VOWEL,\n /* B */ CCLASS_B,        /* C */ CCLASS_C,       /* D */ CCLASS_D,\n /* E */ CCLASS_VOWEL,    /* F */ CCLASS_B,       /* G */ CCLASS_C,\n /* H */ CCLASS_SILENT,   /* I */ CCLASS_VOWEL,   /* J */ CCLASS_C,\n /* K */ CCLASS_C,        /* L */ CCLASS_L,       /* M */ CCLASS_M,\n /* N */ CCLASS_M,        /* O */ CCLASS_VOWEL,   /* P */ CCLASS_B,\n /* Q */ CCLASS_C,        /* R */ CCLASS_R,       /* S */ CCLASS_C,\n /* T */ CCLASS_D,        /* U */ CCLASS_VOWEL,   /* V */ CCLASS_B,\n /* W */ CCLASS_B,        /* X */ CCLASS_C,       /* Y */ CCLASS_Y,\n /* Z */ CCLASS_C,        /* [ */ CCLASS_OTHER,   /* \\ */ CCLASS_OTHER,\n /* ] */ CCLASS_OTHER,    /* ^ */ CCLASS_OTHER,   /* _ */ CCLASS_OTHER,\n /* ` */ CCLASS_OTHER,    /* a */ CCLASS_VOWEL,   /* b */ CCLASS_B,\n /* c */ CCLASS_C,        /* d */ CCLASS_D,       /* e */ CCLASS_VOWEL,\n /* f */ CCLASS_B,        /* g */ CCLASS_C,       /* h */ CCLASS_SILENT,\n /* i */ CCLASS_VOWEL,    /* j */ CCLASS_C,       /* k */ CCLASS_C,\n /* l */ CCLASS_L,        /* m */ CCLASS_M,       /* n */ CCLASS_M,\n /* o */ CCLASS_VOWEL,    /* p */ CCLASS_B,       /* q */ CCLASS_C,\n /* r */ CCLASS_R,        /* s */ CCLASS_C,       /* t */ CCLASS_D,\n /* u */ CCLASS_VOWEL,    /* v */ CCLASS_B,       /* w */ CCLASS_B,\n /* x */ CCLASS_C,        /* y */ CCLASS_Y,       /* z */ CCLASS_C,\n /* { */ CCLASS_OTHER,    /* | */ CCLASS_OTHER,   /* } */ CCLASS_OTHER,\n /* ~ */ CCLASS_OTHER,    /*   */ CCLASS_OTHER,   \n};\n\n/*\n** Mapping from the character class number (0-13) to a symbol for each\n** character class.  Note that initClass[] can be used to map the class\n** symbol back into the class number.\n*/\nstatic const unsigned char className[] = \".ABCDHLRMY9 ?\";\n\n/*\n** Generate a \"phonetic hash\" from a string of ASCII characters\n** in zIn[0..nIn-1].\n**\n**   * Map characters by character class as defined above.\n**   * Omit double-letters\n**   * Omit vowels beside R and L\n**   * Omit T when followed by CH\n**   * Omit W when followed by R\n**   * Omit D when followed by J or G\n**   * Omit K in KN or G in GN at the beginning of a word\n**\n** Space to hold the result is obtained from sqlite3_malloc()\n**\n** Return NULL if memory allocation fails.  \n*/\nstatic unsigned char *phoneticHash(const unsigned char *zIn, int nIn){\n  unsigned char *zOut = sqlite3_malloc64( nIn + 1 );\n  int i;\n  int nOut = 0;\n  char cPrev = 0x77;\n  char cPrevX = 0x77;\n  const unsigned char *aClass = initClass;\n\n  if( zOut==0 ) return 0;\n  if( nIn>2 ){\n    switch( zIn[0] ){\n      case 'g': \n      case 'k': {\n        if( zIn[1]=='n' ){ zIn++; nIn--; }\n        break;\n      }\n    }\n  }\n  for(i=0; i<nIn; i++){\n    unsigned char c = zIn[i];\n    if( i+1<nIn ){\n      if( c=='w' && zIn[i+1]=='r' ) continue;\n      if( c=='d' && (zIn[i+1]=='j' || zIn[i+1]=='g') ) continue;\n      if( i+2<nIn ){\n        if( c=='t' && zIn[i+1]=='c' && zIn[i+2]=='h' ) continue;\n      }\n    }\n    c = aClass[c&0x7f];\n    if( c==CCLASS_SPACE ) continue;\n    if( c==CCLASS_OTHER && cPrev!=CCLASS_DIGIT ) continue;\n    aClass = midClass;\n    if( c==CCLASS_VOWEL && (cPrevX==CCLASS_R || cPrevX==CCLASS_L) ){\n       continue; /* No vowels beside L or R */ \n    }\n    if( (c==CCLASS_R || c==CCLASS_L) && cPrevX==CCLASS_VOWEL ){\n       nOut--;   /* No vowels beside L or R */\n    }\n    cPrev = c;\n    if( c==CCLASS_SILENT ) continue;\n    cPrevX = c;\n    c = className[c];\n    assert( nOut>=0 );\n    if( nOut==0 || c!=zOut[nOut-1] ) zOut[nOut++] = c;\n  }\n  zOut[nOut] = 0;\n  return zOut;\n}\n\n/*\n** This is an SQL function wrapper around phoneticHash().  See\n** the description of phoneticHash() for additional information.\n*/\nstatic void phoneticHashSqlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;\n  unsigned char *zOut;\n\n  zIn = sqlite3_value_text(argv[0]);\n  if( zIn==0 ) return;\n  zOut = phoneticHash(zIn, sqlite3_value_bytes(argv[0]));\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free);\n  }\n}\n\n/*\n** Return the character class number for a character given its\n** context.\n*/\nstatic char characterClass(char cPrev, char c){\n  return cPrev==0 ? initClass[c&0x7f] : midClass[c&0x7f];\n}\n\n/*\n** Return the cost of inserting or deleting character c immediately\n** following character cPrev.  If cPrev==0, that means c is the first\n** character of the word.\n*/\nstatic int insertOrDeleteCost(char cPrev, char c, char cNext){\n  char classC = characterClass(cPrev, c);\n  char classCprev;\n\n  if( classC==CCLASS_SILENT ){\n    /* Insert or delete \"silent\" characters such as H or W */\n    return 1;\n  }\n  if( cPrev==c ){\n    /* Repeated characters, or miss a repeat */\n    return 10;\n  }\n  if( classC==CCLASS_VOWEL && (cPrev=='r' || cNext=='r') ){\n    return 20;  /* Insert a vowel before or after 'r' */\n  }\n  classCprev = characterClass(cPrev, cPrev);\n  if( classC==classCprev ){\n    if( classC==CCLASS_VOWEL ){\n      /* Remove or add a new vowel to a vowel cluster */\n      return 15;\n    }else{\n      /* Remove or add a consonant not in the same class */\n      return 50;\n    }\n  }\n\n  /* any other character insertion or deletion */\n  return 100;\n}\n\n/*\n** Divide the insertion cost by this factor when appending to the\n** end of the word.\n*/\n#define FINAL_INS_COST_DIV  4\n\n/*\n** Return the cost of substituting cTo in place of cFrom assuming\n** the previous character is cPrev.  If cPrev==0 then cTo is the first\n** character of the word.\n*/\nstatic int substituteCost(char cPrev, char cFrom, char cTo){\n  char classFrom, classTo;\n  if( cFrom==cTo ){\n    /* Exact match */\n    return 0;\n  }\n  if( cFrom==(cTo^0x20) && ((cTo>='A' && cTo<='Z') || (cTo>='a' && cTo<='z')) ){\n    /* differ only in case */\n    return 0;\n  }\n  classFrom = characterClass(cPrev, cFrom);\n  classTo = characterClass(cPrev, cTo);\n  if( classFrom==classTo ){\n    /* Same character class */\n    return 40;\n  }\n  if( classFrom>=CCLASS_B && classFrom<=CCLASS_Y\n      && classTo>=CCLASS_B && classTo<=CCLASS_Y ){\n    /* Convert from one consonant to another, but in a different class */\n    return 75;\n  }\n  /* Any other subsitution */\n  return 100;\n}\n\n/*\n** Given two strings zA and zB which are pure ASCII, return the cost\n** of transforming zA into zB.  If zA ends with '*' assume that it is\n** a prefix of zB and give only minimal penalty for extra characters\n** on the end of zB.\n**\n** Smaller numbers mean a closer match.\n**\n** Negative values indicate an error:\n**    -1  One of the inputs is NULL\n**    -2  Non-ASCII characters on input\n**    -3  Unable to allocate memory \n**\n** If pnMatch is not NULL, then *pnMatch is set to the number of bytes\n** of zB that matched the pattern in zA. If zA does not end with a '*',\n** then this value is always the number of bytes in zB (i.e. strlen(zB)).\n** If zA does end in a '*', then it is the number of bytes in the prefix\n** of zB that was deemed to match zA.\n*/\nstatic int editdist1(const char *zA, const char *zB, int *pnMatch){\n  int nA, nB;            /* Number of characters in zA[] and zB[] */\n  int xA, xB;            /* Loop counters for zA[] and zB[] */\n  char cA = 0, cB;       /* Current character of zA and zB */\n  char cAprev, cBprev;   /* Previous character of zA and zB */\n  char cAnext, cBnext;   /* Next character in zA and zB */\n  int d;                 /* North-west cost value */\n  int dc = 0;            /* North-west character value */\n  int res;               /* Final result */\n  int *m;                /* The cost matrix */\n  char *cx;              /* Corresponding character values */\n  int *toFree = 0;       /* Malloced space */\n  int nMatch = 0;\n  int mStack[60+15];     /* Stack space to use if not too much is needed */\n\n  /* Early out if either input is NULL */\n  if( zA==0 || zB==0 ) return -1;\n\n  /* Skip any common prefix */\n  while( zA[0] && zA[0]==zB[0] ){ dc = zA[0]; zA++; zB++; nMatch++; }\n  if( pnMatch ) *pnMatch = nMatch;\n  if( zA[0]==0 && zB[0]==0 ) return 0;\n\n#if 0\n  printf(\"A=\\\"%s\\\" B=\\\"%s\\\" dc=%c\\n\", zA, zB, dc?dc:' ');\n#endif\n\n  /* Verify input strings and measure their lengths */\n  for(nA=0; zA[nA]; nA++){\n    if( zA[nA]&0x80 ) return -2;\n  }\n  for(nB=0; zB[nB]; nB++){\n    if( zB[nB]&0x80 ) return -2;\n  }\n\n  /* Special processing if either string is empty */\n  if( nA==0 ){\n    cBprev = (char)dc;\n    for(xB=res=0; (cB = zB[xB])!=0; xB++){\n      res += insertOrDeleteCost(cBprev, cB, zB[xB+1])/FINAL_INS_COST_DIV;\n      cBprev = cB;\n    }\n    return res;\n  }\n  if( nB==0 ){\n    cAprev = (char)dc;\n    for(xA=res=0; (cA = zA[xA])!=0; xA++){\n      res += insertOrDeleteCost(cAprev, cA, zA[xA+1]);\n      cAprev = cA;\n    }\n    return res;\n  }\n\n  /* A is a prefix of B */\n  if( zA[0]=='*' && zA[1]==0 ) return 0;\n\n  /* Allocate and initialize the Wagner matrix */\n  if( nB<(sizeof(mStack)*4)/(sizeof(mStack[0])*5) ){\n    m = mStack;\n  }else{\n    m = toFree = sqlite3_malloc64( (nB+1)*5*sizeof(m[0])/4 );\n    if( m==0 ) return -3;\n  }\n  cx = (char*)&m[nB+1];\n\n  /* Compute the Wagner edit distance */\n  m[0] = 0;\n  cx[0] = (char)dc;\n  cBprev = (char)dc;\n  for(xB=1; xB<=nB; xB++){\n    cBnext = zB[xB];\n    cB = zB[xB-1];\n    cx[xB] = cB;\n    m[xB] = m[xB-1] + insertOrDeleteCost(cBprev, cB, cBnext);\n    cBprev = cB;\n  }\n  cAprev = (char)dc;\n  for(xA=1; xA<=nA; xA++){\n    int lastA = (xA==nA);\n    cA = zA[xA-1];\n    cAnext = zA[xA];\n    if( cA=='*' && lastA ) break;\n    d = m[0];\n    dc = cx[0];\n    m[0] = d + insertOrDeleteCost(cAprev, cA, cAnext);\n    cBprev = 0;\n    for(xB=1; xB<=nB; xB++){\n      int totalCost, insCost, delCost, subCost, ncx;\n      cB = zB[xB-1];\n      cBnext = zB[xB];\n\n      /* Cost to insert cB */\n      insCost = insertOrDeleteCost(cx[xB-1], cB, cBnext);\n      if( lastA ) insCost /= FINAL_INS_COST_DIV;\n\n      /* Cost to delete cA */\n      delCost = insertOrDeleteCost(cx[xB], cA, cBnext);\n\n      /* Cost to substitute cA->cB */\n      subCost = substituteCost(cx[xB-1], cA, cB);\n\n      /* Best cost */\n      totalCost = insCost + m[xB-1];\n      ncx = cB;\n      if( (delCost + m[xB])<totalCost ){\n        totalCost = delCost + m[xB];\n        ncx = cA;\n      }\n      if( (subCost + d)<totalCost ){\n        totalCost = subCost + d;\n      }\n\n#if 0\n      printf(\"%d,%d d=%4d u=%4d r=%4d dc=%c cA=%c cB=%c\"\n             \" ins=%4d del=%4d sub=%4d t=%4d ncx=%c\\n\",\n             xA, xB, d, m[xB], m[xB-1], dc?dc:' ', cA, cB,\n             insCost, delCost, subCost, totalCost, ncx?ncx:' ');\n#endif\n\n      /* Update the matrix */\n      d = m[xB];\n      dc = cx[xB];\n      m[xB] = totalCost;\n      cx[xB] = (char)ncx;\n      cBprev = cB;\n    }\n    cAprev = cA;\n  }\n\n  /* Free the wagner matrix and return the result */\n  if( cA=='*' ){\n    res = m[1];\n    for(xB=1; xB<=nB; xB++){\n      if( m[xB]<res ){\n        res = m[xB];\n        if( pnMatch ) *pnMatch = xB+nMatch;\n      }\n    }\n  }else{\n    res = m[nB];\n    /* In the current implementation, pnMatch is always NULL if zA does\n    ** not end in \"*\" */\n    assert( pnMatch==0 );\n  }\n  sqlite3_free(toFree);\n  return res;\n}\n\n/*\n** Function:    editdist(A,B)\n**\n** Return the cost of transforming string A into string B.  Both strings\n** must be pure ASCII text.  If A ends with '*' then it is assumed to be\n** a prefix of B and extra characters on the end of B have minimal additional\n** cost.\n*/\nstatic void editdistSqlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int res = editdist1(\n                    (const char*)sqlite3_value_text(argv[0]),\n                    (const char*)sqlite3_value_text(argv[1]),\n                    0);\n  if( res<0 ){\n    if( res==(-3) ){\n      sqlite3_result_error_nomem(context);\n    }else if( res==(-2) ){\n      sqlite3_result_error(context, \"non-ASCII input to editdist()\", -1);\n    }else{\n      sqlite3_result_error(context, \"NULL input to editdist()\", -1);\n    }\n  }else{ \n    sqlite3_result_int(context, res);\n  }\n}\n\n/* End of the fixed-cost edit distance implementation\n******************************************************************************\n*****************************************************************************\n** Begin: Configurable cost unicode edit distance routines\n*/\n/* Forward declaration of structures */\ntypedef struct EditDist3Cost EditDist3Cost;\ntypedef struct EditDist3Config EditDist3Config;\ntypedef struct EditDist3Point EditDist3Point;\ntypedef struct EditDist3From EditDist3From;\ntypedef struct EditDist3FromString EditDist3FromString;\ntypedef struct EditDist3To EditDist3To;\ntypedef struct EditDist3ToString EditDist3ToString;\ntypedef struct EditDist3Lang EditDist3Lang;\n\n\n/*\n** An entry in the edit cost table\n*/\nstruct EditDist3Cost {\n  EditDist3Cost *pNext;     /* Next cost element */\n  u8 nFrom;                 /* Number of bytes in aFrom */\n  u8 nTo;                   /* Number of bytes in aTo */\n  u16 iCost;                /* Cost of this transformation */\n  char a[4]    ;            /* FROM string followed by TO string */\n  /* Additional TO and FROM string bytes appended as necessary */\n};\n\n/*\n** Edit costs for a particular language ID \n*/\nstruct EditDist3Lang {\n  int iLang;             /* Language ID */\n  int iInsCost;          /* Default insertion cost */\n  int iDelCost;          /* Default deletion cost */\n  int iSubCost;          /* Default substitution cost */\n  EditDist3Cost *pCost;  /* Costs */\n};\n\n\n/*\n** The default EditDist3Lang object, with default costs.\n*/\nstatic const EditDist3Lang editDist3Lang = { 0, 100, 100, 150, 0 };\n\n/*\n** Complete configuration\n*/\nstruct EditDist3Config {\n  int nLang;             /* Number of language IDs.  Size of a[] */\n  EditDist3Lang *a;      /* One for each distinct language ID */\n};\n\n/*\n** Extra information about each character in the FROM string.\n*/\nstruct EditDist3From {\n  int nSubst;              /* Number of substitution cost entries */\n  int nDel;                /* Number of deletion cost entries */\n  int nByte;               /* Number of bytes in this character */\n  EditDist3Cost **apSubst; /* Array of substitution costs for this element */\n  EditDist3Cost **apDel;   /* Array of deletion cost entries */\n};\n\n/*\n** A precompiled FROM string.\n*\n** In the common case we expect the FROM string to be reused multiple times.\n** In other words, the common case will be to measure the edit distance\n** from a single origin string to multiple target strings.\n*/\nstruct EditDist3FromString {\n  char *z;                 /* The complete text of the FROM string */\n  int n;                   /* Number of characters in the FROM string */\n  int isPrefix;            /* True if ends with '*' character */\n  EditDist3From *a;        /* Extra info about each char of the FROM string */\n};\n\n/*\n** Extra information about each character in the TO string.\n*/\nstruct EditDist3To {\n  int nIns;                /* Number of insertion cost entries */\n  int nByte;               /* Number of bytes in this character */\n  EditDist3Cost **apIns;   /* Array of deletion cost entries */\n};\n\n/*\n** A precompiled FROM string\n*/\nstruct EditDist3ToString {\n  char *z;                 /* The complete text of the TO string */\n  int n;                   /* Number of characters in the TO string */\n  EditDist3To *a;          /* Extra info about each char of the TO string */\n};\n\n/*\n** Clear or delete an instance of the object that records all edit-distance\n** weights.\n*/\nstatic void editDist3ConfigClear(EditDist3Config *p){\n  int i;\n  if( p==0 ) return;\n  for(i=0; i<p->nLang; i++){\n    EditDist3Cost *pCost, *pNext;\n    pCost = p->a[i].pCost;\n    while( pCost ){\n      pNext = pCost->pNext;\n      sqlite3_free(pCost);\n      pCost = pNext;\n    }\n  }\n  sqlite3_free(p->a);\n  memset(p, 0, sizeof(*p));\n}\nstatic void editDist3ConfigDelete(void *pIn){\n  EditDist3Config *p = (EditDist3Config*)pIn;\n  editDist3ConfigClear(p);\n  sqlite3_free(p);\n}\n\n/*\n** Load all edit-distance weights from a table.\n*/\nstatic int editDist3ConfigLoad(\n  EditDist3Config *p,      /* The edit distance configuration to load */\n  sqlite3 *db,            /* Load from this database */\n  const char *zTable      /* Name of the table from which to load */\n){\n  sqlite3_stmt *pStmt;\n  int rc, rc2;\n  char *zSql;\n  int iLangPrev = -9999;\n  EditDist3Lang *pLang = 0;\n\n  zSql = sqlite3_mprintf(\"SELECT iLang, cFrom, cTo, iCost\"\n                         \" FROM \\\"%w\\\" WHERE iLang>=0 ORDER BY iLang\", zTable);\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ) return rc;\n  editDist3ConfigClear(p);\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int iLang = sqlite3_column_int(pStmt, 0);\n    const char *zFrom = (const char*)sqlite3_column_text(pStmt, 1);\n    int nFrom = zFrom ? sqlite3_column_bytes(pStmt, 1) : 0;\n    const char *zTo = (const char*)sqlite3_column_text(pStmt, 2);\n    int nTo = zTo ? sqlite3_column_bytes(pStmt, 2) : 0;\n    int iCost = sqlite3_column_int(pStmt, 3);\n\n    assert( zFrom!=0 || nFrom==0 );\n    assert( zTo!=0 || nTo==0 );\n    if( nFrom>100 || nTo>100 ) continue;\n    if( iCost<0 ) continue;\n    if( pLang==0 || iLang!=iLangPrev ){\n      EditDist3Lang *pNew;\n      pNew = sqlite3_realloc64(p->a, (p->nLang+1)*sizeof(p->a[0]));\n      if( pNew==0 ){ rc = SQLITE_NOMEM; break; }\n      p->a = pNew;\n      pLang = &p->a[p->nLang];\n      p->nLang++;\n      pLang->iLang = iLang;\n      pLang->iInsCost = 100;\n      pLang->iDelCost = 100;\n      pLang->iSubCost = 150;\n      pLang->pCost = 0;\n      iLangPrev = iLang;\n    }\n    if( nFrom==1 && zFrom[0]=='?' && nTo==0 ){\n      pLang->iDelCost = iCost;\n    }else if( nFrom==0 && nTo==1 && zTo[0]=='?' ){\n      pLang->iInsCost = iCost;\n    }else if( nFrom==1 && nTo==1 && zFrom[0]=='?' && zTo[0]=='?' ){\n      pLang->iSubCost = iCost;\n    }else{\n      EditDist3Cost *pCost;\n      int nExtra = nFrom + nTo - 4;\n      if( nExtra<0 ) nExtra = 0;\n      pCost = sqlite3_malloc64( sizeof(*pCost) + nExtra );\n      if( pCost==0 ){ rc = SQLITE_NOMEM; break; }\n      pCost->nFrom = (u8)nFrom;\n      pCost->nTo = (u8)nTo;\n      pCost->iCost = (u16)iCost;\n      memcpy(pCost->a, zFrom, nFrom);\n      memcpy(pCost->a + nFrom, zTo, nTo);\n      pCost->pNext = pLang->pCost;\n      pLang->pCost = pCost; \n    }\n  }\n  rc2 = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) rc = rc2;\n  return rc;\n}\n\n/*\n** Return the length (in bytes) of a utf-8 character.  Or return a maximum\n** of N.\n*/\nstatic int utf8Len(unsigned char c, int N){\n  int len = 1;\n  if( c>0x7f ){\n    if( (c&0xe0)==0xc0 ){\n      len = 2;\n    }else if( (c&0xf0)==0xe0 ){\n      len = 3;\n    }else{\n      len = 4;\n    }\n  }\n  if( len>N ) len = N;\n  return len;\n}\n\n/*\n** Return TRUE (non-zero) if the To side of the given cost matches\n** the given string.\n*/\nstatic int matchTo(EditDist3Cost *p, const char *z, int n){\n  if( p->nTo>n ) return 0;\n  if( strncmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0;\n  return 1;\n}\n\n/*\n** Return TRUE (non-zero) if the From side of the given cost matches\n** the given string.\n*/\nstatic int matchFrom(EditDist3Cost *p, const char *z, int n){\n  assert( p->nFrom<=n );\n  if( strncmp(p->a, z, p->nFrom)!=0 ) return 0;\n  return 1;\n}\n\n/*\n** Return TRUE (non-zero) of the next FROM character and the next TO\n** character are the same.\n*/\nstatic int matchFromTo(\n  EditDist3FromString *pStr,  /* Left hand string */\n  int n1,                     /* Index of comparison character on the left */\n  const char *z2,             /* Right-handl comparison character */\n  int n2                      /* Bytes remaining in z2[] */\n){\n  int b1 = pStr->a[n1].nByte;\n  if( b1>n2 ) return 0;\n  if( memcmp(pStr->z+n1, z2, b1)!=0 ) return 0;\n  return 1;\n}\n\n/*\n** Delete an EditDist3FromString objecct\n*/\nstatic void editDist3FromStringDelete(EditDist3FromString *p){\n  int i;\n  if( p ){\n    for(i=0; i<p->n; i++){\n      sqlite3_free(p->a[i].apDel);\n      sqlite3_free(p->a[i].apSubst);\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Create a EditDist3FromString object.\n*/\nstatic EditDist3FromString *editDist3FromStringNew(\n  const EditDist3Lang *pLang,\n  const char *z,\n  int n\n){\n  EditDist3FromString *pStr;\n  EditDist3Cost *p;\n  int i;\n\n  if( z==0 ) return 0;\n  if( n<0 ) n = (int)strlen(z);\n  pStr = sqlite3_malloc64( sizeof(*pStr) + sizeof(pStr->a[0])*n + n + 1 );\n  if( pStr==0 ) return 0;\n  pStr->a = (EditDist3From*)&pStr[1];\n  memset(pStr->a, 0, sizeof(pStr->a[0])*n);\n  pStr->n = n;\n  pStr->z = (char*)&pStr->a[n];\n  memcpy(pStr->z, z, n+1);\n  if( n && z[n-1]=='*' ){\n    pStr->isPrefix = 1;\n    n--;\n    pStr->n--;\n    pStr->z[n] = 0;\n  }else{\n    pStr->isPrefix = 0;\n  }\n\n  for(i=0; i<n; i++){\n    EditDist3From *pFrom = &pStr->a[i];\n    memset(pFrom, 0, sizeof(*pFrom));\n    pFrom->nByte = utf8Len((unsigned char)z[i], n-i);\n    for(p=pLang->pCost; p; p=p->pNext){\n      EditDist3Cost **apNew;\n      if( i+p->nFrom>n ) continue;\n      if( matchFrom(p, z+i, n-i)==0 ) continue;\n      if( p->nTo==0 ){\n        apNew = sqlite3_realloc64(pFrom->apDel,\n                                sizeof(*apNew)*(pFrom->nDel+1));\n        if( apNew==0 ) break;\n        pFrom->apDel = apNew;\n        apNew[pFrom->nDel++] = p;\n      }else{\n        apNew = sqlite3_realloc64(pFrom->apSubst,\n                                sizeof(*apNew)*(pFrom->nSubst+1));\n        if( apNew==0 ) break;\n        pFrom->apSubst = apNew;\n        apNew[pFrom->nSubst++] = p;\n      }\n    }\n    if( p ){\n      editDist3FromStringDelete(pStr);\n      pStr = 0;\n      break;\n    }\n  }\n  return pStr;\n}\n\n/*\n** Update entry m[i] such that it is the minimum of its current value\n** and m[j]+iCost.\n**\n** If the iCost is 1,000,000 or greater, then consider the cost to be\n** infinite and skip the update.\n*/\nstatic void updateCost(\n  unsigned int *m,\n  int i,\n  int j,\n  int iCost\n){\n  assert( iCost>=0 );\n  if( iCost<10000 ){\n    unsigned int b = m[j] + iCost;\n    if( b<m[i] ) m[i] = b;\n  }\n}\n\n/*\n** How much stack space (int bytes) to use for Wagner matrix in \n** editDist3Core().  If more space than this is required, the entire\n** matrix is taken from the heap.  To reduce the load on the memory\n** allocator, make this value as large as practical for the\n** architecture in use.\n*/\n#ifndef SQLITE_SPELLFIX_STACKALLOC_SZ\n# define SQLITE_SPELLFIX_STACKALLOC_SZ  (1024)\n#endif\n\n/* Compute the edit distance between two strings.\n**\n** If an error occurs, return a negative number which is the error code.\n**\n** If pnMatch is not NULL, then *pnMatch is set to the number of characters\n** (not bytes) in z2 that matched the search pattern in *pFrom. If pFrom does\n** not contain the pattern for a prefix-search, then this is always the number\n** of characters in z2. If pFrom does contain a prefix search pattern, then\n** it is the number of characters in the prefix of z2 that was deemed to \n** match pFrom.\n*/\nstatic int editDist3Core(\n  EditDist3FromString *pFrom,  /* The FROM string */\n  const char *z2,              /* The TO string */\n  int n2,                      /* Length of the TO string */\n  const EditDist3Lang *pLang,  /* Edit weights for a particular language ID */\n  int *pnMatch                 /* OUT: Characters in matched prefix */\n){\n  int k, n;\n  int i1, b1;\n  int i2, b2;\n  EditDist3FromString f = *pFrom;\n  EditDist3To *a2;\n  unsigned int *m;\n  unsigned int *pToFree;\n  int szRow;\n  EditDist3Cost *p;\n  int res;\n  sqlite3_uint64 nByte;\n  unsigned int stackSpace[SQLITE_SPELLFIX_STACKALLOC_SZ/sizeof(unsigned int)];\n\n  /* allocate the Wagner matrix and the aTo[] array for the TO string */\n  n = (f.n+1)*(n2+1);\n  n = (n+1)&~1;\n  nByte = n*sizeof(m[0]) + sizeof(a2[0])*n2;\n  if( nByte<=sizeof(stackSpace) ){\n    m = stackSpace;\n    pToFree = 0;\n  }else{\n    m = pToFree = sqlite3_malloc64( nByte );\n    if( m==0 ) return -1;            /* Out of memory */\n  }\n  a2 = (EditDist3To*)&m[n];\n  memset(a2, 0, sizeof(a2[0])*n2);\n\n  /* Fill in the a1[] matrix for all characters of the TO string */\n  for(i2=0; i2<n2; i2++){\n    a2[i2].nByte = utf8Len((unsigned char)z2[i2], n2-i2);\n    for(p=pLang->pCost; p; p=p->pNext){\n      EditDist3Cost **apNew;\n      if( p->nFrom>0 ) continue;\n      if( i2+p->nTo>n2 ) continue;\n      if( matchTo(p, z2+i2, n2-i2)==0 ) continue;\n      a2[i2].nIns++;\n      apNew = sqlite3_realloc64(a2[i2].apIns, sizeof(*apNew)*a2[i2].nIns);\n      if( apNew==0 ){\n        res = -1;  /* Out of memory */\n        goto editDist3Abort;\n      }\n      a2[i2].apIns = apNew;\n      a2[i2].apIns[a2[i2].nIns-1] = p;\n    }\n  }\n\n  /* Prepare to compute the minimum edit distance */\n  szRow = f.n+1;\n  memset(m, 0x01, (n2+1)*szRow*sizeof(m[0]));\n  m[0] = 0;\n\n  /* First fill in the top-row of the matrix with FROM deletion costs */\n  for(i1=0; i1<f.n; i1 += b1){\n    b1 = f.a[i1].nByte;\n    updateCost(m, i1+b1, i1, pLang->iDelCost);\n    for(k=0; k<f.a[i1].nDel; k++){\n      p = f.a[i1].apDel[k];\n      updateCost(m, i1+p->nFrom, i1, p->iCost);\n    }\n  }\n\n  /* Fill in all subsequent rows, top-to-bottom, left-to-right */\n  for(i2=0; i2<n2; i2 += b2){\n    int rx;      /* Starting index for current row */\n    int rxp;     /* Starting index for previous row */\n    b2 = a2[i2].nByte;\n    rx = szRow*(i2+b2);\n    rxp = szRow*i2;\n    updateCost(m, rx, rxp, pLang->iInsCost);\n    for(k=0; k<a2[i2].nIns; k++){\n      p = a2[i2].apIns[k];\n      updateCost(m, szRow*(i2+p->nTo), rxp, p->iCost);\n    }\n    for(i1=0; i1<f.n; i1+=b1){\n      int cx;    /* Index of current cell */\n      int cxp;   /* Index of cell immediately to the left */\n      int cxd;   /* Index of cell to the left and one row above */\n      int cxu;   /* Index of cell immediately above */\n      b1 = f.a[i1].nByte;\n      cxp = rx + i1;\n      cx = cxp + b1;\n      cxd = rxp + i1;\n      cxu = cxd + b1;\n      updateCost(m, cx, cxp, pLang->iDelCost);\n      for(k=0; k<f.a[i1].nDel; k++){\n        p = f.a[i1].apDel[k];\n        updateCost(m, cxp+p->nFrom, cxp, p->iCost);\n      }\n      updateCost(m, cx, cxu, pLang->iInsCost);\n      if( matchFromTo(&f, i1, z2+i2, n2-i2) ){\n        updateCost(m, cx, cxd, 0);\n      }\n      updateCost(m, cx, cxd, pLang->iSubCost);\n      for(k=0; k<f.a[i1].nSubst; k++){\n        p = f.a[i1].apSubst[k];\n        if( matchTo(p, z2+i2, n2-i2) ){\n          updateCost(m, cxd+p->nFrom+szRow*p->nTo, cxd, p->iCost);\n        }\n      }\n    }\n  }\n\n#if 0  /* Enable for debugging */\n  printf(\"         ^\");\n  for(i1=0; i1<f.n; i1++) printf(\" %c-%2x\", f.z[i1], f.z[i1]&0xff);\n  printf(\"\\n   ^:\");\n  for(i1=0; i1<szRow; i1++){\n    int v = m[i1];\n    if( v>9999 ) printf(\" ****\");\n    else         printf(\" %4d\", v);\n  }\n  printf(\"\\n\");\n  for(i2=0; i2<n2; i2++){\n    printf(\"%c-%02x:\", z2[i2], z2[i2]&0xff);\n    for(i1=0; i1<szRow; i1++){\n      int v = m[(i2+1)*szRow+i1];\n      if( v>9999 ) printf(\" ****\");\n      else         printf(\" %4d\", v);\n    }\n    printf(\"\\n\");\n  }\n#endif\n\n  /* Free memory allocations and return the result */\n  res = (int)m[szRow*(n2+1)-1];\n  n = n2;\n  if( f.isPrefix ){\n    for(i2=1; i2<=n2; i2++){\n      int b = m[szRow*i2-1];\n      if( b<=res ){ \n        res = b;\n        n = i2 - 1;\n      }\n    }\n  }\n  if( pnMatch ){\n    int nExtra = 0;\n    for(k=0; k<n; k++){\n      if( (z2[k] & 0xc0)==0x80 ) nExtra++;\n    }\n    *pnMatch = n - nExtra;\n  }\n\neditDist3Abort:\n  for(i2=0; i2<n2; i2++) sqlite3_free(a2[i2].apIns);\n  sqlite3_free(pToFree);\n  return res;\n}\n\n/*\n** Get an appropriate EditDist3Lang object.\n*/\nstatic const EditDist3Lang *editDist3FindLang(\n  EditDist3Config *pConfig,\n  int iLang\n){\n  int i;\n  for(i=0; i<pConfig->nLang; i++){\n    if( pConfig->a[i].iLang==iLang ) return &pConfig->a[i];\n  }\n  return &editDist3Lang;\n}\n\n/*\n** Function:    editdist3(A,B,iLang)\n**              editdist3(tablename)\n**\n** Return the cost of transforming string A into string B using edit\n** weights for iLang.\n**\n** The second form loads edit weights into memory from a table.\n*/\nstatic void editDist3SqlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  EditDist3Config *pConfig = (EditDist3Config*)sqlite3_user_data(context);\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int rc;\n  if( argc==1 ){\n    const char *zTable = (const char*)sqlite3_value_text(argv[0]);\n    rc = editDist3ConfigLoad(pConfig, db, zTable);\n    if( rc ) sqlite3_result_error_code(context, rc);\n  }else{\n    const char *zA = (const char*)sqlite3_value_text(argv[0]);\n    const char *zB = (const char*)sqlite3_value_text(argv[1]);\n    int nA = sqlite3_value_bytes(argv[0]);\n    int nB = sqlite3_value_bytes(argv[1]);\n    int iLang = argc==3 ? sqlite3_value_int(argv[2]) : 0;\n    const EditDist3Lang *pLang = editDist3FindLang(pConfig, iLang);\n    EditDist3FromString *pFrom;\n    int dist;\n\n    pFrom = editDist3FromStringNew(pLang, zA, nA);\n    if( pFrom==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    dist = editDist3Core(pFrom, zB, nB, pLang, 0);\n    editDist3FromStringDelete(pFrom);\n    if( dist==(-1) ){\n      sqlite3_result_error_nomem(context);\n    }else{\n      sqlite3_result_int(context, dist);\n    }\n  } \n}\n\n/*\n** Register the editDist3 function with SQLite\n*/\nstatic int editDist3Install(sqlite3 *db){\n  int rc;\n  EditDist3Config *pConfig = sqlite3_malloc64( sizeof(*pConfig) );\n  if( pConfig==0 ) return SQLITE_NOMEM;\n  memset(pConfig, 0, sizeof(*pConfig));\n  rc = sqlite3_create_function_v2(db, \"editdist3\",\n              2, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function_v2(db, \"editdist3\",\n                3, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function_v2(db, \"editdist3\",\n                1, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0,\n                editDist3ConfigDelete);\n  }else{\n    sqlite3_free(pConfig);\n  }\n  return rc;\n}\n/* End configurable cost unicode edit distance routines\n******************************************************************************\n******************************************************************************\n** Begin transliterate unicode-to-ascii implementation\n*/\n\n#if !SQLITE_AMALGAMATION\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character.\n*/\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n#endif\n\n/*\n** Return the value of the first UTF-8 character in the string.\n*/\nstatic int utf8Read(const unsigned char *z, int n, int *pSize){\n  int c, i;\n\n  /* All callers to this routine (in the current implementation)\n  ** always have n>0. */\n  if( NEVER(n==0) ){\n    c = i = 0;\n  }else{\n    c = z[0];\n    i = 1;\n    if( c>=0xc0 ){\n      c = sqlite3Utf8Trans1[c-0xc0];\n      while( i<n && (z[i] & 0xc0)==0x80 ){\n        c = (c<<6) + (0x3f & z[i++]);\n      }\n    }\n  }\n  *pSize = i;\n  return c;\n}\n\n/*\n** Return the number of characters in the utf-8 string in the nIn byte\n** buffer pointed to by zIn.\n*/\nstatic int utf8Charlen(const char *zIn, int nIn){\n  int i;\n  int nChar = 0;\n  for(i=0; i<nIn; nChar++){\n    int sz;\n    utf8Read((const unsigned char *)&zIn[i], nIn-i, &sz);\n    i += sz;\n  }\n  return nChar;\n}\n\n/*\n** Table of translations from unicode characters into ASCII.\n*/\nstatic const struct {\n unsigned short int cFrom;\n unsigned char cTo0, cTo1;\n} translit[] = {\n  { 0x00A0,  0x20, 0x00 },  /*   to   */\n  { 0x00B5,  0x75, 0x00 },  /* µ to u */\n  { 0x00C0,  0x41, 0x00 },  /* À to A */\n  { 0x00C1,  0x41, 0x00 },  /* Á to A */\n  { 0x00C2,  0x41, 0x00 },  /* Â to A */\n  { 0x00C3,  0x41, 0x00 },  /* Ã to A */\n  { 0x00C4,  0x41, 0x65 },  /* Ä to Ae */\n  { 0x00C5,  0x41, 0x61 },  /* Å to Aa */\n  { 0x00C6,  0x41, 0x45 },  /* Æ to AE */\n  { 0x00C7,  0x43, 0x00 },  /* Ç to C */\n  { 0x00C8,  0x45, 0x00 },  /* È to E */\n  { 0x00C9,  0x45, 0x00 },  /* É to E */\n  { 0x00CA,  0x45, 0x00 },  /* Ê to E */\n  { 0x00CB,  0x45, 0x00 },  /* Ë to E */\n  { 0x00CC,  0x49, 0x00 },  /* Ì to I */\n  { 0x00CD,  0x49, 0x00 },  /* Í to I */\n  { 0x00CE,  0x49, 0x00 },  /* Î to I */\n  { 0x00CF,  0x49, 0x00 },  /* Ï to I */\n  { 0x00D0,  0x44, 0x00 },  /* Ð to D */\n  { 0x00D1,  0x4E, 0x00 },  /* Ñ to N */\n  { 0x00D2,  0x4F, 0x00 },  /* Ò to O */\n  { 0x00D3,  0x4F, 0x00 },  /* Ó to O */\n  { 0x00D4,  0x4F, 0x00 },  /* Ô to O */\n  { 0x00D5,  0x4F, 0x00 },  /* Õ to O */\n  { 0x00D6,  0x4F, 0x65 },  /* Ö to Oe */\n  { 0x00D7,  0x78, 0x00 },  /* × to x */\n  { 0x00D8,  0x4F, 0x00 },  /* Ø to O */\n  { 0x00D9,  0x55, 0x00 },  /* Ù to U */\n  { 0x00DA,  0x55, 0x00 },  /* Ú to U */\n  { 0x00DB,  0x55, 0x00 },  /* Û to U */\n  { 0x00DC,  0x55, 0x65 },  /* Ü to Ue */\n  { 0x00DD,  0x59, 0x00 },  /* Ý to Y */\n  { 0x00DE,  0x54, 0x68 },  /* Þ to Th */\n  { 0x00DF,  0x73, 0x73 },  /* ß to ss */\n  { 0x00E0,  0x61, 0x00 },  /* à to a */\n  { 0x00E1,  0x61, 0x00 },  /* á to a */\n  { 0x00E2,  0x61, 0x00 },  /* â to a */\n  { 0x00E3,  0x61, 0x00 },  /* ã to a */\n  { 0x00E4,  0x61, 0x65 },  /* ä to ae */\n  { 0x00E5,  0x61, 0x61 },  /* å to aa */\n  { 0x00E6,  0x61, 0x65 },  /* æ to ae */\n  { 0x00E7,  0x63, 0x00 },  /* ç to c */\n  { 0x00E8,  0x65, 0x00 },  /* è to e */\n  { 0x00E9,  0x65, 0x00 },  /* é to e */\n  { 0x00EA,  0x65, 0x00 },  /* ê to e */\n  { 0x00EB,  0x65, 0x00 },  /* ë to e */\n  { 0x00EC,  0x69, 0x00 },  /* ì to i */\n  { 0x00ED,  0x69, 0x00 },  /* í to i */\n  { 0x00EE,  0x69, 0x00 },  /* î to i */\n  { 0x00EF,  0x69, 0x00 },  /* ï to i */\n  { 0x00F0,  0x64, 0x00 },  /* ð to d */\n  { 0x00F1,  0x6E, 0x00 },  /* ñ to n */\n  { 0x00F2,  0x6F, 0x00 },  /* ò to o */\n  { 0x00F3,  0x6F, 0x00 },  /* ó to o */\n  { 0x00F4,  0x6F, 0x00 },  /* ô to o */\n  { 0x00F5,  0x6F, 0x00 },  /* õ to o */\n  { 0x00F6,  0x6F, 0x65 },  /* ö to oe */\n  { 0x00F7,  0x3A, 0x00 },  /* ÷ to : */\n  { 0x00F8,  0x6F, 0x00 },  /* ø to o */\n  { 0x00F9,  0x75, 0x00 },  /* ù to u */\n  { 0x00FA,  0x75, 0x00 },  /* ú to u */\n  { 0x00FB,  0x75, 0x00 },  /* û to u */\n  { 0x00FC,  0x75, 0x65 },  /* ü to ue */\n  { 0x00FD,  0x79, 0x00 },  /* ý to y */\n  { 0x00FE,  0x74, 0x68 },  /* þ to th */\n  { 0x00FF,  0x79, 0x00 },  /* ÿ to y */\n  { 0x0100,  0x41, 0x00 },  /* Ā to A */\n  { 0x0101,  0x61, 0x00 },  /* ā to a */\n  { 0x0102,  0x41, 0x00 },  /* Ă to A */\n  { 0x0103,  0x61, 0x00 },  /* ă to a */\n  { 0x0104,  0x41, 0x00 },  /* Ą to A */\n  { 0x0105,  0x61, 0x00 },  /* ą to a */\n  { 0x0106,  0x43, 0x00 },  /* Ć to C */\n  { 0x0107,  0x63, 0x00 },  /* ć to c */\n  { 0x0108,  0x43, 0x68 },  /* Ĉ to Ch */\n  { 0x0109,  0x63, 0x68 },  /* ĉ to ch */\n  { 0x010A,  0x43, 0x00 },  /* Ċ to C */\n  { 0x010B,  0x63, 0x00 },  /* ċ to c */\n  { 0x010C,  0x43, 0x00 },  /* Č to C */\n  { 0x010D,  0x63, 0x00 },  /* č to c */\n  { 0x010E,  0x44, 0x00 },  /* Ď to D */\n  { 0x010F,  0x64, 0x00 },  /* ď to d */\n  { 0x0110,  0x44, 0x00 },  /* Đ to D */\n  { 0x0111,  0x64, 0x00 },  /* đ to d */\n  { 0x0112,  0x45, 0x00 },  /* Ē to E */\n  { 0x0113,  0x65, 0x00 },  /* ē to e */\n  { 0x0114,  0x45, 0x00 },  /* Ĕ to E */\n  { 0x0115,  0x65, 0x00 },  /* ĕ to e */\n  { 0x0116,  0x45, 0x00 },  /* Ė to E */\n  { 0x0117,  0x65, 0x00 },  /* ė to e */\n  { 0x0118,  0x45, 0x00 },  /* Ę to E */\n  { 0x0119,  0x65, 0x00 },  /* ę to e */\n  { 0x011A,  0x45, 0x00 },  /* Ě to E */\n  { 0x011B,  0x65, 0x00 },  /* ě to e */\n  { 0x011C,  0x47, 0x68 },  /* Ĝ to Gh */\n  { 0x011D,  0x67, 0x68 },  /* ĝ to gh */\n  { 0x011E,  0x47, 0x00 },  /* Ğ to G */\n  { 0x011F,  0x67, 0x00 },  /* ğ to g */\n  { 0x0120,  0x47, 0x00 },  /* Ġ to G */\n  { 0x0121,  0x67, 0x00 },  /* ġ to g */\n  { 0x0122,  0x47, 0x00 },  /* Ģ to G */\n  { 0x0123,  0x67, 0x00 },  /* ģ to g */\n  { 0x0124,  0x48, 0x68 },  /* Ĥ to Hh */\n  { 0x0125,  0x68, 0x68 },  /* ĥ to hh */\n  { 0x0126,  0x48, 0x00 },  /* Ħ to H */\n  { 0x0127,  0x68, 0x00 },  /* ħ to h */\n  { 0x0128,  0x49, 0x00 },  /* Ĩ to I */\n  { 0x0129,  0x69, 0x00 },  /* ĩ to i */\n  { 0x012A,  0x49, 0x00 },  /* Ī to I */\n  { 0x012B,  0x69, 0x00 },  /* ī to i */\n  { 0x012C,  0x49, 0x00 },  /* Ĭ to I */\n  { 0x012D,  0x69, 0x00 },  /* ĭ to i */\n  { 0x012E,  0x49, 0x00 },  /* Į to I */\n  { 0x012F,  0x69, 0x00 },  /* į to i */\n  { 0x0130,  0x49, 0x00 },  /* İ to I */\n  { 0x0131,  0x69, 0x00 },  /* ı to i */\n  { 0x0132,  0x49, 0x4A },  /* Ĳ to IJ */\n  { 0x0133,  0x69, 0x6A },  /* ĳ to ij */\n  { 0x0134,  0x4A, 0x68 },  /* Ĵ to Jh */\n  { 0x0135,  0x6A, 0x68 },  /* ĵ to jh */\n  { 0x0136,  0x4B, 0x00 },  /* Ķ to K */\n  { 0x0137,  0x6B, 0x00 },  /* ķ to k */\n  { 0x0138,  0x6B, 0x00 },  /* ĸ to k */\n  { 0x0139,  0x4C, 0x00 },  /* Ĺ to L */\n  { 0x013A,  0x6C, 0x00 },  /* ĺ to l */\n  { 0x013B,  0x4C, 0x00 },  /* Ļ to L */\n  { 0x013C,  0x6C, 0x00 },  /* ļ to l */\n  { 0x013D,  0x4C, 0x00 },  /* Ľ to L */\n  { 0x013E,  0x6C, 0x00 },  /* ľ to l */\n  { 0x013F,  0x4C, 0x2E },  /* Ŀ to L. */\n  { 0x0140,  0x6C, 0x2E },  /* ŀ to l. */\n  { 0x0141,  0x4C, 0x00 },  /* Ł to L */\n  { 0x0142,  0x6C, 0x00 },  /* ł to l */\n  { 0x0143,  0x4E, 0x00 },  /* Ń to N */\n  { 0x0144,  0x6E, 0x00 },  /* ń to n */\n  { 0x0145,  0x4E, 0x00 },  /* Ņ to N */\n  { 0x0146,  0x6E, 0x00 },  /* ņ to n */\n  { 0x0147,  0x4E, 0x00 },  /* Ň to N */\n  { 0x0148,  0x6E, 0x00 },  /* ň to n */\n  { 0x0149,  0x27, 0x6E },  /* ŉ to 'n */\n  { 0x014A,  0x4E, 0x47 },  /* Ŋ to NG */\n  { 0x014B,  0x6E, 0x67 },  /* ŋ to ng */\n  { 0x014C,  0x4F, 0x00 },  /* Ō to O */\n  { 0x014D,  0x6F, 0x00 },  /* ō to o */\n  { 0x014E,  0x4F, 0x00 },  /* Ŏ to O */\n  { 0x014F,  0x6F, 0x00 },  /* ŏ to o */\n  { 0x0150,  0x4F, 0x00 },  /* Ő to O */\n  { 0x0151,  0x6F, 0x00 },  /* ő to o */\n  { 0x0152,  0x4F, 0x45 },  /* Œ to OE */\n  { 0x0153,  0x6F, 0x65 },  /* œ to oe */\n  { 0x0154,  0x52, 0x00 },  /* Ŕ to R */\n  { 0x0155,  0x72, 0x00 },  /* ŕ to r */\n  { 0x0156,  0x52, 0x00 },  /* Ŗ to R */\n  { 0x0157,  0x72, 0x00 },  /* ŗ to r */\n  { 0x0158,  0x52, 0x00 },  /* Ř to R */\n  { 0x0159,  0x72, 0x00 },  /* ř to r */\n  { 0x015A,  0x53, 0x00 },  /* Ś to S */\n  { 0x015B,  0x73, 0x00 },  /* ś to s */\n  { 0x015C,  0x53, 0x68 },  /* Ŝ to Sh */\n  { 0x015D,  0x73, 0x68 },  /* ŝ to sh */\n  { 0x015E,  0x53, 0x00 },  /* Ş to S */\n  { 0x015F,  0x73, 0x00 },  /* ş to s */\n  { 0x0160,  0x53, 0x00 },  /* Š to S */\n  { 0x0161,  0x73, 0x00 },  /* š to s */\n  { 0x0162,  0x54, 0x00 },  /* Ţ to T */\n  { 0x0163,  0x74, 0x00 },  /* ţ to t */\n  { 0x0164,  0x54, 0x00 },  /* Ť to T */\n  { 0x0165,  0x74, 0x00 },  /* ť to t */\n  { 0x0166,  0x54, 0x00 },  /* Ŧ to T */\n  { 0x0167,  0x74, 0x00 },  /* ŧ to t */\n  { 0x0168,  0x55, 0x00 },  /* Ũ to U */\n  { 0x0169,  0x75, 0x00 },  /* ũ to u */\n  { 0x016A,  0x55, 0x00 },  /* Ū to U */\n  { 0x016B,  0x75, 0x00 },  /* ū to u */\n  { 0x016C,  0x55, 0x00 },  /* Ŭ to U */\n  { 0x016D,  0x75, 0x00 },  /* ŭ to u */\n  { 0x016E,  0x55, 0x00 },  /* Ů to U */\n  { 0x016F,  0x75, 0x00 },  /* ů to u */\n  { 0x0170,  0x55, 0x00 },  /* Ű to U */\n  { 0x0171,  0x75, 0x00 },  /* ű to u */\n  { 0x0172,  0x55, 0x00 },  /* Ų to U */\n  { 0x0173,  0x75, 0x00 },  /* ų to u */\n  { 0x0174,  0x57, 0x00 },  /* Ŵ to W */\n  { 0x0175,  0x77, 0x00 },  /* ŵ to w */\n  { 0x0176,  0x59, 0x00 },  /* Ŷ to Y */\n  { 0x0177,  0x79, 0x00 },  /* ŷ to y */\n  { 0x0178,  0x59, 0x00 },  /* Ÿ to Y */\n  { 0x0179,  0x5A, 0x00 },  /* Ź to Z */\n  { 0x017A,  0x7A, 0x00 },  /* ź to z */\n  { 0x017B,  0x5A, 0x00 },  /* Ż to Z */\n  { 0x017C,  0x7A, 0x00 },  /* ż to z */\n  { 0x017D,  0x5A, 0x00 },  /* Ž to Z */\n  { 0x017E,  0x7A, 0x00 },  /* ž to z */\n  { 0x017F,  0x73, 0x00 },  /* ſ to s */\n  { 0x0192,  0x66, 0x00 },  /* ƒ to f */\n  { 0x0218,  0x53, 0x00 },  /* Ș to S */\n  { 0x0219,  0x73, 0x00 },  /* ș to s */\n  { 0x021A,  0x54, 0x00 },  /* Ț to T */\n  { 0x021B,  0x74, 0x00 },  /* ț to t */\n  { 0x0386,  0x41, 0x00 },  /* Ά to A */\n  { 0x0388,  0x45, 0x00 },  /* Έ to E */\n  { 0x0389,  0x49, 0x00 },  /* Ή to I */\n  { 0x038A,  0x49, 0x00 },  /* Ί to I */\n  { 0x038C,  0x4f, 0x00 },  /* Ό to O */\n  { 0x038E,  0x59, 0x00 },  /* Ύ to Y */\n  { 0x038F,  0x4f, 0x00 },  /* Ώ to O */\n  { 0x0390,  0x69, 0x00 },  /* ΐ to i */\n  { 0x0391,  0x41, 0x00 },  /* Α to A */\n  { 0x0392,  0x42, 0x00 },  /* Β to B */\n  { 0x0393,  0x47, 0x00 },  /* Γ to G */\n  { 0x0394,  0x44, 0x00 },  /* Δ to D */\n  { 0x0395,  0x45, 0x00 },  /* Ε to E */\n  { 0x0396,  0x5a, 0x00 },  /* Ζ to Z */\n  { 0x0397,  0x49, 0x00 },  /* Η to I */\n  { 0x0398,  0x54, 0x68 },  /* Θ to Th */\n  { 0x0399,  0x49, 0x00 },  /* Ι to I */\n  { 0x039A,  0x4b, 0x00 },  /* Κ to K */\n  { 0x039B,  0x4c, 0x00 },  /* Λ to L */\n  { 0x039C,  0x4d, 0x00 },  /* Μ to M */\n  { 0x039D,  0x4e, 0x00 },  /* Ν to N */\n  { 0x039E,  0x58, 0x00 },  /* Ξ to X */\n  { 0x039F,  0x4f, 0x00 },  /* Ο to O */\n  { 0x03A0,  0x50, 0x00 },  /* Π to P */\n  { 0x03A1,  0x52, 0x00 },  /* Ρ to R */\n  { 0x03A3,  0x53, 0x00 },  /* Σ to S */\n  { 0x03A4,  0x54, 0x00 },  /* Τ to T */\n  { 0x03A5,  0x59, 0x00 },  /* Υ to Y */\n  { 0x03A6,  0x46, 0x00 },  /* Φ to F */\n  { 0x03A7,  0x43, 0x68 },  /* Χ to Ch */\n  { 0x03A8,  0x50, 0x73 },  /* Ψ to Ps */\n  { 0x03A9,  0x4f, 0x00 },  /* Ω to O */\n  { 0x03AA,  0x49, 0x00 },  /* Ϊ to I */\n  { 0x03AB,  0x59, 0x00 },  /* Ϋ to Y */\n  { 0x03AC,  0x61, 0x00 },  /* ά to a */\n  { 0x03AD,  0x65, 0x00 },  /* έ to e */\n  { 0x03AE,  0x69, 0x00 },  /* ή to i */\n  { 0x03AF,  0x69, 0x00 },  /* ί to i */\n  { 0x03B1,  0x61, 0x00 },  /* α to a */\n  { 0x03B2,  0x62, 0x00 },  /* β to b */\n  { 0x03B3,  0x67, 0x00 },  /* γ to g */\n  { 0x03B4,  0x64, 0x00 },  /* δ to d */\n  { 0x03B5,  0x65, 0x00 },  /* ε to e */\n  { 0x03B6,  0x7a, 0x00 },  /* ζ to z */\n  { 0x03B7,  0x69, 0x00 },  /* η to i */\n  { 0x03B8,  0x74, 0x68 },  /* θ to th */\n  { 0x03B9,  0x69, 0x00 },  /* ι to i */\n  { 0x03BA,  0x6b, 0x00 },  /* κ to k */\n  { 0x03BB,  0x6c, 0x00 },  /* λ to l */\n  { 0x03BC,  0x6d, 0x00 },  /* μ to m */\n  { 0x03BD,  0x6e, 0x00 },  /* ν to n */\n  { 0x03BE,  0x78, 0x00 },  /* ξ to x */\n  { 0x03BF,  0x6f, 0x00 },  /* ο to o */\n  { 0x03C0,  0x70, 0x00 },  /* π to p */\n  { 0x03C1,  0x72, 0x00 },  /* ρ to r */\n  { 0x03C3,  0x73, 0x00 },  /* σ to s */\n  { 0x03C4,  0x74, 0x00 },  /* τ to t */\n  { 0x03C5,  0x79, 0x00 },  /* υ to y */\n  { 0x03C6,  0x66, 0x00 },  /* φ to f */\n  { 0x03C7,  0x63, 0x68 },  /* χ to ch */\n  { 0x03C8,  0x70, 0x73 },  /* ψ to ps */\n  { 0x03C9,  0x6f, 0x00 },  /* ω to o */\n  { 0x03CA,  0x69, 0x00 },  /* ϊ to i */\n  { 0x03CB,  0x79, 0x00 },  /* ϋ to y */\n  { 0x03CC,  0x6f, 0x00 },  /* ό to o */\n  { 0x03CD,  0x79, 0x00 },  /* ύ to y */\n  { 0x03CE,  0x69, 0x00 },  /* ώ to i */\n  { 0x0400,  0x45, 0x00 },  /* Ѐ to E */\n  { 0x0401,  0x45, 0x00 },  /* Ё to E */\n  { 0x0402,  0x44, 0x00 },  /* Ђ to D */\n  { 0x0403,  0x47, 0x00 },  /* Ѓ to G */\n  { 0x0404,  0x45, 0x00 },  /* Є to E */\n  { 0x0405,  0x5a, 0x00 },  /* Ѕ to Z */\n  { 0x0406,  0x49, 0x00 },  /* І to I */\n  { 0x0407,  0x49, 0x00 },  /* Ї to I */\n  { 0x0408,  0x4a, 0x00 },  /* Ј to J */\n  { 0x0409,  0x49, 0x00 },  /* Љ to I */\n  { 0x040A,  0x4e, 0x00 },  /* Њ to N */\n  { 0x040B,  0x44, 0x00 },  /* Ћ to D */\n  { 0x040C,  0x4b, 0x00 },  /* Ќ to K */\n  { 0x040D,  0x49, 0x00 },  /* Ѝ to I */\n  { 0x040E,  0x55, 0x00 },  /* Ў to U */\n  { 0x040F,  0x44, 0x00 },  /* Џ to D */\n  { 0x0410,  0x41, 0x00 },  /* А to A */\n  { 0x0411,  0x42, 0x00 },  /* Б to B */\n  { 0x0412,  0x56, 0x00 },  /* В to V */\n  { 0x0413,  0x47, 0x00 },  /* Г to G */\n  { 0x0414,  0x44, 0x00 },  /* Д to D */\n  { 0x0415,  0x45, 0x00 },  /* Е to E */\n  { 0x0416,  0x5a, 0x68 },  /* Ж to Zh */\n  { 0x0417,  0x5a, 0x00 },  /* З to Z */\n  { 0x0418,  0x49, 0x00 },  /* И to I */\n  { 0x0419,  0x49, 0x00 },  /* Й to I */\n  { 0x041A,  0x4b, 0x00 },  /* К to K */\n  { 0x041B,  0x4c, 0x00 },  /* Л to L */\n  { 0x041C,  0x4d, 0x00 },  /* М to M */\n  { 0x041D,  0x4e, 0x00 },  /* Н to N */\n  { 0x041E,  0x4f, 0x00 },  /* О to O */\n  { 0x041F,  0x50, 0x00 },  /* П to P */\n  { 0x0420,  0x52, 0x00 },  /* Р to R */\n  { 0x0421,  0x53, 0x00 },  /* С to S */\n  { 0x0422,  0x54, 0x00 },  /* Т to T */\n  { 0x0423,  0x55, 0x00 },  /* У to U */\n  { 0x0424,  0x46, 0x00 },  /* Ф to F */\n  { 0x0425,  0x4b, 0x68 },  /* Х to Kh */\n  { 0x0426,  0x54, 0x63 },  /* Ц to Tc */\n  { 0x0427,  0x43, 0x68 },  /* Ч to Ch */\n  { 0x0428,  0x53, 0x68 },  /* Ш to Sh */\n  { 0x0429,  0x53, 0x68 },  /* Щ to Shch */\n  { 0x042A,  0x61, 0x00 },  /*  to A */\n  { 0x042B,  0x59, 0x00 },  /* Ы to Y */\n  { 0x042C,  0x59, 0x00 },  /*  to Y */\n  { 0x042D,  0x45, 0x00 },  /* Э to E */\n  { 0x042E,  0x49, 0x75 },  /* Ю to Iu */\n  { 0x042F,  0x49, 0x61 },  /* Я to Ia */\n  { 0x0430,  0x61, 0x00 },  /* а to a */\n  { 0x0431,  0x62, 0x00 },  /* б to b */\n  { 0x0432,  0x76, 0x00 },  /* в to v */\n  { 0x0433,  0x67, 0x00 },  /* г to g */\n  { 0x0434,  0x64, 0x00 },  /* д to d */\n  { 0x0435,  0x65, 0x00 },  /* е to e */\n  { 0x0436,  0x7a, 0x68 },  /* ж to zh */\n  { 0x0437,  0x7a, 0x00 },  /* з to z */\n  { 0x0438,  0x69, 0x00 },  /* и to i */\n  { 0x0439,  0x69, 0x00 },  /* й to i */\n  { 0x043A,  0x6b, 0x00 },  /* к to k */\n  { 0x043B,  0x6c, 0x00 },  /* л to l */\n  { 0x043C,  0x6d, 0x00 },  /* м to m */\n  { 0x043D,  0x6e, 0x00 },  /* н to n */\n  { 0x043E,  0x6f, 0x00 },  /* о to o */\n  { 0x043F,  0x70, 0x00 },  /* п to p */\n  { 0x0440,  0x72, 0x00 },  /* р to r */\n  { 0x0441,  0x73, 0x00 },  /* с to s */\n  { 0x0442,  0x74, 0x00 },  /* т to t */\n  { 0x0443,  0x75, 0x00 },  /* у to u */\n  { 0x0444,  0x66, 0x00 },  /* ф to f */\n  { 0x0445,  0x6b, 0x68 },  /* х to kh */\n  { 0x0446,  0x74, 0x63 },  /* ц to tc */\n  { 0x0447,  0x63, 0x68 },  /* ч to ch */\n  { 0x0448,  0x73, 0x68 },  /* ш to sh */\n  { 0x0449,  0x73, 0x68 },  /* щ to shch */\n  { 0x044A,  0x61, 0x00 },  /*  to a */\n  { 0x044B,  0x79, 0x00 },  /* ы to y */\n  { 0x044C,  0x79, 0x00 },  /*  to y */\n  { 0x044D,  0x65, 0x00 },  /* э to e */\n  { 0x044E,  0x69, 0x75 },  /* ю to iu */\n  { 0x044F,  0x69, 0x61 },  /* я to ia */\n  { 0x0450,  0x65, 0x00 },  /* ѐ to e */\n  { 0x0451,  0x65, 0x00 },  /* ё to e */\n  { 0x0452,  0x64, 0x00 },  /* ђ to d */\n  { 0x0453,  0x67, 0x00 },  /* ѓ to g */\n  { 0x0454,  0x65, 0x00 },  /* є to e */\n  { 0x0455,  0x7a, 0x00 },  /* ѕ to z */\n  { 0x0456,  0x69, 0x00 },  /* і to i */\n  { 0x0457,  0x69, 0x00 },  /* ї to i */\n  { 0x0458,  0x6a, 0x00 },  /* ј to j */\n  { 0x0459,  0x69, 0x00 },  /* љ to i */\n  { 0x045A,  0x6e, 0x00 },  /* њ to n */\n  { 0x045B,  0x64, 0x00 },  /* ћ to d */\n  { 0x045C,  0x6b, 0x00 },  /* ќ to k */\n  { 0x045D,  0x69, 0x00 },  /* ѝ to i */\n  { 0x045E,  0x75, 0x00 },  /* ў to u */\n  { 0x045F,  0x64, 0x00 },  /* џ to d */\n  { 0x1E02,  0x42, 0x00 },  /* Ḃ to B */\n  { 0x1E03,  0x62, 0x00 },  /* ḃ to b */\n  { 0x1E0A,  0x44, 0x00 },  /* Ḋ to D */\n  { 0x1E0B,  0x64, 0x00 },  /* ḋ to d */\n  { 0x1E1E,  0x46, 0x00 },  /* Ḟ to F */\n  { 0x1E1F,  0x66, 0x00 },  /* ḟ to f */\n  { 0x1E40,  0x4D, 0x00 },  /* Ṁ to M */\n  { 0x1E41,  0x6D, 0x00 },  /* ṁ to m */\n  { 0x1E56,  0x50, 0x00 },  /* Ṗ to P */\n  { 0x1E57,  0x70, 0x00 },  /* ṗ to p */\n  { 0x1E60,  0x53, 0x00 },  /* Ṡ to S */\n  { 0x1E61,  0x73, 0x00 },  /* ṡ to s */\n  { 0x1E6A,  0x54, 0x00 },  /* Ṫ to T */\n  { 0x1E6B,  0x74, 0x00 },  /* ṫ to t */\n  { 0x1E80,  0x57, 0x00 },  /* Ẁ to W */\n  { 0x1E81,  0x77, 0x00 },  /* ẁ to w */\n  { 0x1E82,  0x57, 0x00 },  /* Ẃ to W */\n  { 0x1E83,  0x77, 0x00 },  /* ẃ to w */\n  { 0x1E84,  0x57, 0x00 },  /* Ẅ to W */\n  { 0x1E85,  0x77, 0x00 },  /* ẅ to w */\n  { 0x1EF2,  0x59, 0x00 },  /* Ỳ to Y */\n  { 0x1EF3,  0x79, 0x00 },  /* ỳ to y */\n  { 0xFB00,  0x66, 0x66 },  /* ﬀ to ff */\n  { 0xFB01,  0x66, 0x69 },  /* ﬁ to fi */\n  { 0xFB02,  0x66, 0x6C },  /* ﬂ to fl */\n  { 0xFB05,  0x73, 0x74 },  /* ﬅ to st */\n  { 0xFB06,  0x73, 0x74 },  /* ﬆ to st */\n};\n\n/*\n** Convert the input string from UTF-8 into pure ASCII by converting\n** all non-ASCII characters to some combination of characters in the\n** ASCII subset.\n**\n** The returned string might contain more characters than the input.\n**\n** Space to hold the returned string comes from sqlite3_malloc() and\n** should be freed by the caller.\n*/\nstatic unsigned char *transliterate(const unsigned char *zIn, int nIn){\n  unsigned char *zOut = sqlite3_malloc64( nIn*4 + 1 );\n  int c, sz, nOut;\n  if( zOut==0 ) return 0;\n  nOut = 0;\n  while( nIn>0 ){\n    c = utf8Read(zIn, nIn, &sz);\n    zIn += sz;\n    nIn -= sz;\n    if( c<=127 ){\n      zOut[nOut++] = (unsigned char)c;\n    }else{\n      int xTop, xBtm, x;\n      xTop = sizeof(translit)/sizeof(translit[0]) - 1;\n      xBtm = 0;\n      while( xTop>=xBtm ){\n        x = (xTop + xBtm)/2;\n        if( translit[x].cFrom==c ){\n          zOut[nOut++] = translit[x].cTo0;\n          if( translit[x].cTo1 ){\n            zOut[nOut++] = translit[x].cTo1;\n            /* Add an extra \"ch\" after the \"sh\" for Щ and щ */\n            if( c==0x0429 || c== 0x0449 ){\n              zOut[nOut++] = 'c';\n              zOut[nOut++] = 'h';\n            }\n          }\n          c = 0;\n          break;\n        }else if( translit[x].cFrom>c ){\n          xTop = x-1;\n        }else{\n          xBtm = x+1;\n        }\n      }\n      if( c ) zOut[nOut++] = '?';\n    }\n  }\n  zOut[nOut] = 0;\n  return zOut;\n}\n\n/*\n** Return the number of characters in the shortest prefix of the input\n** string that transliterates to an ASCII string nTrans bytes or longer.\n** Or, if the transliteration of the input string is less than nTrans\n** bytes in size, return the number of characters in the input string.\n*/\nstatic int translen_to_charlen(const char *zIn, int nIn, int nTrans){\n  int i, c, sz, nOut;\n  int nChar;\n\n  i = nOut = 0;\n  for(nChar=0; i<nIn && nOut<nTrans; nChar++){\n    c = utf8Read((const unsigned char *)&zIn[i], nIn-i, &sz);\n    i += sz;\n\n    nOut++;\n    if( c>=128 ){\n      int xTop, xBtm, x;\n      xTop = sizeof(translit)/sizeof(translit[0]) - 1;\n      xBtm = 0;\n      while( xTop>=xBtm ){\n        x = (xTop + xBtm)/2;\n        if( translit[x].cFrom==c ){\n          if( translit[x].cTo1 ) nOut++;\n          if( c==0x0429 || c== 0x0449 ) nOut += 2;\n          break;\n        }else if( translit[x].cFrom>c ){\n          xTop = x-1;\n        }else{\n          xBtm = x+1;\n        }\n      }\n    }\n  }\n\n  return nChar;\n}\n\n\n/*\n**    spellfix1_translit(X)\n**\n** Convert a string that contains non-ASCII Roman characters into \n** pure ASCII.\n*/\nstatic void transliterateSqlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn = sqlite3_value_text(argv[0]);\n  int nIn = sqlite3_value_bytes(argv[0]);\n  unsigned char *zOut = transliterate(zIn, nIn);\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free);\n  }\n}\n\n/*\n**    spellfix1_scriptcode(X)\n**\n** Try to determine the dominant script used by the word X and return\n** its ISO 15924 numeric code.\n**\n** The current implementation only understands the following scripts:\n**\n**    215  (Latin)\n**    220  (Cyrillic)\n**    200  (Greek)\n**\n** This routine will return 998 if the input X contains characters from\n** two or more of the above scripts or 999 if X contains no characters\n** from any of the above scripts.\n*/\nstatic void scriptCodeSqlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn = sqlite3_value_text(argv[0]);\n  int nIn = sqlite3_value_bytes(argv[0]);\n  int c, sz;\n  int scriptMask = 0;\n  int res;\n  int seenDigit = 0;\n# define SCRIPT_LATIN       0x0001\n# define SCRIPT_CYRILLIC    0x0002\n# define SCRIPT_GREEK       0x0004\n# define SCRIPT_HEBREW      0x0008\n# define SCRIPT_ARABIC      0x0010\n\n  while( nIn>0 ){\n    c = utf8Read(zIn, nIn, &sz);\n    zIn += sz;\n    nIn -= sz;\n    if( c<0x02af ){\n      if( c>=0x80 || midClass[c&0x7f]<CCLASS_DIGIT ){\n        scriptMask |= SCRIPT_LATIN;\n      }else if( c>='0' && c<='9' ){\n        seenDigit = 1;\n      }\n    }else if( c>=0x0400 && c<=0x04ff ){\n      scriptMask |= SCRIPT_CYRILLIC;\n    }else if( c>=0x0386 && c<=0x03ce ){\n      scriptMask |= SCRIPT_GREEK;\n    }else if( c>=0x0590 && c<=0x05ff ){\n      scriptMask |= SCRIPT_HEBREW;\n    }else if( c>=0x0600 && c<=0x06ff ){\n      scriptMask |= SCRIPT_ARABIC;\n    }\n  }\n  if( scriptMask==0 && seenDigit ) scriptMask = SCRIPT_LATIN;\n  switch( scriptMask ){\n    case 0:                res = 999; break;\n    case SCRIPT_LATIN:     res = 215; break;\n    case SCRIPT_CYRILLIC:  res = 220; break;\n    case SCRIPT_GREEK:     res = 200; break;\n    case SCRIPT_HEBREW:    res = 125; break;\n    case SCRIPT_ARABIC:    res = 160; break;\n    default:               res = 998; break;\n  }\n  sqlite3_result_int(context, res);\n}\n\n/* End transliterate\n******************************************************************************\n******************************************************************************\n** Begin spellfix1 virtual table.\n*/\n\n/* Maximum length of a phonehash used for querying the shadow table */\n#define SPELLFIX_MX_HASH  32\n\n/* Maximum number of hash strings to examine per query */\n#define SPELLFIX_MX_RUN   1\n\ntypedef struct spellfix1_vtab spellfix1_vtab;\ntypedef struct spellfix1_cursor spellfix1_cursor;\n\n/* Fuzzy-search virtual table object */\nstruct spellfix1_vtab {\n  sqlite3_vtab base;         /* Base class - must be first */\n  sqlite3 *db;               /* Database connection */\n  char *zDbName;             /* Name of database holding this table */\n  char *zTableName;          /* Name of the virtual table */\n  char *zCostTable;          /* Table holding edit-distance cost numbers */\n  EditDist3Config *pConfig3; /* Parsed edit distance costs */\n};\n\n/* Fuzzy-search cursor object */\nstruct spellfix1_cursor {\n  sqlite3_vtab_cursor base;    /* Base class - must be first */\n  spellfix1_vtab *pVTab;       /* The table to which this cursor belongs */\n  char *zPattern;              /* rhs of MATCH clause */\n  int idxNum;                  /* idxNum value passed to xFilter() */\n  int nRow;                    /* Number of rows of content */\n  int nAlloc;                  /* Number of allocated rows */\n  int iRow;                    /* Current row of content */\n  int iLang;                   /* Value of the langid= constraint */\n  int iTop;                    /* Value of the top= constraint */\n  int iScope;                  /* Value of the scope= constraint */\n  int nSearch;                 /* Number of vocabulary items checked */\n  sqlite3_stmt *pFullScan;     /* Shadow query for a full table scan */\n  struct spellfix1_row {       /* For each row of content */\n    sqlite3_int64 iRowid;         /* Rowid for this row */\n    char *zWord;                  /* Text for this row */\n    int iRank;                    /* Rank for this row */\n    int iDistance;                /* Distance from pattern for this row */\n    int iScore;                   /* Score for sorting */\n    int iMatchlen;                /* Value of matchlen column (or -1) */\n    char zHash[SPELLFIX_MX_HASH]; /* the phonehash used for this match */\n  } *a; \n};\n\n/*\n** Construct one or more SQL statements from the format string given\n** and then evaluate those statements. The success code is written\n** into *pRc.\n**\n** If *pRc is initially non-zero then this routine is a no-op.\n*/\nstatic void spellfix1DbExec(\n  int *pRc,              /* Success code */\n  sqlite3 *db,           /* Database in which to run SQL */\n  const char *zFormat,   /* Format string for SQL */\n  ...                    /* Arguments to the format string */\n){\n  va_list ap;\n  char *zSql;\n  if( *pRc ) return;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    *pRc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n}\n\n/*\n** xDisconnect/xDestroy method for the fuzzy-search module.\n*/\nstatic int spellfix1Uninit(int isDestroy, sqlite3_vtab *pVTab){\n  spellfix1_vtab *p = (spellfix1_vtab*)pVTab;\n  int rc = SQLITE_OK;\n  if( isDestroy ){\n    sqlite3 *db = p->db;\n    spellfix1DbExec(&rc, db, \"DROP TABLE IF EXISTS \\\"%w\\\".\\\"%w_vocab\\\"\",\n                  p->zDbName, p->zTableName);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_free(p->zTableName);\n    editDist3ConfigDelete(p->pConfig3);\n    sqlite3_free(p->zCostTable);\n    sqlite3_free(p);\n  }\n  return rc;\n}\nstatic int spellfix1Disconnect(sqlite3_vtab *pVTab){\n  return spellfix1Uninit(0, pVTab);\n}\nstatic int spellfix1Destroy(sqlite3_vtab *pVTab){\n  return spellfix1Uninit(1, pVTab);\n}\n\n/*\n** Make a copy of a string.  Remove leading and trailing whitespace\n** and dequote it.\n*/\nstatic char *spellfix1Dequote(const char *zIn){\n  char *zOut;\n  int i, j;\n  char c;\n  while( isspace((unsigned char)zIn[0]) ) zIn++;\n  zOut = sqlite3_mprintf(\"%s\", zIn);\n  if( zOut==0 ) return 0;\n  i = (int)strlen(zOut);\n#if 0  /* The parser will never leave spaces at the end */\n  while( i>0 && isspace(zOut[i-1]) ){ i--; }\n#endif\n  zOut[i] = 0;\n  c = zOut[0];\n  if( c=='\\'' || c=='\"' ){\n    for(i=1, j=0; ALWAYS(zOut[i]); i++){\n      zOut[j++] = zOut[i];\n      if( zOut[i]==c ){\n        if( zOut[i+1]==c ){\n          i++;\n        }else{\n          zOut[j-1] = 0;\n          break;\n        }\n      }\n    }\n  }\n  return zOut;\n}\n\n\n/*\n** xConnect/xCreate method for the spellfix1 module. Arguments are:\n**\n**   argv[0]   -> module name  (\"spellfix1\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[3].. -> optional arguments (i.e. \"edit_cost_table\" parameter)\n*/\nstatic int spellfix1Init(\n  int isCreate,\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  spellfix1_vtab *pNew = 0;\n  /* const char *zModule = argv[0]; // not used */\n  const char *zDbName = argv[1];\n  const char *zTableName = argv[2];\n  int nDbName;\n  int rc = SQLITE_OK;\n  int i;\n\n  nDbName = (int)strlen(zDbName);\n  pNew = sqlite3_malloc64( sizeof(*pNew) + nDbName + 1);\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->zDbName = (char*)&pNew[1];\n    memcpy(pNew->zDbName, zDbName, nDbName+1);\n    pNew->zTableName = sqlite3_mprintf(\"%s\", zTableName);\n    pNew->db = db;\n    if( pNew->zTableName==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_declare_vtab(db, \n           \"CREATE TABLE x(word,rank,distance,langid, \"\n           \"score, matchlen, phonehash HIDDEN, \"\n           \"top HIDDEN, scope HIDDEN, srchcnt HIDDEN, \"\n           \"soundslike HIDDEN, command HIDDEN)\"\n      );\n#define SPELLFIX_COL_WORD            0\n#define SPELLFIX_COL_RANK            1\n#define SPELLFIX_COL_DISTANCE        2\n#define SPELLFIX_COL_LANGID          3\n#define SPELLFIX_COL_SCORE           4\n#define SPELLFIX_COL_MATCHLEN        5\n#define SPELLFIX_COL_PHONEHASH       6\n#define SPELLFIX_COL_TOP             7\n#define SPELLFIX_COL_SCOPE           8\n#define SPELLFIX_COL_SRCHCNT         9\n#define SPELLFIX_COL_SOUNDSLIKE     10\n#define SPELLFIX_COL_COMMAND        11\n    }\n    if( rc==SQLITE_OK && isCreate ){\n      spellfix1DbExec(&rc, db,\n         \"CREATE TABLE IF NOT EXISTS \\\"%w\\\".\\\"%w_vocab\\\"(\\n\"\n         \"  id INTEGER PRIMARY KEY,\\n\"\n         \"  rank INT,\\n\"\n         \"  langid INT,\\n\"\n         \"  word TEXT,\\n\"\n         \"  k1 TEXT,\\n\"\n         \"  k2 TEXT\\n\"\n         \");\\n\",\n         zDbName, zTableName\n      );\n      spellfix1DbExec(&rc, db,\n         \"CREATE INDEX IF NOT EXISTS \\\"%w\\\".\\\"%w_vocab_index_langid_k2\\\" \"\n            \"ON \\\"%w_vocab\\\"(langid,k2);\",\n         zDbName, zTableName, zTableName\n      );\n    }\n    for(i=3; rc==SQLITE_OK && i<argc; i++){\n      if( strncmp(argv[i],\"edit_cost_table=\",16)==0 && pNew->zCostTable==0 ){\n        pNew->zCostTable = spellfix1Dequote(&argv[i][16]);\n        if( pNew->zCostTable==0 ) rc = SQLITE_NOMEM;\n        continue;\n      }\n      *pzErr = sqlite3_mprintf(\"bad argument to spellfix1(): \\\"%s\\\"\", argv[i]);\n      rc = SQLITE_ERROR; \n    }\n  }\n\n  if( rc && pNew ){\n    *ppVTab = 0;\n    spellfix1Uninit(0, &pNew->base);\n  }else{\n    *ppVTab = (sqlite3_vtab *)pNew;\n  }\n  return rc;\n}\n\n/*\n** The xConnect and xCreate methods\n*/\nstatic int spellfix1Connect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  return spellfix1Init(0, db, pAux, argc, argv, ppVTab, pzErr);\n}\nstatic int spellfix1Create(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVTab,\n  char **pzErr\n){\n  return spellfix1Init(1, db, pAux, argc, argv, ppVTab, pzErr);\n}\n\n/*\n** Clear all of the content from a cursor.\n*/\nstatic void spellfix1ResetCursor(spellfix1_cursor *pCur){\n  int i;\n  for(i=0; i<pCur->nRow; i++){\n    sqlite3_free(pCur->a[i].zWord);\n  }\n  pCur->nRow = 0;\n  pCur->iRow = 0;\n  pCur->nSearch = 0;\n  if( pCur->pFullScan ){\n    sqlite3_finalize(pCur->pFullScan);\n    pCur->pFullScan = 0;\n  }\n}\n\n/*\n** Resize the cursor to hold up to N rows of content\n*/\nstatic void spellfix1ResizeCursor(spellfix1_cursor *pCur, int N){\n  struct spellfix1_row *aNew;\n  assert( N>=pCur->nRow );\n  aNew = sqlite3_realloc64(pCur->a, sizeof(pCur->a[0])*N);\n  if( aNew==0 && N>0 ){\n    spellfix1ResetCursor(pCur);\n    sqlite3_free(pCur->a);\n    pCur->nAlloc = 0;\n    pCur->a = 0;\n  }else{\n    pCur->nAlloc = N;\n    pCur->a = aNew;\n  }\n}\n\n\n/*\n** Close a fuzzy-search cursor.\n*/\nstatic int spellfix1Close(sqlite3_vtab_cursor *cur){\n  spellfix1_cursor *pCur = (spellfix1_cursor *)cur;\n  spellfix1ResetCursor(pCur);\n  spellfix1ResizeCursor(pCur, 0);\n  sqlite3_free(pCur->zPattern);\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n#define SPELLFIX_IDXNUM_MATCH  0x01         /* word MATCH $str */\n#define SPELLFIX_IDXNUM_LANGID 0x02         /* langid == $langid */\n#define SPELLFIX_IDXNUM_TOP    0x04         /* top = $top */\n#define SPELLFIX_IDXNUM_SCOPE  0x08         /* scope = $scope */\n#define SPELLFIX_IDXNUM_DISTLT 0x10         /* distance < $distance */\n#define SPELLFIX_IDXNUM_DISTLE 0x20         /* distance <= $distance */\n#define SPELLFIX_IDXNUM_ROWID  0x40         /* rowid = $rowid */\n#define SPELLFIX_IDXNUM_DIST   (0x10|0x20)  /* DISTLT and DISTLE */\n\n/*\n**\n** The plan number is a bitmask of the SPELLFIX_IDXNUM_* values defined\n** above.\n**\n** filter.argv[*] values contains $str, $langid, $top, $scope and $rowid\n** if specified and in that order.\n*/\nstatic int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int iPlan = 0;\n  int iLangTerm = -1;\n  int iTopTerm = -1;\n  int iScopeTerm = -1;\n  int iDistTerm = -1;\n  int iRowidTerm = -1;\n  int i;\n  const struct sqlite3_index_constraint *pConstraint;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n\n    /* Terms of the form:  word MATCH $str */\n    if( (iPlan & SPELLFIX_IDXNUM_MATCH)==0 \n     && pConstraint->iColumn==SPELLFIX_COL_WORD\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_MATCH\n    ){\n      iPlan |= SPELLFIX_IDXNUM_MATCH;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n    }\n\n    /* Terms of the form:  langid = $langid  */\n    if( (iPlan & SPELLFIX_IDXNUM_LANGID)==0\n     && pConstraint->iColumn==SPELLFIX_COL_LANGID\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= SPELLFIX_IDXNUM_LANGID;\n      iLangTerm = i;\n    }\n\n    /* Terms of the form:  top = $top */\n    if( (iPlan & SPELLFIX_IDXNUM_TOP)==0\n     && pConstraint->iColumn==SPELLFIX_COL_TOP\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= SPELLFIX_IDXNUM_TOP;\n      iTopTerm = i;\n    }\n\n    /* Terms of the form:  scope = $scope */\n    if( (iPlan & SPELLFIX_IDXNUM_SCOPE)==0\n     && pConstraint->iColumn==SPELLFIX_COL_SCOPE\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= SPELLFIX_IDXNUM_SCOPE;\n      iScopeTerm = i;\n    }\n\n    /* Terms of the form:  distance < $dist or distance <= $dist */\n    if( (iPlan & SPELLFIX_IDXNUM_DIST)==0\n     && pConstraint->iColumn==SPELLFIX_COL_DISTANCE\n     && (pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT\n          || pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE)\n    ){\n      if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ){\n        iPlan |= SPELLFIX_IDXNUM_DISTLT;\n      }else{\n        iPlan |= SPELLFIX_IDXNUM_DISTLE;\n      }\n      iDistTerm = i;\n    }\n\n    /* Terms of the form:  distance < $dist or distance <= $dist */\n    if( (iPlan & SPELLFIX_IDXNUM_ROWID)==0\n     && pConstraint->iColumn<0\n     && pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ\n    ){\n      iPlan |= SPELLFIX_IDXNUM_ROWID;\n      iRowidTerm = i;\n    }\n  }\n  if( iPlan&SPELLFIX_IDXNUM_MATCH ){\n    int idx = 2;\n    pIdxInfo->idxNum = iPlan;\n    if( pIdxInfo->nOrderBy==1\n     && pIdxInfo->aOrderBy[0].iColumn==SPELLFIX_COL_SCORE\n     && pIdxInfo->aOrderBy[0].desc==0\n    ){\n      pIdxInfo->orderByConsumed = 1;  /* Default order by iScore */\n    }\n    if( iPlan&SPELLFIX_IDXNUM_LANGID ){\n      pIdxInfo->aConstraintUsage[iLangTerm].argvIndex = idx++;\n      pIdxInfo->aConstraintUsage[iLangTerm].omit = 1;\n    }\n    if( iPlan&SPELLFIX_IDXNUM_TOP ){\n      pIdxInfo->aConstraintUsage[iTopTerm].argvIndex = idx++;\n      pIdxInfo->aConstraintUsage[iTopTerm].omit = 1;\n    }\n    if( iPlan&SPELLFIX_IDXNUM_SCOPE ){\n      pIdxInfo->aConstraintUsage[iScopeTerm].argvIndex = idx++;\n      pIdxInfo->aConstraintUsage[iScopeTerm].omit = 1;\n    }\n    if( iPlan&SPELLFIX_IDXNUM_DIST ){\n      pIdxInfo->aConstraintUsage[iDistTerm].argvIndex = idx++;\n      pIdxInfo->aConstraintUsage[iDistTerm].omit = 1;\n    }\n    pIdxInfo->estimatedCost = 1e5;\n  }else if( (iPlan & SPELLFIX_IDXNUM_ROWID) ){\n    pIdxInfo->idxNum = SPELLFIX_IDXNUM_ROWID;\n    pIdxInfo->aConstraintUsage[iRowidTerm].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[iRowidTerm].omit = 1;\n    pIdxInfo->estimatedCost = 5;\n  }else{\n    pIdxInfo->idxNum = 0;\n    pIdxInfo->estimatedCost = 1e50;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Open a new fuzzy-search cursor.\n*/\nstatic int spellfix1Open(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  spellfix1_vtab *p = (spellfix1_vtab*)pVTab;\n  spellfix1_cursor *pCur;\n  pCur = sqlite3_malloc64( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->pVTab = p;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Adjust a distance measurement by the words rank in order to show\n** preference to common words.\n*/\nstatic int spellfix1Score(int iDistance, int iRank){\n  int iLog2;\n  for(iLog2=0; iRank>0; iLog2++, iRank>>=1){}\n  return iDistance + 32 - iLog2;\n}\n\n/*\n** Compare two spellfix1_row objects for sorting purposes in qsort() such\n** that they sort in order of increasing distance.\n*/\nstatic int SQLITE_CDECL spellfix1RowCompare(const void *A, const void *B){\n  const struct spellfix1_row *a = (const struct spellfix1_row*)A;\n  const struct spellfix1_row *b = (const struct spellfix1_row*)B;\n  return a->iScore - b->iScore;\n}\n\n/*\n** A structure used to pass information from spellfix1FilterForMatch()\n** into spellfix1RunQuery().\n*/\ntypedef struct MatchQuery {\n  spellfix1_cursor *pCur;          /* The cursor being queried */\n  sqlite3_stmt *pStmt;             /* shadow table query statment */\n  char zHash[SPELLFIX_MX_HASH];    /* The current phonehash for zPattern */\n  const char *zPattern;            /* Transliterated input string */\n  int nPattern;                    /* Length of zPattern */\n  EditDist3FromString *pMatchStr3; /* Original unicode string */\n  EditDist3Config *pConfig3;       /* Edit-distance cost coefficients */\n  const EditDist3Lang *pLang;      /* The selected language coefficients */\n  int iLang;                       /* The language id */\n  int iScope;                      /* Default scope */\n  int iMaxDist;                    /* Maximum allowed edit distance, or -1 */\n  int rc;                          /* Error code */\n  int nRun;                  /* Number of prior runs for the same zPattern */\n  char azPrior[SPELLFIX_MX_RUN][SPELLFIX_MX_HASH];  /* Prior hashes */\n} MatchQuery;\n\n/*\n** Run a query looking for the best matches against zPattern using\n** zHash as the character class seed hash.\n*/\nstatic void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){\n  const char *zK1;\n  const char *zWord;\n  int iDist;\n  int iRank;\n  int iScore;\n  int iWorst = 0;\n  int idx;\n  int idxWorst = -1;\n  int i;\n  int iScope = p->iScope;\n  spellfix1_cursor *pCur = p->pCur;\n  sqlite3_stmt *pStmt = p->pStmt;\n  char zHash1[SPELLFIX_MX_HASH];\n  char zHash2[SPELLFIX_MX_HASH];\n  char *zClass;\n  int nClass;\n  int rc;\n\n  if( pCur->a==0 || p->rc ) return;   /* Prior memory allocation failure */\n  zClass = (char*)phoneticHash((unsigned char*)zQuery, nQuery);\n  if( zClass==0 ){\n    p->rc = SQLITE_NOMEM;\n    return;\n  }\n  nClass = (int)strlen(zClass);\n  if( nClass>SPELLFIX_MX_HASH-2 ){\n    nClass = SPELLFIX_MX_HASH-2;\n    zClass[nClass] = 0;\n  }\n  if( nClass<=iScope ){\n    if( nClass>2 ){\n      iScope = nClass-1;\n    }else{\n      iScope = nClass;\n    }\n  }\n  memcpy(zHash1, zClass, iScope);\n  sqlite3_free(zClass);\n  zHash1[iScope] = 0;\n  memcpy(zHash2, zHash1, iScope);\n  zHash2[iScope] = 'Z';\n  zHash2[iScope+1] = 0;\n#if SPELLFIX_MX_RUN>1\n  for(i=0; i<p->nRun; i++){\n    if( strcmp(p->azPrior[i], zHash1)==0 ) return;\n  }\n#endif\n  assert( p->nRun<SPELLFIX_MX_RUN );\n  memcpy(p->azPrior[p->nRun++], zHash1, iScope+1);\n  if( sqlite3_bind_text(pStmt, 1, zHash1, -1, SQLITE_STATIC)==SQLITE_NOMEM\n   || sqlite3_bind_text(pStmt, 2, zHash2, -1, SQLITE_STATIC)==SQLITE_NOMEM\n  ){\n    p->rc = SQLITE_NOMEM;\n    return;\n  }\n#if SPELLFIX_MX_RUN>1\n  for(i=0; i<pCur->nRow; i++){\n    if( pCur->a[i].iScore>iWorst ){\n      iWorst = pCur->a[i].iScore;\n      idxWorst = i;\n    }\n  }\n#endif\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int iMatchlen = -1;\n    iRank = sqlite3_column_int(pStmt, 2);\n    if( p->pMatchStr3 ){\n      int nWord = sqlite3_column_bytes(pStmt, 1);\n      zWord = (const char*)sqlite3_column_text(pStmt, 1);\n      iDist = editDist3Core(p->pMatchStr3, zWord, nWord, p->pLang, &iMatchlen);\n    }else{\n      zK1 = (const char*)sqlite3_column_text(pStmt, 3);\n      if( zK1==0 ) continue;\n      iDist = editdist1(p->zPattern, zK1, 0);\n    }\n    if( iDist<0 ){\n      p->rc = SQLITE_NOMEM;\n      break;\n    }\n    pCur->nSearch++;\n    \n    /* If there is a \"distance < $dist\" or \"distance <= $dist\" constraint,\n    ** check if this row meets it. If not, jump back up to the top of the\n    ** loop to process the next row. Otherwise, if the row does match the\n    ** distance constraint, check if the pCur->a[] array is already full.\n    ** If it is and no explicit \"top = ?\" constraint was present in the\n    ** query, grow the array to ensure there is room for the new entry. */\n    assert( (p->iMaxDist>=0)==((pCur->idxNum & SPELLFIX_IDXNUM_DIST) ? 1 : 0) );\n    if( p->iMaxDist>=0 ){\n      if( iDist>p->iMaxDist ) continue;\n      if( pCur->nRow>=pCur->nAlloc && (pCur->idxNum & SPELLFIX_IDXNUM_TOP)==0 ){\n        spellfix1ResizeCursor(pCur, pCur->nAlloc*2 + 10);\n        if( pCur->a==0 ) break;\n      }\n    }\n\n    iScore = spellfix1Score(iDist,iRank);\n    if( pCur->nRow<pCur->nAlloc ){\n      idx = pCur->nRow;\n    }else if( iScore<iWorst ){\n      idx = idxWorst;\n      sqlite3_free(pCur->a[idx].zWord);\n    }else{\n      continue;\n    }\n\n    pCur->a[idx].zWord = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 1));\n    if( pCur->a[idx].zWord==0 ){\n      p->rc = SQLITE_NOMEM;\n      break;\n    }\n    pCur->a[idx].iRowid = sqlite3_column_int64(pStmt, 0);\n    pCur->a[idx].iRank = iRank;\n    pCur->a[idx].iDistance = iDist;\n    pCur->a[idx].iScore = iScore;\n    pCur->a[idx].iMatchlen = iMatchlen;\n    memcpy(pCur->a[idx].zHash, zHash1, iScope+1);\n    if( pCur->nRow<pCur->nAlloc ) pCur->nRow++;\n    if( pCur->nRow==pCur->nAlloc ){\n      iWorst = pCur->a[0].iScore;\n      idxWorst = 0;\n      for(i=1; i<pCur->nRow; i++){\n        iScore = pCur->a[i].iScore;\n        if( iWorst<iScore ){\n          iWorst = iScore;\n          idxWorst = i;\n        }\n      }\n    }\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc ) p->rc = rc;\n}\n\n/*\n** This version of the xFilter method work if the MATCH term is present\n** and we are doing a scan.\n*/\nstatic int spellfix1FilterForMatch(\n  spellfix1_cursor *pCur,\n  int argc,\n  sqlite3_value **argv\n){\n  int idxNum = pCur->idxNum;\n  const unsigned char *zMatchThis;   /* RHS of the MATCH operator */\n  EditDist3FromString *pMatchStr3 = 0; /* zMatchThis as an editdist string */\n  char *zPattern;                    /* Transliteration of zMatchThis */\n  int nPattern;                      /* Length of zPattern */\n  int iLimit = 20;                   /* Max number of rows of output */\n  int iScope = 3;                    /* Use this many characters of zClass */\n  int iLang = 0;                     /* Language code */\n  char *zSql;                        /* SQL of shadow table query */\n  sqlite3_stmt *pStmt = 0;           /* Shadow table query */\n  int rc;                            /* Result code */\n  int idx = 1;                       /* Next available filter parameter */\n  spellfix1_vtab *p = pCur->pVTab;   /* The virtual table that owns pCur */\n  MatchQuery x;                      /* For passing info to RunQuery() */\n\n  /* Load the cost table if we have not already done so */\n  if( p->zCostTable!=0 && p->pConfig3==0 ){\n    p->pConfig3 = sqlite3_malloc64( sizeof(p->pConfig3[0]) );\n    if( p->pConfig3==0 ) return SQLITE_NOMEM;\n    memset(p->pConfig3, 0, sizeof(p->pConfig3[0]));\n    rc = editDist3ConfigLoad(p->pConfig3, p->db, p->zCostTable);\n    if( rc ) return rc;\n  }\n  memset(&x, 0, sizeof(x));\n  x.iScope = 3;  /* Default scope if none specified by \"WHERE scope=N\" */\n  x.iMaxDist = -1;   /* Maximum allowed edit distance */\n\n  if( idxNum&2 ){\n    iLang = sqlite3_value_int(argv[idx++]);\n  }\n  if( idxNum&4 ){\n    iLimit = sqlite3_value_int(argv[idx++]);\n    if( iLimit<1 ) iLimit = 1;\n  }\n  if( idxNum&8 ){\n    x.iScope = sqlite3_value_int(argv[idx++]);\n    if( x.iScope<1 ) x.iScope = 1;\n    if( x.iScope>SPELLFIX_MX_HASH-2 ) x.iScope = SPELLFIX_MX_HASH-2;\n  }\n  if( idxNum&(16|32) ){\n    x.iMaxDist = sqlite3_value_int(argv[idx++]);\n    if( idxNum&16 ) x.iMaxDist--;\n    if( x.iMaxDist<0 ) x.iMaxDist = 0;\n  }\n  spellfix1ResetCursor(pCur);\n  spellfix1ResizeCursor(pCur, iLimit);\n  zMatchThis = sqlite3_value_text(argv[0]);\n  if( zMatchThis==0 ) return SQLITE_OK;\n  if( p->pConfig3 ){\n    x.pLang = editDist3FindLang(p->pConfig3, iLang);\n    pMatchStr3 = editDist3FromStringNew(x.pLang, (const char*)zMatchThis, -1);\n    if( pMatchStr3==0 ){\n      x.rc = SQLITE_NOMEM;\n      goto filter_exit;\n    }\n  }else{\n    x.pLang = 0;\n  }\n  zPattern = (char*)transliterate(zMatchThis, sqlite3_value_bytes(argv[0]));\n  sqlite3_free(pCur->zPattern);\n  pCur->zPattern = zPattern;\n  if( zPattern==0 ){\n    x.rc = SQLITE_NOMEM;\n    goto filter_exit;\n  }\n  nPattern = (int)strlen(zPattern);\n  if( zPattern[nPattern-1]=='*' ) nPattern--;\n  zSql = sqlite3_mprintf(\n     \"SELECT id, word, rank, k1\"\n     \"  FROM \\\"%w\\\".\\\"%w_vocab\\\"\"\n     \" WHERE langid=%d AND k2>=?1 AND k2<?2\",\n     p->zDbName, p->zTableName, iLang\n  );\n  if( zSql==0 ){\n    x.rc = SQLITE_NOMEM;\n    pStmt = 0;\n    goto filter_exit;\n  }\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  pCur->iLang = iLang;\n  x.pCur = pCur;\n  x.pStmt = pStmt;\n  x.zPattern = zPattern;\n  x.nPattern = nPattern;\n  x.pMatchStr3 = pMatchStr3;\n  x.iLang = iLang;\n  x.rc = rc;\n  x.pConfig3 = p->pConfig3;\n  if( x.rc==SQLITE_OK ){\n    spellfix1RunQuery(&x, zPattern, nPattern);\n  }\n\n  if( pCur->a ){\n    qsort(pCur->a, pCur->nRow, sizeof(pCur->a[0]), spellfix1RowCompare);\n    pCur->iTop = iLimit;\n    pCur->iScope = iScope;\n  }else{\n    x.rc = SQLITE_NOMEM;\n  }\n\nfilter_exit:\n  sqlite3_finalize(pStmt);\n  editDist3FromStringDelete(pMatchStr3);\n  return x.rc;\n}\n\n/*\n** This version of xFilter handles a full-table scan case\n*/\nstatic int spellfix1FilterForFullScan(\n  spellfix1_cursor *pCur,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc = SQLITE_OK;\n  int idxNum = pCur->idxNum;\n  char *zSql;\n  spellfix1_vtab *pVTab = pCur->pVTab;\n  spellfix1ResetCursor(pCur);\n  assert( idxNum==0 || idxNum==64 );\n  zSql = sqlite3_mprintf(\n     \"SELECT word, rank, NULL, langid, id FROM \\\"%w\\\".\\\"%w_vocab\\\"%s\",\n     pVTab->zDbName, pVTab->zTableName,\n     ((idxNum & 64) ? \" WHERE rowid=?\" : \"\")\n  );\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_prepare_v2(pVTab->db, zSql, -1, &pCur->pFullScan, 0);\n  sqlite3_free(zSql);\n  if( rc==SQLITE_OK && (idxNum & 64) ){\n    assert( argc==1 );\n    rc = sqlite3_bind_value(pCur->pFullScan, 1, argv[0]);\n  }\n  pCur->nRow = pCur->iRow = 0;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_step(pCur->pFullScan);\n    if( rc==SQLITE_ROW ){ pCur->iRow = -1; rc = SQLITE_OK; }\n    if( rc==SQLITE_DONE ){ rc = SQLITE_OK; }\n  }else{\n    pCur->iRow = 0;\n  }\n  return rc;\n}\n\n\n/*\n** Called to \"rewind\" a cursor back to the beginning so that\n** it starts its output over again.  Always called at least once\n** prior to any spellfix1Column, spellfix1Rowid, or spellfix1Eof call.\n*/\nstatic int spellfix1Filter(\n  sqlite3_vtab_cursor *cur, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  spellfix1_cursor *pCur = (spellfix1_cursor *)cur;\n  int rc;\n  pCur->idxNum = idxNum;\n  if( idxNum & 1 ){\n    rc = spellfix1FilterForMatch(pCur, argc, argv);\n  }else{\n    rc = spellfix1FilterForFullScan(pCur, argc, argv);\n  }\n  return rc;\n}\n\n\n/*\n** Advance a cursor to its next row of output\n*/\nstatic int spellfix1Next(sqlite3_vtab_cursor *cur){\n  spellfix1_cursor *pCur = (spellfix1_cursor *)cur;\n  int rc = SQLITE_OK;\n  if( pCur->iRow < pCur->nRow ){\n    if( pCur->pFullScan ){\n      rc = sqlite3_step(pCur->pFullScan);\n      if( rc!=SQLITE_ROW ) pCur->iRow = pCur->nRow;\n      if( rc==SQLITE_ROW || rc==SQLITE_DONE ) rc = SQLITE_OK;\n    }else{\n      pCur->iRow++;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if we are at the end-of-file\n*/\nstatic int spellfix1Eof(sqlite3_vtab_cursor *cur){\n  spellfix1_cursor *pCur = (spellfix1_cursor *)cur;\n  return pCur->iRow>=pCur->nRow;\n}\n\n/*\n** Return columns from the current row.\n*/\nstatic int spellfix1Column(\n  sqlite3_vtab_cursor *cur,\n  sqlite3_context *ctx,\n  int i\n){\n  spellfix1_cursor *pCur = (spellfix1_cursor*)cur;\n  if( pCur->pFullScan ){\n    if( i<=SPELLFIX_COL_LANGID ){\n      sqlite3_result_value(ctx, sqlite3_column_value(pCur->pFullScan, i));\n    }else{\n      sqlite3_result_null(ctx);\n    }\n    return SQLITE_OK;\n  }\n  switch( i ){\n    case SPELLFIX_COL_WORD: {\n      sqlite3_result_text(ctx, pCur->a[pCur->iRow].zWord, -1, SQLITE_STATIC);\n      break;\n    }\n    case SPELLFIX_COL_RANK: {\n      sqlite3_result_int(ctx, pCur->a[pCur->iRow].iRank);\n      break;\n    }\n    case SPELLFIX_COL_DISTANCE: {\n      sqlite3_result_int(ctx, pCur->a[pCur->iRow].iDistance);\n      break;\n    }\n    case SPELLFIX_COL_LANGID: {\n      sqlite3_result_int(ctx, pCur->iLang);\n      break;\n    }\n    case SPELLFIX_COL_SCORE: {\n      sqlite3_result_int(ctx, pCur->a[pCur->iRow].iScore);\n      break;\n    }\n    case SPELLFIX_COL_MATCHLEN: {\n      int iMatchlen = pCur->a[pCur->iRow].iMatchlen;\n      if( iMatchlen<0 ){\n        int nPattern = (int)strlen(pCur->zPattern);\n        char *zWord = pCur->a[pCur->iRow].zWord;\n        int nWord = (int)strlen(zWord);\n\n        if( nPattern>0 && pCur->zPattern[nPattern-1]=='*' ){\n          char *zTranslit;\n          int res;\n          zTranslit = (char *)transliterate((unsigned char *)zWord, nWord);\n          if( !zTranslit ) return SQLITE_NOMEM;\n          res = editdist1(pCur->zPattern, zTranslit, &iMatchlen);\n          sqlite3_free(zTranslit);\n          if( res<0 ) return SQLITE_NOMEM;\n          iMatchlen = translen_to_charlen(zWord, nWord, iMatchlen);\n        }else{\n          iMatchlen = utf8Charlen(zWord, nWord);\n        }\n      }\n\n      sqlite3_result_int(ctx, iMatchlen);\n      break;\n    }\n    case SPELLFIX_COL_PHONEHASH: {\n      sqlite3_result_text(ctx, pCur->a[pCur->iRow].zHash, -1, SQLITE_STATIC);\n      break;\n    }\n    case SPELLFIX_COL_TOP: {\n      sqlite3_result_int(ctx, pCur->iTop);\n      break;\n    }\n    case SPELLFIX_COL_SCOPE: {\n      sqlite3_result_int(ctx, pCur->iScope);\n      break;\n    }\n    case SPELLFIX_COL_SRCHCNT: {\n      sqlite3_result_int(ctx, pCur->nSearch);\n      break;\n    }\n    default: {\n      sqlite3_result_null(ctx);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The rowid.\n*/\nstatic int spellfix1Rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  spellfix1_cursor *pCur = (spellfix1_cursor*)cur;\n  if( pCur->pFullScan ){\n    *pRowid = sqlite3_column_int64(pCur->pFullScan, 4);\n  }else{\n    *pRowid = pCur->a[pCur->iRow].iRowid;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is called by the xUpdate() method. It returns a string\n** containing the conflict mode that xUpdate() should use for the current\n** operation. One of: \"ROLLBACK\", \"IGNORE\", \"ABORT\" or \"REPLACE\".\n*/\nstatic const char *spellfix1GetConflict(sqlite3 *db){\n  static const char *azConflict[] = {\n    /* Note: Instead of \"FAIL\" - \"ABORT\". */\n    \"ROLLBACK\", \"IGNORE\", \"ABORT\", \"ABORT\", \"REPLACE\"\n  };\n  int eConflict = sqlite3_vtab_on_conflict(db);\n\n  assert( eConflict==SQLITE_ROLLBACK || eConflict==SQLITE_IGNORE\n       || eConflict==SQLITE_FAIL || eConflict==SQLITE_ABORT\n       || eConflict==SQLITE_REPLACE\n  );\n  assert( SQLITE_ROLLBACK==1 );\n  assert( SQLITE_IGNORE==2 );\n  assert( SQLITE_FAIL==3 );\n  assert( SQLITE_ABORT==4 );\n  assert( SQLITE_REPLACE==5 );\n\n  return azConflict[eConflict-1];\n}\n\n/*\n** The xUpdate() method.\n*/\nstatic int spellfix1Update(\n  sqlite3_vtab *pVTab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  int rc = SQLITE_OK;\n  sqlite3_int64 rowid, newRowid;\n  spellfix1_vtab *p = (spellfix1_vtab*)pVTab;\n  sqlite3 *db = p->db;\n\n  if( argc==1 ){\n    /* A delete operation on the rowid given by argv[0] */\n    rowid = *pRowid = sqlite3_value_int64(argv[0]);\n    spellfix1DbExec(&rc, db, \"DELETE FROM \\\"%w\\\".\\\"%w_vocab\\\" \"\n                           \" WHERE id=%lld\",\n                  p->zDbName, p->zTableName, rowid);\n  }else{\n    const unsigned char *zWord = sqlite3_value_text(argv[SPELLFIX_COL_WORD+2]);\n    int nWord = sqlite3_value_bytes(argv[SPELLFIX_COL_WORD+2]);\n    int iLang = sqlite3_value_int(argv[SPELLFIX_COL_LANGID+2]);\n    int iRank = sqlite3_value_int(argv[SPELLFIX_COL_RANK+2]);\n    const unsigned char *zSoundslike =\n           sqlite3_value_text(argv[SPELLFIX_COL_SOUNDSLIKE+2]);\n    int nSoundslike = sqlite3_value_bytes(argv[SPELLFIX_COL_SOUNDSLIKE+2]);\n    char *zK1, *zK2;\n    int i;\n    char c;\n    const char *zConflict = spellfix1GetConflict(db);\n\n    if( zWord==0 ){\n      /* Inserts of the form:  INSERT INTO table(command) VALUES('xyzzy');\n      ** cause zWord to be NULL, so we look at the \"command\" column to see\n      ** what special actions to take */\n      const char *zCmd = \n         (const char*)sqlite3_value_text(argv[SPELLFIX_COL_COMMAND+2]);\n      if( zCmd==0 ){\n        pVTab->zErrMsg = sqlite3_mprintf(\"NOT NULL constraint failed: %s.word\",\n                                         p->zTableName);\n        return SQLITE_CONSTRAINT_NOTNULL;\n      }\n      if( strcmp(zCmd,\"reset\")==0 ){\n        /* Reset the  edit cost table (if there is one). */\n        editDist3ConfigDelete(p->pConfig3);\n        p->pConfig3 = 0;\n        return SQLITE_OK;\n      }\n      if( strncmp(zCmd,\"edit_cost_table=\",16)==0 ){\n        editDist3ConfigDelete(p->pConfig3);\n        p->pConfig3 = 0;\n        sqlite3_free(p->zCostTable);\n        p->zCostTable = spellfix1Dequote(zCmd+16);\n        if( p->zCostTable==0 ) return SQLITE_NOMEM;\n        if( p->zCostTable[0]==0 || sqlite3_stricmp(p->zCostTable,\"null\")==0 ){\n          sqlite3_free(p->zCostTable);\n          p->zCostTable = 0;\n        }\n        return SQLITE_OK;\n      }\n      pVTab->zErrMsg = sqlite3_mprintf(\"unknown value for %s.command: \\\"%w\\\"\",\n                                       p->zTableName, zCmd);\n      return SQLITE_ERROR;\n    }\n    if( iRank<1 ) iRank = 1;\n    if( zSoundslike ){\n      zK1 = (char*)transliterate(zSoundslike, nSoundslike);\n    }else{\n      zK1 = (char*)transliterate(zWord, nWord);\n    }\n    if( zK1==0 ) return SQLITE_NOMEM;\n    for(i=0; (c = zK1[i])!=0; i++){\n       if( c>='A' && c<='Z' ) zK1[i] += 'a' - 'A';\n    }\n    zK2 = (char*)phoneticHash((const unsigned char*)zK1, i);\n    if( zK2==0 ){\n      sqlite3_free(zK1);\n      return SQLITE_NOMEM;\n    }\n    if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n      if( sqlite3_value_type(argv[1])==SQLITE_NULL ){\n        spellfix1DbExec(&rc, db,\n               \"INSERT INTO \\\"%w\\\".\\\"%w_vocab\\\"(rank,langid,word,k1,k2) \"\n               \"VALUES(%d,%d,%Q,%Q,%Q)\",\n               p->zDbName, p->zTableName,\n               iRank, iLang, zWord, zK1, zK2\n        );\n      }else{\n        newRowid = sqlite3_value_int64(argv[1]);\n        spellfix1DbExec(&rc, db,\n            \"INSERT OR %s INTO \\\"%w\\\".\\\"%w_vocab\\\"(id,rank,langid,word,k1,k2) \"\n            \"VALUES(%lld,%d,%d,%Q,%Q,%Q)\",\n            zConflict, p->zDbName, p->zTableName,\n            newRowid, iRank, iLang, zWord, zK1, zK2\n        );\n      }\n      *pRowid = sqlite3_last_insert_rowid(db);\n    }else{\n      rowid = sqlite3_value_int64(argv[0]);\n      newRowid = *pRowid = sqlite3_value_int64(argv[1]);\n      spellfix1DbExec(&rc, db,\n             \"UPDATE OR %s \\\"%w\\\".\\\"%w_vocab\\\" SET id=%lld, rank=%d, langid=%d,\"\n             \" word=%Q, k1=%Q, k2=%Q WHERE id=%lld\",\n             zConflict, p->zDbName, p->zTableName, newRowid, iRank, iLang,\n             zWord, zK1, zK2, rowid\n      );\n    }\n    sqlite3_free(zK1);\n    sqlite3_free(zK2);\n  }\n  return rc;\n}\n\n/*\n** Rename the spellfix1 table.\n*/\nstatic int spellfix1Rename(sqlite3_vtab *pVTab, const char *zNew){\n  spellfix1_vtab *p = (spellfix1_vtab*)pVTab;\n  sqlite3 *db = p->db;\n  int rc = SQLITE_OK;\n  char *zNewName = sqlite3_mprintf(\"%s\", zNew);\n  if( zNewName==0 ){\n    return SQLITE_NOMEM;\n  }\n  spellfix1DbExec(&rc, db, \n     \"ALTER TABLE \\\"%w\\\".\\\"%w_vocab\\\" RENAME TO \\\"%w_vocab\\\"\",\n     p->zDbName, p->zTableName, zNewName\n  );\n  if( rc==SQLITE_OK ){\n    sqlite3_free(p->zTableName);\n    p->zTableName = zNewName;\n  }else{\n    sqlite3_free(zNewName);\n  }\n  return rc;\n}\n\n\n/*\n** A virtual table module that provides fuzzy search.\n*/\nstatic sqlite3_module spellfix1Module = {\n  0,                       /* iVersion */\n  spellfix1Create,         /* xCreate - handle CREATE VIRTUAL TABLE */\n  spellfix1Connect,        /* xConnect - reconnected to an existing table */\n  spellfix1BestIndex,      /* xBestIndex - figure out how to do a query */\n  spellfix1Disconnect,     /* xDisconnect - close a connection */\n  spellfix1Destroy,        /* xDestroy - handle DROP TABLE */\n  spellfix1Open,           /* xOpen - open a cursor */\n  spellfix1Close,          /* xClose - close a cursor */\n  spellfix1Filter,         /* xFilter - configure scan constraints */\n  spellfix1Next,           /* xNext - advance a cursor */\n  spellfix1Eof,            /* xEof - check for end of scan */\n  spellfix1Column,         /* xColumn - read data */\n  spellfix1Rowid,          /* xRowid - read data */\n  spellfix1Update,         /* xUpdate */\n  0,                       /* xBegin */\n  0,                       /* xSync */\n  0,                       /* xCommit */\n  0,                       /* xRollback */\n  0,                       /* xFindMethod */\n  spellfix1Rename,         /* xRename */\n};\n\n/*\n** Register the various functions and the virtual table.\n*/\nstatic int spellfix1Register(sqlite3 *db){\n  int rc = SQLITE_OK;\n  int i;\n  rc = sqlite3_create_function(db, \"spellfix1_translit\", 1, SQLITE_UTF8, 0,\n                                  transliterateSqlFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"spellfix1_editdist\", 2, SQLITE_UTF8, 0,\n                                  editdistSqlFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"spellfix1_phonehash\", 1, SQLITE_UTF8, 0,\n                                  phoneticHashSqlFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"spellfix1_scriptcode\", 1, SQLITE_UTF8, 0,\n                                  scriptCodeSqlFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_module(db, \"spellfix1\", &spellfix1Module, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = editDist3Install(db);\n  }\n\n  /* Verify sanity of the translit[] table */\n  for(i=0; i<sizeof(translit)/sizeof(translit[0])-1; i++){\n    assert( translit[i].cFrom<translit[i+1].cFrom );\n  }\n\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Extension load function.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_spellfix_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  return spellfix1Register(db);\n#endif\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/stmt.c",
    "content": "/*\n** 2017-05-31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates an eponymous virtual table that returns information\n** about all prepared statements for the database connection.\n**\n** Usage example:\n**\n**     .load ./stmt\n**     .mode line\n**     .header on\n**     SELECT * FROM stmt;\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)\n#if !defined(SQLITEINT_H)\n#include \"sqlite3ext.h\"\n#endif\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* stmt_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a stmt virtual table\n*/\ntypedef struct stmt_vtab stmt_vtab;\nstruct stmt_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  sqlite3 *db;        /* Database connection for this stmt vtab */\n};\n\n/* stmt_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct stmt_cursor stmt_cursor;\nstruct stmt_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3 *db;               /* Database connection for this cursor */\n  sqlite3_stmt *pStmt;       /* Statement cursor is currently pointing at */\n  sqlite3_int64 iRowid;      /* The rowid */\n};\n\n/*\n** The stmtConnect() method is invoked to create a new\n** stmt_vtab that describes the stmt virtual table.\n**\n** Think of this routine as the constructor for stmt_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the stmt_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against stmt will look like.\n*/\nstatic int stmtConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  stmt_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define STMT_COLUMN_SQL     0   /* SQL for the statement */\n#define STMT_COLUMN_NCOL    1   /* Number of result columns */\n#define STMT_COLUMN_RO      2   /* True if read-only */\n#define STMT_COLUMN_BUSY    3   /* True if currently busy */\n#define STMT_COLUMN_NSCAN   4   /* SQLITE_STMTSTATUS_FULLSCAN_STEP */\n#define STMT_COLUMN_NSORT   5   /* SQLITE_STMTSTATUS_SORT */\n#define STMT_COLUMN_NAIDX   6   /* SQLITE_STMTSTATUS_AUTOINDEX */\n#define STMT_COLUMN_NSTEP   7   /* SQLITE_STMTSTATUS_VM_STEP */\n#define STMT_COLUMN_REPREP  8   /* SQLITE_STMTSTATUS_REPREPARE */\n#define STMT_COLUMN_RUN     9   /* SQLITE_STMTSTATUS_RUN */\n#define STMT_COLUMN_MEM    10   /* SQLITE_STMTSTATUS_MEMUSED */\n\n\n  rc = sqlite3_declare_vtab(db,\n     \"CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,\"\n                    \"reprep,run,mem)\");\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->db = db;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for stmt_cursor objects.\n*/\nstatic int stmtDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new stmt_cursor object.\n*/\nstatic int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  stmt_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->db = ((stmt_vtab*)p)->db;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a stmt_cursor.\n*/\nstatic int stmtClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a stmt_cursor to its next row of output.\n*/\nstatic int stmtNext(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  pCur->iRowid++;\n  pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the stmt_cursor\n** is currently pointing.\n*/\nstatic int stmtColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  switch( i ){\n    case STMT_COLUMN_SQL: {\n      sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case STMT_COLUMN_NCOL: {\n      sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_RO: {\n      sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_BUSY: {\n      sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_MEM: {\n      i = SQLITE_STMTSTATUS_MEMUSED + \n            STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;\n      /* Fall thru */\n    }\n    case STMT_COLUMN_NSCAN:\n    case STMT_COLUMN_NSORT:\n    case STMT_COLUMN_NAIDX:\n    case STMT_COLUMN_NSTEP:\n    case STMT_COLUMN_REPREP:\n    case STMT_COLUMN_RUN: {\n      sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,\n                      i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int stmtEof(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  return pCur->pStmt==0;\n}\n\n/*\n** This method is called to \"rewind\" the stmt_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to stmtColumn() or stmtRowid() or \n** stmtEof().\n*/\nstatic int stmtFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;\n  pCur->pStmt = 0;\n  pCur->iRowid = 0;\n  return stmtNext(pVtabCursor);\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the stmt virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n*/\nstatic int stmtBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  pIdxInfo->estimatedCost = (double)500;\n  pIdxInfo->estimatedRows = 500;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** stmt virtual table.\n*/\nstatic sqlite3_module stmtModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  stmtConnect,               /* xConnect */\n  stmtBestIndex,             /* xBestIndex */\n  stmtDisconnect,            /* xDisconnect */\n  0,                         /* xDestroy */\n  stmtOpen,                  /* xOpen - open a cursor */\n  stmtClose,                 /* xClose - close a cursor */\n  stmtFilter,                /* xFilter - configure scan constraints */\n  stmtNext,                  /* xNext - advance a cursor */\n  stmtEof,                   /* xEof - check for end of scan */\n  stmtColumn,                /* xColumn - read data */\n  stmtRowid,                 /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\nint sqlite3StmtVtabInit(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"sqlite_stmt\", &stmtModule, 0);\n#endif\n  return rc;\n}\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_stmt_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3StmtVtabInit(db);\n#endif\n  return rc;\n}\n#endif /* SQLITE_CORE */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/totype.c",
    "content": "/*\n** 2013-10-14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements functions tointeger(X) and toreal(X).\n**\n** If X is an integer, real, or string value that can be\n** losslessly represented as an integer, then tointeger(X)\n** returns the corresponding integer value.\n** If X is an 8-byte BLOB then that blob is interpreted as\n** a signed two-compliment little-endian encoding of an integer\n** and tointeger(X) returns the corresponding integer value.\n** Otherwise tointeger(X) return NULL.\n**\n** If X is an integer, real, or string value that can be\n** convert into a real number, preserving at least 15 digits\n** of precision, then toreal(X) returns the corresponding real value.\n** If X is an 8-byte BLOB then that blob is interpreted as\n** a 64-bit IEEE754 big-endian floating point value\n** and toreal(X) returns the corresponding real value.\n** Otherwise toreal(X) return NULL.\n**\n** Note that tointeger(X) of an 8-byte BLOB assumes a little-endian\n** encoding whereas toreal(X) of an 8-byte BLOB assumes a big-endian\n** encoding.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n/*\n** Determine if this is running on a big-endian or little-endian\n** processor\n*/\n#if defined(i386) || defined(__i386__) || defined(_M_IX86)\\\n                             || defined(__x86_64) || defined(__x86_64__)\n# define TOTYPE_BIGENDIAN    0\n# define TOTYPE_LITTLEENDIAN 1\n#else\n  const int totype_one = 1;\n# define TOTYPE_BIGENDIAN    (*(char *)(&totype_one)==0)\n# define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1)\n#endif\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#ifndef LARGEST_INT64\n# define LARGEST_INT64   (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n#endif\n\n#ifndef SMALLEST_INT64\n# define SMALLEST_INT64  (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** Return TRUE if character c is a whitespace character\n*/\nstatic int totypeIsspace(unsigned char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\v' || c=='\\f' || c=='\\r';\n}\n\n/*\n** Return TRUE if character c is a digit\n*/\nstatic int totypeIsdigit(unsigned char c){\n  return c>='0' && c<='9';\n}\n\n/*\n** Compare the 19-character string zNum against the text representation\n** value 2^63:  9223372036854775808.  Return negative, zero, or positive\n** if zNum is less than, equal to, or greater than the string.\n** Note that zNum must contain exactly 19 characters.\n**\n** Unlike memcmp() this routine is guaranteed to return the difference\n** in the values of the last digit if the only difference is in the\n** last digit.  So, for example,\n**\n**      totypeCompare2pow63(\"9223372036854775800\")\n**\n** will return -8.\n*/\nstatic int totypeCompare2pow63(const char *zNum){\n  int c = 0;\n  int i;\n                    /* 012345678901234567 */\n  const char *pow63 = \"922337203685477580\";\n  for(i=0; c==0 && i<18; i++){\n    c = (zNum[i]-pow63[i])*10;\n  }\n  if( c==0 ){\n    c = zNum[18] - '8';\n  }\n  return c;\n}\n\n/*\n** Convert zNum to a 64-bit signed integer.\n**\n** If the zNum value is representable as a 64-bit twos-complement\n** integer, then write that value into *pNum and return 0.\n**\n** If zNum is exactly 9223372036854665808, return 2.  This special\n** case is broken out because while 9223372036854665808 cannot be a\n** signed 64-bit integer, its negative -9223372036854665808 can be.\n**\n** If zNum is too big for a 64-bit integer and is not\n** 9223372036854665808  or if zNum contains any non-numeric text,\n** then return 1.\n**\n** The string is not necessarily zero-terminated.\n*/\nstatic int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){\n  sqlite3_uint64 u = 0;\n  int neg = 0; /* assume positive */\n  int i;\n  int c = 0;\n  int nonNum = 0;\n  const char *zStart;\n  const char *zEnd = zNum + length;\n\n  while( zNum<zEnd && totypeIsspace(*zNum) ) zNum++;\n  if( zNum<zEnd ){\n    if( *zNum=='-' ){\n      neg = 1;\n      zNum++;\n    }else if( *zNum=='+' ){\n      zNum++;\n    }\n  }\n  zStart = zNum;\n  while( zNum<zEnd && zNum[0]=='0' ){ zNum++; } /* Skip leading zeros. */\n  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i++){\n    u = u*10 + c - '0';\n  }\n  if( u>LARGEST_INT64 ){\n    *pNum = SMALLEST_INT64;\n  }else if( neg ){\n    *pNum = -(sqlite3_int64)u;\n  }else{\n    *pNum = (sqlite3_int64)u;\n  }\n  if( (c!=0 && &zNum[i]<zEnd) || (i==0 && zStart==zNum) || i>19 || nonNum ){\n    /* zNum is empty or contains non-numeric text or is longer\n    ** than 19 digits (thus guaranteeing that it is too large) */\n    return 1;\n  }else if( i<19 ){\n    /* Less than 19 digits, so we know that it fits in 64 bits */\n    assert( u<=LARGEST_INT64 );\n    return 0;\n  }else{\n    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */\n    c = totypeCompare2pow63(zNum);\n    if( c<0 ){\n      /* zNum is less than 9223372036854775808 so it fits */\n      assert( u<=LARGEST_INT64 );\n      return 0;\n    }else if( c>0 ){\n      /* zNum is greater than 9223372036854775808 so it overflows */\n      return 1;\n    }else{\n      /* zNum is exactly 9223372036854775808.  Fits if negative.  The\n      ** special case 2 overflow if positive */\n      assert( u-1==LARGEST_INT64 );\n      assert( (*pNum)==SMALLEST_INT64 );\n      return neg ? 0 : 2;\n    }\n  }\n}\n\n/*\n** The string z[] is an text representation of a real number.\n** Convert this string to a double and write it into *pResult.\n**\n** The string is not necessarily zero-terminated.\n**\n** Return TRUE if the result is a valid real number (or integer) and FALSE\n** if the string is empty or contains extraneous text.  Valid numbers\n** are in one of these formats:\n**\n**    [+-]digits[E[+-]digits]\n**    [+-]digits.[digits][E[+-]digits]\n**    [+-].digits[E[+-]digits]\n**\n** Leading and trailing whitespace is ignored for the purpose of determining\n** validity.\n**\n** If some prefix of the input string is a valid number, this routine\n** returns FALSE but it still converts the prefix and writes the result\n** into *pResult.\n*/\nstatic int totypeAtoF(const char *z, double *pResult, int length){\n  const char *zEnd = z + length;\n  /* sign * significand * (10 ^ (esign * exponent)) */\n  int sign = 1;    /* sign of significand */\n  sqlite3_int64 s = 0;       /* significand */\n  int d = 0;       /* adjust exponent for shifting decimal point */\n  int esign = 1;   /* sign of exponent */\n  int e = 0;       /* exponent */\n  int eValid = 1;  /* True exponent is either not used or is well-formed */\n  double result;\n  int nDigits = 0;\n  int nonNum = 0;\n\n  *pResult = 0.0;   /* Default return value, in case of an error */\n\n  /* skip leading spaces */\n  while( z<zEnd && totypeIsspace(*z) ) z++;\n  if( z>=zEnd ) return 0;\n\n  /* get sign of significand */\n  if( *z=='-' ){\n    sign = -1;\n    z++;\n  }else if( *z=='+' ){\n    z++;\n  }\n\n  /* skip leading zeroes */\n  while( z<zEnd && z[0]=='0' ) z++, nDigits++;\n\n  /* copy max significant digits to significand */\n  while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n    s = s*10 + (*z - '0');\n    z++, nDigits++;\n  }\n\n  /* skip non-significant significand digits\n  ** (increase exponent by d to shift decimal left) */\n  while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++, d++;\n  if( z>=zEnd ) goto totype_atof_calc;\n\n  /* if decimal point is present */\n  if( *z=='.' ){\n    z++;\n    /* copy digits from after decimal to significand\n    ** (decrease exponent by d to shift decimal right) */\n    while( z<zEnd && totypeIsdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n      s = s*10 + (*z - '0');\n      z++, nDigits++, d--;\n    }\n    /* skip non-significant digits */\n    while( z<zEnd && totypeIsdigit(*z) ) z++, nDigits++;\n  }\n  if( z>=zEnd ) goto totype_atof_calc;\n\n  /* if exponent is present */\n  if( *z=='e' || *z=='E' ){\n    z++;\n    eValid = 0;\n    if( z>=zEnd ) goto totype_atof_calc;\n    /* get sign of exponent */\n    if( *z=='-' ){\n      esign = -1;\n      z++;\n    }else if( *z=='+' ){\n      z++;\n    }\n    /* copy digits to exponent */\n    while( z<zEnd && totypeIsdigit(*z) ){\n      e = e<10000 ? (e*10 + (*z - '0')) : 10000;\n      z++;\n      eValid = 1;\n    }\n  }\n\n  /* skip trailing spaces */\n  if( nDigits && eValid ){\n    while( z<zEnd && totypeIsspace(*z) ) z++;\n  }\n\ntotype_atof_calc:\n  /* adjust exponent by d, and update sign */\n  e = (e*esign) + d;\n  if( e<0 ) {\n    esign = -1;\n    e *= -1;\n  } else {\n    esign = 1;\n  }\n\n  /* if 0 significand */\n  if( !s ) {\n    /* In the IEEE 754 standard, zero is signed.\n    ** Add the sign if we've seen at least one digit */\n    result = (sign<0 && nDigits) ? -(double)0 : (double)0;\n  } else {\n    /* attempt to reduce exponent */\n    if( esign>0 ){\n      while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10;\n    }else{\n      while( !(s%10) && e>0 ) e--,s/=10;\n    }\n\n    /* adjust the sign of significand */\n    s = sign<0 ? -s : s;\n\n    /* if exponent, scale significand as appropriate\n    ** and store in result. */\n    if( e ){\n      double scale = 1.0;\n      /* attempt to handle extremely small/large numbers better */\n      if( e>307 && e<342 ){\n        while( e%308 ) { scale *= 1.0e+1; e -= 1; }\n        if( esign<0 ){\n          result = s / scale;\n          result /= 1.0e+308;\n        }else{\n          result = s * scale;\n          result *= 1.0e+308;\n        }\n      }else if( e>=342 ){\n        if( esign<0 ){\n          result = 0.0*s;\n        }else{\n          result = 1e308*1e308*s;  /* Infinity */\n        }\n      }else{\n        /* 1.0e+22 is the largest power of 10 than can be\n        ** represented exactly. */\n        while( e%22 ) { scale *= 1.0e+1; e -= 1; }\n        while( e>0 ) { scale *= 1.0e+22; e -= 22; }\n        if( esign<0 ){\n          result = s / scale;\n        }else{\n          result = s * scale;\n        }\n      }\n    } else {\n      result = (double)s;\n    }\n  }\n\n  /* store the result */\n  *pResult = result;\n\n  /* return true if number and no extra non-whitespace chracters after */\n  return z>=zEnd && nDigits>0 && eValid && nonNum==0;\n}\n\n/*\n** tointeger(X):  If X is any value (integer, double, blob, or string) that\n** can be losslessly converted into an integer, then make the conversion and\n** return the result.  Otherwise, return NULL.\n*/\nstatic void tointegerFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( argc==1 );\n  (void)argc;\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      double rVal = sqlite3_value_double(argv[0]);\n      sqlite3_int64 iVal = (sqlite3_int64)rVal;\n      if( rVal==(double)iVal ){\n        sqlite3_result_int64(context, iVal);\n      }\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_result_int64(context, sqlite3_value_int64(argv[0]));\n      break;\n    }\n    case SQLITE_BLOB: {\n      const unsigned char *zBlob = sqlite3_value_blob(argv[0]);\n      if( zBlob ){\n        int nBlob = sqlite3_value_bytes(argv[0]);\n        if( nBlob==sizeof(sqlite3_int64) ){\n          sqlite3_int64 iVal;\n          if( TOTYPE_BIGENDIAN ){\n            int i;\n            unsigned char zBlobRev[sizeof(sqlite3_int64)];\n            for(i=0; i<sizeof(sqlite3_int64); i++){\n              zBlobRev[i] = zBlob[sizeof(sqlite3_int64)-1-i];\n            }\n            memcpy(&iVal, zBlobRev, sizeof(sqlite3_int64));\n          }else{\n            memcpy(&iVal, zBlob, sizeof(sqlite3_int64));\n          }\n          sqlite3_result_int64(context, iVal);\n        }\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *zStr = sqlite3_value_text(argv[0]);\n      if( zStr ){\n        int nStr = sqlite3_value_bytes(argv[0]);\n        if( nStr && !totypeIsspace(zStr[0]) ){\n          sqlite3_int64 iVal;\n          if( !totypeAtoi64((const char*)zStr, &iVal, nStr) ){\n            sqlite3_result_int64(context, iVal);\n          }\n        }\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      break;\n    }\n  }\n}\n\n/*\n** toreal(X): If X is any value (integer, double, blob, or string) that can\n** be losslessly converted into a real number, then do so and return that\n** real number.  Otherwise return NULL.\n*/\n#if defined(_MSC_VER)\n#pragma warning(disable: 4748)\n#pragma optimize(\"\", off)\n#endif\nstatic void torealFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( argc==1 );\n  (void)argc;\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      sqlite3_result_double(context, sqlite3_value_double(argv[0]));\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_int64 iVal = sqlite3_value_int64(argv[0]);\n      double rVal = (double)iVal;\n      if( iVal==(sqlite3_int64)rVal ){\n        sqlite3_result_double(context, rVal);\n      }\n      break;\n    }\n    case SQLITE_BLOB: {\n      const unsigned char *zBlob = sqlite3_value_blob(argv[0]);\n      if( zBlob ){\n        int nBlob = sqlite3_value_bytes(argv[0]);\n        if( nBlob==sizeof(double) ){\n          double rVal;\n          if( TOTYPE_LITTLEENDIAN ){\n            int i;\n            unsigned char zBlobRev[sizeof(double)];\n            for(i=0; i<sizeof(double); i++){\n              zBlobRev[i] = zBlob[sizeof(double)-1-i];\n            }\n            memcpy(&rVal, zBlobRev, sizeof(double));\n          }else{\n            memcpy(&rVal, zBlob, sizeof(double));\n          }\n          sqlite3_result_double(context, rVal);\n        }\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *zStr = sqlite3_value_text(argv[0]);\n      if( zStr ){\n        int nStr = sqlite3_value_bytes(argv[0]);\n        if( nStr && !totypeIsspace(zStr[0]) && !totypeIsspace(zStr[nStr-1]) ){\n          double rVal;\n          if( totypeAtoF((const char*)zStr, &rVal, nStr) ){\n            sqlite3_result_double(context, rVal);\n            return;\n          }\n        }\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      break;\n    }\n  }\n}\n#if defined(_MSC_VER)\n#pragma optimize(\"\", on)\n#pragma warning(default: 4748)\n#endif\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_totype_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"tointeger\", 1, SQLITE_UTF8, 0,\n                               tointegerFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"toreal\", 1, SQLITE_UTF8, 0,\n                                 torealFunc, 0, 0);\n  }\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/unionvtab.c",
    "content": "/*\n** 2017 July 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of the \"unionvtab\" and \"swarmvtab\"\n** virtual tables. These modules provide read-only access to multiple tables,\n** possibly in multiple database files, via a single database object.\n** The source tables must have the following characteristics:\n**\n**   * They must all be rowid tables (not VIRTUAL or WITHOUT ROWID\n**     tables or views).\n**\n**   * Each table must have the same set of columns, declared in\n**     the same order and with the same declared types.\n**\n**   * The tables must not feature a user-defined column named \"_rowid_\".\n**\n**   * Each table must contain a distinct range of rowid values.\n**\n** The difference between the two virtual table modules is that for \n** \"unionvtab\", all source tables must be located in the main database or\n** in databases ATTACHed to the main database by the user. For \"swarmvtab\",\n** the tables may be located in any database file on disk. The \"swarmvtab\"\n** implementation takes care of opening and closing database files\n** automatically.\n**\n** UNIONVTAB\n**\n**   A \"unionvtab\" virtual table is created as follows:\n**\n**     CREATE VIRTUAL TABLE <name> USING unionvtab(<sql-statement>);\n**\n**   The implementation evalutes <sql statement> whenever a unionvtab virtual\n**   table is created or opened. It should return one row for each source\n**   database table. The four columns required of each row are:\n**\n**     1. The name of the database containing the table (\"main\" or \"temp\" or\n**        the name of an attached database). Or NULL to indicate that all\n**        databases should be searched for the table in the usual fashion.\n**\n**     2. The name of the database table.\n**\n**     3. The smallest rowid in the range of rowids that may be stored in the\n**        database table (an integer).\n**\n**     4. The largest rowid in the range of rowids that may be stored in the\n**        database table (an integer).\n**\n** SWARMVTAB\n**\n**   A \"swarmvtab\" virtual table is created similarly to a unionvtab table:\n**\n**     CREATE VIRTUAL TABLE <name>\n**      USING swarmvtab(<sql-statement>, <callback>);\n**\n**   The difference is that for a swarmvtab table, the first column returned\n**   by the <sql statement> must return a path or URI that can be used to open\n**   the database file containing the source table.  The <callback> option\n**   is optional.  If included, it is the name of an application-defined\n**   SQL function that is invoked with the URI of the file, if the file\n**   does not already exist on disk.\n*/\n\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Largest and smallest possible 64-bit signed integers. These macros\n** copied from sqliteInt.h.\n*/\n#ifndef LARGEST_INT64\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n#endif\n#ifndef SMALLEST_INT64\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** The following is also copied from sqliteInt.h. To facilitate coverage\n** testing.\n*/\n#ifndef ALWAYS\n# if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)\n#  define ALWAYS(X)      (1)\n#  define NEVER(X)       (0)\n# elif !defined(NDEBUG)\n#  define ALWAYS(X)      ((X)?1:(assert(0),0))\n#  define NEVER(X)       ((X)?(assert(0),1):0)\n# else\n#  define ALWAYS(X)      (X)\n#  define NEVER(X)       (X)\n# endif\n#endif\n\n/*\n** The swarmvtab module attempts to keep the number of open database files\n** at or below this limit. This may not be possible if there are too many\n** simultaneous queries.\n*/\n#define SWARMVTAB_MAX_OPEN 9\n\ntypedef struct UnionCsr UnionCsr;\ntypedef struct UnionTab UnionTab;\ntypedef struct UnionSrc UnionSrc;\n\n/*\n** Each source table (row returned by the initialization query) is \n** represented by an instance of the following structure stored in the\n** UnionTab.aSrc[] array.\n*/\nstruct UnionSrc {\n  char *zDb;                      /* Database containing source table */\n  char *zTab;                     /* Source table name */\n  sqlite3_int64 iMin;             /* Minimum rowid */\n  sqlite3_int64 iMax;             /* Maximum rowid */\n\n  /* Fields used by swarmvtab only */\n  char *zFile;                    /* Database file containing table zTab */\n  int nUser;                      /* Current number of users */\n  sqlite3 *db;                    /* Database handle */\n  UnionSrc *pNextClosable;        /* Next in list of closable sources */\n};\n\n/*\n** Virtual table  type for union vtab.\n*/\nstruct UnionTab {\n  sqlite3_vtab base;              /* Base class - must be first */\n  sqlite3 *db;                    /* Database handle */\n  int bSwarm;                     /* 1 for \"swarmvtab\", 0 for \"unionvtab\" */\n  int iPK;                        /* INTEGER PRIMARY KEY column, or -1 */\n  int nSrc;                       /* Number of elements in the aSrc[] array */\n  UnionSrc *aSrc;                 /* Array of source tables, sorted by rowid */\n\n  /* Used by swarmvtab only */\n  char *zSourceStr;               /* Expected unionSourceToStr() value */\n  char *zNotFoundCallback;        /* UDF to invoke if file not found on open */\n  UnionSrc *pClosable;            /* First in list of closable sources */\n  int nOpen;                      /* Current number of open sources */\n  int nMaxOpen;                   /* Maximum number of open sources */\n};\n\n/*\n** Virtual table cursor type for union vtab.\n*/\nstruct UnionCsr {\n  sqlite3_vtab_cursor base;       /* Base class - must be first */\n  sqlite3_stmt *pStmt;            /* SQL statement to run */\n\n  /* Used by swarmvtab only */\n  sqlite3_int64 iMaxRowid;        /* Last rowid to visit */\n  int iTab;                       /* Index of table read by pStmt */\n};\n\n/*\n** Given UnionTab table pTab and UnionSrc object pSrc, return the database\n** handle that should be used to access the table identified by pSrc. This\n** is the main db handle for \"unionvtab\" tables, or the source-specific \n** handle for \"swarmvtab\".\n*/\n#define unionGetDb(pTab, pSrc) ((pTab)->bSwarm ? (pSrc)->db : (pTab)->db)\n\n/*\n** If *pRc is other than SQLITE_OK when this function is called, it\n** always returns NULL. Otherwise, it attempts to allocate and return\n** a pointer to nByte bytes of zeroed memory. If the memory allocation\n** is attempted but fails, NULL is returned and *pRc is set to \n** SQLITE_NOMEM.\n*/\nstatic void *unionMalloc(int *pRc, int nByte){\n  void *pRet;\n  assert( nByte>0 );\n  if( *pRc==SQLITE_OK ){\n    pRet = sqlite3_malloc(nByte);\n    if( pRet ){\n      memset(pRet, 0, nByte);\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }else{\n    pRet = 0;\n  }\n  return pRet;\n}\n\n/*\n** If *pRc is other than SQLITE_OK when this function is called, it\n** always returns NULL. Otherwise, it attempts to allocate and return\n** a copy of the nul-terminated string passed as the second argument.\n** If the allocation is attempted but fails, NULL is returned and *pRc is \n** set to SQLITE_NOMEM.\n*/\nstatic char *unionStrdup(int *pRc, const char *zIn){\n  char *zRet = 0;\n  if( zIn ){\n    int nByte = (int)strlen(zIn) + 1;\n    zRet = unionMalloc(pRc, nByte);\n    if( zRet ){\n      memcpy(zRet, zIn, nByte);\n    }\n  }\n  return zRet;\n}\n\n/*\n** If the first character of the string passed as the only argument to this\n** function is one of the 4 that may be used as an open quote character\n** in SQL, this function assumes that the input is a well-formed quoted SQL \n** string. In this case the string is dequoted in place.\n**\n** If the first character of the input is not an open quote, then this\n** function is a no-op.\n*/\nstatic void unionDequote(char *z){\n  if( z ){\n    char q = z[0];\n\n    /* Set stack variable q to the close-quote character */\n    if( q=='[' || q=='\\'' || q=='\"' || q=='`' ){\n      int iIn = 1;\n      int iOut = 0;\n      if( q=='[' ) q = ']';  \n      while( ALWAYS(z[iIn]) ){\n        if( z[iIn]==q ){\n          if( z[iIn+1]!=q ){\n            /* Character iIn was the close quote. */\n            iIn++;\n            break;\n          }else{\n            /* Character iIn and iIn+1 form an escaped quote character. Skip\n            ** the input cursor past both and copy a single quote character \n            ** to the output buffer. */\n            iIn += 2;\n            z[iOut++] = q;\n          }\n        }else{\n          z[iOut++] = z[iIn++];\n        }\n      }\n      z[iOut] = '\\0';\n    }\n  }\n}\n\n/*\n** This function is a no-op if *pRc is set to other than SQLITE_OK when it\n** is called. NULL is returned in this case.\n**\n** Otherwise, the SQL statement passed as the third argument is prepared\n** against the database handle passed as the second. If the statement is\n** successfully prepared, a pointer to the new statement handle is \n** returned. It is the responsibility of the caller to eventually free the\n** statement by calling sqlite3_finalize(). Alternatively, if statement\n** compilation fails, NULL is returned, *pRc is set to an SQLite error\n** code and *pzErr may be set to an error message buffer allocated by\n** sqlite3_malloc().\n*/\nstatic sqlite3_stmt *unionPrepare(\n  int *pRc,                       /* IN/OUT: Error code */\n  sqlite3 *db,                    /* Database handle */\n  const char *zSql,               /* SQL statement to prepare */\n  char **pzErr                    /* OUT: Error message */\n){\n  sqlite3_stmt *pRet = 0;\n  assert( pzErr );\n  if( *pRc==SQLITE_OK ){\n    int rc = sqlite3_prepare_v2(db, zSql, -1, &pRet, 0);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"sql error: %s\", sqlite3_errmsg(db));\n      *pRc = rc;\n    }\n  }\n  return pRet;\n}\n\n/*\n** Like unionPrepare(), except prepare the results of vprintf(zFmt, ...)\n** instead of a constant SQL string.\n*/\nstatic sqlite3_stmt *unionPreparePrintf(\n  int *pRc,                       /* IN/OUT: Error code */\n  char **pzErr,                   /* OUT: Error message */\n  sqlite3 *db,                    /* Database handle */\n  const char *zFmt,               /* printf() format string */\n  ...                             /* Trailing printf args */\n){\n  sqlite3_stmt *pRet = 0;\n  char *zSql;\n  va_list ap;\n  va_start(ap, zFmt);\n\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( *pRc==SQLITE_OK ){\n    if( zSql==0 ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      pRet = unionPrepare(pRc, db, zSql, pzErr);\n    }\n  }\n  sqlite3_free(zSql);\n\n  va_end(ap);\n  return pRet;\n}\n\n\n/*\n** Call sqlite3_reset() on SQL statement pStmt. If *pRc is set to \n** SQLITE_OK when this function is called, then it is set to the\n** value returned by sqlite3_reset() before this function exits.\n** In this case, *pzErr may be set to point to an error message\n** buffer allocated by sqlite3_malloc().\n*/\n#if 0\nstatic void unionReset(int *pRc, sqlite3_stmt *pStmt, char **pzErr){\n  int rc = sqlite3_reset(pStmt);\n  if( *pRc==SQLITE_OK ){\n    *pRc = rc;\n    if( rc ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(sqlite3_db_handle(pStmt)));\n    }\n  }\n}\n#endif\n\n/*\n** Call sqlite3_finalize() on SQL statement pStmt. If *pRc is set to \n** SQLITE_OK when this function is called, then it is set to the\n** value returned by sqlite3_finalize() before this function exits.\n*/\nstatic void unionFinalize(int *pRc, sqlite3_stmt *pStmt, char **pzErr){\n  sqlite3 *db = sqlite3_db_handle(pStmt);\n  int rc = sqlite3_finalize(pStmt);\n  if( *pRc==SQLITE_OK ){\n    *pRc = rc;\n    if( rc ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }\n}\n\n/*\n** This function is a no-op for unionvtab. For swarmvtab, it attempts to\n** close open database files until at most nMax are open. An SQLite error\n** code is returned if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic void unionCloseSources(UnionTab *pTab, int nMax){\n  while( pTab->pClosable && pTab->nOpen>nMax ){\n    UnionSrc **pp;\n    for(pp=&pTab->pClosable; (*pp)->pNextClosable; pp=&(*pp)->pNextClosable);\n    assert( (*pp)->db );\n    sqlite3_close((*pp)->db);\n    (*pp)->db = 0;\n    *pp = 0;\n    pTab->nOpen--;\n  }\n}\n\n/*\n** xDisconnect method.\n*/\nstatic int unionDisconnect(sqlite3_vtab *pVtab){\n  if( pVtab ){\n    UnionTab *pTab = (UnionTab*)pVtab;\n    int i;\n    for(i=0; i<pTab->nSrc; i++){\n      UnionSrc *pSrc = &pTab->aSrc[i];\n      sqlite3_free(pSrc->zDb);\n      sqlite3_free(pSrc->zTab);\n      sqlite3_free(pSrc->zFile);\n      sqlite3_close(pSrc->db);\n    }\n    sqlite3_free(pTab->zSourceStr);\n    sqlite3_free(pTab->zNotFoundCallback);\n    sqlite3_free(pTab->aSrc);\n    sqlite3_free(pTab);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Check that the table identified by pSrc is a rowid table. If not,\n** return SQLITE_ERROR and set (*pzErr) to point to an English language\n** error message. If the table is a rowid table and no error occurs,\n** return SQLITE_OK and leave (*pzErr) unmodified.\n*/\nstatic int unionIsIntkeyTable(\n  sqlite3 *db,                    /* Database handle */\n  UnionSrc *pSrc,                 /* Source table to test */\n  char **pzErr                    /* OUT: Error message */\n){\n  int bPk = 0;\n  const char *zType = 0;\n  int rc;\n\n  sqlite3_table_column_metadata(\n      db, pSrc->zDb, pSrc->zTab, \"_rowid_\", &zType, 0, 0, &bPk, 0\n  );\n  rc = sqlite3_errcode(db);\n  if( rc==SQLITE_ERROR \n   || (rc==SQLITE_OK && (!bPk || sqlite3_stricmp(\"integer\", zType)))\n  ){\n    rc = SQLITE_ERROR;\n    *pzErr = sqlite3_mprintf(\"no such rowid table: %s%s%s\",\n        (pSrc->zDb ? pSrc->zDb : \"\"),\n        (pSrc->zDb ? \".\" : \"\"),\n        pSrc->zTab\n    );\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is\n** called. In this case it returns NULL.\n**\n** Otherwise, this function checks that the source table passed as the\n** second argument (a) exists, (b) is not a view and (c) has a column \n** named \"_rowid_\" of type \"integer\" that is the primary key.\n** If this is not the case, *pRc is set to SQLITE_ERROR and NULL is\n** returned.\n**\n** Finally, if the source table passes the checks above, a nul-terminated\n** string describing the column names and types belonging to the source\n** table is returned. Tables with the same set of column names and types \n** cause this function to return identical strings. Is is the responsibility\n** of the caller to free the returned string using sqlite3_free() when\n** it is no longer required.\n*/\nstatic char *unionSourceToStr(\n  int *pRc,                       /* IN/OUT: Error code */\n  UnionTab *pTab,                 /* Virtual table object */\n  UnionSrc *pSrc,                 /* Source table to test */\n  char **pzErr                    /* OUT: Error message */\n){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    sqlite3 *db = unionGetDb(pTab, pSrc);\n    int rc = unionIsIntkeyTable(db, pSrc, pzErr);\n    sqlite3_stmt *pStmt = unionPrepare(&rc, db, \n        \"SELECT group_concat(quote(name) || '.' || quote(type)) \"\n        \"FROM pragma_table_info(?, ?)\", pzErr\n    );\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_text(pStmt, 1, pSrc->zTab, -1, SQLITE_STATIC);\n      sqlite3_bind_text(pStmt, 2, pSrc->zDb, -1, SQLITE_STATIC);\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        const char *z = (const char*)sqlite3_column_text(pStmt, 0);\n        zRet = unionStrdup(&rc, z);\n      }\n      unionFinalize(&rc, pStmt, pzErr);\n    }\n    *pRc = rc;\n  }\n\n  return zRet;\n}\n\n/*\n** Check that all configured source tables exist and have the same column\n** names and datatypes. If this is not the case, or if some other error\n** occurs, return an SQLite error code. In this case *pzErr may be set\n** to point to an error message buffer allocated by sqlite3_mprintf().\n** Or, if no problems regarding the source tables are detected and no\n** other error occurs, SQLITE_OK is returned.\n*/\nstatic int unionSourceCheck(UnionTab *pTab, char **pzErr){\n  int rc = SQLITE_OK;\n  char *z0 = 0;\n  int i;\n\n  assert( *pzErr==0 );\n  z0 = unionSourceToStr(&rc, pTab, &pTab->aSrc[0], pzErr);\n  for(i=1; i<pTab->nSrc; i++){\n    char *z = unionSourceToStr(&rc, pTab, &pTab->aSrc[i], pzErr);\n    if( rc==SQLITE_OK && sqlite3_stricmp(z, z0) ){\n      *pzErr = sqlite3_mprintf(\"source table schema mismatch\");\n      rc = SQLITE_ERROR;\n    }\n    sqlite3_free(z);\n  }\n  sqlite3_free(z0);\n\n  return rc;\n}\n\n\n/*\n** Try to open the swarmvtab database.  If initially unable, invoke the\n** not-found callback UDF and then try again.\n*/\nstatic int unionOpenDatabaseInner(UnionTab *pTab, UnionSrc *pSrc, char **pzErr){\n  int rc = SQLITE_OK;\n  static const int openFlags = \n       SQLITE_OPEN_READONLY | SQLITE_OPEN_URI;\n  rc = sqlite3_open_v2(pSrc->zFile, &pSrc->db, openFlags, 0);\n  if( rc==SQLITE_OK ) return rc;\n  if( pTab->zNotFoundCallback ){\n    char *zSql = sqlite3_mprintf(\"SELECT \\\"%w\\\"(%Q);\",\n                    pTab->zNotFoundCallback, pSrc->zFile);\n    sqlite3_close(pSrc->db);\n    pSrc->db = 0;\n    if( zSql==0 ){\n      *pzErr = sqlite3_mprintf(\"out of memory\");\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_exec(pTab->db, zSql, 0, 0, pzErr);\n    sqlite3_free(zSql);\n    if( rc ) return rc;\n    rc = sqlite3_open_v2(pSrc->zFile, &pSrc->db, openFlags, 0);\n  }\n  if( rc!=SQLITE_OK ){\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pSrc->db));\n  }\n  return rc;\n}\n\n/*\n** This function may only be called for swarmvtab tables. The results of\n** calling it on a unionvtab table are undefined.\n**\n** For a swarmvtab table, this function ensures that source database iSrc\n** is open. If the database is opened successfully and the schema is as\n** expected, or if it is already open when this function is called, SQLITE_OK\n** is returned.\n**\n** Alternatively If an error occurs while opening the databases, or if the\n** database schema is unsuitable, an SQLite error code is returned and (*pzErr)\n** may be set to point to an English language error message. In this case it is\n** the responsibility of the caller to eventually free the error message buffer\n** using sqlite3_free(). \n*/\nstatic int unionOpenDatabase(UnionTab *pTab, int iSrc, char **pzErr){\n  int rc = SQLITE_OK;\n  UnionSrc *pSrc = &pTab->aSrc[iSrc];\n\n  assert( pTab->bSwarm && iSrc<pTab->nSrc );\n  if( pSrc->db==0 ){\n    unionCloseSources(pTab, pTab->nMaxOpen-1);\n    rc = unionOpenDatabaseInner(pTab, pSrc, pzErr);\n    if( rc==SQLITE_OK ){\n      char *z = unionSourceToStr(&rc, pTab, pSrc, pzErr);\n      if( rc==SQLITE_OK ){\n        if( pTab->zSourceStr==0 ){\n          pTab->zSourceStr = z;\n        }else{\n          if( sqlite3_stricmp(z, pTab->zSourceStr) ){\n            *pzErr = sqlite3_mprintf(\"source table schema mismatch\");\n            rc = SQLITE_ERROR;\n          }\n          sqlite3_free(z);\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      pSrc->pNextClosable = pTab->pClosable;\n      pTab->pClosable = pSrc;\n      pTab->nOpen++;\n    }else{\n      sqlite3_close(pSrc->db);\n      pSrc->db = 0;\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** This function is a no-op for unionvtab tables. For swarmvtab, increment \n** the reference count for source table iTab. If the reference count was\n** zero before it was incremented, also remove the source from the closable\n** list.\n*/\nstatic void unionIncrRefcount(UnionTab *pTab, int iTab){\n  if( pTab->bSwarm ){\n    UnionSrc *pSrc = &pTab->aSrc[iTab];\n    assert( pSrc->nUser>=0 && pSrc->db );\n    if( pSrc->nUser==0 ){\n      UnionSrc **pp;\n      for(pp=&pTab->pClosable; *pp!=pSrc; pp=&(*pp)->pNextClosable);\n      *pp = pSrc->pNextClosable;\n      pSrc->pNextClosable = 0;\n    }\n    pSrc->nUser++;\n  }\n}\n\n/*\n** Finalize the SQL statement pCsr->pStmt and return the result.\n**\n** If this is a swarmvtab table (not unionvtab) and pCsr->pStmt was not\n** NULL when this function was called, also decrement the reference\n** count on the associated source table. If this means the source tables\n** refcount is now zero, add it to the closable list.\n*/\nstatic int unionFinalizeCsrStmt(UnionCsr *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->pStmt ){\n    UnionTab *pTab = (UnionTab*)pCsr->base.pVtab;\n    UnionSrc *pSrc = &pTab->aSrc[pCsr->iTab];\n    rc = sqlite3_finalize(pCsr->pStmt);\n    pCsr->pStmt = 0;\n    if( pTab->bSwarm ){\n      pSrc->nUser--;\n      assert( pSrc->nUser>=0 );\n      if( pSrc->nUser==0 ){\n        pSrc->pNextClosable = pTab->pClosable;\n        pTab->pClosable = pSrc;\n      }\n      unionCloseSources(pTab, pTab->nMaxOpen);\n    }\n  }\n  return rc;\n}\n\n/* \n** xConnect/xCreate method.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"unionvtab\" or \"swarmvtab\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[3]   -> SQL statement\n**   argv[4]   -> not-found callback UDF name\n*/\nstatic int unionConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  UnionTab *pTab = 0;\n  int rc = SQLITE_OK;\n  int bSwarm = (pAux==0 ? 0 : 1);\n  const char *zVtab = (bSwarm ? \"swarmvtab\" : \"unionvtab\");\n\n  if( sqlite3_stricmp(\"temp\", argv[1]) ){\n    /* unionvtab tables may only be created in the temp schema */\n    *pzErr = sqlite3_mprintf(\"%s tables must be created in TEMP schema\", zVtab);\n    rc = SQLITE_ERROR;\n  }else if( argc!=4 && argc!=5 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of arguments for %s\", zVtab);\n    rc = SQLITE_ERROR;\n  }else{\n    int nAlloc = 0;               /* Allocated size of pTab->aSrc[] */\n    sqlite3_stmt *pStmt = 0;      /* Argument statement */\n    char *zArg = unionStrdup(&rc, argv[3]);      /* Copy of argument to CVT */\n\n    /* Prepare the SQL statement. Instead of executing it directly, sort\n    ** the results by the \"minimum rowid\" field. This makes it easier to\n    ** check that there are no rowid range overlaps between source tables \n    ** and that the UnionTab.aSrc[] array is always sorted by rowid.  */\n    unionDequote(zArg);\n    pStmt = unionPreparePrintf(&rc, pzErr, db, \n        \"SELECT * FROM (%z) ORDER BY 3\", zArg\n    );\n\n    /* Allocate the UnionTab structure */\n    pTab = unionMalloc(&rc, sizeof(UnionTab));\n\n    /* Iterate through the rows returned by the SQL statement specified\n    ** as an argument to the CREATE VIRTUAL TABLE statement. */\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);\n      const char *zTab = (const char*)sqlite3_column_text(pStmt, 1);\n      sqlite3_int64 iMin = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iMax = sqlite3_column_int64(pStmt, 3);\n      UnionSrc *pSrc;\n\n      /* Grow the pTab->aSrc[] array if required. */\n      if( nAlloc<=pTab->nSrc ){\n        int nNew = nAlloc ? nAlloc*2 : 8;\n        UnionSrc *aNew = (UnionSrc*)sqlite3_realloc(\n            pTab->aSrc, nNew*sizeof(UnionSrc)\n        );\n        if( aNew==0 ){\n          rc = SQLITE_NOMEM;\n          break;\n        }else{\n          memset(&aNew[pTab->nSrc], 0, (nNew-pTab->nSrc)*sizeof(UnionSrc));\n          pTab->aSrc = aNew;\n          nAlloc = nNew;\n        }\n      }\n\n      /* Check for problems with the specified range of rowids */\n      if( iMax<iMin || (pTab->nSrc>0 && iMin<=pTab->aSrc[pTab->nSrc-1].iMax) ){\n        *pzErr = sqlite3_mprintf(\"rowid range mismatch error\");\n        rc = SQLITE_ERROR;\n      }\n\n      if( rc==SQLITE_OK ){\n        pSrc = &pTab->aSrc[pTab->nSrc++];\n        pSrc->zTab = unionStrdup(&rc, zTab);\n        pSrc->iMin = iMin;\n        pSrc->iMax = iMax;\n        if( bSwarm ){\n          pSrc->zFile = unionStrdup(&rc, zDb);\n        }else{\n          pSrc->zDb = unionStrdup(&rc, zDb);\n        }\n      }\n    }\n    unionFinalize(&rc, pStmt, pzErr);\n    pStmt = 0;\n\n    /* Capture the not-found callback UDF name */\n    if( rc==SQLITE_OK && argc>=5 ){\n      pTab->zNotFoundCallback = unionStrdup(&rc, argv[4]);\n      unionDequote(pTab->zNotFoundCallback);\n    }\n\n    /* It is an error if the SELECT statement returned zero rows. If only\n    ** because there is no way to determine the schema of the virtual \n    ** table in this case.  */\n    if( rc==SQLITE_OK && pTab->nSrc==0 ){\n      *pzErr = sqlite3_mprintf(\"no source tables configured\");\n      rc = SQLITE_ERROR;\n    }\n\n    /* For unionvtab, verify that all source tables exist and have \n    ** compatible schemas. For swarmvtab, attach the first database and\n    ** check that the first table is a rowid table only.  */\n    if( rc==SQLITE_OK ){\n      pTab->db = db;\n      pTab->bSwarm = bSwarm;\n      pTab->nMaxOpen = SWARMVTAB_MAX_OPEN;\n      if( bSwarm ){\n        rc = unionOpenDatabase(pTab, 0, pzErr);\n      }else{\n        rc = unionSourceCheck(pTab, pzErr);\n      }\n    }\n\n    /* Compose a CREATE TABLE statement and pass it to declare_vtab() */\n    if( rc==SQLITE_OK ){\n      UnionSrc *pSrc = &pTab->aSrc[0];\n      sqlite3 *tdb = unionGetDb(pTab, pSrc);\n      pStmt = unionPreparePrintf(&rc, pzErr, tdb, \"SELECT \"\n          \"'CREATE TABLE xyz('\"\n          \"    || group_concat(quote(name) || ' ' || type, ', ')\"\n          \"    || ')',\"\n          \"max((cid+1) * (type='INTEGER' COLLATE nocase AND pk=1))-1 \"\n          \"FROM pragma_table_info(%Q, ?)\", \n          pSrc->zTab, pSrc->zDb\n      );\n    }\n    if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zDecl = (const char*)sqlite3_column_text(pStmt, 0);\n      rc = sqlite3_declare_vtab(db, zDecl);\n      pTab->iPK = sqlite3_column_int(pStmt, 1);\n    }\n\n    unionFinalize(&rc, pStmt, pzErr);\n  }\n\n  if( rc!=SQLITE_OK ){\n    unionDisconnect((sqlite3_vtab*)pTab);\n    pTab = 0;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** xOpen\n*/\nstatic int unionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  UnionCsr *pCsr;\n  int rc = SQLITE_OK;\n  (void)p;  /* Suppress harmless warning */\n  pCsr = (UnionCsr*)unionMalloc(&rc, sizeof(UnionCsr));\n  *ppCursor = &pCsr->base;\n  return rc;\n}\n\n/*\n** xClose\n*/\nstatic int unionClose(sqlite3_vtab_cursor *cur){\n  UnionCsr *pCsr = (UnionCsr*)cur;\n  unionFinalizeCsrStmt(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** This function does the work of the xNext() method. Except that, if it\n** returns SQLITE_ROW, it should be called again within the same xNext()\n** method call. See unionNext() for details.\n*/\nstatic int doUnionNext(UnionCsr *pCsr){\n  int rc = SQLITE_OK;\n  assert( pCsr->pStmt );\n  if( sqlite3_step(pCsr->pStmt)!=SQLITE_ROW ){\n    UnionTab *pTab = (UnionTab*)pCsr->base.pVtab;\n    rc = unionFinalizeCsrStmt(pCsr);\n    if( rc==SQLITE_OK && pTab->bSwarm ){\n      pCsr->iTab++;\n      if( pCsr->iTab<pTab->nSrc ){\n        UnionSrc *pSrc = &pTab->aSrc[pCsr->iTab];\n        if( pCsr->iMaxRowid>=pSrc->iMin ){\n          /* It is necessary to scan the next table. */\n          rc = unionOpenDatabase(pTab, pCsr->iTab, &pTab->base.zErrMsg);\n          pCsr->pStmt = unionPreparePrintf(&rc, &pTab->base.zErrMsg, pSrc->db,\n              \"SELECT rowid, * FROM %Q %s %lld\",\n              pSrc->zTab,\n              (pSrc->iMax>pCsr->iMaxRowid ? \"WHERE _rowid_ <=\" : \"-- \"),\n              pCsr->iMaxRowid\n          );\n          if( rc==SQLITE_OK ){\n            assert( pCsr->pStmt );\n            unionIncrRefcount(pTab, pCsr->iTab);\n            rc = SQLITE_ROW;\n          }\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** xNext\n*/\nstatic int unionNext(sqlite3_vtab_cursor *cur){\n  int rc;\n  do {\n    rc = doUnionNext((UnionCsr*)cur);\n  }while( rc==SQLITE_ROW );\n  return rc;\n}\n\n/*\n** xColumn\n*/\nstatic int unionColumn(\n  sqlite3_vtab_cursor *cur,\n  sqlite3_context *ctx,\n  int i\n){\n  UnionCsr *pCsr = (UnionCsr*)cur;\n  sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pStmt, i+1));\n  return SQLITE_OK;\n}\n\n/*\n** xRowid\n*/\nstatic int unionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  UnionCsr *pCsr = (UnionCsr*)cur;\n  *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);\n  return SQLITE_OK;\n}\n\n/*\n** xEof\n*/\nstatic int unionEof(sqlite3_vtab_cursor *cur){\n  UnionCsr *pCsr = (UnionCsr*)cur;\n  return pCsr->pStmt==0;\n}\n\n/*\n** xFilter\n*/\nstatic int unionFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  UnionTab *pTab = (UnionTab*)(pVtabCursor->pVtab);\n  UnionCsr *pCsr = (UnionCsr*)pVtabCursor;\n  int rc = SQLITE_OK;\n  int i;\n  char *zSql = 0;\n  int bZero = 0;\n\n  sqlite3_int64 iMin = SMALLEST_INT64;\n  sqlite3_int64 iMax = LARGEST_INT64;\n\n  assert( idxNum==0 \n       || idxNum==SQLITE_INDEX_CONSTRAINT_EQ\n       || idxNum==SQLITE_INDEX_CONSTRAINT_LE\n       || idxNum==SQLITE_INDEX_CONSTRAINT_GE\n       || idxNum==SQLITE_INDEX_CONSTRAINT_LT\n       || idxNum==SQLITE_INDEX_CONSTRAINT_GT\n       || idxNum==(SQLITE_INDEX_CONSTRAINT_GE|SQLITE_INDEX_CONSTRAINT_LE)\n  );\n\n  (void)idxStr;  /* Suppress harmless warning */\n  \n  if( idxNum==SQLITE_INDEX_CONSTRAINT_EQ ){\n    assert( argc==1 );\n    iMin = iMax = sqlite3_value_int64(argv[0]);\n  }else{\n\n    if( idxNum & (SQLITE_INDEX_CONSTRAINT_LE|SQLITE_INDEX_CONSTRAINT_LT) ){\n      assert( argc>=1 );\n      iMax = sqlite3_value_int64(argv[0]);\n      if( idxNum & SQLITE_INDEX_CONSTRAINT_LT ){\n        if( iMax==SMALLEST_INT64 ){\n          bZero = 1;\n        }else{\n          iMax--;\n        }\n      }\n    }\n\n    if( idxNum & (SQLITE_INDEX_CONSTRAINT_GE|SQLITE_INDEX_CONSTRAINT_GT) ){\n      assert( argc>=1 );\n      iMin = sqlite3_value_int64(argv[argc-1]);\n      if( idxNum & SQLITE_INDEX_CONSTRAINT_GT ){\n        if( iMin==LARGEST_INT64 ){\n          bZero = 1;\n        }else{\n          iMin++;\n        }\n      }\n    }\n  }\n\n  unionFinalizeCsrStmt(pCsr);\n  if( bZero ){\n    return SQLITE_OK;\n  }\n\n  for(i=0; i<pTab->nSrc; i++){\n    UnionSrc *pSrc = &pTab->aSrc[i];\n    if( iMin>pSrc->iMax || iMax<pSrc->iMin ){\n      continue;\n    }\n\n    zSql = sqlite3_mprintf(\"%z%sSELECT rowid, * FROM %s%q%s%Q\"\n        , zSql\n        , (zSql ? \" UNION ALL \" : \"\")\n        , (pSrc->zDb ? \"'\" : \"\")\n        , (pSrc->zDb ? pSrc->zDb : \"\")\n        , (pSrc->zDb ? \"'.\" : \"\")\n        , pSrc->zTab\n    );\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n      break;\n    }\n\n    if( iMin==iMax ){\n      zSql = sqlite3_mprintf(\"%z WHERE rowid=%lld\", zSql, iMin);\n    }else{\n      const char *zWhere = \"WHERE\";\n      if( iMin!=SMALLEST_INT64 && iMin>pSrc->iMin ){\n        zSql = sqlite3_mprintf(\"%z WHERE rowid>=%lld\", zSql, iMin);\n        zWhere = \"AND\";\n      }\n      if( iMax!=LARGEST_INT64 && iMax<pSrc->iMax ){\n        zSql = sqlite3_mprintf(\"%z %s rowid<=%lld\", zSql, zWhere, iMax);\n      }\n    }\n\n    if( pTab->bSwarm ){\n      pCsr->iTab = i;\n      pCsr->iMaxRowid = iMax;\n      rc = unionOpenDatabase(pTab, i, &pTab->base.zErrMsg);\n      break;\n    }\n  }\n\n  if( zSql==0 ){\n    return rc;\n  }else{\n    sqlite3 *db = unionGetDb(pTab, &pTab->aSrc[pCsr->iTab]);\n    pCsr->pStmt = unionPrepare(&rc, db, zSql, &pTab->base.zErrMsg);\n    if( pCsr->pStmt ){\n      unionIncrRefcount(pTab, pCsr->iTab);\n    }\n    sqlite3_free(zSql);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n  return unionNext(pVtabCursor);\n}\n\n/*\n** xBestIndex.\n**\n** This implementation searches for constraints on the rowid field. EQ, \n** LE, LT, GE and GT are handled.\n**\n** If there is an EQ comparison, then idxNum is set to INDEX_CONSTRAINT_EQ.\n** In this case the only argument passed to xFilter is the rhs of the ==\n** operator.\n**\n** Otherwise, if an LE or LT constraint is found, then the INDEX_CONSTRAINT_LE\n** or INDEX_CONSTRAINT_LT (but not both) bit is set in idxNum. The first\n** argument to xFilter is the rhs of the <= or < operator.  Similarly, if \n** an GE or GT constraint is found, then the INDEX_CONSTRAINT_GE or\n** INDEX_CONSTRAINT_GT bit is set in idxNum. The rhs of the >= or > operator\n** is passed as either the first or second argument to xFilter, depending\n** on whether or not there is also a LT|LE constraint.\n*/\nstatic int unionBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  UnionTab *pTab = (UnionTab*)tab;\n  int iEq = -1;\n  int iLt = -1;\n  int iGt = -1;\n  int i;\n\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];\n    if( p->usable && (p->iColumn<0 || p->iColumn==pTab->iPK) ){\n      switch( p->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ:\n          iEq = i;\n          break;\n        case SQLITE_INDEX_CONSTRAINT_LE:\n        case SQLITE_INDEX_CONSTRAINT_LT:\n          iLt = i;\n          break;\n        case SQLITE_INDEX_CONSTRAINT_GE:\n        case SQLITE_INDEX_CONSTRAINT_GT:\n          iGt = i;\n          break;\n      }\n    }\n  }\n\n  if( iEq>=0 ){\n    pIdxInfo->estimatedRows = 1;\n    pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n    pIdxInfo->estimatedCost = 3.0;\n    pIdxInfo->idxNum = SQLITE_INDEX_CONSTRAINT_EQ;\n    pIdxInfo->aConstraintUsage[iEq].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[iEq].omit = 1;\n  }else{\n    int iCons = 1;\n    int idxNum = 0;\n    sqlite3_int64 nRow = 1000000;\n    if( iLt>=0 ){\n      nRow = nRow / 2;\n      pIdxInfo->aConstraintUsage[iLt].argvIndex = iCons++;\n      pIdxInfo->aConstraintUsage[iLt].omit = 1;\n      idxNum |= pIdxInfo->aConstraint[iLt].op;\n    }\n    if( iGt>=0 ){\n      nRow = nRow / 2;\n      pIdxInfo->aConstraintUsage[iGt].argvIndex = iCons++;\n      pIdxInfo->aConstraintUsage[iGt].omit = 1;\n      idxNum |= pIdxInfo->aConstraint[iGt].op;\n    }\n    pIdxInfo->estimatedRows = nRow;\n    pIdxInfo->estimatedCost = 3.0 * (double)nRow;\n    pIdxInfo->idxNum = idxNum;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Register the unionvtab virtual table module with database handle db.\n*/\nstatic int createUnionVtab(sqlite3 *db){\n  static sqlite3_module unionModule = {\n    0,                            /* iVersion */\n    unionConnect,\n    unionConnect,\n    unionBestIndex,               /* xBestIndex - query planner */\n    unionDisconnect, \n    unionDisconnect,\n    unionOpen,                    /* xOpen - open a cursor */\n    unionClose,                   /* xClose - close a cursor */\n    unionFilter,                  /* xFilter - configure scan constraints */\n    unionNext,                    /* xNext - advance a cursor */\n    unionEof,                     /* xEof - check for end of scan */\n    unionColumn,                  /* xColumn - read data */\n    unionRowid,                   /* xRowid - read data */\n    0,                            /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0                             /* xRollbackTo */\n  };\n  int rc;\n\n  rc = sqlite3_create_module(db, \"unionvtab\", &unionModule, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_module(db, \"swarmvtab\", &unionModule, (void*)db);\n  }\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_unionvtab_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Suppress harmless warning */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = createUnionVtab(db);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/vfslog.c",
    "content": "/*\n** 2013-10-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of an SQLite vfs wrapper for\n** unix that generates per-database log files of all disk activity.\n*/\n\n/*\n** This module contains code for a wrapper VFS that causes a log of\n** most VFS calls to be written into a file on disk.\n**\n** Each database connection creates a separate log file in the same\n** directory as the original database and named after the original\n** database.  A unique suffix is added to avoid name collisions.  \n** Separate log files are used so that concurrent processes do not\n** try to write log operations to the same file at the same instant, \n** resulting in overwritten or comingled log text.\n**\n** Each individual log file records operations by a single database\n** connection on both the original database and its associated rollback\n** journal.\n**\n** The log files are in the comma-separated-value (CSV) format.  The\n** log files can be imported into an SQLite database using the \".import\"\n** command of the SQLite command-line shell for analysis.\n**\n** One technique for using this module is to append the text of this\n** module to the end of a standard \"sqlite3.c\" amalgamation file then\n** add the following compile-time options:\n**\n**     -DSQLITE_EXTRA_INIT=sqlite3_register_vfslog\n**     -DSQLITE_USE_FCNTL_TRACE\n**\n** The first compile-time option causes the sqlite3_register_vfslog()\n** function, defined below, to be invoked when SQLite is initialized.\n** That causes this custom VFS to become the default VFS for all\n** subsequent connections.  The SQLITE_USE_FCNTL_TRACE option causes\n** the SQLite core to issue extra sqlite3_file_control() operations\n** with SQLITE_FCNTL_TRACE to give some indication of what is going\n** on in the core.\n*/\n\n#include \"sqlite3.h\"\n#include <string.h>\n#include <assert.h>\n#include <stdio.h>\n#if SQLITE_OS_UNIX\n# include <unistd.h>\n#endif\n\n/*\n** Forward declaration of objects used by this utility\n*/\ntypedef struct VLogLog VLogLog;\ntypedef struct VLogVfs VLogVfs;\ntypedef struct VLogFile VLogFile;\n\n/* There is a pair (an array of size 2) of the following objects for\n** each database file being logged.  The first contains the filename\n** and is used to log I/O with the main database.  The second has\n** a NULL filename and is used to log I/O for the journal.  Both\n** out pointers are the same.\n*/\nstruct VLogLog {\n  VLogLog *pNext;                 /* Next in a list of all active logs */\n  VLogLog **ppPrev;               /* Pointer to this in the list */\n  int nRef;                       /* Number of references to this object */\n  int nFilename;                  /* Length of zFilename in bytes */\n  char *zFilename;                /* Name of database file.  NULL for journal */\n  FILE *out;                      /* Write information here */\n};\n\nstruct VLogVfs {\n  sqlite3_vfs base;               /* VFS methods */\n  sqlite3_vfs *pVfs;              /* Parent VFS */\n};\n\nstruct VLogFile {\n  sqlite3_file base;              /* IO methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  VLogLog *pLog;                  /* The log file for this file */\n};\n\n#define REALVFS(p) (((VLogVfs*)(p))->pVfs)\n\n/*\n** Methods for VLogFile\n*/\nstatic int vlogClose(sqlite3_file*);\nstatic int vlogRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int vlogWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int vlogTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int vlogSync(sqlite3_file*, int flags);\nstatic int vlogFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int vlogLock(sqlite3_file*, int);\nstatic int vlogUnlock(sqlite3_file*, int);\nstatic int vlogCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int vlogFileControl(sqlite3_file*, int op, void *pArg);\nstatic int vlogSectorSize(sqlite3_file*);\nstatic int vlogDeviceCharacteristics(sqlite3_file*);\n\n/*\n** Methods for VLogVfs\n*/\nstatic int vlogOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int vlogDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int vlogAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int vlogFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *vlogDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void vlogDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void);\nstatic void vlogDlClose(sqlite3_vfs*, void*);\nstatic int vlogRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int vlogSleep(sqlite3_vfs*, int microseconds);\nstatic int vlogCurrentTime(sqlite3_vfs*, double*);\nstatic int vlogGetLastError(sqlite3_vfs*, int, char *);\nstatic int vlogCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\n\nstatic VLogVfs vlog_vfs = {\n  {\n    1,                            /* iVersion */\n    0,                            /* szOsFile (set by register_vlog()) */\n    1024,                         /* mxPathname */\n    0,                            /* pNext */\n    \"vfslog\",                     /* zName */\n    0,                            /* pAppData */\n    vlogOpen,                     /* xOpen */\n    vlogDelete,                   /* xDelete */\n    vlogAccess,                   /* xAccess */\n    vlogFullPathname,             /* xFullPathname */\n    vlogDlOpen,                   /* xDlOpen */\n    vlogDlError,                  /* xDlError */\n    vlogDlSym,                    /* xDlSym */\n    vlogDlClose,                  /* xDlClose */\n    vlogRandomness,               /* xRandomness */\n    vlogSleep,                    /* xSleep */\n    vlogCurrentTime,              /* xCurrentTime */\n    vlogGetLastError,             /* xGetLastError */\n    vlogCurrentTimeInt64          /* xCurrentTimeInt64 */\n  },\n  0\n};\n\nstatic sqlite3_io_methods vlog_io_methods = {\n  1,                              /* iVersion */\n  vlogClose,                      /* xClose */\n  vlogRead,                       /* xRead */\n  vlogWrite,                      /* xWrite */\n  vlogTruncate,                   /* xTruncate */\n  vlogSync,                       /* xSync */\n  vlogFileSize,                   /* xFileSize */\n  vlogLock,                       /* xLock */\n  vlogUnlock,                     /* xUnlock */\n  vlogCheckReservedLock,          /* xCheckReservedLock */\n  vlogFileControl,                /* xFileControl */\n  vlogSectorSize,                 /* xSectorSize */\n  vlogDeviceCharacteristics,      /* xDeviceCharacteristics */\n  0,                              /* xShmMap */\n  0,                              /* xShmLock */\n  0,                              /* xShmBarrier */\n  0                               /* xShmUnmap */\n};\n\n#if SQLITE_OS_UNIX && !defined(NO_GETTOD)\n#include <sys/time.h>\nstatic sqlite3_uint64 vlog_time(){\n  struct timeval sTime;\n  gettimeofday(&sTime, 0);\n  return sTime.tv_usec + (sqlite3_uint64)sTime.tv_sec * 1000000;\n}\n#elif SQLITE_OS_WIN\n#include <windows.h>\n#include <time.h>\nstatic sqlite3_uint64 vlog_time(){\n  FILETIME ft;\n  sqlite3_uint64 u64time = 0;\n \n  GetSystemTimeAsFileTime(&ft);\n\n  u64time |= ft.dwHighDateTime;\n  u64time <<= 32;\n  u64time |= ft.dwLowDateTime;\n\n  /* ft is 100-nanosecond intervals, we want microseconds */\n  return u64time /(sqlite3_uint64)10;\n}\n#else\nstatic sqlite3_uint64 vlog_time(){\n  return 0;\n}\n#endif\n\n\n/*\n** Write a message to the log file\n*/\nstatic void vlogLogPrint(\n  VLogLog *pLog,                 /* The log file to write into */\n  sqlite3_int64 tStart,            /* Start time of system call */\n  sqlite3_int64 tElapse,           /* Elapse time of system call */\n  const char *zOp,                 /* Type of system call */\n  sqlite3_int64 iArg1,             /* First argument */\n  sqlite3_int64 iArg2,             /* Second argument */\n  const char *zArg3,               /* Third argument */\n  int iRes                         /* Result */\n){\n  char z1[40], z2[40], z3[2000];\n  if( pLog==0 ) return;\n  if( iArg1>=0 ){\n    sqlite3_snprintf(sizeof(z1), z1, \"%lld\", iArg1);\n  }else{\n    z1[0] = 0;\n  }\n  if( iArg2>=0 ){\n    sqlite3_snprintf(sizeof(z2), z2, \"%lld\", iArg2);\n  }else{\n    z2[0] = 0;\n  }\n  if( zArg3 ){\n    sqlite3_snprintf(sizeof(z3), z3, \"\\\"%.*w\\\"\", sizeof(z3)-4, zArg3);\n  }else{\n    z3[0] = 0;\n  }\n  fprintf(pLog->out,\"%lld,%lld,%s,%d,%s,%s,%s,%d\\n\",\n      tStart, tElapse, zOp, pLog->zFilename==0, z1, z2, z3, iRes);\n}\n\n/*\n** List of all active log connections.  Protected by the master mutex.\n*/\nstatic VLogLog *allLogs = 0;\n\n/*\n** Close a VLogLog object\n*/\nstatic void vlogLogClose(VLogLog *p){\n  if( p ){\n    sqlite3_mutex *pMutex;\n    p->nRef--;\n    if( p->nRef>0 || p->zFilename==0 ) return;\n    pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);\n    sqlite3_mutex_enter(pMutex);\n    *p->ppPrev = p->pNext;\n    if( p->pNext ) p->pNext->ppPrev = p->ppPrev;\n    sqlite3_mutex_leave(pMutex);\n    fclose(p->out);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Open a VLogLog object on the given file\n*/\nstatic VLogLog *vlogLogOpen(const char *zFilename){\n  int nName = (int)strlen(zFilename);\n  int isJournal = 0;\n  sqlite3_mutex *pMutex;\n  VLogLog *pLog, *pTemp;\n  sqlite3_int64 tNow = 0;\n  if( nName>4 && strcmp(zFilename+nName-4,\"-wal\")==0 ){\n    return 0;  /* Do not log wal files */\n  }else\n  if( nName>8 && strcmp(zFilename+nName-8,\"-journal\")==0 ){\n    nName -= 8;\n    isJournal = 1;\n  }else if( nName>12 \n         && sqlite3_strglob(\"-mj??????9??\", zFilename+nName-12)==0 ){\n    return 0;  /* Do not log master journal files */\n  }\n  pTemp = sqlite3_malloc( sizeof(*pLog)*2 + nName + 60 );\n  if( pTemp==0 ) return 0;\n  pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);\n  sqlite3_mutex_enter(pMutex);\n  for(pLog=allLogs; pLog; pLog=pLog->pNext){\n    if( pLog->nFilename==nName && !memcmp(pLog->zFilename, zFilename, nName) ){\n      break;\n    }\n  }\n  if( pLog==0 ){\n    pLog = pTemp;\n    pTemp = 0;\n    memset(pLog, 0, sizeof(*pLog)*2);\n    pLog->zFilename = (char*)&pLog[2];\n    tNow = vlog_time();\n    sqlite3_snprintf(nName+60, pLog->zFilename, \"%.*s-debuglog-%lld\",\n                     nName, zFilename, tNow);\n    pLog->out = fopen(pLog->zFilename, \"a\");\n    if( pLog->out==0 ){\n      sqlite3_mutex_leave(pMutex);\n      sqlite3_free(pLog);\n      return 0;\n    }\n    pLog->nFilename = nName;\n    pLog[1].out = pLog[0].out;\n    pLog->ppPrev = &allLogs;\n    if( allLogs ) allLogs->ppPrev = &pLog->pNext;\n    pLog->pNext = allLogs;\n    allLogs = pLog;\n  }\n  sqlite3_mutex_leave(pMutex);\n  if( pTemp ){\n    sqlite3_free(pTemp);\n  }else{\n#if SQLITE_OS_UNIX\n    char zHost[200];\n    zHost[0] = 0;\n    gethostname(zHost, sizeof(zHost)-1);\n    zHost[sizeof(zHost)-1] = 0;\n    vlogLogPrint(pLog, tNow, 0, \"IDENT\", getpid(), -1, zHost, 0);\n#endif\n  }\n  if( pLog && isJournal ) pLog++;\n  pLog->nRef++;\n  return pLog;\n}\n\n\n/*\n** Close an vlog-file.\n*/\nstatic int vlogClose(sqlite3_file *pFile){\n  sqlite3_uint64 tStart, tElapse;\n  int rc = SQLITE_OK;\n  VLogFile *p = (VLogFile *)pFile;\n\n  tStart = vlog_time();\n  if( p->pReal->pMethods ){\n    rc = p->pReal->pMethods->xClose(p->pReal);\n  }\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"CLOSE\", -1, -1, 0, rc);\n  vlogLogClose(p->pLog);\n  return rc;\n}\n\n/*\n** Compute signature for a block of content.\n**\n** For blocks of 16 or fewer bytes, the signature is just a hex dump of\n** the entire block.\n**\n** For blocks of more than 16 bytes, the signature is a hex dump of the\n** first 8 bytes followed by a 64-bit has of the entire block.\n*/\nstatic void vlogSignature(unsigned char *p, int n, char *zCksum){\n  unsigned int s0 = 0, s1 = 0;\n  unsigned int *pI;\n  int i;\n  if( n<=16 ){\n    for(i=0; i<n; i++) sqlite3_snprintf(3, zCksum+i*2, \"%02x\", p[i]);\n  }else{ \n    pI = (unsigned int*)p;\n    for(i=0; i<n-7; i+=8){\n      s0 += pI[0] + s1;\n      s1 += pI[1] + s0;\n      pI += 2;\n    }\n    for(i=0; i<8; i++) sqlite3_snprintf(3, zCksum+i*2, \"%02x\", p[i]);\n    sqlite3_snprintf(18, zCksum+i*2, \"-%08x%08x\", s0, s1);\n  }\n}\n\n/*\n** Convert a big-endian 32-bit integer into a native integer\n*/\nstatic int bigToNative(const unsigned char *x){\n  return (x[0]<<24) + (x[1]<<16) + (x[2]<<8) + x[3];\n}\n\n/*\n** Read data from an vlog-file.\n*/\nstatic int vlogRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  char zSig[40];\n\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n  tElapse = vlog_time() - tStart;\n  if( rc==SQLITE_OK ){\n    vlogSignature(zBuf, iAmt, zSig);\n  }else{\n    zSig[0] = 0;\n  }\n  vlogLogPrint(p->pLog, tStart, tElapse, \"READ\", iAmt, iOfst, zSig, rc);\n  if( rc==SQLITE_OK\n   && p->pLog\n   && p->pLog->zFilename\n   && iOfst<=24\n   && iOfst+iAmt>=28\n  ){\n    unsigned char *x = ((unsigned char*)zBuf)+(24-iOfst);\n    unsigned iCtr, nFree = -1;\n    char *zFree = 0;\n    char zStr[12];\n    iCtr = bigToNative(x);\n    if( iOfst+iAmt>=40 ){\n      zFree = zStr;\n      sqlite3_snprintf(sizeof(zStr), zStr, \"%d\", bigToNative(x+8));\n      nFree = bigToNative(x+12);\n    }\n    vlogLogPrint(p->pLog, tStart, 0, \"CHNGCTR-READ\", iCtr, nFree, zFree, 0);\n  }\n  return rc;\n}\n\n/*\n** Write data to an vlog-file.\n*/\nstatic int vlogWrite(\n  sqlite3_file *pFile,\n  const void *z,\n  int iAmt,\n  sqlite_int64 iOfst\n){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  char zSig[40];\n\n  tStart = vlog_time();\n  vlogSignature((unsigned char*)z, iAmt, zSig);\n  rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"WRITE\", iAmt, iOfst, zSig, rc);\n  if( rc==SQLITE_OK\n   && p->pLog\n   && p->pLog->zFilename\n   && iOfst<=24\n   && iOfst+iAmt>=28\n  ){\n    unsigned char *x = ((unsigned char*)z)+(24-iOfst);\n    unsigned iCtr, nFree = -1;\n    char *zFree = 0;\n    char zStr[12];\n    iCtr = bigToNative(x);\n    if( iOfst+iAmt>=40 ){\n      zFree = zStr;\n      sqlite3_snprintf(sizeof(zStr), zStr, \"%d\", bigToNative(x+8));\n      nFree = bigToNative(x+12);\n    }\n    vlogLogPrint(p->pLog, tStart, 0, \"CHNGCTR-WRITE\", iCtr, nFree, zFree, 0);\n  }\n  return rc;\n}\n\n/*\n** Truncate an vlog-file.\n*/\nstatic int vlogTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xTruncate(p->pReal, size);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"TRUNCATE\", size, -1, 0, rc);\n  return rc;\n}\n\n/*\n** Sync an vlog-file.\n*/\nstatic int vlogSync(sqlite3_file *pFile, int flags){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xSync(p->pReal, flags);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"SYNC\", flags, -1, 0, rc);\n  return rc;\n}\n\n/*\n** Return the current file-size of an vlog-file.\n*/\nstatic int vlogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"FILESIZE\", *pSize, -1, 0, rc);\n  return rc;\n}\n\n/*\n** Lock an vlog-file.\n*/\nstatic int vlogLock(sqlite3_file *pFile, int eLock){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"LOCK\", eLock, -1, 0, rc);\n  return rc;\n}\n\n/*\n** Unlock an vlog-file.\n*/\nstatic int vlogUnlock(sqlite3_file *pFile, int eLock){\n  int rc;\n  sqlite3_uint64 tStart;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  vlogLogPrint(p->pLog, tStart, 0, \"UNLOCK\", eLock, -1, 0, 0);\n  rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);\n  return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an vlog-file.\n*/\nstatic int vlogCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"CHECKRESERVEDLOCK\",\n                 *pResOut, -1, \"\", rc);\n  return rc;\n}\n\n/*\n** File control method. For custom operations on an vlog-file.\n*/\nstatic int vlogFileControl(sqlite3_file *pFile, int op, void *pArg){\n  VLogFile *p = (VLogFile *)pFile;\n  sqlite3_uint64 tStart, tElapse;\n  int rc;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n  if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n    *(char**)pArg = sqlite3_mprintf(\"vlog/%z\", *(char**)pArg);\n  }\n  tElapse = vlog_time() - tStart;\n  if( op==SQLITE_FCNTL_TRACE ){\n    vlogLogPrint(p->pLog, tStart, tElapse, \"TRACE\", op, -1, pArg, rc);\n  }else if( op==SQLITE_FCNTL_PRAGMA ){\n    const char **azArg = (const char **)pArg;\n    vlogLogPrint(p->pLog, tStart, tElapse, \"FILECONTROL\", op, -1, azArg[1], rc);\n  }else if( op==SQLITE_FCNTL_SIZE_HINT ){\n    sqlite3_int64 sz = *(sqlite3_int64*)pArg;\n    vlogLogPrint(p->pLog, tStart, tElapse, \"FILECONTROL\", op, sz, 0, rc);\n  }else{\n    vlogLogPrint(p->pLog, tStart, tElapse, \"FILECONTROL\", op, -1, 0, rc);\n  }\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an vlog-file.\n*/\nstatic int vlogSectorSize(sqlite3_file *pFile){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xSectorSize(p->pReal);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"SECTORSIZE\", -1, -1, 0, rc);\n  return rc;\n}\n\n/*\n** Return the device characteristic flags supported by an vlog-file.\n*/\nstatic int vlogDeviceCharacteristics(sqlite3_file *pFile){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogFile *p = (VLogFile *)pFile;\n  tStart = vlog_time();\n  rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n  tElapse = vlog_time() - tStart;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"DEVCHAR\", -1, -1, 0, rc);\n  return rc;\n}\n\n\n/*\n** Open an vlog file handle.\n*/\nstatic int vlogOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  sqlite3_int64 iArg2;\n  VLogFile *p = (VLogFile*)pFile;\n\n  p->pReal = (sqlite3_file*)&p[1];\n  if( (flags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_MAIN_JOURNAL))!=0 ){\n    p->pLog = vlogLogOpen(zName);\n  }else{\n    p->pLog = 0;\n  }\n  tStart = vlog_time();\n  rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags);\n  tElapse = vlog_time() - tStart;\n  iArg2 = pOutFlags ? *pOutFlags : -1;\n  vlogLogPrint(p->pLog, tStart, tElapse, \"OPEN\", flags, iArg2, 0, rc);\n  if( rc==SQLITE_OK ){\n    pFile->pMethods = &vlog_io_methods;\n  }else{\n    if( p->pLog ) vlogLogClose(p->pLog);\n    p->pLog = 0;\n  }\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int vlogDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogLog *pLog;\n  tStart = vlog_time();\n  rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync);\n  tElapse = vlog_time() - tStart;\n  pLog = vlogLogOpen(zPath);\n  vlogLogPrint(pLog, tStart, tElapse, \"DELETE\", dirSync, -1, 0, rc);\n  vlogLogClose(pLog);\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int vlogAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  int rc;\n  sqlite3_uint64 tStart, tElapse;\n  VLogLog *pLog;\n  tStart = vlog_time();\n  rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut);\n  tElapse = vlog_time() - tStart;\n  pLog = vlogLogOpen(zPath);\n  vlogLogPrint(pLog, tStart, tElapse, \"ACCESS\", flags, *pResOut, 0, rc);\n  vlogLogClose(pLog);\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int vlogFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *vlogDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void vlogDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void vlogDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int vlogRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int vlogSleep(sqlite3_vfs *pVfs, int nMicro){\n  return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int vlogCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut);\n}\n\nstatic int vlogGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b);\n}\nstatic int vlogCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){\n  return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p);\n}\n\n/*\n** Register debugvfs as the default VFS for this process.\n*/\nint sqlite3_register_vfslog(const char *zArg){\n  vlog_vfs.pVfs = sqlite3_vfs_find(0);\n  vlog_vfs.base.szOsFile = sizeof(VLogFile) + vlog_vfs.pVfs->szOsFile;\n  return sqlite3_vfs_register(&vlog_vfs.base, 1);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/vfsstat.c",
    "content": "/*\n** 2016-05-27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of an SQLite vfs shim that\n** tracks I/O.  Access to the accumulated status counts is provided using\n** an eponymous virtual table.\n*/\n#include <sqlite3ext.h>\nSQLITE_EXTENSION_INIT1\n\n/*\n** This module contains code for a wrapper VFS that cause stats for\n** most VFS calls to be recorded.\n**\n** To use this module, first compile it as a loadable extension.  See\n** https://www.sqlite.org/loadext.html#build for compilations instructions.\n**\n** After compliing, load this extension, then open database connections to be\n** measured.  Query usages status using the vfsstat virtual table:\n**\n**         SELECT * FROM vfsstat;\n**\n** Reset counters using UPDATE statements against vfsstat:\n**\n**         UPDATE vfsstat SET count=0;\n**\n** EXAMPLE SCRIPT:\n**\n**      .load ./vfsstat\n**      .open test.db\n**      DROP TABLE IF EXISTS t1;\n**      CREATE TABLE t1(x,y);\n**      INSERT INTO t1 VALUES(123, randomblob(5000));\n**      CREATE INDEX t1x ON t1(x);\n**      DROP TABLE t1;\n**      VACUUM;\n**      SELECT * FROM vfsstat WHERE count>0;\n**\n** LIMITATIONS:\n** \n** This module increments counters without using mutex protection.  So if\n** two or more threads try to use this module at the same time, race conditions\n** may occur which mess up the counts.  This is harmless, other than giving\n** incorrect statistics.\n*/\n#include <string.h>\n#include <stdlib.h>\n#include <assert.h>\n\n/*\n** File types\n*/\n#define VFSSTAT_MAIN         0   /* Main database file */\n#define VFSSTAT_JOURNAL      1   /* Rollback journal */\n#define VFSSTAT_WAL          2   /* Write-ahead log file */\n#define VFSSTAT_MASTERJRNL   3   /* Master journal */\n#define VFSSTAT_SUBJRNL      4   /* Subjournal */\n#define VFSSTAT_TEMPDB       5   /* TEMP database */\n#define VFSSTAT_TEMPJRNL     6   /* Journal for TEMP database */\n#define VFSSTAT_TRANSIENT    7   /* Transient database */\n#define VFSSTAT_ANY          8   /* Unspecified file type */\n#define VFSSTAT_nFile        9   /* This many file types */\n\n/* Names of the file types.  These are allowed values for the\n** first column of the vfsstat virtual table.\n*/\nstatic const char *azFile[] = {\n  \"database\", \"journal\", \"wal\", \"master-journal\", \"sub-journal\",\n  \"temp-database\", \"temp-journal\", \"transient-db\", \"*\"\n};\n\n/*\n** Stat types\n*/\n#define VFSSTAT_BYTESIN      0   /* Bytes read in */\n#define VFSSTAT_BYTESOUT     1   /* Bytes written out */   \n#define VFSSTAT_READ         2   /* Read requests */\n#define VFSSTAT_WRITE        3   /* Write requests */\n#define VFSSTAT_SYNC         4   /* Syncs */\n#define VFSSTAT_OPEN         5   /* File opens */\n#define VFSSTAT_LOCK         6   /* Lock requests */\n#define VFSSTAT_ACCESS       0   /* xAccess calls.  filetype==ANY only */\n#define VFSSTAT_DELETE       1   /* xDelete calls.  filetype==ANY only */\n#define VFSSTAT_FULLPATH     2   /* xFullPathname calls.  ANY only */\n#define VFSSTAT_RANDOM       3   /* xRandomness calls.    ANY only */\n#define VFSSTAT_SLEEP        4   /* xSleep calls.         ANY only */\n#define VFSSTAT_CURTIME      5   /* xCurrentTime calls.   ANY only */\n#define VFSSTAT_nStat        7   /* This many stat types */\n\n\n/* Names for the second column of the vfsstat virtual table for all\n** cases except when the first column is \"*\" or VFSSTAT_ANY. */\nstatic const char *azStat[] = {\n  \"bytes-in\", \"bytes-out\", \"read\", \"write\", \"sync\", \"open\", \"lock\",\n};\nstatic const char *azStatAny[] = {\n  \"access\", \"delete\", \"fullpathname\", \"randomness\", \"sleep\", \"currenttimestamp\",\n  \"not-used\"\n};\n\n/* Total number of counters */\n#define VFSSTAT_MXCNT  (VFSSTAT_nStat*VFSSTAT_nFile)\n\n/*\n** Performance stats are collected in an instance of the following\n** global array.\n*/\nstatic sqlite3_uint64 aVfsCnt[VFSSTAT_MXCNT];\n\n/*\n** Access to a specific counter\n*/\n#define STATCNT(filetype,stat) (aVfsCnt[(filetype)*VFSSTAT_nStat+(stat)])\n\n/*\n** Forward declaration of objects used by this utility\n*/\ntypedef struct VStatVfs VStatVfs;\ntypedef struct VStatFile VStatFile;\n\n/* An instance of the VFS */\nstruct VStatVfs {\n  sqlite3_vfs base;               /* VFS methods */\n  sqlite3_vfs *pVfs;              /* Parent VFS */\n};\n\n/* An open file */\nstruct VStatFile {\n  sqlite3_file base;              /* IO methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  unsigned char eFiletype;        /* What type of file is this */\n};\n\n#define REALVFS(p) (((VStatVfs*)(p))->pVfs)\n\n/*\n** Methods for VStatFile\n*/\nstatic int vstatClose(sqlite3_file*);\nstatic int vstatRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int vstatWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int vstatTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int vstatSync(sqlite3_file*, int flags);\nstatic int vstatFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int vstatLock(sqlite3_file*, int);\nstatic int vstatUnlock(sqlite3_file*, int);\nstatic int vstatCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int vstatFileControl(sqlite3_file*, int op, void *pArg);\nstatic int vstatSectorSize(sqlite3_file*);\nstatic int vstatDeviceCharacteristics(sqlite3_file*);\nstatic int vstatShmMap(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\nstatic int vstatShmLock(sqlite3_file*, int offset, int n, int flags);\nstatic void vstatShmBarrier(sqlite3_file*);\nstatic int vstatShmUnmap(sqlite3_file*, int deleteFlag);\nstatic int vstatFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\nstatic int vstatUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n\n/*\n** Methods for VStatVfs\n*/\nstatic int vstatOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int vstatDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int vstatAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int vstatFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *vstatDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void vstatDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void);\nstatic void vstatDlClose(sqlite3_vfs*, void*);\nstatic int vstatRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int vstatSleep(sqlite3_vfs*, int microseconds);\nstatic int vstatCurrentTime(sqlite3_vfs*, double*);\nstatic int vstatGetLastError(sqlite3_vfs*, int, char *);\nstatic int vstatCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\n\nstatic VStatVfs vstat_vfs = {\n  {\n    2,                            /* iVersion */\n    0,                            /* szOsFile (set by register_vstat()) */\n    1024,                         /* mxPathname */\n    0,                            /* pNext */\n    \"vfslog\",                     /* zName */\n    0,                            /* pAppData */\n    vstatOpen,                     /* xOpen */\n    vstatDelete,                   /* xDelete */\n    vstatAccess,                   /* xAccess */\n    vstatFullPathname,             /* xFullPathname */\n    vstatDlOpen,                   /* xDlOpen */\n    vstatDlError,                  /* xDlError */\n    vstatDlSym,                    /* xDlSym */\n    vstatDlClose,                  /* xDlClose */\n    vstatRandomness,               /* xRandomness */\n    vstatSleep,                    /* xSleep */\n    vstatCurrentTime,              /* xCurrentTime */\n    vstatGetLastError,             /* xGetLastError */\n    vstatCurrentTimeInt64          /* xCurrentTimeInt64 */\n  },\n  0\n};\n\nstatic const sqlite3_io_methods vstat_io_methods = {\n  3,                              /* iVersion */\n  vstatClose,                      /* xClose */\n  vstatRead,                       /* xRead */\n  vstatWrite,                      /* xWrite */\n  vstatTruncate,                   /* xTruncate */\n  vstatSync,                       /* xSync */\n  vstatFileSize,                   /* xFileSize */\n  vstatLock,                       /* xLock */\n  vstatUnlock,                     /* xUnlock */\n  vstatCheckReservedLock,          /* xCheckReservedLock */\n  vstatFileControl,                /* xFileControl */\n  vstatSectorSize,                 /* xSectorSize */\n  vstatDeviceCharacteristics,      /* xDeviceCharacteristics */\n  vstatShmMap,                     /* xShmMap */\n  vstatShmLock,                    /* xShmLock */\n  vstatShmBarrier,                 /* xShmBarrier */\n  vstatShmUnmap,                   /* xShmUnmap */\n  vstatFetch,                      /* xFetch */\n  vstatUnfetch                     /* xUnfetch */\n};\n\n\n\n/*\n** Close an vstat-file.\n*/\nstatic int vstatClose(sqlite3_file *pFile){\n  VStatFile *p = (VStatFile *)pFile;\n  int rc = SQLITE_OK;\n\n  if( p->pReal->pMethods ){\n    rc = p->pReal->pMethods->xClose(p->pReal);\n  }\n  return rc;\n}\n\n\n/*\n** Read data from an vstat-file.\n*/\nstatic int vstatRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n\n  rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n  STATCNT(p->eFiletype,VFSSTAT_READ)++;\n  if( rc==SQLITE_OK ){\n    STATCNT(p->eFiletype,VFSSTAT_BYTESIN) += iAmt;\n  }\n  return rc;\n}\n\n/*\n** Write data to an vstat-file.\n*/\nstatic int vstatWrite(\n  sqlite3_file *pFile,\n  const void *z,\n  int iAmt,\n  sqlite_int64 iOfst\n){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n\n  rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);\n  STATCNT(p->eFiletype,VFSSTAT_WRITE)++;\n  if( rc==SQLITE_OK ){\n    STATCNT(p->eFiletype,VFSSTAT_BYTESOUT) += iAmt;\n  }\n  return rc;\n}\n\n/*\n** Truncate an vstat-file.\n*/\nstatic int vstatTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xTruncate(p->pReal, size);\n  return rc;\n}\n\n/*\n** Sync an vstat-file.\n*/\nstatic int vstatSync(sqlite3_file *pFile, int flags){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xSync(p->pReal, flags);\n  STATCNT(p->eFiletype,VFSSTAT_SYNC)++;\n  return rc;\n}\n\n/*\n** Return the current file-size of an vstat-file.\n*/\nstatic int vstatFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n  return rc;\n}\n\n/*\n** Lock an vstat-file.\n*/\nstatic int vstatLock(sqlite3_file *pFile, int eLock){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  STATCNT(p->eFiletype,VFSSTAT_LOCK)++;\n  return rc;\n}\n\n/*\n** Unlock an vstat-file.\n*/\nstatic int vstatUnlock(sqlite3_file *pFile, int eLock){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);\n  STATCNT(p->eFiletype,VFSSTAT_LOCK)++;\n  return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an vstat-file.\n*/\nstatic int vstatCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n  STATCNT(p->eFiletype,VFSSTAT_LOCK)++;\n  return rc;\n}\n\n/*\n** File control method. For custom operations on an vstat-file.\n*/\nstatic int vstatFileControl(sqlite3_file *pFile, int op, void *pArg){\n  VStatFile *p = (VStatFile *)pFile;\n  int rc;\n  rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n  if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n    *(char**)pArg = sqlite3_mprintf(\"vstat/%z\", *(char**)pArg);\n  }\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an vstat-file.\n*/\nstatic int vstatSectorSize(sqlite3_file *pFile){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xSectorSize(p->pReal);\n  return rc;\n}\n\n/*\n** Return the device characteristic flags supported by an vstat-file.\n*/\nstatic int vstatDeviceCharacteristics(sqlite3_file *pFile){\n  int rc;\n  VStatFile *p = (VStatFile *)pFile;\n  rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n  return rc;\n}\n\n/* Create a shared memory file mapping */\nstatic int vstatShmMap(\n  sqlite3_file *pFile,\n  int iPg,\n  int pgsz,\n  int bExtend,\n  void volatile **pp\n){\n  VStatFile *p = (VStatFile *)pFile;\n  return p->pReal->pMethods->xShmMap(p->pReal, iPg, pgsz, bExtend, pp);\n}\n\n/* Perform locking on a shared-memory segment */\nstatic int vstatShmLock(sqlite3_file *pFile, int offset, int n, int flags){\n  VStatFile *p = (VStatFile *)pFile;\n  return p->pReal->pMethods->xShmLock(p->pReal, offset, n, flags);\n}\n\n/* Memory barrier operation on shared memory */\nstatic void vstatShmBarrier(sqlite3_file *pFile){\n  VStatFile *p = (VStatFile *)pFile;\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n}\n\n/* Unmap a shared memory segment */\nstatic int vstatShmUnmap(sqlite3_file *pFile, int deleteFlag){\n  VStatFile *p = (VStatFile *)pFile;\n  return p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag);\n}\n\n/* Fetch a page of a memory-mapped file */\nstatic int vstatFetch(\n  sqlite3_file *pFile,\n  sqlite3_int64 iOfst,\n  int iAmt,\n  void **pp\n){\n  VStatFile *p = (VStatFile *)pFile;\n  return p->pReal->pMethods->xFetch(p->pReal, iOfst, iAmt, pp);\n}\n\n/* Release a memory-mapped page */\nstatic int vstatUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *pPage){\n  VStatFile *p = (VStatFile *)pFile;\n  return p->pReal->pMethods->xUnfetch(p->pReal, iOfst, pPage);\n}\n\n/*\n** Open an vstat file handle.\n*/\nstatic int vstatOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  VStatFile *p = (VStatFile*)pFile;\n\n  p->pReal = (sqlite3_file*)&p[1];\n  rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags);\n  if( flags & SQLITE_OPEN_MAIN_DB ){\n    p->eFiletype = VFSSTAT_MAIN;\n  }else if( flags & SQLITE_OPEN_MAIN_JOURNAL ){\n    p->eFiletype = VFSSTAT_JOURNAL;\n  }else if( flags & SQLITE_OPEN_WAL ){\n    p->eFiletype = VFSSTAT_WAL;\n  }else if( flags & SQLITE_OPEN_MASTER_JOURNAL ){\n    p->eFiletype = VFSSTAT_MASTERJRNL;\n  }else if( flags & SQLITE_OPEN_SUBJOURNAL ){\n    p->eFiletype = VFSSTAT_SUBJRNL;\n  }else if( flags & SQLITE_OPEN_TEMP_DB ){\n    p->eFiletype = VFSSTAT_TEMPDB;\n  }else if( flags & SQLITE_OPEN_TEMP_JOURNAL ){\n    p->eFiletype = VFSSTAT_TEMPJRNL;\n  }else{\n    p->eFiletype = VFSSTAT_TRANSIENT;\n  }\n  STATCNT(p->eFiletype,VFSSTAT_OPEN)++;\n  pFile->pMethods = rc ? 0 : &vstat_io_methods;\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int vstatDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc;\n  rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync);\n  STATCNT(VFSSTAT_ANY,VFSSTAT_DELETE)++;\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int vstatAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  int rc;\n  rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut);\n  STATCNT(VFSSTAT_ANY,VFSSTAT_ACCESS)++;\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int vstatFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  STATCNT(VFSSTAT_ANY,VFSSTAT_FULLPATH)++;\n  return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *vstatDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void vstatDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*vstatDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void vstatDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int vstatRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  STATCNT(VFSSTAT_ANY,VFSSTAT_RANDOM)++;\n  return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int vstatSleep(sqlite3_vfs *pVfs, int nMicro){\n  STATCNT(VFSSTAT_ANY,VFSSTAT_SLEEP)++;\n  return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int vstatCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++;\n  return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut);\n}\n\nstatic int vstatGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b);\n}\nstatic int vstatCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){\n  STATCNT(VFSSTAT_ANY,VFSSTAT_CURTIME)++;\n  return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p);\n}\n\n/*\n** A virtual table for accessing the stats collected by this VFS shim\n*/\nstatic int vstattabConnect(sqlite3*, void*, int, const char*const*, \n                           sqlite3_vtab**,char**);\nstatic int vstattabBestIndex(sqlite3_vtab*,sqlite3_index_info*);\nstatic int vstattabDisconnect(sqlite3_vtab*);\nstatic int vstattabOpen(sqlite3_vtab*, sqlite3_vtab_cursor**);\nstatic int vstattabClose(sqlite3_vtab_cursor*);\nstatic int vstattabFilter(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                          int argc, sqlite3_value **argv);\nstatic int vstattabNext(sqlite3_vtab_cursor*);\nstatic int vstattabEof(sqlite3_vtab_cursor*);\nstatic int vstattabColumn(sqlite3_vtab_cursor*,sqlite3_context*,int);\nstatic int vstattabRowid(sqlite3_vtab_cursor*,sqlite3_int64*);\nstatic int vstattabUpdate(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);\n\n/* A cursor for the vfsstat virtual table */\ntypedef struct VfsStatCursor {\n  sqlite3_vtab_cursor base;       /* Base class.  Must be first */\n  int i;                          /* Pointing to this aVfsCnt[] value */\n} VfsStatCursor;\n\n\nstatic int vstattabConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define VSTAT_COLUMN_FILE  0 \n#define VSTAT_COLUMN_STAT  1\n#define VSTAT_COLUMN_COUNT 2\n\n  rc = sqlite3_declare_vtab(db,\"CREATE TABLE x(file,stat,count)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for vstat table object.\n*/\nstatic int vstattabDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new vstat table cursor object.\n*/\nstatic int vstattabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  VfsStatCursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n\n/*\n** Destructor for a VfsStatCursor.\n*/\nstatic int vstattabClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a VfsStatCursor to its next row of output.\n*/\nstatic int vstattabNext(sqlite3_vtab_cursor *cur){\n  ((VfsStatCursor*)cur)->i++;\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the VfsStatCursor\n** is currently pointing.\n*/\nstatic int vstattabColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  VfsStatCursor *pCur = (VfsStatCursor*)cur;\n  switch( i ){\n    case VSTAT_COLUMN_FILE: {\n      sqlite3_result_text(ctx, azFile[pCur->i/VFSSTAT_nStat], -1, SQLITE_STATIC);\n      break;\n    }\n    case VSTAT_COLUMN_STAT: {\n      const char **az;\n      az = (pCur->i/VFSSTAT_nStat)==VFSSTAT_ANY ? azStatAny : azStat;\n      sqlite3_result_text(ctx, az[pCur->i%VFSSTAT_nStat], -1, SQLITE_STATIC);\n      break;\n    }\n    case VSTAT_COLUMN_COUNT: {\n      sqlite3_result_int64(ctx, aVfsCnt[pCur->i]);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.\n*/\nstatic int vstattabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  VfsStatCursor *pCur = (VfsStatCursor*)cur;\n  *pRowid = pCur->i;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int vstattabEof(sqlite3_vtab_cursor *cur){\n  VfsStatCursor *pCur = (VfsStatCursor*)cur;\n  return pCur->i >= VFSSTAT_MXCNT;\n}\n\n/*\n** Only a full table scan is supported.  So xFilter simply rewinds to\n** the beginning.\n*/\nstatic int vstattabFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  VfsStatCursor *pCur = (VfsStatCursor*)pVtabCursor;\n  pCur->i = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Only a forwards full table scan is supported.  xBestIndex is a no-op.\n*/\nstatic int vstattabBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  return SQLITE_OK;\n}\n\n/*\n** Any VSTAT_COLUMN_COUNT can be changed to a positive integer.\n** No deletions or insertions are allowed.  No changes to other\n** columns are allowed.\n*/\nstatic int vstattabUpdate(\n  sqlite3_vtab *tab,\n  int argc, sqlite3_value **argv,\n  sqlite3_int64 *pRowid\n){\n  sqlite3_int64 iRowid, x;\n  if( argc==1 ) return SQLITE_ERROR;\n  if( sqlite3_value_type(argv[0])!=SQLITE_INTEGER ) return SQLITE_ERROR;\n  iRowid = sqlite3_value_int64(argv[0]);\n  if( iRowid!=sqlite3_value_int64(argv[1]) ) return SQLITE_ERROR;\n  if( iRowid<0 || iRowid>=VFSSTAT_MXCNT ) return SQLITE_ERROR;\n  if( sqlite3_value_type(argv[VSTAT_COLUMN_COUNT+2])!=SQLITE_INTEGER ){\n    return SQLITE_ERROR;\n  }\n  x = sqlite3_value_int64(argv[VSTAT_COLUMN_COUNT+2]);\n  if( x<0 ) return SQLITE_ERROR;\n  aVfsCnt[iRowid] = x;\n  return SQLITE_OK;\n}\n\nstatic sqlite3_module VfsStatModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  vstattabConnect,           /* xConnect */\n  vstattabBestIndex,         /* xBestIndex */\n  vstattabDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  vstattabOpen,              /* xOpen - open a cursor */\n  vstattabClose,             /* xClose - close a cursor */\n  vstattabFilter,            /* xFilter - configure scan constraints */\n  vstattabNext,              /* xNext - advance a cursor */\n  vstattabEof,               /* xEof - check for end of scan */\n  vstattabColumn,            /* xColumn - read data */\n  vstattabRowid,             /* xRowid - read data */\n  vstattabUpdate,            /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n};\n\n/*\n** This routine is an sqlite3_auto_extension() callback, invoked to register\n** the vfsstat virtual table for all new database connections.\n*/\nstatic int vstatRegister(\n  sqlite3 *db,\n  const char **pzErrMsg,\n  const struct sqlite3_api_routines *pThunk\n){\n  return sqlite3_create_module(db, \"vfsstat\", &VfsStatModule, 0);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\n/* \n** This routine is called when the extension is loaded.\n**\n** Register the new VFS.  Make arrangement to register the virtual table\n** for each new database connection.\n*/\nint sqlite3_vfsstat_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  vstat_vfs.pVfs = sqlite3_vfs_find(0);\n  vstat_vfs.base.szOsFile = sizeof(VStatFile) + vstat_vfs.pVfs->szOsFile;\n  rc = sqlite3_vfs_register(&vstat_vfs.base, 1);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_auto_extension(vstatRegister);\n  }\n  if( rc==SQLITE_OK ) rc = SQLITE_OK_LOAD_PERMANENTLY;\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/vtablog.c",
    "content": "/*\n** 2017-08-10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a virtual table that prints diagnostic information\n** on stdout when its key interfaces are called.  This is intended for\n** interactive analysis and debugging of virtual table interfaces.\n**\n** Usage example:\n**\n**     .load ./vtablog\n**     CREATE VIRTUAL TABLE temp.log USING vtablog(\n**        schema='CREATE TABLE x(a,b,c)',\n**        rows=25\n**     );\n**     SELECT * FROM log;\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n#include <string.h>\n#include <ctype.h>\n\n\n/* vtablog_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a vtablog virtual table\n*/\ntypedef struct vtablog_vtab vtablog_vtab;\nstruct vtablog_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  int nRow;           /* Number of rows in the table */\n  int iInst;          /* Instance number for this vtablog table */\n  int nCursor;        /* Number of cursors created */\n};\n\n/* vtablog_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct vtablog_cursor vtablog_cursor;\nstruct vtablog_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  int iCursor;               /* Cursor number */\n  sqlite3_int64 iRowid;      /* The rowid */\n};\n\n/* Skip leading whitespace.  Return a pointer to the first non-whitespace\n** character, or to the zero terminator if the string has only whitespace */\nstatic const char *vtablog_skip_whitespace(const char *z){\n  while( isspace((unsigned char)z[0]) ) z++;\n  return z;\n}\n\n/* Remove trailing whitespace from the end of string z[] */\nstatic void vtablog_trim_whitespace(char *z){\n  size_t n = strlen(z);\n  while( n>0 && isspace((unsigned char)z[n]) ) n--;\n  z[n] = 0;\n}\n\n/* Dequote the string */\nstatic void vtablog_dequote(char *z){\n  int j;\n  char cQuote = z[0];\n  size_t i, n;\n\n  if( cQuote!='\\'' && cQuote!='\"' ) return;\n  n = strlen(z);\n  if( n<2 || z[n-1]!=z[0] ) return;\n  for(i=1, j=0; i<n-1; i++){\n    if( z[i]==cQuote && z[i+1]==cQuote ) i++;\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n}\n\n/* Check to see if the string is of the form:  \"TAG = VALUE\" with optional\n** whitespace before and around tokens.  If it is, return a pointer to the\n** first character of VALUE.  If it is not, return NULL.\n*/\nstatic const char *vtablog_parameter(const char *zTag, int nTag, const char *z){\n  z = vtablog_skip_whitespace(z);\n  if( strncmp(zTag, z, nTag)!=0 ) return 0;\n  z = vtablog_skip_whitespace(z+nTag);\n  if( z[0]!='=' ) return 0;\n  return vtablog_skip_whitespace(z+1);\n}\n\n/* Decode a parameter that requires a dequoted string.\n**\n** Return non-zero on an error.\n*/\nstatic int vtablog_string_parameter(\n  char **pzErr,            /* Leave the error message here, if there is one */\n  const char *zParam,      /* Parameter we are checking for */\n  const char *zArg,        /* Raw text of the virtual table argment */\n  char **pzVal             /* Write the dequoted string value here */\n){\n  const char *zValue;\n  zValue = vtablog_parameter(zParam,(int)strlen(zParam),zArg);\n  if( zValue==0 ) return 0;\n  if( *pzVal ){\n    *pzErr = sqlite3_mprintf(\"more than one '%s' parameter\", zParam);\n    return 1;\n  }\n  *pzVal = sqlite3_mprintf(\"%s\", zValue);\n  if( *pzVal==0 ){\n    *pzErr = sqlite3_mprintf(\"out of memory\");\n    return 1;\n  }\n  vtablog_trim_whitespace(*pzVal);\n  vtablog_dequote(*pzVal);\n  return 0;\n}\n\n#if 0 /* not used - yet */\n/* Return 0 if the argument is false and 1 if it is true.  Return -1 if\n** we cannot really tell.\n*/\nstatic int vtablog_boolean(const char *z){\n  if( sqlite3_stricmp(\"yes\",z)==0\n   || sqlite3_stricmp(\"on\",z)==0\n   || sqlite3_stricmp(\"true\",z)==0\n   || (z[0]=='1' && z[1]==0)\n  ){\n    return 1;\n  }\n  if( sqlite3_stricmp(\"no\",z)==0\n   || sqlite3_stricmp(\"off\",z)==0\n   || sqlite3_stricmp(\"false\",z)==0\n   || (z[0]=='0' && z[1]==0)\n  ){\n    return 0;\n  }\n  return -1;\n}\n#endif\n\n/*\n** The vtablogConnect() method is invoked to create a new\n** vtablog_vtab that describes the vtablog virtual table.\n**\n** Think of this routine as the constructor for vtablog_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the vtablog_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against vtablog will look like.\n*/\nstatic int vtablogConnectCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr,\n  int isCreate\n){\n  static int nInst = 0;\n  vtablog_vtab *pNew;\n  int i;\n  int rc;\n  int iInst = ++nInst;\n  char *zSchema = 0;\n  char *zNRow = 0;\n\n  printf(\"vtablog%s(tab=%d):\\n\", isCreate ? \"Create\" : \"Connect\", iInst);\n  printf(\"  argc=%d\\n\", argc);\n  for(i=0; i<argc; i++){\n    printf(\"  argv[%d] = \", i);\n    if( argv[i] ){\n      printf(\"[%s]\\n\", argv[i]);\n    }else{\n      printf(\"NULL\\n\");\n    }\n  }\n\n  for(i=3; i<argc; i++){\n    const char *z = argv[i];\n    if( vtablog_string_parameter(pzErr, \"schema\", z, &zSchema) ){\n      return SQLITE_ERROR;\n    }\n    if( vtablog_string_parameter(pzErr, \"rows\", z, &zNRow) ){\n      return SQLITE_ERROR;\n    }\n  }\n\n  if( zSchema==0 ){\n    *pzErr = sqlite3_mprintf(\"no schema defined\");\n    return SQLITE_ERROR;\n  }\n  rc = sqlite3_declare_vtab(db, zSchema);\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->nRow = 10;\n    if( zNRow ) pNew->nRow = atoi(zNRow);\n    pNew->iInst = iInst;\n  }\n  return rc;\n}\nstatic int vtablogCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return vtablogConnectCreate(db,pAux,argc,argv,ppVtab,pzErr,1);\n}\nstatic int vtablogConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return vtablogConnectCreate(db,pAux,argc,argv,ppVtab,pzErr,0);\n}\n\n\n/*\n** This method is the destructor for vtablog_cursor objects.\n*/\nstatic int vtablogDisconnect(sqlite3_vtab *pVtab){\n  vtablog_vtab *pTab = (vtablog_vtab*)pVtab;\n  printf(\"vtablogDisconnect(%d)\\n\", pTab->iInst);\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** This method is the destructor for vtablog_cursor objects.\n*/\nstatic int vtablogDestroy(sqlite3_vtab *pVtab){\n  vtablog_vtab *pTab = (vtablog_vtab*)pVtab;\n  printf(\"vtablogDestroy(%d)\\n\", pTab->iInst);\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new vtablog_cursor object.\n*/\nstatic int vtablogOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  vtablog_vtab *pTab = (vtablog_vtab*)p;\n  vtablog_cursor *pCur;\n  printf(\"vtablogOpen(tab=%d, cursor=%d)\\n\", pTab->iInst, ++pTab->nCursor);\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->iCursor = pTab->nCursor;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a vtablog_cursor.\n*/\nstatic int vtablogClose(sqlite3_vtab_cursor *cur){\n  vtablog_cursor *pCur = (vtablog_cursor*)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  printf(\"vtablogClose(tab=%d, cursor=%d)\\n\", pTab->iInst, pCur->iCursor);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a vtablog_cursor to its next row of output.\n*/\nstatic int vtablogNext(sqlite3_vtab_cursor *cur){\n  vtablog_cursor *pCur = (vtablog_cursor*)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  printf(\"vtablogNext(tab=%d, cursor=%d)  rowid %d -> %d\\n\", \n         pTab->iInst, pCur->iCursor, (int)pCur->iRowid, (int)pCur->iRowid+1);\n  pCur->iRowid++;\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the vtablog_cursor\n** is currently pointing.\n*/\nstatic int vtablogColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  vtablog_cursor *pCur = (vtablog_cursor*)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  char zVal[50];\n\n  if( i<26 ){\n    sqlite3_snprintf(sizeof(zVal),zVal,\"%c%d\", \n                     \"abcdefghijklmnopqrstuvwyz\"[i], pCur->iRowid);\n  }else{\n    sqlite3_snprintf(sizeof(zVal),zVal,\"{%d}%d\", i, pCur->iRowid);\n  }\n  printf(\"vtablogColumn(tab=%d, cursor=%d, i=%d): [%s]\\n\",\n         pTab->iInst, pCur->iCursor, i, zVal);\n  sqlite3_result_text(ctx, zVal, -1, SQLITE_TRANSIENT);\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int vtablogRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  vtablog_cursor *pCur = (vtablog_cursor*)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  printf(\"vtablogRowid(tab=%d, cursor=%d): %d\\n\",\n         pTab->iInst, pCur->iCursor, (int)pCur->iRowid);\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int vtablogEof(sqlite3_vtab_cursor *cur){\n  vtablog_cursor *pCur = (vtablog_cursor*)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  int rc = pCur->iRowid >= pTab->nRow;\n  printf(\"vtablogEof(tab=%d, cursor=%d): %d\\n\",\n         pTab->iInst, pCur->iCursor, rc);\n  return rc;\n}\n\n/*\n** Output an sqlite3_value object's value as an SQL literal.\n*/\nstatic void vtablogQuote(sqlite3_value *p){\n  char z[50];\n  switch( sqlite3_value_type(p) ){\n    case SQLITE_NULL: {\n      printf(\"NULL\");\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_snprintf(50,z,\"%lld\", sqlite3_value_int64(p));\n      printf(\"%s\", z);\n      break;\n    }\n    case SQLITE_FLOAT: {\n      sqlite3_snprintf(50,z,\"%!.20g\", sqlite3_value_double(p));\n      printf(\"%s\", z);\n      break;\n    }\n    case SQLITE_BLOB: {\n      int n = sqlite3_value_bytes(p);\n      const unsigned char *z = (const unsigned char*)sqlite3_value_blob(p);\n      int i;\n      printf(\"x'\");\n      for(i=0; i<n; i++) printf(\"%02x\", z[i]);\n      printf(\"'\");\n      break;\n    }\n    case SQLITE_TEXT: {\n      const char *z = (const char*)sqlite3_value_text(p);\n      int i;\n      char c;\n      for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n      if( c==0 ){\n        printf(\"'%s'\",z);\n      }else{\n        printf(\"'\");\n        while( *z ){\n          for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n          if( c=='\\'' ) i++;\n          if( i ){\n            printf(\"%.*s\", i, z);\n            z += i;\n          }\n          if( c=='\\'' ){\n            printf(\"'\");\n            continue;\n          }\n          if( c==0 ){\n            break;\n          }\n          z++;\n        }\n        printf(\"'\");\n      }\n      break;\n    }\n  }\n}\n\n\n/*\n** This method is called to \"rewind\" the vtablog_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to vtablogColumn() or vtablogRowid() or \n** vtablogEof().\n*/\nstatic int vtablogFilter(\n  sqlite3_vtab_cursor *cur,\n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  vtablog_cursor *pCur = (vtablog_cursor *)cur;\n  vtablog_vtab *pTab = (vtablog_vtab*)cur->pVtab;\n  printf(\"vtablogFilter(tab=%d, cursor=%d):\\n\", pTab->iInst, pCur->iCursor);\n  pCur->iRowid = 0;\n  return SQLITE_OK;\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the vtablog virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n*/\nstatic int vtablogBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  vtablog_vtab *pTab = (vtablog_vtab*)tab;\n  printf(\"vtablogBestIndex(tab=%d):\\n\", pTab->iInst);\n  pIdxInfo->estimatedCost = (double)500;\n  pIdxInfo->estimatedRows = 500;\n  return SQLITE_OK;\n}\n\n/*\n** SQLite invokes this method to INSERT, UPDATE, or DELETE content from\n** the table. \n**\n** This implementation does not actually make any changes to the table\n** content.  It merely logs the fact that the method was invoked\n*/\nstatic int vtablogUpdate(\n  sqlite3_vtab *tab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  vtablog_vtab *pTab = (vtablog_vtab*)tab;\n  int i;\n  printf(\"vtablogUpdate(tab=%d):\\n\", pTab->iInst);\n  printf(\"  argc=%d\\n\", argc);\n  for(i=0; i<argc; i++){\n    printf(\"  argv[%d]=\", i);\n    vtablogQuote(argv[i]);\n    printf(\"\\n\");\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** vtablog virtual table.\n*/\nstatic sqlite3_module vtablogModule = {\n  0,                         /* iVersion */\n  vtablogCreate,             /* xCreate */\n  vtablogConnect,            /* xConnect */\n  vtablogBestIndex,          /* xBestIndex */\n  vtablogDisconnect,         /* xDisconnect */\n  vtablogDestroy,            /* xDestroy */\n  vtablogOpen,               /* xOpen - open a cursor */\n  vtablogClose,              /* xClose - close a cursor */\n  vtablogFilter,             /* xFilter - configure scan constraints */\n  vtablogNext,               /* xNext - advance a cursor */\n  vtablogEof,                /* xEof - check for end of scan */\n  vtablogColumn,             /* xColumn - read data */\n  vtablogRowid,              /* xRowid - read data */\n  vtablogUpdate,             /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n};\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_vtablog_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc;\n  SQLITE_EXTENSION_INIT2(pApi);\n  rc = sqlite3_create_module(db, \"vtablog\", &vtablogModule, 0);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/vtshim.c",
    "content": "/*\n** 2013-06-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** A shim that sits between the SQLite virtual table interface and\n** runtimes with garbage collector based memory management.\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* Forward references */\ntypedef struct vtshim_aux vtshim_aux;\ntypedef struct vtshim_vtab vtshim_vtab;\ntypedef struct vtshim_cursor vtshim_cursor;\n\n\n/* The vtshim_aux argument is the auxiliary parameter that is passed\n** into sqlite3_create_module_v2().\n*/\nstruct vtshim_aux {\n  void *pChildAux;              /* pAux for child virtual tables */\n  void (*xChildDestroy)(void*); /* Destructor for pChildAux */\n  sqlite3_module *pMod;         /* Methods for child virtual tables */\n  sqlite3 *db;                  /* The database to which we are attached */\n  char *zName;                  /* Name of the module */\n  int bDisposed;                /* True if disposed */\n  vtshim_vtab *pAllVtab;        /* List of all vtshim_vtab objects */\n  sqlite3_module sSelf;         /* Methods used by this shim */\n};\n\n/* A vtshim virtual table object */\nstruct vtshim_vtab {\n  sqlite3_vtab base;       /* Base class - must be first */\n  sqlite3_vtab *pChild;    /* Child virtual table */\n  vtshim_aux *pAux;        /* Pointer to vtshim_aux object */\n  vtshim_cursor *pAllCur;  /* List of all cursors */\n  vtshim_vtab **ppPrev;    /* Previous on list */\n  vtshim_vtab *pNext;      /* Next on list */\n};\n\n/* A vtshim cursor object */\nstruct vtshim_cursor {\n  sqlite3_vtab_cursor base;    /* Base class - must be first */\n  sqlite3_vtab_cursor *pChild; /* Cursor generated by the managed subclass */\n  vtshim_cursor **ppPrev;      /* Previous on list of all cursors */\n  vtshim_cursor *pNext;        /* Next on list of all cursors */\n};\n\n/* Macro used to copy the child vtable error message to outer vtable */\n#define VTSHIM_COPY_ERRMSG()                                             \\\n  do {                                                                   \\\n    sqlite3_free(pVtab->base.zErrMsg);                                   \\\n    pVtab->base.zErrMsg = sqlite3_mprintf(\"%s\", pVtab->pChild->zErrMsg); \\\n  } while (0)\n\n/* Methods for the vtshim module */\nstatic int vtshimCreate(\n  sqlite3 *db,\n  void *ppAux,\n  int argc,\n  const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  vtshim_aux *pAux = (vtshim_aux*)ppAux;\n  vtshim_vtab *pNew;\n  int rc;\n\n  assert( db==pAux->db );\n  if( pAux->bDisposed ){\n    if( pzErr ){\n      *pzErr = sqlite3_mprintf(\"virtual table was disposed: \\\"%s\\\"\",\n                               pAux->zName);\n    }\n    return SQLITE_ERROR;\n  }\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  *ppVtab = (sqlite3_vtab*)pNew;\n  if( pNew==0 ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(*pNew));\n  rc = pAux->pMod->xCreate(db, pAux->pChildAux, argc, argv,\n                           &pNew->pChild, pzErr);\n  if( rc ){\n    sqlite3_free(pNew);\n    *ppVtab = 0;\n    return rc;\n  }\n  pNew->pAux = pAux;\n  pNew->ppPrev = &pAux->pAllVtab;\n  pNew->pNext = pAux->pAllVtab;\n  if( pAux->pAllVtab ) pAux->pAllVtab->ppPrev = &pNew->pNext;\n  pAux->pAllVtab = pNew;\n  return rc;\n}\n\nstatic int vtshimConnect(\n  sqlite3 *db,\n  void *ppAux,\n  int argc,\n  const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  vtshim_aux *pAux = (vtshim_aux*)ppAux;\n  vtshim_vtab *pNew;\n  int rc;\n\n  assert( db==pAux->db );\n  if( pAux->bDisposed ){\n    if( pzErr ){\n      *pzErr = sqlite3_mprintf(\"virtual table was disposed: \\\"%s\\\"\",\n                               pAux->zName);\n    }\n    return SQLITE_ERROR;\n  }\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  *ppVtab = (sqlite3_vtab*)pNew;\n  if( pNew==0 ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(*pNew));\n  rc = pAux->pMod->xConnect(db, pAux->pChildAux, argc, argv,\n                            &pNew->pChild, pzErr);\n  if( rc ){\n    sqlite3_free(pNew);\n    *ppVtab = 0;\n    return rc;\n  }\n  pNew->pAux = pAux;\n  pNew->ppPrev = &pAux->pAllVtab;\n  pNew->pNext = pAux->pAllVtab;\n  if( pAux->pAllVtab ) pAux->pAllVtab->ppPrev = &pNew->pNext;\n  pAux->pAllVtab = pNew;\n  return rc;\n}\n\nstatic int vtshimBestIndex(\n  sqlite3_vtab *pBase,\n  sqlite3_index_info *pIdxInfo\n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xBestIndex(pVtab->pChild, pIdxInfo);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimDisconnect(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc = SQLITE_OK;\n  if( !pAux->bDisposed ){\n    rc = pAux->pMod->xDisconnect(pVtab->pChild);\n  }\n  if( pVtab->pNext ) pVtab->pNext->ppPrev = pVtab->ppPrev;\n  *pVtab->ppPrev = pVtab->pNext;\n  sqlite3_free(pVtab);\n  return rc;\n}\n\nstatic int vtshimDestroy(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc = SQLITE_OK;\n  if( !pAux->bDisposed ){\n    rc = pAux->pMod->xDestroy(pVtab->pChild);\n  }\n  if( pVtab->pNext ) pVtab->pNext->ppPrev = pVtab->ppPrev;\n  *pVtab->ppPrev = pVtab->pNext;\n  sqlite3_free(pVtab);\n  return rc;\n}\n\nstatic int vtshimOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  vtshim_cursor *pCur;\n  int rc;\n  *ppCursor = 0;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  rc = pAux->pMod->xOpen(pVtab->pChild, &pCur->pChild);\n  if( rc ){\n    sqlite3_free(pCur);\n    VTSHIM_COPY_ERRMSG();\n    return rc;\n  }\n  pCur->pChild->pVtab = pVtab->pChild;\n  *ppCursor = &pCur->base;\n  pCur->ppPrev = &pVtab->pAllCur;\n  if( pVtab->pAllCur ) pVtab->pAllCur->ppPrev = &pCur->pNext;\n  pCur->pNext = pVtab->pAllCur;\n  pVtab->pAllCur = pCur;\n  return SQLITE_OK;\n}\n\nstatic int vtshimClose(sqlite3_vtab_cursor *pX){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc = SQLITE_OK;\n  if( !pAux->bDisposed ){\n    rc = pAux->pMod->xClose(pCur->pChild);\n    if( rc!=SQLITE_OK ){\n      VTSHIM_COPY_ERRMSG();\n    }\n  }\n  if( pCur->pNext ) pCur->pNext->ppPrev = pCur->ppPrev;\n  *pCur->ppPrev = pCur->pNext;\n  sqlite3_free(pCur);\n  return rc;\n}\n\nstatic int vtshimFilter(\n  sqlite3_vtab_cursor *pX,\n  int idxNum,\n  const char *idxStr,\n  int argc,\n  sqlite3_value **argv\n){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xFilter(pCur->pChild, idxNum, idxStr, argc, argv);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimNext(sqlite3_vtab_cursor *pX){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xNext(pCur->pChild);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimEof(sqlite3_vtab_cursor *pX){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return 1;\n  rc = pAux->pMod->xEof(pCur->pChild);\n  VTSHIM_COPY_ERRMSG();\n  return rc;\n}\n\nstatic int vtshimColumn(sqlite3_vtab_cursor *pX, sqlite3_context *ctx, int i){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xColumn(pCur->pChild, ctx, i);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimRowid(sqlite3_vtab_cursor *pX, sqlite3_int64 *pRowid){\n  vtshim_cursor *pCur = (vtshim_cursor*)pX;\n  vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xRowid(pCur->pChild, pRowid);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimUpdate(\n  sqlite3_vtab *pBase,\n  int argc,\n  sqlite3_value **argv,\n  sqlite3_int64 *pRowid\n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xUpdate(pVtab->pChild, argc, argv, pRowid);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimBegin(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xBegin(pVtab->pChild);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimSync(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xSync(pVtab->pChild);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimCommit(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xCommit(pVtab->pChild);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimRollback(sqlite3_vtab *pBase){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xRollback(pVtab->pChild);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimFindFunction(\n  sqlite3_vtab *pBase,\n  int nArg,\n  const char *zName,\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n  void **ppArg\n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return 0;\n  rc = pAux->pMod->xFindFunction(pVtab->pChild, nArg, zName, pxFunc, ppArg);\n  VTSHIM_COPY_ERRMSG();\n  return rc;\n}\n\nstatic int vtshimRename(sqlite3_vtab *pBase, const char *zNewName){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xRename(pVtab->pChild, zNewName);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimSavepoint(sqlite3_vtab *pBase, int n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xSavepoint(pVtab->pChild, n);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimRelease(sqlite3_vtab *pBase, int n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xRelease(pVtab->pChild, n);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\nstatic int vtshimRollbackTo(sqlite3_vtab *pBase, int n){\n  vtshim_vtab *pVtab = (vtshim_vtab*)pBase;\n  vtshim_aux *pAux = pVtab->pAux;\n  int rc;\n  if( pAux->bDisposed ) return SQLITE_ERROR;\n  rc = pAux->pMod->xRollbackTo(pVtab->pChild, n);\n  if( rc!=SQLITE_OK ){\n    VTSHIM_COPY_ERRMSG();\n  }\n  return rc;\n}\n\n/* The destructor function for a disposible module */\nstatic void vtshimAuxDestructor(void *pXAux){\n  vtshim_aux *pAux = (vtshim_aux*)pXAux;\n  assert( pAux->pAllVtab==0 );\n  if( !pAux->bDisposed && pAux->xChildDestroy ){\n    pAux->xChildDestroy(pAux->pChildAux);\n    pAux->xChildDestroy = 0;\n  }\n  sqlite3_free(pAux->zName);\n  sqlite3_free(pAux->pMod);\n  sqlite3_free(pAux);\n}\n\nstatic int vtshimCopyModule(\n  const sqlite3_module *pMod,   /* Source module to be copied */\n  sqlite3_module **ppMod        /* Destination for copied module */\n){\n  sqlite3_module *p;\n  if( !pMod || !ppMod ) return SQLITE_ERROR;\n  p = sqlite3_malloc( sizeof(*p) );\n  if( p==0 ) return SQLITE_NOMEM;\n  memcpy(p, pMod, sizeof(*p));\n  *ppMod = p;\n  return SQLITE_OK;\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nvoid *sqlite3_create_disposable_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n){\n  vtshim_aux *pAux;\n  sqlite3_module *pMod;\n  int rc;\n  pAux = sqlite3_malloc( sizeof(*pAux) );\n  if( pAux==0 ){\n    if( xDestroy ) xDestroy(pClientData);\n    return 0;\n  }\n  rc = vtshimCopyModule(p, &pMod);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(pAux);\n    return 0;\n  }\n  pAux->pChildAux = pClientData;\n  pAux->xChildDestroy = xDestroy;\n  pAux->pMod = pMod;\n  pAux->db = db;\n  pAux->zName = sqlite3_mprintf(\"%s\", zName);\n  pAux->bDisposed = 0;\n  pAux->pAllVtab = 0;\n  pAux->sSelf.iVersion = p->iVersion<=2 ? p->iVersion : 2;\n  pAux->sSelf.xCreate = p->xCreate ? vtshimCreate : 0;\n  pAux->sSelf.xConnect = p->xConnect ? vtshimConnect : 0;\n  pAux->sSelf.xBestIndex = p->xBestIndex ? vtshimBestIndex : 0;\n  pAux->sSelf.xDisconnect = p->xDisconnect ? vtshimDisconnect : 0;\n  pAux->sSelf.xDestroy = p->xDestroy ? vtshimDestroy : 0;\n  pAux->sSelf.xOpen = p->xOpen ? vtshimOpen : 0;\n  pAux->sSelf.xClose = p->xClose ? vtshimClose : 0;\n  pAux->sSelf.xFilter = p->xFilter ? vtshimFilter : 0;\n  pAux->sSelf.xNext = p->xNext ? vtshimNext : 0;\n  pAux->sSelf.xEof = p->xEof ? vtshimEof : 0;\n  pAux->sSelf.xColumn = p->xColumn ? vtshimColumn : 0;\n  pAux->sSelf.xRowid = p->xRowid ? vtshimRowid : 0;\n  pAux->sSelf.xUpdate = p->xUpdate ? vtshimUpdate : 0;\n  pAux->sSelf.xBegin = p->xBegin ? vtshimBegin : 0;\n  pAux->sSelf.xSync = p->xSync ? vtshimSync : 0;\n  pAux->sSelf.xCommit = p->xCommit ? vtshimCommit : 0;\n  pAux->sSelf.xRollback = p->xRollback ? vtshimRollback : 0;\n  pAux->sSelf.xFindFunction = p->xFindFunction ? vtshimFindFunction : 0;\n  pAux->sSelf.xRename = p->xRename ? vtshimRename : 0;\n  if( p->iVersion>=2 ){\n    pAux->sSelf.xSavepoint = p->xSavepoint ? vtshimSavepoint : 0;\n    pAux->sSelf.xRelease = p->xRelease ? vtshimRelease : 0;\n    pAux->sSelf.xRollbackTo = p->xRollbackTo ? vtshimRollbackTo : 0;\n  }else{\n    pAux->sSelf.xSavepoint = 0;\n    pAux->sSelf.xRelease = 0;\n    pAux->sSelf.xRollbackTo = 0;\n  }\n  rc = sqlite3_create_module_v2(db, zName, &pAux->sSelf,\n                                pAux, vtshimAuxDestructor);\n  return rc==SQLITE_OK ? (void*)pAux : 0;\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nvoid sqlite3_dispose_module(void *pX){\n  vtshim_aux *pAux = (vtshim_aux*)pX;\n  if( !pAux->bDisposed ){\n    vtshim_vtab *pVtab;\n    vtshim_cursor *pCur;\n    for(pVtab=pAux->pAllVtab; pVtab; pVtab=pVtab->pNext){\n      for(pCur=pVtab->pAllCur; pCur; pCur=pCur->pNext){\n        pAux->pMod->xClose(pCur->pChild);\n      }\n      pAux->pMod->xDisconnect(pVtab->pChild);\n    }\n    pAux->bDisposed = 1;\n    if( pAux->xChildDestroy ){\n      pAux->xChildDestroy(pAux->pChildAux);\n      pAux->xChildDestroy = 0;\n    }\n  }\n}\n\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_vtshim_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/misc/wholenumber.c",
    "content": "/*\n** 2011 April 02\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a virtual table that returns the whole numbers\n** between 1 and 4294967295, inclusive.\n**\n** Example:\n**\n**     CREATE VIRTUAL TABLE nums USING wholenumber;\n**     SELECT value FROM nums WHERE value<10;\n**\n** Results in:\n**\n**     1 2 3 4 5 6 7 8 9\n*/\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n\n/* A wholenumber cursor object */\ntypedef struct wholenumber_cursor wholenumber_cursor;\nstruct wholenumber_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3_int64 iValue;      /* Current value */\n  sqlite3_int64 mxValue;     /* Maximum value */\n};\n\n/* Methods for the wholenumber module */\nstatic int wholenumberConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return SQLITE_NOMEM;\n  sqlite3_declare_vtab(db, \"CREATE TABLE x(value)\");\n  memset(pNew, 0, sizeof(*pNew));\n  return SQLITE_OK;\n}\n/* Note that for this virtual table, the xCreate and xConnect\n** methods are identical. */\n\nstatic int wholenumberDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n/* The xDisconnect and xDestroy methods are also the same */\n\n\n/*\n** Open a new wholenumber cursor.\n*/\nstatic int wholenumberOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  wholenumber_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a wholenumber cursor.\n*/\nstatic int wholenumberClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a cursor to its next row of output\n*/\nstatic int wholenumberNext(sqlite3_vtab_cursor *cur){\n  wholenumber_cursor *pCur = (wholenumber_cursor*)cur;\n  pCur->iValue++;\n  return SQLITE_OK;\n}\n\n/*\n** Return the value associated with a wholenumber.\n*/\nstatic int wholenumberColumn(\n  sqlite3_vtab_cursor *cur,\n  sqlite3_context *ctx,\n  int i\n){\n  wholenumber_cursor *pCur = (wholenumber_cursor*)cur;\n  sqlite3_result_int64(ctx, pCur->iValue);\n  return SQLITE_OK;\n}\n\n/*\n** The rowid.\n*/\nstatic int wholenumberRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  wholenumber_cursor *pCur = (wholenumber_cursor*)cur;\n  *pRowid = pCur->iValue;\n  return SQLITE_OK;\n}\n\n/*\n** When the wholenumber_cursor.rLimit value is 0 or less, that is a signal\n** that the cursor has nothing more to output.\n*/\nstatic int wholenumberEof(sqlite3_vtab_cursor *cur){\n  wholenumber_cursor *pCur = (wholenumber_cursor*)cur;\n  return pCur->iValue>pCur->mxValue || pCur->iValue==0;\n}\n\n/*\n** Called to \"rewind\" a cursor back to the beginning so that\n** it starts its output over again.  Always called at least once\n** prior to any wholenumberColumn, wholenumberRowid, or wholenumberEof call.\n**\n**    idxNum   Constraints\n**    ------   ---------------------\n**      0      (none)\n**      1      value > $argv0\n**      2      value >= $argv0\n**      4      value < $argv0\n**      8      value <= $argv0\n**\n**      5      value > $argv0 AND value < $argv1\n**      6      value >= $argv0 AND value < $argv1\n**      9      value > $argv0 AND value <= $argv1\n**     10      value >= $argv0 AND value <= $argv1\n*/\nstatic int wholenumberFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  wholenumber_cursor *pCur = (wholenumber_cursor *)pVtabCursor;\n  sqlite3_int64 v;\n  int i = 0;\n  pCur->iValue = 1;\n  pCur->mxValue = 0xffffffff;  /* 4294967295 */\n  if( idxNum & 3 ){\n    v = sqlite3_value_int64(argv[0]) + (idxNum&1);\n    if( v>pCur->iValue && v<=pCur->mxValue ) pCur->iValue = v;\n    i++;\n  }\n  if( idxNum & 12 ){\n    v = sqlite3_value_int64(argv[i]) - ((idxNum>>2)&1);\n    if( v>=pCur->iValue && v<pCur->mxValue ) pCur->mxValue = v;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Search for terms of these forms:\n**\n**  (1)  value > $value\n**  (2)  value >= $value\n**  (4)  value < $value\n**  (8)  value <= $value\n**\n** idxNum is an ORed combination of 1 or 2 with 4 or 8.\n*/\nstatic int wholenumberBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;\n  int idxNum = 0;\n  int argvIdx = 1;\n  int ltIdx = -1;\n  int gtIdx = -1;\n  const struct sqlite3_index_constraint *pConstraint;\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( (idxNum & 3)==0 && pConstraint->op==SQLITE_INDEX_CONSTRAINT_GT ){\n      idxNum |= 1;\n      ltIdx = i;\n    }\n    if( (idxNum & 3)==0 && pConstraint->op==SQLITE_INDEX_CONSTRAINT_GE ){\n      idxNum |= 2;\n      ltIdx = i;\n    }\n    if( (idxNum & 12)==0 && pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ){\n      idxNum |= 4;\n      gtIdx = i;\n    }\n    if( (idxNum & 12)==0 && pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE ){\n      idxNum |= 8;\n      gtIdx = i;\n    }\n  }\n  pIdxInfo->idxNum = idxNum;\n  if( ltIdx>=0 ){\n    pIdxInfo->aConstraintUsage[ltIdx].argvIndex = argvIdx++;\n    pIdxInfo->aConstraintUsage[ltIdx].omit = 1;\n  }\n  if( gtIdx>=0 ){\n    pIdxInfo->aConstraintUsage[gtIdx].argvIndex = argvIdx;\n    pIdxInfo->aConstraintUsage[gtIdx].omit = 1;\n  }\n  if( pIdxInfo->nOrderBy==1\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  if( (idxNum & 12)==0 ){\n    pIdxInfo->estimatedCost = (double)100000000;\n  }else if( (idxNum & 3)==0 ){\n    pIdxInfo->estimatedCost = (double)5;\n  }else{\n    pIdxInfo->estimatedCost = (double)1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that provides read-only access to a\n** Tcl global variable namespace.\n*/\nstatic sqlite3_module wholenumberModule = {\n  0,                         /* iVersion */\n  wholenumberConnect,\n  wholenumberConnect,\n  wholenumberBestIndex,\n  wholenumberDisconnect, \n  wholenumberDisconnect,\n  wholenumberOpen,           /* xOpen - open a cursor */\n  wholenumberClose,          /* xClose - close a cursor */\n  wholenumberFilter,         /* xFilter - configure scan constraints */\n  wholenumberNext,           /* xNext - advance a cursor */\n  wholenumberEof,            /* xEof - check for end of scan */\n  wholenumberColumn,         /* xColumn - read data */\n  wholenumberRowid,          /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_wholenumber_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"wholenumber\", &wholenumberModule, 0);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu.c",
    "content": "/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a command-line application that uses the RBU \n** extension. See the usage() function below for an explanation.\n*/\n\n#include \"sqlite3rbu.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** Print a usage message and exit.\n*/\nvoid usage(const char *zArgv0){\n  fprintf(stderr, \n\"Usage: %s ?OPTIONS? TARGET-DB RBU-DB\\n\"\n\"\\n\"\n\"Where options are:\\n\"\n\"\\n\"\n\"    -step NSTEP\\n\"\n\"    -vacuum\\n\"\n\"\\n\"\n\"  If the -vacuum switch is not present, argument RBU-DB must be an RBU\\n\"\n\"  database containing an update suitable for target database TARGET-DB.\\n\"\n\"  Or, if -vacuum is specified, then TARGET-DB is a database to vacuum using\\n\"\n\"  RBU, and RBU-DB is used as the state database for the vacuum (refer to\\n\"\n\"  API documentation for details).\\n\"\n\"\\n\"\n\"  If NSTEP is set to less than or equal to zero (the default value), this \\n\"\n\"  program attempts to perform the entire update or vacuum operation before\\n\"\n\"  exiting\\n\"\n\"\\n\"\n\"  If NSTEP is greater than zero, then a maximum of NSTEP calls are made\\n\"\n\"  to sqlite3rbu_step(). If the RBU update has not been completely applied\\n\"\n\"  after the NSTEP'th call is made, the state is saved in the database RBU-DB\\n\"\n\"  and the program exits. Subsequent invocations of this (or any other RBU)\\n\"\n\"  application will use this state to resume applying the RBU update to the\\n\"\n\"  target db.\\n\"\n\"\\n\"\n, zArgv0);\n  exit(1);\n}\n\nvoid report_default_vfs(){\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n  fprintf(stdout, \"default vfs is \\\"%s\\\"\\n\", pVfs->zName);\n}\n\nvoid report_rbu_vfs(sqlite3rbu *pRbu){\n  sqlite3 *db = sqlite3rbu_db(pRbu, 0);\n  if( db ){\n    char *zName = 0;\n    sqlite3_file_control(db, \"main\", SQLITE_FCNTL_VFSNAME, &zName);\n    if( zName ){\n      fprintf(stdout, \"using vfs \\\"%s\\\"\\n\", zName);\n    }else{\n      fprintf(stdout, \"vfs name not available\\n\");\n    }\n    sqlite3_free(zName);\n  }\n}\n\nint main(int argc, char **argv){\n  int i;\n  const char *zTarget;            /* Target database to apply RBU to */\n  const char *zRbu;               /* Database containing RBU */\n  char zBuf[200];                 /* Buffer for printf() */\n  char *zErrmsg;                  /* Error message, if any */\n  sqlite3rbu *pRbu;               /* RBU handle */\n  int nStep = 0;                  /* Maximum number of step() calls */\n  int bVacuum = 0;\n  int rc;\n  sqlite3_int64 nProgress = 0;\n  int nArgc = argc-2;\n\n  if( argc<3 ) usage(argv[0]);\n  for(i=1; i<nArgc; i++){\n    const char *zArg = argv[i];\n    int nArg = strlen(zArg);\n    if( nArg>1 && nArg<=8 && 0==memcmp(zArg, \"-vacuum\", nArg) ){\n      bVacuum = 1;\n    }else if( nArg>1 && nArg<=5 && 0==memcmp(zArg, \"-step\", nArg) && i<nArg-1 ){\n      i++;\n      nStep = atoi(argv[i]);\n    }else{\n      usage(argv[0]);\n    }\n  }\n\n  zTarget = argv[argc-2];\n  zRbu = argv[argc-1];\n\n  report_default_vfs();\n\n  /* Open an RBU handle. A vacuum handle if -vacuum was specified, or a\n  ** regular RBU update handle otherwise.  */\n  if( bVacuum ){\n    pRbu = sqlite3rbu_vacuum(zTarget, zRbu);\n  }else{\n    pRbu = sqlite3rbu_open(zTarget, zRbu, 0);\n  }\n  report_rbu_vfs(pRbu);\n\n  /* If nStep is less than or equal to zero, call\n  ** sqlite3rbu_step() until either the RBU has been completely applied\n  ** or an error occurs. Or, if nStep is greater than zero, call\n  ** sqlite3rbu_step() a maximum of nStep times.  */\n  for(i=0; (nStep<=0 || i<nStep) && sqlite3rbu_step(pRbu)==SQLITE_OK; i++);\n  nProgress = sqlite3rbu_progress(pRbu);\n  rc = sqlite3rbu_close(pRbu, &zErrmsg);\n\n  /* Let the user know what happened. */\n  switch( rc ){\n    case SQLITE_OK:\n      sqlite3_snprintf(sizeof(zBuf), zBuf,\n          \"SQLITE_OK: rbu update incomplete (%lld operations so far)\\n\",\n          nProgress\n      );\n      fprintf(stdout, \"%s\", zBuf);\n      break;\n\n    case SQLITE_DONE:\n      sqlite3_snprintf(sizeof(zBuf), zBuf,\n          \"SQLITE_DONE: rbu update completed (%lld operations)\\n\",\n          nProgress\n      );\n      fprintf(stdout, \"%s\", zBuf);\n      break;\n\n    default:\n      fprintf(stderr, \"error=%d: %s\\n\", rc, zErrmsg);\n      break;\n  }\n\n  sqlite3_free(zErrmsg);\n  return (rc==SQLITE_OK || rc==SQLITE_DONE) ? 0 : 1;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu1.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbu1\n\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\n# Create a simple RBU database. That expects to write to a table:\n#\n#   CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n#\nproc create_rbu1 {filename} {\n  forcedelete $filename\n  sqlite3 rbu1 $filename  \n  rbu1 eval {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n    INSERT INTO data_t1 VALUES(2, 'two', 'three', 0);\n    INSERT INTO data_t1 VALUES(3, NULL, 8.2, 0);\n  }\n  rbu1 close\n  return $filename\n}\n\n# Create a simple RBU database. That expects to write to a table:\n#\n#   CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n#\n# This RBU includes both insert and delete operations.\n#\nproc create_rbu4 {filename} {\n  forcedelete $filename\n  sqlite3 rbu1 $filename  \n  rbu1 eval {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n    INSERT INTO data_t1 VALUES(2, NULL, 5, 1);\n    INSERT INTO data_t1 VALUES(3, 8, 9, 0);\n    INSERT INTO data_t1 VALUES(4, NULL, 11, 1);\n  }\n  rbu1 close\n  return $filename\n}\n#\n# Create a simple RBU database. That expects to write to a table:\n#\n#   CREATE TABLE t1(c, b, '(a)' INTEGER PRIMARY KEY);\n#\n# This RBU includes both insert and delete operations.\n#\nproc create_rbu4b {filename} {\n  forcedelete $filename\n  sqlite3 rbu1 $filename  \n  rbu1 eval {\n    CREATE TABLE data_t1(c, b, '(a)', rbu_control);\n    INSERT INTO data_t1 VALUES(3, 2, 1, 0);\n    INSERT INTO data_t1 VALUES(5, NULL, 2, 1);\n    INSERT INTO data_t1 VALUES(9, 8, 3, 0);\n    INSERT INTO data_t1 VALUES(11, NULL, 4, 1);\n  }\n  rbu1 close\n  return $filename\n}\n\n# Create a simple RBU database. That expects to write to a table:\n#\n#   CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n#\n# This RBU includes update statements.\n#\nproc create_rbu5 {filename} {\n  forcedelete $filename\n  sqlite3 rbu5 $filename  \n  rbu5 eval {\n    CREATE TABLE data_t1(a, b, c, d, rbu_control);\n    INSERT INTO data_t1 VALUES(1, NULL, NULL, 5, '...x');  -- SET d = 5\n    INSERT INTO data_t1 VALUES(2, NULL, 10, 5, '..xx');    -- SET c=10, d = 5\n    INSERT INTO data_t1 VALUES(3, 11, NULL, NULL, '.x..'); -- SET b=11\n  }\n  rbu5 close\n  return $filename\n}\n\n\n# Same as [step_rbu], except using a URI to open the target db.\n#\nproc step_rbu_uri {target rbu} {\n  while 1 {\n    sqlite3rbu rbu file:$target?xyz=&abc=123 $rbu\n    set rc [rbu step]\n    rbu close\n    if {$rc != \"SQLITE_OK\"} break\n  }\n  set rc\n}\n\n# Same as [step_rbu], except using an external state database - \"state.db\"\n#\nproc step_rbu_state {target rbu} {\n  while 1 {\n    sqlite3rbu rbu $target $rbu state.db\n    set rc [rbu step]\n    rbu close\n    if {$rc != \"SQLITE_OK\"} break\n  }\n  set rc\n}\n\nproc dbfilecksum {file} {\n  sqlite3 ck $file\n  set cksum [dbcksum ck main]\n  ck close\n  set cksum\n}\n\nforeach {tn3 create_vfs destroy_vfs} {\n  1 {} {}\n  2 {\n    sqlite3rbu_create_vfs -default myrbu \"\"\n  } {\n    sqlite3rbu_destroy_vfs myrbu\n  }\n} {\n\n  eval $create_vfs\n\n  foreach {tn2 cmd} {\n      1 run_rbu \n      2 step_rbu 3 step_rbu_uri 4 step_rbu_state\n  } {\n    foreach {tn schema} {\n      1 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      }\n      2 { \n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b);\n      }\n      3 { \n        CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;\n      }\n      4 { \n        CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n      }\n      5 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(a, c)) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n      }\n      6 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(c)) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b, a);\n      }\n      7 { \n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b, c);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(a, b, c, a, b, c);\n      }\n\n      8 { \n        CREATE TABLE t1(a PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b, c);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(a, b, c, a, b, c);\n      }\n\n      9 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(a, c));\n        CREATE INDEX i1 ON t1(b);\n      }\n\n      10 { \n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b DESC);\n      }\n\n      11 { \n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b DESC, a ASC, c DESC);\n      }\n\n      12 { \n        CREATE TABLE t1(a INT PRIMARY KEY DESC, b, c) WITHOUT ROWID; \n      }\n\n      13 { \n        CREATE TABLE t1(a INT, b, c, PRIMARY KEY(a DESC)) WITHOUT ROWID; \n      }\n\n      14 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(a DESC, c)) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n      }\n\n      15 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(a, c DESC)) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n      }\n\n      16 { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(c DESC, a)) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b DESC, c, a);\n      }\n    } {\n      reset_db\n      execsql $schema\n      create_rbu1 rbu.db\n      set check [dbfilecksum rbu.db]\n      forcedelete state.db\n\n      do_test $tn3.1.$tn2.$tn.1 {\n        $cmd test.db rbu.db\n      } {SQLITE_DONE}\n\n      do_execsql_test $tn3.1.$tn2.$tn.2 { SELECT * FROM t1 ORDER BY a ASC } {\n        1 2 3 \n        2 two three \n        3 {} 8.2\n      }\n      do_execsql_test $tn3.1.$tn2.$tn.3 { SELECT * FROM t1 ORDER BY b ASC } {\n        3 {} 8.2\n        1 2 3 \n        2 two three \n      }\n      do_execsql_test $tn3.1.$tn2.$tn.4 { SELECT * FROM t1 ORDER BY c ASC } {\n        1 2 3 \n        3 {} 8.2\n        2 two three \n      }\n   \n      do_execsql_test $tn3.1.$tn2.$tn.5 { PRAGMA integrity_check } ok\n\n      if {$cmd==\"step_rbu_state\"} {\n        do_test $tn3.1.$tn2.$tn.6 { file exists state.db } 1\n        do_test $tn3.1.$tn2.$tn.7 { expr {$check == [dbfilecksum rbu.db]} } 1\n      } else {\n        do_test $tn3.1.$tn2.$tn.8 { file exists state.db } 0\n        do_test $tn3.1.$tn2.$tn.9 { expr {$check == [dbfilecksum rbu.db]} } 0\n      }\n    }\n  }\n\n  #-------------------------------------------------------------------------\n  # Check that an RBU cannot be applied to a table that has no PK.\n  #\n  # UPDATE: At one point RBU required that all tables featured either\n  # explicit IPK columns or were declared WITHOUT ROWID. This has been\n  # relaxed so that external PRIMARY KEYs on tables with automatic rowids\n  # are now allowed.\n  #\n  # UPDATE 2: Tables without any PRIMARY KEY declaration are now allowed.\n  # However the input table must feature an \"rbu_rowid\" column.\n  #\n  reset_db\n  create_rbu1 rbu.db\n  do_execsql_test $tn3.2.1 { CREATE TABLE t1(a, b, c) }\n  do_test $tn3.2.2 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_ERROR}\n  do_test $tn3.2.3 {\n    list [catch { rbu close } msg] $msg\n  } {1 {SQLITE_ERROR - table data_t1 requires rbu_rowid column}}\n  reset_db\n  do_execsql_test $tn3.2.4 { CREATE TABLE t1(a PRIMARY KEY, b, c) }\n  do_test $tn3.2.5 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_OK}\n  do_test $tn3.2.6 {\n    list [catch { rbu close } msg] $msg\n  } {0 SQLITE_OK}\n\n  #-------------------------------------------------------------------------\n  # Check that if a UNIQUE constraint is violated the current and all \n  # subsequent [rbu step] calls return SQLITE_CONSTRAINT. And that the RBU \n  # transaction is rolled back by the [rbu close] that deletes the rbu \n  # handle.\n  #\n  foreach {tn errcode errmsg schema} {\n    1 SQLITE_CONSTRAINT \"UNIQUE constraint failed: t1.a\" {\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      INSERT INTO t1 VALUES(3, 2, 1);\n    } \n\n    2 SQLITE_CONSTRAINT \"UNIQUE constraint failed: t1.c\" {\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c UNIQUE);\n      INSERT INTO t1 VALUES(4, 2, 'three');\n    } \n\n    3 SQLITE_CONSTRAINT \"UNIQUE constraint failed: t1.a\" {\n      CREATE TABLE t1(a PRIMARY KEY, b, c);\n      INSERT INTO t1 VALUES(3, 2, 1);\n    } \n\n    4 SQLITE_CONSTRAINT \"UNIQUE constraint failed: t1.c\" {\n      CREATE TABLE t1(a PRIMARY KEY, b, c UNIQUE);\n      INSERT INTO t1 VALUES(4, 2, 'three');\n    } \n\n  } {\n    reset_db\n    execsql $schema\n    set cksum [dbcksum db main]\n\n    do_test $tn3.3.$tn.1 {\n      create_rbu1 rbu.db\n      sqlite3rbu rbu test.db rbu.db\n      while {[set res [rbu step]]==\"SQLITE_OK\"} {}\n      set res\n    } $errcode\n\n    do_test $tn3.3.$tn.2 { rbu step } $errcode\n\n    do_test $tn3.3.$tn.3 { \n      list [catch { rbu close } msg] $msg\n    } [list 1 \"$errcode - $errmsg\"]\n\n    do_test $tn3.3.$tn.4 { dbcksum db main } $cksum\n  }\n\n  #-------------------------------------------------------------------------\n  #\n  foreach {tn2 cmd} {1 run_rbu 2 step_rbu 3 step_rbu_state } {\n    foreach {tn schema} {\n      1 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      }\n      2 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b);\n      }\n      3 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(c, b, c);\n      }\n      4 {\n        CREATE TABLE t1(a INT PRIMARY KEY, b, c) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(c, b, c);\n      }\n      5 {\n        CREATE TABLE t1(a INT PRIMARY KEY, b, c);\n        CREATE INDEX i1 ON t1(b);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(c, b, c);\n      }\n\n      6 {\n        CREATE TABLE t1(a INT PRIMARY KEY DESC, b, c);\n        CREATE INDEX i1 ON t1(b DESC);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(c DESC, b, c);\n      }\n      7 {\n        CREATE TABLE t1(a INT PRIMARY KEY DESC, b, c) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(b);\n        CREATE INDEX i2 ON t1(c, b);\n        CREATE INDEX i3 ON t1(c, b, c);\n      }\n    } {\n      reset_db\n      execsql $schema\n      execsql {\n        INSERT INTO t1 VALUES(2, 'hello', 'world');\n        INSERT INTO t1 VALUES(4, 'hello', 'planet');\n        INSERT INTO t1 VALUES(6, 'hello', 'xyz');\n      }\n\n      create_rbu4 rbu.db\n      set check [dbfilecksum rbu.db]\n      forcedelete state.db\n    \n      do_test $tn3.4.$tn2.$tn.1 {\n        $cmd test.db rbu.db\n      } {SQLITE_DONE}\n      \n      do_execsql_test $tn3.4.$tn2.$tn.2 {\n        SELECT * FROM t1 ORDER BY a ASC;\n      } {\n        1 2 3 \n        3 8 9\n        6 hello xyz\n      }\n    \n      do_execsql_test $tn3.4.$tn2.$tn.3 { PRAGMA integrity_check } ok\n\n      if {$cmd==\"step_rbu_state\"} {\n        do_test $tn3.4.$tn2.$tn.4 { file exists state.db } 1\n        do_test $tn3.4.$tn2.$tn.5 { expr {$check == [dbfilecksum rbu.db]} } 1\n      } else {\n        do_test $tn3.4.$tn2.$tn.6 { file exists state.db } 0\n        do_test $tn3.4.$tn2.$tn.7 { expr {$check == [dbfilecksum rbu.db]} } 0\n      }\n    }\n  }\n\n  foreach {tn2 cmd} {1 run_rbu 2 step_rbu 3 step_rbu_state} {\n    foreach {tn schema} {\n      1 {\n        CREATE TABLE t1(c, b, '(a)' INTEGER PRIMARY KEY);\n        CREATE INDEX i1 ON t1(c, b);\n      }\n      2 {\n        CREATE TABLE t1(c, b, '(a)' PRIMARY KEY);\n      }\n      3 {\n        CREATE TABLE t1(c, b, '(a)' PRIMARY KEY) WITHOUT ROWID;\n      }\n    } {\n      reset_db\n      execsql $schema\n      execsql {\n        INSERT INTO t1('(a)', b, c) VALUES(2, 'hello', 'world');\n        INSERT INTO t1('(a)', b, c) VALUES(4, 'hello', 'planet');\n        INSERT INTO t1('(a)', b, c) VALUES(6, 'hello', 'xyz');\n      }\n\n      create_rbu4b rbu.db\n      set check [dbfilecksum rbu.db]\n      forcedelete state.db\n    \n      do_test $tn3.5.$tn2.$tn.1 {\n        $cmd test.db rbu.db\n      } {SQLITE_DONE}\n      \n      do_execsql_test $tn3.5.$tn2.$tn.2 {\n        SELECT * FROM t1 ORDER BY \"(a)\" ASC;\n      } {\n        3 2 1\n        9 8 3\n        xyz hello 6\n      }\n    \n      do_execsql_test $tn3.4.$tn2.$tn.3 { PRAGMA integrity_check } ok\n\n      if {$cmd==\"step_rbu_state\"} {\n        do_test $tn3.5.$tn2.$tn.4 { file exists state.db } 1\n        do_test $tn3.5.$tn2.$tn.5 { expr {$check == [dbfilecksum rbu.db]} } 1\n      } else {\n        do_test $tn3.5.$tn2.$tn.6 { file exists state.db } 0\n        do_test $tn3.5.$tn2.$tn.7 { expr {$check == [dbfilecksum rbu.db]} } 0\n      }\n    }\n  }\n\n  #-------------------------------------------------------------------------\n  #\n  foreach {tn2 cmd} {1 run_rbu 2 step_rbu 3 step_rbu_state} {\n    foreach {tn schema} {\n      1 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n      }\n      2 {\n        CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n        CREATE INDEX i1 ON t1(d);\n        CREATE INDEX i2 ON t1(d, c);\n        CREATE INDEX i3 ON t1(d, c, b);\n        CREATE INDEX i4 ON t1(b);\n        CREATE INDEX i5 ON t1(c);\n        CREATE INDEX i6 ON t1(c, b);\n      }\n      3 {\n        CREATE TABLE t1(a PRIMARY KEY, b, c, d) WITHOUT ROWID;\n        CREATE INDEX i1 ON t1(d);\n        CREATE INDEX i2 ON t1(d, c);\n        CREATE INDEX i3 ON t1(d, c, b);\n        CREATE INDEX i4 ON t1(b);\n        CREATE INDEX i5 ON t1(c);\n        CREATE INDEX i6 ON t1(c, b);\n      }\n      4 {\n        CREATE TABLE t1(a PRIMARY KEY, b, c, d);\n        CREATE INDEX i1 ON t1(d);\n        CREATE INDEX i2 ON t1(d, c);\n        CREATE INDEX i3 ON t1(d, c, b);\n        CREATE INDEX i4 ON t1(b);\n        CREATE INDEX i5 ON t1(c);\n        CREATE INDEX i6 ON t1(c, b);\n      }\n    } {\n      reset_db\n      execsql $schema\n      execsql {\n        INSERT INTO t1 VALUES(1, 2, 3, 4);\n        INSERT INTO t1 VALUES(2, 5, 6, 7);\n        INSERT INTO t1 VALUES(3, 8, 9, 10);\n      }\n    \n      create_rbu5 rbu.db\n      set check [dbfilecksum rbu.db]\n      forcedelete state.db\n\n      do_test $tn3.5.$tn2.$tn.1 {\n        $cmd test.db rbu.db\n      } {SQLITE_DONE}\n      \n      do_execsql_test $tn3.5.$tn2.$tn.2 {\n        SELECT * FROM t1 ORDER BY a ASC;\n      } {\n        1 2 3 5\n        2 5 10 5\n        3 11 9 10\n      }\n    \n      do_execsql_test $tn3.6.$tn2.$tn.3 { PRAGMA integrity_check } ok\n\n      if {$cmd==\"step_rbu_state\"} {\n        do_test $tn3.6.$tn2.$tn.4 { file exists state.db } 1\n        do_test $tn3.6.$tn2.$tn.5 { expr {$check == [dbfilecksum rbu.db]} } 1\n      } else {\n        do_test $tn3.6.$tn2.$tn.6 { file exists state.db } 0\n        do_test $tn3.6.$tn2.$tn.7 { expr {$check == [dbfilecksum rbu.db]} } 0\n      }\n    }\n  }\n\n  #-------------------------------------------------------------------------\n  # Test some error cases:\n  # \n  #   * A virtual table with no rbu_rowid column.\n  #   * A no-PK table with no rbu_rowid column.\n  #   * A PK table with an rbu_rowid column.\n  #\n  #   6: An update string of the wrong length\n  #\n  ifcapable fts3 {\n    foreach {tn schema error} {\n       1 {\n         CREATE TABLE t1(a, b);\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n       } {SQLITE_ERROR - table data_t1 requires rbu_rowid column}\n    \n       2 {\n         CREATE VIRTUAL TABLE t1 USING fts4(a, b);\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n       } {SQLITE_ERROR - table data_t1 requires rbu_rowid column}\n    \n       3 {\n         CREATE TABLE t1(a PRIMARY KEY, b);\n         CREATE TABLE rbu.data_t1(a, b, rbu_rowid, rbu_control);\n       } {SQLITE_ERROR - table data_t1 may not have rbu_rowid column}\n    \n       4 {\n         CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n         CREATE TABLE rbu.data_t1(a, b, rbu_rowid, rbu_control);\n       } {SQLITE_ERROR - table data_t1 may not have rbu_rowid column}\n    \n       5 {\n         CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT ROWID;\n         CREATE TABLE rbu.data_t1(a, b, rbu_rowid, rbu_control);\n       } {SQLITE_ERROR - table data_t1 may not have rbu_rowid column}\n\n       6 {\n         CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT ROWID;\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n         INSERT INTO rbu.data_t1 VALUES(1, 2, 'x.x');\n       } {SQLITE_ERROR - invalid rbu_control value}\n\n       7 {\n         CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT ROWID;\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n         INSERT INTO rbu.data_t1 VALUES(1, 2, NULL);\n       } {SQLITE_ERROR - invalid rbu_control value}\n\n       8 {\n         CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT ROWID;\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n         INSERT INTO rbu.data_t1 VALUES(1, 2, 4);\n       } {SQLITE_ERROR - invalid rbu_control value}\n\n       9 {\n         CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT ROWID;\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n         INSERT INTO rbu.data_t1 VALUES(1, 2, 3);\n       } {SQLITE_ERROR - invalid rbu_control value}\n\n       10 {\n         CREATE TABLE t2(a, b);\n         CREATE TABLE rbu.data_t1(a, b, rbu_control);\n         INSERT INTO rbu.data_t1 VALUES(1, 2, 2);\n       } {SQLITE_ERROR - no such table: t1}\n\n       11 {\n         CREATE TABLE rbu.data_t2(a, b, rbu_control);\n         INSERT INTO rbu.data_t2 VALUES(1, 2, 2);\n       } {SQLITE_ERROR - no such table: t2}\n\n    } {\n      reset_db\n      forcedelete rbu.db\n      execsql { ATTACH 'rbu.db' AS rbu }\n      execsql $schema\n\n      do_test $tn3.7.$tn {\n        list [catch { run_rbu test.db rbu.db } msg] $msg\n      } [list 1 $error]\n    }\n  }\n\n  # Test that an RBU database containing no input tables is handled\n  # correctly.\n  reset_db\n  forcedelete rbu.db\n  do_test $tn3.8.1 {\n    list [catch { run_rbu test.db rbu.db } msg] $msg\n  } {0 SQLITE_DONE}\n\n  # Test that an RBU database containing only empty data_xxx tables is\n  # also handled correctly.\n  reset_db\n  forcedelete rbu.db\n  do_execsql_test $tn3.8.2.1 {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 2);\n    ATTACH 'rbu.db' AS rbu;\n    CREATE TABLE data_t1(a, b, rbu_control);\n    DETACH rbu;\n  }\n  do_test $tn3.8.2.1 {\n    list [catch { run_rbu test.db rbu.db } msg] $msg\n  } {0 SQLITE_DONE}\n\n  # Test that RBU can update indexes containing NULL values.\n  #\n  reset_db\n  forcedelete rbu.db\n  do_execsql_test $tn3.9.1 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    CREATE INDEX i1 ON t1(b, c);\n    INSERT INTO t1 VALUES(1, 1, NULL);\n    INSERT INTO t1 VALUES(2, NULL, 2);\n    INSERT INTO t1 VALUES(3, NULL, NULL);\n\n    ATTACH 'rbu.db' AS rbu;\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, NULL, NULL, 1);\n    INSERT INTO data_t1 VALUES(3, NULL, NULL, 1);\n  } {}\n\n  do_test $tn3.9.2 {\n    list [catch { run_rbu test.db rbu.db } msg] $msg\n  } {0 SQLITE_DONE}\n\n  do_execsql_test $tn3.9.3 {\n    SELECT * FROM t1\n  } {2 {} 2}\n  do_execsql_test $tn3.9.4 { PRAGMA integrity_check } {ok}\n\n  catch { db close }\n  eval $destroy_vfs\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu10.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu10\n\n\n#--------------------------------------------------------------------\n# Test that UPDATE commands work even if the input columns are in a \n# different order to the output columns. \n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1, 'b', 'c');\n}\n\nproc apply_rbu {sql} {\n  forcedelete rbu.db\n  sqlite3 db2 rbu.db\n  db2 eval $sql\n  db2 close\n  sqlite3rbu rbu test.db rbu.db\n  while { [rbu step]==\"SQLITE_OK\" } {}\n  rbu close\n}\n\ndo_test 1.1 {\n  apply_rbu {\n    CREATE TABLE data_t1(a, c, b, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 'xxx', NULL, '.x.');\n  }\n  db eval { SELECT * FROM t1 }\n} {1 b xxx}\n\n#--------------------------------------------------------------------\n# Test that the hidden languageid column of an fts4 table can be \n# written.\n#\nifcapable fts3 {\n  do_execsql_test 2.0 {\n    CREATE VIRTUAL TABLE ft USING fts4(a, b, languageid='langid');\n  }\n  do_test 2.1 {\n    apply_rbu {\n      CREATE TABLE data_ft(a, b, rbu_rowid, langid, rbu_control);\n      INSERT INTO data_ft VALUES('a', 'b', 22, 1, 0);    -- insert\n      INSERT INTO data_ft VALUES('a', 'b', 23, 10, 0);   -- insert\n      INSERT INTO data_ft VALUES('a', 'b', 24, 100, 0);  -- insert\n    }\n    db eval { SELECT a, b, rowid, langid FROM ft }\n  } [list {*}{\n    a b 22 1\n    a b 23 10\n    a b 24 100\n  }]\n  \n  # Or not - this data_xxx table has no langid column, so langid \n  # defaults to 0.\n  #\n  do_test 2.2 {\n    apply_rbu {\n      CREATE TABLE data_ft(a, b, rbu_rowid, rbu_control);\n      INSERT INTO data_ft VALUES('a', 'b', 25, 0);    -- insert\n    }\n    db eval { SELECT a, b, rowid, langid FROM ft }\n  } [list {*}{\n    a b 22 1\n    a b 23 10\n    a b 24 100\n    a b 25 0\n  }]\n  \n  # Update langid.\n  #\n  do_test 2.3 {\n    apply_rbu {\n      CREATE TABLE data_ft(a, b, rbu_rowid, langid, rbu_control);\n      INSERT INTO data_ft VALUES(NULL, NULL, 23, 50, '..x');\n      INSERT INTO data_ft VALUES(NULL, NULL, 25, 500, '..x');\n    }\n    db eval { SELECT a, b, rowid, langid FROM ft }\n  } [list {*}{\n    a b 22 1\n    a b 23 50\n    a b 24 100\n    a b 25 500\n  }]\n}\n\n#--------------------------------------------------------------------\n# Test that if writing a hidden virtual table column is an error, \n# attempting to do so via rbu is also an error.\n#\nifcapable fts3 {\n  do_execsql_test 3.0 {\n    CREATE VIRTUAL TABLE xt USING fts4(a);\n  }\n  do_test 3.1 {\n    list [catch {\n      apply_rbu {\n        CREATE TABLE data_xt(a, xt, rbu_rowid, rbu_control);\n        INSERT INTO data_xt VALUES('a', 'b', 1, 0);\n      }\n    } msg] $msg\n  } {1 {SQLITE_ERROR - SQL logic error}}\n}\n\n#--------------------------------------------------------------------\n# Test that it is not possible to violate a NOT NULL constraint by\n# applying an RBU update.\n#\ndo_execsql_test 4.1 {\n  CREATE TABLE t2(a INTEGER NOT NULL, b TEXT NOT NULL, c PRIMARY KEY);\n  CREATE TABLE t3(a INTEGER NOT NULL, b TEXT NOT NULL, c INTEGER PRIMARY KEY);\n  CREATE TABLE t4(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;\n\n  INSERT INTO t2 VALUES(10, 10, 10);\n  INSERT INTO t3 VALUES(10, 10, 10);\n  INSERT INTO t4 VALUES(10, 10);\n}\n\nforeach {tn error rbu} {\n  2 {SQLITE_CONSTRAINT - NOT NULL constraint failed: t2.a} {\n    INSERT INTO data_t2 VALUES(NULL, 'abc', 1, 0);\n  }\n  3 {SQLITE_CONSTRAINT - NOT NULL constraint failed: t2.b} {\n    INSERT INTO data_t2 VALUES(2, NULL, 1, 0);\n  }\n  4 {SQLITE_CONSTRAINT - NOT NULL constraint failed: t2.c} {\n    INSERT INTO data_t2 VALUES(1, 'abc', NULL, 0);\n  }\n\n  5 {SQLITE_MISMATCH - datatype mismatch} {\n    INSERT INTO data_t3 VALUES(1, 'abc', NULL, 0);\n  }\n\n  6 {SQLITE_CONSTRAINT - NOT NULL constraint failed: t4.b} {\n    INSERT INTO data_t4 VALUES('a', NULL, 0);\n  }\n  7 {SQLITE_CONSTRAINT - NOT NULL constraint failed: t4.a} {\n    INSERT INTO data_t4 VALUES(NULL, 'a', 0);\n  }\n  8  {SQLITE_CONSTRAINT - NOT NULL constraint failed: t2.a} {\n    INSERT INTO data_t2 VALUES(NULL, 0, 10, 'x..');\n  }\n  9  {SQLITE_CONSTRAINT - NOT NULL constraint failed: t3.b} {\n    INSERT INTO data_t3 VALUES(10, NULL, 10, '.x.');\n  }\n\n  10 {SQLITE_MISMATCH - datatype mismatch} {\n    INSERT INTO data_t3 VALUES(1, 'abc', 'text', 0);\n  }\n} {\n  set rbu \"\n    CREATE TABLE data_t2(a, b, c, rbu_control);\n    CREATE TABLE data_t3(a, b, c, rbu_control);\n    CREATE TABLE data_t4(a, b, rbu_control);\n    $rbu\n  \"\n  do_test 4.2.$tn {\n    list [catch { apply_rbu $rbu } msg] $msg\n  } [list 1 $error]\n}\n\ndo_test 4.3 {\n  set rbu {\n    CREATE TABLE data_t3(a, b, c, rbu_control);\n    INSERT INTO data_t3 VALUES(1, 'abc', '5', 0);\n    INSERT INTO data_t3 VALUES(1, 'abc', '-6.0', 0);\n  }\n  list [catch { apply_rbu $rbu } msg] $msg\n} {0 SQLITE_DONE}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu11.test",
    "content": "# 2015 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu11\n\n\n#--------------------------------------------------------------------\n# Test that the xAccess() method of an rbu vfs handles queries other\n# than SQLITE_ACCESS_EXISTS correctly. The test code below causes\n# SQLite to call xAccess(SQLITE_ACCESS_READWRITE) on the directory\n# path argument passed to \"PRAGMA temp_store_directory\".\n#\ndo_test 1.1 {\n  sqlite3rbu_create_vfs -default rbu \"\"\n  reset_db\n  catchsql { PRAGMA temp_store_directory = '/no/such/directory' }\n} {1 {not a writable directory}}\n\ndo_test 1.2 {\n  catchsql \" PRAGMA temp_store_directory = '[pwd]' \"\n} {0 {}}\n\ndo_test 1.3 {\n  catchsql \" PRAGMA temp_store_directory = '' \"\n} {0 {}}\n\ndo_test 1.4 {\n  db close\n  sqlite3rbu_destroy_vfs rbu\n} {}\n\n#--------------------------------------------------------------------\n# Try to trick rbu into operating on a database opened in wal mode.\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  PRAGMA journal_mode = 'wal';\n  CREATE TABLE t2(d PRIMARY KEY, e, f);\n} {wal}\n\ndo_test 2.2 {\n  db_save \n  db close\n\n  forcedelete rbu.db\n  sqlite3 dbo rbu.db\n  dbo eval {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(4, 5, 6, 0);\n    INSERT INTO data_t1 VALUES(7, 8, 9, 0);\n  }\n  dbo close\n\n  db_restore \n  hexio_write test.db 18 0101\n  file exists test.db-wal\n} {1}\n\ndo_test 2.3 {\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_ERROR}\n\ndo_test 2.4 {\n  list [catch {rbu close} msg] $msg\n} {1 {SQLITE_ERROR - cannot update wal mode database}}\n\n#--------------------------------------------------------------------\n# Test a constraint violation message with an unusual table name. \n# Specifically, one for which the first character is a codepoint\n# smaller than 30 (character '0').\n#\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE \"(t1)\"(a PRIMARY KEY, b, c);\n  INSERT INTO \"(t1)\" VALUES(1, 2, 3);\n  INSERT INTO \"(t1)\" VALUES(4, 5, 6);\n}\ndb close\n\ndo_test 3.2 {\n  forcedelete rbu.db\n  sqlite3 dbo rbu.db\n  dbo eval {\n    CREATE TABLE \"data_(t1)\"(a, b, c, rbu_control);\n    INSERT INTO \"data_(t1)\" VALUES(4, 8, 9, 0);\n  }\n  dbo close\n\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n  rbu step\n} {SQLITE_CONSTRAINT}\n\ndo_test 3.3 {\n  list [catch {rbu close} msg] $msg\n} {1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: (t1).a}}\n\n#--------------------------------------------------------------------\n# Check that once an RBU update has been applied, attempting to apply\n# it a second time is a no-op (as the state stored in the RBU database is\n# \"all steps completed\").\n#\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE \"(t1)\"(a, b, c, PRIMARY KEY(c, b, a));\n  INSERT INTO \"(t1)\" VALUES(1, 2, 3);\n  INSERT INTO \"(t1)\" VALUES(4, 5, 6);\n}\ndb close\n\ndo_test 4.2 {\n  forcedelete rbu.db\n  sqlite3 dbo rbu.db\n  dbo eval {\n    CREATE TABLE \"data_(t1)\"(a, b, c, rbu_control);\n    INSERT INTO \"data_(t1)\" VALUES(7, 8, 9, 0);\n    INSERT INTO \"data_(t1)\" VALUES(1, 2, 3, 1);\n  }\n  dbo close\n\n  sqlite3rbu rbu test.db rbu.db\n  while {[rbu step]==\"SQLITE_OK\"} { }\n  rbu close\n} {SQLITE_DONE}\n\ndo_test 4.3 {\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_DONE}\n\ndo_test 4.4 {\n  rbu close\n} {SQLITE_DONE}\n\ndo_test 4.5.1 {\n  sqlite3 dbo rbu.db\n  dbo eval { INSERT INTO rbu_state VALUES(100, 100) }\n  dbo close\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_CORRUPT}\ndo_test 4.5.2 {\n  list [catch {rbu close} msg] $msg\n} {1 SQLITE_CORRUPT}\ndo_test 4.5.3 {\n  sqlite3 dbo rbu.db\n  dbo eval { DELETE FROM rbu_state WHERE k = 100 }\n  dbo close \n} {}\n\n# Also, check that an invalid state value in the rbu_state table is\n# detected and reported as corruption.\ndo_test 4.6.1 {\n  sqlite3 dbo rbu.db\n  dbo eval { UPDATE rbu_state SET v = v*-1 WHERE k = 1 }\n  dbo close\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_CORRUPT}\ndo_test 4.6.2 {\n  list [catch {rbu close} msg] $msg\n} {1 SQLITE_CORRUPT}\ndo_test 4.6.3 {\n  sqlite3 dbo rbu.db\n  dbo eval { UPDATE rbu_state SET v = v*-1 WHERE k = 1 }\n  dbo close \n} {}\n\ndo_test 4.7.1 {\n  sqlite3 dbo rbu.db\n  dbo eval { UPDATE rbu_state SET v = 1 WHERE k = 1 }\n  dbo eval { UPDATE rbu_state SET v = 'nosuchtable' WHERE k = 2 }\n  dbo close\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_ERROR}\ndo_test 4.7.2 {\n  list [catch {rbu close} msg] $msg\n} {1 {SQLITE_ERROR - rbu_state mismatch error}}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu12.test",
    "content": "# 2015 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix rbu12\n\nset setup_sql {\n  DROP TABLE IF EXISTS xx;\n  DROP TABLE IF EXISTS xy;\n  CREATE TABLE xx(a, b, c PRIMARY KEY);\n  INSERT INTO xx VALUES(1, 2, 3);\n  CREATE TABLE xy(a, b, c PRIMARY KEY);\n\n  ATTACH 'rbu.db' AS rbu;\n    DROP TABLE IF EXISTS data_xx;\n    CREATE TABLE rbu.data_xx(a, b, c, rbu_control);\n    INSERT INTO data_xx VALUES(4, 5, 6, 0);\n    INSERT INTO data_xx VALUES(7, 8, 9, 0);\n    CREATE TABLE rbu.data_xy(a, b, c, rbu_control);\n    INSERT INTO data_xy VALUES(10, 11, 12, 0);\n  DETACH rbu;\n}\n\ndo_multiclient_test tn {\n\n  # Initialize a target (test.db) and rbu (rbu.db) database.\n  #\n  forcedelete rbu.db\n  sql1 $setup_sql\n\n  # Using connection 2, open a read transaction on the target database.\n  # RBU will still be able to generate \"test.db-oal\", but it will not be\n  # able to rename it to \"test.db-wal\".\n  #\n  do_test 1.$tn.1 {\n    sql2 { BEGIN; SELECT * FROM xx; }\n  } {1 2 3}\n  do_test 1.$tn.2 {\n    sqlite3rbu rbu test.db rbu.db\n    while 1 {\n      set res [rbu step]\n      if {$res!=\"SQLITE_OK\"} break\n    }\n    set res\n  } {SQLITE_BUSY}\n\n  do_test 1.$tn.3 { sql2 { SELECT * FROM xx; } } {1 2 3}\n  do_test 1.$tn.4 { sql2 { SELECT * FROM xy; } } {}\n  do_test 1.$tn.5 {\n    list [file exists test.db-wal] [file exists test.db-oal]\n  } {0 1}\n  do_test 1.$tn.6 { sql2 COMMIT } {}\n\n  # The rbu object that hit the SQLITE_BUSY error above cannot be reused.\n  # It is stuck in a permanent SQLITE_BUSY state at this point.\n  #\n  do_test 1.$tn.7 { rbu step } {SQLITE_BUSY}\n  do_test 1.$tn.8 { \n    list [catch { rbu close } msg] $msg \n  } {1 SQLITE_BUSY}\n\n  do_test 1.$tn.9.1 { sql2 { BEGIN EXCLUSIVE } } {}\n  do_test 1.$tn.9.2 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_BUSY}\n  do_test 1.$tn.9.3 {\n    list [catch { rbu close } msg] $msg \n  } {1 {SQLITE_BUSY - database is locked}}\n  do_test 1.$tn.9.4 { sql2 COMMIT } {}\n\n  sqlite3rbu rbu test.db rbu.db\n  do_test 1.$tn.10.1 { sql2 { BEGIN EXCLUSIVE } } {}\n  do_test 1.$tn.10.2 {\n    rbu step\n  } {SQLITE_BUSY}\n  do_test 1.$tn.10.3 {\n    list [catch { rbu close } msg] $msg \n  } {1 SQLITE_BUSY}\n  do_test 1.$tn.10.4 { sql2 COMMIT } {}\n\n  # A new rbu object can finish the work though.\n  #\n  do_test 1.$tn.11 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_OK}\n  do_test 1.$tn.12 {\n    list [file exists test.db-wal] [file exists test.db-oal]\n  } {1 0}\n  do_test 1.$tn.13 {\n    while 1 {\n      set res [rbu step]\n      if {$res!=\"SQLITE_OK\"} break\n    }\n    set res\n  } {SQLITE_DONE}\n\n  do_test 1.$tn.14 {\n    rbu close\n  } {SQLITE_DONE}\n}\n\ndo_multiclient_test tn {\n\n  # Initialize a target (test.db) and rbu (rbu.db) database.\n  #\n  forcedelete rbu.db\n  sql1 $setup_sql\n\n  do_test 2.$tn.1 {\n    sqlite3rbu rbu test.db rbu.db\n    while {[file exists test.db-wal]==0} {\n      if {[rbu step]!=\"SQLITE_OK\"} {error \"problem here....\"}\n    }\n    rbu close\n  } {SQLITE_OK}\n\n\n  do_test 2.$tn.2 { sql2 { BEGIN IMMEDIATE } } {}\n\n  do_test 2.$tn.3 { \n    sqlite3rbu rbu test.db rbu.db\n    rbu step \n  } {SQLITE_BUSY}\n\n  do_test 2.$tn.4 { list [catch { rbu close } msg] $msg } {1 SQLITE_BUSY}\n\n  do_test 2.$tn.5 { \n    sql2 { SELECT * FROM xx ; COMMIT }\n  } {1 2 3 4 5 6 7 8 9}\n\n  do_test 2.$tn.6 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n    rbu close\n  } {SQLITE_OK}\n\n  do_test 2.$tn.7 { sql2 { BEGIN EXCLUSIVE } } {}\n\n  do_test 2.$tn.8 { \n    sqlite3rbu rbu test.db rbu.db\n    rbu step \n  } {SQLITE_BUSY}\n  do_test 2.$tn.9 { list [catch { rbu close } msg] $msg } {1 SQLITE_BUSY}\n  do_test 2.$tn.10 { \n    sql2 { SELECT * FROM xx ; COMMIT }\n  } {1 2 3 4 5 6 7 8 9}\n\n  do_test 2.$tn.11 {\n    sqlite3rbu rbu test.db rbu.db\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } {SQLITE_DONE}\n\n}\n\n#-------------------------------------------------------------------------\n# Test that \"PRAGMA data_version\" works when an RBU client writes the\n# database.\n#\ndo_multiclient_test tn {\n\n  # Initialize a target (test.db) and rbu (rbu.db) database.\n  #\n  forcedelete rbu.db\n  sql1 $setup_sql\n\n  # Check the initial database contains table \"xx\" with a single row.\n  # Also save the current values of \"PRAGMA data-version\" for [db1] \n  # and [db2].\n  #\n  do_test 2.$tn.1 {\n    list [sql1 { SELECT count(*) FROM xx }] [sql2 { SELECT count(*) FROM xx }]\n  } {1 1}\n  set V1 [sql1 {PRAGMA data_version}] \n  set V2 [sql2 {PRAGMA data_version}]\n\n  # Check the values of data-version have not magically changed.\n  #\n  do_test 2.$tn.2 {\n    list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]\n  } [list $V1 $V2]\n\n  # Start stepping the RBU. From the point of view of [db1] and [db2], the \n  # data-version values remain unchanged until the database contents are\n  # modified. At which point the values are incremented.\n  #\n  sqlite3rbu rbu test.db rbu.db\n  set x 0\n  while {[db one {SELECT count(*) FROM xx}]==1} {\n    do_test 2.$tn.3.[incr x] {\n      list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]\n    } [list $V1 $V2]\n    rbu step\n  }\n  do_test 2.$tn.5.1 { expr {$V1 < [sql1 {PRAGMA data_version}]} } 1\n  do_test 2.$tn.5.2 { expr {$V2 < [sql2 {PRAGMA data_version}]} } 1\n\n  # Check the db contents is as expected.\n  #\n  do_test 2.$tn.4 {\n    list [sql1 {SELECT count(*) FROM xx}] [sql2 {SELECT count(*) FROM xx}]\n  } {3 3}\n\n  set V1 [sql1 {PRAGMA data_version}] \n  set V2 [sql2 {PRAGMA data_version}]\n\n  # Finish applying the RBU (i.e. do the incremental checkpoint). Check that\n  # this does not cause the data-version values to change.\n  #\n  while {[rbu step]==\"SQLITE_OK\"} { }\n  rbu close\n\n  do_test 2.$tn.6 {\n    list [sql1 {PRAGMA data_version}] [sql2 {PRAGMA data_version}]\n  } [list $V1 $V2]\n\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu13.test",
    "content": "# 2015 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test an RBU update that features lots of different rbu_control strings\n# for UPDATE statements. This tests RBU's internal UPDATE statement cache.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix rbu13\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c, d, e, f, g, h);\n  WITH ii(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM ii WHERE i<127)\n  INSERT INTO t1 SELECT i, 0, 0, 0, 0, 0, 0, 0 FROM ii;\n}\n\nforcedelete rbu.db\ndo_execsql_test 1.1 {\n  ATTACH 'rbu.db' AS rbu;\n  CREATE TABLE rbu.data_t1(a, b, c, d, e, f, g, h, rbu_control);\n}\n\ndo_test 1.2 {\n  for {set i 0} {$i<128} {incr i} {\n    set control \".\"\n    for {set bit 6} {$bit>=0} {incr bit -1} {\n      if { $i & (1<<$bit) } {\n        append control \"x\"\n      } else {\n        append control \".\"\n      }\n    }\n    execsql { INSERT INTO data_t1 VALUES($i, 1, 1, 1, 1, 1, 1, 1, $control) }\n  }\n} {}\n\ndo_test 1.3 {\n  sqlite3rbu rbu test.db rbu.db\n  while 1 {\n    set rc [rbu step]\n    if {$rc!=\"SQLITE_OK\"} break\n  }\n  rbu close\n} {SQLITE_DONE}\n\ndo_execsql_test 1.4 {\n  SELECT count(*) FROM t1 WHERE\n  a == ( (b<<6) + (c<<5) + (d<<4) + (e<<3) + (f<<2) + (g<<1) + (h<<0) )\n} {128}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu14.test",
    "content": "# 2015 July 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that an RBU data_xxx table may be a view instead of a regular\n# table.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix rbu14\n\n\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    CREATE TABLE t2(a PRIMARY KEY, b, c);\n  }\n  2 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    CREATE TABLE t2(a PRIMARY KEY, b, c);\n    CREATE INDEX i1 ON t1(b, c);\n    CREATE INDEX i2 ON t2(b, c);\n  }\n  3 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;\n  }\n  4 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE INDEX i1 ON t1(b, c);\n    CREATE INDEX i2 ON t2(b, c);\n  }\n} {\n  reset_db\n\n  execsql $schema\n  execsql {\n    INSERT INTO t1 VALUES(50, 50, 50);\n    INSERT INTO t1 VALUES(51, 51, 51);\n    INSERT INTO t2 VALUES(50, 50, 50);\n    INSERT INTO t2 VALUES(51, 51, 51);\n  }\n\n  forcedelete rbu.db\n  do_execsql_test $tn.1 {\n    ATTACH 'rbu.db' AS rbu;\n    CREATE TABLE rbu.stuff(tbl, a, b, c, rbu_control);\n    INSERT INTO stuff VALUES\n      ('t1', 1, 2, 3, 0),                   -- insert into t1\n      ('t2', 4, 5, 6, 0),                   -- insert into t2\n      ('t1', 50, NULL, NULL, 1),            -- delete from t1\n      ('t2', 51, NULL, NULL, 1);            -- delete from t2\n\n    CREATE VIEW rbu.data_t1 AS \n    SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t1';\n    CREATE VIEW rbu.data_t2 AS \n    SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t2';\n  }\n\n  do_test $tn.2 {\n    while 1 {\n      sqlite3rbu rbu test.db rbu.db\n      set rc [rbu step]\n      rbu close\n      if {$rc != \"SQLITE_OK\"} break\n    }\n    set rc\n  } {SQLITE_DONE}\n\n  do_execsql_test $tn.3.1 {\n    SELECT * FROM t1 ORDER BY a;\n  } {1 2 3 51 51 51}\n\n  do_execsql_test $tn.3.2 {\n    SELECT * FROM t2 ORDER BY a;\n  } {4 5 6 50 50 50}\n\n  integrity_check $tn.4\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu3.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu3\n\n\n# Run the RBU in file $rbu on target database $target until completion.\n#\nproc run_rbu {target rbu} {\n  sqlite3rbu rbu $target $rbu\n  while { [rbu step]==\"SQLITE_OK\" } {}\n  rbu close\n}\n\nforcedelete test.db-oal rbu.db\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\nreset_db\n\n#--------------------------------------------------------------------\n# Test that for an RBU to be applied, no corruption results if the\n# affinities on the source and target table do not match.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);\n  CREATE INDEX i1 ON x1(b, c);\n} {}\n\ndo_test 1.1 {\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_x1(a, b, c, rbu_control);\n    INSERT INTO data_x1 VALUES(1, '123', '123', 0);\n    INSERT INTO data_x1 VALUES(2, 123, 123, 0);\n  }\n  db2 close\n  run_rbu test.db rbu.db\n} {SQLITE_DONE}\n\ndo_execsql_test 1.2 {\n  PRAGMA integrity_check;\n} {ok}\n\n#--------------------------------------------------------------------\n# Test that NULL values may not be inserted into INTEGER PRIMARY KEY\n# columns.\n#\nforcedelete rbu.db\nreset_db\n\ndo_execsql_test 2.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b TEXT, c REAL);\n  CREATE INDEX i1 ON x1(b, c);\n} {}\n\nforeach {tn rbudb} {\n  1 {\n    CREATE TABLE data_x1(a, b, c, rbu_control);\n    INSERT INTO data_x1 VALUES(NULL, 'a', 'b', 0);\n  }\n\n  2 {\n    CREATE TABLE data_x1(c, b, a, rbu_control);\n    INSERT INTO data_x1 VALUES('b', 'a', NULL, 0);\n  }\n} {\n  do_test 2.$tn.1 {\n    forcedelete rbu.db\n    sqlite3 db2 rbu.db\n    db2 eval $rbudb\n    db2 close\n    list [catch { run_rbu test.db rbu.db } msg] $msg\n  } {1 {SQLITE_MISMATCH - datatype mismatch}}\n\n  do_execsql_test 2.1.2 {\n    PRAGMA integrity_check;\n  } {ok}\n}\n\n#--------------------------------------------------------------------\n# Test that missing columns are detected.\n#\nforcedelete rbu.db\nreset_db\n\ndo_execsql_test 2.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX i1 ON x1(b, c);\n} {}\n\ndo_test 2.1 {\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_x1(a, b, rbu_control);\n    INSERT INTO data_x1 VALUES(1, 'a', 0);\n  }\n  db2 close\n  list [catch { run_rbu test.db rbu.db } msg] $msg\n} {1 {SQLITE_ERROR - column missing from data_x1: c}}\n\ndo_execsql_test 2.2 {\n  PRAGMA integrity_check;\n} {ok}\n\n# Also extra columns.\n#\ndo_execsql_test 2.3 {\n  CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX i2 ON x2(b, c);\n} {}\n\ndo_test 2.4 {\n  forcedelete rbu.db\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_x2(a, b, c, d, rbu_control);\n    INSERT INTO data_x2 VALUES(1, 'a', 2, 3, 0);\n  }\n  db2 close\n  list [catch { run_rbu test.db rbu.db } msg] $msg\n} {1 SQLITE_ERROR}\n\ndo_execsql_test 2.5 {\n  PRAGMA integrity_check;\n} {ok}\n\n\n#-------------------------------------------------------------------------\n# Test that sqlite3rbu_create_vfs() returns an error if the requested \n# parent VFS is unknown.\n#\n# And that nothing disasterous happens if a VFS name passed to\n# sqlite3rbu_destroy_vfs() is unknown or not an RBU vfs.\n#\ndo_test 3.1 {\n  list [catch {sqlite3rbu_create_vfs xyz nosuchparent} msg] $msg\n} {1 SQLITE_NOTFOUND}\n\ndo_test 3.2 {\n  sqlite3rbu_destroy_vfs nosuchvfs\n  sqlite3rbu_destroy_vfs unix\n  sqlite3rbu_destroy_vfs win32\n} {}\n\n#-------------------------------------------------------------------------\n# Test that it is an error to specify an explicit VFS that does not \n# include rbu VFS functionality.\n#\ndo_test 4.1 {\n  testvfs tvfs\n  sqlite3rbu rbu file:test.db?vfs=tvfs rbu.db \n  list [catch { rbu step } msg] $msg\n} {0 SQLITE_ERROR}\ndo_test 4.2 {\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - rbu vfs not found}}\ntvfs delete\n\n#-------------------------------------------------------------------------\n# Test a large rbu update to ensure that wal_autocheckpoint does not get\n# in the way.\n#\nforcedelete rbu.db\nreset_db\ndo_execsql_test 5.1 {\n  CREATE TABLE x1(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;\n  CREATE INDEX i1 ON x1(a);\n\n  ATTACH 'rbu.db' AS rbu;\n  CREATE TABLE rbu.data_x1(a, b, c, rbu_control);\n  WITH s(a, b, c) AS (\n    SELECT randomblob(300), randomblob(300), 1\n    UNION ALL\n    SELECT randomblob(300), randomblob(300), c+1 FROM s WHERE c<2000\n  )\n  INSERT INTO data_x1 SELECT a, b, c, 0 FROM s;\n}\n\ndo_test 5.2 {\n  sqlite3rbu rbu test.db rbu.db\n  while {[rbu step]==\"SQLITE_OK\" && [file exists test.db-wal]==0} {}\n  rbu close\n} {SQLITE_OK}\n\ndo_test 5.3 {\n  expr {[file size test.db-wal] > (1024 * 1200)}\n} 1\n\ndo_test 6.1 { sqlite3rbu_internal_test } {}\n\nfinish_test\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu5.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test some properties of the pager_rbu_mode and rbu_mode pragmas.\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbu5\n\n\n# Return a list of the primary key columns for table $tbl in the database\n# opened by database handle $db.\n#\nproc pkcols {db tbl} {\n  set ret [list]\n  $db eval \"PRAGMA table_info = '$tbl'\" {\n    if {$pk} { lappend ret $name }\n  }\n  return $ret\n}\n\n# Return a list of all columns for table $tbl in the database opened by \n# database handle $db.\n#\nproc allcols {db tbl} {\n  set ret [list]\n  $db eval \"PRAGMA table_info = '$tbl'\" {\n    lappend ret $name\n  }\n  return $ret\n}\n\n# Return a checksum on all tables and data in the main database attached\n# to database handle $db. It is possible to add indexes without changing\n# the checksum.\n#\nproc datacksum {db} {\n\n  $db eval { SELECT name FROM sqlite_master WHERE type='table' } {\n    append txt $name\n    set cols [list]\n    set order [list]\n    set cnt 0\n    $db eval \"PRAGMA table_info = $name\" x {\n      lappend cols \"quote($x(name))\"\n      lappend order [incr cnt]\n    }\n    set cols [join $cols ,]\n    set order [join $order ,]\n    append txt [$db eval \"SELECT $cols FROM $name ORDER BY $order\"]\n  }\n  return \"[string length $txt]-[md5 $txt]\"\n}\n\nproc ucontrol {args} {\n  set ret \"\"\n  foreach a $args {\n    if {$a} {\n      append ret .\n    } else {\n      append ret x\n    }\n  }\n  return $ret\n}\n\n# Argument $target is the name of an SQLite database file. $sql is an SQL\n# script containing INSERT, UPDATE and DELETE statements to execute against\n# it. This command creates an RBU update database in file $rbu that has\n# the same effect as the script. The target database is not modified by\n# this command.\n#\nproc generate_rbu_db {target rbu sql} {\n\n  forcedelete $rbu\n  forcecopy $target copy.db\n\n  # Evaluate the SQL script to modify the contents of copy.db.\n  #\n  sqlite3 dbRbu copy.db\n  dbRbu eval $sql\n\n  dbRbu function ucontrol ucontrol\n  \n  # Evaluate the SQL script to modify the contents of copy.db.\n  set ret [datacksum dbRbu]\n\n  dbRbu eval { ATTACH $rbu AS rbu }\n  dbRbu eval { ATTACH $target AS orig }\n\n  dbRbu eval { SELECT name AS tbl FROM sqlite_master WHERE type = 'table' } {\n    set pk [pkcols dbRbu $tbl]\n    set cols [allcols dbRbu $tbl]\n\n    # A WHERE clause to test that the PK columns match.\n    #\n    set where [list]\n    foreach c $pk { lappend where \"main.$tbl.$c IS orig.$tbl.$c\" }\n    set where [join $where \" AND \"]\n    \n    # A WHERE clause to test that all columns match.\n    #\n    set where2 [list]\n    foreach c $cols { lappend where2 \"main.$tbl.$c IS orig.$tbl.$c\" }\n    set ucontrol \"ucontrol([join $where2 ,])\"\n    set where2 [join $where2 \" AND \"]\n\n    # Create a data_xxx table in the RBU update database.\n    dbRbu eval \"\n      CREATE TABLE rbu.data_$tbl AS SELECT *, '' AS rbu_control \n      FROM main.$tbl LIMIT 0\n    \"\n\n    # Find all new rows INSERTed by the script.\n    dbRbu eval \"\n      INSERT INTO rbu.data_$tbl \n          SELECT *, 0 AS rbu_control FROM main.$tbl\n          WHERE NOT EXISTS (\n            SELECT 1 FROM orig.$tbl WHERE $where\n          )\n    \"\n    \n    # Find all old rows DELETEd by the script.\n    dbRbu eval \"\n      INSERT INTO rbu.data_$tbl \n          SELECT *, 1 AS rbu_control FROM orig.$tbl\n          WHERE NOT EXISTS (\n            SELECT 1 FROM main.$tbl WHERE $where\n          )\n    \"\n    \n    # Find all rows UPDATEd by the script.\n    set origcols [list]\n    foreach c $cols { lappend origcols \"main.$tbl.$c\" }\n    set origcols [join $origcols ,]\n    dbRbu eval \"\n      INSERT INTO rbu.data_$tbl\n          SELECT $origcols, $ucontrol AS rbu_control \n          FROM orig.$tbl, main.$tbl\n          WHERE $where AND NOT ($where2)\n    \"\n\n  }\n\n  dbRbu close\n  forcedelete copy.db\n\n  return $ret\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  CREATE TABLE t2(x, y, z, PRIMARY KEY(y, z)) WITHOUT ROWID;\n\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(2, 4, 6);\n  INSERT INTO t1 VALUES(3, 6, 9);\n\n  INSERT INTO t2 VALUES(1, 2, 3);\n  INSERT INTO t2 VALUES(2, 4, 6);\n  INSERT INTO t2 VALUES(3, 6, 9);\n}\ndb close\n\nset cksum [generate_rbu_db test.db rbu.db {\n  INSERT INTO t1 VALUES(4, 8, 12);\n  DELETE FROM t1 WHERE a = 2;\n  UPDATE t1 SET c = 15 WHERE a=3;\n\n  INSERT INTO t2 VALUES(4, 8, 12);\n  DELETE FROM t2 WHERE x = 2;\n  UPDATE t2 SET x = 15 WHERE z=9;\n}]\n\nforeach {tn idx} {\n  1 {\n  }\n  2 {\n    CREATE INDEX i1 ON t1(a, b, c);\n    CREATE INDEX i2 ON t2(x, y, z);\n  }\n} {\n  foreach cmd {run step} {\n    forcecopy test.db test.db2\n    forcecopy rbu.db rbu.db2\n\n    sqlite3 db test.db2\n    db eval $idx\n\n    do_test 1.$tn.$cmd.1 {\n      ${cmd}_rbu test.db2 rbu.db2\n      datacksum db\n    } $cksum\n\n    do_test 1.$tn.$cmd.2 {\n      db eval { PRAGMA integrity_check } \n    } {ok}\n\n    db close\n  }\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e);\n  INSERT INTO t1 VALUES(-750250,'fyetckfaagjkzqjx',-185831,X'FEAD',444258.29);\n  INSERT INTO t1 VALUES(649081,NULL,X'7DF25BF78778',-342324.63,'akvspktocwozo');\n  INSERT INTO t1 VALUES(-133045,-44822.31,X'',287935,NULL);\n  INSERT INTO t1 VALUES(202132,NULL,X'5399','cujsjtspryqeyovcdpz','m');\n  INSERT INTO t1 VALUES(302910,NULL,'dvdhivtfkaedzhdcnn',-717113.41,688487);\n  INSERT INTO t1 VALUES(-582327,X'7A267A',X'7E6B3CFE5CB9','zacuzilrok',-196478);\n  INSERT INTO t1 VALUES(-190462,X'D1A087E7D68D9578','lsmleti',NULL,-928094);\n  INSERT INTO t1 VALUES(-467665,176344.57,-536684.23,828876.22,X'903E');\n  INSERT INTO t1 VALUES(-629138,632630.29,X'28D6',-774501,X'819BBBFC65');\n  INSERT INTO t1 VALUES(-828110,-54379.24,-881121.44,X'',X'8D5A894F0D');\n\n  CREATE TABLE t2(a PRIMARY KEY, b, c, d, e) WITHOUT ROWID;\n  INSERT INTO t2 VALUES(-65174,X'AC1DBFFE27310F',-194471.08,347988,X'84041BA6F9BDDE86A8');\n  INSERT INTO t2 VALUES('bzbpi',-952693.69,811628.25,NULL,-817434);\n  INSERT INTO t2 VALUES(-643830,NULL,'n',NULL,'dio');\n  INSERT INTO t2 VALUES('rovoenxxj',NULL,'owupbtdcoxxnvg',-119676,X'55431DFA');\n  INSERT INTO t2 VALUES(899770,'jlygdl',X'DBCA4D1A',NULL,-631773);\n  INSERT INTO t2 VALUES(334698.80,NULL,-697585.58,-89277,-817352);\n  INSERT INTO t2 VALUES(X'1A9EB7547A4AAF38','aiprdhkpzdz','anw','szvjbwdvzucybpwwqjt',X'53');\n  INSERT INTO t2 VALUES(713220,NULL,'hfcqhqzjuqplvkum',X'20B076075649DE','fthgpvqdyy');\n  INSERT INTO t2 VALUES(763908,NULL,'xgslzcpvwfknbr',X'75',X'668146');\n  INSERT INTO t2 VALUES(X'E1BA2B6BA27278','wjbpd',NULL,139341,-290086.15);\n}\ndb close\n\nset cksum [generate_rbu_db test.db rbu.db {\nINSERT INTO t2 VALUES(222916.23,'idh',X'472C517405',X'E3',X'7C4F31824669');\nINSERT INTO t2 VALUES('xcndjwafcoxwxizoktd',-319567.21,NULL,-720906.43,-577170);\nINSERT INTO t2 VALUES(376369.99,-536058,'yoaiurfqupdscwc',X'29EC8A2542EC3953E9',-740485.22);\nINSERT INTO t2 VALUES(X'0EFB4DC50693',-175590.83,X'1779E253CAB5B1789E',X'BC6903',NULL);\nINSERT INTO t2 VALUES(-288299,'hfrp',NULL,528477,730676.77);\nDELETE FROM t2 WHERE a < -60000;\n\nUPDATE t2 SET b = 'pgnnaaoflnw' WHERE a = 'bzbpi';\nUPDATE t2 SET c = -675583 WHERE a = 'rovoenxxj';\nUPDATE t2 SET d = X'09CDF2B2C241' WHERE a = 713220;\n\nINSERT INTO t1 VALUES(224938,'bmruycvfznhhnfmgqys','fr',854381,789143);\nINSERT INTO t1 VALUES(-863931,-1386.26,X'2A058540C2FB5C',NULL,X'F9D5990A');\nINSERT INTO t1 VALUES(673696,X'97301F0AC5735F44B5',X'440C',227999.92,-709599.79);\nINSERT INTO t1 VALUES(-243640,NULL,-71718.11,X'1EEFEB38',X'8CC7C55D95E142FBA5');\nINSERT INTO t1 VALUES(275893,X'',375606.30,X'0AF9EC334711FB',-468194);\nDELETE FROM t1 WHERE a > 200000;\n\nUPDATE t1 SET b = 'pgnnaaoflnw' WHERE a = -190462;\nUPDATE t1 SET c = -675583 WHERE a = -467665;\nUPDATE t1 SET d = X'09CDF2B2C241' WHERE a = -133045;\n\n}]\n\nforeach {tn idx} {\n  1 {\n  }\n  2 {\n    CREATE UNIQUE INDEX i1 ON t1(b, c, d);\n    CREATE UNIQUE INDEX i2 ON t1(d, e, a);\n    CREATE UNIQUE INDEX i3 ON t1(e, d, c, b);\n\n    CREATE UNIQUE INDEX i4 ON t2(b, c, d);\n    CREATE UNIQUE INDEX i5 ON t2(d, e, a);\n    CREATE UNIQUE INDEX i6 ON t2(e, d, c, b);\n  }\n} {\n  foreach cmd {run step} {\n    forcecopy test.db test.db2\n    forcecopy rbu.db rbu.db2\n\n    sqlite3 db test.db2\n    db eval $idx\n\n    do_test 2.$tn.$cmd.1 {\n      ${cmd}_rbu test.db2 rbu.db2\n      datacksum db\n    } $cksum\n\n    do_test 2.$tn.$cmd.2 {\n      db eval { PRAGMA integrity_check } \n    } {ok}\n\n    db close\n  }\n}\n\n\nfinish_test\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu6.test",
    "content": "# 2014 October 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module. Specifically, it tests the\n# outcome of some other client writing to the database while an RBU update\n# is being applied.\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu6\n\nproc setup_test {} {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b UNIQUE);\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b UNIQUE);\n  }\n  db close\n\n  forcedelete rbu.db\n  sqlite3 rbu rbu.db\n  rbu eval {\n    CREATE TABLE data_t1(a, b, rbu_control);\n    CREATE TABLE data_t2(a, b, rbu_control);\n    CREATE TABLE data_t3(a, b, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 't1', 0);\n    INSERT INTO data_t2 VALUES(2, 't2', 0);\n    INSERT INTO data_t3 VALUES(3, 't3', 0);\n  }\n  rbu close\n}\n\n# Test the outcome of some other client writing the db while the *-oal \n# file is being generated. Once this has happened, the update cannot be\n# progressed.\n#\nfor {set nStep 1} {$nStep < 8} {incr nStep} {\n  do_test 1.$nStep.1 {\n    setup_test\n    sqlite3rbu rbu test.db rbu.db\n    for {set i 0} {$i<$nStep} {incr i} {rbu step}\n\n    rbu close\n    sqlite3 db test.db\n    execsql { INSERT INTO t1 VALUES(5, 'hello') }\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_BUSY}\n  do_test 1.$nStep.2 {\n    rbu step\n  } {SQLITE_BUSY}\n  do_test 1.$nStep.3 {\n    list [file exists test.db-oal] [file exists test.db-wal]\n  } {1 0}\n  do_test 1.$nStep.4 {\n    list [catch { rbu close } msg] $msg\n  } {1 {SQLITE_BUSY - database modified during rbu update}}\n}\n\n# Test the outcome of some other client writing the db after the *-oal\n# file has been copied to the *-wal path. Once this has happened, any\n# other client writing to the db causes RBU to consider its job finished.\n#\nfor {set nStep 8} {$nStep < 20} {incr nStep} {\n  do_test 1.$nStep.1 {\n    setup_test\n    sqlite3rbu rbu test.db rbu.db\n    for {set i 0} {$i<$nStep} {incr i} {rbu step}\n    rbu close\n    sqlite3 db test.db\n    execsql { INSERT INTO t1 VALUES(5, 'hello') }\n    sqlite3rbu rbu test.db rbu.db\n    rbu step\n  } {SQLITE_DONE}\n  do_test 1.$nStep.2 {\n    rbu step\n  } {SQLITE_DONE}\n  do_test 1.$nStep.3 {\n    file exists test.db-oal\n  } {0}\n  do_test 1.$nStep.4 {\n    list [catch { rbu close } msg] $msg\n  } {0 SQLITE_DONE}\n\n  do_execsql_test 1.$nStep.5 {\n    SELECT * FROM t1;\n  } {1 t1 5 hello}\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu7.test",
    "content": "# 2014 October 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module.\n#\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu7\n\n# Test index:\n#\n#   1.*: That affinities are correctly applied to values within the \n#        RBU database.\n#\n#   2.*: Tests for multi-column primary keys.\n#\n\ndo_test 1.0 {\n  execsql {\n    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;\n    INSERT INTO t1 VALUES(1, 'abc');\n    INSERT INTO t1 VALUES(2, 'def');\n  }\n\n  forcedelete rbu.db\n  sqlite3 rbu rbu.db\n  rbu eval {\n    CREATE TABLE data_t1(a, b, rbu_control);\n    INSERT INTO data_t1 VALUES('1', NULL, 1);\n  }\n  rbu close\n} {}\n\ndo_test 1.1 {\n  sqlite3rbu rbu test.db rbu.db\n  while { [rbu step]==\"SQLITE_OK\" } {}\n  rbu close\n} {SQLITE_DONE}\n\nsqlite3 db test.db\ndo_execsql_test 1.2 {\n  SELECT * FROM t1\n} {2 def}\n\n#-------------------------------------------------------------------------\n#\nforeach {tn tbl} {\n  1 { CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID }\n  2 { CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b)) }\n} {\n  reset_db\n\n  execsql $tbl\n  do_execsql_test 2.$tn.1 {\n    CREATE INDEX t1c ON t1(c);\n    INSERT INTO t1 VALUES(1, 1, 'a');\n    INSERT INTO t1 VALUES(1, 2, 'b');\n    INSERT INTO t1 VALUES(2, 1, 'c');\n    INSERT INTO t1 VALUES(2, 2, 'd');\n  }\n\n  do_test 2.$tn.2 {\n    forcedelete rbu.db\n    sqlite3 rbu rbu.db\n    execsql {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(3, 1, 'e', 0);\n      INSERT INTO data_t1 VALUES(3, 2, 'f', 0);\n      INSERT INTO data_t1 VALUES(1, 2, NULL, 1);\n      INSERT INTO data_t1 VALUES(2, 1, 'X', '..x');\n    } rbu\n    rbu close\n  } {}\n\n  do_test 2.$tn.3 {\n    set rc \"SQLITE_OK\"\n    while {$rc == \"SQLITE_OK\"} {\n      sqlite3rbu rbu test.db rbu.db\n      rbu step\n      set rc [rbu close]\n    } \n    set rc\n  } {SQLITE_DONE}\n\n  do_execsql_test 2.$tn.1 {\n    SELECT * FROM t1 ORDER BY a, b\n  } {\n    1 1 a\n    2 1 X\n    2 2 d\n    3 1 e\n    3 2 f\n  }\n}\n\nfinish_test\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu8.test",
    "content": "# 2014 November 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the rbu_delta() feature.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu8\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y PRIMARY KEY, z);\n  INSERT INTO t1 VALUES(NULL, 1, 'one');\n  INSERT INTO t1 VALUES(NULL, 2, 'two');\n  INSERT INTO t1 VALUES(NULL, 3, 'three');\n  CREATE INDEX i1z ON t1(z, x);\n}\n\ndo_test 1.1 {\n  forcedelete rbu.db\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_t1(x, y, z, rbu_control);\n    INSERT INTO data_t1 VALUES('a',    1, '_i'      , 'x.d');\n    INSERT INTO data_t1 VALUES('b',    2, 2         , '..x');\n    INSERT INTO data_t1 VALUES('_iii', 3, '-III'    , 'd.d');\n  }\n  db2 close\n} {}\n\ndo_test 1.2.1 {\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_ERROR}\ndo_test 1.2.2 {\n  list [catch {rbu close} msg] $msg\n} {1 {SQLITE_ERROR - no such function: rbu_delta}}\n\nproc rbu_delta {orig new} {\n return \"${orig}${new}\"\n}\n\ndo_test 1.3.1 {\n  while 1 {\n    sqlite3rbu rbu test.db rbu.db\n    rbu create_rbu_delta\n    set rc [rbu step]\n    if {$rc != \"SQLITE_OK\"} break\n    rbu close\n  }\n  rbu close\n} {SQLITE_DONE}\n\ndo_execsql_test 1.3.2 {\n  SELECT * FROM t1\n} {\n  a    1 one_i\n  {}   2 2\n  _iii 3 three-III\n}\nintegrity_check 1.3.3\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu9.test",
    "content": "# 2014 November 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test RBU with virtual tables. And tables with no PRIMARY KEY declarations.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbu9\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE f1 USING fts4(a, b, c);\n  INSERT INTO f1(rowid, a, b, c) VALUES(11, 'a', 'b', 'c');\n  INSERT INTO f1(rowid, a, b, c) VALUES(12, 'd', 'e', 'f');\n  INSERT INTO f1(rowid, a, b, c) VALUES(13, 'g', 'h', 'i');\n}\n\ndo_test 1.1 {\n  forcedelete rbu.db\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_f1(rbu_rowid, a, b, c, rbu_control);\n    INSERT INTO data_f1 VALUES(14, 'x', 'y', 'z', 0);         -- INSERT\n    INSERT INTO data_f1 VALUES(11, NULL, NULL, NULL, 1);      -- DELETE\n    INSERT INTO data_f1 VALUES(13, NULL, NULL, 'X', '..x');   -- UPDATE\n  }\n  db2 close\n} {}\n\ndo_test 1.2.1 {\n  while 1 {\n    sqlite3rbu rbu test.db rbu.db\n    set rc [rbu step]\n    if {$rc != \"SQLITE_OK\"} break\n    rbu close\n  }\n  rbu close\n} {SQLITE_DONE}\n\ndo_execsql_test 1.2.2 { SELECT rowid, * FROM f1 } { \n  12 d e f\n  13 g h X\n  14 x y z\n}\ndo_execsql_test 1.2.3 { INSERT INTO f1(f1) VALUES('integrity-check') }\nintegrity_check 1.2.4\n\n#-------------------------------------------------------------------------\n# Tables with no PK declaration.\n#\n\n# Run the RBU in file $rbu on target database $target until completion.\n#\nproc run_rbu {target rbu} {\n  sqlite3rbu rbu $target $rbu\n  while { [rbu step]==\"SQLITE_OK\" } {}\n  rbu close\n}\n\nforeach {tn idx} {\n  1 { }\n  2 { \n    CREATE INDEX i1 ON t1(a);\n  }\n  3 { \n    CREATE INDEX i1 ON t1(b, c);\n    CREATE INDEX i2 ON t1(c, b);\n    CREATE INDEX i3 ON t1(a, a, a, b, b, b, c, c, c);\n  }\n} {\n\n  reset_db\n  do_execsql_test 2.$tn.1 {\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t1(rowid, a, b, c) VALUES(-1, 'a', 'b', 'c');\n    INSERT INTO t1(rowid, a, b, c) VALUES(-2, 'd', 'e', 'f');\n  }\n\n  db eval $idx\n  \n  do_test 2.$tn.2 {\n    forcedelete rbu.db\n    sqlite3 db2 rbu.db\n    db2 eval {\n      CREATE TABLE data_t1(rbu_rowid, a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(3, 'x', 'y', 'z', 0);\n      INSERT INTO data_t1 VALUES(NULL, 'X', 'Y', 'Z', 0);\n      INSERT INTO data_t1 VALUES('1', NULL, NULL, NULL, 1);\n      INSERT INTO data_t1 VALUES(-2, NULL, NULL, 'fff', '..x');\n    }\n    db2 close\n  } {}\n  \n  run_rbu test.db rbu.db\n  \n  do_execsql_test 2.$tn.3 {\n    SELECT rowid, a, b, c FROM t1 ORDER BY rowid;\n  } {\n    -2 d e fff\n    -1 a b c\n     2 4 5 6\n     3 x y z\n     4 X Y Z\n  }\n  \n  integrity_check 2.$tn.4\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuA.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module. More specifically, it\n# contains tests to ensure that it is an error to attempt to update\n# a wal mode database via RBU.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbuA\n\nset db_sql {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n}\nset rbu_sql {\n  CREATE TABLE data_t1(a, b, c, rbu_control);\n  INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n  INSERT INTO data_t1 VALUES(4, 5, 6, 0);\n  INSERT INTO data_t1 VALUES(7, 8, 9, 0);\n}\n\ndo_test 1.0 {\n  db close\n  forcedelete test.db rbu.db\n\n  sqlite3 db test.db\n  db eval $db_sql\n  db eval { PRAGMA journal_mode = wal }\n  db close\n\n  sqlite3 db rbu.db\n  db eval $rbu_sql\n  db close\n\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_ERROR}\ndo_test 1.1 {\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - cannot update wal mode database}}\n\ndo_test 2.0 {\n  forcedelete test.db rbu.db\n\n  sqlite3 db test.db\n  db eval $db_sql\n  db close\n\n  sqlite3 db rbu.db\n  db eval $rbu_sql\n  db close\n\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n  rbu close\n} {SQLITE_OK}\n\ndo_test 2.1 {\n  sqlite3 db test.db\n  db eval {PRAGMA journal_mode = wal}\n  db close\n  sqlite3rbu rbu test.db rbu.db\n  rbu step\n} {SQLITE_ERROR}\n\ndo_test 2.2 {\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - cannot update wal mode database}}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuB.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbuB\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log xLog\nreset_db\n\nproc xLog {args} { }\n\nset db_sql {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n}\nset rbu_sql {\n  CREATE TABLE data_t1(a, b, c, rbu_control);\n  INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n  INSERT INTO data_t1 VALUES(4, 5, 6, 0);\n  INSERT INTO data_t1 VALUES(7, 8, 9, 0);\n}\n\ndo_test 1.1 {\n  forcedelete rbu.db\n  sqlite3 rbu rbu.db\n  rbu eval $rbu_sql\n  rbu close\n\n  db eval $db_sql\n} {}\n\nset ::errlog [list]\nproc xLog {err msg} { lappend ::errlog $err }\ndo_test 1.2 {\n  run_rbu test.db rbu.db\n} {SQLITE_DONE}\n\ndo_test 1.3 {\n  set ::errlog\n} {SQLITE_NOTICE_RECOVER_WAL SQLITE_INTERNAL}\n\ndo_execsql_test 1.4 {\n  SELECT * FROM t1\n} {1 2 3 4 5 6 7 8 9}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log \nsqlite3_initialize\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuC.test",
    "content": "# 2016 March 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Tests for RBU focused on the REPLACE operation (rbu_control column\n# contains integer value 2).\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbuC\n\n#-------------------------------------------------------------------------\n# This test is actually of an UPDATE directive. Just to establish that\n# these work with UNIQUE indexes before preceding to REPLACE.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b, c UNIQUE);\n  INSERT INTO t1 VALUES(1, 'a', 'b', 'c');\n}\n\nforcedelete rbu.db\ndo_execsql_test 1.1 {\n  ATTACH 'rbu.db' AS rbu;\n  CREATE TABLE rbu.data_t1(i, a, b, c, rbu_control);\n  INSERT INTO data_t1 VALUES(1, 'a', 'b', 'c', '.xxx');\n}\n\ndo_test 1.2 {\n  step_rbu test.db rbu.db\n} {SQLITE_DONE}\n\ndo_execsql_test 1.3 {\n  SELECT * FROM t1\n} {\n  1 a b c\n}\n\n#-------------------------------------------------------------------------\n#\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b, c UNIQUE);\n    CREATE INDEX t1a ON t1(a);\n  }\n  2 {\n    CREATE TABLE t1(i PRIMARY KEY, a, b, c UNIQUE);\n    CREATE INDEX t1a ON t1(a);\n  }\n  3 {\n    CREATE TABLE t1(i PRIMARY KEY, a, b, c UNIQUE) WITHOUT ROWID;\n    CREATE INDEX t1a ON t1(a);\n  }\n} {\n  reset_db\n  forcedelete rbu.db\n  execsql $schema\n\n  do_execsql_test 2.$tn.0 {\n    INSERT INTO t1 VALUES(1, 'a', 'b', 'c');\n    INSERT INTO t1 VALUES(2, 'b', 'c', 'd');\n    INSERT INTO t1 VALUES(3, 'c', 'd', 'e');\n  }\n  \n  do_execsql_test 2.$tn.1 {\n    ATTACH 'rbu.db' AS rbu;\n    CREATE TABLE rbu.data_t1(i, a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 1, 2, 3, 2);\n    INSERT INTO data_t1 VALUES(3, 'c', 'd', 'e', 2);\n    INSERT INTO data_t1 VALUES(4, 'd', 'e', 'f', 2);\n  }\n  \n  do_test 2.$tn.2 {\n    step_rbu test.db rbu.db\n  } {SQLITE_DONE}\n  \n  do_execsql_test 2.$tn.3 {\n    SELECT * FROM t1 ORDER BY i\n  } {\n    1 1 2 3\n    2 b c d\n    3 c d e\n    4 d e f\n  }\n  \n  integrity_check 2.$tn.4\n}\n\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t1(a, b, c UNIQUE);\n    CREATE INDEX t1a ON t1(a);\n  }\n\n  2 {\n    CREATE VIRTUAL TABLE t1 USING fts5(a, b, c);\n  }\n} {\n  if {$tn==2} { ifcapable !fts5 break }\n  reset_db\n  forcedelete rbu.db\n  execsql $schema\n\n  do_execsql_test 3.$tn.0 {\n    INSERT INTO t1 VALUES('a', 'b', 'c');\n    INSERT INTO t1 VALUES('b', 'c', 'd');\n    INSERT INTO t1 VALUES('c', 'd', 'e');\n  }\n  \n  do_execsql_test 3.$tn.1 {\n    ATTACH 'rbu.db' AS rbu;\n    CREATE TABLE rbu.data_t1(rbu_rowid, a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 1, 2, 3, 2);\n    INSERT INTO data_t1 VALUES(3, 'c', 'd', 'e', 2);\n    INSERT INTO data_t1 VALUES(4, 'd', 'e', 'f', 2);\n  }\n  \n  do_test 3.$tn.2 {\n    step_rbu test.db rbu.db\n  } {SQLITE_DONE}\n  \n  do_execsql_test 3.$tn.3 {\n    SELECT rowid, * FROM t1 ORDER BY 1\n  } {\n    1 1 2 3\n    2 b c d\n    3 c d e\n    4 d e f\n  }\n  \n  integrity_check 3.$tn.4\n}\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbu_common.tcl",
    "content": "# 2015 Aug 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\n\nproc check_prestep_state {target state} {\n  set oal_exists [file exists $target-oal]\n  set wal_exists [file exists $target-wal]\n  set progress [rbu progress]\n\n  if {($progress==0 && $state!=\"oal\" && $state!=\"done\")\n   || ($oal_exists && $wal_exists)\n   || ($progress>0 && $state==\"oal\" && (!$oal_exists || $wal_exists))\n   || ($state==\"move\" && (!$oal_exists || $wal_exists))\n   || ($state==\"checkpoint\" && ($oal_exists || !$wal_exists))\n   || ($state==\"done\" && ($oal_exists && $progress!=0))\n  } {\n    error \"B: state=$state progress=$progress oal=$oal_exists wal=$wal_exists\"\n  }\n}\n\nproc check_poststep_state {rc target state} {\n  if {$rc==\"SQLITE_OK\" || $rc==\"SQLITE_DONE\"} {\n    set oal_exists [file exists $target-oal]\n    set wal_exists [file exists $target-wal]\n    if {$state==\"move\" && ($oal_exists || !$wal_exists)} {\n      error \"A: state=$state progress=$progress oal=$oal_exists wal=$wal_exists\"\n    }\n  }\n}\n\n# Run the RBU in file $rbu on target database $target until completion.\n#\nproc run_rbu {target rbu} {\n  sqlite3rbu rbu $target $rbu\n  while 1 {\n    set state [rbu state]\n\n    check_prestep_state $target $state\n    set rc [rbu step]\n    check_poststep_state $rc $target $state\n\n    if {$rc!=\"SQLITE_OK\"} break\n  }\n  rbu close\n}\n\nproc step_rbu {target rbu} {\n  while 1 {\n    sqlite3rbu rbu $target $rbu\n    set state [rbu state]\n    check_prestep_state $target $state\n    set rc [rbu step]\n    check_poststep_state $rc $target $state\n    rbu close\n    if {$rc != \"SQLITE_OK\"} break\n  }\n  set rc\n}\n\nproc do_rbu_vacuum_test {tn step} {\n  uplevel [list do_test $tn.1 {\n    if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db }\n    while 1 {\n      if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db }\n      set state [rbu state]\n      check_prestep_state test.db $state\n      set rc [rbu step]\n      check_poststep_state $rc test.db $state\n      if {$rc!=\"SQLITE_OK\"} break\n      if {$step==1} { rbu close }\n    }\n    rbu close\n  } {SQLITE_DONE}]\n\n  uplevel [list do_execsql_test $tn.2 {\n    PRAGMA integrity_check\n  } ok]\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbucrash.test",
    "content": "# 2014 October 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbucrash\n\ndb close\nforcedelete test.db-oal rbu.db\nsqlite3_shutdown\nsqlite3_config_uri 1\nreset_db\n\n# Set up a target database and an rbu update database. The target\n# db is the usual \"test.db\", the rbu db is \"test.db2\".\n#\nforcedelete test.db2\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a), UNIQUE(b));\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  INSERT INTO t1 VALUES(7, 8, 9);\n\n  ATTACH 'test.db2' AS rbu;\n  CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n  INSERT INTO data_t1 VALUES(10, 11, 12, 0);\n  INSERT INTO data_t1 VALUES(13, 14, 15, 0);\n  INSERT INTO data_t1 VALUES(4, NULL, NULL, 1);\n  INSERT INTO data_t1 VALUES(1, NULL, 100, '..x');\n}\ndb_save_and_close\n\n\n# Determine the number of steps in applying the rbu update to the test\n# target database created above. Set $::rbu_num_steps accordingly\n#\n# Check that the same number of steps are required to apply the rbu\n# update using many calls to sqlite3rbu_step() on a single rbu handle\n# as required to apply it using a series of rbu handles, on each of \n# which sqlite3rbu_step() is called once.\n#\ndo_test 1.1 {\n  db_restore\n  sqlite3rbu rbu test.db test.db2\n  set nStep 0\n  while {[rbu step]==\"SQLITE_OK\"} { incr nStep }\n  rbu close\n} {SQLITE_DONE}\nset rbu_num_steps $nStep\ndo_test 1.2 {\n  db_restore\n  set nStep 0\n  while {1} {\n    sqlite3rbu rbu test.db test.db2\n    rbu step\n    if {[rbu close]==\"SQLITE_DONE\"} break\n    incr nStep\n  }\n  set nStep\n} $rbu_num_steps\n\n\n# Run one or more tests using the target (test.db) and rbu (test.db2)\n# databases created above. As follows:\n#\n#   1. This process starts the rbu update and calls sqlite3rbu_step()\n#      $nPre times. Then closes the rbu update handle.\n#\n#   2. A second process resumes the rbu update and attempts to call \n#      sqlite3rbu_step() $nStep times before closing the handle. A\n#      crash is simulated during each xSync() of file test.db2.\n#\n#   3. This process attempts to resume the rbu update from whatever\n#      state it was left in by step (2). Test that it is successful\n#      in doing so and that the final target database is as expected.\n#\n# In total (nSync+1) tests are run, where nSync is the number of times\n# xSync() is called on test.db2.\n#\nproc do_rbu_crash_test {tn nPre nStep} {\n\n  set script [subst -nocommands {\n    sqlite3rbu rbu test.db file:test.db2?vfs=crash\n    set i 0\n    while {[set i] < $nStep} {\n      if {[rbu step]!=\"SQLITE_OK\"} break\n      incr i\n    }\n    rbu close\n  }]\n\n  set bDone 0\n  for {set iDelay 1} {$bDone==0} {incr iDelay} {\n    forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal\n    db_restore\n\n    if {$nPre>0} {\n      sqlite3rbu rbu test.db file:test.db2\n      set i 0\n      for {set i 0} {$i < $nPre} {incr i} { \n        if {[rbu step]!=\"SQLITE_OK\"} break\n      }\n      rbu close\n    }\n\n    set res [\n      crashsql -file test.db2 -delay $iDelay -tclbody $script -opendb {} {}\n    ]\n\n    set bDone 1\n    if {$res == \"1 {child process exited abnormally}\"} {\n      set bDone 0\n    } elseif {$res != \"0 {}\"} {\n      error \"unexected catchsql result: $res\"\n    }\n\n    sqlite3rbu rbu test.db test.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n\n    sqlite3 db test.db\n    do_execsql_test $tn.delay=$iDelay {\n      SELECT * FROM t1;\n      PRAGMA integrity_check;\n    } {1 2 100  7 8 9  10 11 12  13 14 15  ok}\n    db close\n  }\n}\n\nfor {set nPre 0} {$nPre < $rbu_num_steps} {incr nPre} {\n  for {set is 1} {$is <= ($rbu_num_steps - $nPre)} {incr is} {\n    do_rbu_crash_test 2.pre=$nPre.step=$is $nPre $is\n  }\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbucrash2.test",
    "content": "# 2017 March 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbucrash2\n\ndb close\nforcedelete test.db-oal rbu.db\nsqlite3_shutdown\nsqlite3_config_uri 1\nreset_db\n\n# Set up a target database and an rbu update database. The target\n# db is the usual \"test.db\", the rbu db is \"test.db2\".\n#\nforcedelete test.db2\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a), UNIQUE(b));\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  INSERT INTO t1 VALUES(7, 8, 9);\n\n  ATTACH 'test.db2' AS rbu;\n  CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n  INSERT INTO data_t1 VALUES('one', randomblob(3500), NULL, 0);\n  INSERT INTO data_t1 VALUES('two', randomblob(3500), NULL, 0);\n  INSERT INTO data_t1 VALUES('three', randomblob(3500), NULL, 0);\n  INSERT INTO data_t1 VALUES('four', randomblob(3500), NULL, 0);\n  INSERT INTO data_t1 VALUES('five', randomblob(3500), NULL, 0);\n  INSERT INTO data_t1 VALUES('six', randomblob(3500), NULL, 0);\n}\ndb_save_and_close\n\nproc do_rbu_crash_test2 {tn script} {\n\n  foreach {f blksz} {\n    test.db   512\n    test.db2  512\n    test.db   4096\n    test.db2  4096\n  } {\n    set bDone 0\n    for {set iDelay 1} {$bDone==0} {incr iDelay} {\n      forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal\n      db_restore\n  \n      set res [\n        crashsql -file $f -delay $iDelay -tclbody $script -dflt 1 -opendb {} \\\n            -blocksize $blksz {}\n      ]\n  \n      set bDone 1\n      if {$res == \"1 {child process exited abnormally}\"} {\n        set bDone 0\n      } elseif {$res != \"0 {}\"} {\n        error \"unexected catchsql result: $res\"\n      }\n  \n      sqlite3rbu rbu test.db test.db2\n      while {[rbu step]==\"SQLITE_OK\"} {}\n      rbu close\n  \n      sqlite3 db test.db\n      do_execsql_test $tn.delay=$iDelay.f=$f.blksz=$blksz {\n        PRAGMA integrity_check;\n      } {ok}\n      db close\n    }\n  }\n}\n\nfor {set x 1} {$x < 10} {incr x} {\n  do_rbu_crash_test2 1.$x {\n    sqlite3rbu rbu test.db test.db2\n    while {[rbu step]==\"SQLITE_OK\"} {\n      rbu savestate\n    }\n    rbu close\n  }\n}\n\nfor {set x 1} {$x < 2} {incr x} {\n  do_rbu_crash_test2 2.$x {\n    sqlite3rbu rbu test.db test.db2\n    while {[rbu step]==\"SQLITE_OK\"} {\n      rbu close\n      sqlite3rbu rbu test.db test.db2\n    }\n    rbu close\n  }\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbudiff.test",
    "content": "# 2015-07-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the [sqldiff --rbu] command.\n#\n#\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset testprefix rbudiff\n\nset PROG [test_find_sqldiff]\ndb close\n\nproc get_rbudiff_sql {db1 db2} {\n  exec $::PROG --rbu $db1 $db2\n}\n\nproc get_vtab_rbudiff_sql {db1 db2} {\n  exec $::PROG --vtab --rbu $db1 $db2\n}\n\nproc step_rbu {target rbu} {\n  while 1 {\n    sqlite3rbu rbu $target $rbu\n    set rc [rbu step]\n    rbu close\n    if {$rc != \"SQLITE_OK\"} break\n  }\n  set rc\n}\n\nproc apply_rbudiff {sql target} {\n  test_rbucount $sql\n  forcedelete rbu.db\n  sqlite3 rbudb rbu.db\n  rbudb eval $sql\n  rbudb close\n  step_rbu $target rbu.db\n}\n\nproc sqlesc {id} {\n  set ret \"'[string map {' ''} $id]'\"\n  set ret\n}\n\n# The only argument is the output of an [sqldiff -rbu] run. This command\n# tests that the contents of the rbu_count table is correct. An exception\n# is thrown if it is not.\n#\nproc test_rbucount {sql} {\n  sqlite3 tmpdb \"\"\n  tmpdb eval $sql\n  tmpdb eval {\n    SELECT name FROM sqlite_master WHERE name LIKE 'data%' AND type='table'\n  } {\n    set a [tmpdb eval \"SELECT count(*) FROM [sqlesc $name]\"]\n    set b [tmpdb eval {SELECT cnt FROM rbu_count WHERE tbl = $name}]\n    if {$a != $b} { \n      tmpdb close\n      error \"rbu_count error - tbl = $name\" \n    }\n  }\n  tmpdb close\n  return \"\"\n}\n\nproc rbudiff_cksum {db1} {\n  set txt \"\"\n\n  sqlite3 dbtmp $db1\n  foreach tbl [dbtmp eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n    set cols [list]\n    dbtmp eval \"PRAGMA table_info = [sqlesc $tbl]\" { \n      lappend cols \"quote( $name )\" \n    }\n    append txt [dbtmp eval \\\n      \"SELECT [join $cols {||'.'||}] FROM [sqlesc $tbl] ORDER BY 1\"\n    ]\n  }\n  dbtmp close\n\n  md5 $txt\n}\n\nforeach {tn init mod} {\n  1 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n  \n    CREATE TABLE t2(a, b, c, PRIMARY KEY(b, c));\n    INSERT INTO t2 VALUES(1, 2, 3);\n    INSERT INTO t2 VALUES(4, 5, 6);\n  } {\n    INSERT INTO t1 VALUES(7, 8, 9);\n    DELETE FROM t1 WHERE a=4;\n    UPDATE t1 SET c = 11 WHERE a = 1;\n  \n    INSERT INTO t2 VALUES(7, 8, 9);\n    DELETE FROM t2 WHERE a=4;\n    UPDATE t2 SET c = 11 WHERE a = 1;\n  }\n\n  2 {\n    CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b, c));\n    INSERT INTO t1 VALUES('u', 'v', 'w');\n    INSERT INTO t1 VALUES('x', 'y', 'z');\n  } {\n    DELETE FROM t1 WHERE a='u';\n    INSERT INTO t1 VALUES('a', 'b', 'c');\n  }\n\n  3 {\n    CREATE TABLE t1(i INTEGER PRIMARY KEY, x);\n    INSERT INTO t1 VALUES(1,\n      X'0000000000000000111111111111111122222222222222223333333333333333'\n    );\n    CREATE TABLE t2(y INTEGER PRIMARY KEY, x);\n    INSERT INTO t2 VALUES(1,\n        X'0000000000000000111111111111111122222222222222223333333333333333'\n    );\n  } {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,\n      X'0000000000000000111111111111111122222555555552223333333333333333'\n    );\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(1,\n        X'0000000000000000111111111111111122222222222222223333333FFF333333'\n    );\n  }\n\n  4 {\n    CREATE TABLE x1(a, b, c, PRIMARY KEY(a, b, c));\n    INSERT INTO x1 VALUES('u', 'v', NULL);\n    INSERT INTO x1 VALUES('x', 'y', 'z');\n    INSERT INTO x1 VALUES('a', NULL, 'b');\n  } {\n    INSERT INTO x1 VALUES('a', 'b', 'c');\n  }\n\n  5 {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, NULL);\n    INSERT INTO t1 VALUES(2, X'');\n  } {\n    UPDATE t1 SET b = X'' WHERE a=1;\n    UPDATE t1 SET b = NULL WHERE a=2;\n  }\n\n} {\n  catch { db close }\n\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  db eval \"$init\"\n  sqlite3 db test.db2\n  db eval \"$init ; $mod\"\n  db close\n\n  do_test 1.$tn.2 {\n    set sql [get_rbudiff_sql test.db test.db2]\n    apply_rbudiff $sql test.db\n  } {SQLITE_DONE}\n  do_test 1.$tn.3 { rbudiff_cksum test.db } [rbudiff_cksum test.db2]\n\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  db eval \"$init ; $mod\"\n  sqlite3 db test.db2\n  db eval \"$init\"\n  db close\n\n  do_test 1.$tn.4 {\n    set sql [get_rbudiff_sql test.db test.db2]\n    apply_rbudiff $sql test.db\n  } {SQLITE_DONE}\n  do_test 1.$tn.5 { rbudiff_cksum test.db } [rbudiff_cksum test.db2]\n}\n\n#-------------------------------------------------------------------------\n# Test that if the --vtab switch is present, [sqldiff] handles virtual\n# table types fts[345] and rtree correctly.\n#\nifcapable fts3&&fts5&&rtree {\n\nforeach {tn init mod} {\n  1 {\n    CREATE VIRTUAL TABLE t1 USING fts5(c);\n    INSERT INTO t1 VALUES('a b c');\n    INSERT INTO t1 VALUES('a b c');\n  } {\n    DELETE FROM t1 WHERE rowid = 1;\n    INSERT INTO t1 VALUES('a b c');\n  }\n\n  2 {\n    CREATE VIRTUAL TABLE \"x y\" USING 'rtree'(id, x1, x2);\n    INSERT INTO \"x y\" VALUES(1, 2, 3);\n    INSERT INTO \"x y\" VALUES(2, 4, 6);\n  } {\n    DELETE FROM \"x y\" WHERE rowid = 1;\n    INSERT INTO \"x y\" VALUES(3, 6, 9);\n  }\n\n  3 {\n    CREATE VIRTUAL TABLE 'x''y' USING fts3;\n    INSERT INTO 'x''y' VALUES('one two three');\n    INSERT INTO 'x''y' VALUES('four five six');\n  } {\n    DELETE FROM 'x''y' WHERE rowid = 1;\n    INSERT INTO 'x''y' VALUES('one two three');\n  }\n} {\n\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  db eval \"$init\"\n  sqlite3 db test.db2\n  db eval \"$init ; $mod\"\n  db close\n\n  do_test 2.$tn.1 {\n    set sql [get_vtab_rbudiff_sql test.db test.db2]\n    apply_rbudiff $sql test.db\n  } {SQLITE_DONE}\n  do_test 2.$tn.2 { rbudiff_cksum test.db } [rbudiff_cksum test.db2]\n}\n\n}\n\nifcapable fts5 {\n  foreach {tn init mod} {\n    1 {\n      CREATE VIRTUAL TABLE t1 USING fts5(c);\n      INSERT INTO t1 VALUES('a b c');\n      INSERT INTO t1 VALUES('a b c');\n    } {\n      DELETE FROM t1 WHERE rowid = 1;\n      INSERT INTO t1 VALUES('a b c');\n    }\n\n    2 {\n      CREATE VIRTUAL TABLE t1 USING FTs5(c);\n      INSERT INTO t1 VALUES('a b c');\n      INSERT INTO t1 VALUES('a b c');\n    } {\n      DELETE FROM t1 WHERE rowid = 1;\n      INSERT INTO t1 VALUES('a b c');\n    }\n\n    3 {\n      creAte    virTUal\ntablE t1 USING FTs5(c);\n      INSERT INTO t1 VALUES('a b c');\n      INSERT INTO t1 VALUES('a b c');\n    } {\n      DELETE FROM t1 WHERE rowid = 1;\n      INSERT INTO t1 VALUES('a b c');\n    }\n\n  } {\n    forcedelete test.db test.db2\n    sqlite3 db test.db\n    db eval \"$init\"\n    sqlite3 db test.db2\n    db eval \"$init ; $mod\"\n    db eval { INSERT INTO t1(t1) VALUES('optimize') }\n    db close\n\n    do_test 3.$tn.1 {\n      set sql [get_vtab_rbudiff_sql test.db test.db2]\n      apply_rbudiff $sql test.db\n    } {SQLITE_DONE}\n\n    sqlite3 db test.db\n    sqlite3 db2 test.db2\n    do_test 3.$tn.2 { \n      db2 eval { SELECT * FROM t1 ORDER BY rowid }\n    } [db eval { SELECT * FROM t1 ORDER BY rowid }]\n\n    do_test 3.$tn.3 { \n      db2 eval { INSERT INTO t1(t1) VALUES('integrity-check') }\n    } {}\n\n    db close\n    db2 close\n  }\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbudor.test",
    "content": "# 2016 October 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test file focuses on interactions between RBU and the feature\n# enabled by SQLITE_DIRECT_OVERFLOW_READ - Direct Overflow Read.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbudor\n\nset bigA [string repeat a 5000]\nset bigB [string repeat b 5000]\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);\n  INSERT INTO t1 VALUES(1, $bigA);\n} {}\n\ndo_test 1.1 {\n  forcedelete rbu.db\n  sqlite3 rbu rbu.db \n  rbu eval {\n    CREATE TABLE data_t1(a, b, rbu_control);\n    INSERT INTO data_t1 VALUES(2, $bigB, 0);\n  }\n  rbu close\n} {}\n\ndo_test 1.2 {\n  sqlite3rbu rbu test.db rbu.db\n  while {[rbu state]!=\"checkpoint\"} {\n    rbu step\n  }\n  rbu step\n  db eval { SELECT * FROM t1 }\n} [list 1 $bigA 2 $bigB]\n\ndo_test 1.3 {\n  while {[rbu step]==\"SQLITE_OK\"} {}\n  rbu close\n} {SQLITE_DONE}\n\ndo_execsql_test 1.4 {\n  SELECT * FROM t1 \n} [list 1 $bigA 2 $bigB]\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbufault.test",
    "content": "# 2014 October 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix rbufault\n\nproc copy_if_exists {src target} {\n  if {[file exists $src]} {\n    forcecopy $src $target\n  } else {\n    forcedelete $target\n  }\n}\n\nforeach {tn2 setup sql expect} {\n  1 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    CREATE INDEX t1cb ON t1(c, b);\n    INSERT INTO t1 VALUES(1, 1, 1);\n    INSERT INTO t1 VALUES(2, 2, 2);\n    INSERT INTO t1 VALUES(3, 3, 3);\n\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(2, NULL, NULL, 1);\n    INSERT INTO data_t1 VALUES(3, 'three', NULL, '.x.');\n    INSERT INTO data_t1 VALUES(4, 4, 4, 0);\n  } {\n    SELECT * FROM t1\n  } {1 1 1   3 three 3   4 4 4}\n\n  2 {\n    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE INDEX t2cb ON t2(c, b);\n    INSERT INTO t2 VALUES('a', 'a', 'a');\n    INSERT INTO t2 VALUES('b', 'b', 'b');\n    INSERT INTO t2 VALUES('c', 'c', 'c');\n\n    CREATE TABLE rbu.data_t2(a, b, c, rbu_control);\n    INSERT INTO data_t2 VALUES('b', NULL, NULL, 1);\n    INSERT INTO data_t2 VALUES('c', 'see', NULL, '.x.');\n    INSERT INTO data_t2 VALUES('d', 'd', 'd', 0);\n  } {\n    SELECT * FROM t2\n  } {a a a   c see c     d d d}\n\n  3 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE INDEX t1cb ON t1(c, b);\n    CREATE INDEX t2cb ON t2(c, b);\n\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n    CREATE TABLE rbu.data_t2(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n    INSERT INTO data_t2 VALUES(4, 5, 6, 0);\n  } {\n    SELECT * FROM t1 UNION ALL SELECT * FROM t2\n  } {1 2 3 4 5 6}\n\n  4 {\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    CREATE INDEX t1c ON t1(c);\n    INSERT INTO t1 VALUES('A', 'B', 'C');\n    INSERT INTO t1 VALUES('D', 'E', 'F');\n\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES('D', NULL, NULL, 1);\n    INSERT INTO data_t1 VALUES('A', 'Z', NULL, '.x.');\n    INSERT INTO data_t1 VALUES('G', 'H', 'I', 0);\n  } {\n    SELECT * FROM t1 ORDER BY a;\n  } {A Z C G H I}\n\n  5 {\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX t1c ON t1(c, b);\n\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_rowid, rbu_control);\n    INSERT INTO data_t1 VALUES('a', 'b', 'c', 1, 0);\n    INSERT INTO data_t1 VALUES('d', 'e', 'f', '2', 0);\n  } {\n    SELECT * FROM t1 ORDER BY a;\n  } {a b c d e f}\n\n} {\n  catch {db close}\n  forcedelete rbu.db test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = utf16;\n    ATTACH 'rbu.db' AS rbu;\n  }\n  execsql $setup\n  db close\n\n  forcecopy test.db test.db.bak\n  forcecopy rbu.db rbu.db.bak\n\n  foreach {tn f reslist} {\n    1 oom-tra*  {\n      {0 SQLITE_DONE} \n      {1 {SQLITE_NOMEM - out of memory}} \n      {1 SQLITE_NOMEM} \n      {1 SQLITE_IOERR_NOMEM} \n      {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}}\n    }\n  \n    2 ioerr-*  {\n      {0 SQLITE_DONE} \n      {1 {SQLITE_IOERR - disk I/O error}}\n      {1 SQLITE_IOERR}\n      {1 SQLITE_IOERR_WRITE}\n      {1 SQLITE_IOERR_READ}\n      {1 SQLITE_IOERR_FSYNC}\n      {1 {SQLITE_ERROR - SQL logic error}}\n      {1 {SQLITE_ERROR - unable to open database: rbu.db}}\n      {1 {SQLITE_IOERR - unable to open database: rbu.db}}\n    }\n\n    3 shmerr-*  {\n      {0 SQLITE_DONE} \n      {1 {SQLITE_IOERR - disk I/O error}}\n      {1 SQLITE_IOERR}\n    }\n  } {\n\n    catch {db close}\n    sqlite3_shutdown\n    set lookaside_config [sqlite3_config_lookaside 0 0]\n    sqlite3_initialize\n    autoinstall_test_functions\n\n    do_faultsim_test 2.$tn2 -faults $::f -prep {\n      catch { db close }\n      forcedelete test.db-journal test.db-wal rbu.db-journal rbu.db-wal\n      forcecopy test.db.bak test.db\n      forcecopy rbu.db.bak  rbu.db\n    } -body {\n      sqlite3rbu rbu test.db rbu.db\n      while {[rbu step]==\"SQLITE_OK\"} {}\n      rbu close\n    } -test {\n      faultsim_test_result {*}$::reslist\n      if {$testrc==0} {\n        sqlite3 db test.db\n        faultsim_integrity_check\n        set res [db eval $::sql]\n        if {$res != [list {*}$::expect]} {\n          puts \"\"\n          puts \"res: $res\"\n          puts \"exp: $expect\"\n          error \"data not as expected!\"\n        }\n      }\n    }\n\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_lookaside {*}$lookaside_config\n    sqlite3_initialize\n    autoinstall_test_functions\n\n\n    for {set iStep 0} {$iStep<=21} {incr iStep} {\n    \n      forcedelete test.db-journal test.db-wal rbu.db-journal rbu.db-wal\n    \n      copy_if_exists test.db.bak test.db\n      copy_if_exists rbu.db.bak rbu.db\n    \n      sqlite3rbu rbu test.db rbu.db\n      for {set x 0} {$x < $::iStep} {incr x} { rbu step }\n      rbu close\n  \n# sqlite3 x rbu.db ; puts \"XYZ [x eval { SELECT * FROM rbu_state } ]\" ; x close\n    \n      copy_if_exists test.db     test.db.bak.2\n      copy_if_exists test.db-wal test.db.bak.2-wal\n      copy_if_exists test.db-oal test.db.bak.2-oal\n      copy_if_exists rbu.db      rbu.db.bak.2\n    \n      do_faultsim_test 3.$tn.$iStep -faults $::f -prep {\n        catch { db close }\n        forcedelete test.db-journal test.db-wal rbu.db-journal rbu.db-wal\n        copy_if_exists test.db.bak.2 test.db\n        copy_if_exists test.db.bak.2-wal test.db-wal\n        copy_if_exists test.db.bak.2-oal test.db-oal\n        copy_if_exists rbu.db.bak.2  rbu.db\n      } -body {\n        sqlite3rbu rbu test.db rbu.db\n        rbu step\n        rbu close\n      } -test {\n\n        if {$testresult==\"SQLITE_OK\"} {set testresult \"SQLITE_DONE\"}\n        faultsim_test_result {*}$::reslist\n      \n        if {$testrc==0} {\n          # No error occurred. If the RBU has not already been fully applied,\n          # apply the rest of it now. Then ensure that the final state of the\n          # target db is as expected. And that \"PRAGMA integrity_check\"\n          # passes.\n          sqlite3rbu rbu test.db rbu.db\n          while {[rbu step] == \"SQLITE_OK\"} {}\n          rbu close\n\n          sqlite3 db test.db\n          faultsim_integrity_check\n\n          set res [db eval $::sql]\n          if {$res != [list {*}$::expect]} {\n            puts \"\"\n            puts \"res: $res\"\n            puts \"exp: $::expect\"\n            error \"data not as expected!\"\n          }\n        }\n      }\n    }\n  }\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbufault2.test",
    "content": "# 2014 October 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix rbufault2\n\nforcedelete rbu.db\ndo_execsql_test 1.0 {\n  CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));\n  INSERT INTO target VALUES(1, 2, 3);\n  INSERT INTO target VALUES(4, 5, 6);\n\n  ATTACH 'rbu.db' AS rbu;\n  CREATE TABLE rbu.data_target(x, y, z, rbu_control);\n  INSERT INTO data_target VALUES(7, 8, 9, 0);\n  INSERT INTO data_target VALUES(1, 11, 12, 0);\n  DETACH rbu;\n}\ndb close\n\nforcecopy test.db test.db-bak \nforcecopy rbu.db rbu.db-bak \n\ndo_faultsim_test 1 -faults oom* -prep {\n  forcecopy test.db-bak test.db\n  forcecopy rbu.db-bak rbu.db\n  forcedelete test.db-oal test.db-wal rbu.db-journal\n  sqlite3rbu rbu test.db rbu.db\n} -body {\n  while {[rbu step]==\"SQLITE_OK\"} { }\n  rbu close\n} -test {\n  faultsim_test_result      \\\n      {1 {SQLITE_CONSTRAINT - UNIQUE constraint failed: target.x}} \\\n      {1 SQLITE_CONSTRAINT} \\\n      {1 SQLITE_NOMEM} \\\n      {1 {SQLITE_NOMEM - unable to open a temporary database file for storing temporary tables}} \\\n      {1 {SQLITE_NOMEM - out of memory}} \n}\n\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbufault3.test",
    "content": "# 2016 April 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains fault injection tests for RBU vacuum operations.\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nsource $testdir/malloc_common.tcl\nset ::testprefix rbufault3\n\nforeach {fault errlist} {\n  oom-* {\n    {1 SQLITE_NOMEM}\n    {1 SQLITE_IOERR_NOMEM}\n    {1 {SQLITE_NOMEM - out of memory}}\n  }\n\n  ioerr-* {\n    {1 {SQLITE_IOERR - disk I/O error}}\n    {1 SQLITE_IOERR} \n    {1 SQLITE_IOERR_WRITE} \n    {1 SQLITE_IOERR_FSYNC} \n    {1 SQLITE_IOERR_READ} \n    {1 {SQLITE_IOERR - unable to open database: test.db2}} \n    {1 {SQLITE_ERROR - unable to open database: test.db2}} \n    {1 {SQLITE_ERROR - SQL logic error}}\n  }\n\n  cantopen* {\n    {1 {SQLITE_CANTOPEN - unable to open database: test.db2}}  \n    {1 {SQLITE_CANTOPEN - unable to open database: test.db2}}  \n    {1 {SQLITE_CANTOPEN - unable to open database file}}  \n    {1 SQLITE_CANTOPEN} \n  }\n\n} {\n\n  reset_db\n  do_execsql_test 0 {\n    CREATE TABLE target(x UNIQUE, y, z, PRIMARY KEY(y));\n    INSERT INTO target VALUES(1, 2, 3);\n    INSERT INTO target VALUES(4, 5, 6);\n    INSERT INTO target VALUES(7, 8, 9);\n    CREATE INDEX i1 ON target(z);\n  }\n  faultsim_save_and_close\n\n  do_faultsim_test 1 -faults $fault -prep {\n    faultsim_restore_and_reopen\n    forcedelete test.db2\n  } -body {\n    sqlite3rbu_vacuum rbu test.db test.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } -test {\n    eval [list faultsim_test_result {0 SQLITE_DONE} {*}$::errlist]\n  }\n\n  do_faultsim_test 2 -faults $fault -prep {\n    faultsim_restore_and_reopen\n    forcedelete test.db2\n  } -body {\n    sqlite3rbu_vacuum rbu test.db test.db2\n    rbu step\n    rbu close\n  } -test {\n    eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]\n  }\n\n  forcedelete test.db2\n  sqlite3rbu_vacuum rbu test.db test.db2\n  rbu step\n  rbu close\n  faultsim_save_and_close\n\n  do_faultsim_test 3 -faults $fault -prep {\n    faultsim_restore_and_reopen\n    forcedelete test.db2\n  } -body {\n    sqlite3rbu_vacuum rbu test.db test.db2\n    rbu step\n    rbu close\n  } -test {\n    eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist]\n  }\n\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbufault4.test",
    "content": "# 2014 October 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix rbufault4\n\nfor {set tn 1} {1} {incr tn} {\n  reset_db\n  do_execsql_test 1.0 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    CREATE INDEX i1b ON t1(b);\n    CREATE INDEX i1c ON t1(c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n\n  forcedelete test.db2\n  sqlite3rbu_vacuum rbu test.db test.db2\n  for {set i 0} {$i < $tn} {incr i} { rbu step }\n  set rc [rbu close]\n  if {$rc!=\"SQLITE_OK\"} { \n    if {$rc!=\"SQLITE_DONE\"} {error $rc}\n    break\n  }\n  faultsim_save\n\n  do_faultsim_test $tn -faults oom-t* -prep {\n    faultsim_restore\n  } -body {\n    sqlite3rbu_vacuum rbu test.db test.db2\n    while 1 {\n      set rc [rbu step]\n      if {$rc==\"SQLITE_DONE\"} break\n      if {$rc!=\"SQLITE_OK\"} { error $rc }\n    }\n  } -test {\n    catch {rbu close}\n    faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}\n\n    sqlite3rbu_vacuum rbu test.db test.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    set trc [rbu close]\n    if {$trc!=\"SQLITE_DONE\"} { error \"Got $trc instead of SQLITE_DONE!\" }\n\n    set rc [db one {PRAGMA integrity_check}]\n    if {$rc!=\"ok\"} { error \"Got $rc instead of ok!\" }\n  }\n}\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbufts.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module. More specifically, it\n# contains tests to ensure that RBU works with FTS tables.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbufts\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nproc step_rbu {target rbu} {\n  while 1 {\n    sqlite3rbu rbu $target $rbu\n    set rc [rbu step]\n    rbu close\n    if {$rc != \"SQLITE_OK\"} break\n  }\n  set rc\n}\n\nproc apply_rbu_update {target sql} {\n  forcedelete rbu.db\n  sqlite3 dbrbu rbu.db\n  execsql $sql dbrbu\n  dbrbu close\n\n  step_rbu $target rbu.db\n}\n\ndo_execsql_test 1.1.0 {\n  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);\n  CREATE VIRTUAL TABLE xx USING fts4(content=t1, a, b);\n  INSERT INTO t1(rowid, a, b) VALUES(10, 'a b c', 'c b a');\n  INSERT INTO t1(rowid, a, b) VALUES(20, 'a b c', 'd e f');\n  INSERT INTO t1(rowid, a, b) VALUES(30, 'd e f', 'a b c');\n  INSERT INTO t1(rowid, a, b) VALUES(40, 'd e f', 'd e f');\n}\n\ndo_execsql_test 1.1.1 {\n  INSERT INTO xx(xx) VALUES('rebuild');\n  INSERT INTO xx(xx) VALUES('integrity-check');\n}\n\ndo_test 1.1.2 {\n  apply_rbu_update test.db {\n    CREATE TABLE data_t1(i, a, b, rbu_control);\n    INSERT INTO data_t1 VALUES(20, NULL, NULL, 1);        -- delete\n    INSERT INTO data_t1 VALUES(30, 'x y z', NULL, '.x.'); -- update\n    INSERT INTO data_t1 VALUES(50, '1 2 3', 'x y z', 0);  -- insert\n\n    CREATE VIEW data0_xx AS \n    SELECT i AS rbu_rowid, a, b, \n    CASE WHEN rbu_control IN (0, 1) \n    THEN rbu_control ELSE substr(rbu_control, 2) END AS rbu_control\n    FROM data_t1;\n  }\n} {SQLITE_DONE}\n\ndo_execsql_test 1.1.3 {\n  INSERT INTO xx(xx) VALUES('integrity-check');\n}\n\nreset_db\ndo_execsql_test 1.2.1 {\n  CREATE TABLE ccc(addr, text);\n  CREATE VIRTUAL TABLE ccc_fts USING fts4(addr, text, content=ccc);\n  INSERT INTO ccc VALUES('a b c', 'd e f');\n  INSERT INTO ccc VALUES('a b c', 'd e f');\n  INSERT INTO ccc_fts(ccc_fts) VALUES('rebuild');\n  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');\n}\n\ndo_test 1.2.2 {\n  apply_rbu_update test.db {\n    CREATE TABLE data_ccc(addr, text, rbu_rowid, rbu_control);\n    CREATE VIEW data0_ccc_fts AS SELECT * FROM data_ccc;\n    INSERT INTO data_ccc VALUES(NULL, NULL, 1, 1);\n    INSERT INTO data_ccc VALUES('x y z', NULL, 2, 'x.');\n    INSERT INTO data_ccc VALUES('y y y', '1 1 1', 3, 0);\n  }\n} {SQLITE_DONE}\n\ndo_execsql_test 1.2.3 {\n  INSERT INTO ccc_fts(ccc_fts) VALUES('integrity-check');\n}\ndo_execsql_test 1.2.4 {\n  SELECT rowid, * FROM ccc_fts;\n} {2 {x y z} {d e f} 3 {y y y} {1 1 1}}\n\n#-------------------------------------------------------------------------\n# Test the outcome of attempting to delete or update a row within a \n# contentless FTS table using RBU. An error.\n#\nreset_db\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE ft USING fts4(x, content=);\n  INSERT INTO ft(rowid, x) VALUES(1, '1 2 3');\n  INSERT INTO ft(rowid, x) VALUES(2, '4 5 6');\n}\n\ndo_test 3.2 {\n  list [catch { apply_rbu_update test.db {\n    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);\n    INSERT INTO data_ft VALUES(NULL, 2, 1);\n  } } msg] $msg]\n} {1 {SQLITE_ERROR - SQL logic error]}}\n\ndo_test 3.3 {\n  list [catch { apply_rbu_update test.db {\n    CREATE TABLE data_ft(x, rbu_rowid, rbu_control);\n    INSERT INTO data_ft VALUES('7 8 9', 1, 'x');\n  } } msg] $msg]\n} {1 {SQLITE_ERROR - SQL logic error]}}\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuprogress.test",
    "content": "# 2016 March 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbuprogress\n\n\nproc create_db_file {filename sql} {\n  forcedelete $filename\n  sqlite3 tmpdb $filename  \n  tmpdb eval $sql\n  tmpdb close\n}\n\n# Create a simple RBU database. That expects to write to a table:\n#\n#   CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n#\nproc create_rbu1 {filename} {\n  create_db_file $filename {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(1, 2, 3, 0);\n    INSERT INTO data_t1 VALUES(2, 'two', 'three', 0);\n    INSERT INTO data_t1 VALUES(3, NULL, 8.2, 0);\n\n    CREATE TABLE rbu_count(tbl, cnt);\n    INSERT INTO rbu_count VALUES('data_t1', 3);\n  }\n  return $filename\n}\n\n\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 4096;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n}\n\ndo_test 1.1 {\n  create_rbu1 rbu.db\n  sqlite3rbu rbu test.db rbu.db\n  rbu bp_progress\n} {0 0}\ndo_test 1.2 { rbu step ; rbu bp_progress } {3333 0}\ndo_test 1.3 { rbu step ; rbu bp_progress } {6666 0}\ndo_test 1.4 { rbu step ; rbu bp_progress } {10000 0}\ndo_test 1.5 { rbu step ; rbu bp_progress } {10000 0}\ndo_test 1.6 { rbu step ; rbu bp_progress } {10000 0}\ndo_test 1.7 { rbu step ; rbu bp_progress } {10000 5000}\ndo_test 1.8 { rbu step ; rbu bp_progress } {10000 10000}\ndo_test 1.9 { rbu step ; rbu bp_progress } {10000 10000}\n\ndo_test 1.10 {\n  rbu close\n} {SQLITE_DONE}\n\n#-------------------------------------------------------------------------\n#\nproc do_sp_test {tn bReopen target rbu reslist} {\n  uplevel [list do_test $tn [subst -nocommands {\n    if {$bReopen==0} { sqlite3rbu rbu $target $rbu }\n    set res [list]\n    while 1 {\n      if {$bReopen} { sqlite3rbu rbu $target $rbu }\n      set rc [rbu step]\n      if {[set rc] != \"SQLITE_OK\"} { rbu close ; error \"error 1\" }\n      lappend res [lindex [rbu bp_progress] 0]\n      if {[lindex [set res] end]==10000} break\n      if {$bReopen} { rbu close }\n    }\n    if {[set res] != [list $reslist]} {\n      rbu close\n      error \"1. reslist incorrect (expect=$reslist got=[set res])\"\n    }\n\n    # One step to clean up the temporary tables used to update the only\n    # target table in the rbu database. And one more to move the *-oal \n    # file to *-wal. After each of these steps, the progress remains\n    # at \"10000 0\".\n    #\n    if {[lindex [list $reslist] 0]!=-1} {\n      rbu step\n      set res [rbu bp_progress]\n      if {[set res] != [list 10000 0]} {\n        rbu close\n        error \"2. reslist incorrect (expect=10000 0 got=[set res])\"\n      }\n    }\n\n    rbu step\n    set res [rbu bp_progress]\n    if {[set res] != [list 10000 0]} {\n      rbu close\n      error \"3. reslist incorrect (expect=10000 0 got=[set res])\"\n    }\n\n    # Do the checkpoint.\n    while {[rbu step]==\"SQLITE_OK\"} { \n      foreach {a b} [rbu bp_progress] {}\n      if {[set a]!=10000 || [set b]<=0 || [set b]>10000} {\n        rbu close\n        error \"4. reslist incorrect (expect=10000 1..10000 got=[set a] [set b])\"\n      }\n    }\n\n    set res [rbu bp_progress]\n    if {[set res] != [list 10000 10000]} {\n      rbu close\n      error \"5. reslist is incorrect (expect=10000 10000 got=[set res])\"\n    }\n\n    rbu close\n  }] {SQLITE_DONE}]\n}\n\nforeach {bReopen} { 0 1 } {\n  reset_db\n  do_test 2.$bReopen.1.0 {\n    execsql {\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(4, 4, 4, 0);\n      INSERT INTO data_t1 VALUES(5, 5, 5, 0);\n  \n      CREATE TABLE rbu_count(tbl, cnt);\n      INSERT INTO rbu_count VALUES('data_t1', 2);\n    }\n  } {}\n  do_sp_test 2.$bReopen.1.1 $bReopen test.db rbu.db {5000 10000}\n  \n  reset_db\n  do_test 2.$bReopen.2.0 {\n    execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c) }\n    create_rbu1 rbu.db\n  } {rbu.db}\n  do_sp_test 2.$bReopen.2.1 $bReopen test.db rbu.db {3333 6666 10000}\n  \n  reset_db\n  do_test 2.$bReopen.3.0 {\n    execsql { \n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      CREATE INDEX i1 ON t1(b);\n      INSERT INTO t1 VALUES(1, 1, 1);\n      INSERT INTO t1 VALUES(2, 2, 2);\n      INSERT INTO t1 VALUES(3, 3, 3);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(4, 4, 4, 0);\n      INSERT INTO data_t1 VALUES(2, NULL, NULL, 1);\n      INSERT INTO data_t1 VALUES(5, NULL, NULL, 1);\n  \n      CREATE TABLE rbu_count(tbl, cnt);\n      INSERT INTO rbu_count VALUES('data_t1', 3);\n    }\n  } {}\n  do_sp_test 2.$bReopen.3.1 $bReopen test.db rbu.db {1666 3333 6000 8000 10000}\n  \n  reset_db\n  do_test 2.$bReopen.4.0 {\n    execsql { \n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      CREATE INDEX i1 ON t1(b);\n      INSERT INTO t1 VALUES(1, 1, 1);\n      INSERT INTO t1 VALUES(2, 2, 2);\n      INSERT INTO t1 VALUES(3, 3, 3);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(2, 4, 4, '.xx');\n  \n      CREATE TABLE rbu_count(tbl, cnt);\n      INSERT INTO rbu_count VALUES('data_t1', 1);\n    }\n  } {}\n  do_sp_test 2.$bReopen.4.1 $bReopen test.db rbu.db {3333 6666 10000}\n  \n  reset_db\n  do_test 2.$bReopen.5.0 {\n    execsql { \n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      CREATE INDEX i1 ON t1(b);\n      INSERT INTO t1 VALUES(1, 1, 1);\n      INSERT INTO t1 VALUES(2, 2, 2);\n      INSERT INTO t1 VALUES(3, 3, 3);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(4, NULL, 4, '.xx');\n  \n      CREATE TABLE rbu_count(tbl, cnt);\n      INSERT INTO rbu_count VALUES('data_t1', 1);\n    }\n  } {}\n  do_sp_test 2.$bReopen.5.1 $bReopen test.db rbu.db {10000}\n\n  reset_db\n  do_test 2.$bReopen.6.0 {\n    execsql { \n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n      CREATE INDEX i1 ON t1(b);\n      INSERT INTO t1 VALUES(1, 1, 1);\n      INSERT INTO t1 VALUES(2, 2, 2);\n      INSERT INTO t1 VALUES(3, 3, 3);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, c, rbu_control);\n      INSERT INTO data_t1 VALUES(4, 4, 4, 0);\n      INSERT INTO data_t1 VALUES(2, NULL, NULL, 1);\n      INSERT INTO data_t1 VALUES(5, NULL, NULL, 1);\n    }\n  } {}\n  do_sp_test 2.$bReopen.6.1 $bReopen test.db rbu.db {-1 -1 -1 -1 -1 10000}\n}\n\n#-------------------------------------------------------------------------\n# The following tests verify that the API works when resuming an update\n# during the incremental checkpoint stage.\n#\nproc do_phase2_test {tn bReopen target rbu nStep} {\n  uplevel [list do_test $tn [subst -nocommands {\n\n    # Build the OAL/WAL file:\n    sqlite3rbu rbu $target $rbu\n    while {[lindex [rbu bp_progress] 0]<10000} { \n      set rc [rbu step]\n      if {\"SQLITE_OK\" != [set rc]} { rbu close }\n    }\n\n    # Clean up the temp tables and move the *-oal file to *-wal.\n    rbu step\n    rbu step\n\n    for {set i 0} {[set i] < $nStep} {incr i} {\n      if {$bReopen} {\n        rbu close\n        sqlite3rbu rbu $target $rbu\n      }\n      rbu step\n      set res [rbu bp_progress]\n      set expect [expr (1 + [set i]) * 10000 / $nStep]\n      if {[lindex [set res] 1] != [set expect]} {\n        error \"Have [set res], expected 10000 [set expect]\"\n      }\n    }\n\n    set rc [rbu step]\n    if {[set rc] != \"SQLITE_DONE\"} {\n      error \"Have [set rc], expected SQLITE_DONE\" \n    }\n\n    rbu close\n  }] {SQLITE_DONE}]\n}\n\nforeach bReopen {0 1} {\n  do_test 3.$bReopen.1.0 {\n    reset_db\n    execsql {\n      PRAGMA page_size = 4096;\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE t4(a INTEGER PRIMARY KEY, b);\n    }\n    create_db_file rbu.db {\n      CREATE TABLE data_t1(a, b, rbu_control);\n      CREATE TABLE data_t2(a, b, rbu_control);\n      CREATE TABLE data_t3(a, b, rbu_control);\n      CREATE TABLE data_t4(a, b, rbu_control);\n      INSERT INTO data_t1 VALUES(1, 2, 0);\n      INSERT INTO data_t2 VALUES(1, 2, 0);\n      INSERT INTO data_t3 VALUES(1, 2, 0);\n      INSERT INTO data_t4 VALUES(1, 2, 0);\n  \n      CREATE TABLE rbu_count(tbl, cnt);\n      INSERT INTO rbu_count VALUES('data_t1', 1);\n      INSERT INTO rbu_count VALUES('data_t2', 1);\n      INSERT INTO rbu_count VALUES('data_t3', 1);\n      INSERT INTO rbu_count VALUES('data_t4', 1);\n    }\n  } {}\n  do_phase2_test 3.$bReopen.1.1 $bReopen test.db rbu.db 5\n}\n\n\nforeach {bReopen} { 0 1 } {\n  foreach {tn tbl} {\n    ipk { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c) }\n    wr  { CREATE TABLE t1(a INT PRIMARY KEY, b, c) WITHOUT ROWID }\n    pk  { CREATE TABLE t1(a INT PRIMARY KEY, b, c) }\n  } {\n\n    foreach {tn2 rbusql r1 r3} {\n      1 {\n        CREATE TABLE data0_t1(a, b, c, rbu_control);\n        INSERT INTO data0_t1 VALUES(15, 15, 15, 0);\n        INSERT INTO data0_t1 VALUES(20, 20, 20, 0);\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 2); \n      } \n      {2500 5000 7500 10000}\n      {1666 3333 5000 6666 8333 10000}\n\n      2 {\n        CREATE TABLE data0_t1(a, b, c, rbu_control);\n        INSERT INTO data0_t1 VALUES(10, 10, 10, 2);\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 1); \n      } \n      {3333 6666 10000}\n      {2000 4000 6000 8000 10000}\n\n      3 {\n        CREATE TABLE data0_t1(a, b, c, rbu_control);\n        INSERT INTO data0_t1 VALUES(7, 7, 7, 2);\n        INSERT INTO data0_t1 VALUES(10, 10, 10, 2);\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 2); \n      } \n      {2500 4000 6000 8000 10000}\n      {1666 2500 3750 5000 6250 7500 8750 10000}\n\n    } {\n\n      reset_db ; execsql $tbl\n      do_test 4.$tn.$bReopen.$tn2.0 {\n        execsql {\n          CREATE INDEX t1c ON t1(c);\n          INSERT INTO t1 VALUES(1, 1, 1);\n          INSERT INTO t1 VALUES(5, 5, 5);\n          INSERT INTO t1 VALUES(10, 10, 10);\n        }\n        create_db_file rbu.db $rbusql\n      } {}\n\n      set R(ipk) $r1\n      set R(wr) $r1\n      set R(pk) $r3\n      do_sp_test 4.$tn.$bReopen.$tn2.1 $bReopen test.db rbu.db $R($tn)\n    }\n  }\n}\n\nforeach {bReopen} { 0 1 } {\n  foreach {tn tbl} {\n    nopk { \n      CREATE TABLE t1(a, b, c);\n      CREATE INDEX t1c ON t1(c);\n    }\n    vtab { \n      CREATE VIRTUAL TABLE t1 USING fts5(a, b, c);\n    }\n  } {\n\n    if {$tn==\"vtab\"} { ifcapable !fts5 break }\n\n    foreach {tn2 rbusql r1 r2} {\n      1 {\n        CREATE TABLE data0_t1(a, b, c, rbu_rowid, rbu_control);\n        INSERT INTO data0_t1 VALUES(15, 15, 15, 4, 0);\n        INSERT INTO data0_t1 VALUES(20, 20, 20, 5, 0);\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 2); \n      } \n      {2500 5000 7500 10000}\n      {5000 10000}\n\n      2 {\n        CREATE TABLE data0_t1(rbu_rowid, a, b, c, rbu_control);\n        INSERT INTO data0_t1 VALUES(0, 7, 7, 7, 2);\n        INSERT INTO data0_t1 VALUES(2, 10, 10, 10, 2);\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 2); \n      } \n      {2500 4000 6000 8000 10000}\n      {5000 10000}\n\n      3 {\n        CREATE TABLE data0_t1(rbu_rowid, a, b, c, rbu_control);\n        INSERT INTO data0_t1 VALUES(1, NULL, NULL, NULL, 1);\n        INSERT INTO data0_t1 VALUES(2, NULL, NULL, 7, '..x');\n        CREATE TABLE rbu_count(tbl, cnt);\n        INSERT INTO rbu_count VALUES('data0_t1', 2); \n      } \n      {2500 4000 6000 8000 10000}\n      {5000 10000}\n    } {\n\n      reset_db ; execsql $tbl\n      do_test 5.$tn.$bReopen.$tn2.0 {\n        execsql {\n          INSERT INTO t1 VALUES(1, 1, 1);\n          INSERT INTO t1 VALUES(5, 5, 5);\n          INSERT INTO t1 VALUES(10, 10, 10);\n        }\n        create_db_file rbu.db $rbusql\n      } {}\n\n      set R(nopk) $r1\n      set R(vtab) $r2\n      do_sp_test 5.$tn.$bReopen.$tn2.1 $bReopen test.db rbu.db $R($tn)\n    }\n  }\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rburesume.test",
    "content": "# 2017 January 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for resumption of RBU operations in the\n# case where the previous RBU process crashed.\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rburesume\n\nforcedelete test.db-shm test.db-oal\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  CREATE INDEX t1a ON t1(a);\n  CREATE INDEX t1b ON t1(b);\n  CREATE INDEX t1c ON t1(c);\n  WITH s(i) AS (\n    VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<50\n  )\n  INSERT INTO t1 SELECT randomblob(50), randomblob(75), randomblob(100) FROM s;\n}\ndb_save_and_close\n\ndo_test 1.1 {\n  list [file exists test.db] \\\n       [file exists test.db-wal] \\\n       [file exists test.db-shm] \\\n       [file exists test.db-oal]\n} {1 0 0 0}\n\n# Each iteration of the following loop:\n#\n#   1. Restores the db to the state it was in following test case 1.0\n#   2. Opens an RBU vacuum and steps it $n times.\n#   3. Closes the RBU vacuum handled opened in (2).\n#   4. Opens a second RBU vacuum handle, resumes and completes the vacuum op. \n#\n# The loop runs until $n is large enough that step (2) vacuums the entire\n# database.\n#\nfor {set n 1} {$n < 5000} {incr n} {\n  db_restore\n  forcedelete state.db\n  sqlite3rbu_vacuum rbu test.db state.db\n  for {set i 0} {$i<$n} {incr i} {\n    set rc [rbu step]\n    if {$rc == \"SQLITE_DONE\"} break\n  }\n  rbu close\n  if {$rc == \"SQLITE_DONE\"} break\n\n  do_test 1.2.$n.1 {\n    sqlite3rbu_vacuum rbu test.db state.db\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } {SQLITE_DONE}\n\n  do_test 1.2.$n.2 {\n    sqlite3 db2 test.db\n    db2 eval { \n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    }\n  } {50 ok}\n  db2 close\n}\n\n# Each iteration of this loop:\n#\n#   1. Restores the db to the state it was in following test case 1.0\n#   2. Opens an RBU vacuum and steps it $n times.\n#   3. Takes a copy of all database files and the state db.\n#   4. Opens a second RBU vacuum handle on the copy, resumes and completes the\n#      vacuum op. \n#\n# The loop runs until $n is large enough that step (2) vacuums the entire\n# database.\n#\nfor {set n 1} {$n < 5000} {incr n} {\n  db_restore\n  forcedelete state.db state.db-shm state.db-oal state.db-wal\n  sqlite3rbu_vacuum rbu test.db state.db\n  for {set i 0} {$i<$n} {incr i} {\n    set rc [rbu step]\n    if {$rc == \"SQLITE_DONE\"} break\n  }\n  if {$rc == \"SQLITE_DONE\"} {\n    rbu close\n    break\n  }\n\n  foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {\n    set f2 [string map [list test.db test.db2] $f]\n    if {[file exists $f]} {\n      forcecopy $f $f2\n    } else {\n      forcedelete $f2\n    }\n  }\n  forcecopy state.db state.db2\n  rbu close\n\n  do_test 1.3.$n.1 {\n    sqlite3rbu_vacuum rbu test.db2 state.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } {SQLITE_DONE}\n\n  do_test 1.3.$n.2 {\n    sqlite3 db2 test.db2\n    db2 eval { \n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    }\n  } {50 ok}\n  db2 close\n}\n\n# Each iteration of this loop:\n#\n#   1. Restores the db to the state it was in following test case 1.0\n#   2. Opens an RBU vacuum and steps it 10 times. Then closes it.\n#   2. Opens an RBU vacuum and steps it $n times.\n#   3. Takes a copy of all database files and the state db.\n#   4. Opens a second RBU vacuum handle on the copy, resumes and completes the\n#      vacuum op. \n#\n# The loop runs until $n is large enough that step (3) vacuums the entire\n# database.\n#\nfor {set n 1} {$n < 5000} {incr n} {\n  db_restore\n  forcedelete state.db state.db-shm state.db-oal state.db-wal\n\n  sqlite3rbu_vacuum rbu test.db state.db\n  for {set i 0} {$i<10} {incr i} {\n    rbu step\n  }\n  rbu close\n\n  sqlite3rbu_vacuum rbu test.db state.db\n  for {set i 0} {$i<$n} {incr i} {\n    set rc [rbu step]\n    if {$rc == \"SQLITE_DONE\"} break\n  }\n  if {$rc == \"SQLITE_DONE\"} {\n    rbu close\n    break\n  }\n\n  foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {\n    set f2 [string map [list test.db test.db2] $f]\n    if {[file exists $f]} {\n      forcecopy $f $f2\n    } else {\n      forcedelete $f2\n    }\n  }\n  forcecopy state.db state.db2\n  rbu close\n\n  do_test 1.4.$n.1 {\n    sqlite3rbu_vacuum rbu test.db2 state.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } {SQLITE_DONE}\n\n  do_test 1.4.$n.2 {\n    sqlite3 db2 test.db2\n    db2 eval { \n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    }\n  } {50 ok}\n  db2 close\n}\n\nforcedelete rbu.db\ndo_test 2.0 {\n  sqlite3 db2 rbu.db\n  db2 eval {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    WITH s(i) AS (\n        VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<10\n    )\n    INSERT INTO data_t1 \n      SELECT randomblob(50), randomblob(75), randomblob(100), 0 FROM s;\n  }\n  db2 close\n} {}\n\n# Each iteration of this loop:\n#\n#   1. Restores the db to the state it was in following test case 1.0\n#   2. Opens an RBU handle to apply the RBU update created in test case 2.0.\n#   3. Steps the RBU handle $n times.\n#   4. Takes a copy of all database files and the state db.\n#   5. Opens a second RBU handle on the copy, resumes and completes the\n#      RBU op. Checks it worked as expected.\n#\n# The loop runs until $n is large enough that step (3) applies the entire\n# update.\n#\nfor {set n 1} {$n < 5000} {incr n} {\n  db_restore\n  forcedelete state.db state.db-shm state.db-oal state.db-wal\n  sqlite3rbu rbu test.db rbu.db state.db\n\n  for {set i 0} {$i<$n} {incr i} {\n    set rc [rbu step]\n    if {$rc == \"SQLITE_DONE\"} break\n  }\n  if {$rc == \"SQLITE_DONE\"} {\n    rbu close\n    break\n  }\n\n  foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {\n    set f2 [string map [list test.db test.db2] $f]\n    if {[file exists $f]} {\n      forcecopy $f $f2\n    } else {\n      forcedelete $f2\n    }\n  }\n  forcecopy state.db state.db2\n  rbu close\n\n  do_test 2.$n.1 {\n    sqlite3rbu rbu test.db2 rbu.db state.db2\n    while {[rbu step]==\"SQLITE_OK\"} {}\n    rbu close\n  } {SQLITE_DONE}\n\n  do_test 2.$n.2 {\n    sqlite3 db2 test.db2\n    db2 eval { \n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    }\n  } {60 ok}\n  db2 close\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbusave.test",
    "content": "# 2015 August 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nset ::testprefix rbusave\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX i1 ON t1(b);\n  CREATE INDEX i2 ON t2(c, b);\n\n  INSERT INTO t1 VALUES(1, 1, 1);\n  INSERT INTO t1 VALUES(2, 2, 2);\n  INSERT INTO t1 VALUES(3, 3, 3);\n\n  INSERT INTO t2 VALUES(1, 1, 1);\n  INSERT INTO t2 VALUES(2, 2, 2);\n  INSERT INTO t2 VALUES(3, 3, 3);\n}\n\ndo_test 1.1 {\n  forcedelete test.db2\n  sqlite3 db2 test.db2\n  db2 eval {\n    CREATE TABLE data_t1(a, b, c, rbu_control);\n    INSERT INTO data_t1 VALUES(4, 4, 4, 0);\n    INSERT INTO data_t1 VALUES(2, NULL, NULL, 1);\n    INSERT INTO data_t1 VALUES(1, 'one', NULL, '.x.');\n\n    CREATE TABLE data_t2(a, b, c, rbu_control);\n    INSERT INTO data_t2 VALUES(4, 4, 4, 0);\n    INSERT INTO data_t2 VALUES(2, NULL, NULL, 1);\n    INSERT INTO data_t2 VALUES(1, 'one', NULL, '.x.');\n  }\n} {}\n\nproc test_to_bak {} {\n  foreach f {\n    test.db test.db-wal test.db-oal test.db-journal \n    test.db2 test.db2-wal test.db2-oal test.db2-journal \n  } {\n    set t [string map {test bak} $f]\n    forcedelete $t\n    if {[file exists $f]} { forcecopy $f $t }\n  }\n}\n\ndo_test 1.2 {\n  test_to_bak\n  sqlite3rbu rrr bak.db bak.db2\n  set nStep 0\n  while {[rrr step]==\"SQLITE_OK\"} {incr nStep}\n  set res2 [rrr close]\n} {SQLITE_DONE}\n\n\nsqlite3rbu rbu test.db test.db2\nset res \"SQLITE_OK\"\nfor {set i 1} {$res==\"SQLITE_OK\"} {incr i} {\n  set res [rbu step]\n\n  do_test 1.3.$i.1 {\n    rbu savestate\n    test_to_bak\n    sqlite3rbu rrr bak.db bak.db2\n    set nRem 0\n    while {[rrr step]==\"SQLITE_OK\"} {incr nRem}\n    set res2 [rrr close]\n  } {SQLITE_DONE}\n\n  do_test 1.3.$i.3 { expr $nRem+$i } [expr {$nStep + ($res==\"SQLITE_DONE\")}]\n\n  do_test 1.3.$i.3 {\n    sqlite3 bak bak.db\n    bak eval {\n      SELECT * FROM t1;\n      SELECT * FROM t2;\n    }\n  } {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4}\n\n  bak close\n}\n\ndo_test 1.4 { rbu close } {SQLITE_DONE}\n\ndo_execsql_test 1.5 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {1 one 1 3 3 3 4 4 4 1 one 1 3 3 3 4 4 4}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbutemplimit.test",
    "content": "# 2014 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbutemplimit\n\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\nproc setup_databases {} {\n  forcedelete test.db2\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    -- Create target database schema.\n    --\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB(100), c BLOB(100));\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b BLOB(100), c BLOB(100));\n    CREATE INDEX i1b ON t1(b);\n    CREATE INDEX i1c ON t1(c);\n    CREATE INDEX i2b ON t2(b);\n    CREATE INDEX i2c ON t2(c);\n  \n    -- Create a large RBU database.\n    --\n    ATTACH 'test.db2' AS rbu;\n    CREATE TABLE rbu.data_t1(a, b, c, rbu_control);\n    WITH s(i) AS (\n      VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<10000\n    )\n    INSERT INTO data_t1 SELECT i, randomblob(100), randomblob(100), 0 FROM s;\n    CREATE TABLE rbu.data_t2(a, b, c, rbu_control);\n    WITH s(i) AS (\n      VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<15000\n    )\n    INSERT INTO data_t2 SELECT i, randomblob(100), randomblob(100), 0 FROM s;\n  }\n  db close\n}\n\nproc run_rbu_cachesize {target rbu cachesize temp_limit} {\n  sqlite3rbu rbu $target $rbu\n  rbu temp_size_limit $temp_limit\n  sqlite3_exec_nr [rbu db 1] \"PRAGMA cache_size = $cachesize\"\n  while 1 {\n    set rc [rbu step]\n    set ::A([rbu temp_size]) 1\n    if {$rc!=\"SQLITE_OK\"} break\n  }\n  list [catch {rbu close} msg] $msg\n}\n\nproc step_rbu_cachesize {target rbu stepsize cachesize temp_limit} {\n  set res \"\"\n  while 1 {\n    sqlite3rbu rbu $target $rbu\n    rbu temp_size_limit $temp_limit\n    sqlite3_exec_nr [rbu db 1] \"PRAGMA cache_size = $cachesize\"\n    for {set i 0} {$i < $stepsize} {incr i} {\n      set rc [rbu step]\n      set ::A([rbu temp_size]) 1\n      if {$rc!=\"SQLITE_OK\"} break\n    }\n    set res [list [catch {rbu close} msg] $msg]\n    if {$res != \"0 SQLITE_OK\"} break\n  }\n  set res\n}\n\ndo_test 1.1.0 { setup_databases } {}\n\ndo_test 1.1.1 {\n  unset -nocomplain ::A\n  run_rbu_cachesize test.db test.db2 10 0\n} {0 SQLITE_DONE}\n\ndo_test 1.1.2 { llength [array names ::A] } 3\n\ndo_test 1.1.3 { \n  foreach {a0 a1 a2} [lsort -integer [array names ::A]] {}\n  list [expr $a0==0]                         \\\n       [expr $a1>1048576] [expr $a1<1200000] \\\n       [expr $a2>1500000] [expr $a2<1700000]\n} {1 1 1 1 1}\n\ndo_test 1.2.1 {\n  setup_databases\n  run_rbu_cachesize test.db test.db2 10 1000000\n} {1 SQLITE_FULL}\ndo_test 1.2.2 { info commands rbu } {}\n\ndo_test 1.3.1 {\n  setup_databases\n  run_rbu_cachesize test.db test.db2 10 1300000\n} {1 SQLITE_FULL}\ndo_test 1.3.2 { info commands rbu } {}\n\ndo_test 1.4.1 {\n  setup_databases\n  run_rbu_cachesize test.db test.db2 10 1800000\n} {0 SQLITE_DONE}\ndo_test 1.4.2 { info commands rbu } {}\n\ndo_test 1.5.1 {\n  setup_databases\n  unset -nocomplain ::A\n  step_rbu_cachesize test.db test.db2 1000 10 2400000\n} {0 SQLITE_DONE}\ndo_test 1.5.2 { info commands rbu } {}\n\ndo_test 1.6.1 {\n  setup_databases\n  unset -nocomplain ::A\n  step_rbu_cachesize test.db test.db2 1000 10 1400000\n} {1 SQLITE_FULL}\ndo_test 1.6.2 { info commands rbu } {}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuvacuum.test",
    "content": "# 2016 April 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module. More specifically, it\n# contains tests to ensure that the sqlite3rbu_vacuum() API works as\n# expected.\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\nset ::testprefix rbuvacuum\n\nforeach step {0 1} {\n\n  set ::testprefix rbuvacuum-step=$step\n  reset_db\n\n  # Simplest possible vacuum.\n  do_execsql_test 1.0 {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t1 VALUES(7, 8, 9);\n    PRAGMA integrity_check;\n  } {ok}\n  do_rbu_vacuum_test 1.1 $step\n\n  # A vacuum that actually reclaims space.\n  do_execsql_test 1.2.1 {\n    INSERT INTO t1 VALUES(8, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(9, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(10, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(11, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(12, randomblob(900), randomblob(900));\n    PRAGMA page_count;\n  } {12}\n  do_execsql_test 1.2.2 {\n    DELETE FROM t1 WHERE rowid BETWEEN 8 AND 11;\n    PRAGMA page_count;\n  } {12}\n  do_rbu_vacuum_test 1.2.3 $step\n  do_execsql_test 1.2.4 {\n    PRAGMA page_count;\n  } {3}\n  \n  # Add an index to the table.\n  do_execsql_test 1.3.1 {\n    CREATE INDEX t1b ON t1(b);\n    INSERT INTO t1 VALUES(13, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(14, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(15, randomblob(900), randomblob(900));\n    INSERT INTO t1 VALUES(16, randomblob(900), randomblob(900));\n    PRAGMA page_count;\n  } {18}\n  do_execsql_test 1.3.2 {\n    DELETE FROM t1 WHERE rowid BETWEEN 12 AND 15;\n    PRAGMA page_count;\n  } {18}\n  do_rbu_vacuum_test 1.3.3 $step\n  do_execsql_test 1.3.4 {\n    PRAGMA page_count;\n  } {5}\n\n  # WITHOUT ROWID table.\n  do_execsql_test 1.4.1 {\n    CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;\n\n    INSERT INTO t2 VALUES(randomblob(900), 1, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 2, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 3, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 4, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 6, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 7, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 8, randomblob(900));\n\n    DELETE FROM t2 WHERE b BETWEEN 2 AND 7;\n    PRAGMA page_count;\n  } {20}\n  do_rbu_vacuum_test 1.4.2 $step\n  do_execsql_test 1.4.3 {\n    PRAGMA page_count;\n  } {10}\n  \n  # WITHOUT ROWID table with an index.\n  do_execsql_test 1.4.1 {\n    CREATE INDEX t2c ON t2(c);\n\n    INSERT INTO t2 VALUES(randomblob(900), 9, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 10, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 11, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 12, randomblob(900));\n    INSERT INTO t2 VALUES(randomblob(900), 13, randomblob(900));\n\n    DELETE FROM t2 WHERE b BETWEEN 8 AND 12;\n    PRAGMA page_count;\n  } {35}\n  do_rbu_vacuum_test 1.4.2 $step\n  do_execsql_test 1.4.3 {\n    PRAGMA page_count;\n  } {15}\n  do_execsql_test 1.4.4 {\n    VACUUM;\n    PRAGMA page_count;\n  } {15}\n\n  do_execsql_test 1.5.1 {\n    CREATE TABLE t3(a, b, c);\n    INSERT INTO t3 VALUES('a', 'b', 'c');\n    INSERT INTO t3 VALUES('d', 'e', 'f');\n    INSERT INTO t3 VALUES('g', 'h', 'i');\n  }\n  do_rbu_vacuum_test 1.5.2 $step\n  do_execsql_test 1.5.3 {\n    SELECT * FROM t3\n  } {a b c d e f g h i}\n  do_execsql_test 1.5.4 {\n    CREATE INDEX t3a ON t3(a);\n    CREATE INDEX t3b ON t3(b);\n    CREATE INDEX t3c ON t3(c);\n    INSERT INTO t3 VALUES('j', 'k', 'l');\n    DELETE FROM t3 WHERE a = 'g';\n  }\n  do_rbu_vacuum_test 1.5.5 $step\n  do_execsql_test 1.5.6 {\n    SELECT rowid, * FROM t3 ORDER BY b\n  } {1 a b c 2 d e f 4 j k l}\n\n  do_execsql_test 1.6.1 {\n    CREATE TABLE t4(a PRIMARY KEY, b, c);\n    INSERT INTO t4 VALUES('a', 'b', 'c');\n    INSERT INTO t4 VALUES('d', 'e', 'f');\n    INSERT INTO t4 VALUES('g', 'h', 'i');\n  }\n  do_rbu_vacuum_test 1.6.2 $step\n  do_execsql_test 1.6.3 {\n    SELECT * FROM t4\n  } {a b c d e f g h i}\n  do_execsql_test 1.6.4 {\n    CREATE INDEX t4a ON t4(a);\n    CREATE INDEX t4b ON t4(b);\n    CREATE INDEX t4c ON t4(c);\n    \n    INSERT INTO t4 VALUES('j', 'k', 'l');\n    DELETE FROM t4 WHERE a='g';\n  }\n  do_rbu_vacuum_test 1.6.5 $step\n  do_execsql_test 1.6.6 {\n    SELECT * FROM t4 ORDER BY b\n  } {a b c d e f j k l}\n\n  reset_db\n  do_execsql_test 1.7.0 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    INSERT INTO t1 VALUES(NULL, 'one');\n    INSERT INTO t1 VALUES(NULL, 'two');\n    DELETE FROM t1 WHERE a=2;\n    INSERT INTO t1 VALUES(NULL, 'three');\n    INSERT INTO t1 VALUES(NULL, 'four');\n    DELETE FROM t1 WHERE a=4;\n    INSERT INTO t1 VALUES(NULL, 'five');\n    INSERT INTO t1 VALUES(NULL, 'six');\n    DELETE FROM t1 WHERE a=6;\n    SELECT * FROM t1;\n  } {1 one 3 three 5 five}\n  do_rbu_vacuum_test 1.7.1 $step\n  do_execsql_test 1.7.2 {\n    INSERT INTO t1 VALUES(NULL, 'seven');\n    SELECT * FROM t1;\n  } {1 one 3 three 5 five 7 seven}\n\n  reset_db\n  do_execsql_test 1.8.0 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    CREATE INDEX i1 ON t1(b);\n    INSERT INTO t1 VALUES(NULL, 'one');\n    INSERT INTO t1 VALUES(NULL, 'two');\n    INSERT INTO t1 VALUES(NULL, 'three');\n    INSERT INTO t1 VALUES(NULL, 'four');\n    INSERT INTO t1 VALUES(NULL, 'five');\n    INSERT INTO t1 VALUES(NULL, 'six');\n    ANALYZE;\n    SELECT * FROM sqlite_stat1;\n  } {t1 i1 {6 1}}\n  do_rbu_vacuum_test 1.8.1 $step\n  do_execsql_test 1.7.2 {\n    SELECT * FROM sqlite_stat1;\n  } {t1 i1 {6 1}}\n\n  reset_db\n  do_execsql_test 1.9.0 {\n    PRAGMA page_size = 8192;\n    PRAGMA auto_vacuum = 2;\n    PRAGMA user_version = 412;\n    PRAGMA application_id = 413;\n\n    CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    CREATE INDEX i1 ON t1(b);\n    INSERT INTO t1 VALUES(NULL, 'one');\n    INSERT INTO t1 VALUES(NULL, 'two');\n    INSERT INTO t1 VALUES(NULL, 'three');\n    INSERT INTO t1 VALUES(NULL, 'four');\n    INSERT INTO t1 VALUES(NULL, 'five');\n    INSERT INTO t1 VALUES(NULL, 'six');\n\n    PRAGMA main.page_size;\n    PRAGMA main.auto_vacuum;\n    PRAGMA main.user_version;\n    PRAGMA main.application_id;\n  } {8192 2 412 413}\n\n  do_rbu_vacuum_test 1.9.1 $step\n  do_execsql_test 1.9.2 {\n    PRAGMA main.page_size;\n    PRAGMA main.auto_vacuum;\n    PRAGMA main.user_version;\n    PRAGMA main.application_id;\n  } {8192 2 412 413}\n\n  # Vacuum a database with a large sqlite_master table.\n  #\n  reset_db\n  do_test 1.10.1 {\n    for {set i 1} {$i < 50} {incr i} {\n      execsql \"PRAGMA page_size = 1024\"\n      execsql \"CREATE TABLE t$i (a, b, c, PRIMARY KEY(a, b));\"\n      execsql \"\n        INSERT INTO t$i VALUES(1, 2, 3);\n        INSERT INTO t$i VALUES(4, 5, 6);\n      \"\n    }\n  } {}\n  do_rbu_vacuum_test 1.10.2 $step\n\n  # Database with empty tables.\n  #\n  reset_db\n  do_execsql_test 1.11.1 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t4(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t4 VALUES(1, 2);\n  }\n  do_rbu_vacuum_test 1.11.2 $step\n  do_execsql_test 1.11.3 {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n    SELECT * FROM t4;\n  } {1 2}\n  reset_db\n  do_execsql_test 1.12.1 {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t4(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  do_rbu_vacuum_test 1.12.2 $step\n  do_execsql_test 1.12.3 {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n    SELECT * FROM t4;\n  } {1 2}\n}\nset ::testprefix rbuvacuum\n\n#-------------------------------------------------------------------------\n# Test some error cases:\n#\n#   2.1.* the db being vacuumed being in wal mode already.\n#   2.2.* database modified mid vacuum.\n#\nreset_db\ndo_execsql_test 2.1.0 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n  INSERT INTO t1 VALUES(7, 8);\n  PRAGMA journal_mode = wal;\n  INSERT INTO t1 VALUES(9, 10);\n} wal\ndo_test 2.1.1 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  rbu step\n} {SQLITE_ERROR}\ndo_test 2.1.2 {\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - cannot vacuum wal mode database}}\n\ndo_test 2.1.3 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  rbu step\n} {SQLITE_ERROR}\ndo_test 2.1.4 {\n  list [catch { rbu close_no_error } msg] $msg\n} {1 SQLITE_ERROR}\n\nreset_db\ndo_execsql_test 2.2.0 {\n  CREATE TABLE tx(a PRIMARY KEY, b BLOB);\n  INSERT INTO tx VALUES(1, randomblob(900));\n  INSERT INTO tx SELECT a+1, randomblob(900) FROM tx;\n  INSERT INTO tx SELECT a+2, randomblob(900) FROM tx;\n  INSERT INTO tx SELECT a+4, randomblob(900) FROM tx;\n  INSERT INTO tx SELECT a+8, randomblob(900) FROM tx;\n}\ndb_save_and_close\nfor {set i 1} 1 {incr i} {\n  db_restore_and_reopen\n\n  sqlite3rbu_vacuum rbu test.db state.db\n  for {set step 0} {$step<$i} {incr step} { rbu step }\n  rbu close\n  if {[file exists test.db-wal]} break\n\n  execsql { INSERT INTO tx VALUES(20, 20) }\n\n  do_test 2.2.$i.1 {\n    sqlite3rbu_vacuum rbu test.db state.db \n    rbu step\n  } {SQLITE_BUSY}\n  do_test 2.2.$i.2 {\n    list [catch { rbu close } msg] $msg\n  } {1 {SQLITE_BUSY - database modified during rbu vacuum}}\n}\n\n#-------------------------------------------------------------------------\n# Test that a database that uses custom collation sequences can be RBU\n# vacuumed.\n#\nreset_db\nforcedelete state.db\nproc noop {args} {}\nproc length_cmp {x y} {\n  set n1 [string length $x]\n  set n2 [string length $y]\n  return [expr $n1 - $n2]\n}\nsqlite3_create_collation_v2 db length length_cmp noop\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 'i');\n  INSERT INTO t1 VALUES(2, 'iiii');\n  INSERT INTO t1 VALUES(3, 'ii');\n  INSERT INTO t1 VALUES(4, 'iii');\n  SELECT a FROM t1 ORDER BY b COLLATE length;\n} {1 3 4 2}\ndo_execsql_test 3.1 {\n  CREATE INDEX i1 ON t1(b COLLATE length);\n}\n\ndo_test 3.2 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  while {[rbu step]==\"SQLITE_OK\"} {}\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - no such collation sequence: length}}\n\ndo_test 3.3 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  set db1 [rbu db 0]\n  sqlite3_create_collation_v2 $db1 length length_cmp noop\n  while {[rbu step]==\"SQLITE_OK\"} {}\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - no such collation sequence: length}}\n\ndo_test 3.4 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  set db1 [rbu db 1]\n  sqlite3_create_collation_v2 $db1 length length_cmp noop\n  while {[rbu step]==\"SQLITE_OK\"} {}\n  list [catch { rbu close } msg] $msg\n} {1 {SQLITE_ERROR - no such collation sequence: length}}\n\ndo_test 3.5 {\n  sqlite3rbu_vacuum rbu test.db state.db\n  set db1 [rbu db 0]\n  set db2 [rbu db 1]\n\n  sqlite3_create_collation_v2 $db1 length length_cmp noop\n  sqlite3_create_collation_v2 $db2 length length_cmp noop\n\n  while {[rbu step]==\"SQLITE_OK\"} {}\n  list [catch { rbu close } msg] $msg\n} {0 SQLITE_DONE}\n\ncatch { db close }\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/rbuvacuum2.test",
    "content": "# 2016 June 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the RBU module. More specifically, it\n# contains tests to ensure that the sqlite3rbu_vacuum() API works as\n# expected.\n#\n\nsource [file join [file dirname [info script]] rbu_common.tcl]\n\nforeach step {0 1} {\n  set ::testprefix rbuvacuum2-$step\n  \n  #-------------------------------------------------------------------------\n  # Test that a database that contains fts3 tables can be vacuumed.\n  #\n  ifcapable fts3 {\n    reset_db\n    do_execsql_test 1.1 {\n      CREATE VIRTUAL TABLE t1 USING fts3(z, y);\n      INSERT INTO t1 VALUES('fix this issue', 'at some point');\n    }\n  \n    do_rbu_vacuum_test 1.2 $step\n  \n    do_execsql_test 1.3 {\n      SELECT * FROM t1;\n    } {{fix this issue} {at some point}}\n  \n    do_execsql_test 1.4 {\n      SELECT rowid FROM t1 WHERE t1 MATCH 'fix';\n    } {1}\n\n    do_execsql_test 1.5 {\n      INSERT INTO t1 VALUES('a b c', 'd e f');\n      INSERT INTO t1 VALUES('l h i', 'd e f');\n      DELETE FROM t1 WHERE docid = 2;\n      INSERT INTO t1 VALUES('a b c', 'x y z');\n    }\n\n    do_rbu_vacuum_test 1.6 $step\n    do_execsql_test 1.7 {\n      INSERT INTO t1(t1) VALUES('integrity-check');\n      SELECT * FROM t1;\n    } {\n      {fix this issue} {at some point}\n      {l h i} {d e f}\n      {a b c} {x y z}\n    }\n  }\n  \n  #-------------------------------------------------------------------------\n  # Test that a database that contains fts5 tables can be vacuumed.\n  #\n  ifcapable fts5 {\n    reset_db\n    do_execsql_test 2.1 {\n      CREATE VIRTUAL TABLE t1 USING fts5(z, y);\n      INSERT INTO t1 VALUES('fix this issue', 'at some point');\n    }\n  \n    do_rbu_vacuum_test 2.2 $step\n  \n    do_execsql_test 2.3 {\n      SELECT * FROM t1;\n    } {{fix this issue} {at some point}}\n  \n    do_execsql_test 2.4 {\n      SELECT rowid FROM t1 ('fix');\n    } {1}\n\n    do_execsql_test 2.5 {\n      INSERT INTO t1 VALUES('a b c', 'd e f');\n      INSERT INTO t1 VALUES('l h i', 'd e f');\n      DELETE FROM t1 WHERE rowid = 2;\n      INSERT INTO t1 VALUES('a b c', 'x y z');\n    }\n\n    do_rbu_vacuum_test 2.6 $step\n    do_execsql_test 2.7 {\n      INSERT INTO t1(t1) VALUES('integrity-check');\n      SELECT * FROM t1;\n    } {\n      {fix this issue} {at some point}\n      {l h i} {d e f}\n      {a b c} {x y z}\n    }\n  }\n\n  #-------------------------------------------------------------------------\n  # Test that a database that contains an rtree table can be vacuumed.\n  #\n  ifcapable rtree {\n    reset_db\n    do_execsql_test 3.1 {\n      CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);\n      INSERT INTO rt VALUES(1, 45, 55);\n      INSERT INTO rt VALUES(2, 50, 60);\n      INSERT INTO rt VALUES(3, 55, 65);\n    }\n  \n    do_rbu_vacuum_test 3.2 $step\n  \n    do_execsql_test 3.3 {\n      SELECT * FROM rt;\n    } {1 45.0 55.0 2 50.0 60.0 3 55.0 65.0}\n  \n    do_execsql_test 3.4.1 {\n      SELECT rowid FROM rt WHERE x2>51 AND x1 < 51\n    } {1 2}\n    do_execsql_test 3.4.2 {\n      SELECT rowid FROM rt WHERE x2>59 AND x1 < 59\n    } {2 3}\n\n    do_rbu_vacuum_test 3.5 $step\n\n    do_execsql_test 3.6.1 {\n      SELECT rowid FROM rt WHERE x2>51 AND x1 < 51\n    } {1 2}\n    do_execsql_test 3.6.2 {\n      SELECT rowid FROM rt WHERE x2>59 AND x1 < 59\n    } {2 3}\n  }\n\n  ifcapable trigger {\n    reset_db\n    do_execsql_test 4.1 {\n      CREATE TABLE t1(a, b, c);\n      INSERT INTO t1 VALUES(1, 2, 3);\n      CREATE VIEW v1 AS SELECT * FROM t1;\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END;\n    }\n\n    do_execsql_test 4.2 {\n      SELECT * FROM sqlite_master;\n    } {\n    table t1 t1 2 {CREATE TABLE t1(a, b, c)}\n    view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1}\n    trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END}\n    }\n\n    do_rbu_vacuum_test 4.3 $step\n    do_execsql_test 4.4 {\n      SELECT * FROM sqlite_master;\n    } {\n    table t1 t1 2 {CREATE TABLE t1(a, b, c)}\n    view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t1}\n    trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END}\n    }\n  }\n}\n  \n#-------------------------------------------------------------------------\n# Test that passing a NULL value as the second argument to \n# sqlite3rbu_vacuum() causes it to:\n#\n#   * Use <database>-vacuum as the state db, and\n#   * Set the state db permissions to the same as those on the db file.\n#\ndb close\nif {$::tcl_platform(platform)==\"unix\"} {\n  forcedelete test.db\n\n  sqlite3 db test.db\n  do_execsql_test 5.0 {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n    INSERT INTO t1 VALUES(7, 8);\n  }\n  db close\n\n  foreach {tn perm} {\n    1 00755\n    2 00666\n    3 00644\n    4 00444\n  } {\n    forcedelete test.db-vacuum\n\n    do_test 5.$tn.1 {\n      file attributes test.db -permissions $perm\n      sqlite3rbu_vacuum rbu test.db\n      rbu step\n    } {SQLITE_OK}\n\n    do_test 5.$tn.2 { file exists test.db-vacuum } 1\n    do_test 5.$tn.3 { file attributes test.db-vacuum -permissions} $perm\n    rbu close\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test the outcome of some other connection running a checkpoint while\n# the incremental checkpoint is suspended.\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX i1b ON t1(b);\n  CREATE INDEX i1c ON t1(c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n}\nforcedelete test.db2\n\ndo_test 6.1 {\n  sqlite3rbu_vacuum rbu test.db test.db2\n  while {[rbu state]!=\"checkpoint\"} { rbu step }\n  rbu close\n} {SQLITE_OK}\n\ndo_execsql_test 6.2 {\n  SELECT 1 FROM sqlite_master LIMIT 1;\n  PRAGMA wal_checkpoint;\n} {1 0 4 4}\n\ndo_test 6.3 {\n  sqlite3rbu_vacuum rbu test.db test.db2\n  while {[rbu step]!=\"SQLITE_DONE\"} { rbu step }\n  rbu close\n  execsql { PRAGMA integrity_check }\n} {ok}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/sqlite3rbu.c",
    "content": "/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**\n** OVERVIEW \n**\n**  The RBU extension requires that the RBU update be packaged as an\n**  SQLite database. The tables it expects to find are described in\n**  sqlite3rbu.h.  Essentially, for each table xyz in the target database\n**  that the user wishes to write to, a corresponding data_xyz table is\n**  created in the RBU database and populated with one row for each row to\n**  update, insert or delete from the target table.\n** \n**  The update proceeds in three stages:\n** \n**  1) The database is updated. The modified database pages are written\n**     to a *-oal file. A *-oal file is just like a *-wal file, except\n**     that it is named \"<database>-oal\" instead of \"<database>-wal\".\n**     Because regular SQLite clients do not look for file named\n**     \"<database>-oal\", they go on using the original database in\n**     rollback mode while the *-oal file is being generated.\n** \n**     During this stage RBU does not update the database by writing\n**     directly to the target tables. Instead it creates \"imposter\"\n**     tables using the SQLITE_TESTCTRL_IMPOSTER interface that it uses\n**     to update each b-tree individually. All updates required by each\n**     b-tree are completed before moving on to the next, and all\n**     updates are done in sorted key order.\n** \n**  2) The \"<database>-oal\" file is moved to the equivalent \"<database>-wal\"\n**     location using a call to rename(2). Before doing this the RBU\n**     module takes an EXCLUSIVE lock on the database file, ensuring\n**     that there are no other active readers.\n** \n**     Once the EXCLUSIVE lock is released, any other database readers\n**     detect the new *-wal file and read the database in wal mode. At\n**     this point they see the new version of the database - including\n**     the updates made as part of the RBU update.\n** \n**  3) The new *-wal file is checkpointed. This proceeds in the same way \n**     as a regular database checkpoint, except that a single frame is\n**     checkpointed each time sqlite3rbu_step() is called. If the RBU\n**     handle is closed before the entire *-wal file is checkpointed,\n**     the checkpoint progress is saved in the RBU database and the\n**     checkpoint can be resumed by another RBU client at some point in\n**     the future.\n**\n** POTENTIAL PROBLEMS\n** \n**  The rename() call might not be portable. And RBU is not currently\n**  syncing the directory after renaming the file.\n**\n**  When state is saved, any commit to the *-oal file and the commit to\n**  the RBU update database are not atomic. So if the power fails at the\n**  wrong moment they might get out of sync. As the main database will be\n**  committed before the RBU update database this will likely either just\n**  pass unnoticed, or result in SQLITE_CONSTRAINT errors (due to UNIQUE\n**  constraint violations).\n**\n**  If some client does modify the target database mid RBU update, or some\n**  other error occurs, the RBU extension will keep throwing errors. It's\n**  not really clear how to get out of this state. The system could just\n**  by delete the RBU update database and *-oal file and have the device\n**  download the update again and start over.\n**\n**  At present, for an UPDATE, both the new.* and old.* records are\n**  collected in the rbu_xyz table. And for both UPDATEs and DELETEs all\n**  fields are collected.  This means we're probably writing a lot more\n**  data to disk when saving the state of an ongoing update to the RBU\n**  update database than is strictly necessary.\n** \n*/\n\n#include <assert.h>\n#include <string.h>\n#include <stdio.h>\n\n#include \"sqlite3.h\"\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)\n#include \"sqlite3rbu.h\"\n\n#if defined(_WIN32_WCE)\n#include \"windows.h\"\n#endif\n\n/* Maximum number of prepared UPDATE statements held by this module */\n#define SQLITE_RBU_UPDATE_CACHESIZE 16\n\n/* Delta checksums disabled by default.  Compile with -DRBU_ENABLE_DELTA_CKSUM\n** to enable checksum verification.\n*/\n#ifndef RBU_ENABLE_DELTA_CKSUM\n# define RBU_ENABLE_DELTA_CKSUM 0\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#if !defined(SQLITE_AMALGAMATION)\n# define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n#endif\n\n/*\n** The rbu_state table is used to save the state of a partially applied\n** update so that it can be resumed later. The table consists of integer\n** keys mapped to values as follows:\n**\n** RBU_STATE_STAGE:\n**   May be set to integer values 1, 2, 4 or 5. As follows:\n**       1: the *-rbu file is currently under construction.\n**       2: the *-rbu file has been constructed, but not yet moved \n**          to the *-wal path.\n**       4: the checkpoint is underway.\n**       5: the rbu update has been checkpointed.\n**\n** RBU_STATE_TBL:\n**   Only valid if STAGE==1. The target database name of the table \n**   currently being written.\n**\n** RBU_STATE_IDX:\n**   Only valid if STAGE==1. The target database name of the index \n**   currently being written, or NULL if the main table is currently being\n**   updated.\n**\n** RBU_STATE_ROW:\n**   Only valid if STAGE==1. Number of rows already processed for the current\n**   table/index.\n**\n** RBU_STATE_PROGRESS:\n**   Trbul number of sqlite3rbu_step() calls made so far as part of this\n**   rbu update.\n**\n** RBU_STATE_CKPT:\n**   Valid if STAGE==4. The 64-bit checksum associated with the wal-index\n**   header created by recovering the *-wal file. This is used to detect\n**   cases when another client appends frames to the *-wal file in the\n**   middle of an incremental checkpoint (an incremental checkpoint cannot\n**   be continued if this happens).\n**\n** RBU_STATE_COOKIE:\n**   Valid if STAGE==1. The current change-counter cookie value in the \n**   target db file.\n**\n** RBU_STATE_OALSZ:\n**   Valid if STAGE==1. The size in bytes of the *-oal file.\n*/\n#define RBU_STATE_STAGE        1\n#define RBU_STATE_TBL          2\n#define RBU_STATE_IDX          3\n#define RBU_STATE_ROW          4\n#define RBU_STATE_PROGRESS     5\n#define RBU_STATE_CKPT         6\n#define RBU_STATE_COOKIE       7\n#define RBU_STATE_OALSZ        8\n#define RBU_STATE_PHASEONESTEP 9\n\n#define RBU_STAGE_OAL         1\n#define RBU_STAGE_MOVE        2\n#define RBU_STAGE_CAPTURE     3\n#define RBU_STAGE_CKPT        4\n#define RBU_STAGE_DONE        5\n\n\n#define RBU_CREATE_STATE \\\n  \"CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\"\n\ntypedef struct RbuFrame RbuFrame;\ntypedef struct RbuObjIter RbuObjIter;\ntypedef struct RbuState RbuState;\ntypedef struct rbu_vfs rbu_vfs;\ntypedef struct rbu_file rbu_file;\ntypedef struct RbuUpdateStmt RbuUpdateStmt;\n\n#if !defined(SQLITE_AMALGAMATION)\ntypedef unsigned int u32;\ntypedef unsigned short u16;\ntypedef unsigned char u8;\ntypedef sqlite3_int64 i64;\n#endif\n\n/*\n** These values must match the values defined in wal.c for the equivalent\n** locks. These are not magic numbers as they are part of the SQLite file\n** format.\n*/\n#define WAL_LOCK_WRITE  0\n#define WAL_LOCK_CKPT   1\n#define WAL_LOCK_READ0  3\n\n#define SQLITE_FCNTL_RBUCNT    5149216\n\n/*\n** A structure to store values read from the rbu_state table in memory.\n*/\nstruct RbuState {\n  int eStage;\n  char *zTbl;\n  char *zIdx;\n  i64 iWalCksum;\n  int nRow;\n  i64 nProgress;\n  u32 iCookie;\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n};\n\nstruct RbuUpdateStmt {\n  char *zMask;                    /* Copy of update mask used with pUpdate */\n  sqlite3_stmt *pUpdate;          /* Last update statement (or NULL) */\n  RbuUpdateStmt *pNext;\n};\n\n/*\n** An iterator of this type is used to iterate through all objects in\n** the target database that require updating. For each such table, the\n** iterator visits, in order:\n**\n**     * the table itself, \n**     * each index of the table (zero or more points to visit), and\n**     * a special \"cleanup table\" state.\n**\n** abIndexed:\n**   If the table has no indexes on it, abIndexed is set to NULL. Otherwise,\n**   it points to an array of flags nTblCol elements in size. The flag is\n**   set for each column that is either a part of the PK or a part of an\n**   index. Or clear otherwise.\n**   \n*/\nstruct RbuObjIter {\n  sqlite3_stmt *pTblIter;         /* Iterate through tables */\n  sqlite3_stmt *pIdxIter;         /* Index iterator */\n  int nTblCol;                    /* Size of azTblCol[] array */\n  char **azTblCol;                /* Array of unquoted target column names */\n  char **azTblType;               /* Array of target column types */\n  int *aiSrcOrder;                /* src table col -> target table col */\n  u8 *abTblPk;                    /* Array of flags, set on target PK columns */\n  u8 *abNotNull;                  /* Array of flags, set on NOT NULL columns */\n  u8 *abIndexed;                  /* Array of flags, set on indexed & PK cols */\n  int eType;                      /* Table type - an RBU_PK_XXX value */\n\n  /* Output variables. zTbl==0 implies EOF. */\n  int bCleanup;                   /* True in \"cleanup\" state */\n  const char *zTbl;               /* Name of target db table */\n  const char *zDataTbl;           /* Name of rbu db table (or null) */\n  const char *zIdx;               /* Name of target db index (or null) */\n  int iTnum;                      /* Root page of current object */\n  int iPkTnum;                    /* If eType==EXTERNAL, root of PK index */\n  int bUnique;                    /* Current index is unique */\n  int nIndex;                     /* Number of aux. indexes on table zTbl */\n\n  /* Statements created by rbuObjIterPrepareAll() */\n  int nCol;                       /* Number of columns in current object */\n  sqlite3_stmt *pSelect;          /* Source data */\n  sqlite3_stmt *pInsert;          /* Statement for INSERT operations */\n  sqlite3_stmt *pDelete;          /* Statement for DELETE ops */\n  sqlite3_stmt *pTmpInsert;       /* Insert into rbu_tmp_$zDataTbl */\n\n  /* Last UPDATE used (for PK b-tree updates only), or NULL. */\n  RbuUpdateStmt *pRbuUpdate;\n};\n\n/*\n** Values for RbuObjIter.eType\n**\n**     0: Table does not exist (error)\n**     1: Table has an implicit rowid.\n**     2: Table has an explicit IPK column.\n**     3: Table has an external PK index.\n**     4: Table is WITHOUT ROWID.\n**     5: Table is a virtual table.\n*/\n#define RBU_PK_NOTABLE        0\n#define RBU_PK_NONE           1\n#define RBU_PK_IPK            2\n#define RBU_PK_EXTERNAL       3\n#define RBU_PK_WITHOUT_ROWID  4\n#define RBU_PK_VTAB           5\n\n\n/*\n** Within the RBU_STAGE_OAL stage, each call to sqlite3rbu_step() performs\n** one of the following operations.\n*/\n#define RBU_INSERT     1          /* Insert on a main table b-tree */\n#define RBU_DELETE     2          /* Delete a row from a main table b-tree */\n#define RBU_REPLACE    3          /* Delete and then insert a row */\n#define RBU_IDX_DELETE 4          /* Delete a row from an aux. index b-tree */\n#define RBU_IDX_INSERT 5          /* Insert on an aux. index b-tree */\n\n#define RBU_UPDATE     6          /* Update a row in a main table b-tree */\n\n/*\n** A single step of an incremental checkpoint - frame iWalFrame of the wal\n** file should be copied to page iDbPage of the database file.\n*/\nstruct RbuFrame {\n  u32 iDbPage;\n  u32 iWalFrame;\n};\n\n/*\n** RBU handle.\n**\n** nPhaseOneStep:\n**   If the RBU database contains an rbu_count table, this value is set to\n**   a running estimate of the number of b-tree operations required to \n**   finish populating the *-oal file. This allows the sqlite3_bp_progress()\n**   API to calculate the permyriadage progress of populating the *-oal file\n**   using the formula:\n**\n**     permyriadage = (10000 * nProgress) / nPhaseOneStep\n**\n**   nPhaseOneStep is initialized to the sum of:\n**\n**     nRow * (nIndex + 1)\n**\n**   for all source tables in the RBU database, where nRow is the number\n**   of rows in the source table and nIndex the number of indexes on the\n**   corresponding target database table.\n**\n**   This estimate is accurate if the RBU update consists entirely of\n**   INSERT operations. However, it is inaccurate if:\n**\n**     * the RBU update contains any UPDATE operations. If the PK specified\n**       for an UPDATE operation does not exist in the target table, then\n**       no b-tree operations are required on index b-trees. Or if the \n**       specified PK does exist, then (nIndex*2) such operations are\n**       required (one delete and one insert on each index b-tree).\n**\n**     * the RBU update contains any DELETE operations for which the specified\n**       PK does not exist. In this case no operations are required on index\n**       b-trees.\n**\n**     * the RBU update contains REPLACE operations. These are similar to\n**       UPDATE operations.\n**\n**   nPhaseOneStep is updated to account for the conditions above during the\n**   first pass of each source table. The updated nPhaseOneStep value is\n**   stored in the rbu_state table if the RBU update is suspended.\n*/\nstruct sqlite3rbu {\n  int eStage;                     /* Value of RBU_STATE_STAGE field */\n  sqlite3 *dbMain;                /* target database handle */\n  sqlite3 *dbRbu;                 /* rbu database handle */\n  char *zTarget;                  /* Path to target db */\n  char *zRbu;                     /* Path to rbu db */\n  char *zState;                   /* Path to state db (or NULL if zRbu) */\n  char zStateDb[5];               /* Db name for state (\"stat\" or \"main\") */\n  int rc;                         /* Value returned by last rbu_step() call */\n  char *zErrmsg;                  /* Error message if rc!=SQLITE_OK */\n  int nStep;                      /* Rows processed for current object */\n  int nProgress;                  /* Rows processed for all objects */\n  RbuObjIter objiter;             /* Iterator for skipping through tbl/idx */\n  const char *zVfsName;           /* Name of automatically created rbu vfs */\n  rbu_file *pTargetFd;            /* File handle open on target db */\n  int nPagePerSector;             /* Pages per sector for pTargetFd */\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n\n  /* The following state variables are used as part of the incremental\n  ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding\n  ** function rbuSetupCheckpoint() for details.  */\n  u32 iMaxFrame;                  /* Largest iWalFrame value in aFrame[] */\n  u32 mLock;\n  int nFrame;                     /* Entries in aFrame[] array */\n  int nFrameAlloc;                /* Allocated size of aFrame[] array */\n  RbuFrame *aFrame;\n  int pgsz;\n  u8 *aBuf;\n  i64 iWalCksum;\n  i64 szTemp;                     /* Current size of all temp files in use */\n  i64 szTempLimit;                /* Total size limit for temp files */\n\n  /* Used in RBU vacuum mode only */\n  int nRbu;                       /* Number of RBU VFS in the stack */\n  rbu_file *pRbuFd;               /* Fd for main db of dbRbu */\n};\n\n/*\n** An rbu VFS is implemented using an instance of this structure.\n**\n** Variable pRbu is only non-NULL for automatically created RBU VFS objects.\n** It is NULL for RBU VFS objects created explicitly using\n** sqlite3rbu_create_vfs(). It is used to track the total amount of temp\n** space used by the RBU handle.\n*/\nstruct rbu_vfs {\n  sqlite3_vfs base;               /* rbu VFS shim methods */\n  sqlite3_vfs *pRealVfs;          /* Underlying VFS */\n  sqlite3_mutex *mutex;           /* Mutex to protect pMain */\n  sqlite3rbu *pRbu;               /* Owner RBU object */\n  rbu_file *pMain;                /* Linked list of main db files */\n};\n\n/*\n** Each file opened by an rbu VFS is represented by an instance of\n** the following structure.\n**\n** If this is a temporary file (pRbu!=0 && flags&DELETE_ON_CLOSE), variable\n** \"sz\" is set to the current size of the database file.\n*/\nstruct rbu_file {\n  sqlite3_file base;              /* sqlite3_file methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  rbu_vfs *pRbuVfs;               /* Pointer to the rbu_vfs object */\n  sqlite3rbu *pRbu;               /* Pointer to rbu object (rbu target only) */\n  i64 sz;                         /* Size of file in bytes (temp only) */\n\n  int openFlags;                  /* Flags this file was opened with */\n  u32 iCookie;                    /* Cookie value for main db files */\n  u8 iWriteVer;                   /* \"write-version\" value for main db files */\n  u8 bNolock;                     /* True to fail EXCLUSIVE locks */\n\n  int nShm;                       /* Number of entries in apShm[] array */\n  char **apShm;                   /* Array of mmap'd *-shm regions */\n  char *zDel;                     /* Delete this when closing file */\n\n  const char *zWal;               /* Wal filename for this main db file */\n  rbu_file *pWalFd;               /* Wal file descriptor for this main db */\n  rbu_file *pMainNext;            /* Next MAIN_DB file */\n};\n\n/*\n** True for an RBU vacuum handle, or false otherwise.\n*/\n#define rbuIsVacuum(p) ((p)->zTarget==0)\n\n\n/*************************************************************************\n** The following three functions, found below:\n**\n**   rbuDeltaGetInt()\n**   rbuDeltaChecksum()\n**   rbuDeltaApply()\n**\n** are lifted from the fossil source code (http://fossil-scm.org). They\n** are used to implement the scalar SQL function rbu_fossil_delta().\n*/\n\n/*\n** Read bytes from *pz and convert them into a positive integer.  When\n** finished, leave *pz pointing to the first character past the end of\n** the integer.  The *pLen parameter holds the length of the string\n** in *pz and is decremented once for each character in the integer.\n*/\nstatic unsigned int rbuDeltaGetInt(const char **pz, int *pLen){\n  static const signed char zValue[] = {\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n     0,  1,  2,  3,  4,  5,  6,  7,    8,  9, -1, -1, -1, -1, -1, -1,\n    -1, 10, 11, 12, 13, 14, 15, 16,   17, 18, 19, 20, 21, 22, 23, 24,\n    25, 26, 27, 28, 29, 30, 31, 32,   33, 34, 35, -1, -1, -1, -1, 36,\n    -1, 37, 38, 39, 40, 41, 42, 43,   44, 45, 46, 47, 48, 49, 50, 51,\n    52, 53, 54, 55, 56, 57, 58, 59,   60, 61, 62, -1, -1, -1, 63, -1,\n  };\n  unsigned int v = 0;\n  int c;\n  unsigned char *z = (unsigned char*)*pz;\n  unsigned char *zStart = z;\n  while( (c = zValue[0x7f&*(z++)])>=0 ){\n     v = (v<<6) + c;\n  }\n  z--;\n  *pLen -= z - zStart;\n  *pz = (char*)z;\n  return v;\n}\n\n#if RBU_ENABLE_DELTA_CKSUM\n/*\n** Compute a 32-bit checksum on the N-byte buffer.  Return the result.\n*/\nstatic unsigned int rbuDeltaChecksum(const char *zIn, size_t N){\n  const unsigned char *z = (const unsigned char *)zIn;\n  unsigned sum0 = 0;\n  unsigned sum1 = 0;\n  unsigned sum2 = 0;\n  unsigned sum3 = 0;\n  while(N >= 16){\n    sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);\n    sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);\n    sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);\n    sum3 += ((unsigned)z[3] + z[7] + z[11]+ z[15]);\n    z += 16;\n    N -= 16;\n  }\n  while(N >= 4){\n    sum0 += z[0];\n    sum1 += z[1];\n    sum2 += z[2];\n    sum3 += z[3];\n    z += 4;\n    N -= 4;\n  }\n  sum3 += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);\n  switch(N){\n    case 3:   sum3 += (z[2] << 8);\n    case 2:   sum3 += (z[1] << 16);\n    case 1:   sum3 += (z[0] << 24);\n    default:  ;\n  }\n  return sum3;\n}\n#endif\n\n/*\n** Apply a delta.\n**\n** The output buffer should be big enough to hold the whole output\n** file and a NUL terminator at the end.  The delta_output_size()\n** routine will determine this size for you.\n**\n** The delta string should be null-terminated.  But the delta string\n** may contain embedded NUL characters (if the input and output are\n** binary files) so we also have to pass in the length of the delta in\n** the lenDelta parameter.\n**\n** This function returns the size of the output file in bytes (excluding\n** the final NUL terminator character).  Except, if the delta string is\n** malformed or intended for use with a source file other than zSrc,\n** then this routine returns -1.\n**\n** Refer to the delta_create() documentation above for a description\n** of the delta file format.\n*/\nstatic int rbuDeltaApply(\n  const char *zSrc,      /* The source or pattern file */\n  int lenSrc,            /* Length of the source file */\n  const char *zDelta,    /* Delta to apply to the pattern */\n  int lenDelta,          /* Length of the delta */\n  char *zOut             /* Write the output into this preallocated buffer */\n){\n  unsigned int limit;\n  unsigned int total = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n  char *zOrigOut = zOut;\n#endif\n\n  limit = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  zDelta++; lenDelta--;\n  while( *zDelta && lenDelta>0 ){\n    unsigned int cnt, ofst;\n    cnt = rbuDeltaGetInt(&zDelta, &lenDelta);\n    switch( zDelta[0] ){\n      case '@': {\n        zDelta++; lenDelta--;\n        ofst = rbuDeltaGetInt(&zDelta, &lenDelta);\n        if( lenDelta>0 && zDelta[0]!=',' ){\n          /* ERROR: copy command not terminated by ',' */\n          return -1;\n        }\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR: copy exceeds output file size */\n          return -1;\n        }\n        if( (int)(ofst+cnt) > lenSrc ){\n          /* ERROR: copy extends past end of input */\n          return -1;\n        }\n        memcpy(zOut, &zSrc[ofst], cnt);\n        zOut += cnt;\n        break;\n      }\n      case ':': {\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR:  insert command gives an output larger than predicted */\n          return -1;\n        }\n        if( (int)cnt>lenDelta ){\n          /* ERROR: insert count exceeds size of delta */\n          return -1;\n        }\n        memcpy(zOut, zDelta, cnt);\n        zOut += cnt;\n        zDelta += cnt;\n        lenDelta -= cnt;\n        break;\n      }\n      case ';': {\n        zDelta++; lenDelta--;\n        zOut[0] = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n        if( cnt!=rbuDeltaChecksum(zOrigOut, total) ){\n          /* ERROR:  bad checksum */\n          return -1;\n        }\n#endif\n        if( total!=limit ){\n          /* ERROR: generated size does not match predicted size */\n          return -1;\n        }\n        return total;\n      }\n      default: {\n        /* ERROR: unknown delta operator */\n        return -1;\n      }\n    }\n  }\n  /* ERROR: unterminated delta */\n  return -1;\n}\n\nstatic int rbuDeltaOutputSize(const char *zDelta, int lenDelta){\n  int size;\n  size = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  return size;\n}\n\n/*\n** End of code taken from fossil.\n*************************************************************************/\n\n/*\n** Implementation of SQL scalar function rbu_fossil_delta().\n**\n** This function applies a fossil delta patch to a blob. Exactly two\n** arguments must be passed to this function. The first is the blob to\n** patch and the second the patch to apply. If no error occurs, this\n** function returns the patched blob.\n*/\nstatic void rbuFossilDeltaFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *aDelta;\n  int nDelta;\n  const char *aOrig;\n  int nOrig;\n\n  int nOut;\n  int nOut2;\n  char *aOut;\n\n  assert( argc==2 );\n\n  nOrig = sqlite3_value_bytes(argv[0]);\n  aOrig = (const char*)sqlite3_value_blob(argv[0]);\n  nDelta = sqlite3_value_bytes(argv[1]);\n  aDelta = (const char*)sqlite3_value_blob(argv[1]);\n\n  /* Figure out the size of the output */\n  nOut = rbuDeltaOutputSize(aDelta, nDelta);\n  if( nOut<0 ){\n    sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    return;\n  }\n\n  aOut = sqlite3_malloc(nOut+1);\n  if( aOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    nOut2 = rbuDeltaApply(aOrig, nOrig, aDelta, nDelta, aOut);\n    if( nOut2!=nOut ){\n      sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    }else{\n      sqlite3_result_blob(context, aOut, nOut, sqlite3_free);\n    }\n  }\n}\n\n\n/*\n** Prepare the SQL statement in buffer zSql against database handle db.\n** If successful, set *ppStmt to point to the new statement and return\n** SQLITE_OK. \n**\n** Otherwise, if an error does occur, set *ppStmt to NULL and return\n** an SQLite error code. Additionally, set output variable *pzErrmsg to\n** point to a buffer containing an error message. It is the responsibility\n** of the caller to (eventually) free this buffer using sqlite3_free().\n*/\nstatic int prepareAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  const char *zSql\n){\n  int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    *ppStmt = 0;\n  }\n  return rc;\n}\n\n/*\n** Reset the SQL statement passed as the first argument. Return a copy\n** of the value returned by sqlite3_reset().\n**\n** If an error has occurred, then set *pzErrmsg to point to a buffer\n** containing an error message. It is the responsibility of the caller\n** to eventually free this buffer using sqlite3_free().\n*/\nstatic int resetAndCollectError(sqlite3_stmt *pStmt, char **pzErrmsg){\n  int rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(sqlite3_db_handle(pStmt)));\n  }\n  return rc;\n}\n\n/*\n** Unless it is NULL, argument zSql points to a buffer allocated using\n** sqlite3_malloc containing an SQL statement. This function prepares the SQL\n** statement against database db and frees the buffer. If statement \n** compilation is successful, *ppStmt is set to point to the new statement \n** handle and SQLITE_OK is returned. \n**\n** Otherwise, if an error occurs, *ppStmt is set to NULL and an error code\n** returned. In this case, *pzErrmsg may also be set to point to an error\n** message. It is the responsibility of the caller to free this error message\n** buffer using sqlite3_free().\n**\n** If argument zSql is NULL, this function assumes that an OOM has occurred.\n** In this case SQLITE_NOMEM is returned and *ppStmt set to NULL.\n*/\nstatic int prepareFreeAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  char *zSql\n){\n  int rc;\n  assert( *pzErrmsg==0 );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n    *ppStmt = 0;\n  }else{\n    rc = prepareAndCollectError(db, ppStmt, pzErrmsg, zSql);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** Free the RbuObjIter.azTblCol[] and RbuObjIter.abTblPk[] arrays allocated\n** by an earlier call to rbuObjIterCacheTableInfo().\n*/\nstatic void rbuObjIterFreeCols(RbuObjIter *pIter){\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    sqlite3_free(pIter->azTblCol[i]);\n    sqlite3_free(pIter->azTblType[i]);\n  }\n  sqlite3_free(pIter->azTblCol);\n  pIter->azTblCol = 0;\n  pIter->azTblType = 0;\n  pIter->aiSrcOrder = 0;\n  pIter->abTblPk = 0;\n  pIter->abNotNull = 0;\n  pIter->nTblCol = 0;\n  pIter->eType = 0;               /* Invalid value */\n}\n\n/*\n** Finalize all statements and free all allocations that are specific to\n** the current object (table/index pair).\n*/\nstatic void rbuObjIterClearStatements(RbuObjIter *pIter){\n  RbuUpdateStmt *pUp;\n\n  sqlite3_finalize(pIter->pSelect);\n  sqlite3_finalize(pIter->pInsert);\n  sqlite3_finalize(pIter->pDelete);\n  sqlite3_finalize(pIter->pTmpInsert);\n  pUp = pIter->pRbuUpdate;\n  while( pUp ){\n    RbuUpdateStmt *pTmp = pUp->pNext;\n    sqlite3_finalize(pUp->pUpdate);\n    sqlite3_free(pUp);\n    pUp = pTmp;\n  }\n  \n  pIter->pSelect = 0;\n  pIter->pInsert = 0;\n  pIter->pDelete = 0;\n  pIter->pRbuUpdate = 0;\n  pIter->pTmpInsert = 0;\n  pIter->nCol = 0;\n}\n\n/*\n** Clean up any resources allocated as part of the iterator object passed\n** as the only argument.\n*/\nstatic void rbuObjIterFinalize(RbuObjIter *pIter){\n  rbuObjIterClearStatements(pIter);\n  sqlite3_finalize(pIter->pTblIter);\n  sqlite3_finalize(pIter->pIdxIter);\n  rbuObjIterFreeCols(pIter);\n  memset(pIter, 0, sizeof(RbuObjIter));\n}\n\n/*\n** Advance the iterator to the next position.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the next entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc = p->rc;\n  if( rc==SQLITE_OK ){\n\n    /* Free any SQLite statements used while processing the previous object */ \n    rbuObjIterClearStatements(pIter);\n    if( pIter->zIdx==0 ){\n      rc = sqlite3_exec(p->dbMain,\n          \"DROP TRIGGER IF EXISTS temp.rbu_insert_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update1_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update2_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\"\n          , 0, 0, &p->zErrmsg\n      );\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIter->bCleanup ){\n        rbuObjIterFreeCols(pIter);\n        pIter->bCleanup = 0;\n        rc = sqlite3_step(pIter->pTblIter);\n        if( rc!=SQLITE_ROW ){\n          rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);\n          pIter->zTbl = 0;\n        }else{\n          pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0);\n          pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1);\n          rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM;\n        }\n      }else{\n        if( pIter->zIdx==0 ){\n          sqlite3_stmt *pIdx = pIter->pIdxIter;\n          rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3_step(pIter->pIdxIter);\n          if( rc!=SQLITE_ROW ){\n            rc = resetAndCollectError(pIter->pIdxIter, &p->zErrmsg);\n            pIter->bCleanup = 1;\n            pIter->zIdx = 0;\n          }else{\n            pIter->zIdx = (const char*)sqlite3_column_text(pIter->pIdxIter, 0);\n            pIter->iTnum = sqlite3_column_int(pIter->pIdxIter, 1);\n            pIter->bUnique = sqlite3_column_int(pIter->pIdxIter, 2);\n            rc = pIter->zIdx ? SQLITE_OK : SQLITE_NOMEM;\n          }\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    rbuObjIterFinalize(pIter);\n    p->rc = rc;\n  }\n  return rc;\n}\n\n\n/*\n** The implementation of the rbu_target_name() SQL function. This function\n** accepts one or two arguments. The first argument is the name of a table -\n** the name of a table in the RBU database.  The second, if it is present, is 1\n** for a view or 0 for a table. \n**\n** For a non-vacuum RBU handle, if the table name matches the pattern:\n**\n**     data[0-9]_<name>\n**\n** where <name> is any sequence of 1 or more characters, <name> is returned.\n** Otherwise, if the only argument does not match the above pattern, an SQL\n** NULL is returned.\n**\n**     \"data_t1\"     -> \"t1\"\n**     \"data0123_t2\" -> \"t2\"\n**     \"dataAB_t3\"   -> NULL\n**\n** For an rbu vacuum handle, a copy of the first argument is returned if\n** the second argument is either missing or 0 (not a view).\n*/\nstatic void rbuTargetNameFunc(\n  sqlite3_context *pCtx,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  const char *zIn;\n  assert( argc==1 || argc==2 );\n\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  if( zIn ){\n    if( rbuIsVacuum(p) ){\n      if( argc==1 || 0==sqlite3_value_int(argv[1]) ){\n        sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);\n      }\n    }else{\n      if( strlen(zIn)>4 && memcmp(\"data\", zIn, 4)==0 ){\n        int i;\n        for(i=4; zIn[i]>='0' && zIn[i]<='9'; i++);\n        if( zIn[i]=='_' && zIn[i+1] ){\n          sqlite3_result_text(pCtx, &zIn[i+1], -1, SQLITE_STATIC);\n        }\n      }\n    }\n  }\n}\n\n/*\n** Initialize the iterator structure passed as the second argument.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the first entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc;\n  memset(pIter, 0, sizeof(RbuObjIter));\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, \n    sqlite3_mprintf(\n      \"SELECT rbu_target_name(name, type='view') AS target, name \"\n      \"FROM sqlite_master \"\n      \"WHERE type IN ('table', 'view') AND target IS NOT NULL \"\n      \" %s \"\n      \"ORDER BY name\"\n  , rbuIsVacuum(p) ? \"AND rootpage!=0 AND rootpage IS NOT NULL\" : \"\"));\n\n  if( rc==SQLITE_OK ){\n    rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,\n        \"SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' \"\n        \"  FROM main.sqlite_master \"\n        \"  WHERE type='index' AND tbl_name = ?\"\n    );\n  }\n\n  pIter->bCleanup = 1;\n  p->rc = rc;\n  return rbuObjIterNext(p, pIter);\n}\n\n/*\n** This is a wrapper around \"sqlite3_mprintf(zFmt, ...)\". If an OOM occurs,\n** an error code is stored in the RBU handle passed as the first argument.\n**\n** If an error has already occurred (p->rc is already set to something other\n** than SQLITE_OK), then this function returns NULL without modifying the\n** stored error code. In this case it still calls sqlite3_free() on any \n** printf() parameters associated with %z conversions.\n*/\nstatic char *rbuMPrintf(sqlite3rbu *p, const char *zFmt, ...){\n  char *zSql = 0;\n  va_list ap;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ) p->rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_free(zSql);\n    zSql = 0;\n  }\n  va_end(ap);\n  return zSql;\n}\n\n/*\n** Argument zFmt is a sqlite3_mprintf() style format string. The trailing\n** arguments are the usual subsitution values. This function performs\n** the printf() style substitutions and executes the result as an SQL\n** statement on the RBU handles database.\n**\n** If an error occurs, an error code and error message is stored in the\n** RBU handle. If an error has already occurred when this function is\n** called, it is a no-op.\n*/\nstatic int rbuMPrintfExec(sqlite3rbu *p, sqlite3 *db, const char *zFmt, ...){\n  va_list ap;\n  char *zSql;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      p->rc = sqlite3_exec(db, zSql, 0, 0, &p->zErrmsg);\n    }\n  }\n  sqlite3_free(zSql);\n  va_end(ap);\n  return p->rc;\n}\n\n/*\n** Attempt to allocate and return a pointer to a zeroed block of nByte \n** bytes. \n**\n** If an error (i.e. an OOM condition) occurs, return NULL and leave an \n** error code in the rbu handle passed as the first argument. Or, if an \n** error has already occurred when this function is called, return NULL \n** immediately without attempting the allocation or modifying the stored\n** error code.\n*/\nstatic void *rbuMalloc(sqlite3rbu *p, int nByte){\n  void *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    assert( nByte>0 );\n    pRet = sqlite3_malloc64(nByte);\n    if( pRet==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n\n/*\n** Allocate and zero the pIter->azTblCol[] and abTblPk[] arrays so that\n** there is room for at least nCol elements. If an OOM occurs, store an\n** error code in the RBU handle passed as the first argument.\n*/\nstatic void rbuAllocateIterArrays(sqlite3rbu *p, RbuObjIter *pIter, int nCol){\n  int nByte = (2*sizeof(char*) + sizeof(int) + 3*sizeof(u8)) * nCol;\n  char **azNew;\n\n  azNew = (char**)rbuMalloc(p, nByte);\n  if( azNew ){\n    pIter->azTblCol = azNew;\n    pIter->azTblType = &azNew[nCol];\n    pIter->aiSrcOrder = (int*)&pIter->azTblType[nCol];\n    pIter->abTblPk = (u8*)&pIter->aiSrcOrder[nCol];\n    pIter->abNotNull = (u8*)&pIter->abTblPk[nCol];\n    pIter->abIndexed = (u8*)&pIter->abNotNull[nCol];\n  }\n}\n\n/*\n** The first argument must be a nul-terminated string. This function\n** returns a copy of the string in memory obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free this memory\n** using sqlite3_free().\n**\n** If an OOM condition is encountered when attempting to allocate memory,\n** output variable (*pRc) is set to SQLITE_NOMEM before returning. Otherwise,\n** if the allocation succeeds, (*pRc) is left unchanged.\n*/\nstatic char *rbuStrndup(const char *zStr, int *pRc){\n  char *zRet = 0;\n\n  assert( *pRc==SQLITE_OK );\n  if( zStr ){\n    size_t nCopy = strlen(zStr) + 1;\n    zRet = (char*)sqlite3_malloc64(nCopy);\n    if( zRet ){\n      memcpy(zRet, zStr, nCopy);\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** Finalize the statement passed as the second argument.\n**\n** If the sqlite3_finalize() call indicates that an error occurs, and the\n** rbu handle error code is not already set, set the error code and error\n** message accordingly.\n*/\nstatic void rbuFinalize(sqlite3rbu *p, sqlite3_stmt *pStmt){\n  sqlite3 *db = sqlite3_db_handle(pStmt);\n  int rc = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){\n    p->rc = rc;\n    p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n}\n\n/* Determine the type of a table.\n**\n**   peType is of type (int*), a pointer to an output parameter of type\n**   (int). This call sets the output parameter as follows, depending\n**   on the type of the table specified by parameters dbName and zTbl.\n**\n**     RBU_PK_NOTABLE:       No such table.\n**     RBU_PK_NONE:          Table has an implicit rowid.\n**     RBU_PK_IPK:           Table has an explicit IPK column.\n**     RBU_PK_EXTERNAL:      Table has an external PK index.\n**     RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID.\n**     RBU_PK_VTAB:          Table is a virtual table.\n**\n**   Argument *piPk is also of type (int*), and also points to an output\n**   parameter. Unless the table has an external primary key index \n**   (i.e. unless *peType is set to 3), then *piPk is set to zero. Or,\n**   if the table does have an external primary key index, then *piPk\n**   is set to the root page number of the primary key index before\n**   returning.\n**\n** ALGORITHM:\n**\n**   if( no entry exists in sqlite_master ){\n**     return RBU_PK_NOTABLE\n**   }else if( sql for the entry starts with \"CREATE VIRTUAL\" ){\n**     return RBU_PK_VTAB\n**   }else if( \"PRAGMA index_list()\" for the table contains a \"pk\" index ){\n**     if( the index that is the pk exists in sqlite_master ){\n**       *piPK = rootpage of that index.\n**       return RBU_PK_EXTERNAL\n**     }else{\n**       return RBU_PK_WITHOUT_ROWID\n**     }\n**   }else if( \"PRAGMA table_info()\" lists one or more \"pk\" columns ){\n**     return RBU_PK_IPK\n**   }else{\n**     return RBU_PK_NONE\n**   }\n*/\nstatic void rbuTableType(\n  sqlite3rbu *p,\n  const char *zTab,\n  int *peType,\n  int *piTnum,\n  int *piPk\n){\n  /*\n  ** 0) SELECT count(*) FROM sqlite_master where name=%Q AND IsVirtual(%Q)\n  ** 1) PRAGMA index_list = ?\n  ** 2) SELECT count(*) FROM sqlite_master where name=%Q \n  ** 3) PRAGMA table_info = ?\n  */\n  sqlite3_stmt *aStmt[4] = {0, 0, 0, 0};\n\n  *peType = RBU_PK_NOTABLE;\n  *piPk = 0;\n\n  assert( p->rc==SQLITE_OK );\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg, \n    sqlite3_mprintf(\n          \"SELECT (sql LIKE 'create virtual%%'), rootpage\"\n          \"  FROM sqlite_master\"\n          \" WHERE name=%Q\", zTab\n  ));\n  if( p->rc!=SQLITE_OK || sqlite3_step(aStmt[0])!=SQLITE_ROW ){\n    /* Either an error, or no such table. */\n    goto rbuTableType_end;\n  }\n  if( sqlite3_column_int(aStmt[0], 0) ){\n    *peType = RBU_PK_VTAB;                     /* virtual table */\n    goto rbuTableType_end;\n  }\n  *piTnum = sqlite3_column_int(aStmt[0], 1);\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[1], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA index_list=%Q\",zTab)\n  );\n  if( p->rc ) goto rbuTableType_end;\n  while( sqlite3_step(aStmt[1])==SQLITE_ROW ){\n    const u8 *zOrig = sqlite3_column_text(aStmt[1], 3);\n    const u8 *zIdx = sqlite3_column_text(aStmt[1], 1);\n    if( zOrig && zIdx && zOrig[0]=='p' ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[2], &p->zErrmsg, \n          sqlite3_mprintf(\n            \"SELECT rootpage FROM sqlite_master WHERE name = %Q\", zIdx\n      ));\n      if( p->rc==SQLITE_OK ){\n        if( sqlite3_step(aStmt[2])==SQLITE_ROW ){\n          *piPk = sqlite3_column_int(aStmt[2], 0);\n          *peType = RBU_PK_EXTERNAL;\n        }else{\n          *peType = RBU_PK_WITHOUT_ROWID;\n        }\n      }\n      goto rbuTableType_end;\n    }\n  }\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[3], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA table_info=%Q\",zTab)\n  );\n  if( p->rc==SQLITE_OK ){\n    while( sqlite3_step(aStmt[3])==SQLITE_ROW ){\n      if( sqlite3_column_int(aStmt[3],5)>0 ){\n        *peType = RBU_PK_IPK;                /* explicit IPK column */\n        goto rbuTableType_end;\n      }\n    }\n    *peType = RBU_PK_NONE;\n  }\n\nrbuTableType_end: {\n    unsigned int i;\n    for(i=0; i<sizeof(aStmt)/sizeof(aStmt[0]); i++){\n      rbuFinalize(p, aStmt[i]);\n    }\n  }\n}\n\n/*\n** This is a helper function for rbuObjIterCacheTableInfo(). It populates\n** the pIter->abIndexed[] array.\n*/\nstatic void rbuObjIterCacheIndexedCols(sqlite3rbu *p, RbuObjIter *pIter){\n  sqlite3_stmt *pList = 0;\n  int bIndex = 0;\n\n  if( p->rc==SQLITE_OK ){\n    memcpy(pIter->abIndexed, pIter->abTblPk, sizeof(u8)*pIter->nTblCol);\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n  }\n\n  pIter->nIndex = 0;\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pList) ){\n    const char *zIdx = (const char*)sqlite3_column_text(pList, 1);\n    sqlite3_stmt *pXInfo = 0;\n    if( zIdx==0 ) break;\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int iCid = sqlite3_column_int(pXInfo, 1);\n      if( iCid>=0 ) pIter->abIndexed[iCid] = 1;\n    }\n    rbuFinalize(p, pXInfo);\n    bIndex = 1;\n    pIter->nIndex++;\n  }\n\n  if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n    /* \"PRAGMA index_list\" includes the main PK b-tree */\n    pIter->nIndex--;\n  }\n\n  rbuFinalize(p, pList);\n  if( bIndex==0 ) pIter->abIndexed = 0;\n}\n\n\n/*\n** If they are not already populated, populate the pIter->azTblCol[],\n** pIter->abTblPk[], pIter->nTblCol and pIter->bRowid variables according to\n** the table (not index) that the iterator currently points to.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. If\n** an error does occur, an error code and error message are also left in \n** the RBU handle.\n*/\nstatic int rbuObjIterCacheTableInfo(sqlite3rbu *p, RbuObjIter *pIter){\n  if( pIter->azTblCol==0 ){\n    sqlite3_stmt *pStmt = 0;\n    int nCol = 0;\n    int i;                        /* for() loop iterator variable */\n    int bRbuRowid = 0;            /* If input table has column \"rbu_rowid\" */\n    int iOrder = 0;\n    int iTnum = 0;\n\n    /* Figure out the type of table this step will deal with. */\n    assert( pIter->eType==0 );\n    rbuTableType(p, pIter->zTbl, &pIter->eType, &iTnum, &pIter->iPkTnum);\n    if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_NOTABLE ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"no such table: %s\", pIter->zTbl);\n    }\n    if( p->rc ) return p->rc;\n    if( pIter->zIdx==0 ) pIter->iTnum = iTnum;\n\n    assert( pIter->eType==RBU_PK_NONE || pIter->eType==RBU_PK_IPK \n         || pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_WITHOUT_ROWID\n         || pIter->eType==RBU_PK_VTAB\n    );\n\n    /* Populate the azTblCol[] and nTblCol variables based on the columns\n    ** of the input table. Ignore any input table columns that begin with\n    ** \"rbu_\".  */\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n        sqlite3_mprintf(\"SELECT * FROM '%q'\", pIter->zDataTbl)\n    );\n    if( p->rc==SQLITE_OK ){\n      nCol = sqlite3_column_count(pStmt);\n      rbuAllocateIterArrays(p, pIter, nCol);\n    }\n    for(i=0; p->rc==SQLITE_OK && i<nCol; i++){\n      const char *zName = (const char*)sqlite3_column_name(pStmt, i);\n      if( sqlite3_strnicmp(\"rbu_\", zName, 4) ){\n        char *zCopy = rbuStrndup(zName, &p->rc);\n        pIter->aiSrcOrder[pIter->nTblCol] = pIter->nTblCol;\n        pIter->azTblCol[pIter->nTblCol++] = zCopy;\n      }\n      else if( 0==sqlite3_stricmp(\"rbu_rowid\", zName) ){\n        bRbuRowid = 1;\n      }\n    }\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n\n    if( p->rc==SQLITE_OK\n     && rbuIsVacuum(p)==0\n     && bRbuRowid!=(pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE)\n    ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\n          \"table %q %s rbu_rowid column\", pIter->zDataTbl,\n          (bRbuRowid ? \"may not have\" : \"requires\")\n      );\n    }\n\n    /* Check that all non-HIDDEN columns in the destination table are also\n    ** present in the input table. Populate the abTblPk[], azTblType[] and\n    ** aiTblOrder[] arrays at the same time.  */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &p->zErrmsg, \n          sqlite3_mprintf(\"PRAGMA table_info(%Q)\", pIter->zTbl)\n      );\n    }\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;  /* An OOM - finalize() below returns S_NOMEM */\n      for(i=iOrder; i<pIter->nTblCol; i++){\n        if( 0==strcmp(zName, pIter->azTblCol[i]) ) break;\n      }\n      if( i==pIter->nTblCol ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"column missing from %q: %s\",\n            pIter->zDataTbl, zName\n        );\n      }else{\n        int iPk = sqlite3_column_int(pStmt, 5);\n        int bNotNull = sqlite3_column_int(pStmt, 3);\n        const char *zType = (const char*)sqlite3_column_text(pStmt, 2);\n\n        if( i!=iOrder ){\n          SWAP(int, pIter->aiSrcOrder[i], pIter->aiSrcOrder[iOrder]);\n          SWAP(char*, pIter->azTblCol[i], pIter->azTblCol[iOrder]);\n        }\n\n        pIter->azTblType[iOrder] = rbuStrndup(zType, &p->rc);\n        pIter->abTblPk[iOrder] = (iPk!=0);\n        pIter->abNotNull[iOrder] = (u8)bNotNull || (iPk!=0);\n        iOrder++;\n      }\n    }\n\n    rbuFinalize(p, pStmt);\n    rbuObjIterCacheIndexedCols(p, pIter);\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->abIndexed==0 );\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->nIndex==0 );\n  }\n\n  return p->rc;\n}\n\n/*\n** This function constructs and returns a pointer to a nul-terminated \n** string containing some SQL clause or list based on one or more of the \n** column names currently stored in the pIter->azTblCol[] array.\n*/\nstatic char *rbuObjIterGetCollist(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter               /* Object iterator for column names */\n){\n  char *zList = 0;\n  const char *zSep = \"\";\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    const char *z = pIter->azTblCol[i];\n    zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"\", zList, zSep, z);\n    zSep = \", \";\n  }\n  return zList;\n}\n\n/*\n** This function is used to create a SELECT list (the list of SQL \n** expressions that follows a SELECT keyword) for a SELECT statement \n** used to read from an data_xxx or rbu_tmp_xxx table while updating the \n** index object currently indicated by the iterator object passed as the \n** second argument. A \"PRAGMA index_xinfo = <idxname>\" statement is used \n** to obtain the required information.\n**\n** If the index is of the following form:\n**\n**   CREATE INDEX i1 ON t1(c, b COLLATE nocase);\n**\n** and \"t1\" is a table with an explicit INTEGER PRIMARY KEY column \n** \"ipk\", the returned string is:\n**\n**   \"`c` COLLATE 'BINARY', `b` COLLATE 'NOCASE', `ipk` COLLATE 'BINARY'\"\n**\n** As well as the returned string, three other malloc'd strings are \n** returned via output parameters. As follows:\n**\n**   pzImposterCols: ...\n**   pzImposterPk: ...\n**   pzWhere: ...\n*/\nstatic char *rbuObjIterGetIndexCols(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter,              /* Object iterator for column names */\n  char **pzImposterCols,          /* OUT: Columns for imposter table */\n  char **pzImposterPk,            /* OUT: Imposter PK clause */\n  char **pzWhere,                 /* OUT: WHERE clause */\n  int *pnBind                     /* OUT: Trbul number of columns */\n){\n  int rc = p->rc;                 /* Error code */\n  int rc2;                        /* sqlite3_finalize() return code */\n  char *zRet = 0;                 /* String to return */\n  char *zImpCols = 0;             /* String to return via *pzImposterCols */\n  char *zImpPK = 0;               /* String to return via *pzImposterPK */\n  char *zWhere = 0;               /* String to return via *pzWhere */\n  int nBind = 0;                  /* Value to return via *pnBind */\n  const char *zCom = \"\";          /* Set to \", \" later on */\n  const char *zAnd = \"\";          /* Set to \" AND \" later on */\n  sqlite3_stmt *pXInfo = 0;       /* PRAGMA index_xinfo = ? */\n\n  if( rc==SQLITE_OK ){\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", pIter->zIdx)\n    );\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n    int iCid = sqlite3_column_int(pXInfo, 1);\n    int bDesc = sqlite3_column_int(pXInfo, 3);\n    const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n    const char *zCol;\n    const char *zType;\n\n    if( iCid<0 ){\n      /* An integer primary key. If the table has an explicit IPK, use\n      ** its name. Otherwise, use \"rbu_rowid\".  */\n      if( pIter->eType==RBU_PK_IPK ){\n        int i;\n        for(i=0; pIter->abTblPk[i]==0; i++);\n        assert( i<pIter->nTblCol );\n        zCol = pIter->azTblCol[i];\n      }else if( rbuIsVacuum(p) ){\n        zCol = \"_rowid_\";\n      }else{\n        zCol = \"rbu_rowid\";\n      }\n      zType = \"INTEGER\";\n    }else{\n      zCol = pIter->azTblCol[iCid];\n      zType = pIter->azTblType[iCid];\n    }\n\n    zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\" COLLATE %Q\", zRet, zCom, zCol, zCollate);\n    if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){\n      const char *zOrder = (bDesc ? \" DESC\" : \"\");\n      zImpPK = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\"%s\", \n          zImpPK, zCom, nBind, zCol, zOrder\n      );\n    }\n    zImpCols = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\" %s COLLATE %Q\", \n        zImpCols, zCom, nBind, zCol, zType, zCollate\n    );\n    zWhere = sqlite3_mprintf(\n        \"%z%s\\\"rbu_imp_%d%w\\\" IS ?\", zWhere, zAnd, nBind, zCol\n    );\n    if( zRet==0 || zImpPK==0 || zImpCols==0 || zWhere==0 ) rc = SQLITE_NOMEM;\n    zCom = \", \";\n    zAnd = \" AND \";\n    nBind++;\n  }\n\n  rc2 = sqlite3_finalize(pXInfo);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRet);\n    sqlite3_free(zImpCols);\n    sqlite3_free(zImpPK);\n    sqlite3_free(zWhere);\n    zRet = 0;\n    zImpCols = 0;\n    zImpPK = 0;\n    zWhere = 0;\n    p->rc = rc;\n  }\n\n  *pzImposterCols = zImpCols;\n  *pzImposterPk = zImpPK;\n  *pzWhere = zWhere;\n  *pnBind = nBind;\n  return zRet;\n}\n\n/*\n** Assuming the current table columns are \"a\", \"b\" and \"c\", and the zObj\n** paramter is passed \"old\", return a string of the form:\n**\n**     \"old.a, old.b, old.b\"\n**\n** With the column names escaped.\n**\n** For tables with implicit rowids - RBU_PK_EXTERNAL and RBU_PK_NONE, append\n** the text \", old._rowid_\" to the returned value.\n*/\nstatic char *rbuObjIterGetOldlist(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zObj\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK && pIter->abIndexed ){\n    const char *zS = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abIndexed[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = sqlite3_mprintf(\"%z%s%s.\\\"%w\\\"\", zList, zS, zObj, zCol);\n      }else{\n        zList = sqlite3_mprintf(\"%z%sNULL\", zList, zS);\n      }\n      zS = \", \";\n      if( zList==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n    }\n\n    /* For a table with implicit rowids, append \"old._rowid_\" to the list. */\n    if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n      zList = rbuMPrintf(p, \"%z, %s._rowid_\", zList, zObj);\n    }\n  }\n  return zList;\n}\n\n/*\n** Return an expression that can be used in a WHERE clause to match the\n** primary key of the current table. For example, if the table is:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c));\n**\n** Return the string:\n**\n**   \"b = ?1 AND c = ?2\"\n*/\nstatic char *rbuObjIterGetWhere(\n  sqlite3rbu *p, \n  RbuObjIter *pIter\n){\n  char *zList = 0;\n  if( pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE ){\n    zList = rbuMPrintf(p, \"_rowid_ = ?%d\", pIter->nTblCol+1);\n  }else if( pIter->eType==RBU_PK_EXTERNAL ){\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        zList = rbuMPrintf(p, \"%z%sc%d=?%d\", zList, zSep, i, i+1);\n        zSep = \" AND \";\n      }\n    }\n    zList = rbuMPrintf(p, \n        \"_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\", zList\n    );\n\n  }else{\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", zList, zSep, zCol, i+1);\n        zSep = \" AND \";\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. However, there\n** is something wrong with the rbu_control value in the rbu_control value\n** stored in the (p->nCol+1)'th column. Set the error code and error message\n** of the RBU handle to something reflecting this.\n*/\nstatic void rbuBadControlError(sqlite3rbu *p){\n  p->rc = SQLITE_ERROR;\n  p->zErrmsg = sqlite3_mprintf(\"invalid rbu_control value\");\n}\n\n\n/*\n** Return a nul-terminated string containing the comma separated list of\n** assignments that should be included following the \"SET\" keyword of\n** an UPDATE statement used to update the table object that the iterator\n** passed as the second argument currently points to if the rbu_control\n** column of the data_xxx table entry is set to zMask.\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetSetlist(\n  sqlite3rbu *p,\n  RbuObjIter *pIter,\n  const char *zMask\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK ){\n    int i;\n\n    if( (int)strlen(zMask)!=pIter->nTblCol ){\n      rbuBadControlError(p);\n    }else{\n      const char *zSep = \"\";\n      for(i=0; i<pIter->nTblCol; i++){\n        char c = zMask[pIter->aiSrcOrder[i]];\n        if( c=='x' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", \n              zList, zSep, pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='d' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='f' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_fossil_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** Return a nul-terminated string consisting of nByte comma separated\n** \"?\" expressions. For example, if nByte is 3, return a pointer to\n** a buffer containing the string \"?,?,?\".\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetBindlist(sqlite3rbu *p, int nBind){\n  char *zRet = 0;\n  int nByte = nBind*2 + 1;\n\n  zRet = (char*)rbuMalloc(p, nByte);\n  if( zRet ){\n    int i;\n    for(i=0; i<nBind; i++){\n      zRet[i*2] = '?';\n      zRet[i*2+1] = (i+1==nBind) ? '\\0' : ',';\n    }\n  }\n  return zRet;\n}\n\n/*\n** The iterator currently points to a table (not index) of type \n** RBU_PK_WITHOUT_ROWID. This function creates the PRIMARY KEY \n** declaration for the corresponding imposter table. For example,\n** if the iterator points to a table created as:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID\n**\n** this function returns:\n**\n**   PRIMARY KEY(\"b\", \"a\" DESC)\n*/\nstatic char *rbuWithoutRowidPK(sqlite3rbu *p, RbuObjIter *pIter){\n  char *z = 0;\n  assert( pIter->zIdx==0 );\n  if( p->rc==SQLITE_OK ){\n    const char *zSep = \"PRIMARY KEY(\";\n    sqlite3_stmt *pXList = 0;     /* PRAGMA index_list = (pIter->zTbl) */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA index_xinfo = <pk-index> */\n   \n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXList) ){\n      const char *zOrig = (const char*)sqlite3_column_text(pXList,3);\n      if( zOrig && strcmp(zOrig, \"pk\")==0 ){\n        const char *zIdx = (const char*)sqlite3_column_text(pXList,1);\n        if( zIdx ){\n          p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n              sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n          );\n        }\n        break;\n      }\n    }\n    rbuFinalize(p, pXList);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      if( sqlite3_column_int(pXInfo, 5) ){\n        /* int iCid = sqlite3_column_int(pXInfo, 0); */\n        const char *zCol = (const char*)sqlite3_column_text(pXInfo, 2);\n        const char *zDesc = sqlite3_column_int(pXInfo, 3) ? \" DESC\" : \"\";\n        z = rbuMPrintf(p, \"%z%s\\\"%w\\\"%s\", z, zSep, zCol, zDesc);\n        zSep = \", \";\n      }\n    }\n    z = rbuMPrintf(p, \"%z)\", z);\n    rbuFinalize(p, pXInfo);\n  }\n  return z;\n}\n\n/*\n** This function creates the second imposter table used when writing to\n** a table b-tree where the table has an external primary key. If the\n** iterator passed as the second argument does not currently point to\n** a table (not index) with an external primary key, this function is a\n** no-op. \n**\n** Assuming the iterator does point to a table with an external PK, this\n** function creates a WITHOUT ROWID imposter table named \"rbu_imposter2\"\n** used to access that PK index. For example, if the target table is\n** declared as follows:\n**\n**   CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c));\n**\n** then the imposter table schema is:\n**\n**   CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID;\n**\n*/\nstatic void rbuCreateImposterTable2(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_EXTERNAL ){\n    int tnum = pIter->iPkTnum;    /* Root page of PK index */\n    sqlite3_stmt *pQuery = 0;     /* SELECT name ... WHERE rootpage = $tnum */\n    const char *zIdx = 0;         /* Name of PK index */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA main.index_xinfo = $zIdx */\n    const char *zComma = \"\";\n    char *zCols = 0;              /* Used to build up list of table cols */\n    char *zPk = 0;                /* Used to build up table PK declaration */\n\n    /* Figure out the name of the primary key index for the current table.\n    ** This is needed for the argument to \"PRAGMA index_xinfo\". Set\n    ** zIdx to point to a nul-terminated string containing this name. */\n    p->rc = prepareAndCollectError(p->dbMain, &pQuery, &p->zErrmsg, \n        \"SELECT name FROM sqlite_master WHERE rootpage = ?\"\n    );\n    if( p->rc==SQLITE_OK ){\n      sqlite3_bind_int(pQuery, 1, tnum);\n      if( SQLITE_ROW==sqlite3_step(pQuery) ){\n        zIdx = (const char*)sqlite3_column_text(pQuery, 0);\n      }\n    }\n    if( zIdx ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n          sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n      );\n    }\n    rbuFinalize(p, pQuery);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int bKey = sqlite3_column_int(pXInfo, 5);\n      if( bKey ){\n        int iCid = sqlite3_column_int(pXInfo, 1);\n        int bDesc = sqlite3_column_int(pXInfo, 3);\n        const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n        zCols = rbuMPrintf(p, \"%z%sc%d %s COLLATE %s\", zCols, zComma, \n            iCid, pIter->azTblType[iCid], zCollate\n        );\n        zPk = rbuMPrintf(p, \"%z%sc%d%s\", zPk, zComma, iCid, bDesc?\" DESC\":\"\");\n        zComma = \", \";\n      }\n    }\n    zCols = rbuMPrintf(p, \"%z, id INTEGER\", zCols);\n    rbuFinalize(p, pXInfo);\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain,\n        \"CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\", \n        zCols, zPk\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** If an error has already occurred when this function is called, it \n** immediately returns zero (without doing any work). Or, if an error\n** occurs during the execution of this function, it sets the error code\n** in the sqlite3rbu object indicated by the first argument and returns\n** zero.\n**\n** The iterator passed as the second argument is guaranteed to point to\n** a table (not an index) when this function is called. This function\n** attempts to create any imposter table required to write to the main\n** table b-tree of the table before returning. Non-zero is returned if\n** an imposter table are created, or zero otherwise.\n**\n** An imposter table is required in all cases except RBU_PK_VTAB. Only\n** virtual tables are written to directly. The imposter table has the \n** same schema as the actual target table (less any UNIQUE constraints). \n** More precisely, the \"same schema\" means the same columns, types, \n** collation sequences. For tables that do not have an external PRIMARY\n** KEY, it also means the same PRIMARY KEY declaration.\n*/\nstatic void rbuCreateImposterTable(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType!=RBU_PK_VTAB ){\n    int tnum = pIter->iTnum;\n    const char *zComma = \"\";\n    char *zSql = 0;\n    int iCol;\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n\n    for(iCol=0; p->rc==SQLITE_OK && iCol<pIter->nTblCol; iCol++){\n      const char *zPk = \"\";\n      const char *zCol = pIter->azTblCol[iCol];\n      const char *zColl = 0;\n\n      p->rc = sqlite3_table_column_metadata(\n          p->dbMain, \"main\", pIter->zTbl, zCol, 0, &zColl, 0, 0, 0\n      );\n\n      if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){\n        /* If the target table column is an \"INTEGER PRIMARY KEY\", add\n        ** \"PRIMARY KEY\" to the imposter table column declaration. */\n        zPk = \"PRIMARY KEY \";\n      }\n      zSql = rbuMPrintf(p, \"%z%s\\\"%w\\\" %s %sCOLLATE %s%s\", \n          zSql, zComma, zCol, pIter->azTblType[iCol], zPk, zColl,\n          (pIter->abNotNull[iCol] ? \" NOT NULL\" : \"\")\n      );\n      zComma = \", \";\n    }\n\n    if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n      char *zPk = rbuWithoutRowidPK(p, pIter);\n      if( zPk ){\n        zSql = rbuMPrintf(p, \"%z, %z\", zSql, zPk);\n      }\n    }\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain, \"CREATE TABLE \\\"rbu_imp_%w\\\"(%z)%s\", \n        pIter->zTbl, zSql, \n        (pIter->eType==RBU_PK_WITHOUT_ROWID ? \" WITHOUT ROWID\" : \"\")\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** Prepare a statement used to insert rows into the \"rbu_tmp_xxx\" table.\n** Specifically a statement of the form:\n**\n**     INSERT INTO rbu_tmp_xxx VALUES(?, ?, ? ...);\n**\n** The number of bound variables is equal to the number of columns in\n** the target table, plus one (for the rbu_control column), plus one more \n** (for the rbu_rowid column) if the target table is an implicit IPK or \n** virtual table.\n*/\nstatic void rbuObjIterPrepareTmpInsert(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zCollist,\n  const char *zRbuRowid\n){\n  int bRbuRowid = (pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE);\n  char *zBind = rbuObjIterGetBindlist(p, pIter->nTblCol + 1 + bRbuRowid);\n  if( zBind ){\n    assert( pIter->pTmpInsert==0 );\n    p->rc = prepareFreeAndCollectError(\n        p->dbRbu, &pIter->pTmpInsert, &p->zErrmsg, sqlite3_mprintf(\n          \"INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\", \n          p->zStateDb, pIter->zDataTbl, zCollist, zRbuRowid, zBind\n    ));\n  }\n}\n\nstatic void rbuTmpInsertFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  int rc = SQLITE_OK;\n  int i;\n\n  assert( sqlite3_value_int(apVal[0])!=0\n      || p->objiter.eType==RBU_PK_EXTERNAL \n      || p->objiter.eType==RBU_PK_NONE \n  );\n  if( sqlite3_value_int(apVal[0])!=0 ){\n    p->nPhaseOneStep += p->objiter.nIndex;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nVal; i++){\n    rc = sqlite3_bind_value(p->objiter.pTmpInsert, i+1, apVal[i]);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_step(p->objiter.pTmpInsert);\n    rc = sqlite3_reset(p->objiter.pTmpInsert);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\n/*\n** Ensure that the SQLite statement handles required to update the \n** target database object currently indicated by the iterator passed \n** as the second argument are available.\n*/\nstatic int rbuObjIterPrepareAll(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  int nOffset                     /* Add \"LIMIT -1 OFFSET $nOffset\" to SELECT */\n){\n  assert( pIter->bCleanup==0 );\n  if( pIter->pSelect==0 && rbuObjIterCacheTableInfo(p, pIter)==SQLITE_OK ){\n    const int tnum = pIter->iTnum;\n    char *zCollist = 0;           /* List of indexed columns */\n    char **pz = &p->zErrmsg;\n    const char *zIdx = pIter->zIdx;\n    char *zLimit = 0;\n\n    if( nOffset ){\n      zLimit = sqlite3_mprintf(\" LIMIT -1 OFFSET %d\", nOffset);\n      if( !zLimit ) p->rc = SQLITE_NOMEM;\n    }\n\n    if( zIdx ){\n      const char *zTbl = pIter->zTbl;\n      char *zImposterCols = 0;    /* Columns for imposter table */\n      char *zImposterPK = 0;      /* Primary key declaration for imposter */\n      char *zWhere = 0;           /* WHERE clause on PK columns */\n      char *zBind = 0;\n      int nBind = 0;\n\n      assert( pIter->eType!=RBU_PK_VTAB );\n      zCollist = rbuObjIterGetIndexCols(\n          p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind\n      );\n      zBind = rbuObjIterGetBindlist(p, nBind);\n\n      /* Create the imposter table used to write to this index. */\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1,tnum);\n      rbuMPrintfExec(p, p->dbMain,\n          \"CREATE TABLE \\\"rbu_imp_%w\\\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\",\n          zTbl, zImposterCols, zImposterPK\n      );\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n\n      /* Create the statement to insert index entries */\n      pIter->nCol = nBind;\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pInsert, &p->zErrmsg,\n          sqlite3_mprintf(\"INSERT INTO \\\"rbu_imp_%w\\\" VALUES(%s)\", zTbl, zBind)\n        );\n      }\n\n      /* And to delete index entries */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pDelete, &p->zErrmsg,\n          sqlite3_mprintf(\"DELETE FROM \\\"rbu_imp_%w\\\" WHERE %s\", zTbl, zWhere)\n        );\n      }\n\n      /* Create the SELECT statement to read keys in sorted order */\n      if( p->rc==SQLITE_OK ){\n        char *zSql;\n        if( rbuIsVacuum(p) ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, 0 AS rbu_control FROM '%q' ORDER BY %s%s\",\n              zCollist, \n              pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else{\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' \"\n              \"UNION ALL \"\n              \"SELECT %s, rbu_control FROM '%q' \"\n              \"WHERE typeof(rbu_control)='integer' AND rbu_control!=1 \"\n              \"ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl, \n              zCollist, pIter->zDataTbl, \n              zCollist, zLimit\n          );\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql);\n      }\n\n      sqlite3_free(zImposterCols);\n      sqlite3_free(zImposterPK);\n      sqlite3_free(zWhere);\n      sqlite3_free(zBind);\n    }else{\n      int bRbuRowid = (pIter->eType==RBU_PK_VTAB)\n                    ||(pIter->eType==RBU_PK_NONE)\n                    ||(pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p));\n      const char *zTbl = pIter->zTbl;       /* Table this step applies to */\n      const char *zWrite;                   /* Imposter table name */\n\n      char *zBindings = rbuObjIterGetBindlist(p, pIter->nTblCol + bRbuRowid);\n      char *zWhere = rbuObjIterGetWhere(p, pIter);\n      char *zOldlist = rbuObjIterGetOldlist(p, pIter, \"old\");\n      char *zNewlist = rbuObjIterGetOldlist(p, pIter, \"new\");\n\n      zCollist = rbuObjIterGetCollist(p, pIter);\n      pIter->nCol = pIter->nTblCol;\n\n      /* Create the imposter table or tables (if required). */\n      rbuCreateImposterTable(p, pIter);\n      rbuCreateImposterTable2(p, pIter);\n      zWrite = (pIter->eType==RBU_PK_VTAB ? \"\" : \"rbu_imp_\");\n\n      /* Create the INSERT statement to write to the target PK b-tree */\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pInsert, pz,\n            sqlite3_mprintf(\n              \"INSERT INTO \\\"%s%w\\\"(%s%s) VALUES(%s)\", \n              zWrite, zTbl, zCollist, (bRbuRowid ? \", _rowid_\" : \"\"), zBindings\n            )\n        );\n      }\n\n      /* Create the DELETE statement to write to the target PK b-tree.\n      ** Because it only performs INSERT operations, this is not required for\n      ** an rbu vacuum handle.  */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pDelete, pz,\n            sqlite3_mprintf(\n              \"DELETE FROM \\\"%s%w\\\" WHERE %s\", zWrite, zTbl, zWhere\n            )\n        );\n      }\n\n      if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n        const char *zRbuRowid = \"\";\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zRbuRowid = \", rbu_rowid\";\n        }\n\n        /* Create the rbu_tmp_xxx table and the triggers to populate it. */\n        rbuMPrintfExec(p, p->dbRbu,\n            \"CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS \"\n            \"SELECT *%s FROM '%q' WHERE 0;\"\n            , p->zStateDb, pIter->zDataTbl\n            , (pIter->eType==RBU_PK_EXTERNAL ? \", 0 AS rbu_rowid\" : \"\")\n            , pIter->zDataTbl\n        );\n\n        rbuMPrintfExec(p, p->dbMain,\n            \"CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(4, %s);\"\n            \"END;\",\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zNewlist\n        );\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          rbuMPrintfExec(p, p->dbMain,\n              \"CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \\\"%s%w\\\" \"\n              \"BEGIN \"\n              \"  SELECT rbu_tmp_insert(0, %s);\"\n              \"END;\",\n              zWrite, zTbl, zNewlist\n          );\n        }\n\n        rbuObjIterPrepareTmpInsert(p, pIter, zCollist, zRbuRowid);\n      }\n\n      /* Create the SELECT statement to read keys from data_xxx */\n      if( p->rc==SQLITE_OK ){\n        const char *zRbuRowid = \"\";\n        if( bRbuRowid ){\n          zRbuRowid = rbuIsVacuum(p) ? \",_rowid_ \" : \",rbu_rowid\";\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz,\n            sqlite3_mprintf(\n              \"SELECT %s,%s rbu_control%s FROM '%q'%s\", \n              zCollist, \n              (rbuIsVacuum(p) ? \"0 AS \" : \"\"),\n              zRbuRowid,\n              pIter->zDataTbl, zLimit\n            )\n        );\n      }\n\n      sqlite3_free(zWhere);\n      sqlite3_free(zOldlist);\n      sqlite3_free(zNewlist);\n      sqlite3_free(zBindings);\n    }\n    sqlite3_free(zCollist);\n    sqlite3_free(zLimit);\n  }\n  \n  return p->rc;\n}\n\n/*\n** Set output variable *ppStmt to point to an UPDATE statement that may\n** be used to update the imposter table for the main table b-tree of the\n** table object that pIter currently points to, assuming that the \n** rbu_control column of the data_xyz table contains zMask.\n** \n** If the zMask string does not specify any columns to update, then this\n** is not an error. Output variable *ppStmt is set to NULL in this case.\n*/\nstatic int rbuGetUpdateStmt(\n  sqlite3rbu *p,                  /* RBU handle */\n  RbuObjIter *pIter,              /* Object iterator */\n  const char *zMask,              /* rbu_control value ('x.x.') */\n  sqlite3_stmt **ppStmt           /* OUT: UPDATE statement handle */\n){\n  RbuUpdateStmt **pp;\n  RbuUpdateStmt *pUp = 0;\n  int nUp = 0;\n\n  /* In case an error occurs */\n  *ppStmt = 0;\n\n  /* Search for an existing statement. If one is found, shift it to the front\n  ** of the LRU queue and return immediately. Otherwise, leave nUp pointing\n  ** to the number of statements currently in the cache and pUp to the\n  ** last object in the list.  */\n  for(pp=&pIter->pRbuUpdate; *pp; pp=&((*pp)->pNext)){\n    pUp = *pp;\n    if( strcmp(pUp->zMask, zMask)==0 ){\n      *pp = pUp->pNext;\n      pUp->pNext = pIter->pRbuUpdate;\n      pIter->pRbuUpdate = pUp;\n      *ppStmt = pUp->pUpdate; \n      return SQLITE_OK;\n    }\n    nUp++;\n  }\n  assert( pUp==0 || pUp->pNext==0 );\n\n  if( nUp>=SQLITE_RBU_UPDATE_CACHESIZE ){\n    for(pp=&pIter->pRbuUpdate; *pp!=pUp; pp=&((*pp)->pNext));\n    *pp = 0;\n    sqlite3_finalize(pUp->pUpdate);\n    pUp->pUpdate = 0;\n  }else{\n    pUp = (RbuUpdateStmt*)rbuMalloc(p, sizeof(RbuUpdateStmt)+pIter->nTblCol+1);\n  }\n\n  if( pUp ){\n    char *zWhere = rbuObjIterGetWhere(p, pIter);\n    char *zSet = rbuObjIterGetSetlist(p, pIter, zMask);\n    char *zUpdate = 0;\n\n    pUp->zMask = (char*)&pUp[1];\n    memcpy(pUp->zMask, zMask, pIter->nTblCol);\n    pUp->pNext = pIter->pRbuUpdate;\n    pIter->pRbuUpdate = pUp;\n\n    if( zSet ){\n      const char *zPrefix = \"\";\n\n      if( pIter->eType!=RBU_PK_VTAB ) zPrefix = \"rbu_imp_\";\n      zUpdate = sqlite3_mprintf(\"UPDATE \\\"%s%w\\\" SET %s WHERE %s\", \n          zPrefix, pIter->zTbl, zSet, zWhere\n      );\n      p->rc = prepareFreeAndCollectError(\n          p->dbMain, &pUp->pUpdate, &p->zErrmsg, zUpdate\n      );\n      *ppStmt = pUp->pUpdate;\n    }\n    sqlite3_free(zWhere);\n    sqlite3_free(zSet);\n  }\n\n  return p->rc;\n}\n\nstatic sqlite3 *rbuOpenDbhandle(\n  sqlite3rbu *p, \n  const char *zName, \n  int bUseVfs\n){\n  sqlite3 *db = 0;\n  if( p->rc==SQLITE_OK ){\n    const int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI;\n    p->rc = sqlite3_open_v2(zName, &db, flags, bUseVfs ? p->zVfsName : 0);\n    if( p->rc ){\n      p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      sqlite3_close(db);\n      db = 0;\n    }\n  }\n  return db;\n}\n\n/*\n** Free an RbuState object allocated by rbuLoadState().\n*/\nstatic void rbuFreeState(RbuState *p){\n  if( p ){\n    sqlite3_free(p->zTbl);\n    sqlite3_free(p->zIdx);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Allocate an RbuState object and load the contents of the rbu_state \n** table into it. Return a pointer to the new object. It is the \n** responsibility of the caller to eventually free the object using\n** sqlite3_free().\n**\n** If an error occurs, leave an error code and message in the rbu handle\n** and return NULL.\n*/\nstatic RbuState *rbuLoadState(sqlite3rbu *p){\n  RbuState *pRet = 0;\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  int rc2;\n\n  pRet = (RbuState*)rbuMalloc(p, sizeof(RbuState));\n  if( pRet==0 ) return 0;\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n      sqlite3_mprintf(\"SELECT k, v FROM %s.rbu_state\", p->zStateDb)\n  );\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    switch( sqlite3_column_int(pStmt, 0) ){\n      case RBU_STATE_STAGE:\n        pRet->eStage = sqlite3_column_int(pStmt, 1);\n        if( pRet->eStage!=RBU_STAGE_OAL\n         && pRet->eStage!=RBU_STAGE_MOVE\n         && pRet->eStage!=RBU_STAGE_CKPT\n        ){\n          p->rc = SQLITE_CORRUPT;\n        }\n        break;\n\n      case RBU_STATE_TBL:\n        pRet->zTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_IDX:\n        pRet->zIdx = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_ROW:\n        pRet->nRow = sqlite3_column_int(pStmt, 1);\n        break;\n\n      case RBU_STATE_PROGRESS:\n        pRet->nProgress = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_CKPT:\n        pRet->iWalCksum = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_COOKIE:\n        pRet->iCookie = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_OALSZ:\n        pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_PHASEONESTEP:\n        pRet->nPhaseOneStep = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      default:\n        rc = SQLITE_CORRUPT;\n        break;\n    }\n  }\n  rc2 = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  p->rc = rc;\n  return pRet;\n}\n\n\n/*\n** Open the database handle and attach the RBU database as \"rbu\". If an\n** error occurs, leave an error code and message in the RBU handle.\n*/\nstatic void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){\n  assert( p->rc || (p->dbMain==0 && p->dbRbu==0) );\n  assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 );\n\n  /* Open the RBU database */\n  p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1);\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( p->zState==0 ){\n      const char *zFile = sqlite3_db_filename(p->dbRbu, \"main\");\n      p->zState = rbuMPrintf(p, \"file://%s-vacuum?modeof=%s\", zFile, zFile);\n    }\n  }\n\n  /* If using separate RBU and state databases, attach the state database to\n  ** the RBU db handle now.  */\n  if( p->zState ){\n    rbuMPrintfExec(p, p->dbRbu, \"ATTACH %Q AS stat\", p->zState);\n    memcpy(p->zStateDb, \"stat\", 4);\n  }else{\n    memcpy(p->zStateDb, \"main\", 4);\n  }\n\n#if 0\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, 0);\n  }\n#endif\n\n  /* If it has not already been created, create the rbu_state table */\n  rbuMPrintfExec(p, p->dbRbu, RBU_CREATE_STATE, p->zStateDb);\n\n#if 0\n  if( rbuIsVacuum(p) ){\n    if( p->rc==SQLITE_OK ){\n      int rc2;\n      int bOk = 0;\n      sqlite3_stmt *pCnt = 0;\n      p->rc = prepareAndCollectError(p->dbRbu, &pCnt, &p->zErrmsg,\n          \"SELECT count(*) FROM stat.sqlite_master\"\n      );\n      if( p->rc==SQLITE_OK \n       && sqlite3_step(pCnt)==SQLITE_ROW\n       && 1==sqlite3_column_int(pCnt, 0)\n      ){\n        bOk = 1;\n      }\n      rc2 = sqlite3_finalize(pCnt);\n      if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n      if( p->rc==SQLITE_OK && bOk==0 ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"invalid state database\");\n      }\n    \n      if( p->rc==SQLITE_OK ){\n        p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n      }\n    }\n  }\n#endif\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    int bOpen = 0;\n    int rc;\n    p->nRbu = 0;\n    p->pRbuFd = 0;\n    rc = sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( rc!=SQLITE_NOTFOUND ) p->rc = rc;\n    if( p->eStage>=RBU_STAGE_MOVE ){\n      bOpen = 1;\n    }else{\n      RbuState *pState = rbuLoadState(p);\n      if( pState ){\n        bOpen = (pState->eStage>=RBU_STAGE_MOVE);\n        rbuFreeState(pState);\n      }\n    }\n    if( bOpen ) p->dbMain = rbuOpenDbhandle(p, p->zRbu, p->nRbu<=1);\n  }\n\n  p->eStage = 0;\n  if( p->rc==SQLITE_OK && p->dbMain==0 ){\n    if( !rbuIsVacuum(p) ){\n      p->dbMain = rbuOpenDbhandle(p, p->zTarget, 1);\n    }else if( p->pRbuFd->pWalFd ){\n      if( pbRetry ){\n        p->pRbuFd->bNolock = 0;\n        sqlite3_close(p->dbRbu);\n        sqlite3_close(p->dbMain);\n        p->dbMain = 0;\n        p->dbRbu = 0;\n        *pbRetry = 1;\n        return;\n      }\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"cannot vacuum wal mode database\");\n    }else{\n      char *zTarget;\n      char *zExtra = 0;\n      if( strlen(p->zRbu)>=5 && 0==memcmp(\"file:\", p->zRbu, 5) ){\n        zExtra = &p->zRbu[5];\n        while( *zExtra ){\n          if( *zExtra++=='?' ) break;\n        }\n        if( *zExtra=='\\0' ) zExtra = 0;\n      }\n\n      zTarget = sqlite3_mprintf(\"file:%s-vacuum?rbu_memory=1%s%s\", \n          sqlite3_db_filename(p->dbRbu, \"main\"),\n          (zExtra==0 ? \"\" : \"&\"), (zExtra==0 ? \"\" : zExtra)\n      );\n\n      if( zTarget==0 ){\n        p->rc = SQLITE_NOMEM;\n        return;\n      }\n      p->dbMain = rbuOpenDbhandle(p, zTarget, p->nRbu<=1);\n      sqlite3_free(zTarget);\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_tmp_insert\", -1, SQLITE_UTF8, (void*)p, rbuTmpInsertFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_fossil_delta\", 2, SQLITE_UTF8, 0, rbuFossilDeltaFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_target_name\", -1, SQLITE_UTF8, (void*)p, rbuTargetNameFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n  rbuMPrintfExec(p, p->dbMain, \"SELECT * FROM sqlite_master\");\n\n  /* Mark the database file just opened as an RBU target database. If \n  ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use.\n  ** This is an error.  */\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n\n  if( p->rc==SQLITE_NOTFOUND ){\n    p->rc = SQLITE_ERROR;\n    p->zErrmsg = sqlite3_mprintf(\"rbu vfs not found\");\n  }\n}\n\n/*\n** This routine is a copy of the sqlite3FileSuffix3() routine from the core.\n** It is a no-op unless SQLITE_ENABLE_8_3_NAMES is defined.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nstatic void rbuFileSuffix3(const char *zBase, char *z){\n#ifdef SQLITE_ENABLE_8_3_NAMES\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBase, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = (int)strlen(z)&0xffffff;\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n#endif\n}\n\n/*\n** Return the current wal-index header checksum for the target database \n** as a 64-bit integer.\n**\n** The checksum is store in the first page of xShmMap memory as an 8-byte \n** blob starting at byte offset 40.\n*/\nstatic i64 rbuShmChecksum(sqlite3rbu *p){\n  i64 iRet = 0;\n  if( p->rc==SQLITE_OK ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    u32 volatile *ptr;\n    p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr);\n    if( p->rc==SQLITE_OK ){\n      iRet = ((i64)ptr[10] << 32) + ptr[11];\n    }\n  }\n  return iRet;\n}\n\n/*\n** This function is called as part of initializing or reinitializing an\n** incremental checkpoint. \n**\n** It populates the sqlite3rbu.aFrame[] array with the set of \n** (wal frame -> db page) copy operations required to checkpoint the \n** current wal file, and obtains the set of shm locks required to safely \n** perform the copy operations directly on the file-system.\n**\n** If argument pState is not NULL, then the incremental checkpoint is\n** being resumed. In this case, if the checksum of the wal-index-header\n** following recovery is not the same as the checksum saved in the RbuState\n** object, then the rbu handle is set to DONE state. This occurs if some\n** other client appends a transaction to the wal file in the middle of\n** an incremental checkpoint.\n*/\nstatic void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){\n\n  /* If pState is NULL, then the wal file may not have been opened and\n  ** recovered. Running a read-statement here to ensure that doing so\n  ** does not interfere with the \"capture\" process below.  */\n  if( pState==0 ){\n    p->eStage = 0;\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3_exec(p->dbMain, \"SELECT * FROM sqlite_master\", 0, 0, 0);\n    }\n  }\n\n  /* Assuming no error has occurred, run a \"restart\" checkpoint with the\n  ** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following\n  ** special behaviour in the rbu VFS:\n  **\n  **   * If the exclusive shm WRITER or READ0 lock cannot be obtained,\n  **     the checkpoint fails with SQLITE_BUSY (normally SQLite would\n  **     proceed with running a passive checkpoint instead of failing).\n  **\n  **   * Attempts to read from the *-wal file or write to the database file\n  **     do not perform any IO. Instead, the frame/page combinations that\n  **     would be read/written are recorded in the sqlite3rbu.aFrame[]\n  **     array.\n  **\n  **   * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER, \n  **     READ0 and CHECKPOINT locks taken as part of the checkpoint are\n  **     no-ops. These locks will not be released until the connection\n  **     is closed.\n  **\n  **   * Attempting to xSync() the database file causes an SQLITE_INTERNAL \n  **     error.\n  **\n  ** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the\n  ** checkpoint below fails with SQLITE_INTERNAL, and leaves the aFrame[]\n  ** array populated with a set of (frame -> page) mappings. Because the \n  ** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy \n  ** data from the wal file into the database file according to the \n  ** contents of aFrame[].\n  */\n  if( p->rc==SQLITE_OK ){\n    int rc2;\n    p->eStage = RBU_STAGE_CAPTURE;\n    rc2 = sqlite3_exec(p->dbMain, \"PRAGMA main.wal_checkpoint=restart\", 0, 0,0);\n    if( rc2!=SQLITE_INTERNAL ) p->rc = rc2;\n  }\n\n  if( p->rc==SQLITE_OK && p->nFrame>0 ){\n    p->eStage = RBU_STAGE_CKPT;\n    p->nStep = (pState ? pState->nRow : 0);\n    p->aBuf = rbuMalloc(p, p->pgsz);\n    p->iWalCksum = rbuShmChecksum(p);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){\n      p->rc = SQLITE_DONE;\n      p->eStage = RBU_STAGE_DONE;\n    }else{\n      int nSectorSize;\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n      assert( p->nPagePerSector==0 );\n      nSectorSize = pDb->pMethods->xSectorSize(pDb);\n      if( nSectorSize>p->pgsz ){\n        p->nPagePerSector = nSectorSize / p->pgsz;\n      }else{\n        p->nPagePerSector = 1;\n      }\n\n      /* Call xSync() on the wal file. This causes SQLite to sync the \n      ** directory in which the target database and the wal file reside, in \n      ** case it has not been synced since the rename() call in \n      ** rbuMoveOalFile(). */\n      p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);\n    }\n  }\n}\n\n/*\n** Called when iAmt bytes are read from offset iOff of the wal file while\n** the rbu object is in capture mode. Record the frame number of the frame\n** being read in the aFrame[] array.\n*/\nstatic int rbuCaptureWalRead(sqlite3rbu *pRbu, i64 iOff, int iAmt){\n  const u32 mReq = (1<<WAL_LOCK_WRITE)|(1<<WAL_LOCK_CKPT)|(1<<WAL_LOCK_READ0);\n  u32 iFrame;\n\n  if( pRbu->mLock!=mReq ){\n    pRbu->rc = SQLITE_BUSY;\n    return SQLITE_INTERNAL;\n  }\n\n  pRbu->pgsz = iAmt;\n  if( pRbu->nFrame==pRbu->nFrameAlloc ){\n    int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2;\n    RbuFrame *aNew;\n    aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    pRbu->aFrame = aNew;\n    pRbu->nFrameAlloc = nNew;\n  }\n\n  iFrame = (u32)((iOff-32) / (i64)(iAmt+24)) + 1;\n  if( pRbu->iMaxFrame<iFrame ) pRbu->iMaxFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iWalFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iDbPage = 0;\n  pRbu->nFrame++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a page of data is written to offset iOff of the database\n** file while the rbu handle is in capture mode. Record the page number \n** of the page being written in the aFrame[] array.\n*/\nstatic int rbuCaptureDbWrite(sqlite3rbu *pRbu, i64 iOff){\n  pRbu->aFrame[pRbu->nFrame-1].iDbPage = (u32)(iOff / pRbu->pgsz) + 1;\n  return SQLITE_OK;\n}\n\n/*\n** This is called as part of an incremental checkpoint operation. Copy\n** a single frame of data from the wal file into the database file, as\n** indicated by the RbuFrame object.\n*/\nstatic void rbuCheckpointFrame(sqlite3rbu *p, RbuFrame *pFrame){\n  sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n  sqlite3_file *pDb = p->pTargetFd->pReal;\n  i64 iOff;\n\n  assert( p->rc==SQLITE_OK );\n  iOff = (i64)(pFrame->iWalFrame-1) * (p->pgsz + 24) + 32 + 24;\n  p->rc = pWal->pMethods->xRead(pWal, p->aBuf, p->pgsz, iOff);\n  if( p->rc ) return;\n\n  iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;\n  p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);\n}\n\n\n/*\n** Take an EXCLUSIVE lock on the database file.\n*/\nstatic void rbuLockDatabase(sqlite3rbu *p){\n  sqlite3_file *pReal = p->pTargetFd->pReal;\n  assert( p->rc==SQLITE_OK );\n  p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED);\n  if( p->rc==SQLITE_OK ){\n    p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE);\n  }\n}\n\n#if defined(_WIN32_WCE)\nstatic LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){\n  int nChar;\n  LPWSTR zWideFilename;\n\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) );\n  if( zWideFilename==0 ){\n    return 0;\n  }\n  memset(zWideFilename, 0, nChar*sizeof(zWideFilename[0]));\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideFilename);\n    zWideFilename = 0;\n  }\n  return zWideFilename;\n}\n#endif\n\n/*\n** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock\n** on the database file. This proc moves the *-oal file to the *-wal path,\n** then reopens the database file (this time in vanilla, non-oal, WAL mode).\n** If an error occurs, leave an error code and error message in the rbu \n** handle.\n*/\nstatic void rbuMoveOalFile(sqlite3rbu *p){\n  const char *zBase = sqlite3_db_filename(p->dbMain, \"main\");\n  const char *zMove = zBase;\n  char *zOal;\n  char *zWal;\n\n  if( rbuIsVacuum(p) ){\n    zMove = sqlite3_db_filename(p->dbRbu, \"main\");\n  }\n  zOal = sqlite3_mprintf(\"%s-oal\", zMove);\n  zWal = sqlite3_mprintf(\"%s-wal\", zMove);\n\n  assert( p->eStage==RBU_STAGE_MOVE );\n  assert( p->rc==SQLITE_OK && p->zErrmsg==0 );\n  if( zWal==0 || zOal==0 ){\n    p->rc = SQLITE_NOMEM;\n  }else{\n    /* Move the *-oal file to *-wal. At this point connection p->db is\n    ** holding a SHARED lock on the target database file (because it is\n    ** in WAL mode). So no other connection may be writing the db. \n    **\n    ** In order to ensure that there are no database readers, an EXCLUSIVE\n    ** lock is obtained here before the *-oal is moved to *-wal.\n    */\n    rbuLockDatabase(p);\n    if( p->rc==SQLITE_OK ){\n      rbuFileSuffix3(zBase, zWal);\n      rbuFileSuffix3(zBase, zOal);\n\n      /* Re-open the databases. */\n      rbuObjIterFinalize(&p->objiter);\n      sqlite3_close(p->dbRbu);\n      sqlite3_close(p->dbMain);\n      p->dbMain = 0;\n      p->dbRbu = 0;\n\n#if defined(_WIN32_WCE)\n      {\n        LPWSTR zWideOal;\n        LPWSTR zWideWal;\n\n        zWideOal = rbuWinUtf8ToUnicode(zOal);\n        if( zWideOal ){\n          zWideWal = rbuWinUtf8ToUnicode(zWal);\n          if( zWideWal ){\n            if( MoveFileW(zWideOal, zWideWal) ){\n              p->rc = SQLITE_OK;\n            }else{\n              p->rc = SQLITE_IOERR;\n            }\n            sqlite3_free(zWideWal);\n          }else{\n            p->rc = SQLITE_IOERR_NOMEM;\n          }\n          sqlite3_free(zWideOal);\n        }else{\n          p->rc = SQLITE_IOERR_NOMEM;\n        }\n      }\n#else\n      p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;\n#endif\n\n      if( p->rc==SQLITE_OK ){\n        rbuOpenDatabase(p, 0);\n        rbuSetupCheckpoint(p, 0);\n      }\n    }\n  }\n\n  sqlite3_free(zWal);\n  sqlite3_free(zOal);\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. This function\n** determines the type of operation requested by this row and returns\n** one of the following values to indicate the result:\n**\n**     * RBU_INSERT\n**     * RBU_DELETE\n**     * RBU_IDX_DELETE\n**     * RBU_UPDATE\n**\n** If RBU_UPDATE is returned, then output variable *pzMask is set to\n** point to the text value indicating the columns to update.\n**\n** If the rbu_control field contains an invalid value, an error code and\n** message are left in the RBU handle and zero returned.\n*/\nstatic int rbuStepType(sqlite3rbu *p, const char **pzMask){\n  int iCol = p->objiter.nCol;     /* Index of rbu_control column */\n  int res = 0;                    /* Return value */\n\n  switch( sqlite3_column_type(p->objiter.pSelect, iCol) ){\n    case SQLITE_INTEGER: {\n      int iVal = sqlite3_column_int(p->objiter.pSelect, iCol);\n      switch( iVal ){\n        case 0: res = RBU_INSERT;     break;\n        case 1: res = RBU_DELETE;     break;\n        case 2: res = RBU_REPLACE;    break;\n        case 3: res = RBU_IDX_DELETE; break;\n        case 4: res = RBU_IDX_INSERT; break;\n      }\n      break;\n    }\n\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_column_text(p->objiter.pSelect, iCol);\n      if( z==0 ){\n        p->rc = SQLITE_NOMEM;\n      }else{\n        *pzMask = (const char*)z;\n      }\n      res = RBU_UPDATE;\n\n      break;\n    }\n\n    default:\n      break;\n  }\n\n  if( res==0 ){\n    rbuBadControlError(p);\n  }\n  return res;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Assert that column iCol of statement pStmt is named zName.\n*/\nstatic void assertColumnName(sqlite3_stmt *pStmt, int iCol, const char *zName){\n  const char *zCol = sqlite3_column_name(pStmt, iCol);\n  assert( 0==sqlite3_stricmp(zName, zCol) );\n}\n#else\n# define assertColumnName(x,y,z)\n#endif\n\n/*\n** Argument eType must be one of RBU_INSERT, RBU_DELETE, RBU_IDX_INSERT or\n** RBU_IDX_DELETE. This function performs the work of a single\n** sqlite3rbu_step() call for the type of operation specified by eType.\n*/\nstatic void rbuStepOneOp(sqlite3rbu *p, int eType){\n  RbuObjIter *pIter = &p->objiter;\n  sqlite3_value *pVal;\n  sqlite3_stmt *pWriter;\n  int i;\n\n  assert( p->rc==SQLITE_OK );\n  assert( eType!=RBU_DELETE || pIter->zIdx==0 );\n  assert( eType==RBU_DELETE || eType==RBU_IDX_DELETE\n       || eType==RBU_INSERT || eType==RBU_IDX_INSERT\n  );\n\n  /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE\n  ** statement below does actually delete a row, nPhaseOneStep will be\n  ** incremented by the same amount when SQL function rbu_tmp_insert()\n  ** is invoked by the trigger.  */\n  if( eType==RBU_DELETE ){\n    p->nPhaseOneStep -= p->objiter.nIndex;\n  }\n\n  if( eType==RBU_IDX_DELETE || eType==RBU_DELETE ){\n    pWriter = pIter->pDelete;\n  }else{\n    pWriter = pIter->pInsert;\n  }\n\n  for(i=0; i<pIter->nCol; i++){\n    /* If this is an INSERT into a table b-tree and the table has an\n    ** explicit INTEGER PRIMARY KEY, check that this is not an attempt\n    ** to write a NULL into the IPK column. That is not permitted.  */\n    if( eType==RBU_INSERT \n     && pIter->zIdx==0 && pIter->eType==RBU_PK_IPK && pIter->abTblPk[i] \n     && sqlite3_column_type(pIter->pSelect, i)==SQLITE_NULL\n    ){\n      p->rc = SQLITE_MISMATCH;\n      p->zErrmsg = sqlite3_mprintf(\"datatype mismatch\");\n      return;\n    }\n\n    if( eType==RBU_DELETE && pIter->abTblPk[i]==0 ){\n      continue;\n    }\n\n    pVal = sqlite3_column_value(pIter->pSelect, i);\n    p->rc = sqlite3_bind_value(pWriter, i+1, pVal);\n    if( p->rc ) return;\n  }\n  if( pIter->zIdx==0 ){\n    if( pIter->eType==RBU_PK_VTAB \n     || pIter->eType==RBU_PK_NONE \n     || (pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p)) \n    ){\n      /* For a virtual table, or a table with no primary key, the \n      ** SELECT statement is:\n      **\n      **   SELECT <cols>, rbu_control, rbu_rowid FROM ....\n      **\n      ** Hence column_value(pIter->nCol+1).\n      */\n      assertColumnName(pIter->pSelect, pIter->nCol+1, \n          rbuIsVacuum(p) ? \"rowid\" : \"rbu_rowid\"\n      );\n      pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n      p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);\n    }\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_step(pWriter);\n    p->rc = resetAndCollectError(pWriter, &p->zErrmsg);\n  }\n}\n\n/*\n** This function does the work for an sqlite3rbu_step() call.\n**\n** The object-iterator (p->objiter) currently points to a valid object,\n** and the input cursor (p->objiter.pSelect) currently points to a valid\n** input row. Perform whatever processing is required and return.\n**\n** If no  error occurs, SQLITE_OK is returned. Otherwise, an error code\n** and message is left in the RBU handle and a copy of the error code\n** returned.\n*/\nstatic int rbuStep(sqlite3rbu *p){\n  RbuObjIter *pIter = &p->objiter;\n  const char *zMask = 0;\n  int eType = rbuStepType(p, &zMask);\n\n  if( eType ){\n    assert( eType==RBU_INSERT     || eType==RBU_DELETE\n         || eType==RBU_REPLACE    || eType==RBU_IDX_DELETE\n         || eType==RBU_IDX_INSERT || eType==RBU_UPDATE\n    );\n    assert( eType!=RBU_UPDATE || pIter->zIdx==0 );\n\n    if( pIter->zIdx==0 && (eType==RBU_IDX_DELETE || eType==RBU_IDX_INSERT) ){\n      rbuBadControlError(p);\n    }\n    else if( eType==RBU_REPLACE ){\n      if( pIter->zIdx==0 ){\n        p->nPhaseOneStep += p->objiter.nIndex;\n        rbuStepOneOp(p, RBU_DELETE);\n      }\n      if( p->rc==SQLITE_OK ) rbuStepOneOp(p, RBU_INSERT);\n    }\n    else if( eType!=RBU_UPDATE ){\n      rbuStepOneOp(p, eType);\n    }\n    else{\n      sqlite3_value *pVal;\n      sqlite3_stmt *pUpdate = 0;\n      assert( eType==RBU_UPDATE );\n      p->nPhaseOneStep -= p->objiter.nIndex;\n      rbuGetUpdateStmt(p, pIter, zMask, &pUpdate);\n      if( pUpdate ){\n        int i;\n        for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){\n          char c = zMask[pIter->aiSrcOrder[i]];\n          pVal = sqlite3_column_value(pIter->pSelect, i);\n          if( pIter->abTblPk[i] || c!='.' ){\n            p->rc = sqlite3_bind_value(pUpdate, i+1, pVal);\n          }\n        }\n        if( p->rc==SQLITE_OK \n         && (pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE) \n        ){\n          /* Bind the rbu_rowid value to column _rowid_ */\n          assertColumnName(pIter->pSelect, pIter->nCol+1, \"rbu_rowid\");\n          pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n          p->rc = sqlite3_bind_value(pUpdate, pIter->nCol+1, pVal);\n        }\n        if( p->rc==SQLITE_OK ){\n          sqlite3_step(pUpdate);\n          p->rc = resetAndCollectError(pUpdate, &p->zErrmsg);\n        }\n      }\n    }\n  }\n  return p->rc;\n}\n\n/*\n** Increment the schema cookie of the main database opened by p->dbMain.\n**\n** Or, if this is an RBU vacuum, set the schema cookie of the main db\n** opened by p->dbMain to one more than the schema cookie of the main\n** db opened by p->dbRbu.\n*/\nstatic void rbuIncrSchemaCookie(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3 *dbread = (rbuIsVacuum(p) ? p->dbRbu : p->dbMain);\n    int iCookie = 1000000;\n    sqlite3_stmt *pStmt;\n\n    p->rc = prepareAndCollectError(dbread, &pStmt, &p->zErrmsg, \n        \"PRAGMA schema_version\"\n    );\n    if( p->rc==SQLITE_OK ){\n      /* Coverage: it may be that this sqlite3_step() cannot fail. There\n      ** is already a transaction open, so the prepared statement cannot\n      ** throw an SQLITE_SCHEMA exception. The only database page the\n      ** statement reads is page 1, which is guaranteed to be in the cache.\n      ** And no memory allocations are required.  */\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        iCookie = sqlite3_column_int(pStmt, 0);\n      }\n      rbuFinalize(p, pStmt);\n    }\n    if( p->rc==SQLITE_OK ){\n      rbuMPrintfExec(p, p->dbMain, \"PRAGMA schema_version = %d\", iCookie+1);\n    }\n  }\n}\n\n/*\n** Update the contents of the rbu_state table within the rbu database. The\n** value stored in the RBU_STATE_STAGE column is eStage. All other values\n** are determined by inspecting the rbu handle passed as the first argument.\n*/\nstatic void rbuSaveState(sqlite3rbu *p, int eStage){\n  if( p->rc==SQLITE_OK || p->rc==SQLITE_DONE ){\n    sqlite3_stmt *pInsert = 0;\n    rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n    int rc;\n\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbRbu, &pInsert, &p->zErrmsg, \n        sqlite3_mprintf(\n          \"INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES \"\n          \"(%d, %d), \"\n          \"(%d, %Q), \"\n          \"(%d, %Q), \"\n          \"(%d, %d), \"\n          \"(%d, %d), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld) \",\n          p->zStateDb,\n          RBU_STATE_STAGE, eStage,\n          RBU_STATE_TBL, p->objiter.zTbl, \n          RBU_STATE_IDX, p->objiter.zIdx, \n          RBU_STATE_ROW, p->nStep, \n          RBU_STATE_PROGRESS, p->nProgress,\n          RBU_STATE_CKPT, p->iWalCksum,\n          RBU_STATE_COOKIE, (i64)pFd->iCookie,\n          RBU_STATE_OALSZ, p->iOalSz,\n          RBU_STATE_PHASEONESTEP, p->nPhaseOneStep\n      )\n    );\n    assert( pInsert==0 || rc==SQLITE_OK );\n\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_finalize(pInsert);\n    }\n    if( rc!=SQLITE_OK ) p->rc = rc;\n  }\n}\n\n\n/*\n** The second argument passed to this function is the name of a PRAGMA \n** setting - \"page_size\", \"auto_vacuum\", \"user_version\" or \"application_id\".\n** This function executes the following on sqlite3rbu.dbRbu:\n**\n**   \"PRAGMA main.$zPragma\"\n**\n** where $zPragma is the string passed as the second argument, then\n** on sqlite3rbu.dbMain:\n**\n**   \"PRAGMA main.$zPragma = $val\"\n**\n** where $val is the value returned by the first PRAGMA invocation.\n**\n** In short, it copies the value  of the specified PRAGMA setting from\n** dbRbu to dbMain.\n*/\nstatic void rbuCopyPragma(sqlite3rbu *p, const char *zPragma){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pPragma = 0;\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pPragma, &p->zErrmsg, \n        sqlite3_mprintf(\"PRAGMA main.%s\", zPragma)\n    );\n    if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPragma) ){\n      p->rc = rbuMPrintfExec(p, p->dbMain, \"PRAGMA main.%s = %d\",\n          zPragma, sqlite3_column_int(pPragma, 0)\n      );\n    }\n    rbuFinalize(p, pPragma);\n  }\n}\n\n/*\n** The RBU handle passed as the only argument has just been opened and \n** the state database is empty. If this RBU handle was opened for an\n** RBU vacuum operation, create the schema in the target db.\n*/\nstatic void rbuCreateTargetSchema(sqlite3rbu *p){\n  sqlite3_stmt *pSql = 0;\n  sqlite3_stmt *pInsert = 0;\n\n  assert( rbuIsVacuum(p) );\n  p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=1\", 0,0, &p->zErrmsg);\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n      \"SELECT sql FROM sqlite_master WHERE sql!='' AND rootpage!=0\"\n      \" AND name!='sqlite_sequence' \"\n      \" ORDER BY type DESC\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    const char *zSql = (const char*)sqlite3_column_text(pSql, 0);\n    p->rc = sqlite3_exec(p->dbMain, zSql, 0, 0, &p->zErrmsg);\n  }\n  rbuFinalize(p, pSql);\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n        \"SELECT * FROM sqlite_master WHERE rootpage=0 OR rootpage IS NULL\" \n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbMain, &pInsert, &p->zErrmsg, \n        \"INSERT INTO sqlite_master VALUES(?,?,?,?,?)\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    int i;\n    for(i=0; i<5; i++){\n      sqlite3_bind_value(pInsert, i+1, sqlite3_column_value(pSql, i));\n    }\n    sqlite3_step(pInsert);\n    p->rc = sqlite3_reset(pInsert);\n  }\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=0\",0,0,&p->zErrmsg);\n  }\n\n  rbuFinalize(p, pSql);\n  rbuFinalize(p, pInsert);\n}\n\n/*\n** Step the RBU object.\n*/\nint sqlite3rbu_step(sqlite3rbu *p){\n  if( p ){\n    switch( p->eStage ){\n      case RBU_STAGE_OAL: {\n        RbuObjIter *pIter = &p->objiter;\n\n        /* If this is an RBU vacuum operation and the state table was empty\n        ** when this handle was opened, create the target database schema. */\n        if( rbuIsVacuum(p) && p->nProgress==0 && p->rc==SQLITE_OK ){\n          rbuCreateTargetSchema(p);\n          rbuCopyPragma(p, \"user_version\");\n          rbuCopyPragma(p, \"application_id\");\n        }\n\n        while( p->rc==SQLITE_OK && pIter->zTbl ){\n\n          if( pIter->bCleanup ){\n            /* Clean up the rbu_tmp_xxx table for the previous table. It \n            ** cannot be dropped as there are currently active SQL statements.\n            ** But the contents can be deleted.  */\n            if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n              rbuMPrintfExec(p, p->dbRbu, \n                  \"DELETE FROM %s.'rbu_tmp_%q'\", p->zStateDb, pIter->zDataTbl\n              );\n            }\n          }else{\n            rbuObjIterPrepareAll(p, pIter, 0);\n\n            /* Advance to the next row to process. */\n            if( p->rc==SQLITE_OK ){\n              int rc = sqlite3_step(pIter->pSelect);\n              if( rc==SQLITE_ROW ){\n                p->nProgress++;\n                p->nStep++;\n                return rbuStep(p);\n              }\n              p->rc = sqlite3_reset(pIter->pSelect);\n              p->nStep = 0;\n            }\n          }\n\n          rbuObjIterNext(p, pIter);\n        }\n\n        if( p->rc==SQLITE_OK ){\n          assert( pIter->zTbl==0 );\n          rbuSaveState(p, RBU_STAGE_MOVE);\n          rbuIncrSchemaCookie(p);\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          p->eStage = RBU_STAGE_MOVE;\n        }\n        break;\n      }\n\n      case RBU_STAGE_MOVE: {\n        if( p->rc==SQLITE_OK ){\n          rbuMoveOalFile(p);\n          p->nProgress++;\n        }\n        break;\n      }\n\n      case RBU_STAGE_CKPT: {\n        if( p->rc==SQLITE_OK ){\n          if( p->nStep>=p->nFrame ){\n            sqlite3_file *pDb = p->pTargetFd->pReal;\n  \n            /* Sync the db file */\n            p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  \n            /* Update nBackfill */\n            if( p->rc==SQLITE_OK ){\n              void volatile *ptr;\n              p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, &ptr);\n              if( p->rc==SQLITE_OK ){\n                ((u32 volatile*)ptr)[24] = p->iMaxFrame;\n              }\n            }\n  \n            if( p->rc==SQLITE_OK ){\n              p->eStage = RBU_STAGE_DONE;\n              p->rc = SQLITE_DONE;\n            }\n          }else{\n            /* At one point the following block copied a single frame from the\n            ** wal file to the database file. So that one call to sqlite3rbu_step()\n            ** checkpointed a single frame. \n            **\n            ** However, if the sector-size is larger than the page-size, and the\n            ** application calls sqlite3rbu_savestate() or close() immediately\n            ** after this step, then rbu_step() again, then a power failure occurs,\n            ** then the database page written here may be damaged. Work around\n            ** this by checkpointing frames until the next page in the aFrame[]\n            ** lies on a different disk sector to the current one. */\n            u32 iSector;\n            do{\n              RbuFrame *pFrame = &p->aFrame[p->nStep];\n              iSector = (pFrame->iDbPage-1) / p->nPagePerSector;\n              rbuCheckpointFrame(p, pFrame);\n              p->nStep++;\n            }while( p->nStep<p->nFrame \n                 && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)\n                 && p->rc==SQLITE_OK\n            );\n          }\n          p->nProgress++;\n        }\n        break;\n      }\n\n      default:\n        break;\n    }\n    return p->rc;\n  }else{\n    return SQLITE_NOMEM;\n  }\n}\n\n/*\n** Compare strings z1 and z2, returning 0 if they are identical, or non-zero\n** otherwise. Either or both argument may be NULL. Two NULL values are\n** considered equal, and NULL is considered distinct from all other values.\n*/\nstatic int rbuStrCompare(const char *z1, const char *z2){\n  if( z1==0 && z2==0 ) return 0;\n  if( z1==0 || z2==0 ) return 1;\n  return (sqlite3_stricmp(z1, z2)!=0);\n}\n\n/*\n** This function is called as part of sqlite3rbu_open() when initializing\n** an rbu handle in OAL stage. If the rbu update has not started (i.e.\n** the rbu_state table was empty) it is a no-op. Otherwise, it arranges\n** things so that the next call to sqlite3rbu_step() continues on from\n** where the previous rbu handle left off.\n**\n** If an error occurs, an error code and error message are left in the\n** rbu handle passed as the first argument.\n*/\nstatic void rbuSetupOal(sqlite3rbu *p, RbuState *pState){\n  assert( p->rc==SQLITE_OK );\n  if( pState->zTbl ){\n    RbuObjIter *pIter = &p->objiter;\n    int rc = SQLITE_OK;\n\n    while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup \n       || rbuStrCompare(pIter->zIdx, pState->zIdx)\n       || rbuStrCompare(pIter->zTbl, pState->zTbl) \n    )){\n      rc = rbuObjIterNext(p, pIter);\n    }\n\n    if( rc==SQLITE_OK && !pIter->zTbl ){\n      rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"rbu_state mismatch error\");\n    }\n\n    if( rc==SQLITE_OK ){\n      p->nStep = pState->nRow;\n      rc = rbuObjIterPrepareAll(p, &p->objiter, p->nStep);\n    }\n\n    p->rc = rc;\n  }\n}\n\n/*\n** If there is a \"*-oal\" file in the file-system corresponding to the\n** target database in the file-system, delete it. If an error occurs,\n** leave an error code and error message in the rbu handle.\n*/\nstatic void rbuDeleteOalFile(sqlite3rbu *p){\n  char *zOal = rbuMPrintf(p, \"%s-oal\", p->zTarget);\n  if( zOal ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n    assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 );\n    pVfs->xDelete(pVfs, zOal, 0);\n    sqlite3_free(zOal);\n  }\n}\n\n/*\n** Allocate a private rbu VFS for the rbu handle passed as the only\n** argument. This VFS will be used unless the call to sqlite3rbu_open()\n** specified a URI with a vfs=? option in place of a target database\n** file name.\n*/\nstatic void rbuCreateVfs(sqlite3rbu *p){\n  int rnd;\n  char zRnd[64];\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3_randomness(sizeof(int), (void*)&rnd);\n  sqlite3_snprintf(sizeof(zRnd), zRnd, \"rbu_vfs_%d\", rnd);\n  p->rc = sqlite3rbu_create_vfs(zRnd, 0);\n  if( p->rc==SQLITE_OK ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(zRnd);\n    assert( pVfs );\n    p->zVfsName = pVfs->zName;\n    ((rbu_vfs*)pVfs)->pRbu = p;\n  }\n}\n\n/*\n** Destroy the private VFS created for the rbu handle passed as the only\n** argument by an earlier call to rbuCreateVfs().\n*/\nstatic void rbuDeleteVfs(sqlite3rbu *p){\n  if( p->zVfsName ){\n    sqlite3rbu_destroy_vfs(p->zVfsName);\n    p->zVfsName = 0;\n  }\n}\n\n/*\n** This user-defined SQL function is invoked with a single argument - the\n** name of a table expected to appear in the target database. It returns\n** the number of auxilliary indexes on the table.\n*/\nstatic void rbuIndexCntFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);\n  sqlite3_stmt *pStmt = 0;\n  char *zErrmsg = 0;\n  int rc;\n\n  assert( nVal==1 );\n  \n  rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg, \n      sqlite3_mprintf(\"SELECT count(*) FROM sqlite_master \"\n        \"WHERE type='index' AND tbl_name = %Q\", sqlite3_value_text(apVal[0]))\n  );\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error(pCtx, zErrmsg, -1);\n  }else{\n    int nIndex = 0;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      nIndex = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_int(pCtx, nIndex);\n    }else{\n      sqlite3_result_error(pCtx, sqlite3_errmsg(p->dbMain), -1);\n    }\n  }\n\n  sqlite3_free(zErrmsg);\n}\n\n/*\n** If the RBU database contains the rbu_count table, use it to initialize\n** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table\n** is assumed to contain the same columns as:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There should be one row in the table for each data_xxx table in the\n** database. The 'tbl' column should contain the name of a data_xxx table,\n** and the cnt column the number of rows it contains.\n**\n** sqlite3rbu.nPhaseOneStep is initialized to the sum of (1 + nIndex) * cnt\n** for all rows in the rbu_count table, where nIndex is the number of \n** indexes on the corresponding target database table.\n*/\nstatic void rbuInitPhaseOneSteps(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pStmt = 0;\n    int bExists = 0;                /* True if rbu_count exists */\n\n    p->nPhaseOneStep = -1;\n\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_index_cnt\", 1, SQLITE_UTF8, (void*)p, rbuIndexCntFunc, 0, 0\n    );\n  \n    /* Check for the rbu_count table. If it does not exist, or if an error\n    ** occurs, nPhaseOneStep will be left set to -1. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT 1 FROM sqlite_master WHERE tbl_name = 'rbu_count'\"\n      );\n    }\n    if( p->rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        bExists = 1;\n      }\n      p->rc = sqlite3_finalize(pStmt);\n    }\n  \n    if( p->rc==SQLITE_OK && bExists ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))\"\n          \"FROM rbu_count\"\n      );\n      if( p->rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          p->nPhaseOneStep = sqlite3_column_int64(pStmt, 0);\n        }\n        p->rc = sqlite3_finalize(pStmt);\n      }\n    }\n  }\n}\n\n\nstatic sqlite3rbu *openRbuHandle(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  sqlite3rbu *p;\n  size_t nTarget = zTarget ? strlen(zTarget) : 0;\n  size_t nRbu = strlen(zRbu);\n  size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1;\n\n  p = (sqlite3rbu*)sqlite3_malloc64(nByte);\n  if( p ){\n    RbuState *pState = 0;\n\n    /* Create the custom VFS. */\n    memset(p, 0, sizeof(sqlite3rbu));\n    rbuCreateVfs(p);\n\n    /* Open the target, RBU and state databases */\n    if( p->rc==SQLITE_OK ){\n      char *pCsr = (char*)&p[1];\n      int bRetry = 0;\n      if( zTarget ){\n        p->zTarget = pCsr;\n        memcpy(p->zTarget, zTarget, nTarget+1);\n        pCsr += nTarget+1;\n      }\n      p->zRbu = pCsr;\n      memcpy(p->zRbu, zRbu, nRbu+1);\n      pCsr += nRbu+1;\n      if( zState ){\n        p->zState = rbuMPrintf(p, \"%s\", zState);\n      }\n\n      /* If the first attempt to open the database file fails and the bRetry\n      ** flag it set, this means that the db was not opened because it seemed\n      ** to be a wal-mode db. But, this may have happened due to an earlier\n      ** RBU vacuum operation leaving an old wal file in the directory.\n      ** If this is the case, it will have been checkpointed and deleted\n      ** when the handle was closed and a second attempt to open the \n      ** database may succeed.  */\n      rbuOpenDatabase(p, &bRetry);\n      if( bRetry ){\n        rbuOpenDatabase(p, 0);\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      pState = rbuLoadState(p);\n      assert( pState || p->rc!=SQLITE_OK );\n      if( p->rc==SQLITE_OK ){\n\n        if( pState->eStage==0 ){ \n          rbuDeleteOalFile(p);\n          rbuInitPhaseOneSteps(p);\n          p->eStage = RBU_STAGE_OAL;\n        }else{\n          p->eStage = pState->eStage;\n          p->nPhaseOneStep = pState->nPhaseOneStep;\n        }\n        p->nProgress = pState->nProgress;\n        p->iOalSz = pState->iOalSz;\n      }\n    }\n    assert( p->rc!=SQLITE_OK || p->eStage!=0 );\n\n    if( p->rc==SQLITE_OK && p->pTargetFd->pWalFd ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"cannot update wal mode database\");\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        p->eStage = RBU_STAGE_CKPT;\n        p->nStep = 0;\n      }\n    }\n\n    if( p->rc==SQLITE_OK \n     && (p->eStage==RBU_STAGE_OAL || p->eStage==RBU_STAGE_MOVE)\n     && pState->eStage!=0\n    ){\n      rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n      if( pFd->iCookie!=pState->iCookie ){   \n        /* At this point (pTargetFd->iCookie) contains the value of the\n        ** change-counter cookie (the thing that gets incremented when a \n        ** transaction is committed in rollback mode) currently stored on \n        ** page 1 of the database file. */\n        p->rc = SQLITE_BUSY;\n        p->zErrmsg = sqlite3_mprintf(\"database modified during rbu %s\",\n            (rbuIsVacuum(p) ? \"vacuum\" : \"update\")\n        );\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        sqlite3 *db = p->dbMain;\n        p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, &p->zErrmsg);\n\n        /* Point the object iterator at the first object */\n        if( p->rc==SQLITE_OK ){\n          p->rc = rbuObjIterFirst(p, &p->objiter);\n        }\n\n        /* If the RBU database contains no data_xxx tables, declare the RBU\n        ** update finished.  */\n        if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){\n          p->rc = SQLITE_DONE;\n          p->eStage = RBU_STAGE_DONE;\n        }else{\n          if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){\n            rbuCopyPragma(p, \"page_size\");\n            rbuCopyPragma(p, \"auto_vacuum\");\n          }\n\n          /* Open transactions both databases. The *-oal file is opened or\n          ** created at this point. */\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(db, \"BEGIN IMMEDIATE\", 0, 0, &p->zErrmsg);\n          }\n\n          /* Check if the main database is a zipvfs db. If it is, set the upper\n          ** level pager to use \"journal_mode=off\". This prevents it from \n          ** generating a large journal using a temp file.  */\n          if( p->rc==SQLITE_OK ){\n            int frc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_ZIPVFS, 0);\n            if( frc==SQLITE_OK ){\n              p->rc = sqlite3_exec(\n                db, \"PRAGMA journal_mode=off\",0,0,&p->zErrmsg);\n            }\n          }\n\n          if( p->rc==SQLITE_OK ){\n            rbuSetupOal(p, pState);\n          }\n        }\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        /* no-op */\n      }else if( p->eStage==RBU_STAGE_CKPT ){\n        rbuSetupCheckpoint(p, pState);\n      }else if( p->eStage==RBU_STAGE_DONE ){\n        p->rc = SQLITE_DONE;\n      }else{\n        p->rc = SQLITE_CORRUPT;\n      }\n    }\n\n    rbuFreeState(pState);\n  }\n\n  return p;\n}\n\n/*\n** Allocate and return an RBU handle with all fields zeroed except for the\n** error code, which is set to SQLITE_MISUSE.\n*/\nstatic sqlite3rbu *rbuMisuseError(void){\n  sqlite3rbu *pRet;\n  pRet = sqlite3_malloc64(sizeof(sqlite3rbu));\n  if( pRet ){\n    memset(pRet, 0, sizeof(sqlite3rbu));\n    pRet->rc = SQLITE_MISUSE;\n  }\n  return pRet;\n}\n\n/*\n** Open and return a new RBU handle. \n*/\nsqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); }\n  /* TODO: Check that zTarget and zRbu are non-NULL */\n  return openRbuHandle(zTarget, zRbu, zState);\n}\n\n/*\n** Open a handle to begin or resume an RBU VACUUM operation.\n*/\nsqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n){\n  if( zTarget==0 ){ return rbuMisuseError(); }\n  /* TODO: Check that both arguments are non-NULL */\n  return openRbuHandle(0, zTarget, zState);\n}\n\n/*\n** Return the database handle used by pRbu.\n*/\nsqlite3 *sqlite3rbu_db(sqlite3rbu *pRbu, int bRbu){\n  sqlite3 *db = 0;\n  if( pRbu ){\n    db = (bRbu ? pRbu->dbRbu : pRbu->dbMain);\n  }\n  return db;\n}\n\n\n/*\n** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT,\n** then edit any error message string so as to remove all occurrences of\n** the pattern \"rbu_imp_[0-9]*\".\n*/\nstatic void rbuEditErrmsg(sqlite3rbu *p){\n  if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){\n    unsigned int i;\n    size_t nErrmsg = strlen(p->zErrmsg);\n    for(i=0; i<(nErrmsg-8); i++){\n      if( memcmp(&p->zErrmsg[i], \"rbu_imp_\", 8)==0 ){\n        int nDel = 8;\n        while( p->zErrmsg[i+nDel]>='0' && p->zErrmsg[i+nDel]<='9' ) nDel++;\n        memmove(&p->zErrmsg[i], &p->zErrmsg[i+nDel], nErrmsg + 1 - i - nDel);\n        nErrmsg -= nDel;\n      }\n    }\n  }\n}\n\n/*\n** Close the RBU handle.\n*/\nint sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){\n  int rc;\n  if( p ){\n\n    /* Commit the transaction to the *-oal file. */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Sync the db file if currently doing an incremental checkpoint */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n    }\n\n    rbuSaveState(p, p->eStage);\n\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Close any open statement handles. */\n    rbuObjIterFinalize(&p->objiter);\n\n    /* If this is an RBU vacuum handle and the vacuum has either finished\n    ** successfully or encountered an error, delete the contents of the \n    ** state table. This causes the next call to sqlite3rbu_vacuum() \n    ** specifying the current target and state databases to start a new\n    ** vacuum from scratch.  */\n    if( rbuIsVacuum(p) && p->rc!=SQLITE_OK && p->dbRbu ){\n      int rc2 = sqlite3_exec(p->dbRbu, \"DELETE FROM stat.rbu_state\", 0, 0, 0);\n      if( p->rc==SQLITE_DONE && rc2!=SQLITE_OK ) p->rc = rc2;\n    }\n\n    /* Close the open database handle and VFS object. */\n    sqlite3_close(p->dbRbu);\n    sqlite3_close(p->dbMain);\n    assert( p->szTemp==0 );\n    rbuDeleteVfs(p);\n    sqlite3_free(p->aBuf);\n    sqlite3_free(p->aFrame);\n\n    rbuEditErrmsg(p);\n    rc = p->rc;\n    if( pzErrmsg ){\n      *pzErrmsg = p->zErrmsg;\n    }else{\n      sqlite3_free(p->zErrmsg);\n    }\n    sqlite3_free(p->zState);\n    sqlite3_free(p);\n  }else{\n    rc = SQLITE_NOMEM;\n    *pzErrmsg = 0;\n  }\n  return rc;\n}\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nsqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu){\n  return pRbu->nProgress;\n}\n\n/*\n** Return permyriadage progress indications for the two main stages of\n** an RBU update.\n*/\nvoid sqlite3rbu_bp_progress(sqlite3rbu *p, int *pnOne, int *pnTwo){\n  const int MAX_PROGRESS = 10000;\n  switch( p->eStage ){\n    case RBU_STAGE_OAL:\n      if( p->nPhaseOneStep>0 ){\n        *pnOne = (int)(MAX_PROGRESS * (i64)p->nProgress/(i64)p->nPhaseOneStep);\n      }else{\n        *pnOne = -1;\n      }\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_MOVE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_CKPT:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = (int)(MAX_PROGRESS * (i64)p->nStep / (i64)p->nFrame);\n      break;\n\n    case RBU_STAGE_DONE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = MAX_PROGRESS;\n      break;\n\n    default:\n      assert( 0 );\n  }\n}\n\n/*\n** Return the current state of the RBU vacuum or update operation.\n*/\nint sqlite3rbu_state(sqlite3rbu *p){\n  int aRes[] = {\n    0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,\n    0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE\n  };\n\n  assert( RBU_STAGE_OAL==1 );\n  assert( RBU_STAGE_MOVE==2 );\n  assert( RBU_STAGE_CKPT==4 );\n  assert( RBU_STAGE_DONE==5 );\n  assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );\n  assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );\n  assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );\n  assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );\n\n  if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){\n    return SQLITE_RBU_STATE_ERROR;\n  }else{\n    assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );\n    assert( p->eStage==RBU_STAGE_OAL\n         || p->eStage==RBU_STAGE_MOVE\n         || p->eStage==RBU_STAGE_CKPT\n         || p->eStage==RBU_STAGE_DONE\n    );\n    return aRes[p->eStage];\n  }\n}\n\nint sqlite3rbu_savestate(sqlite3rbu *p){\n  int rc = p->rc;\n  if( rc==SQLITE_DONE ) return SQLITE_OK;\n\n  assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, 0);\n  }\n\n  /* Sync the db file */\n  if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  }\n\n  p->rc = rc;\n  rbuSaveState(p, p->eStage);\n  rc = p->rc;\n\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, \"BEGIN IMMEDIATE\", 0, 0, 0);\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"BEGIN IMMEDIATE\", 0, 0,0);\n  }\n\n  p->rc = rc;\n  return rc;\n}\n\n/**************************************************************************\n** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour\n** of a standard VFS in the following ways:\n**\n** 1. Whenever the first page of a main database file is read or \n**    written, the value of the change-counter cookie is stored in\n**    rbu_file.iCookie. Similarly, the value of the \"write-version\"\n**    database header field is stored in rbu_file.iWriteVer. This ensures\n**    that the values are always trustworthy within an open transaction.\n**\n** 2. Whenever an SQLITE_OPEN_WAL file is opened, the (rbu_file.pWalFd)\n**    member variable of the associated database file descriptor is set\n**    to point to the new file. A mutex protected linked list of all main \n**    db fds opened using a particular RBU VFS is maintained at \n**    rbu_vfs.pMain to facilitate this.\n**\n** 3. Using a new file-control \"SQLITE_FCNTL_RBU\", a main db rbu_file \n**    object can be marked as the target database of an RBU update. This\n**    turns on the following extra special behaviour:\n**\n** 3a. If xAccess() is called to check if there exists a *-wal file \n**     associated with an RBU target database currently in RBU_STAGE_OAL\n**     stage (preparing the *-oal file), the following special handling\n**     applies:\n**\n**      * if the *-wal file does exist, return SQLITE_CANTOPEN. An RBU\n**        target database may not be in wal mode already.\n**\n**      * if the *-wal file does not exist, set the output parameter to\n**        non-zero (to tell SQLite that it does exist) anyway.\n**\n**     Then, when xOpen() is called to open the *-wal file associated with\n**     the RBU target in RBU_STAGE_OAL stage, instead of opening the *-wal\n**     file, the rbu vfs opens the corresponding *-oal file instead. \n**\n** 3b. The *-shm pages returned by xShmMap() for a target db file in\n**     RBU_STAGE_OAL mode are actually stored in heap memory. This is to\n**     avoid creating a *-shm file on disk. Additionally, xShmLock() calls\n**     are no-ops on target database files in RBU_STAGE_OAL mode. This is\n**     because assert() statements in some VFS implementations fail if \n**     xShmLock() is called before xShmMap().\n**\n** 3c. If an EXCLUSIVE lock is attempted on a target database file in any\n**     mode except RBU_STAGE_DONE (all work completed and checkpointed), it \n**     fails with an SQLITE_BUSY error. This is to stop RBU connections\n**     from automatically checkpointing a *-wal (or *-oal) file from within\n**     sqlite3_close().\n**\n** 3d. In RBU_STAGE_CAPTURE mode, all xRead() calls on the wal file, and\n**     all xWrite() calls on the target database file perform no IO. \n**     Instead the frame and page numbers that would be read and written\n**     are recorded. Additionally, successful attempts to obtain exclusive\n**     xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target \n**     database file are recorded. xShmLock() calls to unlock the same\n**     locks are no-ops (so that once obtained, these locks are never\n**     relinquished). Finally, calls to xSync() on the target database\n**     file fail with SQLITE_INTERNAL errors.\n*/\n\nstatic void rbuUnlockShm(rbu_file *p){\n  assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n  if( p->pRbu ){\n    int (*xShmLock)(sqlite3_file*,int,int,int) = p->pReal->pMethods->xShmLock;\n    int i;\n    for(i=0; i<SQLITE_SHM_NLOCK;i++){\n      if( (1<<i) & p->pRbu->mLock ){\n        xShmLock(p->pReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE);\n      }\n    }\n    p->pRbu->mLock = 0;\n  }\n}\n\n/*\n*/\nstatic int rbuUpdateTempSize(rbu_file *pFd, sqlite3_int64 nNew){\n  sqlite3rbu *pRbu = pFd->pRbu;\n  i64 nDiff = nNew - pFd->sz;\n  pRbu->szTemp += nDiff;\n  pFd->sz = nNew;\n  assert( pRbu->szTemp>=0 );\n  if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;\n  return SQLITE_OK;\n}\n\n/*\n** Close an rbu file.\n*/\nstatic int rbuVfsClose(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc;\n  int i;\n\n  /* Free the contents of the apShm[] array. And the array itself. */\n  for(i=0; i<p->nShm; i++){\n    sqlite3_free(p->apShm[i]);\n  }\n  sqlite3_free(p->apShm);\n  p->apShm = 0;\n  sqlite3_free(p->zDel);\n\n  if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n    rbu_file **pp;\n    sqlite3_mutex_enter(p->pRbuVfs->mutex);\n    for(pp=&p->pRbuVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext));\n    *pp = p->pMainNext;\n    sqlite3_mutex_leave(p->pRbuVfs->mutex);\n    rbuUnlockShm(p);\n    p->pReal->pMethods->xShmUnmap(p->pReal, 0);\n  }\n  else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    rbuUpdateTempSize(p, 0);\n  }\n\n  /* Close the underlying file handle */\n  rc = p->pReal->pMethods->xClose(p->pReal);\n  return rc;\n}\n\n\n/*\n** Read and return an unsigned 32-bit big-endian integer from the buffer \n** passed as the only argument.\n*/\nstatic u32 rbuGetU32(u8 *aBuf){\n  return ((u32)aBuf[0] << 24)\n       + ((u32)aBuf[1] << 16)\n       + ((u32)aBuf[2] <<  8)\n       + ((u32)aBuf[3]);\n}\n\n/*\n** Write an unsigned 32-bit value in big-endian format to the supplied\n** buffer.\n*/\nstatic void rbuPutU32(u8 *aBuf, u32 iVal){\n  aBuf[0] = (iVal >> 24) & 0xFF;\n  aBuf[1] = (iVal >> 16) & 0xFF;\n  aBuf[2] = (iVal >>  8) & 0xFF;\n  aBuf[3] = (iVal >>  0) & 0xFF;\n}\n\nstatic void rbuPutU16(u8 *aBuf, u16 iVal){\n  aBuf[0] = (iVal >>  8) & 0xFF;\n  aBuf[1] = (iVal >>  0) & 0xFF;\n}\n\n/*\n** Read data from an rbuVfs-file.\n*/\nstatic int rbuVfsRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_WAL );\n    rc = rbuCaptureWalRead(p->pRbu, iOfst, iAmt);\n  }else{\n    if( pRbu && pRbu->eStage==RBU_STAGE_OAL \n     && (p->openFlags & SQLITE_OPEN_WAL) \n     && iOfst>=pRbu->iOalSz \n    ){\n      rc = SQLITE_OK;\n      memset(zBuf, 0, iAmt);\n    }else{\n      rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n#if 1\n      /* If this is being called to read the first page of the target \n      ** database as part of an rbu vacuum operation, synthesize the \n      ** contents of the first page if it does not yet exist. Otherwise,\n      ** SQLite will not check for a *-wal file.  */\n      if( pRbu && rbuIsVacuum(pRbu) \n          && rc==SQLITE_IOERR_SHORT_READ && iOfst==0\n          && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n          && pRbu->rc==SQLITE_OK\n      ){\n        sqlite3_file *pFd = (sqlite3_file*)pRbu->pRbuFd;\n        rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);\n        if( rc==SQLITE_OK ){\n          u8 *aBuf = (u8*)zBuf;\n          u32 iRoot = rbuGetU32(&aBuf[52]) ? 1 : 0;\n          rbuPutU32(&aBuf[52], iRoot);      /* largest root page number */\n          rbuPutU32(&aBuf[36], 0);          /* number of free pages */\n          rbuPutU32(&aBuf[32], 0);          /* first page on free list trunk */\n          rbuPutU32(&aBuf[28], 1);          /* size of db file in pages */\n          rbuPutU32(&aBuf[24], pRbu->pRbuFd->iCookie+1);  /* Change counter */\n\n          if( iAmt>100 ){\n            memset(&aBuf[100], 0, iAmt-100);\n            rbuPutU16(&aBuf[105], iAmt & 0xFFFF);\n            aBuf[100] = 0x0D;\n          }\n        }\n      }\n#endif\n    }\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n       ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Write data to an rbuVfs-file.\n*/\nstatic int rbuVfsWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n    rc = rbuCaptureDbWrite(p->pRbu, iOfst);\n  }else{\n    if( pRbu ){\n      if( pRbu->eStage==RBU_STAGE_OAL \n       && (p->openFlags & SQLITE_OPEN_WAL) \n       && iOfst>=pRbu->iOalSz\n      ){\n        pRbu->iOalSz = iAmt + iOfst;\n      }else if( p->openFlags & SQLITE_OPEN_DELETEONCLOSE ){\n        i64 szNew = iAmt+iOfst;\n        if( szNew>p->sz ){\n          rc = rbuUpdateTempSize(p, szNew);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n      }\n    }\n    rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n      ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Truncate an rbuVfs-file.\n*/\nstatic int rbuVfsTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  rbu_file *p = (rbu_file*)pFile;\n  if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    int rc = rbuUpdateTempSize(p, size);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  return p->pReal->pMethods->xTruncate(p->pReal, size);\n}\n\n/*\n** Sync an rbuVfs-file.\n*/\nstatic int rbuVfsSync(sqlite3_file *pFile, int flags){\n  rbu_file *p = (rbu_file *)pFile;\n  if( p->pRbu && p->pRbu->eStage==RBU_STAGE_CAPTURE ){\n    if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n      return SQLITE_INTERNAL;\n    }\n    return SQLITE_OK;\n  }\n  return p->pReal->pMethods->xSync(p->pReal, flags);\n}\n\n/*\n** Return the current file-size of an rbuVfs-file.\n*/\nstatic int rbuVfsFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  rbu_file *p = (rbu_file *)pFile;\n  int rc;\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n\n  /* If this is an RBU vacuum operation and this is the target database,\n  ** pretend that it has at least one page. Otherwise, SQLite will not\n  ** check for the existance of a *-wal file. rbuVfsRead() contains \n  ** similar logic.  */\n  if( rc==SQLITE_OK && *pSize==0 \n   && p->pRbu && rbuIsVacuum(p->pRbu) \n   && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n  ){\n    *pSize = 1024;\n  }\n  return rc;\n}\n\n/*\n** Lock an rbuVfs-file.\n*/\nstatic int rbuVfsLock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eLock==SQLITE_LOCK_EXCLUSIVE \n   && (p->bNolock || (pRbu && pRbu->eStage!=RBU_STAGE_DONE))\n  ){\n    /* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this \n    ** prevents it from checkpointing the database from sqlite3_close(). */\n    rc = SQLITE_BUSY;\n  }else{\n    rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  }\n\n  return rc;\n}\n\n/*\n** Unlock an rbuVfs-file.\n*/\nstatic int rbuVfsUnlock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xUnlock(p->pReal, eLock);\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an rbuVfs-file.\n*/\nstatic int rbuVfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an rbuVfs-file.\n*/\nstatic int rbuVfsFileControl(sqlite3_file *pFile, int op, void *pArg){\n  rbu_file *p = (rbu_file *)pFile;\n  int (*xControl)(sqlite3_file*,int,void*) = p->pReal->pMethods->xFileControl;\n  int rc;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB)\n       || p->openFlags & (SQLITE_OPEN_TRANSIENT_DB|SQLITE_OPEN_TEMP_JOURNAL)\n  );\n  if( op==SQLITE_FCNTL_RBU ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n\n    /* First try to find another RBU vfs lower down in the vfs stack. If\n    ** one is found, this vfs will operate in pass-through mode. The lower\n    ** level vfs will do the special RBU handling.  */\n    rc = xControl(p->pReal, op, pArg);\n\n    if( rc==SQLITE_NOTFOUND ){\n      /* Now search for a zipvfs instance lower down in the VFS stack. If\n      ** one is found, this is an error.  */\n      void *dummy = 0;\n      rc = xControl(p->pReal, SQLITE_FCNTL_ZIPVFS, &dummy);\n      if( rc==SQLITE_OK ){\n        rc = SQLITE_ERROR;\n        pRbu->zErrmsg = sqlite3_mprintf(\"rbu/zipvfs setup error\");\n      }else if( rc==SQLITE_NOTFOUND ){\n        pRbu->pTargetFd = p;\n        p->pRbu = pRbu;\n        if( p->pWalFd ) p->pWalFd->pRbu = pRbu;\n        rc = SQLITE_OK;\n      }\n    }\n    return rc;\n  }\n  else if( op==SQLITE_FCNTL_RBUCNT ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n    pRbu->nRbu++;\n    pRbu->pRbuFd = p;\n    p->bNolock = 1;\n  }\n\n  rc = xControl(p->pReal, op, pArg);\n  if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){\n    rbu_vfs *pRbuVfs = p->pRbuVfs;\n    char *zIn = *(char**)pArg;\n    char *zOut = sqlite3_mprintf(\"rbu(%s)/%z\", pRbuVfs->base.zName, zIn);\n    *(char**)pArg = zOut;\n    if( zOut==0 ) rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an rbuVfs-file.\n*/\nstatic int rbuVfsSectorSize(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xSectorSize(p->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an rbuVfs-file.\n*/\nstatic int rbuVfsDeviceCharacteristics(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n}\n\n/*\n** Take or release a shared-memory lock.\n*/\nstatic int rbuVfsShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_AMALGAMATION\n    assert( WAL_CKPT_LOCK==1 );\n#endif\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( pRbu && (pRbu->eStage==RBU_STAGE_OAL || pRbu->eStage==RBU_STAGE_MOVE) ){\n    /* Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from\n    ** taking this lock also prevents any checkpoints from occurring. \n    ** todo: really, it's not clear why this might occur, as \n    ** wal_autocheckpoint ought to be turned off.  */\n    if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY;\n  }else{\n    int bCapture = 0;\n    if( n==1 && (flags & SQLITE_SHM_EXCLUSIVE)\n     && pRbu && pRbu->eStage==RBU_STAGE_CAPTURE\n     && (ofst==WAL_LOCK_WRITE || ofst==WAL_LOCK_CKPT || ofst==WAL_LOCK_READ0)\n    ){\n      bCapture = 1;\n    }\n\n    if( bCapture==0 || 0==(flags & SQLITE_SHM_UNLOCK) ){\n      rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);\n      if( bCapture && rc==SQLITE_OK ){\n        pRbu->mLock |= (1 << ofst);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Obtain a pointer to a mapping of a single 32KiB page of the *-shm file.\n*/\nstatic int rbuVfsShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  void volatile **pp\n){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this\n  ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space \n  ** instead of a file on disk.  */\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    if( iRegion<=p->nShm ){\n      int nByte = (iRegion+1) * sizeof(char*);\n      char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte);\n      if( apNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(&apNew[p->nShm], 0, sizeof(char*) * (1 + iRegion - p->nShm));\n        p->apShm = apNew;\n        p->nShm = iRegion+1;\n      }\n    }\n\n    if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){\n      char *pNew = (char*)sqlite3_malloc64(szRegion);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pNew, 0, szRegion);\n        p->apShm[iRegion] = pNew;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      *pp = p->apShm[iRegion];\n    }else{\n      *pp = 0;\n    }\n  }else{\n    assert( p->apShm==0 );\n    rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n  }\n\n  return rc;\n}\n\n/*\n** Memory barrier.\n*/\nstatic void rbuVfsShmBarrier(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n}\n\n/*\n** The xShmUnmap method.\n*/\nstatic int rbuVfsShmUnmap(sqlite3_file *pFile, int delFlag){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    /* no-op */\n  }else{\n    /* Release the checkpointer and writer locks */\n    rbuUnlockShm(p);\n    rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);\n  }\n  return rc;\n}\n\n/*\n** Given that zWal points to a buffer containing a wal file name passed to \n** either the xOpen() or xAccess() VFS method, return a pointer to the\n** file-handle opened by the same database connection on the corresponding\n** database file.\n*/\nstatic rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal){\n  rbu_file *pDb;\n  sqlite3_mutex_enter(pRbuVfs->mutex);\n  for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}\n  sqlite3_mutex_leave(pRbuVfs->mutex);\n  return pDb;\n}\n\n/* \n** A main database named zName has just been opened. The following \n** function returns a pointer to a buffer owned by SQLite that contains\n** the name of the *-wal file this db connection will use. SQLite\n** happens to pass a pointer to this buffer when using xAccess()\n** or xOpen() to operate on the *-wal file.  \n*/\nstatic const char *rbuMainToWal(const char *zName, int flags){\n  int n = (int)strlen(zName);\n  const char *z = &zName[n];\n  if( flags & SQLITE_OPEN_URI ){\n    int odd = 0;\n    while( 1 ){\n      if( z[0]==0 ){\n        odd = 1 - odd;\n        if( odd && z[1]==0 ) break;\n      }\n      z++;\n    }\n    z += 2;\n  }else{\n    while( *z==0 ) z++;\n  }\n  z += (n + 8 + 1);\n  return z;\n}\n\n/*\n** Open an rbu file handle.\n*/\nstatic int rbuVfsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  static sqlite3_io_methods rbuvfs_io_methods = {\n    2,                            /* iVersion */\n    rbuVfsClose,                  /* xClose */\n    rbuVfsRead,                   /* xRead */\n    rbuVfsWrite,                  /* xWrite */\n    rbuVfsTruncate,               /* xTruncate */\n    rbuVfsSync,                   /* xSync */\n    rbuVfsFileSize,               /* xFileSize */\n    rbuVfsLock,                   /* xLock */\n    rbuVfsUnlock,                 /* xUnlock */\n    rbuVfsCheckReservedLock,      /* xCheckReservedLock */\n    rbuVfsFileControl,            /* xFileControl */\n    rbuVfsSectorSize,             /* xSectorSize */\n    rbuVfsDeviceCharacteristics,  /* xDeviceCharacteristics */\n    rbuVfsShmMap,                 /* xShmMap */\n    rbuVfsShmLock,                /* xShmLock */\n    rbuVfsShmBarrier,             /* xShmBarrier */\n    rbuVfsShmUnmap,               /* xShmUnmap */\n    0, 0                          /* xFetch, xUnfetch */\n  };\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  rbu_file *pFd = (rbu_file *)pFile;\n  int rc = SQLITE_OK;\n  const char *zOpen = zName;\n  int oflags = flags;\n\n  memset(pFd, 0, sizeof(rbu_file));\n  pFd->pReal = (sqlite3_file*)&pFd[1];\n  pFd->pRbuVfs = pRbuVfs;\n  pFd->openFlags = flags;\n  if( zName ){\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      /* A main database has just been opened. The following block sets\n      ** (pFd->zWal) to point to a buffer owned by SQLite that contains\n      ** the name of the *-wal file this db connection will use. SQLite\n      ** happens to pass a pointer to this buffer when using xAccess()\n      ** or xOpen() to operate on the *-wal file.  */\n      pFd->zWal = rbuMainToWal(zName, flags);\n    }\n    else if( flags & SQLITE_OPEN_WAL ){\n      rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName);\n      if( pDb ){\n        if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n          /* This call is to open a *-wal file. Intead, open the *-oal. This\n          ** code ensures that the string passed to xOpen() is terminated by a\n          ** pair of '\\0' bytes in case the VFS attempts to extract a URI \n          ** parameter from it.  */\n          const char *zBase = zName;\n          size_t nCopy;\n          char *zCopy;\n          if( rbuIsVacuum(pDb->pRbu) ){\n            zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, \"main\");\n            zBase = rbuMainToWal(zBase, SQLITE_OPEN_URI);\n          }\n          nCopy = strlen(zBase);\n          zCopy = sqlite3_malloc64(nCopy+2);\n          if( zCopy ){\n            memcpy(zCopy, zBase, nCopy);\n            zCopy[nCopy-3] = 'o';\n            zCopy[nCopy] = '\\0';\n            zCopy[nCopy+1] = '\\0';\n            zOpen = (const char*)(pFd->zDel = zCopy);\n          }else{\n            rc = SQLITE_NOMEM;\n          }\n          pFd->pRbu = pDb->pRbu;\n        }\n        pDb->pWalFd = pFd;\n      }\n    }\n  }else{\n    pFd->pRbu = pRbuVfs->pRbu;\n  }\n\n  if( oflags & SQLITE_OPEN_MAIN_DB \n   && sqlite3_uri_boolean(zName, \"rbu_memory\", 0) \n  ){\n    assert( oflags & SQLITE_OPEN_MAIN_DB );\n    oflags =  SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n              SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n    zOpen = 0;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pRealVfs->xOpen(pRealVfs, zOpen, pFd->pReal, oflags, pOutFlags);\n  }\n  if( pFd->pReal->pMethods ){\n    /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods\n    ** pointer and, if the file is a main database file, link it into the\n    ** mutex protected linked list of all such files.  */\n    pFile->pMethods = &rbuvfs_io_methods;\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      sqlite3_mutex_enter(pRbuVfs->mutex);\n      pFd->pMainNext = pRbuVfs->pMain;\n      pRbuVfs->pMain = pFd;\n      sqlite3_mutex_leave(pRbuVfs->mutex);\n    }\n  }else{\n    sqlite3_free(pFd->zDel);\n  }\n\n  return rc;\n}\n\n/*\n** Delete the file located at zPath.\n*/\nstatic int rbuVfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDelete(pRealVfs, zPath, dirSync);\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int rbuVfsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  int rc;\n\n  rc = pRealVfs->xAccess(pRealVfs, zPath, flags, pResOut);\n\n  /* If this call is to check if a *-wal file associated with an RBU target\n  ** database connection exists, and the RBU update is in RBU_STAGE_OAL,\n  ** the following special handling is activated:\n  **\n  **   a) if the *-wal file does exist, return SQLITE_CANTOPEN. This\n  **      ensures that the RBU extension never tries to update a database\n  **      in wal mode, even if the first page of the database file has\n  **      been damaged. \n  **\n  **   b) if the *-wal file does not exist, claim that it does anyway,\n  **      causing SQLite to call xOpen() to open it. This call will also\n  **      be intercepted (see the rbuVfsOpen() function) and the *-oal\n  **      file opened instead.\n  */\n  if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){\n    rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath);\n    if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n      if( *pResOut ){\n        rc = SQLITE_CANTOPEN;\n      }else{\n        sqlite3_int64 sz = 0;\n        rc = rbuVfsFileSize(&pDb->base, &sz);\n        *pResOut = (sz>0);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int rbuVfsFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xFullPathname(pRealVfs, zPath, nOut, zOut);\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *rbuVfsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlOpen(pRealVfs, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void rbuVfsDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlError(pRealVfs, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*rbuVfsDlSym(\n  sqlite3_vfs *pVfs, \n  void *pArg, \n  const char *zSym\n))(void){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlSym(pRealVfs, pArg, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void rbuVfsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlClose(pRealVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int rbuVfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xRandomness(pRealVfs, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int rbuVfsSleep(sqlite3_vfs *pVfs, int nMicro){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xSleep(pRealVfs, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int rbuVfsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xCurrentTime(pRealVfs, pTimeOut);\n}\n\n/*\n** No-op.\n*/\nstatic int rbuVfsGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return 0;\n}\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n*/\nvoid sqlite3rbu_destroy_vfs(const char *zName){\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(zName);\n  if( pVfs && pVfs->xOpen==rbuVfsOpen ){\n    sqlite3_mutex_free(((rbu_vfs*)pVfs)->mutex);\n    sqlite3_vfs_unregister(pVfs);\n    sqlite3_free(pVfs);\n  }\n}\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. The new object is registered as a non-default\n** VFS with SQLite before returning.\n*/\nint sqlite3rbu_create_vfs(const char *zName, const char *zParent){\n\n  /* Template for VFS */\n  static sqlite3_vfs vfs_template = {\n    1,                            /* iVersion */\n    0,                            /* szOsFile */\n    0,                            /* mxPathname */\n    0,                            /* pNext */\n    0,                            /* zName */\n    0,                            /* pAppData */\n    rbuVfsOpen,                   /* xOpen */\n    rbuVfsDelete,                 /* xDelete */\n    rbuVfsAccess,                 /* xAccess */\n    rbuVfsFullPathname,           /* xFullPathname */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    rbuVfsDlOpen,                 /* xDlOpen */\n    rbuVfsDlError,                /* xDlError */\n    rbuVfsDlSym,                  /* xDlSym */\n    rbuVfsDlClose,                /* xDlClose */\n#else\n    0, 0, 0, 0,\n#endif\n\n    rbuVfsRandomness,             /* xRandomness */\n    rbuVfsSleep,                  /* xSleep */\n    rbuVfsCurrentTime,            /* xCurrentTime */\n    rbuVfsGetLastError,           /* xGetLastError */\n    0,                            /* xCurrentTimeInt64 (version 2) */\n    0, 0, 0                       /* Unimplemented version 3 methods */\n  };\n\n  rbu_vfs *pNew = 0;              /* Newly allocated VFS */\n  int rc = SQLITE_OK;\n  size_t nName;\n  size_t nByte;\n\n  nName = strlen(zName);\n  nByte = sizeof(rbu_vfs) + nName + 1;\n  pNew = (rbu_vfs*)sqlite3_malloc64(nByte);\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_vfs *pParent;           /* Parent VFS */\n    memset(pNew, 0, nByte);\n    pParent = sqlite3_vfs_find(zParent);\n    if( pParent==0 ){\n      rc = SQLITE_NOTFOUND;\n    }else{\n      char *zSpace;\n      memcpy(&pNew->base, &vfs_template, sizeof(sqlite3_vfs));\n      pNew->base.mxPathname = pParent->mxPathname;\n      pNew->base.szOsFile = sizeof(rbu_file) + pParent->szOsFile;\n      pNew->pRealVfs = pParent;\n      pNew->base.zName = (const char*)(zSpace = (char*)&pNew[1]);\n      memcpy(zSpace, zName, nName);\n\n      /* Allocate the mutex and register the new VFS (not as the default) */\n      pNew->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);\n      if( pNew->mutex==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        rc = sqlite3_vfs_register(&pNew->base, 0);\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_mutex_free(pNew->mutex);\n      sqlite3_free(pNew);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Configure the aggregate temp file size limit for this RBU handle.\n*/\nsqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu *pRbu, sqlite3_int64 n){\n  if( n>=0 ){\n    pRbu->szTempLimit = n;\n  }\n  return pRbu->szTempLimit;\n}\n\nsqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){\n  return pRbu->szTemp;\n}\n\n\n/**************************************************************************/\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/sqlite3rbu.h",
    "content": "/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the public interface for the RBU extension. \n*/\n\n/*\n** SUMMARY\n**\n** Writing a transaction containing a large number of operations on \n** b-tree indexes that are collectively larger than the available cache\n** memory can be very inefficient. \n**\n** The problem is that in order to update a b-tree, the leaf page (at least)\n** containing the entry being inserted or deleted must be modified. If the\n** working set of leaves is larger than the available cache memory, then a \n** single leaf that is modified more than once as part of the transaction \n** may be loaded from or written to the persistent media multiple times.\n** Additionally, because the index updates are likely to be applied in\n** random order, access to pages within the database is also likely to be in \n** random order, which is itself quite inefficient.\n**\n** One way to improve the situation is to sort the operations on each index\n** by index key before applying them to the b-tree. This leads to an IO\n** pattern that resembles a single linear scan through the index b-tree,\n** and all but guarantees each modified leaf page is loaded and stored \n** exactly once. SQLite uses this trick to improve the performance of\n** CREATE INDEX commands. This extension allows it to be used to improve\n** the performance of large transactions on existing databases.\n**\n** Additionally, this extension allows the work involved in writing the \n** large transaction to be broken down into sub-transactions performed \n** sequentially by separate processes. This is useful if the system cannot \n** guarantee that a single update process will run for long enough to apply \n** the entire update, for example because the update is being applied on a \n** mobile device that is frequently rebooted. Even after the writer process \n** has committed one or more sub-transactions, other database clients continue\n** to read from the original database snapshot. In other words, partially \n** applied transactions are not visible to other clients. \n**\n** \"RBU\" stands for \"Resumable Bulk Update\". As in a large database update\n** transmitted via a wireless network to a mobile device. A transaction\n** applied using this extension is hence refered to as an \"RBU update\".\n**\n**\n** LIMITATIONS\n**\n** An \"RBU update\" transaction is subject to the following limitations:\n**\n**   * The transaction must consist of INSERT, UPDATE and DELETE operations\n**     only.\n**\n**   * INSERT statements may not use any default values.\n**\n**   * UPDATE and DELETE statements must identify their target rows by \n**     non-NULL PRIMARY KEY values. Rows with NULL values stored in PRIMARY\n**     KEY fields may not be updated or deleted. If the table being written \n**     has no PRIMARY KEY, affected rows must be identified by rowid.\n**\n**   * UPDATE statements may not modify PRIMARY KEY columns.\n**\n**   * No triggers will be fired.\n**\n**   * No foreign key violations are detected or reported.\n**\n**   * CHECK constraints are not enforced.\n**\n**   * No constraint handling mode except for \"OR ROLLBACK\" is supported.\n**\n**\n** PREPARATION\n**\n** An \"RBU update\" is stored as a separate SQLite database. A database\n** containing an RBU update is an \"RBU database\". For each table in the \n** target database to be updated, the RBU database should contain a table\n** named \"data_<target name>\" containing the same set of columns as the\n** target table, and one more - \"rbu_control\". The data_% table should \n** have no PRIMARY KEY or UNIQUE constraints, but each column should have\n** the same type as the corresponding column in the target database.\n** The \"rbu_control\" column should have no type at all. For example, if\n** the target database contains:\n**\n**   CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE);\n**\n** Then the RBU database should contain:\n**\n**   CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);\n**\n** The order of the columns in the data_% table does not matter.\n**\n** Instead of a regular table, the RBU database may also contain virtual\n** tables or view named using the data_<target> naming scheme. \n**\n** Instead of the plain data_<target> naming scheme, RBU database tables \n** may also be named data<integer>_<target>, where <integer> is any sequence\n** of zero or more numeric characters (0-9). This can be significant because\n** tables within the RBU database are always processed in order sorted by \n** name. By judicious selection of the <integer> portion of the names\n** of the RBU tables the user can therefore control the order in which they\n** are processed. This can be useful, for example, to ensure that \"external\n** content\" FTS4 tables are updated before their underlying content tables.\n**\n** If the target database table is a virtual table or a table that has no\n** PRIMARY KEY declaration, the data_% table must also contain a column \n** named \"rbu_rowid\". This column is mapped to the tables implicit primary \n** key column - \"rowid\". Virtual tables for which the \"rowid\" column does \n** not function like a primary key value cannot be updated using RBU. For \n** example, if the target db contains either of the following:\n**\n**   CREATE VIRTUAL TABLE x1 USING fts3(a, b);\n**   CREATE TABLE x1(a, b)\n**\n** then the RBU database should contain:\n**\n**   CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control);\n**\n** All non-hidden columns (i.e. all columns matched by \"SELECT *\") of the\n** target table must be present in the input table. For virtual tables,\n** hidden columns are optional - they are updated by RBU if present in\n** the input table, or not otherwise. For example, to write to an fts4\n** table with a hidden languageid column such as:\n**\n**   CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid');\n**\n** Either of the following input table schemas may be used:\n**\n**   CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);\n**   CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);\n**\n** For each row to INSERT into the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 0. The\n** other columns should be set to the values that make up the new record \n** to insert. \n**\n** If the target database table has an INTEGER PRIMARY KEY, it is not \n** possible to insert a NULL value into the IPK column. Attempting to \n** do so results in an SQLITE_MISMATCH error.\n**\n** For each row to DELETE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 1. The\n** real primary key values of the row to delete should be stored in the\n** corresponding columns of the data_% table. The values stored in the\n** other columns are not used.\n**\n** For each row to UPDATE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain a value of type text.\n** The real primary key values identifying the row to update should be \n** stored in the corresponding columns of the data_% table row, as should\n** the new values of all columns being update. The text value in the \n** \"rbu_control\" column must contain the same number of characters as\n** there are columns in the target database table, and must consist entirely\n** of 'x' and '.' characters (or in some special cases 'd' - see below). For \n** each column that is being updated, the corresponding character is set to\n** 'x'. For those that remain as they are, the corresponding character of the\n** rbu_control value should be set to '.'. For example, given the tables \n** above, the update statement:\n**\n**   UPDATE t1 SET c = 'usa' WHERE a = 4;\n**\n** is represented by the data_t1 row created by:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..x');\n**\n** Instead of an 'x' character, characters of the rbu_control value specified\n** for UPDATEs may also be set to 'd'. In this case, instead of updating the\n** target table with the value stored in the corresponding data_% column, the\n** user-defined SQL function \"rbu_delta()\" is invoked and the result stored in\n** the target table column. rbu_delta() is invoked with two arguments - the\n** original value currently stored in the target table column and the \n** value specified in the data_xxx table.\n**\n** For example, this row:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d');\n**\n** is similar to an UPDATE statement such as: \n**\n**   UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4;\n**\n** Finally, if an 'f' character appears in place of a 'd' or 's' in an \n** ota_control string, the contents of the data_xxx table column is assumed\n** to be a \"fossil delta\" - a patch to be applied to a blob value in the\n** format used by the fossil source-code management system. In this case\n** the existing value within the target database table must be of type BLOB. \n** It is replaced by the result of applying the specified fossil delta to\n** itself.\n**\n** If the target database table is a virtual table or a table with no PRIMARY\n** KEY, the rbu_control value should not include a character corresponding \n** to the rbu_rowid value. For example, this:\n**\n**   INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control) \n**       VALUES(NULL, 'usa', 12, '.x');\n**\n** causes a result similar to:\n**\n**   UPDATE ft1 SET b = 'usa' WHERE rowid = 12;\n**\n** The data_xxx tables themselves should have no PRIMARY KEY declarations.\n** However, RBU is more efficient if reading the rows in from each data_xxx\n** table in \"rowid\" order is roughly the same as reading them sorted by\n** the PRIMARY KEY of the corresponding target database table. In other \n** words, rows should be sorted using the destination table PRIMARY KEY \n** fields before they are inserted into the data_xxx tables.\n**\n** USAGE\n**\n** The API declared below allows an application to apply an RBU update \n** stored on disk to an existing target database. Essentially, the \n** application:\n**\n**     1) Opens an RBU handle using the sqlite3rbu_open() function.\n**\n**     2) Registers any required virtual table modules with the database\n**        handle returned by sqlite3rbu_db(). Also, if required, register\n**        the rbu_delta() implementation.\n**\n**     3) Calls the sqlite3rbu_step() function one or more times on\n**        the new handle. Each call to sqlite3rbu_step() performs a single\n**        b-tree operation, so thousands of calls may be required to apply \n**        a complete update.\n**\n**     4) Calls sqlite3rbu_close() to close the RBU update handle. If\n**        sqlite3rbu_step() has been called enough times to completely\n**        apply the update to the target database, then the RBU database\n**        is marked as fully applied. Otherwise, the state of the RBU \n**        update application is saved in the RBU database for later \n**        resumption.\n**\n** See comments below for more detail on APIs.\n**\n** If an update is only partially applied to the target database by the\n** time sqlite3rbu_close() is called, various state information is saved \n** within the RBU database. This allows subsequent processes to automatically\n** resume the RBU update from where it left off.\n**\n** To remove all RBU extension state information, returning an RBU database \n** to its original contents, it is sufficient to drop all tables that begin\n** with the prefix \"rbu_\"\n**\n** DATABASE LOCKING\n**\n** An RBU update may not be applied to a database in WAL mode. Attempting\n** to do so is an error (SQLITE_ERROR).\n**\n** While an RBU handle is open, a SHARED lock may be held on the target\n** database file. This means it is possible for other clients to read the\n** database, but not to write it.\n**\n** If an RBU update is started and then suspended before it is completed,\n** then an external client writes to the database, then attempting to resume\n** the suspended RBU update is also an error (SQLITE_BUSY).\n*/\n\n#ifndef _SQLITE3RBU_H\n#define _SQLITE3RBU_H\n\n#include \"sqlite3.h\"              /* Required for error code definitions */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3rbu sqlite3rbu;\n\n/*\n** Open an RBU handle.\n**\n** Argument zTarget is the path to the target database. Argument zRbu is\n** the path to the RBU database. Each call to this function must be matched\n** by a call to sqlite3rbu_close(). When opening the databases, RBU passes\n** the SQLITE_CONFIG_URI flag to sqlite3_open_v2(). So if either zTarget\n** or zRbu begin with \"file:\", it will be interpreted as an SQLite \n** database URI, not a regular file name.\n**\n** If the zState argument is passed a NULL value, the RBU extension stores \n** the current state of the update (how many rows have been updated, which \n** indexes are yet to be updated etc.) within the RBU database itself. This\n** can be convenient, as it means that the RBU application does not need to\n** organize removing a separate state file after the update is concluded. \n** Or, if zState is non-NULL, it must be a path to a database file in which \n** the RBU extension can store the state of the update.\n**\n** When resuming an RBU update, the zState argument must be passed the same\n** value as when the RBU update was started.\n**\n** Once the RBU update is finished, the RBU extension does not \n** automatically remove any zState database file, even if it created it.\n**\n** By default, RBU uses the default VFS to access the files on disk. To\n** use a VFS other than the default, an SQLite \"file:\" URI containing a\n** \"vfs=...\" option may be passed as the zTarget option.\n**\n** IMPORTANT NOTE FOR ZIPVFS USERS: The RBU extension works with all of\n** SQLite's built-in VFSs, including the multiplexor VFS. However it does\n** not work out of the box with zipvfs. Refer to the comment describing\n** the zipvfs_create_vfs() API below for details on using RBU with zipvfs.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n);\n\n/*\n** Open an RBU handle to perform an RBU vacuum on database file zTarget.\n** An RBU vacuum is similar to SQLite's built-in VACUUM command, except\n** that it can be suspended and resumed like an RBU update.\n**\n** The second argument to this function identifies a database in which \n** to store the state of the RBU vacuum operation if it is suspended. The \n** first time sqlite3rbu_vacuum() is called, to start an RBU vacuum\n** operation, the state database should either not exist or be empty\n** (contain no tables). If an RBU vacuum is suspended by calling \n** sqlite3rbu_close() on the RBU handle before sqlite3rbu_step() has\n** returned SQLITE_DONE, the vacuum state is stored in the state database. \n** The vacuum can be resumed by calling this function to open a new RBU\n** handle specifying the same target and state databases.\n**\n** If the second argument passed to this function is NULL, then the\n** name of the state database is \"<database>-vacuum\", where <database>\n** is the name of the target database file. In this case, on UNIX, if the\n** state database is not already present in the file-system, it is created\n** with the same permissions as the target db is made.\n**\n** This function does not delete the state database after an RBU vacuum\n** is completed, even if it created it. However, if the call to\n** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents\n** of the state tables within the state database are zeroed. This way,\n** the next call to sqlite3rbu_vacuum() opens a handle that starts a \n** new RBU vacuum operation.\n**\n** As with sqlite3rbu_open(), Zipvfs users should rever to the comment\n** describing the sqlite3rbu_create_vfs() API function below for \n** a description of the complications associated with using RBU with \n** zipvfs databases.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n);\n\n/*\n** Configure a limit for the amount of temp space that may be used by\n** the RBU handle passed as the first argument. The new limit is specified\n** in bytes by the second parameter. If it is positive, the limit is updated.\n** If the second parameter to this function is passed zero, then the limit\n** is removed entirely. If the second parameter is negative, the limit is\n** not modified (this is useful for querying the current limit).\n**\n** In all cases the returned value is the current limit in bytes (zero \n** indicates unlimited).\n**\n** If the temp space limit is exceeded during operation, an SQLITE_FULL\n** error is returned.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu*, sqlite3_int64);\n\n/*\n** Return the current amount of temp file space, in bytes, currently used by \n** the RBU handle passed as the only argument.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu*);\n\n/*\n** Internally, each RBU connection uses a separate SQLite database \n** connection to access the target and rbu update databases. This\n** API allows the application direct access to these database handles.\n**\n** The first argument passed to this function must be a valid, open, RBU\n** handle. The second argument should be passed zero to access the target\n** database handle, or non-zero to access the rbu update database handle.\n** Accessing the underlying database handles may be useful in the\n** following scenarios:\n**\n**   * If any target tables are virtual tables, it may be necessary to\n**     call sqlite3_create_module() on the target database handle to \n**     register the required virtual table implementations.\n**\n**   * If the data_xxx tables in the RBU source database are virtual \n**     tables, the application may need to call sqlite3_create_module() on\n**     the rbu update db handle to any required virtual table\n**     implementations.\n**\n**   * If the application uses the \"rbu_delta()\" feature described above,\n**     it must use sqlite3_create_function() or similar to register the\n**     rbu_delta() implementation with the target database handle.\n**\n** If an error has occurred, either while opening or stepping the RBU object,\n** this function may return NULL. The error code and message may be collected\n** when sqlite3rbu_close() is called.\n**\n** Database handles returned by this function remain valid until the next\n** call to any sqlite3rbu_xxx() function other than sqlite3rbu_db().\n*/\nSQLITE_API sqlite3 *sqlite3rbu_db(sqlite3rbu*, int bRbu);\n\n/*\n** Do some work towards applying the RBU update to the target db. \n**\n** Return SQLITE_DONE if the update has been completely applied, or \n** SQLITE_OK if no error occurs but there remains work to do to apply\n** the RBU update. If an error does occur, some other error code is \n** returned. \n**\n** Once a call to sqlite3rbu_step() has returned a value other than\n** SQLITE_OK, all subsequent calls on the same RBU handle are no-ops\n** that immediately return the same value.\n*/\nSQLITE_API int sqlite3rbu_step(sqlite3rbu *pRbu);\n\n/*\n** Force RBU to save its state to disk.\n**\n** If a power failure or application crash occurs during an update, following\n** system recovery RBU may resume the update from the point at which the state\n** was last saved. In other words, from the most recent successful call to \n** sqlite3rbu_close() or this function.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_API int sqlite3rbu_savestate(sqlite3rbu *pRbu);\n\n/*\n** Close an RBU handle. \n**\n** If the RBU update has been completely applied, mark the RBU database\n** as fully applied. Otherwise, assuming no error has occurred, save the\n** current state of the RBU update appliation to the RBU database.\n**\n** If an error has already occurred as part of an sqlite3rbu_step()\n** or sqlite3rbu_open() call, or if one occurs within this function, an\n** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,\n** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted\n** English language error message. It is the responsibility of the caller to\n** eventually free any such buffer using sqlite3_free().\n**\n** Otherwise, if no error occurs, this function returns SQLITE_OK if the\n** update has been partially applied, or SQLITE_DONE if it has been \n** completely applied.\n*/\nSQLITE_API int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg);\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu);\n\n/*\n** Obtain permyriadage (permyriadage is to 10000 as percentage is to 100) \n** progress indications for the two stages of an RBU update. This API may\n** be useful for driving GUI progress indicators and similar.\n**\n** An RBU update is divided into two stages:\n**\n**   * Stage 1, in which changes are accumulated in an oal/wal file, and\n**   * Stage 2, in which the contents of the wal file are copied into the\n**     main database.\n**\n** The update is visible to non-RBU clients during stage 2. During stage 1\n** non-RBU reader clients may see the original database.\n**\n** If this API is called during stage 2 of the update, output variable \n** (*pnOne) is set to 10000 to indicate that stage 1 has finished and (*pnTwo)\n** to a value between 0 and 10000 to indicate the permyriadage progress of\n** stage 2. A value of 5000 indicates that stage 2 is half finished, \n** 9000 indicates that it is 90% finished, and so on.\n**\n** If this API is called during stage 1 of the update, output variable \n** (*pnTwo) is set to 0 to indicate that stage 2 has not yet started. The\n** value to which (*pnOne) is set depends on whether or not the RBU \n** database contains an \"rbu_count\" table. The rbu_count table, if it \n** exists, must contain the same columns as the following:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There must be one row in the table for each source (data_xxx) table within\n** the RBU database. The 'tbl' column should contain the name of the source\n** table. The 'cnt' column should contain the number of rows within the\n** source table.\n**\n** If the rbu_count table is present and populated correctly and this\n** API is called during stage 1, the *pnOne output variable is set to the\n** permyriadage progress of the same stage. If the rbu_count table does\n** not exist, then (*pnOne) is set to -1 during stage 1. If the rbu_count\n** table exists but is not correctly populated, the value of the *pnOne\n** output variable during stage 1 is undefined.\n*/\nSQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int*pnTwo);\n\n/*\n** Obtain an indication as to the current stage of an RBU update or vacuum.\n** This function always returns one of the SQLITE_RBU_STATE_XXX constants\n** defined in this file. Return values should be interpreted as follows:\n**\n** SQLITE_RBU_STATE_OAL:\n**   RBU is currently building a *-oal file. The next call to sqlite3rbu_step()\n**   may either add further data to the *-oal file, or compute data that will\n**   be added by a subsequent call.\n**\n** SQLITE_RBU_STATE_MOVE:\n**   RBU has finished building the *-oal file. The next call to sqlite3rbu_step()\n**   will move the *-oal file to the equivalent *-wal path. If the current\n**   operation is an RBU update, then the updated version of the database\n**   file will become visible to ordinary SQLite clients following the next\n**   call to sqlite3rbu_step().\n**\n** SQLITE_RBU_STATE_CHECKPOINT:\n**   RBU is currently performing an incremental checkpoint. The next call to\n**   sqlite3rbu_step() will copy a page of data from the *-wal file into\n**   the target database file.\n**\n** SQLITE_RBU_STATE_DONE:\n**   The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()\n**   will immediately return SQLITE_DONE.\n**\n** SQLITE_RBU_STATE_ERROR:\n**   An error has occurred. Any subsequent calls to sqlite3rbu_step() will\n**   immediately return the SQLite error code associated with the error.\n*/\n#define SQLITE_RBU_STATE_OAL        1\n#define SQLITE_RBU_STATE_MOVE       2\n#define SQLITE_RBU_STATE_CHECKPOINT 3\n#define SQLITE_RBU_STATE_DONE       4\n#define SQLITE_RBU_STATE_ERROR      5\n\nSQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. Or, if the zParent parameter is passed NULL, \n** then the new RBU VFS uses the default system VFS to access the file-system.\n** The new object is registered as a non-default VFS with SQLite before \n** returning.\n**\n** Part of the RBU implementation uses a custom VFS object. Usually, this\n** object is created and deleted automatically by RBU. \n**\n** The exception is for applications that also use zipvfs. In this case,\n** the custom VFS must be explicitly created by the user before the RBU\n** handle is opened. The RBU VFS should be installed so that the zipvfs\n** VFS uses the RBU VFS, which in turn uses any other VFS layers in use \n** (for example multiplexor) to access the file-system. For example,\n** to assemble an RBU enabled VFS stack that uses both zipvfs and \n** multiplexor (error checking omitted):\n**\n**     // Create a VFS named \"multiplex\" (not the default).\n**     sqlite3_multiplex_initialize(0, 0);\n**\n**     // Create an rbu VFS named \"rbu\" that uses multiplexor. If the\n**     // second argument were replaced with NULL, the \"rbu\" VFS would\n**     // access the file-system via the system default VFS, bypassing the\n**     // multiplexor.\n**     sqlite3rbu_create_vfs(\"rbu\", \"multiplex\");\n**\n**     // Create a zipvfs VFS named \"zipvfs\" that uses rbu.\n**     zipvfs_create_vfs_v3(\"zipvfs\", \"rbu\", 0, xCompressorAlgorithmDetector);\n**\n**     // Make zipvfs the default VFS.\n**     sqlite3_vfs_register(sqlite3_vfs_find(\"zipvfs\"), 1);\n**\n** Because the default VFS created above includes a RBU functionality, it\n** may be used by RBU clients. Attempting to use RBU with a zipvfs VFS stack\n** that does not include the RBU layer results in an error.\n**\n** The overhead of adding the \"rbu\" VFS to the system is negligible for \n** non-RBU users. There is no harm in an application accessing the \n** file-system via \"rbu\" all the time, even if it only uses RBU functionality \n** occasionally.\n*/\nSQLITE_API int sqlite3rbu_create_vfs(const char *zName, const char *zParent);\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n**\n** VFS objects are not reference counted. If a VFS object is destroyed\n** before all database handles that use it have been closed, the results\n** are undefined.\n*/\nSQLITE_API void sqlite3rbu_destroy_vfs(const char *zName);\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _SQLITE3RBU_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rbu/test_rbu.c",
    "content": "/*\n** 2015 February 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#include \"sqlite3.h\"\n\n#if defined(SQLITE_TEST)\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)\n\n#include \"sqlite3rbu.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n#include <assert.h>\n\n/* From main.c */ \nextern const char *sqlite3ErrName(int);\nextern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);\n\nvoid test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){\n  Tcl_Interp *interp = (Tcl_Interp*)sqlite3_user_data(pCtx);\n  Tcl_Obj *pScript;\n  int i;\n\n  pScript = Tcl_NewObj();\n  Tcl_IncrRefCount(pScript);\n  Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(\"rbu_delta\", -1));\n  for(i=0; i<nArg; i++){\n    sqlite3_value *pIn = apVal[i];\n    const char *z = (const char*)sqlite3_value_text(pIn);\n    Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(z, -1));\n  }\n\n  if( TCL_OK==Tcl_EvalObjEx(interp, pScript, TCL_GLOBAL_ONLY) ){\n    const char *z = Tcl_GetStringResult(interp);\n    sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT);\n  }else{\n    Tcl_BackgroundError(interp);\n  }\n\n  Tcl_DecrRefCount(pScript);\n}\n\n\nstatic int SQLITE_TCLAPI test_sqlite3rbu_cmd(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int ret = TCL_OK;\n  sqlite3rbu *pRbu = (sqlite3rbu*)clientData;\n  struct RbuCmd {\n    const char *zName;\n    int nArg;\n    const char *zUsage;\n  } aCmd[] = {\n    {\"step\", 2, \"\"},                 /* 0 */\n    {\"close\", 2, \"\"},                /* 1 */\n    {\"create_rbu_delta\", 2, \"\"},     /* 2 */\n    {\"savestate\", 2, \"\"},            /* 3 */\n    {\"dbMain_eval\", 3, \"SQL\"},       /* 4 */\n    {\"bp_progress\", 2, \"\"},          /* 5 */\n    {\"db\", 3, \"RBU\"},                /* 6 */\n    {\"state\", 2, \"\"},                /* 7 */\n    {\"progress\", 2, \"\"},             /* 8 */\n    {\"close_no_error\", 2, \"\"},       /* 9 */\n    {\"temp_size_limit\", 3, \"LIMIT\"}, /* 10 */\n    {\"temp_size\", 2, \"\"},            /* 11 */\n    {0,0,0}\n  };\n  int iCmd;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"METHOD\");\n    return TCL_ERROR;\n  }\n  ret = Tcl_GetIndexFromObjStruct(\n      interp, objv[1], aCmd, sizeof(aCmd[0]), \"method\", 0, &iCmd\n  );\n  if( ret ) return TCL_ERROR;\n  if( objc!=aCmd[iCmd].nArg ){\n    Tcl_WrongNumArgs(interp, 1, objv, aCmd[iCmd].zUsage);\n    return TCL_ERROR;\n  }\n\n  switch( iCmd ){\n    case 0: /* step */ {\n      int rc = sqlite3rbu_step(pRbu);\n      Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n      break;\n    }\n\n    case 9: /* close_no_error */ \n    case 1: /* close */ {\n      char *zErrmsg = 0;\n      int rc;\n      Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));\n      if( iCmd==1 ){\n        rc = sqlite3rbu_close(pRbu, &zErrmsg);\n      }else{\n        rc = sqlite3rbu_close(pRbu, 0);\n      }\n      if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n        Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n        assert( zErrmsg==0 );\n      }else{\n        Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n        if( zErrmsg ){\n          Tcl_AppendResult(interp, \" - \", zErrmsg, 0);\n          sqlite3_free(zErrmsg);\n        }\n        ret = TCL_ERROR;\n      }\n      break;\n    }\n\n    case 2: /* create_rbu_delta */ {\n      sqlite3 *db = sqlite3rbu_db(pRbu, 0);\n      int rc = sqlite3_create_function(\n          db, \"rbu_delta\", -1, SQLITE_UTF8, (void*)interp, test_rbu_delta, 0, 0\n      );\n      Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n      ret = (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);\n      break;\n    }\n\n    case 3: /* savestate */ {\n      int rc = sqlite3rbu_savestate(pRbu);\n      Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n      ret = (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);\n      break;\n    }\n\n    case 4: /* dbMain_eval */ {\n      sqlite3 *db = sqlite3rbu_db(pRbu, 0);\n      int rc = sqlite3_exec(db, Tcl_GetString(objv[2]), 0, 0, 0);\n      if( rc!=SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(db), -1));\n        ret = TCL_ERROR;\n      }\n      break;\n    }\n\n    case 5: /* bp_progress */ {\n      int one, two;\n      Tcl_Obj *pObj;\n      sqlite3rbu_bp_progress(pRbu, &one, &two);\n\n      pObj = Tcl_NewObj();\n      Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(one));\n      Tcl_ListObjAppendElement(interp, pObj, Tcl_NewIntObj(two));\n      Tcl_SetObjResult(interp, pObj);\n      break;\n    }\n\n    case 6: /* db */ {\n      int bArg;\n      if( Tcl_GetBooleanFromObj(interp, objv[2], &bArg) ){\n        ret = TCL_ERROR;\n      }else{\n        char zBuf[50];\n        sqlite3 *db = sqlite3rbu_db(pRbu, bArg);\n        if( sqlite3TestMakePointerStr(interp, zBuf, (void*)db) ){\n          ret = TCL_ERROR;\n        }else{\n          Tcl_SetResult(interp, zBuf, TCL_VOLATILE);\n        }\n      }\n      break;\n    }\n    case 7: /* state */ {\n      const char *aRes[] = { 0, \"oal\", \"move\", \"checkpoint\", \"done\", \"error\" };\n      int eState = sqlite3rbu_state(pRbu);\n      assert( eState>0 && eState<=5 );\n      Tcl_SetResult(interp, (char*)aRes[eState], TCL_STATIC);\n      break;\n    }\n    case 8: /* progress */ {\n      sqlite3_int64 nStep =  sqlite3rbu_progress(pRbu);\n      Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nStep));\n      break;\n    }\n                           \n    case 10: /* temp_size_limit */ {\n      sqlite3_int64 nLimit;\n      if( Tcl_GetWideIntFromObj(interp, objv[2], &nLimit) ){\n        ret = TCL_ERROR;\n      }else{\n        nLimit = sqlite3rbu_temp_size_limit(pRbu, nLimit);\n        Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nLimit));\n      }\n      break;\n    }\n    case 11: /* temp_size */ {\n      sqlite3_int64 sz = sqlite3rbu_temp_size(pRbu);\n      Tcl_SetObjResult(interp, Tcl_NewWideIntObj(sz));\n      break;\n    }\n\n    default: /* seems unlikely */\n      assert( !\"cannot happen\" );\n      break;\n  }\n\n  return ret;\n}\n\n/*\n** Tclcmd: sqlite3rbu CMD <target-db> <rbu-db> ?<state-db>?\n*/\nstatic int SQLITE_TCLAPI test_sqlite3rbu(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3rbu *pRbu = 0;\n  const char *zCmd;\n  const char *zTarget;\n  const char *zRbu;\n  const char *zStateDb = 0;\n\n  if( objc!=4 && objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME TARGET-DB RBU-DB ?STATE-DB?\");\n    return TCL_ERROR;\n  }\n  zCmd = Tcl_GetString(objv[1]);\n  zTarget = Tcl_GetString(objv[2]);\n  zRbu = Tcl_GetString(objv[3]);\n  if( objc==5 ) zStateDb = Tcl_GetString(objv[4]);\n\n  pRbu = sqlite3rbu_open(zTarget, zRbu, zStateDb);\n  Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);\n  Tcl_SetObjResult(interp, objv[1]);\n  return TCL_OK;\n}\n\n/*\n** Tclcmd: sqlite3rbu_vacuum CMD <target-db> <state-db>\n*/\nstatic int SQLITE_TCLAPI test_sqlite3rbu_vacuum(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3rbu *pRbu = 0;\n  const char *zCmd;\n  const char *zTarget;\n  const char *zStateDb = 0;\n\n  if( objc!=3 && objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME TARGET-DB ?STATE-DB?\");\n    return TCL_ERROR;\n  }\n  zCmd = Tcl_GetString(objv[1]);\n  zTarget = Tcl_GetString(objv[2]);\n  if( objc==4 ) zStateDb = Tcl_GetString(objv[3]);\n\n  pRbu = sqlite3rbu_vacuum(zTarget, zStateDb);\n  Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);\n  Tcl_SetObjResult(interp, objv[1]);\n  return TCL_OK;\n}\n\n/*\n** Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT\n*/\nstatic int SQLITE_TCLAPI test_sqlite3rbu_create_vfs(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zName;\n  const char *zParent;\n  int rc;\n\n  if( objc!=3 && objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-default? NAME PARENT\");\n    return TCL_ERROR;\n  }\n\n  zName = Tcl_GetString(objv[objc-2]);\n  zParent = Tcl_GetString(objv[objc-1]);\n  if( zParent[0]=='\\0' ) zParent = 0;\n\n  rc = sqlite3rbu_create_vfs(zName, zParent);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }else if( objc==4 ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(zName);\n    sqlite3_vfs_register(pVfs, 1);\n  }\n\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n** Tclcmd: sqlite3rbu_destroy_vfs NAME\n*/\nstatic int SQLITE_TCLAPI test_sqlite3rbu_destroy_vfs(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zName;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME\");\n    return TCL_ERROR;\n  }\n\n  zName = Tcl_GetString(objv[1]);\n  sqlite3rbu_destroy_vfs(zName);\n  return TCL_OK;\n}\n\n/*\n** Tclcmd: sqlite3rbu_internal_test\n*/\nstatic int SQLITE_TCLAPI test_sqlite3rbu_internal_test(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  db = sqlite3rbu_db(0, 0);\n  if( db!=0 ){\n    Tcl_AppendResult(interp, \"sqlite3rbu_db(0, 0)!=0\", 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\nint SqliteRbu_Init(Tcl_Interp *interp){ \n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aObjCmd[] = {\n    { \"sqlite3rbu\", test_sqlite3rbu },\n    { \"sqlite3rbu_vacuum\", test_sqlite3rbu_vacuum },\n    { \"sqlite3rbu_create_vfs\", test_sqlite3rbu_create_vfs },\n    { \"sqlite3rbu_destroy_vfs\", test_sqlite3rbu_destroy_vfs },\n    { \"sqlite3rbu_internal_test\", test_sqlite3rbu_internal_test },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);\n  }\n  return TCL_OK;\n}\n\n#else\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\nint SqliteRbu_Init(Tcl_Interp *interp){ return TCL_OK; }\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */\n#endif /* defined(SQLITE_TEST) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/repair/README.md",
    "content": "This folder contains extensions and utility programs intended to analyze\nlive database files, detect problems, and possibly fix them.\n\nAs SQLite is being used on larger and larger databases, database sizes\nare growing into the terabyte range.  At that size, hardware malfunctions\nand/or cosmic rays will occasionally corrupt a database file.  Detecting \nproblems and fixing errors a terabyte-sized databases can take hours or days,\nand it is undesirable to take applications that depend on the databases \noff-line for such a long time.\nThe utilities in the folder are intended to provide mechanisms for\ndetecting and fixing problems in large databases while those databases\nare in active use.\n\nThe utilities and extensions in this folder are experimental and under\nactive development at the time of this writing (2017-10-12).  If and when\nthey stabilize, this README will be updated to reflect that fact.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/repair/checkfreelist.c",
    "content": "/*\n** 2017 October 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module exports a single C function:\n**\n**   int sqlite3_check_freelist(sqlite3 *db, const char *zDb);\n**\n** This function checks the free-list in database zDb (one of \"main\", \n** \"temp\", etc.) and reports any errors by invoking the sqlite3_log()\n** function. It returns SQLITE_OK if successful, or an SQLite error\n** code otherwise. It is not an error if the free-list is corrupted but\n** no IO or OOM errors occur.\n**\n** If this file is compiled and loaded as an SQLite loadable extension,\n** it adds an SQL function \"checkfreelist\" to the database handle, to\n** be invoked as follows:\n**\n**   SELECT checkfreelist(<database-name>);\n**\n** This function performs the same checks as sqlite3_check_freelist(),\n** except that it returns all error messages as a single text value,\n** separated by newline characters. If the freelist is not corrupted\n** in any way, an empty string is returned.\n**\n** To compile this module for use as an SQLite loadable extension:\n**\n**   gcc -Os -fPIC -shared checkfreelist.c -o checkfreelist.so\n*/\n\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n#ifndef SQLITE_AMALGAMATION\n# include <string.h>\n# include <stdio.h>\n# include <stdlib.h>\n# include <assert.h>\n# define ALWAYS(X)  1\n# define NEVER(X)   0\n  typedef unsigned char u8;\n  typedef unsigned short u16;\n  typedef unsigned int u32;\n#define get4byte(x) (        \\\n    ((u32)((x)[0])<<24) +    \\\n    ((u32)((x)[1])<<16) +    \\\n    ((u32)((x)[2])<<8) +     \\\n    ((u32)((x)[3]))          \\\n)\n#endif\n\n/*\n** Execute a single PRAGMA statement and return the integer value returned\n** via output parameter (*pnOut).\n**\n** The SQL statement passed as the third argument should be a printf-style\n** format string containing a single \"%s\" which will be replace by the\n** value passed as the second argument. e.g.\n**\n**   sqlGetInteger(db, \"main\", \"PRAGMA %s.page_count\", pnOut)\n**\n** executes \"PRAGMA main.page_count\" and stores the results in (*pnOut).\n*/\nstatic int sqlGetInteger(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Database name (\"main\", \"temp\" etc.) */\n  const char *zFmt,               /* SQL statement format */\n  u32 *pnOut                      /* OUT: Integer value */\n){\n  int rc, rc2;\n  char *zSql;\n  sqlite3_stmt *pStmt = 0;\n  int bOk = 0;\n\n  zSql = sqlite3_mprintf(zFmt, zDb);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n  }\n\n  if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pnOut = (u32)sqlite3_column_int(pStmt, 0);\n    bOk = 1;\n  }\n\n  rc2 = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) rc = rc2;\n  if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_ERROR;\n  return rc;\n}\n\n/*\n** Argument zFmt must be a printf-style format string and must be \n** followed by its required arguments. If argument pzOut is NULL, \n** then the results of printf()ing the format string are passed to\n** sqlite3_log(). Otherwise, they are appended to the string\n** at (*pzOut).\n*/\nstatic int checkFreelistError(char **pzOut, const char *zFmt, ...){\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  va_list ap;\n\n  va_start(ap, zFmt);\n  zErr = sqlite3_vmprintf(zFmt, ap);\n  if( zErr==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    if( pzOut ){\n      *pzOut = sqlite3_mprintf(\"%s%z%s\", *pzOut?\"\\n\":\"\", *pzOut, zErr);\n      if( *pzOut==0 ) rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_log(SQLITE_ERROR, \"checkfreelist: %s\", zErr);\n    }\n    sqlite3_free(zErr);\n  }\n  va_end(ap);\n  return rc;\n}\n\nstatic int checkFreelist(\n  sqlite3 *db, \n  const char *zDb,\n  char **pzOut\n){\n  /* This query returns one row for each page on the free list. Each row has\n  ** two columns - the page number and page content.  */\n  const char *zTrunk = \n    \"WITH freelist_trunk(i, d, n) AS (\"\n      \"SELECT 1, NULL, sqlite_readint32(data, 32) \"\n      \"FROM sqlite_dbpage(:1) WHERE pgno=1 \"\n        \"UNION ALL \"\n      \"SELECT n, data, sqlite_readint32(data) \"\n      \"FROM freelist_trunk, sqlite_dbpage(:1) WHERE pgno=n \"\n    \")\"\n    \"SELECT i, d FROM freelist_trunk WHERE i!=1;\";\n\n  int rc, rc2;                    /* Return code */\n  sqlite3_stmt *pTrunk = 0;       /* Compilation of zTrunk */\n  u32 nPage = 0;                  /* Number of pages in db */\n  u32 nExpected = 0;              /* Expected number of free pages */\n  u32 nFree = 0;                  /* Number of pages on free list */\n\n  if( zDb==0 ) zDb = \"main\";\n\n  if( (rc = sqlGetInteger(db, zDb, \"PRAGMA %s.page_count\", &nPage))\n   || (rc = sqlGetInteger(db, zDb, \"PRAGMA %s.freelist_count\", &nExpected))\n  ){\n    return rc;\n  }\n\n  rc = sqlite3_prepare_v2(db, zTrunk, -1, &pTrunk, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_text(pTrunk, 1, zDb, -1, SQLITE_STATIC);\n  while( rc==SQLITE_OK && sqlite3_step(pTrunk)==SQLITE_ROW ){\n    u32 i;\n    u32 iTrunk = (u32)sqlite3_column_int(pTrunk, 0);\n    const u8 *aData = (const u8*)sqlite3_column_blob(pTrunk, 1);\n    int nData = sqlite3_column_bytes(pTrunk, 1);\n    u32 iNext = get4byte(&aData[0]);\n    u32 nLeaf = get4byte(&aData[4]);\n\n    if( nLeaf>((nData/4)-2-6) ){\n      rc = checkFreelistError(pzOut, \n          \"leaf count out of range (%d) on trunk page %d\", \n          (int)nLeaf, (int)iTrunk\n      );\n      nLeaf = (nData/4) - 2 - 6;\n    }\n\n    nFree += 1+nLeaf;\n    if( iNext>nPage ){\n      rc = checkFreelistError(pzOut, \n          \"trunk page %d is out of range\", (int)iNext\n      );\n    }\n\n    for(i=0; rc==SQLITE_OK && i<nLeaf; i++){\n      u32 iLeaf = get4byte(&aData[8 + 4*i]);\n      if( iLeaf==0 || iLeaf>nPage ){\n        rc = checkFreelistError(pzOut,\n            \"leaf page %d is out of range (child %d of trunk page %d)\", \n            (int)iLeaf, (int)i, (int)iTrunk\n        );\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK && nFree!=nExpected ){\n    rc = checkFreelistError(pzOut,\n        \"free-list count mismatch: actual=%d header=%d\", \n        (int)nFree, (int)nExpected\n    );\n  }\n\n  rc2 = sqlite3_finalize(pTrunk);\n  if( rc==SQLITE_OK ) rc = rc2;\n  return rc;\n}\n\nint sqlite3_check_freelist(sqlite3 *db, const char *zDb){\n  return checkFreelist(db, zDb, 0);\n}\n\nstatic void checkfreelist_function(\n  sqlite3_context *pCtx,\n  int nArg,\n  sqlite3_value **apArg\n){\n  const char *zDb;\n  int rc;\n  char *zOut = 0;\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n\n  assert( nArg==1 );\n  zDb = (const char*)sqlite3_value_text(apArg[0]);\n  rc = checkFreelist(db, zDb, &zOut);\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, zOut?zOut:\"ok\", -1, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n\n  sqlite3_free(zOut);\n}\n\n/*\n** An SQL function invoked as follows:\n**\n**   sqlite_readint32(BLOB)           -- Decode 32-bit integer from start of blob\n*/\nstatic void readint_function(\n  sqlite3_context *pCtx,\n  int nArg,\n  sqlite3_value **apArg\n){\n  const u8 *zBlob;\n  int nBlob;\n  int iOff = 0;\n  u32 iRet = 0;\n\n  if( nArg!=1 && nArg!=2 ){\n    sqlite3_result_error(\n        pCtx, \"wrong number of arguments to function sqlite_readint32()\", -1\n    );\n    return;\n  }\n  if( nArg==2 ){\n    iOff = sqlite3_value_int(apArg[1]);\n  }\n\n  zBlob = sqlite3_value_blob(apArg[0]);\n  nBlob = sqlite3_value_bytes(apArg[0]);\n\n  if( nBlob>=(iOff+4) ){\n    iRet = get4byte(&zBlob[iOff]);\n  }\n\n  sqlite3_result_int64(pCtx, (sqlite3_int64)iRet);\n}\n\n/*\n** Register the SQL functions.\n*/\nstatic int cflRegister(sqlite3 *db){\n  int rc = sqlite3_create_function(\n      db, \"sqlite_readint32\", -1, SQLITE_UTF8, 0, readint_function, 0, 0\n  );\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3_create_function(\n      db, \"checkfreelist\", 1, SQLITE_UTF8, 0, checkfreelist_function, 0, 0\n  );\n  return rc;\n}\n\n/*\n** Extension load function.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_checkfreelist_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  return cflRegister(db);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/README",
    "content": "\nThis directory contains an SQLite extension that implements a virtual \ntable type that allows users to create, query and manipulate r-tree[1] \ndata structures inside of SQLite databases. Users create, populate \nand query r-tree structures using ordinary SQL statements.\n\n    1.  SQL Interface\n\n        1.1  Table Creation\n        1.2  Data Manipulation\n        1.3  Data Querying\n        1.4  Introspection and Analysis\n\n    2.  Compilation and Deployment\n\n    3.  References\n\n\n1. SQL INTERFACE\n\n  1.1 Table Creation.\n\n    All r-tree virtual tables have an odd number of columns between\n    3 and 11. Unlike regular SQLite tables, r-tree tables are strongly \n    typed. \n\n    The leftmost column is always the pimary key and contains 64-bit \n    integer values. Each subsequent column contains a 32-bit real\n    value. For each pair of real values, the first (leftmost) must be \n    less than or equal to the second. R-tree tables may be \n    constructed using the following syntax:\n\n      CREATE VIRTUAL TABLE <name> USING rtree(<column-names>)\n\n    For example:\n\n      CREATE VIRTUAL TABLE boxes USING rtree(boxno, xmin, xmax, ymin, ymax);\n      INSERT INTO boxes VALUES(1, 1.0, 3.0, 2.0, 4.0);\n\n    Constructing a virtual r-tree table <name> creates the following three\n    real tables in the database to store the data structure:\n\n      <name>_node\n      <name>_rowid\n      <name>_parent\n\n    Dropping or modifying the contents of these tables directly will\n    corrupt the r-tree structure. To delete an r-tree from a database,\n    use a regular DROP TABLE statement:\n\n      DROP TABLE <name>;\n\n    Dropping the main r-tree table automatically drops the automatically\n    created tables. \n\n  1.2 Data Manipulation (INSERT, UPDATE, DELETE).\n\n    The usual INSERT, UPDATE or DELETE syntax is used to manipulate data\n    stored in an r-tree table. Please note the following:\n\n      * Inserting a NULL value into the primary key column has the\n        same effect as inserting a NULL into an INTEGER PRIMARY KEY\n        column of a regular table. The system automatically assigns\n        an unused integer key value to the new record. Usually, this\n        is one greater than the largest primary key value currently\n        present in the table.\n\n      * Attempting to insert a duplicate primary key value fails with\n        an SQLITE_CONSTRAINT error.\n\n      * Attempting to insert or modify a record such that the value\n        stored in the (N*2)th column is greater than that stored in\n        the (N*2+1)th column fails with an SQLITE_CONSTRAINT error.\n\n      * When a record is inserted, values are always converted to \n        the required type (64-bit integer or 32-bit real) as if they\n        were part of an SQL CAST expression. Non-numeric strings are\n        converted to zero.\n\n  1.3 Queries.\n\n    R-tree tables may be queried using all of the same SQL syntax supported\n    by regular tables. However, some query patterns are more efficient\n    than others.\n\n    R-trees support fast lookup by primary key value (O(logN), like \n    regular tables).\n\n    Any combination of equality and range (<, <=, >, >=) constraints\n    on spatial data columns may be used to optimize other queries. This\n    is the key advantage to using r-tree tables instead of creating \n    indices on regular tables.\n\n  1.4 Introspection and Analysis.\n\n    TODO: Describe rtreenode() and rtreedepth() functions.\n\n\n2. COMPILATION AND USAGE\n\n  The easiest way to compile and use the RTREE extension is to build\n  and use it as a dynamically loadable SQLite extension. To do this\n  using gcc on *nix:\n\n    gcc -shared rtree.c -o libSqliteRtree.so\n\n  You may need to add \"-I\" flags so that gcc can find sqlite3ext.h\n  and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be\n  loaded into sqlite in the same way as any other dynamicly loadable\n  extension.\n\n\n3. REFERENCES\n\n  [1]  Atonin Guttman, \"R-trees - A Dynamic Index Structure For Spatial \n       Searching\", University of California Berkeley, 1984.\n\n  [2]  Norbert Beckmann, Hans-Peter Kriegel, Ralf Schneider, Bernhard Seeger,\n       \"The R*-tree: An Efficient and Robust Access Method for Points and\n       Rectangles\", Universitaet Bremen, 1990.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for implementations of the r-tree and r*-tree\n** algorithms packaged as an SQLite virtual table module.\n*/\n\n/*\n** Database Format of R-Tree Tables\n** --------------------------------\n**\n** The data structure for a single virtual r-tree table is stored in three \n** native SQLite tables declared as follows. In each case, the '%' character\n** in the table name is replaced with the user-supplied name of the r-tree\n** table.\n**\n**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)\n**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)\n**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)\n**\n** The data for each node of the r-tree structure is stored in the %_node\n** table. For each node that is not the root node of the r-tree, there is\n** an entry in the %_parent table associating the node with its parent.\n** And for each row of data in the table, there is an entry in the %_rowid\n** table that maps from the entries rowid to the id of the node that it\n** is stored on.\n**\n** The root node of an r-tree always exists, even if the r-tree table is\n** empty. The nodeno of the root node is always 1. All other nodes in the\n** table must be the same size as the root node. The content of each node\n** is formatted as follows:\n**\n**   1. If the node is the root node (node 1), then the first 2 bytes\n**      of the node contain the tree depth as a big-endian integer.\n**      For non-root nodes, the first 2 bytes are left unused.\n**\n**   2. The next 2 bytes contain the number of entries currently \n**      stored in the node.\n**\n**   3. The remainder of the node contains the node entries. Each entry\n**      consists of a single 8-byte integer followed by an even number\n**      of 4-byte coordinates. For leaf nodes the integer is the rowid\n**      of a record. For internal nodes it is the node number of a\n**      child page.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)\n\n#ifndef SQLITE_CORE\n  #include \"sqlite3ext.h\"\n  SQLITE_EXTENSION_INIT1\n#else\n  #include \"sqlite3.h\"\n#endif\n\n#include <string.h>\n#include <assert.h>\n#include <stdio.h>\n\n#ifndef SQLITE_AMALGAMATION\n#include \"sqlite3rtree.h\"\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\ntypedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\n#endif\n\n/*  The following macro is used to suppress compiler warnings.\n*/\n#ifndef UNUSED_PARAMETER\n# define UNUSED_PARAMETER(x) (void)(x)\n#endif\n\ntypedef struct Rtree Rtree;\ntypedef struct RtreeCursor RtreeCursor;\ntypedef struct RtreeNode RtreeNode;\ntypedef struct RtreeCell RtreeCell;\ntypedef struct RtreeConstraint RtreeConstraint;\ntypedef struct RtreeMatchArg RtreeMatchArg;\ntypedef struct RtreeGeomCallback RtreeGeomCallback;\ntypedef union RtreeCoord RtreeCoord;\ntypedef struct RtreeSearchPoint RtreeSearchPoint;\n\n/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */\n#define RTREE_MAX_DIMENSIONS 5\n\n/* Size of hash table Rtree.aHash. This hash table is not expected to\n** ever contain very many entries, so a fixed number of buckets is \n** used.\n*/\n#define HASHSIZE 97\n\n/* The xBestIndex method of this virtual table requires an estimate of\n** the number of rows in the virtual table to calculate the costs of\n** various strategies. If possible, this estimate is loaded from the\n** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).\n** Otherwise, if no sqlite_stat1 entry is available, use \n** RTREE_DEFAULT_ROWEST.\n*/\n#define RTREE_DEFAULT_ROWEST 1048576\n#define RTREE_MIN_ROWEST         100\n\n/* \n** An rtree virtual-table object.\n*/\nstruct Rtree {\n  sqlite3_vtab base;          /* Base class.  Must be first */\n  sqlite3 *db;                /* Host database connection */\n  int iNodeSize;              /* Size in bytes of each node in the node table */\n  u8 nDim;                    /* Number of dimensions */\n  u8 nDim2;                   /* Twice the number of dimensions */\n  u8 eCoordType;              /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */\n  u8 nBytesPerCell;           /* Bytes consumed per cell */\n  u8 inWrTrans;               /* True if inside write transaction */\n  int iDepth;                 /* Current depth of the r-tree structure */\n  char *zDb;                  /* Name of database containing r-tree table */\n  char *zName;                /* Name of r-tree table */ \n  u32 nBusy;                  /* Current number of users of this structure */\n  i64 nRowEst;                /* Estimated number of rows in this table */\n  u32 nCursor;                /* Number of open cursors */\n\n  /* List of nodes removed during a CondenseTree operation. List is\n  ** linked together via the pointer normally used for hash chains -\n  ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree \n  ** headed by the node (leaf nodes have RtreeNode.iNode==0).\n  */\n  RtreeNode *pDeleted;\n  int iReinsertHeight;        /* Height of sub-trees Reinsert() has run on */\n\n  /* Blob I/O on xxx_node */\n  sqlite3_blob *pNodeBlob;\n\n  /* Statements to read/write/delete a record from xxx_node */\n  sqlite3_stmt *pWriteNode;\n  sqlite3_stmt *pDeleteNode;\n\n  /* Statements to read/write/delete a record from xxx_rowid */\n  sqlite3_stmt *pReadRowid;\n  sqlite3_stmt *pWriteRowid;\n  sqlite3_stmt *pDeleteRowid;\n\n  /* Statements to read/write/delete a record from xxx_parent */\n  sqlite3_stmt *pReadParent;\n  sqlite3_stmt *pWriteParent;\n  sqlite3_stmt *pDeleteParent;\n\n  RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ \n};\n\n/* Possible values for Rtree.eCoordType: */\n#define RTREE_COORD_REAL32 0\n#define RTREE_COORD_INT32  1\n\n/*\n** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will\n** only deal with integer coordinates.  No floating point operations\n** will be done.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 RtreeDValue;       /* High accuracy coordinate */\n  typedef int RtreeValue;                  /* Low accuracy coordinate */\n# define RTREE_ZERO 0\n#else\n  typedef double RtreeDValue;              /* High accuracy coordinate */\n  typedef float RtreeValue;                /* Low accuracy coordinate */\n# define RTREE_ZERO 0.0\n#endif\n\n/*\n** When doing a search of an r-tree, instances of the following structure\n** record intermediate results from the tree walk.\n**\n** The id is always a node-id.  For iLevel>=1 the id is the node-id of\n** the node that the RtreeSearchPoint represents.  When iLevel==0, however,\n** the id is of the parent node and the cell that RtreeSearchPoint\n** represents is the iCell-th entry in the parent node.\n*/\nstruct RtreeSearchPoint {\n  RtreeDValue rScore;    /* The score for this node.  Smallest goes first. */\n  sqlite3_int64 id;      /* Node ID */\n  u8 iLevel;             /* 0=entries.  1=leaf node.  2+ for higher */\n  u8 eWithin;            /* PARTLY_WITHIN or FULLY_WITHIN */\n  u8 iCell;              /* Cell index within the node */\n};\n\n/*\n** The minimum number of cells allowed for a node is a third of the \n** maximum. In Gutman's notation:\n**\n**     m = M/3\n**\n** If an R*-tree \"Reinsert\" operation is required, the same number of\n** cells are removed from the overfull node and reinserted into the tree.\n*/\n#define RTREE_MINCELLS(p) ((((p)->iNodeSize-4)/(p)->nBytesPerCell)/3)\n#define RTREE_REINSERT(p) RTREE_MINCELLS(p)\n#define RTREE_MAXCELLS 51\n\n/*\n** The smallest possible node-size is (512-64)==448 bytes. And the largest\n** supported cell size is 48 bytes (8 byte rowid + ten 4 byte coordinates).\n** Therefore all non-root nodes must contain at least 3 entries. Since \n** 2^40 is greater than 2^64, an r-tree structure always has a depth of\n** 40 or less.\n*/\n#define RTREE_MAX_DEPTH 40\n\n\n/*\n** Number of entries in the cursor RtreeNode cache.  The first entry is\n** used to cache the RtreeNode for RtreeCursor.sPoint.  The remaining\n** entries cache the RtreeNode for the first elements of the priority queue.\n*/\n#define RTREE_CACHE_SZ  5\n\n/* \n** An rtree cursor object.\n*/\nstruct RtreeCursor {\n  sqlite3_vtab_cursor base;         /* Base class.  Must be first */\n  u8 atEOF;                         /* True if at end of search */\n  u8 bPoint;                        /* True if sPoint is valid */\n  int iStrategy;                    /* Copy of idxNum search parameter */\n  int nConstraint;                  /* Number of entries in aConstraint */\n  RtreeConstraint *aConstraint;     /* Search constraints. */\n  int nPointAlloc;                  /* Number of slots allocated for aPoint[] */\n  int nPoint;                       /* Number of slots used in aPoint[] */\n  int mxLevel;                      /* iLevel value for root of the tree */\n  RtreeSearchPoint *aPoint;         /* Priority queue for search points */\n  RtreeSearchPoint sPoint;          /* Cached next search point */\n  RtreeNode *aNode[RTREE_CACHE_SZ]; /* Rtree node cache */\n  u32 anQueue[RTREE_MAX_DEPTH+1];   /* Number of queued entries by iLevel */\n};\n\n/* Return the Rtree of a RtreeCursor */\n#define RTREE_OF_CURSOR(X)   ((Rtree*)((X)->base.pVtab))\n\n/*\n** A coordinate can be either a floating point number or a integer.  All\n** coordinates within a single R-Tree are always of the same time.\n*/\nunion RtreeCoord {\n  RtreeValue f;      /* Floating point value */\n  int i;             /* Integer value */\n  u32 u;             /* Unsigned for byte-order conversions */\n};\n\n/*\n** The argument is an RtreeCoord. Return the value stored within the RtreeCoord\n** formatted as a RtreeDValue (double or int64). This macro assumes that local\n** variable pRtree points to the Rtree structure associated with the\n** RtreeCoord.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n# define DCOORD(coord) ((RtreeDValue)coord.i)\n#else\n# define DCOORD(coord) (                           \\\n    (pRtree->eCoordType==RTREE_COORD_REAL32) ?      \\\n      ((double)coord.f) :                           \\\n      ((double)coord.i)                             \\\n  )\n#endif\n\n/*\n** A search constraint.\n*/\nstruct RtreeConstraint {\n  int iCoord;                     /* Index of constrained coordinate */\n  int op;                         /* Constraining operation */\n  union {\n    RtreeDValue rValue;             /* Constraint value. */\n    int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*);\n    int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  } u;\n  sqlite3_rtree_query_info *pInfo;  /* xGeom and xQueryFunc argument */\n};\n\n/* Possible values for RtreeConstraint.op */\n#define RTREE_EQ    0x41  /* A */\n#define RTREE_LE    0x42  /* B */\n#define RTREE_LT    0x43  /* C */\n#define RTREE_GE    0x44  /* D */\n#define RTREE_GT    0x45  /* E */\n#define RTREE_MATCH 0x46  /* F: Old-style sqlite3_rtree_geometry_callback() */\n#define RTREE_QUERY 0x47  /* G: New-style sqlite3_rtree_query_callback() */\n\n\n/* \n** An rtree structure node.\n*/\nstruct RtreeNode {\n  RtreeNode *pParent;         /* Parent node */\n  i64 iNode;                  /* The node number */\n  int nRef;                   /* Number of references to this node */\n  int isDirty;                /* True if the node needs to be written to disk */\n  u8 *zData;                  /* Content of the node, as should be on disk */\n  RtreeNode *pNext;           /* Next node in this hash collision chain */\n};\n\n/* Return the number of cells in a node  */\n#define NCELL(pNode) readInt16(&(pNode)->zData[2])\n\n/* \n** A single cell from a node, deserialized\n*/\nstruct RtreeCell {\n  i64 iRowid;                                 /* Node or entry ID */\n  RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2];  /* Bounding box coordinates */\n};\n\n\n/*\n** This object becomes the sqlite3_user_data() for the SQL functions\n** that are created by sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() and which appear on the right of MATCH\n** operators in order to constrain a search.\n**\n** xGeom and xQueryFunc are the callback functions.  Exactly one of \n** xGeom and xQueryFunc fields is non-NULL, depending on whether the\n** SQL function was created using sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback().\n** \n** This object is deleted automatically by the destructor mechanism in\n** sqlite3_create_function_v2().\n*/\nstruct RtreeGeomCallback {\n  int (*xGeom)(sqlite3_rtree_geometry*, int, RtreeDValue*, int*);\n  int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  void (*xDestructor)(void*);\n  void *pContext;\n};\n\n/*\n** An instance of this structure (in the form of a BLOB) is returned by\n** the SQL functions that sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() create, and is read as the right-hand\n** operand to the MATCH operator of an R-Tree.\n*/\nstruct RtreeMatchArg {\n  u32 iSize;                  /* Size of this object */\n  RtreeGeomCallback cb;       /* Info about the callback functions */\n  int nParam;                 /* Number of parameters to the SQL function */\n  sqlite3_value **apSqlParam; /* Original SQL parameter values */\n  RtreeDValue aParam[1];      /* Values for parameters to the SQL function */\n};\n\n#ifndef MAX\n# define MAX(x,y) ((x) < (y) ? (y) : (x))\n#endif\n#ifndef MIN\n# define MIN(x,y) ((x) > (y) ? (y) : (x))\n#endif\n\n/* What version of GCC is being used.  0 means GCC is not being used .\n** Note that the GCC_VERSION macro will also be set correctly when using\n** clang, since clang works hard to be gcc compatible.  So the gcc\n** optimizations will also work when compiling with clang.\n*/\n#ifndef GCC_VERSION\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#endif\n\n/* The testcase() macro should already be defined in the amalgamation.  If\n** it is not, make it a no-op.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define testcase(X)\n#endif\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n#if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n    defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n    defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n    defined(__arm__)\n# define SQLITE_BYTEORDER    1234\n#elif defined(sparc)    || defined(__ppc__)\n# define SQLITE_BYTEORDER    4321\n#else\n# define SQLITE_BYTEORDER    0     /* 0 means \"unknown at compile-time\" */\n#endif\n#endif\n\n\n/* What version of MSVC is being used.  0 means MSVC is not being used */\n#ifndef MSVC_VERSION\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n#endif\n\n/*\n** Functions to deserialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The deserialized value is returned.\n*/\nstatic int readInt16(u8 *p){\n  return (p[0]<<8) + p[1];\n}\nstatic void readCoord(u8 *p, RtreeCoord *pCoord){\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  pCoord->u = _byteswap_ulong(*(u32*)p);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  pCoord->u = __builtin_bswap32(*(u32*)p);\n#elif SQLITE_BYTEORDER==4321\n  pCoord->u = *(u32*)p;\n#else\n  pCoord->u = (\n    (((u32)p[0]) << 24) + \n    (((u32)p[1]) << 16) + \n    (((u32)p[2]) <<  8) + \n    (((u32)p[3]) <<  0)\n  );\n#endif\n}\nstatic i64 readInt64(u8 *p){\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)_byteswap_uint64(x);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)__builtin_bswap64(x);\n#elif SQLITE_BYTEORDER==4321\n  i64 x;\n  memcpy(&x, p, 8);\n  return x;\n#else\n  return (i64)(\n    (((u64)p[0]) << 56) + \n    (((u64)p[1]) << 48) + \n    (((u64)p[2]) << 40) + \n    (((u64)p[3]) << 32) + \n    (((u64)p[4]) << 24) + \n    (((u64)p[5]) << 16) + \n    (((u64)p[6]) <<  8) + \n    (((u64)p[7]) <<  0)\n  );\n#endif\n}\n\n/*\n** Functions to serialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The value returned is the number of bytes written\n** to the argument buffer (always 2, 4 and 8 respectively).\n*/\nstatic void writeInt16(u8 *p, int i){\n  p[0] = (i>> 8)&0xFF;\n  p[1] = (i>> 0)&0xFF;\n}\nstatic int writeCoord(u8 *p, RtreeCoord *pCoord){\n  u32 i;\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n  assert( sizeof(RtreeCoord)==4 );\n  assert( sizeof(u32)==4 );\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = __builtin_bswap32(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = _byteswap_ulong(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==4321\n  i = pCoord->u;\n  memcpy(p, &i, 4);\n#else\n  i = pCoord->u;\n  p[0] = (i>>24)&0xFF;\n  p[1] = (i>>16)&0xFF;\n  p[2] = (i>> 8)&0xFF;\n  p[3] = (i>> 0)&0xFF;\n#endif\n  return 4;\n}\nstatic int writeInt64(u8 *p, i64 i){\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = (i64)__builtin_bswap64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = (i64)_byteswap_uint64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==4321\n  memcpy(p, &i, 8);\n#else\n  p[0] = (i>>56)&0xFF;\n  p[1] = (i>>48)&0xFF;\n  p[2] = (i>>40)&0xFF;\n  p[3] = (i>>32)&0xFF;\n  p[4] = (i>>24)&0xFF;\n  p[5] = (i>>16)&0xFF;\n  p[6] = (i>> 8)&0xFF;\n  p[7] = (i>> 0)&0xFF;\n#endif\n  return 8;\n}\n\n/*\n** Increment the reference count of node p.\n*/\nstatic void nodeReference(RtreeNode *p){\n  if( p ){\n    p->nRef++;\n  }\n}\n\n/*\n** Clear the content of node p (set all bytes to 0x00).\n*/\nstatic void nodeZero(Rtree *pRtree, RtreeNode *p){\n  memset(&p->zData[2], 0, pRtree->iNodeSize-2);\n  p->isDirty = 1;\n}\n\n/*\n** Given a node number iNode, return the corresponding key to use\n** in the Rtree.aHash table.\n*/\nstatic int nodeHash(i64 iNode){\n  return iNode % HASHSIZE;\n}\n\n/*\n** Search the node hash table for node iNode. If found, return a pointer\n** to it. Otherwise, return 0.\n*/\nstatic RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){\n  RtreeNode *p;\n  for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext);\n  return p;\n}\n\n/*\n** Add node pNode to the node hash table.\n*/\nstatic void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){\n  int iHash;\n  assert( pNode->pNext==0 );\n  iHash = nodeHash(pNode->iNode);\n  pNode->pNext = pRtree->aHash[iHash];\n  pRtree->aHash[iHash] = pNode;\n}\n\n/*\n** Remove node pNode from the node hash table.\n*/\nstatic void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode **pp;\n  if( pNode->iNode!=0 ){\n    pp = &pRtree->aHash[nodeHash(pNode->iNode)];\n    for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }\n    *pp = pNode->pNext;\n    pNode->pNext = 0;\n  }\n}\n\n/*\n** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0),\n** indicating that node has not yet been assigned a node number. It is\n** assigned a node number when nodeWrite() is called to write the\n** node contents out to the database.\n*/\nstatic RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){\n  RtreeNode *pNode;\n  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);\n  if( pNode ){\n    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);\n    pNode->zData = (u8 *)&pNode[1];\n    pNode->nRef = 1;\n    pNode->pParent = pParent;\n    pNode->isDirty = 1;\n    nodeReference(pParent);\n  }\n  return pNode;\n}\n\n/*\n** Clear the Rtree.pNodeBlob object\n*/\nstatic void nodeBlobReset(Rtree *pRtree){\n  if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    sqlite3_blob_close(pBlob);\n  }\n}\n\n/*\n** Obtain a reference to an r-tree node.\n*/\nstatic int nodeAcquire(\n  Rtree *pRtree,             /* R-tree structure */\n  i64 iNode,                 /* Node number to load */\n  RtreeNode *pParent,        /* Either the parent node or NULL */\n  RtreeNode **ppNode         /* OUT: Acquired node */\n){\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = 0;\n\n  /* Check if the requested node is already in the hash table. If so,\n  ** increase its reference count and return it.\n  */\n  if( (pNode = nodeHashLookup(pRtree, iNode)) ){\n    assert( !pParent || !pNode->pParent || pNode->pParent==pParent );\n    if( pParent && !pNode->pParent ){\n      nodeReference(pParent);\n      pNode->pParent = pParent;\n    }\n    pNode->nRef++;\n    *ppNode = pNode;\n    return SQLITE_OK;\n  }\n\n  if( pRtree->pNodeBlob ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    rc = sqlite3_blob_reopen(pBlob, iNode);\n    pRtree->pNodeBlob = pBlob;\n    if( rc ){\n      nodeBlobReset(pRtree);\n      if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM;\n    }\n  }\n  if( pRtree->pNodeBlob==0 ){\n    char *zTab = sqlite3_mprintf(\"%s_node\", pRtree->zName);\n    if( zTab==0 ) return SQLITE_NOMEM;\n    rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, \"data\", iNode, 0,\n                           &pRtree->pNodeBlob);\n    sqlite3_free(zTab);\n  }\n  if( rc ){\n    nodeBlobReset(pRtree);\n    *ppNode = 0;\n    /* If unable to open an sqlite3_blob on the desired row, that can only\n    ** be because the shadow tables hold erroneous data. */\n    if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB;\n  }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){\n    pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);\n    if( !pNode ){\n      rc = SQLITE_NOMEM;\n    }else{\n      pNode->pParent = pParent;\n      pNode->zData = (u8 *)&pNode[1];\n      pNode->nRef = 1;\n      pNode->iNode = iNode;\n      pNode->isDirty = 0;\n      pNode->pNext = 0;\n      rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,\n                             pRtree->iNodeSize, 0);\n      nodeReference(pParent);\n    }\n  }\n\n  /* If the root node was just loaded, set pRtree->iDepth to the height\n  ** of the r-tree structure. A height of zero means all data is stored on\n  ** the root node. A height of one means the children of the root node\n  ** are the leaves, and so on. If the depth as specified on the root node\n  ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.\n  */\n  if( pNode && iNode==1 ){\n    pRtree->iDepth = readInt16(pNode->zData);\n    if( pRtree->iDepth>RTREE_MAX_DEPTH ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  /* If no error has occurred so far, check if the \"number of entries\"\n  ** field on the node is too large. If so, set the return code to \n  ** SQLITE_CORRUPT_VTAB.\n  */\n  if( pNode && rc==SQLITE_OK ){\n    if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( pNode!=0 ){\n      nodeHashInsert(pRtree, pNode);\n    }else{\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n    *ppNode = pNode;\n  }else{\n    sqlite3_free(pNode);\n    *ppNode = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Overwrite cell iCell of node pNode with the contents of pCell.\n*/\nstatic void nodeOverwriteCell(\n  Rtree *pRtree,             /* The overall R-Tree */\n  RtreeNode *pNode,          /* The node into which the cell is to be written */\n  RtreeCell *pCell,          /* The cell to write */\n  int iCell                  /* Index into pNode into which pCell is written */\n){\n  int ii;\n  u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  p += writeInt64(p, pCell->iRowid);\n  for(ii=0; ii<pRtree->nDim2; ii++){\n    p += writeCoord(p, &pCell->aCoord[ii]);\n  }\n  pNode->isDirty = 1;\n}\n\n/*\n** Remove the cell with index iCell from node pNode.\n*/\nstatic void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){\n  u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  u8 *pSrc = &pDst[pRtree->nBytesPerCell];\n  int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;\n  memmove(pDst, pSrc, nByte);\n  writeInt16(&pNode->zData[2], NCELL(pNode)-1);\n  pNode->isDirty = 1;\n}\n\n/*\n** Insert the contents of cell pCell into node pNode. If the insert\n** is successful, return SQLITE_OK.\n**\n** If there is not enough free space in pNode, return SQLITE_FULL.\n*/\nstatic int nodeInsertCell(\n  Rtree *pRtree,                /* The overall R-Tree */\n  RtreeNode *pNode,             /* Write new cell into this node */\n  RtreeCell *pCell              /* The cell to be inserted */\n){\n  int nCell;                    /* Current number of cells in pNode */\n  int nMaxCell;                 /* Maximum number of cells for pNode */\n\n  nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell;\n  nCell = NCELL(pNode);\n\n  assert( nCell<=nMaxCell );\n  if( nCell<nMaxCell ){\n    nodeOverwriteCell(pRtree, pNode, pCell, nCell);\n    writeInt16(&pNode->zData[2], nCell+1);\n    pNode->isDirty = 1;\n  }\n\n  return (nCell==nMaxCell);\n}\n\n/*\n** If the node is dirty, write it out to the database.\n*/\nstatic int nodeWrite(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode->isDirty ){\n    sqlite3_stmt *p = pRtree->pWriteNode;\n    if( pNode->iNode ){\n      sqlite3_bind_int64(p, 1, pNode->iNode);\n    }else{\n      sqlite3_bind_null(p, 1);\n    }\n    sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);\n    sqlite3_step(p);\n    pNode->isDirty = 0;\n    rc = sqlite3_reset(p);\n    if( pNode->iNode==0 && rc==SQLITE_OK ){\n      pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);\n      nodeHashInsert(pRtree, pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Release a reference to a node. If the node is dirty and the reference\n** count drops to zero, the node data is written to the database.\n*/\nstatic int nodeRelease(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode ){\n    assert( pNode->nRef>0 );\n    pNode->nRef--;\n    if( pNode->nRef==0 ){\n      if( pNode->iNode==1 ){\n        pRtree->iDepth = -1;\n      }\n      if( pNode->pParent ){\n        rc = nodeRelease(pRtree, pNode->pParent);\n      }\n      if( rc==SQLITE_OK ){\n        rc = nodeWrite(pRtree, pNode);\n      }\n      nodeHashDelete(pRtree, pNode);\n      sqlite3_free(pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the 64-bit integer value associated with cell iCell of\n** node pNode. If pNode is a leaf node, this is a rowid. If it is\n** an internal node, then the 64-bit integer is a child page number.\n*/\nstatic i64 nodeGetRowid(\n  Rtree *pRtree,       /* The overall R-Tree */\n  RtreeNode *pNode,    /* The node from which to extract the ID */\n  int iCell            /* The cell index from which to extract the ID */\n){\n  assert( iCell<NCELL(pNode) );\n  return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);\n}\n\n/*\n** Return coordinate iCoord from cell iCell in node pNode.\n*/\nstatic void nodeGetCoord(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node from which to extract a coordinate */\n  int iCell,                   /* The index of the cell within the node */\n  int iCoord,                  /* Which coordinate to extract */\n  RtreeCoord *pCoord           /* OUT: Space to write result to */\n){\n  readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);\n}\n\n/*\n** Deserialize cell iCell of node pNode. Populate the structure pointed\n** to by pCell with the results.\n*/\nstatic void nodeGetCell(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node containing the cell to be read */\n  int iCell,                   /* Index of the cell within the node */\n  RtreeCell *pCell             /* OUT: Write the cell contents here */\n){\n  u8 *pData;\n  RtreeCoord *pCoord;\n  int ii = 0;\n  pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);\n  pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell);\n  pCoord = pCell->aCoord;\n  do{\n    readCoord(pData, &pCoord[ii]);\n    readCoord(pData+4, &pCoord[ii+1]);\n    pData += 8;\n    ii += 2;\n  }while( ii<pRtree->nDim2 );\n}\n\n\n/* Forward declaration for the function that does the work of\n** the virtual table module xCreate() and xConnect() methods.\n*/\nstatic int rtreeInit(\n  sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **, int\n);\n\n/* \n** Rtree virtual table module xCreate method.\n*/\nstatic int rtreeCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1);\n}\n\n/* \n** Rtree virtual table module xConnect method.\n*/\nstatic int rtreeConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 0);\n}\n\n/*\n** Increment the r-tree reference count.\n*/\nstatic void rtreeReference(Rtree *pRtree){\n  pRtree->nBusy++;\n}\n\n/*\n** Decrement the r-tree reference count. When the reference count reaches\n** zero the structure is deleted.\n*/\nstatic void rtreeRelease(Rtree *pRtree){\n  pRtree->nBusy--;\n  if( pRtree->nBusy==0 ){\n    pRtree->inWrTrans = 0;\n    pRtree->nCursor = 0;\n    nodeBlobReset(pRtree);\n    sqlite3_finalize(pRtree->pWriteNode);\n    sqlite3_finalize(pRtree->pDeleteNode);\n    sqlite3_finalize(pRtree->pReadRowid);\n    sqlite3_finalize(pRtree->pWriteRowid);\n    sqlite3_finalize(pRtree->pDeleteRowid);\n    sqlite3_finalize(pRtree->pReadParent);\n    sqlite3_finalize(pRtree->pWriteParent);\n    sqlite3_finalize(pRtree->pDeleteParent);\n    sqlite3_free(pRtree);\n  }\n}\n\n/* \n** Rtree virtual table module xDisconnect method.\n*/\nstatic int rtreeDisconnect(sqlite3_vtab *pVtab){\n  rtreeRelease((Rtree *)pVtab);\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xDestroy method.\n*/\nstatic int rtreeDestroy(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc;\n  char *zCreate = sqlite3_mprintf(\n    \"DROP TABLE '%q'.'%q_node';\"\n    \"DROP TABLE '%q'.'%q_rowid';\"\n    \"DROP TABLE '%q'.'%q_parent';\",\n    pRtree->zDb, pRtree->zName, \n    pRtree->zDb, pRtree->zName,\n    pRtree->zDb, pRtree->zName\n  );\n  if( !zCreate ){\n    rc = SQLITE_NOMEM;\n  }else{\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n  }\n  if( rc==SQLITE_OK ){\n    rtreeRelease(pRtree);\n  }\n\n  return rc;\n}\n\n/* \n** Rtree virtual table module xOpen method.\n*/\nstatic int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  Rtree *pRtree = (Rtree *)pVTab;\n  RtreeCursor *pCsr;\n\n  pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));\n  if( pCsr ){\n    memset(pCsr, 0, sizeof(RtreeCursor));\n    pCsr->base.pVtab = pVTab;\n    rc = SQLITE_OK;\n    pRtree->nCursor++;\n  }\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n\n  return rc;\n}\n\n\n/*\n** Free the RtreeCursor.aConstraint[] array and its contents.\n*/\nstatic void freeCursorConstraints(RtreeCursor *pCsr){\n  if( pCsr->aConstraint ){\n    int i;                        /* Used to iterate through constraint array */\n    for(i=0; i<pCsr->nConstraint; i++){\n      sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;\n      if( pInfo ){\n        if( pInfo->xDelUser ) pInfo->xDelUser(pInfo->pUser);\n        sqlite3_free(pInfo);\n      }\n    }\n    sqlite3_free(pCsr->aConstraint);\n    pCsr->aConstraint = 0;\n  }\n}\n\n/* \n** Rtree virtual table module xClose method.\n*/\nstatic int rtreeClose(sqlite3_vtab_cursor *cur){\n  Rtree *pRtree = (Rtree *)(cur->pVtab);\n  int ii;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  assert( pRtree->nCursor>0 );\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);\n  sqlite3_free(pCsr);\n  pRtree->nCursor--;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** Rtree virtual table module xEof method.\n**\n** Return non-zero if the cursor does not currently point to a valid \n** record (i.e if the scan has finished), or zero otherwise.\n*/\nstatic int rtreeEof(sqlite3_vtab_cursor *cur){\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  return pCsr->atEOF;\n}\n\n/*\n** Convert raw bits from the on-disk RTree record into a coordinate value.\n** The on-disk format is big-endian and needs to be converted for little-\n** endian platforms.  The on-disk record stores integer coordinates if\n** eInt is true and it stores 32-bit floating point records if eInt is\n** false.  a[] is the four bytes of the on-disk record to be decoded.\n** Store the results in \"r\".\n**\n** There are five versions of this macro.  The last one is generic.  The\n** other four are various architectures-specific optimizations.\n*/\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = _byteswap_ulong(*(u32*)a);                            \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = __builtin_bswap32(*(u32*)a);                          \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    c.u = ((c.u>>24)&0xff)|((c.u>>8)&0xff00)|                   \\\n          ((c.u&0xff)<<24)|((c.u&0xff00)<<8);                   \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==4321\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#else\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = ((u32)a[0]<<24) + ((u32)a[1]<<16)                     \\\n           +((u32)a[2]<<8) + a[3];                              \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#endif\n\n/*\n** Check the RTree node or entry given by pCellData and p against the MATCH\n** constraint pConstraint.  \n*/\nstatic int rtreeCallbackConstraint(\n  RtreeConstraint *pConstraint,  /* The constraint to test */\n  int eInt,                      /* True if RTree holding integer coordinates */\n  u8 *pCellData,                 /* Raw cell content */\n  RtreeSearchPoint *pSearch,     /* Container of this cell */\n  sqlite3_rtree_dbl *prScore,    /* OUT: score for the cell */\n  int *peWithin                  /* OUT: visibility of the cell */\n){\n  sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */\n  int nCoord = pInfo->nCoord;                           /* No. of coordinates */\n  int rc;                                             /* Callback return code */\n  RtreeCoord c;                                       /* Translator union */\n  sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2];   /* Decoded coordinates */\n\n  assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY );\n  assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 );\n\n  if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){\n    pInfo->iRowid = readInt64(pCellData);\n  }\n  pCellData += 8;\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( eInt==0 ){\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.f;\n                readCoord(pCellData+32, &c); aCoord[8] = c.f;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.f;\n                readCoord(pCellData+24, &c); aCoord[6] = c.f;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.f;\n                readCoord(pCellData+16, &c); aCoord[4] = c.f;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.f;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.f;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.f;\n                readCoord(pCellData,    &c); aCoord[0] = c.f;\n    }\n  }else\n#endif\n  {\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.i;\n                readCoord(pCellData+32, &c); aCoord[8] = c.i;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.i;\n                readCoord(pCellData+24, &c); aCoord[6] = c.i;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.i;\n                readCoord(pCellData+16, &c); aCoord[4] = c.i;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.i;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.i;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.i;\n                readCoord(pCellData,    &c); aCoord[0] = c.i;\n    }\n  }\n  if( pConstraint->op==RTREE_MATCH ){\n    int eWithin = 0;\n    rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo,\n                              nCoord, aCoord, &eWithin);\n    if( eWithin==0 ) *peWithin = NOT_WITHIN;\n    *prScore = RTREE_ZERO;\n  }else{\n    pInfo->aCoord = aCoord;\n    pInfo->iLevel = pSearch->iLevel - 1;\n    pInfo->rScore = pInfo->rParentScore = pSearch->rScore;\n    pInfo->eWithin = pInfo->eParentWithin = pSearch->eWithin;\n    rc = pConstraint->u.xQueryFunc(pInfo);\n    if( pInfo->eWithin<*peWithin ) *peWithin = pInfo->eWithin;\n    if( pInfo->rScore<*prScore || *prScore<RTREE_ZERO ){\n      *prScore = pInfo->rScore;\n    }\n  }\n  return rc;\n}\n\n/* \n** Check the internal RTree node given by pCellData against constraint p.\n** If this constraint cannot be satisfied by any child within the node,\n** set *peWithin to NOT_WITHIN.\n*/\nstatic void rtreeNonleafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  sqlite3_rtree_dbl val;     /* Coordinate value convert to a double */\n\n  /* p->iCoord might point to either a lower or upper bound coordinate\n  ** in a coordinate pair.  But make pCellData point to the lower bound.\n  */\n  pCellData += 8 + 4*(p->iCoord&0xfe);\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  switch( p->op ){\n    case RTREE_LE:\n    case RTREE_LT:\n    case RTREE_EQ:\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the lower bound of the coordinate pair */\n      if( p->u.rValue>=val ) return;\n      if( p->op!=RTREE_EQ ) break;  /* RTREE_LE and RTREE_LT end here */\n      /* Fall through for the RTREE_EQ case */\n\n    default: /* RTREE_GT or RTREE_GE,  or fallthrough of RTREE_EQ */\n      pCellData += 4;\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the upper bound of the coordinate pair */\n      if( p->u.rValue<=val ) return;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** Check the leaf RTree cell given by pCellData against constraint p.\n** If this constraint is not satisfied, set *peWithin to NOT_WITHIN.\n** If the constraint is satisfied, leave *peWithin unchanged.\n**\n** The constraint is of the form:  xN op $val\n**\n** The op is given by p->op.  The xN is p->iCoord-th coordinate in\n** pCellData.  $val is given by p->u.rValue.\n*/\nstatic void rtreeLeafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  RtreeDValue xN;      /* Coordinate value converted to a double */\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  pCellData += 8 + p->iCoord*4;\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  RTREE_DECODE_COORD(eInt, pCellData, xN);\n  switch( p->op ){\n    case RTREE_LE: if( xN <= p->u.rValue ) return;  break;\n    case RTREE_LT: if( xN <  p->u.rValue ) return;  break;\n    case RTREE_GE: if( xN >= p->u.rValue ) return;  break;\n    case RTREE_GT: if( xN >  p->u.rValue ) return;  break;\n    default:       if( xN == p->u.rValue ) return;  break;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** One of the cells in node pNode is guaranteed to have a 64-bit \n** integer value equal to iRowid. Return the index of this cell.\n*/\nstatic int nodeRowidIndex(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  i64 iRowid,\n  int *piIndex\n){\n  int ii;\n  int nCell = NCELL(pNode);\n  assert( nCell<200 );\n  for(ii=0; ii<nCell; ii++){\n    if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){\n      *piIndex = ii;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_CORRUPT_VTAB;\n}\n\n/*\n** Return the index of the cell containing a pointer to node pNode\n** in its parent. If pNode is the root node, return -1.\n*/\nstatic int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){\n  RtreeNode *pParent = pNode->pParent;\n  if( pParent ){\n    return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);\n  }\n  *piIndex = -1;\n  return SQLITE_OK;\n}\n\n/*\n** Compare two search points.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second.\n**\n** The rScore is the primary key.  Smaller rScore values come first.\n** If the rScore is a tie, then use iLevel as the tie breaker with smaller\n** iLevel values coming first.  In this way, if rScore is the same for all\n** SearchPoints, then iLevel becomes the deciding factor and the result\n** is a depth-first search, which is the desired default behavior.\n*/\nstatic int rtreeSearchPointCompare(\n  const RtreeSearchPoint *pA,\n  const RtreeSearchPoint *pB\n){\n  if( pA->rScore<pB->rScore ) return -1;\n  if( pA->rScore>pB->rScore ) return +1;\n  if( pA->iLevel<pB->iLevel ) return -1;\n  if( pA->iLevel>pB->iLevel ) return +1;\n  return 0;\n}\n\n/*\n** Interchange two search points in a cursor.\n*/\nstatic void rtreeSearchPointSwap(RtreeCursor *p, int i, int j){\n  RtreeSearchPoint t = p->aPoint[i];\n  assert( i<j );\n  p->aPoint[i] = p->aPoint[j];\n  p->aPoint[j] = t;\n  i++; j++;\n  if( i<RTREE_CACHE_SZ ){\n    if( j>=RTREE_CACHE_SZ ){\n      nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n      p->aNode[i] = 0;\n    }else{\n      RtreeNode *pTemp = p->aNode[i];\n      p->aNode[i] = p->aNode[j];\n      p->aNode[j] = pTemp;\n    }\n  }\n}\n\n/*\n** Return the search point with the lowest current score.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointFirst(RtreeCursor *pCur){\n  return pCur->bPoint ? &pCur->sPoint : pCur->nPoint ? pCur->aPoint : 0;\n}\n\n/*\n** Get the RtreeNode for the search point with the lowest score.\n*/\nstatic RtreeNode *rtreeNodeOfFirstSearchPoint(RtreeCursor *pCur, int *pRC){\n  sqlite3_int64 id;\n  int ii = 1 - pCur->bPoint;\n  assert( ii==0 || ii==1 );\n  assert( pCur->bPoint || pCur->nPoint );\n  if( pCur->aNode[ii]==0 ){\n    assert( pRC!=0 );\n    id = ii ? pCur->aPoint[0].id : pCur->sPoint.id;\n    *pRC = nodeAcquire(RTREE_OF_CURSOR(pCur), id, 0, &pCur->aNode[ii]);\n  }\n  return pCur->aNode[ii];\n}\n\n/*\n** Push a new element onto the priority queue\n*/\nstatic RtreeSearchPoint *rtreeEnqueue(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  int i, j;\n  RtreeSearchPoint *pNew;\n  if( pCur->nPoint>=pCur->nPointAlloc ){\n    int nNew = pCur->nPointAlloc*2 + 8;\n    pNew = sqlite3_realloc(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));\n    if( pNew==0 ) return 0;\n    pCur->aPoint = pNew;\n    pCur->nPointAlloc = nNew;\n  }\n  i = pCur->nPoint++;\n  pNew = pCur->aPoint + i;\n  pNew->rScore = rScore;\n  pNew->iLevel = iLevel;\n  assert( iLevel<=RTREE_MAX_DEPTH );\n  while( i>0 ){\n    RtreeSearchPoint *pParent;\n    j = (i-1)/2;\n    pParent = pCur->aPoint + j;\n    if( rtreeSearchPointCompare(pNew, pParent)>=0 ) break;\n    rtreeSearchPointSwap(pCur, j, i);\n    i = j;\n    pNew = pParent;\n  }\n  return pNew;\n}\n\n/*\n** Allocate a new RtreeSearchPoint and return a pointer to it.  Return\n** NULL if malloc fails.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointNew(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  RtreeSearchPoint *pNew, *pFirst;\n  pFirst = rtreeSearchPointFirst(pCur);\n  pCur->anQueue[iLevel]++;\n  if( pFirst==0\n   || pFirst->rScore>rScore \n   || (pFirst->rScore==rScore && pFirst->iLevel>iLevel)\n  ){\n    if( pCur->bPoint ){\n      int ii;\n      pNew = rtreeEnqueue(pCur, rScore, iLevel);\n      if( pNew==0 ) return 0;\n      ii = (int)(pNew - pCur->aPoint) + 1;\n      if( ii<RTREE_CACHE_SZ ){\n        assert( pCur->aNode[ii]==0 );\n        pCur->aNode[ii] = pCur->aNode[0];\n       }else{\n        nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]);\n      }\n      pCur->aNode[0] = 0;\n      *pNew = pCur->sPoint;\n    }\n    pCur->sPoint.rScore = rScore;\n    pCur->sPoint.iLevel = iLevel;\n    pCur->bPoint = 1;\n    return &pCur->sPoint;\n  }else{\n    return rtreeEnqueue(pCur, rScore, iLevel);\n  }\n}\n\n#if 0\n/* Tracing routines for the RtreeSearchPoint queue */\nstatic void tracePoint(RtreeSearchPoint *p, int idx, RtreeCursor *pCur){\n  if( idx<0 ){ printf(\" s\"); }else{ printf(\"%2d\", idx); }\n  printf(\" %d.%05lld.%02d %g %d\",\n    p->iLevel, p->id, p->iCell, p->rScore, p->eWithin\n  );\n  idx++;\n  if( idx<RTREE_CACHE_SZ ){\n    printf(\" %p\\n\", pCur->aNode[idx]);\n  }else{\n    printf(\"\\n\");\n  }\n}\nstatic void traceQueue(RtreeCursor *pCur, const char *zPrefix){\n  int ii;\n  printf(\"=== %9s \", zPrefix);\n  if( pCur->bPoint ){\n    tracePoint(&pCur->sPoint, -1, pCur);\n  }\n  for(ii=0; ii<pCur->nPoint; ii++){\n    if( ii>0 || pCur->bPoint ) printf(\"              \");\n    tracePoint(&pCur->aPoint[ii], ii, pCur);\n  }\n}\n# define RTREE_QUEUE_TRACE(A,B) traceQueue(A,B)\n#else\n# define RTREE_QUEUE_TRACE(A,B)   /* no-op */\n#endif\n\n/* Remove the search point with the lowest current score.\n*/\nstatic void rtreeSearchPointPop(RtreeCursor *p){\n  int i, j, k, n;\n  i = 1 - p->bPoint;\n  assert( i==0 || i==1 );\n  if( p->aNode[i] ){\n    nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n    p->aNode[i] = 0;\n  }\n  if( p->bPoint ){\n    p->anQueue[p->sPoint.iLevel]--;\n    p->bPoint = 0;\n  }else if( p->nPoint ){\n    p->anQueue[p->aPoint[0].iLevel]--;\n    n = --p->nPoint;\n    p->aPoint[0] = p->aPoint[n];\n    if( n<RTREE_CACHE_SZ-1 ){\n      p->aNode[1] = p->aNode[n+1];\n      p->aNode[n+1] = 0;\n    }\n    i = 0;\n    while( (j = i*2+1)<n ){\n      k = j+1;\n      if( k<n && rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[j])<0 ){\n        if( rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, k);\n          i = k;\n        }else{\n          break;\n        }\n      }else{\n        if( rtreeSearchPointCompare(&p->aPoint[j], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, j);\n          i = j;\n        }else{\n          break;\n        }\n      }\n    }\n  }\n}\n\n\n/*\n** Continue the search on cursor pCur until the front of the queue\n** contains an entry suitable for returning as a result-set row,\n** or until the RtreeSearchPoint queue is empty, indicating that the\n** query has completed.\n*/\nstatic int rtreeStepToLeaf(RtreeCursor *pCur){\n  RtreeSearchPoint *p;\n  Rtree *pRtree = RTREE_OF_CURSOR(pCur);\n  RtreeNode *pNode;\n  int eWithin;\n  int rc = SQLITE_OK;\n  int nCell;\n  int nConstraint = pCur->nConstraint;\n  int ii;\n  int eInt;\n  RtreeSearchPoint x;\n\n  eInt = pRtree->eCoordType==RTREE_COORD_INT32;\n  while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){\n    pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);\n    if( rc ) return rc;\n    nCell = NCELL(pNode);\n    assert( nCell<200 );\n    while( p->iCell<nCell ){\n      sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;\n      u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);\n      eWithin = FULLY_WITHIN;\n      for(ii=0; ii<nConstraint; ii++){\n        RtreeConstraint *pConstraint = pCur->aConstraint + ii;\n        if( pConstraint->op>=RTREE_MATCH ){\n          rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,\n                                       &rScore, &eWithin);\n          if( rc ) return rc;\n        }else if( p->iLevel==1 ){\n          rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }else{\n          rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }\n        if( eWithin==NOT_WITHIN ) break;\n      }\n      p->iCell++;\n      if( eWithin==NOT_WITHIN ) continue;\n      x.iLevel = p->iLevel - 1;\n      if( x.iLevel ){\n        x.id = readInt64(pCellData);\n        x.iCell = 0;\n      }else{\n        x.id = p->id;\n        x.iCell = p->iCell - 1;\n      }\n      if( p->iCell>=nCell ){\n        RTREE_QUEUE_TRACE(pCur, \"POP-S:\");\n        rtreeSearchPointPop(pCur);\n      }\n      if( rScore<RTREE_ZERO ) rScore = RTREE_ZERO;\n      p = rtreeSearchPointNew(pCur, rScore, x.iLevel);\n      if( p==0 ) return SQLITE_NOMEM;\n      p->eWithin = (u8)eWithin;\n      p->id = x.id;\n      p->iCell = x.iCell;\n      RTREE_QUEUE_TRACE(pCur, \"PUSH-S:\");\n      break;\n    }\n    if( p->iCell>=nCell ){\n      RTREE_QUEUE_TRACE(pCur, \"POP-Se:\");\n      rtreeSearchPointPop(pCur);\n    }\n  }\n  pCur->atEOF = p==0;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xNext method.\n*/\nstatic int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Move to the next entry that matches the configured constraints. */\n  RTREE_QUEUE_TRACE(pCsr, \"POP-Nx:\");\n  rtreeSearchPointPop(pCsr);\n  rc = rtreeStepToLeaf(pCsr);\n  return rc;\n}\n\n/* \n** Rtree virtual table module xRowid method.\n*/\nstatic int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n  if( rc==SQLITE_OK && p ){\n    *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);\n  }\n  return rc;\n}\n\n/* \n** Rtree virtual table module xColumn method.\n*/\nstatic int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Rtree *pRtree = (Rtree *)cur->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  RtreeCoord c;\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n\n  if( rc ) return rc;\n  if( p==0 ) return SQLITE_OK;\n  if( i==0 ){\n    sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));\n  }else{\n    nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      sqlite3_result_double(ctx, c.f);\n    }else\n#endif\n    {\n      assert( pRtree->eCoordType==RTREE_COORD_INT32 );\n      sqlite3_result_int(ctx, c.i);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Use nodeAcquire() to obtain the leaf node containing the record with \n** rowid iRowid. If successful, set *ppLeaf to point to the node and\n** return SQLITE_OK. If there is no such record in the table, set\n** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf\n** to zero and return an SQLite error code.\n*/\nstatic int findLeafNode(\n  Rtree *pRtree,              /* RTree to search */\n  i64 iRowid,                 /* The rowid searching for */\n  RtreeNode **ppLeaf,         /* Write the node here */\n  sqlite3_int64 *piNode       /* Write the node-id here */\n){\n  int rc;\n  *ppLeaf = 0;\n  sqlite3_bind_int64(pRtree->pReadRowid, 1, iRowid);\n  if( sqlite3_step(pRtree->pReadRowid)==SQLITE_ROW ){\n    i64 iNode = sqlite3_column_int64(pRtree->pReadRowid, 0);\n    if( piNode ) *piNode = iNode;\n    rc = nodeAcquire(pRtree, iNode, 0, ppLeaf);\n    sqlite3_reset(pRtree->pReadRowid);\n  }else{\n    rc = sqlite3_reset(pRtree->pReadRowid);\n  }\n  return rc;\n}\n\n/*\n** This function is called to configure the RtreeConstraint object passed\n** as the second argument for a MATCH constraint. The value passed as the\n** first argument to this function is the right-hand operand to the MATCH\n** operator.\n*/\nstatic int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){\n  RtreeMatchArg *pBlob, *pSrc;       /* BLOB returned by geometry function */\n  sqlite3_rtree_query_info *pInfo;   /* Callback information */\n\n  pSrc = sqlite3_value_pointer(pValue, \"RtreeMatchArg\");\n  if( pSrc==0 ) return SQLITE_ERROR;\n  pInfo = (sqlite3_rtree_query_info*)\n                sqlite3_malloc64( sizeof(*pInfo)+pSrc->iSize );\n  if( !pInfo ) return SQLITE_NOMEM;\n  memset(pInfo, 0, sizeof(*pInfo));\n  pBlob = (RtreeMatchArg*)&pInfo[1];\n  memcpy(pBlob, pSrc, pSrc->iSize);\n  pInfo->pContext = pBlob->cb.pContext;\n  pInfo->nParam = pBlob->nParam;\n  pInfo->aParam = pBlob->aParam;\n  pInfo->apSqlParam = pBlob->apSqlParam;\n\n  if( pBlob->cb.xGeom ){\n    pCons->u.xGeom = pBlob->cb.xGeom;\n  }else{\n    pCons->op = RTREE_QUERY;\n    pCons->u.xQueryFunc = pBlob->cb.xQueryFunc;\n  }\n  pCons->pInfo = pInfo;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xFilter method.\n*/\nstatic int rtreeFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeNode *pRoot = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int iCell = 0;\n\n  rtreeReference(pRtree);\n\n  /* Reset the cursor to the same state as rtreeOpen() leaves it in. */\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  memset(pCsr, 0, sizeof(RtreeCursor));\n  pCsr->base.pVtab = (sqlite3_vtab*)pRtree;\n\n  pCsr->iStrategy = idxNum;\n  if( idxNum==1 ){\n    /* Special case - lookup by rowid. */\n    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */\n    RtreeSearchPoint *p;     /* Search point for the leaf */\n    i64 iRowid = sqlite3_value_int64(argv[0]);\n    i64 iNode = 0;\n    rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);\n    if( rc==SQLITE_OK && pLeaf!=0 ){\n      p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);\n      assert( p!=0 );  /* Always returns pCsr->sPoint */\n      pCsr->aNode[0] = pLeaf;\n      p->id = iNode;\n      p->eWithin = PARTLY_WITHIN;\n      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);\n      p->iCell = (u8)iCell;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-F1:\");\n    }else{\n      pCsr->atEOF = 1;\n    }\n  }else{\n    /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array \n    ** with the configured constraints. \n    */\n    rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n    if( rc==SQLITE_OK && argc>0 ){\n      pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);\n      pCsr->nConstraint = argc;\n      if( !pCsr->aConstraint ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);\n        memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));\n        assert( (idxStr==0 && argc==0)\n                || (idxStr && (int)strlen(idxStr)==argc*2) );\n        for(ii=0; ii<argc; ii++){\n          RtreeConstraint *p = &pCsr->aConstraint[ii];\n          p->op = idxStr[ii*2];\n          p->iCoord = idxStr[ii*2+1]-'0';\n          if( p->op>=RTREE_MATCH ){\n            /* A MATCH operator. The right-hand-side must be a blob that\n            ** can be cast into an RtreeMatchArg object. One created using\n            ** an sqlite3_rtree_geometry_callback() SQL user function.\n            */\n            rc = deserializeGeometry(argv[ii], p);\n            if( rc!=SQLITE_OK ){\n              break;\n            }\n            p->pInfo->nCoord = pRtree->nDim2;\n            p->pInfo->anQueue = pCsr->anQueue;\n            p->pInfo->mxLevel = pRtree->iDepth + 1;\n          }else{\n#ifdef SQLITE_RTREE_INT_ONLY\n            p->u.rValue = sqlite3_value_int64(argv[ii]);\n#else\n            p->u.rValue = sqlite3_value_double(argv[ii]);\n#endif\n          }\n        }\n      }\n    }\n    if( rc==SQLITE_OK ){\n      RtreeSearchPoint *pNew;\n      pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1));\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->id = 1;\n      pNew->iCell = 0;\n      pNew->eWithin = PARTLY_WITHIN;\n      assert( pCsr->bPoint==1 );\n      pCsr->aNode[0] = pRoot;\n      pRoot = 0;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-Fm:\");\n      rc = rtreeStepToLeaf(pCsr);\n    }\n  }\n\n  nodeRelease(pRtree, pRoot);\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xBestIndex method. There are three\n** table scan strategies to choose from (in order from most to \n** least desirable):\n**\n**   idxNum     idxStr        Strategy\n**   ------------------------------------------------\n**     1        Unused        Direct lookup by rowid.\n**     2        See below     R-tree query or full-table scan.\n**   ------------------------------------------------\n**\n** If strategy 1 is used, then idxStr is not meaningful. If strategy\n** 2 is used, idxStr is formatted to contain 2 bytes for each \n** constraint used. The first two bytes of idxStr correspond to \n** the constraint in sqlite3_index_info.aConstraintUsage[] with\n** (argvIndex==1) etc.\n**\n** The first of each pair of bytes in idxStr identifies the constraint\n** operator as follows:\n**\n**   Operator    Byte Value\n**   ----------------------\n**      =        0x41 ('A')\n**     <=        0x42 ('B')\n**      <        0x43 ('C')\n**     >=        0x44 ('D')\n**      >        0x45 ('E')\n**   MATCH       0x46 ('F')\n**   ----------------------\n**\n** The second of each pair of bytes identifies the coordinate column\n** to which the constraint applies. The leftmost coordinate column\n** is 'a', the second from the left 'b' etc.\n*/\nstatic int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  Rtree *pRtree = (Rtree*)tab;\n  int rc = SQLITE_OK;\n  int ii;\n  int bMatch = 0;                 /* True if there exists a MATCH constraint */\n  i64 nRow;                       /* Estimated rows returned by this scan */\n\n  int iIdx = 0;\n  char zIdxStr[RTREE_MAX_DIMENSIONS*8+1];\n  memset(zIdxStr, 0, sizeof(zIdxStr));\n\n  /* Check if there exists a MATCH constraint - even an unusable one. If there\n  ** is, do not consider the lookup-by-rowid plan as using such a plan would\n  ** require the VDBE to evaluate the MATCH constraint, which is not currently\n  ** possible. */\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    if( pIdxInfo->aConstraint[ii].op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n      bMatch = 1;\n    }\n  }\n\n  assert( pIdxInfo->idxStr==0 );\n  for(ii=0; ii<pIdxInfo->nConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii];\n\n    if( bMatch==0 && p->usable \n     && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      /* We have an equality constraint on the rowid. Use strategy 1. */\n      int jj;\n      for(jj=0; jj<ii; jj++){\n        pIdxInfo->aConstraintUsage[jj].argvIndex = 0;\n        pIdxInfo->aConstraintUsage[jj].omit = 0;\n      }\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[ii].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[jj].omit = 1;\n\n      /* This strategy involves a two rowid lookups on an B-Tree structures\n      ** and then a linear search of an R-Tree node. This should be \n      ** considered almost as quick as a direct rowid lookup (for which \n      ** sqlite uses an internal cost of 0.0). It is expected to return\n      ** a single row.\n      */ \n      pIdxInfo->estimatedCost = 30.0;\n      pIdxInfo->estimatedRows = 1;\n      return SQLITE_OK;\n    }\n\n    if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){\n      u8 op;\n      switch( p->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;\n        case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;\n        case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;\n        case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;\n        case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;\n        default:\n          assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );\n          op = RTREE_MATCH; \n          break;\n      }\n      zIdxStr[iIdx++] = op;\n      zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');\n      pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);\n      pIdxInfo->aConstraintUsage[ii].omit = 1;\n    }\n  }\n\n  pIdxInfo->idxNum = 2;\n  pIdxInfo->needToFreeIdxStr = 1;\n  if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf(\"%s\", zIdxStr)) ){\n    return SQLITE_NOMEM;\n  }\n\n  nRow = pRtree->nRowEst >> (iIdx/2);\n  pIdxInfo->estimatedCost = (double)6.0 * (double)nRow;\n  pIdxInfo->estimatedRows = nRow;\n\n  return rc;\n}\n\n/*\n** Return the N-dimensional volumn of the cell stored in *p.\n*/\nstatic RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue area = (RtreeDValue)1;\n  assert( pRtree->nDim>=1 && pRtree->nDim<=5 );\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    switch( pRtree->nDim ){\n      case 5:  area  = p->aCoord[9].f - p->aCoord[8].f;\n      case 4:  area *= p->aCoord[7].f - p->aCoord[6].f;\n      case 3:  area *= p->aCoord[5].f - p->aCoord[4].f;\n      case 2:  area *= p->aCoord[3].f - p->aCoord[2].f;\n      default: area *= p->aCoord[1].f - p->aCoord[0].f;\n    }\n  }else\n#endif\n  {\n    switch( pRtree->nDim ){\n      case 5:  area  = p->aCoord[9].i - p->aCoord[8].i;\n      case 4:  area *= p->aCoord[7].i - p->aCoord[6].i;\n      case 3:  area *= p->aCoord[5].i - p->aCoord[4].i;\n      case 2:  area *= p->aCoord[3].i - p->aCoord[2].i;\n      default: area *= p->aCoord[1].i - p->aCoord[0].i;\n    }\n  }\n  return area;\n}\n\n/*\n** Return the margin length of cell p. The margin length is the sum\n** of the objects size in each dimension.\n*/\nstatic RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue margin = 0;\n  int ii = pRtree->nDim2 - 2;\n  do{\n    margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));\n    ii -= 2;\n  }while( ii>=0 );\n  return margin;\n}\n\n/*\n** Store the union of cells p1 and p2 in p1.\n*/\nstatic void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii = 0;\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    do{\n      p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f);\n      p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }else{\n    do{\n      p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i);\n      p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }\n}\n\n/*\n** Return true if the area covered by p2 is a subset of the area covered\n** by p1. False otherwise.\n*/\nstatic int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii;\n  int isInt = (pRtree->eCoordType==RTREE_COORD_INT32);\n  for(ii=0; ii<pRtree->nDim2; ii+=2){\n    RtreeCoord *a1 = &p1->aCoord[ii];\n    RtreeCoord *a2 = &p2->aCoord[ii];\n    if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) \n     || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) \n    ){\n      return 0;\n    }\n  }\n  return 1;\n}\n\n/*\n** Return the amount cell p would grow by if it were unioned with pCell.\n*/\nstatic RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){\n  RtreeDValue area;\n  RtreeCell cell;\n  memcpy(&cell, p, sizeof(RtreeCell));\n  area = cellArea(pRtree, &cell);\n  cellUnion(pRtree, &cell, pCell);\n  return (cellArea(pRtree, &cell)-area);\n}\n\nstatic RtreeDValue cellOverlap(\n  Rtree *pRtree, \n  RtreeCell *p, \n  RtreeCell *aCell, \n  int nCell\n){\n  int ii;\n  RtreeDValue overlap = RTREE_ZERO;\n  for(ii=0; ii<nCell; ii++){\n    int jj;\n    RtreeDValue o = (RtreeDValue)1;\n    for(jj=0; jj<pRtree->nDim2; jj+=2){\n      RtreeDValue x1, x2;\n      x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj]));\n      x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1]));\n      if( x2<x1 ){\n        o = (RtreeDValue)0;\n        break;\n      }else{\n        o = o * (x2-x1);\n      }\n    }\n    overlap += o;\n  }\n  return overlap;\n}\n\n\n/*\n** This function implements the ChooseLeaf algorithm from Gutman[84].\n** ChooseSubTree in r*tree terminology.\n*/\nstatic int ChooseLeaf(\n  Rtree *pRtree,               /* Rtree table */\n  RtreeCell *pCell,            /* Cell to insert into rtree */\n  int iHeight,                 /* Height of sub-tree rooted at pCell */\n  RtreeNode **ppLeaf           /* OUT: Selected leaf page */\n){\n  int rc;\n  int ii;\n  RtreeNode *pNode;\n  rc = nodeAcquire(pRtree, 1, 0, &pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){\n    int iCell;\n    sqlite3_int64 iBest = 0;\n\n    RtreeDValue fMinGrowth = RTREE_ZERO;\n    RtreeDValue fMinArea = RTREE_ZERO;\n\n    int nCell = NCELL(pNode);\n    RtreeCell cell;\n    RtreeNode *pChild;\n\n    RtreeCell *aCell = 0;\n\n    /* Select the child node which will be enlarged the least if pCell\n    ** is inserted into it. Resolve ties by choosing the entry with\n    ** the smallest area.\n    */\n    for(iCell=0; iCell<nCell; iCell++){\n      int bBest = 0;\n      RtreeDValue growth;\n      RtreeDValue area;\n      nodeGetCell(pRtree, pNode, iCell, &cell);\n      growth = cellGrowth(pRtree, &cell, pCell);\n      area = cellArea(pRtree, &cell);\n      if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){\n        bBest = 1;\n      }\n      if( bBest ){\n        fMinGrowth = growth;\n        fMinArea = area;\n        iBest = cell.iRowid;\n      }\n    }\n\n    sqlite3_free(aCell);\n    rc = nodeAcquire(pRtree, iBest, pNode, &pChild);\n    nodeRelease(pRtree, pNode);\n    pNode = pChild;\n  }\n\n  *ppLeaf = pNode;\n  return rc;\n}\n\n/*\n** A cell with the same content as pCell has just been inserted into\n** the node pNode. This function updates the bounding box cells in\n** all ancestor elements.\n*/\nstatic int AdjustTree(\n  Rtree *pRtree,                    /* Rtree table */\n  RtreeNode *pNode,                 /* Adjust ancestry of this node. */\n  RtreeCell *pCell                  /* This cell was just inserted */\n){\n  RtreeNode *p = pNode;\n  while( p->pParent ){\n    RtreeNode *pParent = p->pParent;\n    RtreeCell cell;\n    int iCell;\n\n    if( nodeParentIndex(pRtree, p, &iCell) ){\n      return SQLITE_CORRUPT_VTAB;\n    }\n\n    nodeGetCell(pRtree, pParent, iCell, &cell);\n    if( !cellContains(pRtree, &cell, pCell) ){\n      cellUnion(pRtree, &cell, pCell);\n      nodeOverwriteCell(pRtree, pParent, &cell, iCell);\n    }\n \n    p = pParent;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Write mapping (iRowid->iNode) to the <rtree>_rowid table.\n*/\nstatic int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){\n  sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid);\n  sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode);\n  sqlite3_step(pRtree->pWriteRowid);\n  return sqlite3_reset(pRtree->pWriteRowid);\n}\n\n/*\n** Write mapping (iNode->iPar) to the <rtree>_parent table.\n*/\nstatic int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){\n  sqlite3_bind_int64(pRtree->pWriteParent, 1, iNode);\n  sqlite3_bind_int64(pRtree->pWriteParent, 2, iPar);\n  sqlite3_step(pRtree->pWriteParent);\n  return sqlite3_reset(pRtree->pWriteParent);\n}\n\nstatic int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int);\n\n\n/*\n** Arguments aIdx, aDistance and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to the indexed values in aDistance. For\n** example, assuming the inputs:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**   aDistance = { 5.0, 2.0, 7.0, 6.0 }\n**\n** this function sets the aIdx array to contain:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDistance(\n  int *aIdx, \n  int nIdx, \n  RtreeDValue *aDistance, \n  int *aSpare\n){\n  if( nIdx>1 ){\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDistance(aLeft, nLeft, aDistance, aSpare);\n    SortByDistance(aRight, nRight, aDistance, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n\n    while( iLeft<nLeft || iRight<nRight ){\n      if( iLeft==nLeft ){\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }else if( iRight==nRight ){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        RtreeDValue fLeft = aDistance[aLeft[iLeft]];\n        RtreeDValue fRight = aDistance[aRight[iRight]];\n        if( fLeft<fRight ){\n          aIdx[iLeft+iRight] = aLeft[iLeft];\n          iLeft++;\n        }else{\n          aIdx[iLeft+iRight] = aRight[iRight];\n          iRight++;\n        }\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue left = aDistance[aIdx[jj-1]];\n        RtreeDValue right = aDistance[aIdx[jj]];\n        assert( left<=right );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Arguments aIdx, aCell and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to dimension iDim of the cells in aCell. The\n** minimum value of dimension iDim is considered first, the\n** maximum used to break ties.\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDimension(\n  Rtree *pRtree,\n  int *aIdx, \n  int nIdx, \n  int iDim, \n  RtreeCell *aCell, \n  int *aSpare\n){\n  if( nIdx>1 ){\n\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDimension(pRtree, aLeft, nLeft, iDim, aCell, aSpare);\n    SortByDimension(pRtree, aRight, nRight, iDim, aCell, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n    while( iLeft<nLeft || iRight<nRight ){\n      RtreeDValue xleft1 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2]);\n      RtreeDValue xleft2 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2+1]);\n      RtreeDValue xright1 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2]);\n      RtreeDValue xright2 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2+1]);\n      if( (iLeft!=nLeft) && ((iRight==nRight)\n       || (xleft1<xright1)\n       || (xleft1==xright1 && xleft2<xright2)\n      )){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue xleft1 = aCell[aIdx[jj-1]].aCoord[iDim*2];\n        RtreeDValue xleft2 = aCell[aIdx[jj-1]].aCoord[iDim*2+1];\n        RtreeDValue xright1 = aCell[aIdx[jj]].aCoord[iDim*2];\n        RtreeDValue xright2 = aCell[aIdx[jj]].aCoord[iDim*2+1];\n        assert( xleft1<=xright1 && (xleft1<xright1 || xleft2<=xright2) );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Implementation of the R*-tree variant of SplitNode from Beckman[1990].\n*/\nstatic int splitNodeStartree(\n  Rtree *pRtree,\n  RtreeCell *aCell,\n  int nCell,\n  RtreeNode *pLeft,\n  RtreeNode *pRight,\n  RtreeCell *pBboxLeft,\n  RtreeCell *pBboxRight\n){\n  int **aaSorted;\n  int *aSpare;\n  int ii;\n\n  int iBestDim = 0;\n  int iBestSplit = 0;\n  RtreeDValue fBestMargin = RTREE_ZERO;\n\n  int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));\n\n  aaSorted = (int **)sqlite3_malloc(nByte);\n  if( !aaSorted ){\n    return SQLITE_NOMEM;\n  }\n\n  aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell];\n  memset(aaSorted, 0, nByte);\n  for(ii=0; ii<pRtree->nDim; ii++){\n    int jj;\n    aaSorted[ii] = &((int *)&aaSorted[pRtree->nDim])[ii*nCell];\n    for(jj=0; jj<nCell; jj++){\n      aaSorted[ii][jj] = jj;\n    }\n    SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);\n  }\n\n  for(ii=0; ii<pRtree->nDim; ii++){\n    RtreeDValue margin = RTREE_ZERO;\n    RtreeDValue fBestOverlap = RTREE_ZERO;\n    RtreeDValue fBestArea = RTREE_ZERO;\n    int iBestLeft = 0;\n    int nLeft;\n\n    for(\n      nLeft=RTREE_MINCELLS(pRtree); \n      nLeft<=(nCell-RTREE_MINCELLS(pRtree)); \n      nLeft++\n    ){\n      RtreeCell left;\n      RtreeCell right;\n      int kk;\n      RtreeDValue overlap;\n      RtreeDValue area;\n\n      memcpy(&left, &aCell[aaSorted[ii][0]], sizeof(RtreeCell));\n      memcpy(&right, &aCell[aaSorted[ii][nCell-1]], sizeof(RtreeCell));\n      for(kk=1; kk<(nCell-1); kk++){\n        if( kk<nLeft ){\n          cellUnion(pRtree, &left, &aCell[aaSorted[ii][kk]]);\n        }else{\n          cellUnion(pRtree, &right, &aCell[aaSorted[ii][kk]]);\n        }\n      }\n      margin += cellMargin(pRtree, &left);\n      margin += cellMargin(pRtree, &right);\n      overlap = cellOverlap(pRtree, &left, &right, 1);\n      area = cellArea(pRtree, &left) + cellArea(pRtree, &right);\n      if( (nLeft==RTREE_MINCELLS(pRtree))\n       || (overlap<fBestOverlap)\n       || (overlap==fBestOverlap && area<fBestArea)\n      ){\n        iBestLeft = nLeft;\n        fBestOverlap = overlap;\n        fBestArea = area;\n      }\n    }\n\n    if( ii==0 || margin<fBestMargin ){\n      iBestDim = ii;\n      fBestMargin = margin;\n      iBestSplit = iBestLeft;\n    }\n  }\n\n  memcpy(pBboxLeft, &aCell[aaSorted[iBestDim][0]], sizeof(RtreeCell));\n  memcpy(pBboxRight, &aCell[aaSorted[iBestDim][iBestSplit]], sizeof(RtreeCell));\n  for(ii=0; ii<nCell; ii++){\n    RtreeNode *pTarget = (ii<iBestSplit)?pLeft:pRight;\n    RtreeCell *pBbox = (ii<iBestSplit)?pBboxLeft:pBboxRight;\n    RtreeCell *pCell = &aCell[aaSorted[iBestDim][ii]];\n    nodeInsertCell(pRtree, pTarget, pCell);\n    cellUnion(pRtree, pBbox, pCell);\n  }\n\n  sqlite3_free(aaSorted);\n  return SQLITE_OK;\n}\n\n\nstatic int updateMapping(\n  Rtree *pRtree, \n  i64 iRowid, \n  RtreeNode *pNode, \n  int iHeight\n){\n  int (*xSetMapping)(Rtree *, sqlite3_int64, sqlite3_int64);\n  xSetMapping = ((iHeight==0)?rowidWrite:parentWrite);\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  return xSetMapping(pRtree, iRowid, pNode->iNode);\n}\n\nstatic int SplitNode(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int i;\n  int newCellIsRight = 0;\n\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n  RtreeCell *aCell;\n  int *aiUsed;\n\n  RtreeNode *pLeft = 0;\n  RtreeNode *pRight = 0;\n\n  RtreeCell leftbbox;\n  RtreeCell rightbbox;\n\n  /* Allocate an array and populate it with a copy of pCell and \n  ** all cells from node pLeft. Then zero the original node.\n  */\n  aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));\n  if( !aCell ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n  aiUsed = (int *)&aCell[nCell+1];\n  memset(aiUsed, 0, sizeof(int)*(nCell+1));\n  for(i=0; i<nCell; i++){\n    nodeGetCell(pRtree, pNode, i, &aCell[i]);\n  }\n  nodeZero(pRtree, pNode);\n  memcpy(&aCell[nCell], pCell, sizeof(RtreeCell));\n  nCell++;\n\n  if( pNode->iNode==1 ){\n    pRight = nodeNew(pRtree, pNode);\n    pLeft = nodeNew(pRtree, pNode);\n    pRtree->iDepth++;\n    pNode->isDirty = 1;\n    writeInt16(pNode->zData, pRtree->iDepth);\n  }else{\n    pLeft = pNode;\n    pRight = nodeNew(pRtree, pLeft->pParent);\n    nodeReference(pLeft);\n  }\n\n  if( !pLeft || !pRight ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n\n  memset(pLeft->zData, 0, pRtree->iNodeSize);\n  memset(pRight->zData, 0, pRtree->iNodeSize);\n\n  rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight,\n                         &leftbbox, &rightbbox);\n  if( rc!=SQLITE_OK ){\n    goto splitnode_out;\n  }\n\n  /* Ensure both child nodes have node numbers assigned to them by calling\n  ** nodeWrite(). Node pRight always needs a node number, as it was created\n  ** by nodeNew() above. But node pLeft sometimes already has a node number.\n  ** In this case avoid the all to nodeWrite().\n  */\n  if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))\n   || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))\n  ){\n    goto splitnode_out;\n  }\n\n  rightbbox.iRowid = pRight->iNode;\n  leftbbox.iRowid = pLeft->iNode;\n\n  if( pNode->iNode==1 ){\n    rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1);\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }else{\n    RtreeNode *pParent = pLeft->pParent;\n    int iCell;\n    rc = nodeParentIndex(pRtree, pLeft, &iCell);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);\n      rc = AdjustTree(pRtree, pParent, &leftbbox);\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){\n    goto splitnode_out;\n  }\n\n  for(i=0; i<NCELL(pRight); i++){\n    i64 iRowid = nodeGetRowid(pRtree, pRight, i);\n    rc = updateMapping(pRtree, iRowid, pRight, iHeight);\n    if( iRowid==pCell->iRowid ){\n      newCellIsRight = 1;\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( pNode->iNode==1 ){\n    for(i=0; i<NCELL(pLeft); i++){\n      i64 iRowid = nodeGetRowid(pRtree, pLeft, i);\n      rc = updateMapping(pRtree, iRowid, pLeft, iHeight);\n      if( rc!=SQLITE_OK ){\n        goto splitnode_out;\n      }\n    }\n  }else if( newCellIsRight==0 ){\n    rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRight);\n    pRight = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pLeft);\n    pLeft = 0;\n  }\n\nsplitnode_out:\n  nodeRelease(pRtree, pRight);\n  nodeRelease(pRtree, pLeft);\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** If node pLeaf is not the root of the r-tree and its pParent pointer is \n** still NULL, load all ancestor nodes of pLeaf into memory and populate\n** the pLeaf->pParent chain all the way up to the root node.\n**\n** This operation is required when a row is deleted (or updated - an update\n** is implemented as a delete followed by an insert). SQLite provides the\n** rowid of the row to delete, which can be used to find the leaf on which\n** the entry resides (argument pLeaf). Once the leaf is located, this \n** function is called to determine its ancestry.\n*/\nstatic int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){\n  int rc = SQLITE_OK;\n  RtreeNode *pChild = pLeaf;\n  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){\n    int rc2 = SQLITE_OK;          /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);\n    rc = sqlite3_step(pRtree->pReadParent);\n    if( rc==SQLITE_ROW ){\n      RtreeNode *pTest;           /* Used to test for reference loops */\n      i64 iNode;                  /* Node number of parent node */\n\n      /* Before setting pChild->pParent, test that we are not creating a\n      ** loop of references (as we would if, say, pChild==pParent). We don't\n      ** want to do this as it leads to a memory leak when trying to delete\n      ** the referenced counted node structures.\n      */\n      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);\n      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);\n      if( !pTest ){\n        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);\n      }\n    }\n    rc = sqlite3_reset(pRtree->pReadParent);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;\n    pChild = pChild->pParent;\n  }\n  return rc;\n}\n\nstatic int deleteCell(Rtree *, RtreeNode *, int, int);\n\nstatic int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){\n  int rc;\n  int rc2;\n  RtreeNode *pParent = 0;\n  int iCell;\n\n  assert( pNode->nRef==1 );\n\n  /* Remove the entry in the parent cell. */\n  rc = nodeParentIndex(pRtree, pNode, &iCell);\n  if( rc==SQLITE_OK ){\n    pParent = pNode->pParent;\n    pNode->pParent = 0;\n    rc = deleteCell(pRtree, pParent, iCell, iHeight+1);\n  }\n  rc2 = nodeRelease(pRtree, pParent);\n  if( rc==SQLITE_OK ){\n    rc = rc2;\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Remove the xxx_node entry. */\n  sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteNode);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){\n    return rc;\n  }\n\n  /* Remove the xxx_parent entry. */\n  sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteParent);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){\n    return rc;\n  }\n  \n  /* Remove the node from the in-memory hash table and link it into\n  ** the Rtree.pDeleted list. Its contents will be re-inserted later on.\n  */\n  nodeHashDelete(pRtree, pNode);\n  pNode->iNode = iHeight;\n  pNode->pNext = pRtree->pDeleted;\n  pNode->nRef++;\n  pRtree->pDeleted = pNode;\n\n  return SQLITE_OK;\n}\n\nstatic int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode *pParent = pNode->pParent;\n  int rc = SQLITE_OK; \n  if( pParent ){\n    int ii; \n    int nCell = NCELL(pNode);\n    RtreeCell box;                            /* Bounding box for pNode */\n    nodeGetCell(pRtree, pNode, 0, &box);\n    for(ii=1; ii<nCell; ii++){\n      RtreeCell cell;\n      nodeGetCell(pRtree, pNode, ii, &cell);\n      cellUnion(pRtree, &box, &cell);\n    }\n    box.iRowid = pNode->iNode;\n    rc = nodeParentIndex(pRtree, pNode, &ii);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &box, ii);\n      rc = fixBoundingBox(pRtree, pParent);\n    }\n  }\n  return rc;\n}\n\n/*\n** Delete the cell at index iCell of node pNode. After removing the\n** cell, adjust the r-tree data structure if required.\n*/\nstatic int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){\n  RtreeNode *pParent;\n  int rc;\n\n  if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){\n    return rc;\n  }\n\n  /* Remove the cell from the node. This call just moves bytes around\n  ** the in-memory node image, so it cannot fail.\n  */\n  nodeDeleteCell(pRtree, pNode, iCell);\n\n  /* If the node is not the tree root and now has less than the minimum\n  ** number of cells, remove it from the tree. Otherwise, update the\n  ** cell in the parent node so that it tightly contains the updated\n  ** node.\n  */\n  pParent = pNode->pParent;\n  assert( pParent || pNode->iNode==1 );\n  if( pParent ){\n    if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){\n      rc = removeNode(pRtree, pNode, iHeight);\n    }else{\n      rc = fixBoundingBox(pRtree, pNode);\n    }\n  }\n\n  return rc;\n}\n\nstatic int Reinsert(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  RtreeCell *pCell, \n  int iHeight\n){\n  int *aOrder;\n  int *aSpare;\n  RtreeCell *aCell;\n  RtreeDValue *aDistance;\n  int nCell;\n  RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS];\n  int iDim;\n  int ii;\n  int rc = SQLITE_OK;\n  int n;\n\n  memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS);\n\n  nCell = NCELL(pNode)+1;\n  n = (nCell+1)&(~1);\n\n  /* Allocate the buffers used by this operation. The allocation is\n  ** relinquished before this function returns.\n  */\n  aCell = (RtreeCell *)sqlite3_malloc(n * (\n    sizeof(RtreeCell)     +         /* aCell array */\n    sizeof(int)           +         /* aOrder array */\n    sizeof(int)           +         /* aSpare array */\n    sizeof(RtreeDValue)             /* aDistance array */\n  ));\n  if( !aCell ){\n    return SQLITE_NOMEM;\n  }\n  aOrder    = (int *)&aCell[n];\n  aSpare    = (int *)&aOrder[n];\n  aDistance = (RtreeDValue *)&aSpare[n];\n\n  for(ii=0; ii<nCell; ii++){\n    if( ii==(nCell-1) ){\n      memcpy(&aCell[ii], pCell, sizeof(RtreeCell));\n    }else{\n      nodeGetCell(pRtree, pNode, ii, &aCell[ii]);\n    }\n    aOrder[ii] = ii;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);\n    }\n  }\n  for(iDim=0; iDim<pRtree->nDim; iDim++){\n    aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2));\n  }\n\n  for(ii=0; ii<nCell; ii++){\n    aDistance[ii] = RTREE_ZERO;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - \n                               DCOORD(aCell[ii].aCoord[iDim*2]));\n      aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);\n    }\n  }\n\n  SortByDistance(aOrder, nCell, aDistance, aSpare);\n  nodeZero(pRtree, pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){\n    RtreeCell *p = &aCell[aOrder[ii]];\n    nodeInsertCell(pRtree, pNode, p);\n    if( p->iRowid==pCell->iRowid ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, p->iRowid, pNode->iNode);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = fixBoundingBox(pRtree, pNode);\n  }\n  for(; rc==SQLITE_OK && ii<nCell; ii++){\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    RtreeNode *pInsert;\n    RtreeCell *p = &aCell[aOrder[ii]];\n    rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** Insert cell pCell into node pNode. Node pNode is the head of a \n** subtree iHeight high (leaf nodes have iHeight==0).\n*/\nstatic int rtreeInsertCell(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int rc = SQLITE_OK;\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  if( nodeInsertCell(pRtree, pNode, pCell) ){\n    if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){\n      rc = SplitNode(pRtree, pNode, pCell, iHeight);\n    }else{\n      pRtree->iReinsertHeight = iHeight;\n      rc = Reinsert(pRtree, pNode, pCell, iHeight);\n    }\n  }else{\n    rc = AdjustTree(pRtree, pNode, pCell);\n    if( rc==SQLITE_OK ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){\n  int ii;\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){\n    RtreeNode *pInsert;\n    RtreeCell cell;\n    nodeGetCell(pRtree, pNode, ii, &cell);\n\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Select a currently unused rowid for a new r-tree record.\n*/\nstatic int newRowid(Rtree *pRtree, i64 *piRowid){\n  int rc;\n  sqlite3_bind_null(pRtree->pWriteRowid, 1);\n  sqlite3_bind_null(pRtree->pWriteRowid, 2);\n  sqlite3_step(pRtree->pWriteRowid);\n  rc = sqlite3_reset(pRtree->pWriteRowid);\n  *piRowid = sqlite3_last_insert_rowid(pRtree->db);\n  return rc;\n}\n\n/*\n** Remove the entry with rowid=iDelete from the r-tree structure.\n*/\nstatic int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){\n  int rc;                         /* Return code */\n  RtreeNode *pLeaf = 0;           /* Leaf node containing record iDelete */\n  int iCell;                      /* Index of iDelete cell in pLeaf */\n  RtreeNode *pRoot = 0;           /* Root node of rtree structure */\n\n\n  /* Obtain a reference to the root node to initialize Rtree.iDepth */\n  rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n\n  /* Obtain a reference to the leaf node that contains the entry \n  ** about to be deleted. \n  */\n  if( rc==SQLITE_OK ){\n    rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);\n  }\n\n  /* Delete the cell in question from the leaf node. */\n  if( rc==SQLITE_OK ){\n    int rc2;\n    rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);\n    if( rc==SQLITE_OK ){\n      rc = deleteCell(pRtree, pLeaf, iCell, 0);\n    }\n    rc2 = nodeRelease(pRtree, pLeaf);\n    if( rc==SQLITE_OK ){\n      rc = rc2;\n    }\n  }\n\n  /* Delete the corresponding entry in the <rtree>_rowid table. */\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pRtree->pDeleteRowid, 1, iDelete);\n    sqlite3_step(pRtree->pDeleteRowid);\n    rc = sqlite3_reset(pRtree->pDeleteRowid);\n  }\n\n  /* Check if the root node now has exactly one child. If so, remove\n  ** it, schedule the contents of the child for reinsertion and \n  ** reduce the tree height by one.\n  **\n  ** This is equivalent to copying the contents of the child into\n  ** the root node (the operation that Gutman's paper says to perform \n  ** in this scenario).\n  */\n  if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){\n    int rc2;\n    RtreeNode *pChild;\n    i64 iChild = nodeGetRowid(pRtree, pRoot, 0);\n    rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);\n    if( rc==SQLITE_OK ){\n      rc = removeNode(pRtree, pChild, pRtree->iDepth-1);\n    }\n    rc2 = nodeRelease(pRtree, pChild);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK ){\n      pRtree->iDepth--;\n      writeInt16(pRoot->zData, pRtree->iDepth);\n      pRoot->isDirty = 1;\n    }\n  }\n\n  /* Re-insert the contents of any underfull nodes removed from the tree. */\n  for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){\n    if( rc==SQLITE_OK ){\n      rc = reinsertNodeContent(pRtree, pLeaf);\n    }\n    pRtree->pDeleted = pLeaf->pNext;\n    sqlite3_free(pLeaf);\n  }\n\n  /* Release the reference to the root node. */\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRoot);\n  }else{\n    nodeRelease(pRtree, pRoot);\n  }\n\n  return rc;\n}\n\n/*\n** Rounding constants for float->double conversion.\n*/\n#define RNDTOWARDS  (1.0 - 1.0/8388608.0)  /* Round towards zero */\n#define RNDAWAY     (1.0 + 1.0/8388608.0)  /* Round away from zero */\n\n#if !defined(SQLITE_RTREE_INT_ONLY)\n/*\n** Convert an sqlite3_value into an RtreeValue (presumably a float)\n** while taking care to round toward negative or positive, respectively.\n*/\nstatic RtreeValue rtreeValueDown(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f>d ){\n    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));\n  }\n  return f;\n}\nstatic RtreeValue rtreeValueUp(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f<d ){\n    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));\n  }\n  return f;\n}\n#endif /* !defined(SQLITE_RTREE_INT_ONLY) */\n\n/*\n** A constraint has failed while inserting a row into an rtree table. \n** Assuming no OOM error occurs, this function sets the error message \n** (at pRtree->base.zErrMsg) to an appropriate value and returns\n** SQLITE_CONSTRAINT.\n**\n** Parameter iCol is the index of the leftmost column involved in the\n** constraint failure. If it is 0, then the constraint that failed is\n** the unique constraint on the id column. Otherwise, it is the rtree\n** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.\n**\n** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.\n*/\nstatic int rtreeConstraintError(Rtree *pRtree, int iCol){\n  sqlite3_stmt *pStmt = 0;\n  char *zSql; \n  int rc;\n\n  assert( iCol==0 || iCol%2 );\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", pRtree->zDb, pRtree->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    if( iCol==0 ){\n      const char *zCol = sqlite3_column_name(pStmt, 0);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"UNIQUE constraint failed: %s.%s\", pRtree->zName, zCol\n      );\n    }else{\n      const char *zCol1 = sqlite3_column_name(pStmt, iCol);\n      const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"rtree constraint failed: %s.(%s<=%s)\", pRtree->zName, zCol1, zCol2\n      );\n    }\n  }\n\n  sqlite3_finalize(pStmt);\n  return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);\n}\n\n\n\n/*\n** The xUpdate method for rtree module virtual tables.\n*/\nstatic int rtreeUpdate(\n  sqlite3_vtab *pVtab, \n  int nData, \n  sqlite3_value **azData, \n  sqlite_int64 *pRowid\n){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_OK;\n  RtreeCell cell;                 /* New cell to insert if nData>1 */\n  int bHaveRowid = 0;             /* Set to 1 after new rowid is determined */\n\n  rtreeReference(pRtree);\n  assert(nData>=1);\n\n  cell.iRowid = 0;  /* Used only to suppress a compiler warning */\n\n  /* Constraint handling. A write operation on an r-tree table may return\n  ** SQLITE_CONSTRAINT for two reasons:\n  **\n  **   1. A duplicate rowid value, or\n  **   2. The supplied data violates the \"x2>=x1\" constraint.\n  **\n  ** In the first case, if the conflict-handling mode is REPLACE, then\n  ** the conflicting row can be removed before proceeding. In the second\n  ** case, SQLITE_CONSTRAINT must be returned regardless of the\n  ** conflict-handling mode specified by the user.\n  */\n  if( nData>1 ){\n    int ii;\n\n    /* Populate the cell.aCoord[] array. The first coordinate is azData[3].\n    **\n    ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared\n    ** with \"column\" that are interpreted as table constraints.\n    ** Example:  CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));\n    ** This problem was discovered after years of use, so we silently ignore\n    ** these kinds of misdeclared tables to avoid breaking any legacy.\n    */\n    assert( nData<=(pRtree->nDim2 + 3) );\n\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      for(ii=0; ii<nData-4; ii+=2){\n        cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);\n        cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);\n        if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }else\n#endif\n    {\n      for(ii=0; ii<nData-4; ii+=2){\n        cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);\n        cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);\n        if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }\n\n    /* If a rowid value was supplied, check if it is already present in \n    ** the table. If so, the constraint has failed. */\n    if( sqlite3_value_type(azData[2])!=SQLITE_NULL ){\n      cell.iRowid = sqlite3_value_int64(azData[2]);\n      if( sqlite3_value_type(azData[0])==SQLITE_NULL\n       || sqlite3_value_int64(azData[0])!=cell.iRowid\n      ){\n        int steprc;\n        sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);\n        steprc = sqlite3_step(pRtree->pReadRowid);\n        rc = sqlite3_reset(pRtree->pReadRowid);\n        if( SQLITE_ROW==steprc ){\n          if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){\n            rc = rtreeDeleteRowid(pRtree, cell.iRowid);\n          }else{\n            rc = rtreeConstraintError(pRtree, 0);\n            goto constraint;\n          }\n        }\n      }\n      bHaveRowid = 1;\n    }\n  }\n\n  /* If azData[0] is not an SQL NULL value, it is the rowid of a\n  ** record to delete from the r-tree table. The following block does\n  ** just that.\n  */\n  if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){\n    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(azData[0]));\n  }\n\n  /* If the azData[] array contains more than one element, elements\n  ** (azData[2]..azData[argc-1]) contain a new record to insert into\n  ** the r-tree structure.\n  */\n  if( rc==SQLITE_OK && nData>1 ){\n    /* Insert the new record into the r-tree */\n    RtreeNode *pLeaf = 0;\n\n    /* Figure out the rowid of the new row. */\n    if( bHaveRowid==0 ){\n      rc = newRowid(pRtree, &cell.iRowid);\n    }\n    *pRowid = cell.iRowid;\n\n    if( rc==SQLITE_OK ){\n      rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);\n    }\n    if( rc==SQLITE_OK ){\n      int rc2;\n      pRtree->iReinsertHeight = -1;\n      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);\n      rc2 = nodeRelease(pRtree, pLeaf);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\nconstraint:\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Called when a transaction starts.\n*/\nstatic int rtreeBeginTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  assert( pRtree->inWrTrans==0 );\n  pRtree->inWrTrans++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a transaction completes (either by COMMIT or ROLLBACK).\n** The sqlite3_blob object should be released at this point.\n*/\nstatic int rtreeEndTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** The xRename method for rtree module virtual tables.\n*/\nstatic int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_node'   RENAME TO \\\"%w_node\\\";\"\n    \"ALTER TABLE %Q.'%q_parent' RENAME TO \\\"%w_parent\\\";\"\n    \"ALTER TABLE %Q.'%q_rowid'  RENAME TO \\\"%w_rowid\\\";\"\n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName\n  );\n  if( zSql ){\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** The xSavepoint method.\n**\n** This module does not need to do anything to support savepoints. However,\n** it uses this hook to close any open blob handle. This is done because a \n** DROP TABLE command - which fortunately always opens a savepoint - cannot \n** succeed if there are any open blob handles. i.e. if the blob handle were\n** not closed here, the following would fail:\n**\n**   BEGIN;\n**     INSERT INTO rtree...\n**     DROP TABLE <tablename>;    -- Would fail with SQLITE_LOCKED\n**   COMMIT;\n*/\nstatic int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int iwt = pRtree->inWrTrans;\n  UNUSED_PARAMETER(iSavepoint);\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  pRtree->inWrTrans = iwt;\n  return SQLITE_OK;\n}\n\n/*\n** This function populates the pRtree->nRowEst variable with an estimate\n** of the number of rows in the virtual table. If possible, this is based\n** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST.\n*/\nstatic int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){\n  const char *zFmt = \"SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\";\n  char *zSql;\n  sqlite3_stmt *p;\n  int rc;\n  i64 nRow = 0;\n\n  rc = sqlite3_table_column_metadata(\n      db, pRtree->zDb, \"sqlite_stat1\",0,0,0,0,0,0\n  );\n  if( rc!=SQLITE_OK ){\n    pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n    return rc==SQLITE_ERROR ? SQLITE_OK : rc;\n  }\n  zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);\n    if( rc==SQLITE_OK ){\n      if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0);\n      rc = sqlite3_finalize(p);\n    }else if( rc!=SQLITE_NOMEM ){\n      rc = SQLITE_OK;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( nRow==0 ){\n        pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n      }else{\n        pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST);\n      }\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\nstatic sqlite3_module rtreeModule = {\n  2,                          /* iVersion */\n  rtreeCreate,                /* xCreate - create a table */\n  rtreeConnect,               /* xConnect - connect to an existing table */\n  rtreeBestIndex,             /* xBestIndex - Determine search strategy */\n  rtreeDisconnect,            /* xDisconnect - Disconnect from a table */\n  rtreeDestroy,               /* xDestroy - Drop a table */\n  rtreeOpen,                  /* xOpen - open a cursor */\n  rtreeClose,                 /* xClose - close a cursor */\n  rtreeFilter,                /* xFilter - configure scan constraints */\n  rtreeNext,                  /* xNext - advance a cursor */\n  rtreeEof,                   /* xEof */\n  rtreeColumn,                /* xColumn - read data */\n  rtreeRowid,                 /* xRowid - read data */\n  rtreeUpdate,                /* xUpdate - write data */\n  rtreeBeginTransaction,      /* xBegin - begin transaction */\n  rtreeEndTransaction,        /* xSync - sync transaction */\n  rtreeEndTransaction,        /* xCommit - commit transaction */\n  rtreeEndTransaction,        /* xRollback - rollback transaction */\n  0,                          /* xFindFunction - function overloading */\n  rtreeRename,                /* xRename - rename the table */\n  rtreeSavepoint,             /* xSavepoint */\n  0,                          /* xRelease */\n  0,                          /* xRollbackTo */\n};\n\nstatic int rtreeSqlInit(\n  Rtree *pRtree, \n  sqlite3 *db, \n  const char *zDb, \n  const char *zPrefix, \n  int isCreate\n){\n  int rc = SQLITE_OK;\n\n  #define N_STATEMENT 8\n  static const char *azSql[N_STATEMENT] = {\n    /* Write the xxx_node table */\n    \"INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_node' WHERE nodeno = :1\",\n\n    /* Read and write the xxx_rowid table */\n    \"SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n\n    /* Read and write the xxx_parent table */\n    \"SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1\"\n  };\n  sqlite3_stmt **appStmt[N_STATEMENT];\n  int i;\n\n  pRtree->db = db;\n\n  if( isCreate ){\n    char *zCreate = sqlite3_mprintf(\n\"CREATE TABLE \\\"%w\\\".\\\"%w_node\\\"(nodeno INTEGER PRIMARY KEY, data BLOB);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_rowid\\\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_parent\\\"(nodeno INTEGER PRIMARY KEY,\"\n                                  \" parentnode INTEGER);\"\n\"INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))\",\n      zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize\n    );\n    if( !zCreate ){\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_exec(db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  appStmt[0] = &pRtree->pWriteNode;\n  appStmt[1] = &pRtree->pDeleteNode;\n  appStmt[2] = &pRtree->pReadRowid;\n  appStmt[3] = &pRtree->pWriteRowid;\n  appStmt[4] = &pRtree->pDeleteRowid;\n  appStmt[5] = &pRtree->pReadParent;\n  appStmt[6] = &pRtree->pWriteParent;\n  appStmt[7] = &pRtree->pDeleteParent;\n\n  rc = rtreeQueryStat1(db, pRtree);\n  for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){\n    char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);\n    if( zSql ){\n      rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,\n                              appStmt[i], 0); \n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\n/*\n** The second argument to this function contains the text of an SQL statement\n** that returns a single integer value. The statement is compiled and executed\n** using database connection db. If successful, the integer value returned\n** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error\n** code is returned and the value of *piVal after returning is not defined.\n*/\nstatic int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){\n  int rc = SQLITE_NOMEM;\n  if( zSql ){\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *piVal = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called from within the xConnect() or xCreate() method to\n** determine the node-size used by the rtree table being created or connected\n** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned.\n**\n** If this function is being called as part of an xConnect(), then the rtree\n** table already exists. In this case the node-size is determined by inspecting\n** the root node of the tree.\n**\n** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. \n** This ensures that each node is stored on a single database page. If the \n** database page-size is so large that more than RTREE_MAXCELLS entries \n** would fit in a single node, use a smaller node-size.\n*/\nstatic int getNodeSize(\n  sqlite3 *db,                    /* Database handle */\n  Rtree *pRtree,                  /* Rtree handle */\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  char **pzErr                    /* OUT: Error message, if any */\n){\n  int rc;\n  char *zSql;\n  if( isCreate ){\n    int iPageSize = 0;\n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", pRtree->zDb);\n    rc = getIntFromStmt(db, zSql, &iPageSize);\n    if( rc==SQLITE_OK ){\n      pRtree->iNodeSize = iPageSize-64;\n      if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){\n        pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS;\n      }\n    }else{\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }else{\n    zSql = sqlite3_mprintf(\n        \"SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\",\n        pRtree->zDb, pRtree->zName\n    );\n    rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else if( pRtree->iNodeSize<(512-64) ){\n      rc = SQLITE_CORRUPT_VTAB;\n      *pzErr = sqlite3_mprintf(\"undersize RTree blobs in \\\"%q_node\\\"\",\n                               pRtree->zName);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/* \n** This function is the implementation of both the xConnect and xCreate\n** methods of the r-tree virtual table.\n**\n**   argv[0]   -> module name\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> column names...\n*/\nstatic int rtreeInit(\n  sqlite3 *db,                        /* Database connection */\n  void *pAux,                         /* One of the RTREE_COORD_* constants */\n  int argc, const char *const*argv,   /* Parameters to CREATE TABLE statement */\n  sqlite3_vtab **ppVtab,              /* OUT: New virtual table */\n  char **pzErr,                       /* OUT: Error message, if any */\n  int isCreate                        /* True for xCreate, false for xConnect */\n){\n  int rc = SQLITE_OK;\n  Rtree *pRtree;\n  int nDb;              /* Length of string argv[1] */\n  int nName;            /* Length of string argv[2] */\n  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);\n\n  const char *aErrMsg[] = {\n    0,                                                    /* 0 */\n    \"Wrong number of columns for an rtree table\",         /* 1 */\n    \"Too few columns for an rtree table\",                 /* 2 */\n    \"Too many columns for an rtree table\"                 /* 3 */\n  };\n\n  int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2;\n  if( aErrMsg[iErr] ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[iErr]);\n    return SQLITE_ERROR;\n  }\n\n  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n  /* Allocate the sqlite3_vtab structure */\n  nDb = (int)strlen(argv[1]);\n  nName = (int)strlen(argv[2]);\n  pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);\n  if( !pRtree ){\n    return SQLITE_NOMEM;\n  }\n  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);\n  pRtree->nBusy = 1;\n  pRtree->base.pModule = &rtreeModule;\n  pRtree->zDb = (char *)&pRtree[1];\n  pRtree->zName = &pRtree->zDb[nDb+1];\n  pRtree->nDim = (u8)((argc-4)/2);\n  pRtree->nDim2 = pRtree->nDim*2;\n  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;\n  pRtree->eCoordType = (u8)eCoordType;\n  memcpy(pRtree->zDb, argv[1], nDb);\n  memcpy(pRtree->zName, argv[2], nName);\n\n  /* Figure out the node size to use. */\n  rc = getNodeSize(db, pRtree, isCreate, pzErr);\n\n  /* Create/Connect to the underlying relational database schema. If\n  ** that is successful, call sqlite3_declare_vtab() to configure\n  ** the r-tree table schema.\n  */\n  if( rc==SQLITE_OK ){\n    if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else{\n      char *zSql = sqlite3_mprintf(\"CREATE TABLE x(%s\", argv[3]);\n      char *zTmp;\n      int ii;\n      for(ii=4; zSql && ii<argc; ii++){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s, %s\", zTmp, argv[ii]);\n        sqlite3_free(zTmp);\n      }\n      if( zSql ){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s);\", zTmp);\n        sqlite3_free(zTmp);\n      }\n      if( !zSql ){\n        rc = SQLITE_NOMEM;\n      }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){\n        *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      }\n      sqlite3_free(zSql);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    *ppVtab = (sqlite3_vtab *)pRtree;\n  }else{\n    assert( *ppVtab==0 );\n    assert( pRtree->nBusy==1 );\n    rtreeRelease(pRtree);\n  }\n  return rc;\n}\n\n\n/*\n** Implementation of a scalar function that decodes r-tree nodes to\n** human readable strings. This can be used for debugging and analysis.\n**\n** The scalar function takes two arguments: (1) the number of dimensions\n** to the rtree (between 1 and 5, inclusive) and (2) a blob of data containing\n** an r-tree node.  For a two-dimensional r-tree structure called \"rt\", to\n** deserialize all nodes, a statement like:\n**\n**   SELECT rtreenode(2, data) FROM rt_node;\n**\n** The human readable string takes the form of a Tcl list with one\n** entry for each cell in the r-tree node. Each entry is itself a\n** list, containing the 8-byte rowid/pageno followed by the \n** <num-dimension>*2 coordinates.\n*/\nstatic void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  char *zText = 0;\n  RtreeNode node;\n  Rtree tree;\n  int ii;\n\n  UNUSED_PARAMETER(nArg);\n  memset(&node, 0, sizeof(RtreeNode));\n  memset(&tree, 0, sizeof(Rtree));\n  tree.nDim = (u8)sqlite3_value_int(apArg[0]);\n  tree.nDim2 = tree.nDim*2;\n  tree.nBytesPerCell = 8 + 8 * tree.nDim;\n  node.zData = (u8 *)sqlite3_value_blob(apArg[1]);\n\n  for(ii=0; ii<NCELL(&node); ii++){\n    char zCell[512];\n    int nCell = 0;\n    RtreeCell cell;\n    int jj;\n\n    nodeGetCell(&tree, &node, ii, &cell);\n    sqlite3_snprintf(512-nCell,&zCell[nCell],\"%lld\", cell.iRowid);\n    nCell = (int)strlen(zCell);\n    for(jj=0; jj<tree.nDim2; jj++){\n#ifndef SQLITE_RTREE_INT_ONLY\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %g\",\n                       (double)cell.aCoord[jj].f);\n#else\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %d\",\n                       cell.aCoord[jj].i);\n#endif\n      nCell = (int)strlen(zCell);\n    }\n\n    if( zText ){\n      char *zTextNew = sqlite3_mprintf(\"%s {%s}\", zText, zCell);\n      sqlite3_free(zText);\n      zText = zTextNew;\n    }else{\n      zText = sqlite3_mprintf(\"{%s}\", zCell);\n    }\n  }\n  \n  sqlite3_result_text(ctx, zText, -1, sqlite3_free);\n}\n\n/* This routine implements an SQL function that returns the \"depth\" parameter\n** from the front of a blob that is an r-tree node.  For example:\n**\n**     SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1;\n**\n** The depth value is 0 for all nodes other than the root node, and the root\n** node always has nodeno=1, so the example above is the primary use for this\n** routine.  This routine is intended for testing and analysis only.\n*/\nstatic void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  UNUSED_PARAMETER(nArg);\n  if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB \n   || sqlite3_value_bytes(apArg[0])<2\n  ){\n    sqlite3_result_error(ctx, \"Invalid argument to rtreedepth()\", -1); \n  }else{\n    u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);\n    sqlite3_result_int(ctx, readInt16(zBlob));\n  }\n}\n\n/*\n** Register the r-tree module with database handle db. This creates the\n** virtual table module \"rtree\" and the debugging/analysis scalar \n** function \"rtreenode\".\n*/\nint sqlite3RtreeInit(sqlite3 *db){\n  const int utf8 = SQLITE_UTF8;\n  int rc;\n\n  rc = sqlite3_create_function(db, \"rtreenode\", 2, utf8, 0, rtreenode, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"rtreedepth\", 1, utf8, 0,rtreedepth, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n#ifdef SQLITE_RTREE_INT_ONLY\n    void *c = (void *)RTREE_COORD_INT32;\n#else\n    void *c = (void *)RTREE_COORD_REAL32;\n#endif\n    rc = sqlite3_create_module_v2(db, \"rtree\", &rtreeModule, c, 0);\n  }\n  if( rc==SQLITE_OK ){\n    void *c = (void *)RTREE_COORD_INT32;\n    rc = sqlite3_create_module_v2(db, \"rtree_i32\", &rtreeModule, c, 0);\n  }\n\n  return rc;\n}\n\n/*\n** This routine deletes the RtreeGeomCallback object that was attached\n** one of the SQL functions create by sqlite3_rtree_geometry_callback()\n** or sqlite3_rtree_query_callback().  In other words, this routine is the\n** destructor for an RtreeGeomCallback objecct.  This routine is called when\n** the corresponding SQL function is deleted.\n*/\nstatic void rtreeFreeCallback(void *p){\n  RtreeGeomCallback *pInfo = (RtreeGeomCallback*)p;\n  if( pInfo->xDestructor ) pInfo->xDestructor(pInfo->pContext);\n  sqlite3_free(p);\n}\n\n/*\n** This routine frees the BLOB that is returned by geomCallback().\n*/\nstatic void rtreeMatchArgFree(void *pArg){\n  int i;\n  RtreeMatchArg *p = (RtreeMatchArg*)pArg;\n  for(i=0; i<p->nParam; i++){\n    sqlite3_value_free(p->apSqlParam[i]);\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Each call to sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback() creates an ordinary SQLite\n** scalar function that is implemented by this routine.\n**\n** All this function does is construct an RtreeMatchArg object that\n** contains the geometry-checking callback routines and a list of\n** parameters to this function, then return that RtreeMatchArg object\n** as a BLOB.\n**\n** The R-Tree MATCH operator will read the returned BLOB, deserialize\n** the RtreeMatchArg object, and use the RtreeMatchArg object to figure\n** out which elements of the R-Tree should be returned by the query.\n*/\nstatic void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n  RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);\n  RtreeMatchArg *pBlob;\n  int nBlob;\n  int memErr = 0;\n\n  nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue)\n           + nArg*sizeof(sqlite3_value*);\n  pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);\n  if( !pBlob ){\n    sqlite3_result_error_nomem(ctx);\n  }else{\n    int i;\n    pBlob->iSize = nBlob;\n    pBlob->cb = pGeomCtx[0];\n    pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg];\n    pBlob->nParam = nArg;\n    for(i=0; i<nArg; i++){\n      pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]);\n      if( pBlob->apSqlParam[i]==0 ) memErr = 1;\n#ifdef SQLITE_RTREE_INT_ONLY\n      pBlob->aParam[i] = sqlite3_value_int64(aArg[i]);\n#else\n      pBlob->aParam[i] = sqlite3_value_double(aArg[i]);\n#endif\n    }\n    if( memErr ){\n      sqlite3_result_error_nomem(ctx);\n      rtreeMatchArgFree(pBlob);\n    }else{\n      sqlite3_result_pointer(ctx, pBlob, \"RtreeMatchArg\", rtreeMatchArgFree);\n    }\n  }\n}\n\n/*\n** Register a new geometry function for use with the r-tree MATCH operator.\n*/\nint sqlite3_rtree_geometry_callback(\n  sqlite3 *db,                  /* Register SQL function on this connection */\n  const char *zGeom,            /* Name of the new SQL function */\n  int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */\n  void *pContext                /* Extra data associated with the callback */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = xGeom;\n  pGeomCtx->xQueryFunc = 0;\n  pGeomCtx->xDestructor = 0;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n/*\n** Register a new 2nd-generation geometry function for use with the\n** r-tree MATCH operator.\n*/\nint sqlite3_rtree_query_callback(\n  sqlite3 *db,                 /* Register SQL function on this connection */\n  const char *zQueryFunc,      /* Name of new SQL function */\n  int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */\n  void *pContext,              /* Extra data passed into the callback */\n  void (*xDestructor)(void*)   /* Destructor for the extra data */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = 0;\n  pGeomCtx->xQueryFunc = xQueryFunc;\n  pGeomCtx->xDestructor = xDestructor;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zQueryFunc, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_rtree_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3RtreeInit(db);\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree.h",
    "content": "/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** RTREE library.  All it does is declare the sqlite3RtreeInit() interface.\n*/\n#include \"sqlite3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif  /* __cplusplus */\n\nint sqlite3RtreeInit(sqlite3 *db);\n\n#ifdef __cplusplus\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree1.test",
    "content": "# 2008 Feb 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the r-tree extension.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource [file join [file dirname [info script]] rtree_util.tcl]\nsource $testdir/tester.tcl\nset testprefix rtree1\n\n# Test plan:\n#\n#   rtree-1.*: Creating/destroying r-tree tables.\n#   rtree-2.*: Test the implicit constraints - unique rowid and\n#              (coord[N]<=coord[N+1]) for even values of N. Also\n#              automatic assigning of rowid values.\n#   rtree-3.*: Linear scans of r-tree data.\n#   rtree-4.*: Test INSERT\n#   rtree-5.*: Test DELETE\n#   rtree-6.*: Test UPDATE\n#   rtree-7.*: Test renaming an r-tree table.\n#   rtree-8.*: Test constrained scans of r-tree data.\n#\n#   rtree-12.*: Test that on-conflict clauses are supported.\n#   rtree-13.*: Test that bug [d2889096e7bdeac6d] has been fixed.\n#   rtree-14.*: Test if a non-integer is inserted into the PK column of an\n#               r-tree table, it is converted to an integer before being\n#               inserted. Also that if a non-numeric is inserted into one\n#               of the min/max dimension columns, it is converted to the\n#               required type before being inserted.\n#   rtree-15.*: Check that DROP TABLE works within a transaction that\n#               writes to an r-tree table.\n#\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-1.* test CREATE and DROP table statements.\n#\n\n# Test creating and dropping an rtree table.\n#\ndo_test rtree-1.1.1 {\n  execsql { CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2) }\n} {}\ndo_test rtree-1.1.2 {\n  execsql { SELECT name FROM sqlite_master ORDER BY name }\n} {t1 t1_node t1_parent t1_rowid}\ndo_test rtree-1.1.3 {\n  execsql { \n    DROP TABLE t1; \n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n} {}\n\n# Test creating and dropping an rtree table with an odd name in\n# an attached database.\n#\ndo_test rtree-1.2.1 {\n  file delete -force test2.db\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    CREATE VIRTUAL TABLE aux.'a\" \"b' USING rtree(ii, x1, x2, y1, y2);\n  }\n} {}\ndo_test rtree-1.2.2 {\n  execsql { SELECT name FROM sqlite_master ORDER BY name }\n} {}\ndo_test rtree-1.2.3 {\n  execsql { SELECT name FROM aux.sqlite_master ORDER BY name }\n} {{a\" \"b} {a\" \"b_node} {a\" \"b_parent} {a\" \"b_rowid}}\ndo_test rtree-1.2.4 {\n  execsql { \n    DROP TABLE aux.'a\" \"b'; \n    SELECT name FROM aux.sqlite_master ORDER BY name;\n  }\n} {}\n\n# Test that the logic for checking the number of columns specified\n# for an rtree table. Acceptable values are odd numbers between 3 and\n# 11, inclusive.\n#\nset cols [list i1 i2 i3 i4 i5 i6 i7 i8 i9 iA iB iC iD iE iF iG iH iI iJ iK]\nfor {set nCol 1} {$nCol<[llength $cols]} {incr nCol} {\n\n  set columns [join [lrange $cols 0 [expr {$nCol-1}]] ,]\n\n  set X {0 {}}\n  if {$nCol%2 == 0}  { set X {1 {Wrong number of columns for an rtree table}} }\n  if {$nCol < 3}     { set X {1 {Too few columns for an rtree table}} }\n  if {$nCol > 11}    { set X {1 {Too many columns for an rtree table}} }\n\n  do_test rtree-1.3.$nCol {\n    catchsql \" \n      CREATE VIRTUAL TABLE t1 USING rtree($columns);\n    \"\n  } $X\n\n  catchsql { DROP TABLE t1 }\n}\n\n# Like execsql except display output as integer where that can be\n# done without loss of information.\n#\nproc execsql_intout {sql} {\n  set out {}\n  foreach term [execsql $sql] {\n    regsub {\\.0$} $term {} term\n    lappend out $term\n  }\n  return $out\n}\n\n# Test that it is possible to open an existing database that contains\n# r-tree tables.\n#\ndo_execsql_test rtree-1.4.1a {\n  CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2);\n  INSERT INTO t1 VALUES(1, 5.0, 10.0);\n  SELECT substr(hex(data),1,40) FROM t1_node;\n} {00000001000000000000000140A0000041200000}\ndo_execsql_test rtree-1.4.1b {\n  INSERT INTO t1 VALUES(2, 15.0, 20.0);\n} {}\ndo_test rtree-1.4.2 {\n  db close\n  sqlite3 db test.db\n  execsql_intout { SELECT * FROM t1 ORDER BY ii }\n} {1 5 10 2 15 20}\ndo_test rtree-1.4.3 {\n  execsql { DROP TABLE t1 }\n} {}\n\n# Test that it is possible to create an r-tree table with ridiculous\n# column names.\n#\ndo_test rtree-1.5.1 {\n  execsql_intout {\n    CREATE VIRTUAL TABLE t1 USING rtree(\"the key\", \"x dim.\", \"x2'dim\");\n    INSERT INTO t1 VALUES(1, 2, 3);\n    SELECT \"the key\", \"x dim.\", \"x2'dim\" FROM t1;\n  }\n} {1 2 3}\ndo_test rtree-1.5.1 {\n  execsql { DROP TABLE t1 }\n} {}\n\n# Force the r-tree constructor to fail.\n#\ndo_test rtree-1.6.1 {\n  execsql { CREATE TABLE t1_rowid(a); }\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING rtree(\"the key\", \"x dim.\", \"x2'dim\");\n  }\n} {1 {table \"t1_rowid\" already exists}}\ndo_test rtree-1.6.1 {\n  execsql { DROP TABLE t1_rowid }\n} {}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-2.* \n#\ndo_test rtree-2.1.1 {\n  execsql { \n    CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);\n    SELECT * FROM t1;\n  }\n} {}\n\ndo_test rtree-2.1.2 {\n  execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }\n  execsql_intout { SELECT * FROM t1 }\n} {1 1 3 2 4}\ndo_test rtree-2.1.3 {\n  execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }\n  execsql { SELECT rowid FROM t1 ORDER BY rowid }\n} {1 2}\ndo_test rtree-2.1.3 {\n  execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }\n  execsql { SELECT ii FROM t1 ORDER BY ii }\n} {1 2 3}\n\ndo_test rtree-2.2.1 {\n  catchsql { INSERT INTO t1 VALUES(2, 1, 3, 2, 4) }\n} {1 {UNIQUE constraint failed: t1.ii}}\ndo_test rtree-2.2.2 {\n  catchsql { INSERT INTO t1 VALUES(4, 1, 3, 4, 2) }\n} {1 {rtree constraint failed: t1.(y1<=y2)}}\ndo_test rtree-2.2.3 {\n  catchsql { INSERT INTO t1 VALUES(4, 3, 1, 2, 4) }\n} {1 {rtree constraint failed: t1.(x1<=x2)}}\ndo_test rtree-2.2.4 {\n  execsql { SELECT ii FROM t1 ORDER BY ii }\n} {1 2 3}\n\ndo_test rtree-2.X {\n  execsql { DROP TABLE t1 }\n} {}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-3.* test linear scans of r-tree table data. To test\n# this we have to insert some data into an r-tree, but that is not the\n# focus of these tests.\n#\ndo_test rtree-3.1.1 {\n  execsql { \n    CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);\n    SELECT * FROM t1;\n  }\n} {}\ndo_test rtree-3.1.2 {\n  execsql_intout { \n    INSERT INTO t1 VALUES(5, 1, 3, 2, 4);\n    SELECT * FROM t1;\n  }\n} {5 1 3 2 4}\ndo_test rtree-3.1.3 {\n  execsql_intout {\n    INSERT INTO t1 VALUES(6, 2, 6, 4, 8);\n    SELECT * FROM t1;\n  }\n} {5 1 3 2 4 6 2 6 4 8}\n\n# Test the constraint on the coordinates (c[i]<=c[i+1] where (i%2==0)):\ndo_test rtree-3.2.1 {\n  catchsql { INSERT INTO t1 VALUES(7, 2, 6, 4, 3) }\n} {1 {rtree constraint failed: t1.(y1<=y2)}}\ndo_test rtree-3.2.2 {\n  catchsql { INSERT INTO t1 VALUES(8, 2, 6, 3, 3) }\n} {0 {}}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-5.* test DELETE operations.\n#\ndo_test rtree-5.1.1 {\n  execsql { CREATE VIRTUAL TABLE t2 USING rtree(ii, x1, x2) }\n} {}\ndo_test rtree-5.1.2 {\n  execsql_intout { \n    INSERT INTO t2 VALUES(1, 10, 20);\n    INSERT INTO t2 VALUES(2, 30, 40);\n    INSERT INTO t2 VALUES(3, 50, 60);\n    SELECT * FROM t2 ORDER BY ii;\n  }\n} {1 10 20 2 30 40 3 50 60}\ndo_test rtree-5.1.3 {\n  execsql_intout { \n    DELETE FROM t2 WHERE ii=2;\n    SELECT * FROM t2 ORDER BY ii;\n  }\n} {1 10 20 3 50 60}\ndo_test rtree-5.1.4 {\n  execsql_intout { \n    DELETE FROM t2 WHERE ii=1;\n    SELECT * FROM t2 ORDER BY ii;\n  }\n} {3 50 60}\ndo_test rtree-5.1.5 {\n  execsql { \n    DELETE FROM t2 WHERE ii=3;\n    SELECT * FROM t2 ORDER BY ii;\n  }\n} {}\ndo_test rtree-5.1.6 {\n  execsql { SELECT * FROM t2_rowid }\n} {}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-5.* test UPDATE operations.\n#\ndo_test rtree-6.1.1 {\n  execsql { CREATE VIRTUAL TABLE t3 USING rtree(ii, x1, x2, y1, y2) }\n} {}\ndo_test rtree-6.1.2 {\n  execsql_intout {\n    INSERT INTO t3 VALUES(1, 2, 3, 4, 5);\n    UPDATE t3 SET x2=5;\n    SELECT * FROM t3;\n  }\n} {1 2 5 4 5}\ndo_test rtree-6.1.3 {\n  execsql { UPDATE t3 SET ii = 2 }\n  execsql_intout { SELECT * FROM t3 }\n} {2 2 5 4 5}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-7.* test rename operations.\n#\ndo_test rtree-7.1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t4 USING rtree(ii, x1, x2, y1, y2, z1, z2);\n    INSERT INTO t4 VALUES(1, 2, 3, 4, 5, 6, 7);\n  }\n} {}\ndo_test rtree-7.1.2 {\n  execsql { ALTER TABLE t4 RENAME TO t5 }\n  execsql_intout { SELECT * FROM t5 }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.1.3 {\n  db close\n  sqlite3 db test.db\n  execsql_intout { SELECT * FROM t5 }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.1.4 {\n  execsql { ALTER TABLE t5 RENAME TO 'raisara \"one\"'''}\n  execsql_intout { SELECT * FROM \"raisara \"\"one\"\"'\" }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.1.5 {\n  execsql_intout { SELECT * FROM 'raisara \"one\"''' }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.1.6 {\n  execsql { ALTER TABLE \"raisara \"\"one\"\"'\" RENAME TO \"abc 123\" }\n  execsql_intout { SELECT * FROM \"abc 123\" }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.1.7 {\n  db close\n  sqlite3 db test.db\n  execsql_intout { SELECT * FROM \"abc 123\" }\n} {1 2 3 4 5 6 7}\n\n# An error midway through a rename operation.\ndo_test rtree-7.2.1 {\n  execsql { \n    CREATE TABLE t4_node(a);\n  }\n  catchsql { ALTER TABLE \"abc 123\" RENAME TO t4 }\n} {1 {SQL logic error}}\ndo_test rtree-7.2.2 {\n  execsql_intout { SELECT * FROM \"abc 123\" }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.2.3 {\n  execsql { \n    DROP TABLE t4_node;\n    CREATE TABLE t4_rowid(a);\n  }\n  catchsql { ALTER TABLE \"abc 123\" RENAME TO t4 }\n} {1 {SQL logic error}}\ndo_test rtree-7.2.4 {\n  db close\n  sqlite3 db test.db\n  execsql_intout { SELECT * FROM \"abc 123\" }\n} {1 2 3 4 5 6 7}\ndo_test rtree-7.2.5 {\n  execsql { DROP TABLE t4_rowid }\n  execsql { ALTER TABLE \"abc 123\" RENAME TO t4 }\n  execsql_intout { SELECT * FROM t4 }\n} {1 2 3 4 5 6 7}\n\n\n#----------------------------------------------------------------------------\n# Test cases rtree-8.*\n#\n\n# Test that the function to determine if a leaf cell is part of the\n# result set works.\ndo_test rtree-8.1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t6 USING rtree(ii, x1, x2);\n    INSERT INTO t6 VALUES(1, 3, 7);\n    INSERT INTO t6 VALUES(2, 4, 6);\n  }\n} {}\ndo_test rtree-8.1.2 { execsql { SELECT ii FROM t6 WHERE x1>2 } } {1 2}\ndo_test rtree-8.1.3 { execsql { SELECT ii FROM t6 WHERE x1>3 } } {2}\ndo_test rtree-8.1.4 { execsql { SELECT ii FROM t6 WHERE x1>4 } } {}\ndo_test rtree-8.1.5 { execsql { SELECT ii FROM t6 WHERE x1>5 } } {}\ndo_test rtree-8.1.6 { execsql { SELECT ii FROM t6 WHERE x1<3 } } {}\ndo_test rtree-8.1.7 { execsql { SELECT ii FROM t6 WHERE x1<4 } } {1}\ndo_test rtree-8.1.8 { execsql { SELECT ii FROM t6 WHERE x1<5 } } {1 2}\n\n#----------------------------------------------------------------------------\n# Test cases rtree-9.*\n#\n# Test that ticket #3549 is fixed.\ndo_test rtree-9.1 {\n  execsql {\n    CREATE TABLE foo (id INTEGER PRIMARY KEY);\n    CREATE VIRTUAL TABLE bar USING rtree (id, minX, maxX, minY, maxY);\n    INSERT INTO foo VALUES (null);\n    INSERT INTO foo SELECT null FROM foo;\n    INSERT INTO foo SELECT null FROM foo;\n    INSERT INTO foo SELECT null FROM foo;\n    INSERT INTO foo SELECT null FROM foo;\n    INSERT INTO foo SELECT null FROM foo;\n    INSERT INTO foo SELECT null FROM foo;\n    DELETE FROM foo WHERE id > 40;\n    INSERT INTO bar SELECT NULL, 0, 0, 0, 0 FROM foo;\n  }\n} {}\n\n# This used to crash.\ndo_test rtree-9.2 {\n  execsql {\n    SELECT count(*) FROM bar b1, bar b2, foo s1 WHERE s1.id = b1.id;\n  }\n} {1600}\ndo_test rtree-9.3 {\n  execsql {\n    SELECT count(*) FROM bar b1, bar b2, foo s1 \n    WHERE b1.minX <= b2.maxX AND s1.id = b1.id;\n  }\n} {1600}\n\n#-------------------------------------------------------------------------\n# Ticket #3970: Check that the error message is meaningful when a \n# keyword is used as a column name.\n#\ndo_test rtree-10.1 {\n  catchsql { CREATE VIRTUAL TABLE t7 USING rtree(index, x1, y1, x2, y2) }\n} {1 {near \"index\": syntax error}}\n\n#-------------------------------------------------------------------------\n# Test last_insert_rowid().\n# \ndo_test rtree-11.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t8 USING rtree(idx, x1, x2, y1, y2);\n    INSERT INTO t8 VALUES(1, 1.0, 1.0, 2.0, 2.0);\n    SELECT last_insert_rowid();\n  }\n} {1}\ndo_test rtree-11.2 {\n  execsql {\n    INSERT INTO t8 VALUES(NULL, 1.0, 1.0, 2.0, 2.0);\n    SELECT last_insert_rowid();\n  }\n} {2}\n\n#-------------------------------------------------------------------------\n# Test on-conflict clause handling.\n#\ndb_delete_and_reopen\ndo_execsql_test 12.0.1 {\n  CREATE VIRTUAL TABLE t1 USING rtree_i32(idx, x1, x2, y1, y2);\n  INSERT INTO t1 VALUES(1,   1, 2, 3, 4);\n  SELECT substr(hex(data),1,56) FROM t1_node;\n} {00000001000000000000000100000001000000020000000300000004}\ndo_execsql_test 12.0.2 {\n  INSERT INTO t1 VALUES(2,   2, 3, 4, 5);\n  INSERT INTO t1 VALUES(3,   3, 4, 5, 6);\n\n  CREATE TABLE source(idx, x1, x2, y1, y2);\n  INSERT INTO source VALUES(5, 8, 8, 8, 8);\n  INSERT INTO source VALUES(2, 7, 7, 7, 7);\n}\ndb_save_and_close\nforeach {tn sql_template testdata} {\n  1    \"INSERT %CONF% INTO t1 VALUES(2, 7, 7, 7, 7)\" {\n    ROLLBACK 0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}\n    ABORT    0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    IGNORE   0 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    FAIL     0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    REPLACE  0 0 {1 1 2 3 4   2 7 7 7 7   3 3 4 5 6   4 4 5 6 7}\n  }\n\n  2    \"INSERT %CONF% INTO t1 SELECT * FROM source\" {\n    ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}\n    ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}\n    FAIL     1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}\n    REPLACE  1 0 {1 1 2 3 4   2 7 7 7 7   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}\n  }\n\n  3    \"UPDATE %CONF% t1 SET idx = 2 WHERE idx = 4\" {\n    ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}\n    ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    FAIL     1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    REPLACE  1 0 {1 1 2 3 4   2 4 5 6 7   3 3 4 5 6}\n  }\n\n  3    \"UPDATE %CONF% t1 SET idx = ((idx+1)%5)+1 WHERE idx > 2\" {\n    ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}\n    ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5               4 4 5 6 7   5 3 4 5 6}\n    FAIL     1 1 {1 1 2 3 4   2 2 3 4 5               4 4 5 6 7   5 3 4 5 6}\n    REPLACE  1 0 {1 4 5 6 7   2 2 3 4 5                           5 3 4 5 6}\n  }\n\n  4    \"INSERT %CONF% INTO t1 VALUES(2, 7, 6, 7, 7)\" {\n    ROLLBACK 0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}\n    ABORT    0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    IGNORE   0 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    FAIL     0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n    REPLACE  0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}\n  }\n\n} {\n  foreach {mode uses error data} $testdata {\n    db_restore_and_reopen\n\n    set sql [string map [list %CONF% \"OR $mode\"] $sql_template]\n    set testname \"12.$tn.[string tolower $mode]\"\n\n    execsql {\n      BEGIN;\n        INSERT INTO t1 VALUES(4,   4, 5, 6, 7);\n    }\n\n    set res(0) {0 {}}\n    set res(1) {1 {UNIQUE constraint failed: t1.idx}}\n    set res(2) {1 {rtree constraint failed: t1.(x1<=x2)}}\n\n    do_catchsql_test $testname.1 $sql $res($error)\n    do_test $testname.2 [list sql_uses_stmt db $sql] $uses\n    do_execsql_test $testname.3 { SELECT * FROM t1 ORDER BY idx } $data\n\n    do_test $testname.4 { rtree_check db t1 } 0\n    db close\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that bug [d2889096e7bdeac6d] has been fixed.\n#\nreset_db\ndo_execsql_test 13.1 {\n  CREATE VIRTUAL TABLE t9 USING rtree(id, xmin, xmax);\n  INSERT INTO t9 VALUES(1,0,0);            \n  INSERT INTO t9 VALUES(2,0,0);\n  SELECT * FROM t9 WHERE id IN (1, 2);\n} {1 0.0 0.0 2 0.0 0.0}\n\ndo_execsql_test 13.2 {\n  WITH r(x) AS (\n    SELECT 1 UNION ALL\n    SELECT 2 UNION ALL\n    SELECT 3\n  )\n  SELECT * FROM r CROSS JOIN t9 WHERE id=x;\n} {1 1 0.0 0.0 2 2 0.0 0.0}\n\n#-------------------------------------------------------------------------\n# Test if a non-integer is inserted into the PK column of an r-tree\n# table, it is converted to an integer before being inserted. Also\n# that if a non-numeric is inserted into one of the min/max dimension\n# columns, it is converted to the required type before being inserted.\n#\ndo_execsql_test 14.1 {\n  CREATE VIRTUAL TABLE t10 USING rtree(ii, x1, x2);\n}\n\ndo_execsql_test 14.2 {\n  INSERT INTO t10 VALUES(NULL,   1, 2);\n  INSERT INTO t10 VALUES(NULL,   2, 3);\n  INSERT INTO t10 VALUES('4xxx', 3, 4);\n  INSERT INTO t10 VALUES(5.0,    4, 5);\n  INSERT INTO t10 VALUES(6.4,    5, 6);\n}\ndo_execsql_test 14.3 {\n  SELECT * FROM t10;\n} {\n  1 1.0 2.0   2 2.0 3.0   4 3.0 4.0   5 4.0 5.0   6 5.0 6.0\n}\n\ndo_execsql_test 14.4 {\n  DELETE FROM t10;\n  INSERT INTO t10 VALUES(1, 'one', 'two');\n  INSERT INTO t10 VALUES(2, '52xyz', '81...');\n}\ndo_execsql_test 14.5 {\n  SELECT * FROM t10;\n} {\n  1 0.0 0.0\n  2 52.0 81.0\n}\n\ndo_execsql_test 14.4 {\n  DROP TABLE t10;\n  CREATE VIRTUAL TABLE t10 USING rtree_i32(ii, x1, x2);\n  INSERT INTO t10 VALUES(1, 'one', 'two');\n  INSERT INTO t10 VALUES(2, '52xyz', '81...');\n  INSERT INTO t10 VALUES(3, 42.3, 49.9);\n}\ndo_execsql_test 14.5 {\n  SELECT * FROM t10;\n} {\n  1 0 0\n  2 52 81\n  3 42 49\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 15.0 {\n  CREATE VIRTUAL TABLE rt USING rtree(id, x1,x2, y1,y2);\n  CREATE TEMP TABLE t13(a, b, c);\n}\ndo_execsql_test 15.1 {\n  BEGIN;\n  INSERT INTO rt VALUES(1,2,3,4,5);\n}\ndo_execsql_test 15.2 {\n  DROP TABLE t13;\n  COMMIT;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree2.test",
    "content": "# 2008 Feb 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the r-tree extension.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] rtree_util.tcl]\nsource $testdir/tester.tcl\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\nset ::NROW   1000\nset ::NDEL     10\nset ::NSELECT 100\n\nif {[info exists G(isquick)] && $G(isquick)} {\n  set ::NROW 100\n  set ::NSELECT 10\n}\n\nforeach module {rtree_i32 rtree} {\n  for {set nDim 1} {$nDim <= 5} {incr nDim} {\n  \n    do_test rtree2-$module.$nDim.1 {\n      set cols [list]\n      foreach c [list c0 c1 c2 c3 c4 c5 c6 c7 c8 c9] {\n        lappend cols \"$c REAL\"\n      }\n      set cols [join [lrange $cols 0 [expr {$nDim*2-1}]] \", \"]\n      execsql \" \n        CREATE VIRTUAL TABLE t1 USING ${module}(ii, $cols);\n        CREATE TABLE t2 (ii, $cols);\n      \"\n    } {}\n  \n    do_test rtree2-$module.$nDim.2 {\n      db transaction {\n        for {set ii 0} {$ii < $::NROW} {incr ii} {\n          #puts \"Row $ii\"\n          set values [list]\n          for {set jj 0} {$jj<$nDim*2} {incr jj} {\n            lappend values [expr int(rand()*1000)]\n          }\n          set values [join $values ,]\n          #puts [rtree_treedump db t1]\n          #puts \"INSERT INTO t2 VALUES($ii, $values)\"\n          set rc [catch {db eval \"INSERT INTO t1 VALUES($ii, $values)\"}]\n          if {$rc} {\n            incr ii -1\n          } else {\n            db eval \"INSERT INTO t2 VALUES($ii, $values)\"\n          }\n          #if {[rtree_check db t1]} {\n            #puts [rtree_treedump db t1]\n            #exit\n          #}\n        }\n      }\n  \n      set t1 [execsql {SELECT * FROM t1 ORDER BY ii}]\n      set t2 [execsql {SELECT * FROM t2 ORDER BY ii}]\n      set rc [expr {$t1 eq $t2}]\n      if {$rc != 1} {\n        puts $t1\n        puts $t2\n      }\n      set rc\n    } {1}\n  \n    do_test rtree2-$module.$nDim.3 {\n      rtree_check db t1\n    } 0\n  \n    set OPS [list < > <= >= =]\n    for {set ii 0} {$ii < $::NSELECT} {incr ii} {\n      do_test rtree2-$module.$nDim.4.$ii.1 {\n        set where [list]\n        foreach look_three_dots! {. . .} {\n          set colidx [expr int(rand()*($nDim*2+1))-1]\n          if {$colidx<0} {\n            set col ii\n          } else {\n            set col \"c$colidx\"\n          }\n          set op  [lindex $OPS [expr int(rand()*[llength $OPS])]]\n          set val [expr int(rand()*1000)]\n          lappend where \"$col $op $val\"\n        }\n        set where [join $where \" AND \"]\n  \n        set t1 [execsql \"SELECT * FROM t1 WHERE $where ORDER BY ii\"]\n        set t2 [execsql \"SELECT * FROM t2 WHERE $where ORDER BY ii\"]\n        set rc [expr {$t1 eq $t2}]\n        if {$rc != 1} {\n          #puts $where\n          puts $t1\n          puts $t2\n          #puts [rtree_treedump db t1]\n          #breakpoint\n          #set t1 [execsql \"SELECT * FROM t1 WHERE $where ORDER BY ii\"]\n          #exit\n        }\n        set rc\n      } {1}\n    }\n  \n    for {set ii 0} {$ii < $::NROW} {incr ii $::NDEL} {\n      #puts [rtree_treedump db t1]\n      do_test rtree2-$module.$nDim.5.$ii.1 {\n        execsql \"DELETE FROM t2 WHERE ii <= $::ii\"\n        execsql \"DELETE FROM t1 WHERE ii <= $::ii\"\n  \n        set t1 [execsql {SELECT * FROM t1 ORDER BY ii}]\n        set t2 [execsql {SELECT * FROM t2 ORDER BY ii}]\n        set rc [expr {$t1 eq $t2}]\n        if {$rc != 1} {\n          puts $t1\n          puts $t2\n        }\n        set rc\n      } {1}\n      do_test rtree2-$module.$nDim.5.$ii.2 {\n        rtree_check db t1\n      } {0}\n    }\n  \n    do_test rtree2-$module.$nDim.6 {\n      execsql {\n        DROP TABLE t1;\n        DROP TABLE t2;\n      }\n    } {}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree3.test",
    "content": "# 2008 Feb 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing that the r-tree correctly handles\n# out-of-memory conditions.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !rtree {\n  finish_test\n  return\n}\n\n# Test summary:\n#\n#   rtree3-1: Test OOM in simple CREATE TABLE, INSERT, DELETE and SELECT \n#             commands on an almost empty table.\n#\n#   rtree3-2: Test OOM in a DROP TABLE command.\n#\n#   rtree3-3a: Test OOM during a transaction to insert 100 pseudo-random rows.\n#\n#   rtree3-3b: Test OOM during a transaction deleting all entries in the\n#              database constructed in [rtree3-3a] in pseudo-random order.\n#\n#   rtree3-4a: OOM during \"SELECT count(*) FROM ...\" on a big table.\n#\n#   rtree3-4b: OOM while deleting rows from a big table.\n#\n#   rtree3-5: Test OOM while inserting rows into a big table.\n#\n#   rtree3-6: Test OOM while deleting all rows of a table, one at a time.\n#\n#   rtree3-7: OOM during an ALTER TABLE RENAME TABLE command.\n#\n#   rtree3-8: Test OOM while registering the r-tree module with sqlite.\n#\n#   rtree3-11: OOM following a constraint failure\n#\ndo_faultsim_test rtree3-1 -faults oom* -prep {\n  faultsim_delete_and_reopen\n} -body {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n    INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);\n    INSERT INTO rt VALUES(NULL, 13, 15, 17, 19);\n    DELETE FROM rt WHERE ii = 1;\n    SELECT * FROM rt;\n    SELECT ii FROM rt WHERE ii = 2;\n    COMMIT;\n  }\n}\n\ndo_test rtree3-2.prep {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n    INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { DROP TABLE rt } \n}\n\ndo_malloc_test rtree3-3.prep {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n    INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test rtree3-3a -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval BEGIN\n  for {set ii 0} {$ii < 100} {incr ii} {\n    set f [expr rand()]\n    db eval {INSERT INTO rt VALUES(NULL, $f*10.0, $f*10.0, $f*15.0, $f*15.0)}\n  }\n  db eval COMMIT\n}\nfaultsim_save_and_close\n\ndo_faultsim_test rtree3-3b -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval BEGIN\n  for {set ii 0} {$ii < 100} {incr ii} {\n    set f [expr rand()]\n    db eval { DELETE FROM rt WHERE x1<($f*10.0) AND x1>($f*10.5) }\n  }\n  db eval COMMIT\n} \n\ndo_test rtree3-4.prep {\n  faultsim_delete_and_reopen\n  execsql {\n    BEGIN;\n    PRAGMA page_size = 512;\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n  }\n  for {set i 0} {$i < 1500} {incr i} {\n    execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }\n  }\n  execsql { COMMIT }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test rtree3-4a -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { SELECT count(*) FROM rt }\n} -test {\n  faultsim_test_result {0 1500}\n}\n\ndo_faultsim_test rtree3-4b -faults oom-transient -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { DELETE FROM rt WHERE ii BETWEEN 1 AND 100 }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test rtree3-5.prep {\n  faultsim_delete_and_reopen\n  execsql {\n    BEGIN;\n    PRAGMA page_size = 512;\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n  }\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }\n  }\n  execsql { COMMIT }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-5 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  for {set i 100} {$i < 110} {incr i} {\n    execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test rtree3-6.prep {\n  faultsim_delete_and_reopen\n  execsql {\n    BEGIN;\n    PRAGMA page_size = 512;\n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n  }\n  for {set i 0} {$i < 50} {incr i} {\n    execsql { INSERT INTO rt VALUES($i, $i, $i+1, $i, $i+1) }\n  }\n  execsql { COMMIT }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-6 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql BEGIN\n  for {set i 0} {$i < 50} {incr i} {\n    execsql { DELETE FROM rt WHERE ii=$i }\n  }\n  execsql COMMIT\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test rtree3-7.prep {\n  faultsim_delete_and_reopen\n  execsql { CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2) }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-7 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { ALTER TABLE rt RENAME TO rt2 }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test rtree3-8 -faults oom-* -prep {\n  catch { db close }\n} -body {\n  sqlite3 db test.db\n} \n\ndo_faultsim_test rtree3-9 -faults oom-* -prep {\n  sqlite3 db :memory:\n} -body {\n  set rc [register_cube_geom db]\n  if {$rc != \"SQLITE_OK\"} { error $rc }\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n}\n\ndo_test rtree3-10.prep {\n  faultsim_delete_and_reopen\n  execsql { \n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2, z1, z2);\n    INSERT INTO rt VALUES(1,  10, 10, 10, 11, 11, 11);\n    INSERT INTO rt VALUES(2,  5, 6, 6, 7, 7, 8);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-10 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  register_cube_geom db\n  execsql { SELECT * FROM rt }\n} -body {\n  execsql { SELECT ii FROM rt WHERE ii MATCH cube(4.5, 5.5, 6.5, 1, 1, 1) }\n} -test {\n  faultsim_test_result {0 2}\n}\n\n\ndo_test rtree3-11.prep {\n  faultsim_delete_and_reopen\n  execsql { \n    CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);\n    INSERT INTO rt VALUES(1, 2, 3, 4, 5);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test rtree3-10.1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM rt }\n} -body {\n  execsql { INSERT INTO rt VALUES(1, 2, 3, 4, 5) }\n} -test {\n  faultsim_test_result {1 {UNIQUE constraint failed: rt.ii}} \\\n                       {1 {constraint failed}}\n}\ndo_faultsim_test rtree3-10.2 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM rt }\n} -body {\n  execsql { INSERT INTO rt VALUES(2, 2, 3, 5, 4) }\n} -test {\n  faultsim_test_result {1 {rtree constraint failed: rt.(y1<=y2)}} \\\n                       {1 {constraint failed}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree4.test",
    "content": "# 2008 May 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Randomized test cases for the rtree extension.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\nset ::NROW 2500\nif {[info exists G(isquick)] && $G(isquick)} {\n  set ::NROW 250\n}\n\nifcapable !rtree_int_only {\n  # Return a floating point number between -X and X.\n  # \n  proc rand {X} {\n    return [expr {int((rand()-0.5)*1024.0*$X)/512.0}]\n  }\n  \n  # Return a positive floating point number less than or equal to X\n  #\n  proc randincr {X} {\n    while 1 {\n      set r [expr {int(rand()*$X*32.0)/32.0}]\n      if {$r>0.0} {return $r}\n    }\n  }\n} else {\n  # For rtree_int_only, return an number between -X and X.\n  # \n  proc rand {X} {\n    return [expr {int((rand()-0.5)*2*$X)}]\n  }\n  \n  # Return a positive integer less than or equal to X\n  #\n  proc randincr {X} {\n    while 1 {\n      set r [expr {int(rand()*$X)+1}]\n      if {$r>0} {return $r}\n    }\n  }\n}\n  \n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# Always use the same random seed so that the sequence of tests\n# is repeatable.\n#\nexpr {srand(1234)}\n\n# Run these tests for all number of dimensions between 1 and 5.\n#\nfor {set nDim 1} {$nDim<=5} {incr nDim} {\n\n  # Construct an rtree virtual table and an ordinary btree table\n  # to mirror it.  The ordinary table should be much slower (since\n  # it has to do a full table scan) but should give the exact same\n  # answers.\n  #\n  do_test rtree4-$nDim.1 {\n    set clist {}\n    set cklist {}\n    for {set i 0} {$i<$nDim} {incr i} {\n      lappend clist mn$i mx$i\n      lappend cklist \"mn$i<mx$i\"\n    }\n    db eval \"DROP TABLE IF EXISTS rx\"\n    db eval \"DROP TABLE IF EXISTS bx\"\n    db eval \"CREATE VIRTUAL TABLE rx USING rtree(id, [join $clist ,])\"\n    db eval \"CREATE TABLE bx(id INTEGER PRIMARY KEY,\\\n                [join $clist ,], CHECK( [join $cklist { AND }] ))\"\n  } {}\n\n  # Do many insertions of small objects.  Do both overlapping and\n  # contained-within queries after each insert to verify that all\n  # is well.\n  #\n  unset -nocomplain where\n  for {set i 1} {$i<$::NROW} {incr i} {\n    # Do a random insert\n    #\n    do_test rtree4-$nDim.2.$i.1 {\n      set vlist {}\n      for {set j 0} {$j<$nDim} {incr j} {\n        set mn [rand 10000]\n        set mx [expr {$mn+[randincr 50]}]\n        lappend vlist $mn $mx\n      }\n      db eval \"INSERT INTO rx VALUES(NULL, [join $vlist ,])\"\n      db eval \"INSERT INTO bx VALUES(NULL, [join $vlist ,])\"\n    } {}\n\n    # Do a contained-in query on all dimensions\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mn$j>=$mn mx$j<=$mx\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.2 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do an overlaps query on all dimensions\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mx$j>=$mn mn$j<=$mx\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.3 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do a contained-in query with surplus contraints at the beginning.\n    # This should force a full-table scan on the rtree.\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      lappend where mn$j>-10000 mx$j<10000\n    }\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mn$j>=$mn mx$j<=$mx\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.3 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do an overlaps query with surplus contraints at the beginning.\n    # This should force a full-table scan on the rtree.\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      lappend where mn$j>=-10000 mx$j<=10000\n    }\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mx$j>$mn mn$j<$mx\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.4 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do a contained-in query with surplus contraints at the end\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mn$j>=$mn mx$j<$mx\n    }\n    for {set j [expr {$nDim-1}]} {$j>=0} {incr j -1} {\n      lappend where mn$j>=-10000 mx$j<10000\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.5 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do an overlaps query with surplus contraints at the end\n    #\n    set where {}\n    for {set j [expr {$nDim-1}]} {$j>=0} {incr j -1} {\n      set mn [rand 10000]\n      set mx [expr {$mn+[randincr 500]}]\n      lappend where mx$j>$mn mn$j<=$mx\n    }\n    for {set j 0} {$j<$nDim} {incr j} {\n      lappend where mx$j>-10000 mn$j<=10000\n    }\n    set where \"WHERE [join $where { AND }]\"\n    do_test rtree4-$nDim.2.$i.6 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do a contained-in query with surplus contraints where the \n    # constraints appear in a random order.\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn1 [rand 10000]\n      set mn2 [expr {$mn1+[randincr 100]}]\n      set mx1 [expr {$mn2+[randincr 400]}]\n      set mx2 [expr {$mx1+[randincr 100]}]\n      lappend where mn$j>=$mn1 mn$j>$mn2 mx$j<$mx1 mx$j<=$mx2\n    }\n    set where \"WHERE [join [scramble $where] { AND }]\"\n    do_test rtree4-$nDim.2.$i.7 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n\n    # Do an overlaps query with surplus contraints where the\n    # constraints appear in a random order.\n    #\n    set where {}\n    for {set j 0} {$j<$nDim} {incr j} {\n      set mn1 [rand 10000]\n      set mn2 [expr {$mn1+[randincr 100]}]\n      set mx1 [expr {$mn2+[randincr 400]}]\n      set mx2 [expr {$mx1+[randincr 100]}]\n      lappend where mx$j>=$mn1 mx$j>$mn2 mn$j<$mx1 mn$j<=$mx2\n    }\n    set where \"WHERE [join [scramble $where] { AND }]\"\n    do_test rtree4-$nDim.2.$i.8 {\n      list $where [db eval \"SELECT id FROM rx $where ORDER BY id\"]\n    } [list $where [db eval \"SELECT id FROM bx $where ORDER BY id\"]]\n  }\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree5.test",
    "content": "# 2008 Jul 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the r-tree extension when it is\n# configured to store values as 32 bit integers.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\ndo_test rtree5-1.0 {\n  execsql { CREATE VIRTUAL TABLE t1 USING rtree_i32(id, x1, x2, y1, y2) }\n} {}\ndo_test rtree5-1.1 {\n  execsql { INSERT INTO t1 VALUES(1, 5, 10, 4, 11.2) }\n} {}\ndo_test rtree5-1.2 { \n  execsql { SELECT * FROM t1 }\n} {1 5 10 4 11}\ndo_test rtree5-1.3 { \n  execsql { SELECT typeof(x1) FROM t1 }\n} {integer}\n\ndo_test rtree5-1.4 { \n  execsql { SELECT x1==5 FROM t1 }\n} {1}\ndo_test rtree5-1.5 { \n  execsql { SELECT x1==5.2 FROM t1 }\n} {0}\ndo_test rtree5-1.6 { \n  execsql { SELECT x1==5.0 FROM t1 }\n} {1}\n\ndo_test rtree5-1.7 { \n  execsql { SELECT count(*) FROM t1 WHERE x1==5 }\n} {1}\nifcapable !rtree_int_only {\n  do_test rtree5-1.8 { \n    execsql { SELECT count(*) FROM t1 WHERE x1==5.2 }\n  } {0}\n}\ndo_test rtree5-1.9 { \n  execsql { SELECT count(*) FROM t1 WHERE x1==5.0 }\n} {1}\n\ndo_test rtree5-1.10 { \n  execsql { SELECT (1<<31)-5, (1<<31)-1, -1*(1<<31), -1*(1<<31)+5 }\n} {2147483643 2147483647 -2147483648 -2147483643}\ndo_test rtree5-1.11 { \n  execsql { \n    INSERT INTO t1 VALUES(2, (1<<31)-5, (1<<31)-1, -1*(1<<31), -1*(1<<31)+5) \n  }\n} {}\ndo_test rtree5-1.12 { \n  execsql { SELECT * FROM t1 WHERE id=2 }\n} {2 2147483643 2147483647 -2147483648 -2147483643}\ndo_test rtree5-1.13 { \n  execsql { \n    SELECT * FROM t1 WHERE \n        x1=2147483643 AND x2=2147483647 AND \n        y1=-2147483648 AND y2=-2147483643\n  }\n} {2 2147483643 2147483647 -2147483648 -2147483643}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree6.test",
    "content": "# 2008 Sep 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\n\nifcapable {!rtree || rtree_int_only} {\n  finish_test\n  return\n}\n\n#   Operator    Byte Value\n#   ----------------------\n#      =        0x41 ('A')\n#     <=        0x42 ('B')\n#      <        0x43 ('C')\n#     >=        0x44 ('D')\n#      >        0x45 ('E')\n#   ----------------------\n\nproc rtree_strategy {sql} {\n  set ret [list]\n  db eval \"explain $sql\" a {\n    if {$a(opcode) eq \"VFilter\"} {\n      lappend ret $a(p4)\n    }\n  }\n  set ret\n}\n\nproc query_plan {sql} {\n  set ret [list]\n  db eval \"explain query plan $sql\" a {\n    lappend ret $a(detail)\n  }\n  set ret\n}\n\ndo_test rtree6-1.1 {\n  execsql {\n    CREATE TABLE t2(k INTEGER PRIMARY KEY, v);\n    CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);\n  }\n} {}\n\ndo_test rtree6-1.2 {\n  rtree_strategy {SELECT * FROM t1 WHERE x1>10}\n} {E0}\n\ndo_test rtree6-1.3 {\n  rtree_strategy {SELECT * FROM t1 WHERE x1<10}\n} {C0}\n\ndo_test rtree6-1.4 {\n  rtree_strategy {SELECT * FROM t1,t2 WHERE k=ii AND x1<10}\n} {C0}\n\ndo_test rtree6-1.5 {\n  rtree_strategy {SELECT * FROM t1,t2 WHERE k=+ii AND x1<10}\n} {C0}\n\ndo_eqp_test rtree6.2.1 {\n  SELECT * FROM t1,t2 WHERE k=+ii AND x1<10\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0} \n  0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndo_eqp_test rtree6.2.2 {\n  SELECT * FROM t1,t2 WHERE k=ii AND x1<10\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0} \n  0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndo_eqp_test rtree6.2.3 {\n  SELECT * FROM t1,t2 WHERE k=ii\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:} \n  0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndo_eqp_test rtree6.2.4.1 {\n  SELECT * FROM t1,t2 WHERE v=+ii and x1<10 and x2>10\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0E1} \n  0 1 1 {SEARCH TABLE t2 USING AUTOMATIC COVERING INDEX (v=?)}\n}\ndo_eqp_test rtree6.2.4.2 {\n  SELECT * FROM t1,t2 WHERE v=10 and x1<10 and x2>10\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0E1} \n  0 1 1 {SEARCH TABLE t2 USING AUTOMATIC PARTIAL COVERING INDEX (v=?)}\n}\n\ndo_eqp_test rtree6.2.5 {\n  SELECT * FROM t1,t2 WHERE k=ii AND x1<v\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:} \n  0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndo_execsql_test rtree6-3.1 {\n  CREATE VIRTUAL TABLE t3 USING rtree(id, x1, x2, y1, y2);\n  INSERT INTO t3 VALUES(NULL, 1, 1, 2, 2);\n  SELECT * FROM t3 WHERE \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5;\n} {1 1.0 1.0 2.0 2.0}\n\ndo_test rtree6.3.2 {\n  rtree_strategy {\n    SELECT * FROM t3 WHERE \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 \n  }\n} {E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0}\ndo_test rtree6.3.3 {\n  rtree_strategy {\n    SELECT * FROM t3 WHERE \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n      x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5\n  }\n} {E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0E0}\n\ndo_execsql_test rtree6-3.4 {\n  SELECT * FROM t3 WHERE x1>0.5 AND x1>0.8 AND x1>1.1\n} {}\ndo_execsql_test rtree6-3.5 {\n  SELECT * FROM t3 WHERE \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND \n    x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>1.1\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree7.test",
    "content": "# 2010 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test that nothing goes wrong if an rtree table is created, then the\n# database page-size is modified. At one point (3.6.22), this was causing\n# malfunctions.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\n\nifcapable !rtree||!vacuum {\n  finish_test\n  return\n}\n\n# Like execsql except display output as integer where that can be\n# done without loss of information.\n#\nproc execsql_intout {sql} {\n  set out {}\n  foreach term [execsql $sql] {\n    regsub {\\.0$} $term {} term\n    lappend out $term\n  }\n  return $out\n}\n\ndo_test rtree7-1.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2);\n    INSERT INTO rt VALUES(1, 1, 2, 3, 4);\n  }\n} {}\ndo_test rtree7-1.2 {\n  execsql_intout { SELECT * FROM rt }\n} {1 1 2 3 4}\ndo_test rtree7-1.3 {\n  execsql_intout { \n    PRAGMA page_size = 2048;\n    VACUUM;\n    SELECT * FROM rt;\n  }\n} {1 1 2 3 4}\ndo_test rtree7-1.4 {\n  for {set i 2} {$i <= 51} {incr i} {\n    execsql { INSERT INTO rt VALUES($i, 1, 2, 3, 4) }\n  }\n  execsql_intout { SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt }\n} {51 102 153 204}\ndo_test rtree7-1.5 {\n  execsql_intout { \n    PRAGMA page_size = 512;\n    VACUUM;\n    SELECT sum(x1), sum(x2), sum(y1), sum(y2) FROM rt\n  }\n} {51 102 153 204}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree8.test",
    "content": "# 2010 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\n\n#-------------------------------------------------------------------------\n# The following block of tests - rtree8-1.* - feature reading and writing\n# an r-tree table while there exist open cursors on it.\n#\nproc populate_t1 {n} {\n  execsql { DELETE FROM t1 }\n  for {set i 1} {$i <= $n} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i, $i+2) }\n  }\n}\n\n# A DELETE while a cursor is reading the table.\n#\ndo_test rtree8-1.1.1 {\n  execsql { PRAGMA page_size = 512 }\n  execsql { CREATE VIRTUAL TABLE t1 USING rtree_i32(id, x1, x2) }\n  populate_t1 5\n} {}\ndo_test rtree8-1.1.2 {\n  set res [list]\n  db eval { SELECT * FROM t1 } { \n    lappend res $x1 $x2\n    if {$id==3} { db eval { DELETE FROM t1 WHERE id>3 } }\n  }\n  set res\n} {1 3 2 4 3 5}\ndo_test rtree8-1.1.3 {\n  execsql { SELECT * FROM t1 }\n} {1 1 3 2 2 4 3 3 5}\n\n# Many SELECTs on the same small table.\n#\nproc nested_select {n} {\n  set ::max $n\n  db eval { SELECT * FROM t1 } {\n    if {$id == $n} { nested_select [expr $n+1] }\n  }\n  return $::max\n}\ndo_test rtree8-1.2.1 { populate_t1 50  } {}\ndo_test rtree8-1.2.2 { nested_select 1 } {51}\n\n# This test runs many SELECT queries simultaneously against a large \n# table, causing a collision in the hash-table used to store r-tree \n# nodes internally.\n#\npopulate_t1 1500\ndo_execsql_test rtree8-1.3.1 { SELECT max(nodeno) FROM t1_node } {164}\ndo_test rtree8-1.3.2 {\n  set rowids [execsql {SELECT min(rowid) FROM t1_rowid GROUP BY nodeno}]\n  set stmt_list [list]\n  foreach row $rowids {\n    set stmt [sqlite3_prepare db \"SELECT * FROM t1 WHERE id = $row\" -1 tail]\n    sqlite3_step $stmt\n    lappend res_list [sqlite3_column_int $stmt 0]\n    lappend stmt_list $stmt \n  }\n} {}\ndo_test rtree8-1.3.3 { set res_list } $rowids\ndo_execsql_test rtree8-1.3.4 { SELECT count(*) FROM t1 } {1500}\ndo_test rtree8-1.3.5 { \n  foreach stmt $stmt_list { sqlite3_finalize $stmt }\n} {}\n\n\n#-------------------------------------------------------------------------\n# The following block of tests - rtree8-2.* - test a couple of database\n# corruption cases. In this case things are not corrupted at the b-tree\n# level, but the contents of the various tables used internally by an\n# r-tree table are inconsistent.\n#\npopulate_t1 50\ndo_execsql_test rtree8-2.1.1 { SELECT max(nodeno) FROM t1_node } {5}\ndo_execsql_test rtree8-2.1.2 { DELETE FROM t1_node } {}\nfor {set i 1} {$i <= 50} {incr i} {\n  do_catchsql_test rtree8-2.1.3.$i { \n    SELECT * FROM t1 WHERE id = $i \n  } {1 {database disk image is malformed}}\n}\ndo_catchsql_test rtree8-2.1.4 { \n  SELECT * FROM t1\n} {1 {database disk image is malformed}}\ndo_catchsql_test rtree8-2.1.5 { \n  DELETE FROM t1\n} {1 {database disk image is malformed}}\n\ndo_execsql_test rtree8-2.1.6 { \n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING rtree_i32(id, x1, x2);\n} {}\n\n\npopulate_t1 50\ndo_execsql_test rtree8-2.2.1 {\n  DELETE FROM t1_parent\n} {}\ndo_catchsql_test rtree8-2.2.2 {\n  DELETE FROM t1 WHERE id=25\n} {1 {database disk image is malformed}}\ndo_execsql_test rtree8-2.2.3 { \n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING rtree_i32(id, x1, x2);\n} {}\n\n\n#-------------------------------------------------------------------------\n# Test that trying to use the MATCH operator with the r-tree module does\n# not confuse it. \n#\npopulate_t1 10\ndo_catchsql_test rtree8-3.1 { \n  SELECT * FROM t1 WHERE x1 MATCH '1234'\n} {1 {SQL logic error}}\n\n#-------------------------------------------------------------------------\n# Test a couple of invalid arguments to rtreedepth().\n#\ndo_catchsql_test rtree8-4.1 {\n  SELECT rtreedepth('hello world')\n} {1 {Invalid argument to rtreedepth()}}\ndo_catchsql_test rtree8-4.2 {\n  SELECT rtreedepth(X'00')\n} {1 {Invalid argument to rtreedepth()}}\n\n\n#-------------------------------------------------------------------------\n# Delete half of a lopsided tree.\n#\ndo_execsql_test rtree8-5.1 { \n  CREATE VIRTUAL TABLE t2 USING rtree_i32(id, x1, x2) \n} {}\ndo_test rtree8-5.2 {\n  execsql BEGIN\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO t2 VALUES($i, 100, 101) }\n  }\n  for {set i 100} {$i < 200} {incr i} {\n    execsql { INSERT INTO t2 VALUES($i, 1000, 1001) }\n  }\n  execsql COMMIT\n} {}\ndo_test rtree8-5.3 {\n  execsql BEGIN\n  for {set i 0} {$i < 200} {incr i} {\n    execsql { DELETE FROM t2 WHERE id = $i }\n  }\n  execsql COMMIT\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree9.test",
    "content": "# 2010 August 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains tests for the r-tree module. Specifically, it tests\n# that custom r-tree queries (geometry callbacks) work.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\nifcapable rtree_int_only { finish_test; return }\n\nregister_cube_geom db\n\ndo_execsql_test rtree9-1.1 {\n  CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2, z1, z2);\n  INSERT INTO rt VALUES(1, 1, 2, 1, 2, 1, 2);\n} {}\ndo_execsql_test rtree9-1.2 {\n  SELECT * FROM rt WHERE id MATCH cube(0, 0, 0, 2, 2, 2);\n} {1 1.0 2.0 1.0 2.0 1.0 2.0}\ndo_execsql_test rtree9-1.3 {\n  SELECT * FROM rt WHERE id MATCH cube(3, 3, 3, 2, 2, 2);\n} {}\ndo_execsql_test rtree9-1.4 {\n  DELETE FROM rt;\n} {}\n\n\nfor {set i 0} {$i < 1000} {incr i} {\n  set x [expr $i%10]\n  set y [expr ($i/10)%10]\n  set z [expr ($i/100)%10]\n  execsql { INSERT INTO rt VALUES($i, $x, $x+1, $y, $y+1, $z, $z+1) }\n}\ndo_execsql_test rtree9-2.1 {\n  SELECT id FROM rt WHERE id MATCH cube(2.5, 2.5, 2.5, 1, 1, 1) ORDER BY id;\n} {222 223 232 233 322 323 332 333}\ndo_execsql_test rtree9-2.2 {\n  SELECT id FROM rt WHERE id MATCH cube(5.5, 5.5, 5.5, 1, 1, 1) ORDER BY id;\n} {555 556 565 566 655 656 665 666}\n\n\ndo_execsql_test rtree9-3.1 {\n  CREATE VIRTUAL TABLE rt32 USING rtree_i32(id, x1, x2, y1, y2, z1, z2);\n} {} \nfor {set i 0} {$i < 1000} {incr i} {\n  set x [expr $i%10]\n  set y [expr ($i/10)%10]\n  set z [expr ($i/100)%10]\n  execsql { INSERT INTO rt32 VALUES($i, $x, $x+1, $y, $y+1, $z, $z+1) }\n}\ndo_execsql_test rtree9-3.2 {\n  SELECT id FROM rt32 WHERE id MATCH cube(3, 3, 3, 1, 1, 1) ORDER BY id;\n} {222 223 224 232 233 234 242 243 244 322 323 324 332 333 334 342 343 344 422 423 424 432 433 434 442 443 444}\ndo_execsql_test rtree9-3.3 {\n  SELECT id FROM rt32 WHERE id MATCH cube(5.5, 5.5, 5.5, 1, 1, 1) ORDER BY id;\n} {555 556 565 566 655 656 665 666}\n\n\ndo_catchsql_test rtree9-4.1 {\n  SELECT id FROM rt32 WHERE id MATCH cube(5.5, 5.5, 1, 1, 1) ORDER BY id;\n} {1 {SQL logic error}}\nfor {set x 2} {$x<200} {incr x 2} {\n  do_catchsql_test rtree9-4.2.[expr $x/2] {\n    SELECT id FROM rt WHERE id MATCH randomblob($x)\n  } {1 {SQL logic error}}\n}\ndo_catchsql_test rtree9-4.3 {\n  SELECT id FROM rt WHERE id MATCH CAST( \n    (cube(5.5, 5.5, 5.5, 1, 1, 1) || X'1234567812345678') AS blob \n  )\n} {1 {SQL logic error}}\n\n\n#-------------------------------------------------------------------------\n# Test the example 2d \"circle\" geometry callback.\n#\nregister_circle_geom db\n\ndo_execsql_test rtree9-5.1 {\n  CREATE VIRTUAL TABLE rt2 USING rtree(id, xmin, xmax, ymin, ymax);\n\n  INSERT INTO rt2 VALUES(1,    1,   2,  1,  2);\n  INSERT INTO rt2 VALUES(2,    1,   2, -2, -1);\n  INSERT INTO rt2 VALUES(3,    -2, -1, -2, -1);\n  INSERT INTO rt2 VALUES(4,    -2, -1,  1,  2);\n\n  INSERT INTO rt2 VALUES(5,    2,   3,  2,  3);\n  INSERT INTO rt2 VALUES(6,    2,   3, -3, -2);\n  INSERT INTO rt2 VALUES(7,    -3, -2, -3, -2);\n  INSERT INTO rt2 VALUES(8,    -3, -2,  2,  3);\n\n  INSERT INTO rt2 VALUES(9,    1.8,   3,  1.8,  3);\n  INSERT INTO rt2 VALUES(10,   1.8,   3, -3, -1.8);\n  INSERT INTO rt2 VALUES(11,   -3, -1.8, -3, -1.8);\n  INSERT INTO rt2 VALUES(12,   -3, -1.8,  1.8,  3);\n\n  INSERT INTO rt2 VALUES(13,   -15, 15, 1.8, 2.2);\n  INSERT INTO rt2 VALUES(14,   -15, 15, -2.2, -1.8);\n  INSERT INTO rt2 VALUES(15,   1.8, 2.2, -15, 15);\n  INSERT INTO rt2 VALUES(16,   -2.2, -1.8, -15, 15);\n\n  INSERT INTO rt2 VALUES(17,   -100, 100, -100, 100);\n} {}\n\ndo_execsql_test rtree9-5.2 {\n  SELECT id FROM rt2 WHERE id MATCH circle(0.0, 0.0, 2.0);\n} {1 2 3 4 13 14 15 16 17}\n\ndo_execsql_test rtree9-5.3 {\n  UPDATE rt2 SET xmin=xmin+5, ymin=ymin+5, xmax=xmax+5, ymax=ymax+5;\n  SELECT id FROM rt2 WHERE id MATCH circle(5.0, 5.0, 2.0);\n} {1 2 3 4 13 14 15 16 17}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeA.test",
    "content": "# 2010 September 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains tests for the r-tree module. Specifically, it tests\n# that corrupt or inconsistent databases do not cause crashes in the r-tree\n# module.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\n\nproc create_t1 {} {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2);\n  }\n}\nproc populate_t1 {} {\n  execsql BEGIN\n  for {set i 0} {$i < 500} {incr i} {\n    set x2 [expr $i+5]\n    set y2 [expr $i+5]\n    execsql { INSERT INTO t1 VALUES($i, $i, $x2, $i, $y2) }\n  }\n  execsql COMMIT\n}\n\nproc truncate_node {nodeno nTrunc} {\n  set blob [db one {SELECT data FROM t1_node WHERE nodeno=$nodeno}]\n  if {$nTrunc<0} {set nTrunc \"end-$nTrunc\"}\n  set blob [string range $blob 0 $nTrunc]\n  db eval { UPDATE t1_node SET data = $blob WHERE nodeno=$nodeno }\n}\n\nproc set_tree_depth {tbl {newvalue \"\"}} {\n  set blob [db one \"SELECT data FROM ${tbl}_node WHERE nodeno=1\"]\n\n  if {$newvalue == \"\"} {\n    binary scan $blob Su oldvalue\n    return $oldvalue\n  }\n\n  set blob [binary format Sua* $newvalue [string range $blob 2 end]]\n  db eval \"UPDATE ${tbl}_node SET data = \\$blob WHERE nodeno=1\"\n  return [set_tree_depth $tbl]\n}\n\nproc set_entry_count {tbl nodeno {newvalue \"\"}} {\n  set blob [db one \"SELECT data FROM ${tbl}_node WHERE nodeno=$nodeno\"]\n\n  if {$newvalue == \"\"} {\n    binary scan [string range $blob 2 end] Su oldvalue\n    return $oldvalue\n  }\n\n  set blob [binary format a*Sua* \\\n    [string range $blob 0 1] $newvalue [string range $blob 4 end]\n  ]\n  db eval \"UPDATE ${tbl}_node SET data = \\$blob WHERE nodeno=$nodeno\"\n  return [set_entry_count $tbl $nodeno]\n}\n\n\nproc do_corruption_tests {prefix args} {\n  set testarray [lindex $args end]\n  set errormsg {database disk image is malformed}\n\n  foreach {z value} [lrange $args 0 end-1] {\n    set n [string length $z]\n    if {$n>=2 && [string equal -length $n $z \"-error\"]} {\n      set errormsg $value\n    }\n  }\n\n  foreach {tn sql} $testarray {\n    do_catchsql_test $prefix.$tn $sql [list 1 $errormsg]\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test the libraries response if the %_node table is completely empty\n# (i.e. the root node is missing), or has been removed from the database\n# entirely.\n#\ncreate_t1\npopulate_t1\ndo_execsql_test rtreeA-1.0 {\n  DELETE FROM t1_node;\n} {}\n\ndo_corruption_tests rtreeA-1.1 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n  4   \"SELECT * FROM t1 WHERE x1<10 AND x2>12\"\n}\n\ndo_execsql_test  rtreeA-1.2.0 { DROP TABLE t1_node } {}\ndo_corruption_tests rtreeA-1.2 -error \"database disk image is malformed\" {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n  4   \"SELECT * FROM t1 WHERE x1<10 AND x2>12\"\n}\n\n#-------------------------------------------------------------------------\n# Test the libraries response if some of the entries in the %_node table \n# are the wrong size.\n#\ncreate_t1\npopulate_t1\ndo_test rtreeA-2.1.0 {\n  set nodes [db eval {select nodeno FROM t1_node}]\n  foreach {a b c} $nodes { truncate_node $c 200 }\n} {}\ndo_corruption_tests rtreeA-2.1 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n  4   \"SELECT * FROM t1 WHERE x1<10 AND x2>12\"\n}\n\ncreate_t1\npopulate_t1\ndo_test rtreeA-2.2.0 { truncate_node 1 200 } {}\ndo_corruption_tests rtreeA-2.2 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n  4   \"SELECT * FROM t1 WHERE x1<10 AND x2>12\"\n}\n\n#-------------------------------------------------------------------------\n# Set the \"depth\" of the tree stored on the root node incorrectly. Test\n# that this does not cause any problems.\n#\ncreate_t1\npopulate_t1\ndo_test rtreeA-3.1.0.1 { set_tree_depth t1 } {1}\ndo_test rtreeA-3.1.0.2 { set_tree_depth t1 3 } {3}\ndo_corruption_tests rtreeA-3.1 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n}\n\ndo_test rtreeA-3.2.0 { set_tree_depth t1 1000 } {1000}\ndo_corruption_tests rtreeA-3.2 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n}\n\ncreate_t1\npopulate_t1\ndo_test rtreeA-3.3.0 { \n  execsql { DELETE FROM t1 WHERE rowid = 0 }\n  set_tree_depth t1 65535\n} {65535}\ndo_corruption_tests rtreeA-3.3 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n}\n\n#-------------------------------------------------------------------------\n# Set the \"number of entries\" field on some nodes incorrectly.\n#\ncreate_t1\npopulate_t1\ndo_test rtreeA-4.1.0 { \n  set_entry_count t1 1 4000\n} {4000}\ndo_corruption_tests rtreeA-4.1 {\n  1   \"SELECT * FROM t1\"\n  2   \"SELECT * FROM t1 WHERE rowid=5\"\n  3   \"INSERT INTO t1 VALUES(1000, 1, 2, 3, 4)\"\n  4   \"SELECT * FROM t1 WHERE x1<10 AND x2>12\"\n}\n\n#-------------------------------------------------------------------------\n# Remove entries from the %_parent table and check that this does not\n# cause a crash.\n#\ncreate_t1\npopulate_t1\ndo_execsql_test rtreeA-5.1.0 { DELETE FROM t1_parent } {}\ndo_corruption_tests rtreeA-5.1 {\n  1   \"DELETE FROM t1 WHERE rowid = 5\"\n  2   \"DELETE FROM t1\"\n}\n\n#-------------------------------------------------------------------------\n# Add some bad entries to the %_parent table.\n#\ncreate_t1\npopulate_t1\ndo_execsql_test rtreeA-6.1.0 { \n  UPDATE t1_parent set parentnode = parentnode+1\n} {}\ndo_corruption_tests rtreeA-6.1 {\n  1   \"DELETE FROM t1 WHERE rowid = 5\"\n  2   \"UPDATE t1 SET x1=x1+1, x2=x2+1\"\n}\n\n#-------------------------------------------------------------------------\n# Truncated blobs in the _node table.\n#\ncreate_t1\npopulate_t1\nsqlite3 db test.db\ndo_execsql_test rtreeA-7.100 { \n  UPDATE t1_node SET data=x'' WHERE rowid=1;\n} {}\ndo_catchsql_test rtreeA-7.110 {\n  SELECT * FROM t1 WHERE x1>0 AND x1<100 AND x2>0 AND x2<100;\n} {1 {undersize RTree blobs in \"t1_node\"}}\ndo_test rtreeA-7.120 {\n  sqlite3_extended_errcode db\n} {SQLITE_CORRUPT_VTAB}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeB.test",
    "content": "# 2011 March 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Make sure the rtreenode() testing function can handle entries with\n# 64-bit rowids.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\n\nifcapable rtree_int_only {\n  do_test rtreeB-1.1-intonly {\n    db eval {\n      CREATE VIRTUAL TABLE t1 USING rtree(ii, x0, y0, x1, y1);\n      INSERT INTO t1 VALUES(1073741824, 0.0, 0.0, 100.0, 100.0);\n      INSERT INTO t1 VALUES(2147483646, 0.0, 0.0, 200.0, 200.0);\n      INSERT INTO t1 VALUES(4294967296, 0.0, 0.0, 300.0, 300.0);\n      INSERT INTO t1 VALUES(8589934592, 20.0, 20.0, 150.0, 150.0);\n      INSERT INTO t1 VALUES(9223372036854775807, 150, 150, 400, 400);\n      SELECT rtreenode(2, data) FROM t1_node;\n    }\n  } {{{1073741824 0 0 100 100} {2147483646 0 0 200 200} {4294967296 0 0 300 300} {8589934592 20 20 150 150} {9223372036854775807 150 150 400 400}}}\n} else {  \n  do_test rtreeB-1.1 {\n    db eval {\n      CREATE VIRTUAL TABLE t1 USING rtree(ii, x0, y0, x1, y1);\n      INSERT INTO t1 VALUES(1073741824, 0.0, 0.0, 100.0, 100.0);\n      INSERT INTO t1 VALUES(2147483646, 0.0, 0.0, 200.0, 200.0);\n      INSERT INTO t1 VALUES(4294967296, 0.0, 0.0, 300.0, 300.0);\n      INSERT INTO t1 VALUES(8589934592, 20.0, 20.0, 150.0, 150.0);\n      INSERT INTO t1 VALUES(9223372036854775807, 150, 150, 400, 400);\n      SELECT rtreenode(2, data) FROM t1_node;\n    }\n  } {{{1073741824 0 0 100 100} {2147483646 0 0 200 200} {4294967296 0 0 300 300} {8589934592 20 20 150 150} {9223372036854775807 150 150 400 400}}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeC.test",
    "content": "# 2011 March 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Make sure the rtreenode() testing function can handle entries with\n# 64-bit rowids.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\nset testprefix rtreeC\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE r_tree USING rtree(id, min_x, max_x, min_y, max_y);\n  CREATE TABLE t(x, y);\n}\n\ndo_eqp_test 1.1 {\n  SELECT * FROM r_tree, t \n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND t.x<=max_y\n} {\n  0 0 1 {SCAN TABLE t}\n  0 1 0 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 1.2 {\n  SELECT * FROM t, r_tree\n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND t.x<=max_y\n} {\n  0 0 0 {SCAN TABLE t}\n  0 1 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 1.3 {\n  SELECT * FROM t, r_tree\n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND ?<=max_y\n} {\n  0 0 0 {SCAN TABLE t}\n  0 1 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 1.5 {\n  SELECT * FROM t, r_tree\n} {\n  0 0 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:}\n  0 1 0 {SCAN TABLE t} \n}\n\ndo_execsql_test 2.0 {\n  INSERT INTO t VALUES(0, 0);\n  INSERT INTO t VALUES(0, 1);\n  INSERT INTO t VALUES(0, 2);\n  INSERT INTO t VALUES(0, 3);\n  INSERT INTO t VALUES(0, 4);\n  INSERT INTO t VALUES(0, 5);\n  INSERT INTO t VALUES(0, 6);\n  INSERT INTO t VALUES(0, 7);\n  INSERT INTO t VALUES(0, 8);\n  INSERT INTO t VALUES(0, 9);\n\n  INSERT INTO t SELECT x+1, y FROM t;\n  INSERT INTO t SELECT x+2, y FROM t;\n  INSERT INTO t SELECT x+4, y FROM t;\n  INSERT INTO r_tree SELECT NULL, x-1, x+1, y-1, y+1 FROM t;\n  ANALYZE;\n}\n\ndb close\nsqlite3 db test.db\n\ndo_eqp_test 2.1 {\n  SELECT * FROM r_tree, t \n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND t.x<=max_y\n} {\n  0 0 1 {SCAN TABLE t}\n  0 1 0 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 2.2 {\n  SELECT * FROM t, r_tree\n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND t.x<=max_y\n} {\n  0 0 0 {SCAN TABLE t}\n  0 1 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 2.3 {\n  SELECT * FROM t, r_tree\n  WHERE t.x>=min_x AND t.x<=max_x AND t.y>=min_y AND ?<=max_y\n} {\n  0 0 0 {SCAN TABLE t}\n  0 1 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:D3B2D1B0}\n}\n\ndo_eqp_test 2.5 {\n  SELECT * FROM t, r_tree\n} {\n  0 0 1 {SCAN TABLE r_tree VIRTUAL TABLE INDEX 2:}\n  0 1 0 {SCAN TABLE t} \n}\n\n#-------------------------------------------------------------------------\n# Test that the special CROSS JOIN handling works with rtree tables.\n#\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(y);\n  CREATE VIRTUAL TABLE t3 USING rtree(z, x1,x2, y1,y2);\n}\n\ndo_eqp_test 3.2.1 { SELECT * FROM t1 CROSS JOIN t2 } {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SCAN TABLE t2}\n}\ndo_eqp_test 3.2.2 { SELECT * FROM t2 CROSS JOIN t1 } {\n  0 0 0 {SCAN TABLE t2} 0 1 1 {SCAN TABLE t1}\n}\n\ndo_eqp_test 3.3.1 { SELECT * FROM t1 CROSS JOIN t3 } {\n  0 0 0 {SCAN TABLE t1}\n  0 1 1 {SCAN TABLE t3 VIRTUAL TABLE INDEX 2:} \n}\ndo_eqp_test 3.3.2 { SELECT * FROM t3 CROSS JOIN t1 } {\n  0 0 0 {SCAN TABLE t3 VIRTUAL TABLE INDEX 2:} \n  0 1 1 {SCAN TABLE t1}\n}\n\n#--------------------------------------------------------------------\n# Test that LEFT JOINs are not reordered if the right-hand-side is\n# a virtual table.\n#\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE t1(a);\n  CREATE VIRTUAL TABLE t2 USING rtree(b, x1,x2);\n\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n\n  INSERT INTO t2 VALUES(1, 0.0, 0.1);\n  INSERT INTO t2 VALUES(3, 0.0, 0.1);\n}\n\ndo_execsql_test 4.2 {\n  SELECT a, b FROM t1 LEFT JOIN t2 ON (+a = +b);\n} {1 1 2 {}}\n\ndo_execsql_test 4.3 {\n  SELECT b, a FROM t2 LEFT JOIN t1 ON (+a = +b);\n} {1 1 3 {}}\n\n#--------------------------------------------------------------------\n# Test that the sqlite_stat1 data is used correctly.\n#\nreset_db\ndo_execsql_test 5.1 {\n  CREATE TABLE t1(x PRIMARY KEY, y);\n  CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);\n\n  INSERT INTO t1(x) VALUES(1);\n  INSERT INTO t1(x) SELECT x+1 FROM t1;   --   2\n  INSERT INTO t1(x) SELECT x+2 FROM t1;   --   4\n  INSERT INTO t1(x) SELECT x+4 FROM t1;   --   8\n  INSERT INTO t1(x) SELECT x+8 FROM t1;   --  16\n  INSERT INTO t1(x) SELECT x+16 FROM t1;  --  32\n  INSERT INTO t1(x) SELECT x+32 FROM t1;  --  64\n  INSERT INTO t1(x) SELECT x+64 FROM t1;  -- 128\n  INSERT INTO t1(x) SELECT x+128 FROM t1; -- 256\n  INSERT INTO t1(x) SELECT x+256 FROM t1; -- 512\n  INSERT INTO t1(x) SELECT x+512 FROM t1; --1024\n\n  INSERT INTO rt SELECT x, x, x+1 FROM t1 WHERE x<=5;\n}\n\n# First test a query with no ANALYZE data at all. The outer loop is\n# real table \"t1\".\n#\ndo_eqp_test 5.2 {\n  SELECT * FROM t1, rt WHERE x==id;\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 1:}\n}\n\n# Now create enough ANALYZE data to tell SQLite that virtual table \"rt\"\n# contains very few rows. This causes it to move \"rt\" to the outer loop.\n#\ndo_execsql_test 5.3 {\n  ANALYZE;\n  DELETE FROM sqlite_stat1 WHERE tbl='t1';\n}\ndb close\nsqlite3 db test.db\ndo_eqp_test 5.4 {\n  SELECT * FROM t1, rt WHERE x==id;\n} {\n  0 0 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 2:} \n  0 1 0 {SEARCH TABLE t1 USING INDEX sqlite_autoindex_t1_1 (x=?)}\n}\n\n# Delete the ANALYZE data. \"t1\" should be the outer loop again.\n#\ndo_execsql_test 5.5 { DROP TABLE sqlite_stat1; }\ndb close\nsqlite3 db test.db\ndo_eqp_test 5.6 {\n  SELECT * FROM t1, rt WHERE x==id;\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 1:}\n}\n\n# This time create and attach a database that contains ANALYZE data for\n# tables of the same names as those used internally by virtual table\n# \"rt\". Check that the rtree module is not fooled into using this data.\n# Table \"t1\" should remain the outer loop.\n#\ndo_test 5.7 {\n  db backup test.db2\n  sqlite3 db2 test.db2\n  db2 eval {\n    ANALYZE;\n    DELETE FROM sqlite_stat1 WHERE tbl='t1';\n  }\n  db2 close\n  db close\n  sqlite3 db test.db\n  execsql { ATTACH 'test.db2' AS aux; }\n} {}\ndo_eqp_test 5.8 {\n  SELECT * FROM t1, rt WHERE x==id;\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 1:}\n}\n\n#--------------------------------------------------------------------\n# Test that having a second connection drop the sqlite_stat1 table\n# before it is required by rtreeConnect() does not cause problems.\n#\nifcapable rtree {\n  reset_db\n  do_execsql_test 6.1 {\n    CREATE TABLE t1(x);\n    CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO rt VALUES(1,2,3);\n    ANALYZE;\n  }\n  db close\n  sqlite3 db test.db\n  do_execsql_test 6.2 { SELECT * FROM t1 } {1}\n  \n  do_test 6.3 {\n    sqlite3 db2 test.db\n    db2 eval { DROP TABLE sqlite_stat1 }\n    db2 close\n    execsql { SELECT * FROM rt }\n  } {1 2.0 3.0}\n  db close\n}\n\n#--------------------------------------------------------------------\n# Test that queries featuring LEFT or CROSS JOINS are handled correctly.\n# Handled correctly in this case means:\n#\n#   * Terms with prereqs that appear to the left of a LEFT JOIN against\n#     the virtual table are always available to xBestIndex.\n#\n#   * Terms with prereqs that appear to the right of a LEFT JOIN against\n#     the virtual table are never available to xBestIndex.\n#\n# And the same behaviour for CROSS joins.\n#\nreset_db\ndo_execsql_test 7.0 {\n  CREATE TABLE xdir(x1);\n  CREATE TABLE ydir(y1);\n  CREATE VIRTUAL TABLE rt USING rtree_i32(id, xmin, xmax, ymin, ymax);\n\n  INSERT INTO xdir VALUES(5);\n  INSERT INTO ydir VALUES(10);\n\n  INSERT INTO rt VALUES(1, 2, 7, 12, 14);      -- Not a hit\n  INSERT INTO rt VALUES(2, 2, 7, 8, 12);       -- A hit!\n  INSERT INTO rt VALUES(3, 7, 11, 8, 12);      -- Not a hit!\n  INSERT INTO rt VALUES(4, 5, 5, 10, 10);      -- A hit!\n\n}\n\nproc do_eqp_execsql_test {tn sql res} {\n  set query \"EXPLAIN QUERY PLAN $sql ; $sql \"\n  uplevel [list do_execsql_test $tn $query $res]\n}\n\ndo_eqp_execsql_test 7.1 {\n  SELECT id FROM xdir, rt, ydir \n  ON (y1 BETWEEN ymin AND ymax)\n  WHERE (x1 BETWEEN xmin AND xmax);\n} {\n  0 0 0 {SCAN TABLE xdir} \n  0 1 2 {SCAN TABLE ydir} \n  0 2 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 2:B2D3B0D1}\n  2 4\n}\n\ndo_eqp_execsql_test 7.2 {\n  SELECT * FROM xdir, rt LEFT JOIN ydir \n  ON (y1 BETWEEN ymin AND ymax)\n  WHERE (x1 BETWEEN xmin AND xmax);\n} {\n  0 0 0 {SCAN TABLE xdir} \n  0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 2:B0D1}\n  0 2 2 {SCAN TABLE ydir} \n\n  5 1 2 7 12 14 {}\n  5 2 2 7  8 12 10\n  5 4 5 5 10 10 10\n}\n\ndo_eqp_execsql_test 7.3 {\n  SELECT id FROM xdir, rt CROSS JOIN ydir \n  ON (y1 BETWEEN ymin AND ymax)\n  WHERE (x1 BETWEEN xmin AND xmax);\n} {\n  0 0 0 {SCAN TABLE xdir} \n  0 1 1 {SCAN TABLE rt VIRTUAL TABLE INDEX 2:B0D1}\n  0 2 2 {SCAN TABLE ydir} \n  2 4\n}\n\ndo_eqp_execsql_test 7.4 {\n  SELECT id FROM rt, xdir CROSS JOIN ydir \n  ON (y1 BETWEEN ymin AND ymax)\n  WHERE (x1 BETWEEN xmin AND xmax);\n} {\n  0 0 1 {SCAN TABLE xdir} \n  0 1 0 {SCAN TABLE rt VIRTUAL TABLE INDEX 2:B0D1}\n  0 2 2 {SCAN TABLE ydir} \n  2 4\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeD.test",
    "content": "# 2014 March 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Miscellaneous tests for errors in the rtree constructor.\n#\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] rtree_util.tcl]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nifcapable !rtree||!builtin_test {\n  finish_test\n  return\n}\nset testprefix rtreeD\n\n#-------------------------------------------------------------------------\n# Test that if an SQLITE_BUSY is encountered within the vtable \n# constructor, a relevant error message is returned.\n#\ndo_multiclient_test tn {\n  do_test 1.$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1,2);\n      CREATE VIRTUAL TABLE rt USING rtree(id, minx, maxx, miny, maxy);\n      INSERT INTO rt VALUES(1,2,3,4,5);\n    }\n  } {}\n\n  do_test 1.$tn.2 {\n    sql2 { SELECT * FROM t1; }\n  } {1 2}\n\n  do_test 1.$tn.3 {\n    sql1 { BEGIN EXCLUSIVE; INSERT INTO t1 VALUES(3, 4); }\n  } {}\n\n  do_test 1.$tn.4 {\n    list [catch { sql2 { SELECT * FROM rt } } msg] $msg\n  } {1 {database is locked}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeE.test",
    "content": "# 2010 August 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains tests for the r-tree module. Specifically, it tests\n# that new-style custom r-tree queries (geometry callbacks) work.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\nifcapable rtree_int_only { finish_test; return }\n\n\n#-------------------------------------------------------------------------\n# Test the example 2d \"circle\" geometry callback.\n#\nregister_circle_geom db\n\ndo_execsql_test rtreeE-1.1 {\n  PRAGMA page_size=512;\n  CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1);\n  \n  /* A tight pattern of small boxes near 0,0 */\n  WITH RECURSIVE\n    x(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM x WHERE x<4),\n    y(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM y WHERE y<4)\n  INSERT INTO rt1 SELECT x+5*y, x, x+2, y, y+2 FROM x, y;\n\n  /* A looser pattern of small boxes near 100, 0 */\n  WITH RECURSIVE\n    x(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM x WHERE x<4),\n    y(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM y WHERE y<4)\n  INSERT INTO rt1 SELECT 100+x+5*y, x*3+100, x*3+102, y*3, y*3+2 FROM x, y;\n\n  /* A looser pattern of larger boxes near 0, 200 */\n  WITH RECURSIVE\n    x(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM x WHERE x<4),\n    y(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM y WHERE y<4)\n  INSERT INTO rt1 SELECT 200+x+5*y, x*7, x*7+15, y*7+200, y*7+215 FROM x, y;\n} {}\n\n# Queries against each of the three clusters */\ndo_execsql_test rtreeE-1.1 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle(0.0, 0.0, 50.0, 3) ORDER BY id;\n} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24}\ndo_execsql_test rtreeE-1.1x {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle('x:0 y:0 r:50.0 e:3') ORDER BY id;\n} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24}\ndo_execsql_test rtreeE-1.2 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle(100.0, 0.0, 50.0, 3) ORDER BY id;\n} {100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124}\ndo_execsql_test rtreeE-1.3 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle(0.0, 200.0, 50.0, 3) ORDER BY id;\n} {200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224}\n\n# The Qcircle geometry function gives a lower score to larger leaf-nodes.\n# This causes the 200s to sort before the 100s and the 0s to sort before\n# last.\n#\ndo_execsql_test rtreeE-1.4 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle('r:1000 e:3') AND id%100==0\n} {200 100 0}\n\n# Exclude odd rowids on a depth-first search\ndo_execsql_test rtreeE-1.5 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle('r:1000 e:4') ORDER BY +id\n} {0 2 4 6 8 10 12 14 16 18 20 22 24 100 102 104 106 108 110 112 114 116 118 120 122 124 200 202 204 206 208 210 212 214 216 218 220 222 224}\n\n# Exclude odd rowids on a breadth-first search.\ndo_execsql_test rtreeE-1.6 {\n  SELECT id FROM rt1 WHERE id MATCH Qcircle(0,0,1000,5) ORDER BY +id\n} {0 2 4 6 8 10 12 14 16 18 20 22 24 100 102 104 106 108 110 112 114 116 118 120 122 124 200 202 204 206 208 210 212 214 216 218 220 222 224}\n\n# Test that rtree prefers MATCH to lookup-by-rowid.\n#\ndo_execsql_test rtreeE-1.7 {\n  SELECT id FROM rt1 WHERE id=18 AND id MATCH Qcircle(0,0,1000,5)\n} {18}\n\n\n# Construct a large 2-D RTree with thousands of random entries.\n#\ndo_test rtreeE-2.1 {\n  db eval {\n    CREATE TABLE t2(id,x0,x1,y0,y1);\n    CREATE VIRTUAL TABLE rt2 USING rtree(id,x0,x1,y0,y1);\n    BEGIN;\n  }\n  expr srand(0)\n  for {set i 1} {$i<=10000} {incr i} {\n    set dx [expr {int(rand()*40)+1}]\n    set dy [expr {int(rand()*40)+1}]\n    set x0 [expr {int(rand()*(10000 - $dx))}]\n    set x1 [expr {$x0+$dx}]\n    set y0 [expr {int(rand()*(10000 - $dy))}]\n    set y1 [expr {$y0+$dy}]\n    set id [expr {$i+10000}]\n    db eval {INSERT INTO t2 VALUES($id,$x0,$x1,$y0,$y1)}\n  }\n  db eval {\n    INSERT INTO rt2 SELECT * FROM t2;\n    COMMIT;\n  }\n} {}\n\nfor {set i 1} {$i<=200} {incr i} {\n  set dx [expr {int(rand()*100)}]\n  set dy [expr {int(rand()*100)}]\n  set x0 [expr {int(rand()*(10000 - $dx))}]\n  set x1 [expr {$x0+$dx}]\n  set y0 [expr {int(rand()*(10000 - $dy))}]\n  set y1 [expr {$y0+$dy}]\n  set ans [db eval {SELECT id FROM t2 WHERE x1>=$x0 AND x0<=$x1 AND y1>=$y0 AND y0<=$y1 ORDER BY id}]\n  do_execsql_test rtreeE-2.2.$i {\n    SELECT id FROM rt2 WHERE id MATCH breadthfirstsearch($x0,$x1,$y0,$y1) ORDER BY id\n  } $ans\n}\n\n# Run query that have very deep priority queues\n#\nset ans [db eval {SELECT id FROM t2 WHERE x1>=0 AND x0<=5000 AND y1>=0 AND y0<=5000 ORDER BY id}]\ndo_execsql_test rtreeE-2.3 {\n  SELECT id FROM rt2 WHERE id MATCH breadthfirstsearch(0,5000,0,5000) ORDER BY id\n} $ans\nset ans [db eval {SELECT id FROM t2 WHERE x1>=0 AND x0<=10000 AND y1>=0 AND y0<=10000 ORDER BY id}]\ndo_execsql_test rtreeE-2.4 {\n  SELECT id FROM rt2 WHERE id MATCH breadthfirstsearch(0,10000,0,10000) ORDER BY id\n} $ans\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeF.test",
    "content": "# 2014-08-21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains tests for the r-tree module.\n#\n# This file contains test cases for the ticket\n# [369d57fb8e5ccdff06f197a37147a88f9de95cda] (2014-08-21)\n#\n#  The following SQL causes an assertion fault while running\n#  sqlite3_prepare() on the DELETE statement:\n#\n#     CREATE TABLE t1(x);\n#     CREATE TABLE t2(y);\n#     CREATE VIRTUAL TABLE t3 USING rtree(a,b,c);\n#     CREATE TRIGGER t2del AFTER DELETE ON t2 WHEN (SELECT 1 from t1) BEGIN \n#       DELETE FROM t3 WHERE a=old.y; \n#     END;\n#     DELETE FROM t2 WHERE y=1;\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\n\ndo_execsql_test rtreeF-1.1 {\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(y);\n  CREATE VIRTUAL TABLE t3 USING rtree(a,b,c);\n  CREATE TRIGGER t2dwl AFTER DELETE ON t2 WHEN (SELECT 1 from t1) BEGIN \n    DELETE FROM t3 WHERE a=old.y; \n  END;\n\n  INSERT INTO t1(x) VALUES(999);\n  INSERT INTO t2(y) VALUES(1),(2),(3),(4),(5);\n  INSERT INTO t3(a,b,c) VALUES(1,2,3),(2,3,4),(3,4,5),(4,5,6),(5,6,7);\n\n  SELECT a FROM t3 ORDER BY a;\n  SELECT '|';\n  SELECT y FROM t2 ORDER BY y;\n} {1 2 3 4 5 | 1 2 3 4 5}\ndo_execsql_test rtreeF-1.2 {\n  DELETE FROM t2 WHERE y=3;\n\n  SELECT a FROM t3 ORDER BY a;\n  SELECT '|';\n  SELECT y FROM t2 ORDER BY y;\n} {1 2 4 5 | 1 2 4 5}\ndo_execsql_test rtreeF-1.3 {\n  DELETE FROM t1;\n  DELETE FROM t2 WHERE y=5;\n\n  SELECT a FROM t3 ORDER BY a;\n  SELECT '|';\n  SELECT y FROM t2 ORDER BY y;\n} {1 2 4 5 | 1 2 4}\ndo_execsql_test rtreeF-1.4 {\n  INSERT INTO t1 DEFAULT VALUES;\n  DELETE FROM t2 WHERE y=5;\n\n  SELECT a FROM t3 ORDER BY a;\n  SELECT '|';\n  SELECT y FROM t2 ORDER BY y;\n} {1 2 4 5 | 1 2 4}\ndo_execsql_test rtreeF-1.5 {\n  DELETE FROM t2 WHERE y=2;\n\n  SELECT a FROM t3 ORDER BY a;\n  SELECT '|';\n  SELECT y FROM t2 ORDER BY y;\n} {1 4 5 | 1 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeG.test",
    "content": "# 2016-05-32\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains tests for the r-tree module.\n#\n# Verify that no invalid SQL is run during initialization\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nifcapable !rtree { finish_test ; return }\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log [list lappend ::log]\nset ::log [list]\nsqlite3 db test.db\n\n\nset ::log {}\ndo_execsql_test rtreeG-1.1 {\n  CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1);\n} {}\ndo_test rtreeG-1.1log {\n  set ::log\n} {}\n\ndo_execsql_test rtreeG-1.2 {\n  INSERT INTO t1 VALUES(1,10,15,5,23),(2,20,21,5,23),(3,10,15,20,30);\n  SELECT id from t1 WHERE x0>8 AND x1<16 AND y0>2 AND y1<25;\n} {1}\ndo_test rtreeG-1.2log {\n  set ::log\n} {}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test rtreeG-1.3 {\n  SELECT id from t1 WHERE x0>8 AND x1<16 AND y0>2 AND y1<25;\n} {1}\ndo_test rtreeG-1.3log {\n  set ::log\n} {}\n\ndo_execsql_test rtreeG-1.4 {\n  DROP TABLE t1;\n} {}\ndo_test rtreeG-1.4log {\n  set ::log\n} {}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log\nsqlite3_initialize\nsqlite3 db test.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree_perf.tcl",
    "content": "\nset testdir [file join [file dirname $argv0] .. .. test]\nsource $testdir/tester.tcl\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\nset NROW   10000\nset NQUERY   500\n\nputs \"Generating $NROW rows of data...\"\nset data [list]\nfor {set ii 0} {$ii < $NROW} {incr ii} {\n  set x1 [expr {rand()*1000}]\n  set x2 [expr {$x1+rand()*50}]\n  set y1 [expr {rand()*1000}]\n  set y2 [expr {$y1+rand()*50}]\n  lappend data $x1 $x2 $y1 $y2\n}\nputs \"Finished generating data\"\n\n\nset sql1 {CREATE TABLE btree(ii INTEGER PRIMARY KEY, x1, x2, y1, y2)}\nset sql2 {CREATE VIRTUAL TABLE rtree USING rtree(ii, x1, x2, y1, y2)}\nputs \"Creating tables:\"\nputs \"  $sql1\"\nputs \"  $sql2\"\ndb eval $sql1\ndb eval $sql2\n\ndb eval \"pragma cache_size=100\"\n\nputs -nonewline \"Inserting into btree... \"\nflush stdout\nset btree_time [time {db transaction {\n  set ii 1\n  foreach {x1 x2 y1 y2} $data {\n    db eval {INSERT INTO btree VALUES($ii, $x1, $x2, $y1, $y2)}\n    incr ii\n  }\n}}]\nputs \"$btree_time\"\n\nputs -nonewline \"Inserting into rtree... \"\nflush stdout\nset rtree_time [time {db transaction {\n  set ii 1\n  foreach {x1 x2 y1 y2} $data {\n    incr ii\n    db eval {INSERT INTO rtree VALUES($ii, $x1, $x2, $y1, $y2)}\n  }\n}}]\nputs \"$rtree_time\"\n\n\nputs -nonewline \"Selecting from btree... \"\nflush stdout\nset btree_select_time [time {\n  foreach {x1 x2 y1 y2} [lrange $data 0 [expr $NQUERY*4-1]] {\n    db eval {SELECT * FROM btree WHERE x1<$x1 AND x2>$x2 AND y1<$y1 AND y2>$y2}\n }\n}]\nputs \"$btree_select_time\"\n\nputs -nonewline \"Selecting from rtree... \"\nflush stdout\nset rtree_select_time [time {\n  foreach {x1 x2 y1 y2} [lrange $data 0 [expr $NQUERY*4-1]] {\n    db eval {SELECT * FROM rtree WHERE x1<$x1 AND x2>$x2 AND y1<$y1 AND y2>$y2}\n  }\n}]\nputs \"$rtree_select_time\"\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtree_util.tcl",
    "content": "# 2008 Feb 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains Tcl code that may be useful for testing or\n# analyzing r-tree structures created with this module. It is\n# used by both test procedures and the r-tree viewer application.\n#\n\n\n#--------------------------------------------------------------------------\n# PUBLIC API:\n#\n#   rtree_depth\n#   rtree_ndim\n#   rtree_node\n#   rtree_mincells\n#   rtree_check\n#   rtree_dump\n#   rtree_treedump\n#\n\nproc rtree_depth {db zTab} {\n  $db one \"SELECT rtreedepth(data) FROM ${zTab}_node WHERE nodeno=1\"\n}\n\nproc rtree_nodedepth {db zTab iNode} {\n  set iDepth [rtree_depth $db $zTab]\n  \n  set ii $iNode\n  while {$ii != 1} {\n    set sql \"SELECT parentnode FROM ${zTab}_parent WHERE nodeno = $ii\"\n    set ii [db one $sql]\n    incr iDepth -1\n  }\n  \n  return $iDepth\n}\n\n# Return the number of dimensions of the rtree.\n#\nproc rtree_ndim {db zTab} {\n  set nDim [expr {(([llength [$db eval \"pragma table_info($zTab)\"]]/6)-1)/2}]\n}\n\n# Return the contents of rtree node $iNode.\n#\nproc rtree_node {db zTab iNode {iPrec 6}} {\n  set nDim [rtree_ndim $db $zTab]\n  set sql \"\n    SELECT rtreenode($nDim, data) FROM ${zTab}_node WHERE nodeno = $iNode\n  \"\n  set node [db one $sql]\n\n  set nCell [llength $node]\n  set nCoord [expr $nDim*2]\n  for {set ii 0} {$ii < $nCell} {incr ii} {\n    for {set jj 1} {$jj <= $nCoord} {incr jj} {\n      set newval [format \"%.${iPrec}f\" [lindex $node $ii $jj]]\n      lset node $ii $jj $newval\n    }\n  }\n  set node\n}\n\nproc rtree_mincells {db zTab} {\n  set n [$db one \"select length(data) FROM ${zTab}_node LIMIT 1\"]\n  set nMax [expr {int(($n-4)/(8+[rtree_ndim $db $zTab]*2*4))}]\n  return [expr {int($nMax/3)}]\n}\n\n# An integrity check for the rtree $zTab accessible via database \n# connection $db.\n#\nproc rtree_check {db zTab} {\n  array unset ::checked\n \n  # Check each r-tree node.\n  set rc [catch {\n    rtree_node_check $db $zTab 1 [rtree_depth $db $zTab]\n  } msg]\n  if {$rc && $msg ne \"\"} { error $msg }\n\n  # Check that the _rowid and _parent tables have the right \n  # number of entries.\n  set nNode   [$db one \"SELECT count(*) FROM ${zTab}_node\"]\n  set nRow    [$db one \"SELECT count(*) FROM ${zTab}\"]\n  set nRowid  [$db one \"SELECT count(*) FROM ${zTab}_rowid\"]\n  set nParent [$db one \"SELECT count(*) FROM ${zTab}_parent\"]\n\n  if {$nNode != ($nParent+1)} { \n    error \"Wrong number of entries in ${zTab}_parent\"\n  }\n  if {$nRow != $nRowid} { \n    error \"Wrong number of entries in ${zTab}_rowid\"\n  }\n  \n  return $rc\n}\n\nproc rtree_node_check {db zTab iNode iDepth} {\n  if {[info exists ::checked($iNode)]} { error \"Second ref to $iNode\" }\n  set ::checked($iNode) 1\n\n  set node [rtree_node $db $zTab $iNode]\n  if {$iNode!=1 && [llength $node]==0} { error \"No such node: $iNode\" }\n\n  if {$iNode != 1 && [llength $node]<[rtree_mincells $db $zTab]} {\n    puts \"Node $iNode: Has only [llength $node] cells\"\n    error \"\"\n  }\n  if {$iNode == 1 && [llength $node]==1 && [rtree_depth $db $zTab]>0} {\n    set depth [rtree_depth $db $zTab]\n    puts \"Node $iNode: Has only 1 child (tree depth is $depth)\"\n    error \"\"\n  }\n\n  set nDim [expr {([llength [lindex $node 0]]-1)/2}]\n\n  if {$iDepth > 0} {\n    set d [expr $iDepth-1]\n    foreach cell $node {\n      set shouldbe [rtree_node_check $db $zTab [lindex $cell 0] $d]\n      if {$cell ne $shouldbe} {\n        puts \"Node $iNode: Cell is: {$cell}, should be {$shouldbe}\"\n        error \"\"\n      }\n    }\n  }\n\n  set mapping_table \"${zTab}_parent\" \n  set mapping_sql \"SELECT parentnode FROM $mapping_table WHERE rowid = \\$rowid\"\n  if {$iDepth==0} { \n    set mapping_table \"${zTab}_rowid\"\n    set mapping_sql \"SELECT nodeno FROM $mapping_table WHERE rowid = \\$rowid\"\n  }\n  foreach cell $node {\n    set rowid [lindex $cell 0]\n    set mapping [db one $mapping_sql]\n    if {$mapping != $iNode} {\n      puts \"Node $iNode: $mapping_table entry for cell $rowid is $mapping\"\n      error \"\"\n    }\n  }\n\n  set ret [list $iNode]\n  for {set ii 1} {$ii <= $nDim*2} {incr ii} {\n    set f [lindex $node 0 $ii]\n    foreach cell $node {\n      set f2 [lindex $cell $ii]\n      if {($ii%2)==1 && $f2<$f} {set f $f2}\n      if {($ii%2)==0 && $f2>$f} {set f $f2}\n    }\n    lappend ret $f\n  }\n  return $ret\n}\n\nproc rtree_dump {db zTab} {\n  set zRet \"\"\n  set nDim [expr {(([llength [$db eval \"pragma table_info($zTab)\"]]/6)-1)/2}]\n  set sql \"SELECT nodeno, rtreenode($nDim, data) AS node FROM ${zTab}_node\"\n  $db eval $sql {\n    append zRet [format \"% -10s %s\\n\" $nodeno $node]\n  }\n  set zRet\n}\n\nproc rtree_nodetreedump {db zTab zIndent iDepth iNode} {\n  set ret \"\"\n  set node [rtree_node $db $zTab $iNode 1]\n  append ret [format \"%-3d %s%s\\n\" $iNode $zIndent $node]\n  if {$iDepth>0} {\n    foreach cell $node {\n      set i [lindex $cell 0]\n      append ret [rtree_nodetreedump $db $zTab \"$zIndent  \" [expr $iDepth-1] $i]\n    }\n  }\n  set ret\n}\n\nproc rtree_treedump {db zTab} {\n  set d [rtree_depth $db $zTab]\n  rtree_nodetreedump $db $zTab \"\" $d 1\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/rtreeconnect.test",
    "content": "# 2017 August 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the r-tree extension. Specifically,\n# the impact of an SQLITE_SCHEMA error within the rtree module xConnect\n# callback.\n#\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource $testdir/tester.tcl\nset testprefix rtreeconnect\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE r1 USING rtree(id, x1, x2, y1, y2);\n  CREATE TABLE t1(id, x1, x2, y1, y2);\n  CREATE TABLE log(l);\n\n  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n    INSERT INTO r1 VALUES(new.id, new.x1, new.x2, new.y1, new.y2);\n    INSERT INTO log VALUES('r1: ' || new.id);\n  END;\n}\n\ndb close\nsqlite3 db  test.db\nsqlite3 db2 test.db\n\ndo_test 1.1 {\n  db eval { INSERT INTO log VALUES('startup'); }\n  db2 eval { CREATE TABLE newtable(x,y); }\n} {}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1 VALUES(1, 2, 3, 4, 5);\n}\n\ndb2 close\ndb close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/sqlite3rtree.h",
    "content": "/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n#include <sqlite3.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\ntypedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;\n\n/* The double-precision datatype used by RTree depends on the\n** SQLITE_RTREE_INT_ONLY compile-time option.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 sqlite3_rtree_dbl;\n#else\n  typedef double sqlite3_rtree_dbl;\n#endif\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nint sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  sqlite3_rtree_dbl *aParam;      /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n/*\n** Register a 2nd-generation geometry callback named zScore that can be \n** used as part of an R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)\n*/\nint sqlite3_rtree_query_callback(\n  sqlite3 *db,\n  const char *zQueryFunc,\n  int (*xQueryFunc)(sqlite3_rtree_query_info*),\n  void *pContext,\n  void (*xDestructor)(void*)\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the \n** argument to scored geometry callback registered using\n** sqlite3_rtree_query_callback().\n**\n** Note that the first 5 fields of this structure are identical to\n** sqlite3_rtree_geometry.  This structure is a subclass of\n** sqlite3_rtree_geometry.\n*/\nstruct sqlite3_rtree_query_info {\n  void *pContext;                   /* pContext from when function registered */\n  int nParam;                       /* Number of function parameters */\n  sqlite3_rtree_dbl *aParam;        /* value of function parameters */\n  void *pUser;                      /* callback can use this, if desired */\n  void (*xDelUser)(void*);          /* function to free pUser */\n  sqlite3_rtree_dbl *aCoord;        /* Coordinates of node or entry to check */\n  unsigned int *anQueue;            /* Number of pending entries in the queue */\n  int nCoord;                       /* Number of coordinates */\n  int iLevel;                       /* Level of current node or entry */\n  int mxLevel;                      /* The largest iLevel value in the tree */\n  sqlite3_int64 iRowid;             /* Rowid for current entry */\n  sqlite3_rtree_dbl rParentScore;   /* Score of parent node */\n  int eParentWithin;                /* Visibility of parent node */\n  int eWithin;                      /* OUT: Visiblity */\n  sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */\n  /* The following fields are only available in 3.8.11 and later */\n  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */\n};\n\n/*\n** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.\n*/\n#define NOT_WITHIN       0   /* Object completely outside of query region */\n#define PARTLY_WITHIN    1   /* Object partially overlaps query region */\n#define FULLY_WITHIN     2   /* Object fully contained within query region */\n\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/tkt3363.test",
    "content": "# 2008 Sep 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing that ticket #3363 is fixed.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource [file join [file dirname [info script]] rtree_util.tcl]\nsource $testdir/tester.tcl\n\nifcapable !rtree {\n  finish_test\n  return\n}\n\ndo_test tkt3363.1.1 {\n  execsql { CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2) }\n} {}\n\ndo_test tkt3363.1.2 {\n  for {set ii 1} {$ii < 50} {incr ii} {\n    set x 1000000\n    set y [expr 4000000 + $ii*10]\n    execsql { INSERT INTO t1 VALUES($ii, $x, $x, $y, $y) }\n  }\n} {}\n\ndo_test tkt3363.1.3 {\n  execsql { \n    SELECT count(*) FROM t1 WHERE +y2>4000425.0;\n  }\n} {7}\n\ndo_test tkt3363.1.4 {\n  execsql { \n    SELECT count(*) FROM t1 WHERE y2>4000425.0;\n  }\n} {7}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/rtree/viewrtree.tcl",
    "content": "\nload ./libsqlite3.dylib\n#package require sqlite3\nsource [file join [file dirname $argv0] rtree_util.tcl]\n\nwm title . \"SQLite r-tree viewer\"\n\nif {[llength $argv]!=1} {\n  puts stderr \"Usage: $argv0 <database-file>\"\n  puts stderr \"\"\n  exit\n}\nsqlite3 db [lindex $argv 0]\n\ncanvas .c -background white -width 400 -height 300 -highlightthickness 0\n\nbutton .b -text \"Parent Node\" -command {\n  set sql \"SELECT parentnode FROM $::O(zTab)_parent WHERE nodeno = $::O(iNode)\"\n  set ::O(iNode) [db one $sql]\n  if {$::O(iNode) eq \"\"} {set ::O(iNode) 1}\n  view_node\n}\n\nset O(iNode) 1\nset O(zTab) \"\"\nset O(listbox_captions)  [list]\nset O(listbox_itemmap)   [list]\nset O(listbox_highlight) -1\n\nlistbox   .l -listvariable ::O(listbox_captions) -yscrollcommand {.ls set}\nscrollbar .ls -command {.l yview}\nlabel     .status -font courier -anchor w\nlabel     .title -anchor w -text \"Node 1:\" -background white -borderwidth 0\n\n\nset rtree_tables [list]\ndb eval {\n  SELECT name \n  FROM sqlite_master \n  WHERE type='table' AND sql LIKE '%virtual%table%using%rtree%'\n} {\n  set nCol [expr [llength [db eval \"pragma table_info($name)\"]]/6]\n  if {$nCol != 5} {\n    puts stderr \"Not viewing $name - is not 2-dimensional\"\n  } else {\n    lappend rtree_tables [list Table $name]\n  }\n}\nif {$rtree_tables eq \"\"} {\n  puts stderr \"Cannot find an r-tree table in database [lindex $argv 0]\"\n  puts stderr \"\"\n  exit\n}\neval tk_optionMenu .select option_var $rtree_tables\ntrace add variable option_var write set_option_var\nproc set_option_var {args} {\n  set ::O(zTab) [lindex $::option_var 1]\n  set ::O(iNode) 1\n  view_node\n}\nset ::O(zTab) [lindex $::rtree_tables 0 1]\n\nbind .l <1> {listbox_click [.l nearest %y]}\nbind .l <Motion> {listbox_mouseover [.l nearest %y]}\nbind .l <Leave>  {listbox_mouseover -1}\n\nproc listbox_click {sel} {\n  if {$sel ne \"\"} {\n    set ::O(iNode) [lindex $::O(listbox_captions) $sel 1]\n    view_node\n  }\n}\nproc listbox_mouseover {i} {\n  set oldid [lindex $::O(listbox_itemmap) $::O(listbox_highlight)]\n  .c itemconfigure $oldid -fill \"\"\n\n  .l selection clear 0 end\n  .status configure -text \"\"\n  if {$i>=0} {\n    set id [lindex $::O(listbox_itemmap) $i]\n    .c itemconfigure $id -fill grey\n    .c lower $id\n    set ::O(listbox_highlight) $i\n    .l selection set $i\n    .status configure -text [cell_report db $::O(zTab) $::O(iNode) $i]\n  }\n}\n\ngrid configure .select  -row 0 -column 0 -columnspan 2 -sticky nsew\ngrid configure .b       -row 1 -column 0 -columnspan 2 -sticky nsew\ngrid configure .l       -row 2 -column 0               -sticky nsew\ngrid configure .status  -row 3 -column 0 -columnspan 3 -sticky nsew\n\ngrid configure .title   -row 0 -column 2               -sticky nsew\ngrid configure .c       -row 1 -column 2 -rowspan 2    -sticky nsew\ngrid configure .ls      -row 2 -column 1               -sticky nsew\n\ngrid columnconfigure . 2 -weight 1\ngrid rowconfigure    . 2 -weight 1\n\nproc node_bbox {data} {\n  set xmin 0\n  set xmax 0\n  set ymin 0\n  set ymax 0\n  foreach {rowid xmin xmax ymin ymax} [lindex $data 0] break\n  foreach cell [lrange $data 1 end] {\n    foreach {rowid x1 x2 y1 y2} $cell break\n    if {$x1 < $xmin} {set xmin $x1}\n    if {$x2 > $xmax} {set xmax $x2}\n    if {$y1 < $ymin} {set ymin $y1}\n    if {$y2 > $ymax} {set ymax $y2}\n  }\n  list $xmin $xmax $ymin $ymax\n}\n\nproc view_node {} {\n  set iNode $::O(iNode)\n  set zTab $::O(zTab)\n\n  set data [rtree_node db $zTab $iNode 12]\n  set depth [rtree_nodedepth db $zTab $iNode]\n\n  .c delete all\n  set ::O(listbox_captions) [list]\n  set ::O(listbox_itemmap) [list]\n  set $::O(listbox_highlight) -1\n\n  .b configure -state normal\n  if {$iNode == 1} {.b configure -state disabled}\n  .title configure -text \"Node $iNode: [cell_report db $zTab $iNode -1]\"\n\n  foreach {xmin xmax ymin ymax} [node_bbox $data] break\n  set total_area 0.0\n\n  set xscale [expr {double([winfo width .c]-20)/($xmax-$xmin)}]\n  set yscale [expr {double([winfo height .c]-20)/($ymax-$ymin)}]\n\n  set xoff [expr {10.0 - $xmin*$xscale}]\n  set yoff [expr {10.0 - $ymin*$yscale}]\n\n  foreach cell $data {\n    foreach {rowid x1 x2 y1 y2} $cell break\n    set total_area [expr {$total_area + ($x2-$x1)*($y2-$y1)}]\n    set x1 [expr {$x1*$xscale + $xoff}]\n    set x2 [expr {$x2*$xscale + $xoff}]\n    set y1 [expr {$y1*$yscale + $yoff}]\n    set y2 [expr {$y2*$yscale + $yoff}]\n\n    set id [.c create rectangle $x1 $y1 $x2 $y2]\n    if {$depth>0} {\n      lappend ::O(listbox_captions) \"Node $rowid\"\n      lappend ::O(listbox_itemmap) $id\n    }\n  }\n}\n\nproc cell_report {db zTab iParent iCell} {\n  set data [rtree_node db $zTab $iParent 12]\n  set cell [lindex $data $iCell]\n\n  foreach {xmin xmax ymin ymax} [node_bbox $data] break\n  set total_area [expr ($xmax-$xmin)*($ymax-$ymin)]\n\n  if {$cell eq \"\"} {\n    set cell_area 0.0\n    foreach cell $data {\n      foreach {rowid x1 x2 y1 y2} $cell break\n      set cell_area [expr $cell_area+($x2-$x1)*($y2-$y1)]\n    }\n    set cell_area [expr $cell_area/[llength $data]]\n    set zReport [format \"Size = %.1f x %.1f    Average child area = %.1f%%\" \\\n      [expr $xmax-$xmin] [expr $ymax-$ymin] [expr 100.0*$cell_area/$total_area]\\\n    ]\n    append zReport \"   Sub-tree height: [rtree_nodedepth db $zTab $iParent]\"\n  } else {\n    foreach {rowid x1 x2 y1 y2} $cell break\n    set cell_area  [expr ($x2-$x1)*($y2-$y1)]\n    set zReport [format \"Size = %.1f x %.1f    Area = %.1f%%\" \\\n      [expr $x2-$x1] [expr $y2-$y1] [expr 100.0*$cell_area/$total_area]\n    ]\n  }\n\n  return $zReport\n}\n\nview_node\nbind .c <Configure> view_node\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/changeset.c",
    "content": "/*\n** 2014-08-18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement the \"changeset\" command line\n** utility for displaying and transforming changesets generated by\n** the Sessions extension.\n*/\n#include \"sqlite3.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <ctype.h>\n\n\n/*\n** Show a usage message on stderr then quit.\n*/\nstatic void usage(const char *argv0){\n  fprintf(stderr, \"Usage: %s FILENAME COMMAND ...\\n\", argv0);\n  fprintf(stderr,\n    \"COMMANDs:\\n\"\n    \"   apply DB           Apply the changeset to database file DB\\n\"\n    \"   concat FILE2 OUT   Concatenate FILENAME and FILE2 into OUT\\n\"\n    \"   dump               Show the complete content of the changeset\\n\"\n    \"   invert OUT         Write an inverted changeset into file OUT\\n\"\n    \"   sql                Give a pseudo-SQL rendering of the changeset\\n\"\n  );\n  exit(1);\n}\n\n/*\n** Read the content of a disk file into an in-memory buffer\n*/\nstatic void readFile(const char *zFilename, int *pSz, void **ppBuf){\n  FILE *f;\n  int sz;\n  void *pBuf;\n  f = fopen(zFilename, \"rb\");\n  if( f==0 ){\n    fprintf(stderr, \"cannot open \\\"%s\\\" for reading\\n\", zFilename);\n    exit(1);\n  }\n  fseek(f, 0, SEEK_END);\n  sz = (int)ftell(f);\n  rewind(f);\n  pBuf = sqlite3_malloc( sz ? sz : 1 );\n  if( pBuf==0 ){\n    fprintf(stderr, \"cannot allocate %d to hold content of \\\"%s\\\"\\n\",\n            sz, zFilename);\n    exit(1);\n  }\n  if( sz>0 ){\n    if( fread(pBuf, sz, 1, f)!=1 ){\n      fprintf(stderr, \"cannot read all %d bytes of \\\"%s\\\"\\n\", sz, zFilename);\n      exit(1);\n    }\n    fclose(f);\n  }\n  *pSz = sz;\n  *ppBuf = pBuf;\n}\n\n/* Array for converting from half-bytes (nybbles) into ASCII hex\n** digits. */\nstatic const char hexdigits[] = {\n  '0', '1', '2', '3', '4', '5', '6', '7',\n  '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' \n};\n\n/*\n** Render an sqlite3_value as an SQL string.\n*/\nstatic void renderValue(sqlite3_value *pVal){\n  switch( sqlite3_value_type(pVal) ){\n    case SQLITE_FLOAT: {\n      double r1;\n      char zBuf[50];\n      r1 = sqlite3_value_double(pVal);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.15g\", r1);\n      printf(\"%s\", zBuf);\n      break;\n    }\n    case SQLITE_INTEGER: {\n      printf(\"%lld\", sqlite3_value_int64(pVal));\n      break;\n    }\n    case SQLITE_BLOB: {\n      char const *zBlob = sqlite3_value_blob(pVal);\n      int nBlob = sqlite3_value_bytes(pVal);\n      int i;\n      printf(\"x'\");\n      for(i=0; i<nBlob; i++){\n        putchar(hexdigits[(zBlob[i]>>4)&0x0F]);\n        putchar(hexdigits[(zBlob[i])&0x0F]);\n      }\n      putchar('\\'');\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *zArg = sqlite3_value_text(pVal);\n      putchar('\\'');\n      while( zArg[0] ){\n        putchar(zArg[0]);\n        if( zArg[0]=='\\'' ) putchar(zArg[0]);\n        zArg++;\n      }\n      putchar('\\'');\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(pVal)==SQLITE_NULL );\n      printf(\"NULL\");\n      break;\n    }\n  }\n}\n\n/*\n** Number of conflicts seen\n*/\nstatic int nConflict = 0;\n\n/*\n** The conflict callback\n*/\nstatic int conflictCallback(\n  void *pCtx,\n  int eConflict,\n  sqlite3_changeset_iter *pIter\n){\n  int op, bIndirect, nCol, i;\n  const char *zTab;\n  unsigned char *abPK;\n  const char *zType = \"\";\n  const char *zOp = \"\";\n  const char *zSep = \" \";\n\n  nConflict++;\n  sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);\n  sqlite3changeset_pk(pIter, &abPK, 0);\n  switch( eConflict ){\n    case SQLITE_CHANGESET_DATA:         zType = \"DATA\";         break;\n    case SQLITE_CHANGESET_NOTFOUND:     zType = \"NOTFOUND\";     break;\n    case SQLITE_CHANGESET_CONFLICT:     zType = \"PRIMARY KEY\";  break;\n    case SQLITE_CHANGESET_FOREIGN_KEY:  zType = \"FOREIGN KEY\";  break;\n    case SQLITE_CHANGESET_CONSTRAINT:   zType = \"CONSTRAINT\";   break;\n  }\n  switch( op ){\n    case SQLITE_UPDATE:     zOp = \"UPDATE of\";     break;\n    case SQLITE_INSERT:     zOp = \"INSERT into\";   break;\n    case SQLITE_DELETE:     zOp = \"DELETE from\";   break;\n  }\n  printf(\"%s conflict on %s table %s with primary key\", zType, zOp, zTab);\n  for(i=0; i<nCol; i++){\n    sqlite3_value *pVal;\n    if( abPK[i]==0 ) continue;\n    printf(\"%s\", zSep);\n    if( op==SQLITE_INSERT ){\n      sqlite3changeset_new(pIter, i, &pVal);\n    }else{\n      sqlite3changeset_old(pIter, i, &pVal);\n    }\n    renderValue(pVal);\n    zSep = \",\";\n  }\n  printf(\"\\n\");\n  return SQLITE_CHANGESET_OMIT;\n}\n\nint main(int argc, char **argv){\n  int sz, rc;\n  void *pBuf = 0;\n  if( argc<3 ) usage(argv[0]);\n  readFile(argv[1], &sz, &pBuf);\n\n  /* changeset FILENAME apply DB\n  ** Apply the changeset in FILENAME to the database file DB\n  */\n  if( strcmp(argv[2],\"apply\")==0 ){\n    sqlite3 *db;\n    if( argc!=4 ) usage(argv[0]);\n    rc = sqlite3_open(argv[3], &db);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"unable to open database file \\\"%s\\\": %s\\n\",\n              argv[3], sqlite3_errmsg(db));\n      sqlite3_close(db);\n      exit(1);\n    }\n    sqlite3_exec(db, \"BEGIN\", 0, 0, 0);\n    nConflict = 0;\n    rc = sqlite3changeset_apply(db, sz, pBuf, 0, conflictCallback, 0);\n    if( rc ){\n      fprintf(stderr, \"sqlite3changeset_apply() returned %d\\n\", rc);\n    }\n    if( nConflict ){\n      fprintf(stderr, \"%d conflicts - no changes applied\\n\", nConflict);\n      sqlite3_exec(db, \"ROLLBACK\", 0, 0, 0);\n    }else if( rc ){\n      fprintf(stderr, \"sqlite3changeset_apply() returns %d \"\n                      \"- no changes applied\\n\", rc);\n      sqlite3_exec(db, \"ROLLBACK\", 0, 0, 0);\n    }else{\n      sqlite3_exec(db, \"COMMIT\", 0, 0, 0);\n    }\n    sqlite3_close(db);\n  }else\n\n  /* changeset FILENAME concat FILE2 OUT\n  ** Add changeset FILE2 onto the end of the changeset in FILENAME\n  ** and write the result into OUT.\n  */\n  if( strcmp(argv[2],\"concat\")==0 ){\n    int szB;\n    void *pB;\n    int szOut;\n    void *pOutBuf;\n    FILE *out;\n    const char *zOut = argv[4];\n    if( argc!=5 ) usage(argv[0]);\n    out = fopen(zOut, \"wb\");\n    if( out==0 ){\n      fprintf(stderr, \"cannot open \\\"%s\\\" for writing\\n\", zOut);\n      exit(1);\n    }\n    readFile(argv[3], &szB, &pB);\n    rc = sqlite3changeset_concat(sz, pBuf, szB, pB, &szOut, &pOutBuf);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"sqlite3changeset_concat() returns %d\\n\", rc);\n    }else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){\n      fprintf(stderr, \"unable to write all %d bytes of output to \\\"%s\\\"\\n\",\n              szOut, zOut);\n    }\n    fclose(out);\n    sqlite3_free(pOutBuf);\n    sqlite3_free(pB);\n  }else\n\n  /* changeset FILENAME dump\n  ** Show the complete content of the changeset in FILENAME\n  */\n  if( strcmp(argv[2],\"dump\")==0 ){\n    int cnt = 0;\n    int i;\n    sqlite3_changeset_iter *pIter;\n    rc = sqlite3changeset_start(&pIter, sz, pBuf);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"sqlite3changeset_start() returns %d\\n\", rc);\n      exit(1);\n    }\n    while( sqlite3changeset_next(pIter)==SQLITE_ROW ){\n      int op, bIndirect, nCol;\n      const char *zTab;\n      unsigned char *abPK;\n      sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);\n      cnt++;\n      printf(\"%d: %s table=[%s] indirect=%d nColumn=%d\\n\",\n             cnt, op==SQLITE_INSERT ? \"INSERT\" :\n                       op==SQLITE_UPDATE ? \"UPDATE\" : \"DELETE\",\n             zTab, bIndirect, nCol);\n      sqlite3changeset_pk(pIter, &abPK, 0);\n      for(i=0; i<nCol; i++){\n        sqlite3_value *pVal;\n        pVal = 0;\n        sqlite3changeset_old(pIter, i, &pVal);\n        if( pVal ){\n          printf(\"    old[%d]%s = \", i, abPK[i] ? \"pk\" : \"  \");\n          renderValue(pVal);\n          printf(\"\\n\");\n        }\n        pVal = 0;\n        sqlite3changeset_new(pIter, i, &pVal);\n        if( pVal ){\n          printf(\"    new[%d]%s = \", i, abPK[i] ? \"pk\" : \"  \");\n          renderValue(pVal);\n          printf(\"\\n\");\n        }\n      }\n    }\n    sqlite3changeset_finalize(pIter);\n  }else\n\n  /* changeset FILENAME invert OUT\n  ** Invert the changes in FILENAME and writes the result on OUT\n  */\n  if( strcmp(argv[2],\"invert\")==0 ){\n    FILE *out;\n    int szOut = 0;\n    void *pOutBuf = 0;\n    const char *zOut = argv[3];\n    if( argc!=4 ) usage(argv[0]);\n    out = fopen(zOut, \"wb\");\n    if( out==0 ){\n      fprintf(stderr, \"cannot open \\\"%s\\\" for writing\\n\", zOut);\n      exit(1);\n    }\n    rc = sqlite3changeset_invert(sz, pBuf, &szOut, &pOutBuf);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"sqlite3changeset_invert() returns %d\\n\", rc);\n    }else if( szOut>0 && fwrite(pOutBuf, szOut, 1, out)!=1 ){\n      fprintf(stderr, \"unable to write all %d bytes of output to \\\"%s\\\"\\n\",\n              szOut, zOut);\n    }\n    fclose(out);\n    sqlite3_free(pOutBuf);\n  }else\n\n  /* changeset FILE sql\n  ** Show the content of the changeset as pseudo-SQL\n  */\n  if( strcmp(argv[2],\"sql\")==0 ){\n    int cnt = 0;\n    char *zPrevTab = 0;\n    char *zSQLTabName = 0;\n    sqlite3_changeset_iter *pIter = 0;\n    rc = sqlite3changeset_start(&pIter, sz, pBuf);\n    if( rc!=SQLITE_OK ){\n      fprintf(stderr, \"sqlite3changeset_start() returns %d\\n\", rc);\n      exit(1);\n    }\n    printf(\"BEGIN;\\n\");\n    while( sqlite3changeset_next(pIter)==SQLITE_ROW ){\n      int op, bIndirect, nCol;\n      const char *zTab;\n      sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);\n      cnt++;\n      if( zPrevTab==0 || strcmp(zPrevTab,zTab)!=0 ){\n        sqlite3_free(zPrevTab);\n        sqlite3_free(zSQLTabName);\n        zPrevTab = sqlite3_mprintf(\"%s\", zTab);\n        if( !isalnum(zTab[0]) || sqlite3_strglob(\"*[^a-zA-Z0-9]*\",zTab)==0 ){\n          zSQLTabName = sqlite3_mprintf(\"\\\"%w\\\"\", zTab);\n        }else{\n          zSQLTabName = sqlite3_mprintf(\"%s\", zTab);\n        }\n        printf(\"/****** Changes for table %s ***************/\\n\", zSQLTabName);\n      }\n      switch( op ){\n        case SQLITE_DELETE: {\n          unsigned char *abPK;\n          int i;\n          const char *zSep = \" \";\n          sqlite3changeset_pk(pIter, &abPK, 0);\n          printf(\"/* %d */ DELETE FROM %s WHERE\", cnt, zSQLTabName);\n          for(i=0; i<nCol; i++){\n            sqlite3_value *pVal;\n            if( abPK[i]==0 ) continue;\n            printf(\"%sc%d=\", zSep, i+1);\n            zSep = \" AND \";\n            sqlite3changeset_old(pIter, i, &pVal);\n            renderValue(pVal);\n          }\n          printf(\";\\n\");\n          break;\n        }\n        case SQLITE_UPDATE: {\n          unsigned char *abPK;\n          int i;\n          const char *zSep = \" \";\n          sqlite3changeset_pk(pIter, &abPK, 0);\n          printf(\"/* %d */ UPDATE %s SET\", cnt, zSQLTabName);\n          for(i=0; i<nCol; i++){\n            sqlite3_value *pVal = 0;\n            sqlite3changeset_new(pIter, i, &pVal);\n            if( pVal ){\n              printf(\"%sc%d=\", zSep, i+1);\n              zSep = \", \";\n              renderValue(pVal);\n            }\n          }\n          printf(\" WHERE\");\n          zSep = \" \";\n          for(i=0; i<nCol; i++){\n            sqlite3_value *pVal;\n            if( abPK[i]==0 ) continue;\n            printf(\"%sc%d=\", zSep, i+1);\n            zSep = \" AND \";\n            sqlite3changeset_old(pIter, i, &pVal);\n            renderValue(pVal);\n          }\n          printf(\";\\n\");\n          break;\n        }\n        case SQLITE_INSERT: {\n          int i;\n          printf(\"/* %d */ INSERT INTO %s VALUES\", cnt, zSQLTabName);\n          for(i=0; i<nCol; i++){\n            sqlite3_value *pVal;\n            printf(\"%c\", i==0 ? '(' : ',');\n            sqlite3changeset_new(pIter, i, &pVal);\n            renderValue(pVal);\n          }\n          printf(\");\\n\");\n          break;\n        }\n      }\n    }\n    printf(\"COMMIT;\\n\");\n    sqlite3changeset_finalize(pIter);\n    sqlite3_free(zPrevTab);\n    sqlite3_free(zSQLTabName);\n  }else\n\n  /* If nothing else matches, show the usage comment */\n  usage(argv[0]);\n  sqlite3_free(pBuf);\n  return 0; \n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session1.test",
    "content": "# 2011 March 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session1\n\n# Run all tests in this file twice. Once with \"WITHOUT ROWID\", and once\n# with regular rowid tables.\n#\nforeach {tn trailing} {\n  1 \"\"\n  2 \" WITHOUT ROWID \"\n} {\neval [string map [list %WR% $trailing] {\n\ndb close\nforcedelete test.db test.db2\nreset_db\n\ndo_execsql_test $tn.1.0 {\n  CREATE TABLE t1(x PRIMARY KEY, y) %WR%;\n  INSERT INTO t1 VALUES('abc', 'def');\n}\n\n#-------------------------------------------------------------------------\n# Test creating, attaching tables to and deleting session objects.\n#\ndo_test $tn.1.1 { sqlite3session S db main } {S}\ndo_test $tn.1.2 { S delete } {}\ndo_test $tn.1.3 { sqlite3session S db main } {S}\ndo_test $tn.1.4 { S attach t1 } {}\ndo_test $tn.1.5 { S delete } {}\ndo_test $tn.1.6 { sqlite3session S db main } {S}\ndo_test $tn.1.7 { S attach t1 ; S attach t2 ; S attach t3 } {}\ndo_test $tn.1.8 { S attach t1 ; S attach t2 ; S attach t3 } {}\ndo_test $tn.1.9 { S delete } {}\ndo_test $tn.1.10 {\n  sqlite3session S db main\n  S attach t1\n  execsql { INSERT INTO t1 VALUES('ghi', 'jkl') }\n} {}\ndo_test $tn.1.11 { S delete } {}\nif {$tn==1} {\n  do_test $tn.1.12 {\n    sqlite3session S db main\n    S attach t1\n    execsql { INSERT INTO t1 VALUES('mno', 'pqr') }\n    execsql { UPDATE t1 SET x = 111 WHERE rowid = 1 }\n    execsql { DELETE FROM t1 WHERE rowid = 2 }\n  } {}\n  do_test $tn.1.13 {\n    S changeset\n    S delete\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Simple changeset tests. Also test the sqlite3changeset_invert() \n# function.\n#\ndo_test $tn.2.1.1 {\n  execsql { DELETE FROM t1 }\n  sqlite3session S db main\n  S attach t1\n  execsql { INSERT INTO t1 VALUES(1, 'Sukhothai') }\n  execsql { INSERT INTO t1 VALUES(2, 'Ayutthaya') }\n  execsql { INSERT INTO t1 VALUES(3, 'Thonburi') }\n} {}\ndo_changeset_test $tn.2.1.2 S {\n  {INSERT t1 0 X. {} {i 1 t Sukhothai}}\n  {INSERT t1 0 X. {} {i 2 t Ayutthaya}}\n  {INSERT t1 0 X. {} {i 3 t Thonburi}}\n}\ndo_changeset_invert_test $tn.2.1.3 S {\n  {DELETE t1 0 X. {i 1 t Sukhothai} {}}\n  {DELETE t1 0 X. {i 2 t Ayutthaya} {}}\n  {DELETE t1 0 X. {i 3 t Thonburi} {}}\n}\ndo_test $tn.2.1.4 { S delete } {}\n\ndo_test $tn.2.2.1 {\n  sqlite3session S db main\n  S attach t1\n  execsql { DELETE FROM t1 WHERE 1 }\n} {}\ndo_changeset_test $tn.2.2.2 S {\n  {DELETE t1 0 X. {i 1 t Sukhothai} {}}\n  {DELETE t1 0 X. {i 2 t Ayutthaya} {}}\n  {DELETE t1 0 X. {i 3 t Thonburi} {}}\n}\ndo_changeset_invert_test $tn.2.2.3 S {\n  {INSERT t1 0 X. {} {i 1 t Sukhothai}}\n  {INSERT t1 0 X. {} {i 2 t Ayutthaya}}\n  {INSERT t1 0 X. {} {i 3 t Thonburi}}\n}\ndo_test $tn.2.2.4 { S delete } {}\n\ndo_test $tn.2.3.1 {\n  execsql { DELETE FROM t1 }\n  sqlite3session S db main\n  execsql { INSERT INTO t1 VALUES(1, 'Sukhothai') }\n  execsql { INSERT INTO t1 VALUES(2, 'Ayutthaya') }\n  execsql { INSERT INTO t1 VALUES(3, 'Thonburi') }\n  S attach t1\n  execsql { \n    UPDATE t1 SET x = 10 WHERE x = 1;\n    UPDATE t1 SET y = 'Surin' WHERE x = 2;\n    UPDATE t1 SET x = 20, y = 'Thapae' WHERE x = 3;\n  }\n} {}\n\ndo_changeset_test $tn.2.3.2 S {\n  {INSERT t1 0 X. {} {i 10 t Sukhothai}} \n  {DELETE t1 0 X. {i 1 t Sukhothai} {}} \n  {UPDATE t1 0 X. {i 2 t Ayutthaya} {{} {} t Surin}} \n  {DELETE t1 0 X. {i 3 t Thonburi} {}} \n  {INSERT t1 0 X. {} {i 20 t Thapae}} \n}\n\ndo_changeset_invert_test $tn.2.3.3 S {\n  {DELETE t1 0 X. {i 10 t Sukhothai} {}} \n  {INSERT t1 0 X. {} {i 1 t Sukhothai}} \n  {UPDATE t1 0 X. {i 2 t Surin} {{} {} t Ayutthaya}} \n  {INSERT t1 0 X. {} {i 3 t Thonburi}} \n  {DELETE t1 0 X. {i 20 t Thapae} {}}\n}\ndo_test $tn.2.3.4 { S delete } {}\n\ndo_test $tn.2.4.1 {\n  sqlite3session S db main\n  S attach t1\n  execsql { INSERT INTO t1 VALUES(100, 'Bangkok') }\n  execsql { DELETE FROM t1 WHERE x = 100 }\n} {}\ndo_changeset_test $tn.2.4.2 S {}\ndo_changeset_invert_test $tn.2.4.3 S {}\ndo_test $tn.2.4.4 { S delete } {}\n\n#-------------------------------------------------------------------------\n# Test the application of simple changesets. These tests also test that\n# the conflict callback is invoked correctly. For these tests, the \n# conflict callback always returns OMIT.\n#\ndb close\nforcedelete test.db test.db2\nsqlite3 db test.db\nsqlite3 db2 test.db2\n\nproc xConflict {args} { \n  lappend ::xConflict $args\n  return \"\" \n}\n\nproc bgerror {args} { set ::background_error $args }\n\nproc do_conflict_test {tn args} {\n  set O(-tables)    [list]\n  set O(-sql)       [list]\n  set O(-conflicts) [list]\n\n  array set V $args\n  foreach key [array names V] {\n    if {![info exists O($key)]} {error \"no such option: $key\"}\n  }\n  array set O $args\n\n  sqlite3session S db main\n  foreach t $O(-tables) { S attach $t }\n  execsql $O(-sql)\n  set ::xConflict [list]\n  sqlite3changeset_apply db2 [S changeset] xConflict\n\n  set conflicts [list]\n  foreach c $O(-conflicts) {\n    lappend conflicts $c\n  }\n\n  after 1 {set go 1}\n  vwait go\n\n  uplevel do_test $tn [list { set ::xConflict }] [list $conflicts]\n  S delete\n}\n\nproc do_db2_test {testname sql {result {}}} {\n  uplevel do_test $testname [list \"execsql {$sql} db2\"] [list [list {*}$result]]\n}\n\n# Test INSERT changesets.\n#\ndo_test $tn.3.1.0 {\n  execsql { CREATE TABLE t1(a PRIMARY KEY, b NOT NULL) %WR% } db2\n  execsql { \n    CREATE TABLE t1(a PRIMARY KEY, b) %WR%;\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n  } db \n} {}\ndo_db2_test $tn.3.1.1 \"INSERT INTO t1 VALUES(6, 'VI')\"\ndo_conflict_test $tn.3.1.2 -tables t1 -sql {\n  INSERT INTO t1 VALUES(3, 'three');\n  INSERT INTO t1 VALUES(4, 'four');\n  INSERT INTO t1 VALUES(5, 'five');\n  INSERT INTO t1 VALUES(6, 'six');\n  INSERT INTO t1 VALUES(7, 'seven');\n  INSERT INTO t1 VALUES(8, NULL);\n} -conflicts {\n  {INSERT t1 CONFLICT {i 6 t six} {i 6 t VI}}\n  {INSERT t1 CONSTRAINT {i 8 n {}}}\n}\n\ndo_db2_test $tn.3.1.3 \"SELECT * FROM t1 ORDER BY a\" {\n  3 three 4 four 5 five 6 VI 7 seven\n}\ndo_execsql_test $tn.3.1.4 \"SELECT * FROM t1\" {\n  1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 {}\n}\n\n# Test DELETE changesets.\n#\ndo_execsql_test $tn.3.2.1 {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE t2(a PRIMARY KEY, b)%WR%;\n  CREATE TABLE t3(c, d REFERENCES t2);\n  INSERT INTO t2 VALUES(1, 'one');\n  INSERT INTO t2 VALUES(2, 'two');\n  INSERT INTO t2 VALUES(3, 'three');\n  INSERT INTO t2 VALUES(4, 'four');\n}\ndo_db2_test $tn.3.2.2 {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE t2(a PRIMARY KEY, b)%WR%;\n  CREATE TABLE t3(c, d REFERENCES t2);\n  INSERT INTO t2 VALUES(1, 'one');\n  INSERT INTO t2 VALUES(2, 'two');\n  INSERT INTO t2 VALUES(4, 'five');\n  INSERT INTO t3 VALUES('i', 1);\n}\ndo_conflict_test $tn.3.2.3 -tables t2 -sql {\n  DELETE FROM t2 WHERE a = 1;\n  DELETE FROM t2 WHERE a = 2;\n  DELETE FROM t2 WHERE a = 3;\n  DELETE FROM t2 WHERE a = 4;\n} -conflicts {\n  {DELETE t2 NOTFOUND {i 3 t three}}\n  {DELETE t2 DATA {i 4 t four} {i 4 t five}}\n  {FOREIGN_KEY 1}\n}\ndo_execsql_test $tn.3.2.4 \"SELECT * FROM t2\" {}\ndo_db2_test $tn.3.2.5 \"SELECT * FROM t2\" {4 five}\n\n# Test UPDATE changesets.\n#\ndo_execsql_test $tn.3.3.1 {\n  CREATE TABLE t4(a, b, c, PRIMARY KEY(b, c))%WR%;\n  INSERT INTO t4 VALUES(1, 2, 3);\n  INSERT INTO t4 VALUES(4, 5, 6);\n  INSERT INTO t4 VALUES(7, 8, 9);\n  INSERT INTO t4 VALUES(10, 11, 12);\n}\ndo_db2_test $tn.3.3.2 {\n  CREATE TABLE t4(a NOT NULL, b, c, PRIMARY KEY(b, c))%WR%;\n  INSERT INTO t4 VALUES(0, 2, 3);\n  INSERT INTO t4 VALUES(4, 5, 7);\n  INSERT INTO t4 VALUES(7, 8, 9);\n  INSERT INTO t4 VALUES(10, 11, 12);\n}\ndo_conflict_test $tn.3.3.3 -tables t4 -sql {\n  UPDATE t4 SET a = -1 WHERE b = 2;\n  UPDATE t4 SET a = -1 WHERE b = 5;\n  UPDATE t4 SET a = NULL WHERE c = 9;\n  UPDATE t4 SET a = 'x' WHERE b = 11;\n} -conflicts {\n  {UPDATE t4 DATA {i 1 i 2 i 3} {i -1 {} {} {} {}} {i 0 i 2 i 3}}\n  {UPDATE t4 NOTFOUND {i 4 i 5 i 6} {i -1 {} {} {} {}}}\n  {UPDATE t4 CONSTRAINT {i 7 i 8 i 9} {n {} {} {} {} {}}}\n}\ndo_db2_test $tn.3.3.4 { SELECT * FROM t4 } {0 2 3 4 5 7 7 8 9 x 11 12}\ndo_execsql_test $tn.3.3.5 { SELECT * FROM t4 } {-1 2 3 -1 5 6 {} 8 9 x 11 12}\n\n#-------------------------------------------------------------------------\n# This next block of tests verifies that values returned by the conflict\n# handler are intepreted correctly.\n#\n\nproc test_reset {} {\n  db close\n  db2 close\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  sqlite3 db2 test.db2\n}\n\nproc xConflict {args} {\n  lappend ::xConflict $args\n  return $::conflict_return\n}\n\nforeach {tn2 conflict_return after} {\n  1 OMIT      {1 2 value1   4 5 7       10 x x}\n  2 REPLACE   {1 2 value1   4 5 value2  10 8 9}\n} {\n  test_reset\n\n  do_test $tn.4.$tn2.1 {\n    foreach db {db db2} {\n      execsql { \n        CREATE TABLE t1(a, b, c, PRIMARY KEY(a))%WR%;\n        INSERT INTO t1 VALUES(1, 2, 3);\n        INSERT INTO t1 VALUES(4, 5, 6);\n        INSERT INTO t1 VALUES(7, 8, 9);\n      } $db\n    }\n    execsql { \n      REPLACE INTO t1 VALUES(4, 5, 7);\n      REPLACE INTO t1 VALUES(10, 'x', 'x');\n    } db2\n  } {}\n\n  do_conflict_test $tn.4.$tn2.2 -tables t1 -sql {\n    UPDATE t1 SET c = 'value1' WHERE a = 1;       -- no conflict\n    UPDATE t1 SET c = 'value2' WHERE a = 4;       -- DATA conflict\n    UPDATE t1 SET a = 10 WHERE a = 7;             -- CONFLICT conflict\n  } -conflicts {\n    {INSERT t1 CONFLICT {i 10 i 8 i 9} {i 10 t x t x}}\n    {UPDATE t1 DATA {i 4 {} {} i 6} {{} {} {} {} t value2} {i 4 i 5 i 7}}\n  }\n\n  do_db2_test $tn.4.$tn2.3 \"SELECT * FROM t1 ORDER BY a\" $after\n}\n\nforeach {tn2 conflict_return} {\n  1 OMIT\n  2 REPLACE\n} {\n  test_reset\n\n  do_test $tn.5.$tn2.1 {\n    # Create an identical schema in both databases.\n    set schema {\n      CREATE TABLE \"'foolish name'\"(x, y, z, PRIMARY KEY(x, y))%WR%;\n    }\n    execsql $schema db\n    execsql $schema db2\n\n    # Add some rows to [db2]. These rows will cause conflicts later\n    # on when the changeset from [db] is applied to it.\n    execsql { \n      INSERT INTO \"'foolish name'\" VALUES('one', 'one', 'ii');\n      INSERT INTO \"'foolish name'\" VALUES('one', 'two', 'i');\n      INSERT INTO \"'foolish name'\" VALUES('two', 'two', 'ii');\n    } db2\n\n  } {}\n\n  do_conflict_test $tn.5.$tn2.2 -tables {{'foolish name'}} -sql {\n    INSERT INTO \"'foolish name'\" VALUES('one', 'two', 2);\n  } -conflicts {\n    {INSERT {'foolish name'} CONFLICT {t one t two i 2} {t one t two t i}}\n  }\n\n  set res(REPLACE) {one one ii one two 2 two two ii}\n  set res(OMIT)    {one one ii one two i two two ii}\n  do_db2_test $tn.5.$tn2.3 {\n    SELECT * FROM \"'foolish name'\" ORDER BY x, y\n  } $res($conflict_return)\n\n\n  do_test $tn.5.$tn2.1 {\n    set schema {\n      CREATE TABLE d1(\"z\"\"z\" PRIMARY KEY, y)%WR%;\n      INSERT INTO d1 VALUES(1, 'one');\n      INSERT INTO d1 VALUES(2, 'two');\n    }\n    execsql $schema db\n    execsql $schema db2\n\n    execsql { \n      UPDATE d1 SET y = 'TWO' WHERE \"z\"\"z\" = 2;\n    } db2\n\n  } {}\n\n  do_conflict_test $tn.5.$tn2.2 -tables d1 -sql {\n    DELETE FROM d1 WHERE \"z\"\"z\" = 2;\n  } -conflicts {\n    {DELETE d1 DATA {i 2 t two} {i 2 t TWO}}\n  }\n\n  set res(REPLACE) {1 one}\n  set res(OMIT)    {1 one 2 TWO}\n  do_db2_test $tn.5.$tn2.3 \"SELECT * FROM d1\" $res($conflict_return)\n}\n\n#-------------------------------------------------------------------------\n# Test that two tables can be monitored by a single session object.\n#\ntest_reset\nset schema {\n  CREATE TABLE t1(a COLLATE nocase PRIMARY KEY, b)%WR%;\n  CREATE TABLE t2(a, b PRIMARY KEY)%WR%;\n}\ndo_test $tn.6.0 {\n  execsql $schema db\n  execsql $schema db2\n  execsql {\n    INSERT INTO t1 VALUES('a', 'b');\n    INSERT INTO t2 VALUES('a', 'b');\n  } db2\n} {}\n\nset conflict_return \"\"\ndo_conflict_test $tn.6.1 -tables {t1 t2} -sql {\n  INSERT INTO t1 VALUES('1', '2');\n  INSERT INTO t1 VALUES('A', 'B');\n  INSERT INTO t2 VALUES('A', 'B');\n} -conflicts {\n  {INSERT t1 CONFLICT {t A t B} {t a t b}}\n}\n\ndo_db2_test $tn.6.2 \"SELECT * FROM t1 ORDER BY a\" {1 2 a b}\ndo_db2_test $tn.6.3 \"SELECT * FROM t2 ORDER BY a\" {A B a b}\n\n#-------------------------------------------------------------------------\n# Test that session objects are not confused by changes to table in\n# other databases.\n#\ncatch { db2 close }\ndrop_all_tables\nforcedelete test.db2\ndo_iterator_test $tn.7.1 * {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE main.t1(x PRIMARY KEY, y)%WR%;\n  CREATE TABLE aux.t1(x PRIMARY KEY, y)%WR%;\n\n  INSERT INTO main.t1 VALUES('one', 1);\n  INSERT INTO main.t1 VALUES('two', 2);\n  INSERT INTO aux.t1 VALUES('three', 3);\n  INSERT INTO aux.t1 VALUES('four', 4);\n} {\n  {INSERT t1 0 X. {} {t two i 2}} \n  {INSERT t1 0 X. {} {t one i 1}}\n}\n\n#-------------------------------------------------------------------------\n# Test the sqlite3session_isempty() function.\n#\ndo_test $tn.8.1 {\n  execsql {\n    CREATE TABLE t5(x PRIMARY KEY, y)%WR%;\n    CREATE TABLE t6(x PRIMARY KEY, y)%WR%;\n    INSERT INTO t5 VALUES('a', 'b');\n    INSERT INTO t6 VALUES('a', 'b');\n  }\n  sqlite3session S db main\n  S attach *\n\n  S isempty\n} {1}\ndo_test $tn.8.2 {\n  execsql { DELETE FROM t5 }\n  S isempty\n} {0}\ndo_test $tn.8.3 {\n  S delete\n  sqlite3session S db main\n  S attach t5\n  execsql { DELETE FROM t5 }\n  S isempty\n} {1}\ndo_test $tn.8.4 { S delete } {}\n\ndo_test $tn.8.5 {\n  sqlite3session S db main\n  S attach t5\n  S attach t6\n  execsql { INSERT INTO t5 VALUES(1, 2) }\n  S isempty\n} {0}\n\ndo_test $tn.8.6 {\n  S delete\n  sqlite3session S db main\n  S attach t5\n  S attach t6\n  execsql { INSERT INTO t6 VALUES(1, 2) }\n  S isempty\n} {0}\ndo_test $tn.8.7 { S delete } {}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test $tn.9.1 {\n  CREATE TABLE t7(a, b, c, d, e PRIMARY KEY, f, g)%WR%;\n  INSERT INTO t7 VALUES(1, 1, 1, 1, 1, 1, 1);\n}\ndo_test $tn.9.2 { \n  sqlite3session S db main \n  S attach *\n  execsql { UPDATE t7 SET b=2, d=2 }\n} {}\ndo_changeset_test $tn.9.2 S {{UPDATE t7 0 ....X.. {{} {} i 1 {} {} i 1 i 1 {} {} {} {}} {{} {} i 2 {} {} i 2 {} {} {} {} {} {}}}}\nS delete\ncatch { db2 close }\n \n#-------------------------------------------------------------------------\n# Test a really long table name.\n#\nreset_db\nset tblname [string repeat tblname123 100]\ndo_test $tn.10.1.1 {\n  execsql \"\n    CREATE TABLE $tblname (a PRIMARY KEY, b)%WR%;\n    INSERT INTO $tblname VALUES('xyz', 'def');\n  \"\n  sqlite3session S db main\n  S attach $tblname\n  execsql \" \n    INSERT INTO $tblname VALUES('uvw', 'abc');\n    DELETE FROM $tblname WHERE a = 'xyz';\n  \"\n} {}\ndo_changeset_test $tn.10.1.2 S \"\n  {INSERT $tblname 0 X. {} {t uvw t abc}}\n  {DELETE $tblname 0 X. {t xyz t def} {}}\n\"\ndo_test $tn.10.1.4 { S delete } {}\n\n#---------------------------------------------------------------\nreset_db\ndo_execsql_test $tn.11.1 {\n  CREATE TABLE t1(a, b);\n}\ndo_test $tn.11.2 {\n  sqlite3session S db main\n  S attach t1\n  execsql {\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  S changeset\n} {}\n\nS delete\n\n\n#-------------------------------------------------------------------------\n# Test a really long table name.\n#\nreset_db\nset tblname [string repeat tblname123 100]\ndo_test $tn.10.1.1 {\n  execsql \"\n    CREATE TABLE $tblname (a PRIMARY KEY, b)%WR%;\n    INSERT INTO $tblname VALUES('xyz', 'def');\n  \"\n  sqlite3session S db main\n  S attach $tblname\n  execsql \" \n    INSERT INTO $tblname VALUES('uvw', 'abc');\n    DELETE FROM $tblname WHERE a = 'xyz';\n  \"\n} {}\ndo_changeset_test $tn.10.1.2 S \"\n  {INSERT $tblname 0 X. {} {t uvw t abc}}\n  {DELETE $tblname 0 X. {t xyz t def} {}}\n\"\ndo_test $tn.10.1.4 { S delete } {}\n\n#-------------------------------------------------------------------------\n# Test the effect of updating a column from 0.0 to 0.0.\n#\nreset_db\ndo_execsql_test $tn.11.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b REAL)%WR%;\n  INSERT INTO t1 VALUES(1, 0.0);\n}\ndo_iterator_test $tn.11.2 * {\n  UPDATE t1 SET b = 0.0;\n} {\n}\n\nreset_db\ndo_execsql_test $tn.12.1 {\n  CREATE TABLE t1(r INTEGER PRIMARY KEY, a, b)%WR%;\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1 VALUES(1, 1, 1);\n  INSERT INTO t1 VALUES(2, 1, 2);\n  INSERT INTO t1 VALUES(3, 1, 3);\n}\n\ndo_iterator_test $tn.12.2 * {\n  UPDATE t1 SET b='one' WHERE a=1;\n} {\n  {UPDATE t1 0 X.. {i 1 {} {} i 1} {{} {} {} {} t one}}\n  {UPDATE t1 0 X.. {i 2 {} {} i 2} {{} {} {} {} t one}}\n  {UPDATE t1 0 X.. {i 3 {} {} i 3} {{} {} {} {} t one}}\n}\n\n}]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session2.test",
    "content": "# 2011 Mar 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the session module.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session2\n\nproc test_reset {} {\n  catch { db close }\n  catch { db2 close }\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  sqlite3 db2 test.db2\n}\n\n##########################################################################\n# End of proc definitions. Start of tests.\n##########################################################################\n\ntest_reset\ndo_execsql_test 1.0 { \n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('i', 'one');\n}\ndo_iterator_test 1.1 t1 {\n  DELETE FROM t1 WHERE a = 'i';\n  INSERT INTO t1 VALUES('ii', 'two');\n} {\n  {DELETE t1 0 X. {t i t one} {}} \n  {INSERT t1 0 X. {} {t ii t two}}\n}\n\ndo_iterator_test 1.2 t1 {\n  INSERT INTO t1 VALUES(1.5, 99.9)\n} {\n  {INSERT t1 0 X. {} {f 1.5 f 99.9}}\n}\n\ndo_iterator_test 1.3 t1 {\n  UPDATE t1 SET b = 100.1 WHERE a = 1.5;\n  UPDATE t1 SET b = 99.9 WHERE a = 1.5;\n} { }\n\ndo_iterator_test 1.4 t1 {\n  UPDATE t1 SET b = 100.1 WHERE a = 1.5;\n} {\n  {UPDATE t1 0 X. {f 1.5 f 99.9} {{} {} f 100.1}}\n}\n\n\n# Execute each of the following blocks of SQL on database [db1]. Collect\n# changes using a session object. Apply the resulting changeset to\n# database [db2]. Then check that the contents of the two databases are\n# identical.\n#\n\nset set_of_tests {\n  1 { INSERT INTO %T1% VALUES(1, 2) } \n\n  2 {\n    INSERT INTO %T2% VALUES(1, NULL);\n    INSERT INTO %T2% VALUES(2, NULL);\n    INSERT INTO %T2% VALUES(3, NULL);\n    DELETE FROM %T2% WHERE a = 2;\n    INSERT INTO %T2% VALUES(4, NULL);\n    UPDATE %T2% SET b=0 WHERE b=1;\n  } \n\n  3 { INSERT INTO %T3% SELECT *, NULL FROM %T2% }\n\n  4 {\n    INSERT INTO %T3% SELECT a||a, b||b, NULL FROM %T3%;\n    DELETE FROM %T3% WHERE rowid%2;\n  }\n\n  5 { UPDATE %T3% SET c = a||b }\n\n  6 { UPDATE %T1% SET a = 32 }\n\n  7 { \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%; \n    DELETE FROM %T1% WHERE (rowid%3)==0;\n  }\n\n  8 {\n    BEGIN;\n      INSERT INTO %T1% SELECT randomblob(32), randomblob(32) FROM %T1%;\n    ROLLBACK;\n  }\n  9 {\n    BEGIN;\n      UPDATE %T1% SET b = 'xxx';\n    ROLLBACK;\n  }\n  10 {\n    BEGIN;\n      DELETE FROM %T1% WHERE 1;\n    ROLLBACK;\n  }\n  11 {\n    INSERT INTO %T1% VALUES(randomblob(21000), randomblob(0));\n    INSERT INTO %T1% VALUES(1.5, 1.5);\n    INSERT INTO %T1% VALUES(4.56, -99.999999999999999999999);\n  }\n  12 {\n    INSERT INTO %T2% VALUES(NULL, NULL);\n  }\n\n  13 {\n    DELETE FROM %T1% WHERE 1;\n\n    -- Insert many rows with real primary keys. Enough to force the session\n    -- objects hash table to resize. \n    INSERT INTO %T1% VALUES(0.1, 0.1);\n    INSERT INTO %T1% SELECT a+0.1, b+0.1 FROM %T1%;\n    INSERT INTO %T1% SELECT a+0.2, b+0.2 FROM %T1%;\n    INSERT INTO %T1% SELECT a+0.4, b+0.4 FROM %T1%;\n    INSERT INTO %T1% SELECT a+0.8, b+0.8 FROM %T1%;\n    INSERT INTO %T1% SELECT a+1.6, b+1.6 FROM %T1%;\n    INSERT INTO %T1% SELECT a+3.2, b+3.2 FROM %T1%;\n    INSERT INTO %T1% SELECT a+6.4, b+6.4 FROM %T1%;\n    INSERT INTO %T1% SELECT a+12.8, b+12.8 FROM %T1%;\n    INSERT INTO %T1% SELECT a+25.6, b+25.6 FROM %T1%;\n    INSERT INTO %T1% SELECT a+51.2, b+51.2 FROM %T1%;\n    INSERT INTO %T1% SELECT a+102.4, b+102.4 FROM %T1%;\n    INSERT INTO %T1% SELECT a+204.8, b+204.8 FROM %T1%;\n  }\n\n  14 {\n    DELETE FROM %T1% WHERE 1;\n  }\n\n  15 {\n    INSERT INTO %T1% VALUES(1, 1);\n    INSERT INTO %T1% SELECT a+2, b+2 FROM %T1%;\n    INSERT INTO %T1% SELECT a+4, b+4 FROM %T1%;\n    INSERT INTO %T1% SELECT a+8, b+8 FROM %T1%;\n    INSERT INTO %T1% SELECT a+256, b+256 FROM %T1%;\n  }\n\n  16 {\n    INSERT INTO %T4% VALUES('abc', 'def');\n    INSERT INTO %T4% VALUES('def', 'abc');\n  }\n  17 { UPDATE %T4% SET b = 1 }\n\n  18 { DELETE FROM %T4% WHERE 1 }\n\n  19 { \n    INSERT INTO t1 VALUES('', '');\n    INSERT INTO t1 VALUES(X'', X'');\n  }\n  20 { \n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('', NULL);\n  }\n}\n\ntest_reset\ndo_common_sql {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(a, b INTEGER PRIMARY KEY);\n  CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b));\n  CREATE TABLE t4(a, b, PRIMARY KEY(b, a));\n}\n\nforeach {tn sql} [string map {%T1% t1 %T2% t2 %T3% t3 %T4% t4} $set_of_tests] {\n  do_then_apply_sql $sql\n  do_test 2.$tn { compare_db db db2 } {}\n}\n\n# The following block of tests is similar to the last, except that the\n# session object is recording changes made to an attached database. The\n# main database contains a table of the same name as the table being\n# modified within the attached db.\n#\ntest_reset\nforcedelete test.db3\nsqlite3 db3 test.db3\ndo_test 3.0 {\n  execsql {\n    ATTACH 'test.db3' AS 'aux';\n    CREATE TABLE t1(a, b PRIMARY KEY);\n    CREATE TABLE t2(x, y, z);\n    CREATE TABLE t3(a);\n\n    CREATE TABLE aux.t1(a PRIMARY KEY, b);\n    CREATE TABLE aux.t2(a, b INTEGER PRIMARY KEY);\n    CREATE TABLE aux.t3(a, b, c, PRIMARY KEY(a, b));\n    CREATE TABLE aux.t4(a, b, PRIMARY KEY(b, a));\n  }\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(a, b INTEGER PRIMARY KEY);\n    CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b));\n    CREATE TABLE t4(a, b, PRIMARY KEY(b, a));\n  } db2\n} {}\n\nproc xTrace {args} { puts $args }\n\nforeach {tn sql} [\n  string map {%T1% aux.t1 %T2% aux.t2 %T3% aux.t3 %T4% aux.t4} $set_of_tests\n] {\n  do_then_apply_sql $sql aux\n  do_test 3.$tn { compare_db db2 db3 } {}\n}\ncatch {db3 close}\n\n\n#-------------------------------------------------------------------------\n# The following tests verify that NULL values in primary key columns are\n# handled correctly by the session module.\n#\ntest_reset\ndo_execsql_test 4.0 {\n  CREATE TABLE t1(a PRIMARY KEY);\n  CREATE TABLE t2(a, b, c, PRIMARY KEY(c, b));\n  CREATE TABLE t3(a, b INTEGER PRIMARY KEY);\n}\n\nforeach {tn sql changeset} {\n  1 {\n    INSERT INTO t1 VALUES(123);\n    INSERT INTO t1 VALUES(NULL);\n    INSERT INTO t1 VALUES(456);\n  } {\n    {INSERT t1 0 X {} {i 456}} \n    {INSERT t1 0 X {} {i 123}}\n  }\n\n  2 {\n    UPDATE t1 SET a = NULL;\n  } {\n    {DELETE t1 0 X {i 456} {}}\n    {DELETE t1 0 X {i 123} {}}\n  }\n\n  3 { DELETE FROM t1 } { }\n\n  4 { \n    INSERT INTO t3 VALUES(NULL, NULL)\n  } {\n    {INSERT t3 0 .X {} {n {} i 1}} \n  }\n\n  5 { INSERT INTO t2 VALUES(1, 2, NULL) }    { }\n  6 { INSERT INTO t2 VALUES(1, NULL, 3) }    { }\n  7 { INSERT INTO t2 VALUES(1, NULL, NULL) } { }\n  8 { INSERT INTO t2 VALUES(1, 2, 3) }    { {INSERT t2 0 .XX {} {i 1 i 2 i 3}} }\n  9 { DELETE FROM t2 WHERE 1 }            { {DELETE t2 0 .XX {i 1 i 2 i 3} {}} }\n\n} {\n  do_iterator_test 4.$tn {t1 t2 t3} $sql $changeset\n}\n\n\n#-------------------------------------------------------------------------\n# Test that if NULL is passed to sqlite3session_attach(), all database\n# tables are attached to the session object.\n#\ntest_reset\ndo_execsql_test 5.0 {\n  CREATE TABLE t1(a PRIMARY KEY);\n  CREATE TABLE t2(x, y PRIMARY KEY);\n}\n\nforeach {tn sql changeset} {\n  1 { INSERT INTO t1 VALUES(35) }     { {INSERT t1 0 X {} {i 35}} }\n  2 { INSERT INTO t2 VALUES(36, 37) } { {INSERT t2 0 .X {} {i 36 i 37}} }\n  3 { \n    DELETE FROM t1 WHERE 1;\n    UPDATE t2 SET x = 34;\n  } { \n    {DELETE t1 0 X {i 35} {}}\n    {UPDATE t2 0 .X {i 36 i 37} {i 34 {} {}}}\n  }\n} {\n  do_iterator_test 5.$tn * $sql $changeset\n}\n\n#-------------------------------------------------------------------------\n# The next block of tests verify that the \"indirect\" flag is set \n# correctly within changesets. The indirect flag is set for a change\n# if either of the following are true:\n#\n#   * The sqlite3session_indirect() API has been used to set the session\n#     indirect flag to true, or\n#   * The change was made by a trigger.\n#\n# If the same row is updated more than once during a session, then the \n# change is considered indirect only if all changes meet the criteria \n# above.\n#\ntest_reset\ndb function indirect [list S indirect]\n\ndo_execsql_test 6.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n\n  CREATE TABLE t2(x PRIMARY KEY, y);\n  CREATE TRIGGER AFTER INSERT ON t2 WHEN new.x%2 BEGIN\n    INSERT INTO t2 VALUES(new.x+1, NULL);\n  END;\n}\n\ndo_iterator_test 6.1.1 * {\n  INSERT INTO t1 VALUES(1, 'one', 'i');\n  SELECT indirect(1);\n  INSERT INTO t1 VALUES(2, 'two', 'ii');\n  SELECT indirect(0);\n  INSERT INTO t1 VALUES(3, 'three', 'iii');\n} {\n  {INSERT t1 0 X.. {} {i 1 t one t i}}\n  {INSERT t1 1 X.. {} {i 2 t two t ii}}\n  {INSERT t1 0 X.. {} {i 3 t three t iii}}\n}\n\ndo_iterator_test 6.1.2 * {\n  SELECT indirect(1);\n  UPDATE t1 SET c = 'I' WHERE a = 1;\n  SELECT indirect(0);\n} {\n  {UPDATE t1 1 X.. {i 1 {} {} t i} {{} {} {} {} t I}}\n}\ndo_iterator_test 6.1.3 * {\n  SELECT indirect(1);\n  UPDATE t1 SET c = '.' WHERE a = 1;\n  SELECT indirect(0);\n  UPDATE t1 SET c = 'o' WHERE a = 1;\n} {\n  {UPDATE t1 0 X.. {i 1 {} {} t I} {{} {} {} {} t o}}\n}\ndo_iterator_test 6.1.4 * {\n  SELECT indirect(0);\n  UPDATE t1 SET c = 'x' WHERE a = 1;\n  SELECT indirect(1);\n  UPDATE t1 SET c = 'i' WHERE a = 1;\n} {\n  {UPDATE t1 0 X.. {i 1 {} {} t o} {{} {} {} {} t i}}\n}\ndo_iterator_test 6.1.4 * {\n  SELECT indirect(1);\n  UPDATE t1 SET c = 'y' WHERE a = 1;\n  SELECT indirect(1);\n  UPDATE t1 SET c = 'I' WHERE a = 1;\n} {\n  {UPDATE t1 1 X.. {i 1 {} {} t i} {{} {} {} {} t I}}\n}\n\ndo_iterator_test 6.1.5 * {\n  INSERT INTO t2 VALUES(1, 'x');\n} {\n  {INSERT t2 0 X. {} {i 1 t x}}\n  {INSERT t2 1 X. {} {i 2 n {}}}\n}\n\ndo_iterator_test 6.1.6 * {\n  SELECT indirect(1);\n  INSERT INTO t2 VALUES(3, 'x');\n  SELECT indirect(0);\n  UPDATE t2 SET y = 'y' WHERE x>2;\n} {\n  {INSERT t2 0 X. {} {i 3 t y}}\n  {INSERT t2 0 X. {} {i 4 t y}}\n}\n\ndo_iterator_test 6.1.7 * {\n  SELECT indirect(1);\n  DELETE FROM t2 WHERE x = 4;\n  SELECT indirect(0);\n  INSERT INTO t2 VALUES(4, 'new');\n} {\n  {UPDATE t2 0 X. {i 4 t y} {{} {} t new}}\n}\n\ndo_iterator_test 6.1.8 * {\n  CREATE TABLE t3(a, b PRIMARY KEY);\n  CREATE TABLE t4(a, b PRIMARY KEY);\n  CREATE TRIGGER t4t AFTER UPDATE ON t4 BEGIN\n    UPDATE t3 SET a = new.a WHERE b = new.b;\n  END;\n\n  SELECT indirect(1);\n  INSERT INTO t3 VALUES('one', 1);\n  INSERT INTO t4 VALUES('one', 1);\n  SELECT indirect(0);\n  UPDATE t4 SET a = 'two' WHERE b = 1;\n} {\n  {INSERT t3 1 .X {} {t two i 1}}\n  {INSERT t4 0 .X {} {t two i 1}} \n}\n\nsqlite3session S db main\ndo_execsql_test 6.2.1 {\n  SELECT indirect(0);\n  SELECT indirect(-1);\n  SELECT indirect(45);\n  SELECT indirect(-100);\n} {0 0 1 1}\nS delete\n\n#-------------------------------------------------------------------------\n# Test that if a conflict-handler that has been passed either NOTFOUND or\n# CONSTRAINT returns REPLACE - the sqlite3changeset_apply() call returns\n# MISUSE and rolls back any changes made so far.\n#\n#   7.1.*: NOTFOUND conflict-callback.\n#   7.2.*: CONSTRAINT conflict-callback.\n#\nproc xConflict {args} {return REPLACE}\ntest_reset\n\ndo_execsql_test 7.1.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n}\ndo_test 7.1.2 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b NOT NULL);\n    INSERT INTO t1 VALUES(1, 'one');\n  } db2\n} {}\ndo_test 7.1.3 {\n  set changeset [changeset_from_sql {\n    UPDATE t1 SET b = 'five' WHERE a = 1;\n    UPDATE t1 SET b = 'six' WHERE a = 2;\n  }]\n  set x [list]\n  sqlite3session_foreach c $changeset { lappend x $c }\n  set x\n} [list \\\n  {UPDATE t1 0 X. {i 1 t one} {{} {} t five}} \\\n  {UPDATE t1 0 X. {i 2 t two} {{} {} t six}}  \\\n]\ndo_test 7.1.4 {\n  list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg\n} {1 SQLITE_MISUSE}\ndo_test 7.1.5 { execsql { SELECT * FROM t1 } db2 } {1 one}\n\ndo_test 7.2.1 {\n  set changeset [changeset_from_sql { UPDATE t1 SET b = NULL WHERE a = 1 }]\n\n  set x [list]\n  sqlite3session_foreach c $changeset { lappend x $c }\n  set x\n} [list \\\n  {UPDATE t1 0 X. {i 1 t five} {{} {} n {}}} \\\n]\ndo_test 7.2.2 {\n  list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg\n} {1 SQLITE_MISUSE}\ndo_test 7.2.3 { execsql { SELECT * FROM t1 } db2 } {1 one}\n\n#-------------------------------------------------------------------------\n# Test that if a conflict-handler returns ABORT, application of the \n# changeset is rolled back and the sqlite3changeset_apply() method returns\n# SQLITE_ABORT.\n#\n# Also test that the same thing happens if a conflict handler returns an\n# unrecognized integer value. Except, in this case SQLITE_MISUSE is returned\n# instead of SQLITE_ABORT.\n#\nforeach {tn conflict_return apply_return} {\n  1    ABORT   SQLITE_ABORT\n  2    567     SQLITE_MISUSE\n} {\n  test_reset\n  proc xConflict {args} [list return $conflict_return]\n\n  do_test 8.$tn.0 {\n    do_common_sql { \n      CREATE TABLE t1(x, y, PRIMARY KEY(x, y));\n      INSERT INTO t1 VALUES('x', 'y');\n    }\n    execsql { INSERT INTO t1 VALUES('w', 'w') }\n\n    set changeset [changeset_from_sql { DELETE FROM t1 WHERE 1 }]\n\n    set x [list]\n    sqlite3session_foreach c $changeset { lappend x $c }\n    set x\n  } [list \\\n    {DELETE t1 0 XX {t w t w} {}} \\\n    {DELETE t1 0 XX {t x t y} {}} \\\n  ]\n\n  do_test 8.$tn.1 {\n    list [catch {sqlite3changeset_apply db2 $changeset xConflict} msg] $msg\n  } [list 1 $apply_return]\n\n  do_test 8.$tn.2 {\n    execsql {SELECT * FROM t1} db2\n  } {x y}\n}\n\n\n#-------------------------------------------------------------------------\n# Try to cause an infinite loop as follows:\n#\n#   1. Have a changeset insert a row that causes a CONFLICT callback,\n#   2. Have the conflict handler return REPLACE,\n#   3. After the session module deletes the conflicting row, have a trigger\n#      re-insert it.\n#   4. Goto step 1...\n#\n# This doesn't work, as the second invocation of the conflict handler is a\n# CONSTRAINT, not a CONFLICT. There is at most one CONFLICT callback for\n# each change in the changeset.\n#\ntest_reset\nproc xConflict {type args} { \n  if {$type == \"CONFLICT\"} { return REPLACE }\n  return OMIT\n}\ndo_test 9.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n  }\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES('x', 2);\n    CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN\n      INSERT INTO t1 VALUES(old.a, old.b);\n    END;\n  } db2\n} {}\ndo_test 9.2 {\n  set changeset [changeset_from_sql { INSERT INTO t1 VALUES('x', 1) }]\n  sqlite3changeset_apply db2 $changeset xConflict\n} {}\ndo_test 9.3 {\n  execsql { SELECT * FROM t1 } db2\n} {x 2}\n\n#-------------------------------------------------------------------------\n#\ntest_reset\ndb function enable [list S enable]\n\ndo_common_sql {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('x', 'X');\n}\n\ndo_iterator_test 10.1 t1 {\n  INSERT INTO t1 VALUES('y', 'Y');\n  SELECT enable(0);\n  INSERT INTO t1 VALUES('z', 'Z');\n  SELECT enable(1);\n} {\n  {INSERT t1 0 X. {} {t y t Y}}\n}\n\nsqlite3session S db main\ndo_execsql_test 10.2 {\n  SELECT enable(0);\n  SELECT enable(-1);\n  SELECT enable(1);\n  SELECT enable(-1);\n} {0 0 1 1}\nS delete\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session3.test",
    "content": "# 2011 March 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for the session module. More\n# specifically, it focuses on testing the session modules response to\n# database schema modifications and mismatches.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session3\n\n#-------------------------------------------------------------------------\n# These tests - session3-1.* - verify that the session module behaves\n# correctly when confronted with a schema mismatch when applying a \n# changeset (in function sqlite3changeset_apply()).\n#\n#   session3-1.1.*: Table does not exist in target db.\n#   session3-1.2.*: Table has wrong number of columns in target db.\n#   session3-1.3.*: Table has wrong PK columns in target db.\n#\ndb close\nsqlite3_shutdown\ntest_sqlite3_log log\nsqlite3 db test.db\n\nproc log {code msg} { lappend ::log $code $msg }\n\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n}\ndo_test 1.1 {\n  set ::log {}\n  do_then_apply_sql {\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  set ::log\n} {SQLITE_SCHEMA {sqlite3changeset_apply(): no such table: t1}}\n\ndo_test 1.2.0 {\n  execsql { CREATE TABLE t1(a PRIMARY KEY, b, c) } db2\n} {}\ndo_test 1.2.1 {\n  set ::log {}\n  do_then_apply_sql {\n    INSERT INTO t1 VALUES(5, 6);\n    INSERT INTO t1 VALUES(7, 8);\n  }\n  set ::log\n} {}\ndo_test 1.2.2 {\n  db2 eval { SELECT * FROM t1 }\n} {5 6 {} 7 8 {}}\n\ndo_test 1.3.0 {\n  execsql { \n    DROP TABLE t1;\n    CREATE TABLE t1(a, b PRIMARY KEY);\n  } db2\n} {}\ndo_test 1.3.1 {\n  set ::log {}\n  do_then_apply_sql {\n    INSERT INTO t1 VALUES(9, 10);\n    INSERT INTO t1 VALUES(11, 12);\n  }\n  set ::log\n} {SQLITE_SCHEMA {sqlite3changeset_apply(): primary key mismatch for table t1}}\n\n#-------------------------------------------------------------------------\n# These tests - session3-2.* - verify that the session module behaves\n# correctly when the schema of an attached table is modified during the\n# session.\n#\n#   session3-2.1.*: Table is dropped midway through the session.\n#   session3-2.2.*: Table is dropped and recreated with a different # cols.\n#   session3-2.3.*: Table is dropped and recreated with a different PK.\n#\n# In all of these scenarios, the call to sqlite3session_changeset() will\n# return SQLITE_SCHEMA. Also:\n#   \n#   session3-2.4.*: Table is dropped and recreated with an identical schema.\n#                   In this case sqlite3session_changeset() returns SQLITE_OK.\n#\n\ndo_test 2.1 {\n  execsql { CREATE TABLE t2(a, b PRIMARY KEY) }\n  sqlite3session S db main\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2);\n    DROP TABLE t2;\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\n\ndo_test 2.2.1 {\n  S delete\n  sqlite3session S db main\n  execsql { CREATE TABLE t2(a, b PRIMARY KEY, c) }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2, 3);\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY);\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\ndo_test 2.2.2 {\n  S delete\n  sqlite3session S db main\n  execsql { \n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY, c);\n  }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2, 3);\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY, c, d);\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\ndo_test 2.2.3 {\n  S delete\n  sqlite3session S db main\n  execsql { \n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY, c);\n  }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2, 3);\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY);\n    INSERT INTO t2 VALUES(4, 5);\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\ndo_test 2.2.4 {\n  S delete\n  sqlite3session S db main\n  execsql { \n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY, c);\n  }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2, 3);\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY, c, d);\n    INSERT INTO t2 VALUES(4, 5, 6, 7);\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\n\ndo_test 2.3 {\n  S delete\n  sqlite3session S db main\n  execsql { \n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY);\n  }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2);\n    DROP TABLE t2;\n    CREATE TABLE t2(a PRIMARY KEY, b);\n  }\n  list [catch { S changeset } msg] $msg\n} {1 SQLITE_SCHEMA}\n\ndo_test 2.4 {\n  S delete\n  sqlite3session S db main\n  execsql { \n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY);\n  }\n  S attach t2\n  execsql {\n    INSERT INTO t2 VALUES(1, 2);\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b PRIMARY KEY);\n  }\n  list [catch { S changeset } msg] $msg\n} {0 {}}\n\nS delete\n\n\ncatch { db close }\ncatch { db2 close }\nsqlite3_shutdown\ntest_sqlite3_log\nsqlite3_initialize\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session4.test",
    "content": "# 2011 March 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for the session module. \n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session4\n\ndo_test 1.0 {\n  execsql {\n    CREATE TABLE x(a, b, c, d, e, PRIMARY KEY(c, e));\n    INSERT INTO x VALUES(65.21, X'28B0', 16.35, NULL, 'doers');\n    INSERT INTO x VALUES(NULL, 78.49, 2, X'60', -66);\n    INSERT INTO x VALUES('cathedral', NULL, 35, NULL, X'B220937E80A2D8');\n    INSERT INTO x VALUES(NULL, 'masking', -91.37, NULL, X'596D');\n    INSERT INTO x VALUES(19, 'domains', 'espouse', -94, 'throw');\n  }\n\n  set changeset [changeset_from_sql {\n    DELETE FROM x WHERE e = -66;\n    UPDATE x SET a = 'parameterizable', b = 31.8 WHERE c = 35;\n    INSERT INTO x VALUES(-75.61, -17, 16.85, NULL, X'D73DB02678');\n  }]\n  set {} {}\n} {}\n\n\n# This currently causes crashes. sqlite3changeset_invert() does not handle\n# corrupt changesets well.\nif 0 {\n  do_test 1.1 {\n    for {set i 0} {$i < [string length $changeset]} {incr i} {\n      set before [string range $changeset 0 [expr $i-1]]\n      set after  [string range $changeset [expr $i+1] end]\n      for {set j 10} {$j < 260} {incr j} {\n        set x [binary format \"a*ca*\" $before $j $after]\n        catch { sqlite3changeset_invert $x }\n      }\n    }\n  } {}\n}\n\ndo_test 1.2 {\n  set x [binary format \"ca*\" 0 [string range $changeset 1 end]]\n  list [catch { sqlite3changeset_invert $x } msg] $msg\n} {1 SQLITE_CORRUPT}\n\ndo_test 1.3 {\n  set x [binary format \"ca*\" 0 [string range $changeset 1 end]]\n  list [catch { sqlite3changeset_apply db $x xConflict } msg] $msg\n} {1 SQLITE_CORRUPT}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session5.test",
    "content": "# 2011 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for the session module. \n# Specifically, for the sqlite3changeset_concat() command.\n# \n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session5\n\n# Organization of tests:\n#\n#   session5-1.*: Simple tests to check the concat() function produces \n#                 correct results.\n#\n#   session5-2.*: More complicated tests.\n#   \n#   session5-3.*: Schema mismatch errors.\n#\n#   session5-4.*: Test the concat cases that indicate that the database\n#                 was modified in between recording of the two changesets\n#                 being concatenated (i.e. two changesets that INSERT rows\n#                 with the same PK values).\n#\n\nproc do_concat_test {tn args} {\n\n  set subtest 0\n  foreach sql $args {\n    incr subtest\n    sqlite3session S db main ; S attach *\n    execsql $sql\n\n    set c [S changeset]\n    if {[info commands s_prev] != \"\"} {\n      set c_concat [sqlite3changeset_concat $c_prev $c]\n      set c_two [s_prev changeset]\n      s_prev delete\n\n      set h_concat [changeset_to_list $c_concat]\n      set h_two [changeset_to_list $c_two]\n\n      do_test $tn.$subtest [list set {} $h_concat] $h_two\n    }\n    set c_prev $c\n    rename S s_prev\n  }\n\n  catch { s_prev delete }\n}\n\n#-------------------------------------------------------------------------\n# Test cases session5-1.* - simple tests.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n}\n\ndo_concat_test 1.1.1 {\n  INSERT INTO t1 VALUES(1, 'one');\n} {\n  INSERT INTO t1 VALUES(2, 'two');\n}\n\ndo_concat_test 1.1.2 {\n  UPDATE t1 SET b = 'five' WHERE a = 1;\n} {\n  UPDATE t1 SET b = 'six' WHERE a = 2;\n}\n\ndo_concat_test 1.1.3 {\n  DELETE FROM t1 WHERE a = 1;\n} {\n  DELETE FROM t1 WHERE a = 2;\n}\n\n\n# 1.2.1:    INSERT + DELETE                     -> (none)\n# 1.2.2:    INSERT + UPDATE                     -> INSERT\n#\n# 1.2.3:    DELETE + INSERT (matching data)     -> (none)\n# 1.2.4:    DELETE + INSERT (non-matching data) -> UPDATE\n#\n# 1.2.5:    UPDATE + UPDATE (matching data)     -> (none)\n# 1.2.6:    UPDATE + UPDATE (non-matching data) -> UPDATE\n# 1.2.7:    UPDATE + DELETE                     -> DELETE\n#\ndo_concat_test 1.2.1 {\n  INSERT INTO t1 VALUES('x', 'y');\n} {\n  DELETE FROM t1 WHERE a = 'x';\n}\ndo_concat_test 1.2.2 {\n  INSERT INTO t1 VALUES(5.0, 'five');\n} {\n  UPDATE t1 SET b = 'six' WHERE a = 5.0;\n}\n\ndo_execsql_test 1.2.3.1 \"INSERT INTO t1 VALUES('I', 'one')\"\ndo_concat_test 1.2.3.2 {\n  DELETE FROM t1 WHERE a = 'I';\n} {\n  INSERT INTO t1 VALUES('I', 'one');\n}\ndo_concat_test 1.2.4 {\n  DELETE FROM t1 WHERE a = 'I';\n} {\n  INSERT INTO t1 VALUES('I', 'two');\n}\ndo_concat_test 1.2.5 {\n  UPDATE t1 SET b = 'five' WHERE a = 'I';\n} {\n  UPDATE t1 SET b = 'two' WHERE a = 'I';\n}\ndo_concat_test 1.2.6 {\n  UPDATE t1 SET b = 'six' WHERE a = 'I';\n} {\n  UPDATE t1 SET b = 'seven' WHERE a = 'I';\n}\ndo_concat_test 1.2.7 {\n  UPDATE t1 SET b = 'eight' WHERE a = 'I';\n} {\n  DELETE FROM t1 WHERE a = 'I';\n}\n\n\n#-------------------------------------------------------------------------\n# Test cases session5-2.* - more complex tests.\n#\ndb function indirect indirect \nproc indirect {{x -1}} {\n  S indirect $x\n  s_prev indirect $x\n}\ndo_concat_test 2.1 {\n  CREATE TABLE abc(a, b, c PRIMARY KEY);\n  INSERT INTO abc VALUES(NULL, NULL, 1);\n  INSERT INTO abc VALUES('abcdefghijkl', NULL, 2);\n} {\n  DELETE FROM abc WHERE c = 1;\n  UPDATE abc SET c = 1 WHERE c = 2;\n} {\n  INSERT INTO abc VALUES('abcdefghijkl', NULL, 2);\n  INSERT INTO abc VALUES(1.0, 2.0, 3);\n} {\n  UPDATE abc SET a = a-1;\n} {\n  CREATE TABLE def(d, e, f, PRIMARY KEY(e, f));\n  INSERT INTO def VALUES('x', randomblob(11000), 67);\n  INSERT INTO def SELECT d, e, f+1 FROM def;\n  INSERT INTO def SELECT d, e, f+2 FROM def;\n  INSERT INTO def SELECT d, e, f+4 FROM def;\n} {\n  DELETE FROM def WHERE rowid>4;\n} { \n  INSERT INTO def SELECT d, e, f+4 FROM def; \n} {\n  INSERT INTO abc VALUES(22, 44, -1);\n} { \n  UPDATE abc SET c=-2 WHERE c=-1;\n  UPDATE abc SET c=-3 WHERE c=-2;\n} {\n  UPDATE abc SET c=-4 WHERE c=-3;\n} {\n  UPDATE abc SET a=a+1 WHERE c=-3;\n  UPDATE abc SET a=a+1 WHERE c=-3;\n} {\n  UPDATE abc SET a=a+1 WHERE c=-3;\n  UPDATE abc SET a=a+1 WHERE c=-3;\n} {\n  INSERT INTO abc VALUES('one', 'two', 'three');\n} {\n  SELECT indirect(1);\n  UPDATE abc SET a='one point five' WHERE c = 'three';\n} {\n  SELECT indirect(0);\n  UPDATE abc SET a='one point six' WHERE c = 'three';\n} {\n  CREATE TABLE x1(a, b, PRIMARY KEY(a));\n  SELECT indirect(1);\n  INSERT INTO x1 VALUES(1, 2);\n} {\n  SELECT indirect(1);\n  UPDATE x1 SET b = 3 WHERE a = 1;\n}\n\ncatch {db close}\nforcedelete test.db\nsqlite3 db test.db\ndo_concat_test 2.2 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(b));\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('string', 1);\n  INSERT INTO t1 VALUES(4, 2);\n  INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);\n} {\n  INSERT INTO t2 VALUES('one', 'two');\n  INSERT INTO t2 VALUES(1, NULL);\n  UPDATE t1 SET a = 5 WHERE a = 2;\n} {\n  DELETE FROM t2 WHERE a = 1;\n  UPDATE t1 SET a = 4 WHERE a = 2;\n  INSERT INTO t2 VALUES('x', 'y');\n}\n\ndo_test 2.3.0 {\n  catch {db close}\n  forcedelete test.db\n  sqlite3 db test.db\n \n  set sql1 \"\"\n  set sql2 \"\"\n  for {set i 1} {$i < 120} {incr i} {\n    append sql1 \"INSERT INTO x1 VALUES($i*4, $i);\"\n  }\n  for {set i 1} {$i < 120} {incr i} {\n    append sql2 \"DELETE FROM x1 WHERE a = $i*4;\"\n  }\n  set {} {}\n} {}\ndo_concat_test 2.3 {\n  CREATE TABLE x1(a PRIMARY KEY, b)\n} $sql1 $sql2 $sql1 $sql2\n\ndo_concat_test 2.4 {\n  CREATE TABLE x2(a PRIMARY KEY, b);\n  CREATE TABLE x3(a PRIMARY KEY, b);\n\n  INSERT INTO x2 VALUES('a', 'b');\n  INSERT INTO x2 VALUES('x', 'y');\n  INSERT INTO x3 VALUES('a', 'b');\n} {\n  INSERT INTO x2 VALUES('c', 'd');\n  INSERT INTO x3 VALUES('e', 'f');\n  INSERT INTO x3 VALUES('x', 'y');\n}\n\ndo_concat_test 2.5 {\n  UPDATE x3 SET b = 'Y' WHERE a = 'x'\n} {\n  DELETE FROM x3 WHERE a = 'x'\n} {\n  DELETE FROM x2 WHERE a = 'a'\n} {\n  INSERT INTO x2 VALUES('a', 'B');\n}\n\nfor {set k 1} {$k <=10} {incr k} {\n  do_test 2.6.$k.1 {\n    drop_all_tables\n    set sql1 \"\"\n    set sql2 \"\"\n    for {set i 1} {$i < 120} {incr i} {\n      append sql1 \"INSERT INTO x1 VALUES(randomblob(20+(random()%10)), $i);\"\n    }\n    for {set i 1} {$i < 120} {incr i} {\n      append sql2 \"DELETE FROM x1 WHERE rowid = $i;\"\n    }\n    set {} {}\n  } {}\n  do_concat_test 2.6.$k {\n    CREATE TABLE x1(a PRIMARY KEY, b)\n  } $sql1 $sql2 $sql1 $sql2\n}\n\nfor {set k 1} {$k <=10} {incr k} {\n  do_test 2.7.$k.1 {\n    drop_all_tables\n    set sql1 \"\"\n    set sql2 \"\"\n    for {set i 1} {$i < 120} {incr i} {\n      append sql1 {\n        INSERT INTO x1 VALUES(\n         CASE WHEN random()%2 THEN random() ELSE randomblob(20+random()%10) END,\n         CASE WHEN random()%2 THEN random() ELSE randomblob(20+random()%10) END\n        );\n      }\n    }\n    for {set i 1} {$i < 120} {incr i} {\n      append sql2 \"DELETE FROM x1 WHERE rowid = $i;\"\n    }\n    set {} {}\n  } {}\n  do_concat_test 2.7.$k {\n    CREATE TABLE x1(a PRIMARY KEY, b)\n  } $sql1 $sql2 $sql1 $sql2\n}\n\n\n#-------------------------------------------------------------------------\n# Test that schema incompatibilities are detected correctly.\n#\n#   session5-3.1: Incompatible number of columns.\n#   session5-3.2: Incompatible PK definition.\n#\n\ndo_test 3.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  execsql { CREATE TABLE t1(a PRIMARY KEY, b) }\n  set c1 [changeset_from_sql { INSERT INTO t1 VALUES(1, 2) }]\n  execsql { \n    DROP TABLE t1;\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n  }\n  set c2 [changeset_from_sql { INSERT INTO t1 VALUES(2, 3, 4) }]\n\n  list [catch { sqlite3changeset_concat $c1 $c2 } msg] $msg\n} {1 SQLITE_SCHEMA}\n\ndo_test 3.2 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  execsql { CREATE TABLE t1(a PRIMARY KEY, b) }\n  set c1 [changeset_from_sql { INSERT INTO t1 VALUES(1, 2) }]\n  execsql { \n    DROP TABLE t1;\n    CREATE TABLE t1(a, b PRIMARY KEY);\n  }\n  set c2 [changeset_from_sql { INSERT INTO t1 VALUES(2, 3) }]\n\n  list [catch { sqlite3changeset_concat $c1 $c2 } msg] $msg\n} {1 SQLITE_SCHEMA}\n\n#-------------------------------------------------------------------------\n# Test that concat() handles these properly:\n#\n#   session5-4.1: INSERT + INSERT\n#   session5-4.2: UPDATE + INSERT\n#   session5-4.3: DELETE + UPDATE\n#   session5-4.4: DELETE + DELETE\n#\n\nproc do_concat_test2 {tn sql1 sqlX sql2 expected} {\n  sqlite3session S db main ; S attach *\n  execsql $sql1\n  set ::c1 [S changeset]\n  S delete\n\n  execsql $sqlX\n\n  sqlite3session S db main ; S attach *\n  execsql $sql2\n  set ::c2 [S changeset]\n  S delete\n\n  uplevel do_test $tn [list {\n    changeset_to_list [sqlite3changeset_concat $::c1 $::c2]\n  }] [list [normalize_list $expected]]\n}\n\ndrop_all_tables db\ndo_concat_test2 4.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('key', 'value');\n} {\n  DELETE FROM t1 WHERE a = 'key';\n} {\n  INSERT INTO t1 VALUES('key', 'xxx');\n} {\n  {INSERT t1 0 X. {} {t key t value}}\n}\ndo_concat_test2 4.2 {\n  UPDATE t1 SET b = 'yyy';\n} {\n  DELETE FROM t1 WHERE a = 'key';\n} {\n  INSERT INTO t1 VALUES('key', 'value');\n} {\n  {UPDATE t1 0 X. {t key t xxx} {{} {} t yyy}}\n}\ndo_concat_test2 4.3 {\n  DELETE FROM t1 WHERE a = 'key';\n} {\n  INSERT INTO t1 VALUES('key', 'www');\n} {\n  UPDATE t1 SET b = 'valueX' WHERE a = 'key';\n} {\n  {DELETE t1 0 X. {t key t value} {}}\n}\ndo_concat_test2 4.4 {\n  DELETE FROM t1 WHERE a = 'key';\n} {\n  INSERT INTO t1 VALUES('key', 'ttt');\n} {\n  DELETE FROM t1 WHERE a = 'key';\n} {\n  {DELETE t1 0 X. {t key t valueX} {}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session6.test",
    "content": "# 2011 July 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite sessions extension.\n# Specifically, it tests that sessions work when the database is modified\n# using incremental blob handles.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session6\n\nproc do_then_apply_tcl {tcl {dbname main}} {\n  proc xConflict args { return \"OMIT\" }\n  set rc [catch {\n    sqlite3session S db $dbname\n    db eval \"SELECT name FROM $dbname.sqlite_master WHERE type = 'table'\" {\n      S attach $name\n    }\n    eval $tcl\n    sqlite3changeset_apply db2 [S changeset] xConflict\n  } msg]\n\n  catch { S delete }\n  if {$rc} {error $msg}\n}\n\ntest_sqlite3_log x\nproc x {args} {puts $args}\n\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_common_sql {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(c PRIMARY KEY, d);\n}\n\n# Test a blob update.\n#\ndo_test 1.1 {\n  do_then_apply_tcl {\n    db eval { INSERT INTO t1 VALUES(1, 'helloworld') }\n    db eval { INSERT INTO t2 VALUES(2, 'onetwothree') }\n  }\n  compare_db db db2\n} {}\ndo_test 1.2 {\n  do_then_apply_tcl {\n    set fd [db incrblob t1 b 1]\n    puts -nonewline $fd 1234567890\n    close $fd\n  }\n  compare_db db db2\n} {}\n\n# Test an attached database.\n#\ndo_test 2.1 {\n  forcedelete test.db3\n  file copy test.db2 test.db3\n  execsql { ATTACH 'test.db3' AS aux; }\n\n  do_then_apply_tcl {\n    set fd [db incrblob aux t2 d 1]\n    puts -nonewline $fd fourfivesix\n    close $fd\n  } aux\n\n  sqlite3 db3 test.db3\n  compare_db db2 db3\n} {}\n\n\ndb3 close\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session8.test",
    "content": "# 2011 July 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix session8\n\nproc noop {args} {}\n\n# Like [dbcksum] in tester.tcl. Except this version is not sensitive\n# to changes in the value of implicit IPK columns.\n#\nproc udbcksum {db dbname} {\n  if {$dbname==\"temp\"} {\n    set master sqlite_temp_master\n  } else {\n    set master $dbname.sqlite_master\n  }\n  set alltab [$db eval \"SELECT name FROM $master WHERE type='table'\"]\n  set txt [$db eval \"SELECT * FROM $master\"]\\n\n  foreach tab $alltab {\n    append txt [lsort [$db eval \"SELECT * FROM $dbname.$tab\"]]\\n\n  }\n  return [md5 $txt]\n}\n\nproc do_then_undo {tn sql} {\n  set ck1 [udbcksum db main]\n\n  sqlite3session S db main\n  S attach *\n  db eval $sql\n\n  set ck2 [udbcksum db main]\n  \n  set invert [sqlite3changeset_invert [S changeset]]\n  S delete\n  sqlite3changeset_apply db $invert noop\n\n  set ck3 [udbcksum db main]\n\n  set a [expr {$ck1==$ck2}]\n  set b [expr {$ck1==$ck3}]\n  uplevel [list do_test $tn.1 \"set {} $a\" 0]\n  uplevel [list do_test $tn.2 \"set {} $b\" 1]\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(\"abc\", \"xyz\");\n}\ndo_then_undo 1.2 { INSERT INTO t1 VALUES(3, 4); }\ndo_then_undo 1.3 { DELETE FROM t1 WHERE b=2; }\ndo_then_undo 1.4 { UPDATE t1 SET b = 3 WHERE a = 1; }\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t2(a, b PRIMARY KEY);\n  INSERT INTO t2 VALUES(1, 2);\n  INSERT INTO t2 VALUES('abc', 'xyz');\n}\ndo_then_undo 1.2 { INSERT INTO t2 VALUES(3, 4); }\ndo_then_undo 1.3 { DELETE FROM t2 WHERE b=2; }\ndo_then_undo 1.4 { UPDATE t1 SET a = '123' WHERE b = 'xyz'; }\n\ndo_execsql_test 3.1 {\n  CREATE TABLE t3(a, b, c, d, e, PRIMARY KEY(c, e));\n  INSERT INTO t3 VALUES('x', 45, 0.0, 'abcdef', 12);\n  INSERT INTO t3 VALUES(45, 0.0, 'abcdef', 12, 'x');\n  INSERT INTO t3 VALUES(0.0, 'abcdef', 12, 'x', 45);\n}\n\ndo_then_undo 3.2 { UPDATE t3 SET b=b||b WHERE e!='x' }\ndo_then_undo 3.3 { UPDATE t3 SET a = 46 }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session9.test",
    "content": "# 2013 July 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that the sessions module handles foreign key constraint\n# violations when applying changesets as required.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix session9\n\n\n#--------------------------------------------------------------------\n# Basic tests.\n#\nproc populate_db {} {\n  drop_all_tables\n  execsql {\n    PRAGMA foreign_keys = 1;\n    CREATE TABLE p1(a PRIMARY KEY, b);\n    CREATE TABLE c1(a PRIMARY KEY, b REFERENCES p1);\n    CREATE TABLE c2(a PRIMARY KEY, \n        b REFERENCES p1 DEFERRABLE INITIALLY DEFERRED\n    );\n\n    INSERT INTO p1 VALUES(1, 'one');\n    INSERT INTO p1 VALUES(2, 'two');\n    INSERT INTO p1 VALUES(3, 'three');\n    INSERT INTO p1 VALUES(4, 'four');\n  }\n}\n\nproc capture_changeset {sql} {\n  sqlite3session S db main\n\n  foreach t [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n    S attach $t\n  }\n  execsql $sql\n  set ret [S changeset]\n  S delete\n\n  return $ret\n}\n\ndo_test 1.1 {\n  populate_db\n  set cc [capture_changeset {\n    INSERT INTO c1 VALUES('ii', 2);\n    INSERT INTO c2 VALUES('iii', 3);\n  }]\n  set {} {}\n} {}\n\nproc xConflict {args} {\n  lappend ::xConflict {*}$args\n  return $::conflictret\n}\n\nforeach {tn delrow trans conflictargs conflictret} {\n  1   2 0 {FOREIGN_KEY 1} OMIT\n  2   3 0 {FOREIGN_KEY 1} OMIT\n  3   2 1 {FOREIGN_KEY 1} OMIT\n  4   3 1 {FOREIGN_KEY 1} OMIT\n  5   2 0 {FOREIGN_KEY 1} ABORT\n  6   3 0 {FOREIGN_KEY 1} ABORT\n  7   2 1 {FOREIGN_KEY 1} ABORT\n  8   3 1 {FOREIGN_KEY 1} ABORT\n} {\n\n  set A(OMIT)  {0 {}}\n  set A(ABORT) {1 SQLITE_CONSTRAINT}\n  do_test 1.2.$tn.1 {\n    populate_db\n    execsql { DELETE FROM p1 WHERE a=($delrow+0) }\n    if {$trans} { execsql BEGIN }\n\n    set ::xConflict [list]\n    list [catch {sqlite3changeset_apply db $::cc xConflict} msg] $msg\n  } $A($conflictret)\n\n  do_test 1.2.$tn.2 { set ::xConflict } $conflictargs\n\n  set A(OMIT)  {1 1}\n  set A(ABORT) {0 0}\n  do_test 1.2.$tn.3 {\n    execsql { SELECT count(*) FROM c1 UNION ALL SELECT count(*) FROM c2 }\n  } $A($conflictret)\n\n  do_test 1.2.$tn.4 { expr ![sqlite3_get_autocommit db] } $trans\n  do_test 1.2.$tn.5 {\n    if { $trans } { execsql COMMIT }\n  } {}\n}\n\n#--------------------------------------------------------------------\n# Test that closing a transaction clears the defer_foreign_keys flag.\n#\nforeach {tn open noclose close} {\n  1 BEGIN {} COMMIT\n  2 BEGIN {} ROLLBACK\n\n  3 {SAVEPOINT one} {}                {RELEASE one}\n  4 {SAVEPOINT one} {ROLLBACK TO one} {RELEASE one}\n} {\n  execsql $open\n  do_execsql_test 2.$tn.1 { PRAGMA defer_foreign_keys } {0}\n\n  do_execsql_test 2.$tn.2 {\n    PRAGMA defer_foreign_keys = 1;\n    PRAGMA defer_foreign_keys;\n  } {1}\n\n  execsql $noclose\n  do_execsql_test 2.$tn.3 { PRAGMA defer_foreign_keys } {1}\n\n  execsql $close\n  do_execsql_test 2.$tn.4 { PRAGMA defer_foreign_keys } {0}\n}\n\n#--------------------------------------------------------------------\n# Test that a cyclic relationship can be inserted and deleted.\n#\n# This situation does not come up in practice, but testing it serves to \n# show that it does not matter which order parent and child keys \n# are processed in internally when applying a changeset.\n#\ndrop_all_tables\n\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(x PRIMARY KEY, y);\n}\n\n# Create changesets as follows:\n# \n#   $cc1    - Insert a row into t1.\n#   $cc2    - Insert a row into t2.\n#   $cc     - Combination of $cc1 and $cc2.\n#\n#   $ccdel1 - Delete the row from t1.\n#   $ccdel2 - Delete the row from t2.\n#   $ccdel  - Combination of $cc1 and $cc2.\n#\ndo_test 3.2 {\n  set cc1 [capture_changeset {\n    INSERT INTO t1 VALUES('one', 'value one');\n  }]\n  set ccdel1 [capture_changeset { DELETE FROM t1; }]\n  set cc2 [capture_changeset {\n    INSERT INTO t2 VALUES('value one', 'one');\n  }]\n  set ccdel2 [capture_changeset { DELETE FROM t2; }]\n  set cc [capture_changeset {\n    INSERT INTO t1 VALUES('one', 'value one');\n    INSERT INTO t2 VALUES('value one', 'one');\n  }]\n  set ccdel [capture_changeset {\n    DELETE FROM t1;\n    DELETE FROM t2;\n  }]\n  set {} {}\n} {}\n\n# Now modify the database schema to create a cyclic foreign key dependency\n# between tables t1 and t2. This means that although changesets $cc and\n# $ccdel can be applied, none of the others may without violating the\n# foreign key constraints. \n# \ndo_test 3.3 {\n\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t2);\n    CREATE TABLE t2(x PRIMARY KEY, y REFERENCES t1);\n  }\n\n\n  proc conflict_handler {args} { return \"ABORT\" }\n  sqlite3changeset_apply db $cc conflict_handler\n\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {one {value one} {value one} one}\n\ndo_test 3.3.1 {\n  list [catch {sqlite3changeset_apply db $::ccdel1 conflict_handler} msg] $msg\n} {1 SQLITE_CONSTRAINT}\n\ndo_test 3.3.2 {\n  list [catch {sqlite3changeset_apply db $::ccdel2 conflict_handler} msg] $msg\n} {1 SQLITE_CONSTRAINT}\n\ndo_test 3.3.4.1 {\n  list [catch {sqlite3changeset_apply db $::ccdel conflict_handler} msg] $msg\n} {0 {}}\ndo_execsql_test 3.3.4.2 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {}\n\ndo_test 3.5.1 {\n  list [catch {sqlite3changeset_apply db $::cc1 conflict_handler} msg] $msg\n} {1 SQLITE_CONSTRAINT}\ndo_test 3.5.2 {\n  list [catch {sqlite3changeset_apply db $::cc2 conflict_handler} msg] $msg\n} {1 SQLITE_CONSTRAINT}\n\n#--------------------------------------------------------------------\n# Test that if a change that affects FK processing is not applied \n# due to a separate constraint, SQLite does not get confused and\n# increment FK counters anyway.\n#\ndrop_all_tables\ndo_execsql_test 4.1 {\n  CREATE TABLE p1(x PRIMARY KEY, y);\n  CREATE TABLE c1(a PRIMARY KEY, b REFERENCES p1);\n  INSERT INTO p1 VALUES(1,1);\n}\n\ndo_execsql_test 4.2.1 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    INSERT INTO c1 VALUES('x', 'x');\n}\ndo_catchsql_test 4.2.2 { COMMIT } {1 {FOREIGN KEY constraint failed}}\ndo_catchsql_test 4.2.3 { ROLLBACK } {0 {}}\n\ndo_execsql_test 4.3.1 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    INSERT INTO c1 VALUES(1, 1);\n}\ndo_catchsql_test 4.3.2 { \n  INSERT INTO c1 VALUES(1, 'x') \n} {1 {UNIQUE constraint failed: c1.a}}\n\ndo_catchsql_test 4.3.3 { COMMIT } {0 {}}\ndo_catchsql_test 4.3.4 { BEGIN ; COMMIT } {0 {}}\n\n#--------------------------------------------------------------------\n# Test that if a DELETE change cannot be applied due to an \n# SQLITE_CONSTRAINT error thrown by a trigger program, things do not\n# go awry.\n\ndrop_all_tables\nreset_db\ndo_execsql_test 5.1 {\n  CREATE TABLE x1(x PRIMARY KEY, y);\n  CREATE TABLE x2(x PRIMARY KEY, y);\n  INSERT INTO x2 VALUES(1, 1);\n  INSERT INTO x1 VALUES(1, 1);\n}\n\nset ::cc [changeset_from_sql { DELETE FROM x1; }]\n\ndo_execsql_test 5.2 {\n  INSERT INTO x1 VALUES(1, 1);\n  CREATE TRIGGER tr1 AFTER DELETE ON x1 BEGIN\n    INSERT INTO x2 VALUES(old.x, old.y);\n  END;\n} {}\n\nproc conflict_handler {args} { return \"ABORT\" }\ndo_test 5.3 {\n  list [catch {sqlite3changeset_apply db $::cc conflict_handler} msg] $msg\n} {1 SQLITE_ABORT}\n\ndo_execsql_test 5.4 {\n  SELECT * FROM X1;\n} {1 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionA.test",
    "content": "# 2013 July 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that filter callbacks work as required.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessionA\n\n\nforcedelete test.db2\nsqlite3 db2 test.db2\nforeach {tn db} {1 db 2 db2} {\n  do_test 1.$tn.1 {\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      CREATE TABLE t2(a PRIMARY KEY, b);\n      CREATE TABLE t3(a PRIMARY KEY, b);\n    } $db\n  } {}\n}\n\nproc tbl_filter {zTbl} {\n  return $::table_filter($zTbl)\n}\n\ndo_test 2.1 {\n  set ::table_filter(t1) 1\n  set ::table_filter(t2) 0\n  set ::table_filter(t3) 1\n\n  sqlite3session S db main\n  S table_filter tbl_filter \n\n  execsql {\n    INSERT INTO t1 VALUES('a', 'b');\n    INSERT INTO t2 VALUES('c', 'd');\n    INSERT INTO t3 VALUES('e', 'f');\n  }\n\n  set changeset [S changeset]\n  S delete\n  sqlite3changeset_apply db2 $changeset xConflict\n\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  } db2\n} {a b e f}\n\n#-------------------------------------------------------------------------\n# Test that filter callbacks passed to sqlite3changeset_apply() are \n# invoked correctly.\n#\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(x PRIMARY KEY, y);\n}\n\ndo_test 3.2 {\n  execsql BEGIN\n  set ::cs [changeset_from_sql { \n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES('x', 'y');\n  }]\n  execsql ROLLBACK\n  set {} {}\n} {}\n\nproc filter {x y} { \n  return [string equal $x $y] \n}\n\ndo_test 3.3 {\n  sqlite3changeset_apply db $::cs {} [list filter t1]\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {1 2}\n\ndo_test 3.4 {\n  execsql { DELETE FROM t1 }\n  sqlite3changeset_apply db $::cs {} [list filter t2]\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {x y}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionB.test",
    "content": "# 2014 August 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for sessions SQLite extension.\n# Specifically, this file contains tests for \"patchset\" changes.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionB\n\n#\n# 1.*: Test that the blobs returned by the session_patchset() API are \n#      as expected. Also the sqlite3_changeset_iter functions.\n#\n# 2.*: Test that patchset blobs are handled by sqlite3changeset_apply().\n#\n# 3.*: Test that sqlite3changeset_invert() works with patchset blobs. \n#      Correct behaviour is to return SQLITE_CORRUPT.\n\nproc do_sql2patchset_test {tn sql res} {\n  sqlite3session S db main\n  S attach *\n  execsql $sql\n  uplevel [list do_patchset_test $tn S $res]\n  S delete\n}\n\n#-------------------------------------------------------------------------\n# Run simple tests of the _patchset() API.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, d, PRIMARY KEY(d, a));\n  INSERT INTO t1 VALUES(1, 2, 3, 4);\n  INSERT INTO t1 VALUES(5, 6, 7, 8);\n  INSERT INTO t1 VALUES(9, 10, 11, 12);\n}\n\ndo_test 1.1 {\n  sqlite3session S db main\n  S attach t1\n  execsql {\n    INSERT INTO t1 VALUES('w', 'x', 'y', 'z');\n    DELETE FROM t1 WHERE d=4;\n    UPDATE t1 SET c = 14 WHERE a=5;\n  }\n} {}\n\ndo_patchset_test 1.2 S {\n  {UPDATE t1 0 X..X {i 5 {} {} {} {} i 8} {{} {} {} {} i 14 {} {}}}\n  {INSERT t1 0 X..X {} {t w t x t y t z}}\n  {DELETE t1 0 X..X {i 1 {} {} {} {} i 4} {}}\n}\n\ndo_test 1.3 {\n  S delete\n} {}\n\ndo_sql2patchset_test 1.4 {\n  DELETE FROM t1;\n} {\n  {DELETE t1 0 X..X {i 5 {} {} {} {} i 8} {}}\n  {DELETE t1 0 X..X {t w {} {} {} {} t z} {}}\n  {DELETE t1 0 X..X {i 9 {} {} {} {} i 12} {}}\n}\n\ndo_sql2patchset_test 1.5 {\n  INSERT INTO t1 VALUES(X'61626364', NULL, NULL, 4.2);\n  INSERT INTO t1 VALUES(4.2, NULL, NULL, X'61626364');\n} {\n  {INSERT t1 0 X..X {} {f 4.2 n {} n {} b abcd}} \n  {INSERT t1 0 X..X {} {b abcd n {} n {} f 4.2}}\n}\n\ndo_sql2patchset_test 1.6 {\n  UPDATE t1 SET b=45 WHERE typeof(a)=='blob';\n  UPDATE t1 SET c='zzzz' WHERE typeof(a)!='blob';\n} {\n  {UPDATE t1 0 X..X {f 4.2 {} {} {} {} b abcd} {{} {} {} {} t zzzz {} {}}}\n  {UPDATE t1 0 X..X {b abcd {} {} {} {} f 4.2} {{} {} i 45 {} {} {} {}}}\n}\n\ndo_sql2patchset_test 1.7 {\n  UPDATE t1 SET b='xyz' WHERE typeof(a)=='blob';\n  UPDATE t1 SET c='xyz' WHERE typeof(a)!='blob';\n  UPDATE t1 SET b=45 WHERE typeof(a)=='blob';\n  UPDATE t1 SET c='zzzz' WHERE typeof(a)!='blob';\n} {\n}\n\ndo_sql2patchset_test 1.8 {\n  DELETE FROM t1;\n} {\n  {DELETE t1 0 X..X {f 4.2 {} {} {} {} b abcd} {}} \n  {DELETE t1 0 X..X {b abcd {} {} {} {} f 4.2} {}}\n}\n\n#-------------------------------------------------------------------------\n# Run simple tests of _apply() with patchset objects.\n#\nreset_db\n\nproc noop {args} { error $args }\nproc exec_rollback_replay {sql} {\n  sqlite3session S db main\n  S attach *\n  execsql BEGIN\n  execsql $sql\n  set patchset [S patchset]\n  S delete\n  execsql ROLLBACK\n  sqlite3changeset_apply db $patchset noop\n}\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a, b, c, d, PRIMARY KEY(b,c));\n  CREATE TABLE t3(w, x, y, z, PRIMARY KEY(w));\n}\n\ndo_test 2.1 {\n  exec_rollback_replay {\n    INSERT INTO t2 VALUES(1, 2, 3, 4);\n    INSERT INTO t2 VALUES('w', 'x', 'y', 'z');\n  }\n  execsql { SELECT * FROM t2 }\n} {1 2 3 4 w x y z}\n\ndo_test 2.2 {\n  exec_rollback_replay {\n    DELETE FROM t2 WHERE a=1;\n    UPDATE t2 SET d = 'a';\n  }\n  execsql { SELECT * FROM t2 }\n} {w x y a}\n\n#-------------------------------------------------------------------------\n# sqlite3changeset_invert()\n#\nreset_db\n\ndo_execsql_test 3.1 { CREATE TABLE t1(x PRIMARY KEY, y) }\ndo_test 3.2 {\n  sqlite3session S db main\n  S attach *\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  set patchset [S patchset]\n  S delete\n  list [catch { sqlite3changeset_invert $patchset } msg] [set msg]\n} {1 SQLITE_CORRUPT}\n\n\n#-------------------------------------------------------------------------\n# sqlite3changeset_concat()\n#\nreset_db\n\nproc do_patchconcat_test {tn args} {\n  set bRevert 0\n  if {[lindex $args 0] == \"-revert\"} {\n    set bRevert 1\n    set args [lrange $args 1 end]\n  }\n  set nSql [expr [llength $args]-1]\n  set res [lindex $args $nSql]\n  set patchlist [list]\n\n  execsql BEGIN\n  if {$bRevert} { execsql { SAVEPOINT x } }\n  foreach sql [lrange $args 0 end-1] {\n    sqlite3session S db main\n    S attach *\n    execsql $sql\n    lappend patchlist [S patchset]\n    S delete\n    if {$bRevert} { execsql { ROLLBACK TO x } }\n  }\n  execsql ROLLBACK\n\n  set patch [lindex $patchlist 0]\n  foreach p [lrange $patchlist 1 end] {\n    set patch [sqlite3changeset_concat $patch $p]\n  }\n\n  set x [list]\n  sqlite3session_foreach c $patch { lappend x $c }\n\n  uplevel [list do_test $tn [list set {} $x] [list {*}$res]]\n}\n\ndo_execsql_test 4.1.1 {\n  CREATE TABLE t1(x PRIMARY KEY, y, z);\n}\ndo_patchconcat_test 4.1.2 {\n  INSERT INTO t1 VALUES(1, 2, 3);\n} {\n  INSERT INTO t1 VALUES(4, 5, 6);\n} {\n  {INSERT t1 0 X.. {} {i 1 i 2 i 3}} \n  {INSERT t1 0 X.. {} {i 4 i 5 i 6}}\n}\n\ndo_execsql_test 4.2.1 {\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n}\n\ndo_patchconcat_test 4.2.2 {\n  UPDATE t1 SET z = 'abc' WHERE x=1\n} {\n  UPDATE t1 SET z = 'def' WHERE x=4\n} {\n  {UPDATE t1 0 X.. {i 1 {} {} {} {}} {{} {} {} {} t abc}} \n  {UPDATE t1 0 X.. {i 4 {} {} {} {}} {{} {} {} {} t def}}\n}\n\ndo_patchconcat_test 4.2.3 {\n  DELETE FROM t1 WHERE x=1;\n} {\n  DELETE FROM t1 WHERE x=4;\n} {\n  {DELETE t1 0 X.. {i 1 {} {} {} {}} {}} \n  {DELETE t1 0 X.. {i 4 {} {} {} {}} {}}\n}\n\n\ndo_execsql_test 4.3.1 {\n  CREATE TABLE t2(a, b, c, d, PRIMARY KEY(c, b));\n  INSERT INTO t2 VALUES('.', 1, 1, '.');\n  INSERT INTO t2 VALUES('.', 1, 2, '.');\n  INSERT INTO t2 VALUES('.', 2, 1, '.');\n  INSERT INTO t2 VALUES('.', 2, 2, '.');\n}\n\n# INSERT + INSERT \ndo_patchconcat_test 4.3.2 -revert {\n  INSERT INTO t2 VALUES('a', 'a', 'a', 'a');\n} {\n  INSERT INTO t2 VALUES('b', 'a', 'a', 'b');\n} {\n  {INSERT t2 0 .XX. {} {t a t a t a t a}}\n}\n\n# INSERT + DELETE \ndo_patchconcat_test 4.3.3 {\n  INSERT INTO t2 VALUES('a', 'a', 'a', 'a');\n} {\n  DELETE FROM t2 WHERE c = 'a';\n} {\n}\n\n# INSERT + UPDATE\ndo_patchconcat_test 4.3.4 {\n  INSERT INTO t2 VALUES('a', 'a', 'a', 'a');\n} {\n  UPDATE t2 SET d = 'b' WHERE c='a';\n} {\n  {INSERT t2 0 .XX. {} {t a t a t a t b}}\n}\n\n# UPDATE + UPDATE\ndo_patchconcat_test 4.3.5 {\n  UPDATE t2 SET a = 'a' WHERE c=1 AND b=2;\n} {\n  UPDATE t2 SET d = 'd' WHERE c=1 AND b=2;\n} {\n  {UPDATE t2 0 .XX. {{} {} i 2 i 1 {} {}} {t a {} {} {} {} t d}}\n}\n\n# UPDATE + DELETE\ndo_patchconcat_test 4.3.6 {\n  UPDATE t2 SET a = 'a' WHERE c=1 AND b=2;\n} {\n  DELETE FROM t2 WHERE c=1 AND b=2;\n} {\n  {DELETE t2 0 .XX. {{} {} i 2 i 1 {} {}} {}}\n}\n\n# DELETE + INSERT\ndo_patchconcat_test 4.3.7 {\n  DELETE FROM t2 WHERE b=1;\n} {\n  INSERT INTO t2 VALUES('x', 1, 2, '.');\n} {\n  {DELETE t2 0 .XX. {{} {} i 1 i 1 {} {}} {}} \n  {UPDATE t2 0 .XX. {{} {} i 1 i 2 {} {}} {t x {} {} {} {} t .}}\n}\n\n# DELETE + UPDATE\ndo_patchconcat_test 4.3.8 -revert {\n  DELETE FROM t2 WHERE b=1 AND c=2;\n} {\n  UPDATE t2 SET a=5 WHERE b=1 AND c=2;\n} {\n  {DELETE t2 0 .XX. {{} {} i 1 i 2 {} {}} {}} \n}\n\n# DELETE + UPDATE\ndo_patchconcat_test 4.3.9 -revert {\n  DELETE FROM t2 WHERE b=1 AND c=2;\n} {\n  DELETE FROM t2 WHERE b=1;\n} {\n  {DELETE t2 0 .XX. {{} {} i 1 i 1 {} {}} {}} \n  {DELETE t2 0 .XX. {{} {} i 1 i 2 {} {}} {}} \n}\n\n#-------------------------------------------------------------------------\n# More rigorous testing of the _patchset(), _apply and _concat() APIs.\n#\n# The inputs to each test are a populate database and a list of DML \n# statements. This test determines that the final database is the same\n# if:\n# \n#   1) the statements are executed directly on the database.\n#\n#   2) a single patchset is collected while executing the statements and\n#      then applied to a copy of the original database file.\n#\n#   3) individual patchsets are collected for statement while executing\n#      them and concatenated together before being applied to a copy of\n#      the original database. The concatenation is done in a couple of\n#      different ways - linear, pairwise etc.\n#\n# All tests, as it happens, are run with both changesets and patchsets.\n# But the focus is on patchset capabilities.\n#\n\n# Return a checksum of the contents of the database file. Implicit IPK\n# columns are not included in the checksum - just modifying rowids does\n# not change the database checksum.\n#\nproc databasecksum {db} {\n  set alltab [$db eval {SELECT name FROM sqlite_master WHERE type='table'}]\n  foreach tab $alltab {\n    $db eval \"SELECT * FROM $tab LIMIT 1\" res { }\n    set slist [list]\n    foreach col [lsort $res(*)] {\n      lappend slist \"quote($col)\"\n    }\n    set sql \"SELECT [join $slist ,] FROM $tab\"\n    append txt \"[lsort [$db eval $sql]]\\n\"\n  }\n  return [md5 $txt]\n}\n\nproc do_patchset_test {tn tstcmd lSql} {\n  if {$tstcmd != \"patchset\" && $tstcmd != \"changeset\"} {\n    error \"have $tstcmd: must be patchset or changeset\"\n  }\n\n  foreach fname {test.db2 test.db3 test.db4 test.db5} {\n    forcedelete $fname\n    forcecopy test.db $fname\n  }\n\n  # Execute the SQL statements on [db]. Collect a patchset for each \n  # individual statement, as well as a single patchset for the entire \n  # operation.\n  sqlite3session S db main\n  S attach *\n  foreach sql $lSql { \n    sqlite3session T db main\n    T attach *\n    db eval $sql \n    lappend lPatch [T $tstcmd]\n    T delete\n  }\n  set patchset [S $tstcmd]\n  S delete\n\n  # Calculate a checksum for the final database.\n  set cksum [databasecksum db]\n\n  # 1. Apply the single large patchset to test.db2\n  sqlite3 db2 test.db2\n  sqlite3changeset_apply db2 $patchset noop\n  uplevel [list do_test $tn.1 { databasecksum db2 } $cksum ]\n  db2 close\n  \n  # 2. Apply each of the single-statement patchsets to test.db3\n  sqlite3 db2 test.db3\n  foreach p $lPatch {\n    sqlite3changeset_apply db2 $p noop\n  }\n  uplevel [list do_test $tn.2 { databasecksum db2 } $cksum ]\n  db2 close\n\n  # 3. Concatenate all single-statement patchsets into a single large\n  #    patchset, then apply it to test.db4.\n  #\n  sqlite3 db2 test.db4\n  set big \"\"\n  foreach p $lPatch {\n    set big [sqlite3changeset_concat $big $p]\n  }\n  sqlite3changeset_apply db2 $big noop\n  uplevel [list do_test $tn.3 { databasecksum db2 } $cksum ]\n  db2 close\n\n  # 4. Concatenate all single-statement patchsets pairwise into a single\n  #    large patchset, then apply it to test.db5. Pairwise concatenation:\n  #\n  #         a b c d e f g h i j k\n  #      -> {a b} {c d} {e f} {g h} {i j} k\n  #      -> {a b c d} {e f g h} {i j k}\n  #      -> {a b c d e f g h} {i j k}\n  #      -> {a b c d e f g h i j k}\n  #      -> APPLY!\n  #\n  sqlite3 db2 test.db5\n  set L $lPatch\n  while {[llength $L] > 1} {\n    set O [list]\n    for {set i 0} {$i < [llength $L]} {incr i 2} {\n      if {$i==[llength $L]-1} {\n        lappend O [lindex $L $i]\n      } else {\n        set i1 [expr $i+1]\n        lappend O [sqlite3changeset_concat [lindex $L $i] [lindex $L $i1]]\n      }\n    }\n    set L $O\n  }\n  sqlite3changeset_apply db2 [lindex $L 0] noop\n  uplevel [list do_test $tn.4 { databasecksum db2 } $cksum ]\n  db2 close\n}\n\nproc do_patchset_changeset_test {tn initsql args} {\n  foreach tstcmd {patchset changeset} {\n    reset_db\n    execsql $initsql\n    set x 0\n    foreach sql $args {\n      incr x\n      set lSql [split $sql \";\"]\n      uplevel [list do_patchset_test $tn.$tstcmd.$x $tstcmd $lSql]\n    }\n  }\n}\n\ndo_patchset_changeset_test 5.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n} {\n  INSERT INTO t1 VALUES(4, 5, 6);\n  DELETE FROM t1 WHERE a=1;\n} {\n  INSERT INTO t1 VALUES(7, 8, 9);\n  UPDATE t1 SET c = 5;\n  INSERT INTO t1 VALUES(10, 11, 12);\n  UPDATE t1 SET c = 6;\n  INSERT INTO t1 VALUES(13, 14, 15);\n} {\n  UPDATE t1 SET c=c+1;\n  DELETE FROM t1 WHERE (a%2);\n} \n\ndo_patchset_changeset_test 5.2 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  CREATE TABLE t2(a, b, c, d, PRIMARY KEY(c, b));\n} {\n  INSERT INTO t1 VALUES(x'00', 0, 'zero');\n  INSERT INTO t1 VALUES(x'01', 1, 'one');\n  INSERT INTO t1 VALUES(x'02', 4, 'four');\n  INSERT INTO t1 VALUES(x'03', 9, 'nine');\n  INSERT INTO t1 VALUES(x'04', 16, 'sixteen');\n  INSERT INTO t1 VALUES(x'05', 25, 'twenty-five');\n} {\n  UPDATE t1 SET a = b WHERE b<=4;\n  INSERT INTO t2 SELECT NULL, * FROM t1;\n  DELETE FROM t1 WHERE b=25;\n} {\n  DELETE FROM t2;\n  INSERT INTO t2 SELECT NULL, * FROM t1;\n  DELETE FROM t1;\n  INSERT INTO t1 SELECT b, c, d FROM t2;\n  UPDATE t1 SET b = b+1;\n  UPDATE t1 SET b = b+1;\n  UPDATE t1 SET b = b+1;\n}\n\nset initsql { CREATE TABLE t1(a, b, c, PRIMARY KEY(c, b)); }\nfor {set i 0} {$i < 1000} {incr i} {\n  append insert \"INSERT INTO t1 VALUES($i, $i, $i);\"\n  append delete \"DELETE FROM t1 WHERE b=$i;\"\n}\ndo_patchset_changeset_test 5.3 \\\n  $initsql $insert $delete     \\\n  $insert $delete              \\\n  \"$insert $delete\"            \\\n  $delete\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionC.test",
    "content": "# 2014 August 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionC\n\n#-------------------------------------------------------------------------\n# Test the outcome of a DELETE operation made as part of applying a\n# changeset failing with SQLITE_CONSTRAINT. This may happen if an\n# ON DELETE RESTRICT foreign key action is triggered, or if a trigger\n# program raises a constraint somehow.\n#\n# UPDATE: The above is no longer true, as \"PRAGMA defer_foreign_keys\"\n# now disables \"RESTRICT\" processing. The test below has been rewritten \n# to use a trigger instead of a foreign key to test this case.\n#\ndo_execsql_test 1.0 {\n  PRAGMA foreign_keys = 1;\n\n  CREATE TABLE p(a PRIMARY KEY, b, c);\n  CREATE TABLE c(d PRIMARY KEY, e /* REFERENCES p ON DELETE RESTRICT */);\n\n  CREATE TRIGGER restrict_trig BEFORE DELETE ON p BEGIN\n    SELECT raise(ABORT, 'error!') FROM c WHERE e=old.a;\n  END;\n\n  INSERT INTO p VALUES('one', 1, 1);\n  INSERT INTO p VALUES('two', 2, 2);\n  INSERT INTO p VALUES('three', 3, 3);\n\n  INSERT INTO c VALUES(1, 'one');\n  INSERT INTO c VALUES(3, 'three');\n}\n\ndo_test 1.1 {\n  execsql BEGIN\n  set C [changeset_from_sql {\n    INSERT INTO c VALUES(4, 'one');\n    DELETE FROM p WHERE a='two';\n  }]\n  execsql ROLLBACK\n  execsql {\n    INSERT INTO c VALUES(2, 'two');\n  }\n} {}\n\ndo_test 1.2.1 {\n  proc xConflict {args} { return \"ABORT\" }\n  catch { sqlite3changeset_apply db $C xConflict } msg\n  set msg\n} {SQLITE_ABORT}\ndo_execsql_test 1.2.2 { SELECT * FROM c } {1 one 3 three 2 two}\n\ndo_test 1.3.1 {\n  proc xConflict {args} { return \"OMIT\" }\n  catch { sqlite3changeset_apply db $C xConflict } msg\n  set msg\n} {}\ndo_execsql_test 1.3.2 { SELECT * FROM c } {1 one 3 three 2 two 4 one}\ndo_execsql_test 1.3.3 { \n  SELECT * FROM p;\n} {one 1 1 two 2 2 three 3 3}\n\n\n#-------------------------------------------------------------------------\n# Test that concatenating a changeset with a patchset does not work.\n# Any attempt to do so returns SQLITE_ERROR.\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE TABLE x1(t, v PRIMARY KEY);\n  INSERT INTO x1 VALUES(12, 55);\n  INSERT INTO x1 VALUES(55, 14);\n}\n\ndo_test 2.1 {\n  execsql BEGIN\n\n  sqlite3session S1 db main\n  S1 attach *\n  execsql {\n    UPDATE x1 SET t=13 WHERE v=55;\n    INSERT INTO x1 VALUES(99, 123);\n  }\n  set patchset [S1 patchset]\n  S1 delete\n\n  sqlite3session S1 db main\n  S1 attach *\n  execsql {\n    UPDATE x1 SET t=56 WHERE v=14;\n    INSERT INTO x1 VALUES(22, 998);\n  }\n  set changeset [S1 changeset]\n  S1 delete\n\n  execsql ROLLBACK\n} {}\n\ndo_test 2.2 {\n  set rc [catch { sqlite3changeset_concat $patchset $changeset } msg]\n  list $rc $msg\n} {1 SQLITE_ERROR}\n\ndo_test 2.3 {\n  set rc [catch { sqlite3changeset_concat $changeset $patchset } msg]\n  list $rc $msg\n} {1 SQLITE_ERROR}\n\ndo_test 2.4 {\n  set rc [catch { sqlite3changeset_concat {} $patchset } msg]\n  list $rc $msg\n} [list 0 $patchset]\n\ndo_test 2.5 {\n  set rc [catch { sqlite3changeset_concat $patchset {} } msg]\n  list $rc $msg\n} [list 0 $patchset]\n\ndo_test 2.6 {\n  set rc [catch { sqlite3changeset_concat {} $changeset } msg]\n  list $rc $msg\n} [list 0 $changeset]\n\ndo_test 2.7 {\n  set rc [catch { sqlite3changeset_concat $changeset {} } msg]\n  list $rc $msg\n} [list 0 $changeset]\n\ndo_test 2.8 {\n  set rc [catch { sqlite3changeset_concat {} {} } msg]\n  list $rc $msg\n} [list 0 {}]\n\n\n#-------------------------------------------------------------------------\n# Test that the xFilter argument to sqlite3changeset_apply() works.\n#\nreset_db\ndo_execsql_test 3.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  CREATE TABLE t3(a PRIMARY KEY, b);\n}\ndo_test 3.1 {\n  execsql BEGIN\n  set changeset [changeset_from_sql {\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t2 VALUES(2, 2);\n    INSERT INTO t3 VALUES(3, 3);\n  }]\n  execsql ROLLBACK\n} {}\ndo_test 3.2 {\n  proc xFilter {zName} {\n    if {$zName == \"t1\"} { return 1 }\n    return 0\n  }\n  sqlite3changeset_apply db $changeset noop xFilter\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {1 1}\ndo_test 3.3 {\n  proc xFilter {zName} {\n    if {$zName == \"t3\"} { return 1 }\n    return 0\n  }\n  sqlite3changeset_apply db $changeset noop xFilter\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {1 1 3 3}\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionD.test",
    "content": "# 2014 August 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file focuses on the sqlite3session_diff() function.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionD\n\nproc scksum {db dbname} {\n\n  if {$dbname==\"temp\"} {\n    set master sqlite_temp_master\n  } else {\n    set master $dbname.sqlite_master\n  }\n\n  set alltab [$db eval \"SELECT name FROM $master WHERE type='table'\"]\n  set txt [$db eval \"SELECT * FROM $master ORDER BY type,name,sql\"]\n  foreach tab $alltab {\n    set cols [list]\n    db eval \"PRAGMA $dbname.table_info = $tab\" x { \n      lappend cols \"quote($x(name))\" \n    }\n    set cols [join $cols ,]\n    append txt [db eval \"SELECT $cols FROM $tab ORDER BY $cols\"]\n  }\n  return [md5 $txt]\n}\n\nproc do_diff_test {tn setup} {\n  reset_db\n  forcedelete test.db2\n  execsql { ATTACH 'test.db2' AS aux }\n  execsql $setup\n\n  sqlite3session S db main\n  foreach tbl [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n    S attach $tbl\n    S diff aux $tbl\n  }\n\n  set C [S changeset]\n  S delete\n\n  sqlite3 db2 test.db2\n  sqlite3changeset_apply db2 $C \"\"\n  uplevel do_test $tn.1 [list {execsql { PRAGMA integrity_check } db2}] ok\n  db2 close\n\n  set cksum [scksum db main]\n  uplevel do_test $tn.2 [list {scksum db aux}] [list $cksum]\n}\n\n# Ensure that the diff produced by comparing the current contents of [db]\n# with itself is empty.\nproc do_empty_diff_test {tn} {\n  forcedelete test.db2\n  forcecopy test.db test.db2\n\n  execsql { ATTACH 'test.db2' AS aux }\n  sqlite3session S db main\n  foreach tbl [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n    S attach $tbl\n    S diff aux $tbl\n  }\n\n  set ::C [S changeset]\n  S delete\n\n  uplevel [list do_test $tn {string length $::C} 0]\n}\n\n\nforcedelete test.db2\ndo_execsql_test 1.0 {\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t2 VALUES(1, 'one');\n  INSERT INTO t2 VALUES(2, 'two');\n\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE aux.t2(a PRIMARY KEY, b);\n}\n\ndo_test 1.1 {\n  sqlite3session S db main\n  S attach t2\n  S diff aux t2\n  set C [S changeset]\n  S delete\n} {}\n\ndo_test 1.2 {\n  sqlite3 db2 test.db2\n  sqlite3changeset_apply db2 $C \"\"\n  db2 close\n  db eval { SELECT * FROM aux.t2 }\n} {1 one 2 two}\n\ndo_diff_test 2.1 {\n  CREATE TABLE aux.t1(x, y, PRIMARY KEY(y));\n  CREATE TABLE t1(x, y, PRIMARY KEY(y));\n\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(NULL, 'xyz');\n  INSERT INTO t1 VALUES(4.5, 5.5);\n}\n\ndo_diff_test 2.2 {\n  CREATE TABLE aux.t1(x, y, PRIMARY KEY(y));\n  CREATE TABLE t1(x, y, PRIMARY KEY(y));\n\n  INSERT INTO aux.t1 VALUES(1, 2);\n  INSERT INTO aux.t1 VALUES(NULL, 'xyz');\n  INSERT INTO aux.t1 VALUES(4.5, 5.5);\n}\n\ndo_diff_test 2.3 {\n  CREATE TABLE aux.t1(a PRIMARY KEY, b TEXT);\n  CREATE TABLE t1(a PRIMARY KEY, b TEXT);\n\n  INSERT INTO aux.t1 VALUES(1, 'one');\n  INSERT INTO aux.t1 VALUES(2, 'two');\n  INSERT INTO aux.t1 VALUES(3, 'three');\n\n  INSERT INTO t1 VALUES(1, 'I');\n  INSERT INTO t1 VALUES(2, 'two');\n  INSERT INTO t1 VALUES(3, 'III');\n}\n\ndo_diff_test 2.4 {\n  CREATE TABLE aux.t1(a, b, c, d, PRIMARY KEY(c, b, a));\n  CREATE TABLE t1(a, b, c, d, PRIMARY KEY(c, b, a));\n\n  INSERT INTO t1 VALUES('hvkzyipambwdqlvwv','',-458331.50,X'DA51ED5E84');\n  INSERT INTO t1 VALUES(X'C5C6B5DD','jjxrath',40917,830244);\n  INSERT INTO t1 VALUES(-204877.54,X'1704C253D5F3AFA8',155120.88,NULL);\n  INSERT INTO t1 \n  VALUES('ckmqmzoeuvxisxqy',X'EB5A5D3A1DD22FD1','tidhjcbvbppdt',-642987.37);\n  INSERT INTO t1 VALUES(-851726,-161992,-469943,-159541);\n  INSERT INTO t1 VALUES(X'4A6A667F858938',185083,X'7A',NULL);\n\n  INSERT INTO aux.t1 VALUES(415075.74,'auawczkb',X'',X'57B4FAAF2595');\n  INSERT INTO aux.t1 VALUES(727637,711560,-181340,'hphuo');\n  INSERT INTO aux.t1 \n  VALUES(-921322.81,662959,'lvlgwdgxaurr','ajjrzrbhqflsutnymgc');\n  INSERT INTO aux.t1 VALUES(-146061,-377892,X'4E','gepvpvvuhszpxabbb');\n  INSERT INTO aux.t1 VALUES(-851726,-161992,-469943,-159541);\n  INSERT INTO aux.t1 VALUES(X'4A6A667F858938',185083,X'7A',NULL);\n  INSERT INTO aux.t1 VALUES(-204877.54,X'1704C253D5F3AFA8',155120.88, 4);\n  INSERT INTO aux.t1 \n  VALUES('ckmqmzoeuvxisxqy',X'EB5A5D3A1DD22FD1','tidgtsplhjcbvbppdt',-642987.3);\n}\n\nreset_db\ndo_execsql_test 3.0 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a));\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  INSERT INTO t1 VALUES(7, 8, 9);\n\n  CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b));\n  INSERT INTO t2 VALUES(1, 2, 3);\n  INSERT INTO t2 VALUES(4, 5, 6);\n  INSERT INTO t2 VALUES(7, 8, 9);\n\n  CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b, c));\n  INSERT INTO t3 VALUES(1, 2, 3);\n  INSERT INTO t3 VALUES(4, 5, 6);\n  INSERT INTO t3 VALUES(7, 8, 9);\n}\ndo_empty_diff_test 3.1\n\n\n#-------------------------------------------------------------------------\n# Test some error cases:\n# \n#   1) schema mismatches between the two dbs, and \n#   2) tables with no primary keys. This is not actually an error, but\n#      should not add any changes to the session object.\n#\nreset_db\nforcedelete test.db2\ndo_execsql_test 4.0 {\n  ATTACH 'test.db2' AS ixua;\n  CREATE TABLE ixua.t1(a, b, c);\n  CREATE TABLE main.t1(a, b, c);\n  INSERT INTO main.t1 VALUES(1, 2, 3);\n\n  CREATE TABLE ixua.t2(a PRIMARY KEY, b, c);\n  CREATE TABLE main.t2(a PRIMARY KEY, b, x);\n}\n\ndo_test 4.1.1 {\n  sqlite3session S db main\n  S attach t1\n  list [catch { S diff ixua t1 } msg] $msg\n} {0 {}}\ndo_test 4.1.2 {\n  string length [S changeset]\n} {0}\nS delete\n\ndo_test 4.2.2 {\n  sqlite3session S db main\n  S attach t2\n  list [catch { S diff ixua t2 } msg] $msg\n} {1 {SQLITE_SCHEMA - table schemas do not match}}\nS delete\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionE.test",
    "content": "# 2015 June 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for the sessions module.\n# Specifically, it tests that operations on tables without primary keys\n# are ignored.\n#\n\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessionE\n\n#\n# Test plan:\n#\n#    1.*: Test that non-PK tables are not auto-attached.\n#    2.*: Test that explicitly attaching a non-PK table is a no-op.\n#    3.*: Test that sqlite3session_diff() on a non-PK table is a no-op.\n#\n\n\n#--------------------------------------------------------------------------\nreset_db\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a PRIMARY KEY, b);\n}\ndo_test 1.1 {\n  sqlite3session S db main\n  S attach *\n  execsql {\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES(1, 2);\n  }\n} {}\ndo_changeset_test 1.2 S {\n  {INSERT t2 0 X. {} {i 1 i 2}}\n}\nS delete\n\nreset_db\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a PRIMARY KEY, b);\n}\ndo_test 2.1 {\n  sqlite3session S db main\n  S attach t1\n  S attach t2\n  execsql {\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t2 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n    INSERT INTO t2 VALUES(5, 6);\n  }\n} {}\ndo_changeset_test 2.2 S {\n  {INSERT t2 0 X. {} {i 3 i 4}}\n  {INSERT t2 0 X. {} {i 5 i 6}}\n}\nS delete\n\nreset_db\nforcedelete test.db2\ndo_execsql_test 3.0 {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE aux.t1(a, b);\n  CREATE TABLE aux.t2(a PRIMARY KEY, b);\n\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a PRIMARY KEY, b);\n\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t2 VALUES(3, 4);\n}\ndo_test 3.1 {\n  sqlite3session S db main\n  S attach t1\n  S diff aux t1\n\n  S attach t2\n  S diff aux t2\n} {}\ndo_changeset_test 3.2 S {\n  {INSERT t2 0 X. {} {i 3 i 4}}\n}\ndo_execsql_test 3.3 {\n  INSERT INTO t1 VALUES(5, 6);\n  INSERT INTO t2 VALUES(7, 8);\n}\ndo_changeset_test 3.4 S {\n  {INSERT t2 0 X. {} {i 3 i 4}}\n  {INSERT t2 0 X. {} {i 7 i 8}}\n}\n\n\nS delete\n\nfinish_test\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionF.test",
    "content": "# 2015 June 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for the sessions module.\n# Specifically, it tests that tables appear in the correct order\n# within changesets and patchsets.\n#\n\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessionF\n\n#\n# Test plan:\n#\n#    1.*: Test that sqlite3session_changeset() and sqlite3session_patchset()\n#         output tables in the right order.\n#\n#    2.*: Test that sqlite3session_invert() does not modify the order of\n#         tables within a changeset.\n#\n#    3.*: Test that sqlite3session_concat outputs tables in the right order.\n#\n\n# Create a db schema to use.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t3(e PRIMARY KEY, f);\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(c PRIMARY KEY, d);\n}\n\n#-----------------------------------------------------------------------\n# 1.* - changeset() and patchset().\n#\n\nforeach {tn setup result} {\n  1 {\n    S attach *\n  } {\n    {INSERT t2 0 X. {} {i 2 t two}} \n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t3 0 X. {} {i 3 t three}}\n  }\n\n  2 {\n    S attach t1\n    S attach *\n  } {\n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t2 0 X. {} {i 2 t two}} \n    {INSERT t3 0 X. {} {i 3 t three}}\n  }\n\n  3 {\n    S attach t3\n    S attach t2\n    S attach t1\n  } {\n    {INSERT t3 0 X. {} {i 3 t three}}\n    {INSERT t2 0 X. {} {i 2 t two}} \n    {INSERT t1 0 X. {} {i 1 t one}} \n  }\n} {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    DELETE FROM t3;\n  }\n  sqlite3session S db main\n  eval $setup\n\n  do_execsql_test 1.$tn.1 {\n    INSERT INTO t2 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t3 VALUES(3, 'three');\n  }\n\n  do_changeset_test 1.1.$tn.2 S $result\n  do_patchset_test  1.1.$tn.3 S $result\n\n  S delete\n}\n\nforeach {tn setup result} {\n  1 {\n    S attach *\n  } {\n    {INSERT t2 0 X. {} {i 4 t four}} \n    {INSERT t2 0 X. {} {i 5 t five}}\n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t3 0 X. {} {i 6 t six}}\n  }\n\n  2 {\n    S attach t1\n    S attach *\n  } {\n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t2 0 X. {} {i 4 t four}} \n    {INSERT t2 0 X. {} {i 5 t five}}\n    {INSERT t3 0 X. {} {i 6 t six}}\n  }\n\n  3 {\n    S attach t3\n    S attach t2\n    S attach t1\n  } {\n    {INSERT t3 0 X. {} {i 6 t six}}\n    {INSERT t2 0 X. {} {i 4 t four}} \n    {INSERT t2 0 X. {} {i 5 t five}}\n    {INSERT t1 0 X. {} {i 1 t one}} \n  }\n} {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    DELETE FROM t3;\n  }\n  sqlite3session S db main\n  eval $setup\n\n  do_execsql_test 1.$tn.1 {\n    INSERT INTO t2 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(1, 'one');\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(4, 'four');\n    INSERT INTO t2 VALUES(5, 'five');\n    INSERT INTO t3 VALUES(6, 'six');\n  }\n\n  do_changeset_test 1.2.$tn.2 S $result\n  do_patchset_test 1.2.$tn.2 S $result\n\n  S delete\n}\n\n#-------------------------------------------------------------------------\n# 2.* - invert()\n#\n\nforeach {tn setup result} {\n  1 {\n    S attach *\n  } {\n    {DELETE t2 0 X. {i 4 t four} {}} \n    {DELETE t2 0 X. {i 5 t five} {}} \n    {DELETE t1 0 X. {i 1 t one} {}}\n    {DELETE t3 0 X. {i 6 t six} {}} \n  }\n\n  2 {\n    S attach t1\n    S attach *\n  } {\n    {DELETE t1 0 X. {i 1 t one} {}}\n    {DELETE t2 0 X. {i 4 t four} {}} \n    {DELETE t2 0 X. {i 5 t five} {}} \n    {DELETE t3 0 X. {i 6 t six} {}} \n  }\n\n  3 {\n    S attach t3\n    S attach t2\n    S attach t1\n  } {\n    {DELETE t3 0 X. {i 6 t six} {}} \n    {DELETE t2 0 X. {i 4 t four} {}} \n    {DELETE t2 0 X. {i 5 t five} {}} \n    {DELETE t1 0 X. {i 1 t one} {}}\n  }\n} {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    DELETE FROM t3;\n  }\n  sqlite3session S db main\n  eval $setup\n\n  do_execsql_test 1.$tn.1 {\n    INSERT INTO t2 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(1, 'one');\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(4, 'four');\n    INSERT INTO t2 VALUES(5, 'five');\n    INSERT INTO t3 VALUES(6, 'six');\n  }\n\n  do_changeset_invert_test 2.$tn.2 S $result\n\n  S delete\n}\n\n#-------------------------------------------------------------------------\n# 3.* - concat()\n#\nforeach {tn setup1 sql1 setup2 sql2 result} {\n  1 {\n    S attach *\n  } {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(2, 'two');\n  } {\n    S attach t2\n    S attach t1\n  } {\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t2 VALUES(4, 'four');\n  } {\n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t1 0 X. {} {i 3 t three}} \n    {INSERT t2 0 X. {} {i 2 t two}}\n    {INSERT t2 0 X. {} {i 4 t four}}\n  }\n\n  1 {\n    S attach t2\n    S attach t1\n  } {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(2, 'two');\n  } {\n    S attach *\n  } {\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t2 VALUES(4, 'four');\n  } {\n    {INSERT t2 0 X. {} {i 2 t two}}\n    {INSERT t2 0 X. {} {i 4 t four}}\n    {INSERT t1 0 X. {} {i 1 t one}} \n    {INSERT t1 0 X. {} {i 3 t three}} \n  }\n\n  1 {\n    S attach *\n  } {\n    INSERT INTO t2 VALUES(2, 'two');\n  } {\n    S attach *\n  } {\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t2 VALUES(4, 'four');\n    INSERT INTO t3 VALUES(5, 'five');\n  } {\n    {INSERT t2 0 X. {} {i 2 t two}}\n    {INSERT t2 0 X. {} {i 4 t four}}\n    {INSERT t1 0 X. {} {i 3 t three}} \n    {INSERT t3 0 X. {} {i 5 t five}} \n  }\n\n} {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    DELETE FROM t3;\n  }\n  sqlite3session S db main\n  eval $setup1\n  execsql $sql1\n  set c1 [S changeset]\n  S delete\n\n  sqlite3session S db main\n  eval $setup2\n  execsql $sql2\n  set c2 [S changeset]\n  S delete\n\n  set res [list]\n  sqlite3session_foreach x [sqlite3changeset_concat $c1 $c2] {\n    lappend res $x\n  }\n\n  do_test 3.$tn { set res } [list {*}$result]\n}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionG.test",
    "content": "# 2016 March 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for the sessions module.\n# Specifically, it tests that UNIQUE constraints are dealt with correctly.\n#\n\n\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessionG\n\n\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_test 1.0 {\n  do_common_sql {\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n  }\n  do_then_apply_sql {\n    DELETE FROM t1 WHERE a=1;\n    INSERT INTO t1 VALUES(4, 'one');\n  }\n  compare_db db db2\n} {}\n\ndo_test 1.1 {\n  do_then_apply_sql {\n    DELETE FROM t1 WHERE a=4;\n    INSERT INTO t1 VALUES(1, 'one');\n  }\n  compare_db db db2\n} {}\n\ndo_test 1.2 {\n  execsql { INSERT INTO t1 VALUES(5, 'five') } db2\n  do_then_apply_sql {\n    INSERT INTO t1 VALUES(11, 'eleven');\n    INSERT INTO t1 VALUES(12, 'five');\n  }\n  execsql { SELECT * FROM t1 } db2\n} {2 two 3 three 1 one 5 five 11 eleven}\n\ndo_test 1.3 {\n  execsql { SELECT * FROM t1 }\n} {2 two 3 three 1 one 11 eleven 12 five}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndb2 close\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_test 2.1 {\n  do_common_sql {\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE, c UNIQUE);\n    INSERT INTO t1 VALUES(1, 1, 1);\n    INSERT INTO t1 VALUES(2, 2, 2);\n    INSERT INTO t1 VALUES(3, 3, 3);\n  }\n} {}\n\ndo_test 2.2.1 {\n  # It is not possible to apply the changeset generated by the following\n  # SQL, as none of the three updated rows may be updated as part of the\n  # first pass.\n  do_then_apply_sql {\n    UPDATE t1 SET b=0 WHERE a=1;\n    UPDATE t1 SET b=1 WHERE a=2;\n    UPDATE t1 SET b=2 WHERE a=3;\n    UPDATE t1 SET b=3 WHERE a=1;\n  }\n  db2 eval { SELECT a, b FROM t1 }\n} {1 1 2 2 3 3}\ndo_test 2.2.2 { db eval { SELECT a, b FROM t1 } } {1 3 2 1 3 2}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndb2 close\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_test 3.1 {\n  do_common_sql {\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE, c UNIQUE);\n    INSERT INTO t1 VALUES(1, 1, 1);\n    INSERT INTO t1 VALUES(2, 2, 2);\n    INSERT INTO t1 VALUES(3, 3, 3);\n  }\n} {}\n\ndo_test 3.3 {\n  do_then_apply_sql {\n    UPDATE t1 SET b=4 WHERE a=3;\n    UPDATE t1 SET b=3 WHERE a=2;\n    UPDATE t1 SET b=2 WHERE a=1;\n  }\n  compare_db db db2\n} {}\n\ndo_test 3.4 {\n  do_then_apply_sql {\n    UPDATE t1 SET b=1 WHERE a=1;\n    UPDATE t1 SET b=2 WHERE a=2;\n    UPDATE t1 SET b=3 WHERE a=3;\n  }\n  compare_db db db2\n} {}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndb2 close\nforcedelete test.db2\nsqlite3 db2 test.db2\n\ndo_test 4.1 {\n  do_common_sql {\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 2);\n    INSERT INTO t1 VALUES(3, 3);\n\n    CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t2 VALUES(1, 1);\n    INSERT INTO t2 VALUES(2, 2);\n    INSERT INTO t2 VALUES(3, 3);\n  }\n} {}\n\ndo_test 4.2 {\n  do_then_apply_sql {\n    UPDATE t1 SET b=4 WHERE a=3;\n    UPDATE t1 SET b=3 WHERE a=2;\n    UPDATE t1 SET b=2 WHERE a=1;\n\n    UPDATE t2 SET b=0 WHERE a=1;\n    UPDATE t2 SET b=1 WHERE a=2;\n    UPDATE t2 SET b=2 WHERE a=3;\n  }\n  compare_db db db2\n} {}\n\ndo_test 4.3 {\n  do_then_apply_sql {\n    UPDATE t1 SET b=1 WHERE a=1;\n    UPDATE t1 SET b=2 WHERE a=2;\n    UPDATE t1 SET b=3 WHERE a=3;\n\n    UPDATE t2 SET b=3 WHERE a=3;\n    UPDATE t2 SET b=2 WHERE a=2;\n    UPDATE t2 SET b=1 WHERE a=1;\n  }\n  compare_db db db2\n} {}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session_common.tcl",
    "content": "\nproc do_changeset_test {tn session res} {\n  set r [list]\n  foreach x $res {lappend r $x}\n  uplevel do_test $tn [list [subst -nocommands {\n    set x [list]\n    sqlite3session_foreach c [$session changeset] { lappend x [set c] }\n    set x\n  }]] [list $r]\n}\n\nproc do_patchset_test {tn session res} {\n  set r [list]\n  foreach x $res {lappend r $x}\n  uplevel do_test $tn [list [subst -nocommands {\n    set x [list]\n    sqlite3session_foreach c [$session patchset] { lappend x [set c] }\n    set x\n  }]] [list $r]\n}\n\n\nproc do_changeset_invert_test {tn session res} {\n  set r [list]\n  foreach x $res {lappend r $x}\n  uplevel do_test $tn [list [subst -nocommands {\n    set x [list]\n    set changeset [sqlite3changeset_invert [$session changeset]]\n    sqlite3session_foreach c [set changeset] { lappend x [set c] }\n    set x\n  }]] [list $r]\n}\n\n\nproc do_conflict_test {tn args} {\n\n  set O(-tables)    [list]\n  set O(-sql)       [list]\n  set O(-conflicts) [list]\n  set O(-policy)    \"OMIT\"\n\n  array set V $args\n  foreach key [array names V] {\n    if {![info exists O($key)]} {error \"no such option: $key\"}\n  }\n  array set O $args\n\n  proc xConflict {args} [subst -nocommands { \n    lappend ::xConflict [set args]\n    return $O(-policy) \n  }]\n  proc bgerror {args} { set ::background_error $args }\n\n  sqlite3session S db main\n  foreach t $O(-tables) { S attach $t }\n  execsql $O(-sql)\n\n  set ::xConflict [list]\n  sqlite3changeset_apply db2 [S changeset] xConflict\n\n  set conflicts [list]\n  foreach c $O(-conflicts) {\n    lappend conflicts $c\n  }\n\n  after 1 {set go 1}\n  vwait go\n\n  uplevel do_test $tn [list { set ::xConflict }] [list $conflicts]\n  S delete\n}\n\nproc do_common_sql {sql} {\n  execsql $sql db\n  execsql $sql db2\n}\n\nproc changeset_from_sql {sql {dbname main}} {\n  if {$dbname == \"main\"} {\n    return [sql_exec_changeset db $sql]\n  }\n  set rc [catch {\n    sqlite3session S db $dbname\n    db eval \"SELECT name FROM $dbname.sqlite_master WHERE type = 'table'\" {\n      S attach $name\n    }\n    db eval $sql\n    S changeset\n  } changeset]\n  catch { S delete }\n\n  if {$rc} {\n    error $changeset\n  }\n  return $changeset\n}\n\nproc do_then_apply_sql {sql {dbname main}} {\n  proc xConflict args { return \"OMIT\" }\n  set rc [catch {\n    sqlite3session S db $dbname\n    db eval \"SELECT name FROM $dbname.sqlite_master WHERE type = 'table'\" {\n      S attach $name\n    }\n    db eval $sql\n    sqlite3changeset_apply db2 [S changeset] xConflict\n  } msg]\n\n  catch { S delete }\n\n  if {$rc} {error $msg}\n}\n\nproc do_iterator_test {tn tbl_list sql res} {\n  sqlite3session S db main\n  if {[llength $tbl_list]==0} { S attach * }\n  foreach t $tbl_list {S attach $t}\n\n  execsql $sql\n\n  set r [list]\n  foreach v $res { lappend r $v }\n\n  set x [list]\n  sqlite3session_foreach c [S changeset] { lappend x $c }\n  uplevel do_test $tn [list [list set {} $x]] [list $r]\n\n  S delete\n}\n\n# Compare the contents of all tables in [db1] and [db2]. Throw an error if \n# they are not identical, or return an empty string if they are.\n#\nproc compare_db {db1 db2} {\n\n  set sql {SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name}\n  set lot1 [$db1 eval $sql]\n  set lot2 [$db2 eval $sql]\n\n  if {$lot1 != $lot2} { \n    puts $lot1\n    puts $lot2\n    error \"databases contain different tables\" \n  }\n\n  foreach tbl $lot1 {\n    set col1 [list]\n    set col2 [list]\n\n    $db1 eval \"PRAGMA table_info = $tbl\" { lappend col1 $name }\n    $db2 eval \"PRAGMA table_info = $tbl\" { lappend col2 $name }\n    if {$col1 != $col2} { error \"table $tbl schema mismatch\" }\n\n    set sql \"SELECT * FROM $tbl ORDER BY [join $col1 ,]\"\n    set data1 [$db1 eval $sql]\n    set data2 [$db2 eval $sql]\n    if {$data1 != $data2} { \n      puts \"$data1\"\n      puts \"$data2\"\n      error \"table $tbl data mismatch\" \n    }\n  }\n\n  return \"\"\n}\n\nproc changeset_to_list {c} {\n  set list [list]\n  sqlite3session_foreach elem $c { lappend list $elem }\n  lsort $list\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/session_speed_test.c",
    "content": "/*\n** 2017 January 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the source code for a standalone program used to\n** test the performance of the sessions module. Compile and run:\n**\n**   ./session_speed_test -help\n**\n** for details.\n*/\n\n#include \"sqlite3.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stddef.h>\n#include <unistd.h>\n\n/*************************************************************************\n** Start of generic command line parser.\n*/\n#define CMDLINE_BARE       0\n#define CMDLINE_INTEGER    1\n#define CMDLINE_STRING     2\n#define CMDLINE_BOOLEAN    3\n\ntypedef struct CmdLineOption CmdLineOption;\nstruct CmdLineOption {\n  const char *zText;              /* Name of command line option */\n  const char *zHelp;              /* Help text for option */\n  int eType;                      /* One of the CMDLINE_* values */\n  int iOff;                       /* Offset of output variable */\n};\n\n#define CMDLINE_INT32(x,y,z) {x, y, CMDLINE_INTEGER, z}\n#define CMDLINE_BOOL(x,y,z)  {x, y, CMDLINE_BOOLEAN, z}\n#define CMDLINE_TEXT(x,y,z)  {x, y, CMDLINE_STRING, z}\n#define CMDLINE_NONE(x,y,z)  {x, y, CMDLINE_BARE, z}\n\nstatic void option_requires_argument_error(CmdLineOption *pOpt){\n  fprintf(stderr, \"Option requires a%s argument: %s\\n\", \n      pOpt->eType==CMDLINE_INTEGER ? \"n integer\" :\n      pOpt->eType==CMDLINE_STRING ? \" string\" : \" boolean\",\n      pOpt->zText\n  );\n  exit(1);\n}\n\nstatic void ambiguous_option_error(const char *zArg){\n  fprintf(stderr, \"Option is ambiguous: %s\\n\", zArg);\n  exit(1);\n}\n\nstatic void unknown_option_error(\n  const char *zArg, \n  CmdLineOption *aOpt,\n  const char *zHelp\n){\n  int i;\n  fprintf(stderr, \"Unknown option: %s\\n\", zArg);\n  fprintf(stderr, \"\\nOptions are:\\n\");\n  fprintf(stderr, \"  % -30sEcho command line options\\n\", \"-cmdline:verbose\");\n  for(i=0; aOpt[i].zText; i++){\n    int eType = aOpt[i].eType;\n    char *zOpt = sqlite3_mprintf(\"%s %s\", aOpt[i].zText,\n        eType==CMDLINE_BARE ? \"\" :\n        eType==CMDLINE_INTEGER ? \"N\" :\n        eType==CMDLINE_BOOLEAN ? \"BOOLEAN\" : \"TEXT\"\n    );\n    fprintf(stderr, \"  % -30s%s\\n\", zOpt, aOpt[i].zHelp);\n    sqlite3_free(zOpt);\n  }\n  if( zHelp ){\n    fprintf(stderr, \"\\n%s\\n\", zHelp);\n  }\n  exit(1);\n}\n\nstatic int get_integer_option(CmdLineOption *pOpt, const char *zArg){\n  int i = 0;\n  int iRet = 0;\n  int bSign = 1;\n  if( zArg[0]=='-' ){\n    bSign = -1;\n    i = 1;\n  }\n  while( zArg[i] ){\n    if( zArg[i]<'0' || zArg[i]>'9' ) option_requires_argument_error(pOpt);\n    iRet = iRet*10 + (zArg[i] - '0');\n    i++;\n  }\n  return (iRet*bSign);\n}\n\nstatic int get_boolean_option(CmdLineOption *pOpt, const char *zArg){\n  if( 0==sqlite3_stricmp(zArg, \"true\") ) return 1;\n  if( 0==sqlite3_stricmp(zArg, \"1\") ) return 1;\n  if( 0==sqlite3_stricmp(zArg, \"0\") ) return 0;\n  if( 0==sqlite3_stricmp(zArg, \"false\") ) return 0;\n  option_requires_argument_error(pOpt);\n  return 0;\n}\n\nstatic void parse_command_line(\n  int argc, \n  char **argv, \n  int iStart,\n  CmdLineOption *aOpt,\n  void *pStruct,\n  const char *zHelp\n){\n  char *pOut = (char*)pStruct;\n  int bVerbose = 0;\n  int iArg;\n\n  for(iArg=iStart; iArg<argc; iArg++){\n    const char *zArg = argv[iArg];\n    int nArg = strlen(zArg);\n    int nMatch = 0;\n    int iOpt;\n\n    for(iOpt=0; aOpt[iOpt].zText; iOpt++){\n      CmdLineOption *pOpt = &aOpt[iOpt];\n      if( 0==sqlite3_strnicmp(pOpt->zText, zArg, nArg) ){\n        if( nMatch ){\n          ambiguous_option_error(zArg);\n        }\n        nMatch++;\n        if( pOpt->eType==CMDLINE_BARE ){\n          *(int*)(&pOut[pOpt->iOff]) = 1;\n        }else{\n          iArg++;\n          if( iArg==argc ){\n            option_requires_argument_error(pOpt);\n          }\n          switch( pOpt->eType ){\n            case CMDLINE_INTEGER:\n              *(int*)(&pOut[pOpt->iOff]) = get_integer_option(pOpt, argv[iArg]);\n              break;\n            case CMDLINE_STRING:\n              *(const char**)(&pOut[pOpt->iOff]) = argv[iArg];\n              break;\n            case CMDLINE_BOOLEAN:\n              *(int*)(&pOut[pOpt->iOff]) = get_boolean_option(pOpt, argv[iArg]);\n              break;\n          }\n        }\n      }\n    }\n\n    if( nMatch==0 && 0==sqlite3_strnicmp(\"-cmdline:verbose\", zArg, nArg) ){\n      bVerbose = 1;\n      nMatch = 1;\n    }\n\n    if( nMatch==0 ){\n      unknown_option_error(zArg, aOpt, zHelp);\n    }\n  }\n\n  if( bVerbose ){\n    int iOpt;\n    fprintf(stdout, \"Options are: \");\n    for(iOpt=0; aOpt[iOpt].zText; iOpt++){\n      CmdLineOption *pOpt = &aOpt[iOpt];\n      if( pOpt->eType!=CMDLINE_BARE || *(int*)(&pOut[pOpt->iOff]) ){\n        fprintf(stdout, \"%s \", pOpt->zText);\n      }\n      switch( pOpt->eType ){\n        case CMDLINE_INTEGER:\n          fprintf(stdout, \"%d \", *(int*)(&pOut[pOpt->iOff]));\n          break;\n        case CMDLINE_BOOLEAN:\n          fprintf(stdout, \"%d \", *(int*)(&pOut[pOpt->iOff]));\n          break;\n        case CMDLINE_STRING:\n          fprintf(stdout, \"%s \", *(const char**)(&pOut[pOpt->iOff]));\n          break;\n      }\n    }\n    fprintf(stdout, \"\\n\");\n  }\n}\n/* \n** End of generic command line parser.\n*************************************************************************/\n\nstatic void abort_due_to_error(int rc){\n  fprintf(stderr, \"Error: %d\\n\");\n  exit(-1);\n}\n\nstatic void execsql(sqlite3 *db, const char *zSql){\n  int rc = sqlite3_exec(db, zSql, 0, 0, 0);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n}\n\nstatic int xConflict(void *pCtx, int eConflict, sqlite3_changeset_iter *p){\n  return SQLITE_CHANGESET_ABORT;\n}\n\nstatic void run_test(\n  sqlite3 *db, \n  sqlite3 *db2, \n  int nRow, \n  const char *zSql\n){\n  sqlite3_session *pSession = 0;\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  int i;\n  int nChangeset;\n  void *pChangeset;\n\n  /* Attach a session object to database db */\n  rc = sqlite3session_create(db, \"main\", &pSession);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n\n  /* Configure the session to capture changes on all tables */\n  rc = sqlite3session_attach(pSession, 0);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n\n  /* Prepare the SQL statement */\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n\n  /* Open a transaction */\n  execsql(db, \"BEGIN\");\n\n  /* Execute the SQL statement nRow times */\n  for(i=0; i<nRow; i++){\n    sqlite3_bind_int(pStmt, 1, i);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n  }\n  sqlite3_finalize(pStmt);\n\n  /* Extract a changeset from the sessions object */\n  rc = sqlite3session_changeset(pSession, &nChangeset, &pChangeset);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n  execsql(db, \"COMMIT\");\n\n  /* Apply the changeset to the second db */\n  rc = sqlite3changeset_apply(db2, nChangeset, pChangeset, 0, xConflict, 0);\n  if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n\n  /* Cleanup */\n  sqlite3_free(pChangeset);\n  sqlite3session_delete(pSession);\n}\n\nint main(int argc, char **argv){\n  struct Options {\n    int nRow;\n    int bWithoutRowid;\n    int bInteger;\n    int bAll;\n    const char *zDb;\n  };\n  struct Options o = { 2500, 0, 0, 0, \"session_speed_test.db\" };\n\n  CmdLineOption aOpt[] = {\n    CMDLINE_INT32( \"-rows\", \"number of rows in test\",\n      offsetof(struct Options, nRow) ),\n    CMDLINE_BOOL(\"-without-rowid\", \"use WITHOUT ROWID tables\", \n      offsetof(struct Options, bWithoutRowid) ),\n    CMDLINE_BOOL(\"-integer\", \"use integer data (instead of text/blobs)\",\n      offsetof(struct Options, bInteger) ),\n    CMDLINE_NONE(\"-all\", \"Run all 4 combos of -without-rowid and -integer\",\n      offsetof(struct Options, bAll) ),\n    CMDLINE_TEXT(\"-database\", \"prefix for database files to use\",\n      offsetof(struct Options, zDb) ),\n    {0, 0, 0, 0}\n  };\n\n  const char *azCreate[] = {\n    \"CREATE TABLE t1(a PRIMARY KEY, b, c, d)\",\n    \"CREATE TABLE t1(a PRIMARY KEY, b, c, d) WITHOUT ROWID\",\n  };\n\n  const char *azInsert[] = {\n    \"INSERT INTO t1 VALUES(\"\n    \"printf('%.8d',?), randomblob(50), randomblob(50), randomblob(50))\",\n    \"INSERT INTO t1 VALUES(?, random(), random(), random())\"\n  };\n\n  const char *azUpdate[] = {\n    \"UPDATE t1 SET d = randomblob(50) WHERE a = printf('%.8d',?)\",\n    \"UPDATE t1 SET d = random() WHERE a = ?\"\n  };\n\n  const char *azDelete[] = {\n    \"DELETE FROM t1 WHERE a = printf('%.8d',?)\",\n    \"DELETE FROM t1 WHERE a = ?\"\n  };\n\n  int rc;\n  sqlite3 *db;\n  sqlite3 *db2;\n  char *zDb2;\n  int bWithoutRowid;\n  int bInteger;\n\n  parse_command_line(argc, argv, 1, aOpt, (void*)&o,\n    \"This program creates two new, empty, databases each containing a single\\n\"\n    \"table. It then does the following:\\n\\n\"\n    \"  1. Inserts -rows rows into the first database\\n\"\n    \"  2. Updates each row in the first db\\n\"\n    \"  3. Delete each row from the first db\\n\\n\"\n    \"The modifications made by each step are captured in a changeset and\\n\"\n    \"applied to the second database.\\n\"\n  );\n  zDb2 = sqlite3_mprintf(\"%s2\", o.zDb);\n\n  for(bWithoutRowid=0; bWithoutRowid<2; bWithoutRowid++){\n    for(bInteger=0; bInteger<2; bInteger++){\n      if( o.bAll || (o.bWithoutRowid==bWithoutRowid && o.bInteger==bInteger) ){\n        fprintf(stdout, \"Testing %s data with %s table\\n\",\n            bInteger ? \"integer\" : \"blob/text\",\n            bWithoutRowid ? \"WITHOUT ROWID\" : \"rowid\"\n        );\n\n        /* Open new database handles on two empty databases */\n        unlink(o.zDb);\n        rc = sqlite3_open(o.zDb, &db);\n        if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n        unlink(zDb2);\n        rc = sqlite3_open(zDb2, &db2);\n        if( rc!=SQLITE_OK ) abort_due_to_error(rc);\n\n        /* Create the schema in both databases. */\n        execsql(db, azCreate[o.bWithoutRowid]);\n        execsql(db2, azCreate[o.bWithoutRowid]);\n\n        /* Run the three tests */\n        run_test(db, db2, o.nRow, azInsert[o.bInteger]);\n        run_test(db, db2, o.nRow, azUpdate[o.bInteger]);\n        run_test(db, db2, o.nRow, azDelete[o.bInteger]);\n\n        /* Close the db handles */\n        sqlite3_close(db);\n        sqlite3_close(db2);\n      }\n    }\n  }\n\n\n  return 0;\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionat.test",
    "content": "# 2017 February 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the sessions module. Specifically, that a changeset can\n# be applied after ALTER TABLE ADD COLUMN has been used to add \n# columns to tables.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionat\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log log\nproc log {code msg} { lappend ::log $code $msg }\n\nproc reset_test {} {\n  catch { db  close }\n  catch { db2 close }\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  sqlite3 db2 test.db2\n}\n\n\n# Run all tests in this file twice. Once with \"WITHOUT ROWID\", and once\n# with regular rowid tables.\n#\n# ?.1.*: Test that PK inconsistencies are detected if one or more of the PK\n#        columns are not present in the changeset.\n#\n# ?.2.*: Test that it is not possible to apply a changeset with N columns\n#        to a db with fewer than N columns.\n#\n# ?.3.*: Test some INSERT, UPDATE and DELETE operations that do not\n#        require conflict handling.\n#\n# ?.4.*: Test some INSERT, UPDATE and DELETE operations that do require \n#        conflict handling.\n#\n# ?.5.*: Test that attempting to concat two changesets with different\n#        numbers of columns for the same table is an error.\n#\nforeach {tn trailing} {\n  sessionat-ipk \"\"\n  sessionat-wor \" WITHOUT ROWID \"\n} {\neval [string map [list %WR% $trailing] {\n  reset_test\n\n  #-----------------------------------------------------------------------\n  do_execsql_test $tn.1.0 {\n    CREATE TABLE t1(a, b, PRIMARY KEY(a)) %WR%;\n  }\n  do_execsql_test -db db2 $tn.1.1 {\n    CREATE TABLE t1(a, b, c, PRIMARY KEY(a, c)) %WR%;\n  }\n  do_test $tn.1.2 {\n    set ::log {}\n    do_then_apply_sql { INSERT INTO t1 VALUES('one', 'two') }\n    set ::log\n  } [list \\\n    SQLITE_SCHEMA {sqlite3changeset_apply(): primary key mismatch for table t1}\n  ]\n  do_execsql_test $tn.1.3 { SELECT * FROM t1 } {one two}\n  do_execsql_test -db db2 $tn.1.4 { SELECT * FROM t1 } {}\n\n  #-----------------------------------------------------------------------\n  do_execsql_test $tn.2.0 {\n    CREATE TABLE t2(x, y, z, PRIMARY KEY(x)) %WR%;\n  }\n  do_execsql_test -db db2 $tn.2.1 {\n    CREATE TABLE t2(x, y, PRIMARY KEY(x)) %WR%;\n  }\n  do_test $tn.2.2 {\n    db cache flush\n    set ::log {}\n    do_then_apply_sql { INSERT INTO t2 VALUES(1, 2, 3) }\n    set ::log\n  } [list SQLITE_SCHEMA \\\n    {sqlite3changeset_apply(): table t2 has 2 columns, expected 3 or more}\n  ]\n  do_execsql_test $tn.2.3 { SELECT * FROM t2 } {1 2 3}\n  do_execsql_test -db db2 $tn.2.4 { SELECT * FROM t2 } {}\n\n  #-----------------------------------------------------------------------\n  do_execsql_test $tn.3.0 {\n    CREATE TABLE t3(a, b, PRIMARY KEY(b)) %WR%;\n  }\n  do_execsql_test -db db2 $tn.3.1 {\n    CREATE TABLE t3(a, b, c DEFAULT 'D', PRIMARY KEY(b)) %WR%;\n  }\n  do_test $tn.3.2 {\n    do_then_apply_sql {\n      INSERT INTO t3 VALUES(1, 2);\n      INSERT INTO t3 VALUES(3, 4);\n      INSERT INTO t3 VALUES(5, 6);\n    };\n    db2 eval {SELECT * FROM t3}\n  } {1 2 D 3 4 D 5 6 D}\n  do_test $tn.3.3 {\n    do_then_apply_sql {\n      UPDATE t3 SET a=45 WHERE b=4;\n      DELETE FROM t3 WHERE a=5;\n    };\n    db2 eval {SELECT * FROM t3}\n  } {1 2 D 45 4 D}\n\n  #-----------------------------------------------------------------------\n  # 4.1: INSERT statements\n  # 4.2: DELETE statements\n  # 4.3: UPDATE statements\n  #  \n  do_execsql_test $tn.4.1.0 {\n    CREATE TABLE t4(x INTEGER PRIMARY KEY, y) %WR%;\n  }\n  do_execsql_test -db db2 $tn.4.1.1 {\n    CREATE TABLE t4(x INTEGER PRIMARY KEY, y, z) %WR%;\n    INSERT INTO t4 VALUES(1, 2, 3);\n    INSERT INTO t4 VALUES(4, 5, 6);\n  }\n  do_conflict_test $tn.4.1.2 -tables t4 -sql {\n    INSERT INTO t4 VALUES(10, 20);\n    INSERT INTO t4 VALUES(4, 11);\n  } -conflicts {\n    {INSERT t4 CONFLICT {i 4 i 11} {i 4 i 5}}\n  }\n  do_execsql_test -db db2 $tn.4.1.3 {\n    SELECT * FROM t4 ORDER BY x\n  } {1 2 3 4 5 6 10 20 {}}\n  do_conflict_test $tn.4.1.4 -policy REPLACE -tables t4 -sql {\n    INSERT INTO t4 VALUES(1, 11);\n  } -conflicts {\n    {INSERT t4 CONFLICT {i 1 i 11} {i 1 i 2}}\n  }\n  do_execsql_test -db db2 $tn.4.1.5 {\n    SELECT * FROM t4 ORDER BY x\n  } {1 11 {} 4 5 6 10 20 {}}\n\n  do_execsql_test $tn.4.2.0 {\n    DELETE FROM t4;\n    INSERT INTO t4 VALUES(1, 'A');\n    INSERT INTO t4 VALUES(2, 'B');\n    INSERT INTO t4 VALUES(3, 'C');\n    INSERT INTO t4 VALUES(4, 'D');\n  }\n  do_execsql_test -db db2 $tn.4.2.1 {\n    DELETE FROM t4;\n    INSERT INTO t4 VALUES(1, 'A', 'a');\n    INSERT INTO t4 VALUES(3, 'C', 'c');\n    INSERT INTO t4 VALUES(4, 'E', 'd');\n  }\n  do_conflict_test $tn.4.2.2 -tables t4 -sql {\n    DELETE FROM t4 WHERE x=2;\n    DELETE FROM t4 WHERE x=4;\n  } -conflicts {\n    {DELETE t4 NOTFOUND {i 2 t B}}\n    {DELETE t4 DATA {i 4 t D} {i 4 t E}}\n  }\n\n  do_execsql_test $tn.4.3.0 {\n    CREATE TABLE t5(a, b, c PRIMARY KEY) %WR%;\n    INSERT INTO t5 VALUES(1,1,1), (2,2,2), (3,3,3), (4,4,4);\n  }\n  do_execsql_test -db db2 $tn.4.3.1 {\n    CREATE TABLE t5(a, b, c PRIMARY KEY, d CHECK(b!=10)) %WR%;\n    INSERT INTO t5 VALUES (2,2,2,2), (3,8,3,3), (4,4,4,4);\n  }\n  do_conflict_test $tn.4.3.2 -tables t5 -sql {\n    UPDATE t5 SET a=4 WHERE c=1;\n    UPDATE t5 SET b=9 WHERE c=3;\n    UPDATE t5 SET b=10 WHERE c=2;\n  } -conflicts {\n    {UPDATE t5 NOTFOUND {i 1 {} {} i 1} {i 4 {} {} {} {}}}\n    {UPDATE t5 DATA {{} {} i 3 i 3} {{} {} i 9 {} {}} {i 3 i 8 i 3}}\n    {UPDATE t5 CONSTRAINT {{} {} i 2 i 2} {{} {} i 10 {} {}}}\n  }\n  \n  #-----------------------------------------------------------------------\n  do_execsql_test $tn.5.0 {\n    CREATE TABLE t6(a, b, c, PRIMARY KEY(a, b)) %WR%;\n  }\n  do_execsql_test -db db2 $tn.5.1 {\n    CREATE TABLE t6(a, b, c, d, e, PRIMARY KEY(a, b)) %WR%;\n  }\n  do_test $tn.5.2 {\n    set c1 [sql_exec_changeset db {\n      INSERT INTO t6 VALUES(1, 1, 1);\n      INSERT INTO t6 VALUES(2, 2, 2);\n    }]\n    set c2 [sql_exec_changeset db2 {\n      INSERT INTO t6 VALUES(3, 3, 3, 3, 3);\n      INSERT INTO t6 VALUES(4, 4, 4, 4, 4);\n    }]\n    list [catch { sqlite3changeset_concat $c1 $c2} msg] $msg\n  } {1 SQLITE_SCHEMA}\n\n  #-----------------------------------------------------------------------\n  db2 close\n  sqlite3 db2 test.db\n  do_execsql_test $tn.6.0 {\n    CREATE TABLE t7(a INTEGER PRIMARY KEY, b) %WR%;\n    INSERT INTO t7 VALUES(1, 1);\n    INSERT INTO t7 VALUES(2, 2);\n    INSERT INTO t7 VALUES(3, 3);\n  }\n\n  do_test $tn.6.1 {\n    set c1 [sql_exec_changeset db {\n      INSERT INTO t7 VALUES(4, 4);\n      DELETE FROM t7 WHERE a=1;\n      UPDATE t7 SET b=222 WHERE a=2;\n    }]\n    set cinv [sqlite3changeset_invert $c1]\n    execsql { SELECT * FROM t7 }\n  } {2 222 3 3 4 4}\n\n  do_execsql_test -db db2 $tn.6.2 {\n    ALTER TABLE t7 ADD COLUMN c DEFAULT 'ccc'\n  }\n\n  proc xConfict {args} { return \"OMIT\" }\n  do_test $tn.6.3 {\n    sqlite3changeset_apply db $cinv xConflict\n    execsql { SELECT * FROM t7 }\n  } {1 1 ccc 2 2 ccc 3 3 ccc}\n}]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessiondiff.test",
    "content": "# 2015-07-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the [sqldiff --changeset] command.\n#\n#\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n}\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessiondiff\n\nset PROG [test_find_sqldiff]\ndb close\n\nproc sqlesc {id} {\n  set ret \"'[string map {' ''} $id]'\"\n  set ret\n}\n\nproc database_cksum {db1} {\n  set txt \"\"\n\n  sqlite3 dbtmp $db1\n  foreach tbl [dbtmp eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n    set cols [list]\n    dbtmp eval \"PRAGMA table_info = [sqlesc $tbl]\" { \n      lappend cols \"quote( $name )\" \n    }\n    append txt [dbtmp eval \\\n      \"SELECT [join $cols {||'.'||}] FROM [sqlesc $tbl] ORDER BY 1\"\n    ]\n  }\n  dbtmp close\n\n  md5 $txt\n}\n\nproc readfile {filename} {\n  set fd [open $filename]\n  fconfigure $fd -translation binary -encoding binary\n  set data [read $fd]\n  close $fd\n  set data\n}\n\nproc get_changeset {db1 db2} {\n  exec $::PROG --changeset changeset.bin $db1 $db2\n  set bin [readfile changeset.bin]\n  return $bin\n}\n\nproc xConflict {args} { \n  return \"\" \n}\n\nproc do_changeset_test {tn sql1 sql2} {\n  forcedelete test.db123 test.db124 \n\n  sqlite3 db test.db123\n  db eval $sql1\n  db close\n\n  sqlite3 db test.db124\n  db eval $sql2\n\n  set cs [get_changeset test.db124 test.db123]\n  sqlite3changeset_apply db $cs xConflict\n  db close\n\n  set database_cksum1 [database_cksum test.db123]\n  set database_cksum2 [database_cksum test.db124]\n\n  uplevel [list \\\n      do_test $tn [list string compare $database_cksum1 $database_cksum2] 0\n  ]\n}\n\ndo_changeset_test 1.0 {\n  CREATE TABLE t1(x PRIMARY KEY);\n} {\n  CREATE TABLE t1(x PRIMARY KEY);\n}\n\ndo_changeset_test 1.1 {\n  CREATE TABLE t1(x PRIMARY KEY);\n  CREATE TABLE t2(x PRIMARY KEY, y);\n  INSERT INTO t2 VALUES(1, 2);\n} {\n  CREATE TABLE t1(x PRIMARY KEY);\n  CREATE TABLE t2(x PRIMARY KEY, y);\n  INSERT INTO t2 VALUES(3, 4);\n}\n\ndo_changeset_test 1.2 {\n  CREATE TABLE t2(a, b, c, PRIMARY KEY(b, c));\n  INSERT INTO t2 VALUES(1, 2, 3);\n  INSERT INTO t2 VALUES(4, 5, 6);\n} {\n  CREATE TABLE t2(a, b, c, PRIMARY KEY(b, c));\n  INSERT INTO t2 VALUES(1, 2, 11);\n  INSERT INTO t2 VALUES(7, 8, 9);\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionfault.test",
    "content": "# 2011 Mar 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the session module.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionfault\n\nforcedelete test.db2\nsqlite3 db2 test.db2\ndo_common_sql {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b));\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n}\nfaultsim_save_and_close\ndb2 close\n\n#-------------------------------------------------------------------------\n# Test OOM error handling when collecting and applying a simple changeset.\n#\n# Test 1.1 attaches tables individually by name to the session object. \n# Whereas test 1.2 passes NULL to sqlite3session_attach() to attach all\n# tables.\n#\ndo_faultsim_test 1.1 -faults oom-* -prep {\n  catch {db2 close}\n  catch {db close}\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db2\n} -body {\n  do_then_apply_sql {\n    INSERT INTO t1 VALUES('a string value', 8, 9);\n    UPDATE t1 SET c = 10 WHERE a = 1;\n    DELETE FROM t1 WHERE a = 4;\n  }\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  faultsim_integrity_check\n  if {$testrc==0} { compare_db db db2 }\n}\n\ndo_faultsim_test 1.2 -faults oom-* -prep {\n  catch {db2 close}\n  catch {db close}\n  faultsim_restore_and_reopen\n} -body {\n  sqlite3session S db main\n  S attach *\n  execsql {\n    INSERT INTO t1 VALUES('a string value', 8, 9);\n    UPDATE t1 SET c = 10 WHERE a = 1;\n    DELETE FROM t1 WHERE a = 4;\n  }\n  set ::changeset [S changeset]\n  set {} {}\n} -test {\n  catch { S delete }\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  faultsim_integrity_check\n  if {$testrc==0} { \n    proc xConflict {args} { return \"OMIT\" }\n    sqlite3 db2 test.db2\n    sqlite3changeset_apply db2 $::changeset xConflict\n    compare_db db db2 \n  }\n}\n\n#-------------------------------------------------------------------------\n# The following block of tests - 2.* - are designed to check \n# the handling of faults in the sqlite3changeset_apply() function.\n#\ncatch {db close}\ncatch {db2 close}\nforcedelete test.db2 test.db\nsqlite3 db2 test.db2\nsqlite3 db test.db\ndo_common_sql {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b));\n  INSERT INTO t1 VALUES('apple', 'orange', 'pear');\n\n  CREATE TABLE t2(x PRIMARY KEY, y);\n}\ndb2 close\nfaultsim_save_and_close\n\n\nforeach {tn conflict_policy sql sql2} {\n  1 OMIT { INSERT INTO t1 VALUES('one text', 'two text', X'00ff00') } {}\n  2 OMIT { DELETE FROM t1 WHERE a = 'apple' }                         {}\n  3 OMIT { UPDATE t1 SET c = 'banana' WHERE b = 'orange' }            {}\n  4 REPLACE { INSERT INTO t2 VALUES('keyvalue', 'value 1') } {\n    INSERT INTO t2 VALUES('keyvalue', 'value 2');\n  }\n} {\n  proc xConflict args [list return $conflict_policy]\n\n  do_faultsim_test 2.$tn -faults oom-transient -prep {\n    catch {db2 close}\n    catch {db close}\n    faultsim_restore_and_reopen\n    set ::changeset [changeset_from_sql $::sql]\n    sqlite3 db2 test.db2\n    sqlite3_db_config_lookaside db2 0 0 0\n    execsql $::sql2 db2\n  } -body {\n    sqlite3changeset_apply db2 $::changeset xConflict\n  } -test {\n    faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n    faultsim_integrity_check\n    if {$testrc==0} { compare_db db db2 }\n  }\n}\n\n#-------------------------------------------------------------------------\n# This test case is designed so that a malloc() failure occurs while\n# resizing the session object hash-table from 256 to 512 buckets. This\n# is not an error, just a sub-optimal condition.\n#\ndo_faultsim_test 3 -faults oom-* -prep {\n  catch {db2 close}\n  catch {db close}\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db2\n\n  sqlite3session S db main\n  S attach t1\n  execsql { BEGIN }\n  for {set i 0} {$i < 125} {incr i} {\n    execsql {INSERT INTO t1 VALUES(10+$i, 10+$i, 10+$i)}\n  }\n} -body {\n  for {set i 125} {$i < 133} {incr i} {\n    execsql {INSERT INTO t1 VALUES(10+$i, 10+$i, 1-+$i)}\n  }\n  S changeset\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} { \n    sqlite3changeset_apply db2 [S changeset] xConflict\n    compare_db db db2 \n  }\n  catch { S delete }\n  faultsim_integrity_check\n}\n\ncatch { db close }\ncatch { db2 close }\nforcedelete test.db2 test.db\nsqlite3 db2 test.db2\nsqlite3 db test.db\n\nproc xConflict {op tbl type args} {\n  if { $type==\"CONFLICT\" || $type==\"DATA\" } {\n    return \"REPLACE\"\n  }\n  return \"OMIT\"\n}\n\ndo_test 4.0 {\n  execsql {\n    PRAGMA encoding = 'utf16';\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(5, 32);\n  }\n  execsql {\n    PRAGMA encoding = 'utf16';\n    CREATE TABLE t1(a PRIMARY KEY, b NOT NULL);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(2, 4);\n    INSERT INTO t1 VALUES(4, 16);\n  } db2\n} {}\n\nfaultsim_save_and_close\ndb2 close\n\ndo_faultsim_test 4 -faults oom-* -prep {\n  catch {db2 close}\n  catch {db close}\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db2\n  sqlite3session S db main\n  S attach t1\n  execsql {\n    INSERT INTO t1 VALUES(1, 45);\n    INSERT INTO t1 VALUES(2, 55);\n    INSERT INTO t1 VALUES(3, 55);\n    UPDATE t1 SET a = 4 WHERE a = 5;\n  }\n} -body {\n  sqlite3changeset_apply db2 [S changeset] xConflict\n} -test {\n  catch { S delete }\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} { compare_db db db2 }\n}\n\n#-------------------------------------------------------------------------\n# This block of tests verifies that OOM faults in the \n# sqlite3changeset_invert() function are handled correctly.\n#\ncatch {db close}\ncatch {db2 close}\nforcedelete test.db\nsqlite3 db test.db\nexecsql {\n  CREATE TABLE t1(a, b, PRIMARY KEY(b));\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('string', 1);\n  INSERT INTO t1 VALUES(4, 2);\n  INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);\n}\nset changeset [changeset_from_sql {\n  INSERT INTO t1 VALUES('xxx', 'yyy');\n  DELETE FROM t1 WHERE a = 'string';\n  UPDATE t1 SET a = 20 WHERE b = 2;\n}]\ndb close\n\ndo_faultsim_test 5.1 -faults oom* -body {\n  set ::inverse [sqlite3changeset_invert $::changeset]\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    set x [list]\n    sqlite3session_foreach c $::inverse { lappend x $c }\n    foreach c {\n        {DELETE t1 0 .X {t xxx t yyy} {}} \n        {INSERT t1 0 .X {} {t string i 1}} \n        {UPDATE t1 0 .X {i 20 i 2} {i 4 {} {}}}\n    } { lappend y $c }\n    if {$x != $y} { error \"changeset no good\" }\n  }\n}\n\ncatch {db close}\ncatch {db2 close}\nforcedelete test.db\nsqlite3 db test.db\nexecsql {\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t2 VALUES(1, 'abc');\n  INSERT INTO t2 VALUES(2, 'def');\n}\nset changeset [changeset_from_sql {\n  UPDATE t2 SET b = (b || b || b || b);\n  UPDATE t2 SET b = (b || b || b || b);\n  UPDATE t2 SET b = (b || b || b || b);\n  UPDATE t2 SET b = (b || b || b || b);\n}]\ndb close\nset abc [string repeat abc 256]\nset def [string repeat def 256]\n\ndo_faultsim_test 5.2 -faults oom-tra* -body {\n  set ::inverse [sqlite3changeset_invert $::changeset]\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    set x [list]\n    sqlite3session_foreach c $::inverse { lappend x $c }\n    foreach c \"\n        {UPDATE t2 0 X. {i 1 t $::abc} {{} {} t abc}}\n        {UPDATE t2 0 X. {i 2 t $::def} {{} {} t def}}\n    \" { lappend y $c }\n    if {$x != $y} { error \"changeset no good\" }\n  }\n}\n\ncatch {db close}\ncatch {db2 close}\nforcedelete test.db\nsqlite3 db test.db\nset abc [string repeat abc 256]\nset def [string repeat def 256]\nexecsql \"\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t2 VALUES(1, '$abc');\n\"\nset changeset [changeset_from_sql \"\n  INSERT INTO t2 VALUES(2, '$def');\n  DELETE FROM t2 WHERE a = 1;\n\"]\ndb close\n\ndo_faultsim_test 5.3 -faults oom-tra* -body {\n  set ::inverse [sqlite3changeset_invert $::changeset]\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    set x [list]\n    sqlite3session_foreach c $::inverse { lappend x $c }\n    foreach c \"\n        {INSERT t2 0 X. {} {i 1 t $::abc}}\n        {DELETE t2 0 X. {i 2 t $::def} {}}\n    \" { lappend y $c }\n    if {$x != $y} { error \"changeset no good\" }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that OOM errors in sqlite3changeset_concat() are handled correctly.\n#\ncatch {db close}\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 5.prep1 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(b));\n  CREATE TABLE t2(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES('string', 1);\n  INSERT INTO t1 VALUES(4, 2);\n  INSERT INTO t1 VALUES(X'FFAAFFAAFFAA', 3);\n}\n\ndo_test 6.prep2 {\n  sqlite3session M db main\n  M attach *\n  set ::c2 [changeset_from_sql {\n    INSERT INTO t2 VALUES(randomblob(1000), randomblob(1000));\n    INSERT INTO t2 VALUES('one', 'two');\n    INSERT INTO t2 VALUES(1, NULL);\n    UPDATE t1 SET a = 5 WHERE a = 2;\n  }]\n  set ::c1 [changeset_from_sql {\n    DELETE FROM t2 WHERE a = 1;\n    UPDATE t1 SET a = 4 WHERE a = 2;\n    INSERT INTO t2 VALUES('x', 'y');\n  }]\n  set ::total [changeset_to_list [M changeset]]\n  M delete\n} {}\n\ndo_faultsim_test 6 -faults oom-* -body {\n  set ::result [sqlite3changeset_concat $::c1 $::c2]\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    set v [changeset_to_list $::result]\n    if {$v != $::total} { error \"result no good\" }\n  }\n}\n\nfaultsim_delete_and_reopen\ndo_execsql_test 7.prep1 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(a));\n}\nfaultsim_save_and_close\n\nset res [list]\nfor {set ::i 0} {$::i < 480} {incr ::i 4} {\n  lappend res \"INSERT t1 0 X. {} {i $::i i $::i}\"\n}\nset res [lsort $res]\ndo_faultsim_test 7 -faults oom-transient -prep {\n  catch { S delete }\n  faultsim_restore_and_reopen\n  sqlite3session S db main\n  S attach *\n} -body {\n  for {set ::i 0} {$::i < 480} {incr ::i 4} {\n    execsql {INSERT INTO t1 VALUES($::i, $::i)}\n  }\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    set cres [list [catch {changeset_to_list [S changeset]} msg] $msg]\n    S delete\n    if {$cres != \"1 SQLITE_NOMEM\" && $cres != \"0 {$::res}\"} {\n      error \"Expected {0 $::res} Got {$cres}\"\n    }\n  } else {\n    catch { S changeset }\n    catch { S delete }\n  }\n}\n\nfaultsim_delete_and_reopen\ndo_test 8.prep {\n  sqlite3session S db main\n  S attach *\n  execsql { \n    CREATE TABLE t1(a, b, PRIMARY KEY(a)); \n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n  }\n  set ::changeset [S changeset]\n  S delete\n} {}\n\nset expected [normalize_list {\n  {INSERT t1 0 X. {} {i 1 i 2}} \n  {INSERT t1 0 X. {} {i 3 i 4}} \n  {INSERT t1 0 X. {} {i 5 i 6}}\n}]\ndo_faultsim_test 8.1 -faults oom* -body {\n  set ::res [list]\n  sqlite3session_foreach -next v $::changeset { lappend ::res $v }\n  normalize_list $::res\n} -test {\n  faultsim_test_result [list 0 $::expected] {1 SQLITE_NOMEM}\n}\ndo_faultsim_test 8.2 -faults oom* -body {\n  set ::res [list]\n  sqlite3session_foreach v $::changeset { lappend ::res $v }\n  normalize_list $::res\n} -test {\n  faultsim_test_result [list 0 $::expected] {1 SQLITE_NOMEM}\n}\n\nfaultsim_delete_and_reopen\ndo_test 9.1.prep {\n  execsql { \n    PRAGMA encoding = 'utf16';\n    CREATE TABLE t1(a PRIMARY KEY, b);\n  }\n} {}\nfaultsim_save_and_close\n\nset answers [list {0 {}} {1 SQLITE_NOMEM} \\\n                  {1 {callback requested query abort}} \\\n                  {1 {abort due to ROLLBACK}}]\ndo_faultsim_test 9.1 -faults oom-transient -prep {\n  catch { unset ::c }\n  faultsim_restore_and_reopen\n  sqlite3session S db main\n  S attach *\n} -body {\n  execsql {\n    INSERT INTO t1 VALUES('abcdefghijklmnopqrstuv', 'ABCDEFGHIJKLMNOPQRSTUV');\n  }\n  set ::c [S changeset]\n  set {} {}\n} -test {\n  S delete\n  eval faultsim_test_result $::answers\n  if {[info exists ::c]} {\n    set expected [normalize_list {\n      {INSERT t1 0 X. {} {t abcdefghijklmnopqrstuv t ABCDEFGHIJKLMNOPQRSTUV}}\n    }]\n    if { [changeset_to_list $::c] != $expected } {\n      error \"changeset mismatch\"\n    }\n  }\n}\n\nfaultsim_delete_and_reopen\ndo_test 9.2.prep {\n  execsql { \n    PRAGMA encoding = 'utf16';\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES('abcdefghij', 'ABCDEFGHIJKLMNOPQRSTUV');\n  }\n} {}\nfaultsim_save_and_close\n\nset answers [list {0 {}} {1 SQLITE_NOMEM} \\\n                  {1 {callback requested query abort}} \\\n                  {1 {abort due to ROLLBACK}}]\ndo_faultsim_test 9.2 -faults oom-transient -prep {\n  catch { unset ::c }\n  faultsim_restore_and_reopen\n  sqlite3session S db main\n  S attach *\n} -body {\n  execsql {\n    UPDATE t1 SET b = 'xyz';\n  }\n  set ::c [S changeset]\n  set {} {}\n} -test {\n  S delete\n  eval faultsim_test_result $::answers\n  if {[info exists ::c]} {\n    set expected [normalize_list {\n      {UPDATE t1 0 X. {t abcdefghij t ABCDEFGHIJKLMNOPQRSTUV} {{} {} t xyz}}\n    }]\n    if { [changeset_to_list $::c] != $expected } {\n      error \"changeset mismatch\"\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that if a conflict-handler encounters an OOM in \n# sqlite3_value_text() but goes on to return SQLITE_CHANGESET_REPLACE\n# anyway, the OOM is picked up by the sessions module.\nset bigstr [string repeat abcdefghij 100]\nfaultsim_delete_and_reopen\ndo_test 10.prep.1  {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES($bigstr, $bigstr);\n  }\n\n  sqlite3session S db main\n  S attach *\n  execsql { UPDATE t1 SET b = b||'x' }\n  set C [S changeset]\n  S delete\n  execsql { UPDATE t1 SET b = b||'xyz' }\n} {}\nfaultsim_save_and_close\n\nfaultsim_restore_and_reopen\ndo_test 10.prep.2  {\n  proc xConflict {args} { return \"ABORT\" }\n  list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg\n} {1 SQLITE_ABORT}\ndo_execsql_test 10.prep.3 { SELECT b=$bigstr||'x' FROM t1 } 0\ndo_test 10.prep.4  {\n  proc xConflict {args} { return \"REPLACE\" }\n  list [catch { sqlite3changeset_apply db $C xConflict } msg] $msg\n} {0 {}}\ndo_execsql_test 10.prep.5 { SELECT b=$bigstr||'x' FROM t1 } 1\ndb close\n\ndo_faultsim_test 10 -faults oom-tra* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  sqlite3changeset_apply_replace_all db $::C \n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    if {[db one {SELECT b=$bigstr||'x' FROM t1}]==0} {\n      error \"data does not look right\"\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test an OOM with an sqlite3changeset_apply() filter callback.\n#\nreset_db\ndo_test 11.prep {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(x PRIMARY KEY, y);\n    BEGIN;\n  }\n\n  set ::cs [changeset_from_sql { \n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES('x', 'y');\n  }]\n\n  execsql ROLLBACK\n  set {} {}\n} {}\n\nproc filter {x} { return [string equal t1 $x] } \nfaultsim_save_and_close\n\ndo_faultsim_test 11 -faults oom-tra* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  sqlite3changeset_apply db $::cs {} filter\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  if {$testrc==0} {\n    if {[db eval {SELECT * FROM t1 UNION ALL SELECT * FROM t2}] != \"1 2\"} {\n      error \"data does not look right\"\n    }\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionfault2.test",
    "content": "# 2016 March 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the session module.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\nset testprefix sessionfault2\n\ndo_execsql_test 1.0.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(3, 3);\n\n  CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t2 VALUES(1, 1);\n  INSERT INTO t2 VALUES(2, 2);\n  INSERT INTO t2 VALUES(3, 3);\n}\nfaultsim_save_and_close\n\nfaultsim_restore_and_reopen\ndo_test 1.0.1 {\n  set ::C [changeset_from_sql {\n    UPDATE t1 SET b=4 WHERE a=3;\n    UPDATE t1 SET b=3 WHERE a=2;\n    UPDATE t1 SET b=2 WHERE a=1;\n    UPDATE t2 SET b=0 WHERE a=1;\n    UPDATE t2 SET b=1 WHERE a=2;\n    UPDATE t2 SET b=2 WHERE a=3;\n  }]\n  set {} {}\n} {}\n\nproc xConflict args { return \"OMIT\" }\n\ndo_faultsim_test 1 -faults oom-p* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  sqlite3changeset_apply db $::C xConflict\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  faultsim_integrity_check\n\n  catch { db eval ROLLBACK }\n  set res [db eval {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }]\n\n  if {$testrc==0} {\n    if {$res != \"1 2 2 3 3 4 1 0 2 1 3 2\"} { error \"data error\" }\n  } else {\n    if {\n         $res != \"1 2 2 3 3 4 1 0 2 1 3 2\"\n      && $res != \"1 1 2 2 3 3 1 1 2 2 3 3\"\n    } { error \"data error!! $res\" }\n  }\n}\n\n#-------------------------------------------------------------------------\n# OOM when applying a changeset for which one of the tables has a name\n# 99 bytes in size. This happens to cause an extra malloc in within the\n# sessions_strm permutation.\n#\nreset_db\nset nm [string repeat t 99]\ndo_execsql_test 2.0.0 [string map \"%TBL% $nm\" {\n  CREATE TABLE %TBL%(a PRIMARY KEY, b UNIQUE);\n}]\nfaultsim_save_and_close\n\nfaultsim_restore_and_reopen\ndo_test 1.0.1 {\n  set ::C [changeset_from_sql [string map \"%TBL% $nm\" {\n    INSERT INTO %TBL% VALUES(1, 2);\n    INSERT INTO %TBL% VALUES(3, 4);\n  }]]\n  set {} {}\n} {}\n\nproc xConflict args { return \"OMIT\" }\ndo_faultsim_test 2 -faults oom-p* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  sqlite3changeset_apply db $::C xConflict\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM}\n  faultsim_integrity_check\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sessionwor.test",
    "content": "# 2017 Jan 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the session module. Specifically,\n# testing support for WITHOUT ROWID tables.\n#\n\nif {![info exists testdir]} {\n  set testdir [file join [file dirname [info script]] .. .. test]\n} \nsource [file join [file dirname [info script]] session_common.tcl]\nsource $testdir/tester.tcl\nifcapable !session {finish_test; return}\n\nset testprefix sessionwor\n\nproc test_reset {} {\n  catch { db close }\n  catch { db2 close }\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  sqlite3 db2 test.db2\n}\n\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID;\n}\n\ndo_iterator_test 1.1 t1 {\n  INSERT INTO t1 VALUES('one', 'two');\n} {\n  {INSERT t1 0 X. {} {t one t two}}\n}\n\ndo_iterator_test 1.2 t1 {\n  UPDATE t1 SET b='three'\n} {\n  {UPDATE t1 0 X. {t one t two} {{} {} t three}}\n}\n\ndo_iterator_test 1.3 t1 {\n  DELETE FROM t1;\n} {\n  {DELETE t1 0 X. {t one t three} {}}\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sqlite3session.c",
    "content": "\n#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n#include \"sqlite3session.h\"\n#include <assert.h>\n#include <string.h>\n\n#ifndef SQLITE_AMALGAMATION\n# include \"sqliteInt.h\"\n# include \"vdbeInt.h\"\n#endif\n\ntypedef struct SessionTable SessionTable;\ntypedef struct SessionChange SessionChange;\ntypedef struct SessionBuffer SessionBuffer;\ntypedef struct SessionInput SessionInput;\n\n/*\n** Minimum chunk size used by streaming versions of functions.\n*/\n#ifndef SESSIONS_STRM_CHUNK_SIZE\n# ifdef SQLITE_TEST\n#   define SESSIONS_STRM_CHUNK_SIZE 64\n# else\n#   define SESSIONS_STRM_CHUNK_SIZE 1024\n# endif\n#endif\n\ntypedef struct SessionHook SessionHook;\nstruct SessionHook {\n  void *pCtx;\n  int (*xOld)(void*,int,sqlite3_value**);\n  int (*xNew)(void*,int,sqlite3_value**);\n  int (*xCount)(void*);\n  int (*xDepth)(void*);\n};\n\n/*\n** Session handle structure.\n*/\nstruct sqlite3_session {\n  sqlite3 *db;                    /* Database handle session is attached to */\n  char *zDb;                      /* Name of database session is attached to */\n  int bEnable;                    /* True if currently recording */\n  int bIndirect;                  /* True if all changes are indirect */\n  int bAutoAttach;                /* True to auto-attach tables */\n  int rc;                         /* Non-zero if an error has occurred */\n  void *pFilterCtx;               /* First argument to pass to xTableFilter */\n  int (*xTableFilter)(void *pCtx, const char *zTab);\n  sqlite3_session *pNext;         /* Next session object on same db. */\n  SessionTable *pTable;           /* List of attached tables */\n  SessionHook hook;               /* APIs to grab new and old data with */\n};\n\n/*\n** Instances of this structure are used to build strings or binary records.\n*/\nstruct SessionBuffer {\n  u8 *aBuf;                       /* Pointer to changeset buffer */\n  int nBuf;                       /* Size of buffer aBuf */\n  int nAlloc;                     /* Size of allocation containing aBuf */\n};\n\n/*\n** An object of this type is used internally as an abstraction for \n** input data. Input data may be supplied either as a single large buffer\n** (e.g. sqlite3changeset_start()) or using a stream function (e.g.\n**  sqlite3changeset_start_strm()).\n*/\nstruct SessionInput {\n  int bNoDiscard;                 /* If true, discard no data */\n  int iCurrent;                   /* Offset in aData[] of current change */\n  int iNext;                      /* Offset in aData[] of next change */\n  u8 *aData;                      /* Pointer to buffer containing changeset */\n  int nData;                      /* Number of bytes in aData */\n\n  SessionBuffer buf;              /* Current read buffer */\n  int (*xInput)(void*, void*, int*);        /* Input stream call (or NULL) */\n  void *pIn;                                /* First argument to xInput */\n  int bEof;                       /* Set to true after xInput finished */\n};\n\n/*\n** Structure for changeset iterators.\n*/\nstruct sqlite3_changeset_iter {\n  SessionInput in;                /* Input buffer or stream */\n  SessionBuffer tblhdr;           /* Buffer to hold apValue/zTab/abPK/ */\n  int bPatchset;                  /* True if this is a patchset */\n  int rc;                         /* Iterator error code */\n  sqlite3_stmt *pConflict;        /* Points to conflicting row, if any */\n  char *zTab;                     /* Current table */\n  int nCol;                       /* Number of columns in zTab */\n  int op;                         /* Current operation */\n  int bIndirect;                  /* True if current change was indirect */\n  u8 *abPK;                       /* Primary key array */\n  sqlite3_value **apValue;        /* old.* and new.* values */\n};\n\n/*\n** Each session object maintains a set of the following structures, one\n** for each table the session object is monitoring. The structures are\n** stored in a linked list starting at sqlite3_session.pTable.\n**\n** The keys of the SessionTable.aChange[] hash table are all rows that have\n** been modified in any way since the session object was attached to the\n** table.\n**\n** The data associated with each hash-table entry is a structure containing\n** a subset of the initial values that the modified row contained at the\n** start of the session. Or no initial values if the row was inserted.\n*/\nstruct SessionTable {\n  SessionTable *pNext;\n  char *zName;                    /* Local name of table */\n  int nCol;                       /* Number of columns in table zName */\n  const char **azCol;             /* Column names */\n  u8 *abPK;                       /* Array of primary key flags */\n  int nEntry;                     /* Total number of entries in hash table */\n  int nChange;                    /* Size of apChange[] array */\n  SessionChange **apChange;       /* Hash table buckets */\n};\n\n/* \n** RECORD FORMAT:\n**\n** The following record format is similar to (but not compatible with) that \n** used in SQLite database files. This format is used as part of the \n** change-set binary format, and so must be architecture independent.\n**\n** Unlike the SQLite database record format, each field is self-contained -\n** there is no separation of header and data. Each field begins with a\n** single byte describing its type, as follows:\n**\n**       0x00: Undefined value.\n**       0x01: Integer value.\n**       0x02: Real value.\n**       0x03: Text value.\n**       0x04: Blob value.\n**       0x05: SQL NULL value.\n**\n** Note that the above match the definitions of SQLITE_INTEGER, SQLITE_TEXT\n** and so on in sqlite3.h. For undefined and NULL values, the field consists\n** only of the single type byte. For other types of values, the type byte\n** is followed by:\n**\n**   Text values:\n**     A varint containing the number of bytes in the value (encoded using\n**     UTF-8). Followed by a buffer containing the UTF-8 representation\n**     of the text value. There is no nul terminator.\n**\n**   Blob values:\n**     A varint containing the number of bytes in the value, followed by\n**     a buffer containing the value itself.\n**\n**   Integer values:\n**     An 8-byte big-endian integer value.\n**\n**   Real values:\n**     An 8-byte big-endian IEEE 754-2008 real value.\n**\n** Varint values are encoded in the same way as varints in the SQLite \n** record format.\n**\n** CHANGESET FORMAT:\n**\n** A changeset is a collection of DELETE, UPDATE and INSERT operations on\n** one or more tables. Operations on a single table are grouped together,\n** but may occur in any order (i.e. deletes, updates and inserts are all\n** mixed together).\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x54 (capital 'T')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   old.* record: (delete and update only)\n**   new.* record: (insert and update only)\n**\n** The \"old.*\" and \"new.*\" records, if present, are N field records in the\n** format described above under \"RECORD FORMAT\", where N is the number of\n** columns in the table. The i'th field of each record is associated with\n** the i'th column of the table, counting from left to right in the order\n** in which columns were declared in the CREATE TABLE statement.\n**\n** The new.* record that is part of each INSERT change contains the values\n** that make up the new row. Similarly, the old.* record that is part of each\n** DELETE change contains the values that made up the row that was deleted \n** from the database. In the changeset format, the records that are part\n** of INSERT or DELETE changes never contain any undefined (type byte 0x00)\n** fields.\n**\n** Within the old.* record associated with an UPDATE change, all fields\n** associated with table columns that are not PRIMARY KEY columns and are\n** not modified by the UPDATE change are set to \"undefined\". Other fields\n** are set to the values that made up the row before the UPDATE that the\n** change records took place. Within the new.* record, fields associated \n** with table columns modified by the UPDATE change contain the new \n** values. Fields associated with table columns that are not modified\n** are set to \"undefined\".\n**\n** PATCHSET FORMAT:\n**\n** A patchset is also a collection of changes. It is similar to a changeset,\n** but leaves undefined those fields that are not useful if no conflict\n** resolution is required when applying the changeset.\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x50 (capital 'P')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   single record: (PK fields for DELETE, PK and modified fields for UPDATE,\n**                   full record for INSERT).\n**\n** As in the changeset format, each field of the single record that is part\n** of a patchset change is associated with the correspondingly positioned\n** table column, counting from left to right within the CREATE TABLE \n** statement.\n**\n** For a DELETE change, all fields within the record except those associated\n** with PRIMARY KEY columns are set to \"undefined\". The PRIMARY KEY fields\n** contain the values identifying the row to delete.\n**\n** For an UPDATE change, all fields except those associated with PRIMARY KEY\n** columns and columns that are modified by the UPDATE are set to \"undefined\".\n** PRIMARY KEY fields contain the values identifying the table row to update,\n** and fields associated with modified columns contain the new column values.\n**\n** The records associated with INSERT changes are in the same format as for\n** changesets. It is not possible for a record associated with an INSERT\n** change to contain a field set to \"undefined\".\n*/\n\n/*\n** For each row modified during a session, there exists a single instance of\n** this structure stored in a SessionTable.aChange[] hash table.\n*/\nstruct SessionChange {\n  int op;                         /* One of UPDATE, DELETE, INSERT */\n  int bIndirect;                  /* True if this change is \"indirect\" */\n  int nRecord;                    /* Number of bytes in buffer aRecord[] */\n  u8 *aRecord;                    /* Buffer containing old.* record */\n  SessionChange *pNext;           /* For hash-table collisions */\n};\n\n/*\n** Write a varint with value iVal into the buffer at aBuf. Return the \n** number of bytes written.\n*/\nstatic int sessionVarintPut(u8 *aBuf, int iVal){\n  return putVarint32(aBuf, iVal);\n}\n\n/*\n** Return the number of bytes required to store value iVal as a varint.\n*/\nstatic int sessionVarintLen(int iVal){\n  return sqlite3VarintLen(iVal);\n}\n\n/*\n** Read a varint value from aBuf[] into *piVal. Return the number of \n** bytes read.\n*/\nstatic int sessionVarintGet(u8 *aBuf, int *piVal){\n  return getVarint32(aBuf, *piVal);\n}\n\n/* Load an unaligned and unsigned 32-bit integer */\n#define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Read a 64-bit big-endian integer value from buffer aRec[]. Return\n** the value read.\n*/\nstatic sqlite3_int64 sessionGetI64(u8 *aRec){\n  u64 x = SESSION_UINT32(aRec);\n  u32 y = SESSION_UINT32(aRec+4);\n  x = (x<<32) + y;\n  return (sqlite3_int64)x;\n}\n\n/*\n** Write a 64-bit big-endian integer value to the buffer aBuf[].\n*/\nstatic void sessionPutI64(u8 *aBuf, sqlite3_int64 i){\n  aBuf[0] = (i>>56) & 0xFF;\n  aBuf[1] = (i>>48) & 0xFF;\n  aBuf[2] = (i>>40) & 0xFF;\n  aBuf[3] = (i>>32) & 0xFF;\n  aBuf[4] = (i>>24) & 0xFF;\n  aBuf[5] = (i>>16) & 0xFF;\n  aBuf[6] = (i>> 8) & 0xFF;\n  aBuf[7] = (i>> 0) & 0xFF;\n}\n\n/*\n** This function is used to serialize the contents of value pValue (see\n** comment titled \"RECORD FORMAT\" above).\n**\n** If it is non-NULL, the serialized form of the value is written to \n** buffer aBuf. *pnWrite is set to the number of bytes written before\n** returning. Or, if aBuf is NULL, the only thing this function does is\n** set *pnWrite.\n**\n** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs\n** within a call to sqlite3_value_text() (may fail if the db is utf-16)) \n** SQLITE_NOMEM is returned.\n*/\nstatic int sessionSerializeValue(\n  u8 *aBuf,                       /* If non-NULL, write serialized value here */\n  sqlite3_value *pValue,          /* Value to serialize */\n  int *pnWrite                    /* IN/OUT: Increment by bytes written */\n){\n  int nByte;                      /* Size of serialized value in bytes */\n\n  if( pValue ){\n    int eType;                    /* Value type (SQLITE_NULL, TEXT etc.) */\n  \n    eType = sqlite3_value_type(pValue);\n    if( aBuf ) aBuf[0] = eType;\n  \n    switch( eType ){\n      case SQLITE_NULL: \n        nByte = 1;\n        break;\n  \n      case SQLITE_INTEGER: \n      case SQLITE_FLOAT:\n        if( aBuf ){\n          /* TODO: SQLite does something special to deal with mixed-endian\n          ** floating point values (e.g. ARM7). This code probably should\n          ** too.  */\n          u64 i;\n          if( eType==SQLITE_INTEGER ){\n            i = (u64)sqlite3_value_int64(pValue);\n          }else{\n            double r;\n            assert( sizeof(double)==8 && sizeof(u64)==8 );\n            r = sqlite3_value_double(pValue);\n            memcpy(&i, &r, 8);\n          }\n          sessionPutI64(&aBuf[1], i);\n        }\n        nByte = 9; \n        break;\n  \n      default: {\n        u8 *z;\n        int n;\n        int nVarint;\n  \n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        if( eType==SQLITE_TEXT ){\n          z = (u8 *)sqlite3_value_text(pValue);\n        }else{\n          z = (u8 *)sqlite3_value_blob(pValue);\n        }\n        n = sqlite3_value_bytes(pValue);\n        if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        nVarint = sessionVarintLen(n);\n  \n        if( aBuf ){\n          sessionVarintPut(&aBuf[1], n);\n          if( n ) memcpy(&aBuf[nVarint + 1], z, n);\n        }\n  \n        nByte = 1 + nVarint + n;\n        break;\n      }\n    }\n  }else{\n    nByte = 1;\n    if( aBuf ) aBuf[0] = '\\0';\n  }\n\n  if( pnWrite ) *pnWrite += nByte;\n  return SQLITE_OK;\n}\n\n\n/*\n** This macro is used to calculate hash key values for data structures. In\n** order to use this macro, the entire data structure must be represented\n** as a series of unsigned integers. In order to calculate a hash-key value\n** for a data structure represented as three such integers, the macro may\n** then be used as follows:\n**\n**    int hash_key_value;\n**    hash_key_value = HASH_APPEND(0, <value 1>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 2>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 3>);\n**\n** In practice, the data structures this macro is used for are the primary\n** key values of modified rows.\n*/\n#define HASH_APPEND(hash, add) ((hash) << 3) ^ (hash) ^ (unsigned int)(add)\n\n/*\n** Append the hash of the 64-bit integer passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendI64(unsigned int h, i64 i){\n  h = HASH_APPEND(h, i & 0xFFFFFFFF);\n  return HASH_APPEND(h, (i>>32)&0xFFFFFFFF);\n}\n\n/*\n** Append the hash of the blob passed via the second and third arguments to \n** the hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendBlob(unsigned int h, int n, const u8 *z){\n  int i;\n  for(i=0; i<n; i++) h = HASH_APPEND(h, z[i]);\n  return h;\n}\n\n/*\n** Append the hash of the data type passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendType(unsigned int h, int eType){\n  return HASH_APPEND(h, eType);\n}\n\n/*\n** This function may only be called from within a pre-update callback.\n** It calculates a hash based on the primary key values of the old.* or \n** new.* row currently available and, assuming no error occurs, writes it to\n** *piHash before returning. If the primary key contains one or more NULL\n** values, *pbNullPK is set to true before returning.\n**\n** If an error occurs, an SQLite error code is returned and the final values\n** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned\n** and the output variables are set as described above.\n*/\nstatic int sessionPreupdateHash(\n  sqlite3_session *pSession,      /* Session object that owns pTab */\n  SessionTable *pTab,             /* Session table handle */\n  int bNew,                       /* True to hash the new.* PK */\n  int *piHash,                    /* OUT: Hash value */\n  int *pbNullPK                   /* OUT: True if there are NULL values in PK */\n){\n  unsigned int h = 0;             /* Hash value to return */\n  int i;                          /* Used to iterate through columns */\n\n  assert( *pbNullPK==0 );\n  assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );\n  for(i=0; i<pTab->nCol; i++){\n    if( pTab->abPK[i] ){\n      int rc;\n      int eType;\n      sqlite3_value *pVal;\n\n      if( bNew ){\n        rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);\n      }else{\n        rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n\n      eType = sqlite3_value_type(pVal);\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal;\n        if( eType==SQLITE_INTEGER ){\n          iVal = sqlite3_value_int64(pVal);\n        }else{\n          double rVal = sqlite3_value_double(pVal);\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&iVal, &rVal, 8);\n        }\n        h = sessionHashAppendI64(h, iVal);\n      }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        const u8 *z;\n        int n;\n        if( eType==SQLITE_TEXT ){\n          z = (const u8 *)sqlite3_value_text(pVal);\n        }else{\n          z = (const u8 *)sqlite3_value_blob(pVal);\n        }\n        n = sqlite3_value_bytes(pVal);\n        if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        h = sessionHashAppendBlob(h, n, z);\n      }else{\n        assert( eType==SQLITE_NULL );\n        *pbNullPK = 1;\n      }\n    }\n  }\n\n  *piHash = (h % pTab->nChange);\n  return SQLITE_OK;\n}\n\n/*\n** The buffer that the argument points to contains a serialized SQL value.\n** Return the number of bytes of space occupied by the value (including\n** the type byte).\n*/\nstatic int sessionSerialLen(u8 *a){\n  int e = *a;\n  int n;\n  if( e==0 ) return 1;\n  if( e==SQLITE_NULL ) return 1;\n  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;\n  return sessionVarintGet(&a[1], &n) + 1 + n;\n}\n\n/*\n** Based on the primary key values stored in change aRecord, calculate a\n** hash key. Assume the has table has nBucket buckets. The hash keys\n** calculated by this function are compatible with those calculated by\n** sessionPreupdateHash().\n**\n** The bPkOnly argument is non-zero if the record at aRecord[] is from\n** a patchset DELETE. In this case the non-PK fields are omitted entirely.\n*/\nstatic unsigned int sessionChangeHash(\n  SessionTable *pTab,             /* Table handle */\n  int bPkOnly,                    /* Record consists of PK fields only */\n  u8 *aRecord,                    /* Change record */\n  int nBucket                     /* Assume this many buckets in hash table */\n){\n  unsigned int h = 0;             /* Value to return */\n  int i;                          /* Used to iterate through columns */\n  u8 *a = aRecord;                /* Used to iterate through change record */\n\n  for(i=0; i<pTab->nCol; i++){\n    int eType = *a;\n    int isPK = pTab->abPK[i];\n    if( bPkOnly && isPK==0 ) continue;\n\n    /* It is not possible for eType to be SQLITE_NULL here. The session \n    ** module does not record changes for rows with NULL values stored in\n    ** primary key columns. */\n    assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT \n         || eType==SQLITE_TEXT || eType==SQLITE_BLOB \n         || eType==SQLITE_NULL || eType==0 \n    );\n    assert( !isPK || (eType!=0 && eType!=SQLITE_NULL) );\n\n    if( isPK ){\n      a++;\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        h = sessionHashAppendI64(h, sessionGetI64(a));\n        a += 8;\n      }else{\n        int n; \n        a += sessionVarintGet(a, &n);\n        h = sessionHashAppendBlob(h, n, a);\n        a += n;\n      }\n    }else{\n      a += sessionSerialLen(a);\n    }\n  }\n  return (h % nBucket);\n}\n\n/*\n** Arguments aLeft and aRight are pointers to change records for table pTab.\n** This function returns true if the two records apply to the same row (i.e.\n** have the same values stored in the primary key columns), or false \n** otherwise.\n*/\nstatic int sessionChangeEqual(\n  SessionTable *pTab,             /* Table used for PK definition */\n  int bLeftPkOnly,                /* True if aLeft[] contains PK fields only */\n  u8 *aLeft,                      /* Change record */\n  int bRightPkOnly,               /* True if aRight[] contains PK fields only */\n  u8 *aRight                      /* Change record */\n){\n  u8 *a1 = aLeft;                 /* Cursor to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor to iterate through aRight */\n  int iCol;                       /* Used to iterate through table columns */\n\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( pTab->abPK[iCol] ){\n      int n1 = sessionSerialLen(a1);\n      int n2 = sessionSerialLen(a2);\n\n      if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){\n        return 0;\n      }\n      a1 += n1;\n      a2 += n2;\n    }else{\n      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);\n      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);\n    }\n  }\n\n  return 1;\n}\n\n/*\n** Arguments aLeft and aRight both point to buffers containing change\n** records with nCol columns. This function \"merges\" the two records into\n** a single records which is written to the buffer at *paOut. *paOut is\n** then set to point to one byte after the last byte written before \n** returning.\n**\n** The merging of records is done as follows: For each column, if the \n** aRight record contains a value for the column, copy the value from\n** their. Otherwise, if aLeft contains a value, copy it. If neither\n** record contains a value for a given column, then neither does the\n** output record.\n*/\nstatic void sessionMergeRecord(\n  u8 **paOut, \n  int nCol,\n  u8 *aLeft,\n  u8 *aRight\n){\n  u8 *a1 = aLeft;                 /* Cursor used to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor used to iterate through aRight */\n  u8 *aOut = *paOut;              /* Output cursor */\n  int iCol;                       /* Used to iterate from 0 to nCol */\n\n  for(iCol=0; iCol<nCol; iCol++){\n    int n1 = sessionSerialLen(a1);\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      memcpy(aOut, a2, n2);\n      aOut += n2;\n    }else{\n      memcpy(aOut, a1, n1);\n      aOut += n1;\n    }\n    a1 += n1;\n    a2 += n2;\n  }\n\n  *paOut = aOut;\n}\n\n/*\n** This is a helper function used by sessionMergeUpdate().\n**\n** When this function is called, both *paOne and *paTwo point to a value \n** within a change record. Before it returns, both have been advanced so \n** as to point to the next value in the record.\n**\n** If, when this function is called, *paTwo points to a valid value (i.e.\n** *paTwo[0] is not 0x00 - the \"no value\" placeholder), a copy of the *paTwo\n** pointer is returned and *pnVal is set to the number of bytes in the \n** serialized value. Otherwise, a copy of *paOne is returned and *pnVal\n** set to the number of bytes in the value at *paOne. If *paOne points\n** to the \"no value\" placeholder, *pnVal is set to 1. In other words:\n**\n**   if( *paTwo is valid ) return *paTwo;\n**   return *paOne;\n**\n*/\nstatic u8 *sessionMergeValue(\n  u8 **paOne,                     /* IN/OUT: Left-hand buffer pointer */\n  u8 **paTwo,                     /* IN/OUT: Right-hand buffer pointer */\n  int *pnVal                      /* OUT: Bytes in returned value */\n){\n  u8 *a1 = *paOne;\n  u8 *a2 = *paTwo;\n  u8 *pRet = 0;\n  int n1;\n\n  assert( a1 );\n  if( a2 ){\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      *pnVal = n2;\n      pRet = a2;\n    }\n    *paTwo = &a2[n2];\n  }\n\n  n1 = sessionSerialLen(a1);\n  if( pRet==0 ){\n    *pnVal = n1;\n    pRet = a1;\n  }\n  *paOne = &a1[n1];\n\n  return pRet;\n}\n\n/*\n** This function is used by changeset_concat() to merge two UPDATE changes\n** on the same row.\n*/\nstatic int sessionMergeUpdate(\n  u8 **paOut,                     /* IN/OUT: Pointer to output buffer */\n  SessionTable *pTab,             /* Table change pertains to */\n  int bPatchset,                  /* True if records are patchset records */\n  u8 *aOldRecord1,                /* old.* record for first change */\n  u8 *aOldRecord2,                /* old.* record for second change */\n  u8 *aNewRecord1,                /* new.* record for first change */\n  u8 *aNewRecord2                 /* new.* record for second change */\n){\n  u8 *aOld1 = aOldRecord1;\n  u8 *aOld2 = aOldRecord2;\n  u8 *aNew1 = aNewRecord1;\n  u8 *aNew2 = aNewRecord2;\n\n  u8 *aOut = *paOut;\n  int i;\n\n  if( bPatchset==0 ){\n    int bRequired = 0;\n\n    assert( aOldRecord1 && aNewRecord1 );\n\n    /* Write the old.* vector first. */\n    for(i=0; i<pTab->nCol; i++){\n      int nOld;\n      u8 *aOld;\n      int nNew;\n      u8 *aNew;\n\n      aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n      aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n      if( pTab->abPK[i] || nOld!=nNew || memcmp(aOld, aNew, nNew) ){\n        if( pTab->abPK[i]==0 ) bRequired = 1;\n        memcpy(aOut, aOld, nOld);\n        aOut += nOld;\n      }else{\n        *(aOut++) = '\\0';\n      }\n    }\n\n    if( !bRequired ) return 0;\n  }\n\n  /* Write the new.* vector */\n  aOld1 = aOldRecord1;\n  aOld2 = aOldRecord2;\n  aNew1 = aNewRecord1;\n  aNew2 = aNewRecord2;\n  for(i=0; i<pTab->nCol; i++){\n    int nOld;\n    u8 *aOld;\n    int nNew;\n    u8 *aNew;\n\n    aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n    aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n    if( bPatchset==0 \n     && (pTab->abPK[i] || (nOld==nNew && 0==memcmp(aOld, aNew, nNew))) \n    ){\n      *(aOut++) = '\\0';\n    }else{\n      memcpy(aOut, aNew, nNew);\n      aOut += nNew;\n    }\n  }\n\n  *paOut = aOut;\n  return 1;\n}\n\n/*\n** This function is only called from within a pre-update-hook callback.\n** It determines if the current pre-update-hook change affects the same row\n** as the change stored in argument pChange. If so, it returns true. Otherwise\n** if the pre-update-hook does not affect the same row as pChange, it returns\n** false.\n*/\nstatic int sessionPreupdateEqual(\n  sqlite3_session *pSession,      /* Session object that owns SessionTable */\n  SessionTable *pTab,             /* Table associated with change */\n  SessionChange *pChange,         /* Change to compare to */\n  int op                          /* Current pre-update operation */\n){\n  int iCol;                       /* Used to iterate through columns */\n  u8 *a = pChange->aRecord;       /* Cursor used to scan change record */\n\n  assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( !pTab->abPK[iCol] ){\n      a += sessionSerialLen(a);\n    }else{\n      sqlite3_value *pVal;        /* Value returned by preupdate_new/old */\n      int rc;                     /* Error code from preupdate_new/old */\n      int eType = *a++;           /* Type of value from change record */\n\n      /* The following calls to preupdate_new() and preupdate_old() can not\n      ** fail. This is because they cache their return values, and by the\n      ** time control flows to here they have already been called once from\n      ** within sessionPreupdateHash(). The first two asserts below verify\n      ** this (that the method has already been called). */\n      if( op==SQLITE_INSERT ){\n        /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */\n        rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);\n      }else{\n        /* assert( db->pPreUpdate->pUnpacked ); */\n        rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);\n      }\n      assert( rc==SQLITE_OK );\n      if( sqlite3_value_type(pVal)!=eType ) return 0;\n\n      /* A SessionChange object never has a NULL value in a PK column */\n      assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT\n           || eType==SQLITE_BLOB    || eType==SQLITE_TEXT\n      );\n\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal = sessionGetI64(a);\n        a += 8;\n        if( eType==SQLITE_INTEGER ){\n          if( sqlite3_value_int64(pVal)!=iVal ) return 0;\n        }else{\n          double rVal;\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&rVal, &iVal, 8);\n          if( sqlite3_value_double(pVal)!=rVal ) return 0;\n        }\n      }else{\n        int n;\n        const u8 *z;\n        a += sessionVarintGet(a, &n);\n        if( sqlite3_value_bytes(pVal)!=n ) return 0;\n        if( eType==SQLITE_TEXT ){\n          z = sqlite3_value_text(pVal);\n        }else{\n          z = sqlite3_value_blob(pVal);\n        }\n        if( memcmp(a, z, n) ) return 0;\n        a += n;\n        break;\n      }\n    }\n  }\n\n  return 1;\n}\n\n/*\n** If required, grow the hash table used to store changes on table pTab \n** (part of the session pSession). If a fatal OOM error occurs, set the\n** session object to failed and return SQLITE_ERROR. Otherwise, return\n** SQLITE_OK.\n**\n** It is possible that a non-fatal OOM error occurs in this function. In\n** that case the hash-table does not grow, but SQLITE_OK is returned anyway.\n** Growing the hash table in this case is a performance optimization only,\n** it is not required for correct operation.\n*/\nstatic int sessionGrowHash(int bPatchset, SessionTable *pTab){\n  if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){\n    int i;\n    SessionChange **apNew;\n    int nNew = (pTab->nChange ? pTab->nChange : 128) * 2;\n\n    apNew = (SessionChange **)sqlite3_malloc(sizeof(SessionChange *) * nNew);\n    if( apNew==0 ){\n      if( pTab->nChange==0 ){\n        return SQLITE_ERROR;\n      }\n      return SQLITE_OK;\n    }\n    memset(apNew, 0, sizeof(SessionChange *) * nNew);\n\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNext;\n      for(p=pTab->apChange[i]; p; p=pNext){\n        int bPkOnly = (p->op==SQLITE_DELETE && bPatchset);\n        int iHash = sessionChangeHash(pTab, bPkOnly, p->aRecord, nNew);\n        pNext = p->pNext;\n        p->pNext = apNew[iHash];\n        apNew[iHash] = p;\n      }\n    }\n\n    sqlite3_free(pTab->apChange);\n    pTab->nChange = nNew;\n    pTab->apChange = apNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This function queries the database for the names of the columns of table\n** zThis, in schema zDb. It is expected that the table has nCol columns. If\n** not, SQLITE_SCHEMA is returned and none of the output variables are\n** populated.\n**\n** Otherwise, if they are not NULL, variable *pnCol is set to the number\n** of columns in the database table and variable *pzTab is set to point to a\n** nul-terminated copy of the table name. *pazCol (if not NULL) is set to\n** point to an array of pointers to column names. And *pabPK (again, if not\n** NULL) is set to point to an array of booleans - true if the corresponding\n** column is part of the primary key.\n**\n** For example, if the table is declared as:\n**\n**     CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z));\n**\n** Then the four output variables are populated as follows:\n**\n**     *pnCol  = 4\n**     *pzTab  = \"tbl1\"\n**     *pazCol = {\"w\", \"x\", \"y\", \"z\"}\n**     *pabPK  = {1, 0, 0, 1}\n**\n** All returned buffers are part of the same single allocation, which must\n** be freed using sqlite3_free() by the caller. If pazCol was not NULL, then\n** pointer *pazCol should be freed to release all memory. Otherwise, pointer\n** *pabPK. It is illegal for both pazCol and pabPK to be NULL.\n*/\nstatic int sessionTableInfo(\n  sqlite3 *db,                    /* Database connection */\n  const char *zDb,                /* Name of attached database (e.g. \"main\") */\n  const char *zThis,              /* Table name */\n  int *pnCol,                     /* OUT: number of columns */\n  const char **pzTab,             /* OUT: Copy of zThis */\n  const char ***pazCol,           /* OUT: Array of column names for table */\n  u8 **pabPK                      /* OUT: Array of booleans - true for PK col */\n){\n  char *zPragma;\n  sqlite3_stmt *pStmt;\n  int rc;\n  int nByte;\n  int nDbCol = 0;\n  int nThis;\n  int i;\n  u8 *pAlloc = 0;\n  char **azCol = 0;\n  u8 *abPK = 0;\n\n  assert( pazCol && pabPK );\n\n  nThis = sqlite3Strlen30(zThis);\n  zPragma = sqlite3_mprintf(\"PRAGMA '%q'.table_info('%q')\", zDb, zThis);\n  if( !zPragma ) return SQLITE_NOMEM;\n\n  rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);\n  sqlite3_free(zPragma);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = nThis + 1;\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    nByte += sqlite3_column_bytes(pStmt, 1);\n    nDbCol++;\n  }\n  rc = sqlite3_reset(pStmt);\n\n  if( rc==SQLITE_OK ){\n    nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1);\n    pAlloc = sqlite3_malloc(nByte);\n    if( pAlloc==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    azCol = (char **)pAlloc;\n    pAlloc = (u8 *)&azCol[nDbCol];\n    abPK = (u8 *)pAlloc;\n    pAlloc = &abPK[nDbCol];\n    if( pzTab ){\n      memcpy(pAlloc, zThis, nThis+1);\n      *pzTab = (char *)pAlloc;\n      pAlloc += nThis+1;\n    }\n  \n    i = 0;\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      int nName = sqlite3_column_bytes(pStmt, 1);\n      const unsigned char *zName = sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;\n      memcpy(pAlloc, zName, nName+1);\n      azCol[i] = (char *)pAlloc;\n      pAlloc += nName+1;\n      abPK[i] = sqlite3_column_int(pStmt, 5);\n      i++;\n    }\n    rc = sqlite3_reset(pStmt);\n  \n  }\n\n  /* If successful, populate the output variables. Otherwise, zero them and\n  ** free any allocation made. An error code will be returned in this case.\n  */\n  if( rc==SQLITE_OK ){\n    *pazCol = (const char **)azCol;\n    *pabPK = abPK;\n    *pnCol = nDbCol;\n  }else{\n    *pazCol = 0;\n    *pabPK = 0;\n    *pnCol = 0;\n    if( pzTab ) *pzTab = 0;\n    sqlite3_free(azCol);\n  }\n  sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** This function is only called from within a pre-update handler for a\n** write to table pTab, part of session pSession. If this is the first\n** write to this table, initalize the SessionTable.nCol, azCol[] and\n** abPK[] arrays accordingly.\n**\n** If an error occurs, an error code is stored in sqlite3_session.rc and\n** non-zero returned. Or, if no error occurs but the table has no primary\n** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to\n** indicate that updates on this table should be ignored. SessionTable.abPK \n** is set to NULL in this case.\n*/\nstatic int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){\n  if( pTab->nCol==0 ){\n    u8 *abPK;\n    assert( pTab->azCol==0 || pTab->abPK==0 );\n    pSession->rc = sessionTableInfo(pSession->db, pSession->zDb, \n        pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK\n    );\n    if( pSession->rc==SQLITE_OK ){\n      int i;\n      for(i=0; i<pTab->nCol; i++){\n        if( abPK[i] ){\n          pTab->abPK = abPK;\n          break;\n        }\n      }\n    }\n  }\n  return (pSession->rc || pTab->abPK==0);\n}\n\n/*\n** This function is only called from with a pre-update-hook reporting a \n** change on table pTab (attached to session pSession). The type of change\n** (UPDATE, INSERT, DELETE) is specified by the first argument.\n**\n** Unless one is already present or an error occurs, an entry is added\n** to the changed-rows hash table associated with table pTab.\n*/\nstatic void sessionPreupdateOneChange(\n  int op,                         /* One of SQLITE_UPDATE, INSERT, DELETE */\n  sqlite3_session *pSession,      /* Session object pTab is attached to */\n  SessionTable *pTab              /* Table that change applies to */\n){\n  int iHash; \n  int bNull = 0; \n  int rc = SQLITE_OK;\n\n  if( pSession->rc ) return;\n\n  /* Load table details if required */\n  if( sessionInitTable(pSession, pTab) ) return;\n\n  /* Check the number of columns in this xPreUpdate call matches the \n  ** number of columns in the table.  */\n  if( pTab->nCol!=pSession->hook.xCount(pSession->hook.pCtx) ){\n    pSession->rc = SQLITE_SCHEMA;\n    return;\n  }\n\n  /* Grow the hash table if required */\n  if( sessionGrowHash(0, pTab) ){\n    pSession->rc = SQLITE_NOMEM;\n    return;\n  }\n\n  /* Calculate the hash-key for this change. If the primary key of the row\n  ** includes a NULL value, exit early. Such changes are ignored by the\n  ** session module. */\n  rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull);\n  if( rc!=SQLITE_OK ) goto error_out;\n\n  if( bNull==0 ){\n    /* Search the hash table for an existing record for this row. */\n    SessionChange *pC;\n    for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){\n      if( sessionPreupdateEqual(pSession, pTab, pC, op) ) break;\n    }\n\n    if( pC==0 ){\n      /* Create a new change object containing all the old values (if\n      ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK\n      ** values (if this is an INSERT). */\n      SessionChange *pChange; /* New change object */\n      int nByte;              /* Number of bytes to allocate */\n      int i;                  /* Used to iterate through columns */\n  \n      assert( rc==SQLITE_OK );\n      pTab->nEntry++;\n  \n      /* Figure out how large an allocation is required */\n      nByte = sizeof(SessionChange);\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          TESTONLY(int trc = ) pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }else if( pTab->abPK[i] ){\n          TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }\n\n        /* This may fail if SQLite value p contains a utf-16 string that must\n        ** be converted to utf-8 and an OOM error occurs while doing so. */\n        rc = sessionSerializeValue(0, p, &nByte);\n        if( rc!=SQLITE_OK ) goto error_out;\n      }\n  \n      /* Allocate the change object */\n      pChange = (SessionChange *)sqlite3_malloc(nByte);\n      if( !pChange ){\n        rc = SQLITE_NOMEM;\n        goto error_out;\n      }else{\n        memset(pChange, 0, sizeof(SessionChange));\n        pChange->aRecord = (u8 *)&pChange[1];\n      }\n  \n      /* Populate the change object. None of the preupdate_old(),\n      ** preupdate_new() or SerializeValue() calls below may fail as all\n      ** required values and encodings have already been cached in memory.\n      ** It is not possible for an OOM to occur in this block. */\n      nByte = 0;\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n        }else if( pTab->abPK[i] ){\n          pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n        }\n        sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte);\n      }\n\n      /* Add the change to the hash-table */\n      if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){\n        pChange->bIndirect = 1;\n      }\n      pChange->nRecord = nByte;\n      pChange->op = op;\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n\n    }else if( pC->bIndirect ){\n      /* If the existing change is considered \"indirect\", but this current\n      ** change is \"direct\", mark the change object as direct. */\n      if( pSession->hook.xDepth(pSession->hook.pCtx)==0 \n       && pSession->bIndirect==0 \n      ){\n        pC->bIndirect = 0;\n      }\n    }\n  }\n\n  /* If an error has occurred, mark the session object as failed. */\n error_out:\n  if( rc!=SQLITE_OK ){\n    pSession->rc = rc;\n  }\n}\n\nstatic int sessionFindTable(\n  sqlite3_session *pSession, \n  const char *zName,\n  SessionTable **ppTab\n){\n  int rc = SQLITE_OK;\n  int nName = sqlite3Strlen30(zName);\n  SessionTable *pRet;\n\n  /* Search for an existing table */\n  for(pRet=pSession->pTable; pRet; pRet=pRet->pNext){\n    if( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) ) break;\n  }\n\n  if( pRet==0 && pSession->bAutoAttach ){\n    /* If there is a table-filter configured, invoke it. If it returns 0,\n    ** do not automatically add the new table. */\n    if( pSession->xTableFilter==0\n     || pSession->xTableFilter(pSession->pFilterCtx, zName) \n    ){\n      rc = sqlite3session_attach(pSession, zName);\n      if( rc==SQLITE_OK ){\n        for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);\n        assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );\n      }\n    }\n  }\n\n  assert( rc==SQLITE_OK || pRet==0 );\n  *ppTab = pRet;\n  return rc;\n}\n\n/*\n** The 'pre-update' hook registered by this module with SQLite databases.\n*/\nstatic void xPreUpdate(\n  void *pCtx,                     /* Copy of third arg to preupdate_hook() */\n  sqlite3 *db,                    /* Database handle */\n  int op,                         /* SQLITE_UPDATE, DELETE or INSERT */\n  char const *zDb,                /* Database name */\n  char const *zName,              /* Table name */\n  sqlite3_int64 iKey1,            /* Rowid of row about to be deleted/updated */\n  sqlite3_int64 iKey2             /* New rowid value (for a rowid UPDATE) */\n){\n  sqlite3_session *pSession;\n  int nDb = sqlite3Strlen30(zDb);\n\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(pSession=(sqlite3_session *)pCtx; pSession; pSession=pSession->pNext){\n    SessionTable *pTab;\n\n    /* If this session is attached to a different database (\"main\", \"temp\" \n    ** etc.), or if it is not currently enabled, there is nothing to do. Skip \n    ** to the next session object attached to this database. */\n    if( pSession->bEnable==0 ) continue;\n    if( pSession->rc ) continue;\n    if( sqlite3_strnicmp(zDb, pSession->zDb, nDb+1) ) continue;\n\n    pSession->rc = sessionFindTable(pSession, zName, &pTab);\n    if( pTab ){\n      assert( pSession->rc==SQLITE_OK );\n      sessionPreupdateOneChange(op, pSession, pTab);\n      if( op==SQLITE_UPDATE ){\n        sessionPreupdateOneChange(SQLITE_INSERT, pSession, pTab);\n      }\n    }\n  }\n}\n\n/*\n** The pre-update hook implementations.\n*/\nstatic int sessionPreupdateOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_old((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_new((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateCount(void *pCtx){\n  return sqlite3_preupdate_count((sqlite3*)pCtx);\n}\nstatic int sessionPreupdateDepth(void *pCtx){\n  return sqlite3_preupdate_depth((sqlite3*)pCtx);\n}\n\n/*\n** Install the pre-update hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionPreupdateHooks(\n  sqlite3_session *pSession\n){\n  pSession->hook.pCtx = (void*)pSession->db;\n  pSession->hook.xOld = sessionPreupdateOld;\n  pSession->hook.xNew = sessionPreupdateNew;\n  pSession->hook.xCount = sessionPreupdateCount;\n  pSession->hook.xDepth = sessionPreupdateDepth;\n}\n\ntypedef struct SessionDiffCtx SessionDiffCtx;\nstruct SessionDiffCtx {\n  sqlite3_stmt *pStmt;\n  int nOldOff;\n};\n\n/*\n** The diff hook implementations.\n*/\nstatic int sessionDiffOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal+p->nOldOff);\n  return SQLITE_OK;\n}\nstatic int sessionDiffNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal);\n   return SQLITE_OK;\n}\nstatic int sessionDiffCount(void *pCtx){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  return p->nOldOff ? p->nOldOff : sqlite3_column_count(p->pStmt);\n}\nstatic int sessionDiffDepth(void *pCtx){\n  return 0;\n}\n\n/*\n** Install the diff hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionDiffHooks(\n  sqlite3_session *pSession,\n  SessionDiffCtx *pDiffCtx\n){\n  pSession->hook.pCtx = (void*)pDiffCtx;\n  pSession->hook.xOld = sessionDiffOld;\n  pSession->hook.xNew = sessionDiffNew;\n  pSession->hook.xCount = sessionDiffCount;\n  pSession->hook.xDepth = sessionDiffDepth;\n}\n\nstatic char *sessionExprComparePK(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i] ){\n      zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"=\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" AND \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *sessionExprCompareOther(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n  int bHave = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i]==0 ){\n      bHave = 1;\n      zRet = sqlite3_mprintf(\n          \"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\" IS NOT \\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" OR \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  if( bHave==0 ){\n    assert( zRet==0 );\n    zRet = sqlite3_mprintf(\"0\");\n  }\n\n  return zRet;\n}\n\nstatic char *sessionSelectFindNew(\n  int nCol,\n  const char *zDb1,      /* Pick rows in this db only */\n  const char *zDb2,      /* But not in this one */\n  const char *zTbl,      /* Table name */\n  const char *zExpr\n){\n  char *zRet = sqlite3_mprintf(\n      \"SELECT * FROM \\\"%w\\\".\\\"%w\\\" WHERE NOT EXISTS (\"\n      \"  SELECT 1 FROM \\\"%w\\\".\\\"%w\\\" WHERE %s\"\n      \")\",\n      zDb1, zTbl, zDb2, zTbl, zExpr\n  );\n  return zRet;\n}\n\nstatic int sessionDiffFindNew(\n  int op,\n  sqlite3_session *pSession,\n  SessionTable *pTab,\n  const char *zDb1,\n  const char *zDb2,\n  char *zExpr\n){\n  int rc = SQLITE_OK;\n  char *zStmt = sessionSelectFindNew(pTab->nCol, zDb1, zDb2, pTab->zName,zExpr);\n\n  if( zStmt==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pStmt;\n    rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n      pDiffCtx->pStmt = pStmt;\n      pDiffCtx->nOldOff = 0;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        sessionPreupdateOneChange(op, pSession, pTab);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n    sqlite3_free(zStmt);\n  }\n\n  return rc;\n}\n\nstatic int sessionDiffFindModified(\n  sqlite3_session *pSession, \n  SessionTable *pTab, \n  const char *zFrom, \n  const char *zExpr\n){\n  int rc = SQLITE_OK;\n\n  char *zExpr2 = sessionExprCompareOther(pTab->nCol,\n      pSession->zDb, zFrom, pTab->zName, pTab->azCol, pTab->abPK\n  );\n  if( zExpr2==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    char *zStmt = sqlite3_mprintf(\n        \"SELECT * FROM \\\"%w\\\".\\\"%w\\\", \\\"%w\\\".\\\"%w\\\" WHERE %s AND (%z)\",\n        pSession->zDb, pTab->zName, zFrom, pTab->zName, zExpr, zExpr2\n    );\n    if( zStmt==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_stmt *pStmt;\n      rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n\n      if( rc==SQLITE_OK ){\n        SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n        pDiffCtx->pStmt = pStmt;\n        pDiffCtx->nOldOff = pTab->nCol;\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){\n          sessionPreupdateOneChange(SQLITE_UPDATE, pSession, pTab);\n        }\n        rc = sqlite3_finalize(pStmt);\n      }\n      sqlite3_free(zStmt);\n    }\n  }\n\n  return rc;\n}\n\nint sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFrom,\n  const char *zTbl,\n  char **pzErrMsg\n){\n  const char *zDb = pSession->zDb;\n  int rc = pSession->rc;\n  SessionDiffCtx d;\n\n  memset(&d, 0, sizeof(d));\n  sessionDiffHooks(pSession, &d);\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( pzErrMsg ) *pzErrMsg = 0;\n  if( rc==SQLITE_OK ){\n    char *zExpr = 0;\n    sqlite3 *db = pSession->db;\n    SessionTable *pTo;            /* Table zTbl */\n\n    /* Locate and if necessary initialize the target table object */\n    rc = sessionFindTable(pSession, zTbl, &pTo);\n    if( pTo==0 ) goto diff_out;\n    if( sessionInitTable(pSession, pTo) ){\n      rc = pSession->rc;\n      goto diff_out;\n    }\n\n    /* Check the table schemas match */\n    if( rc==SQLITE_OK ){\n      int bHasPk = 0;\n      int bMismatch = 0;\n      int nCol;                   /* Columns in zFrom.zTbl */\n      u8 *abPK;\n      const char **azCol = 0;\n      rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK);\n      if( rc==SQLITE_OK ){\n        if( pTo->nCol!=nCol ){\n          bMismatch = 1;\n        }else{\n          int i;\n          for(i=0; i<nCol; i++){\n            if( pTo->abPK[i]!=abPK[i] ) bMismatch = 1;\n            if( sqlite3_stricmp(azCol[i], pTo->azCol[i]) ) bMismatch = 1;\n            if( abPK[i] ) bHasPk = 1;\n          }\n        }\n\n      }\n      sqlite3_free((char*)azCol);\n      if( bMismatch ){\n        *pzErrMsg = sqlite3_mprintf(\"table schemas do not match\");\n        rc = SQLITE_SCHEMA;\n      }\n      if( bHasPk==0 ){\n        /* Ignore tables with no primary keys */\n        goto diff_out;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      zExpr = sessionExprComparePK(pTo->nCol, \n          zDb, zFrom, pTo->zName, pTo->azCol, pTo->abPK\n      );\n    }\n\n    /* Find new rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_INSERT, pSession, pTo, zDb, zFrom, zExpr);\n    }\n\n    /* Find old rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_DELETE, pSession, pTo, zFrom, zDb, zExpr);\n    }\n\n    /* Find modified rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindModified(pSession, pTo, zFrom, zExpr);\n    }\n\n    sqlite3_free(zExpr);\n  }\n\n diff_out:\n  sessionPreupdateHooks(pSession);\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Create a session object. This session object will record changes to\n** database zDb attached to connection db.\n*/\nint sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n){\n  sqlite3_session *pNew;          /* Newly allocated session object */\n  sqlite3_session *pOld;          /* Session object already attached to db */\n  int nDb = sqlite3Strlen30(zDb); /* Length of zDb in bytes */\n\n  /* Zero the output value in case an error occurs. */\n  *ppSession = 0;\n\n  /* Allocate and populate the new session object. */\n  pNew = (sqlite3_session *)sqlite3_malloc(sizeof(sqlite3_session) + nDb + 1);\n  if( !pNew ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(sqlite3_session));\n  pNew->db = db;\n  pNew->zDb = (char *)&pNew[1];\n  pNew->bEnable = 1;\n  memcpy(pNew->zDb, zDb, nDb+1);\n  sessionPreupdateHooks(pNew);\n\n  /* Add the new session object to the linked list of session objects \n  ** attached to database handle $db. Do this under the cover of the db\n  ** handle mutex.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pOld = (sqlite3_session*)sqlite3_preupdate_hook(db, xPreUpdate, (void*)pNew);\n  pNew->pNext = pOld;\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n\n  *ppSession = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of table objects passed as the first argument. The contents\n** of the changed-rows hash tables are also deleted.\n*/\nstatic void sessionDeleteTable(SessionTable *pList){\n  SessionTable *pNext;\n  SessionTable *pTab;\n\n  for(pTab=pList; pTab; pTab=pNext){\n    int i;\n    pNext = pTab->pNext;\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNextChange;\n      for(p=pTab->apChange[i]; p; p=pNextChange){\n        pNextChange = p->pNext;\n        sqlite3_free(p);\n      }\n    }\n    sqlite3_free((char*)pTab->azCol);  /* cast works around VC++ bug */\n    sqlite3_free(pTab->apChange);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** Delete a session object previously allocated using sqlite3session_create().\n*/\nvoid sqlite3session_delete(sqlite3_session *pSession){\n  sqlite3 *db = pSession->db;\n  sqlite3_session *pHead;\n  sqlite3_session **pp;\n\n  /* Unlink the session from the linked list of sessions attached to the\n  ** database handle. Hold the db mutex while doing so.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pHead = (sqlite3_session*)sqlite3_preupdate_hook(db, 0, 0);\n  for(pp=&pHead; ALWAYS((*pp)!=0); pp=&((*pp)->pNext)){\n    if( (*pp)==pSession ){\n      *pp = (*pp)->pNext;\n      if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void*)pHead);\n      break;\n    }\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n\n  /* Delete all attached table objects. And the contents of their \n  ** associated hash-tables. */\n  sessionDeleteTable(pSession->pTable);\n\n  /* Free the session object itself. */\n  sqlite3_free(pSession);\n}\n\n/*\n** Set a table filter on a Session Object.\n*/\nvoid sqlite3session_table_filter(\n  sqlite3_session *pSession, \n  int(*xFilter)(void*, const char*),\n  void *pCtx                      /* First argument passed to xFilter */\n){\n  pSession->bAutoAttach = 1;\n  pSession->pFilterCtx = pCtx;\n  pSession->xTableFilter = xFilter;\n}\n\n/*\n** Attach a table to a session. All subsequent changes made to the table\n** while the session object is enabled will be recorded.\n**\n** Only tables that have a PRIMARY KEY defined may be attached. It does\n** not matter if the PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias)\n** or not.\n*/\nint sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zName               /* Table name */\n){\n  int rc = SQLITE_OK;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n\n  if( !zName ){\n    pSession->bAutoAttach = 1;\n  }else{\n    SessionTable *pTab;           /* New table object (if required) */\n    int nName;                    /* Number of bytes in string zName */\n\n    /* First search for an existing entry. If one is found, this call is\n    ** a no-op. Return early. */\n    nName = sqlite3Strlen30(zName);\n    for(pTab=pSession->pTable; pTab; pTab=pTab->pNext){\n      if( 0==sqlite3_strnicmp(pTab->zName, zName, nName+1) ) break;\n    }\n\n    if( !pTab ){\n      /* Allocate new SessionTable object. */\n      pTab = (SessionTable *)sqlite3_malloc(sizeof(SessionTable) + nName + 1);\n      if( !pTab ){\n        rc = SQLITE_NOMEM;\n      }else{\n        /* Populate the new SessionTable object and link it into the list.\n        ** The new object must be linked onto the end of the list, not \n        ** simply added to the start of it in order to ensure that tables\n        ** appear in the correct order when a changeset or patchset is\n        ** eventually generated. */\n        SessionTable **ppTab;\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->zName = (char *)&pTab[1];\n        memcpy(pTab->zName, zName, nName+1);\n        for(ppTab=&pSession->pTable; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Ensure that there is room in the buffer to append nByte bytes of data.\n** If not, use sqlite3_realloc() to grow the buffer so that there is.\n**\n** If successful, return zero. Otherwise, if an OOM condition is encountered,\n** set *pRc to SQLITE_NOMEM and return non-zero.\n*/\nstatic int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){\n  if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){\n    u8 *aNew;\n    int nNew = p->nAlloc ? p->nAlloc : 128;\n    do {\n      nNew = nNew*2;\n    }while( nNew<(p->nBuf+nByte) );\n\n    aNew = (u8 *)sqlite3_realloc(p->aBuf, nNew);\n    if( 0==aNew ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      p->aBuf = aNew;\n      p->nAlloc = nNew;\n    }\n  }\n  return (*pRc!=SQLITE_OK);\n}\n\n/*\n** Append the value passed as the second argument to the buffer passed\n** as the first.\n**\n** This function is a no-op if *pRc is non-zero when it is called.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code\n** before returning.\n*/\nstatic void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    int nByte = 0;\n    rc = sessionSerializeValue(0, pVal, &nByte);\n    sessionBufferGrow(p, nByte, &rc);\n    if( rc==SQLITE_OK ){\n      rc = sessionSerializeValue(&p->aBuf[p->nBuf], pVal, 0);\n      p->nBuf += nByte;\n    }else{\n      *pRc = rc;\n    }\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single byte to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendByte(SessionBuffer *p, u8 v, int *pRc){\n  if( 0==sessionBufferGrow(p, 1, pRc) ){\n    p->aBuf[p->nBuf++] = v;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single varint to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendVarint(SessionBuffer *p, int v, int *pRc){\n  if( 0==sessionBufferGrow(p, 9, pRc) ){\n    p->nBuf += sessionVarintPut(&p->aBuf[p->nBuf], v);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a blob of data to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendBlob(\n  SessionBuffer *p, \n  const u8 *aBlob, \n  int nBlob, \n  int *pRc\n){\n  if( nBlob>0 && 0==sessionBufferGrow(p, nBlob, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], aBlob, nBlob);\n    p->nBuf += nBlob;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a string to the buffer. All bytes in the string\n** up to (but not including) the nul-terminator are written to the buffer.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendStr(\n  SessionBuffer *p, \n  const char *zStr, \n  int *pRc\n){\n  int nStr = sqlite3Strlen30(zStr);\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], zStr, nStr);\n    p->nBuf += nStr;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string representation of integer iVal\n** to the buffer. No nul-terminator is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendInteger(\n  SessionBuffer *p,               /* Buffer to append to */\n  int iVal,                       /* Value to write the string rep. of */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  char aBuf[24];\n  sqlite3_snprintf(sizeof(aBuf)-1, aBuf, \"%d\", iVal);\n  sessionAppendStr(p, aBuf, pRc);\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string zStr enclosed in quotes (\") and\n** with any embedded quote characters escaped to the buffer. No \n** nul-terminator byte is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendIdent(\n  SessionBuffer *p,               /* Buffer to a append to */\n  const char *zStr,               /* String to quote, escape and append */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int nStr = sqlite3Strlen30(zStr)*2 + 2 + 1;\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    char *zOut = (char *)&p->aBuf[p->nBuf];\n    const char *zIn = zStr;\n    *zOut++ = '\"';\n    while( *zIn ){\n      if( *zIn=='\"' ) *zOut++ = '\"';\n      *zOut++ = *(zIn++);\n    }\n    *zOut++ = '\"';\n    p->nBuf = (int)((u8 *)zOut - p->aBuf);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is\n** called. Otherwse, it appends the serialized version of the value stored\n** in column iCol of the row that SQL statement pStmt currently points\n** to to the buffer.\n*/\nstatic void sessionAppendCol(\n  SessionBuffer *p,               /* Buffer to append to */\n  sqlite3_stmt *pStmt,            /* Handle pointing to row containing value */\n  int iCol,                       /* Column to read value from */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int eType = sqlite3_column_type(pStmt, iCol);\n    sessionAppendByte(p, (u8)eType, pRc);\n    if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      sqlite3_int64 i;\n      u8 aBuf[8];\n      if( eType==SQLITE_INTEGER ){\n        i = sqlite3_column_int64(pStmt, iCol);\n      }else{\n        double r = sqlite3_column_double(pStmt, iCol);\n        memcpy(&i, &r, 8);\n      }\n      sessionPutI64(aBuf, i);\n      sessionAppendBlob(p, aBuf, 8, pRc);\n    }\n    if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){\n      u8 *z;\n      int nByte;\n      if( eType==SQLITE_BLOB ){\n        z = (u8 *)sqlite3_column_blob(pStmt, iCol);\n      }else{\n        z = (u8 *)sqlite3_column_text(pStmt, iCol);\n      }\n      nByte = sqlite3_column_bytes(pStmt, iCol);\n      if( z || (eType==SQLITE_BLOB && nByte==0) ){\n        sessionAppendVarint(p, nByte, pRc);\n        sessionAppendBlob(p, z, nByte, pRc);\n      }else{\n        *pRc = SQLITE_NOMEM;\n      }\n    }\n  }\n}\n\n/*\n**\n** This function appends an update change to the buffer (see the comments \n** under \"CHANGESET FORMAT\" at the top of the file). An update change \n** consists of:\n**\n**   1 byte:  SQLITE_UPDATE (0x17)\n**   n bytes: old.* record (see RECORD FORMAT)\n**   m bytes: new.* record (see RECORD FORMAT)\n**\n** The SessionChange object passed as the third argument contains the\n** values that were stored in the row when the session began (the old.*\n** values). The statement handle passed as the second argument points\n** at the current version of the row (the new.* values).\n**\n** If all of the old.* values are equal to their corresponding new.* value\n** (i.e. nothing has changed), then no data at all is appended to the buffer.\n**\n** Otherwise, the old.* record contains all primary key values and the \n** original values of any fields that have been modified. The new.* record \n** contains the new values of only those fields that have been modified.\n*/ \nstatic int sessionAppendUpdate(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  sqlite3_stmt *pStmt,            /* Statement handle pointing at new row */\n  SessionChange *p,               /* Object containing old values */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf2 = {0,0,0}; /* Buffer to accumulate new.* record in */\n  int bNoop = 1;                /* Set to zero if any values are modified */\n  int nRewind = pBuf->nBuf;     /* Set to zero if any values are modified */\n  int i;                        /* Used to iterate through columns */\n  u8 *pCsr = p->aRecord;        /* Used to iterate through old.* values */\n\n  sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n  for(i=0; i<sqlite3_column_count(pStmt); i++){\n    int bChanged = 0;\n    int nAdvance;\n    int eType = *pCsr;\n    switch( eType ){\n      case SQLITE_NULL:\n        nAdvance = 1;\n        if( sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n          bChanged = 1;\n        }\n        break;\n\n      case SQLITE_FLOAT:\n      case SQLITE_INTEGER: {\n        nAdvance = 9;\n        if( eType==sqlite3_column_type(pStmt, i) ){\n          sqlite3_int64 iVal = sessionGetI64(&pCsr[1]);\n          if( eType==SQLITE_INTEGER ){\n            if( iVal==sqlite3_column_int64(pStmt, i) ) break;\n          }else{\n            double dVal;\n            memcpy(&dVal, &iVal, 8);\n            if( dVal==sqlite3_column_double(pStmt, i) ) break;\n          }\n        }\n        bChanged = 1;\n        break;\n      }\n\n      default: {\n        int n;\n        int nHdr = 1 + sessionVarintGet(&pCsr[1], &n);\n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        nAdvance = nHdr + n;\n        if( eType==sqlite3_column_type(pStmt, i) \n         && n==sqlite3_column_bytes(pStmt, i) \n         && (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n))\n        ){\n          break;\n        }\n        bChanged = 1;\n      }\n    }\n\n    /* If at least one field has been modified, this is not a no-op. */\n    if( bChanged ) bNoop = 0;\n\n    /* Add a field to the old.* record. This is omitted if this modules is\n    ** currently generating a patchset. */\n    if( bPatchset==0 ){\n      if( bChanged || abPK[i] ){\n        sessionAppendBlob(pBuf, pCsr, nAdvance, &rc);\n      }else{\n        sessionAppendByte(pBuf, 0, &rc);\n      }\n    }\n\n    /* Add a field to the new.* record. Or the only record if currently\n    ** generating a patchset.  */\n    if( bChanged || (bPatchset && abPK[i]) ){\n      sessionAppendCol(&buf2, pStmt, i, &rc);\n    }else{\n      sessionAppendByte(&buf2, 0, &rc);\n    }\n\n    pCsr += nAdvance;\n  }\n\n  if( bNoop ){\n    pBuf->nBuf = nRewind;\n  }else{\n    sessionAppendBlob(pBuf, buf2.aBuf, buf2.nBuf, &rc);\n  }\n  sqlite3_free(buf2.aBuf);\n\n  return rc;\n}\n\n/*\n** Append a DELETE change to the buffer passed as the first argument. Use\n** the changeset format if argument bPatchset is zero, or the patchset\n** format otherwise.\n*/\nstatic int sessionAppendDelete(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  SessionChange *p,               /* Object containing old values */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n\n  sessionAppendByte(pBuf, SQLITE_DELETE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n\n  if( bPatchset==0 ){\n    sessionAppendBlob(pBuf, p->aRecord, p->nRecord, &rc);\n  }else{\n    int i;\n    u8 *a = p->aRecord;\n    for(i=0; i<nCol; i++){\n      u8 *pStart = a;\n      int eType = *a++;\n\n      switch( eType ){\n        case 0:\n        case SQLITE_NULL:\n          assert( abPK[i]==0 );\n          break;\n\n        case SQLITE_FLOAT:\n        case SQLITE_INTEGER:\n          a += 8;\n          break;\n\n        default: {\n          int n;\n          a += sessionVarintGet(a, &n);\n          a += n;\n          break;\n        }\n      }\n      if( abPK[i] ){\n        sessionAppendBlob(pBuf, pStart, (int)(a-pStart), &rc);\n      }\n    }\n    assert( (a - p->aRecord)==p->nRecord );\n  }\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a SELECT statement to retrieve a row from table\n** zTab in database zDb based on its primary key. i.e.\n**\n**   SELECT * FROM zDb.zTab WHERE pk1 = ? AND pk2 = ? AND ...\n*/\nstatic int sessionSelectStmt(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Database name */\n  const char *zTab,               /* Table name */\n  int nCol,                       /* Number of columns in table */\n  const char **azCol,             /* Names of table columns */\n  u8 *abPK,                       /* PRIMARY KEY  array */\n  sqlite3_stmt **ppStmt           /* OUT: Prepared SELECT statement */\n){\n  int rc = SQLITE_OK;\n  int i;\n  const char *zSep = \"\";\n  SessionBuffer buf = {0, 0, 0};\n\n  sessionAppendStr(&buf, \"SELECT * FROM \", &rc);\n  sessionAppendIdent(&buf, zDb, &rc);\n  sessionAppendStr(&buf, \".\", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n  for(i=0; i<nCol; i++){\n    if( abPK[i] ){\n      sessionAppendStr(&buf, zSep, &rc);\n      sessionAppendIdent(&buf, azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i+1, &rc);\n      zSep = \" AND \";\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, ppStmt, 0);\n  }\n  sqlite3_free(buf.aBuf);\n  return rc;\n}\n\n/*\n** Bind the PRIMARY KEY values from the change passed in argument pChange\n** to the SELECT statement passed as the first argument. The SELECT statement\n** is as prepared by function sessionSelectStmt().\n**\n** Return SQLITE_OK if all PK values are successfully bound, or an SQLite\n** error code (e.g. SQLITE_NOMEM) otherwise.\n*/\nstatic int sessionSelectBind(\n  sqlite3_stmt *pSelect,          /* SELECT from sessionSelectStmt() */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK,                       /* PRIMARY KEY array */\n  SessionChange *pChange          /* Change structure */\n){\n  int i;\n  int rc = SQLITE_OK;\n  u8 *a = pChange->aRecord;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = *a++;\n\n    switch( eType ){\n      case 0:\n      case SQLITE_NULL:\n        assert( abPK[i]==0 );\n        break;\n\n      case SQLITE_INTEGER: {\n        if( abPK[i] ){\n          i64 iVal = sessionGetI64(a);\n          rc = sqlite3_bind_int64(pSelect, i+1, iVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_FLOAT: {\n        if( abPK[i] ){\n          double rVal;\n          i64 iVal = sessionGetI64(a);\n          memcpy(&rVal, &iVal, 8);\n          rc = sqlite3_bind_double(pSelect, i+1, rVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_TEXT: {\n        int n;\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_text(pSelect, i+1, (char *)a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n\n      default: {\n        int n;\n        assert( eType==SQLITE_BLOB );\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is a no-op if *pRc is set to other than SQLITE_OK when it\n** is called. Otherwise, append a serialized table header (part of the binary \n** changeset format) to buffer *pBuf. If an error occurs, set *pRc to an\n** SQLite error code before returning.\n*/\nstatic void sessionAppendTableHdr(\n  SessionBuffer *pBuf,            /* Append header to this buffer */\n  int bPatchset,                  /* Use the patchset format if true */\n  SessionTable *pTab,             /* Table object to append header for */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  /* Write a table header */\n  sessionAppendByte(pBuf, (bPatchset ? 'P' : 'T'), pRc);\n  sessionAppendVarint(pBuf, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, pTab->abPK, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, (u8 *)pTab->zName, (int)strlen(pTab->zName)+1, pRc);\n}\n\n/*\n** Generate either a changeset (if argument bPatchset is zero) or a patchset\n** (if it is non-zero) based on the current contents of the session object\n** passed as the first argument.\n**\n** If no error occurs, SQLITE_OK is returned and the new changeset/patchset\n** stored in output variables *pnChangeset and *ppChangeset. Or, if an error\n** occurs, an SQLite error code is returned and both output variables set \n** to 0.\n*/\nstatic int sessionGenerateChangeset(\n  sqlite3_session *pSession,      /* Session object */\n  int bPatchset,                  /* True for patchset, false for changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,                     /* First argument for xOutput */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  sqlite3 *db = pSession->db;     /* Source database handle */\n  SessionTable *pTab;             /* Used to iterate through attached tables */\n  SessionBuffer buf = {0,0,0};    /* Buffer in which to accumlate changeset */\n  int rc;                         /* Return code */\n\n  assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );\n\n  /* Zero the output variables in case an error occurs. If this session\n  ** object is already in the error state (sqlite3_session.rc != SQLITE_OK),\n  ** this call will be a no-op.  */\n  if( xOutput==0 ){\n    *pnChangeset = 0;\n    *ppChangeset = 0;\n  }\n\n  if( pSession->rc ) return pSession->rc;\n  rc = sqlite3_exec(pSession->db, \"SAVEPOINT changeset\", 0, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n\n  for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    if( pTab->nEntry ){\n      const char *zName = pTab->zName;\n      int nCol;                   /* Number of columns in table */\n      u8 *abPK;                   /* Primary key array */\n      const char **azCol = 0;     /* Table columns */\n      int i;                      /* Used to iterate through hash buckets */\n      sqlite3_stmt *pSel = 0;     /* SELECT statement to query table pTab */\n      int nRewind = buf.nBuf;     /* Initial size of write buffer */\n      int nNoop;                  /* Size of buffer after writing tbl header */\n\n      /* Check the table schema is still Ok. */\n      rc = sessionTableInfo(db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK);\n      if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){\n        rc = SQLITE_SCHEMA;\n      }\n\n      /* Write a table header */\n      sessionAppendTableHdr(&buf, bPatchset, pTab, &rc);\n\n      /* Build and compile a statement to execute: */\n      if( rc==SQLITE_OK ){\n        rc = sessionSelectStmt(\n            db, pSession->zDb, zName, nCol, azCol, abPK, &pSel);\n      }\n\n      nNoop = buf.nBuf;\n      for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){\n        SessionChange *p;         /* Used to iterate through changes */\n\n        for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){\n          rc = sessionSelectBind(pSel, nCol, abPK, p);\n          if( rc!=SQLITE_OK ) continue;\n          if( sqlite3_step(pSel)==SQLITE_ROW ){\n            if( p->op==SQLITE_INSERT ){\n              int iCol;\n              sessionAppendByte(&buf, SQLITE_INSERT, &rc);\n              sessionAppendByte(&buf, p->bIndirect, &rc);\n              for(iCol=0; iCol<nCol; iCol++){\n                sessionAppendCol(&buf, pSel, iCol, &rc);\n              }\n            }else{\n              rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);\n            }\n          }else if( p->op!=SQLITE_INSERT ){\n            rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3_reset(pSel);\n          }\n\n          /* If the buffer is now larger than SESSIONS_STRM_CHUNK_SIZE, pass\n          ** its contents to the xOutput() callback. */\n          if( xOutput \n           && rc==SQLITE_OK \n           && buf.nBuf>nNoop \n           && buf.nBuf>SESSIONS_STRM_CHUNK_SIZE \n          ){\n            rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n            nNoop = -1;\n            buf.nBuf = 0;\n          }\n\n        }\n      }\n\n      sqlite3_finalize(pSel);\n      if( buf.nBuf==nNoop ){\n        buf.nBuf = nRewind;\n      }\n      sqlite3_free((char*)azCol);  /* cast works around VC++ bug */\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput==0 ){\n      *pnChangeset = buf.nBuf;\n      *ppChangeset = buf.aBuf;\n      buf.aBuf = 0;\n    }else if( buf.nBuf>0 ){\n      rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n    }\n  }\n\n  sqlite3_free(buf.aBuf);\n  sqlite3_exec(db, \"RELEASE changeset\", 0, 0, 0);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Obtain a changeset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nint sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset);\n}\n\n/*\n** Streaming version of sqlite3session_changeset().\n*/\nint sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);\n}\n\n/*\n** Streaming version of sqlite3session_patchset().\n*/\nint sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);\n}\n\n/*\n** Obtain a patchset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nint sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppChangeset */\n  void **ppPatchset               /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nint sqlite3session_enable(sqlite3_session *pSession, int bEnable){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bEnable>=0 ){\n    pSession->bEnable = bEnable;\n  }\n  ret = pSession->bEnable;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nint sqlite3session_indirect(sqlite3_session *pSession, int bIndirect){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bIndirect>=0 ){\n    pSession->bIndirect = bIndirect;\n  }\n  ret = pSession->bIndirect;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Return true if there have been no changes to monitored tables recorded\n** by the session object passed as the only argument.\n*/\nint sqlite3session_isempty(sqlite3_session *pSession){\n  int ret = 0;\n  SessionTable *pTab;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  for(pTab=pSession->pTable; pTab && ret==0; pTab=pTab->pNext){\n    ret = (pTab->nEntry>0);\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n\n  return (ret==0);\n}\n\n/*\n** Do the work for either sqlite3changeset_start() or start_strm().\n*/\nstatic int sessionChangesetStart(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset                /* Pointer to buffer containing changeset */\n){\n  sqlite3_changeset_iter *pRet;   /* Iterator to return */\n  int nByte;                      /* Number of bytes to allocate for iterator */\n\n  assert( xInput==0 || (pChangeset==0 && nChangeset==0) );\n\n  /* Zero the output variable in case an error occurs. */\n  *pp = 0;\n\n  /* Allocate and initialize the iterator structure. */\n  nByte = sizeof(sqlite3_changeset_iter);\n  pRet = (sqlite3_changeset_iter *)sqlite3_malloc(nByte);\n  if( !pRet ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(sqlite3_changeset_iter));\n  pRet->in.aData = (u8 *)pChangeset;\n  pRet->in.nData = nChangeset;\n  pRet->in.xInput = xInput;\n  pRet->in.pIn = pIn;\n  pRet->in.bEof = (xInput ? 0 : 1);\n\n  /* Populate the output variable and return success. */\n  *pp = pRet;\n  return SQLITE_OK;\n}\n\n/*\n** Create an iterator used to iterate through the contents of a changeset.\n*/\nint sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset                /* Pointer to buffer containing changeset */\n){\n  return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset);\n}\n\n/*\n** Streaming version of sqlite3changeset_start().\n*/\nint sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  return sessionChangesetStart(pp, xInput, pIn, 0, 0);\n}\n\n/*\n** If the SessionInput object passed as the only argument is a streaming\n** object and the buffer is full, discard some data to free up space.\n*/\nstatic void sessionDiscardData(SessionInput *pIn){\n  if( pIn->bEof && pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){\n    int nMove = pIn->buf.nBuf - pIn->iNext;\n    assert( nMove>=0 );\n    if( nMove>0 ){\n      memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);\n    }\n    pIn->buf.nBuf -= pIn->iNext;\n    pIn->iNext = 0;\n    pIn->nData = pIn->buf.nBuf;\n  }\n}\n\n/*\n** Ensure that there are at least nByte bytes available in the buffer. Or,\n** if there are not nByte bytes remaining in the input, that all available\n** data is in the buffer.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int sessionInputBuffer(SessionInput *pIn, int nByte){\n  int rc = SQLITE_OK;\n  if( pIn->xInput ){\n    while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){\n      int nNew = SESSIONS_STRM_CHUNK_SIZE;\n\n      if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);\n      if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){\n        rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);\n        if( nNew==0 ){\n          pIn->bEof = 1;\n        }else{\n          pIn->buf.nBuf += nNew;\n        }\n      }\n\n      pIn->aData = pIn->buf.aBuf;\n      pIn->nData = pIn->buf.nBuf;\n    }\n  }\n  return rc;\n}\n\n/*\n** When this function is called, *ppRec points to the start of a record\n** that contains nCol values. This function advances the pointer *ppRec\n** until it points to the byte immediately following that record.\n*/\nstatic void sessionSkipRecord(\n  u8 **ppRec,                     /* IN/OUT: Record pointer */\n  int nCol                        /* Number of values in record */\n){\n  u8 *aRec = *ppRec;\n  int i;\n  for(i=0; i<nCol; i++){\n    int eType = *aRec++;\n    if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n      int nByte;\n      aRec += sessionVarintGet((u8*)aRec, &nByte);\n      aRec += nByte;\n    }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      aRec += 8;\n    }\n  }\n\n  *ppRec = aRec;\n}\n\n/*\n** This function sets the value of the sqlite3_value object passed as the\n** first argument to a copy of the string or blob held in the aData[] \n** buffer. SQLITE_OK is returned if successful, or SQLITE_NOMEM if an OOM\n** error occurs.\n*/\nstatic int sessionValueSetStr(\n  sqlite3_value *pVal,            /* Set the value of this object */\n  u8 *aData,                      /* Buffer containing string or blob data */\n  int nData,                      /* Size of buffer aData[] in bytes */\n  u8 enc                          /* String encoding (0 for blobs) */\n){\n  /* In theory this code could just pass SQLITE_TRANSIENT as the final\n  ** argument to sqlite3ValueSetStr() and have the copy created \n  ** automatically. But doing so makes it difficult to detect any OOM\n  ** error. Hence the code to create the copy externally. */\n  u8 *aCopy = sqlite3_malloc(nData+1);\n  if( aCopy==0 ) return SQLITE_NOMEM;\n  memcpy(aCopy, aData, nData);\n  sqlite3ValueSetStr(pVal, nData, (char*)aCopy, enc, sqlite3_free);\n  return SQLITE_OK;\n}\n\n/*\n** Deserialize a single record from a buffer in memory. See \"RECORD FORMAT\"\n** for details.\n**\n** When this function is called, *paChange points to the start of the record\n** to deserialize. Assuming no error occurs, *paChange is set to point to\n** one byte after the end of the same record before this function returns.\n** If the argument abPK is NULL, then the record contains nCol values. Or,\n** if abPK is other than NULL, then the record contains only the PK fields\n** (in other words, it is a patchset DELETE record).\n**\n** If successful, each element of the apOut[] array (allocated by the caller)\n** is set to point to an sqlite3_value object containing the value read\n** from the corresponding position in the record. If that value is not\n** included in the record (i.e. because the record is part of an UPDATE change\n** and the field was not modified), the corresponding element of apOut[] is\n** set to NULL.\n**\n** It is the responsibility of the caller to free all sqlite_value structures\n** using sqlite3_free().\n**\n** If an error occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n** The apOut[] array may have been partially populated in this case.\n*/\nstatic int sessionReadRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of values in record */\n  u8 *abPK,                       /* Array of primary key flags, or NULL */\n  sqlite3_value **apOut           /* Write values to this array */\n){\n  int i;                          /* Used to iterate through columns */\n  int rc = SQLITE_OK;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = 0;                /* Type of value (SQLITE_NULL, TEXT etc.) */\n    if( abPK && abPK[i]==0 ) continue;\n    rc = sessionInputBuffer(pIn, 9);\n    if( rc==SQLITE_OK ){\n      eType = pIn->aData[pIn->iNext++];\n    }\n\n    assert( apOut[i]==0 );\n    if( eType ){\n      apOut[i] = sqlite3ValueNew(0);\n      if( !apOut[i] ) rc = SQLITE_NOMEM;\n    }\n\n    if( rc==SQLITE_OK ){\n      u8 *aVal = &pIn->aData[pIn->iNext];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int nByte;\n        pIn->iNext += sessionVarintGet(aVal, &nByte);\n        rc = sessionInputBuffer(pIn, nByte);\n        if( rc==SQLITE_OK ){\n          u8 enc = (eType==SQLITE_TEXT ? SQLITE_UTF8 : 0);\n          rc = sessionValueSetStr(apOut[i],&pIn->aData[pIn->iNext],nByte,enc);\n        }\n        pIn->iNext += nByte;\n      }\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        sqlite3_int64 v = sessionGetI64(aVal);\n        if( eType==SQLITE_INTEGER ){\n          sqlite3VdbeMemSetInt64(apOut[i], v);\n        }else{\n          double d;\n          memcpy(&d, &v, 8);\n          sqlite3VdbeMemSetDouble(apOut[i], d);\n        }\n        pIn->iNext += 8;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function ensures that all of the above is present in the input \n** buffer (i.e. that it can be accessed without any calls to xInput()).\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n** The input pointer is not moved.\n*/\nstatic int sessionChangesetBufferTblhdr(SessionInput *pIn, int *pnByte){\n  int rc = SQLITE_OK;\n  int nCol = 0;\n  int nRead = 0;\n\n  rc = sessionInputBuffer(pIn, 9);\n  if( rc==SQLITE_OK ){\n    nRead += sessionVarintGet(&pIn->aData[pIn->iNext + nRead], &nCol);\n    rc = sessionInputBuffer(pIn, nRead+nCol+100);\n    nRead += nCol;\n  }\n\n  while( rc==SQLITE_OK ){\n    while( (pIn->iNext + nRead)<pIn->nData && pIn->aData[pIn->iNext + nRead] ){\n      nRead++;\n    }\n    if( (pIn->iNext + nRead)<pIn->nData ) break;\n    rc = sessionInputBuffer(pIn, nRead + 100);\n  }\n  *pnByte = nRead+1;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the first byte of the first field\n** of a record consisting of nCol columns. This function ensures the entire\n** record is buffered. It does not move the input pointer.\n**\n** If successful, SQLITE_OK is returned and *pnByte is set to the size of\n** the record in bytes. Otherwise, an SQLite error code is returned. The\n** final value of *pnByte is undefined in this case.\n*/\nstatic int sessionChangesetBufferRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of columns in record */\n  int *pnByte                     /* OUT: Size of record in bytes */\n){\n  int rc = SQLITE_OK;\n  int nByte = 0;\n  int i;\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    int eType;\n    rc = sessionInputBuffer(pIn, nByte + 10);\n    if( rc==SQLITE_OK ){\n      eType = pIn->aData[pIn->iNext + nByte++];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int n;\n        nByte += sessionVarintGet(&pIn->aData[pIn->iNext+nByte], &n);\n        nByte += n;\n        rc = sessionInputBuffer(pIn, nByte);\n      }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        nByte += 8;\n      }\n    }\n  }\n  *pnByte = nByte;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function decodes the table-header and populates the p->nCol, \n** p->zTab and p->abPK[] variables accordingly. The p->apValue[] array is \n** also allocated or resized according to the new value of p->nCol. The\n** input pointer is left pointing to the byte following the table header.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code\n** is returned and the final values of the various fields enumerated above\n** are undefined.\n*/\nstatic int sessionChangesetReadTblhdr(sqlite3_changeset_iter *p){\n  int rc;\n  int nCopy;\n  assert( p->rc==SQLITE_OK );\n\n  rc = sessionChangesetBufferTblhdr(&p->in, &nCopy);\n  if( rc==SQLITE_OK ){\n    int nByte;\n    int nVarint;\n    nVarint = sessionVarintGet(&p->in.aData[p->in.iNext], &p->nCol);\n    nCopy -= nVarint;\n    p->in.iNext += nVarint;\n    nByte = p->nCol * sizeof(sqlite3_value*) * 2 + nCopy;\n    p->tblhdr.nBuf = 0;\n    sessionBufferGrow(&p->tblhdr, nByte, &rc);\n  }\n\n  if( rc==SQLITE_OK ){\n    int iPK = sizeof(sqlite3_value*)*p->nCol*2;\n    memset(p->tblhdr.aBuf, 0, iPK);\n    memcpy(&p->tblhdr.aBuf[iPK], &p->in.aData[p->in.iNext], nCopy);\n    p->in.iNext += nCopy;\n  }\n\n  p->apValue = (sqlite3_value**)p->tblhdr.aBuf;\n  p->abPK = (u8*)&p->apValue[p->nCol*2];\n  p->zTab = (char*)&p->abPK[p->nCol];\n  return (p->rc = rc);\n}\n\n/*\n** Advance the changeset iterator to the next change.\n**\n** If both paRec and pnRec are NULL, then this function works like the public\n** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the\n** sqlite3changeset_new() and old() APIs may be used to query for values.\n**\n** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change\n** record is written to *paRec before returning and the number of bytes in\n** the record to *pnRec.\n**\n** Either way, this function returns SQLITE_ROW if the iterator is \n** successfully advanced to the next change in the changeset, an SQLite \n** error code if an error occurs, or SQLITE_DONE if there are no further \n** changes in the changeset.\n*/\nstatic int sessionChangesetNext(\n  sqlite3_changeset_iter *p,      /* Changeset iterator */\n  u8 **paRec,                     /* If non-NULL, store record pointer here */\n  int *pnRec                      /* If non-NULL, store size of record here */\n){\n  int i;\n  u8 op;\n\n  assert( (paRec==0 && pnRec==0) || (paRec && pnRec) );\n\n  /* If the iterator is in the error-state, return immediately. */\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* Free the current contents of p->apValue[], if any. */\n  if( p->apValue ){\n    for(i=0; i<p->nCol*2; i++){\n      sqlite3ValueFree(p->apValue[i]);\n    }\n    memset(p->apValue, 0, sizeof(sqlite3_value*)*p->nCol*2);\n  }\n\n  /* Make sure the buffer contains at least 10 bytes of input data, or all\n  ** remaining data if there are less than 10 bytes available. This is\n  ** sufficient either for the 'T' or 'P' byte and the varint that follows\n  ** it, or for the two single byte values otherwise. */\n  p->rc = sessionInputBuffer(&p->in, 2);\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* If the iterator is already at the end of the changeset, return DONE. */\n  if( p->in.iNext>=p->in.nData ){\n    return SQLITE_DONE;\n  }\n\n  sessionDiscardData(&p->in);\n  p->in.iCurrent = p->in.iNext;\n\n  op = p->in.aData[p->in.iNext++];\n  while( op=='T' || op=='P' ){\n    p->bPatchset = (op=='P');\n    if( sessionChangesetReadTblhdr(p) ) return p->rc;\n    if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;\n    p->in.iCurrent = p->in.iNext;\n    if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;\n    op = p->in.aData[p->in.iNext++];\n  }\n\n  p->op = op;\n  p->bIndirect = p->in.aData[p->in.iNext++];\n  if( p->op!=SQLITE_UPDATE && p->op!=SQLITE_DELETE && p->op!=SQLITE_INSERT ){\n    return (p->rc = SQLITE_CORRUPT_BKPT);\n  }\n\n  if( paRec ){ \n    int nVal;                     /* Number of values to buffer */\n    if( p->bPatchset==0 && op==SQLITE_UPDATE ){\n      nVal = p->nCol * 2;\n    }else if( p->bPatchset && op==SQLITE_DELETE ){\n      nVal = 0;\n      for(i=0; i<p->nCol; i++) if( p->abPK[i] ) nVal++;\n    }else{\n      nVal = p->nCol;\n    }\n    p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);\n    if( p->rc!=SQLITE_OK ) return p->rc;\n    *paRec = &p->in.aData[p->in.iNext];\n    p->in.iNext += *pnRec;\n  }else{\n\n    /* If this is an UPDATE or DELETE, read the old.* record. */\n    if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){\n      u8 *abPK = p->bPatchset ? p->abPK : 0;\n      p->rc = sessionReadRecord(&p->in, p->nCol, abPK, p->apValue);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    /* If this is an INSERT or UPDATE, read the new.* record. */\n    if( p->op!=SQLITE_DELETE ){\n      p->rc = sessionReadRecord(&p->in, p->nCol, 0, &p->apValue[p->nCol]);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    if( p->bPatchset && p->op==SQLITE_UPDATE ){\n      /* If this is an UPDATE that is part of a patchset, then all PK and\n      ** modified fields are present in the new.* record. The old.* record\n      ** is currently completely empty. This block shifts the PK fields from\n      ** new.* to old.*, to accommodate the code that reads these arrays.  */\n      for(i=0; i<p->nCol; i++){\n        assert( p->apValue[i]==0 );\n        assert( p->abPK[i]==0 || p->apValue[i+p->nCol] );\n        if( p->abPK[i] ){\n          p->apValue[i] = p->apValue[i+p->nCol];\n          p->apValue[i+p->nCol] = 0;\n        }\n      }\n    }\n  }\n\n  return SQLITE_ROW;\n}\n\n/*\n** Advance an iterator created by sqlite3changeset_start() to the next\n** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE\n** or SQLITE_CORRUPT.\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nint sqlite3changeset_next(sqlite3_changeset_iter *p){\n  return sessionChangesetNext(p, 0, 0);\n}\n\n/*\n** The following function extracts information on the current change\n** from a changeset iterator. It may only be called after changeset_next()\n** has returned SQLITE_ROW.\n*/\nint sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator handle */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True if change is indirect */\n){\n  *pOp = pIter->op;\n  *pnCol = pIter->nCol;\n  *pzTab = pIter->zTab;\n  if( pbIndirect ) *pbIndirect = pIter->bIndirect;\n  return SQLITE_OK;\n}\n\n/*\n** Return information regarding the PRIMARY KEY and number of columns in\n** the database table affected by the change that pIter currently points\n** to. This function may only be called after changeset_next() returns\n** SQLITE_ROW.\n*/\nint sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n){\n  *pabPK = pIter->abPK;\n  if( pnCol ) *pnCol = pIter->nCol;\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_DELETE change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the old.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified and is not a PK column), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nint sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of old.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_DELETE ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[iVal];\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_INSERT change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the new.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nint sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of new.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_INSERT ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[pIter->nCol+iVal];\n  return SQLITE_OK;\n}\n\n/*\n** The following two macros are used internally. They are similar to the\n** sqlite3changeset_new() and sqlite3changeset_old() functions, except that\n** they omit all error checking and return a pointer to the requested value.\n*/\n#define sessionChangesetNew(pIter, iVal) (pIter)->apValue[(pIter)->nCol+(iVal)]\n#define sessionChangesetOld(pIter, iVal) (pIter)->apValue[(iVal)]\n\n/*\n** This function may only be called with a changeset iterator that has been\n** passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT \n** conflict-handler function. Otherwise, SQLITE_MISUSE is returned.\n**\n** If successful, *ppValue is set to point to an sqlite3_value structure\n** containing the iVal'th value of the conflicting record.\n**\n** If value iVal is out-of-range or some other error occurs, an SQLite error\n** code is returned. Otherwise, SQLITE_OK.\n*/\nint sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of conflict record value to fetch */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n){\n  if( !pIter->pConflict ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = sqlite3_column_value(pIter->pConflict, iVal);\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nint sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n){\n  if( pIter->pConflict || pIter->apValue ){\n    return SQLITE_MISUSE;\n  }\n  *pnOut = pIter->nCol;\n  return SQLITE_OK;\n}\n\n\n/*\n** Finalize an iterator allocated with sqlite3changeset_start().\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nint sqlite3changeset_finalize(sqlite3_changeset_iter *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;                        /* Used to iterate through p->apValue[] */\n    rc = p->rc;\n    if( p->apValue ){\n      for(i=0; i<p->nCol*2; i++) sqlite3ValueFree(p->apValue[i]);\n    }\n    sqlite3_free(p->tblhdr.aBuf);\n    sqlite3_free(p->in.buf.aBuf);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\nstatic int sessionChangesetInvert(\n  SessionInput *pInput,           /* Input changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  int rc = SQLITE_OK;             /* Return value */\n  SessionBuffer sOut;             /* Output buffer */\n  int nCol = 0;                   /* Number of cols in current table */\n  u8 *abPK = 0;                   /* PK array for current table */\n  sqlite3_value **apVal = 0;      /* Space for values for UPDATE inversion */\n  SessionBuffer sPK = {0, 0, 0};  /* PK array for current table */\n\n  /* Initialize the output buffer */\n  memset(&sOut, 0, sizeof(SessionBuffer));\n\n  /* Zero the output variables in case an error occurs. */\n  if( ppInverted ){\n    *ppInverted = 0;\n    *pnInverted = 0;\n  }\n\n  while( 1 ){\n    u8 eType;\n\n    /* Test for EOF. */\n    if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;\n    if( pInput->iNext>=pInput->nData ) break;\n    eType = pInput->aData[pInput->iNext];\n\n    switch( eType ){\n      case 'T': {\n        /* A 'table' record consists of:\n        **\n        **   * A constant 'T' character,\n        **   * Number of columns in said table (a varint),\n        **   * An array of nCol bytes (sPK),\n        **   * A nul-terminated table name.\n        */\n        int nByte;\n        int nVar;\n        pInput->iNext++;\n        if( (rc = sessionChangesetBufferTblhdr(pInput, &nByte)) ){\n          goto finished_invert;\n        }\n        nVar = sessionVarintGet(&pInput->aData[pInput->iNext], &nCol);\n        sPK.nBuf = 0;\n        sessionAppendBlob(&sPK, &pInput->aData[pInput->iNext+nVar], nCol, &rc);\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        if( rc ) goto finished_invert;\n\n        pInput->iNext += nByte;\n        sqlite3_free(apVal);\n        apVal = 0;\n        abPK = sPK.aBuf;\n        break;\n      }\n\n      case SQLITE_INSERT:\n      case SQLITE_DELETE: {\n        int nByte;\n        int bIndirect = pInput->aData[pInput->iNext+1];\n        int eType2 = (eType==SQLITE_DELETE ? SQLITE_INSERT : SQLITE_DELETE);\n        pInput->iNext += 2;\n        assert( rc==SQLITE_OK );\n        rc = sessionChangesetBufferRecord(pInput, nCol, &nByte);\n        sessionAppendByte(&sOut, eType2, &rc);\n        sessionAppendByte(&sOut, bIndirect, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        pInput->iNext += nByte;\n        if( rc ) goto finished_invert;\n        break;\n      }\n\n      case SQLITE_UPDATE: {\n        int iCol;\n\n        if( 0==apVal ){\n          apVal = (sqlite3_value **)sqlite3_malloc(sizeof(apVal[0])*nCol*2);\n          if( 0==apVal ){\n            rc = SQLITE_NOMEM;\n            goto finished_invert;\n          }\n          memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        }\n\n        /* Write the header for the new UPDATE change. Same as the original. */\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendByte(&sOut, pInput->aData[pInput->iNext+1], &rc);\n\n        /* Read the old.* and new.* records for the update change. */\n        pInput->iNext += 2;\n        rc = sessionReadRecord(pInput, nCol, 0, &apVal[0]);\n        if( rc==SQLITE_OK ){\n          rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol]);\n        }\n\n        /* Write the new old.* record. Consists of the PK columns from the\n        ** original old.* record, and the other values from the original\n        ** new.* record. */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = apVal[iCol + (abPK[iCol] ? 0 : nCol)];\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        /* Write the new new.* record. Consists of a copy of all values\n        ** from the original old.* record, except for the PK columns, which\n        ** are set to \"undefined\". */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = (abPK[iCol] ? 0 : apVal[iCol]);\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        for(iCol=0; iCol<nCol*2; iCol++){\n          sqlite3ValueFree(apVal[iCol]);\n        }\n        memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        if( rc!=SQLITE_OK ){\n          goto finished_invert;\n        }\n\n        break;\n      }\n\n      default:\n        rc = SQLITE_CORRUPT_BKPT;\n        goto finished_invert;\n    }\n\n    assert( rc==SQLITE_OK );\n    if( xOutput && sOut.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){\n      rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n      sOut.nBuf = 0;\n      if( rc!=SQLITE_OK ) goto finished_invert;\n    }\n  }\n\n  assert( rc==SQLITE_OK );\n  if( pnInverted ){\n    *pnInverted = sOut.nBuf;\n    *ppInverted = sOut.aBuf;\n    sOut.aBuf = 0;\n  }else if( sOut.nBuf>0 ){\n    rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n  }\n\n finished_invert:\n  sqlite3_free(sOut.aBuf);\n  sqlite3_free(apVal);\n  sqlite3_free(sPK.aBuf);\n  return rc;\n}\n\n\n/*\n** Invert a changeset object.\n*/\nint sqlite3changeset_invert(\n  int nChangeset,                 /* Number of bytes in input */\n  const void *pChangeset,         /* Input changeset */\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  SessionInput sInput;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.nData = nChangeset;\n  sInput.aData = (u8*)pChangeset;\n\n  return sessionChangesetInvert(&sInput, 0, 0, pnInverted, ppInverted);\n}\n\n/*\n** Streaming version of sqlite3changeset_invert().\n*/\nint sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  SessionInput sInput;\n  int rc;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.xInput = xInput;\n  sInput.pIn = pIn;\n\n  rc = sessionChangesetInvert(&sInput, xOutput, pOut, 0, 0);\n  sqlite3_free(sInput.buf.aBuf);\n  return rc;\n}\n\ntypedef struct SessionApplyCtx SessionApplyCtx;\nstruct SessionApplyCtx {\n  sqlite3 *db;\n  sqlite3_stmt *pDelete;          /* DELETE statement */\n  sqlite3_stmt *pUpdate;          /* UPDATE statement */\n  sqlite3_stmt *pInsert;          /* INSERT statement */\n  sqlite3_stmt *pSelect;          /* SELECT statement */\n  int nCol;                       /* Size of azCol[] and abPK[] arrays */\n  const char **azCol;             /* Array of column names */\n  u8 *abPK;                       /* Boolean array - true if column is in PK */\n\n  int bDeferConstraints;          /* True to defer constraints */\n  SessionBuffer constraints;      /* Deferred constraints are stored here */\n};\n\n/*\n** Formulate a statement to DELETE a row from database db. Assuming a table\n** structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The DELETE statement looks like this:\n**\n**     DELETE FROM x WHERE a = :1 AND c = :3 AND (:5 OR b IS :2 AND d IS :4)\n**\n** Variable :5 (nCol+1) is a boolean. It should be set to 0 if we require\n** matching b and d values, or 1 otherwise. The second case comes up if the\n** conflict handler is invoked with NOTFOUND and returns CHANGESET_REPLACE.\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pDelete is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionDeleteRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int i;\n  const char *zSep = \"\";\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  int nPk = 0;\n\n  sessionAppendStr(&buf, \"DELETE FROM \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      nPk++;\n      sessionAppendStr(&buf, zSep, &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i+1, &rc);\n      zSep = \" AND \";\n    }\n  }\n\n  if( nPk<p->nCol ){\n    sessionAppendStr(&buf, \" AND (?\", &rc);\n    sessionAppendInteger(&buf, p->nCol+1, &rc);\n    sessionAppendStr(&buf, \" OR \", &rc);\n\n    zSep = \"\";\n    for(i=0; i<p->nCol; i++){\n      if( !p->abPK[i] ){\n        sessionAppendStr(&buf, zSep, &rc);\n        sessionAppendIdent(&buf, p->azCol[i], &rc);\n        sessionAppendStr(&buf, \" IS ?\", &rc);\n        sessionAppendInteger(&buf, i+1, &rc);\n        zSep = \"AND \";\n      }\n    }\n    sessionAppendStr(&buf, \")\", &rc);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pDelete, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a statement to UPDATE a row from database db. \n** Assuming a table structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The UPDATE statement looks like this:\n**\n**     UPDATE x SET\n**     a = CASE WHEN ?2  THEN ?3  ELSE a END,\n**     b = CASE WHEN ?5  THEN ?6  ELSE b END,\n**     c = CASE WHEN ?8  THEN ?9  ELSE c END,\n**     d = CASE WHEN ?11 THEN ?12 ELSE d END\n**     WHERE a = ?1 AND c = ?7 AND (?13 OR \n**       (?5==0 OR b IS ?4) AND (?11==0 OR d IS ?10) AND\n**     )\n**\n** For each column in the table, there are three variables to bind:\n**\n**     ?(i*3+1)    The old.* value of the column, if any.\n**     ?(i*3+2)    A boolean flag indicating that the value is being modified.\n**     ?(i*3+3)    The new.* value of the column, if any.\n**\n** Also, a boolean flag that, if set to true, causes the statement to update\n** a row even if the non-PK values do not match. This is required if the\n** conflict-handler is invoked with CHANGESET_DATA and returns\n** CHANGESET_REPLACE. This is variable \"?(nCol*3+1)\".\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pUpdate is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionUpdateRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  const char *zSep = \"\";\n  SessionBuffer buf = {0, 0, 0};\n\n  /* Append \"UPDATE tbl SET \" */\n  sessionAppendStr(&buf, \"UPDATE \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" SET \", &rc);\n\n  /* Append the assignments */\n  for(i=0; i<p->nCol; i++){\n    sessionAppendStr(&buf, zSep, &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" = CASE WHEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+2, &rc);\n    sessionAppendStr(&buf, \" THEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+3, &rc);\n    sessionAppendStr(&buf, \" ELSE \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" END\", &rc);\n    zSep = \", \";\n  }\n\n  /* Append the PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \" AND \", &rc);\n    }\n  }\n\n  /* Append the non-PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" (?\", &rc);\n  sessionAppendInteger(&buf, p->nCol*3+1, &rc);\n  sessionAppendStr(&buf, \" OR 1\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( !p->abPK[i] ){\n      sessionAppendStr(&buf, \" AND (?\", &rc);\n      sessionAppendInteger(&buf, i*3+2, &rc);\n      sessionAppendStr(&buf, \"=0 OR \", &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" IS ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \")\", &rc);\n    }\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pUpdate, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Formulate and prepare an SQL statement to query table zTab by primary\n** key. Assuming the following table structure:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The SELECT statement looks like this:\n**\n**     SELECT * FROM x WHERE a = ?1 AND c = ?3\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pSelect is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionSelectRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  return sessionSelectStmt(\n      db, \"main\", zTab, p->nCol, p->azCol, p->abPK, &p->pSelect);\n}\n\n/*\n** Formulate and prepare an INSERT statement to add a record to table zTab.\n** For example:\n**\n**     INSERT INTO main.\"zTab\" VALUES(?1, ?2, ?3 ...);\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pInsert is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionInsertRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  SessionBuffer buf = {0, 0, 0};\n\n  sessionAppendStr(&buf, \"INSERT INTO main.\", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \"(\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( i!=0 ) sessionAppendStr(&buf, \", \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n  }\n\n  sessionAppendStr(&buf, \") VALUES(?\", &rc);\n  for(i=1; i<p->nCol; i++){\n    sessionAppendStr(&buf, \", ?\", &rc);\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pInsert, 0);\n  }\n  sqlite3_free(buf.aBuf);\n  return rc;\n}\n\n/*\n** A wrapper around sqlite3_bind_value() that detects an extra problem. \n** See comments in the body of this function for details.\n*/\nstatic int sessionBindValue(\n  sqlite3_stmt *pStmt,            /* Statement to bind value to */\n  int i,                          /* Parameter number to bind to */\n  sqlite3_value *pVal             /* Value to bind */\n){\n  int eType = sqlite3_value_type(pVal);\n  /* COVERAGE: The (pVal->z==0) branch is never true using current versions\n  ** of SQLite. If a malloc fails in an sqlite3_value_xxx() function, either\n  ** the (pVal->z) variable remains as it was or the type of the value is\n  ** set to SQLITE_NULL.  */\n  if( (eType==SQLITE_TEXT || eType==SQLITE_BLOB) && pVal->z==0 ){\n    /* This condition occurs when an earlier OOM in a call to\n    ** sqlite3_value_text() or sqlite3_value_blob() (perhaps from within\n    ** a conflict-handler) has zeroed the pVal->z pointer. Return NOMEM. */\n    return SQLITE_NOMEM;\n  }\n  return sqlite3_bind_value(pStmt, i, pVal);\n}\n\n/*\n** Iterator pIter must point to an SQLITE_INSERT entry. This function \n** transfers new.* values from the current iterator entry to statement\n** pStmt. The table being inserted into has nCol columns.\n**\n** New.* value $i from the iterator is bound to variable ($i+1) of \n** statement pStmt. If parameter abPK is NULL, all values from 0 to (nCol-1)\n** are transfered to the statement. Otherwise, if abPK is not NULL, it points\n** to an array nCol elements in size. In this case only those values for \n** which abPK[$i] is true are read from the iterator and bound to the \n** statement.\n**\n** An SQLite error code is returned if an error occurs. Otherwise, SQLITE_OK.\n*/\nstatic int sessionBindRow(\n  sqlite3_changeset_iter *pIter,  /* Iterator to read values from */\n  int(*xValue)(sqlite3_changeset_iter *, int, sqlite3_value **),\n  int nCol,                       /* Number of columns */\n  u8 *abPK,                       /* If not NULL, bind only if true */\n  sqlite3_stmt *pStmt             /* Bind values to this statement */\n){\n  int i;\n  int rc = SQLITE_OK;\n\n  /* Neither sqlite3changeset_old or sqlite3changeset_new can fail if the\n  ** argument iterator points to a suitable entry. Make sure that xValue \n  ** is one of these to guarantee that it is safe to ignore the return \n  ** in the code below. */\n  assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );\n\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    if( !abPK || abPK[i] ){\n      sqlite3_value *pVal;\n      (void)xValue(pIter, i, &pVal);\n      rc = sessionBindValue(pStmt, i+1, pVal);\n    }\n  }\n  return rc;\n}\n\n/*\n** SQL statement pSelect is as generated by the sessionSelectRow() function.\n** This function binds the primary key values from the change that changeset\n** iterator pIter points to to the SELECT and attempts to seek to the table\n** entry. If a row is found, the SELECT statement left pointing at the row \n** and SQLITE_ROW is returned. Otherwise, if no row is found and no error\n** has occured, the statement is reset and SQLITE_OK is returned. If an\n** error occurs, the statement is reset and an SQLite error code is returned.\n**\n** If this function returns SQLITE_ROW, the caller must eventually reset() \n** statement pSelect. If any other value is returned, the statement does\n** not require a reset().\n**\n** If the iterator currently points to an INSERT record, bind values from the\n** new.* record to the SELECT statement. Or, if it points to a DELETE or\n** UPDATE, bind values from the old.* record. \n*/\nstatic int sessionSeekToRow(\n  sqlite3 *db,                    /* Database handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  u8 *abPK,                       /* Primary key flags array */\n  sqlite3_stmt *pSelect           /* SELECT statement from sessionSelectRow() */\n){\n  int rc;                         /* Return code */\n  int nCol;                       /* Number of columns in table */\n  int op;                         /* Changset operation (SQLITE_UPDATE etc.) */\n  const char *zDummy;             /* Unused */\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n  rc = sessionBindRow(pIter, \n      op==SQLITE_INSERT ? sqlite3changeset_new : sqlite3changeset_old,\n      nCol, abPK, pSelect\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_step(pSelect);\n    if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);\n  }\n\n  return rc;\n}\n\n/*\n** Invoke the conflict handler for the change that the changeset iterator\n** currently points to.\n**\n** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT.\n** If argument pbReplace is NULL, then the type of conflict handler invoked\n** depends solely on eType, as follows:\n**\n**    eType value                 Value passed to xConflict\n**    -------------------------------------------------\n**    CHANGESET_DATA              CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT          CHANGESET_CONSTRAINT\n**\n** Or, if pbReplace is not NULL, then an attempt is made to find an existing\n** record with the same primary key as the record about to be deleted, updated\n** or inserted. If such a record can be found, it is available to the conflict\n** handler as the \"conflicting\" record. In this case the type of conflict\n** handler invoked is as follows:\n**\n**    eType value         PK Record found?   Value passed to xConflict\n**    ----------------------------------------------------------------\n**    CHANGESET_DATA      Yes                CHANGESET_DATA\n**    CHANGESET_DATA      No                 CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT  Yes                CHANGESET_CONFLICT\n**    CHANGESET_CONFLICT  No                 CHANGESET_CONSTRAINT\n**\n** If pbReplace is not NULL, and a record with a matching PK is found, and\n** the conflict handler function returns SQLITE_CHANGESET_REPLACE, *pbReplace\n** is set to non-zero before returning SQLITE_OK.\n**\n** If the conflict handler returns SQLITE_CHANGESET_ABORT, SQLITE_ABORT is\n** returned. Or, if the conflict handler returns an invalid value, \n** SQLITE_MISUSE. If the conflict handler returns SQLITE_CHANGESET_OMIT,\n** this function returns SQLITE_OK.\n*/\nstatic int sessionConflictHandler(\n  int eType,                      /* Either CHANGESET_DATA or CONFLICT */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter*),\n  void *pCtx,                     /* First argument for conflict handler */\n  int *pbReplace                  /* OUT: Set to true if PK row is found */\n){\n  int res = 0;                    /* Value returned by conflict handler */\n  int rc;\n  int nCol;\n  int op;\n  const char *zDummy;\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  assert( eType==SQLITE_CHANGESET_CONFLICT || eType==SQLITE_CHANGESET_DATA );\n  assert( SQLITE_CHANGESET_CONFLICT+1==SQLITE_CHANGESET_CONSTRAINT );\n  assert( SQLITE_CHANGESET_DATA+1==SQLITE_CHANGESET_NOTFOUND );\n\n  /* Bind the new.* PRIMARY KEY values to the SELECT statement. */\n  if( pbReplace ){\n    rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);\n  }else{\n    rc = SQLITE_OK;\n  }\n\n  if( rc==SQLITE_ROW ){\n    /* There exists another row with the new.* primary key. */\n    pIter->pConflict = p->pSelect;\n    res = xConflict(pCtx, eType, pIter);\n    pIter->pConflict = 0;\n    rc = sqlite3_reset(p->pSelect);\n  }else if( rc==SQLITE_OK ){\n    if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){\n      /* Instead of invoking the conflict handler, append the change blob\n      ** to the SessionApplyCtx.constraints buffer. */\n      u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];\n      int nBlob = pIter->in.iNext - pIter->in.iCurrent;\n      sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);\n      res = SQLITE_CHANGESET_OMIT;\n    }else{\n      /* No other row with the new.* primary key. */\n      res = xConflict(pCtx, eType+1, pIter);\n      if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    switch( res ){\n      case SQLITE_CHANGESET_REPLACE:\n        assert( pbReplace );\n        *pbReplace = 1;\n        break;\n\n      case SQLITE_CHANGESET_OMIT:\n        break;\n\n      case SQLITE_CHANGESET_ABORT:\n        rc = SQLITE_ABORT;\n        break;\n\n      default:\n        rc = SQLITE_MISUSE;\n        break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** If argument pbRetry is NULL, then ignore any CHANGESET_DATA conflict. If\n** one is encountered, update or delete the row with the matching primary key\n** instead. Or, if pbRetry is not NULL and a CHANGESET_DATA conflict occurs,\n** invoke the conflict handler. If it returns CHANGESET_REPLACE, set *pbRetry\n** to true before returning. In this case the caller will invoke this function\n** again, this time with pbRetry set to NULL.\n**\n** If argument pbReplace is NULL and a CHANGESET_CONFLICT conflict is \n** encountered invoke the conflict handler with CHANGESET_CONSTRAINT instead.\n** Or, if pbReplace is not NULL, invoke it with CHANGESET_CONFLICT. If such\n** an invocation returns SQLITE_CHANGESET_REPLACE, set *pbReplace to true\n** before retrying. In this case the caller attempts to remove the conflicting\n** row before invoking this function again, this time with pbReplace set \n** to NULL.\n**\n** If any conflict handler returns SQLITE_CHANGESET_ABORT, this function\n** returns SQLITE_ABORT. Otherwise, if no error occurs, SQLITE_OK is \n** returned.\n*/\nstatic int sessionApplyOneOp(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter *),\n  void *pCtx,                     /* First argument for the conflict handler */\n  int *pbReplace,                 /* OUT: True to remove PK row and retry */\n  int *pbRetry                    /* OUT: True to retry. */\n){\n  const char *zDummy;\n  int op;\n  int nCol;\n  int rc = SQLITE_OK;\n\n  assert( p->pDelete && p->pUpdate && p->pInsert && p->pSelect );\n  assert( p->azCol && p->abPK );\n  assert( !pbReplace || *pbReplace==0 );\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  if( op==SQLITE_DELETE ){\n\n    /* Bind values to the DELETE statement. If conflict handling is required,\n    ** bind values for all columns and set bound variable (nCol+1) to true.\n    ** Or, if conflict handling is not required, bind just the PK column\n    ** values and, if it exists, set (nCol+1) to false. Conflict handling\n    ** is not required if:\n    **\n    **   * this is a patchset, or\n    **   * (pbRetry==0), or\n    **   * all columns of the table are PK columns (in this case there is\n    **     no (nCol+1) variable to bind to).\n    */\n    u8 *abPK = (pIter->bPatchset ? p->abPK : 0);\n    rc = sessionBindRow(pIter, sqlite3changeset_old, nCol, abPK, p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_bind_parameter_count(p->pDelete)>nCol ){\n      rc = sqlite3_bind_int(p->pDelete, nCol+1, (pbRetry==0 || abPK));\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    sqlite3_step(p->pDelete);\n    rc = sqlite3_reset(p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else if( op==SQLITE_UPDATE ){\n    int i;\n\n    /* Bind values to the UPDATE statement. */\n    for(i=0; rc==SQLITE_OK && i<nCol; i++){\n      sqlite3_value *pOld = sessionChangesetOld(pIter, i);\n      sqlite3_value *pNew = sessionChangesetNew(pIter, i);\n\n      sqlite3_bind_int(p->pUpdate, i*3+2, !!pNew);\n      if( pOld ){\n        rc = sessionBindValue(p->pUpdate, i*3+1, pOld);\n      }\n      if( rc==SQLITE_OK && pNew ){\n        rc = sessionBindValue(p->pUpdate, i*3+3, pNew);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(p->pUpdate, nCol*3+1, pbRetry==0 || pIter->bPatchset);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict,\n    ** the result will be SQLITE_OK with 0 rows modified. */\n    sqlite3_step(p->pUpdate);\n    rc = sqlite3_reset(p->pUpdate);\n\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      /* A NOTFOUND or DATA error. Search the table to see if it contains\n      ** a row with a matching primary key. If so, this is a DATA conflict.\n      ** Otherwise, if there is no primary key match, it is a NOTFOUND. */\n\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      /* This is always a CONSTRAINT conflict. */\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else{\n    assert( op==SQLITE_INSERT );\n    rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert);\n    if( rc!=SQLITE_OK ) return rc;\n\n    sqlite3_step(p->pInsert);\n    rc = sqlite3_reset(p->pInsert);\n    if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** The difference between this function and sessionApplyOne() is that this\n** function handles the case where the conflict-handler is invoked and \n** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be\n** retried in some manner.\n*/\nstatic int sessionApplyOneWithRetry(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator to read change from */\n  SessionApplyCtx *pApply,        /* Apply context */\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int bReplace = 0;\n  int bRetry = 0;\n  int rc;\n\n  rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);\n  assert( rc==SQLITE_OK || (bRetry==0 && bReplace==0) );\n\n  /* If the bRetry flag is set, the change has not been applied due to an\n  ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and\n  ** a row with the correct PK is present in the db, but one or more other\n  ** fields do not contain the expected values) and the conflict handler \n  ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,\n  ** but pass NULL as the final argument so that sessionApplyOneOp() ignores\n  ** the SQLITE_CHANGESET_DATA problem.  */\n  if( bRetry ){\n    assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );\n    rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n  }\n\n  /* If the bReplace flag is set, the change is an INSERT that has not\n  ** been performed because the database already contains a row with the\n  ** specified primary key and the conflict handler returned\n  ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row\n  ** before reattempting the INSERT.  */\n  else if( bReplace ){\n    assert( pIter->op==SQLITE_INSERT );\n    rc = sqlite3_exec(db, \"SAVEPOINT replace_op\", 0, 0, 0);\n    if( rc==SQLITE_OK ){\n      rc = sessionBindRow(pIter, \n          sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete);\n      sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pApply->pDelete);\n      rc = sqlite3_reset(pApply->pDelete);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_exec(db, \"RELEASE replace_op\", 0, 0, 0);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Retry the changes accumulated in the pApply->constraints buffer.\n*/\nstatic int sessionRetryConstraints(\n  sqlite3 *db, \n  int bPatchset,\n  const char *zTab,\n  SessionApplyCtx *pApply,\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int rc = SQLITE_OK;\n\n  while( pApply->constraints.nBuf ){\n    sqlite3_changeset_iter *pIter2 = 0;\n    SessionBuffer cons = pApply->constraints;\n    memset(&pApply->constraints, 0, sizeof(SessionBuffer));\n\n    rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf);\n    if( rc==SQLITE_OK ){\n      int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);\n      int rc2;\n      pIter2->bPatchset = bPatchset;\n      pIter2->zTab = (char*)zTab;\n      pIter2->nCol = pApply->nCol;\n      pIter2->abPK = pApply->abPK;\n      sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);\n      pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;\n      if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);\n\n      while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){\n        rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);\n      }\n\n      rc2 = sqlite3changeset_finalize(pIter2);\n      if( rc==SQLITE_OK ) rc = rc2;\n    }\n    assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );\n\n    sqlite3_free(cons.aBuf);\n    if( rc!=SQLITE_OK ) break;\n    if( pApply->constraints.nBuf>=cons.nBuf ){\n      /* No progress was made on the last round. */\n      pApply->bDeferConstraints = 0;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Argument pIter is a changeset iterator that has been initialized, but\n** not yet passed to sqlite3changeset_next(). This function applies the \n** changeset to the main database attached to handle \"db\". The supplied\n** conflict handler callback is invoked to resolve any conflicts encountered\n** while applying the change.\n*/\nstatic int sessionChangesetApply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset to apply */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int schemaMismatch = 0;\n  int rc;                         /* Return code */\n  const char *zTab = 0;           /* Name of current table */\n  int nTab = 0;                   /* Result of sqlite3Strlen30(zTab) */\n  SessionApplyCtx sApply;         /* changeset_apply() context object */\n  int bPatchset;\n\n  assert( xConflict!=0 );\n\n  pIter->in.bNoDiscard = 1;\n  memset(&sApply, 0, sizeof(sApply));\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  rc = sqlite3_exec(db, \"SAVEPOINT changeset_apply\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 1\", 0, 0, 0);\n  }\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){\n    int nCol;\n    int op;\n    const char *zNew;\n    \n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, 0);\n\n    if( zTab==0 || sqlite3_strnicmp(zNew, zTab, nTab+1) ){\n      u8 *abPK;\n\n      rc = sessionRetryConstraints(\n          db, pIter->bPatchset, zTab, &sApply, xConflict, pCtx\n      );\n      if( rc!=SQLITE_OK ) break;\n\n      sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n      sqlite3_finalize(sApply.pDelete);\n      sqlite3_finalize(sApply.pUpdate); \n      sqlite3_finalize(sApply.pInsert);\n      sqlite3_finalize(sApply.pSelect);\n      memset(&sApply, 0, sizeof(sApply));\n      sApply.db = db;\n      sApply.bDeferConstraints = 1;\n\n      /* If an xFilter() callback was specified, invoke it now. If the \n      ** xFilter callback returns zero, skip this table. If it returns\n      ** non-zero, proceed. */\n      schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew)));\n      if( schemaMismatch ){\n        zTab = sqlite3_mprintf(\"%s\", zNew);\n        if( zTab==0 ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        nTab = (int)strlen(zTab);\n        sApply.azCol = (const char **)zTab;\n      }else{\n        int nMinCol = 0;\n        int i;\n\n        sqlite3changeset_pk(pIter, &abPK, 0);\n        rc = sessionTableInfo(\n            db, \"main\", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK\n        );\n        if( rc!=SQLITE_OK ) break;\n        for(i=0; i<sApply.nCol; i++){\n          if( sApply.abPK[i] ) nMinCol = i+1;\n        }\n  \n        if( sApply.nCol==0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): no such table: %s\", zTab\n          );\n        }\n        else if( sApply.nCol<nCol ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): table %s has %d columns, \"\n              \"expected %d or more\", \n              zTab, sApply.nCol, nCol\n          );\n        }\n        else if( nCol<nMinCol || memcmp(sApply.abPK, abPK, nCol)!=0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \"sqlite3changeset_apply(): \"\n              \"primary key mismatch for table %s\", zTab\n          );\n        }\n        else{\n          sApply.nCol = nCol;\n          if((rc = sessionSelectRow(db, zTab, &sApply))\n          || (rc = sessionUpdateRow(db, zTab, &sApply))\n          || (rc = sessionDeleteRow(db, zTab, &sApply))\n          || (rc = sessionInsertRow(db, zTab, &sApply))\n          ){\n            break;\n          }\n        }\n        nTab = sqlite3Strlen30(zTab);\n      }\n    }\n\n    /* If there is a schema mismatch on the current table, proceed to the\n    ** next change. A log message has already been issued. */\n    if( schemaMismatch ) continue;\n\n    rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);\n  }\n\n  bPatchset = pIter->bPatchset;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changeset_finalize(pIter);\n  }else{\n    sqlite3changeset_finalize(pIter);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sessionRetryConstraints(db, bPatchset, zTab, &sApply, xConflict, pCtx);\n  }\n\n  if( rc==SQLITE_OK ){\n    int nFk, notUsed;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_DEFERRED_FKS, &nFk, &notUsed, 0);\n    if( nFk!=0 ){\n      int res = SQLITE_CHANGESET_ABORT;\n      sqlite3_changeset_iter sIter;\n      memset(&sIter, 0, sizeof(sIter));\n      sIter.nCol = nFk;\n      res = xConflict(pCtx, SQLITE_CHANGESET_FOREIGN_KEY, &sIter);\n      if( res!=SQLITE_CHANGESET_OMIT ){\n        rc = SQLITE_CONSTRAINT;\n      }\n    }\n  }\n  sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 0\", 0, 0, 0);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n  }else{\n    sqlite3_exec(db, \"ROLLBACK TO changeset_apply\", 0, 0, 0);\n    sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n  }\n\n  sqlite3_finalize(sApply.pInsert);\n  sqlite3_finalize(sApply.pDelete);\n  sqlite3_finalize(sApply.pUpdate);\n  sqlite3_finalize(sApply.pSelect);\n  sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n  sqlite3_free((char*)sApply.constraints.aBuf);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Apply the changeset passed via pChangeset/nChangeset to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nint sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);\n  }\n  return rc;\n}\n\n/*\n** Apply the changeset passed via xInput/pIn to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nint sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);\n  }\n  return rc;\n}\n\n/*\n** sqlite3_changegroup handle.\n*/\nstruct sqlite3_changegroup {\n  int rc;                         /* Error code */\n  int bPatch;                     /* True to accumulate patchsets */\n  SessionTable *pList;            /* List of tables in current patch */\n};\n\n/*\n** This function is called to merge two changes to the same row together as\n** part of an sqlite3changeset_concat() operation. A new change object is\n** allocated and a pointer to it stored in *ppNew.\n*/\nstatic int sessionChangeMerge(\n  SessionTable *pTab,             /* Table structure */\n  int bPatchset,                  /* True for patchsets */\n  SessionChange *pExist,          /* Existing change */\n  int op2,                        /* Second change operation */\n  int bIndirect,                  /* True if second change is indirect */\n  u8 *aRec,                       /* Second change record */\n  int nRec,                       /* Number of bytes in aRec */\n  SessionChange **ppNew           /* OUT: Merged change */\n){\n  SessionChange *pNew = 0;\n\n  if( !pExist ){\n    pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);\n    if( !pNew ){\n      return SQLITE_NOMEM;\n    }\n    memset(pNew, 0, sizeof(SessionChange));\n    pNew->op = op2;\n    pNew->bIndirect = bIndirect;\n    pNew->nRecord = nRec;\n    pNew->aRecord = (u8*)&pNew[1];\n    memcpy(pNew->aRecord, aRec, nRec);\n  }else{\n    int op1 = pExist->op;\n\n    /* \n    **   op1=INSERT, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=INSERT, op2=UPDATE      ->      INSERT.\n    **   op1=INSERT, op2=DELETE      ->      (none)\n    **\n    **   op1=UPDATE, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=UPDATE, op2=UPDATE      ->      UPDATE.\n    **   op1=UPDATE, op2=DELETE      ->      DELETE.\n    **\n    **   op1=DELETE, op2=INSERT      ->      UPDATE.\n    **   op1=DELETE, op2=UPDATE      ->      Unsupported. Discard op2.\n    **   op1=DELETE, op2=DELETE      ->      Unsupported. Discard op2.\n    */   \n    if( (op1==SQLITE_INSERT && op2==SQLITE_INSERT)\n     || (op1==SQLITE_UPDATE && op2==SQLITE_INSERT)\n     || (op1==SQLITE_DELETE && op2==SQLITE_UPDATE)\n     || (op1==SQLITE_DELETE && op2==SQLITE_DELETE)\n    ){\n      pNew = pExist;\n    }else if( op1==SQLITE_INSERT && op2==SQLITE_DELETE ){\n      sqlite3_free(pExist);\n      assert( pNew==0 );\n    }else{\n      u8 *aExist = pExist->aRecord;\n      int nByte;\n      u8 *aCsr;\n\n      /* Allocate a new SessionChange object. Ensure that the aRecord[]\n      ** buffer of the new object is large enough to hold any record that\n      ** may be generated by combining the input records.  */\n      nByte = sizeof(SessionChange) + pExist->nRecord + nRec;\n      pNew = (SessionChange *)sqlite3_malloc(nByte);\n      if( !pNew ){\n        sqlite3_free(pExist);\n        return SQLITE_NOMEM;\n      }\n      memset(pNew, 0, sizeof(SessionChange));\n      pNew->bIndirect = (bIndirect && pExist->bIndirect);\n      aCsr = pNew->aRecord = (u8 *)&pNew[1];\n\n      if( op1==SQLITE_INSERT ){             /* INSERT + UPDATE */\n        u8 *a1 = aRec;\n        assert( op2==SQLITE_UPDATE );\n        pNew->op = SQLITE_INSERT;\n        if( bPatchset==0 ) sessionSkipRecord(&a1, pTab->nCol);\n        sessionMergeRecord(&aCsr, pTab->nCol, aExist, a1);\n      }else if( op1==SQLITE_DELETE ){       /* DELETE + INSERT */\n        assert( op2==SQLITE_INSERT );\n        pNew->op = SQLITE_UPDATE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){\n            sqlite3_free(pNew);\n            pNew = 0;\n          }\n        }\n      }else if( op2==SQLITE_UPDATE ){       /* UPDATE + UPDATE */\n        u8 *a1 = aExist;\n        u8 *a2 = aRec;\n        assert( op1==SQLITE_UPDATE );\n        if( bPatchset==0 ){\n          sessionSkipRecord(&a1, pTab->nCol);\n          sessionSkipRecord(&a2, pTab->nCol);\n        }\n        pNew->op = SQLITE_UPDATE;\n        if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aRec, aExist,a1,a2) ){\n          sqlite3_free(pNew);\n          pNew = 0;\n        }\n      }else{                                /* UPDATE + DELETE */\n        assert( op1==SQLITE_UPDATE && op2==SQLITE_DELETE );\n        pNew->op = SQLITE_DELETE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          sessionMergeRecord(&aCsr, pTab->nCol, aRec, aExist);\n        }\n      }\n\n      if( pNew ){\n        pNew->nRecord = (int)(aCsr - pNew->aRecord);\n      }\n      sqlite3_free(pExist);\n    }\n  }\n\n  *ppNew = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add all changes in the changeset traversed by the iterator passed as\n** the first argument to the changegroup hash tables.\n*/\nstatic int sessionChangesetToHash(\n  sqlite3_changeset_iter *pIter,   /* Iterator to read from */\n  sqlite3_changegroup *pGrp        /* Changegroup object to add changeset to */\n){\n  u8 *aRec;\n  int nRec;\n  int rc = SQLITE_OK;\n  SessionTable *pTab = 0;\n\n\n  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec) ){\n    const char *zNew;\n    int nCol;\n    int op;\n    int iHash;\n    int bIndirect;\n    SessionChange *pChange;\n    SessionChange *pExist = 0;\n    SessionChange **pp;\n\n    if( pGrp->pList==0 ){\n      pGrp->bPatch = pIter->bPatchset;\n    }else if( pIter->bPatchset!=pGrp->bPatch ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect);\n    if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){\n      /* Search the list for a matching table */\n      int nNew = (int)strlen(zNew);\n      u8 *abPK;\n\n      sqlite3changeset_pk(pIter, &abPK, 0);\n      for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){\n        if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break;\n      }\n      if( !pTab ){\n        SessionTable **ppTab;\n\n        pTab = sqlite3_malloc(sizeof(SessionTable) + nCol + nNew+1);\n        if( !pTab ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->nCol = nCol;\n        pTab->abPK = (u8*)&pTab[1];\n        memcpy(pTab->abPK, abPK, nCol);\n        pTab->zName = (char*)&pTab->abPK[nCol];\n        memcpy(pTab->zName, zNew, nNew+1);\n\n        /* The new object must be linked on to the end of the list, not\n        ** simply added to the start of it. This is to ensure that the\n        ** tables within the output of sqlite3changegroup_output() are in \n        ** the right order.  */\n        for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){\n        rc = SQLITE_SCHEMA;\n        break;\n      }\n    }\n\n    if( sessionGrowHash(pIter->bPatchset, pTab) ){\n      rc = SQLITE_NOMEM;\n      break;\n    }\n    iHash = sessionChangeHash(\n        pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange\n    );\n\n    /* Search for existing entry. If found, remove it from the hash table. \n    ** Code below may link it back in.\n    */\n    for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){\n      int bPkOnly1 = 0;\n      int bPkOnly2 = 0;\n      if( pIter->bPatchset ){\n        bPkOnly1 = (*pp)->op==SQLITE_DELETE;\n        bPkOnly2 = op==SQLITE_DELETE;\n      }\n      if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){\n        pExist = *pp;\n        *pp = (*pp)->pNext;\n        pTab->nEntry--;\n        break;\n      }\n    }\n\n    rc = sessionChangeMerge(pTab, \n        pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange\n    );\n    if( rc ) break;\n    if( pChange ){\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n      pTab->nEntry++;\n    }\n  }\n\n  if( rc==SQLITE_OK ) rc = pIter->rc;\n  return rc;\n}\n\n/*\n** Serialize a changeset (or patchset) based on all changesets (or patchsets)\n** added to the changegroup object passed as the first argument.\n**\n** If xOutput is not NULL, then the changeset/patchset is returned to the\n** user via one or more calls to xOutput, as with the other streaming\n** interfaces. \n**\n** Or, if xOutput is NULL, then (*ppOut) is populated with a pointer to a\n** buffer containing the output changeset before this function returns. In\n** this case (*pnOut) is set to the size of the output buffer in bytes. It\n** is the responsibility of the caller to free the output buffer using\n** sqlite3_free() when it is no longer required.\n**\n** If successful, SQLITE_OK is returned. Or, if an error occurs, an SQLite\n** error code. If an error occurs and xOutput is NULL, (*ppOut) and (*pnOut)\n** are both set to 0 before returning.\n*/\nstatic int sessionChangegroupOutput(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnOut,\n  void **ppOut\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  SessionTable *pTab;\n  assert( xOutput==0 || (ppOut==0 && pnOut==0) );\n\n  /* Create the serialized output changeset based on the contents of the\n  ** hash tables attached to the SessionTable objects in list p->pList. \n  */\n  for(pTab=pGrp->pList; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    int i;\n    if( pTab->nEntry==0 ) continue;\n\n    sessionAppendTableHdr(&buf, pGrp->bPatch, pTab, &rc);\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      for(p=pTab->apChange[i]; p; p=p->pNext){\n        sessionAppendByte(&buf, p->op, &rc);\n        sessionAppendByte(&buf, p->bIndirect, &rc);\n        sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);\n      }\n    }\n\n    if( rc==SQLITE_OK && xOutput && buf.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){\n      rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n      buf.nBuf = 0;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput ){\n      if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n    }else{\n      *ppOut = buf.aBuf;\n      *pnOut = buf.nBuf;\n      buf.aBuf = 0;\n    }\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Allocate a new, empty, sqlite3_changegroup.\n*/\nint sqlite3changegroup_new(sqlite3_changegroup **pp){\n  int rc = SQLITE_OK;             /* Return code */\n  sqlite3_changegroup *p;         /* New object */\n  p = (sqlite3_changegroup*)sqlite3_malloc(sizeof(sqlite3_changegroup));\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(p, 0, sizeof(sqlite3_changegroup));\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Add the changeset currently stored in buffer pData, size nData bytes,\n** to changeset-group p.\n*/\nint sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start(&pIter, nData, pData);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Obtain a buffer containing a changeset representing the concatenation\n** of all changesets added to the group so far.\n*/\nint sqlite3changegroup_output(\n    sqlite3_changegroup *pGrp,\n    int *pnData,\n    void **ppData\n){\n  return sessionChangegroupOutput(pGrp, 0, 0, pnData, ppData);\n}\n\n/*\n** Streaming versions of changegroup_add().\n*/\nint sqlite3changegroup_add_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Streaming versions of changegroup_output().\n*/\nint sqlite3changegroup_output_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData), \n  void *pOut\n){\n  return sessionChangegroupOutput(pGrp, xOutput, pOut, 0, 0);\n}\n\n/*\n** Delete a changegroup object.\n*/\nvoid sqlite3changegroup_delete(sqlite3_changegroup *pGrp){\n  if( pGrp ){\n    sessionDeleteTable(pGrp->pList);\n    sqlite3_free(pGrp);\n  }\n}\n\n/* \n** Combine two changesets together.\n*/\nint sqlite3changeset_concat(\n  int nLeft,                      /* Number of bytes in lhs input */\n  void *pLeft,                    /* Lhs input changeset */\n  int nRight                      /* Number of bytes in rhs input */,\n  void *pRight,                   /* Rhs input changeset */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: changeset (left <concat> right) */\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nLeft, pLeft);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nRight, pRight);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n/*\n** Streaming version of sqlite3changeset_concat().\n*/\nint sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputA, pInA);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputB, pInB);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/sqlite3session.h",
    "content": "\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"sqlite3.h\"\n\n/*\n** CAPI3REF: Session Object Handle\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nint sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nvoid sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nint sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nint sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n*/\nint sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nvoid sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nint sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session \n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nint sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nint sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nint sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n*/\nint sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nint sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nint sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nint sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nint sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nint sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n*/\nint sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nint sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nint sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nint sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nint sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nint sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n*/\nvoid sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset to a database. This function attempts to update the\n** \"main\" database attached to handle db with the changes found in the\n** changeset passed via the second and third arguments.\n**\n** The fourth argument (xFilter) passed to this function is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument to this function as the first. If the \"filter\n** callback\" returns zero, then no attempt is made to apply any changes to \n** the table. Otherwise, if the return value is non-zero or the xFilter\n** argument to this function is NULL, all changes related to the table are\n** attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by this function are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n*/\nint sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nint sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nint sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nint sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nint sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nint sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\n\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/session/test_session.c",
    "content": "\n#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_SESSION) \\\n && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n\n#include \"sqlite3session.h\"\n#include <assert.h>\n#include <string.h>\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\ntypedef struct TestSession TestSession;\nstruct TestSession {\n  sqlite3_session *pSession;\n  Tcl_Interp *interp;\n  Tcl_Obj *pFilterScript;\n};\n\ntypedef struct TestStreamInput TestStreamInput;\nstruct TestStreamInput {\n  int nStream;                    /* Maximum chunk size */\n  unsigned char *aData;           /* Pointer to buffer containing data */\n  int nData;                      /* Size of buffer aData in bytes */\n  int iData;                      /* Bytes of data already read by sessions */\n};\n\n/*\n** Extract an sqlite3* db handle from the object passed as the second\n** argument. If successful, set *pDb to point to the db handle and return\n** TCL_OK. Otherwise, return TCL_ERROR.\n*/\nstatic int dbHandleFromObj(Tcl_Interp *interp, Tcl_Obj *pObj, sqlite3 **pDb){\n  Tcl_CmdInfo info;\n  if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(pObj), &info) ){\n    Tcl_AppendResult(interp, \"no such handle: \", Tcl_GetString(pObj), 0);\n    return TCL_ERROR;\n  }\n\n  *pDb = *(sqlite3 **)info.objClientData;\n  return TCL_OK;\n}\n\n/*************************************************************************\n** The following code is copied byte-for-byte from the sessions module\n** documentation.  It is used by some of the sessions modules tests to\n** ensure that the example in the documentation does actually work.\n*/ \n/*\n** Argument zSql points to a buffer containing an SQL script to execute \n** against the database handle passed as the first argument. As well as\n** executing the SQL script, this function collects a changeset recording\n** all changes made to the \"main\" database file. Assuming no error occurs,\n** output variables (*ppChangeset) and (*pnChangeset) are set to point\n** to a buffer containing the changeset and the size of the changeset in\n** bytes before returning SQLITE_OK. In this case it is the responsibility\n** of the caller to eventually free the changeset blob by passing it to\n** the sqlite3_free function.\n**\n** Or, if an error does occur, return an SQLite error code. The final\n** value of (*pChangeset) and (*pnChangeset) are undefined in this case.\n*/\nint sql_exec_changeset(\n  sqlite3 *db,                  /* Database handle */\n  const char *zSql,             /* SQL script to execute */\n  int *pnChangeset,             /* OUT: Size of changeset blob in bytes */\n  void **ppChangeset            /* OUT: Pointer to changeset blob */\n){\n  sqlite3_session *pSession = 0;\n  int rc;\n\n  /* Create a new session object */\n  rc = sqlite3session_create(db, \"main\", &pSession);\n\n  /* Configure the session object to record changes to all tables */\n  if( rc==SQLITE_OK ) rc = sqlite3session_attach(pSession, NULL);\n\n  /* Execute the SQL script */\n  if( rc==SQLITE_OK ) rc = sqlite3_exec(db, zSql, 0, 0, 0);\n\n  /* Collect the changeset */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3session_changeset(pSession, pnChangeset, ppChangeset);\n  }\n\n  /* Delete the session object */\n  sqlite3session_delete(pSession);\n\n  return rc;\n}\n/************************************************************************/\n\n/*\n** Tclcmd: sql_exec_changeset DB SQL\n*/\nstatic int SQLITE_TCLAPI test_sql_exec_changeset(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zSql;\n  sqlite3 *db;\n  void *pChangeset;\n  int nChangeset;\n  int rc;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB SQL\");\n    return TCL_ERROR;\n  }\n  if( dbHandleFromObj(interp, objv[1], &db) ) return TCL_ERROR;\n  zSql = (const char*)Tcl_GetString(objv[2]);\n\n  rc = sql_exec_changeset(db, zSql, &nChangeset, &pChangeset);\n  if( rc!=SQLITE_OK ){\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, \"error in sql_exec_changeset()\", 0);\n    return TCL_ERROR;\n  }\n\n  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pChangeset, nChangeset));\n  sqlite3_free(pChangeset);\n  return TCL_OK;\n}\n\n\n\n#define SESSION_STREAM_TCL_VAR \"sqlite3session_streams\"\n\n/*\n** Attempt to find the global variable zVar within interpreter interp\n** and extract an integer value from it. Return this value.\n**\n** If the named variable cannot be found, or if it cannot be interpreted\n** as a integer, return 0.\n*/\nstatic int test_tcl_integer(Tcl_Interp *interp, const char *zVar){\n  Tcl_Obj *pObj;\n  int iVal = 0;\n  pObj = Tcl_ObjGetVar2(interp, Tcl_NewStringObj(zVar, -1), 0, TCL_GLOBAL_ONLY);\n  if( pObj ) Tcl_GetIntFromObj(0, pObj, &iVal);\n  return iVal;\n}\n\nstatic int test_session_error(Tcl_Interp *interp, int rc, char *zErr){\n  extern const char *sqlite3ErrName(int);\n  Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n  if( zErr ){\n    Tcl_AppendResult(interp, \" - \", zErr, 0);\n    sqlite3_free(zErr);\n  }\n  return TCL_ERROR;\n}\n\nstatic int test_table_filter(void *pCtx, const char *zTbl){\n  TestSession *p = (TestSession*)pCtx;\n  Tcl_Obj *pEval;\n  int rc;\n  int bRes = 0;\n\n  pEval = Tcl_DuplicateObj(p->pFilterScript);\n  Tcl_IncrRefCount(pEval);\n  rc = Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zTbl, -1));\n  if( rc==TCL_OK ){\n    rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);\n  }\n  if( rc==TCL_OK ){\n    rc = Tcl_GetBooleanFromObj(p->interp, Tcl_GetObjResult(p->interp), &bRes);\n  }\n  if( rc!=TCL_OK ){\n    /* printf(\"error: %s\\n\", Tcl_GetStringResult(p->interp)); */\n    Tcl_BackgroundError(p->interp);\n  }\n  Tcl_DecrRefCount(pEval);\n\n  return bRes;\n}\n\nstruct TestSessionsBlob {\n  void *p;\n  int n;\n};\ntypedef struct TestSessionsBlob TestSessionsBlob;\n\nstatic int testStreamOutput(\n  void *pCtx,\n  const void *pData,\n  int nData\n){\n  TestSessionsBlob *pBlob = (TestSessionsBlob*)pCtx;\n  char *pNew;\n\n  assert( nData>0 );\n  pNew = (char*)sqlite3_realloc(pBlob->p, pBlob->n + nData);\n  if( pNew==0 ){\n    return SQLITE_NOMEM;\n  }\n  pBlob->p = (void*)pNew;\n  memcpy(&pNew[pBlob->n], pData, nData);\n  pBlob->n += nData;\n  return SQLITE_OK;\n}\n\n/*\n** Tclcmd:  $session attach TABLE\n**          $session changeset\n**          $session delete\n**          $session enable BOOL\n**          $session indirect INTEGER\n**          $session patchset\n**          $session table_filter SCRIPT\n*/\nstatic int SQLITE_TCLAPI test_session_cmd(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  TestSession *p = (TestSession*)clientData;\n  sqlite3_session *pSession = p->pSession;\n  struct SessionSubcmd {\n    const char *zSub;\n    int nArg;\n    const char *zMsg;\n    int iSub;\n  } aSub[] = {\n    { \"attach\",       1, \"TABLE\",      }, /* 0 */\n    { \"changeset\",    0, \"\",           }, /* 1 */\n    { \"delete\",       0, \"\",           }, /* 2 */\n    { \"enable\",       1, \"BOOL\",       }, /* 3 */\n    { \"indirect\",     1, \"BOOL\",       }, /* 4 */\n    { \"isempty\",      0, \"\",           }, /* 5 */\n    { \"table_filter\", 1, \"SCRIPT\",     }, /* 6 */\n    { \"patchset\",     0, \"\",           }, /* 7 */\n    { \"diff\",         2, \"FROMDB TBL\", }, /* 8 */\n    { 0 }\n  };\n  int iSub;\n  int rc;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUBCOMMAND ...\");\n    return TCL_ERROR;\n  }\n  rc = Tcl_GetIndexFromObjStruct(interp, \n      objv[1], aSub, sizeof(aSub[0]), \"sub-command\", 0, &iSub\n  );\n  if( rc!=TCL_OK ) return rc;\n  if( objc!=2+aSub[iSub].nArg ){\n    Tcl_WrongNumArgs(interp, 2, objv, aSub[iSub].zMsg);\n    return TCL_ERROR;\n  }\n\n  switch( iSub ){\n    case 0: {      /* attach */\n      char *zArg = Tcl_GetString(objv[2]);\n      if( zArg[0]=='*' && zArg[1]=='\\0' ) zArg = 0;\n      rc = sqlite3session_attach(pSession, zArg);\n      if( rc!=SQLITE_OK ){\n        return test_session_error(interp, rc, 0);\n      }\n      break;\n    }\n\n    case 7:        /* patchset */\n    case 1: {      /* changeset */\n      TestSessionsBlob o = {0, 0};\n      if( test_tcl_integer(interp, SESSION_STREAM_TCL_VAR) ){\n        void *pCtx = (void*)&o;\n        if( iSub==7 ){\n          rc = sqlite3session_patchset_strm(pSession, testStreamOutput, pCtx);\n        }else{\n          rc = sqlite3session_changeset_strm(pSession, testStreamOutput, pCtx);\n        }\n      }else{\n        if( iSub==7 ){\n          rc = sqlite3session_patchset(pSession, &o.n, &o.p);\n        }else{\n          rc = sqlite3session_changeset(pSession, &o.n, &o.p);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(o.p, o.n)); \n      }\n      sqlite3_free(o.p);\n      if( rc!=SQLITE_OK ){\n        return test_session_error(interp, rc, 0);\n      }\n      break;\n    }\n\n    case 2:        /* delete */\n      Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));\n      break;\n\n    case 3: {      /* enable */\n      int val;\n      if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;\n      val = sqlite3session_enable(pSession, val);\n      Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));\n      break;\n    }\n\n    case 4: {      /* indirect */\n      int val;\n      if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;\n      val = sqlite3session_indirect(pSession, val);\n      Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));\n      break;\n    }\n\n    case 5: {      /* isempty */\n      int val;\n      val = sqlite3session_isempty(pSession);\n      Tcl_SetObjResult(interp, Tcl_NewBooleanObj(val));\n      break;\n    }\n            \n    case 6: {      /* table_filter */\n      if( p->pFilterScript ) Tcl_DecrRefCount(p->pFilterScript);\n      p->interp = interp;\n      p->pFilterScript = Tcl_DuplicateObj(objv[2]);\n      Tcl_IncrRefCount(p->pFilterScript);\n      sqlite3session_table_filter(pSession, test_table_filter, clientData);\n      break;\n    }\n\n    case 8: {      /* diff */\n      char *zErr = 0;\n      rc = sqlite3session_diff(pSession, \n          Tcl_GetString(objv[2]),\n          Tcl_GetString(objv[3]),\n          &zErr\n      );\n      assert( rc!=SQLITE_OK || zErr==0 );\n      if( rc ){\n        return test_session_error(interp, rc, zErr);\n      }\n      break;\n    }\n  }\n\n  return TCL_OK;\n}\n\nstatic void SQLITE_TCLAPI test_session_del(void *clientData){\n  TestSession *p = (TestSession*)clientData;\n  if( p->pFilterScript ) Tcl_DecrRefCount(p->pFilterScript);\n  sqlite3session_delete(p->pSession);\n  ckfree((char*)p);\n}\n\n/*\n** Tclcmd:  sqlite3session CMD DB-HANDLE DB-NAME\n*/\nstatic int SQLITE_TCLAPI test_sqlite3session(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  Tcl_CmdInfo info;\n  int rc;                         /* sqlite3session_create() return code */\n  TestSession *p;                 /* New wrapper object */\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"CMD DB-HANDLE DB-NAME\");\n    return TCL_ERROR;\n  }\n\n  if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[2]), &info) ){\n    Tcl_AppendResult(interp, \"no such handle: \", Tcl_GetString(objv[2]), 0);\n    return TCL_ERROR;\n  }\n  db = *(sqlite3 **)info.objClientData;\n\n  p = (TestSession*)ckalloc(sizeof(TestSession));\n  memset(p, 0, sizeof(TestSession));\n  rc = sqlite3session_create(db, Tcl_GetString(objv[3]), &p->pSession);\n  if( rc!=SQLITE_OK ){\n    ckfree((char*)p);\n    return test_session_error(interp, rc, 0);\n  }\n\n  Tcl_CreateObjCommand(\n      interp, Tcl_GetString(objv[1]), test_session_cmd, (ClientData)p,\n      test_session_del\n  );\n  Tcl_SetObjResult(interp, objv[1]);\n  return TCL_OK;\n}\n\nstatic void test_append_value(Tcl_Obj *pList, sqlite3_value *pVal){\n  if( pVal==0 ){\n    Tcl_ListObjAppendElement(0, pList, Tcl_NewObj());\n    Tcl_ListObjAppendElement(0, pList, Tcl_NewObj());\n  }else{\n    Tcl_Obj *pObj;\n    switch( sqlite3_value_type(pVal) ){\n      case SQLITE_NULL:\n        Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj(\"n\", 1));\n        pObj = Tcl_NewObj();\n        break;\n      case SQLITE_INTEGER:\n        Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj(\"i\", 1));\n        pObj = Tcl_NewWideIntObj(sqlite3_value_int64(pVal));\n        break;\n      case SQLITE_FLOAT:\n        Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj(\"f\", 1));\n        pObj = Tcl_NewDoubleObj(sqlite3_value_double(pVal));\n        break;\n      case SQLITE_TEXT: {\n        const char *z = (char*)sqlite3_value_blob(pVal);\n        int n = sqlite3_value_bytes(pVal);\n        Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj(\"t\", 1));\n        pObj = Tcl_NewStringObj(z, n);\n        break;\n      }\n      default:\n        assert( sqlite3_value_type(pVal)==SQLITE_BLOB );\n        Tcl_ListObjAppendElement(0, pList, Tcl_NewStringObj(\"b\", 1));\n        pObj = Tcl_NewByteArrayObj(\n            sqlite3_value_blob(pVal),\n            sqlite3_value_bytes(pVal)\n        );\n        break;\n    }\n    Tcl_ListObjAppendElement(0, pList, pObj);\n  }\n}\n\ntypedef struct TestConflictHandler TestConflictHandler;\nstruct TestConflictHandler {\n  Tcl_Interp *interp;\n  Tcl_Obj *pConflictScript;\n  Tcl_Obj *pFilterScript;\n};\n\nstatic int test_obj_eq_string(Tcl_Obj *p, const char *z){\n  int n;\n  int nObj;\n  char *zObj;\n\n  n = (int)strlen(z);\n  zObj = Tcl_GetStringFromObj(p, &nObj);\n\n  return (nObj==n && (n==0 || 0==memcmp(zObj, z, n)));\n}\n\nstatic int test_filter_handler(\n  void *pCtx,                     /* Pointer to TestConflictHandler structure */\n  const char *zTab                /* Table name */\n){\n  TestConflictHandler *p = (TestConflictHandler *)pCtx;\n  int res = 1;\n  Tcl_Obj *pEval;\n  Tcl_Interp *interp = p->interp;\n\n  pEval = Tcl_DuplicateObj(p->pFilterScript);\n  Tcl_IncrRefCount(pEval);\n\n  if( TCL_OK!=Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(zTab, -1))\n   || TCL_OK!=Tcl_EvalObjEx(interp, pEval, TCL_EVAL_GLOBAL) \n   || TCL_OK!=Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &res)\n  ){\n    Tcl_BackgroundError(interp);\n  }\n\n  Tcl_DecrRefCount(pEval);\n  return res;\n}  \n\nstatic int test_conflict_handler(\n  void *pCtx,                     /* Pointer to TestConflictHandler structure */\n  int eConf,                      /* DATA, MISSING, CONFLICT, CONSTRAINT */\n  sqlite3_changeset_iter *pIter   /* Handle describing change and conflict */\n){\n  TestConflictHandler *p = (TestConflictHandler *)pCtx;\n  Tcl_Obj *pEval;\n  Tcl_Interp *interp = p->interp;\n  int ret = 0;                    /* Return value */\n\n  int op;                         /* SQLITE_UPDATE, DELETE or INSERT */\n  const char *zTab;               /* Name of table conflict is on */\n  int nCol;                       /* Number of columns in table zTab */\n\n  pEval = Tcl_DuplicateObj(p->pConflictScript);\n  Tcl_IncrRefCount(pEval);\n\n  sqlite3changeset_op(pIter, &zTab, &nCol, &op, 0);\n\n  if( eConf==SQLITE_CHANGESET_FOREIGN_KEY ){\n    int nFk;\n    sqlite3changeset_fk_conflicts(pIter, &nFk);\n    Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(\"FOREIGN_KEY\", -1));\n    Tcl_ListObjAppendElement(0, pEval, Tcl_NewIntObj(nFk));\n  }else{\n\n    /* Append the operation type. */\n    Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(\n        op==SQLITE_INSERT ? \"INSERT\" :\n        op==SQLITE_UPDATE ? \"UPDATE\" : \n        \"DELETE\", -1\n    ));\n  \n    /* Append the table name. */\n    Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(zTab, -1));\n  \n    /* Append the conflict type. */\n    switch( eConf ){\n      case SQLITE_CHANGESET_DATA:\n        Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj(\"DATA\",-1));\n        break;\n      case SQLITE_CHANGESET_NOTFOUND:\n        Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj(\"NOTFOUND\",-1));\n        break;\n      case SQLITE_CHANGESET_CONFLICT:\n        Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj(\"CONFLICT\",-1));\n        break;\n      case SQLITE_CHANGESET_CONSTRAINT:\n        Tcl_ListObjAppendElement(interp, pEval,Tcl_NewStringObj(\"CONSTRAINT\",-1));\n        break;\n    }\n  \n    /* If this is not an INSERT, append the old row */\n    if( op!=SQLITE_INSERT ){\n      int i;\n      Tcl_Obj *pOld = Tcl_NewObj();\n      for(i=0; i<nCol; i++){\n        sqlite3_value *pVal;\n        sqlite3changeset_old(pIter, i, &pVal);\n        test_append_value(pOld, pVal);\n      }\n      Tcl_ListObjAppendElement(0, pEval, pOld);\n    }\n\n    /* If this is not a DELETE, append the new row */\n    if( op!=SQLITE_DELETE ){\n      int i;\n      Tcl_Obj *pNew = Tcl_NewObj();\n      for(i=0; i<nCol; i++){\n        sqlite3_value *pVal;\n        sqlite3changeset_new(pIter, i, &pVal);\n        test_append_value(pNew, pVal);\n      }\n      Tcl_ListObjAppendElement(0, pEval, pNew);\n    }\n\n    /* If this is a CHANGESET_DATA or CHANGESET_CONFLICT conflict, append\n     ** the conflicting row.  */\n    if( eConf==SQLITE_CHANGESET_DATA || eConf==SQLITE_CHANGESET_CONFLICT ){\n      int i;\n      Tcl_Obj *pConflict = Tcl_NewObj();\n      for(i=0; i<nCol; i++){\n        int rc;\n        sqlite3_value *pVal;\n        rc = sqlite3changeset_conflict(pIter, i, &pVal);\n        assert( rc==SQLITE_OK );\n        test_append_value(pConflict, pVal);\n      }\n      Tcl_ListObjAppendElement(0, pEval, pConflict);\n    }\n\n    /***********************************************************************\n     ** This block is purely for testing some error conditions.\n     */\n    if( eConf==SQLITE_CHANGESET_CONSTRAINT \n     || eConf==SQLITE_CHANGESET_NOTFOUND \n    ){\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_conflict(pIter, 0, &pVal);\n      assert( rc==SQLITE_MISUSE );\n    }else{\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_conflict(pIter, -1, &pVal);\n      assert( rc==SQLITE_RANGE );\n      rc = sqlite3changeset_conflict(pIter, nCol, &pVal);\n      assert( rc==SQLITE_RANGE );\n    }\n    if( op==SQLITE_DELETE ){\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_new(pIter, 0, &pVal);\n      assert( rc==SQLITE_MISUSE );\n    }else{\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_new(pIter, -1, &pVal);\n      assert( rc==SQLITE_RANGE );\n      rc = sqlite3changeset_new(pIter, nCol, &pVal);\n      assert( rc==SQLITE_RANGE );\n    }\n    if( op==SQLITE_INSERT ){\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_old(pIter, 0, &pVal);\n      assert( rc==SQLITE_MISUSE );\n    }else{\n      sqlite3_value *pVal;\n      int rc = sqlite3changeset_old(pIter, -1, &pVal);\n      assert( rc==SQLITE_RANGE );\n      rc = sqlite3changeset_old(pIter, nCol, &pVal);\n      assert( rc==SQLITE_RANGE );\n    }\n    if( eConf!=SQLITE_CHANGESET_FOREIGN_KEY ){\n      /* eConf!=FOREIGN_KEY is always true at this point. The condition is \n      ** just there to make it clearer what is being tested.  */\n      int nDummy;\n      int rc = sqlite3changeset_fk_conflicts(pIter, &nDummy);\n      assert( rc==SQLITE_MISUSE );\n    }\n    /* End of testing block\n    ***********************************************************************/\n  }\n\n  if( TCL_OK!=Tcl_EvalObjEx(interp, pEval, TCL_EVAL_GLOBAL) ){\n    Tcl_BackgroundError(interp);\n  }else{\n    Tcl_Obj *pRes = Tcl_GetObjResult(interp);\n    if( test_obj_eq_string(pRes, \"OMIT\") || test_obj_eq_string(pRes, \"\") ){\n      ret = SQLITE_CHANGESET_OMIT;\n    }else if( test_obj_eq_string(pRes, \"REPLACE\") ){\n      ret = SQLITE_CHANGESET_REPLACE;\n    }else if( test_obj_eq_string(pRes, \"ABORT\") ){\n      ret = SQLITE_CHANGESET_ABORT;\n    }else{\n      Tcl_GetIntFromObj(0, pRes, &ret);\n    }\n  }\n\n  Tcl_DecrRefCount(pEval);\n  return ret;\n}\n\n/*\n** The conflict handler used by sqlite3changeset_apply_replace_all(). \n** This conflict handler calls sqlite3_value_text16() on all available\n** sqlite3_value objects and then returns CHANGESET_REPLACE, or \n** CHANGESET_OMIT if REPLACE is not applicable. This is used to test the\n** effect of a malloc failure within an sqlite3_value_xxx() function\n** invoked by a conflict-handler callback.\n*/\nstatic int replace_handler(\n  void *pCtx,                     /* Pointer to TestConflictHandler structure */\n  int eConf,                      /* DATA, MISSING, CONFLICT, CONSTRAINT */\n  sqlite3_changeset_iter *pIter   /* Handle describing change and conflict */\n){\n  int op;                         /* SQLITE_UPDATE, DELETE or INSERT */\n  const char *zTab;               /* Name of table conflict is on */\n  int nCol;                       /* Number of columns in table zTab */\n  int i;\n  int x = 0;\n\n  sqlite3changeset_op(pIter, &zTab, &nCol, &op, 0);\n\n  if( op!=SQLITE_INSERT ){\n    for(i=0; i<nCol; i++){\n      sqlite3_value *pVal;\n      sqlite3changeset_old(pIter, i, &pVal);\n      sqlite3_value_text16(pVal);\n      x++;\n    }\n  }\n\n  if( op!=SQLITE_DELETE ){\n    for(i=0; i<nCol; i++){\n      sqlite3_value *pVal;\n      sqlite3changeset_new(pIter, i, &pVal);\n      sqlite3_value_text16(pVal);\n      x++;\n    }\n  }\n\n  if( eConf==SQLITE_CHANGESET_DATA ){\n    return SQLITE_CHANGESET_REPLACE;\n  }\n  return SQLITE_CHANGESET_OMIT;\n}\n\nstatic int testStreamInput(\n  void *pCtx,                     /* Context pointer */\n  void *pData,                    /* Buffer to populate */\n  int *pnData                     /* IN/OUT: Bytes requested/supplied */\n){\n  TestStreamInput *p = (TestStreamInput*)pCtx;\n  int nReq = *pnData;             /* Bytes of data requested */\n  int nRem = p->nData - p->iData; /* Bytes of data available */\n  int nRet = p->nStream;          /* Bytes actually returned */\n\n  /* Allocate and free some space. There is no point to this, other than\n  ** that it allows the regular OOM fault-injection tests to cause an error\n  ** in this function.  */\n  void *pAlloc = sqlite3_malloc(10);\n  if( pAlloc==0 ) return SQLITE_NOMEM;\n  sqlite3_free(pAlloc);\n\n  if( nRet>nReq ) nRet = nReq;\n  if( nRet>nRem ) nRet = nRem;\n\n  assert( nRet>=0 );\n  if( nRet>0 ){\n    memcpy(pData, &p->aData[p->iData], nRet);\n    p->iData += nRet;\n  }\n\n  *pnData = nRet;\n  return SQLITE_OK;\n}\n\n\n/*\n** sqlite3changeset_apply DB CHANGESET CONFLICT-SCRIPT ?FILTER-SCRIPT?\n*/\nstatic int SQLITE_TCLAPI test_sqlite3changeset_apply(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;                    /* Database handle */\n  Tcl_CmdInfo info;               /* Database Tcl command (objv[1]) info */\n  int rc;                         /* Return code from changeset_invert() */\n  void *pChangeset;               /* Buffer containing changeset */\n  int nChangeset;                 /* Size of buffer aChangeset in bytes */\n  TestConflictHandler ctx;\n  TestStreamInput sStr;\n\n  memset(&sStr, 0, sizeof(sStr));\n  sStr.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);\n\n  if( objc!=4 && objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \n        \"DB CHANGESET CONFLICT-SCRIPT ?FILTER-SCRIPT?\"\n    );\n    return TCL_ERROR;\n  }\n  if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) ){\n    Tcl_AppendResult(interp, \"no such handle: \", Tcl_GetString(objv[2]), 0);\n    return TCL_ERROR;\n  }\n  db = *(sqlite3 **)info.objClientData;\n  pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[2], &nChangeset);\n  ctx.pConflictScript = objv[3];\n  ctx.pFilterScript = objc==5 ? objv[4] : 0;\n  ctx.interp = interp;\n\n  if( sStr.nStream==0 ){\n    rc = sqlite3changeset_apply(db, nChangeset, pChangeset, \n        (objc==5) ? test_filter_handler : 0, test_conflict_handler, (void *)&ctx\n    );\n  }else{\n    sStr.aData = (unsigned char*)pChangeset;\n    sStr.nData = nChangeset;\n    rc = sqlite3changeset_apply_strm(db, testStreamInput, (void*)&sStr,\n        (objc==5) ? test_filter_handler : 0, test_conflict_handler, (void *)&ctx\n    );\n  }\n\n  if( rc!=SQLITE_OK ){\n    return test_session_error(interp, rc, 0);\n  }\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n** sqlite3changeset_apply_replace_all DB CHANGESET \n*/\nstatic int SQLITE_TCLAPI test_sqlite3changeset_apply_replace_all(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;                    /* Database handle */\n  Tcl_CmdInfo info;               /* Database Tcl command (objv[1]) info */\n  int rc;                         /* Return code from changeset_invert() */\n  void *pChangeset;               /* Buffer containing changeset */\n  int nChangeset;                 /* Size of buffer aChangeset in bytes */\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB CHANGESET\");\n    return TCL_ERROR;\n  }\n  if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &info) ){\n    Tcl_AppendResult(interp, \"no such handle: \", Tcl_GetString(objv[2]), 0);\n    return TCL_ERROR;\n  }\n  db = *(sqlite3 **)info.objClientData;\n  pChangeset = (void *)Tcl_GetByteArrayFromObj(objv[2], &nChangeset);\n\n  rc = sqlite3changeset_apply(db, nChangeset, pChangeset, 0, replace_handler,0);\n  if( rc!=SQLITE_OK ){\n    return test_session_error(interp, rc, 0);\n  }\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n\n/*\n** sqlite3changeset_invert CHANGESET\n*/\nstatic int SQLITE_TCLAPI test_sqlite3changeset_invert(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;                         /* Return code from changeset_invert() */\n  TestStreamInput sIn;            /* Input stream */\n  TestSessionsBlob sOut;          /* Output blob */\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"CHANGESET\");\n    return TCL_ERROR;\n  }\n\n  memset(&sIn, 0, sizeof(sIn));\n  memset(&sOut, 0, sizeof(sOut));\n  sIn.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);\n  sIn.aData = Tcl_GetByteArrayFromObj(objv[1], &sIn.nData);\n\n  if( sIn.nStream ){\n    rc = sqlite3changeset_invert_strm(\n        testStreamInput, (void*)&sIn, testStreamOutput, (void*)&sOut\n    );\n  }else{\n    rc = sqlite3changeset_invert(sIn.nData, sIn.aData, &sOut.n, &sOut.p);\n  }\n  if( rc!=SQLITE_OK ){\n    rc = test_session_error(interp, rc, 0);\n  }else{\n    Tcl_SetObjResult(interp,Tcl_NewByteArrayObj((unsigned char*)sOut.p,sOut.n));\n  }\n  sqlite3_free(sOut.p);\n  return rc;\n}\n\n/*\n** sqlite3changeset_concat LEFT RIGHT\n*/\nstatic int SQLITE_TCLAPI test_sqlite3changeset_concat(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;                         /* Return code from changeset_invert() */\n\n  TestStreamInput sLeft;          /* Input stream */\n  TestStreamInput sRight;         /* Input stream */\n  TestSessionsBlob sOut = {0,0};  /* Output blob */\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"LEFT RIGHT\");\n    return TCL_ERROR;\n  }\n\n  memset(&sLeft, 0, sizeof(sLeft));\n  memset(&sRight, 0, sizeof(sRight));\n  sLeft.aData = Tcl_GetByteArrayFromObj(objv[1], &sLeft.nData);\n  sRight.aData = Tcl_GetByteArrayFromObj(objv[2], &sRight.nData);\n  sLeft.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);\n  sRight.nStream = sLeft.nStream;\n\n  if( sLeft.nStream>0 ){\n    rc = sqlite3changeset_concat_strm(\n        testStreamInput, (void*)&sLeft,\n        testStreamInput, (void*)&sRight,\n        testStreamOutput, (void*)&sOut\n    );\n  }else{\n    rc = sqlite3changeset_concat(\n        sLeft.nData, sLeft.aData, sRight.nData, sRight.aData, &sOut.n, &sOut.p\n    );\n  }\n\n  if( rc!=SQLITE_OK ){\n    rc = test_session_error(interp, rc, 0);\n  }else{\n    Tcl_SetObjResult(interp,Tcl_NewByteArrayObj((unsigned char*)sOut.p,sOut.n));\n  }\n  sqlite3_free(sOut.p);\n  return rc;\n}\n\n/*\n** sqlite3session_foreach VARNAME CHANGESET SCRIPT\n*/\nstatic int SQLITE_TCLAPI test_sqlite3session_foreach(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void *pChangeset;\n  int nChangeset;\n  sqlite3_changeset_iter *pIter;\n  int rc;\n  Tcl_Obj *pVarname;\n  Tcl_Obj *pCS;\n  Tcl_Obj *pScript;\n  int isCheckNext = 0;\n\n  TestStreamInput sStr;\n  memset(&sStr, 0, sizeof(sStr));\n\n  if( objc>1 ){\n    char *zOpt = Tcl_GetString(objv[1]);\n    isCheckNext = (strcmp(zOpt, \"-next\")==0);\n  }\n  if( objc!=4+isCheckNext ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-next? VARNAME CHANGESET SCRIPT\");\n    return TCL_ERROR;\n  }\n\n  pVarname = objv[1+isCheckNext];\n  pCS = objv[2+isCheckNext];\n  pScript = objv[3+isCheckNext];\n\n  pChangeset = (void *)Tcl_GetByteArrayFromObj(pCS, &nChangeset);\n  sStr.nStream = test_tcl_integer(interp, SESSION_STREAM_TCL_VAR);\n  if( sStr.nStream==0 ){\n    rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);\n  }else{\n    sStr.aData = (unsigned char*)pChangeset;\n    sStr.nData = nChangeset;\n    rc = sqlite3changeset_start_strm(&pIter, testStreamInput, (void*)&sStr);\n  }\n  if( rc!=SQLITE_OK ){\n    return test_session_error(interp, rc, 0);\n  }\n\n  while( SQLITE_ROW==sqlite3changeset_next(pIter) ){\n    int nCol;                     /* Number of columns in table */\n    int nCol2;                    /* Number of columns in table */\n    int op;                       /* SQLITE_INSERT, UPDATE or DELETE */\n    const char *zTab;             /* Name of table change applies to */\n    Tcl_Obj *pVar;                /* Tcl value to set $VARNAME to */\n    Tcl_Obj *pOld;                /* Vector of old.* values */\n    Tcl_Obj *pNew;                /* Vector of new.* values */\n    int bIndirect;\n\n    char *zPK;\n    unsigned char *abPK;\n    int i;\n\n    /* Test that _fk_conflicts() returns SQLITE_MISUSE if called on this\n    ** iterator. */\n    int nDummy;\n    if( SQLITE_MISUSE!=sqlite3changeset_fk_conflicts(pIter, &nDummy) ){\n      sqlite3changeset_finalize(pIter);\n      return TCL_ERROR;\n    }\n\n    sqlite3changeset_op(pIter, &zTab, &nCol, &op, &bIndirect);\n    pVar = Tcl_NewObj();\n    Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(\n          op==SQLITE_INSERT ? \"INSERT\" :\n          op==SQLITE_UPDATE ? \"UPDATE\" : \n          \"DELETE\", -1\n    ));\n\n    Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(zTab, -1));\n    Tcl_ListObjAppendElement(0, pVar, Tcl_NewBooleanObj(bIndirect));\n\n    zPK = ckalloc(nCol+1);\n    memset(zPK, 0, nCol+1);\n    sqlite3changeset_pk(pIter, &abPK, &nCol2);\n    assert( nCol==nCol2 );\n    for(i=0; i<nCol; i++){\n      zPK[i] = (abPK[i] ? 'X' : '.');\n    }\n    Tcl_ListObjAppendElement(0, pVar, Tcl_NewStringObj(zPK, -1));\n    ckfree(zPK);\n\n    pOld = Tcl_NewObj();\n    if( op!=SQLITE_INSERT ){\n      for(i=0; i<nCol; i++){\n        sqlite3_value *pVal;\n        sqlite3changeset_old(pIter, i, &pVal);\n        test_append_value(pOld, pVal);\n      }\n    }\n    pNew = Tcl_NewObj();\n    if( op!=SQLITE_DELETE ){\n      for(i=0; i<nCol; i++){\n        sqlite3_value *pVal;\n        sqlite3changeset_new(pIter, i, &pVal);\n        test_append_value(pNew, pVal);\n      }\n    }\n    Tcl_ListObjAppendElement(0, pVar, pOld);\n    Tcl_ListObjAppendElement(0, pVar, pNew);\n\n    Tcl_ObjSetVar2(interp, pVarname, 0, pVar, 0);\n    rc = Tcl_EvalObjEx(interp, pScript, 0);\n    if( rc!=TCL_OK && rc!=TCL_CONTINUE ){\n      sqlite3changeset_finalize(pIter);\n      return rc==TCL_BREAK ? TCL_OK : rc;\n    }\n  }\n\n  if( isCheckNext ){\n    int rc2 = sqlite3changeset_next(pIter);\n    rc = sqlite3changeset_finalize(pIter);\n    assert( (rc2==SQLITE_DONE && rc==SQLITE_OK) || rc2==rc );\n  }else{\n    rc = sqlite3changeset_finalize(pIter);\n  }\n  if( rc!=SQLITE_OK ){\n    return test_session_error(interp, rc, 0);\n  }\n\n  return TCL_OK;\n}\n\nint TestSession_Init(Tcl_Interp *interp){\n  struct Cmd {\n    const char *zCmd;\n    Tcl_ObjCmdProc *xProc;\n  } aCmd[] = {\n    { \"sqlite3session\", test_sqlite3session },\n    { \"sqlite3session_foreach\", test_sqlite3session_foreach },\n    { \"sqlite3changeset_invert\", test_sqlite3changeset_invert },\n    { \"sqlite3changeset_concat\", test_sqlite3changeset_concat },\n    { \"sqlite3changeset_apply\", test_sqlite3changeset_apply },\n    { \"sqlite3changeset_apply_replace_all\", \n      test_sqlite3changeset_apply_replace_all },\n    { \"sql_exec_changeset\", test_sql_exec_changeset },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(struct Cmd); i++){\n    struct Cmd *p = &aCmd[i];\n    Tcl_CreateObjCommand(interp, p->zCmd, p->xProc, 0, 0);\n  }\n\n  return TCL_OK;\n}\n\n#endif /* SQLITE_TEST && SQLITE_SESSION && SQLITE_PREUPDATE_HOOK */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/userauth/sqlite3userauth.h",
    "content": "/*\n** 2014-09-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the application interface definitions for the\n** user-authentication extension feature.\n**\n** To compile with the user-authentication feature, append this file to\n** end of an SQLite amalgamation header file (\"sqlite3.h\"), then add\n** the SQLITE_USER_AUTHENTICATION compile-time option.  See the\n** user-auth.txt file in the same source directory as this file for\n** additional information.\n*/\n#ifdef SQLITE_USER_AUTHENTICATION\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** If a database contains the SQLITE_USER table, then the\n** sqlite3_user_authenticate() interface must be invoked with an\n** appropriate username and password prior to enable read and write\n** access to the database.\n**\n** Return SQLITE_OK on success or SQLITE_ERROR if the username/password\n** combination is incorrect or unknown.\n**\n** If the SQLITE_USER table is not present in the database file, then\n** this interface is a harmless no-op returnning SQLITE_OK.\n*/\nint sqlite3_user_authenticate(\n  sqlite3 *db,           /* The database connection */\n  const char *zUsername, /* Username */\n  const char *aPW,       /* Password or credentials */\n  int nPW                /* Number of bytes in aPW[] */\n);\n\n/*\n** The sqlite3_user_add() interface can be used (by an admin user only)\n** to create a new user.  When called on a no-authentication-required\n** database, this routine converts the database into an authentication-\n** required database, automatically makes the added user an\n** administrator, and logs in the current connection as that user.\n** The sqlite3_user_add() interface only works for the \"main\" database, not\n** for any ATTACH-ed databases.  Any call to sqlite3_user_add() by a\n** non-admin user results in an error.\n*/\nint sqlite3_user_add(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername, /* Username to be added */\n  const char *aPW,       /* Password or credentials */\n  int nPW,               /* Number of bytes in aPW[] */\n  int isAdmin            /* True to give new user admin privilege */\n);\n\n/*\n** The sqlite3_user_change() interface can be used to change a users\n** login credentials or admin privilege.  Any user can change their own\n** login credentials.  Only an admin user can change another users login\n** credentials or admin privilege setting.  No user may change their own \n** admin privilege setting.\n*/\nint sqlite3_user_change(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername, /* Username to change */\n  const char *aPW,       /* New password or credentials */\n  int nPW,               /* Number of bytes in aPW[] */\n  int isAdmin            /* Modified admin privilege for the user */\n);\n\n/*\n** The sqlite3_user_delete() interface can be used (by an admin user only)\n** to delete a user.  The currently logged-in user cannot be deleted,\n** which guarantees that there is always an admin user and hence that\n** the database cannot be converted into a no-authentication-required\n** database.\n*/\nint sqlite3_user_delete(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername  /* Username to remove */\n);\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* SQLITE_USER_AUTHENTICATION */\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/userauth/user-auth.txt",
    "content": "Activate the user authentication logic by including the\next/userauth/userauth.c source code file in the build and\nadding the -DSQLITE_USER_AUTHENTICATION compile-time option.\nThe ext/userauth/sqlite3userauth.h header file is available to\napplications to define the interface.\n\nWhen using the SQLite amalgamation, it is sufficient to append\nthe ext/userauth/userauth.c source file onto the end of the\namalgamation.\n\nThe following new APIs are available when user authentication is\nactivated:\n\n   int sqlite3_user_authenticate(\n     sqlite3 *db,           /* The database connection */\n     const char *zUsername, /* Username */\n     const char *aPW,       /* Password or credentials */\n     int nPW                /* Number of bytes in aPW[] */\n   );\n   \n   int sqlite3_user_add(\n     sqlite3 *db,           /* Database connection */\n     const char *zUsername, /* Username to be added */\n     const char *aPW,       /* Password or credentials */\n     int nPW,               /* Number of bytes in aPW[] */\n     int isAdmin            /* True to give new user admin privilege */\n   );\n   \n   int sqlite3_user_change(\n     sqlite3 *db,           /* Database connection */\n     const char *zUsername, /* Username to change */\n     const void *aPW,       /* Modified password or credentials */\n     int nPW,               /* Number of bytes in aPW[] */\n     int isAdmin            /* Modified admin privilege for the user */\n   );\n   \n   int sqlite3_user_delete(\n     sqlite3 *db,           /* Database connection */\n     const char *zUsername  /* Username to remove */\n   );\n\nWith this extension, a database can be marked as requiring authentication.\nBy default a database does not require authentication.\n\nThe sqlite3_open(), sqlite3_open16(), and sqlite3_open_v2() interfaces\nwork as before: they open a new database connection.  However, if the\ndatabase being opened requires authentication, then attempts to read\nor write from the database will fail with an SQLITE_AUTH error until \nafter sqlite3_user_authenticate() has been called successfully.  The \nsqlite3_user_authenticate() call will return SQLITE_OK if the \nauthentication credentials are accepted and SQLITE_ERROR if not.\n\nCalling sqlite3_user_authenticate() on a no-authentication-required\ndatabase connection is a harmless no-op.  \n\nIf the database is encrypted, then sqlite3_key_v2() must be called first,\nwith the correct decryption key, prior to invoking sqlite3_user_authenticate().\n\nTo recapitulate: When opening an existing unencrypted authentication-\nrequired database, the call sequence is:\n\n    sqlite3_open_v2()\n    sqlite3_user_authenticate();\n    /* Database is now usable */\n\nTo open an existing, encrypted, authentication-required database, the\ncall sequence is:\n\n    sqlite3_open_v2();\n    sqlite3_key_v2();\n    sqlite3_user_authenticate();\n    /* Database is now usable */\n\nWhen opening a no-authentication-required database, the database\nconnection is treated as if it was authenticated as an admin user.\n\nWhen ATTACH-ing new database files to a connection, each newly attached\ndatabase that is an authentication-required database is checked using\nthe same username and password as supplied to the main database.  If that\ncheck fails, then the ATTACH command fails with an SQLITE_AUTH error.\n\nThe sqlite3_user_add() interface can be used (by an admin user only)\nto create a new user.  When called on a no-authentication-required\ndatabase and when A is true, the sqlite3_user_add(D,U,P,N,A) routine\nconverts the database into an authentication-required database and\nlogs in the database connection D as user U with password P,N.\nTo convert a no-authentication-required database into an authentication-\nrequired database, the isAdmin parameter must be true.  If\nsqlite3_user_add(D,U,P,N,A) is called on a no-authentication-required\ndatabase and A is false, then the call fails with an SQLITE_AUTH error.\n\nAny call to sqlite3_user_add() by a non-admin user results in an error.\n\nHence, to create a new, unencrypted, authentication-required database,\nthe call sequence is:\n\n    sqlite3_open_v2();\n    sqlite3_user_add();\n\nAnd to create a new, encrypted, authentication-required database, the call\nsequence is:\n\n    sqlite3_open_v2();\n    sqlite3_key_v2();\n    sqlite3_user_add();\n\nThe sqlite3_user_delete() interface can be used (by an admin user only)\nto delete a user.  The currently logged-in user cannot be deleted,\nwhich guarantees that there is always an admin user and hence that\nthe database cannot be converted into a no-authentication-required\ndatabase.\n\nThe sqlite3_user_change() interface can be used to change a users\nlogin credentials or admin privilege.  Any user can change their own\npassword.  Only an admin user can change another users login\ncredentials or admin privilege setting.  No user may change their own \nadmin privilege setting.\n\nThe sqlite3_set_authorizer() callback is modified to take a 7th parameter\nwhich is the username of the currently logged in user, or NULL for a\nno-authentication-required database.\n\n-----------------------------------------------------------------------------\nImplementation notes:\n\nAn authentication-required database is identified by the presence of a\nnew table:\n\n    CREATE TABLE sqlite_user(\n      uname TEXT PRIMARY KEY,\n      isAdmin BOOLEAN,\n      pw BLOB\n    ) WITHOUT ROWID;\n\nThe sqlite_user table is inaccessible (unreadable and unwriteable) to\nnon-admin users and is read-only for admin users.  However, if the same\ndatabase file is opened by a version of SQLite that omits\nthe -DSQLITE_USER_AUTHENTICATION compile-time option, then the sqlite_user\ntable will be readable by anybody and writeable by anybody if\nthe \"PRAGMA writable_schema=ON\" statement is run first.\n\nThe sqlite_user.pw field is encoded by a built-in SQL function\n\"sqlite_crypt(X,Y)\".  The two arguments are both BLOBs.  The first argument\nis the plaintext password supplied to the sqlite3_user_authenticate()\ninterface.  The second argument is the sqlite_user.pw value and is supplied\nso that the function can extract the \"salt\" used by the password encoder.\nThe result of sqlite_crypt(X,Y) is another blob which is the value that\nends up being stored in sqlite_user.pw.  To verify credentials X supplied\nby the sqlite3_user_authenticate() routine, SQLite runs:\n\n    sqlite_user.pw == sqlite_crypt(X, sqlite_user.pw)\n\nTo compute an appropriate sqlite_user.pw value from a new or modified\npassword X, sqlite_crypt(X,NULL) is run.  A new random salt is selected\nwhen the second argument is NULL.\n\nThe built-in version of of sqlite_crypt() uses a simple Ceasar-cypher\nwhich prevents passwords from being revealed by searching the raw database\nfor ASCII text, but is otherwise trivally broken.  For better password\nsecurity, the database should be encrypted using the SQLite Encryption\nExtension or similar technology.  Or, the application can use the\nsqlite3_create_function() interface to provide an alternative\nimplementation of sqlite_crypt() that computes a stronger password hash,\nperhaps using a cryptographic hash function like SHA1.\n"
  },
  {
    "path": "v2/testdata/_sqlite/ext/userauth/userauth.c",
    "content": "/*\n** 2014-09-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the bulk of the implementation of the\n** user-authentication extension feature.  Some parts of the user-\n** authentication code are contained within the SQLite core (in the\n** src/ subdirectory of the main source code tree) but those parts\n** that could reasonable be separated out are moved into this file.\n**\n** To compile with the user-authentication feature, append this file to\n** end of an SQLite amalgamation, then add the SQLITE_USER_AUTHENTICATION\n** compile-time option.  See the user-auth.txt file in the same source\n** directory as this file for additional information.\n*/\n#ifdef SQLITE_USER_AUTHENTICATION\n#ifndef SQLITEINT_H\n# include \"sqliteInt.h\"\n#endif\n\n/*\n** Prepare an SQL statement for use by the user authentication logic.\n** Return a pointer to the prepared statement on success.  Return a\n** NULL pointer if there is an error of any kind.\n*/\nstatic sqlite3_stmt *sqlite3UserAuthPrepare(\n  sqlite3 *db,\n  const char *zFormat,\n  ...\n){\n  sqlite3_stmt *pStmt;\n  char *zSql;\n  int rc;\n  va_list ap;\n  int savedFlags = db->flags;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ) return 0;\n  db->flags |= SQLITE_WriteSchema;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  db->flags = savedFlags;\n  sqlite3_free(zSql);\n  if( rc ){\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n  }\n  return pStmt;\n}\n\n/*\n** Check to see if the sqlite_user table exists in database zDb.\n*/\nstatic int userTableExists(sqlite3 *db, const char *zDb){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  if( db->init.busy==0 ){\n    char *zErr = 0;\n    sqlite3Init(db, &zErr);\n    sqlite3DbFree(db, zErr);\n  }\n  rc = sqlite3FindTable(db, \"sqlite_user\", zDb)!=0;\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Check to see if database zDb has a \"sqlite_user\" table and if it does\n** whether that table can authenticate zUser with nPw,zPw.  Write one of\n** the UAUTH_* user authorization level codes into *peAuth and return a\n** result code.\n*/\nstatic int userAuthCheckLogin(\n  sqlite3 *db,               /* The database connection to check */\n  const char *zDb,           /* Name of specific database to check */\n  u8 *peAuth                 /* OUT: One of UAUTH_* constants */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  *peAuth = UAUTH_Unknown;\n  if( !userTableExists(db, \"main\") ){\n    *peAuth = UAUTH_Admin;  /* No sqlite_user table.  Everybody is admin. */\n    return SQLITE_OK;\n  }\n  if( db->auth.zAuthUser==0 ){\n    *peAuth = UAUTH_Fail;\n    return SQLITE_OK;\n  }\n  pStmt = sqlite3UserAuthPrepare(db,\n            \"SELECT pw=sqlite_crypt(?1,pw), isAdmin FROM \\\"%w\\\".sqlite_user\"\n            \" WHERE uname=?2\", zDb);\n  if( pStmt==0 ) return SQLITE_NOMEM;\n  sqlite3_bind_blob(pStmt, 1, db->auth.zAuthPW, db->auth.nAuthPW,SQLITE_STATIC);\n  sqlite3_bind_text(pStmt, 2, db->auth.zAuthUser, -1, SQLITE_STATIC);\n  rc = sqlite3_step(pStmt);\n  if( rc==SQLITE_ROW && sqlite3_column_int(pStmt,0) ){\n    *peAuth = sqlite3_column_int(pStmt, 1) + UAUTH_User;\n  }else{\n    *peAuth = UAUTH_Fail;\n  }\n  return sqlite3_finalize(pStmt);\n}\nint sqlite3UserAuthCheckLogin(\n  sqlite3 *db,               /* The database connection to check */\n  const char *zDb,           /* Name of specific database to check */\n  u8 *peAuth                 /* OUT: One of UAUTH_* constants */\n){\n  int rc;\n  u8 savedAuthLevel;\n  assert( zDb!=0 );\n  assert( peAuth!=0 );\n  savedAuthLevel = db->auth.authLevel;\n  db->auth.authLevel = UAUTH_Admin;\n  rc = userAuthCheckLogin(db, zDb, peAuth);\n  db->auth.authLevel = savedAuthLevel;\n  return rc;\n}\n\n/*\n** If the current authLevel is UAUTH_Unknown, the take actions to figure\n** out what authLevel should be\n*/\nvoid sqlite3UserAuthInit(sqlite3 *db){\n  if( db->auth.authLevel==UAUTH_Unknown ){\n    u8 authLevel = UAUTH_Fail;\n    sqlite3UserAuthCheckLogin(db, \"main\", &authLevel);\n    db->auth.authLevel = authLevel;\n    if( authLevel<UAUTH_Admin ) db->flags &= ~SQLITE_WriteSchema;\n  }\n}\n\n/*\n** Implementation of the sqlite_crypt(X,Y) function.\n**\n** If Y is NULL then generate a new hash for password X and return that\n** hash.  If Y is not null, then generate a hash for password X using the\n** same salt as the previous hash Y and return the new hash.\n*/\nvoid sqlite3CryptFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *zIn;\n  int nIn, ii;\n  u8 *zOut;\n  char zSalt[8];\n  zIn = sqlite3_value_blob(argv[0]);\n  nIn = sqlite3_value_bytes(argv[0]);\n  if( sqlite3_value_type(argv[1])==SQLITE_BLOB\n   && sqlite3_value_bytes(argv[1])==nIn+sizeof(zSalt)\n  ){\n    memcpy(zSalt, sqlite3_value_blob(argv[1]), sizeof(zSalt));\n  }else{\n    sqlite3_randomness(sizeof(zSalt), zSalt);\n  }\n  zOut = sqlite3_malloc( nIn+sizeof(zSalt) );\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    memcpy(zOut, zSalt, sizeof(zSalt));\n    for(ii=0; ii<nIn; ii++){\n      zOut[ii+sizeof(zSalt)] = zIn[ii]^zSalt[ii&0x7];\n    }\n    sqlite3_result_blob(context, zOut, nIn+sizeof(zSalt), sqlite3_free);\n  }\n}\n\n/*\n** If a database contains the SQLITE_USER table, then the\n** sqlite3_user_authenticate() interface must be invoked with an\n** appropriate username and password prior to enable read and write\n** access to the database.\n**\n** Return SQLITE_OK on success or SQLITE_ERROR if the username/password\n** combination is incorrect or unknown.\n**\n** If the SQLITE_USER table is not present in the database file, then\n** this interface is a harmless no-op returnning SQLITE_OK.\n*/\nint sqlite3_user_authenticate(\n  sqlite3 *db,           /* The database connection */\n  const char *zUsername, /* Username */\n  const char *zPW,       /* Password or credentials */\n  int nPW                /* Number of bytes in aPW[] */\n){\n  int rc;\n  u8 authLevel = UAUTH_Fail;\n  db->auth.authLevel = UAUTH_Unknown;\n  sqlite3_free(db->auth.zAuthUser);\n  sqlite3_free(db->auth.zAuthPW);\n  memset(&db->auth, 0, sizeof(db->auth));\n  db->auth.zAuthUser = sqlite3_mprintf(\"%s\", zUsername);\n  if( db->auth.zAuthUser==0 ) return SQLITE_NOMEM;\n  db->auth.zAuthPW = sqlite3_malloc( nPW+1 );\n  if( db->auth.zAuthPW==0 ) return SQLITE_NOMEM;\n  memcpy(db->auth.zAuthPW,zPW,nPW);\n  db->auth.nAuthPW = nPW;\n  rc = sqlite3UserAuthCheckLogin(db, \"main\", &authLevel);\n  db->auth.authLevel = authLevel;\n  sqlite3ExpirePreparedStatements(db);\n  if( rc ){\n    return rc;           /* OOM error, I/O error, etc. */\n  }\n  if( authLevel<UAUTH_User ){\n    return SQLITE_AUTH;  /* Incorrect username and/or password */\n  }\n  return SQLITE_OK;      /* Successful login */\n}\n\n/*\n** The sqlite3_user_add() interface can be used (by an admin user only)\n** to create a new user.  When called on a no-authentication-required\n** database, this routine converts the database into an authentication-\n** required database, automatically makes the added user an\n** administrator, and logs in the current connection as that user.\n** The sqlite3_user_add() interface only works for the \"main\" database, not\n** for any ATTACH-ed databases.  Any call to sqlite3_user_add() by a\n** non-admin user results in an error.\n*/\nint sqlite3_user_add(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername, /* Username to be added */\n  const char *aPW,       /* Password or credentials */\n  int nPW,               /* Number of bytes in aPW[] */\n  int isAdmin            /* True to give new user admin privilege */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  sqlite3UserAuthInit(db);\n  if( db->auth.authLevel<UAUTH_Admin ) return SQLITE_AUTH;\n  if( !userTableExists(db, \"main\") ){\n    if( !isAdmin ) return SQLITE_AUTH;\n    pStmt = sqlite3UserAuthPrepare(db, \n              \"CREATE TABLE sqlite_user(\\n\"\n              \"  uname TEXT PRIMARY KEY,\\n\"\n              \"  isAdmin BOOLEAN,\\n\"\n              \"  pw BLOB\\n\"\n              \") WITHOUT ROWID;\");\n    if( pStmt==0 ) return SQLITE_NOMEM;\n    sqlite3_step(pStmt);\n    rc = sqlite3_finalize(pStmt);\n    if( rc ) return rc;\n  }\n  pStmt = sqlite3UserAuthPrepare(db, \n            \"INSERT INTO sqlite_user(uname,isAdmin,pw)\"\n            \" VALUES(%Q,%d,sqlite_crypt(?1,NULL))\",\n            zUsername, isAdmin!=0);\n  if( pStmt==0 ) return SQLITE_NOMEM;\n  sqlite3_bind_blob(pStmt, 1, aPW, nPW, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  rc = sqlite3_finalize(pStmt);\n  if( rc ) return rc;\n  if( db->auth.zAuthUser==0 ){\n    assert( isAdmin!=0 );\n    sqlite3_user_authenticate(db, zUsername, aPW, nPW);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_user_change() interface can be used to change a users\n** login credentials or admin privilege.  Any user can change their own\n** login credentials.  Only an admin user can change another users login\n** credentials or admin privilege setting.  No user may change their own \n** admin privilege setting.\n*/\nint sqlite3_user_change(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername, /* Username to change */\n  const char *aPW,       /* Modified password or credentials */\n  int nPW,               /* Number of bytes in aPW[] */\n  int isAdmin            /* Modified admin privilege for the user */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  u8 authLevel;\n\n  authLevel = db->auth.authLevel;\n  if( authLevel<UAUTH_User ){\n    /* Must be logged in to make a change */\n    return SQLITE_AUTH;\n  }\n  if( strcmp(db->auth.zAuthUser, zUsername)!=0 ){\n    if( db->auth.authLevel<UAUTH_Admin ){\n      /* Must be an administrator to change a different user */\n      return SQLITE_AUTH;\n    }\n  }else if( isAdmin!=(authLevel==UAUTH_Admin) ){\n    /* Cannot change the isAdmin setting for self */\n    return SQLITE_AUTH;\n  }\n  db->auth.authLevel = UAUTH_Admin;\n  if( !userTableExists(db, \"main\") ){\n    /* This routine is a no-op if the user to be modified does not exist */\n  }else{\n    pStmt = sqlite3UserAuthPrepare(db,\n              \"UPDATE sqlite_user SET isAdmin=%d, pw=sqlite_crypt(?1,NULL)\"\n              \" WHERE uname=%Q\", isAdmin, zUsername);\n    if( pStmt==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_bind_blob(pStmt, 1, aPW, nPW, SQLITE_STATIC);\n      sqlite3_step(pStmt);\n      rc = sqlite3_finalize(pStmt);\n    }\n  }\n  db->auth.authLevel = authLevel;\n  return rc;\n}\n\n/*\n** The sqlite3_user_delete() interface can be used (by an admin user only)\n** to delete a user.  The currently logged-in user cannot be deleted,\n** which guarantees that there is always an admin user and hence that\n** the database cannot be converted into a no-authentication-required\n** database.\n*/\nint sqlite3_user_delete(\n  sqlite3 *db,           /* Database connection */\n  const char *zUsername  /* Username to remove */\n){\n  sqlite3_stmt *pStmt;\n  if( db->auth.authLevel<UAUTH_Admin ){\n    /* Must be an administrator to delete a user */\n    return SQLITE_AUTH;\n  }\n  if( strcmp(db->auth.zAuthUser, zUsername)==0 ){\n    /* Cannot delete self */\n    return SQLITE_AUTH;\n  }\n  if( !userTableExists(db, \"main\") ){\n    /* This routine is a no-op if the user to be deleted does not exist */\n    return SQLITE_OK;\n  }\n  pStmt = sqlite3UserAuthPrepare(db,\n              \"DELETE FROM sqlite_user WHERE uname=%Q\", zUsername);\n  if( pStmt==0 ) return SQLITE_NOMEM;\n  sqlite3_step(pStmt);\n  return sqlite3_finalize(pStmt);\n}\n\n#endif /* SQLITE_USER_AUTHENTICATION */\n"
  },
  {
    "path": "v2/testdata/_sqlite/sqlite-amalgamation-3210000/shell.c",
    "content": "/* DO NOT EDIT!\n** This file is automatically generated by the script in the canonical\n** SQLite source tree at tool/mkshellc.tcl.  That script combines source\n** code from various constituent source files of SQLite into this single\n** \"shell.c\" file used to implement the SQLite command-line shell.\n**\n** Most of the code found below comes from the \"src/shell.c.in\" file in\n** the canonical SQLite source tree.  That main file contains \"INCLUDE\"\n** lines that specify other files in the canonical source tree that are\n** inserted to getnerate this complete program source file.\n**\n** The code from multiple files is combined into this single \"shell.c\"\n** source file to help make the command-line program easier to compile.\n**\n** To modify this program, get a copy of the canonical SQLite source tree,\n** edit the src/shell.c.in\" and/or some of the other files that are included\n** by \"src/shell.c.in\", then rerun the tool/mkshellc.tcl script.\n*/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement the \"sqlite\" command line\n** utility for accessing SQLite databases.\n*/\n#if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)\n/* This needs to come before any includes for MSVC compiler */\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n/*\n** Warning pragmas copied from msvc.h in the core.\n*/\n#if defined(_MSC_VER)\n#pragma warning(disable : 4054)\n#pragma warning(disable : 4055)\n#pragma warning(disable : 4100)\n#pragma warning(disable : 4127)\n#pragma warning(disable : 4130)\n#pragma warning(disable : 4152)\n#pragma warning(disable : 4189)\n#pragma warning(disable : 4206)\n#pragma warning(disable : 4210)\n#pragma warning(disable : 4232)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 4306)\n#pragma warning(disable : 4702)\n#pragma warning(disable : 4706)\n#endif /* defined(_MSC_VER) */\n\n/*\n** No support for loadable extensions in VxWorks.\n*/\n#if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION\n# define SQLITE_OMIT_LOAD_EXTENSION 1\n#endif\n\n/*\n** Enable large-file support for fopen() and friends on unix.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n#include <assert.h>\n#include \"sqlite3.h\"\n#if SQLITE_USER_AUTHENTICATION\n# include \"sqlite3userauth.h\"\n#endif\n#include <ctype.h>\n#include <stdarg.h>\n\n#if !defined(_WIN32) && !defined(WIN32)\n# include <signal.h>\n# if !defined(__RTP__) && !defined(_WRS_KERNEL)\n#  include <pwd.h>\n# endif\n# include <unistd.h>\n# include <sys/types.h>\n#endif\n\n#if HAVE_READLINE\n# include <readline/readline.h>\n# include <readline/history.h>\n#endif\n\n#if HAVE_EDITLINE\n# include <editline/readline.h>\n#endif\n\n#if HAVE_EDITLINE || HAVE_READLINE\n\n# define shell_add_history(X) add_history(X)\n# define shell_read_history(X) read_history(X)\n# define shell_write_history(X) write_history(X)\n# define shell_stifle_history(X) stifle_history(X)\n# define shell_readline(X) readline(X)\n\n#elif HAVE_LINENOISE\n\n# include \"linenoise.h\"\n# define shell_add_history(X) linenoiseHistoryAdd(X)\n# define shell_read_history(X) linenoiseHistoryLoad(X)\n# define shell_write_history(X) linenoiseHistorySave(X)\n# define shell_stifle_history(X) linenoiseHistorySetMaxLen(X)\n# define shell_readline(X) linenoise(X)\n\n#else\n\n# define shell_read_history(X)\n# define shell_write_history(X)\n# define shell_stifle_history(X)\n\n# define SHELL_USE_LOCAL_GETLINE 1\n#endif\n\n\n#if defined(_WIN32) || defined(WIN32)\n# include <io.h>\n# include <fcntl.h>\n# define isatty(h) _isatty(h)\n# ifndef access\n#  define access(f,m) _access((f),(m))\n# endif\n# undef popen\n# define popen _popen\n# undef pclose\n# define pclose _pclose\n#else\n /* Make sure isatty() has a prototype. */\n extern int isatty(int);\n\n# if !defined(__RTP__) && !defined(_WRS_KERNEL)\n  /* popen and pclose are not C89 functions and so are\n  ** sometimes omitted from the <stdio.h> header */\n   extern FILE *popen(const char*,const char*);\n   extern int pclose(FILE*);\n# else\n#  define SQLITE_OMIT_POPEN 1\n# endif\n#endif\n\n#if defined(_WIN32_WCE)\n/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()\n * thus we always assume that we have a console. That can be\n * overridden with the -batch command line option.\n */\n#define isatty(x) 1\n#endif\n\n/* ctype macros that work with signed characters */\n#define IsSpace(X)  isspace((unsigned char)X)\n#define IsDigit(X)  isdigit((unsigned char)X)\n#define ToLower(X)  (char)tolower((unsigned char)X)\n\n#if defined(_WIN32) || defined(WIN32)\n#include <windows.h>\n\n/* string conversion routines only needed on Win32 */\nextern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);\nextern char *sqlite3_win32_mbcs_to_utf8_v2(const char *, int);\nextern char *sqlite3_win32_utf8_to_mbcs_v2(const char *, int);\nextern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText);\n#endif\n\n/* On Windows, we normally run with output mode of TEXT so that \\n characters\n** are automatically translated into \\r\\n.  However, this behavior needs\n** to be disabled in some cases (ex: when generating CSV output and when\n** rendering quoted strings that contain \\n characters).  The following\n** routines take care of that.\n*/\n#if defined(_WIN32) || defined(WIN32)\nstatic void setBinaryMode(FILE *file, int isOutput){\n  if( isOutput ) fflush(file);\n  _setmode(_fileno(file), _O_BINARY);\n}\nstatic void setTextMode(FILE *file, int isOutput){\n  if( isOutput ) fflush(file);\n  _setmode(_fileno(file), _O_TEXT);\n}\n#else\n# define setBinaryMode(X,Y)\n# define setTextMode(X,Y)\n#endif\n\n\n/* True if the timer is enabled */\nstatic int enableTimer = 0;\n\n/* Return the current wall-clock time */\nstatic sqlite3_int64 timeOfDay(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)\n#include <sys/time.h>\n#include <sys/resource.h>\n\n/* VxWorks does not support getrusage() as far as we can determine */\n#if defined(_WRS_KERNEL) || defined(__RTP__)\nstruct rusage {\n  struct timeval ru_utime; /* user CPU time used */\n  struct timeval ru_stime; /* system CPU time used */\n};\n#define getrusage(A,B) memset(B,0,sizeof(*B))\n#endif\n\n/* Saved resource information for the beginning of an operation */\nstatic struct rusage sBegin;  /* CPU time at start */\nstatic sqlite3_int64 iBegin;  /* Wall-clock time at start */\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer ){\n    getrusage(RUSAGE_SELF, &sBegin);\n    iBegin = timeOfDay();\n  }\n}\n\n/* Return the difference of two time_structs in seconds */\nstatic double timeDiff(struct timeval *pStart, struct timeval *pEnd){\n  return (pEnd->tv_usec - pStart->tv_usec)*0.000001 +\n         (double)(pEnd->tv_sec - pStart->tv_sec);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer ){\n    sqlite3_int64 iEnd = timeOfDay();\n    struct rusage sEnd;\n    getrusage(RUSAGE_SELF, &sEnd);\n    printf(\"Run Time: real %.3f user %f sys %f\\n\",\n       (iEnd - iBegin)*0.001,\n       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),\n       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER 1\n\n#elif (defined(_WIN32) || defined(WIN32))\n\n/* Saved resource information for the beginning of an operation */\nstatic HANDLE hProcess;\nstatic FILETIME ftKernelBegin;\nstatic FILETIME ftUserBegin;\nstatic sqlite3_int64 ftWallBegin;\ntypedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,\n                                    LPFILETIME, LPFILETIME);\nstatic GETPROCTIMES getProcessTimesAddr = NULL;\n\n/*\n** Check to see if we have timer support.  Return 1 if necessary\n** support found (or found previously).\n*/\nstatic int hasTimer(void){\n  if( getProcessTimesAddr ){\n    return 1;\n  } else {\n    /* GetProcessTimes() isn't supported in WIN95 and some other Windows\n    ** versions. See if the version we are running on has it, and if it\n    ** does, save off a pointer to it and the current process handle.\n    */\n    hProcess = GetCurrentProcess();\n    if( hProcess ){\n      HINSTANCE hinstLib = LoadLibrary(TEXT(\"Kernel32.dll\"));\n      if( NULL != hinstLib ){\n        getProcessTimesAddr =\n            (GETPROCTIMES) GetProcAddress(hinstLib, \"GetProcessTimes\");\n        if( NULL != getProcessTimesAddr ){\n          return 1;\n        }\n        FreeLibrary(hinstLib);\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer && getProcessTimesAddr ){\n    FILETIME ftCreation, ftExit;\n    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,\n                        &ftKernelBegin,&ftUserBegin);\n    ftWallBegin = timeOfDay();\n  }\n}\n\n/* Return the difference of two FILETIME structs in seconds */\nstatic double timeDiff(FILETIME *pStart, FILETIME *pEnd){\n  sqlite_int64 i64Start = *((sqlite_int64 *) pStart);\n  sqlite_int64 i64End = *((sqlite_int64 *) pEnd);\n  return (double) ((i64End - i64Start) / 10000000.0);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer && getProcessTimesAddr){\n    FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;\n    sqlite3_int64 ftWallEnd = timeOfDay();\n    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);\n    printf(\"Run Time: real %.3f user %f sys %f\\n\",\n       (ftWallEnd - ftWallBegin)*0.001,\n       timeDiff(&ftUserBegin, &ftUserEnd),\n       timeDiff(&ftKernelBegin, &ftKernelEnd));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER hasTimer()\n\n#else\n#define BEGIN_TIMER\n#define END_TIMER\n#define HAS_TIMER 0\n#endif\n\n/*\n** Used to prevent warnings about unused parameters\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** If the following flag is set, then command execution stops\n** at an error if we are not interactive.\n*/\nstatic int bail_on_error = 0;\n\n/*\n** Threat stdin as an interactive input if the following variable\n** is true.  Otherwise, assume stdin is connected to a file or pipe.\n*/\nstatic int stdin_is_interactive = 1;\n\n/*\n** On Windows systems we have to know if standard output is a console\n** in order to translate UTF-8 into MBCS.  The following variable is\n** true if translation is required.\n*/\nstatic int stdout_is_console = 1;\n\n/*\n** The following is the open SQLite database.  We make a pointer\n** to this database a static variable so that it can be accessed\n** by the SIGINT handler to interrupt database processing.\n*/\nstatic sqlite3 *globalDb = 0;\n\n/*\n** True if an interrupt (Control-C) has been received.\n*/\nstatic volatile int seenInterrupt = 0;\n\n/*\n** This is the name of our program. It is set in main(), used\n** in a number of other places, mostly for error messages.\n*/\nstatic char *Argv0;\n\n/*\n** Prompt strings. Initialized in main. Settable with\n**   .prompt main continue\n*/\nstatic char mainPrompt[20];     /* First line prompt. default: \"sqlite> \"*/\nstatic char continuePrompt[20]; /* Continuation prompt. default: \"   ...> \" */\n\n/*\n** Render output like fprintf().  Except, if the output is going to the\n** console and if this is running on a Windows machine, translate the\n** output from UTF-8 into MBCS.\n*/\n#if defined(_WIN32) || defined(WIN32)\nvoid utf8_printf(FILE *out, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  if( stdout_is_console && (out==stdout || out==stderr) ){\n    char *z1 = sqlite3_vmprintf(zFormat, ap);\n    char *z2 = sqlite3_win32_utf8_to_mbcs_v2(z1, 0);\n    sqlite3_free(z1);\n    fputs(z2, out);\n    sqlite3_free(z2);\n  }else{\n    vfprintf(out, zFormat, ap);\n  }\n  va_end(ap);\n}\n#elif !defined(utf8_printf)\n# define utf8_printf fprintf\n#endif\n\n/*\n** Render output like fprintf().  This should not be used on anything that\n** includes string formatting (e.g. \"%s\").\n*/\n#if !defined(raw_printf)\n# define raw_printf fprintf\n#endif\n\n/*\n** Write I/O traces to the following stream.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic FILE *iotrace = 0;\n#endif\n\n/*\n** This routine works like printf in that its first argument is a\n** format string and subsequent arguments are values to be substituted\n** in place of % fields.  The result of formatting this string\n** is written to iotrace.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  if( iotrace==0 ) return;\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  utf8_printf(iotrace, \"%s\", z);\n  sqlite3_free(z);\n}\n#endif\n\n/*\n** Output string zUtf to stream pOut as w characters.  If w is negative,\n** then right-justify the text.  W is the width in UTF-8 characters, not\n** in bytes.  This is different from the %*.*s specification in printf\n** since with %*.*s the width is measured in bytes, not characters.\n*/\nstatic void utf8_width_print(FILE *pOut, int w, const char *zUtf){\n  int i;\n  int n;\n  int aw = w<0 ? -w : w;\n  char zBuf[1000];\n  if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3;\n  for(i=n=0; zUtf[i]; i++){\n    if( (zUtf[i]&0xc0)!=0x80 ){\n      n++;\n      if( n==aw ){\n        do{ i++; }while( (zUtf[i]&0xc0)==0x80 );\n        break;\n      }\n    }\n  }\n  if( n>=aw ){\n    utf8_printf(pOut, \"%.*s\", i, zUtf);\n  }else if( w<0 ){\n    utf8_printf(pOut, \"%*s%s\", aw-n, \"\", zUtf);\n  }else{\n    utf8_printf(pOut, \"%s%*s\", zUtf, aw-n, \"\");\n  }\n}\n\n\n/*\n** Determines if a string is a number of not.\n*/\nstatic int isNumber(const char *z, int *realnum){\n  if( *z=='-' || *z=='+' ) z++;\n  if( !IsDigit(*z) ){\n    return 0;\n  }\n  z++;\n  if( realnum ) *realnum = 0;\n  while( IsDigit(*z) ){ z++; }\n  if( *z=='.' ){\n    z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  if( *z=='e' || *z=='E' ){\n    z++;\n    if( *z=='+' || *z=='-' ) z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  return *z==0;\n}\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n*/\nstatic int strlen30(const char *z){\n  const char *z2 = z;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n/*\n** Return the length of a string in characters.  Multibyte UTF8 characters\n** count as a single character.\n*/\nstatic int strlenChar(const char *z){\n  int n = 0;\n  while( *z ){\n    if( (0xc0&*(z++))!=0x80 ) n++;\n  }\n  return n;\n}\n\n/*\n** This routine reads a line of text from FILE in, stores\n** the text in memory obtained from malloc() and returns a pointer\n** to the text.  NULL is returned at end of file, or if malloc()\n** fails.\n**\n** If zLine is not NULL then it is a malloced buffer returned from\n** a previous call to this routine that may be reused.\n*/\nstatic char *local_getline(char *zLine, FILE *in){\n  int nLine = zLine==0 ? 0 : 100;\n  int n = 0;\n\n  while( 1 ){\n    if( n+100>nLine ){\n      nLine = nLine*2 + 100;\n      zLine = realloc(zLine, nLine);\n      if( zLine==0 ) return 0;\n    }\n    if( fgets(&zLine[n], nLine - n, in)==0 ){\n      if( n==0 ){\n        free(zLine);\n        return 0;\n      }\n      zLine[n] = 0;\n      break;\n    }\n    while( zLine[n] ) n++;\n    if( n>0 && zLine[n-1]=='\\n' ){\n      n--;\n      if( n>0 && zLine[n-1]=='\\r' ) n--;\n      zLine[n] = 0;\n      break;\n    }\n  }\n#if defined(_WIN32) || defined(WIN32)\n  /* For interactive input on Windows systems, translate the\n  ** multi-byte characterset characters into UTF-8. */\n  if( stdin_is_interactive && in==stdin ){\n    char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);\n    if( zTrans ){\n      int nTrans = strlen30(zTrans)+1;\n      if( nTrans>nLine ){\n        zLine = realloc(zLine, nTrans);\n        if( zLine==0 ){\n          sqlite3_free(zTrans);\n          return 0;\n        }\n      }\n      memcpy(zLine, zTrans, nTrans);\n      sqlite3_free(zTrans);\n    }\n  }\n#endif /* defined(_WIN32) || defined(WIN32) */\n  return zLine;\n}\n\n/*\n** Retrieve a single line of input text.\n**\n** If in==0 then read from standard input and prompt before each line.\n** If isContinuation is true, then a continuation prompt is appropriate.\n** If isContinuation is zero, then the main prompt should be used.\n**\n** If zPrior is not NULL then it is a buffer from a prior call to this\n** routine that can be reused.\n**\n** The result is stored in space obtained from malloc() and must either\n** be freed by the caller or else passed back into this routine via the\n** zPrior argument for reuse.\n*/\nstatic char *one_input_line(FILE *in, char *zPrior, int isContinuation){\n  char *zPrompt;\n  char *zResult;\n  if( in!=0 ){\n    zResult = local_getline(zPrior, in);\n  }else{\n    zPrompt = isContinuation ? continuePrompt : mainPrompt;\n#if SHELL_USE_LOCAL_GETLINE\n    printf(\"%s\", zPrompt);\n    fflush(stdout);\n    zResult = local_getline(zPrior, stdin);\n#else\n    free(zPrior);\n    zResult = shell_readline(zPrompt);\n    if( zResult && *zResult ) shell_add_history(zResult);\n#endif\n  }\n  return zResult;\n}\n/*\n** A variable length string to which one can append text.\n*/\ntypedef struct ShellText ShellText;\nstruct ShellText {\n  char *z;\n  int n;\n  int nAlloc;\n};\n\n/*\n** Initialize and destroy a ShellText object\n*/\nstatic void initText(ShellText *p){\n  memset(p, 0, sizeof(*p));\n}\nstatic void freeText(ShellText *p){\n  free(p->z);\n  initText(p);\n}\n\n/* zIn is either a pointer to a NULL-terminated string in memory obtained\n** from malloc(), or a NULL pointer. The string pointed to by zAppend is\n** added to zIn, and the result returned in memory obtained from malloc().\n** zIn, if it was not NULL, is freed.\n**\n** If the third argument, quote, is not '\\0', then it is used as a\n** quote character for zAppend.\n*/\nstatic void appendText(ShellText *p, char const *zAppend, char quote){\n  int len;\n  int i;\n  int nAppend = strlen30(zAppend);\n\n  len = nAppend+p->n+1;\n  if( quote ){\n    len += 2;\n    for(i=0; i<nAppend; i++){\n      if( zAppend[i]==quote ) len++;\n    }\n  }\n\n  if( p->n+len>=p->nAlloc ){\n    p->nAlloc = p->nAlloc*2 + len + 20;\n    p->z = realloc(p->z, p->nAlloc);\n    if( p->z==0 ){\n      memset(p, 0, sizeof(*p));\n      return;\n    }\n  }\n\n  if( quote ){\n    char *zCsr = p->z+p->n;\n    *zCsr++ = quote;\n    for(i=0; i<nAppend; i++){\n      *zCsr++ = zAppend[i];\n      if( zAppend[i]==quote ) *zCsr++ = quote;\n    }\n    *zCsr++ = quote;\n    p->n = (int)(zCsr - p->z);\n    *zCsr = '\\0';\n  }else{\n    memcpy(p->z+p->n, zAppend, nAppend);\n    p->n += nAppend;\n    p->z[p->n] = '\\0';\n  }\n}\n\n/*\n** Attempt to determine if identifier zName needs to be quoted, either\n** because it contains non-alphanumeric characters, or because it is an\n** SQLite keyword.  Be conservative in this estimate:  When in doubt assume\n** that quoting is required.\n**\n** Return '\"' if quoting is required.  Return 0 if no quoting is required.\n*/\nstatic char quoteChar(const char *zName){\n  /* All SQLite keywords, in alphabetical order */\n  static const char *azKeywords[] = {\n    \"ABORT\", \"ACTION\", \"ADD\", \"AFTER\", \"ALL\", \"ALTER\", \"ANALYZE\", \"AND\", \"AS\",\n    \"ASC\", \"ATTACH\", \"AUTOINCREMENT\", \"BEFORE\", \"BEGIN\", \"BETWEEN\", \"BY\",\n    \"CASCADE\", \"CASE\", \"CAST\", \"CHECK\", \"COLLATE\", \"COLUMN\", \"COMMIT\",\n    \"CONFLICT\", \"CONSTRAINT\", \"CREATE\", \"CROSS\", \"CURRENT_DATE\",\n    \"CURRENT_TIME\", \"CURRENT_TIMESTAMP\", \"DATABASE\", \"DEFAULT\", \"DEFERRABLE\",\n    \"DEFERRED\", \"DELETE\", \"DESC\", \"DETACH\", \"DISTINCT\", \"DROP\", \"EACH\",\n    \"ELSE\", \"END\", \"ESCAPE\", \"EXCEPT\", \"EXCLUSIVE\", \"EXISTS\", \"EXPLAIN\",\n    \"FAIL\", \"FOR\", \"FOREIGN\", \"FROM\", \"FULL\", \"GLOB\", \"GROUP\", \"HAVING\", \"IF\",\n    \"IGNORE\", \"IMMEDIATE\", \"IN\", \"INDEX\", \"INDEXED\", \"INITIALLY\", \"INNER\",\n    \"INSERT\", \"INSTEAD\", \"INTERSECT\", \"INTO\", \"IS\", \"ISNULL\", \"JOIN\", \"KEY\",\n    \"LEFT\", \"LIKE\", \"LIMIT\", \"MATCH\", \"NATURAL\", \"NO\", \"NOT\", \"NOTNULL\",\n    \"NULL\", \"OF\", \"OFFSET\", \"ON\", \"OR\", \"ORDER\", \"OUTER\", \"PLAN\", \"PRAGMA\",\n    \"PRIMARY\", \"QUERY\", \"RAISE\", \"RECURSIVE\", \"REFERENCES\", \"REGEXP\",\n    \"REINDEX\", \"RELEASE\", \"RENAME\", \"REPLACE\", \"RESTRICT\", \"RIGHT\",\n    \"ROLLBACK\", \"ROW\", \"SAVEPOINT\", \"SELECT\", \"SET\", \"TABLE\", \"TEMP\",\n    \"TEMPORARY\", \"THEN\", \"TO\", \"TRANSACTION\", \"TRIGGER\", \"UNION\", \"UNIQUE\",\n    \"UPDATE\", \"USING\", \"VACUUM\", \"VALUES\", \"VIEW\", \"VIRTUAL\", \"WHEN\", \"WHERE\",\n    \"WITH\", \"WITHOUT\",\n  };\n  int i, lwr, upr, mid, c;\n  if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '\"';\n  for(i=0; zName[i]; i++){\n    if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '\"';\n  }\n  lwr = 0;\n  upr = sizeof(azKeywords)/sizeof(azKeywords[0]) - 1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    c = sqlite3_stricmp(azKeywords[mid], zName);\n    if( c==0 ) return '\"';\n    if( c<0 ){\n      lwr = mid+1;\n    }else{\n      upr = mid-1;\n    }\n  }\n  return 0;\n}\n\n/*\n** SQL function:  shell_add_schema(S,X)\n**\n** Add the schema name X to the CREATE statement in S and return the result.\n** Examples:\n**\n**    CREATE TABLE t1(x)   ->   CREATE TABLE xyz.t1(x);\n**\n** Also works on\n**\n**    CREATE INDEX\n**    CREATE UNIQUE INDEX\n**    CREATE VIEW\n**    CREATE TRIGGER\n**    CREATE VIRTUAL TABLE\n**\n** This UDF is used by the .schema command to insert the schema name of\n** attached databases into the middle of the sqlite_master.sql field.\n*/\nstatic void shellAddSchemaName(\n  sqlite3_context *pCtx,\n  int nVal,\n  sqlite3_value **apVal\n){\n  static const char *aPrefix[] = {\n     \"TABLE\",\n     \"INDEX\",\n     \"UNIQUE INDEX\",\n     \"VIEW\",\n     \"TRIGGER\",\n     \"VIRTUAL TABLE\"\n  };\n  int i = 0;\n  const char *zIn = (const char*)sqlite3_value_text(apVal[0]);\n  const char *zSchema = (const char*)sqlite3_value_text(apVal[1]);\n  assert( nVal==2 );\n  if( zIn!=0 && strncmp(zIn, \"CREATE \", 7)==0 ){\n    for(i=0; i<(int)(sizeof(aPrefix)/sizeof(aPrefix[0])); i++){\n      int n = strlen30(aPrefix[i]);\n      if( strncmp(zIn+7, aPrefix[i], n)==0 && zIn[n+7]==' ' ){\n        char cQuote = quoteChar(zSchema);\n        char *z;\n        if( cQuote ){\n         z = sqlite3_mprintf(\"%.*s \\\"%w\\\".%s\", n+7, zIn, zSchema, zIn+n+8);\n        }else{\n          z = sqlite3_mprintf(\"%.*s %s.%s\", n+7, zIn, zSchema, zIn+n+8);\n        }\n        sqlite3_result_text(pCtx, z, -1, sqlite3_free);\n        return;\n      }\n    }\n  }\n  sqlite3_result_value(pCtx, apVal[0]);\n}\n\n/*\n** The source code for several run-time loadable extensions is inserted\n** below by the ../tool/mkshellc.tcl script.  Before processing that included\n** code, we need to override some macros to make the included program code\n** work here in the middle of this regular program.\n*/\n#define SQLITE_EXTENSION_INIT1\n#define SQLITE_EXTENSION_INIT2(X) (void)(X)\n\n/************************* Begin ../ext/misc/shathree.c ******************/\n/*\n** 2017-03-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements a functions that compute SHA1 hashes.\n** Two SQL functions are implemented:\n**\n**     sha3(X,SIZE)\n**     sha3_query(Y,SIZE)\n**\n** The sha3(X) function computes the SHA3 hash of the input X, or NULL if\n** X is NULL.\n**\n** The sha3_query(Y) function evalutes all queries in the SQL statements of Y\n** and returns a hash of their results.\n**\n** The SIZE argument is optional.  If omitted, the SHA3-256 hash algorithm\n** is used.  If SIZE is included it must be one of the integers 224, 256,\n** 384, or 512, to determine SHA3 hash variant that is computed.\n*/\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <stdarg.h>\ntypedef sqlite3_uint64 u64;\n\n/******************************************************************************\n** The Hash Engine\n*/\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSHA3_BYTEORDER=0 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SHA3_BYTEORDER\n# if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n     defined(__arm__)\n#   define SHA3_BYTEORDER    1234\n# elif defined(sparc)    || defined(__ppc__)\n#   define SHA3_BYTEORDER    4321\n# else\n#   define SHA3_BYTEORDER 0\n# endif\n#endif\n\n\n/*\n** State structure for a SHA3 hash in progress\n*/\ntypedef struct SHA3Context SHA3Context;\nstruct SHA3Context {\n  union {\n    u64 s[25];                /* Keccak state. 5x5 lines of 64 bits each */\n    unsigned char x[1600];    /* ... or 1600 bytes */\n  } u;\n  unsigned nRate;        /* Bytes of input accepted per Keccak iteration */\n  unsigned nLoaded;      /* Input bytes loaded into u.x[] so far this cycle */\n  unsigned ixMask;       /* Insert next input into u.x[nLoaded^ixMask]. */\n};\n\n/*\n** A single step of the Keccak mixing function for a 1600-bit state\n*/\nstatic void KeccakF1600Step(SHA3Context *p){\n  int i;\n  u64 B0, B1, B2, B3, B4;\n  u64 C0, C1, C2, C3, C4;\n  u64 D0, D1, D2, D3, D4;\n  static const u64 RC[] = {\n    0x0000000000000001ULL,  0x0000000000008082ULL,\n    0x800000000000808aULL,  0x8000000080008000ULL,\n    0x000000000000808bULL,  0x0000000080000001ULL,\n    0x8000000080008081ULL,  0x8000000000008009ULL,\n    0x000000000000008aULL,  0x0000000000000088ULL,\n    0x0000000080008009ULL,  0x000000008000000aULL,\n    0x000000008000808bULL,  0x800000000000008bULL,\n    0x8000000000008089ULL,  0x8000000000008003ULL,\n    0x8000000000008002ULL,  0x8000000000000080ULL,\n    0x000000000000800aULL,  0x800000008000000aULL,\n    0x8000000080008081ULL,  0x8000000000008080ULL,\n    0x0000000080000001ULL,  0x8000000080008008ULL\n  };\n# define A00 (p->u.s[0])\n# define A01 (p->u.s[1])\n# define A02 (p->u.s[2])\n# define A03 (p->u.s[3])\n# define A04 (p->u.s[4])\n# define A10 (p->u.s[5])\n# define A11 (p->u.s[6])\n# define A12 (p->u.s[7])\n# define A13 (p->u.s[8])\n# define A14 (p->u.s[9])\n# define A20 (p->u.s[10])\n# define A21 (p->u.s[11])\n# define A22 (p->u.s[12])\n# define A23 (p->u.s[13])\n# define A24 (p->u.s[14])\n# define A30 (p->u.s[15])\n# define A31 (p->u.s[16])\n# define A32 (p->u.s[17])\n# define A33 (p->u.s[18])\n# define A34 (p->u.s[19])\n# define A40 (p->u.s[20])\n# define A41 (p->u.s[21])\n# define A42 (p->u.s[22])\n# define A43 (p->u.s[23])\n# define A44 (p->u.s[24])\n# define ROL64(a,x) ((a<<x)|(a>>(64-x)))\n\n  for(i=0; i<24; i+=4){\n    C0 = A00^A10^A20^A30^A40;\n    C1 = A01^A11^A21^A31^A41;\n    C2 = A02^A12^A22^A32^A42;\n    C3 = A03^A13^A23^A33^A43;\n    C4 = A04^A14^A24^A34^A44;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A11^D1), 44);\n    B2 = ROL64((A22^D2), 43);\n    B3 = ROL64((A33^D3), 21);\n    B4 = ROL64((A44^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i];\n    A11 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A20^D0), 3);\n    B3 = ROL64((A31^D1), 45);\n    B4 = ROL64((A42^D2), 61);\n    B0 = ROL64((A03^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A20 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A40^D0), 18);\n    B0 = ROL64((A01^D1), 1);\n    B1 = ROL64((A12^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A34^D4), 8);\n    A40 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A10^D0), 36);\n    B2 = ROL64((A21^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A43^D3), 56);\n    B0 = ROL64((A04^D4), 27);\n    A10 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A30^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A02^D2), 62);\n    B1 = ROL64((A13^D3), 55);\n    B2 = ROL64((A24^D4), 39);\n    A30 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A20^A40^A10^A30;\n    C1 = A11^A31^A01^A21^A41;\n    C2 = A22^A42^A12^A32^A02;\n    C3 = A33^A03^A23^A43^A13;\n    C4 = A44^A14^A34^A04^A24;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A31^D1), 44);\n    B2 = ROL64((A12^D2), 43);\n    B3 = ROL64((A43^D3), 21);\n    B4 = ROL64((A24^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+1];\n    A31 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A40^D0), 3);\n    B3 = ROL64((A21^D1), 45);\n    B4 = ROL64((A02^D2), 61);\n    B0 = ROL64((A33^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A40 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A30^D0), 18);\n    B0 = ROL64((A11^D1), 1);\n    B1 = ROL64((A42^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A04^D4), 8);\n    A30 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A20^D0), 36);\n    B2 = ROL64((A01^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A13^D3), 56);\n    B0 = ROL64((A44^D4), 27);\n    A20 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A10^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A22^D2), 62);\n    B1 = ROL64((A03^D3), 55);\n    B2 = ROL64((A34^D4), 39);\n    A10 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A40^A30^A20^A10;\n    C1 = A31^A21^A11^A01^A41;\n    C2 = A12^A02^A42^A32^A22;\n    C3 = A43^A33^A23^A13^A03;\n    C4 = A24^A14^A04^A44^A34;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A21^D1), 44);\n    B2 = ROL64((A42^D2), 43);\n    B3 = ROL64((A13^D3), 21);\n    B4 = ROL64((A34^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+2];\n    A21 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A30^D0), 3);\n    B3 = ROL64((A01^D1), 45);\n    B4 = ROL64((A22^D2), 61);\n    B0 = ROL64((A43^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A30 =   B0 ^((~B1)&  B2 );\n    A01 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A10^D0), 18);\n    B0 = ROL64((A31^D1), 1);\n    B1 = ROL64((A02^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A44^D4), 8);\n    A10 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A40^D0), 36);\n    B2 = ROL64((A11^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A03^D3), 56);\n    B0 = ROL64((A24^D4), 27);\n    A40 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A20^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A12^D2), 62);\n    B1 = ROL64((A33^D3), 55);\n    B2 = ROL64((A04^D4), 39);\n    A20 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    C0 = A00^A30^A10^A40^A20;\n    C1 = A21^A01^A31^A11^A41;\n    C2 = A42^A22^A02^A32^A12;\n    C3 = A13^A43^A23^A03^A33;\n    C4 = A34^A14^A44^A24^A04;\n    D0 = C4^ROL64(C1, 1);\n    D1 = C0^ROL64(C2, 1);\n    D2 = C1^ROL64(C3, 1);\n    D3 = C2^ROL64(C4, 1);\n    D4 = C3^ROL64(C0, 1);\n\n    B0 = (A00^D0);\n    B1 = ROL64((A01^D1), 44);\n    B2 = ROL64((A02^D2), 43);\n    B3 = ROL64((A03^D3), 21);\n    B4 = ROL64((A04^D4), 14);\n    A00 =   B0 ^((~B1)&  B2 );\n    A00 ^= RC[i+3];\n    A01 =   B1 ^((~B2)&  B3 );\n    A02 =   B2 ^((~B3)&  B4 );\n    A03 =   B3 ^((~B4)&  B0 );\n    A04 =   B4 ^((~B0)&  B1 );\n\n    B2 = ROL64((A10^D0), 3);\n    B3 = ROL64((A11^D1), 45);\n    B4 = ROL64((A12^D2), 61);\n    B0 = ROL64((A13^D3), 28);\n    B1 = ROL64((A14^D4), 20);\n    A10 =   B0 ^((~B1)&  B2 );\n    A11 =   B1 ^((~B2)&  B3 );\n    A12 =   B2 ^((~B3)&  B4 );\n    A13 =   B3 ^((~B4)&  B0 );\n    A14 =   B4 ^((~B0)&  B1 );\n\n    B4 = ROL64((A20^D0), 18);\n    B0 = ROL64((A21^D1), 1);\n    B1 = ROL64((A22^D2), 6);\n    B2 = ROL64((A23^D3), 25);\n    B3 = ROL64((A24^D4), 8);\n    A20 =   B0 ^((~B1)&  B2 );\n    A21 =   B1 ^((~B2)&  B3 );\n    A22 =   B2 ^((~B3)&  B4 );\n    A23 =   B3 ^((~B4)&  B0 );\n    A24 =   B4 ^((~B0)&  B1 );\n\n    B1 = ROL64((A30^D0), 36);\n    B2 = ROL64((A31^D1), 10);\n    B3 = ROL64((A32^D2), 15);\n    B4 = ROL64((A33^D3), 56);\n    B0 = ROL64((A34^D4), 27);\n    A30 =   B0 ^((~B1)&  B2 );\n    A31 =   B1 ^((~B2)&  B3 );\n    A32 =   B2 ^((~B3)&  B4 );\n    A33 =   B3 ^((~B4)&  B0 );\n    A34 =   B4 ^((~B0)&  B1 );\n\n    B3 = ROL64((A40^D0), 41);\n    B4 = ROL64((A41^D1), 2);\n    B0 = ROL64((A42^D2), 62);\n    B1 = ROL64((A43^D3), 55);\n    B2 = ROL64((A44^D4), 39);\n    A40 =   B0 ^((~B1)&  B2 );\n    A41 =   B1 ^((~B2)&  B3 );\n    A42 =   B2 ^((~B3)&  B4 );\n    A43 =   B3 ^((~B4)&  B0 );\n    A44 =   B4 ^((~B0)&  B1 );\n  }\n}\n\n/*\n** Initialize a new hash.  iSize determines the size of the hash\n** in bits and should be one of 224, 256, 384, or 512.  Or iSize\n** can be zero to use the default hash size of 256 bits.\n*/\nstatic void SHA3Init(SHA3Context *p, int iSize){\n  memset(p, 0, sizeof(*p));\n  if( iSize>=128 && iSize<=512 ){\n    p->nRate = (1600 - ((iSize + 31)&~31)*2)/8;\n  }else{\n    p->nRate = (1600 - 2*256)/8;\n  }\n#if SHA3_BYTEORDER==1234\n  /* Known to be little-endian at compile-time. No-op */\n#elif SHA3_BYTEORDER==4321\n  p->ixMask = 7;  /* Big-endian */\n#else\n  {\n    static unsigned int one = 1;\n    if( 1==*(unsigned char*)&one ){\n      /* Little endian.  No byte swapping. */\n      p->ixMask = 0;\n    }else{\n      /* Big endian.  Byte swap. */\n      p->ixMask = 7;\n    }\n  }\n#endif\n}\n\n/*\n** Make consecutive calls to the SHA3Update function to add new content\n** to the hash\n*/\nstatic void SHA3Update(\n  SHA3Context *p,\n  const unsigned char *aData,\n  unsigned int nData\n){\n  unsigned int i = 0;\n#if SHA3_BYTEORDER==1234\n  if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){\n    for(; i+7<nData; i+=8){\n      p->u.s[p->nLoaded/8] ^= *(u64*)&aData[i];\n      p->nLoaded += 8;\n      if( p->nLoaded>=p->nRate ){\n        KeccakF1600Step(p);\n        p->nLoaded = 0;\n      }\n    }\n  }\n#endif\n  for(; i<nData; i++){\n#if SHA3_BYTEORDER==1234\n    p->u.x[p->nLoaded] ^= aData[i];\n#elif SHA3_BYTEORDER==4321\n    p->u.x[p->nLoaded^0x07] ^= aData[i];\n#else\n    p->u.x[p->nLoaded^p->ixMask] ^= aData[i];\n#endif\n    p->nLoaded++;\n    if( p->nLoaded==p->nRate ){\n      KeccakF1600Step(p);\n      p->nLoaded = 0;\n    }\n  }\n}\n\n/*\n** After all content has been added, invoke SHA3Final() to compute\n** the final hash.  The function returns a pointer to the binary\n** hash value.\n*/\nstatic unsigned char *SHA3Final(SHA3Context *p){\n  unsigned int i;\n  if( p->nLoaded==p->nRate-1 ){\n    const unsigned char c1 = 0x86;\n    SHA3Update(p, &c1, 1);\n  }else{\n    const unsigned char c2 = 0x06;\n    const unsigned char c3 = 0x80;\n    SHA3Update(p, &c2, 1);\n    p->nLoaded = p->nRate - 1;\n    SHA3Update(p, &c3, 1);\n  }\n  for(i=0; i<p->nRate; i++){\n    p->u.x[i+p->nRate] = p->u.x[i^p->ixMask];\n  }\n  return &p->u.x[p->nRate];\n}\n/* End of the hashing logic\n*****************************************************************************/\n\n/*\n** Implementation of the sha3(X,SIZE) function.\n**\n** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default\n** size is 256.  If X is a BLOB, it is hashed as is.  \n** For all other non-NULL types of input, X is converted into a UTF-8 string\n** and the string is hashed without the trailing 0x00 terminator.  The hash\n** of a NULL value is NULL.\n*/\nstatic void sha3Func(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  SHA3Context cx;\n  int eType = sqlite3_value_type(argv[0]);\n  int nByte = sqlite3_value_bytes(argv[0]);\n  int iSize;\n  if( argc==1 ){\n    iSize = 256;\n  }else{\n    iSize = sqlite3_value_int(argv[1]);\n    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){\n      sqlite3_result_error(context, \"SHA3 size should be one of: 224 256 \"\n                                    \"384 512\", -1);\n      return;\n    }\n  }\n  if( eType==SQLITE_NULL ) return;\n  SHA3Init(&cx, iSize);\n  if( eType==SQLITE_BLOB ){\n    SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte);\n  }else{\n    SHA3Update(&cx, sqlite3_value_text(argv[0]), nByte);\n  }\n  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);\n}\n\n/* Compute a string using sqlite3_vsnprintf() with a maximum length\n** of 50 bytes and add it to the hash.\n*/\nstatic void hash_step_vformat(\n  SHA3Context *p,                 /* Add content to this context */\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  int n;\n  char zBuf[50];\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(sizeof(zBuf),zBuf,zFormat,ap);\n  va_end(ap);\n  n = (int)strlen(zBuf);\n  SHA3Update(p, (unsigned char*)zBuf, n);\n}\n\n/*\n** Implementation of the sha3_query(SQL,SIZE) function.\n**\n** This function compiles and runs the SQL statement(s) given in the\n** argument. The results are hashed using a SIZE-bit SHA3.  The default\n** size is 256.\n**\n** The format of the byte stream that is hashed is summarized as follows:\n**\n**       S<n>:<sql>\n**       R\n**       N\n**       I<int>\n**       F<ieee-float>\n**       B<size>:<bytes>\n**       T<size>:<text>\n**\n** <sql> is the original SQL text for each statement run and <n> is\n** the size of that text.  The SQL text is UTF-8.  A single R character\n** occurs before the start of each row.  N means a NULL value.\n** I mean an 8-byte little-endian integer <int>.  F is a floating point\n** number with an 8-byte little-endian IEEE floating point value <ieee-float>.\n** B means blobs of <size> bytes.  T means text rendered as <size>\n** bytes of UTF-8.  The <n> and <size> values are expressed as an ASCII\n** text integers.\n**\n** For each SQL statement in the X input, there is one S segment.  Each\n** S segment is followed by zero or more R segments, one for each row in the\n** result set.  After each R, there are one or more N, I, F, B, or T segments,\n** one for each column in the result set.  Segments are concatentated directly\n** with no delimiters of any kind.\n*/\nstatic void sha3QueryFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zSql = (const char*)sqlite3_value_text(argv[0]);\n  sqlite3_stmt *pStmt = 0;\n  int nCol;                   /* Number of columns in the result set */\n  int i;                      /* Loop counter */\n  int rc;\n  int n;\n  const char *z;\n  SHA3Context cx;\n  int iSize;\n\n  if( argc==1 ){\n    iSize = 256;\n  }else{\n    iSize = sqlite3_value_int(argv[1]);\n    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){\n      sqlite3_result_error(context, \"SHA3 size should be one of: 224 256 \"\n                                    \"384 512\", -1);\n      return;\n    }\n  }\n  if( zSql==0 ) return;\n  SHA3Init(&cx, iSize);\n  while( zSql[0] ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zSql);\n    if( rc ){\n      char *zMsg = sqlite3_mprintf(\"error SQL statement [%s]: %s\",\n                                   zSql, sqlite3_errmsg(db));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    if( !sqlite3_stmt_readonly(pStmt) ){\n      char *zMsg = sqlite3_mprintf(\"non-query: [%s]\", sqlite3_sql(pStmt));\n      sqlite3_finalize(pStmt);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    z = sqlite3_sql(pStmt);\n    n = (int)strlen(z);\n    hash_step_vformat(&cx,\"S%d:\",n);\n    SHA3Update(&cx,(unsigned char*)z,n);\n\n    /* Compute a hash over the result of the query */\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      SHA3Update(&cx,(const unsigned char*)\"R\",1);\n      for(i=0; i<nCol; i++){\n        switch( sqlite3_column_type(pStmt,i) ){\n          case SQLITE_NULL: {\n            SHA3Update(&cx, (const unsigned char*)\"N\",1);\n            break;\n          }\n          case SQLITE_INTEGER: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            sqlite3_int64 v = sqlite3_column_int64(pStmt,i);\n            memcpy(&u, &v, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'I';\n            SHA3Update(&cx, x, 9);\n            break;\n          }\n          case SQLITE_FLOAT: {\n            sqlite3_uint64 u;\n            int j;\n            unsigned char x[9];\n            double r = sqlite3_column_double(pStmt,i);\n            memcpy(&u, &r, 8);\n            for(j=8; j>=1; j--){\n              x[j] = u & 0xff;\n              u >>= 8;\n            }\n            x[0] = 'F';\n            SHA3Update(&cx,x,9);\n            break;\n          }\n          case SQLITE_TEXT: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_text(pStmt, i);\n            hash_step_vformat(&cx,\"T%d:\",n2);\n            SHA3Update(&cx, z2, n2);\n            break;\n          }\n          case SQLITE_BLOB: {\n            int n2 = sqlite3_column_bytes(pStmt, i);\n            const unsigned char *z2 = sqlite3_column_blob(pStmt, i);\n            hash_step_vformat(&cx,\"B%d:\",n2);\n            SHA3Update(&cx, z2, n2);\n            break;\n          }\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }\n  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);\n}\n\n\n#ifdef _WIN32\n\n#endif\nint sqlite3_shathree_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"sha3\", 1, SQLITE_UTF8, 0,\n                               sha3Func, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3\", 2, SQLITE_UTF8, 0,\n                                 sha3Func, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3_query\", 1, SQLITE_UTF8, 0,\n                                 sha3QueryFunc, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"sha3_query\", 2, SQLITE_UTF8, 0,\n                                 sha3QueryFunc, 0, 0);\n  }\n  return rc;\n}\n\n/************************* End ../ext/misc/shathree.c ********************/\n/************************* Begin ../ext/misc/fileio.c ******************/\n/*\n** 2014-06-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements SQL functions readfile() and\n** writefile().\n*/\nSQLITE_EXTENSION_INIT1\n#include <stdio.h>\n\n/*\n** Implementation of the \"readfile(X)\" SQL function.  The entire content\n** of the file named X is read and returned as a BLOB.  NULL is returned\n** if the file does not exist or is unreadable.\n*/\nstatic void readfileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zName;\n  FILE *in;\n  long nIn;\n  void *pBuf;\n\n  (void)(argc);  /* Unused parameter */\n  zName = (const char*)sqlite3_value_text(argv[0]);\n  if( zName==0 ) return;\n  in = fopen(zName, \"rb\");\n  if( in==0 ) return;\n  fseek(in, 0, SEEK_END);\n  nIn = ftell(in);\n  rewind(in);\n  pBuf = sqlite3_malloc( nIn );\n  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){\n    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);\n  }else{\n    sqlite3_free(pBuf);\n  }\n  fclose(in);\n}\n\n/*\n** Implementation of the \"writefile(X,Y)\" SQL function.  The argument Y\n** is written into file X.  The number of bytes written is returned.  Or\n** NULL is returned if something goes wrong, such as being unable to open\n** file X for writing.\n*/\nstatic void writefileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  FILE *out;\n  const char *z;\n  sqlite3_int64 rc;\n  const char *zFile;\n\n  (void)(argc);  /* Unused parameter */\n  zFile = (const char*)sqlite3_value_text(argv[0]);\n  if( zFile==0 ) return;\n  out = fopen(zFile, \"wb\");\n  if( out==0 ) return;\n  z = (const char*)sqlite3_value_blob(argv[1]);\n  if( z==0 ){\n    rc = 0;\n  }else{\n    rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);\n  }\n  fclose(out);\n  sqlite3_result_int64(context, rc);\n}\n\n\n#ifdef _WIN32\n\n#endif\nint sqlite3_fileio_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  rc = sqlite3_create_function(db, \"readfile\", 1, SQLITE_UTF8, 0,\n                               readfileFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"writefile\", 2, SQLITE_UTF8, 0,\n                                 writefileFunc, 0, 0);\n  }\n  return rc;\n}\n\n/************************* End ../ext/misc/fileio.c ********************/\n/************************* Begin ../ext/misc/completion.c ******************/\n/*\n** 2017-07-10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements an eponymous virtual table that returns suggested\n** completions for a partial SQL input.\n**\n** Suggested usage:\n**\n**     SELECT DISTINCT candidate COLLATE nocase\n**       FROM completion($prefix,$wholeline)\n**      ORDER BY 1;\n**\n** The two query parameters are optional.  $prefix is the text of the\n** current word being typed and that is to be completed.  $wholeline is\n** the complete input line, used for context.\n**\n** The raw completion() table might return the same candidate multiple\n** times, for example if the same column name is used to two or more\n** tables.  And the candidates are returned in an arbitrary order.  Hence,\n** the DISTINCT and ORDER BY are recommended.\n**\n** This virtual table operates at the speed of human typing, and so there\n** is no attempt to make it fast.  Even a slow implementation will be much\n** faster than any human can type.\n**\n*/\nSQLITE_EXTENSION_INIT1\n#include <assert.h>\n#include <string.h>\n#include <ctype.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* completion_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a completion virtual table\n*/\ntypedef struct completion_vtab completion_vtab;\nstruct completion_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  sqlite3 *db;        /* Database connection for this completion vtab */\n};\n\n/* completion_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct completion_cursor completion_cursor;\nstruct completion_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3 *db;               /* Database connection for this cursor */\n  int nPrefix, nLine;        /* Number of bytes in zPrefix and zLine */\n  char *zPrefix;             /* The prefix for the word we want to complete */\n  char *zLine;               /* The whole that we want to complete */\n  const char *zCurrentRow;   /* Current output row */\n  sqlite3_stmt *pStmt;       /* Current statement */\n  sqlite3_int64 iRowid;      /* The rowid */\n  int ePhase;                /* Current phase */\n  int j;                     /* inter-phase counter */\n};\n\n/* Values for ePhase:\n*/\n#define COMPLETION_FIRST_PHASE   1\n#define COMPLETION_KEYWORDS      1\n#define COMPLETION_PRAGMAS       2\n#define COMPLETION_FUNCTIONS     3\n#define COMPLETION_COLLATIONS    4\n#define COMPLETION_INDEXES       5\n#define COMPLETION_TRIGGERS      6\n#define COMPLETION_DATABASES     7\n#define COMPLETION_TABLES        8\n#define COMPLETION_COLUMNS       9\n#define COMPLETION_MODULES       10\n#define COMPLETION_EOF           11\n\n/*\n** The completionConnect() method is invoked to create a new\n** completion_vtab that describes the completion virtual table.\n**\n** Think of this routine as the constructor for completion_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the completion_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against completion will look like.\n*/\nstatic int completionConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  completion_vtab *pNew;\n  int rc;\n\n  (void)(pAux);    /* Unused parameter */\n  (void)(argc);    /* Unused parameter */\n  (void)(argv);    /* Unused parameter */\n  (void)(pzErr);   /* Unused parameter */\n\n/* Column numbers */\n#define COMPLETION_COLUMN_CANDIDATE 0  /* Suggested completion of the input */\n#define COMPLETION_COLUMN_PREFIX    1  /* Prefix of the word to be completed */\n#define COMPLETION_COLUMN_WHOLELINE 2  /* Entire line seen so far */\n#define COMPLETION_COLUMN_PHASE     3  /* ePhase - used for debugging only */\n\n  rc = sqlite3_declare_vtab(db,\n      \"CREATE TABLE x(\"\n      \"  candidate TEXT,\"\n      \"  prefix TEXT HIDDEN,\"\n      \"  wholeline TEXT HIDDEN,\"\n      \"  phase INT HIDDEN\"        /* Used for debugging only */\n      \")\");\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->db = db;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for completion_cursor objects.\n*/\nstatic int completionDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new completion_cursor object.\n*/\nstatic int completionOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  completion_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->db = ((completion_vtab*)p)->db;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the completion_cursor.\n*/\nstatic void completionCursorReset(completion_cursor *pCur){\n  sqlite3_free(pCur->zPrefix);   pCur->zPrefix = 0;  pCur->nPrefix = 0;\n  sqlite3_free(pCur->zLine);     pCur->zLine = 0;    pCur->nLine = 0;\n  sqlite3_finalize(pCur->pStmt); pCur->pStmt = 0;\n  pCur->j = 0;\n}\n\n/*\n** Destructor for a completion_cursor.\n*/\nstatic int completionClose(sqlite3_vtab_cursor *cur){\n  completionCursorReset((completion_cursor*)cur);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/*\n** All SQL keywords understood by SQLite\n*/\nstatic const char *completionKwrds[] = {\n  \"ABORT\", \"ACTION\", \"ADD\", \"AFTER\", \"ALL\", \"ALTER\", \"ANALYZE\", \"AND\", \"AS\",\n  \"ASC\", \"ATTACH\", \"AUTOINCREMENT\", \"BEFORE\", \"BEGIN\", \"BETWEEN\", \"BY\",\n  \"CASCADE\", \"CASE\", \"CAST\", \"CHECK\", \"COLLATE\", \"COLUMN\", \"COMMIT\",\n  \"CONFLICT\", \"CONSTRAINT\", \"CREATE\", \"CROSS\", \"CURRENT_DATE\",\n  \"CURRENT_TIME\", \"CURRENT_TIMESTAMP\", \"DATABASE\", \"DEFAULT\", \"DEFERRABLE\",\n  \"DEFERRED\", \"DELETE\", \"DESC\", \"DETACH\", \"DISTINCT\", \"DROP\", \"EACH\",\n  \"ELSE\", \"END\", \"ESCAPE\", \"EXCEPT\", \"EXCLUSIVE\", \"EXISTS\", \"EXPLAIN\",\n  \"FAIL\", \"FOR\", \"FOREIGN\", \"FROM\", \"FULL\", \"GLOB\", \"GROUP\", \"HAVING\", \"IF\",\n  \"IGNORE\", \"IMMEDIATE\", \"IN\", \"INDEX\", \"INDEXED\", \"INITIALLY\", \"INNER\",\n  \"INSERT\", \"INSTEAD\", \"INTERSECT\", \"INTO\", \"IS\", \"ISNULL\", \"JOIN\", \"KEY\",\n  \"LEFT\", \"LIKE\", \"LIMIT\", \"MATCH\", \"NATURAL\", \"NO\", \"NOT\", \"NOTNULL\",\n  \"NULL\", \"OF\", \"OFFSET\", \"ON\", \"OR\", \"ORDER\", \"OUTER\", \"PLAN\", \"PRAGMA\",\n  \"PRIMARY\", \"QUERY\", \"RAISE\", \"RECURSIVE\", \"REFERENCES\", \"REGEXP\",\n  \"REINDEX\", \"RELEASE\", \"RENAME\", \"REPLACE\", \"RESTRICT\", \"RIGHT\",\n  \"ROLLBACK\", \"ROW\", \"SAVEPOINT\", \"SELECT\", \"SET\", \"TABLE\", \"TEMP\",\n  \"TEMPORARY\", \"THEN\", \"TO\", \"TRANSACTION\", \"TRIGGER\", \"UNION\", \"UNIQUE\",\n  \"UPDATE\", \"USING\", \"VACUUM\", \"VALUES\", \"VIEW\", \"VIRTUAL\", \"WHEN\", \"WHERE\",\n  \"WITH\", \"WITHOUT\",\n};\n#define completionKwCount \\\n   (int)(sizeof(completionKwrds)/sizeof(completionKwrds[0]))\n\n/*\n** Advance a completion_cursor to its next row of output.\n**\n** The ->ePhase, ->j, and ->pStmt fields of the completion_cursor object\n** record the current state of the scan.  This routine sets ->zCurrentRow\n** to the current row of output and then returns.  If no more rows remain,\n** then ->ePhase is set to COMPLETION_EOF which will signal the virtual\n** table that has reached the end of its scan.\n**\n** The current implementation just lists potential identifiers and\n** keywords and filters them by zPrefix.  Future enhancements should\n** take zLine into account to try to restrict the set of identifiers and\n** keywords based on what would be legal at the current point of input.\n*/\nstatic int completionNext(sqlite3_vtab_cursor *cur){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  int eNextPhase = 0;  /* Next phase to try if current phase reaches end */\n  int iCol = -1;       /* If >=0, step pCur->pStmt and use the i-th column */\n  pCur->iRowid++;\n  while( pCur->ePhase!=COMPLETION_EOF ){\n    switch( pCur->ePhase ){\n      case COMPLETION_KEYWORDS: {\n        if( pCur->j >= completionKwCount ){\n          pCur->zCurrentRow = 0;\n          pCur->ePhase = COMPLETION_DATABASES;\n        }else{\n          pCur->zCurrentRow = completionKwrds[pCur->j++];\n        }\n        iCol = -1;\n        break;\n      }\n      case COMPLETION_DATABASES: {\n        if( pCur->pStmt==0 ){\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1,\n                             &pCur->pStmt, 0);\n        }\n        iCol = 1;\n        eNextPhase = COMPLETION_TABLES;\n        break;\n      }\n      case COMPLETION_TABLES: {\n        if( pCur->pStmt==0 ){\n          sqlite3_stmt *pS2;\n          char *zSql = 0;\n          const char *zSep = \"\";\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1, &pS2, 0);\n          while( sqlite3_step(pS2)==SQLITE_ROW ){\n            const char *zDb = (const char*)sqlite3_column_text(pS2, 1);\n            zSql = sqlite3_mprintf(\n               \"%z%s\"\n               \"SELECT name FROM \\\"%w\\\".sqlite_master\"\n               \" WHERE type='table'\",\n               zSql, zSep, zDb\n            );\n            if( zSql==0 ) return SQLITE_NOMEM;\n            zSep = \" UNION \";\n          }\n          sqlite3_finalize(pS2);\n          sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);\n          sqlite3_free(zSql);\n        }\n        iCol = 0;\n        eNextPhase = COMPLETION_COLUMNS;\n        break;\n      }\n      case COMPLETION_COLUMNS: {\n        if( pCur->pStmt==0 ){\n          sqlite3_stmt *pS2;\n          char *zSql = 0;\n          const char *zSep = \"\";\n          sqlite3_prepare_v2(pCur->db, \"PRAGMA database_list\", -1, &pS2, 0);\n          while( sqlite3_step(pS2)==SQLITE_ROW ){\n            const char *zDb = (const char*)sqlite3_column_text(pS2, 1);\n            zSql = sqlite3_mprintf(\n               \"%z%s\"\n               \"SELECT pti.name FROM \\\"%w\\\".sqlite_master AS sm\"\n                       \" JOIN pragma_table_info(sm.name,%Q) AS pti\"\n               \" WHERE sm.type='table'\",\n               zSql, zSep, zDb, zDb\n            );\n            if( zSql==0 ) return SQLITE_NOMEM;\n            zSep = \" UNION \";\n          }\n          sqlite3_finalize(pS2);\n          sqlite3_prepare_v2(pCur->db, zSql, -1, &pCur->pStmt, 0);\n          sqlite3_free(zSql);\n        }\n        iCol = 0;\n        eNextPhase = COMPLETION_EOF;\n        break;\n      }\n    }\n    if( iCol<0 ){\n      /* This case is when the phase presets zCurrentRow */\n      if( pCur->zCurrentRow==0 ) continue;\n    }else{\n      if( sqlite3_step(pCur->pStmt)==SQLITE_ROW ){\n        /* Extract the next row of content */\n        pCur->zCurrentRow = (const char*)sqlite3_column_text(pCur->pStmt, iCol);\n      }else{\n        /* When all rows are finished, advance to the next phase */\n        sqlite3_finalize(pCur->pStmt);\n        pCur->pStmt = 0;\n        pCur->ePhase = eNextPhase;\n        continue;\n      }\n    }\n    if( pCur->nPrefix==0 ) break;\n    if( sqlite3_strnicmp(pCur->zPrefix, pCur->zCurrentRow, pCur->nPrefix)==0 ){\n      break;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the completion_cursor\n** is currently pointing.\n*/\nstatic int completionColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  switch( i ){\n    case COMPLETION_COLUMN_CANDIDATE: {\n      sqlite3_result_text(ctx, pCur->zCurrentRow, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_PREFIX: {\n      sqlite3_result_text(ctx, pCur->zPrefix, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_WHOLELINE: {\n      sqlite3_result_text(ctx, pCur->zLine, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case COMPLETION_COLUMN_PHASE: {\n      sqlite3_result_int(ctx, pCur->ePhase);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int completionRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int completionEof(sqlite3_vtab_cursor *cur){\n  completion_cursor *pCur = (completion_cursor*)cur;\n  return pCur->ePhase >= COMPLETION_EOF;\n}\n\n/*\n** This method is called to \"rewind\" the completion_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to completionColumn() or completionRowid() or \n** completionEof().\n*/\nstatic int completionFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  completion_cursor *pCur = (completion_cursor *)pVtabCursor;\n  int iArg = 0;\n  (void)(idxStr);   /* Unused parameter */\n  (void)(argc);     /* Unused parameter */\n  completionCursorReset(pCur);\n  if( idxNum & 1 ){\n    pCur->nPrefix = sqlite3_value_bytes(argv[iArg]);\n    if( pCur->nPrefix>0 ){\n      pCur->zPrefix = sqlite3_mprintf(\"%s\", sqlite3_value_text(argv[iArg]));\n      if( pCur->zPrefix==0 ) return SQLITE_NOMEM;\n    }\n    iArg++;\n  }\n  if( idxNum & 2 ){\n    pCur->nLine = sqlite3_value_bytes(argv[iArg]);\n    if( pCur->nLine>0 ){\n      pCur->zLine = sqlite3_mprintf(\"%s\", sqlite3_value_text(argv[iArg]));\n      if( pCur->zLine==0 ) return SQLITE_NOMEM;\n    }\n    iArg++;\n  }\n  if( pCur->zLine!=0 && pCur->zPrefix==0 ){\n    int i = pCur->nLine;\n    while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){\n      i--;\n    }\n    pCur->nPrefix = pCur->nLine - i;\n    if( pCur->nPrefix>0 ){\n      pCur->zPrefix = sqlite3_mprintf(\"%.*s\", pCur->nPrefix, pCur->zLine + i);\n      if( pCur->zPrefix==0 ) return SQLITE_NOMEM;\n    }\n  }\n  pCur->iRowid = 0;\n  pCur->ePhase = COMPLETION_FIRST_PHASE;\n  return completionNext(pVtabCursor);\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the completion virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n**\n** There are two hidden parameters that act as arguments to the table-valued\n** function:  \"prefix\" and \"wholeline\".  Bit 0 of idxNum is set if \"prefix\"\n** is available and bit 1 is set if \"wholeline\" is available.\n*/\nstatic int completionBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;                 /* Loop over constraints */\n  int idxNum = 0;        /* The query plan bitmask */\n  int prefixIdx = -1;    /* Index of the start= constraint, or -1 if none */\n  int wholelineIdx = -1; /* Index of the stop= constraint, or -1 if none */\n  int nArg = 0;          /* Number of arguments that completeFilter() expects */\n  const struct sqlite3_index_constraint *pConstraint;\n\n  (void)(tab);    /* Unused parameter */\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case COMPLETION_COLUMN_PREFIX:\n        prefixIdx = i;\n        idxNum |= 1;\n        break;\n      case COMPLETION_COLUMN_WHOLELINE:\n        wholelineIdx = i;\n        idxNum |= 2;\n        break;\n    }\n  }\n  if( prefixIdx>=0 ){\n    pIdxInfo->aConstraintUsage[prefixIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[prefixIdx].omit = 1;\n  }\n  if( wholelineIdx>=0 ){\n    pIdxInfo->aConstraintUsage[wholelineIdx].argvIndex = ++nArg;\n    pIdxInfo->aConstraintUsage[wholelineIdx].omit = 1;\n  }\n  pIdxInfo->idxNum = idxNum;\n  pIdxInfo->estimatedCost = (double)5000 - 1000*nArg;\n  pIdxInfo->estimatedRows = 500 - 100*nArg;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** completion virtual table.\n*/\nstatic sqlite3_module completionModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  completionConnect,         /* xConnect */\n  completionBestIndex,       /* xBestIndex */\n  completionDisconnect,      /* xDisconnect */\n  0,                         /* xDestroy */\n  completionOpen,            /* xOpen - open a cursor */\n  completionClose,           /* xClose - close a cursor */\n  completionFilter,          /* xFilter - configure scan constraints */\n  completionNext,            /* xNext - advance a cursor */\n  completionEof,             /* xEof - check for end of scan */\n  completionColumn,          /* xColumn - read data */\n  completionRowid,           /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\nint sqlite3CompletionVtabInit(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"completion\", &completionModule, 0);\n#endif\n  return rc;\n}\n\n#ifdef _WIN32\n\n#endif\nint sqlite3_completion_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)(pzErrMsg);  /* Unused parameter */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3CompletionVtabInit(db);\n#endif\n  return rc;\n}\n\n/************************* End ../ext/misc/completion.c ********************/\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** State information for a single open session\n*/\ntypedef struct OpenSession OpenSession;\nstruct OpenSession {\n  char *zName;             /* Symbolic name for this session */\n  int nFilter;             /* Number of xFilter rejection GLOB patterns */\n  char **azFilter;         /* Array of xFilter rejection GLOB patterns */\n  sqlite3_session *p;      /* The open session */\n};\n#endif\n\n/*\n** Shell output mode information from before \".explain on\",\n** saved so that it can be restored by \".explain off\"\n*/\ntypedef struct SavedModeInfo SavedModeInfo;\nstruct SavedModeInfo {\n  int valid;          /* Is there legit data in here? */\n  int mode;           /* Mode prior to \".explain on\" */\n  int showHeader;     /* The \".header\" setting prior to \".explain on\" */\n  int colWidth[100];  /* Column widths prior to \".explain on\" */\n};\n\n/*\n** State information about the database connection is contained in an\n** instance of the following structure.\n*/\ntypedef struct ShellState ShellState;\nstruct ShellState {\n  sqlite3 *db;           /* The database */\n  int autoExplain;       /* Automatically turn on .explain mode */\n  int autoEQP;           /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */\n  int statsOn;           /* True to display memory stats before each finalize */\n  int scanstatsOn;       /* True to display scan stats before each finalize */\n  int outCount;          /* Revert to stdout when reaching zero */\n  int cnt;               /* Number of records displayed so far */\n  FILE *out;             /* Write results here */\n  FILE *traceOut;        /* Output for sqlite3_trace() */\n  int nErr;              /* Number of errors seen */\n  int mode;              /* An output mode setting */\n  int cMode;             /* temporary output mode for the current query */\n  int normalMode;        /* Output mode before \".explain on\" */\n  int writableSchema;    /* True if PRAGMA writable_schema=ON */\n  int showHeader;        /* True to show column names in List or Column mode */\n  int nCheck;            /* Number of \".check\" commands run */\n  unsigned shellFlgs;    /* Various flags */\n  char *zDestTable;      /* Name of destination table when MODE_Insert */\n  char zTestcase[30];    /* Name of current test case */\n  char colSeparator[20]; /* Column separator character for several modes */\n  char rowSeparator[20]; /* Row separator character for MODE_Ascii */\n  int colWidth[100];     /* Requested width of each column when in column mode*/\n  int actualWidth[100];  /* Actual width of each column */\n  char nullValue[20];    /* The text to print when a NULL comes back from\n                         ** the database */\n  char outfile[FILENAME_MAX]; /* Filename for *out */\n  const char *zDbFilename;    /* name of the database file */\n  char *zFreeOnClose;         /* Filename to free when closing */\n  const char *zVfs;           /* Name of VFS to use */\n  sqlite3_stmt *pStmt;   /* Current statement if any. */\n  FILE *pLog;            /* Write log output here */\n  int *aiIndent;         /* Array of indents used in MODE_Explain */\n  int nIndent;           /* Size of array aiIndent[] */\n  int iIndent;           /* Index of current op in aiIndent[] */\n#if defined(SQLITE_ENABLE_SESSION)\n  int nSession;             /* Number of active sessions */\n  OpenSession aSession[4];  /* Array of sessions.  [0] is in focus. */\n#endif\n};\n\n/*\n** These are the allowed shellFlgs values\n*/\n#define SHFLG_Pagecache      0x00000001 /* The --pagecache option is used */\n#define SHFLG_Lookaside      0x00000002 /* Lookaside memory is used */\n#define SHFLG_Backslash      0x00000004 /* The --backslash option is used */\n#define SHFLG_PreserveRowid  0x00000008 /* .dump preserves rowid values */\n#define SHFLG_Newlines       0x00000010 /* .dump --newline flag */\n#define SHFLG_CountChanges   0x00000020 /* .changes setting */\n#define SHFLG_Echo           0x00000040 /* .echo or --echo setting */\n\n/*\n** Macros for testing and setting shellFlgs\n*/\n#define ShellHasFlag(P,X)    (((P)->shellFlgs & (X))!=0)\n#define ShellSetFlag(P,X)    ((P)->shellFlgs|=(X))\n#define ShellClearFlag(P,X)  ((P)->shellFlgs&=(~(X)))\n\n/*\n** These are the allowed modes.\n*/\n#define MODE_Line     0  /* One column per line.  Blank line between records */\n#define MODE_Column   1  /* One record per line in neat columns */\n#define MODE_List     2  /* One record per line with a separator */\n#define MODE_Semi     3  /* Same as MODE_List but append \";\" to each line */\n#define MODE_Html     4  /* Generate an XHTML table */\n#define MODE_Insert   5  /* Generate SQL \"insert\" statements */\n#define MODE_Quote    6  /* Quote values as for SQL */\n#define MODE_Tcl      7  /* Generate ANSI-C or TCL quoted elements */\n#define MODE_Csv      8  /* Quote strings, numbers are plain */\n#define MODE_Explain  9  /* Like MODE_Column, but do not truncate data */\n#define MODE_Ascii   10  /* Use ASCII unit and record separators (0x1F/0x1E) */\n#define MODE_Pretty  11  /* Pretty-print schemas */\n\nstatic const char *modeDescr[] = {\n  \"line\",\n  \"column\",\n  \"list\",\n  \"semi\",\n  \"html\",\n  \"insert\",\n  \"quote\",\n  \"tcl\",\n  \"csv\",\n  \"explain\",\n  \"ascii\",\n  \"prettyprint\",\n};\n\n/*\n** These are the column/row/line separators used by the various\n** import/export modes.\n*/\n#define SEP_Column    \"|\"\n#define SEP_Row       \"\\n\"\n#define SEP_Tab       \"\\t\"\n#define SEP_Space     \" \"\n#define SEP_Comma     \",\"\n#define SEP_CrLf      \"\\r\\n\"\n#define SEP_Unit      \"\\x1F\"\n#define SEP_Record    \"\\x1E\"\n\n/*\n** Number of elements in an array\n*/\n#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))\n\n/*\n** A callback for the sqlite3_log() interface.\n*/\nstatic void shellLog(void *pArg, int iErrCode, const char *zMsg){\n  ShellState *p = (ShellState*)pArg;\n  if( p->pLog==0 ) return;\n  utf8_printf(p->pLog, \"(%d) %s\\n\", iErrCode, zMsg);\n  fflush(p->pLog);\n}\n\n/*\n** Output the given string as a hex-encoded blob (eg. X'1234' )\n*/\nstatic void output_hex_blob(FILE *out, const void *pBlob, int nBlob){\n  int i;\n  char *zBlob = (char *)pBlob;\n  raw_printf(out,\"X'\");\n  for(i=0; i<nBlob; i++){ raw_printf(out,\"%02x\",zBlob[i]&0xff); }\n  raw_printf(out,\"'\");\n}\n\n/*\n** Find a string that is not found anywhere in z[].  Return a pointer\n** to that string.\n**\n** Try to use zA and zB first.  If both of those are already found in z[]\n** then make up some string and store it in the buffer zBuf.\n*/\nstatic const char *unused_string(\n  const char *z,                    /* Result must not appear anywhere in z */\n  const char *zA, const char *zB,   /* Try these first */\n  char *zBuf                        /* Space to store a generated string */\n){\n  unsigned i = 0;\n  if( strstr(z, zA)==0 ) return zA;\n  if( strstr(z, zB)==0 ) return zB;\n  do{\n    sqlite3_snprintf(20,zBuf,\"(%s%u)\", zA, i++);\n  }while( strstr(z,zBuf)!=0 );\n  return zBuf;\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n**\n** See also: output_quoted_escaped_string()\n*/\nstatic void output_quoted_string(FILE *out, const char *z){\n  int i;\n  char c;\n  setBinaryMode(out, 1);\n  for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n  if( c==0 ){\n    utf8_printf(out,\"'%s'\",z);\n  }else{\n    raw_printf(out, \"'\");\n    while( *z ){\n      for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n      if( c=='\\'' ) i++;\n      if( i ){\n        utf8_printf(out, \"%.*s\", i, z);\n        z += i;\n      }\n      if( c=='\\'' ){\n        raw_printf(out, \"'\");\n        continue;\n      }\n      if( c==0 ){\n        break;\n      }\n      z++;\n    }\n    raw_printf(out, \"'\");\n  }\n  setTextMode(out, 1);\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n** Additionallly , escape the \"\\n\" and \"\\r\" characters so that they do not\n** get corrupted by end-of-line translation facilities in some operating\n** systems.\n**\n** This is like output_quoted_string() but with the addition of the \\r\\n\n** escape mechanism.\n*/\nstatic void output_quoted_escaped_string(FILE *out, const char *z){\n  int i;\n  char c;\n  setBinaryMode(out, 1);\n  for(i=0; (c = z[i])!=0 && c!='\\'' && c!='\\n' && c!='\\r'; i++){}\n  if( c==0 ){\n    utf8_printf(out,\"'%s'\",z);\n  }else{\n    const char *zNL = 0;\n    const char *zCR = 0;\n    int nNL = 0;\n    int nCR = 0;\n    char zBuf1[20], zBuf2[20];\n    for(i=0; z[i]; i++){\n      if( z[i]=='\\n' ) nNL++;\n      if( z[i]=='\\r' ) nCR++;\n    }\n    if( nNL ){\n      raw_printf(out, \"replace(\");\n      zNL = unused_string(z, \"\\\\n\", \"\\\\012\", zBuf1);\n    }\n    if( nCR ){\n      raw_printf(out, \"replace(\");\n      zCR = unused_string(z, \"\\\\r\", \"\\\\015\", zBuf2);\n    }\n    raw_printf(out, \"'\");\n    while( *z ){\n      for(i=0; (c = z[i])!=0 && c!='\\n' && c!='\\r' && c!='\\''; i++){}\n      if( c=='\\'' ) i++;\n      if( i ){\n        utf8_printf(out, \"%.*s\", i, z);\n        z += i;\n      }\n      if( c=='\\'' ){\n        raw_printf(out, \"'\");\n        continue;\n      }\n      if( c==0 ){\n        break;\n      }\n      z++;\n      if( c=='\\n' ){\n        raw_printf(out, \"%s\", zNL);\n        continue;\n      }\n      raw_printf(out, \"%s\", zCR);\n    }\n    raw_printf(out, \"'\");\n    if( nCR ){\n      raw_printf(out, \",'%s',char(13))\", zCR);\n    }\n    if( nNL ){\n      raw_printf(out, \",'%s',char(10))\", zNL);\n    }\n  }\n  setTextMode(out, 1);\n}\n\n/*\n** Output the given string as a quoted according to C or TCL quoting rules.\n*/\nstatic void output_c_string(FILE *out, const char *z){\n  unsigned int c;\n  fputc('\"', out);\n  while( (c = *(z++))!=0 ){\n    if( c=='\\\\' ){\n      fputc(c, out);\n      fputc(c, out);\n    }else if( c=='\"' ){\n      fputc('\\\\', out);\n      fputc('\"', out);\n    }else if( c=='\\t' ){\n      fputc('\\\\', out);\n      fputc('t', out);\n    }else if( c=='\\n' ){\n      fputc('\\\\', out);\n      fputc('n', out);\n    }else if( c=='\\r' ){\n      fputc('\\\\', out);\n      fputc('r', out);\n    }else if( !isprint(c&0xff) ){\n      raw_printf(out, \"\\\\%03o\", c&0xff);\n    }else{\n      fputc(c, out);\n    }\n  }\n  fputc('\"', out);\n}\n\n/*\n** Output the given string with characters that are special to\n** HTML escaped.\n*/\nstatic void output_html_string(FILE *out, const char *z){\n  int i;\n  if( z==0 ) z = \"\";\n  while( *z ){\n    for(i=0;   z[i]\n            && z[i]!='<'\n            && z[i]!='&'\n            && z[i]!='>'\n            && z[i]!='\\\"'\n            && z[i]!='\\'';\n        i++){}\n    if( i>0 ){\n      utf8_printf(out,\"%.*s\",i,z);\n    }\n    if( z[i]=='<' ){\n      raw_printf(out,\"&lt;\");\n    }else if( z[i]=='&' ){\n      raw_printf(out,\"&amp;\");\n    }else if( z[i]=='>' ){\n      raw_printf(out,\"&gt;\");\n    }else if( z[i]=='\\\"' ){\n      raw_printf(out,\"&quot;\");\n    }else if( z[i]=='\\'' ){\n      raw_printf(out,\"&#39;\");\n    }else{\n      break;\n    }\n    z += i + 1;\n  }\n}\n\n/*\n** If a field contains any character identified by a 1 in the following\n** array, then the string must be quoted for CSV.\n*/\nstatic const char needCsvQuote[] = {\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n};\n\n/*\n** Output a single term of CSV.  Actually, p->colSeparator is used for\n** the separator, which may or may not be a comma.  p->nullValue is\n** the null value.  Strings are quoted if necessary.  The separator\n** is only issued if bSep is true.\n*/\nstatic void output_csv(ShellState *p, const char *z, int bSep){\n  FILE *out = p->out;\n  if( z==0 ){\n    utf8_printf(out,\"%s\",p->nullValue);\n  }else{\n    int i;\n    int nSep = strlen30(p->colSeparator);\n    for(i=0; z[i]; i++){\n      if( needCsvQuote[((unsigned char*)z)[i]]\n         || (z[i]==p->colSeparator[0] &&\n             (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){\n        i = 0;\n        break;\n      }\n    }\n    if( i==0 ){\n      putc('\"', out);\n      for(i=0; z[i]; i++){\n        if( z[i]=='\"' ) putc('\"', out);\n        putc(z[i], out);\n      }\n      putc('\"', out);\n    }else{\n      utf8_printf(out, \"%s\", z);\n    }\n  }\n  if( bSep ){\n    utf8_printf(p->out, \"%s\", p->colSeparator);\n  }\n}\n\n#ifdef SIGINT\n/*\n** This routine runs when the user presses Ctrl-C\n*/\nstatic void interrupt_handler(int NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  seenInterrupt++;\n  if( seenInterrupt>2 ) exit(1);\n  if( globalDb ) sqlite3_interrupt(globalDb);\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n/*\n** When the \".auth ON\" is set, the following authorizer callback is\n** invoked.  It always returns SQLITE_OK.\n*/\nstatic int shellAuth(\n  void *pClientData,\n  int op,\n  const char *zA1,\n  const char *zA2,\n  const char *zA3,\n  const char *zA4\n){\n  ShellState *p = (ShellState*)pClientData;\n  static const char *azAction[] = { 0,\n     \"CREATE_INDEX\",         \"CREATE_TABLE\",         \"CREATE_TEMP_INDEX\",\n     \"CREATE_TEMP_TABLE\",    \"CREATE_TEMP_TRIGGER\",  \"CREATE_TEMP_VIEW\",\n     \"CREATE_TRIGGER\",       \"CREATE_VIEW\",          \"DELETE\",\n     \"DROP_INDEX\",           \"DROP_TABLE\",           \"DROP_TEMP_INDEX\",\n     \"DROP_TEMP_TABLE\",      \"DROP_TEMP_TRIGGER\",    \"DROP_TEMP_VIEW\",\n     \"DROP_TRIGGER\",         \"DROP_VIEW\",            \"INSERT\",\n     \"PRAGMA\",               \"READ\",                 \"SELECT\",\n     \"TRANSACTION\",          \"UPDATE\",               \"ATTACH\",\n     \"DETACH\",               \"ALTER_TABLE\",          \"REINDEX\",\n     \"ANALYZE\",              \"CREATE_VTABLE\",        \"DROP_VTABLE\",\n     \"FUNCTION\",             \"SAVEPOINT\",            \"RECURSIVE\"\n  };\n  int i;\n  const char *az[4];\n  az[0] = zA1;\n  az[1] = zA2;\n  az[2] = zA3;\n  az[3] = zA4;\n  utf8_printf(p->out, \"authorizer: %s\", azAction[op]);\n  for(i=0; i<4; i++){\n    raw_printf(p->out, \" \");\n    if( az[i] ){\n      output_c_string(p->out, az[i]);\n    }else{\n      raw_printf(p->out, \"NULL\");\n    }\n  }\n  raw_printf(p->out, \"\\n\");\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Print a schema statement.  Part of MODE_Semi and MODE_Pretty output.\n**\n** This routine converts some CREATE TABLE statements for shadow tables\n** in FTS3/4/5 into CREATE TABLE IF NOT EXISTS statements.\n*/\nstatic void printSchemaLine(FILE *out, const char *z, const char *zTail){\n  if( sqlite3_strglob(\"CREATE TABLE ['\\\"]*\", z)==0 ){\n    utf8_printf(out, \"CREATE TABLE IF NOT EXISTS %s%s\", z+13, zTail);\n  }else{\n    utf8_printf(out, \"%s%s\", z, zTail);\n  }\n}\nstatic void printSchemaLineN(FILE *out, char *z, int n, const char *zTail){\n  char c = z[n];\n  z[n] = 0;\n  printSchemaLine(out, z, zTail);\n  z[n] = c;\n}\n\n/*\n** This is the callback routine that the shell\n** invokes for each row of a query result.\n*/\nstatic int shell_callback(\n  void *pArg,\n  int nArg,        /* Number of result columns */\n  char **azArg,    /* Text of each result column */\n  char **azCol,    /* Column names */\n  int *aiType      /* Column types */\n){\n  int i;\n  ShellState *p = (ShellState*)pArg;\n\n  if( azArg==0 ) return 0;\n  switch( p->cMode ){\n    case MODE_Line: {\n      int w = 5;\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int len = strlen30(azCol[i] ? azCol[i] : \"\");\n        if( len>w ) w = len;\n      }\n      if( p->cnt++>0 ) utf8_printf(p->out, \"%s\", p->rowSeparator);\n      for(i=0; i<nArg; i++){\n        utf8_printf(p->out,\"%*s = %s%s\", w, azCol[i],\n                azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);\n      }\n      break;\n    }\n    case MODE_Explain:\n    case MODE_Column: {\n      static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};\n      const int *colWidth;\n      int showHdr;\n      char *rowSep;\n      if( p->cMode==MODE_Column ){\n        colWidth = p->colWidth;\n        showHdr = p->showHeader;\n        rowSep = p->rowSeparator;\n      }else{\n        colWidth = aExplainWidths;\n        showHdr = 1;\n        rowSep = SEP_Row;\n      }\n      if( p->cnt++==0 ){\n        for(i=0; i<nArg; i++){\n          int w, n;\n          if( i<ArraySize(p->colWidth) ){\n            w = colWidth[i];\n          }else{\n            w = 0;\n          }\n          if( w==0 ){\n            w = strlenChar(azCol[i] ? azCol[i] : \"\");\n            if( w<10 ) w = 10;\n            n = strlenChar(azArg && azArg[i] ? azArg[i] : p->nullValue);\n            if( w<n ) w = n;\n          }\n          if( i<ArraySize(p->actualWidth) ){\n            p->actualWidth[i] = w;\n          }\n          if( showHdr ){\n            utf8_width_print(p->out, w, azCol[i]);\n            utf8_printf(p->out, \"%s\", i==nArg-1 ? rowSep : \"  \");\n          }\n        }\n        if( showHdr ){\n          for(i=0; i<nArg; i++){\n            int w;\n            if( i<ArraySize(p->actualWidth) ){\n               w = p->actualWidth[i];\n               if( w<0 ) w = -w;\n            }else{\n               w = 10;\n            }\n            utf8_printf(p->out,\"%-*.*s%s\",w,w,\n                   \"----------------------------------------------------------\"\n                   \"----------------------------------------------------------\",\n                    i==nArg-1 ? rowSep : \"  \");\n          }\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int w;\n        if( i<ArraySize(p->actualWidth) ){\n           w = p->actualWidth[i];\n        }else{\n           w = 10;\n        }\n        if( p->cMode==MODE_Explain && azArg[i] && strlenChar(azArg[i])>w ){\n          w = strlenChar(azArg[i]);\n        }\n        if( i==1 && p->aiIndent && p->pStmt ){\n          if( p->iIndent<p->nIndent ){\n            utf8_printf(p->out, \"%*.s\", p->aiIndent[p->iIndent], \"\");\n          }\n          p->iIndent++;\n        }\n        utf8_width_print(p->out, w, azArg[i] ? azArg[i] : p->nullValue);\n        utf8_printf(p->out, \"%s\", i==nArg-1 ? rowSep : \"  \");\n      }\n      break;\n    }\n    case MODE_Semi: {   /* .schema and .fullschema output */\n      printSchemaLine(p->out, azArg[0], \";\\n\");\n      break;\n    }\n    case MODE_Pretty: {  /* .schema and .fullschema with --indent */\n      char *z;\n      int j;\n      int nParen = 0;\n      char cEnd = 0;\n      char c;\n      int nLine = 0;\n      assert( nArg==1 );\n      if( azArg[0]==0 ) break;\n      if( sqlite3_strlike(\"CREATE VIEW%\", azArg[0], 0)==0\n       || sqlite3_strlike(\"CREATE TRIG%\", azArg[0], 0)==0\n      ){\n        utf8_printf(p->out, \"%s;\\n\", azArg[0]);\n        break;\n      }\n      z = sqlite3_mprintf(\"%s\", azArg[0]);\n      j = 0;\n      for(i=0; IsSpace(z[i]); i++){}\n      for(; (c = z[i])!=0; i++){\n        if( IsSpace(c) ){\n          if( z[j-1]=='\\r' ) z[j-1] = '\\n';\n          if( IsSpace(z[j-1]) || z[j-1]=='(' ) continue;\n        }else if( (c=='(' || c==')') && j>0 && IsSpace(z[j-1]) ){\n          j--;\n        }\n        z[j++] = c;\n      }\n      while( j>0 && IsSpace(z[j-1]) ){ j--; }\n      z[j] = 0;\n      if( strlen30(z)>=79 ){\n        for(i=j=0; (c = z[i])!=0; i++){\n          if( c==cEnd ){\n            cEnd = 0;\n          }else if( c=='\"' || c=='\\'' || c=='`' ){\n            cEnd = c;\n          }else if( c=='[' ){\n            cEnd = ']';\n          }else if( c=='(' ){\n            nParen++;\n          }else if( c==')' ){\n            nParen--;\n            if( nLine>0 && nParen==0 && j>0 ){\n              printSchemaLineN(p->out, z, j, \"\\n\");\n              j = 0;\n            }\n          }\n          z[j++] = c;\n          if( nParen==1 && (c=='(' || c==',' || c=='\\n') ){\n            if( c=='\\n' ) j--;\n            printSchemaLineN(p->out, z, j, \"\\n  \");\n            j = 0;\n            nLine++;\n            while( IsSpace(z[i+1]) ){ i++; }\n          }\n        }\n        z[j] = 0;\n      }\n      printSchemaLine(p->out, z, \";\\n\");\n      sqlite3_free(z);\n      break;\n    }\n    case MODE_List: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          utf8_printf(p->out,\"%s%s\",azCol[i],\n                  i==nArg-1 ? p->rowSeparator : p->colSeparator);\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        char *z = azArg[i];\n        if( z==0 ) z = p->nullValue;\n        utf8_printf(p->out, \"%s\", z);\n        if( i<nArg-1 ){\n          utf8_printf(p->out, \"%s\", p->colSeparator);\n        }else{\n          utf8_printf(p->out, \"%s\", p->rowSeparator);\n        }\n      }\n      break;\n    }\n    case MODE_Html: {\n      if( p->cnt++==0 && p->showHeader ){\n        raw_printf(p->out,\"<TR>\");\n        for(i=0; i<nArg; i++){\n          raw_printf(p->out,\"<TH>\");\n          output_html_string(p->out, azCol[i]);\n          raw_printf(p->out,\"</TH>\\n\");\n        }\n        raw_printf(p->out,\"</TR>\\n\");\n      }\n      if( azArg==0 ) break;\n      raw_printf(p->out,\"<TR>\");\n      for(i=0; i<nArg; i++){\n        raw_printf(p->out,\"<TD>\");\n        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);\n        raw_printf(p->out,\"</TD>\\n\");\n      }\n      raw_printf(p->out,\"</TR>\\n\");\n      break;\n    }\n    case MODE_Tcl: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_c_string(p->out,azCol[i] ? azCol[i] : \"\");\n          if(i<nArg-1) utf8_printf(p->out, \"%s\", p->colSeparator);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);\n        if(i<nArg-1) utf8_printf(p->out, \"%s\", p->colSeparator);\n      }\n      utf8_printf(p->out, \"%s\", p->rowSeparator);\n      break;\n    }\n    case MODE_Csv: {\n      setBinaryMode(p->out, 1);\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_csv(p, azCol[i] ? azCol[i] : \"\", i<nArg-1);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( nArg>0 ){\n        for(i=0; i<nArg; i++){\n          output_csv(p, azArg[i], i<nArg-1);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      setTextMode(p->out, 1);\n      break;\n    }\n    case MODE_Insert: {\n      if( azArg==0 ) break;\n      utf8_printf(p->out,\"INSERT INTO %s\",p->zDestTable);\n      if( p->showHeader ){\n        raw_printf(p->out,\"(\");\n        for(i=0; i<nArg; i++){\n          if( i>0 ) raw_printf(p->out, \",\");\n          if( quoteChar(azCol[i]) ){\n            char *z = sqlite3_mprintf(\"\\\"%w\\\"\", azCol[i]);\n            utf8_printf(p->out, \"%s\", z);\n            sqlite3_free(z);\n          }else{\n            raw_printf(p->out, \"%s\", azCol[i]);\n          }\n        }\n        raw_printf(p->out,\")\");\n      }\n      p->cnt++;\n      for(i=0; i<nArg; i++){\n        raw_printf(p->out, i>0 ? \",\" : \" VALUES(\");\n        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){\n          utf8_printf(p->out,\"NULL\");\n        }else if( aiType && aiType[i]==SQLITE_TEXT ){\n          if( ShellHasFlag(p, SHFLG_Newlines) ){\n            output_quoted_string(p->out, azArg[i]);\n          }else{\n            output_quoted_escaped_string(p->out, azArg[i]);\n          }\n        }else if( aiType && aiType[i]==SQLITE_INTEGER ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_FLOAT ){\n          char z[50];\n          double r = sqlite3_column_double(p->pStmt, i);\n          sqlite3_snprintf(50,z,\"%!.20g\", r);\n          raw_printf(p->out, \"%s\", z);\n        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){\n          const void *pBlob = sqlite3_column_blob(p->pStmt, i);\n          int nBlob = sqlite3_column_bytes(p->pStmt, i);\n          output_hex_blob(p->out, pBlob, nBlob);\n        }else if( isNumber(azArg[i], 0) ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( ShellHasFlag(p, SHFLG_Newlines) ){\n          output_quoted_string(p->out, azArg[i]);\n        }else{\n          output_quoted_escaped_string(p->out, azArg[i]);\n        }\n      }\n      raw_printf(p->out,\");\\n\");\n      break;\n    }\n    case MODE_Quote: {\n      if( azArg==0 ) break;\n      if( p->cnt==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          if( i>0 ) raw_printf(p->out, \",\");\n          output_quoted_string(p->out, azCol[i]);\n        }\n        raw_printf(p->out,\"\\n\");\n      }\n      p->cnt++;\n      for(i=0; i<nArg; i++){\n        if( i>0 ) raw_printf(p->out, \",\");\n        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){\n          utf8_printf(p->out,\"NULL\");\n        }else if( aiType && aiType[i]==SQLITE_TEXT ){\n          output_quoted_string(p->out, azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_INTEGER ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_FLOAT ){\n          char z[50];\n          double r = sqlite3_column_double(p->pStmt, i);\n          sqlite3_snprintf(50,z,\"%!.20g\", r);\n          raw_printf(p->out, \"%s\", z);\n        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){\n          const void *pBlob = sqlite3_column_blob(p->pStmt, i);\n          int nBlob = sqlite3_column_bytes(p->pStmt, i);\n          output_hex_blob(p->out, pBlob, nBlob);\n        }else if( isNumber(azArg[i], 0) ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else{\n          output_quoted_string(p->out, azArg[i]);\n        }\n      }\n      raw_printf(p->out,\"\\n\");\n      break;\n    }\n    case MODE_Ascii: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          if( i>0 ) utf8_printf(p->out, \"%s\", p->colSeparator);\n          utf8_printf(p->out,\"%s\",azCol[i] ? azCol[i] : \"\");\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        if( i>0 ) utf8_printf(p->out, \"%s\", p->colSeparator);\n        utf8_printf(p->out,\"%s\",azArg[i] ? azArg[i] : p->nullValue);\n      }\n      utf8_printf(p->out, \"%s\", p->rowSeparator);\n      break;\n    }\n  }\n  return 0;\n}\n\n/*\n** This is the callback routine that the SQLite library\n** invokes for each row of a query result.\n*/\nstatic int callback(void *pArg, int nArg, char **azArg, char **azCol){\n  /* since we don't have type info, call the shell_callback with a NULL value */\n  return shell_callback(pArg, nArg, azArg, azCol, NULL);\n}\n\n/*\n** This is the callback routine from sqlite3_exec() that appends all\n** output onto the end of a ShellText object.\n*/\nstatic int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){\n  ShellText *p = (ShellText*)pArg;\n  int i;\n  UNUSED_PARAMETER(az);\n  if( azArg==0 ) return 0;\n  if( p->n ) appendText(p, \"|\", 0);\n  for(i=0; i<nArg; i++){\n    if( i ) appendText(p, \",\", 0);\n    if( azArg[i] ) appendText(p, azArg[i], 0);\n  }\n  return 0;\n}\n\n/*\n** Generate an appropriate SELFTEST table in the main database.\n*/\nstatic void createSelftestTable(ShellState *p){\n  char *zErrMsg = 0;\n  sqlite3_exec(p->db,\n    \"SAVEPOINT selftest_init;\\n\"\n    \"CREATE TABLE IF NOT EXISTS selftest(\\n\"\n    \"  tno INTEGER PRIMARY KEY,\\n\"   /* Test number */\n    \"  op TEXT,\\n\"                   /* Operator:  memo run */\n    \"  cmd TEXT,\\n\"                  /* Command text */\n    \"  ans TEXT\\n\"                   /* Desired answer */\n    \");\"\n    \"CREATE TEMP TABLE [_shell$self](op,cmd,ans);\\n\"\n    \"INSERT INTO [_shell$self](rowid,op,cmd)\\n\"\n    \"  VALUES(coalesce((SELECT (max(tno)+100)/10 FROM selftest),10),\\n\"\n    \"         'memo','Tests generated by --init');\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  SELECT 'run',\\n\"\n    \"    'SELECT hex(sha3_query(''SELECT type,name,tbl_name,sql \"\n                                 \"FROM sqlite_master ORDER BY 2'',224))',\\n\"\n    \"    hex(sha3_query('SELECT type,name,tbl_name,sql \"\n                          \"FROM sqlite_master ORDER BY 2',224));\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  SELECT 'run',\"\n    \"    'SELECT hex(sha3_query(''SELECT * FROM \\\"' ||\"\n    \"        printf('%w',name) || '\\\" NOT INDEXED'',224))',\\n\"\n    \"    hex(sha3_query(printf('SELECT * FROM \\\"%w\\\" NOT INDEXED',name),224))\\n\"\n    \"  FROM (\\n\"\n    \"    SELECT name FROM sqlite_master\\n\"\n    \"     WHERE type='table'\\n\"\n    \"       AND name<>'selftest'\\n\"\n    \"       AND coalesce(rootpage,0)>0\\n\"\n    \"  )\\n\"\n    \" ORDER BY name;\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  VALUES('run','PRAGMA integrity_check','ok');\\n\"\n    \"INSERT INTO selftest(tno,op,cmd,ans)\"\n    \"  SELECT rowid*10,op,cmd,ans FROM [_shell$self];\\n\"\n    \"DROP TABLE [_shell$self];\"\n    ,0,0,&zErrMsg);\n  if( zErrMsg ){\n    utf8_printf(stderr, \"SELFTEST initialization failure: %s\\n\", zErrMsg);\n    sqlite3_free(zErrMsg);\n  }\n  sqlite3_exec(p->db, \"RELEASE selftest_init\",0,0,0);\n}\n\n\n/*\n** Set the destination table field of the ShellState structure to\n** the name of the table given.  Escape any quote characters in the\n** table name.\n*/\nstatic void set_table_name(ShellState *p, const char *zName){\n  int i, n;\n  char cQuote;\n  char *z;\n\n  if( p->zDestTable ){\n    free(p->zDestTable);\n    p->zDestTable = 0;\n  }\n  if( zName==0 ) return;\n  cQuote = quoteChar(zName);\n  n = strlen30(zName);\n  if( cQuote ) n += n+2;\n  z = p->zDestTable = malloc( n+1 );\n  if( z==0 ){\n    raw_printf(stderr,\"Error: out of memory\\n\");\n    exit(1);\n  }\n  n = 0;\n  if( cQuote ) z[n++] = cQuote;\n  for(i=0; zName[i]; i++){\n    z[n++] = zName[i];\n    if( zName[i]==cQuote ) z[n++] = cQuote;\n  }\n  if( cQuote ) z[n++] = cQuote;\n  z[n] = 0;\n}\n\n\n/*\n** Execute a query statement that will generate SQL output.  Print\n** the result columns, comma-separated, on a line and then add a\n** semicolon terminator to the end of that line.\n**\n** If the number of columns is 1 and that column contains text \"--\"\n** then write the semicolon on a separate line.  That way, if a\n** \"--\" comment occurs at the end of the statement, the comment\n** won't consume the semicolon terminator.\n*/\nstatic int run_table_dump_query(\n  ShellState *p,           /* Query context */\n  const char *zSelect,     /* SELECT statement to extract content */\n  const char *zFirstRow    /* Print before first row, if not NULL */\n){\n  sqlite3_stmt *pSelect;\n  int rc;\n  int nResult;\n  int i;\n  const char *z;\n  rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);\n  if( rc!=SQLITE_OK || !pSelect ){\n    utf8_printf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;\n    return rc;\n  }\n  rc = sqlite3_step(pSelect);\n  nResult = sqlite3_column_count(pSelect);\n  while( rc==SQLITE_ROW ){\n    if( zFirstRow ){\n      utf8_printf(p->out, \"%s\", zFirstRow);\n      zFirstRow = 0;\n    }\n    z = (const char*)sqlite3_column_text(pSelect, 0);\n    utf8_printf(p->out, \"%s\", z);\n    for(i=1; i<nResult; i++){\n      utf8_printf(p->out, \",%s\", sqlite3_column_text(pSelect, i));\n    }\n    if( z==0 ) z = \"\";\n    while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;\n    if( z[0] ){\n      raw_printf(p->out, \"\\n;\\n\");\n    }else{\n      raw_printf(p->out, \";\\n\");\n    }\n    rc = sqlite3_step(pSelect);\n  }\n  rc = sqlite3_finalize(pSelect);\n  if( rc!=SQLITE_OK ){\n    utf8_printf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;\n  }\n  return rc;\n}\n\n/*\n** Allocate space and save off current error string.\n*/\nstatic char *save_err_msg(\n  sqlite3 *db            /* Database to query */\n){\n  int nErrMsg = 1+strlen30(sqlite3_errmsg(db));\n  char *zErrMsg = sqlite3_malloc64(nErrMsg);\n  if( zErrMsg ){\n    memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);\n  }\n  return zErrMsg;\n}\n\n#ifdef __linux__\n/*\n** Attempt to display I/O stats on Linux using /proc/PID/io\n*/\nstatic void displayLinuxIoStats(FILE *out){\n  FILE *in;\n  char z[200];\n  sqlite3_snprintf(sizeof(z), z, \"/proc/%d/io\", getpid());\n  in = fopen(z, \"rb\");\n  if( in==0 ) return;\n  while( fgets(z, sizeof(z), in)!=0 ){\n    static const struct {\n      const char *zPattern;\n      const char *zDesc;\n    } aTrans[] = {\n      { \"rchar: \",                  \"Bytes received by read():\" },\n      { \"wchar: \",                  \"Bytes sent to write():\"    },\n      { \"syscr: \",                  \"Read() system calls:\"      },\n      { \"syscw: \",                  \"Write() system calls:\"     },\n      { \"read_bytes: \",             \"Bytes read from storage:\"  },\n      { \"write_bytes: \",            \"Bytes written to storage:\" },\n      { \"cancelled_write_bytes: \",  \"Cancelled write bytes:\"    },\n    };\n    int i;\n    for(i=0; i<ArraySize(aTrans); i++){\n      int n = (int)strlen(aTrans[i].zPattern);\n      if( strncmp(aTrans[i].zPattern, z, n)==0 ){\n        utf8_printf(out, \"%-36s %s\", aTrans[i].zDesc, &z[n]);\n        break;\n      }\n    }\n  }\n  fclose(in);\n}\n#endif\n\n/*\n** Display a single line of status using 64-bit values.\n*/\nstatic void displayStatLine(\n  ShellState *p,            /* The shell context */\n  char *zLabel,             /* Label for this one line */\n  char *zFormat,            /* Format for the result */\n  int iStatusCtrl,          /* Which status to display */\n  int bReset                /* True to reset the stats */\n){\n  sqlite3_int64 iCur = -1;\n  sqlite3_int64 iHiwtr = -1;\n  int i, nPercent;\n  char zLine[200];\n  sqlite3_status64(iStatusCtrl, &iCur, &iHiwtr, bReset);\n  for(i=0, nPercent=0; zFormat[i]; i++){\n    if( zFormat[i]=='%' ) nPercent++;\n  }\n  if( nPercent>1 ){\n    sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iCur, iHiwtr);\n  }else{\n    sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iHiwtr);\n  }\n  raw_printf(p->out, \"%-36s %s\\n\", zLabel, zLine);\n}\n\n/*\n** Display memory stats.\n*/\nstatic int display_stats(\n  sqlite3 *db,                /* Database to query */\n  ShellState *pArg,           /* Pointer to ShellState */\n  int bReset                  /* True to reset the stats */\n){\n  int iCur;\n  int iHiwtr;\n\n  if( pArg && pArg->out ){\n    displayStatLine(pArg, \"Memory Used:\",\n       \"%lld (max %lld) bytes\", SQLITE_STATUS_MEMORY_USED, bReset);\n    displayStatLine(pArg, \"Number of Outstanding Allocations:\",\n       \"%lld (max %lld)\", SQLITE_STATUS_MALLOC_COUNT, bReset);\n    if( pArg->shellFlgs & SHFLG_Pagecache ){\n      displayStatLine(pArg, \"Number of Pcache Pages Used:\",\n         \"%lld (max %lld) pages\", SQLITE_STATUS_PAGECACHE_USED, bReset);\n    }\n    displayStatLine(pArg, \"Number of Pcache Overflow Bytes:\",\n       \"%lld (max %lld) bytes\", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset);\n    displayStatLine(pArg, \"Largest Allocation:\",\n       \"%lld bytes\", SQLITE_STATUS_MALLOC_SIZE, bReset);\n    displayStatLine(pArg, \"Largest Pcache Allocation:\",\n       \"%lld bytes\", SQLITE_STATUS_PAGECACHE_SIZE, bReset);\n#ifdef YYTRACKMAXSTACKDEPTH\n    displayStatLine(pArg, \"Deepest Parser Stack:\",\n       \"%lld (max %lld)\", SQLITE_STATUS_PARSER_STACK, bReset);\n#endif\n  }\n\n  if( pArg && pArg->out && db ){\n    if( pArg->shellFlgs & SHFLG_Lookaside ){\n      iHiwtr = iCur = -1;\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out,\n              \"Lookaside Slots Used:                %d (max %d)\\n\",\n              iCur, iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Successful lookaside attempts:       %d\\n\",\n              iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Lookaside failures due to size:      %d\\n\",\n              iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Lookaside failures due to OOM:       %d\\n\",\n              iHiwtr);\n    }\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Pager Heap Usage:                    %d bytes\\n\",\n            iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache hits:                     %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache misses:                   %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache writes:                   %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Schema Heap Usage:                   %d bytes\\n\",\n            iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Statement Heap/Lookaside Usage:      %d bytes\\n\",\n            iCur);\n  }\n\n  if( pArg && pArg->out && db && pArg->pStmt ){\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,\n                               bReset);\n    raw_printf(pArg->out, \"Fullscan Steps:                      %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);\n    raw_printf(pArg->out, \"Sort Operations:                     %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);\n    raw_printf(pArg->out, \"Autoindex Inserts:                   %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);\n    raw_printf(pArg->out, \"Virtual Machine Steps:               %d\\n\", iCur);\n  }\n\n#ifdef __linux__\n  displayLinuxIoStats(pArg->out);\n#endif\n\n  /* Do not remove this machine readable comment: extra-stats-output-here */\n\n  return 0;\n}\n\n/*\n** Display scan stats.\n*/\nstatic void display_scanstats(\n  sqlite3 *db,                    /* Database to query */\n  ShellState *pArg                /* Pointer to ShellState */\n){\n#ifndef SQLITE_ENABLE_STMT_SCANSTATUS\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pArg);\n#else\n  int i, k, n, mx;\n  raw_printf(pArg->out, \"-------- scanstats --------\\n\");\n  mx = 0;\n  for(k=0; k<=mx; k++){\n    double rEstLoop = 1.0;\n    for(i=n=0; 1; i++){\n      sqlite3_stmt *p = pArg->pStmt;\n      sqlite3_int64 nLoop, nVisit;\n      double rEst;\n      int iSid;\n      const char *zExplain;\n      if( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop) ){\n        break;\n      }\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_SELECTID, (void*)&iSid);\n      if( iSid>mx ) mx = iSid;\n      if( iSid!=k ) continue;\n      if( n==0 ){\n        rEstLoop = (double)nLoop;\n        if( k>0 ) raw_printf(pArg->out, \"-------- subquery %d -------\\n\", k);\n      }\n      n++;\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);\n      utf8_printf(pArg->out, \"Loop %2d: %s\\n\", n, zExplain);\n      rEstLoop *= rEst;\n      raw_printf(pArg->out,\n          \"         nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\\n\",\n          nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst\n      );\n    }\n  }\n  raw_printf(pArg->out, \"---------------------------\\n\");\n#endif\n}\n\n/*\n** Parameter azArray points to a zero-terminated array of strings. zStr\n** points to a single nul-terminated string. Return non-zero if zStr\n** is equal, according to strcmp(), to any of the strings in the array.\n** Otherwise, return zero.\n*/\nstatic int str_in_array(const char *zStr, const char **azArray){\n  int i;\n  for(i=0; azArray[i]; i++){\n    if( 0==strcmp(zStr, azArray[i]) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** If compiled statement pSql appears to be an EXPLAIN statement, allocate\n** and populate the ShellState.aiIndent[] array with the number of\n** spaces each opcode should be indented before it is output.\n**\n** The indenting rules are:\n**\n**     * For each \"Next\", \"Prev\", \"VNext\" or \"VPrev\" instruction, indent\n**       all opcodes that occur between the p2 jump destination and the opcode\n**       itself by 2 spaces.\n**\n**     * For each \"Goto\", if the jump destination is earlier in the program\n**       and ends on one of:\n**          Yield  SeekGt  SeekLt  RowSetRead  Rewind\n**       or if the P1 parameter is one instead of zero,\n**       then indent all opcodes between the earlier instruction\n**       and \"Goto\" by 2 spaces.\n*/\nstatic void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){\n  const char *zSql;               /* The text of the SQL statement */\n  const char *z;                  /* Used to check if this is an EXPLAIN */\n  int *abYield = 0;               /* True if op is an OP_Yield */\n  int nAlloc = 0;                 /* Allocated size of p->aiIndent[], abYield */\n  int iOp;                        /* Index of operation in p->aiIndent[] */\n\n  const char *azNext[] = { \"Next\", \"Prev\", \"VPrev\", \"VNext\", \"SorterNext\",\n                           \"NextIfOpen\", \"PrevIfOpen\", 0 };\n  const char *azYield[] = { \"Yield\", \"SeekLT\", \"SeekGT\", \"RowSetRead\",\n                            \"Rewind\", 0 };\n  const char *azGoto[] = { \"Goto\", 0 };\n\n  /* Try to figure out if this is really an EXPLAIN statement. If this\n  ** cannot be verified, return early.  */\n  if( sqlite3_column_count(pSql)!=8 ){\n    p->cMode = p->mode;\n    return;\n  }\n  zSql = sqlite3_sql(pSql);\n  if( zSql==0 ) return;\n  for(z=zSql; *z==' ' || *z=='\\t' || *z=='\\n' || *z=='\\f' || *z=='\\r'; z++);\n  if( sqlite3_strnicmp(z, \"explain\", 7) ){\n    p->cMode = p->mode;\n    return;\n  }\n\n  for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){\n    int i;\n    int iAddr = sqlite3_column_int(pSql, 0);\n    const char *zOp = (const char*)sqlite3_column_text(pSql, 1);\n\n    /* Set p2 to the P2 field of the current opcode. Then, assuming that\n    ** p2 is an instruction address, set variable p2op to the index of that\n    ** instruction in the aiIndent[] array. p2 and p2op may be different if\n    ** the current instruction is part of a sub-program generated by an\n    ** SQL trigger or foreign key.  */\n    int p2 = sqlite3_column_int(pSql, 3);\n    int p2op = (p2 + (iOp-iAddr));\n\n    /* Grow the p->aiIndent array as required */\n    if( iOp>=nAlloc ){\n      if( iOp==0 ){\n        /* Do further verfication that this is explain output.  Abort if\n        ** it is not */\n        static const char *explainCols[] = {\n           \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\" };\n        int jj;\n        for(jj=0; jj<ArraySize(explainCols); jj++){\n          if( strcmp(sqlite3_column_name(pSql,jj),explainCols[jj])!=0 ){\n            p->cMode = p->mode;\n            sqlite3_reset(pSql);\n            return;\n          }\n        }\n      }\n      nAlloc += 100;\n      p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));\n      abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));\n    }\n    abYield[iOp] = str_in_array(zOp, azYield);\n    p->aiIndent[iOp] = 0;\n    p->nIndent = iOp+1;\n\n    if( str_in_array(zOp, azNext) ){\n      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;\n    }\n    if( str_in_array(zOp, azGoto) && p2op<p->nIndent\n     && (abYield[p2op] || sqlite3_column_int(pSql, 2))\n    ){\n      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;\n    }\n  }\n\n  p->iIndent = 0;\n  sqlite3_free(abYield);\n  sqlite3_reset(pSql);\n}\n\n/*\n** Free the array allocated by explain_data_prepare().\n*/\nstatic void explain_data_delete(ShellState *p){\n  sqlite3_free(p->aiIndent);\n  p->aiIndent = 0;\n  p->nIndent = 0;\n  p->iIndent = 0;\n}\n\n/*\n** Disable and restore .wheretrace and .selecttrace settings.\n*/\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\nextern int sqlite3SelectTrace;\nstatic int savedSelectTrace;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\nextern int sqlite3WhereTrace;\nstatic int savedWhereTrace;\n#endif\nstatic void disable_debug_trace_modes(void){\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  savedSelectTrace = sqlite3SelectTrace;\n  sqlite3SelectTrace = 0;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  savedWhereTrace = sqlite3WhereTrace;\n  sqlite3WhereTrace = 0;\n#endif\n}\nstatic void restore_debug_trace_modes(void){\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  sqlite3SelectTrace = savedSelectTrace;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  sqlite3WhereTrace = savedWhereTrace;\n#endif\n}\n\n/*\n** Run a prepared statement\n*/\nstatic void exec_prepared_stmt(\n  ShellState *pArg,                                /* Pointer to ShellState */\n  sqlite3_stmt *pStmt,                             /* Statment to run */\n  int (*xCallback)(void*,int,char**,char**,int*)   /* Callback function */\n){\n  int rc;\n\n  /* perform the first step.  this will tell us if we\n  ** have a result set or not and how wide it is.\n  */\n  rc = sqlite3_step(pStmt);\n  /* if we have a result set... */\n  if( SQLITE_ROW == rc ){\n    /* if we have a callback... */\n    if( xCallback ){\n      /* allocate space for col name ptr, value ptr, and type */\n      int nCol = sqlite3_column_count(pStmt);\n      void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);\n      if( !pData ){\n        rc = SQLITE_NOMEM;\n      }else{\n        char **azCols = (char **)pData;      /* Names of result columns */\n        char **azVals = &azCols[nCol];       /* Results */\n        int *aiTypes = (int *)&azVals[nCol]; /* Result types */\n        int i, x;\n        assert(sizeof(int) <= sizeof(char *));\n        /* save off ptrs to column names */\n        for(i=0; i<nCol; i++){\n          azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n        }\n        do{\n          /* extract the data and data types */\n          for(i=0; i<nCol; i++){\n            aiTypes[i] = x = sqlite3_column_type(pStmt, i);\n            if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){\n              azVals[i] = \"\";\n            }else{\n              azVals[i] = (char*)sqlite3_column_text(pStmt, i);\n            }\n            if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){\n              rc = SQLITE_NOMEM;\n              break; /* from for */\n            }\n          } /* end for */\n\n          /* if data and types extracted successfully... */\n          if( SQLITE_ROW == rc ){\n            /* call the supplied callback with the result row data */\n            if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){\n              rc = SQLITE_ABORT;\n            }else{\n              rc = sqlite3_step(pStmt);\n            }\n          }\n        } while( SQLITE_ROW == rc );\n        sqlite3_free(pData);\n      }\n    }else{\n      do{\n        rc = sqlite3_step(pStmt);\n      } while( rc == SQLITE_ROW );\n    }\n  }\n}\n\n/*\n** Execute a statement or set of statements.  Print\n** any result rows/columns depending on the current mode\n** set via the supplied callback.\n**\n** This is very similar to SQLite's built-in sqlite3_exec()\n** function except it takes a slightly different callback\n** and callback data argument.\n*/\nstatic int shell_exec(\n  sqlite3 *db,                              /* An open database */\n  const char *zSql,                         /* SQL to be evaluated */\n  int (*xCallback)(void*,int,char**,char**,int*),   /* Callback function */\n                                            /* (not the same as sqlite3_exec) */\n  ShellState *pArg,                         /* Pointer to ShellState */\n  char **pzErrMsg                           /* Error msg written here */\n){\n  sqlite3_stmt *pStmt = NULL;     /* Statement to execute. */\n  int rc = SQLITE_OK;             /* Return Code */\n  int rc2;\n  const char *zLeftover;          /* Tail of unprocessed SQL */\n\n  if( pzErrMsg ){\n    *pzErrMsg = NULL;\n  }\n\n  while( zSql[0] && (SQLITE_OK == rc) ){\n    static const char *zStmtSql;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    if( SQLITE_OK != rc ){\n      if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n    }else{\n      if( !pStmt ){\n        /* this happens for a comment or white-space */\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n        continue;\n      }\n      zStmtSql = sqlite3_sql(pStmt);\n      if( zStmtSql==0 ) zStmtSql = \"\";\n      while( IsSpace(zStmtSql[0]) ) zStmtSql++;\n\n      /* save off the prepared statment handle and reset row count */\n      if( pArg ){\n        pArg->pStmt = pStmt;\n        pArg->cnt = 0;\n      }\n\n      /* echo the sql statement if echo on */\n      if( pArg && ShellHasFlag(pArg, SHFLG_Echo) ){\n        utf8_printf(pArg->out, \"%s\\n\", zStmtSql ? zStmtSql : zSql);\n      }\n\n      /* Show the EXPLAIN QUERY PLAN if .eqp is on */\n      if( pArg && pArg->autoEQP && sqlite3_strlike(\"EXPLAIN%\",zStmtSql,0)!=0 ){\n        sqlite3_stmt *pExplain;\n        char *zEQP;\n        disable_debug_trace_modes();\n        zEQP = sqlite3_mprintf(\"EXPLAIN QUERY PLAN %s\", zStmtSql);\n        rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n        if( rc==SQLITE_OK ){\n          while( sqlite3_step(pExplain)==SQLITE_ROW ){\n            raw_printf(pArg->out,\"--EQP-- %d,\",sqlite3_column_int(pExplain, 0));\n            raw_printf(pArg->out,\"%d,\", sqlite3_column_int(pExplain, 1));\n            raw_printf(pArg->out,\"%d,\", sqlite3_column_int(pExplain, 2));\n            utf8_printf(pArg->out,\"%s\\n\", sqlite3_column_text(pExplain, 3));\n          }\n        }\n        sqlite3_finalize(pExplain);\n        sqlite3_free(zEQP);\n        if( pArg->autoEQP>=2 ){\n          /* Also do an EXPLAIN for \".eqp full\" mode */\n          zEQP = sqlite3_mprintf(\"EXPLAIN %s\", zStmtSql);\n          rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n          if( rc==SQLITE_OK ){\n            pArg->cMode = MODE_Explain;\n            explain_data_prepare(pArg, pExplain);\n            exec_prepared_stmt(pArg, pExplain, xCallback);\n            explain_data_delete(pArg);\n          }\n          sqlite3_finalize(pExplain);\n          sqlite3_free(zEQP);\n        }\n        restore_debug_trace_modes();\n      }\n\n      if( pArg ){\n        pArg->cMode = pArg->mode;\n        if( pArg->autoExplain\n         && sqlite3_column_count(pStmt)==8\n         && sqlite3_strlike(\"EXPLAIN%\", zStmtSql,0)==0\n        ){\n          pArg->cMode = MODE_Explain;\n        }\n\n        /* If the shell is currently in \".explain\" mode, gather the extra\n        ** data required to add indents to the output.*/\n        if( pArg->cMode==MODE_Explain ){\n          explain_data_prepare(pArg, pStmt);\n        }\n      }\n\n      exec_prepared_stmt(pArg, pStmt, xCallback);\n      explain_data_delete(pArg);\n\n      /* print usage stats if stats on */\n      if( pArg && pArg->statsOn ){\n        display_stats(db, pArg, 0);\n      }\n\n      /* print loop-counters if required */\n      if( pArg && pArg->scanstatsOn ){\n        display_scanstats(db, pArg);\n      }\n\n      /* Finalize the statement just executed. If this fails, save a\n      ** copy of the error message. Otherwise, set zSql to point to the\n      ** next statement to execute. */\n      rc2 = sqlite3_finalize(pStmt);\n      if( rc!=SQLITE_NOMEM ) rc = rc2;\n      if( rc==SQLITE_OK ){\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n      }else if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n\n      /* clear saved stmt handle */\n      if( pArg ){\n        pArg->pStmt = NULL;\n      }\n    }\n  } /* end while */\n\n  return rc;\n}\n\n/*\n** Release memory previously allocated by tableColumnList().\n*/\nstatic void freeColumnList(char **azCol){\n  int i;\n  for(i=1; azCol[i]; i++){\n    sqlite3_free(azCol[i]);\n  }\n  /* azCol[0] is a static string */\n  sqlite3_free(azCol);\n}\n\n/*\n** Return a list of pointers to strings which are the names of all\n** columns in table zTab.   The memory to hold the names is dynamically\n** allocated and must be released by the caller using a subsequent call\n** to freeColumnList().\n**\n** The azCol[0] entry is usually NULL.  However, if zTab contains a rowid\n** value that needs to be preserved, then azCol[0] is filled in with the\n** name of the rowid column.\n**\n** The first regular column in the table is azCol[1].  The list is terminated\n** by an entry with azCol[i]==0.\n*/\nstatic char **tableColumnList(ShellState *p, const char *zTab){\n  char **azCol = 0;\n  sqlite3_stmt *pStmt;\n  char *zSql;\n  int nCol = 0;\n  int nAlloc = 0;\n  int nPK = 0;       /* Number of PRIMARY KEY columns seen */\n  int isIPK = 0;     /* True if one PRIMARY KEY column of type INTEGER */\n  int preserveRowid = ShellHasFlag(p, SHFLG_PreserveRowid);\n  int rc;\n\n  zSql = sqlite3_mprintf(\"PRAGMA table_info=%Q\", zTab);\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ) return 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    if( nCol>=nAlloc-2 ){\n      nAlloc = nAlloc*2 + nCol + 10;\n      azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));\n      if( azCol==0 ){\n        raw_printf(stderr, \"Error: out of memory\\n\");\n        exit(1);\n      }\n    }\n    azCol[++nCol] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 1));\n    if( sqlite3_column_int(pStmt, 5) ){\n      nPK++;\n      if( nPK==1\n       && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),\n                          \"INTEGER\")==0\n      ){\n        isIPK = 1;\n      }else{\n        isIPK = 0;\n      }\n    }\n  }\n  sqlite3_finalize(pStmt);\n  if( azCol==0 ) return 0;\n  azCol[0] = 0;\n  azCol[nCol+1] = 0;\n\n  /* The decision of whether or not a rowid really needs to be preserved\n  ** is tricky.  We never need to preserve a rowid for a WITHOUT ROWID table\n  ** or a table with an INTEGER PRIMARY KEY.  We are unable to preserve\n  ** rowids on tables where the rowid is inaccessible because there are other\n  ** columns in the table named \"rowid\", \"_rowid_\", and \"oid\".\n  */\n  if( preserveRowid && isIPK ){\n    /* If a single PRIMARY KEY column with type INTEGER was seen, then it\n    ** might be an alise for the ROWID.  But it might also be a WITHOUT ROWID\n    ** table or a INTEGER PRIMARY KEY DESC column, neither of which are\n    ** ROWID aliases.  To distinguish these cases, check to see if\n    ** there is a \"pk\" entry in \"PRAGMA index_list\".  There will be\n    ** no \"pk\" index if the PRIMARY KEY really is an alias for the ROWID.\n    */\n    zSql = sqlite3_mprintf(\"SELECT 1 FROM pragma_index_list(%Q)\"\n                           \" WHERE origin='pk'\", zTab);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      freeColumnList(azCol);\n      return 0;\n    }\n    rc = sqlite3_step(pStmt);\n    sqlite3_finalize(pStmt);\n    preserveRowid = rc==SQLITE_ROW;\n  }\n  if( preserveRowid ){\n    /* Only preserve the rowid if we can find a name to use for the\n    ** rowid */\n    static char *azRowid[] = { \"rowid\", \"_rowid_\", \"oid\" };\n    int i, j;\n    for(j=0; j<3; j++){\n      for(i=1; i<=nCol; i++){\n        if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break;\n      }\n      if( i>nCol ){\n        /* At this point, we know that azRowid[j] is not the name of any\n        ** ordinary column in the table.  Verify that azRowid[j] is a valid\n        ** name for the rowid before adding it to azCol[0].  WITHOUT ROWID\n        ** tables will fail this last check */\n        rc = sqlite3_table_column_metadata(p->db,0,zTab,azRowid[j],0,0,0,0,0);\n        if( rc==SQLITE_OK ) azCol[0] = azRowid[j];\n        break;\n      }\n    }\n  }\n  return azCol;\n}\n\n/*\n** Toggle the reverse_unordered_selects setting.\n*/\nstatic void toggleSelectOrder(sqlite3 *db){\n  sqlite3_stmt *pStmt = 0;\n  int iSetting = 0;\n  char zStmt[100];\n  sqlite3_prepare_v2(db, \"PRAGMA reverse_unordered_selects\", -1, &pStmt, 0);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    iSetting = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_snprintf(sizeof(zStmt), zStmt,\n       \"PRAGMA reverse_unordered_selects(%d)\", !iSetting);\n  sqlite3_exec(db, zStmt, 0, 0, 0);\n}\n\n/*\n** This is a different callback routine used for dumping the database.\n** Each row received by this callback consists of a table name,\n** the table type (\"index\" or \"table\") and SQL to create the table.\n** This routine should print text sufficient to recreate the table.\n*/\nstatic int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){\n  int rc;\n  const char *zTable;\n  const char *zType;\n  const char *zSql;\n  ShellState *p = (ShellState *)pArg;\n\n  UNUSED_PARAMETER(azNotUsed);\n  if( nArg!=3 || azArg==0 ) return 0;\n  zTable = azArg[0];\n  zType = azArg[1];\n  zSql = azArg[2];\n\n  if( strcmp(zTable, \"sqlite_sequence\")==0 ){\n    raw_printf(p->out, \"DELETE FROM sqlite_sequence;\\n\");\n  }else if( sqlite3_strglob(\"sqlite_stat?\", zTable)==0 ){\n    raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n  }else if( strncmp(zTable, \"sqlite_\", 7)==0 ){\n    return 0;\n  }else if( strncmp(zSql, \"CREATE VIRTUAL TABLE\", 20)==0 ){\n    char *zIns;\n    if( !p->writableSchema ){\n      raw_printf(p->out, \"PRAGMA writable_schema=ON;\\n\");\n      p->writableSchema = 1;\n    }\n    zIns = sqlite3_mprintf(\n       \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n       \"VALUES('table','%q','%q',0,'%q');\",\n       zTable, zTable, zSql);\n    utf8_printf(p->out, \"%s\\n\", zIns);\n    sqlite3_free(zIns);\n    return 0;\n  }else{\n    printSchemaLine(p->out, zSql, \";\\n\");\n  }\n\n  if( strcmp(zType, \"table\")==0 ){\n    ShellText sSelect;\n    ShellText sTable;\n    char **azCol;\n    int i;\n    char *savedDestTable;\n    int savedMode;\n\n    azCol = tableColumnList(p, zTable);\n    if( azCol==0 ){\n      p->nErr++;\n      return 0;\n    }\n\n    /* Always quote the table name, even if it appears to be pure ascii,\n    ** in case it is a keyword. Ex:  INSERT INTO \"table\" ... */\n    initText(&sTable);\n    appendText(&sTable, zTable, quoteChar(zTable));\n    /* If preserving the rowid, add a column list after the table name.\n    ** In other words:  \"INSERT INTO tab(rowid,a,b,c,...) VALUES(...)\"\n    ** instead of the usual \"INSERT INTO tab VALUES(...)\".\n    */\n    if( azCol[0] ){\n      appendText(&sTable, \"(\", 0);\n      appendText(&sTable, azCol[0], 0);\n      for(i=1; azCol[i]; i++){\n        appendText(&sTable, \",\", 0);\n        appendText(&sTable, azCol[i], quoteChar(azCol[i]));\n      }\n      appendText(&sTable, \")\", 0);\n    }\n\n    /* Build an appropriate SELECT statement */\n    initText(&sSelect);\n    appendText(&sSelect, \"SELECT \", 0);\n    if( azCol[0] ){\n      appendText(&sSelect, azCol[0], 0);\n      appendText(&sSelect, \",\", 0);\n    }\n    for(i=1; azCol[i]; i++){\n      appendText(&sSelect, azCol[i], quoteChar(azCol[i]));\n      if( azCol[i+1] ){\n        appendText(&sSelect, \",\", 0);\n      }\n    }\n    freeColumnList(azCol);\n    appendText(&sSelect, \" FROM \", 0);\n    appendText(&sSelect, zTable, quoteChar(zTable));\n\n    savedDestTable = p->zDestTable;\n    savedMode = p->mode;\n    p->zDestTable = sTable.z;\n    p->mode = p->cMode = MODE_Insert;\n    rc = shell_exec(p->db, sSelect.z, shell_callback, p, 0);\n    if( (rc&0xff)==SQLITE_CORRUPT ){\n      raw_printf(p->out, \"/****** CORRUPTION ERROR *******/\\n\");\n      toggleSelectOrder(p->db);\n      shell_exec(p->db, sSelect.z, shell_callback, p, 0);\n      toggleSelectOrder(p->db);\n    }\n    p->zDestTable = savedDestTable;\n    p->mode = savedMode;\n    freeText(&sTable);\n    freeText(&sSelect);\n    if( rc ) p->nErr++;\n  }\n  return 0;\n}\n\n/*\n** Run zQuery.  Use dump_callback() as the callback routine so that\n** the contents of the query are output as SQL statements.\n**\n** If we get a SQLITE_CORRUPT error, rerun the query after appending\n** \"ORDER BY rowid DESC\" to the end.\n*/\nstatic int run_schema_dump_query(\n  ShellState *p,\n  const char *zQuery\n){\n  int rc;\n  char *zErr = 0;\n  rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);\n  if( rc==SQLITE_CORRUPT ){\n    char *zQ2;\n    int len = strlen30(zQuery);\n    raw_printf(p->out, \"/****** CORRUPTION ERROR *******/\\n\");\n    if( zErr ){\n      utf8_printf(p->out, \"/****** %s ******/\\n\", zErr);\n      sqlite3_free(zErr);\n      zErr = 0;\n    }\n    zQ2 = malloc( len+100 );\n    if( zQ2==0 ) return rc;\n    sqlite3_snprintf(len+100, zQ2, \"%s ORDER BY rowid DESC\", zQuery);\n    rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);\n    if( rc ){\n      utf8_printf(p->out, \"/****** ERROR: %s ******/\\n\", zErr);\n    }else{\n      rc = SQLITE_CORRUPT;\n    }\n    sqlite3_free(zErr);\n    free(zQ2);\n  }\n  return rc;\n}\n\n/*\n** Text of a help message\n*/\nstatic char zHelp[] =\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  \".auth ON|OFF           Show authorizer callbacks\\n\"\n#endif\n  \".backup ?DB? FILE      Backup DB (default \\\"main\\\") to FILE\\n\"\n  \".bail on|off           Stop after hitting an error.  Default OFF\\n\"\n  \".binary on|off         Turn binary output on or off.  Default OFF\\n\"\n  \".cd DIRECTORY          Change the working directory to DIRECTORY\\n\"\n  \".changes on|off        Show number of rows changed by SQL\\n\"\n  \".check GLOB            Fail if output since .testcase does not match\\n\"\n  \".clone NEWDB           Clone data into NEWDB from the existing database\\n\"\n  \".databases             List names and files of attached databases\\n\"\n  \".dbinfo ?DB?           Show status information about the database\\n\"\n  \".dump ?TABLE? ...      Dump the database in an SQL text format\\n\"\n  \"                         If TABLE specified, only dump tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".echo on|off           Turn command echo on or off\\n\"\n  \".eqp on|off|full       Enable or disable automatic EXPLAIN QUERY PLAN\\n\"\n  \".exit                  Exit this program\\n\"\n/* Because explain mode comes on automatically now, the \".explain\" mode\n** is removed from the help screen.  It is still supported for legacy, however */\n/*\".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\\n\"*/\n  \".fullschema ?--indent? Show schema and the content of sqlite_stat tables\\n\"\n  \".headers on|off        Turn display of headers on or off\\n\"\n  \".help                  Show this message\\n\"\n  \".import FILE TABLE     Import data from FILE into TABLE\\n\"\n#ifndef SQLITE_OMIT_TEST_CONTROL\n  \".imposter INDEX TABLE  Create imposter table TABLE on index INDEX\\n\"\n#endif\n  \".indexes ?TABLE?       Show names of all indexes\\n\"\n  \"                         If TABLE specified, only show indexes for tables\\n\"\n  \"                         matching LIKE pattern TABLE.\\n\"\n#ifdef SQLITE_ENABLE_IOTRACE\n  \".iotrace FILE          Enable I/O diagnostic logging to FILE\\n\"\n#endif\n  \".limit ?LIMIT? ?VAL?   Display or change the value of an SQLITE_LIMIT\\n\"\n  \".lint OPTIONS          Report potential schema issues. Options:\\n\"\n  \"                         fkey-indexes     Find missing foreign key indexes\\n\"\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  \".load FILE ?ENTRY?     Load an extension library\\n\"\n#endif\n  \".log FILE|off          Turn logging on or off.  FILE can be stderr/stdout\\n\"\n  \".mode MODE ?TABLE?     Set output mode where MODE is one of:\\n\"\n  \"                         ascii    Columns/rows delimited by 0x1F and 0x1E\\n\"\n  \"                         csv      Comma-separated values\\n\"\n  \"                         column   Left-aligned columns.  (See .width)\\n\"\n  \"                         html     HTML <table> code\\n\"\n  \"                         insert   SQL insert statements for TABLE\\n\"\n  \"                         line     One value per line\\n\"\n  \"                         list     Values delimited by \\\"|\\\"\\n\"\n  \"                         quote    Escape answers as for SQL\\n\"\n  \"                         tabs     Tab-separated values\\n\"\n  \"                         tcl      TCL list elements\\n\"\n  \".nullvalue STRING      Use STRING in place of NULL values\\n\"\n  \".once FILENAME         Output for the next SQL command only to FILENAME\\n\"\n  \".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\\n\"\n  \"                         The --new option starts with an empty file\\n\"\n  \".output ?FILENAME?     Send output to FILENAME or stdout\\n\"\n  \".print STRING...       Print literal STRING\\n\"\n  \".prompt MAIN CONTINUE  Replace the standard prompts\\n\"\n  \".quit                  Exit this program\\n\"\n  \".read FILENAME         Execute SQL in FILENAME\\n\"\n  \".restore ?DB? FILE     Restore content of DB (default \\\"main\\\") from FILE\\n\"\n  \".save FILE             Write in-memory database into FILE\\n\"\n  \".scanstats on|off      Turn sqlite3_stmt_scanstatus() metrics on or off\\n\"\n  \".schema ?PATTERN?      Show the CREATE statements matching PATTERN\\n\"\n  \"                          Add --indent for pretty-printing\\n\"\n  \".selftest ?--init?     Run tests defined in the SELFTEST table\\n\"\n  \".separator COL ?ROW?   Change the column separator and optionally the row\\n\"\n  \"                         separator for both the output mode and .import\\n\"\n#if defined(SQLITE_ENABLE_SESSION)\n  \".session CMD ...       Create or control sessions\\n\"\n#endif\n  \".sha3sum ?OPTIONS...?  Compute a SHA3 hash of database content\\n\"\n  \".shell CMD ARGS...     Run CMD ARGS... in a system shell\\n\"\n  \".show                  Show the current values for various settings\\n\"\n  \".stats ?on|off?        Show stats or turn stats on or off\\n\"\n  \".system CMD ARGS...    Run CMD ARGS... in a system shell\\n\"\n  \".tables ?TABLE?        List names of tables\\n\"\n  \"                         If TABLE specified, only list tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".testcase NAME         Begin redirecting output to 'testcase-out.txt'\\n\"\n  \".timeout MS            Try opening locked tables for MS milliseconds\\n\"\n  \".timer on|off          Turn SQL timer on or off\\n\"\n  \".trace FILE|off        Output each SQL statement as it is run\\n\"\n  \".vfsinfo ?AUX?         Information about the top-level VFS\\n\"\n  \".vfslist               List all available VFSes\\n\"\n  \".vfsname ?AUX?         Print the name of the VFS stack\\n\"\n  \".width NUM1 NUM2 ...   Set column widths for \\\"column\\\" mode\\n\"\n  \"                         Negative values right-justify\\n\"\n;\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** Print help information for the \".sessions\" command\n*/\nvoid session_help(ShellState *p){\n  raw_printf(p->out,\n    \".session ?NAME? SUBCOMMAND ?ARGS...?\\n\"\n    \"If ?NAME? is omitted, the first defined session is used.\\n\"\n    \"Subcommands:\\n\"\n    \"   attach TABLE             Attach TABLE\\n\"\n    \"   changeset FILE           Write a changeset into FILE\\n\"\n    \"   close                    Close one session\\n\"\n    \"   enable ?BOOLEAN?         Set or query the enable bit\\n\"\n    \"   filter GLOB...           Reject tables matching GLOBs\\n\"\n    \"   indirect ?BOOLEAN?       Mark or query the indirect status\\n\"\n    \"   isempty                  Query whether the session is empty\\n\"\n    \"   list                     List currently open session names\\n\"\n    \"   open DB NAME             Open a new session on DB\\n\"\n    \"   patchset FILE            Write a patchset into FILE\\n\"\n  );\n}\n#endif\n\n\n/* Forward reference */\nstatic int process_input(ShellState *p, FILE *in);\n\n/*\n** Read the content of file zName into memory obtained from sqlite3_malloc64()\n** and return a pointer to the buffer. The caller is responsible for freeing\n** the memory.\n**\n** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes\n** read.\n**\n** For convenience, a nul-terminator byte is always appended to the data read\n** from the file before the buffer is returned. This byte is not included in\n** the final value of (*pnByte), if applicable.\n**\n** NULL is returned if any error is encountered. The final value of *pnByte\n** is undefined in this case.\n*/\nstatic char *readFile(const char *zName, int *pnByte){\n  FILE *in = fopen(zName, \"rb\");\n  long nIn;\n  size_t nRead;\n  char *pBuf;\n  if( in==0 ) return 0;\n  fseek(in, 0, SEEK_END);\n  nIn = ftell(in);\n  rewind(in);\n  pBuf = sqlite3_malloc64( nIn+1 );\n  if( pBuf==0 ) return 0;\n  nRead = fread(pBuf, nIn, 1, in);\n  fclose(in);\n  if( nRead!=1 ){\n    sqlite3_free(pBuf);\n    return 0;\n  }\n  pBuf[nIn] = 0;\n  if( pnByte ) *pnByte = nIn;\n  return pBuf;\n}\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** Close a single OpenSession object and release all of its associated\n** resources.\n*/\nstatic void session_close(OpenSession *pSession){\n  int i;\n  sqlite3session_delete(pSession->p);\n  sqlite3_free(pSession->zName);\n  for(i=0; i<pSession->nFilter; i++){\n    sqlite3_free(pSession->azFilter[i]);\n  }\n  sqlite3_free(pSession->azFilter);\n  memset(pSession, 0, sizeof(OpenSession));\n}\n#endif\n\n/*\n** Close all OpenSession objects and release all associated resources.\n*/\n#if defined(SQLITE_ENABLE_SESSION)\nstatic void session_close_all(ShellState *p){\n  int i;\n  for(i=0; i<p->nSession; i++){\n    session_close(&p->aSession[i]);\n  }\n  p->nSession = 0;\n}\n#else\n# define session_close_all(X)\n#endif\n\n/*\n** Implementation of the xFilter function for an open session.  Omit\n** any tables named by \".session filter\" but let all other table through.\n*/\n#if defined(SQLITE_ENABLE_SESSION)\nstatic int session_filter(void *pCtx, const char *zTab){\n  OpenSession *pSession = (OpenSession*)pCtx;\n  int i;\n  for(i=0; i<pSession->nFilter; i++){\n    if( sqlite3_strglob(pSession->azFilter[i], zTab)==0 ) return 0;\n  }\n  return 1;\n}\n#endif\n\n/*\n** Make sure the database is open.  If it is not, then open it.  If\n** the database fails to open, print an error message and exit.\n*/\nstatic void open_db(ShellState *p, int keepAlive){\n  if( p->db==0 ){\n    sqlite3_initialize();\n    sqlite3_open(p->zDbFilename, &p->db);\n    globalDb = p->db;\n    if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){\n      utf8_printf(stderr,\"Error: unable to open database \\\"%s\\\": %s\\n\",\n          p->zDbFilename, sqlite3_errmsg(p->db));\n      if( keepAlive ) return;\n      exit(1);\n    }\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    sqlite3_enable_load_extension(p->db, 1);\n#endif\n    sqlite3_fileio_init(p->db, 0, 0);\n    sqlite3_shathree_init(p->db, 0, 0);\n    sqlite3_completion_init(p->db, 0, 0);\n    sqlite3_create_function(p->db, \"shell_add_schema\", 2, SQLITE_UTF8, 0,\n                            shellAddSchemaName, 0, 0);\n  }\n}\n\n#if HAVE_READLINE || HAVE_EDITLINE\n/*\n** Readline completion callbacks\n*/\nstatic char *readline_completion_generator(const char *text, int state){\n  static sqlite3_stmt *pStmt = 0;\n  char *zRet;\n  if( state==0 ){\n    char *zSql;\n    sqlite3_finalize(pStmt);\n    zSql = sqlite3_mprintf(\"SELECT DISTINCT candidate COLLATE nocase\"\n                           \"  FROM completion(%Q) ORDER BY 1\", text);\n    sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n  }\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));\n  }else{\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    zRet = 0;\n  }\n  return zRet;\n}\nstatic char **readline_completion(const char *zText, int iStart, int iEnd){\n  rl_attempted_completion_over = 1;\n  return rl_completion_matches(zText, readline_completion_generator);\n}\n\n#elif HAVE_LINENOISE\n/*\n** Linenoise completion callback\n*/\nstatic void linenoise_completion(const char *zLine, linenoiseCompletions *lc){\n  int nLine = (int)strlen(zLine);\n  int i, iStart;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql;\n  char zBuf[1000];\n\n  if( nLine>sizeof(zBuf)-30 ) return;\n  if( zLine[0]=='.' ) return;\n  for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}\n  if( i==nLine-1 ) return;\n  iStart = i+1;\n  memcpy(zBuf, zLine, iStart);\n  zSql = sqlite3_mprintf(\"SELECT DISTINCT candidate COLLATE nocase\"\n                         \"  FROM completion(%Q,%Q) ORDER BY 1\",\n                         &zLine[iStart], zLine);\n  sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  sqlite3_exec(globalDb, \"PRAGMA page_count\", 0, 0, 0); /* Load the schema */\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);\n    int nCompletion = sqlite3_column_bytes(pStmt, 0);\n    if( iStart+nCompletion < sizeof(zBuf)-1 ){\n      memcpy(zBuf+iStart, zCompletion, nCompletion+1);\n      linenoiseAddCompletion(lc, zBuf);\n    }\n  }\n  sqlite3_finalize(pStmt);\n}\n#endif\n\n/*\n** Do C-language style dequoting.\n**\n**    \\a    -> alarm\n**    \\b    -> backspace\n**    \\t    -> tab\n**    \\n    -> newline\n**    \\v    -> vertical tab\n**    \\f    -> form feed\n**    \\r    -> carriage return\n**    \\s    -> space\n**    \\\"    -> \"\n**    \\'    -> '\n**    \\\\    -> backslash\n**    \\NNN  -> ascii character NNN in octal\n*/\nstatic void resolve_backslashes(char *z){\n  int i, j;\n  char c;\n  while( *z && *z!='\\\\' ) z++;\n  for(i=j=0; (c = z[i])!=0; i++, j++){\n    if( c=='\\\\' && z[i+1]!=0 ){\n      c = z[++i];\n      if( c=='a' ){\n        c = '\\a';\n      }else if( c=='b' ){\n        c = '\\b';\n      }else if( c=='t' ){\n        c = '\\t';\n      }else if( c=='n' ){\n        c = '\\n';\n      }else if( c=='v' ){\n        c = '\\v';\n      }else if( c=='f' ){\n        c = '\\f';\n      }else if( c=='r' ){\n        c = '\\r';\n      }else if( c=='\"' ){\n        c = '\"';\n      }else if( c=='\\'' ){\n        c = '\\'';\n      }else if( c=='\\\\' ){\n        c = '\\\\';\n      }else if( c>='0' && c<='7' ){\n        c -= '0';\n        if( z[i+1]>='0' && z[i+1]<='7' ){\n          i++;\n          c = (c<<3) + z[i] - '0';\n          if( z[i+1]>='0' && z[i+1]<='7' ){\n            i++;\n            c = (c<<3) + z[i] - '0';\n          }\n        }\n      }\n    }\n    z[j] = c;\n  }\n  if( j<i ) z[j] = 0;\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic sqlite3_int64 integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( IsDigit(zArg[0]) ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<ArraySize(aMult); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  return isNeg? -v : v;\n}\n\n/*\n** Interpret zArg as either an integer or a boolean value.  Return 1 or 0\n** for TRUE and FALSE.  Return the integer value if appropriate.\n*/\nstatic int booleanValue(const char *zArg){\n  int i;\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    for(i=2; hexDigitValue(zArg[i])>=0; i++){}\n  }else{\n    for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}\n  }\n  if( i>0 && zArg[i]==0 ) return (int)(integerValue(zArg) & 0xffffffff);\n  if( sqlite3_stricmp(zArg, \"on\")==0 || sqlite3_stricmp(zArg,\"yes\")==0 ){\n    return 1;\n  }\n  if( sqlite3_stricmp(zArg, \"off\")==0 || sqlite3_stricmp(zArg,\"no\")==0 ){\n    return 0;\n  }\n  utf8_printf(stderr, \"ERROR: Not a boolean value: \\\"%s\\\". Assuming \\\"no\\\".\\n\",\n          zArg);\n  return 0;\n}\n\n/*\n** Set or clear a shell flag according to a boolean value.\n*/\nstatic void setOrClearFlag(ShellState *p, unsigned mFlag, const char *zArg){\n  if( booleanValue(zArg) ){\n    ShellSetFlag(p, mFlag);\n  }else{\n    ShellClearFlag(p, mFlag);\n  }\n}\n\n/*\n** Close an output file, assuming it is not stderr or stdout\n*/\nstatic void output_file_close(FILE *f){\n  if( f && f!=stdout && f!=stderr ) fclose(f);\n}\n\n/*\n** Try to open an output file.   The names \"stdout\" and \"stderr\" are\n** recognized and do the right thing.  NULL is returned if the output\n** filename is \"off\".\n*/\nstatic FILE *output_file_open(const char *zFile){\n  FILE *f;\n  if( strcmp(zFile,\"stdout\")==0 ){\n    f = stdout;\n  }else if( strcmp(zFile, \"stderr\")==0 ){\n    f = stderr;\n  }else if( strcmp(zFile, \"off\")==0 ){\n    f = 0;\n  }else{\n    f = fopen(zFile, \"wb\");\n    if( f==0 ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n    }\n  }\n  return f;\n}\n\n#if !defined(SQLITE_UNTESTABLE)\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n/*\n** A routine for handling output from sqlite3_trace().\n*/\nstatic int sql_trace_callback(\n  unsigned mType,\n  void *pArg,\n  void *pP,\n  void *pX\n){\n  FILE *f = (FILE*)pArg;\n  UNUSED_PARAMETER(mType);\n  UNUSED_PARAMETER(pP);\n  if( f ){\n    const char *z = (const char*)pX;\n    int i = (int)strlen(z);\n    while( i>0 && z[i-1]==';' ){ i--; }\n    utf8_printf(f, \"%.*s;\\n\", i, z);\n  }\n  return 0;\n}\n#endif\n#endif\n\n/*\n** A no-op routine that runs with the \".breakpoint\" doc-command.  This is\n** a useful spot to set a debugger breakpoint.\n*/\nstatic void test_breakpoint(void){\n  static int nCall = 0;\n  nCall++;\n}\n\n/*\n** An object used to read a CSV and other files for import.\n*/\ntypedef struct ImportCtx ImportCtx;\nstruct ImportCtx {\n  const char *zFile;  /* Name of the input file */\n  FILE *in;           /* Read the CSV text from this input stream */\n  char *z;            /* Accumulated text for a field */\n  int n;              /* Number of bytes in z */\n  int nAlloc;         /* Space allocated for z[] */\n  int nLine;          /* Current line number */\n  int bNotFirst;      /* True if one or more bytes already read */\n  int cTerm;          /* Character that terminated the most recent field */\n  int cColSep;        /* The column separator character.  (Usually \",\") */\n  int cRowSep;        /* The row separator character.  (Usually \"\\n\") */\n};\n\n/* Append a single byte to z[] */\nstatic void import_append_char(ImportCtx *p, int c){\n  if( p->n+1>=p->nAlloc ){\n    p->nAlloc += p->nAlloc + 100;\n    p->z = sqlite3_realloc64(p->z, p->nAlloc);\n    if( p->z==0 ){\n      raw_printf(stderr, \"out of memory\\n\");\n      exit(1);\n    }\n  }\n  p->z[p->n++] = (char)c;\n}\n\n/* Read a single field of CSV text.  Compatible with rfc4180 and extended\n** with the option of having a separator other than \",\".\n**\n**   +  Input comes from p->in.\n**   +  Store results in p->z of length p->n.  Space to hold p->z comes\n**      from sqlite3_malloc64().\n**   +  Use p->cSep as the column separator.  The default is \",\".\n**   +  Use p->rSep as the row separator.  The default is \"\\n\".\n**   +  Keep track of the line number in p->nLine.\n**   +  Store the character that terminates the field in p->cTerm.  Store\n**      EOF on end-of-file.\n**   +  Report syntax errors on stderr\n*/\nstatic char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){\n  int c;\n  int cSep = p->cColSep;\n  int rSep = p->cRowSep;\n  p->n = 0;\n  c = fgetc(p->in);\n  if( c==EOF || seenInterrupt ){\n    p->cTerm = EOF;\n    return 0;\n  }\n  if( c=='\"' ){\n    int pc, ppc;\n    int startLine = p->nLine;\n    int cQuote = c;\n    pc = ppc = 0;\n    while( 1 ){\n      c = fgetc(p->in);\n      if( c==rSep ) p->nLine++;\n      if( c==cQuote ){\n        if( pc==cQuote ){\n          pc = 0;\n          continue;\n        }\n      }\n      if( (c==cSep && pc==cQuote)\n       || (c==rSep && pc==cQuote)\n       || (c==rSep && pc=='\\r' && ppc==cQuote)\n       || (c==EOF && pc==cQuote)\n      ){\n        do{ p->n--; }while( p->z[p->n]!=cQuote );\n        p->cTerm = c;\n        break;\n      }\n      if( pc==cQuote && c!='\\r' ){\n        utf8_printf(stderr, \"%s:%d: unescaped %c character\\n\",\n                p->zFile, p->nLine, cQuote);\n      }\n      if( c==EOF ){\n        utf8_printf(stderr, \"%s:%d: unterminated %c-quoted field\\n\",\n                p->zFile, startLine, cQuote);\n        p->cTerm = c;\n        break;\n      }\n      import_append_char(p, c);\n      ppc = pc;\n      pc = c;\n    }\n  }else{\n    /* If this is the first field being parsed and it begins with the\n    ** UTF-8 BOM  (0xEF BB BF) then skip the BOM */\n    if( (c&0xff)==0xef && p->bNotFirst==0 ){\n      import_append_char(p, c);\n      c = fgetc(p->in);\n      if( (c&0xff)==0xbb ){\n        import_append_char(p, c);\n        c = fgetc(p->in);\n        if( (c&0xff)==0xbf ){\n          p->bNotFirst = 1;\n          p->n = 0;\n          return csv_read_one_field(p);\n        }\n      }\n    }\n    while( c!=EOF && c!=cSep && c!=rSep ){\n      import_append_char(p, c);\n      c = fgetc(p->in);\n    }\n    if( c==rSep ){\n      p->nLine++;\n      if( p->n>0 && p->z[p->n-1]=='\\r' ) p->n--;\n    }\n    p->cTerm = c;\n  }\n  if( p->z ) p->z[p->n] = 0;\n  p->bNotFirst = 1;\n  return p->z;\n}\n\n/* Read a single field of ASCII delimited text.\n**\n**   +  Input comes from p->in.\n**   +  Store results in p->z of length p->n.  Space to hold p->z comes\n**      from sqlite3_malloc64().\n**   +  Use p->cSep as the column separator.  The default is \"\\x1F\".\n**   +  Use p->rSep as the row separator.  The default is \"\\x1E\".\n**   +  Keep track of the row number in p->nLine.\n**   +  Store the character that terminates the field in p->cTerm.  Store\n**      EOF on end-of-file.\n**   +  Report syntax errors on stderr\n*/\nstatic char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){\n  int c;\n  int cSep = p->cColSep;\n  int rSep = p->cRowSep;\n  p->n = 0;\n  c = fgetc(p->in);\n  if( c==EOF || seenInterrupt ){\n    p->cTerm = EOF;\n    return 0;\n  }\n  while( c!=EOF && c!=cSep && c!=rSep ){\n    import_append_char(p, c);\n    c = fgetc(p->in);\n  }\n  if( c==rSep ){\n    p->nLine++;\n  }\n  p->cTerm = c;\n  if( p->z ) p->z[p->n] = 0;\n  return p->z;\n}\n\n/*\n** Try to transfer data for table zTable.  If an error is seen while\n** moving forward, try to go backwards.  The backwards movement won't\n** work for WITHOUT ROWID tables.\n*/\nstatic void tryToCloneData(\n  ShellState *p,\n  sqlite3 *newDb,\n  const char *zTable\n){\n  sqlite3_stmt *pQuery = 0;\n  sqlite3_stmt *pInsert = 0;\n  char *zQuery = 0;\n  char *zInsert = 0;\n  int rc;\n  int i, j, n;\n  int nTable = (int)strlen(zTable);\n  int k = 0;\n  int cnt = 0;\n  const int spinRate = 10000;\n\n  zQuery = sqlite3_mprintf(\"SELECT * FROM \\\"%w\\\"\", zTable);\n  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error %d: %s on [%s]\\n\",\n            sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n            zQuery);\n    goto end_data_xfer;\n  }\n  n = sqlite3_column_count(pQuery);\n  zInsert = sqlite3_malloc64(200 + nTable + n*3);\n  if( zInsert==0 ){\n    raw_printf(stderr, \"out of memory\\n\");\n    goto end_data_xfer;\n  }\n  sqlite3_snprintf(200+nTable,zInsert,\n                   \"INSERT OR IGNORE INTO \\\"%s\\\" VALUES(?\", zTable);\n  i = (int)strlen(zInsert);\n  for(j=1; j<n; j++){\n    memcpy(zInsert+i, \",?\", 2);\n    i += 2;\n  }\n  memcpy(zInsert+i, \");\", 3);\n  rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error %d: %s on [%s]\\n\",\n            sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb),\n            zQuery);\n    goto end_data_xfer;\n  }\n  for(k=0; k<2; k++){\n    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n      for(i=0; i<n; i++){\n        switch( sqlite3_column_type(pQuery, i) ){\n          case SQLITE_NULL: {\n            sqlite3_bind_null(pInsert, i+1);\n            break;\n          }\n          case SQLITE_INTEGER: {\n            sqlite3_bind_int64(pInsert, i+1, sqlite3_column_int64(pQuery,i));\n            break;\n          }\n          case SQLITE_FLOAT: {\n            sqlite3_bind_double(pInsert, i+1, sqlite3_column_double(pQuery,i));\n            break;\n          }\n          case SQLITE_TEXT: {\n            sqlite3_bind_text(pInsert, i+1,\n                             (const char*)sqlite3_column_text(pQuery,i),\n                             -1, SQLITE_STATIC);\n            break;\n          }\n          case SQLITE_BLOB: {\n            sqlite3_bind_blob(pInsert, i+1, sqlite3_column_blob(pQuery,i),\n                                            sqlite3_column_bytes(pQuery,i),\n                                            SQLITE_STATIC);\n            break;\n          }\n        }\n      } /* End for */\n      rc = sqlite3_step(pInsert);\n      if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){\n        utf8_printf(stderr, \"Error %d: %s\\n\", sqlite3_extended_errcode(newDb),\n                        sqlite3_errmsg(newDb));\n      }\n      sqlite3_reset(pInsert);\n      cnt++;\n      if( (cnt%spinRate)==0 ){\n        printf(\"%c\\b\", \"|/-\\\\\"[(cnt/spinRate)%4]);\n        fflush(stdout);\n      }\n    } /* End while */\n    if( rc==SQLITE_DONE ) break;\n    sqlite3_finalize(pQuery);\n    sqlite3_free(zQuery);\n    zQuery = sqlite3_mprintf(\"SELECT * FROM \\\"%w\\\" ORDER BY rowid DESC;\",\n                             zTable);\n    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n    if( rc ){\n      utf8_printf(stderr, \"Warning: cannot step \\\"%s\\\" backwards\", zTable);\n      break;\n    }\n  } /* End for(k=0...) */\n\nend_data_xfer:\n  sqlite3_finalize(pQuery);\n  sqlite3_finalize(pInsert);\n  sqlite3_free(zQuery);\n  sqlite3_free(zInsert);\n}\n\n\n/*\n** Try to transfer all rows of the schema that match zWhere.  For\n** each row, invoke xForEach() on the object defined by that row.\n** If an error is encountered while moving forward through the\n** sqlite_master table, try again moving backwards.\n*/\nstatic void tryToCloneSchema(\n  ShellState *p,\n  sqlite3 *newDb,\n  const char *zWhere,\n  void (*xForEach)(ShellState*,sqlite3*,const char*)\n){\n  sqlite3_stmt *pQuery = 0;\n  char *zQuery = 0;\n  int rc;\n  const unsigned char *zName;\n  const unsigned char *zSql;\n  char *zErrMsg = 0;\n\n  zQuery = sqlite3_mprintf(\"SELECT name, sql FROM sqlite_master\"\n                           \" WHERE %s\", zWhere);\n  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error: (%d) %s on [%s]\\n\",\n                    sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n                    zQuery);\n    goto end_schema_xfer;\n  }\n  while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n    zName = sqlite3_column_text(pQuery, 0);\n    zSql = sqlite3_column_text(pQuery, 1);\n    printf(\"%s... \", zName); fflush(stdout);\n    sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);\n    if( zErrMsg ){\n      utf8_printf(stderr, \"Error: %s\\nSQL: [%s]\\n\", zErrMsg, zSql);\n      sqlite3_free(zErrMsg);\n      zErrMsg = 0;\n    }\n    if( xForEach ){\n      xForEach(p, newDb, (const char*)zName);\n    }\n    printf(\"done\\n\");\n  }\n  if( rc!=SQLITE_DONE ){\n    sqlite3_finalize(pQuery);\n    sqlite3_free(zQuery);\n    zQuery = sqlite3_mprintf(\"SELECT name, sql FROM sqlite_master\"\n                             \" WHERE %s ORDER BY rowid DESC\", zWhere);\n    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n    if( rc ){\n      utf8_printf(stderr, \"Error: (%d) %s on [%s]\\n\",\n                      sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n                      zQuery);\n      goto end_schema_xfer;\n    }\n    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n      zName = sqlite3_column_text(pQuery, 0);\n      zSql = sqlite3_column_text(pQuery, 1);\n      printf(\"%s... \", zName); fflush(stdout);\n      sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);\n      if( zErrMsg ){\n        utf8_printf(stderr, \"Error: %s\\nSQL: [%s]\\n\", zErrMsg, zSql);\n        sqlite3_free(zErrMsg);\n        zErrMsg = 0;\n      }\n      if( xForEach ){\n        xForEach(p, newDb, (const char*)zName);\n      }\n      printf(\"done\\n\");\n    }\n  }\nend_schema_xfer:\n  sqlite3_finalize(pQuery);\n  sqlite3_free(zQuery);\n}\n\n/*\n** Open a new database file named \"zNewDb\".  Try to recover as much information\n** as possible out of the main database (which might be corrupt) and write it\n** into zNewDb.\n*/\nstatic void tryToClone(ShellState *p, const char *zNewDb){\n  int rc;\n  sqlite3 *newDb = 0;\n  if( access(zNewDb,0)==0 ){\n    utf8_printf(stderr, \"File \\\"%s\\\" already exists.\\n\", zNewDb);\n    return;\n  }\n  rc = sqlite3_open(zNewDb, &newDb);\n  if( rc ){\n    utf8_printf(stderr, \"Cannot create output database: %s\\n\",\n            sqlite3_errmsg(newDb));\n  }else{\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=ON;\", 0, 0, 0);\n    sqlite3_exec(newDb, \"BEGIN EXCLUSIVE;\", 0, 0, 0);\n    tryToCloneSchema(p, newDb, \"type='table'\", tryToCloneData);\n    tryToCloneSchema(p, newDb, \"type!='table'\", 0);\n    sqlite3_exec(newDb, \"COMMIT;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n  }\n  sqlite3_close(newDb);\n}\n\n/*\n** Change the output file back to stdout\n*/\nstatic void output_reset(ShellState *p){\n  if( p->outfile[0]=='|' ){\n#ifndef SQLITE_OMIT_POPEN\n    pclose(p->out);\n#endif\n  }else{\n    output_file_close(p->out);\n  }\n  p->outfile[0] = 0;\n  p->out = stdout;\n}\n\n/*\n** Run an SQL command and return the single integer result.\n*/\nstatic int db_int(ShellState *p, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int res = 0;\n  sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    res = sqlite3_column_int(pStmt,0);\n  }\n  sqlite3_finalize(pStmt);\n  return res;\n}\n\n/*\n** Convert a 2-byte or 4-byte big-endian integer into a native integer\n*/\nstatic unsigned int get2byteInt(unsigned char *a){\n  return (a[0]<<8) + a[1];\n}\nstatic unsigned int get4byteInt(unsigned char *a){\n  return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];\n}\n\n/*\n** Implementation of the \".info\" command.\n**\n** Return 1 on error, 2 to exit, and 0 otherwise.\n*/\nstatic int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){\n  static const struct { const char *zName; int ofst; } aField[] = {\n     { \"file change counter:\",  24  },\n     { \"database page count:\",  28  },\n     { \"freelist page count:\",  36  },\n     { \"schema cookie:\",        40  },\n     { \"schema format:\",        44  },\n     { \"default cache size:\",   48  },\n     { \"autovacuum top root:\",  52  },\n     { \"incremental vacuum:\",   64  },\n     { \"text encoding:\",        56  },\n     { \"user version:\",         60  },\n     { \"application id:\",       68  },\n     { \"software version:\",     96  },\n  };\n  static const struct { const char *zName; const char *zSql; } aQuery[] = {\n     { \"number of tables:\",\n       \"SELECT count(*) FROM %s WHERE type='table'\" },\n     { \"number of indexes:\",\n       \"SELECT count(*) FROM %s WHERE type='index'\" },\n     { \"number of triggers:\",\n       \"SELECT count(*) FROM %s WHERE type='trigger'\" },\n     { \"number of views:\",\n       \"SELECT count(*) FROM %s WHERE type='view'\" },\n     { \"schema size:\",\n       \"SELECT total(length(sql)) FROM %s\" },\n  };\n  int i;\n  char *zSchemaTab;\n  char *zDb = nArg>=2 ? azArg[1] : \"main\";\n  sqlite3_stmt *pStmt = 0;\n  unsigned char aHdr[100];\n  open_db(p, 0);\n  if( p->db==0 ) return 1;\n  sqlite3_prepare_v2(p->db,\"SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1\",\n                     -1, &pStmt, 0);\n  sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC);\n  if( sqlite3_step(pStmt)==SQLITE_ROW\n   && sqlite3_column_bytes(pStmt,0)>100\n  ){\n    memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100);\n    sqlite3_finalize(pStmt);\n  }else{\n    raw_printf(stderr, \"unable to read database header\\n\");\n    sqlite3_finalize(pStmt);\n    return 1;\n  }\n  i = get2byteInt(aHdr+16);\n  if( i==1 ) i = 65536;\n  utf8_printf(p->out, \"%-20s %d\\n\", \"database page size:\", i);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"write format:\", aHdr[18]);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"read format:\", aHdr[19]);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"reserved bytes:\", aHdr[20]);\n  for(i=0; i<ArraySize(aField); i++){\n    int ofst = aField[i].ofst;\n    unsigned int val = get4byteInt(aHdr + ofst);\n    utf8_printf(p->out, \"%-20s %u\", aField[i].zName, val);\n    switch( ofst ){\n      case 56: {\n        if( val==1 ) raw_printf(p->out, \" (utf8)\");\n        if( val==2 ) raw_printf(p->out, \" (utf16le)\");\n        if( val==3 ) raw_printf(p->out, \" (utf16be)\");\n      }\n    }\n    raw_printf(p->out, \"\\n\");\n  }\n  if( zDb==0 ){\n    zSchemaTab = sqlite3_mprintf(\"main.sqlite_master\");\n  }else if( strcmp(zDb,\"temp\")==0 ){\n    zSchemaTab = sqlite3_mprintf(\"%s\", \"sqlite_temp_master\");\n  }else{\n    zSchemaTab = sqlite3_mprintf(\"\\\"%w\\\".sqlite_master\", zDb);\n  }\n  for(i=0; i<ArraySize(aQuery); i++){\n    char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);\n    int val = db_int(p, zSql);\n    sqlite3_free(zSql);\n    utf8_printf(p->out, \"%-20s %d\\n\", aQuery[i].zName, val);\n  }\n  sqlite3_free(zSchemaTab);\n  return 0;\n}\n\n/*\n** Print the current sqlite3_errmsg() value to stderr and return 1.\n*/\nstatic int shellDatabaseError(sqlite3 *db){\n  const char *zErr = sqlite3_errmsg(db);\n  utf8_printf(stderr, \"Error: %s\\n\", zErr);\n  return 1;\n}\n\n/*\n** Print an out-of-memory message to stderr and return 1.\n*/\nstatic int shellNomemError(void){\n  raw_printf(stderr, \"Error: out of memory\\n\");\n  return 1;\n}\n\n/*\n** Compare the pattern in zGlob[] against the text in z[].  Return TRUE\n** if they match and FALSE (0) if they do not match.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n**      '#'       Matches any sequence of one or more digits with an\n**                optional + or - sign in front\n**\n**      ' '       Any span of whitespace matches any other span of\n**                whitespace.\n**\n** Extra whitespace at the end of z[] is ignored.\n*/\nstatic int testcase_glob(const char *zGlob, const char *z){\n  int c, c2;\n  int invert;\n  int seen;\n\n  while( (c = (*(zGlob++)))!=0 ){\n    if( IsSpace(c) ){\n      if( !IsSpace(*z) ) return 0;\n      while( IsSpace(*zGlob) ) zGlob++;\n      while( IsSpace(*z) ) z++;\n    }else if( c=='*' ){\n      while( (c=(*(zGlob++))) == '*' || c=='?' ){\n        if( c=='?' && (*(z++))==0 ) return 0;\n      }\n      if( c==0 ){\n        return 1;\n      }else if( c=='[' ){\n        while( *z && testcase_glob(zGlob-1,z)==0 ){\n          z++;\n        }\n        return (*z)!=0;\n      }\n      while( (c2 = (*(z++)))!=0 ){\n        while( c2!=c ){\n          c2 = *(z++);\n          if( c2==0 ) return 0;\n        }\n        if( testcase_glob(zGlob,z) ) return 1;\n      }\n      return 0;\n    }else if( c=='?' ){\n      if( (*(z++))==0 ) return 0;\n    }else if( c=='[' ){\n      int prior_c = 0;\n      seen = 0;\n      invert = 0;\n      c = *(z++);\n      if( c==0 ) return 0;\n      c2 = *(zGlob++);\n      if( c2=='^' ){\n        invert = 1;\n        c2 = *(zGlob++);\n      }\n      if( c2==']' ){\n        if( c==']' ) seen = 1;\n        c2 = *(zGlob++);\n      }\n      while( c2 && c2!=']' ){\n        if( c2=='-' && zGlob[0]!=']' && zGlob[0]!=0 && prior_c>0 ){\n          c2 = *(zGlob++);\n          if( c>=prior_c && c<=c2 ) seen = 1;\n          prior_c = 0;\n        }else{\n          if( c==c2 ){\n            seen = 1;\n          }\n          prior_c = c2;\n        }\n        c2 = *(zGlob++);\n      }\n      if( c2==0 || (seen ^ invert)==0 ) return 0;\n    }else if( c=='#' ){\n      if( (z[0]=='-' || z[0]=='+') && IsDigit(z[1]) ) z++;\n      if( !IsDigit(z[0]) ) return 0;\n      z++;\n      while( IsDigit(z[0]) ){ z++; }\n    }else{\n      if( c!=(*(z++)) ) return 0;\n    }\n  }\n  while( IsSpace(*z) ){ z++; }\n  return *z==0;\n}\n\n\n/*\n** Compare the string as a command-line option with either one or two\n** initial \"-\" characters.\n*/\nstatic int optionMatch(const char *zStr, const char *zOpt){\n  if( zStr[0]!='-' ) return 0;\n  zStr++;\n  if( zStr[0]=='-' ) zStr++;\n  return strcmp(zStr, zOpt)==0;\n}\n\n/*\n** Delete a file.\n*/\nint shellDeleteFile(const char *zFilename){\n  int rc;\n#ifdef _WIN32\n  wchar_t *z = sqlite3_win32_utf8_to_unicode(zFilename);\n  rc = _wunlink(z);\n  sqlite3_free(z);\n#else\n  rc = unlink(zFilename);\n#endif\n  return rc;\n}\n\n\n/*\n** The implementation of SQL scalar function fkey_collate_clause(), used\n** by the \".lint fkey-indexes\" command. This scalar function is always\n** called with four arguments - the parent table name, the parent column name,\n** the child table name and the child column name.\n**\n**   fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')\n**\n** If either of the named tables or columns do not exist, this function\n** returns an empty string. An empty string is also returned if both tables\n** and columns exist but have the same default collation sequence. Or,\n** if both exist but the default collation sequences are different, this\n** function returns the string \" COLLATE <parent-collation>\", where\n** <parent-collation> is the default collation sequence of the parent column.\n*/\nstatic void shellFkeyCollateClause(\n  sqlite3_context *pCtx,\n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zParent;\n  const char *zParentCol;\n  const char *zParentSeq;\n  const char *zChild;\n  const char *zChildCol;\n  const char *zChildSeq = 0;  /* Initialize to avoid false-positive warning */\n  int rc;\n\n  assert( nVal==4 );\n  zParent = (const char*)sqlite3_value_text(apVal[0]);\n  zParentCol = (const char*)sqlite3_value_text(apVal[1]);\n  zChild = (const char*)sqlite3_value_text(apVal[2]);\n  zChildCol = (const char*)sqlite3_value_text(apVal[3]);\n\n  sqlite3_result_text(pCtx, \"\", -1, SQLITE_STATIC);\n  rc = sqlite3_table_column_metadata(\n      db, \"main\", zParent, zParentCol, 0, &zParentSeq, 0, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_table_column_metadata(\n        db, \"main\", zChild, zChildCol, 0, &zChildSeq, 0, 0, 0\n    );\n  }\n\n  if( rc==SQLITE_OK && sqlite3_stricmp(zParentSeq, zChildSeq) ){\n    char *z = sqlite3_mprintf(\" COLLATE %s\", zParentSeq);\n    sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT);\n    sqlite3_free(z);\n  }\n}\n\n\n/*\n** The implementation of dot-command \".lint fkey-indexes\".\n*/\nstatic int lintFkeyIndexes(\n  ShellState *pState,             /* Current shell tool state */\n  char **azArg,                   /* Array of arguments passed to dot command */\n  int nArg                        /* Number of entries in azArg[] */\n){\n  sqlite3 *db = pState->db;       /* Database handle to query \"main\" db of */\n  FILE *out = pState->out;        /* Stream to write non-error output to */\n  int bVerbose = 0;               /* If -verbose is present */\n  int bGroupByParent = 0;         /* If -groupbyparent is present */\n  int i;                          /* To iterate through azArg[] */\n  const char *zIndent = \"\";       /* How much to indent CREATE INDEX by */\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSql = 0;         /* Compiled version of SQL statement below */\n\n  /*\n  ** This SELECT statement returns one row for each foreign key constraint\n  ** in the schema of the main database. The column values are:\n  **\n  ** 0. The text of an SQL statement similar to:\n  **\n  **      \"EXPLAIN QUERY PLAN SELECT rowid FROM child_table WHERE child_key=?\"\n  **\n  **    This is the same SELECT that the foreign keys implementation needs\n  **    to run internally on child tables. If there is an index that can\n  **    be used to optimize this query, then it can also be used by the FK\n  **    implementation to optimize DELETE or UPDATE statements on the parent\n  **    table.\n  **\n  ** 1. A GLOB pattern suitable for sqlite3_strglob(). If the plan output by\n  **    the EXPLAIN QUERY PLAN command matches this pattern, then the schema\n  **    contains an index that can be used to optimize the query.\n  **\n  ** 2. Human readable text that describes the child table and columns. e.g.\n  **\n  **       \"child_table(child_key1, child_key2)\"\n  **\n  ** 3. Human readable text that describes the parent table and columns. e.g.\n  **\n  **       \"parent_table(parent_key1, parent_key2)\"\n  **\n  ** 4. A full CREATE INDEX statement for an index that could be used to\n  **    optimize DELETE or UPDATE statements on the parent table. e.g.\n  **\n  **       \"CREATE INDEX child_table_child_key ON child_table(child_key)\"\n  **\n  ** 5. The name of the parent table.\n  **\n  ** These six values are used by the C logic below to generate the report.\n  */\n  const char *zSql =\n  \"SELECT \"\n    \"     'EXPLAIN QUERY PLAN SELECT rowid FROM ' || quote(s.name) || ' WHERE '\"\n    \"  || group_concat(quote(s.name) || '.' || quote(f.[from]) || '=?' \"\n    \"  || fkey_collate_clause(\"\n    \"       f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]),' AND ')\"\n    \", \"\n    \"     'SEARCH TABLE ' || s.name || ' USING COVERING INDEX*('\"\n    \"  || group_concat('*=?', ' AND ') || ')'\"\n    \", \"\n    \"     s.name  || '(' || group_concat(f.[from],  ', ') || ')'\"\n    \", \"\n    \"     f.[table] || '(' || group_concat(COALESCE(f.[to], p.[name])) || ')'\"\n    \", \"\n    \"     'CREATE INDEX ' || quote(s.name ||'_'|| group_concat(f.[from], '_'))\"\n    \"  || ' ON ' || quote(s.name) || '('\"\n    \"  || group_concat(quote(f.[from]) ||\"\n    \"        fkey_collate_clause(\"\n    \"          f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]), ', ')\"\n    \"  || ');'\"\n    \", \"\n    \"     f.[table] \"\n    \"FROM sqlite_master AS s, pragma_foreign_key_list(s.name) AS f \"\n    \"LEFT JOIN pragma_table_info AS p ON (pk-1=seq AND p.arg=f.[table]) \"\n    \"GROUP BY s.name, f.id \"\n    \"ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)\"\n  ;\n  const char *zGlobIPK = \"SEARCH TABLE * USING INTEGER PRIMARY KEY (rowid=?)\";\n\n  for(i=2; i<nArg; i++){\n    int n = (int)strlen(azArg[i]);\n    if( n>1 && sqlite3_strnicmp(\"-verbose\", azArg[i], n)==0 ){\n      bVerbose = 1;\n    }\n    else if( n>1 && sqlite3_strnicmp(\"-groupbyparent\", azArg[i], n)==0 ){\n      bGroupByParent = 1;\n      zIndent = \"    \";\n    }\n    else{\n      raw_printf(stderr, \"Usage: %s %s ?-verbose? ?-groupbyparent?\\n\",\n          azArg[0], azArg[1]\n      );\n      return SQLITE_ERROR;\n    }\n  }\n\n  /* Register the fkey_collate_clause() SQL function */\n  rc = sqlite3_create_function(db, \"fkey_collate_clause\", 4, SQLITE_UTF8,\n      0, shellFkeyCollateClause, 0, 0\n  );\n\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pSql, 1, bGroupByParent);\n  }\n\n  if( rc==SQLITE_OK ){\n    int rc2;\n    char *zPrev = 0;\n    while( SQLITE_ROW==sqlite3_step(pSql) ){\n      int res = -1;\n      sqlite3_stmt *pExplain = 0;\n      const char *zEQP = (const char*)sqlite3_column_text(pSql, 0);\n      const char *zGlob = (const char*)sqlite3_column_text(pSql, 1);\n      const char *zFrom = (const char*)sqlite3_column_text(pSql, 2);\n      const char *zTarget = (const char*)sqlite3_column_text(pSql, 3);\n      const char *zCI = (const char*)sqlite3_column_text(pSql, 4);\n      const char *zParent = (const char*)sqlite3_column_text(pSql, 5);\n\n      rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n      if( rc!=SQLITE_OK ) break;\n      if( SQLITE_ROW==sqlite3_step(pExplain) ){\n        const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);\n        res = (\n              0==sqlite3_strglob(zGlob, zPlan)\n           || 0==sqlite3_strglob(zGlobIPK, zPlan)\n        );\n      }\n      rc = sqlite3_finalize(pExplain);\n      if( rc!=SQLITE_OK ) break;\n\n      if( res<0 ){\n        raw_printf(stderr, \"Error: internal error\");\n        break;\n      }else{\n        if( bGroupByParent\n        && (bVerbose || res==0)\n        && (zPrev==0 || sqlite3_stricmp(zParent, zPrev))\n        ){\n          raw_printf(out, \"-- Parent table %s\\n\", zParent);\n          sqlite3_free(zPrev);\n          zPrev = sqlite3_mprintf(\"%s\", zParent);\n        }\n\n        if( res==0 ){\n          raw_printf(out, \"%s%s --> %s\\n\", zIndent, zCI, zTarget);\n        }else if( bVerbose ){\n          raw_printf(out, \"%s/* no extra indexes required for %s -> %s */\\n\",\n              zIndent, zFrom, zTarget\n          );\n        }\n      }\n    }\n    sqlite3_free(zPrev);\n\n    if( rc!=SQLITE_OK ){\n      raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n    }\n\n    rc2 = sqlite3_finalize(pSql);\n    if( rc==SQLITE_OK && rc2!=SQLITE_OK ){\n      rc = rc2;\n      raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n    }\n  }else{\n    raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of \".lint\" dot command.\n*/\nstatic int lintDotCommand(\n  ShellState *pState,             /* Current shell tool state */\n  char **azArg,                   /* Array of arguments passed to dot command */\n  int nArg                        /* Number of entries in azArg[] */\n){\n  int n;\n  n = (nArg>=2 ? (int)strlen(azArg[1]) : 0);\n  if( n<1 || sqlite3_strnicmp(azArg[1], \"fkey-indexes\", n) ) goto usage;\n  return lintFkeyIndexes(pState, azArg, nArg);\n\n usage:\n  raw_printf(stderr, \"Usage %s sub-command ?switches...?\\n\", azArg[0]);\n  raw_printf(stderr, \"Where sub-commands are:\\n\");\n  raw_printf(stderr, \"    fkey-indexes\\n\");\n  return SQLITE_ERROR;\n}\n\n\n/*\n** If an input line begins with \".\" then invoke this routine to\n** process that line.\n**\n** Return 1 on error, 2 to exit, and 0 otherwise.\n*/\nstatic int do_meta_command(char *zLine, ShellState *p){\n  int h = 1;\n  int nArg = 0;\n  int n, c;\n  int rc = 0;\n  char *azArg[50];\n\n  /* Parse the input line into tokens.\n  */\n  while( zLine[h] && nArg<ArraySize(azArg) ){\n    while( IsSpace(zLine[h]) ){ h++; }\n    if( zLine[h]==0 ) break;\n    if( zLine[h]=='\\'' || zLine[h]=='\"' ){\n      int delim = zLine[h++];\n      azArg[nArg++] = &zLine[h];\n      while( zLine[h] && zLine[h]!=delim ){\n        if( zLine[h]=='\\\\' && delim=='\"' && zLine[h+1]!=0 ) h++;\n        h++;\n      }\n      if( zLine[h]==delim ){\n        zLine[h++] = 0;\n      }\n      if( delim=='\"' ) resolve_backslashes(azArg[nArg-1]);\n    }else{\n      azArg[nArg++] = &zLine[h];\n      while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }\n      if( zLine[h] ) zLine[h++] = 0;\n      resolve_backslashes(azArg[nArg-1]);\n    }\n  }\n\n  /* Process the input line.\n  */\n  if( nArg==0 ) return 0; /* no tokens, no error */\n  n = strlen30(azArg[0]);\n  c = azArg[0][0];\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( c=='a' && strncmp(azArg[0], \"auth\", n)==0 ){\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .auth ON|OFF\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    if( booleanValue(azArg[1]) ){\n      sqlite3_set_authorizer(p->db, shellAuth, p);\n    }else{\n      sqlite3_set_authorizer(p->db, 0, 0);\n    }\n  }else\n#endif\n\n  if( (c=='b' && n>=3 && strncmp(azArg[0], \"backup\", n)==0)\n   || (c=='s' && n>=3 && strncmp(azArg[0], \"save\", n)==0)\n  ){\n    const char *zDestFile = 0;\n    const char *zDb = 0;\n    sqlite3 *pDest;\n    sqlite3_backup *pBackup;\n    int j;\n    for(j=1; j<nArg; j++){\n      const char *z = azArg[j];\n      if( z[0]=='-' ){\n        while( z[0]=='-' ) z++;\n        /* No options to process at this time */\n        {\n          utf8_printf(stderr, \"unknown option: %s\\n\", azArg[j]);\n          return 1;\n        }\n      }else if( zDestFile==0 ){\n        zDestFile = azArg[j];\n      }else if( zDb==0 ){\n        zDb = zDestFile;\n        zDestFile = azArg[j];\n      }else{\n        raw_printf(stderr, \"too many arguments to .backup\\n\");\n        return 1;\n      }\n    }\n    if( zDestFile==0 ){\n      raw_printf(stderr, \"missing FILENAME argument on .backup\\n\");\n      return 1;\n    }\n    if( zDb==0 ) zDb = \"main\";\n    rc = sqlite3_open(zDestFile, &pDest);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zDestFile);\n      sqlite3_close(pDest);\n      return 1;\n    }\n    open_db(p, 0);\n    pBackup = sqlite3_backup_init(pDest, \"main\", p->db, zDb);\n    if( pBackup==0 ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      sqlite3_close(pDest);\n      return 1;\n    }\n    while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else{\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      rc = 1;\n    }\n    sqlite3_close(pDest);\n  }else\n\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"bail\", n)==0 ){\n    if( nArg==2 ){\n      bail_on_error = booleanValue(azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .bail on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"binary\", n)==0 ){\n    if( nArg==2 ){\n      if( booleanValue(azArg[1]) ){\n        setBinaryMode(p->out, 1);\n      }else{\n        setTextMode(p->out, 1);\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .binary on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='c' && strcmp(azArg[0],\"cd\")==0 ){\n    if( nArg==2 ){\n#if defined(_WIN32) || defined(WIN32)\n      wchar_t *z = sqlite3_win32_utf8_to_unicode(azArg[1]);\n      rc = !SetCurrentDirectoryW(z);\n      sqlite3_free(z);\n#else\n      rc = chdir(azArg[1]);\n#endif\n      if( rc ){\n        utf8_printf(stderr, \"Cannot change to directory \\\"%s\\\"\\n\", azArg[1]);\n        rc = 1;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .cd DIRECTORY\\n\");\n      rc = 1;\n    }\n  }else\n\n  /* The undocumented \".breakpoint\" command causes a call to the no-op\n  ** routine named test_breakpoint().\n  */\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"breakpoint\", n)==0 ){\n    test_breakpoint();\n  }else\n\n  if( c=='c' && n>=3 && strncmp(azArg[0], \"changes\", n)==0 ){\n    if( nArg==2 ){\n      setOrClearFlag(p, SHFLG_CountChanges, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .changes on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  /* Cancel output redirection, if it is currently set (by .testcase)\n  ** Then read the content of the testcase-out.txt file and compare against\n  ** azArg[1].  If there are differences, report an error and exit.\n  */\n  if( c=='c' && n>=3 && strncmp(azArg[0], \"check\", n)==0 ){\n    char *zRes = 0;\n    output_reset(p);\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .check GLOB-PATTERN\\n\");\n      rc = 2;\n    }else if( (zRes = readFile(\"testcase-out.txt\", 0))==0 ){\n      raw_printf(stderr, \"Error: cannot read 'testcase-out.txt'\\n\");\n      rc = 2;\n    }else if( testcase_glob(azArg[1],zRes)==0 ){\n      utf8_printf(stderr,\n                 \"testcase-%s FAILED\\n Expected: [%s]\\n      Got: [%s]\\n\",\n                 p->zTestcase, azArg[1], zRes);\n      rc = 1;\n    }else{\n      utf8_printf(stdout, \"testcase-%s ok\\n\", p->zTestcase);\n      p->nCheck++;\n    }\n    sqlite3_free(zRes);\n  }else\n\n  if( c=='c' && strncmp(azArg[0], \"clone\", n)==0 ){\n    if( nArg==2 ){\n      tryToClone(p, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .clone FILENAME\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='d' && n>1 && strncmp(azArg[0], \"databases\", n)==0 ){\n    ShellState data;\n    char *zErrMsg = 0;\n    open_db(p, 0);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_List;\n    sqlite3_snprintf(sizeof(data.colSeparator),data.colSeparator,\": \");\n    data.cnt = 0;\n    sqlite3_exec(p->db, \"SELECT name, file FROM pragma_database_list\",\n                 callback, &data, &zErrMsg);\n    if( zErrMsg ){\n      utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n\n  if( c=='d' && strncmp(azArg[0], \"dbinfo\", n)==0 ){\n    rc = shell_dbinfo_command(p, nArg, azArg);\n  }else\n\n  if( c=='d' && strncmp(azArg[0], \"dump\", n)==0 ){\n    const char *zLike = 0;\n    int i;\n    int savedShowHeader = p->showHeader;\n    ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);\n    for(i=1; i<nArg; i++){\n      if( azArg[i][0]=='-' ){\n        const char *z = azArg[i]+1;\n        if( z[0]=='-' ) z++;\n        if( strcmp(z,\"preserve-rowids\")==0 ){\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n          raw_printf(stderr, \"The --preserve-rowids option is not compatible\"\n                             \" with SQLITE_OMIT_VIRTUALTABLE\\n\");\n          rc = 1;\n          goto meta_command_exit;\n#else\n          ShellSetFlag(p, SHFLG_PreserveRowid);\n#endif\n        }else\n        if( strcmp(z,\"newlines\")==0 ){\n          ShellSetFlag(p, SHFLG_Newlines);\n        }else\n        {\n          raw_printf(stderr, \"Unknown option \\\"%s\\\" on \\\".dump\\\"\\n\", azArg[i]);\n          rc = 1;\n          goto meta_command_exit;\n        }\n      }else if( zLike ){\n        raw_printf(stderr, \"Usage: .dump ?--preserve-rowids? \"\n                           \"?--newlines? ?LIKE-PATTERN?\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }else{\n        zLike = azArg[i];\n      }\n    }\n    open_db(p, 0);\n    /* When playing back a \"dump\", the content might appear in an order\n    ** which causes immediate foreign key constraints to be violated.\n    ** So disable foreign-key constraint enforcement to prevent problems. */\n    raw_printf(p->out, \"PRAGMA foreign_keys=OFF;\\n\");\n    raw_printf(p->out, \"BEGIN TRANSACTION;\\n\");\n    p->writableSchema = 0;\n    p->showHeader = 0;\n    /* Set writable_schema=ON since doing so forces SQLite to initialize\n    ** as much of the schema as it can even if the sqlite_master table is\n    ** corrupt. */\n    sqlite3_exec(p->db, \"SAVEPOINT dump; PRAGMA writable_schema=ON\", 0, 0, 0);\n    p->nErr = 0;\n    if( zLike==0 ){\n      run_schema_dump_query(p,\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\"\n      );\n      run_schema_dump_query(p,\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE name=='sqlite_sequence'\"\n      );\n      run_table_dump_query(p,\n        \"SELECT sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type IN ('index','trigger','view')\", 0\n      );\n    }else{\n      char *zSql;\n      zSql = sqlite3_mprintf(\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE tbl_name LIKE %Q AND type=='table'\"\n        \"  AND sql NOT NULL\", zLike);\n      run_schema_dump_query(p,zSql);\n      sqlite3_free(zSql);\n      zSql = sqlite3_mprintf(\n        \"SELECT sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL\"\n        \"  AND type IN ('index','trigger','view')\"\n        \"  AND tbl_name LIKE %Q\", zLike);\n      run_table_dump_query(p, zSql, 0);\n      sqlite3_free(zSql);\n    }\n    if( p->writableSchema ){\n      raw_printf(p->out, \"PRAGMA writable_schema=OFF;\\n\");\n      p->writableSchema = 0;\n    }\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"RELEASE dump;\", 0, 0, 0);\n    raw_printf(p->out, p->nErr ? \"ROLLBACK; -- due to errors\\n\" : \"COMMIT;\\n\");\n    p->showHeader = savedShowHeader;\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"echo\", n)==0 ){\n    if( nArg==2 ){\n      setOrClearFlag(p, SHFLG_Echo, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .echo on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"eqp\", n)==0 ){\n    if( nArg==2 ){\n      if( strcmp(azArg[1],\"full\")==0 ){\n        p->autoEQP = 2;\n      }else{\n        p->autoEQP = booleanValue(azArg[1]);\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .eqp on|off|full\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"exit\", n)==0 ){\n    if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);\n    rc = 2;\n  }else\n\n  /* The \".explain\" command is automatic now.  It is largely pointless.  It\n  ** retained purely for backwards compatibility */\n  if( c=='e' && strncmp(azArg[0], \"explain\", n)==0 ){\n    int val = 1;\n    if( nArg>=2 ){\n      if( strcmp(azArg[1],\"auto\")==0 ){\n        val = 99;\n      }else{\n        val =  booleanValue(azArg[1]);\n      }\n    }\n    if( val==1 && p->mode!=MODE_Explain ){\n      p->normalMode = p->mode;\n      p->mode = MODE_Explain;\n      p->autoExplain = 0;\n    }else if( val==0 ){\n      if( p->mode==MODE_Explain ) p->mode = p->normalMode;\n      p->autoExplain = 0;\n    }else if( val==99 ){\n      if( p->mode==MODE_Explain ) p->mode = p->normalMode;\n      p->autoExplain = 1;\n    }\n  }else\n\n  if( c=='f' && strncmp(azArg[0], \"fullschema\", n)==0 ){\n    ShellState data;\n    char *zErrMsg = 0;\n    int doStats = 0;\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_Semi;\n    if( nArg==2 && optionMatch(azArg[1], \"indent\") ){\n      data.cMode = data.mode = MODE_Pretty;\n      nArg = 1;\n    }\n    if( nArg!=1 ){\n      raw_printf(stderr, \"Usage: .fullschema ?--indent?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    rc = sqlite3_exec(p->db,\n       \"SELECT sql FROM\"\n       \"  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x\"\n       \"     FROM sqlite_master UNION ALL\"\n       \"   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) \"\n       \"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' \"\n       \"ORDER BY rowid\",\n       callback, &data, &zErrMsg\n    );\n    if( rc==SQLITE_OK ){\n      sqlite3_stmt *pStmt;\n      rc = sqlite3_prepare_v2(p->db,\n               \"SELECT rowid FROM sqlite_master\"\n               \" WHERE name GLOB 'sqlite_stat[134]'\",\n               -1, &pStmt, 0);\n      doStats = sqlite3_step(pStmt)==SQLITE_ROW;\n      sqlite3_finalize(pStmt);\n    }\n    if( doStats==0 ){\n      raw_printf(p->out, \"/* No STAT tables available */\\n\");\n    }else{\n      raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n      sqlite3_exec(p->db, \"SELECT 'ANALYZE sqlite_master'\",\n                   callback, &data, &zErrMsg);\n      data.cMode = data.mode = MODE_Insert;\n      data.zDestTable = \"sqlite_stat1\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat1\",\n                 shell_callback, &data,&zErrMsg);\n      data.zDestTable = \"sqlite_stat3\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat3\",\n                 shell_callback, &data,&zErrMsg);\n      data.zDestTable = \"sqlite_stat4\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat4\",\n                 shell_callback, &data, &zErrMsg);\n      raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n    }\n  }else\n\n  if( c=='h' && strncmp(azArg[0], \"headers\", n)==0 ){\n    if( nArg==2 ){\n      p->showHeader = booleanValue(azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .headers on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='h' && strncmp(azArg[0], \"help\", n)==0 ){\n    utf8_printf(p->out, \"%s\", zHelp);\n  }else\n\n  if( c=='i' && strncmp(azArg[0], \"import\", n)==0 ){\n    char *zTable;               /* Insert data into this table */\n    char *zFile;                /* Name of file to extra content from */\n    sqlite3_stmt *pStmt = NULL; /* A statement */\n    int nCol;                   /* Number of columns in the table */\n    int nByte;                  /* Number of bytes in an SQL string */\n    int i, j;                   /* Loop counters */\n    int needCommit;             /* True to COMMIT or ROLLBACK at end */\n    int nSep;                   /* Number of bytes in p->colSeparator[] */\n    char *zSql;                 /* An SQL statement */\n    ImportCtx sCtx;             /* Reader context */\n    char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */\n    int (SQLITE_CDECL *xCloser)(FILE*);      /* Func to close file */\n\n    if( nArg!=3 ){\n      raw_printf(stderr, \"Usage: .import FILE TABLE\\n\");\n      goto meta_command_exit;\n    }\n    zFile = azArg[1];\n    zTable = azArg[2];\n    seenInterrupt = 0;\n    memset(&sCtx, 0, sizeof(sCtx));\n    open_db(p, 0);\n    nSep = strlen30(p->colSeparator);\n    if( nSep==0 ){\n      raw_printf(stderr,\n                 \"Error: non-null column separator required for import\\n\");\n      return 1;\n    }\n    if( nSep>1 ){\n      raw_printf(stderr, \"Error: multi-character column separators not allowed\"\n                      \" for import\\n\");\n      return 1;\n    }\n    nSep = strlen30(p->rowSeparator);\n    if( nSep==0 ){\n      raw_printf(stderr, \"Error: non-null row separator required for import\\n\");\n      return 1;\n    }\n    if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){\n      /* When importing CSV (only), if the row separator is set to the\n      ** default output row separator, change it to the default input\n      ** row separator.  This avoids having to maintain different input\n      ** and output row separators. */\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n      nSep = strlen30(p->rowSeparator);\n    }\n    if( nSep>1 ){\n      raw_printf(stderr, \"Error: multi-character row separators not allowed\"\n                      \" for import\\n\");\n      return 1;\n    }\n    sCtx.zFile = zFile;\n    sCtx.nLine = 1;\n    if( sCtx.zFile[0]=='|' ){\n#ifdef SQLITE_OMIT_POPEN\n      raw_printf(stderr, \"Error: pipes are not supported in this OS\\n\");\n      return 1;\n#else\n      sCtx.in = popen(sCtx.zFile+1, \"r\");\n      sCtx.zFile = \"<pipe>\";\n      xCloser = pclose;\n#endif\n    }else{\n      sCtx.in = fopen(sCtx.zFile, \"rb\");\n      xCloser = fclose;\n    }\n    if( p->mode==MODE_Ascii ){\n      xRead = ascii_read_one_field;\n    }else{\n      xRead = csv_read_one_field;\n    }\n    if( sCtx.in==0 ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n      return 1;\n    }\n    sCtx.cColSep = p->colSeparator[0];\n    sCtx.cRowSep = p->rowSeparator[0];\n    zSql = sqlite3_mprintf(\"SELECT * FROM %s\", zTable);\n    if( zSql==0 ){\n      raw_printf(stderr, \"Error: out of memory\\n\");\n      xCloser(sCtx.in);\n      return 1;\n    }\n    nByte = strlen30(zSql);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */\n    if( rc && sqlite3_strglob(\"no such table: *\", sqlite3_errmsg(p->db))==0 ){\n      char *zCreate = sqlite3_mprintf(\"CREATE TABLE %s\", zTable);\n      char cSep = '(';\n      while( xRead(&sCtx) ){\n        zCreate = sqlite3_mprintf(\"%z%c\\n  \\\"%w\\\" TEXT\", zCreate, cSep, sCtx.z);\n        cSep = ',';\n        if( sCtx.cTerm!=sCtx.cColSep ) break;\n      }\n      if( cSep=='(' ){\n        sqlite3_free(zCreate);\n        sqlite3_free(sCtx.z);\n        xCloser(sCtx.in);\n        utf8_printf(stderr,\"%s: empty file\\n\", sCtx.zFile);\n        return 1;\n      }\n      zCreate = sqlite3_mprintf(\"%z\\n)\", zCreate);\n      rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);\n      sqlite3_free(zCreate);\n      if( rc ){\n        utf8_printf(stderr, \"CREATE TABLE %s(...) failed: %s\\n\", zTable,\n                sqlite3_errmsg(p->db));\n        sqlite3_free(sCtx.z);\n        xCloser(sCtx.in);\n        return 1;\n      }\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    }\n    sqlite3_free(zSql);\n    if( rc ){\n      if (pStmt) sqlite3_finalize(pStmt);\n      utf8_printf(stderr,\"Error: %s\\n\", sqlite3_errmsg(p->db));\n      xCloser(sCtx.in);\n      return 1;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( nCol==0 ) return 0; /* no columns, no error */\n    zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );\n    if( zSql==0 ){\n      raw_printf(stderr, \"Error: out of memory\\n\");\n      xCloser(sCtx.in);\n      return 1;\n    }\n    sqlite3_snprintf(nByte+20, zSql, \"INSERT INTO \\\"%w\\\" VALUES(?\", zTable);\n    j = strlen30(zSql);\n    for(i=1; i<nCol; i++){\n      zSql[j++] = ',';\n      zSql[j++] = '?';\n    }\n    zSql[j++] = ')';\n    zSql[j] = 0;\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      if (pStmt) sqlite3_finalize(pStmt);\n      xCloser(sCtx.in);\n      return 1;\n    }\n    needCommit = sqlite3_get_autocommit(p->db);\n    if( needCommit ) sqlite3_exec(p->db, \"BEGIN\", 0, 0, 0);\n    do{\n      int startLine = sCtx.nLine;\n      for(i=0; i<nCol; i++){\n        char *z = xRead(&sCtx);\n        /*\n        ** Did we reach end-of-file before finding any columns?\n        ** If so, stop instead of NULL filling the remaining columns.\n        */\n        if( z==0 && i==0 ) break;\n        /*\n        ** Did we reach end-of-file OR end-of-line before finding any\n        ** columns in ASCII mode?  If so, stop instead of NULL filling\n        ** the remaining columns.\n        */\n        if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break;\n        sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT);\n        if( i<nCol-1 && sCtx.cTerm!=sCtx.cColSep ){\n          utf8_printf(stderr, \"%s:%d: expected %d columns but found %d - \"\n                          \"filling the rest with NULL\\n\",\n                          sCtx.zFile, startLine, nCol, i+1);\n          i += 2;\n          while( i<=nCol ){ sqlite3_bind_null(pStmt, i); i++; }\n        }\n      }\n      if( sCtx.cTerm==sCtx.cColSep ){\n        do{\n          xRead(&sCtx);\n          i++;\n        }while( sCtx.cTerm==sCtx.cColSep );\n        utf8_printf(stderr, \"%s:%d: expected %d columns but found %d - \"\n                        \"extras ignored\\n\",\n                        sCtx.zFile, startLine, nCol, i);\n      }\n      if( i>=nCol ){\n        sqlite3_step(pStmt);\n        rc = sqlite3_reset(pStmt);\n        if( rc!=SQLITE_OK ){\n          utf8_printf(stderr, \"%s:%d: INSERT failed: %s\\n\", sCtx.zFile,\n                      startLine, sqlite3_errmsg(p->db));\n        }\n      }\n    }while( sCtx.cTerm!=EOF );\n\n    xCloser(sCtx.in);\n    sqlite3_free(sCtx.z);\n    sqlite3_finalize(pStmt);\n    if( needCommit ) sqlite3_exec(p->db, \"COMMIT\", 0, 0, 0);\n  }else\n\n#ifndef SQLITE_UNTESTABLE\n  if( c=='i' && strncmp(azArg[0], \"imposter\", n)==0 ){\n    char *zSql;\n    char *zCollist = 0;\n    sqlite3_stmt *pStmt;\n    int tnum = 0;\n    int i;\n    if( nArg!=3 ){\n      utf8_printf(stderr, \"Usage: .imposter INDEX IMPOSTER\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    zSql = sqlite3_mprintf(\"SELECT rootpage FROM sqlite_master\"\n                           \" WHERE name='%q' AND type='index'\", azArg[1]);\n    sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( sqlite3_step(pStmt)==SQLITE_ROW ){\n      tnum = sqlite3_column_int(pStmt, 0);\n    }\n    sqlite3_finalize(pStmt);\n    if( tnum==0 ){\n      utf8_printf(stderr, \"no such index: \\\"%s\\\"\\n\", azArg[1]);\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zSql = sqlite3_mprintf(\"PRAGMA index_xinfo='%q'\", azArg[1]);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    i = 0;\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      char zLabel[20];\n      const char *zCol = (const char*)sqlite3_column_text(pStmt,2);\n      i++;\n      if( zCol==0 ){\n        if( sqlite3_column_int(pStmt,1)==-1 ){\n          zCol = \"_ROWID_\";\n        }else{\n          sqlite3_snprintf(sizeof(zLabel),zLabel,\"expr%d\",i);\n          zCol = zLabel;\n        }\n      }\n      if( zCollist==0 ){\n        zCollist = sqlite3_mprintf(\"\\\"%w\\\"\", zCol);\n      }else{\n        zCollist = sqlite3_mprintf(\"%z,\\\"%w\\\"\", zCollist, zCol);\n      }\n    }\n    sqlite3_finalize(pStmt);\n    zSql = sqlite3_mprintf(\n          \"CREATE TABLE \\\"%w\\\"(%s,PRIMARY KEY(%s))WITHOUT ROWID\",\n          azArg[2], zCollist, zCollist);\n    sqlite3_free(zCollist);\n    rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, \"main\", 1, tnum);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, \"main\", 0, 0);\n      if( rc ){\n        utf8_printf(stderr, \"Error in [%s]: %s\\n\", zSql, sqlite3_errmsg(p->db));\n      }else{\n        utf8_printf(stdout, \"%s;\\n\", zSql);\n        raw_printf(stdout,\n           \"WARNING: writing to an imposter table will corrupt the index!\\n\"\n        );\n      }\n    }else{\n      raw_printf(stderr, \"SQLITE_TESTCTRL_IMPOSTER returns %d\\n\", rc);\n      rc = 1;\n    }\n    sqlite3_free(zSql);\n  }else\n#endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */\n\n#ifdef SQLITE_ENABLE_IOTRACE\n  if( c=='i' && strncmp(azArg[0], \"iotrace\", n)==0 ){\n    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);\n    if( iotrace && iotrace!=stdout ) fclose(iotrace);\n    iotrace = 0;\n    if( nArg<2 ){\n      sqlite3IoTrace = 0;\n    }else if( strcmp(azArg[1], \"-\")==0 ){\n      sqlite3IoTrace = iotracePrintf;\n      iotrace = stdout;\n    }else{\n      iotrace = fopen(azArg[1], \"w\");\n      if( iotrace==0 ){\n        utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n        sqlite3IoTrace = 0;\n        rc = 1;\n      }else{\n        sqlite3IoTrace = iotracePrintf;\n      }\n    }\n  }else\n#endif\n\n  if( c=='l' && n>=5 && strncmp(azArg[0], \"limits\", n)==0 ){\n    static const struct {\n       const char *zLimitName;   /* Name of a limit */\n       int limitCode;            /* Integer code for that limit */\n    } aLimit[] = {\n      { \"length\",                SQLITE_LIMIT_LENGTH                    },\n      { \"sql_length\",            SQLITE_LIMIT_SQL_LENGTH                },\n      { \"column\",                SQLITE_LIMIT_COLUMN                    },\n      { \"expr_depth\",            SQLITE_LIMIT_EXPR_DEPTH                },\n      { \"compound_select\",       SQLITE_LIMIT_COMPOUND_SELECT           },\n      { \"vdbe_op\",               SQLITE_LIMIT_VDBE_OP                   },\n      { \"function_arg\",          SQLITE_LIMIT_FUNCTION_ARG              },\n      { \"attached\",              SQLITE_LIMIT_ATTACHED                  },\n      { \"like_pattern_length\",   SQLITE_LIMIT_LIKE_PATTERN_LENGTH       },\n      { \"variable_number\",       SQLITE_LIMIT_VARIABLE_NUMBER           },\n      { \"trigger_depth\",         SQLITE_LIMIT_TRIGGER_DEPTH             },\n      { \"worker_threads\",        SQLITE_LIMIT_WORKER_THREADS            },\n    };\n    int i, n2;\n    open_db(p, 0);\n    if( nArg==1 ){\n      for(i=0; i<ArraySize(aLimit); i++){\n        printf(\"%20s %d\\n\", aLimit[i].zLimitName,\n               sqlite3_limit(p->db, aLimit[i].limitCode, -1));\n      }\n    }else if( nArg>3 ){\n      raw_printf(stderr, \"Usage: .limit NAME ?NEW-VALUE?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }else{\n      int iLimit = -1;\n      n2 = strlen30(azArg[1]);\n      for(i=0; i<ArraySize(aLimit); i++){\n        if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){\n          if( iLimit<0 ){\n            iLimit = i;\n          }else{\n            utf8_printf(stderr, \"ambiguous limit: \\\"%s\\\"\\n\", azArg[1]);\n            rc = 1;\n            goto meta_command_exit;\n          }\n        }\n      }\n      if( iLimit<0 ){\n        utf8_printf(stderr, \"unknown limit: \\\"%s\\\"\\n\"\n                        \"enter \\\".limits\\\" with no arguments for a list.\\n\",\n                         azArg[1]);\n        rc = 1;\n        goto meta_command_exit;\n      }\n      if( nArg==3 ){\n        sqlite3_limit(p->db, aLimit[iLimit].limitCode,\n                      (int)integerValue(azArg[2]));\n      }\n      printf(\"%20s %d\\n\", aLimit[iLimit].zLimitName,\n             sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));\n    }\n  }else\n\n  if( c=='l' && n>2 && strncmp(azArg[0], \"lint\", n)==0 ){\n    open_db(p, 0);\n    lintDotCommand(p, azArg, nArg);\n  }else\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  if( c=='l' && strncmp(azArg[0], \"load\", n)==0 ){\n    const char *zFile, *zProc;\n    char *zErrMsg = 0;\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .load FILE ?ENTRYPOINT?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zFile = azArg[1];\n    zProc = nArg>=3 ? azArg[2] : 0;\n    open_db(p, 0);\n    rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n#endif\n\n  if( c=='l' && strncmp(azArg[0], \"log\", n)==0 ){\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .log FILENAME\\n\");\n      rc = 1;\n    }else{\n      const char *zFile = azArg[1];\n      output_file_close(p->pLog);\n      p->pLog = output_file_open(zFile);\n    }\n  }else\n\n  if( c=='m' && strncmp(azArg[0], \"mode\", n)==0 ){\n    const char *zMode = nArg>=2 ? azArg[1] : \"\";\n    int n2 = (int)strlen(zMode);\n    int c2 = zMode[0];\n    if( c2=='l' && n2>2 && strncmp(azArg[1],\"lines\",n2)==0 ){\n      p->mode = MODE_Line;\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='c' && strncmp(azArg[1],\"columns\",n2)==0 ){\n      p->mode = MODE_Column;\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='l' && n2>2 && strncmp(azArg[1],\"list\",n2)==0 ){\n      p->mode = MODE_List;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Column);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='h' && strncmp(azArg[1],\"html\",n2)==0 ){\n      p->mode = MODE_Html;\n    }else if( c2=='t' && strncmp(azArg[1],\"tcl\",n2)==0 ){\n      p->mode = MODE_Tcl;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='c' && strncmp(azArg[1],\"csv\",n2)==0 ){\n      p->mode = MODE_Csv;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);\n    }else if( c2=='t' && strncmp(azArg[1],\"tabs\",n2)==0 ){\n      p->mode = MODE_List;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);\n    }else if( c2=='i' && strncmp(azArg[1],\"insert\",n2)==0 ){\n      p->mode = MODE_Insert;\n      set_table_name(p, nArg>=3 ? azArg[2] : \"table\");\n    }else if( c2=='q' && strncmp(azArg[1],\"quote\",n2)==0 ){\n      p->mode = MODE_Quote;\n    }else if( c2=='a' && strncmp(azArg[1],\"ascii\",n2)==0 ){\n      p->mode = MODE_Ascii;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);\n    }else if( nArg==1 ){\n      raw_printf(p->out, \"current output mode: %s\\n\", modeDescr[p->mode]);\n    }else{\n      raw_printf(stderr, \"Error: mode should be one of: \"\n         \"ascii column csv html insert line list quote tabs tcl\\n\");\n      rc = 1;\n    }\n    p->cMode = p->mode;\n  }else\n\n  if( c=='n' && strncmp(azArg[0], \"nullvalue\", n)==0 ){\n    if( nArg==2 ){\n      sqlite3_snprintf(sizeof(p->nullValue), p->nullValue,\n                       \"%.*s\", (int)ArraySize(p->nullValue)-1, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .nullvalue STRING\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='o' && strncmp(azArg[0], \"open\", n)==0 && n>=2 ){\n    char *zNewFilename;  /* Name of the database file to open */\n    int iName = 1;       /* Index in azArg[] of the filename */\n    int newFlag = 0;     /* True to delete file before opening */\n    /* Close the existing database */\n    session_close_all(p);\n    sqlite3_close(p->db);\n    p->db = 0;\n    p->zDbFilename = 0;\n    sqlite3_free(p->zFreeOnClose);\n    p->zFreeOnClose = 0;\n    /* Check for command-line arguments */\n    for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){\n      const char *z = azArg[iName];\n      if( optionMatch(z,\"new\") ){\n        newFlag = 1;\n      }else if( z[0]=='-' ){\n        utf8_printf(stderr, \"unknown option: %s\\n\", z);\n        rc = 1;\n        goto meta_command_exit;\n      }\n    }\n    /* If a filename is specified, try to open it first */\n    zNewFilename = nArg>iName ? sqlite3_mprintf(\"%s\", azArg[iName]) : 0;\n    if( zNewFilename ){\n      if( newFlag ) shellDeleteFile(zNewFilename);\n      p->zDbFilename = zNewFilename;\n      open_db(p, 1);\n      if( p->db==0 ){\n        utf8_printf(stderr, \"Error: cannot open '%s'\\n\", zNewFilename);\n        sqlite3_free(zNewFilename);\n      }else{\n        p->zFreeOnClose = zNewFilename;\n      }\n    }\n    if( p->db==0 ){\n      /* As a fall-back open a TEMP database */\n      p->zDbFilename = 0;\n      open_db(p, 0);\n    }\n  }else\n\n  if( c=='o'\n   && (strncmp(azArg[0], \"output\", n)==0 || strncmp(azArg[0], \"once\", n)==0)\n  ){\n    const char *zFile = nArg>=2 ? azArg[1] : \"stdout\";\n    if( nArg>2 ){\n      utf8_printf(stderr, \"Usage: .%s FILE\\n\", azArg[0]);\n      rc = 1;\n      goto meta_command_exit;\n    }\n    if( n>1 && strncmp(azArg[0], \"once\", n)==0 ){\n      if( nArg<2 ){\n        raw_printf(stderr, \"Usage: .once FILE\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      p->outCount = 2;\n    }else{\n      p->outCount = 0;\n    }\n    output_reset(p);\n    if( zFile[0]=='|' ){\n#ifdef SQLITE_OMIT_POPEN\n      raw_printf(stderr, \"Error: pipes are not supported in this OS\\n\");\n      rc = 1;\n      p->out = stdout;\n#else\n      p->out = popen(zFile + 1, \"w\");\n      if( p->out==0 ){\n        utf8_printf(stderr,\"Error: cannot open pipe \\\"%s\\\"\\n\", zFile + 1);\n        p->out = stdout;\n        rc = 1;\n      }else{\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", zFile);\n      }\n#endif\n    }else{\n      p->out = output_file_open(zFile);\n      if( p->out==0 ){\n        if( strcmp(zFile,\"off\")!=0 ){\n          utf8_printf(stderr,\"Error: cannot write to \\\"%s\\\"\\n\", zFile);\n        }\n        p->out = stdout;\n        rc = 1;\n      } else {\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", zFile);\n      }\n    }\n  }else\n\n  if( c=='p' && n>=3 && strncmp(azArg[0], \"print\", n)==0 ){\n    int i;\n    for(i=1; i<nArg; i++){\n      if( i>1 ) raw_printf(p->out, \" \");\n      utf8_printf(p->out, \"%s\", azArg[i]);\n    }\n    raw_printf(p->out, \"\\n\");\n  }else\n\n  if( c=='p' && strncmp(azArg[0], \"prompt\", n)==0 ){\n    if( nArg >= 2) {\n      strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);\n    }\n    if( nArg >= 3) {\n      strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);\n    }\n  }else\n\n  if( c=='q' && strncmp(azArg[0], \"quit\", n)==0 ){\n    rc = 2;\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"read\", n)==0 ){\n    FILE *alt;\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .read FILE\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    alt = fopen(azArg[1], \"rb\");\n    if( alt==0 ){\n      utf8_printf(stderr,\"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n      rc = 1;\n    }else{\n      rc = process_input(p, alt);\n      fclose(alt);\n    }\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"restore\", n)==0 ){\n    const char *zSrcFile;\n    const char *zDb;\n    sqlite3 *pSrc;\n    sqlite3_backup *pBackup;\n    int nTimeout = 0;\n\n    if( nArg==2 ){\n      zSrcFile = azArg[1];\n      zDb = \"main\";\n    }else if( nArg==3 ){\n      zSrcFile = azArg[2];\n      zDb = azArg[1];\n    }else{\n      raw_printf(stderr, \"Usage: .restore ?DB? FILE\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    rc = sqlite3_open(zSrcFile, &pSrc);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zSrcFile);\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    open_db(p, 0);\n    pBackup = sqlite3_backup_init(p->db, zDb, pSrc, \"main\");\n    if( pBackup==0 ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK\n          || rc==SQLITE_BUSY  ){\n      if( rc==SQLITE_BUSY ){\n        if( nTimeout++ >= 3 ) break;\n        sqlite3_sleep(100);\n      }\n    }\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      raw_printf(stderr, \"Error: source database is busy\\n\");\n      rc = 1;\n    }else{\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      rc = 1;\n    }\n    sqlite3_close(pSrc);\n  }else\n\n\n  if( c=='s' && strncmp(azArg[0], \"scanstats\", n)==0 ){\n    if( nArg==2 ){\n      p->scanstatsOn = booleanValue(azArg[1]);\n#ifndef SQLITE_ENABLE_STMT_SCANSTATUS\n      raw_printf(stderr, \"Warning: .scanstats not available in this build.\\n\");\n#endif\n    }else{\n      raw_printf(stderr, \"Usage: .scanstats on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"schema\", n)==0 ){\n    ShellText sSelect;\n    ShellState data;\n    char *zErrMsg = 0;\n    const char *zDiv = 0;\n    int iSchema = 0;\n\n    open_db(p, 0);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_Semi;\n    initText(&sSelect);\n    if( nArg>=2 && optionMatch(azArg[1], \"indent\") ){\n      data.cMode = data.mode = MODE_Pretty;\n      nArg--;\n      if( nArg==2 ) azArg[1] = azArg[2];\n    }\n    if( nArg==2 && azArg[1][0]!='-' ){\n      int i;\n      for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]);\n      if( strcmp(azArg[1],\"sqlite_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TABLE sqlite_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else if( strcmp(azArg[1],\"sqlite_temp_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TEMP TABLE sqlite_temp_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else{\n        zDiv = \"(\";\n      }\n    }else if( nArg==1 ){\n      zDiv = \"(\";\n    }else{\n      raw_printf(stderr, \"Usage: .schema ?--indent? ?LIKE-PATTERN?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    if( zDiv ){\n      sqlite3_stmt *pStmt = 0;\n      rc = sqlite3_prepare_v2(p->db, \"SELECT name FROM pragma_database_list\",\n                              -1, &pStmt, 0);\n      if( rc ){\n        utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n        sqlite3_finalize(pStmt);\n        rc = 1;\n        goto meta_command_exit;\n      }\n      appendText(&sSelect, \"SELECT sql FROM\", 0);\n      iSchema = 0;\n      while( sqlite3_step(pStmt)==SQLITE_ROW ){\n        const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);\n        char zScNum[30];\n        sqlite3_snprintf(sizeof(zScNum), zScNum, \"%d\", ++iSchema);\n        appendText(&sSelect, zDiv, 0);\n        zDiv = \" UNION ALL \";\n        if( strcmp(zDb, \"main\")!=0 ){\n          appendText(&sSelect, \"SELECT shell_add_schema(sql,\", 0);\n          appendText(&sSelect, zDb, '\"');\n          appendText(&sSelect, \") AS sql, type, tbl_name, name, rowid,\", 0);\n          appendText(&sSelect, zScNum, 0);\n          appendText(&sSelect, \" AS snum, \", 0);\n          appendText(&sSelect, zDb, '\\'');\n          appendText(&sSelect, \" AS sname FROM \", 0);\n          appendText(&sSelect, zDb, '\"');\n          appendText(&sSelect, \".sqlite_master\", 0);\n        }else{\n          appendText(&sSelect, \"SELECT sql, type, tbl_name, name, rowid, \", 0);\n          appendText(&sSelect, zScNum, 0);\n          appendText(&sSelect, \" AS snum, 'main' AS sname FROM sqlite_master\",0);\n        }\n      }\n      sqlite3_finalize(pStmt);\n      appendText(&sSelect, \") WHERE \", 0);\n      if( nArg>1 ){\n        char *zQarg = sqlite3_mprintf(\"%Q\", azArg[1]);\n        if( strchr(azArg[1], '.') ){\n          appendText(&sSelect, \"lower(printf('%s.%s',sname,tbl_name))\", 0);\n        }else{\n          appendText(&sSelect, \"lower(tbl_name)\", 0);\n        }\n        appendText(&sSelect, strchr(azArg[1], '*') ? \" GLOB \" : \" LIKE \", 0);\n        appendText(&sSelect, zQarg, 0);\n        appendText(&sSelect, \" AND \", 0);\n        sqlite3_free(zQarg);\n      }\n      appendText(&sSelect, \"type!='meta' AND sql IS NOT NULL\"\n                           \" ORDER BY snum, rowid\", 0);\n      rc = sqlite3_exec(p->db, sSelect.z, callback, &data, &zErrMsg);\n      freeText(&sSelect);\n    }\n    if( zErrMsg ){\n      utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }else if( rc != SQLITE_OK ){\n      raw_printf(stderr,\"Error: querying schema information\\n\");\n      rc = 1;\n    }else{\n      rc = 0;\n    }\n  }else\n\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  if( c=='s' && n==11 && strncmp(azArg[0], \"selecttrace\", n)==0 ){\n    sqlite3SelectTrace = (int)integerValue(azArg[1]);\n  }else\n#endif\n\n#if defined(SQLITE_ENABLE_SESSION)\n  if( c=='s' && strncmp(azArg[0],\"session\",n)==0 && n>=3 ){\n    OpenSession *pSession = &p->aSession[0];\n    char **azCmd = &azArg[1];\n    int iSes = 0;\n    int nCmd = nArg - 1;\n    int i;\n    if( nArg<=1 ) goto session_syntax_error;\n    open_db(p, 0);\n    if( nArg>=3 ){\n      for(iSes=0; iSes<p->nSession; iSes++){\n        if( strcmp(p->aSession[iSes].zName, azArg[1])==0 ) break;\n      }\n      if( iSes<p->nSession ){\n        pSession = &p->aSession[iSes];\n        azCmd++;\n        nCmd--;\n      }else{\n        pSession = &p->aSession[0];\n        iSes = 0;\n      }\n    }\n\n    /* .session attach TABLE\n    ** Invoke the sqlite3session_attach() interface to attach a particular\n    ** table so that it is never filtered.\n    */\n    if( strcmp(azCmd[0],\"attach\")==0 ){\n      if( nCmd!=2 ) goto session_syntax_error;\n      if( pSession->p==0 ){\n        session_not_open:\n        raw_printf(stderr, \"ERROR: No sessions are open\\n\");\n      }else{\n        rc = sqlite3session_attach(pSession->p, azCmd[1]);\n        if( rc ){\n          raw_printf(stderr, \"ERROR: sqlite3session_attach() returns %d\\n\", rc);\n          rc = 0;\n        }\n      }\n    }else\n\n    /* .session changeset FILE\n    ** .session patchset FILE\n    ** Write a changeset or patchset into a file.  The file is overwritten.\n    */\n    if( strcmp(azCmd[0],\"changeset\")==0 || strcmp(azCmd[0],\"patchset\")==0 ){\n      FILE *out = 0;\n      if( nCmd!=2 ) goto session_syntax_error;\n      if( pSession->p==0 ) goto session_not_open;\n      out = fopen(azCmd[1], \"wb\");\n      if( out==0 ){\n        utf8_printf(stderr, \"ERROR: cannot open \\\"%s\\\" for writing\\n\", azCmd[1]);\n      }else{\n        int szChng;\n        void *pChng;\n        if( azCmd[0][0]=='c' ){\n          rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);\n        }else{\n          rc = sqlite3session_patchset(pSession->p, &szChng, &pChng);\n        }\n        if( rc ){\n          printf(\"Error: error code %d\\n\", rc);\n          rc = 0;\n        }\n        if( pChng\n          && fwrite(pChng, szChng, 1, out)!=1 ){\n          raw_printf(stderr, \"ERROR: Failed to write entire %d-byte output\\n\",\n                  szChng);\n        }\n        sqlite3_free(pChng);\n        fclose(out);\n      }\n    }else\n\n    /* .session close\n    ** Close the identified session\n    */\n    if( strcmp(azCmd[0], \"close\")==0 ){\n      if( nCmd!=1 ) goto session_syntax_error;\n      if( p->nSession ){\n        session_close(pSession);\n        p->aSession[iSes] = p->aSession[--p->nSession];\n      }\n    }else\n\n    /* .session enable ?BOOLEAN?\n    ** Query or set the enable flag\n    */\n    if( strcmp(azCmd[0], \"enable\")==0 ){\n      int ii;\n      if( nCmd>2 ) goto session_syntax_error;\n      ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);\n      if( p->nSession ){\n        ii = sqlite3session_enable(pSession->p, ii);\n        utf8_printf(p->out, \"session %s enable flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session filter GLOB ....\n    ** Set a list of GLOB patterns of table names to be excluded.\n    */\n    if( strcmp(azCmd[0], \"filter\")==0 ){\n      int ii, nByte;\n      if( nCmd<2 ) goto session_syntax_error;\n      if( p->nSession ){\n        for(ii=0; ii<pSession->nFilter; ii++){\n          sqlite3_free(pSession->azFilter[ii]);\n        }\n        sqlite3_free(pSession->azFilter);\n        nByte = sizeof(pSession->azFilter[0])*(nCmd-1);\n        pSession->azFilter = sqlite3_malloc( nByte );\n        if( pSession->azFilter==0 ){\n          raw_printf(stderr, \"Error: out or memory\\n\");\n          exit(1);\n        }\n        for(ii=1; ii<nCmd; ii++){\n          pSession->azFilter[ii-1] = sqlite3_mprintf(\"%s\", azCmd[ii]);\n        }\n        pSession->nFilter = ii-1;\n      }\n    }else\n\n    /* .session indirect ?BOOLEAN?\n    ** Query or set the indirect flag\n    */\n    if( strcmp(azCmd[0], \"indirect\")==0 ){\n      int ii;\n      if( nCmd>2 ) goto session_syntax_error;\n      ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);\n      if( p->nSession ){\n        ii = sqlite3session_indirect(pSession->p, ii);\n        utf8_printf(p->out, \"session %s indirect flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session isempty\n    ** Determine if the session is empty\n    */\n    if( strcmp(azCmd[0], \"isempty\")==0 ){\n      int ii;\n      if( nCmd!=1 ) goto session_syntax_error;\n      if( p->nSession ){\n        ii = sqlite3session_isempty(pSession->p);\n        utf8_printf(p->out, \"session %s isempty flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session list\n    ** List all currently open sessions\n    */\n    if( strcmp(azCmd[0],\"list\")==0 ){\n      for(i=0; i<p->nSession; i++){\n        utf8_printf(p->out, \"%d %s\\n\", i, p->aSession[i].zName);\n      }\n    }else\n\n    /* .session open DB NAME\n    ** Open a new session called NAME on the attached database DB.\n    ** DB is normally \"main\".\n    */\n    if( strcmp(azCmd[0],\"open\")==0 ){\n      char *zName;\n      if( nCmd!=3 ) goto session_syntax_error;\n      zName = azCmd[2];\n      if( zName[0]==0 ) goto session_syntax_error;\n      for(i=0; i<p->nSession; i++){\n        if( strcmp(p->aSession[i].zName,zName)==0 ){\n          utf8_printf(stderr, \"Session \\\"%s\\\" already exists\\n\", zName);\n          goto meta_command_exit;\n        }\n      }\n      if( p->nSession>=ArraySize(p->aSession) ){\n        raw_printf(stderr, \"Maximum of %d sessions\\n\", ArraySize(p->aSession));\n        goto meta_command_exit;\n      }\n      pSession = &p->aSession[p->nSession];\n      rc = sqlite3session_create(p->db, azCmd[1], &pSession->p);\n      if( rc ){\n        raw_printf(stderr, \"Cannot open session: error code=%d\\n\", rc);\n        rc = 0;\n        goto meta_command_exit;\n      }\n      pSession->nFilter = 0;\n      sqlite3session_table_filter(pSession->p, session_filter, pSession);\n      p->nSession++;\n      pSession->zName = sqlite3_mprintf(\"%s\", zName);\n    }else\n    /* If no command name matches, show a syntax error */\n    session_syntax_error:\n    session_help(p);\n  }else\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Undocumented commands for internal testing.  Subject to change\n  ** without notice. */\n  if( c=='s' && n>=10 && strncmp(azArg[0], \"selftest-\", 9)==0 ){\n    if( strncmp(azArg[0]+9, \"boolean\", n-9)==0 ){\n      int i, v;\n      for(i=1; i<nArg; i++){\n        v = booleanValue(azArg[i]);\n        utf8_printf(p->out, \"%s: %d 0x%x\\n\", azArg[i], v, v);\n      }\n    }\n    if( strncmp(azArg[0]+9, \"integer\", n-9)==0 ){\n      int i; sqlite3_int64 v;\n      for(i=1; i<nArg; i++){\n        char zBuf[200];\n        v = integerValue(azArg[i]);\n        sqlite3_snprintf(sizeof(zBuf),zBuf,\"%s: %lld 0x%llx\\n\", azArg[i],v,v);\n        utf8_printf(p->out, \"%s\", zBuf);\n      }\n    }\n  }else\n#endif\n\n  if( c=='s' && n>=4 && strncmp(azArg[0],\"selftest\",n)==0 ){\n    int bIsInit = 0;         /* True to initialize the SELFTEST table */\n    int bVerbose = 0;        /* Verbose output */\n    int bSelftestExists;     /* True if SELFTEST already exists */\n    int i, k;                /* Loop counters */\n    int nTest = 0;           /* Number of tests runs */\n    int nErr = 0;            /* Number of errors seen */\n    ShellText str;           /* Answer for a query */\n    sqlite3_stmt *pStmt = 0; /* Query against the SELFTEST table */\n\n    open_db(p,0);\n    for(i=1; i<nArg; i++){\n      const char *z = azArg[i];\n      if( z[0]=='-' && z[1]=='-' ) z++;\n      if( strcmp(z,\"-init\")==0 ){\n        bIsInit = 1;\n      }else\n      if( strcmp(z,\"-v\")==0 ){\n        bVerbose++;\n      }else\n      {\n        utf8_printf(stderr, \"Unknown option \\\"%s\\\" on \\\"%s\\\"\\n\",\n                    azArg[i], azArg[0]);\n        raw_printf(stderr, \"Should be one of: --init -v\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n    }\n    if( sqlite3_table_column_metadata(p->db,\"main\",\"selftest\",0,0,0,0,0,0)\n           != SQLITE_OK ){\n      bSelftestExists = 0;\n    }else{\n      bSelftestExists = 1;\n    }\n    if( bIsInit ){\n      createSelftestTable(p);\n      bSelftestExists = 1;\n    }\n    initText(&str);\n    appendText(&str, \"x\", 0);\n    for(k=bSelftestExists; k>=0; k--){\n      if( k==1 ){\n        rc = sqlite3_prepare_v2(p->db,\n            \"SELECT tno,op,cmd,ans FROM selftest ORDER BY tno\",\n            -1, &pStmt, 0);\n      }else{\n        rc = sqlite3_prepare_v2(p->db,\n          \"VALUES(0,'memo','Missing SELFTEST table - default checks only',''),\"\n          \"      (1,'run','PRAGMA integrity_check','ok')\",\n          -1, &pStmt, 0);\n      }\n      if( rc ){\n        raw_printf(stderr, \"Error querying the selftest table\\n\");\n        rc = 1;\n        sqlite3_finalize(pStmt);\n        goto meta_command_exit;\n      }\n      for(i=1; sqlite3_step(pStmt)==SQLITE_ROW; i++){\n        int tno = sqlite3_column_int(pStmt, 0);\n        const char *zOp = (const char*)sqlite3_column_text(pStmt, 1);\n        const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);\n        const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);\n\n        k = 0;\n        if( bVerbose>0 ){\n          char *zQuote = sqlite3_mprintf(\"%q\", zSql);\n          printf(\"%d: %s %s\\n\", tno, zOp, zSql);\n          sqlite3_free(zQuote);\n        }\n        if( strcmp(zOp,\"memo\")==0 ){\n          utf8_printf(p->out, \"%s\\n\", zSql);\n        }else\n        if( strcmp(zOp,\"run\")==0 ){\n          char *zErrMsg = 0;\n          str.n = 0;\n          str.z[0] = 0;\n          rc = sqlite3_exec(p->db, zSql, captureOutputCallback, &str, &zErrMsg);\n          nTest++;\n          if( bVerbose ){\n            utf8_printf(p->out, \"Result: %s\\n\", str.z);\n          }\n          if( rc || zErrMsg ){\n            nErr++;\n            rc = 1;\n            utf8_printf(p->out, \"%d: error-code-%d: %s\\n\", tno, rc, zErrMsg);\n            sqlite3_free(zErrMsg);\n          }else if( strcmp(zAns,str.z)!=0 ){\n            nErr++;\n            rc = 1;\n            utf8_printf(p->out, \"%d: Expected: [%s]\\n\", tno, zAns);\n            utf8_printf(p->out, \"%d:      Got: [%s]\\n\", tno, str.z);\n          }\n        }else\n        {\n          utf8_printf(stderr,\n            \"Unknown operation \\\"%s\\\" on selftest line %d\\n\", zOp, tno);\n          rc = 1;\n          break;\n        }\n      } /* End loop over rows of content from SELFTEST */\n      sqlite3_finalize(pStmt);\n    } /* End loop over k */\n    freeText(&str);\n    utf8_printf(p->out, \"%d errors out of %d tests\\n\", nErr, nTest);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"separator\", n)==0 ){\n    if( nArg<2 || nArg>3 ){\n      raw_printf(stderr, \"Usage: .separator COL ?ROW?\\n\");\n      rc = 1;\n    }\n    if( nArg>=2 ){\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator,\n                       \"%.*s\", (int)ArraySize(p->colSeparator)-1, azArg[1]);\n    }\n    if( nArg>=3 ){\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator,\n                       \"%.*s\", (int)ArraySize(p->rowSeparator)-1, azArg[2]);\n    }\n  }else\n\n  if( c=='s' && n>=4 && strncmp(azArg[0],\"sha3sum\",n)==0 ){\n    const char *zLike = 0;   /* Which table to checksum. 0 means everything */\n    int i;                   /* Loop counter */\n    int bSchema = 0;         /* Also hash the schema */\n    int bSeparate = 0;       /* Hash each table separately */\n    int iSize = 224;         /* Hash algorithm to use */\n    int bDebug = 0;          /* Only show the query that would have run */\n    sqlite3_stmt *pStmt;     /* For querying tables names */\n    char *zSql;              /* SQL to be run */\n    char *zSep;              /* Separator */\n    ShellText sSql;          /* Complete SQL for the query to run the hash */\n    ShellText sQuery;        /* Set of queries used to read all content */\n    open_db(p, 0);\n    for(i=1; i<nArg; i++){\n      const char *z = azArg[i];\n      if( z[0]=='-' ){\n        z++;\n        if( z[0]=='-' ) z++;\n        if( strcmp(z,\"schema\")==0 ){\n          bSchema = 1;\n        }else\n        if( strcmp(z,\"sha3-224\")==0 || strcmp(z,\"sha3-256\")==0\n         || strcmp(z,\"sha3-384\")==0 || strcmp(z,\"sha3-512\")==0\n        ){\n          iSize = atoi(&z[5]);\n        }else\n        if( strcmp(z,\"debug\")==0 ){\n          bDebug = 1;\n        }else\n        {\n          utf8_printf(stderr, \"Unknown option \\\"%s\\\" on \\\"%s\\\"\\n\",\n                      azArg[i], azArg[0]);\n          raw_printf(stderr, \"Should be one of: --schema\"\n                             \" --sha3-224 --sha3-255 --sha3-384 --sha3-512\\n\");\n          rc = 1;\n          goto meta_command_exit;\n        }\n      }else if( zLike ){\n        raw_printf(stderr, \"Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }else{\n        zLike = z;\n        bSeparate = 1;\n        if( sqlite3_strlike(\"sqlite_%\", zLike, 0)==0 ) bSchema = 1;\n      }\n    }\n    if( bSchema ){\n      zSql = \"SELECT lower(name) FROM sqlite_master\"\n             \" WHERE type='table' AND coalesce(rootpage,0)>1\"\n             \" UNION ALL SELECT 'sqlite_master'\"\n             \" ORDER BY 1 collate nocase\";\n    }else{\n      zSql = \"SELECT lower(name) FROM sqlite_master\"\n             \" WHERE type='table' AND coalesce(rootpage,0)>1\"\n             \" AND name NOT LIKE 'sqlite_%'\"\n             \" ORDER BY 1 collate nocase\";\n    }\n    sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    initText(&sQuery);\n    initText(&sSql);\n    appendText(&sSql, \"WITH [sha3sum$query](a,b) AS(\",0);\n    zSep = \"VALUES(\";\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zTab = (const char*)sqlite3_column_text(pStmt,0);\n      if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;\n      if( strncmp(zTab, \"sqlite_\",7)!=0 ){\n        appendText(&sQuery,\"SELECT * FROM \", 0);\n        appendText(&sQuery,zTab,'\"');\n        appendText(&sQuery,\" NOT INDEXED;\", 0);\n      }else if( strcmp(zTab, \"sqlite_master\")==0 ){\n        appendText(&sQuery,\"SELECT type,name,tbl_name,sql FROM sqlite_master\"\n                           \" ORDER BY name;\", 0);\n      }else if( strcmp(zTab, \"sqlite_sequence\")==0 ){\n        appendText(&sQuery,\"SELECT name,seq FROM sqlite_sequence\"\n                           \" ORDER BY name;\", 0);\n      }else if( strcmp(zTab, \"sqlite_stat1\")==0 ){\n        appendText(&sQuery,\"SELECT tbl,idx,stat FROM sqlite_stat1\"\n                           \" ORDER BY tbl,idx;\", 0);\n      }else if( strcmp(zTab, \"sqlite_stat3\")==0\n             || strcmp(zTab, \"sqlite_stat4\")==0 ){\n        appendText(&sQuery, \"SELECT * FROM \", 0);\n        appendText(&sQuery, zTab, 0);\n        appendText(&sQuery, \" ORDER BY tbl, idx, rowid;\\n\", 0);\n      }\n      appendText(&sSql, zSep, 0);\n      appendText(&sSql, sQuery.z, '\\'');\n      sQuery.n = 0;\n      appendText(&sSql, \",\", 0);\n      appendText(&sSql, zTab, '\\'');\n      zSep = \"),(\";\n    }\n    sqlite3_finalize(pStmt);\n    if( bSeparate ){\n      zSql = sqlite3_mprintf(\n          \"%s))\"\n          \" SELECT lower(hex(sha3_query(a,%d))) AS hash, b AS label\"\n          \"   FROM [sha3sum$query]\",\n          sSql.z, iSize);\n    }else{\n      zSql = sqlite3_mprintf(\n          \"%s))\"\n          \" SELECT lower(hex(sha3_query(group_concat(a,''),%d))) AS hash\"\n          \"   FROM [sha3sum$query]\",\n          sSql.z, iSize);\n    }\n    freeText(&sQuery);\n    freeText(&sSql);\n    if( bDebug ){\n      utf8_printf(p->out, \"%s\\n\", zSql);\n    }else{\n      shell_exec(p->db, zSql, shell_callback, p, 0);\n    }\n    sqlite3_free(zSql);\n  }else\n\n  if( c=='s'\n   && (strncmp(azArg[0], \"shell\", n)==0 || strncmp(azArg[0],\"system\",n)==0)\n  ){\n    char *zCmd;\n    int i, x;\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .system COMMAND\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?\"%s\":\"\\\"%s\\\"\", azArg[1]);\n    for(i=2; i<nArg; i++){\n      zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?\"%z %s\":\"%z \\\"%s\\\"\",\n                             zCmd, azArg[i]);\n    }\n    x = system(zCmd);\n    sqlite3_free(zCmd);\n    if( x ) raw_printf(stderr, \"System command returns %d\\n\", x);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"show\", n)==0 ){\n    static const char *azBool[] = { \"off\", \"on\", \"full\", \"unk\" };\n    int i;\n    if( nArg!=1 ){\n      raw_printf(stderr, \"Usage: .show\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"echo\",\n                                  azBool[ShellHasFlag(p, SHFLG_Echo)]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"eqp\", azBool[p->autoEQP&3]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"explain\",\n         p->mode==MODE_Explain ? \"on\" : p->autoExplain ? \"auto\" : \"off\");\n    utf8_printf(p->out,\"%12.12s: %s\\n\",\"headers\", azBool[p->showHeader!=0]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"mode\", modeDescr[p->mode]);\n    utf8_printf(p->out, \"%12.12s: \", \"nullvalue\");\n      output_c_string(p->out, p->nullValue);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out,\"%12.12s: %s\\n\",\"output\",\n            strlen30(p->outfile) ? p->outfile : \"stdout\");\n    utf8_printf(p->out,\"%12.12s: \", \"colseparator\");\n      output_c_string(p->out, p->colSeparator);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out,\"%12.12s: \", \"rowseparator\");\n      output_c_string(p->out, p->rowSeparator);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"stats\", azBool[p->statsOn!=0]);\n    utf8_printf(p->out, \"%12.12s: \", \"width\");\n    for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {\n      raw_printf(p->out, \"%d \", p->colWidth[i]);\n    }\n    raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out, \"%12.12s: %s\\n\", \"filename\",\n                p->zDbFilename ? p->zDbFilename : \"\");\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"stats\", n)==0 ){\n    if( nArg==2 ){\n      p->statsOn = booleanValue(azArg[1]);\n    }else if( nArg==1 ){\n      display_stats(p->db, p, 0);\n    }else{\n      raw_printf(stderr, \"Usage: .stats ?on|off?\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( (c=='t' && n>1 && strncmp(azArg[0], \"tables\", n)==0)\n   || (c=='i' && (strncmp(azArg[0], \"indices\", n)==0\n                 || strncmp(azArg[0], \"indexes\", n)==0) )\n  ){\n    sqlite3_stmt *pStmt;\n    char **azResult;\n    int nRow, nAlloc;\n    int ii;\n    ShellText s;\n    initText(&s);\n    open_db(p, 0);\n    rc = sqlite3_prepare_v2(p->db, \"PRAGMA database_list\", -1, &pStmt, 0);\n    if( rc ) return shellDatabaseError(p->db);\n\n    if( nArg>2 && c=='i' ){\n      /* It is an historical accident that the .indexes command shows an error\n      ** when called with the wrong number of arguments whereas the .tables\n      ** command does not. */\n      raw_printf(stderr, \"Usage: .indexes ?LIKE-PATTERN?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){\n      const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zDbName==0 ) continue;\n      if( s.z && s.z[0] ) appendText(&s, \" UNION ALL \", 0);\n      if( sqlite3_stricmp(zDbName, \"main\")==0 ){\n        appendText(&s, \"SELECT name FROM \", 0);\n      }else{\n        appendText(&s, \"SELECT \", 0);\n        appendText(&s, zDbName, '\\'');\n        appendText(&s, \"||'.'||name FROM \", 0);\n      }\n      appendText(&s, zDbName, '\"');\n      appendText(&s, \".sqlite_master \", 0);\n      if( c=='t' ){\n        appendText(&s,\" WHERE type IN ('table','view')\"\n                      \"   AND name NOT LIKE 'sqlite_%'\"\n                      \"   AND name LIKE ?1\", 0);\n      }else{\n        appendText(&s,\" WHERE type='index'\"\n                      \"   AND tbl_name LIKE ?1\", 0);\n      }\n    }\n    rc = sqlite3_finalize(pStmt);\n    appendText(&s, \" ORDER BY 1\", 0);\n    rc = sqlite3_prepare_v2(p->db, s.z, -1, &pStmt, 0);\n    freeText(&s);\n    if( rc ) return shellDatabaseError(p->db);\n\n    /* Run the SQL statement prepared by the above block. Store the results\n    ** as an array of nul-terminated strings in azResult[].  */\n    nRow = nAlloc = 0;\n    azResult = 0;\n    if( nArg>1 ){\n      sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT);\n    }else{\n      sqlite3_bind_text(pStmt, 1, \"%\", -1, SQLITE_STATIC);\n    }\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      if( nRow>=nAlloc ){\n        char **azNew;\n        int n2 = nAlloc*2 + 10;\n        azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);\n        if( azNew==0 ){\n          rc = shellNomemError();\n          break;\n        }\n        nAlloc = n2;\n        azResult = azNew;\n      }\n      azResult[nRow] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 0));\n      if( 0==azResult[nRow] ){\n        rc = shellNomemError();\n        break;\n      }\n      nRow++;\n    }\n    if( sqlite3_finalize(pStmt)!=SQLITE_OK ){\n      rc = shellDatabaseError(p->db);\n    }\n\n    /* Pretty-print the contents of array azResult[] to the output */\n    if( rc==0 && nRow>0 ){\n      int len, maxlen = 0;\n      int i, j;\n      int nPrintCol, nPrintRow;\n      for(i=0; i<nRow; i++){\n        len = strlen30(azResult[i]);\n        if( len>maxlen ) maxlen = len;\n      }\n      nPrintCol = 80/(maxlen+2);\n      if( nPrintCol<1 ) nPrintCol = 1;\n      nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;\n      for(i=0; i<nPrintRow; i++){\n        for(j=i; j<nRow; j+=nPrintRow){\n          char *zSp = j<nPrintRow ? \"\" : \"  \";\n          utf8_printf(p->out, \"%s%-*s\", zSp, maxlen,\n                      azResult[j] ? azResult[j]:\"\");\n        }\n        raw_printf(p->out, \"\\n\");\n      }\n    }\n\n    for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);\n    sqlite3_free(azResult);\n  }else\n\n  /* Begin redirecting output to the file \"testcase-out.txt\" */\n  if( c=='t' && strcmp(azArg[0],\"testcase\")==0 ){\n    output_reset(p);\n    p->out = output_file_open(\"testcase-out.txt\");\n    if( p->out==0 ){\n      raw_printf(stderr, \"Error: cannot open 'testcase-out.txt'\\n\");\n    }\n    if( nArg>=2 ){\n      sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, \"%s\", azArg[1]);\n    }else{\n      sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, \"?\");\n    }\n  }else\n\n#ifndef SQLITE_UNTESTABLE\n  if( c=='t' && n>=8 && strncmp(azArg[0], \"testctrl\", n)==0 && nArg>=2 ){\n    static const struct {\n       const char *zCtrlName;   /* Name of a test-control option */\n       int ctrlCode;            /* Integer code for that option */\n    } aCtrl[] = {\n      { \"prng_save\",             SQLITE_TESTCTRL_PRNG_SAVE              },\n      { \"prng_restore\",          SQLITE_TESTCTRL_PRNG_RESTORE           },\n      { \"prng_reset\",            SQLITE_TESTCTRL_PRNG_RESET             },\n      { \"bitvec_test\",           SQLITE_TESTCTRL_BITVEC_TEST            },\n      { \"fault_install\",         SQLITE_TESTCTRL_FAULT_INSTALL          },\n      { \"benign_malloc_hooks\",   SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS    },\n      { \"pending_byte\",          SQLITE_TESTCTRL_PENDING_BYTE           },\n      { \"assert\",                SQLITE_TESTCTRL_ASSERT                 },\n      { \"always\",                SQLITE_TESTCTRL_ALWAYS                 },\n      { \"reserve\",               SQLITE_TESTCTRL_RESERVE                },\n      { \"optimizations\",         SQLITE_TESTCTRL_OPTIMIZATIONS          },\n      { \"iskeyword\",             SQLITE_TESTCTRL_ISKEYWORD              },\n      { \"byteorder\",             SQLITE_TESTCTRL_BYTEORDER              },\n      { \"never_corrupt\",         SQLITE_TESTCTRL_NEVER_CORRUPT          },\n      { \"imposter\",              SQLITE_TESTCTRL_IMPOSTER               },\n    };\n    int testctrl = -1;\n    int rc2 = 0;\n    int i, n2;\n    open_db(p, 0);\n\n    /* convert testctrl text option to value. allow any unique prefix\n    ** of the option name, or a numerical value. */\n    n2 = strlen30(azArg[1]);\n    for(i=0; i<ArraySize(aCtrl); i++){\n      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){\n        if( testctrl<0 ){\n          testctrl = aCtrl[i].ctrlCode;\n        }else{\n          utf8_printf(stderr, \"ambiguous option name: \\\"%s\\\"\\n\", azArg[1]);\n          testctrl = -1;\n          break;\n        }\n      }\n    }\n    if( testctrl<0 ) testctrl = (int)integerValue(azArg[1]);\n    if( (testctrl<SQLITE_TESTCTRL_FIRST) || (testctrl>SQLITE_TESTCTRL_LAST) ){\n      utf8_printf(stderr,\"Error: invalid testctrl option: %s\\n\", azArg[1]);\n    }else{\n      switch(testctrl){\n\n        /* sqlite3_test_control(int, db, int) */\n        case SQLITE_TESTCTRL_OPTIMIZATIONS:\n        case SQLITE_TESTCTRL_RESERVE:\n          if( nArg==3 ){\n            int opt = (int)strtol(azArg[2], 0, 0);\n            rc2 = sqlite3_test_control(testctrl, p->db, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                    azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int) */\n        case SQLITE_TESTCTRL_PRNG_SAVE:\n        case SQLITE_TESTCTRL_PRNG_RESTORE:\n        case SQLITE_TESTCTRL_PRNG_RESET:\n        case SQLITE_TESTCTRL_BYTEORDER:\n          if( nArg==2 ){\n            rc2 = sqlite3_test_control(testctrl);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes no options\\n\",\n                        azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, uint) */\n        case SQLITE_TESTCTRL_PENDING_BYTE:\n          if( nArg==3 ){\n            unsigned int opt = (unsigned int)integerValue(azArg[2]);\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single unsigned\"\n                           \" int option\\n\", azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, int) */\n        case SQLITE_TESTCTRL_ASSERT:\n        case SQLITE_TESTCTRL_ALWAYS:\n        case SQLITE_TESTCTRL_NEVER_CORRUPT:\n          if( nArg==3 ){\n            int opt = booleanValue(azArg[2]);\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                            azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, char *) */\n#ifdef SQLITE_N_KEYWORD\n        case SQLITE_TESTCTRL_ISKEYWORD:\n          if( nArg==3 ){\n            const char *opt = azArg[2];\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\n                        \"Error: testctrl %s takes a single char * option\\n\",\n                        azArg[1]);\n          }\n          break;\n#endif\n\n        case SQLITE_TESTCTRL_IMPOSTER:\n          if( nArg==5 ){\n            rc2 = sqlite3_test_control(testctrl, p->db,\n                          azArg[2],\n                          integerValue(azArg[3]),\n                          integerValue(azArg[4]));\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          }else{\n            raw_printf(stderr,\"Usage: .testctrl imposter dbName onoff tnum\\n\");\n          }\n          break;\n\n        case SQLITE_TESTCTRL_BITVEC_TEST:\n        case SQLITE_TESTCTRL_FAULT_INSTALL:\n        case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:\n        default:\n          utf8_printf(stderr,\n                      \"Error: CLI support for testctrl %s not implemented\\n\",\n                      azArg[1]);\n          break;\n      }\n    }\n  }else\n#endif /* !defined(SQLITE_UNTESTABLE) */\n\n  if( c=='t' && n>4 && strncmp(azArg[0], \"timeout\", n)==0 ){\n    open_db(p, 0);\n    sqlite3_busy_timeout(p->db, nArg>=2 ? (int)integerValue(azArg[1]) : 0);\n  }else\n\n  if( c=='t' && n>=5 && strncmp(azArg[0], \"timer\", n)==0 ){\n    if( nArg==2 ){\n      enableTimer = booleanValue(azArg[1]);\n      if( enableTimer && !HAS_TIMER ){\n        raw_printf(stderr, \"Error: timer not available on this system.\\n\");\n        enableTimer = 0;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .timer on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='t' && strncmp(azArg[0], \"trace\", n)==0 ){\n    open_db(p, 0);\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .trace FILE|off\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    output_file_close(p->traceOut);\n    p->traceOut = output_file_open(azArg[1]);\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    if( p->traceOut==0 ){\n      sqlite3_trace_v2(p->db, 0, 0, 0);\n    }else{\n      sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);\n    }\n#endif\n  }else\n\n#if SQLITE_USER_AUTHENTICATION\n  if( c=='u' && strncmp(azArg[0], \"user\", n)==0 ){\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .user SUBCOMMAND ...\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    if( strcmp(azArg[1],\"login\")==0 ){\n      if( nArg!=4 ){\n        raw_printf(stderr, \"Usage: .user login USER PASSWORD\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],\n                                    (int)strlen(azArg[3]));\n      if( rc ){\n        utf8_printf(stderr, \"Authentication failed for user %s\\n\", azArg[2]);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"add\")==0 ){\n      if( nArg!=5 ){\n        raw_printf(stderr, \"Usage: .user add USER PASSWORD ISADMIN\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_add(p->db, azArg[2],\n                            azArg[3], (int)strlen(azArg[3]),\n                            booleanValue(azArg[4]));\n      if( rc ){\n        raw_printf(stderr, \"User-Add failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"edit\")==0 ){\n      if( nArg!=5 ){\n        raw_printf(stderr, \"Usage: .user edit USER PASSWORD ISADMIN\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_change(p->db, azArg[2],\n                              azArg[3], (int)strlen(azArg[3]),\n                              booleanValue(azArg[4]));\n      if( rc ){\n        raw_printf(stderr, \"User-Edit failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"delete\")==0 ){\n      if( nArg!=3 ){\n        raw_printf(stderr, \"Usage: .user delete USER\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_delete(p->db, azArg[2]);\n      if( rc ){\n        raw_printf(stderr, \"User-Delete failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .user login|add|edit|delete ...\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n  }else\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n  if( c=='v' && strncmp(azArg[0], \"version\", n)==0 ){\n    utf8_printf(p->out, \"SQLite %s %s\\n\" /*extra-version-info*/,\n        sqlite3_libversion(), sqlite3_sourceid());\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfsinfo\", n)==0 ){\n    const char *zDbName = nArg==2 ? azArg[1] : \"main\";\n    sqlite3_vfs *pVfs = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs);\n      if( pVfs ){\n        utf8_printf(p->out, \"vfs.zName      = \\\"%s\\\"\\n\", pVfs->zName);\n        raw_printf(p->out, \"vfs.iVersion   = %d\\n\", pVfs->iVersion);\n        raw_printf(p->out, \"vfs.szOsFile   = %d\\n\", pVfs->szOsFile);\n        raw_printf(p->out, \"vfs.mxPathname = %d\\n\", pVfs->mxPathname);\n      }\n    }\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfslist\", n)==0 ){\n    sqlite3_vfs *pVfs;\n    sqlite3_vfs *pCurrent = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, \"main\", SQLITE_FCNTL_VFS_POINTER, &pCurrent);\n    }\n    for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){\n      utf8_printf(p->out, \"vfs.zName      = \\\"%s\\\"%s\\n\", pVfs->zName,\n           pVfs==pCurrent ? \"  <--- CURRENT\" : \"\");\n      raw_printf(p->out, \"vfs.iVersion   = %d\\n\", pVfs->iVersion);\n      raw_printf(p->out, \"vfs.szOsFile   = %d\\n\", pVfs->szOsFile);\n      raw_printf(p->out, \"vfs.mxPathname = %d\\n\", pVfs->mxPathname);\n      if( pVfs->pNext ){\n        raw_printf(p->out, \"-----------------------------------\\n\");\n      }\n    }\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfsname\", n)==0 ){\n    const char *zDbName = nArg==2 ? azArg[1] : \"main\";\n    char *zVfsName = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName);\n      if( zVfsName ){\n        utf8_printf(p->out, \"%s\\n\", zVfsName);\n        sqlite3_free(zVfsName);\n      }\n    }\n  }else\n\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  if( c=='w' && strncmp(azArg[0], \"wheretrace\", n)==0 ){\n    sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;\n  }else\n#endif\n\n  if( c=='w' && strncmp(azArg[0], \"width\", n)==0 ){\n    int j;\n    assert( nArg<=ArraySize(azArg) );\n    for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){\n      p->colWidth[j-1] = (int)integerValue(azArg[j]);\n    }\n  }else\n\n  {\n    utf8_printf(stderr, \"Error: unknown command or invalid arguments: \"\n      \" \\\"%s\\\". Enter \\\".help\\\" for help\\n\", azArg[0]);\n    rc = 1;\n  }\n\nmeta_command_exit:\n  if( p->outCount ){\n    p->outCount--;\n    if( p->outCount==0 ) output_reset(p);\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if a semicolon occurs anywhere in the first N characters\n** of string z[].\n*/\nstatic int line_contains_semicolon(const char *z, int N){\n  int i;\n  for(i=0; i<N; i++){  if( z[i]==';' ) return 1; }\n  return 0;\n}\n\n/*\n** Test to see if a line consists entirely of whitespace.\n*/\nstatic int _all_whitespace(const char *z){\n  for(; *z; z++){\n    if( IsSpace(z[0]) ) continue;\n    if( *z=='/' && z[1]=='*' ){\n      z += 2;\n      while( *z && (*z!='*' || z[1]!='/') ){ z++; }\n      if( *z==0 ) return 0;\n      z++;\n      continue;\n    }\n    if( *z=='-' && z[1]=='-' ){\n      z += 2;\n      while( *z && *z!='\\n' ){ z++; }\n      if( *z==0 ) return 1;\n      continue;\n    }\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Return TRUE if the line typed in is an SQL command terminator other\n** than a semi-colon.  The SQL Server style \"go\" command is understood\n** as is the Oracle \"/\".\n*/\nstatic int line_is_command_terminator(const char *zLine){\n  while( IsSpace(zLine[0]) ){ zLine++; };\n  if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){\n    return 1;  /* Oracle */\n  }\n  if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'\n         && _all_whitespace(&zLine[2]) ){\n    return 1;  /* SQL Server */\n  }\n  return 0;\n}\n\n/*\n** Return true if zSql is a complete SQL statement.  Return false if it\n** ends in the middle of a string literal or C-style comment.\n*/\nstatic int line_is_complete(char *zSql, int nSql){\n  int rc;\n  if( zSql==0 ) return 1;\n  zSql[nSql] = ';';\n  zSql[nSql+1] = 0;\n  rc = sqlite3_complete(zSql);\n  zSql[nSql] = 0;\n  return rc;\n}\n\n/*\n** Run a single line of SQL\n*/\nstatic int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){\n  int rc;\n  char *zErrMsg = 0;\n\n  open_db(p, 0);\n  if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);\n  BEGIN_TIMER;\n  rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);\n  END_TIMER;\n  if( rc || zErrMsg ){\n    char zPrefix[100];\n    if( in!=0 || !stdin_is_interactive ){\n      sqlite3_snprintf(sizeof(zPrefix), zPrefix,\n                       \"Error: near line %d:\", startline);\n    }else{\n      sqlite3_snprintf(sizeof(zPrefix), zPrefix, \"Error:\");\n    }\n    if( zErrMsg!=0 ){\n      utf8_printf(stderr, \"%s %s\\n\", zPrefix, zErrMsg);\n      sqlite3_free(zErrMsg);\n      zErrMsg = 0;\n    }else{\n      utf8_printf(stderr, \"%s %s\\n\", zPrefix, sqlite3_errmsg(p->db));\n    }\n    return 1;\n  }else if( ShellHasFlag(p, SHFLG_CountChanges) ){\n    raw_printf(p->out, \"changes: %3d   total_changes: %d\\n\",\n            sqlite3_changes(p->db), sqlite3_total_changes(p->db));\n  }\n  return 0;\n}\n\n\n/*\n** Read input from *in and process it.  If *in==0 then input\n** is interactive - the user is typing it it.  Otherwise, input\n** is coming from a file or device.  A prompt is issued and history\n** is saved only if input is interactive.  An interrupt signal will\n** cause this routine to exit immediately, unless input is interactive.\n**\n** Return the number of errors.\n*/\nstatic int process_input(ShellState *p, FILE *in){\n  char *zLine = 0;          /* A single input line */\n  char *zSql = 0;           /* Accumulated SQL text */\n  int nLine;                /* Length of current line */\n  int nSql = 0;             /* Bytes of zSql[] used */\n  int nAlloc = 0;           /* Allocated zSql[] space */\n  int nSqlPrior = 0;        /* Bytes of zSql[] used by prior line */\n  int rc;                   /* Error code */\n  int errCnt = 0;           /* Number of errors seen */\n  int lineno = 0;           /* Current line number */\n  int startline = 0;        /* Line number for start of current input */\n\n  while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){\n    fflush(p->out);\n    zLine = one_input_line(in, zLine, nSql>0);\n    if( zLine==0 ){\n      /* End of input */\n      if( in==0 && stdin_is_interactive ) printf(\"\\n\");\n      break;\n    }\n    if( seenInterrupt ){\n      if( in!=0 ) break;\n      seenInterrupt = 0;\n    }\n    lineno++;\n    if( nSql==0 && _all_whitespace(zLine) ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zLine);\n      continue;\n    }\n    if( zLine && zLine[0]=='.' && nSql==0 ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zLine);\n      rc = do_meta_command(zLine, p);\n      if( rc==2 ){ /* exit requested */\n        break;\n      }else if( rc ){\n        errCnt++;\n      }\n      continue;\n    }\n    if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){\n      memcpy(zLine,\";\",2);\n    }\n    nLine = strlen30(zLine);\n    if( nSql+nLine+2>=nAlloc ){\n      nAlloc = nSql+nLine+100;\n      zSql = realloc(zSql, nAlloc);\n      if( zSql==0 ){\n        raw_printf(stderr, \"Error: out of memory\\n\");\n        exit(1);\n      }\n    }\n    nSqlPrior = nSql;\n    if( nSql==0 ){\n      int i;\n      for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}\n      assert( nAlloc>0 && zSql!=0 );\n      memcpy(zSql, zLine+i, nLine+1-i);\n      startline = lineno;\n      nSql = nLine-i;\n    }else{\n      zSql[nSql++] = '\\n';\n      memcpy(zSql+nSql, zLine, nLine+1);\n      nSql += nLine;\n    }\n    if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)\n                && sqlite3_complete(zSql) ){\n      errCnt += runOneSqlLine(p, zSql, in, startline);\n      nSql = 0;\n      if( p->outCount ){\n        output_reset(p);\n        p->outCount = 0;\n      }\n    }else if( nSql && _all_whitespace(zSql) ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zSql);\n      nSql = 0;\n    }\n  }\n  if( nSql && !_all_whitespace(zSql) ){\n    runOneSqlLine(p, zSql, in, startline);\n  }\n  free(zSql);\n  free(zLine);\n  return errCnt>0;\n}\n\n/*\n** Return a pathname which is the user's home directory.  A\n** 0 return indicates an error of some kind.\n*/\nstatic char *find_home_dir(int clearFlag){\n  static char *home_dir = NULL;\n  if( clearFlag ){\n    free(home_dir);\n    home_dir = 0;\n    return 0;\n  }\n  if( home_dir ) return home_dir;\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \\\n     && !defined(__RTP__) && !defined(_WRS_KERNEL)\n  {\n    struct passwd *pwent;\n    uid_t uid = getuid();\n    if( (pwent=getpwuid(uid)) != NULL) {\n      home_dir = pwent->pw_dir;\n    }\n  }\n#endif\n\n#if defined(_WIN32_WCE)\n  /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()\n   */\n  home_dir = \"/\";\n#else\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    home_dir = getenv(\"USERPROFILE\");\n  }\n#endif\n\n  if (!home_dir) {\n    home_dir = getenv(\"HOME\");\n  }\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    char *zDrive, *zPath;\n    int n;\n    zDrive = getenv(\"HOMEDRIVE\");\n    zPath = getenv(\"HOMEPATH\");\n    if( zDrive && zPath ){\n      n = strlen30(zDrive) + strlen30(zPath) + 1;\n      home_dir = malloc( n );\n      if( home_dir==0 ) return 0;\n      sqlite3_snprintf(n, home_dir, \"%s%s\", zDrive, zPath);\n      return home_dir;\n    }\n    home_dir = \"c:\\\\\";\n  }\n#endif\n\n#endif /* !_WIN32_WCE */\n\n  if( home_dir ){\n    int n = strlen30(home_dir) + 1;\n    char *z = malloc( n );\n    if( z ) memcpy(z, home_dir, n);\n    home_dir = z;\n  }\n\n  return home_dir;\n}\n\n/*\n** Read input from the file given by sqliterc_override.  Or if that\n** parameter is NULL, take input from ~/.sqliterc\n**\n** Returns the number of errors.\n*/\nstatic void process_sqliterc(\n  ShellState *p,                  /* Configuration data */\n  const char *sqliterc_override   /* Name of config file. NULL to use default */\n){\n  char *home_dir = NULL;\n  const char *sqliterc = sqliterc_override;\n  char *zBuf = 0;\n  FILE *in = NULL;\n\n  if (sqliterc == NULL) {\n    home_dir = find_home_dir(0);\n    if( home_dir==0 ){\n      raw_printf(stderr, \"-- warning: cannot find home directory;\"\n                      \" cannot read ~/.sqliterc\\n\");\n      return;\n    }\n    sqlite3_initialize();\n    zBuf = sqlite3_mprintf(\"%s/.sqliterc\",home_dir);\n    sqliterc = zBuf;\n  }\n  in = fopen(sqliterc,\"rb\");\n  if( in ){\n    if( stdin_is_interactive ){\n      utf8_printf(stderr,\"-- Loading resources from %s\\n\",sqliterc);\n    }\n    process_input(p,in);\n    fclose(in);\n  }\n  sqlite3_free(zBuf);\n}\n\n/*\n** Show available command line options\n*/\nstatic const char zOptions[] =\n  \"   -ascii               set output mode to 'ascii'\\n\"\n  \"   -bail                stop after hitting an error\\n\"\n  \"   -batch               force batch I/O\\n\"\n  \"   -column              set output mode to 'column'\\n\"\n  \"   -cmd COMMAND         run \\\"COMMAND\\\" before reading stdin\\n\"\n  \"   -csv                 set output mode to 'csv'\\n\"\n  \"   -echo                print commands before execution\\n\"\n  \"   -init FILENAME       read/process named file\\n\"\n  \"   -[no]header          turn headers on or off\\n\"\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n  \"   -heap SIZE           Size of heap for memsys3 or memsys5\\n\"\n#endif\n  \"   -help                show this message\\n\"\n  \"   -html                set output mode to HTML\\n\"\n  \"   -interactive         force interactive I/O\\n\"\n  \"   -line                set output mode to 'line'\\n\"\n  \"   -list                set output mode to 'list'\\n\"\n  \"   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory\\n\"\n  \"   -mmap N              default mmap size set to N\\n\"\n#ifdef SQLITE_ENABLE_MULTIPLEX\n  \"   -multiplex           enable the multiplexor VFS\\n\"\n#endif\n  \"   -newline SEP         set output row separator. Default: '\\\\n'\\n\"\n  \"   -nullvalue TEXT      set text string for NULL values. Default ''\\n\"\n  \"   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory\\n\"\n  \"   -quote               set output mode to 'quote'\\n\"\n  \"   -separator SEP       set output column separator. Default: '|'\\n\"\n  \"   -stats               print memory stats before each finalize\\n\"\n  \"   -version             show SQLite version\\n\"\n  \"   -vfs NAME            use NAME as the default VFS\\n\"\n#ifdef SQLITE_ENABLE_VFSTRACE\n  \"   -vfstrace            enable tracing of all VFS calls\\n\"\n#endif\n;\nstatic void usage(int showDetail){\n  utf8_printf(stderr,\n      \"Usage: %s [OPTIONS] FILENAME [SQL]\\n\"\n      \"FILENAME is the name of an SQLite database. A new database is created\\n\"\n      \"if the file does not previously exist.\\n\", Argv0);\n  if( showDetail ){\n    utf8_printf(stderr, \"OPTIONS include:\\n%s\", zOptions);\n  }else{\n    raw_printf(stderr, \"Use the -help option for additional information\\n\");\n  }\n  exit(1);\n}\n\n/*\n** Initialize the state information in data\n*/\nstatic void main_init(ShellState *data) {\n  memset(data, 0, sizeof(*data));\n  data->normalMode = data->cMode = data->mode = MODE_List;\n  data->autoExplain = 1;\n  memcpy(data->colSeparator,SEP_Column, 2);\n  memcpy(data->rowSeparator,SEP_Row, 2);\n  data->showHeader = 0;\n  data->shellFlgs = SHFLG_Lookaside;\n  sqlite3_config(SQLITE_CONFIG_URI, 1);\n  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);\n  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,\"sqlite> \");\n  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,\"   ...> \");\n}\n\n/*\n** Output text to the console in a font that attracts extra attention.\n*/\n#ifdef _WIN32\nstatic void printBold(const char *zText){\n  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);\n  CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;\n  GetConsoleScreenBufferInfo(out, &defaultScreenInfo);\n  SetConsoleTextAttribute(out,\n         FOREGROUND_RED|FOREGROUND_INTENSITY\n  );\n  printf(\"%s\", zText);\n  SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);\n}\n#else\nstatic void printBold(const char *zText){\n  printf(\"\\033[1m%s\\033[0m\", zText);\n}\n#endif\n\n/*\n** Get the argument to an --option.  Throw an error and die if no argument\n** is available.\n*/\nstatic char *cmdline_option_value(int argc, char **argv, int i){\n  if( i==argc ){\n    utf8_printf(stderr, \"%s: Error: missing argument to %s\\n\",\n            argv[0], argv[argc-1]);\n    exit(1);\n  }\n  return argv[i];\n}\n\n#ifndef SQLITE_SHELL_IS_UTF8\n#  if (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)\n#    define SQLITE_SHELL_IS_UTF8          (0)\n#  else\n#    define SQLITE_SHELL_IS_UTF8          (1)\n#  endif\n#endif\n\n#if SQLITE_SHELL_IS_UTF8\nint SQLITE_CDECL main(int argc, char **argv){\n#else\nint SQLITE_CDECL wmain(int argc, wchar_t **wargv){\n  char **argv;\n#endif\n  char *zErrMsg = 0;\n  ShellState data;\n  const char *zInitFile = 0;\n  int i;\n  int rc = 0;\n  int warnInmemoryDb = 0;\n  int readStdin = 1;\n  int nCmd = 0;\n  char **azCmd = 0;\n\n  setBinaryMode(stdin, 0);\n  setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */\n  stdin_is_interactive = isatty(0);\n  stdout_is_console = isatty(1);\n\n#if USE_SYSTEM_SQLITE+0!=1\n  if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){\n    utf8_printf(stderr, \"SQLite header and source version mismatch\\n%s\\n%s\\n\",\n            sqlite3_sourceid(), SQLITE_SOURCE_ID);\n    exit(1);\n  }\n#endif\n  main_init(&data);\n#if !SQLITE_SHELL_IS_UTF8\n  sqlite3_initialize();\n  argv = sqlite3_malloc64(sizeof(argv[0])*argc);\n  if( argv==0 ){\n    raw_printf(stderr, \"out of memory\\n\");\n    exit(1);\n  }\n  for(i=0; i<argc; i++){\n    argv[i] = sqlite3_win32_unicode_to_utf8(wargv[i]);\n    if( argv[i]==0 ){\n      raw_printf(stderr, \"out of memory\\n\");\n      exit(1);\n    }\n  }\n#endif\n  assert( argc>=1 && argv && argv[0] );\n  Argv0 = argv[0];\n\n  /* Make sure we have a valid signal handler early, before anything\n  ** else is done.\n  */\n#ifdef SIGINT\n  signal(SIGINT, interrupt_handler);\n#endif\n\n#ifdef SQLITE_SHELL_DBNAME_PROC\n  {\n    /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name\n    ** of a C-function that will provide the name of the database file.  Use\n    ** this compile-time option to embed this shell program in larger\n    ** applications. */\n    extern void SQLITE_SHELL_DBNAME_PROC(const char**);\n    SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);\n    warnInmemoryDb = 0;\n  }\n#endif\n\n  /* Do an initial pass through the command-line argument to locate\n  ** the name of the database file, the name of the initialization file,\n  ** the size of the alternative malloc heap,\n  ** and the first command to execute.\n  */\n  for(i=1; i<argc; i++){\n    char *z;\n    z = argv[i];\n    if( z[0]!='-' ){\n      if( data.zDbFilename==0 ){\n        data.zDbFilename = z;\n      }else{\n        /* Excesss arguments are interpreted as SQL (or dot-commands) and\n        ** mean that nothing is read from stdin */\n        readStdin = 0;\n        nCmd++;\n        azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);\n        if( azCmd==0 ){\n          raw_printf(stderr, \"out of memory\\n\");\n          exit(1);\n        }\n        azCmd[nCmd-1] = z;\n      }\n    }\n    if( z[1]=='-' ) z++;\n    if( strcmp(z,\"-separator\")==0\n     || strcmp(z,\"-nullvalue\")==0\n     || strcmp(z,\"-newline\")==0\n     || strcmp(z,\"-cmd\")==0\n    ){\n      (void)cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-init\")==0 ){\n      zInitFile = cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-batch\")==0 ){\n      /* Need to check for batch mode here to so we can avoid printing\n      ** informational messages (like from process_sqliterc) before\n      ** we do the actual processing of arguments later in a second pass.\n      */\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n      const char *zSize;\n      sqlite3_int64 szHeap;\n\n      zSize = cmdline_option_value(argc, argv, ++i);\n      szHeap = integerValue(zSize);\n      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;\n      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);\n#else\n      (void)cmdline_option_value(argc, argv, ++i);\n#endif\n    }else if( strcmp(z,\"-pagecache\")==0 ){\n      int n, sz;\n      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( sz>70000 ) sz = 70000;\n      if( sz<0 ) sz = 0;\n      n = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      sqlite3_config(SQLITE_CONFIG_PAGECACHE,\n                    (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);\n      data.shellFlgs |= SHFLG_Pagecache;\n    }else if( strcmp(z,\"-lookaside\")==0 ){\n      int n, sz;\n      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( sz<0 ) sz = 0;\n      n = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( n<0 ) n = 0;\n      sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);\n      if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      extern int vfstrace_register(\n         const char *zTraceName,\n         const char *zOldVfsName,\n         int (*xOut)(const char*,void*),\n         void *pOutArg,\n         int makeDefault\n      );\n      vfstrace_register(\"trace\",0,(int(*)(const char*,void*))fputs,stderr,1);\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      extern int sqlite3_multiple_initialize(const char*,int);\n      sqlite3_multiplex_initialize(0, 1);\n#endif\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));\n      sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, sz, sz);\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));\n      if( pVfs ){\n        sqlite3_vfs_register(pVfs, 1);\n      }else{\n        utf8_printf(stderr, \"no such VFS: \\\"%s\\\"\\n\", argv[i]);\n        exit(1);\n      }\n    }\n  }\n  if( data.zDbFilename==0 ){\n#ifndef SQLITE_OMIT_MEMORYDB\n    data.zDbFilename = \":memory:\";\n    warnInmemoryDb = argc==1;\n#else\n    utf8_printf(stderr,\"%s: Error: no database filename specified\\n\", Argv0);\n    return 1;\n#endif\n  }\n  data.out = stdout;\n\n  /* Go ahead and open the database file if it already exists.  If the\n  ** file does not exist, delay opening it.  This prevents empty database\n  ** files from being created if a user mistypes the database name argument\n  ** to the sqlite command-line tool.\n  */\n  if( access(data.zDbFilename, 0)==0 ){\n    open_db(&data, 0);\n  }\n\n  /* Process the initialization file if there is one.  If no -init option\n  ** is given on the command line, look for a file named ~/.sqliterc and\n  ** try to process it.\n  */\n  process_sqliterc(&data,zInitFile);\n\n  /* Make a second pass through the command-line argument and set\n  ** options.  This second pass is delayed until after the initialization\n  ** file is processed so that the command-line arguments will override\n  ** settings in the initialization file.\n  */\n  for(i=1; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) continue;\n    if( z[1]=='-' ){ z++; }\n    if( strcmp(z,\"-init\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-html\")==0 ){\n      data.mode = MODE_Html;\n    }else if( strcmp(z,\"-list\")==0 ){\n      data.mode = MODE_List;\n    }else if( strcmp(z,\"-quote\")==0 ){\n      data.mode = MODE_Quote;\n    }else if( strcmp(z,\"-line\")==0 ){\n      data.mode = MODE_Line;\n    }else if( strcmp(z,\"-column\")==0 ){\n      data.mode = MODE_Column;\n    }else if( strcmp(z,\"-csv\")==0 ){\n      data.mode = MODE_Csv;\n      memcpy(data.colSeparator,\",\",2);\n    }else if( strcmp(z,\"-ascii\")==0 ){\n      data.mode = MODE_Ascii;\n      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,\n                       SEP_Unit);\n      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,\n                       SEP_Record);\n    }else if( strcmp(z,\"-separator\")==0 ){\n      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-newline\")==0 ){\n      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-nullvalue\")==0 ){\n      sqlite3_snprintf(sizeof(data.nullValue), data.nullValue,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-header\")==0 ){\n      data.showHeader = 1;\n    }else if( strcmp(z,\"-noheader\")==0 ){\n      data.showHeader = 0;\n    }else if( strcmp(z,\"-echo\")==0 ){\n      ShellSetFlag(&data, SHFLG_Echo);\n    }else if( strcmp(z,\"-eqp\")==0 ){\n      data.autoEQP = 1;\n    }else if( strcmp(z,\"-eqpfull\")==0 ){\n      data.autoEQP = 2;\n    }else if( strcmp(z,\"-stats\")==0 ){\n      data.statsOn = 1;\n    }else if( strcmp(z,\"-scanstats\")==0 ){\n      data.scanstatsOn = 1;\n    }else if( strcmp(z,\"-backslash\")==0 ){\n      /* Undocumented command-line option: -backslash\n      ** Causes C-style backslash escapes to be evaluated in SQL statements\n      ** prior to sending the SQL into SQLite.  Useful for injecting\n      ** crazy bytes in the middle of SQL statements for testing and debugging.\n      */\n      ShellSetFlag(&data, SHFLG_Backslash);\n    }else if( strcmp(z,\"-bail\")==0 ){\n      bail_on_error = 1;\n    }else if( strcmp(z,\"-version\")==0 ){\n      printf(\"%s %s\\n\", sqlite3_libversion(), sqlite3_sourceid());\n      return 0;\n    }else if( strcmp(z,\"-interactive\")==0 ){\n      stdin_is_interactive = 1;\n    }else if( strcmp(z,\"-batch\")==0 ){\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-pagecache\")==0 ){\n      i+=2;\n    }else if( strcmp(z,\"-lookaside\")==0 ){\n      i+=2;\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      i++;\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      i++;\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      i++;\n#endif\n    }else if( strcmp(z,\"-help\")==0 ){\n      usage(1);\n    }else if( strcmp(z,\"-cmd\")==0 ){\n      /* Run commands that follow -cmd first and separately from commands\n      ** that simply appear on the command-line.  This seems goofy.  It would\n      ** be better if all commands ran in the order that they appear.  But\n      ** we retain the goofy behavior for historical compatibility. */\n      if( i==argc-1 ) break;\n      z = cmdline_option_value(argc,argv,++i);\n      if( z[0]=='.' ){\n        rc = do_meta_command(z, &data);\n        if( rc && bail_on_error ) return rc==2 ? 0 : rc;\n      }else{\n        open_db(&data, 0);\n        rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg);\n        if( zErrMsg!=0 ){\n          utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n          if( bail_on_error ) return rc!=0 ? rc : 1;\n        }else if( rc!=0 ){\n          utf8_printf(stderr,\"Error: unable to process SQL \\\"%s\\\"\\n\", z);\n          if( bail_on_error ) return rc;\n        }\n      }\n    }else{\n      utf8_printf(stderr,\"%s: Error: unknown option: %s\\n\", Argv0, z);\n      raw_printf(stderr,\"Use -help for a list of options.\\n\");\n      return 1;\n    }\n    data.cMode = data.mode;\n  }\n\n  if( !readStdin ){\n    /* Run all arguments that do not begin with '-' as if they were separate\n    ** command-line inputs, except for the argToSkip argument which contains\n    ** the database filename.\n    */\n    for(i=0; i<nCmd; i++){\n      if( azCmd[i][0]=='.' ){\n        rc = do_meta_command(azCmd[i], &data);\n        if( rc ) return rc==2 ? 0 : rc;\n      }else{\n        open_db(&data, 0);\n        rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);\n        if( zErrMsg!=0 ){\n          utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n          return rc!=0 ? rc : 1;\n        }else if( rc!=0 ){\n          utf8_printf(stderr,\"Error: unable to process SQL: %s\\n\", azCmd[i]);\n          return rc;\n        }\n      }\n    }\n    free(azCmd);\n  }else{\n    /* Run commands received from standard input\n    */\n    if( stdin_is_interactive ){\n      char *zHome;\n      char *zHistory = 0;\n      int nHistory;\n      printf(\n        \"SQLite version %s %.19s\\n\" /*extra-version-info*/\n        \"Enter \\\".help\\\" for usage hints.\\n\",\n        sqlite3_libversion(), sqlite3_sourceid()\n      );\n      if( warnInmemoryDb ){\n        printf(\"Connected to a \");\n        printBold(\"transient in-memory database\");\n        printf(\".\\nUse \\\".open FILENAME\\\" to reopen on a \"\n               \"persistent database.\\n\");\n      }\n      zHome = find_home_dir(0);\n      if( zHome ){\n        nHistory = strlen30(zHome) + 20;\n        if( (zHistory = malloc(nHistory))!=0 ){\n          sqlite3_snprintf(nHistory, zHistory,\"%s/.sqlite_history\", zHome);\n        }\n      }\n      if( zHistory ){ shell_read_history(zHistory); }\n#if HAVE_READLINE || HAVE_EDITLINE\n      rl_attempted_completion_function = readline_completion;\n#elif HAVE_LINENOISE\n      linenoiseSetCompletionCallback(linenoise_completion);\n#endif\n      rc = process_input(&data, 0);\n      if( zHistory ){\n        shell_stifle_history(2000);\n        shell_write_history(zHistory);\n        free(zHistory);\n      }\n    }else{\n      rc = process_input(&data, stdin);\n    }\n  }\n  set_table_name(&data, 0);\n  if( data.db ){\n    session_close_all(&data);\n    sqlite3_close(data.db);\n  }\n  sqlite3_free(data.zFreeOnClose);\n  find_home_dir(1);\n#if !SQLITE_SHELL_IS_UTF8\n  for(i=0; i<argc; i++) sqlite3_free(argv[i]);\n  sqlite3_free(argv);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/sqlite-amalgamation-3210000/sqlite3.c",
    "content": "/******************************************************************************\n** This file is an amalgamation of many separate C source files from SQLite\n** version 3.21.0.  By combining all the individual C code files into this\n** single large file, the entire code can be compiled as a single translation\n** unit.  This allows many compilers to do optimizations that would not be\n** possible if the files were compiled separately.  Performance improvements\n** of 5% or more are commonly seen when SQLite is compiled as a single\n** translation unit.\n**\n** This file is all you need to compile SQLite.  To use SQLite in other\n** programs, you need this file and the \"sqlite3.h\" header file that defines\n** the programming interface to the SQLite library.  (If you do not have\n** the \"sqlite3.h\" header file at hand, you will find a copy embedded within\n** the text of this file.  Search for \"Begin file sqlite3.h\" to find the start\n** of the embedded sqlite3.h header file.) Additional code files may be needed\n** if you want a wrapper to interface SQLite with your choice of programming\n** language. The code for the \"sqlite3\" command-line shell is also in a\n** separate file. This file contains only code for the core SQLite library.\n*/\n#define SQLITE_CORE 1\n#define SQLITE_AMALGAMATION 1\n#ifndef SQLITE_PRIVATE\n# define SQLITE_PRIVATE static\n#endif\n/************** Begin file ctime.c *******************************************/\n/*\n** 2010 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements routines used to report what compile-time options\n** SQLite was built with.\n*/\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n#include \"config.h\"\n#define SQLITECONFIG_H 1\n#endif\n\n/* These macros are provided to \"stringify\" the value of the define\n** for those options in which the value is meaningful. */\n#define CTIMEOPT_VAL_(opt) #opt\n#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)\n\n/*\n** An array of names of all compile-time options.  This array should \n** be sorted A-Z.\n**\n** This array looks large, but in a typical installation actually uses\n** only a handful of compile-time options, so most times this array is usually\n** rather short and uses little memory space.\n*/\nstatic const char * const sqlite3azCompileOpt[] = {\n\n/* \n** BEGIN CODE GENERATED BY tool/mkctime.tcl \n*/\n#if SQLITE_32BIT_ROWID\n  \"32BIT_ROWID\",\n#endif\n#if SQLITE_4_BYTE_ALIGNED_MALLOC\n  \"4_BYTE_ALIGNED_MALLOC\",\n#endif\n#if SQLITE_64BIT_STATS\n  \"64BIT_STATS\",\n#endif\n#if SQLITE_ALLOW_COVERING_INDEX_SCAN\n  \"ALLOW_COVERING_INDEX_SCAN\",\n#endif\n#if SQLITE_ALLOW_URI_AUTHORITY\n  \"ALLOW_URI_AUTHORITY\",\n#endif\n#ifdef SQLITE_BITMASK_TYPE\n  \"BITMASK_TYPE=\" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),\n#endif\n#if SQLITE_BUG_COMPATIBLE_20160819\n  \"BUG_COMPATIBLE_20160819\",\n#endif\n#if SQLITE_CASE_SENSITIVE_LIKE\n  \"CASE_SENSITIVE_LIKE\",\n#endif\n#if SQLITE_CHECK_PAGES\n  \"CHECK_PAGES\",\n#endif\n#if defined(__clang__) && defined(__clang_major__)\n  \"COMPILER=clang-\" CTIMEOPT_VAL(__clang_major__) \".\"\n                    CTIMEOPT_VAL(__clang_minor__) \".\"\n                    CTIMEOPT_VAL(__clang_patchlevel__),\n#elif defined(_MSC_VER)\n  \"COMPILER=msvc-\" CTIMEOPT_VAL(_MSC_VER),\n#elif defined(__GNUC__) && defined(__VERSION__)\n  \"COMPILER=gcc-\" __VERSION__,\n#endif\n#if SQLITE_COVERAGE_TEST\n  \"COVERAGE_TEST\",\n#endif\n#if SQLITE_DEBUG\n  \"DEBUG\",\n#endif\n#if SQLITE_DEFAULT_AUTOMATIC_INDEX\n  \"DEFAULT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_DEFAULT_AUTOVACUUM\n  \"DEFAULT_AUTOVACUUM\",\n#endif\n#ifdef SQLITE_DEFAULT_CACHE_SIZE\n  \"DEFAULT_CACHE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n  \"DEFAULT_CKPTFULLFSYNC\",\n#endif\n#ifdef SQLITE_DEFAULT_FILE_FORMAT\n  \"DEFAULT_FILE_FORMAT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),\n#endif\n#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS\n  \"DEFAULT_FILE_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_FOREIGN_KEYS\n  \"DEFAULT_FOREIGN_KEYS\",\n#endif\n#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  \"DEFAULT_JOURNAL_SIZE_LIMIT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),\n#endif\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  \"DEFAULT_LOCKING_MODE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),\n#endif\n#ifdef SQLITE_DEFAULT_LOOKASIDE\n  \"DEFAULT_LOOKASIDE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),\n#endif\n#if SQLITE_DEFAULT_MEMSTATUS\n  \"DEFAULT_MEMSTATUS\",\n#endif\n#ifdef SQLITE_DEFAULT_MMAP_SIZE\n  \"DEFAULT_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PAGE_SIZE\n  \"DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PCACHE_INITSZ\n  \"DEFAULT_PCACHE_INITSZ=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),\n#endif\n#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n  \"DEFAULT_PROXYDIR_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n  \"DEFAULT_RECURSIVE_TRIGGERS\",\n#endif\n#ifdef SQLITE_DEFAULT_ROWEST\n  \"DEFAULT_ROWEST=\" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),\n#endif\n#ifdef SQLITE_DEFAULT_SECTOR_SIZE\n  \"DEFAULT_SECTOR_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_SYNCHRONOUS\n  \"DEFAULT_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n  \"DEFAULT_WAL_AUTOCHECKPOINT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n  \"DEFAULT_WAL_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WORKER_THREADS\n  \"DEFAULT_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),\n#endif\n#if SQLITE_DIRECT_OVERFLOW_READ\n  \"DIRECT_OVERFLOW_READ\",\n#endif\n#if SQLITE_DISABLE_DIRSYNC\n  \"DISABLE_DIRSYNC\",\n#endif\n#if SQLITE_DISABLE_FTS3_UNICODE\n  \"DISABLE_FTS3_UNICODE\",\n#endif\n#if SQLITE_DISABLE_FTS4_DEFERRED\n  \"DISABLE_FTS4_DEFERRED\",\n#endif\n#if SQLITE_DISABLE_INTRINSIC\n  \"DISABLE_INTRINSIC\",\n#endif\n#if SQLITE_DISABLE_LFS\n  \"DISABLE_LFS\",\n#endif\n#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n  \"DISABLE_PAGECACHE_OVERFLOW_STATS\",\n#endif\n#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n  \"DISABLE_SKIPAHEAD_DISTINCT\",\n#endif\n#ifdef SQLITE_ENABLE_8_3_NAMES\n  \"ENABLE_8_3_NAMES=\" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),\n#endif\n#if SQLITE_ENABLE_API_ARMOR\n  \"ENABLE_API_ARMOR\",\n#endif\n#if SQLITE_ENABLE_ATOMIC_WRITE\n  \"ENABLE_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  \"ENABLE_BATCH_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_CEROD\n  \"ENABLE_CEROD\",\n#endif\n#if SQLITE_ENABLE_COLUMN_METADATA\n  \"ENABLE_COLUMN_METADATA\",\n#endif\n#if SQLITE_ENABLE_COLUMN_USED_MASK\n  \"ENABLE_COLUMN_USED_MASK\",\n#endif\n#if SQLITE_ENABLE_COSTMULT\n  \"ENABLE_COSTMULT\",\n#endif\n#if SQLITE_ENABLE_CURSOR_HINTS\n  \"ENABLE_CURSOR_HINTS\",\n#endif\n#if SQLITE_ENABLE_DBSTAT_VTAB\n  \"ENABLE_DBSTAT_VTAB\",\n#endif\n#if SQLITE_ENABLE_EXPENSIVE_ASSERT\n  \"ENABLE_EXPENSIVE_ASSERT\",\n#endif\n#if SQLITE_ENABLE_FTS1\n  \"ENABLE_FTS1\",\n#endif\n#if SQLITE_ENABLE_FTS2\n  \"ENABLE_FTS2\",\n#endif\n#if SQLITE_ENABLE_FTS3\n  \"ENABLE_FTS3\",\n#endif\n#if SQLITE_ENABLE_FTS3_PARENTHESIS\n  \"ENABLE_FTS3_PARENTHESIS\",\n#endif\n#if SQLITE_ENABLE_FTS3_TOKENIZER\n  \"ENABLE_FTS3_TOKENIZER\",\n#endif\n#if SQLITE_ENABLE_FTS4\n  \"ENABLE_FTS4\",\n#endif\n#if SQLITE_ENABLE_FTS5\n  \"ENABLE_FTS5\",\n#endif\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\n  \"ENABLE_HIDDEN_COLUMNS\",\n#endif\n#if SQLITE_ENABLE_ICU\n  \"ENABLE_ICU\",\n#endif\n#if SQLITE_ENABLE_IOTRACE\n  \"ENABLE_IOTRACE\",\n#endif\n#if SQLITE_ENABLE_JSON1\n  \"ENABLE_JSON1\",\n#endif\n#if SQLITE_ENABLE_LOAD_EXTENSION\n  \"ENABLE_LOAD_EXTENSION\",\n#endif\n#ifdef SQLITE_ENABLE_LOCKING_STYLE\n  \"ENABLE_LOCKING_STYLE=\" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),\n#endif\n#if SQLITE_ENABLE_MEMORY_MANAGEMENT\n  \"ENABLE_MEMORY_MANAGEMENT\",\n#endif\n#if SQLITE_ENABLE_MEMSYS3\n  \"ENABLE_MEMSYS3\",\n#endif\n#if SQLITE_ENABLE_MEMSYS5\n  \"ENABLE_MEMSYS5\",\n#endif\n#if SQLITE_ENABLE_MULTIPLEX\n  \"ENABLE_MULTIPLEX\",\n#endif\n#if SQLITE_ENABLE_NULL_TRIM\n  \"ENABLE_NULL_TRIM\",\n#endif\n#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK\n  \"ENABLE_OVERSIZE_CELL_CHECK\",\n#endif\n#if SQLITE_ENABLE_PREUPDATE_HOOK\n  \"ENABLE_PREUPDATE_HOOK\",\n#endif\n#if SQLITE_ENABLE_QPSG\n  \"ENABLE_QPSG\",\n#endif\n#if SQLITE_ENABLE_RBU\n  \"ENABLE_RBU\",\n#endif\n#if SQLITE_ENABLE_RTREE\n  \"ENABLE_RTREE\",\n#endif\n#if SQLITE_ENABLE_SELECTTRACE\n  \"ENABLE_SELECTTRACE\",\n#endif\n#if SQLITE_ENABLE_SESSION\n  \"ENABLE_SESSION\",\n#endif\n#if SQLITE_ENABLE_SNAPSHOT\n  \"ENABLE_SNAPSHOT\",\n#endif\n#if SQLITE_ENABLE_SQLLOG\n  \"ENABLE_SQLLOG\",\n#endif\n#if defined(SQLITE_ENABLE_STAT4)\n  \"ENABLE_STAT4\",\n#elif defined(SQLITE_ENABLE_STAT3)\n  \"ENABLE_STAT3\",\n#endif\n#if SQLITE_ENABLE_STMTVTAB\n  \"ENABLE_STMTVTAB\",\n#endif\n#if SQLITE_ENABLE_STMT_SCANSTATUS\n  \"ENABLE_STMT_SCANSTATUS\",\n#endif\n#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n  \"ENABLE_UNKNOWN_SQL_FUNCTION\",\n#endif\n#if SQLITE_ENABLE_UNLOCK_NOTIFY\n  \"ENABLE_UNLOCK_NOTIFY\",\n#endif\n#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  \"ENABLE_UPDATE_DELETE_LIMIT\",\n#endif\n#if SQLITE_ENABLE_URI_00_ERROR\n  \"ENABLE_URI_00_ERROR\",\n#endif\n#if SQLITE_ENABLE_VFSTRACE\n  \"ENABLE_VFSTRACE\",\n#endif\n#if SQLITE_ENABLE_WHERETRACE\n  \"ENABLE_WHERETRACE\",\n#endif\n#if SQLITE_ENABLE_ZIPVFS\n  \"ENABLE_ZIPVFS\",\n#endif\n#if SQLITE_EXPLAIN_ESTIMATED_ROWS\n  \"EXPLAIN_ESTIMATED_ROWS\",\n#endif\n#if SQLITE_EXTRA_IFNULLROW\n  \"EXTRA_IFNULLROW\",\n#endif\n#ifdef SQLITE_EXTRA_INIT\n  \"EXTRA_INIT=\" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),\n#endif\n#ifdef SQLITE_EXTRA_SHUTDOWN\n  \"EXTRA_SHUTDOWN=\" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),\n#endif\n#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH\n  \"FTS3_MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),\n#endif\n#if SQLITE_FTS5_ENABLE_TEST_MI\n  \"FTS5_ENABLE_TEST_MI\",\n#endif\n#if SQLITE_FTS5_NO_WITHOUT_ROWID\n  \"FTS5_NO_WITHOUT_ROWID\",\n#endif\n#if SQLITE_HAS_CODEC\n  \"HAS_CODEC\",\n#endif\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n  \"HAVE_ISNAN\",\n#endif\n#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  \"HOMEGROWN_RECURSIVE_MUTEX\",\n#endif\n#if SQLITE_IGNORE_AFP_LOCK_ERRORS\n  \"IGNORE_AFP_LOCK_ERRORS\",\n#endif\n#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  \"IGNORE_FLOCK_LOCK_ERRORS\",\n#endif\n#if SQLITE_INLINE_MEMCPY\n  \"INLINE_MEMCPY\",\n#endif\n#if SQLITE_INT64_TYPE\n  \"INT64_TYPE\",\n#endif\n#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n  \"INTEGRITY_CHECK_ERROR_MAX=\" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),\n#endif\n#if SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  \"LIKE_DOESNT_MATCH_BLOBS\",\n#endif\n#if SQLITE_LOCK_TRACE\n  \"LOCK_TRACE\",\n#endif\n#if SQLITE_LOG_CACHE_SPILL\n  \"LOG_CACHE_SPILL\",\n#endif\n#ifdef SQLITE_MALLOC_SOFT_LIMIT\n  \"MALLOC_SOFT_LIMIT=\" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),\n#endif\n#ifdef SQLITE_MAX_ATTACHED\n  \"MAX_ATTACHED=\" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),\n#endif\n#ifdef SQLITE_MAX_COLUMN\n  \"MAX_COLUMN=\" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),\n#endif\n#ifdef SQLITE_MAX_COMPOUND_SELECT\n  \"MAX_COMPOUND_SELECT=\" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),\n#endif\n#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE\n  \"MAX_DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_EXPR_DEPTH\n  \"MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),\n#endif\n#ifdef SQLITE_MAX_FUNCTION_ARG\n  \"MAX_FUNCTION_ARG=\" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),\n#endif\n#ifdef SQLITE_MAX_LENGTH\n  \"MAX_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),\n#endif\n#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH\n  \"MAX_LIKE_PATTERN_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),\n#endif\n#ifdef SQLITE_MAX_MEMORY\n  \"MAX_MEMORY=\" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE\n  \"MAX_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE_\n  \"MAX_MMAP_SIZE_=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),\n#endif\n#ifdef SQLITE_MAX_PAGE_COUNT\n  \"MAX_PAGE_COUNT=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),\n#endif\n#ifdef SQLITE_MAX_PAGE_SIZE\n  \"MAX_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_SCHEMA_RETRY\n  \"MAX_SCHEMA_RETRY=\" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),\n#endif\n#ifdef SQLITE_MAX_SQL_LENGTH\n  \"MAX_SQL_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),\n#endif\n#ifdef SQLITE_MAX_TRIGGER_DEPTH\n  \"MAX_TRIGGER_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),\n#endif\n#ifdef SQLITE_MAX_VARIABLE_NUMBER\n  \"MAX_VARIABLE_NUMBER=\" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),\n#endif\n#ifdef SQLITE_MAX_VDBE_OP\n  \"MAX_VDBE_OP=\" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),\n#endif\n#ifdef SQLITE_MAX_WORKER_THREADS\n  \"MAX_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),\n#endif\n#if SQLITE_MEMDEBUG\n  \"MEMDEBUG\",\n#endif\n#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n  \"MIXED_ENDIAN_64BIT_FLOAT\",\n#endif\n#if SQLITE_MMAP_READWRITE\n  \"MMAP_READWRITE\",\n#endif\n#if SQLITE_MUTEX_NOOP\n  \"MUTEX_NOOP\",\n#endif\n#if SQLITE_MUTEX_NREF\n  \"MUTEX_NREF\",\n#endif\n#if SQLITE_MUTEX_OMIT\n  \"MUTEX_OMIT\",\n#endif\n#if SQLITE_MUTEX_PTHREADS\n  \"MUTEX_PTHREADS\",\n#endif\n#if SQLITE_MUTEX_W32\n  \"MUTEX_W32\",\n#endif\n#if SQLITE_NEED_ERR_NAME\n  \"NEED_ERR_NAME\",\n#endif\n#if SQLITE_NOINLINE\n  \"NOINLINE\",\n#endif\n#if SQLITE_NO_SYNC\n  \"NO_SYNC\",\n#endif\n#if SQLITE_OMIT_ALTERTABLE\n  \"OMIT_ALTERTABLE\",\n#endif\n#if SQLITE_OMIT_ANALYZE\n  \"OMIT_ANALYZE\",\n#endif\n#if SQLITE_OMIT_ATTACH\n  \"OMIT_ATTACH\",\n#endif\n#if SQLITE_OMIT_AUTHORIZATION\n  \"OMIT_AUTHORIZATION\",\n#endif\n#if SQLITE_OMIT_AUTOINCREMENT\n  \"OMIT_AUTOINCREMENT\",\n#endif\n#if SQLITE_OMIT_AUTOINIT\n  \"OMIT_AUTOINIT\",\n#endif\n#if SQLITE_OMIT_AUTOMATIC_INDEX\n  \"OMIT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_OMIT_AUTORESET\n  \"OMIT_AUTORESET\",\n#endif\n#if SQLITE_OMIT_AUTOVACUUM\n  \"OMIT_AUTOVACUUM\",\n#endif\n#if SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  \"OMIT_BETWEEN_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_BLOB_LITERAL\n  \"OMIT_BLOB_LITERAL\",\n#endif\n#if SQLITE_OMIT_BTREECOUNT\n  \"OMIT_BTREECOUNT\",\n#endif\n#if SQLITE_OMIT_CAST\n  \"OMIT_CAST\",\n#endif\n#if SQLITE_OMIT_CHECK\n  \"OMIT_CHECK\",\n#endif\n#if SQLITE_OMIT_COMPLETE\n  \"OMIT_COMPLETE\",\n#endif\n#if SQLITE_OMIT_COMPOUND_SELECT\n  \"OMIT_COMPOUND_SELECT\",\n#endif\n#if SQLITE_OMIT_CONFLICT_CLAUSE\n  \"OMIT_CONFLICT_CLAUSE\",\n#endif\n#if SQLITE_OMIT_CTE\n  \"OMIT_CTE\",\n#endif\n#if SQLITE_OMIT_DATETIME_FUNCS\n  \"OMIT_DATETIME_FUNCS\",\n#endif\n#if SQLITE_OMIT_DECLTYPE\n  \"OMIT_DECLTYPE\",\n#endif\n#if SQLITE_OMIT_DEPRECATED\n  \"OMIT_DEPRECATED\",\n#endif\n#if SQLITE_OMIT_DISKIO\n  \"OMIT_DISKIO\",\n#endif\n#if SQLITE_OMIT_EXPLAIN\n  \"OMIT_EXPLAIN\",\n#endif\n#if SQLITE_OMIT_FLAG_PRAGMAS\n  \"OMIT_FLAG_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_FLOATING_POINT\n  \"OMIT_FLOATING_POINT\",\n#endif\n#if SQLITE_OMIT_FOREIGN_KEY\n  \"OMIT_FOREIGN_KEY\",\n#endif\n#if SQLITE_OMIT_GET_TABLE\n  \"OMIT_GET_TABLE\",\n#endif\n#if SQLITE_OMIT_HEX_INTEGER\n  \"OMIT_HEX_INTEGER\",\n#endif\n#if SQLITE_OMIT_INCRBLOB\n  \"OMIT_INCRBLOB\",\n#endif\n#if SQLITE_OMIT_INTEGRITY_CHECK\n  \"OMIT_INTEGRITY_CHECK\",\n#endif\n#if SQLITE_OMIT_LIKE_OPTIMIZATION\n  \"OMIT_LIKE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_LOAD_EXTENSION\n  \"OMIT_LOAD_EXTENSION\",\n#endif\n#if SQLITE_OMIT_LOCALTIME\n  \"OMIT_LOCALTIME\",\n#endif\n#if SQLITE_OMIT_LOOKASIDE\n  \"OMIT_LOOKASIDE\",\n#endif\n#if SQLITE_OMIT_MEMORYDB\n  \"OMIT_MEMORYDB\",\n#endif\n#if SQLITE_OMIT_OR_OPTIMIZATION\n  \"OMIT_OR_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_PAGER_PRAGMAS\n  \"OMIT_PAGER_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_PARSER_TRACE\n  \"OMIT_PARSER_TRACE\",\n#endif\n#if SQLITE_OMIT_POPEN\n  \"OMIT_POPEN\",\n#endif\n#if SQLITE_OMIT_PRAGMA\n  \"OMIT_PRAGMA\",\n#endif\n#if SQLITE_OMIT_PROGRESS_CALLBACK\n  \"OMIT_PROGRESS_CALLBACK\",\n#endif\n#if SQLITE_OMIT_QUICKBALANCE\n  \"OMIT_QUICKBALANCE\",\n#endif\n#if SQLITE_OMIT_REINDEX\n  \"OMIT_REINDEX\",\n#endif\n#if SQLITE_OMIT_SCHEMA_PRAGMAS\n  \"OMIT_SCHEMA_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  \"OMIT_SCHEMA_VERSION_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SHARED_CACHE\n  \"OMIT_SHARED_CACHE\",\n#endif\n#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n  \"OMIT_SHUTDOWN_DIRECTORIES\",\n#endif\n#if SQLITE_OMIT_SUBQUERY\n  \"OMIT_SUBQUERY\",\n#endif\n#if SQLITE_OMIT_TCL_VARIABLE\n  \"OMIT_TCL_VARIABLE\",\n#endif\n#if SQLITE_OMIT_TEMPDB\n  \"OMIT_TEMPDB\",\n#endif\n#if SQLITE_OMIT_TEST_CONTROL\n  \"OMIT_TEST_CONTROL\",\n#endif\n#if SQLITE_OMIT_TRACE\n  \"OMIT_TRACE\",\n#endif\n#if SQLITE_OMIT_TRIGGER\n  \"OMIT_TRIGGER\",\n#endif\n#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  \"OMIT_TRUNCATE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_UTF16\n  \"OMIT_UTF16\",\n#endif\n#if SQLITE_OMIT_VACUUM\n  \"OMIT_VACUUM\",\n#endif\n#if SQLITE_OMIT_VIEW\n  \"OMIT_VIEW\",\n#endif\n#if SQLITE_OMIT_VIRTUALTABLE\n  \"OMIT_VIRTUALTABLE\",\n#endif\n#if SQLITE_OMIT_WAL\n  \"OMIT_WAL\",\n#endif\n#if SQLITE_OMIT_WSD\n  \"OMIT_WSD\",\n#endif\n#if SQLITE_OMIT_XFER_OPT\n  \"OMIT_XFER_OPT\",\n#endif\n#if SQLITE_PCACHE_SEPARATE_HEADER\n  \"PCACHE_SEPARATE_HEADER\",\n#endif\n#if SQLITE_PERFORMANCE_TRACE\n  \"PERFORMANCE_TRACE\",\n#endif\n#if SQLITE_POWERSAFE_OVERWRITE\n  \"POWERSAFE_OVERWRITE\",\n#endif\n#if SQLITE_PREFER_PROXY_LOCKING\n  \"PREFER_PROXY_LOCKING\",\n#endif\n#if SQLITE_PROXY_DEBUG\n  \"PROXY_DEBUG\",\n#endif\n#if SQLITE_REVERSE_UNORDERED_SELECTS\n  \"REVERSE_UNORDERED_SELECTS\",\n#endif\n#if SQLITE_RTREE_INT_ONLY\n  \"RTREE_INT_ONLY\",\n#endif\n#if SQLITE_SECURE_DELETE\n  \"SECURE_DELETE\",\n#endif\n#if SQLITE_SMALL_STACK\n  \"SMALL_STACK\",\n#endif\n#ifdef SQLITE_SORTER_PMASZ\n  \"SORTER_PMASZ=\" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),\n#endif\n#if SQLITE_SOUNDEX\n  \"SOUNDEX\",\n#endif\n#ifdef SQLITE_STAT4_SAMPLES\n  \"STAT4_SAMPLES=\" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),\n#endif\n#ifdef SQLITE_STMTJRNL_SPILL\n  \"STMTJRNL_SPILL=\" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),\n#endif\n#if SQLITE_SUBSTR_COMPATIBILITY\n  \"SUBSTR_COMPATIBILITY\",\n#endif\n#if SQLITE_SYSTEM_MALLOC\n  \"SYSTEM_MALLOC\",\n#endif\n#if SQLITE_TCL\n  \"TCL\",\n#endif\n#ifdef SQLITE_TEMP_STORE\n  \"TEMP_STORE=\" CTIMEOPT_VAL(SQLITE_TEMP_STORE),\n#endif\n#if SQLITE_TEST\n  \"TEST\",\n#endif\n#if defined(SQLITE_THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(SQLITE_THREADSAFE),\n#elif defined(THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(THREADSAFE),\n#else\n  \"THREADSAFE=1\",\n#endif\n#if SQLITE_UNLINK_AFTER_CLOSE\n  \"UNLINK_AFTER_CLOSE\",\n#endif\n#if SQLITE_UNTESTABLE\n  \"UNTESTABLE\",\n#endif\n#if SQLITE_USER_AUTHENTICATION\n  \"USER_AUTHENTICATION\",\n#endif\n#if SQLITE_USE_ALLOCA\n  \"USE_ALLOCA\",\n#endif\n#if SQLITE_USE_FCNTL_TRACE\n  \"USE_FCNTL_TRACE\",\n#endif\n#if SQLITE_USE_URI\n  \"USE_URI\",\n#endif\n#if SQLITE_VDBE_COVERAGE\n  \"VDBE_COVERAGE\",\n#endif\n#if SQLITE_WIN32_MALLOC\n  \"WIN32_MALLOC\",\n#endif\n#if SQLITE_ZERO_MALLOC\n  \"ZERO_MALLOC\",\n#endif\n/* \n** END CODE GENERATED BY tool/mkctime.tcl \n*/\n};\n\nSQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){\n  *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);\n  return (const char**)sqlite3azCompileOpt;\n}\n\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/************** End of ctime.c ***********************************************/\n/************** Begin file sqliteInt.h ***************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Internal interface definitions for SQLite.\n**\n*/\n#ifndef SQLITEINT_H\n#define SQLITEINT_H\n\n/* Special Comments:\n**\n** Some comments have special meaning to the tools that measure test\n** coverage:\n**\n**    NO_TEST                     - The branches on this line are not\n**                                  measured by branch coverage.  This is\n**                                  used on lines of code that actually\n**                                  implement parts of coverage testing.\n**\n**    OPTIMIZATION-IF-TRUE        - This branch is allowed to alway be false\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    OPTIMIZATION-IF-FALSE       - This branch is allowed to alway be true\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    PREVENTS-HARMLESS-OVERREAD  - This branch prevents a buffer overread\n**                                  that would be harmless and undetectable\n**                                  if it did occur.  \n**\n** In all cases, the special comment must be enclosed in the usual\n** slash-asterisk...asterisk-slash comment marks, with no spaces between the \n** asterisks and the comment text.\n*/\n\n/*\n** Make sure the Tcl calling convention macro is defined.  This macro is\n** only used by test code and Tcl integration code.\n*/\n#ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n#endif\n\n/*\n** Include the header file used to customize the compiler options for MSVC.\n** This should be done first so that it can successfully prevent spurious\n** compiler warnings due to subsequent content in this file and other files\n** that are included by this file.\n*/\n/************** Include msvc.h in the middle of sqliteInt.h ******************/\n/************** Begin file msvc.h ********************************************/\n/*\n** 2015 January 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to MSVC.\n*/\n#ifndef SQLITE_MSVC_H\n#define SQLITE_MSVC_H\n\n#if defined(_MSC_VER)\n#pragma warning(disable : 4054)\n#pragma warning(disable : 4055)\n#pragma warning(disable : 4100)\n#pragma warning(disable : 4127)\n#pragma warning(disable : 4130)\n#pragma warning(disable : 4152)\n#pragma warning(disable : 4189)\n#pragma warning(disable : 4206)\n#pragma warning(disable : 4210)\n#pragma warning(disable : 4232)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 4306)\n#pragma warning(disable : 4702)\n#pragma warning(disable : 4706)\n#endif /* defined(_MSC_VER) */\n\n#endif /* SQLITE_MSVC_H */\n\n/************** End of msvc.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/*\n** Special setup for VxWorks\n*/\n/************** Include vxworks.h in the middle of sqliteInt.h ***************/\n/************** Begin file vxworks.h *****************************************/\n/*\n** 2015-03-02\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Wind River's VxWorks\n*/\n#if defined(__RTP__) || defined(_WRS_KERNEL)\n/* This is VxWorks.  Set up things specially for that OS\n*/\n#include <vxWorks.h>\n#include <pthread.h>  /* amalgamator: dontcache */\n#define OS_VXWORKS 1\n#define SQLITE_OS_OTHER 0\n#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1\n#define SQLITE_OMIT_LOAD_EXTENSION 1\n#define SQLITE_ENABLE_LOCKING_STYLE 0\n#define HAVE_UTIME 1\n#else\n/* This is not VxWorks. */\n#define OS_VXWORKS 0\n#define HAVE_FCHOWN 1\n#define HAVE_READLINK 1\n#define HAVE_LSTAT 1\n#endif /* defined(_WRS_KERNEL) */\n\n/************** End of vxworks.h *********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/*\n** These #defines should enable >2GB file support on POSIX if the\n** underlying operating system supports it.  If the OS lacks\n** large file support, or if the OS is windows, these should be no-ops.\n**\n** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any\n** system #includes.  Hence, this block of code must be the very first\n** code in all source files.\n**\n** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch\n** on the compiler command line.  This is necessary if you are compiling\n** on a recent machine (ex: Red Hat 7.2) but you want your code to work\n** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2\n** without this option, LFS is enable.  But LFS does not exist in the kernel\n** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary\n** portability you should omit LFS.\n**\n** The previous paragraph was written in 2005.  (This paragraph is written\n** on 2008-11-28.) These days, all Linux kernels support large files, so\n** you should probably leave LFS enabled.  But some embedded platforms might\n** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.\n**\n** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n/* The GCC_VERSION and MSVC_VERSION macros are used to\n** conditionally include optimizations for each of these compilers.  A\n** value of 0 means that compiler is not being used.  The\n** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific\n** optimizations, and hence set all compiler macros to 0\n**\n** There was once also a CLANG_VERSION macro.  However, we learn that the\n** version numbers in clang are for \"marketing\" only and are inconsistent\n** and unreliable.  Fortunately, all versions of clang also recognize the\n** gcc version numbers and have reasonable settings for gcc version numbers,\n** so the GCC_VERSION macro will be set to a correct non-zero value even\n** when compiling with clang.\n*/\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n\n/* Needed for various definitions... */\n#if defined(__GNUC__) && !defined(_GNU_SOURCE)\n# define _GNU_SOURCE\n#endif\n\n#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)\n# define _BSD_SOURCE\n#endif\n\n/*\n** For MinGW, check to see if we can include the header file containing its\n** version information, among other things.  Normally, this internal MinGW\n** header file would [only] be included automatically by other MinGW header\n** files; however, the contained version information is now required by this\n** header file to work around binary compatibility issues (see below) and\n** this is the only known way to reliably obtain it.  This entire #if block\n** would be completely unnecessary if there was any other way of detecting\n** MinGW via their preprocessor (e.g. if they customized their GCC to define\n** some MinGW-specific macros).  When compiling for MinGW, either the\n** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be\n** defined; otherwise, detection of conditions specific to MinGW will be\n** disabled.\n*/\n#if defined(_HAVE_MINGW_H)\n# include \"mingw.h\"\n#elif defined(_HAVE__MINGW_H)\n# include \"_mingw.h\"\n#endif\n\n/*\n** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T\n** define is required to maintain binary compatibility with the MSVC runtime\n** library in use (e.g. for Windows XP).\n*/\n#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \\\n    defined(_WIN32) && !defined(_WIN64) && \\\n    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \\\n    defined(__MSVCRT__)\n# define _USE_32BIT_TIME_T\n#endif\n\n/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear\n** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for\n** MinGW.\n*/\n/************** Include sqlite3.h in the middle of sqliteInt.h ***************/\n/************** Begin file sqlite3.h *****************************************/\n/*\n** 2001-09-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are supposed to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef SQLITE3_H\n#define SQLITE3_H\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\nextern \"C\" {\n#endif\n\n\n/*\n** Provide the ability to override linkage features of the interface.\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n#ifndef SQLITE_CDECL\n# define SQLITE_CDECL\n#endif\n#ifndef SQLITE_APICALL\n# define SQLITE_APICALL\n#endif\n#ifndef SQLITE_STDCALL\n# define SQLITE_STDCALL SQLITE_APICALL\n#endif\n#ifndef SQLITE_CALLBACK\n# define SQLITE_CALLBACK\n#endif\n#ifndef SQLITE_SYSAPI\n# define SQLITE_SYSAPI\n#endif\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are supported for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since [version 3.6.18] ([dateof:3.6.18]), \n** SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and a SHA1\n** or SHA3-256 hash of the entire source tree.  If the source code has\n** been edited in any way since it was last checked in, then the last\n** four hexadecimal digits of the hash may be modified.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.21.0\"\n#define SQLITE_VERSION_NUMBER 3021000\n#define SQLITE_SOURCE_ID      \"2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de48827\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus ensure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built\n** using an edited copy of [the amalgamation], then the last four characters\n** of the hash might be different from [SQLITE_SOURCE_ID].)^\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n# ifdef SQLITE_UINT64_TYPE\n    typedef SQLITE_UINT64_TYPE sqlite_uint64;\n# else  \n    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n# endif\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n** DESTRUCTOR: sqlite3\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and/or unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n** METHOD: sqlite3\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must ensure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close the [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: {result code definitions}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [extended result code definitions]\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* Generic error */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Internal use only */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Not used */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended result code definitions}\n**\n** In its default configuration, SQLite API routines return one of 30 integer\n** [result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]\n** and later) include\n** support for additional result codes that provide more detailed information\n** about errors. These [extended result codes] are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.  Or, the extended code for\n** the most recent error can be obtained using\n** [sqlite3_extended_errcode()].\n*/\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))\n#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))\n#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))\n#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))\n#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))\n#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))\n#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))\n#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))\n#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n** flag indicates that a file cannot be deleted when open.  The\n** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on\n** read-only media and cannot be changed even by processes with\n** elevated privileges.\n**\n** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying\n** filesystem supports doing multiple write operations atomically when those\n** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and\n** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n#define SQLITE_IOCAP_IMMUTABLE              0x00002000\n#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [file control opcodes | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]\n** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]\n** <li> [SQLITE_IOCAP_IMMUTABLE]\n** <li> [SQLITE_IOCAP_BATCH_ATOMIC]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n** KEYWORDS: {file control opcodes} {file control opcode}\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** <ul>\n** <li>[[SQLITE_FCNTL_LOCKSTATE]]\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and is only available when the SQLITE_TEST\n** compile-time option is used.\n**\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].\n**\n** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]\n** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with the journal file (either\n** the [rollback journal] or the [write-ahead log]) for a particular database\n** connection.  See also [SQLITE_FCNTL_FILE_POINTER].\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** No longer in use.\n**\n** <li>[[SQLITE_FCNTL_SYNC]]\n** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and\n** sent to the VFS immediately before the xSync method is invoked on a\n** database file descriptor. Or, if the xSync method is not invoked \n** because the user has configured SQLite with \n** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place \n** of the xSync method. In most cases, the pointer argument passed with\n** this file-control is NULL. However, if the database file is being synced\n** as part of a multi-database commit, the argument points to a nul-terminated\n** string containing the transactions master-journal file name. VFSes that \n** do not need this signal should silently ignore this opcode. Applications \n** should not call [sqlite3_file_control()] with this opcode as doing so may \n** disrupt the operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]\n** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite\n** and sent to the VFS after a transaction has been committed immediately\n** but before the database is unlocked. VFSes that do not need this signal\n** should silently ignore this opcode. Applications should not call\n** [sqlite3_file_control()] with this opcode as doing so may disrupt the \n** operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer is the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log and shared memory files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_VFS_POINTER]]\n** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level\n** [VFSes] currently in use.  ^(The argument X in\n** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be\n** of type \"[sqlite3_vfs] **\".  This opcodes will set *X\n** to a pointer to the top-level VFS.)^\n** ^When there are multiple VFS shims in the stack, this opcode finds the\n** upper-most shim only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement if result string is NULL, or that returns a copy\n** of the result string if the string is non-NULL.\n** ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** <li>[[SQLITE_FCNTL_TRACE]]\n** The [SQLITE_FCNTL_TRACE] file control provides advisory information\n** to the VFS about what the higher layers of the SQLite stack are doing.\n** This file control is used by some VFS activity tracing [shims].\n** The argument is a zero-terminated string.  Higher layers in the\n** SQLite stack may generate instances of this file control if\n** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.\n**\n** <li>[[SQLITE_FCNTL_HAS_MOVED]]\n** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a\n** pointer to an integer and it writes a boolean into that integer depending\n** on whether or not the file has been renamed, moved, or deleted since it\n** was first opened.\n**\n** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the\n** underlying native file handle associated with a file handle.  This file\n** control interprets its argument as a pointer to a native file handle and\n** writes the resulting value there.\n**\n** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to swap the file handle with the one\n** pointed to by the pArg argument.  This capability is used during testing\n** and only needs to be supported when SQLITE_TEST is defined.\n**\n** <li>[[SQLITE_FCNTL_WAL_BLOCK]]\n** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might\n** be advantageous to block on the next WAL lock if the lock is not immediately\n** available.  The WAL subsystem issues this signal during rare\n** circumstances in order to fix a problem with priority inversion.\n** Applications should <em>not</em> use this file-control.\n**\n** <li>[[SQLITE_FCNTL_ZIPVFS]]\n** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other\n** VFS should return SQLITE_NOTFOUND for this opcode.\n**\n** <li>[[SQLITE_FCNTL_RBU]]\n** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by\n** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for\n** this opcode.  \n**\n** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]\n** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then\n** the file descriptor is placed in \"batch write mode\", which\n** means all subsequent write operations will be deferred and done\n** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems\n** that do not support batch atomic writes will return SQLITE_NOTFOUND.\n** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to\n** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or\n** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make\n** no VFS interface calls on the same [sqlite3_file] file descriptor\n** except for calls to the xWrite method and the xFileControl method\n** with [SQLITE_FCNTL_SIZE_HINT].\n**\n** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.\n** This file control returns [SQLITE_OK] if and only if the writes were\n** all performed successfully and have been committed to persistent storage.\n** ^Regardless of whether or not it is successful, this file control takes\n** the file descriptor out of batch write mode so that all subsequent\n** write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.\n** ^This file control takes the file descriptor out of batch write mode\n** so that all subsequent write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2\n#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3\n#define SQLITE_FCNTL_LAST_ERRNO              4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n#define SQLITE_FCNTL_TRACE                  19\n#define SQLITE_FCNTL_HAS_MOVED              20\n#define SQLITE_FCNTL_SYNC                   21\n#define SQLITE_FCNTL_COMMIT_PHASETWO        22\n#define SQLITE_FCNTL_WIN32_SET_HANDLE       23\n#define SQLITE_FCNTL_WAL_BLOCK              24\n#define SQLITE_FCNTL_ZIPVFS                 25\n#define SQLITE_FCNTL_RBU                    26\n#define SQLITE_FCNTL_VFS_POINTER            27\n#define SQLITE_FCNTL_JOURNAL_POINTER        28\n#define SQLITE_FCNTL_WIN32_GET_HANDLE       29\n#define SQLITE_FCNTL_PDB                    30\n#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31\n#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32\n#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33\n\n/* deprecated names */\n#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE\n#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE\n#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO\n\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: Loadable Extension Thunk\n**\n** A pointer to the opaque sqlite3_api_routines structure is passed as\n** the third parameter to entry points of [loadable extensions].  This\n** structure must be typedefed in order to work around compiler warnings\n** on some platforms.\n*/\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The value of the iVersion field is initially 1 but may be larger in\n** future versions of SQLite.  Additional fields may be appended to this\n** object when the iVersion value is increased.  Note that the structure\n** of the sqlite3_vfs object changes in the transaction between\n** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not\n** modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in future versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given on the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** <b>The sqlite3_config() interface is not threadsafe. The application\n** must ensure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.</b>\n**\n** The sqlite3_config() interface\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n** METHOD: sqlite3\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is \n** a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>\n** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of\n** type int, interpreted as a boolean, which if true provides a hint to\n** SQLite that it should avoid large memory allocations if possible.\n** SQLite will run faster if it is free to make large memory allocations,\n** but some application might prefer to run slower in exchange for\n** guarantees about memory fragmentation that are possible if large\n** allocations are avoided.  This hint is normally off.\n** </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,\n** interpreted as a boolean, which enables or disables the collection of\n** memory allocation statistics. ^(When memory allocation statistics are\n** disabled, the following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status64()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.\n** </dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool\n** that SQLite can use for the database page cache with the default page\n** cache implementation.  \n** This configuration option is a no-op if an application-define page\n** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].\n** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to\n** 8-byte aligned memory (pMem), the size of each page cache line (sz),\n** and the number of cache lines (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 65536) plus some extra bytes for each\n** page header.  ^The number of extra bytes needed by the page header\n** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].\n** ^It is harmless, apart from the wasted memory,\n** for the sz parameter to be larger than necessary.  The pMem\n** argument must be either a NULL pointer or a pointer to an 8-byte\n** aligned block of memory of at least sz*N bytes, otherwise\n** subsequent behavior is undefined.\n** ^When pMem is not NULL, SQLite will strive to use the memory provided\n** to satisfy page cache needs, falling back to [sqlite3_malloc()] if\n** a page cache line is larger than sz bytes or if all of the pMem buffer\n** is exhausted.\n** ^If pMem is NULL and N is non-zero, then each database connection\n** does an initial bulk allocation for page cache memory\n** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or\n** of -1024*N bytes if N is negative, . ^If additional\n** page cache memory is needed beyond what is provided by the initial\n** allocation, then SQLite goes to [sqlite3_malloc()] separately for each\n** additional cache line. </dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer \n** that SQLite will use for all of its dynamic memory allocation needs\n** beyond those provided for by [SQLITE_CONFIG_PAGECACHE].\n** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled\n** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns\n** [SQLITE_ERROR] if invoked otherwise.\n** ^There are three arguments to SQLITE_CONFIG_HEAP:\n** An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a\n** pointer to an instance of the [sqlite3_mutex_methods] structure.\n** The argument specifies alternative low-level mutex routines to be used\n** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of\n** the content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine\n** the default size of lookaside memory on each [database connection].\n** The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE\n** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** option to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is \n** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies\n** the interface to a custom page cache implementation.)^\n** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which\n** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of\n** the current page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.\n** If non-zero, then URI handling is globally enabled. If the parameter is zero,\n** then URI handling is globally disabled.)^ ^If URI handling is globally\n** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],\n** [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. ^If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. ^(By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.)^\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer\n** argument which is interpreted as a boolean in order to enable or disable\n** the use of covering indices for full table scans in the query optimizer.\n** ^The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** ^The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size\n** will be silently truncated if necessary so that it does not exceed the\n** compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^\n** ^If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n**\n** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]\n** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE\n** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is\n** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro\n** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value\n** that specifies the maximum size of the created heap.\n**\n** [[SQLITE_CONFIG_PCACHE_HDRSZ]]\n** <dt>SQLITE_CONFIG_PCACHE_HDRSZ\n** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which\n** is a pointer to an integer and writes into that integer the number of extra\n** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].\n** The amount of extra space required can change depending on the compiler,\n** target platform, and SQLite version.\n**\n** [[SQLITE_CONFIG_PMASZ]]\n** <dt>SQLITE_CONFIG_PMASZ\n** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which\n** is an unsigned integer and sets the \"Minimum PMA Size\" for the multithreaded\n** sorter to that integer.  The default minimum PMA Size is set by the\n** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched\n** to help with sort operations when multithreaded sorting\n** is enabled (using the [PRAGMA threads] command) and the amount of content\n** to be sorted exceeds the page size times the minimum of the\n** [PRAGMA cache_size] setting and this value.\n**\n** [[SQLITE_CONFIG_STMTJRNL_SPILL]]\n** <dt>SQLITE_CONFIG_STMTJRNL_SPILL\n** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which\n** becomes the [statement journal] spill-to-disk threshold.  \n** [Statement journals] are held in memory until their size (in bytes)\n** exceeds this threshold, at which point they are written to disk.\n** Or if the threshold is -1, statement journals are always held\n** exclusively in memory.\n** Since many statement journals never become large, setting the spill\n** threshold to a value such as 64KiB can greatly reduce the amount of\n** I/O required to support statement rollback.\n** The default value for this setting is controlled by the\n** [SQLITE_STMTJRNL_SPILL] compile-time option.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* No longer used */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */\n#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */\n#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */\n#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */\n#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>\n** <dd> ^This option is used to enable or disable the two-argument\n** version of the [fts3_tokenizer()] function which is part of the\n** [FTS3] full-text search engine extension.\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable fts3_tokenizer() or\n** positive to enable fts3_tokenizer() or negative to leave the setting\n** unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the new setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>\n** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]\n** interface independently of the [load_extension()] SQL function.\n** The [sqlite3_enable_load_extension()] API enables or disables both the\n** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].\n** There should be two additional arguments.\n** When the first argument to this interface is 1, then only the C-API is\n** enabled and the SQL function remains disabled.  If the first argument to\n** this interface is 0, then both the C-API and the SQL function are disabled.\n** If the first argument is -1, then no changes are made to state of either the\n** C-API or the SQL function.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface\n** is disabled or enabled following this call.  The second parameter may\n** be a NULL pointer, in which case the new setting is not reported back.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>\n** <dd> ^This option is used to change the name of the \"main\" database\n** schema.  ^The sole argument is a pointer to a constant UTF8 string\n** which will become the new schema name in place of \"main\".  ^SQLite\n** does not make a copy of the new main schema name string, so the application\n** must ensure that the argument passed into this DBCONFIG option is unchanged\n** until after the database connection closes.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>\n** <dd> Usually, when a database in wal mode is closed or detached from a \n** database handle, SQLite checks if this will mean that there are now no \n** connections at all to the database. If so, it performs a checkpoint \n** operation before closing the connection. This option may be used to\n** override this behaviour. The first parameter passed to this operation\n** is an integer - non-zero to disable checkpoints-on-close, or zero (the\n** default) to enable them. The second parameter is a pointer to an integer\n** into which is written 0 or 1 to indicate whether checkpoints-on-close\n** have been disabled - 0 if they are not disabled, 1 if they are.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>\n** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates\n** the [query planner stability guarantee] (QPSG).  When the QPSG is active,\n** a single SQL query statement will always use the same algorithm regardless\n** of values of [bound parameters].)^ The QPSG disables some query optimizations\n** that look at the values of bound parameters, which can make some queries\n** slower.  But the QPSG has the advantage of more predictable behavior.  With\n** the QPSG active, SQLite will always use the same query plan in the field as\n** was used during testing in the lab.\n** </dd>\n**\n** </dl>\n*/\n#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */\n#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */\n#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */\n\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n** METHOD: sqlite3\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n** METHOD: sqlite3\n**\n** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)\n** has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of\n** the most recent successful [INSERT] into a rowid table or [virtual table]\n** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not\n** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred \n** on the database connection D, then sqlite3_last_insert_rowid(D) returns \n** zero.\n**\n** As well as being set automatically as rows are inserted into database\n** tables, the value returned by this function may be set explicitly by\n** [sqlite3_set_last_insert_rowid()]\n**\n** Some virtual table implementations may INSERT rows into rowid tables as\n** part of committing a transaction (e.g. to flush data accumulated in memory\n** to disk). In this case subsequent calls to this function return the rowid\n** associated with these internal INSERT operations, which leads to \n** unintuitive results. Virtual table implementations that do write to rowid\n** tables in this way can avoid this problem by restoring the original \n** rowid value using [sqlite3_set_last_insert_rowid()] before returning \n** control to the user.\n**\n** ^(If an [INSERT] occurs within a trigger then this routine will \n** return the [rowid] of the inserted row as long as the trigger is \n** running. Once the trigger program ends, the value returned \n** by this routine reverts to what it was before the trigger was fired.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Set the Last Insert Rowid value.\n** METHOD: sqlite3\n**\n** The sqlite3_set_last_insert_rowid(D, R) method allows the application to\n** set the value returned by calling sqlite3_last_insert_rowid(D) to R \n** without inserting a row into the database.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the number of rows modified, inserted or\n** deleted by the most recently completed INSERT, UPDATE or DELETE\n** statement on the database connection specified by the only parameter.\n** ^Executing any other type of SQL statement does not modify the value\n** returned by this function.\n**\n** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are\n** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], \n** [foreign key actions] or [REPLACE] constraint resolution are not counted.\n** \n** Changes to a view that are intercepted by \n** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value \n** returned by sqlite3_changes() immediately after an INSERT, UPDATE or \n** DELETE statement run on a view is always zero. Only changes made to real \n** tables are counted.\n**\n** Things are more complicated if the sqlite3_changes() function is\n** executed while a trigger program is running. This may happen if the\n** program uses the [changes() SQL function], or if some other callback\n** function invokes sqlite3_changes() directly. Essentially:\n** \n** <ul>\n**   <li> ^(Before entering a trigger program the value returned by\n**        sqlite3_changes() function is saved. After the trigger program \n**        has finished, the original value is restored.)^\n** \n**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE \n**        statement sets the value returned by sqlite3_changes() \n**        upon completion as normal. Of course, this value will not include \n**        any changes performed by sub-triggers, as the sqlite3_changes() \n**        value will be saved and restored after each sub-trigger has run.)^\n** </ul>\n** \n** ^This means that if the changes() SQL function (or similar) is used\n** by the first INSERT, UPDATE or DELETE statement within a trigger, it \n** returns the value as set when the calling statement began executing.\n** ^If it is used by the second or subsequent such statement within a trigger \n** program, the value returned reflects the number of rows modified by the \n** previous INSERT, UPDATE or DELETE statement within the same trigger.\n**\n** See also the [sqlite3_total_changes()] interface, the\n** [count_changes pragma], and the [changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the total number of rows inserted, modified or\n** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed\n** since the database connection was opened, including those executed as\n** part of trigger programs. ^Executing any other type of SQL statement\n** does not affect the value returned by sqlite3_total_changes().\n** \n** ^Changes made as part of [foreign key actions] are included in the\n** count, but those made as part of REPLACE constraint resolution are\n** not. ^Changes to a view that are intercepted by INSTEAD OF triggers \n** are not counted.\n** \n** See also the [sqlite3_changes()] interface, the\n** [count_changes pragma], and the [total_changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n** METHOD: sqlite3\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n** KEYWORDS: {busy-handler callback} {busy handler}\n** METHOD: sqlite3\n**\n** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X\n** that might be invoked with argument P whenever\n** an attempt is made to access a database table associated with\n** [database connection] D when another thread\n** or process has the table locked.\n** The sqlite3_busy_handler() interface is used to implement\n** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked previously for the same locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] is returned\n** to the application.\n** ^If the callback returns non-zero, then another attempt\n** is made to access the database and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** to the application instead of invoking the \n** busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** or evaluating [PRAGMA busy_timeout=N] will change the\n** busy handler and thus clear any previously set busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  In other words,\n** the busy handler is not reentrant.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n** METHOD: sqlite3\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] at any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n**\n** See also:  [PRAGMA busy_timeout]\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n** METHOD: sqlite3\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n** These routines understand most of the common K&R formatting options,\n** plus some additional non-standard formats, detailed below.\n** Note that some of the more obscure formatting options from recent\n** C-library standards are omitted from this implementation.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** These routines all implement some additional formatting\n** options that are useful for constructing SQL statements.\n** All of the usual printf() formatting options apply.  In addition, there\n** is are \"%q\", \"%Q\", \"%w\" and \"%z\" options.\n**\n** ^(The %q option works like %s in that it substitutes a nul-terminated\n** string from the argument list.  But %q also doubles every '\\'' character.\n** %q is designed for use inside a string literal.)^  By doubling each '\\''\n** character it escapes that character and allows it to be inserted into\n** the string.\n**\n** For example, assume the string variable zText contains text as follows:\n**\n** <blockquote><pre>\n**  char *zText = \"It's a happy day!\";\n** </pre></blockquote>\n**\n** One can use this text in an SQL statement as follows:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES('%q')\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** Because the %q format string is used, the '\\'' character in zText\n** is escaped and the SQL generated is as follows:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It''s a happy day!')\n** </pre></blockquote>\n**\n** This is correct.  Had we used %s instead of %q, the generated SQL\n** would have looked like this:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It's a happy day!');\n** </pre></blockquote>\n**\n** This second example is an SQL syntax error.  As a general rule you should\n** always use %q instead of %s when inserting text into a string literal.\n**\n** ^(The %Q option works like %q except it also adds single quotes around\n** the outside of the total string.  Additionally, if the parameter in the\n** argument list is a NULL pointer, %Q substitutes the text \"NULL\" (without\n** single quotes).)^  So, for example, one could say:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES(%Q)\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** The code above will render a correct SQL statement in the zSQL\n** variable even if the zText variable is a NULL pointer.\n**\n** ^(The \"%w\" formatting option is like \"%q\" except that it expects to\n** be contained within double-quotes instead of single quotes, and it\n** escapes the double-quote character instead of the single-quote\n** character.)^  The \"%w\" formatting option is intended for safely inserting\n** table and column names into a constructed SQL statement.\n**\n** ^(The \"%z\" formatting option works like \"%s\" but with the\n** addition that after the string has been read and copied into\n** the result, [sqlite3_free()] is called on the input string.)^\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^The sqlite3_malloc64(N) routine works just like\n** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead\n** of a signed 32-bit integer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^The sqlite3_realloc(X,N) interface attempts to resize a\n** prior memory allocation X to be at least N bytes.\n** ^If the X parameter to sqlite3_realloc(X,N)\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N).\n** ^If the N parameter to sqlite3_realloc(X,N) is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(X).\n** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if insufficient memory is available.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc(X,N) and the prior allocation is freed.\n** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the\n** prior allocation is not freed.\n**\n** ^The sqlite3_realloc64(X,N) interfaces works the same as\n** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead\n** of a 32-bit signed integer.\n**\n** ^If X is a memory allocation previously obtained from sqlite3_malloc(),\n** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then\n** sqlite3_msize(X) returns the size of that memory allocation in bytes.\n** ^The value returned by sqlite3_msize(X) might be larger than the number\n** of bytes requested when X was allocated.  ^If X is a NULL pointer then\n** sqlite3_msize(X) returns zero.  If X points to something that is not\n** the beginning of memory allocation, or if it points to a formerly\n** valid memory allocation that has now been freed, then the behavior\n** of sqlite3_msize(X) is undefined and possibly harmful.\n**\n** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),\n** sqlite3_malloc64(), and sqlite3_realloc64()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);\nSQLITE_API void sqlite3_free(void*);\nSQLITE_API sqlite3_uint64 sqlite3_msize(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n** ^The P parameter can be a NULL pointer.\n**\n** ^If this routine has not been previously called or if the previous\n** call had N less than one or a NULL pointer for P, then the PRNG is\n** seeded using randomness obtained from the xRandomness method of\n** the default [sqlite3_vfs] object.\n** ^If the previous call to this routine had an N of 1 or more and a\n** non-NULL P then the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n** METHOD: sqlite3\n** KEYWORDS: {authorizer callback}\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],\n** and [sqlite3_prepare16_v3()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are either NULL pointers or zero-terminated strings\n** that contain additional details about the action to be authorized.\n** Applications must always be prepared to encounter a NULL pointer in any\n** of the third through the sixth parameters of the authorization callback.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^When a table is referenced by a [SELECT] but no column values are\n** extracted from that table (for example in a query like\n** \"SELECT count(*) FROM tab\") then the [SQLITE_READ] authorizer callback\n** is invoked once for that table with a column name that is an empty string.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]\n** returned from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n#define SQLITE_RECURSIVE            33   /* NULL            NULL            */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n** METHOD: sqlite3\n**\n** These routines are deprecated. Use the [sqlite3_trace_v2()] interface\n** instead of the routines described here.\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  The\n** sqlite3_profile() function is considered experimental and is\n** subject to change in future versions of SQLite.\n*/\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,\n   void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: SQL Trace Event Codes\n** KEYWORDS: SQLITE_TRACE\n**\n** These constants identify classes of events that can be monitored\n** using the [sqlite3_trace_v2()] tracing logic.  The third argument\n** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of\n** the following constants.  ^The first argument to the trace callback\n** is one of the following constants.\n**\n** New tracing constants may be added in future releases.\n**\n** ^A trace callback has four arguments: xCallback(T,C,P,X).\n** ^The T argument is one of the integer type codes above.\n** ^The C argument is a copy of the context pointer passed in as the\n** fourth argument to [sqlite3_trace_v2()].\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** <dl>\n** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>\n** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement\n** first begins running and possibly at other times during the\n** execution of the prepared statement, such as at the start of each\n** trigger subprogram. ^The P argument is a pointer to the\n** [prepared statement]. ^The X argument is a pointer to a string which\n** is the unexpanded SQL text of the prepared statement or an SQL comment \n** that indicates the invocation of a trigger.  ^The callback can compute\n** the same text that would have been returned by the legacy [sqlite3_trace()]\n** interface by using the X argument when X begins with \"--\" and invoking\n** [sqlite3_expanded_sql(P)] otherwise.\n**\n** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>\n** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same\n** information as is provided by the [sqlite3_profile()] callback.\n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument points to a 64-bit integer which is the estimated of\n** the number of nanosecond that the prepared statement took to run.\n** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.\n**\n** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>\n** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared\n** statement generates a single row of result.  \n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument is unused.\n**\n** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>\n** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database\n** connection closes.\n** ^The P argument is a pointer to the [database connection] object\n** and the X argument is unused.\n** </dl>\n*/\n#define SQLITE_TRACE_STMT       0x01\n#define SQLITE_TRACE_PROFILE    0x02\n#define SQLITE_TRACE_ROW        0x04\n#define SQLITE_TRACE_CLOSE      0x08\n\n/*\n** CAPI3REF: SQL Trace Hook\n** METHOD: sqlite3\n**\n** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback\n** function X against [database connection] D, using property mask M\n** and context pointer P.  ^If the X callback is\n** NULL or if the M mask is zero, then tracing is disabled.  The\n** M argument should be the bitwise OR-ed combination of\n** zero or more [SQLITE_TRACE] constants.\n**\n** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides \n** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().\n**\n** ^The X callback is invoked whenever any of the events identified by \n** mask M occur.  ^The integer return value from the callback is currently\n** ignored, though this may change in future releases.  Callback\n** implementations should return zero to ensure future compatibility.\n**\n** ^A trace callback is invoked with four arguments: callback(T,C,P,X).\n** ^The T argument is one of the [SQLITE_TRACE]\n** constants to indicate why the callback was invoked.\n** ^The C argument is a copy of the context pointer.\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** The sqlite3_trace_v2() interface is intended to replace the legacy\n** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which\n** are deprecated.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3*,\n  unsigned uMask,\n  int(*xCallback)(unsigned,void*,void*,void*),\n  void *pCtx\n);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the approximate number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.  ^If N is less than one then the progress\n** handler is disabled.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n** CONSTRUCTOR: sqlite3\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding will be UTF-8 for databases created using\n** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases\n** created using sqlite3_open16() will be UTF-16 in the native byte order.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the third argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^(On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").)^\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite and its built-in [VFSes] interpret the\n** following query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n**\n**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the\n**     [powersafe overwrite] property does or does not apply to the\n**     storage media on which the database file resides.\n**\n**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter\n**     which if set disables file locking in rollback journal modes.  This\n**     is useful for accessing a database on a filesystem that does not\n**     support locking.  Caution:  Database corruption might result if two\n**     or more processes write to the same database and any one of those\n**     processes uses nolock=1.\n**\n**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query\n**     parameter that indicates that the database file is stored on\n**     read-only media.  ^When immutable is set, SQLite assumes that the\n**     database file cannot be changed, even by a process with higher\n**     privilege, and so the database is opened read-only and all locking\n**     and change detection is disabled.  Caution: Setting the immutable\n**     property on a database file that does in fact change can result\n**     in incorrect query results and/or [SQLITE_CORRUPT] errors.\n**     See also: [SQLITE_IOCAP_IMMUTABLE].\n**       \n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-dotfile\"\n**          that uses dot-files in place of posix advisory locking.\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n** METHOD: sqlite3\n**\n** ^If the most recent sqlite3_* API call associated with \n** [database connection] D failed, then the sqlite3_errcode(D) interface\n** returns the numeric [result code] or [extended result code] for that\n** API call.\n** If the most recent API call was successful,\n** then the return value from sqlite3_errcode() is undefined.\n** ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: Prepared Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement that\n** has been compiled into binary form and is ready to be evaluated.\n**\n** Think of each SQL statement as a separate computer program.  The\n** original SQL text is source code.  A prepared statement object \n** is the compiled object code.  All SQL must be converted into a\n** prepared statement before it can be run.\n**\n** The life-cycle of a prepared statement object usually goes like this:\n**\n** <ol>\n** <li> Create the prepared statement object using [sqlite3_prepare_v2()].\n** <li> Bind values to [parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the prepared statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n** METHOD: sqlite3\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or\n** the equivalent tries to allocate space for more than this many opcodes\n** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n**\n** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>\n** <dd>The maximum number of auxiliary worker threads that a single\n** [prepared statement] may start.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n#define SQLITE_LIMIT_WORKER_THREADS           11\n\n/*\n** CAPI3REF: Prepare Flags\n**\n** These constants define various flags that can be passed into\n** \"prepFlags\" parameter of the [sqlite3_prepare_v3()] and\n** [sqlite3_prepare16_v3()] interfaces.\n**\n** New flags may be added in future releases of SQLite.\n**\n** <dl>\n** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>\n** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner\n** that the prepared statement will be retained for a long time and\n** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]\n** and [sqlite3_prepare16_v3()] assume that the prepared statement will \n** be used just once or at most a few times and then destroyed using\n** [sqlite3_finalize()] relatively soon. The current implementation acts\n** on this hint by avoiding the use of [lookaside memory] so as not to\n** deplete the limited store of lookaside memory. Future versions of\n** SQLite may act on this hint differently.\n** </dl>\n*/\n#define SQLITE_PREPARE_PERSISTENT              0x01\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_stmt\n**\n** To execute an SQL statement, it must first be compiled into a byte-code\n** program using one of these routines.  Or, in other words, these routines\n** are constructors for the [prepared statement] object.\n**\n** The preferred routine to use is [sqlite3_prepare_v2()].  The\n** [sqlite3_prepare()] interface is legacy and should be avoided.\n** [sqlite3_prepare_v3()] has an extra \"prepFlags\" option that is used\n** for special purposes.\n**\n** The use of the UTF-8 interfaces is preferred, as SQLite currently\n** does all parsing using UTF-8.  The UTF-16 interfaces are provided\n** as a convenience.  The UTF-16 interfaces work by converting the\n** input text into UTF-8, then invoking the corresponding UTF-8 interface.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare(), sqlite3_prepare_v2(),\n** and sqlite3_prepare_v3()\n** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() use UTF-16.\n**\n** ^If the nByte argument is negative, then zSql is read up to the\n** first zero terminator. ^If nByte is positive, then it is the\n** number of bytes read from zSql.  ^If nByte is zero, then no prepared\n** statement is generated.\n** If the caller knows that the supplied string is nul-terminated, then\n** there is a small performance advantage to passing an nByte parameter that\n** is the number of bytes in the input string <i>including</i>\n** the nul-terminator.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.\n** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())\n** are retained for backwards compatibility, but their use is discouraged.\n** ^In the \"vX\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** </li>\n**\n** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having\n** the extra prepFlags parameter, which is a bit array consisting of zero or\n** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The\n** sqlite3_prepare_v2() interface works exactly the same as\n** sqlite3_prepare_v3() with a zero prepFlags parameter.\n** </ol>\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8\n** SQL text used to create [prepared statement] P if P was\n** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8\n** string containing the SQL text of prepared statement P with\n** [bound parameters] expanded.\n**\n** ^(For example, if a prepared statement is created using the SQL\n** text \"SELECT $abc,:xyz\" and if parameter $abc is bound to integer 2345\n** and parameter :xyz is unbound, then sqlite3_sql() will return\n** the original string, \"SELECT $abc,:xyz\" but sqlite3_expanded_sql()\n** will return \"SELECT 2345,NULL\".)^\n**\n** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory\n** is available to hold the result, or if the result would exceed the\n** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].\n**\n** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of\n** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time\n** option causes sqlite3_expanded_sql() to always return NULL.\n**\n** ^The string returned by sqlite3_sql(P) is managed by SQLite and is\n** automatically freed when the prepared statement is finalized.\n** ^The string returned by sqlite3_expanded_sql(P), on the other hand,\n** is obtained from [sqlite3_malloc()] and must be free by the application\n** by passing it to [sqlite3_free()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since\n** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and\n** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so\n** sqlite3_stmt_readonly() returns false for those commands.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has neither run to completion (returned\n** [SQLITE_DONE] from [sqlite3_step(S)]) nor\n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.  The\n** [sqlite3_value_dup()] interface can be used to construct a new \n** protected sqlite3_value from an unprotected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used as arguments\n** to [sqlite3_result_value()], [sqlite3_bind_value()], and\n** [sqlite3_value_dup()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct sqlite3_value sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n** METHOD: sqlite3_stmt\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() or sqlite3_bind_text64() then\n** that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to the BLOB and string binding interfaces\n** is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to bind API fails.\n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sixth argument to sqlite3_bind_text64() must be one of\n** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]\n** to specify the encoding of the text in the third parameter.  If\n** the sixth argument to sqlite3_bind_text64() is not one of the\n** allowed values shown above, or if the text encoding is different\n** from the encoding specified by the sixth parameter, then the behavior\n** is undefined.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in\n** [prepared statement] S to have an SQL value of NULL, but to also be\n** associated with the pointer P of type T.  ^D is either a NULL pointer or\n** a pointer to a destructor function for P. ^SQLite will invoke the\n** destructor D with a single argument of P when it is finished using\n** P.  The T parameter should be a static string, preferably a string\n** literal. The sqlite3_bind_pointer() routine is part of the\n** [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB\n** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or\n** [SQLITE_MAX_LENGTH].\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,\n                        void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,\n                         void(*)(void*), unsigned char encoding);\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n** METHOD: sqlite3_stmt\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n** METHOD: sqlite3_stmt\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or\n** [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_name()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^If this routine returns 0, that means the \n** [prepared statement] returns no data (for example an [UPDATE]).\n** ^However, just because this routine returns a positive number does not\n** mean that one or more rows of data will be returned.  ^A SELECT statement\n** will always have a positive sqlite3_column_count() but depending on the\n** WHERE clause constraints and the table content, it might return no rows.\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n** METHOD: sqlite3_stmt\n**\n** After a [prepared statement] has been prepared using any of\n** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],\n** or [sqlite3_prepare16_v3()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"vX\" interfaces\n** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],\n** [sqlite3_prepare16_v2()] or the older legacy\n** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"vX\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],\n** sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]\n** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"vX\" interfaces is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n** METHOD: sqlite3_stmt\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result\n** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result\n** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result\n** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result\n** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result\n** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result\n** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an \n** [sqlite3_value|unprotected sqlite3_value] object.\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT result in bytes\n** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default\n** datatype of the result\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)\n** each return the value of a result column in a specific data format.  If\n** the result column is not initially in the requested format (for example,\n** if the query returns an integer but the sqlite3_column_text() interface\n** is used to extract the value) then an automatic type conversion is performed.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].\n** The return value of sqlite3_column_type() can be used to decide which\n** of the first six interface should be used to extract the column value.\n** The value returned by sqlite3_column_type() is only meaningful if no\n** automatic type conversions have occurred for the value in question.  \n** After a type conversion, the result of calling sqlite3_column_type()\n** is undefined, though harmless.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()\n** or sqlite3_column_bytes16() interfaces can be used to determine the size\n** of that BLOB or string.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  In a multithreaded environment,\n** an unprotected sqlite3_value object may only be used safely with\n** [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], the behavior is not threadsafe.\n** Hence, the sqlite3_column_value() interface\n** is normally only useful within the implementation of \n** [application-defined SQL functions] or [virtual tables], not within\n** top-level application code.\n**\n** The these routines may attempt to convert the datatype of the result.\n** ^For example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB\n** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do not pass the pointers returned\n** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** ^(If a memory allocation error occurs during the evaluation of any\n** of these routines, a default value is returned.  The default value\n** is either the integer 0, the floating point number 0.0, or a NULL\n** pointer.  Subsequent calls to [sqlite3_errcode()] will return\n** [SQLITE_NOMEM].)^\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n** DESTRUCTOR: sqlite3_stmt\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n** METHOD: sqlite3_stmt\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n** METHOD: sqlite3\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates.  The only differences between\n** these routines are the text encoding expected for\n** the second parameter (the name of the function being created)\n** and the presence or absence of a destructor callback for\n** the application data pointer.\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  The application should set this parameter to\n** [SQLITE_UTF16LE] if the function implementation invokes \n** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the\n** implementation invokes [sqlite3_value_text16be()] on an input, or\n** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]\n** otherwise.  ^The same SQL function may be registered multiple times using\n** different preferred text encodings, with different implementations for\n** each encoding.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n**\n** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]\n** to signal that the function will always return the same result given\n** the same inputs within a single SQL statement.  Most SQL functions are\n** deterministic.  The built-in [random()] SQL function is an example of a\n** function that is not deterministic.  The SQLite query planner is able to\n** perform additional optimizations on deterministic functions, so use\n** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,\n** then it is destructor for the application data pointer. \n** The destructor is invoked when the function is deleted, either by being\n** overloaded or when the database connection closes.)^\n** ^The destructor is also invoked if the call to\n** sqlite3_create_function_v2() fails.\n** ^When the destructor callback of the tenth parameter is invoked, it\n** is passed a single argument which is a copy of the application data \n** pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */\n#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */\n#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* Deprecated */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Function Flags\n**\n** These constants may be ORed together with the \n** [SQLITE_UTF8 | preferred text encoding] as the fourth argument\n** to [sqlite3_create_function()], [sqlite3_create_function16()], or\n** [sqlite3_create_function_v2()].\n*/\n#define SQLITE_DETERMINISTIC    0x800\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To encourage programmers to avoid\n** these functions, we will not explain what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Values\n** METHOD: sqlite3_value\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value\n** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value\n** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value\n** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value\n** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value\n** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value\n** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in\n** the native byteorder\n** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value\n** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT in bytes\n** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default\n** datatype of the value\n** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** These routines extract type, size, and content information from\n** [protected sqlite3_value] objects.  Protected sqlite3_value objects\n** are used to pass parameter information into implementation of\n** [application-defined SQL functions] and [virtual tables].\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** is not threadsafe.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^If [sqlite3_value] object V was initialized \n** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]\n** and if X and Y are strings that compare equal according to strcmp(X,Y),\n** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,\n** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() \n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^(The sqlite3_value_type(V) interface returns the\n** [SQLITE_INTEGER | datatype code] for the initial datatype of the\n** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^\n** Other interfaces might change the datatype for an sqlite3_value object.\n** For example, if the datatype is initially SQLITE_INTEGER and\n** sqlite3_value_text(V) is called to extract a text value for that\n** integer, then subsequent calls to sqlite3_value_type(V) might return\n** SQLITE_TEXT.  Whether or not a persistent internal datatype conversion\n** occurs is undefined and may change from one release of SQLite to the next.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\n\n/*\n** CAPI3REF: Finding The Subtype Of SQL Values\n** METHOD: sqlite3_value\n**\n** The sqlite3_value_subtype(V) function returns the subtype for\n** an [application-defined SQL function] argument V.  The subtype\n** information can be used to pass a limited amount of context from\n** one SQL function to another.  Use the [sqlite3_result_subtype()]\n** routine to set the subtype for the return value of an SQL function.\n*/\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);\n\n/*\n** CAPI3REF: Copy And Free SQL Values\n** METHOD: sqlite3_value\n**\n** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]\n** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned\n** is a [protected sqlite3_value] object even if the input is not.\n** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a\n** memory allocation fails.\n**\n** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object\n** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer\n** then sqlite3_value_free(V) is a harmless no-op.\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*);\nSQLITE_API void sqlite3_value_free(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n** METHOD: sqlite3_context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n** METHOD: sqlite3_context\n**\n** These functions may be used by (non-aggregate) SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved.  An example\n** of where this might be useful is in a regular-expression matching\n** function. The compiled version of the regular expression can be stored as\n** metadata associated with the pattern string.  \n** Then as long as the pattern string remains the same,\n** the compiled regular expression can be reused on multiple\n** invocations of the same function.\n**\n** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument\n** value to the application-defined function.  ^N is zero for the left-most\n** function argument.  ^If there is no metadata\n** associated with the function argument, the sqlite3_get_auxdata(C,N) interface\n** returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th\n** argument of the application-defined function.  ^Subsequent\n** calls to sqlite3_get_auxdata(C,N) return P from the most recent\n** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or\n** NULL if the metadata has been discarded.\n** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,\n** SQLite will invoke the destructor function X with parameter P exactly\n** once, when the metadata is discarded.\n** SQLite is free to discard the metadata at any time, including: <ul>\n** <li> ^(when the corresponding function parameter changes)^, or\n** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the\n**      SQL statement)^, or\n** <li> ^(when sqlite3_set_auxdata() is invoked again on the same\n**       parameter)^, or\n** <li> ^(during the original sqlite3_set_auxdata() call when a memory \n**      allocation error occurs.)^ </ul>\n**\n** Note the last bullet in particular.  The destructor X in \n** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the\n** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()\n** should be called near the end of the function implementation and the\n** function implementation should not make any use of P after\n** sqlite3_set_auxdata() has been called.\n**\n** ^(In practice, metadata is preserved between function calls for\n** function parameters that are compile-time constants, including literal\n** values and [parameters] and expressions composed from the same.)^\n**\n** The value of the N parameter to these interfaces should be non-negative.\n** Future enhancements may make use of negative N values to define new\n** kinds of function caching behavior.\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n** METHOD: sqlite3_context\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)\n** interfaces set the result of the application-defined function to be\n** a BLOB containing all zero bytes and N bytes in size.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^The sqlite3_result_text64() interface sets the return value of an\n** application-defined function to be a text string in an encoding\n** specified by the fifth (and last) parameter, which must be one\n** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy of the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an\n** SQL NULL value, just like [sqlite3_result_null(C)], except that it\n** also associates the host-language pointer P or type T with that \n** NULL value such that the pointer can be retrieved within an\n** [application-defined SQL function] using [sqlite3_value_pointer()].\n** ^If the D parameter is not NULL, then it is a pointer to a destructor\n** for the P parameter.  ^SQLite invokes D with P as its only argument\n** when SQLite is finished with P.  The T parameter should be a static\n** string and preferably a string literal. The sqlite3_result_pointer()\n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,\n                           sqlite3_uint64,void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,\n                           void(*)(void*), unsigned char encoding);\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);\n\n\n/*\n** CAPI3REF: Setting The Subtype Of An SQL Function\n** METHOD: sqlite3_context\n**\n** The sqlite3_result_subtype(C,T) function causes the subtype of\n** the result from the [application-defined SQL function] with \n** [sqlite3_context] C to be the value T.  Only the lower 8 bits \n** of the subtype T are preserved in current versions of SQLite;\n** higher order bits are discarded.\n** The number of subtype bytes preserved by SQLite might increase\n** in future releases of SQLite.\n*/\nSQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n** METHOD: sqlite3\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n** METHOD: sqlite3\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\nSQLITE_API int sqlite3_key_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\nSQLITE_API int sqlite3_rekey_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** Applications are strongly discouraged from using this global variable.\n** It is required to set a temporary folder on Windows Runtime (WinRT).\n** But for all other platforms, it is highly recommended that applications\n** neither read nor write this variable.  This global variable is a relic\n** that exists for backwards compatibility of legacy applications and should\n** be avoided in new projects.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n** Except when requested by the [temp_store_directory pragma], SQLite\n** does not free the memory that sqlite3_temp_directory points to.  If\n** the application wants that memory to be freed, it must do\n** so itself, taking care to only do so after all [database connection]\n** objects have been destroyed.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n** METHOD: sqlite3\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted in\n** a [rowid table].\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted in a rowid table.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.\n**\n** ^In the current implementation, the update hook\n** is not invoked when conflicting rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],\n** and [sqlite3_preupdate_hook()] interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). \n** In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0\n** and will always return SQLITE_MISUSE. On those systems, \n** shared cache mode should be enabled per-database connection via \n** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is in effect even\n** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), \n** the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n** METHOD: sqlite3\n**\n** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns\n** information about column C of table T in database D\n** on [database connection] X.)^  ^The sqlite3_table_column_metadata()\n** interface returns SQLITE_OK and fills in the non-NULL pointers in\n** the final five arguments with appropriate values if the specified\n** column exists.  ^The sqlite3_table_column_metadata() interface returns\n** SQLITE_ERROR and if the specified column does not exist.\n** ^If the column-name parameter to sqlite3_table_column_metadata() is a\n** NULL pointer, then this routine simply checks for the existence of the\n** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it\n** does not.  If the table name parameter T in a call to\n** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is\n** undefined behavior.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^(The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL.)^ ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and the table \n** is not a [WITHOUT ROWID] table and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** [INTEGER PRIMARY KEY] column, then the outputs\n** for the [rowid] are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^This function causes all database schemas to be read from disk and\n** parsed, if that has not already been done, and returns an error if\n** any errors are encountered while loading the schema.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n** METHOD: sqlite3\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] or\n** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)\n** prior to calling this API,\n** otherwise an error will be returned.\n**\n** <b>Security warning:</b> It is recommended that the \n** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this\n** interface.  The use of the [sqlite3_enable_load_extension()] interface\n** should be avoided.  This will keep the SQL function [load_extension()]\n** disabled and prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n** METHOD: sqlite3\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n**\n** ^This interface enables or disables both the C-API\n** [sqlite3_load_extension()] and the SQL function [load_extension()].\n** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)\n** to enable or disable only the C-API.)^\n**\n** <b>Security warning:</b> It is recommended that extension loading\n** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method\n** rather than this interface, so the [load_extension()] SQL function\n** remains disabled. This will prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects an integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()]\n** and [sqlite3_cancel_auto_extension()]\n*/\nSQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Cancel Automatic Extension Loading\n**\n** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the\n** initialization routine X that was registered using a prior call to\n** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]\n** routine returns 1 if initialization routine X was successfully \n** unregistered and it returns 0 if X was not on the list of initialization\n** routines.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The colUsed field indicates which columns of the virtual table may be\n** required by the current scan. Virtual table columns are numbered from\n** zero in the order in which they appear within the CREATE TABLE statement\n** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),\n** the corresponding bit is set within the colUsed mask if the column may be\n** required by SQLite. If the table has at least 64 columns and any column\n** to the right of the first 63 is required, then bit 63 of colUsed is also\n** set. In other words, column iCol may be required if the expression\n** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to \n** non-zero.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of a particular\n** strategy. A cost of N indicates that the cost of the strategy is similar\n** to a linear scan of an SQLite table with N rows. A cost of log(N) \n** indicates that the expense of the operation is similar to that of a\n** binary search on a unique indexed field of an SQLite table with N rows.\n**\n** ^The estimatedRows value is an estimate of the number of rows that\n** will be returned by the strategy.\n**\n** The xBestIndex method may optionally populate the idxFlags field with a \n** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -\n** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite\n** assumes that the strategy may visit at most one row. \n**\n** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then\n** SQLite also assumes that if a call to the xUpdate() method is made as\n** part of the same statement to delete or update a virtual table row and the\n** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback\n** any database changes. In other words, if the xUpdate() returns\n** SQLITE_CONSTRAINT, the database contents must be exactly as they were\n** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not\n** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by\n** the xUpdate method are automatically rolled back by SQLite.\n**\n** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info\n** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). \n** If a virtual table extension is\n** used with an SQLite version earlier than 3.8.2, the results of attempting \n** to read or write the estimatedRows field are undefined (but are likely \n** to included crashing the application). The estimatedRows field should\n** therefore only be used if [sqlite3_libversion_number()] returns a\n** value greater than or equal to 3008002. Similarly, the idxFlags field\n** was added for [version 3.9.0] ([dateof:3.9.0]). \n** It may therefore only be used if\n** sqlite3_libversion_number() returns a value greater than or equal to\n** 3009000.\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column constrained.  -1 for ROWID */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;           /* Estimated cost of using this index */\n  /* Fields below are only available in SQLite 3.8.2 and later */\n  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */\n  /* Fields below are only available in SQLite 3.9.0 and later */\n  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */\n  /* Fields below are only available in SQLite 3.10.0 and later */\n  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */\n};\n\n/*\n** CAPI3REF: Virtual Table Scan Flags\n*/\n#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ         2\n#define SQLITE_INDEX_CONSTRAINT_GT         4\n#define SQLITE_INDEX_CONSTRAINT_LE         8\n#define SQLITE_INDEX_CONSTRAINT_LT        16\n#define SQLITE_INDEX_CONSTRAINT_GE        32\n#define SQLITE_INDEX_CONSTRAINT_MATCH     64\n#define SQLITE_INDEX_CONSTRAINT_LIKE      65\n#define SQLITE_INDEX_CONSTRAINT_GLOB      66\n#define SQLITE_INDEX_CONSTRAINT_REGEXP    67\n#define SQLITE_INDEX_CONSTRAINT_NE        68\n#define SQLITE_INDEX_CONSTRAINT_ISNOT     69\n#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70\n#define SQLITE_INDEX_CONSTRAINT_ISNULL    71\n#define SQLITE_INDEX_CONSTRAINT_IS        72\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n** METHOD: sqlite3\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* Number of open cursors */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n** METHOD: sqlite3\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_blob\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^(Parameter zDb is not the filename that contains the database, but \n** rather the symbolic name of the database. For attached databases, this is\n** the name that appears after the AS keyword in the [ATTACH] statement.\n** For the main database file, the database name is \"main\". For TEMP\n** tables, the database name is \"temp\".)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If the flags parameter is zero, the BLOB is opened for\n** read-only access.\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored\n** in *ppBlob. Otherwise an [error code] is returned and, unless the error\n** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided\n** the API is not misused, it is always safe to call [sqlite3_blob_close()] \n** on *ppBlob after this function it returns.\n**\n** This function fails with SQLITE_ERROR if any of the following are true:\n** <ul>\n**   <li> ^(Database zDb does not exist)^, \n**   <li> ^(Table zTable does not exist within database zDb)^, \n**   <li> ^(Table zTable is a WITHOUT ROWID table)^, \n**   <li> ^(Column zColumn does not exist)^,\n**   <li> ^(Row iRow is not present in the table)^,\n**   <li> ^(The specified column of row iRow contains a value that is not\n**         a TEXT or BLOB value)^,\n**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE \n**         constraint and the blob is being opened for read/write access)^,\n**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, \n**         column zColumn is part of a [child key] definition and the blob is\n**         being opened for read/write access)^.\n** </ul>\n**\n** ^Unless it returns SQLITE_MISUSE, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** A BLOB referenced by sqlite3_blob_open() may be read using the\n** [sqlite3_blob_read()] interface and modified by using\n** [sqlite3_blob_write()].  The [BLOB handle] can be moved to a\n** different row of the same table using the [sqlite3_blob_reopen()]\n** interface.  However, the column, table, or database of a [BLOB handle]\n** cannot be changed after the [BLOB handle] is opened.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function may be used to create a \n** zero-filled blob to read or write using the incremental-blob interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n**\n** See also: [sqlite3_blob_close()],\n** [sqlite3_blob_reopen()], [sqlite3_blob_read()],\n** [sqlite3_blob_bytes()], [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n** METHOD: sqlite3_blob\n**\n** ^This function is used to move an existing [BLOB handle] so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing [BLOB handle] to a new row is\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n** DESTRUCTOR: sqlite3_blob\n**\n** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed\n** unconditionally.  Even if this routine returns an error code, the \n** handle is still closed.)^\n**\n** ^If the blob handle being closed was opened for read-write access, and if\n** the database is in auto-commit mode and there are no other open read-write\n** blob handles or active write statements, the current transaction is\n** committed. ^If an error occurs while committing the transaction, an error\n** code is returned and the transaction rolled back.\n**\n** Calling this function with an argument that is not a NULL pointer or an\n** open blob handle results in undefined behaviour. ^Calling this routine \n** with a null pointer (such as would be returned by a failed call to \n** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function\n** is passed a valid open blob handle, the values returned by the \n** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n** METHOD: sqlite3_blob\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.)^\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n** ^Unless SQLITE_MISUSE is returned, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written. The size of the \n** BLOB (and hence the maximum value of N+iOffset) can be determined \n** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less \n** than zero [SQLITE_ERROR] is returned and no data is written.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>\n**\n** The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()\n** routine returns NULL if it is unable to allocate the requested\n** mutex.  The argument to sqlite3_mutex_alloc() must one of these\n** integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Nine static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^For the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  Attempting to deallocate a static\n** mutex results in undefined behavior.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases, the\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  If the same thread tries to enter any mutex other\n** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY. The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable \n** behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the application has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the application\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_randomness() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */\n#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */\n#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */\n#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n** METHOD: sqlite3\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  ^The SQLITE_FCNTL_FILE_POINTER\n** case is a short-circuit path which does not actually invoke the\n** underlying sqlite3_io_methods.xFileControl method.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [SQLITE_FCNTL_LOCKSTATE]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */\n#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19\n#define SQLITE_TESTCTRL_NEVER_CORRUPT           20\n#define SQLITE_TESTCTRL_VDBE_COVERAGE           21\n#define SQLITE_TESTCTRL_BYTEORDER               22\n#define SQLITE_TESTCTRL_ISINIT                  23\n#define SQLITE_TESTCTRL_SORTER_MMAP             24\n#define SQLITE_TESTCTRL_IMPOSTER                25\n#define SQLITE_TESTCTRL_LAST                    25\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^These interfaces are used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() and sqlite3_status64() routines return\n** SQLITE_OK on success and a non-zero [error code] on failure.\n**\n** If either the current value or the highwater mark is too large to\n** be represented by a 32-bit integer, then the values returned by\n** sqlite3_status() are undefined.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>The *pHighwater parameter records the deepest parser stack. \n** The *pCurrent value is undefined.  The *pHighwater value is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3  /* NOT USED */\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n** METHOD: sqlite3\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] \n** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>\n** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a\n** pager cache is shared between two or more connections the bytes of heap\n** memory used by that pager cache is divided evenly between the attached\n** connections.)^  In other words, if none of the pager caches associated\n** with the database connection are shared, this request returns the same\n** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are\n** shared, the value returned by this call will be smaller than that returned\n** by DBSTATUS_CACHE_USED. ^The highwater mark associated with\n** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>\n** <dd>This parameter returns zero for the current value if and only if\n** all foreign key constraints (deferred or immediate) have been\n** resolved.)^  ^The highwater mark is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_DEFERRED_FKS        10\n#define SQLITE_DBSTATUS_CACHE_USED_SHARED   11\n#define SQLITE_DBSTATUS_MAX                 11   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n** METHOD: sqlite3_stmt\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n**\n** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>\n** <dd>^This is the number of virtual machine operations executed\n** by the prepared statement if that number is less than or equal\n** to 2147483647.  The number of virtual machine operations can be \n** used as a proxy for the total work done by the prepared statement.\n** If the number of virtual machine operations exceeds 2147483647\n** then the value returned by this statement status code is undefined.\n**\n** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>\n** <dd>^This is the number of times that the prepare statement has been\n** automatically regenerated due to schema changes or change to \n** [bound parameters] that might affect the query plan.\n**\n** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>\n** <dd>^This is the number of times that the prepared statement has\n** been run.  A single \"run\" for the purposes of this counter is one\n** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].\n** The counter is incremented on the first [sqlite3_step()] call of each\n** cycle.\n**\n** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>\n** <dd>^This is the approximate number of bytes of heap memory\n** used to store the prepared statement.  ^This value is not actually\n** a counter, and so the resetFlg parameter to sqlite3_stmt_status()\n** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.\n** </dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n#define SQLITE_STMTSTATUS_VM_STEP           4\n#define SQLITE_STMTSTATUS_REPREPARE         5\n#define SQLITE_STMTSTATUS_RUN               6\n#define SQLITE_STMTSTATUS_MEMUSED           99\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^A call to sqlite3_backup_init() will fail, returning NULL, if \n** there is already a read or read-write transaction open on the \n** destination database.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^The sqlite3_backup_remaining() routine returns the number of pages still\n** to be backed up at the conclusion of the most recent sqlite3_backup_step().\n** ^The sqlite3_backup_pagecount() routine returns the total number of pages\n** in the source database at the conclusion of the most recent\n** sqlite3_backup_step().\n** ^(The values returned by these functions are only updated by\n** sqlite3_backup_step(). If the source database is modified in a way that\n** changes the size of the source database or the number of pages remaining,\n** those changes are not reflected in the output of sqlite3_backup_pagecount()\n** and sqlite3_backup_remaining() until after the next\n** sqlite3_backup_step().)^\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n** METHOD: sqlite3\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if\n** string X matches the [GLOB] pattern P.\n** ^The definition of [GLOB] pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function\n** is case sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strlike()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: String LIKE Matching\n*\n** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if\n** string X matches the [LIKE] pattern P with escape character E.\n** ^The definition of [LIKE] pattern matching used in\n** [sqlite3_strlike(P,X,E)] is the same as for the \"X LIKE P ESCAPE E\"\n** operator in the SQL dialect understood by SQLite.  ^For \"X LIKE P\" without\n** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.\n** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case\n** insensitive - equivalent upper and lower case ASCII characters match\n** one another.\n**\n** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though\n** only ASCII characters are case folded.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strglob()].\n*/\nSQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** is invoked each time data is committed to a database in wal mode.\n**\n** ^(The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released)^, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Checkpoints initiated by this mechanism are\n** [sqlite3_wal_checkpoint_v2|PASSIVE].\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to\n** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^\n**\n** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the \n** [write-ahead log] for database X on [database connection] D to be\n** transferred into the database file and for the write-ahead log to\n** be reset.  See the [checkpointing] documentation for addition\n** information.\n**\n** This interface used to be the only way to cause a checkpoint to\n** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]\n** interface was added.  This interface is retained for backwards\n** compatibility and as a convenience for applications that need to manually\n** start a callback but which do not need the full power (and corresponding\n** complication) of [sqlite3_wal_checkpoint_v2()].\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint\n** operation on database X of [database connection] D in mode M.  Status\n** information is written back into integers pointed to by L and C.)^\n** ^(The M parameter must be a valid [checkpoint mode]:)^\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   ^Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish, then sync the database file if all frames \n**   in the log were checkpointed. ^The [busy-handler callback]\n**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  \n**   ^On the other hand, passive mode might leave the checkpoint unfinished\n**   if there are concurrent readers or writers.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   ^This mode blocks (it invokes the\n**   [sqlite3_busy_handler|busy-handler callback]) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. ^It then checkpoints all frames in the log file and syncs the\n**   database file. ^This mode blocks new database writers while it is pending,\n**   but new database readers are allowed to continue unimpeded.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition\n**   that after checkpointing the log file it blocks (calls the \n**   [busy-handler callback])\n**   until all readers are reading from the database file only. ^This ensures \n**   that the next writer will restart the log file from the beginning.\n**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new\n**   database writer attempts while it is pending, but does not impede readers.\n**\n** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the\n**   addition that it also truncates the log file to zero bytes just prior\n**   to a successful return.\n** </dl>\n**\n** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file or to -1 if the checkpoint could not run because\n** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not\n** NULL,then *pnCkpt is set to the total number of checkpointed frames in the\n** log file (including any that were already checkpointed before the function\n** was called) or to -1 if the checkpoint could not run due to an error or\n** because the database is not in WAL mode. ^Note that upon successful\n** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been\n** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n**\n** ^All calls obtain an exclusive \"checkpoint\" lock on the database file. ^If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the \n** exclusive \"writer\" lock on the database file. ^If the writer lock cannot be\n** obtained immediately, and a busy-handler is configured, it is invoked and\n** the writer lock retried until either the busy-handler returns 0 or the lock\n** is successfully obtained. ^The busy-handler is also invoked while waiting for\n** database readers as described above. ^If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. ^SQLITE_BUSY is returned in this case.\n**\n** ^If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases [attached] to \n** [database connection] db.  In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. ^If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned at the end. ^If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code is returned to the caller immediately. ^If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** ^If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n**\n** ^Unless it returns SQLITE_MISUSE,\n** the sqlite3_wal_checkpoint_v2() interface\n** sets the error information that is queried by\n** [sqlite3_errcode()] and [sqlite3_errmsg()].\n**\n** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface\n** from SQL.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint Mode Values\n** KEYWORDS: {checkpoint mode}\n**\n** These constants define all valid values for the \"checkpoint mode\" passed\n** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.\n** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the\n** meaning of each of these checkpoint modes.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */\n#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */\n#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */\n#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Conflict resolution modes\n** KEYWORDS: {conflict resolution mode}\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status Opcodes\n** KEYWORDS: {scanstatus options}\n**\n** The following constants can be used for the T parameter to the\n** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a\n** different metric for sqlite3_stmt_scanstatus() to return.\n**\n** When the value returned to V is a string, space to hold that string is\n** managed by the prepared statement S and will be automatically freed when\n** S is finalized.\n**\n** <dl>\n** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be\n** set to the total number of times that the X-th loop has run.</dd>\n**\n** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set\n** to the total number of rows examined by all iterations of the X-th loop.</dd>\n**\n** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>\n** <dd>^The \"double\" variable pointed to by the T parameter will be set to the\n** query planner's estimate for the average number of rows output from each\n** iteration of the X-th loop.  If the query planner's estimates was accurate,\n** then this value will approximate the quotient NVISIT/NLOOP and the\n** product of this value for all prior loops with the same SELECTID will\n** be the NLOOP value for the current loop.\n**\n** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the name of the index or table\n** used for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]\n** description for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>\n** <dd>^The \"int\" variable pointed to by the T parameter will be set to the\n** \"select-id\" for the X-th loop.  The select-id identifies which query or\n** subquery the loop is part of.  The main query has a select-id of zero.\n** The select-id is the same value as is output in the first column\n** of an [EXPLAIN QUERY PLAN] query.\n** </dl>\n*/\n#define SQLITE_SCANSTAT_NLOOP    0\n#define SQLITE_SCANSTAT_NVISIT   1\n#define SQLITE_SCANSTAT_EST      2\n#define SQLITE_SCANSTAT_NAME     3\n#define SQLITE_SCANSTAT_EXPLAIN  4\n#define SQLITE_SCANSTAT_SELECTID 5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status\n** METHOD: sqlite3_stmt\n**\n** This interface returns information about the predicted and measured\n** performance for pStmt.  Advanced applications can use this\n** interface to compare the predicted and the measured performance and\n** issue warnings and/or rerun [ANALYZE] if discrepancies are found.\n**\n** Since this interface is expected to be rarely used, it is only\n** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]\n** compile-time option.\n**\n** The \"iScanStatusOp\" parameter determines which status information to return.\n** The \"iScanStatusOp\" must be one of the [scanstatus options] or the behavior\n** of this interface is undefined.\n** ^The requested measurement is written into a variable pointed to by\n** the \"pOut\" parameter.\n** Parameter \"idx\" identifies the specific loop to retrieve statistics for.\n** Loops are numbered starting from zero. ^If idx is out of range - less than\n** zero or greater than or equal to the total number of loops used to implement\n** the statement - a non-zero value is returned and the variable that pOut\n** points to is unchanged.\n**\n** ^Statistics might not be available for all loops in all statements. ^In cases\n** where there exist loops with no available statistics, this function behaves\n** as if the loop did not exist - it returns non-zero and leave the variable\n** that pOut points to unchanged.\n**\n** See also: [sqlite3_stmt_scanstatus_reset()]\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */\n  int idx,                  /* Index of loop to report on */\n  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */\n  void *pOut                /* Result written here */\n);     \n\n/*\n** CAPI3REF: Zero Scan-Status Counters\n** METHOD: sqlite3_stmt\n**\n** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.\n**\n** This API is only available if the library is built with pre-processor\n** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Flush caches to disk mid-transaction\n**\n** ^If a write-transaction is open on [database connection] D when the\n** [sqlite3_db_cacheflush(D)] interface invoked, any dirty\n** pages in the pager-cache that are not currently in use are written out \n** to disk. A dirty page may be in use if a database cursor created by an\n** active SQL statement is reading from it, or if it is page 1 of a database\n** file (page 1 is always \"in use\").  ^The [sqlite3_db_cacheflush(D)]\n** interface flushes caches for all schemas - \"main\", \"temp\", and\n** any [attached] databases.\n**\n** ^If this function needs to obtain extra database locks before dirty pages \n** can be flushed to disk, it does so. ^If those locks cannot be obtained \n** immediately and there is a busy-handler callback configured, it is invoked\n** in the usual manner. ^If the required lock still cannot be obtained, then\n** the database is skipped and an attempt made to flush any dirty pages\n** belonging to the next (if any) database. ^If any databases are skipped\n** because locks cannot be obtained, but no other error occurs, this\n** function returns SQLITE_BUSY.\n**\n** ^If any other error occurs while flushing dirty pages to disk (for\n** example an IO error or out-of-memory condition), then processing is\n** abandoned and an SQLite [error code] is returned to the caller immediately.\n**\n** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.\n**\n** ^This function does not set the database handle error code or message\n** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3*);\n\n/*\n** CAPI3REF: The pre-update hook.\n**\n** ^These interfaces are only available if SQLite is compiled using the\n** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.\n**\n** ^The [sqlite3_preupdate_hook()] interface registers a callback function\n** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation\n** on a database table.\n** ^At most one preupdate hook may be registered at a time on a single\n** [database connection]; each call to [sqlite3_preupdate_hook()] overrides\n** the previous setting.\n** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]\n** with a NULL pointer as the second parameter.\n** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as\n** the first parameter to callbacks.\n**\n** ^The preupdate hook only fires for changes to real database tables; the\n** preupdate hook is not invoked for changes to [virtual tables] or to\n** system tables like sqlite_master or sqlite_stat1.\n**\n** ^The second parameter to the preupdate callback is a pointer to\n** the [database connection] that registered the preupdate hook.\n** ^The third parameter to the preupdate callback is one of the constants\n** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the\n** kind of update operation that is about to occur.\n** ^(The fourth parameter to the preupdate callback is the name of the\n** database within the database connection that is being modified.  This\n** will be \"main\" for the main database or \"temp\" for TEMP tables or \n** the name given after the AS keyword in the [ATTACH] statement for attached\n** databases.)^\n** ^The fifth parameter to the preupdate callback is the name of the\n** table that is being modified.\n**\n** For an UPDATE or DELETE operation on a [rowid table], the sixth\n** parameter passed to the preupdate callback is the initial [rowid] of the \n** row being modified or deleted. For an INSERT operation on a rowid table,\n** or any operation on a WITHOUT ROWID table, the value of the sixth \n** parameter is undefined. For an INSERT or UPDATE on a rowid table the\n** seventh parameter is the final rowid value of the row being inserted\n** or updated. The value of the seventh parameter passed to the callback\n** function is not defined for operations on WITHOUT ROWID tables, or for\n** INSERT operations on rowid tables.\n**\n** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],\n** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces\n** provide additional information about a preupdate event. These routines\n** may only be called from within a preupdate callback.  Invoking any of\n** these routines from outside of a preupdate callback or with a\n** [database connection] pointer that is different from the one supplied\n** to the preupdate callback results in undefined and probably undesirable\n** behavior.\n**\n** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns\n** in the row that is being inserted, updated, or deleted.\n**\n** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row before it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE\n** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row after it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE\n** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate\n** callback was invoked as a result of a direct insert, update, or delete\n** operation; or 1 for inserts, updates, or deletes invoked by top-level \n** triggers; or 2 for changes resulting from triggers called by top-level\n** triggers; and so forth.\n**\n** See also:  [sqlite3_update_hook()]\n*/\n#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,\n  void(*xPreUpdate)(\n    void *pCtx,                   /* Copy of third arg to preupdate_hook() */\n    sqlite3 *db,                  /* Database handle */\n    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */\n    char const *zDb,              /* Database name */\n    char const *zName,            /* Table name */\n    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */\n    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */\n  ),\n  void*\n);\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);\n#endif\n\n/*\n** CAPI3REF: Low-level system error code\n**\n** ^Attempt to return the underlying operating system error code or error\n** number that caused the most recent I/O error or failure to open a file.\n** The return value is OS-dependent.  For example, on unix systems, after\n** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be\n** called to get back the underlying \"errno\" that caused the problem, such\n** as ENOSPC, EAUTH, EISDIR, and so forth.  \n*/\nSQLITE_API int sqlite3_system_errno(sqlite3*);\n\n/*\n** CAPI3REF: Database Snapshot\n** KEYWORDS: {snapshot} {sqlite3_snapshot}\n** EXPERIMENTAL\n**\n** An instance of the snapshot object records the state of a [WAL mode]\n** database for some specific point in history.\n**\n** In [WAL mode], multiple [database connections] that are open on the\n** same database file can each be reading a different historical version\n** of the database file.  When a [database connection] begins a read\n** transaction, that connection sees an unchanging copy of the database\n** as it existed for the point in time when the transaction first started.\n** Subsequent changes to the database from other connections are not seen\n** by the reader until a new read transaction is started.\n**\n** The sqlite3_snapshot object records state information about an historical\n** version of the database file so that it is possible to later open a new read\n** transaction that sees that historical version of the database rather than\n** the most recent version.\n**\n** The constructor for this object is [sqlite3_snapshot_get()].  The\n** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer\n** to an historical snapshot (if possible).  The destructor for \n** sqlite3_snapshot objects is [sqlite3_snapshot_free()].\n*/\ntypedef struct sqlite3_snapshot {\n  unsigned char hidden[48];\n} sqlite3_snapshot;\n\n/*\n** CAPI3REF: Record A Database Snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a\n** new [sqlite3_snapshot] object that records the current state of\n** schema S in database connection D.  ^On success, the\n** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly\n** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.\n** If there is not already a read-transaction open on schema S when\n** this function is called, one is opened automatically. \n**\n** The following must be true for this function to succeed. If any of\n** the following statements are false when sqlite3_snapshot_get() is\n** called, SQLITE_ERROR is returned. The final value of *P is undefined\n** in this case. \n**\n** <ul>\n**   <li> The database handle must be in [autocommit mode].\n**\n**   <li> Schema S of [database connection] D must be a [WAL mode] database.\n**\n**   <li> There must not be a write transaction open on schema S of database\n**        connection D.\n**\n**   <li> One or more transactions must have been written to the current wal\n**        file since it was created on disk (by any connection). This means\n**        that a snapshot cannot be taken on a wal mode database with no wal \n**        file immediately after it is first opened. At least one transaction\n**        must be written to it first.\n** </ul>\n**\n** This function may also return SQLITE_NOMEM.  If it is called with the\n** database handle in autocommit mode but fails for some other reason, \n** whether or not a read transaction is opened on schema S is undefined.\n**\n** The [sqlite3_snapshot] object returned from a successful call to\n** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]\n** to avoid a memory leak.\n**\n** The [sqlite3_snapshot_get()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot **ppSnapshot\n);\n\n/*\n** CAPI3REF: Start a read transaction on an historical snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a\n** read transaction for schema S of\n** [database connection] D such that the read transaction\n** refers to historical [snapshot] P, rather than the most\n** recent change to the database.\n** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success\n** or an appropriate [error code] if it fails.\n**\n** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be\n** the first operation following the [BEGIN] that takes the schema S\n** out of [autocommit mode].\n** ^In other words, schema S must not currently be in\n** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the\n** database connection D must be out of [autocommit mode].\n** ^A [snapshot] will fail to open if it has been overwritten by a\n** [checkpoint].\n** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the\n** database connection D does not know that the database file for\n** schema S is in [WAL mode].  A database connection might not know\n** that the database file is in [WAL mode] if there has been no prior\n** I/O on that database connection, or if the database entered [WAL mode] \n** after the most recent I/O on the database connection.)^\n** (Hint: Run \"[PRAGMA application_id]\" against a newly opened\n** database connection in order to make it ready to use snapshots.)\n**\n** The [sqlite3_snapshot_open()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot *pSnapshot\n);\n\n/*\n** CAPI3REF: Destroy a snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.\n** The application must eventually free every [sqlite3_snapshot] object\n** using this routine to avoid a memory leak.\n**\n** The [sqlite3_snapshot_free()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);\n\n/*\n** CAPI3REF: Compare the ages of two snapshot handles.\n** EXPERIMENTAL\n**\n** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages\n** of two valid snapshot handles. \n**\n** If the two snapshot handles are not associated with the same database \n** file, the result of the comparison is undefined. \n**\n** Additionally, the result of the comparison is only valid if both of the\n** snapshot handles were obtained by calling sqlite3_snapshot_get() since the\n** last time the wal file was deleted. The wal file is deleted when the\n** database is changed back to rollback mode or when the number of database\n** clients drops to zero. If either snapshot handle was obtained before the \n** wal file was last deleted, the value returned by this function \n** is undefined.\n**\n** Otherwise, this API returns a negative value if P1 refers to an older\n** snapshot than P2, zero if the two handles refer to the same database\n** snapshot, and a positive value if P1 is a newer snapshot than P2.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(\n  sqlite3_snapshot *p1,\n  sqlite3_snapshot *p2\n);\n\n/*\n** CAPI3REF: Recover snapshots from a wal file\n** EXPERIMENTAL\n**\n** If all connections disconnect from a database file but do not perform\n** a checkpoint, the existing wal file is opened along with the database\n** file the next time the database is opened. At this point it is only\n** possible to successfully call sqlite3_snapshot_open() to open the most\n** recent snapshot of the database (the one at the head of the wal file),\n** even though the wal file may contain other valid snapshots for which\n** clients have sqlite3_snapshot handles.\n**\n** This function attempts to scan the wal file associated with database zDb\n** of database handle db and make all valid snapshots available to\n** sqlite3_snapshot_open(). It is an error if there is already a read\n** transaction open on the database, or if the database is not a wal mode\n** database.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#if 0\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE3_H */\n\n/******** Begin file sqlite3rtree.h *********/\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#if 0\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\ntypedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;\n\n/* The double-precision datatype used by RTree depends on the\n** SQLITE_RTREE_INT_ONLY compile-time option.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 sqlite3_rtree_dbl;\n#else\n  typedef double sqlite3_rtree_dbl;\n#endif\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  sqlite3_rtree_dbl *aParam;      /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n/*\n** Register a 2nd-generation geometry callback named zScore that can be \n** used as part of an R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,\n  const char *zQueryFunc,\n  int (*xQueryFunc)(sqlite3_rtree_query_info*),\n  void *pContext,\n  void (*xDestructor)(void*)\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the \n** argument to scored geometry callback registered using\n** sqlite3_rtree_query_callback().\n**\n** Note that the first 5 fields of this structure are identical to\n** sqlite3_rtree_geometry.  This structure is a subclass of\n** sqlite3_rtree_geometry.\n*/\nstruct sqlite3_rtree_query_info {\n  void *pContext;                   /* pContext from when function registered */\n  int nParam;                       /* Number of function parameters */\n  sqlite3_rtree_dbl *aParam;        /* value of function parameters */\n  void *pUser;                      /* callback can use this, if desired */\n  void (*xDelUser)(void*);          /* function to free pUser */\n  sqlite3_rtree_dbl *aCoord;        /* Coordinates of node or entry to check */\n  unsigned int *anQueue;            /* Number of pending entries in the queue */\n  int nCoord;                       /* Number of coordinates */\n  int iLevel;                       /* Level of current node or entry */\n  int mxLevel;                      /* The largest iLevel value in the tree */\n  sqlite3_int64 iRowid;             /* Rowid for current entry */\n  sqlite3_rtree_dbl rParentScore;   /* Score of parent node */\n  int eParentWithin;                /* Visibility of parent node */\n  int eWithin;                      /* OUT: Visiblity */\n  sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */\n  /* The following fields are only available in 3.8.11 and later */\n  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */\n};\n\n/*\n** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.\n*/\n#define NOT_WITHIN       0   /* Object completely outside of query region */\n#define PARTLY_WITHIN    1   /* Object partially overlaps query region */\n#define FULLY_WITHIN     2   /* Object fully contained within query region */\n\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n/******** End of sqlite3rtree.h *********/\n/******** Begin file sqlite3session.h *********/\n\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\nextern \"C\" {\n#endif\n\n\n/*\n** CAPI3REF: Session Object Handle\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session \n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nSQLITE_API int sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset to a database. This function attempts to update the\n** \"main\" database attached to handle db with the changes found in the\n** changeset passed via the second and third arguments.\n**\n** The fourth argument (xFilter) passed to this function is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument to this function as the first. If the \"filter\n** callback\" returns zero, then no attempt is made to apply any changes to \n** the table. Otherwise, if the return value is non-zero or the xFilter\n** argument to this function is NULL, all changes related to the table are\n** attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by this function are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nSQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\n\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#if 0\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n\n/******** End of sqlite3session.h *********/\n/******** Begin file fts5.h *********/\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n\n#if 0\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. The exception is if the table was created\n**   with the offsets=0 option specified. In this case *piOff is always\n**   set to -1.\n**\n**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) \n**   if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            In this case, when tokenizing query text, the tokenizer may \n**            provide multiple synonyms for a single term within the document.\n**            FTS5 then queries the index for each synonym individually. For\n**            example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entires in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is subsituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/******** End of fts5.h *********/\n\n/************** End of sqlite3.h *********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n/* #include \"config.h\" */\n#define SQLITECONFIG_H 1\n#endif\n\n/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/\n/************** Begin file sqliteLimit.h *************************************/\n/*\n** 2007 May 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file defines various limits of what SQLite can process.\n*/\n\n/*\n** The maximum length of a TEXT or BLOB in bytes.   This also\n** limits the size of a row in a table or index.\n**\n** The hard limit is the ability of a 32-bit signed integer\n** to count the size: 2^31-1 or 2147483647.\n*/\n#ifndef SQLITE_MAX_LENGTH\n# define SQLITE_MAX_LENGTH 1000000000\n#endif\n\n/*\n** This is the maximum number of\n**\n**    * Columns in a table\n**    * Columns in an index\n**    * Columns in a view\n**    * Terms in the SET clause of an UPDATE statement\n**    * Terms in the result set of a SELECT statement\n**    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.\n**    * Terms in the VALUES clause of an INSERT statement\n**\n** The hard upper limit here is 32676.  Most database people will\n** tell you that in a well-normalized database, you usually should\n** not have more than a dozen or so columns in any table.  And if\n** that is the case, there is no point in having more than a few\n** dozen values in any of the other situations described above.\n*/\n#ifndef SQLITE_MAX_COLUMN\n# define SQLITE_MAX_COLUMN 2000\n#endif\n\n/*\n** The maximum length of a single SQL statement in bytes.\n**\n** It used to be the case that setting this value to zero would\n** turn the limit off.  That is no longer true.  It is not possible\n** to turn this limit off.\n*/\n#ifndef SQLITE_MAX_SQL_LENGTH\n# define SQLITE_MAX_SQL_LENGTH 1000000000\n#endif\n\n/*\n** The maximum depth of an expression tree. This is limited to \n** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might \n** want to place more severe limits on the complexity of an \n** expression.\n**\n** A value of 0 used to mean that the limit was not enforced.\n** But that is no longer true.  The limit is now strictly enforced\n** at all times.\n*/\n#ifndef SQLITE_MAX_EXPR_DEPTH\n# define SQLITE_MAX_EXPR_DEPTH 1000\n#endif\n\n/*\n** The maximum number of terms in a compound SELECT statement.\n** The code generator for compound SELECT statements does one\n** level of recursion for each term.  A stack overflow can result\n** if the number of terms is too large.  In practice, most SQL\n** never has more than 3 or 4 terms.  Use a value of 0 to disable\n** any limit on the number of terms in a compount SELECT.\n*/\n#ifndef SQLITE_MAX_COMPOUND_SELECT\n# define SQLITE_MAX_COMPOUND_SELECT 500\n#endif\n\n/*\n** The maximum number of opcodes in a VDBE program.\n** Not currently enforced.\n*/\n#ifndef SQLITE_MAX_VDBE_OP\n# define SQLITE_MAX_VDBE_OP 250000000\n#endif\n\n/*\n** The maximum number of arguments to an SQL function.\n*/\n#ifndef SQLITE_MAX_FUNCTION_ARG\n# define SQLITE_MAX_FUNCTION_ARG 127\n#endif\n\n/*\n** The suggested maximum number of in-memory pages to use for\n** the main database table and for temporary tables.\n**\n** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,\n** which means the cache size is limited to 2048000 bytes of memory.\n** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be\n** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.\n*/\n#ifndef SQLITE_DEFAULT_CACHE_SIZE\n# define SQLITE_DEFAULT_CACHE_SIZE  -2000\n#endif\n\n/*\n** The default number of frames to accumulate in the log file before\n** checkpointing the database in WAL mode.\n*/\n#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000\n#endif\n\n/*\n** The maximum number of attached databases.  This must be between 0\n** and 125.  The upper bound of 125 is because the attached databases are\n** counted using a signed 8-bit integer which has a maximum value of 127\n** and we have to allow 2 extra counts for the \"main\" and \"temp\" databases.\n*/\n#ifndef SQLITE_MAX_ATTACHED\n# define SQLITE_MAX_ATTACHED 10\n#endif\n\n\n/*\n** The maximum value of a ?nnn wildcard that the parser will accept.\n*/\n#ifndef SQLITE_MAX_VARIABLE_NUMBER\n# define SQLITE_MAX_VARIABLE_NUMBER 999\n#endif\n\n/* Maximum page size.  The upper bound on this value is 65536.  This a limit\n** imposed by the use of 16-bit offsets within each page.\n**\n** Earlier versions of SQLite allowed the user to change this value at\n** compile time. This is no longer permitted, on the grounds that it creates\n** a library that is technically incompatible with an SQLite library \n** compiled with a different limit. If a process operating on a database \n** with a page-size of 65536 bytes crashes, then an instance of SQLite \n** compiled with the default page-size limit will not be able to rollback \n** the aborted transaction. This could lead to database corruption.\n*/\n#ifdef SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_PAGE_SIZE\n#endif\n#define SQLITE_MAX_PAGE_SIZE 65536\n\n\n/*\n** The default size of a database page.\n*/\n#ifndef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE 4096\n#endif\n#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n/*\n** Ordinarily, if no value is explicitly provided, SQLite creates databases\n** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain\n** device characteristics (sector-size and atomic write() support),\n** SQLite may choose a larger value. This constant is the maximum value\n** SQLite will choose on its own.\n*/\n#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192\n#endif\n#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n\n/*\n** Maximum number of pages in one database file.\n**\n** This is really just the default value for the max_page_count pragma.\n** This value can be lowered (or raised) at run-time using that the\n** max_page_count macro.\n*/\n#ifndef SQLITE_MAX_PAGE_COUNT\n# define SQLITE_MAX_PAGE_COUNT 1073741823\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Maximum depth of recursion for triggers.\n**\n** A value of 1 means that a trigger program will not be able to itself\n** fire any triggers. A value of 0 means that no trigger programs at all \n** may be executed.\n*/\n#ifndef SQLITE_MAX_TRIGGER_DEPTH\n# define SQLITE_MAX_TRIGGER_DEPTH 1000\n#endif\n\n/************** End of sqliteLimit.h *****************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/* Disable nuisance warnings on Borland compilers */\n#if defined(__BORLANDC__)\n#pragma warn -rch /* unreachable code */\n#pragma warn -ccc /* Condition is always true or false */\n#pragma warn -aus /* Assigned value is never used */\n#pragma warn -csu /* Comparing signed and unsigned */\n#pragma warn -spa /* Suspicious pointer arithmetic */\n#endif\n\n/*\n** Include standard header files as necessary\n*/\n#ifdef HAVE_STDINT_H\n#include <stdint.h>\n#endif\n#ifdef HAVE_INTTYPES_H\n#include <inttypes.h>\n#endif\n\n/*\n** The following macros are used to cast pointers to integers and\n** integers to pointers.  The way you do this varies from one compiler\n** to the next, so we have developed the following set of #if statements\n** to generate appropriate macros for a wide range of compilers.\n**\n** The correct \"ANSI\" way to do this is to use the intptr_t type.\n** Unfortunately, that typedef is not available on all compilers, or\n** if it is available, it requires an #include of specific headers\n** that vary from one machine to the next.\n**\n** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on\n** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).\n** So we have to define the macros in different ways depending on the\n** compiler.\n*/\n#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))\n#elif !defined(__GNUC__)       /* Works for compilers other than LLVM */\n# define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])\n# define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))\n#elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))\n#else                          /* Generates a warning - but it always works */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(X))\n#endif\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define SQLITE_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define SQLITE_NOINLINE  __declspec(noinline)\n#else\n#  define SQLITE_NOINLINE\n#endif\n\n/*\n** Make sure that the compiler intrinsics we desire are enabled when\n** compiling with an appropriate version of MSVC unless prevented by\n** the SQLITE_DISABLE_INTRINSIC define.\n*/\n#if !defined(SQLITE_DISABLE_INTRINSIC)\n#  if defined(_MSC_VER) && _MSC_VER>=1400\n#    if !defined(_WIN32_WCE)\n#      include <intrin.h>\n#      pragma intrinsic(_byteswap_ushort)\n#      pragma intrinsic(_byteswap_ulong)\n#      pragma intrinsic(_byteswap_uint64)\n#      pragma intrinsic(_ReadWriteBarrier)\n#    else\n#      include <cmnintrin.h>\n#    endif\n#  endif\n#endif\n\n/*\n** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.\n** 0 means mutexes are permanently disable and the library is never\n** threadsafe.  1 means the library is serialized which is the highest\n** level of threadsafety.  2 means the library is multithreaded - multiple\n** threads can use SQLite as long as no two threads try to use the same\n** database connection at the same time.\n**\n** Older versions of SQLite used an optional THREADSAFE macro.\n** We support that for legacy.\n**\n** To ensure that the correct value of \"THREADSAFE\" is reported when querying\n** for compile-time options at runtime (e.g. \"PRAGMA compile_options\"), this\n** logic is partially replicated in ctime.c. If it is updated here, it should\n** also be updated there.\n*/\n#if !defined(SQLITE_THREADSAFE)\n# if defined(THREADSAFE)\n#   define SQLITE_THREADSAFE THREADSAFE\n# else\n#   define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */\n# endif\n#endif\n\n/*\n** Powersafe overwrite is on by default.  But can be turned off using\n** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.\n*/\n#ifndef SQLITE_POWERSAFE_OVERWRITE\n# define SQLITE_POWERSAFE_OVERWRITE 1\n#endif\n\n/*\n** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by\n** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in\n** which case memory allocation statistics are disabled by default.\n*/\n#if !defined(SQLITE_DEFAULT_MEMSTATUS)\n# define SQLITE_DEFAULT_MEMSTATUS 1\n#endif\n\n/*\n** Exactly one of the following macros must be defined in order to\n** specify which memory allocation subsystem to use.\n**\n**     SQLITE_SYSTEM_MALLOC          // Use normal system malloc()\n**     SQLITE_WIN32_MALLOC           // Use Win32 native heap API\n**     SQLITE_ZERO_MALLOC            // Use a stub allocator that always fails\n**     SQLITE_MEMDEBUG               // Debugging version of system malloc()\n**\n** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the\n** assert() macro is enabled, each call into the Win32 native heap subsystem\n** will cause HeapValidate to be called.  If heap validation should fail, an\n** assertion will be triggered.\n**\n** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as\n** the default.\n*/\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)>1\n# error \"Two or more of the following compile-time configuration options\\\n are defined but at most one is allowed:\\\n SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\\\n SQLITE_ZERO_MALLOC\"\n#endif\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)==0\n# define SQLITE_SYSTEM_MALLOC 1\n#endif\n\n/*\n** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the\n** sizes of memory allocations below this value where possible.\n*/\n#if !defined(SQLITE_MALLOC_SOFT_LIMIT)\n# define SQLITE_MALLOC_SOFT_LIMIT 1024\n#endif\n\n/*\n** We need to define _XOPEN_SOURCE as follows in order to enable\n** recursive mutexes on most Unix systems and fchmod() on OpenBSD.\n** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit\n** it.\n*/\n#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)\n#  define _XOPEN_SOURCE 600\n#endif\n\n/*\n** NDEBUG and SQLITE_DEBUG are opposites.  It should always be true that\n** defined(NDEBUG)==!defined(SQLITE_DEBUG).  If this is not currently true,\n** make it true by defining or undefining NDEBUG.\n**\n** Setting NDEBUG makes the code smaller and faster by disabling the\n** assert() statements in the code.  So we want the default action\n** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG\n** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out\n** feature.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)\n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.\n*/\n#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)\n# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1\n#endif\n\n/*\n** The testcase() macro is used to aid in coverage testing.  When\n** doing coverage testing, the condition inside the argument to\n** testcase() must be evaluated both true and false in order to\n** get full branch coverage.  The testcase() macro is inserted\n** to help ensure adequate test coverage in places where simple\n** condition/decision coverage is inadequate.  For example, testcase()\n** can be used to make sure boundary values are tested.  For\n** bitmask tests, testcase() can be used to make sure each bit\n** is significant and used at least once.  On switch statements\n** where multiple cases go to the same block of code, testcase()\n** can insure that all cases are evaluated.\n**\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE   void sqlite3Coverage(int);\n# define testcase(X)  if( X ){ sqlite3Coverage(__LINE__); }\n#else\n# define testcase(X)\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n/*\n** Sometimes we need a small amount of code such as a variable initialization\n** to setup for a later assert() statement.  We do not want this code to\n** appear when assert() is disabled.  The following macro is therefore\n** used to contain that setup code.  The \"VVA\" acronym stands for\n** \"Verification, Validation, and Accreditation\".  In other words, the\n** code within VVA_ONLY() will only run during verification processes.\n*/\n#ifndef NDEBUG\n# define VVA_ONLY(X)  X\n#else\n# define VVA_ONLY(X)\n#endif\n\n/*\n** The ALWAYS and NEVER macros surround boolean expressions which\n** are intended to always be true or false, respectively.  Such\n** expressions could be omitted from the code completely.  But they\n** are included in a few cases in order to enhance the resilience\n** of SQLite to unexpected behavior - to make the code \"self-healing\"\n** or \"ductile\" rather than being \"brittle\" and crashing at the first\n** hint of unplanned behavior.\n**\n** In other words, ALWAYS and NEVER are added for defensive code.\n**\n** When doing coverage testing ALWAYS and NEVER are hard-coded to\n** be true and false so that the unreachable code they specify will\n** not be counted as untested code.\n*/\n#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)\n# define ALWAYS(X)      (1)\n# define NEVER(X)       (0)\n#elif !defined(NDEBUG)\n# define ALWAYS(X)      ((X)?1:(assert(0),0))\n# define NEVER(X)       ((X)?(assert(0),1):0)\n#else\n# define ALWAYS(X)      (X)\n# define NEVER(X)       (X)\n#endif\n\n/*\n** Some conditionals are optimizations only.  In other words, if the\n** conditionals are replaced with a constant 1 (true) or 0 (false) then\n** the correct answer is still obtained, though perhaps not as quickly.\n**\n** The following macros mark these optimizations conditionals.\n*/\n#if defined(SQLITE_MUTATION_TEST)\n# define OK_IF_ALWAYS_TRUE(X)  (1)\n# define OK_IF_ALWAYS_FALSE(X) (0)\n#else\n# define OK_IF_ALWAYS_TRUE(X)  (X)\n# define OK_IF_ALWAYS_FALSE(X) (X)\n#endif\n\n/*\n** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is\n** defined.  We need to defend against those failures when testing with\n** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches\n** during a normal build.  The following macro can be used to disable tests\n** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.\n*/\n#if defined(SQLITE_TEST_REALLOC_STRESS)\n# define ONLY_IF_REALLOC_STRESS(X)  (X)\n#elif !defined(NDEBUG)\n# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)\n#else\n# define ONLY_IF_REALLOC_STRESS(X)  (0)\n#endif\n\n/*\n** Declarations used for tracing the operating system interfaces.\n*/\n#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n  extern int sqlite3OSTrace;\n# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X\n# define SQLITE_HAVE_OS_TRACE\n#else\n# define OSTRACE(X)\n# undef  SQLITE_HAVE_OS_TRACE\n#endif\n\n/*\n** Is the sqlite3ErrName() function needed in the build?  Currently,\n** it is needed by \"mutex_w32.c\" (when debugging), \"os_win.c\" (when\n** OSTRACE is enabled), and by several \"test*.c\" files (which are\n** compiled using SQLITE_TEST).\n*/\n#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n# define SQLITE_NEED_ERR_NAME\n#else\n# undef  SQLITE_NEED_ERR_NAME\n#endif\n\n/*\n** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN\n*/\n#ifdef SQLITE_OMIT_EXPLAIN\n# undef SQLITE_ENABLE_EXPLAIN_COMMENTS\n#endif\n\n/*\n** Return true (non-zero) if the input is an integer that is too large\n** to fit in 32-bits.  This macro is used inside of various testcase()\n** macros to verify that we have tested SQLite for large-file support.\n*/\n#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)\n\n/*\n** The macro unlikely() is a hint that surrounds a boolean\n** expression that is usually false.  Macro likely() surrounds\n** a boolean expression that is usually true.  These hints could,\n** in theory, be used by the compiler to generate better code, but\n** currently they are just comments for human readers.\n*/\n#define likely(X)    (X)\n#define unlikely(X)  (X)\n\n/************** Include hash.h in the middle of sqliteInt.h ******************/\n/************** Begin file hash.h ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.\n*/\n#ifndef SQLITE_HASH_H\n#define SQLITE_HASH_H\n\n/* Forward declarations of structures. */\ntypedef struct Hash Hash;\ntypedef struct HashElem HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, some of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n**\n** All elements of the hash table are on a single doubly-linked list.\n** Hash.first points to the head of this list.\n**\n** There are Hash.htsize buckets.  Each bucket points to a spot in\n** the global doubly-linked list.  The contents of the bucket are the\n** element pointed to plus the next _ht.count-1 elements in the list.\n**\n** Hash.htsize and Hash.ht may be zero.  In that case lookup is done\n** by a linear search of the global list.  For small tables, the \n** Hash.ht table is never allocated because if there are few elements\n** in the table, it is faster to do a linear search than to manage\n** the hash table.\n*/\nstruct Hash {\n  unsigned int htsize;      /* Number of buckets in the hash table */\n  unsigned int count;       /* Number of entries in this table */\n  HashElem *first;          /* The first element of the array */\n  struct _ht {              /* the hash table */\n    int count;                 /* Number of entries with this hash */\n    HashElem *chain;           /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct HashElem {\n  HashElem *next, *prev;       /* Next and previous elements in the table */\n  void *data;                  /* Data associated with this element */\n  const char *pKey;            /* Key associated with this element */\n};\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash*);\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, void *pData);\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey);\nSQLITE_PRIVATE void sqlite3HashClear(Hash*);\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Hash h;\n**   HashElem *p;\n**   ...\n**   for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){\n**     SomeStructure *pData = sqliteHashData(p);\n**     // do something with pData\n**   }\n*/\n#define sqliteHashFirst(H)  ((H)->first)\n#define sqliteHashNext(E)   ((E)->next)\n#define sqliteHashData(E)   ((E)->data)\n/* #define sqliteHashKey(E)    ((E)->pKey) // NOT USED */\n/* #define sqliteHashKeysize(E) ((E)->nKey)  // NOT USED */\n\n/*\n** Number of entries in a hash table\n*/\n/* #define sqliteHashCount(H)  ((H)->count) // NOT USED */\n\n#endif /* SQLITE_HASH_H */\n\n/************** End of hash.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include parse.h in the middle of sqliteInt.h *****************/\n/************** Begin file parse.h *******************************************/\n#define TK_SEMI                             1\n#define TK_EXPLAIN                          2\n#define TK_QUERY                            3\n#define TK_PLAN                             4\n#define TK_BEGIN                            5\n#define TK_TRANSACTION                      6\n#define TK_DEFERRED                         7\n#define TK_IMMEDIATE                        8\n#define TK_EXCLUSIVE                        9\n#define TK_COMMIT                          10\n#define TK_END                             11\n#define TK_ROLLBACK                        12\n#define TK_SAVEPOINT                       13\n#define TK_RELEASE                         14\n#define TK_TO                              15\n#define TK_TABLE                           16\n#define TK_CREATE                          17\n#define TK_IF                              18\n#define TK_NOT                             19\n#define TK_EXISTS                          20\n#define TK_TEMP                            21\n#define TK_LP                              22\n#define TK_RP                              23\n#define TK_AS                              24\n#define TK_WITHOUT                         25\n#define TK_COMMA                           26\n#define TK_ABORT                           27\n#define TK_ACTION                          28\n#define TK_AFTER                           29\n#define TK_ANALYZE                         30\n#define TK_ASC                             31\n#define TK_ATTACH                          32\n#define TK_BEFORE                          33\n#define TK_BY                              34\n#define TK_CASCADE                         35\n#define TK_CAST                            36\n#define TK_CONFLICT                        37\n#define TK_DATABASE                        38\n#define TK_DESC                            39\n#define TK_DETACH                          40\n#define TK_EACH                            41\n#define TK_FAIL                            42\n#define TK_OR                              43\n#define TK_AND                             44\n#define TK_IS                              45\n#define TK_MATCH                           46\n#define TK_LIKE_KW                         47\n#define TK_BETWEEN                         48\n#define TK_IN                              49\n#define TK_ISNULL                          50\n#define TK_NOTNULL                         51\n#define TK_NE                              52\n#define TK_EQ                              53\n#define TK_GT                              54\n#define TK_LE                              55\n#define TK_LT                              56\n#define TK_GE                              57\n#define TK_ESCAPE                          58\n#define TK_ID                              59\n#define TK_COLUMNKW                        60\n#define TK_FOR                             61\n#define TK_IGNORE                          62\n#define TK_INITIALLY                       63\n#define TK_INSTEAD                         64\n#define TK_NO                              65\n#define TK_KEY                             66\n#define TK_OF                              67\n#define TK_OFFSET                          68\n#define TK_PRAGMA                          69\n#define TK_RAISE                           70\n#define TK_RECURSIVE                       71\n#define TK_REPLACE                         72\n#define TK_RESTRICT                        73\n#define TK_ROW                             74\n#define TK_TRIGGER                         75\n#define TK_VACUUM                          76\n#define TK_VIEW                            77\n#define TK_VIRTUAL                         78\n#define TK_WITH                            79\n#define TK_REINDEX                         80\n#define TK_RENAME                          81\n#define TK_CTIME_KW                        82\n#define TK_ANY                             83\n#define TK_BITAND                          84\n#define TK_BITOR                           85\n#define TK_LSHIFT                          86\n#define TK_RSHIFT                          87\n#define TK_PLUS                            88\n#define TK_MINUS                           89\n#define TK_STAR                            90\n#define TK_SLASH                           91\n#define TK_REM                             92\n#define TK_CONCAT                          93\n#define TK_COLLATE                         94\n#define TK_BITNOT                          95\n#define TK_INDEXED                         96\n#define TK_STRING                          97\n#define TK_JOIN_KW                         98\n#define TK_CONSTRAINT                      99\n#define TK_DEFAULT                        100\n#define TK_NULL                           101\n#define TK_PRIMARY                        102\n#define TK_UNIQUE                         103\n#define TK_CHECK                          104\n#define TK_REFERENCES                     105\n#define TK_AUTOINCR                       106\n#define TK_ON                             107\n#define TK_INSERT                         108\n#define TK_DELETE                         109\n#define TK_UPDATE                         110\n#define TK_SET                            111\n#define TK_DEFERRABLE                     112\n#define TK_FOREIGN                        113\n#define TK_DROP                           114\n#define TK_UNION                          115\n#define TK_ALL                            116\n#define TK_EXCEPT                         117\n#define TK_INTERSECT                      118\n#define TK_SELECT                         119\n#define TK_VALUES                         120\n#define TK_DISTINCT                       121\n#define TK_DOT                            122\n#define TK_FROM                           123\n#define TK_JOIN                           124\n#define TK_USING                          125\n#define TK_ORDER                          126\n#define TK_GROUP                          127\n#define TK_HAVING                         128\n#define TK_LIMIT                          129\n#define TK_WHERE                          130\n#define TK_INTO                           131\n#define TK_FLOAT                          132\n#define TK_BLOB                           133\n#define TK_INTEGER                        134\n#define TK_VARIABLE                       135\n#define TK_CASE                           136\n#define TK_WHEN                           137\n#define TK_THEN                           138\n#define TK_ELSE                           139\n#define TK_INDEX                          140\n#define TK_ALTER                          141\n#define TK_ADD                            142\n#define TK_ISNOT                          143\n#define TK_FUNCTION                       144\n#define TK_COLUMN                         145\n#define TK_AGG_FUNCTION                   146\n#define TK_AGG_COLUMN                     147\n#define TK_UMINUS                         148\n#define TK_UPLUS                          149\n#define TK_REGISTER                       150\n#define TK_VECTOR                         151\n#define TK_SELECT_COLUMN                  152\n#define TK_IF_NULL_ROW                    153\n#define TK_ASTERISK                       154\n#define TK_SPAN                           155\n#define TK_END_OF_FILE                    156\n#define TK_UNCLOSED_STRING                157\n#define TK_SPACE                          158\n#define TK_ILLEGAL                        159\n\n/* The token codes above must all fit in 8 bits */\n#define TKFLG_MASK           0xff  \n\n/* Flags that can be added to a token code when it is not\n** being stored in a u8: */\n#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */\n\n/************** End of parse.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stddef.h>\n\n/*\n** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.\n** This allows better measurements of where memcpy() is used when running\n** cachegrind.  But this macro version of memcpy() is very slow so it\n** should not be used in production.  This is a performance measurement\n** hack only.\n*/\n#ifdef SQLITE_INLINE_MEMCPY\n# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\\\n                        int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}\n#endif\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite_int64\n# define float sqlite_int64\n# define LONGDOUBLE_TYPE sqlite_int64\n# ifndef SQLITE_BIG_DBL\n#   define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)\n# endif\n# define SQLITE_OMIT_DATETIME_FUNCS 1\n# define SQLITE_OMIT_TRACE 1\n# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n# undef SQLITE_HAVE_ISNAN\n#endif\n#ifndef SQLITE_BIG_DBL\n# define SQLITE_BIG_DBL (1e99)\n#endif\n\n/*\n** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0\n** afterward. Having this macro allows us to cause the C compiler\n** to omit code used by TEMP tables without messy #ifndef statements.\n*/\n#ifdef SQLITE_OMIT_TEMPDB\n#define OMIT_TEMPDB 1\n#else\n#define OMIT_TEMPDB 0\n#endif\n\n/*\n** The \"file format\" number is an integer that is incremented whenever\n** the VDBE-level file format changes.  The following macros define the\n** the default file format for new databases and the maximum file format\n** that the library can read.\n*/\n#define SQLITE_MAX_FILE_FORMAT 4\n#ifndef SQLITE_DEFAULT_FILE_FORMAT\n# define SQLITE_DEFAULT_FILE_FORMAT 4\n#endif\n\n/*\n** Determine whether triggers are recursive by default.  This can be\n** changed at run-time using a pragma.\n*/\n#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0\n#endif\n\n/*\n** Provide a default value for SQLITE_TEMP_STORE in case it is not specified\n** on the command-line\n*/\n#ifndef SQLITE_TEMP_STORE\n# define SQLITE_TEMP_STORE 1\n#endif\n\n/*\n** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if\n** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it\n** to zero.\n*/\n#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 0\n#endif\n#ifndef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 8\n#endif\n#ifndef SQLITE_DEFAULT_WORKER_THREADS\n# define SQLITE_DEFAULT_WORKER_THREADS 0\n#endif\n#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS\n#endif\n\n/*\n** The default initial allocation for the pagecache when using separate\n** pagecaches for each database connection.  A positive number is the\n** number of pages.  A negative number N translations means that a buffer\n** of -1024*N bytes is allocated and used for as many pages as it will hold.\n**\n** The default value of \"20\" was choosen to minimize the run-time of the\n** speedtest1 test program with options: --shrink-memory --reprepare\n*/\n#ifndef SQLITE_DEFAULT_PCACHE_INITSZ\n# define SQLITE_DEFAULT_PCACHE_INITSZ 20\n#endif\n\n/*\n** The compile-time options SQLITE_MMAP_READWRITE and \n** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.\n** You must choose one or the other (or neither) but not both.\n*/\n#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n#endif\n\n/*\n** GCC does not define the offsetof() macro so we'll have to do it\n** ourselves.\n*/\n#ifndef offsetof\n#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))\n#endif\n\n/*\n** Macros to compute minimum and maximum of two numbers.\n*/\n#ifndef MIN\n# define MIN(A,B) ((A)<(B)?(A):(B))\n#endif\n#ifndef MAX\n# define MAX(A,B) ((A)>(B)?(A):(B))\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n\n/*\n** Check to see if this machine uses EBCDIC.  (Yes, believe it or\n** not, there are still machines out there that use EBCDIC.)\n*/\n#if 'A' == '\\301'\n# define SQLITE_EBCDIC 1\n#else\n# define SQLITE_ASCII 1\n#endif\n\n/*\n** Integers of known sizes.  These typedefs might change for architectures\n** where the sizes very.  Preprocessor macros are available so that the\n** types can be conveniently redefined at compile-type.  Like this:\n**\n**         cc '-DUINTPTR_TYPE=long long int' ...\n*/\n#ifndef UINT32_TYPE\n# ifdef HAVE_UINT32_T\n#  define UINT32_TYPE uint32_t\n# else\n#  define UINT32_TYPE unsigned int\n# endif\n#endif\n#ifndef UINT16_TYPE\n# ifdef HAVE_UINT16_T\n#  define UINT16_TYPE uint16_t\n# else\n#  define UINT16_TYPE unsigned short int\n# endif\n#endif\n#ifndef INT16_TYPE\n# ifdef HAVE_INT16_T\n#  define INT16_TYPE int16_t\n# else\n#  define INT16_TYPE short int\n# endif\n#endif\n#ifndef UINT8_TYPE\n# ifdef HAVE_UINT8_T\n#  define UINT8_TYPE uint8_t\n# else\n#  define UINT8_TYPE unsigned char\n# endif\n#endif\n#ifndef INT8_TYPE\n# ifdef HAVE_INT8_T\n#  define INT8_TYPE int8_t\n# else\n#  define INT8_TYPE signed char\n# endif\n#endif\n#ifndef LONGDOUBLE_TYPE\n# define LONGDOUBLE_TYPE long double\n#endif\ntypedef sqlite_int64 i64;          /* 8-byte signed integer */\ntypedef sqlite_uint64 u64;         /* 8-byte unsigned integer */\ntypedef UINT32_TYPE u32;           /* 4-byte unsigned integer */\ntypedef UINT16_TYPE u16;           /* 2-byte unsigned integer */\ntypedef INT16_TYPE i16;            /* 2-byte signed integer */\ntypedef UINT8_TYPE u8;             /* 1-byte unsigned integer */\ntypedef INT8_TYPE i8;              /* 1-byte signed integer */\n\n/*\n** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value\n** that can be stored in a u32 without loss of data.  The value\n** is 0x00000000ffffffff.  But because of quirks of some compilers, we\n** have to specify the value in the less intuitive manner shown:\n*/\n#define SQLITE_MAX_U32  ((((u64)1)<<32)-1)\n\n/*\n** The datatype used to store estimates of the number of rows in a\n** table or index.  This is an unsigned integer type.  For 99.9% of\n** the world, a 32-bit integer is sufficient.  But a 64-bit integer\n** can be used at compile-time if desired.\n*/\n#ifdef SQLITE_64BIT_STATS\n typedef u64 tRowcnt;    /* 64-bit only if requested at compile-time */\n#else\n typedef u32 tRowcnt;    /* 32-bit is the default */\n#endif\n\n/*\n** Estimated quantities used for query planning are stored as 16-bit\n** logarithms.  For quantity X, the value stored is 10*log2(X).  This\n** gives a possible range of values of approximately 1.0e986 to 1e-986.\n** But the allowed values are \"grainy\".  Not every value is representable.\n** For example, quantities 16 and 17 are both represented by a LogEst\n** of 40.  However, since LogEst quantities are suppose to be estimates,\n** not exact values, this imprecision is not a problem.\n**\n** \"LogEst\" is short for \"Logarithmic Estimate\".\n**\n** Examples:\n**      1 -> 0              20 -> 43          10000 -> 132\n**      2 -> 10             25 -> 46          25000 -> 146\n**      3 -> 16            100 -> 66        1000000 -> 199\n**      4 -> 20           1000 -> 99        1048576 -> 200\n**     10 -> 33           1024 -> 100    4294967296 -> 320\n**\n** The LogEst can be negative to indicate fractional values.\n** Examples:\n**\n**    0.5 -> -10           0.1 -> -33        0.0625 -> -40\n*/\ntypedef INT16_TYPE LogEst;\n\n/*\n** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer\n*/\n#ifndef SQLITE_PTRSIZE\n# if defined(__SIZEOF_POINTER__)\n#   define SQLITE_PTRSIZE __SIZEOF_POINTER__\n# elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n       defined(_M_ARM)   || defined(__arm__)    || defined(__x86)\n#   define SQLITE_PTRSIZE 4\n# else\n#   define SQLITE_PTRSIZE 8\n# endif\n#endif\n\n/* The uptr type is an unsigned integer large enough to hold a pointer\n*/\n#if defined(HAVE_STDINT_H)\n  typedef uintptr_t uptr;\n#elif SQLITE_PTRSIZE==4\n  typedef u32 uptr;\n#else\n  typedef u64 uptr;\n#endif\n\n/*\n** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to\n** something between S (inclusive) and E (exclusive).\n**\n** In other words, S is a buffer and E is a pointer to the first byte after\n** the end of buffer S.  This macro returns true if P points to something\n** contained within the buffer S.\n*/\n#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))\n\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n# if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n     defined(__arm__)\n#   define SQLITE_BYTEORDER    1234\n# elif defined(sparc)    || defined(__ppc__)\n#   define SQLITE_BYTEORDER    4321\n# else\n#   define SQLITE_BYTEORDER 0\n# endif\n#endif\n#if SQLITE_BYTEORDER==4321\n# define SQLITE_BIGENDIAN    1\n# define SQLITE_LITTLEENDIAN 0\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16BE\n#elif SQLITE_BYTEORDER==1234\n# define SQLITE_BIGENDIAN    0\n# define SQLITE_LITTLEENDIAN 1\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16LE\n#else\n# ifdef SQLITE_AMALGAMATION\n  const int sqlite3one = 1;\n# else\n  extern const int sqlite3one;\n# endif\n# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)\n# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)\n# define SQLITE_UTF16NATIVE  (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)\n#endif\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n/*\n** Round up a number to the next larger multiple of 8.  This is used\n** to force 8-byte alignment on 64-bit architectures.\n*/\n#define ROUND8(x)     (((x)+7)&~7)\n\n/*\n** Round down to the nearest multiple of 8\n*/\n#define ROUNDDOWN8(x) ((x)&~7)\n\n/*\n** Assert that the pointer X is aligned to an 8-byte boundary.  This\n** macro is used only within assert() to verify that the code gets\n** all alignment restrictions correct.\n**\n** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the\n** underlying malloc() implementation might return us 4-byte aligned\n** pointers.  In that case, only verify 4-byte alignment.\n*/\n#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)\n#else\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)\n#endif\n\n/*\n** Disable MMAP on platforms where it is known to not work\n*/\n#if defined(__OpenBSD__) || defined(__QNXNTO__)\n# undef SQLITE_MAX_MMAP_SIZE\n# define SQLITE_MAX_MMAP_SIZE 0\n#endif\n\n/*\n** Default maximum size of memory used by memory-mapped I/O in the VFS\n*/\n#ifdef __APPLE__\n# include <TargetConditionals.h>\n#endif\n#ifndef SQLITE_MAX_MMAP_SIZE\n# if defined(__linux__) \\\n  || defined(_WIN32) \\\n  || (defined(__APPLE__) && defined(__MACH__)) \\\n  || defined(__sun) \\\n  || defined(__FreeBSD__) \\\n  || defined(__DragonFly__)\n#   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */\n# else\n#   define SQLITE_MAX_MMAP_SIZE 0\n# endif\n#endif\n\n/*\n** The default MMAP_SIZE is zero on all platforms.  Or, even if a larger\n** default MMAP_SIZE is specified at compile-time, make sure that it does\n** not exceed the maximum mmap size.\n*/\n#ifndef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE 0\n#endif\n#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE\n# undef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE\n#endif\n\n/*\n** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.\n** Priority is given to SQLITE_ENABLE_STAT4.  If either are defined, also\n** define SQLITE_ENABLE_STAT3_OR_STAT4\n*/\n#ifdef SQLITE_ENABLE_STAT4\n# undef SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3_OR_STAT4\n# undef SQLITE_ENABLE_STAT3_OR_STAT4\n#endif\n\n/*\n** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not\n** the Select query generator tracing logic is turned on.\n*/\n#if defined(SQLITE_ENABLE_SELECTTRACE)\n# define SELECTTRACE_ENABLED 1\n#else\n# define SELECTTRACE_ENABLED 0\n#endif\n\n/*\n** An instance of the following structure is used to store the busy-handler\n** callback for a given sqlite handle.\n**\n** The sqlite.busyHandler member of the sqlite struct contains the busy\n** callback for the database handle. Each pager opened via the sqlite\n** handle is passed a pointer to sqlite.busyHandler. The busy-handler\n** callback is currently invoked only from within pager.c.\n*/\ntypedef struct BusyHandler BusyHandler;\nstruct BusyHandler {\n  int (*xFunc)(void *,int);  /* The busy callback */\n  void *pArg;                /* First arg to busy callback */\n  int nBusy;                 /* Incremented with each busy call */\n};\n\n/*\n** Name of the master database table.  The master database table\n** is a special table that holds the names and attributes of all\n** user tables and indices.\n*/\n#define MASTER_NAME       \"sqlite_master\"\n#define TEMP_MASTER_NAME  \"sqlite_temp_master\"\n\n/*\n** The root-page of the master database table.\n*/\n#define MASTER_ROOT       1\n\n/*\n** The name of the schema table.\n*/\n#define SCHEMA_TABLE(x)  ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)\n\n/*\n** A convenience macro that returns the number of elements in\n** an array.\n*/\n#define ArraySize(X)    ((int)(sizeof(X)/sizeof(X[0])))\n\n/*\n** Determine if the argument is a power of two\n*/\n#define IsPowerOfTwo(X) (((X)&((X)-1))==0)\n\n/*\n** The following value as a destructor means to use sqlite3DbFree().\n** The sqlite3DbFree() routine requires two parameters instead of the\n** one parameter that destructors normally want.  So we have to introduce\n** this magic value that the code knows to handle differently.  Any\n** pointer will work here as long as it is distinct from SQLITE_STATIC\n** and SQLITE_TRANSIENT.\n*/\n#define SQLITE_DYNAMIC   ((sqlite3_destructor_type)sqlite3MallocSize)\n\n/*\n** When SQLITE_OMIT_WSD is defined, it means that the target platform does\n** not support Writable Static Data (WSD) such as global and static variables.\n** All variables must either be on the stack or dynamically allocated from\n** the heap.  When WSD is unsupported, the variable declarations scattered\n** throughout the SQLite code must become constants instead.  The SQLITE_WSD\n** macro is used for this purpose.  And instead of referencing the variable\n** directly, we use its constant as a key to lookup the run-time allocated\n** buffer that holds real variable.  The constant is also the initializer\n** for the run-time allocated buffer.\n**\n** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL\n** macros become no-ops and have zero performance impact.\n*/\n#ifdef SQLITE_OMIT_WSD\n  #define SQLITE_WSD const\n  #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))\n  #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)\nSQLITE_API int sqlite3_wsd_init(int N, int J);\nSQLITE_API void *sqlite3_wsd_find(void *K, int L);\n#else\n  #define SQLITE_WSD\n  #define GLOBAL(t,v) v\n  #define sqlite3GlobalConfig sqlite3Config\n#endif\n\n/*\n** The following macros are used to suppress compiler warnings and to\n** make it clear to human readers when a function parameter is deliberately\n** left unused within the body of a function. This usually happens when\n** a function is called via a function pointer. For example the\n** implementation of an SQL aggregate step callback may not use the\n** parameter indicating the number of arguments passed to the aggregate,\n** if it knows that this is enforced elsewhere.\n**\n** When a function parameter is not used at all within the body of a function,\n** it is generally named \"NotUsed\" or \"NotUsed2\" to make things even clearer.\n** However, these macros may also be used to suppress warnings related to\n** parameters that may or may not be used depending on compilation options.\n** For example those parameters only used in assert() statements. In these\n** cases the parameters are named as per the usual conventions.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)\n\n/*\n** Forward references to structures\n*/\ntypedef struct AggInfo AggInfo;\ntypedef struct AuthContext AuthContext;\ntypedef struct AutoincInfo AutoincInfo;\ntypedef struct Bitvec Bitvec;\ntypedef struct CollSeq CollSeq;\ntypedef struct Column Column;\ntypedef struct Db Db;\ntypedef struct Schema Schema;\ntypedef struct Expr Expr;\ntypedef struct ExprList ExprList;\ntypedef struct ExprSpan ExprSpan;\ntypedef struct FKey FKey;\ntypedef struct FuncDestructor FuncDestructor;\ntypedef struct FuncDef FuncDef;\ntypedef struct FuncDefHash FuncDefHash;\ntypedef struct IdList IdList;\ntypedef struct Index Index;\ntypedef struct IndexSample IndexSample;\ntypedef struct KeyClass KeyClass;\ntypedef struct KeyInfo KeyInfo;\ntypedef struct Lookaside Lookaside;\ntypedef struct LookasideSlot LookasideSlot;\ntypedef struct Module Module;\ntypedef struct NameContext NameContext;\ntypedef struct Parse Parse;\ntypedef struct PreUpdate PreUpdate;\ntypedef struct PrintfArguments PrintfArguments;\ntypedef struct RowSet RowSet;\ntypedef struct Savepoint Savepoint;\ntypedef struct Select Select;\ntypedef struct SQLiteThread SQLiteThread;\ntypedef struct SelectDest SelectDest;\ntypedef struct SrcList SrcList;\ntypedef struct StrAccum StrAccum;\ntypedef struct Table Table;\ntypedef struct TableLock TableLock;\ntypedef struct Token Token;\ntypedef struct TreeView TreeView;\ntypedef struct Trigger Trigger;\ntypedef struct TriggerPrg TriggerPrg;\ntypedef struct TriggerStep TriggerStep;\ntypedef struct UnpackedRecord UnpackedRecord;\ntypedef struct VTable VTable;\ntypedef struct VtabCtx VtabCtx;\ntypedef struct Walker Walker;\ntypedef struct WhereInfo WhereInfo;\ntypedef struct With With;\n\n/* A VList object records a mapping between parameters/variables/wildcards\n** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer\n** variable number associated with that parameter.  See the format description\n** on the sqlite3VListAdd() routine for more information.  A VList is really\n** just an array of integers.\n*/\ntypedef int VList;\n\n/*\n** Defer sourcing vdbe.h and btree.h until after the \"u8\" and\n** \"BusyHandler\" typedefs. vdbe.h also requires a few of the opaque\n** pointer types (i.e. FuncDef) defined above.\n*/\n/************** Include btree.h in the middle of sqliteInt.h *****************/\n/************** Begin file btree.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite B-Tree file\n** subsystem.  See comments in the source code for a detailed description\n** of what each interface routine does.\n*/\n#ifndef SQLITE_BTREE_H\n#define SQLITE_BTREE_H\n\n/* TODO: This definition is just included so other modules compile. It\n** needs to be revisited.\n*/\n#define SQLITE_N_BTREE_META 16\n\n/*\n** If defined as non-zero, auto-vacuum is enabled by default. Otherwise\n** it must be turned on for each database using \"PRAGMA auto_vacuum = 1\".\n*/\n#ifndef SQLITE_DEFAULT_AUTOVACUUM\n  #define SQLITE_DEFAULT_AUTOVACUUM 0\n#endif\n\n#define BTREE_AUTOVACUUM_NONE 0        /* Do not do auto-vacuum */\n#define BTREE_AUTOVACUUM_FULL 1        /* Do full auto-vacuum */\n#define BTREE_AUTOVACUUM_INCR 2        /* Incremental vacuum */\n\n/*\n** Forward declarations of structure\n*/\ntypedef struct Btree Btree;\ntypedef struct BtCursor BtCursor;\ntypedef struct BtShared BtShared;\ntypedef struct BtreePayload BtreePayload;\n\n\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,       /* VFS to use with this b-tree */\n  const char *zFilename,   /* Name of database file to open */\n  sqlite3 *db,             /* Associated database connection */\n  Btree **ppBtree,         /* Return open Btree* here */\n  int flags,               /* Flags */\n  int vfsFlags             /* Flags passed through to VFS open */\n);\n\n/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the\n** following values.\n**\n** NOTE:  These values must match the corresponding PAGER_ values in\n** pager.h.\n*/\n#define BTREE_OMIT_JOURNAL  1  /* Do not create or use a rollback journal */\n#define BTREE_MEMORY        2  /* This is an in-memory DB */\n#define BTREE_SINGLE        4  /* The file contains at most 1 b-tree */\n#define BTREE_UNORDERED     8  /* Use of a hash implementation is OK */\n\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree*,int);\n#if SQLITE_MAX_MMAP_SIZE>0\nSQLITE_PRIVATE   int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(Btree*,unsigned);\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags);\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree*);\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);\n\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);\n\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *);\n\n/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR\n** of the flags shown below.\n**\n** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.\n** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data\n** is stored in the leaves.  (BTREE_INTKEY is used for SQL tables.)  With\n** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored\n** anywhere - the key is the content.  (BTREE_BLOBKEY is used for SQL\n** indices.)\n*/\n#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */\n#define BTREE_BLOBKEY    2    /* Table has keys only - no data */\n\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);\nSQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);\n\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);\n\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);\n\n/*\n** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta\n** should be one of the following values. The integer values are assigned \n** to constants so that the offset of the corresponding field in an\n** SQLite database header may be found using the following formula:\n**\n**   offset = 36 + (idx * 4)\n**\n** For example, the free-page-count field is located at byte offset 36 of\n** the database file header. The incr-vacuum-flag field is located at\n** byte offset 64 (== 36+4*7).\n**\n** The BTREE_DATA_VERSION value is not really a value stored in the header.\n** It is a read-only number computed by the pager.  But we merge it with\n** the header value access routines since its access pattern is the same.\n** Call it a \"virtual meta value\".\n*/\n#define BTREE_FREE_PAGE_COUNT     0\n#define BTREE_SCHEMA_VERSION      1\n#define BTREE_FILE_FORMAT         2\n#define BTREE_DEFAULT_CACHE_SIZE  3\n#define BTREE_LARGEST_ROOT_PAGE   4\n#define BTREE_TEXT_ENCODING       5\n#define BTREE_USER_VERSION        6\n#define BTREE_INCR_VACUUM         7\n#define BTREE_APPLICATION_ID      8\n#define BTREE_DATA_VERSION        15  /* A virtual meta-value */\n\n/*\n** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()\n** interface.\n**\n** BTREE_HINT_RANGE  (arguments: Expr*, Mem*)\n**\n**     The first argument is an Expr* (which is guaranteed to be constant for\n**     the lifetime of the cursor) that defines constraints on which rows\n**     might be fetched with this cursor.  The Expr* tree may contain\n**     TK_REGISTER nodes that refer to values stored in the array of registers\n**     passed as the second parameter.  In other words, if Expr.op==TK_REGISTER\n**     then the value of the node is the value in Mem[pExpr.iTable].  Any\n**     TK_COLUMN node in the expression tree refers to the Expr.iColumn-th\n**     column of the b-tree of the cursor.  The Expr tree will not contain\n**     any function calls nor subqueries nor references to b-trees other than\n**     the cursor being hinted.\n**\n**     The design of the _RANGE hint is aid b-tree implementations that try\n**     to prefetch content from remote machines - to provide those\n**     implementations with limits on what needs to be prefetched and thereby\n**     reduce network bandwidth.\n**\n** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by\n** standard SQLite.  The other hints are provided for extentions that use\n** the SQLite parser and code generator but substitute their own storage\n** engine.\n*/\n#define BTREE_HINT_RANGE 0       /* Range constraints on queries */\n\n/*\n** Values that may be OR'd together to form the argument to the\n** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():\n**\n** The BTREE_BULKLOAD flag is set on index cursors when the index is going\n** to be filled with content that is already in sorted order.\n**\n** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or\n** OP_SeekLE opcodes for a range search, but where the range of entries\n** selected will all have the same key.  In other words, the cursor will\n** be used only for equality key searches.\n**\n*/\n#define BTREE_BULKLOAD 0x00000001  /* Used to full index in sorted order */\n#define BTREE_SEEK_EQ  0x00000002  /* EQ seeks only - no range seeks */\n\n/* \n** Flags passed as the third argument to sqlite3BtreeCursor().\n**\n** For read-only cursors the wrFlag argument is always zero. For read-write\n** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just\n** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will\n** only be used by SQLite for the following:\n**\n**   * to seek to and then delete specific entries, and/or\n**\n**   * to read values that will be used to create keys that other\n**     BTREE_FORDELETE cursors will seek to and delete.\n**\n** The BTREE_FORDELETE flag is an optimization hint.  It is not used by\n** by this, the native b-tree engine of SQLite, but it is available to\n** alternative storage engines that might be substituted in place of this\n** b-tree system.  For alternative storage engines in which a delete of\n** the main table row automatically deletes corresponding index rows,\n** the FORDELETE flag hint allows those alternative storage engines to\n** skip a lot of work.  Namely:  FORDELETE cursors may treat all SEEK\n** and DELETE operations as no-ops, and any READ operation against a\n** FORDELETE cursor may return a null row: 0x01 0x00.\n*/\n#define BTREE_WRCSR     0x00000004     /* read-write cursor */\n#define BTREE_FORDELETE 0x00000008     /* Cursor is for seek/delete only */\n\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree*,                              /* BTree containing table to open */\n  int iTable,                          /* Index of root page */\n  int wrFlag,                          /* 1 for writing.  0 for read-only */\n  struct KeyInfo*,                     /* First argument to compare function */\n  BtCursor *pCursor                    /* Space to write cursor structure */\n);\nSQLITE_PRIVATE BtCursor *sqlite3BtreeFakeValidCursor(void);\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void);\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*);\nSQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nSQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);\n#endif\n\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor*,\n  UnpackedRecord *pUnKey,\n  i64 intKey,\n  int bias,\n  int *pRes\n);\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);\n\n/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */\n#define BTREE_SAVEPOSITION 0x02  /* Leave cursor pointing at NEXT or PREV */\n#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */\n#define BTREE_APPEND       0x08  /* Insert is likely an append */\n\n/* An instance of the BtreePayload object describes the content of a single\n** entry in either an index or table btree.\n**\n** Index btrees (used for indexes and also WITHOUT ROWID tables) contain\n** an arbitrary key and no data.  These btrees have pKey,nKey set to their\n** key and pData,nData,nZero set to zero.\n**\n** Table btrees (used for rowid tables) contain an integer rowid used as\n** the key and passed in the nKey field.  The pKey field is zero.  \n** pData,nData hold the content of the new entry.  nZero extra zero bytes\n** are appended to the end of the content when constructing the entry.\n**\n** This object is used to pass information into sqlite3BtreeInsert().  The\n** same information used to be passed as five separate parameters.  But placing\n** the information into this object helps to keep the interface more \n** organized and understandable, and it also helps the resulting code to\n** run a little faster by using fewer registers for parameter passing.\n*/\nstruct BtreePayload {\n  const void *pKey;       /* Key content for indexes.  NULL for tables */\n  sqlite3_int64 nKey;     /* Size of pKey for indexes.  PRIMARY KEY for tabs */\n  const void *pData;      /* Data for tables.  NULL for indexes */\n  sqlite3_value *aMem;    /* First of nMem value in the unpacked pKey */\n  u16 nMem;               /* Number of aMem[] value.  Might be zero */\n  int nData;              /* Size of pData.  0 if none. */\n  int nZero;              /* Extra zero data appended after pData,nData */\n};\n\nSQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,\n                       int flags, int seekResult);\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);\nSQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);\nSQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);\nSQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);\n\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);\nSQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);\nSQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);\n\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);\nSQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);\n#endif\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);\nSQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);\nSQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);\nSQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);\n\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);\n#endif\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor*);\n\n#ifndef SQLITE_OMIT_BTREECOUNT\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int);\nSQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*);\n#endif\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);\n#endif\n\n/*\n** If we are not using shared cache, then there is no need to\n** use mutexes to access the BtShared structures.  So make the\n** Enter and Leave procedures no-ops.\n*/\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3BtreeEnter(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterAll(sqlite3*);\nSQLITE_PRIVATE   int sqlite3BtreeSharable(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeEnterCursor(BtCursor*);\nSQLITE_PRIVATE   int sqlite3BtreeConnectionCount(Btree*);\n#else\n# define sqlite3BtreeEnter(X) \n# define sqlite3BtreeEnterAll(X)\n# define sqlite3BtreeSharable(X) 0\n# define sqlite3BtreeEnterCursor(X)\n# define sqlite3BtreeConnectionCount(X) 1\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE\nSQLITE_PRIVATE   void sqlite3BtreeLeave(Btree*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveCursor(BtCursor*);\nSQLITE_PRIVATE   void sqlite3BtreeLeaveAll(sqlite3*);\n#ifndef NDEBUG\n  /* These routines are used inside assert() statements only. */\nSQLITE_PRIVATE   int sqlite3BtreeHoldsMutex(Btree*);\nSQLITE_PRIVATE   int sqlite3BtreeHoldsAllMutexes(sqlite3*);\nSQLITE_PRIVATE   int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);\n#endif\n#else\n\n# define sqlite3BtreeLeave(X)\n# define sqlite3BtreeLeaveCursor(X)\n# define sqlite3BtreeLeaveAll(X)\n\n# define sqlite3BtreeHoldsMutex(X) 1\n# define sqlite3BtreeHoldsAllMutexes(X) 1\n# define sqlite3SchemaMutexHeld(X,Y,Z) 1\n#endif\n\n\n#endif /* SQLITE_BTREE_H */\n\n/************** End of btree.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include vdbe.h in the middle of sqliteInt.h ******************/\n/************** Begin file vdbe.h ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Header file for the Virtual DataBase Engine (VDBE)\n**\n** This header defines the interface to the virtual database engine\n** or VDBE.  The VDBE implements an abstract machine that runs a\n** simple program to access and modify the underlying database.\n*/\n#ifndef SQLITE_VDBE_H\n#define SQLITE_VDBE_H\n/* #include <stdio.h> */\n\n/*\n** A single VDBE is an opaque structure named \"Vdbe\".  Only routines\n** in the source file sqliteVdbe.c are allowed to see the insides\n** of this structure.\n*/\ntypedef struct Vdbe Vdbe;\n\n/*\n** The names of the following types declared in vdbeInt.h are required\n** for the VdbeOp definition.\n*/\ntypedef struct sqlite3_value Mem;\ntypedef struct SubProgram SubProgram;\n\n/*\n** A single instruction of the virtual machine has an opcode\n** and as many as three operands.  The instruction is recorded\n** as an instance of the following structure:\n*/\nstruct VdbeOp {\n  u8 opcode;          /* What operation to perform */\n  signed char p4type; /* One of the P4_xxx constants for p4 */\n  u16 p5;             /* Fifth parameter is an unsigned 16-bit integer */\n  int p1;             /* First operand */\n  int p2;             /* Second parameter (often the jump destination) */\n  int p3;             /* The third parameter */\n  union p4union {     /* fourth parameter */\n    int i;                 /* Integer value if p4type==P4_INT32 */\n    void *p;               /* Generic pointer */\n    char *z;               /* Pointer to data for string (char array) types */\n    i64 *pI64;             /* Used when p4type is P4_INT64 */\n    double *pReal;         /* Used when p4type is P4_REAL */\n    FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */\n    sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */\n    CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */\n    Mem *pMem;             /* Used when p4type is P4_MEM */\n    VTable *pVtab;         /* Used when p4type is P4_VTAB */\n    KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */\n    int *ai;               /* Used when p4type is P4_INTARRAY */\n    SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */\n    Table *pTab;           /* Used when p4type is P4_TABLE */\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    Expr *pExpr;           /* Used when p4type is P4_EXPR */\n#endif\n    int (*xAdvance)(BtCursor *, int);\n  } p4;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  char *zComment;          /* Comment to improve readability */\n#endif\n#ifdef VDBE_PROFILE\n  u32 cnt;                 /* Number of times this instruction was executed */\n  u64 cycles;              /* Total time spent executing this instruction */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  int iSrcLine;            /* Source-code line that generated this opcode */\n#endif\n};\ntypedef struct VdbeOp VdbeOp;\n\n\n/*\n** A sub-routine used to implement a trigger program.\n*/\nstruct SubProgram {\n  VdbeOp *aOp;                  /* Array of opcodes for sub-program */\n  int nOp;                      /* Elements in aOp[] */\n  int nMem;                     /* Number of memory cells required */\n  int nCsr;                     /* Number of cursors required */\n  u8 *aOnce;                    /* Array of OP_Once flags */\n  void *token;                  /* id that may be used to recursive triggers */\n  SubProgram *pNext;            /* Next sub-program already visited */\n};\n\n/*\n** A smaller version of VdbeOp used for the VdbeAddOpList() function because\n** it takes up less space.\n*/\nstruct VdbeOpList {\n  u8 opcode;          /* What operation to perform */\n  signed char p1;     /* First operand */\n  signed char p2;     /* Second parameter (often the jump destination) */\n  signed char p3;     /* Third parameter */\n};\ntypedef struct VdbeOpList VdbeOpList;\n\n/*\n** Allowed values of VdbeOp.p4type\n*/\n#define P4_NOTUSED      0   /* The P4 parameter is not used */\n#define P4_TRANSIENT    0   /* P4 is a pointer to a transient string */\n#define P4_STATIC     (-1)  /* Pointer to a static string */\n#define P4_COLLSEQ    (-2)  /* P4 is a pointer to a CollSeq structure */\n#define P4_INT32      (-3)  /* P4 is a 32-bit signed integer */\n#define P4_SUBPROGRAM (-4)  /* P4 is a pointer to a SubProgram structure */\n#define P4_ADVANCE    (-5)  /* P4 is a pointer to BtreeNext() or BtreePrev() */\n#define P4_TABLE      (-6)  /* P4 is a pointer to a Table structure */\n/* Above do not own any resources.  Must free those below */\n#define P4_FREE_IF_LE (-7)\n#define P4_DYNAMIC    (-7)  /* Pointer to memory from sqliteMalloc() */\n#define P4_FUNCDEF    (-8)  /* P4 is a pointer to a FuncDef structure */\n#define P4_KEYINFO    (-9)  /* P4 is a pointer to a KeyInfo structure */\n#define P4_EXPR       (-10) /* P4 is a pointer to an Expr tree */\n#define P4_MEM        (-11) /* P4 is a pointer to a Mem*    structure */\n#define P4_VTAB       (-12) /* P4 is a pointer to an sqlite3_vtab structure */\n#define P4_REAL       (-13) /* P4 is a 64-bit floating point value */\n#define P4_INT64      (-14) /* P4 is a 64-bit signed integer */\n#define P4_INTARRAY   (-15) /* P4 is a vector of 32-bit integers */\n#define P4_FUNCCTX    (-16) /* P4 is a pointer to an sqlite3_context object */\n\n/* Error message codes for OP_Halt */\n#define P5_ConstraintNotNull 1\n#define P5_ConstraintUnique  2\n#define P5_ConstraintCheck   3\n#define P5_ConstraintFK      4\n\n/*\n** The Vdbe.aColName array contains 5n Mem structures, where n is the \n** number of columns of data returned by the statement.\n*/\n#define COLNAME_NAME     0\n#define COLNAME_DECLTYPE 1\n#define COLNAME_DATABASE 2\n#define COLNAME_TABLE    3\n#define COLNAME_COLUMN   4\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define COLNAME_N        5      /* Number of COLNAME_xxx symbols */\n#else\n# ifdef SQLITE_OMIT_DECLTYPE\n#   define COLNAME_N      1      /* Store only the name */\n# else\n#   define COLNAME_N      2      /* Store the name and decltype */\n# endif\n#endif\n\n/*\n** The following macro converts a relative address in the p2 field\n** of a VdbeOp structure into a negative number so that \n** sqlite3VdbeAddOpList() knows that the address is relative.  Calling\n** the macro again restores the address.\n*/\n#define ADDR(X)  (-1-(X))\n\n/*\n** The makefile scans the vdbe.c source file and creates the \"opcodes.h\"\n** header file that defines a number for each opcode used by the VDBE.\n*/\n/************** Include opcodes.h in the middle of vdbe.h ********************/\n/************** Begin file opcodes.h *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the tool/mkopcodeh.tcl script for details */\n#define OP_Savepoint       0\n#define OP_AutoCommit      1\n#define OP_Transaction     2\n#define OP_SorterNext      3 /* jump                                       */\n#define OP_PrevIfOpen      4 /* jump                                       */\n#define OP_NextIfOpen      5 /* jump                                       */\n#define OP_Prev            6 /* jump                                       */\n#define OP_Next            7 /* jump                                       */\n#define OP_Checkpoint      8\n#define OP_JournalMode     9\n#define OP_Vacuum         10\n#define OP_VFilter        11 /* jump, synopsis: iplan=r[P3] zplan='P4'     */\n#define OP_VUpdate        12 /* synopsis: data=r[P3@P2]                    */\n#define OP_Goto           13 /* jump                                       */\n#define OP_Gosub          14 /* jump                                       */\n#define OP_InitCoroutine  15 /* jump                                       */\n#define OP_Yield          16 /* jump                                       */\n#define OP_MustBeInt      17 /* jump                                       */\n#define OP_Jump           18 /* jump                                       */\n#define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */\n#define OP_Once           20 /* jump                                       */\n#define OP_If             21 /* jump                                       */\n#define OP_IfNot          22 /* jump                                       */\n#define OP_IfNullRow      23 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */\n#define OP_SeekLT         24 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekLE         25 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGE         26 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGT         27 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NoConflict     28 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NotFound       29 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_Found          30 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekRowid      31 /* jump, synopsis: intkey=r[P3]               */\n#define OP_NotExists      32 /* jump, synopsis: intkey=r[P3]               */\n#define OP_Last           33 /* jump                                       */\n#define OP_IfSmaller      34 /* jump                                       */\n#define OP_SorterSort     35 /* jump                                       */\n#define OP_Sort           36 /* jump                                       */\n#define OP_Rewind         37 /* jump                                       */\n#define OP_IdxLE          38 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGT          39 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxLT          40 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGE          41 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_RowSetRead     42 /* jump, synopsis: r[P3]=rowset(P1)           */\n#define OP_Or             43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */\n#define OP_And            44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */\n#define OP_RowSetTest     45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */\n#define OP_Program        46 /* jump                                       */\n#define OP_FkIfZero       47 /* jump, synopsis: if fkctr[P1]==0 goto P2    */\n#define OP_IfPos          48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */\n#define OP_IfNotZero      49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */\n#define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */\n#define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */\n#define OP_Ne             52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */\n#define OP_Eq             53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */\n#define OP_Gt             54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */\n#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */\n#define OP_Lt             56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */\n#define OP_Ge             57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */\n#define OP_ElseNotEq      58 /* jump, same as TK_ESCAPE                    */\n#define OP_DecrJumpZero   59 /* jump, synopsis: if (--r[P1])==0 goto P2    */\n#define OP_IncrVacuum     60 /* jump                                       */\n#define OP_VNext          61 /* jump                                       */\n#define OP_Init           62 /* jump, synopsis: Start at P2                */\n#define OP_Return         63\n#define OP_EndCoroutine   64\n#define OP_HaltIfNull     65 /* synopsis: if r[P3]=null halt               */\n#define OP_Halt           66\n#define OP_Integer        67 /* synopsis: r[P2]=P1                         */\n#define OP_Int64          68 /* synopsis: r[P2]=P4                         */\n#define OP_String         69 /* synopsis: r[P2]='P4' (len=P1)              */\n#define OP_Null           70 /* synopsis: r[P2..P3]=NULL                   */\n#define OP_SoftNull       71 /* synopsis: r[P1]=NULL                       */\n#define OP_Blob           72 /* synopsis: r[P2]=P4 (len=P1)                */\n#define OP_Variable       73 /* synopsis: r[P2]=parameter(P1,P4)           */\n#define OP_Move           74 /* synopsis: r[P2@P3]=r[P1@P3]                */\n#define OP_Copy           75 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */\n#define OP_SCopy          76 /* synopsis: r[P2]=r[P1]                      */\n#define OP_IntCopy        77 /* synopsis: r[P2]=r[P1]                      */\n#define OP_ResultRow      78 /* synopsis: output=r[P1@P2]                  */\n#define OP_CollSeq        79\n#define OP_AddImm         80 /* synopsis: r[P1]=r[P1]+P2                   */\n#define OP_RealAffinity   81\n#define OP_Cast           82 /* synopsis: affinity(r[P1])                  */\n#define OP_Permutation    83\n#define OP_BitAnd         84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */\n#define OP_BitOr          85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */\n#define OP_ShiftLeft      86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */\n#define OP_ShiftRight     87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */\n#define OP_Add            88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */\n#define OP_Subtract       89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */\n#define OP_Multiply       90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */\n#define OP_Divide         91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */\n#define OP_Remainder      92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */\n#define OP_Concat         93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */\n#define OP_Compare        94 /* synopsis: r[P1@P3] <-> r[P2@P3]            */\n#define OP_BitNot         95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */\n#define OP_Column         96 /* synopsis: r[P3]=PX                         */\n#define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */\n#define OP_Affinity       98 /* synopsis: affinity(r[P1@P2])               */\n#define OP_MakeRecord     99 /* synopsis: r[P3]=mkrec(r[P1@P2])            */\n#define OP_Count         100 /* synopsis: r[P2]=count()                    */\n#define OP_ReadCookie    101\n#define OP_SetCookie     102\n#define OP_ReopenIdx     103 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenRead      104 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenWrite     105 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenDup       106\n#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2                       */\n#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2                       */\n#define OP_SorterOpen    109\n#define OP_SequenceTest  110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */\n#define OP_OpenPseudo    111 /* synopsis: P3 columns in r[P2]              */\n#define OP_Close         112\n#define OP_ColumnsUsed   113\n#define OP_Sequence      114 /* synopsis: r[P2]=cursor[P1].ctr++           */\n#define OP_NewRowid      115 /* synopsis: r[P2]=rowid                      */\n#define OP_Insert        116 /* synopsis: intkey=r[P3] data=r[P2]          */\n#define OP_InsertInt     117 /* synopsis: intkey=P3 data=r[P2]             */\n#define OP_Delete        118\n#define OP_ResetCount    119\n#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */\n#define OP_SorterData    121 /* synopsis: r[P2]=data                       */\n#define OP_RowData       122 /* synopsis: r[P2]=data                       */\n#define OP_Rowid         123 /* synopsis: r[P2]=rowid                      */\n#define OP_NullRow       124\n#define OP_SeekEnd       125\n#define OP_SorterInsert  126 /* synopsis: key=r[P2]                        */\n#define OP_IdxInsert     127 /* synopsis: key=r[P2]                        */\n#define OP_IdxDelete     128 /* synopsis: key=r[P2@P3]                     */\n#define OP_DeferredSeek  129 /* synopsis: Move P3 to P1.rowid if needed    */\n#define OP_IdxRowid      130 /* synopsis: r[P2]=rowid                      */\n#define OP_Destroy       131\n#define OP_Real          132 /* same as TK_FLOAT, synopsis: r[P2]=P4       */\n#define OP_Clear         133\n#define OP_ResetSorter   134\n#define OP_CreateBtree   135 /* synopsis: r[P2]=root iDb=P1 flags=P3       */\n#define OP_SqlExec       136\n#define OP_ParseSchema   137\n#define OP_LoadAnalysis  138\n#define OP_DropTable     139\n#define OP_DropIndex     140\n#define OP_DropTrigger   141\n#define OP_IntegrityCk   142\n#define OP_RowSetAdd     143 /* synopsis: rowset(P1)=r[P2]                 */\n#define OP_Param         144\n#define OP_FkCounter     145 /* synopsis: fkctr[P1]+=P2                    */\n#define OP_MemMax        146 /* synopsis: r[P1]=max(r[P1],r[P2])           */\n#define OP_OffsetLimit   147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */\n#define OP_AggStep0      148 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggStep       149 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggFinal      150 /* synopsis: accum=r[P1] N=P2                 */\n#define OP_Expire        151\n#define OP_TableLock     152 /* synopsis: iDb=P1 root=P2 write=P3          */\n#define OP_VBegin        153\n#define OP_VCreate       154\n#define OP_VDestroy      155\n#define OP_VOpen         156\n#define OP_VColumn       157 /* synopsis: r[P3]=vcolumn(P2)                */\n#define OP_VRename       158\n#define OP_Pagecount     159\n#define OP_MaxPgcnt      160\n#define OP_PureFunc0     161\n#define OP_Function0     162 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_PureFunc      163\n#define OP_Function      164 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_CursorHint    165\n#define OP_Noop          166\n#define OP_Explain       167\n\n/* Properties such as \"out2\" or \"jump\" that are specified in\n** comments following the \"case\" for each opcode in the vdbe.c\n** are encoded into bitvectors as follows:\n*/\n#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */\n#define OPFLG_IN1         0x02  /* in1:   P1 is an input */\n#define OPFLG_IN2         0x04  /* in2:   P2 is an input */\n#define OPFLG_IN3         0x08  /* in3:   P3 is an input */\n#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */\n#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */\n#define OPFLG_INITIALIZER {\\\n/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\\\n/*   8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\\\n/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\\\n/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\\\n/*  32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\\\n/*  40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\\\n/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\\\n/*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\\\n/*  64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\\\n/*  72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\\\n/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x26, 0x26, 0x26, 0x26,\\\n/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\\\n/*  96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\\\n/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\\\n/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04,\\\n/* 128 */ 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10,\\\n/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\\\n/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\\\n/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\\\n/* 160 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n}\n\n/* The sqlite3P2Values() routine is able to run faster if it knows\n** the value of the largest JUMP opcode.  The smaller the maximum\n** JUMP opcode the better, so the mkopcodeh.tcl script that\n** generated this include file strives to group all JUMP opcodes\n** together near the beginning of the list.\n*/\n#define SQLITE_MX_JUMP_OPCODE  62  /* Maximum JUMP opcode */\n\n/************** End of opcodes.h *********************************************/\n/************** Continuing where we left off in vdbe.h ***********************/\n\n/*\n** Additional non-public SQLITE_PREPARE_* flags\n*/\n#define SQLITE_PREPARE_SAVESQL  0x80  /* Preserve SQL text */\n#define SQLITE_PREPARE_MASK     0x0f  /* Mask of public flags */\n\n/*\n** Prototypes for the VDBE interface.  See comments on the implementation\n** for a description of what each of these routines does.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*);\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*);\nSQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);\nSQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe*,int);\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE   void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);\nSQLITE_PRIVATE   void sqlite3VdbeVerifyNoResultRow(Vdbe *p);\n#else\n# define sqlite3VdbeVerifyNoMallocRequired(A,B)\n# define sqlite3VdbeVerifyNoResultRow(A)\n#endif\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);\nSQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);\nSQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);\nSQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);\nSQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);\nSQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);\nSQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int);\n#ifndef SQLITE_OMIT_TRACE\nSQLITE_PRIVATE   char *sqlite3VdbeExpandSql(Vdbe*, const char*);\n#endif\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);\n\nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);\n\ntypedef int (*RecordCompare)(int,const void*,UnpackedRecord*);\nSQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);\n#endif\n\nSQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);\n\n/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on\n** each VDBE opcode.\n**\n** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op\n** comments in VDBE programs that show key decision points in the code\n** generator.\n*/\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\nSQLITE_PRIVATE   void sqlite3VdbeComment(Vdbe*, const char*, ...);\n# define VdbeComment(X)  sqlite3VdbeComment X\nSQLITE_PRIVATE   void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);\n# define VdbeNoopComment(X)  sqlite3VdbeNoopComment X\n# ifdef SQLITE_ENABLE_MODULE_COMMENTS\n#   define VdbeModuleComment(X)  sqlite3VdbeNoopComment X\n# else\n#   define VdbeModuleComment(X)\n# endif\n#else\n# define VdbeComment(X)\n# define VdbeNoopComment(X)\n# define VdbeModuleComment(X)\n#endif\n\n/*\n** The VdbeCoverage macros are used to set a coverage testing point\n** for VDBE branch instructions.  The coverage testing points are line\n** numbers in the sqlite3.c source file.  VDBE branch coverage testing\n** only works with an amalagmation build.  That's ok since a VDBE branch\n** coverage build designed for testing the test suite only.  No application\n** should ever ship with VDBE branch coverage measuring turned on.\n**\n**    VdbeCoverage(v)                  // Mark the previously coded instruction\n**                                     // as a branch\n**\n**    VdbeCoverageIf(v, conditional)   // Mark previous if conditional true\n**\n**    VdbeCoverageAlwaysTaken(v)       // Previous branch is always taken\n**\n**    VdbeCoverageNeverTaken(v)        // Previous branch is never taken\n**\n** Every VDBE branch operation must be tagged with one of the macros above.\n** If not, then when \"make test\" is run with -DSQLITE_VDBE_COVERAGE and\n** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()\n** routine in vdbe.c, alerting the developer to the missed tag.\n*/\n#ifdef SQLITE_VDBE_COVERAGE\nSQLITE_PRIVATE   void sqlite3VdbeSetLineNumber(Vdbe*,int);\n# define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);\n# define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);\n# define VDBE_OFFSET_LINENO(x) (__LINE__+x)\n#else\n# define VdbeCoverage(v)\n# define VdbeCoverageIf(v,x)\n# define VdbeCoverageAlwaysTaken(v)\n# define VdbeCoverageNeverTaken(v)\n# define VDBE_OFFSET_LINENO(x) 0\n#endif\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nSQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);\n#else\n# define sqlite3VdbeScanStatus(a,b,c,d,e)\n#endif\n\n#endif /* SQLITE_VDBE_H */\n\n/************** End of vdbe.h ************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pager.h in the middle of sqliteInt.h *****************/\n/************** Begin file pager.h *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem.  The page cache subsystem reads and writes a file a page\n** at a time and provides a journal for rollback.\n*/\n\n#ifndef SQLITE_PAGER_H\n#define SQLITE_PAGER_H\n\n/*\n** Default maximum size for persistent journal files. A negative \n** value means no limit. This value may be overridden using the \n** sqlite3PagerJournalSizeLimit() API. See also \"PRAGMA journal_size_limit\".\n*/\n#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1\n#endif\n\n/*\n** The type used to represent a page number.  The first page in a file\n** is called page 1.  0 is used to represent \"not a page\".\n*/\ntypedef u32 Pgno;\n\n/*\n** Each open file is managed by a separate instance of the \"Pager\" structure.\n*/\ntypedef struct Pager Pager;\n\n/*\n** Handle type for pages.\n*/\ntypedef struct PgHdr DbPage;\n\n/*\n** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is\n** reserved for working around a windows/posix incompatibility). It is\n** used in the journal to signify that the remainder of the journal file \n** is devoted to storing a master journal name - there are no more pages to\n** roll back. See comments for function writeMasterJournal() in pager.c \n** for details.\n*/\n#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))\n\n/*\n** Allowed values for the flags parameter to sqlite3PagerOpen().\n**\n** NOTE: These values must match the corresponding BTREE_ values in btree.h.\n*/\n#define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */\n#define PAGER_MEMORY        0x0002    /* In-memory database */\n\n/*\n** Valid values for the second argument to sqlite3PagerLockingMode().\n*/\n#define PAGER_LOCKINGMODE_QUERY      -1\n#define PAGER_LOCKINGMODE_NORMAL      0\n#define PAGER_LOCKINGMODE_EXCLUSIVE   1\n\n/*\n** Numeric constants that encode the journalmode.\n**\n** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)\n** are exposed in the API via the \"PRAGMA journal_mode\" command and\n** therefore cannot be changed without a compatibility break.\n*/\n#define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */\n#define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */\n#define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */\n#define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */\n#define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */\n#define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */\n#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */\n\n/*\n** Flags that make up the mask passed to sqlite3PagerGet().\n*/\n#define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */\n#define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */\n\n/*\n** Flags for sqlite3PagerSetFlags()\n**\n** Value constraints (enforced via assert()):\n**    PAGER_FULLFSYNC      == SQLITE_FullFSync\n**    PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync\n**    PAGER_CACHE_SPILL    == SQLITE_CacheSpill\n*/\n#define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */\n#define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */\n#define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */\n#define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */\n#define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */\n#define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */\n#define PAGER_CKPT_FULLFSYNC        0x10  /* PRAGMA checkpoint_fullfsync=ON */\n#define PAGER_CACHESPILL            0x20  /* PRAGMA cache_spill=ON */\n#define PAGER_FLAGS_MASK            0x38  /* All above except SYNCHRONOUS */\n\n/*\n** The remainder of this file contains the declarations of the functions\n** that make up the Pager sub-system API. See source code comments for \n** a detailed description of each routine.\n*/\n\n/* Open and close a Pager connection. */ \nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs*,\n  Pager **ppPager,\n  const char*,\n  int,\n  int,\n  int,\n  void(*)(DbPage*)\n);\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*);\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);\n\n/* Functions used to configure a Pager object. */\nSQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int);\n#ifdef SQLITE_HAS_CODEC\nSQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*);\n#endif\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int);\nSQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int);\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager*);\nSQLITE_PRIVATE void sqlite3PagerSetFlags(Pager*,unsigned);\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *, int);\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager*);\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64);\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*);\nSQLITE_PRIVATE int sqlite3PagerFlush(Pager*);\n\n/* Functions used to obtain and release page references. */ \nSQLITE_PRIVATE int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage*);\n\n/* Operations on page references. */\nSQLITE_PRIVATE int sqlite3PagerWrite(DbPage*);\nSQLITE_PRIVATE void sqlite3PagerDontWrite(DbPage*);\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage*);\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); \nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); \n\n/* Functions used to manage pager transactions and savepoints. */\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager*, int*);\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager*);\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster);\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*);\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager*);\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);\nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);\n\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3PagerWalSupported(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerWalCallback(Pager *pPager);\nSQLITE_PRIVATE   int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);\nSQLITE_PRIVATE   int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);\n# ifdef SQLITE_DIRECT_OVERFLOW_READ\nSQLITE_PRIVATE   int sqlite3PagerUseWal(Pager *pPager, Pgno);\n# endif\n# ifdef SQLITE_ENABLE_SNAPSHOT\nSQLITE_PRIVATE   int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);\nSQLITE_PRIVATE   int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE   int sqlite3PagerSnapshotRecover(Pager *pPager);\n# endif\n#else\n# define sqlite3PagerUseWal(x,y) 0\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\nSQLITE_PRIVATE   int sqlite3PagerWalFramesize(Pager *pPager);\n#endif\n\n/* Functions used to query pager state and configuration. */\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);\nSQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3PagerRefcount(Pager*);\n#endif\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);\nSQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager*);\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*);\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*);\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*);\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*);\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*);\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *);\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager*);\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);\n\n/* Functions used to truncate the database file. */\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);\n\nSQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);\n\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)\nSQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);\n#endif\n\n/* Functions to support testing and debugging. */\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\nSQLITE_PRIVATE   Pgno sqlite3PagerPagenumber(DbPage*);\nSQLITE_PRIVATE   int sqlite3PagerIswriteable(DbPage*);\n#endif\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int *sqlite3PagerStats(Pager*);\nSQLITE_PRIVATE   void sqlite3PagerRefdump(Pager*);\n  void disable_simulated_io_errors(void);\n  void enable_simulated_io_errors(void);\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n#endif /* SQLITE_PAGER_H */\n\n/************** End of pager.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include pcache.h in the middle of sqliteInt.h ****************/\n/************** Begin file pcache.h ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem. \n*/\n\n#ifndef _PCACHE_H_\n\ntypedef struct PgHdr PgHdr;\ntypedef struct PCache PCache;\n\n/*\n** Every page in the cache is controlled by an instance of the following\n** structure.\n*/\nstruct PgHdr {\n  sqlite3_pcache_page *pPage;    /* Pcache object page handle */\n  void *pData;                   /* Page data */\n  void *pExtra;                  /* Extra content */\n  PCache *pCache;                /* PRIVATE: Cache that owns this page */\n  PgHdr *pDirty;                 /* Transient list of dirty sorted by pgno */\n  Pager *pPager;                 /* The pager this page is part of */\n  Pgno pgno;                     /* Page number for this page */\n#ifdef SQLITE_CHECK_PAGES\n  u32 pageHash;                  /* Hash of page content */\n#endif\n  u16 flags;                     /* PGHDR flags defined below */\n\n  /**********************************************************************\n  ** Elements above, except pCache, are public.  All that follow are \n  ** private to pcache.c and should not be accessed by other modules.\n  ** pCache is grouped with the public elements for efficiency.\n  */\n  i16 nRef;                      /* Number of users of this page */\n  PgHdr *pDirtyNext;             /* Next element in list of dirty pages */\n  PgHdr *pDirtyPrev;             /* Previous element in list of dirty pages */\n                          /* NB: pDirtyNext and pDirtyPrev are undefined if the\n                          ** PgHdr object is not dirty */\n};\n\n/* Bit values for PgHdr.flags */\n#define PGHDR_CLEAN           0x001  /* Page not on the PCache.pDirty list */\n#define PGHDR_DIRTY           0x002  /* Page is on the PCache.pDirty list */\n#define PGHDR_WRITEABLE       0x004  /* Journaled and ready to modify */\n#define PGHDR_NEED_SYNC       0x008  /* Fsync the rollback journal before\n                                     ** writing this page to the database */\n#define PGHDR_DONT_WRITE      0x010  /* Do not write content to disk */\n#define PGHDR_MMAP            0x020  /* This is an mmap page object */\n\n#define PGHDR_WAL_APPEND      0x040  /* Appended to wal file */\n\n/* Initialize and shutdown the page cache subsystem */\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void);\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void);\n\n/* Page cache buffer management:\n** These routines implement SQLITE_CONFIG_PAGECACHE.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *, int sz, int n);\n\n/* Create a new pager cache.\n** Under memory stress, invoke xStress to try to make pages clean.\n** Only clean and unpinned pages can be reclaimed.\n*/\nSQLITE_PRIVATE int sqlite3PcacheOpen(\n  int szPage,                    /* Size of every page */\n  int szExtra,                   /* Extra space associated with each page */\n  int bPurgeable,                /* True if pages are on backing store */\n  int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */\n  void *pStress,                 /* Argument to xStress */\n  PCache *pToInit                /* Preallocated space for the PCache */\n);\n\n/* Modify the page-size after the cache has been created. */\nSQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *, int);\n\n/* Return the size in bytes of a PCache object.  Used to preallocate\n** storage space.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void);\n\n/* One release per successful fetch.  Page is pinned until released.\n** Reference counted. \n*/\nSQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(PCache*, Pgno, int createFlag);\nSQLITE_PRIVATE int sqlite3PcacheFetchStress(PCache*, Pgno, sqlite3_pcache_page**);\nSQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(PCache*, Pgno, sqlite3_pcache_page *pPage);\nSQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*);\n\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr*);    /* Make sure page is marked dirty */\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr*);    /* Mark a single page as clean */\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache*);    /* Mark all dirty list pages as clean */\nSQLITE_PRIVATE void sqlite3PcacheClearWritable(PCache*);\n\n/* Change a page number.  Used by incr-vacuum. */\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr*, Pgno);\n\n/* Remove all pages with pgno>x.  Reset the cache if x==0 */\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache*, Pgno x);\n\n/* Get a list of all dirty pages in the cache, sorted by page number */\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache*);\n\n/* Reset and close the cache object */\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache*);\n\n/* Clear flags from pages of the page cache */\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *);\n\n/* Discard the contents of the cache */\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache*);\n\n/* Return the total number of outstanding page references */\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*);\n\n/* Increment the reference count of an existing page */\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*);\n\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*);\n\n/* Return the total number of pages stored in the cache */\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache*);\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/* Iterate through all dirty pages currently stored in the cache. This\n** interface is only available if SQLITE_CHECK_PAGES is defined when the \n** library is built.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));\n#endif\n\n#if defined(SQLITE_DEBUG)\n/* Check invariants on a PgHdr object */\nSQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr*);\n#endif\n\n/* Set and get the suggested cache-size for the specified pager-cache.\n**\n** If no global maximum is configured, then the system attempts to limit\n** the total number of pages cached by purgeable pager-caches to the sum\n** of the suggested cache-sizes.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *);\n#endif\n\n/* Set or get the suggested spill-size for the specified pager-cache.\n**\n** The spill-size is the minimum number of pages in cache before the cache\n** will attempt to spill dirty pages by calling xStress.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *, int);\n\n/* Free up as much memory as possible from the page cache */\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache*);\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/* Try to return memory used by the pcache module to the main memory heap */\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int);\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*);\n#endif\n\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void);\n\n/* Return the header size */\nSQLITE_PRIVATE int sqlite3HeaderSizePcache(void);\nSQLITE_PRIVATE int sqlite3HeaderSizePcache1(void);\n\n/* Number of dirty pages as a percentage of the configured cache size */\nSQLITE_PRIVATE int sqlite3PCachePercentDirty(PCache*);\n\n#endif /* _PCACHE_H_ */\n\n/************** End of pcache.h **********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include os.h in the middle of sqliteInt.h ********************/\n/************** Begin file os.h **********************************************/\n/*\n** 2001 September 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file (together with is companion C source-code file\n** \"os.c\") attempt to abstract the underlying operating system so that\n** the SQLite library will work on both POSIX and windows systems.\n**\n** This header file is #include-ed by sqliteInt.h and thus ends up\n** being included by every source file.\n*/\n#ifndef _SQLITE_OS_H_\n#define _SQLITE_OS_H_\n\n/*\n** Attempt to automatically detect the operating system and setup the\n** necessary pre-processor macros for it.\n*/\n/************** Include os_setup.h in the middle of os.h *********************/\n/************** Begin file os_setup.h ****************************************/\n/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains pre-processor directives related to operating system\n** detection and/or setup.\n*/\n#ifndef SQLITE_OS_SETUP_H\n#define SQLITE_OS_SETUP_H\n\n/*\n** Figure out if we are dealing with Unix, Windows, or some other operating\n** system.\n**\n** After the following block of preprocess macros, all of SQLITE_OS_UNIX,\n** SQLITE_OS_WIN, and SQLITE_OS_OTHER will defined to either 1 or 0.  One of\n** the three will be 1.  The other two will be 0.\n*/\n#if defined(SQLITE_OS_OTHER)\n#  if SQLITE_OS_OTHER==1\n#    undef SQLITE_OS_UNIX\n#    define SQLITE_OS_UNIX 0\n#    undef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  else\n#    undef SQLITE_OS_OTHER\n#  endif\n#endif\n#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER)\n#  define SQLITE_OS_OTHER 0\n#  ifndef SQLITE_OS_WIN\n#    if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || \\\n        defined(__MINGW32__) || defined(__BORLANDC__)\n#      define SQLITE_OS_WIN 1\n#      define SQLITE_OS_UNIX 0\n#    else\n#      define SQLITE_OS_WIN 0\n#      define SQLITE_OS_UNIX 1\n#    endif\n#  else\n#    define SQLITE_OS_UNIX 0\n#  endif\n#else\n#  ifndef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  endif\n#endif\n\n#endif /* SQLITE_OS_SETUP_H */\n\n/************** End of os_setup.h ********************************************/\n/************** Continuing where we left off in os.h *************************/\n\n/* If the SET_FULLSYNC macro is not defined above, then make it\n** a no-op\n*/\n#ifndef SET_FULLSYNC\n# define SET_FULLSYNC(x,y)\n#endif\n\n/*\n** The default size of a disk sector\n*/\n#ifndef SQLITE_DEFAULT_SECTOR_SIZE\n# define SQLITE_DEFAULT_SECTOR_SIZE 4096\n#endif\n\n/*\n** Temporary files are named starting with this prefix followed by 16 random\n** alphanumeric characters, and no file extension. They are stored in the\n** OS's standard temporary file directory, and are deleted prior to exit.\n** If sqlite is being embedded in another program, you may wish to change the\n** prefix to reflect your program's name, so that if your program exits\n** prematurely, old temporary files can be easily identified. This can be done\n** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.\n**\n** 2006-10-31:  The default prefix used to be \"sqlite_\".  But then\n** Mcafee started using SQLite in their anti-virus product and it\n** started putting files with the \"sqlite\" name in the c:/temp folder.\n** This annoyed many windows users.  Those users would then do a \n** Google search for \"sqlite\", find the telephone numbers of the\n** developers and call to wake them up at night and complain.\n** For this reason, the default name prefix is changed to be \"sqlite\" \n** spelled backwards.  So the temp files are still identified, but\n** anybody smart enough to figure out the code is also likely smart\n** enough to know that calling the developer will not help get rid\n** of the file.\n*/\n#ifndef SQLITE_TEMP_FILE_PREFIX\n# define SQLITE_TEMP_FILE_PREFIX \"etilqs_\"\n#endif\n\n/*\n** The following values may be passed as the second argument to\n** sqlite3OsLock(). The various locks exhibit the following semantics:\n**\n** SHARED:    Any number of processes may hold a SHARED lock simultaneously.\n** RESERVED:  A single process may hold a RESERVED lock on a file at\n**            any time. Other processes may hold and obtain new SHARED locks.\n** PENDING:   A single process may hold a PENDING lock on a file at\n**            any one time. Existing SHARED locks may persist, but no new\n**            SHARED locks may be obtained by other processes.\n** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.\n**\n** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a\n** process that requests an EXCLUSIVE lock may actually obtain a PENDING\n** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to\n** sqlite3OsLock().\n*/\n#define NO_LOCK         0\n#define SHARED_LOCK     1\n#define RESERVED_LOCK   2\n#define PENDING_LOCK    3\n#define EXCLUSIVE_LOCK  4\n\n/*\n** File Locking Notes:  (Mostly about windows but also some info for Unix)\n**\n** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because\n** those functions are not available.  So we use only LockFile() and\n** UnlockFile().\n**\n** LockFile() prevents not just writing but also reading by other processes.\n** A SHARED_LOCK is obtained by locking a single randomly-chosen \n** byte out of a specific range of bytes. The lock byte is obtained at \n** random so two separate readers can probably access the file at the \n** same time, unless they are unlucky and choose the same lock byte.\n** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range.\n** There can only be one writer.  A RESERVED_LOCK is obtained by locking\n** a single byte of the file that is designated as the reserved lock byte.\n** A PENDING_LOCK is obtained by locking a designated byte different from\n** the RESERVED_LOCK byte.\n**\n** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,\n** which means we can use reader/writer locks.  When reader/writer locks\n** are used, the lock is placed on the same range of bytes that is used\n** for probabilistic locking in Win95/98/ME.  Hence, the locking scheme\n** will support two or more Win95 readers or two or more WinNT readers.\n** But a single Win95 reader will lock out all WinNT readers and a single\n** WinNT reader will lock out all other Win95 readers.\n**\n** The following #defines specify the range of bytes used for locking.\n** SHARED_SIZE is the number of bytes available in the pool from which\n** a random byte is selected for a shared lock.  The pool of bytes for\n** shared locks begins at SHARED_FIRST. \n**\n** The same locking strategy and\n** byte ranges are used for Unix.  This leaves open the possibility of having\n** clients on win95, winNT, and unix all talking to the same shared file\n** and all locking correctly.  To do so would require that samba (or whatever\n** tool is being used for file sharing) implements locks correctly between\n** windows and unix.  I'm guessing that isn't likely to happen, but by\n** using the same locking range we are at least open to the possibility.\n**\n** Locking in windows is manditory.  For this reason, we cannot store\n** actual data in the bytes used for locking.  The pager never allocates\n** the pages involved in locking therefore.  SHARED_SIZE is selected so\n** that all locks will fit on a single page even at the minimum page size.\n** PENDING_BYTE defines the beginning of the locks.  By default PENDING_BYTE\n** is set high so that we don't have to allocate an unused page except\n** for very large databases.  But one should test the page skipping logic \n** by setting PENDING_BYTE low and running the entire regression suite.\n**\n** Changing the value of PENDING_BYTE results in a subtly incompatible\n** file format.  Depending on how it is changed, you might not notice\n** the incompatibility right away, even running a full regression test.\n** The default location of PENDING_BYTE is the first byte past the\n** 1GB boundary.\n**\n*/\n#ifdef SQLITE_OMIT_WSD\n# define PENDING_BYTE     (0x40000000)\n#else\n# define PENDING_BYTE      sqlite3PendingByte\n#endif\n#define RESERVED_BYTE     (PENDING_BYTE+1)\n#define SHARED_FIRST      (PENDING_BYTE+2)\n#define SHARED_SIZE       510\n\n/*\n** Wrapper around OS specific sqlite3_os_init() function.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void);\n\n/* \n** Functions for accessing sqlite3_file methods \n*/\nSQLITE_PRIVATE void sqlite3OsClose(sqlite3_file*);\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file*, i64 size);\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize);\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int);\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*);\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file*,int,void*);\n#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id);\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE int sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **);\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int, int, int);\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id);\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int);\n#endif /* SQLITE_OMIT_WAL */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64, int, void **);\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *, i64, void *);\n\n\n/* \n** Functions for accessing sqlite3_vfs methods \n*/\nSQLITE_PRIVATE int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *);\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *, const char *, int);\nSQLITE_PRIVATE int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut);\nSQLITE_PRIVATE int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *, const char *);\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void);\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *);\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int);\nSQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs*);\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);\n\n/*\n** Convenience functions for opening and closing files using \n** sqlite3_malloc() to obtain space for the file-handle structure.\n*/\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);\nSQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *);\n\n#endif /* _SQLITE_OS_H_ */\n\n/************** End of os.h **************************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n/************** Include mutex.h in the middle of sqliteInt.h *****************/\n/************** Begin file mutex.h *******************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the common header for all mutex implementations.\n** The sqliteInt.h header #includes this file so that it is available\n** to all source files.  We break it out in an effort to keep the code\n** better organized.\n**\n** NOTE:  source files should *not* #include this header file directly.\n** Source files should #include the sqliteInt.h file and let that file\n** include this one indirectly.\n*/\n\n\n/*\n** Figure out what version of the code to use.  The choices are\n**\n**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The\n**                             mutexes implementation cannot be overridden\n**                             at start-time.\n**\n**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No\n**                             mutual exclusion is provided.  But this\n**                             implementation can be overridden at\n**                             start-time.\n**\n**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.\n**\n**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.\n*/\n#if !SQLITE_THREADSAFE\n# define SQLITE_MUTEX_OMIT\n#endif\n#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)\n#  if SQLITE_OS_UNIX\n#    define SQLITE_MUTEX_PTHREADS\n#  elif SQLITE_OS_WIN\n#    define SQLITE_MUTEX_W32\n#  else\n#    define SQLITE_MUTEX_NOOP\n#  endif\n#endif\n\n#ifdef SQLITE_MUTEX_OMIT\n/*\n** If this is a no-op implementation, implement everything as macros.\n*/\n#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)\n#define sqlite3_mutex_free(X)\n#define sqlite3_mutex_enter(X)    \n#define sqlite3_mutex_try(X)      SQLITE_OK\n#define sqlite3_mutex_leave(X)    \n#define sqlite3_mutex_held(X)     ((void)(X),1)\n#define sqlite3_mutex_notheld(X)  ((void)(X),1)\n#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)\n#define sqlite3MutexInit()        SQLITE_OK\n#define sqlite3MutexEnd()\n#define MUTEX_LOGIC(X)\n#else\n#define MUTEX_LOGIC(X)            X\n#endif /* defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.h ***********************************************/\n/************** Continuing where we left off in sqliteInt.h ******************/\n\n/* The SQLITE_EXTRA_DURABLE compile-time option used to set the default\n** synchronous setting to EXTRA.  It is no longer supported.\n*/\n#ifdef SQLITE_EXTRA_DURABLE\n# warning Use SQLITE_DEFAULT_SYNCHRONOUS=3 instead of SQLITE_EXTRA_DURABLE\n# define SQLITE_DEFAULT_SYNCHRONOUS 3\n#endif\n\n/*\n** Default synchronous levels.\n**\n** Note that (for historcal reasons) the PAGER_SYNCHRONOUS_* macros differ\n** from the SQLITE_DEFAULT_SYNCHRONOUS value by 1.\n**\n**           PAGER_SYNCHRONOUS       DEFAULT_SYNCHRONOUS\n**   OFF           1                         0\n**   NORMAL        2                         1\n**   FULL          3                         2\n**   EXTRA         4                         3\n**\n** The \"PRAGMA synchronous\" statement also uses the zero-based numbers.\n** In other words, the zero-based numbers are used for all external interfaces\n** and the one-based values are used internally.\n*/\n#ifndef SQLITE_DEFAULT_SYNCHRONOUS\n# define SQLITE_DEFAULT_SYNCHRONOUS 2\n#endif\n#ifndef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n# define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS\n#endif\n\n/*\n** Each database file to be accessed by the system is an instance\n** of the following structure.  There are normally two of these structures\n** in the sqlite.aDb[] array.  aDb[0] is the main database file and\n** aDb[1] is the database file used to hold temporary tables.  Additional\n** databases may be attached.\n*/\nstruct Db {\n  char *zDbSName;      /* Name of this database. (schema name, not filename) */\n  Btree *pBt;          /* The B*Tree structure for this database file */\n  u8 safety_level;     /* How aggressive at syncing data to disk */\n  u8 bSyncSet;         /* True if \"PRAGMA synchronous=N\" has been run */\n  Schema *pSchema;     /* Pointer to database schema (possibly shared) */\n};\n\n/*\n** An instance of the following structure stores a database schema.\n**\n** Most Schema objects are associated with a Btree.  The exception is\n** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.\n** In shared cache mode, a single Schema object can be shared by multiple\n** Btrees that refer to the same underlying BtShared object.\n**\n** Schema objects are automatically deallocated when the last Btree that\n** references them is destroyed.   The TEMP Schema is manually freed by\n** sqlite3_close().\n*\n** A thread must be holding a mutex on the corresponding Btree in order\n** to access Schema content.  This implies that the thread must also be\n** holding a mutex on the sqlite3 connection pointer that owns the Btree.\n** For a TEMP Schema, only the connection mutex is required.\n*/\nstruct Schema {\n  int schema_cookie;   /* Database schema version number for this file */\n  int iGeneration;     /* Generation counter.  Incremented with each change */\n  Hash tblHash;        /* All tables indexed by name */\n  Hash idxHash;        /* All (named) indices indexed by name */\n  Hash trigHash;       /* All triggers indexed by name */\n  Hash fkeyHash;       /* All foreign keys by referenced table name */\n  Table *pSeqTab;      /* The sqlite_sequence table used by AUTOINCREMENT */\n  u8 file_format;      /* Schema format version for this file */\n  u8 enc;              /* Text encoding used by this database */\n  u16 schemaFlags;     /* Flags associated with this schema */\n  int cache_size;      /* Number of pages to use in the cache */\n};\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Db.pSchema->flags field.\n*/\n#define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))\n#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)\n#define DbSetProperty(D,I,P)     (D)->aDb[I].pSchema->schemaFlags|=(P)\n#define DbClearProperty(D,I,P)   (D)->aDb[I].pSchema->schemaFlags&=~(P)\n\n/*\n** Allowed values for the DB.pSchema->flags field.\n**\n** The DB_SchemaLoaded flag is set after the database schema has been\n** read into internal hash tables.\n**\n** DB_UnresetViews means that one or more views have column names that\n** have been filled out.  If the schema changes, these column names might\n** changes and so the view will need to be reset.\n*/\n#define DB_SchemaLoaded    0x0001  /* The schema has been loaded */\n#define DB_UnresetViews    0x0002  /* Some views have defined column names */\n#define DB_Empty           0x0004  /* The file is empty (length 0 bytes) */\n#define DB_ResetWanted     0x0008  /* Reset the schema when nSchemaLock==0 */\n\n/*\n** The number of different kinds of things that can be limited\n** using the sqlite3_limit() interface.\n*/\n#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)\n\n/*\n** Lookaside malloc is a set of fixed-size buffers that can be used\n** to satisfy small transient memory allocation requests for objects\n** associated with a particular database connection.  The use of\n** lookaside malloc provides a significant performance enhancement\n** (approx 10%) by avoiding numerous malloc/free requests while parsing\n** SQL statements.\n**\n** The Lookaside structure holds configuration information about the\n** lookaside malloc subsystem.  Each available memory allocation in\n** the lookaside subsystem is stored on a linked list of LookasideSlot\n** objects.\n**\n** Lookaside allocations are only allowed for objects that are associated\n** with a particular database connection.  Hence, schema information cannot\n** be stored in lookaside because in shared cache mode the schema information\n** is shared by multiple database connections.  Therefore, while parsing\n** schema information, the Lookaside.bEnabled flag is cleared so that\n** lookaside allocations are not used to construct the schema objects.\n*/\nstruct Lookaside {\n  u32 bDisable;           /* Only operate the lookaside when zero */\n  u16 sz;                 /* Size of each buffer in bytes */\n  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */\n  u32 nSlot;              /* Number of lookaside slots allocated */\n  u32 anStat[3];          /* 0: hits.  1: size misses.  2: full misses */\n  LookasideSlot *pInit;   /* List of buffers not previously used */\n  LookasideSlot *pFree;   /* List of available buffers */\n  void *pStart;           /* First byte of available memory space */\n  void *pEnd;             /* First byte past end of available space */\n};\nstruct LookasideSlot {\n  LookasideSlot *pNext;    /* Next buffer in the list of free buffers */\n};\n\n/*\n** A hash table for built-in function definitions.  (Application-defined\n** functions use a regular table table from hash.h.)\n**\n** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.\n** Collisions are on the FuncDef.u.pHash chain.\n*/\n#define SQLITE_FUNC_HASH_SZ 23\nstruct FuncDefHash {\n  FuncDef *a[SQLITE_FUNC_HASH_SZ];       /* Hash table for functions */\n};\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** Information held in the \"sqlite3\" database connection object and used\n** to manage user authentication.\n*/\ntypedef struct sqlite3_userauth sqlite3_userauth;\nstruct sqlite3_userauth {\n  u8 authLevel;                 /* Current authentication level */\n  int nAuthPW;                  /* Size of the zAuthPW in bytes */\n  char *zAuthPW;                /* Password used to authenticate */\n  char *zAuthUser;              /* User name used to authenticate */\n};\n\n/* Allowed values for sqlite3_userauth.authLevel */\n#define UAUTH_Unknown     0     /* Authentication not yet checked */\n#define UAUTH_Fail        1     /* User authentication failed */\n#define UAUTH_User        2     /* Authenticated as a normal user */\n#define UAUTH_Admin       3     /* Authenticated as an administrator */\n\n/* Functions used only by user authorization logic */\nSQLITE_PRIVATE int sqlite3UserAuthTable(const char*);\nSQLITE_PRIVATE int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);\nSQLITE_PRIVATE void sqlite3UserAuthInit(sqlite3*);\nSQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);\n\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n/*\n** typedef for the authorization callback function.\n*/\n#ifdef SQLITE_USER_AUTHENTICATION\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*, const char*);\n#else\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*);\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/* This is an extra SQLITE_TRACE macro that indicates \"legacy\" tracing\n** in the style of sqlite3_trace()\n*/\n#define SQLITE_TRACE_LEGACY  0x80\n#else\n#define SQLITE_TRACE_LEGACY  0\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n\n/*\n** Each database connection is an instance of the following structure.\n*/\nstruct sqlite3 {\n  sqlite3_vfs *pVfs;            /* OS Interface */\n  struct Vdbe *pVdbe;           /* List of active virtual machines */\n  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */\n  sqlite3_mutex *mutex;         /* Connection mutex */\n  Db *aDb;                      /* All backends */\n  int nDb;                      /* Number of backends currently in use */\n  u32 mDbFlags;                 /* flags recording internal state */\n  u32 flags;                    /* flags settable by pragmas. See below */\n  i64 lastRowid;                /* ROWID of most recent insert (see above) */\n  i64 szMmap;                   /* Default mmap_size setting */\n  u32 nSchemaLock;              /* Do not reset the schema when non-zero */\n  unsigned int openFlags;       /* Flags passed to sqlite3_vfs.xOpen() */\n  int errCode;                  /* Most recent error code (SQLITE_*) */\n  int errMask;                  /* & result codes with this before returning */\n  int iSysErrno;                /* Errno value from last system error */\n  u16 dbOptFlags;               /* Flags to enable/disable optimizations */\n  u8 enc;                       /* Text encoding */\n  u8 autoCommit;                /* The auto-commit flag. */\n  u8 temp_store;                /* 1: file 2: memory 0: default */\n  u8 mallocFailed;              /* True if we have seen a malloc failure */\n  u8 bBenignMalloc;             /* Do not require OOMs if true */\n  u8 dfltLockMode;              /* Default locking-mode for attached dbs */\n  signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */\n  u8 suppressErr;               /* Do not issue error messages if true */\n  u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */\n  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */\n  u8 mTrace;                    /* zero or more SQLITE_TRACE flags */\n  u8 skipBtreeMutex;            /* True if no shared-cache backends */\n  u8 nSqlExec;                  /* Number of pending OP_SqlExec opcodes */\n  int nextPagesize;             /* Pagesize after VACUUM if >0 */\n  u32 magic;                    /* Magic number for detect library misuse */\n  int nChange;                  /* Value returned by sqlite3_changes() */\n  int nTotalChange;             /* Value returned by sqlite3_total_changes() */\n  int aLimit[SQLITE_N_LIMIT];   /* Limits */\n  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */\n  struct sqlite3InitInfo {      /* Information used during initialization */\n    int newTnum;                /* Rootpage of table being initialized */\n    u8 iDb;                     /* Which db file is being initialized */\n    u8 busy;                    /* TRUE if currently initializing */\n    u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */\n    u8 imposterTable;           /* Building an imposter table */\n  } init;\n  int nVdbeActive;              /* Number of VDBEs currently running */\n  int nVdbeRead;                /* Number of active VDBEs that read or write */\n  int nVdbeWrite;               /* Number of active VDBEs that read and write */\n  int nVdbeExec;                /* Number of nested calls to VdbeExec() */\n  int nVDestroy;                /* Number of active OP_VDestroy operations */\n  int nExtension;               /* Number of loaded extensions */\n  void **aExtension;            /* Array of shared library handles */\n  int (*xTrace)(u32,void*,void*,void*);     /* Trace function */\n  void *pTraceArg;                          /* Argument to the trace function */\n  void (*xProfile)(void*,const char*,u64);  /* Profiling function */\n  void *pProfileArg;                        /* Argument to profile function */\n  void *pCommitArg;                 /* Argument to xCommitCallback() */\n  int (*xCommitCallback)(void*);    /* Invoked at every commit. */\n  void *pRollbackArg;               /* Argument to xRollbackCallback() */\n  void (*xRollbackCallback)(void*); /* Invoked at every commit. */\n  void *pUpdateArg;\n  void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  void *pPreUpdateArg;          /* First argument to xPreUpdateCallback */\n  void (*xPreUpdateCallback)(   /* Registered using sqlite3_preupdate_hook() */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64\n  );\n  PreUpdate *pPreUpdate;        /* Context for active pre-update callback */\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n#ifndef SQLITE_OMIT_WAL\n  int (*xWalCallback)(void *, sqlite3 *, const char *, int);\n  void *pWalArg;\n#endif\n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);\n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);\n  void *pCollNeededArg;\n  sqlite3_value *pErr;          /* Most recent error message */\n  union {\n    volatile int isInterrupted; /* True if sqlite3_interrupt has been called */\n    double notUsed1;            /* Spacer */\n  } u1;\n  Lookaside lookaside;          /* Lookaside malloc configuration */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;          /* Access authorization function */\n  void *pAuthArg;               /* 1st argument to the access auth function */\n#endif\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  int (*xProgress)(void *);     /* The progress callback */\n  void *pProgressArg;           /* Argument to the progress callback */\n  unsigned nProgressOps;        /* Number of opcodes for progress callback */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nVTrans;                  /* Allocated size of aVTrans */\n  Hash aModule;                 /* populated by sqlite3_create_module() */\n  VtabCtx *pVtabCtx;            /* Context for active vtab connect/create */\n  VTable **aVTrans;             /* Virtual tables with open transactions */\n  VTable *pDisconnect;    /* Disconnect these in next sqlite3_prepare() */\n#endif\n  Hash aFunc;                   /* Hash table of connection functions */\n  Hash aCollSeq;                /* All collating sequences */\n  BusyHandler busyHandler;      /* Busy callback */\n  Db aDbStatic[2];              /* Static space for the 2 default backends */\n  Savepoint *pSavepoint;        /* List of active savepoints */\n  int busyTimeout;              /* Busy handler timeout, in msec */\n  int nSavepoint;               /* Number of non-transaction savepoints */\n  int nStatement;               /* Number of nested statement-transactions  */\n  i64 nDeferredCons;            /* Net deferred constraints this transaction. */\n  i64 nDeferredImmCons;         /* Net deferred immediate constraints */\n  int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  /* The following variables are all protected by the STATIC_MASTER\n  ** mutex, not by sqlite3.mutex. They are used by code in notify.c.\n  **\n  ** When X.pUnlockConnection==Y, that means that X is waiting for Y to\n  ** unlock so that it can proceed.\n  **\n  ** When X.pBlockingConnection==Y, that means that something that X tried\n  ** tried to do recently failed with an SQLITE_LOCKED error due to locks\n  ** held by Y.\n  */\n  sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */\n  sqlite3 *pUnlockConnection;           /* Connection to watch for unlock */\n  void *pUnlockArg;                     /* Argument to xUnlockNotify */\n  void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */\n  sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */\n#endif\n#ifdef SQLITE_USER_AUTHENTICATION\n  sqlite3_userauth auth;        /* User authentication information */\n#endif\n};\n\n/*\n** A macro to discover the encoding of a database.\n*/\n#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)\n#define ENC(db)        ((db)->enc)\n\n/*\n** Possible values for the sqlite3.flags.\n**\n** Value constraints (enforced via assert()):\n**      SQLITE_FullFSync     == PAGER_FULLFSYNC\n**      SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC\n**      SQLITE_CacheSpill    == PAGER_CACHE_SPILL\n*/\n#define SQLITE_WriteSchema    0x00000001  /* OK to update SQLITE_MASTER */\n#define SQLITE_LegacyFileFmt  0x00000002  /* Create new databases in format 1 */\n#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */\n#define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */\n#define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */\n#define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */\n#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */\n#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */\n                                          /*   DELETE, or UPDATE and return */\n                                          /*   the count using a callback. */\n#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */\n                                          /*   result set is empty */\n#define SQLITE_IgnoreChecks   0x00000200  /* Do not enforce check constraints */\n#define SQLITE_ReadUncommit   0x00000400  /* READ UNCOMMITTED in shared-cache */\n#define SQLITE_NoCkptOnClose  0x00000800  /* No checkpoint on close()/DETACH */\n#define SQLITE_ReverseOrder   0x00001000  /* Reverse unordered SELECTs */\n#define SQLITE_RecTriggers    0x00002000  /* Enable recursive triggers */\n#define SQLITE_ForeignKeys    0x00004000  /* Enforce foreign key constraints  */\n#define SQLITE_AutoIndex      0x00008000  /* Enable automatic indexes */\n#define SQLITE_LoadExtension  0x00010000  /* Enable load_extension */\n#define SQLITE_LoadExtFunc    0x00020000  /* Enable load_extension() SQL func */\n#define SQLITE_EnableTrigger  0x00040000  /* True to enable triggers */\n#define SQLITE_DeferFKs       0x00080000  /* Defer all FK constraints */\n#define SQLITE_QueryOnly      0x00100000  /* Disable database changes */\n#define SQLITE_CellSizeCk     0x00200000  /* Check btree cell sizes on load */\n#define SQLITE_Fts3Tokenizer  0x00400000  /* Enable fts3_tokenizer(2) */\n#define SQLITE_EnableQPSG     0x00800000  /* Query Planner Stability Guarantee */\n/* Flags used only if debugging */\n#ifdef SQLITE_DEBUG\n#define SQLITE_SqlTrace       0x08000000  /* Debug print SQL as it executes */\n#define SQLITE_VdbeListing    0x10000000  /* Debug listings of VDBE programs */\n#define SQLITE_VdbeTrace      0x20000000  /* True to trace VDBE execution */\n#define SQLITE_VdbeAddopTrace 0x40000000  /* Trace sqlite3VdbeAddOp() calls */\n#define SQLITE_VdbeEQP        0x80000000  /* Debug EXPLAIN QUERY PLAN */\n#endif\n\n/*\n** Allowed values for sqlite3.mDbFlags\n*/\n#define DBFLAG_SchemaChange   0x0001  /* Uncommitted Hash table changes */\n#define DBFLAG_PreferBuiltin  0x0002  /* Preference to built-in funcs */\n#define DBFLAG_Vacuum         0x0004  /* Currently in a VACUUM */\n\n/*\n** Bits of the sqlite3.dbOptFlags field that are used by the\n** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to\n** selectively disable various optimizations.\n*/\n#define SQLITE_QueryFlattener 0x0001   /* Query flattening */\n#define SQLITE_ColumnCache    0x0002   /* Column cache */\n#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */\n#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */\n#define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */\n#define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */\n#define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */\n#define SQLITE_Transitive     0x0080   /* Transitive constraints */\n#define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */\n#define SQLITE_CountOfView    0x0200   /* The count-of-view optimization */\n#define SQLITE_CursorHints    0x0400   /* Add OP_CursorHint opcodes */\n#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */\n   /* TH3 expects the Stat34  ^^^^^^ value to be 0x0800.  Don't change it */\n#define SQLITE_AllOpts        0xffff   /* All optimizations */\n\n/*\n** Macros for testing whether or not optimizations are enabled or disabled.\n*/\n#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)\n#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)\n\n/*\n** Return true if it OK to factor constant expressions into the initialization\n** code. The argument is a Parse object for the code generator.\n*/\n#define ConstFactorOk(P) ((P)->okConstFactor)\n\n/*\n** Possible values for the sqlite.magic field.\n** The numbers are obtained at random and have no special meaning, other\n** than being distinct from one another.\n*/\n#define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */\n#define SQLITE_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */\n#define SQLITE_MAGIC_SICK     0x4b771290  /* Error and awaiting close */\n#define SQLITE_MAGIC_BUSY     0xf03b7906  /* Database currently in use */\n#define SQLITE_MAGIC_ERROR    0xb5357930  /* An SQLITE_MISUSE error occurred */\n#define SQLITE_MAGIC_ZOMBIE   0x64cffc7f  /* Close with last statement close */\n\n/*\n** Each SQL function is defined by an instance of the following\n** structure.  For global built-in functions (ex: substr(), max(), count())\n** a pointer to this structure is held in the sqlite3BuiltinFunctions object.\n** For per-connection application-defined functions, a pointer to this\n** structure is held in the db->aHash hash table.\n**\n** The u.pHash field is used by the global built-ins.  The u.pDestructor\n** field is used by per-connection app-def functions.\n*/\nstruct FuncDef {\n  i8 nArg;             /* Number of arguments.  -1 means unlimited */\n  u16 funcFlags;       /* Some combination of SQLITE_FUNC_* */\n  void *pUserData;     /* User data parameter */\n  FuncDef *pNext;      /* Next function with same name */\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */\n  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */\n  const char *zName;   /* SQL name of the function. */\n  union {\n    FuncDef *pHash;      /* Next with a different name but the same hash */\n    FuncDestructor *pDestructor;   /* Reference counted destructor function */\n  } u;\n};\n\n/*\n** This structure encapsulates a user-function destructor callback (as\n** configured using create_function_v2()) and a reference counter. When\n** create_function_v2() is called to create a function with a destructor,\n** a single object of this type is allocated. FuncDestructor.nRef is set to\n** the number of FuncDef objects created (either 1 or 3, depending on whether\n** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor\n** member of each of the new FuncDef objects is set to point to the allocated\n** FuncDestructor.\n**\n** Thereafter, when one of the FuncDef objects is deleted, the reference\n** count on this object is decremented. When it reaches 0, the destructor\n** is invoked and the FuncDestructor structure freed.\n*/\nstruct FuncDestructor {\n  int nRef;\n  void (*xDestroy)(void *);\n  void *pUserData;\n};\n\n/*\n** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF\n** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And\n** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There\n** are assert() statements in the code to verify this.\n**\n** Value constraints (enforced via assert()):\n**     SQLITE_FUNC_MINMAX    ==  NC_MinMaxAgg      == SF_MinMaxAgg\n**     SQLITE_FUNC_LENGTH    ==  OPFLAG_LENGTHARG\n**     SQLITE_FUNC_TYPEOF    ==  OPFLAG_TYPEOFARG\n**     SQLITE_FUNC_CONSTANT  ==  SQLITE_DETERMINISTIC from the API\n**     SQLITE_FUNC_ENCMASK   depends on SQLITE_UTF* macros in the API\n*/\n#define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */\n#define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */\n#define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */\n#define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */\n#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/\n#define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */\n#define SQLITE_FUNC_TYPEOF   0x0080 /* Built-in typeof() function */\n#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */\n#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */\n#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */\n#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */\n#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */\n#define SQLITE_FUNC_SLOCHNG  0x2000 /* \"Slow Change\". Value constant during a\n                                    ** single query - might change over time */\n#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */\n\n/*\n** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are\n** used to create the initializers for the FuncDef structures.\n**\n**   FUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Used to create a scalar function definition of a function zName\n**     implemented by C function xFunc that accepts nArg arguments. The\n**     value passed as iArg is cast to a (void*) and made available\n**     as the user-data (sqlite3_user_data()) for the function. If\n**     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.\n**\n**   VFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.\n**\n**   DFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and\n**     adds the SQLITE_FUNC_SLOCHNG flag.  Used for date & time functions\n**     and functions like sqlite_version() that can change, but not during\n**     a single query.  The iArg is ignored.  The user-data is always set\n**     to a NULL pointer.  The bNC parameter is not used.\n**\n**   PURE_DATE(zName, nArg, iArg, bNC, xFunc)\n**     Used for \"pure\" date/time functions, this macro is like DFUNCTION\n**     except that it does set the SQLITE_FUNC_CONSTANT flags.  iArg is\n**     ignored and the user-data for these functions is set to an \n**     arbitrary non-NULL pointer.  The bNC parameter is not used.\n**\n**   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)\n**     Used to create an aggregate function definition implemented by\n**     the C functions xStep and xFinal. The first four parameters\n**     are interpreted in the same way as the first 4 parameters to\n**     FUNCTION().\n**\n**   LIKEFUNC(zName, nArg, pArg, flags)\n**     Used to create a scalar function definition of a function zName\n**     that accepts nArg arguments and is implemented by a call to C\n**     function likeFunc. Argument pArg is cast to a (void *) and made\n**     available as the function user-data (sqlite3_user_data()). The\n**     FuncDef.flags variable is set to the value passed as the flags\n**     parameter.\n*/\n#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \\\n   0, 0, xFunc, 0, #zName, {0} }\n#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \\\n   (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} }\n#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \\\n  {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   pArg, 0, xFunc, 0, #zName, }\n#define LIKEFUNC(zName, nArg, arg, flags) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \\\n   (void *)arg, 0, likeFunc, 0, #zName, {0} }\n#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}\n#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}\n\n/*\n** All current savepoints are stored in a linked list starting at\n** sqlite3.pSavepoint. The first element in the list is the most recently\n** opened savepoint. Savepoints are added to the list by the vdbe\n** OP_Savepoint instruction.\n*/\nstruct Savepoint {\n  char *zName;                        /* Savepoint name (nul-terminated) */\n  i64 nDeferredCons;                  /* Number of deferred fk violations */\n  i64 nDeferredImmCons;               /* Number of deferred imm fk. */\n  Savepoint *pNext;                   /* Parent savepoint (if any) */\n};\n\n/*\n** The following are used as the second parameter to sqlite3Savepoint(),\n** and as the P1 argument to the OP_Savepoint instruction.\n*/\n#define SAVEPOINT_BEGIN      0\n#define SAVEPOINT_RELEASE    1\n#define SAVEPOINT_ROLLBACK   2\n\n\n/*\n** Each SQLite module (virtual table definition) is defined by an\n** instance of the following structure, stored in the sqlite3.aModule\n** hash table.\n*/\nstruct Module {\n  const sqlite3_module *pModule;       /* Callback pointers */\n  const char *zName;                   /* Name passed to create_module() */\n  void *pAux;                          /* pAux passed to create_module() */\n  void (*xDestroy)(void *);            /* Module destructor function */\n  Table *pEpoTab;                      /* Eponymous table for this module */\n};\n\n/*\n** information about each column of an SQL table is held in an instance\n** of this structure.\n*/\nstruct Column {\n  char *zName;     /* Name of this column, \\000, then the type */\n  Expr *pDflt;     /* Default value of this column */\n  char *zColl;     /* Collating sequence.  If NULL, use the default */\n  u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */\n  char affinity;   /* One of the SQLITE_AFF_... values */\n  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */\n  u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */\n};\n\n/* Allowed values for Column.colFlags:\n*/\n#define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */\n#define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */\n#define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */\n\n/*\n** A \"Collating Sequence\" is defined by an instance of the following\n** structure. Conceptually, a collating sequence consists of a name and\n** a comparison routine that defines the order of that sequence.\n**\n** If CollSeq.xCmp is NULL, it means that the\n** collating sequence is undefined.  Indices built on an undefined\n** collating sequence may not be read or written.\n*/\nstruct CollSeq {\n  char *zName;          /* Name of the collating sequence, UTF-8 encoded */\n  u8 enc;               /* Text encoding handled by xCmp() */\n  void *pUser;          /* First argument to xCmp() */\n  int (*xCmp)(void*,int, const void*, int, const void*);\n  void (*xDel)(void*);  /* Destructor for pUser */\n};\n\n/*\n** A sort order can be either ASC or DESC.\n*/\n#define SQLITE_SO_ASC       0  /* Sort in ascending order */\n#define SQLITE_SO_DESC      1  /* Sort in ascending order */\n#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */\n\n/*\n** Column affinity types.\n**\n** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and\n** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve\n** the speed a little by numbering the values consecutively.\n**\n** But rather than start with 0 or 1, we begin with 'A'.  That way,\n** when multiple affinity types are concatenated into a string and\n** used as the P4 operand, they will be more readable.\n**\n** Note also that the numeric types are grouped together so that testing\n** for a numeric type is a single comparison.  And the BLOB type is first.\n*/\n#define SQLITE_AFF_BLOB     'A'\n#define SQLITE_AFF_TEXT     'B'\n#define SQLITE_AFF_NUMERIC  'C'\n#define SQLITE_AFF_INTEGER  'D'\n#define SQLITE_AFF_REAL     'E'\n\n#define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)\n\n/*\n** The SQLITE_AFF_MASK values masks off the significant bits of an\n** affinity value.\n*/\n#define SQLITE_AFF_MASK     0x47\n\n/*\n** Additional bit values that can be ORed with an affinity without\n** changing the affinity.\n**\n** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.\n** It causes an assert() to fire if either operand to a comparison\n** operator is NULL.  It is added to certain comparison operators to\n** prove that the operands are always NOT NULL.\n*/\n#define SQLITE_KEEPNULL     0x08  /* Used by vector == or <> */\n#define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */\n#define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */\n#define SQLITE_NULLEQ       0x80  /* NULL=NULL */\n#define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */\n\n/*\n** An object of this type is created for each virtual table present in\n** the database schema.\n**\n** If the database schema is shared, then there is one instance of this\n** structure for each database connection (sqlite3*) that uses the shared\n** schema. This is because each database connection requires its own unique\n** instance of the sqlite3_vtab* handle used to access the virtual table\n** implementation. sqlite3_vtab* handles can not be shared between\n** database connections, even when the rest of the in-memory database\n** schema is shared, as the implementation often stores the database\n** connection handle passed to it via the xConnect() or xCreate() method\n** during initialization internally. This database connection handle may\n** then be used by the virtual table implementation to access real tables\n** within the database. So that they appear as part of the callers\n** transaction, these accesses need to be made via the same database\n** connection as that used to execute SQL operations on the virtual table.\n**\n** All VTable objects that correspond to a single table in a shared\n** database schema are initially stored in a linked-list pointed to by\n** the Table.pVTable member variable of the corresponding Table object.\n** When an sqlite3_prepare() operation is required to access the virtual\n** table, it searches the list for the VTable that corresponds to the\n** database connection doing the preparing so as to use the correct\n** sqlite3_vtab* handle in the compiled query.\n**\n** When an in-memory Table object is deleted (for example when the\n** schema is being reloaded for some reason), the VTable objects are not\n** deleted and the sqlite3_vtab* handles are not xDisconnect()ed\n** immediately. Instead, they are moved from the Table.pVTable list to\n** another linked list headed by the sqlite3.pDisconnect member of the\n** corresponding sqlite3 structure. They are then deleted/xDisconnected\n** next time a statement is prepared using said sqlite3*. This is done\n** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.\n** Refer to comments above function sqlite3VtabUnlockList() for an\n** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect\n** list without holding the corresponding sqlite3.mutex mutex.\n**\n** The memory for objects of this type is always allocated by\n** sqlite3DbMalloc(), using the connection handle stored in VTable.db as\n** the first argument.\n*/\nstruct VTable {\n  sqlite3 *db;              /* Database connection associated with this table */\n  Module *pMod;             /* Pointer to module implementation */\n  sqlite3_vtab *pVtab;      /* Pointer to vtab instance */\n  int nRef;                 /* Number of pointers to this structure */\n  u8 bConstraint;           /* True if constraints are supported */\n  int iSavepoint;           /* Depth of the SAVEPOINT stack */\n  VTable *pNext;            /* Next in linked list (see above) */\n};\n\n/*\n** The schema for each SQL table and view is represented in memory\n** by an instance of the following structure.\n*/\nstruct Table {\n  char *zName;         /* Name of the table or view */\n  Column *aCol;        /* Information about each column */\n  Index *pIndex;       /* List of SQL indexes on this table. */\n  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */\n  FKey *pFKey;         /* Linked list of all foreign keys in this table */\n  char *zColAff;       /* String defining the affinity of each column */\n  ExprList *pCheck;    /* All CHECK constraints */\n                       /*   ... also used as column name list in a VIEW */\n  int tnum;            /* Root BTree page for this table */\n  u32 nTabRef;         /* Number of pointers to this Table */\n  u32 tabFlags;        /* Mask of TF_* values */\n  i16 iPKey;           /* If not negative, use aCol[iPKey] as the rowid */\n  i16 nCol;            /* Number of columns in this table */\n  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */\n  LogEst szTabRow;     /* Estimated size of each table row in bytes */\n#ifdef SQLITE_ENABLE_COSTMULT\n  LogEst costMult;     /* Cost multiplier for using this table */\n#endif\n  u8 keyConf;          /* What to do in case of uniqueness conflict on iPKey */\n#ifndef SQLITE_OMIT_ALTERTABLE\n  int addColOffset;    /* Offset in CREATE TABLE stmt to add a new column */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nModuleArg;      /* Number of arguments to the module */\n  char **azModuleArg;  /* 0: module 1: schema 2: vtab name 3...: args */\n  VTable *pVTable;     /* List of VTable objects. */\n#endif\n  Trigger *pTrigger;   /* List of triggers stored in pSchema */\n  Schema *pSchema;     /* Schema that contains this table */\n  Table *pNextZombie;  /* Next on the Parse.pZombieTab list */\n};\n\n/*\n** Allowed values for Table.tabFlags.\n**\n** TF_OOOHidden applies to tables or view that have hidden columns that are\n** followed by non-hidden columns.  Example:  \"CREATE VIRTUAL TABLE x USING\n** vtab1(a HIDDEN, b);\".  Since \"b\" is a non-hidden column but \"a\" is hidden,\n** the TF_OOOHidden attribute would apply in this case.  Such tables require\n** special handling during INSERT processing.\n*/\n#define TF_Readonly        0x0001    /* Read-only system table */\n#define TF_Ephemeral       0x0002    /* An ephemeral table */\n#define TF_HasPrimaryKey   0x0004    /* Table has a primary key */\n#define TF_Autoincrement   0x0008    /* Integer primary key is autoincrement */\n#define TF_HasStat1        0x0010    /* nRowLogEst set from sqlite_stat1 */\n#define TF_WithoutRowid    0x0020    /* No rowid.  PRIMARY KEY is the key */\n#define TF_NoVisibleRowid  0x0040    /* No user-visible \"rowid\" column */\n#define TF_OOOHidden       0x0080    /* Out-of-Order hidden columns */\n#define TF_StatsUsed       0x0100    /* Query planner decisions affected by\n                                     ** Index.aiRowLogEst[] values */\n#define TF_HasNotNull      0x0200    /* Contains NOT NULL constraints */\n\n/*\n** Test to see whether or not a table is a virtual table.  This is\n** done as a macro so that it will be optimized out when virtual\n** table support is omitted from the build.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n#  define IsVirtual(X)      ((X)->nModuleArg)\n#else\n#  define IsVirtual(X)      0\n#endif\n\n/*\n** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()\n** only works for non-virtual tables (ordinary tables and views) and is\n** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The\n** IsHiddenColumn() macro is general purpose.\n*/\n#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#elif !defined(SQLITE_OMIT_VIRTUALTABLE)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) 0\n#else\n#  define IsHiddenColumn(X)         0\n#  define IsOrdinaryHiddenColumn(X) 0\n#endif\n\n\n/* Does the table have a rowid */\n#define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)\n#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)\n\n/*\n** Each foreign key constraint is an instance of the following structure.\n**\n** A foreign key is associated with two tables.  The \"from\" table is\n** the table that contains the REFERENCES clause that creates the foreign\n** key.  The \"to\" table is the table that is named in the REFERENCES clause.\n** Consider this example:\n**\n**     CREATE TABLE ex1(\n**       a INTEGER PRIMARY KEY,\n**       b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)\n**     );\n**\n** For foreign key \"fk1\", the from-table is \"ex1\" and the to-table is \"ex2\".\n** Equivalent names:\n**\n**     from-table == child-table\n**       to-table == parent-table\n**\n** Each REFERENCES clause generates an instance of the following structure\n** which is attached to the from-table.  The to-table need not exist when\n** the from-table is created.  The existence of the to-table is not checked.\n**\n** The list of all parents for child Table X is held at X.pFKey.\n**\n** A list of all children for a table named Z (which might not even exist)\n** is held in Schema.fkeyHash with a hash key of Z.\n*/\nstruct FKey {\n  Table *pFrom;     /* Table containing the REFERENCES clause (aka: Child) */\n  FKey *pNextFrom;  /* Next FKey with the same in pFrom. Next parent of pFrom */\n  char *zTo;        /* Name of table that the key points to (aka: Parent) */\n  FKey *pNextTo;    /* Next with the same zTo. Next child of zTo. */\n  FKey *pPrevTo;    /* Previous with the same zTo */\n  int nCol;         /* Number of columns in this key */\n  /* EV: R-30323-21917 */\n  u8 isDeferred;       /* True if constraint checking is deferred till COMMIT */\n  u8 aAction[2];        /* ON DELETE and ON UPDATE actions, respectively */\n  Trigger *apTrigger[2];/* Triggers for aAction[] actions */\n  struct sColMap {      /* Mapping of columns in pFrom to columns in zTo */\n    int iFrom;            /* Index of column in pFrom */\n    char *zCol;           /* Name of column in zTo.  If NULL use PRIMARY KEY */\n  } aCol[1];            /* One entry for each of nCol columns */\n};\n\n/*\n** SQLite supports many different ways to resolve a constraint\n** error.  ROLLBACK processing means that a constraint violation\n** causes the operation in process to fail and for the current transaction\n** to be rolled back.  ABORT processing means the operation in process\n** fails and any prior changes from that one operation are backed out,\n** but the transaction is not rolled back.  FAIL processing means that\n** the operation in progress stops and returns an error code.  But prior\n** changes due to the same operation are not backed out and no rollback\n** occurs.  IGNORE means that the particular row that caused the constraint\n** error is not inserted or updated.  Processing continues and no error\n** is returned.  REPLACE means that preexisting database rows that caused\n** a UNIQUE constraint violation are removed so that the new insert or\n** update can proceed.  Processing continues and no error is reported.\n**\n** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.\n** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the\n** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign\n** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the\n** referenced table row is propagated into the row that holds the\n** foreign key.\n**\n** The following symbolic values are used to record which type\n** of action to take.\n*/\n#define OE_None     0   /* There is no constraint to check */\n#define OE_Rollback 1   /* Fail the operation and rollback the transaction */\n#define OE_Abort    2   /* Back out changes but do no rollback transaction */\n#define OE_Fail     3   /* Stop the operation but leave all prior changes */\n#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */\n#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */\n\n#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */\n#define OE_SetNull  7   /* Set the foreign key value to NULL */\n#define OE_SetDflt  8   /* Set the foreign key value to its default */\n#define OE_Cascade  9   /* Cascade the changes */\n\n#define OE_Default  10  /* Do whatever the default action is */\n\n\n/*\n** An instance of the following structure is passed as the first\n** argument to sqlite3VdbeKeyCompare and is used to control the\n** comparison of the two index keys.\n**\n** Note that aSortOrder[] and aColl[] have nField+1 slots.  There\n** are nField slots for the columns of an index then one extra slot\n** for the rowid at the end.\n*/\nstruct KeyInfo {\n  u32 nRef;           /* Number of references to this KeyInfo object */\n  u8 enc;             /* Text encoding - one of the SQLITE_UTF* values */\n  u16 nKeyField;      /* Number of key columns in the index */\n  u16 nAllField;      /* Total columns, including key plus others */\n  sqlite3 *db;        /* The database connection */\n  u8 *aSortOrder;     /* Sort order for each column. */\n  CollSeq *aColl[1];  /* Collating sequence for each term of the key */\n};\n\n/*\n** This object holds a record which has been parsed out into individual\n** fields, for the purposes of doing a comparison.\n**\n** A record is an object that contains one or more fields of data.\n** Records are used to store the content of a table row and to store\n** the key of an index.  A blob encoding of a record is created by\n** the OP_MakeRecord opcode of the VDBE and is disassembled by the\n** OP_Column opcode.\n**\n** An instance of this object serves as a \"key\" for doing a search on\n** an index b+tree. The goal of the search is to find the entry that\n** is closed to the key described by this object.  This object might hold\n** just a prefix of the key.  The number of fields is given by\n** pKeyInfo->nField.\n**\n** The r1 and r2 fields are the values to return if this key is less than\n** or greater than a key in the btree, respectively.  These are normally\n** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree\n** is in DESC order.\n**\n** The key comparison functions actually return default_rc when they find\n** an equals comparison.  default_rc can be -1, 0, or +1.  If there are\n** multiple entries in the b-tree with the same key (when only looking\n** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to\n** cause the search to find the last match, or +1 to cause the search to\n** find the first match.\n**\n** The key comparison functions will set eqSeen to true if they ever\n** get and equal results when comparing this structure to a b-tree record.\n** When default_rc!=0, the search might end up on the record immediately\n** before the first match or immediately after the last match.  The\n** eqSeen field will indicate whether or not an exact match exists in the\n** b-tree.\n*/\nstruct UnpackedRecord {\n  KeyInfo *pKeyInfo;  /* Collation and sort-order information */\n  Mem *aMem;          /* Values */\n  u16 nField;         /* Number of entries in apMem[] */\n  i8 default_rc;      /* Comparison result if keys are equal */\n  u8 errCode;         /* Error detected by xRecordCompare (CORRUPT or NOMEM) */\n  i8 r1;              /* Value to return if (lhs < rhs) */\n  i8 r2;              /* Value to return if (lhs > rhs) */\n  u8 eqSeen;          /* True if an equality comparison has been seen */\n};\n\n\n/*\n** Each SQL index is represented in memory by an\n** instance of the following structure.\n**\n** The columns of the table that are to be indexed are described\n** by the aiColumn[] field of this structure.  For example, suppose\n** we have the following table and index:\n**\n**     CREATE TABLE Ex1(c1 int, c2 int, c3 text);\n**     CREATE INDEX Ex2 ON Ex1(c3,c1);\n**\n** In the Table structure describing Ex1, nCol==3 because there are\n** three columns in the table.  In the Index structure describing\n** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.\n** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the\n** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].\n** The second column to be indexed (c1) has an index of 0 in\n** Ex1.aCol[], hence Ex2.aiColumn[1]==0.\n**\n** The Index.onError field determines whether or not the indexed columns\n** must be unique and what to do if they are not.  When Index.onError=OE_None,\n** it means this is not a unique index.  Otherwise it is a unique index\n** and the value of Index.onError indicate the which conflict resolution\n** algorithm to employ whenever an attempt is made to insert a non-unique\n** element.\n**\n** While parsing a CREATE TABLE or CREATE INDEX statement in order to\n** generate VDBE code (as opposed to parsing one read from an sqlite_master\n** table as part of parsing an existing database schema), transient instances\n** of this structure may be created. In this case the Index.tnum variable is\n** used to store the address of a VDBE instruction, not a database page\n** number (it cannot - the database page is not allocated until the VDBE\n** program is executed). See convertToWithoutRowidTable() for details.\n*/\nstruct Index {\n  char *zName;             /* Name of this index */\n  i16 *aiColumn;           /* Which columns are used by this index.  1st is 0 */\n  LogEst *aiRowLogEst;     /* From ANALYZE: Est. rows selected by each column */\n  Table *pTable;           /* The SQL table being indexed */\n  char *zColAff;           /* String defining the affinity of each column */\n  Index *pNext;            /* The next index associated with the same table */\n  Schema *pSchema;         /* Schema containing this index */\n  u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */\n  const char **azColl;     /* Array of collation sequence names for index */\n  Expr *pPartIdxWhere;     /* WHERE clause for partial indices */\n  ExprList *aColExpr;      /* Column expressions */\n  int tnum;                /* DB Page containing root of this index */\n  LogEst szIdxRow;         /* Estimated average row size in bytes */\n  u16 nKeyCol;             /* Number of columns forming the key */\n  u16 nColumn;             /* Number of columns stored in the index */\n  u8 onError;              /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  unsigned idxType:2;      /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */\n  unsigned bUnordered:1;   /* Use this index for == or IN queries only */\n  unsigned uniqNotNull:1;  /* True if UNIQUE and NOT NULL for all columns */\n  unsigned isResized:1;    /* True if resizeIndexObject() has been called */\n  unsigned isCovering:1;   /* True if this is a covering index */\n  unsigned noSkipScan:1;   /* Do not try to use skip-scan if true */\n  unsigned hasStat1:1;     /* aiRowLogEst values come from sqlite_stat1 */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int nSample;             /* Number of elements in aSample[] */\n  int nSampleCol;          /* Size of IndexSample.anEq[] and so on */\n  tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */\n  IndexSample *aSample;    /* Samples of the left-most key */\n  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */\n  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */\n#endif\n};\n\n/*\n** Allowed values for Index.idxType\n*/\n#define SQLITE_IDXTYPE_APPDEF      0   /* Created using CREATE INDEX */\n#define SQLITE_IDXTYPE_UNIQUE      1   /* Implements a UNIQUE constraint */\n#define SQLITE_IDXTYPE_PRIMARYKEY  2   /* Is the PRIMARY KEY for the table */\n\n/* Return true if index X is a PRIMARY KEY index */\n#define IsPrimaryKeyIndex(X)  ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)\n\n/* Return true if index X is a UNIQUE index */\n#define IsUniqueIndex(X)      ((X)->onError!=OE_None)\n\n/* The Index.aiColumn[] values are normally positive integer.  But\n** there are some negative values that have special meaning:\n*/\n#define XN_ROWID     (-1)     /* Indexed column is the rowid */\n#define XN_EXPR      (-2)     /* Indexed column is an expression */\n\n/*\n** Each sample stored in the sqlite_stat3 table is represented in memory\n** using a structure of this type.  See documentation at the top of the\n** analyze.c source file for additional information.\n*/\nstruct IndexSample {\n  void *p;          /* Pointer to sampled record */\n  int n;            /* Size of record in bytes */\n  tRowcnt *anEq;    /* Est. number of rows where the key equals this sample */\n  tRowcnt *anLt;    /* Est. number of rows where key is less than this sample */\n  tRowcnt *anDLt;   /* Est. number of distinct keys less than this sample */\n};\n\n/*\n** Each token coming out of the lexer is an instance of\n** this structure.  Tokens are also used as part of an expression.\n**\n** Note if Token.z==0 then Token.dyn and Token.n are undefined and\n** may contain random values.  Do not make any assumptions about Token.dyn\n** and Token.n when Token.z==0.\n*/\nstruct Token {\n  const char *z;     /* Text of the token.  Not NULL-terminated! */\n  unsigned int n;    /* Number of characters in this token */\n};\n\n/*\n** An instance of this structure contains information needed to generate\n** code for a SELECT that contains aggregate functions.\n**\n** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a\n** pointer to this structure.  The Expr.iColumn field is the index in\n** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate\n** code for that node.\n**\n** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the\n** original Select structure that describes the SELECT statement.  These\n** fields do not need to be freed when deallocating the AggInfo structure.\n*/\nstruct AggInfo {\n  u8 directMode;          /* Direct rendering mode means take data directly\n                          ** from source tables rather than from accumulators */\n  u8 useSortingIdx;       /* In direct mode, reference the sorting index rather\n                          ** than the source table */\n  int sortingIdx;         /* Cursor number of the sorting index */\n  int sortingIdxPTab;     /* Cursor number of pseudo-table */\n  int nSortingColumn;     /* Number of columns in the sorting index */\n  int mnReg, mxReg;       /* Range of registers allocated for aCol and aFunc */\n  ExprList *pGroupBy;     /* The group by clause */\n  struct AggInfo_col {    /* For each column used in source tables */\n    Table *pTab;             /* Source table */\n    int iTable;              /* Cursor number of the source table */\n    int iColumn;             /* Column number within the source table */\n    int iSorterColumn;       /* Column number in the sorting index */\n    int iMem;                /* Memory location that acts as accumulator */\n    Expr *pExpr;             /* The original expression */\n  } *aCol;\n  int nColumn;            /* Number of used entries in aCol[] */\n  int nAccumulator;       /* Number of columns that show through to the output.\n                          ** Additional columns are used only as parameters to\n                          ** aggregate functions */\n  struct AggInfo_func {   /* For each aggregate function */\n    Expr *pExpr;             /* Expression encoding the function */\n    FuncDef *pFunc;          /* The aggregate function implementation */\n    int iMem;                /* Memory location that acts as accumulator */\n    int iDistinct;           /* Ephemeral table used to enforce DISTINCT */\n  } *aFunc;\n  int nFunc;              /* Number of entries in aFunc[] */\n};\n\n/*\n** The datatype ynVar is a signed integer, either 16-bit or 32-bit.\n** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater\n** than 32767 we have to make it 32-bit.  16-bit is preferred because\n** it uses less memory in the Expr object, which is a big memory user\n** in systems with lots of prepared statements.  And few applications\n** need more than about 10 or 20 variables.  But some extreme users want\n** to have prepared statements with over 32767 variables, and for them\n** the option is available (at compile-time).\n*/\n#if SQLITE_MAX_VARIABLE_NUMBER<=32767\ntypedef i16 ynVar;\n#else\ntypedef int ynVar;\n#endif\n\n/*\n** Each node of an expression in the parse tree is an instance\n** of this structure.\n**\n** Expr.op is the opcode. The integer parser token codes are reused\n** as opcodes here. For example, the parser defines TK_GE to be an integer\n** code representing the \">=\" operator. This same integer code is reused\n** to represent the greater-than-or-equal-to operator in the expression\n** tree.\n**\n** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,\n** or TK_STRING), then Expr.token contains the text of the SQL literal. If\n** the expression is a variable (TK_VARIABLE), then Expr.token contains the\n** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),\n** then Expr.token contains the name of the function.\n**\n** Expr.pRight and Expr.pLeft are the left and right subexpressions of a\n** binary operator. Either or both may be NULL.\n**\n** Expr.x.pList is a list of arguments if the expression is an SQL function,\n** a CASE expression or an IN expression of the form \"<lhs> IN (<y>, <z>...)\".\n** Expr.x.pSelect is used if the expression is a sub-select or an expression of\n** the form \"<lhs> IN (SELECT ...)\". If the EP_xIsSelect bit is set in the\n** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is\n** valid.\n**\n** An expression of the form ID or ID.ID refers to a column in a table.\n** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is\n** the integer cursor number of a VDBE cursor pointing to that table and\n** Expr.iColumn is the column number for the specific column.  If the\n** expression is used as a result in an aggregate SELECT, then the\n** value is also stored in the Expr.iAgg column in the aggregate so that\n** it can be accessed after all aggregates are computed.\n**\n** If the expression is an unbound variable marker (a question mark\n** character '?' in the original SQL) then the Expr.iTable holds the index\n** number for that variable.\n**\n** If the expression is a subquery then Expr.iColumn holds an integer\n** register number containing the result of the subquery.  If the\n** subquery gives a constant result, then iTable is -1.  If the subquery\n** gives a different answer at different times during statement processing\n** then iTable is the address of a subroutine that computes the subquery.\n**\n** If the Expr is of type OP_Column, and the table it is selecting from\n** is a disk table or the \"old.*\" pseudo-table, then pTab points to the\n** corresponding table definition.\n**\n** ALLOCATION NOTES:\n**\n** Expr objects can use a lot of memory space in database schema.  To\n** help reduce memory requirements, sometimes an Expr object will be\n** truncated.  And to reduce the number of memory allocations, sometimes\n** two or more Expr objects will be stored in a single memory allocation,\n** together with Expr.zToken strings.\n**\n** If the EP_Reduced and EP_TokenOnly flags are set when\n** an Expr object is truncated.  When EP_Reduced is set, then all\n** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees\n** are contained within the same memory allocation.  Note, however, that\n** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately\n** allocated, regardless of whether or not EP_Reduced is set.\n*/\nstruct Expr {\n  u8 op;                 /* Operation performed by this node */\n  char affinity;         /* The affinity of the column or 0 if not a column */\n  u32 flags;             /* Various flags.  EP_* See below */\n  union {\n    char *zToken;          /* Token value. Zero terminated and dequoted */\n    int iValue;            /* Non-negative integer value if EP_IntValue */\n  } u;\n\n  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n  Expr *pLeft;           /* Left subnode */\n  Expr *pRight;          /* Right subnode */\n  union {\n    ExprList *pList;     /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */\n    Select *pSelect;     /* EP_xIsSelect and op = IN, EXISTS, SELECT */\n  } x;\n\n  /* If the EP_Reduced flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n  int nHeight;           /* Height of the tree headed by this node */\n#endif\n  int iTable;            /* TK_COLUMN: cursor number of table holding column\n                         ** TK_REGISTER: register number\n                         ** TK_TRIGGER: 1 -> new, 0 -> old\n                         ** EP_Unlikely:  134217728 times likelihood\n                         ** TK_SELECT: 1st register of result vector */\n  ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.\n                         ** TK_VARIABLE: variable number (always >= 1).\n                         ** TK_SELECT_COLUMN: column of the result vector */\n  i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */\n  i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */\n  u8 op2;                /* TK_REGISTER: original value of Expr.op\n                         ** TK_COLUMN: the value of p5 for OP_Column\n                         ** TK_AGG_FUNCTION: nesting depth */\n  AggInfo *pAggInfo;     /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */\n  Table *pTab;           /* Table for TK_COLUMN expressions.  Can be NULL\n                         ** for a column of an index on an expression */\n};\n\n/*\n** The following are the meanings of bits in the Expr.flags field.\n*/\n#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */\n#define EP_Agg       0x000002 /* Contains one or more aggregate functions */\n                  /* 0x000004 // available for use */\n                  /* 0x000008 // available for use */\n#define EP_Distinct  0x000010 /* Aggregate function with DISTINCT keyword */\n#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */\n#define EP_DblQuoted 0x000040 /* token.z was originally in \"...\" */\n#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */\n#define EP_Collate   0x000100 /* Tree contains a TK_COLLATE operator */\n#define EP_Generic   0x000200 /* Ignore COLLATE or affinity on this tree */\n#define EP_IntValue  0x000400 /* Integer value contained in u.iValue */\n#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */\n#define EP_Skip      0x001000 /* COLLATE, AS, or UNLIKELY */\n#define EP_Reduced   0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */\n#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */\n#define EP_Static    0x008000 /* Held in memory not obtained from malloc() */\n#define EP_MemToken  0x010000 /* Need to sqlite3DbFree() Expr.zToken */\n#define EP_NoReduce  0x020000 /* Cannot EXPRDUP_REDUCE this Expr */\n#define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */\n#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */\n#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */\n#define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */\n#define EP_Alias     0x400000 /* Is an alias for a result set column */\n#define EP_Leaf      0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */\n\n/*\n** Combinations of two or more EP_* flags\n*/\n#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Expr.flags field.\n*/\n#define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)\n#define ExprHasAllProperty(E,P)  (((E)->flags&(P))==(P))\n#define ExprSetProperty(E,P)     (E)->flags|=(P)\n#define ExprClearProperty(E,P)   (E)->flags&=~(P)\n\n/* The ExprSetVVAProperty() macro is used for Verification, Validation,\n** and Accreditation only.  It works like ExprSetProperty() during VVA\n** processes but is a no-op for delivery.\n*/\n#ifdef SQLITE_DEBUG\n# define ExprSetVVAProperty(E,P)  (E)->flags|=(P)\n#else\n# define ExprSetVVAProperty(E,P)\n#endif\n\n/*\n** Macros to determine the number of bytes required by a normal Expr\n** struct, an Expr struct with the EP_Reduced flag set in Expr.flags\n** and an Expr struct with the EP_TokenOnly flag set.\n*/\n#define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */\n#define EXPR_REDUCEDSIZE        offsetof(Expr,iTable)  /* Common features */\n#define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */\n\n/*\n** Flags passed to the sqlite3ExprDup() function. See the header comment\n** above sqlite3ExprDup() for details.\n*/\n#define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */\n\n/*\n** A list of expressions.  Each expression may optionally have a\n** name.  An expr/name combination can be used in several ways, such\n** as the list of \"expr AS ID\" fields following a \"SELECT\" or in the\n** list of \"ID = expr\" items in an UPDATE.  A list of expressions can\n** also be used as the argument to a function, in which case the a.zName\n** field is not used.\n**\n** By default the Expr.zSpan field holds a human-readable description of\n** the expression that is used in the generation of error messages and\n** column labels.  In this case, Expr.zSpan is typically the text of a\n** column expression as it exists in a SELECT statement.  However, if\n** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name\n** of the result column in the form: DATABASE.TABLE.COLUMN.  This later\n** form is used for name resolution with nested FROM clauses.\n*/\nstruct ExprList {\n  int nExpr;             /* Number of expressions on the list */\n  struct ExprList_item { /* For each expression in the list */\n    Expr *pExpr;            /* The parse tree for this expression */\n    char *zName;            /* Token associated with this expression */\n    char *zSpan;            /* Original text of the expression */\n    u8 sortOrder;           /* 1 for DESC or 0 for ASC */\n    unsigned done :1;       /* A flag to indicate when processing is finished */\n    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */\n    unsigned reusable :1;   /* Constant expression is reusable */\n    union {\n      struct {\n        u16 iOrderByCol;      /* For ORDER BY, column number in result set */\n        u16 iAlias;           /* Index into Parse.aAlias[] for zName */\n      } x;\n      int iConstExprReg;      /* Register in which Expr value is cached */\n    } u;\n  } a[1];                  /* One slot for each expression in the list */\n};\n\n/*\n** An instance of this structure is used by the parser to record both\n** the parse tree for an expression and the span of input text for an\n** expression.\n*/\nstruct ExprSpan {\n  Expr *pExpr;          /* The expression parse tree */\n  const char *zStart;   /* First character of input text */\n  const char *zEnd;     /* One character past the end of input text */\n};\n\n/*\n** An instance of this structure can hold a simple list of identifiers,\n** such as the list \"a,b,c\" in the following statements:\n**\n**      INSERT INTO t(a,b,c) VALUES ...;\n**      CREATE INDEX idx ON t(a,b,c);\n**      CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;\n**\n** The IdList.a.idx field is used when the IdList represents the list of\n** column names after a table name in an INSERT statement.  In the statement\n**\n**     INSERT INTO t(a,b,c) ...\n**\n** If \"a\" is the k-th column of table \"t\", then IdList.a[0].idx==k.\n*/\nstruct IdList {\n  struct IdList_item {\n    char *zName;      /* Name of the identifier */\n    int idx;          /* Index in some Table.aCol[] of a column named zName */\n  } *a;\n  int nId;         /* Number of identifiers on the list */\n};\n\n/*\n** The bitmask datatype defined below is used for various optimizations.\n**\n** Changing this from a 64-bit to a 32-bit type limits the number of\n** tables in a join to 32 instead of 64.  But it also reduces the size\n** of the library by 738 bytes on ix86.\n*/\n#ifdef SQLITE_BITMASK_TYPE\n  typedef SQLITE_BITMASK_TYPE Bitmask;\n#else\n  typedef u64 Bitmask;\n#endif\n\n/*\n** The number of bits in a Bitmask.  \"BMS\" means \"BitMask Size\".\n*/\n#define BMS  ((int)(sizeof(Bitmask)*8))\n\n/*\n** A bit in a Bitmask\n*/\n#define MASKBIT(n)   (((Bitmask)1)<<(n))\n#define MASKBIT32(n) (((unsigned int)1)<<(n))\n#define ALLBITS      ((Bitmask)-1)\n\n/*\n** The following structure describes the FROM clause of a SELECT statement.\n** Each table or subquery in the FROM clause is a separate element of\n** the SrcList.a[] array.\n**\n** With the addition of multiple database support, the following structure\n** can also be used to describe a particular table such as the table that\n** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,\n** such a table must be a simple name: ID.  But in SQLite, the table can\n** now be identified by a database name, a dot, then the table name: ID.ID.\n**\n** The jointype starts out showing the join type between the current table\n** and the next table on the list.  The parser builds the list this way.\n** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each\n** jointype expresses the join between the table and the previous table.\n**\n** In the colUsed field, the high-order bit (bit 63) is set if the table\n** contains more than 63 columns and the 64-th or later column is used.\n*/\nstruct SrcList {\n  int nSrc;        /* Number of tables or subqueries in the FROM clause */\n  u32 nAlloc;      /* Number of entries allocated in a[] below */\n  struct SrcList_item {\n    Schema *pSchema;  /* Schema to which this item is fixed */\n    char *zDatabase;  /* Name of database holding this table */\n    char *zName;      /* Name of the table */\n    char *zAlias;     /* The \"B\" part of a \"A AS B\" phrase.  zName is the \"A\" */\n    Table *pTab;      /* An SQL table corresponding to zName */\n    Select *pSelect;  /* A SELECT statement used in place of a table name */\n    int addrFillSub;  /* Address of subroutine to manifest a subquery */\n    int regReturn;    /* Register holding return address of addrFillSub */\n    int regResult;    /* Registers holding results of a co-routine */\n    struct {\n      u8 jointype;      /* Type of join between this table and the previous */\n      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */\n      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */\n      unsigned isTabFunc :1;     /* True if table-valued-function syntax */\n      unsigned isCorrelated :1;  /* True if sub-query is correlated */\n      unsigned viaCoroutine :1;  /* Implemented as a co-routine */\n      unsigned isRecursive :1;   /* True for recursive reference in WITH */\n    } fg;\n#ifndef SQLITE_OMIT_EXPLAIN\n    u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */\n#endif\n    int iCursor;      /* The VDBE cursor number used to access this table */\n    Expr *pOn;        /* The ON clause of a join */\n    IdList *pUsing;   /* The USING clause of a join */\n    Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */\n    union {\n      char *zIndexedBy;    /* Identifier from \"INDEXED BY <zIndex>\" clause */\n      ExprList *pFuncArg;  /* Arguments to table-valued-function */\n    } u1;\n    Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */\n  } a[1];             /* One entry for each identifier on the list */\n};\n\n/*\n** Permitted values of the SrcList.a.jointype field\n*/\n#define JT_INNER     0x0001    /* Any kind of inner or cross join */\n#define JT_CROSS     0x0002    /* Explicit use of the CROSS keyword */\n#define JT_NATURAL   0x0004    /* True for a \"natural\" join */\n#define JT_LEFT      0x0008    /* Left outer join */\n#define JT_RIGHT     0x0010    /* Right outer join */\n#define JT_OUTER     0x0020    /* The \"OUTER\" keyword is present */\n#define JT_ERROR     0x0040    /* unknown or unsupported join type */\n\n\n/*\n** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()\n** and the WhereInfo.wctrlFlags member.\n**\n** Value constraints (enforced via assert()):\n**     WHERE_USE_LIMIT  == SF_FixedLimit\n*/\n#define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */\n#define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */\n#define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */\n#define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */\n#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */\n#define WHERE_DUPLICATES_OK    0x0010 /* Ok to return a row more than once */\n#define WHERE_OR_SUBCLAUSE     0x0020 /* Processing a sub-WHERE as part of\n                                      ** the OR optimization  */\n#define WHERE_GROUPBY          0x0040 /* pOrderBy is really a GROUP BY */\n#define WHERE_DISTINCTBY       0x0080 /* pOrderby is really a DISTINCT clause */\n#define WHERE_WANT_DISTINCT    0x0100 /* All output needs to be distinct */\n#define WHERE_SORTBYGROUP      0x0200 /* Support sqlite3WhereIsSorted() */\n#define WHERE_SEEK_TABLE       0x0400 /* Do not defer seeks on main table */\n#define WHERE_ORDERBY_LIMIT    0x0800 /* ORDERBY+LIMIT on the inner loop */\n#define WHERE_SEEK_UNIQ_TABLE  0x1000 /* Do not defer seeks if unique */\n                        /*     0x2000    not currently used */\n#define WHERE_USE_LIMIT        0x4000 /* Use the LIMIT in cost estimates */\n                        /*     0x8000    not currently used */\n\n/* Allowed return values from sqlite3WhereIsDistinct()\n*/\n#define WHERE_DISTINCT_NOOP      0  /* DISTINCT keyword not used */\n#define WHERE_DISTINCT_UNIQUE    1  /* No duplicates */\n#define WHERE_DISTINCT_ORDERED   2  /* All duplicates are adjacent */\n#define WHERE_DISTINCT_UNORDERED 3  /* Duplicates are scattered */\n\n/*\n** A NameContext defines a context in which to resolve table and column\n** names.  The context consists of a list of tables (the pSrcList) field and\n** a list of named expression (pEList).  The named expression list may\n** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or\n** to the table being operated on by INSERT, UPDATE, or DELETE.  The\n** pEList corresponds to the result set of a SELECT and is NULL for\n** other statements.\n**\n** NameContexts can be nested.  When resolving names, the inner-most\n** context is searched first.  If no match is found, the next outer\n** context is checked.  If there is still no match, the next context\n** is checked.  This process continues until either a match is found\n** or all contexts are check.  When a match is found, the nRef member of\n** the context containing the match is incremented.\n**\n** Each subquery gets a new NameContext.  The pNext field points to the\n** NameContext in the parent query.  Thus the process of scanning the\n** NameContext list corresponds to searching through successively outer\n** subqueries looking for a match.\n*/\nstruct NameContext {\n  Parse *pParse;       /* The parser */\n  SrcList *pSrcList;   /* One or more tables used to resolve names */\n  ExprList *pEList;    /* Optional list of result-set columns */\n  AggInfo *pAggInfo;   /* Information about aggregates at this level */\n  NameContext *pNext;  /* Next outer name context.  NULL for outermost */\n  int nRef;            /* Number of names resolved by this context */\n  int nErr;            /* Number of errors encountered while resolving names */\n  u16 ncFlags;         /* Zero or more NC_* flags defined below */\n};\n\n/*\n** Allowed values for the NameContext, ncFlags field.\n**\n** Value constraints (all checked via assert()):\n**    NC_HasAgg    == SF_HasAgg\n**    NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX\n**\n*/\n#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */\n#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */\n#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */\n#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */\n#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */\n#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */\n#define NC_VarSelect 0x0040  /* A correlated subquery has been seen */\n#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */\n\n/*\n** An instance of the following structure contains all information\n** needed to generate code for a single SELECT statement.\n**\n** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.\n** If there is a LIMIT clause, the parser sets nLimit to the value of the\n** limit and nOffset to the value of the offset (or 0 if there is not\n** offset).  But later on, nLimit and nOffset become the memory locations\n** in the VDBE that record the limit and offset counters.\n**\n** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.\n** These addresses must be stored so that we can go back and fill in\n** the P4_KEYINFO and P2 parameters later.  Neither the KeyInfo nor\n** the number of columns in P2 can be computed at the same time\n** as the OP_OpenEphm instruction is coded because not\n** enough information about the compound query is known at that point.\n** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences\n** for the result set.  The KeyInfo for addrOpenEphm[2] contains collating\n** sequences for the ORDER BY clause.\n*/\nstruct Select {\n  ExprList *pEList;      /* The fields of the result */\n  u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */\n  LogEst nSelectRow;     /* Estimated number of result rows */\n  u32 selFlags;          /* Various SF_* values */\n  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */\n#if SELECTTRACE_ENABLED\n  char zSelName[12];     /* Symbolic name of this SELECT use for debugging */\n#endif\n  int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */\n  SrcList *pSrc;         /* The FROM clause */\n  Expr *pWhere;          /* The WHERE clause */\n  ExprList *pGroupBy;    /* The GROUP BY clause */\n  Expr *pHaving;         /* The HAVING clause */\n  ExprList *pOrderBy;    /* The ORDER BY clause */\n  Select *pPrior;        /* Prior select in a compound select statement */\n  Select *pNext;         /* Next select to the left in a compound */\n  Expr *pLimit;          /* LIMIT expression. NULL means not used. */\n  Expr *pOffset;         /* OFFSET expression. NULL means not used. */\n  With *pWith;           /* WITH clause attached to this select. Or NULL. */\n};\n\n/*\n** Allowed values for Select.selFlags.  The \"SF\" prefix stands for\n** \"Select Flag\".\n**\n** Value constraints (all checked via assert())\n**     SF_HasAgg     == NC_HasAgg\n**     SF_MinMaxAgg  == NC_MinMaxAgg     == SQLITE_FUNC_MINMAX\n**     SF_FixedLimit == WHERE_USE_LIMIT\n*/\n#define SF_Distinct       0x00001  /* Output should be DISTINCT */\n#define SF_All            0x00002  /* Includes the ALL keyword */\n#define SF_Resolved       0x00004  /* Identifiers have been resolved */\n#define SF_Aggregate      0x00008  /* Contains agg functions or a GROUP BY */\n#define SF_HasAgg         0x00010  /* Contains aggregate functions */\n#define SF_UsesEphemeral  0x00020  /* Uses the OpenEphemeral opcode */\n#define SF_Expanded       0x00040  /* sqlite3SelectExpand() called on this */\n#define SF_HasTypeInfo    0x00080  /* FROM subqueries have Table metadata */\n#define SF_Compound       0x00100  /* Part of a compound query */\n#define SF_Values         0x00200  /* Synthesized from VALUES clause */\n#define SF_MultiValue     0x00400  /* Single VALUES term with multiple rows */\n#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */\n#define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */\n#define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */\n#define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */\n#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */\n#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */\n#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */\n\n\n/*\n** The results of a SELECT can be distributed in several ways, as defined\n** by one of the following macros.  The \"SRT\" prefix means \"SELECT Result\n** Type\".\n**\n**     SRT_Union       Store results as a key in a temporary index\n**                     identified by pDest->iSDParm.\n**\n**     SRT_Except      Remove results from the temporary index pDest->iSDParm.\n**\n**     SRT_Exists      Store a 1 in memory cell pDest->iSDParm if the result\n**                     set is not empty.\n**\n**     SRT_Discard     Throw the results away.  This is used by SELECT\n**                     statements within triggers whose only purpose is\n**                     the side-effects of functions.\n**\n** All of the above are free to ignore their ORDER BY clause. Those that\n** follow must honor the ORDER BY clause.\n**\n**     SRT_Output      Generate a row of output (using the OP_ResultRow\n**                     opcode) for each row in the result set.\n**\n**     SRT_Mem         Only valid if the result is a single column.\n**                     Store the first column of the first result row\n**                     in register pDest->iSDParm then abandon the rest\n**                     of the query.  This destination implies \"LIMIT 1\".\n**\n**     SRT_Set         The result must be a single column.  Store each\n**                     row of result as the key in table pDest->iSDParm.\n**                     Apply the affinity pDest->affSdst before storing\n**                     results.  Used to implement \"IN (SELECT ...)\".\n**\n**     SRT_EphemTab    Create an temporary table pDest->iSDParm and store\n**                     the result there. The cursor is left open after\n**                     returning.  This is like SRT_Table except that\n**                     this destination uses OP_OpenEphemeral to create\n**                     the table first.\n**\n**     SRT_Coroutine   Generate a co-routine that returns a new row of\n**                     results each time it is invoked.  The entry point\n**                     of the co-routine is stored in register pDest->iSDParm\n**                     and the result row is stored in pDest->nDest registers\n**                     starting with pDest->iSdst.\n**\n**     SRT_Table       Store results in temporary table pDest->iSDParm.\n**     SRT_Fifo        This is like SRT_EphemTab except that the table\n**                     is assumed to already be open.  SRT_Fifo has\n**                     the additional property of being able to ignore\n**                     the ORDER BY clause.\n**\n**     SRT_DistFifo    Store results in a temporary table pDest->iSDParm.\n**                     But also use temporary table pDest->iSDParm+1 as\n**                     a record of all prior results and ignore any duplicate\n**                     rows.  Name means:  \"Distinct Fifo\".\n**\n**     SRT_Queue       Store results in priority queue pDest->iSDParm (really\n**                     an index).  Append a sequence number so that all entries\n**                     are distinct.\n**\n**     SRT_DistQueue   Store results in priority queue pDest->iSDParm only if\n**                     the same record has never been stored before.  The\n**                     index at pDest->iSDParm+1 hold all prior stores.\n*/\n#define SRT_Union        1  /* Store result as keys in an index */\n#define SRT_Except       2  /* Remove result from a UNION index */\n#define SRT_Exists       3  /* Store 1 if the result is not empty */\n#define SRT_Discard      4  /* Do not save the results anywhere */\n#define SRT_Fifo         5  /* Store result as data with an automatic rowid */\n#define SRT_DistFifo     6  /* Like SRT_Fifo, but unique results only */\n#define SRT_Queue        7  /* Store result in an queue */\n#define SRT_DistQueue    8  /* Like SRT_Queue, but unique results only */\n\n/* The ORDER BY clause is ignored for all of the above */\n#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue)\n\n#define SRT_Output       9  /* Output each row of result */\n#define SRT_Mem         10  /* Store result in a memory cell */\n#define SRT_Set         11  /* Store results as keys in an index */\n#define SRT_EphemTab    12  /* Create transient tab and store like SRT_Table */\n#define SRT_Coroutine   13  /* Generate a single row of result */\n#define SRT_Table       14  /* Store result as data with an automatic rowid */\n\n/*\n** An instance of this object describes where to put of the results of\n** a SELECT statement.\n*/\nstruct SelectDest {\n  u8 eDest;            /* How to dispose of the results.  On of SRT_* above. */\n  int iSDParm;         /* A parameter used by the eDest disposal method */\n  int iSdst;           /* Base register where results are written */\n  int nSdst;           /* Number of registers allocated */\n  char *zAffSdst;      /* Affinity used when eDest==SRT_Set */\n  ExprList *pOrderBy;  /* Key columns for SRT_Queue and SRT_DistQueue */\n};\n\n/*\n** During code generation of statements that do inserts into AUTOINCREMENT\n** tables, the following information is attached to the Table.u.autoInc.p\n** pointer of each autoincrement table to record some side information that\n** the code generator needs.  We have to keep per-table autoincrement\n** information in case inserts are done within triggers.  Triggers do not\n** normally coordinate their activities, but we do need to coordinate the\n** loading and saving of autoincrement information.\n*/\nstruct AutoincInfo {\n  AutoincInfo *pNext;   /* Next info block in a list of them all */\n  Table *pTab;          /* Table this info block refers to */\n  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */\n  int regCtr;           /* Memory register holding the rowid counter */\n};\n\n/*\n** Size of the column cache\n*/\n#ifndef SQLITE_N_COLCACHE\n# define SQLITE_N_COLCACHE 10\n#endif\n\n/*\n** At least one instance of the following structure is created for each\n** trigger that may be fired while parsing an INSERT, UPDATE or DELETE\n** statement. All such objects are stored in the linked list headed at\n** Parse.pTriggerPrg and deleted once statement compilation has been\n** completed.\n**\n** A Vdbe sub-program that implements the body and WHEN clause of trigger\n** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of\n** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.\n** The Parse.pTriggerPrg list never contains two entries with the same\n** values for both pTrigger and orconf.\n**\n** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns\n** accessed (or set to 0 for triggers fired as a result of INSERT\n** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to\n** a mask of new.* columns used by the program.\n*/\nstruct TriggerPrg {\n  Trigger *pTrigger;      /* Trigger this program was coded from */\n  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */\n  SubProgram *pProgram;   /* Program implementing pTrigger/orconf */\n  int orconf;             /* Default ON CONFLICT policy */\n  u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */\n};\n\n/*\n** The yDbMask datatype for the bitmask of all attached databases.\n*/\n#if SQLITE_MAX_ATTACHED>30\n  typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8];\n# define DbMaskTest(M,I)    (((M)[(I)/8]&(1<<((I)&7)))!=0)\n# define DbMaskZero(M)      memset((M),0,sizeof(M))\n# define DbMaskSet(M,I)     (M)[(I)/8]|=(1<<((I)&7))\n# define DbMaskAllZero(M)   sqlite3DbMaskAllZero(M)\n# define DbMaskNonZero(M)   (sqlite3DbMaskAllZero(M)==0)\n#else\n  typedef unsigned int yDbMask;\n# define DbMaskTest(M,I)    (((M)&(((yDbMask)1)<<(I)))!=0)\n# define DbMaskZero(M)      (M)=0\n# define DbMaskSet(M,I)     (M)|=(((yDbMask)1)<<(I))\n# define DbMaskAllZero(M)   (M)==0\n# define DbMaskNonZero(M)   (M)!=0\n#endif\n\n/*\n** An SQL parser context.  A copy of this structure is passed through\n** the parser and down into all the parser action routine in order to\n** carry around information that is global to the entire parse.\n**\n** The structure is divided into two parts.  When the parser and code\n** generate call themselves recursively, the first part of the structure\n** is constant but the second part is reset at the beginning and end of\n** each recursion.\n**\n** The nTableLock and aTableLock variables are only used if the shared-cache\n** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are\n** used to store the set of table-locks required by the statement being\n** compiled. Function sqlite3TableLock() is used to add entries to the\n** list.\n*/\nstruct Parse {\n  sqlite3 *db;         /* The main database structure */\n  char *zErrMsg;       /* An error message */\n  Vdbe *pVdbe;         /* An engine for executing database bytecode */\n  int rc;              /* Return code from execution */\n  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */\n  u8 checkSchema;      /* Causes schema cookie check after an error */\n  u8 nested;           /* Number of nested calls to the parser/code generator */\n  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */\n  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */\n  u8 mayAbort;         /* True if statement may throw an ABORT exception */\n  u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */\n  u8 okConstFactor;    /* OK to factor out constants */\n  u8 disableLookaside; /* Number of times lookaside has been disabled */\n  u8 nColCache;        /* Number of entries in aColCache[] */\n  int nRangeReg;       /* Size of the temporary register block */\n  int iRangeReg;       /* First register in temporary register block */\n  int nErr;            /* Number of errors seen */\n  int nTab;            /* Number of previously allocated VDBE cursors */\n  int nMem;            /* Number of memory cells used so far */\n  int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */\n  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */\n  int iSelfTab;        /* Table for associated with an index on expr, or negative\n                       ** of the base register during check-constraint eval */\n  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */\n  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */\n  int nLabel;          /* Number of labels used */\n  int *aLabel;         /* Space to hold the labels */\n  ExprList *pConstExpr;/* Constant expressions */\n  Token constraintName;/* Name of the constraint currently being parsed */\n  yDbMask writeMask;   /* Start a write transaction on these databases */\n  yDbMask cookieMask;  /* Bitmask of schema verified databases */\n  int regRowid;        /* Register holding rowid of CREATE TABLE entry */\n  int regRoot;         /* Register holding root page number for new objects */\n  int nMaxArg;         /* Max args passed to user function by sub-program */\n#if SELECTTRACE_ENABLED\n  int nSelect;         /* Number of SELECT statements seen */\n  int nSelectIndent;   /* How far to indent SELECTTRACE() output */\n#endif\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nTableLock;        /* Number of locks in aTableLock */\n  TableLock *aTableLock; /* Required table locks for shared-cache mode */\n#endif\n  AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */\n  Parse *pToplevel;    /* Parse structure for main program (or NULL) */\n  Table *pTriggerTab;  /* Table triggers are being coded for */\n  int addrCrTab;       /* Address of OP_CreateBtree opcode on CREATE TABLE */\n  u32 nQueryLoop;      /* Est number of iterations of a query (10*log2(N)) */\n  u32 oldmask;         /* Mask of old.* columns referenced */\n  u32 newmask;         /* Mask of new.* columns referenced */\n  u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */\n  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */\n  u8 disableTriggers;  /* True to disable triggers */\n\n  /**************************************************************************\n  ** Fields above must be initialized to zero.  The fields that follow,\n  ** down to the beginning of the recursive section, do not need to be\n  ** initialized as they will be set before being used.  The boundary is\n  ** determined by offsetof(Parse,aColCache).\n  **************************************************************************/\n\n  struct yColCache {\n    int iTable;           /* Table cursor number */\n    i16 iColumn;          /* Table column number */\n    u8 tempReg;           /* iReg is a temp register that needs to be freed */\n    int iLevel;           /* Nesting level */\n    int iReg;             /* Reg with value of this column. 0 means none. */\n    int lru;              /* Least recently used entry has the smallest value */\n  } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */\n  int aTempReg[8];        /* Holding area for temporary registers */\n  Token sNameToken;       /* Token with unqualified schema object name */\n\n  /************************************************************************\n  ** Above is constant between recursions.  Below is reset before and after\n  ** each recursion.  The boundary between these two regions is determined\n  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the\n  ** first field in the recursive region.\n  ************************************************************************/\n\n  Token sLastToken;       /* The last token parsed */\n  ynVar nVar;               /* Number of '?' variables seen in the SQL so far */\n  u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */\n  u8 explain;               /* True if the EXPLAIN flag is found on the query */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */\n  int nVtabLock;            /* Number of virtual tables to lock */\n#endif\n  int nHeight;              /* Expression tree height of current sub-select */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSelectId;            /* ID of current select for EXPLAIN output */\n  int iNextSelectId;        /* Next available select ID for EXPLAIN output */\n#endif\n  VList *pVList;            /* Mapping between variable names and numbers */\n  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */\n  const char *zTail;        /* All SQL text past the last semicolon parsed */\n  Table *pNewTable;         /* A table being constructed by CREATE TABLE */\n  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */\n  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  Token sArg;               /* Complete text of a module argument */\n  Table **apVtabLock;       /* Pointer to virtual tables needing locking */\n#endif\n  Table *pZombieTab;        /* List of Table objects to delete after code gen */\n  TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */\n  With *pWith;              /* Current WITH clause, or NULL */\n  With *pWithToFree;        /* Free this WITH object at the end of the parse */\n};\n\n/*\n** Sizes and pointers of various parts of the Parse object.\n*/\n#define PARSE_HDR_SZ offsetof(Parse,aColCache) /* Recursive part w/o aColCache*/\n#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */\n#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */\n#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */\n\n/*\n** Return true if currently inside an sqlite3_declare_vtab() call.\n*/\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  #define IN_DECLARE_VTAB 0\n#else\n  #define IN_DECLARE_VTAB (pParse->declareVtab)\n#endif\n\n/*\n** An instance of the following structure can be declared on a stack and used\n** to save the Parse.zAuthContext value so that it can be restored later.\n*/\nstruct AuthContext {\n  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */\n  Parse *pParse;              /* The Parse structure */\n};\n\n/*\n** Bitfield flags for P5 value in various opcodes.\n**\n** Value constraints (enforced via assert()):\n**    OPFLAG_LENGTHARG    == SQLITE_FUNC_LENGTH\n**    OPFLAG_TYPEOFARG    == SQLITE_FUNC_TYPEOF\n**    OPFLAG_BULKCSR      == BTREE_BULKLOAD\n**    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ\n**    OPFLAG_FORDELETE    == BTREE_FORDELETE\n**    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION\n**    OPFLAG_AUXDELETE    == BTREE_AUXDELETE\n*/\n#define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */\n                                     /* Also used in P2 (not P5) of OP_Delete */\n#define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */\n#define OPFLAG_LASTROWID     0x20    /* Set to update db->lastRowid */\n#define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */\n#define OPFLAG_APPEND        0x08    /* This is likely to be an append */\n#define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */\n#define OPFLAG_ISNOOP        0x40    /* OP_Delete does pre-update-hook only */\n#define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */\n#define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */\n#define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */\n#define OPFLAG_SEEKEQ        0x02    /* OP_Open** cursor uses EQ seek only */\n#define OPFLAG_FORDELETE     0x08    /* OP_Open should use BTREE_FORDELETE */\n#define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */\n#define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */\n#define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete/Insert: save cursor pos */\n#define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */\n\n/*\n * Each trigger present in the database schema is stored as an instance of\n * struct Trigger.\n *\n * Pointers to instances of struct Trigger are stored in two ways.\n * 1. In the \"trigHash\" hash table (part of the sqlite3* that represents the\n *    database). This allows Trigger structures to be retrieved by name.\n * 2. All triggers associated with a single table form a linked list, using the\n *    pNext member of struct Trigger. A pointer to the first element of the\n *    linked list is stored as the \"pTrigger\" member of the associated\n *    struct Table.\n *\n * The \"step_list\" member points to the first element of a linked list\n * containing the SQL statements specified as the trigger program.\n */\nstruct Trigger {\n  char *zName;            /* The name of the trigger                        */\n  char *table;            /* The table or view to which the trigger applies */\n  u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */\n  u8 tr_tm;               /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Expr *pWhen;            /* The WHEN clause of the expression (may be NULL) */\n  IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,\n                             the <column-list> is stored here */\n  Schema *pSchema;        /* Schema containing the trigger */\n  Schema *pTabSchema;     /* Schema containing the table */\n  TriggerStep *step_list; /* Link list of trigger program steps             */\n  Trigger *pNext;         /* Next trigger associated with the table */\n};\n\n/*\n** A trigger is either a BEFORE or an AFTER trigger.  The following constants\n** determine which.\n**\n** If there are multiple triggers, you might of some BEFORE and some AFTER.\n** In that cases, the constants below can be ORed together.\n*/\n#define TRIGGER_BEFORE  1\n#define TRIGGER_AFTER   2\n\n/*\n * An instance of struct TriggerStep is used to store a single SQL statement\n * that is a part of a trigger-program.\n *\n * Instances of struct TriggerStep are stored in a singly linked list (linked\n * using the \"pNext\" member) referenced by the \"step_list\" member of the\n * associated struct Trigger instance. The first element of the linked list is\n * the first step of the trigger-program.\n *\n * The \"op\" member indicates whether this is a \"DELETE\", \"INSERT\", \"UPDATE\" or\n * \"SELECT\" statement. The meanings of the other members is determined by the\n * value of \"op\" as follows:\n *\n * (op == TK_INSERT)\n * orconf    -> stores the ON CONFLICT algorithm\n * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then\n *              this stores a pointer to the SELECT statement. Otherwise NULL.\n * zTarget   -> Dequoted name of the table to insert into.\n * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then\n *              this stores values to be inserted. Otherwise NULL.\n * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...\n *              statement, then this stores the column-names to be\n *              inserted into.\n *\n * (op == TK_DELETE)\n * zTarget   -> Dequoted name of the table to delete from.\n * pWhere    -> The WHERE clause of the DELETE statement if one is specified.\n *              Otherwise NULL.\n *\n * (op == TK_UPDATE)\n * zTarget   -> Dequoted name of the table to update.\n * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.\n *              Otherwise NULL.\n * pExprList -> A list of the columns to update and the expressions to update\n *              them to. See sqlite3Update() documentation of \"pChanges\"\n *              argument.\n *\n */\nstruct TriggerStep {\n  u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */\n  u8 orconf;           /* OE_Rollback etc. */\n  Trigger *pTrig;      /* The trigger that this step is a part of */\n  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */\n  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */\n  Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */\n  ExprList *pExprList; /* SET clause for UPDATE. */\n  IdList *pIdList;     /* Column names for INSERT */\n  TriggerStep *pNext;  /* Next in the link-list */\n  TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */\n};\n\n/*\n** The following structure contains information used by the sqliteFix...\n** routines as they walk the parse tree to make database references\n** explicit.\n*/\ntypedef struct DbFixer DbFixer;\nstruct DbFixer {\n  Parse *pParse;      /* The parsing context.  Error messages written here */\n  Schema *pSchema;    /* Fix items to this schema */\n  int bVarOnly;       /* Check for variable references only */\n  const char *zDb;    /* Make sure all objects are contained in this database */\n  const char *zType;  /* Type of the container - used for error messages */\n  const Token *pName; /* Name of the container - used for error messages */\n};\n\n/*\n** An objected used to accumulate the text of a string where we\n** do not necessarily know how big the string will be in the end.\n*/\nstruct StrAccum {\n  sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */\n  char *zText;         /* The string collected so far */\n  u32  nAlloc;         /* Amount of space allocated in zText */\n  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */\n  u32  nChar;          /* Length of the string so far */\n  u8   accError;       /* STRACCUM_NOMEM or STRACCUM_TOOBIG */\n  u8   printfFlags;    /* SQLITE_PRINTF flags below */\n};\n#define STRACCUM_NOMEM   1\n#define STRACCUM_TOOBIG  2\n#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */\n#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */\n#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */\n\n#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)\n\n\n/*\n** A pointer to this structure is used to communicate information\n** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.\n*/\ntypedef struct {\n  sqlite3 *db;        /* The database being initialized */\n  char **pzErrMsg;    /* Error message stored here */\n  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */\n  int rc;             /* Result code stored here */\n} InitData;\n\n/*\n** Structure containing global configuration data for the SQLite library.\n**\n** This structure also contains some state information.\n*/\nstruct Sqlite3Config {\n  int bMemstat;                     /* True to enable memory status */\n  int bCoreMutex;                   /* True to enable core mutexing */\n  int bFullMutex;                   /* True to enable full mutexing */\n  int bOpenUri;                     /* True to interpret filenames as URIs */\n  int bUseCis;                      /* Use covering indices for full-scans */\n  int bSmallMalloc;                 /* Avoid large memory allocations if true */\n  int mxStrlen;                     /* Maximum string length */\n  int neverCorrupt;                 /* Database is always well-formed */\n  int szLookaside;                  /* Default lookaside buffer size */\n  int nLookaside;                   /* Default lookaside buffer count */\n  int nStmtSpill;                   /* Stmt-journal spill-to-disk threshold */\n  sqlite3_mem_methods m;            /* Low-level memory allocation interface */\n  sqlite3_mutex_methods mutex;      /* Low-level mutex interface */\n  sqlite3_pcache_methods2 pcache2;  /* Low-level page-cache interface */\n  void *pHeap;                      /* Heap storage space */\n  int nHeap;                        /* Size of pHeap[] */\n  int mnReq, mxReq;                 /* Min and max heap requests sizes */\n  sqlite3_int64 szMmap;             /* mmap() space per open file */\n  sqlite3_int64 mxMmap;             /* Maximum value for szMmap */\n  void *pPage;                      /* Page cache memory */\n  int szPage;                       /* Size of each page in pPage[] */\n  int nPage;                        /* Number of pages in pPage[] */\n  int mxParserStack;                /* maximum depth of the parser stack */\n  int sharedCacheEnabled;           /* true if shared-cache mode enabled */\n  u32 szPma;                        /* Maximum Sorter PMA size */\n  /* The above might be initialized to non-zero.  The following need to always\n  ** initially be zero, however. */\n  int isInit;                       /* True after initialization has finished */\n  int inProgress;                   /* True while initialization in progress */\n  int isMutexInit;                  /* True after mutexes are initialized */\n  int isMallocInit;                 /* True after malloc is initialized */\n  int isPCacheInit;                 /* True after malloc is initialized */\n  int nRefInitMutex;                /* Number of users of pInitMutex */\n  sqlite3_mutex *pInitMutex;        /* Mutex used by sqlite3_initialize() */\n  void (*xLog)(void*,int,const char*); /* Function for logging */\n  void *pLogArg;                       /* First argument to xLog() */\n#ifdef SQLITE_ENABLE_SQLLOG\n  void(*xSqllog)(void*,sqlite3*,const char*, int);\n  void *pSqllogArg;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  /* The following callback (if not NULL) is invoked on every VDBE branch\n  ** operation.  Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.\n  */\n  void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx);  /* Callback */\n  void *pVdbeBranchArg;                                     /* 1st argument */\n#endif\n#ifndef SQLITE_UNTESTABLE\n  int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */\n#endif\n  int bLocaltimeFault;              /* True to fail localtime() calls */\n  int iOnceResetThreshold;          /* When to reset OP_Once counters */\n};\n\n/*\n** This macro is used inside of assert() statements to indicate that\n** the assert is only valid on a well-formed database.  Instead of:\n**\n**     assert( X );\n**\n** One writes:\n**\n**     assert( X || CORRUPT_DB );\n**\n** CORRUPT_DB is true during normal operation.  CORRUPT_DB does not indicate\n** that the database is definitely corrupt, only that it might be corrupt.\n** For most test cases, CORRUPT_DB is set to false using a special\n** sqlite3_test_control().  This enables assert() statements to prove\n** things that are always true for well-formed databases.\n*/\n#define CORRUPT_DB  (sqlite3Config.neverCorrupt==0)\n\n/*\n** Context pointer passed down through the tree-walk.\n*/\nstruct Walker {\n  Parse *pParse;                            /* Parser context.  */\n  int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */\n  int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */\n  void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */\n  int walkerDepth;                          /* Number of subqueries */\n  u8 eCode;                                 /* A small processing code */\n  union {                                   /* Extra data for callback */\n    NameContext *pNC;                         /* Naming context */\n    int n;                                    /* A counter */\n    int iCur;                                 /* A cursor number */\n    SrcList *pSrcList;                        /* FROM clause */\n    struct SrcCount *pSrcCount;               /* Counting column references */\n    struct CCurHint *pCCurHint;               /* Used by codeCursorHint() */\n    int *aiCol;                               /* array of column indexes */\n    struct IdxCover *pIdxCover;               /* Check for index coverage */\n    struct IdxExprTrans *pIdxTrans;           /* Convert indexed expr to column */\n    ExprList *pGroupBy;                       /* GROUP BY clause */\n    struct HavingToWhereCtx *pHavingCtx;      /* HAVING to WHERE clause ctx */\n  } u;\n};\n\n/* Forward declarations */\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*);\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*);\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);\nSQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);\nSQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);\n#endif\n\n/*\n** Return code from the parse-tree walking primitives and their\n** callbacks.\n*/\n#define WRC_Continue    0   /* Continue down into children */\n#define WRC_Prune       1   /* Omit children but continue walking siblings */\n#define WRC_Abort       2   /* Abandon the tree walk */\n\n/*\n** An instance of this structure represents a set of one or more CTEs\n** (common table expressions) created by a single WITH clause.\n*/\nstruct With {\n  int nCte;                       /* Number of CTEs in the WITH clause */\n  With *pOuter;                   /* Containing WITH clause, or NULL */\n  struct Cte {                    /* For each CTE in the WITH clause.... */\n    char *zName;                    /* Name of this CTE */\n    ExprList *pCols;                /* List of explicit column names, or NULL */\n    Select *pSelect;                /* The definition of this CTE */\n    const char *zCteErr;            /* Error message for circular references */\n  } a[1];\n};\n\n#ifdef SQLITE_DEBUG\n/*\n** An instance of the TreeView object is used for printing the content of\n** data structures on sqlite3DebugPrintf() using a tree-like view.\n*/\nstruct TreeView {\n  int iLevel;             /* Which level of the tree we are on */\n  u8  bLine[100];         /* Draw vertical in column i if bLine[i] is true */\n};\n#endif /* SQLITE_DEBUG */\n\n/*\n** Assuming zIn points to the first byte of a UTF-8 character,\n** advance zIn to point to the first byte of the next UTF-8 character.\n*/\n#define SQLITE_SKIP_UTF8(zIn) {                        \\\n  if( (*(zIn++))>=0xc0 ){                              \\\n    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \\\n  }                                                    \\\n}\n\n/*\n** The SQLITE_*_BKPT macros are substitutes for the error codes with\n** the same name but without the _BKPT suffix.  These macros invoke\n** routines that report the line-number on which the error originated\n** using sqlite3_log().  The routines also provide a convenient place\n** to set a debugger breakpoint.\n*/\nSQLITE_PRIVATE int sqlite3CorruptError(int);\nSQLITE_PRIVATE int sqlite3MisuseError(int);\nSQLITE_PRIVATE int sqlite3CantopenError(int);\n#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)\n#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)\n#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   int sqlite3NomemError(int);\nSQLITE_PRIVATE   int sqlite3IoerrnomemError(int);\nSQLITE_PRIVATE   int sqlite3CorruptPgnoError(int,Pgno);\n# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)\n# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))\n#else\n# define SQLITE_NOMEM_BKPT SQLITE_NOMEM\n# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)\n#endif\n\n/*\n** FTS3 and FTS4 both require virtual table support\n*/\n#if defined(SQLITE_OMIT_VIRTUALTABLE)\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call\n** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3 1\n#endif\n\n/*\n** The ctype.h header is needed for non-ASCII systems.  It is also\n** needed by FTS3 when FTS3 is included in the amalgamation.\n*/\n#if !defined(SQLITE_ASCII) || \\\n    (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))\n# include <ctype.h>\n#endif\n\n/*\n** The following macros mimic the standard library functions toupper(),\n** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The\n** sqlite versions only work for ASCII characters, regardless of locale.\n*/\n#ifdef SQLITE_ASCII\n# define sqlite3Toupper(x)  ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))\n# define sqlite3Isspace(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x01)\n# define sqlite3Isalnum(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x06)\n# define sqlite3Isalpha(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x02)\n# define sqlite3Isdigit(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x04)\n# define sqlite3Isxdigit(x)  (sqlite3CtypeMap[(unsigned char)(x)]&0x08)\n# define sqlite3Tolower(x)   (sqlite3UpperToLower[(unsigned char)(x)])\n# define sqlite3Isquote(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x80)\n#else\n# define sqlite3Toupper(x)   toupper((unsigned char)(x))\n# define sqlite3Isspace(x)   isspace((unsigned char)(x))\n# define sqlite3Isalnum(x)   isalnum((unsigned char)(x))\n# define sqlite3Isalpha(x)   isalpha((unsigned char)(x))\n# define sqlite3Isdigit(x)   isdigit((unsigned char)(x))\n# define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))\n# define sqlite3Tolower(x)   tolower((unsigned char)(x))\n# define sqlite3Isquote(x)   ((x)=='\"'||(x)=='\\''||(x)=='['||(x)=='`')\n#endif\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_PRIVATE int sqlite3IsIdChar(u8);\n#endif\n\n/*\n** Internal function prototypes\n*/\nSQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*);\nSQLITE_PRIVATE int sqlite3Strlen30(const char*);\nSQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*);\n#define sqlite3StrNICmp sqlite3_strnicmp\n\nSQLITE_PRIVATE int sqlite3MallocInit(void);\nSQLITE_PRIVATE void sqlite3MallocEnd(void);\nSQLITE_PRIVATE void *sqlite3Malloc(u64);\nSQLITE_PRIVATE void *sqlite3MallocZero(u64);\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3*, u64);\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3*, u64);\nSQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3*, u64);\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3*,const char*);\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64);\nSQLITE_PRIVATE void *sqlite3Realloc(void*, u64);\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64);\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*);\nSQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*);\nSQLITE_PRIVATE int sqlite3MallocSize(void*);\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*);\nSQLITE_PRIVATE void *sqlite3PageMalloc(int);\nSQLITE_PRIVATE void sqlite3PageFree(void*);\nSQLITE_PRIVATE void sqlite3MemSetDefault(void);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));\n#endif\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void);\n\n/*\n** On systems with ample stack space and that support alloca(), make\n** use of alloca() to obtain space for large automatic objects.  By default,\n** obtain space from malloc().\n**\n** The alloca() routine never returns NULL.  This will cause code paths\n** that deal with sqlite3StackAlloc() failures to be unreachable.\n*/\n#ifdef SQLITE_USE_ALLOCA\n# define sqlite3StackAllocRaw(D,N)   alloca(N)\n# define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)\n# define sqlite3StackFree(D,P)\n#else\n# define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)\n# define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)\n# define sqlite3StackFree(D,P)       sqlite3DbFree(D,P)\n#endif\n\n/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together.  If they\n** are, disable MEMSYS3\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void);\n#undef SQLITE_ENABLE_MEMSYS3\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS3\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);\n#endif\n\n\n#ifndef SQLITE_MUTEX_OMIT\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3DefaultMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex_methods const *sqlite3NoopMutex(void);\nSQLITE_PRIVATE   sqlite3_mutex *sqlite3MutexAlloc(int);\nSQLITE_PRIVATE   int sqlite3MutexInit(void);\nSQLITE_PRIVATE   int sqlite3MutexEnd(void);\n#endif\n#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)\nSQLITE_PRIVATE   void sqlite3MemoryBarrier(void);\n#else\n# define sqlite3MemoryBarrier()\n#endif\n\nSQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);\nSQLITE_PRIVATE void sqlite3StatusUp(int, int);\nSQLITE_PRIVATE void sqlite3StatusDown(int, int);\nSQLITE_PRIVATE void sqlite3StatusHighwater(int, int);\nSQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3*,int*);\n\n/* Access to mutexes used by sqlite3_status() */\nSQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\nSQLITE_PRIVATE   int sqlite3IsNaN(double);\n#else\n# define sqlite3IsNaN(X)  0\n#endif\n\n/*\n** An instance of the following structure holds information about SQL\n** functions arguments that are the parameters to the printf() function.\n*/\nstruct PrintfArguments {\n  int nArg;                /* Total number of arguments */\n  int nUsed;               /* Number of arguments used so far */\n  sqlite3_value **apArg;   /* The argument values */\n};\n\nSQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, const char*, va_list);\nSQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, const char*, ...);\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\nSQLITE_PRIVATE   void sqlite3DebugPrintf(const char*, ...);\n#endif\n#if defined(SQLITE_TEST)\nSQLITE_PRIVATE   void *sqlite3TestTextToPtr(const char*);\n#endif\n\n#if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE   void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);\nSQLITE_PRIVATE   void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);\nSQLITE_PRIVATE   void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);\nSQLITE_PRIVATE   void sqlite3TreeViewSelect(TreeView*, const Select*, u8);\nSQLITE_PRIVATE   void sqlite3TreeViewWith(TreeView*, const With*, u8);\n#endif\n\n\nSQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);\nSQLITE_PRIVATE void sqlite3Dequote(char*);\nSQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);\nSQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse*);\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse*);\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int);\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse*,int,int);\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3NoTempsInRange(Parse*,int,int);\n#endif\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);\nSQLITE_PRIVATE Expr *sqlite3Expr(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);\nSQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*);\nSQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*);\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*);\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);\nSQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int);\nSQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);\nSQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);\nSQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);\nSQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);\nSQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nSQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);\n#endif\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*);\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*);\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*);\nSQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*);\nSQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);\nSQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);\nSQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);\nSQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);\nSQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\nSQLITE_PRIVATE   void sqlite3ColumnPropertiesFromName(Table*, Column*);\n#else\n# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */\n#endif\nSQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*,Token*);\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,ExprSpan*);\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);\nSQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,\n                    sqlite3_vfs**,char**,char **);\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);\n\n#ifdef SQLITE_UNTESTABLE\n# define sqlite3FaultSim(X) SQLITE_OK\n#else\nSQLITE_PRIVATE   int sqlite3FaultSim(int);\n#endif\n\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32);\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec*, u32);\nSQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec*, u32);\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec*, u32);\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec*, u32, void*);\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec*);\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec*);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int,int*);\n#endif\n\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);\nSQLITE_PRIVATE void sqlite3RowSetClear(RowSet*);\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet*, i64);\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, int iBatch, i64);\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*);\n\nSQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\nSQLITE_PRIVATE   int sqlite3ViewGetColumnNames(Parse*,Table*);\n#else\n# define sqlite3ViewGetColumnNames(A,B) 0\n#endif\n\n#if SQLITE_MAX_ATTACHED>30\nSQLITE_PRIVATE   int sqlite3DbMaskAllZero(yDbMask);\n#endif\nSQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int);\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int);\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*);\n#ifndef SQLITE_OMIT_AUTOINCREMENT\nSQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);\nSQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);\n#else\n# define sqlite3AutoincrementBegin(X)\n# define sqlite3AutoincrementEnd(X)\n#endif\nSQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,\n                                      Token*, Select*, Expr*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);\nSQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *);\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*);\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*);\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*);\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*);\nSQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);\nSQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,\n                          Expr*, int, int, u8);\nSQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int);\nSQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);\nSQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,\n                         Expr*,ExprList*,u32,Expr*,Expr*);\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);\nSQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*);\n#endif\nSQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);\nSQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);\nSQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*);\nSQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*);\n#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */\n#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */\n#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */\nSQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);\nSQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);\nSQLITE_PRIVATE void sqlite3ExprCachePop(Parse*);\nSQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);\nSQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);\n#define SQLITE_ECEL_DUP      0x01  /* Deep, not shallow copies */\n#define SQLITE_ECEL_FACTOR   0x02  /* Factor out constant terms */\n#define SQLITE_ECEL_REF      0x04  /* Use ExprList.u.x.iOrderByCol */\n#define SQLITE_ECEL_OMITREF  0x08  /* Omit if ExprList.u.x.iOrderByCol */\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int);\nSQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*);\n#define LOCATE_VIEW    0x01\n#define LOCATE_NOERR   0x02\nSQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);\nSQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);\nSQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);\nSQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);\nSQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*);\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE void sqlite3PrngSaveState(void);\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void);\n#endif\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse*, int);\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse*, int);\nSQLITE_PRIVATE void sqlite3EndTransaction(Parse*,int);\nSQLITE_PRIVATE void sqlite3Savepoint(Parse*, int, Token*);\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *);\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);\nSQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nSQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*);\n#endif\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);\nSQLITE_PRIVATE int sqlite3IsRowid(const char*);\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(\n    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);\nSQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,\n                                     u8,u8,int,int*,int*);\n#ifdef SQLITE_ENABLE_NULL_TRIM\nSQLITE_PRIVATE   void sqlite3SetMakeRecordP5(Vdbe*,Table*);\n#else\n# define sqlite3SetMakeRecordP5(A,B)\n#endif\nSQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse*);\nSQLITE_PRIVATE void sqlite3MayAbort(Parse*);\nSQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);\nSQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*);\nSQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*);\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int);\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);\n#if SELECTTRACE_ENABLED\nSQLITE_PRIVATE void sqlite3SelectSetName(Select*,const char*);\n#else\n# define sqlite3SelectSetName(A,B)\n#endif\nSQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);\nSQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE void sqlite3MaterializeView(Parse*, Table*, Expr*, int);\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE   void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,\n                           Expr*,int, int);\nSQLITE_PRIVATE   void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);\nSQLITE_PRIVATE   void sqlite3DropTrigger(Parse*, SrcList*, int);\nSQLITE_PRIVATE   void sqlite3DropTriggerPtr(Parse*, Trigger*);\nSQLITE_PRIVATE   Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);\nSQLITE_PRIVATE   Trigger *sqlite3TriggerList(Parse *, Table *);\nSQLITE_PRIVATE   void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,\n                            int, int, int);\nSQLITE_PRIVATE   void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);\n  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);\nSQLITE_PRIVATE   void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,\n                                        Select*,u8);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);\nSQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);\nSQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);\nSQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);\nSQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);\n# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))\n# define sqlite3IsToplevel(p) ((p)->pToplevel==0)\n#else\n# define sqlite3TriggersExist(B,C,D,E,F) 0\n# define sqlite3DeleteTrigger(A,B)\n# define sqlite3DropTriggerPtr(A,B)\n# define sqlite3UnlinkAndDeleteTrigger(A,B,C)\n# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)\n# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)\n# define sqlite3TriggerList(X, Y) 0\n# define sqlite3ParseToplevel(p) p\n# define sqlite3IsToplevel(p) 1\n# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0\n#endif\n\nSQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int);\n#ifndef SQLITE_OMIT_AUTHORIZATION\nSQLITE_PRIVATE   void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);\nSQLITE_PRIVATE   int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);\nSQLITE_PRIVATE   void sqlite3AuthContextPop(AuthContext*);\nSQLITE_PRIVATE   int sqlite3AuthReadCol(Parse*, const char *, const char *, int);\n#else\n# define sqlite3AuthRead(a,b,c,d)\n# define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK\n# define sqlite3AuthContextPush(a,b,c)\n# define sqlite3AuthContextPop(a)  ((void)(a))\n#endif\nSQLITE_PRIVATE void sqlite3Attach(Parse*, Expr*, Expr*, Expr*);\nSQLITE_PRIVATE void sqlite3Detach(Parse*, Expr*);\nSQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);\nSQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);\nSQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);\nSQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);\nSQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);\nSQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);\nSQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);\nSQLITE_PRIVATE int sqlite3Atoi(const char*);\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);\n#endif\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);\nSQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);\nSQLITE_PRIVATE LogEst sqlite3LogEst(u64);\nSQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nSQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);\n#endif\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\nSQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);\n#endif\nSQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);\nSQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);\nSQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int);\n\n/*\n** Routines to read and write variable-length integers.  These used to\n** be defined locally, but now we use the varint routines in the util.c\n** file.\n*/\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char*, u64);\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *, u64 *);\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *, u32 *);\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v);\n\n/*\n** The common case is for a varint to be a single byte.  They following\n** macros handle the common case without a procedure call, but then call\n** the procedure for larger varints.\n*/\n#define getVarint32(A,B)  \\\n  (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))\n#define putVarint32(A,B)  \\\n  (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\\\n  sqlite3PutVarint((A),(B)))\n#define getVarint    sqlite3GetVarint\n#define putVarint    sqlite3PutVarint\n\n\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*);\nSQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int);\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2);\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);\nSQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int);\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr);\nSQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8);\nSQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);\nSQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);\nSQLITE_PRIVATE void sqlite3Error(sqlite3*,int);\nSQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h);\nSQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);\n\n#if defined(SQLITE_NEED_ERR_NAME)\nSQLITE_PRIVATE const char *sqlite3ErrName(int);\n#endif\n\nSQLITE_PRIVATE const char *sqlite3ErrStr(int);\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);\nSQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);\nSQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *, const char *);\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);\nSQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);\nSQLITE_PRIVATE int sqlite3AbsInt32(int);\n#ifdef SQLITE_ENABLE_8_3_NAMES\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char*, char*);\n#else\n# define sqlite3FileSuffix3(X,Y)\n#endif\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z,u8);\n\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value*, u8);\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);\nSQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,\n                        void(*)(void*));\nSQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value*);\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);\n#endif\nSQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);\n#ifndef SQLITE_AMALGAMATION\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];\nSQLITE_PRIVATE const char sqlite3StrBINARY[];\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];\nSQLITE_PRIVATE const Token sqlite3IntTokens[];\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;\nSQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions;\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte;\n#endif\n#endif\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int);\nSQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*);\nSQLITE_PRIVATE void sqlite3AlterFunctions(void);\nSQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);\nSQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*);\nSQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);\nSQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);\nSQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);\nSQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);\nSQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);\nSQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);\nSQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);\nSQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*);\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int);\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);\nSQLITE_PRIVATE void sqlite3SchemaClear(void *);\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *);\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);\nSQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*);\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*);\n#endif\nSQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,\n  void (*)(sqlite3_context*,int,sqlite3_value **),\n  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),\n  FuncDestructor *pDestructor\n);\nSQLITE_PRIVATE void sqlite3OomFault(sqlite3*);\nSQLITE_PRIVATE void sqlite3OomClear(sqlite3*);\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);\n\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);\nSQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);\nSQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);\nSQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);\nSQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);\n\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);\n\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3ExprCheckIN(Parse*, Expr*);\n#else\n# define sqlite3ExprCheckIN(x,y) SQLITE_OK\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nSQLITE_PRIVATE void sqlite3AnalyzeFunctions(void);\nSQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(\n    Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);\nSQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);\nSQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord*);\nSQLITE_PRIVATE int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);\nSQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);\n#endif\n\n/*\n** The interface to the LEMON-generated parser\n*/\n#ifndef SQLITE_AMALGAMATION\nSQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64));\nSQLITE_PRIVATE   void sqlite3ParserFree(void*, void(*)(void*));\n#endif\nSQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE   int sqlite3ParserStackPeak(void*);\n#endif\n\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE   void sqlite3CloseExtensions(sqlite3*);\n#else\n# define sqlite3CloseExtensions(X)\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\nSQLITE_PRIVATE   void sqlite3TableLock(Parse *, int, int, u8, const char *);\n#else\n  #define sqlite3TableLock(v,w,x,y,z)\n#endif\n\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE   int sqlite3Utf8To8(unsigned char*);\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n#  define sqlite3VtabClear(Y)\n#  define sqlite3VtabSync(X,Y) SQLITE_OK\n#  define sqlite3VtabRollback(X)\n#  define sqlite3VtabCommit(X)\n#  define sqlite3VtabInSync(db) 0\n#  define sqlite3VtabLock(X)\n#  define sqlite3VtabUnlock(X)\n#  define sqlite3VtabUnlockList(X)\n#  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK\n#  define sqlite3GetVTable(X,Y)  ((VTable*)0)\n#else\nSQLITE_PRIVATE    void sqlite3VtabClear(sqlite3 *db, Table*);\nSQLITE_PRIVATE    void sqlite3VtabDisconnect(sqlite3 *db, Table *p);\nSQLITE_PRIVATE    int sqlite3VtabSync(sqlite3 *db, Vdbe*);\nSQLITE_PRIVATE    int sqlite3VtabRollback(sqlite3 *db);\nSQLITE_PRIVATE    int sqlite3VtabCommit(sqlite3 *db);\nSQLITE_PRIVATE    void sqlite3VtabLock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlock(VTable *);\nSQLITE_PRIVATE    void sqlite3VtabUnlockList(sqlite3*);\nSQLITE_PRIVATE    int sqlite3VtabSavepoint(sqlite3 *, int, int);\nSQLITE_PRIVATE    void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);\nSQLITE_PRIVATE    VTable *sqlite3GetVTable(sqlite3*, Table*);\nSQLITE_PRIVATE    Module *sqlite3VtabCreateModule(\n     sqlite3*,\n     const char*,\n     const sqlite3_module*,\n     void*,\n     void(*)(void*)\n   );\n#  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)\n#endif\nSQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);\nSQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);\nSQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*);\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse*);\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*);\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);\nSQLITE_PRIVATE void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);\nSQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);\nSQLITE_PRIVATE void sqlite3ParserReset(Parse*);\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);\nSQLITE_PRIVATE const char *sqlite3JournalModename(int);\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE   int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);\nSQLITE_PRIVATE   int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);\n#endif\n#ifndef SQLITE_OMIT_CTE\nSQLITE_PRIVATE   With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);\nSQLITE_PRIVATE   void sqlite3WithDelete(sqlite3*,With*);\nSQLITE_PRIVATE   void sqlite3WithPush(Parse*, With*, u8);\n#else\n#define sqlite3WithPush(x,y,z)\n#define sqlite3WithDelete(x,y)\n#endif\n\n/* Declarations for functions in fkey.c. All of these are replaced by\n** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign\n** key functionality is available. If OMIT_TRIGGER is defined but\n** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In\n** this case foreign keys are parsed, but no other functionality is\n** provided (enforcement of FK constraints requires the triggers sub-system).\n*/\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE   void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);\nSQLITE_PRIVATE   void sqlite3FkDropTable(Parse*, SrcList *, Table*);\nSQLITE_PRIVATE   void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);\nSQLITE_PRIVATE   int sqlite3FkRequired(Parse*, Table*, int*, int);\nSQLITE_PRIVATE   u32 sqlite3FkOldmask(Parse*, Table*);\nSQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *);\n#else\n  #define sqlite3FkActions(a,b,c,d,e,f)\n  #define sqlite3FkCheck(a,b,c,d,e,f)\n  #define sqlite3FkDropTable(a,b,c)\n  #define sqlite3FkOldmask(a,b)         0\n  #define sqlite3FkRequired(a,b,c,d)    0\n  #define sqlite3FkReferences(a)        0\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE   void sqlite3FkDelete(sqlite3 *, Table*);\nSQLITE_PRIVATE   int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);\n#else\n  #define sqlite3FkDelete(a,b)\n  #define sqlite3FkLocateIndex(a,b,c,d,e)\n#endif\n\n\n/*\n** Available fault injectors.  Should be numbered beginning with 0.\n*/\n#define SQLITE_FAULTINJECTOR_MALLOC     0\n#define SQLITE_FAULTINJECTOR_COUNT      1\n\n/*\n** The interface to the code in fault.c used for identifying \"benign\"\n** malloc failures. This is only present if SQLITE_UNTESTABLE\n** is not defined.\n*/\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE   void sqlite3BeginBenignMalloc(void);\nSQLITE_PRIVATE   void sqlite3EndBenignMalloc(void);\n#else\n  #define sqlite3BeginBenignMalloc()\n  #define sqlite3EndBenignMalloc()\n#endif\n\n/*\n** Allowed return values from sqlite3FindInIndex()\n*/\n#define IN_INDEX_ROWID        1   /* Search the rowid of the table */\n#define IN_INDEX_EPH          2   /* Search an ephemeral b-tree */\n#define IN_INDEX_INDEX_ASC    3   /* Existing index ASCENDING */\n#define IN_INDEX_INDEX_DESC   4   /* Existing index DESCENDING */\n#define IN_INDEX_NOOP         5   /* No table available. Use comparisons */\n/*\n** Allowed flags for the 3rd parameter to sqlite3FindInIndex().\n*/\n#define IN_INDEX_NOOP_OK     0x0001  /* OK to return IN_INDEX_NOOP */\n#define IN_INDEX_MEMBERSHIP  0x0002  /* IN operator used for membership test */\n#define IN_INDEX_LOOP        0x0004  /* IN operator used as a loop */\nSQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);\n\nSQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);\nSQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\nSQLITE_PRIVATE   int sqlite3JournalCreate(sqlite3_file *);\n#endif\n\nSQLITE_PRIVATE int sqlite3JournalIsInMemory(sqlite3_file *p);\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);\n\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);\n#if SQLITE_MAX_EXPR_DEPTH>0\nSQLITE_PRIVATE   int sqlite3SelectExprHeight(Select *);\nSQLITE_PRIVATE   int sqlite3ExprCheckHeight(Parse*, int);\n#else\n  #define sqlite3SelectExprHeight(x) 0\n  #define sqlite3ExprCheckHeight(x,y)\n#endif\n\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8*);\nSQLITE_PRIVATE void sqlite3Put4byte(u8*, u32);\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nSQLITE_PRIVATE   void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);\nSQLITE_PRIVATE   void sqlite3ConnectionUnlocked(sqlite3 *db);\nSQLITE_PRIVATE   void sqlite3ConnectionClosed(sqlite3 *db);\n#else\n  #define sqlite3ConnectionBlocked(x,y)\n  #define sqlite3ConnectionUnlocked(x)\n  #define sqlite3ConnectionClosed(x)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3ParserTrace(FILE*, char *);\n#endif\n\n/*\n** If the SQLITE_ENABLE IOTRACE exists then the global variable\n** sqlite3IoTrace is a pointer to a printf-like routine used to\n** print I/O tracing messages.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\n# define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }\nSQLITE_PRIVATE   void sqlite3VdbeIOTraceSql(Vdbe*);\nSQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);\n#else\n# define IOTRACE(A)\n# define sqlite3VdbeIOTraceSql(X)\n#endif\n\n/*\n** These routines are available for the mem2.c debugging memory allocator\n** only.  They are used to verify that different \"types\" of memory\n** allocations are properly tracked by the system.\n**\n** sqlite3MemdebugSetType() sets the \"type\" of an allocation to one of\n** the MEMTYPE_* macros defined below.  The type must be a bitmask with\n** a single bit set.\n**\n** sqlite3MemdebugHasType() returns true if any of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n** sqlite3MemdebugHasType() is intended for use inside assert() statements.\n**\n** sqlite3MemdebugNoType() returns true if none of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n**\n** Perhaps the most important point is the difference between MEMTYPE_HEAP\n** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means\n** it might have been allocated by lookaside, except the allocation was\n** too large or lookaside was already full.  It is important to verify\n** that allocations that might have been satisfied by lookaside are not\n** passed back to non-lookaside free() routines.  Asserts such as the\n** example above are placed on the non-lookaside free() routines to verify\n** this constraint.\n**\n** All of this is no-op for a production build.  It only comes into\n** play when the SQLITE_MEMDEBUG compile-time option is used.\n*/\n#ifdef SQLITE_MEMDEBUG\nSQLITE_PRIVATE   void sqlite3MemdebugSetType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugHasType(void*,u8);\nSQLITE_PRIVATE   int sqlite3MemdebugNoType(void*,u8);\n#else\n# define sqlite3MemdebugSetType(X,Y)  /* no-op */\n# define sqlite3MemdebugHasType(X,Y)  1\n# define sqlite3MemdebugNoType(X,Y)   1\n#endif\n#define MEMTYPE_HEAP       0x01  /* General heap allocations */\n#define MEMTYPE_LOOKASIDE  0x02  /* Heap that might have been lookaside */\n#define MEMTYPE_PCACHE     0x04  /* Page cache allocations */\n\n/*\n** Threading interface\n*/\n#if SQLITE_MAX_WORKER_THREADS>0\nSQLITE_PRIVATE int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread*, void**);\n#endif\n\n#if defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3*);\n#endif\n#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*);\n#endif\n\nSQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);\nSQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);\nSQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);\nSQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);\nSQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);\n#endif\n\n#endif /* SQLITEINT_H */\n\n/************** End of sqliteInt.h *******************************************/\n/************** Begin file global.c ******************************************/\n/*\n** 2008 June 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains definitions of global variables and constants.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* An array to map all upper-case characters into their corresponding\n** lower-case character. \n**\n** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not\n** handle case conversions for the UTF character set since the tables\n** involved are nearly as big or bigger than SQLite itself.\n*/\nSQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {\n#ifdef SQLITE_ASCII\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,\n     18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n     36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,\n     54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,\n    104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,\n    122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,\n    108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,\n    126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,\n    162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,\n    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,\n    198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,\n    216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,\n    234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,\n    252,253,254,255\n#endif\n#ifdef SQLITE_EBCDIC\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */\n     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */\n     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */\n     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */\n     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */\n     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */\n     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */\n    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */\n    128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */\n    160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */\n    176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */\n    192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */\n    208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */\n    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */\n    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */\n#endif\n};\n\n/*\n** The following 256 byte lookup table is used to support SQLites built-in\n** equivalents to the following standard library functions:\n**\n**   isspace()                        0x01\n**   isalpha()                        0x02\n**   isdigit()                        0x04\n**   isalnum()                        0x06\n**   isxdigit()                       0x08\n**   toupper()                        0x20\n**   SQLite identifier character      0x40\n**   Quote character                  0x80\n**\n** Bit 0x20 is set if the mapped character requires translation to upper\n** case. i.e. if the character is a lower-case ASCII character.\n** If x is a lower-case ASCII character, then its upper-case equivalent\n** is (x - 0x20). Therefore toupper() can be implemented as:\n**\n**   (x & ~(map[x]&0x20))\n**\n** The equivalent of tolower() is implemented using the sqlite3UpperToLower[]\n** array. tolower() is used more often than toupper() by SQLite.\n**\n** Bit 0x40 is set if the character is non-alphanumeric and can be used in an \n** SQLite identifier.  Identifiers are alphanumerics, \"_\", \"$\", and any\n** non-ASCII UTF character. Hence the test for whether or not a character is\n** part of an identifier is 0x46.\n*/\n#ifdef SQLITE_ASCII\nSQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 00..07    ........ */\n  0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */\n  0x01, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x80,  /* 20..27     !\"#$%&' */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */\n  0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */\n  0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */\n\n  0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */\n  0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\\]^_ */\n  0x80, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */\n  0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */\n};\n#endif\n\n/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards\n** compatibility for legacy applications, the URI filename capability is\n** disabled by default.\n**\n** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled\n** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.\n**\n** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** SQLITE_USE_URI symbol defined.\n**\n** URI filenames are enabled by default if SQLITE_HAS_CODEC is\n** enabled.\n*/\n#ifndef SQLITE_USE_URI\n# ifdef SQLITE_HAS_CODEC\n#  define SQLITE_USE_URI 1\n# else\n#  define SQLITE_USE_URI 0\n# endif\n#endif\n\n/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the\n** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is \"on\" if\n** that compile-time option is omitted.\n*/\n#ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN\n# define SQLITE_ALLOW_COVERING_INDEX_SCAN 1\n#endif\n\n/* The minimum PMA size is set to this value multiplied by the database\n** page size in bytes.\n*/\n#ifndef SQLITE_SORTER_PMASZ\n# define SQLITE_SORTER_PMASZ 250\n#endif\n\n/* Statement journals spill to disk when their size exceeds the following\n** threshold (in bytes). 0 means that statement journals are created and\n** written to disk immediately (the default behavior for SQLite versions\n** before 3.12.0).  -1 means always keep the entire statement journal in\n** memory.  (The statement journal is also always held entirely in memory\n** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this\n** setting.)\n*/\n#ifndef SQLITE_STMTJRNL_SPILL \n# define SQLITE_STMTJRNL_SPILL (64*1024)\n#endif\n\n/*\n** The default lookaside-configuration, the format \"SZ,N\".  SZ is the\n** number of bytes in each lookaside slot (should be a multiple of 8)\n** and N is the number of slots.  The lookaside-configuration can be\n** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)\n** or at run-time for an individual database connection using\n** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);\n*/\n#ifndef SQLITE_DEFAULT_LOOKASIDE\n# define SQLITE_DEFAULT_LOOKASIDE 1200,100\n#endif\n\n\n/*\n** The following singleton contains the global configuration for\n** the SQLite library.\n*/\nSQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {\n   SQLITE_DEFAULT_MEMSTATUS,  /* bMemstat */\n   1,                         /* bCoreMutex */\n   SQLITE_THREADSAFE==1,      /* bFullMutex */\n   SQLITE_USE_URI,            /* bOpenUri */\n   SQLITE_ALLOW_COVERING_INDEX_SCAN,   /* bUseCis */\n   0,                         /* bSmallMalloc */\n   0x7ffffffe,                /* mxStrlen */\n   0,                         /* neverCorrupt */\n   SQLITE_DEFAULT_LOOKASIDE,  /* szLookaside, nLookaside */\n   SQLITE_STMTJRNL_SPILL,     /* nStmtSpill */\n   {0,0,0,0,0,0,0,0},         /* m */\n   {0,0,0,0,0,0,0,0,0},       /* mutex */\n   {0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */\n   (void*)0,                  /* pHeap */\n   0,                         /* nHeap */\n   0, 0,                      /* mnHeap, mxHeap */\n   SQLITE_DEFAULT_MMAP_SIZE,  /* szMmap */\n   SQLITE_MAX_MMAP_SIZE,      /* mxMmap */\n   (void*)0,                  /* pPage */\n   0,                         /* szPage */\n   SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */\n   0,                         /* mxParserStack */\n   0,                         /* sharedCacheEnabled */\n   SQLITE_SORTER_PMASZ,       /* szPma */\n   /* All the rest should always be initialized to zero */\n   0,                         /* isInit */\n   0,                         /* inProgress */\n   0,                         /* isMutexInit */\n   0,                         /* isMallocInit */\n   0,                         /* isPCacheInit */\n   0,                         /* nRefInitMutex */\n   0,                         /* pInitMutex */\n   0,                         /* xLog */\n   0,                         /* pLogArg */\n#ifdef SQLITE_ENABLE_SQLLOG\n   0,                         /* xSqllog */\n   0,                         /* pSqllogArg */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n   0,                         /* xVdbeBranch */\n   0,                         /* pVbeBranchArg */\n#endif\n#ifndef SQLITE_UNTESTABLE\n   0,                         /* xTestCallback */\n#endif\n   0,                         /* bLocaltimeFault */\n   0x7ffffffe                 /* iOnceResetThreshold */\n};\n\n/*\n** Hash table for global functions - functions common to all\n** database connections.  After initialization, this table is\n** read-only.\n*/\nSQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions;\n\n/*\n** Constant tokens for values 0 and 1.\n*/\nSQLITE_PRIVATE const Token sqlite3IntTokens[] = {\n   { \"0\", 1 },\n   { \"1\", 1 }\n};\n\n\n/*\n** The value of the \"pending\" byte must be 0x40000000 (1 byte past the\n** 1-gibabyte boundary) in a compatible database.  SQLite never uses\n** the database page that contains the pending byte.  It never attempts\n** to read or write that page.  The pending byte page is set aside\n** for use by the VFS layers as space for managing file locks.\n**\n** During testing, it is often desirable to move the pending byte to\n** a different position in the file.  This allows code that has to\n** deal with the pending byte to run on files that are much smaller\n** than 1 GiB.  The sqlite3_test_control() interface can be used to\n** move the pending byte.\n**\n** IMPORTANT:  Changing the pending byte to any value other than\n** 0x40000000 results in an incompatible database file format!\n** Changing the pending byte during operation will result in undefined\n** and incorrect behavior.\n*/\n#ifndef SQLITE_OMIT_WSD\nSQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;\n#endif\n\n/* #include \"opcodes.h\" */\n/*\n** Properties of opcodes.  The OPFLG_INITIALIZER macro is\n** created by mkopcodeh.awk during compilation.  Data is obtained\n** from the comments following the \"case OP_xxxx:\" statements in\n** the vdbe.c file.  \n*/\nSQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;\n\n/*\n** Name of the default collating sequence\n*/\nSQLITE_PRIVATE const char sqlite3StrBINARY[] = \"BINARY\";\n\n/************** End of global.c **********************************************/\n/************** Begin file status.c ******************************************/\n/*\n** 2008 June 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements the sqlite3_status() interface and related\n** functionality.\n*/\n/* #include \"sqliteInt.h\" */\n/************** Include vdbeInt.h in the middle of status.c ******************/\n/************** Begin file vdbeInt.h *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for information that is private to the\n** VDBE.  This information used to all be at the top of the single\n** source code file \"vdbe.c\".  When that file became too big (over\n** 6000 lines long) it was split up into several smaller files and\n** this header information was factored out.\n*/\n#ifndef SQLITE_VDBEINT_H\n#define SQLITE_VDBEINT_H\n\n/*\n** The maximum number of times that a statement will try to reparse\n** itself before giving up and returning SQLITE_SCHEMA.\n*/\n#ifndef SQLITE_MAX_SCHEMA_RETRY\n# define SQLITE_MAX_SCHEMA_RETRY 50\n#endif\n\n/*\n** VDBE_DISPLAY_P4 is true or false depending on whether or not the\n** \"explain\" P4 display logic is enabled.\n*/\n#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \\\n     || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n# define VDBE_DISPLAY_P4 1\n#else\n# define VDBE_DISPLAY_P4 0\n#endif\n\n/*\n** SQL is translated into a sequence of instructions to be\n** executed by a virtual machine.  Each instruction is an instance\n** of the following structure.\n*/\ntypedef struct VdbeOp Op;\n\n/*\n** Boolean values\n*/\ntypedef unsigned Bool;\n\n/* Opaque type used by code in vdbesort.c */\ntypedef struct VdbeSorter VdbeSorter;\n\n/* Elements of the linked list at Vdbe.pAuxData */\ntypedef struct AuxData AuxData;\n\n/* Types of VDBE cursors */\n#define CURTYPE_BTREE       0\n#define CURTYPE_SORTER      1\n#define CURTYPE_VTAB        2\n#define CURTYPE_PSEUDO      3\n\n/*\n** A VdbeCursor is an superclass (a wrapper) for various cursor objects:\n**\n**      * A b-tree cursor\n**          -  In the main database or in an ephemeral database\n**          -  On either an index or a table\n**      * A sorter\n**      * A virtual table\n**      * A one-row \"pseudotable\" stored in a single register\n*/\ntypedef struct VdbeCursor VdbeCursor;\nstruct VdbeCursor {\n  u8 eCurType;            /* One of the CURTYPE_* values above */\n  i8 iDb;                 /* Index of cursor database in db->aDb[] (or -1) */\n  u8 nullRow;             /* True if pointing to a row with no data */\n  u8 deferredMoveto;      /* A call to sqlite3BtreeMoveto() is needed */\n  u8 isTable;             /* True for rowid tables.  False for indexes */\n#ifdef SQLITE_DEBUG\n  u8 seekOp;              /* Most recent seek operation on this cursor */\n  u8 wrFlag;              /* The wrFlag argument to sqlite3BtreeCursor() */\n#endif\n  Bool isEphemeral:1;     /* True for an ephemeral table */\n  Bool useRandomRowid:1;  /* Generate new record numbers semi-randomly */\n  Bool isOrdered:1;       /* True if the table is not BTREE_UNORDERED */\n  Btree *pBtx;            /* Separate file holding temporary table */\n  i64 seqCount;           /* Sequence counter */\n  int *aAltMap;           /* Mapping from table to index column numbers */\n\n  /* Cached OP_Column parse information is only valid if cacheStatus matches\n  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of\n  ** CACHE_STALE (0) and so setting cacheStatus=CACHE_STALE guarantees that\n  ** the cache is out of date. */\n  u32 cacheStatus;        /* Cache is valid if this matches Vdbe.cacheCtr */\n  int seekResult;         /* Result of previous sqlite3BtreeMoveto() or 0\n                          ** if there have been no prior seeks on the cursor. */\n  /* seekResult does not distinguish between \"no seeks have ever occurred\n  ** on this cursor\" and \"the most recent seek was an exact match\".\n  ** For CURTYPE_PSEUDO, seekResult is the register holding the record */\n\n  /* When a new VdbeCursor is allocated, only the fields above are zeroed.\n  ** The fields that follow are uninitialized, and must be individually\n  ** initialized prior to first use. */\n  VdbeCursor *pAltCursor; /* Associated index cursor from which to read */\n  union {\n    BtCursor *pCursor;          /* CURTYPE_BTREE or _PSEUDO.  Btree cursor */\n    sqlite3_vtab_cursor *pVCur; /* CURTYPE_VTAB.              Vtab cursor */\n    VdbeSorter *pSorter;        /* CURTYPE_SORTER.            Sorter object */\n  } uc;\n  KeyInfo *pKeyInfo;      /* Info about index keys needed by index cursors */\n  u32 iHdrOffset;         /* Offset to next unparsed byte of the header */\n  Pgno pgnoRoot;          /* Root page of the open btree cursor */\n  i16 nField;             /* Number of fields in the header */\n  u16 nHdrParsed;         /* Number of header fields parsed so far */\n  i64 movetoTarget;       /* Argument to the deferred sqlite3BtreeMoveto() */\n  u32 *aOffset;           /* Pointer to aType[nField] */\n  const u8 *aRow;         /* Data for the current row, if all on one page */\n  u32 payloadSize;        /* Total number of bytes in the record */\n  u32 szRow;              /* Byte available in aRow */\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n  u64 maskUsed;           /* Mask of columns used by this cursor */\n#endif\n\n  /* 2*nField extra array elements allocated for aType[], beyond the one\n  ** static element declared in the structure.  nField total array slots for\n  ** aType[] and nField+1 array slots for aOffset[] */\n  u32 aType[1];           /* Type values record decode.  MUST BE LAST */\n};\n\n\n/*\n** A value for VdbeCursor.cacheStatus that means the cache is always invalid.\n*/\n#define CACHE_STALE 0\n\n/*\n** When a sub-program is executed (OP_Program), a structure of this type\n** is allocated to store the current value of the program counter, as\n** well as the current memory cell array and various other frame specific\n** values stored in the Vdbe struct. When the sub-program is finished, \n** these values are copied back to the Vdbe from the VdbeFrame structure,\n** restoring the state of the VM to as it was before the sub-program\n** began executing.\n**\n** The memory for a VdbeFrame object is allocated and managed by a memory\n** cell in the parent (calling) frame. When the memory cell is deleted or\n** overwritten, the VdbeFrame object is not freed immediately. Instead, it\n** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame\n** list is deleted when the VM is reset in VdbeHalt(). The reason for doing\n** this instead of deleting the VdbeFrame immediately is to avoid recursive\n** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the\n** child frame are released.\n**\n** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is\n** set to NULL if the currently executing frame is the main program.\n*/\ntypedef struct VdbeFrame VdbeFrame;\nstruct VdbeFrame {\n  Vdbe *v;                /* VM this frame belongs to */\n  VdbeFrame *pParent;     /* Parent of this frame, or NULL if parent is main */\n  Op *aOp;                /* Program instructions for parent frame */\n  i64 *anExec;            /* Event counters from parent frame */\n  Mem *aMem;              /* Array of memory cells for parent frame */\n  VdbeCursor **apCsr;     /* Array of Vdbe cursors for parent frame */\n  u8 *aOnce;              /* Bitmask used by OP_Once */\n  void *token;            /* Copy of SubProgram.token */\n  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n  int nCursor;            /* Number of entries in apCsr */\n  int pc;                 /* Program Counter in parent (calling) frame */\n  int nOp;                /* Size of aOp array */\n  int nMem;               /* Number of entries in aMem */\n  int nChildMem;          /* Number of memory cells for child frame */\n  int nChildCsr;          /* Number of cursors for child frame */\n  int nChange;            /* Statement changes (Vdbe.nChange)     */\n  int nDbChange;          /* Value of db->nChange */\n};\n\n#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])\n\n/*\n** Internally, the vdbe manipulates nearly all SQL values as Mem\n** structures. Each Mem struct may cache multiple representations (string,\n** integer etc.) of the same value.\n*/\nstruct sqlite3_value {\n  union MemValue {\n    double r;           /* Real value used when MEM_Real is set in flags */\n    i64 i;              /* Integer value used when MEM_Int is set in flags */\n    int nZero;          /* Extra zero bytes when MEM_Zero and MEM_Blob set */\n    const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */\n    FuncDef *pDef;      /* Used only when flags==MEM_Agg */\n    RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */\n    VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */\n  } u;\n  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */\n  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */\n  u8  eSubtype;       /* Subtype for this value */\n  int n;              /* Number of characters in string value, excluding '\\0' */\n  char *z;            /* String or BLOB value */\n  /* ShallowCopy only needs to copy the information above */\n  char *zMalloc;      /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */\n  int szMalloc;       /* Size of the zMalloc allocation */\n  u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */\n  sqlite3 *db;        /* The associated database connection */\n  void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */\n#ifdef SQLITE_DEBUG\n  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */\n  void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */\n#endif\n};\n\n/*\n** Size of struct Mem not including the Mem.zMalloc member or anything that\n** follows.\n*/\n#define MEMCELLSIZE offsetof(Mem,zMalloc)\n\n/* One or more of the following flags are set to indicate the validOK\n** representations of the value stored in the Mem struct.\n**\n** If the MEM_Null flag is set, then the value is an SQL NULL value.\n** For a pointer type created using sqlite3_bind_pointer() or\n** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.\n**\n** If the MEM_Str flag is set then Mem.z points at a string representation.\n** Usually this is encoded in the same unicode encoding as the main\n** database (see below for exceptions). If the MEM_Term flag is also\n** set, then the string is nul terminated. The MEM_Int and MEM_Real \n** flags may coexist with the MEM_Str flag.\n*/\n#define MEM_Null      0x0001   /* Value is NULL (or a pointer) */\n#define MEM_Str       0x0002   /* Value is a string */\n#define MEM_Int       0x0004   /* Value is an integer */\n#define MEM_Real      0x0008   /* Value is a real number */\n#define MEM_Blob      0x0010   /* Value is a BLOB */\n#define MEM_AffMask   0x001f   /* Mask of affinity bits */\n#define MEM_RowSet    0x0020   /* Value is a RowSet object */\n#define MEM_Frame     0x0040   /* Value is a VdbeFrame object */\n#define MEM_Undefined 0x0080   /* Value is undefined */\n#define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */\n#define MEM_TypeMask  0xc1ff   /* Mask of type bits */\n\n\n/* Whenever Mem contains a valid string or blob representation, one of\n** the following flags must be set to determine the memory management\n** policy for Mem.z.  The MEM_Term flag tells us whether or not the\n** string is \\000 or \\u0000 terminated\n*/\n#define MEM_Term      0x0200   /* String in Mem.z is zero terminated */\n#define MEM_Dyn       0x0400   /* Need to call Mem.xDel() on Mem.z */\n#define MEM_Static    0x0800   /* Mem.z points to a static string */\n#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */\n#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */\n#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */\n#define MEM_Subtype   0x8000   /* Mem.eSubtype is valid */\n#ifdef SQLITE_OMIT_INCRBLOB\n  #undef MEM_Zero\n  #define MEM_Zero 0x0000\n#endif\n\n/* Return TRUE if Mem X contains dynamically allocated content - anything\n** that needs to be deallocated to avoid a leak.\n*/\n#define VdbeMemDynamic(X)  \\\n  (((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame))!=0)\n\n/*\n** Clear any existing type flags from a Mem and replace them with f\n*/\n#define MemSetTypeFlag(p, f) \\\n   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)\n\n/*\n** Return true if a memory cell is not marked as invalid.  This macro\n** is for use inside assert() statements only.\n*/\n#ifdef SQLITE_DEBUG\n#define memIsValid(M)  ((M)->flags & MEM_Undefined)==0\n#endif\n\n/*\n** Each auxiliary data pointer stored by a user defined function \n** implementation calling sqlite3_set_auxdata() is stored in an instance\n** of this structure. All such structures associated with a single VM\n** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed\n** when the VM is halted (if not before).\n*/\nstruct AuxData {\n  int iAuxOp;                     /* Instruction number of OP_Function opcode */\n  int iAuxArg;                    /* Index of function argument. */\n  void *pAux;                     /* Aux data pointer */\n  void (*xDeleteAux)(void*);      /* Destructor for the aux data */\n  AuxData *pNextAux;              /* Next element in list */\n};\n\n/*\n** The \"context\" argument for an installable function.  A pointer to an\n** instance of this structure is the first argument to the routines used\n** implement the SQL functions.\n**\n** There is a typedef for this structure in sqlite.h.  So all routines,\n** even the public interface to SQLite, can use a pointer to this structure.\n** But this file is the only place where the internal details of this\n** structure are known.\n**\n** This structure is defined inside of vdbeInt.h because it uses substructures\n** (Mem) which are only defined there.\n*/\nstruct sqlite3_context {\n  Mem *pOut;              /* The return value is stored here */\n  FuncDef *pFunc;         /* Pointer to function information */\n  Mem *pMem;              /* Memory cell used to store aggregate context */\n  Vdbe *pVdbe;            /* The VM that owns this context */\n  int iOp;                /* Instruction number of OP_Function */\n  int isError;            /* Error code returned by the function. */\n  u8 skipFlag;            /* Skip accumulator loading if true */\n  u8 fErrorOrAux;         /* isError!=0 or pVdbe->pAuxData modified */\n  u8 argc;                /* Number of arguments */\n  sqlite3_value *argv[1]; /* Argument set */\n};\n\n/* A bitfield type for use inside of structures.  Always follow with :N where\n** N is the number of bits.\n*/\ntypedef unsigned bft;  /* Bit Field Type */\n\ntypedef struct ScanStatus ScanStatus;\nstruct ScanStatus {\n  int addrExplain;                /* OP_Explain for loop */\n  int addrLoop;                   /* Address of \"loops\" counter */\n  int addrVisit;                  /* Address of \"rows visited\" counter */\n  int iSelectID;                  /* The \"Select-ID\" for this loop */\n  LogEst nEst;                    /* Estimated output rows per loop */\n  char *zName;                    /* Name of table or index */\n};\n\n/*\n** An instance of the virtual machine.  This structure contains the complete\n** state of the virtual machine.\n**\n** The \"sqlite3_stmt\" structure pointer that is returned by sqlite3_prepare()\n** is really a pointer to an instance of this structure.\n*/\nstruct Vdbe {\n  sqlite3 *db;            /* The database connection that owns this statement */\n  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */\n  Parse *pParse;          /* Parsing context used to create this Vdbe */\n  ynVar nVar;             /* Number of entries in aVar[] */\n  u32 magic;              /* Magic number for sanity checking */\n  int nMem;               /* Number of memory locations currently allocated */\n  int nCursor;            /* Number of slots in apCsr[] */\n  u32 cacheCtr;           /* VdbeCursor row cache generation counter */\n  int pc;                 /* The program counter */\n  int rc;                 /* Value to return */\n  int nChange;            /* Number of db changes made since last reset */\n  int iStatement;         /* Statement number (or 0 if has not opened stmt) */\n  i64 iCurrentTime;       /* Value of julianday('now') for this statement */\n  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */\n  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */\n  i64 nStmtDefImmCons;    /* Number of def. imm constraints when stmt started */\n\n  /* When allocating a new Vdbe object, all of the fields below should be\n  ** initialized to zero or NULL */\n\n  Op *aOp;                /* Space to hold the virtual machine's program */\n  Mem *aMem;              /* The memory locations */\n  Mem **apArg;            /* Arguments to currently executing user function */\n  Mem *aColName;          /* Column names to return */\n  Mem *pResultSet;        /* Pointer to an array of results */\n  char *zErrMsg;          /* Error message written here */\n  VdbeCursor **apCsr;     /* One element of this array for each open cursor */\n  Mem *aVar;              /* Values for the OP_Variable opcode. */\n  VList *pVList;          /* Name of variables */\n#ifndef SQLITE_OMIT_TRACE\n  i64 startTime;          /* Time when query started - used for profiling */\n#endif\n  int nOp;                /* Number of instructions in the program */\n#ifdef SQLITE_DEBUG\n  int rcApp;              /* errcode set by sqlite3_result_error_code() */\n#endif\n  u16 nResColumn;         /* Number of columns in one row of the result set */\n  u8 errorAction;         /* Recovery action to do in case of an error */\n  u8 minWriteFileFormat;  /* Minimum file format for writable database files */\n  u8 prepFlags;           /* SQLITE_PREPARE_* flags */\n  bft expired:1;          /* True if the VM needs to be recompiled */\n  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */\n  bft explain:2;          /* True if EXPLAIN present on SQL command */\n  bft changeCntOn:1;      /* True to update the change-counter */\n  bft runOnlyOnce:1;      /* Automatically expire on reset */\n  bft usesStmtJournal:1;  /* True if uses a statement journal */\n  bft readOnly:1;         /* True for statements that do not write */\n  bft bIsReader:1;        /* True for statements that read */\n  yDbMask btreeMask;      /* Bitmask of db->aDb[] entries referenced */\n  yDbMask lockMask;       /* Subset of btreeMask that requires a lock */\n  u32 aCounter[7];        /* Counters used by sqlite3_stmt_status() */\n  char *zSql;             /* Text of the SQL statement that generated this */\n  void *pFree;            /* Free this when deleting the vdbe */\n  VdbeFrame *pFrame;      /* Parent frame */\n  VdbeFrame *pDelFrame;   /* List of frame objects to free on VM reset */\n  int nFrame;             /* Number of frames in pFrame list */\n  u32 expmask;            /* Binding to these vars invalidates VM */\n  SubProgram *pProgram;   /* Linked list of all sub-programs used by VM */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  i64 *anExec;            /* Number of times each op has been executed */\n  int nScan;              /* Entries in aScan[] */\n  ScanStatus *aScan;      /* Scan definitions for sqlite3_stmt_scanstatus() */\n#endif\n};\n\n/*\n** The following are allowed values for Vdbe.magic\n*/\n#define VDBE_MAGIC_INIT     0x16bceaa5    /* Building a VDBE program */\n#define VDBE_MAGIC_RUN      0x2df20da3    /* VDBE is ready to execute */\n#define VDBE_MAGIC_HALT     0x319c2973    /* VDBE has completed execution */\n#define VDBE_MAGIC_RESET    0x48fa9f76    /* Reset and ready to run again */\n#define VDBE_MAGIC_DEAD     0x5606c3c8    /* The VDBE has been deallocated */\n\n/*\n** Structure used to store the context required by the \n** sqlite3_preupdate_*() API functions.\n*/\nstruct PreUpdate {\n  Vdbe *v;\n  VdbeCursor *pCsr;               /* Cursor to read old values from */\n  int op;                         /* One of SQLITE_INSERT, UPDATE, DELETE */\n  u8 *aRecord;                    /* old.* database record */\n  KeyInfo keyinfo;\n  UnpackedRecord *pUnpacked;      /* Unpacked version of aRecord[] */\n  UnpackedRecord *pNewUnpacked;   /* Unpacked version of new.* record */\n  int iNewReg;                    /* Register for new.* values */\n  i64 iKey1;                      /* First key value passed to hook */\n  i64 iKey2;                      /* Second key value passed to hook */\n  Mem *aNew;                      /* Array of new.* values */\n  Table *pTab;                    /* Schema object being upated */          \n  Index *pPk;                     /* PK index if pTab is WITHOUT ROWID */\n};\n\n/*\n** Function prototypes\n*/\nSQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);\nvoid sqliteVdbePopStack(Vdbe*,int);\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor**, int*);\nSQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE*, int, Op*);\n#endif\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);\nSQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int, u32*);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);\nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);\n\nint sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(sqlite3*,VdbeCursor*,UnpackedRecord*,int*);\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor*, i64*);\nSQLITE_PRIVATE int sqlite3VdbeExec(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeList(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe*);\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *, int);\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem*, const Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem*, Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem*, i64);\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64\n#else\nSQLITE_PRIVATE   void sqlite3VdbeMemSetDouble(Mem*, double);\n#endif\nSQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*));\nSQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int);\nSQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem*);\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemCast(Mem*,u8,u8);\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p);\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem*, FuncDef*);\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int);\nSQLITE_PRIVATE int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);\nSQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int n);\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *, int);\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame*);\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\nSQLITE_PRIVATE void sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);\n#endif\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p);\n\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);\nSQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *, int *);\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) \nSQLITE_PRIVATE   void sqlite3VdbeEnter(Vdbe*);\n#else\n# define sqlite3VdbeEnter(X)\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\nSQLITE_PRIVATE   void sqlite3VdbeLeave(Vdbe*);\n#else\n# define sqlite3VdbeLeave(X)\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);\nSQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem*);\n#endif\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);\n#else\n# define sqlite3VdbeCheckFk(p,i) 0\n#endif\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE   void sqlite3VdbePrintSql(Vdbe*);\nSQLITE_PRIVATE   void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);\n#endif\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_PRIVATE   int sqlite3VdbeMemTranslate(Mem*, u8);\nSQLITE_PRIVATE   int sqlite3VdbeMemHandleBom(Mem *pMem);\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE   int sqlite3VdbeMemExpandBlob(Mem *);\n  #define ExpandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)\n#else\n  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK\n  #define ExpandBlob(P) SQLITE_OK\n#endif\n\n#endif /* !defined(SQLITE_VDBEINT_H) */\n\n/************** End of vdbeInt.h *********************************************/\n/************** Continuing where we left off in status.c *********************/\n\n/*\n** Variables in which to record status information.\n*/\n#if SQLITE_PTRSIZE>4\ntypedef sqlite3_int64 sqlite3StatValueType;\n#else\ntypedef u32 sqlite3StatValueType;\n#endif\ntypedef struct sqlite3StatType sqlite3StatType;\nstatic SQLITE_WSD struct sqlite3StatType {\n  sqlite3StatValueType nowValue[10];  /* Current value */\n  sqlite3StatValueType mxValue[10];   /* Maximum value */\n} sqlite3Stat = { {0,}, {0,} };\n\n/*\n** Elements of sqlite3Stat[] are protected by either the memory allocator\n** mutex, or by the pcache1 mutex.  The following array determines which.\n*/\nstatic const char statMutex[] = {\n  0,  /* SQLITE_STATUS_MEMORY_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_OVERFLOW */\n  0,  /* SQLITE_STATUS_SCRATCH_USED */\n  0,  /* SQLITE_STATUS_SCRATCH_OVERFLOW */\n  0,  /* SQLITE_STATUS_MALLOC_SIZE */\n  0,  /* SQLITE_STATUS_PARSER_STACK */\n  1,  /* SQLITE_STATUS_PAGECACHE_SIZE */\n  0,  /* SQLITE_STATUS_SCRATCH_SIZE */\n  0,  /* SQLITE_STATUS_MALLOC_COUNT */\n};\n\n\n/* The \"wsdStat\" macro will resolve to the status information\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Stat\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdStatInit  sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat)\n# define wsdStat x[0]\n#else\n# define wsdStatInit\n# define wsdStat sqlite3Stat\n#endif\n\n/*\n** Return the current value of a status parameter.  The caller must\n** be holding the appropriate mutex.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  return wsdStat.nowValue[op];\n}\n\n/*\n** Add N to the value of a status record.  The caller must hold the\n** appropriate mutex.  (Locking is checked by assert()).\n**\n** The StatusUp() routine can accept positive or negative values for N.\n** The value of N is added to the current status value and the high-water\n** mark is adjusted if necessary.\n**\n** The StatusDown() routine lowers the current value by N.  The highwater\n** mark is unchanged.  N must be non-negative for StatusDown().\n*/\nSQLITE_PRIVATE void sqlite3StatusUp(int op, int N){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  wsdStat.nowValue[op] += N;\n  if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n}\nSQLITE_PRIVATE void sqlite3StatusDown(int op, int N){\n  wsdStatInit;\n  assert( N>=0 );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  wsdStat.nowValue[op] -= N;\n}\n\n/*\n** Adjust the highwater mark if necessary.\n** The caller must hold the appropriate mutex.\n*/\nSQLITE_PRIVATE void sqlite3StatusHighwater(int op, int X){\n  sqlite3StatValueType newValue;\n  wsdStatInit;\n  assert( X>=0 );\n  newValue = (sqlite3StatValueType)X;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op==SQLITE_STATUS_MALLOC_SIZE\n          || op==SQLITE_STATUS_PAGECACHE_SIZE\n          || op==SQLITE_STATUS_PARSER_STACK );\n  if( newValue>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = newValue;\n  }\n}\n\n/*\n** Query status information.\n*/\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n){\n  sqlite3_mutex *pMutex;\n  wsdStatInit;\n  if( op<0 || op>=ArraySize(wsdStat.nowValue) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();\n  sqlite3_mutex_enter(pMutex);\n  *pCurrent = wsdStat.nowValue[op];\n  *pHighwater = wsdStat.mxValue[op];\n  if( resetFlag ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n  sqlite3_mutex_leave(pMutex);\n  (void)pMutex;  /* Prevent warning when SQLITE_THREADSAFE=0 */\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){\n  sqlite3_int64 iCur = 0, iHwtr = 0;\n  int rc;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);\n  if( rc==0 ){\n    *pCurrent = (int)iCur;\n    *pHighwater = (int)iHwtr;\n  }\n  return rc;\n}\n\n/*\n** Return the number of LookasideSlot elements on the linked list\n*/\nstatic u32 countLookasideSlots(LookasideSlot *p){\n  u32 cnt = 0;\n  while( p ){\n    p = p->pNext;\n    cnt++;\n  }\n  return cnt;\n}\n\n/*\n** Count the number of slots of lookaside memory that are outstanding\n*/\nSQLITE_PRIVATE int sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){\n  u32 nInit = countLookasideSlots(db->lookaside.pInit);\n  u32 nFree = countLookasideSlots(db->lookaside.pFree);\n  if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit;\n  return db->lookaside.nSlot - (nInit+nFree);\n}\n\n/*\n** Query status information for a single database connection\n*/\nSQLITE_API int sqlite3_db_status(\n  sqlite3 *db,          /* The database connection whose status is desired */\n  int op,               /* Status verb */\n  int *pCurrent,        /* Write current value here */\n  int *pHighwater,      /* Write high-water mark here */\n  int resetFlag         /* Reset high-water mark if true */\n){\n  int rc = SQLITE_OK;   /* Return code */\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  switch( op ){\n    case SQLITE_DBSTATUS_LOOKASIDE_USED: {\n      *pCurrent = sqlite3LookasideUsed(db, pHighwater);\n      if( resetFlag ){\n        LookasideSlot *p = db->lookaside.pFree;\n        if( p ){\n          while( p->pNext ) p = p->pNext;\n          p->pNext = db->lookaside.pInit;\n          db->lookaside.pInit = db->lookaside.pFree;\n          db->lookaside.pFree = 0;\n        }\n      }\n      break;\n    }\n\n    case SQLITE_DBSTATUS_LOOKASIDE_HIT:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );\n      *pCurrent = 0;\n      *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];\n      if( resetFlag ){\n        db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;\n      }\n      break;\n    }\n\n    /* \n    ** Return an approximation for the amount of memory currently used\n    ** by all pagers associated with the given database connection.  The\n    ** highwater mark is meaningless and is returned as zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_USED_SHARED:\n    case SQLITE_DBSTATUS_CACHE_USED: {\n      int totalUsed = 0;\n      int i;\n      sqlite3BtreeEnterAll(db);\n      for(i=0; i<db->nDb; i++){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          Pager *pPager = sqlite3BtreePager(pBt);\n          int nByte = sqlite3PagerMemUsed(pPager);\n          if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){\n            nByte = nByte / sqlite3BtreeConnectionCount(pBt);\n          }\n          totalUsed += nByte;\n        }\n      }\n      sqlite3BtreeLeaveAll(db);\n      *pCurrent = totalUsed;\n      *pHighwater = 0;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store the schema for all databases (main, temp, and any ATTACHed\n    ** databases.  *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_SCHEMA_USED: {\n      int i;                      /* Used to iterate through schemas */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      sqlite3BtreeEnterAll(db);\n      db->pnBytesFreed = &nByte;\n      for(i=0; i<db->nDb; i++){\n        Schema *pSchema = db->aDb[i].pSchema;\n        if( ALWAYS(pSchema!=0) ){\n          HashElem *p;\n\n          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (\n              pSchema->tblHash.count \n            + pSchema->trigHash.count\n            + pSchema->idxHash.count\n            + pSchema->fkeyHash.count\n          );\n          nByte += sqlite3_msize(pSchema->tblHash.ht);\n          nByte += sqlite3_msize(pSchema->trigHash.ht);\n          nByte += sqlite3_msize(pSchema->idxHash.ht);\n          nByte += sqlite3_msize(pSchema->fkeyHash.ht);\n\n          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));\n          }\n          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));\n          }\n        }\n      }\n      db->pnBytesFreed = 0;\n      sqlite3BtreeLeaveAll(db);\n\n      *pHighwater = 0;\n      *pCurrent = nByte;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store all prepared statements.\n    ** *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_STMT_USED: {\n      struct Vdbe *pVdbe;         /* Used to iterate through VMs */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      db->pnBytesFreed = &nByte;\n      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){\n        sqlite3VdbeClearObject(db, pVdbe);\n        sqlite3DbFree(db, pVdbe);\n      }\n      db->pnBytesFreed = 0;\n\n      *pHighwater = 0;  /* IMP: R-64479-57858 */\n      *pCurrent = nByte;\n\n      break;\n    }\n\n    /*\n    ** Set *pCurrent to the total cache hits or misses encountered by all\n    ** pagers the database handle is connected to. *pHighwater is always set \n    ** to zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_HIT:\n    case SQLITE_DBSTATUS_CACHE_MISS:\n    case SQLITE_DBSTATUS_CACHE_WRITE:{\n      int i;\n      int nRet = 0;\n      assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );\n      assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );\n\n      for(i=0; i<db->nDb; i++){\n        if( db->aDb[i].pBt ){\n          Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);\n          sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);\n        }\n      }\n      *pHighwater = 0; /* IMP: R-42420-56072 */\n                       /* IMP: R-54100-20147 */\n                       /* IMP: R-29431-39229 */\n      *pCurrent = nRet;\n      break;\n    }\n\n    /* Set *pCurrent to non-zero if there are unresolved deferred foreign\n    ** key constraints.  Set *pCurrent to zero if all foreign key constraints\n    ** have been satisfied.  The *pHighwater is always set to zero.\n    */\n    case SQLITE_DBSTATUS_DEFERRED_FKS: {\n      *pHighwater = 0;  /* IMP: R-11967-56545 */\n      *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of status.c **********************************************/\n/************** Begin file date.c ********************************************/\n/*\n** 2003 October 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement date and time\n** functions for SQLite.  \n**\n** There is only one exported symbol in this file - the function\n** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.\n** All other code has file scope.\n**\n** SQLite processes all times and dates as julian day numbers.  The\n** dates and times are stored as the number of days since noon\n** in Greenwich on November 24, 4714 B.C. according to the Gregorian\n** calendar system. \n**\n** 1970-01-01 00:00:00 is JD 2440587.5\n** 2000-01-01 00:00:00 is JD 2451544.5\n**\n** This implementation requires years to be expressed as a 4-digit number\n** which means that only dates between 0000-01-01 and 9999-12-31 can\n** be represented, even though julian day numbers allow a much wider\n** range of dates.\n**\n** The Gregorian calendar system is used for all dates and times,\n** even those that predate the Gregorian calendar.  Historians usually\n** use the julian calendar for dates prior to 1582-10-15 and for some\n** dates afterwards, depending on locale.  Beware of this difference.\n**\n** The conversion algorithms are implemented based on descriptions\n** in the following text:\n**\n**      Jean Meeus\n**      Astronomical Algorithms, 2nd Edition, 1998\n**      ISBM 0-943396-61-1\n**      Willmann-Bell, Inc\n**      Richmond, Virginia (USA)\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n#include <time.h>\n\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So declare a substitute.  The substitute function itself is\n** defined in \"os_win.c\".\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\nstruct tm *__cdecl localtime(const time_t *);\n#endif\n\n/*\n** A structure for holding a single date and time.\n*/\ntypedef struct DateTime DateTime;\nstruct DateTime {\n  sqlite3_int64 iJD;  /* The julian day number times 86400000 */\n  int Y, M, D;        /* Year, month, and day */\n  int h, m;           /* Hour and minutes */\n  int tz;             /* Timezone offset in minutes */\n  double s;           /* Seconds */\n  char validJD;       /* True (1) if iJD is valid */\n  char rawS;          /* Raw numeric value stored in s */\n  char validYMD;      /* True (1) if Y,M,D are valid */\n  char validHMS;      /* True (1) if h,m,s are valid */\n  char validTZ;       /* True (1) if tz is valid */\n  char tzSet;         /* Timezone was set explicitly */\n  char isError;       /* An overflow has occurred */\n};\n\n\n/*\n** Convert zDate into one or more integers according to the conversion\n** specifier zFormat.\n**\n** zFormat[] contains 4 characters for each integer converted, except for\n** the last integer which is specified by three characters.  The meaning\n** of a four-character format specifiers ABCD is:\n**\n**    A:   number of digits to convert.  Always \"2\" or \"4\".\n**    B:   minimum value.  Always \"0\" or \"1\".\n**    C:   maximum value, decoded as:\n**           a:  12\n**           b:  14\n**           c:  24\n**           d:  31\n**           e:  59\n**           f:  9999\n**    D:   the separator character, or \\000 to indicate this is the\n**         last number to convert.\n**\n** Example:  To translate an ISO-8601 date YYYY-MM-DD, the format would\n** be \"40f-21a-20c\".  The \"40f-\" indicates the 4-digit year followed by \"-\".\n** The \"21a-\" indicates the 2-digit month followed by \"-\".  The \"20c\" indicates\n** the 2-digit day which is the last integer in the set.\n**\n** The function returns the number of successful conversions.\n*/\nstatic int getDigits(const char *zDate, const char *zFormat, ...){\n  /* The aMx[] array translates the 3rd character of each format\n  ** spec into a max size:    a   b   c   d   e     f */\n  static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 };\n  va_list ap;\n  int cnt = 0;\n  char nextC;\n  va_start(ap, zFormat);\n  do{\n    char N = zFormat[0] - '0';\n    char min = zFormat[1] - '0';\n    int val = 0;\n    u16 max;\n\n    assert( zFormat[2]>='a' && zFormat[2]<='f' );\n    max = aMx[zFormat[2] - 'a'];\n    nextC = zFormat[3];\n    val = 0;\n    while( N-- ){\n      if( !sqlite3Isdigit(*zDate) ){\n        goto end_getDigits;\n      }\n      val = val*10 + *zDate - '0';\n      zDate++;\n    }\n    if( val<(int)min || val>(int)max || (nextC!=0 && nextC!=*zDate) ){\n      goto end_getDigits;\n    }\n    *va_arg(ap,int*) = val;\n    zDate++;\n    cnt++;\n    zFormat += 4;\n  }while( nextC );\nend_getDigits:\n  va_end(ap);\n  return cnt;\n}\n\n/*\n** Parse a timezone extension on the end of a date-time.\n** The extension is of the form:\n**\n**        (+/-)HH:MM\n**\n** Or the \"zulu\" notation:\n**\n**        Z\n**\n** If the parse is successful, write the number of minutes\n** of change in p->tz and return 0.  If a parser error occurs,\n** return non-zero.\n**\n** A missing specifier is not considered an error.\n*/\nstatic int parseTimezone(const char *zDate, DateTime *p){\n  int sgn = 0;\n  int nHr, nMn;\n  int c;\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tz = 0;\n  c = *zDate;\n  if( c=='-' ){\n    sgn = -1;\n  }else if( c=='+' ){\n    sgn = +1;\n  }else if( c=='Z' || c=='z' ){\n    zDate++;\n    goto zulu_time;\n  }else{\n    return c!=0;\n  }\n  zDate++;\n  if( getDigits(zDate, \"20b:20e\", &nHr, &nMn)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  p->tz = sgn*(nMn + nHr*60);\nzulu_time:\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tzSet = 1;\n  return *zDate!=0;\n}\n\n/*\n** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.\n** The HH, MM, and SS must each be exactly 2 digits.  The\n** fractional seconds FFFF can be one or more digits.\n**\n** Return 1 if there is a parsing error and 0 on success.\n*/\nstatic int parseHhMmSs(const char *zDate, DateTime *p){\n  int h, m, s;\n  double ms = 0.0;\n  if( getDigits(zDate, \"20c:20e\", &h, &m)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  if( *zDate==':' ){\n    zDate++;\n    if( getDigits(zDate, \"20e\", &s)!=1 ){\n      return 1;\n    }\n    zDate += 2;\n    if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){\n      double rScale = 1.0;\n      zDate++;\n      while( sqlite3Isdigit(*zDate) ){\n        ms = ms*10.0 + *zDate - '0';\n        rScale *= 10.0;\n        zDate++;\n      }\n      ms /= rScale;\n    }\n  }else{\n    s = 0;\n  }\n  p->validJD = 0;\n  p->rawS = 0;\n  p->validHMS = 1;\n  p->h = h;\n  p->m = m;\n  p->s = s + ms;\n  if( parseTimezone(zDate, p) ) return 1;\n  p->validTZ = (p->tz!=0)?1:0;\n  return 0;\n}\n\n/*\n** Put the DateTime object into its error state.\n*/\nstatic void datetimeError(DateTime *p){\n  memset(p, 0, sizeof(*p));\n  p->isError = 1;\n}\n\n/*\n** Convert from YYYY-MM-DD HH:MM:SS to julian day.  We always assume\n** that the YYYY-MM-DD is according to the Gregorian calendar.\n**\n** Reference:  Meeus page 61\n*/\nstatic void computeJD(DateTime *p){\n  int Y, M, D, A, B, X1, X2;\n\n  if( p->validJD ) return;\n  if( p->validYMD ){\n    Y = p->Y;\n    M = p->M;\n    D = p->D;\n  }else{\n    Y = 2000;  /* If no YMD specified, assume 2000-Jan-01 */\n    M = 1;\n    D = 1;\n  }\n  if( Y<-4713 || Y>9999 || p->rawS ){\n    datetimeError(p);\n    return;\n  }\n  if( M<=2 ){\n    Y--;\n    M += 12;\n  }\n  A = Y/100;\n  B = 2 - A + (A/4);\n  X1 = 36525*(Y+4716)/100;\n  X2 = 306001*(M+1)/10000;\n  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);\n  p->validJD = 1;\n  if( p->validHMS ){\n    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);\n    if( p->validTZ ){\n      p->iJD -= p->tz*60000;\n      p->validYMD = 0;\n      p->validHMS = 0;\n      p->validTZ = 0;\n    }\n  }\n}\n\n/*\n** Parse dates of the form\n**\n**     YYYY-MM-DD HH:MM:SS.FFF\n**     YYYY-MM-DD HH:MM:SS\n**     YYYY-MM-DD HH:MM\n**     YYYY-MM-DD\n**\n** Write the result into the DateTime structure and return 0\n** on success and 1 if the input string is not a well-formed\n** date.\n*/\nstatic int parseYyyyMmDd(const char *zDate, DateTime *p){\n  int Y, M, D, neg;\n\n  if( zDate[0]=='-' ){\n    zDate++;\n    neg = 1;\n  }else{\n    neg = 0;\n  }\n  if( getDigits(zDate, \"40f-21a-21d\", &Y, &M, &D)!=3 ){\n    return 1;\n  }\n  zDate += 10;\n  while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }\n  if( parseHhMmSs(zDate, p)==0 ){\n    /* We got the time */\n  }else if( *zDate==0 ){\n    p->validHMS = 0;\n  }else{\n    return 1;\n  }\n  p->validJD = 0;\n  p->validYMD = 1;\n  p->Y = neg ? -Y : Y;\n  p->M = M;\n  p->D = D;\n  if( p->validTZ ){\n    computeJD(p);\n  }\n  return 0;\n}\n\n/*\n** Set the time to the current time reported by the VFS.\n**\n** Return the number of errors.\n*/\nstatic int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){\n  p->iJD = sqlite3StmtCurrentTime(context);\n  if( p->iJD>0 ){\n    p->validJD = 1;\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Input \"r\" is a numeric quantity which might be a julian day number,\n** or the number of seconds since 1970.  If the value if r is within\n** range of a julian day number, install it as such and set validJD.\n** If the value is a valid unix timestamp, put it in p->s and set p->rawS.\n*/\nstatic void setRawDateNumber(DateTime *p, double r){\n  p->s = r;\n  p->rawS = 1;\n  if( r>=0.0 && r<5373484.5 ){\n    p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);\n    p->validJD = 1;\n  }\n}\n\n/*\n** Attempt to parse the given string into a julian day number.  Return\n** the number of errors.\n**\n** The following are acceptable forms for the input string:\n**\n**      YYYY-MM-DD HH:MM:SS.FFF  +/-HH:MM\n**      DDDD.DD \n**      now\n**\n** In the first form, the +/-HH:MM is always optional.  The fractional\n** seconds extension (the \".FFF\") is optional.  The seconds portion\n** (\":SS.FFF\") is option.  The year and date can be omitted as long\n** as there is a time string.  The time string can be omitted as long\n** as there is a year and date.\n*/\nstatic int parseDateOrTime(\n  sqlite3_context *context, \n  const char *zDate, \n  DateTime *p\n){\n  double r;\n  if( parseYyyyMmDd(zDate,p)==0 ){\n    return 0;\n  }else if( parseHhMmSs(zDate, p)==0 ){\n    return 0;\n  }else if( sqlite3StrICmp(zDate,\"now\")==0 && sqlite3NotPureFunc(context) ){\n    return setDateTimeToCurrent(context, p);\n  }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){\n    setRawDateNumber(p, r);\n    return 0;\n  }\n  return 1;\n}\n\n/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999.\n** Multiplying this by 86400000 gives 464269060799999 as the maximum value\n** for DateTime.iJD.\n**\n** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with \n** such a large integer literal, so we have to encode it.\n*/\n#define INT_464269060799999  ((((i64)0x1a640)<<32)|0x1072fdff)\n\n/*\n** Return TRUE if the given julian day number is within range.\n**\n** The input is the JulianDay times 86400000.\n*/\nstatic int validJulianDay(sqlite3_int64 iJD){\n  return iJD>=0 && iJD<=INT_464269060799999;\n}\n\n/*\n** Compute the Year, Month, and Day from the julian day number.\n*/\nstatic void computeYMD(DateTime *p){\n  int Z, A, B, C, D, E, X1;\n  if( p->validYMD ) return;\n  if( !p->validJD ){\n    p->Y = 2000;\n    p->M = 1;\n    p->D = 1;\n  }else if( !validJulianDay(p->iJD) ){\n    datetimeError(p);\n    return;\n  }else{\n    Z = (int)((p->iJD + 43200000)/86400000);\n    A = (int)((Z - 1867216.25)/36524.25);\n    A = Z + 1 + A - (A/4);\n    B = A + 1524;\n    C = (int)((B - 122.1)/365.25);\n    D = (36525*(C&32767))/100;\n    E = (int)((B-D)/30.6001);\n    X1 = (int)(30.6001*E);\n    p->D = B - D - X1;\n    p->M = E<14 ? E-1 : E-13;\n    p->Y = p->M>2 ? C - 4716 : C - 4715;\n  }\n  p->validYMD = 1;\n}\n\n/*\n** Compute the Hour, Minute, and Seconds from the julian day number.\n*/\nstatic void computeHMS(DateTime *p){\n  int s;\n  if( p->validHMS ) return;\n  computeJD(p);\n  s = (int)((p->iJD + 43200000) % 86400000);\n  p->s = s/1000.0;\n  s = (int)p->s;\n  p->s -= s;\n  p->h = s/3600;\n  s -= p->h*3600;\n  p->m = s/60;\n  p->s += s - p->m*60;\n  p->rawS = 0;\n  p->validHMS = 1;\n}\n\n/*\n** Compute both YMD and HMS\n*/\nstatic void computeYMD_HMS(DateTime *p){\n  computeYMD(p);\n  computeHMS(p);\n}\n\n/*\n** Clear the YMD and HMS and the TZ\n*/\nstatic void clearYMD_HMS_TZ(DateTime *p){\n  p->validYMD = 0;\n  p->validHMS = 0;\n  p->validTZ = 0;\n}\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** On recent Windows platforms, the localtime_s() function is available\n** as part of the \"Secure CRT\". It is essentially equivalent to \n** localtime_r() available under most POSIX platforms, except that the \n** order of the parameters is reversed.\n**\n** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.\n**\n** If the user has not indicated to use localtime_r() or localtime_s()\n** already, check for an MSVC build environment that provides \n** localtime_s().\n*/\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \\\n    && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)\n#undef  HAVE_LOCALTIME_S\n#define HAVE_LOCALTIME_S 1\n#endif\n\n/*\n** The following routine implements the rough equivalent of localtime_r()\n** using whatever operating-system specific localtime facility that\n** is available.  This routine returns 0 on success and\n** non-zero on any kind of error.\n**\n** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this\n** routine will always fail.\n**\n** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C\n** library function localtime_r() is used to assist in the calculation of\n** local time.\n*/\nstatic int osLocaltime(time_t *t, struct tm *pTm){\n  int rc;\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S\n  struct tm *pX;\n#if SQLITE_THREADSAFE>0\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  pX = localtime(t);\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;\n#endif\n  if( pX ) *pTm = *pX;\n  sqlite3_mutex_leave(mutex);\n  rc = pX==0;\n#else\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;\n#endif\n#if HAVE_LOCALTIME_R\n  rc = localtime_r(t, pTm)==0;\n#else\n  rc = localtime_s(pTm, t);\n#endif /* HAVE_LOCALTIME_R */\n#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */\n  return rc;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** Compute the difference (in milliseconds) between localtime and UTC\n** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,\n** return this value and set *pRc to SQLITE_OK. \n**\n** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value\n** is undefined in this case.\n*/\nstatic sqlite3_int64 localtimeOffset(\n  DateTime *p,                    /* Date at which to calculate offset */\n  sqlite3_context *pCtx,          /* Write error here if one occurs */\n  int *pRc                        /* OUT: Error code. SQLITE_OK or ERROR */\n){\n  DateTime x, y;\n  time_t t;\n  struct tm sLocal;\n\n  /* Initialize the contents of sLocal to avoid a compiler warning. */\n  memset(&sLocal, 0, sizeof(sLocal));\n\n  x = *p;\n  computeYMD_HMS(&x);\n  if( x.Y<1971 || x.Y>=2038 ){\n    /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only\n    ** works for years between 1970 and 2037. For dates outside this range,\n    ** SQLite attempts to map the year into an equivalent year within this\n    ** range, do the calculation, then map the year back.\n    */\n    x.Y = 2000;\n    x.M = 1;\n    x.D = 1;\n    x.h = 0;\n    x.m = 0;\n    x.s = 0.0;\n  } else {\n    int s = (int)(x.s + 0.5);\n    x.s = s;\n  }\n  x.tz = 0;\n  x.validJD = 0;\n  computeJD(&x);\n  t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);\n  if( osLocaltime(&t, &sLocal) ){\n    sqlite3_result_error(pCtx, \"local time unavailable\", -1);\n    *pRc = SQLITE_ERROR;\n    return 0;\n  }\n  y.Y = sLocal.tm_year + 1900;\n  y.M = sLocal.tm_mon + 1;\n  y.D = sLocal.tm_mday;\n  y.h = sLocal.tm_hour;\n  y.m = sLocal.tm_min;\n  y.s = sLocal.tm_sec;\n  y.validYMD = 1;\n  y.validHMS = 1;\n  y.validJD = 0;\n  y.rawS = 0;\n  y.validTZ = 0;\n  y.isError = 0;\n  computeJD(&y);\n  *pRc = SQLITE_OK;\n  return y.iJD - x.iJD;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n/*\n** The following table defines various date transformations of the form\n**\n**            'NNN days'\n**\n** Where NNN is an arbitrary floating-point number and \"days\" can be one\n** of several units of time.\n*/\nstatic const struct {\n  u8 eType;           /* Transformation type code */\n  u8 nName;           /* Length of th name */\n  char *zName;        /* Name of the transformation */\n  double rLimit;      /* Maximum NNN value for this transform */\n  double rXform;      /* Constant used for this transform */\n} aXformType[] = {\n  { 0, 6, \"second\", 464269060800.0, 86400000.0/(24.0*60.0*60.0) },\n  { 0, 6, \"minute\", 7737817680.0,   86400000.0/(24.0*60.0)      },\n  { 0, 4, \"hour\",   128963628.0,    86400000.0/24.0             },\n  { 0, 3, \"day\",    5373485.0,      86400000.0                  },\n  { 1, 5, \"month\",  176546.0,       30.0*86400000.0             },\n  { 2, 4, \"year\",   14713.0,        365.0*86400000.0            },\n};\n\n/*\n** Process a modifier to a date-time stamp.  The modifiers are\n** as follows:\n**\n**     NNN days\n**     NNN hours\n**     NNN minutes\n**     NNN.NNNN seconds\n**     NNN months\n**     NNN years\n**     start of month\n**     start of year\n**     start of week\n**     start of day\n**     weekday N\n**     unixepoch\n**     localtime\n**     utc\n**\n** Return 0 on success and 1 if there is any kind of error. If the error\n** is in a system call (i.e. localtime()), then an error message is written\n** to context pCtx. If the error is an unrecognized modifier, no error is\n** written to pCtx.\n*/\nstatic int parseModifier(\n  sqlite3_context *pCtx,      /* Function context */\n  const char *z,              /* The text of the modifier */\n  int n,                      /* Length of zMod in bytes */\n  DateTime *p                 /* The date/time value to be modified */\n){\n  int rc = 1;\n  double r;\n  switch(sqlite3UpperToLower[(u8)z[0]] ){\n#ifndef SQLITE_OMIT_LOCALTIME\n    case 'l': {\n      /*    localtime\n      **\n      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to\n      ** show local time.\n      */\n      if( sqlite3_stricmp(z, \"localtime\")==0 && sqlite3NotPureFunc(pCtx) ){\n        computeJD(p);\n        p->iJD += localtimeOffset(p, pCtx, &rc);\n        clearYMD_HMS_TZ(p);\n      }\n      break;\n    }\n#endif\n    case 'u': {\n      /*\n      **    unixepoch\n      **\n      ** Treat the current value of p->s as the number of\n      ** seconds since 1970.  Convert to a real julian day number.\n      */\n      if( sqlite3_stricmp(z, \"unixepoch\")==0 && p->rawS ){\n        r = p->s*1000.0 + 210866760000000.0;\n        if( r>=0.0 && r<464269060800000.0 ){\n          clearYMD_HMS_TZ(p);\n          p->iJD = (sqlite3_int64)r;\n          p->validJD = 1;\n          p->rawS = 0;\n          rc = 0;\n        }\n      }\n#ifndef SQLITE_OMIT_LOCALTIME\n      else if( sqlite3_stricmp(z, \"utc\")==0 && sqlite3NotPureFunc(pCtx) ){\n        if( p->tzSet==0 ){\n          sqlite3_int64 c1;\n          computeJD(p);\n          c1 = localtimeOffset(p, pCtx, &rc);\n          if( rc==SQLITE_OK ){\n            p->iJD -= c1;\n            clearYMD_HMS_TZ(p);\n            p->iJD += c1 - localtimeOffset(p, pCtx, &rc);\n          }\n          p->tzSet = 1;\n        }else{\n          rc = SQLITE_OK;\n        }\n      }\n#endif\n      break;\n    }\n    case 'w': {\n      /*\n      **    weekday N\n      **\n      ** Move the date to the same time on the next occurrence of\n      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the\n      ** date is already on the appropriate weekday, this is a no-op.\n      */\n      if( sqlite3_strnicmp(z, \"weekday \", 8)==0\n               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)\n               && (n=(int)r)==r && n>=0 && r<7 ){\n        sqlite3_int64 Z;\n        computeYMD_HMS(p);\n        p->validTZ = 0;\n        p->validJD = 0;\n        computeJD(p);\n        Z = ((p->iJD + 129600000)/86400000) % 7;\n        if( Z>n ) Z -= 7;\n        p->iJD += (n - Z)*86400000;\n        clearYMD_HMS_TZ(p);\n        rc = 0;\n      }\n      break;\n    }\n    case 's': {\n      /*\n      **    start of TTTTT\n      **\n      ** Move the date backwards to the beginning of the current day,\n      ** or month or year.\n      */\n      if( sqlite3_strnicmp(z, \"start of \", 9)!=0 ) break;\n      if( !p->validJD && !p->validYMD && !p->validHMS ) break;\n      z += 9;\n      computeYMD(p);\n      p->validHMS = 1;\n      p->h = p->m = 0;\n      p->s = 0.0;\n      p->rawS = 0;\n      p->validTZ = 0;\n      p->validJD = 0;\n      if( sqlite3_stricmp(z,\"month\")==0 ){\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"year\")==0 ){\n        p->M = 1;\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"day\")==0 ){\n        rc = 0;\n      }\n      break;\n    }\n    case '+':\n    case '-':\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9': {\n      double rRounder;\n      int i;\n      for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){}\n      if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){\n        rc = 1;\n        break;\n      }\n      if( z[n]==':' ){\n        /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the\n        ** specified number of hours, minutes, seconds, and fractional seconds\n        ** to the time.  The \".FFF\" may be omitted.  The \":SS.FFF\" may be\n        ** omitted.\n        */\n        const char *z2 = z;\n        DateTime tx;\n        sqlite3_int64 day;\n        if( !sqlite3Isdigit(*z2) ) z2++;\n        memset(&tx, 0, sizeof(tx));\n        if( parseHhMmSs(z2, &tx) ) break;\n        computeJD(&tx);\n        tx.iJD -= 43200000;\n        day = tx.iJD/86400000;\n        tx.iJD -= day*86400000;\n        if( z[0]=='-' ) tx.iJD = -tx.iJD;\n        computeJD(p);\n        clearYMD_HMS_TZ(p);\n        p->iJD += tx.iJD;\n        rc = 0;\n        break;\n      }\n\n      /* If control reaches this point, it means the transformation is\n      ** one of the forms like \"+NNN days\".  */\n      z += n;\n      while( sqlite3Isspace(*z) ) z++;\n      n = sqlite3Strlen30(z);\n      if( n>10 || n<3 ) break;\n      if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;\n      computeJD(p);\n      rc = 1;\n      rRounder = r<0 ? -0.5 : +0.5;\n      for(i=0; i<ArraySize(aXformType); i++){\n        if( aXformType[i].nName==n\n         && sqlite3_strnicmp(aXformType[i].zName, z, n)==0\n         && r>-aXformType[i].rLimit && r<aXformType[i].rLimit\n        ){\n          switch( aXformType[i].eType ){\n            case 1: { /* Special processing to add months */\n              int x;\n              computeYMD_HMS(p);\n              p->M += (int)r;\n              x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;\n              p->Y += x;\n              p->M -= x*12;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n            case 2: { /* Special processing to add years */\n              int y = (int)r;\n              computeYMD_HMS(p);\n              p->Y += y;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n          }\n          computeJD(p);\n          p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);\n          rc = 0;\n          break;\n        }\n      }\n      clearYMD_HMS_TZ(p);\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n  return rc;\n}\n\n/*\n** Process time function arguments.  argv[0] is a date-time stamp.\n** argv[1] and following are modifiers.  Parse them all and write\n** the resulting time into the DateTime structure p.  Return 0\n** on success and 1 if there are any errors.\n**\n** If there are zero parameters (if even argv[0] is undefined)\n** then assume a default value of \"now\" for argv[0].\n*/\nstatic int isDate(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv, \n  DateTime *p\n){\n  int i, n;\n  const unsigned char *z;\n  int eType;\n  memset(p, 0, sizeof(*p));\n  if( argc==0 ){\n    return setDateTimeToCurrent(context, p);\n  }\n  if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT\n                   || eType==SQLITE_INTEGER ){\n    setRawDateNumber(p, sqlite3_value_double(argv[0]));\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( !z || parseDateOrTime(context, (char*)z, p) ){\n      return 1;\n    }\n  }\n  for(i=1; i<argc; i++){\n    z = sqlite3_value_text(argv[i]);\n    n = sqlite3_value_bytes(argv[i]);\n    if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;\n  }\n  computeJD(p);\n  if( p->isError || !validJulianDay(p->iJD) ) return 1;\n  return 0;\n}\n\n\n/*\n** The following routines implement the various date and time functions\n** of SQLite.\n*/\n\n/*\n**    julianday( TIMESTRING, MOD, MOD, ...)\n**\n** Return the julian day number of the date specified in the arguments\n*/\nstatic void juliandayFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    computeJD(&x);\n    sqlite3_result_double(context, x.iJD/86400000.0);\n  }\n}\n\n/*\n**    datetime( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD HH:MM:SS\n*/\nstatic void datetimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD_HMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d %02d:%02d:%02d\",\n                     x.Y, x.M, x.D, x.h, x.m, (int)(x.s));\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    time( TIMESTRING, MOD, MOD, ...)\n**\n** Return HH:MM:SS\n*/\nstatic void timeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeHMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%02d:%02d:%02d\", x.h, x.m, (int)x.s);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    date( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD\n*/\nstatic void dateFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d\", x.Y, x.M, x.D);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    strftime( FORMAT, TIMESTRING, MOD, MOD, ...)\n**\n** Return a string described by FORMAT.  Conversions as follows:\n**\n**   %d  day of month\n**   %f  ** fractional seconds  SS.SSS\n**   %H  hour 00-24\n**   %j  day of year 000-366\n**   %J  ** julian day number\n**   %m  month 01-12\n**   %M  minute 00-59\n**   %s  seconds since 1970-01-01\n**   %S  seconds 00-59\n**   %w  day of week 0-6  sunday==0\n**   %W  week of year 00-53\n**   %Y  year 0000-9999\n**   %%  %\n*/\nstatic void strftimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  u64 n;\n  size_t i,j;\n  char *z;\n  sqlite3 *db;\n  const char *zFmt;\n  char zBuf[100];\n  if( argc==0 ) return;\n  zFmt = (const char*)sqlite3_value_text(argv[0]);\n  if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;\n  db = sqlite3_context_db_handle(context);\n  for(i=0, n=1; zFmt[i]; i++, n++){\n    if( zFmt[i]=='%' ){\n      switch( zFmt[i+1] ){\n        case 'd':\n        case 'H':\n        case 'm':\n        case 'M':\n        case 'S':\n        case 'W':\n          n++;\n          /* fall thru */\n        case 'w':\n        case '%':\n          break;\n        case 'f':\n          n += 8;\n          break;\n        case 'j':\n          n += 3;\n          break;\n        case 'Y':\n          n += 8;\n          break;\n        case 's':\n        case 'J':\n          n += 50;\n          break;\n        default:\n          return;  /* ERROR.  return a NULL */\n      }\n      i++;\n    }\n  }\n  testcase( n==sizeof(zBuf)-1 );\n  testcase( n==sizeof(zBuf) );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] );\n  if( n<sizeof(zBuf) ){\n    z = zBuf;\n  }else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    return;\n  }else{\n    z = sqlite3DbMallocRawNN(db, (int)n);\n    if( z==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }\n  computeJD(&x);\n  computeYMD_HMS(&x);\n  for(i=j=0; zFmt[i]; i++){\n    if( zFmt[i]!='%' ){\n      z[j++] = zFmt[i];\n    }else{\n      i++;\n      switch( zFmt[i] ){\n        case 'd':  sqlite3_snprintf(3, &z[j],\"%02d\",x.D); j+=2; break;\n        case 'f': {\n          double s = x.s;\n          if( s>59.999 ) s = 59.999;\n          sqlite3_snprintf(7, &z[j],\"%06.3f\", s);\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'H':  sqlite3_snprintf(3, &z[j],\"%02d\",x.h); j+=2; break;\n        case 'W': /* Fall thru */\n        case 'j': {\n          int nDay;             /* Number of days since 1st day of year */\n          DateTime y = x;\n          y.validJD = 0;\n          y.M = 1;\n          y.D = 1;\n          computeJD(&y);\n          nDay = (int)((x.iJD-y.iJD+43200000)/86400000);\n          if( zFmt[i]=='W' ){\n            int wd;   /* 0=Monday, 1=Tuesday, ... 6=Sunday */\n            wd = (int)(((x.iJD+43200000)/86400000)%7);\n            sqlite3_snprintf(3, &z[j],\"%02d\",(nDay+7-wd)/7);\n            j += 2;\n          }else{\n            sqlite3_snprintf(4, &z[j],\"%03d\",nDay+1);\n            j += 3;\n          }\n          break;\n        }\n        case 'J': {\n          sqlite3_snprintf(20, &z[j],\"%.16g\",x.iJD/86400000.0);\n          j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'm':  sqlite3_snprintf(3, &z[j],\"%02d\",x.M); j+=2; break;\n        case 'M':  sqlite3_snprintf(3, &z[j],\"%02d\",x.m); j+=2; break;\n        case 's': {\n          sqlite3_snprintf(30,&z[j],\"%lld\",\n                           (i64)(x.iJD/1000 - 21086676*(i64)10000));\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'S':  sqlite3_snprintf(3,&z[j],\"%02d\",(int)x.s); j+=2; break;\n        case 'w': {\n          z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';\n          break;\n        }\n        case 'Y': {\n          sqlite3_snprintf(5,&z[j],\"%04d\",x.Y); j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        default:   z[j++] = '%'; break;\n      }\n    }\n  }\n  z[j] = 0;\n  sqlite3_result_text(context, z, -1,\n                      z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);\n}\n\n/*\n** current_time()\n**\n** This function returns the same value as time('now').\n*/\nstatic void ctimeFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  timeFunc(context, 0, 0);\n}\n\n/*\n** current_date()\n**\n** This function returns the same value as date('now').\n*/\nstatic void cdateFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  dateFunc(context, 0, 0);\n}\n\n/*\n** current_timestamp()\n**\n** This function returns the same value as datetime('now').\n*/\nstatic void ctimestampFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  datetimeFunc(context, 0, 0);\n}\n#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */\n\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n/*\n** If the library is compiled to omit the full-scale date and time\n** handling (to get a smaller binary), the following minimal version\n** of the functions current_time(), current_date() and current_timestamp()\n** are included instead. This is to support column declarations that\n** include \"DEFAULT CURRENT_TIME\" etc.\n**\n** This function uses the C-library functions time(), gmtime()\n** and strftime(). The format string to pass to strftime() is supplied\n** as the user-data for the function.\n*/\nstatic void currentTimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  time_t t;\n  char *zFormat = (char *)sqlite3_user_data(context);\n  sqlite3_int64 iT;\n  struct tm *pTm;\n  struct tm sNow;\n  char zBuf[20];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  iT = sqlite3StmtCurrentTime(context);\n  if( iT<=0 ) return;\n  t = iT/1000 - 10000*(sqlite3_int64)21086676;\n#if HAVE_GMTIME_R\n  pTm = gmtime_r(&t, &sNow);\n#else\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  pTm = gmtime(&t);\n  if( pTm ) memcpy(&sNow, pTm, sizeof(sNow));\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n#endif\n  if( pTm ){\n    strftime(zBuf, 20, zFormat, &sNow);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n#endif\n\n/*\n** This function registered all of the above C functions as SQL\n** functions.  This should be the only routine in this file with\n** external linkage.\n*/\nSQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){\n  static FuncDef aDateTimeFuncs[] = {\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n    PURE_DATE(julianday,        -1, 0, 0, juliandayFunc ),\n    PURE_DATE(date,             -1, 0, 0, dateFunc      ),\n    PURE_DATE(time,             -1, 0, 0, timeFunc      ),\n    PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),\n    PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),\n    DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),\n    DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),\n    DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),\n#else\n    STR_FUNCTION(current_time,      0, \"%H:%M:%S\",          0, currentTimeFunc),\n    STR_FUNCTION(current_date,      0, \"%Y-%m-%d\",          0, currentTimeFunc),\n    STR_FUNCTION(current_timestamp, 0, \"%Y-%m-%d %H:%M:%S\", 0, currentTimeFunc),\n#endif\n  };\n  sqlite3InsertBuiltinFuncs(aDateTimeFuncs, ArraySize(aDateTimeFuncs));\n}\n\n/************** End of date.c ************************************************/\n/************** Begin file os.c **********************************************/\n/*\n** 2005 November 29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains OS interface code that is common to all\n** architectures.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_io_error_hit = 0;            /* Total number of I/O Errors */\nSQLITE_API int sqlite3_io_error_hardhit = 0;        /* Number of non-benign errors */\nSQLITE_API int sqlite3_io_error_pending = 0;        /* Count down to first I/O error */\nSQLITE_API int sqlite3_io_error_persist = 0;        /* True if I/O errors persist */\nSQLITE_API int sqlite3_io_error_benign = 0;         /* True if errors are benign */\nSQLITE_API int sqlite3_diskfull_pending = 0;\nSQLITE_API int sqlite3_diskfull = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, also keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_open_file_count = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** The default SQLite sqlite3_vfs implementations do not allocate\n** memory (actually, os_unix.c allocates a small amount of memory\n** from within OsOpen()), but some third-party implementations may.\n** So we test the effects of a malloc() failing and the sqlite3OsXXX()\n** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.\n**\n** The following functions are instrumented for malloc() failure\n** testing:\n**\n**     sqlite3OsRead()\n**     sqlite3OsWrite()\n**     sqlite3OsSync()\n**     sqlite3OsFileSize()\n**     sqlite3OsLock()\n**     sqlite3OsCheckReservedLock()\n**     sqlite3OsFileControl()\n**     sqlite3OsShmMap()\n**     sqlite3OsOpen()\n**     sqlite3OsDelete()\n**     sqlite3OsAccess()\n**     sqlite3OsFullPathname()\n**\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API int sqlite3_memdebug_vfs_oom_test = 1;\n  #define DO_OS_MALLOC_TEST(x)                                       \\\n  if (sqlite3_memdebug_vfs_oom_test && (!x || !sqlite3JournalIsInMemory(x))) { \\\n    void *pTstAlloc = sqlite3Malloc(10);                             \\\n    if (!pTstAlloc) return SQLITE_IOERR_NOMEM_BKPT;                  \\\n    sqlite3_free(pTstAlloc);                                         \\\n  }\n#else\n  #define DO_OS_MALLOC_TEST(x)\n#endif\n\n/*\n** The following routines are convenience wrappers around methods\n** of the sqlite3_file object.  This is mostly just syntactic sugar. All\n** of this would be completely automatic if SQLite were coded using\n** C++ instead of plain old C.\n*/\nSQLITE_PRIVATE void sqlite3OsClose(sqlite3_file *pId){\n  if( pId->pMethods ){\n    pId->pMethods->xClose(pId);\n    pId->pMethods = 0;\n  }\n}\nSQLITE_PRIVATE int sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xRead(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xWrite(id, pBuf, amt, offset);\n}\nSQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file *id, i64 size){\n  return id->pMethods->xTruncate(id, size);\n}\nSQLITE_PRIVATE int sqlite3OsSync(sqlite3_file *id, int flags){\n  DO_OS_MALLOC_TEST(id);\n  return flags ? id->pMethods->xSync(id, flags) : SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFileSize(id, pSize);\n}\nSQLITE_PRIVATE int sqlite3OsLock(sqlite3_file *id, int lockType){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xLock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file *id, int lockType){\n  return id->pMethods->xUnlock(id, lockType);\n}\nSQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xCheckReservedLock(id, pResOut);\n}\n\n/*\n** Use sqlite3OsFileControl() when we are doing something that might fail\n** and we need to know about the failures.  Use sqlite3OsFileControlHint()\n** when simply tossing information over the wall to the VFS and we do not\n** really care if the VFS receives and understands the information since it\n** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()\n** routine has no return value since the return value would be meaningless.\n*/\nSQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){\n#ifdef SQLITE_TEST\n  if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){\n    /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite\n    ** is using a regular VFS, it is called after the corresponding\n    ** transaction has been committed. Injecting a fault at this point\n    ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM\n    ** but the transaction is committed anyway.\n    **\n    ** The core must call OsFileControl() though, not OsFileControlHint(),\n    ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably\n    ** means the commit really has failed and an error should be returned\n    ** to the user.  */\n    DO_OS_MALLOC_TEST(id);\n  }\n#endif\n  return id->pMethods->xFileControl(id, op, pArg);\n}\nSQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){\n  (void)id->pMethods->xFileControl(id, op, pArg);\n}\n\nSQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){\n  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;\n  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);\n}\nSQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){\n  return id->pMethods->xDeviceCharacteristics(id);\n}\n#ifndef SQLITE_OMIT_WAL\nSQLITE_PRIVATE int sqlite3OsShmLock(sqlite3_file *id, int offset, int n, int flags){\n  return id->pMethods->xShmLock(id, offset, n, flags);\n}\nSQLITE_PRIVATE void sqlite3OsShmBarrier(sqlite3_file *id){\n  id->pMethods->xShmBarrier(id);\n}\nSQLITE_PRIVATE int sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){\n  return id->pMethods->xShmUnmap(id, deleteFlag);\n}\nSQLITE_PRIVATE int sqlite3OsShmMap(\n  sqlite3_file *id,               /* Database file handle */\n  int iPage,\n  int pgsz,\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Pointer to mapping */\n){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);\n}\n#endif /* SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The real implementation of xFetch and xUnfetch */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFetch(id, iOff, iAmt, pp);\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return id->pMethods->xUnfetch(id, iOff, p);\n}\n#else\n/* No-op stubs to use when memory-mapped I/O is disabled */\nSQLITE_PRIVATE int sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  *pp = 0;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The next group of routines are convenience wrappers around the\n** VFS methods.\n*/\nSQLITE_PRIVATE int sqlite3OsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  sqlite3_file *pFile,\n  int flags,\n  int *pFlagsOut\n){\n  int rc;\n  DO_OS_MALLOC_TEST(0);\n  /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed\n  ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,\n  ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before\n  ** reaching the VFS. */\n  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);\n  assert( rc==SQLITE_OK || pFile->pMethods==0 );\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  DO_OS_MALLOC_TEST(0);\n  assert( dirSync==0 || dirSync==1 );\n  return pVfs->xDelete(pVfs, zPath, dirSync);\n}\nSQLITE_PRIVATE int sqlite3OsAccess(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int flags,\n  int *pResOut\n){\n  DO_OS_MALLOC_TEST(0);\n  return pVfs->xAccess(pVfs, zPath, flags, pResOut);\n}\nSQLITE_PRIVATE int sqlite3OsFullPathname(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int nPathOut,\n  char *zPathOut\n){\n  DO_OS_MALLOC_TEST(0);\n  zPathOut[0] = 0;\n  return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n}\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nSQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  pVfs->xDlError(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHdle, const char *zSym))(void){\n  return pVfs->xDlSym(pVfs, pHdle, zSym);\n}\nSQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  pVfs->xDlClose(pVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nSQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nSQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){\n  return pVfs->xSleep(pVfs, nMicro);\n}\nSQLITE_PRIVATE int sqlite3OsGetLastError(sqlite3_vfs *pVfs){\n  return pVfs->xGetLastError ? pVfs->xGetLastError(pVfs, 0, 0) : 0;\n}\nSQLITE_PRIVATE int sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  int rc;\n  /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()\n  ** method to get the current date and time if that method is available\n  ** (if iVersion is 2 or greater and the function pointer is not NULL) and\n  ** will fall back to xCurrentTime() if xCurrentTimeInt64() is\n  ** unavailable.\n  */\n  if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){\n    rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut);\n  }else{\n    double r;\n    rc = pVfs->xCurrentTime(pVfs, &r);\n    *pTimeOut = (sqlite3_int64)(r*86400000.0);\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3OsOpenMalloc(\n  sqlite3_vfs *pVfs,\n  const char *zFile,\n  sqlite3_file **ppFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  sqlite3_file *pFile;\n  pFile = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile);\n  if( pFile ){\n    rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags);\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(pFile);\n    }else{\n      *ppFile = pFile;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\nSQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *pFile){\n  assert( pFile );\n  sqlite3OsClose(pFile);\n  sqlite3_free(pFile);\n}\n\n/*\n** This function is a wrapper around the OS specific implementation of\n** sqlite3_os_init(). The purpose of the wrapper is to provide the\n** ability to simulate a malloc failure, so that the handling of an\n** error in sqlite3_os_init() by the upper layers can be tested.\n*/\nSQLITE_PRIVATE int sqlite3OsInit(void){\n  void *p = sqlite3_malloc(10);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  sqlite3_free(p);\n  return sqlite3_os_init();\n}\n\n/*\n** The list of all registered VFS implementations.\n*/\nstatic sqlite3_vfs * SQLITE_WSD vfsList = 0;\n#define vfsList GLOBAL(sqlite3_vfs *, vfsList)\n\n/*\n** Locate a VFS by name.  If no name is given, simply return the\n** first VFS on the list.\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){\n  sqlite3_vfs *pVfs = 0;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return 0;\n#endif\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){\n    if( zVfs==0 ) break;\n    if( strcmp(zVfs, pVfs->zName)==0 ) break;\n  }\n  sqlite3_mutex_leave(mutex);\n  return pVfs;\n}\n\n/*\n** Unlink a VFS from the linked list\n*/\nstatic void vfsUnlink(sqlite3_vfs *pVfs){\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) );\n  if( pVfs==0 ){\n    /* No-op */\n  }else if( vfsList==pVfs ){\n    vfsList = pVfs->pNext;\n  }else if( vfsList ){\n    sqlite3_vfs *p = vfsList;\n    while( p->pNext && p->pNext!=pVfs ){\n      p = p->pNext;\n    }\n    if( p->pNext==pVfs ){\n      p->pNext = pVfs->pNext;\n    }\n  }\n}\n\n/*\n** Register a VFS with the system.  It is harmless to register the same\n** VFS multiple times.  The new VFS becomes the default if makeDflt is\n** true.\n*/\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){\n  MUTEX_LOGIC(sqlite3_mutex *mutex;)\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pVfs==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  if( makeDflt || vfsList==0 ){\n    pVfs->pNext = vfsList;\n    vfsList = pVfs;\n  }else{\n    pVfs->pNext = vfsList->pNext;\n    vfsList->pNext = pVfs;\n  }\n  assert(vfsList);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Unregister a VFS so that it is no longer accessible.\n*/\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/************** End of os.c **************************************************/\n/************** Begin file fault.c *******************************************/\n/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to support the concept of \"benign\" \n** malloc failures (when the xMalloc() or xRealloc() method of the\n** sqlite3_mem_methods structure fails to allocate a block of memory\n** and returns 0). \n**\n** Most malloc failures are non-benign. After they occur, SQLite\n** abandons the current operation and returns an error code (usually\n** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily\n** fatal. For example, if a malloc fails while resizing a hash table, this \n** is completely recoverable simply by not carrying out the resize. The \n** hash table will continue to function normally.  So a malloc failure \n** during a hash table resize is a benign fault.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_UNTESTABLE\n\n/*\n** Global variables.\n*/\ntypedef struct BenignMallocHooks BenignMallocHooks;\nstatic SQLITE_WSD struct BenignMallocHooks {\n  void (*xBenignBegin)(void);\n  void (*xBenignEnd)(void);\n} sqlite3Hooks = { 0, 0 };\n\n/* The \"wsdHooks\" macro will resolve to the appropriate BenignMallocHooks\n** structure.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdHooks can refer directly\n** to the \"sqlite3Hooks\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdHooksInit \\\n  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)\n# define wsdHooks x[0]\n#else\n# define wsdHooksInit\n# define wsdHooks sqlite3Hooks\n#endif\n\n\n/*\n** Register hooks to call when sqlite3BeginBenignMalloc() and\n** sqlite3EndBenignMalloc() are called, respectively.\n*/\nSQLITE_PRIVATE void sqlite3BenignMallocHooks(\n  void (*xBenignBegin)(void),\n  void (*xBenignEnd)(void)\n){\n  wsdHooksInit;\n  wsdHooks.xBenignBegin = xBenignBegin;\n  wsdHooks.xBenignEnd = xBenignEnd;\n}\n\n/*\n** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that\n** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()\n** indicates that subsequent malloc failures are non-benign.\n*/\nSQLITE_PRIVATE void sqlite3BeginBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignBegin ){\n    wsdHooks.xBenignBegin();\n  }\n}\nSQLITE_PRIVATE void sqlite3EndBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignEnd ){\n    wsdHooks.xBenignEnd();\n  }\n}\n\n#endif   /* #ifndef SQLITE_UNTESTABLE */\n\n/************** End of fault.c ***********************************************/\n/************** Begin file mem0.c ********************************************/\n/*\n** 2008 October 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a no-op memory allocation drivers for use when\n** SQLITE_ZERO_MALLOC is defined.  The allocation drivers implemented\n** here always fail.  SQLite will not operate with these drivers.  These\n** are merely placeholders.  Real drivers must be substituted using\n** sqlite3_config() before SQLite will operate.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_ZERO_MALLOC\n\n/*\n** No-op versions of all memory allocation routines\n*/\nstatic void *sqlite3MemMalloc(int nByte){ return 0; }\nstatic void sqlite3MemFree(void *pPrior){ return; }\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){ return 0; }\nstatic int sqlite3MemSize(void *pPrior){ return 0; }\nstatic int sqlite3MemRoundup(int n){ return n; }\nstatic int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }\nstatic void sqlite3MemShutdown(void *NotUsed){ return; }\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_ZERO_MALLOC */\n\n/************** End of mem0.c ************************************************/\n/************** Begin file mem1.c ********************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.  The content of\n** this file is only used if SQLITE_SYSTEM_MALLOC is defined.  The\n** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the\n** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined.  The\n** default configuration is to use memory allocation routines in this\n** file.\n**\n** C-preprocessor macro summary:\n**\n**    HAVE_MALLOC_USABLE_SIZE     The configure script sets this symbol if\n**                                the malloc_usable_size() interface exists\n**                                on the target platform.  Or, this symbol\n**                                can be set manually, if desired.\n**                                If an equivalent interface exists by\n**                                a different name, using a separate -D\n**                                option to rename it.\n**\n**    SQLITE_WITHOUT_ZONEMALLOC   Some older macs lack support for the zone\n**                                memory allocator.  Set this symbol to enable\n**                                building on older macs.\n**\n**    SQLITE_WITHOUT_MSIZE        Set this symbol to disable the use of\n**                                _msize() on windows systems.  This might\n**                                be necessary when compiling for Delphi,\n**                                for example.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_SYSTEM_MALLOC\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n\n/*\n** Use the zone allocator available on apple products unless the\n** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.\n*/\n#include <sys/sysctl.h>\n#include <malloc/malloc.h>\n#ifdef SQLITE_MIGHT_BE_SINGLE_CORE\n#include <libkern/OSAtomic.h>\n#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */\nstatic malloc_zone_t* _sqliteZone_;\n#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))\n#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));\n#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))\n#define SQLITE_MALLOCSIZE(x) \\\n        (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))\n\n#else /* if not __APPLE__ */\n\n/*\n** Use standard C library malloc and free on non-Apple systems.  \n** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.\n*/\n#define SQLITE_MALLOC(x)             malloc(x)\n#define SQLITE_FREE(x)               free(x)\n#define SQLITE_REALLOC(x,y)          realloc((x),(y))\n\n/*\n** The malloc.h header file is needed for malloc_usable_size() function\n** on some systems (e.g. Linux).\n*/\n#if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE\n#  define SQLITE_USE_MALLOC_H 1\n#  define SQLITE_USE_MALLOC_USABLE_SIZE 1\n/*\n** The MSVCRT has malloc_usable_size(), but it is called _msize().  The\n** use of _msize() is automatic, but can be disabled by compiling with\n** -DSQLITE_WITHOUT_MSIZE.  Using the _msize() function also requires\n** the malloc.h header file.\n*/\n#elif defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)\n#  define SQLITE_USE_MALLOC_H\n#  define SQLITE_USE_MSIZE\n#endif\n\n/*\n** Include the malloc.h header file, if necessary.  Also set define macro\n** SQLITE_MALLOCSIZE to the appropriate function name, which is _msize()\n** for MSVC and malloc_usable_size() for most other systems (e.g. Linux).\n** The memory size function can always be overridden manually by defining\n** the macro SQLITE_MALLOCSIZE to the desired function name.\n*/\n#if defined(SQLITE_USE_MALLOC_H)\n#  include <malloc.h>\n#  if defined(SQLITE_USE_MALLOC_USABLE_SIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE(x)   malloc_usable_size(x)\n#    endif\n#  elif defined(SQLITE_USE_MSIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE      _msize\n#    endif\n#  endif\n#endif /* defined(SQLITE_USE_MALLOC_H) */\n\n#endif /* __APPLE__ or not __APPLE__ */\n\n/*\n** Like malloc(), but remember the size of the allocation\n** so that we can find it later using sqlite3MemSize().\n**\n** For this low-level routine, we are guaranteed that nByte>0 because\n** cases of nByte<=0 will be intercepted and dealt with by higher level\n** routines.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p;\n  testcase( ROUND8(nByte)==nByte );\n  p = SQLITE_MALLOC( nByte );\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p;\n  assert( nByte>0 );\n  testcase( ROUND8(nByte)!=nByte );\n  p = SQLITE_MALLOC( nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return (void *)p;\n#endif\n}\n\n/*\n** Like free() but works for allocations obtained from sqlite3MemMalloc()\n** or sqlite3MemRealloc().\n**\n** For this low-level routine, we already know that pPrior!=0 since\n** cases where pPrior==0 will have been intecepted and dealt with\n** by higher-level routines.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  SQLITE_FREE(pPrior);\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 );\n  p--;\n  SQLITE_FREE(p);\n#endif\n}\n\n/*\n** Report the allocated size of a prior return from xMalloc()\n** or xRealloc().\n*/\nstatic int sqlite3MemSize(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  assert( pPrior!=0 );\n  return (int)SQLITE_MALLOCSIZE(pPrior);\n#else\n  sqlite3_int64 *p;\n  assert( pPrior!=0 );\n  p = (sqlite3_int64*)pPrior;\n  p--;\n  return (int)p[0];\n#endif\n}\n\n/*\n** Like realloc().  Resize an allocation previously obtained from\n** sqlite3MemMalloc().\n**\n** For this low-level interface, we know that pPrior!=0.  Cases where\n** pPrior==0 while have been intercepted by higher-level routine and\n** redirected to xMalloc.  Similarly, we know that nByte>0 because\n** cases where nByte<=0 will have been intercepted by higher-level\n** routines and redirected to xFree.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p = SQLITE_REALLOC(pPrior, nByte);\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      SQLITE_MALLOCSIZE(pPrior), nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 && nByte>0 );\n  assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */\n  p--;\n  p = SQLITE_REALLOC(p, nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      sqlite3MemSize(pPrior), nByte);\n  }\n  return (void*)p;\n#endif\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Initialize this module.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n  int cpuCount;\n  size_t len;\n  if( _sqliteZone_ ){\n    return SQLITE_OK;\n  }\n  len = sizeof(cpuCount);\n  /* One usually wants to use hw.acctivecpu for MT decisions, but not here */\n  sysctlbyname(\"hw.ncpu\", &cpuCount, &len, NULL, 0);\n  if( cpuCount>1 ){\n    /* defer MT decisions to system malloc */\n    _sqliteZone_ = malloc_default_zone();\n  }else{\n    /* only 1 core, use our own zone to contention over global locks, \n    ** e.g. we have our own dedicated locks */\n    _sqliteZone_ = malloc_create_zone(4096, 0);\n    malloc_set_zone_name(_sqliteZone_, \"Sqlite_Heap\");\n  }\n#endif /*  defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */\n  UNUSED_PARAMETER(NotUsed);\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  return;\n}\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_SYSTEM_MALLOC */\n\n/************** End of mem1.c ************************************************/\n/************** Begin file mem2.c ********************************************/\n/*\n** 2007 August 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs while adding lots of additional debugging\n** information to each allocation in order to help detect and fix memory\n** leaks and memory usage errors.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is used only if the\n** SQLITE_MEMDEBUG macro is defined\n*/\n#ifdef SQLITE_MEMDEBUG\n\n/*\n** The backtrace functionality is only available with GLIBC\n*/\n#ifdef __GLIBC__\n  extern int backtrace(void**,int);\n  extern void backtrace_symbols_fd(void*const*,int,int);\n#else\n# define backtrace(A,B) 1\n# define backtrace_symbols_fd(A,B,C)\n#endif\n/* #include <stdio.h> */\n\n/*\n** Each memory allocation looks like this:\n**\n**  ------------------------------------------------------------------------\n**  | Title |  backtrace pointers |  MemBlockHdr |  allocation |  EndGuard |\n**  ------------------------------------------------------------------------\n**\n** The application code sees only a pointer to the allocation.  We have\n** to back up from the allocation pointer to find the MemBlockHdr.  The\n** MemBlockHdr tells us the size of the allocation and the number of\n** backtrace pointers.  There is also a guard word at the end of the\n** MemBlockHdr.\n*/\nstruct MemBlockHdr {\n  i64 iSize;                          /* Size of this allocation */\n  struct MemBlockHdr *pNext, *pPrev;  /* Linked list of all unfreed memory */\n  char nBacktrace;                    /* Number of backtraces on this alloc */\n  char nBacktraceSlots;               /* Available backtrace slots */\n  u8 nTitle;                          /* Bytes of title; includes '\\0' */\n  u8 eType;                           /* Allocation type code */\n  int iForeGuard;                     /* Guard word for sanity */\n};\n\n/*\n** Guard words\n*/\n#define FOREGUARD 0x80F5E153\n#define REARGUARD 0xE4676B53\n\n/*\n** Number of malloc size increments to track.\n*/\n#define NCSIZE  1000\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic struct {\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n  /*\n  ** Head and tail of a linked list of all outstanding allocations\n  */\n  struct MemBlockHdr *pFirst;\n  struct MemBlockHdr *pLast;\n  \n  /*\n  ** The number of levels of backtrace to save in new allocations.\n  */\n  int nBacktrace;\n  void (*xBacktrace)(int, int, void **);\n\n  /*\n  ** Title text to insert in front of each block\n  */\n  int nTitle;        /* Bytes of zTitle to save.  Includes '\\0' and padding */\n  char zTitle[100];  /* The title text */\n\n  /* \n  ** sqlite3MallocDisallow() increments the following counter.\n  ** sqlite3MallocAllow() decrements it.\n  */\n  int disallow; /* Do not allow memory allocation */\n\n  /*\n  ** Gather statistics on the sizes of memory allocations.\n  ** nAlloc[i] is the number of allocation attempts of i*8\n  ** bytes.  i==NCSIZE is the number of allocation attempts for\n  ** sizes more than NCSIZE*8 bytes.\n  */\n  int nAlloc[NCSIZE];      /* Total number of allocations */\n  int nCurrent[NCSIZE];    /* Current number of allocations */\n  int mxCurrent[NCSIZE];   /* Highwater mark for nCurrent */\n\n} mem;\n\n\n/*\n** Adjust memory usage statistics\n*/\nstatic void adjustStats(int iSize, int increment){\n  int i = ROUND8(iSize)/8;\n  if( i>NCSIZE-1 ){\n    i = NCSIZE - 1;\n  }\n  if( increment>0 ){\n    mem.nAlloc[i]++;\n    mem.nCurrent[i]++;\n    if( mem.nCurrent[i]>mem.mxCurrent[i] ){\n      mem.mxCurrent[i] = mem.nCurrent[i];\n    }\n  }else{\n    mem.nCurrent[i]--;\n    assert( mem.nCurrent[i]>=0 );\n  }\n}\n\n/*\n** Given an allocation, find the MemBlockHdr for that allocation.\n**\n** This routine checks the guards at either end of the allocation and\n** if they are incorrect it asserts.\n*/\nstatic struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){\n  struct MemBlockHdr *p;\n  int *pInt;\n  u8 *pU8;\n  int nReserve;\n\n  p = (struct MemBlockHdr*)pAllocation;\n  p--;\n  assert( p->iForeGuard==(int)FOREGUARD );\n  nReserve = ROUND8(p->iSize);\n  pInt = (int*)pAllocation;\n  pU8 = (u8*)pAllocation;\n  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );\n  /* This checks any of the \"extra\" bytes allocated due\n  ** to rounding up to an 8 byte boundary to ensure \n  ** they haven't been overwritten.\n  */\n  while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );\n  return p;\n}\n\n/*\n** Return the number of bytes currently allocated at address p.\n*/\nstatic int sqlite3MemSize(void *p){\n  struct MemBlockHdr *pHdr;\n  if( !p ){\n    return 0;\n  }\n  pHdr = sqlite3MemsysGetHeader(p);\n  return (int)pHdr->iSize;\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( (sizeof(struct MemBlockHdr)&7) == 0 );\n  if( !sqlite3GlobalConfig.bMemstat ){\n    /* If memory status is enabled, then the malloc.c wrapper will already\n    ** hold the STATIC_MEM mutex when the routines here are invoked. */\n    mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem.mutex = 0;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Fill a buffer with pseudo-random bytes.  This is used to preset\n** the content of a new memory allocation to unpredictable values and\n** to clear the content of a freed allocation to unpredictable values.\n*/\nstatic void randomFill(char *pBuf, int nByte){\n  unsigned int x, y, r;\n  x = SQLITE_PTR_TO_INT(pBuf);\n  y = nByte | 1;\n  while( nByte >= 4 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(int*)pBuf = r;\n    pBuf += 4;\n    nByte -= 4;\n  }\n  while( nByte-- > 0 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(pBuf++) = r & 0xff;\n  }\n}\n\n/*\n** Allocate nByte bytes of memory.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  int *pInt;\n  void *p = 0;\n  int totalSize;\n  int nReserve;\n  sqlite3_mutex_enter(mem.mutex);\n  assert( mem.disallow==0 );\n  nReserve = ROUND8(nByte);\n  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +\n               mem.nBacktrace*sizeof(void*) + mem.nTitle;\n  p = malloc(totalSize);\n  if( p ){\n    z = p;\n    pBt = (void**)&z[mem.nTitle];\n    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];\n    pHdr->pNext = 0;\n    pHdr->pPrev = mem.pLast;\n    if( mem.pLast ){\n      mem.pLast->pNext = pHdr;\n    }else{\n      mem.pFirst = pHdr;\n    }\n    mem.pLast = pHdr;\n    pHdr->iForeGuard = FOREGUARD;\n    pHdr->eType = MEMTYPE_HEAP;\n    pHdr->nBacktraceSlots = mem.nBacktrace;\n    pHdr->nTitle = mem.nTitle;\n    if( mem.nBacktrace ){\n      void *aAddr[40];\n      pHdr->nBacktrace = backtrace(aAddr, mem.nBacktrace+1)-1;\n      memcpy(pBt, &aAddr[1], pHdr->nBacktrace*sizeof(void*));\n      assert(pBt[0]);\n      if( mem.xBacktrace ){\n        mem.xBacktrace(nByte, pHdr->nBacktrace-1, &aAddr[1]);\n      }\n    }else{\n      pHdr->nBacktrace = 0;\n    }\n    if( mem.nTitle ){\n      memcpy(z, mem.zTitle, mem.nTitle);\n    }\n    pHdr->iSize = nByte;\n    adjustStats(nByte, +1);\n    pInt = (int*)&pHdr[1];\n    pInt[nReserve/sizeof(int)] = REARGUARD;\n    randomFill((char*)pInt, nByte);\n    memset(((char*)pInt)+nByte, 0x65, nReserve-nByte);\n    p = (void*)pInt;\n  }\n  sqlite3_mutex_leave(mem.mutex);\n  return p; \n}\n\n/*\n** Free memory.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0 \n       || mem.mutex!=0 );\n  pHdr = sqlite3MemsysGetHeader(pPrior);\n  pBt = (void**)pHdr;\n  pBt -= pHdr->nBacktraceSlots;\n  sqlite3_mutex_enter(mem.mutex);\n  if( pHdr->pPrev ){\n    assert( pHdr->pPrev->pNext==pHdr );\n    pHdr->pPrev->pNext = pHdr->pNext;\n  }else{\n    assert( mem.pFirst==pHdr );\n    mem.pFirst = pHdr->pNext;\n  }\n  if( pHdr->pNext ){\n    assert( pHdr->pNext->pPrev==pHdr );\n    pHdr->pNext->pPrev = pHdr->pPrev;\n  }else{\n    assert( mem.pLast==pHdr );\n    mem.pLast = pHdr->pPrev;\n  }\n  z = (char*)pBt;\n  z -= pHdr->nTitle;\n  adjustStats((int)pHdr->iSize, -1);\n  randomFill(z, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +\n                (int)pHdr->iSize + sizeof(int) + pHdr->nTitle);\n  free(z);\n  sqlite3_mutex_leave(mem.mutex);  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** For this debugging implementation, we *always* make a copy of the\n** allocation into a new place in memory.  In this way, if the \n** higher level code is using pointer to the old allocation, it is \n** much more likely to break and we are much more liking to find\n** the error.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n  struct MemBlockHdr *pOldHdr;\n  void *pNew;\n  assert( mem.disallow==0 );\n  assert( (nByte & 7)==0 );     /* EV: R-46199-30249 */\n  pOldHdr = sqlite3MemsysGetHeader(pPrior);\n  pNew = sqlite3MemMalloc(nByte);\n  if( pNew ){\n    memcpy(pNew, pPrior, (int)(nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize));\n    if( nByte>pOldHdr->iSize ){\n      randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);\n    }\n    sqlite3MemFree(pPrior);\n  }\n  return pNew;\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n/*\n** Set the \"type\" of an allocation.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );\n    pHdr->eType = eType;\n  }\n}\n\n/*\n** Return TRUE if the mask of type in eType matches the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)==0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if the mask of type in eType matches no bits of the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n*/\nSQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)!=0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Set the number of backtrace levels kept for each allocation.\n** A value of zero turns off backtracing.  The number is always rounded\n** up to a multiple of 2.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugBacktrace(int depth){\n  if( depth<0 ){ depth = 0; }\n  if( depth>20 ){ depth = 20; }\n  depth = (depth+1)&0xfe;\n  mem.nBacktrace = depth;\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(int, int, void **)){\n  mem.xBacktrace = xBacktrace;\n}\n\n/*\n** Set the title string for subsequent allocations.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugSettitle(const char *zTitle){\n  unsigned int n = sqlite3Strlen30(zTitle) + 1;\n  sqlite3_mutex_enter(mem.mutex);\n  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;\n  memcpy(mem.zTitle, zTitle, n);\n  mem.zTitle[n] = 0;\n  mem.nTitle = ROUND8(n);\n  sqlite3_mutex_leave(mem.mutex);\n}\n\nSQLITE_PRIVATE void sqlite3MemdebugSync(){\n  struct MemBlockHdr *pHdr;\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    void **pBt = (void**)pHdr;\n    pBt -= pHdr->nBacktraceSlots;\n    mem.xBacktrace((int)pHdr->iSize, pHdr->nBacktrace-1, &pBt[1]);\n  }\n}\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3MemdebugDump(const char *zFilename){\n  FILE *out;\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  int i;\n  out = fopen(zFilename, \"w\");\n  if( out==0 ){\n    fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                    zFilename);\n    return;\n  }\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    char *z = (char*)pHdr;\n    z -= pHdr->nBacktraceSlots*sizeof(void*) + pHdr->nTitle;\n    fprintf(out, \"**** %lld bytes at %p from %s ****\\n\", \n            pHdr->iSize, &pHdr[1], pHdr->nTitle ? z : \"???\");\n    if( pHdr->nBacktrace ){\n      fflush(out);\n      pBt = (void**)pHdr;\n      pBt -= pHdr->nBacktraceSlots;\n      backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out));\n      fprintf(out, \"\\n\");\n    }\n  }\n  fprintf(out, \"COUNTS:\\n\");\n  for(i=0; i<NCSIZE-1; i++){\n    if( mem.nAlloc[i] ){\n      fprintf(out, \"   %5d: %10d %10d %10d\\n\", \n            i*8, mem.nAlloc[i], mem.nCurrent[i], mem.mxCurrent[i]);\n    }\n  }\n  if( mem.nAlloc[NCSIZE-1] ){\n    fprintf(out, \"   %5d: %10d %10d %10d\\n\",\n             NCSIZE*8-8, mem.nAlloc[NCSIZE-1],\n             mem.nCurrent[NCSIZE-1], mem.mxCurrent[NCSIZE-1]);\n  }\n  fclose(out);\n}\n\n/*\n** Return the number of times sqlite3MemMalloc() has been called.\n*/\nSQLITE_PRIVATE int sqlite3MemdebugMallocCount(){\n  int i;\n  int nTotal = 0;\n  for(i=0; i<NCSIZE; i++){\n    nTotal += mem.nAlloc[i];\n  }\n  return nTotal;\n}\n\n\n#endif /* SQLITE_MEMDEBUG */\n\n/************** End of mem2.c ************************************************/\n/************** Begin file mem3.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The SQLite user supplies a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is only built into the library\n** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not\n** mean that the library will use a memory-pool by default, just that\n** it is available. The mempool allocator is activated by calling\n** sqlite3_config().\n*/\n#ifdef SQLITE_ENABLE_MEMSYS3\n\n/*\n** Maximum size (in Mem3Blocks) of a \"small\" chunk.\n*/\n#define MX_SMALL 10\n\n\n/*\n** Number of freelist hash slots\n*/\n#define N_HASH  61\n\n/*\n** A memory allocation (also called a \"chunk\") consists of two or \n** more blocks where each block is 8 bytes.  The first 8 bytes are \n** a header that is not returned to the user.\n**\n** A chunk is two or more blocks that is either checked out or\n** free.  The first block has format u.hdr.  u.hdr.size4x is 4 times the\n** size of the allocation in blocks if the allocation is free.\n** The u.hdr.size4x&1 bit is true if the chunk is checked out and\n** false if the chunk is on the freelist.  The u.hdr.size4x&2 bit\n** is true if the previous chunk is checked out and false if the\n** previous chunk is free.  The u.hdr.prevSize field is the size of\n** the previous chunk in blocks if the previous chunk is on the\n** freelist. If the previous chunk is checked out, then\n** u.hdr.prevSize can be part of the data for that chunk and should\n** not be read or written.\n**\n** We often identify a chunk by its index in mem3.aPool[].  When\n** this is done, the chunk index refers to the second block of\n** the chunk.  In this way, the first chunk has an index of 1.\n** A chunk index of 0 means \"no such chunk\" and is the equivalent\n** of a NULL pointer.\n**\n** The second block of free chunks is of the form u.list.  The\n** two fields form a double-linked list of chunks of related sizes.\n** Pointers to the head of the list are stored in mem3.aiSmall[] \n** for smaller chunks and mem3.aiHash[] for larger chunks.\n**\n** The second block of a chunk is user data if the chunk is checked \n** out.  If a chunk is checked out, the user data may extend into\n** the u.hdr.prevSize value of the following chunk.\n*/\ntypedef struct Mem3Block Mem3Block;\nstruct Mem3Block {\n  union {\n    struct {\n      u32 prevSize;   /* Size of previous chunk in Mem3Block elements */\n      u32 size4x;     /* 4x the size of current chunk in Mem3Block elements */\n    } hdr;\n    struct {\n      u32 next;       /* Index in mem3.aPool[] of next free chunk */\n      u32 prev;       /* Index in mem3.aPool[] of previous free chunk */\n    } list;\n  } u;\n};\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem3\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem3Global {\n  /*\n  ** Memory available for allocation. nPool is the size of the array\n  ** (in Mem3Blocks) pointed to by aPool less 2.\n  */\n  u32 nPool;\n  Mem3Block *aPool;\n\n  /*\n  ** True if we are evaluating an out-of-memory callback.\n  */\n  int alarmBusy;\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n  \n  /*\n  ** The minimum amount of free space that we have seen.\n  */\n  u32 mnMaster;\n\n  /*\n  ** iMaster is the index of the master chunk.  Most new allocations\n  ** occur off of this chunk.  szMaster is the size (in Mem3Blocks)\n  ** of the current master.  iMaster is 0 if there is not master chunk.\n  ** The master chunk is not in either the aiHash[] or aiSmall[].\n  */\n  u32 iMaster;\n  u32 szMaster;\n\n  /*\n  ** Array of lists of free blocks according to the block size \n  ** for smaller chunks, or a hash on the block size for larger\n  ** chunks.\n  */\n  u32 aiSmall[MX_SMALL-1];   /* For sizes 2 through MX_SMALL, inclusive */\n  u32 aiHash[N_HASH];        /* For sizes MX_SMALL+1 and larger */\n} mem3 = { 97535575 };\n\n#define mem3 GLOBAL(struct Mem3Global, mem3)\n\n/*\n** Unlink the chunk at mem3.aPool[i] from list it is currently\n** on.  *pRoot is the list that i is a member of.\n*/\nstatic void memsys3UnlinkFromList(u32 i, u32 *pRoot){\n  u32 next = mem3.aPool[i].u.list.next;\n  u32 prev = mem3.aPool[i].u.list.prev;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  if( prev==0 ){\n    *pRoot = next;\n  }else{\n    mem3.aPool[prev].u.list.next = next;\n  }\n  if( next ){\n    mem3.aPool[next].u.list.prev = prev;\n  }\n  mem3.aPool[i].u.list.next = 0;\n  mem3.aPool[i].u.list.prev = 0;\n}\n\n/*\n** Unlink the chunk at index i from \n** whatever list is currently a member of.\n*/\nstatic void memsys3Unlink(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  assert( i>=1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** Link the chunk at mem3.aPool[i] so that is on the list rooted\n** at *pRoot.\n*/\nstatic void memsys3LinkIntoList(u32 i, u32 *pRoot){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  mem3.aPool[i].u.list.next = *pRoot;\n  mem3.aPool[i].u.list.prev = 0;\n  if( *pRoot ){\n    mem3.aPool[*pRoot].u.list.prev = i;\n  }\n  *pRoot = i;\n}\n\n/*\n** Link the chunk at index i into either the appropriate\n** small chunk list, or into the large chunk hash table.\n*/\nstatic void memsys3Link(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3LinkIntoList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** If the STATIC_MEM mutex is not already held, obtain it now. The mutex\n** will already be held (obtained by code in malloc.c) if\n** sqlite3GlobalConfig.bMemStat is true.\n*/\nstatic void memsys3Enter(void){\n  if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){\n    mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  sqlite3_mutex_enter(mem3.mutex);\n}\nstatic void memsys3Leave(void){\n  sqlite3_mutex_leave(mem3.mutex);\n}\n\n/*\n** Called when we are unable to satisfy an allocation of nBytes.\n*/\nstatic void memsys3OutOfMemory(int nByte){\n  if( !mem3.alarmBusy ){\n    mem3.alarmBusy = 1;\n    assert( sqlite3_mutex_held(mem3.mutex) );\n    sqlite3_mutex_leave(mem3.mutex);\n    sqlite3_release_memory(nByte);\n    sqlite3_mutex_enter(mem3.mutex);\n    mem3.alarmBusy = 0;\n  }\n}\n\n\n/*\n** Chunk i is a free chunk that has been unlinked.  Adjust its \n** size parameters for check-out and return a pointer to the \n** user portion of the chunk.\n*/\nstatic void *memsys3Checkout(u32 i, u32 nBlock){\n  u32 x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock );\n  assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock );\n  x = mem3.aPool[i-1].u.hdr.size4x;\n  mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2);\n  mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock;\n  mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2;\n  return &mem3.aPool[i];\n}\n\n/*\n** Carve a piece off of the end of the mem3.iMaster free chunk.\n** Return a pointer to the new allocation.  Or, if the master chunk\n** is not large enough, return 0.\n*/\nstatic void *memsys3FromMaster(u32 nBlock){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( mem3.szMaster>=nBlock );\n  if( nBlock>=mem3.szMaster-1 ){\n    /* Use the entire master */\n    void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster);\n    mem3.iMaster = 0;\n    mem3.szMaster = 0;\n    mem3.mnMaster = 0;\n    return p;\n  }else{\n    /* Split the master block.  Return the tail. */\n    u32 newi, x;\n    newi = mem3.iMaster + mem3.szMaster - nBlock;\n    assert( newi > mem3.iMaster+1 );\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock;\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2;\n    mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1;\n    mem3.szMaster -= nBlock;\n    mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster;\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n    if( mem3.szMaster < mem3.mnMaster ){\n      mem3.mnMaster = mem3.szMaster;\n    }\n    return (void*)&mem3.aPool[newi];\n  }\n}\n\n/*\n** *pRoot is the head of a list of free chunks of the same size\n** or same size hash.  In other words, *pRoot is an entry in either\n** mem3.aiSmall[] or mem3.aiHash[].  \n**\n** This routine examines all entries on the given list and tries\n** to coalesce each entries with adjacent free chunks.  \n**\n** If it sees a chunk that is larger than mem3.iMaster, it replaces \n** the current mem3.iMaster with the new larger chunk.  In order for\n** this mem3.iMaster replacement to work, the master chunk must be\n** linked into the hash tables.  That is not the normal state of\n** affairs, of course.  The calling routine must link the master\n** chunk before invoking this routine, then must unlink the (possibly\n** changed) master chunk once this routine has finished.\n*/\nstatic void memsys3Merge(u32 *pRoot){\n  u32 iNext, prev, size, i, x;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  for(i=*pRoot; i>0; i=iNext){\n    iNext = mem3.aPool[i].u.list.next;\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    assert( (size&1)==0 );\n    if( (size&2)==0 ){\n      memsys3UnlinkFromList(i, pRoot);\n      assert( i > mem3.aPool[i-1].u.hdr.prevSize );\n      prev = i - mem3.aPool[i-1].u.hdr.prevSize;\n      if( prev==iNext ){\n        iNext = mem3.aPool[prev].u.list.next;\n      }\n      memsys3Unlink(prev);\n      size = i + size/4 - prev;\n      x = mem3.aPool[prev-1].u.hdr.size4x & 2;\n      mem3.aPool[prev-1].u.hdr.size4x = size*4 | x;\n      mem3.aPool[prev+size-1].u.hdr.prevSize = size;\n      memsys3Link(prev);\n      i = prev;\n    }else{\n      size /= 4;\n    }\n    if( size>mem3.szMaster ){\n      mem3.iMaster = i;\n      mem3.szMaster = size;\n    }\n  }\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void *memsys3MallocUnsafe(int nByte){\n  u32 i;\n  u32 nBlock;\n  u32 toFree;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( sizeof(Mem3Block)==8 );\n  if( nByte<=12 ){\n    nBlock = 2;\n  }else{\n    nBlock = (nByte + 11)/8;\n  }\n  assert( nBlock>=2 );\n\n  /* STEP 1:\n  ** Look for an entry of the correct size in either the small\n  ** chunk table or in the large chunk hash table.  This is\n  ** successful most of the time (about 9 times out of 10).\n  */\n  if( nBlock <= MX_SMALL ){\n    i = mem3.aiSmall[nBlock-2];\n    if( i>0 ){\n      memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);\n      return memsys3Checkout(i, nBlock);\n    }\n  }else{\n    int hash = nBlock % N_HASH;\n    for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){\n      if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){\n        memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n        return memsys3Checkout(i, nBlock);\n      }\n    }\n  }\n\n  /* STEP 2:\n  ** Try to satisfy the allocation by carving a piece off of the end\n  ** of the master chunk.  This step usually works if step 1 fails.\n  */\n  if( mem3.szMaster>=nBlock ){\n    return memsys3FromMaster(nBlock);\n  }\n\n\n  /* STEP 3:  \n  ** Loop through the entire memory pool.  Coalesce adjacent free\n  ** chunks.  Recompute the master chunk as the largest free chunk.\n  ** Then try again to satisfy the allocation by carving a piece off\n  ** of the end of the master chunk.  This step happens very\n  ** rarely (we hope!)\n  */\n  for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){\n    memsys3OutOfMemory(toFree);\n    if( mem3.iMaster ){\n      memsys3Link(mem3.iMaster);\n      mem3.iMaster = 0;\n      mem3.szMaster = 0;\n    }\n    for(i=0; i<N_HASH; i++){\n      memsys3Merge(&mem3.aiHash[i]);\n    }\n    for(i=0; i<MX_SMALL-1; i++){\n      memsys3Merge(&mem3.aiSmall[i]);\n    }\n    if( mem3.szMaster ){\n      memsys3Unlink(mem3.iMaster);\n      if( mem3.szMaster>=nBlock ){\n        return memsys3FromMaster(nBlock);\n      }\n    }\n  }\n\n  /* If none of the above worked, then we fail. */\n  return 0;\n}\n\n/*\n** Free an outstanding memory allocation.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void memsys3FreeUnsafe(void *pOld){\n  Mem3Block *p = (Mem3Block*)pOld;\n  int i;\n  u32 size, x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] );\n  i = p - mem3.aPool;\n  assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( i+size<=mem3.nPool+1 );\n  mem3.aPool[i-1].u.hdr.size4x &= ~1;\n  mem3.aPool[i+size-1].u.hdr.prevSize = size;\n  mem3.aPool[i+size-1].u.hdr.size4x &= ~2;\n  memsys3Link(i);\n\n  /* Try to expand the master using the newly freed chunk */\n  if( mem3.iMaster ){\n    while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){\n      size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize;\n      mem3.iMaster -= size;\n      mem3.szMaster += size;\n      memsys3Unlink(mem3.iMaster);\n      x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){\n      memsys3Unlink(mem3.iMaster+mem3.szMaster);\n      mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n  }\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.  The\n** size returned omits the 8-byte header overhead.  This only\n** works for chunks that are currently checked out.\n*/\nstatic int memsys3Size(void *p){\n  Mem3Block *pBlock;\n  assert( p!=0 );\n  pBlock = (Mem3Block*)p;\n  assert( (pBlock[-1].u.hdr.size4x&1)!=0 );\n  return (pBlock[-1].u.hdr.size4x&~3)*2 - 4;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int memsys3Roundup(int n){\n  if( n<=12 ){\n    return 12;\n  }else{\n    return ((n+11)&~7) - 4;\n  }\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys3Malloc(int nBytes){\n  sqlite3_int64 *p;\n  assert( nBytes>0 );          /* malloc.c filters out 0 byte requests */\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  memsys3Leave();\n  return (void*)p; \n}\n\n/*\n** Free memory.\n*/\nstatic void memsys3Free(void *pPrior){\n  assert( pPrior );\n  memsys3Enter();\n  memsys3FreeUnsafe(pPrior);\n  memsys3Leave();\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *memsys3Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  if( pPrior==0 ){\n    return sqlite3_malloc(nBytes);\n  }\n  if( nBytes<=0 ){\n    sqlite3_free(pPrior);\n    return 0;\n  }\n  nOld = memsys3Size(pPrior);\n  if( nBytes<=nOld && nBytes>=nOld-128 ){\n    return pPrior;\n  }\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  if( p ){\n    if( nOld<nBytes ){\n      memcpy(p, pPrior, nOld);\n    }else{\n      memcpy(p, pPrior, nBytes);\n    }\n    memsys3FreeUnsafe(pPrior);\n  }\n  memsys3Leave();\n  return p;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int memsys3Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  if( !sqlite3GlobalConfig.pHeap ){\n    return SQLITE_ERROR;\n  }\n\n  /* Store a pointer to the memory block in global structure mem3. */\n  assert( sizeof(Mem3Block)==8 );\n  mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap;\n  mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2;\n\n  /* Initialize the master block. */\n  mem3.szMaster = mem3.nPool;\n  mem3.mnMaster = mem3.szMaster;\n  mem3.iMaster = 1;\n  mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2;\n  mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool;\n  mem3.aPool[mem3.nPool].u.hdr.size4x = 1;\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys3Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem3.mutex = 0;\n  return;\n}\n\n\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys3Dump(const char *zFilename){\n#ifdef SQLITE_DEBUG\n  FILE *out;\n  u32 i, j;\n  u32 size;\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys3Enter();\n  fprintf(out, \"CHUNKS:\\n\");\n  for(i=1; i<=mem3.nPool; i+=size/4){\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    if( size/4<=1 ){\n      fprintf(out, \"%p size error\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){\n      fprintf(out, \"%p tail size does not match\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){\n      fprintf(out, \"%p tail checkout bit is incorrect\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( size&1 ){\n      fprintf(out, \"%p %6d bytes checked out\\n\", &mem3.aPool[i], (size/4)*8-8);\n    }else{\n      fprintf(out, \"%p %6d bytes free%s\\n\", &mem3.aPool[i], (size/4)*8-8,\n                  i==mem3.iMaster ? \" **master**\" : \"\");\n    }\n  }\n  for(i=0; i<MX_SMALL-1; i++){\n    if( mem3.aiSmall[i]==0 ) continue;\n    fprintf(out, \"small(%2d):\", i);\n    for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  for(i=0; i<N_HASH; i++){\n    if( mem3.aiHash[i]==0 ) continue;\n    fprintf(out, \"hash(%2d):\", i);\n    for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  fprintf(out, \"master=%d\\n\", mem3.iMaster);\n  fprintf(out, \"nowUsed=%d\\n\", mem3.nPool*8 - mem3.szMaster*8);\n  fprintf(out, \"mxUsed=%d\\n\", mem3.nPool*8 - mem3.mnMaster*8);\n  sqlite3_mutex_leave(mem3.mutex);\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n#else\n  UNUSED_PARAMETER(zFilename);\n#endif\n}\n\n/*\n** This routine is the only routine in this file with external \n** linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void){\n  static const sqlite3_mem_methods mempoolMethods = {\n     memsys3Malloc,\n     memsys3Free,\n     memsys3Realloc,\n     memsys3Size,\n     memsys3Roundup,\n     memsys3Init,\n     memsys3Shutdown,\n     0\n  };\n  return &mempoolMethods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS3 */\n\n/************** End of mem3.c ************************************************/\n/************** Begin file mem5.c ********************************************/\n/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The application gives SQLite a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.\n**\n** This memory allocator uses the following algorithm:\n**\n**   1.  All memory allocation sizes are rounded up to a power of 2.\n**\n**   2.  If two adjacent free blocks are the halves of a larger block,\n**       then the two blocks are coalesced into the single larger block.\n**\n**   3.  New memory is allocated from the first available free block.\n**\n** This algorithm is described in: J. M. Robson. \"Bounds for Some Functions\n** Concerning Dynamic Storage Allocation\". Journal of the Association for\n** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499.\n** \n** Let n be the size of the largest allocation divided by the minimum\n** allocation size (after rounding all sizes up to a power of 2.)  Let M\n** be the maximum amount of memory ever outstanding at one time.  Let\n** N be the total amount of memory available for allocation.  Robson\n** proved that this memory allocator will never breakdown due to \n** fragmentation as long as the following constraint holds:\n**\n**      N >=  M*(1 + log2(n)/2) - n + 1\n**\n** The sqlite3_status() logic tracks the maximum values of n and M so\n** that an application can, at any time, verify this constraint.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** This version of the memory allocator is used only when \n** SQLITE_ENABLE_MEMSYS5 is defined.\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\n\n/*\n** A minimum allocation is an instance of the following structure.\n** Larger allocations are an array of these structures where the\n** size of the array is a power of 2.\n**\n** The size of this object must be a power of two.  That fact is\n** verified in memsys5Init().\n*/\ntypedef struct Mem5Link Mem5Link;\nstruct Mem5Link {\n  int next;       /* Index of next free chunk */\n  int prev;       /* Index of previous free chunk */\n};\n\n/*\n** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since\n** mem5.szAtom is always at least 8 and 32-bit integers are used,\n** it is not actually possible to reach this limit.\n*/\n#define LOGMAX 30\n\n/*\n** Masks used for mem5.aCtrl[] elements.\n*/\n#define CTRL_LOGSIZE  0x1f    /* Log2 Size of this block */\n#define CTRL_FREE     0x20    /* True if not checked out */\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem5\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem5Global {\n  /*\n  ** Memory available for allocation\n  */\n  int szAtom;      /* Smallest possible allocation in bytes */\n  int nBlock;      /* Number of szAtom sized blocks in zPool */\n  u8 *zPool;       /* Memory available to be allocated */\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Performance statistics\n  */\n  u64 nAlloc;         /* Total number of calls to malloc */\n  u64 totalAlloc;     /* Total of all malloc calls - includes internal frag */\n  u64 totalExcess;    /* Total internal fragmentation */\n  u32 currentOut;     /* Current checkout, including internal fragmentation */\n  u32 currentCount;   /* Current number of distinct checkouts */\n  u32 maxOut;         /* Maximum instantaneous currentOut */\n  u32 maxCount;       /* Maximum instantaneous currentCount */\n  u32 maxRequest;     /* Largest allocation (exclusive of internal frag) */\n#endif\n  \n  /*\n  ** Lists of free blocks.  aiFreelist[0] is a list of free blocks of\n  ** size mem5.szAtom.  aiFreelist[1] holds blocks of size szAtom*2.\n  ** aiFreelist[2] holds free blocks of size szAtom*4.  And so forth.\n  */\n  int aiFreelist[LOGMAX+1];\n\n  /*\n  ** Space for tracking which blocks are checked out and the size\n  ** of each block.  One byte per block.\n  */\n  u8 *aCtrl;\n\n} mem5;\n\n/*\n** Access the static variable through a macro for SQLITE_OMIT_WSD.\n*/\n#define mem5 GLOBAL(struct Mem5Global, mem5)\n\n/*\n** Assuming mem5.zPool is divided up into an array of Mem5Link\n** structures, return a pointer to the idx-th such link.\n*/\n#define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))\n\n/*\n** Unlink the chunk at mem5.aPool[i] from list it is currently\n** on.  It should be found on mem5.aiFreelist[iLogsize].\n*/\nstatic void memsys5Unlink(int i, int iLogsize){\n  int next, prev;\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  next = MEM5LINK(i)->next;\n  prev = MEM5LINK(i)->prev;\n  if( prev<0 ){\n    mem5.aiFreelist[iLogsize] = next;\n  }else{\n    MEM5LINK(prev)->next = next;\n  }\n  if( next>=0 ){\n    MEM5LINK(next)->prev = prev;\n  }\n}\n\n/*\n** Link the chunk at mem5.aPool[i] so that is on the iLogsize\n** free list.\n*/\nstatic void memsys5Link(int i, int iLogsize){\n  int x;\n  assert( sqlite3_mutex_held(mem5.mutex) );\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];\n  MEM5LINK(i)->prev = -1;\n  if( x>=0 ){\n    assert( x<mem5.nBlock );\n    MEM5LINK(x)->prev = i;\n  }\n  mem5.aiFreelist[iLogsize] = i;\n}\n\n/*\n** Obtain or release the mutex needed to access global data structures.\n*/\nstatic void memsys5Enter(void){\n  sqlite3_mutex_enter(mem5.mutex);\n}\nstatic void memsys5Leave(void){\n  sqlite3_mutex_leave(mem5.mutex);\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n** This only works for chunks that are currently checked out.\n*/\nstatic int memsys5Size(void *p){\n  int iSize, i;\n  assert( p!=0 );\n  i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);\n  assert( i>=0 && i<mem5.nBlock );\n  iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));\n  return iSize;\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.  Return NULL if nBytes==0.\n**\n** The caller guarantees that nByte is positive.\n**\n** The caller has obtained a mutex prior to invoking this\n** routine so there is never any chance that two or more\n** threads can be in this routine at the same time.\n*/\nstatic void *memsys5MallocUnsafe(int nByte){\n  int i;           /* Index of a mem5.aPool[] slot */\n  int iBin;        /* Index into mem5.aiFreelist[] */\n  int iFullSz;     /* Size of allocation rounded up to power of 2 */\n  int iLogsize;    /* Log2 of iFullSz/POW2_MIN */\n\n  /* nByte must be a positive */\n  assert( nByte>0 );\n\n  /* No more than 1GiB per allocation */\n  if( nByte > 0x40000000 ) return 0;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Keep track of the maximum allocation request.  Even unfulfilled\n  ** requests are counted */\n  if( (u32)nByte>mem5.maxRequest ){\n    mem5.maxRequest = nByte;\n  }\n#endif\n\n\n  /* Round nByte up to the next valid power of two */\n  for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}\n\n  /* Make sure mem5.aiFreelist[iLogsize] contains at least one free\n  ** block.  If not, then split a block of the next larger power of\n  ** two in order to create a new free block of size iLogsize.\n  */\n  for(iBin=iLogsize; iBin<=LOGMAX && mem5.aiFreelist[iBin]<0; iBin++){}\n  if( iBin>LOGMAX ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes\", nByte);\n    return 0;\n  }\n  i = mem5.aiFreelist[iBin];\n  memsys5Unlink(i, iBin);\n  while( iBin>iLogsize ){\n    int newSize;\n\n    iBin--;\n    newSize = 1 << iBin;\n    mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;\n    memsys5Link(i+newSize, iBin);\n  }\n  mem5.aCtrl[i] = iLogsize;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Update allocator performance statistics. */\n  mem5.nAlloc++;\n  mem5.totalAlloc += iFullSz;\n  mem5.totalExcess += iFullSz - nByte;\n  mem5.currentCount++;\n  mem5.currentOut += iFullSz;\n  if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;\n  if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Make sure the allocated memory does not assume that it is set to zero\n  ** or retains a value from a previous allocation */\n  memset(&mem5.zPool[i*mem5.szAtom], 0xAA, iFullSz);\n#endif\n\n  /* Return a pointer to the allocated memory. */\n  return (void*)&mem5.zPool[i*mem5.szAtom];\n}\n\n/*\n** Free an outstanding memory allocation.\n*/\nstatic void memsys5FreeUnsafe(void *pOld){\n  u32 size, iLogsize;\n  int iBlock;\n\n  /* Set iBlock to the index of the block pointed to by pOld in \n  ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.\n  */\n  iBlock = (int)(((u8 *)pOld-mem5.zPool)/mem5.szAtom);\n\n  /* Check that the pointer pOld points to a valid, non-free block. */\n  assert( iBlock>=0 && iBlock<mem5.nBlock );\n  assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );\n  assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );\n\n  iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;\n  size = 1<<iLogsize;\n  assert( iBlock+size-1<(u32)mem5.nBlock );\n\n  mem5.aCtrl[iBlock] |= CTRL_FREE;\n  mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  assert( mem5.currentCount>0 );\n  assert( mem5.currentOut>=(size*mem5.szAtom) );\n  mem5.currentCount--;\n  mem5.currentOut -= size*mem5.szAtom;\n  assert( mem5.currentOut>0 || mem5.currentCount==0 );\n  assert( mem5.currentCount>0 || mem5.currentOut==0 );\n#endif\n\n  mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n  while( ALWAYS(iLogsize<LOGMAX) ){\n    int iBuddy;\n    if( (iBlock>>iLogsize) & 1 ){\n      iBuddy = iBlock - size;\n      assert( iBuddy>=0 );\n    }else{\n      iBuddy = iBlock + size;\n      if( iBuddy>=mem5.nBlock ) break;\n    }\n    if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;\n    memsys5Unlink(iBuddy, iLogsize);\n    iLogsize++;\n    if( iBuddy<iBlock ){\n      mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBlock] = 0;\n      iBlock = iBuddy;\n    }else{\n      mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBuddy] = 0;\n    }\n    size *= 2;\n  }\n\n#ifdef SQLITE_DEBUG\n  /* Overwrite freed memory with the 0x55 bit pattern to verify that it is\n  ** not used after being freed */\n  memset(&mem5.zPool[iBlock*mem5.szAtom], 0x55, size);\n#endif\n\n  memsys5Link(iBlock, iLogsize);\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys5Malloc(int nBytes){\n  sqlite3_int64 *p = 0;\n  if( nBytes>0 ){\n    memsys5Enter();\n    p = memsys5MallocUnsafe(nBytes);\n    memsys5Leave();\n  }\n  return (void*)p; \n}\n\n/*\n** Free memory.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.\n*/\nstatic void memsys5Free(void *pPrior){\n  assert( pPrior!=0 );\n  memsys5Enter();\n  memsys5FreeUnsafe(pPrior);\n  memsys5Leave();  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.  \n**\n** nBytes is always a value obtained from a prior call to\n** memsys5Round().  Hence nBytes is always a non-negative power\n** of two.  If nBytes==0 that means that an oversize allocation\n** (an allocation larger than 0x40000000) was requested and this\n** routine should return 0 without freeing pPrior.\n*/\nstatic void *memsys5Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  assert( pPrior!=0 );\n  assert( (nBytes&(nBytes-1))==0 );  /* EV: R-46199-30249 */\n  assert( nBytes>=0 );\n  if( nBytes==0 ){\n    return 0;\n  }\n  nOld = memsys5Size(pPrior);\n  if( nBytes<=nOld ){\n    return pPrior;\n  }\n  p = memsys5Malloc(nBytes);\n  if( p ){\n    memcpy(p, pPrior, nOld);\n    memsys5Free(pPrior);\n  }\n  return p;\n}\n\n/*\n** Round up a request size to the next valid allocation size.  If\n** the allocation is too large to be handled by this allocation system,\n** return 0.\n**\n** All allocations must be a power of two and must be expressed by a\n** 32-bit signed integer.  Hence the largest allocation is 0x40000000\n** or 1073741824 bytes.\n*/\nstatic int memsys5Roundup(int n){\n  int iFullSz;\n  if( n > 0x40000000 ) return 0;\n  for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);\n  return iFullSz;\n}\n\n/*\n** Return the ceiling of the logarithm base 2 of iValue.\n**\n** Examples:   memsys5Log(1) -> 0\n**             memsys5Log(2) -> 1\n**             memsys5Log(4) -> 2\n**             memsys5Log(5) -> 3\n**             memsys5Log(8) -> 3\n**             memsys5Log(9) -> 4\n*/\nstatic int memsys5Log(int iValue){\n  int iLog;\n  for(iLog=0; (iLog<(int)((sizeof(int)*8)-1)) && (1<<iLog)<iValue; iLog++);\n  return iLog;\n}\n\n/*\n** Initialize the memory allocator.\n**\n** This routine is not threadsafe.  The caller must be holding a mutex\n** to prevent multiple threads from entering at the same time.\n*/\nstatic int memsys5Init(void *NotUsed){\n  int ii;            /* Loop counter */\n  int nByte;         /* Number of bytes of memory available to this allocator */\n  u8 *zByte;         /* Memory usable by this allocator */\n  int nMinLog;       /* Log base 2 of minimum allocation size in bytes */\n  int iOffset;       /* An offset into mem5.aCtrl[] */\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* For the purposes of this routine, disable the mutex */\n  mem5.mutex = 0;\n\n  /* The size of a Mem5Link object must be a power of two.  Verify that\n  ** this is case.\n  */\n  assert( (sizeof(Mem5Link)&(sizeof(Mem5Link)-1))==0 );\n\n  nByte = sqlite3GlobalConfig.nHeap;\n  zByte = (u8*)sqlite3GlobalConfig.pHeap;\n  assert( zByte!=0 );  /* sqlite3_config() does not allow otherwise */\n\n  /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */\n  nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);\n  mem5.szAtom = (1<<nMinLog);\n  while( (int)sizeof(Mem5Link)>mem5.szAtom ){\n    mem5.szAtom = mem5.szAtom << 1;\n  }\n\n  mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));\n  mem5.zPool = zByte;\n  mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];\n\n  for(ii=0; ii<=LOGMAX; ii++){\n    mem5.aiFreelist[ii] = -1;\n  }\n\n  iOffset = 0;\n  for(ii=LOGMAX; ii>=0; ii--){\n    int nAlloc = (1<<ii);\n    if( (iOffset+nAlloc)<=mem5.nBlock ){\n      mem5.aCtrl[iOffset] = ii | CTRL_FREE;\n      memsys5Link(iOffset, ii);\n      iOffset += nAlloc;\n    }\n    assert((iOffset+nAlloc)>mem5.nBlock);\n  }\n\n  /* If a mutex is required for normal operation, allocate one */\n  if( sqlite3GlobalConfig.bMemstat==0 ){\n    mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys5Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem5.mutex = 0;\n  return;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nSQLITE_PRIVATE void sqlite3Memsys5Dump(const char *zFilename){\n  FILE *out;\n  int i, j, n;\n  int nMinLog;\n\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys5Enter();\n  nMinLog = memsys5Log(mem5.szAtom);\n  for(i=0; i<=LOGMAX && i+nMinLog<32; i++){\n    for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}\n    fprintf(out, \"freelist items of size %d: %d\\n\", mem5.szAtom << i, n);\n  }\n  fprintf(out, \"mem5.nAlloc       = %llu\\n\", mem5.nAlloc);\n  fprintf(out, \"mem5.totalAlloc   = %llu\\n\", mem5.totalAlloc);\n  fprintf(out, \"mem5.totalExcess  = %llu\\n\", mem5.totalExcess);\n  fprintf(out, \"mem5.currentOut   = %u\\n\", mem5.currentOut);\n  fprintf(out, \"mem5.currentCount = %u\\n\", mem5.currentCount);\n  fprintf(out, \"mem5.maxOut       = %u\\n\", mem5.maxOut);\n  fprintf(out, \"mem5.maxCount     = %u\\n\", mem5.maxCount);\n  fprintf(out, \"mem5.maxRequest   = %u\\n\", mem5.maxRequest);\n  memsys5Leave();\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n}\n#endif\n\n/*\n** This routine is the only routine in this file with external \n** linkage. It returns a pointer to a static sqlite3_mem_methods\n** struct populated with the memsys5 methods.\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void){\n  static const sqlite3_mem_methods memsys5Methods = {\n     memsys5Malloc,\n     memsys5Free,\n     memsys5Realloc,\n     memsys5Size,\n     memsys5Roundup,\n     memsys5Init,\n     memsys5Shutdown,\n     0\n  };\n  return &memsys5Methods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS5 */\n\n/************** End of mem5.c ************************************************/\n/************** Begin file mutex.c *******************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This file contains code that is common across all mutex implementations.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)\n/*\n** For debugging purposes, record when the mutex subsystem is initialized\n** and uninitialized so that we can assert() if there is an attempt to\n** allocate a mutex while the system is uninitialized.\n*/\nstatic SQLITE_WSD int mutexIsInit = 0;\n#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */\n\n\n#ifndef SQLITE_MUTEX_OMIT\n/*\n** Initialize the mutex system.\n*/\nSQLITE_PRIVATE int sqlite3MutexInit(void){ \n  int rc = SQLITE_OK;\n  if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){\n    /* If the xMutexAlloc method has not been set, then the user did not\n    ** install a mutex implementation via sqlite3_config() prior to \n    ** sqlite3_initialize() being called. This block copies pointers to\n    ** the default implementation into the sqlite3GlobalConfig structure.\n    */\n    sqlite3_mutex_methods const *pFrom;\n    sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pFrom = sqlite3DefaultMutex();\n    }else{\n      pFrom = sqlite3NoopMutex();\n    }\n    pTo->xMutexInit = pFrom->xMutexInit;\n    pTo->xMutexEnd = pFrom->xMutexEnd;\n    pTo->xMutexFree = pFrom->xMutexFree;\n    pTo->xMutexEnter = pFrom->xMutexEnter;\n    pTo->xMutexTry = pFrom->xMutexTry;\n    pTo->xMutexLeave = pFrom->xMutexLeave;\n    pTo->xMutexHeld = pFrom->xMutexHeld;\n    pTo->xMutexNotheld = pFrom->xMutexNotheld;\n    sqlite3MemoryBarrier();\n    pTo->xMutexAlloc = pFrom->xMutexAlloc;\n  }\n  assert( sqlite3GlobalConfig.mutex.xMutexInit );\n  rc = sqlite3GlobalConfig.mutex.xMutexInit();\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 1;\n#endif\n\n  return rc;\n}\n\n/*\n** Shutdown the mutex system. This call frees resources allocated by\n** sqlite3MutexInit().\n*/\nSQLITE_PRIVATE int sqlite3MutexEnd(void){\n  int rc = SQLITE_OK;\n  if( sqlite3GlobalConfig.mutex.xMutexEnd ){\n    rc = sqlite3GlobalConfig.mutex.xMutexEnd();\n  }\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 0;\n#endif\n\n  return rc;\n}\n\n/*\n** Retrieve a pointer to a static mutex or allocate a new dynamic one.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;\n  if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;\n#endif\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){\n  if( !sqlite3GlobalConfig.bCoreMutex ){\n    return 0;\n  }\n  assert( GLOBAL(int, mutexIsInit) );\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\n/*\n** Free a dynamic mutex.\n*/\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexFree );\n    sqlite3GlobalConfig.mutex.xMutexFree(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If some other thread already has the mutex, block\n** until it can be obtained.\n*/\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexEnter );\n    sqlite3GlobalConfig.mutex.xMutexEnter(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another\n** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.\n*/\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexTry );\n    return sqlite3GlobalConfig.mutex.xMutexTry(p);\n  }\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was previously\n** entered by the same thread.  The behavior is undefined if the mutex \n** is not currently entered. If a NULL pointer is passed as an argument\n** this function is a no-op.\n*/\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexLeave );\n    sqlite3GlobalConfig.mutex.xMutexLeave(p);\n  }\n}\n\n#ifndef NDEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexHeld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);\n}\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);\n}\n#endif\n\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex.c ***********************************************/\n/************** Begin file mutex_noop.c **************************************/\n/*\n** 2008 October 07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This implementation in this file does not provide any mutual\n** exclusion and is thus suitable for use only in applications\n** that use SQLite in a single thread.  The routines defined\n** here are place-holders.  Applications can substitute working\n** mutex routines at start-time using the\n**\n**     sqlite3_config(SQLITE_CONFIG_MUTEX,...)\n**\n** interface.\n**\n** If compiled with SQLITE_DEBUG, then additional logic is inserted\n** that does error checking on mutexes to make sure they are being\n** called correctly.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_MUTEX_OMIT\n\n#ifndef SQLITE_DEBUG\n/*\n** Stub routines for all mutex methods.\n**\n** This routines provide no mutual exclusion or error checking.\n*/\nstatic int noopMutexInit(void){ return SQLITE_OK; }\nstatic int noopMutexEnd(void){ return SQLITE_OK; }\nstatic sqlite3_mutex *noopMutexAlloc(int id){ \n  UNUSED_PARAMETER(id);\n  return (sqlite3_mutex*)8; \n}\nstatic void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic int noopMutexTry(sqlite3_mutex *p){\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\nstatic void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    noopMutexInit,\n    noopMutexEnd,\n    noopMutexAlloc,\n    noopMutexFree,\n    noopMutexEnter,\n    noopMutexTry,\n    noopMutexLeave,\n\n    0,\n    0,\n  };\n\n  return &sMutex;\n}\n#endif /* !SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n** In this implementation, error checking is provided for testing\n** and debugging purposes.  The mutexes still do not provide any\n** mutual exclusion.\n*/\n\n/*\n** The mutex object\n*/\ntypedef struct sqlite3_debug_mutex {\n  int id;     /* The mutex type */\n  int cnt;    /* Number of entries without a matching leave */\n} sqlite3_debug_mutex;\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nstatic int debugMutexHeld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt>0;\n}\nstatic int debugMutexNotheld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt==0;\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int debugMutexInit(void){ return SQLITE_OK; }\nstatic int debugMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated. \n*/\nstatic sqlite3_mutex *debugMutexAlloc(int id){\n  static sqlite3_debug_mutex aStatic[SQLITE_MUTEX_STATIC_VFS3 - 1];\n  sqlite3_debug_mutex *pNew = 0;\n  switch( id ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      pNew = sqlite3Malloc(sizeof(*pNew));\n      if( pNew ){\n        pNew->id = id;\n        pNew->cnt = 0;\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( id-2<0 || id-2>=ArraySize(aStatic) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      pNew = &aStatic[id-2];\n      pNew->id = id;\n      break;\n    }\n  }\n  return (sqlite3_mutex*)pNew;\n}\n\n/*\n** This routine deallocates a previously allocated mutex.\n*/\nstatic void debugMutexFree(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->cnt==0 );\n  if( p->id==SQLITE_MUTEX_RECURSIVE || p->id==SQLITE_MUTEX_FAST ){\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void debugMutexEnter(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n}\nstatic int debugMutexTry(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void debugMutexLeave(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( debugMutexHeld(pX) );\n  p->cnt--;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    debugMutexInit,\n    debugMutexEnd,\n    debugMutexAlloc,\n    debugMutexFree,\n    debugMutexEnter,\n    debugMutexTry,\n    debugMutexLeave,\n\n    debugMutexHeld,\n    debugMutexNotheld\n  };\n\n  return &sMutex;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation\n** is used regardless of the run-time threadsafety setting.\n*/\n#ifdef SQLITE_MUTEX_NOOP\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  return sqlite3NoopMutex();\n}\n#endif /* defined(SQLITE_MUTEX_NOOP) */\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n\n/************** End of mutex_noop.c ******************************************/\n/************** Begin file mutex_unix.c **************************************/\n/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for pthreads\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** The code in this file is only used if we are compiling threadsafe\n** under unix with pthreads.\n**\n** Note that this implementation requires a version of pthreads that\n** supports recursive mutexes.\n*/\n#ifdef SQLITE_MUTEX_PTHREADS\n\n#include <pthread.h>\n\n/*\n** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields\n** are necessary under two condidtions:  (1) Debug builds and (2) using\n** home-grown mutexes.  Encapsulate these conditions into a single #define.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX)\n# define SQLITE_MUTEX_NREF 1\n#else\n# define SQLITE_MUTEX_NREF 0\n#endif\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  pthread_mutex_t mutex;     /* Mutex controlling the lock */\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  int id;                    /* Mutex type */\n#endif\n#if SQLITE_MUTEX_NREF\n  volatile int nRef;         /* Number of entrances */\n  volatile pthread_t owner;  /* Thread that is within this mutex */\n  int trace;                 /* True to trace changes */\n#endif\n};\n#if SQLITE_MUTEX_NREF\n#define SQLITE3_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER,0,0,(pthread_t)0,0}\n#elif defined(SQLITE_ENABLE_API_ARMOR)\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }\n#endif\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.  On some platforms,\n** there might be race conditions that can cause these routines to\n** deliver incorrect results.  In particular, if pthread_equal() is\n** not an atomic operation, then these routines might delivery\n** incorrect results.  On most platforms, pthread_equal() is a \n** comparison of two integers and is therefore atomic.  But we are\n** told that HPUX is not such a platform.  If so, then these routines\n** will not always work correctly on HPUX.\n**\n** On those platforms where pthread_equal() is not atomic, SQLite\n** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to\n** make sure no assert() statements are evaluated and hence these\n** routines are never called.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_DEBUG)\nstatic int pthreadMutexHeld(sqlite3_mutex *p){\n  return (p->nRef!=0 && pthread_equal(p->owner, pthread_self()));\n}\nstatic int pthreadMutexNotheld(sqlite3_mutex *p){\n  return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0;\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the implementation of xShmBarrier in the VFS in cases\n** where SQLite is compiled without mutexes.\n*/\nSQLITE_PRIVATE void sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__) && GCC_VERSION>=4001000\n  __sync_synchronize();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int pthreadMutexInit(void){ return SQLITE_OK; }\nstatic int pthreadMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static \n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *pthreadMutexAlloc(int iType){\n  static sqlite3_mutex staticMutexes[] = {\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER\n  };\n  sqlite3_mutex *p;\n  switch( iType ){\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n        /* If recursive mutexes are not available, we will have to\n        ** build our own.  See below. */\n        pthread_mutex_init(&p->mutex, 0);\n#else\n        /* Use a recursive mutex if it is available */\n        pthread_mutexattr_t recursiveAttr;\n        pthread_mutexattr_init(&recursiveAttr);\n        pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);\n        pthread_mutex_init(&p->mutex, &recursiveAttr);\n        pthread_mutexattr_destroy(&recursiveAttr);\n#endif\n      }\n      break;\n    }\n    case SQLITE_MUTEX_FAST: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        pthread_mutex_init(&p->mutex, 0);\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &staticMutexes[iType-2];\n      break;\n    }\n  }\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  if( p ) p->id = iType;\n#endif\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void pthreadMutexFree(sqlite3_mutex *p){\n  assert( p->nRef==0 );\n#if SQLITE_ENABLE_API_ARMOR\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE )\n#endif\n  {\n    pthread_mutex_destroy(&p->mutex);\n    sqlite3_free(p);\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  else{\n    (void)SQLITE_MISUSE_BKPT;\n  }\n#endif\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void pthreadMutexEnter(sqlite3_mutex *p){\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n    }else{\n      pthread_mutex_lock(&p->mutex);\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  pthread_mutex_lock(&p->mutex);\n#if SQLITE_MUTEX_NREF\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = pthread_self();\n  p->nRef++;\n#endif\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\nstatic int pthreadMutexTry(sqlite3_mutex *p){\n  int rc;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n      rc = SQLITE_OK;\n    }else if( pthread_mutex_trylock(&p->mutex)==0 ){\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_BUSY;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  if( pthread_mutex_trylock(&p->mutex)==0 ){\n#if SQLITE_MUTEX_NREF\n    p->owner = pthread_self();\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }else{\n    rc = SQLITE_BUSY;\n  }\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( rc==SQLITE_OK && p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void pthreadMutexLeave(sqlite3_mutex *p){\n  assert( pthreadMutexHeld(p) );\n#if SQLITE_MUTEX_NREF\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n#endif\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  if( p->nRef==0 ){\n    pthread_mutex_unlock(&p->mutex);\n  }\n#else\n  pthread_mutex_unlock(&p->mutex);\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"leave mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    pthreadMutexInit,\n    pthreadMutexEnd,\n    pthreadMutexAlloc,\n    pthreadMutexFree,\n    pthreadMutexEnter,\n    pthreadMutexTry,\n    pthreadMutexLeave,\n#ifdef SQLITE_DEBUG\n    pthreadMutexHeld,\n    pthreadMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_PTHREADS */\n\n/************** End of mutex_unix.c ******************************************/\n/************** Begin file mutex_w32.c ***************************************/\n/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for Win32.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if SQLITE_OS_WIN\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of mutex_w32.c *************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in mutex_w32.c ******************/\n\n/*\n** Include the header file for the Windows VFS.\n*/\n/************** Include os_win.h in the middle of mutex_w32.c ****************/\n/************** Begin file os_win.h ******************************************/\n/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n#ifndef SQLITE_OS_WIN_H\n#define SQLITE_OS_WIN_H\n\n/*\n** Include the primary Windows SDK header file.\n*/\n#include \"windows.h\"\n\n#ifdef __CYGWIN__\n# include <sys/cygwin.h>\n# include <errno.h> /* amalgamator: dontcache */\n#endif\n\n/*\n** Determine if we are dealing with Windows NT.\n**\n** We ought to be able to determine if we are compiling for Windows 9x or\n** Windows NT using the _WIN32_WINNT macro as follows:\n**\n** #if defined(_WIN32_WINNT)\n** # define SQLITE_OS_WINNT 1\n** #else\n** # define SQLITE_OS_WINNT 0\n** #endif\n**\n** However, Visual Studio 2005 does not set _WIN32_WINNT by default, as\n** it ought to, so the above test does not work.  We'll just assume that\n** everything is Windows NT unless the programmer explicitly says otherwise\n** by setting SQLITE_OS_WINNT to 0.\n*/\n#if SQLITE_OS_WIN && !defined(SQLITE_OS_WINNT)\n# define SQLITE_OS_WINNT 1\n#endif\n\n/*\n** Determine if we are dealing with Windows CE - which has a much reduced\n** API.\n*/\n#if defined(_WIN32_WCE)\n# define SQLITE_OS_WINCE 1\n#else\n# define SQLITE_OS_WINCE 0\n#endif\n\n/*\n** Determine if we are dealing with WinRT, which provides only a subset of\n** the full Win32 API.\n*/\n#if !defined(SQLITE_OS_WINRT)\n# define SQLITE_OS_WINRT 0\n#endif\n\n/*\n** For WinCE, some API function parameters do not appear to be declared as\n** volatile.\n*/\n#if SQLITE_OS_WINCE\n# define SQLITE_WIN32_VOLATILE\n#else\n# define SQLITE_WIN32_VOLATILE volatile\n#endif\n\n/*\n** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()\n** functions are not available (e.g. those not using MSVC, Cygwin, etc).\n*/\n#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n    SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)\n# define SQLITE_OS_WIN_THREADS 1\n#else\n# define SQLITE_OS_WIN_THREADS 0\n#endif\n\n#endif /* SQLITE_OS_WIN_H */\n\n/************** End of os_win.h **********************************************/\n/************** Continuing where we left off in mutex_w32.c ******************/\n#endif\n\n/*\n** The code in this file is only used if we are compiling multithreaded\n** on a Win32 system.\n*/\n#ifdef SQLITE_MUTEX_W32\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  CRITICAL_SECTION mutex;    /* Mutex controlling the lock */\n  int id;                    /* Mutex type */\n#ifdef SQLITE_DEBUG\n  volatile int nRef;         /* Number of enterances */\n  volatile DWORD owner;      /* Thread holding this mutex */\n  volatile int trace;        /* True to trace changes */\n#endif\n};\n\n/*\n** These are the initializer values used when declaring a \"static\" mutex\n** on Win32.  It should be noted that all mutexes require initialization\n** on the Win32 platform.\n*/\n#define SQLITE_W32_MUTEX_INITIALIZER { 0 }\n\n#ifdef SQLITE_DEBUG\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, \\\n                                    0L, (DWORD)0, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 }\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.\n*/\nstatic int winMutexHeld(sqlite3_mutex *p){\n  return p->nRef!=0 && p->owner==GetCurrentThreadId();\n}\n\nstatic int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){\n  return p->nRef==0 || p->owner!=tid;\n}\n\nstatic int winMutexNotheld(sqlite3_mutex *p){\n  DWORD tid = GetCurrentThreadId();\n  return winMutexNotheld2(p, tid);\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the xShmBarrier method of the VFS in cases when SQLite is\n** compiled without mutexes (SQLITE_THREADSAFE=0).\n*/\nSQLITE_PRIVATE void sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__)\n  __sync_synchronize();\n#elif MSVC_VERSION>=1300\n  _ReadWriteBarrier();\n#elif defined(MemoryBarrier)\n  MemoryBarrier();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic sqlite3_mutex winMutex_staticMutexes[] = {\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER\n};\n\nstatic int winMutex_isInit = 0;\nstatic int winMutex_isNt = -1; /* <0 means \"need to query\" */\n\n/* As the winMutexInit() and winMutexEnd() functions are called as part\n** of the sqlite3_initialize() and sqlite3_shutdown() processing, the\n** \"interlocked\" magic used here is probably not strictly necessary.\n*/\nstatic LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;\n\nSQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */\n\nstatic int winMutexInit(void){\n  /* The first to increment to 1 does actual initialization */\n  if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){\n    int i;\n    for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n#if SQLITE_OS_WINRT\n      InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);\n#else\n      InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);\n#endif\n    }\n    winMutex_isInit = 1;\n  }else{\n    /* Another thread is (in the process of) initializing the static\n    ** mutexes */\n    while( !winMutex_isInit ){\n      sqlite3_win32_sleep(1);\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int winMutexEnd(void){\n  /* The first to decrement to 0 does actual shutdown\n  ** (which should be the last to shutdown.) */\n  if( InterlockedCompareExchange(&winMutex_lock, 0, 1)==1 ){\n    if( winMutex_isInit==1 ){\n      int i;\n      for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n        DeleteCriticalSection(&winMutex_staticMutexes[i].mutex);\n      }\n      winMutex_isInit = 0;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *winMutexAlloc(int iType){\n  sqlite3_mutex *p;\n\n  switch( iType ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        p->id = iType;\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC\n        p->trace = 1;\n#endif\n#endif\n#if SQLITE_OS_WINRT\n        InitializeCriticalSectionEx(&p->mutex, 0, 0);\n#else\n        InitializeCriticalSection(&p->mutex);\n#endif\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &winMutex_staticMutexes[iType-2];\n      p->id = iType;\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_STATIC\n      p->trace = 1;\n#endif\n#endif\n      break;\n    }\n  }\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void winMutexFree(sqlite3_mutex *p){\n  assert( p );\n  assert( p->nRef==0 && p->owner==0 );\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ){\n    DeleteCriticalSection(&p->mutex);\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void winMutexEnter(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n#ifdef SQLITE_DEBUG\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n#else\n  assert( p );\n#endif\n  assert( winMutex_isInit==1 );\n  EnterCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = tid;\n  p->nRef++;\n  if( p->trace ){\n    OSTRACE((\"ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nstatic int winMutexTry(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  int rc = SQLITE_BUSY;\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n  /*\n  ** The sqlite3_mutex_try() routine is very rarely used, and when it\n  ** is used it is merely an optimization.  So it is OK for it to always\n  ** fail.\n  **\n  ** The TryEnterCriticalSection() interface is only available on WinNT.\n  ** And some windows compilers complain if you try to use it without\n  ** first doing some #defines that prevent SQLite from building on Win98.\n  ** For that reason, we will omit this optimization for now.  See\n  ** ticket #2685.\n  */\n#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400\n  assert( winMutex_isInit==1 );\n  assert( winMutex_isNt>=-1 && winMutex_isNt<=1 );\n  if( winMutex_isNt<0 ){\n    winMutex_isNt = sqlite3_win32_is_nt();\n  }\n  assert( winMutex_isNt==0 || winMutex_isNt==1 );\n  if( winMutex_isNt && TryEnterCriticalSection(&p->mutex) ){\n#ifdef SQLITE_DEBUG\n    p->owner = tid;\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\\n\",\n             tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void winMutexLeave(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  assert( p );\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 );\n  assert( p->owner==tid );\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n#endif\n  assert( winMutex_isInit==1 );\n  LeaveCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nSQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    winMutexInit,\n    winMutexEnd,\n    winMutexAlloc,\n    winMutexFree,\n    winMutexEnter,\n    winMutexTry,\n    winMutexLeave,\n#ifdef SQLITE_DEBUG\n    winMutexHeld,\n    winMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_W32 */\n\n/************** End of mutex_w32.c *******************************************/\n/************** Begin file malloc.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Memory allocation functions used throughout sqlite.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdarg.h> */\n\n/*\n** Attempt to release up to n bytes of non-essential memory currently\n** held by SQLite. An example of non-essential memory is memory used to\n** cache database pages that are not currently in use.\n*/\nSQLITE_API int sqlite3_release_memory(int n){\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  return sqlite3PcacheReleaseMemory(n);\n#else\n  /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine\n  ** is a no-op returning zero if SQLite is not compiled with\n  ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */\n  UNUSED_PARAMETER(n);\n  return 0;\n#endif\n}\n\n/*\n** State information local to the memory allocation subsystem.\n*/\nstatic SQLITE_WSD struct Mem0Global {\n  sqlite3_mutex *mutex;         /* Mutex to serialize access */\n  sqlite3_int64 alarmThreshold; /* The soft heap limit */\n\n  /*\n  ** True if heap is nearly \"full\" where \"full\" is defined by the\n  ** sqlite3_soft_heap_limit() setting.\n  */\n  int nearlyFull;\n} mem0 = { 0, 0, 0 };\n\n#define mem0 GLOBAL(struct Mem0Global, mem0)\n\n/*\n** Return the memory allocator mutex. sqlite3_status() needs it.\n*/\nSQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){\n  return mem0.mutex;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  It used to set an alarm callback\n** that was invoked when memory usage grew too large.  Now it is a\n** no-op.\n*/\nSQLITE_API int sqlite3_memory_alarm(\n  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),\n  void *pArg,\n  sqlite3_int64 iThreshold\n){\n  (void)xCallback;\n  (void)pArg;\n  (void)iThreshold;\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Set the soft heap-size limit for the library. Passing a zero or \n** negative value indicates no limit.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){\n  sqlite3_int64 priorLimit;\n  sqlite3_int64 excess;\n  sqlite3_int64 nUsed;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return -1;\n#endif\n  sqlite3_mutex_enter(mem0.mutex);\n  priorLimit = mem0.alarmThreshold;\n  if( n<0 ){\n    sqlite3_mutex_leave(mem0.mutex);\n    return priorLimit;\n  }\n  mem0.alarmThreshold = n;\n  nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n  mem0.nearlyFull = (n>0 && n<=nUsed);\n  sqlite3_mutex_leave(mem0.mutex);\n  excess = sqlite3_memory_used() - n;\n  if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));\n  return priorLimit;\n}\nSQLITE_API void sqlite3_soft_heap_limit(int n){\n  if( n<0 ) n = 0;\n  sqlite3_soft_heap_limit64(n);\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE int sqlite3MallocInit(void){\n  int rc;\n  if( sqlite3GlobalConfig.m.xMalloc==0 ){\n    sqlite3MemSetDefault();\n  }\n  memset(&mem0, 0, sizeof(mem0));\n  mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512\n      || sqlite3GlobalConfig.nPage<=0 ){\n    sqlite3GlobalConfig.pPage = 0;\n    sqlite3GlobalConfig.szPage = 0;\n  }\n  rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);\n  if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));\n  return rc;\n}\n\n/*\n** Return true if the heap is currently under memory pressure - in other\n** words if the amount of heap used is close to the limit set by\n** sqlite3_soft_heap_limit().\n*/\nSQLITE_PRIVATE int sqlite3HeapNearlyFull(void){\n  return mem0.nearlyFull;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nSQLITE_PRIVATE void sqlite3MallocEnd(void){\n  if( sqlite3GlobalConfig.m.xShutdown ){\n    sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);\n  }\n  memset(&mem0, 0, sizeof(mem0));\n}\n\n/*\n** Return the amount of memory currently checked out.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, 0);\n  return res;\n}\n\n/*\n** Return the maximum amount of memory that has ever been\n** checked out since either the beginning of this process\n** or since the most recent reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag);\n  return mx;\n}\n\n/*\n** Trigger the alarm \n*/\nstatic void sqlite3MallocAlarm(int nByte){\n  if( mem0.alarmThreshold<=0 ) return;\n  sqlite3_mutex_leave(mem0.mutex);\n  sqlite3_release_memory(nByte);\n  sqlite3_mutex_enter(mem0.mutex);\n}\n\n/*\n** Do a memory allocation with statistics and alarms.  Assume the\n** lock is already held.\n*/\nstatic void mallocWithAlarm(int n, void **pp){\n  void *p;\n  int nFull;\n  assert( sqlite3_mutex_held(mem0.mutex) );\n  assert( n>0 );\n\n  /* In Firefox (circa 2017-02-08), xRoundup() is remapped to an internal\n  ** implementation of malloc_good_size(), which must be called in debug\n  ** mode and specifically when the DMD \"Dark Matter Detector\" is enabled\n  ** or else a crash results.  Hence, do not attempt to optimize out the\n  ** following xRoundup() call. */\n  nFull = sqlite3GlobalConfig.m.xRoundup(n);\n\n#ifdef SQLITE_MAX_MEMORY\n  if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){\n    *pp = 0;\n    return;\n  }\n#endif\n\n  sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);\n  if( mem0.alarmThreshold>0 ){\n    sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n    if( nUsed >= mem0.alarmThreshold - nFull ){\n      mem0.nearlyFull = 1;\n      sqlite3MallocAlarm(nFull);\n    }else{\n      mem0.nearlyFull = 0;\n    }\n  }\n  p = sqlite3GlobalConfig.m.xMalloc(nFull);\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  if( p==0 && mem0.alarmThreshold>0 ){\n    sqlite3MallocAlarm(nFull);\n    p = sqlite3GlobalConfig.m.xMalloc(nFull);\n  }\n#endif\n  if( p ){\n    nFull = sqlite3MallocSize(p);\n    sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);\n    sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);\n  }\n  *pp = p;\n}\n\n/*\n** Allocate memory.  This routine is like sqlite3_malloc() except that it\n** assumes the memory subsystem has already been initialized.\n*/\nSQLITE_PRIVATE void *sqlite3Malloc(u64 n){\n  void *p;\n  if( n==0 || n>=0x7fffff00 ){\n    /* A memory allocation of a number of bytes which is near the maximum\n    ** signed integer value might cause an integer overflow inside of the\n    ** xMalloc().  Hence we limit the maximum size to 0x7fffff00, giving\n    ** 255 bytes of overhead.  SQLite itself will never use anything near\n    ** this amount.  The only way to reach the limit is with sqlite3_malloc() */\n    p = 0;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    mallocWithAlarm((int)n, &p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    p = sqlite3GlobalConfig.m.xMalloc((int)n);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-11148-40995 */\n  return p;\n}\n\n/*\n** This version of the memory allocation is for use by the application.\n** First make sure the memory subsystem is initialized, then do the\n** allocation.\n*/\nSQLITE_API void *sqlite3_malloc(int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return n<=0 ? 0 : sqlite3Malloc(n);\n}\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Malloc(n);\n}\n\n/*\n** TRUE if p is a lookaside memory allocation from db\n*/\n#ifndef SQLITE_OMIT_LOOKASIDE\nstatic int isLookaside(sqlite3 *db, void *p){\n  return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd);\n}\n#else\n#define isLookaside(A,B) 0\n#endif\n\n/*\n** Return the size of a memory allocation previously obtained from\n** sqlite3Malloc() or sqlite3_malloc().\n*/\nSQLITE_PRIVATE int sqlite3MallocSize(void *p){\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return sqlite3GlobalConfig.m.xSize(p);\n}\nSQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){\n  assert( p!=0 );\n  if( db==0 || !isLookaside(db,p) ){\n#ifdef SQLITE_DEBUG\n    if( db==0 ){\n      assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n    }\n#endif\n    return sqlite3GlobalConfig.m.xSize(p);\n  }else{\n    assert( sqlite3_mutex_held(db->mutex) );\n    return db->lookaside.sz;\n  }\n}\nSQLITE_API sqlite3_uint64 sqlite3_msize(void *p){\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return p ? sqlite3GlobalConfig.m.xSize(p) : 0;\n}\n\n/*\n** Free memory previously obtained from sqlite3Malloc().\n*/\nSQLITE_API void sqlite3_free(void *p){\n  if( p==0 ) return;  /* IMP: R-49053-54554 */\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));\n    sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);\n    sqlite3GlobalConfig.m.xFree(p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    sqlite3GlobalConfig.m.xFree(p);\n  }\n}\n\n/*\n** Add the size of memory allocation \"p\" to the count in\n** *db->pnBytesFreed.\n*/\nstatic SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){\n  *db->pnBytesFreed += sqlite3DbMallocSize(db,p);\n}\n\n/*\n** Free memory that might be associated with a particular database\n** connection.  Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op.\n** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL.\n*/\nSQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  assert( p!=0 );\n  if( db ){\n    if( db->pnBytesFreed ){\n      measureAllocationSize(db, p);\n      return;\n    }\n    if( isLookaside(db, p) ){\n      LookasideSlot *pBuf = (LookasideSlot*)p;\n#ifdef SQLITE_DEBUG\n      /* Trash all content in the buffer being freed */\n      memset(p, 0xaa, db->lookaside.sz);\n#endif\n      pBuf->pNext = db->lookaside.pFree;\n      db->lookaside.pFree = pBuf;\n      return;\n    }\n  }\n  assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  sqlite3_free(p);\n}\nSQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  if( p ) sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nSQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){\n  int nOld, nNew, nDiff;\n  void *pNew;\n  assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );\n  if( pOld==0 ){\n    return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */\n  }\n  if( nBytes==0 ){\n    sqlite3_free(pOld); /* IMP: R-26507-47431 */\n    return 0;\n  }\n  if( nBytes>=0x7fffff00 ){\n    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */\n    return 0;\n  }\n  nOld = sqlite3MallocSize(pOld);\n  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second\n  ** argument to xRealloc is always a value returned by a prior call to\n  ** xRoundup. */\n  nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);\n  if( nOld==nNew ){\n    pNew = pOld;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);\n    nDiff = nNew - nOld;\n    if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= \n          mem0.alarmThreshold-nDiff ){\n      sqlite3MallocAlarm(nDiff);\n    }\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    if( pNew==0 && mem0.alarmThreshold>0 ){\n      sqlite3MallocAlarm((int)nBytes);\n      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    }\n    if( pNew ){\n      nNew = sqlite3MallocSize(pNew);\n      sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);\n    }\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-11148-40995 */\n  return pNew;\n}\n\n/*\n** The public interface to sqlite3Realloc.  Make sure that the memory\n** subsystem is initialized prior to invoking sqliteRealloc.\n*/\nSQLITE_API void *sqlite3_realloc(void *pOld, int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  if( n<0 ) n = 0;  /* IMP: R-26507-47431 */\n  return sqlite3Realloc(pOld, n);\n}\nSQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Realloc(pOld, n);\n}\n\n\n/*\n** Allocate and zero memory.\n*/ \nSQLITE_PRIVATE void *sqlite3MallocZero(u64 n){\n  void *p = sqlite3Malloc(n);\n  if( p ){\n    memset(p, 0, (size_t)n);\n  }\n  return p;\n}\n\n/*\n** Allocate and zero memory.  If the allocation fails, make\n** the mallocFailed flag in the connection pointer.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocZero(sqlite3 *db, u64 n){\n  void *p;\n  testcase( db==0 );\n  p = sqlite3DbMallocRaw(db, n);\n  if( p ) memset(p, 0, (size_t)n);\n  return p;\n}\n\n\n/* Finish the work of sqlite3DbMallocRawNN for the unusual and\n** slower case when the allocation cannot be fulfilled using lookaside.\n*/\nstatic SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){\n  void *p;\n  assert( db!=0 );\n  p = sqlite3Malloc(n);\n  if( !p ) sqlite3OomFault(db);\n  sqlite3MemdebugSetType(p, \n         (db->lookaside.bDisable==0) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP);\n  return p;\n}\n\n/*\n** Allocate memory, either lookaside (if possible) or heap.  \n** If the allocation fails, set the mallocFailed flag in\n** the connection pointer.\n**\n** If db!=0 and db->mallocFailed is true (indicating a prior malloc\n** failure on the same database connection) then always return 0.\n** Hence for a particular database connection, once malloc starts\n** failing, it fails consistently until mallocFailed is reset.\n** This is an important assumption.  There are many places in the\n** code that do things like this:\n**\n**         int *a = (int*)sqlite3DbMallocRaw(db, 100);\n**         int *b = (int*)sqlite3DbMallocRaw(db, 200);\n**         if( b ) a[10] = 9;\n**\n** In other words, if a subsequent malloc (ex: \"b\") worked, it is assumed\n** that all prior mallocs (ex: \"a\") worked too.\n**\n** The sqlite3MallocRawNN() variant guarantees that the \"db\" parameter is\n** not a NULL pointer.\n*/\nSQLITE_PRIVATE void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){\n  void *p;\n  if( db ) return sqlite3DbMallocRawNN(db, n);\n  p = sqlite3Malloc(n);\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  return p;\n}\nSQLITE_PRIVATE void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  LookasideSlot *pBuf;\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->lookaside.bDisable==0 ){\n    assert( db->mallocFailed==0 );\n    if( n>db->lookaside.sz ){\n      db->lookaside.anStat[1]++;\n    }else if( (pBuf = db->lookaside.pFree)!=0 ){\n      db->lookaside.pFree = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else if( (pBuf = db->lookaside.pInit)!=0 ){\n      db->lookaside.pInit = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else{\n      db->lookaside.anStat[2]++;\n    }\n  }else if( db->mallocFailed ){\n    return 0;\n  }\n#else\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->mallocFailed ){\n    return 0;\n  }\n#endif\n  return dbMallocRawFinish(db, n);\n}\n\n/* Forward declaration */\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n);\n\n/*\n** Resize the block of memory pointed to by p to n bytes. If the\n** resize fails, set the mallocFailed flag in the connection object.\n*/\nSQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){\n  assert( db!=0 );\n  if( p==0 ) return sqlite3DbMallocRawNN(db, n);\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( isLookaside(db,p) && n<=db->lookaside.sz ) return p;\n  return dbReallocFinish(db, p, n);\n}\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){\n  void *pNew = 0;\n  assert( db!=0 );\n  assert( p!=0 );\n  if( db->mallocFailed==0 ){\n    if( isLookaside(db, p) ){\n      pNew = sqlite3DbMallocRawNN(db, n);\n      if( pNew ){\n        memcpy(pNew, p, db->lookaside.sz);\n        sqlite3DbFree(db, p);\n      }\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n      pNew = sqlite3_realloc64(p, n);\n      if( !pNew ){\n        sqlite3OomFault(db);\n      }\n      sqlite3MemdebugSetType(pNew,\n            (db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));\n    }\n  }\n  return pNew;\n}\n\n/*\n** Attempt to reallocate p.  If the reallocation fails, then free p\n** and set the mallocFailed flag in the database connection.\n*/\nSQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *db, void *p, u64 n){\n  void *pNew;\n  pNew = sqlite3DbRealloc(db, p, n);\n  if( !pNew ){\n    sqlite3DbFree(db, p);\n  }\n  return pNew;\n}\n\n/*\n** Make a copy of a string in memory obtained from sqliteMalloc(). These \n** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This\n** is because when memory debugging is turned on, these two functions are \n** called via macros that record the current file and line number in the\n** ThreadData structure.\n*/\nSQLITE_PRIVATE char *sqlite3DbStrDup(sqlite3 *db, const char *z){\n  char *zNew;\n  size_t n;\n  if( z==0 ){\n    return 0;\n  }\n  n = strlen(z) + 1;\n  zNew = sqlite3DbMallocRaw(db, n);\n  if( zNew ){\n    memcpy(zNew, z, n);\n  }\n  return zNew;\n}\nSQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){\n  char *zNew;\n  assert( db!=0 );\n  if( z==0 ){\n    return 0;\n  }\n  assert( (n&0x7fffffff)==n );\n  zNew = sqlite3DbMallocRawNN(db, n+1);\n  if( zNew ){\n    memcpy(zNew, z, (size_t)n);\n    zNew[n] = 0;\n  }\n  return zNew;\n}\n\n/*\n** Free any prior content in *pz and replace it with a copy of zNew.\n*/\nSQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){\n  sqlite3DbFree(db, *pz);\n  *pz = sqlite3DbStrDup(db, zNew);\n}\n\n/*\n** Call this routine to record the fact that an OOM (out-of-memory) error\n** has happened.  This routine will set db->mallocFailed, and also\n** temporarily disable the lookaside memory allocator and interrupt\n** any running VDBEs.\n*/\nSQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){\n  if( db->mallocFailed==0 && db->bBenignMalloc==0 ){\n    db->mallocFailed = 1;\n    if( db->nVdbeExec>0 ){\n      db->u1.isInterrupted = 1;\n    }\n    db->lookaside.bDisable++;\n  }\n}\n\n/*\n** This routine reactivates the memory allocator and clears the\n** db->mallocFailed flag as necessary.\n**\n** The memory allocator is not restarted if there are running\n** VDBEs.\n*/\nSQLITE_PRIVATE void sqlite3OomClear(sqlite3 *db){\n  if( db->mallocFailed && db->nVdbeExec==0 ){\n    db->mallocFailed = 0;\n    db->u1.isInterrupted = 0;\n    assert( db->lookaside.bDisable>0 );\n    db->lookaside.bDisable--;\n  }\n}\n\n/*\n** Take actions at the end of an API call to indicate an OOM error\n*/\nstatic SQLITE_NOINLINE int apiOomError(sqlite3 *db){\n  sqlite3OomClear(db);\n  sqlite3Error(db, SQLITE_NOMEM);\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** This function must be called before exiting any API function (i.e. \n** returning control to the user) that has called sqlite3_malloc or\n** sqlite3_realloc.\n**\n** The returned value is normally a copy of the second argument to this\n** function. However, if a malloc() failure has occurred since the previous\n** invocation SQLITE_NOMEM is returned instead. \n**\n** If an OOM as occurred, then the connection error-code (the value\n** returned by sqlite3_errcode()) is set to SQLITE_NOMEM.\n*/\nSQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){\n  /* If the db handle must hold the connection handle mutex here.\n  ** Otherwise the read (and possible write) of db->mallocFailed \n  ** is unsafe, as is the call to sqlite3Error().\n  */\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){\n    return apiOomError(db);\n  }\n  return rc & db->errMask;\n}\n\n/************** End of malloc.c **********************************************/\n/************** Begin file printf.c ******************************************/\n/*\n** The \"printf\" code that follows dates from the 1980's.  It is in\n** the public domain. \n**\n**************************************************************************\n**\n** This file contains code for a set of \"printf\"-like routines.  These\n** routines format strings much like the printf() from the standard C\n** library, though the implementation here has enhancements to support\n** SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Conversion types fall into various categories as defined by the\n** following enumeration.\n*/\n#define etRADIX       0 /* non-decimal integer types.  %x %o */\n#define etFLOAT       1 /* Floating point.  %f */\n#define etEXP         2 /* Exponentional notation. %e and %E */\n#define etGENERIC     3 /* Floating or exponential, depending on exponent. %g */\n#define etSIZE        4 /* Return number of characters processed so far. %n */\n#define etSTRING      5 /* Strings. %s */\n#define etDYNSTRING   6 /* Dynamically allocated strings. %z */\n#define etPERCENT     7 /* Percent symbol. %% */\n#define etCHARX       8 /* Characters. %c */\n/* The rest are extensions, not normally found in printf() */\n#define etSQLESCAPE   9 /* Strings with '\\'' doubled.  %q */\n#define etSQLESCAPE2 10 /* Strings with '\\'' doubled and enclosed in '',\n                          NULL pointers replaced by SQL NULL.  %Q */\n#define etTOKEN      11 /* a pointer to a Token structure */\n#define etSRCLIST    12 /* a pointer to a SrcList */\n#define etPOINTER    13 /* The %p conversion */\n#define etSQLESCAPE3 14 /* %w -> Strings with '\\\"' doubled */\n#define etORDINAL    15 /* %r -> 1st, 2nd, 3rd, 4th, etc.  English only */\n#define etDECIMAL    16 /* %d or %u, but not %x, %o */\n\n#define etINVALID    17 /* Any unrecognized conversion type */\n\n\n/*\n** An \"etByte\" is an 8-bit unsigned value.\n*/\ntypedef unsigned char etByte;\n\n/*\n** Each builtin conversion character (ex: the 'd' in \"%d\") is described\n** by an instance of the following structure\n*/\ntypedef struct et_info {   /* Information about each format field */\n  char fmttype;            /* The format field code letter */\n  etByte base;             /* The base for radix conversion */\n  etByte flags;            /* One or more of FLAG_ constants below */\n  etByte type;             /* Conversion paradigm */\n  etByte charset;          /* Offset into aDigits[] of the digits string */\n  etByte prefix;           /* Offset into aPrefix[] of the prefix string */\n} et_info;\n\n/*\n** Allowed values for et_info.flags\n*/\n#define FLAG_SIGNED    1     /* True if the value to convert is signed */\n#define FLAG_STRING    4     /* Allow infinite precision */\n\n\n/*\n** The following table is searched linearly, so it is good to put the\n** most frequently used conversion types first.\n*/\nstatic const char aDigits[] = \"0123456789ABCDEF0123456789abcdef\";\nstatic const char aPrefix[] = \"-x0\\000X0\";\nstatic const et_info fmtinfo[] = {\n  {  'd', 10, 1, etDECIMAL,    0,  0 },\n  {  's',  0, 4, etSTRING,     0,  0 },\n  {  'g',  0, 1, etGENERIC,    30, 0 },\n  {  'z',  0, 4, etDYNSTRING,  0,  0 },\n  {  'q',  0, 4, etSQLESCAPE,  0,  0 },\n  {  'Q',  0, 4, etSQLESCAPE2, 0,  0 },\n  {  'w',  0, 4, etSQLESCAPE3, 0,  0 },\n  {  'c',  0, 0, etCHARX,      0,  0 },\n  {  'o',  8, 0, etRADIX,      0,  2 },\n  {  'u', 10, 0, etDECIMAL,    0,  0 },\n  {  'x', 16, 0, etRADIX,      16, 1 },\n  {  'X', 16, 0, etRADIX,      0,  4 },\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  {  'f',  0, 1, etFLOAT,      0,  0 },\n  {  'e',  0, 1, etEXP,        30, 0 },\n  {  'E',  0, 1, etEXP,        14, 0 },\n  {  'G',  0, 1, etGENERIC,    14, 0 },\n#endif\n  {  'i', 10, 1, etDECIMAL,    0,  0 },\n  {  'n',  0, 0, etSIZE,       0,  0 },\n  {  '%',  0, 0, etPERCENT,    0,  0 },\n  {  'p', 16, 0, etPOINTER,    0,  1 },\n\n  /* All the rest are undocumented and are for internal use only */\n  {  'T',  0, 0, etTOKEN,      0,  0 },\n  {  'S',  0, 0, etSRCLIST,    0,  0 },\n  {  'r', 10, 1, etORDINAL,    0,  0 },\n};\n\n/*\n** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point\n** conversions will work.\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** \"*val\" is a double such that 0.1 <= *val < 10.0\n** Return the ascii code for the leading digit of *val, then\n** multiply \"*val\" by 10.0 to renormalize.\n**\n** Example:\n**     input:     *val = 3.14159\n**     output:    *val = 1.4159    function return = '3'\n**\n** The counter *cnt is incremented each time.  After counter exceeds\n** 16 (the number of significant digits in a 64-bit float) '0' is\n** always returned.\n*/\nstatic char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){\n  int digit;\n  LONGDOUBLE_TYPE d;\n  if( (*cnt)<=0 ) return '0';\n  (*cnt)--;\n  digit = (int)*val;\n  d = digit;\n  digit += '0';\n  *val = (*val - d)*10.0;\n  return (char)digit;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Set the StrAccum object to an error mode.\n*/\nstatic void setStrAccumError(StrAccum *p, u8 eError){\n  assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );\n  p->accError = eError;\n  p->nAlloc = 0;\n}\n\n/*\n** Extra argument values from a PrintfArguments object\n*/\nstatic sqlite3_int64 getIntArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return sqlite3_value_int64(p->apArg[p->nUsed++]);\n}\nstatic double getDoubleArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0.0;\n  return sqlite3_value_double(p->apArg[p->nUsed++]);\n}\nstatic char *getTextArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);\n}\n\n\n/*\n** On machines with a small stack size, you can redefine the\n** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.\n*/\n#ifndef SQLITE_PRINT_BUF_SIZE\n# define SQLITE_PRINT_BUF_SIZE 70\n#endif\n#define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */\n\n/*\n** Render a string given by \"fmt\" into the StrAccum object.\n*/\nSQLITE_PRIVATE void sqlite3VXPrintf(\n  StrAccum *pAccum,          /* Accumulate results here */\n  const char *fmt,           /* Format string */\n  va_list ap                 /* arguments */\n){\n  int c;                     /* Next character in the format string */\n  char *bufpt;               /* Pointer to the conversion buffer */\n  int precision;             /* Precision of the current field */\n  int length;                /* Length of the field */\n  int idx;                   /* A general purpose loop counter */\n  int width;                 /* Width of the current field */\n  etByte flag_leftjustify;   /* True if \"-\" flag is present */\n  etByte flag_prefix;        /* '+' or ' ' or 0 for prefix */\n  etByte flag_alternateform; /* True if \"#\" flag is present */\n  etByte flag_altform2;      /* True if \"!\" flag is present */\n  etByte flag_zeropad;       /* True if field width constant starts with zero */\n  etByte flag_long;          /* 1 for the \"l\" flag, 2 for \"ll\", 0 by default */\n  etByte done;               /* Loop termination flag */\n  etByte cThousand;          /* Thousands separator for %d and %u */\n  etByte xtype = etINVALID;  /* Conversion paradigm */\n  u8 bArgList;               /* True for SQLITE_PRINTF_SQLFUNC */\n  char prefix;               /* Prefix character.  \"+\" or \"-\" or \" \" or '\\0'. */\n  sqlite_uint64 longvalue;   /* Value for integer types */\n  LONGDOUBLE_TYPE realvalue; /* Value for real types */\n  const et_info *infop;      /* Pointer to the appropriate info structure */\n  char *zOut;                /* Rendering buffer */\n  int nOut;                  /* Size of the rendering buffer */\n  char *zExtra = 0;          /* Malloced memory used by some conversion */\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int  exp, e2;              /* exponent of real numbers */\n  int nsd;                   /* Number of significant digits returned */\n  double rounder;            /* Used for rounding floating point values */\n  etByte flag_dp;            /* True if decimal point should be shown */\n  etByte flag_rtz;           /* True if trailing zeros should be removed */\n#endif\n  PrintfArguments *pArgList = 0; /* Arguments for SQLITE_PRINTF_SQLFUNC */\n  char buf[etBUFSIZE];       /* Conversion buffer */\n\n  bufpt = 0;\n  if( (pAccum->printfFlags & SQLITE_PRINTF_SQLFUNC)!=0 ){\n    pArgList = va_arg(ap, PrintfArguments*);\n    bArgList = 1;\n  }else{\n    bArgList = 0;\n  }\n  for(; (c=(*fmt))!=0; ++fmt){\n    if( c!='%' ){\n      bufpt = (char *)fmt;\n#if HAVE_STRCHRNUL\n      fmt = strchrnul(fmt, '%');\n#else\n      do{ fmt++; }while( *fmt && *fmt != '%' );\n#endif\n      sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));\n      if( *fmt==0 ) break;\n    }\n    if( (c=(*++fmt))==0 ){\n      sqlite3StrAccumAppend(pAccum, \"%\", 1);\n      break;\n    }\n    /* Find out what flags are present */\n    flag_leftjustify = flag_prefix = cThousand =\n     flag_alternateform = flag_altform2 = flag_zeropad = 0;\n    done = 0;\n    do{\n      switch( c ){\n        case '-':   flag_leftjustify = 1;     break;\n        case '+':   flag_prefix = '+';        break;\n        case ' ':   flag_prefix = ' ';        break;\n        case '#':   flag_alternateform = 1;   break;\n        case '!':   flag_altform2 = 1;        break;\n        case '0':   flag_zeropad = 1;         break;\n        case ',':   cThousand = ',';          break;\n        default:    done = 1;                 break;\n      }\n    }while( !done && (c=(*++fmt))!=0 );\n    /* Get the field width */\n    if( c=='*' ){\n      if( bArgList ){\n        width = (int)getIntArg(pArgList);\n      }else{\n        width = va_arg(ap,int);\n      }\n      if( width<0 ){\n        flag_leftjustify = 1;\n        width = width >= -2147483647 ? -width : 0;\n      }\n      c = *++fmt;\n    }else{\n      unsigned wx = 0;\n      while( c>='0' && c<='9' ){\n        wx = wx*10 + c - '0';\n        c = *++fmt;\n      }\n      testcase( wx>0x7fffffff );\n      width = wx & 0x7fffffff;\n    }\n    assert( width>=0 );\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n    if( width>SQLITE_PRINTF_PRECISION_LIMIT ){\n      width = SQLITE_PRINTF_PRECISION_LIMIT;\n    }\n#endif\n\n    /* Get the precision */\n    if( c=='.' ){\n      c = *++fmt;\n      if( c=='*' ){\n        if( bArgList ){\n          precision = (int)getIntArg(pArgList);\n        }else{\n          precision = va_arg(ap,int);\n        }\n        c = *++fmt;\n        if( precision<0 ){\n          precision = precision >= -2147483647 ? -precision : -1;\n        }\n      }else{\n        unsigned px = 0;\n        while( c>='0' && c<='9' ){\n          px = px*10 + c - '0';\n          c = *++fmt;\n        }\n        testcase( px>0x7fffffff );\n        precision = px & 0x7fffffff;\n      }\n    }else{\n      precision = -1;\n    }\n    assert( precision>=(-1) );\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n    if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){\n      precision = SQLITE_PRINTF_PRECISION_LIMIT;\n    }\n#endif\n\n\n    /* Get the conversion type modifier */\n    if( c=='l' ){\n      flag_long = 1;\n      c = *++fmt;\n      if( c=='l' ){\n        flag_long = 2;\n        c = *++fmt;\n      }\n    }else{\n      flag_long = 0;\n    }\n    /* Fetch the info entry for the field */\n    infop = &fmtinfo[0];\n    xtype = etINVALID;\n    for(idx=0; idx<ArraySize(fmtinfo); idx++){\n      if( c==fmtinfo[idx].fmttype ){\n        infop = &fmtinfo[idx];\n        xtype = infop->type;\n        break;\n      }\n    }\n\n    /*\n    ** At this point, variables are initialized as follows:\n    **\n    **   flag_alternateform          TRUE if a '#' is present.\n    **   flag_altform2               TRUE if a '!' is present.\n    **   flag_prefix                 '+' or ' ' or zero\n    **   flag_leftjustify            TRUE if a '-' is present or if the\n    **                               field width was negative.\n    **   flag_zeropad                TRUE if the width began with 0.\n    **   flag_long                   1 for \"l\", 2 for \"ll\"\n    **   width                       The specified field width.  This is\n    **                               always non-negative.  Zero is the default.\n    **   precision                   The specified precision.  The default\n    **                               is -1.\n    **   xtype                       The class of the conversion.\n    **   infop                       Pointer to the appropriate info struct.\n    */\n    switch( xtype ){\n      case etPOINTER:\n        flag_long = sizeof(char*)==sizeof(i64) ? 2 :\n                     sizeof(char*)==sizeof(long int) ? 1 : 0;\n        /* Fall through into the next case */\n      case etORDINAL:\n      case etRADIX:      \n        cThousand = 0;\n        /* Fall through into the next case */\n      case etDECIMAL:\n        if( infop->flags & FLAG_SIGNED ){\n          i64 v;\n          if( bArgList ){\n            v = getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              v = va_arg(ap,i64) ;\n            }else{\n              v = va_arg(ap,long int);\n            }\n          }else{\n            v = va_arg(ap,int);\n          }\n          if( v<0 ){\n            if( v==SMALLEST_INT64 ){\n              longvalue = ((u64)1)<<63;\n            }else{\n              longvalue = -v;\n            }\n            prefix = '-';\n          }else{\n            longvalue = v;\n            prefix = flag_prefix;\n          }\n        }else{\n          if( bArgList ){\n            longvalue = (u64)getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              longvalue = va_arg(ap,u64);\n            }else{\n              longvalue = va_arg(ap,unsigned long int);\n            }\n          }else{\n            longvalue = va_arg(ap,unsigned int);\n          }\n          prefix = 0;\n        }\n        if( longvalue==0 ) flag_alternateform = 0;\n        if( flag_zeropad && precision<width-(prefix!=0) ){\n          precision = width-(prefix!=0);\n        }\n        if( precision<etBUFSIZE-10-etBUFSIZE/3 ){\n          nOut = etBUFSIZE;\n          zOut = buf;\n        }else{\n          u64 n = (u64)precision + 10 + precision/3;\n          zOut = zExtra = sqlite3Malloc( n );\n          if( zOut==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n          nOut = (int)n;\n        }\n        bufpt = &zOut[nOut-1];\n        if( xtype==etORDINAL ){\n          static const char zOrd[] = \"thstndrd\";\n          int x = (int)(longvalue % 10);\n          if( x>=4 || (longvalue/10)%10==1 ){\n            x = 0;\n          }\n          *(--bufpt) = zOrd[x*2+1];\n          *(--bufpt) = zOrd[x*2];\n        }\n        {\n          const char *cset = &aDigits[infop->charset];\n          u8 base = infop->base;\n          do{                                           /* Convert to ascii */\n            *(--bufpt) = cset[longvalue%base];\n            longvalue = longvalue/base;\n          }while( longvalue>0 );\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        while( precision>length ){\n          *(--bufpt) = '0';                             /* Zero pad */\n          length++;\n        }\n        if( cThousand ){\n          int nn = (length - 1)/3;  /* Number of \",\" to insert */\n          int ix = (length - 1)%3 + 1;\n          bufpt -= nn;\n          for(idx=0; nn>0; idx++){\n            bufpt[idx] = bufpt[idx+nn];\n            ix--;\n            if( ix==0 ){\n              bufpt[++idx] = cThousand;\n              nn--;\n              ix = 3;\n            }\n          }\n        }\n        if( prefix ) *(--bufpt) = prefix;               /* Add sign */\n        if( flag_alternateform && infop->prefix ){      /* Add \"0\" or \"0x\" */\n          const char *pre;\n          char x;\n          pre = &aPrefix[infop->prefix];\n          for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        break;\n      case etFLOAT:\n      case etEXP:\n      case etGENERIC:\n        if( bArgList ){\n          realvalue = getDoubleArg(pArgList);\n        }else{\n          realvalue = va_arg(ap,double);\n        }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n        length = 0;\n#else\n        if( precision<0 ) precision = 6;         /* Set default precision */\n        if( realvalue<0.0 ){\n          realvalue = -realvalue;\n          prefix = '-';\n        }else{\n          prefix = flag_prefix;\n        }\n        if( xtype==etGENERIC && precision>0 ) precision--;\n        testcase( precision>0xfff );\n        for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}\n        if( xtype==etFLOAT ) realvalue += rounder;\n        /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */\n        exp = 0;\n        if( sqlite3IsNaN((double)realvalue) ){\n          bufpt = \"NaN\";\n          length = 3;\n          break;\n        }\n        if( realvalue>0.0 ){\n          LONGDOUBLE_TYPE scale = 1.0;\n          while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;}\n          while( realvalue>=1e10*scale && exp<=350 ){ scale *= 1e10; exp+=10; }\n          while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }\n          realvalue /= scale;\n          while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }\n          while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }\n          if( exp>350 ){\n            bufpt = buf;\n            buf[0] = prefix;\n            memcpy(buf+(prefix!=0),\"Inf\",4);\n            length = 3+(prefix!=0);\n            break;\n          }\n        }\n        bufpt = buf;\n        /*\n        ** If the field type is etGENERIC, then convert to either etEXP\n        ** or etFLOAT, as appropriate.\n        */\n        if( xtype!=etFLOAT ){\n          realvalue += rounder;\n          if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }\n        }\n        if( xtype==etGENERIC ){\n          flag_rtz = !flag_alternateform;\n          if( exp<-4 || exp>precision ){\n            xtype = etEXP;\n          }else{\n            precision = precision - exp;\n            xtype = etFLOAT;\n          }\n        }else{\n          flag_rtz = flag_altform2;\n        }\n        if( xtype==etEXP ){\n          e2 = 0;\n        }else{\n          e2 = exp;\n        }\n        if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){\n          bufpt = zExtra \n              = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );\n          if( bufpt==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n        }\n        zOut = bufpt;\n        nsd = 16 + flag_altform2*10;\n        flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;\n        /* The sign in front of the number */\n        if( prefix ){\n          *(bufpt++) = prefix;\n        }\n        /* Digits prior to the decimal point */\n        if( e2<0 ){\n          *(bufpt++) = '0';\n        }else{\n          for(; e2>=0; e2--){\n            *(bufpt++) = et_getdigit(&realvalue,&nsd);\n          }\n        }\n        /* The decimal point */\n        if( flag_dp ){\n          *(bufpt++) = '.';\n        }\n        /* \"0\" digits after the decimal point but before the first\n        ** significant digit of the number */\n        for(e2++; e2<0; precision--, e2++){\n          assert( precision>0 );\n          *(bufpt++) = '0';\n        }\n        /* Significant digits after the decimal point */\n        while( (precision--)>0 ){\n          *(bufpt++) = et_getdigit(&realvalue,&nsd);\n        }\n        /* Remove trailing zeros and the \".\" if no digits follow the \".\" */\n        if( flag_rtz && flag_dp ){\n          while( bufpt[-1]=='0' ) *(--bufpt) = 0;\n          assert( bufpt>zOut );\n          if( bufpt[-1]=='.' ){\n            if( flag_altform2 ){\n              *(bufpt++) = '0';\n            }else{\n              *(--bufpt) = 0;\n            }\n          }\n        }\n        /* Add the \"eNNN\" suffix */\n        if( xtype==etEXP ){\n          *(bufpt++) = aDigits[infop->charset];\n          if( exp<0 ){\n            *(bufpt++) = '-'; exp = -exp;\n          }else{\n            *(bufpt++) = '+';\n          }\n          if( exp>=100 ){\n            *(bufpt++) = (char)((exp/100)+'0');        /* 100's digit */\n            exp %= 100;\n          }\n          *(bufpt++) = (char)(exp/10+'0');             /* 10's digit */\n          *(bufpt++) = (char)(exp%10+'0');             /* 1's digit */\n        }\n        *bufpt = 0;\n\n        /* The converted number is in buf[] and zero terminated. Output it.\n        ** Note that the number is in the usual order, not reversed as with\n        ** integer conversions. */\n        length = (int)(bufpt-zOut);\n        bufpt = zOut;\n\n        /* Special case:  Add leading zeros if the flag_zeropad flag is\n        ** set and we are not left justified */\n        if( flag_zeropad && !flag_leftjustify && length < width){\n          int i;\n          int nPad = width - length;\n          for(i=width; i>=nPad; i--){\n            bufpt[i] = bufpt[i-nPad];\n          }\n          i = prefix!=0;\n          while( nPad-- ) bufpt[i++] = '0';\n          length = width;\n        }\n#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */\n        break;\n      case etSIZE:\n        if( !bArgList ){\n          *(va_arg(ap,int*)) = pAccum->nChar;\n        }\n        length = width = 0;\n        break;\n      case etPERCENT:\n        buf[0] = '%';\n        bufpt = buf;\n        length = 1;\n        break;\n      case etCHARX:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          c = bufpt ? bufpt[0] : 0;\n        }else{\n          c = va_arg(ap,int);\n        }\n        if( precision>1 ){\n          width -= precision-1;\n          if( width>1 && !flag_leftjustify ){\n            sqlite3AppendChar(pAccum, width-1, ' ');\n            width = 0;\n          }\n          sqlite3AppendChar(pAccum, precision-1, c);\n        }\n        length = 1;\n        buf[0] = c;\n        bufpt = buf;\n        break;\n      case etSTRING:\n      case etDYNSTRING:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          xtype = etSTRING;\n        }else{\n          bufpt = va_arg(ap,char*);\n        }\n        if( bufpt==0 ){\n          bufpt = \"\";\n        }else if( xtype==etDYNSTRING ){\n          zExtra = bufpt;\n        }\n        if( precision>=0 ){\n          for(length=0; length<precision && bufpt[length]; length++){}\n        }else{\n          length = 0x7fffffff & (int)strlen(bufpt);\n        }\n        break;\n      case etSQLESCAPE:           /* Escape ' characters */\n      case etSQLESCAPE2:          /* Escape ' and enclose in '...' */\n      case etSQLESCAPE3: {        /* Escape \" characters */\n        int i, j, k, n, isnull;\n        int needQuote;\n        char ch;\n        char q = ((xtype==etSQLESCAPE3)?'\"':'\\'');   /* Quote character */\n        char *escarg;\n\n        if( bArgList ){\n          escarg = getTextArg(pArgList);\n        }else{\n          escarg = va_arg(ap,char*);\n        }\n        isnull = escarg==0;\n        if( isnull ) escarg = (xtype==etSQLESCAPE2 ? \"NULL\" : \"(NULL)\");\n        k = precision;\n        for(i=n=0; k!=0 && (ch=escarg[i])!=0; i++, k--){\n          if( ch==q )  n++;\n        }\n        needQuote = !isnull && xtype==etSQLESCAPE2;\n        n += i + 3;\n        if( n>etBUFSIZE ){\n          bufpt = zExtra = sqlite3Malloc( n );\n          if( bufpt==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n        }else{\n          bufpt = buf;\n        }\n        j = 0;\n        if( needQuote ) bufpt[j++] = q;\n        k = i;\n        for(i=0; i<k; i++){\n          bufpt[j++] = ch = escarg[i];\n          if( ch==q ) bufpt[j++] = ch;\n        }\n        if( needQuote ) bufpt[j++] = q;\n        bufpt[j] = 0;\n        length = j;\n        /* The precision in %q and %Q means how many input characters to\n        ** consume, not the length of the output...\n        ** if( precision>=0 && precision<length ) length = precision; */\n        break;\n      }\n      case etTOKEN: {\n        Token *pToken;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pToken = va_arg(ap, Token*);\n        assert( bArgList==0 );\n        if( pToken && pToken->n ){\n          sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);\n        }\n        length = width = 0;\n        break;\n      }\n      case etSRCLIST: {\n        SrcList *pSrc;\n        int k;\n        struct SrcList_item *pItem;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pSrc = va_arg(ap, SrcList*);\n        k = va_arg(ap, int);\n        pItem = &pSrc->a[k];\n        assert( bArgList==0 );\n        assert( k>=0 && k<pSrc->nSrc );\n        if( pItem->zDatabase ){\n          sqlite3StrAccumAppendAll(pAccum, pItem->zDatabase);\n          sqlite3StrAccumAppend(pAccum, \".\", 1);\n        }\n        sqlite3StrAccumAppendAll(pAccum, pItem->zName);\n        length = width = 0;\n        break;\n      }\n      default: {\n        assert( xtype==etINVALID );\n        return;\n      }\n    }/* End switch over the format type */\n    /*\n    ** The text of the conversion is pointed to by \"bufpt\" and is\n    ** \"length\" characters long.  The field width is \"width\".  Do\n    ** the output.\n    */\n    width -= length;\n    if( width>0 ){\n      if( !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');\n      sqlite3StrAccumAppend(pAccum, bufpt, length);\n      if( flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');\n    }else{\n      sqlite3StrAccumAppend(pAccum, bufpt, length);\n    }\n\n    if( zExtra ){\n      sqlite3DbFree(pAccum->db, zExtra);\n      zExtra = 0;\n    }\n  }/* End for loop over the format string */\n} /* End of function */\n\n/*\n** Enlarge the memory allocation on a StrAccum object so that it is\n** able to accept at least N more bytes of text.\n**\n** Return the number of bytes of text that StrAccum is able to accept\n** after the attempted enlargement.  The value returned might be zero.\n*/\nstatic int sqlite3StrAccumEnlarge(StrAccum *p, int N){\n  char *zNew;\n  assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */\n  if( p->accError ){\n    testcase(p->accError==STRACCUM_TOOBIG);\n    testcase(p->accError==STRACCUM_NOMEM);\n    return 0;\n  }\n  if( p->mxAlloc==0 ){\n    N = p->nAlloc - p->nChar - 1;\n    setStrAccumError(p, STRACCUM_TOOBIG);\n    return N;\n  }else{\n    char *zOld = isMalloced(p) ? p->zText : 0;\n    i64 szNew = p->nChar;\n    szNew += N + 1;\n    if( szNew+p->nChar<=p->mxAlloc ){\n      /* Force exponential buffer size growth as long as it does not overflow,\n      ** to avoid having to call this routine too often */\n      szNew += p->nChar;\n    }\n    if( szNew > p->mxAlloc ){\n      sqlite3StrAccumReset(p);\n      setStrAccumError(p, STRACCUM_TOOBIG);\n      return 0;\n    }else{\n      p->nAlloc = (int)szNew;\n    }\n    if( p->db ){\n      zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);\n    }else{\n      zNew = sqlite3_realloc64(zOld, p->nAlloc);\n    }\n    if( zNew ){\n      assert( p->zText!=0 || p->nChar==0 );\n      if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);\n      p->zText = zNew;\n      p->nAlloc = sqlite3DbMallocSize(p->db, zNew);\n      p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n    }else{\n      sqlite3StrAccumReset(p);\n      setStrAccumError(p, STRACCUM_NOMEM);\n      return 0;\n    }\n  }\n  return N;\n}\n\n/*\n** Append N copies of character c to the given string buffer.\n*/\nSQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){\n  testcase( p->nChar + (i64)N > 0x7fffffff );\n  if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){\n    return;\n  }\n  while( (N--)>0 ) p->zText[p->nChar++] = c;\n}\n\n/*\n** The StrAccum \"p\" is not large enough to accept N new bytes of z[].\n** So enlarge if first, then do the append.\n**\n** This is a helper routine to sqlite3StrAccumAppend() that does special-case\n** work (enlarging the buffer) using tail recursion, so that the\n** sqlite3StrAccumAppend() routine can use fast calling semantics.\n*/\nstatic void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){\n  N = sqlite3StrAccumEnlarge(p, N);\n  if( N>0 ){\n    memcpy(&p->zText[p->nChar], z, N);\n    p->nChar += N;\n  }\n}\n\n/*\n** Append N bytes of text from z to the StrAccum object.  Increase the\n** size of the memory allocation for StrAccum if necessary.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){\n  assert( z!=0 || N==0 );\n  assert( p->zText!=0 || p->nChar==0 || p->accError );\n  assert( N>=0 );\n  assert( p->accError==0 || p->nAlloc==0 );\n  if( p->nChar+N >= p->nAlloc ){\n    enlargeAndAppend(p,z,N);\n  }else if( N ){\n    assert( p->zText );\n    p->nChar += N;\n    memcpy(&p->zText[p->nChar-N], z, N);\n  }\n}\n\n/*\n** Append the complete text of zero-terminated string z[] to the p string.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum *p, const char *z){\n  sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z));\n}\n\n\n/*\n** Finish off a string by making sure it is zero-terminated.\n** Return a pointer to the resulting string.  Return a NULL\n** pointer if any kind of error was encountered.\n*/\nstatic SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){\n  char *zText;\n  assert( p->mxAlloc>0 && !isMalloced(p) );\n  zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );\n  if( zText ){\n    memcpy(zText, p->zText, p->nChar+1);\n    p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n  }else{\n    setStrAccumError(p, STRACCUM_NOMEM);\n  }\n  p->zText = zText;\n  return zText;\n}\nSQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){\n  if( p->zText ){\n    p->zText[p->nChar] = 0;\n    if( p->mxAlloc>0 && !isMalloced(p) ){\n      return strAccumFinishRealloc(p);\n    }\n  }\n  return p->zText;\n}\n\n/*\n** Reset an StrAccum string.  Reclaim all malloced memory.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){\n  if( isMalloced(p) ){\n    sqlite3DbFree(p->db, p->zText);\n    p->printfFlags &= ~SQLITE_PRINTF_MALLOCED;\n  }\n  p->zText = 0;\n}\n\n/*\n** Initialize a string accumulator.\n**\n** p:     The accumulator to be initialized.\n** db:    Pointer to a database connection.  May be NULL.  Lookaside\n**        memory is used if not NULL. db->mallocFailed is set appropriately\n**        when not NULL.\n** zBase: An initial buffer.  May be NULL in which case the initial buffer\n**        is malloced.\n** n:     Size of zBase in bytes.  If total space requirements never exceed\n**        n then no memory allocations ever occur.\n** mx:    Maximum number of bytes to accumulate.  If mx==0 then no memory\n**        allocations will ever occur.\n*/\nSQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){\n  p->zText = zBase;\n  p->db = db;\n  p->nAlloc = n;\n  p->mxAlloc = mx;\n  p->nChar = 0;\n  p->accError = 0;\n  p->printfFlags = 0;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n  assert( db!=0 );\n  sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),\n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  acc.printfFlags = SQLITE_PRINTF_INTERNAL;\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  if( acc.accError==STRACCUM_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return z;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nSQLITE_PRIVATE char *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR  \n  if( zFormat==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc()().  Omit the internal\n** %-conversion extensions.\n*/\nSQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** sqlite3_snprintf() works like snprintf() except that it ignores the\n** current locale settings.  This is important for SQLite because we\n** are not able to use a \",\" as the decimal point in place of \".\" as\n** specified by some locales.\n**\n** Oops:  The first two arguments of sqlite3_snprintf() are backwards\n** from the snprintf() standard.  Unfortunately, it is too late to change\n** this without breaking compatibility, so we just have to live with the\n** mistake.\n**\n** sqlite3_vsnprintf() is the varargs version.\n*/\nSQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){\n  StrAccum acc;\n  if( n<=0 ) return zBuf;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zBuf==0 || zFormat==0 ) {\n    (void)SQLITE_MISUSE_BKPT;\n    if( zBuf ) zBuf[0] = 0;\n    return zBuf;\n  }\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  zBuf[acc.nChar] = 0;\n  return zBuf;\n}\nSQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){\n  char *z;\n  va_list ap;\n  va_start(ap,zFormat);\n  z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** This is the routine that actually formats the sqlite3_log() message.\n** We house it in a separate routine from sqlite3_log() to avoid using\n** stack space on small-stack systems when logging is disabled.\n**\n** sqlite3_log() must render into a static buffer.  It cannot dynamically\n** allocate memory because it might be called while the memory allocator\n** mutex is held.\n**\n** sqlite3VXPrintf() might ask for *temporary* memory allocations for\n** certain format characters (%q) or for very large precisions or widths.\n** Care must be taken that any sqlite3_log() calls that occur while the\n** memory mutex is held do not use these mechanisms.\n*/\nstatic void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){\n  StrAccum acc;                          /* String accumulator */\n  char zMsg[SQLITE_PRINT_BUF_SIZE*3];    /* Complete log message */\n\n  sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,\n                           sqlite3StrAccumFinish(&acc));\n}\n\n/*\n** Format and write a message to the log if logging is enabled.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){\n  va_list ap;                             /* Vararg list */\n  if( sqlite3GlobalConfig.xLog ){\n    va_start(ap, zFormat);\n    renderLogMsg(iErrCode, zFormat, ap);\n    va_end(ap);\n  }\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n/*\n** A version of printf() that understands %lld.  Used for debugging.\n** The printf() built into some versions of windows does not understand %lld\n** and segfaults if you give it a long long int.\n*/\nSQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){\n  va_list ap;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  va_end(ap);\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n#endif\n\n\n/*\n** variable-argument wrapper around sqlite3VXPrintf().  The bFlags argument\n** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.\n*/\nSQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(p, zFormat, ap);\n  va_end(ap);\n}\n\n/************** End of printf.c **********************************************/\n/************** Begin file treeview.c ****************************************/\n/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains C code to implement the TreeView debugging routines.\n** These routines print a parse tree to standard output for debugging and\n** analysis. \n**\n** The interfaces in this file is only available when compiling\n** with SQLITE_DEBUG.\n*/\n/* #include \"sqliteInt.h\" */\n#ifdef SQLITE_DEBUG\n\n/*\n** Add a new subitem to the tree.  The moreToFollow flag indicates that this\n** is not the last item in the tree.\n*/\nstatic TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){\n  if( p==0 ){\n    p = sqlite3_malloc64( sizeof(*p) );\n    if( p==0 ) return 0;\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->iLevel++;\n  }\n  assert( moreToFollow==0 || moreToFollow==1 );\n  if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;\n  return p;\n}\n\n/*\n** Finished with one layer of the tree\n*/\nstatic void sqlite3TreeViewPop(TreeView *p){\n  if( p==0 ) return;\n  p->iLevel--;\n  if( p->iLevel<0 ) sqlite3_free(p);\n}\n\n/*\n** Generate a single line of output for the tree, with a prefix that contains\n** all the appropriate tree lines\n*/\nstatic void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){\n  va_list ap;\n  int i;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  if( p ){\n    for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){\n      sqlite3StrAccumAppend(&acc, p->bLine[i] ? \"|   \" : \"    \", 4);\n    }\n    sqlite3StrAccumAppend(&acc, p->bLine[i] ? \"|-- \" : \"'-- \", 4);\n  }\n  va_start(ap, zFormat);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  va_end(ap);\n  assert( acc.nChar>0 );\n  if( zBuf[acc.nChar-1]!='\\n' ) sqlite3StrAccumAppend(&acc, \"\\n\", 1);\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n\n/*\n** Shorthand for starting a new tree item that consists of a single label\n*/\nstatic void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreFollows){\n  p = sqlite3TreeViewPush(p, moreFollows);\n  sqlite3TreeViewLine(p, \"%s\", zLabel);\n}\n\n/*\n** Generate a human-readable description of a WITH clause.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 moreToFollow){\n  int i;\n  if( pWith==0 ) return;\n  if( pWith->nCte==0 ) return;\n  if( pWith->pOuter ){\n    sqlite3TreeViewLine(pView, \"WITH (0x%p, pOuter=0x%p)\",pWith,pWith->pOuter);\n  }else{\n    sqlite3TreeViewLine(pView, \"WITH (0x%p)\", pWith);\n  }\n  if( pWith->nCte>0 ){\n    pView = sqlite3TreeViewPush(pView, 1);\n    for(i=0; i<pWith->nCte; i++){\n      StrAccum x;\n      char zLine[1000];\n      const struct Cte *pCte = &pWith->a[i];\n      sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n      sqlite3XPrintf(&x, \"%s\", pCte->zName);\n      if( pCte->pCols && pCte->pCols->nExpr>0 ){\n        char cSep = '(';\n        int j;\n        for(j=0; j<pCte->pCols->nExpr; j++){\n          sqlite3XPrintf(&x, \"%c%s\", cSep, pCte->pCols->a[j].zName);\n          cSep = ',';\n        }\n        sqlite3XPrintf(&x, \")\");\n      }\n      sqlite3XPrintf(&x, \" AS\");\n      sqlite3StrAccumFinish(&x);\n      sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1);\n      sqlite3TreeViewSelect(pView, pCte->pSelect, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    sqlite3TreeViewPop(pView);\n  }\n}\n\n\n/*\n** Generate a human-readable description of a Select object.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){\n  int n = 0;\n  int cnt = 0;\n  if( p==0 ){\n    sqlite3TreeViewLine(pView, \"nil-SELECT\");\n    return;\n  } \n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( p->pWith ){\n    sqlite3TreeViewWith(pView, p->pWith, 1);\n    cnt = 1;\n    sqlite3TreeViewPush(pView, 1);\n  }\n  do{\n    sqlite3TreeViewLine(pView, \"SELECT%s%s (0x%p) selFlags=0x%x nSelectRow=%d\",\n      ((p->selFlags & SF_Distinct) ? \" DISTINCT\" : \"\"),\n      ((p->selFlags & SF_Aggregate) ? \" agg_flag\" : \"\"), p, p->selFlags,\n      (int)p->nSelectRow\n    );\n    if( cnt++ ) sqlite3TreeViewPop(pView);\n    if( p->pPrior ){\n      n = 1000;\n    }else{\n      n = 0;\n      if( p->pSrc && p->pSrc->nSrc ) n++;\n      if( p->pWhere ) n++;\n      if( p->pGroupBy ) n++;\n      if( p->pHaving ) n++;\n      if( p->pOrderBy ) n++;\n      if( p->pLimit ) n++;\n      if( p->pOffset ) n++;\n    }\n    sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, \"result-set\");\n    if( p->pSrc && p->pSrc->nSrc ){\n      int i;\n      pView = sqlite3TreeViewPush(pView, (n--)>0);\n      sqlite3TreeViewLine(pView, \"FROM\");\n      for(i=0; i<p->pSrc->nSrc; i++){\n        struct SrcList_item *pItem = &p->pSrc->a[i];\n        StrAccum x;\n        char zLine[100];\n        sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n        sqlite3XPrintf(&x, \"{%d,*}\", pItem->iCursor);\n        if( pItem->zDatabase ){\n          sqlite3XPrintf(&x, \" %s.%s\", pItem->zDatabase, pItem->zName);\n        }else if( pItem->zName ){\n          sqlite3XPrintf(&x, \" %s\", pItem->zName);\n        }\n        if( pItem->pTab ){\n          sqlite3XPrintf(&x, \" tabname=%Q\", pItem->pTab->zName);\n        }\n        if( pItem->zAlias ){\n          sqlite3XPrintf(&x, \" (AS %s)\", pItem->zAlias);\n        }\n        if( pItem->fg.jointype & JT_LEFT ){\n          sqlite3XPrintf(&x, \" LEFT-JOIN\");\n        }\n        sqlite3StrAccumFinish(&x);\n        sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1); \n        if( pItem->pSelect ){\n          sqlite3TreeViewSelect(pView, pItem->pSelect, 0);\n        }\n        if( pItem->fg.isTabFunc ){\n          sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, \"func-args:\");\n        }\n        sqlite3TreeViewPop(pView);\n      }\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pWhere ){\n      sqlite3TreeViewItem(pView, \"WHERE\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pWhere, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pGroupBy ){\n      sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, \"GROUPBY\");\n    }\n    if( p->pHaving ){\n      sqlite3TreeViewItem(pView, \"HAVING\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pHaving, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pOrderBy ){\n      sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, \"ORDERBY\");\n    }\n    if( p->pLimit ){\n      sqlite3TreeViewItem(pView, \"LIMIT\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pLimit, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pOffset ){\n      sqlite3TreeViewItem(pView, \"OFFSET\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pOffset, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pPrior ){\n      const char *zOp = \"UNION\";\n      switch( p->op ){\n        case TK_ALL:         zOp = \"UNION ALL\";  break;\n        case TK_INTERSECT:   zOp = \"INTERSECT\";  break;\n        case TK_EXCEPT:      zOp = \"EXCEPT\";     break;\n      }\n      sqlite3TreeViewItem(pView, zOp, 1);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  sqlite3TreeViewPop(pView);\n}\n\n/*\n** Generate a human-readable explanation of an expression tree.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){\n  const char *zBinOp = 0;   /* Binary operator */\n  const char *zUniOp = 0;   /* Unary operator */\n  char zFlgs[60];\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( pExpr==0 ){\n    sqlite3TreeViewLine(pView, \"nil\");\n    sqlite3TreeViewPop(pView);\n    return;\n  }\n  if( pExpr->flags ){\n    if( ExprHasProperty(pExpr, EP_FromJoin) ){\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x iRJT=%d\",\n                       pExpr->flags, pExpr->iRightJoinTable);\n    }else{\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x\",pExpr->flags);\n    }\n  }else{\n    zFlgs[0] = 0;\n  }\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN: {\n      sqlite3TreeViewLine(pView, \"AGG{%d:%d}%s\",\n            pExpr->iTable, pExpr->iColumn, zFlgs);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iTable<0 ){\n        /* This only happens when coding check constraints */\n        sqlite3TreeViewLine(pView, \"COLUMN(%d)%s\", pExpr->iColumn, zFlgs);\n      }else{\n        sqlite3TreeViewLine(pView, \"{%d:%d}%s\",\n                             pExpr->iTable, pExpr->iColumn, zFlgs);\n      }\n      break;\n    }\n    case TK_INTEGER: {\n      if( pExpr->flags & EP_IntValue ){\n        sqlite3TreeViewLine(pView, \"%d\", pExpr->u.iValue);\n      }else{\n        sqlite3TreeViewLine(pView, \"%s\", pExpr->u.zToken);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_STRING: {\n      sqlite3TreeViewLine(pView,\"%Q\", pExpr->u.zToken);\n      break;\n    }\n    case TK_NULL: {\n      sqlite3TreeViewLine(pView,\"NULL\");\n      break;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_VARIABLE: {\n      sqlite3TreeViewLine(pView,\"VARIABLE(%s,%d)\",\n                          pExpr->u.zToken, pExpr->iColumn);\n      break;\n    }\n    case TK_REGISTER: {\n      sqlite3TreeViewLine(pView,\"REGISTER(%d)\", pExpr->iTable);\n      break;\n    }\n    case TK_ID: {\n      sqlite3TreeViewLine(pView,\"ID \\\"%w\\\"\", pExpr->u.zToken);\n      break;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      sqlite3TreeViewLine(pView,\"CAST %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_LT:      zBinOp = \"LT\";     break;\n    case TK_LE:      zBinOp = \"LE\";     break;\n    case TK_GT:      zBinOp = \"GT\";     break;\n    case TK_GE:      zBinOp = \"GE\";     break;\n    case TK_NE:      zBinOp = \"NE\";     break;\n    case TK_EQ:      zBinOp = \"EQ\";     break;\n    case TK_IS:      zBinOp = \"IS\";     break;\n    case TK_ISNOT:   zBinOp = \"ISNOT\";  break;\n    case TK_AND:     zBinOp = \"AND\";    break;\n    case TK_OR:      zBinOp = \"OR\";     break;\n    case TK_PLUS:    zBinOp = \"ADD\";    break;\n    case TK_STAR:    zBinOp = \"MUL\";    break;\n    case TK_MINUS:   zBinOp = \"SUB\";    break;\n    case TK_REM:     zBinOp = \"REM\";    break;\n    case TK_BITAND:  zBinOp = \"BITAND\"; break;\n    case TK_BITOR:   zBinOp = \"BITOR\";  break;\n    case TK_SLASH:   zBinOp = \"DIV\";    break;\n    case TK_LSHIFT:  zBinOp = \"LSHIFT\"; break;\n    case TK_RSHIFT:  zBinOp = \"RSHIFT\"; break;\n    case TK_CONCAT:  zBinOp = \"CONCAT\"; break;\n    case TK_DOT:     zBinOp = \"DOT\";    break;\n\n    case TK_UMINUS:  zUniOp = \"UMINUS\"; break;\n    case TK_UPLUS:   zUniOp = \"UPLUS\";  break;\n    case TK_BITNOT:  zUniOp = \"BITNOT\"; break;\n    case TK_NOT:     zUniOp = \"NOT\";    break;\n    case TK_ISNULL:  zUniOp = \"ISNULL\"; break;\n    case TK_NOTNULL: zUniOp = \"NOTNULL\"; break;\n\n    case TK_SPAN: {\n      sqlite3TreeViewLine(pView, \"SPAN %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_COLLATE: {\n      sqlite3TreeViewLine(pView, \"COLLATE %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_AGG_FUNCTION:\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      if( pExpr->op==TK_AGG_FUNCTION ){\n        sqlite3TreeViewLine(pView, \"AGG_FUNCTION%d %Q\",\n                             pExpr->op2, pExpr->u.zToken);\n      }else{\n        sqlite3TreeViewLine(pView, \"FUNCTION %Q\", pExpr->u.zToken);\n      }\n      if( pFarg ){\n        sqlite3TreeViewExprList(pView, pFarg, 0, 0);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS: {\n      sqlite3TreeViewLine(pView, \"EXISTS-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_SELECT: {\n      sqlite3TreeViewLine(pView, \"SELECT-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_IN: {\n      sqlite3TreeViewLine(pView, \"IN flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      }else{\n        sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      }\n      break;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      Expr *pX = pExpr->pLeft;\n      Expr *pY = pExpr->x.pList->a[0].pExpr;\n      Expr *pZ = pExpr->x.pList->a[1].pExpr;\n      sqlite3TreeViewLine(pView, \"BETWEEN\");\n      sqlite3TreeViewExpr(pView, pX, 1);\n      sqlite3TreeViewExpr(pView, pY, 1);\n      sqlite3TreeViewExpr(pView, pZ, 0);\n      break;\n    }\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      */\n      sqlite3TreeViewLine(pView, \"%s(%d)\", \n          pExpr->iTable ? \"NEW\" : \"OLD\", pExpr->iColumn);\n      break;\n    }\n    case TK_CASE: {\n      sqlite3TreeViewLine(pView, \"CASE\");\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      const char *zType = \"unk\";\n      switch( pExpr->affinity ){\n        case OE_Rollback:   zType = \"rollback\";  break;\n        case OE_Abort:      zType = \"abort\";     break;\n        case OE_Fail:       zType = \"fail\";      break;\n        case OE_Ignore:     zType = \"ignore\";    break;\n      }\n      sqlite3TreeViewLine(pView, \"RAISE %s(%Q)\", zType, pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_MATCH: {\n      sqlite3TreeViewLine(pView, \"MATCH {%d:%d}%s\",\n                          pExpr->iTable, pExpr->iColumn, zFlgs);\n      sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n      break;\n    }\n    case TK_VECTOR: {\n      sqlite3TreeViewBareExprList(pView, pExpr->x.pList, \"VECTOR\");\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      sqlite3TreeViewLine(pView, \"SELECT-COLUMN %d\", pExpr->iColumn);\n      sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);\n      break;\n    }\n    case TK_IF_NULL_ROW: {\n      sqlite3TreeViewLine(pView, \"IF-NULL-ROW %d\", pExpr->iTable);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n    default: {\n      sqlite3TreeViewLine(pView, \"op=%d\", pExpr->op);\n      break;\n    }\n  }\n  if( zBinOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zBinOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n    sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n  }else if( zUniOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zUniOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n  }\n  sqlite3TreeViewPop(pView);\n}\n\n\n/*\n** Generate a human-readable explanation of an expression list.\n*/\nSQLITE_PRIVATE void sqlite3TreeViewBareExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  const char *zLabel\n){\n  if( zLabel==0 || zLabel[0]==0 ) zLabel = \"LIST\";\n  if( pList==0 ){\n    sqlite3TreeViewLine(pView, \"%s (empty)\", zLabel);\n  }else{\n    int i;\n    sqlite3TreeViewLine(pView, \"%s\", zLabel);\n    for(i=0; i<pList->nExpr; i++){\n      int j = pList->a[i].u.x.iOrderByCol;\n      if( j ){\n        sqlite3TreeViewPush(pView, 0);\n        sqlite3TreeViewLine(pView, \"iOrderByCol=%d\", j);\n      }\n      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);\n      if( j ) sqlite3TreeViewPop(pView);\n    }\n  }\n}\nSQLITE_PRIVATE void sqlite3TreeViewExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  u8 moreToFollow,\n  const char *zLabel\n){\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  sqlite3TreeViewBareExprList(pView, pList, zLabel);\n  sqlite3TreeViewPop(pView);\n}\n\n#endif /* SQLITE_DEBUG */\n\n/************** End of treeview.c ********************************************/\n/************** Begin file random.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement a pseudo-random number\n** generator (PRNG) for SQLite.\n**\n** Random numbers are used by some of the database backends in order\n** to generate random integer keys for tables or random filenames.\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/* All threads share a single random number generator.\n** This structure is the current state of the generator.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType {\n  unsigned char isInit;          /* True if initialized */\n  unsigned char i, j;            /* State variables */\n  unsigned char s[256];          /* State variables */\n} sqlite3Prng;\n\n/*\n** Return N random bytes.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *pBuf){\n  unsigned char t;\n  unsigned char *zBuf = pBuf;\n\n  /* The \"wsdPrng\" macro will resolve to the pseudo-random number generator\n  ** state vector.  If writable static data is unsupported on the target,\n  ** we have to locate the state vector at run-time.  In the more common\n  ** case where writable static data is supported, wsdPrng can refer directly\n  ** to the \"sqlite3Prng\" state vector declared above.\n  */\n#ifdef SQLITE_OMIT_WSD\n  struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);\n# define wsdPrng p[0]\n#else\n# define wsdPrng sqlite3Prng\n#endif\n\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return;\n#endif\n\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);\n#endif\n\n  sqlite3_mutex_enter(mutex);\n  if( N<=0 || pBuf==0 ){\n    wsdPrng.isInit = 0;\n    sqlite3_mutex_leave(mutex);\n    return;\n  }\n\n  /* Initialize the state of the random number generator once,\n  ** the first time this routine is called.  The seed value does\n  ** not need to contain a lot of randomness since we are not\n  ** trying to do secure encryption or anything like that...\n  **\n  ** Nothing in this file or anywhere else in SQLite does any kind of\n  ** encryption.  The RC4 algorithm is being used as a PRNG (pseudo-random\n  ** number generator) not as an encryption device.\n  */\n  if( !wsdPrng.isInit ){\n    int i;\n    char k[256];\n    wsdPrng.j = 0;\n    wsdPrng.i = 0;\n    sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);\n    for(i=0; i<256; i++){\n      wsdPrng.s[i] = (u8)i;\n    }\n    for(i=0; i<256; i++){\n      wsdPrng.j += wsdPrng.s[i] + k[i];\n      t = wsdPrng.s[wsdPrng.j];\n      wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];\n      wsdPrng.s[i] = t;\n    }\n    wsdPrng.isInit = 1;\n  }\n\n  assert( N>0 );\n  do{\n    wsdPrng.i++;\n    t = wsdPrng.s[wsdPrng.i];\n    wsdPrng.j += t;\n    wsdPrng.s[wsdPrng.i] = wsdPrng.s[wsdPrng.j];\n    wsdPrng.s[wsdPrng.j] = t;\n    t += wsdPrng.s[wsdPrng.i];\n    *(zBuf++) = wsdPrng.s[t];\n  }while( --N );\n  sqlite3_mutex_leave(mutex);\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** For testing purposes, we sometimes want to preserve the state of\n** PRNG and restore the PRNG to its saved state at a later time, or\n** to reset the PRNG to its initial state.  These routines accomplish\n** those tasks.\n**\n** The sqlite3_test_control() interface calls these routines to\n** control the PRNG.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType sqlite3SavedPrng;\nSQLITE_PRIVATE void sqlite3PrngSaveState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    sizeof(sqlite3Prng)\n  );\n}\nSQLITE_PRIVATE void sqlite3PrngRestoreState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    sizeof(sqlite3Prng)\n  );\n}\n#endif /* SQLITE_UNTESTABLE */\n\n/************** End of random.c **********************************************/\n/************** Begin file threads.c *****************************************/\n/*\n** 2012 July 21\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file presents a simple cross-platform threading interface for\n** use internally by SQLite.\n**\n** A \"thread\" can be created using sqlite3ThreadCreate().  This thread\n** runs independently of its creator until it is joined using\n** sqlite3ThreadJoin(), at which point it terminates.\n**\n** Threads do not have to be real.  It could be that the work of the\n** \"thread\" is done by the main thread at either the sqlite3ThreadCreate()\n** or sqlite3ThreadJoin() call.  This is, in fact, what happens in\n** single threaded systems.  Nothing in SQLite requires multiple threads.\n** This interface exists so that applications that want to take advantage\n** of multiple cores can do so, while also allowing applications to stay\n** single-threaded if desired.\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_WIN\n/* #  include \"os_win.h\" */\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n\n/********************************* Unix Pthreads ****************************/\n#if SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n/* #include <pthread.h> */\n\n/* A running thread */\nstruct SQLiteThread {\n  pthread_t tid;                 /* Thread ID */\n  int done;                      /* Set to true when thread finishes */\n  void *pOut;                    /* Result returned by the thread */\n  void *(*xTask)(void*);         /* The thread routine */\n  void *pIn;                     /* Argument to the thread */\n};\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n  int rc;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  /* This routine is never used in single-threaded mode */\n  assert( sqlite3GlobalConfig.bCoreMutex!=0 );\n\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  p->xTask = xTask;\n  p->pIn = pIn;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** for testing purposes. */\n  if( sqlite3FaultSim(200) ){\n    rc = 1;\n  }else{    \n    rc = pthread_create(&p->tid, 0, xTask, pIn);\n  }\n  if( rc ){\n    p->done = 1;\n    p->pOut = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  int rc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->done ){\n    *ppOut = p->pOut;\n    rc = SQLITE_OK;\n  }else{\n    rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK;\n  }\n  sqlite3_free(p);\n  return rc;\n}\n\n#endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */\n/******************************** End Unix Pthreads *************************/\n\n\n/********************************* Win32 Threads ****************************/\n#if SQLITE_OS_WIN_THREADS\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n#include <process.h>\n\n/* A running thread */\nstruct SQLiteThread {\n  void *tid;               /* The thread handle */\n  unsigned id;             /* The thread identifier */\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Thread procedure Win32 compatibility shim */\nstatic unsigned __stdcall sqlite3ThreadProc(\n  void *pArg  /* IN: Pointer to the SQLiteThread structure */\n){\n  SQLiteThread *p = (SQLiteThread *)pArg;\n\n  assert( p!=0 );\n#if 0\n  /*\n  ** This assert appears to trigger spuriously on certain\n  ** versions of Windows, possibly due to _beginthreadex()\n  ** and/or CreateThread() not fully setting their thread\n  ** ID parameter before starting the thread.\n  */\n  assert( p->id==GetCurrentThreadId() );\n#endif\n  assert( p->xTask!=0 );\n  p->pResult = p->xTask(p->pIn);\n\n  _endthreadex(0);\n  return 0; /* NOT REACHED */\n}\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** (via the sqlite3FaultSim() term of the conditional) for testing\n  ** purposes. */\n  if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->xTask = xTask;\n    p->pIn = pIn;\n    p->tid = (void*)_beginthreadex(0, 0, sqlite3ThreadProc, p, 0, &p->id);\n    if( p->tid==0 ){\n      memset(p, 0, sizeof(*p));\n    }\n  }\n  if( p->xTask==0 ){\n    p->id = GetCurrentThreadId();\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject); /* os_win.c */\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  DWORD rc;\n  BOOL bRc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask==0 ){\n    /* assert( p->id==GetCurrentThreadId() ); */\n    rc = WAIT_OBJECT_0;\n    assert( p->tid==0 );\n  }else{\n    assert( p->id!=0 && p->id!=GetCurrentThreadId() );\n    rc = sqlite3Win32Wait((HANDLE)p->tid);\n    assert( rc!=WAIT_IO_COMPLETION );\n    bRc = CloseHandle((HANDLE)p->tid);\n    assert( bRc );\n  }\n  if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;\n  sqlite3_free(p);\n  return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;\n}\n\n#endif /* SQLITE_OS_WIN_THREADS */\n/******************************** End Win32 Threads *************************/\n\n\n/********************************* Single-Threaded **************************/\n#ifndef SQLITE_THREADS_IMPLEMENTED\n/*\n** This implementation does not actually create a new thread.  It does the\n** work of the thread in the main thread, when either the thread is created\n** or when it is joined\n*/\n\n/* A running thread */\nstruct SQLiteThread {\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Create a new thread */\nSQLITE_PRIVATE int sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  if( (SQLITE_PTR_TO_INT(p)/17)&1 ){\n    p->xTask = xTask;\n    p->pIn = pIn;\n  }else{\n    p->xTask = 0;\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nSQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask ){\n    *ppOut = p->xTask(p->pIn);\n  }else{\n    *ppOut = p->pResult;\n  }\n  sqlite3_free(p);\n\n#if defined(SQLITE_TEST)\n  {\n    void *pTstAlloc = sqlite3Malloc(10);\n    if (!pTstAlloc) return SQLITE_NOMEM_BKPT;\n    sqlite3_free(pTstAlloc);\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_THREADS_IMPLEMENTED) */\n/****************************** End Single-Threaded *************************/\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n/************** End of threads.c *********************************************/\n/************** Begin file utf.c *********************************************/\n/*\n** 2004 April 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used to translate between UTF-8, \n** UTF-16, UTF-16BE, and UTF-16LE.\n**\n** Notes on UTF-8:\n**\n**   Byte-0    Byte-1    Byte-2    Byte-3    Value\n**  0xxxxxxx                                 00000000 00000000 0xxxxxxx\n**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx\n**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx\n**  11110uuu  10uuzzzz  10yyyyyy  10xxxxxx   000uuuuu zzzzyyyy yyxxxxxx\n**\n**\n** Notes on UTF-16:  (with wwww+1==uuuuu)\n**\n**      Word-0               Word-1          Value\n**  110110ww wwzzzzyy   110111yy yyxxxxxx    000uuuuu zzzzyyyy yyxxxxxx\n**  zzzzyyyy yyxxxxxx                        00000000 zzzzyyyy yyxxxxxx\n**\n**\n** BOM or Byte Order Mark:\n**     0xff 0xfe   little-endian utf-16 follows\n**     0xfe 0xff   big-endian utf-16 follows\n**\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <assert.h> */\n/* #include \"vdbeInt.h\" */\n\n#if !defined(SQLITE_AMALGAMATION) && SQLITE_BYTEORDER==0\n/*\n** The following constant value is used by the SQLITE_BIGENDIAN and\n** SQLITE_LITTLEENDIAN macros.\n*/\nSQLITE_PRIVATE const int sqlite3one = 1;\n#endif /* SQLITE_AMALGAMATION && SQLITE_BYTEORDER==0 */\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character.\n*/\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#define WRITE_UTF16LE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n  }else{                                                            \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n  }                                                                 \\\n}\n\n#define WRITE_UTF16BE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }else{                                                            \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }                                                                 \\\n}\n\n#define READ_UTF16LE(zIn, TERM, c){                                   \\\n  c = (*zIn++);                                                       \\\n  c += ((*zIn++)<<8);                                                 \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = (*zIn++);                                                \\\n    c2 += ((*zIn++)<<8);                                              \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n#define READ_UTF16BE(zIn, TERM, c){                                   \\\n  c = ((*zIn++)<<8);                                                  \\\n  c += (*zIn++);                                                      \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = ((*zIn++)<<8);                                           \\\n    c2 += (*zIn++);                                                   \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n/*\n** Translate a single UTF-8 character.  Return the unicode value.\n**\n** During translation, assume that the byte that zTerm points\n** is a 0x00.\n**\n** Write a pointer to the next unread byte back into *pzNext.\n**\n** Notes On Invalid UTF-8:\n**\n**  *  This routine never allows a 7-bit character (0x00 through 0x7f) to\n**     be encoded as a multi-byte character.  Any multi-byte character that\n**     attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd.\n**\n**  *  This routine never allows a UTF16 surrogate value to be encoded.\n**     If a multi-byte character attempts to encode a value between\n**     0xd800 and 0xe000 then it is rendered as 0xfffd.\n**\n**  *  Bytes in the range of 0x80 through 0xbf which occur as the first\n**     byte of a character are interpreted as single-byte characters\n**     and rendered as themselves even though they are technically\n**     invalid characters.\n**\n**  *  This routine accepts over-length UTF8 encodings\n**     for unicode values 0x80 and greater.  It does not change over-length\n**     encodings to 0xfffd as some systems recommend.\n*/\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\nSQLITE_PRIVATE u32 sqlite3Utf8Read(\n  const unsigned char **pz    /* Pointer to string from which to read char */\n){\n  unsigned int c;\n\n  /* Same as READ_UTF8() above but without the zTerm parameter.\n  ** For this routine, we assume the UTF8 string is always zero-terminated.\n  */\n  c = *((*pz)++);\n  if( c>=0xc0 ){\n    c = sqlite3Utf8Trans1[c-0xc0];\n    while( (*(*pz) & 0xc0)==0x80 ){\n      c = (c<<6) + (0x3f & *((*pz)++));\n    }\n    if( c<0x80\n        || (c&0xFFFFF800)==0xD800\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }\n  }\n  return c;\n}\n\n\n\n\n/*\n** If the TRANSLATE_TRACE macro is defined, the value of each Mem is\n** printed on stderr on the way into and out of sqlite3VdbeMemTranslate().\n*/ \n/* #define TRANSLATE_TRACE 1 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine transforms the internal text encoding used by pMem to\n** desiredEnc. It is an error if the string is already of the desired\n** encoding, or if *pMem does not contain a string value.\n*/\nSQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){\n  int len;                    /* Maximum length of output string in bytes */\n  unsigned char *zOut;                  /* Output buffer */\n  unsigned char *zIn;                   /* Input iterator */\n  unsigned char *zTerm;                 /* End of input */\n  unsigned char *z;                     /* Output iterator */\n  unsigned int c;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( pMem->flags&MEM_Str );\n  assert( pMem->enc!=desiredEnc );\n  assert( pMem->enc!=0 );\n  assert( pMem->n>=0 );\n\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"INPUT:  %s\\n\", zBuf);\n  }\n#endif\n\n  /* If the translation is between UTF-16 little and big endian, then \n  ** all that is required is to swap the byte order. This case is handled\n  ** differently from the others.\n  */\n  if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){\n    u8 temp;\n    int rc;\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc!=SQLITE_OK ){\n      assert( rc==SQLITE_NOMEM );\n      return SQLITE_NOMEM_BKPT;\n    }\n    zIn = (u8*)pMem->z;\n    zTerm = &zIn[pMem->n&~1];\n    while( zIn<zTerm ){\n      temp = *zIn;\n      *zIn = *(zIn+1);\n      zIn++;\n      *zIn++ = temp;\n    }\n    pMem->enc = desiredEnc;\n    goto translate_out;\n  }\n\n  /* Set len to the maximum number of bytes required in the output buffer. */\n  if( desiredEnc==SQLITE_UTF8 ){\n    /* When converting from UTF-16, the maximum growth results from\n    ** translating a 2-byte character to a 4-byte UTF-8 character.\n    ** A single byte is required for the output string\n    ** nul-terminator.\n    */\n    pMem->n &= ~1;\n    len = pMem->n * 2 + 1;\n  }else{\n    /* When converting from UTF-8 to UTF-16 the maximum growth is caused\n    ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16\n    ** character. Two bytes are required in the output buffer for the\n    ** nul-terminator.\n    */\n    len = pMem->n * 2 + 2;\n  }\n\n  /* Set zIn to point at the start of the input buffer and zTerm to point 1\n  ** byte past the end.\n  **\n  ** Variable zOut is set to point at the output buffer, space obtained\n  ** from sqlite3_malloc().\n  */\n  zIn = (u8*)pMem->z;\n  zTerm = &zIn[pMem->n];\n  zOut = sqlite3DbMallocRaw(pMem->db, len);\n  if( !zOut ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  z = zOut;\n\n  if( pMem->enc==SQLITE_UTF8 ){\n    if( desiredEnc==SQLITE_UTF16LE ){\n      /* UTF-8 -> UTF-16 Little-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16LE(z, c);\n      }\n    }else{\n      assert( desiredEnc==SQLITE_UTF16BE );\n      /* UTF-8 -> UTF-16 Big-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16BE(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n    *z++ = 0;\n  }else{\n    assert( desiredEnc==SQLITE_UTF8 );\n    if( pMem->enc==SQLITE_UTF16LE ){\n      /* UTF-16 Little-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16LE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }else{\n      /* UTF-16 Big-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16BE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n  }\n  *z = 0;\n  assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );\n\n  c = pMem->flags;\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Str|MEM_Term|(c&(MEM_AffMask|MEM_Subtype));\n  pMem->enc = desiredEnc;\n  pMem->z = (char*)zOut;\n  pMem->zMalloc = pMem->z;\n  pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z);\n\ntranslate_out:\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"OUTPUT: %s\\n\", zBuf);\n  }\n#endif\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine checks for a byte-order mark at the beginning of the \n** UTF-16 string stored in *pMem. If one is present, it is removed and\n** the encoding of the Mem adjusted. This routine does not do any\n** byte-swapping, it just sets Mem.enc appropriately.\n**\n** The allocation (static, dynamic etc.) and encoding of the Mem may be\n** changed by this function.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemHandleBom(Mem *pMem){\n  int rc = SQLITE_OK;\n  u8 bom = 0;\n\n  assert( pMem->n>=0 );\n  if( pMem->n>1 ){\n    u8 b1 = *(u8 *)pMem->z;\n    u8 b2 = *(((u8 *)pMem->z) + 1);\n    if( b1==0xFE && b2==0xFF ){\n      bom = SQLITE_UTF16BE;\n    }\n    if( b1==0xFF && b2==0xFE ){\n      bom = SQLITE_UTF16LE;\n    }\n  }\n  \n  if( bom ){\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc==SQLITE_OK ){\n      pMem->n -= 2;\n      memmove(pMem->z, &pMem->z[2], pMem->n);\n      pMem->z[pMem->n] = '\\0';\n      pMem->z[pMem->n+1] = '\\0';\n      pMem->flags |= MEM_Term;\n      pMem->enc = bom;\n    }\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,\n** return the number of unicode characters in pZ up to (but not including)\n** the first 0x00 byte. If nByte is not less than zero, return the\n** number of unicode characters in the first nByte of pZ (or up to \n** the first 0x00, whichever comes first).\n*/\nSQLITE_PRIVATE int sqlite3Utf8CharLen(const char *zIn, int nByte){\n  int r = 0;\n  const u8 *z = (const u8*)zIn;\n  const u8 *zTerm;\n  if( nByte>=0 ){\n    zTerm = &z[nByte];\n  }else{\n    zTerm = (const u8*)(-1);\n  }\n  assert( z<=zTerm );\n  while( *z!=0 && z<zTerm ){\n    SQLITE_SKIP_UTF8(z);\n    r++;\n  }\n  return r;\n}\n\n/* This test function is not currently used by the automated test-suite. \n** Hence it is only available in debug builds.\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Translate UTF-8 to UTF-8.\n**\n** This has the effect of making sure that the string is well-formed\n** UTF-8.  Miscoded characters are removed.\n**\n** The translation is done in-place and aborted if the output\n** overruns the input.\n*/\nSQLITE_PRIVATE int sqlite3Utf8To8(unsigned char *zIn){\n  unsigned char *zOut = zIn;\n  unsigned char *zStart = zIn;\n  u32 c;\n\n  while( zIn[0] && zOut<=zIn ){\n    c = sqlite3Utf8Read((const u8**)&zIn);\n    if( c!=0xfffd ){\n      WRITE_UTF8(zOut, c);\n    }\n  }\n  *zOut = 0;\n  return (int)(zOut - zStart);\n}\n#endif\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Convert a UTF-16 string in the native encoding into a UTF-8 string.\n** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must\n** be freed by the calling function.\n**\n** NULL is returned if there is an allocation error.\n*/\nSQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){\n  Mem m;\n  memset(&m, 0, sizeof(m));\n  m.db = db;\n  sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);\n  sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);\n  if( db->mallocFailed ){\n    sqlite3VdbeMemRelease(&m);\n    m.z = 0;\n  }\n  assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );\n  assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );\n  assert( m.z || db->mallocFailed );\n  return m.z;\n}\n\n/*\n** zIn is a UTF-16 encoded unicode string at least nChar characters long.\n** Return the number of bytes in the first nChar unicode characters\n** in pZ.  nChar must be non-negative.\n*/\nSQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *zIn, int nChar){\n  int c;\n  unsigned char const *z = zIn;\n  int n = 0;\n  \n  if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){\n    while( n<nChar ){\n      READ_UTF16BE(z, 1, c);\n      n++;\n    }\n  }else{\n    while( n<nChar ){\n      READ_UTF16LE(z, 1, c);\n      n++;\n    }\n  }\n  return (int)(z-(unsigned char const *)zIn);\n}\n\n#if defined(SQLITE_TEST)\n/*\n** This routine is called from the TCL test function \"translate_selftest\".\n** It checks that the primitives for serializing and deserializing\n** characters in each encoding are inverses of each other.\n*/\nSQLITE_PRIVATE void sqlite3UtfSelfTest(void){\n  unsigned int i, t;\n  unsigned char zBuf[20];\n  unsigned char *z;\n  int n;\n  unsigned int c;\n\n  for(i=0; i<0x00110000; i++){\n    z = zBuf;\n    WRITE_UTF8(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    c = sqlite3Utf8Read((const u8**)&z);\n    t = i;\n    if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;\n    if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;\n    assert( c==t );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16LE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16LE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16BE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16BE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n}\n#endif /* SQLITE_TEST */\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of utf.c *************************************************/\n/************** Begin file util.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Utility functions used throughout sqlite.\n**\n** This file contains functions for allocating memory, comparing\n** strings, and stuff like that.\n**\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdarg.h> */\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n# include <math.h>\n#endif\n\n/*\n** Routine needed to support the testcase() macro.\n*/\n#ifdef SQLITE_COVERAGE_TEST\nSQLITE_PRIVATE void sqlite3Coverage(int x){\n  static unsigned dummy = 0;\n  dummy += (unsigned)x;\n}\n#endif\n\n/*\n** Give a callback to the test harness that can be used to simulate faults\n** in places where it is difficult or expensive to do so purely by means\n** of inputs.\n**\n** The intent of the integer argument is to let the fault simulator know\n** which of multiple sqlite3FaultSim() calls has been hit.\n**\n** Return whatever integer value the test callback returns, or return\n** SQLITE_OK if no test callback is installed.\n*/\n#ifndef SQLITE_UNTESTABLE\nSQLITE_PRIVATE int sqlite3FaultSim(int iTest){\n  int (*xCallback)(int) = sqlite3GlobalConfig.xTestCallback;\n  return xCallback ? xCallback(iTest) : SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Return true if the floating point value is Not a Number (NaN).\n**\n** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.\n** Otherwise, we have our own implementation that works on most systems.\n*/\nSQLITE_PRIVATE int sqlite3IsNaN(double x){\n  int rc;   /* The value return */\n#if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN\n  /*\n  ** Systems that support the isnan() library function should probably\n  ** make use of it by compiling with -DSQLITE_HAVE_ISNAN.  But we have\n  ** found that many systems do not have a working isnan() function so\n  ** this implementation is provided as an alternative.\n  **\n  ** This NaN test sometimes fails if compiled on GCC with -ffast-math.\n  ** On the other hand, the use of -ffast-math comes with the following\n  ** warning:\n  **\n  **      This option [-ffast-math] should never be turned on by any\n  **      -O option since it can result in incorrect output for programs\n  **      which depend on an exact implementation of IEEE or ISO \n  **      rules/specifications for math functions.\n  **\n  ** Under MSVC, this NaN test may fail if compiled with a floating-\n  ** point precision mode other than /fp:precise.  From the MSDN \n  ** documentation:\n  **\n  **      The compiler [with /fp:precise] will properly handle comparisons \n  **      involving NaN. For example, x != x evaluates to true if x is NaN \n  **      ...\n  */\n#ifdef __FAST_MATH__\n# error SQLite will not work correctly with the -ffast-math option of GCC.\n#endif\n  volatile double y = x;\n  volatile double z = y;\n  rc = (y!=z);\n#else  /* if HAVE_ISNAN */\n  rc = isnan(x);\n#endif /* HAVE_ISNAN */\n  testcase( rc );\n  return rc;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n**\n** The value returned will never be negative.  Nor will it ever be greater\n** than the actual length of the string.  For very long strings (greater\n** than 1GiB) the value returned might be less than the true string length.\n*/\nSQLITE_PRIVATE int sqlite3Strlen30(const char *z){\n  if( z==0 ) return 0;\n  return 0x3fffffff & (int)strlen(z);\n}\n\n/*\n** Return the declared type of a column.  Or return zDflt if the column \n** has no declared type.\n**\n** The column type is an extra string stored after the zero-terminator on\n** the column name if and only if the COLFLAG_HASTYPE flag is set.\n*/\nSQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){\n  if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;\n  return pCol->zName + strlen(pCol->zName) + 1;\n}\n\n/*\n** Helper function for sqlite3Error() - called rarely.  Broken out into\n** a separate routine to avoid unnecessary register saves on entry to\n** sqlite3Error().\n*/\nstatic SQLITE_NOINLINE void  sqlite3ErrorFinish(sqlite3 *db, int err_code){\n  if( db->pErr ) sqlite3ValueSetNull(db->pErr);\n  sqlite3SystemError(db, err_code);\n}\n\n/*\n** Set the current error code to err_code and clear any prior error message.\n** Also set iSysErrno (by calling sqlite3System) if the err_code indicates\n** that would be appropriate.\n*/\nSQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){\n  assert( db!=0 );\n  db->errCode = err_code;\n  if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);\n}\n\n/*\n** Load the sqlite3.iSysErrno field if that is an appropriate thing\n** to do based on the SQLite error code in rc.\n*/\nSQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){\n  if( rc==SQLITE_IOERR_NOMEM ) return;\n  rc &= 0xff;\n  if( rc==SQLITE_CANTOPEN || rc==SQLITE_IOERR ){\n    db->iSysErrno = sqlite3OsGetLastError(db->pVfs);\n  }\n}\n\n/*\n** Set the most recent error code and error string for the sqlite\n** handle \"db\". The error code is set to \"err_code\".\n**\n** If it is not NULL, string zFormat specifies the format of the\n** error string in the style of the printf functions: The following\n** format characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** zFormat and any string tokens that follow it are assumed to be\n** encoded in UTF-8.\n**\n** To clear the most recent error for sqlite handle \"db\", sqlite3Error\n** should be called with err_code set to SQLITE_OK and zFormat set\n** to NULL.\n*/\nSQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *zFormat, ...){\n  assert( db!=0 );\n  db->errCode = err_code;\n  sqlite3SystemError(db, err_code);\n  if( zFormat==0 ){\n    sqlite3Error(db, err_code);\n  }else if( db->pErr || (db->pErr = sqlite3ValueNew(db))!=0 ){\n    char *z;\n    va_list ap;\n    va_start(ap, zFormat);\n    z = sqlite3VMPrintf(db, zFormat, ap);\n    va_end(ap);\n    sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Add an error message to pParse->zErrMsg and increment pParse->nErr.\n** The following formatting characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** This function should be used to report any error that occurs while\n** compiling an SQL statement (i.e. within sqlite3_prepare()). The\n** last thing the sqlite3_prepare() function does is copy the error\n** stored by this function into the database handle using sqlite3Error().\n** Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used\n** during statement execution (sqlite3_step() etc.).\n*/\nSQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){\n  char *zMsg;\n  va_list ap;\n  sqlite3 *db = pParse->db;\n  va_start(ap, zFormat);\n  zMsg = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( db->suppressErr ){\n    sqlite3DbFree(db, zMsg);\n  }else{\n    pParse->nErr++;\n    sqlite3DbFree(db, pParse->zErrMsg);\n    pParse->zErrMsg = zMsg;\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** The input string must be zero-terminated.  A new zero-terminator\n** is added to the dequoted string.\n**\n** The return value is -1 if no dequoting occurs or the length of the\n** dequoted string, exclusive of the zero terminator, if dequoting does\n** occur.\n**\n** 2002-Feb-14: This routine is extended to remove MS-Access style\n** brackets from around identifiers.  For example:  \"[a-b-c]\" becomes\n** \"a-b-c\".\n*/\nSQLITE_PRIVATE void sqlite3Dequote(char *z){\n  char quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  if( !sqlite3Isquote(quote) ) return;\n  if( quote=='[' ) quote = ']';\n  for(i=1, j=0;; i++){\n    assert( z[i] );\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n  z[j] = 0;\n}\n\n/*\n** Generate a Token object from a string\n*/\nSQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){\n  p->z = z;\n  p->n = sqlite3Strlen30(z);\n}\n\n/* Convenient short-hand */\n#define UpperToLower sqlite3UpperToLower\n\n/*\n** Some systems have stricmp().  Others have strcasecmp().  Because\n** there is no consistency, we will define our own.\n**\n** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and\n** sqlite3_strnicmp() APIs allow applications and extensions to compare\n** the contents of two buffers containing UTF-8 strings in a\n** case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  return sqlite3StrICmp(zLeft, zRight);\n}\nSQLITE_PRIVATE int sqlite3StrICmp(const char *zLeft, const char *zRight){\n  unsigned char *a, *b;\n  int c;\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  for(;;){\n    c = (int)UpperToLower[*a] - (int)UpperToLower[*b];\n    if( c || *a==0 ) break;\n    a++;\n    b++;\n  }\n  return c;\n}\nSQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){\n  register unsigned char *a, *b;\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }\n  return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];\n}\n\n/*\n** The string z[] is an text representation of a real number.\n** Convert this string to a double and write it into *pResult.\n**\n** The string z[] is length bytes in length (bytes, not characters) and\n** uses the encoding enc.  The string is not necessarily zero-terminated.\n**\n** Return TRUE if the result is a valid real number (or integer) and FALSE\n** if the string is empty or contains extraneous text.  Valid numbers\n** are in one of these formats:\n**\n**    [+-]digits[E[+-]digits]\n**    [+-]digits.[digits][E[+-]digits]\n**    [+-].digits[E[+-]digits]\n**\n** Leading and trailing whitespace is ignored for the purpose of determining\n** validity.\n**\n** If some prefix of the input string is a valid number, this routine\n** returns FALSE but it still converts the prefix and writes the result\n** into *pResult.\n*/\nSQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int incr;\n  const char *zEnd = z + length;\n  /* sign * significand * (10 ^ (esign * exponent)) */\n  int sign = 1;    /* sign of significand */\n  i64 s = 0;       /* significand */\n  int d = 0;       /* adjust exponent for shifting decimal point */\n  int esign = 1;   /* sign of exponent */\n  int e = 0;       /* exponent */\n  int eValid = 1;  /* True exponent is either not used or is well-formed */\n  double result;\n  int nDigits = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  *pResult = 0.0;   /* Default return value, in case of an error */\n\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    int i;\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && z[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &z[i^1];\n    z += (enc&1);\n  }\n\n  /* skip leading spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n  if( z>=zEnd ) return 0;\n\n  /* get sign of significand */\n  if( *z=='-' ){\n    sign = -1;\n    z+=incr;\n  }else if( *z=='+' ){\n    z+=incr;\n  }\n\n  /* copy max significant digits to significand */\n  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n    s = s*10 + (*z - '0');\n    z+=incr, nDigits++;\n  }\n\n  /* skip non-significant significand digits\n  ** (increase exponent by d to shift decimal left) */\n  while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++;\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if decimal point is present */\n  if( *z=='.' ){\n    z+=incr;\n    /* copy digits from after decimal to significand\n    ** (decrease exponent by d to shift decimal right) */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      if( s<((LARGEST_INT64-9)/10) ){\n        s = s*10 + (*z - '0');\n        d--;\n      }\n      z+=incr, nDigits++;\n    }\n  }\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if exponent is present */\n  if( *z=='e' || *z=='E' ){\n    z+=incr;\n    eValid = 0;\n\n    /* This branch is needed to avoid a (harmless) buffer overread.  The \n    ** special comment alerts the mutation tester that the correct answer\n    ** is obtained even if the branch is omitted */\n    if( z>=zEnd ) goto do_atof_calc;              /*PREVENTS-HARMLESS-OVERREAD*/\n\n    /* get sign of exponent */\n    if( *z=='-' ){\n      esign = -1;\n      z+=incr;\n    }else if( *z=='+' ){\n      z+=incr;\n    }\n    /* copy digits to exponent */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      e = e<10000 ? (e*10 + (*z - '0')) : 10000;\n      z+=incr;\n      eValid = 1;\n    }\n  }\n\n  /* skip trailing spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n\ndo_atof_calc:\n  /* adjust exponent by d, and update sign */\n  e = (e*esign) + d;\n  if( e<0 ) {\n    esign = -1;\n    e *= -1;\n  } else {\n    esign = 1;\n  }\n\n  if( s==0 ) {\n    /* In the IEEE 754 standard, zero is signed. */\n    result = sign<0 ? -(double)0 : (double)0;\n  } else {\n    /* Attempt to reduce exponent.\n    **\n    ** Branches that are not required for the correct answer but which only\n    ** help to obtain the correct answer faster are marked with special\n    ** comments, as a hint to the mutation tester.\n    */\n    while( e>0 ){                                       /*OPTIMIZATION-IF-TRUE*/\n      if( esign>0 ){\n        if( s>=(LARGEST_INT64/10) ) break;             /*OPTIMIZATION-IF-FALSE*/\n        s *= 10;\n      }else{\n        if( s%10!=0 ) break;                           /*OPTIMIZATION-IF-FALSE*/\n        s /= 10;\n      }\n      e--;\n    }\n\n    /* adjust the sign of significand */\n    s = sign<0 ? -s : s;\n\n    if( e==0 ){                                         /*OPTIMIZATION-IF-TRUE*/\n      result = (double)s;\n    }else{\n      LONGDOUBLE_TYPE scale = 1.0;\n      /* attempt to handle extremely small/large numbers better */\n      if( e>307 ){                                      /*OPTIMIZATION-IF-TRUE*/\n        if( e<342 ){                                    /*OPTIMIZATION-IF-TRUE*/\n          while( e%308 ) { scale *= 1.0e+1; e -= 1; }\n          if( esign<0 ){\n            result = s / scale;\n            result /= 1.0e+308;\n          }else{\n            result = s * scale;\n            result *= 1.0e+308;\n          }\n        }else{ assert( e>=342 );\n          if( esign<0 ){\n            result = 0.0*s;\n          }else{\n#ifdef INFINITY\n            result = INFINITY*s;\n#else\n            result = 1e308*1e308*s;  /* Infinity */\n#endif\n          }\n        }\n      }else{\n        /* 1.0e+22 is the largest power of 10 than can be \n        ** represented exactly. */\n        while( e%22 ) { scale *= 1.0e+1; e -= 1; }\n        while( e>0 ) { scale *= 1.0e+22; e -= 22; }\n        if( esign<0 ){\n          result = s / scale;\n        }else{\n          result = s * scale;\n        }\n      }\n    }\n  }\n\n  /* store the result */\n  *pResult = result;\n\n  /* return true if number and no extra non-whitespace chracters after */\n  return z==zEnd && nDigits>0 && eValid && nonNum==0;\n#else\n  return !sqlite3Atoi64(z, pResult, length, enc);\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n}\n\n/*\n** Compare the 19-character string zNum against the text representation\n** value 2^63:  9223372036854775808.  Return negative, zero, or positive\n** if zNum is less than, equal to, or greater than the string.\n** Note that zNum must contain exactly 19 characters.\n**\n** Unlike memcmp() this routine is guaranteed to return the difference\n** in the values of the last digit if the only difference is in the\n** last digit.  So, for example,\n**\n**      compare2pow63(\"9223372036854775800\", 1)\n**\n** will return -8.\n*/\nstatic int compare2pow63(const char *zNum, int incr){\n  int c = 0;\n  int i;\n                    /* 012345678901234567 */\n  const char *pow63 = \"922337203685477580\";\n  for(i=0; c==0 && i<18; i++){\n    c = (zNum[i*incr]-pow63[i])*10;\n  }\n  if( c==0 ){\n    c = zNum[18*incr] - '8';\n    testcase( c==(-1) );\n    testcase( c==0 );\n    testcase( c==(+1) );\n  }\n  return c;\n}\n\n/*\n** Convert zNum to a 64-bit signed integer.  zNum must be decimal. This\n** routine does *not* accept hexadecimal notation.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n**\n** length is the number of bytes in the string (bytes, not characters).\n** The string is not necessarily zero-terminated.  The encoding is\n** given by enc.\n*/\nSQLITE_PRIVATE int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){\n  int incr;\n  u64 u = 0;\n  int neg = 0; /* assume positive */\n  int i;\n  int c = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n  int rc;          /* Baseline return code */\n  const char *zStart;\n  const char *zEnd = zNum + length;\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && zNum[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &zNum[i^1];\n    zNum += (enc&1);\n  }\n  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;\n  if( zNum<zEnd ){\n    if( *zNum=='-' ){\n      neg = 1;\n      zNum+=incr;\n    }else if( *zNum=='+' ){\n      zNum+=incr;\n    }\n  }\n  zStart = zNum;\n  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */\n  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){\n    u = u*10 + c - '0';\n  }\n  if( u>LARGEST_INT64 ){\n    *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;\n  }else if( neg ){\n    *pNum = -(i64)u;\n  }else{\n    *pNum = (i64)u;\n  }\n  testcase( i==18 );\n  testcase( i==19 );\n  testcase( i==20 );\n  if( &zNum[i]<zEnd              /* Extra bytes at the end */\n   || (i==0 && zStart==zNum)     /* No digits */\n   || nonNum                     /* UTF16 with high-order bytes non-zero */\n  ){\n    rc = 1;\n  }else{\n    rc = 0;\n  }\n  if( i>19*incr ){                /* Too many digits */\n    /* zNum is empty or contains non-numeric text or is longer\n    ** than 19 digits (thus guaranteeing that it is too large) */\n    return 2;\n  }else if( i<19*incr ){\n    /* Less than 19 digits, so we know that it fits in 64 bits */\n    assert( u<=LARGEST_INT64 );\n    return rc;\n  }else{\n    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */\n    c = compare2pow63(zNum, incr);\n    if( c<0 ){\n      /* zNum is less than 9223372036854775808 so it fits */\n      assert( u<=LARGEST_INT64 );\n      return rc;\n    }else if( c>0 ){\n      /* zNum is greater than 9223372036854775808 so it overflows */\n      return 2;\n    }else{\n      /* zNum is exactly 9223372036854775808.  Fits if negative.  The\n      ** special case 2 overflow if positive */\n      assert( u-1==LARGEST_INT64 );\n      return neg ? rc : 3;\n    }\n  }\n}\n\n/*\n** Transform a UTF-8 integer literal, in either decimal or hexadecimal,\n** into a 64-bit signed integer.  This routine accepts hexadecimal literals,\n** whereas sqlite3Atoi64() does not.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n*/\nSQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  if( z[0]=='0'\n   && (z[1]=='x' || z[1]=='X')\n  ){\n    u64 u = 0;\n    int i, k;\n    for(i=2; z[i]=='0'; i++){}\n    for(k=i; sqlite3Isxdigit(z[k]); k++){\n      u = u*16 + sqlite3HexToInt(z[k]);\n    }\n    memcpy(pOut, &u, 8);\n    return (z[k]==0 && k-i<=16) ? 0 : 2;\n  }else\n#endif /* SQLITE_OMIT_HEX_INTEGER */\n  {\n    return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8);\n  }\n}\n\n/*\n** If zNum represents an integer that will fit in 32-bits, then set\n** *pValue to that integer and return true.  Otherwise return false.\n**\n** This routine accepts both decimal and hexadecimal notation for integers.\n**\n** Any non-numeric characters that following zNum are ignored.\n** This is different from sqlite3Atoi64() which requires the\n** input number to be zero-terminated.\n*/\nSQLITE_PRIVATE int sqlite3GetInt32(const char *zNum, int *pValue){\n  sqlite_int64 v = 0;\n  int i, c;\n  int neg = 0;\n  if( zNum[0]=='-' ){\n    neg = 1;\n    zNum++;\n  }else if( zNum[0]=='+' ){\n    zNum++;\n  }\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  else if( zNum[0]=='0'\n        && (zNum[1]=='x' || zNum[1]=='X')\n        && sqlite3Isxdigit(zNum[2])\n  ){\n    u32 u = 0;\n    zNum += 2;\n    while( zNum[0]=='0' ) zNum++;\n    for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){\n      u = u*16 + sqlite3HexToInt(zNum[i]);\n    }\n    if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){\n      memcpy(pValue, &u, 4);\n      return 1;\n    }else{\n      return 0;\n    }\n  }\n#endif\n  if( !sqlite3Isdigit(zNum[0]) ) return 0;\n  while( zNum[0]=='0' ) zNum++;\n  for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){\n    v = v*10 + c;\n  }\n\n  /* The longest decimal representation of a 32 bit integer is 10 digits:\n  **\n  **             1234567890\n  **     2^31 -> 2147483648\n  */\n  testcase( i==10 );\n  if( i>10 ){\n    return 0;\n  }\n  testcase( v-neg==2147483647 );\n  if( v-neg>2147483647 ){\n    return 0;\n  }\n  if( neg ){\n    v = -v;\n  }\n  *pValue = (int)v;\n  return 1;\n}\n\n/*\n** Return a 32-bit integer value extracted from a string.  If the\n** string is not an integer, just return 0.\n*/\nSQLITE_PRIVATE int sqlite3Atoi(const char *z){\n  int x = 0;\n  if( z ) sqlite3GetInt32(z, &x);\n  return x;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int SQLITE_NOINLINE putVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\nSQLITE_PRIVATE int sqlite3PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return putVarint64(p,v);\n}\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above\n    ** while calculating s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** Read a 32-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n**\n** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned\n** integer, then set *v to 0xffffffff.\n**\n** A MACRO version, getVarint32, is provided which inlines the \n** single-byte case.  All code should use the MACRO version as \n** this function assumes the single-byte case has already been handled.\n*/\nSQLITE_PRIVATE u8 sqlite3GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case.  Overwhelmingly the most common.  Handled inline\n  ** by the getVarin32() macro */\n  a = *p;\n  /* a: p0 (unmasked) */\n#ifndef getVarint32\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n#endif\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n#if 1\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 2;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>3 && n<=9 );\n    if( (v64 & SQLITE_MAX_U32)!=v64 ){\n      *v = 0xffffffff;\n    }else{\n      *v = (u32)v64;\n    }\n    return n;\n  }\n\n#else\n  /* For following code (kept for historical record only) shows an\n  ** unrolling for the 3- and 4-byte varint cases.  This code is\n  ** slightly faster, but it is also larger and much harder to test.\n  */\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 2097152 and 268435455 */\n    b &= (0x7f<<14)|(0x7f);\n    a &= (0x7f<<14)|(0x7f);\n    a = a<<7;\n    *v = a | b;\n    return 4;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values  between 268435456 and 34359738367 */\n    a &= SLOT_4_2_0;\n    b &= SLOT_4_2_0;\n    b = b<<7;\n    *v = a | b;\n    return 5;\n  }\n\n  /* We can only reach this point when reading a corrupt database\n  ** file.  In that case we are not in any hurry.  Use the (relatively\n  ** slow) general-purpose sqlite3GetVarint() routine to extract the\n  ** value. */\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 4;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>5 && n<=9 );\n    *v = (u32)v64;\n    return n;\n  }\n#endif\n}\n\n/*\n** Return the number of bytes that will be needed to store the given\n** 64-bit integer.\n*/\nSQLITE_PRIVATE int sqlite3VarintLen(u64 v){\n  int i;\n  for(i=1; (v >>= 7)!=0; i++){ assert( i<10 ); }\n  return i;\n}\n\n\n/*\n** Read or write a four-byte big-endian integer value.\n*/\nSQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){\n#if SQLITE_BYTEORDER==4321\n  u32 x;\n  memcpy(&x,p,4);\n  return x;\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x;\n  memcpy(&x,p,4);\n  return __builtin_bswap32(x);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x;\n  memcpy(&x,p,4);\n  return _byteswap_ulong(x);\n#else\n  testcase( p[0]&0x80 );\n  return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];\n#endif\n}\nSQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){\n#if SQLITE_BYTEORDER==4321\n  memcpy(p,&v,4);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x = __builtin_bswap32(v);\n  memcpy(p,&x,4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x = _byteswap_ulong(v);\n  memcpy(p,&x,4);\n#else\n  p[0] = (u8)(v>>24);\n  p[1] = (u8)(v>>16);\n  p[2] = (u8)(v>>8);\n  p[3] = (u8)v;\n#endif\n}\n\n\n\n/*\n** Translate a single byte of Hex into an integer.\n** This routine only works if h really is a valid hexadecimal\n** character:  0..9a..fA..F\n*/\nSQLITE_PRIVATE u8 sqlite3HexToInt(int h){\n  assert( (h>='0' && h<='9') ||  (h>='a' && h<='f') ||  (h>='A' && h<='F') );\n#ifdef SQLITE_ASCII\n  h += 9*(1&(h>>6));\n#endif\n#ifdef SQLITE_EBCDIC\n  h += 9*(1&~(h>>4));\n#endif\n  return (u8)(h & 0xf);\n}\n\n#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)\n/*\n** Convert a BLOB literal of the form \"x'hhhhhh'\" into its binary\n** value.  Return a pointer to its binary value.  Space to hold the\n** binary value has been obtained from malloc and must be freed by\n** the calling routine.\n*/\nSQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){\n  char *zBlob;\n  int i;\n\n  zBlob = (char *)sqlite3DbMallocRawNN(db, n/2 + 1);\n  n--;\n  if( zBlob ){\n    for(i=0; i<n; i+=2){\n      zBlob[i/2] = (sqlite3HexToInt(z[i])<<4) | sqlite3HexToInt(z[i+1]);\n    }\n    zBlob[i/2] = 0;\n  }\n  return zBlob;\n}\n#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */\n\n/*\n** Log an error that is an API call on a connection pointer that should\n** not have been used.  The \"type\" of connection pointer is given as the\n** argument.  The zType is a word like \"NULL\" or \"closed\" or \"invalid\".\n*/\nstatic void logBadConnection(const char *zType){\n  sqlite3_log(SQLITE_MISUSE, \n     \"API call with %s database connection pointer\",\n     zType\n  );\n}\n\n/*\n** Check to make sure we have a valid db pointer.  This test is not\n** foolproof but it does provide some measure of protection against\n** misuse of the interface such as passing in db pointers that are\n** NULL or which have been previously closed.  If this routine returns\n** 1 it means that the db pointer is valid and 0 if it should not be\n** dereferenced for any reason.  The calling function should invoke\n** SQLITE_MISUSE immediately.\n**\n** sqlite3SafetyCheckOk() requires that the db pointer be valid for\n** use.  sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to\n** open properly and is not fit for general use but which can be\n** used as an argument to sqlite3_errmsg() or sqlite3_close().\n*/\nSQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){\n  u32 magic;\n  if( db==0 ){\n    logBadConnection(\"NULL\");\n    return 0;\n  }\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_OPEN ){\n    if( sqlite3SafetyCheckSickOrOk(db) ){\n      testcase( sqlite3GlobalConfig.xLog!=0 );\n      logBadConnection(\"unopened\");\n    }\n    return 0;\n  }else{\n    return 1;\n  }\n}\nSQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){\n  u32 magic;\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_SICK &&\n      magic!=SQLITE_MAGIC_OPEN &&\n      magic!=SQLITE_MAGIC_BUSY ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    logBadConnection(\"invalid\");\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Attempt to add, substract, or multiply the 64-bit signed value iB against\n** the other 64-bit signed integer at *pA and store the result in *pA.\n** Return 0 on success.  Or if the operation would have resulted in an\n** overflow, leave *pA unchanged and return 1.\n*/\nSQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_add_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  testcase( iA==0 ); testcase( iA==1 );\n  testcase( iB==-1 ); testcase( iB==0 );\n  if( iB>=0 ){\n    testcase( iA>0 && LARGEST_INT64 - iA == iB );\n    testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 );\n    if( iA>0 && LARGEST_INT64 - iA < iB ) return 1;\n  }else{\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 );\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 );\n    if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1;\n  }\n  *pA += iB;\n  return 0; \n#endif\n}\nSQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_sub_overflow(*pA, iB, pA);\n#else\n  testcase( iB==SMALLEST_INT64+1 );\n  if( iB==SMALLEST_INT64 ){\n    testcase( (*pA)==(-1) ); testcase( (*pA)==0 );\n    if( (*pA)>=0 ) return 1;\n    *pA -= iB;\n    return 0;\n  }else{\n    return sqlite3AddInt64(pA, -iB);\n  }\n#endif\n}\nSQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_mul_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  if( iB>0 ){\n    if( iA>LARGEST_INT64/iB ) return 1;\n    if( iA<SMALLEST_INT64/iB ) return 1;\n  }else if( iB<0 ){\n    if( iA>0 ){\n      if( iB<SMALLEST_INT64/iA ) return 1;\n    }else if( iA<0 ){\n      if( iB==SMALLEST_INT64 ) return 1;\n      if( iA==SMALLEST_INT64 ) return 1;\n      if( -iA>LARGEST_INT64/-iB ) return 1;\n    }\n  }\n  *pA = iA*iB;\n  return 0;\n#endif\n}\n\n/*\n** Compute the absolute value of a 32-bit signed integer, of possible.  Or \n** if the integer has a value of -2147483648, return +2147483647\n*/\nSQLITE_PRIVATE int sqlite3AbsInt32(int x){\n  if( x>=0 ) return x;\n  if( x==(int)0x80000000 ) return 0x7fffffff;\n  return -x;\n}\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n/*\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nSQLITE_PRIVATE void sqlite3FileSuffix3(const char *zBaseFilename, char *z){\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBaseFilename, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = sqlite3Strlen30(z);\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n}\n#endif\n\n/* \n** Find (an approximate) sum of two LogEst values.  This computation is\n** not a simple \"+\" operator because LogEst is stored as a logarithmic\n** value.\n** \n*/\nSQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst a, LogEst b){\n  static const unsigned char x[] = {\n     10, 10,                         /* 0,1 */\n      9, 9,                          /* 2,3 */\n      8, 8,                          /* 4,5 */\n      7, 7, 7,                       /* 6,7,8 */\n      6, 6, 6,                       /* 9,10,11 */\n      5, 5, 5,                       /* 12-14 */\n      4, 4, 4, 4,                    /* 15-18 */\n      3, 3, 3, 3, 3, 3,              /* 19-24 */\n      2, 2, 2, 2, 2, 2, 2,           /* 25-31 */\n  };\n  if( a>=b ){\n    if( a>b+49 ) return a;\n    if( a>b+31 ) return a+1;\n    return a+x[a-b];\n  }else{\n    if( b>a+49 ) return b;\n    if( b>a+31 ) return b+1;\n    return b+x[b-a];\n  }\n}\n\n/*\n** Convert an integer into a LogEst.  In other words, compute an\n** approximation for 10*log2(x).\n*/\nSQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){\n  static LogEst a[] = { 0, 2, 3, 5, 6, 7, 8, 9 };\n  LogEst y = 40;\n  if( x<8 ){\n    if( x<2 ) return 0;\n    while( x<8 ){  y -= 10; x <<= 1; }\n  }else{\n#if GCC_VERSION>=5004000\n    int i = 60 - __builtin_clzll(x);\n    y += i*10;\n    x >>= i;\n#else\n    while( x>255 ){ y += 40; x >>= 4; }  /*OPTIMIZATION-IF-TRUE*/\n    while( x>15 ){  y += 10; x >>= 1; }\n#endif\n  }\n  return a[x&7] + y - 10;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Convert a double into a LogEst\n** In other words, compute an approximation for 10*log2(x).\n*/\nSQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){\n  u64 a;\n  LogEst e;\n  assert( sizeof(x)==8 && sizeof(a)==8 );\n  if( x<=1 ) return 0;\n  if( x<=2000000000 ) return sqlite3LogEst((u64)x);\n  memcpy(&a, &x, 8);\n  e = (a>>52) - 1022;\n  return e*10;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n/*\n** Convert a LogEst into an integer.\n**\n** Note that this routine is only used when one or more of various\n** non-standard compile-time options is enabled.\n*/\nSQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){\n  u64 n;\n  n = x%10;\n  x /= 10;\n  if( n>=5 ) n -= 2;\n  else if( n>=1 ) n -= 1;\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n  if( x>60 ) return (u64)LARGEST_INT64;\n#else\n  /* If only SQLITE_ENABLE_STAT3_OR_STAT4 is on, then the largest input\n  ** possible to this routine is 310, resulting in a maximum x of 31 */\n  assert( x<=60 );\n#endif\n  return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);\n}\n#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */\n\n/*\n** Add a new name/number pair to a VList.  This might require that the\n** VList object be reallocated, so return the new VList.  If an OOM\n** error occurs, the original VList returned and the\n** db->mallocFailed flag is set.\n**\n** A VList is really just an array of integers.  To destroy a VList,\n** simply pass it to sqlite3DbFree().\n**\n** The first integer is the number of integers allocated for the whole\n** VList.  The second integer is the number of integers actually used.\n** Each name/number pair is encoded by subsequent groups of 3 or more\n** integers.\n**\n** Each name/number pair starts with two integers which are the numeric\n** value for the pair and the size of the name/number pair, respectively.\n** The text name overlays one or more following integers.  The text name\n** is always zero-terminated.\n**\n** Conceptually:\n**\n**    struct VList {\n**      int nAlloc;   // Number of allocated slots \n**      int nUsed;    // Number of used slots \n**      struct VListEntry {\n**        int iValue;    // Value for this entry\n**        int nSlot;     // Slots used by this entry\n**        // ... variable name goes here\n**      } a[0];\n**    }\n**\n** During code generation, pointers to the variable names within the\n** VList are taken.  When that happens, nAlloc is set to zero as an \n** indication that the VList may never again be enlarged, since the\n** accompanying realloc() would invalidate the pointers.\n*/\nSQLITE_PRIVATE VList *sqlite3VListAdd(\n  sqlite3 *db,           /* The database connection used for malloc() */\n  VList *pIn,            /* The input VList.  Might be NULL */\n  const char *zName,     /* Name of symbol to add */\n  int nName,             /* Bytes of text in zName */\n  int iVal               /* Value to associate with zName */\n){\n  int nInt;              /* number of sizeof(int) objects needed for zName */\n  char *z;               /* Pointer to where zName will be stored */\n  int i;                 /* Index in pIn[] where zName is stored */\n\n  nInt = nName/4 + 3;\n  assert( pIn==0 || pIn[0]>=3 );  /* Verify ok to add new elements */\n  if( pIn==0 || pIn[1]+nInt > pIn[0] ){\n    /* Enlarge the allocation */\n    int nAlloc = (pIn ? pIn[0]*2 : 10) + nInt;\n    VList *pOut = sqlite3DbRealloc(db, pIn, nAlloc*sizeof(int));\n    if( pOut==0 ) return pIn;\n    if( pIn==0 ) pOut[1] = 2;\n    pIn = pOut;\n    pIn[0] = nAlloc;\n  }\n  i = pIn[1];\n  pIn[i] = iVal;\n  pIn[i+1] = nInt;\n  z = (char*)&pIn[i+2];\n  pIn[1] = i+nInt;\n  assert( pIn[1]<=pIn[0] );\n  memcpy(z, zName, nName);\n  z[nName] = 0;\n  return pIn;\n}\n\n/*\n** Return a pointer to the name of a variable in the given VList that\n** has the value iVal.  Or return a NULL if there is no such variable in\n** the list\n*/\nSQLITE_PRIVATE const char *sqlite3VListNumToName(VList *pIn, int iVal){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    if( pIn[i]==iVal ) return (char*)&pIn[i+2];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n\n/*\n** Return the number of the variable named zName, if it is in VList.\n** or return 0 if there is no such variable.\n*/\nSQLITE_PRIVATE int sqlite3VListNameToNum(VList *pIn, const char *zName, int nName){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    const char *z = (const char*)&pIn[i+2];\n    if( strncmp(z,zName,nName)==0 && z[nName]==0 ) return pIn[i];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n\n/************** End of util.c ************************************************/\n/************** Begin file hash.c ********************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables\n** used in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <assert.h> */\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n*/\nSQLITE_PRIVATE void sqlite3HashInit(Hash *pNew){\n  assert( pNew!=0 );\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3HashClear(Hash *pH){\n  HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  sqlite3_free(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    HashElem *next_elem = elem->next;\n    sqlite3_free(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** The hashing function.\n*/\nstatic unsigned int strHash(const char *z){\n  unsigned int h = 0;\n  unsigned char c;\n  while( (c = (unsigned char)*z++)!=0 ){     /*OPTIMIZATION-IF-TRUE*/\n    /* Knuth multiplicative hashing.  (Sorting & Searching, p. 510).\n    ** 0x9e3779b1 is 2654435761 which is the closest prime number to\n    ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */\n    h += sqlite3UpperToLower[c];\n    h *= 0x9e3779b1;\n  }\n  return h;\n}\n\n\n/* Link pNew element into the hash table pH.  If pEntry!=0 then also\n** insert pNew into the pEntry hash bucket.\n*/\nstatic void insertElement(\n  Hash *pH,              /* The complete hash table */\n  struct _ht *pEntry,    /* The entry into which pNew is inserted */\n  HashElem *pNew         /* The element to be inserted */\n){\n  HashElem *pHead;       /* First element already in pEntry */\n  if( pEntry ){\n    pHead = pEntry->count ? pEntry->chain : 0;\n    pEntry->count++;\n    pEntry->chain = pNew;\n  }else{\n    pHead = 0;\n  }\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n**\n** The hash table might fail to resize if sqlite3_malloc() fails or\n** if the new size is the same as the prior size.\n** Return TRUE if the resize occurs and false if not.\n*/\nstatic int rehash(Hash *pH, unsigned int new_size){\n  struct _ht *new_ht;            /* The new hash table */\n  HashElem *elem, *next_elem;    /* For looping over existing elements */\n\n#if SQLITE_MALLOC_SOFT_LIMIT>0\n  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){\n    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);\n  }\n  if( new_size==pH->htsize ) return 0;\n#endif\n\n  /* The inability to allocates space for a larger hash table is\n  ** a performance hit but it is not a fatal error.  So mark the\n  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of \n  ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()\n  ** only zeroes the requested number of bytes whereas this module will\n  ** use the actual amount of space allocated for the hash table (which\n  ** may be larger than the requested amount).\n  */\n  sqlite3BeginBenignMalloc();\n  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );\n  sqlite3EndBenignMalloc();\n\n  if( new_ht==0 ) return 0;\n  sqlite3_free(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);\n  memset(new_ht, 0, new_size*sizeof(struct _ht));\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    unsigned int h = strHash(elem->pKey) % new_size;\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n  return 1;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  If no element is found,\n** a pointer to a static null element with HashElem.data==0 is returned.\n** If pH is not NULL, then the hash for this key is written to *pH.\n*/\nstatic HashElem *findElementWithHash(\n  const Hash *pH,     /* The pH to be searched */\n  const char *pKey,   /* The key we are searching for */\n  unsigned int *pHash /* Write the hash value here */\n){\n  HashElem *elem;                /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  unsigned int h;                /* The computed hash */\n  static HashElem nullElement = { 0, 0, 0, 0 };\n\n  if( pH->ht ){   /*OPTIMIZATION-IF-TRUE*/\n    struct _ht *pEntry;\n    h = strHash(pKey) % pH->htsize;\n    pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n  }else{\n    h = 0;\n    elem = pH->first;\n    count = pH->count;\n  }\n  if( pHash ) *pHash = h;\n  while( count-- ){\n    assert( elem!=0 );\n    if( sqlite3StrICmp(elem->pKey,pKey)==0 ){ \n      return elem;\n    }\n    elem = elem->next;\n  }\n  return &nullElement;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  Hash *pH,         /* The pH containing \"elem\" */\n  HashElem* elem,   /* The element to be removed from the pH */\n  unsigned int h    /* Hash value for the element */\n){\n  struct _ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  if( pH->ht ){\n    pEntry = &pH->ht[h];\n    if( pEntry->chain==elem ){\n      pEntry->chain = elem->next;\n    }\n    pEntry->count--;\n    assert( pEntry->count>=0 );\n  }\n  sqlite3_free( elem );\n  pH->count--;\n  if( pH->count==0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    sqlite3HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  return findElementWithHash(pH, pKey, 0)->data;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created and NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3HashInsert(Hash *pH, const char *pKey, void *data){\n  unsigned int h;       /* the hash of the key modulo hash table size */\n  HashElem *elem;       /* Used to loop thru the element list */\n  HashElem *new_elem;   /* New element added to the pH */\n\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  elem = findElementWithHash(pH,pKey,&h);\n  if( elem->data ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n      elem->pKey = pKey;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );\n  if( new_elem==0 ) return data;\n  new_elem->pKey = pKey;\n  new_elem->data = data;\n  pH->count++;\n  if( pH->count>=10 && pH->count > 2*pH->htsize ){\n    if( rehash(pH, pH->count*2) ){\n      assert( pH->htsize>0 );\n      h = strHash(pKey) % pH->htsize;\n    }\n  }\n  insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem);\n  return 0;\n}\n\n/************** End of hash.c ************************************************/\n/************** Begin file opcodes.c *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the tool/mkopcodec.tcl script for details. */\n#if !defined(SQLITE_OMIT_EXPLAIN) \\\n || defined(VDBE_PROFILE) \\\n || defined(SQLITE_DEBUG)\n#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)\n# define OpHelp(X) \"\\0\" X\n#else\n# define OpHelp(X)\n#endif\nSQLITE_PRIVATE const char *sqlite3OpcodeName(int i){\n static const char *const azName[] = {\n    /*   0 */ \"Savepoint\"        OpHelp(\"\"),\n    /*   1 */ \"AutoCommit\"       OpHelp(\"\"),\n    /*   2 */ \"Transaction\"      OpHelp(\"\"),\n    /*   3 */ \"SorterNext\"       OpHelp(\"\"),\n    /*   4 */ \"PrevIfOpen\"       OpHelp(\"\"),\n    /*   5 */ \"NextIfOpen\"       OpHelp(\"\"),\n    /*   6 */ \"Prev\"             OpHelp(\"\"),\n    /*   7 */ \"Next\"             OpHelp(\"\"),\n    /*   8 */ \"Checkpoint\"       OpHelp(\"\"),\n    /*   9 */ \"JournalMode\"      OpHelp(\"\"),\n    /*  10 */ \"Vacuum\"           OpHelp(\"\"),\n    /*  11 */ \"VFilter\"          OpHelp(\"iplan=r[P3] zplan='P4'\"),\n    /*  12 */ \"VUpdate\"          OpHelp(\"data=r[P3@P2]\"),\n    /*  13 */ \"Goto\"             OpHelp(\"\"),\n    /*  14 */ \"Gosub\"            OpHelp(\"\"),\n    /*  15 */ \"InitCoroutine\"    OpHelp(\"\"),\n    /*  16 */ \"Yield\"            OpHelp(\"\"),\n    /*  17 */ \"MustBeInt\"        OpHelp(\"\"),\n    /*  18 */ \"Jump\"             OpHelp(\"\"),\n    /*  19 */ \"Not\"              OpHelp(\"r[P2]= !r[P1]\"),\n    /*  20 */ \"Once\"             OpHelp(\"\"),\n    /*  21 */ \"If\"               OpHelp(\"\"),\n    /*  22 */ \"IfNot\"            OpHelp(\"\"),\n    /*  23 */ \"IfNullRow\"        OpHelp(\"if P1.nullRow then r[P3]=NULL, goto P2\"),\n    /*  24 */ \"SeekLT\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  25 */ \"SeekLE\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  26 */ \"SeekGE\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  27 */ \"SeekGT\"           OpHelp(\"key=r[P3@P4]\"),\n    /*  28 */ \"NoConflict\"       OpHelp(\"key=r[P3@P4]\"),\n    /*  29 */ \"NotFound\"         OpHelp(\"key=r[P3@P4]\"),\n    /*  30 */ \"Found\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  31 */ \"SeekRowid\"        OpHelp(\"intkey=r[P3]\"),\n    /*  32 */ \"NotExists\"        OpHelp(\"intkey=r[P3]\"),\n    /*  33 */ \"Last\"             OpHelp(\"\"),\n    /*  34 */ \"IfSmaller\"        OpHelp(\"\"),\n    /*  35 */ \"SorterSort\"       OpHelp(\"\"),\n    /*  36 */ \"Sort\"             OpHelp(\"\"),\n    /*  37 */ \"Rewind\"           OpHelp(\"\"),\n    /*  38 */ \"IdxLE\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  39 */ \"IdxGT\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  40 */ \"IdxLT\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  41 */ \"IdxGE\"            OpHelp(\"key=r[P3@P4]\"),\n    /*  42 */ \"RowSetRead\"       OpHelp(\"r[P3]=rowset(P1)\"),\n    /*  43 */ \"Or\"               OpHelp(\"r[P3]=(r[P1] || r[P2])\"),\n    /*  44 */ \"And\"              OpHelp(\"r[P3]=(r[P1] && r[P2])\"),\n    /*  45 */ \"RowSetTest\"       OpHelp(\"if r[P3] in rowset(P1) goto P2\"),\n    /*  46 */ \"Program\"          OpHelp(\"\"),\n    /*  47 */ \"FkIfZero\"         OpHelp(\"if fkctr[P1]==0 goto P2\"),\n    /*  48 */ \"IfPos\"            OpHelp(\"if r[P1]>0 then r[P1]-=P3, goto P2\"),\n    /*  49 */ \"IfNotZero\"        OpHelp(\"if r[P1]!=0 then r[P1]--, goto P2\"),\n    /*  50 */ \"IsNull\"           OpHelp(\"if r[P1]==NULL goto P2\"),\n    /*  51 */ \"NotNull\"          OpHelp(\"if r[P1]!=NULL goto P2\"),\n    /*  52 */ \"Ne\"               OpHelp(\"IF r[P3]!=r[P1]\"),\n    /*  53 */ \"Eq\"               OpHelp(\"IF r[P3]==r[P1]\"),\n    /*  54 */ \"Gt\"               OpHelp(\"IF r[P3]>r[P1]\"),\n    /*  55 */ \"Le\"               OpHelp(\"IF r[P3]<=r[P1]\"),\n    /*  56 */ \"Lt\"               OpHelp(\"IF r[P3]<r[P1]\"),\n    /*  57 */ \"Ge\"               OpHelp(\"IF r[P3]>=r[P1]\"),\n    /*  58 */ \"ElseNotEq\"        OpHelp(\"\"),\n    /*  59 */ \"DecrJumpZero\"     OpHelp(\"if (--r[P1])==0 goto P2\"),\n    /*  60 */ \"IncrVacuum\"       OpHelp(\"\"),\n    /*  61 */ \"VNext\"            OpHelp(\"\"),\n    /*  62 */ \"Init\"             OpHelp(\"Start at P2\"),\n    /*  63 */ \"Return\"           OpHelp(\"\"),\n    /*  64 */ \"EndCoroutine\"     OpHelp(\"\"),\n    /*  65 */ \"HaltIfNull\"       OpHelp(\"if r[P3]=null halt\"),\n    /*  66 */ \"Halt\"             OpHelp(\"\"),\n    /*  67 */ \"Integer\"          OpHelp(\"r[P2]=P1\"),\n    /*  68 */ \"Int64\"            OpHelp(\"r[P2]=P4\"),\n    /*  69 */ \"String\"           OpHelp(\"r[P2]='P4' (len=P1)\"),\n    /*  70 */ \"Null\"             OpHelp(\"r[P2..P3]=NULL\"),\n    /*  71 */ \"SoftNull\"         OpHelp(\"r[P1]=NULL\"),\n    /*  72 */ \"Blob\"             OpHelp(\"r[P2]=P4 (len=P1)\"),\n    /*  73 */ \"Variable\"         OpHelp(\"r[P2]=parameter(P1,P4)\"),\n    /*  74 */ \"Move\"             OpHelp(\"r[P2@P3]=r[P1@P3]\"),\n    /*  75 */ \"Copy\"             OpHelp(\"r[P2@P3+1]=r[P1@P3+1]\"),\n    /*  76 */ \"SCopy\"            OpHelp(\"r[P2]=r[P1]\"),\n    /*  77 */ \"IntCopy\"          OpHelp(\"r[P2]=r[P1]\"),\n    /*  78 */ \"ResultRow\"        OpHelp(\"output=r[P1@P2]\"),\n    /*  79 */ \"CollSeq\"          OpHelp(\"\"),\n    /*  80 */ \"AddImm\"           OpHelp(\"r[P1]=r[P1]+P2\"),\n    /*  81 */ \"RealAffinity\"     OpHelp(\"\"),\n    /*  82 */ \"Cast\"             OpHelp(\"affinity(r[P1])\"),\n    /*  83 */ \"Permutation\"      OpHelp(\"\"),\n    /*  84 */ \"BitAnd\"           OpHelp(\"r[P3]=r[P1]&r[P2]\"),\n    /*  85 */ \"BitOr\"            OpHelp(\"r[P3]=r[P1]|r[P2]\"),\n    /*  86 */ \"ShiftLeft\"        OpHelp(\"r[P3]=r[P2]<<r[P1]\"),\n    /*  87 */ \"ShiftRight\"       OpHelp(\"r[P3]=r[P2]>>r[P1]\"),\n    /*  88 */ \"Add\"              OpHelp(\"r[P3]=r[P1]+r[P2]\"),\n    /*  89 */ \"Subtract\"         OpHelp(\"r[P3]=r[P2]-r[P1]\"),\n    /*  90 */ \"Multiply\"         OpHelp(\"r[P3]=r[P1]*r[P2]\"),\n    /*  91 */ \"Divide\"           OpHelp(\"r[P3]=r[P2]/r[P1]\"),\n    /*  92 */ \"Remainder\"        OpHelp(\"r[P3]=r[P2]%r[P1]\"),\n    /*  93 */ \"Concat\"           OpHelp(\"r[P3]=r[P2]+r[P1]\"),\n    /*  94 */ \"Compare\"          OpHelp(\"r[P1@P3] <-> r[P2@P3]\"),\n    /*  95 */ \"BitNot\"           OpHelp(\"r[P1]= ~r[P1]\"),\n    /*  96 */ \"Column\"           OpHelp(\"r[P3]=PX\"),\n    /*  97 */ \"String8\"          OpHelp(\"r[P2]='P4'\"),\n    /*  98 */ \"Affinity\"         OpHelp(\"affinity(r[P1@P2])\"),\n    /*  99 */ \"MakeRecord\"       OpHelp(\"r[P3]=mkrec(r[P1@P2])\"),\n    /* 100 */ \"Count\"            OpHelp(\"r[P2]=count()\"),\n    /* 101 */ \"ReadCookie\"       OpHelp(\"\"),\n    /* 102 */ \"SetCookie\"        OpHelp(\"\"),\n    /* 103 */ \"ReopenIdx\"        OpHelp(\"root=P2 iDb=P3\"),\n    /* 104 */ \"OpenRead\"         OpHelp(\"root=P2 iDb=P3\"),\n    /* 105 */ \"OpenWrite\"        OpHelp(\"root=P2 iDb=P3\"),\n    /* 106 */ \"OpenDup\"          OpHelp(\"\"),\n    /* 107 */ \"OpenAutoindex\"    OpHelp(\"nColumn=P2\"),\n    /* 108 */ \"OpenEphemeral\"    OpHelp(\"nColumn=P2\"),\n    /* 109 */ \"SorterOpen\"       OpHelp(\"\"),\n    /* 110 */ \"SequenceTest\"     OpHelp(\"if( cursor[P1].ctr++ ) pc = P2\"),\n    /* 111 */ \"OpenPseudo\"       OpHelp(\"P3 columns in r[P2]\"),\n    /* 112 */ \"Close\"            OpHelp(\"\"),\n    /* 113 */ \"ColumnsUsed\"      OpHelp(\"\"),\n    /* 114 */ \"Sequence\"         OpHelp(\"r[P2]=cursor[P1].ctr++\"),\n    /* 115 */ \"NewRowid\"         OpHelp(\"r[P2]=rowid\"),\n    /* 116 */ \"Insert\"           OpHelp(\"intkey=r[P3] data=r[P2]\"),\n    /* 117 */ \"InsertInt\"        OpHelp(\"intkey=P3 data=r[P2]\"),\n    /* 118 */ \"Delete\"           OpHelp(\"\"),\n    /* 119 */ \"ResetCount\"       OpHelp(\"\"),\n    /* 120 */ \"SorterCompare\"    OpHelp(\"if key(P1)!=trim(r[P3],P4) goto P2\"),\n    /* 121 */ \"SorterData\"       OpHelp(\"r[P2]=data\"),\n    /* 122 */ \"RowData\"          OpHelp(\"r[P2]=data\"),\n    /* 123 */ \"Rowid\"            OpHelp(\"r[P2]=rowid\"),\n    /* 124 */ \"NullRow\"          OpHelp(\"\"),\n    /* 125 */ \"SeekEnd\"          OpHelp(\"\"),\n    /* 126 */ \"SorterInsert\"     OpHelp(\"key=r[P2]\"),\n    /* 127 */ \"IdxInsert\"        OpHelp(\"key=r[P2]\"),\n    /* 128 */ \"IdxDelete\"        OpHelp(\"key=r[P2@P3]\"),\n    /* 129 */ \"DeferredSeek\"     OpHelp(\"Move P3 to P1.rowid if needed\"),\n    /* 130 */ \"IdxRowid\"         OpHelp(\"r[P2]=rowid\"),\n    /* 131 */ \"Destroy\"          OpHelp(\"\"),\n    /* 132 */ \"Real\"             OpHelp(\"r[P2]=P4\"),\n    /* 133 */ \"Clear\"            OpHelp(\"\"),\n    /* 134 */ \"ResetSorter\"      OpHelp(\"\"),\n    /* 135 */ \"CreateBtree\"      OpHelp(\"r[P2]=root iDb=P1 flags=P3\"),\n    /* 136 */ \"SqlExec\"          OpHelp(\"\"),\n    /* 137 */ \"ParseSchema\"      OpHelp(\"\"),\n    /* 138 */ \"LoadAnalysis\"     OpHelp(\"\"),\n    /* 139 */ \"DropTable\"        OpHelp(\"\"),\n    /* 140 */ \"DropIndex\"        OpHelp(\"\"),\n    /* 141 */ \"DropTrigger\"      OpHelp(\"\"),\n    /* 142 */ \"IntegrityCk\"      OpHelp(\"\"),\n    /* 143 */ \"RowSetAdd\"        OpHelp(\"rowset(P1)=r[P2]\"),\n    /* 144 */ \"Param\"            OpHelp(\"\"),\n    /* 145 */ \"FkCounter\"        OpHelp(\"fkctr[P1]+=P2\"),\n    /* 146 */ \"MemMax\"           OpHelp(\"r[P1]=max(r[P1],r[P2])\"),\n    /* 147 */ \"OffsetLimit\"      OpHelp(\"if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)\"),\n    /* 148 */ \"AggStep0\"         OpHelp(\"accum=r[P3] step(r[P2@P5])\"),\n    /* 149 */ \"AggStep\"          OpHelp(\"accum=r[P3] step(r[P2@P5])\"),\n    /* 150 */ \"AggFinal\"         OpHelp(\"accum=r[P1] N=P2\"),\n    /* 151 */ \"Expire\"           OpHelp(\"\"),\n    /* 152 */ \"TableLock\"        OpHelp(\"iDb=P1 root=P2 write=P3\"),\n    /* 153 */ \"VBegin\"           OpHelp(\"\"),\n    /* 154 */ \"VCreate\"          OpHelp(\"\"),\n    /* 155 */ \"VDestroy\"         OpHelp(\"\"),\n    /* 156 */ \"VOpen\"            OpHelp(\"\"),\n    /* 157 */ \"VColumn\"          OpHelp(\"r[P3]=vcolumn(P2)\"),\n    /* 158 */ \"VRename\"          OpHelp(\"\"),\n    /* 159 */ \"Pagecount\"        OpHelp(\"\"),\n    /* 160 */ \"MaxPgcnt\"         OpHelp(\"\"),\n    /* 161 */ \"PureFunc0\"        OpHelp(\"\"),\n    /* 162 */ \"Function0\"        OpHelp(\"r[P3]=func(r[P2@P5])\"),\n    /* 163 */ \"PureFunc\"         OpHelp(\"\"),\n    /* 164 */ \"Function\"         OpHelp(\"r[P3]=func(r[P2@P5])\"),\n    /* 165 */ \"CursorHint\"       OpHelp(\"\"),\n    /* 166 */ \"Noop\"             OpHelp(\"\"),\n    /* 167 */ \"Explain\"          OpHelp(\"\"),\n  };\n  return azName[i];\n}\n#endif\n\n/************** End of opcodes.c *********************************************/\n/************** Begin file os_unix.c *****************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the VFS implementation for unix-like operating systems\n** include Linux, MacOSX, *BSD, QNX, VxWorks, AIX, HPUX, and others.\n**\n** There are actually several different VFS implementations in this file.\n** The differences are in the way that file locking is done.  The default\n** implementation uses Posix Advisory Locks.  Alternative implementations\n** use flock(), dot-files, various proprietary locking schemas, or simply\n** skip locking all together.\n**\n** This source file is organized into divisions where the logic for various\n** subfunctions is contained within the appropriate division.  PLEASE\n** KEEP THE STRUCTURE OF THIS FILE INTACT.  New code should be placed\n** in the correct division and should be clearly labeled.\n**\n** The layout of divisions is as follows:\n**\n**   *  General-purpose declarations and utility functions.\n**   *  Unique file ID logic used by VxWorks.\n**   *  Various locking primitive implementations (all except proxy locking):\n**      + for Posix Advisory Locks\n**      + for no-op locks\n**      + for dot-file locks\n**      + for flock() locking\n**      + for named semaphore locks (VxWorks only)\n**      + for AFP filesystem locks (MacOSX only)\n**   *  sqlite3_file methods not associated with locking.\n**   *  Definitions of sqlite3_io_methods objects for all locking\n**      methods plus \"finder\" functions for each locking method.\n**   *  sqlite3_vfs method implementations.\n**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)\n**   *  Definitions of sqlite3_vfs objects for all locking methods\n**      plus implementations of sqlite3_os_init() and sqlite3_os_end().\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_UNIX              /* This file is used on unix only */\n\n/*\n** There are various methods for file locking used for concurrency\n** control:\n**\n**   1. POSIX locking (the default),\n**   2. No locking,\n**   3. Dot-file locking,\n**   4. flock() locking,\n**   5. AFP locking (OSX only),\n**   6. Named POSIX semaphores (VXWorks only),\n**   7. proxy locking. (OSX only)\n**\n** Styles 4, 5, and 7 are only available of SQLITE_ENABLE_LOCKING_STYLE\n** is defined to 1.  The SQLITE_ENABLE_LOCKING_STYLE also enables automatic\n** selection of the appropriate locking style based on the filesystem\n** where the database is located.  \n*/\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/* Use pread() and pwrite() if they are available */\n#if defined(__APPLE__)\n# define HAVE_PREAD 1\n# define HAVE_PWRITE 1\n#endif\n#if defined(HAVE_PREAD64) && defined(HAVE_PWRITE64)\n# undef USE_PREAD\n# define USE_PREAD64 1\n#elif defined(HAVE_PREAD) && defined(HAVE_PWRITE)\n# undef USE_PREAD64\n# define USE_PREAD 1\n#endif\n\n/*\n** standard include files.\n*/\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include <unistd.h>\n/* #include <time.h> */\n#include <sys/time.h>\n#include <errno.h>\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n# include <sys/mman.h>\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n/* # include <sys/ioctl.h> */\n# include <sys/file.h>\n# include <sys/param.h>\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */\n\n#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \\\n                           (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))\n#  if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \\\n       && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))\n#    define HAVE_GETHOSTUUID 1\n#  else\n#    warning \"gethostuuid() is disabled.\"\n#  endif\n#endif\n\n\n#if OS_VXWORKS\n/* # include <sys/ioctl.h> */\n# include <semaphore.h>\n# include <limits.h>\n#endif /* OS_VXWORKS */\n\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n# include <sys/mount.h>\n#endif\n\n#ifdef HAVE_UTIME\n# include <utime.h>\n#endif\n\n/*\n** Allowed values of unixFile.fsFlags\n*/\n#define SQLITE_FSFLAGS_IS_MSDOS     0x1\n\n/*\n** If we are to be thread-safe, include the pthreads header and define\n** the SQLITE_UNIX_THREADS macro.\n*/\n#if SQLITE_THREADSAFE\n/* # include <pthread.h> */\n# define SQLITE_UNIX_THREADS 1\n#endif\n\n/*\n** Default permissions when creating a new file\n*/\n#ifndef SQLITE_DEFAULT_FILE_PERMISSIONS\n# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644\n#endif\n\n/*\n** Default permissions when creating auto proxy dir\n*/\n#ifndef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n# define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755\n#endif\n\n/*\n** Maximum supported path-length.\n*/\n#define MAX_PATHNAME 512\n\n/*\n** Maximum supported symbolic links\n*/\n#define SQLITE_MAX_SYMLINKS 100\n\n/* Always cast the getpid() return type for compatibility with\n** kernel modules in VxWorks. */\n#define osGetpid(X) (pid_t)getpid()\n\n/*\n** Only set the lastErrno if the error code is a real error and not \n** a normal expected return code of SQLITE_BUSY or SQLITE_OK\n*/\n#define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))\n\n/* Forward references */\ntypedef struct unixShm unixShm;               /* Connection shared memory */\ntypedef struct unixShmNode unixShmNode;       /* Shared memory instance */\ntypedef struct unixInodeInfo unixInodeInfo;   /* An i-node */\ntypedef struct UnixUnusedFd UnixUnusedFd;     /* An unused file descriptor */\n\n/*\n** Sometimes, after a file handle is closed by SQLite, the file descriptor\n** cannot be closed immediately. In these cases, instances of the following\n** structure are used to store the file descriptor while waiting for an\n** opportunity to either close or reuse it.\n*/\nstruct UnixUnusedFd {\n  int fd;                   /* File descriptor to close */\n  int flags;                /* Flags this file descriptor was opened with */\n  UnixUnusedFd *pNext;      /* Next unused file descriptor on same file */\n};\n\n/*\n** The unixFile structure is subclass of sqlite3_file specific to the unix\n** VFS implementations.\n*/\ntypedef struct unixFile unixFile;\nstruct unixFile {\n  sqlite3_io_methods const *pMethod;  /* Always the first entry */\n  sqlite3_vfs *pVfs;                  /* The VFS that created this unixFile */\n  unixInodeInfo *pInode;              /* Info about locks on this inode */\n  int h;                              /* The file descriptor */\n  unsigned char eFileLock;            /* The type of lock held on this fd */\n  unsigned short int ctrlFlags;       /* Behavioral bits.  UNIXFILE_* flags */\n  int lastErrno;                      /* The unix errno from last I/O error */\n  void *lockingContext;               /* Locking style specific state */\n  UnixUnusedFd *pPreallocatedUnused;  /* Pre-allocated UnixUnusedFd */\n  const char *zPath;                  /* Name of the file */\n  unixShm *pShm;                      /* Shared memory segment information */\n  int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                      /* Number of outstanding xFetch refs */\n  sqlite3_int64 mmapSize;             /* Usable size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeActual;       /* Actual size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeMax;          /* Configured FCNTL_MMAP_SIZE value */\n  void *pMapRegion;                   /* Memory mapped region */\n#endif\n  int sectorSize;                     /* Device sector size */\n  int deviceCharacteristics;          /* Precomputed device characteristics */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int openFlags;                      /* The flags specified at open() */\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)\n  unsigned fsFlags;                   /* cached details from statfs() */\n#endif\n#if OS_VXWORKS\n  struct vxworksFileId *pId;          /* Unique file ID */\n#endif\n#ifdef SQLITE_DEBUG\n  /* The next group of variables are used to track whether or not the\n  ** transaction counter in bytes 24-27 of database files are updated\n  ** whenever any part of the database changes.  An assertion fault will\n  ** occur if a file is updated without also updating the transaction\n  ** counter.  This test is made to avoid new problems similar to the\n  ** one described by ticket #3584. \n  */\n  unsigned char transCntrChng;   /* True if the transaction counter changed */\n  unsigned char dbUpdate;        /* True if any part of database file changed */\n  unsigned char inNormalWrite;   /* True if in a normal write operation */\n\n#endif\n\n#ifdef SQLITE_TEST\n  /* In test mode, increase the size of this structure a bit so that \n  ** it is larger than the struct CrashFile defined in test6.c.\n  */\n  char aPadding[32];\n#endif\n};\n\n/* This variable holds the process id (pid) from when the xRandomness()\n** method was called.  If xOpen() is called from a different process id,\n** indicating that a fork() has occurred, the PRNG will be reset.\n*/\nstatic pid_t randomnessPid = 0;\n\n/*\n** Allowed values for the unixFile.ctrlFlags bitmask:\n*/\n#define UNIXFILE_EXCL        0x01     /* Connections from one process only */\n#define UNIXFILE_RDONLY      0x02     /* Connection is read only */\n#define UNIXFILE_PERSIST_WAL 0x04     /* Persistent WAL mode */\n#ifndef SQLITE_DISABLE_DIRSYNC\n# define UNIXFILE_DIRSYNC    0x08     /* Directory sync needed */\n#else\n# define UNIXFILE_DIRSYNC    0x00\n#endif\n#define UNIXFILE_PSOW        0x10     /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n#define UNIXFILE_DELETE      0x20     /* Delete on close */\n#define UNIXFILE_URI         0x40     /* Filename might have query parameters */\n#define UNIXFILE_NOLOCK      0x80     /* Do no file locking */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_unix.c ***************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_unix.c ********************/\n\n/*\n** Define various macros that are missing from some systems.\n*/\n#ifndef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifdef SQLITE_DISABLE_LFS\n# undef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifndef O_NOFOLLOW\n# define O_NOFOLLOW 0\n#endif\n#ifndef O_BINARY\n# define O_BINARY 0\n#endif\n\n/*\n** The threadid macro resolves to the thread-id or to 0.  Used for\n** testing and debugging only.\n*/\n#if SQLITE_THREADSAFE\n#define threadid pthread_self()\n#else\n#define threadid 0\n#endif\n\n/*\n** HAVE_MREMAP defaults to true on Linux and false everywhere else.\n*/\n#if !defined(HAVE_MREMAP)\n# if defined(__linux__) && defined(_GNU_SOURCE)\n#  define HAVE_MREMAP 1\n# else\n#  define HAVE_MREMAP 0\n# endif\n#endif\n\n/*\n** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek()\n** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined.\n*/\n#ifdef __ANDROID__\n# define lseek lseek64\n#endif\n\n#ifdef __linux__\n/*\n** Linux-specific IOCTL magic numbers used for controlling F2FS\n*/\n#define F2FS_IOCTL_MAGIC        0xf5\n#define F2FS_IOC_START_ATOMIC_WRITE     _IO(F2FS_IOCTL_MAGIC, 1)\n#define F2FS_IOC_COMMIT_ATOMIC_WRITE    _IO(F2FS_IOCTL_MAGIC, 2)\n#define F2FS_IOC_START_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 3)\n#define F2FS_IOC_ABORT_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 5)\n#define F2FS_IOC_GET_FEATURES           _IOR(F2FS_IOCTL_MAGIC, 12, u32)\n#define F2FS_FEATURE_ATOMIC_WRITE 0x0004\n#endif /* __linux__ */\n\n\n/*\n** Different Unix systems declare open() in different ways.  Same use\n** open(const char*,int,mode_t).  Others use open(const char*,int,...).\n** The difference is important when using a pointer to the function.\n**\n** The safest way to deal with the problem is to always use this wrapper\n** which always has the same well-defined interface.\n*/\nstatic int posixOpen(const char *zFile, int flags, int mode){\n  return open(zFile, flags, mode);\n}\n\n/* Forward reference */\nstatic int openDirectory(const char*, int*);\nstatic int unixGetpagesize(void);\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct unix_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n  { \"open\",         (sqlite3_syscall_ptr)posixOpen,  0  },\n#define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)\n\n  { \"close\",        (sqlite3_syscall_ptr)close,      0  },\n#define osClose     ((int(*)(int))aSyscall[1].pCurrent)\n\n  { \"access\",       (sqlite3_syscall_ptr)access,     0  },\n#define osAccess    ((int(*)(const char*,int))aSyscall[2].pCurrent)\n\n  { \"getcwd\",       (sqlite3_syscall_ptr)getcwd,     0  },\n#define osGetcwd    ((char*(*)(char*,size_t))aSyscall[3].pCurrent)\n\n  { \"stat\",         (sqlite3_syscall_ptr)stat,       0  },\n#define osStat      ((int(*)(const char*,struct stat*))aSyscall[4].pCurrent)\n\n/*\n** The DJGPP compiler environment looks mostly like Unix, but it\n** lacks the fcntl() system call.  So redefine fcntl() to be something\n** that always succeeds.  This means that locking does not occur under\n** DJGPP.  But it is DOS - what did you expect?\n*/\n#ifdef __DJGPP__\n  { \"fstat\",        0,                 0  },\n#define osFstat(a,b,c)    0\n#else     \n  { \"fstat\",        (sqlite3_syscall_ptr)fstat,      0  },\n#define osFstat     ((int(*)(int,struct stat*))aSyscall[5].pCurrent)\n#endif\n\n  { \"ftruncate\",    (sqlite3_syscall_ptr)ftruncate,  0  },\n#define osFtruncate ((int(*)(int,off_t))aSyscall[6].pCurrent)\n\n  { \"fcntl\",        (sqlite3_syscall_ptr)fcntl,      0  },\n#define osFcntl     ((int(*)(int,int,...))aSyscall[7].pCurrent)\n\n  { \"read\",         (sqlite3_syscall_ptr)read,       0  },\n#define osRead      ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pread\",        (sqlite3_syscall_ptr)pread,      0  },\n#else\n  { \"pread\",        (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pread64\",      (sqlite3_syscall_ptr)pread64,    0  },\n#else\n  { \"pread64\",      (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)\n\n  { \"write\",        (sqlite3_syscall_ptr)write,      0  },\n#define osWrite     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pwrite\",       (sqlite3_syscall_ptr)pwrite,     0  },\n#else\n  { \"pwrite\",       (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                    aSyscall[12].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pwrite64\",     (sqlite3_syscall_ptr)pwrite64,   0  },\n#else\n  { \"pwrite64\",     (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\\\n                    aSyscall[13].pCurrent)\n\n  { \"fchmod\",       (sqlite3_syscall_ptr)fchmod,          0  },\n#define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n  { \"fallocate\",    (sqlite3_syscall_ptr)posix_fallocate,  0 },\n#else\n  { \"fallocate\",    (sqlite3_syscall_ptr)0,                0 },\n#endif\n#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent)\n\n  { \"unlink\",       (sqlite3_syscall_ptr)unlink,           0 },\n#define osUnlink    ((int(*)(const char*))aSyscall[16].pCurrent)\n\n  { \"openDirectory\",    (sqlite3_syscall_ptr)openDirectory,      0 },\n#define osOpenDirectory ((int(*)(const char*,int*))aSyscall[17].pCurrent)\n\n  { \"mkdir\",        (sqlite3_syscall_ptr)mkdir,           0 },\n#define osMkdir     ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)\n\n  { \"rmdir\",        (sqlite3_syscall_ptr)rmdir,           0 },\n#define osRmdir     ((int(*)(const char*))aSyscall[19].pCurrent)\n\n#if defined(HAVE_FCHOWN)\n  { \"fchown\",       (sqlite3_syscall_ptr)fchown,          0 },\n#else\n  { \"fchown\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osFchown    ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)\n\n  { \"geteuid\",      (sqlite3_syscall_ptr)geteuid,         0 },\n#define osGeteuid   ((uid_t(*)(void))aSyscall[21].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"mmap\",         (sqlite3_syscall_ptr)mmap,            0 },\n#else\n  { \"mmap\",         (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"munmap\",       (sqlite3_syscall_ptr)munmap,          0 },\n#else\n  { \"munmap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent)\n\n#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"mremap\",       (sqlite3_syscall_ptr)mremap,          0 },\n#else\n  { \"mremap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[24].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"getpagesize\",  (sqlite3_syscall_ptr)unixGetpagesize, 0 },\n#else\n  { \"getpagesize\",  (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent)\n\n#if defined(HAVE_READLINK)\n  { \"readlink\",     (sqlite3_syscall_ptr)readlink,        0 },\n#else\n  { \"readlink\",     (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent)\n\n#if defined(HAVE_LSTAT)\n  { \"lstat\",         (sqlite3_syscall_ptr)lstat,          0 },\n#else\n  { \"lstat\",         (sqlite3_syscall_ptr)0,              0 },\n#endif\n#define osLstat      ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)\n\n  { \"ioctl\",         (sqlite3_syscall_ptr)ioctl,          0 },\n#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n\n/*\n** On some systems, calls to fchown() will trigger a message in a security\n** log if they come from non-root processes.  So avoid calling fchown() if\n** we are not running as root.\n*/\nstatic int robustFchown(int fd, uid_t uid, gid_t gid){\n#if defined(HAVE_FCHOWN)\n  return osGeteuid() ? 0 : osFchown(fd,uid,gid);\n#else\n  return 0;\n#endif\n}\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"unix\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int unixSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr unixGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n/*\n** Do not accept any file descriptor less than this value, in order to avoid\n** opening database file using file descriptors that are commonly used for \n** standard input, output, and error.\n*/\n#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR\n# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3\n#endif\n\n/*\n** Invoke open().  Do so multiple times, until it either succeeds or\n** fails for some reason other than EINTR.\n**\n** If the file creation mode \"m\" is 0 then set it to the default for\n** SQLite.  The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally\n** 0644) as modified by the system umask.  If m is not 0, then\n** make the file creation mode be exactly m ignoring the umask.\n**\n** The m parameter will be non-zero only when creating -wal, -journal,\n** and -shm files.  We want those files to have *exactly* the same\n** permissions as their original database, unadulterated by the umask.\n** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a\n** transaction crashes and leaves behind hot journals, then any\n** process that is able to write to the database will also be able to\n** recover the hot journals.\n*/\nstatic int robust_open(const char *z, int f, mode_t m){\n  int fd;\n  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;\n  while(1){\n#if defined(O_CLOEXEC)\n    fd = osOpen(z,f|O_CLOEXEC,m2);\n#else\n    fd = osOpen(z,f,m2);\n#endif\n    if( fd<0 ){\n      if( errno==EINTR ) continue;\n      break;\n    }\n    if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;\n    osClose(fd);\n    sqlite3_log(SQLITE_WARNING, \n                \"attempt to open \\\"%s\\\" as file descriptor %d\", z, fd);\n    fd = -1;\n    if( osOpen(\"/dev/null\", f, m)<0 ) break;\n  }\n  if( fd>=0 ){\n    if( m!=0 ){\n      struct stat statbuf;\n      if( osFstat(fd, &statbuf)==0 \n       && statbuf.st_size==0\n       && (statbuf.st_mode&0777)!=m \n      ){\n        osFchmod(fd, m);\n      }\n    }\n#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)\n    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);\n#endif\n  }\n  return fd;\n}\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the unixInodeInfo and\n** vxworksFileId objects used by this file, all of which may be \n** shared by multiple threads.\n**\n** Function unixMutexHeld() is used to assert() that the global mutex \n** is held when required. This function is only used as part of assert() \n** statements. e.g.\n**\n**   unixEnterMutex()\n**     assert( unixMutexHeld() );\n**   unixEnterLeave()\n*/\nstatic void unixEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\nstatic void unixLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#ifdef SQLITE_DEBUG\nstatic int unixMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#endif\n\n\n#ifdef SQLITE_HAVE_OS_TRACE\n/*\n** Helper function for printing out trace information from debugging\n** binaries. This returns the string representation of the supplied\n** integer lock-type.\n*/\nstatic const char *azFileLock(int eFileLock){\n  switch( eFileLock ){\n    case NO_LOCK: return \"NONE\";\n    case SHARED_LOCK: return \"SHARED\";\n    case RESERVED_LOCK: return \"RESERVED\";\n    case PENDING_LOCK: return \"PENDING\";\n    case EXCLUSIVE_LOCK: return \"EXCLUSIVE\";\n  }\n  return \"ERROR\";\n}\n#endif\n\n#ifdef SQLITE_LOCK_TRACE\n/*\n** Print out information about all locking operations.\n**\n** This routine is used for troubleshooting locks on multithreaded\n** platforms.  Enable by compiling with the -DSQLITE_LOCK_TRACE\n** command-line option on the compiler.  This code is normally\n** turned off.\n*/\nstatic int lockTrace(int fd, int op, struct flock *p){\n  char *zOpName, *zType;\n  int s;\n  int savedErrno;\n  if( op==F_GETLK ){\n    zOpName = \"GETLK\";\n  }else if( op==F_SETLK ){\n    zOpName = \"SETLK\";\n  }else{\n    s = osFcntl(fd, op, p);\n    sqlite3DebugPrintf(\"fcntl unknown %d %d %d\\n\", fd, op, s);\n    return s;\n  }\n  if( p->l_type==F_RDLCK ){\n    zType = \"RDLCK\";\n  }else if( p->l_type==F_WRLCK ){\n    zType = \"WRLCK\";\n  }else if( p->l_type==F_UNLCK ){\n    zType = \"UNLCK\";\n  }else{\n    assert( 0 );\n  }\n  assert( p->l_whence==SEEK_SET );\n  s = osFcntl(fd, op, p);\n  savedErrno = errno;\n  sqlite3DebugPrintf(\"fcntl %d %d %s %s %d %d %d %d\\n\",\n     threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len,\n     (int)p->l_pid, s);\n  if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){\n    struct flock l2;\n    l2 = *p;\n    osFcntl(fd, F_GETLK, &l2);\n    if( l2.l_type==F_RDLCK ){\n      zType = \"RDLCK\";\n    }else if( l2.l_type==F_WRLCK ){\n      zType = \"WRLCK\";\n    }else if( l2.l_type==F_UNLCK ){\n      zType = \"UNLCK\";\n    }else{\n      assert( 0 );\n    }\n    sqlite3DebugPrintf(\"fcntl-failure-reason: %s %d %d %d\\n\",\n       zType, (int)l2.l_start, (int)l2.l_len, (int)l2.l_pid);\n  }\n  errno = savedErrno;\n  return s;\n}\n#undef osFcntl\n#define osFcntl lockTrace\n#endif /* SQLITE_LOCK_TRACE */\n\n/*\n** Retry ftruncate() calls that fail due to EINTR\n**\n** All calls to ftruncate() within this file should be made through\n** this wrapper.  On the Android platform, bypassing the logic below\n** could lead to a corrupt database.\n*/\nstatic int robust_ftruncate(int h, sqlite3_int64 sz){\n  int rc;\n#ifdef __ANDROID__\n  /* On Android, ftruncate() always uses 32-bit offsets, even if \n  ** _FILE_OFFSET_BITS=64 is defined. This means it is unsafe to attempt to\n  ** truncate a file to any size larger than 2GiB. Silently ignore any\n  ** such attempts.  */\n  if( sz>(sqlite3_int64)0x7FFFFFFF ){\n    rc = SQLITE_OK;\n  }else\n#endif\n  do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n\n/*\n** This routine translates a standard POSIX errno code into something\n** useful to the clients of the sqlite3 functions.  Specifically, it is\n** intended to translate a variety of \"try again\" errors into SQLITE_BUSY\n** and a variety of \"please close the file descriptor NOW\" errors into \n** SQLITE_IOERR\n** \n** Errors during initialization of locks, or file system support for locks,\n** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.\n*/\nstatic int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {\n  assert( (sqliteIOErr == SQLITE_IOERR_LOCK) || \n          (sqliteIOErr == SQLITE_IOERR_UNLOCK) || \n          (sqliteIOErr == SQLITE_IOERR_RDLOCK) ||\n          (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) );\n  switch (posixError) {\n  case EACCES: \n  case EAGAIN:\n  case ETIMEDOUT:\n  case EBUSY:\n  case EINTR:\n  case ENOLCK:  \n    /* random NFS retry error, unless during file system support \n     * introspection, in which it actually means what it says */\n    return SQLITE_BUSY;\n    \n  case EPERM: \n    return SQLITE_PERM;\n    \n  default: \n    return sqliteIOErr;\n  }\n}\n\n\n/******************************************************************************\n****************** Begin Unique File ID Utility Used By VxWorks ***************\n**\n** On most versions of unix, we can get a unique ID for a file by concatenating\n** the device number and the inode number.  But this does not work on VxWorks.\n** On VxWorks, a unique file id must be based on the canonical filename.\n**\n** A pointer to an instance of the following structure can be used as a\n** unique file ID in VxWorks.  Each instance of this structure contains\n** a copy of the canonical filename.  There is also a reference count.  \n** The structure is reclaimed when the number of pointers to it drops to\n** zero.\n**\n** There are never very many files open at one time and lookups are not\n** a performance-critical path, so it is sufficient to put these\n** structures on a linked list.\n*/\nstruct vxworksFileId {\n  struct vxworksFileId *pNext;  /* Next in a list of them all */\n  int nRef;                     /* Number of references to this one */\n  int nName;                    /* Length of the zCanonicalName[] string */\n  char *zCanonicalName;         /* Canonical filename */\n};\n\n#if OS_VXWORKS\n/* \n** All unique filenames are held on a linked list headed by this\n** variable:\n*/\nstatic struct vxworksFileId *vxworksFileList = 0;\n\n/*\n** Simplify a filename into its canonical form\n** by making the following changes:\n**\n**  * removing any trailing and duplicate /\n**  * convert /./ into just /\n**  * convert /A/../ where A is any simple name into just /\n**\n** Changes are made in-place.  Return the new name length.\n**\n** The original filename is in z[0..n-1].  Return the number of\n** characters in the simplified name.\n*/\nstatic int vxworksSimplifyName(char *z, int n){\n  int i, j;\n  while( n>1 && z[n-1]=='/' ){ n--; }\n  for(i=j=0; i<n; i++){\n    if( z[i]=='/' ){\n      if( z[i+1]=='/' ) continue;\n      if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){\n        i += 1;\n        continue;\n      }\n      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){\n        while( j>0 && z[j-1]!='/' ){ j--; }\n        if( j>0 ){ j--; }\n        i += 2;\n        continue;\n      }\n    }\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n  return j;\n}\n\n/*\n** Find a unique file ID for the given absolute pathname.  Return\n** a pointer to the vxworksFileId object.  This pointer is the unique\n** file ID.\n**\n** The nRef field of the vxworksFileId object is incremented before\n** the object is returned.  A new vxworksFileId object is created\n** and added to the global list if necessary.\n**\n** If a memory allocation error occurs, return NULL.\n*/\nstatic struct vxworksFileId *vxworksFindFileId(const char *zAbsoluteName){\n  struct vxworksFileId *pNew;         /* search key and new file ID */\n  struct vxworksFileId *pCandidate;   /* For looping over existing file IDs */\n  int n;                              /* Length of zAbsoluteName string */\n\n  assert( zAbsoluteName[0]=='/' );\n  n = (int)strlen(zAbsoluteName);\n  pNew = sqlite3_malloc64( sizeof(*pNew) + (n+1) );\n  if( pNew==0 ) return 0;\n  pNew->zCanonicalName = (char*)&pNew[1];\n  memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);\n  n = vxworksSimplifyName(pNew->zCanonicalName, n);\n\n  /* Search for an existing entry that matching the canonical name.\n  ** If found, increment the reference count and return a pointer to\n  ** the existing file ID.\n  */\n  unixEnterMutex();\n  for(pCandidate=vxworksFileList; pCandidate; pCandidate=pCandidate->pNext){\n    if( pCandidate->nName==n \n     && memcmp(pCandidate->zCanonicalName, pNew->zCanonicalName, n)==0\n    ){\n       sqlite3_free(pNew);\n       pCandidate->nRef++;\n       unixLeaveMutex();\n       return pCandidate;\n    }\n  }\n\n  /* No match was found.  We will make a new file ID */\n  pNew->nRef = 1;\n  pNew->nName = n;\n  pNew->pNext = vxworksFileList;\n  vxworksFileList = pNew;\n  unixLeaveMutex();\n  return pNew;\n}\n\n/*\n** Decrement the reference count on a vxworksFileId object.  Free\n** the object when the reference count reaches zero.\n*/\nstatic void vxworksReleaseFileId(struct vxworksFileId *pId){\n  unixEnterMutex();\n  assert( pId->nRef>0 );\n  pId->nRef--;\n  if( pId->nRef==0 ){\n    struct vxworksFileId **pp;\n    for(pp=&vxworksFileList; *pp && *pp!=pId; pp = &((*pp)->pNext)){}\n    assert( *pp==pId );\n    *pp = pId->pNext;\n    sqlite3_free(pId);\n  }\n  unixLeaveMutex();\n}\n#endif /* OS_VXWORKS */\n/*************** End of Unique File ID Utility Used By VxWorks ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Posix Advisory Locking ****************************\n**\n** POSIX advisory locks are broken by design.  ANSI STD 1003.1 (1996)\n** section 6.5.2.2 lines 483 through 490 specify that when a process\n** sets or clears a lock, that operation overrides any prior locks set\n** by the same process.  It does not explicitly say so, but this implies\n** that it overrides locks set by the same process using a different\n** file descriptor.  Consider this test case:\n**\n**       int fd1 = open(\"./file1\", O_RDWR|O_CREAT, 0644);\n**       int fd2 = open(\"./file2\", O_RDWR|O_CREAT, 0644);\n**\n** Suppose ./file1 and ./file2 are really the same file (because\n** one is a hard or symbolic link to the other) then if you set\n** an exclusive lock on fd1, then try to get an exclusive lock\n** on fd2, it works.  I would have expected the second lock to\n** fail since there was already a lock on the file due to fd1.\n** But not so.  Since both locks came from the same process, the\n** second overrides the first, even though they were on different\n** file descriptors opened on different file names.\n**\n** This means that we cannot use POSIX locks to synchronize file access\n** among competing threads of the same process.  POSIX locks will work fine\n** to synchronize access for threads in separate processes, but not\n** threads within the same process.\n**\n** To work around the problem, SQLite has to manage file locks internally\n** on its own.  Whenever a new database is opened, we have to find the\n** specific inode of the database file (the inode is determined by the\n** st_dev and st_ino fields of the stat structure that fstat() fills in)\n** and check for locks already existing on that inode.  When locks are\n** created or removed, we have to look at our own internal record of the\n** locks to see if another thread has previously set a lock on that same\n** inode.\n**\n** (Aside: The use of inode numbers as unique IDs does not work on VxWorks.\n** For VxWorks, we have to use the alternative unique ID system based on\n** canonical filename and implemented in the previous division.)\n**\n** The sqlite3_file structure for POSIX is no longer just an integer file\n** descriptor.  It is now a structure that holds the integer file\n** descriptor and a pointer to a structure that describes the internal\n** locks on the corresponding inode.  There is one locking structure\n** per inode, so if the same inode is opened twice, both unixFile structures\n** point to the same locking structure.  The locking structure keeps\n** a reference count (so we will know when to delete it) and a \"cnt\"\n** field that tells us its internal lock status.  cnt==0 means the\n** file is unlocked.  cnt==-1 means the file has an exclusive lock.\n** cnt>0 means there are cnt shared locks on the file.\n**\n** Any attempt to lock or unlock a file first checks the locking\n** structure.  The fcntl() system call is only invoked to set a \n** POSIX lock if the internal lock structure transitions between\n** a locked and an unlocked state.\n**\n** But wait:  there are yet more problems with POSIX advisory locks.\n**\n** If you close a file descriptor that points to a file that has locks,\n** all locks on that file that are owned by the current process are\n** released.  To work around this problem, each unixInodeInfo object\n** maintains a count of the number of pending locks on tha inode.\n** When an attempt is made to close an unixFile, if there are\n** other unixFile open on the same inode that are holding locks, the call\n** to close() the file descriptor is deferred until all of the locks clear.\n** The unixInodeInfo structure keeps a list of file descriptors that need to\n** be closed and that list is walked (and cleared) when the last lock\n** clears.\n**\n** Yet another problem:  LinuxThreads do not play well with posix locks.\n**\n** Many older versions of linux use the LinuxThreads library which is\n** not posix compliant.  Under LinuxThreads, a lock created by thread\n** A cannot be modified or overridden by a different thread B.\n** Only thread A can modify the lock.  Locking behavior is correct\n** if the appliation uses the newer Native Posix Thread Library (NPTL)\n** on linux - with NPTL a lock created by thread A can override locks\n** in thread B.  But there is no way to know at compile-time which\n** threading library is being used.  So there is no way to know at\n** compile-time whether or not thread A can override locks on thread B.\n** One has to do a run-time check to discover the behavior of the\n** current process.\n**\n** SQLite used to support LinuxThreads.  But support for LinuxThreads\n** was dropped beginning with version 3.7.0.  SQLite will still work with\n** LinuxThreads provided that (1) there is no more than one connection \n** per database file in the same process and (2) database connections\n** do not move across threads.\n*/\n\n/*\n** An instance of the following structure serves as the key used\n** to locate a particular unixInodeInfo object.\n*/\nstruct unixFileId {\n  dev_t dev;                  /* Device number */\n#if OS_VXWORKS\n  struct vxworksFileId *pId;  /* Unique file ID for vxworks. */\n#else\n  /* We are told that some versions of Android contain a bug that\n  ** sizes ino_t at only 32-bits instead of 64-bits. (See\n  ** https://android-review.googlesource.com/#/c/115351/3/dist/sqlite3.c)\n  ** To work around this, always allocate 64-bits for the inode number.  \n  ** On small machines that only have 32-bit inodes, this wastes 4 bytes,\n  ** but that should not be a big deal. */\n  /* WAS:  ino_t ino;   */\n  u64 ino;                   /* Inode number */\n#endif\n};\n\n/*\n** An instance of the following structure is allocated for each open\n** inode.  Or, on LinuxThreads, there is one of these structures for\n** each inode opened by each thread.\n**\n** A single inode can have multiple file descriptors, so each unixFile\n** structure contains a pointer to an instance of this object and this\n** object keeps a count of the number of unixFile pointing to it.\n*/\nstruct unixInodeInfo {\n  struct unixFileId fileId;       /* The lookup key */\n  int nShared;                    /* Number of SHARED locks held */\n  unsigned char eFileLock;        /* One of SHARED_LOCK, RESERVED_LOCK etc. */\n  unsigned char bProcessLock;     /* An exclusive process lock is held */\n  int nRef;                       /* Number of pointers to this structure */\n  unixShmNode *pShmNode;          /* Shared memory associated with this inode */\n  int nLock;                      /* Number of outstanding file locks */\n  UnixUnusedFd *pUnused;          /* Unused file descriptors to close */\n  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */\n  unixInodeInfo *pPrev;           /*    .... doubly linked */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  unsigned long long sharedByte;  /* for AFP simulated shared lock */\n#endif\n#if OS_VXWORKS\n  sem_t *pSem;                    /* Named POSIX semaphore */\n  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */\n#endif\n};\n\n/*\n** A lists of all unixInodeInfo objects.\n*/\nstatic unixInodeInfo *inodeList = 0;  /* All unixInodeInfo objects */\nstatic unsigned int nUnusedFd = 0;    /* Total unused file descriptors */\n\n/*\n**\n** This function - unixLogErrorAtLine(), is only ever called via the macro\n** unixLogError().\n**\n** It is invoked after an error occurs in an OS function and errno has been\n** set. It logs a message using sqlite3_log() containing the current value of\n** errno and, if possible, the human-readable equivalent from strerror() or\n** strerror_r().\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). \n** The two subsequent arguments should be the name of the OS function that\n** failed (e.g. \"unlink\", \"open\") and the associated file-system path,\n** if any.\n*/\n#define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)\nstatic int unixLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char *zErr;                     /* Message from strerror() or equivalent */\n  int iErrno = errno;             /* Saved syscall error number */\n\n  /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use\n  ** the strerror() function to obtain the human-readable error message\n  ** equivalent to errno. Otherwise, use strerror_r().\n  */ \n#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)\n  char aErr[80];\n  memset(aErr, 0, sizeof(aErr));\n  zErr = aErr;\n\n  /* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,\n  ** assume that the system provides the GNU version of strerror_r() that\n  ** returns a pointer to a buffer containing the error message. That pointer \n  ** may point to aErr[], or it may point to some static storage somewhere. \n  ** Otherwise, assume that the system provides the POSIX version of \n  ** strerror_r(), which always writes an error message into aErr[].\n  **\n  ** If the code incorrectly assumes that it is the POSIX version that is\n  ** available, the error message will often be an empty string. Not a\n  ** huge problem. Incorrectly concluding that the GNU version is available \n  ** could lead to a segfault though.\n  */\n#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)\n  zErr = \n# endif\n  strerror_r(iErrno, aErr, sizeof(aErr)-1);\n\n#elif SQLITE_THREADSAFE\n  /* This is a threadsafe build, but strerror_r() is not available. */\n  zErr = \"\";\n#else\n  /* Non-threadsafe build, use strerror(). */\n  zErr = strerror(iErrno);\n#endif\n\n  if( zPath==0 ) zPath = \"\";\n  sqlite3_log(errcode,\n      \"os_unix.c:%d: (%d) %s(%s) - %s\",\n      iLine, iErrno, zFunc, zPath, zErr\n  );\n\n  return errcode;\n}\n\n/*\n** Close a file descriptor.\n**\n** We assume that close() almost always works, since it is only in a\n** very sick application or on a very sick platform that it might fail.\n** If it does fail, simply leak the file descriptor, but do log the\n** error.\n**\n** Note that it is not safe to retry close() after EINTR since the\n** file descriptor might have already been reused by another thread.\n** So we don't even try to recover from an EINTR.  Just log the error\n** and move on.\n*/\nstatic void robust_close(unixFile *pFile, int h, int lineno){\n  if( osClose(h) ){\n    unixLogErrorAtLine(SQLITE_IOERR_CLOSE, \"close\",\n                       pFile ? pFile->zPath : 0, lineno);\n  }\n}\n\n/*\n** Set the pFile->lastErrno.  Do this in a subroutine as that provides\n** a convenient place to set a breakpoint.\n*/\nstatic void storeLastErrno(unixFile *pFile, int error){\n  pFile->lastErrno = error;\n}\n\n/*\n** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.\n*/ \nstatic void closePendingFds(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p;\n  UnixUnusedFd *pNext;\n  for(p=pInode->pUnused; p; p=pNext){\n    pNext = p->pNext;\n    robust_close(pFile, p->fd, __LINE__);\n    sqlite3_free(p);\n    nUnusedFd--;\n  }\n  pInode->pUnused = 0;\n}\n\n/*\n** Release a unixInodeInfo structure previously allocated by findInodeInfo().\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n*/\nstatic void releaseInodeInfo(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  if( ALWAYS(pInode) ){\n    pInode->nRef--;\n    if( pInode->nRef==0 ){\n      assert( pInode->pShmNode==0 );\n      closePendingFds(pFile);\n      if( pInode->pPrev ){\n        assert( pInode->pPrev->pNext==pInode );\n        pInode->pPrev->pNext = pInode->pNext;\n      }else{\n        assert( inodeList==pInode );\n        inodeList = pInode->pNext;\n      }\n      if( pInode->pNext ){\n        assert( pInode->pNext->pPrev==pInode );\n        pInode->pNext->pPrev = pInode->pPrev;\n      }\n      sqlite3_free(pInode);\n    }\n  }\n  assert( inodeList!=0 || nUnusedFd==0 );\n}\n\n/*\n** Given a file descriptor, locate the unixInodeInfo object that\n** describes that file descriptor.  Create a new one if necessary.  The\n** return value might be uninitialized if an error occurs.\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n**\n** Return an appropriate error code.\n*/\nstatic int findInodeInfo(\n  unixFile *pFile,               /* Unix file with file desc used in the key */\n  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */\n){\n  int rc;                        /* System call return code */\n  int fd;                        /* The file descriptor for pFile */\n  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */\n  struct stat statbuf;           /* Low-level file information */\n  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */\n\n  assert( unixMutexHeld() );\n\n  /* Get low-level information about the file that we can used to\n  ** create a unique name for the file.\n  */\n  fd = pFile->h;\n  rc = osFstat(fd, &statbuf);\n  if( rc!=0 ){\n    storeLastErrno(pFile, errno);\n#if defined(EOVERFLOW) && defined(SQLITE_DISABLE_LFS)\n    if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;\n#endif\n    return SQLITE_IOERR;\n  }\n\n#ifdef __APPLE__\n  /* On OS X on an msdos filesystem, the inode number is reported\n  ** incorrectly for zero-size files.  See ticket #3260.  To work\n  ** around this problem (we consider it a bug in OS X, not SQLite)\n  ** we always increase the file size to 1 by writing a single byte\n  ** prior to accessing the inode number.  The one byte written is\n  ** an ASCII 'S' character which also happens to be the first byte\n  ** in the header of every SQLite database.  In this way, if there\n  ** is a race condition such that another thread has already populated\n  ** the first page of the database, no damage is done.\n  */\n  if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){\n    do{ rc = osWrite(fd, \"S\", 1); }while( rc<0 && errno==EINTR );\n    if( rc!=1 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n    rc = osFstat(fd, &statbuf);\n    if( rc!=0 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n  }\n#endif\n\n  memset(&fileId, 0, sizeof(fileId));\n  fileId.dev = statbuf.st_dev;\n#if OS_VXWORKS\n  fileId.pId = pFile->pId;\n#else\n  fileId.ino = (u64)statbuf.st_ino;\n#endif\n  assert( inodeList!=0 || nUnusedFd==0 );\n  pInode = inodeList;\n  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){\n    pInode = pInode->pNext;\n  }\n  if( pInode==0 ){\n    pInode = sqlite3_malloc64( sizeof(*pInode) );\n    if( pInode==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(pInode, 0, sizeof(*pInode));\n    memcpy(&pInode->fileId, &fileId, sizeof(fileId));\n    pInode->nRef = 1;\n    pInode->pNext = inodeList;\n    pInode->pPrev = 0;\n    if( inodeList ) inodeList->pPrev = pInode;\n    inodeList = pInode;\n  }else{\n    pInode->nRef++;\n  }\n  *ppInode = pInode;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if pFile has been renamed or unlinked since it was first opened.\n*/\nstatic int fileHasMoved(unixFile *pFile){\n#if OS_VXWORKS\n  return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId;\n#else\n  struct stat buf;\n  return pFile->pInode!=0 &&\n      (osStat(pFile->zPath, &buf)!=0 \n         || (u64)buf.st_ino!=pFile->pInode->fileId.ino);\n#endif\n}\n\n\n/*\n** Check a unixFile that is a database.  Verify the following:\n**\n** (1) There is exactly one hard link on the file\n** (2) The file is not a symbolic link\n** (3) The file has not been renamed or unlinked\n**\n** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right.\n*/\nstatic void verifyDbFile(unixFile *pFile){\n  struct stat buf;\n  int rc;\n\n  /* These verifications occurs for the main database only */\n  if( pFile->ctrlFlags & UNIXFILE_NOLOCK ) return;\n\n  rc = osFstat(pFile->h, &buf);\n  if( rc!=0 ){\n    sqlite3_log(SQLITE_WARNING, \"cannot fstat db file %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink==0 ){\n    sqlite3_log(SQLITE_WARNING, \"file unlinked while open: %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink>1 ){\n    sqlite3_log(SQLITE_WARNING, \"multiple links to file: %s\", pFile->zPath);\n    return;\n  }\n  if( fileHasMoved(pFile) ){\n    sqlite3_log(SQLITE_WARNING, \"file renamed while open: %s\", pFile->zPath);\n    return;\n  }\n}\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int unixCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n\n  assert( pFile );\n  assert( pFile->eFileLock<=SHARED_LOCK );\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n\n  /* Otherwise see if some other process holds it.\n  */\n#ifndef __DJGPP__\n  if( !reserved && !pFile->pInode->bProcessLock ){\n    struct flock lock;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = RESERVED_BYTE;\n    lock.l_len = 1;\n    lock.l_type = F_WRLCK;\n    if( osFcntl(pFile->h, F_GETLK, &lock) ){\n      rc = SQLITE_IOERR_CHECKRESERVEDLOCK;\n      storeLastErrno(pFile, errno);\n    } else if( lock.l_type!=F_UNLCK ){\n      reserved = 1;\n    }\n  }\n#endif\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (unix)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Attempt to set a system-lock on the file pFile.  The lock is \n** described by pLock.\n**\n** If the pFile was opened read/write from unix-excl, then the only lock\n** ever obtained is an exclusive lock, and it is obtained exactly once\n** the first time any lock is attempted.  All subsequent system locking\n** operations become no-ops.  Locking operations still happen internally,\n** in order to coordinate access between separate database connections\n** within this process, but all of that is handled in memory and the\n** operating system does not participate.\n**\n** This function is a pass-through to fcntl(F_SETLK) if pFile is using\n** any VFS other than \"unix-excl\" or if pFile is opened on \"unix-excl\"\n** and is read-only.\n**\n** Zero is returned if the call completes successfully, or -1 if a call\n** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).\n*/\nstatic int unixFileLock(unixFile *pFile, struct flock *pLock){\n  int rc;\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  assert( pInode!=0 );\n  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){\n    if( pInode->bProcessLock==0 ){\n      struct flock lock;\n      assert( pInode->nLock==0 );\n      lock.l_whence = SEEK_SET;\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n      lock.l_type = F_WRLCK;\n      rc = osFcntl(pFile->h, F_SETLK, &lock);\n      if( rc<0 ) return rc;\n      pInode->bProcessLock = 1;\n      pInode->nLock++;\n    }else{\n      rc = 0;\n    }\n  }else{\n    rc = osFcntl(pFile->h, F_SETLK, pLock);\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int unixLock(sqlite3_file *id, int eFileLock){\n  /* The following describes the implementation of the various locks and\n  ** lock transitions in terms of the POSIX advisory shared and exclusive\n  ** lock primitives (called read-locks and write-locks below, to avoid\n  ** confusion with SQLite lock names). The algorithms are complicated\n  ** slightly in order to be compatible with Windows95 systems simultaneously\n  ** accessing the same database file, in case that is ever required.\n  **\n  ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved\n  ** byte', each single bytes at well known offsets, and the 'shared byte\n  ** range', a range of 510 bytes at a well known offset.\n  **\n  ** To obtain a SHARED lock, a read-lock is obtained on the 'pending\n  ** byte'.  If this is successful, 'shared byte range' is read-locked\n  ** and the lock on the 'pending byte' released.  (Legacy note:  When\n  ** SQLite was first developed, Windows95 systems were still very common,\n  ** and Widnows95 lacks a shared-lock capability.  So on Windows95, a\n  ** single randomly selected by from the 'shared byte range' is locked.\n  ** Windows95 is now pretty much extinct, but this work-around for the\n  ** lack of shared-locks on Windows95 lives on, for backwards\n  ** compatibility.)\n  **\n  ** A process may only obtain a RESERVED lock after it has a SHARED lock.\n  ** A RESERVED lock is implemented by grabbing a write-lock on the\n  ** 'reserved byte'. \n  **\n  ** A process may only obtain a PENDING lock after it has obtained a\n  ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock\n  ** on the 'pending byte'. This ensures that no new SHARED locks can be\n  ** obtained, but existing SHARED locks are allowed to persist. A process\n  ** does not have to obtain a RESERVED lock on the way to a PENDING lock.\n  ** This property is used by the algorithm for rolling back a journal file\n  ** after a crash.\n  **\n  ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is\n  ** implemented by obtaining a write-lock on the entire 'shared byte\n  ** range'. Since all other locks require a read-lock on one of the bytes\n  ** within this range, this ensures that no other locks are held on the\n  ** database. \n  */\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int tErrno = 0;\n\n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (unix)\\n\", pFile->h,\n      azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n      azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,\n      osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (unix)\\n\", pFile->h,\n            azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct.\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n\n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n  ){\n    rc = SQLITE_BUSY;\n    goto end_lock;\n  }\n\n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n      (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto end_lock;\n  }\n\n\n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  lock.l_len = 1L;\n  lock.l_whence = SEEK_SET;\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);\n    lock.l_start = PENDING_BYTE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }\n  }\n\n\n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n    assert( rc==SQLITE_OK );\n\n    /* Now get the read-lock */\n    lock.l_start = SHARED_FIRST;\n    lock.l_len = SHARED_SIZE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    }\n\n    /* Drop the temporary PENDING lock */\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 1L;\n    lock.l_type = F_UNLCK;\n    if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){\n      /* This could happen with a network mount */\n      tErrno = errno;\n      rc = SQLITE_IOERR_UNLOCK; \n    }\n\n    if( rc ){\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }else{\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n    ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    assert( 0!=pFile->eFileLock );\n    lock.l_type = F_WRLCK;\n\n    assert( eFileLock==RESERVED_LOCK || eFileLock==EXCLUSIVE_LOCK );\n    if( eFileLock==RESERVED_LOCK ){\n      lock.l_start = RESERVED_BYTE;\n      lock.l_len = 1L;\n    }else{\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n    }\n\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n  }\n  \n\n#ifdef SQLITE_DEBUG\n  /* Set up the transaction-counter change checking flags when\n  ** transitioning from a SHARED to a RESERVED lock.  The change\n  ** from SHARED to RESERVED marks the beginning of a normal\n  ** write operation (not a hot journal rollback).\n  */\n  if( rc==SQLITE_OK\n   && pFile->eFileLock<=SHARED_LOCK\n   && eFileLock==RESERVED_LOCK\n  ){\n    pFile->transCntrChng = 0;\n    pFile->dbUpdate = 0;\n    pFile->inNormalWrite = 1;\n  }\n#endif\n\n\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n\nend_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (unix)\\n\", pFile->h, azFileLock(eFileLock), \n      rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Add the file descriptor used by file handle pFile to the corresponding\n** pUnused list.\n*/\nstatic void setPendingFd(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p = pFile->pPreallocatedUnused;\n  p->pNext = pInode->pUnused;\n  pInode->pUnused = p;\n  pFile->h = -1;\n  pFile->pPreallocatedUnused = 0;\n  nUnusedFd++;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n** \n** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED\n** the byte range is divided into 2 parts and the first part is unlocked then\n** set to a read lock, then the other part is simply unlocked.  This works \n** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to \n** remove the write lock on a region when a read lock is set.\n*/\nstatic int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int rc = SQLITE_OK;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\\n\", pFile->h, eFileLock,\n      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n      osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n\n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    pFile->inNormalWrite = 0;\n#endif\n\n    /* downgrading to a shared lock on NFS involves clearing the write lock\n    ** before establishing the readlock - to avoid a race condition we downgrade\n    ** the lock in 2 blocks, so that part of the range will be covered by a \n    ** write lock until the rest is covered by a read lock:\n    **  1:   [WWWWW]\n    **  2:   [....W]\n    **  3:   [RRRRW]\n    **  4:   [RRRR.]\n    */\n    if( eFileLock==SHARED_LOCK ){\n#if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE\n      (void)handleNFSUnlock;\n      assert( handleNFSUnlock==0 );\n#endif\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n      if( handleNFSUnlock ){\n        int tErrno;               /* Error code from system call errors */\n        off_t divSize = SHARED_SIZE - 1;\n        \n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);\n          if( IS_LOCK_ERROR(rc) ){\n            storeLastErrno(pFile, tErrno);\n          }\n          goto end_unlock;\n        }\n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST+divSize;\n        lock.l_len = SHARED_SIZE-divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n      }else\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n      {\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = SHARED_SIZE;\n        if( unixFileLock(pFile, &lock) ){\n          /* In theory, the call to unixFileLock() cannot fail because another\n          ** process is holding an incompatible lock. If it does, this \n          ** indicates that the other process is not following the locking\n          ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning\n          ** SQLITE_BUSY would confuse the upper layer (in practice it causes \n          ** an assert to fail). */ \n          rc = SQLITE_IOERR_RDLOCK;\n          storeLastErrno(pFile, errno);\n          goto end_unlock;\n        }\n      }\n    }\n    lock.l_type = F_UNLCK;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );\n    if( unixFileLock(pFile, &lock)==0 ){\n      pInode->eFileLock = SHARED_LOCK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, errno);\n      goto end_unlock;\n    }\n  }\n  if( eFileLock==NO_LOCK ){\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      lock.l_type = F_UNLCK;\n      lock.l_whence = SEEK_SET;\n      lock.l_start = lock.l_len = 0L;\n      if( unixFileLock(pFile, &lock)==0 ){\n        pInode->eFileLock = NO_LOCK;\n      }else{\n        rc = SQLITE_IOERR_UNLOCK;\n        storeLastErrno(pFile, errno);\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n\n    /* Decrement the count of locks against this same file.  When the\n    ** count reaches zero, close any other file descriptors whose close\n    ** was deferred because of outstanding locks.\n    */\n    pInode->nLock--;\n    assert( pInode->nLock>=0 );\n    if( pInode->nLock==0 ){\n      closePendingFds(pFile);\n    }\n  }\n\nend_unlock:\n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int unixUnlock(sqlite3_file *id, int eFileLock){\n#if SQLITE_MAX_MMAP_SIZE>0\n  assert( eFileLock==SHARED_LOCK || ((unixFile *)id)->nFetchOut==0 );\n#endif\n  return posixUnlock(id, eFileLock, 0);\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int unixMapfile(unixFile *pFd, i64 nByte);\nstatic void unixUnmapfile(unixFile *pFd);\n#endif\n\n/*\n** This function performs the parts of the \"close file\" operation \n** common to all locking schemes. It closes the directory and file\n** handles, if they are valid, and sets all fields of the unixFile\n** structure to 0.\n**\n** It is *not* necessary to hold the mutex when this routine is called,\n** even on VxWorks.  A mutex will be acquired on VxWorks by the\n** vxworksReleaseFileId() routine.\n*/\nstatic int closeUnixFile(sqlite3_file *id){\n  unixFile *pFile = (unixFile*)id;\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixUnmapfile(pFile);\n#endif\n  if( pFile->h>=0 ){\n    robust_close(pFile, pFile->h, __LINE__);\n    pFile->h = -1;\n  }\n#if OS_VXWORKS\n  if( pFile->pId ){\n    if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n      osUnlink(pFile->pId->zCanonicalName);\n    }\n    vxworksReleaseFileId(pFile->pId);\n    pFile->pId = 0;\n  }\n#endif\n#ifdef SQLITE_UNLINK_AFTER_CLOSE\n  if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n    osUnlink(pFile->zPath);\n    sqlite3_free(*(char**)&pFile->zPath);\n    pFile->zPath = 0;\n  }\n#endif\n  OSTRACE((\"CLOSE   %-3d\\n\", pFile->h));\n  OpenCounter(-1);\n  sqlite3_free(pFile->pPreallocatedUnused);\n  memset(pFile, 0, sizeof(unixFile));\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.\n*/\nstatic int unixClose(sqlite3_file *id){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile *)id;\n  verifyDbFile(pFile);\n  unixUnlock(id, NO_LOCK);\n  unixEnterMutex();\n\n  /* unixFile.pInode is always valid here. Otherwise, a different close\n  ** routine (e.g. nolockClose()) would be called instead.\n  */\n  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );\n  if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->pUnused list.  It will be automatically closed \n    ** when the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  releaseInodeInfo(pFile);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n/************** End of the posix advisory lock implementation *****************\n******************************************************************************/\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){\n  UNUSED_PARAMETER(NotUsed);\n  *pResOut = 0;\n  return SQLITE_OK;\n}\nstatic int nolockLock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\nstatic int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int nolockClose(sqlite3_file *id) {\n  return closeUnixFile(id);\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************* Begin dot-file Locking ******************************\n**\n** The dotfile locking implementation uses the existence of separate lock\n** files (really a directory) to control access to the database.  This works\n** on just about every filesystem imaginable.  But there are serious downsides:\n**\n**    (1)  There is zero concurrency.  A single reader blocks all other\n**         connections from reading or writing the database.\n**\n**    (2)  An application crash or power loss can leave stale lock files\n**         sitting around that need to be cleared manually.\n**\n** Nevertheless, a dotlock is an appropriate locking mode for use if no\n** other locking strategy is available.\n**\n** Dotfile locking works by creating a subdirectory in the same directory as\n** the database and with the same name but with a \".lock\" extension added.\n** The existence of a lock directory implies an EXCLUSIVE lock.  All other\n** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.\n*/\n\n/*\n** The file suffix added to the data base filename in order to create the\n** lock directory.\n*/\n#define DOTLOCK_SUFFIX \".lock\"\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n**\n** In dotfile locking, either a lock exists or it does not.  So in this\n** variation of CheckReservedLock(), *pResOut is set to true if any lock\n** is held on the file and false if the file is unlocked.\n*/\nstatic int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  reserved = osAccess((const char*)pFile->lockingContext, 0)==0;\n  OSTRACE((\"TEST WR-LOCK %d %d %d (dotlock)\\n\", pFile->h, rc, reserved));\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n**\n** With dotfile locking, we really only support state (4): EXCLUSIVE.\n** But we track the other locking levels internally.\n*/\nstatic int dotlockLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc = SQLITE_OK;\n\n\n  /* If we have any lock, then the lock file already exists.  All we have\n  ** to do is adjust our internal record of the lock level.\n  */\n  if( pFile->eFileLock > NO_LOCK ){\n    pFile->eFileLock = eFileLock;\n    /* Always update the timestamp on the old file */\n#ifdef HAVE_UTIME\n    utime(zLockFile, NULL);\n#else\n    utimes(zLockFile, NULL);\n#endif\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  rc = osMkdir(zLockFile, 0777);\n  if( rc<0 ){\n    /* failed to open/create the lock directory */\n    int tErrno = errno;\n    if( EEXIST == tErrno ){\n      rc = SQLITE_BUSY;\n    } else {\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n    return rc;\n  } \n  \n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** When the locking level reaches NO_LOCK, delete the lock file.\n*/\nstatic int dotlockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (dotlock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n\n  /* To downgrade to shared, simply update our internal notion of the\n  ** lock state.  No need to mess with the file on disk.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    pFile->eFileLock = SHARED_LOCK;\n    return SQLITE_OK;\n  }\n  \n  /* To fully unlock the database, delete the lock file */\n  assert( eFileLock==NO_LOCK );\n  rc = osRmdir(zLockFile);\n  if( rc<0 ){\n    int tErrno = errno;\n    if( tErrno==ENOENT ){\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.  Make sure the lock has been released before closing.\n*/\nstatic int dotlockClose(sqlite3_file *id) {\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  dotlockUnlock(id, NO_LOCK);\n  sqlite3_free(pFile->lockingContext);\n  return closeUnixFile(id);\n}\n/****************** End of the dot-file lock implementation *******************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin flock Locking ********************************\n**\n** Use the flock() system call to do file locking.\n**\n** flock() locking is like dot-file locking in that the various\n** fine-grain locking levels supported by SQLite are collapsed into\n** a single exclusive lock.  In other words, SHARED, RESERVED, and\n** PENDING locks are the same thing as an EXCLUSIVE lock.  SQLite\n** still works when you do this, but concurrency is reduced since\n** only a single process can be reading the database at a time.\n**\n** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off\n*/\n#if SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** Retry flock() calls that fail with EINTR\n*/\n#ifdef EINTR\nstatic int robust_flock(int fd, int op){\n  int rc;\n  do{ rc = flock(fd,op); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n#else\n# define robust_flock(a,b) flock(a,b)\n#endif\n     \n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int flockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    /* attempt to get the lock */\n    int lrc = robust_flock(pFile->h, LOCK_EX | LOCK_NB);\n    if( !lrc ){\n      /* got the lock, unlock it */\n      lrc = robust_flock(pFile->h, LOCK_UN);\n      if ( lrc ) {\n        int tErrno = errno;\n        /* unlock failed with an error */\n        lrc = SQLITE_IOERR_UNLOCK; \n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    } else {\n      int tErrno = errno;\n      reserved = 1;\n      /* someone else might have it reserved */\n      lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); \n      if( IS_LOCK_ERROR(lrc) ){\n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (flock)\\n\", pFile->h, rc, reserved));\n\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_OK;\n    reserved=1;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** flock() only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int flockLock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n\n  assert( pFile );\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  \n  if (robust_flock(pFile->h, LOCK_EX | LOCK_NB)) {\n    int tErrno = errno;\n    /* didn't get, must be busy */\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n  } else {\n    /* got it, set the type and return ok */\n    pFile->eFileLock = eFileLock;\n  }\n  OSTRACE((\"LOCK    %d %s %s (flock)\\n\", pFile->h, azFileLock(eFileLock), \n           rc==SQLITE_OK ? \"ok\" : \"failed\"));\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_BUSY;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int flockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  \n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (flock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really, unlock. */\n  if( robust_flock(pFile->h, LOCK_UN) ){\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n    return SQLITE_OK;\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n    return SQLITE_IOERR_UNLOCK;\n  }else{\n    pFile->eFileLock = NO_LOCK;\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Close a file.\n*/\nstatic int flockClose(sqlite3_file *id) {\n  assert( id!=0 );\n  flockUnlock(id, NO_LOCK);\n  return closeUnixFile(id);\n}\n\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */\n\n/******************* End of the flock lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************ Begin Named Semaphore Locking ************************\n**\n** Named semaphore locking is only supported on VxWorks.\n**\n** Semaphore locking is like dot-lock and flock in that it really only\n** supports EXCLUSIVE locking.  Only a single process can read or write\n** the database file at a time.  This reduces potential concurrency, but\n** makes the lock implementation much easier.\n*/\n#if OS_VXWORKS\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    sem_t *pSem = pFile->pInode->pSem;\n\n    if( sem_trywait(pSem)==-1 ){\n      int tErrno = errno;\n      if( EAGAIN != tErrno ){\n        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);\n        storeLastErrno(pFile, tErrno);\n      } else {\n        /* someone else has the lock when we are in NO_LOCK */\n        reserved = (pFile->eFileLock < SHARED_LOCK);\n      }\n    }else{\n      /* we could have it if we want it */\n      sem_post(pSem);\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (sem)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** Semaphore locks only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int semXLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n  int rc = SQLITE_OK;\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    rc = SQLITE_OK;\n    goto sem_end_lock;\n  }\n  \n  /* lock semaphore now but bail out when already locked. */\n  if( sem_trywait(pSem)==-1 ){\n    rc = SQLITE_BUSY;\n    goto sem_end_lock;\n  }\n\n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n\n sem_end_lock:\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int semXUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n\n  assert( pFile );\n  assert( pSem );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (sem)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really unlock. */\n  if ( sem_post(pSem)==-1 ) {\n    int rc, tErrno = errno;\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n ** Close a file.\n */\nstatic int semXClose(sqlite3_file *id) {\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    semXUnlock(id, NO_LOCK);\n    assert( pFile );\n    unixEnterMutex();\n    releaseInodeInfo(pFile);\n    unixLeaveMutex();\n    closeUnixFile(id);\n  }\n  return SQLITE_OK;\n}\n\n#endif /* OS_VXWORKS */\n/*\n** Named semaphore locking is only available on VxWorks.\n**\n*************** End of the named semaphore lock implementation ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Begin AFP Locking *********************************\n**\n** AFP is the Apple Filing Protocol.  AFP is a network filesystem found\n** on Apple Macintosh computers - both OS9 and OSX.\n**\n** Third-party implementations of AFP are available.  But this code here\n** only works on OSX.\n*/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n** The afpLockingContext structure contains all afp lock specific state\n*/\ntypedef struct afpLockingContext afpLockingContext;\nstruct afpLockingContext {\n  int reserved;\n  const char *dbPath;             /* Name of the open file */\n};\n\nstruct ByteRangeLockPB2\n{\n  unsigned long long offset;        /* offset to first byte to lock */\n  unsigned long long length;        /* nbr of bytes to lock */\n  unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */\n  unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */\n  unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */\n  int fd;                           /* file desc to assoc this lock with */\n};\n\n#define afpfsByteRangeLock2FSCTL        _IOWR('z', 23, struct ByteRangeLockPB2)\n\n/*\n** This is a utility for setting or clearing a bit-range lock on an\n** AFP filesystem.\n** \n** Return SQLITE_OK on success, SQLITE_BUSY on failure.\n*/\nstatic int afpSetLock(\n  const char *path,              /* Name of the file to be locked or unlocked */\n  unixFile *pFile,               /* Open file descriptor on path */\n  unsigned long long offset,     /* First byte to be locked */\n  unsigned long long length,     /* Number of bytes to lock */\n  int setLockFlag                /* True to set lock.  False to clear lock */\n){\n  struct ByteRangeLockPB2 pb;\n  int err;\n  \n  pb.unLockFlag = setLockFlag ? 0 : 1;\n  pb.startEndFlag = 0;\n  pb.offset = offset;\n  pb.length = length; \n  pb.fd = pFile->h;\n  \n  OSTRACE((\"AFPSETLOCK [%s] for %d%s in range %llx:%llx\\n\", \n    (setLockFlag?\"ON\":\"OFF\"), pFile->h, (pb.fd==-1?\"[testval-1]\":\"\"),\n    offset, length));\n  err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);\n  if ( err==-1 ) {\n    int rc;\n    int tErrno = errno;\n    OSTRACE((\"AFPSETLOCK failed to fsctl() '%s' %d %s\\n\",\n             path, tErrno, strerror(tErrno)));\n#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS\n    rc = SQLITE_BUSY;\n#else\n    rc = sqliteErrorFromPosixError(tErrno,\n                    setLockFlag ? SQLITE_IOERR_LOCK : SQLITE_IOERR_UNLOCK);\n#endif /* SQLITE_IGNORE_AFP_LOCK_ERRORS */\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc;\n  } else {\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int afpCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  afpLockingContext *context;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  context = (afpLockingContext *) pFile->lockingContext;\n  if( context->reserved ){\n    *pResOut = 1;\n    return SQLITE_OK;\n  }\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it.\n   */\n  if( !reserved ){\n    /* lock the RESERVED byte */\n    int lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);  \n    if( SQLITE_OK==lrc ){\n      /* if we succeeded in taking the reserved lock, unlock it to restore\n      ** the original state */\n      lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n    } else {\n      /* if we failed to get the lock then someone else must have it */\n      reserved = 1;\n    }\n    if( IS_LOCK_ERROR(lrc) ){\n      rc=lrc;\n    }\n  }\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (afp)\\n\", pFile->h, rc, reserved));\n  \n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int afpLock(sqlite3_file *id, int eFileLock){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode = pFile->pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  \n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (afp)\\n\", pFile->h,\n           azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n           azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (afp)\\n\", pFile->h,\n           azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n  \n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n     ){\n    rc = SQLITE_BUSY;\n    goto afp_end_lock;\n  }\n  \n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n     (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto afp_end_lock;\n  }\n    \n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    int failed;\n    failed = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 1);\n    if (failed) {\n      rc = failed;\n      goto afp_end_lock;\n    }\n  }\n  \n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    int lrc1, lrc2, lrc1Errno = 0;\n    long lk, mask;\n    \n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n        \n    mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;\n    /* Now get the read-lock SHARED_LOCK */\n    /* note that the quality of the randomness doesn't matter that much */\n    lk = random(); \n    pInode->sharedByte = (lk & mask)%(SHARED_SIZE - 1);\n    lrc1 = afpSetLock(context->dbPath, pFile, \n          SHARED_FIRST+pInode->sharedByte, 1, 1);\n    if( IS_LOCK_ERROR(lrc1) ){\n      lrc1Errno = pFile->lastErrno;\n    }\n    /* Drop the temporary PENDING lock */\n    lrc2 = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    \n    if( IS_LOCK_ERROR(lrc1) ) {\n      storeLastErrno(pFile, lrc1Errno);\n      rc = lrc1;\n      goto afp_end_lock;\n    } else if( IS_LOCK_ERROR(lrc2) ){\n      rc = lrc2;\n      goto afp_end_lock;\n    } else if( lrc1 != SQLITE_OK ) {\n      rc = lrc1;\n    } else {\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n     ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    int failed = 0;\n    assert( 0!=pFile->eFileLock );\n    if (eFileLock >= RESERVED_LOCK && pFile->eFileLock < RESERVED_LOCK) {\n        /* Acquire a RESERVED lock */\n        failed = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);\n      if( !failed ){\n        context->reserved = 1;\n      }\n    }\n    if (!failed && eFileLock == EXCLUSIVE_LOCK) {\n      /* Acquire an EXCLUSIVE lock */\n        \n      /* Remove the shared lock before trying the range.  we'll need to \n      ** reestablish the shared lock if we can't get the  afpUnlock\n      */\n      if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST +\n                         pInode->sharedByte, 1, 0)) ){\n        int failed2 = SQLITE_OK;\n        /* now attemmpt to get the exclusive lock range */\n        failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, \n                               SHARED_SIZE, 1);\n        if( failed && (failed2 = afpSetLock(context->dbPath, pFile, \n                       SHARED_FIRST + pInode->sharedByte, 1, 1)) ){\n          /* Can't reestablish the shared lock.  Sqlite can't deal, this is\n          ** a critical I/O error\n          */\n          rc = ((failed & 0xff) == SQLITE_IOERR) ? failed2 : \n               SQLITE_IOERR_LOCK;\n          goto afp_end_lock;\n        } \n      }else{\n        rc = failed; \n      }\n    }\n    if( failed ){\n      rc = failed;\n    }\n  }\n  \n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n  \nafp_end_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (afp)\\n\", pFile->h, azFileLock(eFileLock), \n         rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int afpUnlock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  int skipShared = 0;\n#ifdef SQLITE_TEST\n  int h = pFile->h;\n#endif\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n           osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n    SimulateIOErrorBenign(1);\n    SimulateIOError( h=(-1) )\n    SimulateIOErrorBenign(0);\n    \n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    assert( pFile->inNormalWrite==0\n           || pFile->dbUpdate==0\n           || pFile->transCntrChng==1 );\n    pFile->inNormalWrite = 0;\n#endif\n    \n    if( pFile->eFileLock==EXCLUSIVE_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);\n      if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){\n        /* only re-establish the shared lock if necessary */\n        int sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);\n      } else {\n        skipShared = 1;\n      }\n    }\n    if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    } \n    if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){\n      rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n      if( !rc ){ \n        context->reserved = 0; \n      }\n    }\n    if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){\n      pInode->eFileLock = SHARED_LOCK;\n    }\n  }\n  if( rc==SQLITE_OK && eFileLock==NO_LOCK ){\n\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      SimulateIOErrorBenign(1);\n      SimulateIOError( h=(-1) )\n      SimulateIOErrorBenign(0);\n      if( !skipShared ){\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);\n      }\n      if( !rc ){\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pInode->nLock--;\n      assert( pInode->nLock>=0 );\n      if( pInode->nLock==0 ){\n        closePendingFds(pFile);\n      }\n    }\n  }\n  \n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Close a file & cleanup AFP specific locking context \n*/\nstatic int afpClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  afpUnlock(id, NO_LOCK);\n  unixEnterMutex();\n  if( pFile->pInode && pFile->pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->aPending.  It will be automatically closed when\n    ** the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  releaseInodeInfo(pFile);\n  sqlite3_free(pFile->lockingContext);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the AFP lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  If you don't compile for a mac, then the \"unix-afp\"\n** VFS is not available.\n**\n********************* End of the AFP lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n*************************** Begin NFS Locking ********************************/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n ** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n ** must be either NO_LOCK or SHARED_LOCK.\n **\n ** If the locking level of the file descriptor is already at or below\n ** the requested locking level, this routine is a no-op.\n */\nstatic int nfsUnlock(sqlite3_file *id, int eFileLock){\n  return posixUnlock(id, eFileLock, 1);\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the NFS lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  \n**\n********************* End of the NFS lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n**************** Non-locking sqlite3_file methods *****************************\n**\n** The next division contains implementations for all methods of the \n** sqlite3_file object other than the locking methods.  The locking\n** methods were defined in divisions above (one locking method per\n** division).  Those methods that are common to all locking modes\n** are gather together into this division.\n*/\n\n/*\n** Seek to the offset passed as the second argument, then read cnt \n** bytes into pBuf. Return the number of bytes actually read.\n**\n** NB:  If you define USE_PREAD or USE_PREAD64, then it might also\n** be necessary to define _XOPEN_SOURCE to be 500.  This varies from\n** one system to another.  Since SQLite does not define USE_PREAD\n** in any form by default, we will not attempt to define _XOPEN_SOURCE.\n** See tickets #2741 and #2681.\n**\n** To avoid stomping the errno value on a failed read the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){\n  int got;\n  int prior = 0;\n#if (!defined(USE_PREAD) && !defined(USE_PREAD64))\n  i64 newOffset;\n#endif\n  TIMER_START;\n  assert( cnt==(cnt&0x1ffff) );\n  assert( id->h>2 );\n  do{\n#if defined(USE_PREAD)\n    got = osPread(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#elif defined(USE_PREAD64)\n    got = osPread64(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#else\n    newOffset = lseek(id->h, offset, SEEK_SET);\n    SimulateIOError( newOffset = -1 );\n    if( newOffset<0 ){\n      storeLastErrno((unixFile*)id, errno);\n      return -1;\n    }\n    got = osRead(id->h, pBuf, cnt);\n#endif\n    if( got==cnt ) break;\n    if( got<0 ){\n      if( errno==EINTR ){ got = 1; continue; }\n      prior = 0;\n      storeLastErrno((unixFile*)id,  errno);\n      break;\n    }else if( got>0 ){\n      cnt -= got;\n      offset += got;\n      prior += got;\n      pBuf = (void*)(got + (char*)pBuf);\n    }\n  }while( got>0 );\n  TIMER_END;\n  OSTRACE((\"READ    %-3d %5d %7lld %llu\\n\",\n            id->h, got+prior, offset-prior, TIMER_ELAPSED));\n  return got+prior;\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int unixRead(\n  sqlite3_file *id, \n  void *pBuf, \n  int amt,\n  sqlite3_int64 offset\n){\n  unixFile *pFile = (unixFile *)id;\n  int got;\n  assert( id );\n  assert( offset>=0 );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n  got = seekAndRead(pFile, offset, pBuf, amt);\n  if( got==amt ){\n    return SQLITE_OK;\n  }else if( got<0 ){\n    /* lastErrno set by seekAndRead */\n    return SQLITE_IOERR_READ;\n  }else{\n    storeLastErrno(pFile, 0);   /* not a system error */\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[got], 0, amt-got);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n}\n\n/*\n** Attempt to seek the file-descriptor passed as the first argument to\n** absolute offset iOff, then attempt to write nBuf bytes of data from\n** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, \n** return the actual number of bytes written (which may be less than\n** nBuf).\n*/\nstatic int seekAndWriteFd(\n  int fd,                         /* File descriptor to write to */\n  i64 iOff,                       /* File offset to begin writing at */\n  const void *pBuf,               /* Copy data from this buffer to the file */\n  int nBuf,                       /* Size of buffer pBuf in bytes */\n  int *piErrno                    /* OUT: Error number if error occurs */\n){\n  int rc = 0;                     /* Value returned by system call */\n\n  assert( nBuf==(nBuf&0x1ffff) );\n  assert( fd>2 );\n  assert( piErrno!=0 );\n  nBuf &= 0x1ffff;\n  TIMER_START;\n\n#if defined(USE_PREAD)\n  do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );\n#elif defined(USE_PREAD64)\n  do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);\n#else\n  do{\n    i64 iSeek = lseek(fd, iOff, SEEK_SET);\n    SimulateIOError( iSeek = -1 );\n    if( iSeek<0 ){\n      rc = -1;\n      break;\n    }\n    rc = osWrite(fd, pBuf, nBuf);\n  }while( rc<0 && errno==EINTR );\n#endif\n\n  TIMER_END;\n  OSTRACE((\"WRITE   %-3d %5d %7lld %llu\\n\", fd, rc, iOff, TIMER_ELAPSED));\n\n  if( rc<0 ) *piErrno = errno;\n  return rc;\n}\n\n\n/*\n** Seek to the offset in id->offset then read cnt bytes into pBuf.\n** Return the number of bytes actually read.  Update the offset.\n**\n** To avoid stomping the errno value on a failed write the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){\n  return seekAndWriteFd(id->h, offset, pBuf, cnt, &id->lastErrno);\n}\n\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int unixWrite(\n  sqlite3_file *id, \n  const void *pBuf, \n  int amt,\n  sqlite3_int64 offset \n){\n  unixFile *pFile = (unixFile*)id;\n  int wrote = 0;\n  assert( id );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* If we are doing a normal write to a database file (as opposed to\n  ** doing a hot-journal rollback or a write to some file other than a\n  ** normal database file) then record the fact that the database\n  ** has changed.  If the transaction counter is modified, record that\n  ** fact too.\n  */\n  if( pFile->inNormalWrite ){\n    pFile->dbUpdate = 1;  /* The database has been modified */\n    if( offset<=24 && offset+amt>=27 ){\n      int rc;\n      char oldCntr[4];\n      SimulateIOErrorBenign(1);\n      rc = seekAndRead(pFile, 24, oldCntr, 4);\n      SimulateIOErrorBenign(0);\n      if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){\n        pFile->transCntrChng = 1;  /* The transaction counter has changed */\n      }\n    }\n  }\n#endif\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n \n  while( (wrote = seekAndWrite(pFile, offset, pBuf, amt))<amt && wrote>0 ){\n    amt -= wrote;\n    offset += wrote;\n    pBuf = &((char*)pBuf)[wrote];\n  }\n  SimulateIOError(( wrote=(-1), amt=1 ));\n  SimulateDiskfullError(( wrote=0, amt=1 ));\n\n  if( amt>wrote ){\n    if( wrote<0 && pFile->lastErrno!=ENOSPC ){\n      /* lastErrno set by seekAndWrite */\n      return SQLITE_IOERR_WRITE;\n    }else{\n      storeLastErrno(pFile, 0); /* not a system error */\n      return SQLITE_FULL;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occurring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** We do not trust systems to provide a working fdatasync().  Some do.\n** Others do no.  To be safe, we will stick with the (slightly slower)\n** fsync(). If you know that your system does support fdatasync() correctly,\n** then simply compile with -Dfdatasync=fdatasync or -DHAVE_FDATASYNC\n*/\n#if !defined(fdatasync) && !HAVE_FDATASYNC\n# define fdatasync fsync\n#endif\n\n/*\n** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not\n** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently\n** only available on Mac OS X.  But that could change.\n*/\n#ifdef F_FULLFSYNC\n# define HAVE_FULLFSYNC 1\n#else\n# define HAVE_FULLFSYNC 0\n#endif\n\n\n/*\n** The fsync() system call does not work as advertised on many\n** unix systems.  The following procedure is an attempt to make\n** it work better.\n**\n** The SQLITE_NO_SYNC macro disables all fsync()s.  This is useful\n** for testing when we want to run through the test suite quickly.\n** You are strongly advised *not* to deploy with SQLITE_NO_SYNC\n** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash\n** or power failure will likely corrupt the database file.\n**\n** SQLite sets the dataOnly flag if the size of the file is unchanged.\n** The idea behind dataOnly is that it should only write the file content\n** to disk, not the inode.  We only set dataOnly if the file size is \n** unchanged since the file size is part of the inode.  However, \n** Ted Ts'o tells us that fdatasync() will also write the inode if the\n** file size has changed.  The only real difference between fdatasync()\n** and fsync(), Ted tells us, is that fdatasync() will not flush the\n** inode if the mtime or owner or other inode attributes have changed.\n** We only care about the file size, not the other file attributes, so\n** as far as SQLite is concerned, an fdatasync() is always adequate.\n** So, we always use fdatasync() if it is available, regardless of\n** the value of the dataOnly flag.\n*/\nstatic int full_fsync(int fd, int fullSync, int dataOnly){\n  int rc;\n\n  /* The following \"ifdef/elif/else/\" block has the same structure as\n  ** the one below. It is replicated here solely to avoid cluttering \n  ** up the real code with the UNUSED_PARAMETER() macros.\n  */\n#ifdef SQLITE_NO_SYNC\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#elif HAVE_FULLFSYNC\n  UNUSED_PARAMETER(dataOnly);\n#else\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#endif\n\n  /* Record the number of times that we do a normal fsync() and \n  ** FULLSYNC.  This is used during testing to verify that this procedure\n  ** gets called with the correct arguments.\n  */\n#ifdef SQLITE_TEST\n  if( fullSync ) sqlite3_fullsync_count++;\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op.  But go ahead and call fstat() to validate the file\n  ** descriptor as we need a method to provoke a failure during\n  ** coverate testing.\n  */\n#ifdef SQLITE_NO_SYNC\n  {\n    struct stat buf;\n    rc = osFstat(fd, &buf);\n  }\n#elif HAVE_FULLFSYNC\n  if( fullSync ){\n    rc = osFcntl(fd, F_FULLFSYNC, 0);\n  }else{\n    rc = 1;\n  }\n  /* If the FULLFSYNC failed, fall back to attempting an fsync().\n  ** It shouldn't be possible for fullfsync to fail on the local \n  ** file system (on OSX), so failure indicates that FULLFSYNC\n  ** isn't supported for this file system. So, attempt an fsync \n  ** and (for now) ignore the overhead of a superfluous fcntl call.  \n  ** It'd be better to detect fullfsync support once and avoid \n  ** the fcntl call every time sync is called.\n  */\n  if( rc ) rc = fsync(fd);\n\n#elif defined(__APPLE__)\n  /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly\n  ** so currently we default to the macro that redefines fdatasync to fsync\n  */\n  rc = fsync(fd);\n#else \n  rc = fdatasync(fd);\n#if OS_VXWORKS\n  if( rc==-1 && errno==ENOTSUP ){\n    rc = fsync(fd);\n  }\n#endif /* OS_VXWORKS */\n#endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */\n\n  if( OS_VXWORKS && rc!= -1 ){\n    rc = 0;\n  }\n  return rc;\n}\n\n/*\n** Open a file descriptor to the directory containing file zFilename.\n** If successful, *pFd is set to the opened file descriptor and\n** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM\n** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined\n** value.\n**\n** The directory file descriptor is used for only one thing - to\n** fsync() a directory to make sure file creation and deletion events\n** are flushed to disk.  Such fsyncs are not needed on newer\n** journaling filesystems, but are required on older filesystems.\n**\n** This routine can be overridden using the xSetSysCall interface.\n** The ability to override this routine was added in support of the\n** chromium sandbox.  Opening a directory is a security risk (we are\n** told) so making it overrideable allows the chromium sandbox to\n** replace this routine with a harmless no-op.  To make this routine\n** a no-op, replace it with a stub that returns SQLITE_OK but leaves\n** *pFd set to a negative number.\n**\n** If SQLITE_OK is returned, the caller is responsible for closing\n** the file descriptor *pFd using close().\n*/\nstatic int openDirectory(const char *zFilename, int *pFd){\n  int ii;\n  int fd = -1;\n  char zDirname[MAX_PATHNAME+1];\n\n  sqlite3_snprintf(MAX_PATHNAME, zDirname, \"%s\", zFilename);\n  for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--);\n  if( ii>0 ){\n    zDirname[ii] = '\\0';\n  }else{\n    if( zDirname[0]!='/' ) zDirname[0] = '.';\n    zDirname[1] = 0;\n  }\n  fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);\n  if( fd>=0 ){\n    OSTRACE((\"OPENDIR %-3d %s\\n\", fd, zDirname));\n  }\n  *pFd = fd;\n  if( fd>=0 ) return SQLITE_OK;\n  return unixLogError(SQLITE_CANTOPEN_BKPT, \"openDirectory\", zDirname);\n}\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n**\n** If dataOnly==0 then both the file itself and its metadata (file\n** size, access time, etc) are synced.  If dataOnly!=0 then only the\n** file data is synced.\n**\n** Under Unix, also make sure that the directory entry for the file\n** has been created by fsync-ing the directory that contains the file.\n** If we do not do this and we encounter a power failure, the directory\n** entry for the journal might not exist after we reboot.  The next\n** SQLite to access the file will not know that the journal exists (because\n** the directory entry for the journal was never created) and the transaction\n** will not roll back - possibly leading to database corruption.\n*/\nstatic int unixSync(sqlite3_file *id, int flags){\n  int rc;\n  unixFile *pFile = (unixFile*)id;\n\n  int isDataOnly = (flags&SQLITE_SYNC_DATAONLY);\n  int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL;\n\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  assert( pFile );\n  OSTRACE((\"SYNC    %-3d\\n\", pFile->h));\n  rc = full_fsync(pFile->h, isFullsync, isDataOnly);\n  SimulateIOError( rc=1 );\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_FSYNC, \"full_fsync\", pFile->zPath);\n  }\n\n  /* Also fsync the directory containing the file if the DIRSYNC flag\n  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)\n  ** are unable to fsync a directory, so ignore errors on the fsync.\n  */\n  if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){\n    int dirfd;\n    OSTRACE((\"DIRSYNC %s (have_fullfsync=%d fullsync=%d)\\n\", pFile->zPath,\n            HAVE_FULLFSYNC, isFullsync));\n    rc = osOpenDirectory(pFile->zPath, &dirfd);\n    if( rc==SQLITE_OK ){\n      full_fsync(dirfd, 0, 0);\n      robust_close(pFile, dirfd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n    pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;\n  }\n  return rc;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int unixTruncate(sqlite3_file *id, i64 nByte){\n  unixFile *pFile = (unixFile *)id;\n  int rc;\n  assert( pFile );\n  SimulateIOError( return SQLITE_IOERR_TRUNCATE );\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  rc = robust_ftruncate(pFile->h, nByte);\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n  }else{\n#ifdef SQLITE_DEBUG\n    /* If we are doing a normal write to a database file (as opposed to\n    ** doing a hot-journal rollback or a write to some file other than a\n    ** normal database file) and we truncate the file to zero length,\n    ** that effectively updates the change counter.  This might happen\n    ** when restoring a database using the backup API from a zero-length\n    ** source.\n    */\n    if( pFile->inNormalWrite && nByte==0 ){\n      pFile->transCntrChng = 1;\n    }\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n    /* If the file was just truncated to a size smaller than the currently\n    ** mapped region, reduce the effective mapping size as well. SQLite will\n    ** use read() and write() to access data beyond this point from now on.  \n    */\n    if( nByte<pFile->mmapSize ){\n      pFile->mmapSize = nByte;\n    }\n#endif\n\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int unixFileSize(sqlite3_file *id, i64 *pSize){\n  int rc;\n  struct stat buf;\n  assert( id );\n  rc = osFstat(((unixFile*)id)->h, &buf);\n  SimulateIOError( rc=1 );\n  if( rc!=0 ){\n    storeLastErrno((unixFile*)id, errno);\n    return SQLITE_IOERR_FSTAT;\n  }\n  *pSize = buf.st_size;\n\n  /* When opening a zero-size database, the findInodeInfo() procedure\n  ** writes a single byte into that file in order to work around a bug\n  ** in the OS-X msdos filesystem.  In order to avoid problems with upper\n  ** layers, we need to report this file size as zero even though it is\n  ** really 1.   Ticket #3260.\n  */\n  if( *pSize==1 ) *pSize = 0;\n\n\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Handler for proxy-locking file-control verbs.  Defined below in the\n** proxying locking division.\n*/\nstatic int proxyFileControl(sqlite3_file*,int,void*);\n#endif\n\n/* \n** This function is called to handle the SQLITE_FCNTL_SIZE_HINT \n** file-control operation.  Enlarge the database to nBytes in size\n** (rounded up to the next chunk-size).  If the database is already\n** nBytes or larger, this routine is a no-op.\n*/\nstatic int fcntlSizeHint(unixFile *pFile, i64 nByte){\n  if( pFile->szChunk>0 ){\n    i64 nSize;                    /* Required file size */\n    struct stat buf;              /* Used to hold return values of fstat() */\n   \n    if( osFstat(pFile->h, &buf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n\n    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;\n    if( nSize>(i64)buf.st_size ){\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n      /* The code below is handling the return value of osFallocate() \n      ** correctly. posix_fallocate() is defined to \"returns zero on success, \n      ** or an error number on  failure\". See the manpage for details. */\n      int err;\n      do{\n        err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);\n      }while( err==EINTR );\n      if( err ) return SQLITE_IOERR_WRITE;\n#else\n      /* If the OS does not have posix_fallocate(), fake it. Write a \n      ** single byte to the last byte in each block that falls entirely\n      ** within the extended region. Then, if required, a single byte\n      ** at offset (nSize-1), to set the size of the file correctly.\n      ** This is a similar technique to that used by glibc on systems\n      ** that do not have a real fallocate() call.\n      */\n      int nBlk = buf.st_blksize;  /* File-system block size */\n      int nWrite = 0;             /* Number of bytes written by seekAndWrite */\n      i64 iWrite;                 /* Next offset to write to */\n\n      iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;\n      assert( iWrite>=buf.st_size );\n      assert( ((iWrite+1)%nBlk)==0 );\n      for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){\n        if( iWrite>=nSize ) iWrite = nSize - 1;\n        nWrite = seekAndWrite(pFile, iWrite, \"\", 1);\n        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;\n      }\n#endif\n    }\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){\n    int rc;\n    if( pFile->szChunk<=0 ){\n      if( robust_ftruncate(pFile->h, nByte) ){\n        storeLastErrno(pFile, errno);\n        return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n      }\n    }\n\n    rc = unixMapfile(pFile, nByte);\n    return rc;\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward declaration */\nstatic int unixGetTempname(int nBuf, char *zBuf);\n\n/*\n** Information and control of an open file handle.\n*/\nstatic int unixFileControl(sqlite3_file *id, int op, void *pArg){\n  unixFile *pFile = (unixFile*)id;\n  switch( op ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE);\n      return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->eFileLock;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = pFile->lastErrno;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      int rc;\n      SimulateIOErrorBenign(1);\n      rc = fcntlSizeHint(pFile, *(i64 *)pArg);\n      SimulateIOErrorBenign(0);\n      return rc;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      unixModeBit(pFile, UNIXFILE_PERSIST_WAL, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );\n      if( zTFile ){\n        unixGetTempname(pFile->pVfs->mxPathname, zTFile);\n        *(char**)pArg = zTFile;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_HAS_MOVED: {\n      *(int*)pArg = fileHasMoved(pFile);\n      return SQLITE_OK;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (size_t) and passed\n      ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a\n      ** 64-bit type. */\n      if( newLimit>0 && sizeof(size_t)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          unixUnmapfile(pFile);\n          rc = unixMapfile(pFile, -1);\n        }\n      }\n      return rc;\n    }\n#endif\n#ifdef SQLITE_DEBUG\n    /* The pager calls this method to signal that it has done\n    ** a rollback and that the database is therefore unchanged and\n    ** it hence it is OK for the transaction change counter to be\n    ** unchanged.\n    */\n    case SQLITE_FCNTL_DB_UNCHANGED: {\n      ((unixFile*)id)->dbUpdate = 0;\n      return SQLITE_OK;\n    }\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE:\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      return proxyFileControl(id,op,pArg);\n    }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */\n  }\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** If pFd->sectorSize is non-zero when this function is called, it is a\n** no-op. Otherwise, the values of pFd->sectorSize and \n** pFd->deviceCharacteristics are set according to the file-system \n** characteristics. \n**\n** There are two versions of this function. One for QNX and one for all\n** other systems.\n*/\n#ifndef __QNXNTO__\nstatic void setDeviceCharacteristics(unixFile *pFd){\n  assert( pFd->deviceCharacteristics==0 || pFd->sectorSize!=0 );\n  if( pFd->sectorSize==0 ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    int res;\n    u32 f = 0;\n\n    /* Check for support for F2FS atomic batch writes. */\n    res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f);\n    if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){\n      pFd->deviceCharacteristics = SQLITE_IOCAP_BATCH_ATOMIC;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    /* Set the POWERSAFE_OVERWRITE flag if requested. */\n    if( pFd->ctrlFlags & UNIXFILE_PSOW ){\n      pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n    }\n\n    pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#else\n#include <sys/dcmd_blk.h>\n#include <sys/statvfs.h>\nstatic void setDeviceCharacteristics(unixFile *pFile){\n  if( pFile->sectorSize == 0 ){\n    struct statvfs fsInfo;\n       \n    /* Set defaults for non-supported filesystems */\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n    pFile->deviceCharacteristics = 0;\n    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {\n      return pFile->sectorSize;\n    }\n\n    if( !strcmp(fsInfo.f_basetype, \"tmp\") ) {\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"etfs\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* etfs cluster size writes are atomic */\n        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx6\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx4\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"dos\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else{\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        0;\n    }\n  }\n  /* Last chance verification.  If the sector size isn't a multiple of 512\n  ** then it isn't valid.*/\n  if( pFile->sectorSize % 512 != 0 ){\n    pFile->deviceCharacteristics = 0;\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#endif\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int unixSectorSize(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->sectorSize;\n}\n\n/*\n** Return the device characteristics for the file.\n**\n** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.\n** However, that choice is controversial since technically the underlying\n** file system does not always provide powersafe overwrites.  (In other\n** words, after a power-loss event, parts of the file that were never\n** written might end up being altered.)  However, non-PSOW behavior is very,\n** very rare.  And asserting PSOW makes a large reduction in the amount\n** of required I/O for journaling, since a lot of padding is eliminated.\n**  Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control\n** available to turn it off and URI query parameter available to turn it off.\n*/\nstatic int unixDeviceCharacteristics(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->deviceCharacteristics;\n}\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n\n/*\n** Return the system page size.\n**\n** This function should not be called directly by other code in this file. \n** Instead, it should be called via macro osGetpagesize().\n*/\nstatic int unixGetpagesize(void){\n#if OS_VXWORKS\n  return 1024;\n#elif defined(_BSD_SOURCE)\n  return getpagesize();\n#else\n  return (int)sysconf(_SC_PAGESIZE);\n#endif\n}\n\n#endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Object used to represent an shared memory buffer.  \n**\n** When multiple threads all reference the same wal-index, each thread\n** has its own unixShm object, but they all point to a single instance\n** of this unixShmNode object.  In other words, each wal-index is opened\n** only once per process.\n**\n** Each unixShmNode object is connected to a single unixInodeInfo object.\n** We could coalesce this object into unixInodeInfo, but that would mean\n** every open file that does not use shared memory (in other words, most\n** open files) would have to carry around this extra information.  So\n** the unixInodeInfo object contains a pointer to this unixShmNode object\n** and the unixShmNode object is created only when needed.\n**\n** unixMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**\n** The following fields are read-only after the object is created:\n** \n**      fid\n**      zFilename\n**\n** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and\n** unixMutexHeld() is true when reading or writing any other field\n** in this structure.\n*/\nstruct unixShmNode {\n  unixInodeInfo *pInode;     /* unixInodeInfo that owns this SHM node */\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the mmapped file */\n  int h;                     /* Open file descriptor */\n  int szRegion;              /* Size of shared-memory regions */\n  u16 nRegion;               /* Size of array apRegion */\n  u8 isReadonly;             /* True if read-only */\n  char **apRegion;           /* Array of mapped shared-memory regions */\n  int nRef;                  /* Number of unixShm objects pointing to this */\n  unixShm *pFirst;           /* All unixShm objects pointing to this */\n#ifdef SQLITE_DEBUG\n  u8 exclMask;               /* Mask of exclusive locks held */\n  u8 sharedMask;             /* Mask of shared locks held */\n  u8 nextShmId;              /* Next available unixShm.id value */\n#endif\n};\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    unixShm.pFile\n**    unixShm.id\n**\n** All other fields are read/write.  The unixShm.pFile->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct unixShm {\n  unixShmNode *pShmNode;     /* The underlying unixShmNode object */\n  unixShm *pNext;            /* Next unixShm with the same unixShmNode */\n  u8 hasMutex;               /* True if holding the unixShmNode mutex */\n  u8 id;                     /* Id of this connection within its unixShmNode */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n};\n\n/*\n** Constants used for locking\n*/\n#define UNIX_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)         /* first lock byte */\n#define UNIX_SHM_DMS    (UNIX_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply posix advisory locks for all bytes from ofst through ofst+n-1.\n**\n** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking\n** otherwise.\n*/\nstatic int unixShmSystemLock(\n  unixFile *pFile,       /* Open connection to the WAL file */\n  int lockType,          /* F_UNLCK, F_RDLCK, or F_WRLCK */\n  int ofst,              /* First byte of the locking range */\n  int n                  /* Number of bytes to lock */\n){\n  unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */\n  struct flock f;        /* The posix advisory locking structure */\n  int rc = SQLITE_OK;    /* Result code form fcntl() */\n\n  /* Access to the unixShmNode object is serialized by the caller */\n  pShmNode = pFile->pInode->pShmNode;\n  assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );\n\n  /* Shared locks never span more than one byte */\n  assert( n==1 || lockType!=F_RDLCK );\n\n  /* Locks are within range */\n  assert( n>=1 && n<=SQLITE_SHM_NLOCK );\n\n  if( pShmNode->h>=0 ){\n    /* Initialize the locking parameters */\n    memset(&f, 0, sizeof(f));\n    f.l_type = lockType;\n    f.l_whence = SEEK_SET;\n    f.l_start = ofst;\n    f.l_len = n;\n\n    rc = osFcntl(pShmNode->h, F_SETLK, &f);\n    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;\n  }\n\n  /* Update the global lock state and do debug tracing */\n#ifdef SQLITE_DEBUG\n  { u16 mask;\n  OSTRACE((\"SHM-LOCK \"));\n  mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);\n  if( rc==SQLITE_OK ){\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask &= ~mask;\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask |= mask;\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d ok\", ofst));\n      pShmNode->exclMask |= mask;\n      pShmNode->sharedMask &= ~mask;\n    }\n  }else{\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d failed\", ofst));\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock failed\"));\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d failed\", ofst));\n    }\n  }\n  OSTRACE((\" - afterwards %03x,%03x\\n\",\n           pShmNode->sharedMask, pShmNode->exclMask));\n  }\n#endif\n\n  return rc;        \n}\n\n/*\n** Return the minimum number of 32KB shm regions that should be mapped at\n** a time, assuming that each mapping must be an integer multiple of the\n** current system page-size.\n**\n** Usually, this is 1. The exception seems to be systems that are configured\n** to use 64KB pages - in this case each mapping must cover at least two\n** shm regions.\n*/\nstatic int unixShmRegionPerMap(void){\n  int shmsz = 32*1024;            /* SHM region size */\n  int pgsz = osGetpagesize();   /* System page size */\n  assert( ((pgsz-1)&pgsz)==0 );   /* Page size must be a power of 2 */\n  if( pgsz<shmsz ) return 1;\n  return pgsz/shmsz;\n}\n\n/*\n** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void unixShmPurge(unixFile *pFd){\n  unixShmNode *p = pFd->pInode->pShmNode;\n  assert( unixMutexHeld() );\n  if( p && ALWAYS(p->nRef==0) ){\n    int nShmPerMap = unixShmRegionPerMap();\n    int i;\n    assert( p->pInode==pFd->pInode );\n    sqlite3_mutex_free(p->mutex);\n    for(i=0; i<p->nRegion; i+=nShmPerMap){\n      if( p->h>=0 ){\n        osMunmap(p->apRegion[i], p->szRegion);\n      }else{\n        sqlite3_free(p->apRegion[i]);\n      }\n    }\n    sqlite3_free(p->apRegion);\n    if( p->h>=0 ){\n      robust_close(pFd, p->h, __LINE__);\n      p->h = -1;\n    }\n    p->pInode->pShmNode = 0;\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Open a shared-memory area associated with open database file pDbFd.  \n** This particular implementation uses mmapped files.\n**\n** The file used to implement shared-memory is in the same directory\n** as the open database file and has the same name as the open database\n** file with the \"-shm\" suffix added.  For example, if the database file\n** is \"/home/user1/config.db\" then the file that is created and mmapped\n** for shared memory will be called \"/home/user1/config.db-shm\".  \n**\n** Another approach to is to use files in /dev/shm or /dev/tmp or an\n** some other tmpfs mount. But if a file in a different directory\n** from the database file is used, then differing access permissions\n** or a chroot() might cause two different processes on the same\n** database to end up using different files for shared memory - \n** meaning that their memory would not really be shared - resulting\n** in database corruption.  Nevertheless, this tmpfs file usage\n** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY=\"/dev/shm\"\n** or the equivalent.  The use of the SQLITE_SHM_DIRECTORY compile-time\n** option results in an incompatible build of SQLite;  builds of SQLite\n** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the\n** same database file at the same time, database corruption will likely\n** result. The SQLITE_SHM_DIRECTORY compile-time option is considered\n** \"unsupported\" and may go away in a future SQLite release.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n**\n** If the original database file (pDbFd) is using the \"unix-excl\" VFS\n** that means that an exclusive lock is held on the database file and\n** that no other processes are able to read or write the database.  In\n** that case, we do not really need shared memory.  No shared memory\n** file is created.  The shared memory will be simulated with heap memory.\n*/\nstatic int unixOpenSharedMemory(unixFile *pDbFd){\n  struct unixShm *p = 0;          /* The connection to be opened */\n  struct unixShmNode *pShmNode;   /* The underlying mmapped file */\n  int rc;                         /* Result code */\n  unixInodeInfo *pInode;          /* The inode of fd */\n  char *zShmFilename;             /* Name of the file used for SHM */\n  int nShmFilename;               /* Size of the SHM filename in bytes */\n\n  /* Allocate space for the new unixShm object. */\n  p = sqlite3_malloc64( sizeof(*p) );\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  assert( pDbFd->pShm==0 );\n\n  /* Check to see if a unixShmNode object already exists. Reuse an existing\n  ** one if present. Create a new one if necessary.\n  */\n  unixEnterMutex();\n  pInode = pDbFd->pInode;\n  pShmNode = pInode->pShmNode;\n  if( pShmNode==0 ){\n    struct stat sStat;                 /* fstat() info for database file */\n#ifndef SQLITE_SHM_DIRECTORY\n    const char *zBasePath = pDbFd->zPath;\n#endif\n\n    /* Call fstat() to figure out the permissions on the database file. If\n    ** a new *-shm file is created, an attempt will be made to create it\n    ** with the same permissions.\n    */\n    if( osFstat(pDbFd->h, &sStat) ){\n      rc = SQLITE_IOERR_FSTAT;\n      goto shm_open_err;\n    }\n\n#ifdef SQLITE_SHM_DIRECTORY\n    nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;\n#else\n    nShmFilename = 6 + (int)strlen(zBasePath);\n#endif\n    pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename );\n    if( pShmNode==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto shm_open_err;\n    }\n    memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);\n    zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1];\n#ifdef SQLITE_SHM_DIRECTORY\n    sqlite3_snprintf(nShmFilename, zShmFilename, \n                     SQLITE_SHM_DIRECTORY \"/sqlite-shm-%x-%x\",\n                     (u32)sStat.st_ino, (u32)sStat.st_dev);\n#else\n    sqlite3_snprintf(nShmFilename, zShmFilename, \"%s-shm\", zBasePath);\n    sqlite3FileSuffix3(pDbFd->zPath, zShmFilename);\n#endif\n    pShmNode->h = -1;\n    pDbFd->pInode->pShmNode = pShmNode;\n    pShmNode->pInode = pDbFd->pInode;\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->mutex==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    if( pInode->bProcessLock==0 ){\n      int openFlags = O_RDWR | O_CREAT;\n      if( sqlite3_uri_boolean(pDbFd->zPath, \"readonly_shm\", 0) ){\n        openFlags = O_RDONLY;\n        pShmNode->isReadonly = 1;\n      }\n      pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777));\n      if( pShmNode->h<0 ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zShmFilename);\n        goto shm_open_err;\n      }\n\n      /* If this process is running as root, make sure that the SHM file\n      ** is owned by the same user that owns the original database.  Otherwise,\n      ** the original owner will not be able to connect.\n      */\n      robustFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);\n  \n      /* Check to see if another process is holding the dead-man switch.\n      ** If not, truncate the file to zero length. \n      */\n      rc = SQLITE_OK;\n      if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){\n        if( robust_ftruncate(pShmNode->h, 0) ){\n          rc = unixLogError(SQLITE_IOERR_SHMOPEN, \"ftruncate\", zShmFilename);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);\n      }\n      if( rc ) goto shm_open_err;\n    }\n  }\n\n  /* Make the new connection a child of the unixShmNode */\n  p->pShmNode = pShmNode;\n#ifdef SQLITE_DEBUG\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  unixLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the unixEnterMutex() mutex and the pointer from the\n  ** new (struct unixShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex \n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  unixShmPurge(pDbFd);       /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  unixLeaveMutex();\n  return rc;\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the \n** shared-memory associated with the database file fd. Shared-memory regions \n** are numbered starting from zero. Each shared-memory region is szRegion \n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the bExtend parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If \n** bExtend is non-zero and the requested shared-memory region has not yet \n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes \n** address space (if it is not already), *pp is set to point to the mapped \n** memory and SQLITE_OK returned.\n*/\nstatic int unixShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  unixFile *pDbFd = (unixFile*)fd;\n  unixShm *p;\n  unixShmNode *pShmNode;\n  int rc = SQLITE_OK;\n  int nShmPerMap = unixShmRegionPerMap();\n  int nReqRegion;\n\n  /* If the shared-memory file has not yet been opened, open it now. */\n  if( pDbFd->pShm==0 ){\n    rc = unixOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  p = pDbFd->pShm;\n  pShmNode = p->pShmNode;\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  /* Minimum number of regions required to be mapped. */\n  nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;\n\n  if( pShmNode->nRegion<nReqRegion ){\n    char **apNew;                      /* New apRegion[] array */\n    int nByte = nReqRegion*szRegion;   /* Minimum required file size */\n    struct stat sStat;                 /* Used by fstat() */\n\n    pShmNode->szRegion = szRegion;\n\n    if( pShmNode->h>=0 ){\n      /* The requested region is not mapped into this processes address space.\n      ** Check to see if it has been allocated (i.e. if the wal-index file is\n      ** large enough to contain the requested region).\n      */\n      if( osFstat(pShmNode->h, &sStat) ){\n        rc = SQLITE_IOERR_SHMSIZE;\n        goto shmpage_out;\n      }\n  \n      if( sStat.st_size<nByte ){\n        /* The requested memory region does not exist. If bExtend is set to\n        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.\n        */\n        if( !bExtend ){\n          goto shmpage_out;\n        }\n\n        /* Alternatively, if bExtend is true, extend the file. Do this by\n        ** writing a single byte to the end of each (OS) page being\n        ** allocated or extended. Technically, we need only write to the\n        ** last page in order to extend the file. But writing to all new\n        ** pages forces the OS to allocate them immediately, which reduces\n        ** the chances of SIGBUS while accessing the mapped region later on.\n        */\n        else{\n          static const int pgsz = 4096;\n          int iPg;\n\n          /* Write to the last byte of each newly allocated or extended page */\n          assert( (nByte % pgsz)==0 );\n          for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){\n            int x = 0;\n            if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, \"\", 1, &x)!=1 ){\n              const char *zFile = pShmNode->zFilename;\n              rc = unixLogError(SQLITE_IOERR_SHMSIZE, \"write\", zFile);\n              goto shmpage_out;\n            }\n          }\n        }\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (char **)sqlite3_realloc(\n        pShmNode->apRegion, nReqRegion*sizeof(char *)\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->apRegion = apNew;\n    while( pShmNode->nRegion<nReqRegion ){\n      int nMap = szRegion*nShmPerMap;\n      int i;\n      void *pMem;\n      if( pShmNode->h>=0 ){\n        pMem = osMmap(0, nMap,\n            pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, \n            MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion\n        );\n        if( pMem==MAP_FAILED ){\n          rc = unixLogError(SQLITE_IOERR_SHMMAP, \"mmap\", pShmNode->zFilename);\n          goto shmpage_out;\n        }\n      }else{\n        pMem = sqlite3_malloc64(szRegion);\n        if( pMem==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto shmpage_out;\n        }\n        memset(pMem, 0, szRegion);\n      }\n\n      for(i=0; i<nShmPerMap; i++){\n        pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];\n      }\n      pShmNode->nRegion += nShmPerMap;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    *pp = pShmNode->apRegion[iRegion];\n  }else{\n    *pp = 0;\n  }\n  if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n**\n** Note that the relationship between SHAREd and EXCLUSIVE locks is a little\n** different here than in posix.  In xShmLock(), one can go from unlocked\n** to shared and back or from unlocked to exclusive and back.  But one may\n** not go from shared to exclusive or from exclusive to shared.\n*/\nstatic int unixShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  unixFile *pDbFd = (unixFile*)fd;      /* Connection holding shared memory */\n  unixShm *p = pDbFd->pShm;             /* The shared memory being locked */\n  unixShm *pX;                          /* For looping over all siblings */\n  unixShmNode *pShmNode = p->pShmNode;  /* The underlying file iNode */\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  mask = (1<<(ofst+n)) - (1<<ofst);\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    } \n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n  \n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK shmid-%d, pid-%d got %03x,%03x\\n\",\n           p->id, osGetpid(0), p->sharedMask, p->exclMask));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.  \n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void unixShmBarrier(\n  sqlite3_file *fd                /* Database file holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();         /* compiler-defined memory barrier */\n  unixEnterMutex();               /* Also mutex, for redundancy */\n  unixLeaveMutex();\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying \n** storage if deleteFlag is true.\n**\n** If there is no shared memory associated with the connection then this\n** routine is a harmless no-op.\n*/\nstatic int unixShmUnmap(\n  sqlite3_file *fd,               /* The underlying database file */\n  int deleteFlag                  /* Delete shared-memory if true */\n){\n  unixShm *p;                     /* The connection to be closed */\n  unixShmNode *pShmNode;          /* The underlying shared-memory file */\n  unixShm **pp;                   /* For looping over sibling connections */\n  unixFile *pDbFd;                /* The underlying database file */\n\n  pDbFd = (unixFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  unixEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    if( deleteFlag && pShmNode->h>=0 ){\n      osUnlink(pShmNode->zFilename);\n    }\n    unixShmPurge(pDbFd);\n  }\n  unixLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n\n#else\n# define unixShmMap     0\n# define unixShmLock    0\n# define unixShmBarrier 0\n# define unixShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** If it is currently memory mapped, unmap file pFd.\n*/\nstatic void unixUnmapfile(unixFile *pFd){\n  assert( pFd->nFetchOut==0 );\n  if( pFd->pMapRegion ){\n    osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);\n    pFd->pMapRegion = 0;\n    pFd->mmapSize = 0;\n    pFd->mmapSizeActual = 0;\n  }\n}\n\n/*\n** Attempt to set the size of the memory mapping maintained by file \n** descriptor pFd to nNew bytes. Any existing mapping is discarded.\n**\n** If successful, this function sets the following variables:\n**\n**       unixFile.pMapRegion\n**       unixFile.mmapSize\n**       unixFile.mmapSizeActual\n**\n** If unsuccessful, an error message is logged via sqlite3_log() and\n** the three variables above are zeroed. In this case SQLite should\n** continue accessing the database using the xRead() and xWrite()\n** methods.\n*/\nstatic void unixRemapfile(\n  unixFile *pFd,                  /* File descriptor object */\n  i64 nNew                        /* Required mapping size */\n){\n  const char *zErr = \"mmap\";\n  int h = pFd->h;                      /* File descriptor open on db file */\n  u8 *pOrig = (u8 *)pFd->pMapRegion;   /* Pointer to current file mapping */\n  i64 nOrig = pFd->mmapSizeActual;     /* Size of pOrig region in bytes */\n  u8 *pNew = 0;                        /* Location of new mapping */\n  int flags = PROT_READ;               /* Flags to pass to mmap() */\n\n  assert( pFd->nFetchOut==0 );\n  assert( nNew>pFd->mmapSize );\n  assert( nNew<=pFd->mmapSizeMax );\n  assert( nNew>0 );\n  assert( pFd->mmapSizeActual>=pFd->mmapSize );\n  assert( MAP_FAILED!=0 );\n\n#ifdef SQLITE_MMAP_READWRITE\n  if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;\n#endif\n\n  if( pOrig ){\n#if HAVE_MREMAP\n    i64 nReuse = pFd->mmapSize;\n#else\n    const int szSyspage = osGetpagesize();\n    i64 nReuse = (pFd->mmapSize & ~(szSyspage-1));\n#endif\n    u8 *pReq = &pOrig[nReuse];\n\n    /* Unmap any pages of the existing mapping that cannot be reused. */\n    if( nReuse!=nOrig ){\n      osMunmap(pReq, nOrig-nReuse);\n    }\n\n#if HAVE_MREMAP\n    pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE);\n    zErr = \"mremap\";\n#else\n    pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse);\n    if( pNew!=MAP_FAILED ){\n      if( pNew!=pReq ){\n        osMunmap(pNew, nNew - nReuse);\n        pNew = 0;\n      }else{\n        pNew = pOrig;\n      }\n    }\n#endif\n\n    /* The attempt to extend the existing mapping failed. Free it. */\n    if( pNew==MAP_FAILED || pNew==0 ){\n      osMunmap(pOrig, nReuse);\n    }\n  }\n\n  /* If pNew is still NULL, try to create an entirely new mapping. */\n  if( pNew==0 ){\n    pNew = osMmap(0, nNew, flags, MAP_SHARED, h, 0);\n  }\n\n  if( pNew==MAP_FAILED ){\n    pNew = 0;\n    nNew = 0;\n    unixLogError(SQLITE_OK, zErr, pFd->zPath);\n\n    /* If the mmap() above failed, assume that all subsequent mmap() calls\n    ** will probably fail too. Fall back to using xRead/xWrite exclusively\n    ** in this case.  */\n    pFd->mmapSizeMax = 0;\n  }\n  pFd->pMapRegion = (void *)pNew;\n  pFd->mmapSize = pFd->mmapSizeActual = nNew;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if \n** there already exists a mapping for this file, and there are still \n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of \n** the mapping to create. Otherwise, if nByte is less than zero, then the \n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured \n** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int unixMapfile(unixFile *pFd, i64 nMap){\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    struct stat statbuf;          /* Low-level file information */\n    if( osFstat(pFd->h, &statbuf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n    nMap = statbuf.st_size;\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( nMap!=pFd->mmapSize ){\n    unixRemapfile(pFd, nMap);\n  }\n\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually \n** release the reference by calling unixUnfetch().\n*/\nstatic int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = unixMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a \n** reference obtained by an earlier call to unixFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the unixFetch() invocation. \n**\n** Or, if the third argument is NULL, then this function is being called \n** to inform the VFS layer that, according to POSIX, any existing mapping \n** may now be invalid and should be unmapped.\n*/\nstatic int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n  UNUSED_PARAMETER(iOff);\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding \n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    unixUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#else\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(p);\n  UNUSED_PARAMETER(iOff);\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This division contains definitions of sqlite3_io_methods objects that\n** implement various file locking strategies.  It also contains definitions\n** of \"finder\" functions.  A finder-function is used to locate the appropriate\n** sqlite3_io_methods object for a particular database file.  The pAppData\n** field of the sqlite3_vfs VFS objects are initialized to be pointers to\n** the correct finder-function for that VFS.\n**\n** Most finder functions return a pointer to a fixed sqlite3_io_methods\n** object.  The only interesting finder-function is autolockIoFinder, which\n** looks at the filesystem type and tries to guess the best locking\n** strategy from that.\n**\n** For finder-function F, two objects are created:\n**\n**    (1) The real finder-function named \"FImpt()\".\n**\n**    (2) A constant pointer to this function named just \"F\".\n**\n**\n** A pointer to the F pointer is used as the pAppData value for VFS\n** objects.  We have to do this instead of letting pAppData point\n** directly at the finder-function since C90 rules prevent a void*\n** from be cast into a function pointer.\n**\n**\n** Each instance of this macro generates two objects:\n**\n**   *  A constant sqlite3_io_methods object call METHOD that has locking\n**      methods CLOSE, LOCK, UNLOCK, CKRESLOCK.\n**\n**   *  An I/O method finder function called FINDER that returns a pointer\n**      to the METHOD object in the previous bullet.\n*/\n#define IOMETHODS(FINDER,METHOD,VERSION,CLOSE,LOCK,UNLOCK,CKLOCK,SHMMAP)     \\\nstatic const sqlite3_io_methods METHOD = {                                   \\\n   VERSION,                    /* iVersion */                                \\\n   CLOSE,                      /* xClose */                                  \\\n   unixRead,                   /* xRead */                                   \\\n   unixWrite,                  /* xWrite */                                  \\\n   unixTruncate,               /* xTruncate */                               \\\n   unixSync,                   /* xSync */                                   \\\n   unixFileSize,               /* xFileSize */                               \\\n   LOCK,                       /* xLock */                                   \\\n   UNLOCK,                     /* xUnlock */                                 \\\n   CKLOCK,                     /* xCheckReservedLock */                      \\\n   unixFileControl,            /* xFileControl */                            \\\n   unixSectorSize,             /* xSectorSize */                             \\\n   unixDeviceCharacteristics,  /* xDeviceCapabilities */                     \\\n   SHMMAP,                     /* xShmMap */                                 \\\n   unixShmLock,                /* xShmLock */                                \\\n   unixShmBarrier,             /* xShmBarrier */                             \\\n   unixShmUnmap,               /* xShmUnmap */                               \\\n   unixFetch,                  /* xFetch */                                  \\\n   unixUnfetch,                /* xUnfetch */                                \\\n};                                                                           \\\nstatic const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){   \\\n  UNUSED_PARAMETER(z); UNUSED_PARAMETER(p);                                  \\\n  return &METHOD;                                                            \\\n}                                                                            \\\nstatic const sqlite3_io_methods *(*const FINDER)(const char*,unixFile *p)    \\\n    = FINDER##Impl;\n\n/*\n** Here are all of the sqlite3_io_methods objects for each of the\n** locking strategies.  Functions that return pointers to these methods\n** are also created.\n*/\nIOMETHODS(\n  posixIoFinder,            /* Finder function name */\n  posixIoMethods,           /* sqlite3_io_methods object name */\n  3,                        /* shared memory and mmap are enabled */\n  unixClose,                /* xClose method */\n  unixLock,                 /* xLock method */\n  unixUnlock,               /* xUnlock method */\n  unixCheckReservedLock,    /* xCheckReservedLock method */\n  unixShmMap                /* xShmMap method */\n)\nIOMETHODS(\n  nolockIoFinder,           /* Finder function name */\n  nolockIoMethods,          /* sqlite3_io_methods object name */\n  3,                        /* shared memory is disabled */\n  nolockClose,              /* xClose method */\n  nolockLock,               /* xLock method */\n  nolockUnlock,             /* xUnlock method */\n  nolockCheckReservedLock,  /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\nIOMETHODS(\n  dotlockIoFinder,          /* Finder function name */\n  dotlockIoMethods,         /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  dotlockClose,             /* xClose method */\n  dotlockLock,              /* xLock method */\n  dotlockUnlock,            /* xUnlock method */\n  dotlockCheckReservedLock, /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n\n#if SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  flockIoFinder,            /* Finder function name */\n  flockIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  flockClose,               /* xClose method */\n  flockLock,                /* xLock method */\n  flockUnlock,              /* xUnlock method */\n  flockCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if OS_VXWORKS\nIOMETHODS(\n  semIoFinder,              /* Finder function name */\n  semIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  semXClose,                /* xClose method */\n  semXLock,                 /* xLock method */\n  semXUnlock,               /* xUnlock method */\n  semXCheckReservedLock,    /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  afpIoFinder,              /* Finder function name */\n  afpIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  afpClose,                 /* xClose method */\n  afpLock,                  /* xLock method */\n  afpUnlock,                /* xUnlock method */\n  afpCheckReservedLock,     /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/*\n** The proxy locking method is a \"super-method\" in the sense that it\n** opens secondary file descriptors for the conch and lock files and\n** it uses proxy, dot-file, AFP, and flock() locking methods on those\n** secondary files.  For this reason, the division that implements\n** proxy locking is located much further down in the file.  But we need\n** to go ahead and define the sqlite3_io_methods and finder function\n** for proxy locking here.  So we forward declare the I/O methods.\n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nstatic int proxyClose(sqlite3_file*);\nstatic int proxyLock(sqlite3_file*, int);\nstatic int proxyUnlock(sqlite3_file*, int);\nstatic int proxyCheckReservedLock(sqlite3_file*, int*);\nIOMETHODS(\n  proxyIoFinder,            /* Finder function name */\n  proxyIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  proxyClose,               /* xClose method */\n  proxyLock,                /* xLock method */\n  proxyUnlock,              /* xUnlock method */\n  proxyCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  nfsIoFinder,               /* Finder function name */\n  nfsIoMethods,              /* sqlite3_io_methods object name */\n  1,                         /* shared memory is disabled */\n  unixClose,                 /* xClose method */\n  unixLock,                  /* xLock method */\n  nfsUnlock,                 /* xUnlock method */\n  unixCheckReservedLock,     /* xCheckReservedLock method */\n  0                          /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/* \n** This \"finder\" function attempts to determine the best locking strategy \n** for the database file \"filePath\".  It then returns the sqlite3_io_methods\n** object that implements that strategy.\n**\n** This is for MacOSX only.\n*/\nstatic const sqlite3_io_methods *autolockIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* open file object for the database file */\n){\n  static const struct Mapping {\n    const char *zFilesystem;              /* Filesystem type name */\n    const sqlite3_io_methods *pMethods;   /* Appropriate locking method */\n  } aMap[] = {\n    { \"hfs\",    &posixIoMethods },\n    { \"ufs\",    &posixIoMethods },\n    { \"afpfs\",  &afpIoMethods },\n    { \"smbfs\",  &afpIoMethods },\n    { \"webdav\", &nolockIoMethods },\n    { 0, 0 }\n  };\n  int i;\n  struct statfs fsInfo;\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n  if( statfs(filePath, &fsInfo) != -1 ){\n    if( fsInfo.f_flags & MNT_RDONLY ){\n      return &nolockIoMethods;\n    }\n    for(i=0; aMap[i].zFilesystem; i++){\n      if( strcmp(fsInfo.f_fstypename, aMap[i].zFilesystem)==0 ){\n        return aMap[i].pMethods;\n      }\n    }\n  }\n\n  /* Default case. Handles, amongst others, \"nfs\".\n  ** Test byte-range lock using fcntl(). If the call succeeds, \n  ** assume that the file-system supports POSIX style locks. \n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    if( strcmp(fsInfo.f_fstypename, \"nfs\")==0 ){\n      return &nfsIoMethods;\n    } else {\n      return &posixIoMethods;\n    }\n  }else{\n    return &dotlockIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n\n#if OS_VXWORKS\n/*\n** This \"finder\" function for VxWorks checks to see if posix advisory\n** locking works.  If it does, then that is what is used.  If it does not\n** work, then fallback to named semaphore locking.\n*/\nstatic const sqlite3_io_methods *vxworksIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* the open file object */\n){\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n\n  /* Test if fcntl() is supported and use POSIX style locks.\n  ** Otherwise fall back to the named semaphore method.\n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    return &posixIoMethods;\n  }else{\n    return &semIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;\n\n#endif /* OS_VXWORKS */\n\n/*\n** An abstract type for a pointer to an IO method finder function:\n*/\ntypedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);\n\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n/*\n** Initialize the contents of the unixFile structure pointed to by pId.\n*/\nstatic int fillInUnixFile(\n  sqlite3_vfs *pVfs,      /* Pointer to vfs object */\n  int h,                  /* Open file descriptor of file being opened */\n  sqlite3_file *pId,      /* Write to the unixFile structure here */\n  const char *zFilename,  /* Name of the file being opened */\n  int ctrlFlags           /* Zero or more UNIXFILE_* values */\n){\n  const sqlite3_io_methods *pLockingStyle;\n  unixFile *pNew = (unixFile *)pId;\n  int rc = SQLITE_OK;\n\n  assert( pNew->pInode==NULL );\n\n  /* No locking occurs in temporary files */\n  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );\n\n  OSTRACE((\"OPEN    %-3d %s\\n\", h, zFilename));\n  pNew->h = h;\n  pNew->pVfs = pVfs;\n  pNew->zPath = zFilename;\n  pNew->ctrlFlags = (u8)ctrlFlags;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),\n                           \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pNew->ctrlFlags |= UNIXFILE_PSOW;\n  }\n  if( strcmp(pVfs->zName,\"unix-excl\")==0 ){\n    pNew->ctrlFlags |= UNIXFILE_EXCL;\n  }\n\n#if OS_VXWORKS\n  pNew->pId = vxworksFindFileId(zFilename);\n  if( pNew->pId==0 ){\n    ctrlFlags |= UNIXFILE_NOLOCK;\n    rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( ctrlFlags & UNIXFILE_NOLOCK ){\n    pLockingStyle = &nolockIoMethods;\n  }else{\n    pLockingStyle = (**(finder_type*)pVfs->pAppData)(zFilename, pNew);\n#if SQLITE_ENABLE_LOCKING_STYLE\n    /* Cache zFilename in the locking context (AFP and dotlock override) for\n    ** proxyLock activation is possible (remote proxy is based on db name)\n    ** zFilename remains valid until file is closed, to support */\n    pNew->lockingContext = (void*)zFilename;\n#endif\n  }\n\n  if( pLockingStyle == &posixIoMethods\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n    || pLockingStyle == &nfsIoMethods\n#endif\n  ){\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( rc!=SQLITE_OK ){\n      /* If an error occurred in findInodeInfo(), close the file descriptor\n      ** immediately, before releasing the mutex. findInodeInfo() may fail\n      ** in two scenarios:\n      **\n      **   (a) A call to fstat() failed.\n      **   (b) A malloc failed.\n      **\n      ** Scenario (b) may only occur if the process is holding no other\n      ** file descriptors open on the same file. If there were other file\n      ** descriptors on this file, then no malloc would be required by\n      ** findInodeInfo(). If this is the case, it is quite safe to close\n      ** handle h - as it is guaranteed that no posix locks will be released\n      ** by doing so.\n      **\n      ** If scenario (a) caused the error then things are not so safe. The\n      ** implicit assumption here is that if fstat() fails, things are in\n      ** such bad shape that dropping a lock or two doesn't matter much.\n      */\n      robust_close(pNew, h, __LINE__);\n      h = -1;\n    }\n    unixLeaveMutex();\n  }\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  else if( pLockingStyle == &afpIoMethods ){\n    /* AFP locking uses the file path so it needs to be included in\n    ** the afpLockingContext.\n    */\n    afpLockingContext *pCtx;\n    pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n    if( pCtx==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      /* NB: zFilename exists and remains valid until the file is closed\n      ** according to requirement F11141.  So we do not need to make a\n      ** copy of the filename. */\n      pCtx->dbPath = zFilename;\n      pCtx->reserved = 0;\n      srandomdev();\n      unixEnterMutex();\n      rc = findInodeInfo(pNew, &pNew->pInode);\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pNew->lockingContext);\n        robust_close(pNew, h, __LINE__);\n        h = -1;\n      }\n      unixLeaveMutex();        \n    }\n  }\n#endif\n\n  else if( pLockingStyle == &dotlockIoMethods ){\n    /* Dotfile locking uses the file path so it needs to be included in\n    ** the dotlockLockingContext \n    */\n    char *zLockFile;\n    int nFilename;\n    assert( zFilename!=0 );\n    nFilename = (int)strlen(zFilename) + 6;\n    zLockFile = (char *)sqlite3_malloc64(nFilename);\n    if( zLockFile==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_snprintf(nFilename, zLockFile, \"%s\" DOTLOCK_SUFFIX, zFilename);\n    }\n    pNew->lockingContext = zLockFile;\n  }\n\n#if OS_VXWORKS\n  else if( pLockingStyle == &semIoMethods ){\n    /* Named semaphore locking uses the file path so it needs to be\n    ** included in the semLockingContext\n    */\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){\n      char *zSemName = pNew->pInode->aSemName;\n      int n;\n      sqlite3_snprintf(MAX_PATHNAME, zSemName, \"/%s.sem\",\n                       pNew->pId->zCanonicalName);\n      for( n=1; zSemName[n]; n++ )\n        if( zSemName[n]=='/' ) zSemName[n] = '_';\n      pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1);\n      if( pNew->pInode->pSem == SEM_FAILED ){\n        rc = SQLITE_NOMEM_BKPT;\n        pNew->pInode->aSemName[0] = '\\0';\n      }\n    }\n    unixLeaveMutex();\n  }\n#endif\n  \n  storeLastErrno(pNew, 0);\n#if OS_VXWORKS\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n    h = -1;\n    osUnlink(zFilename);\n    pNew->ctrlFlags |= UNIXFILE_DELETE;\n  }\n#endif\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n  }else{\n    pNew->pMethod = pLockingStyle;\n    OpenCounter(+1);\n    verifyDbFile(pNew);\n  }\n  return rc;\n}\n\n/*\n** Return the name of a directory in which to put temporary files.\n** If no suitable temporary file directory can be found, return NULL.\n*/\nstatic const char *unixTempFileDir(void){\n  static const char *azDirs[] = {\n     0,\n     0,\n     \"/var/tmp\",\n     \"/usr/tmp\",\n     \"/tmp\",\n     \".\"\n  };\n  unsigned int i = 0;\n  struct stat buf;\n  const char *zDir = sqlite3_temp_directory;\n\n  if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n  if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n  while(1){\n    if( zDir!=0\n     && osStat(zDir, &buf)==0\n     && S_ISDIR(buf.st_mode)\n     && osAccess(zDir, 03)==0\n    ){\n      return zDir;\n    }\n    if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break;\n    zDir = azDirs[i++];\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name in zBuf.  zBuf must be allocated\n** by the calling process and must be big enough to hold at least\n** pVfs->mxPathname bytes.\n*/\nstatic int unixGetTempname(int nBuf, char *zBuf){\n  const char *zDir;\n  int iLimit = 0;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. \n  */\n  zBuf[0] = 0;\n  SimulateIOError( return SQLITE_IOERR );\n\n  zDir = unixTempFileDir();\n  if( zDir==0 ) return SQLITE_IOERR_GETTEMPPATH;\n  do{\n    u64 r;\n    sqlite3_randomness(sizeof(r), &r);\n    assert( nBuf>2 );\n    zBuf[nBuf-2] = 0;\n    sqlite3_snprintf(nBuf, zBuf, \"%s/\"SQLITE_TEMP_FILE_PREFIX\"%llx%c\",\n                     zDir, r, 0);\n    if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ) return SQLITE_ERROR;\n  }while( osAccess(zBuf,0)==0 );\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Routine to transform a unixFile into a proxy-locking unixFile.\n** Implementation in the proxy-lock division, but used by unixOpen()\n** if SQLITE_PREFER_PROXY_LOCKING is defined.\n*/\nstatic int proxyTransformUnixFile(unixFile*, const char*);\n#endif\n\n/*\n** Search for an unused file descriptor that was opened on the database \n** file (not a journal or master-journal file) identified by pathname\n** zPath with SQLITE_OPEN_XXX flags matching those passed as the second\n** argument to this function.\n**\n** Such a file descriptor may exist if a database connection was closed\n** but the associated file descriptor could not be closed because some\n** other file descriptor open on the same file is holding a file-lock.\n** Refer to comments in the unixClose() function and the lengthy comment\n** describing \"Posix Advisory Locking\" at the start of this file for \n** further details. Also, ticket #4018.\n**\n** If a suitable file descriptor is found, then it is returned. If no\n** such file descriptor is located, -1 is returned.\n*/\nstatic UnixUnusedFd *findReusableFd(const char *zPath, int flags){\n  UnixUnusedFd *pUnused = 0;\n\n  /* Do not search for an unused file descriptor on vxworks. Not because\n  ** vxworks would not benefit from the change (it might, we're not sure),\n  ** but because no way to test it is currently available. It is better \n  ** not to risk breaking vxworks support for the sake of such an obscure \n  ** feature.  */\n#if !OS_VXWORKS\n  struct stat sStat;                   /* Results of stat() call */\n\n  unixEnterMutex();\n\n  /* A stat() call may fail for various reasons. If this happens, it is\n  ** almost certain that an open() call on the same path will also fail.\n  ** For this reason, if an error occurs in the stat() call here, it is\n  ** ignored and -1 is returned. The caller will try to open a new file\n  ** descriptor on the same path, fail, and return an error to SQLite.\n  **\n  ** Even if a subsequent open() call does succeed, the consequences of\n  ** not searching for a reusable file descriptor are not dire.  */\n  if( nUnusedFd>0 && 0==osStat(zPath, &sStat) ){\n    unixInodeInfo *pInode;\n\n    pInode = inodeList;\n    while( pInode && (pInode->fileId.dev!=sStat.st_dev\n                     || pInode->fileId.ino!=(u64)sStat.st_ino) ){\n       pInode = pInode->pNext;\n    }\n    if( pInode ){\n      UnixUnusedFd **pp;\n      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));\n      pUnused = *pp;\n      if( pUnused ){\n        nUnusedFd--;\n        *pp = pUnused->pNext;\n      }\n    }\n  }\n  unixLeaveMutex();\n#endif    /* if !OS_VXWORKS */\n  return pUnused;\n}\n\n/*\n** Find the mode, uid and gid of file zFile. \n*/\nstatic int getFileMode(\n  const char *zFile,              /* File name */\n  mode_t *pMode,                  /* OUT: Permissions of zFile */\n  uid_t *pUid,                    /* OUT: uid of zFile. */\n  gid_t *pGid                     /* OUT: gid of zFile. */\n){\n  struct stat sStat;              /* Output of stat() on database file */\n  int rc = SQLITE_OK;\n  if( 0==osStat(zFile, &sStat) ){\n    *pMode = sStat.st_mode & 0777;\n    *pUid = sStat.st_uid;\n    *pGid = sStat.st_gid;\n  }else{\n    rc = SQLITE_IOERR_FSTAT;\n  }\n  return rc;\n}\n\n/*\n** This function is called by unixOpen() to determine the unix permissions\n** to create new files with. If no error occurs, then SQLITE_OK is returned\n** and a value suitable for passing as the third argument to open(2) is\n** written to *pMode. If an IO error occurs, an SQLite error code is \n** returned and the value of *pMode is not modified.\n**\n** In most cases, this routine sets *pMode to 0, which will become\n** an indication to robust_open() to create the file using\n** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.\n** But if the file being opened is a WAL or regular journal file, then \n** this function queries the file-system for the permissions on the \n** corresponding database file and sets *pMode to this value. Whenever \n** possible, WAL and journal files are created using the same permissions \n** as the associated database file.\n**\n** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the\n** original filename is unavailable.  But 8_3_NAMES is only used for\n** FAT filesystems and permissions do not matter there, so just use\n** the default permissions.\n*/\nstatic int findCreateFileMode(\n  const char *zPath,              /* Path of file (possibly) being created */\n  int flags,                      /* Flags passed as 4th argument to xOpen() */\n  mode_t *pMode,                  /* OUT: Permissions to open file with */\n  uid_t *pUid,                    /* OUT: uid to set on the file */\n  gid_t *pGid                     /* OUT: gid to set on the file */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  *pMode = 0;\n  *pUid = 0;\n  *pGid = 0;\n  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n    char zDb[MAX_PATHNAME+1];     /* Database file path */\n    int nDb;                      /* Number of valid bytes in zDb */\n\n    /* zPath is a path to a WAL or journal file. The following block derives\n    ** the path to the associated database file from zPath. This block handles\n    ** the following naming conventions:\n    **\n    **   \"<path to db>-journal\"\n    **   \"<path to db>-wal\"\n    **   \"<path to db>-journalNN\"\n    **   \"<path to db>-walNN\"\n    **\n    ** where NN is a decimal number. The NN naming schemes are \n    ** used by the test_multiplex.c module.\n    */\n    nDb = sqlite3Strlen30(zPath) - 1; \n    while( zPath[nDb]!='-' ){\n      /* In normal operation, the journal file name will always contain\n      ** a '-' character.  However in 8+3 filename mode, or if a corrupt\n      ** rollback journal specifies a master journal with a goofy name, then\n      ** the '-' might be missing. */\n      if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;\n      nDb--;\n    }\n    memcpy(zDb, zPath, nDb);\n    zDb[nDb] = '\\0';\n\n    rc = getFileMode(zDb, pMode, pUid, pGid);\n  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){\n    *pMode = 0600;\n  }else if( flags & SQLITE_OPEN_URI ){\n    /* If this is a main database file and the file was opened using a URI\n    ** filename, check for the \"modeof\" parameter. If present, interpret\n    ** its value as a filename and try to copy the mode, uid and gid from\n    ** that file.  */\n    const char *z = sqlite3_uri_parameter(zPath, \"modeof\");\n    if( z ){\n      rc = getFileMode(z, pMode, pUid, pGid);\n    }\n  }\n  return rc;\n}\n\n/*\n** Open the file zPath.\n** \n** Previously, the SQLite OS layer used three functions in place of this\n** one:\n**\n**     sqlite3OsOpenReadWrite();\n**     sqlite3OsOpenReadOnly();\n**     sqlite3OsOpenExclusive();\n**\n** These calls correspond to the following combinations of flags:\n**\n**     ReadWrite() ->     (READWRITE | CREATE)\n**     ReadOnly()  ->     (READONLY) \n**     OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE)\n**\n** The old OpenExclusive() accepted a boolean argument - \"delFlag\". If\n** true, the file was configured to be automatically deleted when the\n** file handle closed. To achieve the same effect using this new \n** interface, add the DELETEONCLOSE flag to those specified above for \n** OpenExclusive().\n*/\nstatic int unixOpen(\n  sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */\n  const char *zPath,           /* Pathname of file to be opened */\n  sqlite3_file *pFile,         /* The file descriptor to be filled in */\n  int flags,                   /* Input flags to control the opening */\n  int *pOutFlags               /* Output flags returned to SQLite core */\n){\n  unixFile *p = (unixFile *)pFile;\n  int fd = -1;                   /* File descriptor returned by open() */\n  int openFlags = 0;             /* Flags to pass to open() */\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n  int noLock;                    /* True to omit locking primitives */\n  int rc = SQLITE_OK;            /* Function Return Code */\n  int ctrlFlags = 0;             /* UNIXFILE_* flags */\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int isAutoProxy  = (flags & SQLITE_OPEN_AUTOPROXY);\n#endif\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  struct statfs fsInfo;\n#endif\n\n  /* If creating a master or main-file journal, this function will open\n  ** a file-descriptor on the directory too. The first time unixSync()\n  ** is called the directory file descriptor will be fsync()ed and close()d.\n  */\n  int syncDir = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL \n     || eType==SQLITE_OPEN_MAIN_JOURNAL \n     || eType==SQLITE_OPEN_WAL\n  ));\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char zTmpname[MAX_PATHNAME+2];\n  const char *zName = zPath;\n\n  /* Check the following statements are true: \n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and \n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never \n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB \n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL \n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL \n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  /* Detect a pid change and reset the PRNG.  There is a race condition\n  ** here such that two or more threads all trying to open databases at\n  ** the same instant might all reset the PRNG.  But multiple resets\n  ** are harmless.\n  */\n  if( randomnessPid!=osGetpid(0) ){\n    randomnessPid = osGetpid(0);\n    sqlite3_randomness(0,0);\n  }\n\n  memset(p, 0, sizeof(unixFile));\n\n  if( eType==SQLITE_OPEN_MAIN_DB ){\n    UnixUnusedFd *pUnused;\n    pUnused = findReusableFd(zName, flags);\n    if( pUnused ){\n      fd = pUnused->fd;\n    }else{\n      pUnused = sqlite3_malloc64(sizeof(*pUnused));\n      if( !pUnused ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    p->pPreallocatedUnused = pUnused;\n\n    /* Database filenames are double-zero terminated if they are not\n    ** URIs with parameters.  Hence, they can always be passed into\n    ** sqlite3_uri_parameter(). */\n    assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );\n\n  }else if( !zName ){\n    /* If zName is NULL, the upper layer is requesting a temp file. */\n    assert(isDelete && !syncDir);\n    rc = unixGetTempname(pVfs->mxPathname, zTmpname);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    zName = zTmpname;\n\n    /* Generated temporary filenames are always double-zero terminated\n    ** for use by sqlite3_uri_parameter(). */\n    assert( zName[strlen(zName)+1]==0 );\n  }\n\n  /* Determine the value of the flags parameter passed to POSIX function\n  ** open(). These must be calculated even if open() is not called, as\n  ** they may be stored as part of the file handle and used by the \n  ** 'conch file' locking functions later on.  */\n  if( isReadonly )  openFlags |= O_RDONLY;\n  if( isReadWrite ) openFlags |= O_RDWR;\n  if( isCreate )    openFlags |= O_CREAT;\n  if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);\n  openFlags |= (O_LARGEFILE|O_BINARY);\n\n  if( fd<0 ){\n    mode_t openMode;              /* Permissions to create file with */\n    uid_t uid;                    /* Userid for the file */\n    gid_t gid;                    /* Groupid for the file */\n    rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);\n    if( rc!=SQLITE_OK ){\n      assert( !p->pPreallocatedUnused );\n      assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );\n      return rc;\n    }\n    fd = robust_open(zName, openFlags, openMode);\n    OSTRACE((\"OPENX   %-3d %s 0%o\\n\", fd, zName, openFlags));\n    assert( !isExclusive || (openFlags & O_CREAT)!=0 );\n    if( fd<0 && errno!=EISDIR && isReadWrite ){\n      /* Failed to open the file for read/write access. Try read-only. */\n      flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);\n      openFlags &= ~(O_RDWR|O_CREAT);\n      flags |= SQLITE_OPEN_READONLY;\n      openFlags |= O_RDONLY;\n      isReadonly = 1;\n      fd = robust_open(zName, openFlags, openMode);\n    }\n    if( fd<0 ){\n      rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zName);\n      goto open_finished;\n    }\n\n    /* If this process is running as root and if creating a new rollback\n    ** journal or WAL file, set the ownership of the journal or WAL to be\n    ** the same as the original database.\n    */\n    if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n      robustFchown(fd, uid, gid);\n    }\n  }\n  assert( fd>=0 );\n  if( pOutFlags ){\n    *pOutFlags = flags;\n  }\n\n  if( p->pPreallocatedUnused ){\n    p->pPreallocatedUnused->fd = fd;\n    p->pPreallocatedUnused->flags = flags;\n  }\n\n  if( isDelete ){\n#if OS_VXWORKS\n    zPath = zName;\n#elif defined(SQLITE_UNLINK_AFTER_CLOSE)\n    zPath = sqlite3_mprintf(\"%s\", zName);\n    if( zPath==0 ){\n      robust_close(p, fd, __LINE__);\n      return SQLITE_NOMEM_BKPT;\n    }\n#else\n    osUnlink(zName);\n#endif\n  }\n#if SQLITE_ENABLE_LOCKING_STYLE\n  else{\n    p->openFlags = openFlags;\n  }\n#endif\n  \n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  if( fstatfs(fd, &fsInfo) == -1 ){\n    storeLastErrno(p, errno);\n    robust_close(p, fd, __LINE__);\n    return SQLITE_IOERR_ACCESS;\n  }\n  if (0 == strncmp(\"msdos\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n  if (0 == strncmp(\"exfat\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n#endif\n\n  /* Set up appropriate ctrlFlags */\n  if( isDelete )                ctrlFlags |= UNIXFILE_DELETE;\n  if( isReadonly )              ctrlFlags |= UNIXFILE_RDONLY;\n  noLock = eType!=SQLITE_OPEN_MAIN_DB;\n  if( noLock )                  ctrlFlags |= UNIXFILE_NOLOCK;\n  if( syncDir )                 ctrlFlags |= UNIXFILE_DIRSYNC;\n  if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n#if SQLITE_PREFER_PROXY_LOCKING\n  isAutoProxy = 1;\n#endif\n  if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){\n    char *envforce = getenv(\"SQLITE_FORCE_PROXY_LOCKING\");\n    int useProxy = 0;\n\n    /* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means \n    ** never use proxy, NULL means use proxy for non-local files only.  */\n    if( envforce!=NULL ){\n      useProxy = atoi(envforce)>0;\n    }else{\n      useProxy = !(fsInfo.f_flags&MNT_LOCAL);\n    }\n    if( useProxy ){\n      rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n      if( rc==SQLITE_OK ){\n        rc = proxyTransformUnixFile((unixFile*)pFile, \":auto:\");\n        if( rc!=SQLITE_OK ){\n          /* Use unixClose to clean up the resources added in fillInUnixFile \n          ** and clear all the structure's references.  Specifically, \n          ** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op \n          */\n          unixClose(pFile);\n          return rc;\n        }\n      }\n      goto open_finished;\n    }\n  }\n#endif\n  \n  assert( zPath==0 || zPath[0]=='/' \n      || eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL \n  );\n  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n\nopen_finished:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(p->pPreallocatedUnused);\n  }\n  return rc;\n}\n\n\n/*\n** Delete the file at zPath. If the dirSync argument is true, fsync()\n** the directory after deleting the file.\n*/\nstatic int unixDelete(\n  sqlite3_vfs *NotUsed,     /* VFS containing this as the xDelete method */\n  const char *zPath,        /* Name of file to be deleted */\n  int dirSync               /* If true, fsync() directory after deleting file */\n){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  if( osUnlink(zPath)==(-1) ){\n    if( errno==ENOENT\n#if OS_VXWORKS\n        || osAccess(zPath,0)!=0\n#endif\n    ){\n      rc = SQLITE_IOERR_DELETE_NOENT;\n    }else{\n      rc = unixLogError(SQLITE_IOERR_DELETE, \"unlink\", zPath);\n    }\n    return rc;\n  }\n#ifndef SQLITE_DISABLE_DIRSYNC\n  if( (dirSync & 1)!=0 ){\n    int fd;\n    rc = osOpenDirectory(zPath, &fd);\n    if( rc==SQLITE_OK ){\n      if( full_fsync(fd,0,0) ){\n        rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, \"fsync\", zPath);\n      }\n      robust_close(0, fd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Test the existence of or access permissions of file zPath. The\n** test performed depends on the value of flags:\n**\n**     SQLITE_ACCESS_EXISTS: Return 1 if the file exists\n**     SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable.\n**     SQLITE_ACCESS_READONLY: Return 1 if the file is readable.\n**\n** Otherwise return 0.\n*/\nstatic int unixAccess(\n  sqlite3_vfs *NotUsed,   /* The VFS containing this xAccess method */\n  const char *zPath,      /* Path of the file to examine */\n  int flags,              /* What do we want to learn about the zPath file? */\n  int *pResOut            /* Write result boolean here */\n){\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  assert( pResOut!=0 );\n\n  /* The spec says there are three possible values for flags.  But only\n  ** two of them are actually used */\n  assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );\n\n  if( flags==SQLITE_ACCESS_EXISTS ){\n    struct stat buf;\n    *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);\n  }else{\n    *pResOut = osAccess(zPath, W_OK|R_OK)==0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n**\n*/\nstatic int mkFullPathname(\n  const char *zPath,              /* Input path */\n  char *zOut,                     /* Output buffer */\n  int nOut                        /* Allocated size of buffer zOut */\n){\n  int nPath = sqlite3Strlen30(zPath);\n  int iOff = 0;\n  if( zPath[0]!='/' ){\n    if( osGetcwd(zOut, nOut-2)==0 ){\n      return unixLogError(SQLITE_CANTOPEN_BKPT, \"getcwd\", zPath);\n    }\n    iOff = sqlite3Strlen30(zOut);\n    zOut[iOff++] = '/';\n  }\n  if( (iOff+nPath+1)>nOut ){\n    /* SQLite assumes that xFullPathname() nul-terminates the output buffer\n    ** even if it returns an error.  */\n    zOut[iOff] = '\\0';\n    return SQLITE_CANTOPEN_BKPT;\n  }\n  sqlite3_snprintf(nOut-iOff, &zOut[iOff], \"%s\", zPath);\n  return SQLITE_OK;\n}\n\n/*\n** Turn a relative pathname into a full pathname. The relative path\n** is stored as a nul-terminated string in the buffer pointed to by\n** zPath. \n**\n** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes \n** (in this case, MAX_PATHNAME bytes). The full-path is written to\n** this buffer before returning.\n*/\nstatic int unixFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zPath,            /* Possibly relative input path */\n  int nOut,                     /* Size of output buffer in bytes */\n  char *zOut                    /* Output buffer */\n){\n#if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)\n  return mkFullPathname(zPath, zOut, nOut);\n#else\n  int rc = SQLITE_OK;\n  int nByte;\n  int nLink = 1;                /* Number of symbolic links followed so far */\n  const char *zIn = zPath;      /* Input path for each iteration of loop */\n  char *zDel = 0;\n\n  assert( pVfs->mxPathname==MAX_PATHNAME );\n  UNUSED_PARAMETER(pVfs);\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n\n  do {\n\n    /* Call stat() on path zIn. Set bLink to true if the path is a symbolic\n    ** link, or false otherwise.  */\n    int bLink = 0;\n    struct stat buf;\n    if( osLstat(zIn, &buf)!=0 ){\n      if( errno!=ENOENT ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"lstat\", zIn);\n      }\n    }else{\n      bLink = S_ISLNK(buf.st_mode);\n    }\n\n    if( bLink ){\n      if( zDel==0 ){\n        zDel = sqlite3_malloc(nOut);\n        if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;\n      }else if( ++nLink>SQLITE_MAX_SYMLINKS ){\n        rc = SQLITE_CANTOPEN_BKPT;\n      }\n\n      if( rc==SQLITE_OK ){\n        nByte = osReadlink(zIn, zDel, nOut-1);\n        if( nByte<0 ){\n          rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"readlink\", zIn);\n        }else{\n          if( zDel[0]!='/' ){\n            int n;\n            for(n = sqlite3Strlen30(zIn); n>0 && zIn[n-1]!='/'; n--);\n            if( nByte+n+1>nOut ){\n              rc = SQLITE_CANTOPEN_BKPT;\n            }else{\n              memmove(&zDel[n], zDel, nByte+1);\n              memcpy(zDel, zIn, n);\n              nByte += n;\n            }\n          }\n          zDel[nByte] = '\\0';\n        }\n      }\n\n      zIn = zDel;\n    }\n\n    assert( rc!=SQLITE_OK || zIn!=zOut || zIn[0]=='/' );\n    if( rc==SQLITE_OK && zIn!=zOut ){\n      rc = mkFullPathname(zIn, zOut, nOut);\n    }\n    if( bLink==0 ) break;\n    zIn = zOut;\n  }while( rc==SQLITE_OK );\n\n  sqlite3_free(zDel);\n  return rc;\n#endif   /* HAVE_READLINK && HAVE_LSTAT */\n}\n\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\n#include <dlfcn.h>\nstatic void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){\n  UNUSED_PARAMETER(NotUsed);\n  return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);\n}\n\n/*\n** SQLite calls this function immediately after a call to unixDlSym() or\n** unixDlOpen() fails (returns a null pointer). If a more detailed error\n** message is available, it is written to zBufOut. If no error message\n** is available, zBufOut is left unmodified and SQLite uses a default\n** error message.\n*/\nstatic void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){\n  const char *zErr;\n  UNUSED_PARAMETER(NotUsed);\n  unixEnterMutex();\n  zErr = dlerror();\n  if( zErr ){\n    sqlite3_snprintf(nBuf, zBufOut, \"%s\", zErr);\n  }\n  unixLeaveMutex();\n}\nstatic void (*unixDlSym(sqlite3_vfs *NotUsed, void *p, const char*zSym))(void){\n  /* \n  ** GCC with -pedantic-errors says that C90 does not allow a void* to be\n  ** cast into a pointer to a function.  And yet the library dlsym() routine\n  ** returns a void* which is really a pointer to a function.  So how do we\n  ** use dlsym() with -pedantic-errors?\n  **\n  ** Variable x below is defined to be a pointer to a function taking\n  ** parameters void* and const char* and returning a pointer to a function.\n  ** We initialize x by assigning it a pointer to the dlsym() function.\n  ** (That assignment requires a cast.)  Then we call the function that\n  ** x points to.  \n  **\n  ** This work-around is unlikely to work correctly on any system where\n  ** you really cannot cast a function pointer into void*.  But then, on the\n  ** other hand, dlsym() will not work on such a system either, so we have\n  ** not really lost anything.\n  */\n  void (*(*x)(void*,const char*))(void);\n  UNUSED_PARAMETER(NotUsed);\n  x = (void(*(*)(void*,const char*))(void))dlsym;\n  return (*x)(p, zSym);\n}\nstatic void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle){\n  UNUSED_PARAMETER(NotUsed);\n  dlclose(pHandle);\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define unixDlOpen  0\n  #define unixDlError 0\n  #define unixDlSym   0\n  #define unixDlClose 0\n#endif\n\n/*\n** Write nBuf bytes of random data to the supplied buffer zBuf.\n*/\nstatic int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){\n  UNUSED_PARAMETER(NotUsed);\n  assert((size_t)nBuf>=(sizeof(time_t)+sizeof(int)));\n\n  /* We have to initialize zBuf to prevent valgrind from reporting\n  ** errors.  The reports issued by valgrind are incorrect - we would\n  ** prefer that the randomness be increased by making use of the\n  ** uninitialized space in zBuf - but valgrind errors tend to worry\n  ** some users.  Rather than argue, it seems easier just to initialize\n  ** the whole array and silence valgrind, even if that means less randomness\n  ** in the random seed.\n  **\n  ** When testing, initializing zBuf[] to zero is all we do.  That means\n  ** that we always use the same random number sequence.  This makes the\n  ** tests repeatable.\n  */\n  memset(zBuf, 0, nBuf);\n  randomnessPid = osGetpid(0);  \n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n  {\n    int fd, got;\n    fd = robust_open(\"/dev/urandom\", O_RDONLY, 0);\n    if( fd<0 ){\n      time_t t;\n      time(&t);\n      memcpy(zBuf, &t, sizeof(t));\n      memcpy(&zBuf[sizeof(t)], &randomnessPid, sizeof(randomnessPid));\n      assert( sizeof(t)+sizeof(randomnessPid)<=(size_t)nBuf );\n      nBuf = sizeof(t) + sizeof(randomnessPid);\n    }else{\n      do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR );\n      robust_close(0, fd, __LINE__);\n    }\n  }\n#endif\n  return nBuf;\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n** The argument is the number of microseconds we want to sleep.\n** The return value is the number of microseconds of sleep actually\n** requested from the underlying operating system, a number which\n** might be greater than or equal to the argument, but not less\n** than the argument.\n*/\nstatic int unixSleep(sqlite3_vfs *NotUsed, int microseconds){\n#if OS_VXWORKS\n  struct timespec sp;\n\n  sp.tv_sec = microseconds / 1000000;\n  sp.tv_nsec = (microseconds % 1000000) * 1000;\n  nanosleep(&sp, NULL);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#elif defined(HAVE_USLEEP) && HAVE_USLEEP\n  usleep(microseconds);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#else\n  int seconds = (microseconds+999999)/1000000;\n  sleep(seconds);\n  UNUSED_PARAMETER(NotUsed);\n  return seconds*1000000;\n#endif\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date \n** cannot be found.\n*/\nstatic int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n  int rc = SQLITE_OK;\n#if defined(NO_GETTOD)\n  time_t t;\n  time(&t);\n  *piNow = ((sqlite3_int64)t)*1000 + unixEpoch;\n#elif OS_VXWORKS\n  struct timespec sNow;\n  clock_gettime(CLOCK_REALTIME, &sNow);\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;\n#else\n  struct timeval sNow;\n  (void)gettimeofday(&sNow, 0);  /* Cannot fail given valid arguments */\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;\n#endif\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(NotUsed);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){\n  sqlite3_int64 i = 0;\n  int rc;\n  UNUSED_PARAMETER(NotUsed);\n  rc = unixCurrentTimeInt64(0, &i);\n  *prNow = i/86400000.0;\n  return rc;\n}\n#else\n# define unixCurrentTime 0\n#endif\n\n/*\n** The xGetLastError() method is designed to return a better\n** low-level error message when operating-system problems come up\n** during SQLite operation.  Only the integer return code is currently\n** used.\n*/\nstatic int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){\n  UNUSED_PARAMETER(NotUsed);\n  UNUSED_PARAMETER(NotUsed2);\n  UNUSED_PARAMETER(NotUsed3);\n  return errno;\n}\n\n\n/*\n************************ End of sqlite3_vfs methods ***************************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin Proxy Locking ********************************\n**\n** Proxy locking is a \"uber-locking-method\" in this sense:  It uses the\n** other locking methods on secondary lock files.  Proxy locking is a\n** meta-layer over top of the primitive locking implemented above.  For\n** this reason, the division that implements of proxy locking is deferred\n** until late in the file (here) after all of the other I/O methods have\n** been defined - so that the primitive locking methods are available\n** as services to help with the implementation of proxy locking.\n**\n****\n**\n** The default locking schemes in SQLite use byte-range locks on the\n** database file to coordinate safe, concurrent access by multiple readers\n** and writers [http://sqlite.org/lockingv3.html].  The five file locking\n** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented\n** as POSIX read & write locks over fixed set of locations (via fsctl),\n** on AFP and SMB only exclusive byte-range locks are available via fsctl\n** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states.\n** To simulate a F_RDLCK on the shared range, on AFP a randomly selected\n** address in the shared range is taken for a SHARED lock, the entire\n** shared range is taken for an EXCLUSIVE lock):\n**\n**      PENDING_BYTE        0x40000000\n**      RESERVED_BYTE       0x40000001\n**      SHARED_RANGE        0x40000002 -> 0x40000200\n**\n** This works well on the local file system, but shows a nearly 100x\n** slowdown in read performance on AFP because the AFP client disables\n** the read cache when byte-range locks are present.  Enabling the read\n** cache exposes a cache coherency problem that is present on all OS X\n** supported network file systems.  NFS and AFP both observe the\n** close-to-open semantics for ensuring cache coherency\n** [http://nfs.sourceforge.net/#faq_a8], which does not effectively\n** address the requirements for concurrent database access by multiple\n** readers and writers\n** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html].\n**\n** To address the performance and cache coherency issues, proxy file locking\n** changes the way database access is controlled by limiting access to a\n** single host at a time and moving file locks off of the database file\n** and onto a proxy file on the local file system.  \n**\n**\n** Using proxy locks\n** -----------------\n**\n** C APIs\n**\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,\n**                       <proxy_path> | \":auto:\");\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,\n**                       &<proxy_path>);\n**\n**\n** SQL pragmas\n**\n**  PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:\n**  PRAGMA [database.]lock_proxy_file\n**\n** Specifying \":auto:\" means that if there is a conch file with a matching\n** host ID in it, the proxy path in the conch file will be used, otherwise\n** a proxy path based on the user's temp dir\n** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the\n** actual proxy file name is generated from the name and path of the\n** database file.  For example:\n**\n**       For database path \"/Users/me/foo.db\" \n**       The lock path will be \"<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:\")\n**\n** Once a lock proxy is configured for a database connection, it can not\n** be removed, however it may be switched to a different proxy path via\n** the above APIs (assuming the conch file is not being held by another\n** connection or process). \n**\n**\n** How proxy locking works\n** -----------------------\n**\n** Proxy file locking relies primarily on two new supporting files: \n**\n**   *  conch file to limit access to the database file to a single host\n**      at a time\n**\n**   *  proxy file to act as a proxy for the advisory locks normally\n**      taken on the database\n**\n** The conch file - to use a proxy file, sqlite must first \"hold the conch\"\n** by taking an sqlite-style shared lock on the conch file, reading the\n** contents and comparing the host's unique host ID (see below) and lock\n** proxy path against the values stored in the conch.  The conch file is\n** stored in the same directory as the database file and the file name\n** is patterned after the database file name as \".<databasename>-conch\".\n** If the conch file does not exist, or its contents do not match the\n** host ID and/or proxy path, then the lock is escalated to an exclusive\n** lock and the conch file contents is updated with the host ID and proxy\n** path and the lock is downgraded to a shared lock again.  If the conch\n** is held by another process (with a shared lock), the exclusive lock\n** will fail and SQLITE_BUSY is returned.\n**\n** The proxy file - a single-byte file used for all advisory file locks\n** normally taken on the database file.   This allows for safe sharing\n** of the database file for multiple readers and writers on the same\n** host (the conch ensures that they all use the same local lock file).\n**\n** Requesting the lock proxy does not immediately take the conch, it is\n** only taken when the first request to lock database file is made.  \n** This matches the semantics of the traditional locking behavior, where\n** opening a connection to a database file does not take a lock on it.\n** The shared lock and an open file descriptor are maintained until \n** the connection to the database is closed. \n**\n** The proxy file and the lock file are never deleted so they only need\n** to be created the first time they are used.\n**\n** Configuration options\n** ---------------------\n**\n**  SQLITE_PREFER_PROXY_LOCKING\n**\n**       Database files accessed on non-local file systems are\n**       automatically configured for proxy locking, lock files are\n**       named automatically using the same logic as\n**       PRAGMA lock_proxy_file=\":auto:\"\n**    \n**  SQLITE_PROXY_DEBUG\n**\n**       Enables the logging of error messages during host id file\n**       retrieval and creation\n**\n**  LOCKPROXYDIR\n**\n**       Overrides the default directory used for lock proxy files that\n**       are named automatically via the \":auto:\" setting\n**\n**  SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n**\n**       Permissions to use when creating a directory for storing the\n**       lock proxy files, only used when LOCKPROXYDIR is not set.\n**    \n**    \n** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,\n** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will\n** force proxy locking to be used for every database file opened, and 0\n** will force automatic proxy locking to be disabled for all database\n** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or\n** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).\n*/\n\n/*\n** Proxy locking is only available on MacOSX \n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** The proxyLockingContext has the path and file structures for the remote \n** and local proxy files in it\n*/\ntypedef struct proxyLockingContext proxyLockingContext;\nstruct proxyLockingContext {\n  unixFile *conchFile;         /* Open conch file */\n  char *conchFilePath;         /* Name of the conch file */\n  unixFile *lockProxy;         /* Open proxy lock file */\n  char *lockProxyPath;         /* Name of the proxy lock file */\n  char *dbPath;                /* Name of the open file */\n  int conchHeld;               /* 1 if the conch is held, -1 if lockless */\n  int nFails;                  /* Number of conch taking failures */\n  void *oldLockingContext;     /* Original lockingcontext to restore on close */\n  sqlite3_io_methods const *pOldMethod;     /* Original I/O methods for close */\n};\n\n/* \n** The proxy lock file path for the database at dbPath is written into lPath, \n** which must point to valid, writable memory large enough for a maxLen length\n** file path. \n*/\nstatic int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){\n  int len;\n  int dbLen;\n  int i;\n\n#ifdef LOCKPROXYDIR\n  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);\n#else\n# ifdef _CS_DARWIN_USER_TEMP_DIR\n  {\n    if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){\n      OSTRACE((\"GETLOCKPATH  failed %s errno=%d pid=%d\\n\",\n               lPath, errno, osGetpid(0)));\n      return SQLITE_IOERR_LOCK;\n    }\n    len = strlcat(lPath, \"sqliteplocks\", maxLen);    \n  }\n# else\n  len = strlcpy(lPath, \"/tmp/\", maxLen);\n# endif\n#endif\n\n  if( lPath[len-1]!='/' ){\n    len = strlcat(lPath, \"/\", maxLen);\n  }\n  \n  /* transform the db path to a unique cache name */\n  dbLen = (int)strlen(dbPath);\n  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){\n    char c = dbPath[i];\n    lPath[i+len] = (c=='/')?'_':c;\n  }\n  lPath[i+len]='\\0';\n  strlcat(lPath, \":auto:\", maxLen);\n  OSTRACE((\"GETLOCKPATH  proxy lock path=%s pid=%d\\n\", lPath, osGetpid(0)));\n  return SQLITE_OK;\n}\n\n/* \n ** Creates the lock file and any missing directories in lockPath\n */\nstatic int proxyCreateLockPath(const char *lockPath){\n  int i, len;\n  char buf[MAXPATHLEN];\n  int start = 0;\n  \n  assert(lockPath!=NULL);\n  /* try to create all the intermediate directories */\n  len = (int)strlen(lockPath);\n  buf[0] = lockPath[0];\n  for( i=1; i<len; i++ ){\n    if( lockPath[i] == '/' && (i - start > 0) ){\n      /* only mkdir if leaf dir != \".\" or \"/\" or \"..\" */\n      if( i-start>2 || (i-start==1 && buf[start] != '.' && buf[start] != '/') \n         || (i-start==2 && buf[start] != '.' && buf[start+1] != '.') ){\n        buf[i]='\\0';\n        if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){\n          int err=errno;\n          if( err!=EEXIST ) {\n            OSTRACE((\"CREATELOCKPATH  FAILED creating %s, \"\n                     \"'%s' proxy lock path=%s pid=%d\\n\",\n                     buf, strerror(err), lockPath, osGetpid(0)));\n            return err;\n          }\n        }\n      }\n      start=i+1;\n    }\n    buf[i] = lockPath[i];\n  }\n  OSTRACE((\"CREATELOCKPATH  proxy lock path=%s pid=%d\\n\",lockPath,osGetpid(0)));\n  return 0;\n}\n\n/*\n** Create a new VFS file descriptor (stored in memory obtained from\n** sqlite3_malloc) and open the file named \"path\" in the file descriptor.\n**\n** The caller is responsible not only for closing the file descriptor\n** but also for freeing the memory associated with the file descriptor.\n*/\nstatic int proxyCreateUnixFile(\n    const char *path,        /* path for the new unixFile */\n    unixFile **ppFile,       /* unixFile created and returned by ref */\n    int islockfile           /* if non zero missing dirs will be created */\n) {\n  int fd = -1;\n  unixFile *pNew;\n  int rc = SQLITE_OK;\n  int openFlags = O_RDWR | O_CREAT;\n  sqlite3_vfs dummyVfs;\n  int terrno = 0;\n  UnixUnusedFd *pUnused = NULL;\n\n  /* 1. first try to open/create the file\n  ** 2. if that fails, and this is a lock file (not-conch), try creating\n  ** the parent directories and then try again.\n  ** 3. if that fails, try to open the file read-only\n  ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file\n  */\n  pUnused = findReusableFd(path, openFlags);\n  if( pUnused ){\n    fd = pUnused->fd;\n  }else{\n    pUnused = sqlite3_malloc64(sizeof(*pUnused));\n    if( !pUnused ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( fd<0 ){\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n    if( fd<0 && errno==ENOENT && islockfile ){\n      if( proxyCreateLockPath(path) == SQLITE_OK ){\n        fd = robust_open(path, openFlags, 0);\n      }\n    }\n  }\n  if( fd<0 ){\n    openFlags = O_RDONLY;\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n  }\n  if( fd<0 ){\n    if( islockfile ){\n      return SQLITE_BUSY;\n    }\n    switch (terrno) {\n      case EACCES:\n        return SQLITE_PERM;\n      case EIO: \n        return SQLITE_IOERR_LOCK; /* even though it is the conch */\n      default:\n        return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n  \n  pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew));\n  if( pNew==NULL ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_create_proxy;\n  }\n  memset(pNew, 0, sizeof(unixFile));\n  pNew->openFlags = openFlags;\n  memset(&dummyVfs, 0, sizeof(dummyVfs));\n  dummyVfs.pAppData = (void*)&autolockIoFinder;\n  dummyVfs.zName = \"dummy\";\n  pUnused->fd = fd;\n  pUnused->flags = openFlags;\n  pNew->pPreallocatedUnused = pUnused;\n  \n  rc = fillInUnixFile(&dummyVfs, fd, (sqlite3_file*)pNew, path, 0);\n  if( rc==SQLITE_OK ){\n    *ppFile = pNew;\n    return SQLITE_OK;\n  }\nend_create_proxy:    \n  robust_close(pNew, fd, __LINE__);\n  sqlite3_free(pNew);\n  sqlite3_free(pUnused);\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/* simulate multiple hosts by creating unique hostid file paths */\nSQLITE_API int sqlite3_hostid_num = 0;\n#endif\n\n#define PROXY_HOSTIDLEN    16  /* conch file host id length */\n\n#ifdef HAVE_GETHOSTUUID\n/* Not always defined in the headers as it ought to be */\nextern int gethostuuid(uuid_t id, const struct timespec *wait);\n#endif\n\n/* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN \n** bytes of writable memory.\n*/\nstatic int proxyGetHostID(unsigned char *pHostID, int *pError){\n  assert(PROXY_HOSTIDLEN == sizeof(uuid_t));\n  memset(pHostID, 0, PROXY_HOSTIDLEN);\n#ifdef HAVE_GETHOSTUUID\n  {\n    struct timespec timeout = {1, 0}; /* 1 sec timeout */\n    if( gethostuuid(pHostID, &timeout) ){\n      int err = errno;\n      if( pError ){\n        *pError = err;\n      }\n      return SQLITE_IOERR;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pError);\n#endif\n#ifdef SQLITE_TEST\n  /* simulate multiple hosts by creating unique hostid file paths */\n  if( sqlite3_hostid_num != 0){\n    pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF));\n  }\n#endif\n  \n  return SQLITE_OK;\n}\n\n/* The conch file contains the header, host id and lock file path\n */\n#define PROXY_CONCHVERSION 2   /* 1-byte header, 16-byte host id, path */\n#define PROXY_HEADERLEN    1   /* conch file header length */\n#define PROXY_PATHINDEX    (PROXY_HEADERLEN+PROXY_HOSTIDLEN)\n#define PROXY_MAXCONCHLEN  (PROXY_HEADERLEN+PROXY_HOSTIDLEN+MAXPATHLEN)\n\n/* \n** Takes an open conch file, copies the contents to a new path and then moves \n** it back.  The newly created file's file descriptor is assigned to the\n** conch file structure and finally the original conch file descriptor is \n** closed.  Returns zero if successful.\n*/\nstatic int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  char tPath[MAXPATHLEN];\n  char buf[PROXY_MAXCONCHLEN];\n  char *cPath = pCtx->conchFilePath;\n  size_t readLen = 0;\n  size_t pathLen = 0;\n  char errmsg[64] = \"\";\n  int fd = -1;\n  int rc = -1;\n  UNUSED_PARAMETER(myHostID);\n\n  /* create a new path by replace the trailing '-conch' with '-break' */\n  pathLen = strlcpy(tPath, cPath, MAXPATHLEN);\n  if( pathLen>MAXPATHLEN || pathLen<6 || \n     (strlcpy(&tPath[pathLen-5], \"break\", 6) != 5) ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"path error (len %d)\",(int)pathLen);\n    goto end_breaklock;\n  }\n  /* read the conch content */\n  readLen = osPread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);\n  if( readLen<PROXY_PATHINDEX ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"read error (len %d)\",(int)readLen);\n    goto end_breaklock;\n  }\n  /* write it out to the temporary break file */\n  fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);\n  if( fd<0 ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"create failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"write failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( rename(tPath, cPath) ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"rename failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  rc = 0;\n  fprintf(stderr, \"broke stale lock on %s\\n\", cPath);\n  robust_close(pFile, conchFile->h, __LINE__);\n  conchFile->h = fd;\n  conchFile->openFlags = O_RDWR | O_CREAT;\n\nend_breaklock:\n  if( rc ){\n    if( fd>=0 ){\n      osUnlink(tPath);\n      robust_close(pFile, fd, __LINE__);\n    }\n    fprintf(stderr, \"failed to break stale lock on %s, %s\\n\", cPath, errmsg);\n  }\n  return rc;\n}\n\n/* Take the requested lock on the conch file and break a stale lock if the \n** host id matches.\n*/\nstatic int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  int rc = SQLITE_OK;\n  int nTries = 0;\n  struct timespec conchModTime;\n  \n  memset(&conchModTime, 0, sizeof(conchModTime));\n  do {\n    rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n    nTries ++;\n    if( rc==SQLITE_BUSY ){\n      /* If the lock failed (busy):\n       * 1st try: get the mod time of the conch, wait 0.5s and try again. \n       * 2nd try: fail if the mod time changed or host id is different, wait \n       *           10 sec and try again\n       * 3rd try: break the lock unless the mod time has changed.\n       */\n      struct stat buf;\n      if( osFstat(conchFile->h, &buf) ){\n        storeLastErrno(pFile, errno);\n        return SQLITE_IOERR_LOCK;\n      }\n      \n      if( nTries==1 ){\n        conchModTime = buf.st_mtimespec;\n        usleep(500000); /* wait 0.5 sec and try the lock again*/\n        continue;  \n      }\n\n      assert( nTries>1 );\n      if( conchModTime.tv_sec != buf.st_mtimespec.tv_sec || \n         conchModTime.tv_nsec != buf.st_mtimespec.tv_nsec ){\n        return SQLITE_BUSY;\n      }\n      \n      if( nTries==2 ){  \n        char tBuf[PROXY_MAXCONCHLEN];\n        int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);\n        if( len<0 ){\n          storeLastErrno(pFile, errno);\n          return SQLITE_IOERR_LOCK;\n        }\n        if( len>PROXY_PATHINDEX && tBuf[0]==(char)PROXY_CONCHVERSION){\n          /* don't break the lock if the host id doesn't match */\n          if( 0!=memcmp(&tBuf[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN) ){\n            return SQLITE_BUSY;\n          }\n        }else{\n          /* don't break the lock on short read or a version mismatch */\n          return SQLITE_BUSY;\n        }\n        usleep(10000000); /* wait 10 sec and try the lock again */\n        continue; \n      }\n      \n      assert( nTries==3 );\n      if( 0==proxyBreakConchLock(pFile, myHostID) ){\n        rc = SQLITE_OK;\n        if( lockType==EXCLUSIVE_LOCK ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);\n        }\n        if( !rc ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n        }\n      }\n    }\n  } while( rc==SQLITE_BUSY && nTries<3 );\n  \n  return rc;\n}\n\n/* Takes the conch by taking a shared lock and read the contents conch, if \n** lockPath is non-NULL, the host ID and lock file path must match.  A NULL \n** lockPath means that the lockPath in the conch file will be used if the \n** host IDs match, or a new lock path will be generated automatically \n** and written to the conch file.\n*/\nstatic int proxyTakeConch(unixFile *pFile){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  \n  if( pCtx->conchHeld!=0 ){\n    return SQLITE_OK;\n  }else{\n    unixFile *conchFile = pCtx->conchFile;\n    uuid_t myHostID;\n    int pError = 0;\n    char readBuf[PROXY_MAXCONCHLEN];\n    char lockPath[MAXPATHLEN];\n    char *tempLockPath = NULL;\n    int rc = SQLITE_OK;\n    int createConch = 0;\n    int hostIdMatch = 0;\n    int readLen = 0;\n    int tryOldLockPath = 0;\n    int forceNewLockPath = 0;\n    \n    OSTRACE((\"TAKECONCH  %d for %s pid=%d\\n\", conchFile->h,\n             (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"),\n             osGetpid(0)));\n\n    rc = proxyGetHostID(myHostID, &pError);\n    if( (rc&0xff)==SQLITE_IOERR ){\n      storeLastErrno(pFile, pError);\n      goto end_takeconch;\n    }\n    rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      goto end_takeconch;\n    }\n    /* read the existing conch file */\n    readLen = seekAndRead((unixFile*)conchFile, 0, readBuf, PROXY_MAXCONCHLEN);\n    if( readLen<0 ){\n      /* I/O error: lastErrno set by seekAndRead */\n      storeLastErrno(pFile, conchFile->lastErrno);\n      rc = SQLITE_IOERR_READ;\n      goto end_takeconch;\n    }else if( readLen<=(PROXY_HEADERLEN+PROXY_HOSTIDLEN) || \n             readBuf[0]!=(char)PROXY_CONCHVERSION ){\n      /* a short read or version format mismatch means we need to create a new \n      ** conch file. \n      */\n      createConch = 1;\n    }\n    /* if the host id matches and the lock path already exists in the conch\n    ** we'll try to use the path there, if we can't open that path, we'll \n    ** retry with a new auto-generated path \n    */\n    do { /* in case we need to try again for an :auto: named lock file */\n\n      if( !createConch && !forceNewLockPath ){\n        hostIdMatch = !memcmp(&readBuf[PROXY_HEADERLEN], myHostID, \n                                  PROXY_HOSTIDLEN);\n        /* if the conch has data compare the contents */\n        if( !pCtx->lockProxyPath ){\n          /* for auto-named local lock file, just check the host ID and we'll\n           ** use the local lock file path that's already in there\n           */\n          if( hostIdMatch ){\n            size_t pathLen = (readLen - PROXY_PATHINDEX);\n            \n            if( pathLen>=MAXPATHLEN ){\n              pathLen=MAXPATHLEN-1;\n            }\n            memcpy(lockPath, &readBuf[PROXY_PATHINDEX], pathLen);\n            lockPath[pathLen] = 0;\n            tempLockPath = lockPath;\n            tryOldLockPath = 1;\n            /* create a copy of the lock path if the conch is taken */\n            goto end_takeconch;\n          }\n        }else if( hostIdMatch\n               && !strncmp(pCtx->lockProxyPath, &readBuf[PROXY_PATHINDEX],\n                           readLen-PROXY_PATHINDEX)\n        ){\n          /* conch host and lock path match */\n          goto end_takeconch; \n        }\n      }\n      \n      /* if the conch isn't writable and doesn't match, we can't take it */\n      if( (conchFile->openFlags&O_RDWR) == 0 ){\n        rc = SQLITE_BUSY;\n        goto end_takeconch;\n      }\n      \n      /* either the conch didn't match or we need to create a new one */\n      if( !pCtx->lockProxyPath ){\n        proxyGetLockPath(pCtx->dbPath, lockPath, MAXPATHLEN);\n        tempLockPath = lockPath;\n        /* create a copy of the lock path _only_ if the conch is taken */\n      }\n      \n      /* update conch with host and path (this will fail if other process\n      ** has a shared lock already), if the host id matches, use the big\n      ** stick.\n      */\n      futimes(conchFile->h, NULL);\n      if( hostIdMatch && !createConch ){\n        if( conchFile->pInode && conchFile->pInode->nShared>1 ){\n          /* We are trying for an exclusive lock but another thread in this\n           ** same process is still holding a shared lock. */\n          rc = SQLITE_BUSY;\n        } else {          \n          rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n        }\n      }else{\n        rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n      }\n      if( rc==SQLITE_OK ){\n        char writeBuffer[PROXY_MAXCONCHLEN];\n        int writeSize = 0;\n        \n        writeBuffer[0] = (char)PROXY_CONCHVERSION;\n        memcpy(&writeBuffer[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN);\n        if( pCtx->lockProxyPath!=NULL ){\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath,\n                  MAXPATHLEN);\n        }else{\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], tempLockPath, MAXPATHLEN);\n        }\n        writeSize = PROXY_PATHINDEX + strlen(&writeBuffer[PROXY_PATHINDEX]);\n        robust_ftruncate(conchFile->h, writeSize);\n        rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0);\n        full_fsync(conchFile->h,0,0);\n        /* If we created a new conch file (not just updated the contents of a \n         ** valid conch file), try to match the permissions of the database \n         */\n        if( rc==SQLITE_OK && createConch ){\n          struct stat buf;\n          int err = osFstat(pFile->h, &buf);\n          if( err==0 ){\n            mode_t cmode = buf.st_mode&(S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP |\n                                        S_IROTH|S_IWOTH);\n            /* try to match the database file R/W permissions, ignore failure */\n#ifndef SQLITE_PROXY_DEBUG\n            osFchmod(conchFile->h, cmode);\n#else\n            do{\n              rc = osFchmod(conchFile->h, cmode);\n            }while( rc==(-1) && errno==EINTR );\n            if( rc!=0 ){\n              int code = errno;\n              fprintf(stderr, \"fchmod %o FAILED with %d %s\\n\",\n                      cmode, code, strerror(code));\n            } else {\n              fprintf(stderr, \"fchmod %o SUCCEDED\\n\",cmode);\n            }\n          }else{\n            int code = errno;\n            fprintf(stderr, \"STAT FAILED[%d] with %d %s\\n\", \n                    err, code, strerror(code));\n#endif\n          }\n        }\n      }\n      conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);\n      \n    end_takeconch:\n      OSTRACE((\"TRANSPROXY: CLOSE  %d\\n\", pFile->h));\n      if( rc==SQLITE_OK && pFile->openFlags ){\n        int fd;\n        if( pFile->h>=0 ){\n          robust_close(pFile, pFile->h, __LINE__);\n        }\n        pFile->h = -1;\n        fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);\n        OSTRACE((\"TRANSPROXY: OPEN  %d\\n\", fd));\n        if( fd>=0 ){\n          pFile->h = fd;\n        }else{\n          rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called\n           during locking */\n        }\n      }\n      if( rc==SQLITE_OK && !pCtx->lockProxy ){\n        char *path = tempLockPath ? tempLockPath : pCtx->lockProxyPath;\n        rc = proxyCreateUnixFile(path, &pCtx->lockProxy, 1);\n        if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM && tryOldLockPath ){\n          /* we couldn't create the proxy lock file with the old lock file path\n           ** so try again via auto-naming \n           */\n          forceNewLockPath = 1;\n          tryOldLockPath = 0;\n          continue; /* go back to the do {} while start point, try again */\n        }\n      }\n      if( rc==SQLITE_OK ){\n        /* Need to make a copy of path if we extracted the value\n         ** from the conch file or the path was allocated on the stack\n         */\n        if( tempLockPath ){\n          pCtx->lockProxyPath = sqlite3DbStrDup(0, tempLockPath);\n          if( !pCtx->lockProxyPath ){\n            rc = SQLITE_NOMEM_BKPT;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        pCtx->conchHeld = 1;\n        \n        if( pCtx->lockProxy->pMethod == &afpIoMethods ){\n          afpLockingContext *afpCtx;\n          afpCtx = (afpLockingContext *)pCtx->lockProxy->lockingContext;\n          afpCtx->dbPath = pCtx->lockProxyPath;\n        }\n      } else {\n        conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n      }\n      OSTRACE((\"TAKECONCH  %d %s\\n\", conchFile->h,\n               rc==SQLITE_OK?\"ok\":\"failed\"));\n      return rc;\n    } while (1); /* in case we need to retry the :auto: lock file - \n                 ** we should never get here except via the 'continue' call. */\n  }\n}\n\n/*\n** If pFile holds a lock on a conch file, then release that lock.\n*/\nstatic int proxyReleaseConch(unixFile *pFile){\n  int rc = SQLITE_OK;         /* Subroutine return code */\n  proxyLockingContext *pCtx;  /* The locking context for the proxy lock */\n  unixFile *conchFile;        /* Name of the conch file */\n\n  pCtx = (proxyLockingContext *)pFile->lockingContext;\n  conchFile = pCtx->conchFile;\n  OSTRACE((\"RELEASECONCH  %d for %s pid=%d\\n\", conchFile->h,\n           (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"), \n           osGetpid(0)));\n  if( pCtx->conchHeld>0 ){\n    rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n  }\n  pCtx->conchHeld = 0;\n  OSTRACE((\"RELEASECONCH  %d %s\\n\", conchFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n/*\n** Given the name of a database file, compute the name of its conch file.\n** Store the conch filename in memory obtained from sqlite3_malloc64().\n** Make *pConchPath point to the new name.  Return SQLITE_OK on success\n** or SQLITE_NOMEM if unable to obtain memory.\n**\n** The caller is responsible for ensuring that the allocated memory\n** space is eventually freed.\n**\n** *pConchPath is set to NULL if a memory allocation error occurs.\n*/\nstatic int proxyCreateConchPathname(char *dbPath, char **pConchPath){\n  int i;                        /* Loop counter */\n  int len = (int)strlen(dbPath); /* Length of database filename - dbPath */\n  char *conchPath;              /* buffer in which to construct conch name */\n\n  /* Allocate space for the conch filename and initialize the name to\n  ** the name of the original database file. */  \n  *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8);\n  if( conchPath==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(conchPath, dbPath, len+1);\n  \n  /* now insert a \".\" before the last / character */\n  for( i=(len-1); i>=0; i-- ){\n    if( conchPath[i]=='/' ){\n      i++;\n      break;\n    }\n  }\n  conchPath[i]='.';\n  while ( i<len ){\n    conchPath[i+1]=dbPath[i];\n    i++;\n  }\n\n  /* append the \"-conch\" suffix to the file */\n  memcpy(&conchPath[i+1], \"-conch\", 7);\n  assert( (int)strlen(conchPath) == len+7 );\n\n  return SQLITE_OK;\n}\n\n\n/* Takes a fully configured proxy locking-style unix file and switches\n** the local lock file path \n*/\nstatic int switchLockProxyPath(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n  char *oldPath = pCtx->lockProxyPath;\n  int rc = SQLITE_OK;\n\n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }  \n\n  /* nothing to do if the path is NULL, :auto: or matches the existing path */\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ||\n    (oldPath && !strncmp(oldPath, path, MAXPATHLEN)) ){\n    return SQLITE_OK;\n  }else{\n    unixFile *lockProxy = pCtx->lockProxy;\n    pCtx->lockProxy=NULL;\n    pCtx->conchHeld = 0;\n    if( lockProxy!=NULL ){\n      rc=lockProxy->pMethod->xClose((sqlite3_file *)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n    }\n    sqlite3_free(oldPath);\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, path);\n  }\n  \n  return rc;\n}\n\n/*\n** pFile is a file that has been opened by a prior xOpen call.  dbPath\n** is a string buffer at least MAXPATHLEN+1 characters in size.\n**\n** This routine find the filename associated with pFile and writes it\n** int dbPath.\n*/\nstatic int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){\n#if defined(__APPLE__)\n  if( pFile->pMethod == &afpIoMethods ){\n    /* afp style keeps a reference to the db path in the filePath field \n    ** of the struct */\n    assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath,\n            MAXPATHLEN);\n  } else\n#endif\n  if( pFile->pMethod == &dotlockIoMethods ){\n    /* dot lock style uses the locking context to store the dot lock\n    ** file path */\n    int len = strlen((char *)pFile->lockingContext) - strlen(DOTLOCK_SUFFIX);\n    memcpy(dbPath, (char *)pFile->lockingContext, len + 1);\n  }else{\n    /* all other styles use the locking context to store the db file path */\n    assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, (char *)pFile->lockingContext, MAXPATHLEN);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Takes an already filled in unix file and alters it so all file locking \n** will be performed on the local proxy lock file.  The following fields\n** are preserved in the locking context so that they can be restored and \n** the unix structure properly cleaned up at close time:\n**  ->lockingContext\n**  ->pMethod\n*/\nstatic int proxyTransformUnixFile(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx;\n  char dbPath[MAXPATHLEN+1];       /* Name of the database file */\n  char *lockPath=NULL;\n  int rc = SQLITE_OK;\n  \n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }\n  proxyGetDbPathForUnixFile(pFile, dbPath);\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ){\n    lockPath=NULL;\n  }else{\n    lockPath=(char *)path;\n  }\n  \n  OSTRACE((\"TRANSPROXY  %d for %s pid=%d\\n\", pFile->h,\n           (lockPath ? lockPath : \":auto:\"), osGetpid(0)));\n\n  pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n  if( pCtx==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(pCtx, 0, sizeof(*pCtx));\n\n  rc = proxyCreateConchPathname(dbPath, &pCtx->conchFilePath);\n  if( rc==SQLITE_OK ){\n    rc = proxyCreateUnixFile(pCtx->conchFilePath, &pCtx->conchFile, 0);\n    if( rc==SQLITE_CANTOPEN && ((pFile->openFlags&O_RDWR) == 0) ){\n      /* if (a) the open flags are not O_RDWR, (b) the conch isn't there, and\n      ** (c) the file system is read-only, then enable no-locking access.\n      ** Ugh, since O_RDONLY==0x0000 we test for !O_RDWR since unixOpen asserts\n      ** that openFlags will have only one of O_RDONLY or O_RDWR.\n      */\n      struct statfs fsInfo;\n      struct stat conchInfo;\n      int goLockless = 0;\n\n      if( osStat(pCtx->conchFilePath, &conchInfo) == -1 ) {\n        int err = errno;\n        if( (err==ENOENT) && (statfs(dbPath, &fsInfo) != -1) ){\n          goLockless = (fsInfo.f_flags&MNT_RDONLY) == MNT_RDONLY;\n        }\n      }\n      if( goLockless ){\n        pCtx->conchHeld = -1; /* read only FS/ lockless */\n        rc = SQLITE_OK;\n      }\n    }\n  }  \n  if( rc==SQLITE_OK && lockPath ){\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, lockPath);\n  }\n\n  if( rc==SQLITE_OK ){\n    pCtx->dbPath = sqlite3DbStrDup(0, dbPath);\n    if( pCtx->dbPath==NULL ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    /* all memory is allocated, proxys are created and assigned, \n    ** switch the locking context and pMethod then return.\n    */\n    pCtx->oldLockingContext = pFile->lockingContext;\n    pFile->lockingContext = pCtx;\n    pCtx->pOldMethod = pFile->pMethod;\n    pFile->pMethod = &proxyIoMethods;\n  }else{\n    if( pCtx->conchFile ){ \n      pCtx->conchFile->pMethod->xClose((sqlite3_file *)pCtx->conchFile);\n      sqlite3_free(pCtx->conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath); \n    sqlite3_free(pCtx);\n  }\n  OSTRACE((\"TRANSPROXY  %d %s\\n\", pFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n\n/*\n** This routine handles sqlite3_file_control() calls that are specific\n** to proxy locking.\n*/\nstatic int proxyFileControl(sqlite3_file *id, int op, void *pArg){\n  switch( op ){\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      if( pFile->pMethod == &proxyIoMethods ){\n        proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n        proxyTakeConch(pFile);\n        if( pCtx->lockProxyPath ){\n          *(const char **)pArg = pCtx->lockProxyPath;\n        }else{\n          *(const char **)pArg = \":auto: (not held)\";\n        }\n      } else {\n        *(const char **)pArg = NULL;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      int rc = SQLITE_OK;\n      int isProxyStyle = (pFile->pMethod == &proxyIoMethods);\n      if( pArg==NULL || (const char *)pArg==0 ){\n        if( isProxyStyle ){\n          /* turn off proxy locking - not supported.  If support is added for\n          ** switching proxy locking mode off then it will need to fail if\n          ** the journal mode is WAL mode. \n          */\n          rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;\n        }else{\n          /* turn off proxy locking - already off - NOOP */\n          rc = SQLITE_OK;\n        }\n      }else{\n        const char *proxyPath = (const char *)pArg;\n        if( isProxyStyle ){\n          proxyLockingContext *pCtx = \n            (proxyLockingContext*)pFile->lockingContext;\n          if( !strcmp(pArg, \":auto:\") \n           || (pCtx->lockProxyPath &&\n               !strncmp(pCtx->lockProxyPath, proxyPath, MAXPATHLEN))\n          ){\n            rc = SQLITE_OK;\n          }else{\n            rc = switchLockProxyPath(pFile, proxyPath);\n          }\n        }else{\n          /* turn on proxy file locking */\n          rc = proxyTransformUnixFile(pFile, proxyPath);\n        }\n      }\n      return rc;\n    }\n    default: {\n      assert( 0 );  /* The call assures that only valid opcodes are sent */\n    }\n  }\n  /*NOTREACHED*/\n  return SQLITE_ERROR;\n}\n\n/*\n** Within this division (the proxying locking implementation) the procedures\n** above this point are all utilities.  The lock-related methods of the\n** proxy-locking sqlite3_io_method object follow.\n*/\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      return proxy->pMethod->xCheckReservedLock((sqlite3_file*)proxy, pResOut);\n    }else{ /* conchHeld < 0 is lockless */\n      pResOut=0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int proxyLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int proxyUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n/*\n** Close a file that uses proxy locks.\n*/\nstatic int proxyClose(sqlite3_file *id) {\n  if( ALWAYS(id) ){\n    unixFile *pFile = (unixFile*)id;\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    unixFile *lockProxy = pCtx->lockProxy;\n    unixFile *conchFile = pCtx->conchFile;\n    int rc = SQLITE_OK;\n    \n    if( lockProxy ){\n      rc = lockProxy->pMethod->xUnlock((sqlite3_file*)lockProxy, NO_LOCK);\n      if( rc ) return rc;\n      rc = lockProxy->pMethod->xClose((sqlite3_file*)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n      pCtx->lockProxy = 0;\n    }\n    if( conchFile ){\n      if( pCtx->conchHeld ){\n        rc = proxyReleaseConch(pFile);\n        if( rc ) return rc;\n      }\n      rc = conchFile->pMethod->xClose((sqlite3_file*)conchFile);\n      if( rc ) return rc;\n      sqlite3_free(conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath);\n    sqlite3DbFree(0, pCtx->dbPath);\n    /* restore the original locking context and pMethod then close it */\n    pFile->lockingContext = pCtx->oldLockingContext;\n    pFile->pMethod = pCtx->pOldMethod;\n    sqlite3_free(pCtx);\n    return pFile->pMethod->xClose(id);\n  }\n  return SQLITE_OK;\n}\n\n\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The proxy locking style is intended for use with AFP filesystems.\n** And since AFP is only supported on MacOSX, the proxy locking is also\n** restricted to MacOSX.\n** \n**\n******************* End of the proxy lock implementation **********************\n******************************************************************************/\n\n/*\n** Initialize the operating system interface.\n**\n** This routine registers all VFS implementations for unix-like operating\n** systems.  This routine, and the sqlite3_os_end() routine that follows,\n** should be the only routines in this file that are visible from other\n** files.\n**\n** This routine is called once during SQLite initialization and by a\n** single thread.  The memory allocation and mutex subsystems have not\n** necessarily been initialized when this routine is called, and so they\n** should not be used.\n*/\nSQLITE_API int sqlite3_os_init(void){ \n  /* \n  ** The following macro defines an initializer for an sqlite3_vfs object.\n  ** The name of the VFS is NAME.  The pAppData is a pointer to a pointer\n  ** to the \"finder\" function.  (pAppData is a pointer to a pointer because\n  ** silly C90 rules prohibit a void* from being cast to a function pointer\n  ** and so we have to go through the intermediate pointer to avoid problems\n  ** when compiling with -pedantic-errors on GCC.)\n  **\n  ** The FINDER parameter to this macro is the name of the pointer to the\n  ** finder-function.  The finder-function returns a pointer to the\n  ** sqlite_io_methods object that implements the desired locking\n  ** behaviors.  See the division above that contains the IOMETHODS\n  ** macro for addition information on finder-functions.\n  **\n  ** Most finders simply return a pointer to a fixed sqlite3_io_methods\n  ** object.  But the \"autolockIoFinder\" available on MacOSX does a little\n  ** more than that; it looks at the filesystem type that hosts the \n  ** database file and tries to choose an locking method appropriate for\n  ** that filesystem time.\n  */\n  #define UNIXVFS(VFSNAME, FINDER) {                        \\\n    3,                    /* iVersion */                    \\\n    sizeof(unixFile),     /* szOsFile */                    \\\n    MAX_PATHNAME,         /* mxPathname */                  \\\n    0,                    /* pNext */                       \\\n    VFSNAME,              /* zName */                       \\\n    (void*)&FINDER,       /* pAppData */                    \\\n    unixOpen,             /* xOpen */                       \\\n    unixDelete,           /* xDelete */                     \\\n    unixAccess,           /* xAccess */                     \\\n    unixFullPathname,     /* xFullPathname */               \\\n    unixDlOpen,           /* xDlOpen */                     \\\n    unixDlError,          /* xDlError */                    \\\n    unixDlSym,            /* xDlSym */                      \\\n    unixDlClose,          /* xDlClose */                    \\\n    unixRandomness,       /* xRandomness */                 \\\n    unixSleep,            /* xSleep */                      \\\n    unixCurrentTime,      /* xCurrentTime */                \\\n    unixGetLastError,     /* xGetLastError */               \\\n    unixCurrentTimeInt64, /* xCurrentTimeInt64 */           \\\n    unixSetSystemCall,    /* xSetSystemCall */              \\\n    unixGetSystemCall,    /* xGetSystemCall */              \\\n    unixNextSystemCall,   /* xNextSystemCall */             \\\n  }\n\n  /*\n  ** All default VFSes for unix are contained in the following array.\n  **\n  ** Note that the sqlite3_vfs.pNext field of the VFS object is modified\n  ** by the SQLite core when the VFS is registered.  So the following\n  ** array cannot be const.\n  */\n  static sqlite3_vfs aVfs[] = {\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix\",          autolockIoFinder ),\n#elif OS_VXWORKS\n    UNIXVFS(\"unix\",          vxworksIoFinder ),\n#else\n    UNIXVFS(\"unix\",          posixIoFinder ),\n#endif\n    UNIXVFS(\"unix-none\",     nolockIoFinder ),\n    UNIXVFS(\"unix-dotfile\",  dotlockIoFinder ),\n    UNIXVFS(\"unix-excl\",     posixIoFinder ),\n#if OS_VXWORKS\n    UNIXVFS(\"unix-namedsem\", semIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS\n    UNIXVFS(\"unix-posix\",    posixIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n    UNIXVFS(\"unix-flock\",    flockIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix-afp\",      afpIoFinder ),\n    UNIXVFS(\"unix-nfs\",      nfsIoFinder ),\n    UNIXVFS(\"unix-proxy\",    proxyIoFinder ),\n#endif\n  };\n  unsigned int i;          /* Loop counter */\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==29 );\n\n  /* Register all VFSes defined in the aVfs[] array */\n  for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){\n    sqlite3_vfs_register(&aVfs[i], i==0);\n  }\n  return SQLITE_OK; \n}\n\n/*\n** Shutdown the operating system interface.\n**\n** Some operating systems might need to do some cleanup in this routine,\n** to release dynamically allocated objects.  But not on unix.\n** This routine is a no-op for unix.\n*/\nSQLITE_API int sqlite3_os_end(void){ \n  return SQLITE_OK; \n}\n \n#endif /* SQLITE_OS_UNIX */\n\n/************** End of os_unix.c *********************************************/\n/************** Begin file os_win.c ******************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n/* #include \"sqliteInt.h\" */\n#if SQLITE_OS_WIN               /* This file is used for Windows only */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n/************** Include os_common.h in the middle of os_win.c ****************/\n/************** Begin file os_common.h ***************************************/\n/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of os_common.h ****************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in os_common.h ******************/\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_io_error_hit;\nSQLITE_API extern int sqlite3_io_error_hardhit;\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_persist;\nSQLITE_API extern int sqlite3_io_error_benign;\nSQLITE_API extern int sqlite3_diskfull_pending;\nSQLITE_API extern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nSQLITE_API extern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n\n/************** End of os_common.h *******************************************/\n/************** Continuing where we left off in os_win.c *********************/\n\n/*\n** Include the header file for the Windows VFS.\n*/\n/* #include \"os_win.h\" */\n\n/*\n** Compiling and using WAL mode requires several APIs that are only\n** available in Windows platforms based on the NT kernel.\n*/\n#if !SQLITE_OS_WINNT && !defined(SQLITE_OMIT_WAL)\n#  error \"WAL mode requires support from the Windows NT kernel, compile\\\n with SQLITE_OMIT_WAL.\"\n#endif\n\n#if !SQLITE_OS_WINNT && SQLITE_MAX_MMAP_SIZE>0\n#  error \"Memory mapped files require support from the Windows NT kernel,\\\n compile with SQLITE_MAX_MMAP_SIZE=0.\"\n#endif\n\n/*\n** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)\n#  define SQLITE_WIN32_HAS_ANSI\n#endif\n\n/*\n** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \\\n    !defined(SQLITE_WIN32_NO_WIDE)\n#  define SQLITE_WIN32_HAS_WIDE\n#endif\n\n/*\n** Make sure at least one set of Win32 APIs is available.\n*/\n#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)\n#  error \"At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\\\n must be defined.\"\n#endif\n\n/*\n** Define the required Windows SDK version constants if they are not\n** already available.\n*/\n#ifndef NTDDI_WIN8\n#  define NTDDI_WIN8                        0x06020000\n#endif\n\n#ifndef NTDDI_WINBLUE\n#  define NTDDI_WINBLUE                     0x06030000\n#endif\n\n#ifndef NTDDI_WINTHRESHOLD\n#  define NTDDI_WINTHRESHOLD                0x06040000\n#endif\n\n/*\n** Check to see if the GetVersionEx[AW] functions are deprecated on the\n** target system.  GetVersionEx was first deprecated in Win8.1.\n*/\n#ifndef SQLITE_WIN32_GETVERSIONEX\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE\n#    define SQLITE_WIN32_GETVERSIONEX   0   /* GetVersionEx() is deprecated */\n#  else\n#    define SQLITE_WIN32_GETVERSIONEX   1   /* GetVersionEx() is current */\n#  endif\n#endif\n\n/*\n** Check to see if the CreateFileMappingA function is supported on the\n** target system.  It is unavailable when using \"mincore.lib\" on Win10.\n** When compiling for Windows 10, always assume \"mincore.lib\" is in use.\n*/\n#ifndef SQLITE_WIN32_CREATEFILEMAPPINGA\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINTHRESHOLD\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   0\n#  else\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   1\n#  endif\n#endif\n\n/*\n** This constant should already be defined (in the \"WinDef.h\" SDK file).\n*/\n#ifndef MAX_PATH\n#  define MAX_PATH                      (260)\n#endif\n\n/*\n** Maximum pathname length (in chars) for Win32.  This should normally be\n** MAX_PATH.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_CHARS\n#  define SQLITE_WIN32_MAX_PATH_CHARS   (MAX_PATH)\n#endif\n\n/*\n** This constant should already be defined (in the \"WinNT.h\" SDK file).\n*/\n#ifndef UNICODE_STRING_MAX_CHARS\n#  define UNICODE_STRING_MAX_CHARS      (32767)\n#endif\n\n/*\n** Maximum pathname length (in chars) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS.\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_CHARS\n#  define SQLITE_WINNT_MAX_PATH_CHARS   (UNICODE_STRING_MAX_CHARS)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in\n** characters, so we allocate 4 bytes per character assuming worst-case of\n** 4-bytes-per-character for UTF8.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_BYTES\n#  define SQLITE_WIN32_MAX_PATH_BYTES   (SQLITE_WIN32_MAX_PATH_CHARS*4)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS * sizeof(WCHAR).\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_BYTES\n#  define SQLITE_WINNT_MAX_PATH_BYTES   \\\n                            (sizeof(WCHAR) * SQLITE_WINNT_MAX_PATH_CHARS)\n#endif\n\n/*\n** Maximum error message length (in chars) for WinRT.\n*/\n#ifndef SQLITE_WIN32_MAX_ERRMSG_CHARS\n#  define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024)\n#endif\n\n/*\n** Returns non-zero if the character should be treated as a directory\n** separator.\n*/\n#ifndef winIsDirSep\n#  define winIsDirSep(a)                (((a) == '/') || ((a) == '\\\\'))\n#endif\n\n/*\n** This macro is used when a local variable is set to a value that is\n** [sometimes] not used by the code (e.g. via conditional compilation).\n*/\n#ifndef UNUSED_VARIABLE_VALUE\n#  define UNUSED_VARIABLE_VALUE(x)      (void)(x)\n#endif\n\n/*\n** Returns the character that should be used as the directory separator.\n*/\n#ifndef winGetDirSep\n#  define winGetDirSep()                '\\\\'\n#endif\n\n/*\n** Do we need to manually define the Win32 file mapping APIs for use with WAL\n** mode or memory mapped files (e.g. these APIs are available in the Windows\n** CE SDK; however, they are not present in the header file)?\n*/\n#if SQLITE_WIN32_FILEMAPPING_API && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n/*\n** Two of the file mapping APIs are different under WinRT.  Figure out which\n** set we need.\n*/\n#if SQLITE_OS_WINRT\nWINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \\\n        LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);\n\nWINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);\n#else\n#if defined(SQLITE_WIN32_HAS_ANSI)\nWINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCSTR);\n#endif /* defined(SQLITE_WIN32_HAS_ANSI) */\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\nWINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCWSTR);\n#endif /* defined(SQLITE_WIN32_HAS_WIDE) */\n\nWINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);\n#endif /* SQLITE_OS_WINRT */\n\n/*\n** These file mapping APIs are common to both Win32 and WinRT.\n*/\n\nWINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);\nWINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);\n#endif /* SQLITE_WIN32_FILEMAPPING_API */\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_FILE_ATTRIBUTES\n# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)\n#endif\n\n#ifndef FILE_FLAG_MASK\n# define FILE_FLAG_MASK          (0xFF3C0000)\n#endif\n\n#ifndef FILE_ATTRIBUTE_MASK\n# define FILE_ATTRIBUTE_MASK     (0x0003FFF7)\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/* Forward references to structures used for WAL */\ntypedef struct winShm winShm;           /* A connection to shared-memory */\ntypedef struct winShmNode winShmNode;   /* A region of shared-memory */\n#endif\n\n/*\n** WinCE lacks native support for file locking so we have to fake it\n** with some code of our own.\n*/\n#if SQLITE_OS_WINCE\ntypedef struct winceLock {\n  int nReaders;       /* Number of reader locks obtained */\n  BOOL bPending;      /* Indicates a pending lock has been obtained */\n  BOOL bReserved;     /* Indicates a reserved lock has been obtained */\n  BOOL bExclusive;    /* Indicates an exclusive lock has been obtained */\n} winceLock;\n#endif\n\n/*\n** The winFile structure is a subclass of sqlite3_file* specific to the win32\n** portability layer.\n*/\ntypedef struct winFile winFile;\nstruct winFile {\n  const sqlite3_io_methods *pMethod; /*** Must be first ***/\n  sqlite3_vfs *pVfs;      /* The VFS used to open this file */\n  HANDLE h;               /* Handle for accessing the file */\n  u8 locktype;            /* Type of lock currently held on this file */\n  short sharedLockByte;   /* Randomly chosen byte used as a shared lock */\n  u8 ctrlFlags;           /* Flags.  See WINFILE_* below */\n  DWORD lastErrno;        /* The Windows errno from the last I/O error */\n#ifndef SQLITE_OMIT_WAL\n  winShm *pShm;           /* Instance of shared memory on this file */\n#endif\n  const char *zPath;      /* Full pathname of this file */\n  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_OS_WINCE\n  LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */\n  HANDLE hMutex;          /* Mutex used to control access to shared lock */\n  HANDLE hShared;         /* Shared memory segment used for locking */\n  winceLock local;        /* Locks obtained by this instance of winFile */\n  winceLock *shared;      /* Global shared lock memory for the file  */\n#endif\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                /* Number of outstanding xFetch references */\n  HANDLE hMap;                  /* Handle for accessing memory mapping */\n  void *pMapRegion;             /* Area memory mapped */\n  sqlite3_int64 mmapSize;       /* Usable size of mapped region */\n  sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */\n  sqlite3_int64 mmapSizeMax;    /* Configured FCNTL_MMAP_SIZE value */\n#endif\n};\n\n/*\n** The winVfsAppData structure is used for the pAppData member for all of the\n** Win32 VFS variants.\n*/\ntypedef struct winVfsAppData winVfsAppData;\nstruct winVfsAppData {\n  const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */\n  void *pAppData;                    /* The extra pAppData, if any. */\n  BOOL bNoLock;                      /* Non-zero if locking is disabled. */\n};\n\n/*\n** Allowed values for winFile.ctrlFlags\n*/\n#define WINFILE_RDONLY          0x02   /* Connection is read only */\n#define WINFILE_PERSIST_WAL     0x04   /* Persistent WAL mode */\n#define WINFILE_PSOW            0x10   /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n\n/*\n * The size of the buffer used by sqlite3_win32_write_debug().\n */\n#ifndef SQLITE_WIN32_DBG_BUF_SIZE\n#  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the data directory should be changed.\n */\n#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE\n#  define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1)\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the temporary directory should be changed.\n */\n#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n#  define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2)\n#endif\n\n/*\n * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the\n * various Win32 API heap functions instead of our own.\n */\n#ifdef SQLITE_WIN32_MALLOC\n\n/*\n * If this is non-zero, an isolated heap will be created by the native Win32\n * allocator subsystem; otherwise, the default process heap will be used.  This\n * setting has no effect when compiling for WinRT.  By default, this is enabled\n * and an isolated heap will be created to store all allocated data.\n *\n ******************************************************************************\n * WARNING: It is important to note that when this setting is non-zero and the\n *          winMemShutdown function is called (e.g. by the sqlite3_shutdown\n *          function), all data that was allocated using the isolated heap will\n *          be freed immediately and any attempt to access any of that freed\n *          data will almost certainly result in an immediate access violation.\n ******************************************************************************\n */\n#ifndef SQLITE_WIN32_HEAP_CREATE\n#  define SQLITE_WIN32_HEAP_CREATE        (TRUE)\n#endif\n\n/*\n * This is the maximum possible initial size of the Win32-specific heap, in\n * bytes.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)\n#endif\n\n/*\n * This is the extra space for the initial size of the Win32-specific heap,\n * in bytes.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA\n#  define SQLITE_WIN32_HEAP_INIT_EXTRA  (4194304)\n#endif\n\n/*\n * Calculate the maximum legal cache size, in pages, based on the maximum\n * possible initial heap size and the default page size, setting aside the\n * needed extra space.\n */\n#ifndef SQLITE_WIN32_MAX_CACHE_SIZE\n#  define SQLITE_WIN32_MAX_CACHE_SIZE   (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \\\n                                          (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE))\n#endif\n\n/*\n * This is cache size used in the calculation of the initial size of the\n * Win32-specific heap.  It cannot be negative.\n */\n#ifndef SQLITE_WIN32_CACHE_SIZE\n#  if SQLITE_DEFAULT_CACHE_SIZE>=0\n#    define SQLITE_WIN32_CACHE_SIZE     (SQLITE_DEFAULT_CACHE_SIZE)\n#  else\n#    define SQLITE_WIN32_CACHE_SIZE     (-(SQLITE_DEFAULT_CACHE_SIZE))\n#  endif\n#endif\n\n/*\n * Make sure that the calculated cache size, in pages, cannot cause the\n * initial size of the Win32-specific heap to exceed the maximum amount\n * of memory that can be specified in the call to HeapCreate.\n */\n#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE\n#  undef SQLITE_WIN32_CACHE_SIZE\n#  define SQLITE_WIN32_CACHE_SIZE       (2000)\n#endif\n\n/*\n * The initial size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_INIT_SIZE   ((SQLITE_WIN32_CACHE_SIZE) * \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE) + \\\n                                         (SQLITE_WIN32_HEAP_INIT_EXTRA))\n#endif\n\n/*\n * The maximum size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_SIZE    (0)\n#endif\n\n/*\n * The extra flags to use in calls to the Win32 heap APIs.  This value may be\n * zero for the default behavior.\n */\n#ifndef SQLITE_WIN32_HEAP_FLAGS\n#  define SQLITE_WIN32_HEAP_FLAGS       (0)\n#endif\n\n\n/*\n** The winMemData structure stores information required by the Win32-specific\n** sqlite3_mem_methods implementation.\n*/\ntypedef struct winMemData winMemData;\nstruct winMemData {\n#ifndef NDEBUG\n  u32 magic1;   /* Magic number to detect structure corruption. */\n#endif\n  HANDLE hHeap; /* The handle to our heap. */\n  BOOL bOwned;  /* Do we own the heap (i.e. destroy it on shutdown)? */\n#ifndef NDEBUG\n  u32 magic2;   /* Magic number to detect structure corruption. */\n#endif\n};\n\n#ifndef NDEBUG\n#define WINMEM_MAGIC1     0x42b2830b\n#define WINMEM_MAGIC2     0xbd4d7cf4\n#endif\n\nstatic struct winMemData win_mem_data = {\n#ifndef NDEBUG\n  WINMEM_MAGIC1,\n#endif\n  NULL, FALSE\n#ifndef NDEBUG\n  ,WINMEM_MAGIC2\n#endif\n};\n\n#ifndef NDEBUG\n#define winMemAssertMagic1() assert( win_mem_data.magic1==WINMEM_MAGIC1 )\n#define winMemAssertMagic2() assert( win_mem_data.magic2==WINMEM_MAGIC2 )\n#define winMemAssertMagic()  winMemAssertMagic1(); winMemAssertMagic2();\n#else\n#define winMemAssertMagic()\n#endif\n\n#define winMemGetDataPtr()  &win_mem_data\n#define winMemGetHeap()     win_mem_data.hHeap\n#define winMemGetOwned()    win_mem_data.bOwned\n\nstatic void *winMemMalloc(int nBytes);\nstatic void winMemFree(void *pPrior);\nstatic void *winMemRealloc(void *pPrior, int nBytes);\nstatic int winMemSize(void *p);\nstatic int winMemRoundup(int n);\nstatic int winMemInit(void *pAppData);\nstatic void winMemShutdown(void *pAppData);\n\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void);\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** The following variable is (normally) set once and never changes\n** thereafter.  It records whether the operating system is Win9x\n** or WinNT.\n**\n** 0:   Operating system unknown.\n** 1:   Operating system is Win9x.\n** 2:   Operating system is WinNT.\n**\n** In order to facilitate testing on a WinNT system, the test fixture\n** can manually set this value to 1 to emulate Win98 behavior.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#else\nstatic LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#endif\n\n#ifndef SYSCALL\n#  define SYSCALL sqlite3_syscall_ptr\n#endif\n\n/*\n** This function is not available on Windows CE or WinRT.\n */\n\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n#  define osAreFileApisANSI()       1\n#endif\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct win_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"AreFileApisANSI\",         (SYSCALL)AreFileApisANSI,         0 },\n#else\n  { \"AreFileApisANSI\",         (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osAreFileApisANSI\n#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharLowerW\",              (SYSCALL)CharLowerW,              0 },\n#else\n  { \"CharLowerW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharLowerW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[1].pCurrent)\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharUpperW\",              (SYSCALL)CharUpperW,              0 },\n#else\n  { \"CharUpperW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharUpperW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[2].pCurrent)\n\n  { \"CloseHandle\",             (SYSCALL)CloseHandle,             0 },\n\n#define osCloseHandle ((BOOL(WINAPI*)(HANDLE))aSyscall[3].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"CreateFileA\",             (SYSCALL)CreateFileA,             0 },\n#else\n  { \"CreateFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateFileW\",             (SYSCALL)CreateFileW,             0 },\n#else\n  { \"CreateFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \\\n        SQLITE_WIN32_CREATEFILEMAPPINGA\n  { \"CreateFileMappingA\",      (SYSCALL)CreateFileMappingA,      0 },\n#else\n  { \"CreateFileMappingA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"CreateFileMappingW\",      (SYSCALL)CreateFileMappingW,      0 },\n#else\n  { \"CreateFileMappingW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateMutexW\",            (SYSCALL)CreateMutexW,            0 },\n#else\n  { \"CreateMutexW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \\\n        LPCWSTR))aSyscall[8].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"DeleteFileA\",             (SYSCALL)DeleteFileA,             0 },\n#else\n  { \"DeleteFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"DeleteFileW\",             (SYSCALL)DeleteFileW,             0 },\n#else\n  { \"DeleteFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToLocalFileTime\", (SYSCALL)FileTimeToLocalFileTime, 0 },\n#else\n  { \"FileTimeToLocalFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPFILETIME))aSyscall[11].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToSystemTime\",    (SYSCALL)FileTimeToSystemTime,    0 },\n#else\n  { \"FileTimeToSystemTime\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPSYSTEMTIME))aSyscall[12].pCurrent)\n\n  { \"FlushFileBuffers\",        (SYSCALL)FlushFileBuffers,        0 },\n\n#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"FormatMessageA\",          (SYSCALL)FormatMessageA,          0 },\n#else\n  { \"FormatMessageA\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \\\n        DWORD,va_list*))aSyscall[14].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"FormatMessageW\",          (SYSCALL)FormatMessageW,          0 },\n#else\n  { \"FormatMessageW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \\\n        DWORD,va_list*))aSyscall[15].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"FreeLibrary\",             (SYSCALL)FreeLibrary,             0 },\n#else\n  { \"FreeLibrary\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent)\n\n  { \"GetCurrentProcessId\",     (SYSCALL)GetCurrentProcessId,     0 },\n\n#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)GetDiskFreeSpaceA,       0 },\n#else\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[18].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)GetDiskFreeSpaceW,       0 },\n#else\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[19].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFileAttributesA\",      (SYSCALL)GetFileAttributesA,      0 },\n#else\n  { \"GetFileAttributesA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesW\",      (SYSCALL)GetFileAttributesW,      0 },\n#else\n  { \"GetFileAttributesW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesExW\",    (SYSCALL)GetFileAttributesExW,    0 },\n#else\n  { \"GetFileAttributesExW\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \\\n        LPVOID))aSyscall[22].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetFileSize\",             (SYSCALL)GetFileSize,             0 },\n#else\n  { \"GetFileSize\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFullPathNameA\",        (SYSCALL)GetFullPathNameA,        0 },\n#else\n  { \"GetFullPathNameA\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \\\n        LPSTR*))aSyscall[24].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFullPathNameW\",        (SYSCALL)GetFullPathNameW,        0 },\n#else\n  { \"GetFullPathNameW\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \\\n        LPWSTR*))aSyscall[25].pCurrent)\n\n  { \"GetLastError\",            (SYSCALL)GetLastError,            0 },\n\n#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#if SQLITE_OS_WINCE\n  /* The GetProcAddressA() routine is only available on Windows CE. */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddressA,         0 },\n#else\n  /* All other Windows platforms expect GetProcAddress() to take\n  ** an ANSI string regardless of the _UNICODE setting */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddress,          0 },\n#endif\n#else\n  { \"GetProcAddressA\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \\\n        LPCSTR))aSyscall[27].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetSystemInfo\",           (SYSCALL)GetSystemInfo,           0 },\n#else\n  { \"GetSystemInfo\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)\n\n  { \"GetSystemTime\",           (SYSCALL)GetSystemTime,           0 },\n\n#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)GetSystemTimeAsFileTime, 0 },\n#else\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \\\n        LPFILETIME))aSyscall[30].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetTempPathA\",            (SYSCALL)GetTempPathA,            0 },\n#else\n  { \"GetTempPathA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetTempPathW\",            (SYSCALL)GetTempPathW,            0 },\n#else\n  { \"GetTempPathW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetTickCount\",            (SYSCALL)GetTickCount,            0 },\n#else\n  { \"GetTickCount\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExA\",           (SYSCALL)GetVersionExA,           0 },\n#else\n  { \"GetVersionExA\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExA ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOA))aSyscall[34].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExW\",           (SYSCALL)GetVersionExW,           0 },\n#else\n  { \"GetVersionExW\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExW ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOW))aSyscall[35].pCurrent)\n\n  { \"HeapAlloc\",               (SYSCALL)HeapAlloc,               0 },\n\n#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \\\n        SIZE_T))aSyscall[36].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapCreate\",              (SYSCALL)HeapCreate,              0 },\n#else\n  { \"HeapCreate\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \\\n        SIZE_T))aSyscall[37].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapDestroy\",             (SYSCALL)HeapDestroy,             0 },\n#else\n  { \"HeapDestroy\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)\n\n  { \"HeapFree\",                (SYSCALL)HeapFree,                0 },\n\n#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[39].pCurrent)\n\n  { \"HeapReAlloc\",             (SYSCALL)HeapReAlloc,             0 },\n\n#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \\\n        SIZE_T))aSyscall[40].pCurrent)\n\n  { \"HeapSize\",                (SYSCALL)HeapSize,                0 },\n\n#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[41].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapValidate\",            (SYSCALL)HeapValidate,            0 },\n#else\n  { \"HeapValidate\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[42].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"HeapCompact\",             (SYSCALL)HeapCompact,             0 },\n#else\n  { \"HeapCompact\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCompact ((UINT(WINAPI*)(HANDLE,DWORD))aSyscall[43].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryA\",            (SYSCALL)LoadLibraryA,            0 },\n#else\n  { \"LoadLibraryA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryW\",            (SYSCALL)LoadLibraryW,            0 },\n#else\n  { \"LoadLibraryW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"LocalFree\",               (SYSCALL)LocalFree,               0 },\n#else\n  { \"LocalFree\",               (SYSCALL)0,                       0 },\n#endif\n\n#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"LockFile\",                (SYSCALL)LockFile,                0 },\n#else\n  { \"LockFile\",                (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFile\n#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[47].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"LockFileEx\",              (SYSCALL)LockFileEx,              0 },\n#else\n  { \"LockFileEx\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFileEx\n#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[48].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"MapViewOfFile\",           (SYSCALL)MapViewOfFile,           0 },\n#else\n  { \"MapViewOfFile\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        SIZE_T))aSyscall[49].pCurrent)\n\n  { \"MultiByteToWideChar\",     (SYSCALL)MultiByteToWideChar,     0 },\n\n#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \\\n        int))aSyscall[50].pCurrent)\n\n  { \"QueryPerformanceCounter\", (SYSCALL)QueryPerformanceCounter, 0 },\n\n#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \\\n        LARGE_INTEGER*))aSyscall[51].pCurrent)\n\n  { \"ReadFile\",                (SYSCALL)ReadFile,                0 },\n\n#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[52].pCurrent)\n\n  { \"SetEndOfFile\",            (SYSCALL)SetEndOfFile,            0 },\n\n#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"SetFilePointer\",          (SYSCALL)SetFilePointer,          0 },\n#else\n  { \"SetFilePointer\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \\\n        DWORD))aSyscall[54].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"Sleep\",                   (SYSCALL)Sleep,                   0 },\n#else\n  { \"Sleep\",                   (SYSCALL)0,                       0 },\n#endif\n\n#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)\n\n  { \"SystemTimeToFileTime\",    (SYSCALL)SystemTimeToFileTime,    0 },\n\n#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \\\n        LPFILETIME))aSyscall[56].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"UnlockFile\",              (SYSCALL)UnlockFile,              0 },\n#else\n  { \"UnlockFile\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osUnlockFile\n#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[57].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"UnlockFileEx\",            (SYSCALL)UnlockFileEx,            0 },\n#else\n  { \"UnlockFileEx\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[58].pCurrent)\n\n#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"UnmapViewOfFile\",         (SYSCALL)UnmapViewOfFile,         0 },\n#else\n  { \"UnmapViewOfFile\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[59].pCurrent)\n\n  { \"WideCharToMultiByte\",     (SYSCALL)WideCharToMultiByte,     0 },\n\n#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \\\n        LPCSTR,LPBOOL))aSyscall[60].pCurrent)\n\n  { \"WriteFile\",               (SYSCALL)WriteFile,               0 },\n\n#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[61].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateEventExW\",          (SYSCALL)CreateEventExW,          0 },\n#else\n  { \"CreateEventExW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \\\n        DWORD,DWORD))aSyscall[62].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"WaitForSingleObject\",     (SYSCALL)WaitForSingleObject,     0 },\n#else\n  { \"WaitForSingleObject\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \\\n        DWORD))aSyscall[63].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"WaitForSingleObjectEx\",   (SYSCALL)WaitForSingleObjectEx,   0 },\n#else\n  { \"WaitForSingleObjectEx\",   (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \\\n        BOOL))aSyscall[64].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"SetFilePointerEx\",        (SYSCALL)SetFilePointerEx,        0 },\n#else\n  { \"SetFilePointerEx\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \\\n        PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetFileInformationByHandleEx\", (SYSCALL)GetFileInformationByHandleEx, 0 },\n#else\n  { \"GetFileInformationByHandleEx\", (SYSCALL)0,                  0 },\n#endif\n\n#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \\\n        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"MapViewOfFileFromApp\",    (SYSCALL)MapViewOfFileFromApp,    0 },\n#else\n  { \"MapViewOfFileFromApp\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \\\n        SIZE_T))aSyscall[67].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateFile2\",             (SYSCALL)CreateFile2,             0 },\n#else\n  { \"CreateFile2\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \\\n        LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadPackagedLibrary\",     (SYSCALL)LoadPackagedLibrary,     0 },\n#else\n  { \"LoadPackagedLibrary\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \\\n        DWORD))aSyscall[69].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetTickCount64\",          (SYSCALL)GetTickCount64,          0 },\n#else\n  { \"GetTickCount64\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetNativeSystemInfo\",     (SYSCALL)GetNativeSystemInfo,     0 },\n#else\n  { \"GetNativeSystemInfo\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osGetNativeSystemInfo ((VOID(WINAPI*)( \\\n        LPSYSTEM_INFO))aSyscall[71].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"OutputDebugStringA\",      (SYSCALL)OutputDebugStringA,      0 },\n#else\n  { \"OutputDebugStringA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[72].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"OutputDebugStringW\",      (SYSCALL)OutputDebugStringW,      0 },\n#else\n  { \"OutputDebugStringW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[73].pCurrent)\n\n  { \"GetProcessHeap\",          (SYSCALL)GetProcessHeap,          0 },\n\n#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"CreateFileMappingFromApp\", (SYSCALL)CreateFileMappingFromApp, 0 },\n#else\n  { \"CreateFileMappingFromApp\", (SYSCALL)0,                      0 },\n#endif\n\n#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \\\n        LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)\n\n/*\n** NOTE: On some sub-platforms, the InterlockedCompareExchange \"function\"\n**       is really just a macro that uses a compiler intrinsic (e.g. x64).\n**       So do not try to make this is into a redefinable interface.\n*/\n#if defined(InterlockedCompareExchange)\n  { \"InterlockedCompareExchange\", (SYSCALL)0,                    0 },\n\n#define osInterlockedCompareExchange InterlockedCompareExchange\n#else\n  { \"InterlockedCompareExchange\", (SYSCALL)InterlockedCompareExchange, 0 },\n\n#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \\\n        SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)\n#endif /* defined(InterlockedCompareExchange) */\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreate\",               (SYSCALL)UuidCreate,             0 },\n#else\n  { \"UuidCreate\",               (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreateSequential\",     (SYSCALL)UuidCreateSequential,   0 },\n#else\n  { \"UuidCreateSequential\",     (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreateSequential \\\n        ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)\n\n#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0\n  { \"FlushViewOfFile\",          (SYSCALL)FlushViewOfFile,        0 },\n#else\n  { \"FlushViewOfFile\",          (SYSCALL)0,                      0 },\n#endif\n\n#define osFlushViewOfFile \\\n        ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"win32\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int winSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr winGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** compact it.  Upon success, SQLITE_OK will be returned.  Upon failure, one\n** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned.  The\n** \"pnLargest\" argument, if non-zero, will be used to return the size of the\n** largest committed free block in the heap, in bytes.\n*/\nSQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){\n  int rc = SQLITE_OK;\n  UINT nLargest = 0;\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){\n    DWORD lastErrno = osGetLastError();\n    if( lastErrno==NO_ERROR ){\n      sqlite3_log(SQLITE_NOMEM, \"failed to HeapCompact (no space), heap=%p\",\n                  (void*)hHeap);\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_log(SQLITE_ERROR, \"failed to HeapCompact (%lu), heap=%p\",\n                  osGetLastError(), (void*)hHeap);\n      rc = SQLITE_ERROR;\n    }\n  }\n#else\n  sqlite3_log(SQLITE_NOTFOUND, \"failed to HeapCompact, heap=%p\",\n              (void*)hHeap);\n  rc = SQLITE_NOTFOUND;\n#endif\n  if( pnLargest ) *pnLargest = nLargest;\n  return rc;\n}\n\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** destroy and recreate it.  If the Win32 native heap is not isolated and/or\n** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will\n** be returned and no changes will be made to the Win32 native heap.\n*/\nSQLITE_API int sqlite3_win32_reset_heap(){\n  int rc;\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */\n  MUTEX_LOGIC( sqlite3_mutex *pMem; )    /* The memsys static mutex */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3_mutex_enter(pMem);\n  winMemAssertMagic();\n  if( winMemGetHeap()!=NULL && winMemGetOwned() && sqlite3_memory_used()==0 ){\n    /*\n    ** At this point, there should be no outstanding memory allocations on\n    ** the heap.  Also, since both the master and memsys locks are currently\n    ** being held by us, no other function (i.e. from another thread) should\n    ** be able to even access the heap.  Attempt to destroy and recreate our\n    ** isolated Win32 native heap now.\n    */\n    assert( winMemGetHeap()!=NULL );\n    assert( winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    winMemShutdown(winMemGetDataPtr());\n    assert( winMemGetHeap()==NULL );\n    assert( !winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    rc = winMemInit(winMemGetDataPtr());\n    assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL );\n    assert( rc!=SQLITE_OK || winMemGetOwned() );\n    assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 );\n  }else{\n    /*\n    ** The Win32 native heap cannot be modified because it may be in use.\n    */\n    rc = SQLITE_BUSY;\n  }\n  sqlite3_mutex_leave(pMem);\n  sqlite3_mutex_leave(pMaster);\n  return rc;\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** This function outputs the specified (ANSI) string to the Win32 debugger\n** (if available).\n*/\n\nSQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){\n  char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];\n  int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */\n  if( nMin<-1 ) nMin = -1; /* all negative values become -1. */\n  assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zBuf ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    osOutputDebugStringA(zDbgBuf);\n  }else{\n    osOutputDebugStringA(zBuf);\n  }\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n  memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n  if ( osMultiByteToWideChar(\n          osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf,\n          nMin, (LPWSTR)zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){\n    return;\n  }\n  osOutputDebugStringW((LPCWSTR)zDbgBuf);\n#else\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    fprintf(stderr, \"%s\", zDbgBuf);\n  }else{\n    fprintf(stderr, \"%s\", zBuf);\n  }\n#endif\n}\n\n/*\n** The following routine suspends the current thread for at least ms\n** milliseconds.  This is equivalent to the Win32 Sleep() interface.\n*/\n#if SQLITE_OS_WINRT\nstatic HANDLE sleepObj = NULL;\n#endif\n\nSQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){\n#if SQLITE_OS_WINRT\n  if ( sleepObj==NULL ){\n    sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,\n                                SYNCHRONIZE);\n  }\n  assert( sleepObj!=NULL );\n  osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);\n#else\n  osSleep(milliseconds);\n#endif\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n        SQLITE_THREADSAFE>0\nSQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){\n  DWORD rc;\n  while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,\n                                       TRUE))==WAIT_IO_COMPLETION ){}\n  return rc;\n}\n#endif\n\n/*\n** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,\n** or WinCE.  Return false (zero) for Win95, Win98, or WinME.\n**\n** Here is an interesting observation:  Win95, Win98, and WinME lack\n** the LockFileEx() API.  But we can still statically link against that\n** API as long as we don't call it when running Win95/98/ME.  A call to\n** this routine is used to determine if the host is Win95/98/ME or\n** WinNT/2K/XP so that we will know whether or not we can safely call\n** the LockFileEx() API.\n*/\n\n#if !SQLITE_WIN32_GETVERSIONEX\n# define osIsNT()  (1)\n#elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)\n# define osIsNT()  (1)\n#elif !defined(SQLITE_WIN32_HAS_WIDE)\n# define osIsNT()  (0)\n#else\n# define osIsNT()  ((sqlite3_os_type==2) || sqlite3_win32_is_nt())\n#endif\n\n/*\n** This function determines if the machine is running a version of Windows\n** based on the NT kernel.\n*/\nSQLITE_API int sqlite3_win32_is_nt(void){\n#if SQLITE_OS_WINRT\n  /*\n  ** NOTE: The WinRT sub-platform is always assumed to be based on the NT\n  **       kernel.\n  */\n  return 1;\n#elif SQLITE_WIN32_GETVERSIONEX\n  if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){\n#if defined(SQLITE_WIN32_HAS_ANSI)\n    OSVERSIONINFOA sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExA(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    OSVERSIONINFOW sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExW(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#endif\n  }\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#elif SQLITE_TEST\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#else\n  /*\n  ** NOTE: All sub-platforms where the GetVersionEx[AW] functions are\n  **       deprecated are always assumed to be based on the NT kernel.\n  */\n  return 1;\n#endif\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *winMemMalloc(int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  assert( nBytes>=0 );\n  p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapAlloc %u bytes (%lu), heap=%p\",\n                nBytes, osGetLastError(), (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Free memory.\n*/\nstatic void winMemFree(void *pPrior){\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */\n  if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapFree block %p (%lu), heap=%p\",\n                pPrior, osGetLastError(), (void*)hHeap);\n  }\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *winMemRealloc(void *pPrior, int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  assert( nBytes>=0 );\n  if( !pPrior ){\n    p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  }else{\n    p = osHeapReAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior, (SIZE_T)nBytes);\n  }\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to %s %u bytes (%lu), heap=%p\",\n                pPrior ? \"HeapReAlloc\" : \"HeapAlloc\", nBytes, osGetLastError(),\n                (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n*/\nstatic int winMemSize(void *p){\n  HANDLE hHeap;\n  SIZE_T n;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );\n#endif\n  if( !p ) return 0;\n  n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);\n  if( n==(SIZE_T)-1 ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapSize block %p (%lu), heap=%p\",\n                p, osGetLastError(), (void*)hHeap);\n    return 0;\n  }\n  return (int)n;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int winMemRoundup(int n){\n  return n;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int winMemInit(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return SQLITE_ERROR;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE\n  if( !pWinMemData->hHeap ){\n    DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;\n    DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;\n    if( dwMaximumSize==0 ){\n      dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;\n    }else if( dwInitialSize>dwMaximumSize ){\n      dwInitialSize = dwMaximumSize;\n    }\n    pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS,\n                                      dwInitialSize, dwMaximumSize);\n    if( !pWinMemData->hHeap ){\n      sqlite3_log(SQLITE_NOMEM,\n          \"failed to HeapCreate (%lu), flags=%u, initSize=%lu, maxSize=%lu\",\n          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, dwInitialSize,\n          dwMaximumSize);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pWinMemData->bOwned = TRUE;\n    assert( pWinMemData->bOwned );\n  }\n#else\n  pWinMemData->hHeap = osGetProcessHeap();\n  if( !pWinMemData->hHeap ){\n    sqlite3_log(SQLITE_NOMEM,\n        \"failed to GetProcessHeap (%lu)\", osGetLastError());\n    return SQLITE_NOMEM_BKPT;\n  }\n  pWinMemData->bOwned = FALSE;\n  assert( !pWinMemData->bOwned );\n#endif\n  assert( pWinMemData->hHeap!=0 );\n  assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void winMemShutdown(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n  if( pWinMemData->hHeap ){\n    assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n    assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n    if( pWinMemData->bOwned ){\n      if( !osHeapDestroy(pWinMemData->hHeap) ){\n        sqlite3_log(SQLITE_NOMEM, \"failed to HeapDestroy (%lu), heap=%p\",\n                    osGetLastError(), (void*)pWinMemData->hHeap);\n      }\n      pWinMemData->bOwned = FALSE;\n    }\n    pWinMemData->hHeap = NULL;\n  }\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nSQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetWin32(void){\n  static const sqlite3_mem_methods winMemMethods = {\n    winMemMalloc,\n    winMemFree,\n    winMemRealloc,\n    winMemSize,\n    winMemRoundup,\n    winMemInit,\n    winMemShutdown,\n    &win_mem_data\n  };\n  return &winMemMethods;\n}\n\nSQLITE_PRIVATE void sqlite3MemSetDefault(void){\n  sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** Convert a UTF-8 string to Microsoft Unicode.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winUtf8ToUnicode(const char *zText){\n  int nChar;\n  LPWSTR zWideText;\n\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideText = sqlite3MallocZero( nChar*sizeof(WCHAR) );\n  if( zWideText==0 ){\n    return 0;\n  }\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideText);\n    zWideText = 0;\n  }\n  return zWideText;\n}\n\n/*\n** Convert a Microsoft Unicode string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToUtf8(LPCWSTR zWideText){\n  int nByte;\n  char *zText;\n\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, zText, nByte,\n                                0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert an ANSI string to Microsoft Unicode, using the ANSI or OEM\n** code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winMbcsToUnicode(const char *zText, int useAnsi){\n  int nByte;\n  LPWSTR zMbcsText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, NULL,\n                                0)*sizeof(WCHAR);\n  if( nByte==0 ){\n    return 0;\n  }\n  zMbcsText = sqlite3MallocZero( nByte*sizeof(WCHAR) );\n  if( zMbcsText==0 ){\n    return 0;\n  }\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, zMbcsText,\n                                nByte);\n  if( nByte==0 ){\n    sqlite3_free(zMbcsText);\n    zMbcsText = 0;\n  }\n  return zMbcsText;\n}\n\n/*\n** Convert a Microsoft Unicode string to a multi-byte character string,\n** using the ANSI or OEM code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToMbcs(LPCWSTR zWideText, int useAnsi){\n  int nByte;\n  char *zText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, zText,\n                                nByte, 0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert a multi-byte character string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winMbcsToUtf8(const char *zText, int useAnsi){\n  char *zTextUtf8;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winMbcsToUnicode(zText, useAnsi);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextUtf8 = winUnicodeToUtf8(zTmpWide);\n  sqlite3_free(zTmpWide);\n  return zTextUtf8;\n}\n\n/*\n** Convert a UTF-8 string to a multi-byte character string.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUtf8ToMbcs(const char *zText, int useAnsi){\n  char *zTextMbcs;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winUtf8ToUnicode(zText);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextMbcs = winUnicodeToMbcs(zTmpWide, useAnsi);\n  sqlite3_free(zTmpWide);\n  return zTextMbcs;\n}\n\n/*\n** This is a public wrapper for the winUtf8ToUnicode() function.\n*/\nSQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToUnicode(zText);\n}\n\n/*\n** This is a public wrapper for the winUnicodeToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_unicode_to_utf8(LPCWSTR zWideText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zWideText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUnicodeToUtf8(zWideText);\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nSQLITE_API char *sqlite3_win32_mbcs_to_utf8_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, useAnsi);\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nSQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nSQLITE_API char *sqlite3_win32_utf8_to_mbcs_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, useAnsi);\n}\n\n/*\n** This function sets the data directory or the temporary directory based on\n** the provided arguments.  The type argument must be 1 in order to set the\n** data directory or 2 in order to set the temporary directory.  The zValue\n** argument is the name of the directory to use.  The return value will be\n** SQLITE_OK if successful.\n*/\nSQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){\n  char **ppDirectory = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_data_directory;\n  }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_temp_directory;\n  }\n  assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE\n          || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n  );\n  assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );\n  if( ppDirectory ){\n    char *zValueUtf8 = 0;\n    if( zValue && zValue[0] ){\n      zValueUtf8 = winUnicodeToUtf8(zValue);\n      if ( zValueUtf8==0 ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    sqlite3_free(*ppDirectory);\n    *ppDirectory = zValueUtf8;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** The return value of winGetLastErrorMsg\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated).\n*/\nstatic int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){\n  /* FormatMessage returns 0 on failure.  Otherwise it\n  ** returns the number of TCHARs written to the output\n  ** buffer, excluding the terminating null char.\n  */\n  DWORD dwLen = 0;\n  char *zOut = 0;\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1];\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             zTempWide,\n                             SQLITE_WIN32_MAX_ERRMSG_CHARS,\n                             0);\n#else\n    LPWSTR zTempWide = NULL;\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPWSTR) &zTempWide,\n                             0,\n                             0);\n#endif\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winUnicodeToUtf8(zTempWide);\n      sqlite3EndBenignMalloc();\n#if !SQLITE_OS_WINRT\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTempWide);\n#endif\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp = NULL;\n    dwLen = osFormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPSTR) &zTemp,\n                             0,\n                             0);\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n      sqlite3EndBenignMalloc();\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTemp);\n    }\n  }\n#endif\n  if( 0 == dwLen ){\n    sqlite3_snprintf(nBuf, zBuf, \"OsError 0x%lx (%lu)\", lastErrno, lastErrno);\n  }else{\n    /* copy a maximum of nBuf chars to output buffer */\n    sqlite3_snprintf(nBuf, zBuf, \"%s\", zOut);\n    /* free the UTF8 buffer */\n    sqlite3_free(zOut);\n  }\n  return 0;\n}\n\n/*\n**\n** This function - winLogErrorAtLine() - is only ever called via the macro\n** winLogError().\n**\n** This routine is invoked after an error occurs in an OS function.\n** It logs a message using sqlite3_log() containing the current value of\n** error code and, if possible, the human-readable equivalent from\n** FormatMessage.\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).\n** The two subsequent arguments should be the name of the OS function that\n** failed and the associated file-system path, if any.\n*/\n#define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)\nstatic int winLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  DWORD lastErrno,                /* Win32 last error */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char zMsg[500];                 /* Human readable error text */\n  int i;                          /* Loop counter */\n\n  zMsg[0] = 0;\n  winGetLastErrorMsg(lastErrno, sizeof(zMsg), zMsg);\n  assert( errcode!=SQLITE_OK );\n  if( zPath==0 ) zPath = \"\";\n  for(i=0; zMsg[i] && zMsg[i]!='\\r' && zMsg[i]!='\\n'; i++){}\n  zMsg[i] = 0;\n  sqlite3_log(errcode,\n      \"os_win.c:%d: (%lu) %s(%s) - %s\",\n      iLine, lastErrno, zFunc, zPath, zMsg\n  );\n\n  return errcode;\n}\n\n/*\n** The number of times that a ReadFile(), WriteFile(), and DeleteFile()\n** will be retried following a locking error - probably caused by\n** antivirus software.  Also the initial delay before the first retry.\n** The delay increases linearly with each retry.\n*/\n#ifndef SQLITE_WIN32_IOERR_RETRY\n# define SQLITE_WIN32_IOERR_RETRY 10\n#endif\n#ifndef SQLITE_WIN32_IOERR_RETRY_DELAY\n# define SQLITE_WIN32_IOERR_RETRY_DELAY 25\n#endif\nstatic int winIoerrRetry = SQLITE_WIN32_IOERR_RETRY;\nstatic int winIoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY;\n\n/*\n** The \"winIoerrCanRetry1\" macro is used to determine if a particular I/O\n** error code obtained via GetLastError() is eligible to be retried.  It\n** must accept the error code DWORD as its only argument and should return\n** non-zero if the error code is transient in nature and the operation\n** responsible for generating the original error might succeed upon being\n** retried.  The argument to this macro should be a variable.\n**\n** Additionally, a macro named \"winIoerrCanRetry2\" may be defined.  If it\n** is defined, it will be consulted only when the macro \"winIoerrCanRetry1\"\n** returns zero.  The \"winIoerrCanRetry2\" macro is completely optional and\n** may be used to include additional error codes in the set that should\n** result in the failing I/O operation being retried by the caller.  If\n** defined, the \"winIoerrCanRetry2\" macro must exhibit external semantics\n** identical to those of the \"winIoerrCanRetry1\" macro.\n*/\n#if !defined(winIoerrCanRetry1)\n#define winIoerrCanRetry1(a) (((a)==ERROR_ACCESS_DENIED)        || \\\n                              ((a)==ERROR_SHARING_VIOLATION)    || \\\n                              ((a)==ERROR_LOCK_VIOLATION)       || \\\n                              ((a)==ERROR_DEV_NOT_EXIST)        || \\\n                              ((a)==ERROR_NETNAME_DELETED)      || \\\n                              ((a)==ERROR_SEM_TIMEOUT)          || \\\n                              ((a)==ERROR_NETWORK_UNREACHABLE))\n#endif\n\n/*\n** If a ReadFile() or WriteFile() error occurs, invoke this routine\n** to see if it should be retried.  Return TRUE to retry.  Return FALSE\n** to give up with an error.\n*/\nstatic int winRetryIoerr(int *pnRetry, DWORD *pError){\n  DWORD e = osGetLastError();\n  if( *pnRetry>=winIoerrRetry ){\n    if( pError ){\n      *pError = e;\n    }\n    return 0;\n  }\n  if( winIoerrCanRetry1(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#if defined(winIoerrCanRetry2)\n  else if( winIoerrCanRetry2(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#endif\n  if( pError ){\n    *pError = e;\n  }\n  return 0;\n}\n\n/*\n** Log a I/O error retry episode.\n*/\nstatic void winLogIoerr(int nRetry, int lineno){\n  if( nRetry ){\n    sqlite3_log(SQLITE_NOTICE,\n      \"delayed %dms for lock/sharing conflict at line %d\",\n      winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno\n    );\n  }\n}\n\n/*\n** This #if does not rely on the SQLITE_OS_WINCE define because the\n** corresponding section in \"date.c\" cannot use it.\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So define a substitute.\n*/\n/* #  include <time.h> */\nstruct tm *__cdecl localtime(const time_t *t)\n{\n  static struct tm y;\n  FILETIME uTm, lTm;\n  SYSTEMTIME pTm;\n  sqlite3_int64 t64;\n  t64 = *t;\n  t64 = (t64 + 11644473600)*10000000;\n  uTm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);\n  uTm.dwHighDateTime= (DWORD)(t64 >> 32);\n  osFileTimeToLocalFileTime(&uTm,&lTm);\n  osFileTimeToSystemTime(&lTm,&pTm);\n  y.tm_year = pTm.wYear - 1900;\n  y.tm_mon = pTm.wMonth - 1;\n  y.tm_wday = pTm.wDayOfWeek;\n  y.tm_mday = pTm.wDay;\n  y.tm_hour = pTm.wHour;\n  y.tm_min = pTm.wMinute;\n  y.tm_sec = pTm.wSecond;\n  return &y;\n}\n#endif\n\n#if SQLITE_OS_WINCE\n/*************************************************************************\n** This section contains code for WinCE only.\n*/\n#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]\n\n/*\n** Acquire a lock on the handle h\n*/\nstatic void winceMutexAcquire(HANDLE h){\n   DWORD dwErr;\n   do {\n     dwErr = osWaitForSingleObject(h, INFINITE);\n   } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED);\n}\n/*\n** Release a lock acquired by winceMutexAcquire()\n*/\n#define winceMutexRelease(h) ReleaseMutex(h)\n\n/*\n** Create the mutex and shared memory used for locking in the file\n** descriptor pFile\n*/\nstatic int winceCreateLock(const char *zFilename, winFile *pFile){\n  LPWSTR zTok;\n  LPWSTR zName;\n  DWORD lastErrno;\n  BOOL bLogged = FALSE;\n  BOOL bInit = TRUE;\n\n  zName = winUtf8ToUnicode(zFilename);\n  if( zName==0 ){\n    /* out of memory */\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Initialize the local lockdata */\n  memset(&pFile->local, 0, sizeof(pFile->local));\n\n  /* Replace the backslashes from the filename and lowercase it\n  ** to derive a mutex name. */\n  zTok = osCharLowerW(zName);\n  for (;*zTok;zTok++){\n    if (*zTok == '\\\\') *zTok = '_';\n  }\n\n  /* Create/open the named mutex */\n  pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);\n  if (!pFile->hMutex){\n    pFile->lastErrno = osGetLastError();\n    sqlite3_free(zName);\n    return winLogError(SQLITE_IOERR, pFile->lastErrno,\n                       \"winceCreateLock1\", zFilename);\n  }\n\n  /* Acquire the mutex before continuing */\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Since the names of named mutexes, semaphores, file mappings etc are\n  ** case-sensitive, take advantage of that by uppercasing the mutex name\n  ** and using that as the shared filemapping name.\n  */\n  osCharUpperW(zName);\n  pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,\n                                        PAGE_READWRITE, 0, sizeof(winceLock),\n                                        zName);\n\n  /* Set a flag that indicates we're the first to create the memory so it\n  ** must be zero-initialized */\n  lastErrno = osGetLastError();\n  if (lastErrno == ERROR_ALREADY_EXISTS){\n    bInit = FALSE;\n  }\n\n  sqlite3_free(zName);\n\n  /* If we succeeded in making the shared memory handle, map it. */\n  if( pFile->hShared ){\n    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,\n             FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));\n    /* If mapping failed, close the shared memory handle and erase it */\n    if( !pFile->shared ){\n      pFile->lastErrno = osGetLastError();\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock2\", zFilename);\n      bLogged = TRUE;\n      osCloseHandle(pFile->hShared);\n      pFile->hShared = NULL;\n    }\n  }\n\n  /* If shared memory could not be created, then close the mutex and fail */\n  if( pFile->hShared==NULL ){\n    if( !bLogged ){\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock3\", zFilename);\n      bLogged = TRUE;\n    }\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n    return SQLITE_IOERR;\n  }\n\n  /* Initialize the shared memory if we're supposed to */\n  if( bInit ){\n    memset(pFile->shared, 0, sizeof(winceLock));\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return SQLITE_OK;\n}\n\n/*\n** Destroy the part of winFile that deals with wince locks\n*/\nstatic void winceDestroyLock(winFile *pFile){\n  if (pFile->hMutex){\n    /* Acquire the mutex */\n    winceMutexAcquire(pFile->hMutex);\n\n    /* The following blocks should probably assert in debug mode, but they\n       are to cleanup in case any locks remained open */\n    if (pFile->local.nReaders){\n      pFile->shared->nReaders --;\n    }\n    if (pFile->local.bReserved){\n      pFile->shared->bReserved = FALSE;\n    }\n    if (pFile->local.bPending){\n      pFile->shared->bPending = FALSE;\n    }\n    if (pFile->local.bExclusive){\n      pFile->shared->bExclusive = FALSE;\n    }\n\n    /* De-reference and close our copy of the shared memory handle */\n    osUnmapViewOfFile(pFile->shared);\n    osCloseHandle(pFile->hShared);\n\n    /* Done with the mutex */\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n  }\n}\n\n/*\n** An implementation of the LockFile() API of Windows for CE\n*/\nstatic BOOL winceLockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToLockLow,\n  DWORD nNumberOfBytesToLockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToLockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Wanting an exclusive lock? */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST\n       && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){\n    if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){\n       pFile->shared->bExclusive = TRUE;\n       pFile->local.bExclusive = TRUE;\n       bReturn = TRUE;\n    }\n  }\n\n  /* Want a read-only lock? */\n  else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&\n           nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bExclusive == 0){\n      pFile->local.nReaders ++;\n      if (pFile->local.nReaders == 1){\n        pFile->shared->nReaders ++;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a pending lock? */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    /* If no pending lock has been acquired, then acquire it */\n    if (pFile->shared->bPending == 0) {\n      pFile->shared->bPending = TRUE;\n      pFile->local.bPending = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a reserved lock? */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bReserved == 0) {\n      pFile->shared->bReserved = TRUE;\n      pFile->local.bReserved = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n\n/*\n** An implementation of the UnlockFile API of Windows for CE\n*/\nstatic BOOL winceUnlockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToUnlockLow,\n  DWORD nNumberOfBytesToUnlockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToUnlockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Releasing a reader lock or an exclusive lock */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST){\n    /* Did we have an exclusive lock? */\n    if (pFile->local.bExclusive){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);\n      pFile->local.bExclusive = FALSE;\n      pFile->shared->bExclusive = FALSE;\n      bReturn = TRUE;\n    }\n\n    /* Did we just have a reader lock? */\n    else if (pFile->local.nReaders){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE\n             || nNumberOfBytesToUnlockLow == 1);\n      pFile->local.nReaders --;\n      if (pFile->local.nReaders == 0)\n      {\n        pFile->shared->nReaders --;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Releasing a pending lock */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bPending){\n      pFile->local.bPending = FALSE;\n      pFile->shared->bPending = FALSE;\n      bReturn = TRUE;\n    }\n  }\n  /* Releasing a reserved lock */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bReserved) {\n      pFile->local.bReserved = FALSE;\n      pFile->shared->bReserved = FALSE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n/*\n** End of the special code for wince\n*****************************************************************************/\n#endif /* SQLITE_OS_WINCE */\n\n/*\n** Lock a file region.\n*/\nstatic BOOL winLockFile(\n  LPHANDLE phFile,\n  DWORD flags,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API LockFile.\n  */\n  return winceLockFile(phFile, offsetLow, offsetHigh,\n                       numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osLockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                      numBytesHigh);\n  }\n#endif\n}\n\n/*\n** Unlock a file region.\n */\nstatic BOOL winUnlockFile(\n  LPHANDLE phFile,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API UnlockFile.\n  */\n  return winceUnlockFile(phFile, offsetLow, offsetHigh,\n                         numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osUnlockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                        numBytesHigh);\n  }\n#endif\n}\n\n/*****************************************************************************\n** The next group of routines implement the I/O methods specified\n** by the sqlite3_io_methods object.\n******************************************************************************/\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_SET_FILE_POINTER\n# define INVALID_SET_FILE_POINTER ((DWORD)-1)\n#endif\n\n/*\n** Move the current position of the file handle passed as the first\n** argument to offset iOffset within the file. If successful, return 0.\n** Otherwise, set pFile->lastErrno and return non-zero.\n*/\nstatic int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){\n#if !SQLITE_OS_WINRT\n  LONG upperBits;                 /* Most sig. 32 bits of new offset */\n  LONG lowerBits;                 /* Least sig. 32 bits of new offset */\n  DWORD dwRet;                    /* Value returned by SetFilePointer() */\n  DWORD lastErrno;                /* Value returned by GetLastError() */\n\n  OSTRACE((\"SEEK file=%p, offset=%lld\\n\", pFile->h, iOffset));\n\n  upperBits = (LONG)((iOffset>>32) & 0x7fffffff);\n  lowerBits = (LONG)(iOffset & 0xffffffff);\n\n  /* API oddity: If successful, SetFilePointer() returns a dword\n  ** containing the lower 32-bits of the new file-offset. Or, if it fails,\n  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,\n  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine\n  ** whether an error has actually occurred, it is also necessary to call\n  ** GetLastError().\n  */\n  dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);\n\n  if( (dwRet==INVALID_SET_FILE_POINTER\n      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#else\n  /*\n  ** Same as above, except that this implementation works for WinRT.\n  */\n\n  LARGE_INTEGER x;                /* The new offset */\n  BOOL bRet;                      /* Value returned by SetFilePointerEx() */\n\n  x.QuadPart = iOffset;\n  bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);\n\n  if(!bRet){\n    pFile->lastErrno = osGetLastError();\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#endif\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* Forward references to VFS helper methods used for memory mapped files */\nstatic int winMapfile(winFile*, sqlite3_int64);\nstatic int winUnmapfile(winFile*);\n#endif\n\n/*\n** Close a file.\n**\n** It is reported that an attempt to close a handle might sometimes\n** fail.  This is a very unreasonable result, but Windows is notorious\n** for being unreasonable so I do not doubt that it might happen.  If\n** the close fails, we pause for 100 milliseconds and try again.  As\n** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before\n** giving up and returning an error.\n*/\n#define MX_CLOSE_ATTEMPT 3\nstatic int winClose(sqlite3_file *id){\n  int rc, cnt = 0;\n  winFile *pFile = (winFile*)id;\n\n  assert( id!=0 );\n#ifndef SQLITE_OMIT_WAL\n  assert( pFile->pShm==0 );\n#endif\n  assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  winUnmapfile(pFile);\n#endif\n\n  do{\n    rc = osCloseHandle(pFile->h);\n    /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */\n  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );\n#if SQLITE_OS_WINCE\n#define WINCE_DELETION_ATTEMPTS 3\n  {\n    winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;\n    if( pAppData==NULL || !pAppData->bNoLock ){\n      winceDestroyLock(pFile);\n    }\n  }\n  if( pFile->zDeleteOnClose ){\n    int cnt = 0;\n    while(\n           osDeleteFileW(pFile->zDeleteOnClose)==0\n        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff\n        && cnt++ < WINCE_DELETION_ATTEMPTS\n    ){\n       sqlite3_win32_sleep(100);  /* Wait a little before trying again */\n    }\n    sqlite3_free(pFile->zDeleteOnClose);\n  }\n#endif\n  if( rc ){\n    pFile->h = NULL;\n  }\n  OpenCounter(-1);\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, rc ? \"ok\" : \"failed\"));\n  return rc ? SQLITE_OK\n            : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),\n                          \"winClose\", pFile->zPath);\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int winRead(\n  sqlite3_file *id,          /* File to read from */\n  void *pBuf,                /* Write content into this buffer */\n  int amt,                   /* Number of bytes to read */\n  sqlite3_int64 offset       /* Begin reading at this offset */\n){\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n  OVERLAPPED overlapped;          /* The offset for ReadFile. */\n#endif\n  winFile *pFile = (winFile*)id;  /* file handle */\n  DWORD nRead;                    /* Number of bytes actually read from file */\n  int nRetry = 0;                 /* Number of retrys */\n\n  assert( id!=0 );\n  assert( amt>0 );\n  assert( offset>=0 );\n  SimulateIOError(return SQLITE_IOERR_READ);\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      OSTRACE((\"READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  if( winSeekFile(pFile, offset) ){\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_FULL;\n  }\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){\n#else\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(offset & 0xffffffff);\n  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&\n         osGetLastError()!=ERROR_HANDLE_EOF ){\n#endif\n    DWORD lastErrno;\n    if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n    pFile->lastErrno = lastErrno;\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,\n                       \"winRead\", pFile->zPath);\n  }\n  winLogIoerr(nRetry, __LINE__);\n  if( nRead<(DWORD)amt ){\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[nRead], 0, amt-nRead);\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int winWrite(\n  sqlite3_file *id,               /* File to write into */\n  const void *pBuf,               /* The bytes to be written */\n  int amt,                        /* Number of bytes to write */\n  sqlite3_int64 offset            /* Offset into the file to begin writing at */\n){\n  int rc = 0;                     /* True if error has occurred, else false */\n  winFile *pFile = (winFile*)id;  /* File handle */\n  int nRetry = 0;                 /* Number of retries */\n\n  assert( amt>0 );\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_WRITE);\n  SimulateDiskfullError(return SQLITE_FULL);\n\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      OSTRACE((\"WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  rc = winSeekFile(pFile, offset);\n  if( rc==0 ){\n#else\n  {\n#endif\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    OVERLAPPED overlapped;        /* The offset for WriteFile. */\n#endif\n    u8 *aRem = (u8 *)pBuf;        /* Data yet to be written */\n    int nRem = amt;               /* Number of bytes yet to be written */\n    DWORD nWrite;                 /* Bytes written by each WriteFile() call */\n    DWORD lastErrno = NO_ERROR;   /* Value returned by GetLastError() */\n\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    memset(&overlapped, 0, sizeof(OVERLAPPED));\n    overlapped.Offset = (LONG)(offset & 0xffffffff);\n    overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n\n    while( nRem>0 ){\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){\n#else\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){\n#endif\n        if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n        break;\n      }\n      assert( nWrite==0 || nWrite<=(DWORD)nRem );\n      if( nWrite==0 || nWrite>(DWORD)nRem ){\n        lastErrno = osGetLastError();\n        break;\n      }\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n      offset += nWrite;\n      overlapped.Offset = (LONG)(offset & 0xffffffff);\n      overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n      aRem += nWrite;\n      nRem -= nWrite;\n    }\n    if( nRem>0 ){\n      pFile->lastErrno = lastErrno;\n      rc = 1;\n    }\n  }\n\n  if( rc ){\n    if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )\n       || ( pFile->lastErrno==ERROR_DISK_FULL )){\n      OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return winLogError(SQLITE_FULL, pFile->lastErrno,\n                         \"winWrite1\", pFile->zPath);\n    }\n    OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,\n                       \"winWrite2\", pFile->zPath);\n  }else{\n    winLogIoerr(nRetry, __LINE__);\n  }\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){\n  winFile *pFile = (winFile*)id;  /* File handle object */\n  int rc = SQLITE_OK;             /* Return code for this function */\n  DWORD lastErrno;\n\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_TRUNCATE);\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */\n  if( winSeekFile(pFile, nByte) ){\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate1\", pFile->zPath);\n  }else if( 0==osSetEndOfFile(pFile->h) &&\n            ((lastErrno = osGetLastError())!=ERROR_USER_MAPPED_FILE) ){\n    pFile->lastErrno = lastErrno;\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate2\", pFile->zPath);\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* If the file was truncated to a size smaller than the currently\n  ** mapped region, reduce the effective mapping size as well. SQLite will\n  ** use read() and write() to access data beyond this point from now on.\n  */\n  if( pFile->pMapRegion && nByte<pFile->mmapSize ){\n    pFile->mmapSize = nByte;\n  }\n#endif\n\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occuring at the right times.\n*/\nSQLITE_API int sqlite3_sync_count = 0;\nSQLITE_API int sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n*/\nstatic int winSync(sqlite3_file *id, int flags){\n#ifndef SQLITE_NO_SYNC\n  /*\n  ** Used only when SQLITE_NO_SYNC is not defined.\n   */\n  BOOL rc;\n#endif\n#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \\\n    defined(SQLITE_HAVE_OS_TRACE)\n  /*\n  ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or\n  ** OSTRACE() macros.\n   */\n  winFile *pFile = (winFile*)id;\n#else\n  UNUSED_PARAMETER(id);\n#endif\n\n  assert( pFile );\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, flags,\n           pFile->locktype));\n\n#ifndef SQLITE_TEST\n  UNUSED_PARAMETER(flags);\n#else\n  if( (flags&0x0F)==SQLITE_SYNC_FULL ){\n    sqlite3_fullsync_count++;\n  }\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op\n  */\n#ifdef SQLITE_NO_SYNC\n  OSTRACE((\"SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n#else\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->pMapRegion ){\n    if( osFlushViewOfFile(pFile->pMapRegion, 0) ){\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_OK\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n    }else{\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winSync1\", pFile->zPath);\n    }\n  }\n#endif\n  rc = osFlushFileBuffers(pFile->h);\n  SimulateIOError( rc=FALSE );\n  if( rc ){\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_OK;\n  }else{\n    pFile->lastErrno = osGetLastError();\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,\n                       \"winSync2\", pFile->zPath);\n  }\n#endif\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n\n  assert( id!=0 );\n  assert( pSize!=0 );\n  SimulateIOError(return SQLITE_IOERR_FSTAT);\n  OSTRACE((\"SIZE file=%p, pSize=%p\\n\", pFile->h, pSize));\n\n#if SQLITE_OS_WINRT\n  {\n    FILE_STANDARD_INFO info;\n    if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,\n                                     &info, sizeof(info)) ){\n      *pSize = info.EndOfFile.QuadPart;\n    }else{\n      pFile->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#else\n  {\n    DWORD upperBits;\n    DWORD lowerBits;\n    DWORD lastErrno;\n\n    lowerBits = osGetFileSize(pFile->h, &upperBits);\n    *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;\n    if(   (lowerBits == INVALID_FILE_SIZE)\n       && ((lastErrno = osGetLastError())!=NO_ERROR) ){\n      pFile->lastErrno = lastErrno;\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#endif\n  OSTRACE((\"SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\\n\",\n           pFile->h, pSize, *pSize, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.\n*/\n#ifndef LOCKFILE_FAIL_IMMEDIATELY\n# define LOCKFILE_FAIL_IMMEDIATELY 1\n#endif\n\n#ifndef LOCKFILE_EXCLUSIVE_LOCK\n# define LOCKFILE_EXCLUSIVE_LOCK 2\n#endif\n\n/*\n** Historically, SQLite has used both the LockFile and LockFileEx functions.\n** When the LockFile function was used, it was always expected to fail\n** immediately if the lock could not be obtained.  Also, it always expected to\n** obtain an exclusive lock.  These flags are used with the LockFileEx function\n** and reflect those expectations; therefore, they should not be changed.\n*/\n#ifndef SQLITE_LOCKFILE_FLAGS\n# define SQLITE_LOCKFILE_FLAGS   (LOCKFILE_FAIL_IMMEDIATELY | \\\n                                  LOCKFILE_EXCLUSIVE_LOCK)\n#endif\n\n/*\n** Currently, SQLite never calls the LockFileEx function without wanting the\n** call to fail immediately if the lock cannot be obtained.\n*/\n#ifndef SQLITE_LOCKFILEEX_FLAGS\n# define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY)\n#endif\n\n/*\n** Acquire a reader lock.\n** Different API routines are called depending on whether or not this\n** is Win9x or WinNT.\n*/\nstatic int winGetReadLock(winFile *pFile){\n  int res;\n  OSTRACE((\"READ-LOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n#if SQLITE_OS_WINCE\n    /*\n    ** NOTE: Windows CE is handled differently here due its lack of the Win32\n    **       API LockFileEx.\n    */\n    res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);\n#else\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    int lk;\n    sqlite3_randomness(sizeof(lk), &lk);\n    pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1));\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                      SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res == 0 ){\n    pFile->lastErrno = osGetLastError();\n    /* No need to log a failure to lock */\n  }\n  OSTRACE((\"READ-LOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Undo a readlock\n*/\nstatic int winUnlockReadLock(winFile *pFile){\n  int res;\n  DWORD lastErrno;\n  OSTRACE((\"READ-UNLOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n    res = winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,\n                \"winUnlockReadLock\", pFile->zPath);\n  }\n  OSTRACE((\"READ-UNLOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Lock the file with the lock specified by parameter locktype - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  The winUnlock() routine\n** erases all locks at once and returns us immediately to locking level 0.\n** It is not possible to lower the locking level one step at a time.  You\n** must go straight to locking level 0.\n*/\nstatic int winLock(sqlite3_file *id, int locktype){\n  int rc = SQLITE_OK;    /* Return code from subroutines */\n  int res = 1;           /* Result of a Windows lock call */\n  int newLocktype;       /* Set pFile->locktype to this value before exiting */\n  int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */\n  winFile *pFile = (winFile*)id;\n  DWORD lastErrno = NO_ERROR;\n\n  assert( id!=0 );\n  OSTRACE((\"LOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** OsFile, do nothing. Don't use the end_lock: exit path, as\n  ** sqlite3OsEnterMutex() hasn't been called yet.\n  */\n  if( pFile->locktype>=locktype ){\n    OSTRACE((\"LOCK-HELD file=%p, rc=SQLITE_OK\\n\", pFile->h));\n    return SQLITE_OK;\n  }\n\n  /* Do not allow any kind of write-lock on a read-only database\n  */\n  if( (pFile->ctrlFlags & WINFILE_RDONLY)!=0 && locktype>=RESERVED_LOCK ){\n    return SQLITE_IOERR_LOCK;\n  }\n\n  /* Make sure the locking sequence is correct\n  */\n  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );\n  assert( locktype!=PENDING_LOCK );\n  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );\n\n  /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or\n  ** a SHARED lock.  If we are acquiring a SHARED lock, the acquisition of\n  ** the PENDING_LOCK byte is temporary.\n  */\n  newLocktype = pFile->locktype;\n  if( pFile->locktype==NO_LOCK\n   || (locktype==EXCLUSIVE_LOCK && pFile->locktype<=RESERVED_LOCK)\n  ){\n    int cnt = 3;\n    while( cnt-->0 && (res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                                         PENDING_BYTE, 0, 1, 0))==0 ){\n      /* Try 3 times to get the pending lock.  This is needed to work\n      ** around problems caused by indexing and/or anti-virus software on\n      ** Windows systems.\n      ** If you are using this code as a model for alternative VFSes, do not\n      ** copy this retry logic.  It is a hack intended for Windows only.\n      */\n      lastErrno = osGetLastError();\n      OSTRACE((\"LOCK-PENDING-FAIL file=%p, count=%d, result=%d\\n\",\n               pFile->h, cnt, res));\n      if( lastErrno==ERROR_INVALID_HANDLE ){\n        pFile->lastErrno = lastErrno;\n        rc = SQLITE_IOERR_LOCK;\n        OSTRACE((\"LOCK-FAIL file=%p, count=%d, rc=%s\\n\",\n                 pFile->h, cnt, sqlite3ErrName(rc)));\n        return rc;\n      }\n      if( cnt ) sqlite3_win32_sleep(1);\n    }\n    gotPendingLock = res;\n    if( !res ){\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a shared lock\n  */\n  if( locktype==SHARED_LOCK && res ){\n    assert( pFile->locktype==NO_LOCK );\n    res = winGetReadLock(pFile);\n    if( res ){\n      newLocktype = SHARED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a RESERVED lock\n  */\n  if( locktype==RESERVED_LOCK && res ){\n    assert( pFile->locktype==SHARED_LOCK );\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);\n    if( res ){\n      newLocktype = RESERVED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a PENDING lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    newLocktype = PENDING_LOCK;\n    gotPendingLock = 0;\n  }\n\n  /* Acquire an EXCLUSIVE lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    assert( pFile->locktype>=SHARED_LOCK );\n    res = winUnlockReadLock(pFile);\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n    if( res ){\n      newLocktype = EXCLUSIVE_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n      winGetReadLock(pFile);\n    }\n  }\n\n  /* If we are holding a PENDING lock that ought to be released, then\n  ** release it now.\n  */\n  if( gotPendingLock && locktype==SHARED_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n\n  /* Update the state of the lock has held in the file descriptor then\n  ** return the appropriate result code.\n  */\n  if( res ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno = lastErrno;\n    rc = SQLITE_BUSY;\n    OSTRACE((\"LOCK-FAIL file=%p, wanted=%d, got=%d\\n\",\n             pFile->h, locktype, newLocktype));\n  }\n  pFile->locktype = (u8)newLocktype;\n  OSTRACE((\"LOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, return\n** non-zero, otherwise zero.\n*/\nstatic int winCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int res;\n  winFile *pFile = (winFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p\\n\", pFile->h, pResOut));\n\n  assert( id!=0 );\n  if( pFile->locktype>=RESERVED_LOCK ){\n    res = 1;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (local)\\n\", pFile->h, res));\n  }else{\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE,0,1,0);\n    if( res ){\n      winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n    }\n    res = !res;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (remote)\\n\", pFile->h, res));\n  }\n  *pResOut = res;\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           pFile->h, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Lower the locking level on file descriptor id to locktype.  locktype\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** It is not possible for this routine to fail if the second argument\n** is NO_LOCK.  If the second argument is SHARED_LOCK then this routine\n** might return SQLITE_IOERR;\n*/\nstatic int winUnlock(sqlite3_file *id, int locktype){\n  int type;\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n  assert( pFile!=0 );\n  assert( locktype<=SHARED_LOCK );\n  OSTRACE((\"UNLOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n  type = pFile->locktype;\n  if( type>=EXCLUSIVE_LOCK ){\n    winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n    if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){\n      /* This should never happen.  We should always be able to\n      ** reacquire the read lock */\n      rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),\n                       \"winUnlock\", pFile->zPath);\n    }\n  }\n  if( type>=RESERVED_LOCK ){\n    winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n  }\n  if( locktype==NO_LOCK && type>=SHARED_LOCK ){\n    winUnlockReadLock(pFile);\n  }\n  if( type>=PENDING_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n  pFile->locktype = (u8)locktype;\n  OSTRACE((\"UNLOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int winNolockLock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\nstatic int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(pResOut);\n  return SQLITE_OK;\n}\n\nstatic int winNolockUnlock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void winModeBit(winFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward references to VFS helper methods used for temporary files */\nstatic int winGetTempname(sqlite3_vfs *, char **);\nstatic int winIsDir(const void *);\nstatic BOOL winIsDriveLetterAndColon(const char *);\n\n/*\n** Control and query of the open file handle.\n*/\nstatic int winFileControl(sqlite3_file *id, int op, void *pArg){\n  winFile *pFile = (winFile*)id;\n  OSTRACE((\"FCNTL file=%p, op=%d, pArg=%p\\n\", pFile->h, op, pArg));\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->locktype;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = (int)pFile->lastErrno;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      if( pFile->szChunk>0 ){\n        sqlite3_int64 oldSz;\n        int rc = winFileSize(id, &oldSz);\n        if( rc==SQLITE_OK ){\n          sqlite3_int64 newSz = *(sqlite3_int64*)pArg;\n          if( newSz>oldSz ){\n            SimulateIOErrorBenign(1);\n            rc = winTruncate(id, newSz);\n            SimulateIOErrorBenign(0);\n          }\n        }\n        OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n        return rc;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      winModeBit(pFile, WINFILE_PSOW, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_AV_RETRY: {\n      int *a = (int*)pArg;\n      if( a[0]>0 ){\n        winIoerrRetry = a[0];\n      }else{\n        a[0] = winIoerrRetry;\n      }\n      if( a[1]>0 ){\n        winIoerrRetryDelay = a[1];\n      }else{\n        a[1] = winIoerrRetryDelay;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_GET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      *phFile = pFile->h;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n#ifdef SQLITE_TEST\n    case SQLITE_FCNTL_WIN32_SET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      HANDLE hOldFile = pFile->h;\n      pFile->h = *phFile;\n      *phFile = hOldFile;\n      OSTRACE((\"FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\\n\",\n               hOldFile, pFile->h));\n      return SQLITE_OK;\n    }\n#endif\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = 0;\n      int rc = winGetTempname(pFile->pVfs, &zTFile);\n      if( rc==SQLITE_OK ){\n        *(char**)pArg = zTFile;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (SIZE_T) and passed\n      ** to MapViewOfFile(). Restrict its value to 2GB if (SIZE_T) is not at\n      ** least a 64-bit type. */\n      if( newLimit>0 && sizeof(SIZE_T)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          winUnmapfile(pFile);\n          rc = winMapfile(pFile, -1);\n        }\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#endif\n  }\n  OSTRACE((\"FCNTL file=%p, rc=SQLITE_NOTFOUND\\n\", pFile->h));\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int winSectorSize(sqlite3_file *id){\n  (void)id;\n  return SQLITE_DEFAULT_SECTOR_SIZE;\n}\n\n/*\n** Return a vector of device characteristics.\n*/\nstatic int winDeviceCharacteristics(sqlite3_file *id){\n  winFile *p = (winFile*)id;\n  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n         ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);\n}\n\n/*\n** Windows will only let you create file view mappings\n** on allocation size granularity boundaries.\n** During sqlite3_os_init() we do a GetSystemInfo()\n** to get the granularity size.\n*/\nstatic SYSTEM_INFO winSysInfo;\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the winLockInfo objects used by\n** this file, all of which may be shared by multiple threads.\n**\n** Function winShmMutexHeld() is used to assert() that the global mutex\n** is held when required. This function is only used as part of assert()\n** statements. e.g.\n**\n**   winShmEnterMutex()\n**     assert( winShmMutexHeld() );\n**   winShmLeaveMutex()\n*/\nstatic void winShmEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\nstatic void winShmLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#ifndef NDEBUG\nstatic int winShmMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#endif\n\n/*\n** Object used to represent a single file opened and mmapped to provide\n** shared memory.  When multiple threads all reference the same\n** log-summary, each thread has its own winFile object, but they all\n** point to a single instance of this object.  In other words, each\n** log-summary is opened only once per process.\n**\n** winShmMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**      pNext\n**\n** The following fields are read-only after the object is created:\n**\n**      fid\n**      zFilename\n**\n** Either winShmNode.mutex must be held or winShmNode.nRef==0 and\n** winShmMutexHeld() is true when reading or writing any other field\n** in this structure.\n**\n*/\nstruct winShmNode {\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the file */\n  winFile hFile;             /* File handle from winOpen */\n\n  int szRegion;              /* Size of shared-memory regions */\n  int nRegion;               /* Size of array apRegion */\n  struct ShmRegion {\n    HANDLE hMap;             /* File handle from CreateFileMapping */\n    void *pMap;\n  } *aRegion;\n  DWORD lastErrno;           /* The Windows errno from the last I/O error */\n\n  int nRef;                  /* Number of winShm objects pointing to this */\n  winShm *pFirst;            /* All winShm objects pointing to this */\n  winShmNode *pNext;         /* Next in list of all winShmNode objects */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 nextShmId;              /* Next available winShm.id value */\n#endif\n};\n\n/*\n** A global array of all winShmNode objects.\n**\n** The winShmMutexHeld() must be true while reading or writing this list.\n*/\nstatic winShmNode *winShmNodeList = 0;\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    winShm.pShmNode\n**    winShm.id\n**\n** All other fields are read/write.  The winShm.pShmNode->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct winShm {\n  winShmNode *pShmNode;      /* The underlying winShmNode object */\n  winShm *pNext;             /* Next winShm with the same winShmNode */\n  u8 hasMutex;               /* True if holding the winShmNode mutex */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 id;                     /* Id of this connection with its winShmNode */\n#endif\n};\n\n/*\n** Constants used for locking\n*/\n#define WIN_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)        /* first lock byte */\n#define WIN_SHM_DMS    (WIN_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply advisory locks for all n bytes beginning at ofst.\n*/\n#define WINSHM_UNLCK  1\n#define WINSHM_RDLCK  2\n#define WINSHM_WRLCK  3\nstatic int winShmSystemLock(\n  winShmNode *pFile,    /* Apply locks to this open shared-memory segment */\n  int lockType,         /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */\n  int ofst,             /* Offset to first byte to be locked/unlocked */\n  int nByte             /* Number of bytes to lock or unlock */\n){\n  int rc = 0;           /* Result code form Lock/UnlockFileEx() */\n\n  /* Access to the winShmNode object is serialized by the caller */\n  assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );\n\n  OSTRACE((\"SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\\n\",\n           pFile->hFile.h, lockType, ofst, nByte));\n\n  /* Release/Acquire the system-level lock */\n  if( lockType==WINSHM_UNLCK ){\n    rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);\n  }else{\n    /* Initialize the locking parameters */\n    DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;\n    if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;\n    rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);\n  }\n\n  if( rc!= 0 ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno =  osGetLastError();\n    rc = SQLITE_BUSY;\n  }\n\n  OSTRACE((\"SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\\n\",\n           pFile->hFile.h, (lockType == WINSHM_UNLCK) ? \"winUnlockFile\" :\n           \"winLockFile\", pFile->lastErrno, sqlite3ErrName(rc)));\n\n  return rc;\n}\n\n/* Forward references to VFS methods */\nstatic int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);\nstatic int winDelete(sqlite3_vfs *,const char*,int);\n\n/*\n** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){\n  winShmNode **pp;\n  winShmNode *p;\n  assert( winShmMutexHeld() );\n  OSTRACE((\"SHM-PURGE pid=%lu, deleteFlag=%d\\n\",\n           osGetCurrentProcessId(), deleteFlag));\n  pp = &winShmNodeList;\n  while( (p = *pp)!=0 ){\n    if( p->nRef==0 ){\n      int i;\n      if( p->mutex ){ sqlite3_mutex_free(p->mutex); }\n      for(i=0; i<p->nRegion; i++){\n        BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);\n        OSTRACE((\"SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n        bRc = osCloseHandle(p->aRegion[i].hMap);\n        OSTRACE((\"SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n      }\n      if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){\n        SimulateIOErrorBenign(1);\n        winClose((sqlite3_file *)&p->hFile);\n        SimulateIOErrorBenign(0);\n      }\n      if( deleteFlag ){\n        SimulateIOErrorBenign(1);\n        sqlite3BeginBenignMalloc();\n        winDelete(pVfs, p->zFilename, 0);\n        sqlite3EndBenignMalloc();\n        SimulateIOErrorBenign(0);\n      }\n      *pp = p->pNext;\n      sqlite3_free(p->aRegion);\n      sqlite3_free(p);\n    }else{\n      pp = &p->pNext;\n    }\n  }\n}\n\n/*\n** Open the shared-memory area associated with database file pDbFd.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n*/\nstatic int winOpenSharedMemory(winFile *pDbFd){\n  struct winShm *p;                  /* The connection to be opened */\n  struct winShmNode *pShmNode = 0;   /* The underlying mmapped file */\n  int rc;                            /* Result code */\n  struct winShmNode *pNew;           /* Newly allocated winShmNode */\n  int nName;                         /* Size of zName in bytes */\n\n  assert( pDbFd->pShm==0 );    /* Not previously opened */\n\n  /* Allocate space for the new sqlite3_shm object.  Also speculatively\n  ** allocate space for a new winShmNode and filename.\n  */\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;\n  nName = sqlite3Strlen30(pDbFd->zPath);\n  pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );\n  if( pNew==0 ){\n    sqlite3_free(p);\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  pNew->zFilename = (char*)&pNew[1];\n  sqlite3_snprintf(nName+15, pNew->zFilename, \"%s-shm\", pDbFd->zPath);\n  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);\n\n  /* Look to see if there is an existing winShmNode that can be used.\n  ** If no matching winShmNode currently exists, create a new one.\n  */\n  winShmEnterMutex();\n  for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){\n    /* TBD need to come up with better match here.  Perhaps\n    ** use FILE_ID_BOTH_DIR_INFO Structure.\n    */\n    if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;\n  }\n  if( pShmNode ){\n    sqlite3_free(pNew);\n  }else{\n    pShmNode = pNew;\n    pNew = 0;\n    ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE;\n    pShmNode->pNext = winShmNodeList;\n    winShmNodeList = pShmNode;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->mutex==0 ){\n        rc = SQLITE_IOERR_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    rc = winOpen(pDbFd->pVfs,\n                 pShmNode->zFilename,             /* Name of the file (UTF-8) */\n                 (sqlite3_file*)&pShmNode->hFile,  /* File handle here */\n                 SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,\n                 0);\n    if( SQLITE_OK!=rc ){\n      goto shm_open_err;\n    }\n\n    /* Check to see if another process is holding the dead-man switch.\n    ** If not, truncate the file to zero length.\n    */\n    if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),\n                         \"winOpenShm\", pDbFd->zPath);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n      rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);\n    }\n    if( rc ) goto shm_open_err;\n  }\n\n  /* Make the new connection a child of the winShmNode */\n  p->pShmNode = pShmNode;\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  winShmLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the winShmEnterMutex() mutex and the pointer from the\n  ** new (struct winShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex\n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n  winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  sqlite3_free(pNew);\n  winShmLeaveMutex();\n  return rc;\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying\n** storage if deleteFlag is true.\n*/\nstatic int winShmUnmap(\n  sqlite3_file *fd,          /* Database holding shared memory */\n  int deleteFlag             /* Delete after closing if true */\n){\n  winFile *pDbFd;       /* Database holding shared-memory */\n  winShm *p;            /* The connection to be closed */\n  winShmNode *pShmNode; /* The underlying shared-memory file */\n  winShm **pp;          /* For looping over sibling connections */\n\n  pDbFd = (winFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  winShmEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    winShmPurge(pDbFd->pVfs, deleteFlag);\n  }\n  winShmLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n*/\nstatic int winShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  winFile *pDbFd = (winFile*)fd;        /* Connection holding shared memory */\n  winShm *p = pDbFd->pShm;              /* The shared memory being locked */\n  winShm *pX;                           /* For looping over all siblings */\n  winShmNode *pShmNode = p->pShmNode;\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n\n  mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    }\n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n\n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\\n\",\n           osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,\n           sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.\n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void winShmBarrier(\n  sqlite3_file *fd          /* Database holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();   /* compiler-defined memory barrier */\n  winShmEnterMutex();       /* Also mutex, for redundancy */\n  winShmLeaveMutex();\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the\n** shared-memory associated with the database file fd. Shared-memory regions\n** are numbered starting from zero. Each shared-memory region is szRegion\n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the isWrite parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If\n** isWrite is non-zero and the requested shared-memory region has not yet\n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes\n** address space (if it is not already), *pp is set to point to the mapped\n** memory and SQLITE_OK returned.\n*/\nstatic int winShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int isWrite,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  winFile *pDbFd = (winFile*)fd;\n  winShm *pShm = pDbFd->pShm;\n  winShmNode *pShmNode;\n  int rc = SQLITE_OK;\n\n  if( !pShm ){\n    rc = winOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n    pShm = pDbFd->pShm;\n  }\n  pShmNode = pShm->pShmNode;\n\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n\n  if( pShmNode->nRegion<=iRegion ){\n    struct ShmRegion *apNew;           /* New aRegion[] array */\n    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */\n    sqlite3_int64 sz;                  /* Current size of wal-index file */\n\n    pShmNode->szRegion = szRegion;\n\n    /* The requested region is not mapped into this processes address space.\n    ** Check to see if it has been allocated (i.e. if the wal-index file is\n    ** large enough to contain the requested region).\n    */\n    rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);\n    if( rc!=SQLITE_OK ){\n      rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                       \"winShmMap1\", pDbFd->zPath);\n      goto shmpage_out;\n    }\n\n    if( sz<nByte ){\n      /* The requested memory region does not exist. If isWrite is set to\n      ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.\n      **\n      ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate\n      ** the requested memory region.\n      */\n      if( !isWrite ) goto shmpage_out;\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                         \"winShmMap2\", pDbFd->zPath);\n        goto shmpage_out;\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (struct ShmRegion *)sqlite3_realloc64(\n        pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->aRegion = apNew;\n\n    while( pShmNode->nRegion<=iRegion ){\n      HANDLE hMap = NULL;         /* file-mapping handle */\n      void *pMap = 0;             /* Mapped memory region */\n\n#if SQLITE_OS_WINRT\n      hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n      hMap = osCreateFileMappingW(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n      hMap = osCreateFileMappingA(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#endif\n      OSTRACE((\"SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\\n\",\n               osGetCurrentProcessId(), pShmNode->nRegion, nByte,\n               hMap ? \"ok\" : \"failed\"));\n      if( hMap ){\n        int iOffset = pShmNode->nRegion*szRegion;\n        int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n#if SQLITE_OS_WINRT\n        pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#else\n        pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            0, iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#endif\n        OSTRACE((\"SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,\n                 szRegion, pMap ? \"ok\" : \"failed\"));\n      }\n      if( !pMap ){\n        pShmNode->lastErrno = osGetLastError();\n        rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,\n                         \"winShmMap3\", pDbFd->zPath);\n        if( hMap ) osCloseHandle(hMap);\n        goto shmpage_out;\n      }\n\n      pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;\n      pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;\n      pShmNode->nRegion++;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    int iOffset = iRegion*szRegion;\n    int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n    char *p = (char *)pShmNode->aRegion[iRegion].pMap;\n    *pp = (void *)&p[iOffsetShift];\n  }else{\n    *pp = 0;\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n#else\n# define winShmMap     0\n# define winShmLock    0\n# define winShmBarrier 0\n# define winShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/*\n** Cleans up the mapped region of the specified file, if any.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int winUnmapfile(winFile *pFile){\n  assert( pFile!=0 );\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, pMapRegion=%p, \"\n           \"mmapSize=%lld, mmapSizeActual=%lld, mmapSizeMax=%lld\\n\",\n           osGetCurrentProcessId(), pFile, pFile->hMap, pFile->pMapRegion,\n           pFile->mmapSize, pFile->mmapSizeActual, pFile->mmapSizeMax));\n  if( pFile->pMapRegion ){\n    if( !osUnmapViewOfFile(pFile->pMapRegion) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(), pFile,\n               pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile1\", pFile->zPath);\n    }\n    pFile->pMapRegion = 0;\n    pFile->mmapSize = 0;\n    pFile->mmapSizeActual = 0;\n  }\n  if( pFile->hMap!=NULL ){\n    if( !osCloseHandle(pFile->hMap) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFile, pFile->hMap));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile2\", pFile->zPath);\n    }\n    pFile->hMap = NULL;\n  }\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile));\n  return SQLITE_OK;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if\n** there already exists a mapping for this file, and there are still\n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of\n** the mapping to create. Otherwise, if nByte is less than zero, then the\n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured\n** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int winMapfile(winFile *pFd, sqlite3_int64 nByte){\n  sqlite3_int64 nMap = nByte;\n  int rc;\n\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, size=%lld\\n\",\n           osGetCurrentProcessId(), pFd, nByte));\n\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    rc = winFileSize((sqlite3_file*)pFd, &nMap);\n    if( rc ){\n      OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_IOERR_FSTAT\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_IOERR_FSTAT;\n    }\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n  nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);\n\n  if( nMap==0 && pFd->mmapSize>0 ){\n    winUnmapfile(pFd);\n  }\n  if( nMap!=pFd->mmapSize ){\n    void *pNew = 0;\n    DWORD protect = PAGE_READONLY;\n    DWORD flags = FILE_MAP_READ;\n\n    winUnmapfile(pFd);\n#ifdef SQLITE_MMAP_READWRITE\n    if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){\n      protect = PAGE_READWRITE;\n      flags |= FILE_MAP_WRITE;\n    }\n#endif\n#if SQLITE_OS_WINRT\n    pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n    pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#endif\n    if( pFd->hMap==NULL ){\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile1\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    assert( (nMap % winSysInfo.dwPageSize)==0 );\n    assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );\n#if SQLITE_OS_WINRT\n    pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);\n#else\n    pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);\n#endif\n    if( pNew==NULL ){\n      osCloseHandle(pFd->hMap);\n      pFd->hMap = NULL;\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile2\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    pFd->pMapRegion = pNew;\n    pFd->mmapSize = nMap;\n    pFd->mmapSizeActual = nMap;\n  }\n\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFd));\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually\n** release the reference by calling winUnfetch().\n*/\nstatic int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, offset=%lld, amount=%d, pp=%p\\n\",\n           osGetCurrentProcessId(), fd, iOff, nAmt, pp));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = winMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ){\n        OSTRACE((\"FETCH pid=%lu, pFile=%p, rc=%s\\n\",\n                 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n        return rc;\n      }\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd, pp, *pp));\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a\n** reference obtained by an earlier call to winFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the winFetch() invocation.\n**\n** Or, if the third argument is NULL, then this function is being called\n** to inform the VFS layer that, according to POSIX, any existing mapping\n** may now be invalid and should be unmapped.\n*/\nstatic int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding\n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, offset=%lld, p=%p\\n\",\n           osGetCurrentProcessId(), pFd, iOff, p));\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    /* FIXME:  If Windows truly always prevents truncating or deleting a\n    ** file while a mapping is held, then the following winUnmapfile() call\n    ** is unnecessary can be omitted - potentially improving\n    ** performance.  */\n    winUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#endif\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd));\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32.\n*/\nstatic const sqlite3_io_methods winIoMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winLock,                        /* xLock */\n  winUnlock,                      /* xUnlock */\n  winCheckReservedLock,           /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32 without performing any locking.\n*/\nstatic const sqlite3_io_methods winIoNolockMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winNolockLock,                  /* xLock */\n  winNolockUnlock,                /* xUnlock */\n  winNolockCheckReservedLock,     /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\nstatic winVfsAppData winAppData = {\n  &winIoMethod,       /* pMethod */\n  0,                  /* pAppData */\n  0                   /* bNoLock */\n};\n\nstatic winVfsAppData winNolockAppData = {\n  &winIoNolockMethod, /* pMethod */\n  0,                  /* pAppData */\n  1                   /* bNoLock */\n};\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n#if defined(__CYGWIN__)\n/*\n** Convert a filename from whatever the underlying operating system\n** supports for filenames into UTF-8.  Space to hold the result is\n** obtained from malloc and must be freed by the calling function.\n*/\nstatic char *winConvertToUtf8Filename(const void *zFilename){\n  char *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUnicodeToUtf8(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winMbcsToUtf8(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n#endif\n\n/*\n** Convert a UTF-8 filename into whatever form the underlying\n** operating system wants filenames in.  Space to hold the result\n** is obtained from malloc and must be freed by the calling\n** function.\n*/\nstatic void *winConvertFromUtf8Filename(const char *zFilename){\n  void *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUtf8ToUnicode(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n\n/*\n** This function returns non-zero if the specified UTF-8 string buffer\n** ends with a directory separator character or one was successfully\n** added to it.\n*/\nstatic int winMakeEndInDirSep(int nBuf, char *zBuf){\n  if( zBuf ){\n    int nLen = sqlite3Strlen30(zBuf);\n    if( nLen>0 ){\n      if( winIsDirSep(zBuf[nLen-1]) ){\n        return 1;\n      }else if( nLen+1<nBuf ){\n        zBuf[nLen] = winGetDirSep();\n        zBuf[nLen+1] = '\\0';\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name and store the resulting pointer into pzBuf.\n** The pointer returned in pzBuf must be freed via sqlite3_free().\n*/\nstatic int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){\n  static char zChars[] =\n    \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"0123456789\";\n  size_t i, j;\n  int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);\n  int nMax, nBuf, nDir, nLen;\n  char *zBuf;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing.\n  */\n  SimulateIOError( return SQLITE_IOERR );\n\n  /* Allocate a temporary buffer to store the fully qualified file\n  ** name for the temporary file.  If this fails, we cannot continue.\n  */\n  nMax = pVfs->mxPathname; nBuf = nMax + 2;\n  zBuf = sqlite3MallocZero( nBuf );\n  if( !zBuf ){\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Figure out the effective temporary directory.  First, check if one\n  ** has been explicitly set by the application; otherwise, use the one\n  ** configured by the operating system.\n  */\n  nDir = nMax - (nPre + 15);\n  assert( nDir>0 );\n  if( sqlite3_temp_directory ){\n    int nDirLen = sqlite3Strlen30(sqlite3_temp_directory);\n    if( nDirLen>0 ){\n      if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){\n        nDirLen++;\n      }\n      if( nDirLen>nDir ){\n        sqlite3_free(zBuf);\n        OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n        return winLogError(SQLITE_ERROR, 0, \"winGetTempname1\", 0);\n      }\n      sqlite3_snprintf(nMax, zBuf, \"%s\", sqlite3_temp_directory);\n    }\n  }\n#if defined(__CYGWIN__)\n  else{\n    static const char *azDirs[] = {\n       0, /* getenv(\"SQLITE_TMPDIR\") */\n       0, /* getenv(\"TMPDIR\") */\n       0, /* getenv(\"TMP\") */\n       0, /* getenv(\"TEMP\") */\n       0, /* getenv(\"USERPROFILE\") */\n       \"/var/tmp\",\n       \"/usr/tmp\",\n       \"/tmp\",\n       \".\",\n       0        /* List terminator */\n    };\n    unsigned int i;\n    const char *zDir = 0;\n\n    if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n    if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n    if( !azDirs[2] ) azDirs[2] = getenv(\"TMP\");\n    if( !azDirs[3] ) azDirs[3] = getenv(\"TEMP\");\n    if( !azDirs[4] ) azDirs[4] = getenv(\"USERPROFILE\");\n    for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){\n      void *zConverted;\n      if( zDir==0 ) continue;\n      /* If the path starts with a drive letter followed by the colon\n      ** character, assume it is already a native Win32 path; otherwise,\n      ** it must be converted to a native Win32 path via the Cygwin API\n      ** prior to using it.\n      */\n      if( winIsDriveLetterAndColon(zDir) ){\n        zConverted = winConvertFromUtf8Filename(zDir);\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( winIsDir(zConverted) ){\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zDir);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }else{\n        zConverted = sqlite3MallocZero( nMax+1 );\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( cygwin_conv_path(\n                osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,\n                zConverted, nMax+1)<0 ){\n          sqlite3_free(zConverted);\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\\n\"));\n          return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,\n                             \"winGetTempname2\", zDir);\n        }\n        if( winIsDir(zConverted) ){\n          /* At this point, we know the candidate directory exists and should\n          ** be used.  However, we may need to convert the string containing\n          ** its name into UTF-8 (i.e. if it is UTF-16 right now).\n          */\n          char *zUtf8 = winConvertToUtf8Filename(zConverted);\n          if( !zUtf8 ){\n            sqlite3_free(zConverted);\n            sqlite3_free(zBuf);\n            OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n          sqlite3_free(zUtf8);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }\n    }\n  }\n#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  else if( osIsNT() ){\n    char *zMulti;\n    LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );\n    if( !zWidePath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathW(nMax, zWidePath)==0 ){\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname2\", 0);\n    }\n    zMulti = winUnicodeToUtf8(zWidePath);\n    if( zMulti ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zMulti);\n      sqlite3_free(zMulti);\n      sqlite3_free(zWidePath);\n    }else{\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zUtf8;\n    char *zMbcsPath = sqlite3MallocZero( nMax );\n    if( !zMbcsPath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathA(nMax, zMbcsPath)==0 ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname3\", 0);\n    }\n    zUtf8 = winMbcsToUtf8(zMbcsPath, osAreFileApisANSI());\n    if( zUtf8 ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n    }else{\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#endif /* SQLITE_WIN32_HAS_ANSI */\n#endif /* !SQLITE_OS_WINRT */\n\n  /*\n  ** Check to make sure the temporary directory ends with an appropriate\n  ** separator.  If it does not and there is not enough space left to add\n  ** one, fail.\n  */\n  if( !winMakeEndInDirSep(nDir+1, zBuf) ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname4\", 0);\n  }\n\n  /*\n  ** Check that the output buffer is large enough for the temporary file\n  ** name in the following format:\n  **\n  **   \"<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\\0\\0\"\n  **\n  ** If not, return SQLITE_ERROR.  The number 17 is used here in order to\n  ** account for the space used by the 15 character random suffix and the\n  ** two trailing NUL characters.  The final directory separator character\n  ** has already added if it was not already present.\n  */\n  nLen = sqlite3Strlen30(zBuf);\n  if( (nLen + nPre + 17) > nBuf ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname5\", 0);\n  }\n\n  sqlite3_snprintf(nBuf-16-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);\n\n  j = sqlite3Strlen30(zBuf);\n  sqlite3_randomness(15, &zBuf[j]);\n  for(i=0; i<15; i++, j++){\n    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];\n  }\n  zBuf[j] = 0;\n  zBuf[j+1] = 0;\n  *pzBuf = zBuf;\n\n  OSTRACE((\"TEMP-FILENAME name=%s, rc=SQLITE_OK\\n\", zBuf));\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the named file is really a directory.  Return false if\n** it is something other than a directory, or if there is any kind of memory\n** allocation failure.\n*/\nstatic int winIsDir(const void *zConverted){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno;\n\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( !rc ){\n      return 0; /* Invalid name? */\n    }\n    attr = sAttrData.dwFileAttributes;\n#if SQLITE_OS_WINCE==0\n  }else{\n    attr = osGetFileAttributesA((char*)zConverted);\n#endif\n  }\n  return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);\n}\n\n/* forward reference */\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n);\n\n/*\n** Open a file.\n*/\nstatic int winOpen(\n  sqlite3_vfs *pVfs,        /* Used to get maximum path length and AppData */\n  const char *zName,        /* Name of the file (UTF-8) */\n  sqlite3_file *id,         /* Write the SQLite file handle here */\n  int flags,                /* Open mode flags */\n  int *pOutFlags            /* Status return flags */\n){\n  HANDLE h;\n  DWORD lastErrno = 0;\n  DWORD dwDesiredAccess;\n  DWORD dwShareMode;\n  DWORD dwCreationDisposition;\n  DWORD dwFlagsAndAttributes = 0;\n#if SQLITE_OS_WINCE\n  int isTemp = 0;\n#endif\n  winVfsAppData *pAppData;\n  winFile *pFile = (winFile*)id;\n  void *zConverted;              /* Filename in OS encoding */\n  const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */\n  int cnt = 0;\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char *zTmpname = 0; /* For temporary filename, if necessary. */\n\n  int rc = SQLITE_OK;            /* Function Return Code */\n#if !defined(NDEBUG) || SQLITE_OS_WINCE\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n#endif\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n\n#ifndef NDEBUG\n  int isOpenJournal = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL\n     || eType==SQLITE_OPEN_MAIN_JOURNAL\n     || eType==SQLITE_OPEN_WAL\n  ));\n#endif\n\n  OSTRACE((\"OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\\n\",\n           zUtf8Name, id, flags, pOutFlags));\n\n  /* Check the following statements are true:\n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and\n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never\n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB\n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL\n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL\n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  assert( pFile!=0 );\n  memset(pFile, 0, sizeof(winFile));\n  pFile->h = INVALID_HANDLE_VALUE;\n\n#if SQLITE_OS_WINRT\n  if( !zUtf8Name && !sqlite3_temp_directory ){\n    sqlite3_log(SQLITE_ERROR,\n        \"sqlite3_temp_directory variable should be set for WinRT\");\n  }\n#endif\n\n  /* If the second argument to this function is NULL, generate a\n  ** temporary file name to use\n  */\n  if( !zUtf8Name ){\n    assert( isDelete && !isOpenJournal );\n    rc = winGetTempname(pVfs, &zTmpname);\n    if( rc!=SQLITE_OK ){\n      OSTRACE((\"OPEN name=%s, rc=%s\", zUtf8Name, sqlite3ErrName(rc)));\n      return rc;\n    }\n    zUtf8Name = zTmpname;\n  }\n\n  /* Database filenames are double-zero terminated if they are not\n  ** URIs with parameters.  Hence, they can always be passed into\n  ** sqlite3_uri_parameter().\n  */\n  assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||\n       zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );\n\n  /* Convert the filename to the system encoding. */\n  zConverted = winConvertFromUtf8Filename(zUtf8Name);\n  if( zConverted==0 ){\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_IOERR_NOMEM\", zUtf8Name));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  if( winIsDir(zConverted) ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_CANTOPEN_ISDIR\", zUtf8Name));\n    return SQLITE_CANTOPEN_ISDIR;\n  }\n\n  if( isReadWrite ){\n    dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;\n  }else{\n    dwDesiredAccess = GENERIC_READ;\n  }\n\n  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is\n  ** created. SQLite doesn't use it to indicate \"exclusive access\"\n  ** as it is usually understood.\n  */\n  if( isExclusive ){\n    /* Creates a new file, only if it does not already exist. */\n    /* If the file exists, it fails. */\n    dwCreationDisposition = CREATE_NEW;\n  }else if( isCreate ){\n    /* Open existing file, or create if it doesn't exist */\n    dwCreationDisposition = OPEN_ALWAYS;\n  }else{\n    /* Opens a file, only if it exists. */\n    dwCreationDisposition = OPEN_EXISTING;\n  }\n\n  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;\n\n  if( isDelete ){\n#if SQLITE_OS_WINCE\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;\n    isTemp = 1;\n#else\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY\n                               | FILE_ATTRIBUTE_HIDDEN\n                               | FILE_FLAG_DELETE_ON_CLOSE;\n#endif\n  }else{\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;\n  }\n  /* Reports from the internet are that performance is always\n  ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */\n#if SQLITE_OS_WINCE\n  dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;\n#endif\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;\n    extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);\n    extendedParameters.dwFileAttributes =\n            dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;\n    extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;\n    extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;\n    extendedParameters.lpSecurityAttributes = NULL;\n    extendedParameters.hTemplateFile = NULL;\n    do{\n      h = osCreateFile2((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode,\n                        dwCreationDisposition,\n                        &extendedParameters);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#else\n    do{\n      h = osCreateFileW((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do{\n      h = osCreateFileA((LPCSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n  }\n#endif\n  winLogIoerr(cnt, __LINE__);\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, rc=%s\\n\", h, zUtf8Name,\n           dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  if( h==INVALID_HANDLE_VALUE ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    if( isReadWrite && !isExclusive ){\n      return winOpen(pVfs, zName, id,\n         ((flags|SQLITE_OPEN_READONLY) &\n                     ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),\n         pOutFlags);\n    }else{\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_CANTOPEN, pFile->lastErrno, \"winOpen\", zUtf8Name);\n      return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n\n  if( pOutFlags ){\n    if( isReadWrite ){\n      *pOutFlags = SQLITE_OPEN_READWRITE;\n    }else{\n      *pOutFlags = SQLITE_OPEN_READONLY;\n    }\n  }\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, \"\n           \"rc=%s\\n\", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?\n           *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  pAppData = (winVfsAppData*)pVfs->pAppData;\n\n#if SQLITE_OS_WINCE\n  {\n    if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB\n         && ((pAppData==NULL) || !pAppData->bNoLock)\n         && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK\n    ){\n      osCloseHandle(h);\n      sqlite3_free(zConverted);\n      sqlite3_free(zTmpname);\n      OSTRACE((\"OPEN-CE-LOCK name=%s, rc=%s\\n\", zName, sqlite3ErrName(rc)));\n      return rc;\n    }\n  }\n  if( isTemp ){\n    pFile->zDeleteOnClose = zConverted;\n  }else\n#endif\n  {\n    sqlite3_free(zConverted);\n  }\n\n  sqlite3_free(zTmpname);\n  pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;\n  pFile->pVfs = pVfs;\n  pFile->h = h;\n  if( isReadonly ){\n    pFile->ctrlFlags |= WINFILE_RDONLY;\n  }\n  if( sqlite3_uri_boolean(zName, \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pFile->ctrlFlags |= WINFILE_PSOW;\n  }\n  pFile->lastErrno = NO_ERROR;\n  pFile->zPath = zName;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pFile->hMap = NULL;\n  pFile->pMapRegion = 0;\n  pFile->mmapSize = 0;\n  pFile->mmapSizeActual = 0;\n  pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n\n  OpenCounter(+1);\n  return rc;\n}\n\n/*\n** Delete the named file.\n**\n** Note that Windows does not allow a file to be deleted if some other\n** process has it open.  Sometimes a virus scanner or indexing program\n** will open a journal file shortly after it is created in order to do\n** whatever it does.  While this other process is holding the\n** file open, we will be unable to delete it.  To work around this\n** problem, we delay 100 milliseconds and try to delete again.  Up\n** to MX_DELETION_ATTEMPTs deletion attempts are run before giving\n** up and returning an error.\n*/\nstatic int winDelete(\n  sqlite3_vfs *pVfs,          /* Not used on win32 */\n  const char *zFilename,      /* Name of file to delete */\n  int syncDir                 /* Not used on win32 */\n){\n  int cnt = 0;\n  int rc;\n  DWORD attr;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n  UNUSED_PARAMETER(syncDir);\n\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  OSTRACE((\"DELETE name=%s, syncDir=%d\\n\", zFilename, syncDir));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"DELETE name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    do {\n#if SQLITE_OS_WINRT\n      WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n      memset(&sAttrData, 0, sizeof(sAttrData));\n      if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,\n                                  &sAttrData) ){\n        attr = sAttrData.dwFileAttributes;\n      }else{\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n#else\n      attr = osGetFileAttributesW(zConverted);\n#endif\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileW(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do {\n      attr = osGetFileAttributesA(zConverted);\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileA(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#endif\n  if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){\n    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, \"winDelete\", zFilename);\n  }else{\n    winLogIoerr(cnt, __LINE__);\n  }\n  sqlite3_free(zConverted);\n  OSTRACE((\"DELETE name=%s, rc=%s\\n\", zFilename, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Check the existence and status of a file.\n*/\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  OSTRACE((\"ACCESS name=%s, flags=%x, pResOut=%p\\n\",\n           zFilename, flags, pResOut));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( rc ){\n      /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file\n      ** as if it does not exist.\n      */\n      if(    flags==SQLITE_ACCESS_EXISTS\n          && sAttrData.nFileSizeHigh==0\n          && sAttrData.nFileSizeLow==0 ){\n        attr = INVALID_FILE_ATTRIBUTES;\n      }else{\n        attr = sAttrData.dwFileAttributes;\n      }\n    }else{\n      winLogIoerr(cnt, __LINE__);\n      if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){\n        sqlite3_free(zConverted);\n        return winLogError(SQLITE_IOERR_ACCESS, lastErrno, \"winAccess\",\n                           zFilename);\n      }else{\n        attr = INVALID_FILE_ATTRIBUTES;\n      }\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    attr = osGetFileAttributesA((char*)zConverted);\n  }\n#endif\n  sqlite3_free(zConverted);\n  switch( flags ){\n    case SQLITE_ACCESS_READ:\n    case SQLITE_ACCESS_EXISTS:\n      rc = attr!=INVALID_FILE_ATTRIBUTES;\n      break;\n    case SQLITE_ACCESS_READWRITE:\n      rc = attr!=INVALID_FILE_ATTRIBUTES &&\n             (attr & FILE_ATTRIBUTE_READONLY)==0;\n      break;\n    default:\n      assert(!\"Invalid flags argument\");\n  }\n  *pResOut = rc;\n  OSTRACE((\"ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           zFilename, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Returns non-zero if the specified path name starts with a drive letter\n** followed by a colon character.\n*/\nstatic BOOL winIsDriveLetterAndColon(\n  const char *zPathname\n){\n  return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' );\n}\n\n/*\n** Returns non-zero if the specified path name should be used verbatim.  If\n** non-zero is returned from this function, the calling function must simply\n** use the provided path name verbatim -OR- resolve it into a full path name\n** using the GetFullPathName Win32 API function (if available).\n*/\nstatic BOOL winIsVerbatimPathname(\n  const char *zPathname\n){\n  /*\n  ** If the path name starts with a forward slash or a backslash, it is either\n  ** a legal UNC name, a volume relative path, or an absolute path name in the\n  ** \"Unix\" format on Windows.  There is no easy way to differentiate between\n  ** the final two cases; therefore, we return the safer return value of TRUE\n  ** so that callers of this function will simply use it verbatim.\n  */\n  if ( winIsDirSep(zPathname[0]) ){\n    return TRUE;\n  }\n\n  /*\n  ** If the path name starts with a letter and a colon it is either a volume\n  ** relative path or an absolute path.  Callers of this function must not\n  ** attempt to treat it as a relative path name (i.e. they should simply use\n  ** it verbatim).\n  */\n  if ( winIsDriveLetterAndColon(zPathname) ){\n    return TRUE;\n  }\n\n  /*\n  ** If we get to this point, the path name should almost certainly be a purely\n  ** relative one (i.e. not a UNC name, not absolute, and not volume relative).\n  */\n  return FALSE;\n}\n\n/*\n** Turn a relative pathname into a full pathname.  Write the full\n** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname\n** bytes in size.\n*/\nstatic int winFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zRelative,        /* Possibly relative input path */\n  int nFull,                    /* Size of output buffer in bytes */\n  char *zFull                   /* Output buffer */\n){\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  DWORD nByte;\n  void *zConverted;\n  char *zOut;\n#endif\n\n  /* If this path name begins with \"/X:\", where \"X\" is any alphabetic\n  ** character, discard the initial \"/\" from the pathname.\n  */\n  if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){\n    zRelative++;\n  }\n\n#if defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  UNUSED_PARAMETER(nFull);\n  assert( nFull>=pVfs->mxPathname );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a slash.\n    */\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |\n            CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname1\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                       sqlite3_data_directory, winGetDirSep(), zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }else{\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A),\n            zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname2\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }\n  return SQLITE_OK;\n#endif\n\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  /* WinCE has no concept of a relative pathname, or so I am told. */\n  /* WinRT has no way to convert a relative path to an absolute one. */\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n  }else{\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zRelative);\n  }\n  return SQLITE_OK;\n#endif\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n    return SQLITE_OK;\n  }\n  zConverted = winConvertFromUtf8Filename(zRelative);\n  if( zConverted==0 ){\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    LPWSTR zTemp;\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname1\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname2\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winUnicodeToUtf8(zTemp);\n    sqlite3_free(zTemp);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp;\n    nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname3\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname4\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n    sqlite3_free(zTemp);\n  }\n#endif\n  if( zOut ){\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zOut);\n    sqlite3_free(zOut);\n    return SQLITE_OK;\n  }else{\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n#endif\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\nstatic void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){\n  HANDLE h;\n#if defined(__CYGWIN__)\n  int nFull = pVfs->mxPathname+1;\n  char *zFull = sqlite3MallocZero( nFull );\n  void *zConverted = 0;\n  if( zFull==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( winFullPathname(pVfs, zFilename, nFull, zFull)!=SQLITE_OK ){\n    sqlite3_free(zFull);\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  zConverted = winConvertFromUtf8Filename(zFull);\n  sqlite3_free(zFull);\n#else\n  void *zConverted = winConvertFromUtf8Filename(zFilename);\n  UNUSED_PARAMETER(pVfs);\n#endif\n  if( zConverted==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);\n#else\n    h = osLoadLibraryW((LPCWSTR)zConverted);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    h = osLoadLibraryA((char*)zConverted);\n  }\n#endif\n  OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)h));\n  sqlite3_free(zConverted);\n  return (void*)h;\n}\nstatic void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){\n  UNUSED_PARAMETER(pVfs);\n  winGetLastErrorMsg(osGetLastError(), nBuf, zBufOut);\n}\nstatic void (*winDlSym(sqlite3_vfs *pVfs,void *pH,const char *zSym))(void){\n  FARPROC proc;\n  UNUSED_PARAMETER(pVfs);\n  proc = osGetProcAddressA((HANDLE)pH, zSym);\n  OSTRACE((\"DLSYM handle=%p, symbol=%s, address=%p\\n\",\n           (void*)pH, zSym, (void*)proc));\n  return (void(*)(void))proc;\n}\nstatic void winDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  UNUSED_PARAMETER(pVfs);\n  osFreeLibrary((HANDLE)pHandle);\n  OSTRACE((\"DLCLOSE handle=%p\\n\", (void*)pHandle));\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define winDlOpen  0\n  #define winDlError 0\n  #define winDlSym   0\n  #define winDlClose 0\n#endif\n\n/* State information for the randomness gatherer. */\ntypedef struct EntropyGatherer EntropyGatherer;\nstruct EntropyGatherer {\n  unsigned char *a;   /* Gather entropy into this buffer */\n  int na;             /* Size of a[] in bytes */\n  int i;              /* XOR next input into a[i] */\n  int nXor;           /* Number of XOR operations done */\n};\n\n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n/* Mix sz bytes of entropy into p. */\nstatic void xorMemory(EntropyGatherer *p, unsigned char *x, int sz){\n  int j, k;\n  for(j=0, k=p->i; j<sz; j++){\n    p->a[k++] ^= x[j];\n    if( k>=p->na ) k = 0;\n  }\n  p->i = k;\n  p->nXor += sz;\n}\n#endif /* !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS) */\n\n/*\n** Write up to nBuf bytes of randomness into zBuf.\n*/\nstatic int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n#if defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS)\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  return nBuf;\n#else\n  EntropyGatherer e;\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  e.a = (unsigned char*)zBuf;\n  e.na = nBuf;\n  e.nXor = 0;\n  e.i = 0;\n  {\n    SYSTEMTIME x;\n    osGetSystemTime(&x);\n    xorMemory(&e, (unsigned char*)&x, sizeof(SYSTEMTIME));\n  }\n  {\n    DWORD pid = osGetCurrentProcessId();\n    xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));\n  }\n#if SQLITE_OS_WINRT\n  {\n    ULONGLONG cnt = osGetTickCount64();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(ULONGLONG));\n  }\n#else\n  {\n    DWORD cnt = osGetTickCount();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));\n  }\n#endif /* SQLITE_OS_WINRT */\n  {\n    LARGE_INTEGER i;\n    osQueryPerformanceCounter(&i);\n    xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));\n  }\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  {\n    UUID id;\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreate(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreateSequential(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n  }\n#endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */\n  return e.nXor>nBuf ? nBuf : e.nXor;\n#endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nstatic int winSleep(sqlite3_vfs *pVfs, int microsec){\n  sqlite3_win32_sleep((microsec+999)/1000);\n  UNUSED_PARAMETER(pVfs);\n  return ((microsec+999)/1000)*1000;\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date\n** cannot be found.\n*/\nstatic int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){\n  /* FILETIME structure is a 64-bit value representing the number of\n     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).\n  */\n  FILETIME ft;\n  static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;\n#ifdef SQLITE_TEST\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n#endif\n  /* 2^32 - to avoid use of LL and warnings in gcc */\n  static const sqlite3_int64 max32BitValue =\n      (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +\n      (sqlite3_int64)294967296;\n\n#if SQLITE_OS_WINCE\n  SYSTEMTIME time;\n  osGetSystemTime(&time);\n  /* if SystemTimeToFileTime() fails, it returns zero. */\n  if (!osSystemTimeToFileTime(&time,&ft)){\n    return SQLITE_ERROR;\n  }\n#else\n  osGetSystemTimeAsFileTime( &ft );\n#endif\n\n  *piNow = winFiletimeEpoch +\n            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +\n               (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(pVfs);\n  return SQLITE_OK;\n}\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){\n  int rc;\n  sqlite3_int64 i;\n  rc = winCurrentTimeInt64(pVfs, &i);\n  if( !rc ){\n    *prNow = i/86400000.0;\n  }\n  return rc;\n}\n\n/*\n** The idea is that this function works like a combination of\n** GetLastError() and FormatMessage() on Windows (or errno and\n** strerror_r() on Unix). After an error is returned by an OS\n** function, SQLite calls this function with zBuf pointing to\n** a buffer of nBuf bytes. The OS layer should populate the\n** buffer with a nul-terminated UTF-8 encoded error message\n** describing the last IO error to have occurred within the calling\n** thread.\n**\n** If the error message is too large for the supplied buffer,\n** it should be truncated. The return value of xGetLastError\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated). If non-zero is returned,\n** then it is not necessary to include the nul-terminator character\n** in the output buffer.\n**\n** Not supplying an error message will have no adverse effect\n** on SQLite. It is fine to have an implementation that never\n** returns an error message:\n**\n**   int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n**     assert(zBuf[0]=='\\0');\n**     return 0;\n**   }\n**\n** However if an error message is supplied, it will be incorporated\n** by sqlite into the error message available to the user using\n** sqlite3_errmsg(), possibly making IO errors easier to debug.\n*/\nstatic int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n  DWORD e = osGetLastError();\n  UNUSED_PARAMETER(pVfs);\n  if( nBuf>0 ) winGetLastErrorMsg(e, nBuf, zBuf);\n  return e;\n}\n\n/*\n** Initialize and deinitialize the operating system interface.\n*/\nSQLITE_API int sqlite3_os_init(void){\n  static sqlite3_vfs winVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32\",               /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath\",      /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n  static sqlite3_vfs winNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-none\",          /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath-none\", /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==80 );\n\n  /* get memory map allocation granularity */\n  memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));\n#if SQLITE_OS_WINRT\n  osGetNativeSystemInfo(&winSysInfo);\n#else\n  osGetSystemInfo(&winSysInfo);\n#endif\n  assert( winSysInfo.dwAllocationGranularity>0 );\n  assert( winSysInfo.dwPageSize>0 );\n\n  sqlite3_vfs_register(&winVfs, 1);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathVfs, 0);\n#endif\n\n  sqlite3_vfs_register(&winNolockVfs, 0);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathNolockVfs, 0);\n#endif\n\n  return SQLITE_OK;\n}\n\nSQLITE_API int sqlite3_os_end(void){\n#if SQLITE_OS_WINRT\n  if( sleepObj!=NULL ){\n    osCloseHandle(sleepObj);\n    sleepObj = NULL;\n  }\n#endif\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OS_WIN */\n\n/************** End of os_win.c **********************************************/\n/************** Begin file bitvec.c ******************************************/\n/*\n** 2008 February 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an object that represents a fixed-length\n** bitmap.  Bits are numbered starting with 1.\n**\n** A bitmap is used to record which pages of a database file have been\n** journalled during a transaction, or which pages have the \"dont-write\"\n** property.  Usually only a few pages are meet either condition.\n** So the bitmap is usually sparse and has low cardinality.\n** But sometimes (for example when during a DROP of a large table) most\n** or all of the pages in a database can get journalled.  In those cases, \n** the bitmap becomes dense with high cardinality.  The algorithm needs \n** to handle both cases well.\n**\n** The size of the bitmap is fixed when the object is created.\n**\n** All bits are clear when the bitmap is created.  Individual bits\n** may be set or cleared one at a time.\n**\n** Test operations are about 100 times more common that set operations.\n** Clear operations are exceedingly rare.  There are usually between\n** 5 and 500 set operations per Bitvec object, though the number of sets can\n** sometimes grow into tens of thousands or larger.  The size of the\n** Bitvec object is the number of pages in the database file at the\n** start of a transaction, and is thus usually less than a few thousand,\n** but can be as large as 2 billion for a really big database.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Size of the Bitvec structure in bytes. */\n#define BITVEC_SZ        512\n\n/* Round the union size down to the nearest pointer boundary, since that's how \n** it will be aligned within the Bitvec struct. */\n#define BITVEC_USIZE \\\n    (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*))\n\n/* Type of the array \"element\" for the bitmap representation. \n** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. \n** Setting this to the \"natural word\" size of your CPU may improve\n** performance. */\n#define BITVEC_TELEM     u8\n/* Size, in bits, of the bitmap element. */\n#define BITVEC_SZELEM    8\n/* Number of elements in a bitmap array. */\n#define BITVEC_NELEM     (BITVEC_USIZE/sizeof(BITVEC_TELEM))\n/* Number of bits in the bitmap array. */\n#define BITVEC_NBIT      (BITVEC_NELEM*BITVEC_SZELEM)\n\n/* Number of u32 values in hash table. */\n#define BITVEC_NINT      (BITVEC_USIZE/sizeof(u32))\n/* Maximum number of entries in hash table before \n** sub-dividing and re-hashing. */\n#define BITVEC_MXHASH    (BITVEC_NINT/2)\n/* Hashing function for the aHash representation.\n** Empirical testing showed that the *37 multiplier \n** (an arbitrary prime)in the hash function provided \n** no fewer collisions than the no-op *1. */\n#define BITVEC_HASH(X)   (((X)*1)%BITVEC_NINT)\n\n#define BITVEC_NPTR      (BITVEC_USIZE/sizeof(Bitvec *))\n\n\n/*\n** A bitmap is an instance of the following structure.\n**\n** This bitmap records the existence of zero or more bits\n** with values between 1 and iSize, inclusive.\n**\n** There are three possible representations of the bitmap.\n** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight\n** bitmap.  The least significant bit is bit 1.\n**\n** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is\n** a hash table that will hold up to BITVEC_MXHASH distinct values.\n**\n** Otherwise, the value i is redirected into one of BITVEC_NPTR\n** sub-bitmaps pointed to by Bitvec.u.apSub[].  Each subbitmap\n** handles up to iDivisor separate values of i.  apSub[0] holds\n** values between 1 and iDivisor.  apSub[1] holds values between\n** iDivisor+1 and 2*iDivisor.  apSub[N] holds values between\n** N*iDivisor+1 and (N+1)*iDivisor.  Each subbitmap is normalized\n** to hold deal with values between 1 and iDivisor.\n*/\nstruct Bitvec {\n  u32 iSize;      /* Maximum bit index.  Max iSize is 4,294,967,296. */\n  u32 nSet;       /* Number of bits that are set - only valid for aHash\n                  ** element.  Max is BITVEC_NINT.  For BITVEC_SZ of 512,\n                  ** this would be 125. */\n  u32 iDivisor;   /* Number of bits handled by each apSub[] entry. */\n                  /* Should >=0 for apSub element. */\n                  /* Max iDivisor is max(u32) / BITVEC_NPTR + 1.  */\n                  /* For a BITVEC_SZ of 512, this would be 34,359,739. */\n  union {\n    BITVEC_TELEM aBitmap[BITVEC_NELEM];    /* Bitmap representation */\n    u32 aHash[BITVEC_NINT];      /* Hash table representation */\n    Bitvec *apSub[BITVEC_NPTR];  /* Recursive representation */\n  } u;\n};\n\n/*\n** Create a new bitmap object able to handle bits between 0 and iSize,\n** inclusive.  Return a pointer to the new object.  Return NULL if \n** malloc fails.\n*/\nSQLITE_PRIVATE Bitvec *sqlite3BitvecCreate(u32 iSize){\n  Bitvec *p;\n  assert( sizeof(*p)==BITVEC_SZ );\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p ){\n    p->iSize = iSize;\n  }\n  return p;\n}\n\n/*\n** Check to see if the i-th bit is set.  Return true or false.\n** If p is NULL (if the bitmap has not been created) or if\n** i is out of range, then return false.\n*/\nSQLITE_PRIVATE int sqlite3BitvecTestNotNull(Bitvec *p, u32 i){\n  assert( p!=0 );\n  i--;\n  if( i>=p->iSize ) return 0;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return 0;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    return (p->u.aBitmap[i/BITVEC_SZELEM] & (1<<(i&(BITVEC_SZELEM-1))))!=0;\n  } else{\n    u32 h = BITVEC_HASH(i++);\n    while( p->u.aHash[h] ){\n      if( p->u.aHash[h]==i ) return 1;\n      h = (h+1) % BITVEC_NINT;\n    }\n    return 0;\n  }\n}\nSQLITE_PRIVATE int sqlite3BitvecTest(Bitvec *p, u32 i){\n  return p!=0 && sqlite3BitvecTestNotNull(p,i);\n}\n\n/*\n** Set the i-th bit.  Return 0 on success and an error code if\n** anything goes wrong.\n**\n** This routine might cause sub-bitmaps to be allocated.  Failing\n** to get the memory needed to hold the sub-bitmap is the only\n** that can go wrong with an insert, assuming p and i are valid.\n**\n** The calling function must ensure that p is a valid Bitvec object\n** and that the value for \"i\" is within range of the Bitvec object.\n** Otherwise the behavior is undefined.\n*/\nSQLITE_PRIVATE int sqlite3BitvecSet(Bitvec *p, u32 i){\n  u32 h;\n  if( p==0 ) return SQLITE_OK;\n  assert( i>0 );\n  assert( i<=p->iSize );\n  i--;\n  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    if( p->u.apSub[bin]==0 ){\n      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );\n      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM_BKPT;\n    }\n    p = p->u.apSub[bin];\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] |= 1 << (i&(BITVEC_SZELEM-1));\n    return SQLITE_OK;\n  }\n  h = BITVEC_HASH(i++);\n  /* if there wasn't a hash collision, and this doesn't */\n  /* completely fill the hash, then just add it without */\n  /* worring about sub-dividing and re-hashing. */\n  if( !p->u.aHash[h] ){\n    if (p->nSet<(BITVEC_NINT-1)) {\n      goto bitvec_set_end;\n    } else {\n      goto bitvec_set_rehash;\n    }\n  }\n  /* there was a collision, check to see if it's already */\n  /* in hash, if not, try to find a spot for it */\n  do {\n    if( p->u.aHash[h]==i ) return SQLITE_OK;\n    h++;\n    if( h>=BITVEC_NINT ) h = 0;\n  } while( p->u.aHash[h] );\n  /* we didn't find it in the hash.  h points to the first */\n  /* available free spot. check to see if this is going to */\n  /* make our hash too \"full\".  */\nbitvec_set_rehash:\n  if( p->nSet>=BITVEC_MXHASH ){\n    unsigned int j;\n    int rc;\n    u32 *aiValues = sqlite3StackAllocRaw(0, sizeof(p->u.aHash));\n    if( aiValues==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }else{\n      memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n      memset(p->u.apSub, 0, sizeof(p->u.apSub));\n      p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;\n      rc = sqlite3BitvecSet(p, i);\n      for(j=0; j<BITVEC_NINT; j++){\n        if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);\n      }\n      sqlite3StackFree(0, aiValues);\n      return rc;\n    }\n  }\nbitvec_set_end:\n  p->nSet++;\n  p->u.aHash[h] = i;\n  return SQLITE_OK;\n}\n\n/*\n** Clear the i-th bit.\n**\n** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage\n** that BitvecClear can use to rebuilt its hash table.\n*/\nSQLITE_PRIVATE void sqlite3BitvecClear(Bitvec *p, u32 i, void *pBuf){\n  if( p==0 ) return;\n  assert( i>0 );\n  i--;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] &= ~(1 << (i&(BITVEC_SZELEM-1)));\n  }else{\n    unsigned int j;\n    u32 *aiValues = pBuf;\n    memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n    memset(p->u.aHash, 0, sizeof(p->u.aHash));\n    p->nSet = 0;\n    for(j=0; j<BITVEC_NINT; j++){\n      if( aiValues[j] && aiValues[j]!=(i+1) ){\n        u32 h = BITVEC_HASH(aiValues[j]-1);\n        p->nSet++;\n        while( p->u.aHash[h] ){\n          h++;\n          if( h>=BITVEC_NINT ) h = 0;\n        }\n        p->u.aHash[h] = aiValues[j];\n      }\n    }\n  }\n}\n\n/*\n** Destroy a bitmap object.  Reclaim all memory used.\n*/\nSQLITE_PRIVATE void sqlite3BitvecDestroy(Bitvec *p){\n  if( p==0 ) return;\n  if( p->iDivisor ){\n    unsigned int i;\n    for(i=0; i<BITVEC_NPTR; i++){\n      sqlite3BitvecDestroy(p->u.apSub[i]);\n    }\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Return the value of the iSize parameter specified when Bitvec *p\n** was created.\n*/\nSQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec *p){\n  return p->iSize;\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** Let V[] be an array of unsigned characters sufficient to hold\n** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.\n** Then the following macros can be used to set, clear, or test\n** individual bits within V.\n*/\n#define SETBIT(V,I)      V[I>>3] |= (1<<(I&7))\n#define CLEARBIT(V,I)    V[I>>3] &= ~(1<<(I&7))\n#define TESTBIT(V,I)     (V[I>>3]&(1<<(I&7)))!=0\n\n/*\n** This routine runs an extensive test of the Bitvec code.\n**\n** The input is an array of integers that acts as a program\n** to test the Bitvec.  The integers are opcodes followed\n** by 0, 1, or 3 operands, depending on the opcode.  Another\n** opcode follows immediately after the last operand.\n**\n** There are 6 opcodes numbered from 0 through 5.  0 is the\n** \"halt\" opcode and causes the test to end.\n**\n**    0          Halt and return the number of errors\n**    1 N S X    Set N bits beginning with S and incrementing by X\n**    2 N S X    Clear N bits beginning with S and incrementing by X\n**    3 N        Set N randomly chosen bits\n**    4 N        Clear N randomly chosen bits\n**    5 N S X    Set N bits from S increment X in array only, not in bitvec\n**\n** The opcodes 1 through 4 perform set and clear operations are performed\n** on both a Bitvec object and on a linear array of bits obtained from malloc.\n** Opcode 5 works on the linear array only, not on the Bitvec.\n** Opcode 5 is used to deliberately induce a fault in order to\n** confirm that error detection works.\n**\n** At the conclusion of the test the linear array is compared\n** against the Bitvec object.  If there are any differences,\n** an error is returned.  If they are the same, zero is returned.\n**\n** If a memory allocation error occurs, return -1.\n*/\nSQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){\n  Bitvec *pBitvec = 0;\n  unsigned char *pV = 0;\n  int rc = -1;\n  int i, nx, pc, op;\n  void *pTmpSpace;\n\n  /* Allocate the Bitvec to be tested and a linear array of\n  ** bits to act as the reference */\n  pBitvec = sqlite3BitvecCreate( sz );\n  pV = sqlite3MallocZero( (sz+7)/8 + 1 );\n  pTmpSpace = sqlite3_malloc64(BITVEC_SZ);\n  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;\n\n  /* NULL pBitvec tests */\n  sqlite3BitvecSet(0, 1);\n  sqlite3BitvecClear(0, 1, pTmpSpace);\n\n  /* Run the program */\n  pc = 0;\n  while( (op = aOp[pc])!=0 ){\n    switch( op ){\n      case 1:\n      case 2:\n      case 5: {\n        nx = 4;\n        i = aOp[pc+2] - 1;\n        aOp[pc+2] += aOp[pc+3];\n        break;\n      }\n      case 3:\n      case 4: \n      default: {\n        nx = 2;\n        sqlite3_randomness(sizeof(i), &i);\n        break;\n      }\n    }\n    if( (--aOp[pc+1]) > 0 ) nx = 0;\n    pc += nx;\n    i = (i & 0x7fffffff)%sz;\n    if( (op & 1)!=0 ){\n      SETBIT(pV, (i+1));\n      if( op!=5 ){\n        if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;\n      }\n    }else{\n      CLEARBIT(pV, (i+1));\n      sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);\n    }\n  }\n\n  /* Test to make sure the linear array exactly matches the\n  ** Bitvec object.  Start with the assumption that they do\n  ** match (rc==0).  Change rc to non-zero if a discrepancy\n  ** is found.\n  */\n  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)\n          + sqlite3BitvecTest(pBitvec, 0)\n          + (sqlite3BitvecSize(pBitvec) - sz);\n  for(i=1; i<=sz; i++){\n    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){\n      rc = i;\n      break;\n    }\n  }\n\n  /* Free allocated structure */\nbitvec_end:\n  sqlite3_free(pTmpSpace);\n  sqlite3_free(pV);\n  sqlite3BitvecDestroy(pBitvec);\n  return rc;\n}\n#endif /* SQLITE_UNTESTABLE */\n\n/************** End of bitvec.c **********************************************/\n/************** Begin file pcache.c ******************************************/\n/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements that page cache.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** A complete page cache is an instance of this structure.  Every\n** entry in the cache holds a single page of the database file.  The\n** btree layer only operates on the cached copy of the database pages.\n**\n** A page cache entry is \"clean\" if it exactly matches what is currently\n** on disk.  A page is \"dirty\" if it has been modified and needs to be\n** persisted to disk.\n**\n** pDirty, pDirtyTail, pSynced:\n**   All dirty pages are linked into the doubly linked list using\n**   PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order\n**   such that p was added to the list more recently than p->pDirtyNext.\n**   PCache.pDirty points to the first (newest) element in the list and\n**   pDirtyTail to the last (oldest).\n**\n**   The PCache.pSynced variable is used to optimize searching for a dirty\n**   page to eject from the cache mid-transaction. It is better to eject\n**   a page that does not require a journal sync than one that does. \n**   Therefore, pSynced is maintained to that it *almost* always points\n**   to either the oldest page in the pDirty/pDirtyTail list that has a\n**   clear PGHDR_NEED_SYNC flag or to a page that is older than this one\n**   (so that the right page to eject can be found by following pDirtyPrev\n**   pointers).\n*/\nstruct PCache {\n  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */\n  PgHdr *pSynced;                     /* Last synced page in dirty page list */\n  int nRefSum;                        /* Sum of ref counts over all pages */\n  int szCache;                        /* Configured cache size */\n  int szSpill;                        /* Size before spilling occurs */\n  int szPage;                         /* Size of every page in this cache */\n  int szExtra;                        /* Size of extra space for each page */\n  u8 bPurgeable;                      /* True if pages are on backing store */\n  u8 eCreate;                         /* eCreate value for for xFetch() */\n  int (*xStress)(void*,PgHdr*);       /* Call to try make a page clean */\n  void *pStress;                      /* Argument to xStress */\n  sqlite3_pcache *pCache;             /* Pluggable cache module */\n};\n\n/********************************** Test and Debug Logic **********************/\n/*\n** Debug tracing macros.  Enable by by changing the \"0\" to \"1\" and\n** recompiling.\n**\n** When sqlite3PcacheTrace is 1, single line trace messages are issued.\n** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries\n** is displayed for many operations, resulting in a lot of output.\n*/\n#if defined(SQLITE_DEBUG) && 0\n  int sqlite3PcacheTrace = 2;       /* 0: off  1: simple  2: cache dumps */\n  int sqlite3PcacheMxDump = 9999;   /* Max cache entries for pcacheDump() */\n# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;}\n  void pcacheDump(PCache *pCache){\n    int N;\n    int i, j;\n    sqlite3_pcache_page *pLower;\n    PgHdr *pPg;\n    unsigned char *a;\n  \n    if( sqlite3PcacheTrace<2 ) return;\n    if( pCache->pCache==0 ) return;\n    N = sqlite3PcachePagecount(pCache);\n    if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump;\n    for(i=1; i<=N; i++){\n       pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);\n       if( pLower==0 ) continue;\n       pPg = (PgHdr*)pLower->pExtra;\n       printf(\"%3d: nRef %2d flgs %02x data \", i, pPg->nRef, pPg->flags);\n       a = (unsigned char *)pLower->pBuf;\n       for(j=0; j<12; j++) printf(\"%02x\", a[j]);\n       printf(\"\\n\");\n       if( pPg->pPage==0 ){\n         sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);\n       }\n    }\n  }\n  #else\n# define pcacheTrace(X)\n# define pcacheDump(X)\n#endif\n\n/*\n** Check invariants on a PgHdr entry.  Return true if everything is OK.\n** Return false if any invariant is violated.\n**\n** This routine is for use inside of assert() statements only.  For\n** example:\n**\n**          assert( sqlite3PcachePageSanity(pPg) );\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){\n  PCache *pCache;\n  assert( pPg!=0 );\n  assert( pPg->pgno>0 || pPg->pPager==0 );    /* Page number is 1 or more */\n  pCache = pPg->pCache;\n  assert( pCache!=0 );      /* Every page has an associated PCache */\n  if( pPg->flags & PGHDR_CLEAN ){\n    assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */\n    assert( pCache->pDirty!=pPg );          /* CLEAN pages not on dirty list */\n    assert( pCache->pDirtyTail!=pPg );\n  }\n  /* WRITEABLE pages must also be DIRTY */\n  if( pPg->flags & PGHDR_WRITEABLE ){\n    assert( pPg->flags & PGHDR_DIRTY );     /* WRITEABLE implies DIRTY */\n  }\n  /* NEED_SYNC can be set independently of WRITEABLE.  This can happen,\n  ** for example, when using the sqlite3PagerDontWrite() optimization:\n  **    (1)  Page X is journalled, and gets WRITEABLE and NEED_SEEK.\n  **    (2)  Page X moved to freelist, WRITEABLE is cleared\n  **    (3)  Page X reused, WRITEABLE is set again\n  ** If NEED_SYNC had been cleared in step 2, then it would not be reset\n  ** in step 3, and page might be written into the database without first\n  ** syncing the rollback journal, which might cause corruption on a power\n  ** loss.\n  **\n  ** Another example is when the database page size is smaller than the\n  ** disk sector size.  When any page of a sector is journalled, all pages\n  ** in that sector are marked NEED_SYNC even if they are still CLEAN, just\n  ** in case they are later modified, since all pages in the same sector\n  ** must be journalled and synced before any of those pages can be safely\n  ** written.\n  */\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/********************************** Linked List Management ********************/\n\n/* Allowed values for second argument to pcacheManageDirtyList() */\n#define PCACHE_DIRTYLIST_REMOVE   1    /* Remove pPage from dirty list */\n#define PCACHE_DIRTYLIST_ADD      2    /* Add pPage to the dirty list */\n#define PCACHE_DIRTYLIST_FRONT    3    /* Move pPage to the front of the list */\n\n/*\n** Manage pPage's participation on the dirty list.  Bits of the addRemove\n** argument determines what operation to do.  The 0x01 bit means first\n** remove pPage from the dirty list.  The 0x02 means add pPage back to\n** the dirty list.  Doing both moves pPage to the front of the dirty list.\n*/\nstatic void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){\n  PCache *p = pPage->pCache;\n\n  pcacheTrace((\"%p.DIRTYLIST.%s %d\\n\", p,\n                addRemove==1 ? \"REMOVE\" : addRemove==2 ? \"ADD\" : \"FRONT\",\n                pPage->pgno));\n  if( addRemove & PCACHE_DIRTYLIST_REMOVE ){\n    assert( pPage->pDirtyNext || pPage==p->pDirtyTail );\n    assert( pPage->pDirtyPrev || pPage==p->pDirty );\n  \n    /* Update the PCache1.pSynced variable if necessary. */\n    if( p->pSynced==pPage ){\n      p->pSynced = pPage->pDirtyPrev;\n    }\n  \n    if( pPage->pDirtyNext ){\n      pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;\n    }else{\n      assert( pPage==p->pDirtyTail );\n      p->pDirtyTail = pPage->pDirtyPrev;\n    }\n    if( pPage->pDirtyPrev ){\n      pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;\n    }else{\n      /* If there are now no dirty pages in the cache, set eCreate to 2. \n      ** This is an optimization that allows sqlite3PcacheFetch() to skip\n      ** searching for a dirty page to eject from the cache when it might\n      ** otherwise have to.  */\n      assert( pPage==p->pDirty );\n      p->pDirty = pPage->pDirtyNext;\n      assert( p->bPurgeable || p->eCreate==2 );\n      if( p->pDirty==0 ){         /*OPTIMIZATION-IF-TRUE*/\n        assert( p->bPurgeable==0 || p->eCreate==1 );\n        p->eCreate = 2;\n      }\n    }\n  }\n  if( addRemove & PCACHE_DIRTYLIST_ADD ){\n    pPage->pDirtyPrev = 0;\n    pPage->pDirtyNext = p->pDirty;\n    if( pPage->pDirtyNext ){\n      assert( pPage->pDirtyNext->pDirtyPrev==0 );\n      pPage->pDirtyNext->pDirtyPrev = pPage;\n    }else{\n      p->pDirtyTail = pPage;\n      if( p->bPurgeable ){\n        assert( p->eCreate==2 );\n        p->eCreate = 1;\n      }\n    }\n    p->pDirty = pPage;\n\n    /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set\n    ** pSynced to point to it. Checking the NEED_SYNC flag is an \n    ** optimization, as if pSynced points to a page with the NEED_SYNC\n    ** flag set sqlite3PcacheFetchStress() searches through all newer \n    ** entries of the dirty-list for a page with NEED_SYNC clear anyway.  */\n    if( !p->pSynced \n     && 0==(pPage->flags&PGHDR_NEED_SYNC)   /*OPTIMIZATION-IF-FALSE*/\n    ){\n      p->pSynced = pPage;\n    }\n  }\n  pcacheDump(p);\n}\n\n/*\n** Wrapper around the pluggable caches xUnpin method. If the cache is\n** being used for an in-memory database, this function is a no-op.\n*/\nstatic void pcacheUnpin(PgHdr *p){\n  if( p->pCache->bPurgeable ){\n    pcacheTrace((\"%p.UNPIN %d\\n\", p->pCache, p->pgno));\n    sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);\n    pcacheDump(p->pCache);\n  }\n}\n\n/*\n** Compute the number of pages of cache requested.   p->szCache is the\n** cache size requested by the \"PRAGMA cache_size\" statement.\n*/\nstatic int numberOfCachePages(PCache *p){\n  if( p->szCache>=0 ){\n    /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the\n    ** suggested cache size is set to N. */\n    return p->szCache;\n  }else{\n    /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then\n    ** the number of cache pages is adjusted to use approximately abs(N*1024)\n    ** bytes of memory. */\n    return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));\n  }\n}\n\n/*************************************************** General Interfaces ******\n**\n** Initialize and shutdown the page cache subsystem. Neither of these \n** functions are threadsafe.\n*/\nSQLITE_PRIVATE int sqlite3PcacheInitialize(void){\n  if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n    /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the\n    ** built-in default page cache is used instead of the application defined\n    ** page cache. */\n    sqlite3PCacheSetDefault();\n  }\n  return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);\n}\nSQLITE_PRIVATE void sqlite3PcacheShutdown(void){\n  if( sqlite3GlobalConfig.pcache2.xShutdown ){\n    /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */\n    sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg);\n  }\n}\n\n/*\n** Return the size in bytes of a PCache object.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSize(void){ return sizeof(PCache); }\n\n/*\n** Create a new PCache object. Storage space to hold the object\n** has already been allocated and is passed in as the p pointer. \n** The caller discovers how much space needs to be allocated by \n** calling sqlite3PcacheSize().\n**\n** szExtra is some extra space allocated for each page.  The first\n** 8 bytes of the extra space will be zeroed as the page is allocated,\n** but remaining content will be uninitialized.  Though it is opaque\n** to this module, the extra space really ends up being the MemPage\n** structure in the pager.\n*/\nSQLITE_PRIVATE int sqlite3PcacheOpen(\n  int szPage,                  /* Size of every page */\n  int szExtra,                 /* Extra space associated with each page */\n  int bPurgeable,              /* True if pages are on backing store */\n  int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */\n  void *pStress,               /* Argument to xStress */\n  PCache *p                    /* Preallocated space for the PCache */\n){\n  memset(p, 0, sizeof(PCache));\n  p->szPage = 1;\n  p->szExtra = szExtra;\n  assert( szExtra>=8 );  /* First 8 bytes will be zeroed */\n  p->bPurgeable = bPurgeable;\n  p->eCreate = 2;\n  p->xStress = xStress;\n  p->pStress = pStress;\n  p->szCache = 100;\n  p->szSpill = 1;\n  pcacheTrace((\"%p.OPEN szPage %d bPurgeable %d\\n\",p,szPage,bPurgeable));\n  return sqlite3PcacheSetPageSize(p, szPage);\n}\n\n/*\n** Change the page size for PCache object. The caller must ensure that there\n** are no outstanding page references when this function is called.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){\n  assert( pCache->nRefSum==0 && pCache->pDirty==0 );\n  if( pCache->szPage ){\n    sqlite3_pcache *pNew;\n    pNew = sqlite3GlobalConfig.pcache2.xCreate(\n                szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),\n                pCache->bPurgeable\n    );\n    if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));\n    if( pCache->pCache ){\n      sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n    }\n    pCache->pCache = pNew;\n    pCache->szPage = szPage;\n    pcacheTrace((\"%p.PAGESIZE %d\\n\",pCache,szPage));\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Try to obtain a page from the cache.\n**\n** This routine returns a pointer to an sqlite3_pcache_page object if\n** such an object is already in cache, or if a new one is created.\n** This routine returns a NULL pointer if the object was not in cache\n** and could not be created.\n**\n** The createFlags should be 0 to check for existing pages and should\n** be 3 (not 1, but 3) to try to create a new page.\n**\n** If the createFlag is 0, then NULL is always returned if the page\n** is not already in the cache.  If createFlag is 1, then a new page\n** is created only if that can be done without spilling dirty pages\n** and without exceeding the cache size limit.\n**\n** The caller needs to invoke sqlite3PcacheFetchFinish() to properly\n** initialize the sqlite3_pcache_page object and convert it into a\n** PgHdr object.  The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish()\n** routines are split this way for performance reasons. When separated\n** they can both (usually) operate without having to push values to\n** the stack on entry and pop them back off on exit, which saves a\n** lot of pushing and popping.\n*/\nSQLITE_PRIVATE sqlite3_pcache_page *sqlite3PcacheFetch(\n  PCache *pCache,       /* Obtain the page from this cache */\n  Pgno pgno,            /* Page number to obtain */\n  int createFlag        /* If true, create page if it does not exist already */\n){\n  int eCreate;\n  sqlite3_pcache_page *pRes;\n\n  assert( pCache!=0 );\n  assert( pCache->pCache!=0 );\n  assert( createFlag==3 || createFlag==0 );\n  assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );\n\n  /* eCreate defines what to do if the page does not exist.\n  **    0     Do not allocate a new page.  (createFlag==0)\n  **    1     Allocate a new page if doing so is inexpensive.\n  **          (createFlag==1 AND bPurgeable AND pDirty)\n  **    2     Allocate a new page even it doing so is difficult.\n  **          (createFlag==1 AND !(bPurgeable AND pDirty)\n  */\n  eCreate = createFlag & pCache->eCreate;\n  assert( eCreate==0 || eCreate==1 || eCreate==2 );\n  assert( createFlag==0 || pCache->eCreate==eCreate );\n  assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );\n  pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);\n  pcacheTrace((\"%p.FETCH %d%s (result: %p)\\n\",pCache,pgno,\n               createFlag?\" create\":\"\",pRes));\n  return pRes;\n}\n\n/*\n** If the sqlite3PcacheFetch() routine is unable to allocate a new\n** page because no clean pages are available for reuse and the cache\n** size limit has been reached, then this routine can be invoked to \n** try harder to allocate a page.  This routine might invoke the stress\n** callback to spill dirty pages to the journal.  It will then try to\n** allocate the new page and will only fail to allocate a new page on\n** an OOM error.\n**\n** This routine should be invoked only after sqlite3PcacheFetch() fails.\n*/\nSQLITE_PRIVATE int sqlite3PcacheFetchStress(\n  PCache *pCache,                 /* Obtain the page from this cache */\n  Pgno pgno,                      /* Page number to obtain */\n  sqlite3_pcache_page **ppPage    /* Write result here */\n){\n  PgHdr *pPg;\n  if( pCache->eCreate==2 ) return 0;\n\n  if( sqlite3PcachePagecount(pCache)>pCache->szSpill ){\n    /* Find a dirty page to write-out and recycle. First try to find a \n    ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC\n    ** cleared), but if that is not possible settle for any other \n    ** unreferenced dirty page.\n    **\n    ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC\n    ** flag is currently referenced, then the following may leave pSynced\n    ** set incorrectly (pointing to other than the LRU page with NEED_SYNC\n    ** cleared). This is Ok, as pSynced is just an optimization.  */\n    for(pPg=pCache->pSynced; \n        pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); \n        pPg=pPg->pDirtyPrev\n    );\n    pCache->pSynced = pPg;\n    if( !pPg ){\n      for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);\n    }\n    if( pPg ){\n      int rc;\n#ifdef SQLITE_LOG_CACHE_SPILL\n      sqlite3_log(SQLITE_FULL, \n                  \"spill page %d making room for %d - cache used: %d/%d\",\n                  pPg->pgno, pgno,\n                  sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),\n                numberOfCachePages(pCache));\n#endif\n      pcacheTrace((\"%p.SPILL %d\\n\",pCache,pPg->pgno));\n      rc = pCache->xStress(pCache->pStress, pPg);\n      pcacheDump(pCache);\n      if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);\n  return *ppPage==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n}\n\n/*\n** This is a helper routine for sqlite3PcacheFetchFinish()\n**\n** In the uncommon case where the page being fetched has not been\n** initialized, this routine is invoked to do the initialization.\n** This routine is broken out into a separate function since it\n** requires extra stack manipulation that can be avoided in the common\n** case.\n*/\nstatic SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr*)pPage->pExtra;\n  assert( pPgHdr->pPage==0 );\n  memset(&pPgHdr->pDirty, 0, sizeof(PgHdr) - offsetof(PgHdr,pDirty));\n  pPgHdr->pPage = pPage;\n  pPgHdr->pData = pPage->pBuf;\n  pPgHdr->pExtra = (void *)&pPgHdr[1];\n  memset(pPgHdr->pExtra, 0, 8);\n  pPgHdr->pCache = pCache;\n  pPgHdr->pgno = pgno;\n  pPgHdr->flags = PGHDR_CLEAN;\n  return sqlite3PcacheFetchFinish(pCache,pgno,pPage);\n}\n\n/*\n** This routine converts the sqlite3_pcache_page object returned by\n** sqlite3PcacheFetch() into an initialized PgHdr object.  This routine\n** must be called after sqlite3PcacheFetch() in order to get a usable\n** result.\n*/\nSQLITE_PRIVATE PgHdr *sqlite3PcacheFetchFinish(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr *)pPage->pExtra;\n\n  if( !pPgHdr->pPage ){\n    return pcacheFetchFinishWithInit(pCache, pgno, pPage);\n  }\n  pCache->nRefSum++;\n  pPgHdr->nRef++;\n  assert( sqlite3PcachePageSanity(pPgHdr) );\n  return pPgHdr;\n}\n\n/*\n** Decrement the reference count on a page. If the page is clean and the\n** reference count drops to 0, then it is made eligible for recycling.\n*/\nSQLITE_PRIVATE void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){\n  assert( p->nRef>0 );\n  p->pCache->nRefSum--;\n  if( (--p->nRef)==0 ){\n    if( p->flags&PGHDR_CLEAN ){\n      pcacheUnpin(p);\n    }else{\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n    }\n  }\n}\n\n/*\n** Increase the reference count of a supplied page by 1.\n*/\nSQLITE_PRIVATE void sqlite3PcacheRef(PgHdr *p){\n  assert(p->nRef>0);\n  assert( sqlite3PcachePageSanity(p) );\n  p->nRef++;\n  p->pCache->nRefSum++;\n}\n\n/*\n** Drop a page from the cache. There must be exactly one reference to the\n** page. This function deletes that reference, so after it returns the\n** page pointed to by p is invalid.\n*/\nSQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){\n  assert( p->nRef==1 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags&PGHDR_DIRTY ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n  }\n  p->pCache->nRefSum--;\n  sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1);\n}\n\n/*\n** Make sure the page is marked as dirty. If it isn't dirty already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){\n  assert( p->nRef>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){    /*OPTIMIZATION-IF-FALSE*/\n    p->flags &= ~PGHDR_DONT_WRITE;\n    if( p->flags & PGHDR_CLEAN ){\n      p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);\n      pcacheTrace((\"%p.DIRTY %d\\n\",p->pCache,p->pgno));\n      assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);\n    }\n    assert( sqlite3PcachePageSanity(p) );\n  }\n}\n\n/*\n** Make sure the page is marked as clean. If it isn't clean already,\n** make it so.\n*/\nSQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr *p){\n  assert( sqlite3PcachePageSanity(p) );\n  if( ALWAYS((p->flags & PGHDR_DIRTY)!=0) ){\n    assert( (p->flags & PGHDR_CLEAN)==0 );\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n    p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n    p->flags |= PGHDR_CLEAN;\n    pcacheTrace((\"%p.CLEAN %d\\n\",p->pCache,p->pgno));\n    assert( sqlite3PcachePageSanity(p) );\n    if( p->nRef==0 ){\n      pcacheUnpin(p);\n    }\n  }\n}\n\n/*\n** Make every page in the cache clean.\n*/\nSQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAN-ALL\\n\",pCache));\n  while( (p = pCache->pDirty)!=0 ){\n    sqlite3PcacheMakeClean(p);\n  }\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClearWritable(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAR-WRITEABLE\\n\",pCache));\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~(PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC flag from all dirty pages.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~PGHDR_NEED_SYNC;\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Change the page number of page p to newPgno. \n*/\nSQLITE_PRIVATE void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){\n  PCache *pCache = p->pCache;\n  assert( p->nRef>0 );\n  assert( newPgno>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  pcacheTrace((\"%p.MOVE %d -> %d\\n\",pCache,p->pgno,newPgno));\n  sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);\n  p->pgno = newPgno;\n  if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n  }\n}\n\n/*\n** Drop every cache entry whose page number is greater than \"pgno\". The\n** caller must ensure that there are no outstanding references to any pages\n** other than page 1 with a page number greater than pgno.\n**\n** If there is a reference to page 1 and the pgno parameter passed to this\n** function is 0, then the data area associated with page 1 is zeroed, but\n** the page object is not dropped.\n*/\nSQLITE_PRIVATE void sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){\n  if( pCache->pCache ){\n    PgHdr *p;\n    PgHdr *pNext;\n    pcacheTrace((\"%p.TRUNCATE %d\\n\",pCache,pgno));\n    for(p=pCache->pDirty; p; p=pNext){\n      pNext = p->pDirtyNext;\n      /* This routine never gets call with a positive pgno except right\n      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,\n      ** it must be that pgno==0.\n      */\n      assert( p->pgno>0 );\n      if( p->pgno>pgno ){\n        assert( p->flags&PGHDR_DIRTY );\n        sqlite3PcacheMakeClean(p);\n      }\n    }\n    if( pgno==0 && pCache->nRefSum ){\n      sqlite3_pcache_page *pPage1;\n      pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0);\n      if( ALWAYS(pPage1) ){  /* Page 1 is always available in cache, because\n                             ** pCache->nRefSum>0 */\n        memset(pPage1->pBuf, 0, pCache->szPage);\n        pgno = 1;\n      }\n    }\n    sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);\n  }\n}\n\n/*\n** Close a cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClose(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  pcacheTrace((\"%p.CLOSE\\n\",pCache));\n  sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n}\n\n/* \n** Discard the contents of the cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheClear(PCache *pCache){\n  sqlite3PcacheTruncate(pCache, 0);\n}\n\n/*\n** Merge two lists of pages connected by pDirty and in pgno order.\n** Do not bother fixing the pDirtyPrev pointers.\n*/\nstatic PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){\n  PgHdr result, *pTail;\n  pTail = &result;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n      if( pA==0 ){\n        pTail->pDirty = pB;\n        break;\n      }\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n      if( pB==0 ){\n        pTail->pDirty = pA;\n        break;\n      }\n    }\n  }\n  return result.pDirty;\n}\n\n/*\n** Sort the list of pages in accending order by pgno.  Pages are\n** connected by pDirty pointers.  The pDirtyPrev pointers are\n** corrupted by this sort.\n**\n** Since there cannot be more than 2^31 distinct pages in a database,\n** there cannot be more than 31 buckets required by the merge sorter.\n** One extra bucket is added to catch overflow in case something\n** ever changes to make the previous sentence incorrect.\n*/\n#define N_SORT_BUCKET  32\nstatic PgHdr *pcacheSortDirtyList(PgHdr *pIn){\n  PgHdr *a[N_SORT_BUCKET], *p;\n  int i;\n  memset(a, 0, sizeof(a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = pcacheMergeDirtyList(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( NEVER(i==N_SORT_BUCKET-1) ){\n      /* To get here, there need to be 2^(N_SORT_BUCKET) elements in\n      ** the input list.  But that is impossible.\n      */\n      a[i] = pcacheMergeDirtyList(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<N_SORT_BUCKET; i++){\n    if( a[i]==0 ) continue;\n    p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];\n  }\n  return p;\n}\n\n/*\n** Return a list of all dirty pages in the cache, sorted by page number.\n*/\nSQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->pDirty = p->pDirtyNext;\n  }\n  return pcacheSortDirtyList(pCache->pDirty);\n}\n\n/* \n** Return the total number of references to all pages held by the cache.\n**\n** This is not the total number of pages referenced, but the sum of the\n** reference count for all pages.\n*/\nSQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){\n  return pCache->nRefSum;\n}\n\n/*\n** Return the number of references to the page supplied as an argument.\n*/\nSQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr *p){\n  return p->nRef;\n}\n\n/* \n** Return the total number of pages in the cache.\n*/\nSQLITE_PRIVATE int sqlite3PcachePagecount(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);\n}\n\n#ifdef SQLITE_TEST\n/*\n** Get the suggested cache-size value.\n*/\nSQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *pCache){\n  return numberOfCachePages(pCache);\n}\n#endif\n\n/*\n** Set the suggested cache-size value.\n*/\nSQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){\n  assert( pCache->pCache!=0 );\n  pCache->szCache = mxPage;\n  sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,\n                                         numberOfCachePages(pCache));\n}\n\n/*\n** Set the suggested cache-spill value.  Make no changes if if the\n** argument is zero.  Return the effective cache-spill size, which will\n** be the larger of the szSpill and szCache.\n*/\nSQLITE_PRIVATE int sqlite3PcacheSetSpillsize(PCache *p, int mxPage){\n  int res;\n  assert( p->pCache!=0 );\n  if( mxPage ){\n    if( mxPage<0 ){\n      mxPage = (int)((-1024*(i64)mxPage)/(p->szPage+p->szExtra));\n    }\n    p->szSpill = mxPage;\n  }\n  res = numberOfCachePages(p);\n  if( res<p->szSpill ) res = p->szSpill; \n  return res;\n}\n\n/*\n** Free up as much memory as possible from the page cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);\n}\n\n/*\n** Return the size of the header added by this middleware layer\n** in the page-cache hierarchy.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }\n\n/*\n** Return the number of dirty pages currently in the cache, as a percentage\n** of the configured cache size.\n*/\nSQLITE_PRIVATE int sqlite3PCachePercentDirty(PCache *pCache){\n  PgHdr *pDirty;\n  int nDirty = 0;\n  int nCache = numberOfCachePages(pCache);\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++;\n  return nCache ? (int)(((i64)nDirty * 100) / nCache) : 0;\n}\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/*\n** For all dirty pages currently in the cache, invoke the specified\n** callback. This is only used if the SQLITE_CHECK_PAGES macro is\n** defined.\n*/\nSQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){\n  PgHdr *pDirty;\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){\n    xIter(pDirty);\n  }\n}\n#endif\n\n/************** End of pcache.c **********************************************/\n/************** Begin file pcache1.c *****************************************/\n/*\n** 2008 November 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements the default page cache implementation (the\n** sqlite3_pcache interface). It also contains part of the implementation\n** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.\n** If the default page cache implementation is overridden, then neither of\n** these two features are available.\n**\n** A Page cache line looks like this:\n**\n**  -------------------------------------------------------------\n**  |  database page content   |  PgHdr1  |  MemPage  |  PgHdr  |\n**  -------------------------------------------------------------\n**\n** The database page content is up front (so that buffer overreads tend to\n** flow harmlessly into the PgHdr1, MemPage, and PgHdr extensions).   MemPage\n** is the extension added by the btree.c module containing information such\n** as the database page number and how that database page is used.  PgHdr\n** is added by the pcache.c layer and contains information used to keep track\n** of which pages are \"dirty\".  PgHdr1 is an extension added by this\n** module (pcache1.c).  The PgHdr1 header is a subclass of sqlite3_pcache_page.\n** PgHdr1 contains information needed to look up a page by its page number.\n** The superclass sqlite3_pcache_page.pBuf points to the start of the\n** database page content and sqlite3_pcache_page.pExtra points to PgHdr.\n**\n** The size of the extension (MemPage+PgHdr+PgHdr1) can be determined at\n** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size).  The\n** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this\n** size can vary according to architecture, compile-time options, and\n** SQLite library version number.\n**\n** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained\n** using a separate memory allocation from the database page content.  This\n** seeks to overcome the \"clownshoe\" problem (also called \"internal\n** fragmentation\" in academic literature) of allocating a few bytes more\n** than a power of two with the memory allocator rounding up to the next\n** power of two, and leaving the rounded-up space unused.\n**\n** This module tracks pointers to PgHdr1 objects.  Only pcache.c communicates\n** with this module.  Information is passed back and forth as PgHdr1 pointers.\n**\n** The pcache.c and pager.c modules deal pointers to PgHdr objects.\n** The btree.c module deals with pointers to MemPage objects.\n**\n** SOURCE OF PAGE CACHE MEMORY:\n**\n** Memory for a page might come from any of three sources:\n**\n**    (1)  The general-purpose memory allocator - sqlite3Malloc()\n**    (2)  Global page-cache memory provided using sqlite3_config() with\n**         SQLITE_CONFIG_PAGECACHE.\n**    (3)  PCache-local bulk allocation.\n**\n** The third case is a chunk of heap memory (defaulting to 100 pages worth)\n** that is allocated when the page cache is created.  The size of the local\n** bulk allocation can be adjusted using \n**\n**     sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, N).\n**\n** If N is positive, then N pages worth of memory are allocated using a single\n** sqlite3Malloc() call and that memory is used for the first N pages allocated.\n** Or if N is negative, then -1024*N bytes of memory are allocated and used\n** for as many pages as can be accomodated.\n**\n** Only one of (2) or (3) can be used.  Once the memory available to (2) or\n** (3) is exhausted, subsequent allocations fail over to the general-purpose\n** memory allocator (1).\n**\n** Earlier versions of SQLite used only methods (1) and (2).  But experiments\n** show that method (3) with N==100 provides about a 5% performance boost for\n** common workloads.\n*/\n/* #include \"sqliteInt.h\" */\n\ntypedef struct PCache1 PCache1;\ntypedef struct PgHdr1 PgHdr1;\ntypedef struct PgFreeslot PgFreeslot;\ntypedef struct PGroup PGroup;\n\n/*\n** Each cache entry is represented by an instance of the following \n** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of\n** PgHdr1.pCache->szPage bytes is allocated directly before this structure \n** in memory.\n*/\nstruct PgHdr1 {\n  sqlite3_pcache_page page;      /* Base class. Must be first. pBuf & pExtra */\n  unsigned int iKey;             /* Key value (page number) */\n  u8 isBulkLocal;                /* This page from bulk local storage */\n  u8 isAnchor;                   /* This is the PGroup.lru element */\n  PgHdr1 *pNext;                 /* Next in hash table chain */\n  PCache1 *pCache;               /* Cache that currently owns this page */\n  PgHdr1 *pLruNext;              /* Next in LRU list of unpinned pages */\n  PgHdr1 *pLruPrev;              /* Previous in LRU list of unpinned pages */\n};\n\n/*\n** A page is pinned if it is no on the LRU list\n*/\n#define PAGE_IS_PINNED(p)    ((p)->pLruNext==0)\n#define PAGE_IS_UNPINNED(p)  ((p)->pLruNext!=0)\n\n/* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set \n** of one or more PCaches that are able to recycle each other's unpinned\n** pages when they are under memory pressure.  A PGroup is an instance of\n** the following object.\n**\n** This page cache implementation works in one of two modes:\n**\n**   (1)  Every PCache is the sole member of its own PGroup.  There is\n**        one PGroup per PCache.\n**\n**   (2)  There is a single global PGroup that all PCaches are a member\n**        of.\n**\n** Mode 1 uses more memory (since PCache instances are not able to rob\n** unused pages from other PCaches) but it also operates without a mutex,\n** and is therefore often faster.  Mode 2 requires a mutex in order to be\n** threadsafe, but recycles pages more efficiently.\n**\n** For mode (1), PGroup.mutex is NULL.  For mode (2) there is only a single\n** PGroup which is the pcache1.grp global variable and its mutex is\n** SQLITE_MUTEX_STATIC_LRU.\n*/\nstruct PGroup {\n  sqlite3_mutex *mutex;          /* MUTEX_STATIC_LRU or NULL */\n  unsigned int nMaxPage;         /* Sum of nMax for purgeable caches */\n  unsigned int nMinPage;         /* Sum of nMin for purgeable caches */\n  unsigned int mxPinned;         /* nMaxpage + 10 - nMinPage */\n  unsigned int nPurgeable;       /* Number of purgeable pages allocated */\n  PgHdr1 lru;                    /* The beginning and end of the LRU list */\n};\n\n/* Each page cache is an instance of the following object.  Every\n** open database file (including each in-memory database and each\n** temporary or transient database) has a single page cache which\n** is an instance of this object.\n**\n** Pointers to structures of this type are cast and returned as \n** opaque sqlite3_pcache* handles.\n*/\nstruct PCache1 {\n  /* Cache configuration parameters. Page size (szPage) and the purgeable\n  ** flag (bPurgeable) and the pnPurgeable pointer are all set when the\n  ** cache is created and are never changed thereafter. nMax may be \n  ** modified at any time by a call to the pcache1Cachesize() method.\n  ** The PGroup mutex must be held when accessing nMax.\n  */\n  PGroup *pGroup;                     /* PGroup this cache belongs to */\n  unsigned int *pnPurgeable;          /* Pointer to pGroup->nPurgeable */\n  int szPage;                         /* Size of database content section */\n  int szExtra;                        /* sizeof(MemPage)+sizeof(PgHdr) */\n  int szAlloc;                        /* Total size of one pcache line */\n  int bPurgeable;                     /* True if cache is purgeable */\n  unsigned int nMin;                  /* Minimum number of pages reserved */\n  unsigned int nMax;                  /* Configured \"cache_size\" value */\n  unsigned int n90pct;                /* nMax*9/10 */\n  unsigned int iMaxKey;               /* Largest key seen since xTruncate() */\n\n  /* Hash table of all pages. The following variables may only be accessed\n  ** when the accessor is holding the PGroup mutex.\n  */\n  unsigned int nRecyclable;           /* Number of pages in the LRU list */\n  unsigned int nPage;                 /* Total number of pages in apHash */\n  unsigned int nHash;                 /* Number of slots in apHash[] */\n  PgHdr1 **apHash;                    /* Hash table for fast lookup by key */\n  PgHdr1 *pFree;                      /* List of unused pcache-local pages */\n  void *pBulk;                        /* Bulk memory used by pcache-local */\n};\n\n/*\n** Free slots in the allocator used to divide up the global page cache\n** buffer provided using the SQLITE_CONFIG_PAGECACHE mechanism.\n*/\nstruct PgFreeslot {\n  PgFreeslot *pNext;  /* Next free slot */\n};\n\n/*\n** Global data used by this cache.\n*/\nstatic SQLITE_WSD struct PCacheGlobal {\n  PGroup grp;                    /* The global PGroup for mode (2) */\n\n  /* Variables related to SQLITE_CONFIG_PAGECACHE settings.  The\n  ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all\n  ** fixed at sqlite3_initialize() time and do not require mutex protection.\n  ** The nFreeSlot and pFree values do require mutex protection.\n  */\n  int isInit;                    /* True if initialized */\n  int separateCache;             /* Use a new PGroup for each PCache */\n  int nInitPage;                 /* Initial bulk allocation size */   \n  int szSlot;                    /* Size of each free slot */\n  int nSlot;                     /* The number of pcache slots */\n  int nReserve;                  /* Try to keep nFreeSlot above this */\n  void *pStart, *pEnd;           /* Bounds of global page cache memory */\n  /* Above requires no mutex.  Use mutex below for variable that follow. */\n  sqlite3_mutex *mutex;          /* Mutex for accessing the following: */\n  PgFreeslot *pFree;             /* Free page blocks */\n  int nFreeSlot;                 /* Number of unused pcache slots */\n  /* The following value requires a mutex to change.  We skip the mutex on\n  ** reading because (1) most platforms read a 32-bit integer atomically and\n  ** (2) even if an incorrect value is read, no great harm is done since this\n  ** is really just an optimization. */\n  int bUnderPressure;            /* True if low on PAGECACHE memory */\n} pcache1_g;\n\n/*\n** All code in this file should access the global structure above via the\n** alias \"pcache1\". This ensures that the WSD emulation is used when\n** compiling for systems that do not support real WSD.\n*/\n#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g))\n\n/*\n** Macros to enter and leave the PCache LRU mutex.\n*/\n#if !defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0\n# define pcache1EnterMutex(X)  assert((X)->mutex==0)\n# define pcache1LeaveMutex(X)  assert((X)->mutex==0)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 0\n#else\n# define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)\n# define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 1\n#endif\n\n/******************************************************************************/\n/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/\n\n\n/*\n** This function is called during initialization if a static buffer is \n** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE\n** verb to sqlite3_config(). Parameter pBuf points to an allocation large\n** enough to contain 'n' buffers of 'sz' bytes each.\n**\n** This routine is called from sqlite3_initialize() and so it is guaranteed\n** to be serialized already.  There is no need for further mutexing.\n*/\nSQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){\n  if( pcache1.isInit ){\n    PgFreeslot *p;\n    if( pBuf==0 ) sz = n = 0;\n    if( n==0 ) sz = 0;\n    sz = ROUNDDOWN8(sz);\n    pcache1.szSlot = sz;\n    pcache1.nSlot = pcache1.nFreeSlot = n;\n    pcache1.nReserve = n>90 ? 10 : (n/10 + 1);\n    pcache1.pStart = pBuf;\n    pcache1.pFree = 0;\n    pcache1.bUnderPressure = 0;\n    while( n-- ){\n      p = (PgFreeslot*)pBuf;\n      p->pNext = pcache1.pFree;\n      pcache1.pFree = p;\n      pBuf = (void*)&((char*)pBuf)[sz];\n    }\n    pcache1.pEnd = pBuf;\n  }\n}\n\n/*\n** Try to initialize the pCache->pFree and pCache->pBulk fields.  Return\n** true if pCache->pFree ends up containing one or more free pages.\n*/\nstatic int pcache1InitBulk(PCache1 *pCache){\n  i64 szBulk;\n  char *zBulk;\n  if( pcache1.nInitPage==0 ) return 0;\n  /* Do not bother with a bulk allocation if the cache size very small */\n  if( pCache->nMax<3 ) return 0;\n  sqlite3BeginBenignMalloc();\n  if( pcache1.nInitPage>0 ){\n    szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;\n  }else{\n    szBulk = -1024 * (i64)pcache1.nInitPage;\n  }\n  if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){\n    szBulk = pCache->szAlloc*(i64)pCache->nMax;\n  }\n  zBulk = pCache->pBulk = sqlite3Malloc( szBulk );\n  sqlite3EndBenignMalloc();\n  if( zBulk ){\n    int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;\n    do{\n      PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];\n      pX->page.pBuf = zBulk;\n      pX->page.pExtra = &pX[1];\n      pX->isBulkLocal = 1;\n      pX->isAnchor = 0;\n      pX->pNext = pCache->pFree;\n      pCache->pFree = pX;\n      zBulk += pCache->szAlloc;\n    }while( --nBulk );\n  }\n  return pCache->pFree!=0;\n}\n\n/*\n** Malloc function used within this file to allocate space from the buffer\n** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no \n** such buffer exists or there is no space left in it, this function falls \n** back to sqlite3Malloc().\n**\n** Multiple threads can run this routine at the same time.  Global variables\n** in pcache1 need to be protected via mutex.\n*/\nstatic void *pcache1Alloc(int nByte){\n  void *p = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  if( nByte<=pcache1.szSlot ){\n    sqlite3_mutex_enter(pcache1.mutex);\n    p = (PgHdr1 *)pcache1.pFree;\n    if( p ){\n      pcache1.pFree = pcache1.pFree->pNext;\n      pcache1.nFreeSlot--;\n      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n      assert( pcache1.nFreeSlot>=0 );\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);\n    }\n    sqlite3_mutex_leave(pcache1.mutex);\n  }\n  if( p==0 ){\n    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get\n    ** it from sqlite3Malloc instead.\n    */\n    p = sqlite3Malloc(nByte);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    if( p ){\n      int sz = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n  }\n  return p;\n}\n\n/*\n** Free an allocated buffer obtained from pcache1Alloc().\n*/\nstatic void pcache1Free(void *p){\n  if( p==0 ) return;\n  if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){\n    PgFreeslot *pSlot;\n    sqlite3_mutex_enter(pcache1.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);\n    pSlot = (PgFreeslot*)p;\n    pSlot->pNext = pcache1.pFree;\n    pcache1.pFree = pSlot;\n    pcache1.nFreeSlot++;\n    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n    assert( pcache1.nFreeSlot<=pcache1.nSlot );\n    sqlite3_mutex_leave(pcache1.mutex);\n  }else{\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    {\n      int nFreed = 0;\n      nFreed = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3_free(p);\n  }\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** Return the size of a pcache allocation\n*/\nstatic int pcache1MemSize(void *p){\n  if( p>=pcache1.pStart && p<pcache1.pEnd ){\n    return pcache1.szSlot;\n  }else{\n    int iSize;\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n    iSize = sqlite3MallocSize(p);\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n    return iSize;\n  }\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n/*\n** Allocate a new page object initially associated with cache pCache.\n*/\nstatic PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){\n  PgHdr1 *p = 0;\n  void *pPg;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){\n    p = pCache->pFree;\n    pCache->pFree = p->pNext;\n    p->pNext = 0;\n  }else{\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    /* The group mutex must be released before pcache1Alloc() is called. This\n    ** is because it might call sqlite3_release_memory(), which assumes that \n    ** this mutex is not held. */\n    assert( pcache1.separateCache==0 );\n    assert( pCache->pGroup==&pcache1.grp );\n    pcache1LeaveMutex(pCache->pGroup);\n#endif\n    if( benignMalloc ){ sqlite3BeginBenignMalloc(); }\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    pPg = pcache1Alloc(pCache->szPage);\n    p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);\n    if( !pPg || !p ){\n      pcache1Free(pPg);\n      sqlite3_free(p);\n      pPg = 0;\n    }\n#else\n    pPg = pcache1Alloc(pCache->szAlloc);\n    p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];\n#endif\n    if( benignMalloc ){ sqlite3EndBenignMalloc(); }\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    pcache1EnterMutex(pCache->pGroup);\n#endif\n    if( pPg==0 ) return 0;\n    p->page.pBuf = pPg;\n    p->page.pExtra = &p[1];\n    p->isBulkLocal = 0;\n    p->isAnchor = 0;\n  }\n  (*pCache->pnPurgeable)++;\n  return p;\n}\n\n/*\n** Free a page object allocated by pcache1AllocPage().\n*/\nstatic void pcache1FreePage(PgHdr1 *p){\n  PCache1 *pCache;\n  assert( p!=0 );\n  pCache = p->pCache;\n  assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );\n  if( p->isBulkLocal ){\n    p->pNext = pCache->pFree;\n    pCache->pFree = p;\n  }else{\n    pcache1Free(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    sqlite3_free(p);\n#endif\n  }\n  (*pCache->pnPurgeable)--;\n}\n\n/*\n** Malloc function used by SQLite to obtain space from the buffer configured\n** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer\n** exists, this function falls back to sqlite3Malloc().\n*/\nSQLITE_PRIVATE void *sqlite3PageMalloc(int sz){\n  return pcache1Alloc(sz);\n}\n\n/*\n** Free an allocated buffer obtained from sqlite3PageMalloc().\n*/\nSQLITE_PRIVATE void sqlite3PageFree(void *p){\n  pcache1Free(p);\n}\n\n\n/*\n** Return true if it desirable to avoid allocating a new page cache\n** entry.\n**\n** If memory was allocated specifically to the page cache using\n** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then\n** it is desirable to avoid allocating a new page cache entry because\n** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient\n** for all page cache needs and we should not need to spill the\n** allocation onto the heap.\n**\n** Or, the heap is used for all page cache memory but the heap is\n** under memory pressure, then again it is desirable to avoid\n** allocating a new page cache entry in order to avoid stressing\n** the heap even further.\n*/\nstatic int pcache1UnderMemoryPressure(PCache1 *pCache){\n  if( pcache1.nSlot && (pCache->szPage+pCache->szExtra)<=pcache1.szSlot ){\n    return pcache1.bUnderPressure;\n  }else{\n    return sqlite3HeapNearlyFull();\n  }\n}\n\n/******************************************************************************/\n/******** General Implementation Functions ************************************/\n\n/*\n** This function is used to resize the hash table used by the cache passed\n** as the first argument.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1ResizeHash(PCache1 *p){\n  PgHdr1 **apNew;\n  unsigned int nNew;\n  unsigned int i;\n\n  assert( sqlite3_mutex_held(p->pGroup->mutex) );\n\n  nNew = p->nHash*2;\n  if( nNew<256 ){\n    nNew = 256;\n  }\n\n  pcache1LeaveMutex(p->pGroup);\n  if( p->nHash ){ sqlite3BeginBenignMalloc(); }\n  apNew = (PgHdr1 **)sqlite3MallocZero(sizeof(PgHdr1 *)*nNew);\n  if( p->nHash ){ sqlite3EndBenignMalloc(); }\n  pcache1EnterMutex(p->pGroup);\n  if( apNew ){\n    for(i=0; i<p->nHash; i++){\n      PgHdr1 *pPage;\n      PgHdr1 *pNext = p->apHash[i];\n      while( (pPage = pNext)!=0 ){\n        unsigned int h = pPage->iKey % nNew;\n        pNext = pPage->pNext;\n        pPage->pNext = apNew[h];\n        apNew[h] = pPage;\n      }\n    }\n    sqlite3_free(p->apHash);\n    p->apHash = apNew;\n    p->nHash = nNew;\n  }\n}\n\n/*\n** This function is used internally to remove the page pPage from the \n** PGroup LRU list, if is part of it. If pPage is not part of the PGroup\n** LRU list, then this function is a no-op.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic PgHdr1 *pcache1PinPage(PgHdr1 *pPage){\n  assert( pPage!=0 );\n  assert( PAGE_IS_UNPINNED(pPage) );\n  assert( pPage->pLruNext );\n  assert( pPage->pLruPrev );\n  assert( sqlite3_mutex_held(pPage->pCache->pGroup->mutex) );\n  pPage->pLruPrev->pLruNext = pPage->pLruNext;\n  pPage->pLruNext->pLruPrev = pPage->pLruPrev;\n  pPage->pLruNext = 0;\n  pPage->pLruPrev = 0;\n  assert( pPage->isAnchor==0 );\n  assert( pPage->pCache->pGroup->lru.isAnchor==1 );\n  pPage->pCache->nRecyclable--;\n  return pPage;\n}\n\n\n/*\n** Remove the page supplied as an argument from the hash table \n** (PCache1.apHash structure) that it is currently stored in.\n** Also free the page if freePage is true.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic void pcache1RemoveFromHash(PgHdr1 *pPage, int freeFlag){\n  unsigned int h;\n  PCache1 *pCache = pPage->pCache;\n  PgHdr1 **pp;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  h = pPage->iKey % pCache->nHash;\n  for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);\n  *pp = (*pp)->pNext;\n\n  pCache->nPage--;\n  if( freeFlag ) pcache1FreePage(pPage);\n}\n\n/*\n** If there are currently more than nMaxPage pages allocated, try\n** to recycle pages to reduce the number allocated to nMaxPage.\n*/\nstatic void pcache1EnforceMaxPage(PCache1 *pCache){\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *p;\n  assert( sqlite3_mutex_held(pGroup->mutex) );\n  while( pGroup->nPurgeable>pGroup->nMaxPage\n      && (p=pGroup->lru.pLruPrev)->isAnchor==0\n  ){\n    assert( p->pCache->pGroup==pGroup );\n    assert( PAGE_IS_UNPINNED(p) );\n    pcache1PinPage(p);\n    pcache1RemoveFromHash(p, 1);\n  }\n  if( pCache->nPage==0 && pCache->pBulk ){\n    sqlite3_free(pCache->pBulk);\n    pCache->pBulk = pCache->pFree = 0;\n  }\n}\n\n/*\n** Discard all pages from cache pCache with a page number (key value) \n** greater than or equal to iLimit. Any pinned pages that meet this \n** criteria are unpinned before they are discarded.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1TruncateUnsafe(\n  PCache1 *pCache,             /* The cache to truncate */\n  unsigned int iLimit          /* Drop pages with this pgno or larger */\n){\n  TESTONLY( int nPage = 0; )  /* To assert pCache->nPage is correct */\n  unsigned int h, iStop;\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  assert( pCache->iMaxKey >= iLimit );\n  assert( pCache->nHash > 0 );\n  if( pCache->iMaxKey - iLimit < pCache->nHash ){\n    /* If we are just shaving the last few pages off the end of the\n    ** cache, then there is no point in scanning the entire hash table.\n    ** Only scan those hash slots that might contain pages that need to\n    ** be removed. */\n    h = iLimit % pCache->nHash;\n    iStop = pCache->iMaxKey % pCache->nHash;\n    TESTONLY( nPage = -10; )  /* Disable the pCache->nPage validity check */\n  }else{\n    /* This is the general case where many pages are being removed.\n    ** It is necessary to scan the entire hash table */\n    h = pCache->nHash/2;\n    iStop = h - 1;\n  }\n  for(;;){\n    PgHdr1 **pp;\n    PgHdr1 *pPage;\n    assert( h<pCache->nHash );\n    pp = &pCache->apHash[h]; \n    while( (pPage = *pp)!=0 ){\n      if( pPage->iKey>=iLimit ){\n        pCache->nPage--;\n        *pp = pPage->pNext;\n        if( PAGE_IS_UNPINNED(pPage) ) pcache1PinPage(pPage);\n        pcache1FreePage(pPage);\n      }else{\n        pp = &pPage->pNext;\n        TESTONLY( if( nPage>=0 ) nPage++; )\n      }\n    }\n    if( h==iStop ) break;\n    h = (h+1) % pCache->nHash;\n  }\n  assert( nPage<0 || pCache->nPage==(unsigned)nPage );\n}\n\n/******************************************************************************/\n/******** sqlite3_pcache Methods **********************************************/\n\n/*\n** Implementation of the sqlite3_pcache.xInit method.\n*/\nstatic int pcache1Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit==0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n\n\n  /*\n  ** The pcache1.separateCache variable is true if each PCache has its own\n  ** private PGroup (mode-1).  pcache1.separateCache is false if the single\n  ** PGroup in pcache1.grp is used for all page caches (mode-2).\n  **\n  **   *  Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT\n  **\n  **   *  Use a unified cache in single-threaded applications that have\n  **      configured a start-time buffer for use as page-cache memory using\n  **      sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL \n  **      pBuf argument.\n  **\n  **   *  Otherwise use separate caches (mode-1)\n  */\n#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)\n  pcache1.separateCache = 0;\n#elif SQLITE_THREADSAFE\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0\n                          || sqlite3GlobalConfig.bCoreMutex>0;\n#else\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0;\n#endif\n\n#if SQLITE_THREADSAFE\n  if( sqlite3GlobalConfig.bCoreMutex ){\n    pcache1.grp.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU);\n    pcache1.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PMEM);\n  }\n#endif\n  if( pcache1.separateCache\n   && sqlite3GlobalConfig.nPage!=0\n   && sqlite3GlobalConfig.pPage==0\n  ){\n    pcache1.nInitPage = sqlite3GlobalConfig.nPage;\n  }else{\n    pcache1.nInitPage = 0;\n  }\n  pcache1.grp.mxPinned = 10;\n  pcache1.isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShutdown method.\n** Note that the static mutex allocated in xInit does \n** not need to be freed.\n*/\nstatic void pcache1Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit!=0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n}\n\n/* forward declaration */\nstatic void pcache1Destroy(sqlite3_pcache *p);\n\n/*\n** Implementation of the sqlite3_pcache.xCreate method.\n**\n** Allocate a new cache.\n*/\nstatic sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){\n  PCache1 *pCache;      /* The newly created page cache */\n  PGroup *pGroup;       /* The group the new page cache will belong to */\n  int sz;               /* Bytes of memory required to allocate the new cache */\n\n  assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );\n  assert( szExtra < 300 );\n\n  sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;\n  pCache = (PCache1 *)sqlite3MallocZero(sz);\n  if( pCache ){\n    if( pcache1.separateCache ){\n      pGroup = (PGroup*)&pCache[1];\n      pGroup->mxPinned = 10;\n    }else{\n      pGroup = &pcache1.grp;\n    }\n    if( pGroup->lru.isAnchor==0 ){\n      pGroup->lru.isAnchor = 1;\n      pGroup->lru.pLruPrev = pGroup->lru.pLruNext = &pGroup->lru;\n    }\n    pCache->pGroup = pGroup;\n    pCache->szPage = szPage;\n    pCache->szExtra = szExtra;\n    pCache->szAlloc = szPage + szExtra + ROUND8(sizeof(PgHdr1));\n    pCache->bPurgeable = (bPurgeable ? 1 : 0);\n    pcache1EnterMutex(pGroup);\n    pcache1ResizeHash(pCache);\n    if( bPurgeable ){\n      pCache->nMin = 10;\n      pGroup->nMinPage += pCache->nMin;\n      pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n      pCache->pnPurgeable = &pGroup->nPurgeable;\n    }else{\n      static unsigned int dummyCurrentPage;\n      pCache->pnPurgeable = &dummyCurrentPage;\n    }\n    pcache1LeaveMutex(pGroup);\n    if( pCache->nHash==0 ){\n      pcache1Destroy((sqlite3_pcache*)pCache);\n      pCache = 0;\n    }\n  }\n  return (sqlite3_pcache *)pCache;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xCachesize method. \n**\n** Configure the cache_size limit for a cache.\n*/\nstatic void pcache1Cachesize(sqlite3_pcache *p, int nMax){\n  PCache1 *pCache = (PCache1 *)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    pcache1EnterMutex(pGroup);\n    pGroup->nMaxPage += (nMax - pCache->nMax);\n    pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n    pCache->nMax = nMax;\n    pCache->n90pct = pCache->nMax*9/10;\n    pcache1EnforceMaxPage(pCache);\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShrink method. \n**\n** Free up as much memory as possible.\n*/\nstatic void pcache1Shrink(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1*)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    int savedMaxPage;\n    pcache1EnterMutex(pGroup);\n    savedMaxPage = pGroup->nMaxPage;\n    pGroup->nMaxPage = 0;\n    pcache1EnforceMaxPage(pCache);\n    pGroup->nMaxPage = savedMaxPage;\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xPagecount method. \n*/\nstatic int pcache1Pagecount(sqlite3_pcache *p){\n  int n;\n  PCache1 *pCache = (PCache1*)p;\n  pcache1EnterMutex(pCache->pGroup);\n  n = pCache->nPage;\n  pcache1LeaveMutex(pCache->pGroup);\n  return n;\n}\n\n\n/*\n** Implement steps 3, 4, and 5 of the pcache1Fetch() algorithm described\n** in the header of the pcache1Fetch() procedure.\n**\n** This steps are broken out into a separate procedure because they are\n** usually not needed, and by avoiding the stack initialization required\n** for these steps, the main pcache1Fetch() procedure can run faster.\n*/\nstatic SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(\n  PCache1 *pCache, \n  unsigned int iKey, \n  int createFlag\n){\n  unsigned int nPinned;\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *pPage = 0;\n\n  /* Step 3: Abort if createFlag is 1 but the cache is nearly full */\n  assert( pCache->nPage >= pCache->nRecyclable );\n  nPinned = pCache->nPage - pCache->nRecyclable;\n  assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );\n  assert( pCache->n90pct == pCache->nMax*9/10 );\n  if( createFlag==1 && (\n        nPinned>=pGroup->mxPinned\n     || nPinned>=pCache->n90pct\n     || (pcache1UnderMemoryPressure(pCache) && pCache->nRecyclable<nPinned)\n  )){\n    return 0;\n  }\n\n  if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache);\n  assert( pCache->nHash>0 && pCache->apHash );\n\n  /* Step 4. Try to recycle a page. */\n  if( pCache->bPurgeable\n   && !pGroup->lru.pLruPrev->isAnchor\n   && ((pCache->nPage+1>=pCache->nMax) || pcache1UnderMemoryPressure(pCache))\n  ){\n    PCache1 *pOther;\n    pPage = pGroup->lru.pLruPrev;\n    assert( PAGE_IS_UNPINNED(pPage) );\n    pcache1RemoveFromHash(pPage, 0);\n    pcache1PinPage(pPage);\n    pOther = pPage->pCache;\n    if( pOther->szAlloc != pCache->szAlloc ){\n      pcache1FreePage(pPage);\n      pPage = 0;\n    }else{\n      pGroup->nPurgeable -= (pOther->bPurgeable - pCache->bPurgeable);\n    }\n  }\n\n  /* Step 5. If a usable page buffer has still not been found, \n  ** attempt to allocate a new one. \n  */\n  if( !pPage ){\n    pPage = pcache1AllocPage(pCache, createFlag==1);\n  }\n\n  if( pPage ){\n    unsigned int h = iKey % pCache->nHash;\n    pCache->nPage++;\n    pPage->iKey = iKey;\n    pPage->pNext = pCache->apHash[h];\n    pPage->pCache = pCache;\n    pPage->pLruPrev = 0;\n    pPage->pLruNext = 0;\n    *(void **)pPage->page.pExtra = 0;\n    pCache->apHash[h] = pPage;\n    if( iKey>pCache->iMaxKey ){\n      pCache->iMaxKey = iKey;\n    }\n  }\n  return pPage;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xFetch method. \n**\n** Fetch a page by key value.\n**\n** Whether or not a new page may be allocated by this function depends on\n** the value of the createFlag argument.  0 means do not allocate a new\n** page.  1 means allocate a new page if space is easily available.  2 \n** means to try really hard to allocate a new page.\n**\n** For a non-purgeable cache (a cache used as the storage for an in-memory\n** database) there is really no difference between createFlag 1 and 2.  So\n** the calling function (pcache.c) will never have a createFlag of 1 on\n** a non-purgeable cache.\n**\n** There are three different approaches to obtaining space for a page,\n** depending on the value of parameter createFlag (which may be 0, 1 or 2).\n**\n**   1. Regardless of the value of createFlag, the cache is searched for a \n**      copy of the requested page. If one is found, it is returned.\n**\n**   2. If createFlag==0 and the page is not already in the cache, NULL is\n**      returned.\n**\n**   3. If createFlag is 1, and the page is not already in the cache, then\n**      return NULL (do not allocate a new page) if any of the following\n**      conditions are true:\n**\n**       (a) the number of pages pinned by the cache is greater than\n**           PCache1.nMax, or\n**\n**       (b) the number of pages pinned by the cache is greater than\n**           the sum of nMax for all purgeable caches, less the sum of \n**           nMin for all other purgeable caches, or\n**\n**   4. If none of the first three conditions apply and the cache is marked\n**      as purgeable, and if one of the following is true:\n**\n**       (a) The number of pages allocated for the cache is already \n**           PCache1.nMax, or\n**\n**       (b) The number of pages allocated for all purgeable caches is\n**           already equal to or greater than the sum of nMax for all\n**           purgeable caches,\n**\n**       (c) The system is under memory pressure and wants to avoid\n**           unnecessary pages cache entry allocations\n**\n**      then attempt to recycle a page from the LRU list. If it is the right\n**      size, return the recycled buffer. Otherwise, free the buffer and\n**      proceed to step 5. \n**\n**   5. Otherwise, allocate and return a new page buffer.\n**\n** There are two versions of this routine.  pcache1FetchWithMutex() is\n** the general case.  pcache1FetchNoMutex() is a faster implementation for\n** the common case where pGroup->mutex is NULL.  The pcache1Fetch() wrapper\n** invokes the appropriate routine.\n*/\nstatic PgHdr1 *pcache1FetchNoMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = 0;\n\n  /* Step 1: Search the hash table for an existing entry. */\n  pPage = pCache->apHash[iKey % pCache->nHash];\n  while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; }\n\n  /* Step 2: If the page was found in the hash table, then return it.\n  ** If the page was not in the hash table and createFlag is 0, abort.\n  ** Otherwise (page not in hash and createFlag!=0) continue with\n  ** subsequent steps to try to create the page. */\n  if( pPage ){\n    if( PAGE_IS_UNPINNED(pPage) ){\n      return pcache1PinPage(pPage);\n    }else{\n      return pPage;\n    }\n  }else if( createFlag ){\n    /* Steps 3, 4, and 5 implemented by this subroutine */\n    return pcache1FetchStage2(pCache, iKey, createFlag);\n  }else{\n    return 0;\n  }\n}\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\nstatic PgHdr1 *pcache1FetchWithMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage;\n\n  pcache1EnterMutex(pCache->pGroup);\n  pPage = pcache1FetchNoMutex(p, iKey, createFlag);\n  assert( pPage==0 || pCache->iMaxKey>=iKey );\n  pcache1LeaveMutex(pCache->pGroup);\n  return pPage;\n}\n#endif\nstatic sqlite3_pcache_page *pcache1Fetch(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX || defined(SQLITE_DEBUG)\n  PCache1 *pCache = (PCache1 *)p;\n#endif\n\n  assert( offsetof(PgHdr1,page)==0 );\n  assert( pCache->bPurgeable || createFlag!=1 );\n  assert( pCache->bPurgeable || pCache->nMin==0 );\n  assert( pCache->bPurgeable==0 || pCache->nMin==10 );\n  assert( pCache->nMin==0 || pCache->bPurgeable );\n  assert( pCache->nHash>0 );\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\n  if( pCache->pGroup->mutex ){\n    return (sqlite3_pcache_page*)pcache1FetchWithMutex(p, iKey, createFlag);\n  }else\n#endif\n  {\n    return (sqlite3_pcache_page*)pcache1FetchNoMutex(p, iKey, createFlag);\n  }\n}\n\n\n/*\n** Implementation of the sqlite3_pcache.xUnpin method.\n**\n** Mark a page as unpinned (eligible for asynchronous recycling).\n*/\nstatic void pcache1Unpin(\n  sqlite3_pcache *p, \n  sqlite3_pcache_page *pPg, \n  int reuseUnlikely\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PGroup *pGroup = pCache->pGroup;\n \n  assert( pPage->pCache==pCache );\n  pcache1EnterMutex(pGroup);\n\n  /* It is an error to call this function if the page is already \n  ** part of the PGroup LRU list.\n  */\n  assert( pPage->pLruPrev==0 && pPage->pLruNext==0 );\n  assert( PAGE_IS_PINNED(pPage) );\n\n  if( reuseUnlikely || pGroup->nPurgeable>pGroup->nMaxPage ){\n    pcache1RemoveFromHash(pPage, 1);\n  }else{\n    /* Add the page to the PGroup LRU list. */\n    PgHdr1 **ppFirst = &pGroup->lru.pLruNext;\n    pPage->pLruPrev = &pGroup->lru;\n    (pPage->pLruNext = *ppFirst)->pLruPrev = pPage;\n    *ppFirst = pPage;\n    pCache->nRecyclable++;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xRekey method. \n*/\nstatic void pcache1Rekey(\n  sqlite3_pcache *p,\n  sqlite3_pcache_page *pPg,\n  unsigned int iOld,\n  unsigned int iNew\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PgHdr1 **pp;\n  unsigned int h; \n  assert( pPage->iKey==iOld );\n  assert( pPage->pCache==pCache );\n\n  pcache1EnterMutex(pCache->pGroup);\n\n  h = iOld%pCache->nHash;\n  pp = &pCache->apHash[h];\n  while( (*pp)!=pPage ){\n    pp = &(*pp)->pNext;\n  }\n  *pp = pPage->pNext;\n\n  h = iNew%pCache->nHash;\n  pPage->iKey = iNew;\n  pPage->pNext = pCache->apHash[h];\n  pCache->apHash[h] = pPage;\n  if( iNew>pCache->iMaxKey ){\n    pCache->iMaxKey = iNew;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xTruncate method. \n**\n** Discard all unpinned pages in the cache with a page number equal to\n** or greater than parameter iLimit. Any pinned pages with a page number\n** equal to or greater than iLimit are implicitly unpinned.\n*/\nstatic void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){\n  PCache1 *pCache = (PCache1 *)p;\n  pcache1EnterMutex(pCache->pGroup);\n  if( iLimit<=pCache->iMaxKey ){\n    pcache1TruncateUnsafe(pCache, iLimit);\n    pCache->iMaxKey = iLimit-1;\n  }\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xDestroy method. \n**\n** Destroy a cache allocated using pcache1Create().\n*/\nstatic void pcache1Destroy(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1 *)p;\n  PGroup *pGroup = pCache->pGroup;\n  assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );\n  pcache1EnterMutex(pGroup);\n  if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);\n  assert( pGroup->nMaxPage >= pCache->nMax );\n  pGroup->nMaxPage -= pCache->nMax;\n  assert( pGroup->nMinPage >= pCache->nMin );\n  pGroup->nMinPage -= pCache->nMin;\n  pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n  pcache1EnforceMaxPage(pCache);\n  pcache1LeaveMutex(pGroup);\n  sqlite3_free(pCache->pBulk);\n  sqlite3_free(pCache->apHash);\n  sqlite3_free(pCache);\n}\n\n/*\n** This function is called during initialization (sqlite3_initialize()) to\n** install the default pluggable cache module, assuming the user has not\n** already provided an alternative.\n*/\nSQLITE_PRIVATE void sqlite3PCacheSetDefault(void){\n  static const sqlite3_pcache_methods2 defaultMethods = {\n    1,                       /* iVersion */\n    0,                       /* pArg */\n    pcache1Init,             /* xInit */\n    pcache1Shutdown,         /* xShutdown */\n    pcache1Create,           /* xCreate */\n    pcache1Cachesize,        /* xCachesize */\n    pcache1Pagecount,        /* xPagecount */\n    pcache1Fetch,            /* xFetch */\n    pcache1Unpin,            /* xUnpin */\n    pcache1Rekey,            /* xRekey */\n    pcache1Truncate,         /* xTruncate */\n    pcache1Destroy,          /* xDestroy */\n    pcache1Shrink            /* xShrink */\n  };\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);\n}\n\n/*\n** Return the size of the header on each page of this PCACHE implementation.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }\n\n/*\n** Return the global mutex used by this PCACHE implementation.  The\n** sqlite3_status() routine needs access to this mutex.\n*/\nSQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){\n  return pcache1.mutex;\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** This function is called to free superfluous dynamically allocated memory\n** held by the pager system. Memory in use by any SQLite pager allocated\n** by the current thread may be sqlite3_free()ed.\n**\n** nReq is the number of bytes of memory required. Once this much has\n** been released, the function returns. The return value is the total number \n** of bytes of memory released.\n*/\nSQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){\n  int nFree = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  assert( sqlite3_mutex_notheld(pcache1.mutex) );\n  if( sqlite3GlobalConfig.pPage==0 ){\n    PgHdr1 *p;\n    pcache1EnterMutex(&pcache1.grp);\n    while( (nReq<0 || nFree<nReq)\n       &&  (p=pcache1.grp.lru.pLruPrev)!=0\n       &&  p->isAnchor==0\n    ){\n      nFree += pcache1MemSize(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n      nFree += sqlite3MemSize(p);\n#endif\n      assert( PAGE_IS_UNPINNED(p) );\n      pcache1PinPage(p);\n      pcache1RemoveFromHash(p, 1);\n    }\n    pcache1LeaveMutex(&pcache1.grp);\n  }\n  return nFree;\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n#ifdef SQLITE_TEST\n/*\n** This function is used by test procedures to inspect the internal state\n** of the global cache.\n*/\nSQLITE_PRIVATE void sqlite3PcacheStats(\n  int *pnCurrent,      /* OUT: Total number of pages cached */\n  int *pnMax,          /* OUT: Global maximum cache size */\n  int *pnMin,          /* OUT: Sum of PCache1.nMin for purgeable caches */\n  int *pnRecyclable    /* OUT: Total number of pages available for recycling */\n){\n  PgHdr1 *p;\n  int nRecyclable = 0;\n  for(p=pcache1.grp.lru.pLruNext; p && !p->isAnchor; p=p->pLruNext){\n    assert( PAGE_IS_UNPINNED(p) );\n    nRecyclable++;\n  }\n  *pnCurrent = pcache1.grp.nPurgeable;\n  *pnMax = (int)pcache1.grp.nMaxPage;\n  *pnMin = (int)pcache1.grp.nMinPage;\n  *pnRecyclable = nRecyclable;\n}\n#endif\n\n/************** End of pcache1.c *********************************************/\n/************** Begin file rowset.c ******************************************/\n/*\n** 2008 December 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements an object we call a \"RowSet\".\n**\n** The RowSet object is a collection of rowids.  Rowids\n** are inserted into the RowSet in an arbitrary order.  Inserts\n** can be intermixed with tests to see if a given rowid has been\n** previously inserted into the RowSet.\n**\n** After all inserts are finished, it is possible to extract the\n** elements of the RowSet in sorted order.  Once this extraction\n** process has started, no new elements may be inserted.\n**\n** Hence, the primitive operations for a RowSet are:\n**\n**    CREATE\n**    INSERT\n**    TEST\n**    SMALLEST\n**    DESTROY\n**\n** The CREATE and DESTROY primitives are the constructor and destructor,\n** obviously.  The INSERT primitive adds a new element to the RowSet.\n** TEST checks to see if an element is already in the RowSet.  SMALLEST\n** extracts the least value from the RowSet.\n**\n** The INSERT primitive might allocate additional memory.  Memory is\n** allocated in chunks so most INSERTs do no allocation.  There is an \n** upper bound on the size of allocated memory.  No memory is freed\n** until DESTROY.\n**\n** The TEST primitive includes a \"batch\" number.  The TEST primitive\n** will only see elements that were inserted before the last change\n** in the batch number.  In other words, if an INSERT occurs between\n** two TESTs where the TESTs have the same batch nubmer, then the\n** value added by the INSERT will not be visible to the second TEST.\n** The initial batch number is zero, so if the very first TEST contains\n** a non-zero batch number, it will see all prior INSERTs.\n**\n** No INSERTs may occurs after a SMALLEST.  An assertion will fail if\n** that is attempted.\n**\n** The cost of an INSERT is roughly constant.  (Sometimes new memory\n** has to be allocated on an INSERT.)  The cost of a TEST with a new\n** batch number is O(NlogN) where N is the number of elements in the RowSet.\n** The cost of a TEST using the same batch number is O(logN).  The cost\n** of the first SMALLEST is O(NlogN).  Second and subsequent SMALLEST\n** primitives are constant time.  The cost of DESTROY is O(N).\n**\n** TEST and SMALLEST may not be used by the same RowSet.  This used to\n** be possible, but the feature was not used, so it was removed in order\n** to simplify the code.\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/*\n** Target size for allocation chunks.\n*/\n#define ROWSET_ALLOCATION_SIZE 1024\n\n/*\n** The number of rowset entries per allocation chunk.\n*/\n#define ROWSET_ENTRY_PER_CHUNK  \\\n                       ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry))\n\n/*\n** Each entry in a RowSet is an instance of the following object.\n**\n** This same object is reused to store a linked list of trees of RowSetEntry\n** objects.  In that alternative use, pRight points to the next entry\n** in the list, pLeft points to the tree, and v is unused.  The\n** RowSet.pForest value points to the head of this forest list.\n*/\nstruct RowSetEntry {            \n  i64 v;                        /* ROWID value for this entry */\n  struct RowSetEntry *pRight;   /* Right subtree (larger entries) or list */\n  struct RowSetEntry *pLeft;    /* Left subtree (smaller entries) */\n};\n\n/*\n** RowSetEntry objects are allocated in large chunks (instances of the\n** following structure) to reduce memory allocation overhead.  The\n** chunks are kept on a linked list so that they can be deallocated\n** when the RowSet is destroyed.\n*/\nstruct RowSetChunk {\n  struct RowSetChunk *pNextChunk;        /* Next chunk on list of them all */\n  struct RowSetEntry aEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */\n};\n\n/*\n** A RowSet in an instance of the following structure.\n**\n** A typedef of this structure if found in sqliteInt.h.\n*/\nstruct RowSet {\n  struct RowSetChunk *pChunk;    /* List of all chunk allocations */\n  sqlite3 *db;                   /* The database connection */\n  struct RowSetEntry *pEntry;    /* List of entries using pRight */\n  struct RowSetEntry *pLast;     /* Last entry on the pEntry list */\n  struct RowSetEntry *pFresh;    /* Source of new entry objects */\n  struct RowSetEntry *pForest;   /* List of binary trees of entries */\n  u16 nFresh;                    /* Number of objects on pFresh */\n  u16 rsFlags;                   /* Various flags */\n  int iBatch;                    /* Current insert batch */\n};\n\n/*\n** Allowed values for RowSet.rsFlags\n*/\n#define ROWSET_SORTED  0x01   /* True if RowSet.pEntry is sorted */\n#define ROWSET_NEXT    0x02   /* True if sqlite3RowSetNext() has been called */\n\n/*\n** Turn bulk memory into a RowSet object.  N bytes of memory\n** are available at pSpace.  The db pointer is used as a memory context\n** for any subsequent allocations that need to occur.\n** Return a pointer to the new RowSet object.\n**\n** It must be the case that N is sufficient to make a Rowset.  If not\n** an assertion fault occurs.\n** \n** If N is larger than the minimum, use the surplus as an initial\n** allocation of entries available to be filled.\n*/\nSQLITE_PRIVATE RowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsigned int N){\n  RowSet *p;\n  assert( N >= ROUND8(sizeof(*p)) );\n  p = pSpace;\n  p->pChunk = 0;\n  p->db = db;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p);\n  p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry));\n  p->rsFlags = ROWSET_SORTED;\n  p->iBatch = 0;\n  return p;\n}\n\n/*\n** Deallocate all chunks from a RowSet.  This frees all memory that\n** the RowSet has allocated over its lifetime.  This routine is\n** the destructor for the RowSet.\n*/\nSQLITE_PRIVATE void sqlite3RowSetClear(RowSet *p){\n  struct RowSetChunk *pChunk, *pNextChunk;\n  for(pChunk=p->pChunk; pChunk; pChunk = pNextChunk){\n    pNextChunk = pChunk->pNextChunk;\n    sqlite3DbFree(p->db, pChunk);\n  }\n  p->pChunk = 0;\n  p->nFresh = 0;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->rsFlags = ROWSET_SORTED;\n}\n\n/*\n** Allocate a new RowSetEntry object that is associated with the\n** given RowSet.  Return a pointer to the new and completely uninitialized\n** objected.\n**\n** In an OOM situation, the RowSet.db->mallocFailed flag is set and this\n** routine returns NULL.\n*/\nstatic struct RowSetEntry *rowSetEntryAlloc(RowSet *p){\n  assert( p!=0 );\n  if( p->nFresh==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    /* We could allocate a fresh RowSetEntry each time one is needed, but it\n    ** is more efficient to pull a preallocated entry from the pool */\n    struct RowSetChunk *pNew;\n    pNew = sqlite3DbMallocRawNN(p->db, sizeof(*pNew));\n    if( pNew==0 ){\n      return 0;\n    }\n    pNew->pNextChunk = p->pChunk;\n    p->pChunk = pNew;\n    p->pFresh = pNew->aEntry;\n    p->nFresh = ROWSET_ENTRY_PER_CHUNK;\n  }\n  p->nFresh--;\n  return p->pFresh++;\n}\n\n/*\n** Insert a new value into a RowSet.\n**\n** The mallocFailed flag of the database connection is set if a\n** memory allocation fails.\n*/\nSQLITE_PRIVATE void sqlite3RowSetInsert(RowSet *p, i64 rowid){\n  struct RowSetEntry *pEntry;  /* The new entry */\n  struct RowSetEntry *pLast;   /* The last prior entry */\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );\n\n  pEntry = rowSetEntryAlloc(p);\n  if( pEntry==0 ) return;\n  pEntry->v = rowid;\n  pEntry->pRight = 0;\n  pLast = p->pLast;\n  if( pLast ){\n    if( rowid<=pLast->v ){  /*OPTIMIZATION-IF-FALSE*/\n      /* Avoid unnecessary sorts by preserving the ROWSET_SORTED flags\n      ** where possible */\n      p->rsFlags &= ~ROWSET_SORTED;\n    }\n    pLast->pRight = pEntry;\n  }else{\n    p->pEntry = pEntry;\n  }\n  p->pLast = pEntry;\n}\n\n/*\n** Merge two lists of RowSetEntry objects.  Remove duplicates.\n**\n** The input lists are connected via pRight pointers and are \n** assumed to each already be in sorted order.\n*/\nstatic struct RowSetEntry *rowSetEntryMerge(\n  struct RowSetEntry *pA,    /* First sorted list to be merged */\n  struct RowSetEntry *pB     /* Second sorted list to be merged */\n){\n  struct RowSetEntry head;\n  struct RowSetEntry *pTail;\n\n  pTail = &head;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    assert( pA->pRight==0 || pA->v<=pA->pRight->v );\n    assert( pB->pRight==0 || pB->v<=pB->pRight->v );\n    if( pA->v<=pB->v ){\n      if( pA->v<pB->v ) pTail = pTail->pRight = pA;\n      pA = pA->pRight;\n      if( pA==0 ){\n        pTail->pRight = pB;\n        break;\n      }\n    }else{\n      pTail = pTail->pRight = pB;\n      pB = pB->pRight;\n      if( pB==0 ){\n        pTail->pRight = pA;\n        break;\n      }\n    }\n  }\n  return head.pRight;\n}\n\n/*\n** Sort all elements on the list of RowSetEntry objects into order of\n** increasing v.\n*/ \nstatic struct RowSetEntry *rowSetEntrySort(struct RowSetEntry *pIn){\n  unsigned int i;\n  struct RowSetEntry *pNext, *aBucket[40];\n\n  memset(aBucket, 0, sizeof(aBucket));\n  while( pIn ){\n    pNext = pIn->pRight;\n    pIn->pRight = 0;\n    for(i=0; aBucket[i]; i++){\n      pIn = rowSetEntryMerge(aBucket[i], pIn);\n      aBucket[i] = 0;\n    }\n    aBucket[i] = pIn;\n    pIn = pNext;\n  }\n  pIn = aBucket[0];\n  for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){\n    if( aBucket[i]==0 ) continue;\n    pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];\n  }\n  return pIn;\n}\n\n\n/*\n** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects.\n** Convert this tree into a linked list connected by the pRight pointers\n** and return pointers to the first and last elements of the new list.\n*/\nstatic void rowSetTreeToList(\n  struct RowSetEntry *pIn,         /* Root of the input tree */\n  struct RowSetEntry **ppFirst,    /* Write head of the output list here */\n  struct RowSetEntry **ppLast      /* Write tail of the output list here */\n){\n  assert( pIn!=0 );\n  if( pIn->pLeft ){\n    struct RowSetEntry *p;\n    rowSetTreeToList(pIn->pLeft, ppFirst, &p);\n    p->pRight = pIn;\n  }else{\n    *ppFirst = pIn;\n  }\n  if( pIn->pRight ){\n    rowSetTreeToList(pIn->pRight, &pIn->pRight, ppLast);\n  }else{\n    *ppLast = pIn;\n  }\n  assert( (*ppLast)->pRight==0 );\n}\n\n\n/*\n** Convert a sorted list of elements (connected by pRight) into a binary\n** tree with depth of iDepth.  A depth of 1 means the tree contains a single\n** node taken from the head of *ppList.  A depth of 2 means a tree with\n** three nodes.  And so forth.\n**\n** Use as many entries from the input list as required and update the\n** *ppList to point to the unused elements of the list.  If the input\n** list contains too few elements, then construct an incomplete tree\n** and leave *ppList set to NULL.\n**\n** Return a pointer to the root of the constructed binary tree.\n*/\nstatic struct RowSetEntry *rowSetNDeepTree(\n  struct RowSetEntry **ppList,\n  int iDepth\n){\n  struct RowSetEntry *p;         /* Root of the new tree */\n  struct RowSetEntry *pLeft;     /* Left subtree */\n  if( *ppList==0 ){ /*OPTIMIZATION-IF-TRUE*/\n    /* Prevent unnecessary deep recursion when we run out of entries */\n    return 0; \n  }\n  if( iDepth>1 ){   /*OPTIMIZATION-IF-TRUE*/\n    /* This branch causes a *balanced* tree to be generated.  A valid tree\n    ** is still generated without this branch, but the tree is wildly\n    ** unbalanced and inefficient. */\n    pLeft = rowSetNDeepTree(ppList, iDepth-1);\n    p = *ppList;\n    if( p==0 ){     /*OPTIMIZATION-IF-FALSE*/\n      /* It is safe to always return here, but the resulting tree\n      ** would be unbalanced */\n      return pLeft;\n    }\n    p->pLeft = pLeft;\n    *ppList = p->pRight;\n    p->pRight = rowSetNDeepTree(ppList, iDepth-1);\n  }else{\n    p = *ppList;\n    *ppList = p->pRight;\n    p->pLeft = p->pRight = 0;\n  }\n  return p;\n}\n\n/*\n** Convert a sorted list of elements into a binary tree. Make the tree\n** as deep as it needs to be in order to contain the entire list.\n*/\nstatic struct RowSetEntry *rowSetListToTree(struct RowSetEntry *pList){\n  int iDepth;           /* Depth of the tree so far */\n  struct RowSetEntry *p;       /* Current tree root */\n  struct RowSetEntry *pLeft;   /* Left subtree */\n\n  assert( pList!=0 );\n  p = pList;\n  pList = p->pRight;\n  p->pLeft = p->pRight = 0;\n  for(iDepth=1; pList; iDepth++){\n    pLeft = p;\n    p = pList;\n    pList = p->pRight;\n    p->pLeft = pLeft;\n    p->pRight = rowSetNDeepTree(&pList, iDepth);\n  }\n  return p;\n}\n\n/*\n** Extract the smallest element from the RowSet.\n** Write the element into *pRowid.  Return 1 on success.  Return\n** 0 if the RowSet is already empty.\n**\n** After this routine has been called, the sqlite3RowSetInsert()\n** routine may not be called again.\n**\n** This routine may not be called after sqlite3RowSetTest() has\n** been used.  Older versions of RowSet allowed that, but as the\n** capability was not used by the code generator, it was removed\n** for code economy.\n*/\nSQLITE_PRIVATE int sqlite3RowSetNext(RowSet *p, i64 *pRowid){\n  assert( p!=0 );\n  assert( p->pForest==0 );  /* Cannot be used with sqlite3RowSetText() */\n\n  /* Merge the forest into a single sorted list on first call */\n  if( (p->rsFlags & ROWSET_NEXT)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    if( (p->rsFlags & ROWSET_SORTED)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n      p->pEntry = rowSetEntrySort(p->pEntry);\n    }\n    p->rsFlags |= ROWSET_SORTED|ROWSET_NEXT;\n  }\n\n  /* Return the next entry on the list */\n  if( p->pEntry ){\n    *pRowid = p->pEntry->v;\n    p->pEntry = p->pEntry->pRight;\n    if( p->pEntry==0 ){ /*OPTIMIZATION-IF-TRUE*/\n      /* Free memory immediately, rather than waiting on sqlite3_finalize() */\n      sqlite3RowSetClear(p);\n    }\n    return 1;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Check to see if element iRowid was inserted into the rowset as\n** part of any insert batch prior to iBatch.  Return 1 or 0.\n**\n** If this is the first test of a new batch and if there exist entries\n** on pRowSet->pEntry, then sort those entries into the forest at\n** pRowSet->pForest so that they can be tested.\n*/\nSQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 iRowid){\n  struct RowSetEntry *p, *pTree;\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );\n\n  /* Sort entries into the forest on the first test of a new batch.\n  ** To save unnecessary work, only do this when the batch number changes.\n  */\n  if( iBatch!=pRowSet->iBatch ){  /*OPTIMIZATION-IF-FALSE*/\n    p = pRowSet->pEntry;\n    if( p ){\n      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;\n      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n        /* Only sort the current set of entiries if they need it */\n        p = rowSetEntrySort(p);\n      }\n      for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n        ppPrevTree = &pTree->pRight;\n        if( pTree->pLeft==0 ){\n          pTree->pLeft = rowSetListToTree(p);\n          break;\n        }else{\n          struct RowSetEntry *pAux, *pTail;\n          rowSetTreeToList(pTree->pLeft, &pAux, &pTail);\n          pTree->pLeft = 0;\n          p = rowSetEntryMerge(pAux, p);\n        }\n      }\n      if( pTree==0 ){\n        *ppPrevTree = pTree = rowSetEntryAlloc(pRowSet);\n        if( pTree ){\n          pTree->v = 0;\n          pTree->pRight = 0;\n          pTree->pLeft = rowSetListToTree(p);\n        }\n      }\n      pRowSet->pEntry = 0;\n      pRowSet->pLast = 0;\n      pRowSet->rsFlags |= ROWSET_SORTED;\n    }\n    pRowSet->iBatch = iBatch;\n  }\n\n  /* Test to see if the iRowid value appears anywhere in the forest.\n  ** Return 1 if it does and 0 if not.\n  */\n  for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n    p = pTree->pLeft;\n    while( p ){\n      if( p->v<iRowid ){\n        p = p->pRight;\n      }else if( p->v>iRowid ){\n        p = p->pLeft;\n      }else{\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/************** End of rowset.c **********************************************/\n/************** Begin file pager.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of the page cache subsystem or \"pager\".\n** \n** The pager is used to access a database disk file.  It implements\n** atomic commit and rollback through the use of a journal file that\n** is separate from the database file.  The pager also implements file\n** locking to prevent two processes from writing the same database\n** file simultaneously, or one process from reading the database while\n** another is writing.\n*/\n#ifndef SQLITE_OMIT_DISKIO\n/* #include \"sqliteInt.h\" */\n/************** Include wal.h in the middle of pager.c ***********************/\n/************** Begin file wal.h *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface to the write-ahead logging \n** system. Refer to the comments below and the header comment attached to \n** the implementation of each function in log.c for further details.\n*/\n\n#ifndef SQLITE_WAL_H\n#define SQLITE_WAL_H\n\n/* #include \"sqliteInt.h\" */\n\n/* Macros for extracting appropriate sync flags for either transaction\n** commits (WAL_SYNC_FLAGS(X)) or for checkpoint ops (CKPT_SYNC_FLAGS(X)):\n*/\n#define WAL_SYNC_FLAGS(X)   ((X)&0x03)\n#define CKPT_SYNC_FLAGS(X)  (((X)>>2)&0x03)\n\n#ifdef SQLITE_OMIT_WAL\n# define sqlite3WalOpen(x,y,z)                   0\n# define sqlite3WalLimit(x,y)\n# define sqlite3WalClose(v,w,x,y,z)              0\n# define sqlite3WalBeginReadTransaction(y,z)     0\n# define sqlite3WalEndReadTransaction(z)\n# define sqlite3WalDbsize(y)                     0\n# define sqlite3WalBeginWriteTransaction(y)      0\n# define sqlite3WalEndWriteTransaction(x)        0\n# define sqlite3WalUndo(x,y,z)                   0\n# define sqlite3WalSavepoint(y,z)\n# define sqlite3WalSavepointUndo(y,z)            0\n# define sqlite3WalFrames(u,v,w,x,y,z)           0\n# define sqlite3WalCheckpoint(q,r,s,t,u,v,w,x,y,z) 0\n# define sqlite3WalCallback(z)                   0\n# define sqlite3WalExclusiveMode(y,z)            0\n# define sqlite3WalHeapMemory(z)                 0\n# define sqlite3WalFramesize(z)                  0\n# define sqlite3WalFindFrame(x,y,z)              0\n# define sqlite3WalFile(x)                       0\n#else\n\n#define WAL_SAVEPOINT_NDATA 4\n\n/* Connection to a write-ahead log (WAL) file. \n** There is one object of this type for each pager. \n*/\ntypedef struct Wal Wal;\n\n/* Open and close a connection to a write-ahead log. */\nSQLITE_PRIVATE int sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);\nSQLITE_PRIVATE int sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);\n\n/* Set the limiting size of a WAL file. */\nSQLITE_PRIVATE void sqlite3WalLimit(Wal*, i64);\n\n/* Used by readers to open (lock) and close (unlock) a snapshot.  A \n** snapshot is like a read-transaction.  It is the state of the database\n** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and\n** preserves the current state even if the other threads or processes\n** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the\n** transaction and releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *);\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal);\n\n/* Read a page from the write-ahead log, if it is present. */\nSQLITE_PRIVATE int sqlite3WalFindFrame(Wal *, Pgno, u32 *);\nSQLITE_PRIVATE int sqlite3WalReadFrame(Wal *, u32, int, u8 *);\n\n/* If the WAL is not empty, return the size of the database. */\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal);\n\n/* Obtain or release the WRITER lock. */\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal);\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal);\n\n/* Undo any frames written (but not committed) to the log */\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);\n\n/* Return an integer that records the current (uncommitted) write\n** position in the WAL */\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);\n\n/* Move the write position of the WAL back to iFrame.  Called in\n** response to a ROLLBACK TO command. */\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);\n\n/* Write a frame or frames to the log. */\nSQLITE_PRIVATE int sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);\n\n/* Copy pages from the log to the database file */ \nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Write-ahead log connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* One of PASSIVE, FULL and RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of buffer nBuf */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n);\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal);\n\n/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)\n** by the pager layer on the database file.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op);\n\n/* Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal);\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\nSQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);\nSQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);\nSQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal);\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/* If the WAL file is not empty, return the number of bytes of content\n** stored in each frame (i.e. the db page-size when the WAL was created).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal);\n#endif\n\n/* Return the sqlite3_file object for the WAL file */\nSQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal);\n\n#endif /* ifndef SQLITE_OMIT_WAL */\n#endif /* SQLITE_WAL_H */\n\n/************** End of wal.h *************************************************/\n/************** Continuing where we left off in pager.c **********************/\n\n\n/******************* NOTES ON THE DESIGN OF THE PAGER ************************\n**\n** This comment block describes invariants that hold when using a rollback\n** journal.  These invariants do not apply for journal_mode=WAL,\n** journal_mode=MEMORY, or journal_mode=OFF.\n**\n** Within this comment block, a page is deemed to have been synced\n** automatically as soon as it is written when PRAGMA synchronous=OFF.\n** Otherwise, the page is not synced until the xSync method of the VFS\n** is called successfully on the file containing the page.\n**\n** Definition:  A page of the database file is said to be \"overwriteable\" if\n** one or more of the following are true about the page:\n** \n**     (a)  The original content of the page as it was at the beginning of\n**          the transaction has been written into the rollback journal and\n**          synced.\n** \n**     (b)  The page was a freelist leaf page at the start of the transaction.\n** \n**     (c)  The page number is greater than the largest page that existed in\n**          the database file at the start of the transaction.\n** \n** (1) A page of the database file is never overwritten unless one of the\n**     following are true:\n** \n**     (a) The page and all other pages on the same sector are overwriteable.\n** \n**     (b) The atomic page write optimization is enabled, and the entire\n**         transaction other than the update of the transaction sequence\n**         number consists of a single page change.\n** \n** (2) The content of a page written into the rollback journal exactly matches\n**     both the content in the database when the rollback journal was written\n**     and the content in the database at the beginning of the current\n**     transaction.\n** \n** (3) Writes to the database file are an integer multiple of the page size\n**     in length and are aligned on a page boundary.\n** \n** (4) Reads from the database file are either aligned on a page boundary and\n**     an integer multiple of the page size in length or are taken from the\n**     first 100 bytes of the database file.\n** \n** (5) All writes to the database file are synced prior to the rollback journal\n**     being deleted, truncated, or zeroed.\n** \n** (6) If a master journal file is used, then all writes to the database file\n**     are synced prior to the master journal being deleted.\n** \n** Definition: Two databases (or the same database at two points it time)\n** are said to be \"logically equivalent\" if they give the same answer to\n** all queries.  Note in particular the content of freelist leaf\n** pages can be changed arbitrarily without affecting the logical equivalence\n** of the database.\n** \n** (7) At any time, if any subset, including the empty set and the total set,\n**     of the unsynced changes to a rollback journal are removed and the \n**     journal is rolled back, the resulting database file will be logically\n**     equivalent to the database file at the beginning of the transaction.\n** \n** (8) When a transaction is rolled back, the xTruncate method of the VFS\n**     is called to restore the database file to the same size it was at\n**     the beginning of the transaction.  (In some VFSes, the xTruncate\n**     method is a no-op, but that does not change the fact the SQLite will\n**     invoke it.)\n** \n** (9) Whenever the database file is modified, at least one bit in the range\n**     of bytes from 24 through 39 inclusive will be changed prior to releasing\n**     the EXCLUSIVE lock, thus signaling other connections on the same\n**     database to flush their caches.\n**\n** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less\n**      than one billion transactions.\n**\n** (11) A database file is well-formed at the beginning and at the conclusion\n**      of every transaction.\n**\n** (12) An EXCLUSIVE lock is held on the database file when writing to\n**      the database file.\n**\n** (13) A SHARED lock is held on the database file while reading any\n**      content out of the database file.\n**\n******************************************************************************/\n\n/*\n** Macros for troubleshooting.  Normally turned off\n*/\n#if 0\nint sqlite3PagerTrace=1;  /* True to enable tracing */\n#define sqlite3DebugPrintf printf\n#define PAGERTRACE(X)     if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; }\n#else\n#define PAGERTRACE(X)\n#endif\n\n/*\n** The following two macros are used within the PAGERTRACE() macros above\n** to print out file-descriptors. \n**\n** PAGERID() takes a pointer to a Pager struct as its argument. The\n** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file\n** struct as its argument.\n*/\n#define PAGERID(p) (SQLITE_PTR_TO_INT(p->fd))\n#define FILEHANDLEID(fd) (SQLITE_PTR_TO_INT(fd))\n\n/*\n** The Pager.eState variable stores the current 'state' of a pager. A\n** pager may be in any one of the seven states shown in the following\n** state diagram.\n**\n**                            OPEN <------+------+\n**                              |         |      |\n**                              V         |      |\n**               +---------> READER-------+      |\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_LOCKED------> ERROR\n**               |              |                ^  \n**               |              V                |\n**               |<------WRITER_CACHEMOD-------->|\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_DBMOD---------->|\n**               |              |                |\n**               |              V                |\n**               +<------WRITER_FINISHED-------->+\n**\n**\n** List of state transitions and the C [function] that performs each:\n** \n**   OPEN              -> READER              [sqlite3PagerSharedLock]\n**   READER            -> OPEN                [pager_unlock]\n**\n**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]\n**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]\n**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]\n**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]\n**   WRITER_***        -> READER              [pager_end_transaction]\n**\n**   WRITER_***        -> ERROR               [pager_error]\n**   ERROR             -> OPEN                [pager_unlock]\n** \n**\n**  OPEN:\n**\n**    The pager starts up in this state. Nothing is guaranteed in this\n**    state - the file may or may not be locked and the database size is\n**    unknown. The database may not be read or written.\n**\n**    * No read or write transaction is active.\n**    * Any lock, or no lock at all, may be held on the database file.\n**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.\n**\n**  READER:\n**\n**    In this state all the requirements for reading the database in \n**    rollback (non-WAL) mode are met. Unless the pager is (or recently\n**    was) in exclusive-locking mode, a user-level read transaction is \n**    open. The database size is known in this state.\n**\n**    A connection running with locking_mode=normal enters this state when\n**    it opens a read-transaction on the database and returns to state\n**    OPEN after the read-transaction is completed. However a connection\n**    running in locking_mode=exclusive (including temp databases) remains in\n**    this state even after the read-transaction is closed. The only way\n**    a locking_mode=exclusive connection can transition from READER to OPEN\n**    is via the ERROR state (see below).\n** \n**    * A read transaction may be active (but a write-transaction cannot).\n**    * A SHARED or greater lock is held on the database file.\n**    * The dbSize variable may be trusted (even if a user-level read \n**      transaction is not active). The dbOrigSize and dbFileSize variables\n**      may not be trusted at this point.\n**    * If the database is a WAL database, then the WAL connection is open.\n**    * Even if a read-transaction is not open, it is guaranteed that \n**      there is no hot-journal in the file-system.\n**\n**  WRITER_LOCKED:\n**\n**    The pager moves to this state from READER when a write-transaction\n**    is first opened on the database. In WRITER_LOCKED state, all locks \n**    required to start a write-transaction are held, but no actual \n**    modifications to the cache or database have taken place.\n**\n**    In rollback mode, a RESERVED or (if the transaction was opened with \n**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when\n**    moving to this state, but the journal file is not written to or opened \n**    to in this state. If the transaction is committed or rolled back while \n**    in WRITER_LOCKED state, all that is required is to unlock the database \n**    file.\n**\n**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.\n**    If the connection is running with locking_mode=exclusive, an attempt\n**    is made to obtain an EXCLUSIVE lock on the database file.\n**\n**    * A write transaction is active.\n**    * If the connection is open in rollback-mode, a RESERVED or greater \n**      lock is held on the database file.\n**    * If the connection is open in WAL-mode, a WAL write transaction\n**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully\n**      called).\n**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.\n**    * The contents of the pager cache have not been modified.\n**    * The journal file may or may not be open.\n**    * Nothing (not even the first header) has been written to the journal.\n**\n**  WRITER_CACHEMOD:\n**\n**    A pager moves from WRITER_LOCKED state to this state when a page is\n**    first modified by the upper layer. In rollback mode the journal file\n**    is opened (if it is not already open) and a header written to the\n**    start of it. The database file on disk has not been modified.\n**\n**    * A write transaction is active.\n**    * A RESERVED or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      to it, but the header has not been synced to disk.\n**    * The contents of the page cache have been modified.\n**\n**  WRITER_DBMOD:\n**\n**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state\n**    when it modifies the contents of the database file. WAL connections\n**    never enter this state (since they do not modify the database file,\n**    just the log file).\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      and synced to disk.\n**    * The contents of the page cache have been modified (and possibly\n**      written to disk).\n**\n**  WRITER_FINISHED:\n**\n**    It is not possible for a WAL connection to enter this state.\n**\n**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD\n**    state after the entire transaction has been successfully written into the\n**    database file. In this state the transaction may be committed simply\n**    by finalizing the journal file. Once in WRITER_FINISHED state, it is \n**    not possible to modify the database further. At this point, the upper \n**    layer must either commit or rollback the transaction.\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * All writing and syncing of journal and database data has finished.\n**      If no error occurred, all that remains is to finalize the journal to\n**      commit the transaction. If an error did occur, the caller will need\n**      to rollback the transaction. \n**\n**  ERROR:\n**\n**    The ERROR state is entered when an IO or disk-full error (including\n**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it \n**    difficult to be sure that the in-memory pager state (cache contents, \n**    db size etc.) are consistent with the contents of the file-system.\n**\n**    Temporary pager files may enter the ERROR state, but in-memory pagers\n**    cannot.\n**\n**    For example, if an IO error occurs while performing a rollback, \n**    the contents of the page-cache may be left in an inconsistent state.\n**    At this point it would be dangerous to change back to READER state\n**    (as usually happens after a rollback). Any subsequent readers might\n**    report database corruption (due to the inconsistent cache), and if\n**    they upgrade to writers, they may inadvertently corrupt the database\n**    file. To avoid this hazard, the pager switches into the ERROR state\n**    instead of READER following such an error.\n**\n**    Once it has entered the ERROR state, any attempt to use the pager\n**    to read or write data returns an error. Eventually, once all \n**    outstanding transactions have been abandoned, the pager is able to\n**    transition back to OPEN state, discarding the contents of the \n**    page-cache and any other in-memory state at the same time. Everything\n**    is reloaded from disk (and, if necessary, hot-journal rollback peformed)\n**    when a read-transaction is next opened on the pager (transitioning\n**    the pager into READER state). At that point the system has recovered \n**    from the error.\n**\n**    Specifically, the pager jumps into the ERROR state if:\n**\n**      1. An error occurs while attempting a rollback. This happens in\n**         function sqlite3PagerRollback().\n**\n**      2. An error occurs while attempting to finalize a journal file\n**         following a commit in function sqlite3PagerCommitPhaseTwo().\n**\n**      3. An error occurs while attempting to write to the journal or\n**         database file in function pagerStress() in order to free up\n**         memory.\n**\n**    In other cases, the error is returned to the b-tree layer. The b-tree\n**    layer then attempts a rollback operation. If the error condition \n**    persists, the pager enters the ERROR state via condition (1) above.\n**\n**    Condition (3) is necessary because it can be triggered by a read-only\n**    statement executed within a transaction. In this case, if the error\n**    code were simply returned to the user, the b-tree layer would not\n**    automatically attempt a rollback, as it assumes that an error in a\n**    read-only statement cannot leave the pager in an internally inconsistent \n**    state.\n**\n**    * The Pager.errCode variable is set to something other than SQLITE_OK.\n**    * There are one or more outstanding references to pages (after the\n**      last reference is dropped the pager should move back to OPEN state).\n**    * The pager is not an in-memory pager.\n**    \n**\n** Notes:\n**\n**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the\n**     connection is open in WAL mode. A WAL connection is always in one\n**     of the first four states.\n**\n**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN\n**     state. There are two exceptions: immediately after exclusive-mode has\n**     been turned on (and before any read or write transactions are \n**     executed), and when the pager is leaving the \"error state\".\n**\n**   * See also: assert_pager_state().\n*/\n#define PAGER_OPEN                  0\n#define PAGER_READER                1\n#define PAGER_WRITER_LOCKED         2\n#define PAGER_WRITER_CACHEMOD       3\n#define PAGER_WRITER_DBMOD          4\n#define PAGER_WRITER_FINISHED       5\n#define PAGER_ERROR                 6\n\n/*\n** The Pager.eLock variable is almost always set to one of the \n** following locking-states, according to the lock currently held on\n** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n** This variable is kept up to date as locks are taken and released by\n** the pagerLockDb() and pagerUnlockDb() wrappers.\n**\n** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY\n** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not\n** the operation was successful. In these circumstances pagerLockDb() and\n** pagerUnlockDb() take a conservative approach - eLock is always updated\n** when unlocking the file, and only updated when locking the file if the\n** VFS call is successful. This way, the Pager.eLock variable may be set\n** to a less exclusive (lower) value than the lock that is actually held\n** at the system level, but it is never set to a more exclusive value.\n**\n** This is usually safe. If an xUnlock fails or appears to fail, there may \n** be a few redundant xLock() calls or a lock may be held for longer than\n** required, but nothing really goes wrong.\n**\n** The exception is when the database file is unlocked as the pager moves\n** from ERROR to OPEN state. At this point there may be a hot-journal file \n** in the file-system that needs to be rolled back (as part of an OPEN->SHARED\n** transition, by the same pager or any other). If the call to xUnlock()\n** fails at this point and the pager is left holding an EXCLUSIVE lock, this\n** can confuse the call to xCheckReservedLock() call made later as part\n** of hot-journal detection.\n**\n** xCheckReservedLock() is defined as returning true \"if there is a RESERVED \n** lock held by this process or any others\". So xCheckReservedLock may \n** return true because the caller itself is holding an EXCLUSIVE lock (but\n** doesn't know it because of a previous error in xUnlock). If this happens\n** a hot-journal may be mistaken for a journal being created by an active\n** transaction in another process, causing SQLite to read from the database\n** without rolling it back.\n**\n** To work around this, if a call to xUnlock() fails when unlocking the\n** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It\n** is only changed back to a real locking state after a successful call\n** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition\n** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK \n** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE\n** lock on the database file before attempting to roll it back. See function\n** PagerSharedLock() for more detail.\n**\n** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in \n** PAGER_OPEN state.\n*/\n#define UNKNOWN_LOCK                (EXCLUSIVE_LOCK+1)\n\n/*\n** A macro used for invoking the codec if there is one\n*/\n#ifdef SQLITE_HAS_CODEC\n# define CODEC1(P,D,N,X,E) \\\n    if( P->xCodec && P->xCodec(P->pCodec,D,N,X)==0 ){ E; }\n# define CODEC2(P,D,N,X,E,O) \\\n    if( P->xCodec==0 ){ O=(char*)D; }else \\\n    if( (O=(char*)(P->xCodec(P->pCodec,D,N,X)))==0 ){ E; }\n#else\n# define CODEC1(P,D,N,X,E)   /* NO-OP */\n# define CODEC2(P,D,N,X,E,O) O=(char*)D\n#endif\n\n/*\n** The maximum allowed sector size. 64KiB. If the xSectorsize() method \n** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.\n** This could conceivably cause corruption following a power failure on\n** such a system. This is currently an undocumented limit.\n*/\n#define MAX_SECTOR_SIZE 0x10000\n\n\n/*\n** An instance of the following structure is allocated for each active\n** savepoint and statement transaction in the system. All such structures\n** are stored in the Pager.aSavepoint[] array, which is allocated and\n** resized using sqlite3Realloc().\n**\n** When a savepoint is created, the PagerSavepoint.iHdrOffset field is\n** set to 0. If a journal-header is written into the main journal while\n** the savepoint is active, then iHdrOffset is set to the byte offset \n** immediately following the last journal record written into the main\n** journal before the journal-header. This is required during savepoint\n** rollback (see pagerPlaybackSavepoint()).\n*/\ntypedef struct PagerSavepoint PagerSavepoint;\nstruct PagerSavepoint {\n  i64 iOffset;                 /* Starting offset in main journal */\n  i64 iHdrOffset;              /* See above */\n  Bitvec *pInSavepoint;        /* Set of pages in this savepoint */\n  Pgno nOrig;                  /* Original number of pages in file */\n  Pgno iSubRec;                /* Index of first record in sub-journal */\n#ifndef SQLITE_OMIT_WAL\n  u32 aWalData[WAL_SAVEPOINT_NDATA];        /* WAL savepoint context */\n#endif\n};\n\n/*\n** Bits of the Pager.doNotSpill flag.  See further description below.\n*/\n#define SPILLFLAG_OFF         0x01 /* Never spill cache.  Set via pragma */\n#define SPILLFLAG_ROLLBACK    0x02 /* Current rolling back, so do not spill */\n#define SPILLFLAG_NOSYNC      0x04 /* Spill is ok, but do not sync */\n\n/*\n** An open page cache is an instance of struct Pager. A description of\n** some of the more important member variables follows:\n**\n** eState\n**\n**   The current 'state' of the pager object. See the comment and state\n**   diagram above for a description of the pager state.\n**\n** eLock\n**\n**   For a real on-disk database, the current lock held on the database file -\n**   NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n**\n**   For a temporary or in-memory database (neither of which require any\n**   locks), this variable is always set to EXCLUSIVE_LOCK. Since such\n**   databases always have Pager.exclusiveMode==1, this tricks the pager\n**   logic into thinking that it already has all the locks it will ever\n**   need (and no reason to release them).\n**\n**   In some (obscure) circumstances, this variable may also be set to\n**   UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for\n**   details.\n**\n** changeCountDone\n**\n**   This boolean variable is used to make sure that the change-counter \n**   (the 4-byte header field at byte offset 24 of the database file) is \n**   not updated more often than necessary. \n**\n**   It is set to true when the change-counter field is updated, which \n**   can only happen if an exclusive lock is held on the database file.\n**   It is cleared (set to false) whenever an exclusive lock is \n**   relinquished on the database file. Each time a transaction is committed,\n**   The changeCountDone flag is inspected. If it is true, the work of\n**   updating the change-counter is omitted for the current transaction.\n**\n**   This mechanism means that when running in exclusive mode, a connection \n**   need only update the change-counter once, for the first transaction\n**   committed.\n**\n** setMaster\n**\n**   When PagerCommitPhaseOne() is called to commit a transaction, it may\n**   (or may not) specify a master-journal name to be written into the \n**   journal file before it is synced to disk.\n**\n**   Whether or not a journal file contains a master-journal pointer affects \n**   the way in which the journal file is finalized after the transaction is \n**   committed or rolled back when running in \"journal_mode=PERSIST\" mode.\n**   If a journal file does not contain a master-journal pointer, it is\n**   finalized by overwriting the first journal header with zeroes. If\n**   it does contain a master-journal pointer the journal file is finalized \n**   by truncating it to zero bytes, just as if the connection were \n**   running in \"journal_mode=truncate\" mode.\n**\n**   Journal files that contain master journal pointers cannot be finalized\n**   simply by overwriting the first journal-header with zeroes, as the\n**   master journal pointer could interfere with hot-journal rollback of any\n**   subsequently interrupted transaction that reuses the journal file.\n**\n**   The flag is cleared as soon as the journal file is finalized (either\n**   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the\n**   journal file from being successfully finalized, the setMaster flag\n**   is cleared anyway (and the pager will move to ERROR state).\n**\n** doNotSpill\n**\n**   This variables control the behavior of cache-spills  (calls made by\n**   the pcache module to the pagerStress() routine to write cached data\n**   to the file-system in order to free up memory).\n**\n**   When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,\n**   writing to the database from pagerStress() is disabled altogether.\n**   The SPILLFLAG_ROLLBACK case is done in a very obscure case that\n**   comes up during savepoint rollback that requires the pcache module\n**   to allocate a new page to prevent the journal file from being written\n**   while it is being traversed by code in pager_playback().  The SPILLFLAG_OFF\n**   case is a user preference.\n** \n**   If the SPILLFLAG_NOSYNC bit is set, writing to the database from\n**   pagerStress() is permitted, but syncing the journal file is not.\n**   This flag is set by sqlite3PagerWrite() when the file-system sector-size\n**   is larger than the database page-size in order to prevent a journal sync\n**   from happening in between the journalling of two pages on the same sector. \n**\n** subjInMemory\n**\n**   This is a boolean variable. If true, then any required sub-journal\n**   is opened as an in-memory journal file. If false, then in-memory\n**   sub-journals are only used for in-memory pager files.\n**\n**   This variable is updated by the upper layer each time a new \n**   write-transaction is opened.\n**\n** dbSize, dbOrigSize, dbFileSize\n**\n**   Variable dbSize is set to the number of pages in the database file.\n**   It is valid in PAGER_READER and higher states (all states except for\n**   OPEN and ERROR). \n**\n**   dbSize is set based on the size of the database file, which may be \n**   larger than the size of the database (the value stored at offset\n**   28 of the database header by the btree). If the size of the file\n**   is not an integer multiple of the page-size, the value stored in\n**   dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).\n**   Except, any file that is greater than 0 bytes in size is considered\n**   to have at least one page. (i.e. a 1KB file with 2K page-size leads\n**   to dbSize==1).\n**\n**   During a write-transaction, if pages with page-numbers greater than\n**   dbSize are modified in the cache, dbSize is updated accordingly.\n**   Similarly, if the database is truncated using PagerTruncateImage(), \n**   dbSize is updated.\n**\n**   Variables dbOrigSize and dbFileSize are valid in states \n**   PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize\n**   variable at the start of the transaction. It is used during rollback,\n**   and to determine whether or not pages need to be journalled before\n**   being modified.\n**\n**   Throughout a write-transaction, dbFileSize contains the size of\n**   the file on disk in pages. It is set to a copy of dbSize when the\n**   write-transaction is first opened, and updated when VFS calls are made\n**   to write or truncate the database file on disk. \n**\n**   The only reason the dbFileSize variable is required is to suppress \n**   unnecessary calls to xTruncate() after committing a transaction. If, \n**   when a transaction is committed, the dbFileSize variable indicates \n**   that the database file is larger than the database image (Pager.dbSize), \n**   pager_truncate() is called. The pager_truncate() call uses xFilesize()\n**   to measure the database file on disk, and then truncates it if required.\n**   dbFileSize is not used when rolling back a transaction. In this case\n**   pager_truncate() is called unconditionally (which means there may be\n**   a call to xFilesize() that is not strictly required). In either case,\n**   pager_truncate() may cause the file to become smaller or larger.\n**\n** dbHintSize\n**\n**   The dbHintSize variable is used to limit the number of calls made to\n**   the VFS xFileControl(FCNTL_SIZE_HINT) method. \n**\n**   dbHintSize is set to a copy of the dbSize variable when a\n**   write-transaction is opened (at the same time as dbFileSize and\n**   dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,\n**   dbHintSize is increased to the number of pages that correspond to the\n**   size-hint passed to the method call. See pager_write_pagelist() for \n**   details.\n**\n** errCode\n**\n**   The Pager.errCode variable is only ever used in PAGER_ERROR state. It\n**   is set to zero in all other states. In PAGER_ERROR state, Pager.errCode \n**   is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX \n**   sub-codes.\n**\n** syncFlags, walSyncFlags\n**\n**   syncFlags is either SQLITE_SYNC_NORMAL (0x02) or SQLITE_SYNC_FULL (0x03).\n**   syncFlags is used for rollback mode.  walSyncFlags is used for WAL mode\n**   and contains the flags used to sync the checkpoint operations in the\n**   lower two bits, and sync flags used for transaction commits in the WAL\n**   file in bits 0x04 and 0x08.  In other words, to get the correct sync flags\n**   for checkpoint operations, use (walSyncFlags&0x03) and to get the correct\n**   sync flags for transaction commit, use ((walSyncFlags>>2)&0x03).  Note\n**   that with synchronous=NORMAL in WAL mode, transaction commit is not synced\n**   meaning that the 0x04 and 0x08 bits are both zero.\n*/\nstruct Pager {\n  sqlite3_vfs *pVfs;          /* OS functions to use for IO */\n  u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */\n  u8 journalMode;             /* One of the PAGER_JOURNALMODE_* values */\n  u8 useJournal;              /* Use a rollback journal on this file */\n  u8 noSync;                  /* Do not sync the journal if true */\n  u8 fullSync;                /* Do extra syncs of the journal for robustness */\n  u8 extraSync;               /* sync directory after journal delete */\n  u8 syncFlags;               /* SYNC_NORMAL or SYNC_FULL otherwise */\n  u8 walSyncFlags;            /* See description above */\n  u8 tempFile;                /* zFilename is a temporary or immutable file */\n  u8 noLock;                  /* Do not lock (except in WAL mode) */\n  u8 readOnly;                /* True for a read-only database */\n  u8 memDb;                   /* True to inhibit all file I/O */\n\n  /**************************************************************************\n  ** The following block contains those class members that change during\n  ** routine operation.  Class members not in this block are either fixed\n  ** when the pager is first created or else only change when there is a\n  ** significant mode change (such as changing the page_size, locking_mode,\n  ** or the journal_mode).  From another view, these class members describe\n  ** the \"state\" of the pager, while other class members describe the\n  ** \"configuration\" of the pager.\n  */\n  u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */\n  u8 eLock;                   /* Current lock held on database file */\n  u8 changeCountDone;         /* Set after incrementing the change-counter */\n  u8 setMaster;               /* True if a m-j name has been written to jrnl */\n  u8 doNotSpill;              /* Do not spill the cache when non-zero */\n  u8 subjInMemory;            /* True to use in-memory sub-journals */\n  u8 bUseFetch;               /* True to use xFetch() */\n  u8 hasHeldSharedLock;       /* True if a shared lock has ever been held */\n  Pgno dbSize;                /* Number of pages in the database */\n  Pgno dbOrigSize;            /* dbSize before the current transaction */\n  Pgno dbFileSize;            /* Number of pages in the database file */\n  Pgno dbHintSize;            /* Value passed to FCNTL_SIZE_HINT call */\n  int errCode;                /* One of several kinds of errors */\n  int nRec;                   /* Pages journalled since last j-header written */\n  u32 cksumInit;              /* Quasi-random value added to every checksum */\n  u32 nSubRec;                /* Number of records written to sub-journal */\n  Bitvec *pInJournal;         /* One bit for each page in the database file */\n  sqlite3_file *fd;           /* File descriptor for database */\n  sqlite3_file *jfd;          /* File descriptor for main journal */\n  sqlite3_file *sjfd;         /* File descriptor for sub-journal */\n  i64 journalOff;             /* Current write offset in the journal file */\n  i64 journalHdr;             /* Byte offset to previous journal header */\n  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */\n  PagerSavepoint *aSavepoint; /* Array of active savepoints */\n  int nSavepoint;             /* Number of elements in aSavepoint[] */\n  u32 iDataVersion;           /* Changes whenever database content changes */\n  char dbFileVers[16];        /* Changes whenever database file changes */\n\n  int nMmapOut;               /* Number of mmap pages currently outstanding */\n  sqlite3_int64 szMmap;       /* Desired maximum mmap size */\n  PgHdr *pMmapFreelist;       /* List of free mmap page headers (pDirty) */\n  /*\n  ** End of the routinely-changing class members\n  ***************************************************************************/\n\n  u16 nExtra;                 /* Add this many bytes to each in-memory page */\n  i16 nReserve;               /* Number of unused bytes at end of each page */\n  u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */\n  u32 sectorSize;             /* Assumed sector size during rollback */\n  int pageSize;               /* Number of bytes in a page */\n  Pgno mxPgno;                /* Maximum allowed size of the database */\n  i64 journalSizeLimit;       /* Size limit for persistent journal files */\n  char *zFilename;            /* Name of the database file */\n  char *zJournal;             /* Name of the journal file */\n  int (*xBusyHandler)(void*); /* Function to call when busy */\n  void *pBusyHandlerArg;      /* Context argument for xBusyHandler */\n  int aStat[3];               /* Total cache hits, misses and writes */\n#ifdef SQLITE_TEST\n  int nRead;                  /* Database pages read */\n#endif\n  void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */\n  int (*xGet)(Pager*,Pgno,DbPage**,int); /* Routine to fetch a patch */\n#ifdef SQLITE_HAS_CODEC\n  void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */\n  void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */\n  void (*xCodecFree)(void*);             /* Destructor for the codec */\n  void *pCodec;               /* First argument to xCodec... methods */\n#endif\n  char *pTmpSpace;            /* Pager.pageSize bytes of space for tmp use */\n  PCache *pPCache;            /* Pointer to page cache object */\n#ifndef SQLITE_OMIT_WAL\n  Wal *pWal;                  /* Write-ahead log used by \"journal_mode=wal\" */\n  char *zWal;                 /* File name for write-ahead log */\n#endif\n};\n\n/*\n** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains\n** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS \n** or CACHE_WRITE to sqlite3_db_status().\n*/\n#define PAGER_STAT_HIT   0\n#define PAGER_STAT_MISS  1\n#define PAGER_STAT_WRITE 2\n\n/*\n** The following global variables hold counters used for\n** testing purposes only.  These variables do not exist in\n** a non-testing build.  These variables are not thread-safe.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_pager_readdb_count = 0;    /* Number of full pages read from DB */\nSQLITE_API int sqlite3_pager_writedb_count = 0;   /* Number of full pages written to DB */\nSQLITE_API int sqlite3_pager_writej_count = 0;    /* Number of pages written to journal */\n# define PAGER_INCR(v)  v++\n#else\n# define PAGER_INCR(v)\n#endif\n\n\n\n/*\n** Journal files begin with the following magic string.  The data\n** was obtained from /dev/random.  It is used only as a sanity check.\n**\n** Since version 2.8.0, the journal format contains additional sanity\n** checking information.  If the power fails while the journal is being\n** written, semi-random garbage data might appear in the journal\n** file after power is restored.  If an attempt is then made\n** to roll the journal back, the database could be corrupted.  The additional\n** sanity checking data is an attempt to discover the garbage in the\n** journal and ignore it.\n**\n** The sanity checking information for the new journal format consists\n** of a 32-bit checksum on each page of data.  The checksum covers both\n** the page number and the pPager->pageSize bytes of data for the page.\n** This cksum is initialized to a 32-bit random value that appears in the\n** journal file right after the header.  The random initializer is important,\n** because garbage data that appears at the end of a journal is likely\n** data that was once in other files that have now been deleted.  If the\n** garbage data came from an obsolete journal file, the checksums might\n** be correct.  But by initializing the checksum to random value which\n** is different for every journal, we minimize that risk.\n*/\nstatic const unsigned char aJournalMagic[] = {\n  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7,\n};\n\n/*\n** The size of the of each page record in the journal is given by\n** the following macro.\n*/\n#define JOURNAL_PG_SZ(pPager)  ((pPager->pageSize) + 8)\n\n/*\n** The journal header size for this pager. This is usually the same \n** size as a single disk sector. See also setSectorSize().\n*/\n#define JOURNAL_HDR_SZ(pPager) (pPager->sectorSize)\n\n/*\n** The macro MEMDB is true if we are dealing with an in-memory database.\n** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,\n** the value of MEMDB will be a constant and the compiler will optimize\n** out code that would never execute.\n*/\n#ifdef SQLITE_OMIT_MEMORYDB\n# define MEMDB 0\n#else\n# define MEMDB pPager->memDb\n#endif\n\n/*\n** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch\n** interfaces to access the database using memory-mapped I/O.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\n# define USEFETCH(x) ((x)->bUseFetch)\n#else\n# define USEFETCH(x) 0\n#endif\n\n/*\n** The maximum legal page number is (2^31 - 1).\n*/\n#define PAGER_MAX_PGNO 2147483647\n\n/*\n** The argument to this macro is a file descriptor (type sqlite3_file*).\n** Return 0 if it is not open, or non-zero (but not 1) if it is.\n**\n** This is so that expressions can be written as:\n**\n**   if( isOpen(pPager->jfd) ){ ...\n**\n** instead of\n**\n**   if( pPager->jfd->pMethods ){ ...\n*/\n#define isOpen(pFd) ((pFd)->pMethods!=0)\n\n/*\n** Return true if this pager uses a write-ahead log to read page pgno.\n** Return false if the pager reads pgno directly from the database.\n*/\n#if !defined(SQLITE_OMIT_WAL) && defined(SQLITE_DIRECT_OVERFLOW_READ)\nSQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager, Pgno pgno){\n  u32 iRead = 0;\n  int rc;\n  if( pPager->pWal==0 ) return 0;\n  rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);\n  return rc || iRead;\n}\n#endif\n#ifndef SQLITE_OMIT_WAL\n# define pagerUseWal(x) ((x)->pWal!=0)\n#else\n# define pagerUseWal(x) 0\n# define pagerRollbackWal(x) 0\n# define pagerWalFrames(v,w,x,y) 0\n# define pagerOpenWalIfPresent(z) SQLITE_OK\n# define pagerBeginReadTransaction(z) SQLITE_OK\n#endif\n\n#ifndef NDEBUG \n/*\n** Usage:\n**\n**   assert( assert_pager_state(pPager) );\n**\n** This function runs many asserts to try to find inconsistencies in\n** the internal state of the Pager object.\n*/\nstatic int assert_pager_state(Pager *p){\n  Pager *pPager = p;\n\n  /* State must be valid. */\n  assert( p->eState==PAGER_OPEN\n       || p->eState==PAGER_READER\n       || p->eState==PAGER_WRITER_LOCKED\n       || p->eState==PAGER_WRITER_CACHEMOD\n       || p->eState==PAGER_WRITER_DBMOD\n       || p->eState==PAGER_WRITER_FINISHED\n       || p->eState==PAGER_ERROR\n  );\n\n  /* Regardless of the current state, a temp-file connection always behaves\n  ** as if it has an exclusive lock on the database file. It never updates\n  ** the change-counter field, so the changeCountDone flag is always set.\n  */\n  assert( p->tempFile==0 || p->eLock==EXCLUSIVE_LOCK );\n  assert( p->tempFile==0 || pPager->changeCountDone );\n\n  /* If the useJournal flag is clear, the journal-mode must be \"OFF\". \n  ** And if the journal-mode is \"OFF\", the journal file must not be open.\n  */\n  assert( p->journalMode==PAGER_JOURNALMODE_OFF || p->useJournal );\n  assert( p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd) );\n\n  /* Check that MEMDB implies noSync. And an in-memory journal. Since \n  ** this means an in-memory pager performs no IO at all, it cannot encounter \n  ** either SQLITE_IOERR or SQLITE_FULL during rollback or while finalizing \n  ** a journal file. (although the in-memory journal implementation may \n  ** return SQLITE_IOERR_NOMEM while the journal file is being written). It \n  ** is therefore not possible for an in-memory pager to enter the ERROR \n  ** state.\n  */\n  if( MEMDB ){\n    assert( !isOpen(p->fd) );\n    assert( p->noSync );\n    assert( p->journalMode==PAGER_JOURNALMODE_OFF \n         || p->journalMode==PAGER_JOURNALMODE_MEMORY \n    );\n    assert( p->eState!=PAGER_ERROR && p->eState!=PAGER_OPEN );\n    assert( pagerUseWal(p)==0 );\n  }\n\n  /* If changeCountDone is set, a RESERVED lock or greater must be held\n  ** on the file.\n  */\n  assert( pPager->changeCountDone==0 || pPager->eLock>=RESERVED_LOCK );\n  assert( p->eLock!=PENDING_LOCK );\n\n  switch( p->eState ){\n    case PAGER_OPEN:\n      assert( !MEMDB );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)==0 || pPager->tempFile );\n      break;\n\n    case PAGER_READER:\n      assert( pPager->errCode==SQLITE_OK );\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( p->eLock>=SHARED_LOCK );\n      break;\n\n    case PAGER_WRITER_LOCKED:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        assert( p->eLock>=RESERVED_LOCK );\n      }\n      assert( pPager->dbSize==pPager->dbOrigSize );\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      assert( pPager->setMaster==0 );\n      break;\n\n    case PAGER_WRITER_CACHEMOD:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        /* It is possible that if journal_mode=wal here that neither the\n        ** journal file nor the WAL file are open. This happens during\n        ** a rollback transaction that switches from journal_mode=off\n        ** to journal_mode=wal.\n        */\n        assert( p->eLock>=RESERVED_LOCK );\n        assert( isOpen(p->jfd) \n             || p->journalMode==PAGER_JOURNALMODE_OFF \n             || p->journalMode==PAGER_JOURNALMODE_WAL \n        );\n      }\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_DBMOD:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( p->eLock>=EXCLUSIVE_LOCK );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      assert( pPager->dbOrigSize<=pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_FINISHED:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      break;\n\n    case PAGER_ERROR:\n      /* There must be at least one outstanding reference to the pager if\n      ** in ERROR state. Otherwise the pager should have already dropped\n      ** back to OPEN state.\n      */\n      assert( pPager->errCode!=SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)>0 || pPager->tempFile );\n      break;\n  }\n\n  return 1;\n}\n#endif /* ifndef NDEBUG */\n\n#ifdef SQLITE_DEBUG \n/*\n** Return a pointer to a human readable string in a static buffer\n** containing the state of the Pager object passed as an argument. This\n** is intended to be used within debuggers. For example, as an alternative\n** to \"print *pPager\" in gdb:\n**\n** (gdb) printf \"%s\", print_pager_state(pPager)\n*/\nstatic char *print_pager_state(Pager *p){\n  static char zRet[1024];\n\n  sqlite3_snprintf(1024, zRet,\n      \"Filename:      %s\\n\"\n      \"State:         %s errCode=%d\\n\"\n      \"Lock:          %s\\n\"\n      \"Locking mode:  locking_mode=%s\\n\"\n      \"Journal mode:  journal_mode=%s\\n\"\n      \"Backing store: tempFile=%d memDb=%d useJournal=%d\\n\"\n      \"Journal:       journalOff=%lld journalHdr=%lld\\n\"\n      \"Size:          dbsize=%d dbOrigSize=%d dbFileSize=%d\\n\"\n      , p->zFilename\n      , p->eState==PAGER_OPEN            ? \"OPEN\" :\n        p->eState==PAGER_READER          ? \"READER\" :\n        p->eState==PAGER_WRITER_LOCKED   ? \"WRITER_LOCKED\" :\n        p->eState==PAGER_WRITER_CACHEMOD ? \"WRITER_CACHEMOD\" :\n        p->eState==PAGER_WRITER_DBMOD    ? \"WRITER_DBMOD\" :\n        p->eState==PAGER_WRITER_FINISHED ? \"WRITER_FINISHED\" :\n        p->eState==PAGER_ERROR           ? \"ERROR\" : \"?error?\"\n      , (int)p->errCode\n      , p->eLock==NO_LOCK         ? \"NO_LOCK\" :\n        p->eLock==RESERVED_LOCK   ? \"RESERVED\" :\n        p->eLock==EXCLUSIVE_LOCK  ? \"EXCLUSIVE\" :\n        p->eLock==SHARED_LOCK     ? \"SHARED\" :\n        p->eLock==UNKNOWN_LOCK    ? \"UNKNOWN\" : \"?error?\"\n      , p->exclusiveMode ? \"exclusive\" : \"normal\"\n      , p->journalMode==PAGER_JOURNALMODE_MEMORY   ? \"memory\" :\n        p->journalMode==PAGER_JOURNALMODE_OFF      ? \"off\" :\n        p->journalMode==PAGER_JOURNALMODE_DELETE   ? \"delete\" :\n        p->journalMode==PAGER_JOURNALMODE_PERSIST  ? \"persist\" :\n        p->journalMode==PAGER_JOURNALMODE_TRUNCATE ? \"truncate\" :\n        p->journalMode==PAGER_JOURNALMODE_WAL      ? \"wal\" : \"?error?\"\n      , (int)p->tempFile, (int)p->memDb, (int)p->useJournal\n      , p->journalOff, p->journalHdr\n      , (int)p->dbSize, (int)p->dbOrigSize, (int)p->dbFileSize\n  );\n\n  return zRet;\n}\n#endif\n\n/* Forward references to the various page getters */\nstatic int getPageNormal(Pager*,Pgno,DbPage**,int);\nstatic int getPageError(Pager*,Pgno,DbPage**,int);\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int getPageMMap(Pager*,Pgno,DbPage**,int);\n#endif\n\n/*\n** Set the Pager.xGet method for the appropriate routine used to fetch\n** content from the pager.\n*/\nstatic void setGetterMethod(Pager *pPager){\n  if( pPager->errCode ){\n    pPager->xGet = getPageError;\n#if SQLITE_MAX_MMAP_SIZE>0\n  }else if( USEFETCH(pPager)\n#ifdef SQLITE_HAS_CODEC\n   && pPager->xCodec==0\n#endif\n  ){\n    pPager->xGet = getPageMMap;\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n  }else{\n    pPager->xGet = getPageNormal;\n  }\n}\n\n/*\n** Return true if it is necessary to write page *pPg into the sub-journal.\n** A page needs to be written into the sub-journal if there exists one\n** or more open savepoints for which:\n**\n**   * The page-number is less than or equal to PagerSavepoint.nOrig, and\n**   * The bit corresponding to the page-number is not set in\n**     PagerSavepoint.pInSavepoint.\n*/\nstatic int subjRequiresPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  PagerSavepoint *p;\n  Pgno pgno = pPg->pgno;\n  int i;\n  for(i=0; i<pPager->nSavepoint; i++){\n    p = &pPager->aSavepoint[i];\n    if( p->nOrig>=pgno && 0==sqlite3BitvecTestNotNull(p->pInSavepoint, pgno) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return true if the page is already in the journal file.\n*/\nstatic int pageInJournal(Pager *pPager, PgHdr *pPg){\n  return sqlite3BitvecTest(pPager->pInJournal, pPg->pgno);\n}\n#endif\n\n/*\n** Read a 32-bit integer from the given file descriptor.  Store the integer\n** that is read in *pRes.  Return SQLITE_OK if everything worked, or an\n** error code is something goes wrong.\n**\n** All values are stored on disk as big-endian.\n*/\nstatic int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){\n  unsigned char ac[4];\n  int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);\n  if( rc==SQLITE_OK ){\n    *pRes = sqlite3Get4byte(ac);\n  }\n  return rc;\n}\n\n/*\n** Write a 32-bit integer into a string buffer in big-endian byte order.\n*/\n#define put32bits(A,B)  sqlite3Put4byte((u8*)A,B)\n\n\n/*\n** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK\n** on success or an error code is something goes wrong.\n*/\nstatic int write32bits(sqlite3_file *fd, i64 offset, u32 val){\n  char ac[4];\n  put32bits(ac, val);\n  return sqlite3OsWrite(fd, ac, 4, offset);\n}\n\n/*\n** Unlock the database file to level eLock, which must be either NO_LOCK\n** or SHARED_LOCK. Regardless of whether or not the call to xUnlock()\n** succeeds, set the Pager.eLock variable to match the (attempted) new lock.\n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is\n** called, do not modify it. See the comment above the #define of \n** UNKNOWN_LOCK for an explanation of this.\n*/\nstatic int pagerUnlockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( !pPager->exclusiveMode || pPager->eLock==eLock );\n  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );\n  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );\n  if( isOpen(pPager->fd) ){\n    assert( pPager->eLock>=eLock );\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsUnlock(pPager->fd, eLock);\n    if( pPager->eLock!=UNKNOWN_LOCK ){\n      pPager->eLock = (u8)eLock;\n    }\n    IOTRACE((\"UNLOCK %p %d\\n\", pPager, eLock))\n  }\n  return rc;\n}\n\n/*\n** Lock the database file to level eLock, which must be either SHARED_LOCK,\n** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the\n** Pager.eLock variable to the new locking state. \n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is \n** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. \n** See the comment above the #define of UNKNOWN_LOCK for an explanation \n** of this.\n*/\nstatic int pagerLockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );\n  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsLock(pPager->fd, eLock);\n    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){\n      pPager->eLock = (u8)eLock;\n      IOTRACE((\"LOCK %p %d\\n\", pPager, eLock))\n    }\n  }\n  return rc;\n}\n\n/*\n** This function determines whether or not the atomic-write or\n** atomic-batch-write optimizations can be used with this pager. The\n** atomic-write optimization can be used if:\n**\n**  (a) the value returned by OsDeviceCharacteristics() indicates that\n**      a database page may be written atomically, and\n**  (b) the value returned by OsSectorSize() is less than or equal\n**      to the page size.\n**\n** If it can be used, then the value returned is the size of the journal \n** file when it contains rollback data for exactly one page.\n**\n** The atomic-batch-write optimization can be used if OsDeviceCharacteristics()\n** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is\n** returned in this case.\n**\n** If neither optimization can be used, 0 is returned.\n*/\nstatic int jrnlBufferSize(Pager *pPager){\n  assert( !MEMDB );\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  int dc;                           /* Device characteristics */\n\n  assert( isOpen(pPager->fd) );\n  dc = sqlite3OsDeviceCharacteristics(pPager->fd);\n#else\n  UNUSED_PARAMETER(pPager);\n#endif\n\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){\n    return -1;\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n  {\n    int nSector = pPager->sectorSize;\n    int szPage = pPager->pageSize;\n\n    assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n    assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n    if( 0==(dc&(SQLITE_IOCAP_ATOMIC|(szPage>>8)) || nSector>szPage) ){\n      return 0;\n    }\n  }\n\n  return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager);\n#endif\n\n  return 0;\n}\n\n/*\n** If SQLITE_CHECK_PAGES is defined then we do some sanity checking\n** on the cache using a hash function.  This is used for testing\n** and debugging only.\n*/\n#ifdef SQLITE_CHECK_PAGES\n/*\n** Return a 32-bit hash of the page data for pPage.\n*/\nstatic u32 pager_datahash(int nByte, unsigned char *pData){\n  u32 hash = 0;\n  int i;\n  for(i=0; i<nByte; i++){\n    hash = (hash*1039) + pData[i];\n  }\n  return hash;\n}\nstatic u32 pager_pagehash(PgHdr *pPage){\n  return pager_datahash(pPage->pPager->pageSize, (unsigned char *)pPage->pData);\n}\nstatic void pager_set_pagehash(PgHdr *pPage){\n  pPage->pageHash = pager_pagehash(pPage);\n}\n\n/*\n** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES\n** is defined, and NDEBUG is not defined, an assert() statement checks\n** that the page is either dirty or still matches the calculated page-hash.\n*/\n#define CHECK_PAGE(x) checkPage(x)\nstatic void checkPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );\n}\n\n#else\n#define pager_datahash(X,Y)  0\n#define pager_pagehash(X)  0\n#define pager_set_pagehash(X)\n#define CHECK_PAGE(x)\n#endif  /* SQLITE_CHECK_PAGES */\n\n/*\n** When this is called the journal file for pager pPager must be open.\n** This function attempts to read a master journal file name from the \n** end of the file and, if successful, copies it into memory supplied \n** by the caller. See comments above writeMasterJournal() for the format\n** used to store a master journal file name at the end of a journal file.\n**\n** zMaster must point to a buffer of at least nMaster bytes allocated by\n** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is\n** enough space to write the master journal name). If the master journal\n** name in the journal is longer than nMaster bytes (including a\n** nul-terminator), then this is handled as if no master journal name\n** were present in the journal.\n**\n** If a master journal file name is present at the end of the journal\n** file, then it is copied into the buffer pointed to by zMaster. A\n** nul-terminator byte is appended to the buffer following the master\n** journal file name.\n**\n** If it is determined that no master journal file name is present \n** zMaster[0] is set to 0 and SQLITE_OK returned.\n**\n** If an error occurs while reading from the journal file, an SQLite\n** error code is returned.\n*/\nstatic int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){\n  int rc;                    /* Return code */\n  u32 len;                   /* Length in bytes of master journal name */\n  i64 szJ;                   /* Total size in bytes of journal file pJrnl */\n  u32 cksum;                 /* MJ checksum value read from journal */\n  u32 u;                     /* Unsigned loop counter */\n  unsigned char aMagic[8];   /* A buffer to hold the magic header */\n  zMaster[0] = '\\0';\n\n  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))\n   || szJ<16\n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))\n   || len>=nMaster \n   || len>szJ-16\n   || len==0 \n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))\n   || memcmp(aMagic, aJournalMagic, 8)\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))\n  ){\n    return rc;\n  }\n\n  /* See if the checksum matches the master journal name */\n  for(u=0; u<len; u++){\n    cksum -= zMaster[u];\n  }\n  if( cksum ){\n    /* If the checksum doesn't add up, then one or more of the disk sectors\n    ** containing the master journal filename is corrupted. This means\n    ** definitely roll back, so just return SQLITE_OK and report a (nul)\n    ** master-journal filename.\n    */\n    len = 0;\n  }\n  zMaster[len] = '\\0';\n   \n  return SQLITE_OK;\n}\n\n/*\n** Return the offset of the sector boundary at or immediately \n** following the value in pPager->journalOff, assuming a sector \n** size of pPager->sectorSize bytes.\n**\n** i.e for a sector size of 512:\n**\n**   Pager.journalOff          Return value\n**   ---------------------------------------\n**   0                         0\n**   512                       512\n**   100                       512\n**   2000                      2048\n** \n*/\nstatic i64 journalHdrOffset(Pager *pPager){\n  i64 offset = 0;\n  i64 c = pPager->journalOff;\n  if( c ){\n    offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);\n  }\n  assert( offset%JOURNAL_HDR_SZ(pPager)==0 );\n  assert( offset>=c );\n  assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );\n  return offset;\n}\n\n/*\n** The journal file must be open when this function is called.\n**\n** This function is a no-op if the journal file has not been written to\n** within the current transaction (i.e. if Pager.journalOff==0).\n**\n** If doTruncate is non-zero or the Pager.journalSizeLimit variable is\n** set to 0, then truncate the journal file to zero bytes in size. Otherwise,\n** zero the 28-byte header at the start of the journal file. In either case, \n** if the pager is not in no-sync mode, sync the journal file immediately \n** after writing or truncating it.\n**\n** If Pager.journalSizeLimit is set to a positive, non-zero value, and\n** following the truncation or zeroing described above the size of the \n** journal file in bytes is larger than this value, then truncate the\n** journal file to Pager.journalSizeLimit bytes. The journal file does\n** not need to be synced following this operation.\n**\n** If an IO error occurs, abandon processing and return the IO error code.\n** Otherwise, return SQLITE_OK.\n*/\nstatic int zeroJournalHdr(Pager *pPager, int doTruncate){\n  int rc = SQLITE_OK;                               /* Return code */\n  assert( isOpen(pPager->jfd) );\n  assert( !sqlite3JournalIsInMemory(pPager->jfd) );\n  if( pPager->journalOff ){\n    const i64 iLimit = pPager->journalSizeLimit;    /* Local cache of jsl */\n\n    IOTRACE((\"JZEROHDR %p\\n\", pPager))\n    if( doTruncate || iLimit==0 ){\n      rc = sqlite3OsTruncate(pPager->jfd, 0);\n    }else{\n      static const char zeroHdr[28] = {0};\n      rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);\n    }\n    if( rc==SQLITE_OK && !pPager->noSync ){\n      rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);\n    }\n\n    /* At this point the transaction is committed but the write lock \n    ** is still held on the file. If there is a size limit configured for \n    ** the persistent journal and the journal file currently consumes more\n    ** space than that limit allows for, truncate it now. There is no need\n    ** to sync the file following this operation.\n    */\n    if( rc==SQLITE_OK && iLimit>0 ){\n      i64 sz;\n      rc = sqlite3OsFileSize(pPager->jfd, &sz);\n      if( rc==SQLITE_OK && sz>iLimit ){\n        rc = sqlite3OsTruncate(pPager->jfd, iLimit);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The journal file must be open when this routine is called. A journal\n** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the\n** current location.\n**\n** The format for the journal header is as follows:\n** - 8 bytes: Magic identifying journal format.\n** - 4 bytes: Number of records in journal, or -1 no-sync mode is on.\n** - 4 bytes: Random number used for page hash.\n** - 4 bytes: Initial database page count.\n** - 4 bytes: Sector size used by the process that wrote this journal.\n** - 4 bytes: Database page size.\n** \n** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.\n*/\nstatic int writeJournalHdr(Pager *pPager){\n  int rc = SQLITE_OK;                 /* Return code */\n  char *zHeader = pPager->pTmpSpace;  /* Temporary space used to build header */\n  u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */\n  u32 nWrite;                         /* Bytes of header sector written */\n  int ii;                             /* Loop counter */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  if( nHeader>JOURNAL_HDR_SZ(pPager) ){\n    nHeader = JOURNAL_HDR_SZ(pPager);\n  }\n\n  /* If there are active savepoints and any of them were created \n  ** since the most recent journal header was written, update the \n  ** PagerSavepoint.iHdrOffset fields now.\n  */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    if( pPager->aSavepoint[ii].iHdrOffset==0 ){\n      pPager->aSavepoint[ii].iHdrOffset = pPager->journalOff;\n    }\n  }\n\n  pPager->journalHdr = pPager->journalOff = journalHdrOffset(pPager);\n\n  /* \n  ** Write the nRec Field - the number of page records that follow this\n  ** journal header. Normally, zero is written to this value at this time.\n  ** After the records are added to the journal (and the journal synced, \n  ** if in full-sync mode), the zero is overwritten with the true number\n  ** of records (see syncJournal()).\n  **\n  ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When\n  ** reading the journal this value tells SQLite to assume that the\n  ** rest of the journal file contains valid page records. This assumption\n  ** is dangerous, as if a failure occurred whilst writing to the journal\n  ** file it may contain some garbage data. There are two scenarios\n  ** where this risk can be ignored:\n  **\n  **   * When the pager is in no-sync mode. Corruption can follow a\n  **     power failure in this case anyway.\n  **\n  **   * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees\n  **     that garbage data is never appended to the journal file.\n  */\n  assert( isOpen(pPager->fd) || pPager->noSync );\n  if( pPager->noSync || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)\n   || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND) \n  ){\n    memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n    put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff);\n  }else{\n    memset(zHeader, 0, sizeof(aJournalMagic)+4);\n  }\n\n  /* The random check-hash initializer */ \n  sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);\n  put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);\n  /* The initial database size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);\n  /* The assumed sector size for this process */\n  put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);\n\n  /* The page size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);\n\n  /* Initializing the tail of the buffer is not necessary.  Everything\n  ** works find if the following memset() is omitted.  But initializing\n  ** the memory prevents valgrind from complaining, so we are willing to\n  ** take the performance hit.\n  */\n  memset(&zHeader[sizeof(aJournalMagic)+20], 0,\n         nHeader-(sizeof(aJournalMagic)+20));\n\n  /* In theory, it is only necessary to write the 28 bytes that the \n  ** journal header consumes to the journal file here. Then increment the \n  ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next \n  ** record is written to the following sector (leaving a gap in the file\n  ** that will be implicitly filled in by the OS).\n  **\n  ** However it has been discovered that on some systems this pattern can \n  ** be significantly slower than contiguously writing data to the file,\n  ** even if that means explicitly writing data to the block of \n  ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what\n  ** is done. \n  **\n  ** The loop is required here in case the sector-size is larger than the \n  ** database page size. Since the zHeader buffer is only Pager.pageSize\n  ** bytes in size, more than one call to sqlite3OsWrite() may be required\n  ** to populate the entire journal header sector.\n  */ \n  for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){\n    IOTRACE((\"JHDR %p %lld %d\\n\", pPager, pPager->journalHdr, nHeader))\n    rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);\n    assert( pPager->journalHdr <= pPager->journalOff );\n    pPager->journalOff += nHeader;\n  }\n\n  return rc;\n}\n\n/*\n** The journal file must be open when this is called. A journal header file\n** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal\n** file. The current location in the journal file is given by\n** pPager->journalOff. See comments above function writeJournalHdr() for\n** a description of the journal header format.\n**\n** If the header is read successfully, *pNRec is set to the number of\n** page records following this header and *pDbSize is set to the size of the\n** database before the transaction began, in pages. Also, pPager->cksumInit\n** is set to the value read from the journal header. SQLITE_OK is returned\n** in this case.\n**\n** If the journal header file appears to be corrupted, SQLITE_DONE is\n** returned and *pNRec and *PDbSize are undefined.  If JOURNAL_HDR_SZ bytes\n** cannot be read from the journal file an error code is returned.\n*/\nstatic int readJournalHdr(\n  Pager *pPager,               /* Pager object */\n  int isHot,\n  i64 journalSize,             /* Size of the open journal file in bytes */\n  u32 *pNRec,                  /* OUT: Value read from the nRec field */\n  u32 *pDbSize                 /* OUT: Value of original database size field */\n){\n  int rc;                      /* Return code */\n  unsigned char aMagic[8];     /* A buffer to hold the magic header */\n  i64 iHdrOff;                 /* Offset of journal header being read */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  /* Advance Pager.journalOff to the start of the next sector. If the\n  ** journal file is too small for there to be a header stored at this\n  ** point, return SQLITE_DONE.\n  */\n  pPager->journalOff = journalHdrOffset(pPager);\n  if( pPager->journalOff+JOURNAL_HDR_SZ(pPager) > journalSize ){\n    return SQLITE_DONE;\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Read in the first 8 bytes of the journal header. If they do not match\n  ** the  magic string found at the start of each journal header, return\n  ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,\n  ** proceed.\n  */\n  if( isHot || iHdrOff!=pPager->journalHdr ){\n    rc = sqlite3OsRead(pPager->jfd, aMagic, sizeof(aMagic), iHdrOff);\n    if( rc ){\n      return rc;\n    }\n    if( memcmp(aMagic, aJournalMagic, sizeof(aMagic))!=0 ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* Read the first three 32-bit fields of the journal header: The nRec\n  ** field, the checksum-initializer and the database size at the start\n  ** of the transaction. Return an error code if anything goes wrong.\n  */\n  if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+8, pNRec))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+12, &pPager->cksumInit))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+16, pDbSize))\n  ){\n    return rc;\n  }\n\n  if( pPager->journalOff==0 ){\n    u32 iPageSize;               /* Page-size field of journal header */\n    u32 iSectorSize;             /* Sector-size field of journal header */\n\n    /* Read the page-size and sector-size journal header fields. */\n    if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))\n     || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+24, &iPageSize))\n    ){\n      return rc;\n    }\n\n    /* Versions of SQLite prior to 3.5.8 set the page-size field of the\n    ** journal header to zero. In this case, assume that the Pager.pageSize\n    ** variable is already set to the correct page size.\n    */\n    if( iPageSize==0 ){\n      iPageSize = pPager->pageSize;\n    }\n\n    /* Check that the values read from the page-size and sector-size fields\n    ** are within range. To be 'in range', both values need to be a power\n    ** of two greater than or equal to 512 or 32, and not greater than their \n    ** respective compile time maximum limits.\n    */\n    if( iPageSize<512                  || iSectorSize<32\n     || iPageSize>SQLITE_MAX_PAGE_SIZE || iSectorSize>MAX_SECTOR_SIZE\n     || ((iPageSize-1)&iPageSize)!=0   || ((iSectorSize-1)&iSectorSize)!=0 \n    ){\n      /* If the either the page-size or sector-size in the journal-header is \n      ** invalid, then the process that wrote the journal-header must have \n      ** crashed before the header was synced. In this case stop reading \n      ** the journal file here.\n      */\n      return SQLITE_DONE;\n    }\n\n    /* Update the page-size to match the value read from the journal. \n    ** Use a testcase() macro to make sure that malloc failure within \n    ** PagerSetPagesize() is tested.\n    */\n    rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);\n    testcase( rc!=SQLITE_OK );\n\n    /* Update the assumed sector-size to match the value used by \n    ** the process that created this journal. If this journal was\n    ** created by a process other than this one, then this routine\n    ** is being called from within pager_playback(). The local value\n    ** of Pager.sectorSize is restored at the end of that routine.\n    */\n    pPager->sectorSize = iSectorSize;\n  }\n\n  pPager->journalOff += JOURNAL_HDR_SZ(pPager);\n  return rc;\n}\n\n\n/*\n** Write the supplied master journal name into the journal file for pager\n** pPager at the current location. The master journal name must be the last\n** thing written to a journal file. If the pager is in full-sync mode, the\n** journal file descriptor is advanced to the next sector boundary before\n** anything is written. The format is:\n**\n**   + 4 bytes: PAGER_MJ_PGNO.\n**   + N bytes: Master journal filename in utf-8.\n**   + 4 bytes: N (length of master journal name in bytes, no nul-terminator).\n**   + 4 bytes: Master journal name checksum.\n**   + 8 bytes: aJournalMagic[].\n**\n** The master journal page checksum is the sum of the bytes in the master\n** journal name, where each byte is interpreted as a signed 8-bit integer.\n**\n** If zMaster is a NULL pointer (occurs for a single database transaction), \n** this call is a no-op.\n*/\nstatic int writeMasterJournal(Pager *pPager, const char *zMaster){\n  int rc;                          /* Return code */\n  int nMaster;                     /* Length of string zMaster */\n  i64 iHdrOff;                     /* Offset of header in journal file */\n  i64 jrnlSize;                    /* Size of journal file on disk */\n  u32 cksum = 0;                   /* Checksum of string zMaster */\n\n  assert( pPager->setMaster==0 );\n  assert( !pagerUseWal(pPager) );\n\n  if( !zMaster \n   || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n   || !isOpen(pPager->jfd)\n  ){\n    return SQLITE_OK;\n  }\n  pPager->setMaster = 1;\n  assert( pPager->journalHdr <= pPager->journalOff );\n\n  /* Calculate the length in bytes and the checksum of zMaster */\n  for(nMaster=0; zMaster[nMaster]; nMaster++){\n    cksum += zMaster[nMaster];\n  }\n\n  /* If in full-sync mode, advance to the next disk sector before writing\n  ** the master journal name. This is in case the previous page written to\n  ** the journal has already been synced.\n  */\n  if( pPager->fullSync ){\n    pPager->journalOff = journalHdrOffset(pPager);\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Write the master journal data to the end of the journal file. If\n  ** an error occurs, return the error code to the caller.\n  */\n  if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, zMaster, nMaster, iHdrOff+4)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster, nMaster)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster+4, cksum)))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,\n                                 iHdrOff+4+nMaster+8)))\n  ){\n    return rc;\n  }\n  pPager->journalOff += (nMaster+20);\n\n  /* If the pager is in peristent-journal mode, then the physical \n  ** journal-file may extend past the end of the master-journal name\n  ** and 8 bytes of magic data just written to the file. This is \n  ** dangerous because the code to rollback a hot-journal file\n  ** will not be able to find the master-journal name to determine \n  ** whether or not the journal is hot. \n  **\n  ** Easiest thing to do in this scenario is to truncate the journal \n  ** file to the required size.\n  */ \n  if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))\n   && jrnlSize>pPager->journalOff\n  ){\n    rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);\n  }\n  return rc;\n}\n\n/*\n** Discard the entire contents of the in-memory page-cache.\n*/\nstatic void pager_reset(Pager *pPager){\n  pPager->iDataVersion++;\n  sqlite3BackupRestart(pPager->pBackup);\n  sqlite3PcacheClear(pPager->pPCache);\n}\n\n/*\n** Return the pPager->iDataVersion value\n*/\nSQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){\n  assert( pPager->eState>PAGER_OPEN );\n  return pPager->iDataVersion;\n}\n\n/*\n** Free all structures in the Pager.aSavepoint[] array and set both\n** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal\n** if it is open and the pager is not in exclusive mode.\n*/\nstatic void releaseAllSavepoints(Pager *pPager){\n  int ii;               /* Iterator for looping through Pager.aSavepoint */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n  }\n  if( !pPager->exclusiveMode || sqlite3JournalIsInMemory(pPager->sjfd) ){\n    sqlite3OsClose(pPager->sjfd);\n  }\n  sqlite3_free(pPager->aSavepoint);\n  pPager->aSavepoint = 0;\n  pPager->nSavepoint = 0;\n  pPager->nSubRec = 0;\n}\n\n/*\n** Set the bit number pgno in the PagerSavepoint.pInSavepoint \n** bitvecs of all open savepoints. Return SQLITE_OK if successful\n** or SQLITE_NOMEM if a malloc failure occurs.\n*/\nstatic int addToSavepointBitvecs(Pager *pPager, Pgno pgno){\n  int ii;                   /* Loop counter */\n  int rc = SQLITE_OK;       /* Result code */\n\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    PagerSavepoint *p = &pPager->aSavepoint[ii];\n    if( pgno<=p->nOrig ){\n      rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);\n      testcase( rc==SQLITE_NOMEM );\n      assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if the pager is in exclusive mode and not\n** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN\n** state.\n**\n** If the pager is not in exclusive-access mode, the database file is\n** completely unlocked. If the file is unlocked and the file-system does\n** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is\n** closed (if it is open).\n**\n** If the pager is in ERROR state when this function is called, the \n** contents of the pager cache are discarded before switching back to \n** the OPEN state. Regardless of whether the pager is in exclusive-mode\n** or not, any journal file left in the file-system will be treated\n** as a hot-journal and rolled back the next time a read-transaction\n** is opened (by this or by any other connection).\n*/\nstatic void pager_unlock(Pager *pPager){\n\n  assert( pPager->eState==PAGER_READER \n       || pPager->eState==PAGER_OPEN \n       || pPager->eState==PAGER_ERROR \n  );\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  releaseAllSavepoints(pPager);\n\n  if( pagerUseWal(pPager) ){\n    assert( !isOpen(pPager->jfd) );\n    sqlite3WalEndReadTransaction(pPager->pWal);\n    pPager->eState = PAGER_OPEN;\n  }else if( !pPager->exclusiveMode ){\n    int rc;                       /* Error code returned by pagerUnlockDb() */\n    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;\n\n    /* If the operating system support deletion of open files, then\n    ** close the journal file when dropping the database lock.  Otherwise\n    ** another connection with journal_mode=delete might delete the file\n    ** out from under us.\n    */\n    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );\n    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)\n     || 1!=(pPager->journalMode & 5)\n    ){\n      sqlite3OsClose(pPager->jfd);\n    }\n\n    /* If the pager is in the ERROR state and the call to unlock the database\n    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment\n    ** above the #define for UNKNOWN_LOCK for an explanation of why this\n    ** is necessary.\n    */\n    rc = pagerUnlockDb(pPager, NO_LOCK);\n    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){\n      pPager->eLock = UNKNOWN_LOCK;\n    }\n\n    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here\n    ** without clearing the error code. This is intentional - the error\n    ** code is cleared and the cache reset in the block below.\n    */\n    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );\n    pPager->changeCountDone = 0;\n    pPager->eState = PAGER_OPEN;\n  }\n\n  /* If Pager.errCode is set, the contents of the pager cache cannot be\n  ** trusted. Now that there are no outstanding references to the pager,\n  ** it can safely move back to PAGER_OPEN state. This happens in both\n  ** normal and exclusive-locking mode.\n  */\n  assert( pPager->errCode==SQLITE_OK || !MEMDB );\n  if( pPager->errCode ){\n    if( pPager->tempFile==0 ){\n      pager_reset(pPager);\n      pPager->changeCountDone = 0;\n      pPager->eState = PAGER_OPEN;\n    }else{\n      pPager->eState = (isOpen(pPager->jfd) ? PAGER_OPEN : PAGER_READER);\n    }\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n    pPager->errCode = SQLITE_OK;\n    setGetterMethod(pPager);\n  }\n\n  pPager->journalOff = 0;\n  pPager->journalHdr = 0;\n  pPager->setMaster = 0;\n}\n\n/*\n** This function is called whenever an IOERR or FULL error that requires\n** the pager to transition into the ERROR state may ahve occurred.\n** The first argument is a pointer to the pager structure, the second \n** the error-code about to be returned by a pager API function. The \n** value returned is a copy of the second argument to this function. \n**\n** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the\n** IOERR sub-codes, the pager enters the ERROR state and the error code\n** is stored in Pager.errCode. While the pager remains in the ERROR state,\n** all major API calls on the Pager will immediately return Pager.errCode.\n**\n** The ERROR state indicates that the contents of the pager-cache \n** cannot be trusted. This state can be cleared by completely discarding \n** the contents of the pager-cache. If a transaction was active when\n** the persistent error occurred, then the rollback journal may need\n** to be replayed to restore the contents of the database file (as if\n** it were a hot-journal).\n*/\nstatic int pager_error(Pager *pPager, int rc){\n  int rc2 = rc & 0xff;\n  assert( rc==SQLITE_OK || !MEMDB );\n  assert(\n       pPager->errCode==SQLITE_FULL ||\n       pPager->errCode==SQLITE_OK ||\n       (pPager->errCode & 0xff)==SQLITE_IOERR\n  );\n  if( rc2==SQLITE_FULL || rc2==SQLITE_IOERR ){\n    pPager->errCode = rc;\n    pPager->eState = PAGER_ERROR;\n    setGetterMethod(pPager);\n  }\n  return rc;\n}\n\nstatic int pager_truncate(Pager *pPager, Pgno nPage);\n\n/*\n** The write transaction open on pPager is being committed (bCommit==1)\n** or rolled back (bCommit==0).\n**\n** Return TRUE if and only if all dirty pages should be flushed to disk.\n**\n** Rules:\n**\n**   *  For non-TEMP databases, always sync to disk.  This is necessary\n**      for transactions to be durable.\n**\n**   *  Sync TEMP database only on a COMMIT (not a ROLLBACK) when the backing\n**      file has been created already (via a spill on pagerStress()) and\n**      when the number of dirty pages in memory exceeds 25% of the total\n**      cache size.\n*/\nstatic int pagerFlushOnCommit(Pager *pPager, int bCommit){\n  if( pPager->tempFile==0 ) return 1;\n  if( !bCommit ) return 0;\n  if( !isOpen(pPager->fd) ) return 0;\n  return (sqlite3PCachePercentDirty(pPager->pPCache)>=25);\n}\n\n/*\n** This routine ends a transaction. A transaction is usually ended by \n** either a COMMIT or a ROLLBACK operation. This routine may be called \n** after rollback of a hot-journal, or if an error occurs while opening\n** the journal file or writing the very first journal-header of a\n** database transaction.\n** \n** This routine is never called in PAGER_ERROR state. If it is called\n** in PAGER_NONE or PAGER_SHARED state and the lock held is less\n** exclusive than a RESERVED lock, it is a no-op.\n**\n** Otherwise, any active savepoints are released.\n**\n** If the journal file is open, then it is \"finalized\". Once a journal \n** file has been finalized it is not possible to use it to roll back a \n** transaction. Nor will it be considered to be a hot-journal by this\n** or any other database connection. Exactly how a journal is finalized\n** depends on whether or not the pager is running in exclusive mode and\n** the current journal-mode (Pager.journalMode value), as follows:\n**\n**   journalMode==MEMORY\n**     Journal file descriptor is simply closed. This destroys an \n**     in-memory journal.\n**\n**   journalMode==TRUNCATE\n**     Journal file is truncated to zero bytes in size.\n**\n**   journalMode==PERSIST\n**     The first 28 bytes of the journal file are zeroed. This invalidates\n**     the first journal header in the file, and hence the entire journal\n**     file. An invalid journal file cannot be rolled back.\n**\n**   journalMode==DELETE\n**     The journal file is closed and deleted using sqlite3OsDelete().\n**\n**     If the pager is running in exclusive mode, this method of finalizing\n**     the journal file is never used. Instead, if the journalMode is\n**     DELETE and the pager is in exclusive mode, the method described under\n**     journalMode==PERSIST is used instead.\n**\n** After the journal is finalized, the pager moves to PAGER_READER state.\n** If running in non-exclusive rollback mode, the lock on the file is \n** downgraded to a SHARED_LOCK.\n**\n** SQLITE_OK is returned if no error occurs. If an error occurs during\n** any of the IO operations to finalize the journal file or unlock the\n** database then the IO error code is returned to the user. If the \n** operation to finalize the journal file fails, then the code still\n** tries to unlock the database file if not in exclusive mode. If the\n** unlock operation fails as well, then the first error code related\n** to the first error encountered (the journal finalization one) is\n** returned.\n*/\nstatic int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){\n  int rc = SQLITE_OK;      /* Error code from journal finalization operation */\n  int rc2 = SQLITE_OK;     /* Error code from db file unlock operation */\n\n  /* Do nothing if the pager does not have an open write transaction\n  ** or at least a RESERVED lock. This function may be called when there\n  ** is no write-transaction active but a RESERVED or greater lock is\n  ** held under two circumstances:\n  **\n  **   1. After a successful hot-journal rollback, it is called with\n  **      eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK.\n  **\n  **   2. If a connection with locking_mode=exclusive holding an EXCLUSIVE \n  **      lock switches back to locking_mode=normal and then executes a\n  **      read-transaction, this function is called with eState==PAGER_READER \n  **      and eLock==EXCLUSIVE_LOCK when the read-transaction is closed.\n  */\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState!=PAGER_ERROR );\n  if( pPager->eState<PAGER_WRITER_LOCKED && pPager->eLock<RESERVED_LOCK ){\n    return SQLITE_OK;\n  }\n\n  releaseAllSavepoints(pPager);\n  assert( isOpen(pPager->jfd) || pPager->pInJournal==0 \n      || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n  );\n  if( isOpen(pPager->jfd) ){\n    assert( !pagerUseWal(pPager) );\n\n    /* Finalize the journal file. */\n    if( sqlite3JournalIsInMemory(pPager->jfd) ){\n      /* assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); */\n      sqlite3OsClose(pPager->jfd);\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_TRUNCATE ){\n      if( pPager->journalOff==0 ){\n        rc = SQLITE_OK;\n      }else{\n        rc = sqlite3OsTruncate(pPager->jfd, 0);\n        if( rc==SQLITE_OK && pPager->fullSync ){\n          /* Make sure the new file size is written into the inode right away.\n          ** Otherwise the journal might resurrect following a power loss and\n          ** cause the last transaction to roll back.  See\n          ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773\n          */\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n        }\n      }\n      pPager->journalOff = 0;\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)\n    ){\n      rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);\n      pPager->journalOff = 0;\n    }else{\n      /* This branch may be executed with Pager.journalMode==MEMORY if\n      ** a hot-journal was just rolled back. In this case the journal\n      ** file should be closed and deleted. If this connection writes to\n      ** the database file, it will do so using an in-memory journal.\n      */\n      int bDelete = !pPager->tempFile;\n      assert( sqlite3JournalIsInMemory(pPager->jfd)==0 );\n      assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE \n           || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n           || pPager->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      sqlite3OsClose(pPager->jfd);\n      if( bDelete ){\n        rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, pPager->extraSync);\n      }\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);\n  if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){\n    PgHdr *p = sqlite3PagerLookup(pPager, 1);\n    if( p ){\n      p->pageHash = 0;\n      sqlite3PagerUnrefNotNull(p);\n    }\n  }\n#endif\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  pPager->nRec = 0;\n  if( rc==SQLITE_OK ){\n    if( MEMDB || pagerFlushOnCommit(pPager, bCommit) ){\n      sqlite3PcacheCleanAll(pPager->pPCache);\n    }else{\n      sqlite3PcacheClearWritable(pPager->pPCache);\n    }\n    sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);\n  }\n\n  if( pagerUseWal(pPager) ){\n    /* Drop the WAL write-lock, if any. Also, if the connection was in \n    ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE \n    ** lock held on the database file.\n    */\n    rc2 = sqlite3WalEndWriteTransaction(pPager->pWal);\n    assert( rc2==SQLITE_OK );\n  }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){\n    /* This branch is taken when committing a transaction in rollback-journal\n    ** mode if the database file on disk is larger than the database image.\n    ** At this point the journal has been finalized and the transaction \n    ** successfully committed, but the EXCLUSIVE lock is still held on the\n    ** file. So it is safe to truncate the database file to its minimum\n    ** required size.  */\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    rc = pager_truncate(pPager, pPager->dbSize);\n  }\n\n  if( rc==SQLITE_OK && bCommit && isOpen(pPager->fd) ){\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  }\n\n  if( !pPager->exclusiveMode \n   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))\n  ){\n    rc2 = pagerUnlockDb(pPager, SHARED_LOCK);\n    pPager->changeCountDone = 0;\n  }\n  pPager->eState = PAGER_READER;\n  pPager->setMaster = 0;\n\n  return (rc==SQLITE_OK?rc2:rc);\n}\n\n/*\n** Execute a rollback if a transaction is active and unlock the \n** database file. \n**\n** If the pager has already entered the ERROR state, do not attempt \n** the rollback at this time. Instead, pager_unlock() is called. The\n** call to pager_unlock() will discard all in-memory pages, unlock\n** the database file and move the pager back to OPEN state. If this \n** means that there is a hot-journal left in the file-system, the next \n** connection to obtain a shared lock on the pager (which may be this one) \n** will roll it back.\n**\n** If the pager has not already entered the ERROR state, but an IO or\n** malloc error occurs during a rollback, then this will itself cause \n** the pager to enter the ERROR state. Which will be cleared by the\n** call to pager_unlock(), as described above.\n*/\nstatic void pagerUnlockAndRollback(Pager *pPager){\n  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){\n    assert( assert_pager_state(pPager) );\n    if( pPager->eState>=PAGER_WRITER_LOCKED ){\n      sqlite3BeginBenignMalloc();\n      sqlite3PagerRollback(pPager);\n      sqlite3EndBenignMalloc();\n    }else if( !pPager->exclusiveMode ){\n      assert( pPager->eState==PAGER_READER );\n      pager_end_transaction(pPager, 0, 0);\n    }\n  }\n  pager_unlock(pPager);\n}\n\n/*\n** Parameter aData must point to a buffer of pPager->pageSize bytes\n** of data. Compute and return a checksum based ont the contents of the \n** page of data and the current value of pPager->cksumInit.\n**\n** This is not a real checksum. It is really just the sum of the \n** random initial value (pPager->cksumInit) and every 200th byte\n** of the page data, starting with byte offset (pPager->pageSize%200).\n** Each byte is interpreted as an 8-bit unsigned integer.\n**\n** Changing the formula used to compute this checksum results in an\n** incompatible journal file format.\n**\n** If journal corruption occurs due to a power failure, the most likely \n** scenario is that one end or the other of the record will be changed. \n** It is much less likely that the two ends of the journal record will be\n** correct and the middle be corrupt.  Thus, this \"checksum\" scheme,\n** though fast and simple, catches the mostly likely kind of corruption.\n*/\nstatic u32 pager_cksum(Pager *pPager, const u8 *aData){\n  u32 cksum = pPager->cksumInit;         /* Checksum value to return */\n  int i = pPager->pageSize-200;          /* Loop counter */\n  while( i>0 ){\n    cksum += aData[i];\n    i -= 200;\n  }\n  return cksum;\n}\n\n/*\n** Report the current page size and number of reserved bytes back\n** to the codec.\n*/\n#ifdef SQLITE_HAS_CODEC\nstatic void pagerReportSize(Pager *pPager){\n  if( pPager->xCodecSizeChng ){\n    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,\n                           (int)pPager->nReserve);\n  }\n}\n#else\n# define pagerReportSize(X)     /* No-op if we do not support a codec */\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Make sure the number of reserved bits is the same in the destination\n** pager as it is in the source.  This comes up when a VACUUM changes the\n** number of reserved bits to the \"optimal\" amount.\n*/\nSQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager *pDest, Pager *pSrc){\n  if( pDest->nReserve!=pSrc->nReserve ){\n    pDest->nReserve = pSrc->nReserve;\n    pagerReportSize(pDest);\n  }\n}\n#endif\n\n/*\n** Read a single page from either the journal file (if isMainJrnl==1) or\n** from the sub-journal (if isMainJrnl==0) and playback that page.\n** The page begins at offset *pOffset into the file. The *pOffset\n** value is increased to the start of the next page in the journal.\n**\n** The main rollback journal uses checksums - the statement journal does \n** not.\n**\n** If the page number of the page record read from the (sub-)journal file\n** is greater than the current value of Pager.dbSize, then playback is\n** skipped and SQLITE_OK is returned.\n**\n** If pDone is not NULL, then it is a record of pages that have already\n** been played back.  If the page at *pOffset has already been played back\n** (if the corresponding pDone bit is set) then skip the playback.\n** Make sure the pDone bit corresponding to the *pOffset page is set\n** prior to returning.\n**\n** If the page record is successfully read from the (sub-)journal file\n** and played back, then SQLITE_OK is returned. If an IO error occurs\n** while reading the record from the (sub-)journal file or while writing\n** to the database file, then the IO error code is returned. If data\n** is successfully read from the (sub-)journal file but appears to be\n** corrupted, SQLITE_DONE is returned. Data is considered corrupted in\n** two circumstances:\n** \n**   * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or\n**   * If the record is being rolled back from the main journal file\n**     and the checksum field does not match the record content.\n**\n** Neither of these two scenarios are possible during a savepoint rollback.\n**\n** If this is a savepoint rollback, then memory may have to be dynamically\n** allocated by this function. If this is the case and an allocation fails,\n** SQLITE_NOMEM is returned.\n*/\nstatic int pager_playback_one_page(\n  Pager *pPager,                /* The pager being played back */\n  i64 *pOffset,                 /* Offset of record to playback */\n  Bitvec *pDone,                /* Bitvec of pages already played back */\n  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */\n  int isSavepnt                 /* True for a savepoint rollback */\n){\n  int rc;\n  PgHdr *pPg;                   /* An existing page in the cache */\n  Pgno pgno;                    /* The page number of a page in journal */\n  u32 cksum;                    /* Checksum used for sanity checking */\n  char *aData;                  /* Temporary storage for the page */\n  sqlite3_file *jfd;            /* The file descriptor for the journal file */\n  int isSynced;                 /* True if journal page is synced */\n#ifdef SQLITE_HAS_CODEC\n  /* The jrnlEnc flag is true if Journal pages should be passed through\n  ** the codec.  It is false for pure in-memory journals. */\n  const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0);\n#endif\n\n  assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */\n  assert( (isSavepnt&~1)==0 );       /* isSavepnt is 0 or 1 */\n  assert( isMainJrnl || pDone );     /* pDone always used on sub-journals */\n  assert( isSavepnt || pDone==0 );   /* pDone never used on non-savepoint */\n\n  aData = pPager->pTmpSpace;\n  assert( aData );         /* Temp storage must have already been allocated */\n  assert( pagerUseWal(pPager)==0 || (!isMainJrnl && isSavepnt) );\n\n  /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction \n  ** or savepoint rollback done at the request of the caller) or this is\n  ** a hot-journal rollback. If it is a hot-journal rollback, the pager\n  ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback\n  ** only reads from the main journal, not the sub-journal.\n  */\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD\n       || (pPager->eState==PAGER_OPEN && pPager->eLock==EXCLUSIVE_LOCK)\n  );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD || isMainJrnl );\n\n  /* Read the page number and page data from the journal or sub-journal\n  ** file. Return an error code to the caller if an IO error occurs.\n  */\n  jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;\n  rc = read32bits(jfd, *pOffset, &pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);\n  if( rc!=SQLITE_OK ) return rc;\n  *pOffset += pPager->pageSize + 4 + isMainJrnl*4;\n\n  /* Sanity checking on the page.  This is more important that I originally\n  ** thought.  If a power failure occurs while the journal is being written,\n  ** it could cause invalid data to be written into the journal.  We need to\n  ** detect this invalid data (with high probability) and ignore it.\n  */\n  if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){\n    assert( !isSavepnt );\n    return SQLITE_DONE;\n  }\n  if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){\n    return SQLITE_OK;\n  }\n  if( isMainJrnl ){\n    rc = read32bits(jfd, (*pOffset)-4, &cksum);\n    if( rc ) return rc;\n    if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If this page has already been played back before during the current\n  ** rollback, then don't bother to play it back again.\n  */\n  if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* When playing back page 1, restore the nReserve setting\n  */\n  if( pgno==1 && pPager->nReserve!=((u8*)aData)[20] ){\n    pPager->nReserve = ((u8*)aData)[20];\n    pagerReportSize(pPager);\n  }\n\n  /* If the pager is in CACHEMOD state, then there must be a copy of this\n  ** page in the pager cache. In this case just update the pager cache,\n  ** not the database file. The page is left marked dirty in this case.\n  **\n  ** An exception to the above rule: If the database is in no-sync mode\n  ** and a page is moved during an incremental vacuum then the page may\n  ** not be in the pager cache. Later: if a malloc() or IO error occurs\n  ** during a Movepage() call, then the page may not be in the cache\n  ** either. So the condition described in the above paragraph is not\n  ** assert()able.\n  **\n  ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the\n  ** pager cache if it exists and the main file. The page is then marked \n  ** not dirty. Since this code is only executed in PAGER_OPEN state for\n  ** a hot-journal rollback, it is guaranteed that the page-cache is empty\n  ** if the pager is in OPEN state.\n  **\n  ** Ticket #1171:  The statement journal might contain page content that is\n  ** different from the page content at the start of the transaction.\n  ** This occurs when a page is changed prior to the start of a statement\n  ** then changed again within the statement.  When rolling back such a\n  ** statement we must not write to the original database unless we know\n  ** for certain that original page contents are synced into the main rollback\n  ** journal.  Otherwise, a power loss might leave modified data in the\n  ** database file without an entry in the rollback journal that can\n  ** restore the database to its original form.  Two conditions must be\n  ** met before writing to the database files. (1) the database must be\n  ** locked.  (2) we know that the original page content is fully synced\n  ** in the main journal either because the page is not in cache or else\n  ** the page is marked as needSync==0.\n  **\n  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it\n  ** is possible to fail a statement on a database that does not yet exist.\n  ** Do not attempt to write if database file has never been opened.\n  */\n  if( pagerUseWal(pPager) ){\n    pPg = 0;\n  }else{\n    pPg = sqlite3PagerLookup(pPager, pgno);\n  }\n  assert( pPg || !MEMDB );\n  assert( pPager->eState!=PAGER_OPEN || pPg==0 || pPager->tempFile );\n  PAGERTRACE((\"PLAYBACK %d page %d hash(%08x) %s\\n\",\n           PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),\n           (isMainJrnl?\"main-journal\":\"sub-journal\")\n  ));\n  if( isMainJrnl ){\n    isSynced = pPager->noSync || (*pOffset <= pPager->journalHdr);\n  }else{\n    isSynced = (pPg==0 || 0==(pPg->flags & PGHDR_NEED_SYNC));\n  }\n  if( isOpen(pPager->fd)\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n   && isSynced\n  ){\n    i64 ofst = (pgno-1)*(i64)pPager->pageSize;\n    testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 );\n    assert( !pagerUseWal(pPager) );\n\n    /* Write the data read from the journal back into the database file.\n    ** This is usually safe even for an encrypted database - as the data\n    ** was encrypted before it was written to the journal file. The exception\n    ** is if the data was just read from an in-memory sub-journal. In that\n    ** case it must be encrypted here before it is copied into the database\n    ** file.  */\n#ifdef SQLITE_HAS_CODEC\n    if( !jrnlEnc ){\n      CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);\n      rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n      CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n    }else\n#endif\n    rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n\n    if( pgno>pPager->dbFileSize ){\n      pPager->dbFileSize = pgno;\n    }\n    if( pPager->pBackup ){\n#ifdef SQLITE_HAS_CODEC\n      if( jrnlEnc ){\n        CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n        sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n        CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);\n      }else\n#endif\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n    }\n  }else if( !isMainJrnl && pPg==0 ){\n    /* If this is a rollback of a savepoint and data was not written to\n    ** the database and the page is not in-memory, there is a potential\n    ** problem. When the page is next fetched by the b-tree layer, it \n    ** will be read from the database file, which may or may not be \n    ** current. \n    **\n    ** There are a couple of different ways this can happen. All are quite\n    ** obscure. When running in synchronous mode, this can only happen \n    ** if the page is on the free-list at the start of the transaction, then\n    ** populated, then moved using sqlite3PagerMovepage().\n    **\n    ** The solution is to add an in-memory page to the cache containing\n    ** the data just read from the sub-journal. Mark the page as dirty \n    ** and if the pager requires a journal-sync, then mark the page as \n    ** requiring a journal-sync before it is written.\n    */\n    assert( isSavepnt );\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)==0 );\n    pPager->doNotSpill |= SPILLFLAG_ROLLBACK;\n    rc = sqlite3PagerGet(pPager, pgno, &pPg, 1);\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)!=0 );\n    pPager->doNotSpill &= ~SPILLFLAG_ROLLBACK;\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3PcacheMakeDirty(pPg);\n  }\n  if( pPg ){\n    /* No page should ever be explicitly rolled back that is in use, except\n    ** for page 1 which is held in use in order to keep the lock on the\n    ** database active. However such a page may be rolled back as a result\n    ** of an internal error resulting in an automatic call to\n    ** sqlite3PagerRollback().\n    */\n    void *pData;\n    pData = pPg->pData;\n    memcpy(pData, (u8*)aData, pPager->pageSize);\n    pPager->xReiniter(pPg);\n    /* It used to be that sqlite3PcacheMakeClean(pPg) was called here.  But\n    ** that call was dangerous and had no detectable benefit since the cache\n    ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so\n    ** has been removed. */\n    pager_set_pagehash(pPg);\n\n    /* If this was page 1, then restore the value of Pager.dbFileVers.\n    ** Do this before any decoding. */\n    if( pgno==1 ){\n      memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers));\n    }\n\n    /* Decode the page just read from disk */\n#if SQLITE_HAS_CODEC\n    if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); }\n#endif\n    sqlite3PcacheRelease(pPg);\n  }\n  return rc;\n}\n\n/*\n** Parameter zMaster is the name of a master journal file. A single journal\n** file that referred to the master journal file has just been rolled back.\n** This routine checks if it is possible to delete the master journal file,\n** and does so if it is.\n**\n** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not \n** available for use within this function.\n**\n** When a master journal file is created, it is populated with the names \n** of all of its child journals, one after another, formatted as utf-8 \n** encoded text. The end of each child journal file is marked with a \n** nul-terminator byte (0x00). i.e. the entire contents of a master journal\n** file for a transaction involving two databases might be:\n**\n**   \"/home/bill/a.db-journal\\x00/home/bill/b.db-journal\\x00\"\n**\n** A master journal file may only be deleted once all of its child \n** journals have been rolled back.\n**\n** This function reads the contents of the master-journal file into \n** memory and loops through each of the child journal names. For\n** each child journal, it checks if:\n**\n**   * if the child journal exists, and if so\n**   * if the child journal contains a reference to master journal \n**     file zMaster\n**\n** If a child journal can be found that matches both of the criteria\n** above, this function returns without doing anything. Otherwise, if\n** no such child journal can be found, file zMaster is deleted from\n** the file-system using sqlite3OsDelete().\n**\n** If an IO error within this function, an error code is returned. This\n** function allocates memory by calling sqlite3Malloc(). If an allocation\n** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors \n** occur, SQLITE_OK is returned.\n**\n** TODO: This function allocates a single block of memory to load\n** the entire contents of the master journal file. This could be\n** a couple of kilobytes or so - potentially larger than the page \n** size.\n*/\nstatic int pager_delmaster(Pager *pPager, const char *zMaster){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  int rc;                   /* Return code */\n  sqlite3_file *pMaster;    /* Malloc'd master-journal file descriptor */\n  sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */\n  char *zMasterJournal = 0; /* Contents of master journal file */\n  i64 nMasterJournal;       /* Size of master journal file */\n  char *zJournal;           /* Pointer to one journal within MJ file */\n  char *zMasterPtr;         /* Space to hold MJ filename from a journal file */\n  int nMasterPtr;           /* Amount of space allocated to zMasterPtr[] */\n\n  /* Allocate space for both the pJournal and pMaster file descriptors.\n  ** If successful, open the master journal file for reading.\n  */\n  pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);\n  pJournal = (sqlite3_file *)(((u8 *)pMaster) + pVfs->szOsFile);\n  if( !pMaster ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);\n    rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);\n  }\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n\n  /* Load the entire master journal file into space obtained from\n  ** sqlite3_malloc() and pointed to by zMasterJournal.   Also obtain\n  ** sufficient space (in zMasterPtr) to hold the names of master\n  ** journal files extracted from regular rollback-journals.\n  */\n  rc = sqlite3OsFileSize(pMaster, &nMasterJournal);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  nMasterPtr = pVfs->mxPathname+1;\n  zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1);\n  if( !zMasterJournal ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto delmaster_out;\n  }\n  zMasterPtr = &zMasterJournal[nMasterJournal+1];\n  rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  zMasterJournal[nMasterJournal] = 0;\n\n  zJournal = zMasterJournal;\n  while( (zJournal-zMasterJournal)<nMasterJournal ){\n    int exists;\n    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);\n    if( rc!=SQLITE_OK ){\n      goto delmaster_out;\n    }\n    if( exists ){\n      /* One of the journals pointed to by the master journal exists.\n      ** Open it and check if it points at the master journal. If\n      ** so, return without deleting the master journal file.\n      */\n      int c;\n      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);\n      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);\n      sqlite3OsClose(pJournal);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;\n      if( c ){\n        /* We have a match. Do not delete the master journal file. */\n        goto delmaster_out;\n      }\n    }\n    zJournal += (sqlite3Strlen30(zJournal)+1);\n  }\n \n  sqlite3OsClose(pMaster);\n  rc = sqlite3OsDelete(pVfs, zMaster, 0);\n\ndelmaster_out:\n  sqlite3_free(zMasterJournal);\n  if( pMaster ){\n    sqlite3OsClose(pMaster);\n    assert( !isOpen(pJournal) );\n    sqlite3_free(pMaster);\n  }\n  return rc;\n}\n\n\n/*\n** This function is used to change the actual size of the database \n** file in the file-system. This only happens when committing a transaction,\n** or rolling back a transaction (including rolling back a hot-journal).\n**\n** If the main database file is not open, or the pager is not in either\n** DBMOD or OPEN state, this function is a no-op. Otherwise, the size \n** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). \n** If the file on disk is currently larger than nPage pages, then use the VFS\n** xTruncate() method to truncate it.\n**\n** Or, it might be the case that the file on disk is smaller than \n** nPage pages. Some operating system implementations can get confused if \n** you try to truncate a file to some size that is larger than it \n** currently is, so detect this case and write a single zero byte to \n** the end of the new file instead.\n**\n** If successful, return SQLITE_OK. If an IO error occurs while modifying\n** the database file, return the error code to the caller.\n*/\nstatic int pager_truncate(Pager *pPager, Pgno nPage){\n  int rc = SQLITE_OK;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState!=PAGER_READER );\n  \n  if( isOpen(pPager->fd) \n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) \n  ){\n    i64 currentSize, newSize;\n    int szPage = pPager->pageSize;\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    /* TODO: Is it safe to use Pager.dbFileSize here? */\n    rc = sqlite3OsFileSize(pPager->fd, &currentSize);\n    newSize = szPage*(i64)nPage;\n    if( rc==SQLITE_OK && currentSize!=newSize ){\n      if( currentSize>newSize ){\n        rc = sqlite3OsTruncate(pPager->fd, newSize);\n      }else if( (currentSize+szPage)<=newSize ){\n        char *pTmp = pPager->pTmpSpace;\n        memset(pTmp, 0, szPage);\n        testcase( (newSize-szPage) == currentSize );\n        testcase( (newSize-szPage) >  currentSize );\n        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);\n      }\n      if( rc==SQLITE_OK ){\n        pPager->dbFileSize = nPage;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return a sanitized version of the sector-size of OS file pFile. The\n** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.\n*/\nSQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *pFile){\n  int iRet = sqlite3OsSectorSize(pFile);\n  if( iRet<32 ){\n    iRet = 512;\n  }else if( iRet>MAX_SECTOR_SIZE ){\n    assert( MAX_SECTOR_SIZE>=512 );\n    iRet = MAX_SECTOR_SIZE;\n  }\n  return iRet;\n}\n\n/*\n** Set the value of the Pager.sectorSize variable for the given\n** pager based on the value returned by the xSectorSize method\n** of the open database file. The sector size will be used \n** to determine the size and alignment of journal header and \n** master journal pointers within created journal files.\n**\n** For temporary files the effective sector size is always 512 bytes.\n**\n** Otherwise, for non-temporary files, the effective sector size is\n** the value returned by the xSectorSize() method rounded up to 32 if\n** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it\n** is greater than MAX_SECTOR_SIZE.\n**\n** If the file has the SQLITE_IOCAP_POWERSAFE_OVERWRITE property, then set\n** the effective sector size to its minimum value (512).  The purpose of\n** pPager->sectorSize is to define the \"blast radius\" of bytes that\n** might change if a crash occurs while writing to a single byte in\n** that range.  But with POWERSAFE_OVERWRITE, the blast radius is zero\n** (that is what POWERSAFE_OVERWRITE means), so we minimize the sector\n** size.  For backwards compatibility of the rollback journal file format,\n** we cannot reduce the effective sector size below 512.\n*/\nstatic void setSectorSize(Pager *pPager){\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  if( pPager->tempFile\n   || (sqlite3OsDeviceCharacteristics(pPager->fd) & \n              SQLITE_IOCAP_POWERSAFE_OVERWRITE)!=0\n  ){\n    /* Sector size doesn't matter for temporary files. Also, the file\n    ** may not have been opened yet, in which case the OsSectorSize()\n    ** call will segfault. */\n    pPager->sectorSize = 512;\n  }else{\n    pPager->sectorSize = sqlite3SectorSize(pPager->fd);\n  }\n}\n\n/*\n** Playback the journal and thus restore the database file to\n** the state it was in before we started making changes.  \n**\n** The journal file format is as follows: \n**\n**  (1)  8 byte prefix.  A copy of aJournalMagic[].\n**  (2)  4 byte big-endian integer which is the number of valid page records\n**       in the journal.  If this value is 0xffffffff, then compute the\n**       number of page records from the journal size.\n**  (3)  4 byte big-endian integer which is the initial value for the \n**       sanity checksum.\n**  (4)  4 byte integer which is the number of pages to truncate the\n**       database to during a rollback.\n**  (5)  4 byte big-endian integer which is the sector size.  The header\n**       is this many bytes in size.\n**  (6)  4 byte big-endian integer which is the page size.\n**  (7)  zero padding out to the next sector size.\n**  (8)  Zero or more pages instances, each as follows:\n**        +  4 byte page number.\n**        +  pPager->pageSize bytes of data.\n**        +  4 byte checksum\n**\n** When we speak of the journal header, we mean the first 7 items above.\n** Each entry in the journal is an instance of the 8th item.\n**\n** Call the value from the second bullet \"nRec\".  nRec is the number of\n** valid page entries in the journal.  In most cases, you can compute the\n** value of nRec from the size of the journal file.  But if a power\n** failure occurred while the journal was being written, it could be the\n** case that the size of the journal file had already been increased but\n** the extra entries had not yet made it safely to disk.  In such a case,\n** the value of nRec computed from the file size would be too large.  For\n** that reason, we always use the nRec value in the header.\n**\n** If the nRec value is 0xffffffff it means that nRec should be computed\n** from the file size.  This value is used when the user selects the\n** no-sync option for the journal.  A power failure could lead to corruption\n** in this case.  But for things like temporary table (which will be\n** deleted when the power is restored) we don't care.  \n**\n** If the file opened as the journal file is not a well-formed\n** journal file then all pages up to the first corrupted page are rolled\n** back (or no pages if the journal header is corrupted). The journal file\n** is then deleted and SQLITE_OK returned, just as if no corruption had\n** been encountered.\n**\n** If an I/O or malloc() error occurs, the journal-file is not deleted\n** and an error code is returned.\n**\n** The isHot parameter indicates that we are trying to rollback a journal\n** that might be a hot journal.  Or, it could be that the journal is \n** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE.\n** If the journal really is hot, reset the pager cache prior rolling\n** back any content.  If the journal is merely persistent, no reset is\n** needed.\n*/\nstatic int pager_playback(Pager *pPager, int isHot){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  i64 szJ;                 /* Size of the journal file in bytes */\n  u32 nRec;                /* Number of Records in the journal */\n  u32 u;                   /* Unsigned loop counter */\n  Pgno mxPg = 0;           /* Size of the original file in pages */\n  int rc;                  /* Result code of a subroutine */\n  int res = 1;             /* Value returned by sqlite3OsAccess() */\n  char *zMaster = 0;       /* Name of master journal file if any */\n  int needPagerReset;      /* True to reset page prior to first page rollback */\n  int nPlayback = 0;       /* Total number of pages restored from journal */\n  u32 savedPageSize = pPager->pageSize;\n\n  /* Figure out how many records are in the journal.  Abort early if\n  ** the journal is empty.\n  */\n  assert( isOpen(pPager->jfd) );\n  rc = sqlite3OsFileSize(pPager->jfd, &szJ);\n  if( rc!=SQLITE_OK ){\n    goto end_playback;\n  }\n\n  /* Read the master journal name from the journal, if it is present.\n  ** If a master journal file name is specified, but the file is not\n  ** present on disk, then the journal is not hot and does not need to be\n  ** played back.\n  **\n  ** TODO: Technically the following is an error because it assumes that\n  ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that\n  ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,\n  ** mxPathname is 512, which is the same as the minimum allowable value\n  ** for pageSize.\n  */\n  zMaster = pPager->pTmpSpace;\n  rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n  if( rc==SQLITE_OK && zMaster[0] ){\n    rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n  }\n  zMaster = 0;\n  if( rc!=SQLITE_OK || !res ){\n    goto end_playback;\n  }\n  pPager->journalOff = 0;\n  needPagerReset = isHot;\n\n  /* This loop terminates either when a readJournalHdr() or \n  ** pager_playback_one_page() call returns SQLITE_DONE or an IO error \n  ** occurs. \n  */\n  while( 1 ){\n    /* Read the next journal header from the journal file.  If there are\n    ** not enough bytes left in the journal file for a complete header, or\n    ** it is corrupted, then a process must have failed while writing it.\n    ** This indicates nothing more needs to be rolled back.\n    */\n    rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);\n    if( rc!=SQLITE_OK ){ \n      if( rc==SQLITE_DONE ){\n        rc = SQLITE_OK;\n      }\n      goto end_playback;\n    }\n\n    /* If nRec is 0xffffffff, then this journal was created by a process\n    ** working in no-sync mode. This means that the rest of the journal\n    ** file consists of pages, there are no more journal headers. Compute\n    ** the value of nRec based on this assumption.\n    */\n    if( nRec==0xffffffff ){\n      assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );\n      nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If nRec is 0 and this rollback is of a transaction created by this\n    ** process and if this is the final header in the journal, then it means\n    ** that this part of the journal was being filled but has not yet been\n    ** synced to disk.  Compute the number of pages based on the remaining\n    ** size of the file.\n    **\n    ** The third term of the test was added to fix ticket #2565.\n    ** When rolling back a hot journal, nRec==0 always means that the next\n    ** chunk of the journal contains zero pages to be rolled back.  But\n    ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in\n    ** the journal, it means that the journal might contain additional\n    ** pages that need to be rolled back and that the number of pages \n    ** should be computed based on the journal file size.\n    */\n    if( nRec==0 && !isHot &&\n        pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){\n      nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If this is the first header read from the journal, truncate the\n    ** database file back to its original size.\n    */\n    if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){\n      rc = pager_truncate(pPager, mxPg);\n      if( rc!=SQLITE_OK ){\n        goto end_playback;\n      }\n      pPager->dbSize = mxPg;\n    }\n\n    /* Copy original pages out of the journal and back into the \n    ** database file and/or page cache.\n    */\n    for(u=0; u<nRec; u++){\n      if( needPagerReset ){\n        pager_reset(pPager);\n        needPagerReset = 0;\n      }\n      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);\n      if( rc==SQLITE_OK ){\n        nPlayback++;\n      }else{\n        if( rc==SQLITE_DONE ){\n          pPager->journalOff = szJ;\n          break;\n        }else if( rc==SQLITE_IOERR_SHORT_READ ){\n          /* If the journal has been truncated, simply stop reading and\n          ** processing the journal. This might happen if the journal was\n          ** not completely written and synced prior to a crash.  In that\n          ** case, the database should have never been written in the\n          ** first place so it is OK to simply abandon the rollback. */\n          rc = SQLITE_OK;\n          goto end_playback;\n        }else{\n          /* If we are unable to rollback, quit and return the error\n          ** code.  This will cause the pager to enter the error state\n          ** so that no further harm will be done.  Perhaps the next\n          ** process to come along will be able to rollback the database.\n          */\n          goto end_playback;\n        }\n      }\n    }\n  }\n  /*NOTREACHED*/\n  assert( 0 );\n\nend_playback:\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerSetPagesize(pPager, &savedPageSize, -1);\n  }\n  /* Following a rollback, the database file should be back in its original\n  ** state prior to the start of the transaction, so invoke the\n  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the\n  ** assertion that the transaction counter was modified.\n  */\n#ifdef SQLITE_DEBUG\n  if( pPager->fd->pMethods ){\n    sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);\n  }\n#endif\n\n  /* If this playback is happening automatically as a result of an IO or \n  ** malloc error that occurred after the change-counter was updated but \n  ** before the transaction was committed, then the change-counter \n  ** modification may just have been reverted. If this happens in exclusive \n  ** mode, then subsequent transactions performed by the connection will not\n  ** update the change-counter at all. This may lead to cache inconsistency\n  ** problems for other processes at some point in the future. So, just\n  ** in case this has happened, clear the changeCountDone flag now.\n  */\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( rc==SQLITE_OK ){\n    zMaster = pPager->pTmpSpace;\n    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n  ){\n    rc = sqlite3PagerSync(pPager, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = pager_end_transaction(pPager, zMaster[0]!='\\0', 0);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK && zMaster[0] && res ){\n    /* If there was a master journal and this routine will return success,\n    ** see if it is possible to delete the master journal.\n    */\n    rc = pager_delmaster(pPager, zMaster);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( isHot && nPlayback ){\n    sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, \"recovered %d pages from %s\",\n                nPlayback, pPager->zJournal);\n  }\n\n  /* The Pager.sectorSize variable may have been updated while rolling\n  ** back a journal created by a process with a different sector size\n  ** value. Reset it to the correct value for this process.\n  */\n  setSectorSize(pPager);\n  return rc;\n}\n\n\n/*\n** Read the content for page pPg out of the database file (or out of\n** the WAL if that is where the most recent copy if found) into \n** pPg->pData. A shared lock or greater must be held on the database\n** file before this function is called.\n**\n** If page 1 is read, then the value of Pager.dbFileVers[] is set to\n** the value read from the database file.\n**\n** If an IO error occurs, then the IO error is returned to the caller.\n** Otherwise, SQLITE_OK is returned.\n*/\nstatic int readDbPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */\n  int rc = SQLITE_OK;          /* Return code */\n\n#ifndef SQLITE_OMIT_WAL\n  u32 iFrame = 0;              /* Frame of WAL containing pgno */\n\n  assert( pPager->eState>=PAGER_READER && !MEMDB );\n  assert( isOpen(pPager->fd) );\n\n  if( pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);\n    if( rc ) return rc;\n  }\n  if( iFrame ){\n    rc = sqlite3WalReadFrame(pPager->pWal, iFrame,pPager->pageSize,pPg->pData);\n  }else\n#endif\n  {\n    i64 iOffset = (pPg->pgno-1)*(i64)pPager->pageSize;\n    rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n\n  if( pPg->pgno==1 ){\n    if( rc ){\n      /* If the read is unsuccessful, set the dbFileVers[] to something\n      ** that will never be a valid file version.  dbFileVers[] is a copy\n      ** of bytes 24..39 of the database.  Bytes 28..31 should always be\n      ** zero or the size of the database in page. Bytes 32..35 and 35..39\n      ** should be page numbers which are never 0xffffffff.  So filling\n      ** pPager->dbFileVers[] with all 0xff bytes should suffice.\n      **\n      ** For an encrypted database, the situation is more complex:  bytes\n      ** 24..39 of the database are white noise.  But the probability of\n      ** white noise equaling 16 bytes of 0xff is vanishingly small so\n      ** we should still be ok.\n      */\n      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));\n    }else{\n      u8 *dbFileVers = &((u8*)pPg->pData)[24];\n      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));\n    }\n  }\n  CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM_BKPT);\n\n  PAGER_INCR(sqlite3_pager_readdb_count);\n  PAGER_INCR(pPager->nRead);\n  IOTRACE((\"PGIN %p %d\\n\", pPager, pPg->pgno));\n  PAGERTRACE((\"FETCH %d page %d hash(%08x)\\n\",\n               PAGERID(pPager), pPg->pgno, pager_pagehash(pPg)));\n\n  return rc;\n}\n\n/*\n** Update the value of the change-counter at offsets 24 and 92 in\n** the header and the sqlite version number at offset 96.\n**\n** This is an unconditional update.  See also the pager_incr_changecounter()\n** routine which only updates the change-counter if the update is actually\n** needed, as determined by the pPager->changeCountDone state variable.\n*/\nstatic void pager_write_changecounter(PgHdr *pPg){\n  u32 change_counter;\n\n  /* Increment the value just read and write it back to byte 24. */\n  change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;\n  put32bits(((char*)pPg->pData)+24, change_counter);\n\n  /* Also store the SQLite version number in bytes 96..99 and in\n  ** bytes 92..95 store the change counter for which the version number\n  ** is valid. */\n  put32bits(((char*)pPg->pData)+92, change_counter);\n  put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is invoked once for each page that has already been \n** written into the log file when a WAL transaction is rolled back.\n** Parameter iPg is the page number of said page. The pCtx argument \n** is actually a pointer to the Pager structure.\n**\n** If page iPg is present in the cache, and has no outstanding references,\n** it is discarded. Otherwise, if there are one or more outstanding\n** references, the page content is reloaded from the database. If the\n** attempt to reload content from the database is required and fails, \n** return an SQLite error code. Otherwise, SQLITE_OK.\n*/\nstatic int pagerUndoCallback(void *pCtx, Pgno iPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = (Pager *)pCtx;\n  PgHdr *pPg;\n\n  assert( pagerUseWal(pPager) );\n  pPg = sqlite3PagerLookup(pPager, iPg);\n  if( pPg ){\n    if( sqlite3PcachePageRefcount(pPg)==1 ){\n      sqlite3PcacheDrop(pPg);\n    }else{\n      rc = readDbPage(pPg);\n      if( rc==SQLITE_OK ){\n        pPager->xReiniter(pPg);\n      }\n      sqlite3PagerUnrefNotNull(pPg);\n    }\n  }\n\n  /* Normally, if a transaction is rolled back, any backup processes are\n  ** updated as data is copied out of the rollback journal and into the\n  ** database. This is not generally possible with a WAL database, as\n  ** rollback involves simply truncating the log file. Therefore, if one\n  ** or more frames have already been written to the log (and therefore \n  ** also copied into the backup databases) as part of this transaction,\n  ** the backups must be restarted.\n  */\n  sqlite3BackupRestart(pPager->pBackup);\n\n  return rc;\n}\n\n/*\n** This function is called to rollback a transaction on a WAL database.\n*/\nstatic int pagerRollbackWal(Pager *pPager){\n  int rc;                         /* Return Code */\n  PgHdr *pList;                   /* List of dirty pages to revert */\n\n  /* For all pages in the cache that are currently dirty or have already\n  ** been written (but not committed) to the log file, do one of the \n  ** following:\n  **\n  **   + Discard the cached page (if refcount==0), or\n  **   + Reload page content from the database (if refcount>0).\n  */\n  pPager->dbSize = pPager->dbOrigSize;\n  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  while( pList && rc==SQLITE_OK ){\n    PgHdr *pNext = pList->pDirty;\n    rc = pagerUndoCallback((void *)pPager, pList->pgno);\n    pList = pNext;\n  }\n\n  return rc;\n}\n\n/*\n** This function is a wrapper around sqlite3WalFrames(). As well as logging\n** the contents of the list of pages headed by pList (connected by pDirty),\n** this function notifies any active backup processes that the pages have\n** changed. \n**\n** The list of pages passed into this routine is always sorted by page number.\n** Hence, if page 1 appears anywhere on the list, it will be the first page.\n*/ \nstatic int pagerWalFrames(\n  Pager *pPager,                  /* Pager object */\n  PgHdr *pList,                   /* List of frames to log */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit                    /* True if this is a commit */\n){\n  int rc;                         /* Return code */\n  int nList;                      /* Number of pages in pList */\n  PgHdr *p;                       /* For looping over pages */\n\n  assert( pPager->pWal );\n  assert( pList );\n#ifdef SQLITE_DEBUG\n  /* Verify that the page list is in accending order */\n  for(p=pList; p && p->pDirty; p=p->pDirty){\n    assert( p->pgno < p->pDirty->pgno );\n  }\n#endif\n\n  assert( pList->pDirty==0 || isCommit );\n  if( isCommit ){\n    /* If a WAL transaction is being committed, there is no point in writing\n    ** any pages with page numbers greater than nTruncate into the WAL file.\n    ** They will never be read by any client. So remove them from the pDirty\n    ** list here. */\n    PgHdr **ppNext = &pList;\n    nList = 0;\n    for(p=pList; (*ppNext = p)!=0; p=p->pDirty){\n      if( p->pgno<=nTruncate ){\n        ppNext = &p->pDirty;\n        nList++;\n      }\n    }\n    assert( pList );\n  }else{\n    nList = 1;\n  }\n  pPager->aStat[PAGER_STAT_WRITE] += nList;\n\n  if( pList->pgno==1 ) pager_write_changecounter(pList);\n  rc = sqlite3WalFrames(pPager->pWal, \n      pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags\n  );\n  if( rc==SQLITE_OK && pPager->pBackup ){\n    for(p=pList; p; p=p->pDirty){\n      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  for(p=pList; p; p=p->pDirty){\n    pager_set_pagehash(p);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Begin a read transaction on the WAL.\n**\n** This routine used to be called \"pagerOpenSnapshot()\" because it essentially\n** makes a snapshot of the database at the current point in time and preserves\n** that snapshot for use by the reader in spite of concurrently changes by\n** other writers or checkpointers.\n*/\nstatic int pagerBeginReadTransaction(Pager *pPager){\n  int rc;                         /* Return code */\n  int changed = 0;                /* True if cache must be reset */\n\n  assert( pagerUseWal(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n\n  /* sqlite3WalEndReadTransaction() was not called for the previous\n  ** transaction in locking_mode=EXCLUSIVE.  So call it now.  If we\n  ** are in locking_mode=NORMAL and EndRead() was previously called,\n  ** the duplicate call is harmless.\n  */\n  sqlite3WalEndReadTransaction(pPager->pWal);\n\n  rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);\n  if( rc!=SQLITE_OK || changed ){\n    pager_reset(pPager);\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n  }\n\n  return rc;\n}\n#endif\n\n/*\n** This function is called as part of the transition from PAGER_OPEN\n** to PAGER_READER state to determine the size of the database file\n** in pages (assuming the page size currently stored in Pager.pageSize).\n**\n** If no error occurs, SQLITE_OK is returned and the size of the database\n** in pages is stored in *pnPage. Otherwise, an error code (perhaps\n** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified.\n*/\nstatic int pagerPagecount(Pager *pPager, Pgno *pnPage){\n  Pgno nPage;                     /* Value to return via *pnPage */\n\n  /* Query the WAL sub-system for the database size. The WalDbsize()\n  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or\n  ** if the database size is not available. The database size is not\n  ** available from the WAL sub-system if the log file is empty or\n  ** contains no valid committed transactions.\n  */\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->tempFile==0 );\n  nPage = sqlite3WalDbsize(pPager->pWal);\n\n  /* If the number of pages in the database is not available from the\n  ** WAL sub-system, determine the page count based on the size of\n  ** the database file.  If the size of the database file is not an\n  ** integer multiple of the page-size, round up the result.\n  */\n  if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){\n    i64 n = 0;                    /* Size of db file in bytes */\n    int rc = sqlite3OsFileSize(pPager->fd, &n);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);\n  }\n\n  /* If the current number of pages in the file is greater than the\n  ** configured maximum pager number, increase the allowed limit so\n  ** that the file can be read.\n  */\n  if( nPage>pPager->mxPgno ){\n    pPager->mxPgno = (Pgno)nPage;\n  }\n\n  *pnPage = nPage;\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Check if the *-wal file that corresponds to the database opened by pPager\n** exists if the database is not empy, or verify that the *-wal file does\n** not exist (by deleting it) if the database file is empty.\n**\n** If the database is not empty and the *-wal file exists, open the pager\n** in WAL mode.  If the database is empty or if no *-wal file exists and\n** if no error occurs, make sure Pager.journalMode is not set to\n** PAGER_JOURNALMODE_WAL.\n**\n** Return SQLITE_OK or an error code.\n**\n** The caller must hold a SHARED lock on the database file to call this\n** function. Because an EXCLUSIVE lock on the db file is required to delete \n** a WAL on a none-empty database, this ensures there is no race condition \n** between the xAccess() below and an xDelete() being executed by some \n** other connection.\n*/\nstatic int pagerOpenWalIfPresent(Pager *pPager){\n  int rc = SQLITE_OK;\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n\n  if( !pPager->tempFile ){\n    int isWal;                    /* True if WAL file exists */\n    rc = sqlite3OsAccess(\n        pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal\n    );\n    if( rc==SQLITE_OK ){\n      if( isWal ){\n        Pgno nPage;                   /* Size of the database file */\n\n        rc = pagerPagecount(pPager, &nPage);\n        if( rc ) return rc;\n        if( nPage==0 ){\n          rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);\n        }else{\n          testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );\n          rc = sqlite3PagerOpenWal(pPager, 0);\n        }\n      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){\n        pPager->journalMode = PAGER_JOURNALMODE_DELETE;\n      }\n    }\n  }\n  return rc;\n}\n#endif\n\n/*\n** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback\n** the entire master journal file. The case pSavepoint==NULL occurs when \n** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction \n** savepoint.\n**\n** When pSavepoint is not NULL (meaning a non-transaction savepoint is \n** being rolled back), then the rollback consists of up to three stages,\n** performed in the order specified:\n**\n**   * Pages are played back from the main journal starting at byte\n**     offset PagerSavepoint.iOffset and continuing to \n**     PagerSavepoint.iHdrOffset, or to the end of the main journal\n**     file if PagerSavepoint.iHdrOffset is zero.\n**\n**   * If PagerSavepoint.iHdrOffset is not zero, then pages are played\n**     back starting from the journal header immediately following \n**     PagerSavepoint.iHdrOffset to the end of the main journal file.\n**\n**   * Pages are then played back from the sub-journal file, starting\n**     with the PagerSavepoint.iSubRec and continuing to the end of\n**     the journal file.\n**\n** Throughout the rollback process, each time a page is rolled back, the\n** corresponding bit is set in a bitvec structure (variable pDone in the\n** implementation below). This is used to ensure that a page is only\n** rolled back the first time it is encountered in either journal.\n**\n** If pSavepoint is NULL, then pages are only played back from the main\n** journal file. There is no need for a bitvec in this case.\n**\n** In either case, before playback commences the Pager.dbSize variable\n** is reset to the value that it held at the start of the savepoint \n** (or transaction). No page with a page-number greater than this value\n** is played back. If one is encountered it is simply skipped.\n*/\nstatic int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){\n  i64 szJ;                 /* Effective size of the main journal */\n  i64 iHdrOff;             /* End of first segment of main-journal records */\n  int rc = SQLITE_OK;      /* Return code */\n  Bitvec *pDone = 0;       /* Bitvec to ensure pages played back only once */\n\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n\n  /* Allocate a bitvec to use to store the set of pages rolled back */\n  if( pSavepoint ){\n    pDone = sqlite3BitvecCreate(pSavepoint->nOrig);\n    if( !pDone ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n\n  /* Set the database size back to the value it was before the savepoint \n  ** being reverted was opened.\n  */\n  pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( !pSavepoint && pagerUseWal(pPager) ){\n    return pagerRollbackWal(pPager);\n  }\n\n  /* Use pPager->journalOff as the effective size of the main rollback\n  ** journal.  The actual file might be larger than this in\n  ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST.  But anything\n  ** past pPager->journalOff is off-limits to us.\n  */\n  szJ = pPager->journalOff;\n  assert( pagerUseWal(pPager)==0 || szJ==0 );\n\n  /* Begin by rolling back records from the main journal starting at\n  ** PagerSavepoint.iOffset and continuing to the next journal header.\n  ** There might be records in the main journal that have a page number\n  ** greater than the current database size (pPager->dbSize) but those\n  ** will be skipped automatically.  Pages are added to pDone as they\n  ** are played back.\n  */\n  if( pSavepoint && !pagerUseWal(pPager) ){\n    iHdrOff = pSavepoint->iHdrOffset ? pSavepoint->iHdrOffset : szJ;\n    pPager->journalOff = pSavepoint->iOffset;\n    while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }else{\n    pPager->journalOff = 0;\n  }\n\n  /* Continue rolling back records out of the main journal starting at\n  ** the first journal header seen and continuing until the effective end\n  ** of the main journal file.  Continue to skip out-of-range pages and\n  ** continue adding pages rolled back to pDone.\n  */\n  while( rc==SQLITE_OK && pPager->journalOff<szJ ){\n    u32 ii;            /* Loop counter */\n    u32 nJRec = 0;     /* Number of Journal Records */\n    u32 dummy;\n    rc = readJournalHdr(pPager, 0, szJ, &nJRec, &dummy);\n    assert( rc!=SQLITE_DONE );\n\n    /*\n    ** The \"pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\"\n    ** test is related to ticket #2565.  See the discussion in the\n    ** pager_playback() function for additional information.\n    */\n    if( nJRec==0 \n     && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\n    ){\n      nJRec = (u32)((szJ - pPager->journalOff)/JOURNAL_PG_SZ(pPager));\n    }\n    for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n  assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );\n\n  /* Finally,  rollback pages from the sub-journal.  Page that were\n  ** previously rolled back out of the main journal (and are hence in pDone)\n  ** will be skipped.  Out-of-range pages are also skipped.\n  */\n  if( pSavepoint ){\n    u32 ii;            /* Loop counter */\n    i64 offset = (i64)pSavepoint->iSubRec*(4+pPager->pageSize);\n\n    if( pagerUseWal(pPager) ){\n      rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);\n    }\n    for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){\n      assert( offset==(i64)ii*(4+pPager->pageSize) );\n      rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n\n  sqlite3BitvecDestroy(pDone);\n  if( rc==SQLITE_OK ){\n    pPager->journalOff = szJ;\n  }\n\n  return rc;\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to recycle clean and unused pages.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){\n  sqlite3PcacheSetCachesize(pPager->pPCache, mxPage);\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to spill pages to journal.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager *pPager, int mxPage){\n  return sqlite3PcacheSetSpillsize(pPager->pPCache, mxPage);\n}\n\n/*\n** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.\n*/\nstatic void pagerFixMaplimit(Pager *pPager){\n#if SQLITE_MAX_MMAP_SIZE>0\n  sqlite3_file *fd = pPager->fd;\n  if( isOpen(fd) && fd->pMethods->iVersion>=3 ){\n    sqlite3_int64 sz;\n    sz = pPager->szMmap;\n    pPager->bUseFetch = (sz>0);\n    setGetterMethod(pPager);\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);\n  }\n#endif\n}\n\n/*\n** Change the maximum size of any memory mapping made of the database file.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 szMmap){\n  pPager->szMmap = szMmap;\n  pagerFixMaplimit(pPager);\n}\n\n/*\n** Free as much memory as possible from the pager.\n*/\nSQLITE_PRIVATE void sqlite3PagerShrink(Pager *pPager){\n  sqlite3PcacheShrink(pPager->pPCache);\n}\n\n/*\n** Adjust settings of the pager to those specified in the pgFlags parameter.\n**\n** The \"level\" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness\n** of the database to damage due to OS crashes or power failures by\n** changing the number of syncs()s when writing the journals.\n** There are four levels:\n**\n**    OFF       sqlite3OsSync() is never called.  This is the default\n**              for temporary and transient files.\n**\n**    NORMAL    The journal is synced once before writes begin on the\n**              database.  This is normally adequate protection, but\n**              it is theoretically possible, though very unlikely,\n**              that an inopertune power failure could leave the journal\n**              in a state which would cause damage to the database\n**              when it is rolled back.\n**\n**    FULL      The journal is synced twice before writes begin on the\n**              database (with some additional information - the nRec field\n**              of the journal header - being written in between the two\n**              syncs).  If we assume that writing a\n**              single disk sector is atomic, then this mode provides\n**              assurance that the journal will not be corrupted to the\n**              point of causing damage to the database during rollback.\n**\n**    EXTRA     This is like FULL except that is also syncs the directory\n**              that contains the rollback journal after the rollback\n**              journal is unlinked.\n**\n** The above is for a rollback-journal mode.  For WAL mode, OFF continues\n** to mean that no syncs ever occur.  NORMAL means that the WAL is synced\n** prior to the start of checkpoint and that the database file is synced\n** at the conclusion of the checkpoint if the entire content of the WAL\n** was written back into the database.  But no sync operations occur for\n** an ordinary commit in NORMAL mode with WAL.  FULL means that the WAL\n** file is synced following each commit operation, in addition to the\n** syncs associated with NORMAL.  There is no difference between FULL\n** and EXTRA for WAL mode.\n**\n** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL.  The\n** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync\n** using fcntl(F_FULLFSYNC).  SQLITE_SYNC_NORMAL means to do an\n** ordinary fsync() call.  There is no difference between SQLITE_SYNC_FULL\n** and SQLITE_SYNC_NORMAL on platforms other than MacOSX.  But the\n** synchronous=FULL versus synchronous=NORMAL setting determines when\n** the xSync primitive is called and is relevant to all platforms.\n**\n** Numeric values associated with these states are OFF==1, NORMAL=2,\n** and FULL=3.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE void sqlite3PagerSetFlags(\n  Pager *pPager,        /* The pager to set safety level for */\n  unsigned pgFlags      /* Various flags */\n){\n  unsigned level = pgFlags & PAGER_SYNCHRONOUS_MASK;\n  if( pPager->tempFile ){\n    pPager->noSync = 1;\n    pPager->fullSync = 0;\n    pPager->extraSync = 0;\n  }else{\n    pPager->noSync =  level==PAGER_SYNCHRONOUS_OFF ?1:0;\n    pPager->fullSync = level>=PAGER_SYNCHRONOUS_FULL ?1:0;\n    pPager->extraSync = level==PAGER_SYNCHRONOUS_EXTRA ?1:0;\n  }\n  if( pPager->noSync ){\n    pPager->syncFlags = 0;\n  }else if( pgFlags & PAGER_FULLFSYNC ){\n    pPager->syncFlags = SQLITE_SYNC_FULL;\n  }else{\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n  }\n  pPager->walSyncFlags = (pPager->syncFlags<<2);\n  if( pPager->fullSync ){\n    pPager->walSyncFlags |= pPager->syncFlags;\n  }\n  if( (pgFlags & PAGER_CKPT_FULLFSYNC) && !pPager->noSync ){\n    pPager->walSyncFlags |= (SQLITE_SYNC_FULL<<2);\n  }\n  if( pgFlags & PAGER_CACHESPILL ){\n    pPager->doNotSpill &= ~SPILLFLAG_OFF;\n  }else{\n    pPager->doNotSpill |= SPILLFLAG_OFF;\n  }\n}\n#endif\n\n/*\n** The following global variable is incremented whenever the library\n** attempts to open a temporary file.  This information is used for\n** testing and analysis only.  \n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_opentemp_count = 0;\n#endif\n\n/*\n** Open a temporary file.\n**\n** Write the file descriptor into *pFile. Return SQLITE_OK on success \n** or some other error code if we fail. The OS will automatically \n** delete the temporary file when it is closed.\n**\n** The flags passed to the VFS layer xOpen() call are those specified\n** by parameter vfsFlags ORed with the following:\n**\n**     SQLITE_OPEN_READWRITE\n**     SQLITE_OPEN_CREATE\n**     SQLITE_OPEN_EXCLUSIVE\n**     SQLITE_OPEN_DELETEONCLOSE\n*/\nstatic int pagerOpentemp(\n  Pager *pPager,        /* The pager object */\n  sqlite3_file *pFile,  /* Write the file descriptor here */\n  int vfsFlags          /* Flags passed through to the VFS */\n){\n  int rc;               /* Return code */\n\n#ifdef SQLITE_TEST\n  sqlite3_opentemp_count++;  /* Used for testing and analysis only */\n#endif\n\n  vfsFlags |=  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n            SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n  rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);\n  assert( rc!=SQLITE_OK || isOpen(pFile) );\n  return rc;\n}\n\n/*\n** Set the busy handler function.\n**\n** The pager invokes the busy-handler if sqlite3OsLock() returns \n** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,\n** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE \n** lock. It does *not* invoke the busy handler when upgrading from\n** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE\n** (which occurs during hot-journal rollback). Summary:\n**\n**   Transition                        | Invokes xBusyHandler\n**   --------------------------------------------------------\n**   NO_LOCK       -> SHARED_LOCK      | Yes\n**   SHARED_LOCK   -> RESERVED_LOCK    | No\n**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No\n**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes\n**\n** If the busy-handler callback returns non-zero, the lock is \n** retried. If it returns zero, then the SQLITE_BUSY error is\n** returned to the caller of the pager API function.\n*/\nSQLITE_PRIVATE void sqlite3PagerSetBusyhandler(\n  Pager *pPager,                       /* Pager object */\n  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */\n  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */\n){\n  pPager->xBusyHandler = xBusyHandler;\n  pPager->pBusyHandlerArg = pBusyHandlerArg;\n\n  if( isOpen(pPager->fd) ){\n    void **ap = (void **)&pPager->xBusyHandler;\n    assert( ((int(*)(void *))(ap[0]))==xBusyHandler );\n    assert( ap[1]==pBusyHandlerArg );\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);\n  }\n}\n\n/*\n** Change the page size used by the Pager object. The new page size \n** is passed in *pPageSize.\n**\n** If the pager is in the error state when this function is called, it\n** is a no-op. The value returned is the error state error code (i.e. \n** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).\n**\n** Otherwise, if all of the following are true:\n**\n**   * the new page size (value of *pPageSize) is valid (a power \n**     of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and\n**\n**   * there are no outstanding page references, and\n**\n**   * the database is either not an in-memory database or it is\n**     an in-memory database that currently consists of zero pages.\n**\n** then the pager object page size is set to *pPageSize.\n**\n** If the page size is changed, then this function uses sqlite3PagerMalloc() \n** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt \n** fails, SQLITE_NOMEM is returned and the page size remains unchanged. \n** In all other cases, SQLITE_OK is returned.\n**\n** If the page size is not changed, either because one of the enumerated\n** conditions above is not true, the pager was in error state when this\n** function was called, or because the memory allocation attempt failed, \n** then *pPageSize is set to the old, retained page size before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){\n  int rc = SQLITE_OK;\n\n  /* It is not possible to do a full assert_pager_state() here, as this\n  ** function may be called from within PagerOpen(), before the state\n  ** of the Pager object is internally consistent.\n  **\n  ** At one point this function returned an error if the pager was in \n  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that\n  ** there is at least one outstanding page reference, this function\n  ** is a no-op for that case anyhow.\n  */\n\n  u32 pageSize = *pPageSize;\n  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );\n  if( (pPager->memDb==0 || pPager->dbSize==0)\n   && sqlite3PcacheRefCount(pPager->pPCache)==0 \n   && pageSize && pageSize!=(u32)pPager->pageSize \n  ){\n    char *pNew = NULL;             /* New temp space */\n    i64 nByte = 0;\n\n    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){\n      rc = sqlite3OsFileSize(pPager->fd, &nByte);\n    }\n    if( rc==SQLITE_OK ){\n      pNew = (char *)sqlite3PageMalloc(pageSize);\n      if( !pNew ) rc = SQLITE_NOMEM_BKPT;\n    }\n\n    if( rc==SQLITE_OK ){\n      pager_reset(pPager);\n      rc = sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PageFree(pPager->pTmpSpace);\n      pPager->pTmpSpace = pNew;\n      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);\n      pPager->pageSize = pageSize;\n    }else{\n      sqlite3PageFree(pNew);\n    }\n  }\n\n  *pPageSize = pPager->pageSize;\n  if( rc==SQLITE_OK ){\n    if( nReserve<0 ) nReserve = pPager->nReserve;\n    assert( nReserve>=0 && nReserve<1000 );\n    pPager->nReserve = (i16)nReserve;\n    pagerReportSize(pPager);\n    pagerFixMaplimit(pPager);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to the \"temporary page\" buffer held internally\n** by the pager.  This is a buffer that is big enough to hold the\n** entire content of a database page.  This buffer is used internally\n** during rollback and will be overwritten whenever a rollback\n** occurs.  But other modules are free to use it too, as long as\n** no rollbacks are happening.\n*/\nSQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager *pPager){\n  return pPager->pTmpSpace;\n}\n\n/*\n** Attempt to set the maximum database page count if mxPage is positive. \n** Make no changes if mxPage is zero or negative.  And never reduce the\n** maximum page count below the current size of the database.\n**\n** Regardless of mxPage, return the current maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){\n  if( mxPage>0 ){\n    pPager->mxPgno = mxPage;\n  }\n  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */\n  assert( pPager->mxPgno>=pPager->dbSize );  /* OP_MaxPgcnt enforces this */\n  return pPager->mxPgno;\n}\n\n/*\n** The following set of routines are used to disable the simulated\n** I/O error mechanism.  These routines are used to avoid simulated\n** errors in places where we do not care about errors.\n**\n** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops\n** and generate no code.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API extern int sqlite3_io_error_pending;\nSQLITE_API extern int sqlite3_io_error_hit;\nstatic int saved_cnt;\nvoid disable_simulated_io_errors(void){\n  saved_cnt = sqlite3_io_error_pending;\n  sqlite3_io_error_pending = -1;\n}\nvoid enable_simulated_io_errors(void){\n  sqlite3_io_error_pending = saved_cnt;\n}\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n/*\n** Read the first N bytes from the beginning of the file into memory\n** that pDest points to. \n**\n** If the pager was opened on a transient file (zFilename==\"\"), or\n** opened on a file less than N bytes in size, the output buffer is\n** zeroed and SQLITE_OK returned. The rationale for this is that this \n** function is used to read database headers, and a new transient or\n** zero sized database has a header than consists entirely of zeroes.\n**\n** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered,\n** the error code is returned to the caller and the contents of the\n** output buffer undefined.\n*/\nSQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){\n  int rc = SQLITE_OK;\n  memset(pDest, 0, N);\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  /* This routine is only called by btree immediately after creating\n  ** the Pager object.  There has not been an opportunity to transition\n  ** to WAL mode yet.\n  */\n  assert( !pagerUseWal(pPager) );\n\n  if( isOpen(pPager->fd) ){\n    IOTRACE((\"DBHDR %p 0 %d\\n\", pPager, N))\n    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function may only be called when a read-transaction is open on\n** the pager. It returns the total number of pages in the database.\n**\n** However, if the file is between 1 and <page-size> bytes in size, then \n** this is considered a 1 page file.\n*/\nSQLITE_PRIVATE void sqlite3PagerPagecount(Pager *pPager, int *pnPage){\n  assert( pPager->eState>=PAGER_READER );\n  assert( pPager->eState!=PAGER_WRITER_FINISHED );\n  *pnPage = (int)pPager->dbSize;\n}\n\n\n/*\n** Try to obtain a lock of type locktype on the database file. If\n** a similar or greater lock is already held, this function is a no-op\n** (returning SQLITE_OK immediately).\n**\n** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke \n** the busy callback if the lock is currently not available. Repeat \n** until the busy callback returns false or until the attempt to \n** obtain the lock succeeds.\n**\n** Return SQLITE_OK on success and an error code if we cannot obtain\n** the lock. If the lock is obtained successfully, set the Pager.state \n** variable to locktype before returning.\n*/\nstatic int pager_wait_on_lock(Pager *pPager, int locktype){\n  int rc;                              /* Return code */\n\n  /* Check that this is either a no-op (because the requested lock is \n  ** already held), or one of the transitions that the busy-handler\n  ** may be invoked during, according to the comment above\n  ** sqlite3PagerSetBusyhandler().\n  */\n  assert( (pPager->eLock>=locktype)\n       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)\n       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)\n  );\n\n  do {\n    rc = pagerLockDb(pPager, locktype);\n  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );\n  return rc;\n}\n\n/*\n** Function assertTruncateConstraint(pPager) checks that one of the \n** following is true for all dirty pages currently in the page-cache:\n**\n**   a) The page number is less than or equal to the size of the \n**      current database image, in pages, OR\n**\n**   b) if the page content were written at this time, it would not\n**      be necessary to write the current content out to the sub-journal\n**      (as determined by function subjRequiresPage()).\n**\n** If the condition asserted by this function were not true, and the\n** dirty page were to be discarded from the cache via the pagerStress()\n** routine, pagerStress() would not write the current page content to\n** the database file. If a savepoint transaction were rolled back after\n** this happened, the correct behavior would be to restore the current\n** content of the page. However, since this content is not present in either\n** the database file or the portion of the rollback journal and \n** sub-journal rolled back the content could not be restored and the\n** database image would become corrupt. It is therefore fortunate that \n** this circumstance cannot arise.\n*/\n#if defined(SQLITE_DEBUG)\nstatic void assertTruncateConstraintCb(PgHdr *pPg){\n  assert( pPg->flags&PGHDR_DIRTY );\n  assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );\n}\nstatic void assertTruncateConstraint(Pager *pPager){\n  sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);\n}\n#else\n# define assertTruncateConstraint(pPager)\n#endif\n\n/*\n** Truncate the in-memory database file image to nPage pages. This \n** function does not actually modify the database file on disk. It \n** just sets the internal state of the pager object so that the \n** truncation will be done when the current transaction is committed.\n**\n** This function is only called right before committing a transaction.\n** Once this function has been called, the transaction must either be\n** rolled back or committed. It is not safe to call this function and\n** then continue writing to the database.\n*/\nSQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){\n  assert( pPager->dbSize>=nPage );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  pPager->dbSize = nPage;\n\n  /* At one point the code here called assertTruncateConstraint() to\n  ** ensure that all pages being truncated away by this operation are,\n  ** if one or more savepoints are open, present in the savepoint \n  ** journal so that they can be restored if the savepoint is rolled\n  ** back. This is no longer necessary as this function is now only\n  ** called right before committing a transaction. So although the \n  ** Pager object may still have open savepoints (Pager.nSavepoint!=0), \n  ** they cannot be rolled back. So the assertTruncateConstraint() call\n  ** is no longer correct. */\n}\n\n\n/*\n** This function is called before attempting a hot-journal rollback. It\n** syncs the journal file to disk, then sets pPager->journalHdr to the\n** size of the journal file so that the pager_playback() routine knows\n** that the entire journal file has been synced.\n**\n** Syncing a hot-journal to disk before attempting to roll it back ensures \n** that if a power-failure occurs during the rollback, the process that\n** attempts rollback following system recovery sees the same journal\n** content as this process.\n**\n** If everything goes as planned, SQLITE_OK is returned. Otherwise, \n** an SQLite error code.\n*/\nstatic int pagerSyncHotJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !pPager->noSync ){\n    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Obtain a reference to a memory mapped page object for page number pgno. \n** The new object will use the pointer pData, obtained from xFetch().\n** If successful, set *ppPage to point to the new page reference\n** and return SQLITE_OK. Otherwise, return an SQLite error code and set\n** *ppPage to zero.\n**\n** Page references obtained by calling this function should be released\n** by calling pagerReleaseMapPage().\n*/\nstatic int pagerAcquireMapPage(\n  Pager *pPager,                  /* Pager object */\n  Pgno pgno,                      /* Page number */\n  void *pData,                    /* xFetch()'d data for this page */\n  PgHdr **ppPage                  /* OUT: Acquired page object */\n){\n  PgHdr *p;                       /* Memory mapped page to return */\n  \n  if( pPager->pMmapFreelist ){\n    *ppPage = p = pPager->pMmapFreelist;\n    pPager->pMmapFreelist = p->pDirty;\n    p->pDirty = 0;\n    assert( pPager->nExtra>=8 );\n    memset(p->pExtra, 0, 8);\n  }else{\n    *ppPage = p = (PgHdr *)sqlite3MallocZero(sizeof(PgHdr) + pPager->nExtra);\n    if( p==0 ){\n      sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1) * pPager->pageSize, pData);\n      return SQLITE_NOMEM_BKPT;\n    }\n    p->pExtra = (void *)&p[1];\n    p->flags = PGHDR_MMAP;\n    p->nRef = 1;\n    p->pPager = pPager;\n  }\n\n  assert( p->pExtra==(void *)&p[1] );\n  assert( p->pPage==0 );\n  assert( p->flags==PGHDR_MMAP );\n  assert( p->pPager==pPager );\n  assert( p->nRef==1 );\n\n  p->pgno = pgno;\n  p->pData = pData;\n  pPager->nMmapOut++;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Release a reference to page pPg. pPg must have been returned by an \n** earlier call to pagerAcquireMapPage().\n*/\nstatic void pagerReleaseMapPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  pPager->nMmapOut--;\n  pPg->pDirty = pPager->pMmapFreelist;\n  pPager->pMmapFreelist = pPg;\n\n  assert( pPager->fd->pMethods->iVersion>=3 );\n  sqlite3OsUnfetch(pPager->fd, (i64)(pPg->pgno-1)*pPager->pageSize, pPg->pData);\n}\n\n/*\n** Free all PgHdr objects stored in the Pager.pMmapFreelist list.\n*/\nstatic void pagerFreeMapHdrs(Pager *pPager){\n  PgHdr *p;\n  PgHdr *pNext;\n  for(p=pPager->pMmapFreelist; p; p=pNext){\n    pNext = p->pDirty;\n    sqlite3_free(p);\n  }\n}\n\n\n/*\n** Shutdown the page cache.  Free all memory and close all files.\n**\n** If a transaction was in progress when this routine is called, that\n** transaction is rolled back.  All outstanding pages are invalidated\n** and their memory is freed.  Any attempt to use a page associated\n** with this page cache after this function returns will likely\n** result in a coredump.\n**\n** This function always succeeds. If a transaction is active an attempt\n** is made to roll it back. If an error occurs during the rollback \n** a hot journal may be left in the filesystem but no error is returned\n** to the caller.\n*/\nSQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){\n  u8 *pTmp = (u8 *)pPager->pTmpSpace;\n\n  assert( db || pagerUseWal(pPager)==0 );\n  assert( assert_pager_state(pPager) );\n  disable_simulated_io_errors();\n  sqlite3BeginBenignMalloc();\n  pagerFreeMapHdrs(pPager);\n  /* pPager->errCode = 0; */\n  pPager->exclusiveMode = 0;\n#ifndef SQLITE_OMIT_WAL\n  assert( db || pPager->pWal==0 );\n  sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,\n      (db && (db->flags & SQLITE_NoCkptOnClose) ? 0 : pTmp)\n  );\n  pPager->pWal = 0;\n#endif\n  pager_reset(pPager);\n  if( MEMDB ){\n    pager_unlock(pPager);\n  }else{\n    /* If it is open, sync the journal file before calling UnlockAndRollback.\n    ** If this is not done, then an unsynced portion of the open journal \n    ** file may be played back into the database. If a power failure occurs \n    ** while this is happening, the database could become corrupt.\n    **\n    ** If an error occurs while trying to sync the journal, shift the pager\n    ** into the ERROR state. This causes UnlockAndRollback to unlock the\n    ** database and close the journal file without attempting to roll it\n    ** back or finalize it. The next database user will have to do hot-journal\n    ** rollback before accessing the database file.\n    */\n    if( isOpen(pPager->jfd) ){\n      pager_error(pPager, pagerSyncHotJournal(pPager));\n    }\n    pagerUnlockAndRollback(pPager);\n  }\n  sqlite3EndBenignMalloc();\n  enable_simulated_io_errors();\n  PAGERTRACE((\"CLOSE %d\\n\", PAGERID(pPager)));\n  IOTRACE((\"CLOSE %p\\n\", pPager))\n  sqlite3OsClose(pPager->jfd);\n  sqlite3OsClose(pPager->fd);\n  sqlite3PageFree(pTmp);\n  sqlite3PcacheClose(pPager->pPCache);\n\n#ifdef SQLITE_HAS_CODEC\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n#endif\n\n  assert( !pPager->aSavepoint && !pPager->pInJournal );\n  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );\n\n  sqlite3_free(pPager);\n  return SQLITE_OK;\n}\n\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\n/*\n** Return the page number for page pPg.\n*/\nSQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage *pPg){\n  return pPg->pgno;\n}\n#endif\n\n/*\n** Increment the reference count for page pPg.\n*/\nSQLITE_PRIVATE void sqlite3PagerRef(DbPage *pPg){\n  sqlite3PcacheRef(pPg);\n}\n\n/*\n** Sync the journal. In other words, make sure all the pages that have\n** been written to the journal have actually reached the surface of the\n** disk and can be restored in the event of a hot-journal rollback.\n**\n** If the Pager.noSync flag is set, then this function is a no-op.\n** Otherwise, the actions required depend on the journal-mode and the \n** device characteristics of the file-system, as follows:\n**\n**   * If the journal file is an in-memory journal file, no action need\n**     be taken.\n**\n**   * Otherwise, if the device does not support the SAFE_APPEND property,\n**     then the nRec field of the most recently written journal header\n**     is updated to contain the number of journal records that have\n**     been written following it. If the pager is operating in full-sync\n**     mode, then the journal file is synced before this field is updated.\n**\n**   * If the device does not support the SEQUENTIAL property, then \n**     journal file is synced.\n**\n** Or, in pseudo-code:\n**\n**   if( NOT <in-memory journal> ){\n**     if( NOT SAFE_APPEND ){\n**       if( <full-sync mode> ) xSync(<journal file>);\n**       <update nRec field>\n**     } \n**     if( NOT SEQUENTIAL ) xSync(<journal file>);\n**   }\n**\n** If successful, this routine clears the PGHDR_NEED_SYNC flag of every \n** page currently held in memory before returning SQLITE_OK. If an IO\n** error is encountered, then the IO error code is returned to the caller.\n*/\nstatic int syncJournal(Pager *pPager, int newHdr){\n  int rc;                         /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( !pagerUseWal(pPager) );\n\n  rc = sqlite3PagerExclusiveLock(pPager);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( !pPager->noSync ){\n    assert( !pPager->tempFile );\n    if( isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){\n      const int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      assert( isOpen(pPager->jfd) );\n\n      if( 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        /* This block deals with an obscure problem. If the last connection\n        ** that wrote to this database was operating in persistent-journal\n        ** mode, then the journal file may at this point actually be larger\n        ** than Pager.journalOff bytes. If the next thing in the journal\n        ** file happens to be a journal-header (written as part of the\n        ** previous connection's transaction), and a crash or power-failure \n        ** occurs after nRec is updated but before this connection writes \n        ** anything else to the journal file (or commits/rolls back its \n        ** transaction), then SQLite may become confused when doing the \n        ** hot-journal rollback following recovery. It may roll back all\n        ** of this connections data, then proceed to rolling back the old,\n        ** out-of-date data that follows it. Database corruption.\n        **\n        ** To work around this, if the journal file does appear to contain\n        ** a valid header following Pager.journalOff, then write a 0x00\n        ** byte to the start of it to prevent it from being recognized.\n        **\n        ** Variable iNextHdrOffset is set to the offset at which this\n        ** problematic header will occur, if it exists. aMagic is used \n        ** as a temporary buffer to inspect the first couple of bytes of\n        ** the potential journal header.\n        */\n        i64 iNextHdrOffset;\n        u8 aMagic[8];\n        u8 zHeader[sizeof(aJournalMagic)+4];\n\n        memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n        put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);\n\n        iNextHdrOffset = journalHdrOffset(pPager);\n        rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);\n        if( rc==SQLITE_OK && 0==memcmp(aMagic, aJournalMagic, 8) ){\n          static const u8 zerobyte = 0;\n          rc = sqlite3OsWrite(pPager->jfd, &zerobyte, 1, iNextHdrOffset);\n        }\n        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){\n          return rc;\n        }\n\n        /* Write the nRec value into the journal file header. If in\n        ** full-synchronous mode, sync the journal first. This ensures that\n        ** all data has really hit the disk before nRec is updated to mark\n        ** it as a candidate for rollback.\n        **\n        ** This is not required if the persistent media supports the\n        ** SAFE_APPEND property. Because in this case it is not possible \n        ** for garbage data to be appended to the file, the nRec field\n        ** is populated with 0xFFFFFFFF when the journal header is written\n        ** and never needs to be updated.\n        */\n        if( pPager->fullSync && 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n          PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n          IOTRACE((\"JSYNC %p\\n\", pPager))\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n        IOTRACE((\"JHDR %p %lld\\n\", pPager, pPager->journalHdr));\n        rc = sqlite3OsWrite(\n            pPager->jfd, zHeader, sizeof(zHeader), pPager->journalHdr\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n      if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n        PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n        IOTRACE((\"JSYNC %p\\n\", pPager))\n        rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags| \n          (pPager->syncFlags==SQLITE_SYNC_FULL?SQLITE_SYNC_DATAONLY:0)\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n\n      pPager->journalHdr = pPager->journalOff;\n      if( newHdr && 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        pPager->nRec = 0;\n        rc = writeJournalHdr(pPager);\n        if( rc!=SQLITE_OK ) return rc;\n      }\n    }else{\n      pPager->journalHdr = pPager->journalOff;\n    }\n  }\n\n  /* Unless the pager is in noSync mode, the journal file was just \n  ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on \n  ** all pages.\n  */\n  sqlite3PcacheClearSyncFlags(pPager->pPCache);\n  pPager->eState = PAGER_WRITER_DBMOD;\n  assert( assert_pager_state(pPager) );\n  return SQLITE_OK;\n}\n\n/*\n** The argument is the first in a linked list of dirty pages connected\n** by the PgHdr.pDirty pointer. This function writes each one of the\n** in-memory pages in the list to the database file. The argument may\n** be NULL, representing an empty list. In this case this function is\n** a no-op.\n**\n** The pager must hold at least a RESERVED lock when this function\n** is called. Before writing anything to the database file, this lock\n** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,\n** SQLITE_BUSY is returned and no data is written to the database file.\n** \n** If the pager is a temp-file pager and the actual file-system file\n** is not yet open, it is created and opened before any data is \n** written out.\n**\n** Once the lock has been upgraded and, if necessary, the file opened,\n** the pages are written out to the database file in list order. Writing\n** a page is skipped if it meets either of the following criteria:\n**\n**   * The page number is greater than Pager.dbSize, or\n**   * The PGHDR_DONT_WRITE flag is set on the page.\n**\n** If writing out a page causes the database file to grow, Pager.dbFileSize\n** is updated accordingly. If page 1 is written out, then the value cached\n** in Pager.dbFileVers[] is updated to match the new value stored in\n** the database file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot\n** be obtained, SQLITE_BUSY is returned.\n*/\nstatic int pager_write_pagelist(Pager *pPager, PgHdr *pList){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This function is only called for rollback pagers in WRITER_DBMOD state. */\n  assert( !pagerUseWal(pPager) );\n  assert( pPager->tempFile || pPager->eState==PAGER_WRITER_DBMOD );\n  assert( pPager->eLock==EXCLUSIVE_LOCK );\n  assert( isOpen(pPager->fd) || pList->pDirty==0 );\n\n  /* If the file is a temp-file has not yet been opened, open it now. It\n  ** is not possible for rc to be other than SQLITE_OK if this branch\n  ** is taken, as pager_wait_on_lock() is a no-op for temp-files.\n  */\n  if( !isOpen(pPager->fd) ){\n    assert( pPager->tempFile && rc==SQLITE_OK );\n    rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);\n  }\n\n  /* Before the first write, give the VFS a hint of what the final\n  ** file size will be.\n  */\n  assert( rc!=SQLITE_OK || isOpen(pPager->fd) );\n  if( rc==SQLITE_OK \n   && pPager->dbHintSize<pPager->dbSize\n   && (pList->pDirty || pList->pgno>pPager->dbHintSize)\n  ){\n    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);\n    pPager->dbHintSize = pPager->dbSize;\n  }\n\n  while( rc==SQLITE_OK && pList ){\n    Pgno pgno = pList->pgno;\n\n    /* If there are dirty pages in the page cache with page numbers greater\n    ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to\n    ** make the file smaller (presumably by auto-vacuum code). Do not write\n    ** any such pages to the file.\n    **\n    ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag\n    ** set (set by sqlite3PagerDontWrite()).\n    */\n    if( pgno<=pPager->dbSize && 0==(pList->flags&PGHDR_DONT_WRITE) ){\n      i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */\n      char *pData;                                   /* Data to write */    \n\n      assert( (pList->flags&PGHDR_NEED_SYNC)==0 );\n      if( pList->pgno==1 ) pager_write_changecounter(pList);\n\n      /* Encode the database */\n      CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM_BKPT, pData);\n\n      /* Write out the page data. */\n      rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize, offset);\n\n      /* If page 1 was just written, update Pager.dbFileVers to match\n      ** the value now stored in the database file. If writing this \n      ** page caused the database file to grow, update dbFileSize. \n      */\n      if( pgno==1 ){\n        memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));\n      }\n      if( pgno>pPager->dbFileSize ){\n        pPager->dbFileSize = pgno;\n      }\n      pPager->aStat[PAGER_STAT_WRITE]++;\n\n      /* Update any backup objects copying the contents of this pager. */\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);\n\n      PAGERTRACE((\"STORE %d page %d hash(%08x)\\n\",\n                   PAGERID(pPager), pgno, pager_pagehash(pList)));\n      IOTRACE((\"PGOUT %p %d\\n\", pPager, pgno));\n      PAGER_INCR(sqlite3_pager_writedb_count);\n    }else{\n      PAGERTRACE((\"NOSTORE %d page %d\\n\", PAGERID(pPager), pgno));\n    }\n    pager_set_pagehash(pList);\n    pList = pList->pDirty;\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the sub-journal file is open. If it is already open, this \n** function is a no-op.\n**\n** SQLITE_OK is returned if everything goes according to plan. An \n** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() \n** fails.\n*/\nstatic int openSubJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !isOpen(pPager->sjfd) ){\n    const int flags =  SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE \n      | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE \n      | SQLITE_OPEN_DELETEONCLOSE;\n    int nStmtSpill = sqlite3Config.nStmtSpill;\n    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){\n      nStmtSpill = -1;\n    }\n    rc = sqlite3JournalOpen(pPager->pVfs, 0, pPager->sjfd, flags, nStmtSpill);\n  }\n  return rc;\n}\n\n/*\n** Append a record of the current state of page pPg to the sub-journal. \n**\n** If successful, set the bit corresponding to pPg->pgno in the bitvecs\n** for all open savepoints before returning.\n**\n** This function returns SQLITE_OK if everything is successful, an IO\n** error code if the attempt to write to the sub-journal fails, or \n** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint\n** bitvec.\n*/\nstatic int subjournalPage(PgHdr *pPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = pPg->pPager;\n  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n\n    /* Open the sub-journal, if it has not already been opened */\n    assert( pPager->useJournal );\n    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );\n    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );\n    assert( pagerUseWal(pPager) \n         || pageInJournal(pPager, pPg) \n         || pPg->pgno>pPager->dbOrigSize \n    );\n    rc = openSubJournal(pPager);\n\n    /* If the sub-journal was opened successfully (or was already open),\n    ** write the journal record into the file.  */\n    if( rc==SQLITE_OK ){\n      void *pData = pPg->pData;\n      i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize);\n      char *pData2;\n\n#if SQLITE_HAS_CODEC   \n      if( !pPager->subjInMemory ){\n        CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n      }else\n#endif\n      pData2 = pData;\n      PAGERTRACE((\"STMT-JOURNAL %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n      rc = write32bits(pPager->sjfd, offset, pPg->pgno);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    pPager->nSubRec++;\n    assert( pPager->nSavepoint>0 );\n    rc = addToSavepointBitvecs(pPager, pPg->pgno);\n  }\n  return rc;\n}\nstatic int subjournalPageIfRequired(PgHdr *pPg){\n  if( subjRequiresPage(pPg) ){\n    return subjournalPage(pPg);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This function is called by the pcache layer when it has reached some\n** soft memory limit. The first argument is a pointer to a Pager object\n** (cast as a void*). The pager is always 'purgeable' (not an in-memory\n** database). The second argument is a reference to a page that is \n** currently dirty but has no outstanding references. The page\n** is always associated with the Pager object passed as the first \n** argument.\n**\n** The job of this function is to make pPg clean by writing its contents\n** out to the database file, if possible. This may involve syncing the\n** journal file. \n**\n** If successful, sqlite3PcacheMakeClean() is called on the page and\n** SQLITE_OK returned. If an IO error occurs while trying to make the\n** page clean, the IO error code is returned. If the page cannot be\n** made clean for some other reason, but no error occurs, then SQLITE_OK\n** is returned by sqlite3PcacheMakeClean() is not called.\n*/\nstatic int pagerStress(void *p, PgHdr *pPg){\n  Pager *pPager = (Pager *)p;\n  int rc = SQLITE_OK;\n\n  assert( pPg->pPager==pPager );\n  assert( pPg->flags&PGHDR_DIRTY );\n\n  /* The doNotSpill NOSYNC bit is set during times when doing a sync of\n  ** journal (and adding a new header) is not allowed.  This occurs\n  ** during calls to sqlite3PagerWrite() while trying to journal multiple\n  ** pages belonging to the same sector.\n  **\n  ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling\n  ** regardless of whether or not a sync is required.  This is set during\n  ** a rollback or by user request, respectively.\n  **\n  ** Spilling is also prohibited when in an error state since that could\n  ** lead to database corruption.   In the current implementation it \n  ** is impossible for sqlite3PcacheFetch() to be called with createFlag==3\n  ** while in the error state, hence it is impossible for this routine to\n  ** be called in the error state.  Nevertheless, we include a NEVER()\n  ** test for the error state as a safeguard against future changes.\n  */\n  if( NEVER(pPager->errCode) ) return SQLITE_OK;\n  testcase( pPager->doNotSpill & SPILLFLAG_ROLLBACK );\n  testcase( pPager->doNotSpill & SPILLFLAG_OFF );\n  testcase( pPager->doNotSpill & SPILLFLAG_NOSYNC );\n  if( pPager->doNotSpill\n   && ((pPager->doNotSpill & (SPILLFLAG_ROLLBACK|SPILLFLAG_OFF))!=0\n      || (pPg->flags & PGHDR_NEED_SYNC)!=0)\n  ){\n    return SQLITE_OK;\n  }\n\n  pPg->pDirty = 0;\n  if( pagerUseWal(pPager) ){\n    /* Write a single frame for this page to the log. */\n    rc = subjournalPageIfRequired(pPg); \n    if( rc==SQLITE_OK ){\n      rc = pagerWalFrames(pPager, pPg, 0, 0);\n    }\n  }else{\n    \n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n    if( pPager->tempFile==0 ){\n      rc = sqlite3JournalCreate(pPager->jfd);\n      if( rc!=SQLITE_OK ) return pager_error(pPager, rc);\n    }\n#endif\n  \n    /* Sync the journal file if required. */\n    if( pPg->flags&PGHDR_NEED_SYNC \n     || pPager->eState==PAGER_WRITER_CACHEMOD\n    ){\n      rc = syncJournal(pPager, 1);\n    }\n  \n    /* Write the contents of the page out to the database file. */\n    if( rc==SQLITE_OK ){\n      assert( (pPg->flags&PGHDR_NEED_SYNC)==0 );\n      rc = pager_write_pagelist(pPager, pPg);\n    }\n  }\n\n  /* Mark the page as clean. */\n  if( rc==SQLITE_OK ){\n    PAGERTRACE((\"STRESS %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n    sqlite3PcacheMakeClean(pPg);\n  }\n\n  return pager_error(pPager, rc); \n}\n\n/*\n** Flush all unreferenced dirty pages to disk.\n*/\nSQLITE_PRIVATE int sqlite3PagerFlush(Pager *pPager){\n  int rc = pPager->errCode;\n  if( !MEMDB ){\n    PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n    assert( assert_pager_state(pPager) );\n    while( rc==SQLITE_OK && pList ){\n      PgHdr *pNext = pList->pDirty;\n      if( pList->nRef==0 ){\n        rc = pagerStress((void*)pPager, pList);\n      }\n      pList = pNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and initialize a new Pager object and put a pointer to it\n** in *ppPager. The pager should eventually be freed by passing it\n** to sqlite3PagerClose().\n**\n** The zFilename argument is the path to the database file to open.\n** If zFilename is NULL then a randomly-named temporary file is created\n** and used as the file to be cached. Temporary files are be deleted\n** automatically when they are closed. If zFilename is \":memory:\" then \n** all information is held in cache. It is never written to disk. \n** This can be used to implement an in-memory database.\n**\n** The nExtra parameter specifies the number of bytes of space allocated\n** along with each page reference. This space is available to the user\n** via the sqlite3PagerGetExtra() API.  When a new page is allocated, the\n** first 8 bytes of this space are zeroed but the remainder is uninitialized.\n** (The extra space is used by btree as the MemPage object.)\n**\n** The flags argument is used to specify properties that affect the\n** operation of the pager. It should be passed some bitwise combination\n** of the PAGER_* flags.\n**\n** The vfsFlags parameter is a bitmask to pass to the flags parameter\n** of the xOpen() method of the supplied VFS when opening files. \n**\n** If the pager object is allocated and the specified file opened \n** successfully, SQLITE_OK is returned and *ppPager set to point to\n** the new pager object. If an error occurs, *ppPager is set to NULL\n** and error code returned. This function may return SQLITE_NOMEM\n** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or \n** various SQLITE_IO_XXX errors.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpen(\n  sqlite3_vfs *pVfs,       /* The virtual file system to use */\n  Pager **ppPager,         /* OUT: Return the Pager structure here */\n  const char *zFilename,   /* Name of the database file to open */\n  int nExtra,              /* Extra bytes append to each in-memory page */\n  int flags,               /* flags controlling this file */\n  int vfsFlags,            /* flags passed through to sqlite3_vfs.xOpen() */\n  void (*xReinit)(DbPage*) /* Function to reinitialize pages */\n){\n  u8 *pPtr;\n  Pager *pPager = 0;       /* Pager object to allocate and return */\n  int rc = SQLITE_OK;      /* Return code */\n  int tempFile = 0;        /* True for temp files (incl. in-memory files) */\n  int memDb = 0;           /* True if this is an in-memory file */\n  int readOnly = 0;        /* True if this is a read-only file */\n  int journalFileSize;     /* Bytes to allocate for each journal fd */\n  char *zPathname = 0;     /* Full path to database file */\n  int nPathname = 0;       /* Number of bytes in zPathname */\n  int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */\n  int pcacheSize = sqlite3PcacheSize();       /* Bytes to allocate for PCache */\n  u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */\n  const char *zUri = 0;    /* URI args to copy */\n  int nUri = 0;            /* Number of bytes of URI args at *zUri */\n\n  /* Figure out how much space is required for each journal file-handle\n  ** (there are two of them, the main journal and the sub-journal).  */\n  journalFileSize = ROUND8(sqlite3JournalSize(pVfs));\n\n  /* Set the output variable to NULL in case an error occurs. */\n  *ppPager = 0;\n\n#ifndef SQLITE_OMIT_MEMORYDB\n  if( flags & PAGER_MEMORY ){\n    memDb = 1;\n    if( zFilename && zFilename[0] ){\n      zPathname = sqlite3DbStrDup(0, zFilename);\n      if( zPathname==0  ) return SQLITE_NOMEM_BKPT;\n      nPathname = sqlite3Strlen30(zPathname);\n      zFilename = 0;\n    }\n  }\n#endif\n\n  /* Compute and store the full pathname in an allocated buffer pointed\n  ** to by zPathname, length nPathname. Or, if this is a temporary file,\n  ** leave both nPathname and zPathname set to 0.\n  */\n  if( zFilename && zFilename[0] ){\n    const char *z;\n    nPathname = pVfs->mxPathname+1;\n    zPathname = sqlite3DbMallocRaw(0, nPathname*2);\n    if( zPathname==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */\n    rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);\n    nPathname = sqlite3Strlen30(zPathname);\n    z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];\n    while( *z ){\n      z += sqlite3Strlen30(z)+1;\n      z += sqlite3Strlen30(z)+1;\n    }\n    nUri = (int)(&z[1] - zUri);\n    assert( nUri>=0 );\n    if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){\n      /* This branch is taken when the journal path required by\n      ** the database being opened will be more than pVfs->mxPathname\n      ** bytes in length. This means the database cannot be opened,\n      ** as it will not be possible to open the journal file or even\n      ** check for a hot-journal before reading.\n      */\n      rc = SQLITE_CANTOPEN_BKPT;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(0, zPathname);\n      return rc;\n    }\n  }\n\n  /* Allocate memory for the Pager structure, PCache object, the\n  ** three file descriptors, the database file name and the journal \n  ** file name. The layout in memory is as follows:\n  **\n  **     Pager object                    (sizeof(Pager) bytes)\n  **     PCache object                   (sqlite3PcacheSize() bytes)\n  **     Database file handle            (pVfs->szOsFile bytes)\n  **     Sub-journal file handle         (journalFileSize bytes)\n  **     Main journal file handle        (journalFileSize bytes)\n  **     Database file name              (nPathname+1 bytes)\n  **     Journal file name               (nPathname+8+1 bytes)\n  */\n  pPtr = (u8 *)sqlite3MallocZero(\n    ROUND8(sizeof(*pPager)) +      /* Pager structure */\n    ROUND8(pcacheSize) +           /* PCache object */\n    ROUND8(pVfs->szOsFile) +       /* The main db file */\n    journalFileSize * 2 +          /* The two journal files */ \n    nPathname + 1 + nUri +         /* zFilename */\n    nPathname + 8 + 2              /* zJournal */\n#ifndef SQLITE_OMIT_WAL\n    + nPathname + 4 + 2            /* zWal */\n#endif\n  );\n  assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );\n  if( !pPtr ){\n    sqlite3DbFree(0, zPathname);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pPager =              (Pager*)(pPtr);\n  pPager->pPCache =    (PCache*)(pPtr += ROUND8(sizeof(*pPager)));\n  pPager->fd =   (sqlite3_file*)(pPtr += ROUND8(pcacheSize));\n  pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));\n  pPager->jfd =  (sqlite3_file*)(pPtr += journalFileSize);\n  pPager->zFilename =    (char*)(pPtr += journalFileSize);\n  assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );\n\n  /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */\n  if( zPathname ){\n    assert( nPathname>0 );\n    pPager->zJournal =   (char*)(pPtr += nPathname + 1 + nUri);\n    memcpy(pPager->zFilename, zPathname, nPathname);\n    if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);\n    memcpy(pPager->zJournal, zPathname, nPathname);\n    memcpy(&pPager->zJournal[nPathname], \"-journal\\000\", 8+2);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);\n#ifndef SQLITE_OMIT_WAL\n    pPager->zWal = &pPager->zJournal[nPathname+8+1];\n    memcpy(pPager->zWal, zPathname, nPathname);\n    memcpy(&pPager->zWal[nPathname], \"-wal\\000\", 4+1);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);\n#endif\n    sqlite3DbFree(0, zPathname);\n  }\n  pPager->pVfs = pVfs;\n  pPager->vfsFlags = vfsFlags;\n\n  /* Open the pager file.\n  */\n  if( zFilename && zFilename[0] ){\n    int fout = 0;                    /* VFS flags returned by xOpen() */\n    rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);\n    assert( !memDb );\n    readOnly = (fout&SQLITE_OPEN_READONLY);\n\n    /* If the file was successfully opened for read/write access,\n    ** choose a default page size in case we have to create the\n    ** database file. The default page size is the maximum of:\n    **\n    **    + SQLITE_DEFAULT_PAGE_SIZE,\n    **    + The value returned by sqlite3OsSectorSize()\n    **    + The largest page size that can be written atomically.\n    */\n    if( rc==SQLITE_OK ){\n      int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      if( !readOnly ){\n        setSectorSize(pPager);\n        assert(SQLITE_DEFAULT_PAGE_SIZE<=SQLITE_MAX_DEFAULT_PAGE_SIZE);\n        if( szPageDflt<pPager->sectorSize ){\n          if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){\n            szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;\n          }else{\n            szPageDflt = (u32)pPager->sectorSize;\n          }\n        }\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n        {\n          int ii;\n          assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n          assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n          assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);\n          for(ii=szPageDflt; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){\n            if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ){\n              szPageDflt = ii;\n            }\n          }\n        }\n#endif\n      }\n      pPager->noLock = sqlite3_uri_boolean(zFilename, \"nolock\", 0);\n      if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0\n       || sqlite3_uri_boolean(zFilename, \"immutable\", 0) ){\n          vfsFlags |= SQLITE_OPEN_READONLY;\n          goto act_like_temp_file;\n      }\n    }\n  }else{\n    /* If a temporary file is requested, it is not opened immediately.\n    ** In this case we accept the default page size and delay actually\n    ** opening the file until the first call to OsWrite().\n    **\n    ** This branch is also run for an in-memory database. An in-memory\n    ** database is the same as a temp-file that is never written out to\n    ** disk and uses an in-memory rollback journal.\n    **\n    ** This branch also runs for files marked as immutable.\n    */ \nact_like_temp_file:\n    tempFile = 1;\n    pPager->eState = PAGER_READER;     /* Pretend we already have a lock */\n    pPager->eLock = EXCLUSIVE_LOCK;    /* Pretend we are in EXCLUSIVE mode */\n    pPager->noLock = 1;                /* Do no locking */\n    readOnly = (vfsFlags&SQLITE_OPEN_READONLY);\n  }\n\n  /* The following call to PagerSetPagesize() serves to set the value of \n  ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer.\n  */\n  if( rc==SQLITE_OK ){\n    assert( pPager->memDb==0 );\n    rc = sqlite3PagerSetPagesize(pPager, &szPageDflt, -1);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  /* Initialize the PCache object. */\n  if( rc==SQLITE_OK ){\n    nExtra = ROUND8(nExtra);\n    assert( nExtra>=8 && nExtra<1000 );\n    rc = sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,\n                       !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);\n  }\n\n  /* If an error occurred above, free the  Pager structure and close the file.\n  */\n  if( rc!=SQLITE_OK ){\n    sqlite3OsClose(pPager->fd);\n    sqlite3PageFree(pPager->pTmpSpace);\n    sqlite3_free(pPager);\n    return rc;\n  }\n\n  PAGERTRACE((\"OPEN %d %s\\n\", FILEHANDLEID(pPager->fd), pPager->zFilename));\n  IOTRACE((\"OPEN %p %s\\n\", pPager, pPager->zFilename))\n\n  pPager->useJournal = (u8)useJournal;\n  /* pPager->stmtOpen = 0; */\n  /* pPager->stmtInUse = 0; */\n  /* pPager->nRef = 0; */\n  /* pPager->stmtSize = 0; */\n  /* pPager->stmtJSize = 0; */\n  /* pPager->nPage = 0; */\n  pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;\n  /* pPager->state = PAGER_UNLOCK; */\n  /* pPager->errMask = 0; */\n  pPager->tempFile = (u8)tempFile;\n  assert( tempFile==PAGER_LOCKINGMODE_NORMAL \n          || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 );\n  pPager->exclusiveMode = (u8)tempFile; \n  pPager->changeCountDone = pPager->tempFile;\n  pPager->memDb = (u8)memDb;\n  pPager->readOnly = (u8)readOnly;\n  assert( useJournal || pPager->tempFile );\n  pPager->noSync = pPager->tempFile;\n  if( pPager->noSync ){\n    assert( pPager->fullSync==0 );\n    assert( pPager->extraSync==0 );\n    assert( pPager->syncFlags==0 );\n    assert( pPager->walSyncFlags==0 );\n  }else{\n    pPager->fullSync = 1;\n    pPager->extraSync = 0;\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->walSyncFlags = SQLITE_SYNC_NORMAL | (SQLITE_SYNC_NORMAL<<2);\n  }\n  /* pPager->pFirst = 0; */\n  /* pPager->pFirstSynced = 0; */\n  /* pPager->pLast = 0; */\n  pPager->nExtra = (u16)nExtra;\n  pPager->journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT;\n  assert( isOpen(pPager->fd) || tempFile );\n  setSectorSize(pPager);\n  if( !useJournal ){\n    pPager->journalMode = PAGER_JOURNALMODE_OFF;\n  }else if( memDb ){\n    pPager->journalMode = PAGER_JOURNALMODE_MEMORY;\n  }\n  /* pPager->xBusyHandler = 0; */\n  /* pPager->pBusyHandlerArg = 0; */\n  pPager->xReiniter = xReinit;\n  setGetterMethod(pPager);\n  /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */\n  /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */\n\n  *ppPager = pPager;\n  return SQLITE_OK;\n}\n\n\n/* Verify that the database file has not be deleted or renamed out from\n** under the pager.  Return SQLITE_OK if the database is still were it ought\n** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error\n** code from sqlite3OsAccess()) if the database has gone missing.\n*/\nstatic int databaseIsUnmoved(Pager *pPager){\n  int bHasMoved = 0;\n  int rc;\n\n  if( pPager->tempFile ) return SQLITE_OK;\n  if( pPager->dbSize==0 ) return SQLITE_OK;\n  assert( pPager->zFilename && pPager->zFilename[0] );\n  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);\n  if( rc==SQLITE_NOTFOUND ){\n    /* If the HAS_MOVED file-control is unimplemented, assume that the file\n    ** has not been moved.  That is the historical behavior of SQLite: prior to\n    ** version 3.8.3, it never checked */\n    rc = SQLITE_OK;\n  }else if( rc==SQLITE_OK && bHasMoved ){\n    rc = SQLITE_READONLY_DBMOVED;\n  }\n  return rc;\n}\n\n\n/*\n** This function is called after transitioning from PAGER_UNLOCK to\n** PAGER_SHARED state. It tests if there is a hot journal present in\n** the file-system for the given pager. A hot journal is one that \n** needs to be played back. According to this function, a hot-journal\n** file exists if the following criteria are met:\n**\n**   * The journal file exists in the file system, and\n**   * No process holds a RESERVED or greater lock on the database file, and\n**   * The database file itself is greater than 0 bytes in size, and\n**   * The first byte of the journal file exists and is not 0x00.\n**\n** If the current size of the database file is 0 but a journal file\n** exists, that is probably an old journal left over from a prior\n** database with the same name. In this case the journal file is\n** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK\n** is returned.\n**\n** This routine does not check if there is a master journal filename\n** at the end of the file. If there is, and that master journal file\n** does not exist, then the journal file is not really hot. In this\n** case this routine will return a false-positive. The pager_playback()\n** routine will discover that the journal file is not really hot and \n** will not roll it back. \n**\n** If a hot-journal file is found to exist, *pExists is set to 1 and \n** SQLITE_OK returned. If no hot-journal file is present, *pExists is\n** set to 0 and SQLITE_OK returned. If an IO error occurs while trying\n** to determine whether or not a hot-journal file exists, the IO error\n** code is returned and the value of *pExists is undefined.\n*/\nstatic int hasHotJournal(Pager *pPager, int *pExists){\n  sqlite3_vfs * const pVfs = pPager->pVfs;\n  int rc = SQLITE_OK;           /* Return code */\n  int exists = 1;               /* True if a journal file is present */\n  int jrnlOpen = !!isOpen(pPager->jfd);\n\n  assert( pPager->useJournal );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->eState==PAGER_OPEN );\n\n  assert( jrnlOpen==0 || ( sqlite3OsDeviceCharacteristics(pPager->jfd) &\n    SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n  ));\n\n  *pExists = 0;\n  if( !jrnlOpen ){\n    rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);\n  }\n  if( rc==SQLITE_OK && exists ){\n    int locked = 0;             /* True if some process holds a RESERVED lock */\n\n    /* Race condition here:  Another process might have been holding the\n    ** the RESERVED lock and have a journal open at the sqlite3OsAccess() \n    ** call above, but then delete the journal and drop the lock before\n    ** we get to the following sqlite3OsCheckReservedLock() call.  If that\n    ** is the case, this routine might think there is a hot journal when\n    ** in fact there is none.  This results in a false-positive which will\n    ** be dealt with by the playback routine.  Ticket #3883.\n    */\n    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);\n    if( rc==SQLITE_OK && !locked ){\n      Pgno nPage;                 /* Number of pages in database file */\n\n      assert( pPager->tempFile==0 );\n      rc = pagerPagecount(pPager, &nPage);\n      if( rc==SQLITE_OK ){\n        /* If the database is zero pages in size, that means that either (1) the\n        ** journal is a remnant from a prior database with the same name where\n        ** the database file but not the journal was deleted, or (2) the initial\n        ** transaction that populates a new database is being rolled back.\n        ** In either case, the journal file can be deleted.  However, take care\n        ** not to delete the journal file if it is already open due to\n        ** journal_mode=PERSIST.\n        */\n        if( nPage==0 && !jrnlOpen ){\n          sqlite3BeginBenignMalloc();\n          if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){\n            sqlite3OsDelete(pVfs, pPager->zJournal, 0);\n            if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n          }\n          sqlite3EndBenignMalloc();\n        }else{\n          /* The journal file exists and no other connection has a reserved\n          ** or greater lock on the database file. Now check that there is\n          ** at least one non-zero bytes at the start of the journal file.\n          ** If there is, then we consider this journal to be hot. If not, \n          ** it can be ignored.\n          */\n          if( !jrnlOpen ){\n            int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;\n            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);\n          }\n          if( rc==SQLITE_OK ){\n            u8 first = 0;\n            rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);\n            if( rc==SQLITE_IOERR_SHORT_READ ){\n              rc = SQLITE_OK;\n            }\n            if( !jrnlOpen ){\n              sqlite3OsClose(pPager->jfd);\n            }\n            *pExists = (first!=0);\n          }else if( rc==SQLITE_CANTOPEN ){\n            /* If we cannot open the rollback journal file in order to see if\n            ** it has a zero header, that might be due to an I/O error, or\n            ** it might be due to the race condition described above and in\n            ** ticket #3883.  Either way, assume that the journal is hot.\n            ** This might be a false positive.  But if it is, then the\n            ** automatic journal playback and recovery mechanism will deal\n            ** with it under an EXCLUSIVE lock where we do not need to\n            ** worry so much with race conditions.\n            */\n            *pExists = 1;\n            rc = SQLITE_OK;\n          }\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to obtain a shared lock on the database file.\n** It is illegal to call sqlite3PagerGet() until after this function\n** has been successfully called. If a shared-lock is already held when\n** this function is called, it is a no-op.\n**\n** The following operations are also performed by this function.\n**\n**   1) If the pager is currently in PAGER_OPEN state (no lock held\n**      on the database file), then an attempt is made to obtain a\n**      SHARED lock on the database file. Immediately after obtaining\n**      the SHARED lock, the file-system is checked for a hot-journal,\n**      which is played back if present. Following any hot-journal \n**      rollback, the contents of the cache are validated by checking\n**      the 'change-counter' field of the database file header and\n**      discarded if they are found to be invalid.\n**\n**   2) If the pager is running in exclusive-mode, and there are currently\n**      no outstanding references to any pages, and is in the error state,\n**      then an attempt is made to clear the error state by discarding\n**      the contents of the page cache and rolling back any open journal\n**      file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs while locking the database, checking for a hot-journal file or \n** rolling back a journal file, the IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){\n  int rc = SQLITE_OK;                /* Return code */\n\n  /* This routine is only called from b-tree and only when there are no\n  ** outstanding pages. This implies that the pager state should either\n  ** be OPEN or READER. READER is only possible if the pager is or was in \n  ** exclusive access mode.  */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( !pagerUseWal(pPager) && pPager->eState==PAGER_OPEN ){\n    int bHotJournal = 1;          /* True if there exists a hot journal-file */\n\n    assert( !MEMDB );\n    assert( pPager->tempFile==0 || pPager->eLock==EXCLUSIVE_LOCK );\n\n    rc = pager_wait_on_lock(pPager, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK );\n      goto failed;\n    }\n\n    /* If a journal file exists, and there is no RESERVED lock on the\n    ** database file, then it either needs to be played back or deleted.\n    */\n    if( pPager->eLock<=SHARED_LOCK ){\n      rc = hasHotJournal(pPager, &bHotJournal);\n    }\n    if( rc!=SQLITE_OK ){\n      goto failed;\n    }\n    if( bHotJournal ){\n      if( pPager->readOnly ){\n        rc = SQLITE_READONLY_ROLLBACK;\n        goto failed;\n      }\n\n      /* Get an EXCLUSIVE lock on the database file. At this point it is\n      ** important that a RESERVED lock is not obtained on the way to the\n      ** EXCLUSIVE lock. If it were, another process might open the\n      ** database file, detect the RESERVED lock, and conclude that the\n      ** database is safe to read while this process is still rolling the \n      ** hot-journal back.\n      ** \n      ** Because the intermediate RESERVED lock is not requested, any\n      ** other process attempting to access the database file will get to \n      ** this point in the code and fail to obtain its own EXCLUSIVE lock \n      ** on the database file.\n      **\n      ** Unless the pager is in locking_mode=exclusive mode, the lock is\n      ** downgraded to SHARED_LOCK before this function returns.\n      */\n      rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n      if( rc!=SQLITE_OK ){\n        goto failed;\n      }\n \n      /* If it is not already open and the file exists on disk, open the \n      ** journal for read/write access. Write access is required because \n      ** in exclusive-access mode the file descriptor will be kept open \n      ** and possibly used for a transaction later on. Also, write-access \n      ** is usually required to finalize the journal in journal_mode=persist \n      ** mode (and also for journal_mode=truncate on some systems).\n      **\n      ** If the journal does not exist, it usually means that some \n      ** other connection managed to get in and roll it back before \n      ** this connection obtained the exclusive lock above. Or, it \n      ** may mean that the pager was in the error-state when this\n      ** function was called and the journal file does not exist.\n      */\n      if( !isOpen(pPager->jfd) ){\n        sqlite3_vfs * const pVfs = pPager->pVfs;\n        int bExists;              /* True if journal file exists */\n        rc = sqlite3OsAccess(\n            pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);\n        if( rc==SQLITE_OK && bExists ){\n          int fout = 0;\n          int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;\n          assert( !pPager->tempFile );\n          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);\n          assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n          if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){\n            rc = SQLITE_CANTOPEN_BKPT;\n            sqlite3OsClose(pPager->jfd);\n          }\n        }\n      }\n \n      /* Playback and delete the journal.  Drop the database write\n      ** lock and reacquire the read lock. Purge the cache before\n      ** playing back the hot-journal so that we don't end up with\n      ** an inconsistent cache.  Sync the hot journal before playing\n      ** it back since the process that crashed and left the hot journal\n      ** probably did not sync it and we are required to always sync\n      ** the journal before playing it back.\n      */\n      if( isOpen(pPager->jfd) ){\n        assert( rc==SQLITE_OK );\n        rc = pagerSyncHotJournal(pPager);\n        if( rc==SQLITE_OK ){\n          rc = pager_playback(pPager, !pPager->tempFile);\n          pPager->eState = PAGER_OPEN;\n        }\n      }else if( !pPager->exclusiveMode ){\n        pagerUnlockDb(pPager, SHARED_LOCK);\n      }\n\n      if( rc!=SQLITE_OK ){\n        /* This branch is taken if an error occurs while trying to open\n        ** or roll back a hot-journal while holding an EXCLUSIVE lock. The\n        ** pager_unlock() routine will be called before returning to unlock\n        ** the file. If the unlock attempt fails, then Pager.eLock must be\n        ** set to UNKNOWN_LOCK (see the comment above the #define for \n        ** UNKNOWN_LOCK above for an explanation). \n        **\n        ** In order to get pager_unlock() to do this, set Pager.eState to\n        ** PAGER_ERROR now. This is not actually counted as a transition\n        ** to ERROR state in the state diagram at the top of this file,\n        ** since we know that the same call to pager_unlock() will very\n        ** shortly transition the pager object to the OPEN state. Calling\n        ** assert_pager_state() would fail now, as it should not be possible\n        ** to be in ERROR state when there are zero outstanding page \n        ** references.\n        */\n        pager_error(pPager, rc);\n        goto failed;\n      }\n\n      assert( pPager->eState==PAGER_OPEN );\n      assert( (pPager->eLock==SHARED_LOCK)\n           || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK)\n      );\n    }\n\n    if( !pPager->tempFile && pPager->hasHeldSharedLock ){\n      /* The shared-lock has just been acquired then check to\n      ** see if the database has been modified.  If the database has changed,\n      ** flush the cache.  The hasHeldSharedLock flag prevents this from\n      ** occurring on the very first access to a file, in order to save a\n      ** single unnecessary sqlite3OsRead() call at the start-up.\n      **\n      ** Database changes are detected by looking at 15 bytes beginning\n      ** at offset 24 into the file.  The first 4 of these 16 bytes are\n      ** a 32-bit counter that is incremented with each change.  The\n      ** other bytes change randomly with each file change when\n      ** a codec is in use.\n      ** \n      ** There is a vanishingly small chance that a change will not be \n      ** detected.  The chance of an undetected change is so small that\n      ** it can be neglected.\n      */\n      char dbFileVers[sizeof(pPager->dbFileVers)];\n\n      IOTRACE((\"CKVERS %p %d\\n\", pPager, sizeof(dbFileVers)));\n      rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);\n      if( rc!=SQLITE_OK ){\n        if( rc!=SQLITE_IOERR_SHORT_READ ){\n          goto failed;\n        }\n        memset(dbFileVers, 0, sizeof(dbFileVers));\n      }\n\n      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){\n        pager_reset(pPager);\n\n        /* Unmap the database file. It is possible that external processes\n        ** may have truncated the database file and then extended it back\n        ** to its original size while this process was not holding a lock.\n        ** In this case there may exist a Pager.pMap mapping that appears\n        ** to be the right size but is not actually valid. Avoid this\n        ** possibility by unmapping the db here. */\n        if( USEFETCH(pPager) ){\n          sqlite3OsUnfetch(pPager->fd, 0, 0);\n        }\n      }\n    }\n\n    /* If there is a WAL file in the file-system, open this database in WAL\n    ** mode. Otherwise, the following function call is a no-op.\n    */\n    rc = pagerOpenWalIfPresent(pPager);\n#ifndef SQLITE_OMIT_WAL\n    assert( pPager->pWal==0 || rc==SQLITE_OK );\n#endif\n  }\n\n  if( pagerUseWal(pPager) ){\n    assert( rc==SQLITE_OK );\n    rc = pagerBeginReadTransaction(pPager);\n  }\n\n  if( pPager->tempFile==0 && pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){\n    rc = pagerPagecount(pPager, &pPager->dbSize);\n  }\n\n failed:\n  if( rc!=SQLITE_OK ){\n    assert( !MEMDB );\n    pager_unlock(pPager);\n    assert( pPager->eState==PAGER_OPEN );\n  }else{\n    pPager->eState = PAGER_READER;\n    pPager->hasHeldSharedLock = 1;\n  }\n  return rc;\n}\n\n/*\n** If the reference count has reached zero, rollback any active\n** transaction and unlock the pager.\n**\n** Except, in locking_mode=EXCLUSIVE when there is nothing to in\n** the rollback journal, the unlock is not performed and there is\n** nothing to rollback, so this routine is a no-op.\n*/ \nstatic void pagerUnlockIfUnused(Pager *pPager){\n  if( sqlite3PcacheRefCount(pPager->pPCache)==0 ){\n    assert( pPager->nMmapOut==0 ); /* because page1 is never memory mapped */\n    pagerUnlockAndRollback(pPager);\n  }\n}\n\n/*\n** The page getter methods each try to acquire a reference to a\n** page with page number pgno. If the requested reference is \n** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.\n**\n** There are different implementations of the getter method depending\n** on the current state of the pager.\n**\n**     getPageNormal()         --  The normal getter\n**     getPageError()          --  Used if the pager is in an error state\n**     getPageMmap()           --  Used if memory-mapped I/O is enabled\n**\n** If the requested page is already in the cache, it is returned. \n** Otherwise, a new page object is allocated and populated with data\n** read from the database file. In some cases, the pcache module may\n** choose not to allocate a new page object and may reuse an existing\n** object with no outstanding references.\n**\n** The extra data appended to a page is always initialized to zeros the \n** first time a page is loaded into memory. If the page requested is \n** already in the cache when this function is called, then the extra\n** data is left as it was when the page object was last used.\n**\n** If the database image is smaller than the requested page or if \n** the flags parameter contains the PAGER_GET_NOCONTENT bit and the \n** requested page is not already stored in the cache, then no \n** actual disk read occurs. In this case the memory image of the \n** page is initialized to all zeros. \n**\n** If PAGER_GET_NOCONTENT is true, it means that we do not care about\n** the contents of the page. This occurs in two scenarios:\n**\n**   a) When reading a free-list leaf page from the database, and\n**\n**   b) When a savepoint is being rolled back and we need to load\n**      a new page into the cache to be filled with the data read\n**      from the savepoint journal.\n**\n** If PAGER_GET_NOCONTENT is true, then the data returned is zeroed instead\n** of being read from the database. Additionally, the bits corresponding\n** to pgno in Pager.pInJournal (bitvec of pages already written to the\n** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open\n** savepoints are set. This means if the page is made writable at any\n** point in the future, using a call to sqlite3PagerWrite(), its contents\n** will not be journaled. This saves IO.\n**\n** The acquisition might fail for several reasons.  In all cases,\n** an appropriate error code is returned and *ppPage is set to NULL.\n**\n** See also sqlite3PagerLookup().  Both this routine and Lookup() attempt\n** to find a page in the in-memory cache first.  If the page is not already\n** in memory, this routine goes to disk to read it in whereas Lookup()\n** just returns 0.  This routine acquires a read-lock the first time it\n** has to go to disk, and could also playback an old journal if necessary.\n** Since Lookup() never goes to disk, it never has to deal with locks\n** or journal files.\n*/\nstatic int getPageNormal(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg;\n  u8 noContent;                   /* True if PAGER_GET_NOCONTENT is set */\n  sqlite3_pcache_page *pBase;\n\n  assert( pPager->errCode==SQLITE_OK );\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n\n  if( pgno==0 ) return SQLITE_CORRUPT_BKPT;\n  pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);\n  if( pBase==0 ){\n    pPg = 0;\n    rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);\n    if( rc!=SQLITE_OK ) goto pager_acquire_err;\n    if( pBase==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto pager_acquire_err;\n    }\n  }\n  pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);\n  assert( pPg==(*ppPage) );\n  assert( pPg->pgno==pgno );\n  assert( pPg->pPager==pPager || pPg->pPager==0 );\n\n  noContent = (flags & PAGER_GET_NOCONTENT)!=0;\n  if( pPg->pPager && !noContent ){\n    /* In this case the pcache already contains an initialized copy of\n    ** the page. Return without further ado.  */\n    assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );\n    pPager->aStat[PAGER_STAT_HIT]++;\n    return SQLITE_OK;\n\n  }else{\n    /* The pager cache has created a new page. Its content needs to \n    ** be initialized. But first some error checks:\n    **\n    ** (1) The maximum page number is 2^31\n    ** (2) Never try to fetch the locking page\n    */\n    if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto pager_acquire_err;\n    }\n\n    pPg->pPager = pPager;\n\n    assert( !isOpen(pPager->fd) || !MEMDB );\n    if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){\n      if( pgno>pPager->mxPgno ){\n        rc = SQLITE_FULL;\n        goto pager_acquire_err;\n      }\n      if( noContent ){\n        /* Failure to set the bits in the InJournal bit-vectors is benign.\n        ** It merely means that we might do some extra work to journal a \n        ** page that does not need to be journaled.  Nevertheless, be sure \n        ** to test the case where a malloc error occurs while trying to set \n        ** a bit in a bit vector.\n        */\n        sqlite3BeginBenignMalloc();\n        if( pgno<=pPager->dbOrigSize ){\n          TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);\n          testcase( rc==SQLITE_NOMEM );\n        }\n        TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);\n        testcase( rc==SQLITE_NOMEM );\n        sqlite3EndBenignMalloc();\n      }\n      memset(pPg->pData, 0, pPager->pageSize);\n      IOTRACE((\"ZERO %p %d\\n\", pPager, pgno));\n    }else{\n      assert( pPg->pPager==pPager );\n      pPager->aStat[PAGER_STAT_MISS]++;\n      rc = readDbPage(pPg);\n      if( rc!=SQLITE_OK ){\n        goto pager_acquire_err;\n      }\n    }\n    pager_set_pagehash(pPg);\n  }\n  return SQLITE_OK;\n\npager_acquire_err:\n  assert( rc!=SQLITE_OK );\n  if( pPg ){\n    sqlite3PcacheDrop(pPg);\n  }\n  pagerUnlockIfUnused(pPager);\n  *ppPage = 0;\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The page getter for when memory-mapped I/O is enabled */\nstatic int getPageMMap(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg = 0;\n  u32 iFrame = 0;                 /* Frame to read from WAL file */\n\n  /* It is acceptable to use a read-only (mmap) page for any page except\n  ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY\n  ** flag was specified by the caller. And so long as the db is not a \n  ** temporary or in-memory database.  */\n  const int bMmapOk = (pgno>1\n   && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))\n  );\n\n  assert( USEFETCH(pPager) );\n#ifdef SQLITE_HAS_CODEC\n  assert( pPager->xCodec==0 );\n#endif\n\n  /* Optimization note:  Adding the \"pgno<=1\" term before \"pgno==0\" here\n  ** allows the compiler optimizer to reuse the results of the \"pgno>1\"\n  ** test in the previous statement, and avoid testing pgno==0 in the\n  ** common case where pgno is large. */\n  if( pgno<=1 && pgno==0 ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( bMmapOk && pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  if( bMmapOk && iFrame==0 ){\n    void *pData = 0;\n    rc = sqlite3OsFetch(pPager->fd, \n        (i64)(pgno-1) * pPager->pageSize, pPager->pageSize, &pData\n    );\n    if( rc==SQLITE_OK && pData ){\n      if( pPager->eState>PAGER_READER || pPager->tempFile ){\n        pPg = sqlite3PagerLookup(pPager, pgno);\n      }\n      if( pPg==0 ){\n        rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);\n     }else{\n        sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1)*pPager->pageSize, pData);\n      }\n      if( pPg ){\n        assert( rc==SQLITE_OK );\n        *ppPage = pPg;\n        return SQLITE_OK;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  return getPageNormal(pPager, pgno, ppPage, flags);\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/* The page getter method for when the pager is an error state */\nstatic int getPageError(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  UNUSED_PARAMETER(pgno);\n  UNUSED_PARAMETER(flags);\n  assert( pPager->errCode!=SQLITE_OK );\n  *ppPage = 0;\n  return pPager->errCode;\n}\n\n\n/* Dispatch all page fetch requests to the appropriate getter method.\n*/\nSQLITE_PRIVATE int sqlite3PagerGet(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  return pPager->xGet(pPager, pgno, ppPage, flags);\n}\n\n/*\n** Acquire a page if it is already in the in-memory cache.  Do\n** not read the page from disk.  Return a pointer to the page,\n** or 0 if the page is not in cache. \n**\n** See also sqlite3PagerGet().  The difference between this routine\n** and sqlite3PagerGet() is that _get() will go to the disk and read\n** in the page if the page is not already in cache.  This routine\n** returns NULL if the page is not in cache or if a disk I/O error \n** has ever happened.\n*/\nSQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){\n  sqlite3_pcache_page *pPage;\n  assert( pPager!=0 );\n  assert( pgno!=0 );\n  assert( pPager->pPCache!=0 );\n  pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0);\n  assert( pPage==0 || pPager->hasHeldSharedLock );\n  if( pPage==0 ) return 0;\n  return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage);\n}\n\n/*\n** Release a page reference.\n**\n** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be\n** used if we know that the page being released is not the last page.\n** The btree layer always holds page1 open until the end, so these first\n** to routines can be used to release any page other than BtShared.pPage1.\n**\n** Use sqlite3PagerUnrefPageOne() to release page1.  This latter routine\n** checks the total number of outstanding pages and if the number of\n** pages reaches zero it drops the database lock.\n*/\nSQLITE_PRIVATE void sqlite3PagerUnrefNotNull(DbPage *pPg){\n  TESTONLY( Pager *pPager = pPg->pPager; )\n  assert( pPg!=0 );\n  if( pPg->flags & PGHDR_MMAP ){\n    assert( pPg->pgno!=1 );  /* Page1 is never memory mapped */\n    pagerReleaseMapPage(pPg);\n  }else{\n    sqlite3PcacheRelease(pPg);\n  }\n  /* Do not use this routine to release the last reference to page1 */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );\n}\nSQLITE_PRIVATE void sqlite3PagerUnref(DbPage *pPg){\n  if( pPg ) sqlite3PagerUnrefNotNull(pPg);\n}\nSQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){\n  Pager *pPager;\n  assert( pPg!=0 );\n  assert( pPg->pgno==1 );\n  assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */\n  pPager = pPg->pPager;\n  sqlite3PcacheRelease(pPg);\n  pagerUnlockIfUnused(pPager);\n}\n\n/*\n** This function is called at the start of every write transaction.\n** There must already be a RESERVED or EXCLUSIVE lock on the database \n** file when this routine is called.\n**\n** Open the journal file for pager pPager and write a journal header\n** to the start of it. If there are active savepoints, open the sub-journal\n** as well. This function is only used when the journal file is being \n** opened to write a rollback log for a transaction. It is not used \n** when opening a hot journal file to roll it back.\n**\n** If the journal file is already open (as it may be in exclusive mode),\n** then this function just writes a journal header to the start of the\n** already open file. \n**\n** Whether or not the journal file is opened by this function, the\n** Pager.pInJournal bitvec structure is allocated.\n**\n** Return SQLITE_OK if everything is successful. Otherwise, return \n** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or \n** an IO error code if opening or writing the journal file fails.\n*/\nstatic int pager_open_journal(Pager *pPager){\n  int rc = SQLITE_OK;                        /* Return code */\n  sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->pInJournal==0 );\n  \n  /* If already in the error state, this function is a no-op.  But on\n  ** the other hand, this routine is never called if we are already in\n  ** an error state. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);\n    if( pPager->pInJournal==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  \n    /* Open the journal file if it is not already open. */\n    if( !isOpen(pPager->jfd) ){\n      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){\n        sqlite3MemJournalOpen(pPager->jfd);\n      }else{\n        int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;\n        int nSpill;\n\n        if( pPager->tempFile ){\n          flags |= (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL);\n          nSpill = sqlite3Config.nStmtSpill;\n        }else{\n          flags |= SQLITE_OPEN_MAIN_JOURNAL;\n          nSpill = jrnlBufferSize(pPager);\n        }\n          \n        /* Verify that the database still has the same name as it did when\n        ** it was originally opened. */\n        rc = databaseIsUnmoved(pPager);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3JournalOpen (\n              pVfs, pPager->zJournal, pPager->jfd, flags, nSpill\n          );\n        }\n      }\n      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n    }\n  \n  \n    /* Write the first journal header to the journal file and open \n    ** the sub-journal if necessary.\n    */\n    if( rc==SQLITE_OK ){\n      /* TODO: Check if all of these are really required. */\n      pPager->nRec = 0;\n      pPager->journalOff = 0;\n      pPager->setMaster = 0;\n      pPager->journalHdr = 0;\n      rc = writeJournalHdr(pPager);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3BitvecDestroy(pPager->pInJournal);\n    pPager->pInJournal = 0;\n  }else{\n    assert( pPager->eState==PAGER_WRITER_LOCKED );\n    pPager->eState = PAGER_WRITER_CACHEMOD;\n  }\n\n  return rc;\n}\n\n/*\n** Begin a write-transaction on the specified pager object. If a \n** write-transaction has already been opened, this function is a no-op.\n**\n** If the exFlag argument is false, then acquire at least a RESERVED\n** lock on the database file. If exFlag is true, then acquire at least\n** an EXCLUSIVE lock. If such a lock is already held, no locking \n** functions need be called.\n**\n** If the subjInMemory argument is non-zero, then any sub-journal opened\n** within this transaction will be opened as an in-memory file. This\n** has no effect if the sub-journal is already opened (as it may be when\n** running in exclusive mode) or if the transaction does not require a\n** sub-journal. If the subjInMemory argument is zero, then any required\n** sub-journal is implemented in-memory if pPager is an in-memory database, \n** or using a temporary file otherwise.\n*/\nSQLITE_PRIVATE int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){\n  int rc = SQLITE_OK;\n\n  if( pPager->errCode ) return pPager->errCode;\n  assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );\n  pPager->subjInMemory = (u8)subjInMemory;\n\n  if( ALWAYS(pPager->eState==PAGER_READER) ){\n    assert( pPager->pInJournal==0 );\n\n    if( pagerUseWal(pPager) ){\n      /* If the pager is configured to use locking_mode=exclusive, and an\n      ** exclusive lock on the database is not already held, obtain it now.\n      */\n      if( pPager->exclusiveMode && sqlite3WalExclusiveMode(pPager->pWal, -1) ){\n        rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        (void)sqlite3WalExclusiveMode(pPager->pWal, 1);\n      }\n\n      /* Grab the write lock on the log file. If successful, upgrade to\n      ** PAGER_RESERVED state. Otherwise, return an error code to the caller.\n      ** The busy-handler is not invoked if another connection already\n      ** holds the write-lock. If possible, the upper layer will call it.\n      */\n      rc = sqlite3WalBeginWriteTransaction(pPager->pWal);\n    }else{\n      /* Obtain a RESERVED lock on the database file. If the exFlag parameter\n      ** is true, then immediately upgrade this to an EXCLUSIVE lock. The\n      ** busy-handler callback can be used when upgrading to the EXCLUSIVE\n      ** lock, but not when obtaining the RESERVED lock.\n      */\n      rc = pagerLockDb(pPager, RESERVED_LOCK);\n      if( rc==SQLITE_OK && exFlag ){\n        rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Change to WRITER_LOCKED state.\n      **\n      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD\n      ** when it has an open transaction, but never to DBMOD or FINISHED.\n      ** This is because in those states the code to roll back savepoint \n      ** transactions may copy data from the sub-journal into the database \n      ** file as well as into the page cache. Which would be incorrect in \n      ** WAL mode.\n      */\n      pPager->eState = PAGER_WRITER_LOCKED;\n      pPager->dbHintSize = pPager->dbSize;\n      pPager->dbFileSize = pPager->dbSize;\n      pPager->dbOrigSize = pPager->dbSize;\n      pPager->journalOff = 0;\n    }\n\n    assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );\n    assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );\n    assert( assert_pager_state(pPager) );\n  }\n\n  PAGERTRACE((\"TRANSACTION %d\\n\", PAGERID(pPager)));\n  return rc;\n}\n\n/*\n** Write page pPg onto the end of the rollback journal.\n*/\nstatic SQLITE_NOINLINE int pagerAddPageToRollbackJournal(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc;\n  u32 cksum;\n  char *pData2;\n  i64 iOff = pPager->journalOff;\n\n  /* We should never write to the journal file the page that\n  ** contains the database locks.  The following assert verifies\n  ** that we do not. */\n  assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );\n\n  assert( pPager->journalHdr<=pPager->journalOff );\n  CODEC2(pPager, pPg->pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n  cksum = pager_cksum(pPager, (u8*)pData2);\n\n  /* Even if an IO or diskfull error occurs while journalling the\n  ** page in the block above, set the need-sync flag for the page.\n  ** Otherwise, when the transaction is rolled back, the logic in\n  ** playback_one_page() will think that the page needs to be restored\n  ** in the database file. And if an IO error occurs while doing so,\n  ** then corruption may follow.\n  */\n  pPg->flags |= PGHDR_NEED_SYNC;\n\n  rc = write32bits(pPager->jfd, iOff, pPg->pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);\n  if( rc!=SQLITE_OK ) return rc;\n\n  IOTRACE((\"JOUT %p %d %lld %d\\n\", pPager, pPg->pgno, \n           pPager->journalOff, pPager->pageSize));\n  PAGER_INCR(sqlite3_pager_writej_count);\n  PAGERTRACE((\"JOURNAL %d page %d needSync=%d hash(%08x)\\n\",\n       PAGERID(pPager), pPg->pgno, \n       ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));\n\n  pPager->journalOff += 8 + pPager->pageSize;\n  pPager->nRec++;\n  assert( pPager->pInJournal!=0 );\n  rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);\n  testcase( rc==SQLITE_NOMEM );\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  rc |= addToSavepointBitvecs(pPager, pPg->pgno);\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  return rc;\n}\n\n/*\n** Mark a single data page as writeable. The page is written into the \n** main journal or sub-journal as required. If the page is written into\n** one of the journals, the corresponding bit is set in the \n** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs\n** of any open savepoints as appropriate.\n*/\nstatic int pager_write(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc = SQLITE_OK;\n\n  /* This routine is not called unless a write-transaction has already \n  ** been started. The journal file may or may not be open at this point.\n  ** It is never called in the ERROR state.\n  */\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->errCode==0 );\n  assert( pPager->readOnly==0 );\n  CHECK_PAGE(pPg);\n\n  /* The journal file needs to be opened. Higher level routines have already\n  ** obtained the necessary locks to begin the write-transaction, but the\n  ** rollback journal might not yet be open. Open it now if this is the case.\n  **\n  ** This is done before calling sqlite3PcacheMakeDirty() on the page. \n  ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then\n  ** an error might occur and the pager would end up in WRITER_LOCKED state\n  ** with pages marked as dirty in the cache.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED ){\n    rc = pager_open_journal(pPager);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  assert( assert_pager_state(pPager) );\n\n  /* Mark the page that is about to be modified as dirty. */\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* If a rollback journal is in use, them make sure the page that is about\n  ** to change is in the rollback journal, or if the page is a new page off\n  ** then end of the file, make sure it is marked as PGHDR_NEED_SYNC.\n  */\n  assert( (pPager->pInJournal!=0) == isOpen(pPager->jfd) );\n  if( pPager->pInJournal!=0\n   && sqlite3BitvecTestNotNull(pPager->pInJournal, pPg->pgno)==0\n  ){\n    assert( pagerUseWal(pPager)==0 );\n    if( pPg->pgno<=pPager->dbOrigSize ){\n      rc = pagerAddPageToRollbackJournal(pPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      if( pPager->eState!=PAGER_WRITER_DBMOD ){\n        pPg->flags |= PGHDR_NEED_SYNC;\n      }\n      PAGERTRACE((\"APPEND %d page %d needSync=%d\\n\",\n              PAGERID(pPager), pPg->pgno,\n             ((pPg->flags&PGHDR_NEED_SYNC)?1:0)));\n    }\n  }\n\n  /* The PGHDR_DIRTY bit is set above when the page was added to the dirty-list\n  ** and before writing the page into the rollback journal.  Wait until now,\n  ** after the page has been successfully journalled, before setting the\n  ** PGHDR_WRITEABLE bit that indicates that the page can be safely modified.\n  */\n  pPg->flags |= PGHDR_WRITEABLE;\n  \n  /* If the statement journal is open and the page is not in it,\n  ** then write the page into the statement journal.\n  */\n  if( pPager->nSavepoint>0 ){\n    rc = subjournalPageIfRequired(pPg);\n  }\n\n  /* Update the database size and return. */\n  if( pPager->dbSize<pPg->pgno ){\n    pPager->dbSize = pPg->pgno;\n  }\n  return rc;\n}\n\n/*\n** This is a variant of sqlite3PagerWrite() that runs when the sector size\n** is larger than the page size.  SQLite makes the (reasonable) assumption that\n** all bytes of a sector are written together by hardware.  Hence, all bytes of\n** a sector need to be journalled in case of a power loss in the middle of\n** a write.\n**\n** Usually, the sector size is less than or equal to the page size, in which\n** case pages can be individually written.  This routine only runs in the\n** exceptional case where the page size is smaller than the sector size.\n*/\nstatic SQLITE_NOINLINE int pagerWriteLargeSector(PgHdr *pPg){\n  int rc = SQLITE_OK;          /* Return code */\n  Pgno nPageCount;             /* Total number of pages in database file */\n  Pgno pg1;                    /* First page of the sector pPg is located on. */\n  int nPage = 0;               /* Number of pages starting at pg1 to journal */\n  int ii;                      /* Loop counter */\n  int needSync = 0;            /* True if any page has PGHDR_NEED_SYNC */\n  Pager *pPager = pPg->pPager; /* The pager that owns pPg */\n  Pgno nPagePerSector = (pPager->sectorSize/pPager->pageSize);\n\n  /* Set the doNotSpill NOSYNC bit to 1. This is because we cannot allow\n  ** a journal header to be written between the pages journaled by\n  ** this function.\n  */\n  assert( !MEMDB );\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)==0 );\n  pPager->doNotSpill |= SPILLFLAG_NOSYNC;\n\n  /* This trick assumes that both the page-size and sector-size are\n  ** an integer power of 2. It sets variable pg1 to the identifier\n  ** of the first page of the sector pPg is located on.\n  */\n  pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;\n\n  nPageCount = pPager->dbSize;\n  if( pPg->pgno>nPageCount ){\n    nPage = (pPg->pgno - pg1)+1;\n  }else if( (pg1+nPagePerSector-1)>nPageCount ){\n    nPage = nPageCount+1-pg1;\n  }else{\n    nPage = nPagePerSector;\n  }\n  assert(nPage>0);\n  assert(pg1<=pPg->pgno);\n  assert((pg1+nPage)>pPg->pgno);\n\n  for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){\n    Pgno pg = pg1+ii;\n    PgHdr *pPage;\n    if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){\n      if( pg!=PAGER_MJ_PGNO(pPager) ){\n        rc = sqlite3PagerGet(pPager, pg, &pPage, 0);\n        if( rc==SQLITE_OK ){\n          rc = pager_write(pPage);\n          if( pPage->flags&PGHDR_NEED_SYNC ){\n            needSync = 1;\n          }\n          sqlite3PagerUnrefNotNull(pPage);\n        }\n      }\n    }else if( (pPage = sqlite3PagerLookup(pPager, pg))!=0 ){\n      if( pPage->flags&PGHDR_NEED_SYNC ){\n        needSync = 1;\n      }\n      sqlite3PagerUnrefNotNull(pPage);\n    }\n  }\n\n  /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages \n  ** starting at pg1, then it needs to be set for all of them. Because\n  ** writing to any of these nPage pages may damage the others, the\n  ** journal file must contain sync()ed copies of all of them\n  ** before any of them can be written out to the database file.\n  */\n  if( rc==SQLITE_OK && needSync ){\n    assert( !MEMDB );\n    for(ii=0; ii<nPage; ii++){\n      PgHdr *pPage = sqlite3PagerLookup(pPager, pg1+ii);\n      if( pPage ){\n        pPage->flags |= PGHDR_NEED_SYNC;\n        sqlite3PagerUnrefNotNull(pPage);\n      }\n    }\n  }\n\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)!=0 );\n  pPager->doNotSpill &= ~SPILLFLAG_NOSYNC;\n  return rc;\n}\n\n/*\n** Mark a data page as writeable. This routine must be called before \n** making changes to a page. The caller must check the return value \n** of this function and be careful not to change any page data unless \n** this routine returns SQLITE_OK.\n**\n** The difference between this function and pager_write() is that this\n** function also deals with the special case where 2 or more pages\n** fit on a single disk sector. In this case all co-resident pages\n** must have been written to the journal file before returning.\n**\n** If an error occurs, SQLITE_NOMEM or an IO error code is returned\n** as appropriate. Otherwise, SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( (pPg->flags & PGHDR_MMAP)==0 );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  if( (pPg->flags & PGHDR_WRITEABLE)!=0 && pPager->dbSize>=pPg->pgno ){\n    if( pPager->nSavepoint ) return subjournalPageIfRequired(pPg);\n    return SQLITE_OK;\n  }else if( pPager->errCode ){\n    return pPager->errCode;\n  }else if( pPager->sectorSize > (u32)pPager->pageSize ){\n    assert( pPager->tempFile==0 );\n    return pagerWriteLargeSector(pPg);\n  }else{\n    return pager_write(pPg);\n  }\n}\n\n/*\n** Return TRUE if the page given in the argument was previously passed\n** to sqlite3PagerWrite().  In other words, return TRUE if it is ok\n** to change the content of the page.\n*/\n#ifndef NDEBUG\nSQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage *pPg){\n  return pPg->flags & PGHDR_WRITEABLE;\n}\n#endif\n\n/*\n** A call to this routine tells the pager that it is not necessary to\n** write the information on page pPg back to the disk, even though\n** that page might be marked as dirty.  This happens, for example, when\n** the page has been added as a leaf of the freelist and so its\n** content no longer matters.\n**\n** The overlying software layer calls this routine when all of the data\n** on the given page is unused. The pager marks the page as clean so\n** that it does not get written to disk.\n**\n** Tests show that this optimization can quadruple the speed of large \n** DELETE operations.\n**\n** This optimization cannot be used with a temp-file, as the page may\n** have been dirty at the start of the transaction. In that case, if\n** memory pressure forces page pPg out of the cache, the data does need \n** to be written out to disk so that it may be read back in if the \n** current transaction is rolled back.\n*/\nSQLITE_PRIVATE void sqlite3PagerDontWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  if( !pPager->tempFile && (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){\n    PAGERTRACE((\"DONT_WRITE page %d of %d\\n\", pPg->pgno, PAGERID(pPager)));\n    IOTRACE((\"CLEAN %p %d\\n\", pPager, pPg->pgno))\n    pPg->flags |= PGHDR_DONT_WRITE;\n    pPg->flags &= ~PGHDR_WRITEABLE;\n    testcase( pPg->flags & PGHDR_NEED_SYNC );\n    pager_set_pagehash(pPg);\n  }\n}\n\n/*\n** This routine is called to increment the value of the database file \n** change-counter, stored as a 4-byte big-endian integer starting at \n** byte offset 24 of the pager file.  The secondary change counter at\n** 92 is also updated, as is the SQLite version number at offset 96.\n**\n** But this only happens if the pPager->changeCountDone flag is false.\n** To avoid excess churning of page 1, the update only happens once.\n** See also the pager_write_changecounter() routine that does an \n** unconditional update of the change counters.\n**\n** If the isDirectMode flag is zero, then this is done by calling \n** sqlite3PagerWrite() on page 1, then modifying the contents of the\n** page data. In this case the file will be updated when the current\n** transaction is committed.\n**\n** The isDirectMode flag may only be non-zero if the library was compiled\n** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,\n** if isDirect is non-zero, then the database file is updated directly\n** by writing an updated version of page 1 using a call to the \n** sqlite3OsWrite() function.\n*/\nstatic int pager_incr_changecounter(Pager *pPager, int isDirectMode){\n  int rc = SQLITE_OK;\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* Declare and initialize constant integer 'isDirect'. If the\n  ** atomic-write optimization is enabled in this build, then isDirect\n  ** is initialized to the value passed as the isDirectMode parameter\n  ** to this function. Otherwise, it is always set to zero.\n  **\n  ** The idea is that if the atomic-write optimization is not\n  ** enabled at compile time, the compiler can omit the tests of\n  ** 'isDirect' below, as well as the block enclosed in the\n  ** \"if( isDirect )\" condition.\n  */\n#ifndef SQLITE_ENABLE_ATOMIC_WRITE\n# define DIRECT_MODE 0\n  assert( isDirectMode==0 );\n  UNUSED_PARAMETER(isDirectMode);\n#else\n# define DIRECT_MODE isDirectMode\n#endif\n\n  if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){\n    PgHdr *pPgHdr;                /* Reference to page 1 */\n\n    assert( !pPager->tempFile && isOpen(pPager->fd) );\n\n    /* Open page 1 of the file for writing. */\n    rc = sqlite3PagerGet(pPager, 1, &pPgHdr, 0);\n    assert( pPgHdr==0 || rc==SQLITE_OK );\n\n    /* If page one was fetched successfully, and this function is not\n    ** operating in direct-mode, make page 1 writable.  When not in \n    ** direct mode, page 1 is always held in cache and hence the PagerGet()\n    ** above is always successful - hence the ALWAYS on rc==SQLITE_OK.\n    */\n    if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){\n      rc = sqlite3PagerWrite(pPgHdr);\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Actually do the update of the change counter */\n      pager_write_changecounter(pPgHdr);\n\n      /* If running in direct mode, write the contents of page 1 to the file. */\n      if( DIRECT_MODE ){\n        const void *zBuf;\n        assert( pPager->dbFileSize>0 );\n        CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM_BKPT, zBuf);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);\n          pPager->aStat[PAGER_STAT_WRITE]++;\n        }\n        if( rc==SQLITE_OK ){\n          /* Update the pager's copy of the change-counter. Otherwise, the\n          ** next time a read transaction is opened the cache will be\n          ** flushed (as the change-counter values will not match).  */\n          const void *pCopy = (const void *)&((const char *)zBuf)[24];\n          memcpy(&pPager->dbFileVers, pCopy, sizeof(pPager->dbFileVers));\n          pPager->changeCountDone = 1;\n        }\n      }else{\n        pPager->changeCountDone = 1;\n      }\n    }\n\n    /* Release the page reference. */\n    sqlite3PagerUnref(pPgHdr);\n  }\n  return rc;\n}\n\n/*\n** Sync the database file to disk. This is a no-op for in-memory databases\n** or pages with the Pager.noSync flag set.\n**\n** If successful, or if called on a pager for which it is a no-op, this\n** function returns SQLITE_OK. Otherwise, an IO error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){\n  int rc = SQLITE_OK;\n\n  if( isOpen(pPager->fd) ){\n    void *pArg = (void*)zMaster;\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  }\n  if( rc==SQLITE_OK && !pPager->noSync ){\n    assert( !MEMDB );\n    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);\n  }\n  return rc;\n}\n\n/*\n** This function may only be called while a write-transaction is active in\n** rollback. If the connection is in WAL mode, this call is a no-op. \n** Otherwise, if the connection does not already have an EXCLUSIVE lock on \n** the database file, an attempt is made to obtain one.\n**\n** If the EXCLUSIVE lock is already held or the attempt to obtain it is\n** successful, or the connection is in WAL mode, SQLITE_OK is returned.\n** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is \n** returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerExclusiveLock(Pager *pPager){\n  int rc = pPager->errCode;\n  assert( assert_pager_state(pPager) );\n  if( rc==SQLITE_OK ){\n    assert( pPager->eState==PAGER_WRITER_CACHEMOD \n         || pPager->eState==PAGER_WRITER_DBMOD \n         || pPager->eState==PAGER_WRITER_LOCKED \n    );\n    assert( assert_pager_state(pPager) );\n    if( 0==pagerUseWal(pPager) ){\n      rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n    }\n  }\n  return rc;\n}\n\n/*\n** Sync the database file for the pager pPager. zMaster points to the name\n** of a master journal file that should be written into the individual\n** journal file. zMaster may be NULL, which is interpreted as no master\n** journal (a single database transaction).\n**\n** This routine ensures that:\n**\n**   * The database file change-counter is updated,\n**   * the journal is synced (unless the atomic-write optimization is used),\n**   * all dirty pages are written to the database file, \n**   * the database file is truncated (if required), and\n**   * the database file synced. \n**\n** The only thing that remains to commit the transaction is to finalize \n** (delete, truncate or zero the first part of) the journal file (or \n** delete the master journal file if specified).\n**\n** Note that if zMaster==NULL, this does not overwrite a previous value\n** passed to an sqlite3PagerCommitPhaseOne() call.\n**\n** If the final parameter - noSync - is true, then the database file itself\n** is not synced. The caller must call sqlite3PagerSync() directly to\n** sync the database file before calling CommitPhaseTwo() to delete the\n** journal file in this case.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(\n  Pager *pPager,                  /* Pager object */\n  const char *zMaster,            /* If not NULL, the master journal name */\n  int noSync                      /* True to omit the xSync on the db file */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n       || pPager->eState==PAGER_ERROR\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* If a prior error occurred, report that error again. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  /* Provide the ability to easily simulate an I/O error during testing */\n  if( sqlite3FaultSim(400) ) return SQLITE_IOERR;\n\n  PAGERTRACE((\"DATABASE SYNC: File=%s zMaster=%s nSize=%d\\n\", \n      pPager->zFilename, zMaster, pPager->dbSize));\n\n  /* If no database changes have been made, return early. */\n  if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;\n\n  assert( MEMDB==0 || pPager->tempFile );\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n  if( 0==pagerFlushOnCommit(pPager, 1) ){\n    /* If this is an in-memory db, or no pages have been written to, or this\n    ** function has already been called, it is mostly a no-op.  However, any\n    ** backup in progress needs to be restarted.  */\n    sqlite3BackupRestart(pPager->pBackup);\n  }else{\n    if( pagerUseWal(pPager) ){\n      PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n      PgHdr *pPageOne = 0;\n      if( pList==0 ){\n        /* Must have at least one page for the WAL commit flag.\n        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */\n        rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0);\n        pList = pPageOne;\n        pList->pDirty = 0;\n      }\n      assert( rc==SQLITE_OK );\n      if( ALWAYS(pList) ){\n        rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);\n      }\n      sqlite3PagerUnref(pPageOne);\n      if( rc==SQLITE_OK ){\n        sqlite3PcacheCleanAll(pPager->pPCache);\n      }\n    }else{\n      /* The bBatch boolean is true if the batch-atomic-write commit method\n      ** should be used.  No rollback journal is created if batch-atomic-write\n      ** is enabled.\n      */\n      sqlite3_file *fd = pPager->fd;\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      const int bBatch = zMaster==0    /* An SQLITE_IOCAP_BATCH_ATOMIC commit */\n        && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC)\n        && !pPager->noSync\n        && sqlite3JournalIsInMemory(pPager->jfd);\n#else\n# define bBatch 0\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n      /* The following block updates the change-counter. Exactly how it\n      ** does this depends on whether or not the atomic-update optimization\n      ** was enabled at compile time, and if this transaction meets the \n      ** runtime criteria to use the operation: \n      **\n      **    * The file-system supports the atomic-write property for\n      **      blocks of size page-size, and \n      **    * This commit is not part of a multi-file transaction, and\n      **    * Exactly one page has been modified and store in the journal file.\n      **\n      ** If the optimization was not enabled at compile time, then the\n      ** pager_incr_changecounter() function is called to update the change\n      ** counter in 'indirect-mode'. If the optimization is compiled in but\n      ** is not applicable to this transaction, call sqlite3JournalCreate()\n      ** to make sure the journal file has actually been created, then call\n      ** pager_incr_changecounter() to update the change-counter in indirect\n      ** mode. \n      **\n      ** Otherwise, if the optimization is both enabled and applicable,\n      ** then call pager_incr_changecounter() to update the change-counter\n      ** in 'direct' mode. In this case the journal file will never be\n      ** created for this transaction.\n      */\n      if( bBatch==0 ){\n        PgHdr *pPg;\n        assert( isOpen(pPager->jfd) \n            || pPager->journalMode==PAGER_JOURNALMODE_OFF \n            || pPager->journalMode==PAGER_JOURNALMODE_WAL \n            );\n        if( !zMaster && isOpen(pPager->jfd) \n         && pPager->journalOff==jrnlBufferSize(pPager) \n         && pPager->dbSize>=pPager->dbOrigSize\n         && (!(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)\n        ){\n          /* Update the db file change counter via the direct-write method. The \n          ** following call will modify the in-memory representation of page 1 \n          ** to include the updated change counter and then write page 1 \n          ** directly to the database file. Because of the atomic-write \n          ** property of the host file-system, this is safe.\n          */\n          rc = pager_incr_changecounter(pPager, 1);\n        }else{\n          rc = sqlite3JournalCreate(pPager->jfd);\n          if( rc==SQLITE_OK ){\n            rc = pager_incr_changecounter(pPager, 0);\n          }\n        }\n      }\n#else \n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      if( zMaster ){\n        rc = sqlite3JournalCreate(pPager->jfd);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n#endif\n      rc = pager_incr_changecounter(pPager, 0);\n#endif\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Write the master journal name into the journal file. If a master \n      ** journal file name has already been written to the journal file, \n      ** or if zMaster is NULL (no master journal), then this call is a no-op.\n      */\n      rc = writeMasterJournal(pPager, zMaster);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Sync the journal file and write all dirty pages to the database.\n      ** If the atomic-update optimization is being used, this sync will not \n      ** create the journal file or perform any real IO.\n      **\n      ** Because the change-counter page was just modified, unless the\n      ** atomic-update optimization is used it is almost certain that the\n      ** journal requires a sync here. However, in locking_mode=exclusive\n      ** on a system under memory pressure it is just possible that this is \n      ** not the case. In this case it is likely enough that the redundant\n      ** xSync() call will be changed to a no-op by the OS anyhow. \n      */\n      rc = syncJournal(pPager, 0);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n\n      if( bBatch ){\n        /* The pager is now in DBMOD state. But regardless of what happens\n        ** next, attempting to play the journal back into the database would\n        ** be unsafe. Close it now to make sure that does not happen.  */\n        sqlite3OsClose(pPager->jfd);\n        rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n      rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));\n      if( bBatch ){\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);\n        }else{\n          sqlite3OsFileControl(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);\n        }\n      }\n\n      if( rc!=SQLITE_OK ){\n        assert( rc!=SQLITE_IOERR_BLOCKED );\n        goto commit_phase_one_exit;\n      }\n      sqlite3PcacheCleanAll(pPager->pPCache);\n\n      /* If the file on disk is smaller than the database image, use \n      ** pager_truncate to grow the file here. This can happen if the database\n      ** image was extended as part of the current transaction and then the\n      ** last page in the db image moved to the free-list. In this case the\n      ** last page is never written out to disk, leaving the database file\n      ** undersized. Fix this now if it is the case.  */\n      if( pPager->dbSize>pPager->dbFileSize ){\n        Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));\n        assert( pPager->eState==PAGER_WRITER_DBMOD );\n        rc = pager_truncate(pPager, nNew);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n  \n      /* Finally, sync the database file. */\n      if( !noSync ){\n        rc = sqlite3PagerSync(pPager, zMaster);\n      }\n      IOTRACE((\"DBSYNC %p\\n\", pPager))\n    }\n  }\n\ncommit_phase_one_exit:\n  if( rc==SQLITE_OK && !pagerUseWal(pPager) ){\n    pPager->eState = PAGER_WRITER_FINISHED;\n  }\n  return rc;\n}\n\n\n/*\n** When this function is called, the database file has been completely\n** updated to reflect the changes made by the current transaction and\n** synced to disk. The journal file still exists in the file-system \n** though, and if a failure occurs at this point it will eventually\n** be used as a hot-journal and the current transaction rolled back.\n**\n** This function finalizes the journal file, either by deleting, \n** truncating or partially zeroing it, so that it cannot be used \n** for hot-journal rollback. Once this is done the transaction is\n** irrevocably committed.\n**\n** If an error occurs, an IO error code is returned and the pager\n** moves into the error state. Otherwise, SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This routine should not be called if a prior error has occurred.\n  ** But if (due to a coding error elsewhere in the system) it does get\n  ** called, just return the same error code without doing anything. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_FINISHED\n       || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* An optimization. If the database was not actually modified during\n  ** this transaction, the pager is running in exclusive-mode and is\n  ** using persistent journals, then this function is a no-op.\n  **\n  ** The start of the journal file currently contains a single journal \n  ** header with the nRec field set to 0. If such a journal is used as\n  ** a hot-journal during hot-journal rollback, 0 changes will be made\n  ** to the database file. So there is no need to zero the journal \n  ** header. Since the pager is in exclusive mode, there is no need\n  ** to drop any locks either.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED \n   && pPager->exclusiveMode \n   && pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n  ){\n    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );\n    pPager->eState = PAGER_READER;\n    return SQLITE_OK;\n  }\n\n  PAGERTRACE((\"COMMIT %d\\n\", PAGERID(pPager)));\n  pPager->iDataVersion++;\n  rc = pager_end_transaction(pPager, pPager->setMaster, 1);\n  return pager_error(pPager, rc);\n}\n\n/*\n** If a write transaction is open, then all changes made within the \n** transaction are reverted and the current write-transaction is closed.\n** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR\n** state if an error occurs.\n**\n** If the pager is already in PAGER_ERROR state when this function is called,\n** it returns Pager.errCode immediately. No work is performed in this case.\n**\n** Otherwise, in rollback mode, this function performs two functions:\n**\n**   1) It rolls back the journal file, restoring all database file and \n**      in-memory cache pages to the state they were in when the transaction\n**      was opened, and\n**\n**   2) It finalizes the journal file, so that it is not used for hot\n**      rollback at any point in the future.\n**\n** Finalization of the journal file (task 2) is only performed if the \n** rollback is successful.\n**\n** In WAL mode, all cache-entries containing data modified within the\n** current transaction are either expelled from the cache or reverted to\n** their pre-transaction state by re-reading data from the database or\n** WAL files. The WAL transaction is then closed.\n*/\nSQLITE_PRIVATE int sqlite3PagerRollback(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n  PAGERTRACE((\"ROLLBACK %d\\n\", PAGERID(pPager)));\n\n  /* PagerRollback() is a no-op if called in READER or OPEN state. If\n  ** the pager is already in the ERROR state, the rollback is not \n  ** attempted here. Instead, the error code is returned to the caller.\n  */\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;\n  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;\n\n  if( pagerUseWal(pPager) ){\n    int rc2;\n    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);\n    rc2 = pager_end_transaction(pPager, pPager->setMaster, 0);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){\n    int eState = pPager->eState;\n    rc = pager_end_transaction(pPager, 0, 0);\n    if( !MEMDB && eState>PAGER_WRITER_LOCKED ){\n      /* This can happen using journal_mode=off. Move the pager to the error \n      ** state to indicate that the contents of the cache may not be trusted.\n      ** Any active readers will get SQLITE_ABORT.\n      */\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n      return rc;\n    }\n  }else{\n    rc = pager_playback(pPager, 0);\n  }\n\n  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );\n  assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT\n          || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR \n          || rc==SQLITE_CANTOPEN\n  );\n\n  /* If an error occurs during a ROLLBACK, we can no longer trust the pager\n  ** cache. So call pager_error() on the way out to make any error persistent.\n  */\n  return pager_error(pPager, rc);\n}\n\n/*\n** Return TRUE if the database file is opened read-only.  Return FALSE\n** if the database is (in theory) writable.\n*/\nSQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager *pPager){\n  return pPager->readOnly;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return the sum of the reference counts for all pages held by pPager.\n*/\nSQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){\n  return sqlite3PcacheRefCount(pPager->pPCache);\n}\n#endif\n\n/*\n** Return the approximate number of bytes of memory currently\n** used by the pager and its associated cache.\n*/\nSQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){\n  int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)\n                                     + 5*sizeof(void*);\n  return perPageSize*sqlite3PcachePagecount(pPager->pPCache)\n           + sqlite3MallocSize(pPager)\n           + pPager->pageSize;\n}\n\n/*\n** Return the number of references to the specified page.\n*/\nSQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage *pPage){\n  return sqlite3PcachePageRefcount(pPage);\n}\n\n#ifdef SQLITE_TEST\n/*\n** This routine is used for testing and analysis only.\n*/\nSQLITE_PRIVATE int *sqlite3PagerStats(Pager *pPager){\n  static int a[11];\n  a[0] = sqlite3PcacheRefCount(pPager->pPCache);\n  a[1] = sqlite3PcachePagecount(pPager->pPCache);\n  a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);\n  a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;\n  a[4] = pPager->eState;\n  a[5] = pPager->errCode;\n  a[6] = pPager->aStat[PAGER_STAT_HIT];\n  a[7] = pPager->aStat[PAGER_STAT_MISS];\n  a[8] = 0;  /* Used to be pPager->nOvfl */\n  a[9] = pPager->nRead;\n  a[10] = pPager->aStat[PAGER_STAT_WRITE];\n  return a;\n}\n#endif\n\n/*\n** Parameter eStat must be either SQLITE_DBSTATUS_CACHE_HIT or\n** SQLITE_DBSTATUS_CACHE_MISS. Before returning, *pnVal is incremented by the\n** current cache hit or miss count, according to the value of eStat. If the \n** reset parameter is non-zero, the cache hit or miss count is zeroed before \n** returning.\n*/\nSQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){\n\n  assert( eStat==SQLITE_DBSTATUS_CACHE_HIT\n       || eStat==SQLITE_DBSTATUS_CACHE_MISS\n       || eStat==SQLITE_DBSTATUS_CACHE_WRITE\n  );\n\n  assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );\n  assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );\n  assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );\n\n  *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];\n  if( reset ){\n    pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;\n  }\n}\n\n/*\n** Return true if this is an in-memory or temp-file backed pager.\n*/\nSQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){\n  return pPager->tempFile;\n}\n\n/*\n** Check that there are at least nSavepoint savepoints open. If there are\n** currently less than nSavepoints open, then open one or more savepoints\n** to make up the difference. If the number of savepoints is already\n** equal to nSavepoint, then this function is a no-op.\n**\n** If a memory allocation fails, SQLITE_NOMEM is returned. If an error \n** occurs while opening the sub-journal file, then an IO error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  int rc = SQLITE_OK;                       /* Return code */\n  int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */\n  int ii;                                   /* Iterator variable */\n  PagerSavepoint *aNew;                     /* New Pager.aSavepoint array */\n\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( nSavepoint>nCurrent && pPager->useJournal );\n\n  /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM\n  ** if the allocation fails. Otherwise, zero the new portion in case a \n  ** malloc failure occurs while populating it in the for(...) loop below.\n  */\n  aNew = (PagerSavepoint *)sqlite3Realloc(\n      pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint\n  );\n  if( !aNew ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));\n  pPager->aSavepoint = aNew;\n\n  /* Populate the PagerSavepoint structures just allocated. */\n  for(ii=nCurrent; ii<nSavepoint; ii++){\n    aNew[ii].nOrig = pPager->dbSize;\n    if( isOpen(pPager->jfd) && pPager->journalOff>0 ){\n      aNew[ii].iOffset = pPager->journalOff;\n    }else{\n      aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);\n    }\n    aNew[ii].iSubRec = pPager->nSubRec;\n    aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);\n    if( !aNew[ii].pInSavepoint ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pagerUseWal(pPager) ){\n      sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);\n    }\n    pPager->nSavepoint = ii+1;\n  }\n  assert( pPager->nSavepoint==nSavepoint );\n  assertTruncateConstraint(pPager);\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n\n  if( nSavepoint>pPager->nSavepoint && pPager->useJournal ){\n    return pagerOpenSavepoint(pPager, nSavepoint);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n\n/*\n** This function is called to rollback or release (commit) a savepoint.\n** The savepoint to release or rollback need not be the most recently \n** created savepoint.\n**\n** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.\n** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with\n** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes\n** that have occurred since the specified savepoint was created.\n**\n** The savepoint to rollback or release is identified by parameter \n** iSavepoint. A value of 0 means to operate on the outermost savepoint\n** (the first created). A value of (Pager.nSavepoint-1) means operate\n** on the most recently created savepoint. If iSavepoint is greater than\n** (Pager.nSavepoint-1), then this function is a no-op.\n**\n** If a negative value is passed to this function, then the current\n** transaction is rolled back. This is different to calling \n** sqlite3PagerRollback() because this function does not terminate\n** the transaction or unlock the database, it just restores the \n** contents of the database to its original state. \n**\n** In any case, all savepoints with an index greater than iSavepoint \n** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),\n** then savepoint iSavepoint is also destroyed.\n**\n** This function may return SQLITE_NOMEM if a memory allocation fails,\n** or an IO error code if an IO error occurs while rolling back a \n** savepoint. If no errors occur, SQLITE_OK is returned.\n*/ \nSQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){\n  int rc = pPager->errCode;\n  \n#ifdef SQLITE_ENABLE_ZIPVFS\n  if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;\n#endif\n\n  assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n  assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );\n\n  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){\n    int ii;            /* Iterator variable */\n    int nNew;          /* Number of remaining savepoints after this op. */\n\n    /* Figure out how many savepoints will still be active after this\n    ** operation. Store this value in nNew. Then free resources associated \n    ** with any savepoints that are destroyed by this operation.\n    */\n    nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);\n    for(ii=nNew; ii<pPager->nSavepoint; ii++){\n      sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n    }\n    pPager->nSavepoint = nNew;\n\n    /* If this is a release of the outermost savepoint, truncate \n    ** the sub-journal to zero bytes in size. */\n    if( op==SAVEPOINT_RELEASE ){\n      if( nNew==0 && isOpen(pPager->sjfd) ){\n        /* Only truncate if it is an in-memory sub-journal. */\n        if( sqlite3JournalIsInMemory(pPager->sjfd) ){\n          rc = sqlite3OsTruncate(pPager->sjfd, 0);\n          assert( rc==SQLITE_OK );\n        }\n        pPager->nSubRec = 0;\n      }\n    }\n    /* Else this is a rollback operation, playback the specified savepoint.\n    ** If this is a temp-file, it is possible that the journal file has\n    ** not yet been opened. In this case there have been no changes to\n    ** the database file, so the playback operation can be skipped.\n    */\n    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){\n      PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];\n      rc = pagerPlaybackSavepoint(pPager, pSavepoint);\n      assert(rc!=SQLITE_DONE);\n    }\n    \n#ifdef SQLITE_ENABLE_ZIPVFS\n    /* If the cache has been modified but the savepoint cannot be rolled \n    ** back journal_mode=off, put the pager in the error state. This way,\n    ** if the VFS used by this pager includes ZipVFS, the entire transaction\n    ** can be rolled back at the ZipVFS level.  */\n    else if( \n        pPager->journalMode==PAGER_JOURNALMODE_OFF \n     && pPager->eState>=PAGER_WRITER_CACHEMOD\n    ){\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n    }\n#endif\n  }\n\n  return rc;\n}\n\n/*\n** Return the full pathname of the database file.\n**\n** Except, if the pager is in-memory only, then return an empty string if\n** nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when\n** used to report the filename to the user, for compatibility with legacy\n** behavior.  But when the Btree needs to know the filename for matching to\n** shared cache, it uses nullIfMemDb==0 so that in-memory databases can\n** participate in shared-cache.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){\n  return (nullIfMemDb && pPager->memDb) ? \"\" : pPager->zFilename;\n}\n\n/*\n** Return the VFS structure for the pager.\n*/\nSQLITE_PRIVATE sqlite3_vfs *sqlite3PagerVfs(Pager *pPager){\n  return pPager->pVfs;\n}\n\n/*\n** Return the file handle for the database file associated\n** with the pager.  This might return NULL if the file has\n** not yet been opened.\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){\n  return pPager->fd;\n}\n\n/*\n** Return the file handle for the journal file (if it exists).\n** This will be either the rollback journal or the WAL file.\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){\n#if SQLITE_OMIT_WAL\n  return pPager->jfd;\n#else\n  return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;\n#endif\n}\n\n/*\n** Return the full pathname of the journal file.\n*/\nSQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager *pPager){\n  return pPager->zJournal;\n}\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Set or retrieve the codec for this pager\n*/\nSQLITE_PRIVATE void sqlite3PagerSetCodec(\n  Pager *pPager,\n  void *(*xCodec)(void*,void*,Pgno,int),\n  void (*xCodecSizeChng)(void*,int,int),\n  void (*xCodecFree)(void*),\n  void *pCodec\n){\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n  pPager->xCodec = pPager->memDb ? 0 : xCodec;\n  pPager->xCodecSizeChng = xCodecSizeChng;\n  pPager->xCodecFree = xCodecFree;\n  pPager->pCodec = pCodec;\n  setGetterMethod(pPager);\n  pagerReportSize(pPager);\n}\nSQLITE_PRIVATE void *sqlite3PagerGetCodec(Pager *pPager){\n  return pPager->pCodec;\n}\n\n/*\n** This function is called by the wal module when writing page content\n** into the log file.\n**\n** This function returns a pointer to a buffer containing the encrypted\n** page content. If a malloc fails, this function may return NULL.\n*/\nSQLITE_PRIVATE void *sqlite3PagerCodec(PgHdr *pPg){\n  void *aData = 0;\n  CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);\n  return aData;\n}\n\n/*\n** Return the current pager state\n*/\nSQLITE_PRIVATE int sqlite3PagerState(Pager *pPager){\n  return pPager->eState;\n}\n#endif /* SQLITE_HAS_CODEC */\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Move the page pPg to location pgno in the file.\n**\n** There must be no references to the page previously located at\n** pgno (which we call pPgOld) though that page is allowed to be\n** in cache.  If the page previously located at pgno is not already\n** in the rollback journal, it is not put there by by this routine.\n**\n** References to the page pPg remain valid. Updating any\n** meta-data associated with pPg (i.e. data stored in the nExtra bytes\n** allocated along with the page) is the responsibility of the caller.\n**\n** A transaction must be active when this routine is called. It used to be\n** required that a statement transaction was not active, but this restriction\n** has been removed (CREATE INDEX needs to move a page when a statement\n** transaction is active).\n**\n** If the fourth argument, isCommit, is non-zero, then this page is being\n** moved as part of a database reorganization just before the transaction \n** is being committed. In this case, it is guaranteed that the database page \n** pPg refers to will not be written to again within this transaction.\n**\n** This function may return SQLITE_NOMEM or an IO error code if an error\n** occurs. Otherwise, it returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){\n  PgHdr *pPgOld;               /* The page being overwritten. */\n  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */\n  int rc;                      /* Return code */\n  Pgno origPgno;               /* The original page number */\n\n  assert( pPg->nRef>0 );\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* In order to be able to rollback, an in-memory database must journal\n  ** the page we are moving from.\n  */\n  assert( pPager->tempFile || !MEMDB );\n  if( pPager->tempFile ){\n    rc = sqlite3PagerWrite(pPg);\n    if( rc ) return rc;\n  }\n\n  /* If the page being moved is dirty and has not been saved by the latest\n  ** savepoint, then save the current contents of the page into the \n  ** sub-journal now. This is required to handle the following scenario:\n  **\n  **   BEGIN;\n  **     <journal page X, then modify it in memory>\n  **     SAVEPOINT one;\n  **       <Move page X to location Y>\n  **     ROLLBACK TO one;\n  **\n  ** If page X were not written to the sub-journal here, it would not\n  ** be possible to restore its contents when the \"ROLLBACK TO one\"\n  ** statement were is processed.\n  **\n  ** subjournalPage() may need to allocate space to store pPg->pgno into\n  ** one or more savepoint bitvecs. This is the reason this function\n  ** may return SQLITE_NOMEM.\n  */\n  if( (pPg->flags & PGHDR_DIRTY)!=0\n   && SQLITE_OK!=(rc = subjournalPageIfRequired(pPg))\n  ){\n    return rc;\n  }\n\n  PAGERTRACE((\"MOVE %d page %d (needSync=%d) moves to %d\\n\", \n      PAGERID(pPager), pPg->pgno, (pPg->flags&PGHDR_NEED_SYNC)?1:0, pgno));\n  IOTRACE((\"MOVE %p %d %d\\n\", pPager, pPg->pgno, pgno))\n\n  /* If the journal needs to be sync()ed before page pPg->pgno can\n  ** be written to, store pPg->pgno in local variable needSyncPgno.\n  **\n  ** If the isCommit flag is set, there is no need to remember that\n  ** the journal needs to be sync()ed before database page pPg->pgno \n  ** can be written to. The caller has already promised not to write to it.\n  */\n  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit ){\n    needSyncPgno = pPg->pgno;\n    assert( pPager->journalMode==PAGER_JOURNALMODE_OFF ||\n            pageInJournal(pPager, pPg) || pPg->pgno>pPager->dbOrigSize );\n    assert( pPg->flags&PGHDR_DIRTY );\n  }\n\n  /* If the cache contains a page with page-number pgno, remove it\n  ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for \n  ** page pgno before the 'move' operation, it needs to be retained \n  ** for the page moved there.\n  */\n  pPg->flags &= ~PGHDR_NEED_SYNC;\n  pPgOld = sqlite3PagerLookup(pPager, pgno);\n  assert( !pPgOld || pPgOld->nRef==1 );\n  if( pPgOld ){\n    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);\n    if( pPager->tempFile ){\n      /* Do not discard pages from an in-memory database since we might\n      ** need to rollback later.  Just move the page out of the way. */\n      sqlite3PcacheMove(pPgOld, pPager->dbSize+1);\n    }else{\n      sqlite3PcacheDrop(pPgOld);\n    }\n  }\n\n  origPgno = pPg->pgno;\n  sqlite3PcacheMove(pPg, pgno);\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* For an in-memory database, make sure the original page continues\n  ** to exist, in case the transaction needs to roll back.  Use pPgOld\n  ** as the original page since it has already been allocated.\n  */\n  if( pPager->tempFile && pPgOld ){\n    sqlite3PcacheMove(pPgOld, origPgno);\n    sqlite3PagerUnrefNotNull(pPgOld);\n  }\n\n  if( needSyncPgno ){\n    /* If needSyncPgno is non-zero, then the journal file needs to be \n    ** sync()ed before any data is written to database file page needSyncPgno.\n    ** Currently, no such page exists in the page-cache and the \n    ** \"is journaled\" bitvec flag has been set. This needs to be remedied by\n    ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC\n    ** flag.\n    **\n    ** If the attempt to load the page into the page-cache fails, (due\n    ** to a malloc() or IO failure), clear the bit in the pInJournal[]\n    ** array. Otherwise, if the page is loaded and written again in\n    ** this transaction, it may be written to the database file before\n    ** it is synced into the journal file. This way, it may end up in\n    ** the journal file twice, but that is not a problem.\n    */\n    PgHdr *pPgHdr;\n    rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr, 0);\n    if( rc!=SQLITE_OK ){\n      if( needSyncPgno<=pPager->dbOrigSize ){\n        assert( pPager->pTmpSpace!=0 );\n        sqlite3BitvecClear(pPager->pInJournal, needSyncPgno, pPager->pTmpSpace);\n      }\n      return rc;\n    }\n    pPgHdr->flags |= PGHDR_NEED_SYNC;\n    sqlite3PcacheMakeDirty(pPgHdr);\n    sqlite3PagerUnrefNotNull(pPgHdr);\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The page handle passed as the first argument refers to a dirty page \n** with a page number other than iNew. This function changes the page's \n** page number to iNew and sets the value of the PgHdr.flags field to \n** the value passed as the third parameter.\n*/\nSQLITE_PRIVATE void sqlite3PagerRekey(DbPage *pPg, Pgno iNew, u16 flags){\n  assert( pPg->pgno!=iNew );\n  pPg->flags = flags;\n  sqlite3PcacheMove(pPg, iNew);\n}\n\n/*\n** Return a pointer to the data for the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *pPg){\n  assert( pPg->nRef>0 || pPg->pPager->memDb );\n  return pPg->pData;\n}\n\n/*\n** Return a pointer to the Pager.nExtra bytes of \"extra\" space \n** allocated along with the specified page.\n*/\nSQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *pPg){\n  return pPg->pExtra;\n}\n\n/*\n** Get/set the locking-mode for this pager. Parameter eMode must be one\n** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or \n** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then\n** the locking-mode is set to the value specified.\n**\n** The returned value is either PAGER_LOCKINGMODE_NORMAL or\n** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated)\n** locking-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *pPager, int eMode){\n  assert( eMode==PAGER_LOCKINGMODE_QUERY\n            || eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_QUERY<0 );\n  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );\n  assert( pPager->exclusiveMode || 0==sqlite3WalHeapMemory(pPager->pWal) );\n  if( eMode>=0 && !pPager->tempFile && !sqlite3WalHeapMemory(pPager->pWal) ){\n    pPager->exclusiveMode = (u8)eMode;\n  }\n  return (int)pPager->exclusiveMode;\n}\n\n/*\n** Set the journal-mode for this pager. Parameter eMode must be one of:\n**\n**    PAGER_JOURNALMODE_DELETE\n**    PAGER_JOURNALMODE_TRUNCATE\n**    PAGER_JOURNALMODE_PERSIST\n**    PAGER_JOURNALMODE_OFF\n**    PAGER_JOURNALMODE_MEMORY\n**    PAGER_JOURNALMODE_WAL\n**\n** The journalmode is set to the value specified if the change is allowed.\n** The change may be disallowed for the following reasons:\n**\n**   *  An in-memory database can only have its journal_mode set to _OFF\n**      or _MEMORY.\n**\n**   *  Temporary databases cannot have _WAL journalmode.\n**\n** The returned indicate the current (possibly updated) journal-mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){\n  u8 eOld = pPager->journalMode;    /* Prior journalmode */\n\n#ifdef SQLITE_DEBUG\n  /* The print_pager_state() routine is intended to be used by the debugger\n  ** only.  We invoke it once here to suppress a compiler warning. */\n  print_pager_state(pPager);\n#endif\n\n\n  /* The eMode parameter is always valid */\n  assert(      eMode==PAGER_JOURNALMODE_DELETE\n            || eMode==PAGER_JOURNALMODE_TRUNCATE\n            || eMode==PAGER_JOURNALMODE_PERSIST\n            || eMode==PAGER_JOURNALMODE_OFF \n            || eMode==PAGER_JOURNALMODE_WAL \n            || eMode==PAGER_JOURNALMODE_MEMORY );\n\n  /* This routine is only called from the OP_JournalMode opcode, and\n  ** the logic there will never allow a temporary file to be changed\n  ** to WAL mode.\n  */\n  assert( pPager->tempFile==0 || eMode!=PAGER_JOURNALMODE_WAL );\n\n  /* Do allow the journalmode of an in-memory database to be set to\n  ** anything other than MEMORY or OFF\n  */\n  if( MEMDB ){\n    assert( eOld==PAGER_JOURNALMODE_MEMORY || eOld==PAGER_JOURNALMODE_OFF );\n    if( eMode!=PAGER_JOURNALMODE_MEMORY && eMode!=PAGER_JOURNALMODE_OFF ){\n      eMode = eOld;\n    }\n  }\n\n  if( eMode!=eOld ){\n\n    /* Change the journal mode. */\n    assert( pPager->eState!=PAGER_ERROR );\n    pPager->journalMode = (u8)eMode;\n\n    /* When transistioning from TRUNCATE or PERSIST to any other journal\n    ** mode except WAL, unless the pager is in locking_mode=exclusive mode,\n    ** delete the journal file.\n    */\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );\n    assert( (PAGER_JOURNALMODE_DELETE & 5)==0 );\n    assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );\n    assert( (PAGER_JOURNALMODE_OFF & 5)==0 );\n    assert( (PAGER_JOURNALMODE_WAL & 5)==5 );\n\n    assert( isOpen(pPager->fd) || pPager->exclusiveMode );\n    if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){\n\n      /* In this case we would like to delete the journal file. If it is\n      ** not possible, then that is not a problem. Deleting the journal file\n      ** here is an optimization only.\n      **\n      ** Before deleting the journal file, obtain a RESERVED lock on the\n      ** database file. This ensures that the journal file is not deleted\n      ** while it is in use by some other client.\n      */\n      sqlite3OsClose(pPager->jfd);\n      if( pPager->eLock>=RESERVED_LOCK ){\n        sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n      }else{\n        int rc = SQLITE_OK;\n        int state = pPager->eState;\n        assert( state==PAGER_OPEN || state==PAGER_READER );\n        if( state==PAGER_OPEN ){\n          rc = sqlite3PagerSharedLock(pPager);\n        }\n        if( pPager->eState==PAGER_READER ){\n          assert( rc==SQLITE_OK );\n          rc = pagerLockDb(pPager, RESERVED_LOCK);\n        }\n        if( rc==SQLITE_OK ){\n          sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n        }\n        if( rc==SQLITE_OK && state==PAGER_READER ){\n          pagerUnlockDb(pPager, SHARED_LOCK);\n        }else if( state==PAGER_OPEN ){\n          pager_unlock(pPager);\n        }\n        assert( state==pPager->eState );\n      }\n    }else if( eMode==PAGER_JOURNALMODE_OFF ){\n      sqlite3OsClose(pPager->jfd);\n    }\n  }\n\n  /* Return the new journal mode */\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return the current journal mode.\n*/\nSQLITE_PRIVATE int sqlite3PagerGetJournalMode(Pager *pPager){\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return TRUE if the pager is in a state where it is OK to change the\n** journalmode.  Journalmode changes can only happen when the database\n** is unmodified.\n*/\nSQLITE_PRIVATE int sqlite3PagerOkToChangeJournalMode(Pager *pPager){\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;\n  if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;\n  return 1;\n}\n\n/*\n** Get/set the size-limit used for persistent journal files.\n**\n** Setting the size limit to -1 means no limit is enforced.\n** An attempt to set a limit smaller than -1 is a no-op.\n*/\nSQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){\n  if( iLimit>=-1 ){\n    pPager->journalSizeLimit = iLimit;\n    sqlite3WalLimit(pPager->pWal, iLimit);\n  }\n  return pPager->journalSizeLimit;\n}\n\n/*\n** Return a pointer to the pPager->pBackup variable. The backup module\n** in backup.c maintains the content of this variable. This module\n** uses it opaquely as an argument to sqlite3BackupRestart() and\n** sqlite3BackupUpdate() only.\n*/\nSQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){\n  return &pPager->pBackup;\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Unless this is an in-memory or temporary database, clear the pager cache.\n*/\nSQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){\n  assert( MEMDB==0 || pPager->tempFile );\n  if( pPager->tempFile==0 ) pager_reset(pPager);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is called when the user invokes \"PRAGMA wal_checkpoint\",\n** \"PRAGMA wal_blocking_checkpoint\" or calls the sqlite3_wal_checkpoint()\n** or wal_blocking_checkpoint() API functions.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3PagerCheckpoint(\n  Pager *pPager,                  /* Checkpoint on this pager */\n  sqlite3 *db,                    /* Db handle used to check for interrupts */\n  int eMode,                      /* Type of checkpoint */\n  int *pnLog,                     /* OUT: Final number of frames in log */\n  int *pnCkpt                     /* OUT: Final number of checkpointed frames */\n){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,\n        (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),\n        pPager->pBusyHandlerArg,\n        pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,\n        pnLog, pnCkpt\n    );\n  }\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){\n  return sqlite3WalCallback(pPager->pWal);\n}\n\n/*\n** Return true if the underlying VFS for the given pager supports the\n** primitives necessary for write-ahead logging.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager){\n  const sqlite3_io_methods *pMethods = pPager->fd->pMethods;\n  if( pPager->noLock ) return 0;\n  return pPager->exclusiveMode || (pMethods->iVersion>=2 && pMethods->xShmMap);\n}\n\n/*\n** Attempt to take an exclusive lock on the database file. If a PENDING lock\n** is obtained instead, immediately release it.\n*/\nstatic int pagerExclusiveLock(Pager *pPager){\n  int rc;                         /* Return code */\n\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n  rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n  if( rc!=SQLITE_OK ){\n    /* If the attempt to grab the exclusive lock failed, release the \n    ** pending lock that may have been obtained instead.  */\n    pagerUnlockDb(pPager, SHARED_LOCK);\n  }\n\n  return rc;\n}\n\n/*\n** Call sqlite3WalOpen() to open the WAL handle. If the pager is in \n** exclusive-locking mode when this function is called, take an EXCLUSIVE\n** lock on the database file and use heap-memory to store the wal-index\n** in. Otherwise, use the normal shared-memory.\n*/\nstatic int pagerOpenWal(Pager *pPager){\n  int rc = SQLITE_OK;\n\n  assert( pPager->pWal==0 && pPager->tempFile==0 );\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n\n  /* If the pager is already in exclusive-mode, the WAL module will use \n  ** heap-memory for the wal-index instead of the VFS shared-memory \n  ** implementation. Take the exclusive lock now, before opening the WAL\n  ** file, to make sure this is safe.\n  */\n  if( pPager->exclusiveMode ){\n    rc = pagerExclusiveLock(pPager);\n  }\n\n  /* Open the connection to the log file. If this operation fails, \n  ** (e.g. due to malloc() failure), return an error code.\n  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3WalOpen(pPager->pVfs,\n        pPager->fd, pPager->zWal, pPager->exclusiveMode,\n        pPager->journalSizeLimit, &pPager->pWal\n    );\n  }\n  pagerFixMaplimit(pPager);\n\n  return rc;\n}\n\n\n/*\n** The caller must be holding a SHARED lock on the database file to call\n** this function.\n**\n** If the pager passed as the first argument is open on a real database\n** file (not a temp file or an in-memory database), and the WAL file\n** is not already open, make an attempt to open it now. If successful,\n** return SQLITE_OK. If an error occurs or the VFS used by the pager does \n** not support the xShmXXX() methods, return an error code. *pbOpen is\n** not modified in either case.\n**\n** If the pager is open on a temp-file (or in-memory database), or if\n** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK\n** without doing anything.\n*/\nSQLITE_PRIVATE int sqlite3PagerOpenWal(\n  Pager *pPager,                  /* Pager object */\n  int *pbOpen                     /* OUT: Set to true if call is a no-op */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN   || pbOpen );\n  assert( pPager->eState==PAGER_READER || !pbOpen );\n  assert( pbOpen==0 || *pbOpen==0 );\n  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );\n\n  if( !pPager->tempFile && !pPager->pWal ){\n    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;\n\n    /* Close any rollback journal previously open */\n    sqlite3OsClose(pPager->jfd);\n\n    rc = pagerOpenWal(pPager);\n    if( rc==SQLITE_OK ){\n      pPager->journalMode = PAGER_JOURNALMODE_WAL;\n      pPager->eState = PAGER_OPEN;\n    }\n  }else{\n    *pbOpen = 1;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to close the connection to the log file prior\n** to switching from WAL to rollback mode.\n**\n** Before closing the log file, this function attempts to take an \n** EXCLUSIVE lock on the database file. If this cannot be obtained, an\n** error (SQLITE_BUSY) is returned and the log connection is not closed.\n** If successful, the EXCLUSIVE lock is not released before returning.\n*/\nSQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){\n  int rc = SQLITE_OK;\n\n  assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );\n\n  /* If the log file is not already open, but does exist in the file-system,\n  ** it may need to be checkpointed before the connection can switch to\n  ** rollback mode. Open it now so this can happen.\n  */\n  if( !pPager->pWal ){\n    int logexists = 0;\n    rc = pagerLockDb(pPager, SHARED_LOCK);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsAccess(\n          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists\n      );\n    }\n    if( rc==SQLITE_OK && logexists ){\n      rc = pagerOpenWal(pPager);\n    }\n  }\n    \n  /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on\n  ** the database file, the log and log-summary files will be deleted.\n  */\n  if( rc==SQLITE_OK && pPager->pWal ){\n    rc = pagerExclusiveLock(pPager);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags,\n                           pPager->pageSize, (u8*)pPager->pTmpSpace);\n      pPager->pWal = 0;\n      pagerFixMaplimit(pPager);\n      if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n    }\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** If this is a WAL database, obtain a snapshot handle for the snapshot\n** currently open. Otherwise, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_ERROR;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotGet(pPager->pWal, ppSnapshot);\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, store a pointer to pSnapshot. Next time a\n** read transaction is opened, attempt to read from the snapshot it \n** identifies. If this is not a WAL database, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    sqlite3WalSnapshotOpen(pPager->pWal, pSnapshot);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this \n** is not a WAL database, return an error.\n*/\nSQLITE_PRIVATE int sqlite3PagerSnapshotRecover(Pager *pPager){\n  int rc;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotRecover(pPager->pWal);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n#endif /* !SQLITE_OMIT_WAL */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** A read-lock must be held on the pager when this function is called. If\n** the pager is in WAL mode and the WAL file currently contains one or more\n** frames, return the size in bytes of the page images stored within the\n** WAL frames. Otherwise, if this is not a WAL database or the WAL file\n** is empty, return 0.\n*/\nSQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){\n  assert( pPager->eState>=PAGER_READER );\n  return sqlite3WalFramesize(pPager->pWal);\n}\n#endif\n\n#endif /* SQLITE_OMIT_DISKIO */\n\n/************** End of pager.c ***********************************************/\n/************** Begin file wal.c *********************************************/\n/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of a write-ahead log (WAL) used in \n** \"journal_mode=WAL\" mode.\n**\n** WRITE-AHEAD LOG (WAL) FILE FORMAT\n**\n** A WAL file consists of a header followed by zero or more \"frames\".\n** Each frame records the revised content of a single page from the\n** database file.  All changes to the database are recorded by writing\n** frames into the WAL.  Transactions commit when a frame is written that\n** contains a commit marker.  A single WAL can and usually does record \n** multiple transactions.  Periodically, the content of the WAL is\n** transferred back into the database file in an operation called a\n** \"checkpoint\".\n**\n** A single WAL file can be used multiple times.  In other words, the\n** WAL can fill up with frames and then be checkpointed and then new\n** frames can overwrite the old ones.  A WAL always grows from beginning\n** toward the end.  Checksums and counters attached to each frame are\n** used to determine which frames within the WAL are valid and which\n** are leftovers from prior checkpoints.\n**\n** The WAL header is 32 bytes in size and consists of the following eight\n** big-endian 32-bit unsigned integer values:\n**\n**     0: Magic number.  0x377f0682 or 0x377f0683\n**     4: File format version.  Currently 3007000\n**     8: Database page size.  Example: 1024\n**    12: Checkpoint sequence number\n**    16: Salt-1, random integer incremented with each checkpoint\n**    20: Salt-2, a different random integer changing with each ckpt\n**    24: Checksum-1 (first part of checksum for first 24 bytes of header).\n**    28: Checksum-2 (second part of checksum for first 24 bytes of header).\n**\n** Immediately following the wal-header are zero or more frames. Each\n** frame consists of a 24-byte frame-header followed by a <page-size> bytes\n** of page data. The frame-header is six big-endian 32-bit unsigned \n** integer values, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the header)\n**    12: Salt-2 (copied from the header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n**\n** A frame is considered valid if and only if the following conditions are\n** true:\n**\n**    (1) The salt-1 and salt-2 values in the frame-header match\n**        salt values in the wal-header\n**\n**    (2) The checksum values in the final 8 bytes of the frame-header\n**        exactly match the checksum computed consecutively on the\n**        WAL header and the first 8 bytes and the content of all frames\n**        up to and including the current frame.\n**\n** The checksum is computed using 32-bit big-endian integers if the\n** magic number in the first 4 bytes of the WAL is 0x377f0683 and it\n** is computed using little-endian if the magic number is 0x377f0682.\n** The checksum values are always stored in the frame header in a\n** big-endian format regardless of which byte order is used to compute\n** the checksum.  The checksum is computed by interpreting the input as\n** an even number of unsigned 32-bit integers: x[0] through x[N].  The\n** algorithm used for the checksum is as follows:\n** \n**   for i from 0 to n-1 step 2:\n**     s0 += x[i] + s1;\n**     s1 += x[i+1] + s0;\n**   endfor\n**\n** Note that s0 and s1 are both weighted checksums using fibonacci weights\n** in reverse order (the largest fibonacci weight occurs on the first element\n** of the sequence being summed.)  The s1 value spans all 32-bit \n** terms of the sequence whereas s0 omits the final term.\n**\n** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the\n** WAL is transferred into the database, then the database is VFS.xSync-ed.\n** The VFS.xSync operations serve as write barriers - all writes launched\n** before the xSync must complete before any write that launches after the\n** xSync begins.\n**\n** After each checkpoint, the salt-1 value is incremented and the salt-2\n** value is randomized.  This prevents old and new frames in the WAL from\n** being considered valid at the same time and being checkpointing together\n** following a crash.\n**\n** READER ALGORITHM\n**\n** To read a page from the database (call it page number P), a reader\n** first checks the WAL to see if it contains page P.  If so, then the\n** last valid instance of page P that is a followed by a commit frame\n** or is a commit frame itself becomes the value read.  If the WAL\n** contains no copies of page P that are valid and which are a commit\n** frame or are followed by a commit frame, then page P is read from\n** the database file.\n**\n** To start a read transaction, the reader records the index of the last\n** valid frame in the WAL.  The reader uses this recorded \"mxFrame\" value\n** for all subsequent read operations.  New transactions can be appended\n** to the WAL, but as long as the reader uses its original mxFrame value\n** and ignores the newly appended content, it will see a consistent snapshot\n** of the database from a single point in time.  This technique allows\n** multiple concurrent readers to view different versions of the database\n** content simultaneously.\n**\n** The reader algorithm in the previous paragraphs works correctly, but \n** because frames for page P can appear anywhere within the WAL, the\n** reader has to scan the entire WAL looking for page P frames.  If the\n** WAL is large (multiple megabytes is typical) that scan can be slow,\n** and read performance suffers.  To overcome this problem, a separate\n** data structure called the wal-index is maintained to expedite the\n** search for frames of a particular page.\n** \n** WAL-INDEX FORMAT\n**\n** Conceptually, the wal-index is shared memory, though VFS implementations\n** might choose to implement the wal-index using a mmapped file.  Because\n** the wal-index is shared memory, SQLite does not support journal_mode=WAL \n** on a network filesystem.  All users of the database must be able to\n** share memory.\n**\n** The wal-index is transient.  After a crash, the wal-index can (and should\n** be) reconstructed from the original WAL file.  In fact, the VFS is required\n** to either truncate or zero the header of the wal-index when the last\n** connection to it closes.  Because the wal-index is transient, it can\n** use an architecture-specific format; it does not have to be cross-platform.\n** Hence, unlike the database and WAL file formats which store all values\n** as big endian, the wal-index can store multi-byte values in the native\n** byte order of the host computer.\n**\n** The purpose of the wal-index is to answer this question quickly:  Given\n** a page number P and a maximum frame index M, return the index of the \n** last frame in the wal before frame M for page P in the WAL, or return\n** NULL if there are no frames for page P in the WAL prior to M.\n**\n** The wal-index consists of a header region, followed by an one or\n** more index blocks.  \n**\n** The wal-index header contains the total number of frames within the WAL\n** in the mxFrame field.\n**\n** Each index block except for the first contains information on \n** HASHTABLE_NPAGE frames. The first index block contains information on\n** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and \n** HASHTABLE_NPAGE are selected so that together the wal-index header and\n** first index block are the same size as all other index blocks in the\n** wal-index.\n**\n** Each index block contains two sections, a page-mapping that contains the\n** database page number associated with each wal frame, and a hash-table \n** that allows readers to query an index block for a specific page number.\n** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE\n** for the first index block) 32-bit page numbers. The first entry in the \n** first index-block contains the database page number corresponding to the\n** first frame in the WAL file. The first entry in the second index block\n** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in\n** the log, and so on.\n**\n** The last index block in a wal-index usually contains less than the full\n** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,\n** depending on the contents of the WAL file. This does not change the\n** allocated size of the page-mapping array - the page-mapping array merely\n** contains unused entries.\n**\n** Even without using the hash table, the last frame for page P\n** can be found by scanning the page-mapping sections of each index block\n** starting with the last index block and moving toward the first, and\n** within each index block, starting at the end and moving toward the\n** beginning.  The first entry that equals P corresponds to the frame\n** holding the content for that page.\n**\n** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.\n** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the\n** hash table for each page number in the mapping section, so the hash \n** table is never more than half full.  The expected number of collisions \n** prior to finding a match is 1.  Each entry of the hash table is an\n** 1-based index of an entry in the mapping section of the same\n** index block.   Let K be the 1-based index of the largest entry in\n** the mapping section.  (For index blocks other than the last, K will\n** always be exactly HASHTABLE_NPAGE (4096) and for the last index block\n** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table\n** contain a value of 0.\n**\n** To look for page P in the hash table, first compute a hash iKey on\n** P as follows:\n**\n**      iKey = (P * 383) % HASHTABLE_NSLOT\n**\n** Then start scanning entries of the hash table, starting with iKey\n** (wrapping around to the beginning when the end of the hash table is\n** reached) until an unused hash slot is found. Let the first unused slot\n** be at index iUnused.  (iUnused might be less than iKey if there was\n** wrap-around.) Because the hash table is never more than half full,\n** the search is guaranteed to eventually hit an unused entry.  Let \n** iMax be the value between iKey and iUnused, closest to iUnused,\n** where aHash[iMax]==P.  If there is no iMax entry (if there exists\n** no hash slot such that aHash[i]==p) then page P is not in the\n** current index block.  Otherwise the iMax-th mapping entry of the\n** current index block corresponds to the last entry that references \n** page P.\n**\n** A hash search begins with the last index block and moves toward the\n** first index block, looking for entries corresponding to page P.  On\n** average, only two or three slots in each index block need to be\n** examined in order to either find the last entry for page P, or to\n** establish that no such entry exists in the block.  Each index block\n** holds over 4000 entries.  So two or three index blocks are sufficient\n** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10\n** comparisons (on average) suffice to either locate a frame in the\n** WAL or to establish that the frame does not exist in the WAL.  This\n** is much faster than scanning the entire 10MB WAL.\n**\n** Note that entries are added in order of increasing K.  Hence, one\n** reader might be using some value K0 and a second reader that started\n** at a later time (after additional transactions were added to the WAL\n** and to the wal-index) might be using a different value K1, where K1>K0.\n** Both readers can use the same hash table and mapping section to get\n** the correct result.  There may be entries in the hash table with\n** K>K0 but to the first reader, those entries will appear to be unused\n** slots in the hash table and so the first reader will get an answer as\n** if no values greater than K0 had ever been inserted into the hash table\n** in the first place - which is what reader one wants.  Meanwhile, the\n** second reader using K1 will see additional values that were inserted\n** later, which is exactly what reader two wants.  \n**\n** When a rollback occurs, the value of K is decreased. Hash table entries\n** that correspond to frames greater than the new K value are removed\n** from the hash table at this point.\n*/\n#ifndef SQLITE_OMIT_WAL\n\n/* #include \"wal.h\" */\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3WalTrace = 0;\n# define WALTRACE(X)  if(sqlite3WalTrace) sqlite3DebugPrintf X\n#else\n# define WALTRACE(X)\n#endif\n\n/*\n** The maximum (and only) versions of the wal and wal-index formats\n** that may be interpreted by this version of SQLite.\n**\n** If a client begins recovering a WAL file and finds that (a) the checksum\n** values in the wal-header are correct and (b) the version field is not\n** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.\n**\n** Similarly, if a client successfully reads a wal-index header (i.e. the \n** checksum test is successful) and finds that the version field is not\n** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite\n** returns SQLITE_CANTOPEN.\n*/\n#define WAL_MAX_VERSION      3007000\n#define WALINDEX_MAX_VERSION 3007000\n\n/*\n** Indices of various locking bytes.   WAL_NREADER is the number\n** of available reader locks and should be at least 3.  The default\n** is SQLITE_SHM_NLOCK==8 and  WAL_NREADER==5.\n*/\n#define WAL_WRITE_LOCK         0\n#define WAL_ALL_BUT_WRITE      1\n#define WAL_CKPT_LOCK          1\n#define WAL_RECOVER_LOCK       2\n#define WAL_READ_LOCK(I)       (3+(I))\n#define WAL_NREADER            (SQLITE_SHM_NLOCK-3)\n\n\n/* Object declarations */\ntypedef struct WalIndexHdr WalIndexHdr;\ntypedef struct WalIterator WalIterator;\ntypedef struct WalCkptInfo WalCkptInfo;\n\n\n/*\n** The following object holds a copy of the wal-index header content.\n**\n** The actual header in the wal-index consists of two copies of this\n** object followed by one instance of the WalCkptInfo object.\n** For all versions of SQLite through 3.10.0 and probably beyond,\n** the locking bytes (WalCkptInfo.aLock) start at offset 120 and\n** the total header size is 136 bytes.\n**\n** The szPage value can be any power of 2 between 512 and 32768, inclusive.\n** Or it can be 1 to represent a 65536-byte page.  The latter case was\n** added in 3.7.1 when support for 64K pages was added.  \n*/\nstruct WalIndexHdr {\n  u32 iVersion;                   /* Wal-index version */\n  u32 unused;                     /* Unused (padding) field */\n  u32 iChange;                    /* Counter incremented each transaction */\n  u8 isInit;                      /* 1 when initialized */\n  u8 bigEndCksum;                 /* True if checksums in WAL are big-endian */\n  u16 szPage;                     /* Database page size in bytes. 1==64K */\n  u32 mxFrame;                    /* Index of last valid frame in the WAL */\n  u32 nPage;                      /* Size of database in pages */\n  u32 aFrameCksum[2];             /* Checksum of last frame in log */\n  u32 aSalt[2];                   /* Two salt values copied from WAL header */\n  u32 aCksum[2];                  /* Checksum over all prior fields */\n};\n\n/*\n** A copy of the following object occurs in the wal-index immediately\n** following the second copy of the WalIndexHdr.  This object stores\n** information used by checkpoint.\n**\n** nBackfill is the number of frames in the WAL that have been written\n** back into the database. (We call the act of moving content from WAL to\n** database \"backfilling\".)  The nBackfill number is never greater than\n** WalIndexHdr.mxFrame.  nBackfill can only be increased by threads\n** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).\n** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from\n** mxFrame back to zero when the WAL is reset.\n**\n** nBackfillAttempted is the largest value of nBackfill that a checkpoint\n** has attempted to achieve.  Normally nBackfill==nBackfillAtempted, however\n** the nBackfillAttempted is set before any backfilling is done and the\n** nBackfill is only set after all backfilling completes.  So if a checkpoint\n** crashes, nBackfillAttempted might be larger than nBackfill.  The\n** WalIndexHdr.mxFrame must never be less than nBackfillAttempted.\n**\n** The aLock[] field is a set of bytes used for locking.  These bytes should\n** never be read or written.\n**\n** There is one entry in aReadMark[] for each reader lock.  If a reader\n** holds read-lock K, then the value in aReadMark[K] is no greater than\n** the mxFrame for that reader.  The value READMARK_NOT_USED (0xffffffff)\n** for any aReadMark[] means that entry is unused.  aReadMark[0] is \n** a special case; its value is never used and it exists as a place-holder\n** to avoid having to offset aReadMark[] indexs by one.  Readers holding\n** WAL_READ_LOCK(0) always ignore the entire WAL and read all content\n** directly from the database.\n**\n** The value of aReadMark[K] may only be changed by a thread that\n** is holding an exclusive lock on WAL_READ_LOCK(K).  Thus, the value of\n** aReadMark[K] cannot changed while there is a reader is using that mark\n** since the reader will be holding a shared lock on WAL_READ_LOCK(K).\n**\n** The checkpointer may only transfer frames from WAL to database where\n** the frame numbers are less than or equal to every aReadMark[] that is\n** in use (that is, every aReadMark[j] for which there is a corresponding\n** WAL_READ_LOCK(j)).  New readers (usually) pick the aReadMark[] with the\n** largest value and will increase an unused aReadMark[] to mxFrame if there\n** is not already an aReadMark[] equal to mxFrame.  The exception to the\n** previous sentence is when nBackfill equals mxFrame (meaning that everything\n** in the WAL has been backfilled into the database) then new readers\n** will choose aReadMark[0] which has value 0 and hence such reader will\n** get all their all content directly from the database file and ignore \n** the WAL.\n**\n** Writers normally append new frames to the end of the WAL.  However,\n** if nBackfill equals mxFrame (meaning that all WAL content has been\n** written back into the database) and if no readers are using the WAL\n** (in other words, if there are no WAL_READ_LOCK(i) where i>0) then\n** the writer will first \"reset\" the WAL back to the beginning and start\n** writing new content beginning at frame 1.\n**\n** We assume that 32-bit loads are atomic and so no locks are needed in\n** order to read from any aReadMark[] entries.\n*/\nstruct WalCkptInfo {\n  u32 nBackfill;                  /* Number of WAL frames backfilled into DB */\n  u32 aReadMark[WAL_NREADER];     /* Reader marks */\n  u8 aLock[SQLITE_SHM_NLOCK];     /* Reserved space for locks */\n  u32 nBackfillAttempted;         /* WAL frames perhaps written, or maybe not */\n  u32 notUsed0;                   /* Available for future enhancements */\n};\n#define READMARK_NOT_USED  0xffffffff\n\n\n/* A block of WALINDEX_LOCK_RESERVED bytes beginning at\n** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems\n** only support mandatory file-locks, we do not read or write data\n** from the region of the file on which locks are applied.\n*/\n#define WALINDEX_LOCK_OFFSET (sizeof(WalIndexHdr)*2+offsetof(WalCkptInfo,aLock))\n#define WALINDEX_HDR_SIZE    (sizeof(WalIndexHdr)*2+sizeof(WalCkptInfo))\n\n/* Size of header before each frame in wal */\n#define WAL_FRAME_HDRSIZE 24\n\n/* Size of write ahead log header, including checksum. */\n/* #define WAL_HDRSIZE 24 */\n#define WAL_HDRSIZE 32\n\n/* WAL magic value. Either this value, or the same value with the least\n** significant bit also set (WAL_MAGIC | 0x00000001) is stored in 32-bit\n** big-endian format in the first 4 bytes of a WAL file.\n**\n** If the LSB is set, then the checksums for each frame within the WAL\n** file are calculated by treating all data as an array of 32-bit \n** big-endian words. Otherwise, they are calculated by interpreting \n** all data as 32-bit little-endian words.\n*/\n#define WAL_MAGIC 0x377f0682\n\n/*\n** Return the offset of frame iFrame in the write-ahead log file, \n** assuming a database page size of szPage bytes. The offset returned\n** is to the start of the write-ahead log frame-header.\n*/\n#define walFrameOffset(iFrame, szPage) (                               \\\n  WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE)         \\\n)\n\n/*\n** An open write-ahead log file is represented by an instance of the\n** following object.\n*/\nstruct Wal {\n  sqlite3_vfs *pVfs;         /* The VFS used to create pDbFd */\n  sqlite3_file *pDbFd;       /* File handle for the database file */\n  sqlite3_file *pWalFd;      /* File handle for WAL file */\n  u32 iCallback;             /* Value to pass to log callback (or 0) */\n  i64 mxWalSize;             /* Truncate WAL to this size upon reset */\n  int nWiData;               /* Size of array apWiData */\n  int szFirstBlock;          /* Size of first block written to WAL file */\n  volatile u32 **apWiData;   /* Pointer to wal-index content in memory */\n  u32 szPage;                /* Database page size */\n  i16 readLock;              /* Which read lock is being held.  -1 for none */\n  u8 syncFlags;              /* Flags to use to sync header writes */\n  u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */\n  u8 writeLock;              /* True if in a write transaction */\n  u8 ckptLock;               /* True if holding a checkpoint lock */\n  u8 readOnly;               /* WAL_RDWR, WAL_RDONLY, or WAL_SHM_RDONLY */\n  u8 truncateOnCommit;       /* True to truncate WAL file on commit */\n  u8 syncHeader;             /* Fsync the WAL header if true */\n  u8 padToSectorBoundary;    /* Pad transactions out to the next sector */\n  WalIndexHdr hdr;           /* Wal-index header for current transaction */\n  u32 minFrame;              /* Ignore wal frames before this one */\n  u32 iReCksum;              /* On commit, recalculate checksums from here */\n  const char *zWalName;      /* Name of WAL file */\n  u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */\n#ifdef SQLITE_DEBUG\n  u8 lockError;              /* True if a locking error has occurred */\n#endif\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  WalIndexHdr *pSnapshot;    /* Start transaction here if not NULL */\n#endif\n};\n\n/*\n** Candidate values for Wal.exclusiveMode.\n*/\n#define WAL_NORMAL_MODE     0\n#define WAL_EXCLUSIVE_MODE  1     \n#define WAL_HEAPMEMORY_MODE 2\n\n/*\n** Possible values for WAL.readOnly\n*/\n#define WAL_RDWR        0    /* Normal read/write connection */\n#define WAL_RDONLY      1    /* The WAL file is readonly */\n#define WAL_SHM_RDONLY  2    /* The SHM file is readonly */\n\n/*\n** Each page of the wal-index mapping contains a hash-table made up of\n** an array of HASHTABLE_NSLOT elements of the following type.\n*/\ntypedef u16 ht_slot;\n\n/*\n** This structure is used to implement an iterator that loops through\n** all frames in the WAL in database page order. Where two or more frames\n** correspond to the same database page, the iterator visits only the \n** frame most recently written to the WAL (in other words, the frame with\n** the largest index).\n**\n** The internals of this structure are only accessed by:\n**\n**   walIteratorInit() - Create a new iterator,\n**   walIteratorNext() - Step an iterator,\n**   walIteratorFree() - Free an iterator.\n**\n** This functionality is used by the checkpoint code (see walCheckpoint()).\n*/\nstruct WalIterator {\n  int iPrior;                     /* Last result returned from the iterator */\n  int nSegment;                   /* Number of entries in aSegment[] */\n  struct WalSegment {\n    int iNext;                    /* Next slot in aIndex[] not yet returned */\n    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */\n    u32 *aPgno;                   /* Array of page numbers. */\n    int nEntry;                   /* Nr. of entries in aPgno[] and aIndex[] */\n    int iZero;                    /* Frame number associated with aPgno[0] */\n  } aSegment[1];                  /* One for every 32KB page in the wal-index */\n};\n\n/*\n** Define the parameters of the hash tables in the wal-index file. There\n** is a hash-table following every HASHTABLE_NPAGE page numbers in the\n** wal-index.\n**\n** Changing any of these constants will alter the wal-index format and\n** create incompatibilities.\n*/\n#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */\n#define HASHTABLE_HASH_1     383                  /* Should be prime */\n#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */\n\n/* \n** The block of page numbers associated with the first hash-table in a\n** wal-index is smaller than usual. This is so that there is a complete\n** hash-table on each aligned 32KB page of the wal-index.\n*/\n#define HASHTABLE_NPAGE_ONE  (HASHTABLE_NPAGE - (WALINDEX_HDR_SIZE/sizeof(u32)))\n\n/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */\n#define WALINDEX_PGSZ   (                                         \\\n    sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \\\n)\n\n/*\n** Obtain a pointer to the iPage'th page of the wal-index. The wal-index\n** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are\n** numbered from zero.\n**\n** If this call is successful, *ppPage is set to point to the wal-index\n** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,\n** then an SQLite error code is returned and *ppPage is set to 0.\n*/\nstatic int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){\n  int rc = SQLITE_OK;\n\n  /* Enlarge the pWal->apWiData[] array if required */\n  if( pWal->nWiData<=iPage ){\n    int nByte = sizeof(u32*)*(iPage+1);\n    volatile u32 **apNew;\n    apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);\n    if( !apNew ){\n      *ppPage = 0;\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset((void*)&apNew[pWal->nWiData], 0,\n           sizeof(u32*)*(iPage+1-pWal->nWiData));\n    pWal->apWiData = apNew;\n    pWal->nWiData = iPage+1;\n  }\n\n  /* Request a pointer to the required page from the VFS */\n  if( pWal->apWiData[iPage]==0 ){\n    if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n      pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);\n      if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM_BKPT;\n    }else{\n      rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, \n          pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]\n      );\n      if( rc==SQLITE_READONLY ){\n        pWal->readOnly |= WAL_SHM_RDONLY;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  *ppPage = pWal->apWiData[iPage];\n  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );\n  return rc;\n}\n\n/*\n** Return a pointer to the WalCkptInfo structure in the wal-index.\n*/\nstatic volatile WalCkptInfo *walCkptInfo(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]);\n}\n\n/*\n** Return a pointer to the WalIndexHdr structure in the wal-index.\n*/\nstatic volatile WalIndexHdr *walIndexHdr(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalIndexHdr*)pWal->apWiData[0];\n}\n\n/*\n** The argument to this macro must be of type u32. On a little-endian\n** architecture, it returns the u32 value that results from interpreting\n** the 4 bytes as a big-endian value. On a big-endian architecture, it\n** returns the value that would be produced by interpreting the 4 bytes\n** of the input value as a little-endian integer.\n*/\n#define BYTESWAP32(x) ( \\\n    (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \\\n  + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \\\n)\n\n/*\n** Generate or extend an 8 byte checksum based on the data in \n** array aByte[] and the initial values of aIn[0] and aIn[1] (or\n** initial values of 0 and 0 if aIn==NULL).\n**\n** The checksum is written back into aOut[] before returning.\n**\n** nByte must be a positive multiple of 8.\n*/\nstatic void walChecksumBytes(\n  int nativeCksum, /* True for native byte-order, false for non-native */\n  u8 *a,           /* Content to be checksummed */\n  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */\n  const u32 *aIn,  /* Initial checksum value input */\n  u32 *aOut        /* OUT: Final checksum value output */\n){\n  u32 s1, s2;\n  u32 *aData = (u32 *)a;\n  u32 *aEnd = (u32 *)&a[nByte];\n\n  if( aIn ){\n    s1 = aIn[0];\n    s2 = aIn[1];\n  }else{\n    s1 = s2 = 0;\n  }\n\n  assert( nByte>=8 );\n  assert( (nByte&0x00000007)==0 );\n\n  if( nativeCksum ){\n    do {\n      s1 += *aData++ + s2;\n      s2 += *aData++ + s1;\n    }while( aData<aEnd );\n  }else{\n    do {\n      s1 += BYTESWAP32(aData[0]) + s2;\n      s2 += BYTESWAP32(aData[1]) + s1;\n      aData += 2;\n    }while( aData<aEnd );\n  }\n\n  aOut[0] = s1;\n  aOut[1] = s2;\n}\n\nstatic void walShmBarrier(Wal *pWal){\n  if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){\n    sqlite3OsShmBarrier(pWal->pDbFd);\n  }\n}\n\n/*\n** Write the header information in pWal->hdr into the wal-index.\n**\n** The checksum on pWal->hdr is updated before it is written.\n*/\nstatic void walIndexWriteHdr(Wal *pWal){\n  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);\n  const int nCksum = offsetof(WalIndexHdr, aCksum);\n\n  assert( pWal->writeLock );\n  pWal->hdr.isInit = 1;\n  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;\n  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);\n  memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n  walShmBarrier(pWal);\n  memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n}\n\n/*\n** This function encodes a single frame header and writes it to a buffer\n** supplied by the caller. A frame-header is made up of a series of \n** 4-byte big-endian integers, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the wal-header)\n**    12: Salt-2 (copied from the wal-header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n*/\nstatic void walEncodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 iPage,                      /* Database page number for frame */\n  u32 nTruncate,                  /* New db size (or 0 for non-commit frames) */\n  u8 *aData,                      /* Pointer to page data */\n  u8 *aFrame                      /* OUT: Write encoded frame here */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  assert( WAL_FRAME_HDRSIZE==24 );\n  sqlite3Put4byte(&aFrame[0], iPage);\n  sqlite3Put4byte(&aFrame[4], nTruncate);\n  if( pWal->iReCksum==0 ){\n    memcpy(&aFrame[8], pWal->hdr.aSalt, 8);\n\n    nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n    walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n    walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n\n    sqlite3Put4byte(&aFrame[16], aCksum[0]);\n    sqlite3Put4byte(&aFrame[20], aCksum[1]);\n  }else{\n    memset(&aFrame[8], 0, 16);\n  }\n}\n\n/*\n** Check to see if the frame with header in aFrame[] and content\n** in aData[] is valid.  If it is a valid frame, fill *piPage and\n** *pnTruncate and return true.  Return if the frame is not valid.\n*/\nstatic int walDecodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 *piPage,                    /* OUT: Database page number for frame */\n  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */\n  u8 *aData,                      /* Pointer to page data (for checksum) */\n  u8 *aFrame                      /* Frame data */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  u32 pgno;                       /* Page number of the frame */\n  assert( WAL_FRAME_HDRSIZE==24 );\n\n  /* A frame is only valid if the salt values in the frame-header\n  ** match the salt values in the wal-header. \n  */\n  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if the page number is creater than zero.\n  */\n  pgno = sqlite3Get4byte(&aFrame[0]);\n  if( pgno==0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if a checksum of the WAL header,\n  ** all prior frams, the first 16 bytes of this frame-header, \n  ** and the frame-data matches the checksum in the last 8 \n  ** bytes of this frame-header.\n  */\n  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) \n   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) \n  ){\n    /* Checksum failed. */\n    return 0;\n  }\n\n  /* If we reach this point, the frame is valid.  Return the page number\n  ** and the new database size.\n  */\n  *piPage = pgno;\n  *pnTruncate = sqlite3Get4byte(&aFrame[4]);\n  return 1;\n}\n\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Names of locks.  This routine is used to provide debugging output and is not\n** a part of an ordinary build.\n*/\nstatic const char *walLockName(int lockIdx){\n  if( lockIdx==WAL_WRITE_LOCK ){\n    return \"WRITE-LOCK\";\n  }else if( lockIdx==WAL_CKPT_LOCK ){\n    return \"CKPT-LOCK\";\n  }else if( lockIdx==WAL_RECOVER_LOCK ){\n    return \"RECOVER-LOCK\";\n  }else{\n    static char zName[15];\n    sqlite3_snprintf(sizeof(zName), zName, \"READ-LOCK[%d]\",\n                     lockIdx-WAL_READ_LOCK(0));\n    return zName;\n  }\n}\n#endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */\n    \n\n/*\n** Set or release locks on the WAL.  Locks are either shared or exclusive.\n** A lock cannot be moved directly between shared and exclusive - it must go\n** through the unlocked state first.\n**\n** In locking_mode=EXCLUSIVE, all of these routines become no-ops.\n*/\nstatic int walLockShared(Wal *pWal, int lockIdx){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: acquire SHARED-%s %s\\n\", pWal,\n            walLockName(lockIdx), rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockShared(Wal *pWal, int lockIdx){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: release SHARED-%s\\n\", pWal, walLockName(lockIdx)));\n}\nstatic int walLockExclusive(Wal *pWal, int lockIdx, int n){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\\n\", pWal,\n            walLockName(lockIdx), n, rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockExclusive(Wal *pWal, int lockIdx, int n){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: release EXCLUSIVE-%s cnt=%d\\n\", pWal,\n             walLockName(lockIdx), n));\n}\n\n/*\n** Compute a hash on a page number.  The resulting hash value must land\n** between 0 and (HASHTABLE_NSLOT-1).  The walHashNext() function advances\n** the hash to the next value in the event of a collision.\n*/\nstatic int walHash(u32 iPage){\n  assert( iPage>0 );\n  assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );\n  return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);\n}\nstatic int walNextHash(int iPriorHash){\n  return (iPriorHash+1)&(HASHTABLE_NSLOT-1);\n}\n\n/* \n** Return pointers to the hash table and page number array stored on\n** page iHash of the wal-index. The wal-index is broken into 32KB pages\n** numbered starting from 0.\n**\n** Set output variable *paHash to point to the start of the hash table\n** in the wal-index file. Set *piZero to one less than the frame \n** number of the first frame indexed by this hash table. If a\n** slot in the hash table is set to N, it refers to frame number \n** (*piZero+N) in the log.\n**\n** Finally, set *paPgno so that *paPgno[1] is the page number of the\n** first frame indexed by the hash table, frame (*piZero+1).\n*/\nstatic int walHashGet(\n  Wal *pWal,                      /* WAL handle */\n  int iHash,                      /* Find the iHash'th table */\n  volatile ht_slot **paHash,      /* OUT: Pointer to hash index */\n  volatile u32 **paPgno,          /* OUT: Pointer to page number array */\n  u32 *piZero                     /* OUT: Frame associated with *paPgno[0] */\n){\n  int rc;                         /* Return code */\n  volatile u32 *aPgno;\n\n  rc = walIndexPage(pWal, iHash, &aPgno);\n  assert( rc==SQLITE_OK || iHash>0 );\n\n  if( rc==SQLITE_OK ){\n    u32 iZero;\n    volatile ht_slot *aHash;\n\n    aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];\n    if( iHash==0 ){\n      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];\n      iZero = 0;\n    }else{\n      iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;\n    }\n  \n    *paPgno = &aPgno[-1];\n    *paHash = aHash;\n    *piZero = iZero;\n  }\n  return rc;\n}\n\n/*\n** Return the number of the wal-index page that contains the hash-table\n** and page-number array that contain entries corresponding to WAL frame\n** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages \n** are numbered starting from 0.\n*/\nstatic int walFramePage(u32 iFrame){\n  int iHash = (iFrame+HASHTABLE_NPAGE-HASHTABLE_NPAGE_ONE-1) / HASHTABLE_NPAGE;\n  assert( (iHash==0 || iFrame>HASHTABLE_NPAGE_ONE)\n       && (iHash>=1 || iFrame<=HASHTABLE_NPAGE_ONE)\n       && (iHash<=1 || iFrame>(HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE))\n       && (iHash>=2 || iFrame<=HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE)\n       && (iHash<=2 || iFrame>(HASHTABLE_NPAGE_ONE+2*HASHTABLE_NPAGE))\n  );\n  return iHash;\n}\n\n/*\n** Return the page number associated with frame iFrame in this WAL.\n*/\nstatic u32 walFramePgno(Wal *pWal, u32 iFrame){\n  int iHash = walFramePage(iFrame);\n  if( iHash==0 ){\n    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];\n  }\n  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];\n}\n\n/*\n** Remove entries from the hash table that point to WAL slots greater\n** than pWal->hdr.mxFrame.\n**\n** This function is called whenever pWal->hdr.mxFrame is decreased due\n** to a rollback or savepoint.\n**\n** At most only the hash table containing pWal->hdr.mxFrame needs to be\n** updated.  Any later hash tables will be automatically cleared when\n** pWal->hdr.mxFrame advances to the point where those hash tables are\n** actually needed.\n*/\nstatic void walCleanupHash(Wal *pWal){\n  volatile ht_slot *aHash = 0;    /* Pointer to hash table to clear */\n  volatile u32 *aPgno = 0;        /* Page number array for hash table */\n  u32 iZero = 0;                  /* frame == (aHash[x]+iZero) */\n  int iLimit = 0;                 /* Zero values greater than this */\n  int nByte;                      /* Number of bytes to zero in aPgno[] */\n  int i;                          /* Used to iterate through aHash[] */\n\n  assert( pWal->writeLock );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );\n\n  if( pWal->hdr.mxFrame==0 ) return;\n\n  /* Obtain pointers to the hash-table and page-number array containing \n  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed\n  ** that the page said hash-table and array reside on is already mapped.\n  */\n  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );\n  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );\n  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);\n\n  /* Zero all hash-table entries that correspond to frame numbers greater\n  ** than pWal->hdr.mxFrame.\n  */\n  iLimit = pWal->hdr.mxFrame - iZero;\n  assert( iLimit>0 );\n  for(i=0; i<HASHTABLE_NSLOT; i++){\n    if( aHash[i]>iLimit ){\n      aHash[i] = 0;\n    }\n  }\n  \n  /* Zero the entries in the aPgno array that correspond to frames with\n  ** frame numbers greater than pWal->hdr.mxFrame. \n  */\n  nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);\n  memset((void *)&aPgno[iLimit+1], 0, nByte);\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* Verify that the every entry in the mapping region is still reachable\n  ** via the hash table even after the cleanup.\n  */\n  if( iLimit ){\n    int j;           /* Loop counter */\n    int iKey;        /* Hash key */\n    for(j=1; j<=iLimit; j++){\n      for(iKey=walHash(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){\n        if( aHash[iKey]==j ) break;\n      }\n      assert( aHash[iKey]==j );\n    }\n  }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n}\n\n\n/*\n** Set an entry in the wal-index that will map database page number\n** pPage into WAL frame iFrame.\n*/\nstatic int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){\n  int rc;                         /* Return code */\n  u32 iZero = 0;                  /* One less than frame number of aPgno[1] */\n  volatile u32 *aPgno = 0;        /* Page number array */\n  volatile ht_slot *aHash = 0;    /* Hash table */\n\n  rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);\n\n  /* Assuming the wal-index file was successfully mapped, populate the\n  ** page number array and hash table entry.\n  */\n  if( rc==SQLITE_OK ){\n    int iKey;                     /* Hash table key */\n    int idx;                      /* Value to write to hash-table slot */\n    int nCollide;                 /* Number of hash collisions */\n\n    idx = iFrame - iZero;\n    assert( idx <= HASHTABLE_NSLOT/2 + 1 );\n    \n    /* If this is the first entry to be added to this hash-table, zero the\n    ** entire hash table and aPgno[] array before proceeding. \n    */\n    if( idx==1 ){\n      int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);\n      memset((void*)&aPgno[1], 0, nByte);\n    }\n\n    /* If the entry in aPgno[] is already set, then the previous writer\n    ** must have exited unexpectedly in the middle of a transaction (after\n    ** writing one or more dirty pages to the WAL to free up memory). \n    ** Remove the remnants of that writers uncommitted transaction from \n    ** the hash-table before writing any new entries.\n    */\n    if( aPgno[idx] ){\n      walCleanupHash(pWal);\n      assert( !aPgno[idx] );\n    }\n\n    /* Write the aPgno[] array entry and the hash-table slot. */\n    nCollide = idx;\n    for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){\n      if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;\n    }\n    aPgno[idx] = iPage;\n    aHash[iKey] = (ht_slot)idx;\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n    /* Verify that the number of entries in the hash table exactly equals\n    ** the number of entries in the mapping region.\n    */\n    {\n      int i;           /* Loop counter */\n      int nEntry = 0;  /* Number of entries in the hash table */\n      for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }\n      assert( nEntry==idx );\n    }\n\n    /* Verify that the every entry in the mapping region is reachable\n    ** via the hash table.  This turns out to be a really, really expensive\n    ** thing to check, so only do this occasionally - not on every\n    ** iteration.\n    */\n    if( (idx&0x3ff)==0 ){\n      int i;           /* Loop counter */\n      for(i=1; i<=idx; i++){\n        for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){\n          if( aHash[iKey]==i ) break;\n        }\n        assert( aHash[iKey]==i );\n      }\n    }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n  }\n\n\n  return rc;\n}\n\n\n/*\n** Recover the wal-index by reading the write-ahead log file. \n**\n** This routine first tries to establish an exclusive lock on the\n** wal-index to prevent other threads/processes from doing anything\n** with the WAL or wal-index while recovery is running.  The\n** WAL_RECOVER_LOCK is also held so that other threads will know\n** that this thread is running recovery.  If unable to establish\n** the necessary locks, this routine returns SQLITE_BUSY.\n*/\nstatic int walIndexRecover(Wal *pWal){\n  int rc;                         /* Return Code */\n  i64 nSize;                      /* Size of log file */\n  u32 aFrameCksum[2] = {0, 0};\n  int iLock;                      /* Lock offset to lock for checkpoint */\n  int nLock;                      /* Number of locks to hold */\n\n  /* Obtain an exclusive lock on all byte in the locking range not already\n  ** locked by the caller. The caller is guaranteed to have locked the\n  ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.\n  ** If successful, the same bytes that are locked here are unlocked before\n  ** this function returns.\n  */\n  assert( pWal->ckptLock==1 || pWal->ckptLock==0 );\n  assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );\n  assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );\n  assert( pWal->writeLock );\n  iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;\n  nLock = SQLITE_SHM_NLOCK - iLock;\n  rc = walLockExclusive(pWal, iLock, nLock);\n  if( rc ){\n    return rc;\n  }\n  WALTRACE((\"WAL%p: recovery begin...\\n\", pWal));\n\n  memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n\n  rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n  if( rc!=SQLITE_OK ){\n    goto recovery_error;\n  }\n\n  if( nSize>WAL_HDRSIZE ){\n    u8 aBuf[WAL_HDRSIZE];         /* Buffer to load WAL header into */\n    u8 *aFrame = 0;               /* Malloc'd buffer to load entire frame */\n    int szFrame;                  /* Number of bytes in buffer aFrame[] */\n    u8 *aData;                    /* Pointer to data part of aFrame buffer */\n    int iFrame;                   /* Index of last frame read */\n    i64 iOffset;                  /* Next offset to read from log file */\n    int szPage;                   /* Page size according to the log */\n    u32 magic;                    /* Magic value read from WAL header */\n    u32 version;                  /* Magic value read from WAL header */\n    int isValid;                  /* True if this frame is valid */\n\n    /* Read in the WAL header. */\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);\n    if( rc!=SQLITE_OK ){\n      goto recovery_error;\n    }\n\n    /* If the database page size is not a power of two, or is greater than\n    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid \n    ** data. Similarly, if the 'magic' value is invalid, ignore the whole\n    ** WAL file.\n    */\n    magic = sqlite3Get4byte(&aBuf[0]);\n    szPage = sqlite3Get4byte(&aBuf[8]);\n    if( (magic&0xFFFFFFFE)!=WAL_MAGIC \n     || szPage&(szPage-1) \n     || szPage>SQLITE_MAX_PAGE_SIZE \n     || szPage<512 \n    ){\n      goto finished;\n    }\n    pWal->hdr.bigEndCksum = (u8)(magic&0x00000001);\n    pWal->szPage = szPage;\n    pWal->nCkpt = sqlite3Get4byte(&aBuf[12]);\n    memcpy(&pWal->hdr.aSalt, &aBuf[16], 8);\n\n    /* Verify that the WAL header checksum is correct */\n    walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, \n        aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum\n    );\n    if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24])\n     || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28])\n    ){\n      goto finished;\n    }\n\n    /* Verify that the version number on the WAL format is one that\n    ** are able to understand */\n    version = sqlite3Get4byte(&aBuf[4]);\n    if( version!=WAL_MAX_VERSION ){\n      rc = SQLITE_CANTOPEN_BKPT;\n      goto finished;\n    }\n\n    /* Malloc a buffer to read frames into. */\n    szFrame = szPage + WAL_FRAME_HDRSIZE;\n    aFrame = (u8 *)sqlite3_malloc64(szFrame);\n    if( !aFrame ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto recovery_error;\n    }\n    aData = &aFrame[WAL_FRAME_HDRSIZE];\n\n    /* Read all frames from the log file. */\n    iFrame = 0;\n    for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){\n      u32 pgno;                   /* Database page number for frame */\n      u32 nTruncate;              /* dbsize field from frame header */\n\n      /* Read and decode the next log frame. */\n      iFrame++;\n      rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);\n      if( rc!=SQLITE_OK ) break;\n      isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);\n      if( !isValid ) break;\n      rc = walIndexAppend(pWal, iFrame, pgno);\n      if( rc!=SQLITE_OK ) break;\n\n      /* If nTruncate is non-zero, this is a commit record. */\n      if( nTruncate ){\n        pWal->hdr.mxFrame = iFrame;\n        pWal->hdr.nPage = nTruncate;\n        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n        testcase( szPage<=32768 );\n        testcase( szPage>=65536 );\n        aFrameCksum[0] = pWal->hdr.aFrameCksum[0];\n        aFrameCksum[1] = pWal->hdr.aFrameCksum[1];\n      }\n    }\n\n    sqlite3_free(aFrame);\n  }\n\nfinished:\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo;\n    int i;\n    pWal->hdr.aFrameCksum[0] = aFrameCksum[0];\n    pWal->hdr.aFrameCksum[1] = aFrameCksum[1];\n    walIndexWriteHdr(pWal);\n\n    /* Reset the checkpoint-header. This is safe because this thread is \n    ** currently holding locks that exclude all other readers, writers and\n    ** checkpointers.\n    */\n    pInfo = walCkptInfo(pWal);\n    pInfo->nBackfill = 0;\n    pInfo->nBackfillAttempted = pWal->hdr.mxFrame;\n    pInfo->aReadMark[0] = 0;\n    for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n    if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame;\n\n    /* If more than one frame was recovered from the log file, report an\n    ** event via sqlite3_log(). This is to help with identifying performance\n    ** problems caused by applications routinely shutting down without\n    ** checkpointing the log file.\n    */\n    if( pWal->hdr.nPage ){\n      sqlite3_log(SQLITE_NOTICE_RECOVER_WAL,\n          \"recovered %d frames from WAL file %s\",\n          pWal->hdr.mxFrame, pWal->zWalName\n      );\n    }\n  }\n\nrecovery_error:\n  WALTRACE((\"WAL%p: recovery %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  walUnlockExclusive(pWal, iLock, nLock);\n  return rc;\n}\n\n/*\n** Close an open wal-index.\n*/\nstatic void walIndexClose(Wal *pWal, int isDelete){\n  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n    int i;\n    for(i=0; i<pWal->nWiData; i++){\n      sqlite3_free((void *)pWal->apWiData[i]);\n      pWal->apWiData[i] = 0;\n    }\n  }else{\n    sqlite3OsShmUnmap(pWal->pDbFd, isDelete);\n  }\n}\n\n/* \n** Open a connection to the WAL file zWalName. The database file must \n** already be opened on connection pDbFd. The buffer that zWalName points\n** to must remain valid for the lifetime of the returned Wal* handle.\n**\n** A SHARED lock should be held on the database file when this function\n** is called. The purpose of this SHARED lock is to prevent any other\n** client from unlinking the WAL or wal-index file. If another process\n** were to do this just after this client opened one of these files, the\n** system would be badly broken.\n**\n** If the log file is successfully opened, SQLITE_OK is returned and \n** *ppWal is set to point to a new WAL handle. If an error occurs,\n** an SQLite error code is returned and *ppWal is left unmodified.\n*/\nSQLITE_PRIVATE int sqlite3WalOpen(\n  sqlite3_vfs *pVfs,              /* vfs module to open wal and wal-index */\n  sqlite3_file *pDbFd,            /* The open database file */\n  const char *zWalName,           /* Name of the WAL file */\n  int bNoShm,                     /* True to run in heap-memory mode */\n  i64 mxWalSize,                  /* Truncate WAL to this size on reset */\n  Wal **ppWal                     /* OUT: Allocated Wal handle */\n){\n  int rc;                         /* Return Code */\n  Wal *pRet;                      /* Object to allocate and return */\n  int flags;                      /* Flags passed to OsOpen() */\n\n  assert( zWalName && zWalName[0] );\n  assert( pDbFd );\n\n  /* In the amalgamation, the os_unix.c and os_win.c source files come before\n  ** this source file.  Verify that the #defines of the locking byte offsets\n  ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.\n  ** For that matter, if the lock offset ever changes from its initial design\n  ** value of 120, we need to know that so there is an assert() to check it.\n  */\n  assert( 120==WALINDEX_LOCK_OFFSET );\n  assert( 136==WALINDEX_HDR_SIZE );\n#ifdef WIN_SHM_BASE\n  assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n#ifdef UNIX_SHM_BASE\n  assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n\n\n  /* Allocate an instance of struct Wal to return. */\n  *ppWal = 0;\n  pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile);\n  if( !pRet ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pRet->pVfs = pVfs;\n  pRet->pWalFd = (sqlite3_file *)&pRet[1];\n  pRet->pDbFd = pDbFd;\n  pRet->readLock = -1;\n  pRet->mxWalSize = mxWalSize;\n  pRet->zWalName = zWalName;\n  pRet->syncHeader = 1;\n  pRet->padToSectorBoundary = 1;\n  pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);\n\n  /* Open file handle on the write-ahead log file. */\n  flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);\n  rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);\n  if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){\n    pRet->readOnly = WAL_RDONLY;\n  }\n\n  if( rc!=SQLITE_OK ){\n    walIndexClose(pRet, 0);\n    sqlite3OsClose(pRet->pWalFd);\n    sqlite3_free(pRet);\n  }else{\n    int iDC = sqlite3OsDeviceCharacteristics(pDbFd);\n    if( iDC & SQLITE_IOCAP_SEQUENTIAL ){ pRet->syncHeader = 0; }\n    if( iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE ){\n      pRet->padToSectorBoundary = 0;\n    }\n    *ppWal = pRet;\n    WALTRACE((\"WAL%d: opened\\n\", pRet));\n  }\n  return rc;\n}\n\n/*\n** Change the size to which the WAL file is trucated on each reset.\n*/\nSQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){\n  if( pWal ) pWal->mxWalSize = iLimit;\n}\n\n/*\n** Find the smallest page number out of all pages held in the WAL that\n** has not been returned by any prior invocation of this method on the\n** same WalIterator object.   Write into *piFrame the frame index where\n** that page was last written into the WAL.  Write into *piPage the page\n** number.\n**\n** Return 0 on success.  If there are no pages in the WAL with a page\n** number larger than *piPage, then return 1.\n*/\nstatic int walIteratorNext(\n  WalIterator *p,               /* Iterator */\n  u32 *piPage,                  /* OUT: The page number of the next page */\n  u32 *piFrame                  /* OUT: Wal frame index of next page */\n){\n  u32 iMin;                     /* Result pgno must be greater than iMin */\n  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */\n  int i;                        /* For looping through segments */\n\n  iMin = p->iPrior;\n  assert( iMin<0xffffffff );\n  for(i=p->nSegment-1; i>=0; i--){\n    struct WalSegment *pSegment = &p->aSegment[i];\n    while( pSegment->iNext<pSegment->nEntry ){\n      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];\n      if( iPg>iMin ){\n        if( iPg<iRet ){\n          iRet = iPg;\n          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];\n        }\n        break;\n      }\n      pSegment->iNext++;\n    }\n  }\n\n  *piPage = p->iPrior = iRet;\n  return (iRet==0xFFFFFFFF);\n}\n\n/*\n** This function merges two sorted lists into a single sorted list.\n**\n** aLeft[] and aRight[] are arrays of indices.  The sort key is\n** aContent[aLeft[]] and aContent[aRight[]].  Upon entry, the following\n** is guaranteed for all J<K:\n**\n**        aContent[aLeft[J]] < aContent[aLeft[K]]\n**        aContent[aRight[J]] < aContent[aRight[K]]\n**\n** This routine overwrites aRight[] with a new (probably longer) sequence\n** of indices such that the aRight[] contains every index that appears in\n** either aLeft[] or the old aRight[] and such that the second condition\n** above is still met.\n**\n** The aContent[aLeft[X]] values will be unique for all X.  And the\n** aContent[aRight[X]] values will be unique too.  But there might be\n** one or more combinations of X and Y such that\n**\n**      aLeft[X]!=aRight[Y]  &&  aContent[aLeft[X]] == aContent[aRight[Y]]\n**\n** When that happens, omit the aLeft[X] and use the aRight[Y] index.\n*/\nstatic void walMerge(\n  const u32 *aContent,            /* Pages in wal - keys for the sort */\n  ht_slot *aLeft,                 /* IN: Left hand input list */\n  int nLeft,                      /* IN: Elements in array *paLeft */\n  ht_slot **paRight,              /* IN/OUT: Right hand input list */\n  int *pnRight,                   /* IN/OUT: Elements in *paRight */\n  ht_slot *aTmp                   /* Temporary buffer */\n){\n  int iLeft = 0;                  /* Current index in aLeft */\n  int iRight = 0;                 /* Current index in aRight */\n  int iOut = 0;                   /* Current index in output buffer */\n  int nRight = *pnRight;\n  ht_slot *aRight = *paRight;\n\n  assert( nLeft>0 && nRight>0 );\n  while( iRight<nRight || iLeft<nLeft ){\n    ht_slot logpage;\n    Pgno dbpage;\n\n    if( (iLeft<nLeft) \n     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])\n    ){\n      logpage = aLeft[iLeft++];\n    }else{\n      logpage = aRight[iRight++];\n    }\n    dbpage = aContent[logpage];\n\n    aTmp[iOut++] = logpage;\n    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;\n\n    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );\n    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );\n  }\n\n  *paRight = aLeft;\n  *pnRight = iOut;\n  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);\n}\n\n/*\n** Sort the elements in list aList using aContent[] as the sort key.\n** Remove elements with duplicate keys, preferring to keep the\n** larger aList[] values.\n**\n** The aList[] entries are indices into aContent[].  The values in\n** aList[] are to be sorted so that for all J<K:\n**\n**      aContent[aList[J]] < aContent[aList[K]]\n**\n** For any X and Y such that\n**\n**      aContent[aList[X]] == aContent[aList[Y]]\n**\n** Keep the larger of the two values aList[X] and aList[Y] and discard\n** the smaller.\n*/\nstatic void walMergesort(\n  const u32 *aContent,            /* Pages in wal */\n  ht_slot *aBuffer,               /* Buffer of at least *pnList items to use */\n  ht_slot *aList,                 /* IN/OUT: List to sort */\n  int *pnList                     /* IN/OUT: Number of elements in aList[] */\n){\n  struct Sublist {\n    int nList;                    /* Number of elements in aList */\n    ht_slot *aList;               /* Pointer to sub-list content */\n  };\n\n  const int nList = *pnList;      /* Size of input list */\n  int nMerge = 0;                 /* Number of elements in list aMerge */\n  ht_slot *aMerge = 0;            /* List to be merged */\n  int iList;                      /* Index into input list */\n  u32 iSub = 0;                   /* Index into aSub array */\n  struct Sublist aSub[13];        /* Array of sub-lists */\n\n  memset(aSub, 0, sizeof(aSub));\n  assert( nList<=HASHTABLE_NPAGE && nList>0 );\n  assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );\n\n  for(iList=0; iList<nList; iList++){\n    nMerge = 1;\n    aMerge = &aList[iList];\n    for(iSub=0; iList & (1<<iSub); iSub++){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->aList && p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[iList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n    aSub[iSub].aList = aMerge;\n    aSub[iSub].nList = nMerge;\n  }\n\n  for(iSub++; iSub<ArraySize(aSub); iSub++){\n    if( nList & (1<<iSub) ){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[nList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n  }\n  assert( aMerge==aList );\n  *pnList = nMerge;\n\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=1; i<*pnList; i++){\n      assert( aContent[aList[i]] > aContent[aList[i-1]] );\n    }\n  }\n#endif\n}\n\n/* \n** Free an iterator allocated by walIteratorInit().\n*/\nstatic void walIteratorFree(WalIterator *p){\n  sqlite3_free(p);\n}\n\n/*\n** Construct a WalInterator object that can be used to loop over all \n** pages in the WAL in ascending order. The caller must hold the checkpoint\n** lock.\n**\n** On success, make *pp point to the newly allocated WalInterator object\n** return SQLITE_OK. Otherwise, return an error code. If this routine\n** returns an error, the value of *pp is undefined.\n**\n** The calling routine should invoke walIteratorFree() to destroy the\n** WalIterator object when it has finished with it.\n*/\nstatic int walIteratorInit(Wal *pWal, WalIterator **pp){\n  WalIterator *p;                 /* Return value */\n  int nSegment;                   /* Number of segments to merge */\n  u32 iLast;                      /* Last frame in log */\n  int nByte;                      /* Number of bytes to allocate */\n  int i;                          /* Iterator variable */\n  ht_slot *aTmp;                  /* Temp space used by merge-sort */\n  int rc = SQLITE_OK;             /* Return Code */\n\n  /* This routine only runs while holding the checkpoint lock. And\n  ** it only runs if there is actually content in the log (mxFrame>0).\n  */\n  assert( pWal->ckptLock && pWal->hdr.mxFrame>0 );\n  iLast = pWal->hdr.mxFrame;\n\n  /* Allocate space for the WalIterator object. */\n  nSegment = walFramePage(iLast) + 1;\n  nByte = sizeof(WalIterator) \n        + (nSegment-1)*sizeof(struct WalSegment)\n        + iLast*sizeof(ht_slot);\n  p = (WalIterator *)sqlite3_malloc64(nByte);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(p, 0, nByte);\n  p->nSegment = nSegment;\n\n  /* Allocate temporary space used by the merge-sort routine. This block\n  ** of memory will be freed before this function returns.\n  */\n  aTmp = (ht_slot *)sqlite3_malloc64(\n      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)\n  );\n  if( !aTmp ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nSegment; i++){\n    volatile ht_slot *aHash;\n    u32 iZero;\n    volatile u32 *aPgno;\n\n    rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);\n    if( rc==SQLITE_OK ){\n      int j;                      /* Counter variable */\n      int nEntry;                 /* Number of entries in this segment */\n      ht_slot *aIndex;            /* Sorted index for this segment */\n\n      aPgno++;\n      if( (i+1)==nSegment ){\n        nEntry = (int)(iLast - iZero);\n      }else{\n        nEntry = (int)((u32*)aHash - (u32*)aPgno);\n      }\n      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];\n      iZero++;\n  \n      for(j=0; j<nEntry; j++){\n        aIndex[j] = (ht_slot)j;\n      }\n      walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);\n      p->aSegment[i].iZero = iZero;\n      p->aSegment[i].nEntry = nEntry;\n      p->aSegment[i].aIndex = aIndex;\n      p->aSegment[i].aPgno = (u32 *)aPgno;\n    }\n  }\n  sqlite3_free(aTmp);\n\n  if( rc!=SQLITE_OK ){\n    walIteratorFree(p);\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and\n** n. If the attempt fails and parameter xBusy is not NULL, then it is a\n** busy-handler function. Invoke it and retry the lock until either the\n** lock is successfully obtained or the busy-handler returns 0.\n*/\nstatic int walBusyLock(\n  Wal *pWal,                      /* WAL connection */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int lockIdx,                    /* Offset of first byte to lock */\n  int n                           /* Number of bytes to lock */\n){\n  int rc;\n  do {\n    rc = walLockExclusive(pWal, lockIdx, n);\n  }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );\n  return rc;\n}\n\n/*\n** The cache of the wal-index header must be valid to call this function.\n** Return the page-size in bytes used by the database.\n*/\nstatic int walPagesize(Wal *pWal){\n  return (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n}\n\n/*\n** The following is guaranteed when this function is called:\n**\n**   a) the WRITER lock is held,\n**   b) the entire log file has been checkpointed, and\n**   c) any existing readers are reading exclusively from the database\n**      file - there are no readers that may attempt to read a frame from\n**      the log file.\n**\n** This function updates the shared-memory structures so that the next\n** client to write to the database (which may be this one) does so by\n** writing frames into the start of the log file.\n**\n** The value of parameter salt1 is used as the aSalt[1] value in the \n** new wal-index header. It should be passed a pseudo-random value (i.e. \n** one obtained from sqlite3_randomness()).\n*/\nstatic void walRestartHdr(Wal *pWal, u32 salt1){\n  volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n  int i;                          /* Loop counter */\n  u32 *aSalt = pWal->hdr.aSalt;   /* Big-endian salt values */\n  pWal->nCkpt++;\n  pWal->hdr.mxFrame = 0;\n  sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));\n  memcpy(&pWal->hdr.aSalt[1], &salt1, 4);\n  walIndexWriteHdr(pWal);\n  pInfo->nBackfill = 0;\n  pInfo->nBackfillAttempted = 0;\n  pInfo->aReadMark[1] = 0;\n  for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n  assert( pInfo->aReadMark[0]==0 );\n}\n\n/*\n** Copy as much content as we can from the WAL back into the database file\n** in response to an sqlite3_wal_checkpoint() request or the equivalent.\n**\n** The amount of information copies from WAL to database might be limited\n** by active readers.  This routine will never overwrite a database page\n** that a concurrent reader might be using.\n**\n** All I/O barrier operations (a.k.a fsyncs) occur in this routine when\n** SQLite is in WAL-mode in synchronous=NORMAL.  That means that if \n** checkpoints are always run by a background thread or background \n** process, foreground threads will never block on a lengthy fsync call.\n**\n** Fsync is called on the WAL before writing content out of the WAL and\n** into the database.  This ensures that if the new content is persistent\n** in the WAL and can be recovered following a power-loss or hard reset.\n**\n** Fsync is also called on the database file if (and only if) the entire\n** WAL content is copied into the database file.  This second fsync makes\n** it safe to delete the WAL since the new content will persist in the\n** database file.\n**\n** This routine uses and updates the nBackfill field of the wal-index header.\n** This is the only routine that will increase the value of nBackfill.  \n** (A WAL reset or recovery will revert nBackfill to zero, but not increase\n** its value.)\n**\n** The caller must be holding sufficient locks to ensure that no other\n** checkpoint is running (in any other thread or process) at the same\n** time.\n*/\nstatic int walCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check for interrupts on this handle */\n  int eMode,                      /* One of PASSIVE, FULL or RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags for OsSync() (or 0) */\n  u8 *zBuf                        /* Temporary buffer to use */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int szPage;                     /* Database page-size */\n  WalIterator *pIter = 0;         /* Wal iterator context */\n  u32 iDbpage = 0;                /* Next database page to write */\n  u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */\n  u32 mxSafeFrame;                /* Max frame that can be backfilled */\n  u32 mxPage;                     /* Max database page to write */\n  int i;                          /* Loop counter */\n  volatile WalCkptInfo *pInfo;    /* The checkpoint status information */\n\n  szPage = walPagesize(pWal);\n  testcase( szPage<=32768 );\n  testcase( szPage>=65536 );\n  pInfo = walCkptInfo(pWal);\n  if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n\n    /* Allocate the iterator */\n    rc = walIteratorInit(pWal, &pIter);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    assert( pIter );\n\n    /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n    ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n    assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n    /* Compute in mxSafeFrame the index of the last frame of the WAL that is\n    ** safe to write into the database.  Frames beyond mxSafeFrame might\n    ** overwrite database pages that are in use by active readers and thus\n    ** cannot be backfilled from the WAL.\n    */\n    mxSafeFrame = pWal->hdr.mxFrame;\n    mxPage = pWal->hdr.nPage;\n    for(i=1; i<WAL_NREADER; i++){\n      /* Thread-sanitizer reports that the following is an unsafe read,\n      ** as some other thread may be in the process of updating the value\n      ** of the aReadMark[] slot. The assumption here is that if that is\n      ** happening, the other client may only be increasing the value,\n      ** not decreasing it. So assuming either that either the \"old\" or\n      ** \"new\" version of the value is read, and not some arbitrary value\n      ** that would never be written by a real client, things are still \n      ** safe.  */\n      u32 y = pInfo->aReadMark[i];\n      if( mxSafeFrame>y ){\n        assert( y<=pWal->hdr.mxFrame );\n        rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);\n        if( rc==SQLITE_OK ){\n          pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);\n          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        }else if( rc==SQLITE_BUSY ){\n          mxSafeFrame = y;\n          xBusy = 0;\n        }else{\n          goto walcheckpoint_out;\n        }\n      }\n    }\n\n    if( pInfo->nBackfill<mxSafeFrame\n     && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK\n    ){\n      i64 nSize;                    /* Current size of database file */\n      u32 nBackfill = pInfo->nBackfill;\n\n      pInfo->nBackfillAttempted = mxSafeFrame;\n\n      /* Sync the WAL to disk */\n      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n\n      /* If the database may grow as a result of this checkpoint, hint\n      ** about the eventual size of the db file to the VFS layer.\n      */\n      if( rc==SQLITE_OK ){\n        i64 nReq = ((i64)mxPage * szPage);\n        rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);\n        if( rc==SQLITE_OK && nSize<nReq ){\n          sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);\n        }\n      }\n\n\n      /* Iterate through the contents of the WAL, copying data to the db file */\n      while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){\n        i64 iOffset;\n        assert( walFramePgno(pWal, iFrame)==iDbpage );\n        if( db->u1.isInterrupted ){\n          rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n          break;\n        }\n        if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){\n          continue;\n        }\n        iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;\n        /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */\n        rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n        iOffset = (iDbpage-1)*(i64)szPage;\n        testcase( IS_BIG_INT(iOffset) );\n        rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n      }\n\n      /* If work was actually accomplished... */\n      if( rc==SQLITE_OK ){\n        if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){\n          i64 szDb = pWal->hdr.nPage*(i64)szPage;\n          testcase( IS_BIG_INT(szDb) );\n          rc = sqlite3OsTruncate(pWal->pDbFd, szDb);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));\n          }\n        }\n        if( rc==SQLITE_OK ){\n          pInfo->nBackfill = mxSafeFrame;\n        }\n      }\n\n      /* Release the reader lock held while backfilling */\n      walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);\n    }\n\n    if( rc==SQLITE_BUSY ){\n      /* Reset the return code so as not to report a checkpoint failure\n      ** just because there are active readers.  */\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the\n  ** entire wal file has been copied into the database file, then block \n  ** until all readers have finished using the wal file. This ensures that \n  ** the next process to write to the database restarts the wal file.\n  */\n  if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    assert( pWal->writeLock );\n    if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n      rc = SQLITE_BUSY;\n    }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n      rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){\n          /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as\n          ** SQLITE_CHECKPOINT_RESTART with the addition that it also\n          ** truncates the log file to zero bytes just prior to a\n          ** successful return.\n          **\n          ** In theory, it might be safe to do this without updating the\n          ** wal-index header in shared memory, as all subsequent reader or\n          ** writer clients should see that the entire log file has been\n          ** checkpointed and behave accordingly. This seems unsafe though,\n          ** as it would leave the system in a state where the contents of\n          ** the wal-index header do not match the contents of the \n          ** file-system. To avoid this, update the wal-index header to\n          ** indicate that the log file contains zero valid frames.  */\n          walRestartHdr(pWal, salt1);\n          rc = sqlite3OsTruncate(pWal->pWalFd, 0);\n        }\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }\n    }\n  }\n\n walcheckpoint_out:\n  walIteratorFree(pIter);\n  return rc;\n}\n\n/*\n** If the WAL file is currently larger than nMax bytes in size, truncate\n** it to exactly nMax bytes. If an error occurs while doing so, ignore it.\n*/\nstatic void walLimitSize(Wal *pWal, i64 nMax){\n  i64 sz;\n  int rx;\n  sqlite3BeginBenignMalloc();\n  rx = sqlite3OsFileSize(pWal->pWalFd, &sz);\n  if( rx==SQLITE_OK && (sz > nMax ) ){\n    rx = sqlite3OsTruncate(pWal->pWalFd, nMax);\n  }\n  sqlite3EndBenignMalloc();\n  if( rx ){\n    sqlite3_log(rx, \"cannot limit WAL size: %s\", pWal->zWalName);\n  }\n}\n\n/*\n** Close a connection to a log file.\n*/\nSQLITE_PRIVATE int sqlite3WalClose(\n  Wal *pWal,                      /* Wal to close */\n  sqlite3 *db,                    /* For interrupt flag */\n  int sync_flags,                 /* Flags to pass to OsSync() (or 0) */\n  int nBuf,\n  u8 *zBuf                        /* Buffer of at least nBuf bytes */\n){\n  int rc = SQLITE_OK;\n  if( pWal ){\n    int isDelete = 0;             /* True to unlink wal and wal-index files */\n\n    /* If an EXCLUSIVE lock can be obtained on the database file (using the\n    ** ordinary, rollback-mode locking methods, this guarantees that the\n    ** connection associated with this log file is the only connection to\n    ** the database. In this case checkpoint the database and unlink both\n    ** the wal and wal-index files.\n    **\n    ** The EXCLUSIVE lock is not released before returning.\n    */\n    if( zBuf!=0\n     && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))\n    ){\n      if( pWal->exclusiveMode==WAL_NORMAL_MODE ){\n        pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n      }\n      rc = sqlite3WalCheckpoint(pWal, db, \n          SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0\n      );\n      if( rc==SQLITE_OK ){\n        int bPersist = -1;\n        sqlite3OsFileControlHint(\n            pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist\n        );\n        if( bPersist!=1 ){\n          /* Try to delete the WAL file if the checkpoint completed and\n          ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal\n          ** mode (!bPersist) */\n          isDelete = 1;\n        }else if( pWal->mxWalSize>=0 ){\n          /* Try to truncate the WAL file to zero bytes if the checkpoint\n          ** completed and fsynced (rc==SQLITE_OK) and we are in persistent\n          ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a\n          ** non-negative value (pWal->mxWalSize>=0).  Note that we truncate\n          ** to zero bytes as truncating to the journal_size_limit might\n          ** leave a corrupt WAL file on disk. */\n          walLimitSize(pWal, 0);\n        }\n      }\n    }\n\n    walIndexClose(pWal, isDelete);\n    sqlite3OsClose(pWal->pWalFd);\n    if( isDelete ){\n      sqlite3BeginBenignMalloc();\n      sqlite3OsDelete(pWal->pVfs, pWal->zWalName, 0);\n      sqlite3EndBenignMalloc();\n    }\n    WALTRACE((\"WAL%p: closed\\n\", pWal));\n    sqlite3_free((void *)pWal->apWiData);\n    sqlite3_free(pWal);\n  }\n  return rc;\n}\n\n/*\n** Try to read the wal-index header.  Return 0 on success and 1 if\n** there is a problem.\n**\n** The wal-index is in shared memory.  Another thread or process might\n** be writing the header at the same time this procedure is trying to\n** read it, which might result in inconsistency.  A dirty read is detected\n** by verifying that both copies of the header are the same and also by\n** a checksum on the header.\n**\n** If and only if the read is consistent and the header is different from\n** pWal->hdr, then pWal->hdr is updated to the content of the new header\n** and *pChanged is set to 1.\n**\n** If the checksum cannot be verified return non-zero. If the header\n** is read successfully and the checksum verified, return zero.\n*/\nstatic int walIndexTryHdr(Wal *pWal, int *pChanged){\n  u32 aCksum[2];                  /* Checksum on the header content */\n  WalIndexHdr h1, h2;             /* Two copies of the header content */\n  WalIndexHdr volatile *aHdr;     /* Header in shared memory */\n\n  /* The first page of the wal-index must be mapped at this point. */\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n\n  /* Read the header. This might happen concurrently with a write to the\n  ** same area of shared memory on a different CPU in a SMP,\n  ** meaning it is possible that an inconsistent snapshot is read\n  ** from the file. If this happens, return non-zero.\n  **\n  ** There are two copies of the header at the beginning of the wal-index.\n  ** When reading, read [0] first then [1].  Writes are in the reverse order.\n  ** Memory barriers are used to prevent the compiler or the hardware from\n  ** reordering the reads and writes.\n  */\n  aHdr = walIndexHdr(pWal);\n  memcpy(&h1, (void *)&aHdr[0], sizeof(h1));\n  walShmBarrier(pWal);\n  memcpy(&h2, (void *)&aHdr[1], sizeof(h2));\n\n  if( memcmp(&h1, &h2, sizeof(h1))!=0 ){\n    return 1;   /* Dirty read */\n  }  \n  if( h1.isInit==0 ){\n    return 1;   /* Malformed header - probably all zeros */\n  }\n  walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);\n  if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){\n    return 1;   /* Checksum does not match */\n  }\n\n  if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){\n    *pChanged = 1;\n    memcpy(&pWal->hdr, &h1, sizeof(WalIndexHdr));\n    pWal->szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n    testcase( pWal->szPage<=32768 );\n    testcase( pWal->szPage>=65536 );\n  }\n\n  /* The header was successfully read. Return zero. */\n  return 0;\n}\n\n/*\n** Read the wal-index header from the wal-index and into pWal->hdr.\n** If the wal-header appears to be corrupt, try to reconstruct the\n** wal-index from the WAL before returning.\n**\n** Set *pChanged to 1 if the wal-index header value in pWal->hdr is\n** changed by this operation.  If pWal->hdr is unchanged, set *pChanged\n** to 0.\n**\n** If the wal-index header is successfully read, return SQLITE_OK. \n** Otherwise an SQLite error code.\n*/\nstatic int walIndexReadHdr(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int badHdr;                     /* True if a header read failed */\n  volatile u32 *page0;            /* Chunk of wal-index containing header */\n\n  /* Ensure that page 0 of the wal-index (the page that contains the \n  ** wal-index header) is mapped. Return early if an error occurs here.\n  */\n  assert( pChanged );\n  rc = walIndexPage(pWal, 0, &page0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  };\n  assert( page0 || pWal->writeLock==0 );\n\n  /* If the first page of the wal-index has been mapped, try to read the\n  ** wal-index header immediately, without holding any lock. This usually\n  ** works, but may fail if the wal-index header is corrupt or currently \n  ** being modified by another thread or process.\n  */\n  badHdr = (page0 ? walIndexTryHdr(pWal, pChanged) : 1);\n\n  /* If the first attempt failed, it might have been due to a race\n  ** with a writer.  So get a WRITE lock and try again.\n  */\n  assert( badHdr==0 || pWal->writeLock==0 );\n  if( badHdr ){\n    if( pWal->readOnly & WAL_SHM_RDONLY ){\n      if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){\n        walUnlockShared(pWal, WAL_WRITE_LOCK);\n        rc = SQLITE_READONLY_RECOVERY;\n      }\n    }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){\n      pWal->writeLock = 1;\n      if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){\n        badHdr = walIndexTryHdr(pWal, pChanged);\n        if( badHdr ){\n          /* If the wal-index header is still malformed even while holding\n          ** a WRITE lock, it can only mean that the header is corrupted and\n          ** needs to be reconstructed.  So run recovery to do exactly that.\n          */\n          rc = walIndexRecover(pWal);\n          *pChanged = 1;\n        }\n      }\n      pWal->writeLock = 0;\n      walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    }\n  }\n\n  /* If the header is read successfully, check the version number to make\n  ** sure the wal-index was not constructed with some future format that\n  ** this version of SQLite cannot understand.\n  */\n  if( badHdr==0 && pWal->hdr.iVersion!=WALINDEX_MAX_VERSION ){\n    rc = SQLITE_CANTOPEN_BKPT;\n  }\n\n  return rc;\n}\n\n/*\n** This is the value that walTryBeginRead returns when it needs to\n** be retried.\n*/\n#define WAL_RETRY  (-1)\n\n/*\n** Attempt to start a read transaction.  This might fail due to a race or\n** other transient condition.  When that happens, it returns WAL_RETRY to\n** indicate to the caller that it is safe to retry immediately.\n**\n** On success return SQLITE_OK.  On a permanent failure (such an\n** I/O error or an SQLITE_BUSY because another process is running\n** recovery) return a positive error code.\n**\n** The useWal parameter is true to force the use of the WAL and disable\n** the case where the WAL is bypassed because it has been completely\n** checkpointed.  If useWal==0 then this routine calls walIndexReadHdr() \n** to make a copy of the wal-index header into pWal->hdr.  If the \n** wal-index header has changed, *pChanged is set to 1 (as an indication \n** to the caller that the local paget cache is obsolete and needs to be \n** flushed.)  When useWal==1, the wal-index header is assumed to already\n** be loaded and the pChanged parameter is unused.\n**\n** The caller must set the cnt parameter to the number of prior calls to\n** this routine during the current read attempt that returned WAL_RETRY.\n** This routine will start taking more aggressive measures to clear the\n** race conditions after multiple WAL_RETRY returns, and after an excessive\n** number of errors will ultimately return SQLITE_PROTOCOL.  The\n** SQLITE_PROTOCOL return indicates that some other process has gone rogue\n** and is not honoring the locking protocol.  There is a vanishingly small\n** chance that SQLITE_PROTOCOL could be returned because of a run of really\n** bad luck when there is lots of contention for the wal-index, but that\n** possibility is so small that it can be safely neglected, we believe.\n**\n** On success, this routine obtains a read lock on \n** WAL_READ_LOCK(pWal->readLock).  The pWal->readLock integer is\n** in the range 0 <= pWal->readLock < WAL_NREADER.  If pWal->readLock==(-1)\n** that means the Wal does not hold any read lock.  The reader must not\n** access any database page that is modified by a WAL frame up to and\n** including frame number aReadMark[pWal->readLock].  The reader will\n** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0\n** Or if pWal->readLock==0, then the reader will ignore the WAL\n** completely and get all content directly from the database file.\n** If the useWal parameter is 1 then the WAL will never be ignored and\n** this routine will always set pWal->readLock>0 on success.\n** When the read transaction is completed, the caller must release the\n** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.\n**\n** This routine uses the nBackfill and aReadMark[] fields of the header\n** to select a particular WAL_READ_LOCK() that strives to let the\n** checkpoint process do as much work as possible.  This routine might\n** update values of the aReadMark[] array in the header, but if it does\n** so it takes care to hold an exclusive lock on the corresponding\n** WAL_READ_LOCK() while changing values.\n*/\nstatic int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){\n  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */\n  u32 mxReadMark;                 /* Largest aReadMark[] value */\n  int mxI;                        /* Index of largest aReadMark[] value */\n  int i;                          /* Loop counter */\n  int rc = SQLITE_OK;             /* Return code  */\n  u32 mxFrame;                    /* Wal frame to lock to */\n\n  assert( pWal->readLock<0 );     /* Not currently locked */\n\n  /* Take steps to avoid spinning forever if there is a protocol error.\n  **\n  ** Circumstances that cause a RETRY should only last for the briefest\n  ** instances of time.  No I/O or other system calls are done while the\n  ** locks are held, so the locks should not be held for very long. But \n  ** if we are unlucky, another process that is holding a lock might get\n  ** paged out or take a page-fault that is time-consuming to resolve, \n  ** during the few nanoseconds that it is holding the lock.  In that case,\n  ** it might take longer than normal for the lock to free.\n  **\n  ** After 5 RETRYs, we begin calling sqlite3OsSleep().  The first few\n  ** calls to sqlite3OsSleep() have a delay of 1 microsecond.  Really this\n  ** is more of a scheduler yield than an actual delay.  But on the 10th\n  ** an subsequent retries, the delays start becoming longer and longer, \n  ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.\n  ** The total delay time before giving up is less than 10 seconds.\n  */\n  if( cnt>5 ){\n    int nDelay = 1;                      /* Pause time in microseconds */\n    if( cnt>100 ){\n      VVA_ONLY( pWal->lockError = 1; )\n      return SQLITE_PROTOCOL;\n    }\n    if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;\n    sqlite3OsSleep(pWal->pVfs, nDelay);\n  }\n\n  if( !useWal ){\n    rc = walIndexReadHdr(pWal, pChanged);\n    if( rc==SQLITE_BUSY ){\n      /* If there is not a recovery running in another thread or process\n      ** then convert BUSY errors to WAL_RETRY.  If recovery is known to\n      ** be running, convert BUSY to BUSY_RECOVERY.  There is a race here\n      ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY\n      ** would be technically correct.  But the race is benign since with\n      ** WAL_RETRY this routine will be called again and will probably be\n      ** right on the second iteration.\n      */\n      if( pWal->apWiData[0]==0 ){\n        /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.\n        ** We assume this is a transient condition, so return WAL_RETRY. The\n        ** xShmMap() implementation used by the default unix and win32 VFS \n        ** modules may return SQLITE_BUSY due to a race condition in the \n        ** code that determines whether or not the shared-memory region \n        ** must be zeroed before the requested page is returned.\n        */\n        rc = WAL_RETRY;\n      }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){\n        walUnlockShared(pWal, WAL_RECOVER_LOCK);\n        rc = WAL_RETRY;\n      }else if( rc==SQLITE_BUSY ){\n        rc = SQLITE_BUSY_RECOVERY;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  pInfo = walCkptInfo(pWal);\n  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame \n#ifdef SQLITE_ENABLE_SNAPSHOT\n   && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0\n     || 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr)))\n#endif\n  ){\n    /* The WAL has been completely backfilled (or it is empty).\n    ** and can be safely ignored.\n    */\n    rc = walLockShared(pWal, WAL_READ_LOCK(0));\n    walShmBarrier(pWal);\n    if( rc==SQLITE_OK ){\n      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){\n        /* It is not safe to allow the reader to continue here if frames\n        ** may have been appended to the log before READ_LOCK(0) was obtained.\n        ** When holding READ_LOCK(0), the reader ignores the entire log file,\n        ** which implies that the database file contains a trustworthy\n        ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from\n        ** happening, this is usually correct.\n        **\n        ** However, if frames have been appended to the log (or if the log \n        ** is wrapped and written for that matter) before the READ_LOCK(0)\n        ** is obtained, that is not necessarily true. A checkpointer may\n        ** have started to backfill the appended frames but crashed before\n        ** it finished. Leaving a corrupt image in the database file.\n        */\n        walUnlockShared(pWal, WAL_READ_LOCK(0));\n        return WAL_RETRY;\n      }\n      pWal->readLock = 0;\n      return SQLITE_OK;\n    }else if( rc!=SQLITE_BUSY ){\n      return rc;\n    }\n  }\n\n  /* If we get this far, it means that the reader will want to use\n  ** the WAL to get at content from recent commits.  The job now is\n  ** to select one of the aReadMark[] entries that is closest to\n  ** but not exceeding pWal->hdr.mxFrame and lock that entry.\n  */\n  mxReadMark = 0;\n  mxI = 0;\n  mxFrame = pWal->hdr.mxFrame;\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){\n    mxFrame = pWal->pSnapshot->mxFrame;\n  }\n#endif\n  for(i=1; i<WAL_NREADER; i++){\n    u32 thisMark = pInfo->aReadMark[i];\n    if( mxReadMark<=thisMark && thisMark<=mxFrame ){\n      assert( thisMark!=READMARK_NOT_USED );\n      mxReadMark = thisMark;\n      mxI = i;\n    }\n  }\n  if( (pWal->readOnly & WAL_SHM_RDONLY)==0\n   && (mxReadMark<mxFrame || mxI==0)\n  ){\n    for(i=1; i<WAL_NREADER; i++){\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);\n      if( rc==SQLITE_OK ){\n        mxReadMark = pInfo->aReadMark[i] = mxFrame;\n        mxI = i;\n        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        break;\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  if( mxI==0 ){\n    assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );\n    return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK;\n  }\n\n  rc = walLockShared(pWal, WAL_READ_LOCK(mxI));\n  if( rc ){\n    return rc==SQLITE_BUSY ? WAL_RETRY : rc;\n  }\n  /* Now that the read-lock has been obtained, check that neither the\n  ** value in the aReadMark[] array or the contents of the wal-index\n  ** header have changed.\n  **\n  ** It is necessary to check that the wal-index header did not change\n  ** between the time it was read and when the shared-lock was obtained\n  ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility\n  ** that the log file may have been wrapped by a writer, or that frames\n  ** that occur later in the log than pWal->hdr.mxFrame may have been\n  ** copied into the database by a checkpointer. If either of these things\n  ** happened, then reading the database with the current value of\n  ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry\n  ** instead.\n  **\n  ** Before checking that the live wal-index header has not changed\n  ** since it was read, set Wal.minFrame to the first frame in the wal\n  ** file that has not yet been checkpointed. This client will not need\n  ** to read any frames earlier than minFrame from the wal file - they\n  ** can be safely read directly from the database file.\n  **\n  ** Because a ShmBarrier() call is made between taking the copy of \n  ** nBackfill and checking that the wal-header in shared-memory still\n  ** matches the one cached in pWal->hdr, it is guaranteed that the \n  ** checkpointer that set nBackfill was not working with a wal-index\n  ** header newer than that cached in pWal->hdr. If it were, that could\n  ** cause a problem. The checkpointer could omit to checkpoint\n  ** a version of page X that lies before pWal->minFrame (call that version\n  ** A) on the basis that there is a newer version (version B) of the same\n  ** page later in the wal file. But if version B happens to like past\n  ** frame pWal->hdr.mxFrame - then the client would incorrectly assume\n  ** that it can read version A from the database file. However, since\n  ** we can guarantee that the checkpointer that set nBackfill could not\n  ** see any pages past pWal->hdr.mxFrame, this problem does not come up.\n  */\n  pWal->minFrame = pInfo->nBackfill+1;\n  walShmBarrier(pWal);\n  if( pInfo->aReadMark[mxI]!=mxReadMark\n   || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))\n  ){\n    walUnlockShared(pWal, WAL_READ_LOCK(mxI));\n    return WAL_RETRY;\n  }else{\n    assert( mxReadMark<=pWal->hdr.mxFrame );\n    pWal->readLock = (i16)mxI;\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted \n** variable so that older snapshots can be accessed. To do this, loop\n** through all wal frames from nBackfillAttempted to (nBackfill+1), \n** comparing their content to the corresponding page with the database\n** file, if any. Set nBackfillAttempted to the frame number of the\n** first frame for which the wal file content matches the db file.\n**\n** This is only really safe if the file-system is such that any page \n** writes made by earlier checkpointers were atomic operations, which \n** is not always true. It is also possible that nBackfillAttempted\n** may be left set to a value larger than expected, if a wal frame\n** contains content that duplicate of an earlier version of the same\n** page.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code if an\n** error occurs. It is not an error if nBackfillAttempted cannot be\n** decreased at all.\n*/\nSQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal){\n  int rc;\n\n  assert( pWal->readLock>=0 );\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    int szPage = (int)pWal->szPage;\n    i64 szDb;                   /* Size of db file in bytes */\n\n    rc = sqlite3OsFileSize(pWal->pDbFd, &szDb);\n    if( rc==SQLITE_OK ){\n      void *pBuf1 = sqlite3_malloc(szPage);\n      void *pBuf2 = sqlite3_malloc(szPage);\n      if( pBuf1==0 || pBuf2==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        u32 i = pInfo->nBackfillAttempted;\n        for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){\n          volatile ht_slot *dummy;\n          volatile u32 *aPgno;      /* Array of page numbers */\n          u32 iZero;                /* Frame corresponding to aPgno[0] */\n          u32 pgno;                 /* Page number in db file */\n          i64 iDbOff;               /* Offset of db file entry */\n          i64 iWalOff;              /* Offset of wal file entry */\n\n          rc = walHashGet(pWal, walFramePage(i), &dummy, &aPgno, &iZero);\n          if( rc!=SQLITE_OK ) break;\n          pgno = aPgno[i-iZero];\n          iDbOff = (i64)(pgno-1) * szPage;\n\n          if( iDbOff+szPage<=szDb ){\n            iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;\n            rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);\n\n            if( rc==SQLITE_OK ){\n              rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff);\n            }\n\n            if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){\n              break;\n            }\n          }\n\n          pInfo->nBackfillAttempted = i-1;\n        }\n      }\n\n      sqlite3_free(pBuf1);\n      sqlite3_free(pBuf2);\n    }\n    walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n/*\n** Begin a read transaction on the database.\n**\n** This routine used to be called sqlite3OpenSnapshot() and with good reason:\n** it takes a snapshot of the state of the WAL and wal-index for the current\n** instant in time.  The current thread will continue to use this snapshot.\n** Other threads might append new content to the WAL and wal-index but\n** that extra content is ignored by the current thread.\n**\n** If the database contents have changes since the previous read\n** transaction, then *pChanged is set to 1 before returning.  The\n** Pager layer will use this to know that is cache is stale and\n** needs to be flushed.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int cnt = 0;                    /* Number of TryBeginRead attempts */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  int bChanged = 0;\n  WalIndexHdr *pSnapshot = pWal->pSnapshot;\n  if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n    bChanged = 1;\n  }\n#endif\n\n  do{\n    rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);\n  }while( rc==WAL_RETRY );\n  testcase( (rc&0xff)==SQLITE_BUSY );\n  testcase( (rc&0xff)==SQLITE_IOERR );\n  testcase( rc==SQLITE_PROTOCOL );\n  testcase( rc==SQLITE_OK );\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( rc==SQLITE_OK ){\n    if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n      /* At this point the client has a lock on an aReadMark[] slot holding\n      ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr\n      ** is populated with the wal-index header corresponding to the head\n      ** of the wal file. Verify that pSnapshot is still valid before\n      ** continuing.  Reasons why pSnapshot might no longer be valid:\n      **\n      **    (1)  The WAL file has been reset since the snapshot was taken.\n      **         In this case, the salt will have changed.\n      **\n      **    (2)  A checkpoint as been attempted that wrote frames past\n      **         pSnapshot->mxFrame into the database file.  Note that the\n      **         checkpoint need not have completed for this to cause problems.\n      */\n      volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n\n      assert( pWal->readLock>0 || pWal->hdr.mxFrame==0 );\n      assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame );\n\n      /* It is possible that there is a checkpointer thread running \n      ** concurrent with this code. If this is the case, it may be that the\n      ** checkpointer has already determined that it will checkpoint \n      ** snapshot X, where X is later in the wal file than pSnapshot, but \n      ** has not yet set the pInfo->nBackfillAttempted variable to indicate \n      ** its intent. To avoid the race condition this leads to, ensure that\n      ** there is no checkpointer process by taking a shared CKPT lock \n      ** before checking pInfo->nBackfillAttempted.  \n      **\n      ** TODO: Does the aReadMark[] lock prevent a checkpointer from doing\n      **       this already?\n      */\n      rc = walLockShared(pWal, WAL_CKPT_LOCK);\n\n      if( rc==SQLITE_OK ){\n        /* Check that the wal file has not been wrapped. Assuming that it has\n        ** not, also check that no checkpointer has attempted to checkpoint any\n        ** frames beyond pSnapshot->mxFrame. If either of these conditions are\n        ** true, return SQLITE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr\n        ** with *pSnapshot and set *pChanged as appropriate for opening the\n        ** snapshot.  */\n        if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))\n         && pSnapshot->mxFrame>=pInfo->nBackfillAttempted\n        ){\n          assert( pWal->readLock>0 );\n          memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));\n          *pChanged = bChanged;\n        }else{\n          rc = SQLITE_BUSY_SNAPSHOT;\n        }\n\n        /* Release the shared CKPT lock obtained above. */\n        walUnlockShared(pWal, WAL_CKPT_LOCK);\n      }\n\n\n      if( rc!=SQLITE_OK ){\n        sqlite3WalEndReadTransaction(pWal);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Finish with a read transaction.  All this does is release the\n** read-lock.\n*/\nSQLITE_PRIVATE void sqlite3WalEndReadTransaction(Wal *pWal){\n  sqlite3WalEndWriteTransaction(pWal);\n  if( pWal->readLock>=0 ){\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->readLock = -1;\n  }\n}\n\n/*\n** Search the wal file for page pgno. If found, set *piRead to the frame that\n** contains the page. Otherwise, if pgno is not in the wal file, set *piRead\n** to zero.\n**\n** Return SQLITE_OK if successful, or an error code if an error occurs. If an\n** error does occur, the final value of *piRead is undefined.\n*/\nSQLITE_PRIVATE int sqlite3WalFindFrame(\n  Wal *pWal,                      /* WAL handle */\n  Pgno pgno,                      /* Database page number to read data for */\n  u32 *piRead                     /* OUT: Frame number (or zero) */\n){\n  u32 iRead = 0;                  /* If !=0, WAL frame to return data from */\n  u32 iLast = pWal->hdr.mxFrame;  /* Last page in WAL for this reader */\n  int iHash;                      /* Used to loop through N hash tables */\n  int iMinHash;\n\n  /* This routine is only be called from within a read transaction. */\n  assert( pWal->readLock>=0 || pWal->lockError );\n\n  /* If the \"last page\" field of the wal-index header snapshot is 0, then\n  ** no data will be read from the wal under any circumstances. Return early\n  ** in this case as an optimization.  Likewise, if pWal->readLock==0, \n  ** then the WAL is ignored by the reader so return early, as if the \n  ** WAL were empty.\n  */\n  if( iLast==0 || pWal->readLock==0 ){\n    *piRead = 0;\n    return SQLITE_OK;\n  }\n\n  /* Search the hash table or tables for an entry matching page number\n  ** pgno. Each iteration of the following for() loop searches one\n  ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).\n  **\n  ** This code might run concurrently to the code in walIndexAppend()\n  ** that adds entries to the wal-index (and possibly to this hash \n  ** table). This means the value just read from the hash \n  ** slot (aHash[iKey]) may have been added before or after the \n  ** current read transaction was opened. Values added after the\n  ** read transaction was opened may have been written incorrectly -\n  ** i.e. these slots may contain garbage data. However, we assume\n  ** that any slots written before the current read transaction was\n  ** opened remain unmodified.\n  **\n  ** For the reasons above, the if(...) condition featured in the inner\n  ** loop of the following block is more stringent that would be required \n  ** if we had exclusive access to the hash-table:\n  **\n  **   (aPgno[iFrame]==pgno): \n  **     This condition filters out normal hash-table collisions.\n  **\n  **   (iFrame<=iLast): \n  **     This condition filters out entries that were added to the hash\n  **     table after the current read-transaction had started.\n  */\n  iMinHash = walFramePage(pWal->minFrame);\n  for(iHash=walFramePage(iLast); iHash>=iMinHash && iRead==0; iHash--){\n    volatile ht_slot *aHash;      /* Pointer to hash table */\n    volatile u32 *aPgno;          /* Pointer to array of page numbers */\n    u32 iZero;                    /* Frame number corresponding to aPgno[0] */\n    int iKey;                     /* Hash slot index */\n    int nCollide;                 /* Number of hash collisions remaining */\n    int rc;                       /* Error code */\n\n    rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nCollide = HASHTABLE_NSLOT;\n    for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){\n      u32 iFrame = aHash[iKey] + iZero;\n      if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){\n        assert( iFrame>iRead || CORRUPT_DB );\n        iRead = iFrame;\n      }\n      if( (nCollide--)==0 ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n    }\n  }\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* If expensive assert() statements are available, do a linear search\n  ** of the wal-index file content. Make sure the results agree with the\n  ** result obtained using the hash indexes above.  */\n  {\n    u32 iRead2 = 0;\n    u32 iTest;\n    assert( pWal->minFrame>0 );\n    for(iTest=iLast; iTest>=pWal->minFrame; iTest--){\n      if( walFramePgno(pWal, iTest)==pgno ){\n        iRead2 = iTest;\n        break;\n      }\n    }\n    assert( iRead==iRead2 );\n  }\n#endif\n\n  *piRead = iRead;\n  return SQLITE_OK;\n}\n\n/*\n** Read the contents of frame iRead from the wal file into buffer pOut\n** (which is nOut bytes in size). Return SQLITE_OK if successful, or an\n** error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3WalReadFrame(\n  Wal *pWal,                      /* WAL handle */\n  u32 iRead,                      /* Frame to read */\n  int nOut,                       /* Size of buffer pOut in bytes */\n  u8 *pOut                        /* Buffer to write page data to */\n){\n  int sz;\n  i64 iOffset;\n  sz = pWal->hdr.szPage;\n  sz = (sz&0xfe00) + ((sz&0x0001)<<16);\n  testcase( sz<=32768 );\n  testcase( sz>=65536 );\n  iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;\n  /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */\n  return sqlite3OsRead(pWal->pWalFd, pOut, (nOut>sz ? sz : nOut), iOffset);\n}\n\n/* \n** Return the size of the database in pages (or zero, if unknown).\n*/\nSQLITE_PRIVATE Pgno sqlite3WalDbsize(Wal *pWal){\n  if( pWal && ALWAYS(pWal->readLock>=0) ){\n    return pWal->hdr.nPage;\n  }\n  return 0;\n}\n\n\n/* \n** This function starts a write transaction on the WAL.\n**\n** A read transaction must have already been started by a prior call\n** to sqlite3WalBeginReadTransaction().\n**\n** If another thread or process has written into the database since\n** the read transaction was started, then it is not possible for this\n** thread to write as doing so would cause a fork.  So this routine\n** returns SQLITE_BUSY in that case and no write transaction is started.\n**\n** There can only be a single writer active at a time.\n*/\nSQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){\n  int rc;\n\n  /* Cannot start a write transaction without first holding a read\n  ** transaction. */\n  assert( pWal->readLock>=0 );\n  assert( pWal->writeLock==0 && pWal->iReCksum==0 );\n\n  if( pWal->readOnly ){\n    return SQLITE_READONLY;\n  }\n\n  /* Only one writer allowed at a time.  Get the write lock.  Return\n  ** SQLITE_BUSY if unable.\n  */\n  rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);\n  if( rc ){\n    return rc;\n  }\n  pWal->writeLock = 1;\n\n  /* If another connection has written to the database file since the\n  ** time the read transaction on this connection was started, then\n  ** the write is disallowed.\n  */\n  if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    rc = SQLITE_BUSY_SNAPSHOT;\n  }\n\n  return rc;\n}\n\n/*\n** End a write transaction.  The commit has already been done.  This\n** routine merely releases the lock.\n*/\nSQLITE_PRIVATE int sqlite3WalEndWriteTransaction(Wal *pWal){\n  if( pWal->writeLock ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    pWal->iReCksum = 0;\n    pWal->truncateOnCommit = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** If any data has been written (but not committed) to the log file, this\n** function moves the write-pointer back to the start of the transaction.\n**\n** Additionally, the callback function is invoked for each frame written\n** to the WAL since the start of the transaction. If the callback returns\n** other than SQLITE_OK, it is not invoked again and the error code is\n** returned to the caller.\n**\n** Otherwise, if the callback function does not return an error, this\n** function returns SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pWal->writeLock) ){\n    Pgno iMax = pWal->hdr.mxFrame;\n    Pgno iFrame;\n  \n    /* Restore the clients cache of the wal-index header to the state it\n    ** was in before the client began writing to the database. \n    */\n    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));\n\n    for(iFrame=pWal->hdr.mxFrame+1; \n        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; \n        iFrame++\n    ){\n      /* This call cannot fail. Unless the page for which the page number\n      ** is passed as the second argument is (a) in the cache and \n      ** (b) has an outstanding reference, then xUndo is either a no-op\n      ** (if (a) is false) or simply expels the page from the cache (if (b)\n      ** is false).\n      **\n      ** If the upper layer is doing a rollback, it is guaranteed that there\n      ** are no outstanding references to any page other than page 1. And\n      ** page 1 is never written to the log until the transaction is\n      ** committed. As a result, the call to xUndo may not fail.\n      */\n      assert( walFramePgno(pWal, iFrame)!=1 );\n      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));\n    }\n    if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);\n  }\n  return rc;\n}\n\n/* \n** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 \n** values. This function populates the array with values required to \n** \"rollback\" the write position of the WAL handle back to the current \n** point in the event of a savepoint rollback (via WalSavepointUndo()).\n*/\nSQLITE_PRIVATE void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){\n  assert( pWal->writeLock );\n  aWalData[0] = pWal->hdr.mxFrame;\n  aWalData[1] = pWal->hdr.aFrameCksum[0];\n  aWalData[2] = pWal->hdr.aFrameCksum[1];\n  aWalData[3] = pWal->nCkpt;\n}\n\n/* \n** Move the write position of the WAL back to the point identified by\n** the values in the aWalData[] array. aWalData must point to an array\n** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated\n** by a call to WalSavepoint().\n*/\nSQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){\n  int rc = SQLITE_OK;\n\n  assert( pWal->writeLock );\n  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );\n\n  if( aWalData[3]!=pWal->nCkpt ){\n    /* This savepoint was opened immediately after the write-transaction\n    ** was started. Right after that, the writer decided to wrap around\n    ** to the start of the log. Update the savepoint values to match.\n    */\n    aWalData[0] = 0;\n    aWalData[3] = pWal->nCkpt;\n  }\n\n  if( aWalData[0]<pWal->hdr.mxFrame ){\n    pWal->hdr.mxFrame = aWalData[0];\n    pWal->hdr.aFrameCksum[0] = aWalData[1];\n    pWal->hdr.aFrameCksum[1] = aWalData[2];\n    walCleanupHash(pWal);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called just before writing a set of frames to the log\n** file (see sqlite3WalFrames()). It checks to see if, instead of appending\n** to the current log file, it is possible to overwrite the start of the\n** existing log file with the new frames (i.e. \"reset\" the log). If so,\n** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left\n** unchanged.\n**\n** SQLITE_OK is returned if no error is encountered (regardless of whether\n** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned\n** if an error occurs.\n*/\nstatic int walRestartLog(Wal *pWal){\n  int rc = SQLITE_OK;\n  int cnt;\n\n  if( pWal->readLock==0 ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n    if( pInfo->nBackfill>0 ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        /* If all readers are using WAL_READ_LOCK(0) (in other words if no\n        ** readers are currently using the WAL), then the transactions\n        ** frames will overwrite the start of the existing log. Update the\n        ** wal-index header to reflect this.\n        **\n        ** In theory it would be Ok to update the cache of the header only\n        ** at this point. But updating the actual wal-index header is also\n        ** safe and means there is no special case for sqlite3WalUndo()\n        ** to handle if this transaction is rolled back.  */\n        walRestartHdr(pWal, salt1);\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n    walUnlockShared(pWal, WAL_READ_LOCK(0));\n    pWal->readLock = -1;\n    cnt = 0;\n    do{\n      int notUsed;\n      rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);\n    }while( rc==WAL_RETRY );\n    assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */\n    testcase( (rc&0xff)==SQLITE_IOERR );\n    testcase( rc==SQLITE_PROTOCOL );\n    testcase( rc==SQLITE_OK );\n  }\n  return rc;\n}\n\n/*\n** Information about the current state of the WAL file and where\n** the next fsync should occur - passed from sqlite3WalFrames() into\n** walWriteToLog().\n*/\ntypedef struct WalWriter {\n  Wal *pWal;                   /* The complete WAL information */\n  sqlite3_file *pFd;           /* The WAL file to which we write */\n  sqlite3_int64 iSyncPoint;    /* Fsync at this offset */\n  int syncFlags;               /* Flags for the fsync */\n  int szPage;                  /* Size of one page */\n} WalWriter;\n\n/*\n** Write iAmt bytes of content into the WAL file beginning at iOffset.\n** Do a sync when crossing the p->iSyncPoint boundary.\n**\n** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt,\n** first write the part before iSyncPoint, then sync, then write the\n** rest.\n*/\nstatic int walWriteToLog(\n  WalWriter *p,              /* WAL to write to */\n  void *pContent,            /* Content to be written */\n  int iAmt,                  /* Number of bytes to write */\n  sqlite3_int64 iOffset      /* Start writing at this offset */\n){\n  int rc;\n  if( iOffset<p->iSyncPoint && iOffset+iAmt>=p->iSyncPoint ){\n    int iFirstAmt = (int)(p->iSyncPoint - iOffset);\n    rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);\n    if( rc ) return rc;\n    iOffset += iFirstAmt;\n    iAmt -= iFirstAmt;\n    pContent = (void*)(iFirstAmt + (char*)pContent);\n    assert( WAL_SYNC_FLAGS(p->syncFlags)!=0 );\n    rc = sqlite3OsSync(p->pFd, WAL_SYNC_FLAGS(p->syncFlags));\n    if( iAmt==0 || rc ) return rc;\n  }\n  rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);\n  return rc;\n}\n\n/*\n** Write out a single frame of the WAL\n*/\nstatic int walWriteOneFrame(\n  WalWriter *p,               /* Where to write the frame */\n  PgHdr *pPage,               /* The page of the frame to be written */\n  int nTruncate,              /* The commit flag.  Usually 0.  >0 for commit */\n  sqlite3_int64 iOffset       /* Byte offset at which to write */\n){\n  int rc;                         /* Result code from subfunctions */\n  void *pData;                    /* Data actually written */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */\n#if defined(SQLITE_HAS_CODEC)\n  if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;\n#else\n  pData = pPage->pData;\n#endif\n  walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);\n  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);\n  if( rc ) return rc;\n  /* Write the page data */\n  rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));\n  return rc;\n}\n\n/*\n** This function is called as part of committing a transaction within which\n** one or more frames have been overwritten. It updates the checksums for\n** all frames written to the wal file by the current transaction starting\n** with the earliest to have been overwritten.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int walRewriteChecksums(Wal *pWal, u32 iLast){\n  const int szPage = pWal->szPage;/* Database page size */\n  int rc = SQLITE_OK;             /* Return code */\n  u8 *aBuf;                       /* Buffer to load data from wal file into */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-headers in */\n  u32 iRead;                      /* Next frame to read from wal file */\n  i64 iCksumOff;\n\n  aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE);\n  if( aBuf==0 ) return SQLITE_NOMEM_BKPT;\n\n  /* Find the checksum values to use as input for the recalculating the\n  ** first checksum. If the first frame is frame 1 (implying that the current\n  ** transaction restarted the wal file), these values must be read from the\n  ** wal-file header. Otherwise, read them from the frame header of the\n  ** previous frame.  */\n  assert( pWal->iReCksum>0 );\n  if( pWal->iReCksum==1 ){\n    iCksumOff = 24;\n  }else{\n    iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16;\n  }\n  rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff);\n  pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf);\n  pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]);\n\n  iRead = pWal->iReCksum;\n  pWal->iReCksum = 0;\n  for(; rc==SQLITE_OK && iRead<=iLast; iRead++){\n    i64 iOff = walFrameOffset(iRead, szPage);\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);\n    if( rc==SQLITE_OK ){\n      u32 iPgno, nDbSize;\n      iPgno = sqlite3Get4byte(aBuf);\n      nDbSize = sqlite3Get4byte(&aBuf[4]);\n\n      walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame);\n      rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff);\n    }\n  }\n\n  sqlite3_free(aBuf);\n  return rc;\n}\n\n/* \n** Write a set of frames to the log. The caller must hold the write-lock\n** on the log file (obtained using sqlite3WalBeginWriteTransaction()).\n*/\nSQLITE_PRIVATE int sqlite3WalFrames(\n  Wal *pWal,                      /* Wal handle to write to */\n  int szPage,                     /* Database page-size in bytes */\n  PgHdr *pList,                   /* List of dirty pages to write */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit,                   /* True if this is a commit */\n  int sync_flags                  /* Flags to pass to OsSync() (or 0) */\n){\n  int rc;                         /* Used to catch return codes */\n  u32 iFrame;                     /* Next frame address */\n  PgHdr *p;                       /* Iterator to run through pList with. */\n  PgHdr *pLast = 0;               /* Last frame in list */\n  int nExtra = 0;                 /* Number of extra copies of last page */\n  int szFrame;                    /* The size of a single frame */\n  i64 iOffset;                    /* Next byte to write in WAL file */\n  WalWriter w;                    /* The writer */\n  u32 iFirst = 0;                 /* First frame that may be overwritten */\n  WalIndexHdr *pLive;             /* Pointer to shared header */\n\n  assert( pList );\n  assert( pWal->writeLock );\n\n  /* If this frame set completes a transaction, then nTruncate>0.  If\n  ** nTruncate==0 then this frame set does not complete the transaction. */\n  assert( (isCommit!=0)==(nTruncate!=0) );\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}\n    WALTRACE((\"WAL%p: frame write begin. %d frames. mxFrame=%d. %s\\n\",\n              pWal, cnt, pWal->hdr.mxFrame, isCommit ? \"Commit\" : \"Spill\"));\n  }\n#endif\n\n  pLive = (WalIndexHdr*)walIndexHdr(pWal);\n  if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 ){\n    iFirst = pLive->mxFrame+1;\n  }\n\n  /* See if it is possible to write these frames into the start of the\n  ** log file, instead of appending to it at pWal->hdr.mxFrame.\n  */\n  if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){\n    return rc;\n  }\n\n  /* If this is the first frame written into the log, write the WAL\n  ** header to the start of the WAL file. See comments at the top of\n  ** this source file for a description of the WAL header format.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  if( iFrame==0 ){\n    u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */\n    u32 aCksum[2];                /* Checksum for wal-header */\n\n    sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));\n    sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);\n    sqlite3Put4byte(&aWalHdr[8], szPage);\n    sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);\n    if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);\n    memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);\n    walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);\n    sqlite3Put4byte(&aWalHdr[24], aCksum[0]);\n    sqlite3Put4byte(&aWalHdr[28], aCksum[1]);\n    \n    pWal->szPage = szPage;\n    pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;\n    pWal->hdr.aFrameCksum[0] = aCksum[0];\n    pWal->hdr.aFrameCksum[1] = aCksum[1];\n    pWal->truncateOnCommit = 1;\n\n    rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);\n    WALTRACE((\"WAL%p: wal-header write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless\n    ** all syncing is turned off by PRAGMA synchronous=OFF).  Otherwise\n    ** an out-of-order write following a WAL restart could result in\n    ** database corruption.  See the ticket:\n    **\n    **     https://sqlite.org/src/info/ff5be73dee\n    */\n    if( pWal->syncHeader ){\n      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n      if( rc ) return rc;\n    }\n  }\n  assert( (int)pWal->szPage==szPage );\n\n  /* Setup information needed to write frames into the WAL */\n  w.pWal = pWal;\n  w.pFd = pWal->pWalFd;\n  w.iSyncPoint = 0;\n  w.syncFlags = sync_flags;\n  w.szPage = szPage;\n  iOffset = walFrameOffset(iFrame+1, szPage);\n  szFrame = szPage + WAL_FRAME_HDRSIZE;\n\n  /* Write all frames into the log file exactly once */\n  for(p=pList; p; p=p->pDirty){\n    int nDbSize;   /* 0 normally.  Positive == commit flag */\n\n    /* Check if this page has already been written into the wal file by\n    ** the current transaction. If so, overwrite the existing frame and\n    ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that \n    ** checksums must be recomputed when the transaction is committed.  */\n    if( iFirst && (p->pDirty || isCommit==0) ){\n      u32 iWrite = 0;\n      VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite);\n      assert( rc==SQLITE_OK || iWrite==0 );\n      if( iWrite>=iFirst ){\n        i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE;\n        void *pData;\n        if( pWal->iReCksum==0 || iWrite<pWal->iReCksum ){\n          pWal->iReCksum = iWrite;\n        }\n#if defined(SQLITE_HAS_CODEC)\n        if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;\n#else\n        pData = p->pData;\n#endif\n        rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOff);\n        if( rc ) return rc;\n        p->flags &= ~PGHDR_WAL_APPEND;\n        continue;\n      }\n    }\n\n    iFrame++;\n    assert( iOffset==walFrameOffset(iFrame, szPage) );\n    nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0;\n    rc = walWriteOneFrame(&w, p, nDbSize, iOffset);\n    if( rc ) return rc;\n    pLast = p;\n    iOffset += szFrame;\n    p->flags |= PGHDR_WAL_APPEND;\n  }\n\n  /* Recalculate checksums within the wal file if required. */\n  if( isCommit && pWal->iReCksum ){\n    rc = walRewriteChecksums(pWal, iFrame);\n    if( rc ) return rc;\n  }\n\n  /* If this is the end of a transaction, then we might need to pad\n  ** the transaction and/or sync the WAL file.\n  **\n  ** Padding and syncing only occur if this set of frames complete a\n  ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL\n  ** or synchronous==OFF, then no padding or syncing are needed.\n  **\n  ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not\n  ** needed and only the sync is done.  If padding is needed, then the\n  ** final frame is repeated (with its commit mark) until the next sector\n  ** boundary is crossed.  Only the part of the WAL prior to the last\n  ** sector boundary is synced; the part of the last frame that extends\n  ** past the sector boundary is written after the sync.\n  */\n  if( isCommit && WAL_SYNC_FLAGS(sync_flags)!=0 ){\n    int bSync = 1;\n    if( pWal->padToSectorBoundary ){\n      int sectorSize = sqlite3SectorSize(pWal->pWalFd);\n      w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;\n      bSync = (w.iSyncPoint==iOffset);\n      testcase( bSync );\n      while( iOffset<w.iSyncPoint ){\n        rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);\n        if( rc ) return rc;\n        iOffset += szFrame;\n        nExtra++;\n      }\n    }\n    if( bSync ){\n      assert( rc==SQLITE_OK );\n      rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));\n    }\n  }\n\n  /* If this frame set completes the first transaction in the WAL and\n  ** if PRAGMA journal_size_limit is set, then truncate the WAL to the\n  ** journal size limit, if possible.\n  */\n  if( isCommit && pWal->truncateOnCommit && pWal->mxWalSize>=0 ){\n    i64 sz = pWal->mxWalSize;\n    if( walFrameOffset(iFrame+nExtra+1, szPage)>pWal->mxWalSize ){\n      sz = walFrameOffset(iFrame+nExtra+1, szPage);\n    }\n    walLimitSize(pWal, sz);\n    pWal->truncateOnCommit = 0;\n  }\n\n  /* Append data to the wal-index. It is not necessary to lock the \n  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index\n  ** guarantees that there are no other writers, and no data that may\n  ** be in use by existing readers is being overwritten.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){\n    if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;\n    iFrame++;\n    rc = walIndexAppend(pWal, iFrame, p->pgno);\n  }\n  while( rc==SQLITE_OK && nExtra>0 ){\n    iFrame++;\n    nExtra--;\n    rc = walIndexAppend(pWal, iFrame, pLast->pgno);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* Update the private copy of the header. */\n    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n    testcase( szPage<=32768 );\n    testcase( szPage>=65536 );\n    pWal->hdr.mxFrame = iFrame;\n    if( isCommit ){\n      pWal->hdr.iChange++;\n      pWal->hdr.nPage = nTruncate;\n    }\n    /* If this is a commit, update the wal-index header too. */\n    if( isCommit ){\n      walIndexWriteHdr(pWal);\n      pWal->iCallback = iFrame;\n    }\n  }\n\n  WALTRACE((\"WAL%p: frame write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return rc;\n}\n\n/* \n** This routine is called to implement sqlite3_wal_checkpoint() and\n** related interfaces.\n**\n** Obtain a CHECKPOINT lock and then backfill as much information as\n** we can from WAL into the database.\n**\n** If parameter xBusy is not NULL, it is a pointer to a busy-handler\n** callback. In this case this function runs a blocking checkpoint.\n*/\nSQLITE_PRIVATE int sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* PASSIVE, FULL, RESTART, or TRUNCATE */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of temporary buffer */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n){\n  int rc;                         /* Return code */\n  int isChanged = 0;              /* True if a new wal-index header is loaded */\n  int eMode2 = eMode;             /* Mode to pass to walCheckpoint() */\n  int (*xBusy2)(void*) = xBusy;   /* Busy handler for eMode2 */\n\n  assert( pWal->ckptLock==0 );\n  assert( pWal->writeLock==0 );\n\n  /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n  ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n  assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n  if( pWal->readOnly ) return SQLITE_READONLY;\n  WALTRACE((\"WAL%p: checkpoint begins\\n\", pWal));\n\n  /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive \n  ** \"checkpoint\" lock on the database file. */\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc ){\n    /* EVIDENCE-OF: R-10421-19736 If any other process is running a\n    ** checkpoint operation at the same time, the lock cannot be obtained and\n    ** SQLITE_BUSY is returned.\n    ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,\n    ** it will not be invoked in this case.\n    */\n    testcase( rc==SQLITE_BUSY );\n    testcase( xBusy!=0 );\n    return rc;\n  }\n  pWal->ckptLock = 1;\n\n  /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and\n  ** TRUNCATE modes also obtain the exclusive \"writer\" lock on the database\n  ** file.\n  **\n  ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained\n  ** immediately, and a busy-handler is configured, it is invoked and the\n  ** writer lock retried until either the busy-handler returns 0 or the\n  ** lock is successfully obtained.\n  */\n  if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);\n    if( rc==SQLITE_OK ){\n      pWal->writeLock = 1;\n    }else if( rc==SQLITE_BUSY ){\n      eMode2 = SQLITE_CHECKPOINT_PASSIVE;\n      xBusy2 = 0;\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* Read the wal-index header. */\n  if( rc==SQLITE_OK ){\n    rc = walIndexReadHdr(pWal, &isChanged);\n    if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){\n      sqlite3OsUnfetch(pWal->pDbFd, 0, 0);\n    }\n  }\n\n  /* Copy data from the log to the database file. */\n  if( rc==SQLITE_OK ){\n\n    if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);\n    }\n\n    /* If no error occurred, set the output variables. */\n    if( rc==SQLITE_OK || rc==SQLITE_BUSY ){\n      if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;\n      if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);\n    }\n  }\n\n  if( isChanged ){\n    /* If a new wal-index header was loaded before the checkpoint was \n    ** performed, then the pager-cache associated with pWal is now\n    ** out of date. So zero the cached wal-index header to ensure that\n    ** next time the pager opens a snapshot on this database it knows that\n    ** the cache needs to be reset.\n    */\n    memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n  }\n\n  /* Release the locks. */\n  sqlite3WalEndWriteTransaction(pWal);\n  walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  pWal->ckptLock = 0;\n  WALTRACE((\"WAL%p: checkpoint %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return (rc==SQLITE_OK && eMode!=eMode2 ? SQLITE_BUSY : rc);\n}\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nSQLITE_PRIVATE int sqlite3WalCallback(Wal *pWal){\n  u32 ret = 0;\n  if( pWal ){\n    ret = pWal->iCallback;\n    pWal->iCallback = 0;\n  }\n  return (int)ret;\n}\n\n/*\n** This function is called to change the WAL subsystem into or out\n** of locking_mode=EXCLUSIVE.\n**\n** If op is zero, then attempt to change from locking_mode=EXCLUSIVE\n** into locking_mode=NORMAL.  This means that we must acquire a lock\n** on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL\n** or if the acquisition of the lock fails, then return 0.  If the\n** transition out of exclusive-mode is successful, return 1.  This\n** operation must occur while the pager is still holding the exclusive\n** lock on the main database file.\n**\n** If op is one, then change from locking_mode=NORMAL into \n** locking_mode=EXCLUSIVE.  This means that the pWal->readLock must\n** be released.  Return 1 if the transition is made and 0 if the\n** WAL is already in exclusive-locking mode - meaning that this\n** routine is a no-op.  The pager must already hold the exclusive lock\n** on the main database file before invoking this operation.\n**\n** If op is negative, then do a dry-run of the op==1 case but do\n** not actually change anything. The pager uses this to see if it\n** should acquire the database exclusive lock prior to invoking\n** the op==1 case.\n*/\nSQLITE_PRIVATE int sqlite3WalExclusiveMode(Wal *pWal, int op){\n  int rc;\n  assert( pWal->writeLock==0 );\n  assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 );\n\n  /* pWal->readLock is usually set, but might be -1 if there was a \n  ** prior error while attempting to acquire are read-lock. This cannot \n  ** happen if the connection is actually in exclusive mode (as no xShmLock\n  ** locks are taken in this case). Nor should the pager attempt to\n  ** upgrade to exclusive-mode following such an error.\n  */\n  assert( pWal->readLock>=0 || pWal->lockError );\n  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );\n\n  if( op==0 ){\n    if( pWal->exclusiveMode ){\n      pWal->exclusiveMode = 0;\n      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){\n        pWal->exclusiveMode = 1;\n      }\n      rc = pWal->exclusiveMode==0;\n    }else{\n      /* Already in locking_mode=NORMAL */\n      rc = 0;\n    }\n  }else if( op>0 ){\n    assert( pWal->exclusiveMode==0 );\n    assert( pWal->readLock>=0 );\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->exclusiveMode = 1;\n    rc = 1;\n  }else{\n    rc = pWal->exclusiveMode==0;\n  }\n  return rc;\n}\n\n/* \n** Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nSQLITE_PRIVATE int sqlite3WalHeapMemory(Wal *pWal){\n  return (pWal && pWal->exclusiveMode==WAL_HEAPMEMORY_MODE );\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/* Create a snapshot object.  The content of a snapshot is opaque to\n** every other subsystem, so the WAL module can put whatever it needs\n** in the object.\n*/\nSQLITE_PRIVATE int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_OK;\n  WalIndexHdr *pRet;\n  static const u32 aZero[4] = { 0, 0, 0, 0 };\n\n  assert( pWal->readLock>=0 && pWal->writeLock==0 );\n\n  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){\n    *ppSnapshot = 0;\n    return SQLITE_ERROR;\n  }\n  pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr));\n  if( pRet==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    memcpy(pRet, &pWal->hdr, sizeof(WalIndexHdr));\n    *ppSnapshot = (sqlite3_snapshot*)pRet;\n  }\n\n  return rc;\n}\n\n/* Try to open on pSnapshot when the next read-transaction starts\n*/\nSQLITE_PRIVATE void sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){\n  pWal->pSnapshot = (WalIndexHdr*)pSnapshot;\n}\n\n/* \n** Return a +ve value if snapshot p1 is newer than p2. A -ve value if\n** p1 is older than p2 and zero if p1 and p2 are the same snapshot.\n*/\nSQLITE_API int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){\n  WalIndexHdr *pHdr1 = (WalIndexHdr*)p1;\n  WalIndexHdr *pHdr2 = (WalIndexHdr*)p2;\n\n  /* aSalt[0] is a copy of the value stored in the wal file header. It\n  ** is incremented each time the wal file is restarted.  */\n  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;\n  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;\n  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;\n  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;\n  return 0;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** If the argument is not NULL, it points to a Wal object that holds a\n** read-lock. This function returns the database page-size if it is known,\n** or zero if it is not (or if pWal is NULL).\n*/\nSQLITE_PRIVATE int sqlite3WalFramesize(Wal *pWal){\n  assert( pWal==0 || pWal->readLock>=0 );\n  return (pWal ? pWal->szPage : 0);\n}\n#endif\n\n/* Return the sqlite3_file object for the WAL file\n*/\nSQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal){\n  return pWal->pWalFd;\n}\n\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/************** End of wal.c *************************************************/\n/************** Begin file btmutex.c *****************************************/\n/*\n** 2007 August 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement mutexes on Btree objects.\n** This code really belongs in btree.c.  But btree.c is getting too\n** big and we want to break it down some.  This packaged seemed like\n** a good breakout.\n*/\n/************** Include btreeInt.h in the middle of btmutex.c ****************/\n/************** Begin file btreeInt.h ****************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** For a detailed discussion of BTrees, refer to\n**\n**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:\n**     \"Sorting And Searching\", pages 473-480. Addison-Wesley\n**     Publishing Company, Reading, Massachusetts.\n**\n** The basic idea is that each page of the file contains N database\n** entries and N+1 pointers to subpages.\n**\n**   ----------------------------------------------------------------\n**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |\n**   ----------------------------------------------------------------\n**\n** All of the keys on the page that Ptr(0) points to have values less\n** than Key(0).  All of the keys on page Ptr(1) and its subpages have\n** values greater than Key(0) and less than Key(1).  All of the keys\n** on Ptr(N) and its subpages have values greater than Key(N-1).  And\n** so forth.\n**\n** Finding a particular key requires reading O(log(M)) pages from the \n** disk where M is the number of entries in the tree.\n**\n** In this implementation, a single file can hold one or more separate \n** BTrees.  Each BTree is identified by the index of its root page.  The\n** key and data for any entry are combined to form the \"payload\".  A\n** fixed amount of payload can be carried directly on the database\n** page.  If the payload is larger than the preset amount then surplus\n** bytes are stored on overflow pages.  The payload for an entry\n** and the preceding pointer are combined to form a \"Cell\".  Each \n** page has a small header which contains the Ptr(N) pointer and other\n** information such as the size of key and data.\n**\n** FORMAT DETAILS\n**\n** The file is divided into pages.  The first page is called page 1,\n** the second is page 2, and so forth.  A page number of zero indicates\n** \"no such page\".  The page size can be any power of 2 between 512 and 65536.\n** Each page can be either a btree page, a freelist page, an overflow\n** page, or a pointer-map page.\n**\n** The first page is always a btree page.  The first 100 bytes of the first\n** page contain a special header (the \"file header\") that describes the file.\n** The format of the file header is as follows:\n**\n**   OFFSET   SIZE    DESCRIPTION\n**      0      16     Header string: \"SQLite format 3\\000\"\n**     16       2     Page size in bytes.  (1 means 65536)\n**     18       1     File format write version\n**     19       1     File format read version\n**     20       1     Bytes of unused space at the end of each page\n**     21       1     Max embedded payload fraction (must be 64)\n**     22       1     Min embedded payload fraction (must be 32)\n**     23       1     Min leaf payload fraction (must be 32)\n**     24       4     File change counter\n**     28       4     Reserved for future use\n**     32       4     First freelist page\n**     36       4     Number of freelist pages in the file\n**     40      60     15 4-byte meta values passed to higher layers\n**\n**     40       4     Schema cookie\n**     44       4     File format of schema layer\n**     48       4     Size of page cache\n**     52       4     Largest root-page (auto/incr_vacuum)\n**     56       4     1=UTF-8 2=UTF16le 3=UTF16be\n**     60       4     User version\n**     64       4     Incremental vacuum mode\n**     68       4     Application-ID\n**     72      20     unused\n**     92       4     The version-valid-for number\n**     96       4     SQLITE_VERSION_NUMBER\n**\n** All of the integer values are big-endian (most significant byte first).\n**\n** The file change counter is incremented when the database is changed\n** This counter allows other processes to know when the file has changed\n** and thus when they need to flush their cache.\n**\n** The max embedded payload fraction is the amount of the total usable\n** space in a page that can be consumed by a single cell for standard\n** B-tree (non-LEAFDATA) tables.  A value of 255 means 100%.  The default\n** is to limit the maximum cell size so that at least 4 cells will fit\n** on one page.  Thus the default max embedded payload fraction is 64.\n**\n** If the payload for a cell is larger than the max payload, then extra\n** payload is spilled to overflow pages.  Once an overflow page is allocated,\n** as many bytes as possible are moved into the overflow pages without letting\n** the cell size drop below the min embedded payload fraction.\n**\n** The min leaf payload fraction is like the min embedded payload fraction\n** except that it applies to leaf nodes in a LEAFDATA tree.  The maximum\n** payload fraction for a LEAFDATA tree is always 100% (or 255) and it\n** not specified in the header.\n**\n** Each btree pages is divided into three sections:  The header, the\n** cell pointer array, and the cell content area.  Page 1 also has a 100-byte\n** file header that occurs before the page header.\n**\n**      |----------------|\n**      | file header    |   100 bytes.  Page 1 only.\n**      |----------------|\n**      | page header    |   8 bytes for leaves.  12 bytes for interior nodes\n**      |----------------|\n**      | cell pointer   |   |  2 bytes per cell.  Sorted order.\n**      | array          |   |  Grows downward\n**      |                |   v\n**      |----------------|\n**      | unallocated    |\n**      | space          |\n**      |----------------|   ^  Grows upwards\n**      | cell content   |   |  Arbitrary order interspersed with freeblocks.\n**      | area           |   |  and free space fragments.\n**      |----------------|\n**\n** The page headers looks like this:\n**\n**   OFFSET   SIZE     DESCRIPTION\n**      0       1      Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf\n**      1       2      byte offset to the first freeblock\n**      3       2      number of cells on this page\n**      5       2      first byte of the cell content area\n**      7       1      number of fragmented free bytes\n**      8       4      Right child (the Ptr(N) value).  Omitted on leaves.\n**\n** The flags define the format of this btree page.  The leaf flag means that\n** this page has no children.  The zerodata flag means that this page carries\n** only keys and no data.  The intkey flag means that the key is an integer\n** which is stored in the key size entry of the cell header rather than in\n** the payload area.\n**\n** The cell pointer array begins on the first byte after the page header.\n** The cell pointer array contains zero or more 2-byte numbers which are\n** offsets from the beginning of the page to the cell content in the cell\n** content area.  The cell pointers occur in sorted order.  The system strives\n** to keep free space after the last cell pointer so that new cells can\n** be easily added without having to defragment the page.\n**\n** Cell content is stored at the very end of the page and grows toward the\n** beginning of the page.\n**\n** Unused space within the cell content area is collected into a linked list of\n** freeblocks.  Each freeblock is at least 4 bytes in size.  The byte offset\n** to the first freeblock is given in the header.  Freeblocks occur in\n** increasing order.  Because a freeblock must be at least 4 bytes in size,\n** any group of 3 or fewer unused bytes in the cell content area cannot\n** exist on the freeblock chain.  A group of 3 or fewer free bytes is called\n** a fragment.  The total number of bytes in all fragments is recorded.\n** in the page header at offset 7.\n**\n**    SIZE    DESCRIPTION\n**      2     Byte offset of the next freeblock\n**      2     Bytes in this freeblock\n**\n** Cells are of variable length.  Cells are stored in the cell content area at\n** the end of the page.  Pointers to the cells are in the cell pointer array\n** that immediately follows the page header.  Cells is not necessarily\n** contiguous or in order, but cell pointers are contiguous and in order.\n**\n** Cell content makes use of variable length integers.  A variable\n** length integer is 1 to 9 bytes where the lower 7 bits of each \n** byte are used.  The integer consists of all bytes that have bit 8 set and\n** the first byte with bit 8 clear.  The most significant byte of the integer\n** appears first.  A variable-length integer may not be more than 9 bytes long.\n** As a special case, all 8 bytes of the 9th byte are used as data.  This\n** allows a 64-bit integer to be encoded in 9 bytes.\n**\n**    0x00                      becomes  0x00000000\n**    0x7f                      becomes  0x0000007f\n**    0x81 0x00                 becomes  0x00000080\n**    0x82 0x00                 becomes  0x00000100\n**    0x80 0x7f                 becomes  0x0000007f\n**    0x8a 0x91 0xd1 0xac 0x78  becomes  0x12345678\n**    0x81 0x81 0x81 0x81 0x01  becomes  0x10204081\n**\n** Variable length integers are used for rowids and to hold the number of\n** bytes of key and data in a btree cell.\n**\n** The content of a cell looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of the left child. Omitted if leaf flag is set.\n**     var    Number of bytes of data. Omitted if the zerodata flag is set.\n**     var    Number of bytes of key. Or the key itself if intkey flag is set.\n**      *     Payload\n**      4     First page of the overflow chain.  Omitted if no overflow\n**\n** Overflow pages form a linked list.  Each page except the last is completely\n** filled with data (pagesize - 4 bytes).  The last page can have as little\n** as 1 byte of data.\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next overflow page\n**      *     Data\n**\n** Freelist pages come in two subtypes: trunk pages and leaf pages.  The\n** file header points to the first in a linked list of trunk page.  Each trunk\n** page points to multiple leaf pages.  The content of a leaf page is\n** unspecified.  A trunk page looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next trunk page\n**      4     Number of leaf pointers on this page\n**      *     zero or more pages numbers of leaves\n*/\n/* #include \"sqliteInt.h\" */\n\n\n/* The following value is the maximum cell size assuming a maximum page\n** size give above.\n*/\n#define MX_CELL_SIZE(pBt)  ((int)(pBt->pageSize-8))\n\n/* The maximum number of cells on a single page of the database.  This\n** assumes a minimum cell size of 6 bytes  (4 bytes for the cell itself\n** plus 2 bytes for the index to the cell in the page header).  Such\n** small cells will be rare, but they are possible.\n*/\n#define MX_CELL(pBt) ((pBt->pageSize-8)/6)\n\n/* Forward declarations */\ntypedef struct MemPage MemPage;\ntypedef struct BtLock BtLock;\ntypedef struct CellInfo CellInfo;\n\n/*\n** This is a magic string that appears at the beginning of every\n** SQLite database in order to identify the file as a real database.\n**\n** You can change this value at compile-time by specifying a\n** -DSQLITE_FILE_HEADER=\"...\" on the compiler command-line.  The\n** header must be exactly 16 bytes including the zero-terminator so\n** the string itself should be 15 characters long.  If you change\n** the header, then your custom library will not be able to read \n** databases generated by the standard tools and the standard tools\n** will not be able to read databases created by your custom library.\n*/\n#ifndef SQLITE_FILE_HEADER /* 123456789 123456 */\n#  define SQLITE_FILE_HEADER \"SQLite format 3\"\n#endif\n\n/*\n** Page type flags.  An ORed combination of these flags appear as the\n** first byte of on-disk image of every BTree page.\n*/\n#define PTF_INTKEY    0x01\n#define PTF_ZERODATA  0x02\n#define PTF_LEAFDATA  0x04\n#define PTF_LEAF      0x08\n\n/*\n** An instance of this object stores information about each a single database\n** page that has been loaded into memory.  The information in this object\n** is derived from the raw on-disk page content.\n**\n** As each database page is loaded into memory, the pager allocats an\n** instance of this object and zeros the first 8 bytes.  (This is the\n** \"extra\" information associated with each page of the pager.)\n**\n** Access to all fields of this structure is controlled by the mutex\n** stored in MemPage.pBt->mutex.\n*/\nstruct MemPage {\n  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */\n  u8 bBusy;            /* Prevent endless loops on corrupt database files */\n  u8 intKey;           /* True if table b-trees.  False for index b-trees */\n  u8 intKeyLeaf;       /* True if the leaf of an intKey table */\n  Pgno pgno;           /* Page number for this page */\n  /* Only the first 8 bytes (above) are zeroed by pager.c when a new page\n  ** is allocated. All fields that follow must be initialized before use */\n  u8 leaf;             /* True if a leaf page */\n  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */\n  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */\n  u8 max1bytePayload;  /* min(maxLocal,127) */\n  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */\n  u16 maxLocal;        /* Copy of BtShared.maxLocal or BtShared.maxLeaf */\n  u16 minLocal;        /* Copy of BtShared.minLocal or BtShared.minLeaf */\n  u16 cellOffset;      /* Index in aData of first cell pointer */\n  u16 nFree;           /* Number of free bytes on the page */\n  u16 nCell;           /* Number of cells on this page, local and ovfl */\n  u16 maskPage;        /* Mask for page offset */\n  u16 aiOvfl[4];       /* Insert the i-th overflow cell before the aiOvfl-th\n                       ** non-overflow cell */\n  u8 *apOvfl[4];       /* Pointers to the body of overflow cells */\n  BtShared *pBt;       /* Pointer to BtShared that this page is part of */\n  u8 *aData;           /* Pointer to disk image of the page data */\n  u8 *aDataEnd;        /* One byte past the end of usable data */\n  u8 *aCellIdx;        /* The cell index area */\n  u8 *aDataOfst;       /* Same as aData for leaves.  aData+4 for interior */\n  DbPage *pDbPage;     /* Pager page handle */\n  u16 (*xCellSize)(MemPage*,u8*);             /* cellSizePtr method */\n  void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */\n};\n\n/*\n** A linked list of the following structures is stored at BtShared.pLock.\n** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor \n** is opened on the table with root page BtShared.iTable. Locks are removed\n** from this list when a transaction is committed or rolled back, or when\n** a btree handle is closed.\n*/\nstruct BtLock {\n  Btree *pBtree;        /* Btree handle holding this lock */\n  Pgno iTable;          /* Root page of table */\n  u8 eLock;             /* READ_LOCK or WRITE_LOCK */\n  BtLock *pNext;        /* Next in BtShared.pLock list */\n};\n\n/* Candidate values for BtLock.eLock */\n#define READ_LOCK     1\n#define WRITE_LOCK    2\n\n/* A Btree handle\n**\n** A database connection contains a pointer to an instance of\n** this object for every database file that it has open.  This structure\n** is opaque to the database connection.  The database connection cannot\n** see the internals of this structure and only deals with pointers to\n** this structure.\n**\n** For some database files, the same underlying database cache might be \n** shared between multiple connections.  In that case, each connection\n** has it own instance of this object.  But each instance of this object\n** points to the same BtShared object.  The database cache and the\n** schema associated with the database file are all contained within\n** the BtShared object.\n**\n** All fields in this structure are accessed under sqlite3.mutex.\n** The pBt pointer itself may not be changed while there exists cursors \n** in the referenced BtShared that point back to this Btree since those\n** cursors have to go through this Btree to find their BtShared and\n** they often do so without holding sqlite3.mutex.\n*/\nstruct Btree {\n  sqlite3 *db;       /* The database connection holding this btree */\n  BtShared *pBt;     /* Sharable content of this btree */\n  u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */\n  u8 sharable;       /* True if we can share pBt with another db */\n  u8 locked;         /* True if db currently has pBt locked */\n  u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */\n  int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */\n  int nBackup;       /* Number of backup operations reading this btree */\n  u32 iDataVersion;  /* Combines with pBt->pPager->iDataVersion */\n  Btree *pNext;      /* List of other sharable Btrees from the same db */\n  Btree *pPrev;      /* Back pointer of the same list */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  BtLock lock;       /* Object used to lock page 1 */\n#endif\n};\n\n/*\n** Btree.inTrans may take one of the following values.\n**\n** If the shared-data extension is enabled, there may be multiple users\n** of the Btree structure. At most one of these may open a write transaction,\n** but any number may have active read transactions.\n*/\n#define TRANS_NONE  0\n#define TRANS_READ  1\n#define TRANS_WRITE 2\n\n/*\n** An instance of this object represents a single database file.\n** \n** A single database file can be in use at the same time by two\n** or more database connections.  When two or more connections are\n** sharing the same database file, each connection has it own\n** private Btree object for the file and each of those Btrees points\n** to this one BtShared object.  BtShared.nRef is the number of\n** connections currently sharing this database file.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** mutex, except for nRef and pNext which are accessed under the\n** global SQLITE_MUTEX_STATIC_MASTER mutex.  The pPager field\n** may not be modified once it is initially set as long as nRef>0.\n** The pSchema field may be set once under BtShared.mutex and\n** thereafter is unchanged as long as nRef>0.\n**\n** isPending:\n**\n**   If a BtShared client fails to obtain a write-lock on a database\n**   table (because there exists one or more read-locks on the table),\n**   the shared-cache enters 'pending-lock' state and isPending is\n**   set to true.\n**\n**   The shared-cache leaves the 'pending lock' state when either of\n**   the following occur:\n**\n**     1) The current writer (BtShared.pWriter) concludes its transaction, OR\n**     2) The number of locks held by other connections drops to zero.\n**\n**   while in the 'pending-lock' state, no connection may start a new\n**   transaction.\n**\n**   This feature is included to help prevent writer-starvation.\n*/\nstruct BtShared {\n  Pager *pPager;        /* The page cache */\n  sqlite3 *db;          /* Database connection currently using this Btree */\n  BtCursor *pCursor;    /* A list of all open cursors */\n  MemPage *pPage1;      /* First page of the database */\n  u8 openFlags;         /* Flags to sqlite3BtreeOpen() */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  u8 autoVacuum;        /* True if auto-vacuum is enabled */\n  u8 incrVacuum;        /* True if incr-vacuum is enabled */\n  u8 bDoTruncate;       /* True to truncate db on commit */\n#endif\n  u8 inTransaction;     /* Transaction state */\n  u8 max1bytePayload;   /* Maximum first byte of cell for a 1-byte payload */\n#ifdef SQLITE_HAS_CODEC\n  u8 optimalReserve;    /* Desired amount of reserved space per page */\n#endif\n  u16 btsFlags;         /* Boolean parameters.  See BTS_* macros below */\n  u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */\n  u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */\n  u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */\n  u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */\n  u32 pageSize;         /* Total number of bytes on a page */\n  u32 usableSize;       /* Number of usable bytes on each page */\n  int nTransaction;     /* Number of open transactions (read + write) */\n  u32 nPage;            /* Number of pages in the database */\n  void *pSchema;        /* Pointer to space allocated by sqlite3BtreeSchema() */\n  void (*xFreeSchema)(void*);  /* Destructor for BtShared.pSchema */\n  sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */\n  Bitvec *pHasContent;  /* Set of pages moved to free-list this transaction */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nRef;             /* Number of references to this structure */\n  BtShared *pNext;      /* Next on a list of sharable BtShared structs */\n  BtLock *pLock;        /* List of locks held on this shared-btree struct */\n  Btree *pWriter;       /* Btree with currently open write transaction */\n#endif\n  u8 *pTmpSpace;        /* Temp space sufficient to hold a single cell */\n};\n\n/*\n** Allowed values for BtShared.btsFlags\n*/\n#define BTS_READ_ONLY        0x0001   /* Underlying file is readonly */\n#define BTS_PAGESIZE_FIXED   0x0002   /* Page size can no longer be changed */\n#define BTS_SECURE_DELETE    0x0004   /* PRAGMA secure_delete is enabled */\n#define BTS_OVERWRITE        0x0008   /* Overwrite deleted content with zeros */\n#define BTS_FAST_SECURE      0x000c   /* Combination of the previous two */\n#define BTS_INITIALLY_EMPTY  0x0010   /* Database was empty at trans start */\n#define BTS_NO_WAL           0x0020   /* Do not open write-ahead-log files */\n#define BTS_EXCLUSIVE        0x0040   /* pWriter has an exclusive lock */\n#define BTS_PENDING          0x0080   /* Waiting for read-locks to clear */\n\n/*\n** An instance of the following structure is used to hold information\n** about a cell.  The parseCellPtr() function fills in this structure\n** based on information extract from the raw disk page.\n*/\nstruct CellInfo {\n  i64 nKey;      /* The key for INTKEY tables, or nPayload otherwise */\n  u8 *pPayload;  /* Pointer to the start of payload */\n  u32 nPayload;  /* Bytes of payload */\n  u16 nLocal;    /* Amount of payload held locally, not on overflow */\n  u16 nSize;     /* Size of the cell content on the main b-tree page */\n};\n\n/*\n** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than\n** this will be declared corrupt. This value is calculated based on a\n** maximum database size of 2^31 pages a minimum fanout of 2 for a\n** root-node and 3 for all other internal nodes.\n**\n** If a tree that appears to be taller than this is encountered, it is\n** assumed that the database is corrupt.\n*/\n#define BTCURSOR_MAX_DEPTH 20\n\n/*\n** A cursor is a pointer to a particular entry within a particular\n** b-tree within a database file.\n**\n** The entry is identified by its MemPage and the index in\n** MemPage.aCell[] of the entry.\n**\n** A single database file can be shared by two more database connections,\n** but cursors cannot be shared.  Each cursor is associated with a\n** particular database connection identified BtCursor.pBtree.db.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** found at self->pBt->mutex. \n**\n** skipNext meaning:\n**    eState==SKIPNEXT && skipNext>0:  Next sqlite3BtreeNext() is no-op.\n**    eState==SKIPNEXT && skipNext<0:  Next sqlite3BtreePrevious() is no-op.\n**    eState==FAULT:                   Cursor fault with skipNext as error code.\n*/\nstruct BtCursor {\n  u8 eState;                /* One of the CURSOR_XXX constants (see below) */\n  u8 curFlags;              /* zero or more BTCF_* flags defined below */\n  u8 curPagerFlags;         /* Flags to send to sqlite3PagerGet() */\n  u8 hints;                 /* As configured by CursorSetHints() */\n  int nOvflAlloc;           /* Allocated size of aOverflow[] array */\n  Btree *pBtree;            /* The Btree to which this cursor belongs */\n  BtShared *pBt;            /* The BtShared this cursor points to */\n  BtCursor *pNext;          /* Forms a linked list of all cursors */\n  Pgno *aOverflow;          /* Cache of overflow page locations */\n  CellInfo info;            /* A parse of the cell we are pointing at */\n  i64 nKey;                 /* Size of pKey, or last integer key */\n  void *pKey;               /* Saved key that was cursor last known position */\n  Pgno pgnoRoot;            /* The root page of this tree */\n  int skipNext;    /* Prev() is noop if negative. Next() is noop if positive.\n                   ** Error code if eState==CURSOR_FAULT */\n  /* All fields above are zeroed when the cursor is allocated.  See\n  ** sqlite3BtreeCursorZero().  Fields that follow must be manually\n  ** initialized. */\n  i8 iPage;                 /* Index of current page in apPage */\n  u8 curIntKey;             /* Value of apPage[0]->intKey */\n  u16 ix;                   /* Current index for apPage[iPage] */\n  u16 aiIdx[BTCURSOR_MAX_DEPTH-1];     /* Current index in apPage[i] */\n  struct KeyInfo *pKeyInfo;            /* Arg passed to comparison function */\n  MemPage *pPage;                        /* Current page */\n  MemPage *apPage[BTCURSOR_MAX_DEPTH-1]; /* Stack of parents of current page */\n};\n\n/*\n** Legal values for BtCursor.curFlags\n*/\n#define BTCF_WriteFlag    0x01   /* True if a write cursor */\n#define BTCF_ValidNKey    0x02   /* True if info.nKey is valid */\n#define BTCF_ValidOvfl    0x04   /* True if aOverflow is valid */\n#define BTCF_AtLast       0x08   /* Cursor is pointing ot the last entry */\n#define BTCF_Incrblob     0x10   /* True if an incremental I/O handle */\n#define BTCF_Multiple     0x20   /* Maybe another cursor on the same btree */\n\n/*\n** Potential values for BtCursor.eState.\n**\n** CURSOR_INVALID:\n**   Cursor does not point to a valid entry. This can happen (for example) \n**   because the table is empty or because BtreeCursorFirst() has not been\n**   called.\n**\n** CURSOR_VALID:\n**   Cursor points to a valid entry. getPayload() etc. may be called.\n**\n** CURSOR_SKIPNEXT:\n**   Cursor is valid except that the Cursor.skipNext field is non-zero\n**   indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious()\n**   operation should be a no-op.\n**\n** CURSOR_REQUIRESEEK:\n**   The table that this cursor was opened on still exists, but has been \n**   modified since the cursor was last used. The cursor position is saved\n**   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in \n**   this state, restoreCursorPosition() can be called to attempt to\n**   seek the cursor to the saved position.\n**\n** CURSOR_FAULT:\n**   An unrecoverable error (an I/O error or a malloc failure) has occurred\n**   on a different connection that shares the BtShared cache with this\n**   cursor.  The error has left the cache in an inconsistent state.\n**   Do nothing else with this cursor.  Any attempt to use the cursor\n**   should return the error code stored in BtCursor.skipNext\n*/\n#define CURSOR_INVALID           0\n#define CURSOR_VALID             1\n#define CURSOR_SKIPNEXT          2\n#define CURSOR_REQUIRESEEK       3\n#define CURSOR_FAULT             4\n\n/* \n** The database page the PENDING_BYTE occupies. This page is never used.\n*/\n# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)\n\n/*\n** These macros define the location of the pointer-map entry for a \n** database page. The first argument to each is the number of usable\n** bytes on each page of the database (often 1024). The second is the\n** page number to look up in the pointer map.\n**\n** PTRMAP_PAGENO returns the database page number of the pointer-map\n** page that stores the required pointer. PTRMAP_PTROFFSET returns\n** the offset of the requested map entry.\n**\n** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,\n** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be\n** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements\n** this test.\n*/\n#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)\n#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1))\n#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno))\n\n/*\n** The pointer map is a lookup table that identifies the parent page for\n** each child page in the database file.  The parent page is the page that\n** contains a pointer to the child.  Every page in the database contains\n** 0 or 1 parent pages.  (In this context 'database page' refers\n** to any page that is not part of the pointer map itself.)  Each pointer map\n** entry consists of a single byte 'type' and a 4 byte parent page number.\n** The PTRMAP_XXX identifiers below are the valid types.\n**\n** The purpose of the pointer map is to facility moving pages from one\n** position in the file to another as part of autovacuum.  When a page\n** is moved, the pointer in its parent must be updated to point to the\n** new location.  The pointer map is used to locate the parent page quickly.\n**\n** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not\n**                  used in this case.\n**\n** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number \n**                  is not used in this case.\n**\n** PTRMAP_OVERFLOW1: The database page is the first page in a list of \n**                   overflow pages. The page number identifies the page that\n**                   contains the cell with a pointer to this overflow page.\n**\n** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of\n**                   overflow pages. The page-number identifies the previous\n**                   page in the overflow page list.\n**\n** PTRMAP_BTREE: The database page is a non-root btree page. The page number\n**               identifies the parent page in the btree.\n*/\n#define PTRMAP_ROOTPAGE 1\n#define PTRMAP_FREEPAGE 2\n#define PTRMAP_OVERFLOW1 3\n#define PTRMAP_OVERFLOW2 4\n#define PTRMAP_BTREE 5\n\n/* A bunch of assert() statements to check the transaction state variables\n** of handle p (type Btree*) are internally consistent.\n*/\n#define btreeIntegrity(p) \\\n  assert( p->pBt->inTransaction!=TRANS_NONE || p->pBt->nTransaction==0 ); \\\n  assert( p->pBt->inTransaction>=p->inTrans ); \n\n\n/*\n** The ISAUTOVACUUM macro is used within balance_nonroot() to determine\n** if the database supports auto-vacuum or not. Because it is used\n** within an expression that is an argument to another macro \n** (sqliteMallocRaw), it is not possible to use conditional compilation.\n** So, this macro is defined instead.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define ISAUTOVACUUM (pBt->autoVacuum)\n#else\n#define ISAUTOVACUUM 0\n#endif\n\n\n/*\n** This structure is passed around through all the sanity checking routines\n** in order to keep track of some global state information.\n**\n** The aRef[] array is allocated so that there is 1 bit for each page in\n** the database. As the integrity-check proceeds, for each page used in\n** the database the corresponding bit is set. This allows integrity-check to \n** detect pages that are used twice and orphaned pages (both of which \n** indicate corruption).\n*/\ntypedef struct IntegrityCk IntegrityCk;\nstruct IntegrityCk {\n  BtShared *pBt;    /* The tree being checked out */\n  Pager *pPager;    /* The associated pager.  Also accessible by pBt->pPager */\n  u8 *aPgRef;       /* 1 bit per page in the db (see above) */\n  Pgno nPage;       /* Number of pages in the database */\n  int mxErr;        /* Stop accumulating errors when this reaches zero */\n  int nErr;         /* Number of messages written to zErrMsg so far */\n  int mallocFailed; /* A memory allocation error has occurred */\n  const char *zPfx; /* Error message prefix */\n  int v1, v2;       /* Values for up to two %d fields in zPfx */\n  StrAccum errMsg;  /* Accumulate the error message text here */\n  u32 *heap;        /* Min-heap used for analyzing cell coverage */\n};\n\n/*\n** Routines to read or write a two- and four-byte big-endian integer values.\n*/\n#define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))\n#define get4byte sqlite3Get4byte\n#define put4byte sqlite3Put4byte\n\n/*\n** get2byteAligned(), unlike get2byte(), requires that its argument point to a\n** two-byte aligned address.  get2bytea() is only used for accessing the\n** cell addresses in a btree header.\n*/\n#if SQLITE_BYTEORDER==4321\n# define get2byteAligned(x)  (*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000\n# define get2byteAligned(x)  __builtin_bswap16(*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n# define get2byteAligned(x)  _byteswap_ushort(*(u16*)(x))\n#else\n# define get2byteAligned(x)  ((x)[0]<<8 | (x)[1])\n#endif\n\n/************** End of btreeInt.h ********************************************/\n/************** Continuing where we left off in btmutex.c ********************/\n#ifndef SQLITE_OMIT_SHARED_CACHE\n#if SQLITE_THREADSAFE\n\n/*\n** Obtain the BtShared mutex associated with B-Tree handle p. Also,\n** set BtShared.db to the database handle associated with p and the\n** p->locked boolean to true.\n*/\nstatic void lockBtreeMutex(Btree *p){\n  assert( p->locked==0 );\n  assert( sqlite3_mutex_notheld(p->pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  sqlite3_mutex_enter(p->pBt->mutex);\n  p->pBt->db = p->db;\n  p->locked = 1;\n}\n\n/*\n** Release the BtShared mutex associated with B-Tree handle p and\n** clear the p->locked boolean.\n*/\nstatic void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){\n  BtShared *pBt = p->pBt;\n  assert( p->locked==1 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  assert( p->db==pBt->db );\n\n  sqlite3_mutex_leave(pBt->mutex);\n  p->locked = 0;\n}\n\n/* Forward reference */\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p);\n\n/*\n** Enter a mutex on the given BTree object.\n**\n** If the object is not sharable, then no mutex is ever required\n** and this routine is a no-op.  The underlying mutex is non-recursive.\n** But we keep a reference count in Btree.wantToLock so the behavior\n** of this interface is recursive.\n**\n** To avoid deadlocks, multiple Btrees are locked in the same order\n** by all database connections.  The p->pNext is a list of other\n** Btrees belonging to the same database connection as the p Btree\n** which need to be locked after p.  If we cannot get a lock on\n** p, then first unlock all of the others on p->pNext, then wait\n** for the lock to become available on p, then relock all of the\n** subsequent Btrees that desire a lock.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  /* Some basic sanity checking on the Btree.  The list of Btrees\n  ** connected by pNext and pPrev should be in sorted order by\n  ** Btree.pBt value. All elements of the list should belong to\n  ** the same connection. Only shared Btrees are on the list. */\n  assert( p->pNext==0 || p->pNext->pBt>p->pBt );\n  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );\n  assert( p->pNext==0 || p->pNext->db==p->db );\n  assert( p->pPrev==0 || p->pPrev->db==p->db );\n  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );\n\n  /* Check for locking consistency */\n  assert( !p->locked || p->wantToLock>0 );\n  assert( p->sharable || p->wantToLock==0 );\n\n  /* We should already hold a lock on the database connection */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  /* Unless the database is sharable and unlocked, then BtShared.db\n  ** should already be set correctly. */\n  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );\n\n  if( !p->sharable ) return;\n  p->wantToLock++;\n  if( p->locked ) return;\n  btreeLockCarefully(p);\n}\n\n/* This is a helper function for sqlite3BtreeLock(). By moving\n** complex, but seldom used logic, out of sqlite3BtreeLock() and\n** into this routine, we avoid unnecessary stack pointer changes\n** and thus help the sqlite3BtreeLock() routine to run much faster\n** in the common case.\n*/\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p){\n  Btree *pLater;\n\n  /* In most cases, we should be able to acquire the lock we\n  ** want without having to go through the ascending lock\n  ** procedure that follows.  Just be sure not to block.\n  */\n  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){\n    p->pBt->db = p->db;\n    p->locked = 1;\n    return;\n  }\n\n  /* To avoid deadlock, first release all locks with a larger\n  ** BtShared address.  Then acquire our lock.  Then reacquire\n  ** the other BtShared locks that we used to hold in ascending\n  ** order.\n  */\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    assert( pLater->sharable );\n    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );\n    assert( !pLater->locked || pLater->wantToLock>0 );\n    if( pLater->locked ){\n      unlockBtreeMutex(pLater);\n    }\n  }\n  lockBtreeMutex(p);\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    if( pLater->wantToLock ){\n      lockBtreeMutex(pLater);\n    }\n  }\n}\n\n\n/*\n** Exit the recursive mutex on a Btree.\n*/\nSQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  if( p->sharable ){\n    assert( p->wantToLock>0 );\n    p->wantToLock--;\n    if( p->wantToLock==0 ){\n      unlockBtreeMutex(p);\n    }\n  }\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the BtShared mutex is held on the btree, or if the\n** B-Tree is not marked as sharable.\n**\n** This routine is used only from within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree *p){\n  assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );\n  assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );\n\n  return (p->sharable==0 || p->locked);\n}\n#endif\n\n\n/*\n** Enter the mutex on every Btree associated with a database\n** connection.  This is needed (for example) prior to parsing\n** a statement since we will be comparing table and column names\n** against all schemas and we do not want those schemas being\n** reset out from under us.\n**\n** There is a corresponding leave-all procedures.\n**\n** Enter the mutexes in accending order by BtShared pointer address\n** to avoid the possibility of deadlock when two threads with\n** two or more btrees in common both try to lock all their btrees\n** at the same instant.\n*/\nstatic void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){\n  int i;\n  int skipOk = 1;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p && p->sharable ){\n      sqlite3BtreeEnter(p);\n      skipOk = 0;\n    }\n  }\n  db->skipBtreeMutex = skipOk;\n}\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  if( db->skipBtreeMutex==0 ) btreeEnterAll(db);\n}\nstatic void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){\n  int i;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p ) sqlite3BtreeLeave(p);\n  }\n}\nSQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){\n  if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the current thread holds the database connection\n** mutex and all required BtShared mutexes.\n**\n** This routine is used inside assert() statements only.\n*/\nSQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3 *db){\n  int i;\n  if( !sqlite3_mutex_held(db->mutex) ){\n    return 0;\n  }\n  for(i=0; i<db->nDb; i++){\n    Btree *p;\n    p = db->aDb[i].pBt;\n    if( p && p->sharable &&\n         (p->wantToLock==0 || !sqlite3_mutex_held(p->pBt->mutex)) ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/*\n** Return true if the correct mutexes are held for accessing the\n** db->aDb[iDb].pSchema structure.  The mutexes required for schema\n** access are:\n**\n**   (1) The mutex on db\n**   (2) if iDb!=1, then the mutex on db->aDb[iDb].pBt.\n**\n** If pSchema is not NULL, then iDb is computed from pSchema and\n** db using sqlite3SchemaToIndex().\n*/\nSQLITE_PRIVATE int sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){\n  Btree *p;\n  assert( db!=0 );\n  if( pSchema ) iDb = sqlite3SchemaToIndex(db, pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  if( !sqlite3_mutex_held(db->mutex) ) return 0;\n  if( iDb==1 ) return 1;\n  p = db->aDb[iDb].pBt;\n  assert( p!=0 );\n  return p->sharable==0 || p->locked==1;\n}\n#endif /* NDEBUG */\n\n#else /* SQLITE_THREADSAFE>0 above.  SQLITE_THREADSAFE==0 below */\n/*\n** The following are special cases for mutex enter routines for use\n** in single threaded applications that use shared cache.  Except for\n** these two routines, all mutex operations are no-ops in that case and\n** are null #defines in btree.h.\n**\n** If shared cache is disabled, then all btree mutex routines, including\n** the ones below, are no-ops and are null #defines in btree.h.\n*/\n\nSQLITE_PRIVATE void sqlite3BtreeEnter(Btree *p){\n  p->pBt->db = p->db;\n}\nSQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      p->pBt->db = p->db;\n    }\n  }\n}\n#endif /* if SQLITE_THREADSAFE */\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Enter a mutex on a Btree given a cursor owned by that Btree. \n**\n** These entry points are used by incremental I/O only. Enter() is required \n** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not \n** the build is threadsafe. Leave() is only required by threadsafe builds.\n*/\nSQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor *pCur){\n  sqlite3BtreeEnter(pCur->pBtree);\n}\n# if SQLITE_THREADSAFE\nSQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor *pCur){\n  sqlite3BtreeLeave(pCur->pBtree);\n}\n# endif\n#endif /* ifndef SQLITE_OMIT_INCRBLOB */\n\n#endif /* ifndef SQLITE_OMIT_SHARED_CACHE */\n\n/************** End of btmutex.c *********************************************/\n/************** Begin file btree.c *******************************************/\n/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** See the header comment on \"btreeInt.h\" for additional information.\n** Including a description of file format and an overview of operation.\n*/\n/* #include \"btreeInt.h\" */\n\n/*\n** The header string that appears at the beginning of every\n** SQLite database.\n*/\nstatic const char zMagicHeader[] = SQLITE_FILE_HEADER;\n\n/*\n** Set this global variable to 1 to enable tracing using the TRACE\n** macro.\n*/\n#if 0\nint sqlite3BtreeTrace=1;  /* True to enable tracing */\n# define TRACE(X)  if(sqlite3BtreeTrace){printf X;fflush(stdout);}\n#else\n# define TRACE(X)\n#endif\n\n/*\n** Extract a 2-byte big-endian integer from an array of unsigned bytes.\n** But if the value is zero, make it 65536.\n**\n** This routine is used to extract the \"offset to cell content area\" value\n** from the header of a btree page.  If the page size is 65536 and the page\n** is empty, the offset should be 65536, but the 2-byte value stores zero.\n** This routine makes the necessary adjustment to 65536.\n*/\n#define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)\n\n/*\n** Values passed as the 5th argument to allocateBtreePage()\n*/\n#define BTALLOC_ANY   0           /* Allocate any page */\n#define BTALLOC_EXACT 1           /* Allocate exact page if possible */\n#define BTALLOC_LE    2           /* Allocate any page <= the parameter */\n\n/*\n** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not \n** defined, or 0 if it is. For example:\n**\n**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define IfNotOmitAV(expr) (expr)\n#else\n#define IfNotOmitAV(expr) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** A list of BtShared objects that are eligible for participation\n** in shared cache.  This variable has file scope during normal builds,\n** but the test harness needs to access it so we make it global for \n** test builds.\n**\n** Access to this variable is protected by SQLITE_MUTEX_STATIC_MASTER.\n*/\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#else\nstatic BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#endif\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Enable or disable the shared pager and schema features.\n**\n** This routine has no effect on existing database connections.\n** The shared cache setting effects only future calls to\n** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int enable){\n  sqlite3GlobalConfig.sharedCacheEnabled = enable;\n  return SQLITE_OK;\n}\n#endif\n\n\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n  /*\n  ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(),\n  ** and clearAllSharedCacheTableLocks()\n  ** manipulate entries in the BtShared.pLock linked list used to store\n  ** shared-cache table level locks. If the library is compiled with the\n  ** shared-cache feature disabled, then there is only ever one user\n  ** of each BtShared structure and so this locking is not necessary. \n  ** So define the lock related functions as no-ops.\n  */\n  #define querySharedCacheTableLock(a,b,c) SQLITE_OK\n  #define setSharedCacheTableLock(a,b,c) SQLITE_OK\n  #define clearAllSharedCacheTableLocks(a)\n  #define downgradeAllSharedCacheTableLocks(a)\n  #define hasSharedCacheTableLock(a,b,c,d) 1\n  #define hasReadConflicts(a, b) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function is only used as part of an assert() statement. ***\n**\n** Check to see if pBtree holds the required locks to read or write to the \n** table with root page iRoot.   Return 1 if it does and 0 if not.\n**\n** For example, when writing to a table with root-page iRoot via \n** Btree connection pBtree:\n**\n**    assert( hasSharedCacheTableLock(pBtree, iRoot, 0, WRITE_LOCK) );\n**\n** When writing to an index that resides in a sharable database, the \n** caller should have first obtained a lock specifying the root page of\n** the corresponding table. This makes things a bit more complicated,\n** as this module treats each table as a separate structure. To determine\n** the table corresponding to the index being written, this\n** function has to search through the database schema.\n**\n** Instead of a lock on the table/index rooted at page iRoot, the caller may\n** hold a write-lock on the schema table (root page 1). This is also\n** acceptable.\n*/\nstatic int hasSharedCacheTableLock(\n  Btree *pBtree,         /* Handle that must hold lock */\n  Pgno iRoot,            /* Root page of b-tree */\n  int isIndex,           /* True if iRoot is the root of an index b-tree */\n  int eLockType          /* Required lock type (READ_LOCK or WRITE_LOCK) */\n){\n  Schema *pSchema = (Schema *)pBtree->pBt->pSchema;\n  Pgno iTab = 0;\n  BtLock *pLock;\n\n  /* If this database is not shareable, or if the client is reading\n  ** and has the read-uncommitted flag set, then no lock is required. \n  ** Return true immediately.\n  */\n  if( (pBtree->sharable==0)\n   || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))\n  ){\n    return 1;\n  }\n\n  /* If the client is reading  or writing an index and the schema is\n  ** not loaded, then it is too difficult to actually check to see if\n  ** the correct locks are held.  So do not bother - just return true.\n  ** This case does not come up very often anyhow.\n  */\n  if( isIndex && (!pSchema || (pSchema->schemaFlags&DB_SchemaLoaded)==0) ){\n    return 1;\n  }\n\n  /* Figure out the root-page that the lock should be held on. For table\n  ** b-trees, this is just the root page of the b-tree being read or\n  ** written. For index b-trees, it is the root page of the associated\n  ** table.  */\n  if( isIndex ){\n    HashElem *p;\n    for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){\n      Index *pIdx = (Index *)sqliteHashData(p);\n      if( pIdx->tnum==(int)iRoot ){\n        if( iTab ){\n          /* Two or more indexes share the same root page.  There must\n          ** be imposter tables.  So just return true.  The assert is not\n          ** useful in that case. */\n          return 1;\n        }\n        iTab = pIdx->pTable->tnum;\n      }\n    }\n  }else{\n    iTab = iRoot;\n  }\n\n  /* Search for the required lock. Either a write-lock on root-page iTab, a \n  ** write-lock on the schema table, or (if the client is reading) a\n  ** read-lock on iTab will suffice. Return 1 if any of these are found.  */\n  for(pLock=pBtree->pBt->pLock; pLock; pLock=pLock->pNext){\n    if( pLock->pBtree==pBtree \n     && (pLock->iTable==iTab || (pLock->eLock==WRITE_LOCK && pLock->iTable==1))\n     && pLock->eLock>=eLockType \n    ){\n      return 1;\n    }\n  }\n\n  /* Failed to find the required lock. */\n  return 0;\n}\n#endif /* SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function may be used as part of assert() statements only. ****\n**\n** Return true if it would be illegal for pBtree to write into the\n** table or index rooted at iRoot because other shared connections are\n** simultaneously reading that same table or index.\n**\n** It is illegal for pBtree to write if some other Btree object that\n** shares the same BtShared object is currently reading or writing\n** the iRoot table.  Except, if the other Btree object has the\n** read-uncommitted flag set, then it is OK for the other object to\n** have a read cursor.\n**\n** For example, before writing to any part of the table or index\n** rooted at page iRoot, one should call:\n**\n**    assert( !hasReadConflicts(pBtree, iRoot) );\n*/\nstatic int hasReadConflicts(Btree *pBtree, Pgno iRoot){\n  BtCursor *p;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( p->pgnoRoot==iRoot \n     && p->pBtree!=pBtree\n     && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif    /* #ifdef SQLITE_DEBUG */\n\n/*\n** Query to see if Btree handle p may obtain a lock of type eLock \n** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return\n** SQLITE_OK if the lock may be obtained (by calling\n** setSharedCacheTableLock()), or SQLITE_LOCKED if not.\n*/\nstatic int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n  assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );\n  \n  /* If requesting a write-lock, then the Btree must have an open write\n  ** transaction on this file. And, obviously, for this to be so there \n  ** must be an open write transaction on the file itself.\n  */\n  assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );\n  assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );\n  \n  /* This routine is a no-op if the shared-cache is not enabled */\n  if( !p->sharable ){\n    return SQLITE_OK;\n  }\n\n  /* If some other connection is holding an exclusive lock, the\n  ** requested lock may not be obtained.\n  */\n  if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){\n    sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);\n    return SQLITE_LOCKED_SHAREDCACHE;\n  }\n\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    /* The condition (pIter->eLock!=eLock) in the following if(...) \n    ** statement is a simplification of:\n    **\n    **   (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)\n    **\n    ** since we know that if eLock==WRITE_LOCK, then no other connection\n    ** may hold a WRITE_LOCK on any table in this file (since there can\n    ** only be a single writer).\n    */\n    assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );\n    assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);\n    if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){\n      sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);\n      if( eLock==WRITE_LOCK ){\n        assert( p==pBt->pWriter );\n        pBt->btsFlags |= BTS_PENDING;\n      }\n      return SQLITE_LOCKED_SHAREDCACHE;\n    }\n  }\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Add a lock on the table with root-page iTable to the shared-btree used\n** by Btree handle p. Parameter eLock must be either READ_LOCK or \n** WRITE_LOCK.\n**\n** This function assumes the following:\n**\n**   (a) The specified Btree object p is connected to a sharable\n**       database (one with the BtShared.sharable flag set), and\n**\n**   (b) No other Btree objects hold a lock that conflicts\n**       with the requested lock (i.e. querySharedCacheTableLock() has\n**       already been called and returned SQLITE_OK).\n**\n** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM \n** is returned if a malloc attempt fails.\n*/\nstatic int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pLock = 0;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n\n  /* A connection with the read-uncommitted flag set will never try to\n  ** obtain a read-lock using this function. The only read-lock obtained\n  ** by a connection in read-uncommitted mode is on the sqlite_master \n  ** table, and that lock is obtained in BtreeBeginTrans().  */\n  assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );\n\n  /* This function should only be called on a sharable b-tree after it \n  ** has been determined that no other b-tree holds a conflicting lock.  */\n  assert( p->sharable );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );\n\n  /* First search the list for an existing lock on this table. */\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    if( pIter->iTable==iTable && pIter->pBtree==p ){\n      pLock = pIter;\n      break;\n    }\n  }\n\n  /* If the above search did not find a BtLock struct associating Btree p\n  ** with table iTable, allocate one and link it into the list.\n  */\n  if( !pLock ){\n    pLock = (BtLock *)sqlite3MallocZero(sizeof(BtLock));\n    if( !pLock ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pLock->iTable = iTable;\n    pLock->pBtree = p;\n    pLock->pNext = pBt->pLock;\n    pBt->pLock = pLock;\n  }\n\n  /* Set the BtLock.eLock variable to the maximum of the current lock\n  ** and the requested lock. This means if a write-lock was already held\n  ** and a read-lock requested, we don't incorrectly downgrade the lock.\n  */\n  assert( WRITE_LOCK>READ_LOCK );\n  if( eLock>pLock->eLock ){\n    pLock->eLock = eLock;\n  }\n\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Release all the table locks (locks obtained via calls to\n** the setSharedCacheTableLock() procedure) held by Btree object p.\n**\n** This function assumes that Btree p has an open read or write \n** transaction. If it does not, then the BTS_PENDING flag\n** may be incorrectly cleared.\n*/\nstatic void clearAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtLock **ppIter = &pBt->pLock;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->sharable || 0==*ppIter );\n  assert( p->inTrans>0 );\n\n  while( *ppIter ){\n    BtLock *pLock = *ppIter;\n    assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );\n    assert( pLock->pBtree->inTrans>=pLock->eLock );\n    if( pLock->pBtree==p ){\n      *ppIter = pLock->pNext;\n      assert( pLock->iTable!=1 || pLock==&p->lock );\n      if( pLock->iTable!=1 ){\n        sqlite3_free(pLock);\n      }\n    }else{\n      ppIter = &pLock->pNext;\n    }\n  }\n\n  assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );\n  if( pBt->pWriter==p ){\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n  }else if( pBt->nTransaction==2 ){\n    /* This function is called when Btree p is concluding its \n    ** transaction. If there currently exists a writer, and p is not\n    ** that writer, then the number of locks held by connections other\n    ** than the writer must be about to drop to zero. In this case\n    ** set the BTS_PENDING flag to 0.\n    **\n    ** If there is not currently a writer, then BTS_PENDING must\n    ** be zero already. So this next line is harmless in that case.\n    */\n    pBt->btsFlags &= ~BTS_PENDING;\n  }\n}\n\n/*\n** This function changes all write-locks held by Btree p into read-locks.\n*/\nstatic void downgradeAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  if( pBt->pWriter==p ){\n    BtLock *pLock;\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n    for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){\n      assert( pLock->eLock==READ_LOCK || pLock->pBtree==p );\n      pLock->eLock = READ_LOCK;\n    }\n  }\n}\n\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\nstatic void releasePage(MemPage *pPage);         /* Forward reference */\nstatic void releasePageOne(MemPage *pPage);      /* Forward reference */\nstatic void releasePageNotNull(MemPage *pPage);  /* Forward reference */\n\n/*\n***** This routine is used inside of assert() only ****\n**\n** Verify that the cursor holds the mutex on its BtShared\n*/\n#ifdef SQLITE_DEBUG\nstatic int cursorHoldsMutex(BtCursor *p){\n  return sqlite3_mutex_held(p->pBt->mutex);\n}\n\n/* Verify that the cursor and the BtShared agree about what is the current\n** database connetion. This is important in shared-cache mode. If the database \n** connection pointers get out-of-sync, it is possible for routines like\n** btreeInitPage() to reference an stale connection pointer that references a\n** a connection that has already closed.  This routine is used inside assert()\n** statements only and for the purpose of double-checking that the btree code\n** does keep the database connection pointers up-to-date.\n*/\nstatic int cursorOwnsBtShared(BtCursor *p){\n  assert( cursorHoldsMutex(p) );\n  return (p->pBtree->db==p->pBt->db);\n}\n#endif\n\n/*\n** Invalidate the overflow cache of the cursor passed as the first argument.\n** on the shared btree structure pBt.\n*/\n#define invalidateOverflowCache(pCur) (pCur->curFlags &= ~BTCF_ValidOvfl)\n\n/*\n** Invalidate the overflow page-list cache for all cursors opened\n** on the shared btree structure pBt.\n*/\nstatic void invalidateAllOverflowCache(BtShared *pBt){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    invalidateOverflowCache(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** This function is called before modifying the contents of a table\n** to invalidate any incrblob cursors that are open on the\n** row or one of the rows being modified.\n**\n** If argument isClearTable is true, then the entire contents of the\n** table is about to be deleted. In this case invalidate all incrblob\n** cursors open on any row within the table with root-page pgnoRoot.\n**\n** Otherwise, if argument isClearTable is false, then the row with\n** rowid iRow is being replaced or deleted. In this case invalidate\n** only those incrblob cursors open on that specific row.\n*/\nstatic void invalidateIncrblobCursors(\n  Btree *pBtree,          /* The database file to check */\n  Pgno pgnoRoot,          /* The table that might be changing */\n  i64 iRow,               /* The rowid that might be changing */\n  int isClearTable        /* True if all rows are being deleted */\n){\n  BtCursor *p;\n  if( pBtree->hasIncrblobCur==0 ) return;\n  assert( sqlite3BtreeHoldsMutex(pBtree) );\n  pBtree->hasIncrblobCur = 0;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( (p->curFlags & BTCF_Incrblob)!=0 ){\n      pBtree->hasIncrblobCur = 1;\n      if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){\n        p->eState = CURSOR_INVALID;\n      }\n    }\n  }\n}\n\n#else\n  /* Stub function when INCRBLOB is omitted */\n  #define invalidateIncrblobCursors(w,x,y,z)\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Set bit pgno of the BtShared.pHasContent bitvec. This is called \n** when a page that previously contained data becomes a free-list leaf \n** page.\n**\n** The BtShared.pHasContent bitvec exists to work around an obscure\n** bug caused by the interaction of two useful IO optimizations surrounding\n** free-list leaf pages:\n**\n**   1) When all data is deleted from a page and the page becomes\n**      a free-list leaf page, the page is not written to the database\n**      (as free-list leaf pages contain no meaningful data). Sometimes\n**      such a page is not even journalled (as it will not be modified,\n**      why bother journalling it?).\n**\n**   2) When a free-list leaf page is reused, its content is not read\n**      from the database or written to the journal file (why should it\n**      be, if it is not at all meaningful?).\n**\n** By themselves, these optimizations work fine and provide a handy\n** performance boost to bulk delete or insert operations. However, if\n** a page is moved to the free-list and then reused within the same\n** transaction, a problem comes up. If the page is not journalled when\n** it is moved to the free-list and it is also not journalled when it\n** is extracted from the free-list and reused, then the original data\n** may be lost. In the event of a rollback, it may not be possible\n** to restore the database to its original configuration.\n**\n** The solution is the BtShared.pHasContent bitvec. Whenever a page is \n** moved to become a free-list leaf page, the corresponding bit is\n** set in the bitvec. Whenever a leaf page is extracted from the free-list,\n** optimization 2 above is omitted if the corresponding bit is already\n** set in BtShared.pHasContent. The contents of the bitvec are cleared\n** at the end of every transaction.\n*/\nstatic int btreeSetHasContent(BtShared *pBt, Pgno pgno){\n  int rc = SQLITE_OK;\n  if( !pBt->pHasContent ){\n    assert( pgno<=pBt->nPage );\n    pBt->pHasContent = sqlite3BitvecCreate(pBt->nPage);\n    if( !pBt->pHasContent ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){\n    rc = sqlite3BitvecSet(pBt->pHasContent, pgno);\n  }\n  return rc;\n}\n\n/*\n** Query the BtShared.pHasContent vector.\n**\n** This function is called when a free-list leaf page is removed from the\n** free-list for reuse. It returns false if it is safe to retrieve the\n** page from the pager layer with the 'no-content' flag set. True otherwise.\n*/\nstatic int btreeGetHasContent(BtShared *pBt, Pgno pgno){\n  Bitvec *p = pBt->pHasContent;\n  return (p && (pgno>sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno)));\n}\n\n/*\n** Clear (destroy) the BtShared.pHasContent bitvec. This should be\n** invoked at the conclusion of each write-transaction.\n*/\nstatic void btreeClearHasContent(BtShared *pBt){\n  sqlite3BitvecDestroy(pBt->pHasContent);\n  pBt->pHasContent = 0;\n}\n\n/*\n** Release all of the apPage[] pages for a cursor.\n*/\nstatic void btreeReleaseAllCursorPages(BtCursor *pCur){\n  int i;\n  if( pCur->iPage>=0 ){\n    for(i=0; i<pCur->iPage; i++){\n      releasePageNotNull(pCur->apPage[i]);\n    }\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage = -1;\n  }\n}\n\n/*\n** The cursor passed as the only argument must point to a valid entry\n** when this function is called (i.e. have eState==CURSOR_VALID). This\n** function saves the current cursor key in variables pCur->nKey and\n** pCur->pKey. SQLITE_OK is returned if successful or an SQLite error \n** code otherwise.\n**\n** If the cursor is open on an intkey table, then the integer key\n** (the rowid) is stored in pCur->nKey and pCur->pKey is left set to\n** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is \n** set to point to a malloced buffer pCur->nKey bytes in size containing \n** the key.\n*/\nstatic int saveCursorKey(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  assert( CURSOR_VALID==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->curIntKey ){\n    /* Only the rowid is required for a table btree */\n    pCur->nKey = sqlite3BtreeIntegerKey(pCur);\n  }else{\n    /* For an index btree, save the complete key content */\n    void *pKey;\n    pCur->nKey = sqlite3BtreePayloadSize(pCur);\n    pKey = sqlite3Malloc( pCur->nKey );\n    if( pKey ){\n      rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);\n      if( rc==SQLITE_OK ){\n        pCur->pKey = pKey;\n      }else{\n        sqlite3_free(pKey);\n      }\n    }else{\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  assert( !pCur->curIntKey || !pCur->pKey );\n  return rc;\n}\n\n/*\n** Save the current cursor position in the variables BtCursor.nKey \n** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.\n**\n** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID)\n** prior to calling this routine.  \n*/\nstatic int saveCursorPosition(BtCursor *pCur){\n  int rc;\n\n  assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->eState==CURSOR_SKIPNEXT ){\n    pCur->eState = CURSOR_VALID;\n  }else{\n    pCur->skipNext = 0;\n  }\n\n  rc = saveCursorKey(pCur);\n  if( rc==SQLITE_OK ){\n    btreeReleaseAllCursorPages(pCur);\n    pCur->eState = CURSOR_REQUIRESEEK;\n  }\n\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl|BTCF_AtLast);\n  return rc;\n}\n\n/* Forward reference */\nstatic int SQLITE_NOINLINE saveCursorsOnList(BtCursor*,Pgno,BtCursor*);\n\n/*\n** Save the positions of all cursors (except pExcept) that are open on\n** the table with root-page iRoot.  \"Saving the cursor position\" means that\n** the location in the btree is remembered in such a way that it can be\n** moved back to the same spot after the btree has been modified.  This\n** routine is called just before cursor pExcept is used to modify the\n** table, for example in BtreeDelete() or BtreeInsert().\n**\n** If there are two or more cursors on the same btree, then all such \n** cursors should have their BTCF_Multiple flag set.  The btreeCursor()\n** routine enforces that rule.  This routine only needs to be called in\n** the uncommon case when pExpect has the BTCF_Multiple flag set.\n**\n** If pExpect!=NULL and if no other cursors are found on the same root-page,\n** then the BTCF_Multiple flag on pExpect is cleared, to avoid another\n** pointless call to this routine.\n**\n** Implementation note:  This routine merely checks to see if any cursors\n** need to be saved.  It calls out to saveCursorsOnList() in the (unusual)\n** event that cursors are in need to being saved.\n*/\nstatic int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pExcept==0 || pExcept->pBt==pBt );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ) break;\n  }\n  if( p ) return saveCursorsOnList(p, iRoot, pExcept);\n  if( pExcept ) pExcept->curFlags &= ~BTCF_Multiple;\n  return SQLITE_OK;\n}\n\n/* This helper routine to saveAllCursors does the actual work of saving\n** the cursors if and when a cursor is found that actually requires saving.\n** The common case is that no cursors need to be saved, so this routine is\n** broken out from its caller to avoid unnecessary stack pointer movement.\n*/\nstatic int SQLITE_NOINLINE saveCursorsOnList(\n  BtCursor *p,         /* The first cursor that needs saving */\n  Pgno iRoot,          /* Only save cursor with this iRoot. Save all if zero */\n  BtCursor *pExcept    /* Do not save this cursor */\n){\n  do{\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){\n      if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n        int rc = saveCursorPosition(p);\n        if( SQLITE_OK!=rc ){\n          return rc;\n        }\n      }else{\n        testcase( p->iPage>=0 );\n        btreeReleaseAllCursorPages(p);\n      }\n    }\n    p = p->pNext;\n  }while( p );\n  return SQLITE_OK;\n}\n\n/*\n** Clear the current cursor position.\n*/\nSQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  sqlite3_free(pCur->pKey);\n  pCur->pKey = 0;\n  pCur->eState = CURSOR_INVALID;\n}\n\n/*\n** In this version of BtreeMoveto, pKey is a packed index record\n** such as is generated by the OP_MakeRecord opcode.  Unpack the\n** record and then call BtreeMovetoUnpacked() to do the work.\n*/\nstatic int btreeMoveto(\n  BtCursor *pCur,     /* Cursor open on the btree to be searched */\n  const void *pKey,   /* Packed key if the btree is an index */\n  i64 nKey,           /* Integer key for tables.  Size of pKey for indices */\n  int bias,           /* Bias search to the high end */\n  int *pRes           /* Write search results here */\n){\n  int rc;                    /* Status code */\n  UnpackedRecord *pIdxKey;   /* Unpacked index key */\n\n  if( pKey ){\n    assert( nKey==(i64)(int)nKey );\n    pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);\n    if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);\n    if( pIdxKey->nField==0 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto moveto_done;\n    }\n  }else{\n    pIdxKey = 0;\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);\nmoveto_done:\n  if( pIdxKey ){\n    sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);\n  }\n  return rc;\n}\n\n/*\n** Restore the cursor to the position it was in (or as close to as possible)\n** when saveCursorPosition() was called. Note that this call deletes the \n** saved position info stored by saveCursorPosition(), so there can be\n** at most one effective restoreCursorPosition() call after each \n** saveCursorPosition().\n*/\nstatic int btreeRestoreCursorPosition(BtCursor *pCur){\n  int rc;\n  int skipNext;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState>=CURSOR_REQUIRESEEK );\n  if( pCur->eState==CURSOR_FAULT ){\n    return pCur->skipNext;\n  }\n  pCur->eState = CURSOR_INVALID;\n  rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);\n  if( rc==SQLITE_OK ){\n    sqlite3_free(pCur->pKey);\n    pCur->pKey = 0;\n    assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );\n    pCur->skipNext |= skipNext;\n    if( pCur->skipNext && pCur->eState==CURSOR_VALID ){\n      pCur->eState = CURSOR_SKIPNEXT;\n    }\n  }\n  return rc;\n}\n\n#define restoreCursorPosition(p) \\\n  (p->eState>=CURSOR_REQUIRESEEK ? \\\n         btreeRestoreCursorPosition(p) : \\\n         SQLITE_OK)\n\n/*\n** Determine whether or not a cursor has moved from the position where\n** it was last placed, or has been invalidated for any other reason.\n** Cursors can move when the row they are pointing at is deleted out\n** from under them, for example.  Cursor might also move if a btree\n** is rebalanced.\n**\n** Calling this routine with a NULL cursor pointer returns false.\n**\n** Use the separate sqlite3BtreeCursorRestore() routine to restore a cursor\n** back to where it ought to be if this routine returns true.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor *pCur){\n  return pCur->eState!=CURSOR_VALID;\n}\n\n/*\n** Return a pointer to a fake BtCursor object that will always answer\n** false to the sqlite3BtreeCursorHasMoved() routine above.  The fake\n** cursor returned must not be used with any other Btree interface.\n*/\nSQLITE_PRIVATE BtCursor *sqlite3BtreeFakeValidCursor(void){\n  static u8 fakeCursor = CURSOR_VALID;\n  assert( offsetof(BtCursor, eState)==0 );\n  return (BtCursor*)&fakeCursor;\n}\n\n/*\n** This routine restores a cursor back to its original position after it\n** has been moved by some outside activity (such as a btree rebalance or\n** a row having been deleted out from under the cursor).  \n**\n** On success, the *pDifferentRow parameter is false if the cursor is left\n** pointing at exactly the same row.  *pDifferntRow is the row the cursor\n** was pointing to has been deleted, forcing the cursor to point to some\n** nearby row.\n**\n** This routine should only be called for a cursor that just returned\n** TRUE from sqlite3BtreeCursorHasMoved().\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){\n  int rc;\n\n  assert( pCur!=0 );\n  assert( pCur->eState!=CURSOR_VALID );\n  rc = restoreCursorPosition(pCur);\n  if( rc ){\n    *pDifferentRow = 1;\n    return rc;\n  }\n  if( pCur->eState!=CURSOR_VALID ){\n    *pDifferentRow = 1;\n  }else{\n    assert( pCur->skipNext==0 );\n    *pDifferentRow = 0;\n  }\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Provide hints to the cursor.  The particular hint given (and the type\n** and number of the varargs parameters) is determined by the eHintType\n** parameter.  See the definitions of the BTREE_HINT_* macros for details.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){\n  /* Used only by system that substitute their own storage engine */\n}\n#endif\n\n/*\n** Provide flag hints to the cursor.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){\n  assert( x==BTREE_SEEK_EQ || x==BTREE_BULKLOAD || x==0 );\n  pCur->hints = x;\n}\n\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Given a page number of a regular database page, return the page\n** number for the pointer-map page that contains the entry for the\n** input page number.\n**\n** Return 0 (not a valid page) for pgno==1 since there is\n** no pointer map associated with page 1.  The integrity_check logic\n** requires that ptrmapPageno(*,1)!=1.\n*/\nstatic Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){\n  int nPagesPerMapPage;\n  Pgno iPtrMap, ret;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno<2 ) return 0;\n  nPagesPerMapPage = (pBt->usableSize/5)+1;\n  iPtrMap = (pgno-2)/nPagesPerMapPage;\n  ret = (iPtrMap*nPagesPerMapPage) + 2; \n  if( ret==PENDING_BYTE_PAGE(pBt) ){\n    ret++;\n  }\n  return ret;\n}\n\n/*\n** Write an entry into the pointer map.\n**\n** This routine updates the pointer map entry for page number 'key'\n** so that it maps to type 'eType' and parent page number 'pgno'.\n**\n** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is\n** a no-op.  If an error occurs, the appropriate error code is written\n** into *pRC.\n*/\nstatic void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){\n  DbPage *pDbPage;  /* The pointer map page */\n  u8 *pPtrmap;      /* The pointer map data */\n  Pgno iPtrmap;     /* The pointer map page number */\n  int offset;       /* Offset in pointer map page */\n  int rc;           /* Return code from subfunctions */\n\n  if( *pRC ) return;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  /* The master-journal page number must never be used as a pointer map page */\n  assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );\n\n  assert( pBt->autoVacuum );\n  if( key==0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=SQLITE_OK ){\n    *pRC = rc;\n    return;\n  }\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    goto ptrmap_exit;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){\n    TRACE((\"PTRMAP_UPDATE: %d->(%d,%d)\\n\", key, eType, parent));\n    *pRC= rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      pPtrmap[offset] = eType;\n      put4byte(&pPtrmap[offset+1], parent);\n    }\n  }\n\nptrmap_exit:\n  sqlite3PagerUnref(pDbPage);\n}\n\n/*\n** Read an entry from the pointer map.\n**\n** This routine retrieves the pointer map entry for page 'key', writing\n** the type and parent page number to *pEType and *pPgno respectively.\n** An error code is returned if something goes wrong, otherwise SQLITE_OK.\n*/\nstatic int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){\n  DbPage *pDbPage;   /* The pointer map page */\n  int iPtrmap;       /* Pointer map page index */\n  u8 *pPtrmap;       /* Pointer map page data */\n  int offset;        /* Offset of entry in pointer map */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=0 ){\n    return rc;\n  }\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    sqlite3PagerUnref(pDbPage);\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  assert( pEType!=0 );\n  *pEType = pPtrmap[offset];\n  if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);\n\n  sqlite3PagerUnref(pDbPage);\n  if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap);\n  return SQLITE_OK;\n}\n\n#else /* if defined SQLITE_OMIT_AUTOVACUUM */\n  #define ptrmapPut(w,x,y,z,rc)\n  #define ptrmapGet(w,x,y,z) SQLITE_OK\n  #define ptrmapPutOvflPtr(x, y, rc)\n#endif\n\n/*\n** Given a btree page and a cell index (0 means the first cell on\n** the page, 1 means the second cell, and so forth) return a pointer\n** to the cell content.\n**\n** findCellPastPtr() does the same except it skips past the initial\n** 4-byte child pointer found on interior pages, if there is one.\n**\n** This routine works only for pages that do not contain overflow cells.\n*/\n#define findCell(P,I) \\\n  ((P)->aData + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n#define findCellPastPtr(P,I) \\\n  ((P)->aDataOfst + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n\n\n/*\n** This is common tail processing for btreeParseCellPtr() and\n** btreeParseCellPtrIndex() for the case when the cell does not fit entirely\n** on a single B-tree page.  Make necessary adjustments to the CellInfo\n** structure.\n*/\nstatic SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  /* If the payload will not fit completely on the local page, we have\n  ** to decide how much to store locally and how much to spill onto\n  ** overflow pages.  The strategy is to minimize the amount of unused\n  ** space on overflow pages while keeping the amount of local storage\n  ** in between minLocal and maxLocal.\n  **\n  ** Warning:  changing the way overflow payload is distributed in any\n  ** way will result in an incompatible file format.\n  */\n  int minLocal;  /* Minimum amount of payload held locally */\n  int maxLocal;  /* Maximum amount of payload held locally */\n  int surplus;   /* Overflow payload available for local storage */\n\n  minLocal = pPage->minLocal;\n  maxLocal = pPage->maxLocal;\n  surplus = minLocal + (pInfo->nPayload - minLocal)%(pPage->pBt->usableSize-4);\n  testcase( surplus==maxLocal );\n  testcase( surplus==maxLocal+1 );\n  if( surplus <= maxLocal ){\n    pInfo->nLocal = (u16)surplus;\n  }else{\n    pInfo->nLocal = (u16)minLocal;\n  }\n  pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4;\n}\n\n/*\n** The following routines are implementations of the MemPage.xParseCell()\n** method.\n**\n** Parse a cell content block and fill in the CellInfo structure.\n**\n** btreeParseCellPtr()        =>   table btree leaf nodes\n** btreeParseCellNoPayload()  =>   table btree internal nodes\n** btreeParseCellPtrIndex()   =>   index btree nodes\n**\n** There is also a wrapper function btreeParseCell() that works for\n** all MemPage types and that references the cell by index rather than\n** by pointer.\n*/\nstatic void btreeParseCellPtrNoPayload(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 );\n  assert( pPage->childPtrSize==4 );\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER(pPage);\n#endif\n  pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);\n  pInfo->nPayload = 0;\n  pInfo->nLocal = 0;\n  pInfo->pPayload = 0;\n  return;\n}\nstatic void btreeParseCellPtr(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n  u64 iKey;               /* Extracted Key value */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf );\n  assert( pPage->childPtrSize==0 );\n  pIter = pCell;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint32(pIter, nPayload);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( (*pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint(pIter, (u64*)&pInfo->nKey);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  iKey = *pIter;\n  if( iKey>=0x80 ){\n    u8 *pEnd = &pIter[7];\n    iKey &= 0x7f;\n    while(1){\n      iKey = (iKey<<7) | (*++pIter & 0x7f);\n      if( (*pIter)<0x80 ) break;\n      if( pIter>=pEnd ){\n        iKey = (iKey<<8) | *++pIter;\n        break;\n      }\n    }\n  }\n  pIter++;\n\n  pInfo->nKey = *(i64*)&iKey;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCellPtrIndex(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf==0 );\n  pIter = pCell + pPage->childPtrSize;\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  pInfo->nKey = nPayload;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCell(\n  MemPage *pPage,         /* Page containing the cell */\n  int iCell,              /* The cell index.  First cell is 0 */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  pPage->xParseCell(pPage, findCell(pPage, iCell), pInfo);\n}\n\n/*\n** The following routines are implementations of the MemPage.xCellSize\n** method.\n**\n** Compute the total number of bytes that a Cell needs in the cell\n** data area of the btree-page.  The return number includes the cell\n** data header and the local payload, but not any overflow page or\n** the space used by the cell pointer.\n**\n** cellSizePtrNoPayload()    =>   table internal nodes\n** cellSizePtr()             =>   all index nodes & table leaf nodes\n*/\nstatic u16 cellSizePtr(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */\n  u8 *pEnd;                                /* End mark for a varint */\n  u32 nSize;                               /* Size value to return */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#endif\n\n  nSize = *pIter;\n  if( nSize>=0x80 ){\n    pEnd = &pIter[8];\n    nSize &= 0x7f;\n    do{\n      nSize = (nSize<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  if( pPage->intKey ){\n    /* pIter now points at the 64-bit integer key value, a variable length \n    ** integer. The following block moves pIter to point at the first byte\n    ** past the end of the key value. */\n    pEnd = &pIter[9];\n    while( (*pIter++)&0x80 && pIter<pEnd );\n  }\n  testcase( nSize==pPage->maxLocal );\n  testcase( nSize==pPage->maxLocal+1 );\n  if( nSize<=pPage->maxLocal ){\n    nSize += (u32)(pIter - pCell);\n    if( nSize<4 ) nSize = 4;\n  }else{\n    int minLocal = pPage->minLocal;\n    nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);\n    testcase( nSize==pPage->maxLocal );\n    testcase( nSize==pPage->maxLocal+1 );\n    if( nSize>pPage->maxLocal ){\n      nSize = minLocal;\n    }\n    nSize += 4 + (u16)(pIter - pCell);\n  }\n  assert( nSize==debuginfo.nSize || CORRUPT_DB );\n  return (u16)nSize;\n}\nstatic u16 cellSizePtrNoPayload(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + 4; /* For looping over bytes of pCell */\n  u8 *pEnd;              /* End mark for a varint */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#else\n  UNUSED_PARAMETER(pPage);\n#endif\n\n  assert( pPage->childPtrSize==4 );\n  pEnd = pIter + 9;\n  while( (*pIter++)&0x80 && pIter<pEnd );\n  assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );\n  return (u16)(pIter - pCell);\n}\n\n\n#ifdef SQLITE_DEBUG\n/* This variation on cellSizePtr() is used inside of assert() statements\n** only. */\nstatic u16 cellSize(MemPage *pPage, int iCell){\n  return pPage->xCellSize(pPage, findCell(pPage, iCell));\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** If the cell pCell, part of page pPage contains a pointer\n** to an overflow page, insert an entry into the pointer-map\n** for the overflow page.\n*/\nstatic void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){\n  CellInfo info;\n  if( *pRC ) return;\n  assert( pCell!=0 );\n  pPage->xParseCell(pPage, pCell, &info);\n  if( info.nLocal<info.nPayload ){\n    Pgno ovfl = get4byte(&pCell[info.nSize-4]);\n    ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);\n  }\n}\n#endif\n\n\n/*\n** Defragment the page given. This routine reorganizes cells within the\n** page so that there are no free-blocks on the free-block list.\n**\n** Parameter nMaxFrag is the maximum amount of fragmented space that may be\n** present in the page after this routine returns.\n**\n** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a\n** b-tree page so that there are no freeblocks or fragment bytes, all\n** unused bytes are contained in the unallocated space region, and all\n** cells are packed tightly at the end of the page.\n*/\nstatic int defragmentPage(MemPage *pPage, int nMaxFrag){\n  int i;                     /* Loop counter */\n  int pc;                    /* Address of the i-th cell */\n  int hdr;                   /* Offset to the page header */\n  int size;                  /* Size of a cell */\n  int usableSize;            /* Number of usable bytes on a page */\n  int cellOffset;            /* Offset to the cell pointer array */\n  int cbrk;                  /* Offset to the cell content area */\n  int nCell;                 /* Number of cells on the page */\n  unsigned char *data;       /* The page data */\n  unsigned char *temp;       /* Temp area for cell content */\n  unsigned char *src;        /* Source of content */\n  int iCellFirst;            /* First allowable cell index */\n  int iCellLast;             /* Last possible cell index */\n\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );\n  assert( pPage->nOverflow==0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  temp = 0;\n  src = data = pPage->aData;\n  hdr = pPage->hdrOffset;\n  cellOffset = pPage->cellOffset;\n  nCell = pPage->nCell;\n  assert( nCell==get2byte(&data[hdr+3]) );\n  iCellFirst = cellOffset + 2*nCell;\n  usableSize = pPage->pBt->usableSize;\n\n  /* This block handles pages with two or fewer free blocks and nMaxFrag\n  ** or fewer fragmented bytes. In this case it is faster to move the\n  ** two (or one) blocks of cells using memmove() and add the required\n  ** offsets to each pointer in the cell-pointer array than it is to \n  ** reconstruct the entire page.  */\n  if( (int)data[hdr+7]<=nMaxFrag ){\n    int iFree = get2byte(&data[hdr+1]);\n    if( iFree ){\n      int iFree2 = get2byte(&data[iFree]);\n\n      /* pageFindSlot() has already verified that free blocks are sorted\n      ** in order of offset within the page, and that no block extends\n      ** past the end of the page. Provided the two free slots do not \n      ** overlap, this guarantees that the memmove() calls below will not\n      ** overwrite the usableSize byte buffer, even if the database page\n      ** is corrupt.  */\n      assert( iFree2==0 || iFree2>iFree );\n      assert( iFree+get2byte(&data[iFree+2]) <= usableSize );\n      assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );\n\n      if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){\n        u8 *pEnd = &data[cellOffset + nCell*2];\n        u8 *pAddr;\n        int sz2 = 0;\n        int sz = get2byte(&data[iFree+2]);\n        int top = get2byte(&data[hdr+5]);\n        if( top>=iFree ){\n          return SQLITE_CORRUPT_PGNO(pPage->pgno);\n        }\n        if( iFree2 ){\n          assert( iFree+sz<=iFree2 ); /* Verified by pageFindSlot() */\n          sz2 = get2byte(&data[iFree2+2]);\n          assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );\n          memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));\n          sz += sz2;\n        }\n        cbrk = top+sz;\n        assert( cbrk+(iFree-top) <= usableSize );\n        memmove(&data[cbrk], &data[top], iFree-top);\n        for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){\n          pc = get2byte(pAddr);\n          if( pc<iFree ){ put2byte(pAddr, pc+sz); }\n          else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); }\n        }\n        goto defragment_out;\n      }\n    }\n  }\n\n  cbrk = usableSize;\n  iCellLast = usableSize - 4;\n  for(i=0; i<nCell; i++){\n    u8 *pAddr;     /* The i-th cell pointer */\n    pAddr = &data[cellOffset + i*2];\n    pc = get2byte(pAddr);\n    testcase( pc==iCellFirst );\n    testcase( pc==iCellLast );\n    /* These conditions have already been verified in btreeInitPage()\n    ** if PRAGMA cell_size_check=ON.\n    */\n    if( pc<iCellFirst || pc>iCellLast ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( pc>=iCellFirst && pc<=iCellLast );\n    size = pPage->xCellSize(pPage, &src[pc]);\n    cbrk -= size;\n    if( cbrk<iCellFirst || pc+size>usableSize ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( cbrk+size<=usableSize && cbrk>=iCellFirst );\n    testcase( cbrk+size==usableSize );\n    testcase( pc+size==usableSize );\n    put2byte(pAddr, cbrk);\n    if( temp==0 ){\n      int x;\n      if( cbrk==pc ) continue;\n      temp = sqlite3PagerTempSpace(pPage->pBt->pPager);\n      x = get2byte(&data[hdr+5]);\n      memcpy(&temp[x], &data[x], (cbrk+size) - x);\n      src = temp;\n    }\n    memcpy(&data[cbrk], &src[pc], size);\n  }\n  data[hdr+7] = 0;\n\n defragment_out:\n  if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  assert( cbrk>=iCellFirst );\n  put2byte(&data[hdr+5], cbrk);\n  data[hdr+1] = 0;\n  data[hdr+2] = 0;\n  memset(&data[iCellFirst], 0, cbrk-iCellFirst);\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  return SQLITE_OK;\n}\n\n/*\n** Search the free-list on page pPg for space to store a cell nByte bytes in\n** size. If one can be found, return a pointer to the space and remove it\n** from the free-list.\n**\n** If no suitable space can be found on the free-list, return NULL.\n**\n** This function may detect corruption within pPg.  If corruption is\n** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned.\n**\n** Slots on the free list that are between 1 and 3 bytes larger than nByte\n** will be ignored if adding the extra space to the fragmentation count\n** causes the fragmentation count to exceed 60.\n*/\nstatic u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){\n  const int hdr = pPg->hdrOffset;\n  u8 * const aData = pPg->aData;\n  int iAddr = hdr + 1;\n  int pc = get2byte(&aData[iAddr]);\n  int x;\n  int usableSize = pPg->pBt->usableSize;\n  int size;            /* Size of the free slot */\n\n  assert( pc>0 );\n  while( pc<=usableSize-4 ){\n    /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each\n    ** freeblock form a big-endian integer which is the size of the freeblock\n    ** in bytes, including the 4-byte header. */\n    size = get2byte(&aData[pc+2]);\n    if( (x = size - nByte)>=0 ){\n      testcase( x==4 );\n      testcase( x==3 );\n      if( size+pc > usableSize ){\n        *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);\n        return 0;\n      }else if( x<4 ){\n        /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total\n        ** number of bytes in fragments may not exceed 60. */\n        if( aData[hdr+7]>57 ) return 0;\n\n        /* Remove the slot from the free-list. Update the number of\n        ** fragmented bytes within the page. */\n        memcpy(&aData[iAddr], &aData[pc], 2);\n        aData[hdr+7] += (u8)x;\n      }else{\n        /* The slot remains on the free-list. Reduce its size to account\n         ** for the portion used by the new allocation. */\n        put2byte(&aData[pc+2], x);\n      }\n      return &aData[pc + x];\n    }\n    iAddr = pc;\n    pc = get2byte(&aData[pc]);\n    if( pc<iAddr+size ) break;\n  }\n  if( pc ){\n    *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);\n  }\n\n  return 0;\n}\n\n/*\n** Allocate nByte bytes of space from within the B-Tree page passed\n** as the first argument. Write into *pIdx the index into pPage->aData[]\n** of the first byte of allocated space. Return either SQLITE_OK or\n** an error code (usually SQLITE_CORRUPT).\n**\n** The caller guarantees that there is sufficient space to make the\n** allocation.  This routine might need to defragment in order to bring\n** all the space together, however.  This routine will avoid using\n** the first two bytes past the cell pointer area since presumably this\n** allocation is being made in order to insert a new cell, so we will\n** also end up needing a new cell pointer.\n*/\nstatic int allocateSpace(MemPage *pPage, int nByte, int *pIdx){\n  const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */\n  u8 * const data = pPage->aData;      /* Local cache of pPage->aData */\n  int top;                             /* First byte of cell content area */\n  int rc = SQLITE_OK;                  /* Integer return code */\n  int gap;        /* First byte of gap between cell pointers and cell content */\n  \n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( nByte>=0 );  /* Minimum cell size is 4 */\n  assert( pPage->nFree>=nByte );\n  assert( pPage->nOverflow==0 );\n  assert( nByte < (int)(pPage->pBt->usableSize-8) );\n\n  assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );\n  gap = pPage->cellOffset + 2*pPage->nCell;\n  assert( gap<=65536 );\n  /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size\n  ** and the reserved space is zero (the usual value for reserved space)\n  ** then the cell content offset of an empty page wants to be 65536.\n  ** However, that integer is too large to be stored in a 2-byte unsigned\n  ** integer, so a value of 0 is used in its place. */\n  top = get2byte(&data[hdr+5]);\n  assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */\n  if( gap>top ){\n    if( top==0 && pPage->pBt->usableSize==65536 ){\n      top = 65536;\n    }else{\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n  }\n\n  /* If there is enough space between gap and top for one more cell pointer\n  ** array entry offset, and if the freelist is not empty, then search the\n  ** freelist looking for a free slot big enough to satisfy the request.\n  */\n  testcase( gap+2==top );\n  testcase( gap+1==top );\n  testcase( gap==top );\n  if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){\n    u8 *pSpace = pageFindSlot(pPage, nByte, &rc);\n    if( pSpace ){\n      assert( pSpace>=data && (pSpace - data)<65536 );\n      *pIdx = (int)(pSpace - data);\n      return SQLITE_OK;\n    }else if( rc ){\n      return rc;\n    }\n  }\n\n  /* The request could not be fulfilled using a freelist slot.  Check\n  ** to see if defragmentation is necessary.\n  */\n  testcase( gap+2+nByte==top );\n  if( gap+2+nByte>top ){\n    assert( pPage->nCell>0 || CORRUPT_DB );\n    rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));\n    if( rc ) return rc;\n    top = get2byteNotZero(&data[hdr+5]);\n    assert( gap+2+nByte<=top );\n  }\n\n\n  /* Allocate memory from the gap in between the cell pointer array\n  ** and the cell content area.  The btreeInitPage() call has already\n  ** validated the freelist.  Given that the freelist is valid, there\n  ** is no way that the allocation can extend off the end of the page.\n  ** The assert() below verifies the previous sentence.\n  */\n  top -= nByte;\n  put2byte(&data[hdr+5], top);\n  assert( top+nByte <= (int)pPage->pBt->usableSize );\n  *pIdx = top;\n  return SQLITE_OK;\n}\n\n/*\n** Return a section of the pPage->aData to the freelist.\n** The first byte of the new free block is pPage->aData[iStart]\n** and the size of the block is iSize bytes.\n**\n** Adjacent freeblocks are coalesced.\n**\n** Note that even though the freeblock list was checked by btreeInitPage(),\n** that routine will not detect overlap between cells or freeblocks.  Nor\n** does it detect cells or freeblocks that encrouch into the reserved bytes\n** at the end of the page.  So do additional corruption checks inside this\n** routine and return SQLITE_CORRUPT if any problems are found.\n*/\nstatic int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){\n  u16 iPtr;                             /* Address of ptr to next freeblock */\n  u16 iFreeBlk;                         /* Address of the next freeblock */\n  u8 hdr;                               /* Page header size.  0 or 100 */\n  u8 nFrag = 0;                         /* Reduction in fragmentation */\n  u16 iOrigSize = iSize;                /* Original value of iSize */\n  u16 x;                                /* Offset to cell content area */\n  u32 iEnd = iStart + iSize;            /* First byte past the iStart buffer */\n  unsigned char *data = pPage->aData;   /* Page content */\n\n  assert( pPage->pBt!=0 );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );\n  assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( iSize>=4 );   /* Minimum cell size is 4 */\n  assert( iStart<=pPage->pBt->usableSize-4 );\n\n  /* The list of freeblocks must be in ascending order.  Find the \n  ** spot on the list where iStart should be inserted.\n  */\n  hdr = pPage->hdrOffset;\n  iPtr = hdr + 1;\n  if( data[iPtr+1]==0 && data[iPtr]==0 ){\n    iFreeBlk = 0;  /* Shortcut for the case when the freelist is empty */\n  }else{\n    while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){\n      if( iFreeBlk<iPtr+4 ){\n        if( iFreeBlk==0 ) break;\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      iPtr = iFreeBlk;\n    }\n    if( iFreeBlk>pPage->pBt->usableSize-4 ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( iFreeBlk>iPtr || iFreeBlk==0 );\n  \n    /* At this point:\n    **    iFreeBlk:   First freeblock after iStart, or zero if none\n    **    iPtr:       The address of a pointer to iFreeBlk\n    **\n    ** Check to see if iFreeBlk should be coalesced onto the end of iStart.\n    */\n    if( iFreeBlk && iEnd+3>=iFreeBlk ){\n      nFrag = iFreeBlk - iEnd;\n      if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);\n      if( iEnd > pPage->pBt->usableSize ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      iSize = iEnd - iStart;\n      iFreeBlk = get2byte(&data[iFreeBlk]);\n    }\n  \n    /* If iPtr is another freeblock (that is, if iPtr is not the freelist\n    ** pointer in the page header) then check to see if iStart should be\n    ** coalesced onto the end of iPtr.\n    */\n    if( iPtr>hdr+1 ){\n      int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);\n      if( iPtrEnd+3>=iStart ){\n        if( iPtrEnd>iStart ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n        nFrag += iStart - iPtrEnd;\n        iSize = iEnd - iPtr;\n        iStart = iPtr;\n      }\n    }\n    if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    data[hdr+7] -= nFrag;\n  }\n  x = get2byte(&data[hdr+5]);\n  if( iStart<=x ){\n    /* The new freeblock is at the beginning of the cell content area,\n    ** so just extend the cell content area rather than create another\n    ** freelist entry */\n    if( iStart<x || iPtr!=hdr+1 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    put2byte(&data[hdr+1], iFreeBlk);\n    put2byte(&data[hdr+5], iEnd);\n  }else{\n    /* Insert the new freeblock into the freelist */\n    put2byte(&data[iPtr], iStart);\n  }\n  if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){\n    /* Overwrite deleted information with zeros when the secure_delete\n    ** option is enabled */\n    memset(&data[iStart], 0, iSize);\n  }\n  put2byte(&data[iStart], iFreeBlk);\n  put2byte(&data[iStart+2], iSize);\n  pPage->nFree += iOrigSize;\n  return SQLITE_OK;\n}\n\n/*\n** Decode the flags byte (the first byte of the header) for a page\n** and initialize fields of the MemPage structure accordingly.\n**\n** Only the following combinations are supported.  Anything different\n** indicates a corrupt database files:\n**\n**         PTF_ZERODATA\n**         PTF_ZERODATA | PTF_LEAF\n**         PTF_LEAFDATA | PTF_INTKEY\n**         PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF\n*/\nstatic int decodeFlags(MemPage *pPage, int flagByte){\n  BtShared *pBt;     /* A copy of pPage->pBt */\n\n  assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->leaf = (u8)(flagByte>>3);  assert( PTF_LEAF == 1<<3 );\n  flagByte &= ~PTF_LEAF;\n  pPage->childPtrSize = 4-4*pPage->leaf;\n  pPage->xCellSize = cellSizePtr;\n  pBt = pPage->pBt;\n  if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){\n    /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an\n    ** interior table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );\n    /* EVIDENCE-OF: R-26900-09176 A value of 13 (0x0d) means the page is a\n    ** leaf table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );\n    pPage->intKey = 1;\n    if( pPage->leaf ){\n      pPage->intKeyLeaf = 1;\n      pPage->xParseCell = btreeParseCellPtr;\n    }else{\n      pPage->intKeyLeaf = 0;\n      pPage->xCellSize = cellSizePtrNoPayload;\n      pPage->xParseCell = btreeParseCellPtrNoPayload;\n    }\n    pPage->maxLocal = pBt->maxLeaf;\n    pPage->minLocal = pBt->minLeaf;\n  }else if( flagByte==PTF_ZERODATA ){\n    /* EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an\n    ** interior index b-tree page. */\n    assert( (PTF_ZERODATA)==2 );\n    /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a\n    ** leaf index b-tree page. */\n    assert( (PTF_ZERODATA|PTF_LEAF)==10 );\n    pPage->intKey = 0;\n    pPage->intKeyLeaf = 0;\n    pPage->xParseCell = btreeParseCellPtrIndex;\n    pPage->maxLocal = pBt->maxLocal;\n    pPage->minLocal = pBt->minLocal;\n  }else{\n    /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is\n    ** an error. */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  pPage->max1bytePayload = pBt->max1bytePayload;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the auxiliary information for a disk block.\n**\n** Return SQLITE_OK on success.  If we see that the page does\n** not contain a well-formed database page, then return \n** SQLITE_CORRUPT.  Note that a return of SQLITE_OK does not\n** guarantee that the page is well-formed.  It only shows that\n** we failed to detect any corruption.\n*/\nstatic int btreeInitPage(MemPage *pPage){\n  int pc;            /* Address of a freeblock within pPage->aData[] */\n  u8 hdr;            /* Offset to beginning of page header */\n  u8 *data;          /* Equal to pPage->aData */\n  BtShared *pBt;        /* The main btree structure */\n  int usableSize;    /* Amount of usable space on each page */\n  u16 cellOffset;    /* Offset from start of page to first cell pointer */\n  int nFree;         /* Number of unused bytes on the page */\n  int top;           /* First byte of the cell content area */\n  int iCellFirst;    /* First allowable cell or freeblock offset */\n  int iCellLast;     /* Last possible cell or freeblock offset */\n\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->db!=0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );\n  assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );\n  assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );\n  assert( pPage->isInit==0 );\n\n  pBt = pPage->pBt;\n  hdr = pPage->hdrOffset;\n  data = pPage->aData;\n  /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating\n  ** the b-tree page type. */\n  if( decodeFlags(pPage, data[hdr]) ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nOverflow = 0;\n  usableSize = pBt->usableSize;\n  pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;\n  pPage->aDataEnd = &data[usableSize];\n  pPage->aCellIdx = &data[cellOffset];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates\n  ** the start of the cell content area. A zero value for this integer is\n  ** interpreted as 65536. */\n  top = get2byteNotZero(&data[hdr+5]);\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  pPage->nCell = get2byte(&data[hdr+3]);\n  if( pPage->nCell>MX_CELL(pBt) ){\n    /* To many cells for a single page.  The page must be corrupt */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  testcase( pPage->nCell==MX_CELL(pBt) );\n  /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only\n  ** possible for a root page of a table that contains no rows) then the\n  ** offset to the cell content area will equal the page size minus the\n  ** bytes of reserved space. */\n  assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );\n\n  /* A malformed database page might cause us to read past the end\n  ** of page when parsing a cell.  \n  **\n  ** The following block of code checks early to see if a cell extends\n  ** past the end of a page boundary and causes SQLITE_CORRUPT to be \n  ** returned if it does.\n  */\n  iCellFirst = cellOffset + 2*pPage->nCell;\n  iCellLast = usableSize - 4;\n  if( pBt->db->flags & SQLITE_CellSizeCk ){\n    int i;            /* Index into the cell pointer array */\n    int sz;           /* Size of a cell */\n\n    if( !pPage->leaf ) iCellLast--;\n    for(i=0; i<pPage->nCell; i++){\n      pc = get2byteAligned(&data[cellOffset+i*2]);\n      testcase( pc==iCellFirst );\n      testcase( pc==iCellLast );\n      if( pc<iCellFirst || pc>iCellLast ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      sz = pPage->xCellSize(pPage, &data[pc]);\n      testcase( pc+sz==usableSize );\n      if( pc+sz>usableSize ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n    }\n    if( !pPage->leaf ) iCellLast++;\n  }  \n\n  /* Compute the total free space on the page\n  ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the\n  ** start of the first freeblock on the page, or is zero if there are no\n  ** freeblocks. */\n  pc = get2byte(&data[hdr+1]);\n  nFree = data[hdr+7] + top;  /* Init nFree to non-freeblock free space */\n  if( pc>0 ){\n    u32 next, size;\n    if( pc<iCellFirst ){\n      /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will\n      ** always be at least one cell before the first freeblock.\n      */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno); \n    }\n    while( 1 ){\n      if( pc>iCellLast ){\n        /* Freeblock off the end of the page */\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      next = get2byte(&data[pc]);\n      size = get2byte(&data[pc+2]);\n      nFree = nFree + size;\n      if( next<=pc+size+3 ) break;\n      pc = next;\n    }\n    if( next>0 ){\n      /* Freeblock not in ascending order */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    if( pc+size>(unsigned int)usableSize ){\n      /* Last freeblock extends past page end */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n  }\n\n  /* At this point, nFree contains the sum of the offset to the start\n  ** of the cell-content area plus the number of free bytes within\n  ** the cell-content area. If this is greater than the usable-size\n  ** of the page, then the page must be corrupted. This check also\n  ** serves to verify that the offset to the start of the cell-content\n  ** area, according to the page header, lies within the page.\n  */\n  if( nFree>usableSize ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  pPage->nFree = (u16)(nFree - iCellFirst);\n  pPage->isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Set up a raw page so that it looks like a database page holding\n** no entries.\n*/\nstatic void zeroPage(MemPage *pPage, int flags){\n  unsigned char *data = pPage->aData;\n  BtShared *pBt = pPage->pBt;\n  u8 hdr = pPage->hdrOffset;\n  u16 first;\n\n  assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage) == data );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->btsFlags & BTS_FAST_SECURE ){\n    memset(&data[hdr], 0, pBt->usableSize - hdr);\n  }\n  data[hdr] = (char)flags;\n  first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);\n  memset(&data[hdr+1], 0, 4);\n  data[hdr+7] = 0;\n  put2byte(&data[hdr+5], pBt->usableSize);\n  pPage->nFree = (u16)(pBt->usableSize - first);\n  decodeFlags(pPage, flags);\n  pPage->cellOffset = first;\n  pPage->aDataEnd = &data[pBt->usableSize];\n  pPage->aCellIdx = &data[first];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  pPage->nOverflow = 0;\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nCell = 0;\n  pPage->isInit = 1;\n}\n\n\n/*\n** Convert a DbPage obtained from the pager into a MemPage used by\n** the btree layer.\n*/\nstatic MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared *pBt){\n  MemPage *pPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( pgno!=pPage->pgno ){\n    pPage->aData = sqlite3PagerGetData(pDbPage);\n    pPage->pDbPage = pDbPage;\n    pPage->pBt = pBt;\n    pPage->pgno = pgno;\n    pPage->hdrOffset = pgno==1 ? 100 : 0;\n  }\n  assert( pPage->aData==sqlite3PagerGetData(pDbPage) );\n  return pPage; \n}\n\n/*\n** Get a page from the pager.  Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.  See also: btreeGetUnusedPage().\n**\n** If the PAGER_GET_NOCONTENT flag is set, it means that we do not care\n** about the content of the page at this time.  So do not go to the disk\n** to fetch the content.  Just fill in the content with zeros for now.\n** If in the future we call sqlite3PagerWrite() on this page, that\n** means we have started to be concerned about content and the disk\n** read should occur at that point.\n*/\nstatic int btreeGetPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc;\n  DbPage *pDbPage;\n\n  assert( flags==0 || flags==PAGER_GET_NOCONTENT || flags==PAGER_GET_READONLY );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);\n  if( rc ) return rc;\n  *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a page from the pager cache. If the requested page is not\n** already in the pager cache return NULL. Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.\n*/\nstatic MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);\n  if( pDbPage ){\n    return btreePageFromDbPage(pDbPage, pgno, pBt);\n  }\n  return 0;\n}\n\n/*\n** Return the size of the database file in pages. If there is any kind of\n** error, return ((unsigned int)-1).\n*/\nstatic Pgno btreePagecount(BtShared *pBt){\n  return pBt->nPage;\n}\nSQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree *p){\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( ((p->pBt->nPage)&0x80000000)==0 );\n  return btreePagecount(p->pBt);\n}\n\n/*\n** Get a page from the pager and initialize it.\n**\n** If pCur!=0 then the page is being fetched as part of a moveToChild()\n** call.  Do additional sanity checking on the page in this case.\n** And if the fetch fails, this routine must decrement pCur->iPage.\n**\n** The page is fetched as read-write unless pCur is not NULL and is\n** a read-only cursor.\n**\n** If an error occurs, then *ppPage is undefined. It\n** may remain unchanged, or it may be set to an invalid value.\n*/\nstatic int getAndInitPage(\n  BtShared *pBt,                  /* The database file */\n  Pgno pgno,                      /* Number of the page to get */\n  MemPage **ppPage,               /* Write the page pointer here */\n  BtCursor *pCur,                 /* Cursor to receive the page, or NULL */\n  int bReadOnly                   /* True for a read-only page */\n){\n  int rc;\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pCur==0 || ppPage==&pCur->pPage );\n  assert( pCur==0 || bReadOnly==pCur->curPagerFlags );\n  assert( pCur==0 || pCur->iPage>0 );\n\n  if( pgno>btreePagecount(pBt) ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto getAndInitPage_error;\n  }\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly);\n  if( rc ){\n    goto getAndInitPage_error;\n  }\n  *ppPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( (*ppPage)->isInit==0 ){\n    btreePageFromDbPage(pDbPage, pgno, pBt);\n    rc = btreeInitPage(*ppPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      goto getAndInitPage_error;\n    }\n  }\n  assert( (*ppPage)->pgno==pgno );\n  assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );\n\n  /* If obtaining a child page for a cursor, we must verify that the page is\n  ** compatible with the root page. */\n  if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){\n    rc = SQLITE_CORRUPT_PGNO(pgno);\n    releasePage(*ppPage);\n    goto getAndInitPage_error;\n  }\n  return SQLITE_OK;\n\ngetAndInitPage_error:\n  if( pCur ){\n    pCur->iPage--;\n    pCur->pPage = pCur->apPage[pCur->iPage];\n  }\n  testcase( pgno==0 );\n  assert( pgno!=0 || rc==SQLITE_CORRUPT );\n  return rc;\n}\n\n/*\n** Release a MemPage.  This should be called once for each prior\n** call to btreeGetPage.\n**\n** Page1 is a special case and must be released using releasePageOne().\n*/\nstatic void releasePageNotNull(MemPage *pPage){\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefNotNull(pPage->pDbPage);\n}\nstatic void releasePage(MemPage *pPage){\n  if( pPage ) releasePageNotNull(pPage);\n}\nstatic void releasePageOne(MemPage *pPage){\n  assert( pPage!=0 );\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefPageOne(pPage->pDbPage);\n}\n\n/*\n** Get an unused page.\n**\n** This works just like btreeGetPage() with the addition:\n**\n**   *  If the page is already in use for some other purpose, immediately\n**      release it and return an SQLITE_CURRUPT error.\n**   *  Make sure the isInit flag is clear\n*/\nstatic int btreeGetUnusedPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc = btreeGetPage(pBt, pgno, ppPage, flags);\n  if( rc==SQLITE_OK ){\n    if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n      return SQLITE_CORRUPT_BKPT;\n    }\n    (*ppPage)->isInit = 0;\n  }else{\n    *ppPage = 0;\n  }\n  return rc;\n}\n\n\n/*\n** During a rollback, when the pager reloads information into the cache\n** so that the cache is restored to its original state at the start of\n** the transaction, for each page restored this routine is called.\n**\n** This routine needs to reset the extra data section at the end of the\n** page to agree with the restored data.\n*/\nstatic void pageReinit(DbPage *pData){\n  MemPage *pPage;\n  pPage = (MemPage *)sqlite3PagerGetExtra(pData);\n  assert( sqlite3PagerPageRefcount(pData)>0 );\n  if( pPage->isInit ){\n    assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n    pPage->isInit = 0;\n    if( sqlite3PagerPageRefcount(pData)>1 ){\n      /* pPage might not be a btree page;  it might be an overflow page\n      ** or ptrmap page or a free page.  In those cases, the following\n      ** call to btreeInitPage() will likely return SQLITE_CORRUPT.\n      ** But no harm is done by this.  And it is very important that\n      ** btreeInitPage() be called on every btree page so we make\n      ** the call for every page that comes in for re-initing. */\n      btreeInitPage(pPage);\n    }\n  }\n}\n\n/*\n** Invoke the busy handler for a btree.\n*/\nstatic int btreeInvokeBusyHandler(void *pArg){\n  BtShared *pBt = (BtShared*)pArg;\n  assert( pBt->db );\n  assert( sqlite3_mutex_held(pBt->db->mutex) );\n  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);\n}\n\n/*\n** Open a database file.\n** \n** zFilename is the name of the database file.  If zFilename is NULL\n** then an ephemeral database is created.  The ephemeral database might\n** be exclusively in memory, or it might use a disk-based memory cache.\n** Either way, the ephemeral database will be automatically deleted \n** when sqlite3BtreeClose() is called.\n**\n** If zFilename is \":memory:\" then an in-memory database is created\n** that is automatically destroyed when it is closed.\n**\n** The \"flags\" parameter is a bitmask that might contain bits like\n** BTREE_OMIT_JOURNAL and/or BTREE_MEMORY.\n**\n** If the database is already opened in the same database connection\n** and we are in shared cache mode, then the open will fail with an\n** SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared\n** objects in the same database connection since doing so will lead\n** to problems with locking.\n*/\nSQLITE_PRIVATE int sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,      /* VFS to use for this b-tree */\n  const char *zFilename,  /* Name of the file containing the BTree database */\n  sqlite3 *db,            /* Associated database handle */\n  Btree **ppBtree,        /* Pointer to new Btree object written here */\n  int flags,              /* Options */\n  int vfsFlags            /* Flags passed through to sqlite3_vfs.xOpen() */\n){\n  BtShared *pBt = 0;             /* Shared part of btree structure */\n  Btree *p;                      /* Handle to return */\n  sqlite3_mutex *mutexOpen = 0;  /* Prevents a race condition. Ticket #3537 */\n  int rc = SQLITE_OK;            /* Result code from this function */\n  u8 nReserve;                   /* Byte of unused space on each page */\n  unsigned char zDbHeader[100];  /* Database header content */\n\n  /* True if opening an ephemeral, temporary database */\n  const int isTempDb = zFilename==0 || zFilename[0]==0;\n\n  /* Set the variable isMemdb to true for an in-memory database, or \n  ** false for a file-based database.\n  */\n#ifdef SQLITE_OMIT_MEMORYDB\n  const int isMemdb = 0;\n#else\n  const int isMemdb = (zFilename && strcmp(zFilename, \":memory:\")==0)\n                       || (isTempDb && sqlite3TempInMemory(db))\n                       || (vfsFlags & SQLITE_OPEN_MEMORY)!=0;\n#endif\n\n  assert( db!=0 );\n  assert( pVfs!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( (flags&0xff)==flags );   /* flags fit in 8 bits */\n\n  /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */\n  assert( (flags & BTREE_UNORDERED)==0 || (flags & BTREE_SINGLE)!=0 );\n\n  /* A BTREE_SINGLE database is always a temporary and/or ephemeral */\n  assert( (flags & BTREE_SINGLE)==0 || isTempDb );\n\n  if( isMemdb ){\n    flags |= BTREE_MEMORY;\n  }\n  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){\n    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;\n  }\n  p = sqlite3MallocZero(sizeof(Btree));\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  p->inTrans = TRANS_NONE;\n  p->db = db;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  p->lock.pBtree = p;\n  p->lock.iTable = 1;\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /*\n  ** If this Btree is a candidate for shared cache, try to find an\n  ** existing BtShared object that we can share with\n  */\n  if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){\n    if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){\n      int nFilename = sqlite3Strlen30(zFilename)+1;\n      int nFullPathname = pVfs->mxPathname+1;\n      char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n\n      p->sharable = 1;\n      if( !zFullPathname ){\n        sqlite3_free(p);\n        return SQLITE_NOMEM_BKPT;\n      }\n      if( isMemdb ){\n        memcpy(zFullPathname, zFilename, nFilename);\n      }else{\n        rc = sqlite3OsFullPathname(pVfs, zFilename,\n                                   nFullPathname, zFullPathname);\n        if( rc ){\n          sqlite3_free(zFullPathname);\n          sqlite3_free(p);\n          return rc;\n        }\n      }\n#if SQLITE_THREADSAFE\n      mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);\n      sqlite3_mutex_enter(mutexOpen);\n      mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n      sqlite3_mutex_enter(mutexShared);\n#endif\n      for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){\n        assert( pBt->nRef>0 );\n        if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager, 0))\n                 && sqlite3PagerVfs(pBt->pPager)==pVfs ){\n          int iDb;\n          for(iDb=db->nDb-1; iDb>=0; iDb--){\n            Btree *pExisting = db->aDb[iDb].pBt;\n            if( pExisting && pExisting->pBt==pBt ){\n              sqlite3_mutex_leave(mutexShared);\n              sqlite3_mutex_leave(mutexOpen);\n              sqlite3_free(zFullPathname);\n              sqlite3_free(p);\n              return SQLITE_CONSTRAINT;\n            }\n          }\n          p->pBt = pBt;\n          pBt->nRef++;\n          break;\n        }\n      }\n      sqlite3_mutex_leave(mutexShared);\n      sqlite3_free(zFullPathname);\n    }\n#ifdef SQLITE_DEBUG\n    else{\n      /* In debug mode, we mark all persistent databases as sharable\n      ** even when they are not.  This exercises the locking code and\n      ** gives more opportunity for asserts(sqlite3_mutex_held())\n      ** statements to find locking problems.\n      */\n      p->sharable = 1;\n    }\n#endif\n  }\n#endif\n  if( pBt==0 ){\n    /*\n    ** The following asserts make sure that structures used by the btree are\n    ** the right size.  This is to guard against size changes that result\n    ** when compiling on a different architecture.\n    */\n    assert( sizeof(i64)==8 );\n    assert( sizeof(u64)==8 );\n    assert( sizeof(u32)==4 );\n    assert( sizeof(u16)==2 );\n    assert( sizeof(Pgno)==4 );\n  \n    pBt = sqlite3MallocZero( sizeof(*pBt) );\n    if( pBt==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto btree_open_out;\n    }\n    rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,\n                          sizeof(MemPage), flags, vfsFlags, pageReinit);\n    if( rc==SQLITE_OK ){\n      sqlite3PagerSetMmapLimit(pBt->pPager, db->szMmap);\n      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);\n    }\n    if( rc!=SQLITE_OK ){\n      goto btree_open_out;\n    }\n    pBt->openFlags = (u8)flags;\n    pBt->db = db;\n    sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);\n    p->pBt = pBt;\n  \n    pBt->pCursor = 0;\n    pBt->pPage1 = 0;\n    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;\n#if defined(SQLITE_SECURE_DELETE)\n    pBt->btsFlags |= BTS_SECURE_DELETE;\n#elif defined(SQLITE_FAST_SECURE_DELETE)\n    pBt->btsFlags |= BTS_OVERWRITE;\n#endif\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);\n    if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE\n         || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){\n      pBt->pageSize = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the magic name \":memory:\" will create an in-memory database, then\n      ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if\n      ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if\n      ** SQLITE_OMIT_MEMORYDB has been defined, then \":memory:\" is just a\n      ** regular file-name. In this case the auto-vacuum applies as per normal.\n      */\n      if( zFilename && !isMemdb ){\n        pBt->autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM ? 1 : 0);\n        pBt->incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM==2 ? 1 : 0);\n      }\n#endif\n      nReserve = 0;\n    }else{\n      /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n      ** determined by the one-byte unsigned integer found at an offset of 20\n      ** into the database file header. */\n      nReserve = zDbHeader[20];\n      pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);\n      pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);\n#endif\n    }\n    rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n    if( rc ) goto btree_open_out;\n    pBt->usableSize = pBt->pageSize - nReserve;\n    assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */\n   \n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n    /* Add the new BtShared object to the linked list sharable BtShareds.\n    */\n    pBt->nRef = 1;\n    if( p->sharable ){\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n      MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)\n      if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){\n        pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);\n        if( pBt->mutex==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto btree_open_out;\n        }\n      }\n      sqlite3_mutex_enter(mutexShared);\n      pBt->pNext = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt;\n      sqlite3_mutex_leave(mutexShared);\n    }\n#endif\n  }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /* If the new Btree uses a sharable pBtShared, then link the new\n  ** Btree into the list of all sharable Btrees for the same connection.\n  ** The list is kept in ascending order by pBt address.\n  */\n  if( p->sharable ){\n    int i;\n    Btree *pSib;\n    for(i=0; i<db->nDb; i++){\n      if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){\n        while( pSib->pPrev ){ pSib = pSib->pPrev; }\n        if( (uptr)p->pBt<(uptr)pSib->pBt ){\n          p->pNext = pSib;\n          p->pPrev = 0;\n          pSib->pPrev = p;\n        }else{\n          while( pSib->pNext && (uptr)pSib->pNext->pBt<(uptr)p->pBt ){\n            pSib = pSib->pNext;\n          }\n          p->pNext = pSib->pNext;\n          p->pPrev = pSib;\n          if( p->pNext ){\n            p->pNext->pPrev = p;\n          }\n          pSib->pNext = p;\n        }\n        break;\n      }\n    }\n  }\n#endif\n  *ppBtree = p;\n\nbtree_open_out:\n  if( rc!=SQLITE_OK ){\n    if( pBt && pBt->pPager ){\n      sqlite3PagerClose(pBt->pPager, 0);\n    }\n    sqlite3_free(pBt);\n    sqlite3_free(p);\n    *ppBtree = 0;\n  }else{\n    sqlite3_file *pFile;\n\n    /* If the B-Tree was successfully opened, set the pager-cache size to the\n    ** default value. Except, when opening on an existing shared pager-cache,\n    ** do not change the pager-cache size.\n    */\n    if( sqlite3BtreeSchema(p, 0, 0)==0 ){\n      sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);\n    }\n\n    pFile = sqlite3PagerFile(pBt->pPager);\n    if( pFile->pMethods ){\n      sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_PDB, (void*)&pBt->db);\n    }\n  }\n  if( mutexOpen ){\n    assert( sqlite3_mutex_held(mutexOpen) );\n    sqlite3_mutex_leave(mutexOpen);\n  }\n  assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );\n  return rc;\n}\n\n/*\n** Decrement the BtShared.nRef counter.  When it reaches zero,\n** remove the BtShared structure from the sharing list.  Return\n** true if the BtShared.nRef counter reaches zero and return\n** false if it is still positive.\n*/\nstatic int removeFromSharingList(BtShared *pBt){\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )\n  BtShared *pList;\n  int removed = 0;\n\n  assert( sqlite3_mutex_notheld(pBt->mutex) );\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  pBt->nRef--;\n  if( pBt->nRef<=0 ){\n    if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;\n    }else{\n      pList = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      while( ALWAYS(pList) && pList->pNext!=pBt ){\n        pList=pList->pNext;\n      }\n      if( ALWAYS(pList) ){\n        pList->pNext = pBt->pNext;\n      }\n    }\n    if( SQLITE_THREADSAFE ){\n      sqlite3_mutex_free(pBt->mutex);\n    }\n    removed = 1;\n  }\n  sqlite3_mutex_leave(pMaster);\n  return removed;\n#else\n  return 1;\n#endif\n}\n\n/*\n** Make sure pBt->pTmpSpace points to an allocation of \n** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child\n** pointer.\n*/\nstatic void allocateTempSpace(BtShared *pBt){\n  if( !pBt->pTmpSpace ){\n    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );\n\n    /* One of the uses of pBt->pTmpSpace is to format cells before\n    ** inserting them into a leaf page (function fillInCell()). If\n    ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes\n    ** by the various routines that manipulate binary cells. Which\n    ** can mean that fillInCell() only initializes the first 2 or 3\n    ** bytes of pTmpSpace, but that the first 4 bytes are copied from\n    ** it into a database page. This is not actually a problem, but it\n    ** does cause a valgrind error when the 1 or 2 bytes of unitialized \n    ** data is passed to system call write(). So to avoid this error,\n    ** zero the first 4 bytes of temp space here.\n    **\n    ** Also:  Provide four bytes of initialized space before the\n    ** beginning of pTmpSpace as an area available to prepend the\n    ** left-child pointer to the beginning of a cell.\n    */\n    if( pBt->pTmpSpace ){\n      memset(pBt->pTmpSpace, 0, 8);\n      pBt->pTmpSpace += 4;\n    }\n  }\n}\n\n/*\n** Free the pBt->pTmpSpace allocation\n*/\nstatic void freeTempSpace(BtShared *pBt){\n  if( pBt->pTmpSpace ){\n    pBt->pTmpSpace -= 4;\n    sqlite3PageFree(pBt->pTmpSpace);\n    pBt->pTmpSpace = 0;\n  }\n}\n\n/*\n** Close an open database and invalidate all cursors.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClose(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtCursor *pCur;\n\n  /* Close all cursors opened via this handle.  */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  pCur = pBt->pCursor;\n  while( pCur ){\n    BtCursor *pTmp = pCur;\n    pCur = pCur->pNext;\n    if( pTmp->pBtree==p ){\n      sqlite3BtreeCloseCursor(pTmp);\n    }\n  }\n\n  /* Rollback any active transaction and free the handle structure.\n  ** The call to sqlite3BtreeRollback() drops any table-locks held by\n  ** this handle.\n  */\n  sqlite3BtreeRollback(p, SQLITE_OK, 0);\n  sqlite3BtreeLeave(p);\n\n  /* If there are still other outstanding references to the shared-btree\n  ** structure, return now. The remainder of this procedure cleans \n  ** up the shared-btree.\n  */\n  assert( p->wantToLock==0 && p->locked==0 );\n  if( !p->sharable || removeFromSharingList(pBt) ){\n    /* The pBt is no longer on the sharing list, so we can access\n    ** it without having to hold the mutex.\n    **\n    ** Clean out and delete the BtShared object.\n    */\n    assert( !pBt->pCursor );\n    sqlite3PagerClose(pBt->pPager, p->db);\n    if( pBt->xFreeSchema && pBt->pSchema ){\n      pBt->xFreeSchema(pBt->pSchema);\n    }\n    sqlite3DbFree(0, pBt->pSchema);\n    freeTempSpace(pBt);\n    sqlite3_free(pBt);\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  assert( p->wantToLock==0 );\n  assert( p->locked==0 );\n  if( p->pPrev ) p->pPrev->pNext = p->pNext;\n  if( p->pNext ) p->pNext->pPrev = p->pPrev;\n#endif\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"soft\" limit on the number of pages in the cache.\n** Unused and unmodified pages will be recycled when the number of\n** pages in the cache exceeds this soft limit.  But the size of the\n** cache is allowed to grow larger than this limit if it contains\n** dirty pages or pages still in active use.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetCachesize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"spill\" limit on the number of pages in the cache.\n** If the number of pages exceeds this limit during a write transaction,\n** the pager might attempt to \"spill\" pages to the journal early in\n** order to free up memory.\n**\n** The value returned is the current spill size.  If zero is passed\n** as an argument, no changes are made to the spill size setting, so\n** using mxPage of 0 is a way to query the current spill size.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetSpillSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  int res;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  res = sqlite3PagerSetSpillsize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return res;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Change the limit on the amount of the database file that may be\n** memory mapped.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetMmapLimit(pBt->pPager, szMmap);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** Change the way data is synced to disk in order to increase or decrease\n** how well the database resists damage due to OS crashes and power\n** failures.  Level 1 is the same as asynchronous (no syncs() occur and\n** there is a high probability of damage)  Level 2 is the default.  There\n** is a very low but non-zero probability of damage.  Level 3 reduces the\n** probability of damage to near zero but with a write performance reduction.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nSQLITE_PRIVATE int sqlite3BtreeSetPagerFlags(\n  Btree *p,              /* The btree to set the safety level on */\n  unsigned pgFlags       /* Various PAGER_* flags */\n){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetFlags(pBt->pPager, pgFlags);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Change the default pages size and the number of reserved bytes per page.\n** Or, if the page size has already been fixed, return SQLITE_READONLY \n** without changing anything.\n**\n** The page size must be a power of 2 between 512 and 65536.  If the page\n** size supplied does not meet this constraint then the page size is not\n** changed.\n**\n** Page sizes are constrained to be a power of two so that the region\n** of the database file used for locking (beginning at PENDING_BYTE,\n** the first byte past the 1GB boundary, 0x40000000) needs to occur\n** at the beginning of a page.\n**\n** If parameter nReserve is less than zero, then the number of reserved\n** bytes per page is left unchanged.\n**\n** If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size\n** and autovacuum mode can no longer be changed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){\n  int rc = SQLITE_OK;\n  BtShared *pBt = p->pBt;\n  assert( nReserve>=-1 && nReserve<=255 );\n  sqlite3BtreeEnter(p);\n#if SQLITE_HAS_CODEC\n  if( nReserve>pBt->optimalReserve ) pBt->optimalReserve = (u8)nReserve;\n#endif\n  if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){\n    sqlite3BtreeLeave(p);\n    return SQLITE_READONLY;\n  }\n  if( nReserve<0 ){\n    nReserve = pBt->pageSize - pBt->usableSize;\n  }\n  assert( nReserve>=0 && nReserve<=255 );\n  if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&\n        ((pageSize-1)&pageSize)==0 ){\n    assert( (pageSize & 7)==0 );\n    assert( !pBt->pCursor );\n    pBt->pageSize = (u32)pageSize;\n    freeTempSpace(pBt);\n  }\n  rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n  pBt->usableSize = pBt->pageSize - (u16)nReserve;\n  if( iFix ) pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Return the currently defined page size\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){\n  return p->pBt->pageSize;\n}\n\n/*\n** This function is similar to sqlite3BtreeGetReserve(), except that it\n** may only be called if it is guaranteed that the b-tree mutex is already\n** held.\n**\n** This is useful in one special case in the backup API code where it is\n** known that the shared b-tree mutex is held, but the mutex on the \n** database handle that owns *p is not. In this case if sqlite3BtreeEnter()\n** were to be called, it might collide with some other operation on the\n** database handle that owns *p, causing undefined behavior.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){\n  int n;\n  assert( sqlite3_mutex_held(p->pBt->mutex) );\n  n = p->pBt->pageSize - p->pBt->usableSize;\n  return n;\n}\n\n/*\n** Return the number of bytes of space at the end of every page that\n** are intentually left unused.  This is the \"reserved\" space that is\n** sometimes used by extensions.\n**\n** If SQLITE_HAS_MUTEX is defined then the number returned is the\n** greater of the current reserved space and the maximum requested\n** reserve space.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree *p){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3BtreeGetReserveNoMutex(p);\n#ifdef SQLITE_HAS_CODEC\n  if( n<p->pBt->optimalReserve ) n = p->pBt->optimalReserve;\n#endif\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n\n/*\n** Set the maximum page count for a database if mxPage is positive.\n** No changes are made if mxPage is 0 or negative.\n** Regardless of the value of mxPage, return the maximum page count.\n*/\nSQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n/*\n** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:\n**\n**    newFlag==0       Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared\n**    newFlag==1       BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared\n**    newFlag==2       BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set\n**    newFlag==(-1)    No changes\n**\n** This routine acts as a query if newFlag is less than zero\n**\n** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but\n** freelist leaf pages are not written back to the database.  Thus in-page\n** deleted content is cleared, but freelist deleted content is not.\n**\n** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition\n** that freelist leaf pages are written back into the database, increasing\n** the amount of disk I/O.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){\n  int b;\n  if( p==0 ) return 0;\n  sqlite3BtreeEnter(p);\n  assert( BTS_OVERWRITE==BTS_SECURE_DELETE*2 );\n  assert( BTS_FAST_SECURE==(BTS_OVERWRITE|BTS_SECURE_DELETE) );\n  if( newFlag>=0 ){\n    p->pBt->btsFlags &= ~BTS_FAST_SECURE;\n    p->pBt->btsFlags |= BTS_SECURE_DELETE*newFlag;\n  }\n  b = (p->pBt->btsFlags & BTS_FAST_SECURE)/BTS_SECURE_DELETE;\n  sqlite3BtreeLeave(p);\n  return b;\n}\n\n/*\n** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'\n** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it\n** is disabled. The default value for the auto-vacuum property is \n** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return SQLITE_READONLY;\n#else\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n  u8 av = (u8)autoVacuum;\n\n  sqlite3BtreeEnter(p);\n  if( (pBt->btsFlags & BTS_PAGESIZE_FIXED)!=0 && (av ?1:0)!=pBt->autoVacuum ){\n    rc = SQLITE_READONLY;\n  }else{\n    pBt->autoVacuum = av ?1:0;\n    pBt->incrVacuum = av==2 ?1:0;\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** Return the value of the 'auto-vacuum' property. If auto-vacuum is \n** enabled 1 is returned. Otherwise 0.\n*/\nSQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *p){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return BTREE_AUTOVACUUM_NONE;\n#else\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = (\n    (!p->pBt->autoVacuum)?BTREE_AUTOVACUUM_NONE:\n    (!p->pBt->incrVacuum)?BTREE_AUTOVACUUM_FULL:\n    BTREE_AUTOVACUUM_INCR\n  );\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** If the user has not set the safety-level for this database connection\n** using \"PRAGMA synchronous\", and if the safety-level is not already\n** set to the value passed to this function as the second parameter,\n** set it so.\n*/\n#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS \\\n    && !defined(SQLITE_OMIT_WAL)\nstatic void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){\n  sqlite3 *db;\n  Db *pDb;\n  if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){\n    while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }\n    if( pDb->bSyncSet==0 \n     && pDb->safety_level!=safety_level \n     && pDb!=&db->aDb[1] \n    ){\n      pDb->safety_level = safety_level;\n      sqlite3PagerSetFlags(pBt->pPager,\n          pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));\n    }\n  }\n}\n#else\n# define setDefaultSyncFlag(pBt,safety_level)\n#endif\n\n/*\n** Get a reference to pPage1 of the database file.  This will\n** also acquire a readlock on that file.\n**\n** SQLITE_OK is returned on success.  If the file is not a\n** well-formed database file, then SQLITE_CORRUPT is returned.\n** SQLITE_BUSY is returned if the database is locked.  SQLITE_NOMEM\n** is returned if we run out of memory. \n*/\nstatic int lockBtree(BtShared *pBt){\n  int rc;              /* Result code from subfunctions */\n  MemPage *pPage1;     /* Page 1 of the database file */\n  int nPage;           /* Number of pages in the database */\n  int nPageFile = 0;   /* Number of pages in the database file */\n  int nPageHeader;     /* Number of pages in the database according to hdr */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pBt->pPage1==0 );\n  rc = sqlite3PagerSharedLock(pBt->pPager);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = btreeGetPage(pBt, 1, &pPage1, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Do some checking to help insure the file we opened really is\n  ** a valid database file. \n  */\n  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);\n  sqlite3PagerPagecount(pBt->pPager, &nPageFile);\n  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){\n    nPage = nPageFile;\n  }\n  if( nPage>0 ){\n    u32 pageSize;\n    u32 usableSize;\n    u8 *page1 = pPage1->aData;\n    rc = SQLITE_NOTADB;\n    /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins\n    ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d\n    ** 61 74 20 33 00. */\n    if( memcmp(page1, zMagicHeader, 16)!=0 ){\n      goto page1_init_failed;\n    }\n\n#ifdef SQLITE_OMIT_WAL\n    if( page1[18]>1 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>1 ){\n      goto page1_init_failed;\n    }\n#else\n    if( page1[18]>2 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>2 ){\n      goto page1_init_failed;\n    }\n\n    /* If the write version is set to 2, this database should be accessed\n    ** in WAL mode. If the log is not already open, open it now. Then \n    ** return SQLITE_OK and return without populating BtShared.pPage1.\n    ** The caller detects this and calls this function again. This is\n    ** required as the version of page 1 currently in the page1 buffer\n    ** may not be the latest version - there may be a newer one in the log\n    ** file.\n    */\n    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){\n      int isOpen = 0;\n      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);\n      if( rc!=SQLITE_OK ){\n        goto page1_init_failed;\n      }else{\n        setDefaultSyncFlag(pBt, SQLITE_DEFAULT_WAL_SYNCHRONOUS+1);\n        if( isOpen==0 ){\n          releasePageOne(pPage1);\n          return SQLITE_OK;\n        }\n      }\n      rc = SQLITE_NOTADB;\n    }else{\n      setDefaultSyncFlag(pBt, SQLITE_DEFAULT_SYNCHRONOUS+1);\n    }\n#endif\n\n    /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload\n    ** fractions and the leaf payload fraction values must be 64, 32, and 32.\n    **\n    ** The original design allowed these amounts to vary, but as of\n    ** version 3.6.0, we require them to be fixed.\n    */\n    if( memcmp(&page1[21], \"\\100\\040\\040\",3)!=0 ){\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pageSize = (page1[16]<<8) | (page1[17]<<16);\n    /* EVIDENCE-OF: R-25008-21688 The size of a page is a power of two\n    ** between 512 and 65536 inclusive. */\n    if( ((pageSize-1)&pageSize)!=0\n     || pageSize>SQLITE_MAX_PAGE_SIZE \n     || pageSize<=256 \n    ){\n      goto page1_init_failed;\n    }\n    assert( (pageSize & 7)==0 );\n    /* EVIDENCE-OF: R-59310-51205 The \"reserved space\" size in the 1-byte\n    ** integer at offset 20 is the number of bytes of space at the end of\n    ** each page to reserve for extensions. \n    **\n    ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n    ** determined by the one-byte unsigned integer found at an offset of 20\n    ** into the database file header. */\n    usableSize = pageSize - page1[20];\n    if( (u32)pageSize!=pBt->pageSize ){\n      /* After reading the first page of the database assuming a page size\n      ** of BtShared.pageSize, we have discovered that the page-size is\n      ** actually pageSize. Unlock the database, leave pBt->pPage1 at\n      ** zero and return SQLITE_OK. The caller will call this function\n      ** again with the correct page-size.\n      */\n      releasePageOne(pPage1);\n      pBt->usableSize = usableSize;\n      pBt->pageSize = pageSize;\n      freeTempSpace(pBt);\n      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,\n                                   pageSize-usableSize);\n      return rc;\n    }\n    if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to\n    ** be less than 480. In other words, if the page size is 512, then the\n    ** reserved space size cannot exceed 32. */\n    if( usableSize<480 ){\n      goto page1_init_failed;\n    }\n    pBt->pageSize = pageSize;\n    pBt->usableSize = usableSize;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);\n    pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);\n#endif\n  }\n\n  /* maxLocal is the maximum amount of payload to store locally for\n  ** a cell.  Make sure it is small enough so that at least minFanout\n  ** cells can will fit on one page.  We assume a 10-byte page header.\n  ** Besides the payload, the cell must store:\n  **     2-byte pointer to the cell\n  **     4-byte child pointer\n  **     9-byte nKey value\n  **     4-byte nData value\n  **     4-byte overflow page pointer\n  ** So a cell consists of a 2-byte pointer, a header which is as much as\n  ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow\n  ** page pointer.\n  */\n  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);\n  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);\n  pBt->maxLeaf = (u16)(pBt->usableSize - 35);\n  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);\n  if( pBt->maxLocal>127 ){\n    pBt->max1bytePayload = 127;\n  }else{\n    pBt->max1bytePayload = (u8)pBt->maxLocal;\n  }\n  assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );\n  pBt->pPage1 = pPage1;\n  pBt->nPage = nPage;\n  return SQLITE_OK;\n\npage1_init_failed:\n  releasePageOne(pPage1);\n  pBt->pPage1 = 0;\n  return rc;\n}\n\n#ifndef NDEBUG\n/*\n** Return the number of cursors open on pBt. This is for use\n** in assert() expressions, so it is only compiled if NDEBUG is not\n** defined.\n**\n** Only write cursors are counted if wrOnly is true.  If wrOnly is\n** false then all cursors are counted.\n**\n** For the purposes of this routine, a cursor is any cursor that\n** is capable of reading or writing to the database.  Cursors that\n** have been tripped into the CURSOR_FAULT state are not counted.\n*/\nstatic int countValidCursors(BtShared *pBt, int wrOnly){\n  BtCursor *pCur;\n  int r = 0;\n  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){\n    if( (wrOnly==0 || (pCur->curFlags & BTCF_WriteFlag)!=0)\n     && pCur->eState!=CURSOR_FAULT ) r++; \n  }\n  return r;\n}\n#endif\n\n/*\n** If there are no outstanding cursors and we are not in the middle\n** of a transaction but there is a read lock on the database, then\n** this routine unrefs the first page of the database file which \n** has the effect of releasing the read lock.\n**\n** If there is a transaction in progress, this routine is a no-op.\n*/\nstatic void unlockBtreeIfUnused(BtShared *pBt){\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );\n  if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){\n    MemPage *pPage1 = pBt->pPage1;\n    assert( pPage1->aData );\n    assert( sqlite3PagerRefcount(pBt->pPager)==1 );\n    pBt->pPage1 = 0;\n    releasePageOne(pPage1);\n  }\n}\n\n/*\n** If pBt points to an empty file then convert that empty file\n** into a new empty database by initializing the first page of\n** the database.\n*/\nstatic int newDatabase(BtShared *pBt){\n  MemPage *pP1;\n  unsigned char *data;\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->nPage>0 ){\n    return SQLITE_OK;\n  }\n  pP1 = pBt->pPage1;\n  assert( pP1!=0 );\n  data = pP1->aData;\n  rc = sqlite3PagerWrite(pP1->pDbPage);\n  if( rc ) return rc;\n  memcpy(data, zMagicHeader, sizeof(zMagicHeader));\n  assert( sizeof(zMagicHeader)==16 );\n  data[16] = (u8)((pBt->pageSize>>8)&0xff);\n  data[17] = (u8)((pBt->pageSize>>16)&0xff);\n  data[18] = 1;\n  data[19] = 1;\n  assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);\n  data[20] = (u8)(pBt->pageSize - pBt->usableSize);\n  data[21] = 64;\n  data[22] = 32;\n  data[23] = 32;\n  memset(&data[24], 0, 100-24);\n  zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );\n  pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );\n  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );\n  put4byte(&data[36 + 4*4], pBt->autoVacuum);\n  put4byte(&data[36 + 7*4], pBt->incrVacuum);\n#endif\n  pBt->nPage = 1;\n  data[31] = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the first page of the database file (creating a database\n** consisting of a single page and no schema objects). Return SQLITE_OK\n** if successful, or an SQLite error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  p->pBt->nPage = 0;\n  rc = newDatabase(p->pBt);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Attempt to start a new transaction. A write-transaction\n** is started if the second argument is nonzero, otherwise a read-\n** transaction.  If the second argument is 2 or more and exclusive\n** transaction is started, meaning that no other process is allowed\n** to access the database.  A preexisting transaction may not be\n** upgraded to exclusive by calling this routine a second time - the\n** exclusivity flag only works for a new transaction.\n**\n** A write-transaction must be started before attempting any \n** changes to the database.  None of the following routines \n** will work unless a transaction is started first:\n**\n**      sqlite3BtreeCreateTable()\n**      sqlite3BtreeCreateIndex()\n**      sqlite3BtreeClearTable()\n**      sqlite3BtreeDropTable()\n**      sqlite3BtreeInsert()\n**      sqlite3BtreeDelete()\n**      sqlite3BtreeUpdateMeta()\n**\n** If an initial attempt to acquire the lock fails because of lock contention\n** and the database was previously unlocked, then invoke the busy handler\n** if there is one.  But if there was previously a read-lock, do not\n** invoke the busy handler - just return SQLITE_BUSY.  SQLITE_BUSY is \n** returned when there is already a read-lock in order to avoid a deadlock.\n**\n** Suppose there are two processes A and B.  A has a read lock and B has\n** a reserved lock.  B tries to promote to exclusive but is blocked because\n** of A's read lock.  A tries to promote to reserved but is blocked by B.\n** One or the other of the two processes must give way or there can be\n** no progress.  By returning SQLITE_BUSY and not invoking the busy callback\n** when A already has a read lock, we encourage A to give up and let B\n** proceed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree *p, int wrflag){\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the btree is already in a write-transaction, or it\n  ** is already in a read-transaction and a read-transaction\n  ** is requested, this is a no-op.\n  */\n  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){\n    goto trans_begun;\n  }\n  assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );\n\n  /* Write transactions are not possible on a read-only database */\n  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){\n    rc = SQLITE_READONLY;\n    goto trans_begun;\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  {\n    sqlite3 *pBlock = 0;\n    /* If another database handle has already opened a write transaction \n    ** on this shared-btree structure and a second write transaction is\n    ** requested, return SQLITE_LOCKED.\n    */\n    if( (wrflag && pBt->inTransaction==TRANS_WRITE)\n     || (pBt->btsFlags & BTS_PENDING)!=0\n    ){\n      pBlock = pBt->pWriter->db;\n    }else if( wrflag>1 ){\n      BtLock *pIter;\n      for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n        if( pIter->pBtree!=p ){\n          pBlock = pIter->pBtree->db;\n          break;\n        }\n      }\n    }\n    if( pBlock ){\n      sqlite3ConnectionBlocked(p->db, pBlock);\n      rc = SQLITE_LOCKED_SHAREDCACHE;\n      goto trans_begun;\n    }\n  }\n#endif\n\n  /* Any read-only or read-write transaction implies a read-lock on \n  ** page 1. So if some other shared-cache client already has a write-lock \n  ** on page 1, the transaction cannot be opened. */\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  if( SQLITE_OK!=rc ) goto trans_begun;\n\n  pBt->btsFlags &= ~BTS_INITIALLY_EMPTY;\n  if( pBt->nPage==0 ) pBt->btsFlags |= BTS_INITIALLY_EMPTY;\n  do {\n    /* Call lockBtree() until either pBt->pPage1 is populated or\n    ** lockBtree() returns something other than SQLITE_OK. lockBtree()\n    ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after\n    ** reading page 1 it discovers that the page-size of the database \n    ** file is not pBt->pageSize. In this case lockBtree() will update\n    ** pBt->pageSize to the page-size of the file on disk.\n    */\n    while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );\n\n    if( rc==SQLITE_OK && wrflag ){\n      if( (pBt->btsFlags & BTS_READ_ONLY)!=0 ){\n        rc = SQLITE_READONLY;\n      }else{\n        rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));\n        if( rc==SQLITE_OK ){\n          rc = newDatabase(pBt);\n        }\n      }\n    }\n  \n    if( rc!=SQLITE_OK ){\n      unlockBtreeIfUnused(pBt);\n    }\n  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&\n          btreeInvokeBusyHandler(pBt) );\n\n  if( rc==SQLITE_OK ){\n    if( p->inTrans==TRANS_NONE ){\n      pBt->nTransaction++;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      if( p->sharable ){\n        assert( p->lock.pBtree==p && p->lock.iTable==1 );\n        p->lock.eLock = READ_LOCK;\n        p->lock.pNext = pBt->pLock;\n        pBt->pLock = &p->lock;\n      }\n#endif\n    }\n    p->inTrans = (wrflag?TRANS_WRITE:TRANS_READ);\n    if( p->inTrans>pBt->inTransaction ){\n      pBt->inTransaction = p->inTrans;\n    }\n    if( wrflag ){\n      MemPage *pPage1 = pBt->pPage1;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      assert( !pBt->pWriter );\n      pBt->pWriter = p;\n      pBt->btsFlags &= ~BTS_EXCLUSIVE;\n      if( wrflag>1 ) pBt->btsFlags |= BTS_EXCLUSIVE;\n#endif\n\n      /* If the db-size header field is incorrect (as it may be if an old\n      ** client has been writing the database file), update it now. Doing\n      ** this sooner rather than later means the database size can safely \n      ** re-read the database size from page 1 if a savepoint or transaction\n      ** rollback occurs within the transaction.\n      */\n      if( pBt->nPage!=get4byte(&pPage1->aData[28]) ){\n        rc = sqlite3PagerWrite(pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          put4byte(&pPage1->aData[28], pBt->nPage);\n        }\n      }\n    }\n  }\n\n\ntrans_begun:\n  if( rc==SQLITE_OK && wrflag ){\n    /* This call makes sure that the pager has the correct number of\n    ** open savepoints. If the second parameter is greater than 0 and\n    ** the sub-journal is not already open, then it will be opened here.\n    */\n    rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);\n  }\n\n  btreeIntegrity(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n\n/*\n** Set the pointer-map entries for all children of page pPage. Also, if\n** pPage contains cells that point to overflow pages, set the pointer\n** map entries for the overflow pages as well.\n*/\nstatic int setChildPtrmaps(MemPage *pPage){\n  int i;                             /* Counter variable */\n  int nCell;                         /* Number of cells in page pPage */\n  int rc;                            /* Return code */\n  BtShared *pBt = pPage->pBt;\n  Pgno pgno = pPage->pgno;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n  if( rc!=SQLITE_OK ) return rc;\n  nCell = pPage->nCell;\n\n  for(i=0; i<nCell; i++){\n    u8 *pCell = findCell(pPage, i);\n\n    ptrmapPutOvflPtr(pPage, pCell, &rc);\n\n    if( !pPage->leaf ){\n      Pgno childPgno = get4byte(pCell);\n      ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n    }\n  }\n\n  if( !pPage->leaf ){\n    Pgno childPgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n  }\n\n  return rc;\n}\n\n/*\n** Somewhere on pPage is a pointer to page iFrom.  Modify this pointer so\n** that it points to iTo. Parameter eType describes the type of pointer to\n** be modified, as  follows:\n**\n** PTRMAP_BTREE:     pPage is a btree-page. The pointer points at a child \n**                   page of pPage.\n**\n** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow\n**                   page pointed to by one of the cells on pPage.\n**\n** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next\n**                   overflow page in the list.\n*/\nstatic int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  if( eType==PTRMAP_OVERFLOW2 ){\n    /* The pointer is always the first 4 bytes of the page in this case.  */\n    if( get4byte(pPage->aData)!=iFrom ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    put4byte(pPage->aData, iTo);\n  }else{\n    int i;\n    int nCell;\n    int rc;\n\n    rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n    if( rc ) return rc;\n    nCell = pPage->nCell;\n\n    for(i=0; i<nCell; i++){\n      u8 *pCell = findCell(pPage, i);\n      if( eType==PTRMAP_OVERFLOW1 ){\n        CellInfo info;\n        pPage->xParseCell(pPage, pCell, &info);\n        if( info.nLocal<info.nPayload ){\n          if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){\n            return SQLITE_CORRUPT_PGNO(pPage->pgno);\n          }\n          if( iFrom==get4byte(pCell+info.nSize-4) ){\n            put4byte(pCell+info.nSize-4, iTo);\n            break;\n          }\n        }\n      }else{\n        if( get4byte(pCell)==iFrom ){\n          put4byte(pCell, iTo);\n          break;\n        }\n      }\n    }\n  \n    if( i==nCell ){\n      if( eType!=PTRMAP_BTREE || \n          get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);\n    }\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Move the open database page pDbPage to location iFreePage in the \n** database. The pDbPage reference remains valid.\n**\n** The isCommit flag indicates that there is no need to remember that\n** the journal needs to be sync()ed before database page pDbPage->pgno \n** can be written to. The caller has already promised not to write to that\n** page.\n*/\nstatic int relocatePage(\n  BtShared *pBt,           /* Btree */\n  MemPage *pDbPage,        /* Open page to move */\n  u8 eType,                /* Pointer map 'type' entry for pDbPage */\n  Pgno iPtrPage,           /* Pointer map 'page-no' entry for pDbPage */\n  Pgno iFreePage,          /* The location to move pDbPage to */\n  int isCommit             /* isCommit flag passed to sqlite3PagerMovepage */\n){\n  MemPage *pPtrPage;   /* The page that contains a pointer to pDbPage */\n  Pgno iDbPage = pDbPage->pgno;\n  Pager *pPager = pBt->pPager;\n  int rc;\n\n  assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || \n      eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pDbPage->pBt==pBt );\n\n  /* Move page iDbPage from its current location to page number iFreePage */\n  TRACE((\"AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\\n\", \n      iDbPage, iFreePage, iPtrPage, eType));\n  rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  pDbPage->pgno = iFreePage;\n\n  /* If pDbPage was a btree-page, then it may have child pages and/or cells\n  ** that point to overflow pages. The pointer map entries for all these\n  ** pages need to be changed.\n  **\n  ** If pDbPage is an overflow page, then the first 4 bytes may store a\n  ** pointer to a subsequent overflow page. If this is the case, then\n  ** the pointer map needs to be updated for the subsequent overflow page.\n  */\n  if( eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ){\n    rc = setChildPtrmaps(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }else{\n    Pgno nextOvfl = get4byte(pDbPage->aData);\n    if( nextOvfl!=0 ){\n      ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  /* Fix the database pointer on page iPtrPage that pointed at iDbPage so\n  ** that it points at iFreePage. Also fix the pointer map entry for\n  ** iPtrPage.\n  */\n  if( eType!=PTRMAP_ROOTPAGE ){\n    rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    rc = sqlite3PagerWrite(pPtrPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(pPtrPage);\n      return rc;\n    }\n    rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);\n    releasePage(pPtrPage);\n    if( rc==SQLITE_OK ){\n      ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);\n    }\n  }\n  return rc;\n}\n\n/* Forward declaration required by incrVacuumStep(). */\nstatic int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);\n\n/*\n** Perform a single step of an incremental-vacuum. If successful, return\n** SQLITE_OK. If there is no work to do (and therefore no point in \n** calling this function again), return SQLITE_DONE. Or, if an error \n** occurs, return some other error code.\n**\n** More specifically, this function attempts to re-organize the database so \n** that the last page of the file currently in use is no longer in use.\n**\n** Parameter nFin is the number of pages that this database would contain\n** were this function called until it returns SQLITE_DONE.\n**\n** If the bCommit parameter is non-zero, this function assumes that the \n** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE \n** or an error. bCommit is passed true for an auto-vacuum-on-commit \n** operation, or false for an incremental vacuum.\n*/\nstatic int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){\n  Pgno nFreeList;           /* Number of pages still on the free-list */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( iLastPg>nFin );\n\n  if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){\n    u8 eType;\n    Pgno iPtrPage;\n\n    nFreeList = get4byte(&pBt->pPage1->aData[36]);\n    if( nFreeList==0 ){\n      return SQLITE_DONE;\n    }\n\n    rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( eType==PTRMAP_ROOTPAGE ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    if( eType==PTRMAP_FREEPAGE ){\n      if( bCommit==0 ){\n        /* Remove the page from the files free-list. This is not required\n        ** if bCommit is non-zero. In that case, the free-list will be\n        ** truncated to zero after this function returns, so it doesn't \n        ** matter if it still contains some garbage entries.\n        */\n        Pgno iFreePg;\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        assert( iFreePg==iLastPg );\n        releasePage(pFreePg);\n      }\n    } else {\n      Pgno iFreePg;             /* Index of free page to move pLastPg to */\n      MemPage *pLastPg;\n      u8 eMode = BTALLOC_ANY;   /* Mode parameter for allocateBtreePage() */\n      Pgno iNear = 0;           /* nearby parameter for allocateBtreePage() */\n\n      rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* If bCommit is zero, this loop runs exactly once and page pLastPg\n      ** is swapped with the first free page pulled off the free list.\n      **\n      ** On the other hand, if bCommit is greater than zero, then keep\n      ** looping until a free-page located within the first nFin pages\n      ** of the file is found.\n      */\n      if( bCommit==0 ){\n        eMode = BTALLOC_LE;\n        iNear = nFin;\n      }\n      do {\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode);\n        if( rc!=SQLITE_OK ){\n          releasePage(pLastPg);\n          return rc;\n        }\n        releasePage(pFreePg);\n      }while( bCommit && iFreePg>nFin );\n      assert( iFreePg<iLastPg );\n      \n      rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, bCommit);\n      releasePage(pLastPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  if( bCommit==0 ){\n    do {\n      iLastPg--;\n    }while( iLastPg==PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg) );\n    pBt->bDoTruncate = 1;\n    pBt->nPage = iLastPg;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The database opened by the first argument is an auto-vacuum database\n** nOrig pages in size containing nFree free pages. Return the expected \n** size of the database in pages following an auto-vacuum operation.\n*/\nstatic Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){\n  int nEntry;                     /* Number of entries on one ptrmap page */\n  Pgno nPtrmap;                   /* Number of PtrMap pages to be freed */\n  Pgno nFin;                      /* Return value */\n\n  nEntry = pBt->usableSize/5;\n  nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry;\n  nFin = nOrig - nFree - nPtrmap;\n  if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n  while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n\n  return nFin;\n}\n\n/*\n** A write-transaction must be opened before calling this function.\n** It performs a single unit of work towards an incremental vacuum.\n**\n** If the incremental vacuum is finished after this function has run,\n** SQLITE_DONE is returned. If it is not finished, but no error occurred,\n** SQLITE_OK is returned. Otherwise an SQLite error code. \n*/\nSQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){\n  int rc;\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );\n  if( !pBt->autoVacuum ){\n    rc = SQLITE_DONE;\n  }else{\n    Pgno nOrig = btreePagecount(pBt);\n    Pgno nFree = get4byte(&pBt->pPage1->aData[36]);\n    Pgno nFin = finalDbSize(pBt, nOrig, nFree);\n\n    if( nOrig<nFin ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else if( nFree>0 ){\n      rc = saveAllCursors(pBt, 0, 0);\n      if( rc==SQLITE_OK ){\n        invalidateAllOverflowCache(pBt);\n        rc = incrVacuumStep(pBt, nFin, nOrig, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        put4byte(&pBt->pPage1->aData[28], pBt->nPage);\n      }\n    }else{\n      rc = SQLITE_DONE;\n    }\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine is called prior to sqlite3PagerCommit when a transaction\n** is committed for an auto-vacuum database.\n**\n** If SQLITE_OK is returned, then *pnTrunc is set to the number of pages\n** the database file should be truncated to during the commit process. \n** i.e. the database has been reorganized so that only the first *pnTrunc\n** pages are in use.\n*/\nstatic int autoVacuumCommit(BtShared *pBt){\n  int rc = SQLITE_OK;\n  Pager *pPager = pBt->pPager;\n  VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  invalidateAllOverflowCache(pBt);\n  assert(pBt->autoVacuum);\n  if( !pBt->incrVacuum ){\n    Pgno nFin;         /* Number of pages in database after autovacuuming */\n    Pgno nFree;        /* Number of pages on the freelist initially */\n    Pgno iFree;        /* The next page to be freed */\n    Pgno nOrig;        /* Database size before freeing */\n\n    nOrig = btreePagecount(pBt);\n    if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){\n      /* It is not possible to create a database for which the final page\n      ** is either a pointer-map page or the pending-byte page. If one\n      ** is encountered, this indicates corruption.\n      */\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    nFree = get4byte(&pBt->pPage1->aData[36]);\n    nFin = finalDbSize(pBt, nOrig, nFree);\n    if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT;\n    if( nFin<nOrig ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){\n      rc = incrVacuumStep(pBt, nFin, iFree, 1);\n    }\n    if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){\n      rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n      put4byte(&pBt->pPage1->aData[32], 0);\n      put4byte(&pBt->pPage1->aData[36], 0);\n      put4byte(&pBt->pPage1->aData[28], nFin);\n      pBt->bDoTruncate = 1;\n      pBt->nPage = nFin;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3PagerRollback(pPager);\n    }\n  }\n\n  assert( nRef>=sqlite3PagerRefcount(pPager) );\n  return rc;\n}\n\n#else /* ifndef SQLITE_OMIT_AUTOVACUUM */\n# define setChildPtrmaps(x) SQLITE_OK\n#endif\n\n/*\n** This routine does the first phase of a two-phase commit.  This routine\n** causes a rollback journal to be created (if it does not already exist)\n** and populated with enough information so that if a power loss occurs\n** the database can be restored to its original state by playing back\n** the journal.  Then the contents of the journal are flushed out to\n** the disk.  After the journal is safely on oxide, the changes to the\n** database are written into the database file and flushed to oxide.\n** At the end of this call, the rollback journal still exists on the\n** disk and we are still holding all locks, so the transaction has not\n** committed.  See sqlite3BtreeCommitPhaseTwo() for the second phase of the\n** commit process.\n**\n** This call is a no-op if no write-transaction is currently active on pBt.\n**\n** Otherwise, sync the database file for the btree pBt. zMaster points to\n** the name of a master journal file that should be written into the\n** individual journal file, or is NULL, indicating no master journal file \n** (single database transaction).\n**\n** When this is called, the master journal should already have been\n** created, populated with this journal pointer and synced to disk.\n**\n** Once this is routine has returned, the only thing required to commit\n** the write-transaction for this database file is to delete the journal.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){\n  int rc = SQLITE_OK;\n  if( p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      rc = autoVacuumCommit(pBt);\n      if( rc!=SQLITE_OK ){\n        sqlite3BtreeLeave(p);\n        return rc;\n      }\n    }\n    if( pBt->bDoTruncate ){\n      sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage);\n    }\n#endif\n    rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()\n** at the conclusion of a transaction.\n*/\nstatic void btreeEndTransaction(Btree *p){\n  BtShared *pBt = p->pBt;\n  sqlite3 *db = p->db;\n  assert( sqlite3BtreeHoldsMutex(p) );\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  pBt->bDoTruncate = 0;\n#endif\n  if( p->inTrans>TRANS_NONE && db->nVdbeRead>1 ){\n    /* If there are other active statements that belong to this database\n    ** handle, downgrade to a read-only transaction. The other statements\n    ** may still be reading from the database.  */\n    downgradeAllSharedCacheTableLocks(p);\n    p->inTrans = TRANS_READ;\n  }else{\n    /* If the handle had any kind of transaction open, decrement the \n    ** transaction count of the shared btree. If the transaction count \n    ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused()\n    ** call below will unlock the pager.  */\n    if( p->inTrans!=TRANS_NONE ){\n      clearAllSharedCacheTableLocks(p);\n      pBt->nTransaction--;\n      if( 0==pBt->nTransaction ){\n        pBt->inTransaction = TRANS_NONE;\n      }\n    }\n\n    /* Set the current transaction state to TRANS_NONE and unlock the \n    ** pager if this call closed the only read or write transaction.  */\n    p->inTrans = TRANS_NONE;\n    unlockBtreeIfUnused(pBt);\n  }\n\n  btreeIntegrity(p);\n}\n\n/*\n** Commit the transaction currently in progress.\n**\n** This routine implements the second phase of a 2-phase commit.  The\n** sqlite3BtreeCommitPhaseOne() routine does the first phase and should\n** be invoked prior to calling this routine.  The sqlite3BtreeCommitPhaseOne()\n** routine did all the work of writing information out to disk and flushing the\n** contents so that they are written onto the disk platter.  All this\n** routine has to do is delete or truncate or zero the header in the\n** the rollback journal (which causes the transaction to commit) and\n** drop locks.\n**\n** Normally, if an error occurs while the pager layer is attempting to \n** finalize the underlying journal file, this function returns an error and\n** the upper layer will attempt a rollback. However, if the second argument\n** is non-zero then this b-tree transaction is part of a multi-file \n** transaction. In this case, the transaction has already been committed \n** (by deleting a master journal file) and the caller will ignore this \n** functions return code. So, even if an error occurs in the pager layer,\n** reset the b-tree objects internal state to indicate that the write\n** transaction has been closed. This is quite safe, as the pager will have\n** transitioned to the error state.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){\n\n  if( p->inTrans==TRANS_NONE ) return SQLITE_OK;\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the handle has a write-transaction open, commit the shared-btrees \n  ** transaction and set the shared state to TRANS_READ.\n  */\n  if( p->inTrans==TRANS_WRITE ){\n    int rc;\n    BtShared *pBt = p->pBt;\n    assert( pBt->inTransaction==TRANS_WRITE );\n    assert( pBt->nTransaction>0 );\n    rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);\n    if( rc!=SQLITE_OK && bCleanup==0 ){\n      sqlite3BtreeLeave(p);\n      return rc;\n    }\n    p->iDataVersion--;  /* Compensate for pPager->iDataVersion++; */\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Do both phases of a commit.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCommit(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = sqlite3BtreeCommitPhaseOne(p, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeCommitPhaseTwo(p, 0);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine sets the state to CURSOR_FAULT and the error\n** code to errCode for every cursor on any BtShared that pBtree\n** references.  Or if the writeOnly flag is set to 1, then only\n** trip write cursors and leave read cursors unchanged.\n**\n** Every cursor is a candidate to be tripped, including cursors\n** that belong to other database connections that happen to be\n** sharing the cache with pBtree.\n**\n** This routine gets called when a rollback occurs. If the writeOnly\n** flag is true, then only write-cursors need be tripped - read-only\n** cursors save their current positions so that they may continue \n** following the rollback. Or, if writeOnly is false, all cursors are \n** tripped. In general, writeOnly is false if the transaction being\n** rolled back modified the database schema. In this case b-tree root\n** pages may be moved or deleted from the database altogether, making\n** it unsafe for read cursors to continue.\n**\n** If the writeOnly flag is true and an error is encountered while \n** saving the current position of a read-only cursor, all cursors, \n** including all read-cursors are tripped.\n**\n** SQLITE_OK is returned if successful, or if an error occurs while\n** saving a cursor position, an SQLite error code.\n*/\nSQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){\n  BtCursor *p;\n  int rc = SQLITE_OK;\n\n  assert( (writeOnly==0 || writeOnly==1) && BTCF_WriteFlag==1 );\n  if( pBtree ){\n    sqlite3BtreeEnter(pBtree);\n    for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n      if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){\n        if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n          rc = saveCursorPosition(p);\n          if( rc!=SQLITE_OK ){\n            (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);\n            break;\n          }\n        }\n      }else{\n        sqlite3BtreeClearCursor(p);\n        p->eState = CURSOR_FAULT;\n        p->skipNext = errCode;\n      }\n      btreeReleaseAllCursorPages(p);\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  return rc;\n}\n\n/*\n** Rollback the transaction in progress.\n**\n** If tripCode is not SQLITE_OK then cursors will be invalidated (tripped).\n** Only write cursors are tripped if writeOnly is true but all cursors are\n** tripped if writeOnly is false.  Any attempt to use\n** a tripped cursor will result in an error.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nSQLITE_PRIVATE int sqlite3BtreeRollback(Btree *p, int tripCode, int writeOnly){\n  int rc;\n  BtShared *pBt = p->pBt;\n  MemPage *pPage1;\n\n  assert( writeOnly==1 || writeOnly==0 );\n  assert( tripCode==SQLITE_ABORT_ROLLBACK || tripCode==SQLITE_OK );\n  sqlite3BtreeEnter(p);\n  if( tripCode==SQLITE_OK ){\n    rc = tripCode = saveAllCursors(pBt, 0, 0);\n    if( rc ) writeOnly = 0;\n  }else{\n    rc = SQLITE_OK;\n  }\n  if( tripCode ){\n    int rc2 = sqlite3BtreeTripAllCursors(p, tripCode, writeOnly);\n    assert( rc==SQLITE_OK || (writeOnly==0 && rc2==SQLITE_OK) );\n    if( rc2!=SQLITE_OK ) rc = rc2;\n  }\n  btreeIntegrity(p);\n\n  if( p->inTrans==TRANS_WRITE ){\n    int rc2;\n\n    assert( TRANS_WRITE==pBt->inTransaction );\n    rc2 = sqlite3PagerRollback(pBt->pPager);\n    if( rc2!=SQLITE_OK ){\n      rc = rc2;\n    }\n\n    /* The rollback may have destroyed the pPage1->aData value.  So\n    ** call btreeGetPage() on page 1 again to make\n    ** sure pPage1->aData is set correctly. */\n    if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){\n      int nPage = get4byte(28+(u8*)pPage1->aData);\n      testcase( nPage==0 );\n      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);\n      testcase( pBt->nPage!=nPage );\n      pBt->nPage = nPage;\n      releasePageOne(pPage1);\n    }\n    assert( countValidCursors(pBt, 1)==0 );\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Start a statement subtransaction. The subtransaction can be rolled\n** back independently of the main transaction. You must start a transaction \n** before starting a subtransaction. The subtransaction is ended automatically \n** if the main transaction commits or rolls back.\n**\n** Statement subtransactions are used around individual SQL statements\n** that are contained within a BEGIN...COMMIT block.  If a constraint\n** error occurs within the statement, the effect of that one statement\n** can be rolled back without having to rollback the entire transaction.\n**\n** A statement sub-transaction is implemented as an anonymous savepoint. The\n** value passed as the second parameter is the total number of savepoints,\n** including the new anonymous savepoint, open on the B-Tree. i.e. if there\n** are no active savepoints and no other statement-transactions open,\n** iStatement is 1. This anonymous savepoint can be released or rolled back\n** using the sqlite3BtreeSavepoint() function.\n*/\nSQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree *p, int iStatement){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( iStatement>0 );\n  assert( iStatement>p->db->nSavepoint );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  /* At the pager level, a statement transaction is a savepoint with\n  ** an index greater than all savepoints created explicitly using\n  ** SQL statements. It is illegal to open, release or rollback any\n  ** such savepoints while the statement transaction savepoint is active.\n  */\n  rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** The second argument to this function, op, is always SAVEPOINT_ROLLBACK\n** or SAVEPOINT_RELEASE. This function either releases or rolls back the\n** savepoint identified by parameter iSavepoint, depending on the value \n** of op.\n**\n** Normally, iSavepoint is greater than or equal to zero. However, if op is\n** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the \n** contents of the entire transaction are rolled back. This is different\n** from a normal transaction rollback, as no locks are released and the\n** transaction remains open.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n  if( p && p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n    assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );\n    sqlite3BtreeEnter(p);\n    if( op==SAVEPOINT_ROLLBACK ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){\n        pBt->nPage = 0;\n      }\n      rc = newDatabase(pBt);\n      pBt->nPage = get4byte(28 + pBt->pPage1->aData);\n\n      /* The database size was written into the offset 28 of the header\n      ** when the transaction started, so we know that the value at offset\n      ** 28 is nonzero. */\n      assert( pBt->nPage>0 );\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Create a new cursor for the BTree whose root is on the page\n** iTable. If a read-only cursor is requested, it is assumed that\n** the caller already has at least a read-only transaction open\n** on the database already. If a write-cursor is requested, then\n** the caller is assumed to have an open write transaction.\n**\n** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only\n** be used for reading.  If the BTREE_WRCSR bit is set, then the cursor\n** can be used for reading or for writing if other conditions for writing\n** are also met.  These are the conditions that must be met in order\n** for writing to be allowed:\n**\n** 1:  The cursor must have been opened with wrFlag containing BTREE_WRCSR\n**\n** 2:  Other database connections that share the same pager cache\n**     but which are not in the READ_UNCOMMITTED state may not have\n**     cursors open with wrFlag==0 on the same table.  Otherwise\n**     the changes made by this write cursor would be visible to\n**     the read cursors in the other database connection.\n**\n** 3:  The database must be writable (not on read-only media)\n**\n** 4:  There must be an active transaction.\n**\n** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR\n** is set.  If FORDELETE is set, that is a hint to the implementation that\n** this cursor will only be used to seek to and delete entries of an index\n** as part of a larger DELETE statement.  The FORDELETE hint is not used by\n** this implementation.  But in a hypothetical alternative storage engine \n** in which index entries are automatically deleted when corresponding table\n** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE\n** operations on this cursor can be no-ops and all READ operations can \n** return a null row (2-bytes: 0x01 0x00).\n**\n** No checking is done to make sure that page iTable really is the\n** root page of a b-tree.  If it is not, then the cursor acquired\n** will not work correctly.\n**\n** It is assumed that the sqlite3BtreeCursorZero() has been called\n** on pCur to initialize the memory space prior to invoking this routine.\n*/\nstatic int btreeCursor(\n  Btree *p,                              /* The btree */\n  int iTable,                            /* Root page of table to open */\n  int wrFlag,                            /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,              /* First arg to comparison function */\n  BtCursor *pCur                         /* Space for new cursor */\n){\n  BtShared *pBt = p->pBt;                /* Shared b-tree handle */\n  BtCursor *pX;                          /* Looping over other all cursors */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( wrFlag==0 \n       || wrFlag==BTREE_WRCSR \n       || wrFlag==(BTREE_WRCSR|BTREE_FORDELETE) \n  );\n\n  /* The following assert statements verify that if this is a sharable \n  ** b-tree database, the connection is holding the required table locks, \n  ** and that no other connection has any open cursor that conflicts with \n  ** this lock.  */\n  assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) );\n  assert( wrFlag==0 || !hasReadConflicts(p, iTable) );\n\n  /* Assert that the caller has opened the required transaction. */\n  assert( p->inTrans>TRANS_NONE );\n  assert( wrFlag==0 || p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1 && pBt->pPage1->aData );\n  assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n  if( wrFlag ){\n    allocateTempSpace(pBt);\n    if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  if( iTable==1 && btreePagecount(pBt)==0 ){\n    assert( wrFlag==0 );\n    iTable = 0;\n  }\n\n  /* Now that no other errors can occur, finish filling in the BtCursor\n  ** variables and link the cursor into the BtShared list.  */\n  pCur->pgnoRoot = (Pgno)iTable;\n  pCur->iPage = -1;\n  pCur->pKeyInfo = pKeyInfo;\n  pCur->pBtree = p;\n  pCur->pBt = pBt;\n  pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;\n  pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;\n  /* If there are two or more cursors on the same btree, then all such\n  ** cursors *must* have the BTCF_Multiple flag set. */\n  for(pX=pBt->pCursor; pX; pX=pX->pNext){\n    if( pX->pgnoRoot==(Pgno)iTable ){\n      pX->curFlags |= BTCF_Multiple;\n      pCur->curFlags |= BTCF_Multiple;\n    }\n  }\n  pCur->pNext = pBt->pCursor;\n  pBt->pCursor = pCur;\n  pCur->eState = CURSOR_INVALID;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCursor(\n  Btree *p,                                   /* The btree */\n  int iTable,                                 /* Root page of table to open */\n  int wrFlag,                                 /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,                   /* First arg to xCompare() */\n  BtCursor *pCur                              /* Write new cursor here */\n){\n  int rc;\n  if( iTable<1 ){\n    rc = SQLITE_CORRUPT_BKPT;\n  }else{\n    sqlite3BtreeEnter(p);\n    rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Return the size of a BtCursor object in bytes.\n**\n** This interfaces is needed so that users of cursors can preallocate\n** sufficient storage to hold a cursor.  The BtCursor object is opaque\n** to users so they cannot do the sizeof() themselves - they must call\n** this routine.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorSize(void){\n  return ROUND8(sizeof(BtCursor));\n}\n\n/*\n** Initialize memory that will be converted into a BtCursor object.\n**\n** The simple approach here would be to memset() the entire object\n** to zero.  But it turns out that the apPage[] and aiIdx[] arrays\n** do not need to be zeroed and they are large, so we can save a lot\n** of run-time by skipping the initialization of those elements.\n*/\nSQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor *p){\n  memset(p, 0, offsetof(BtCursor, iPage));\n}\n\n/*\n** Close a cursor.  The read lock on the database file is released\n** when the last cursor is closed.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){\n  Btree *pBtree = pCur->pBtree;\n  if( pBtree ){\n    BtShared *pBt = pCur->pBt;\n    sqlite3BtreeEnter(pBtree);\n    assert( pBt->pCursor!=0 );\n    if( pBt->pCursor==pCur ){\n      pBt->pCursor = pCur->pNext;\n    }else{\n      BtCursor *pPrev = pBt->pCursor;\n      do{\n        if( pPrev->pNext==pCur ){\n          pPrev->pNext = pCur->pNext;\n          break;\n        }\n        pPrev = pPrev->pNext;\n      }while( ALWAYS(pPrev) );\n    }\n    btreeReleaseAllCursorPages(pCur);\n    unlockBtreeIfUnused(pBt);\n    sqlite3_free(pCur->aOverflow);\n    sqlite3_free(pCur->pKey);\n    sqlite3BtreeLeave(pBtree);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the BtCursor* given in the argument has a valid\n** BtCursor.info structure.  If it is not already valid, call\n** btreeParseCell() to fill it in.\n**\n** BtCursor.info is a cache of the information in the current cell.\n** Using this cache reduces the number of calls to btreeParseCell().\n*/\n#ifndef NDEBUG\n  static void assertCellInfo(BtCursor *pCur){\n    CellInfo info;\n    memset(&info, 0, sizeof(info));\n    btreeParseCell(pCur->pPage, pCur->ix, &info);\n    assert( CORRUPT_DB || memcmp(&info, &pCur->info, sizeof(info))==0 );\n  }\n#else\n  #define assertCellInfo(x)\n#endif\nstatic SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){\n  if( pCur->info.nSize==0 ){\n    pCur->curFlags |= BTCF_ValidNKey;\n    btreeParseCell(pCur->pPage,pCur->ix,&pCur->info);\n  }else{\n    assertCellInfo(pCur);\n  }\n}\n\n#ifndef NDEBUG  /* The next routine used only within assert() statements */\n/*\n** Return true if the given BtCursor is valid.  A valid cursor is one\n** that is currently pointing to a row in a (non-empty) table.\n** This is a verification routine is used only within assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor *pCur){\n  return pCur && pCur->eState==CURSOR_VALID;\n}\n#endif /* NDEBUG */\nSQLITE_PRIVATE int sqlite3BtreeCursorIsValidNN(BtCursor *pCur){\n  assert( pCur!=0 );\n  return pCur->eState==CURSOR_VALID;\n}\n\n/*\n** Return the value of the integer key or \"rowid\" for a table btree.\n** This routine is only valid for a cursor that is pointing into a\n** ordinary table btree.  If the cursor points to an index btree or\n** is invalid, the result of this routine is undefined.\n*/\nSQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->curIntKey );\n  getCellInfo(pCur);\n  return pCur->info.nKey;\n}\n\n/*\n** Return the number of bytes of payload for the entry that pCur is\n** currently pointing to.  For table btrees, this will be the amount\n** of data.  For index btrees, this will be the size of the key.\n**\n** The caller must guarantee that the cursor is pointing to a non-NULL\n** valid entry.  In other words, the calling procedure must guarantee\n** that the cursor has Cursor.eState==CURSOR_VALID.\n*/\nSQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  getCellInfo(pCur);\n  return pCur->info.nPayload;\n}\n\n/*\n** Given the page number of an overflow page in the database (parameter\n** ovfl), this function finds the page number of the next page in the \n** linked list of overflow pages. If possible, it uses the auto-vacuum\n** pointer-map data instead of reading the content of page ovfl to do so. \n**\n** If an error occurs an SQLite error code is returned. Otherwise:\n**\n** The page number of the next overflow page in the linked list is \n** written to *pPgnoNext. If page ovfl is the last page in its linked \n** list, *pPgnoNext is set to zero. \n**\n** If ppPage is not NULL, and a reference to the MemPage object corresponding\n** to page number pOvfl was obtained, then *ppPage is set to point to that\n** reference. It is the responsibility of the caller to call releasePage()\n** on *ppPage to free the reference. In no reference was obtained (because\n** the pointer-map was used to obtain the value for *pPgnoNext), then\n** *ppPage is set to zero.\n*/\nstatic int getOverflowPage(\n  BtShared *pBt,               /* The database file */\n  Pgno ovfl,                   /* Current overflow page number */\n  MemPage **ppPage,            /* OUT: MemPage handle (may be NULL) */\n  Pgno *pPgnoNext              /* OUT: Next overflow page number */\n){\n  Pgno next = 0;\n  MemPage *pPage = 0;\n  int rc = SQLITE_OK;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert(pPgnoNext);\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* Try to find the next page in the overflow list using the\n  ** autovacuum pointer-map pages. Guess that the next page in \n  ** the overflow list is page number (ovfl+1). If that guess turns \n  ** out to be wrong, fall back to loading the data of page \n  ** number ovfl to determine the next page number.\n  */\n  if( pBt->autoVacuum ){\n    Pgno pgno;\n    Pgno iGuess = ovfl+1;\n    u8 eType;\n\n    while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){\n      iGuess++;\n    }\n\n    if( iGuess<=btreePagecount(pBt) ){\n      rc = ptrmapGet(pBt, iGuess, &eType, &pgno);\n      if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){\n        next = iGuess;\n        rc = SQLITE_DONE;\n      }\n    }\n  }\n#endif\n\n  assert( next==0 || rc==SQLITE_DONE );\n  if( rc==SQLITE_OK ){\n    rc = btreeGetPage(pBt, ovfl, &pPage, (ppPage==0) ? PAGER_GET_READONLY : 0);\n    assert( rc==SQLITE_OK || pPage==0 );\n    if( rc==SQLITE_OK ){\n      next = get4byte(pPage->aData);\n    }\n  }\n\n  *pPgnoNext = next;\n  if( ppPage ){\n    *ppPage = pPage;\n  }else{\n    releasePage(pPage);\n  }\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/*\n** Copy data from a buffer to a page, or from a page to a buffer.\n**\n** pPayload is a pointer to data stored on database page pDbPage.\n** If argument eOp is false, then nByte bytes of data are copied\n** from pPayload to the buffer pointed at by pBuf. If eOp is true,\n** then sqlite3PagerWrite() is called on pDbPage and nByte bytes\n** of data are copied from the buffer pBuf to pPayload.\n**\n** SQLITE_OK is returned on success, otherwise an error code.\n*/\nstatic int copyPayload(\n  void *pPayload,           /* Pointer to page data */\n  void *pBuf,               /* Pointer to buffer */\n  int nByte,                /* Number of bytes to copy */\n  int eOp,                  /* 0 -> copy from page, 1 -> copy to page */\n  DbPage *pDbPage           /* Page containing pPayload */\n){\n  if( eOp ){\n    /* Copy data from buffer to page (a write operation) */\n    int rc = sqlite3PagerWrite(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    memcpy(pPayload, pBuf, nByte);\n  }else{\n    /* Copy data from page to buffer (a read operation) */\n    memcpy(pBuf, pPayload, nByte);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is used to read or overwrite payload information\n** for the entry that the pCur cursor is pointing to. The eOp\n** argument is interpreted as follows:\n**\n**   0: The operation is a read. Populate the overflow cache.\n**   1: The operation is a write. Populate the overflow cache.\n**\n** A total of \"amt\" bytes are read or written beginning at \"offset\".\n** Data is read to or from the buffer pBuf.\n**\n** The content being read or written might appear on the main page\n** or be scattered out on multiple overflow pages.\n**\n** If the current cursor entry uses one or more overflow pages\n** this function may allocate space for and lazily populate\n** the overflow page-list cache array (BtCursor.aOverflow). \n** Subsequent calls use this cache to make seeking to the supplied offset \n** more efficient.\n**\n** Once an overflow page-list cache has been allocated, it must be\n** invalidated if some other cursor writes to the same table, or if\n** the cursor is moved to a different row. Additionally, in auto-vacuum\n** mode, the following events may invalidate an overflow page-list cache.\n**\n**   * An incremental vacuum,\n**   * A commit in auto_vacuum=\"full\" mode,\n**   * Creating a table (may require moving an overflow page).\n*/\nstatic int accessPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 offset,          /* Begin reading this far into payload */\n  u32 amt,             /* Read this many bytes */\n  unsigned char *pBuf, /* Write the bytes into this buffer */ \n  int eOp              /* zero to read. non-zero to write. */\n){\n  unsigned char *aPayload;\n  int rc = SQLITE_OK;\n  int iIdx = 0;\n  MemPage *pPage = pCur->pPage;               /* Btree page of current entry */\n  BtShared *pBt = pCur->pBt;                  /* Btree this cursor belongs to */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n  unsigned char * const pBufStart = pBuf;     /* Start of original out buffer */\n#endif\n\n  assert( pPage );\n  assert( eOp==0 || eOp==1 );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->ix<pPage->nCell );\n  assert( cursorHoldsMutex(pCur) );\n\n  getCellInfo(pCur);\n  aPayload = pCur->info.pPayload;\n  assert( offset+amt <= pCur->info.nPayload );\n\n  assert( aPayload > pPage->aData );\n  if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){\n    /* Trying to read or write past the end of the data is an error.  The\n    ** conditional above is really:\n    **    &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]\n    ** but is recast into its current form to avoid integer overflow problems\n    */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n\n  /* Check if data must be read/written to/from the btree page itself. */\n  if( offset<pCur->info.nLocal ){\n    int a = amt;\n    if( a+offset>pCur->info.nLocal ){\n      a = pCur->info.nLocal - offset;\n    }\n    rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);\n    offset = 0;\n    pBuf += a;\n    amt -= a;\n  }else{\n    offset -= pCur->info.nLocal;\n  }\n\n\n  if( rc==SQLITE_OK && amt>0 ){\n    const u32 ovflSize = pBt->usableSize - 4;  /* Bytes content per ovfl page */\n    Pgno nextPage;\n\n    nextPage = get4byte(&aPayload[pCur->info.nLocal]);\n\n    /* If the BtCursor.aOverflow[] has not been allocated, allocate it now.\n    **\n    ** The aOverflow[] array is sized at one entry for each overflow page\n    ** in the overflow chain. The page number of the first overflow page is\n    ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array\n    ** means \"not yet known\" (the cache is lazily populated).\n    */\n    if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){\n      int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;\n      if( nOvfl>pCur->nOvflAlloc ){\n        Pgno *aNew = (Pgno*)sqlite3Realloc(\n            pCur->aOverflow, nOvfl*2*sizeof(Pgno)\n        );\n        if( aNew==0 ){\n          return SQLITE_NOMEM_BKPT;\n        }else{\n          pCur->nOvflAlloc = nOvfl*2;\n          pCur->aOverflow = aNew;\n        }\n      }\n      memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));\n      pCur->curFlags |= BTCF_ValidOvfl;\n    }else{\n      /* If the overflow page-list cache has been allocated and the\n      ** entry for the first required overflow page is valid, skip\n      ** directly to it.\n      */\n      if( pCur->aOverflow[offset/ovflSize] ){\n        iIdx = (offset/ovflSize);\n        nextPage = pCur->aOverflow[iIdx];\n        offset = (offset%ovflSize);\n      }\n    }\n\n    assert( rc==SQLITE_OK && amt>0 );\n    while( nextPage ){\n      /* If required, populate the overflow page-list cache. */\n      assert( pCur->aOverflow[iIdx]==0\n              || pCur->aOverflow[iIdx]==nextPage\n              || CORRUPT_DB );\n      pCur->aOverflow[iIdx] = nextPage;\n\n      if( offset>=ovflSize ){\n        /* The only reason to read this page is to obtain the page\n        ** number for the next page in the overflow chain. The page\n        ** data is not required. So first try to lookup the overflow\n        ** page-list cache, if any, then fall back to the getOverflowPage()\n        ** function.\n        */\n        assert( pCur->curFlags & BTCF_ValidOvfl );\n        assert( pCur->pBtree->db==pBt->db );\n        if( pCur->aOverflow[iIdx+1] ){\n          nextPage = pCur->aOverflow[iIdx+1];\n        }else{\n          rc = getOverflowPage(pBt, nextPage, 0, &nextPage);\n        }\n        offset -= ovflSize;\n      }else{\n        /* Need to read this page properly. It contains some of the\n        ** range of data that is being read (eOp==0) or written (eOp!=0).\n        */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        sqlite3_file *fd;      /* File from which to do direct overflow read */\n#endif\n        int a = amt;\n        if( a + offset > ovflSize ){\n          a = ovflSize - offset;\n        }\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        /* If all the following are true:\n        **\n        **   1) this is a read operation, and \n        **   2) data is required from the start of this overflow page, and\n        **   3) there is no open write-transaction, and\n        **   4) the database is file-backed, and\n        **   5) the page is not in the WAL file\n        **   6) at least 4 bytes have already been read into the output buffer \n        **\n        ** then data can be read directly from the database file into the\n        ** output buffer, bypassing the page-cache altogether. This speeds\n        ** up loading large records that span many overflow pages.\n        */\n        if( eOp==0                                             /* (1) */\n         && offset==0                                          /* (2) */\n         && pBt->inTransaction==TRANS_READ                     /* (3) */\n         && (fd = sqlite3PagerFile(pBt->pPager))->pMethods     /* (4) */\n         && 0==sqlite3PagerUseWal(pBt->pPager, nextPage)       /* (5) */\n         && &pBuf[-4]>=pBufStart                               /* (6) */\n        ){\n          u8 aSave[4];\n          u8 *aWrite = &pBuf[-4];\n          assert( aWrite>=pBufStart );                         /* due to (6) */\n          memcpy(aSave, aWrite, 4);\n          rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));\n          nextPage = get4byte(aWrite);\n          memcpy(aWrite, aSave, 4);\n        }else\n#endif\n\n        {\n          DbPage *pDbPage;\n          rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage,\n              (eOp==0 ? PAGER_GET_READONLY : 0)\n          );\n          if( rc==SQLITE_OK ){\n            aPayload = sqlite3PagerGetData(pDbPage);\n            nextPage = get4byte(aPayload);\n            rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);\n            sqlite3PagerUnref(pDbPage);\n            offset = 0;\n          }\n        }\n        amt -= a;\n        if( amt==0 ) return rc;\n        pBuf += a;\n      }\n      if( rc ) break;\n      iIdx++;\n    }\n  }\n\n  if( rc==SQLITE_OK && amt>0 ){\n    /* Overflow chain ends prematurely */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  return rc;\n}\n\n/*\n** Read part of the payload for the row at which that cursor pCur is currently\n** pointing.  \"amt\" bytes will be transferred into pBuf[].  The transfer\n** begins at \"offset\".\n**\n** pCur can be pointing to either a table or an index b-tree.\n** If pointing to a table btree, then the content section is read.  If\n** pCur is pointing to an index b-tree then the key section is read.\n**\n** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing\n** to a valid row in the table.  For sqlite3BtreePayloadChecked(), the\n** cursor might be invalid or might need to be restored before being read.\n**\n** Return SQLITE_OK on success or an error code if anything goes\n** wrong.  An error is returned if \"offset+amt\" is larger than\n** the available payload.\n*/\nSQLITE_PRIVATE int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>=0 && pCur->pPage );\n  assert( pCur->ix<pCur->pPage->nCell );\n  return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);\n}\n\n/*\n** This variant of sqlite3BtreePayload() works even if the cursor has not\n** in the CURSOR_VALID state.  It is only used by the sqlite3_blob_read()\n** interface.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nstatic SQLITE_NOINLINE int accessPayloadChecked(\n  BtCursor *pCur,\n  u32 offset,\n  u32 amt,\n  void *pBuf\n){\n  int rc;\n  if ( pCur->eState==CURSOR_INVALID ){\n    return SQLITE_ABORT;\n  }\n  assert( cursorOwnsBtShared(pCur) );\n  rc = btreeRestoreCursorPosition(pCur);\n  return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);\n}\nSQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  if( pCur->eState==CURSOR_VALID ){\n    assert( cursorOwnsBtShared(pCur) );\n    return accessPayload(pCur, offset, amt, pBuf, 0);\n  }else{\n    return accessPayloadChecked(pCur, offset, amt, pBuf);\n  }\n}\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Return a pointer to payload information from the entry that the \n** pCur cursor is pointing to.  The pointer is to the beginning of\n** the key if index btrees (pPage->intKey==0) and is the data for\n** table btrees (pPage->intKey==1). The number of bytes of available\n** key/data is written into *pAmt.  If *pAmt==0, then the value\n** returned will not be a valid pointer.\n**\n** This routine is an optimization.  It is common for the entire key\n** and data to fit on the local page and for there to be no overflow\n** pages.  When that is so, this routine can be used to access the\n** key and data without making a copy.  If the key and/or data spills\n** onto overflow pages, then accessPayload() must be used to reassemble\n** the key/data and copy it into a preallocated buffer.\n**\n** The pointer returned by this routine looks directly into the cached\n** page of the database.  The data might change or move the next time\n** any btree routine is called.\n*/\nstatic const void *fetchPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 *pAmt            /* Write the number of available bytes here */\n){\n  int amt;\n  assert( pCur!=0 && pCur->iPage>=0 && pCur->pPage);\n  assert( pCur->eState==CURSOR_VALID );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->info.nSize>0 );\n  assert( pCur->info.pPayload>pCur->pPage->aData || CORRUPT_DB );\n  assert( pCur->info.pPayload<pCur->pPage->aDataEnd ||CORRUPT_DB);\n  amt = pCur->info.nLocal;\n  if( amt>(int)(pCur->pPage->aDataEnd - pCur->info.pPayload) ){\n    /* There is too little space on the page for the expected amount\n    ** of local content. Database must be corrupt. */\n    assert( CORRUPT_DB );\n    amt = MAX(0, (int)(pCur->pPage->aDataEnd - pCur->info.pPayload));\n  }\n  *pAmt = (u32)amt;\n  return (void*)pCur->info.pPayload;\n}\n\n\n/*\n** For the entry that cursor pCur is point to, return as\n** many bytes of the key or data as are available on the local\n** b-tree page.  Write the number of available bytes into *pAmt.\n**\n** The pointer returned is ephemeral.  The key/data may move\n** or be destroyed on the next call to any Btree routine,\n** including calls from other threads against the same cache.\n** Hence, a mutex on the BtShared should be held prior to calling\n** this routine.\n**\n** These routines is used to get quick access to key and data\n** in the common case where no overflow pages are used.\n*/\nSQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){\n  return fetchPayload(pCur, pAmt);\n}\n\n\n/*\n** Move the cursor down to a new child page.  The newPgno argument is the\n** page number of the child page to move to.\n**\n** This function returns SQLITE_CORRUPT if the page-header flags field of\n** the new child page does not match the flags field of the parent (i.e.\n** if an intkey page appears to be the parent of a non-intkey page, or\n** vice-versa).\n*/\nstatic int moveToChild(BtCursor *pCur, u32 newPgno){\n  BtShared *pBt = pCur->pBt;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage<BTCURSOR_MAX_DEPTH );\n  assert( pCur->iPage>=0 );\n  if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->aiIdx[pCur->iPage] = pCur->ix;\n  pCur->apPage[pCur->iPage] = pCur->pPage;\n  pCur->ix = 0;\n  pCur->iPage++;\n  return getAndInitPage(pBt, newPgno, &pCur->pPage, pCur, pCur->curPagerFlags);\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Page pParent is an internal (non-leaf) tree page. This function \n** asserts that page number iChild is the left-child if the iIdx'th\n** cell in page pParent. Or, if iIdx is equal to the total number of\n** cells in pParent, that page number iChild is the right-child of\n** the page.\n*/\nstatic void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){\n  if( CORRUPT_DB ) return;  /* The conditions tested below might not be true\n                            ** in a corrupt database */\n  assert( iIdx<=pParent->nCell );\n  if( iIdx==pParent->nCell ){\n    assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );\n  }else{\n    assert( get4byte(findCell(pParent, iIdx))==iChild );\n  }\n}\n#else\n#  define assertParentIndex(x,y,z) \n#endif\n\n/*\n** Move the cursor up to the parent page.\n**\n** pCur->idx is set to the cell index that contains the pointer\n** to the page we are coming from.  If we are coming from the\n** right-most child page then pCur->idx is set to one more than\n** the largest cell index.\n*/\nstatic void moveToParent(BtCursor *pCur){\n  MemPage *pLeaf;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>0 );\n  assert( pCur->pPage );\n  assertParentIndex(\n    pCur->apPage[pCur->iPage-1], \n    pCur->aiIdx[pCur->iPage-1], \n    pCur->pPage->pgno\n  );\n  testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->ix = pCur->aiIdx[pCur->iPage-1];\n  pLeaf = pCur->pPage;\n  pCur->pPage = pCur->apPage[--pCur->iPage];\n  releasePageNotNull(pLeaf);\n}\n\n/*\n** Move the cursor to point to the root page of its b-tree structure.\n**\n** If the table has a virtual root page, then the cursor is moved to point\n** to the virtual root page instead of the actual root page. A table has a\n** virtual root page when the actual root page contains no cells and a \n** single child page. This can only happen with the table rooted at page 1.\n**\n** If the b-tree structure is empty, the cursor state is set to \n** CURSOR_INVALID and this routine returns SQLITE_EMPTY. Otherwise,\n** the cursor is set to point to the first cell located on the root\n** (or virtual root) page and the cursor state is set to CURSOR_VALID.\n**\n** If this function returns successfully, it may be assumed that the\n** page-header flags indicate that the [virtual] root-page is the expected \n** kind of b-tree page (i.e. if when opening the cursor the caller did not\n** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D,\n** indicating a table b-tree, or if the caller did specify a KeyInfo \n** structure the flags byte is set to 0x02 or 0x0A, indicating an index\n** b-tree).\n*/\nstatic int moveToRoot(BtCursor *pCur){\n  MemPage *pRoot;\n  int rc = SQLITE_OK;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );\n  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );\n  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );\n  assert( pCur->eState < CURSOR_REQUIRESEEK || pCur->iPage<0 );\n  assert( pCur->pgnoRoot>0 || pCur->iPage<0 );\n\n  if( pCur->iPage>=0 ){\n    if( pCur->iPage ){\n      releasePageNotNull(pCur->pPage);\n      while( --pCur->iPage ){\n        releasePageNotNull(pCur->apPage[pCur->iPage]);\n      }\n      pCur->pPage = pCur->apPage[0];\n      goto skip_init;\n    }\n  }else if( pCur->pgnoRoot==0 ){\n    pCur->eState = CURSOR_INVALID;\n    return SQLITE_EMPTY;\n  }else{\n    assert( pCur->iPage==(-1) );\n    if( pCur->eState>=CURSOR_REQUIRESEEK ){\n      if( pCur->eState==CURSOR_FAULT ){\n        assert( pCur->skipNext!=SQLITE_OK );\n        return pCur->skipNext;\n      }\n      sqlite3BtreeClearCursor(pCur);\n    }\n    rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->pPage,\n                        0, pCur->curPagerFlags);\n    if( rc!=SQLITE_OK ){\n      pCur->eState = CURSOR_INVALID;\n      return rc;\n    }\n    pCur->iPage = 0;\n    pCur->curIntKey = pCur->pPage->intKey;\n  }\n  pRoot = pCur->pPage;\n  assert( pRoot->pgno==pCur->pgnoRoot );\n\n  /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor\n  ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is\n  ** NULL, the caller expects a table b-tree. If this is not the case,\n  ** return an SQLITE_CORRUPT error. \n  **\n  ** Earlier versions of SQLite assumed that this test could not fail\n  ** if the root page was already loaded when this function was called (i.e.\n  ** if pCur->iPage>=0). But this is not so if the database is corrupted \n  ** in such a way that page pRoot is linked into a second b-tree table \n  ** (or the freelist).  */\n  assert( pRoot->intKey==1 || pRoot->intKey==0 );\n  if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){\n    return SQLITE_CORRUPT_PGNO(pCur->pPage->pgno);\n  }\n\nskip_init:  \n  pCur->ix = 0;\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);\n\n  pRoot = pCur->pPage;\n  if( pRoot->nCell>0 ){\n    pCur->eState = CURSOR_VALID;\n  }else if( !pRoot->leaf ){\n    Pgno subpage;\n    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;\n    subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);\n    pCur->eState = CURSOR_VALID;\n    rc = moveToChild(pCur, subpage);\n  }else{\n    pCur->eState = CURSOR_INVALID;\n    rc = SQLITE_EMPTY;\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the left-most leaf entry beneath the\n** entry to which it is currently pointing.\n**\n** The left-most leaf is the one with the smallest key - the first\n** in ascending order.\n*/\nstatic int moveToLeftmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){\n    assert( pCur->ix<pPage->nCell );\n    pgno = get4byte(findCell(pPage, pCur->ix));\n    rc = moveToChild(pCur, pgno);\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the right-most leaf entry beneath the\n** page to which it is currently pointing.  Notice the difference\n** between moveToLeftmost() and moveToRightmost().  moveToLeftmost()\n** finds the left-most entry beneath the *entry* whereas moveToRightmost()\n** finds the right-most entry beneath the *page*.\n**\n** The right-most entry is the one with the largest key - the last\n** key in ascending order.\n*/\nstatic int moveToRightmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage = 0;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( !(pPage = pCur->pPage)->leaf ){\n    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    pCur->ix = pPage->nCell;\n    rc = moveToChild(pCur, pgno);\n    if( rc ) return rc;\n  }\n  pCur->ix = pPage->nCell-1;\n  assert( pCur->info.nSize==0 );\n  assert( (pCur->curFlags & BTCF_ValidNKey)==0 );\n  return SQLITE_OK;\n}\n\n/* Move the cursor to the first entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){\n  int rc;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->pPage->nCell>0 );\n    *pRes = 0;\n    rc = moveToLeftmost(pCur);\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/* Move the cursor to the last entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){\n  int rc;\n \n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* If the cursor already points to the last entry, this is a no-op. */\n  if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){\n#ifdef SQLITE_DEBUG\n    /* This block serves to assert() that the cursor really does point \n    ** to the last entry in the b-tree. */\n    int ii;\n    for(ii=0; ii<pCur->iPage; ii++){\n      assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );\n    }\n    assert( pCur->ix==pCur->pPage->nCell-1 );\n    assert( pCur->pPage->leaf );\n#endif\n    return SQLITE_OK;\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->eState==CURSOR_VALID );\n    *pRes = 0;\n    rc = moveToRightmost(pCur);\n    if( rc==SQLITE_OK ){\n      pCur->curFlags |= BTCF_AtLast;\n    }else{\n      pCur->curFlags &= ~BTCF_AtLast;\n    }\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/* Move the cursor so that it points to an entry near the key \n** specified by pIdxKey or intKey.   Return a success code.\n**\n** For INTKEY tables, the intKey parameter is used.  pIdxKey \n** must be NULL.  For index tables, pIdxKey is used and intKey\n** is ignored.\n**\n** If an exact match is not found, then the cursor is always\n** left pointing at a leaf page which would hold the entry if it\n** were present.  The cursor might point to an entry that comes\n** before or after the key.\n**\n** An integer is written into *pRes which is the result of\n** comparing the key with the entry to which the cursor is \n** pointing.  The meaning of the integer written into\n** *pRes is as follows:\n**\n**     *pRes<0      The cursor is left pointing at an entry that\n**                  is smaller than intKey/pIdxKey or if the table is empty\n**                  and the cursor is therefore left point to nothing.\n**\n**     *pRes==0     The cursor is left pointing at an entry that\n**                  exactly matches intKey/pIdxKey.\n**\n**     *pRes>0      The cursor is left pointing at an entry that\n**                  is larger than intKey/pIdxKey.\n**\n** For index tables, the pIdxKey->eqSeen field is set to 1 if there\n** exists an entry in the table that exactly matches pIdxKey.  \n*/\nSQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(\n  BtCursor *pCur,          /* The cursor to be moved */\n  UnpackedRecord *pIdxKey, /* Unpacked index key */\n  i64 intKey,              /* The table key */\n  int biasRight,           /* If true, bias the search to the high end */\n  int *pRes                /* Write search results here */\n){\n  int rc;\n  RecordCompare xRecordCompare;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( pRes );\n  assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );\n  assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );\n\n  /* If the cursor is already positioned at the point we are trying\n  ** to move to, then just return without doing any work */\n  if( pIdxKey==0\n   && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0\n  ){\n    if( pCur->info.nKey==intKey ){\n      *pRes = 0;\n      return SQLITE_OK;\n    }\n    if( pCur->info.nKey<intKey ){\n      if( (pCur->curFlags & BTCF_AtLast)!=0 ){\n        *pRes = -1;\n        return SQLITE_OK;\n      }\n      /* If the requested key is one more than the previous key, then\n      ** try to get there using sqlite3BtreeNext() rather than a full\n      ** binary search.  This is an optimization only.  The correct answer\n      ** is still obtained without this case, only a little more slowely */\n      if( pCur->info.nKey+1==intKey && !pCur->skipNext ){\n        *pRes = 0;\n        rc = sqlite3BtreeNext(pCur, 0);\n        if( rc==SQLITE_OK ){\n          getCellInfo(pCur);\n          if( pCur->info.nKey==intKey ){\n            return SQLITE_OK;\n          }\n        }else if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n        }else{\n          return rc;\n        }\n      }\n    }\n  }\n\n  if( pIdxKey ){\n    xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);\n    pIdxKey->errCode = 0;\n    assert( pIdxKey->default_rc==1 \n         || pIdxKey->default_rc==0 \n         || pIdxKey->default_rc==-1\n    );\n  }else{\n    xRecordCompare = 0; /* All keys are integers */\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc ){\n    if( rc==SQLITE_EMPTY ){\n      assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n    return rc;\n  }\n  assert( pCur->pPage );\n  assert( pCur->pPage->isInit );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->pPage->nCell > 0 );\n  assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );\n  assert( pCur->curIntKey || pIdxKey );\n  for(;;){\n    int lwr, upr, idx, c;\n    Pgno chldPg;\n    MemPage *pPage = pCur->pPage;\n    u8 *pCell;                          /* Pointer to current cell in pPage */\n\n    /* pPage->nCell must be greater than zero. If this is the root-page\n    ** the cursor would have been INVALID above and this for(;;) loop\n    ** not run. If this is not the root-page, then the moveToChild() routine\n    ** would have already detected db corruption. Similarly, pPage must\n    ** be the right kind (index or table) of b-tree page. Otherwise\n    ** a moveToChild() or moveToRoot() call would have detected corruption.  */\n    assert( pPage->nCell>0 );\n    assert( pPage->intKey==(pIdxKey==0) );\n    lwr = 0;\n    upr = pPage->nCell-1;\n    assert( biasRight==0 || biasRight==1 );\n    idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */\n    pCur->ix = (u16)idx;\n    if( xRecordCompare==0 ){\n      for(;;){\n        i64 nCellKey;\n        pCell = findCellPastPtr(pPage, idx);\n        if( pPage->intKeyLeaf ){\n          while( 0x80 <= *(pCell++) ){\n            if( pCell>=pPage->aDataEnd ){\n              return SQLITE_CORRUPT_PGNO(pPage->pgno);\n            }\n          }\n        }\n        getVarint(pCell, (u64*)&nCellKey);\n        if( nCellKey<intKey ){\n          lwr = idx+1;\n          if( lwr>upr ){ c = -1; break; }\n        }else if( nCellKey>intKey ){\n          upr = idx-1;\n          if( lwr>upr ){ c = +1; break; }\n        }else{\n          assert( nCellKey==intKey );\n          pCur->ix = (u16)idx;\n          if( !pPage->leaf ){\n            lwr = idx;\n            goto moveto_next_layer;\n          }else{\n            pCur->curFlags |= BTCF_ValidNKey;\n            pCur->info.nKey = nCellKey;\n            pCur->info.nSize = 0;\n            *pRes = 0;\n            return SQLITE_OK;\n          }\n        }\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2; */\n      }\n    }else{\n      for(;;){\n        int nCell;  /* Size of the pCell cell in bytes */\n        pCell = findCellPastPtr(pPage, idx);\n\n        /* The maximum supported page-size is 65536 bytes. This means that\n        ** the maximum number of record bytes stored on an index B-Tree\n        ** page is less than 16384 bytes and may be stored as a 2-byte\n        ** varint. This information is used to attempt to avoid parsing \n        ** the entire cell by checking for the cases where the record is \n        ** stored entirely within the b-tree page by inspecting the first \n        ** 2 bytes of the cell.\n        */\n        nCell = pCell[0];\n        if( nCell<=pPage->max1bytePayload ){\n          /* This branch runs if the record-size field of the cell is a\n          ** single byte varint and the record fits entirely on the main\n          ** b-tree page.  */\n          testcase( pCell+nCell+1==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);\n        }else if( !(pCell[1] & 0x80) \n          && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal\n        ){\n          /* The record-size field is a 2 byte varint and the record \n          ** fits entirely on the main b-tree page.  */\n          testcase( pCell+nCell+2==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);\n        }else{\n          /* The record flows over onto one or more overflow pages. In\n          ** this case the whole cell needs to be parsed, a buffer allocated\n          ** and accessPayload() used to retrieve the record into the\n          ** buffer before VdbeRecordCompare() can be called. \n          **\n          ** If the record is corrupt, the xRecordCompare routine may read\n          ** up to two varints past the end of the buffer. An extra 18 \n          ** bytes of padding is allocated at the end of the buffer in\n          ** case this happens.  */\n          void *pCellKey;\n          u8 * const pCellBody = pCell - pPage->childPtrSize;\n          pPage->xParseCell(pPage, pCellBody, &pCur->info);\n          nCell = (int)pCur->info.nKey;\n          testcase( nCell<0 );   /* True if key size is 2^32 or more */\n          testcase( nCell==0 );  /* Invalid key size:  0x80 0x80 0x00 */\n          testcase( nCell==1 );  /* Invalid key size:  0x80 0x80 0x01 */\n          testcase( nCell==2 );  /* Minimum legal index key size */\n          if( nCell<2 ){\n            rc = SQLITE_CORRUPT_PGNO(pPage->pgno);\n            goto moveto_finish;\n          }\n          pCellKey = sqlite3Malloc( nCell+18 );\n          if( pCellKey==0 ){\n            rc = SQLITE_NOMEM_BKPT;\n            goto moveto_finish;\n          }\n          pCur->ix = (u16)idx;\n          rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);\n          pCur->curFlags &= ~BTCF_ValidOvfl;\n          if( rc ){\n            sqlite3_free(pCellKey);\n            goto moveto_finish;\n          }\n          c = xRecordCompare(nCell, pCellKey, pIdxKey);\n          sqlite3_free(pCellKey);\n        }\n        assert( \n            (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)\n         && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)\n        );\n        if( c<0 ){\n          lwr = idx+1;\n        }else if( c>0 ){\n          upr = idx-1;\n        }else{\n          assert( c==0 );\n          *pRes = 0;\n          rc = SQLITE_OK;\n          pCur->ix = (u16)idx;\n          if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;\n          goto moveto_finish;\n        }\n        if( lwr>upr ) break;\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2 */\n      }\n    }\n    assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );\n    assert( pPage->isInit );\n    if( pPage->leaf ){\n      assert( pCur->ix<pCur->pPage->nCell );\n      pCur->ix = (u16)idx;\n      *pRes = c;\n      rc = SQLITE_OK;\n      goto moveto_finish;\n    }\nmoveto_next_layer:\n    if( lwr>=pPage->nCell ){\n      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    }else{\n      chldPg = get4byte(findCell(pPage, lwr));\n    }\n    pCur->ix = (u16)lwr;\n    rc = moveToChild(pCur, chldPg);\n    if( rc ) break;\n  }\nmoveto_finish:\n  pCur->info.nSize = 0;\n  assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n  return rc;\n}\n\n\n/*\n** Return TRUE if the cursor is not pointing at an entry of the table.\n**\n** TRUE will be returned after a call to sqlite3BtreeNext() moves\n** past the last entry in the table or sqlite3BtreePrev() moves past\n** the first entry.  TRUE is also returned if the table is empty.\n*/\nSQLITE_PRIVATE int sqlite3BtreeEof(BtCursor *pCur){\n  /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries\n  ** have been deleted? This API will need to change to return an error code\n  ** as well as the boolean result value.\n  */\n  return (CURSOR_VALID!=pCur->eState);\n}\n\n/*\n** Return an estimate for the number of rows in the table that pCur is\n** pointing to.  Return a negative number if no estimate is currently \n** available.\n*/\nSQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){\n  i64 n;\n  u8 i;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* Currently this interface is only called by the OP_IfSmaller\n  ** opcode, and it that case the cursor will always be valid and\n  ** will always point to a leaf node. */\n  if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;\n  if( NEVER(pCur->pPage->leaf==0) ) return -1;\n\n  n = pCur->pPage->nCell;\n  for(i=0; i<pCur->iPage; i++){\n    n *= pCur->apPage[i]->nCell;\n  }\n  return n;\n}\n\n/*\n** Advance the cursor to the next entry in the database. \n** Return value:\n**\n**    SQLITE_OK        success\n**    SQLITE_DONE      cursor is already pointing at the last element\n**    otherwise        some kind of error occurred\n**\n** The main entry point is sqlite3BtreeNext().  That routine is optimized\n** for the common case of merely incrementing the cell counter BtCursor.aiIdx\n** to the next cell on the current page.  The (slower) btreeNext() helper\n** routine is called when it is necessary to move to a different page or\n** to restore the cursor.\n**\n** If bit 0x01 of the F argument in sqlite3BtreeNext(C,F) is 1, then the\n** cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument\n** is a hint to the implement.  SQLite btree implementation does not use\n** this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreeNext(BtCursor *pCur){\n  int rc;\n  int idx;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  if( pCur->eState!=CURSOR_VALID ){\n    assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( pCur->skipNext ){\n      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext>0 ){\n        pCur->skipNext = 0;\n        return SQLITE_OK;\n      }\n      pCur->skipNext = 0;\n    }\n  }\n\n  pPage = pCur->pPage;\n  idx = ++pCur->ix;\n  assert( pPage->isInit );\n\n  /* If the database file is corrupt, it is possible for the value of idx \n  ** to be invalid here. This can only occur if a second cursor modifies\n  ** the page while cursor pCur is holding a reference to it. Which can\n  ** only happen if the database is corrupt in such a way as to link the\n  ** page into more than one b-tree structure. */\n  testcase( idx>pPage->nCell );\n\n  if( idx>=pPage->nCell ){\n    if( !pPage->leaf ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n      if( rc ) return rc;\n      return moveToLeftmost(pCur);\n    }\n    do{\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n      pPage = pCur->pPage;\n    }while( pCur->ix>=pPage->nCell );\n    if( pPage->intKey ){\n      return sqlite3BtreeNext(pCur, 0);\n    }else{\n      return SQLITE_OK;\n    }\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\nSQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){\n  MemPage *pPage;\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur);\n  pPage = pCur->pPage;\n  if( (++pCur->ix)>=pPage->nCell ){\n    pCur->ix--;\n    return btreeNext(pCur);\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\n\n/*\n** Step the cursor to the back to the previous entry in the database.\n** Return values:\n**\n**     SQLITE_OK     success\n**     SQLITE_DONE   the cursor is already on the first element of the table\n**     otherwise     some kind of error occurred\n**\n** The main entry point is sqlite3BtreePrevious().  That routine is optimized\n** for the common case of merely decrementing the cell counter BtCursor.aiIdx\n** to the previous cell on the current page.  The (slower) btreePrevious()\n** helper routine is called when it is necessary to move to a different page\n** or to restore the cursor.\n**\n** If bit 0x01 of the F argument to sqlite3BtreePrevious(C,F) is 1, then\n** the cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument is a\n** hint to the implement.  The native SQLite btree implementation does not\n** use this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){\n  int rc;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );\n  assert( pCur->info.nSize==0 );\n  if( pCur->eState!=CURSOR_VALID ){\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( pCur->skipNext ){\n      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext<0 ){\n        pCur->skipNext = 0;\n        return SQLITE_OK;\n      }\n      pCur->skipNext = 0;\n    }\n  }\n\n  pPage = pCur->pPage;\n  assert( pPage->isInit );\n  if( !pPage->leaf ){\n    int idx = pCur->ix;\n    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));\n    if( rc ) return rc;\n    rc = moveToRightmost(pCur);\n  }else{\n    while( pCur->ix==0 ){\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n    }\n    assert( pCur->info.nSize==0 );\n    assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );\n\n    pCur->ix--;\n    pPage = pCur->pPage;\n    if( pPage->intKey && !pPage->leaf ){\n      rc = sqlite3BtreePrevious(pCur, 0);\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);\n  pCur->info.nSize = 0;\n  if( pCur->eState!=CURSOR_VALID\n   || pCur->ix==0\n   || pCur->pPage->leaf==0\n  ){\n    return btreePrevious(pCur);\n  }\n  pCur->ix--;\n  return SQLITE_OK;\n}\n\n/*\n** Allocate a new page from the database file.\n**\n** The new page is marked as dirty.  (In other words, sqlite3PagerWrite()\n** has already been called on the new page.)  The new page has also\n** been referenced and the calling routine is responsible for calling\n** sqlite3PagerUnref() on the new page when it is done.\n**\n** SQLITE_OK is returned on success.  Any other return value indicates\n** an error.  *ppPage is set to NULL in the event of an error.\n**\n** If the \"nearby\" parameter is not 0, then an effort is made to \n** locate a page close to the page number \"nearby\".  This can be used in an\n** attempt to keep related pages close to each other in the database file,\n** which in turn can make database access faster.\n**\n** If the eMode parameter is BTALLOC_EXACT and the nearby page exists\n** anywhere on the free-list, then it is guaranteed to be returned.  If\n** eMode is BTALLOC_LT then the page returned will be less than or equal\n** to nearby if any such page exists.  If eMode is BTALLOC_ANY then there\n** are no restrictions on which page is returned.\n*/\nstatic int allocateBtreePage(\n  BtShared *pBt,         /* The btree */\n  MemPage **ppPage,      /* Store pointer to the allocated page here */\n  Pgno *pPgno,           /* Store the page number here */\n  Pgno nearby,           /* Search for a page near this one */\n  u8 eMode               /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */\n){\n  MemPage *pPage1;\n  int rc;\n  u32 n;     /* Number of pages on the freelist */\n  u32 k;     /* Number of leaves on the trunk of the freelist */\n  MemPage *pTrunk = 0;\n  MemPage *pPrevTrunk = 0;\n  Pgno mxPage;     /* Total size of the database file */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );\n  pPage1 = pBt->pPage1;\n  mxPage = btreePagecount(pBt);\n  /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36\n  ** stores stores the total number of pages on the freelist. */\n  n = get4byte(&pPage1->aData[36]);\n  testcase( n==mxPage-1 );\n  if( n>=mxPage ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  if( n>0 ){\n    /* There are pages on the freelist.  Reuse one of those pages. */\n    Pgno iTrunk;\n    u8 searchList = 0; /* If the free-list must be searched for 'nearby' */\n    u32 nSearch = 0;   /* Count of the number of search attempts */\n    \n    /* If eMode==BTALLOC_EXACT and a query of the pointer-map\n    ** shows that the page 'nearby' is somewhere on the free-list, then\n    ** the entire-list will be searched for that page.\n    */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( eMode==BTALLOC_EXACT ){\n      if( nearby<=mxPage ){\n        u8 eType;\n        assert( nearby>0 );\n        assert( pBt->autoVacuum );\n        rc = ptrmapGet(pBt, nearby, &eType, 0);\n        if( rc ) return rc;\n        if( eType==PTRMAP_FREEPAGE ){\n          searchList = 1;\n        }\n      }\n    }else if( eMode==BTALLOC_LE ){\n      searchList = 1;\n    }\n#endif\n\n    /* Decrement the free-list count by 1. Set iTrunk to the index of the\n    ** first free-list trunk page. iPrevTrunk is initially 1.\n    */\n    rc = sqlite3PagerWrite(pPage1->pDbPage);\n    if( rc ) return rc;\n    put4byte(&pPage1->aData[36], n-1);\n\n    /* The code within this loop is run only once if the 'searchList' variable\n    ** is not true. Otherwise, it runs once for each trunk-page on the\n    ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT)\n    ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT)\n    */\n    do {\n      pPrevTrunk = pTrunk;\n      if( pPrevTrunk ){\n        /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page\n        ** is the page number of the next freelist trunk page in the list or\n        ** zero if this is the last freelist trunk page. */\n        iTrunk = get4byte(&pPrevTrunk->aData[0]);\n      }else{\n        /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32\n        ** stores the page number of the first page of the freelist, or zero if\n        ** the freelist is empty. */\n        iTrunk = get4byte(&pPage1->aData[32]);\n      }\n      testcase( iTrunk==mxPage );\n      if( iTrunk>mxPage || nSearch++ > n ){\n        rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);\n      }else{\n        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);\n      }\n      if( rc ){\n        pTrunk = 0;\n        goto end_allocate_page;\n      }\n      assert( pTrunk!=0 );\n      assert( pTrunk->aData!=0 );\n      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page\n      ** is the number of leaf page pointers to follow. */\n      k = get4byte(&pTrunk->aData[4]);\n      if( k==0 && !searchList ){\n        /* The trunk has no leaves and the list is not being searched. \n        ** So extract the trunk page itself and use it as the newly \n        ** allocated page */\n        assert( pPrevTrunk==0 );\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        *pPgno = iTrunk;\n        memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n        *ppPage = pTrunk;\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n      }else if( k>(u32)(pBt->usableSize/4 - 2) ){\n        /* Value of k is out of range.  Database corruption */\n        rc = SQLITE_CORRUPT_PGNO(iTrunk);\n        goto end_allocate_page;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      }else if( searchList \n            && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE)) \n      ){\n        /* The list is being searched and this trunk page is the page\n        ** to allocate, regardless of whether it has leaves.\n        */\n        *pPgno = iTrunk;\n        *ppPage = pTrunk;\n        searchList = 0;\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        if( k==0 ){\n          if( !pPrevTrunk ){\n            memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc!=SQLITE_OK ){\n              goto end_allocate_page;\n            }\n            memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);\n          }\n        }else{\n          /* The trunk page is required by the caller but it contains \n          ** pointers to free-list leaves. The first leaf becomes a trunk\n          ** page in this case.\n          */\n          MemPage *pNewTrunk;\n          Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);\n          if( iNewTrunk>mxPage ){ \n            rc = SQLITE_CORRUPT_PGNO(iTrunk);\n            goto end_allocate_page;\n          }\n          testcase( iNewTrunk==mxPage );\n          rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);\n          if( rc!=SQLITE_OK ){\n            goto end_allocate_page;\n          }\n          rc = sqlite3PagerWrite(pNewTrunk->pDbPage);\n          if( rc!=SQLITE_OK ){\n            releasePage(pNewTrunk);\n            goto end_allocate_page;\n          }\n          memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);\n          put4byte(&pNewTrunk->aData[4], k-1);\n          memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);\n          releasePage(pNewTrunk);\n          if( !pPrevTrunk ){\n            assert( sqlite3PagerIswriteable(pPage1->pDbPage) );\n            put4byte(&pPage1->aData[32], iNewTrunk);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc ){\n              goto end_allocate_page;\n            }\n            put4byte(&pPrevTrunk->aData[0], iNewTrunk);\n          }\n        }\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n#endif\n      }else if( k>0 ){\n        /* Extract a leaf from the trunk */\n        u32 closest;\n        Pgno iPage;\n        unsigned char *aData = pTrunk->aData;\n        if( nearby>0 ){\n          u32 i;\n          closest = 0;\n          if( eMode==BTALLOC_LE ){\n            for(i=0; i<k; i++){\n              iPage = get4byte(&aData[8+i*4]);\n              if( iPage<=nearby ){\n                closest = i;\n                break;\n              }\n            }\n          }else{\n            int dist;\n            dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);\n            for(i=1; i<k; i++){\n              int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);\n              if( d2<dist ){\n                closest = i;\n                dist = d2;\n              }\n            }\n          }\n        }else{\n          closest = 0;\n        }\n\n        iPage = get4byte(&aData[8+closest*4]);\n        testcase( iPage==mxPage );\n        if( iPage>mxPage ){\n          rc = SQLITE_CORRUPT_PGNO(iTrunk);\n          goto end_allocate_page;\n        }\n        testcase( iPage==mxPage );\n        if( !searchList \n         || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE)) \n        ){\n          int noContent;\n          *pPgno = iPage;\n          TRACE((\"ALLOCATE: %d was leaf %d of %d on trunk %d\"\n                 \": %d more free pages\\n\",\n                 *pPgno, closest+1, k, pTrunk->pgno, n-1));\n          rc = sqlite3PagerWrite(pTrunk->pDbPage);\n          if( rc ) goto end_allocate_page;\n          if( closest<k-1 ){\n            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);\n          }\n          put4byte(&aData[4], k-1);\n          noContent = !btreeGetHasContent(pBt, *pPgno)? PAGER_GET_NOCONTENT : 0;\n          rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, noContent);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n            if( rc!=SQLITE_OK ){\n              releasePage(*ppPage);\n              *ppPage = 0;\n            }\n          }\n          searchList = 0;\n        }\n      }\n      releasePage(pPrevTrunk);\n      pPrevTrunk = 0;\n    }while( searchList );\n  }else{\n    /* There are no pages on the freelist, so append a new page to the\n    ** database image.\n    **\n    ** Normally, new pages allocated by this block can be requested from the\n    ** pager layer with the 'no-content' flag set. This prevents the pager\n    ** from trying to read the pages content from disk. However, if the\n    ** current transaction has already run one or more incremental-vacuum\n    ** steps, then the page we are about to allocate may contain content\n    ** that is required in the event of a rollback. In this case, do\n    ** not set the no-content flag. This causes the pager to load and journal\n    ** the current page content before overwriting it.\n    **\n    ** Note that the pager will not actually attempt to load or journal \n    ** content for any page that really does lie past the end of the database\n    ** file on disk. So the effects of disabling the no-content optimization\n    ** here are confined to those pages that lie between the end of the\n    ** database image and the end of the database file.\n    */\n    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate))? PAGER_GET_NOCONTENT:0;\n\n    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n    if( rc ) return rc;\n    pBt->nPage++;\n    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){\n      /* If *pPgno refers to a pointer-map page, allocate two new pages\n      ** at the end of the file instead of one. The first allocated page\n      ** becomes a new pointer-map page, the second is used by the caller.\n      */\n      MemPage *pPg = 0;\n      TRACE((\"ALLOCATE: %d from end of file (pointer-map page)\\n\", pBt->nPage));\n      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );\n      rc = btreeGetUnusedPage(pBt, pBt->nPage, &pPg, bNoContent);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pPg->pDbPage);\n        releasePage(pPg);\n      }\n      if( rc ) return rc;\n      pBt->nPage++;\n      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }\n    }\n#endif\n    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);\n    *pPgno = pBt->nPage;\n\n    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n    rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, bNoContent);\n    if( rc ) return rc;\n    rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n    }\n    TRACE((\"ALLOCATE: %d from end of file\\n\", *pPgno));\n  }\n\n  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n\nend_allocate_page:\n  releasePage(pTrunk);\n  releasePage(pPrevTrunk);\n  assert( rc!=SQLITE_OK || sqlite3PagerPageRefcount((*ppPage)->pDbPage)<=1 );\n  assert( rc!=SQLITE_OK || (*ppPage)->isInit==0 );\n  return rc;\n}\n\n/*\n** This function is used to add page iPage to the database file free-list. \n** It is assumed that the page is not already a part of the free-list.\n**\n** The value passed as the second argument to this function is optional.\n** If the caller happens to have a pointer to the MemPage object \n** corresponding to page iPage handy, it may pass it as the second value. \n** Otherwise, it may pass NULL.\n**\n** If a pointer to a MemPage object is passed as the second argument,\n** its reference count is not altered by this function.\n*/\nstatic int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){\n  MemPage *pTrunk = 0;                /* Free-list trunk page */\n  Pgno iTrunk = 0;                    /* Page number of free-list trunk page */ \n  MemPage *pPage1 = pBt->pPage1;      /* Local reference to page 1 */\n  MemPage *pPage;                     /* Page being freed. May be NULL. */\n  int rc;                             /* Return Code */\n  int nFree;                          /* Initial number of pages on free-list */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( CORRUPT_DB || iPage>1 );\n  assert( !pMemPage || pMemPage->pgno==iPage );\n\n  if( iPage<2 ) return SQLITE_CORRUPT_BKPT;\n  if( pMemPage ){\n    pPage = pMemPage;\n    sqlite3PagerRef(pPage->pDbPage);\n  }else{\n    pPage = btreePageLookup(pBt, iPage);\n  }\n\n  /* Increment the free page count on pPage1 */\n  rc = sqlite3PagerWrite(pPage1->pDbPage);\n  if( rc ) goto freepage_out;\n  nFree = get4byte(&pPage1->aData[36]);\n  put4byte(&pPage1->aData[36], nFree+1);\n\n  if( pBt->btsFlags & BTS_SECURE_DELETE ){\n    /* If the secure_delete option is enabled, then\n    ** always fully overwrite deleted information with zeros.\n    */\n    if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0) )\n     ||            ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0)\n    ){\n      goto freepage_out;\n    }\n    memset(pPage->aData, 0, pPage->pBt->pageSize);\n  }\n\n  /* If the database supports auto-vacuum, write an entry in the pointer-map\n  ** to indicate that the page is free.\n  */\n  if( ISAUTOVACUUM ){\n    ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);\n    if( rc ) goto freepage_out;\n  }\n\n  /* Now manipulate the actual database free-list structure. There are two\n  ** possibilities. If the free-list is currently empty, or if the first\n  ** trunk page in the free-list is full, then this page will become a\n  ** new free-list trunk page. Otherwise, it will become a leaf of the\n  ** first trunk page in the current free-list. This block tests if it\n  ** is possible to add the page as a new free-list leaf.\n  */\n  if( nFree!=0 ){\n    u32 nLeaf;                /* Initial number of leaf cells on trunk page */\n\n    iTrunk = get4byte(&pPage1->aData[32]);\n    rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);\n    if( rc!=SQLITE_OK ){\n      goto freepage_out;\n    }\n\n    nLeaf = get4byte(&pTrunk->aData[4]);\n    assert( pBt->usableSize>32 );\n    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto freepage_out;\n    }\n    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){\n      /* In this case there is room on the trunk page to insert the page\n      ** being freed as a new leaf.\n      **\n      ** Note that the trunk page is not really full until it contains\n      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have\n      ** coded.  But due to a coding error in versions of SQLite prior to\n      ** 3.6.0, databases with freelist trunk pages holding more than\n      ** usableSize/4 - 8 entries will be reported as corrupt.  In order\n      ** to maintain backwards compatibility with older versions of SQLite,\n      ** we will continue to restrict the number of entries to usableSize/4 - 8\n      ** for now.  At some point in the future (once everyone has upgraded\n      ** to 3.6.0 or later) we should consider fixing the conditional above\n      ** to read \"usableSize/4-2\" instead of \"usableSize/4-8\".\n      **\n      ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still\n      ** avoid using the last six entries in the freelist trunk page array in\n      ** order that database files created by newer versions of SQLite can be\n      ** read by older versions of SQLite.\n      */\n      rc = sqlite3PagerWrite(pTrunk->pDbPage);\n      if( rc==SQLITE_OK ){\n        put4byte(&pTrunk->aData[4], nLeaf+1);\n        put4byte(&pTrunk->aData[8+nLeaf*4], iPage);\n        if( pPage && (pBt->btsFlags & BTS_SECURE_DELETE)==0 ){\n          sqlite3PagerDontWrite(pPage->pDbPage);\n        }\n        rc = btreeSetHasContent(pBt, iPage);\n      }\n      TRACE((\"FREE-PAGE: %d leaf on trunk page %d\\n\",pPage->pgno,pTrunk->pgno));\n      goto freepage_out;\n    }\n  }\n\n  /* If control flows to this point, then it was not possible to add the\n  ** the page being freed as a leaf page of the first trunk in the free-list.\n  ** Possibly because the free-list is empty, or possibly because the \n  ** first trunk in the free-list is full. Either way, the page being freed\n  ** will become the new first trunk page in the free-list.\n  */\n  if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0)) ){\n    goto freepage_out;\n  }\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc!=SQLITE_OK ){\n    goto freepage_out;\n  }\n  put4byte(pPage->aData, iTrunk);\n  put4byte(&pPage->aData[4], 0);\n  put4byte(&pPage1->aData[32], iPage);\n  TRACE((\"FREE-PAGE: %d new trunk page replacing %d\\n\", pPage->pgno, iTrunk));\n\nfreepage_out:\n  if( pPage ){\n    pPage->isInit = 0;\n  }\n  releasePage(pPage);\n  releasePage(pTrunk);\n  return rc;\n}\nstatic void freePage(MemPage *pPage, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);\n  }\n}\n\n/*\n** Free any overflow pages associated with the given Cell.  Write the\n** local Cell size (the number of bytes on the original page, omitting\n** overflow) into *pnSize.\n*/\nstatic int clearCell(\n  MemPage *pPage,          /* The page that contains the Cell */\n  unsigned char *pCell,    /* First byte of the Cell */\n  CellInfo *pInfo          /* Size information about the cell */\n){\n  BtShared *pBt;\n  Pgno ovflPgno;\n  int rc;\n  int nOvfl;\n  u32 ovflPageSize;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->xParseCell(pPage, pCell, pInfo);\n  if( pInfo->nLocal==pInfo->nPayload ){\n    return SQLITE_OK;  /* No overflow pages. Return without doing anything */\n  }\n  if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){\n    /* Cell extends past end of page */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  ovflPgno = get4byte(pCell + pInfo->nSize - 4);\n  pBt = pPage->pBt;\n  assert( pBt->usableSize > 4 );\n  ovflPageSize = pBt->usableSize - 4;\n  nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;\n  assert( nOvfl>0 || \n    (CORRUPT_DB && (pInfo->nPayload + ovflPageSize)<ovflPageSize)\n  );\n  while( nOvfl-- ){\n    Pgno iNext = 0;\n    MemPage *pOvfl = 0;\n    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){\n      /* 0 is not a legal page number and page 1 cannot be an \n      ** overflow page. Therefore if ovflPgno<2 or past the end of the \n      ** file the database must be corrupt. */\n      return SQLITE_CORRUPT_BKPT;\n    }\n    if( nOvfl ){\n      rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);\n      if( rc ) return rc;\n    }\n\n    if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )\n     && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1\n    ){\n      /* There is no reason any cursor should have an outstanding reference \n      ** to an overflow page belonging to a cell that is being deleted/updated.\n      ** So if there exists more than one reference to this page, then it \n      ** must not really be an overflow page and the database must be corrupt. \n      ** It is helpful to detect this before calling freePage2(), as \n      ** freePage2() may zero the page contents if secure-delete mode is\n      ** enabled. If this 'overflow' page happens to be a page that the\n      ** caller is iterating through or using in some other way, this\n      ** can be problematic.\n      */\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = freePage2(pBt, pOvfl, ovflPgno);\n    }\n\n    if( pOvfl ){\n      sqlite3PagerUnref(pOvfl->pDbPage);\n    }\n    if( rc ) return rc;\n    ovflPgno = iNext;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create the byte sequence used to represent a cell on page pPage\n** and write that byte sequence into pCell[].  Overflow pages are\n** allocated and filled in as necessary.  The calling procedure\n** is responsible for making sure sufficient space has been allocated\n** for pCell[].\n**\n** Note that pCell does not necessary need to point to the pPage->aData\n** area.  pCell might point to some temporary storage.  The cell will\n** be constructed in this temporary area then copied into pPage->aData\n** later.\n*/\nstatic int fillInCell(\n  MemPage *pPage,                /* The page that contains the cell */\n  unsigned char *pCell,          /* Complete text of the cell */\n  const BtreePayload *pX,        /* Payload with which to construct the cell */\n  int *pnSize                    /* Write cell size here */\n){\n  int nPayload;\n  const u8 *pSrc;\n  int nSrc, n, rc, mn;\n  int spaceLeft;\n  MemPage *pToRelease;\n  unsigned char *pPrior;\n  unsigned char *pPayload;\n  BtShared *pBt;\n  Pgno pgnoOvfl;\n  int nHeader;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n\n  /* pPage is not necessarily writeable since pCell might be auxiliary\n  ** buffer space that is separate from the pPage buffer area */\n  assert( pCell<pPage->aData || pCell>=&pPage->aData[pPage->pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n  /* Fill in the header. */\n  nHeader = pPage->childPtrSize;\n  if( pPage->intKey ){\n    nPayload = pX->nData + pX->nZero;\n    pSrc = pX->pData;\n    nSrc = pX->nData;\n    assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n    nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);\n  }else{\n    assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );\n    nSrc = nPayload = (int)pX->nKey;\n    pSrc = pX->pKey;\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n  }\n  \n  /* Fill in the payload */\n  pPayload = &pCell[nHeader];\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the common case where everything fits on the btree page\n    ** and no overflow pages are required. */\n    n = nHeader + nPayload;\n    testcase( n==3 );\n    testcase( n==4 );\n    if( n<4 ) n = 4;\n    *pnSize = n;\n    assert( nSrc<=nPayload );\n    testcase( nSrc<nPayload );\n    memcpy(pPayload, pSrc, nSrc);\n    memset(pPayload+nSrc, 0, nPayload-nSrc);\n    return SQLITE_OK;\n  }\n\n  /* If we reach this point, it means that some of the content will need\n  ** to spill onto overflow pages.\n  */\n  mn = pPage->minLocal;\n  n = mn + (nPayload - mn) % (pPage->pBt->usableSize - 4);\n  testcase( n==pPage->maxLocal );\n  testcase( n==pPage->maxLocal+1 );\n  if( n > pPage->maxLocal ) n = mn;\n  spaceLeft = n;\n  *pnSize = n + nHeader + 4;\n  pPrior = &pCell[nHeader+n];\n  pToRelease = 0;\n  pgnoOvfl = 0;\n  pBt = pPage->pBt;\n\n  /* At this point variables should be set as follows:\n  **\n  **   nPayload           Total payload size in bytes\n  **   pPayload           Begin writing payload here\n  **   spaceLeft          Space available at pPayload.  If nPayload>spaceLeft,\n  **                      that means content must spill into overflow pages.\n  **   *pnSize            Size of the local cell (not counting overflow pages)\n  **   pPrior             Where to write the pgno of the first overflow page\n  **\n  ** Use a call to btreeParseCellPtr() to verify that the values above\n  ** were computed correctly.\n  */\n#ifdef SQLITE_DEBUG\n  {\n    CellInfo info;\n    pPage->xParseCell(pPage, pCell, &info);\n    assert( nHeader==(int)(info.pPayload - pCell) );\n    assert( info.nKey==pX->nKey );\n    assert( *pnSize == info.nSize );\n    assert( spaceLeft == info.nLocal );\n  }\n#endif\n\n  /* Write the payload into the local Cell and any extra into overflow pages */\n  while( 1 ){\n    n = nPayload;\n    if( n>spaceLeft ) n = spaceLeft;\n\n    /* If pToRelease is not zero than pPayload points into the data area\n    ** of pToRelease.  Make sure pToRelease is still writeable. */\n    assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n    /* If pPayload is part of the data area of pPage, then make sure pPage\n    ** is still writeable */\n    assert( pPayload<pPage->aData || pPayload>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n    if( nSrc>=n ){\n      memcpy(pPayload, pSrc, n);\n    }else if( nSrc>0 ){\n      n = nSrc;\n      memcpy(pPayload, pSrc, n);\n    }else{\n      memset(pPayload, 0, n);\n    }\n    nPayload -= n;\n    if( nPayload<=0 ) break;\n    pPayload += n;\n    pSrc += n;\n    nSrc -= n;\n    spaceLeft -= n;\n    if( spaceLeft==0 ){\n      MemPage *pOvfl = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */\n      if( pBt->autoVacuum ){\n        do{\n          pgnoOvfl++;\n        } while( \n          PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) \n        );\n      }\n#endif\n      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the database supports auto-vacuum, and the second or subsequent\n      ** overflow page is being allocated, add an entry to the pointer-map\n      ** for that page now. \n      **\n      ** If this is the first overflow page, then write a partial entry \n      ** to the pointer-map. If we write nothing to this pointer-map slot,\n      ** then the optimistic overflow chain processing in clearCell()\n      ** may misinterpret the uninitialized values and delete the\n      ** wrong pages from the database.\n      */\n      if( pBt->autoVacuum && rc==SQLITE_OK ){\n        u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);\n        ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);\n        if( rc ){\n          releasePage(pOvfl);\n        }\n      }\n#endif\n      if( rc ){\n        releasePage(pToRelease);\n        return rc;\n      }\n\n      /* If pToRelease is not zero than pPrior points into the data area\n      ** of pToRelease.  Make sure pToRelease is still writeable. */\n      assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n      /* If pPrior is part of the data area of pPage, then make sure pPage\n      ** is still writeable */\n      assert( pPrior<pPage->aData || pPrior>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n      put4byte(pPrior, pgnoOvfl);\n      releasePage(pToRelease);\n      pToRelease = pOvfl;\n      pPrior = pOvfl->aData;\n      put4byte(pPrior, 0);\n      pPayload = &pOvfl->aData[4];\n      spaceLeft = pBt->usableSize - 4;\n    }\n  }\n  releasePage(pToRelease);\n  return SQLITE_OK;\n}\n\n/*\n** Remove the i-th cell from pPage.  This routine effects pPage only.\n** The cell content is not freed or deallocated.  It is assumed that\n** the cell content has been copied someplace else.  This routine just\n** removes the reference to the cell from pPage.\n**\n** \"sz\" must be the number of bytes in the cell.\n*/\nstatic void dropCell(MemPage *pPage, int idx, int sz, int *pRC){\n  u32 pc;         /* Offset to cell content of cell being deleted */\n  u8 *data;       /* pPage->aData */\n  u8 *ptr;        /* Used to move bytes around within data[] */\n  int rc;         /* The return code */\n  int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */\n\n  if( *pRC ) return;\n  assert( idx>=0 && idx<pPage->nCell );\n  assert( CORRUPT_DB || sz==cellSize(pPage, idx) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  data = pPage->aData;\n  ptr = &pPage->aCellIdx[2*idx];\n  pc = get2byte(ptr);\n  hdr = pPage->hdrOffset;\n  testcase( pc==get2byte(&data[hdr+5]) );\n  testcase( pc+sz==pPage->pBt->usableSize );\n  if( pc+sz > pPage->pBt->usableSize ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  rc = freeSpace(pPage, pc, sz);\n  if( rc ){\n    *pRC = rc;\n    return;\n  }\n  pPage->nCell--;\n  if( pPage->nCell==0 ){\n    memset(&data[hdr+1], 0, 4);\n    data[hdr+7] = 0;\n    put2byte(&data[hdr+5], pPage->pBt->usableSize);\n    pPage->nFree = pPage->pBt->usableSize - pPage->hdrOffset\n                       - pPage->childPtrSize - 8;\n  }else{\n    memmove(ptr, ptr+2, 2*(pPage->nCell - idx));\n    put2byte(&data[hdr+3], pPage->nCell);\n    pPage->nFree += 2;\n  }\n}\n\n/*\n** Insert a new cell on pPage at cell index \"i\".  pCell points to the\n** content of the cell.\n**\n** If the cell content will fit on the page, then put it there.  If it\n** will not fit, then make a copy of the cell content into pTemp if\n** pTemp is not null.  Regardless of pTemp, allocate a new entry\n** in pPage->apOvfl[] and make it point to the cell content (either\n** in pTemp or the original pCell) and also record its index. \n** Allocating a new entry in pPage->aCell[] implies that \n** pPage->nOverflow is incremented.\n**\n** *pRC must be SQLITE_OK when this routine is called.\n*/\nstatic void insertCell(\n  MemPage *pPage,   /* Page into which we are copying */\n  int i,            /* New cell becomes the i-th cell of the page */\n  u8 *pCell,        /* Content of the new cell */\n  int sz,           /* Bytes of content in pCell */\n  u8 *pTemp,        /* Temp storage space for pCell, if needed */\n  Pgno iChild,      /* If non-zero, replace first 4 bytes with this value */\n  int *pRC          /* Read and write return code from here */\n){\n  int idx = 0;      /* Where to write new cell content in data[] */\n  int j;            /* Loop counter */\n  u8 *data;         /* The content of the whole page */\n  u8 *pIns;         /* The point in pPage->aCellIdx[] where no cell inserted */\n\n  assert( *pRC==SQLITE_OK );\n  assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );\n  assert( MX_CELL(pPage->pBt)<=10921 );\n  assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );\n  assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );\n  assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  /* The cell should normally be sized correctly.  However, when moving a\n  ** malformed cell from a leaf page to an interior page, if the cell size\n  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size\n  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence\n  ** the term after the || in the following assert(). */\n  assert( sz==pPage->xCellSize(pPage, pCell) || (sz==8 && iChild>0) );\n  if( pPage->nOverflow || sz+2>pPage->nFree ){\n    if( pTemp ){\n      memcpy(pTemp, pCell, sz);\n      pCell = pTemp;\n    }\n    if( iChild ){\n      put4byte(pCell, iChild);\n    }\n    j = pPage->nOverflow++;\n    /* Comparison against ArraySize-1 since we hold back one extra slot\n    ** as a contingency.  In other words, never need more than 3 overflow\n    ** slots but 4 are allocated, just to be safe. */\n    assert( j < ArraySize(pPage->apOvfl)-1 );\n    pPage->apOvfl[j] = pCell;\n    pPage->aiOvfl[j] = (u16)i;\n\n    /* When multiple overflows occur, they are always sequential and in\n    ** sorted order.  This invariants arise because multiple overflows can\n    ** only occur when inserting divider cells into the parent page during\n    ** balancing, and the dividers are adjacent and sorted.\n    */\n    assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */\n    assert( j==0 || i==pPage->aiOvfl[j-1]+1 );   /* Overflows are sequential */\n  }else{\n    int rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n    assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n    data = pPage->aData;\n    assert( &data[pPage->cellOffset]==pPage->aCellIdx );\n    rc = allocateSpace(pPage, sz, &idx);\n    if( rc ){ *pRC = rc; return; }\n    /* The allocateSpace() routine guarantees the following properties\n    ** if it returns successfully */\n    assert( idx >= 0 );\n    assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );\n    assert( idx+sz <= (int)pPage->pBt->usableSize );\n    pPage->nFree -= (u16)(2 + sz);\n    memcpy(&data[idx], pCell, sz);\n    if( iChild ){\n      put4byte(&data[idx], iChild);\n    }\n    pIns = pPage->aCellIdx + i*2;\n    memmove(pIns+2, pIns, 2*(pPage->nCell - i));\n    put2byte(pIns, idx);\n    pPage->nCell++;\n    /* increment the cell count */\n    if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;\n    assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell );\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pPage->pBt->autoVacuum ){\n      /* The cell may contain a pointer to an overflow page. If so, write\n      ** the entry for the overflow page into the pointer map.\n      */\n      ptrmapPutOvflPtr(pPage, pCell, pRC);\n    }\n#endif\n  }\n}\n\n/*\n** A CellArray object contains a cache of pointers and sizes for a\n** consecutive sequence of cells that might be held on multiple pages.\n*/\ntypedef struct CellArray CellArray;\nstruct CellArray {\n  int nCell;              /* Number of cells in apCell[] */\n  MemPage *pRef;          /* Reference page */\n  u8 **apCell;            /* All cells begin balanced */\n  u16 *szCell;            /* Local size of all cells in apCell[] */\n};\n\n/*\n** Make sure the cell sizes at idx, idx+1, ..., idx+N-1 have been\n** computed.\n*/\nstatic void populateCellCache(CellArray *p, int idx, int N){\n  assert( idx>=0 && idx+N<=p->nCell );\n  while( N>0 ){\n    assert( p->apCell[idx]!=0 );\n    if( p->szCell[idx]==0 ){\n      p->szCell[idx] = p->pRef->xCellSize(p->pRef, p->apCell[idx]);\n    }else{\n      assert( CORRUPT_DB ||\n              p->szCell[idx]==p->pRef->xCellSize(p->pRef, p->apCell[idx]) );\n    }\n    idx++;\n    N--;\n  }\n}\n\n/*\n** Return the size of the Nth element of the cell array\n*/\nstatic SQLITE_NOINLINE u16 computeCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  assert( p->szCell[N]==0 );\n  p->szCell[N] = p->pRef->xCellSize(p->pRef, p->apCell[N]);\n  return p->szCell[N];\n}\nstatic u16 cachedCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  if( p->szCell[N] ) return p->szCell[N];\n  return computeCellSize(p, N);\n}\n\n/*\n** Array apCell[] contains pointers to nCell b-tree page cells. The \n** szCell[] array contains the size in bytes of each cell. This function\n** replaces the current contents of page pPg with the contents of the cell\n** array.\n**\n** Some of the cells in apCell[] may currently be stored in pPg. This\n** function works around problems caused by this by making a copy of any \n** such cells before overwriting the page data.\n**\n** The MemPage.nFree field is invalidated by this function. It is the \n** responsibility of the caller to set it correctly.\n*/\nstatic int rebuildPage(\n  MemPage *pPg,                   /* Edit this page */\n  int nCell,                      /* Final number of cells on page */\n  u8 **apCell,                    /* Array of cells */\n  u16 *szCell                     /* Array of cell sizes */\n){\n  const int hdr = pPg->hdrOffset;          /* Offset of header on pPg */\n  u8 * const aData = pPg->aData;           /* Pointer to data for pPg */\n  const int usableSize = pPg->pBt->usableSize;\n  u8 * const pEnd = &aData[usableSize];\n  int i;\n  u8 *pCellptr = pPg->aCellIdx;\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  u8 *pData;\n\n  i = get2byte(&aData[hdr+5]);\n  memcpy(&pTmp[i], &aData[i], usableSize - i);\n\n  pData = pEnd;\n  for(i=0; i<nCell; i++){\n    u8 *pCell = apCell[i];\n    if( SQLITE_WITHIN(pCell,aData,pEnd) ){\n      pCell = &pTmp[pCell - aData];\n    }\n    pData -= szCell[i];\n    put2byte(pCellptr, (pData - aData));\n    pCellptr += 2;\n    if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;\n    memcpy(pData, pCell, szCell[i]);\n    assert( szCell[i]==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );\n    testcase( szCell[i]!=pPg->xCellSize(pPg,pCell) );\n  }\n\n  /* The pPg->nFree field is now set incorrectly. The caller will fix it. */\n  pPg->nCell = nCell;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+1], 0);\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n  aData[hdr+7] = 0x00;\n  return SQLITE_OK;\n}\n\n/*\n** Array apCell[] contains nCell pointers to b-tree cells. Array szCell\n** contains the size in bytes of each such cell. This function attempts to \n** add the cells stored in the array to page pPg. If it cannot (because \n** the page needs to be defragmented before the cells will fit), non-zero\n** is returned. Otherwise, if the cells are added successfully, zero is\n** returned.\n**\n** Argument pCellptr points to the first entry in the cell-pointer array\n** (part of page pPg) to populate. After cell apCell[0] is written to the\n** page body, a 16-bit offset is written to pCellptr. And so on, for each\n** cell in the array. It is the responsibility of the caller to ensure\n** that it is safe to overwrite this part of the cell-pointer array.\n**\n** When this function is called, *ppData points to the start of the \n** content area on page pPg. If the size of the content area is extended,\n** *ppData is updated to point to the new start of the content area\n** before returning.\n**\n** Finally, argument pBegin points to the byte immediately following the\n** end of the space required by this page for the cell-pointer area (for\n** all cells - not just those inserted by the current call). If the content\n** area must be extended to before this point in order to accomodate all\n** cells in apCell[], then the cells do not fit and non-zero is returned.\n*/\nstatic int pageInsertArray(\n  MemPage *pPg,                   /* Page to add cells to */\n  u8 *pBegin,                     /* End of cell-pointer array */\n  u8 **ppData,                    /* IN/OUT: Page content -area pointer */\n  u8 *pCellptr,                   /* Pointer to cell-pointer area */\n  int iFirst,                     /* Index of first cell to add */\n  int nCell,                      /* Number of cells to add to pPg */\n  CellArray *pCArray              /* Array of cells */\n){\n  int i;\n  u8 *aData = pPg->aData;\n  u8 *pData = *ppData;\n  int iEnd = iFirst + nCell;\n  assert( CORRUPT_DB || pPg->hdrOffset==0 );    /* Never called on page 1 */\n  for(i=iFirst; i<iEnd; i++){\n    int sz, rc;\n    u8 *pSlot;\n    sz = cachedCellSize(pCArray, i);\n    if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){\n      if( (pData - pBegin)<sz ) return 1;\n      pData -= sz;\n      pSlot = pData;\n    }\n    /* pSlot and pCArray->apCell[i] will never overlap on a well-formed\n    ** database.  But they might for a corrupt database.  Hence use memmove()\n    ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */\n    assert( (pSlot+sz)<=pCArray->apCell[i]\n         || pSlot>=(pCArray->apCell[i]+sz)\n         || CORRUPT_DB );\n    memmove(pSlot, pCArray->apCell[i], sz);\n    put2byte(pCellptr, (pSlot - aData));\n    pCellptr += 2;\n  }\n  *ppData = pData;\n  return 0;\n}\n\n/*\n** Array apCell[] contains nCell pointers to b-tree cells. Array szCell \n** contains the size in bytes of each such cell. This function adds the\n** space associated with each cell in the array that is currently stored \n** within the body of pPg to the pPg free-list. The cell-pointers and other\n** fields of the page are not updated.\n**\n** This function returns the total number of cells added to the free-list.\n*/\nstatic int pageFreeArray(\n  MemPage *pPg,                   /* Page to edit */\n  int iFirst,                     /* First cell to delete */\n  int nCell,                      /* Cells to delete */\n  CellArray *pCArray              /* Array of cells */\n){\n  u8 * const aData = pPg->aData;\n  u8 * const pEnd = &aData[pPg->pBt->usableSize];\n  u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];\n  int nRet = 0;\n  int i;\n  int iEnd = iFirst + nCell;\n  u8 *pFree = 0;\n  int szFree = 0;\n\n  for(i=iFirst; i<iEnd; i++){\n    u8 *pCell = pCArray->apCell[i];\n    if( SQLITE_WITHIN(pCell, pStart, pEnd) ){\n      int sz;\n      /* No need to use cachedCellSize() here.  The sizes of all cells that\n      ** are to be freed have already been computing while deciding which\n      ** cells need freeing */\n      sz = pCArray->szCell[i];  assert( sz>0 );\n      if( pFree!=(pCell + sz) ){\n        if( pFree ){\n          assert( pFree>aData && (pFree - aData)<65536 );\n          freeSpace(pPg, (u16)(pFree - aData), szFree);\n        }\n        pFree = pCell;\n        szFree = sz;\n        if( pFree+sz>pEnd ) return 0;\n      }else{\n        pFree = pCell;\n        szFree += sz;\n      }\n      nRet++;\n    }\n  }\n  if( pFree ){\n    assert( pFree>aData && (pFree - aData)<65536 );\n    freeSpace(pPg, (u16)(pFree - aData), szFree);\n  }\n  return nRet;\n}\n\n/*\n** apCell[] and szCell[] contains pointers to and sizes of all cells in the\n** pages being balanced.  The current page, pPg, has pPg->nCell cells starting\n** with apCell[iOld].  After balancing, this page should hold nNew cells\n** starting at apCell[iNew].\n**\n** This routine makes the necessary adjustments to pPg so that it contains\n** the correct cells after being balanced.\n**\n** The pPg->nFree field is invalid when this function returns. It is the\n** responsibility of the caller to set it correctly.\n*/\nstatic int editPage(\n  MemPage *pPg,                   /* Edit this page */\n  int iOld,                       /* Index of first cell currently on page */\n  int iNew,                       /* Index of new first cell on page */\n  int nNew,                       /* Final number of cells on page */\n  CellArray *pCArray              /* Array of cells and sizes */\n){\n  u8 * const aData = pPg->aData;\n  const int hdr = pPg->hdrOffset;\n  u8 *pBegin = &pPg->aCellIdx[nNew * 2];\n  int nCell = pPg->nCell;       /* Cells stored on pPg */\n  u8 *pData;\n  u8 *pCellptr;\n  int i;\n  int iOldEnd = iOld + pPg->nCell + pPg->nOverflow;\n  int iNewEnd = iNew + nNew;\n\n#ifdef SQLITE_DEBUG\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  memcpy(pTmp, aData, pPg->pBt->usableSize);\n#endif\n\n  /* Remove cells from the start and end of the page */\n  if( iOld<iNew ){\n    int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray);\n    memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);\n    nCell -= nShift;\n  }\n  if( iNewEnd < iOldEnd ){\n    nCell -= pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);\n  }\n\n  pData = &aData[get2byteNotZero(&aData[hdr+5])];\n  if( pData<pBegin ) goto editpage_fail;\n\n  /* Add cells to the start of the page */\n  if( iNew<iOld ){\n    int nAdd = MIN(nNew,iOld-iNew);\n    assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );\n    pCellptr = pPg->aCellIdx;\n    memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);\n    if( pageInsertArray(\n          pPg, pBegin, &pData, pCellptr,\n          iNew, nAdd, pCArray\n    ) ) goto editpage_fail;\n    nCell += nAdd;\n  }\n\n  /* Add any overflow cells */\n  for(i=0; i<pPg->nOverflow; i++){\n    int iCell = (iOld + pPg->aiOvfl[i]) - iNew;\n    if( iCell>=0 && iCell<nNew ){\n      pCellptr = &pPg->aCellIdx[iCell * 2];\n      memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);\n      nCell++;\n      if( pageInsertArray(\n            pPg, pBegin, &pData, pCellptr,\n            iCell+iNew, 1, pCArray\n      ) ) goto editpage_fail;\n    }\n  }\n\n  /* Append cells to the end of the page */\n  pCellptr = &pPg->aCellIdx[nCell*2];\n  if( pageInsertArray(\n        pPg, pBegin, &pData, pCellptr,\n        iNew+nCell, nNew-nCell, pCArray\n  ) ) goto editpage_fail;\n\n  pPg->nCell = nNew;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<nNew && !CORRUPT_DB; i++){\n    u8 *pCell = pCArray->apCell[i+iNew];\n    int iOff = get2byteAligned(&pPg->aCellIdx[i*2]);\n    if( SQLITE_WITHIN(pCell, aData, &aData[pPg->pBt->usableSize]) ){\n      pCell = &pTmp[pCell - aData];\n    }\n    assert( 0==memcmp(pCell, &aData[iOff],\n            pCArray->pRef->xCellSize(pCArray->pRef, pCArray->apCell[i+iNew])) );\n  }\n#endif\n\n  return SQLITE_OK;\n editpage_fail:\n  /* Unable to edit this page. Rebuild it from scratch instead. */\n  populateCellCache(pCArray, iNew, nNew);\n  return rebuildPage(pPg, nNew, &pCArray->apCell[iNew], &pCArray->szCell[iNew]);\n}\n\n/*\n** The following parameters determine how many adjacent pages get involved\n** in a balancing operation.  NN is the number of neighbors on either side\n** of the page that participate in the balancing operation.  NB is the\n** total number of pages that participate, including the target page and\n** NN neighbors on either side.\n**\n** The minimum value of NN is 1 (of course).  Increasing NN above 1\n** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance\n** in exchange for a larger degradation in INSERT and UPDATE performance.\n** The value of NN appears to give the best results overall.\n*/\n#define NN 1             /* Number of neighbors on either side of pPage */\n#define NB (NN*2+1)      /* Total pages involved in the balance */\n\n\n#ifndef SQLITE_OMIT_QUICKBALANCE\n/*\n** This version of balance() handles the common special case where\n** a new entry is being inserted on the extreme right-end of the\n** tree, in other words, when the new entry will become the largest\n** entry in the tree.\n**\n** Instead of trying to balance the 3 right-most leaf pages, just add\n** a new page to the right-hand side and put the one new entry in\n** that page.  This leaves the right side of the tree somewhat\n** unbalanced.  But odds are that we will be inserting new entries\n** at the end soon afterwards so the nearly empty page will quickly\n** fill up.  On average.\n**\n** pPage is the leaf page which is the right-most page in the tree.\n** pParent is its parent.  pPage must have a single overflow entry\n** which is also the right-most entry on the page.\n**\n** The pSpace buffer is used to store a temporary copy of the divider\n** cell that will be inserted into pParent. Such a cell consists of a 4\n** byte page number followed by a variable length integer. In other\n** words, at most 13 bytes. Hence the pSpace buffer must be at\n** least 13 bytes in size.\n*/\nstatic int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){\n  BtShared *const pBt = pPage->pBt;    /* B-Tree Database */\n  MemPage *pNew;                       /* Newly allocated page */\n  int rc;                              /* Return Code */\n  Pgno pgnoNew;                        /* Page number of pNew */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  assert( pPage->nOverflow==1 );\n\n  /* This error condition is now caught prior to reaching this function */\n  if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;\n\n  /* Allocate a new page. This page will become the right-sibling of \n  ** pPage. Make the parent page writable, so that the new divider cell\n  ** may be inserted. If both these operations are successful, proceed.\n  */\n  rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);\n\n  if( rc==SQLITE_OK ){\n\n    u8 *pOut = &pSpace[4];\n    u8 *pCell = pPage->apOvfl[0];\n    u16 szCell = pPage->xCellSize(pPage, pCell);\n    u8 *pStop;\n\n    assert( sqlite3PagerIswriteable(pNew->pDbPage) );\n    assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );\n    zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);\n    rc = rebuildPage(pNew, 1, &pCell, &szCell);\n    if( NEVER(rc) ) return rc;\n    pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;\n\n    /* If this is an auto-vacuum database, update the pointer map\n    ** with entries for the new page, and any pointer from the \n    ** cell on the page to an overflow page. If either of these\n    ** operations fails, the return code is set, but the contents\n    ** of the parent page are still manipulated by thh code below.\n    ** That is Ok, at this point the parent page is guaranteed to\n    ** be marked as dirty. Returning an error code will cause a\n    ** rollback, undoing any changes made to the parent page.\n    */\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);\n      if( szCell>pNew->minLocal ){\n        ptrmapPutOvflPtr(pNew, pCell, &rc);\n      }\n    }\n  \n    /* Create a divider cell to insert into pParent. The divider cell\n    ** consists of a 4-byte page number (the page number of pPage) and\n    ** a variable length key value (which must be the same value as the\n    ** largest key on pPage).\n    **\n    ** To find the largest key value on pPage, first find the right-most \n    ** cell on pPage. The first two fields of this cell are the \n    ** record-length (a variable length integer at most 32-bits in size)\n    ** and the key value (a variable length integer, may have any value).\n    ** The first of the while(...) loops below skips over the record-length\n    ** field. The second while(...) loop copies the key value from the\n    ** cell on pPage into the pSpace buffer.\n    */\n    pCell = findCell(pPage, pPage->nCell-1);\n    pStop = &pCell[9];\n    while( (*(pCell++)&0x80) && pCell<pStop );\n    pStop = &pCell[9];\n    while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );\n\n    /* Insert the new divider cell into pParent. */\n    if( rc==SQLITE_OK ){\n      insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),\n                   0, pPage->pgno, &rc);\n    }\n\n    /* Set the right-child pointer of pParent to point to the new page. */\n    put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);\n  \n    /* Release the reference to the new page. */\n    releasePage(pNew);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_OMIT_QUICKBALANCE */\n\n#if 0\n/*\n** This function does not contribute anything to the operation of SQLite.\n** it is sometimes activated temporarily while debugging code responsible \n** for setting pointer-map entries.\n*/\nstatic int ptrmapCheckPages(MemPage **apPage, int nPage){\n  int i, j;\n  for(i=0; i<nPage; i++){\n    Pgno n;\n    u8 e;\n    MemPage *pPage = apPage[i];\n    BtShared *pBt = pPage->pBt;\n    assert( pPage->isInit );\n\n    for(j=0; j<pPage->nCell; j++){\n      CellInfo info;\n      u8 *z;\n     \n      z = findCell(pPage, j);\n      pPage->xParseCell(pPage, z, &info);\n      if( info.nLocal<info.nPayload ){\n        Pgno ovfl = get4byte(&z[info.nSize-4]);\n        ptrmapGet(pBt, ovfl, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );\n      }\n      if( !pPage->leaf ){\n        Pgno child = get4byte(z);\n        ptrmapGet(pBt, child, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_BTREE );\n      }\n    }\n    if( !pPage->leaf ){\n      Pgno child = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n      ptrmapGet(pBt, child, &e, &n);\n      assert( n==pPage->pgno && e==PTRMAP_BTREE );\n    }\n  }\n  return 1;\n}\n#endif\n\n/*\n** This function is used to copy the contents of the b-tree node stored \n** on page pFrom to page pTo. If page pFrom was not a leaf page, then\n** the pointer-map entries for each child page are updated so that the\n** parent page stored in the pointer map is page pTo. If pFrom contained\n** any cells with overflow page pointers, then the corresponding pointer\n** map entries are also updated so that the parent page is page pTo.\n**\n** If pFrom is currently carrying any overflow cells (entries in the\n** MemPage.apOvfl[] array), they are not copied to pTo. \n**\n** Before returning, page pTo is reinitialized using btreeInitPage().\n**\n** The performance of this function is not critical. It is only used by \n** the balance_shallower() and balance_deeper() procedures, neither of\n** which are called often under normal circumstances.\n*/\nstatic void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    BtShared * const pBt = pFrom->pBt;\n    u8 * const aFrom = pFrom->aData;\n    u8 * const aTo = pTo->aData;\n    int const iFromHdr = pFrom->hdrOffset;\n    int const iToHdr = ((pTo->pgno==1) ? 100 : 0);\n    int rc;\n    int iData;\n  \n  \n    assert( pFrom->isInit );\n    assert( pFrom->nFree>=iToHdr );\n    assert( get2byte(&aFrom[iFromHdr+5]) <= (int)pBt->usableSize );\n  \n    /* Copy the b-tree node content from page pFrom to page pTo. */\n    iData = get2byte(&aFrom[iFromHdr+5]);\n    memcpy(&aTo[iData], &aFrom[iData], pBt->usableSize-iData);\n    memcpy(&aTo[iToHdr], &aFrom[iFromHdr], pFrom->cellOffset + 2*pFrom->nCell);\n  \n    /* Reinitialize page pTo so that the contents of the MemPage structure\n    ** match the new data. The initialization of pTo can actually fail under\n    ** fairly obscure circumstances, even though it is a copy of initialized \n    ** page pFrom.\n    */\n    pTo->isInit = 0;\n    rc = btreeInitPage(pTo);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n  \n    /* If this is an auto-vacuum database, update the pointer-map entries\n    ** for any b-tree or overflow pages that pTo now contains the pointers to.\n    */\n    if( ISAUTOVACUUM ){\n      *pRC = setChildPtrmaps(pTo);\n    }\n  }\n}\n\n/*\n** This routine redistributes cells on the iParentIdx'th child of pParent\n** (hereafter \"the page\") and up to 2 siblings so that all pages have about the\n** same amount of free space. Usually a single sibling on either side of the\n** page are used in the balancing, though both siblings might come from one\n** side if the page is the first or last child of its parent. If the page \n** has fewer than 2 siblings (something which can only happen if the page\n** is a root page or a child of a root page) then all available siblings\n** participate in the balancing.\n**\n** The number of siblings of the page might be increased or decreased by \n** one or two in an effort to keep pages nearly full but not over full. \n**\n** Note that when this routine is called, some of the cells on the page\n** might not actually be stored in MemPage.aData[]. This can happen\n** if the page is overfull. This routine ensures that all cells allocated\n** to the page and its siblings fit into MemPage.aData[] before returning.\n**\n** In the course of balancing the page and its siblings, cells may be\n** inserted into or removed from the parent page (pParent). Doing so\n** may cause the parent page to become overfull or underfull. If this\n** happens, it is the responsibility of the caller to invoke the correct\n** balancing routine to fix this problem (see the balance() routine). \n**\n** If this routine fails for any reason, it might leave the database\n** in a corrupted state. So if this routine fails, the database should\n** be rolled back.\n**\n** The third argument to this function, aOvflSpace, is a pointer to a\n** buffer big enough to hold one page. If while inserting cells into the parent\n** page (pParent) the parent page becomes overfull, this buffer is\n** used to store the parent's overflow cells. Because this function inserts\n** a maximum of four divider cells into the parent page, and the maximum\n** size of a cell stored within an internal node is always less than 1/4\n** of the page-size, the aOvflSpace[] buffer is guaranteed to be large\n** enough for all overflow cells.\n**\n** If aOvflSpace is set to a null pointer, this function returns \n** SQLITE_NOMEM.\n*/\nstatic int balance_nonroot(\n  MemPage *pParent,               /* Parent page of siblings being balanced */\n  int iParentIdx,                 /* Index of \"the page\" in pParent */\n  u8 *aOvflSpace,                 /* page-size bytes of space for parent ovfl */\n  int isRoot,                     /* True if pParent is a root-page */\n  int bBulk                       /* True if this call is part of a bulk load */\n){\n  BtShared *pBt;               /* The whole database */\n  int nMaxCells = 0;           /* Allocated size of apCell, szCell, aFrom. */\n  int nNew = 0;                /* Number of pages in apNew[] */\n  int nOld;                    /* Number of pages in apOld[] */\n  int i, j, k;                 /* Loop counters */\n  int nxDiv;                   /* Next divider slot in pParent->aCell[] */\n  int rc = SQLITE_OK;          /* The return code */\n  u16 leafCorrection;          /* 4 if pPage is a leaf.  0 if not */\n  int leafData;                /* True if pPage is a leaf of a LEAFDATA tree */\n  int usableSpace;             /* Bytes in pPage beyond the header */\n  int pageFlags;               /* Value of pPage->aData[0] */\n  int iSpace1 = 0;             /* First unused byte of aSpace1[] */\n  int iOvflSpace = 0;          /* First unused byte of aOvflSpace[] */\n  int szScratch;               /* Size of scratch memory requested */\n  MemPage *apOld[NB];          /* pPage and up to two siblings */\n  MemPage *apNew[NB+2];        /* pPage and up to NB siblings after balancing */\n  u8 *pRight;                  /* Location in parent of right-sibling pointer */\n  u8 *apDiv[NB-1];             /* Divider cells in pParent */\n  int cntNew[NB+2];            /* Index in b.paCell[] of cell after i-th page */\n  int cntOld[NB+2];            /* Old index in b.apCell[] */\n  int szNew[NB+2];             /* Combined size of cells placed on i-th page */\n  u8 *aSpace1;                 /* Space for copies of dividers cells */\n  Pgno pgno;                   /* Temp var to store a page number in */\n  u8 abDone[NB+2];             /* True after i'th new page is populated */\n  Pgno aPgno[NB+2];            /* Page numbers of new pages before shuffling */\n  Pgno aPgOrder[NB+2];         /* Copy of aPgno[] used for sorting pages */\n  u16 aPgFlags[NB+2];          /* flags field of new pages before shuffling */\n  CellArray b;                  /* Parsed information on cells being balanced */\n\n  memset(abDone, 0, sizeof(abDone));\n  b.nCell = 0;\n  b.apCell = 0;\n  pBt = pParent->pBt;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n\n#if 0\n  TRACE((\"BALANCE: begin page %d child of %d\\n\", pPage->pgno, pParent->pgno));\n#endif\n\n  /* At this point pParent may have at most one overflow cell. And if\n  ** this overflow cell is present, it must be the cell with \n  ** index iParentIdx. This scenario comes about when this function\n  ** is called (indirectly) from sqlite3BtreeDelete().\n  */\n  assert( pParent->nOverflow==0 || pParent->nOverflow==1 );\n  assert( pParent->nOverflow==0 || pParent->aiOvfl[0]==iParentIdx );\n\n  if( !aOvflSpace ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* Find the sibling pages to balance. Also locate the cells in pParent \n  ** that divide the siblings. An attempt is made to find NN siblings on \n  ** either side of pPage. More siblings are taken from one side, however, \n  ** if there are fewer than NN siblings on the other side. If pParent\n  ** has NB or fewer children then all children of pParent are taken.  \n  **\n  ** This loop also drops the divider cells from the parent page. This\n  ** way, the remainder of the function does not have to deal with any\n  ** overflow cells in the parent page, since if any existed they will\n  ** have already been removed.\n  */\n  i = pParent->nOverflow + pParent->nCell;\n  if( i<2 ){\n    nxDiv = 0;\n  }else{\n    assert( bBulk==0 || bBulk==1 );\n    if( iParentIdx==0 ){                 \n      nxDiv = 0;\n    }else if( iParentIdx==i ){\n      nxDiv = i-2+bBulk;\n    }else{\n      nxDiv = iParentIdx-1;\n    }\n    i = 2-bBulk;\n  }\n  nOld = i+1;\n  if( (i+nxDiv-pParent->nOverflow)==pParent->nCell ){\n    pRight = &pParent->aData[pParent->hdrOffset+8];\n  }else{\n    pRight = findCell(pParent, i+nxDiv-pParent->nOverflow);\n  }\n  pgno = get4byte(pRight);\n  while( 1 ){\n    rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);\n    if( rc ){\n      memset(apOld, 0, (i+1)*sizeof(MemPage*));\n      goto balance_cleanup;\n    }\n    nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;\n    if( (i--)==0 ) break;\n\n    if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){\n      apDiv[i] = pParent->apOvfl[0];\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n      pParent->nOverflow = 0;\n    }else{\n      apDiv[i] = findCell(pParent, i+nxDiv-pParent->nOverflow);\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n\n      /* Drop the cell from the parent page. apDiv[i] still points to\n      ** the cell within the parent, even though it has been dropped.\n      ** This is safe because dropping a cell only overwrites the first\n      ** four bytes of it, and this function does not need the first\n      ** four bytes of the divider cell. So the pointer is safe to use\n      ** later on.  \n      **\n      ** But not if we are in secure-delete mode. In secure-delete mode,\n      ** the dropCell() routine will overwrite the entire cell with zeroes.\n      ** In this case, temporarily copy the cell into the aOvflSpace[]\n      ** buffer. It will be copied out again as soon as the aSpace[] buffer\n      ** is allocated.  */\n      if( pBt->btsFlags & BTS_FAST_SECURE ){\n        int iOff;\n\n        iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);\n        if( (iOff+szNew[i])>(int)pBt->usableSize ){\n          rc = SQLITE_CORRUPT_BKPT;\n          memset(apOld, 0, (i+1)*sizeof(MemPage*));\n          goto balance_cleanup;\n        }else{\n          memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]);\n          apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData];\n        }\n      }\n      dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);\n    }\n  }\n\n  /* Make nMaxCells a multiple of 4 in order to preserve 8-byte\n  ** alignment */\n  nMaxCells = (nMaxCells + 3)&~3;\n\n  /*\n  ** Allocate space for memory structures\n  */\n  szScratch =\n       nMaxCells*sizeof(u8*)                       /* b.apCell */\n     + nMaxCells*sizeof(u16)                       /* b.szCell */\n     + pBt->pageSize;                              /* aSpace1 */\n\n  assert( szScratch<=6*(int)pBt->pageSize );\n  b.apCell = sqlite3StackAllocRaw(0, szScratch );\n  if( b.apCell==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto balance_cleanup;\n  }\n  b.szCell = (u16*)&b.apCell[nMaxCells];\n  aSpace1 = (u8*)&b.szCell[nMaxCells];\n  assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );\n\n  /*\n  ** Load pointers to all cells on sibling pages and the divider cells\n  ** into the local b.apCell[] array.  Make copies of the divider cells\n  ** into space obtained from aSpace1[]. The divider cells have already\n  ** been removed from pParent.\n  **\n  ** If the siblings are on leaf pages, then the child pointers of the\n  ** divider cells are stripped from the cells before they are copied\n  ** into aSpace1[].  In this way, all cells in b.apCell[] are without\n  ** child pointers.  If siblings are not leaves, then all cell in\n  ** b.apCell[] include child pointers.  Either way, all cells in b.apCell[]\n  ** are alike.\n  **\n  ** leafCorrection:  4 if pPage is a leaf.  0 if pPage is not a leaf.\n  **       leafData:  1 if pPage holds key+data and pParent holds only keys.\n  */\n  b.pRef = apOld[0];\n  leafCorrection = b.pRef->leaf*4;\n  leafData = b.pRef->intKeyLeaf;\n  for(i=0; i<nOld; i++){\n    MemPage *pOld = apOld[i];\n    int limit = pOld->nCell;\n    u8 *aData = pOld->aData;\n    u16 maskPage = pOld->maskPage;\n    u8 *piCell = aData + pOld->cellOffset;\n    u8 *piEnd;\n\n    /* Verify that all sibling pages are of the same \"type\" (table-leaf,\n    ** table-interior, index-leaf, or index-interior).\n    */\n    if( pOld->aData[0]!=apOld[0]->aData[0] ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n\n    /* Load b.apCell[] with pointers to all cells in pOld.  If pOld\n    ** constains overflow cells, include them in the b.apCell[] array\n    ** in the correct spot.\n    **\n    ** Note that when there are multiple overflow cells, it is always the\n    ** case that they are sequential and adjacent.  This invariant arises\n    ** because multiple overflows can only occurs when inserting divider\n    ** cells into a parent on a prior balance, and divider cells are always\n    ** adjacent and are inserted in order.  There is an assert() tagged\n    ** with \"NOTE 1\" in the overflow cell insertion loop to prove this\n    ** invariant.\n    **\n    ** This must be done in advance.  Once the balance starts, the cell\n    ** offset section of the btree page will be overwritten and we will no\n    ** long be able to find the cells if a pointer to each cell is not saved\n    ** first.\n    */\n    memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));\n    if( pOld->nOverflow>0 ){\n      limit = pOld->aiOvfl[0];\n      for(j=0; j<limit; j++){\n        b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n        piCell += 2;\n        b.nCell++;\n      }\n      for(k=0; k<pOld->nOverflow; k++){\n        assert( k==0 || pOld->aiOvfl[k-1]+1==pOld->aiOvfl[k] );/* NOTE 1 */\n        b.apCell[b.nCell] = pOld->apOvfl[k];\n        b.nCell++;\n      }\n    }\n    piEnd = aData + pOld->cellOffset + 2*pOld->nCell;\n    while( piCell<piEnd ){\n      assert( b.nCell<nMaxCells );\n      b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n      piCell += 2;\n      b.nCell++;\n    }\n\n    cntOld[i] = b.nCell;\n    if( i<nOld-1 && !leafData){\n      u16 sz = (u16)szNew[i];\n      u8 *pTemp;\n      assert( b.nCell<nMaxCells );\n      b.szCell[b.nCell] = sz;\n      pTemp = &aSpace1[iSpace1];\n      iSpace1 += sz;\n      assert( sz<=pBt->maxLocal+23 );\n      assert( iSpace1 <= (int)pBt->pageSize );\n      memcpy(pTemp, apDiv[i], sz);\n      b.apCell[b.nCell] = pTemp+leafCorrection;\n      assert( leafCorrection==0 || leafCorrection==4 );\n      b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;\n      if( !pOld->leaf ){\n        assert( leafCorrection==0 );\n        assert( pOld->hdrOffset==0 );\n        /* The right pointer of the child page pOld becomes the left\n        ** pointer of the divider cell */\n        memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);\n      }else{\n        assert( leafCorrection==4 );\n        while( b.szCell[b.nCell]<4 ){\n          /* Do not allow any cells smaller than 4 bytes. If a smaller cell\n          ** does exist, pad it with 0x00 bytes. */\n          assert( b.szCell[b.nCell]==3 || CORRUPT_DB );\n          assert( b.apCell[b.nCell]==&aSpace1[iSpace1-3] || CORRUPT_DB );\n          aSpace1[iSpace1++] = 0x00;\n          b.szCell[b.nCell]++;\n        }\n      }\n      b.nCell++;\n    }\n  }\n\n  /*\n  ** Figure out the number of pages needed to hold all b.nCell cells.\n  ** Store this number in \"k\".  Also compute szNew[] which is the total\n  ** size of all cells on the i-th page and cntNew[] which is the index\n  ** in b.apCell[] of the cell that divides page i from page i+1.  \n  ** cntNew[k] should equal b.nCell.\n  **\n  ** Values computed by this block:\n  **\n  **           k: The total number of sibling pages\n  **    szNew[i]: Spaced used on the i-th sibling page.\n  **   cntNew[i]: Index in b.apCell[] and b.szCell[] for the first cell to\n  **              the right of the i-th sibling page.\n  ** usableSpace: Number of bytes of space available on each sibling.\n  ** \n  */\n  usableSpace = pBt->usableSize - 12 + leafCorrection;\n  for(i=0; i<nOld; i++){\n    MemPage *p = apOld[i];\n    szNew[i] = usableSpace - p->nFree;\n    for(j=0; j<p->nOverflow; j++){\n      szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);\n    }\n    cntNew[i] = cntOld[i];\n  }\n  k = nOld;\n  for(i=0; i<k; i++){\n    int sz;\n    while( szNew[i]>usableSpace ){\n      if( i+1>=k ){\n        k = i+2;\n        if( k>NB+2 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }\n        szNew[k-1] = 0;\n        cntNew[k-1] = b.nCell;\n      }\n      sz = 2 + cachedCellSize(&b, cntNew[i]-1);\n      szNew[i] -= sz;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] += sz;\n      cntNew[i]--;\n    }\n    while( cntNew[i]<b.nCell ){\n      sz = 2 + cachedCellSize(&b, cntNew[i]);\n      if( szNew[i]+sz>usableSpace ) break;\n      szNew[i] += sz;\n      cntNew[i]++;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] -= sz;\n    }\n    if( cntNew[i]>=b.nCell ){\n      k = i+1;\n    }else if( cntNew[i] <= (i>0 ? cntNew[i-1] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /*\n  ** The packing computed by the previous block is biased toward the siblings\n  ** on the left side (siblings with smaller keys). The left siblings are\n  ** always nearly full, while the right-most sibling might be nearly empty.\n  ** The next block of code attempts to adjust the packing of siblings to\n  ** get a better balance.\n  **\n  ** This adjustment is more than an optimization.  The packing above might\n  ** be so out of balance as to be illegal.  For example, the right-most\n  ** sibling might be completely empty.  This adjustment is not optional.\n  */\n  for(i=k-1; i>0; i--){\n    int szRight = szNew[i];  /* Size of sibling on the right */\n    int szLeft = szNew[i-1]; /* Size of sibling on the left */\n    int r;              /* Index of right-most cell in left sibling */\n    int d;              /* Index of first cell to the left of right sibling */\n\n    r = cntNew[i-1] - 1;\n    d = r + 1 - leafData;\n    (void)cachedCellSize(&b, d);\n    do{\n      assert( d<nMaxCells );\n      assert( r<nMaxCells );\n      (void)cachedCellSize(&b, r);\n      if( szRight!=0\n       && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){\n        break;\n      }\n      szRight += b.szCell[d] + 2;\n      szLeft -= b.szCell[r] + 2;\n      cntNew[i-1] = r;\n      r--;\n      d--;\n    }while( r>=0 );\n    szNew[i] = szRight;\n    szNew[i-1] = szLeft;\n    if( cntNew[i-1] <= (i>1 ? cntNew[i-2] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /* Sanity check:  For a non-corrupt database file one of the follwing\n  ** must be true:\n  **    (1) We found one or more cells (cntNew[0])>0), or\n  **    (2) pPage is a virtual root page.  A virtual root page is when\n  **        the real root page is page 1 and we are the only child of\n  **        that page.\n  */\n  assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) || CORRUPT_DB);\n  TRACE((\"BALANCE: old: %d(nc=%d) %d(nc=%d) %d(nc=%d)\\n\",\n    apOld[0]->pgno, apOld[0]->nCell,\n    nOld>=2 ? apOld[1]->pgno : 0, nOld>=2 ? apOld[1]->nCell : 0,\n    nOld>=3 ? apOld[2]->pgno : 0, nOld>=3 ? apOld[2]->nCell : 0\n  ));\n\n  /*\n  ** Allocate k new pages.  Reuse old pages where possible.\n  */\n  pageFlags = apOld[0]->aData[0];\n  for(i=0; i<k; i++){\n    MemPage *pNew;\n    if( i<nOld ){\n      pNew = apNew[i] = apOld[i];\n      apOld[i] = 0;\n      rc = sqlite3PagerWrite(pNew->pDbPage);\n      nNew++;\n      if( rc ) goto balance_cleanup;\n    }else{\n      assert( i>0 );\n      rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);\n      if( rc ) goto balance_cleanup;\n      zeroPage(pNew, pageFlags);\n      apNew[i] = pNew;\n      nNew++;\n      cntOld[i] = b.nCell;\n\n      /* Set the pointer-map entry for the new sibling page. */\n      if( ISAUTOVACUUM ){\n        ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);\n        if( rc!=SQLITE_OK ){\n          goto balance_cleanup;\n        }\n      }\n    }\n  }\n\n  /*\n  ** Reassign page numbers so that the new pages are in ascending order. \n  ** This helps to keep entries in the disk file in order so that a scan\n  ** of the table is closer to a linear scan through the file. That in turn \n  ** helps the operating system to deliver pages from the disk more rapidly.\n  **\n  ** An O(n^2) insertion sort algorithm is used, but since n is never more \n  ** than (NB+2) (a small constant), that should not be a problem.\n  **\n  ** When NB==3, this one optimization makes the database about 25% faster \n  ** for large insertions and deletions.\n  */\n  for(i=0; i<nNew; i++){\n    aPgOrder[i] = aPgno[i] = apNew[i]->pgno;\n    aPgFlags[i] = apNew[i]->pDbPage->flags;\n    for(j=0; j<i; j++){\n      if( aPgno[j]==aPgno[i] ){\n        /* This branch is taken if the set of sibling pages somehow contains\n        ** duplicate entries. This can happen if the database is corrupt. \n        ** It would be simpler to detect this as part of the loop below, but\n        ** we do the detection here in order to avoid populating the pager\n        ** cache with two separate objects associated with the same\n        ** page number.  */\n        assert( CORRUPT_DB );\n        rc = SQLITE_CORRUPT_BKPT;\n        goto balance_cleanup;\n      }\n    }\n  }\n  for(i=0; i<nNew; i++){\n    int iBest = 0;                /* aPgno[] index of page number to use */\n    for(j=1; j<nNew; j++){\n      if( aPgOrder[j]<aPgOrder[iBest] ) iBest = j;\n    }\n    pgno = aPgOrder[iBest];\n    aPgOrder[iBest] = 0xffffffff;\n    if( iBest!=i ){\n      if( iBest>i ){\n        sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, 0);\n      }\n      sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]);\n      apNew[i]->pgno = pgno;\n    }\n  }\n\n  TRACE((\"BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) \"\n         \"%d(%d nc=%d) %d(%d nc=%d)\\n\",\n    apNew[0]->pgno, szNew[0], cntNew[0],\n    nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,\n    nNew>=2 ? cntNew[1] - cntNew[0] - !leafData : 0,\n    nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,\n    nNew>=3 ? cntNew[2] - cntNew[1] - !leafData : 0,\n    nNew>=4 ? apNew[3]->pgno : 0, nNew>=4 ? szNew[3] : 0,\n    nNew>=4 ? cntNew[3] - cntNew[2] - !leafData : 0,\n    nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,\n    nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0\n  ));\n\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  put4byte(pRight, apNew[nNew-1]->pgno);\n\n  /* If the sibling pages are not leaves, ensure that the right-child pointer\n  ** of the right-most new sibling page is set to the value that was \n  ** originally in the same field of the right-most old sibling page. */\n  if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){\n    MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];\n    memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);\n  }\n\n  /* Make any required updates to pointer map entries associated with \n  ** cells stored on sibling pages following the balance operation. Pointer\n  ** map entries associated with divider cells are set by the insertCell()\n  ** routine. The associated pointer map entries are:\n  **\n  **   a) if the cell contains a reference to an overflow chain, the\n  **      entry associated with the first page in the overflow chain, and\n  **\n  **   b) if the sibling pages are not leaves, the child page associated\n  **      with the cell.\n  **\n  ** If the sibling pages are not leaves, then the pointer map entry \n  ** associated with the right-child of each sibling may also need to be \n  ** updated. This happens below, after the sibling pages have been \n  ** populated, not here.\n  */\n  if( ISAUTOVACUUM ){\n    MemPage *pNew = apNew[0];\n    u8 *aOld = pNew->aData;\n    int cntOldNext = pNew->nCell + pNew->nOverflow;\n    int usableSize = pBt->usableSize;\n    int iNew = 0;\n    int iOld = 0;\n\n    for(i=0; i<b.nCell; i++){\n      u8 *pCell = b.apCell[i];\n      if( i==cntOldNext ){\n        MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];\n        cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;\n        aOld = pOld->aData;\n      }\n      if( i==cntNew[iNew] ){\n        pNew = apNew[++iNew];\n        if( !leafData ) continue;\n      }\n\n      /* Cell pCell is destined for new sibling page pNew. Originally, it\n      ** was either part of sibling page iOld (possibly an overflow cell), \n      ** or else the divider cell to the left of sibling page iOld. So,\n      ** if sibling page iOld had the same page number as pNew, and if\n      ** pCell really was a part of sibling page iOld (not a divider or\n      ** overflow cell), we can skip updating the pointer map entries.  */\n      if( iOld>=nNew\n       || pNew->pgno!=aPgno[iOld]\n       || !SQLITE_WITHIN(pCell,aOld,&aOld[usableSize])\n      ){\n        if( !leafCorrection ){\n          ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);\n        }\n        if( cachedCellSize(&b,i)>pNew->minLocal ){\n          ptrmapPutOvflPtr(pNew, pCell, &rc);\n        }\n        if( rc ) goto balance_cleanup;\n      }\n    }\n  }\n\n  /* Insert new divider cells into pParent. */\n  for(i=0; i<nNew-1; i++){\n    u8 *pCell;\n    u8 *pTemp;\n    int sz;\n    MemPage *pNew = apNew[i];\n    j = cntNew[i];\n\n    assert( j<nMaxCells );\n    assert( b.apCell[j]!=0 );\n    pCell = b.apCell[j];\n    sz = b.szCell[j] + leafCorrection;\n    pTemp = &aOvflSpace[iOvflSpace];\n    if( !pNew->leaf ){\n      memcpy(&pNew->aData[8], pCell, 4);\n    }else if( leafData ){\n      /* If the tree is a leaf-data tree, and the siblings are leaves, \n      ** then there is no divider cell in b.apCell[]. Instead, the divider \n      ** cell consists of the integer key for the right-most cell of \n      ** the sibling-page assembled above only.\n      */\n      CellInfo info;\n      j--;\n      pNew->xParseCell(pNew, b.apCell[j], &info);\n      pCell = pTemp;\n      sz = 4 + putVarint(&pCell[4], info.nKey);\n      pTemp = 0;\n    }else{\n      pCell -= 4;\n      /* Obscure case for non-leaf-data trees: If the cell at pCell was\n      ** previously stored on a leaf node, and its reported size was 4\n      ** bytes, then it may actually be smaller than this \n      ** (see btreeParseCellPtr(), 4 bytes is the minimum size of\n      ** any cell). But it is important to pass the correct size to \n      ** insertCell(), so reparse the cell now.\n      **\n      ** This can only happen for b-trees used to evaluate \"IN (SELECT ...)\"\n      ** and WITHOUT ROWID tables with exactly one column which is the\n      ** primary key.\n      */\n      if( b.szCell[j]==4 ){\n        assert(leafCorrection==4);\n        sz = pParent->xCellSize(pParent, pCell);\n      }\n    }\n    iOvflSpace += sz;\n    assert( sz<=pBt->maxLocal+23 );\n    assert( iOvflSpace <= (int)pBt->pageSize );\n    insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);\n    if( rc!=SQLITE_OK ) goto balance_cleanup;\n    assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  }\n\n  /* Now update the actual sibling pages. The order in which they are updated\n  ** is important, as this code needs to avoid disrupting any page from which\n  ** cells may still to be read. In practice, this means:\n  **\n  **  (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the left-hand sibling apNew[iPg-1] has been updated.\n  **\n  **  (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the right-hand sibling apNew[iPg+1] has been updated.\n  **\n  ** If neither of the above apply, the page is safe to update.\n  **\n  ** The iPg value in the following loop starts at nNew-1 goes down\n  ** to 0, then back up to nNew-1 again, thus making two passes over\n  ** the pages.  On the initial downward pass, only condition (1) above\n  ** needs to be tested because (2) will always be true from the previous\n  ** step.  On the upward pass, both conditions are always true, so the\n  ** upwards pass simply processes pages that were missed on the downward\n  ** pass.\n  */\n  for(i=1-nNew; i<nNew; i++){\n    int iPg = i<0 ? -i : i;\n    assert( iPg>=0 && iPg<nNew );\n    if( abDone[iPg] ) continue;         /* Skip pages already processed */\n    if( i>=0                            /* On the upwards pass, or... */\n     || cntOld[iPg-1]>=cntNew[iPg-1]    /* Condition (1) is true */\n    ){\n      int iNew;\n      int iOld;\n      int nNewCell;\n\n      /* Verify condition (1):  If cells are moving left, update iPg\n      ** only after iPg-1 has already been updated. */\n      assert( iPg==0 || cntOld[iPg-1]>=cntNew[iPg-1] || abDone[iPg-1] );\n\n      /* Verify condition (2):  If cells are moving right, update iPg\n      ** only after iPg+1 has already been updated. */\n      assert( cntNew[iPg]>=cntOld[iPg] || abDone[iPg+1] );\n\n      if( iPg==0 ){\n        iNew = iOld = 0;\n        nNewCell = cntNew[0];\n      }else{\n        iOld = iPg<nOld ? (cntOld[iPg-1] + !leafData) : b.nCell;\n        iNew = cntNew[iPg-1] + !leafData;\n        nNewCell = cntNew[iPg] - iNew;\n      }\n\n      rc = editPage(apNew[iPg], iOld, iNew, nNewCell, &b);\n      if( rc ) goto balance_cleanup;\n      abDone[iPg]++;\n      apNew[iPg]->nFree = usableSpace-szNew[iPg];\n      assert( apNew[iPg]->nOverflow==0 );\n      assert( apNew[iPg]->nCell==nNewCell );\n    }\n  }\n\n  /* All pages have been processed exactly once */\n  assert( memcmp(abDone, \"\\01\\01\\01\\01\\01\", nNew)==0 );\n\n  assert( nOld>0 );\n  assert( nNew>0 );\n\n  if( isRoot && pParent->nCell==0 && pParent->hdrOffset<=apNew[0]->nFree ){\n    /* The root page of the b-tree now contains no cells. The only sibling\n    ** page is the right-child of the parent. Copy the contents of the\n    ** child page into the parent, decreasing the overall height of the\n    ** b-tree structure by one. This is described as the \"balance-shallower\"\n    ** sub-algorithm in some documentation.\n    **\n    ** If this is an auto-vacuum database, the call to copyNodeContent() \n    ** sets all pointer-map entries corresponding to database image pages \n    ** for which the pointer is stored within the content being copied.\n    **\n    ** It is critical that the child page be defragmented before being\n    ** copied into the parent, because if the parent is page 1 then it will\n    ** by smaller than the child due to the database header, and so all the\n    ** free space needs to be up front.\n    */\n    assert( nNew==1 || CORRUPT_DB );\n    rc = defragmentPage(apNew[0], -1);\n    testcase( rc!=SQLITE_OK );\n    assert( apNew[0]->nFree == \n        (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)\n      || rc!=SQLITE_OK\n    );\n    copyNodeContent(apNew[0], pParent, &rc);\n    freePage(apNew[0], &rc);\n  }else if( ISAUTOVACUUM && !leafCorrection ){\n    /* Fix the pointer map entries associated with the right-child of each\n    ** sibling page. All other pointer map entries have already been taken\n    ** care of.  */\n    for(i=0; i<nNew; i++){\n      u32 key = get4byte(&apNew[i]->aData[8]);\n      ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);\n    }\n  }\n\n  assert( pParent->isInit );\n  TRACE((\"BALANCE: finished: old=%d new=%d cells=%d\\n\",\n          nOld, nNew, b.nCell));\n\n  /* Free any old pages that were not reused as new pages.\n  */\n  for(i=nNew; i<nOld; i++){\n    freePage(apOld[i], &rc);\n  }\n\n#if 0\n  if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){\n    /* The ptrmapCheckPages() contains assert() statements that verify that\n    ** all pointer map pages are set correctly. This is helpful while \n    ** debugging. This is usually disabled because a corrupt database may\n    ** cause an assert() statement to fail.  */\n    ptrmapCheckPages(apNew, nNew);\n    ptrmapCheckPages(&pParent, 1);\n  }\n#endif\n\n  /*\n  ** Cleanup before returning.\n  */\nbalance_cleanup:\n  sqlite3StackFree(0, b.apCell);\n  for(i=0; i<nOld; i++){\n    releasePage(apOld[i]);\n  }\n  for(i=0; i<nNew; i++){\n    releasePage(apNew[i]);\n  }\n\n  return rc;\n}\n\n\n/*\n** This function is called when the root page of a b-tree structure is\n** overfull (has one or more overflow pages).\n**\n** A new child page is allocated and the contents of the current root\n** page, including overflow cells, are copied into the child. The root\n** page is then overwritten to make it an empty page with the right-child \n** pointer pointing to the new page.\n**\n** Before returning, all pointer-map entries corresponding to pages \n** that the new child-page now contains pointers to are updated. The\n** entry corresponding to the new right-child pointer of the root\n** page is also updated.\n**\n** If successful, *ppChild is set to contain a reference to the child \n** page and SQLITE_OK is returned. In this case the caller is required\n** to call releasePage() on *ppChild exactly once. If an error occurs,\n** an error code is returned and *ppChild is set to 0.\n*/\nstatic int balance_deeper(MemPage *pRoot, MemPage **ppChild){\n  int rc;                        /* Return value from subprocedures */\n  MemPage *pChild = 0;           /* Pointer to a new child page */\n  Pgno pgnoChild = 0;            /* Page number of the new child page */\n  BtShared *pBt = pRoot->pBt;    /* The BTree */\n\n  assert( pRoot->nOverflow>0 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  /* Make pRoot, the root page of the b-tree, writable. Allocate a new \n  ** page that will become the new right-child of pPage. Copy the contents\n  ** of the node stored on pRoot into the new child page.\n  */\n  rc = sqlite3PagerWrite(pRoot->pDbPage);\n  if( rc==SQLITE_OK ){\n    rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);\n    copyNodeContent(pRoot, pChild, &rc);\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);\n    }\n  }\n  if( rc ){\n    *ppChild = 0;\n    releasePage(pChild);\n    return rc;\n  }\n  assert( sqlite3PagerIswriteable(pChild->pDbPage) );\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  assert( pChild->nCell==pRoot->nCell );\n\n  TRACE((\"BALANCE: copy root %d into %d\\n\", pRoot->pgno, pChild->pgno));\n\n  /* Copy the overflow cells from pRoot to pChild */\n  memcpy(pChild->aiOvfl, pRoot->aiOvfl,\n         pRoot->nOverflow*sizeof(pRoot->aiOvfl[0]));\n  memcpy(pChild->apOvfl, pRoot->apOvfl,\n         pRoot->nOverflow*sizeof(pRoot->apOvfl[0]));\n  pChild->nOverflow = pRoot->nOverflow;\n\n  /* Zero the contents of pRoot. Then install pChild as the right-child. */\n  zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);\n  put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild);\n\n  *ppChild = pChild;\n  return SQLITE_OK;\n}\n\n/*\n** The page that pCur currently points to has just been modified in\n** some way. This function figures out if this modification means the\n** tree needs to be balanced, and if so calls the appropriate balancing \n** routine. Balancing routines are:\n**\n**   balance_quick()\n**   balance_deeper()\n**   balance_nonroot()\n*/\nstatic int balance(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  const int nMin = pCur->pBt->usableSize * 2 / 3;\n  u8 aBalanceQuickSpace[13];\n  u8 *pFree = 0;\n\n  VVA_ONLY( int balance_quick_called = 0 );\n  VVA_ONLY( int balance_deeper_called = 0 );\n\n  do {\n    int iPage = pCur->iPage;\n    MemPage *pPage = pCur->pPage;\n\n    if( iPage==0 ){\n      if( pPage->nOverflow ){\n        /* The root page of the b-tree is overfull. In this case call the\n        ** balance_deeper() function to create a new child for the root-page\n        ** and copy the current contents of the root-page to it. The\n        ** next iteration of the do-loop will balance the child page.\n        */ \n        assert( balance_deeper_called==0 );\n        VVA_ONLY( balance_deeper_called++ );\n        rc = balance_deeper(pPage, &pCur->apPage[1]);\n        if( rc==SQLITE_OK ){\n          pCur->iPage = 1;\n          pCur->ix = 0;\n          pCur->aiIdx[0] = 0;\n          pCur->apPage[0] = pPage;\n          pCur->pPage = pCur->apPage[1];\n          assert( pCur->pPage->nOverflow );\n        }\n      }else{\n        break;\n      }\n    }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){\n      break;\n    }else{\n      MemPage * const pParent = pCur->apPage[iPage-1];\n      int const iIdx = pCur->aiIdx[iPage-1];\n\n      rc = sqlite3PagerWrite(pParent->pDbPage);\n      if( rc==SQLITE_OK ){\n#ifndef SQLITE_OMIT_QUICKBALANCE\n        if( pPage->intKeyLeaf\n         && pPage->nOverflow==1\n         && pPage->aiOvfl[0]==pPage->nCell\n         && pParent->pgno!=1\n         && pParent->nCell==iIdx\n        ){\n          /* Call balance_quick() to create a new sibling of pPage on which\n          ** to store the overflow cell. balance_quick() inserts a new cell\n          ** into pParent, which may cause pParent overflow. If this\n          ** happens, the next iteration of the do-loop will balance pParent \n          ** use either balance_nonroot() or balance_deeper(). Until this\n          ** happens, the overflow cell is stored in the aBalanceQuickSpace[]\n          ** buffer. \n          **\n          ** The purpose of the following assert() is to check that only a\n          ** single call to balance_quick() is made for each call to this\n          ** function. If this were not verified, a subtle bug involving reuse\n          ** of the aBalanceQuickSpace[] might sneak in.\n          */\n          assert( balance_quick_called==0 ); \n          VVA_ONLY( balance_quick_called++ );\n          rc = balance_quick(pParent, pPage, aBalanceQuickSpace);\n        }else\n#endif\n        {\n          /* In this case, call balance_nonroot() to redistribute cells\n          ** between pPage and up to 2 of its sibling pages. This involves\n          ** modifying the contents of pParent, which may cause pParent to\n          ** become overfull or underfull. The next iteration of the do-loop\n          ** will balance the parent page to correct this.\n          ** \n          ** If the parent page becomes overfull, the overflow cell or cells\n          ** are stored in the pSpace buffer allocated immediately below. \n          ** A subsequent iteration of the do-loop will deal with this by\n          ** calling balance_nonroot() (balance_deeper() may be called first,\n          ** but it doesn't deal with overflow cells - just moves them to a\n          ** different page). Once this subsequent call to balance_nonroot() \n          ** has completed, it is safe to release the pSpace buffer used by\n          ** the previous call, as the overflow cell data will have been \n          ** copied either into the body of a database page or into the new\n          ** pSpace buffer passed to the latter call to balance_nonroot().\n          */\n          u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);\n          rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,\n                               pCur->hints&BTREE_BULKLOAD);\n          if( pFree ){\n            /* If pFree is not NULL, it points to the pSpace buffer used \n            ** by a previous call to balance_nonroot(). Its contents are\n            ** now stored either on real database pages or within the \n            ** new pSpace buffer, so it may be safely freed here. */\n            sqlite3PageFree(pFree);\n          }\n\n          /* The pSpace buffer will be freed after the next call to\n          ** balance_nonroot(), or just before this function returns, whichever\n          ** comes first. */\n          pFree = pSpace;\n        }\n      }\n\n      pPage->nOverflow = 0;\n\n      /* The next iteration of the do-loop balances the parent page. */\n      releasePage(pPage);\n      pCur->iPage--;\n      assert( pCur->iPage>=0 );\n      pCur->pPage = pCur->apPage[pCur->iPage];\n    }\n  }while( rc==SQLITE_OK );\n\n  if( pFree ){\n    sqlite3PageFree(pFree);\n  }\n  return rc;\n}\n\n\n/*\n** Insert a new record into the BTree.  The content of the new record\n** is described by the pX object.  The pCur cursor is used only to\n** define what table the record should be inserted into, and is left\n** pointing at a random location.\n**\n** For a table btree (used for rowid tables), only the pX.nKey value of\n** the key is used. The pX.pKey value must be NULL.  The pX.nKey is the\n** rowid or INTEGER PRIMARY KEY of the row.  The pX.nData,pData,nZero fields\n** hold the content of the row.\n**\n** For an index btree (used for indexes and WITHOUT ROWID tables), the\n** key is an arbitrary byte sequence stored in pX.pKey,nKey.  The \n** pX.pData,nData,nZero fields must be zero.\n**\n** If the seekResult parameter is non-zero, then a successful call to\n** MovetoUnpacked() to seek cursor pCur to (pKey,nKey) has already\n** been performed.  In other words, if seekResult!=0 then the cursor\n** is currently pointing to a cell that will be adjacent to the cell\n** to be inserted.  If seekResult<0 then pCur points to a cell that is\n** smaller then (pKey,nKey).  If seekResult>0 then pCur points to a cell\n** that is larger than (pKey,nKey).\n**\n** If seekResult==0, that means pCur is pointing at some unknown location.\n** In that case, this routine must seek the cursor to the correct insertion\n** point for (pKey,nKey) before doing the insertion.  For index btrees,\n** if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked\n** key values and pX->aMem can be used instead of pX->pKey to avoid having\n** to decode the key.\n*/\nSQLITE_PRIVATE int sqlite3BtreeInsert(\n  BtCursor *pCur,                /* Insert data into the table of this cursor */\n  const BtreePayload *pX,        /* Content of the row to be inserted */\n  int flags,                     /* True if this is likely an append */\n  int seekResult                 /* Result of prior MovetoUnpacked() call */\n){\n  int rc;\n  int loc = seekResult;          /* -1: before desired location  +1: after */\n  int szNew = 0;\n  int idx;\n  MemPage *pPage;\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;\n  unsigned char *oldCell;\n  unsigned char *newCell = 0;\n\n  assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND))==flags );\n\n  if( pCur->eState==CURSOR_FAULT ){\n    assert( pCur->skipNext!=SQLITE_OK );\n    return pCur->skipNext;\n  }\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( (pCur->curFlags & BTCF_WriteFlag)!=0\n              && pBt->inTransaction==TRANS_WRITE\n              && (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n\n  /* Assert that the caller has been consistent. If this cursor was opened\n  ** expecting an index b-tree, then the caller should be inserting blob\n  ** keys with no associated data. If the cursor was opened expecting an\n  ** intkey table, the caller should be inserting integer keys with a\n  ** blob of associated data.  */\n  assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );\n\n  /* Save the positions of any other cursors open on this table.\n  **\n  ** In some cases, the call to btreeMoveto() below is a no-op. For\n  ** example, when inserting data into a table with auto-generated integer\n  ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the \n  ** integer key to use. It then calls this function to actually insert the \n  ** data into the intkey B-Tree. In this case btreeMoveto() recognizes\n  ** that the cursor is already where it needs to be and returns without\n  ** doing any work. To avoid thwarting these optimizations, it is important\n  ** not to clear the cursor here.\n  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  if( pCur->pKeyInfo==0 ){\n    assert( pX->pKey==0 );\n    /* If this is an insert into a table b-tree, invalidate any incrblob \n    ** cursors open on the row being replaced */\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);\n\n    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing \n    ** to a row with the same key as the new entry being inserted.  */\n    assert( (flags & BTREE_SAVEPOSITION)==0 || \n            ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );\n\n    /* If the cursor is currently on the last row and we are appending a\n    ** new row onto the end, set the \"loc\" to avoid an unnecessary\n    ** btreeMoveto() call */\n    if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){\n      loc = 0;\n    }else if( loc==0 ){\n      rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);\n      if( rc ) return rc;\n    }\n  }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){\n    if( pX->nMem ){\n      UnpackedRecord r;\n      r.pKeyInfo = pCur->pKeyInfo;\n      r.aMem = pX->aMem;\n      r.nField = pX->nMem;\n      r.default_rc = 0;\n      r.errCode = 0;\n      r.r1 = 0;\n      r.r2 = 0;\n      r.eqSeen = 0;\n      rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);\n    }else{\n      rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);\n    }\n    if( rc ) return rc;\n  }\n  assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );\n\n  pPage = pCur->pPage;\n  assert( pPage->intKey || pX->nKey>=0 );\n  assert( pPage->leaf || !pPage->intKey );\n\n  TRACE((\"INSERT: table=%d nkey=%lld ndata=%d page=%d %s\\n\",\n          pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,\n          loc==0 ? \"overwrite\" : \"new entry\"));\n  assert( pPage->isInit );\n  newCell = pBt->pTmpSpace;\n  assert( newCell!=0 );\n  rc = fillInCell(pPage, newCell, pX, &szNew);\n  if( rc ) goto end_insert;\n  assert( szNew==pPage->xCellSize(pPage, newCell) );\n  assert( szNew <= MX_CELL_SIZE(pBt) );\n  idx = pCur->ix;\n  if( loc==0 ){\n    CellInfo info;\n    assert( idx<pPage->nCell );\n    rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc ){\n      goto end_insert;\n    }\n    oldCell = findCell(pPage, idx);\n    if( !pPage->leaf ){\n      memcpy(newCell, oldCell, 4);\n    }\n    rc = clearCell(pPage, oldCell, &info);\n    if( info.nSize==szNew && info.nLocal==info.nPayload \n     && (!ISAUTOVACUUM || szNew<pPage->minLocal)\n    ){\n      /* Overwrite the old cell with the new if they are the same size.\n      ** We could also try to do this if the old cell is smaller, then add\n      ** the leftover space to the free list.  But experiments show that\n      ** doing that is no faster then skipping this optimization and just\n      ** calling dropCell() and insertCell(). \n      **\n      ** This optimization cannot be used on an autovacuum database if the\n      ** new entry uses overflow pages, as the insertCell() call below is\n      ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */\n      assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */\n      if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;\n      memcpy(oldCell, newCell, szNew);\n      return SQLITE_OK;\n    }\n    dropCell(pPage, idx, info.nSize, &rc);\n    if( rc ) goto end_insert;\n  }else if( loc<0 && pPage->nCell>0 ){\n    assert( pPage->leaf );\n    idx = ++pCur->ix;\n    pCur->curFlags &= ~BTCF_ValidNKey;\n  }else{\n    assert( pPage->leaf );\n  }\n  insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);\n  assert( pPage->nOverflow==0 || rc==SQLITE_OK );\n  assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );\n\n  /* If no error has occurred and pPage has an overflow cell, call balance() \n  ** to redistribute the cells within the tree. Since balance() may move\n  ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey\n  ** variables.\n  **\n  ** Previous versions of SQLite called moveToRoot() to move the cursor\n  ** back to the root page as balance() used to invalidate the contents\n  ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that,\n  ** set the cursor state to \"invalid\". This makes common insert operations\n  ** slightly faster.\n  **\n  ** There is a subtle but important optimization here too. When inserting\n  ** multiple records into an intkey b-tree using a single cursor (as can\n  ** happen while processing an \"INSERT INTO ... SELECT\" statement), it\n  ** is advantageous to leave the cursor pointing to the last entry in\n  ** the b-tree if possible. If the cursor is left pointing to the last\n  ** entry in the table, and the next row inserted has an integer key\n  ** larger than the largest existing key, it is possible to insert the\n  ** row without seeking the cursor. This can be a big performance boost.\n  */\n  pCur->info.nSize = 0;\n  if( pPage->nOverflow ){\n    assert( rc==SQLITE_OK );\n    pCur->curFlags &= ~(BTCF_ValidNKey);\n    rc = balance(pCur);\n\n    /* Must make sure nOverflow is reset to zero even if the balance()\n    ** fails. Internal data structure corruption will result otherwise. \n    ** Also, set the cursor state to invalid. This stops saveCursorPosition()\n    ** from trying to save the current position of the cursor.  */\n    pCur->pPage->nOverflow = 0;\n    pCur->eState = CURSOR_INVALID;\n    if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){\n      btreeReleaseAllCursorPages(pCur);\n      if( pCur->pKeyInfo ){\n        assert( pCur->pKey==0 );\n        pCur->pKey = sqlite3Malloc( pX->nKey );\n        if( pCur->pKey==0 ){\n          rc = SQLITE_NOMEM;\n        }else{\n          memcpy(pCur->pKey, pX->pKey, pX->nKey);\n        }\n      }\n      pCur->eState = CURSOR_REQUIRESEEK;\n      pCur->nKey = pX->nKey;\n    }\n  }\n  assert( pCur->iPage<0 || pCur->pPage->nOverflow==0 );\n\nend_insert:\n  return rc;\n}\n\n/*\n** Delete the entry that the cursor is pointing to. \n**\n** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then\n** the cursor is left pointing at an arbitrary location after the delete.\n** But if that bit is set, then the cursor is left in a state such that\n** the next call to BtreeNext() or BtreePrev() moves it to the same row\n** as it would have been on if the call to BtreeDelete() had been omitted.\n**\n** The BTREE_AUXDELETE bit of flags indicates that is one of several deletes\n** associated with a single table entry and its indexes.  Only one of those\n** deletes is considered the \"primary\" delete.  The primary delete occurs\n** on a cursor that is not a BTREE_FORDELETE cursor.  All but one delete\n** operation on non-FORDELETE cursors is tagged with the AUXDELETE flag.\n** The BTREE_AUXDELETE bit is a hint that is not used by this implementation,\n** but which might be used by alternative storage engines.\n*/\nSQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;              \n  int rc;                              /* Return code */\n  MemPage *pPage;                      /* Page to delete cell from */\n  unsigned char *pCell;                /* Pointer to cell to delete */\n  int iCellIdx;                        /* Index of cell to delete */\n  int iCellDepth;                      /* Depth of node containing pCell */ \n  CellInfo info;                       /* Size of the cell being deleted */\n  int bSkipnext = 0;                   /* Leaf cursor in SKIPNEXT state */\n  u8 bPreserve = flags & BTREE_SAVEPOSITION;  /* Keep cursor valid */\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( pCur->curFlags & BTCF_WriteFlag );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n  assert( !hasReadConflicts(p, pCur->pgnoRoot) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );\n\n  iCellDepth = pCur->iPage;\n  iCellIdx = pCur->ix;\n  pPage = pCur->pPage;\n  pCell = findCell(pPage, iCellIdx);\n\n  /* If the bPreserve flag is set to true, then the cursor position must\n  ** be preserved following this delete operation. If the current delete\n  ** will cause a b-tree rebalance, then this is done by saving the cursor\n  ** key and leaving the cursor in CURSOR_REQUIRESEEK state before \n  ** returning. \n  **\n  ** Or, if the current delete will not cause a rebalance, then the cursor\n  ** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately\n  ** before or after the deleted entry. In this case set bSkipnext to true.  */\n  if( bPreserve ){\n    if( !pPage->leaf \n     || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)\n    ){\n      /* A b-tree rebalance will be required after deleting this entry.\n      ** Save the cursor key.  */\n      rc = saveCursorKey(pCur);\n      if( rc ) return rc;\n    }else{\n      bSkipnext = 1;\n    }\n  }\n\n  /* If the page containing the entry to delete is not a leaf page, move\n  ** the cursor to the largest entry in the tree that is smaller than\n  ** the entry being deleted. This cell will replace the cell being deleted\n  ** from the internal node. The 'previous' entry is used for this instead\n  ** of the 'next' entry, as the previous entry is always a part of the\n  ** sub-tree headed by the child page of the cell being deleted. This makes\n  ** balancing the tree following the delete operation easier.  */\n  if( !pPage->leaf ){\n    rc = sqlite3BtreePrevious(pCur, 0);\n    assert( rc!=SQLITE_DONE );\n    if( rc ) return rc;\n  }\n\n  /* Save the positions of any other cursors open on this table before\n  ** making any modifications.  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  /* If this is a delete operation to remove a row from a table b-tree,\n  ** invalidate any incrblob cursors open on the row being deleted.  */\n  if( pCur->pKeyInfo==0 ){\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);\n  }\n\n  /* Make the page containing the entry to be deleted writable. Then free any\n  ** overflow pages associated with the entry and finally remove the cell\n  ** itself from within the page.  */\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc ) return rc;\n  rc = clearCell(pPage, pCell, &info);\n  dropCell(pPage, iCellIdx, info.nSize, &rc);\n  if( rc ) return rc;\n\n  /* If the cell deleted was not located on a leaf page, then the cursor\n  ** is currently pointing to the largest entry in the sub-tree headed\n  ** by the child-page of the cell that was just deleted from an internal\n  ** node. The cell from the leaf node needs to be moved to the internal\n  ** node to replace the deleted cell.  */\n  if( !pPage->leaf ){\n    MemPage *pLeaf = pCur->pPage;\n    int nCell;\n    Pgno n;\n    unsigned char *pTmp;\n\n    if( iCellDepth<pCur->iPage-1 ){\n      n = pCur->apPage[iCellDepth+1]->pgno;\n    }else{\n      n = pCur->pPage->pgno;\n    }\n    pCell = findCell(pLeaf, pLeaf->nCell-1);\n    if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT;\n    nCell = pLeaf->xCellSize(pLeaf, pCell);\n    assert( MX_CELL_SIZE(pBt) >= nCell );\n    pTmp = pBt->pTmpSpace;\n    assert( pTmp!=0 );\n    rc = sqlite3PagerWrite(pLeaf->pDbPage);\n    if( rc==SQLITE_OK ){\n      insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);\n    }\n    dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);\n    if( rc ) return rc;\n  }\n\n  /* Balance the tree. If the entry deleted was located on a leaf page,\n  ** then the cursor still points to that page. In this case the first\n  ** call to balance() repairs the tree, and the if(...) condition is\n  ** never true.\n  **\n  ** Otherwise, if the entry deleted was on an internal node page, then\n  ** pCur is pointing to the leaf page from which a cell was removed to\n  ** replace the cell deleted from the internal node. This is slightly\n  ** tricky as the leaf node may be underfull, and the internal node may\n  ** be either under or overfull. In this case run the balancing algorithm\n  ** on the leaf node first. If the balance proceeds far enough up the\n  ** tree that we can be sure that any problem in the internal node has\n  ** been corrected, so be it. Otherwise, after balancing the leaf node,\n  ** walk the cursor up the tree to the internal node and balance it as \n  ** well.  */\n  rc = balance(pCur);\n  if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage--;\n    while( pCur->iPage>iCellDepth ){\n      releasePage(pCur->apPage[pCur->iPage--]);\n    }\n    pCur->pPage = pCur->apPage[pCur->iPage];\n    rc = balance(pCur);\n  }\n\n  if( rc==SQLITE_OK ){\n    if( bSkipnext ){\n      assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );\n      assert( pPage==pCur->pPage || CORRUPT_DB );\n      assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );\n      pCur->eState = CURSOR_SKIPNEXT;\n      if( iCellIdx>=pPage->nCell ){\n        pCur->skipNext = -1;\n        pCur->ix = pPage->nCell-1;\n      }else{\n        pCur->skipNext = 1;\n      }\n    }else{\n      rc = moveToRoot(pCur);\n      if( bPreserve ){\n        btreeReleaseAllCursorPages(pCur);\n        pCur->eState = CURSOR_REQUIRESEEK;\n      }\n      if( rc==SQLITE_EMPTY ) rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** Create a new BTree table.  Write into *piTable the page\n** number for the root page of the new table.\n**\n** The type of type is determined by the flags parameter.  Only the\n** following values of flags are currently in use.  Other values for\n** flags might not work:\n**\n**     BTREE_INTKEY|BTREE_LEAFDATA     Used for SQL tables with rowid keys\n**     BTREE_ZERODATA                  Used for SQL indices\n*/\nstatic int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){\n  BtShared *pBt = p->pBt;\n  MemPage *pRoot;\n  Pgno pgnoRoot;\n  int rc;\n  int ptfFlags;          /* Page-type flage for the root page of new table */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n  if( rc ){\n    return rc;\n  }\n#else\n  if( pBt->autoVacuum ){\n    Pgno pgnoMove;      /* Move a page here to make room for the root-page */\n    MemPage *pPageMove; /* The page to move to. */\n\n    /* Creating a new table may probably require moving an existing database\n    ** to make room for the new tables root page. In case this page turns\n    ** out to be an overflow page, delete all overflow page-map caches\n    ** held by open cursors.\n    */\n    invalidateAllOverflowCache(pBt);\n\n    /* Read the value of meta[3] from the database to determine where the\n    ** root page of the new table should go. meta[3] is the largest root-page\n    ** created so far, so the new root-page is (meta[3]+1).\n    */\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);\n    pgnoRoot++;\n\n    /* The new root-page may not be allocated on a pointer-map page, or the\n    ** PENDING_BYTE page.\n    */\n    while( pgnoRoot==PTRMAP_PAGENO(pBt, pgnoRoot) ||\n        pgnoRoot==PENDING_BYTE_PAGE(pBt) ){\n      pgnoRoot++;\n    }\n    assert( pgnoRoot>=3 || CORRUPT_DB );\n    testcase( pgnoRoot<3 );\n\n    /* Allocate a page. The page that currently resides at pgnoRoot will\n    ** be moved to the allocated page (unless the allocated page happens\n    ** to reside at pgnoRoot).\n    */\n    rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, BTALLOC_EXACT);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    if( pgnoMove!=pgnoRoot ){\n      /* pgnoRoot is the page that will be used for the root-page of\n      ** the new table (assuming an error did not occur). But we were\n      ** allocated pgnoMove. If required (i.e. if it was not allocated\n      ** by extending the file), the current page at position pgnoMove\n      ** is already journaled.\n      */\n      u8 eType = 0;\n      Pgno iPtrPage = 0;\n\n      /* Save the positions of any open cursors. This is required in\n      ** case they are holding a reference to an xFetch reference\n      ** corresponding to page pgnoRoot.  */\n      rc = saveAllCursors(pBt, 0, 0);\n      releasePage(pPageMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* Move the page currently at pgnoRoot to pgnoMove. */\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);\n      if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n      assert( eType!=PTRMAP_ROOTPAGE );\n      assert( eType!=PTRMAP_FREEPAGE );\n      rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);\n      releasePage(pRoot);\n\n      /* Obtain the page at pgnoRoot */\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = sqlite3PagerWrite(pRoot->pDbPage);\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n    }else{\n      pRoot = pPageMove;\n    } \n\n    /* Update the pointer-map and meta-data with the new root-page number. */\n    ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);\n    if( rc ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n    /* When the new root page was allocated, page 1 was made writable in\n    ** order either to increase the database filesize, or to decrement the\n    ** freelist count.  Hence, the sqlite3BtreeUpdateMeta() call cannot fail.\n    */\n    assert( sqlite3PagerIswriteable(pBt->pPage1->pDbPage) );\n    rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);\n    if( NEVER(rc) ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n  }else{\n    rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n    if( rc ) return rc;\n  }\n#endif\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  if( createTabFlags & BTREE_INTKEY ){\n    ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF;\n  }else{\n    ptfFlags = PTF_ZERODATA | PTF_LEAF;\n  }\n  zeroPage(pRoot, ptfFlags);\n  sqlite3PagerUnref(pRoot->pDbPage);\n  assert( (pBt->openFlags & BTREE_SINGLE)==0 || pgnoRoot==2 );\n  *piTable = (int)pgnoRoot;\n  return SQLITE_OK;\n}\nSQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeCreateTable(p, piTable, flags);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Erase the given database page and all its children.  Return\n** the page to the freelist.\n*/\nstatic int clearDatabasePage(\n  BtShared *pBt,           /* The BTree that contains the table */\n  Pgno pgno,               /* Page number to clear */\n  int freePageFlag,        /* Deallocate page if true */\n  int *pnChange            /* Add number of Cells freed to this counter */\n){\n  MemPage *pPage;\n  int rc;\n  unsigned char *pCell;\n  int i;\n  int hdr;\n  CellInfo info;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno>btreePagecount(pBt) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);\n  if( rc ) return rc;\n  if( pPage->bBusy ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto cleardatabasepage_out;\n  }\n  pPage->bBusy = 1;\n  hdr = pPage->hdrOffset;\n  for(i=0; i<pPage->nCell; i++){\n    pCell = findCell(pPage, i);\n    if( !pPage->leaf ){\n      rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);\n      if( rc ) goto cleardatabasepage_out;\n    }\n    rc = clearCell(pPage, pCell, &info);\n    if( rc ) goto cleardatabasepage_out;\n  }\n  if( !pPage->leaf ){\n    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);\n    if( rc ) goto cleardatabasepage_out;\n  }else if( pnChange ){\n    assert( pPage->intKey || CORRUPT_DB );\n    testcase( !pPage->intKey );\n    *pnChange += pPage->nCell;\n  }\n  if( freePageFlag ){\n    freePage(pPage, &rc);\n  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){\n    zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);\n  }\n\ncleardatabasepage_out:\n  pPage->bBusy = 0;\n  releasePage(pPage);\n  return rc;\n}\n\n/*\n** Delete all information from a single table in the database.  iTable is\n** the page number of the root of the table.  After this routine returns,\n** the root page is empty, but still exists.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** read cursors on the table.  Open write cursors are moved to the\n** root of the table.\n**\n** If pnChange is not NULL, then table iTable must be an intkey table. The\n** integer value pointed to by pnChange is incremented by the number of\n** entries in the table.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n\n  rc = saveAllCursors(pBt, (Pgno)iTable, 0);\n\n  if( SQLITE_OK==rc ){\n    /* Invalidate all incrblob cursors open on table iTable (assuming iTable\n    ** is the root of a table b-tree - if it is not, the following call is\n    ** a no-op).  */\n    invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);\n    rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Delete all information from the single table that pCur is open on.\n**\n** This routine only work for pCur on an ephemeral table.\n*/\nSQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor *pCur){\n  return sqlite3BtreeClearTable(pCur->pBtree, pCur->pgnoRoot, 0);\n}\n\n/*\n** Erase all information in a table and add the root of the table to\n** the freelist.  Except, the root of the principle table (the one on\n** page 1) is never added to the freelist.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** cursors on the table.\n**\n** If AUTOVACUUM is enabled and the page at iTable is not the last\n** root page in the database file, then the last root page \n** in the database file is moved into the slot formerly occupied by\n** iTable and that last slot formerly occupied by the last root page\n** is added to the freelist instead of iTable.  In this say, all\n** root pages are kept at the beginning of the database file, which\n** is necessary for AUTOVACUUM to work right.  *piMoved is set to the \n** page number that used to be the last root page in the file before\n** the move.  If no page gets moved, *piMoved is set to 0.\n** The last root page is recorded in meta[3] and the value of\n** meta[3] is updated by this procedure.\n*/\nstatic int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){\n  int rc;\n  MemPage *pPage = 0;\n  BtShared *pBt = p->pBt;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->inTrans==TRANS_WRITE );\n  assert( iTable>=2 );\n\n  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);\n  if( rc ) return rc;\n  rc = sqlite3BtreeClearTable(p, iTable, 0);\n  if( rc ){\n    releasePage(pPage);\n    return rc;\n  }\n\n  *piMoved = 0;\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  freePage(pPage, &rc);\n  releasePage(pPage);\n#else\n  if( pBt->autoVacuum ){\n    Pgno maxRootPgno;\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno);\n\n    if( iTable==maxRootPgno ){\n      /* If the table being dropped is the table with the largest root-page\n      ** number in the database, put the root page on the free list. \n      */\n      freePage(pPage, &rc);\n      releasePage(pPage);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      /* The table being dropped does not have the largest root-page\n      ** number in the database. So move the page that does into the \n      ** gap left by the deleted root-page.\n      */\n      MemPage *pMove;\n      releasePage(pPage);\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      pMove = 0;\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      freePage(pMove, &rc);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      *piMoved = maxRootPgno;\n    }\n\n    /* Set the new 'max-root-page' value in the database header. This\n    ** is the old value less one, less one more if that happens to\n    ** be a root-page number, less one again if that is the\n    ** PENDING_BYTE_PAGE.\n    */\n    maxRootPgno--;\n    while( maxRootPgno==PENDING_BYTE_PAGE(pBt)\n           || PTRMAP_ISPAGE(pBt, maxRootPgno) ){\n      maxRootPgno--;\n    }\n    assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );\n\n    rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);\n  }else{\n    freePage(pPage, &rc);\n    releasePage(pPage);\n  }\n#endif\n  return rc;  \n}\nSQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeDropTable(p, iTable, piMoved);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n/*\n** This function may only be called if the b-tree connection already\n** has a read or write transaction open on the database.\n**\n** Read the meta-information out of a database file.  Meta[0]\n** is the number of free pages currently in the database.  Meta[1]\n** through meta[15] are available for use by higher layers.  Meta[0]\n** is read-only, the others are read/write.\n** \n** The schema layer numbers meta values differently.  At the schema\n** layer (and the SetCookie and ReadCookie opcodes) the number of\n** free pages is not visible.  So Cookie[0] is the same as Meta[1].\n**\n** This routine treats Meta[BTREE_DATA_VERSION] as a special case.  Instead\n** of reading the value out of the header, it instead loads the \"DataVersion\"\n** from the pager.  The BTREE_DATA_VERSION value is not actually stored in the\n** database file.  It is a number computed by the pager.  But its access\n** pattern is the same as header meta values, and so it is convenient to\n** read it from this routine.\n*/\nSQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK) );\n  assert( pBt->pPage1 );\n  assert( idx>=0 && idx<=15 );\n\n  if( idx==BTREE_DATA_VERSION ){\n    *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;\n  }else{\n    *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);\n  }\n\n  /* If auto-vacuum is disabled in this build and this is an auto-vacuum\n  ** database, mark the database as read-only.  */\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  if( idx==BTREE_LARGEST_ROOT_PAGE && *pMeta>0 ){\n    pBt->btsFlags |= BTS_READ_ONLY;\n  }\n#endif\n\n  sqlite3BtreeLeave(p);\n}\n\n/*\n** Write meta-information back into the database.  Meta[0] is\n** read-only and may not be written.\n*/\nSQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){\n  BtShared *pBt = p->pBt;\n  unsigned char *pP1;\n  int rc;\n  assert( idx>=1 && idx<=15 );\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1!=0 );\n  pP1 = pBt->pPage1->aData;\n  rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n  if( rc==SQLITE_OK ){\n    put4byte(&pP1[36 + idx*4], iMeta);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( idx==BTREE_INCR_VACUUM ){\n      assert( pBt->autoVacuum || iMeta==0 );\n      assert( iMeta==0 || iMeta==1 );\n      pBt->incrVacuum = (u8)iMeta;\n    }\n#endif\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_BTREECOUNT\n/*\n** The first argument, pCur, is a cursor opened on some b-tree. Count the\n** number of entries in the b-tree and write the result to *pnEntry.\n**\n** SQLITE_OK is returned if the operation is successfully executed. \n** Otherwise, if an error is encountered (i.e. an IO error or database\n** corruption) an SQLite error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){\n  i64 nEntry = 0;                      /* Value to return in *pnEntry */\n  int rc;                              /* Return code */\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_EMPTY ){\n    *pnEntry = 0;\n    return SQLITE_OK;\n  }\n\n  /* Unless an error occurs, the following loop runs one iteration for each\n  ** page in the B-Tree structure (not including overflow pages). \n  */\n  while( rc==SQLITE_OK ){\n    int iIdx;                          /* Index of child node in parent */\n    MemPage *pPage;                    /* Current page of the b-tree */\n\n    /* If this is a leaf page or the tree is not an int-key tree, then \n    ** this page contains countable entries. Increment the entry counter\n    ** accordingly.\n    */\n    pPage = pCur->pPage;\n    if( pPage->leaf || !pPage->intKey ){\n      nEntry += pPage->nCell;\n    }\n\n    /* pPage is a leaf node. This loop navigates the cursor so that it \n    ** points to the first interior cell that it points to the parent of\n    ** the next page in the tree that has not yet been visited. The\n    ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell\n    ** of the page, or to the number of cells in the page if the next page\n    ** to visit is the right-child of its parent.\n    **\n    ** If all pages in the tree have been visited, return SQLITE_OK to the\n    ** caller.\n    */\n    if( pPage->leaf ){\n      do {\n        if( pCur->iPage==0 ){\n          /* All pages of the b-tree have been visited. Return successfully. */\n          *pnEntry = nEntry;\n          return moveToRoot(pCur);\n        }\n        moveToParent(pCur);\n      }while ( pCur->ix>=pCur->pPage->nCell );\n\n      pCur->ix++;\n      pPage = pCur->pPage;\n    }\n\n    /* Descend to the child node of the cell that the cursor currently \n    ** points at. This is the right-child if (iIdx==pPage->nCell).\n    */\n    iIdx = pCur->ix;\n    if( iIdx==pPage->nCell ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n    }else{\n      rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));\n    }\n  }\n\n  /* An error has occurred. Return an error code. */\n  return rc;\n}\n#endif\n\n/*\n** Return the pager associated with a BTree.  This routine is used for\n** testing and debugging only.\n*/\nSQLITE_PRIVATE Pager *sqlite3BtreePager(Btree *p){\n  return p->pBt->pPager;\n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Append a message to the error message string.\n*/\nstatic void checkAppendMsg(\n  IntegrityCk *pCheck,\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  if( !pCheck->mxErr ) return;\n  pCheck->mxErr--;\n  pCheck->nErr++;\n  va_start(ap, zFormat);\n  if( pCheck->errMsg.nChar ){\n    sqlite3StrAccumAppend(&pCheck->errMsg, \"\\n\", 1);\n  }\n  if( pCheck->zPfx ){\n    sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);\n  }\n  sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);\n  va_end(ap);\n  if( pCheck->errMsg.accError==STRACCUM_NOMEM ){\n    pCheck->mallocFailed = 1;\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n\n/*\n** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that\n** corresponds to page iPg is already set.\n*/\nstatic int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));\n}\n\n/*\n** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.\n*/\nstatic void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));\n}\n\n\n/*\n** Add 1 to the reference count for page iPage.  If this is the second\n** reference to the page, add an error message to pCheck->zErrMsg.\n** Return 1 if there are 2 or more references to the page and 0 if\n** if this is the first reference to the page.\n**\n** Also check that the page number is in bounds.\n*/\nstatic int checkRef(IntegrityCk *pCheck, Pgno iPage){\n  if( iPage==0 ) return 1;\n  if( iPage>pCheck->nPage ){\n    checkAppendMsg(pCheck, \"invalid page number %d\", iPage);\n    return 1;\n  }\n  if( getPageReferenced(pCheck, iPage) ){\n    checkAppendMsg(pCheck, \"2nd reference to page %d\", iPage);\n    return 1;\n  }\n  setPageReferenced(pCheck, iPage);\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Check that the entry in the pointer-map for page iChild maps to \n** page iParent, pointer type ptrType. If not, append an error message\n** to pCheck.\n*/\nstatic void checkPtrmap(\n  IntegrityCk *pCheck,   /* Integrity check context */\n  Pgno iChild,           /* Child page number */\n  u8 eType,              /* Expected pointer map type */\n  Pgno iParent           /* Expected pointer map parent page number */\n){\n  int rc;\n  u8 ePtrmapType;\n  Pgno iPtrmapParent;\n\n  rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;\n    checkAppendMsg(pCheck, \"Failed to read ptrmap key=%d\", iChild);\n    return;\n  }\n\n  if( ePtrmapType!=eType || iPtrmapParent!=iParent ){\n    checkAppendMsg(pCheck,\n      \"Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)\", \n      iChild, eType, iParent, ePtrmapType, iPtrmapParent);\n  }\n}\n#endif\n\n/*\n** Check the integrity of the freelist or of an overflow page list.\n** Verify that the number of pages on the list is N.\n*/\nstatic void checkList(\n  IntegrityCk *pCheck,  /* Integrity checking context */\n  int isFreeList,       /* True for a freelist.  False for overflow page list */\n  int iPage,            /* Page number for first page in the list */\n  int N                 /* Expected number of pages in the list */\n){\n  int i;\n  int expected = N;\n  int iFirst = iPage;\n  while( N-- > 0 && pCheck->mxErr ){\n    DbPage *pOvflPage;\n    unsigned char *pOvflData;\n    if( iPage<1 ){\n      checkAppendMsg(pCheck,\n         \"%d of %d pages missing from overflow list starting at %d\",\n          N+1, expected, iFirst);\n      break;\n    }\n    if( checkRef(pCheck, iPage) ) break;\n    if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){\n      checkAppendMsg(pCheck, \"failed to get page %d\", iPage);\n      break;\n    }\n    pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);\n    if( isFreeList ){\n      int n = get4byte(&pOvflData[4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pCheck->pBt->autoVacuum ){\n        checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);\n      }\n#endif\n      if( n>(int)pCheck->pBt->usableSize/4-2 ){\n        checkAppendMsg(pCheck,\n           \"freelist leaf count too big on page %d\", iPage);\n        N--;\n      }else{\n        for(i=0; i<n; i++){\n          Pgno iFreePage = get4byte(&pOvflData[8+i*4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n          if( pCheck->pBt->autoVacuum ){\n            checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);\n          }\n#endif\n          checkRef(pCheck, iFreePage);\n        }\n        N -= n;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    else{\n      /* If this database supports auto-vacuum and iPage is not the last\n      ** page in this overflow list, check that the pointer-map entry for\n      ** the following page matches iPage.\n      */\n      if( pCheck->pBt->autoVacuum && N>0 ){\n        i = get4byte(pOvflData);\n        checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);\n      }\n    }\n#endif\n    iPage = get4byte(pOvflData);\n    sqlite3PagerUnref(pOvflPage);\n\n    if( isFreeList && N<(iPage!=0) ){\n      checkAppendMsg(pCheck, \"free-page count in header is too small\");\n    }\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** An implementation of a min-heap.\n**\n** aHeap[0] is the number of elements on the heap.  aHeap[1] is the\n** root element.  The daughter nodes of aHeap[N] are aHeap[N*2]\n** and aHeap[N*2+1].\n**\n** The heap property is this:  Every node is less than or equal to both\n** of its daughter nodes.  A consequence of the heap property is that the\n** root node aHeap[1] is always the minimum value currently in the heap.\n**\n** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto\n** the heap, preserving the heap property.  The btreeHeapPull() routine\n** removes the root element from the heap (the minimum value in the heap)\n** and then moves other nodes around as necessary to preserve the heap\n** property.\n**\n** This heap is used for cell overlap and coverage testing.  Each u32\n** entry represents the span of a cell or freeblock on a btree page.  \n** The upper 16 bits are the index of the first byte of a range and the\n** lower 16 bits are the index of the last byte of that range.\n*/\nstatic void btreeHeapInsert(u32 *aHeap, u32 x){\n  u32 j, i = ++aHeap[0];\n  aHeap[i] = x;\n  while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){\n    x = aHeap[j];\n    aHeap[j] = aHeap[i];\n    aHeap[i] = x;\n    i = j;\n  }\n}\nstatic int btreeHeapPull(u32 *aHeap, u32 *pOut){\n  u32 j, i, x;\n  if( (x = aHeap[0])==0 ) return 0;\n  *pOut = aHeap[1];\n  aHeap[1] = aHeap[x];\n  aHeap[x] = 0xffffffff;\n  aHeap[0]--;\n  i = 1;\n  while( (j = i*2)<=aHeap[0] ){\n    if( aHeap[j]>aHeap[j+1] ) j++;\n    if( aHeap[i]<aHeap[j] ) break;\n    x = aHeap[i];\n    aHeap[i] = aHeap[j];\n    aHeap[j] = x;\n    i = j;\n  }\n  return 1;  \n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Do various sanity checks on a single page of a tree.  Return\n** the tree depth.  Root pages return 0.  Parents of root pages\n** return 1, and so forth.\n** \n** These checks are done:\n**\n**      1.  Make sure that cells and freeblocks do not overlap\n**          but combine to completely cover the page.\n**      2.  Make sure integer cell keys are in order.\n**      3.  Check the integrity of overflow pages.\n**      4.  Recursively call checkTreePage on all children.\n**      5.  Verify that the depth of all children is the same.\n*/\nstatic int checkTreePage(\n  IntegrityCk *pCheck,  /* Context for the sanity check */\n  int iPage,            /* Page number of the page to check */\n  i64 *piMinKey,        /* Write minimum integer primary key here */\n  i64 maxKey            /* Error if integer primary key greater than this */\n){\n  MemPage *pPage = 0;      /* The page being analyzed */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subroutine call */\n  int depth = -1, d2;      /* Depth of a subtree */\n  int pgno;                /* Page number */\n  int nFrag;               /* Number of fragmented bytes on the page */\n  int hdr;                 /* Offset to the page header */\n  int cellStart;           /* Offset to the start of the cell pointer array */\n  int nCell;               /* Number of cells */\n  int doCoverageCheck = 1; /* True if cell coverage checking should be done */\n  int keyCanBeEqual = 1;   /* True if IPK can be equal to maxKey\n                           ** False if IPK must be strictly less than maxKey */\n  u8 *data;                /* Page content */\n  u8 *pCell;               /* Cell content */\n  u8 *pCellIdx;            /* Next element of the cell pointer array */\n  BtShared *pBt;           /* The BtShared object that owns pPage */\n  u32 pc;                  /* Address of a cell */\n  u32 usableSize;          /* Usable size of the page */\n  u32 contentOffset;       /* Offset to the start of the cell content area */\n  u32 *heap = 0;           /* Min-heap used for checking cell coverage */\n  u32 x, prev = 0;         /* Next and previous entry on the min-heap */\n  const char *saved_zPfx = pCheck->zPfx;\n  int saved_v1 = pCheck->v1;\n  int saved_v2 = pCheck->v2;\n  u8 savedIsInit = 0;\n\n  /* Check that the page exists\n  */\n  pBt = pCheck->pBt;\n  usableSize = pBt->usableSize;\n  if( iPage==0 ) return 0;\n  if( checkRef(pCheck, iPage) ) return 0;\n  pCheck->zPfx = \"Page %d: \";\n  pCheck->v1 = iPage;\n  if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){\n    checkAppendMsg(pCheck,\n       \"unable to get the page. error code=%d\", rc);\n    goto end_of_check;\n  }\n\n  /* Clear MemPage.isInit to make sure the corruption detection code in\n  ** btreeInitPage() is executed.  */\n  savedIsInit = pPage->isInit;\n  pPage->isInit = 0;\n  if( (rc = btreeInitPage(pPage))!=0 ){\n    assert( rc==SQLITE_CORRUPT );  /* The only possible error from InitPage */\n    checkAppendMsg(pCheck,\n                   \"btreeInitPage() returns error code %d\", rc);\n    goto end_of_check;\n  }\n  data = pPage->aData;\n  hdr = pPage->hdrOffset;\n\n  /* Set up for cell analysis */\n  pCheck->zPfx = \"On tree page %d cell %d: \";\n  contentOffset = get2byteNotZero(&data[hdr+5]);\n  assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */\n\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  nCell = get2byte(&data[hdr+3]);\n  assert( pPage->nCell==nCell );\n\n  /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page\n  ** immediately follows the b-tree page header. */\n  cellStart = hdr + 12 - 4*pPage->leaf;\n  assert( pPage->aCellIdx==&data[cellStart] );\n  pCellIdx = &data[cellStart + 2*(nCell-1)];\n\n  if( !pPage->leaf ){\n    /* Analyze the right-child page of internal pages */\n    pgno = get4byte(&data[hdr+8]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      pCheck->zPfx = \"On page %d at right child: \";\n      checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n    }\n#endif\n    depth = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n    keyCanBeEqual = 0;\n  }else{\n    /* For leaf pages, the coverage check will occur in the same loop\n    ** as the other cell checks, so initialize the heap.  */\n    heap = pCheck->heap;\n    heap[0] = 0;\n  }\n\n  /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte\n  ** integer offsets to the cell contents. */\n  for(i=nCell-1; i>=0 && pCheck->mxErr; i--){\n    CellInfo info;\n\n    /* Check cell size */\n    pCheck->v2 = i;\n    assert( pCellIdx==&data[cellStart + i*2] );\n    pc = get2byteAligned(pCellIdx);\n    pCellIdx -= 2;\n    if( pc<contentOffset || pc>usableSize-4 ){\n      checkAppendMsg(pCheck, \"Offset %d out of range %d..%d\",\n                             pc, contentOffset, usableSize-4);\n      doCoverageCheck = 0;\n      continue;\n    }\n    pCell = &data[pc];\n    pPage->xParseCell(pPage, pCell, &info);\n    if( pc+info.nSize>usableSize ){\n      checkAppendMsg(pCheck, \"Extends off end of page\");\n      doCoverageCheck = 0;\n      continue;\n    }\n\n    /* Check for integer primary key out of range */\n    if( pPage->intKey ){\n      if( keyCanBeEqual ? (info.nKey > maxKey) : (info.nKey >= maxKey) ){\n        checkAppendMsg(pCheck, \"Rowid %lld out of order\", info.nKey);\n      }\n      maxKey = info.nKey;\n      keyCanBeEqual = 0;     /* Only the first key on the page may ==maxKey */\n    }\n\n    /* Check the content overflow list */\n    if( info.nPayload>info.nLocal ){\n      int nPage;       /* Number of pages on the overflow chain */\n      Pgno pgnoOvfl;   /* First page of the overflow chain */\n      assert( pc + info.nSize - 4 <= usableSize );\n      nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);\n      pgnoOvfl = get4byte(&pCell[info.nSize - 4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);\n      }\n#endif\n      checkList(pCheck, 0, pgnoOvfl, nPage);\n    }\n\n    if( !pPage->leaf ){\n      /* Check sanity of left child page for internal pages */\n      pgno = get4byte(pCell);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n      }\n#endif\n      d2 = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n      keyCanBeEqual = 0;\n      if( d2!=depth ){\n        checkAppendMsg(pCheck, \"Child page depth differs\");\n        depth = d2;\n      }\n    }else{\n      /* Populate the coverage-checking heap for leaf pages */\n      btreeHeapInsert(heap, (pc<<16)|(pc+info.nSize-1));\n    }\n  }\n  *piMinKey = maxKey;\n\n  /* Check for complete coverage of the page\n  */\n  pCheck->zPfx = 0;\n  if( doCoverageCheck && pCheck->mxErr>0 ){\n    /* For leaf pages, the min-heap has already been initialized and the\n    ** cells have already been inserted.  But for internal pages, that has\n    ** not yet been done, so do it now */\n    if( !pPage->leaf ){\n      heap = pCheck->heap;\n      heap[0] = 0;\n      for(i=nCell-1; i>=0; i--){\n        u32 size;\n        pc = get2byteAligned(&data[cellStart+i*2]);\n        size = pPage->xCellSize(pPage, &data[pc]);\n        btreeHeapInsert(heap, (pc<<16)|(pc+size-1));\n      }\n    }\n    /* Add the freeblocks to the min-heap\n    **\n    ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header\n    ** is the offset of the first freeblock, or zero if there are no\n    ** freeblocks on the page. \n    */\n    i = get2byte(&data[hdr+1]);\n    while( i>0 ){\n      int size, j;\n      assert( (u32)i<=usableSize-4 );     /* Enforced by btreeInitPage() */\n      size = get2byte(&data[i+2]);\n      assert( (u32)(i+size)<=usableSize );  /* Enforced by btreeInitPage() */\n      btreeHeapInsert(heap, (((u32)i)<<16)|(i+size-1));\n      /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a\n      ** big-endian integer which is the offset in the b-tree page of the next\n      ** freeblock in the chain, or zero if the freeblock is the last on the\n      ** chain. */\n      j = get2byte(&data[i]);\n      /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of\n      ** increasing offset. */\n      assert( j==0 || j>i+size );  /* Enforced by btreeInitPage() */\n      assert( (u32)j<=usableSize-4 );   /* Enforced by btreeInitPage() */\n      i = j;\n    }\n    /* Analyze the min-heap looking for overlap between cells and/or \n    ** freeblocks, and counting the number of untracked bytes in nFrag.\n    ** \n    ** Each min-heap entry is of the form:    (start_address<<16)|end_address.\n    ** There is an implied first entry the covers the page header, the cell\n    ** pointer index, and the gap between the cell pointer index and the start\n    ** of cell content.  \n    **\n    ** The loop below pulls entries from the min-heap in order and compares\n    ** the start_address against the previous end_address.  If there is an\n    ** overlap, that means bytes are used multiple times.  If there is a gap,\n    ** that gap is added to the fragmentation count.\n    */\n    nFrag = 0;\n    prev = contentOffset - 1;   /* Implied first min-heap entry */\n    while( btreeHeapPull(heap,&x) ){\n      if( (prev&0xffff)>=(x>>16) ){\n        checkAppendMsg(pCheck,\n          \"Multiple uses for byte %u of page %d\", x>>16, iPage);\n        break;\n      }else{\n        nFrag += (x>>16) - (prev&0xffff) - 1;\n        prev = x;\n      }\n    }\n    nFrag += usableSize - (prev&0xffff) - 1;\n    /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments\n    ** is stored in the fifth field of the b-tree page header.\n    ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the\n    ** number of fragmented free bytes within the cell content area.\n    */\n    if( heap[0]==0 && nFrag!=data[hdr+7] ){\n      checkAppendMsg(pCheck,\n          \"Fragmentation of %d bytes reported as %d on page %d\",\n          nFrag, data[hdr+7], iPage);\n    }\n  }\n\nend_of_check:\n  if( !doCoverageCheck ) pPage->isInit = savedIsInit;\n  releasePage(pPage);\n  pCheck->zPfx = saved_zPfx;\n  pCheck->v1 = saved_v1;\n  pCheck->v2 = saved_v2;\n  return depth+1;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** This routine does a complete check of the given BTree file.  aRoot[] is\n** an array of pages numbers were each page number is the root page of\n** a table.  nRoot is the number of entries in aRoot.\n**\n** A read-only or read-write transaction must be opened before calling\n** this function.\n**\n** Write the number of error seen in *pnErr.  Except for some memory\n** allocation errors,  an error message held in memory obtained from\n** malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is\n** returned.  If a memory allocation error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(\n  Btree *p,     /* The btree to be checked */\n  int *aRoot,   /* An array of root pages numbers for individual trees */\n  int nRoot,    /* Number of entries in aRoot[] */\n  int mxErr,    /* Stop reporting errors after this many */\n  int *pnErr    /* Write number of errors seen to this variable */\n){\n  Pgno i;\n  IntegrityCk sCheck;\n  BtShared *pBt = p->pBt;\n  int savedDbFlags = pBt->db->flags;\n  char zErr[100];\n  VVA_ONLY( int nRef );\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );\n  VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );\n  assert( nRef>=0 );\n  sCheck.pBt = pBt;\n  sCheck.pPager = pBt->pPager;\n  sCheck.nPage = btreePagecount(sCheck.pBt);\n  sCheck.mxErr = mxErr;\n  sCheck.nErr = 0;\n  sCheck.mallocFailed = 0;\n  sCheck.zPfx = 0;\n  sCheck.v1 = 0;\n  sCheck.v2 = 0;\n  sCheck.aPgRef = 0;\n  sCheck.heap = 0;\n  sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);\n  sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL;\n  if( sCheck.nPage==0 ){\n    goto integrity_ck_cleanup;\n  }\n\n  sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1);\n  if( !sCheck.aPgRef ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n  sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize );\n  if( sCheck.heap==0 ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n\n  i = PENDING_BYTE_PAGE(pBt);\n  if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);\n\n  /* Check the integrity of the freelist\n  */\n  sCheck.zPfx = \"Main freelist: \";\n  checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),\n            get4byte(&pBt->pPage1->aData[36]));\n  sCheck.zPfx = 0;\n\n  /* Check all the tables.\n  */\n  testcase( pBt->db->flags & SQLITE_CellSizeCk );\n  pBt->db->flags &= ~SQLITE_CellSizeCk;\n  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){\n    i64 notUsed;\n    if( aRoot[i]==0 ) continue;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && aRoot[i]>1 ){\n      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);\n    }\n#endif\n    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);\n  }\n  pBt->db->flags = savedDbFlags;\n\n  /* Make sure every page in the file is referenced\n  */\n  for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n    if( getPageReferenced(&sCheck, i)==0 ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n#else\n    /* If the database supports auto-vacuum, make sure no tables contain\n    ** references to pointer-map pages.\n    */\n    if( getPageReferenced(&sCheck, i)==0 && \n       (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n    if( getPageReferenced(&sCheck, i)!=0 && \n       (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Pointer map page %d is referenced\", i);\n    }\n#endif\n  }\n\n  /* Clean  up and report errors.\n  */\nintegrity_ck_cleanup:\n  sqlite3PageFree(sCheck.heap);\n  sqlite3_free(sCheck.aPgRef);\n  if( sCheck.mallocFailed ){\n    sqlite3StrAccumReset(&sCheck.errMsg);\n    sCheck.nErr++;\n  }\n  *pnErr = sCheck.nErr;\n  if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);\n  /* Make sure this analysis did not leave any unref() pages. */\n  assert( nRef==sqlite3PagerRefcount(pBt->pPager) );\n  sqlite3BtreeLeave(p);\n  return sqlite3StrAccumFinish(&sCheck.errMsg);\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** Return the full pathname of the underlying database file.  Return\n** an empty string if the database is in-memory or a TEMP database.\n**\n** The pager filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerFilename(p->pBt->pPager, 1);\n}\n\n/*\n** Return the pathname of the journal file for this database. The return\n** value of this routine is the same regardless of whether the journal file\n** has been created or not.\n**\n** The pager journal filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nSQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerJournalname(p->pBt->pPager);\n}\n\n/*\n** Return non-zero if a transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree *p){\n  assert( p==0 || sqlite3_mutex_held(p->db->mutex) );\n  return (p && (p->inTrans==TRANS_WRITE));\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on the Btree passed as the first argument.\n**\n** Return SQLITE_LOCKED if this or any other connection has an open \n** transaction on the shared-cache the argument Btree is connected to.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;\n  if( p ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n    if( pBt->inTransaction!=TRANS_NONE ){\n      rc = SQLITE_LOCKED;\n    }else{\n      rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** Return non-zero if a read (or write) transaction is active.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->inTrans!=TRANS_NONE;\n}\n\nSQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->nBackup!=0;\n}\n\n/*\n** This function returns a pointer to a blob of memory associated with\n** a single shared-btree. The memory is used by client code for its own\n** purposes (for example, to store a high-level schema associated with \n** the shared-btree). The btree layer manages reference counting issues.\n**\n** The first time this is called on a shared-btree, nBytes bytes of memory\n** are allocated, zeroed, and returned to the caller. For each subsequent \n** call the nBytes parameter is ignored and a pointer to the same blob\n** of memory returned. \n**\n** If the nBytes parameter is 0 and the blob of memory has not yet been\n** allocated, a null pointer is returned. If the blob has already been\n** allocated, it is returned as normal.\n**\n** Just before the shared-btree is closed, the function passed as the \n** xFree argument when the memory allocation was made is invoked on the \n** blob of allocated memory. The xFree function should not call sqlite3_free()\n** on the memory, the btree layer does that.\n*/\nSQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  if( !pBt->pSchema && nBytes ){\n    pBt->pSchema = sqlite3DbMallocZero(0, nBytes);\n    pBt->xFreeSchema = xFree;\n  }\n  sqlite3BtreeLeave(p);\n  return pBt->pSchema;\n}\n\n/*\n** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared \n** btree as the argument handle holds an exclusive lock on the \n** sqlite_master table. Otherwise SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){\n  int rc;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE );\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Obtain a lock on the table whose root page is iTab.  The\n** lock is a write lock if isWritelock is true or a read lock\n** if it is false.\n*/\nSQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){\n  int rc = SQLITE_OK;\n  assert( p->inTrans!=TRANS_NONE );\n  if( p->sharable ){\n    u8 lockType = READ_LOCK + isWriteLock;\n    assert( READ_LOCK+1==WRITE_LOCK );\n    assert( isWriteLock==0 || isWriteLock==1 );\n\n    sqlite3BtreeEnter(p);\n    rc = querySharedCacheTableLock(p, iTab, lockType);\n    if( rc==SQLITE_OK ){\n      rc = setSharedCacheTableLock(p, iTab, lockType);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Argument pCsr must be a cursor opened for writing on an \n** INTKEY table currently pointing at a valid table entry. \n** This function modifies the data stored as part of that entry.\n**\n** Only the data content may only be modified, it is not possible to \n** change the length of the data stored. If this function is called with\n** parameters that attempt to write past the end of the existing data,\n** no modifications are made and SQLITE_CORRUPT is returned.\n*/\nSQLITE_PRIVATE int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){\n  int rc;\n  assert( cursorOwnsBtShared(pCsr) );\n  assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );\n  assert( pCsr->curFlags & BTCF_Incrblob );\n\n  rc = restoreCursorPosition(pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pCsr->eState!=CURSOR_REQUIRESEEK );\n  if( pCsr->eState!=CURSOR_VALID ){\n    return SQLITE_ABORT;\n  }\n\n  /* Save the positions of all other cursors open on this table. This is\n  ** required in case any of them are holding references to an xFetch\n  ** version of the b-tree page modified by the accessPayload call below.\n  **\n  ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()\n  ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence\n  ** saveAllCursors can only return SQLITE_OK.\n  */\n  VVA_ONLY(rc =) saveAllCursors(pCsr->pBt, pCsr->pgnoRoot, pCsr);\n  assert( rc==SQLITE_OK );\n\n  /* Check some assumptions: \n  **   (a) the cursor is open for writing,\n  **   (b) there is a read/write transaction open,\n  **   (c) the connection holds a write-lock on the table (if required),\n  **   (d) there are no conflicting read-locks, and\n  **   (e) the cursor points at a valid row of an intKey table.\n  */\n  if( (pCsr->curFlags & BTCF_WriteFlag)==0 ){\n    return SQLITE_READONLY;\n  }\n  assert( (pCsr->pBt->btsFlags & BTS_READ_ONLY)==0\n              && pCsr->pBt->inTransaction==TRANS_WRITE );\n  assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );\n  assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );\n  assert( pCsr->pPage->intKey );\n\n  return accessPayload(pCsr, offset, amt, (unsigned char *)z, 1);\n}\n\n/* \n** Mark this cursor as an incremental blob cursor.\n*/\nSQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *pCur){\n  pCur->curFlags |= BTCF_Incrblob;\n  pCur->pBtree->hasIncrblobCur = 1;\n}\n#endif\n\n/*\n** Set both the \"read version\" (single byte at byte offset 18) and \n** \"write version\" (single byte at byte offset 19) fields in the database\n** header to iVersion.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){\n  BtShared *pBt = pBtree->pBt;\n  int rc;                         /* Return code */\n \n  assert( iVersion==1 || iVersion==2 );\n\n  /* If setting the version fields to 1, do not automatically open the\n  ** WAL connection, even if the version fields are currently set to 2.\n  */\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;\n\n  rc = sqlite3BtreeBeginTrans(pBtree, 0);\n  if( rc==SQLITE_OK ){\n    u8 *aData = pBt->pPage1->aData;\n    if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){\n      rc = sqlite3BtreeBeginTrans(pBtree, 2);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          aData[18] = (u8)iVersion;\n          aData[19] = (u8)iVersion;\n        }\n      }\n    }\n  }\n\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  return rc;\n}\n\n/*\n** Return true if the cursor has a hint specified.  This routine is\n** only used from within assert() statements\n*/\nSQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){\n  return (pCsr->hints & mask)!=0;\n}\n\n/*\n** Return true if the given Btree is read-only.\n*/\nSQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){\n  return (p->pBt->btsFlags & BTS_READ_ONLY)!=0;\n}\n\n/*\n** Return the size of the header added to each page by this module.\n*/\nSQLITE_PRIVATE int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** Return true if the Btree passed as the only argument is sharable.\n*/\nSQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){\n  return p->sharable;\n}\n\n/*\n** Return the number of connections to the BtShared object accessed by\n** the Btree handle passed as the only argument. For private caches \n** this is always 1. For shared caches it may be 1 or greater.\n*/\nSQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){\n  testcase( p->sharable );\n  return p->pBt->nRef;\n}\n#endif\n\n/************** End of btree.c ***********************************************/\n/************** Begin file backup.c ******************************************/\n/*\n** 2009 January 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_backup_XXX() \n** API functions and the related features.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"btreeInt.h\" */\n\n/*\n** Structure allocated for each backup operation.\n*/\nstruct sqlite3_backup {\n  sqlite3* pDestDb;        /* Destination database handle */\n  Btree *pDest;            /* Destination b-tree file */\n  u32 iDestSchema;         /* Original schema cookie in destination */\n  int bDestLocked;         /* True once a write-transaction is open on pDest */\n\n  Pgno iNext;              /* Page number of the next source page to copy */\n  sqlite3* pSrcDb;         /* Source database handle */\n  Btree *pSrc;             /* Source b-tree file */\n\n  int rc;                  /* Backup process error code */\n\n  /* These two variables are set by every call to backup_step(). They are\n  ** read by calls to backup_remaining() and backup_pagecount().\n  */\n  Pgno nRemaining;         /* Number of pages left to copy */\n  Pgno nPagecount;         /* Total number of pages to copy */\n\n  int isAttached;          /* True once backup has been registered with pager */\n  sqlite3_backup *pNext;   /* Next backup associated with source pager */\n};\n\n/*\n** THREAD SAFETY NOTES:\n**\n**   Once it has been created using backup_init(), a single sqlite3_backup\n**   structure may be accessed via two groups of thread-safe entry points:\n**\n**     * Via the sqlite3_backup_XXX() API function backup_step() and \n**       backup_finish(). Both these functions obtain the source database\n**       handle mutex and the mutex associated with the source BtShared \n**       structure, in that order.\n**\n**     * Via the BackupUpdate() and BackupRestart() functions, which are\n**       invoked by the pager layer to report various state changes in\n**       the page cache associated with the source database. The mutex\n**       associated with the source database BtShared structure will always \n**       be held when either of these functions are invoked.\n**\n**   The other sqlite3_backup_XXX() API functions, backup_remaining() and\n**   backup_pagecount() are not thread-safe functions. If they are called\n**   while some other thread is calling backup_step() or backup_finish(),\n**   the values returned may be invalid. There is no way for a call to\n**   BackupUpdate() or BackupRestart() to interfere with backup_remaining()\n**   or backup_pagecount().\n**\n**   Depending on the SQLite configuration, the database handles and/or\n**   the Btree objects may have their own mutexes that require locking.\n**   Non-sharable Btrees (in-memory databases for example), do not have\n**   associated mutexes.\n*/\n\n/*\n** Return a pointer corresponding to database zDb (i.e. \"main\", \"temp\")\n** in connection handle pDb. If such a database cannot be found, return\n** a NULL pointer and write an error message to pErrorDb.\n**\n** If the \"temp\" database is requested, it may need to be opened by this \n** function. If an error occurs while doing so, return 0 and write an \n** error message to pErrorDb.\n*/\nstatic Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){\n  int i = sqlite3FindDbName(pDb, zDb);\n\n  if( i==1 ){\n    Parse sParse;\n    int rc = 0;\n    memset(&sParse, 0, sizeof(sParse));\n    sParse.db = pDb;\n    if( sqlite3OpenTempDatabase(&sParse) ){\n      sqlite3ErrorWithMsg(pErrorDb, sParse.rc, \"%s\", sParse.zErrMsg);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3DbFree(pErrorDb, sParse.zErrMsg);\n    sqlite3ParserReset(&sParse);\n    if( rc ){\n      return 0;\n    }\n  }\n\n  if( i<0 ){\n    sqlite3ErrorWithMsg(pErrorDb, SQLITE_ERROR, \"unknown database %s\", zDb);\n    return 0;\n  }\n\n  return pDb->aDb[i].pBt;\n}\n\n/*\n** Attempt to set the page size of the destination to match the page size\n** of the source.\n*/\nstatic int setDestPgsz(sqlite3_backup *p){\n  int rc;\n  rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0);\n  return rc;\n}\n\n/*\n** Check that there is no open read-transaction on the b-tree passed as the\n** second argument. If there is not, return SQLITE_OK. Otherwise, if there\n** is an open read-transaction, return SQLITE_ERROR and leave an error \n** message in database handle db.\n*/\nstatic int checkReadTransaction(sqlite3 *db, Btree *p){\n  if( sqlite3BtreeIsInReadTrans(p) ){\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"destination database is in use\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create an sqlite3_backup process to copy the contents of zSrcDb from\n** connection handle pSrcDb to zDestDb in pDestDb. If successful, return\n** a pointer to the new sqlite3_backup object.\n**\n** If an error occurs, NULL is returned and an error code and error message\n** stored in database handle pDestDb.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3* pDestDb,                     /* Database to write to */\n  const char *zDestDb,                  /* Name of database within pDestDb */\n  sqlite3* pSrcDb,                      /* Database connection to read from */\n  const char *zSrcDb                    /* Name of database within pSrcDb */\n){\n  sqlite3_backup *p;                    /* Value to return */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pSrcDb)||!sqlite3SafetyCheckOk(pDestDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  /* Lock the source database handle. The destination database\n  ** handle is not locked in this routine, but it is locked in\n  ** sqlite3_backup_step(). The user is required to ensure that no\n  ** other thread accesses the destination handle for the duration\n  ** of the backup operation.  Any attempt to use the destination\n  ** database connection while a backup is in progress may cause\n  ** a malfunction or a deadlock.\n  */\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3_mutex_enter(pDestDb->mutex);\n\n  if( pSrcDb==pDestDb ){\n    sqlite3ErrorWithMsg(\n        pDestDb, SQLITE_ERROR, \"source and destination must be distinct\"\n    );\n    p = 0;\n  }else {\n    /* Allocate space for a new sqlite3_backup object...\n    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup));\n    if( !p ){\n      sqlite3Error(pDestDb, SQLITE_NOMEM_BKPT);\n    }\n  }\n\n  /* If the allocation succeeded, populate the new object. */\n  if( p ){\n    p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb);\n    p->pDest = findBtree(pDestDb, pDestDb, zDestDb);\n    p->pDestDb = pDestDb;\n    p->pSrcDb = pSrcDb;\n    p->iNext = 1;\n    p->isAttached = 0;\n\n    if( 0==p->pSrc || 0==p->pDest \n     || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK \n     ){\n      /* One (or both) of the named databases did not exist or an OOM\n      ** error was hit. Or there is a transaction open on the destination\n      ** database. The error has already been written into the pDestDb \n      ** handle. All that is left to do here is free the sqlite3_backup \n      ** structure.  */\n      sqlite3_free(p);\n      p = 0;\n    }\n  }\n  if( p ){\n    p->pSrc->nBackup++;\n  }\n\n  sqlite3_mutex_leave(pDestDb->mutex);\n  sqlite3_mutex_leave(pSrcDb->mutex);\n  return p;\n}\n\n/*\n** Argument rc is an SQLite error code. Return true if this error is \n** considered fatal if encountered during a backup operation. All errors\n** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED.\n*/\nstatic int isFatalError(int rc){\n  return (rc!=SQLITE_OK && rc!=SQLITE_BUSY && ALWAYS(rc!=SQLITE_LOCKED));\n}\n\n/*\n** Parameter zSrcData points to a buffer containing the data for \n** page iSrcPg from the source database. Copy this data into the \n** destination database.\n*/\nstatic int backupOnePage(\n  sqlite3_backup *p,              /* Backup handle */\n  Pgno iSrcPg,                    /* Source database page to backup */\n  const u8 *zSrcData,             /* Source database page data */\n  int bUpdate                     /* True for an update, false otherwise */\n){\n  Pager * const pDestPager = sqlite3BtreePager(p->pDest);\n  const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);\n  int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);\n  const int nCopy = MIN(nSrcPgsz, nDestPgsz);\n  const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;\n#ifdef SQLITE_HAS_CODEC\n  /* Use BtreeGetReserveNoMutex() for the source b-tree, as although it is\n  ** guaranteed that the shared-mutex is held by this thread, handle\n  ** p->pSrc may not actually be the owner.  */\n  int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);\n  int nDestReserve = sqlite3BtreeGetOptimalReserve(p->pDest);\n#endif\n  int rc = SQLITE_OK;\n  i64 iOff;\n\n  assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );\n  assert( p->bDestLocked );\n  assert( !isFatalError(p->rc) );\n  assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );\n  assert( zSrcData );\n\n  /* Catch the case where the destination is an in-memory database and the\n  ** page sizes of the source and destination differ. \n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){\n    rc = SQLITE_READONLY;\n  }\n\n#ifdef SQLITE_HAS_CODEC\n  /* Backup is not possible if the page size of the destination is changing\n  ** and a codec is in use.\n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){\n    rc = SQLITE_READONLY;\n  }\n\n  /* Backup is not possible if the number of bytes of reserve space differ\n  ** between source and destination.  If there is a difference, try to\n  ** fix the destination to agree with the source.  If that is not possible,\n  ** then the backup cannot proceed.\n  */\n  if( nSrcReserve!=nDestReserve ){\n    u32 newPgsz = nSrcPgsz;\n    rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve);\n    if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY;\n  }\n#endif\n\n  /* This loop runs once for each destination page spanned by the source \n  ** page. For each iteration, variable iOff is set to the byte offset\n  ** of the destination page.\n  */\n  for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){\n    DbPage *pDestPg = 0;\n    Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;\n    if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;\n    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))\n     && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))\n    ){\n      const u8 *zIn = &zSrcData[iOff%nSrcPgsz];\n      u8 *zDestData = sqlite3PagerGetData(pDestPg);\n      u8 *zOut = &zDestData[iOff%nDestPgsz];\n\n      /* Copy the data from the source page into the destination page.\n      ** Then clear the Btree layer MemPage.isInit flag. Both this module\n      ** and the pager code use this trick (clearing the first byte\n      ** of the page 'extra' space to invalidate the Btree layers\n      ** cached parse of the page). MemPage.isInit is marked \n      ** \"MUST BE FIRST\" for this purpose.\n      */\n      memcpy(zOut, zIn, nCopy);\n      ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;\n      if( iOff==0 && bUpdate==0 ){\n        sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));\n      }\n    }\n    sqlite3PagerUnref(pDestPg);\n  }\n\n  return rc;\n}\n\n/*\n** If pFile is currently larger than iSize bytes, then truncate it to\n** exactly iSize bytes. If pFile is not larger than iSize bytes, then\n** this function is a no-op.\n**\n** Return SQLITE_OK if everything is successful, or an SQLite error \n** code if an error occurs.\n*/\nstatic int backupTruncateFile(sqlite3_file *pFile, i64 iSize){\n  i64 iCurrent;\n  int rc = sqlite3OsFileSize(pFile, &iCurrent);\n  if( rc==SQLITE_OK && iCurrent>iSize ){\n    rc = sqlite3OsTruncate(pFile, iSize);\n  }\n  return rc;\n}\n\n/*\n** Register this backup object with the associated source pager for\n** callbacks when pages are changed or the cache invalidated.\n*/\nstatic void attachBackupObject(sqlite3_backup *p){\n  sqlite3_backup **pp;\n  assert( sqlite3BtreeHoldsMutex(p->pSrc) );\n  pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n  p->pNext = *pp;\n  *pp = p;\n  p->isAttached = 1;\n}\n\n/*\n** Copy nPage pages from the source b-tree to the destination.\n*/\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){\n  int rc;\n  int destMode;       /* Destination journal mode */\n  int pgszSrc = 0;    /* Source page size */\n  int pgszDest = 0;   /* Destination page size */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(p->pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  rc = p->rc;\n  if( !isFatalError(rc) ){\n    Pager * const pSrcPager = sqlite3BtreePager(p->pSrc);     /* Source pager */\n    Pager * const pDestPager = sqlite3BtreePager(p->pDest);   /* Dest pager */\n    int ii;                            /* Iterator variable */\n    int nSrcPage = -1;                 /* Size of source db in pages */\n    int bCloseTrans = 0;               /* True if src db requires unlocking */\n\n    /* If the source pager is currently in a write-transaction, return\n    ** SQLITE_BUSY immediately.\n    */\n    if( p->pDestDb && p->pSrc->pBt->inTransaction==TRANS_WRITE ){\n      rc = SQLITE_BUSY;\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* If there is no open read-transaction on the source database, open\n    ** one now. If a transaction is opened here, then it will be closed\n    ** before this function exits.\n    */\n    if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){\n      rc = sqlite3BtreeBeginTrans(p->pSrc, 0);\n      bCloseTrans = 1;\n    }\n\n    /* If the destination database has not yet been locked (i.e. if this\n    ** is the first call to backup_step() for the current backup operation),\n    ** try to set its page size to the same as the source database. This\n    ** is especially important on ZipVFS systems, as in that case it is\n    ** not possible to create a database file that uses one page size by\n    ** writing to it with another.  */\n    if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){\n      rc = SQLITE_NOMEM;\n    }\n\n    /* Lock the destination database, if it is not locked already. */\n    if( SQLITE_OK==rc && p->bDestLocked==0\n     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2)) \n    ){\n      p->bDestLocked = 1;\n      sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);\n    }\n\n    /* Do not allow backup if the destination database is in WAL mode\n    ** and the page sizes are different between source and destination */\n    pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);\n    pgszDest = sqlite3BtreeGetPageSize(p->pDest);\n    destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));\n    if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){\n      rc = SQLITE_READONLY;\n    }\n  \n    /* Now that there is a read-lock on the source database, query the\n    ** source pager for the number of pages in the database.\n    */\n    nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);\n    assert( nSrcPage>=0 );\n    for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){\n      const Pgno iSrcPg = p->iNext;                 /* Source page number */\n      if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){\n        DbPage *pSrcPg;                             /* Source page object */\n        rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg,PAGER_GET_READONLY);\n        if( rc==SQLITE_OK ){\n          rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);\n          sqlite3PagerUnref(pSrcPg);\n        }\n      }\n      p->iNext++;\n    }\n    if( rc==SQLITE_OK ){\n      p->nPagecount = nSrcPage;\n      p->nRemaining = nSrcPage+1-p->iNext;\n      if( p->iNext>(Pgno)nSrcPage ){\n        rc = SQLITE_DONE;\n      }else if( !p->isAttached ){\n        attachBackupObject(p);\n      }\n    }\n  \n    /* Update the schema version field in the destination database. This\n    ** is to make sure that the schema-version really does change in\n    ** the case where the source and destination databases have the\n    ** same schema version.\n    */\n    if( rc==SQLITE_DONE ){\n      if( nSrcPage==0 ){\n        rc = sqlite3BtreeNewDb(p->pDest);\n        nSrcPage = 1;\n      }\n      if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n        rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);\n      }\n      if( rc==SQLITE_OK ){\n        if( p->pDestDb ){\n          sqlite3ResetAllSchemasOfConnection(p->pDestDb);\n        }\n        if( destMode==PAGER_JOURNALMODE_WAL ){\n          rc = sqlite3BtreeSetVersion(p->pDest, 2);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        int nDestTruncate;\n        /* Set nDestTruncate to the final number of pages in the destination\n        ** database. The complication here is that the destination page\n        ** size may be different to the source page size. \n        **\n        ** If the source page size is smaller than the destination page size, \n        ** round up. In this case the call to sqlite3OsTruncate() below will\n        ** fix the size of the file. However it is important to call\n        ** sqlite3PagerTruncateImage() here so that any pages in the \n        ** destination file that lie beyond the nDestTruncate page mark are\n        ** journalled by PagerCommitPhaseOne() before they are destroyed\n        ** by the file truncation.\n        */\n        assert( pgszSrc==sqlite3BtreeGetPageSize(p->pSrc) );\n        assert( pgszDest==sqlite3BtreeGetPageSize(p->pDest) );\n        if( pgszSrc<pgszDest ){\n          int ratio = pgszDest/pgszSrc;\n          nDestTruncate = (nSrcPage+ratio-1)/ratio;\n          if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){\n            nDestTruncate--;\n          }\n        }else{\n          nDestTruncate = nSrcPage * (pgszSrc/pgszDest);\n        }\n        assert( nDestTruncate>0 );\n\n        if( pgszSrc<pgszDest ){\n          /* If the source page-size is smaller than the destination page-size,\n          ** two extra things may need to happen:\n          **\n          **   * The destination may need to be truncated, and\n          **\n          **   * Data stored on the pages immediately following the \n          **     pending-byte page in the source database may need to be\n          **     copied into the destination database.\n          */\n          const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;\n          sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);\n          Pgno iPg;\n          int nDstPage;\n          i64 iOff;\n          i64 iEnd;\n\n          assert( pFile );\n          assert( nDestTruncate==0 \n              || (i64)nDestTruncate*(i64)pgszDest >= iSize || (\n                nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)\n             && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest\n          ));\n\n          /* This block ensures that all data required to recreate the original\n          ** database has been stored in the journal for pDestPager and the\n          ** journal synced to disk. So at this point we may safely modify\n          ** the database file in any way, knowing that if a power failure\n          ** occurs, the original database will be reconstructed from the \n          ** journal file.  */\n          sqlite3PagerPagecount(pDestPager, &nDstPage);\n          for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){\n            if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){\n              DbPage *pPg;\n              rc = sqlite3PagerGet(pDestPager, iPg, &pPg, 0);\n              if( rc==SQLITE_OK ){\n                rc = sqlite3PagerWrite(pPg);\n                sqlite3PagerUnref(pPg);\n              }\n            }\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);\n          }\n\n          /* Write the extra pages and truncate the database file as required */\n          iEnd = MIN(PENDING_BYTE + pgszDest, iSize);\n          for(\n            iOff=PENDING_BYTE+pgszSrc; \n            rc==SQLITE_OK && iOff<iEnd; \n            iOff+=pgszSrc\n          ){\n            PgHdr *pSrcPg = 0;\n            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);\n            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg, 0);\n            if( rc==SQLITE_OK ){\n              u8 *zData = sqlite3PagerGetData(pSrcPg);\n              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);\n            }\n            sqlite3PagerUnref(pSrcPg);\n          }\n          if( rc==SQLITE_OK ){\n            rc = backupTruncateFile(pFile, iSize);\n          }\n\n          /* Sync the database file to disk. */\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerSync(pDestPager, 0);\n          }\n        }else{\n          sqlite3PagerTruncateImage(pDestPager, nDestTruncate);\n          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);\n        }\n    \n        /* Finish committing the transaction to the destination database. */\n        if( SQLITE_OK==rc\n         && SQLITE_OK==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))\n        ){\n          rc = SQLITE_DONE;\n        }\n      }\n    }\n  \n    /* If bCloseTrans is true, then this function opened a read transaction\n    ** on the source database. Close the read transaction here. There is\n    ** no need to check the return values of the btree methods here, as\n    ** \"committing\" a read-only transaction cannot fail.\n    */\n    if( bCloseTrans ){\n      TESTONLY( int rc2 );\n      TESTONLY( rc2  = ) sqlite3BtreeCommitPhaseOne(p->pSrc, 0);\n      TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p->pSrc, 0);\n      assert( rc2==SQLITE_OK );\n    }\n  \n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    p->rc = rc;\n  }\n  if( p->pDestDb ){\n    sqlite3_mutex_leave(p->pDestDb->mutex);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  sqlite3_mutex_leave(p->pSrcDb->mutex);\n  return rc;\n}\n\n/*\n** Release all resources associated with an sqlite3_backup* handle.\n*/\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){\n  sqlite3_backup **pp;                 /* Ptr to head of pagers backup list */\n  sqlite3 *pSrcDb;                     /* Source database connection */\n  int rc;                              /* Value to return */\n\n  /* Enter the mutexes */\n  if( p==0 ) return SQLITE_OK;\n  pSrcDb = p->pSrcDb;\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  /* Detach this backup from the source pager. */\n  if( p->pDestDb ){\n    p->pSrc->nBackup--;\n  }\n  if( p->isAttached ){\n    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n    while( *pp!=p ){\n      pp = &(*pp)->pNext;\n    }\n    *pp = p->pNext;\n  }\n\n  /* If a transaction is still open on the Btree, roll it back. */\n  sqlite3BtreeRollback(p->pDest, SQLITE_OK, 0);\n\n  /* Set the error code of the destination database handle. */\n  rc = (p->rc==SQLITE_DONE) ? SQLITE_OK : p->rc;\n  if( p->pDestDb ){\n    sqlite3Error(p->pDestDb, rc);\n\n    /* Exit the mutexes and free the backup context structure. */\n    sqlite3LeaveMutexAndCloseZombie(p->pDestDb);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  if( p->pDestDb ){\n    /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    sqlite3_free(p);\n  }\n  sqlite3LeaveMutexAndCloseZombie(pSrcDb);\n  return rc;\n}\n\n/*\n** Return the number of pages still to be backed up as of the most recent\n** call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nRemaining;\n}\n\n/*\n** Return the total number of pages in the source database as of the most \n** recent call to sqlite3_backup_step().\n*/\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nPagecount;\n}\n\n/*\n** This function is called after the contents of page iPage of the\n** source database have been modified. If page iPage has already been \n** copied into the destination database, then the data written to the\n** destination is now invalidated. The destination copy of iPage needs\n** to be updated with the new data before the backup operation is\n** complete.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nstatic SQLITE_NOINLINE void backupUpdate(\n  sqlite3_backup *p,\n  Pgno iPage,\n  const u8 *aData\n){\n  assert( p!=0 );\n  do{\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    if( !isFatalError(p->rc) && iPage<p->iNext ){\n      /* The backup process p has already copied page iPage. But now it\n      ** has been modified by a transaction on the source pager. Copy\n      ** the new data into the backup.\n      */\n      int rc;\n      assert( p->pDestDb );\n      sqlite3_mutex_enter(p->pDestDb->mutex);\n      rc = backupOnePage(p, iPage, aData, 1);\n      sqlite3_mutex_leave(p->pDestDb->mutex);\n      assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );\n      if( rc!=SQLITE_OK ){\n        p->rc = rc;\n      }\n    }\n  }while( (p = p->pNext)!=0 );\n}\nSQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){\n  if( pBackup ) backupUpdate(pBackup, iPage, aData);\n}\n\n/*\n** Restart the backup process. This is called when the pager layer\n** detects that the database has been modified by an external database\n** connection. In this case there is no way of knowing which of the\n** pages that have been copied into the destination database are still \n** valid and which are not, so the entire process needs to be restarted.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nSQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *pBackup){\n  sqlite3_backup *p;                   /* Iterator variable */\n  for(p=pBackup; p; p=p->pNext){\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    p->iNext = 1;\n  }\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Copy the complete content of pBtFrom into pBtTo.  A transaction\n** must be active for both files.\n**\n** The size of file pTo may be reduced by this operation. If anything \n** goes wrong, the transaction on pTo is rolled back. If successful, the \n** transaction is committed before returning.\n*/\nSQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){\n  int rc;\n  sqlite3_file *pFd;              /* File descriptor for database pTo */\n  sqlite3_backup b;\n  sqlite3BtreeEnter(pTo);\n  sqlite3BtreeEnter(pFrom);\n\n  assert( sqlite3BtreeIsInTrans(pTo) );\n  pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));\n  if( pFd->pMethods ){\n    i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);\n    rc = sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n    if( rc ) goto copy_finished;\n  }\n\n  /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set\n  ** to 0. This is used by the implementations of sqlite3_backup_step()\n  ** and sqlite3_backup_finish() to detect that they are being called\n  ** from this function, not directly by the user.\n  */\n  memset(&b, 0, sizeof(b));\n  b.pSrcDb = pFrom->db;\n  b.pSrc = pFrom;\n  b.pDest = pTo;\n  b.iNext = 1;\n\n#ifdef SQLITE_HAS_CODEC\n  sqlite3PagerAlignReserve(sqlite3BtreePager(pTo), sqlite3BtreePager(pFrom));\n#endif\n\n  /* 0x7FFFFFFF is the hard limit for the number of pages in a database\n  ** file. By passing this as the number of pages to copy to\n  ** sqlite3_backup_step(), we can guarantee that the copy finishes \n  ** within a single call (unless an error occurs). The assert() statement\n  ** checks this assumption - (p->rc) should be set to either SQLITE_DONE \n  ** or an error code.  */\n  sqlite3_backup_step(&b, 0x7FFFFFFF);\n  assert( b.rc!=SQLITE_OK );\n\n  rc = sqlite3_backup_finish(&b);\n  if( rc==SQLITE_OK ){\n    pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;\n  }else{\n    sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));\n  }\n\n  assert( sqlite3BtreeIsInTrans(pTo)==0 );\ncopy_finished:\n  sqlite3BtreeLeave(pFrom);\n  sqlite3BtreeLeave(pTo);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VACUUM */\n\n/************** End of backup.c **********************************************/\n/************** Begin file vdbemem.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to manipulate \"Mem\" structure.  A \"Mem\"\n** stores a single value in the VDBE.  Mem is an opaque structure visible\n** only within the VDBE.  Interface routines refer to a Mem using the\n** name sqlite_value\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifdef SQLITE_DEBUG\n/*\n** Check invariants on a Mem object.\n**\n** This routine is intended for use inside of assert() statements, like\n** this:    assert( sqlite3VdbeCheckMemInvariants(pMem) );\n*/\nSQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem *p){\n  /* If MEM_Dyn is set then Mem.xDel!=0.  \n  ** Mem.xDel might not be initialized if MEM_Dyn is clear.\n  */\n  assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 );\n\n  /* MEM_Dyn may only be set if Mem.szMalloc==0.  In this way we\n  ** ensure that if Mem.szMalloc>0 then it is safe to do\n  ** Mem.z = Mem.zMalloc without having to check Mem.flags&MEM_Dyn.\n  ** That saves a few cycles in inner loops. */\n  assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 );\n\n  /* Cannot be both MEM_Int and MEM_Real at the same time */\n  assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) );\n\n  if( p->flags & MEM_Null ){\n    /* Cannot be both MEM_Null and some other type */\n    assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob\n                         |MEM_RowSet|MEM_Frame|MEM_Agg|MEM_Zero))==0 );\n\n    /* If MEM_Null is set, then either the value is a pure NULL (the usual\n    ** case) or it is a pointer set using sqlite3_bind_pointer() or\n    ** sqlite3_result_pointer().  If a pointer, then MEM_Term must also be\n    ** set.\n    */\n    if( (p->flags & (MEM_Term|MEM_Subtype))==(MEM_Term|MEM_Subtype) ){\n      /* This is a pointer type.  There may be a flag to indicate what to\n      ** do with the pointer. */\n      assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );\n\n      /* No other bits set */\n      assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype\n                           |MEM_Dyn|MEM_Ephem|MEM_Static))==0 );\n    }else{\n      /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,\n      ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */\n    }\n  }else{\n    /* The MEM_Cleared bit is only allowed on NULLs */\n    assert( (p->flags & MEM_Cleared)==0 );\n  }\n\n  /* The szMalloc field holds the correct memory allocation size */\n  assert( p->szMalloc==0\n       || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );\n\n  /* If p holds a string or blob, the Mem.z must point to exactly\n  ** one of the following:\n  **\n  **   (1) Memory in Mem.zMalloc and managed by the Mem object\n  **   (2) Memory to be freed using Mem.xDel\n  **   (3) An ephemeral string or blob\n  **   (4) A static string or blob\n  */\n  if( (p->flags & (MEM_Str|MEM_Blob)) && p->n>0 ){\n    assert( \n      ((p->szMalloc>0 && p->z==p->zMalloc)? 1 : 0) +\n      ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Static)!=0 ? 1 : 0) == 1\n    );\n  }\n  return 1;\n}\n#endif\n\n\n/*\n** If pMem is an object with a valid string representation, this routine\n** ensures the internal encoding for the string representation is\n** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.\n**\n** If pMem is not a string object, or the encoding of the string\n** representation is already stored using the requested encoding, then this\n** routine is a no-op.\n**\n** SQLITE_OK is returned if the conversion is successful (or not required).\n** SQLITE_NOMEM may be returned if a malloc() fails during conversion\n** between formats.\n*/\nSQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){\n#ifndef SQLITE_OMIT_UTF16\n  int rc;\n#endif\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE\n           || desiredEnc==SQLITE_UTF16BE );\n  if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){\n    return SQLITE_OK;\n  }\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n#ifdef SQLITE_OMIT_UTF16\n  return SQLITE_ERROR;\n#else\n\n  /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,\n  ** then the encoding of the value may not have changed.\n  */\n  rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);\n  assert(rc==SQLITE_OK    || rc==SQLITE_NOMEM);\n  assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);\n  assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);\n  return rc;\n#endif\n}\n\n/*\n** Make sure pMem->z points to a writable allocation of at least \n** min(n,32) bytes.\n**\n** If the bPreserve argument is true, then copy of the content of\n** pMem->z into the new allocation.  pMem must be either a string or\n** blob if bPreserve is true.  If bPreserve is false, any prior content\n** in pMem->z is discarded.\n*/\nSQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){\n  assert( sqlite3VdbeCheckMemInvariants(pMem) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  testcase( pMem->db==0 );\n\n  /* If the bPreserve flag is set to true, then the memory cell must already\n  ** contain a valid string or blob value.  */\n  assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );\n  testcase( bPreserve && pMem->z==0 );\n\n  assert( pMem->szMalloc==0\n       || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );\n  if( n<32 ) n = 32;\n  if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){\n    pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);\n    bPreserve = 0;\n  }else{\n    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n    pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);\n  }\n  if( pMem->zMalloc==0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n    pMem->szMalloc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }\n\n  if( bPreserve && pMem->z ){\n    assert( pMem->z!=pMem->zMalloc );\n    memcpy(pMem->zMalloc, pMem->z, pMem->n);\n  }\n  if( (pMem->flags&MEM_Dyn)!=0 ){\n    assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );\n    pMem->xDel((void *)(pMem->z));\n  }\n\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);\n  return SQLITE_OK;\n}\n\n/*\n** Change the pMem->zMalloc allocation to be at least szNew bytes.\n** If pMem->zMalloc already meets or exceeds the requested size, this\n** routine is a no-op.\n**\n** Any prior string or blob content in the pMem object may be discarded.\n** The pMem->xDel destructor is called, if it exists.  Though MEM_Str\n** and MEM_Blob values may be discarded, MEM_Int, MEM_Real, and MEM_Null\n** values are preserved.\n**\n** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM)\n** if unable to complete the resizing.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){\n  assert( szNew>0 );\n  assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );\n  if( pMem->szMalloc<szNew ){\n    return sqlite3VdbeMemGrow(pMem, szNew, 0);\n  }\n  assert( (pMem->flags & MEM_Dyn)==0 );\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** It is already known that pMem contains an unterminated string.\n** Add the zero terminator.\n*/\nstatic SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){\n  if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pMem->z[pMem->n] = 0;\n  pMem->z[pMem->n+1] = 0;\n  pMem->flags |= MEM_Term;\n  return SQLITE_OK;\n}\n\n/*\n** Change pMem so that its MEM_Str or MEM_Blob value is stored in\n** MEM.zMalloc, where it can be safely written.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){\n    if( ExpandBlob(pMem) ) return SQLITE_NOMEM;\n    if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){\n      int rc = vdbeMemAddTerminator(pMem);\n      if( rc ) return rc;\n    }\n  }\n  pMem->flags &= ~MEM_Ephem;\n#ifdef SQLITE_DEBUG\n  pMem->pScopyFrom = 0;\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If the given Mem* has a zero-filled tail, turn it into an ordinary\n** blob stored in dynamically allocated space.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nSQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){\n  int nByte;\n  assert( pMem->flags & MEM_Zero );\n  assert( pMem->flags&MEM_Blob );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n\n  /* Set nByte to the number of bytes required to store the expanded blob. */\n  nByte = pMem->n + pMem->u.nZero;\n  if( nByte<=0 ){\n    nByte = 1;\n  }\n  if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  memset(&pMem->z[pMem->n], 0, pMem->u.nZero);\n  pMem->n += pMem->u.nZero;\n  pMem->flags &= ~(MEM_Zero|MEM_Term);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Make sure the given Mem is \\u0000 terminated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );\n  if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){\n    return SQLITE_OK;   /* Nothing to do */\n  }else{\n    return vdbeMemAddTerminator(pMem);\n  }\n}\n\n/*\n** Add MEM_Str to the set of representations for the given Mem.  Numbers\n** are converted using sqlite3_snprintf().  Converting a BLOB to a string\n** is a no-op.\n**\n** Existing representations MEM_Int and MEM_Real are invalidated if\n** bForce is true but are retained if bForce is false.\n**\n** A MEM_Null value will never be passed to this function. This function is\n** used for converting values to text for returning to the user (i.e. via\n** sqlite3_value_text()), or for ensuring that values to be used as btree\n** keys are strings. In the former case a NULL pointer is returned the\n** user and the latter is an internal programming error.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){\n  int fg = pMem->flags;\n  const int nByte = 32;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !(fg&MEM_Zero) );\n  assert( !(fg&(MEM_Str|MEM_Blob)) );\n  assert( fg&(MEM_Int|MEM_Real) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n\n  if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    pMem->enc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8\n  ** string representation of the value. Then, if the required encoding\n  ** is UTF-16le or UTF-16be do a translation.\n  ** \n  ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.\n  */\n  if( fg & MEM_Int ){\n    sqlite3_snprintf(nByte, pMem->z, \"%lld\", pMem->u.i);\n  }else{\n    assert( fg & MEM_Real );\n    sqlite3_snprintf(nByte, pMem->z, \"%!.15g\", pMem->u.r);\n  }\n  pMem->n = sqlite3Strlen30(pMem->z);\n  pMem->enc = SQLITE_UTF8;\n  pMem->flags |= MEM_Str|MEM_Term;\n  if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);\n  sqlite3VdbeChangeEncoding(pMem, enc);\n  return SQLITE_OK;\n}\n\n/*\n** Memory cell pMem contains the context of an aggregate function.\n** This routine calls the finalize method for that function.  The\n** result of the aggregate is stored back into pMem.\n**\n** Return SQLITE_ERROR if the finalizer reports an error.  SQLITE_OK\n** otherwise.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pFunc && pFunc->xFinalize) ){\n    sqlite3_context ctx;\n    Mem t;\n    assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    memset(&ctx, 0, sizeof(ctx));\n    memset(&t, 0, sizeof(t));\n    t.flags = MEM_Null;\n    t.db = pMem->db;\n    ctx.pOut = &t;\n    ctx.pMem = pMem;\n    ctx.pFunc = pFunc;\n    pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */\n    assert( (pMem->flags & MEM_Dyn)==0 );\n    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n    memcpy(pMem, &t, sizeof(t));\n    rc = ctx.isError;\n  }\n  return rc;\n}\n\n/*\n** If the memory cell contains a value that must be freed by\n** invoking the external callback in Mem.xDel, then this routine\n** will free that value.  It also sets Mem.flags to MEM_Null.\n**\n** This is a helper routine for sqlite3VdbeMemSetNull() and\n** for sqlite3VdbeMemRelease().  Use those other routines as the\n** entry point for releasing Mem resources.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClearExternAndSetNull(Mem *p){\n  assert( p->db==0 || sqlite3_mutex_held(p->db->mutex) );\n  assert( VdbeMemDynamic(p) );\n  if( p->flags&MEM_Agg ){\n    sqlite3VdbeMemFinalize(p, p->u.pDef);\n    assert( (p->flags & MEM_Agg)==0 );\n    testcase( p->flags & MEM_Dyn );\n  }\n  if( p->flags&MEM_Dyn ){\n    assert( (p->flags&MEM_RowSet)==0 );\n    assert( p->xDel!=SQLITE_DYNAMIC && p->xDel!=0 );\n    p->xDel((void *)p->z);\n  }else if( p->flags&MEM_RowSet ){\n    sqlite3RowSetClear(p->u.pRowSet);\n  }else if( p->flags&MEM_Frame ){\n    VdbeFrame *pFrame = p->u.pFrame;\n    pFrame->pParent = pFrame->v->pDelFrame;\n    pFrame->v->pDelFrame = pFrame;\n  }\n  p->flags = MEM_Null;\n}\n\n/*\n** Release memory held by the Mem p, both external memory cleared\n** by p->xDel and memory in p->zMalloc.\n**\n** This is a helper routine invoked by sqlite3VdbeMemRelease() in\n** the unusual case where there really is memory in p that needs\n** to be freed.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClear(Mem *p){\n  if( VdbeMemDynamic(p) ){\n    vdbeMemClearExternAndSetNull(p);\n  }\n  if( p->szMalloc ){\n    sqlite3DbFreeNN(p->db, p->zMalloc);\n    p->szMalloc = 0;\n  }\n  p->z = 0;\n}\n\n/*\n** Release any memory resources held by the Mem.  Both the memory that is\n** free by Mem.xDel and the Mem.zMalloc allocation are freed.\n**\n** Use this routine prior to clean up prior to abandoning a Mem, or to\n** reset a Mem back to its minimum memory utilization.\n**\n** Use sqlite3VdbeMemSetNull() to release just the Mem.xDel space\n** prior to inserting new content into the Mem.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemRelease(Mem *p){\n  assert( sqlite3VdbeCheckMemInvariants(p) );\n  if( VdbeMemDynamic(p) || p->szMalloc ){\n    vdbeMemClear(p);\n  }\n}\n\n/*\n** Convert a 64-bit IEEE double into a 64-bit signed integer.\n** If the double is out of range of a 64-bit signed integer then\n** return the closest available 64-bit signed integer.\n*/\nstatic SQLITE_NOINLINE i64 doubleToInt64(double r){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  /* When floating-point is omitted, double and int64 are the same thing */\n  return r;\n#else\n  /*\n  ** Many compilers we encounter do not define constants for the\n  ** minimum and maximum 64-bit integers, or they define them\n  ** inconsistently.  And many do not understand the \"LL\" notation.\n  ** So we define our own static constants here using nothing\n  ** larger than a 32-bit integer constant.\n  */\n  static const i64 maxInt = LARGEST_INT64;\n  static const i64 minInt = SMALLEST_INT64;\n\n  if( r<=(double)minInt ){\n    return minInt;\n  }else if( r>=(double)maxInt ){\n    return maxInt;\n  }else{\n    return (i64)r;\n  }\n#endif\n}\n\n/*\n** Return some kind of integer value which is the best we can do\n** at representing the value that *pMem describes as an integer.\n** If pMem is an integer, then the value is exact.  If pMem is\n** a floating-point then the value returned is the integer part.\n** If pMem is a string or blob, then we make an attempt to convert\n** it into an integer and return that.  If pMem represents an\n** an SQL-NULL value, return 0.\n**\n** If pMem represents a string value, its encoding might be changed.\n*/\nstatic SQLITE_NOINLINE i64 memIntValue(Mem *pMem){\n  i64 value = 0;\n  sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);\n  return value;\n}\nSQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){\n  int flags;\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  flags = pMem->flags;\n  if( flags & MEM_Int ){\n    return pMem->u.i;\n  }else if( flags & MEM_Real ){\n    return doubleToInt64(pMem->u.r);\n  }else if( flags & (MEM_Str|MEM_Blob) ){\n    assert( pMem->z || pMem->n==0 );\n    return memIntValue(pMem);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Return the best representation of pMem that we can get into a\n** double.  If pMem is already a double or an integer, return its\n** value.  If it is a string or blob, try to convert it to a double.\n** If it is a NULL, return 0.0.\n*/\nstatic SQLITE_NOINLINE double memRealValue(Mem *pMem){\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  double val = (double)0;\n  sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);\n  return val;\n}\nSQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  if( pMem->flags & MEM_Real ){\n    return pMem->u.r;\n  }else if( pMem->flags & MEM_Int ){\n    return (double)pMem->u.i;\n  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return memRealValue(pMem);\n  }else{\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    return (double)0;\n  }\n}\n\n/*\n** The MEM structure is already a MEM_Real.  Try to also make it a\n** MEM_Int if we can.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){\n  i64 ix;\n  assert( pMem->flags & MEM_Real );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  ix = doubleToInt64(pMem->u.r);\n\n  /* Only mark the value as an integer if\n  **\n  **    (1) the round-trip conversion real->int->real is a no-op, and\n  **    (2) The integer is neither the largest nor the smallest\n  **        possible integer (ticket #3922)\n  **\n  ** The second and third terms in the following conditional enforces\n  ** the second condition under the assumption that addition overflow causes\n  ** values to wrap around.\n  */\n  if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){\n    pMem->u.i = ix;\n    MemSetTypeFlag(pMem, MEM_Int);\n  }\n}\n\n/*\n** Convert pMem to type integer.  Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.i = sqlite3VdbeIntValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Int);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it is of type MEM_Real.\n** Invalidate any prior representations.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.r = sqlite3VdbeRealValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it has types MEM_Real or MEM_Int or both.\n** Invalidate any prior representations.\n**\n** Every effort is made to force the conversion, even if the input\n** is a string that does not look completely like a number.  Convert\n** as much of the string as we can and ignore the rest.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){\n  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){\n    int rc;\n    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);\n    if( rc==0 ){\n      MemSetTypeFlag(pMem, MEM_Int);\n    }else{\n      i64 i = pMem->u.i;\n      sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);\n      if( rc==1 && pMem->u.r==(double)i ){\n        pMem->u.i = i;\n        MemSetTypeFlag(pMem, MEM_Int);\n      }else{\n        MemSetTypeFlag(pMem, MEM_Real);\n      }\n    }\n  }\n  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );\n  pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero);\n  return SQLITE_OK;\n}\n\n/*\n** Cast the datatype of the value in pMem according to the affinity\n** \"aff\".  Casting is different from applying affinity in that a cast\n** is forced.  In other words, the value is converted into the desired\n** affinity even if that results in loss of data.  This routine is\n** used (for example) to implement the SQL \"cast()\" operator.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){\n  if( pMem->flags & MEM_Null ) return;\n  switch( aff ){\n    case SQLITE_AFF_BLOB: {   /* Really a cast to BLOB */\n      if( (pMem->flags & MEM_Blob)==0 ){\n        sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n        assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n        if( pMem->flags & MEM_Str ) MemSetTypeFlag(pMem, MEM_Blob);\n      }else{\n        pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);\n      }\n      break;\n    }\n    case SQLITE_AFF_NUMERIC: {\n      sqlite3VdbeMemNumerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_INTEGER: {\n      sqlite3VdbeMemIntegerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_REAL: {\n      sqlite3VdbeMemRealify(pMem);\n      break;\n    }\n    default: {\n      assert( aff==SQLITE_AFF_TEXT );\n      assert( MEM_Str==(MEM_Blob>>3) );\n      pMem->flags |= (pMem->flags&MEM_Blob)>>3;\n      sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n      assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n      pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);\n      break;\n    }\n  }\n}\n\n/*\n** Initialize bulk memory to be a consistent Mem object.\n**\n** The minimum amount of initialization feasible is performed.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){\n  assert( (flags & ~MEM_TypeMask)==0 );\n  pMem->flags = flags;\n  pMem->db = db;\n  pMem->szMalloc = 0;\n}\n\n\n/*\n** Delete any previous value and set the value stored in *pMem to NULL.\n**\n** This routine calls the Mem.xDel destructor to dispose of values that\n** require the destructor.  But it preserves the Mem.zMalloc memory allocation.\n** To free all resources, use sqlite3VdbeMemRelease(), which both calls this\n** routine to invoke the destructor and deallocates Mem.zMalloc.\n**\n** Use this routine to reset the Mem prior to insert a new value.\n**\n** Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem *pMem){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeMemClearExternAndSetNull(pMem);\n  }else{\n    pMem->flags = MEM_Null;\n  }\n}\nSQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){\n  sqlite3VdbeMemSetNull((Mem*)p); \n}\n\n/*\n** Delete any previous value and set the value to be a BLOB of length\n** n containing all zeros.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Blob|MEM_Zero;\n  pMem->n = 0;\n  if( n<0 ) n = 0;\n  pMem->u.nZero = n;\n  pMem->enc = SQLITE_UTF8;\n  pMem->z = 0;\n}\n\n/*\n** The pMem is known to contain content that needs to be destroyed prior\n** to a value change.  So invoke the destructor, then set the value to\n** a 64-bit integer.\n*/\nstatic SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){\n  sqlite3VdbeMemSetNull(pMem);\n  pMem->u.i = val;\n  pMem->flags = MEM_Int;\n}\n\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type INTEGER.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeReleaseAndSetInt64(pMem, val);\n  }else{\n    pMem->u.i = val;\n    pMem->flags = MEM_Int;\n  }\n}\n\n/* A no-op destructor */\nstatic void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }\n\n/*\n** Set the value stored in *pMem should already be a NULL.\n** Also store a pointer to go with it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetPointer(\n  Mem *pMem,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  assert( pMem->flags==MEM_Null );\n  pMem->u.zPType = zPType ? zPType : \"\";\n  pMem->z = pPtr;\n  pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;\n  pMem->eSubtype = 'p';\n  pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type REAL.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem *pMem, double val){\n  sqlite3VdbeMemSetNull(pMem);\n  if( !sqlite3IsNaN(val) ){\n    pMem->u.r = val;\n    pMem->flags = MEM_Real;\n  }\n}\n#endif\n\n/*\n** Delete any previous value and set the value of pMem to be an\n** empty boolean index.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemSetRowSet(Mem *pMem){\n  sqlite3 *db = pMem->db;\n  assert( db!=0 );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  sqlite3VdbeMemRelease(pMem);\n  pMem->zMalloc = sqlite3DbMallocRawNN(db, 64);\n  if( db->mallocFailed ){\n    pMem->flags = MEM_Null;\n    pMem->szMalloc = 0;\n  }else{\n    assert( pMem->zMalloc );\n    pMem->szMalloc = sqlite3DbMallocSize(db, pMem->zMalloc);\n    pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, pMem->szMalloc);\n    assert( pMem->u.pRowSet!=0 );\n    pMem->flags = MEM_RowSet;\n  }\n}\n\n/*\n** Return true if the Mem object contains a TEXT or BLOB that is\n** too large - whose size exceeds SQLITE_MAX_LENGTH.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){\n  assert( p->db!=0 );\n  if( p->flags & (MEM_Str|MEM_Blob) ){\n    int n = p->n;\n    if( p->flags & MEM_Zero ){\n      n += p->u.nZero;\n    }\n    return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  return 0; \n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This routine prepares a memory cell for modification by breaking\n** its link to a shallow copy and by marking any current shallow\n** copies of this cell as invalid.\n**\n** This is used for testing and debugging only - to make sure shallow\n** copies are not misused.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){\n  int i;\n  Mem *pX;\n  for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){\n    if( pX->pScopyFrom==pMem ){\n      pX->flags |= MEM_Undefined;\n      pX->pScopyFrom = 0;\n    }\n  }\n  pMem->pScopyFrom = 0;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/*\n** Make an shallow copy of pFrom into pTo.  Prior contents of\n** pTo are freed.  The pFrom->z field is not duplicated.  If\n** pFrom->z is used, then pTo->z points to the same thing as pFrom->z\n** and flags gets srcType (either MEM_Ephem or MEM_Static).\n*/\nstatic SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int eType){\n  vdbeMemClearExternAndSetNull(pTo);\n  assert( !VdbeMemDynamic(pTo) );\n  sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);\n}\nSQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  assert( pTo->db==pFrom->db );\n  if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  if( (pFrom->flags&MEM_Static)==0 ){\n    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);\n    assert( srcType==MEM_Ephem || srcType==MEM_Static );\n    pTo->flags |= srcType;\n  }\n}\n\n/*\n** Make a full copy of pFrom into pTo.  Prior contents of pTo are\n** freed before the copy is made.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){\n  int rc = SQLITE_OK;\n\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  pTo->flags &= ~MEM_Dyn;\n  if( pTo->flags&(MEM_Str|MEM_Blob) ){\n    if( 0==(pFrom->flags&MEM_Static) ){\n      pTo->flags |= MEM_Ephem;\n      rc = sqlite3VdbeMemMakeWriteable(pTo);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Transfer the contents of pFrom to pTo. Any existing value in pTo is\n** freed. If pFrom contains ephemeral data, a copy is made.\n**\n** pFrom contains an SQL NULL when this routine returns.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){\n  assert( pFrom->db==0 || sqlite3_mutex_held(pFrom->db->mutex) );\n  assert( pTo->db==0 || sqlite3_mutex_held(pTo->db->mutex) );\n  assert( pFrom->db==0 || pTo->db==0 || pFrom->db==pTo->db );\n\n  sqlite3VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, sizeof(Mem));\n  pFrom->flags = MEM_Null;\n  pFrom->szMalloc = 0;\n}\n\n/*\n** Change the value of a Mem to be a string or a BLOB.\n**\n** The memory management strategy depends on the value of the xDel\n** parameter. If the value passed is SQLITE_TRANSIENT, then the \n** string is copied into a (possibly existing) buffer managed by the \n** Mem structure. Otherwise, any existing buffer is freed and the\n** pointer copied.\n**\n** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH\n** size limit) then no memory allocation occurs.  If the string can be\n** stored without allocating memory, then it is.  If a memory allocation\n** is required to store the string, then value of pMem is unchanged.  In\n** either case, SQLITE_TOOBIG is returned.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMemSetStr(\n  Mem *pMem,          /* Memory cell to set to string value */\n  const char *z,      /* String pointer */\n  int n,              /* Bytes in string, or negative */\n  u8 enc,             /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*) /* Destructor function */\n){\n  int nByte = n;      /* New value for pMem->n */\n  int iLimit;         /* Maximum allowed string or blob size */\n  u16 flags = 0;      /* New value for pMem->flags */\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n\n  /* If z is a NULL pointer, set pMem to contain an SQL NULL. */\n  if( !z ){\n    sqlite3VdbeMemSetNull(pMem);\n    return SQLITE_OK;\n  }\n\n  if( pMem->db ){\n    iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }else{\n    iLimit = SQLITE_MAX_LENGTH;\n  }\n  flags = (enc==0?MEM_Blob:MEM_Str);\n  if( nByte<0 ){\n    assert( enc!=0 );\n    if( enc==SQLITE_UTF8 ){\n      nByte = 0x7fffffff & (int)strlen(z);\n      if( nByte>iLimit ) nByte = iLimit+1;\n    }else{\n      for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}\n    }\n    flags |= MEM_Term;\n  }\n\n  /* The following block sets the new values of Mem.z and Mem.xDel. It\n  ** also sets a flag in local variable \"flags\" to indicate the memory\n  ** management (one of MEM_Dyn or MEM_Static).\n  */\n  if( xDel==SQLITE_TRANSIENT ){\n    int nAlloc = nByte;\n    if( flags&MEM_Term ){\n      nAlloc += (enc==SQLITE_UTF8?1:2);\n    }\n    if( nByte>iLimit ){\n      return SQLITE_TOOBIG;\n    }\n    testcase( nAlloc==0 );\n    testcase( nAlloc==31 );\n    testcase( nAlloc==32 );\n    if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(pMem->z, z, nAlloc);\n  }else if( xDel==SQLITE_DYNAMIC ){\n    sqlite3VdbeMemRelease(pMem);\n    pMem->zMalloc = pMem->z = (char *)z;\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }else{\n    sqlite3VdbeMemRelease(pMem);\n    pMem->z = (char *)z;\n    pMem->xDel = xDel;\n    flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);\n  }\n\n  pMem->n = nByte;\n  pMem->flags = flags;\n  pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( nByte>iLimit ){\n    return SQLITE_TOOBIG;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Move data out of a btree key or data field and into a Mem structure.\n** The data is payload from the entry that pCur is currently pointing\n** to.  offset and amt determine what portion of the data or key to retrieve.\n** The result is written into the pMem element.\n**\n** The pMem object must have been initialized.  This routine will use\n** pMem->zMalloc to hold the content from the btree, if possible.  New\n** pMem->zMalloc space will be allocated if necessary.  The calling routine\n** is responsible for making sure that the pMem object is eventually\n** destroyed.\n**\n** If this routine fails for any reason (malloc returns NULL or unable\n** to read from the disk) then the pMem is left in an inconsistent state.\n*/\nstatic SQLITE_NOINLINE int vdbeMemFromBtreeResize(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  int rc;\n  pMem->flags = MEM_Null;\n  if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){\n    rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);\n    if( rc==SQLITE_OK ){\n      pMem->z[amt] = 0;   /* Overrun area used when reading malformed records */\n      pMem->flags = MEM_Blob;\n      pMem->n = (int)amt;\n    }else{\n      sqlite3VdbeMemRelease(pMem);\n    }\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeMemFromBtree(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  char *zData;        /* Data from the btree layer */\n  u32 available = 0;  /* Number of bytes available on the local btree page */\n  int rc = SQLITE_OK; /* Return code */\n\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  assert( !VdbeMemDynamic(pMem) );\n\n  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() \n  ** that both the BtShared and database handle mutexes are held. */\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);\n  assert( zData!=0 );\n\n  if( offset+amt<=available ){\n    pMem->z = &zData[offset];\n    pMem->flags = MEM_Blob|MEM_Ephem;\n    pMem->n = (int)amt;\n  }else{\n    rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);\n  }\n\n  return rc;\n}\n\n/*\n** The pVal argument is known to be a value other than NULL.\n** Convert it into a string with encoding enc and return a pointer\n** to a zero-terminated version of that string.\n*/\nstatic SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 enc){\n  assert( pVal!=0 );\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( (pVal->flags & MEM_RowSet)==0 );\n  assert( (pVal->flags & (MEM_Null))==0 );\n  if( pVal->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(pVal) ) return 0;\n    pVal->flags |= MEM_Str;\n    if( pVal->enc != (enc & ~SQLITE_UTF16_ALIGNED) ){\n      sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);\n    }\n    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&SQLITE_PTR_TO_INT(pVal->z)) ){\n      assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );\n      if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){\n        return 0;\n      }\n    }\n    sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */\n  }else{\n    sqlite3VdbeMemStringify(pVal, enc, 0);\n    assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );\n  }\n  assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0\n              || pVal->db->mallocFailed );\n  if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){\n    return pVal->z;\n  }else{\n    return 0;\n  }\n}\n\n/* This function is only available internally, it is not part of the\n** external API. It works in a similar way to sqlite3_value_text(),\n** except the data returned is in the encoding specified by the second\n** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or\n** SQLITE_UTF8.\n**\n** (2006-02-16:)  The enc value can be or-ed with SQLITE_UTF16_ALIGNED.\n** If that is the case, then the result must be aligned on an even byte\n** boundary.\n*/\nSQLITE_PRIVATE const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){\n  if( !pVal ) return 0;\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( (pVal->flags & MEM_RowSet)==0 );\n  if( (pVal->flags&(MEM_Str|MEM_Term))==(MEM_Str|MEM_Term) && pVal->enc==enc ){\n    return pVal->z;\n  }\n  if( pVal->flags&MEM_Null ){\n    return 0;\n  }\n  return valueToText(pVal, enc);\n}\n\n/*\n** Create a new sqlite3_value object.\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *db){\n  Mem *p = sqlite3DbMallocZero(db, sizeof(*p));\n  if( p ){\n    p->flags = MEM_Null;\n    p->db = db;\n  }\n  return p;\n}\n\n/*\n** Context object passed by sqlite3Stat4ProbeSetValue() through to \n** valueNew(). See comments above valueNew() for details.\n*/\nstruct ValueNewStat4Ctx {\n  Parse *pParse;\n  Index *pIdx;\n  UnpackedRecord **ppRec;\n  int iVal;\n};\n\n/*\n** Allocate and return a pointer to a new sqlite3_value object. If\n** the second argument to this function is NULL, the object is allocated\n** by calling sqlite3ValueNew().\n**\n** Otherwise, if the second argument is non-zero, then this function is \n** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not\n** already been allocated, allocate the UnpackedRecord structure that \n** that function will return to its caller here. Then return a pointer to\n** an sqlite3_value within the UnpackedRecord.a[] array.\n*/\nstatic sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( p ){\n    UnpackedRecord *pRec = p->ppRec[0];\n\n    if( pRec==0 ){\n      Index *pIdx = p->pIdx;      /* Index being probed */\n      int nByte;                  /* Bytes of space to allocate */\n      int i;                      /* Counter variable */\n      int nCol = pIdx->nColumn;   /* Number of index columns including rowid */\n  \n      nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));\n      pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);\n      if( pRec ){\n        pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);\n        if( pRec->pKeyInfo ){\n          assert( pRec->pKeyInfo->nAllField==nCol );\n          assert( pRec->pKeyInfo->enc==ENC(db) );\n          pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));\n          for(i=0; i<nCol; i++){\n            pRec->aMem[i].flags = MEM_Null;\n            pRec->aMem[i].db = db;\n          }\n        }else{\n          sqlite3DbFreeNN(db, pRec);\n          pRec = 0;\n        }\n      }\n      if( pRec==0 ) return 0;\n      p->ppRec[0] = pRec;\n    }\n  \n    pRec->nField = p->iVal+1;\n    return &pRec->aMem[p->iVal];\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n  return sqlite3ValueNew(db);\n}\n\n/*\n** The expression object indicated by the second argument is guaranteed\n** to be a scalar SQL function. If\n**\n**   * all function arguments are SQL literals,\n**   * one of the SQLITE_FUNC_CONSTANT or _SLOCHNG function flags is set, and\n**   * the SQLITE_FUNC_NEEDCOLL function flag is not set,\n**\n** then this routine attempts to invoke the SQL function. Assuming no\n** error occurs, output parameter (*ppVal) is set to point to a value \n** object containing the result before returning SQLITE_OK.\n**\n** Affinity aff is applied to the result of the function before returning.\n** If the result is a text value, the sqlite3_value object uses encoding \n** enc.\n**\n** If the conditions above are not met, this function returns SQLITE_OK\n** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to\n** NULL and an SQLite error code returned.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic int valueFromFunction(\n  sqlite3 *db,                    /* The database connection */\n  Expr *p,                        /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 aff,                         /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  sqlite3_context ctx;            /* Context object for function invocation */\n  sqlite3_value **apVal = 0;      /* Function arguments */\n  int nVal = 0;                   /* Size of apVal[] array */\n  FuncDef *pFunc = 0;             /* Function definition */\n  sqlite3_value *pVal = 0;        /* New value */\n  int rc = SQLITE_OK;             /* Return code */\n  ExprList *pList = 0;            /* Function arguments */\n  int i;                          /* Iterator variable */\n\n  assert( pCtx!=0 );\n  assert( (p->flags & EP_TokenOnly)==0 );\n  pList = p->x.pList;\n  if( pList ) nVal = pList->nExpr;\n  pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);\n  assert( pFunc );\n  if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 \n   || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)\n  ){\n    return SQLITE_OK;\n  }\n\n  if( pList ){\n    apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);\n    if( apVal==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto value_from_function_out;\n    }\n    for(i=0; i<nVal; i++){\n      rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);\n      if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;\n    }\n  }\n\n  pVal = valueNew(db, pCtx);\n  if( pVal==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto value_from_function_out;\n  }\n\n  assert( pCtx->pParse->rc==SQLITE_OK );\n  memset(&ctx, 0, sizeof(ctx));\n  ctx.pOut = pVal;\n  ctx.pFunc = pFunc;\n  pFunc->xSFunc(&ctx, nVal, apVal);\n  if( ctx.isError ){\n    rc = ctx.isError;\n    sqlite3ErrorMsg(pCtx->pParse, \"%s\", sqlite3_value_text(pVal));\n  }else{\n    sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);\n    assert( rc==SQLITE_OK );\n    rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){\n      rc = SQLITE_TOOBIG;\n      pCtx->pParse->nErr++;\n    }\n  }\n  pCtx->pParse->rc = rc;\n\n value_from_function_out:\n  if( rc!=SQLITE_OK ){\n    pVal = 0;\n  }\n  if( apVal ){\n    for(i=0; i<nVal; i++){\n      sqlite3ValueFree(apVal[i]);\n    }\n    sqlite3DbFreeNN(db, apVal);\n  }\n\n  *ppVal = pVal;\n  return rc;\n}\n#else\n# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n\n/*\n** Extract a value from the supplied expression in the manner described\n** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object\n** using valueNew().\n**\n** If pCtx is NULL and an error occurs after the sqlite3_value object\n** has been allocated, it is freed before returning. Or, if pCtx is not\n** NULL, it is assumed that the caller will free any allocated object\n** in all cases.\n*/\nstatic int valueFromExpr(\n  sqlite3 *db,                    /* The database connection */\n  Expr *pExpr,                    /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  int op;\n  char *zVal = 0;\n  sqlite3_value *pVal = 0;\n  int negInt = 1;\n  const char *zNeg = \"\";\n  int rc = SQLITE_OK;\n\n  assert( pExpr!=0 );\n  while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;\n  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;\n\n  /* Compressed expressions only appear when parsing the DEFAULT clause\n  ** on a table column definition, and hence only when pCtx==0.  This\n  ** check ensures that an EP_TokenOnly expression is never passed down\n  ** into valueFromFunction(). */\n  assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );\n\n  if( op==TK_CAST ){\n    u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);\n    rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);\n    testcase( rc!=SQLITE_OK );\n    if( *ppVal ){\n      sqlite3VdbeMemCast(*ppVal, aff, SQLITE_UTF8);\n      sqlite3ValueApplyAffinity(*ppVal, affinity, SQLITE_UTF8);\n    }\n    return rc;\n  }\n\n  /* Handle negative integers in a single step.  This is needed in the\n  ** case when the value is -9223372036854775808.\n  */\n  if( op==TK_UMINUS\n   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){\n    pExpr = pExpr->pLeft;\n    op = pExpr->op;\n    negInt = -1;\n    zNeg = \"-\";\n  }\n\n  if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    if( ExprHasProperty(pExpr, EP_IntValue) ){\n      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);\n    }else{\n      zVal = sqlite3MPrintf(db, \"%s%s\", zNeg, pExpr->u.zToken);\n      if( zVal==0 ) goto no_mem;\n      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);\n    }\n    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){\n      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);\n    }else{\n      sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);\n    }\n    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;\n    if( enc!=SQLITE_UTF8 ){\n      rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    }\n  }else if( op==TK_UMINUS ) {\n    /* This branch happens for multiple negative signs.  Ex: -(-5) */\n    if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx) \n     && pVal!=0\n    ){\n      sqlite3VdbeMemNumerify(pVal);\n      if( pVal->flags & MEM_Real ){\n        pVal->u.r = -pVal->u.r;\n      }else if( pVal->u.i==SMALLEST_INT64 ){\n        pVal->u.r = -(double)SMALLEST_INT64;\n        MemSetTypeFlag(pVal, MEM_Real);\n      }else{\n        pVal->u.i = -pVal->u.i;\n      }\n      sqlite3ValueApplyAffinity(pVal, affinity, enc);\n    }\n  }else if( op==TK_NULL ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    sqlite3VdbeMemNumerify(pVal);\n  }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n  else if( op==TK_BLOB ){\n    int nVal;\n    assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n    assert( pExpr->u.zToken[1]=='\\'' );\n    pVal = valueNew(db, pCtx);\n    if( !pVal ) goto no_mem;\n    zVal = &pExpr->u.zToken[2];\n    nVal = sqlite3Strlen30(zVal)-1;\n    assert( zVal[nVal]=='\\'' );\n    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,\n                         0, SQLITE_DYNAMIC);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( op==TK_FUNCTION && pCtx!=0 ){\n    rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);\n  }\n#endif\n\n  *ppVal = pVal;\n  return rc;\n\nno_mem:\n  sqlite3OomFault(db);\n  sqlite3DbFree(db, zVal);\n  assert( *ppVal==0 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx==0 ) sqlite3ValueFree(pVal);\n#else\n  assert( pCtx==0 ); sqlite3ValueFree(pVal);\n#endif\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** Create a new sqlite3_value object, containing the value of pExpr.\n**\n** This only works for very simple expressions that consist of one constant\n** token (i.e. \"5\", \"5.1\", \"'a string'\"). If the expression can\n** be converted directly into a value, then the value is allocated and\n** a pointer written to *ppVal. The caller is responsible for deallocating\n** the value by passing it to sqlite3ValueFree() later on. If the expression\n** cannot be converted to a value, then *ppVal is set to NULL.\n*/\nSQLITE_PRIVATE int sqlite3ValueFromExpr(\n  sqlite3 *db,              /* The database connection */\n  Expr *pExpr,              /* The expression to evaluate */\n  u8 enc,                   /* Encoding to use */\n  u8 affinity,              /* Affinity to use */\n  sqlite3_value **ppVal     /* Write the new value here */\n){\n  return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** The implementation of the sqlite_record() function. This function accepts\n** a single argument of any type. The return value is a formatted database \n** record (a blob) containing the argument value.\n**\n** This is used to convert the value stored in the 'sample' column of the\n** sqlite_stat3 table to the record format SQLite uses internally.\n*/\nstatic void recordFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const int file_format = 1;\n  u32 iSerial;                    /* Serial type */\n  int nSerial;                    /* Bytes of space for iSerial as varint */\n  u32 nVal;                       /* Bytes of space required for argv[0] */\n  int nRet;\n  sqlite3 *db;\n  u8 *aRet;\n\n  UNUSED_PARAMETER( argc );\n  iSerial = sqlite3VdbeSerialType(argv[0], file_format, &nVal);\n  nSerial = sqlite3VarintLen(iSerial);\n  db = sqlite3_context_db_handle(context);\n\n  nRet = 1 + nSerial + nVal;\n  aRet = sqlite3DbMallocRawNN(db, nRet);\n  if( aRet==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    aRet[0] = nSerial+1;\n    putVarint32(&aRet[1], iSerial);\n    sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);\n    sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);\n    sqlite3DbFreeNN(db, aRet);\n  }\n}\n\n/*\n** Register built-in functions used to help read ANALYZE data.\n*/\nSQLITE_PRIVATE void sqlite3AnalyzeFunctions(void){\n  static FuncDef aAnalyzeTableFuncs[] = {\n    FUNCTION(sqlite_record,   1, 0, 0, recordFunc),\n  };\n  sqlite3InsertBuiltinFuncs(aAnalyzeTableFuncs, ArraySize(aAnalyzeTableFuncs));\n}\n\n/*\n** Attempt to extract a value from pExpr and use it to construct *ppVal.\n**\n** If pAlloc is not NULL, then an UnpackedRecord object is created for\n** pAlloc if one does not exist and the new value is added to the\n** UnpackedRecord object.\n**\n** A value is extracted in the following cases:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The expression is a literal value.\n**\n** On success, *ppVal is made to point to the extracted value.  The caller\n** is responsible for ensuring that the value is eventually freed.\n*/\nstatic int stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  struct ValueNewStat4Ctx *pAlloc,/* How to allocate space.  Or NULL */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  int rc = SQLITE_OK;\n  sqlite3_value *pVal = 0;\n  sqlite3 *db = pParse->db;\n\n  /* Skip over any TK_COLLATE nodes */\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n\n  assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );\n  if( !pExpr ){\n    pVal = valueNew(db, pAlloc);\n    if( pVal ){\n      sqlite3VdbeMemSetNull((Mem*)pVal);\n    }\n  }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *v;\n    int iBindVar = pExpr->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);\n    if( (v = pParse->pReprepare)!=0 ){\n      pVal = valueNew(db, pAlloc);\n      if( pVal ){\n        rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);\n        sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));\n        pVal->db = pParse->db;\n      }\n    }\n  }else{\n    rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);\n  }\n\n  assert( pVal==0 || pVal->db==db );\n  *ppVal = pVal;\n  return rc;\n}\n\n/*\n** This function is used to allocate and populate UnpackedRecord \n** structures intended to be compared against sample index keys stored \n** in the sqlite_stat4 table.\n**\n** A single call to this function populates zero or more fields of the\n** record starting with field iVal (fields are numbered from left to\n** right starting with 0). A single field is populated if:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The sqlite3ValueFromExpr() function is able to extract a value \n**    from the expression (i.e. the expression is a literal value).\n**\n** Or, if pExpr is a TK_VECTOR, one field is populated for each of the\n** vector components that match either of the two latter criteria listed\n** above.\n**\n** Before any value is appended to the record, the affinity of the \n** corresponding column within index pIdx is applied to it. Before\n** this function returns, output parameter *pnExtract is set to the\n** number of values appended to the record.\n**\n** When this function is called, *ppRec must either point to an object\n** allocated by an earlier call to this function, or must be NULL. If it\n** is NULL and a value can be successfully extracted, a new UnpackedRecord\n** is allocated (and *ppRec set to point to it) before returning.\n**\n** Unless an error is encountered, SQLITE_OK is returned. It is not an\n** error if a value cannot be extracted from pExpr. If an error does\n** occur, an SQLite error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(\n  Parse *pParse,                  /* Parse context */\n  Index *pIdx,                    /* Index being probed */\n  UnpackedRecord **ppRec,         /* IN/OUT: Probe record */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  int nElem,                      /* Maximum number of values to append */\n  int iVal,                       /* Array element to populate */\n  int *pnExtract                  /* OUT: Values appended to the record */\n){\n  int rc = SQLITE_OK;\n  int nExtract = 0;\n\n  if( pExpr==0 || pExpr->op!=TK_SELECT ){\n    int i;\n    struct ValueNewStat4Ctx alloc;\n\n    alloc.pParse = pParse;\n    alloc.pIdx = pIdx;\n    alloc.ppRec = ppRec;\n\n    for(i=0; i<nElem; i++){\n      sqlite3_value *pVal = 0;\n      Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);\n      u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);\n      alloc.iVal = iVal+i;\n      rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);\n      if( !pVal ) break;\n      nExtract++;\n    }\n  }\n\n  *pnExtract = nExtract;\n  return rc;\n}\n\n/*\n** Attempt to extract a value from expression pExpr using the methods\n** as described for sqlite3Stat4ProbeSetValue() above. \n**\n** If successful, set *ppVal to point to a new value object and return \n** SQLITE_OK. If no value can be extracted, but no other error occurs\n** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error\n** does occur, return an SQLite error code. The final value of *ppVal\n** is undefined in this case.\n*/\nSQLITE_PRIVATE int sqlite3Stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal);\n}\n\n/*\n** Extract the iCol-th column from the nRec-byte record in pRec.  Write\n** the column value into *ppVal.  If *ppVal is initially NULL then a new\n** sqlite3_value object is allocated.\n**\n** If *ppVal is initially NULL then the caller is responsible for \n** ensuring that the value written into *ppVal is eventually freed.\n*/\nSQLITE_PRIVATE int sqlite3Stat4Column(\n  sqlite3 *db,                    /* Database handle */\n  const void *pRec,               /* Pointer to buffer containing record */\n  int nRec,                       /* Size of buffer pRec in bytes */\n  int iCol,                       /* Column to extract */\n  sqlite3_value **ppVal           /* OUT: Extracted value */\n){\n  u32 t;                          /* a column type code */\n  int nHdr;                       /* Size of the header in the record */\n  int iHdr;                       /* Next unread header byte */\n  int iField;                     /* Next unread data byte */\n  int szField;                    /* Size of the current data field */\n  int i;                          /* Column index */\n  u8 *a = (u8*)pRec;              /* Typecast byte array */\n  Mem *pMem = *ppVal;             /* Write result into this Mem object */\n\n  assert( iCol>0 );\n  iHdr = getVarint32(a, nHdr);\n  if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;\n  iField = nHdr;\n  for(i=0; i<=iCol; i++){\n    iHdr += getVarint32(&a[iHdr], t);\n    testcase( iHdr==nHdr );\n    testcase( iHdr==nHdr+1 );\n    if( iHdr>nHdr ) return SQLITE_CORRUPT_BKPT;\n    szField = sqlite3VdbeSerialTypeLen(t);\n    iField += szField;\n  }\n  testcase( iField==nRec );\n  testcase( iField==nRec+1 );\n  if( iField>nRec ) return SQLITE_CORRUPT_BKPT;\n  if( pMem==0 ){\n    pMem = *ppVal = sqlite3ValueNew(db);\n    if( pMem==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);\n  pMem->enc = ENC(db);\n  return SQLITE_OK;\n}\n\n/*\n** Unless it is NULL, the argument must be an UnpackedRecord object returned\n** by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes\n** the object.\n*/\nSQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){\n  if( pRec ){\n    int i;\n    int nCol = pRec->pKeyInfo->nAllField;\n    Mem *aMem = pRec->aMem;\n    sqlite3 *db = aMem[0].db;\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeMemRelease(&aMem[i]);\n    }\n    sqlite3KeyInfoUnref(pRec->pKeyInfo);\n    sqlite3DbFreeNN(db, pRec);\n  }\n}\n#endif /* ifdef SQLITE_ENABLE_STAT4 */\n\n/*\n** Change the string value of an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueSetStr(\n  sqlite3_value *v,     /* Value to be set */\n  int n,                /* Length of string z */\n  const void *z,        /* Text of the new string */\n  u8 enc,               /* Encoding to use */\n  void (*xDel)(void*)   /* Destructor for the string */\n){\n  if( v ) sqlite3VdbeMemSetStr((Mem *)v, z, n, enc, xDel);\n}\n\n/*\n** Free an sqlite3_value object\n*/\nSQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){\n  if( !v ) return;\n  sqlite3VdbeMemRelease((Mem *)v);\n  sqlite3DbFreeNN(((Mem*)v)->db, v);\n}\n\n/*\n** The sqlite3ValueBytes() routine returns the number of bytes in the\n** sqlite3_value object assuming that it uses the encoding \"enc\".\n** The valueBytes() routine is a helper function.\n*/\nstatic SQLITE_NOINLINE int valueBytes(sqlite3_value *pVal, u8 enc){\n  return valueToText(pVal, enc)!=0 ? pVal->n : 0;\n}\nSQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){\n  Mem *p = (Mem*)pVal;\n  assert( (p->flags & MEM_Null)==0 || (p->flags & (MEM_Str|MEM_Blob))==0 );\n  if( (p->flags & MEM_Str)!=0 && pVal->enc==enc ){\n    return p->n;\n  }\n  if( (p->flags & MEM_Blob)!=0 ){\n    if( p->flags & MEM_Zero ){\n      return p->n + p->u.nZero;\n    }else{\n      return p->n;\n    }\n  }\n  if( p->flags & MEM_Null ) return 0;\n  return valueBytes(pVal, enc);\n}\n\n/************** End of vdbemem.c *********************************************/\n/************** Begin file vdbeaux.c *****************************************/\n/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used for creating, destroying, and populating\n** a VDBE (or an \"sqlite3_stmt\" as it is known to the outside world.) \n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Create a new virtual database engine.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  Vdbe *p;\n  p = sqlite3DbMallocRawNN(db, sizeof(Vdbe) );\n  if( p==0 ) return 0;\n  memset(&p->aOp, 0, sizeof(Vdbe)-offsetof(Vdbe,aOp));\n  p->db = db;\n  if( db->pVdbe ){\n    db->pVdbe->pPrev = p;\n  }\n  p->pNext = db->pVdbe;\n  p->pPrev = 0;\n  db->pVdbe = p;\n  p->magic = VDBE_MAGIC_INIT;\n  p->pParse = pParse;\n  pParse->pVdbe = p;\n  assert( pParse->aLabel==0 );\n  assert( pParse->nLabel==0 );\n  assert( pParse->nOpAlloc==0 );\n  assert( pParse->szOpAlloc==0 );\n  sqlite3VdbeAddOp2(p, OP_Init, 0, 1);\n  return p;\n}\n\n/*\n** Change the error string stored in Vdbe.zErrMsg\n*/\nSQLITE_PRIVATE void sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  sqlite3DbFree(p->db, p->zErrMsg);\n  va_start(ap, zFormat);\n  p->zErrMsg = sqlite3VMPrintf(p->db, zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Remember the SQL string for a prepared statement.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){\n  if( p==0 ) return;\n  p->prepFlags = prepFlags;\n  if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){\n    p->expmask = 0;\n  }\n  assert( p->zSql==0 );\n  p->zSql = sqlite3DbStrNDup(p->db, z, n);\n}\n\n/*\n** Swap all content between two VDBE structures.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){\n  Vdbe tmp, *pTmp;\n  char *zTmp;\n  assert( pA->db==pB->db );\n  tmp = *pA;\n  *pA = *pB;\n  *pB = tmp;\n  pTmp = pA->pNext;\n  pA->pNext = pB->pNext;\n  pB->pNext = pTmp;\n  pTmp = pA->pPrev;\n  pA->pPrev = pB->pPrev;\n  pB->pPrev = pTmp;\n  zTmp = pA->zSql;\n  pA->zSql = pB->zSql;\n  pB->zSql = zTmp;\n  pB->expmask = pA->expmask;\n  pB->prepFlags = pA->prepFlags;\n  memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));\n  pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;\n}\n\n/*\n** Resize the Vdbe.aOp array so that it is at least nOp elements larger \n** than its current size. nOp is guaranteed to be less than or equal\n** to 1024/sizeof(Op).\n**\n** If an out-of-memory error occurs while resizing the array, return\n** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain \n** unchanged (this is so that any opcodes already allocated can be \n** correctly deallocated along with the rest of the Vdbe).\n*/\nstatic int growOpArray(Vdbe *v, int nOp){\n  VdbeOp *pNew;\n  Parse *p = v->pParse;\n\n  /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force\n  ** more frequent reallocs and hence provide more opportunities for \n  ** simulated OOM faults.  SQLITE_TEST_REALLOC_STRESS is generally used\n  ** during testing only.  With SQLITE_TEST_REALLOC_STRESS grow the op array\n  ** by the minimum* amount required until the size reaches 512.  Normal\n  ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current\n  ** size of the op array or add 1KB of space, whichever is smaller. */\n#ifdef SQLITE_TEST_REALLOC_STRESS\n  int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);\n#else\n  int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));\n  UNUSED_PARAMETER(nOp);\n#endif\n\n  /* Ensure that the size of a VDBE does not grow too large */\n  if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){\n    sqlite3OomFault(p->db);\n    return SQLITE_NOMEM;\n  }\n\n  assert( nOp<=(1024/sizeof(Op)) );\n  assert( nNew>=(p->nOpAlloc+nOp) );\n  pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));\n  if( pNew ){\n    p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);\n    p->nOpAlloc = p->szOpAlloc/sizeof(Op);\n    v->aOp = pNew;\n  }\n  return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);\n}\n\n#ifdef SQLITE_DEBUG\n/* This routine is just a convenient place to set a breakpoint that will\n** fire after each opcode is inserted and displayed using\n** \"PRAGMA vdbe_addoptrace=on\".\n*/\nstatic void test_addop_breakpoint(void){\n  static int n = 0;\n  n++;\n}\n#endif\n\n/*\n** Add a new instruction to the list of instructions current in the\n** VDBE.  Return the address of the new instruction.\n**\n** Parameters:\n**\n**    p               Pointer to the VDBE\n**\n**    op              The opcode for this instruction\n**\n**    p1, p2, p3      Operands\n**\n** Use the sqlite3VdbeResolveLabel() function to fix an address and\n** the sqlite3VdbeChangeP4() function to change the value of the P4\n** operand.\n*/\nstatic SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  assert( p->pParse->nOpAlloc<=p->nOp );\n  if( growOpArray(p, 1) ) return 1;\n  assert( p->pParse->nOpAlloc>p->nOp );\n  return sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  int i;\n  VdbeOp *pOp;\n\n  i = p->nOp;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( op>=0 && op<0xff );\n  if( p->pParse->nOpAlloc<=i ){\n    return growOp3(p, op, p1, p2, p3);\n  }\n  p->nOp++;\n  pOp = &p->aOp[i];\n  pOp->opcode = (u8)op;\n  pOp->p5 = 0;\n  pOp->p1 = p1;\n  pOp->p2 = p2;\n  pOp->p3 = p3;\n  pOp->p4.p = 0;\n  pOp->p4type = P4_NOTUSED;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  pOp->zComment = 0;\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->db->flags & SQLITE_VdbeAddopTrace ){\n    int jj, kk;\n    Parse *pParse = p->pParse;\n    for(jj=kk=0; jj<pParse->nColCache; jj++){\n      struct yColCache *x = pParse->aColCache + jj;\n      printf(\" r[%d]={%d:%d}\", x->iReg, x->iTable, x->iColumn);\n      kk++;\n    }\n    if( kk ) printf(\"\\n\");\n    sqlite3VdbePrintOp(0, i, &p->aOp[i]);\n    test_addop_breakpoint();\n  }\n#endif\n#ifdef VDBE_PROFILE\n  pOp->cycles = 0;\n  pOp->cnt = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  pOp->iSrcLine = 0;\n#endif\n  return i;\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe *p, int op){\n  return sqlite3VdbeAddOp3(p, op, 0, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){\n  return sqlite3VdbeAddOp3(p, op, p1, 0, 0);\n}\nSQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){\n  return sqlite3VdbeAddOp3(p, op, p1, p2, 0);\n}\n\n/* Generate code for an unconditional jump to instruction iDest\n*/\nSQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe *p, int iDest){\n  return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0);\n}\n\n/* Generate code to cause the string zStr to be loaded into\n** register iDest\n*/\nSQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){\n  return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0);\n}\n\n/*\n** Generate code that initializes multiple registers to string or integer\n** constants.  The registers begin with iDest and increase consecutively.\n** One register is initialized for each characgter in zTypes[].  For each\n** \"s\" character in zTypes[], the register is a string if the argument is\n** not NULL, or OP_Null if the value is a null pointer.  For each \"i\" character\n** in zTypes[], the register is initialized to an integer.\n**\n** If the input string does not end with \"X\" then an OP_ResultRow instruction\n** is generated for the values inserted.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){\n  va_list ap;\n  int i;\n  char c;\n  va_start(ap, zTypes);\n  for(i=0; (c = zTypes[i])!=0; i++){\n    if( c=='s' ){\n      const char *z = va_arg(ap, const char*);\n      sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest+i, 0, z, 0);\n    }else if( c=='i' ){\n      sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest+i);\n    }else{\n      goto skip_op_resultrow;\n    }\n  }\n  sqlite3VdbeAddOp2(p, OP_ResultRow, iDest, i);\nskip_op_resultrow:\n  va_end(ap);\n}\n\n/*\n** Add an opcode that includes the p4 value as a pointer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const char *zP4,    /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  sqlite3VdbeChangeP4(p, addr, zP4, p4type);\n  return addr;\n}\n\n/*\n** Add an opcode that includes the p4 value with a P4_INT64 or\n** P4_REAL type.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const u8 *zP4,      /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  char *p4copy = sqlite3DbMallocRawNN(sqlite3VdbeDb(p), 8);\n  if( p4copy ) memcpy(p4copy, zP4, 8);\n  return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);\n}\n\n/*\n** Add an OP_ParseSchema opcode.  This routine is broken out from\n** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees\n** as having been used.\n**\n** The zWhere string must have been obtained from sqlite3_malloc().\n** This routine will take ownership of the allocated memory.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){\n  int j;\n  sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);\n  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);\n}\n\n/*\n** Add an opcode that includes the p4 value as an integer.\n*/\nSQLITE_PRIVATE int sqlite3VdbeAddOp4Int(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  int p4              /* The P4 operand as an integer */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  if( p->db->mallocFailed==0 ){\n    VdbeOp *pOp = &p->aOp[addr];\n    pOp->p4type = P4_INT32;\n    pOp->p4.i = p4;\n  }\n  return addr;\n}\n\n/* Insert the end of a co-routine\n*/\nSQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){\n  sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);\n\n  /* Clear the temporary register cache, thereby ensuring that each\n  ** co-routine has its own independent set of registers, because co-routines\n  ** might expect their registers to be preserved across an OP_Yield, and\n  ** that could cause problems if two or more co-routines are using the same\n  ** temporary register.\n  */\n  v->pParse->nTempReg = 0;\n  v->pParse->nRangeReg = 0;\n}\n\n/*\n** Create a new symbolic label for an instruction that has yet to be\n** coded.  The symbolic label is really just a negative number.  The\n** label can be used as the P2 value of an operation.  Later, when\n** the label is resolved to a specific address, the VDBE will scan\n** through its operation list and change all values of P2 which match\n** the label into the resolved address.\n**\n** The VDBE knows that a P2 value is a label because labels are\n** always negative and P2 values are suppose to be non-negative.\n** Hence, a negative P2 value is a label that has yet to be resolved.\n**\n** Zero is returned if a malloc() fails.\n*/\nSQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe *v){\n  Parse *p = v->pParse;\n  int i = p->nLabel++;\n  assert( v->magic==VDBE_MAGIC_INIT );\n  if( (i & (i-1))==0 ){\n    p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel, \n                                       (i*2+1)*sizeof(p->aLabel[0]));\n  }\n  if( p->aLabel ){\n    p->aLabel[i] = -1;\n  }\n  return ADDR(i);\n}\n\n/*\n** Resolve label \"x\" to be the address of the next instruction to\n** be inserted.  The parameter \"x\" must have been obtained from\n** a prior call to sqlite3VdbeMakeLabel().\n*/\nSQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){\n  Parse *p = v->pParse;\n  int j = ADDR(x);\n  assert( v->magic==VDBE_MAGIC_INIT );\n  assert( j<p->nLabel );\n  assert( j>=0 );\n  if( p->aLabel ){\n    p->aLabel[j] = v->nOp;\n  }\n}\n\n/*\n** Mark the VDBE as one that can only be run one time.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){\n  p->runOnlyOnce = 1;\n}\n\n/*\n** Mark the VDBE as one that can only be run multiple times.\n*/\nSQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe *p){\n  p->runOnlyOnce = 0;\n}\n\n#ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */\n\n/*\n** The following type and function are used to iterate through all opcodes\n** in a Vdbe main program and each of the sub-programs (triggers) it may \n** invoke directly or indirectly. It should be used as follows:\n**\n**   Op *pOp;\n**   VdbeOpIter sIter;\n**\n**   memset(&sIter, 0, sizeof(sIter));\n**   sIter.v = v;                            // v is of type Vdbe* \n**   while( (pOp = opIterNext(&sIter)) ){\n**     // Do something with pOp\n**   }\n**   sqlite3DbFree(v->db, sIter.apSub);\n** \n*/\ntypedef struct VdbeOpIter VdbeOpIter;\nstruct VdbeOpIter {\n  Vdbe *v;                   /* Vdbe to iterate through the opcodes of */\n  SubProgram **apSub;        /* Array of subprograms */\n  int nSub;                  /* Number of entries in apSub */\n  int iAddr;                 /* Address of next instruction to return */\n  int iSub;                  /* 0 = main program, 1 = first sub-program etc. */\n};\nstatic Op *opIterNext(VdbeOpIter *p){\n  Vdbe *v = p->v;\n  Op *pRet = 0;\n  Op *aOp;\n  int nOp;\n\n  if( p->iSub<=p->nSub ){\n\n    if( p->iSub==0 ){\n      aOp = v->aOp;\n      nOp = v->nOp;\n    }else{\n      aOp = p->apSub[p->iSub-1]->aOp;\n      nOp = p->apSub[p->iSub-1]->nOp;\n    }\n    assert( p->iAddr<nOp );\n\n    pRet = &aOp[p->iAddr];\n    p->iAddr++;\n    if( p->iAddr==nOp ){\n      p->iSub++;\n      p->iAddr = 0;\n    }\n  \n    if( pRet->p4type==P4_SUBPROGRAM ){\n      int nByte = (p->nSub+1)*sizeof(SubProgram*);\n      int j;\n      for(j=0; j<p->nSub; j++){\n        if( p->apSub[j]==pRet->p4.pProgram ) break;\n      }\n      if( j==p->nSub ){\n        p->apSub = sqlite3DbReallocOrFree(v->db, p->apSub, nByte);\n        if( !p->apSub ){\n          pRet = 0;\n        }else{\n          p->apSub[p->nSub++] = pRet->p4.pProgram;\n        }\n      }\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Check if the program stored in the VM associated with pParse may\n** throw an ABORT exception (causing the statement, but not entire transaction\n** to be rolled back). This condition is true if the main program or any\n** sub-programs contains any of the following:\n**\n**   *  OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_Destroy\n**   *  OP_VUpdate\n**   *  OP_VRename\n**   *  OP_FkCounter with P2==0 (immediate foreign key constraint)\n**   *  OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine \n**      (for CREATE TABLE AS SELECT ...)\n**\n** Then check that the value of Parse.mayAbort is true if an\n** ABORT may be thrown, or false otherwise. Return true if it does\n** match, or false otherwise. This function is intended to be used as\n** part of an assert statement in the compiler. Similar to:\n**\n**   assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );\n*/\nSQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){\n  int hasAbort = 0;\n  int hasFkCounter = 0;\n  int hasCreateTable = 0;\n  int hasInitCoroutine = 0;\n  Op *pOp;\n  VdbeOpIter sIter;\n  memset(&sIter, 0, sizeof(sIter));\n  sIter.v = v;\n\n  while( (pOp = opIterNext(&sIter))!=0 ){\n    int opcode = pOp->opcode;\n    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename \n     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) \n      && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))\n    ){\n      hasAbort = 1;\n      break;\n    }\n    if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;\n    if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){\n      hasFkCounter = 1;\n    }\n#endif\n  }\n  sqlite3DbFree(v->db, sIter.apSub);\n\n  /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.\n  ** If malloc failed, then the while() loop above may not have iterated\n  ** through all opcodes and hasAbort may be set incorrectly. Return\n  ** true for this case to prevent the assert() in the callers frame\n  ** from failing.  */\n  return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter\n              || (hasCreateTable && hasInitCoroutine) );\n}\n#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */\n\n/*\n** This routine is called after all opcodes have been inserted.  It loops\n** through all the opcodes and fixes up some details.\n**\n** (1) For each jump instruction with a negative P2 value (a label)\n**     resolve the P2 value to an actual address.\n**\n** (2) Compute the maximum number of arguments used by any SQL function\n**     and store that value in *pMaxFuncArgs.\n**\n** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately\n**     indicate what the prepared statement actually does.\n**\n** (4) Initialize the p4.xAdvance pointer on opcodes that use it.\n**\n** (5) Reclaim the memory allocated for storing labels.\n**\n** This routine will only function correctly if the mkopcodeh.tcl generator\n** script numbers the opcodes correctly.  Changes to this routine must be\n** coordinated with changes to mkopcodeh.tcl.\n*/\nstatic void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){\n  int nMaxArgs = *pMaxFuncArgs;\n  Op *pOp;\n  Parse *pParse = p->pParse;\n  int *aLabel = pParse->aLabel;\n  p->readOnly = 1;\n  p->bIsReader = 0;\n  pOp = &p->aOp[p->nOp-1];\n  while(1){\n\n    /* Only JUMP opcodes and the short list of special opcodes in the switch\n    ** below need to be considered.  The mkopcodeh.tcl generator script groups\n    ** all these opcodes together near the front of the opcode list.  Skip\n    ** any opcode that does not need processing by virtual of the fact that\n    ** it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization.\n    */\n    if( pOp->opcode<=SQLITE_MX_JUMP_OPCODE ){\n      /* NOTE: Be sure to update mkopcodeh.tcl when adding or removing\n      ** cases from this switch! */\n      switch( pOp->opcode ){\n        case OP_Transaction: {\n          if( pOp->p2!=0 ) p->readOnly = 0;\n          /* fall thru */\n        }\n        case OP_AutoCommit:\n        case OP_Savepoint: {\n          p->bIsReader = 1;\n          break;\n        }\n#ifndef SQLITE_OMIT_WAL\n        case OP_Checkpoint:\n#endif\n        case OP_Vacuum:\n        case OP_JournalMode: {\n          p->readOnly = 0;\n          p->bIsReader = 1;\n          break;\n        }\n        case OP_Next:\n        case OP_NextIfOpen:\n        case OP_SorterNext: {\n          pOp->p4.xAdvance = sqlite3BtreeNext;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n        case OP_Prev:\n        case OP_PrevIfOpen: {\n          pOp->p4.xAdvance = sqlite3BtreePrevious;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        case OP_VUpdate: {\n          if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;\n          break;\n        }\n        case OP_VFilter: {\n          int n;\n          assert( (pOp - p->aOp) >= 3 );\n          assert( pOp[-1].opcode==OP_Integer );\n          n = pOp[-1].p1;\n          if( n>nMaxArgs ) nMaxArgs = n;\n          /* Fall through into the default case */\n        }\n#endif\n        default: {\n          if( pOp->p2<0 ){\n            /* The mkopcodeh.tcl script has so arranged things that the only\n            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n            ** have non-negative values for P2. */\n            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );\n            assert( ADDR(pOp->p2)<pParse->nLabel );\n            pOp->p2 = aLabel[ADDR(pOp->p2)];\n          }\n          break;\n        }\n      }\n      /* The mkopcodeh.tcl script has so arranged things that the only\n      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n      ** have non-negative values for P2. */\n      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);\n    }\n    if( pOp==p->aOp ) break;\n    pOp--;\n  }\n  sqlite3DbFree(p->db, pParse->aLabel);\n  pParse->aLabel = 0;\n  pParse->nLabel = 0;\n  *pMaxFuncArgs = nMaxArgs;\n  assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );\n}\n\n/*\n** Return the address of the next instruction to be inserted.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){\n  assert( p->magic==VDBE_MAGIC_INIT );\n  return p->nOp;\n}\n\n/*\n** Verify that at least N opcode slots are available in p without\n** having to malloc for more space (except when compiled using\n** SQLITE_TEST_REALLOC_STRESS).  This interface is used during testing\n** to verify that certain calls to sqlite3VdbeAddOpList() can never\n** fail due to a OOM fault and hence that the return value from\n** sqlite3VdbeAddOpList() will always be non-NULL.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){\n  assert( p->nOp + N <= p->pParse->nOpAlloc );\n}\n#endif\n\n/*\n** Verify that the VM passed as the only argument does not contain\n** an OP_ResultRow opcode. Fail an assert() if it does. This is used\n** by code in pragma.c to ensure that the implementation of certain\n** pragmas comports with the flags specified in the mkpragmatab.tcl\n** script.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nSQLITE_PRIVATE void sqlite3VdbeVerifyNoResultRow(Vdbe *p){\n  int i;\n  for(i=0; i<p->nOp; i++){\n    assert( p->aOp[i].opcode!=OP_ResultRow );\n  }\n}\n#endif\n\n/*\n** This function returns a pointer to the array of opcodes associated with\n** the Vdbe passed as the first argument. It is the callers responsibility\n** to arrange for the returned array to be eventually freed using the \n** vdbeFreeOpArray() function.\n**\n** Before returning, *pnOp is set to the number of entries in the returned\n** array. Also, *pnMaxArg is set to the larger of its current value and \n** the number of entries in the Vdbe.apArg[] array required to execute the \n** returned program.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){\n  VdbeOp *aOp = p->aOp;\n  assert( aOp && !p->db->mallocFailed );\n\n  /* Check that sqlite3VdbeUsesBtree() was not called on this VM */\n  assert( DbMaskAllZero(p->btreeMask) );\n\n  resolveP2Values(p, pnMaxArg);\n  *pnOp = p->nOp;\n  p->aOp = 0;\n  return aOp;\n}\n\n/*\n** Add a whole list of operations to the operation stack.  Return a\n** pointer to the first operation inserted.\n**\n** Non-zero P2 arguments to jump instructions are automatically adjusted\n** so that the jump target is relative to the first operation inserted.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(\n  Vdbe *p,                     /* Add opcodes to the prepared statement */\n  int nOp,                     /* Number of opcodes to add */\n  VdbeOpList const *aOp,       /* The opcodes to be added */\n  int iLineno                  /* Source-file line number of first opcode */\n){\n  int i;\n  VdbeOp *pOut, *pFirst;\n  assert( nOp>0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){\n    return 0;\n  }\n  pFirst = pOut = &p->aOp[p->nOp];\n  for(i=0; i<nOp; i++, aOp++, pOut++){\n    pOut->opcode = aOp->opcode;\n    pOut->p1 = aOp->p1;\n    pOut->p2 = aOp->p2;\n    assert( aOp->p2>=0 );\n    if( (sqlite3OpcodeProperty[aOp->opcode] & OPFLG_JUMP)!=0 && aOp->p2>0 ){\n      pOut->p2 += p->nOp;\n    }\n    pOut->p3 = aOp->p3;\n    pOut->p4type = P4_NOTUSED;\n    pOut->p4.p = 0;\n    pOut->p5 = 0;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n    pOut->zComment = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n    pOut->iSrcLine = iLineno+i;\n#else\n    (void)iLineno;\n#endif\n#ifdef SQLITE_DEBUG\n    if( p->db->flags & SQLITE_VdbeAddopTrace ){\n      sqlite3VdbePrintOp(0, i+p->nOp, &p->aOp[i+p->nOp]);\n    }\n#endif\n  }\n  p->nOp += nOp;\n  return pFirst;\n}\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n/*\n** Add an entry to the array of counters managed by sqlite3_stmt_scanstatus().\n*/\nSQLITE_PRIVATE void sqlite3VdbeScanStatus(\n  Vdbe *p,                        /* VM to add scanstatus() to */\n  int addrExplain,                /* Address of OP_Explain (or 0) */\n  int addrLoop,                   /* Address of loop counter */ \n  int addrVisit,                  /* Address of rows visited counter */\n  LogEst nEst,                    /* Estimated number of output rows */\n  const char *zName               /* Name of table or index being scanned */\n){\n  int nByte = (p->nScan+1) * sizeof(ScanStatus);\n  ScanStatus *aNew;\n  aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);\n  if( aNew ){\n    ScanStatus *pNew = &aNew[p->nScan++];\n    pNew->addrExplain = addrExplain;\n    pNew->addrLoop = addrLoop;\n    pNew->addrVisit = addrVisit;\n    pNew->nEst = nEst;\n    pNew->zName = sqlite3DbStrDup(p->db, zName);\n    p->aScan = aNew;\n  }\n}\n#endif\n\n\n/*\n** Change the value of the opcode, or P1, P2, P3, or P5 operands\n** for a specific instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){\n  sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p1 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p2 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p3 = val;\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){\n  assert( p->nOp>0 || p->db->mallocFailed );\n  if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;\n}\n\n/*\n** Change the P2 operand of instruction addr so that it points to\n** the address of the next instruction to be coded.\n*/\nSQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){\n  sqlite3VdbeChangeP2(p, addr, p->nOp);\n}\n\n\n/*\n** If the input FuncDef structure is ephemeral, then free it.  If\n** the FuncDef is not ephermal, then do nothing.\n*/\nstatic void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){\n  if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){\n    sqlite3DbFreeNN(db, pDef);\n  }\n}\n\nstatic void vdbeFreeOpArray(sqlite3 *, Op *, int);\n\n/*\n** Delete a P4 value if necessary.\n*/\nstatic SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){\n  if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n  sqlite3DbFreeNN(db, p);\n}\nstatic SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){\n  freeEphemeralFunction(db, p->pFunc);\n sqlite3DbFreeNN(db, p);\n}\nstatic void freeP4(sqlite3 *db, int p4type, void *p4){\n  assert( db );\n  switch( p4type ){\n    case P4_FUNCCTX: {\n      freeP4FuncCtx(db, (sqlite3_context*)p4);\n      break;\n    }\n    case P4_REAL:\n    case P4_INT64:\n    case P4_DYNAMIC:\n    case P4_INTARRAY: {\n      sqlite3DbFree(db, p4);\n      break;\n    }\n    case P4_KEYINFO: {\n      if( db->pnBytesFreed==0 ) sqlite3KeyInfoUnref((KeyInfo*)p4);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      sqlite3ExprDelete(db, (Expr*)p4);\n      break;\n    }\n#endif\n    case P4_FUNCDEF: {\n      freeEphemeralFunction(db, (FuncDef*)p4);\n      break;\n    }\n    case P4_MEM: {\n      if( db->pnBytesFreed==0 ){\n        sqlite3ValueFree((sqlite3_value*)p4);\n      }else{\n        freeP4Mem(db, (Mem*)p4);\n      }\n      break;\n    }\n    case P4_VTAB : {\n      if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);\n      break;\n    }\n  }\n}\n\n/*\n** Free the space allocated for aOp and any p4 values allocated for the\n** opcodes contained within. If aOp is not NULL it is assumed to contain \n** nOp entries. \n*/\nstatic void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){\n  if( aOp ){\n    Op *pOp;\n    for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){\n      if( pOp->p4type <= P4_FREE_IF_LE ) freeP4(db, pOp->p4type, pOp->p4.p);\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n      sqlite3DbFree(db, pOp->zComment);\n#endif     \n    }\n    sqlite3DbFreeNN(db, aOp);\n  }\n}\n\n/*\n** Link the SubProgram object passed as the second argument into the linked\n** list at Vdbe.pSubProgram. This list is used to delete all sub-program\n** objects when the VM is no longer required.\n*/\nSQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){\n  p->pNext = pVdbe->pProgram;\n  pVdbe->pProgram = p;\n}\n\n/*\n** Change the opcode at addr into OP_Noop\n*/\nSQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe *p, int addr){\n  VdbeOp *pOp;\n  if( p->db->mallocFailed ) return 0;\n  assert( addr>=0 && addr<p->nOp );\n  pOp = &p->aOp[addr];\n  freeP4(p->db, pOp->p4type, pOp->p4.p);\n  pOp->p4type = P4_NOTUSED;\n  pOp->p4.z = 0;\n  pOp->opcode = OP_Noop;\n  return 1;\n}\n\n/*\n** If the last opcode is \"op\" and it is not a jump destination,\n** then remove it.  Return true if and only if an opcode was removed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){\n  if( p->nOp>0 && p->aOp[p->nOp-1].opcode==op ){\n    return sqlite3VdbeChangeToNoop(p, p->nOp-1);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Change the value of the P4 operand for a specific instruction.\n** This routine is useful when a large program is loaded from a\n** static array using sqlite3VdbeAddOpList but we want to make a\n** few minor changes to the program.\n**\n** If n>=0 then the P4 operand is dynamic, meaning that a copy of\n** the string is made into memory obtained from sqlite3_malloc().\n** A value of n==0 means copy bytes of zP4 up to and including the\n** first null byte.  If n>0 then copy n+1 bytes of zP4.\n** \n** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points\n** to a string or structure that is guaranteed to exist for the lifetime of\n** the Vdbe. In these cases we can just copy the pointer.\n**\n** If addr<0 then change P4 on the most recently inserted instruction.\n*/\nstatic void SQLITE_NOINLINE vdbeChangeP4Full(\n  Vdbe *p,\n  Op *pOp,\n  const char *zP4,\n  int n\n){\n  if( pOp->p4type ){\n    freeP4(p->db, pOp->p4type, pOp->p4.p);\n    pOp->p4type = 0;\n    pOp->p4.p = 0;\n  }\n  if( n<0 ){\n    sqlite3VdbeChangeP4(p, (int)(pOp - p->aOp), zP4, n);\n  }else{\n    if( n==0 ) n = sqlite3Strlen30(zP4);\n    pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);\n    pOp->p4type = P4_DYNAMIC;\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){\n  Op *pOp;\n  sqlite3 *db;\n  assert( p!=0 );\n  db = p->db;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( p->aOp!=0 || db->mallocFailed );\n  if( db->mallocFailed ){\n    if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4);\n    return;\n  }\n  assert( p->nOp>0 );\n  assert( addr<p->nOp );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  pOp = &p->aOp[addr];\n  if( n>=0 || pOp->p4type ){\n    vdbeChangeP4Full(p, pOp, zP4, n);\n    return;\n  }\n  if( n==P4_INT32 ){\n    /* Note: this cast is safe, because the origin data point was an int\n    ** that was cast to a (const char *). */\n    pOp->p4.i = SQLITE_PTR_TO_INT(zP4);\n    pOp->p4type = P4_INT32;\n  }else if( zP4!=0 ){\n    assert( n<0 );\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = (signed char)n;\n    if( n==P4_VTAB ) sqlite3VtabLock((VTable*)zP4);\n  }\n}\n\n/*\n** Change the P4 operand of the most recently coded instruction \n** to the value defined by the arguments.  This is a high-speed\n** version of sqlite3VdbeChangeP4().\n**\n** The P4 operand must not have been previously defined.  And the new\n** P4 must not be P4_INT32.  Use sqlite3VdbeChangeP4() in either of\n** those cases.\n*/\nSQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe *p, void *pP4, int n){\n  VdbeOp *pOp;\n  assert( n!=P4_INT32 && n!=P4_VTAB );\n  assert( n<=0 );\n  if( p->db->mallocFailed ){\n    freeP4(p->db, n, pP4);\n  }else{\n    assert( pP4!=0 );\n    assert( p->nOp>0 );\n    pOp = &p->aOp[p->nOp-1];\n    assert( pOp->p4type==P4_NOTUSED );\n    pOp->p4type = n;\n    pOp->p4.p = pP4;\n  }\n}\n\n/*\n** Set the P4 on the most recently added opcode to the KeyInfo for the\n** index given.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){\n  Vdbe *v = pParse->pVdbe;\n  KeyInfo *pKeyInfo;\n  assert( v!=0 );\n  assert( pIdx!=0 );\n  pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);\n  if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** Change the comment on the most recently coded instruction.  Or\n** insert a No-op and add the comment to that new instruction.  This\n** makes the code easier to read during debugging.  None of this happens\n** in a production build.\n*/\nstatic void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){\n  assert( p->nOp>0 || p->aOp==0 );\n  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );\n  if( p->nOp ){\n    assert( p->aOp );\n    sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);\n    p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    sqlite3VdbeAddOp0(p, OP_Noop);\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\n#endif  /* NDEBUG */\n\n#ifdef SQLITE_VDBE_COVERAGE\n/*\n** Set the value if the iSrcLine field for the previously coded instruction.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe *v, int iLine){\n  sqlite3VdbeGetOp(v,-1)->iSrcLine = iLine;\n}\n#endif /* SQLITE_VDBE_COVERAGE */\n\n/*\n** Return the opcode for a given address.  If the address is -1, then\n** return the most recently inserted opcode.\n**\n** If a memory allocation error has occurred prior to the calling of this\n** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode\n** is readable but not writable, though it is cast to a writable value.\n** The return of a dummy opcode allows the call to continue functioning\n** after an OOM fault without having to check to see if the return from \n** this routine is a valid pointer.  But because the dummy.opcode is 0,\n** dummy will never be written to.  This is verified by code inspection and\n** by running with Valgrind.\n*/\nSQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){\n  /* C89 specifies that the constant \"dummy\" will be initialized to all\n  ** zeros, which is correct.  MSVC generates a warning, nevertheless. */\n  static VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );\n  if( p->db->mallocFailed ){\n    return (VdbeOp*)&dummy;\n  }else{\n    return &p->aOp[addr];\n  }\n}\n\n#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS)\n/*\n** Return an integer value for one of the parameters to the opcode pOp\n** determined by character c.\n*/\nstatic int translateP(char c, const Op *pOp){\n  if( c=='1' ) return pOp->p1;\n  if( c=='2' ) return pOp->p2;\n  if( c=='3' ) return pOp->p3;\n  if( c=='4' ) return pOp->p4.i;\n  return pOp->p5;\n}\n\n/*\n** Compute a string for the \"comment\" field of a VDBE opcode listing.\n**\n** The Synopsis: field in comments in the vdbe.c source file gets converted\n** to an extra string that is appended to the sqlite3OpcodeName().  In the\n** absence of other comments, this synopsis becomes the comment on the opcode.\n** Some translation occurs:\n**\n**       \"PX\"      ->  \"r[X]\"\n**       \"PX@PY\"   ->  \"r[X..X+Y-1]\"  or \"r[x]\" if y is 0 or 1\n**       \"PX@PY+1\" ->  \"r[X..X+Y]\"    or \"r[x]\" if y is 0\n**       \"PY..PY\"  ->  \"r[X..Y]\"      or \"r[x]\" if y<=x\n*/\nstatic int displayComment(\n  const Op *pOp,     /* The opcode to be commented */\n  const char *zP4,   /* Previously obtained value for P4 */\n  char *zTemp,       /* Write result here */\n  int nTemp          /* Space available in zTemp[] */\n){\n  const char *zOpName;\n  const char *zSynopsis;\n  int nOpName;\n  int ii, jj;\n  char zAlt[50];\n  zOpName = sqlite3OpcodeName(pOp->opcode);\n  nOpName = sqlite3Strlen30(zOpName);\n  if( zOpName[nOpName+1] ){\n    int seenCom = 0;\n    char c;\n    zSynopsis = zOpName += nOpName + 1;\n    if( strncmp(zSynopsis,\"IF \",3)==0 ){\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"r[P2] = (%s)\", zSynopsis+3);\n      }else{\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"if %s goto P2\", zSynopsis+3);\n      }\n      zSynopsis = zAlt;\n    }\n    for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){\n      if( c=='P' ){\n        c = zSynopsis[++ii];\n        if( c=='4' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", zP4);\n        }else if( c=='X' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", pOp->zComment);\n          seenCom = 1;\n        }else{\n          int v1 = translateP(c, pOp);\n          int v2;\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%d\", v1);\n          if( strncmp(zSynopsis+ii+1, \"@P\", 2)==0 ){\n            ii += 3;\n            jj += sqlite3Strlen30(zTemp+jj);\n            v2 = translateP(zSynopsis[ii], pOp);\n            if( strncmp(zSynopsis+ii+1,\"+1\",2)==0 ){\n              ii += 2;\n              v2++;\n            }\n            if( v2>1 ){\n              sqlite3_snprintf(nTemp-jj, zTemp+jj, \"..%d\", v1+v2-1);\n            }\n          }else if( strncmp(zSynopsis+ii+1, \"..P3\", 4)==0 && pOp->p3==0 ){\n            ii += 4;\n          }\n        }\n        jj += sqlite3Strlen30(zTemp+jj);\n      }else{\n        zTemp[jj++] = c;\n      }\n    }\n    if( !seenCom && jj<nTemp-5 && pOp->zComment ){\n      sqlite3_snprintf(nTemp-jj, zTemp+jj, \"; %s\", pOp->zComment);\n      jj += sqlite3Strlen30(zTemp+jj);\n    }\n    if( jj<nTemp ) zTemp[jj] = 0;\n  }else if( pOp->zComment ){\n    sqlite3_snprintf(nTemp, zTemp, \"%s\", pOp->zComment);\n    jj = sqlite3Strlen30(zTemp);\n  }else{\n    zTemp[0] = 0;\n    jj = 0;\n  }\n  return jj;\n}\n#endif /* SQLITE_DEBUG */\n\n#if VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS)\n/*\n** Translate the P4.pExpr value for an OP_CursorHint opcode into text\n** that can be displayed in the P4 column of EXPLAIN output.\n*/\nstatic void displayP4Expr(StrAccum *p, Expr *pExpr){\n  const char *zOp = 0;\n  switch( pExpr->op ){\n    case TK_STRING:\n      sqlite3XPrintf(p, \"%Q\", pExpr->u.zToken);\n      break;\n    case TK_INTEGER:\n      sqlite3XPrintf(p, \"%d\", pExpr->u.iValue);\n      break;\n    case TK_NULL:\n      sqlite3XPrintf(p, \"NULL\");\n      break;\n    case TK_REGISTER: {\n      sqlite3XPrintf(p, \"r[%d]\", pExpr->iTable);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iColumn<0 ){\n        sqlite3XPrintf(p, \"rowid\");\n      }else{\n        sqlite3XPrintf(p, \"c%d\", (int)pExpr->iColumn);\n      }\n      break;\n    }\n    case TK_LT:      zOp = \"LT\";      break;\n    case TK_LE:      zOp = \"LE\";      break;\n    case TK_GT:      zOp = \"GT\";      break;\n    case TK_GE:      zOp = \"GE\";      break;\n    case TK_NE:      zOp = \"NE\";      break;\n    case TK_EQ:      zOp = \"EQ\";      break;\n    case TK_IS:      zOp = \"IS\";      break;\n    case TK_ISNOT:   zOp = \"ISNOT\";   break;\n    case TK_AND:     zOp = \"AND\";     break;\n    case TK_OR:      zOp = \"OR\";      break;\n    case TK_PLUS:    zOp = \"ADD\";     break;\n    case TK_STAR:    zOp = \"MUL\";     break;\n    case TK_MINUS:   zOp = \"SUB\";     break;\n    case TK_REM:     zOp = \"REM\";     break;\n    case TK_BITAND:  zOp = \"BITAND\";  break;\n    case TK_BITOR:   zOp = \"BITOR\";   break;\n    case TK_SLASH:   zOp = \"DIV\";     break;\n    case TK_LSHIFT:  zOp = \"LSHIFT\";  break;\n    case TK_RSHIFT:  zOp = \"RSHIFT\";  break;\n    case TK_CONCAT:  zOp = \"CONCAT\";  break;\n    case TK_UMINUS:  zOp = \"MINUS\";   break;\n    case TK_UPLUS:   zOp = \"PLUS\";    break;\n    case TK_BITNOT:  zOp = \"BITNOT\";  break;\n    case TK_NOT:     zOp = \"NOT\";     break;\n    case TK_ISNULL:  zOp = \"ISNULL\";  break;\n    case TK_NOTNULL: zOp = \"NOTNULL\"; break;\n\n    default:\n      sqlite3XPrintf(p, \"%s\", \"expr\");\n      break;\n  }\n\n  if( zOp ){\n    sqlite3XPrintf(p, \"%s(\", zOp);\n    displayP4Expr(p, pExpr->pLeft);\n    if( pExpr->pRight ){\n      sqlite3StrAccumAppend(p, \",\", 1);\n      displayP4Expr(p, pExpr->pRight);\n    }\n    sqlite3StrAccumAppend(p, \")\", 1);\n  }\n}\n#endif /* VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS) */\n\n\n#if VDBE_DISPLAY_P4\n/*\n** Compute a string that describes the P4 parameter for an opcode.\n** Use zTemp for any required temporary buffer space.\n*/\nstatic char *displayP4(Op *pOp, char *zTemp, int nTemp){\n  char *zP4 = zTemp;\n  StrAccum x;\n  assert( nTemp>=20 );\n  sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);\n  switch( pOp->p4type ){\n    case P4_KEYINFO: {\n      int j;\n      KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;\n      assert( pKeyInfo->aSortOrder!=0 );\n      sqlite3XPrintf(&x, \"k(%d\", pKeyInfo->nKeyField);\n      for(j=0; j<pKeyInfo->nKeyField; j++){\n        CollSeq *pColl = pKeyInfo->aColl[j];\n        const char *zColl = pColl ? pColl->zName : \"\";\n        if( strcmp(zColl, \"BINARY\")==0 ) zColl = \"B\";\n        sqlite3XPrintf(&x, \",%s%s\", pKeyInfo->aSortOrder[j] ? \"-\" : \"\", zColl);\n      }\n      sqlite3StrAccumAppend(&x, \")\", 1);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      displayP4Expr(&x, pOp->p4.pExpr);\n      break;\n    }\n#endif\n    case P4_COLLSEQ: {\n      CollSeq *pColl = pOp->p4.pColl;\n      sqlite3XPrintf(&x, \"(%.20s)\", pColl->zName);\n      break;\n    }\n    case P4_FUNCDEF: {\n      FuncDef *pDef = pOp->p4.pFunc;\n      sqlite3XPrintf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    case P4_FUNCCTX: {\n      FuncDef *pDef = pOp->p4.pCtx->pFunc;\n      sqlite3XPrintf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#endif\n    case P4_INT64: {\n      sqlite3XPrintf(&x, \"%lld\", *pOp->p4.pI64);\n      break;\n    }\n    case P4_INT32: {\n      sqlite3XPrintf(&x, \"%d\", pOp->p4.i);\n      break;\n    }\n    case P4_REAL: {\n      sqlite3XPrintf(&x, \"%.16g\", *pOp->p4.pReal);\n      break;\n    }\n    case P4_MEM: {\n      Mem *pMem = pOp->p4.pMem;\n      if( pMem->flags & MEM_Str ){\n        zP4 = pMem->z;\n      }else if( pMem->flags & MEM_Int ){\n        sqlite3XPrintf(&x, \"%lld\", pMem->u.i);\n      }else if( pMem->flags & MEM_Real ){\n        sqlite3XPrintf(&x, \"%.16g\", pMem->u.r);\n      }else if( pMem->flags & MEM_Null ){\n        zP4 = \"NULL\";\n      }else{\n        assert( pMem->flags & MEM_Blob );\n        zP4 = \"(blob)\";\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case P4_VTAB: {\n      sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;\n      sqlite3XPrintf(&x, \"vtab:%p\", pVtab);\n      break;\n    }\n#endif\n    case P4_INTARRAY: {\n      int i;\n      int *ai = pOp->p4.ai;\n      int n = ai[0];   /* The first element of an INTARRAY is always the\n                       ** count of the number of elements to follow */\n      for(i=1; i<=n; i++){\n        sqlite3XPrintf(&x, \",%d\", ai[i]);\n      }\n      zTemp[0] = '[';\n      sqlite3StrAccumAppend(&x, \"]\", 1);\n      break;\n    }\n    case P4_SUBPROGRAM: {\n      sqlite3XPrintf(&x, \"program\");\n      break;\n    }\n    case P4_ADVANCE: {\n      zTemp[0] = 0;\n      break;\n    }\n    case P4_TABLE: {\n      sqlite3XPrintf(&x, \"%s\", pOp->p4.pTab->zName);\n      break;\n    }\n    default: {\n      zP4 = pOp->p4.z;\n      if( zP4==0 ){\n        zP4 = zTemp;\n        zTemp[0] = 0;\n      }\n    }\n  }\n  sqlite3StrAccumFinish(&x);\n  assert( zP4!=0 );\n  return zP4;\n}\n#endif /* VDBE_DISPLAY_P4 */\n\n/*\n** Declare to the Vdbe that the BTree object at db->aDb[i] is used.\n**\n** The prepared statements need to know in advance the complete set of\n** attached databases that will be use.  A mask of these databases\n** is maintained in p->btreeMask.  The p->lockMask value is the subset of\n** p->btreeMask of databases that will require a lock.\n*/\nSQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){\n  assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );\n  assert( i<(int)sizeof(p->btreeMask)*8 );\n  DbMaskSet(p->btreeMask, i);\n  if( i!=1 && sqlite3BtreeSharable(p->db->aDb[i].pBt) ){\n    DbMaskSet(p->lockMask, i);\n  }\n}\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** If SQLite is compiled to support shared-cache mode and to be threadsafe,\n** this routine obtains the mutex associated with each BtShared structure\n** that may be accessed by the VM passed as an argument. In doing so it also\n** sets the BtShared.db member of each of the BtShared structures, ensuring\n** that the correct busy-handler callback is invoked if required.\n**\n** If SQLite is not threadsafe but does support shared-cache mode, then\n** sqlite3BtreeEnter() is invoked to set the BtShared.db variables\n** of all of BtShared structures accessible via the database handle \n** associated with the VM.\n**\n** If SQLite is not threadsafe and does not support shared-cache mode, this\n** function is a no-op.\n**\n** The p->btreeMask field is a bitmask of all btrees that the prepared \n** statement p will ever use.  Let N be the number of bits in p->btreeMask\n** corresponding to btrees that use shared cache.  Then the runtime of\n** this routine is N*N.  But as N is rarely more than 1, this should not\n** be a problem.\n*/\nSQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeEnter(aDb[i].pBt);\n    }\n  }\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n/*\n** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter().\n*/\nstatic SQLITE_NOINLINE void vdbeLeave(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeLeave(aDb[i].pBt);\n    }\n  }\n}\nSQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe *p){\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  vdbeLeave(p);\n}\n#endif\n\n#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n/*\n** Print a single opcode.  This routine is used for debugging only.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){\n  char *zP4;\n  char zPtr[50];\n  char zCom[100];\n  static const char *zFormat1 = \"%4d %-13s %4d %4d %4d %-13s %.2X %s\\n\";\n  if( pOut==0 ) pOut = stdout;\n  zP4 = displayP4(pOp, zPtr, sizeof(zPtr));\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  displayComment(pOp, zP4, zCom, sizeof(zCom));\n#else\n  zCom[0] = 0;\n#endif\n  /* NB:  The sqlite3OpcodeName() function is implemented by code created\n  ** by the mkopcodeh.awk and mkopcodec.awk scripts which extract the\n  ** information from the vdbe.c source text */\n  fprintf(pOut, zFormat1, pc, \n      sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5,\n      zCom\n  );\n  fflush(pOut);\n}\n#endif\n\n/*\n** Initialize an array of N Mem element.\n*/\nstatic void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){\n  while( (N--)>0 ){\n    p->db = db;\n    p->flags = flags;\n    p->szMalloc = 0;\n#ifdef SQLITE_DEBUG\n    p->pScopyFrom = 0;\n#endif\n    p++;\n  }\n}\n\n/*\n** Release an array of N Mem elements\n*/\nstatic void releaseMemArray(Mem *p, int N){\n  if( p && N ){\n    Mem *pEnd = &p[N];\n    sqlite3 *db = p->db;\n    if( db->pnBytesFreed ){\n      do{\n        if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n      }while( (++p)<pEnd );\n      return;\n    }\n    do{\n      assert( (&p[1])==pEnd || p[0].db==p[1].db );\n      assert( sqlite3VdbeCheckMemInvariants(p) );\n\n      /* This block is really an inlined version of sqlite3VdbeMemRelease()\n      ** that takes advantage of the fact that the memory cell value is \n      ** being set to NULL after releasing any dynamic resources.\n      **\n      ** The justification for duplicating code is that according to \n      ** callgrind, this causes a certain test case to hit the CPU 4.7 \n      ** percent less (x86 linux, gcc version 4.1.2, -O6) than if \n      ** sqlite3MemRelease() were called from here. With -O2, this jumps\n      ** to 6.6 percent. The test case is inserting 1000 rows into a table \n      ** with no indexes using a single prepared INSERT statement, bind() \n      ** and reset(). Inserts are grouped into a transaction.\n      */\n      testcase( p->flags & MEM_Agg );\n      testcase( p->flags & MEM_Dyn );\n      testcase( p->flags & MEM_Frame );\n      testcase( p->flags & MEM_RowSet );\n      if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){\n        sqlite3VdbeMemRelease(p);\n      }else if( p->szMalloc ){\n        sqlite3DbFreeNN(db, p->zMalloc);\n        p->szMalloc = 0;\n      }\n\n      p->flags = MEM_Undefined;\n    }while( (++p)<pEnd );\n  }\n}\n\n/*\n** Delete a VdbeFrame object and its contents. VdbeFrame objects are\n** allocated by the OP_Program opcode in sqlite3VdbeExec().\n*/\nSQLITE_PRIVATE void sqlite3VdbeFrameDelete(VdbeFrame *p){\n  int i;\n  Mem *aMem = VdbeFrameMem(p);\n  VdbeCursor **apCsr = (VdbeCursor **)&aMem[p->nChildMem];\n  for(i=0; i<p->nChildCsr; i++){\n    sqlite3VdbeFreeCursor(p->v, apCsr[i]);\n  }\n  releaseMemArray(aMem, p->nChildMem);\n  sqlite3VdbeDeleteAuxData(p->v->db, &p->pAuxData, -1, 0);\n  sqlite3DbFree(p->v->db, p);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Give a listing of the program in the virtual machine.\n**\n** The interface is the same as sqlite3VdbeExec().  But instead of\n** running the code, it invokes the callback once for each instruction.\n** This feature is used to implement \"EXPLAIN\".\n**\n** When p->explain==1, each instruction is listed.  When\n** p->explain==2, only OP_Explain instructions are listed and these\n** are shown in a different format.  p->explain==2 is used to implement\n** EXPLAIN QUERY PLAN.\n**\n** When p->explain==1, first the main program is listed, then each of\n** the trigger subprograms are listed one by one.\n*/\nSQLITE_PRIVATE int sqlite3VdbeList(\n  Vdbe *p                   /* The VDBE */\n){\n  int nRow;                            /* Stop when row count reaches this */\n  int nSub = 0;                        /* Number of sub-vdbes seen so far */\n  SubProgram **apSub = 0;              /* Array of sub-vdbes */\n  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */\n  sqlite3 *db = p->db;                 /* The database connection */\n  int i;                               /* Loop counter */\n  int rc = SQLITE_OK;                  /* Return code */\n  Mem *pMem = &p->aMem[1];             /* First Mem of result set */\n\n  assert( p->explain );\n  assert( p->magic==VDBE_MAGIC_RUN );\n  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );\n\n  /* Even though this opcode does not use dynamic strings for\n  ** the result, result columns may become dynamic if the user calls\n  ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.\n  */\n  releaseMemArray(pMem, 8);\n  p->pResultSet = 0;\n\n  if( p->rc==SQLITE_NOMEM_BKPT ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    sqlite3OomFault(db);\n    return SQLITE_ERROR;\n  }\n\n  /* When the number of output rows reaches nRow, that means the\n  ** listing has finished and sqlite3_step() should return SQLITE_DONE.\n  ** nRow is the sum of the number of rows in the main program, plus\n  ** the sum of the number of rows in all trigger subprograms encountered\n  ** so far.  The nRow value will increase as new trigger subprograms are\n  ** encountered, but p->pc will eventually catch up to nRow.\n  */\n  nRow = p->nOp;\n  if( p->explain==1 ){\n    /* The first 8 memory cells are used for the result set.  So we will\n    ** commandeer the 9th cell to use as storage for an array of pointers\n    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9\n    ** cells.  */\n    assert( p->nMem>9 );\n    pSub = &p->aMem[9];\n    if( pSub->flags&MEM_Blob ){\n      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is\n      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */\n      nSub = pSub->n/sizeof(Vdbe*);\n      apSub = (SubProgram **)pSub->z;\n    }\n    for(i=0; i<nSub; i++){\n      nRow += apSub[i]->nOp;\n    }\n  }\n\n  do{\n    i = p->pc++;\n  }while( i<nRow && p->explain==2 && p->aOp[i].opcode!=OP_Explain );\n  if( i>=nRow ){\n    p->rc = SQLITE_OK;\n    rc = SQLITE_DONE;\n  }else if( db->u1.isInterrupted ){\n    p->rc = SQLITE_INTERRUPT;\n    rc = SQLITE_ERROR;\n    sqlite3VdbeError(p, sqlite3ErrStr(p->rc));\n  }else{\n    char *zP4;\n    Op *pOp;\n    if( i<p->nOp ){\n      /* The output line number is small enough that we are still in the\n      ** main program. */\n      pOp = &p->aOp[i];\n    }else{\n      /* We are currently listing subprograms.  Figure out which one and\n      ** pick up the appropriate opcode. */\n      int j;\n      i -= p->nOp;\n      for(j=0; i>=apSub[j]->nOp; j++){\n        i -= apSub[j]->nOp;\n      }\n      pOp = &apSub[j]->aOp[i];\n    }\n    if( p->explain==1 ){\n      pMem->flags = MEM_Int;\n      pMem->u.i = i;                                /* Program counter */\n      pMem++;\n  \n      pMem->flags = MEM_Static|MEM_Str|MEM_Term;\n      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n\n      /* When an OP_Program opcode is encounter (the only opcode that has\n      ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms\n      ** kept in p->aMem[9].z to hold the new program - assuming this subprogram\n      ** has not already been seen.\n      */\n      if( pOp->p4type==P4_SUBPROGRAM ){\n        int nByte = (nSub+1)*sizeof(SubProgram*);\n        int j;\n        for(j=0; j<nSub; j++){\n          if( apSub[j]==pOp->p4.pProgram ) break;\n        }\n        if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){\n          apSub = (SubProgram **)pSub->z;\n          apSub[nSub++] = pOp->p4.pProgram;\n          pSub->flags |= MEM_Blob;\n          pSub->n = nSub*sizeof(SubProgram*);\n        }\n      }\n    }\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p1;                          /* P1 */\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p2;                          /* P2 */\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p3;                          /* P3 */\n    pMem++;\n\n    if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */\n      assert( p->db->mallocFailed );\n      return SQLITE_ERROR;\n    }\n    pMem->flags = MEM_Str|MEM_Term;\n    zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);\n    if( zP4!=pMem->z ){\n      pMem->n = 0;\n      sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);\n    }else{\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->enc = SQLITE_UTF8;\n    }\n    pMem++;\n\n    if( p->explain==1 ){\n      if( sqlite3VdbeMemClearAndResize(pMem, 4) ){\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Str|MEM_Term;\n      pMem->n = 2;\n      sqlite3_snprintf(3, pMem->z, \"%.2x\", pOp->p5);   /* P5 */\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n  \n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n      if( sqlite3VdbeMemClearAndResize(pMem, 500) ){\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Str|MEM_Term;\n      pMem->n = displayComment(pOp, zP4, pMem->z, 500);\n      pMem->enc = SQLITE_UTF8;\n#else\n      pMem->flags = MEM_Null;                       /* Comment */\n#endif\n    }\n\n    p->nResColumn = 8 - 4*(p->explain-1);\n    p->pResultSet = &p->aMem[1];\n    p->rc = SQLITE_OK;\n    rc = SQLITE_ROW;\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the SQL that was used to generate a VDBE program.\n*/\nSQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe *p){\n  const char *z = 0;\n  if( p->zSql ){\n    z = p->zSql;\n  }else if( p->nOp>=1 ){\n    const VdbeOp *pOp = &p->aOp[0];\n    if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n      z = pOp->p4.z;\n      while( sqlite3Isspace(*z) ) z++;\n    }\n  }\n  if( z ) printf(\"SQL: [%s]\\n\", z);\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** Print an IOTRACE message showing SQL content.\n*/\nSQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe *p){\n  int nOp = p->nOp;\n  VdbeOp *pOp;\n  if( sqlite3IoTrace==0 ) return;\n  if( nOp<1 ) return;\n  pOp = &p->aOp[0];\n  if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n    int i, j;\n    char z[1000];\n    sqlite3_snprintf(sizeof(z), z, \"%s\", pOp->p4.z);\n    for(i=0; sqlite3Isspace(z[i]); i++){}\n    for(j=0; z[i]; i++){\n      if( sqlite3Isspace(z[i]) ){\n        if( z[i-1]!=' ' ){\n          z[j++] = ' ';\n        }\n      }else{\n        z[j++] = z[i];\n      }\n    }\n    z[j] = 0;\n    sqlite3IoTrace(\"SQL %s\\n\", z);\n  }\n}\n#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */\n\n/* An instance of this object describes bulk memory available for use\n** by subcomponents of a prepared statement.  Space is allocated out\n** of a ReusableSpace object by the allocSpace() routine below.\n*/\nstruct ReusableSpace {\n  u8 *pSpace;          /* Available memory */\n  int nFree;           /* Bytes of available memory */\n  int nNeeded;         /* Total bytes that could not be allocated */\n};\n\n/* Try to allocate nByte bytes of 8-byte aligned bulk memory for pBuf\n** from the ReusableSpace object.  Return a pointer to the allocated\n** memory on success.  If insufficient memory is available in the\n** ReusableSpace object, increase the ReusableSpace.nNeeded\n** value by the amount needed and return NULL.\n**\n** If pBuf is not initially NULL, that means that the memory has already\n** been allocated by a prior call to this routine, so just return a copy\n** of pBuf and leave ReusableSpace unchanged.\n**\n** This allocator is employed to repurpose unused slots at the end of the\n** opcode array of prepared state for other memory needs of the prepared\n** statement.\n*/\nstatic void *allocSpace(\n  struct ReusableSpace *p,  /* Bulk memory available for allocation */\n  void *pBuf,               /* Pointer to a prior allocation */\n  int nByte                 /* Bytes of memory needed */\n){\n  assert( EIGHT_BYTE_ALIGNMENT(p->pSpace) );\n  if( pBuf==0 ){\n    nByte = ROUND8(nByte);\n    if( nByte <= p->nFree ){\n      p->nFree -= nByte;\n      pBuf = &p->pSpace[p->nFree];\n    }else{\n      p->nNeeded += nByte;\n    }\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pBuf) );\n  return pBuf;\n}\n\n/*\n** Rewind the VDBE back to the beginning in preparation for\n** running it.\n*/\nSQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n  assert( p!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET );\n\n  /* There should be at least one opcode.\n  */\n  assert( p->nOp>0 );\n\n  /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */\n  p->magic = VDBE_MAGIC_RUN;\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<p->nMem; i++){\n    assert( p->aMem[i].db==p->db );\n  }\n#endif\n  p->pc = -1;\n  p->rc = SQLITE_OK;\n  p->errorAction = OE_Abort;\n  p->nChange = 0;\n  p->cacheCtr = 1;\n  p->minWriteFileFormat = 255;\n  p->iStatement = 0;\n  p->nFkConstraint = 0;\n#ifdef VDBE_PROFILE\n  for(i=0; i<p->nOp; i++){\n    p->aOp[i].cnt = 0;\n    p->aOp[i].cycles = 0;\n  }\n#endif\n}\n\n/*\n** Prepare a virtual machine for execution for the first time after\n** creating the virtual machine.  This involves things such\n** as allocating registers and initializing the program counter.\n** After the VDBE has be prepped, it can be executed by one or more\n** calls to sqlite3VdbeExec().  \n**\n** This function may be called exactly once on each virtual machine.\n** After this routine is called the VM has been \"packaged\" and is ready\n** to run.  After this routine is called, further calls to \n** sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects\n** the Vdbe from the Parse object that helped generate it so that the\n** the Vdbe becomes an independent entity and the Parse object can be\n** destroyed.\n**\n** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back\n** to its initial state after it has been run.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMakeReady(\n  Vdbe *p,                       /* The VDBE */\n  Parse *pParse                  /* Parsing context */\n){\n  sqlite3 *db;                   /* The database connection */\n  int nVar;                      /* Number of parameters */\n  int nMem;                      /* Number of VM memory registers */\n  int nCursor;                   /* Number of cursors required */\n  int nArg;                      /* Number of arguments in subprograms */\n  int n;                         /* Loop counter */\n  struct ReusableSpace x;        /* Reusable bulk memory */\n\n  assert( p!=0 );\n  assert( p->nOp>0 );\n  assert( pParse!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( pParse==p->pParse );\n  db = p->db;\n  assert( db->mallocFailed==0 );\n  nVar = pParse->nVar;\n  nMem = pParse->nMem;\n  nCursor = pParse->nTab;\n  nArg = pParse->nMaxArg;\n  \n  /* Each cursor uses a memory cell.  The first cursor (cursor 0) can\n  ** use aMem[0] which is not otherwise used by the VDBE program.  Allocate\n  ** space at the end of aMem[] for cursors 1 and greater.\n  ** See also: allocateCursor().\n  */\n  nMem += nCursor;\n  if( nCursor==0 && nMem>0 ) nMem++;  /* Space for aMem[0] even if not used */\n\n  /* Figure out how much reusable memory is available at the end of the\n  ** opcode array.  This extra memory will be reallocated for other elements\n  ** of the prepared statement.\n  */\n  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */\n  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */\n  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );\n  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */\n  assert( x.nFree>=0 );\n  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );\n\n  resolveP2Values(p, &nArg);\n  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);\n  if( pParse->explain && nMem<10 ){\n    nMem = 10;\n  }\n  p->expired = 0;\n\n  /* Memory for registers, parameters, cursor, etc, is allocated in one or two\n  ** passes.  On the first pass, we try to reuse unused memory at the \n  ** end of the opcode array.  If we are unable to satisfy all memory\n  ** requirements by reusing the opcode array tail, then the second\n  ** pass will fill in the remainder using a fresh memory allocation.  \n  **\n  ** This two-pass approach that reuses as much memory as possible from\n  ** the leftover memory at the end of the opcode array.  This can significantly\n  ** reduce the amount of memory held by a prepared statement.\n  */\n  do {\n    x.nNeeded = 0;\n    p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));\n    p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));\n    p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));\n    p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));\n#endif\n    if( x.nNeeded==0 ) break;\n    x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);\n    x.nFree = x.nNeeded;\n  }while( !db->mallocFailed );\n\n  p->pVList = pParse->pVList;\n  pParse->pVList =  0;\n  p->explain = pParse->explain;\n  if( db->mallocFailed ){\n    p->nVar = 0;\n    p->nCursor = 0;\n    p->nMem = 0;\n  }else{\n    p->nCursor = nCursor;\n    p->nVar = (ynVar)nVar;\n    initMemArray(p->aVar, nVar, db, MEM_Null);\n    p->nMem = nMem;\n    initMemArray(p->aMem, nMem, db, MEM_Undefined);\n    memset(p->apCsr, 0, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    memset(p->anExec, 0, p->nOp*sizeof(i64));\n#endif\n  }\n  sqlite3VdbeRewind(p);\n}\n\n/*\n** Close a VDBE cursor and release all the resources that cursor \n** happens to hold.\n*/\nSQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){\n  if( pCx==0 ){\n    return;\n  }\n  assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );\n  switch( pCx->eCurType ){\n    case CURTYPE_SORTER: {\n      sqlite3VdbeSorterClose(p->db, pCx);\n      break;\n    }\n    case CURTYPE_BTREE: {\n      if( pCx->isEphemeral ){\n        if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);\n        /* The pCx->pCursor will be close automatically, if it exists, by\n        ** the call above. */\n      }else{\n        assert( pCx->uc.pCursor!=0 );\n        sqlite3BtreeCloseCursor(pCx->uc.pCursor);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case CURTYPE_VTAB: {\n      sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;\n      const sqlite3_module *pModule = pVCur->pVtab->pModule;\n      assert( pVCur->pVtab->nRef>0 );\n      pVCur->pVtab->nRef--;\n      pModule->xClose(pVCur);\n      break;\n    }\n#endif\n  }\n}\n\n/*\n** Close all cursors in the current frame.\n*/\nstatic void closeCursorsInFrame(Vdbe *p){\n  if( p->apCsr ){\n    int i;\n    for(i=0; i<p->nCursor; i++){\n      VdbeCursor *pC = p->apCsr[i];\n      if( pC ){\n        sqlite3VdbeFreeCursor(p, pC);\n        p->apCsr[i] = 0;\n      }\n    }\n  }\n}\n\n/*\n** Copy the values stored in the VdbeFrame structure to its Vdbe. This\n** is used, for example, when a trigger sub-program is halted to restore\n** control to the main program.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){\n  Vdbe *v = pFrame->v;\n  closeCursorsInFrame(v);\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  v->anExec = pFrame->anExec;\n#endif\n  v->aOp = pFrame->aOp;\n  v->nOp = pFrame->nOp;\n  v->aMem = pFrame->aMem;\n  v->nMem = pFrame->nMem;\n  v->apCsr = pFrame->apCsr;\n  v->nCursor = pFrame->nCursor;\n  v->db->lastRowid = pFrame->lastRowid;\n  v->nChange = pFrame->nChange;\n  v->db->nChange = pFrame->nDbChange;\n  sqlite3VdbeDeleteAuxData(v->db, &v->pAuxData, -1, 0);\n  v->pAuxData = pFrame->pAuxData;\n  pFrame->pAuxData = 0;\n  return pFrame->pc;\n}\n\n/*\n** Close all cursors.\n**\n** Also release any dynamic memory held by the VM in the Vdbe.aMem memory \n** cell array. This is necessary as the memory cell array may contain\n** pointers to VdbeFrame objects, which may in turn contain pointers to\n** open cursors.\n*/\nstatic void closeAllCursors(Vdbe *p){\n  if( p->pFrame ){\n    VdbeFrame *pFrame;\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    sqlite3VdbeFrameRestore(pFrame);\n    p->pFrame = 0;\n    p->nFrame = 0;\n  }\n  assert( p->nFrame==0 );\n  closeCursorsInFrame(p);\n  if( p->aMem ){\n    releaseMemArray(p->aMem, p->nMem);\n  }\n  while( p->pDelFrame ){\n    VdbeFrame *pDel = p->pDelFrame;\n    p->pDelFrame = pDel->pParent;\n    sqlite3VdbeFrameDelete(pDel);\n  }\n\n  /* Delete any auxdata allocations made by the VM */\n  if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p->db, &p->pAuxData, -1, 0);\n  assert( p->pAuxData==0 );\n}\n\n/*\n** Set the number of result columns that will be returned by this SQL\n** statement. This is now set at compile time, rather than during\n** execution of the vdbe program so that sqlite3_column_count() can\n** be called on an SQL statement before sqlite3_step().\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){\n  int n;\n  sqlite3 *db = p->db;\n\n  if( p->nResColumn ){\n    releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n    sqlite3DbFree(db, p->aColName);\n  }\n  n = nResColumn*COLNAME_N;\n  p->nResColumn = (u16)nResColumn;\n  p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );\n  if( p->aColName==0 ) return;\n  initMemArray(p->aColName, n, db, MEM_Null);\n}\n\n/*\n** Set the name of the idx'th column to be returned by the SQL statement.\n** zName must be a pointer to a nul terminated string.\n**\n** This call must be made after a call to sqlite3VdbeSetNumCols().\n**\n** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC\n** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed\n** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSetColName(\n  Vdbe *p,                         /* Vdbe being configured */\n  int idx,                         /* Index of column zName applies to */\n  int var,                         /* One of the COLNAME_* constants */\n  const char *zName,               /* Pointer to buffer containing name */\n  void (*xDel)(void*)              /* Memory management strategy for zName */\n){\n  int rc;\n  Mem *pColName;\n  assert( idx<p->nResColumn );\n  assert( var<COLNAME_N );\n  if( p->db->mallocFailed ){\n    assert( !zName || xDel!=SQLITE_DYNAMIC );\n    return SQLITE_NOMEM_BKPT;\n  }\n  assert( p->aColName!=0 );\n  pColName = &(p->aColName[idx+var*p->nResColumn]);\n  rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel);\n  assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 );\n  return rc;\n}\n\n/*\n** A read or write transaction may or may not be active on database handle\n** db. If a transaction is active, commit it. If there is a\n** write-transaction spanning more than one database file, this routine\n** takes care of the master journal trickery.\n*/\nstatic int vdbeCommit(sqlite3 *db, Vdbe *p){\n  int i;\n  int nTrans = 0;  /* Number of databases with an active write-transaction\n                   ** that are candidates for a two-phase commit using a\n                   ** master-journal */\n  int rc = SQLITE_OK;\n  int needXcommit = 0;\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  /* With this option, sqlite3VtabSync() is defined to be simply \n  ** SQLITE_OK so p is not used. \n  */\n  UNUSED_PARAMETER(p);\n#endif\n\n  /* Before doing anything else, call the xSync() callback for any\n  ** virtual module tables written in this transaction. This has to\n  ** be done before determining whether a master journal file is \n  ** required, as an xSync() callback may add an attached database\n  ** to the transaction.\n  */\n  rc = sqlite3VtabSync(db, p);\n\n  /* This loop determines (a) if the commit hook should be invoked and\n  ** (b) how many database files have open write transactions, not \n  ** including the temp database. (b) is important because if more than \n  ** one database file has an open write transaction, a master journal\n  ** file is required for an atomic commit.\n  */ \n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n    Btree *pBt = db->aDb[i].pBt;\n    if( sqlite3BtreeIsInTrans(pBt) ){\n      /* Whether or not a database might need a master journal depends upon\n      ** its journal mode (among other things).  This matrix determines which\n      ** journal modes use a master journal and which do not */\n      static const u8 aMJNeeded[] = {\n        /* DELETE   */  1,\n        /* PERSIST   */ 1,\n        /* OFF       */ 0,\n        /* TRUNCATE  */ 1,\n        /* MEMORY    */ 0,\n        /* WAL       */ 0\n      };\n      Pager *pPager;   /* Pager associated with pBt */\n      needXcommit = 1;\n      sqlite3BtreeEnter(pBt);\n      pPager = sqlite3BtreePager(pBt);\n      if( db->aDb[i].safety_level!=PAGER_SYNCHRONOUS_OFF\n       && aMJNeeded[sqlite3PagerGetJournalMode(pPager)]\n      ){ \n        assert( i!=1 );\n        nTrans++;\n      }\n      rc = sqlite3PagerExclusiveLock(pPager);\n      sqlite3BtreeLeave(pBt);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* If there are any write-transactions at all, invoke the commit hook */\n  if( needXcommit && db->xCommitCallback ){\n    rc = db->xCommitCallback(db->pCommitArg);\n    if( rc ){\n      return SQLITE_CONSTRAINT_COMMITHOOK;\n    }\n  }\n\n  /* The simple case - no more than one database file (not counting the\n  ** TEMP database) has a transaction active.   There is no need for the\n  ** master-journal.\n  **\n  ** If the return value of sqlite3BtreeGetFilename() is a zero length\n  ** string, it means the main database is :memory: or a temp file.  In \n  ** that case we do not support atomic multi-file commits, so use the \n  ** simple case then too.\n  */\n  if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))\n   || nTrans<=1\n  ){\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, 0);\n      }\n    }\n\n    /* Do the commit only if all databases successfully complete phase 1. \n    ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an\n    ** IO error while deleting or truncating a journal file. It is unlikely,\n    ** but could happen. In this case abandon processing and return the error.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3VtabCommit(db);\n    }\n  }\n\n  /* The complex case - There is a multi-file write-transaction active.\n  ** This requires a master journal file to ensure the transaction is\n  ** committed atomically.\n  */\n#ifndef SQLITE_OMIT_DISKIO\n  else{\n    sqlite3_vfs *pVfs = db->pVfs;\n    char *zMaster = 0;   /* File-name for the master journal */\n    char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);\n    sqlite3_file *pMaster = 0;\n    i64 offset = 0;\n    int res;\n    int retryCount = 0;\n    int nMainFile;\n\n    /* Select a master journal file name */\n    nMainFile = sqlite3Strlen30(zMainFile);\n    zMaster = sqlite3MPrintf(db, \"%s-mjXXXXXX9XXz\", zMainFile);\n    if( zMaster==0 ) return SQLITE_NOMEM_BKPT;\n    do {\n      u32 iRandom;\n      if( retryCount ){\n        if( retryCount>100 ){\n          sqlite3_log(SQLITE_FULL, \"MJ delete: %s\", zMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          break;\n        }else if( retryCount==1 ){\n          sqlite3_log(SQLITE_FULL, \"MJ collide: %s\", zMaster);\n        }\n      }\n      retryCount++;\n      sqlite3_randomness(sizeof(iRandom), &iRandom);\n      sqlite3_snprintf(13, &zMaster[nMainFile], \"-mj%06X9%02X\",\n                               (iRandom>>8)&0xffffff, iRandom&0xff);\n      /* The antipenultimate character of the master journal name must\n      ** be \"9\" to avoid name collisions when using 8+3 filenames. */\n      assert( zMaster[sqlite3Strlen30(zMaster)-3]=='9' );\n      sqlite3FileSuffix3(zMainFile, zMaster);\n      rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n    }while( rc==SQLITE_OK && res );\n    if( rc==SQLITE_OK ){\n      /* Open the master journal. */\n      rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, \n          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|\n          SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0\n      );\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n \n    /* Write the name of each database file in the transaction into the new\n    ** master journal file. If an error occurs at this point close\n    ** and delete the master journal file. All the individual journal files\n    ** still have 'null' as the master journal pointer, so they will roll\n    ** back independently if a failure occurs.\n    */\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( sqlite3BtreeIsInTrans(pBt) ){\n        char const *zFile = sqlite3BtreeGetJournalname(pBt);\n        if( zFile==0 ){\n          continue;  /* Ignore TEMP and :memory: databases */\n        }\n        assert( zFile[0]!=0 );\n        rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);\n        offset += sqlite3Strlen30(zFile)+1;\n        if( rc!=SQLITE_OK ){\n          sqlite3OsCloseFree(pMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          sqlite3DbFree(db, zMaster);\n          return rc;\n        }\n      }\n    }\n\n    /* Sync the master journal file. If the IOCAP_SEQUENTIAL device\n    ** flag is set this is not required.\n    */\n    if( 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)\n     && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))\n    ){\n      sqlite3OsCloseFree(pMaster);\n      sqlite3OsDelete(pVfs, zMaster, 0);\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Sync all the db files involved in the transaction. The same call\n    ** sets the master journal pointer in each individual journal. If\n    ** an error occurs here, do not delete the master journal file.\n    **\n    ** If the error occurs during the first call to\n    ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the\n    ** master journal file will be orphaned. But we cannot delete it,\n    ** in case the master journal file name was written into the journal\n    ** file before the failure occurred.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);\n      }\n    }\n    sqlite3OsCloseFree(pMaster);\n    assert( rc!=SQLITE_BUSY );\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Delete the master journal file. This commits the transaction. After\n    ** doing this the directory is synced again before any individual\n    ** transaction files are deleted.\n    */\n    rc = sqlite3OsDelete(pVfs, zMaster, 1);\n    sqlite3DbFree(db, zMaster);\n    zMaster = 0;\n    if( rc ){\n      return rc;\n    }\n\n    /* All files and directories have already been synced, so the following\n    ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and\n    ** deleting or truncating journals. If something goes wrong while\n    ** this is happening we don't really care. The integrity of the\n    ** transaction is already guaranteed, but some stray 'cold' journals\n    ** may be lying around. Returning an error code won't help matters.\n    */\n    disable_simulated_io_errors();\n    sqlite3BeginBenignMalloc();\n    for(i=0; i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        sqlite3BtreeCommitPhaseTwo(pBt, 1);\n      }\n    }\n    sqlite3EndBenignMalloc();\n    enable_simulated_io_errors();\n\n    sqlite3VtabCommit(db);\n  }\n#endif\n\n  return rc;\n}\n\n/* \n** This routine checks that the sqlite3.nVdbeActive count variable\n** matches the number of vdbe's in the list sqlite3.pVdbe that are\n** currently active. An assertion fails if the two counts do not match.\n** This is an internal self-check only - it is not an essential processing\n** step.\n**\n** This is a no-op if NDEBUG is defined.\n*/\n#ifndef NDEBUG\nstatic void checkActiveVdbeCnt(sqlite3 *db){\n  Vdbe *p;\n  int cnt = 0;\n  int nWrite = 0;\n  int nRead = 0;\n  p = db->pVdbe;\n  while( p ){\n    if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){\n      cnt++;\n      if( p->readOnly==0 ) nWrite++;\n      if( p->bIsReader ) nRead++;\n    }\n    p = p->pNext;\n  }\n  assert( cnt==db->nVdbeActive );\n  assert( nWrite==db->nVdbeWrite );\n  assert( nRead==db->nVdbeRead );\n}\n#else\n#define checkActiveVdbeCnt(x)\n#endif\n\n/*\n** If the Vdbe passed as the first argument opened a statement-transaction,\n** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or\n** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement\n** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the \n** statement transaction is committed.\n**\n** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. \n** Otherwise SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int vdbeCloseStatement(Vdbe *p, int eOp){\n  sqlite3 *const db = p->db;\n  int rc = SQLITE_OK;\n  int i;\n  const int iSavepoint = p->iStatement-1;\n\n  assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);\n  assert( db->nStatement>0 );\n  assert( p->iStatement==(db->nStatement+db->nSavepoint) );\n\n  for(i=0; i<db->nDb; i++){ \n    int rc2 = SQLITE_OK;\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      if( eOp==SAVEPOINT_ROLLBACK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);\n      }\n      if( rc2==SQLITE_OK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);\n      }\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  db->nStatement--;\n  p->iStatement = 0;\n\n  if( rc==SQLITE_OK ){\n    if( eOp==SAVEPOINT_ROLLBACK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);\n    }\n  }\n\n  /* If the statement transaction is being rolled back, also restore the \n  ** database handles deferred constraint counter to the value it had when \n  ** the statement transaction was opened.  */\n  if( eOp==SAVEPOINT_ROLLBACK ){\n    db->nDeferredCons = p->nStmtDefCons;\n    db->nDeferredImmCons = p->nStmtDefImmCons;\n  }\n  return rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){\n  if( p->db->nStatement && p->iStatement ){\n    return vdbeCloseStatement(p, eOp);\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** This function is called when a transaction opened by the database \n** handle associated with the VM passed as an argument is about to be \n** committed. If there are outstanding deferred foreign key constraint\n** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.\n**\n** If there are outstanding FK violations and this function returns \n** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY\n** and write an error message to it. Then return SQLITE_ERROR.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nSQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){\n  sqlite3 *db = p->db;\n  if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) \n   || (!deferred && p->nFkConstraint>0) \n  ){\n    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n    p->errorAction = OE_Abort;\n    sqlite3VdbeError(p, \"FOREIGN KEY constraint failed\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** This routine is called the when a VDBE tries to halt.  If the VDBE\n** has made changes and is in autocommit mode, then commit those\n** changes.  If a rollback is needed, then do the rollback.\n**\n** This routine is the only way to move the state of a VM from\n** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT.  It is harmless to\n** call this on a VM that is in the SQLITE_MAGIC_HALT state.\n**\n** Return an error code.  If the commit could not complete because of\n** lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it\n** means the close did not happen and needs to be repeated.\n*/\nSQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){\n  int rc;                         /* Used to store transient return codes */\n  sqlite3 *db = p->db;\n\n  /* This function contains the logic that determines if a statement or\n  ** transaction will be committed or rolled back as a result of the\n  ** execution of this virtual machine. \n  **\n  ** If any of the following errors occur:\n  **\n  **     SQLITE_NOMEM\n  **     SQLITE_IOERR\n  **     SQLITE_FULL\n  **     SQLITE_INTERRUPT\n  **\n  ** Then the internal cache might have been left in an inconsistent\n  ** state.  We need to rollback the statement transaction, if there is\n  ** one, or the complete transaction if there is no statement transaction.\n  */\n\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    return SQLITE_OK;\n  }\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n  closeAllCursors(p);\n  checkActiveVdbeCnt(db);\n\n  /* No commit or rollback needed if the program never started or if the\n  ** SQL statement does not read or write a database file.  */\n  if( p->pc>=0 && p->bIsReader ){\n    int mrc;   /* Primary error code from p->rc */\n    int eStatementOp = 0;\n    int isSpecialError;            /* Set to true if a 'special' error */\n\n    /* Lock all btrees used by the statement */\n    sqlite3VdbeEnter(p);\n\n    /* Check for one of the special errors */\n    mrc = p->rc & 0xff;\n    isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR\n                     || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;\n    if( isSpecialError ){\n      /* If the query was read-only and the error code is SQLITE_INTERRUPT, \n      ** no rollback is necessary. Otherwise, at least a savepoint \n      ** transaction must be rolled back to restore the database to a \n      ** consistent state.\n      **\n      ** Even if the statement is read-only, it is important to perform\n      ** a statement or transaction rollback operation. If the error \n      ** occurred while writing to the journal, sub-journal or database\n      ** file as part of an effort to free up cache space (see function\n      ** pagerStress() in pager.c), the rollback is required to restore \n      ** the pager to a consistent state.\n      */\n      if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){\n        if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){\n          eStatementOp = SAVEPOINT_ROLLBACK;\n        }else{\n          /* We are forced to roll back the active transaction. Before doing\n          ** so, abort any other statements this handle currently has active.\n          */\n          sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n          sqlite3CloseSavepoints(db);\n          db->autoCommit = 1;\n          p->nChange = 0;\n        }\n      }\n    }\n\n    /* Check for immediate foreign key violations. */\n    if( p->rc==SQLITE_OK ){\n      sqlite3VdbeCheckFk(p, 0);\n    }\n  \n    /* If the auto-commit flag is set and this is the only active writer \n    ** VM, then we do either a commit or rollback of the current transaction. \n    **\n    ** Note: This block also runs if one of the special errors handled \n    ** above has occurred. \n    */\n    if( !sqlite3VtabInSync(db) \n     && db->autoCommit \n     && db->nVdbeWrite==(p->readOnly==0) \n    ){\n      if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){\n        rc = sqlite3VdbeCheckFk(p, 1);\n        if( rc!=SQLITE_OK ){\n          if( NEVER(p->readOnly) ){\n            sqlite3VdbeLeave(p);\n            return SQLITE_ERROR;\n          }\n          rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n        }else{ \n          /* The auto-commit flag is true, the vdbe program was successful \n          ** or hit an 'OR FAIL' constraint and there are no deferred foreign\n          ** key constraints to hold up the transaction. This means a commit \n          ** is required. */\n          rc = vdbeCommit(db, p);\n        }\n        if( rc==SQLITE_BUSY && p->readOnly ){\n          sqlite3VdbeLeave(p);\n          return SQLITE_BUSY;\n        }else if( rc!=SQLITE_OK ){\n          p->rc = rc;\n          sqlite3RollbackAll(db, SQLITE_OK);\n          p->nChange = 0;\n        }else{\n          db->nDeferredCons = 0;\n          db->nDeferredImmCons = 0;\n          db->flags &= ~SQLITE_DeferFKs;\n          sqlite3CommitInternalChanges(db);\n        }\n      }else{\n        sqlite3RollbackAll(db, SQLITE_OK);\n        p->nChange = 0;\n      }\n      db->nStatement = 0;\n    }else if( eStatementOp==0 ){\n      if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){\n        eStatementOp = SAVEPOINT_RELEASE;\n      }else if( p->errorAction==OE_Abort ){\n        eStatementOp = SAVEPOINT_ROLLBACK;\n      }else{\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If eStatementOp is non-zero, then a statement transaction needs to\n    ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to\n    ** do so. If this operation returns an error, and the current statement\n    ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the\n    ** current statement error code.\n    */\n    if( eStatementOp ){\n      rc = sqlite3VdbeCloseStatement(p, eStatementOp);\n      if( rc ){\n        if( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ){\n          p->rc = rc;\n          sqlite3DbFree(db, p->zErrMsg);\n          p->zErrMsg = 0;\n        }\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If this was an INSERT, UPDATE or DELETE and no statement transaction\n    ** has been rolled back, update the database connection change-counter. \n    */\n    if( p->changeCntOn ){\n      if( eStatementOp!=SAVEPOINT_ROLLBACK ){\n        sqlite3VdbeSetChanges(db, p->nChange);\n      }else{\n        sqlite3VdbeSetChanges(db, 0);\n      }\n      p->nChange = 0;\n    }\n\n    /* Release the locks */\n    sqlite3VdbeLeave(p);\n  }\n\n  /* We have successfully halted and closed the VM.  Record this fact. */\n  if( p->pc>=0 ){\n    db->nVdbeActive--;\n    if( !p->readOnly ) db->nVdbeWrite--;\n    if( p->bIsReader ) db->nVdbeRead--;\n    assert( db->nVdbeActive>=db->nVdbeRead );\n    assert( db->nVdbeRead>=db->nVdbeWrite );\n    assert( db->nVdbeWrite>=0 );\n  }\n  p->magic = VDBE_MAGIC_HALT;\n  checkActiveVdbeCnt(db);\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n\n  /* If the auto-commit flag is set to true, then any locks that were held\n  ** by connection db have now been released. Call sqlite3ConnectionUnlocked() \n  ** to invoke any required unlock-notify callbacks.\n  */\n  if( db->autoCommit ){\n    sqlite3ConnectionUnlocked(db);\n  }\n\n  assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );\n  return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);\n}\n\n\n/*\n** Each VDBE holds the result of the most recent sqlite3_step() call\n** in p->rc.  This routine sets that result back to SQLITE_OK.\n*/\nSQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe *p){\n  p->rc = SQLITE_OK;\n}\n\n/*\n** Copy the error code and error message belonging to the VDBE passed\n** as the first argument to its database handle (so that they will be \n** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).\n**\n** This function does not clear the VDBE error code or message, just\n** copies them to the database handle.\n*/\nSQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){\n  sqlite3 *db = p->db;\n  int rc = p->rc;\n  if( p->zErrMsg ){\n    db->bBenignMalloc++;\n    sqlite3BeginBenignMalloc();\n    if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);\n    sqlite3EndBenignMalloc();\n    db->bBenignMalloc--;\n  }else if( db->pErr ){\n    sqlite3ValueSetNull(db->pErr);\n  }\n  db->errCode = rc;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SQLLOG\n/*\n** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run, \n** invoke it.\n*/\nstatic void vdbeInvokeSqllog(Vdbe *v){\n  if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){\n    char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);\n    assert( v->db->init.busy==0 );\n    if( zExpanded ){\n      sqlite3GlobalConfig.xSqllog(\n          sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1\n      );\n      sqlite3DbFree(v->db, zExpanded);\n    }\n  }\n}\n#else\n# define vdbeInvokeSqllog(x)\n#endif\n\n/*\n** Clean up a VDBE after execution but do not delete the VDBE just yet.\n** Write any error messages into *pzErrMsg.  Return the result code.\n**\n** After this routine is run, the VDBE should be ready to be executed\n** again.\n**\n** To look at it another way, this routine resets the state of the\n** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to\n** VDBE_MAGIC_INIT.\n*/\nSQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n\n  sqlite3 *db;\n  db = p->db;\n\n  /* If the VM did not run to completion or if it encountered an\n  ** error, then it might not have been halted properly.  So halt\n  ** it now.\n  */\n  sqlite3VdbeHalt(p);\n\n  /* If the VDBE has be run even partially, then transfer the error code\n  ** and error message from the VDBE into the main database structure.  But\n  ** if the VDBE has just been set to run but has not actually executed any\n  ** instructions yet, leave the main database error information unchanged.\n  */\n  if( p->pc>=0 ){\n    vdbeInvokeSqllog(p);\n    sqlite3VdbeTransferError(p);\n    if( p->runOnlyOnce ) p->expired = 1;\n  }else if( p->rc && p->expired ){\n    /* The expired flag was set on the VDBE before the first call\n    ** to sqlite3_step(). For consistency (since sqlite3_step() was\n    ** called), set the database error in this case as well.\n    */\n    sqlite3ErrorWithMsg(db, p->rc, p->zErrMsg ? \"%s\" : 0, p->zErrMsg);\n  }\n\n  /* Reset register contents and reclaim error message memory.\n  */\n#ifdef SQLITE_DEBUG\n  /* Execute assert() statements to ensure that the Vdbe.apCsr[] and \n  ** Vdbe.aMem[] arrays have already been cleaned up.  */\n  if( p->apCsr ) for(i=0; i<p->nCursor; i++) assert( p->apCsr[i]==0 );\n  if( p->aMem ){\n    for(i=0; i<p->nMem; i++) assert( p->aMem[i].flags==MEM_Undefined );\n  }\n#endif\n  sqlite3DbFree(db, p->zErrMsg);\n  p->zErrMsg = 0;\n  p->pResultSet = 0;\n\n  /* Save profiling information from this VDBE run.\n  */\n#ifdef VDBE_PROFILE\n  {\n    FILE *out = fopen(\"vdbe_profile.out\", \"a\");\n    if( out ){\n      fprintf(out, \"---- \");\n      for(i=0; i<p->nOp; i++){\n        fprintf(out, \"%02x\", p->aOp[i].opcode);\n      }\n      fprintf(out, \"\\n\");\n      if( p->zSql ){\n        char c, pc = 0;\n        fprintf(out, \"-- \");\n        for(i=0; (c = p->zSql[i])!=0; i++){\n          if( pc=='\\n' ) fprintf(out, \"-- \");\n          putc(c, out);\n          pc = c;\n        }\n        if( pc!='\\n' ) fprintf(out, \"\\n\");\n      }\n      for(i=0; i<p->nOp; i++){\n        char zHdr[100];\n        sqlite3_snprintf(sizeof(zHdr), zHdr, \"%6u %12llu %8llu \",\n           p->aOp[i].cnt,\n           p->aOp[i].cycles,\n           p->aOp[i].cnt>0 ? p->aOp[i].cycles/p->aOp[i].cnt : 0\n        );\n        fprintf(out, \"%s\", zHdr);\n        sqlite3VdbePrintOp(out, i, &p->aOp[i]);\n      }\n      fclose(out);\n    }\n  }\n#endif\n  p->magic = VDBE_MAGIC_RESET;\n  return p->rc & db->errMask;\n}\n \n/*\n** Clean up and delete a VDBE after execution.  Return an integer which is\n** the result code.  Write any error message text into *pzErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){\n  int rc = SQLITE_OK;\n  if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){\n    rc = sqlite3VdbeReset(p);\n    assert( (rc & p->db->errMask)==rc );\n  }\n  sqlite3VdbeDelete(p);\n  return rc;\n}\n\n/*\n** If parameter iOp is less than zero, then invoke the destructor for\n** all auxiliary data pointers currently cached by the VM passed as\n** the first argument.\n**\n** Or, if iOp is greater than or equal to zero, then the destructor is\n** only invoked for those auxiliary data pointers created by the user \n** function invoked by the OP_Function opcode at instruction iOp of \n** VM pVdbe, and only then if:\n**\n**    * the associated function parameter is the 32nd or later (counting\n**      from left to right), or\n**\n**    * the corresponding bit in argument mask is clear (where the first\n**      function parameter corresponds to bit 0 etc.).\n*/\nSQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){\n  while( *pp ){\n    AuxData *pAux = *pp;\n    if( (iOp<0)\n     || (pAux->iAuxOp==iOp\n          && pAux->iAuxArg>=0\n          && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))\n    ){\n      testcase( pAux->iAuxArg==31 );\n      if( pAux->xDeleteAux ){\n        pAux->xDeleteAux(pAux->pAux);\n      }\n      *pp = pAux->pNextAux;\n      sqlite3DbFree(db, pAux);\n    }else{\n      pp= &pAux->pNextAux;\n    }\n  }\n}\n\n/*\n** Free all memory associated with the Vdbe passed as the second argument,\n** except for object itself, which is preserved.\n**\n** The difference between this function and sqlite3VdbeDelete() is that\n** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with\n** the database connection and frees the object itself.\n*/\nSQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){\n  SubProgram *pSub, *pNext;\n  assert( p->db==0 || p->db==db );\n  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n  for(pSub=p->pProgram; pSub; pSub=pNext){\n    pNext = pSub->pNext;\n    vdbeFreeOpArray(db, pSub->aOp, pSub->nOp);\n    sqlite3DbFree(db, pSub);\n  }\n  if( p->magic!=VDBE_MAGIC_INIT ){\n    releaseMemArray(p->aVar, p->nVar);\n    sqlite3DbFree(db, p->pVList);\n    sqlite3DbFree(db, p->pFree);\n  }\n  vdbeFreeOpArray(db, p->aOp, p->nOp);\n  sqlite3DbFree(db, p->aColName);\n  sqlite3DbFree(db, p->zSql);\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  {\n    int i;\n    for(i=0; i<p->nScan; i++){\n      sqlite3DbFree(db, p->aScan[i].zName);\n    }\n    sqlite3DbFree(db, p->aScan);\n  }\n#endif\n}\n\n/*\n** Delete an entire VDBE.\n*/\nSQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){\n  sqlite3 *db;\n\n  if( NEVER(p==0) ) return;\n  db = p->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3VdbeClearObject(db, p);\n  if( p->pPrev ){\n    p->pPrev->pNext = p->pNext;\n  }else{\n    assert( db->pVdbe==p );\n    db->pVdbe = p->pNext;\n  }\n  if( p->pNext ){\n    p->pNext->pPrev = p->pPrev;\n  }\n  p->magic = VDBE_MAGIC_DEAD;\n  p->db = 0;\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** The cursor \"p\" has a pending seek operation that has not yet been\n** carried out.  Seek the cursor now.  If an error occurs, return\n** the appropriate error code.\n*/\nstatic int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){\n  int res, rc;\n#ifdef SQLITE_TEST\n  extern int sqlite3_search_count;\n#endif\n  assert( p->deferredMoveto );\n  assert( p->isTable );\n  assert( p->eCurType==CURTYPE_BTREE );\n  rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);\n  if( rc ) return rc;\n  if( res!=0 ) return SQLITE_CORRUPT_BKPT;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  p->deferredMoveto = 0;\n  p->cacheStatus = CACHE_STALE;\n  return SQLITE_OK;\n}\n\n/*\n** Something has moved cursor \"p\" out of place.  Maybe the row it was\n** pointed to was deleted out from under it.  Or maybe the btree was\n** rebalanced.  Whatever the cause, try to restore \"p\" to the place it\n** is supposed to be pointing.  If the row was deleted out from under the\n** cursor, set the cursor to point to a NULL row.\n*/\nstatic int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){\n  int isDifferentRow, rc;\n  assert( p->eCurType==CURTYPE_BTREE );\n  assert( p->uc.pCursor!=0 );\n  assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );\n  rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);\n  p->cacheStatus = CACHE_STALE;\n  if( isDifferentRow ) p->nullRow = 1;\n  return rc;\n}\n\n/*\n** Check to ensure that the cursor is valid.  Restore the cursor\n** if need be.  Return any I/O error from the restore operation.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor *p){\n  assert( p->eCurType==CURTYPE_BTREE );\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the cursor p is ready to read or write the row to which it\n** was last positioned.  Return an error code if an OOM fault or I/O error\n** prevents us from positioning the cursor to its correct position.\n**\n** If a MoveTo operation is pending on the given cursor, then do that\n** MoveTo now.  If no move is pending, check to see if the row has been\n** deleted out from under the cursor and if it has, mark the row as\n** a NULL row.\n**\n** If the cursor is already pointing to the correct row and that row has\n** not been deleted out from under the cursor, then this routine is a no-op.\n*/\nSQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){\n  VdbeCursor *p = *pp;\n  assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );\n  if( p->deferredMoveto ){\n    int iMap;\n    if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 ){\n      *pp = p->pAltCursor;\n      *piCol = iMap - 1;\n      return SQLITE_OK;\n    }\n    return handleDeferredMoveto(p);\n  }\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The following functions:\n**\n** sqlite3VdbeSerialType()\n** sqlite3VdbeSerialTypeLen()\n** sqlite3VdbeSerialLen()\n** sqlite3VdbeSerialPut()\n** sqlite3VdbeSerialGet()\n**\n** encapsulate the code that serializes values for storage in SQLite\n** data and index records. Each serialized value consists of a\n** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned\n** integer, stored as a varint.\n**\n** In an SQLite index record, the serial type is stored directly before\n** the blob of data that it corresponds to. In a table record, all serial\n** types are stored at the start of the record, and the blobs of data at\n** the end. Hence these functions allow the caller to handle the\n** serial-type and data blob separately.\n**\n** The following table describes the various storage classes for data:\n**\n**   serial type        bytes of data      type\n**   --------------     ---------------    ---------------\n**      0                     0            NULL\n**      1                     1            signed integer\n**      2                     2            signed integer\n**      3                     3            signed integer\n**      4                     4            signed integer\n**      5                     6            signed integer\n**      6                     8            signed integer\n**      7                     8            IEEE float\n**      8                     0            Integer constant 0\n**      9                     0            Integer constant 1\n**     10,11                               reserved for expansion\n**    N>=12 and even       (N-12)/2        BLOB\n**    N>=13 and odd        (N-13)/2        text\n**\n** The 8 and 9 types were added in 3.3.0, file format 4.  Prior versions\n** of SQLite will not understand those serial types.\n*/\n\n/*\n** Return the serial-type for the value stored in pMem.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){\n  int flags = pMem->flags;\n  u32 n;\n\n  assert( pLen!=0 );\n  if( flags&MEM_Null ){\n    *pLen = 0;\n    return 0;\n  }\n  if( flags&MEM_Int ){\n    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */\n#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)\n    i64 i = pMem->u.i;\n    u64 u;\n    if( i<0 ){\n      u = ~i;\n    }else{\n      u = i;\n    }\n    if( u<=127 ){\n      if( (i&1)==i && file_format>=4 ){\n        *pLen = 0;\n        return 8+(u32)u;\n      }else{\n        *pLen = 1;\n        return 1;\n      }\n    }\n    if( u<=32767 ){ *pLen = 2; return 2; }\n    if( u<=8388607 ){ *pLen = 3; return 3; }\n    if( u<=2147483647 ){ *pLen = 4; return 4; }\n    if( u<=MAX_6BYTE ){ *pLen = 6; return 5; }\n    *pLen = 8;\n    return 6;\n  }\n  if( flags&MEM_Real ){\n    *pLen = 8;\n    return 7;\n  }\n  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );\n  assert( pMem->n>=0 );\n  n = (u32)pMem->n;\n  if( flags & MEM_Zero ){\n    n += pMem->u.nZero;\n  }\n  *pLen = n;\n  return ((n*2) + 12 + ((flags&MEM_Str)!=0));\n}\n\n/*\n** The sizes for serial types less than 128\n*/\nstatic const u8 sqlite3SmallTypeSizes[] = {\n        /*  0   1   2   3   4   5   6   7   8   9 */   \n/*   0 */   0,  1,  2,  3,  4,  6,  8,  8,  0,  0,\n/*  10 */   0,  0,  0,  0,  1,  1,  2,  2,  3,  3,\n/*  20 */   4,  4,  5,  5,  6,  6,  7,  7,  8,  8,\n/*  30 */   9,  9, 10, 10, 11, 11, 12, 12, 13, 13,\n/*  40 */  14, 14, 15, 15, 16, 16, 17, 17, 18, 18,\n/*  50 */  19, 19, 20, 20, 21, 21, 22, 22, 23, 23,\n/*  60 */  24, 24, 25, 25, 26, 26, 27, 27, 28, 28,\n/*  70 */  29, 29, 30, 30, 31, 31, 32, 32, 33, 33,\n/*  80 */  34, 34, 35, 35, 36, 36, 37, 37, 38, 38,\n/*  90 */  39, 39, 40, 40, 41, 41, 42, 42, 43, 43,\n/* 100 */  44, 44, 45, 45, 46, 46, 47, 47, 48, 48,\n/* 110 */  49, 49, 50, 50, 51, 51, 52, 52, 53, 53,\n/* 120 */  54, 54, 55, 55, 56, 56, 57, 57\n};\n\n/*\n** Return the length of the data corresponding to the supplied serial-type.\n*/\nSQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32 serial_type){\n  if( serial_type>=128 ){\n    return (serial_type-12)/2;\n  }else{\n    assert( serial_type<12 \n            || sqlite3SmallTypeSizes[serial_type]==(serial_type - 12)/2 );\n    return sqlite3SmallTypeSizes[serial_type];\n  }\n}\nSQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8 serial_type){\n  assert( serial_type<128 );\n  return sqlite3SmallTypeSizes[serial_type];  \n}\n\n/*\n** If we are on an architecture with mixed-endian floating \n** points (ex: ARM7) then swap the lower 4 bytes with the \n** upper 4 bytes.  Return the result.\n**\n** For most architectures, this is a no-op.\n**\n** (later):  It is reported to me that the mixed-endian problem\n** on ARM7 is an issue with GCC, not with the ARM7 chip.  It seems\n** that early versions of GCC stored the two words of a 64-bit\n** float in the wrong order.  And that error has been propagated\n** ever since.  The blame is not necessarily with GCC, though.\n** GCC might have just copying the problem from a prior compiler.\n** I am also told that newer versions of GCC that follow a different\n** ABI get the byte order right.\n**\n** Developers using SQLite on an ARM7 should compile and run their\n** application using -DSQLITE_DEBUG=1 at least once.  With DEBUG\n** enabled, some asserts below will ensure that the byte order of\n** floating point values is correct.\n**\n** (2007-08-30)  Frank van Vugt has studied this problem closely\n** and has send his findings to the SQLite developers.  Frank\n** writes that some Linux kernels offer floating point hardware\n** emulation that uses only 32-bit mantissas instead of a full \n** 48-bits as required by the IEEE standard.  (This is the\n** CONFIG_FPE_FASTFPE option.)  On such systems, floating point\n** byte swapping becomes very complicated.  To avoid problems,\n** the necessary byte swapping is carried out using a 64-bit integer\n** rather than a 64-bit float.  Frank assures us that the code here\n** works for him.  We, the developers, have no way to independently\n** verify this, but Frank seems to know what he is talking about\n** so we trust him.\n*/\n#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\nstatic u64 floatSwap(u64 in){\n  union {\n    u64 r;\n    u32 i[2];\n  } u;\n  u32 t;\n\n  u.r = in;\n  t = u.i[0];\n  u.i[0] = u.i[1];\n  u.i[1] = t;\n  return u.r;\n}\n# define swapMixedEndianFloat(X)  X = floatSwap(X)\n#else\n# define swapMixedEndianFloat(X)\n#endif\n\n/*\n** Write the serialized data blob for the value stored in pMem into \n** buf. It is assumed that the caller has allocated sufficient space.\n** Return the number of bytes written.\n**\n** nBuf is the amount of space left in buf[].  The caller is responsible\n** for allocating enough space to buf[] to hold the entire field, exclusive\n** of the pMem->u.nZero bytes for a MEM_Zero value.\n**\n** Return the number of bytes actually written into buf[].  The number\n** of bytes in the zero-filled tail is included in the return value only\n** if those bytes were zeroed in buf[].\n*/ \nSQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){\n  u32 len;\n\n  /* Integer and Real */\n  if( serial_type<=7 && serial_type>0 ){\n    u64 v;\n    u32 i;\n    if( serial_type==7 ){\n      assert( sizeof(v)==sizeof(pMem->u.r) );\n      memcpy(&v, &pMem->u.r, sizeof(v));\n      swapMixedEndianFloat(v);\n    }else{\n      v = pMem->u.i;\n    }\n    len = i = sqlite3SmallTypeSizes[serial_type];\n    assert( i>0 );\n    do{\n      buf[--i] = (u8)(v&0xFF);\n      v >>= 8;\n    }while( i );\n    return len;\n  }\n\n  /* String or blob */\n  if( serial_type>=12 ){\n    assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)\n             == (int)sqlite3VdbeSerialTypeLen(serial_type) );\n    len = pMem->n;\n    if( len>0 ) memcpy(buf, pMem->z, len);\n    return len;\n  }\n\n  /* NULL or constants 0 or 1 */\n  return 0;\n}\n\n/* Input \"x\" is a sequence of unsigned characters that represent a\n** big-endian integer.  Return the equivalent native integer\n*/\n#define ONE_BYTE_INT(x)    ((i8)(x)[0])\n#define TWO_BYTE_INT(x)    (256*(i8)((x)[0])|(x)[1])\n#define THREE_BYTE_INT(x)  (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2])\n#define FOUR_BYTE_UINT(x)  (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n#define FOUR_BYTE_INT(x) (16777216*(i8)((x)[0])|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Deserialize the data blob pointed to by buf as serial type serial_type\n** and store the result in pMem.  Return the number of bytes read.\n**\n** This function is implemented as two separate routines for performance.\n** The few cases that require local variables are broken out into a separate\n** routine so that in most cases the overhead of moving the stack pointer\n** is avoided.\n*/ \nstatic u32 SQLITE_NOINLINE serialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  u64 x = FOUR_BYTE_UINT(buf);\n  u32 y = FOUR_BYTE_UINT(buf+4);\n  x = (x<<32) + y;\n  if( serial_type==6 ){\n    /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit\n    ** twos-complement integer. */\n    pMem->u.i = *(i64*)&x;\n    pMem->flags = MEM_Int;\n    testcase( pMem->u.i<0 );\n  }else{\n    /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit\n    ** floating point number. */\n#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    /* Verify that integers and floating point values use the same\n    ** byte order.  Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is\n    ** defined that 64-bit floating point values really are mixed\n    ** endian.\n    */\n    static const u64 t1 = ((u64)0x3ff00000)<<32;\n    static const double r1 = 1.0;\n    u64 t2 = t1;\n    swapMixedEndianFloat(t2);\n    assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );\n#endif\n    assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );\n    swapMixedEndianFloat(x);\n    memcpy(&pMem->u.r, &x, sizeof(x));\n    pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;\n  }\n  return 8;\n}\nSQLITE_PRIVATE u32 sqlite3VdbeSerialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  switch( serial_type ){\n    case 10:   /* Reserved for future use */\n    case 11:   /* Reserved for future use */\n    case 0: {  /* Null */\n      /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */\n      pMem->flags = MEM_Null;\n      break;\n    }\n    case 1: {\n      /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement\n      ** integer. */\n      pMem->u.i = ONE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 1;\n    }\n    case 2: { /* 2-byte signed integer */\n      /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit\n      ** twos-complement integer. */\n      pMem->u.i = TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 2;\n    }\n    case 3: { /* 3-byte signed integer */\n      /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit\n      ** twos-complement integer. */\n      pMem->u.i = THREE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 3;\n    }\n    case 4: { /* 4-byte signed integer */\n      /* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_INT(buf);\n#ifdef __HP_cc \n      /* Work around a sign-extension bug in the HP compiler for HP/UX */\n      if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;\n#endif\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 4;\n    }\n    case 5: { /* 6-byte signed integer */\n      /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 6;\n    }\n    case 6:   /* 8-byte signed integer */\n    case 7: { /* IEEE floating point */\n      /* These use local variables, so do them in a separate routine\n      ** to avoid having to move the frame pointer in the common case */\n      return serialGet(buf,serial_type,pMem);\n    }\n    case 8:    /* Integer 0 */\n    case 9: {  /* Integer 1 */\n      /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */\n      /* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */\n      pMem->u.i = serial_type-8;\n      pMem->flags = MEM_Int;\n      return 0;\n    }\n    default: {\n      /* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in\n      ** length.\n      ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and\n      ** (N-13)/2 bytes in length. */\n      static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };\n      pMem->z = (char *)buf;\n      pMem->n = (serial_type-12)/2;\n      pMem->flags = aFlag[serial_type&1];\n      return pMem->n;\n    }\n  }\n  return 0;\n}\n/*\n** This routine is used to allocate sufficient space for an UnpackedRecord\n** structure large enough to be used with sqlite3VdbeRecordUnpack() if\n** the first argument is a pointer to KeyInfo structure pKeyInfo.\n**\n** The space is either allocated using sqlite3DbMallocRaw() or from within\n** the unaligned buffer passed via the second and third arguments (presumably\n** stack space). If the former, then *ppFree is set to a pointer that should\n** be eventually freed by the caller using sqlite3DbFree(). Or, if the \n** allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL\n** before returning.\n**\n** If an OOM error occurs, NULL is returned.\n*/\nSQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(\n  KeyInfo *pKeyInfo               /* Description of the record */\n){\n  UnpackedRecord *p;              /* Unpacked record to return */\n  int nByte;                      /* Number of bytes required for *p */\n  nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);\n  p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);\n  if( !p ) return 0;\n  p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];\n  assert( pKeyInfo->aSortOrder!=0 );\n  p->pKeyInfo = pKeyInfo;\n  p->nField = pKeyInfo->nKeyField + 1;\n  return p;\n}\n\n/*\n** Given the nKey-byte encoding of a record in pKey[], populate the \n** UnpackedRecord structure indicated by the fourth argument with the\n** contents of the decoded record.\n*/ \nSQLITE_PRIVATE void sqlite3VdbeRecordUnpack(\n  KeyInfo *pKeyInfo,     /* Information about the record format */\n  int nKey,              /* Size of the binary record */\n  const void *pKey,      /* The binary record */\n  UnpackedRecord *p      /* Populate this structure before returning. */\n){\n  const unsigned char *aKey = (const unsigned char *)pKey;\n  int d; \n  u32 idx;                        /* Offset in aKey[] to read from */\n  u16 u;                          /* Unsigned loop counter */\n  u32 szHdr;\n  Mem *pMem = p->aMem;\n\n  p->default_rc = 0;\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  idx = getVarint32(aKey, szHdr);\n  d = szHdr;\n  u = 0;\n  while( idx<szHdr && d<=nKey ){\n    u32 serial_type;\n\n    idx += getVarint32(&aKey[idx], serial_type);\n    pMem->enc = pKeyInfo->enc;\n    pMem->db = pKeyInfo->db;\n    /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */\n    pMem->szMalloc = 0;\n    pMem->z = 0;\n    d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);\n    pMem++;\n    if( (++u)>=p->nField ) break;\n  }\n  assert( u<=pKeyInfo->nKeyField + 1 );\n  p->nField = u;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function compares two index or table record keys in the same way\n** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),\n** this function deserializes and compares values using the\n** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used\n** in assert() statements to ensure that the optimized code in\n** sqlite3VdbeRecordCompare() returns results with these two primitives.\n**\n** Return true if the result of comparison is equivalent to desiredResult.\n** Return false if there is a disagreement.\n*/\nstatic int vdbeRecordCompareDebug(\n  int nKey1, const void *pKey1, /* Left key */\n  const UnpackedRecord *pPKey2, /* Right key */\n  int desiredResult             /* Correct answer */\n){\n  u32 d1;            /* Offset into aKey[] of next data element */\n  u32 idx1;          /* Offset into aKey[] of next header element */\n  u32 szHdr1;        /* Number of bytes in header */\n  int i = 0;\n  int rc = 0;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  KeyInfo *pKeyInfo;\n  Mem mem1;\n\n  pKeyInfo = pPKey2->pKeyInfo;\n  if( pKeyInfo->db==0 ) return 1;\n  mem1.enc = pKeyInfo->enc;\n  mem1.db = pKeyInfo->db;\n  /* mem1.flags = 0;  // Will be initialized by sqlite3VdbeSerialGet() */\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n\n  /* Compilers may complain that mem1.u.i is potentially uninitialized.\n  ** We could initialize it, as shown here, to silence those complaints.\n  ** But in fact, mem1.u.i will never actually be used uninitialized, and doing \n  ** the unnecessary initialization has a measurable negative performance\n  ** impact, since this routine is a very high runner.  And so, we choose\n  ** to ignore the compiler warnings and leave this variable uninitialized.\n  */\n  /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */\n  \n  idx1 = getVarint32(aKey1, szHdr1);\n  if( szHdr1>98307 ) return SQLITE_CORRUPT;\n  d1 = szHdr1;\n  assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );\n  assert( pKeyInfo->aSortOrder!=0 );\n  assert( pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type1;\n\n    /* Read the serial types for the next element in each key. */\n    idx1 += getVarint32( aKey1+idx1, serial_type1 );\n\n    /* Verify that there is enough key space remaining to avoid\n    ** a buffer overread.  The \"d1+serial_type1+2\" subexpression will\n    ** always be greater than or equal to the amount of required key space.\n    ** Use that approximation to avoid the more expensive call to\n    ** sqlite3VdbeSerialTypeLen() in the common case.\n    */\n    if( d1+serial_type1+2>(u32)nKey1\n     && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 \n    ){\n      break;\n    }\n\n    /* Extract the values to be compared.\n    */\n    d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);\n\n    /* Do the comparison\n    */\n    rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);\n    if( rc!=0 ){\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      if( pKeyInfo->aSortOrder[i] ){\n        rc = -rc;  /* Invert the result for DESC sort order. */\n      }\n      goto debugCompareEnd;\n    }\n    i++;\n  }while( idx1<szHdr1 && i<pPKey2->nField );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).\n  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  rc = pPKey2->default_rc;\n\ndebugCompareEnd:\n  if( desiredResult==0 && rc==0 ) return 1;\n  if( desiredResult<0 && rc<0 ) return 1;\n  if( desiredResult>0 && rc>0 ) return 1;\n  if( CORRUPT_DB ) return 1;\n  if( pKeyInfo->db->mallocFailed ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Count the number of fields (a.k.a. columns) in the record given by\n** pKey,nKey.  The verify that this count is less than or equal to the\n** limit given by pKeyInfo->nAllField.\n**\n** If this constraint is not satisfied, it means that the high-speed\n** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will\n** not work correctly.  If this assert() ever fires, it probably means\n** that the KeyInfo.nKeyField or KeyInfo.nAllField values were computed\n** incorrectly.\n*/\nstatic void vdbeAssertFieldCountWithinLimits(\n  int nKey, const void *pKey,   /* The record to verify */ \n  const KeyInfo *pKeyInfo       /* Compare size with this KeyInfo */\n){\n  int nField = 0;\n  u32 szHdr;\n  u32 idx;\n  u32 notUsed;\n  const unsigned char *aKey = (const unsigned char*)pKey;\n\n  if( CORRUPT_DB ) return;\n  idx = getVarint32(aKey, szHdr);\n  assert( nKey>=0 );\n  assert( szHdr<=(u32)nKey );\n  while( idx<szHdr ){\n    idx += getVarint32(aKey+idx, notUsed);\n    nField++;\n  }\n  assert( nField <= pKeyInfo->nAllField );\n}\n#else\n# define vdbeAssertFieldCountWithinLimits(A,B,C)\n#endif\n\n/*\n** Both *pMem1 and *pMem2 contain string values. Compare the two values\n** using the collation sequence pColl. As usual, return a negative , zero\n** or positive value if *pMem1 is less than, equal to or greater than \n** *pMem2, respectively. Similar in spirit to \"rc = (*pMem1) - (*pMem2);\".\n*/\nstatic int vdbeCompareMemString(\n  const Mem *pMem1,\n  const Mem *pMem2,\n  const CollSeq *pColl,\n  u8 *prcErr                      /* If an OOM occurs, set to SQLITE_NOMEM */\n){\n  if( pMem1->enc==pColl->enc ){\n    /* The strings are already in the correct encoding.  Call the\n     ** comparison function directly */\n    return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);\n  }else{\n    int rc;\n    const void *v1, *v2;\n    Mem c1;\n    Mem c2;\n    sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);\n    sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);\n    sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);\n    sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);\n    v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);\n    v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);\n    if( (v1==0 || v2==0) ){\n      if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;\n      rc = 0;\n    }else{\n      rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);\n    }\n    sqlite3VdbeMemRelease(&c1);\n    sqlite3VdbeMemRelease(&c2);\n    return rc;\n  }\n}\n\n/*\n** The input pBlob is guaranteed to be a Blob that is not marked\n** with MEM_Zero.  Return true if it could be a zero-blob.\n*/\nstatic int isAllZero(const char *z, int n){\n  int i;\n  for(i=0; i<n; i++){\n    if( z[i] ) return 0;\n  }\n  return 1;\n}\n\n/*\n** Compare two blobs.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second, respectively.\n** If one blob is a prefix of the other, then the shorter is the lessor.\n*/\nstatic SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){\n  int c;\n  int n1 = pB1->n;\n  int n2 = pB2->n;\n\n  /* It is possible to have a Blob value that has some non-zero content\n  ** followed by zero content.  But that only comes up for Blobs formed\n  ** by the OP_MakeRecord opcode, and such Blobs never get passed into\n  ** sqlite3MemCompare(). */\n  assert( (pB1->flags & MEM_Zero)==0 || n1==0 );\n  assert( (pB2->flags & MEM_Zero)==0 || n2==0 );\n\n  if( (pB1->flags|pB2->flags) & MEM_Zero ){\n    if( pB1->flags & pB2->flags & MEM_Zero ){\n      return pB1->u.nZero - pB2->u.nZero;\n    }else if( pB1->flags & MEM_Zero ){\n      if( !isAllZero(pB2->z, pB2->n) ) return -1;\n      return pB1->u.nZero - n2;\n    }else{\n      if( !isAllZero(pB1->z, pB1->n) ) return +1;\n      return n1 - pB2->u.nZero;\n    }\n  }\n  c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1);\n  if( c ) return c;\n  return n1 - n2;\n}\n\n/*\n** Do a comparison between a 64-bit signed integer and a 64-bit floating-point\n** number.  Return negative, zero, or positive if the first (i64) is less than,\n** equal to, or greater than the second (double).\n*/\nstatic int sqlite3IntFloatCompare(i64 i, double r){\n  if( sizeof(LONGDOUBLE_TYPE)>8 ){\n    LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;\n    if( x<r ) return -1;\n    if( x>r ) return +1;\n    return 0;\n  }else{\n    i64 y;\n    double s;\n    if( r<-9223372036854775808.0 ) return +1;\n    if( r>9223372036854775807.0 ) return -1;\n    y = (i64)r;\n    if( i<y ) return -1;\n    if( i>y ){\n      if( y==SMALLEST_INT64 && r>0.0 ) return -1;\n      return +1;\n    }\n    s = (double)i;\n    if( s<r ) return -1;\n    if( s>r ) return +1;\n    return 0;\n  }\n}\n\n/*\n** Compare the values contained by the two memory cells, returning\n** negative, zero or positive if pMem1 is less than, equal to, or greater\n** than pMem2. Sorting order is NULL's first, followed by numbers (integers\n** and reals) sorted numerically, followed by text ordered by the collating\n** sequence pColl and finally blob's ordered by memcmp().\n**\n** Two NULL values are considered equal by this function.\n*/\nSQLITE_PRIVATE int sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){\n  int f1, f2;\n  int combined_flags;\n\n  f1 = pMem1->flags;\n  f2 = pMem2->flags;\n  combined_flags = f1|f2;\n  assert( (combined_flags & MEM_RowSet)==0 );\n \n  /* If one value is NULL, it is less than the other. If both values\n  ** are NULL, return 0.\n  */\n  if( combined_flags&MEM_Null ){\n    return (f2&MEM_Null) - (f1&MEM_Null);\n  }\n\n  /* At least one of the two values is a number\n  */\n  if( combined_flags&(MEM_Int|MEM_Real) ){\n    if( (f1 & f2 & MEM_Int)!=0 ){\n      if( pMem1->u.i < pMem2->u.i ) return -1;\n      if( pMem1->u.i > pMem2->u.i ) return +1;\n      return 0;\n    }\n    if( (f1 & f2 & MEM_Real)!=0 ){\n      if( pMem1->u.r < pMem2->u.r ) return -1;\n      if( pMem1->u.r > pMem2->u.r ) return +1;\n      return 0;\n    }\n    if( (f1&MEM_Int)!=0 ){\n      if( (f2&MEM_Real)!=0 ){\n        return sqlite3IntFloatCompare(pMem1->u.i, pMem2->u.r);\n      }else{\n        return -1;\n      }\n    }\n    if( (f1&MEM_Real)!=0 ){\n      if( (f2&MEM_Int)!=0 ){\n        return -sqlite3IntFloatCompare(pMem2->u.i, pMem1->u.r);\n      }else{\n        return -1;\n      }\n    }\n    return +1;\n  }\n\n  /* If one value is a string and the other is a blob, the string is less.\n  ** If both are strings, compare using the collating functions.\n  */\n  if( combined_flags&MEM_Str ){\n    if( (f1 & MEM_Str)==0 ){\n      return 1;\n    }\n    if( (f2 & MEM_Str)==0 ){\n      return -1;\n    }\n\n    assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );\n    assert( pMem1->enc==SQLITE_UTF8 || \n            pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );\n\n    /* The collation sequence must be defined at this point, even if\n    ** the user deletes the collation sequence after the vdbe program is\n    ** compiled (this was not always the case).\n    */\n    assert( !pColl || pColl->xCmp );\n\n    if( pColl ){\n      return vdbeCompareMemString(pMem1, pMem2, pColl, 0);\n    }\n    /* If a NULL pointer was passed as the collate function, fall through\n    ** to the blob case and use memcmp().  */\n  }\n \n  /* Both values must be blobs.  Compare using memcmp().  */\n  return sqlite3BlobCompare(pMem1, pMem2);\n}\n\n\n/*\n** The first argument passed to this function is a serial-type that\n** corresponds to an integer - all values between 1 and 9 inclusive \n** except 7. The second points to a buffer containing an integer value\n** serialized according to serial_type. This function deserializes\n** and returns the value.\n*/\nstatic i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){\n  u32 y;\n  assert( CORRUPT_DB || (serial_type>=1 && serial_type<=9 && serial_type!=7) );\n  switch( serial_type ){\n    case 0:\n    case 1:\n      testcase( aKey[0]&0x80 );\n      return ONE_BYTE_INT(aKey);\n    case 2:\n      testcase( aKey[0]&0x80 );\n      return TWO_BYTE_INT(aKey);\n    case 3:\n      testcase( aKey[0]&0x80 );\n      return THREE_BYTE_INT(aKey);\n    case 4: {\n      testcase( aKey[0]&0x80 );\n      y = FOUR_BYTE_UINT(aKey);\n      return (i64)*(int*)&y;\n    }\n    case 5: {\n      testcase( aKey[0]&0x80 );\n      return FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n    }\n    case 6: {\n      u64 x = FOUR_BYTE_UINT(aKey);\n      testcase( aKey[0]&0x80 );\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      return (i64)*(i64*)&x;\n    }\n  }\n\n  return (serial_type - 8);\n}\n\n/*\n** This function compares the two table rows or index records\n** specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero\n** or positive integer if key1 is less than, equal to or \n** greater than key2.  The {nKey1, pKey1} key must be a blob\n** created by the OP_MakeRecord opcode of the VDBE.  The pPKey2\n** key must be a parsed key such as obtained from\n** sqlite3VdbeParseRecord.\n**\n** If argument bSkip is non-zero, it is assumed that the caller has already\n** determined that the first fields of the keys are equal.\n**\n** Key1 and Key2 do not have to contain the same number of fields. If all \n** fields that appear in both keys are equal, then pPKey2->default_rc is \n** returned.\n**\n** If database corruption is discovered, set pPKey2->errCode to \n** SQLITE_CORRUPT and return 0. If an OOM error is encountered, \n** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the\n** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).\n*/\nSQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2,         /* Right key */\n  int bSkip                       /* If true, skip the first field */\n){\n  u32 d1;                         /* Offset into aKey[] of next data element */\n  int i;                          /* Index of next field to compare */\n  u32 szHdr1;                     /* Size of record header in bytes */\n  u32 idx1;                       /* Offset of first type in header */\n  int rc = 0;                     /* Return value */\n  Mem *pRhs = pPKey2->aMem;       /* Next field of pPKey2 to compare */\n  KeyInfo *pKeyInfo = pPKey2->pKeyInfo;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  Mem mem1;\n\n  /* If bSkip is true, then the caller has already determined that the first\n  ** two elements in the keys are equal. Fix the various stack variables so\n  ** that this routine begins comparing at the second field. */\n  if( bSkip ){\n    u32 s1;\n    idx1 = 1 + getVarint32(&aKey1[1], s1);\n    szHdr1 = aKey1[0];\n    d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1);\n    i = 1;\n    pRhs++;\n  }else{\n    idx1 = getVarint32(aKey1, szHdr1);\n    d1 = szHdr1;\n    if( d1>(unsigned)nKey1 ){ \n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;  /* Corruption */\n    }\n    i = 0;\n  }\n\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n  assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField \n       || CORRUPT_DB );\n  assert( pPKey2->pKeyInfo->aSortOrder!=0 );\n  assert( pPKey2->pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type;\n\n    /* RHS is an integer */\n    if( pRhs->flags & MEM_Int ){\n      serial_type = aKey1[idx1];\n      testcase( serial_type==12 );\n      if( serial_type>=10 ){\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else if( serial_type==7 ){\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);\n      }else{\n        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);\n        i64 rhs = pRhs->u.i;\n        if( lhs<rhs ){\n          rc = -1;\n        }else if( lhs>rhs ){\n          rc = +1;\n        }\n      }\n    }\n\n    /* RHS is real */\n    else if( pRhs->flags & MEM_Real ){\n      serial_type = aKey1[idx1];\n      if( serial_type>=10 ){\n        /* Serial types 12 or greater are strings and blobs (greater than\n        ** numbers). Types 10 and 11 are currently \"reserved for future \n        ** use\", so it doesn't really matter what the results of comparing\n        ** them to numberic values are.  */\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else{\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        if( serial_type==7 ){\n          if( mem1.u.r<pRhs->u.r ){\n            rc = -1;\n          }else if( mem1.u.r>pRhs->u.r ){\n            rc = +1;\n          }\n        }else{\n          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);\n        }\n      }\n    }\n\n    /* RHS is a string */\n    else if( pRhs->flags & MEM_Str ){\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 ){\n        rc = -1;\n      }else if( !(serial_type & 0x01) ){\n        rc = +1;\n      }else{\n        mem1.n = (serial_type - 12) / 2;\n        testcase( (d1+mem1.n)==(unsigned)nKey1 );\n        testcase( (d1+mem1.n+1)==(unsigned)nKey1 );\n        if( (d1+mem1.n) > (unsigned)nKey1 ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pKeyInfo->aColl[i] ){\n          mem1.enc = pKeyInfo->enc;\n          mem1.db = pKeyInfo->db;\n          mem1.flags = MEM_Str;\n          mem1.z = (char*)&aKey1[d1];\n          rc = vdbeCompareMemString(\n              &mem1, pRhs, pKeyInfo->aColl[i], &pPKey2->errCode\n          );\n        }else{\n          int nCmp = MIN(mem1.n, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = mem1.n - pRhs->n; \n        }\n      }\n    }\n\n    /* RHS is a blob */\n    else if( pRhs->flags & MEM_Blob ){\n      assert( (pRhs->flags & MEM_Zero)==0 || pRhs->n==0 );\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 || (serial_type & 0x01) ){\n        rc = -1;\n      }else{\n        int nStr = (serial_type - 12) / 2;\n        testcase( (d1+nStr)==(unsigned)nKey1 );\n        testcase( (d1+nStr+1)==(unsigned)nKey1 );\n        if( (d1+nStr) > (unsigned)nKey1 ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pRhs->flags & MEM_Zero ){\n          if( !isAllZero((const char*)&aKey1[d1],nStr) ){\n            rc = 1;\n          }else{\n            rc = nStr - pRhs->u.nZero;\n          }\n        }else{\n          int nCmp = MIN(nStr, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = nStr - pRhs->n;\n        }\n      }\n    }\n\n    /* RHS is null */\n    else{\n      serial_type = aKey1[idx1];\n      rc = (serial_type!=0);\n    }\n\n    if( rc!=0 ){\n      if( pKeyInfo->aSortOrder[i] ){\n        rc = -rc;\n      }\n      assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      return rc;\n    }\n\n    i++;\n    pRhs++;\n    d1 += sqlite3VdbeSerialTypeLen(serial_type);\n    idx1 += sqlite3VarintLen(serial_type);\n  }while( idx1<(unsigned)szHdr1 && i<pPKey2->nField && d1<=(unsigned)nKey1 );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one or both of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  assert( CORRUPT_DB \n       || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc) \n       || pKeyInfo->db->mallocFailed\n  );\n  pPKey2->eqSeen = 1;\n  return pPKey2->default_rc;\n}\nSQLITE_PRIVATE int sqlite3VdbeRecordCompare(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2          /* Right key */\n){\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);\n}\n\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is an integer, and (b) the \n** size-of-header varint at the start of (pKey1/nKey1) fits in a single\n** byte (i.e. is less than 128).\n**\n** To avoid concerns about buffer overreads, this routine is only used\n** on schemas where the maximum valid header size is 63 bytes or less.\n*/\nstatic int vdbeRecordCompareInt(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F];\n  int serial_type = ((const u8*)pKey1)[1];\n  int res;\n  u32 y;\n  u64 x;\n  i64 v;\n  i64 lhs;\n\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );\n  switch( serial_type ){\n    case 1: { /* 1-byte signed integer */\n      lhs = ONE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 2: { /* 2-byte signed integer */\n      lhs = TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 3: { /* 3-byte signed integer */\n      lhs = THREE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 4: { /* 4-byte signed integer */\n      y = FOUR_BYTE_UINT(aKey);\n      lhs = (i64)*(int*)&y;\n      testcase( lhs<0 );\n      break;\n    }\n    case 5: { /* 6-byte signed integer */\n      lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 6: { /* 8-byte signed integer */\n      x = FOUR_BYTE_UINT(aKey);\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      lhs = *(i64*)&x;\n      testcase( lhs<0 );\n      break;\n    }\n    case 8: \n      lhs = 0;\n      break;\n    case 9:\n      lhs = 1;\n      break;\n\n    /* This case could be removed without changing the results of running\n    ** this code. Including it causes gcc to generate a faster switch \n    ** statement (since the range of switch targets now starts at zero and\n    ** is contiguous) but does not cause any duplicate code to be generated\n    ** (as gcc is clever enough to combine the two like cases). Other \n    ** compilers might be similar.  */ \n    case 0: case 7:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n\n    default:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n  }\n\n  v = pPKey2->aMem[0].u.i;\n  if( v>lhs ){\n    res = pPKey2->r1;\n  }else if( v<lhs ){\n    res = pPKey2->r2;\n  }else if( pPKey2->nField>1 ){\n    /* The first fields of the two keys are equal. Compare the trailing \n    ** fields.  */\n    res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n  }else{\n    /* The first fields of the two keys are equal and there are no trailing\n    ** fields. Return pPKey2->default_rc in this case. */\n    res = pPKey2->default_rc;\n    pPKey2->eqSeen = 1;\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res) );\n  return res;\n}\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is a string, that (b) the first field\n** uses the collation sequence BINARY and (c) that the size-of-header varint \n** at the start of (pKey1/nKey1) fits in a single byte.\n*/\nstatic int vdbeRecordCompareString(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey1 = (const u8*)pKey1;\n  int serial_type;\n  int res;\n\n  assert( pPKey2->aMem[0].flags & MEM_Str );\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  getVarint32(&aKey1[1], serial_type);\n  if( serial_type<12 ){\n    res = pPKey2->r1;      /* (pKey1/nKey1) is a number or a null */\n  }else if( !(serial_type & 0x01) ){ \n    res = pPKey2->r2;      /* (pKey1/nKey1) is a blob */\n  }else{\n    int nCmp;\n    int nStr;\n    int szHdr = aKey1[0];\n\n    nStr = (serial_type-12) / 2;\n    if( (szHdr + nStr) > nKey1 ){\n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;    /* Corruption */\n    }\n    nCmp = MIN( pPKey2->aMem[0].n, nStr );\n    res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);\n\n    if( res==0 ){\n      res = nStr - pPKey2->aMem[0].n;\n      if( res==0 ){\n        if( pPKey2->nField>1 ){\n          res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n        }else{\n          res = pPKey2->default_rc;\n          pPKey2->eqSeen = 1;\n        }\n      }else if( res>0 ){\n        res = pPKey2->r2;\n      }else{\n        res = pPKey2->r1;\n      }\n    }else if( res>0 ){\n      res = pPKey2->r2;\n    }else{\n      res = pPKey2->r1;\n    }\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)\n       || CORRUPT_DB\n       || pPKey2->pKeyInfo->db->mallocFailed\n  );\n  return res;\n}\n\n/*\n** Return a pointer to an sqlite3VdbeRecordCompare() compatible function\n** suitable for comparing serialized records to the unpacked record passed\n** as the only argument.\n*/\nSQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){\n  /* varintRecordCompareInt() and varintRecordCompareString() both assume\n  ** that the size-of-header varint that occurs at the start of each record\n  ** fits in a single byte (i.e. is 127 or less). varintRecordCompareInt()\n  ** also assumes that it is safe to overread a buffer by at least the \n  ** maximum possible legal header size plus 8 bytes. Because there is\n  ** guaranteed to be at least 74 (but not 136) bytes of padding following each\n  ** buffer passed to varintRecordCompareInt() this makes it convenient to\n  ** limit the size of the header to 64 bytes in cases where the first field\n  ** is an integer.\n  **\n  ** The easiest way to enforce this limit is to consider only records with\n  ** 13 fields or less. If the first field is an integer, the maximum legal\n  ** header size is (12*5 + 1 + 1) bytes.  */\n  if( p->pKeyInfo->nAllField<=13 ){\n    int flags = p->aMem[0].flags;\n    if( p->pKeyInfo->aSortOrder[0] ){\n      p->r1 = 1;\n      p->r2 = -1;\n    }else{\n      p->r1 = -1;\n      p->r2 = 1;\n    }\n    if( (flags & MEM_Int) ){\n      return vdbeRecordCompareInt;\n    }\n    testcase( flags & MEM_Real );\n    testcase( flags & MEM_Null );\n    testcase( flags & MEM_Blob );\n    if( (flags & (MEM_Real|MEM_Null|MEM_Blob))==0 && p->pKeyInfo->aColl[0]==0 ){\n      assert( flags & MEM_Str );\n      return vdbeRecordCompareString;\n    }\n  }\n\n  return sqlite3VdbeRecordCompare;\n}\n\n/*\n** pCur points at an index entry created using the OP_MakeRecord opcode.\n** Read the rowid (the last field in the record) and store it in *rowid.\n** Return SQLITE_OK if everything works, or an error code otherwise.\n**\n** pCur might be pointing to text obtained from a corrupt database file.\n** So the content cannot be trusted.  Do appropriate checks on the content.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){\n  i64 nCellKey = 0;\n  int rc;\n  u32 szHdr;        /* Size of the header */\n  u32 typeRowid;    /* Serial type of the rowid */\n  u32 lenRowid;     /* Size of the rowid */\n  Mem m, v;\n\n  /* Get the size of the index entry.  Only indices entries of less\n  ** than 2GiB are support - anything large must be database corruption.\n  ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so\n  ** this code can safely assume that nCellKey is 32-bits  \n  */\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );\n\n  /* Read in the complete content of the index entry */\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n\n  /* The index entry must begin with a header size */\n  (void)getVarint32((u8*)m.z, szHdr);\n  testcase( szHdr==3 );\n  testcase( szHdr==m.n );\n  if( unlikely(szHdr<3 || (int)szHdr>m.n) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* The last field of the index should be an integer - the ROWID.\n  ** Verify that the last entry really is an integer. */\n  (void)getVarint32((u8*)&m.z[szHdr-1], typeRowid);\n  testcase( typeRowid==1 );\n  testcase( typeRowid==2 );\n  testcase( typeRowid==3 );\n  testcase( typeRowid==4 );\n  testcase( typeRowid==5 );\n  testcase( typeRowid==6 );\n  testcase( typeRowid==8 );\n  testcase( typeRowid==9 );\n  if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){\n    goto idx_rowid_corruption;\n  }\n  lenRowid = sqlite3SmallTypeSizes[typeRowid];\n  testcase( (u32)m.n==szHdr+lenRowid );\n  if( unlikely((u32)m.n<szHdr+lenRowid) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* Fetch the integer off the end of the index record */\n  sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);\n  *rowid = v.u.i;\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n\n  /* Jump here if database corruption is detected after m has been\n  ** allocated.  Free the m object and return SQLITE_CORRUPT. */\nidx_rowid_corruption:\n  testcase( m.szMalloc!=0 );\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** Compare the key of the index entry that cursor pC is pointing to against\n** the key string in pUnpacked.  Write into *pRes a number\n** that is negative, zero, or positive if pC is less than, equal to,\n** or greater than pUnpacked.  Return SQLITE_OK on success.\n**\n** pUnpacked is either created without a rowid or is truncated so that it\n** omits the rowid at the end.  The rowid at the end of the index entry\n** is ignored as well.  Hence, this routine only compares the prefixes \n** of the keys prior to the final rowid, not the entire key.\n*/\nSQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(\n  sqlite3 *db,                     /* Database connection */\n  VdbeCursor *pC,                  /* The cursor to compare against */\n  UnpackedRecord *pUnpacked,       /* Unpacked version of key */\n  int *res                         /* Write the comparison result here */\n){\n  i64 nCellKey = 0;\n  int rc;\n  BtCursor *pCur;\n  Mem m;\n\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCur = pC->uc.pCursor;\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  /* nCellKey will always be between 0 and 0xffffffff because of the way\n  ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */\n  if( nCellKey<=0 || nCellKey>0x7fffffff ){\n    *res = 0;\n    return SQLITE_CORRUPT_BKPT;\n  }\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n  *res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n}\n\n/*\n** This routine sets the value to be returned by subsequent calls to\n** sqlite3_changes() on the database handle 'db'. \n*/\nSQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){\n  assert( sqlite3_mutex_held(db->mutex) );\n  db->nChange = nChange;\n  db->nTotalChange += nChange;\n}\n\n/*\n** Set a flag in the vdbe to update the change counter when it is finalised\n** or reset.\n*/\nSQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe *v){\n  v->changeCntOn = 1;\n}\n\n/*\n** Mark every prepared statement associated with a database connection\n** as expired.\n**\n** An expired statement means that recompilation of the statement is\n** recommend.  Statements expire when things happen that make their\n** programs obsolete.  Removing user-defined functions or collating\n** sequences, or changing an authorization function are the types of\n** things that make prepared statements obsolete.\n*/\nSQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3 *db){\n  Vdbe *p;\n  for(p = db->pVdbe; p; p=p->pNext){\n    p->expired = 1;\n  }\n}\n\n/*\n** Return the database associated with the Vdbe.\n*/\nSQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe *v){\n  return v->db;\n}\n\n/*\n** Return the SQLITE_PREPARE flags for a Vdbe.\n*/\nSQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe *v){\n  return v->prepFlags;\n}\n\n/*\n** Return a pointer to an sqlite3_value structure containing the value bound\n** parameter iVar of VM v. Except, if the value is an SQL NULL, return \n** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*\n** constants) to the value before returning it.\n**\n** The returned value must be freed by the caller using sqlite3ValueFree().\n*/\nSQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){\n  assert( iVar>0 );\n  if( v ){\n    Mem *pMem = &v->aVar[iVar-1];\n    assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n    if( 0==(pMem->flags & MEM_Null) ){\n      sqlite3_value *pRet = sqlite3ValueNew(v->db);\n      if( pRet ){\n        sqlite3VdbeMemCopy((Mem *)pRet, pMem);\n        sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);\n      }\n      return pRet;\n    }\n  }\n  return 0;\n}\n\n/*\n** Configure SQL variable iVar so that binding a new value to it signals\n** to sqlite3_reoptimize() that re-preparing the statement may result\n** in a better query plan.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){\n  assert( iVar>0 );\n  assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n  if( iVar>=32 ){\n    v->expmask |= 0x80000000;\n  }else{\n    v->expmask |= ((u32)1 << (iVar-1));\n  }\n}\n\n/*\n** Cause a function to throw an error if it was call from OP_PureFunc\n** rather than OP_Function.\n**\n** OP_PureFunc means that the function must be deterministic, and should\n** throw an error if it is given inputs that would make it non-deterministic.\n** This routine is invoked by date/time functions that use non-deterministic\n** features such as 'now'.\n*/\nSQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context *pCtx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 1;\n#endif\n  if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){\n    sqlite3_result_error(pCtx, \n       \"non-deterministic function in index expression or CHECK constraint\",\n       -1);\n    return 0;\n  }\n  return 1;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored\n** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored\n** in memory obtained from sqlite3DbMalloc).\n*/\nSQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){\n  if( pVtab->zErrMsg ){\n    sqlite3 *db = p->db;\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg);\n    sqlite3_free(pVtab->zErrMsg);\n    pVtab->zErrMsg = 0;\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n\n/*\n** If the second argument is not NULL, release any allocations associated \n** with the memory cells in the p->aMem[] array. Also free the UnpackedRecord\n** structure itself, using sqlite3DbFree().\n**\n** This function is used to free UnpackedRecord structures allocated by\n** the vdbeUnpackRecord() function found in vdbeapi.c.\n*/\nstatic void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){\n  if( p ){\n    int i;\n    for(i=0; i<nField; i++){\n      Mem *pMem = &p->aMem[i];\n      if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);\n    }\n    sqlite3DbFreeNN(db, p);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,\n** then cursor passed as the second argument should point to the row about\n** to be update or deleted. If the application calls sqlite3_preupdate_old(),\n** the required value will be read from the row the cursor points to.\n*/\nSQLITE_PRIVATE void sqlite3VdbePreUpdateHook(\n  Vdbe *v,                        /* Vdbe pre-update hook is invoked by */\n  VdbeCursor *pCsr,               /* Cursor to grab old.* values from */\n  int op,                         /* SQLITE_INSERT, UPDATE or DELETE */\n  const char *zDb,                /* Database name */\n  Table *pTab,                    /* Modified table */\n  i64 iKey1,                      /* Initial key value */\n  int iReg                        /* Register for new.* record */\n){\n  sqlite3 *db = v->db;\n  i64 iKey2;\n  PreUpdate preupdate;\n  const char *zTbl = pTab->zName;\n  static const u8 fakeSortOrder = 0;\n\n  assert( db->pPreUpdate==0 );\n  memset(&preupdate, 0, sizeof(PreUpdate));\n  if( HasRowid(pTab)==0 ){\n    iKey1 = iKey2 = 0;\n    preupdate.pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    if( op==SQLITE_UPDATE ){\n      iKey2 = v->aMem[iReg].u.i;\n    }else{\n      iKey2 = iKey1;\n    }\n  }\n\n  assert( pCsr->nField==pTab->nCol \n       || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1)\n  );\n\n  preupdate.v = v;\n  preupdate.pCsr = pCsr;\n  preupdate.op = op;\n  preupdate.iNewReg = iReg;\n  preupdate.keyinfo.db = db;\n  preupdate.keyinfo.enc = ENC(db);\n  preupdate.keyinfo.nKeyField = pTab->nCol;\n  preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;\n  preupdate.iKey1 = iKey1;\n  preupdate.iKey2 = iKey2;\n  preupdate.pTab = pTab;\n\n  db->pPreUpdate = &preupdate;\n  db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);\n  db->pPreUpdate = 0;\n  sqlite3DbFree(db, preupdate.aRecord);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pUnpacked);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pNewUnpacked);\n  if( preupdate.aNew ){\n    int i;\n    for(i=0; i<pCsr->nField; i++){\n      sqlite3VdbeMemRelease(&preupdate.aNew[i]);\n    }\n    sqlite3DbFreeNN(db, preupdate.aNew);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n/************** End of vdbeaux.c *********************************************/\n/************** Begin file vdbeapi.c *****************************************/\n/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement APIs that are part of the\n** VDBE.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return TRUE (non-zero) of the statement supplied as an argument needs\n** to be recompiled.  A statement needs to be recompiled whenever the\n** execution environment changes in a way that would alter the program\n** that sqlite3_prepare() generates.  For example, if new functions or\n** collating sequences are registered or if an authorizer function is\n** added or changed.\n*/\nSQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p==0 || p->expired;\n}\n#endif\n\n/*\n** Check on a Vdbe to make sure it has not been finalized.  Log\n** an error and return true if it has been finalized (or is otherwise\n** invalid).  Return false if it is ok.\n*/\nstatic int vdbeSafety(Vdbe *p){\n  if( p->db==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with finalized prepared statement\");\n    return 1;\n  }else{\n    return 0;\n  }\n}\nstatic int vdbeSafetyNotNull(Vdbe *p){\n  if( p==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with NULL prepared statement\");\n    return 1;\n  }else{\n    return vdbeSafety(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Invoke the profile callback.  This routine is only called if we already\n** know that the profile callback is defined and needs to be invoked.\n*/\nstatic SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){\n  sqlite3_int64 iNow;\n  sqlite3_int64 iElapse;\n  assert( p->startTime>0 );\n  assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );\n  assert( db->init.busy==0 );\n  assert( p->zSql!=0 );\n  sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);\n  iElapse = (iNow - p->startTime)*1000000;\n  if( db->xProfile ){\n    db->xProfile(db->pProfileArg, p->zSql, iElapse);\n  }\n  if( db->mTrace & SQLITE_TRACE_PROFILE ){\n    db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);\n  }\n  p->startTime = 0;\n}\n/*\n** The checkProfileCallback(DB,P) macro checks to see if a profile callback\n** is needed, and it invokes the callback if it is needed.\n*/\n# define checkProfileCallback(DB,P) \\\n   if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }\n#else\n# define checkProfileCallback(DB,P)  /*no-op*/\n#endif\n\n/*\n** The following routine destroys a virtual machine that is created by\n** the sqlite3_compile() routine. The integer returned is an SQLITE_\n** success/failure code that describes the result of executing the virtual\n** machine.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL\n    ** pointer is a harmless no-op. */\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeFinalize(v);\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3LeaveMutexAndCloseZombie(db);\n  }\n  return rc;\n}\n\n/*\n** Terminate the current execution of an SQL statement and reset it\n** back to its starting state so that it can be reused. A success code from\n** the prior execution is returned.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeReset(v);\n    sqlite3VdbeRewind(v);\n    assert( (rc & (db->errMask))==rc );\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return rc;\n}\n\n/*\n** Set all the parameters in the compiled SQL statement to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){\n  int i;\n  int rc = SQLITE_OK;\n  Vdbe *p = (Vdbe*)pStmt;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(i=0; i<p->nVar; i++){\n    sqlite3VdbeMemRelease(&p->aVar[i]);\n    p->aVar[i].flags = MEM_Null;\n  }\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask ){\n    p->expired = 1;\n  }\n  sqlite3_mutex_leave(mutex);\n  return rc;\n}\n\n\n/**************************** sqlite3_value_  *******************************\n** The following routines extract information from a Mem or sqlite3_value\n** structure.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){\n  Mem *p = (Mem*)pVal;\n  if( p->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(p)!=SQLITE_OK ){\n      assert( p->flags==MEM_Null && p->z==0 );\n      return 0;\n    }\n    p->flags |= MEM_Blob;\n    return p->n ? p->z : 0;\n  }else{\n    return sqlite3_value_text(pVal);\n  }\n}\nSQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF8);\n}\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API double sqlite3_value_double(sqlite3_value *pVal){\n  return sqlite3VdbeRealValue((Mem*)pVal);\n}\nSQLITE_API int sqlite3_value_int(sqlite3_value *pVal){\n  return (int)sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){\n  return sqlite3VdbeIntValue((Mem*)pVal);\n}\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *pVal){\n  Mem *pMem = (Mem*)pVal;\n  return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);\n}\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){\n  Mem *p = (Mem*)pVal;\n  if( (p->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==\n                 (MEM_Null|MEM_Term|MEM_Subtype)\n   && zPType!=0\n   && p->eSubtype=='p'\n   && strcmp(p->u.zPType, zPType)==0\n  ){\n    return (void*)p->z;\n  }else{\n    return 0;\n  }\n}\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){\n  return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n}\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16BE);\n}\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16LE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five\n** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating\n** point number string BLOB NULL\n*/\nSQLITE_API int sqlite3_value_type(sqlite3_value* pVal){\n  static const u8 aType[] = {\n     SQLITE_BLOB,     /* 0x00 */\n     SQLITE_NULL,     /* 0x01 */\n     SQLITE_TEXT,     /* 0x02 */\n     SQLITE_NULL,     /* 0x03 */\n     SQLITE_INTEGER,  /* 0x04 */\n     SQLITE_NULL,     /* 0x05 */\n     SQLITE_INTEGER,  /* 0x06 */\n     SQLITE_NULL,     /* 0x07 */\n     SQLITE_FLOAT,    /* 0x08 */\n     SQLITE_NULL,     /* 0x09 */\n     SQLITE_FLOAT,    /* 0x0a */\n     SQLITE_NULL,     /* 0x0b */\n     SQLITE_INTEGER,  /* 0x0c */\n     SQLITE_NULL,     /* 0x0d */\n     SQLITE_INTEGER,  /* 0x0e */\n     SQLITE_NULL,     /* 0x0f */\n     SQLITE_BLOB,     /* 0x10 */\n     SQLITE_NULL,     /* 0x11 */\n     SQLITE_TEXT,     /* 0x12 */\n     SQLITE_NULL,     /* 0x13 */\n     SQLITE_INTEGER,  /* 0x14 */\n     SQLITE_NULL,     /* 0x15 */\n     SQLITE_INTEGER,  /* 0x16 */\n     SQLITE_NULL,     /* 0x17 */\n     SQLITE_FLOAT,    /* 0x18 */\n     SQLITE_NULL,     /* 0x19 */\n     SQLITE_FLOAT,    /* 0x1a */\n     SQLITE_NULL,     /* 0x1b */\n     SQLITE_INTEGER,  /* 0x1c */\n     SQLITE_NULL,     /* 0x1d */\n     SQLITE_INTEGER,  /* 0x1e */\n     SQLITE_NULL,     /* 0x1f */\n  };\n  return aType[pVal->flags&MEM_AffMask];\n}\n\n/* Make a copy of an sqlite3_value object\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){\n  sqlite3_value *pNew;\n  if( pOrig==0 ) return 0;\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  memset(pNew, 0, sizeof(*pNew));\n  memcpy(pNew, pOrig, MEMCELLSIZE);\n  pNew->flags &= ~MEM_Dyn;\n  pNew->db = 0;\n  if( pNew->flags&(MEM_Str|MEM_Blob) ){\n    pNew->flags &= ~(MEM_Static|MEM_Dyn);\n    pNew->flags |= MEM_Ephem;\n    if( sqlite3VdbeMemMakeWriteable(pNew)!=SQLITE_OK ){\n      sqlite3ValueFree(pNew);\n      pNew = 0;\n    }\n  }\n  return pNew;\n}\n\n/* Destroy an sqlite3_value object previously obtained from\n** sqlite3_value_dup().\n*/\nSQLITE_API void sqlite3_value_free(sqlite3_value *pOld){\n  sqlite3ValueFree(pOld);\n}\n  \n\n/**************************** sqlite3_result_  *******************************\n** The following routines are used by user-defined functions to specify\n** the function result.\n**\n** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the\n** result as a string or blob but if the string or blob is too large, it\n** then sets the error code to SQLITE_TOOBIG\n**\n** The invokeValueDestructor(P,X) routine invokes destructor function X()\n** on value P is not going to be used and need to be destroyed.\n*/\nstatic void setResultStrOrError(\n  sqlite3_context *pCtx,  /* Function context */\n  const char *z,          /* String pointer */\n  int n,                  /* Bytes in string, or negative */\n  u8 enc,                 /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*)     /* Destructor function */\n){\n  if( sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel)==SQLITE_TOOBIG ){\n    sqlite3_result_error_toobig(pCtx);\n  }\n}\nstatic int invokeValueDestructor(\n  const void *p,             /* Value to destroy */\n  void (*xDel)(void*),       /* The destructor */\n  sqlite3_context *pCtx      /* Set a SQLITE_TOOBIG error if no NULL */\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( xDel==0 ){\n    /* noop */\n  }else if( xDel==SQLITE_TRANSIENT ){\n    /* noop */\n  }else{\n    xDel((void*)p);\n  }\n  if( pCtx ) sqlite3_result_error_toobig(pCtx);\n  return SQLITE_TOOBIG;\n}\nSQLITE_API void sqlite3_result_blob(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( n>=0 );\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, 0, xDel);\n}\nSQLITE_API void sqlite3_result_blob64(\n  sqlite3_context *pCtx, \n  const void *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, 0, xDel);\n  }\n}\nSQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);\n}\nSQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);\n}\n#endif\nSQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);\n}\nSQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);\n}\nSQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n}\nSQLITE_API void sqlite3_result_pointer(\n  sqlite3_context *pCtx,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  sqlite3VdbeMemRelease(pOut);\n  pOut->flags = MEM_Null;\n  sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor);\n}\nSQLITE_API void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  pOut->eSubtype = eSubtype & 0xff;\n  pOut->flags |= MEM_Subtype;\n}\nSQLITE_API void sqlite3_result_text(\n  sqlite3_context *pCtx, \n  const char *z, \n  int n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);\n}\nSQLITE_API void sqlite3_result_text64(\n  sqlite3_context *pCtx, \n  const char *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *),\n  unsigned char enc\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, enc, xDel);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API void sqlite3_result_text16(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);\n}\nSQLITE_API void sqlite3_result_text16be(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);\n}\nSQLITE_API void sqlite3_result_text16le(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemCopy(pCtx->pOut, pValue);\n}\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);\n}\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    return SQLITE_TOOBIG;\n  }\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n);\n  return SQLITE_OK;\n}\nSQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){\n  pCtx->isError = errCode;\n  pCtx->fErrorOrAux = 1;\n#ifdef SQLITE_DEBUG\n  if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;\n#endif\n  if( pCtx->pOut->flags & MEM_Null ){\n    sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1, \n                         SQLITE_UTF8, SQLITE_STATIC);\n  }\n}\n\n/* Force an SQLITE_TOOBIG error. */\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_TOOBIG;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, \"string or blob too big\", -1, \n                       SQLITE_UTF8, SQLITE_STATIC);\n}\n\n/* An SQLITE_NOMEM error. */\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n  pCtx->isError = SQLITE_NOMEM_BKPT;\n  pCtx->fErrorOrAux = 1;\n  sqlite3OomFault(pCtx->pOut->db);\n}\n\n/*\n** This function is called after a transaction has been committed. It \n** invokes callbacks registered with sqlite3_wal_hook() as required.\n*/\nstatic int doWalCallbacks(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_WAL\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      int nEntry;\n      sqlite3BtreeEnter(pBt);\n      nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));\n      sqlite3BtreeLeave(pBt);\n      if( nEntry>0 && db->xWalCallback && rc==SQLITE_OK ){\n        rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zDbSName, nEntry);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n\n/*\n** Execute the statement pStmt, either until a row of data is ready, the\n** statement is completely executed or an error occurs.\n**\n** This routine implements the bulk of the logic behind the sqlite_step()\n** API.  The only thing omitted is the automatic recompile if a \n** schema change has occurred.  That detail is handled by the\n** outer sqlite3_step() wrapper procedure.\n*/\nstatic int sqlite3Step(Vdbe *p){\n  sqlite3 *db;\n  int rc;\n\n  assert(p);\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    /* We used to require that sqlite3_reset() be called before retrying\n    ** sqlite3_step() after any error or after SQLITE_DONE.  But beginning\n    ** with version 3.7.0, we changed this so that sqlite3_reset() would\n    ** be called automatically instead of throwing the SQLITE_MISUSE error.\n    ** This \"automatic-reset\" change is not technically an incompatibility, \n    ** since any application that receives an SQLITE_MISUSE is broken by\n    ** definition.\n    **\n    ** Nevertheless, some published applications that were originally written\n    ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE \n    ** returns, and those were broken by the automatic-reset change.  As a\n    ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the\n    ** legacy behavior of returning SQLITE_MISUSE for cases where the \n    ** previous sqlite3_step() returned something other than a SQLITE_LOCKED\n    ** or SQLITE_BUSY error.\n    */\n#ifdef SQLITE_OMIT_AUTORESET\n    if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      sqlite3_reset((sqlite3_stmt*)p);\n    }else{\n      return SQLITE_MISUSE_BKPT;\n    }\n#else\n    sqlite3_reset((sqlite3_stmt*)p);\n#endif\n  }\n\n  /* Check that malloc() has not failed. If it has, return early. */\n  db = p->db;\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  if( p->pc<=0 && p->expired ){\n    p->rc = SQLITE_SCHEMA;\n    rc = SQLITE_ERROR;\n    goto end_of_step;\n  }\n  if( p->pc<0 ){\n    /* If there are no other statements currently running, then\n    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt\n    ** from interrupting a statement that has not yet started.\n    */\n    if( db->nVdbeActive==0 ){\n      db->u1.isInterrupted = 0;\n    }\n\n    assert( db->nVdbeWrite>0 || db->autoCommit==0 \n        || (db->nDeferredCons==0 && db->nDeferredImmCons==0)\n    );\n\n#ifndef SQLITE_OMIT_TRACE\n    if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)\n        && !db->init.busy && p->zSql ){\n      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);\n    }else{\n      assert( p->startTime==0 );\n    }\n#endif\n\n    db->nVdbeActive++;\n    if( p->readOnly==0 ) db->nVdbeWrite++;\n    if( p->bIsReader ) db->nVdbeRead++;\n    p->pc = 0;\n  }\n#ifdef SQLITE_DEBUG\n  p->rcApp = SQLITE_OK;\n#endif\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( p->explain ){\n    rc = sqlite3VdbeList(p);\n  }else\n#endif /* SQLITE_OMIT_EXPLAIN */\n  {\n    db->nVdbeExec++;\n    rc = sqlite3VdbeExec(p);\n    db->nVdbeExec--;\n  }\n\n#ifndef SQLITE_OMIT_TRACE\n  /* If the statement completed successfully, invoke the profile callback */\n  if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);\n#endif\n\n  if( rc==SQLITE_DONE && db->autoCommit ){\n    assert( p->rc==SQLITE_OK );\n    p->rc = doWalCallbacks(db);\n    if( p->rc!=SQLITE_OK ){\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  db->errCode = rc;\n  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\nend_of_step:\n  /* At this point local variable rc holds the value that should be \n  ** returned if this statement was compiled using the legacy \n  ** sqlite3_prepare() interface. According to the docs, this can only\n  ** be one of the values in the first assert() below. Variable p->rc \n  ** contains the value that would be returned if sqlite3_finalize() \n  ** were called on statement p.\n  */\n  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR \n       || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE\n  );\n  assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );\n  if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 \n   && rc!=SQLITE_ROW \n   && rc!=SQLITE_DONE \n  ){\n    /* If this statement was prepared using saved SQL and an \n    ** error has occurred, then return the error code in p->rc to the\n    ** caller. Set the error code in the database handle to the same value.\n    */ \n    rc = sqlite3VdbeTransferError(p);\n  }\n  return (rc&db->errMask);\n}\n\n/*\n** This is the top-level implementation of sqlite3_step().  Call\n** sqlite3Step() to do most of the work.  If a schema error occurs,\n** call sqlite3Reprepare() and try again.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){\n  int rc = SQLITE_OK;      /* Result from sqlite3Step() */\n  Vdbe *v = (Vdbe*)pStmt;  /* the prepared statement */\n  int cnt = 0;             /* Counter to prevent infinite loop of reprepares */\n  sqlite3 *db;             /* The database connection */\n\n  if( vdbeSafetyNotNull(v) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  db = v->db;\n  sqlite3_mutex_enter(db->mutex);\n  v->doingRerun = 0;\n  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA\n         && cnt++ < SQLITE_MAX_SCHEMA_RETRY ){\n    int savedPc = v->pc;\n    rc = sqlite3Reprepare(v);\n    if( rc!=SQLITE_OK ){\n      /* This case occurs after failing to recompile an sql statement. \n      ** The error message from the SQL compiler has already been loaded \n      ** into the database handle. This block copies the error message \n      ** from the database handle into the statement and sets the statement\n      ** program counter to 0 to ensure that when the statement is \n      ** finalized or reset the parser error message is available via\n      ** sqlite3_errmsg() and sqlite3_errcode().\n      */\n      const char *zErr = (const char *)sqlite3_value_text(db->pErr); \n      sqlite3DbFree(db, v->zErrMsg);\n      if( !db->mallocFailed ){\n        v->zErrMsg = sqlite3DbStrDup(db, zErr);\n        v->rc = rc = sqlite3ApiExit(db, rc);\n      } else {\n        v->zErrMsg = 0;\n        v->rc = rc = SQLITE_NOMEM_BKPT;\n      }\n      break;\n    }\n    sqlite3_reset(pStmt);\n    if( savedPc>=0 ) v->doingRerun = 1;\n    assert( v->expired==0 );\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context *p){\n  assert( p && p->pFunc );\n  return p->pFunc->pUserData;\n}\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n**\n** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface\n** returns a copy of the pointer to the database connection (the 1st\n** parameter) of the sqlite3_create_function() and\n** sqlite3_create_function16() routines that originally registered the\n** application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){\n  assert( p && p->pOut );\n  return p->pOut->db;\n}\n\n/*\n** Return the current time for a statement.  If the current time\n** is requested more than once within the same run of a single prepared\n** statement, the exact same time is returned for each invocation regardless\n** of the amount of time that elapses between invocations.  In other words,\n** the time returned is always the time of the first call.\n*/\nSQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){\n  int rc;\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;\n  assert( p->pVdbe!=0 );\n#else\n  sqlite3_int64 iTime = 0;\n  sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;\n#endif\n  if( *piTime==0 ){\n    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);\n    if( rc ) *piTime = 0;\n  }\n  return *piTime;\n}\n\n/*\n** The following is the implementation of an SQL function that always\n** fails with an error message stating that the function is used in the\n** wrong context.  The sqlite3_overload_function() API might construct\n** SQL function that use this routine so that the functions will exist\n** for name resolution but are actually overloaded by the xFindFunction\n** method of virtual tables.\n*/\nSQLITE_PRIVATE void sqlite3InvalidFunction(\n  sqlite3_context *context,  /* The function calling context */\n  int NotUsed,               /* Number of arguments to the function */\n  sqlite3_value **NotUsed2   /* Value of each argument */\n){\n  const char *zName = context->pFunc->zName;\n  char *zErr;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  zErr = sqlite3_mprintf(\n      \"unable to use function %s in the requested context\", zName);\n  sqlite3_result_error(context, zErr, -1);\n  sqlite3_free(zErr);\n}\n\n/*\n** Create a new aggregate context for p and return a pointer to\n** its pMem->z element.\n*/\nstatic SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){\n  Mem *pMem = p->pMem;\n  assert( (pMem->flags & MEM_Agg)==0 );\n  if( nByte<=0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n  }else{\n    sqlite3VdbeMemClearAndResize(pMem, nByte);\n    pMem->flags = MEM_Agg;\n    pMem->u.pDef = p->pFunc;\n    if( pMem->z ){\n      memset(pMem->z, 0, nByte);\n    }\n  }\n  return (void*)pMem->z;\n}\n\n/*\n** Allocate or return the aggregate context for a user function.  A new\n** context is allocated on the first call.  Subsequent calls return the\n** same context that was returned on prior calls.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){\n  assert( p && p->pFunc && p->pFunc->xFinalize );\n  assert( sqlite3_mutex_held(p->pOut->db->mutex) );\n  testcase( nByte<0 );\n  if( (p->pMem->flags & MEM_Agg)==0 ){\n    return createAggContext(p, nByte);\n  }else{\n    return (void*)p->pMem->z;\n  }\n}\n\n/*\n** Return the auxiliary data pointer, if any, for the iArg'th argument to\n** the user-function defined by pCtx.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then access a cache of\n** auxiliary data pointers that is available to all functions within a\n** single prepared statement.  The iArg values must match.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){\n  AuxData *pAuxData;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#if SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 0;\n#else\n  assert( pCtx->pVdbe!=0 );\n#endif\n  for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if(  pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      return pAuxData->pAux;\n    }\n  }\n  return 0;\n}\n\n/*\n** Set the auxiliary data pointer and delete function, for the iArg'th\n** argument to the user-function defined by pCtx. Any previous value is\n** deleted by calling the delete function specified when it was set.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then make the data available\n** to all functions within the current prepared statement using iArg as an\n** access code.\n*/\nSQLITE_API void sqlite3_set_auxdata(\n  sqlite3_context *pCtx, \n  int iArg, \n  void *pAux, \n  void (*xDelete)(void*)\n){\n  AuxData *pAuxData;\n  Vdbe *pVdbe = pCtx->pVdbe;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pVdbe==0 ) goto failed;\n#else\n  assert( pVdbe!=0 );\n#endif\n\n  for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      break;\n    }\n  }\n  if( pAuxData==0 ){\n    pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));\n    if( !pAuxData ) goto failed;\n    pAuxData->iAuxOp = pCtx->iOp;\n    pAuxData->iAuxArg = iArg;\n    pAuxData->pNextAux = pVdbe->pAuxData;\n    pVdbe->pAuxData = pAuxData;\n    if( pCtx->fErrorOrAux==0 ){\n      pCtx->isError = 0;\n      pCtx->fErrorOrAux = 1;\n    }\n  }else if( pAuxData->xDeleteAux ){\n    pAuxData->xDeleteAux(pAuxData->pAux);\n  }\n\n  pAuxData->pAux = pAux;\n  pAuxData->xDeleteAux = xDelete;\n  return;\n\nfailed:\n  if( xDelete ){\n    xDelete(pAux);\n  }\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return the number of times the Step function of an aggregate has been \n** called.\n**\n** This function is deprecated.  Do not use it for new code.  It is\n** provide only to avoid breaking legacy code.  New aggregate function\n** implementations should keep their own counts within their aggregate\n** context.\n*/\nSQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){\n  assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize );\n  return p->pMem->n;\n}\n#endif\n\n/*\n** Return the number of columns in the result set for the statement pStmt.\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  return pVm ? pVm->nResColumn : 0;\n}\n\n/*\n** Return the number of values available from the current row of the\n** currently executing statement pStmt.\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  if( pVm==0 || pVm->pResultSet==0 ) return 0;\n  return pVm->nResColumn;\n}\n\n/*\n** Return a pointer to static memory containing an SQL NULL value.\n*/\nstatic const Mem *columnNullValue(void){\n  /* Even though the Mem structure contains an element\n  ** of type i64, on certain architectures (x86) with certain compiler\n  ** switches (-Os), gcc may align this Mem object on a 4-byte boundary\n  ** instead of an 8-byte one. This all works fine, except that when\n  ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s\n  ** that a Mem structure is located on an 8-byte boundary. To prevent\n  ** these assert()s from failing, when building with SQLITE_DEBUG defined\n  ** using gcc, we force nullMem to be 8-byte aligned using the magical\n  ** __attribute__((aligned(8))) macro.  */\n  static const Mem nullMem \n#if defined(SQLITE_DEBUG) && defined(__GNUC__)\n    __attribute__((aligned(8))) \n#endif\n    = {\n        /* .u          = */ {0},\n        /* .flags      = */ (u16)MEM_Null,\n        /* .enc        = */ (u8)0,\n        /* .eSubtype   = */ (u8)0,\n        /* .n          = */ (int)0,\n        /* .z          = */ (char*)0,\n        /* .zMalloc    = */ (char*)0,\n        /* .szMalloc   = */ (int)0,\n        /* .uTemp      = */ (u32)0,\n        /* .db         = */ (sqlite3*)0,\n        /* .xDel       = */ (void(*)(void*))0,\n#ifdef SQLITE_DEBUG\n        /* .pScopyFrom = */ (Mem*)0,\n        /* .pFiller    = */ (void*)0,\n#endif\n      };\n  return &nullMem;\n}\n\n/*\n** Check to see if column iCol of the given statement is valid.  If\n** it is, return a pointer to the Mem for the value of that column.\n** If iCol is not valid, return a pointer to a Mem which has a value\n** of NULL.\n*/\nstatic Mem *columnMem(sqlite3_stmt *pStmt, int i){\n  Vdbe *pVm;\n  Mem *pOut;\n\n  pVm = (Vdbe *)pStmt;\n  if( pVm==0 ) return (Mem*)columnNullValue();\n  assert( pVm->db );\n  sqlite3_mutex_enter(pVm->db->mutex);\n  if( pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){\n    pOut = &pVm->pResultSet[i];\n  }else{\n    sqlite3Error(pVm->db, SQLITE_RANGE);\n    pOut = (Mem*)columnNullValue();\n  }\n  return pOut;\n}\n\n/*\n** This function is called after invoking an sqlite3_value_XXX function on a \n** column value (i.e. a value returned by evaluating an SQL expression in the\n** select list of a SELECT statement) that may cause a malloc() failure. If \n** malloc() has failed, the threads mallocFailed flag is cleared and the result\n** code of statement pStmt set to SQLITE_NOMEM.\n**\n** Specifically, this is called from within:\n**\n**     sqlite3_column_int()\n**     sqlite3_column_int64()\n**     sqlite3_column_text()\n**     sqlite3_column_text16()\n**     sqlite3_column_real()\n**     sqlite3_column_bytes()\n**     sqlite3_column_bytes16()\n**     sqiite3_column_blob()\n*/\nstatic void columnMallocFailure(sqlite3_stmt *pStmt)\n{\n  /* If malloc() failed during an encoding conversion within an\n  ** sqlite3_column_XXX API, then set the return code of the statement to\n  ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR\n  ** and _finalize() will return NOMEM.\n  */\n  Vdbe *p = (Vdbe *)pStmt;\n  if( p ){\n    assert( p->db!=0 );\n    assert( sqlite3_mutex_held(p->db->mutex) );\n    p->rc = sqlite3ApiExit(p->db, p->rc);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n}\n\n/**************************** sqlite3_column_  *******************************\n** The following routines are used to access elements of the current row\n** in the result set.\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){\n  const void *val;\n  val = sqlite3_value_blob( columnMem(pStmt,i) );\n  /* Even though there is no encoding conversion, value_blob() might\n  ** need to call malloc() to expand the result of a zeroblob() \n  ** expression. \n  */\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){\n  double val = sqlite3_value_double( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_int( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){\n  sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){\n  const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){\n  Mem *pOut = columnMem(pStmt, i);\n  if( pOut->flags&MEM_Static ){\n    pOut->flags &= ~MEM_Static;\n    pOut->flags |= MEM_Ephem;\n  }\n  columnMallocFailure(pStmt);\n  return (sqlite3_value *)pOut;\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){\n  const void *val = sqlite3_value_text16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){\n  int iType = sqlite3_value_type( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return iType;\n}\n\n/*\n** Convert the N-th element of pStmt->pColName[] into a string using\n** xFunc() then return that string.  If N is out of range, return 0.\n**\n** There are up to 5 names for each column.  useType determines which\n** name is returned.  Here are the names:\n**\n**    0      The column name as it should be displayed for output\n**    1      The datatype name for the column\n**    2      The name of the database that the column derives from\n**    3      The name of the table that the column derives from\n**    4      The name of the table column that the result column derives from\n**\n** If the result is not a simple column reference (if it is an expression\n** or a constant) then useTypes 2, 3, and 4 return NULL.\n*/\nstatic const void *columnName(\n  sqlite3_stmt *pStmt,\n  int N,\n  const void *(*xFunc)(Mem*),\n  int useType\n){\n  const void *ret;\n  Vdbe *p;\n  int n;\n  sqlite3 *db;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pStmt==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  ret = 0;\n  p = (Vdbe *)pStmt;\n  db = p->db;\n  assert( db!=0 );\n  n = sqlite3_column_count(pStmt);\n  if( N<n && N>=0 ){\n    N += useType*n;\n    sqlite3_mutex_enter(db->mutex);\n    assert( db->mallocFailed==0 );\n    ret = xFunc(&p->aColName[N]);\n     /* A malloc may have failed inside of the xFunc() call. If this\n    ** is the case, clear the mallocFailed flag and return NULL.\n    */\n    if( db->mallocFailed ){\n      sqlite3OomClear(db);\n      ret = 0;\n    }\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return ret;\n}\n\n/*\n** Return the name of the Nth column of the result set returned by SQL\n** statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);\n}\n#endif\n\n/*\n** Constraint:  If you have ENABLE_COLUMN_METADATA then you must\n** not define OMIT_DECLTYPE.\n*/\n#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METADATA)\n# error \"Must not define both SQLITE_OMIT_DECLTYPE \\\n         and SQLITE_ENABLE_COLUMN_METADATA\"\n#endif\n\n#ifndef SQLITE_OMIT_DECLTYPE\n/*\n** Return the column declaration type (if applicable) of the 'i'th column\n** of the result set of SQL statement pStmt.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_DECLTYPE */\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n/*\n** Return the name of the database from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table column from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_ENABLE_COLUMN_METADATA */\n\n\n/******************************* sqlite3_bind_  ***************************\n** \n** Routines used to attach values to wildcards in a compiled SQL statement.\n*/\n/*\n** Unbind the value bound to variable i in virtual machine p. This is the \n** the same as binding a NULL value to the column. If the \"i\" parameter is\n** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK.\n**\n** A successful evaluation of this routine acquires the mutex on p.\n** the mutex is released if any kind of error occurs.\n**\n** The error code stored in database p->db is overwritten with the return\n** value in any case.\n*/\nstatic int vdbeUnbind(Vdbe *p, int i){\n  Mem *pVar;\n  if( vdbeSafetyNotNull(p) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(p->db->mutex);\n  if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){\n    sqlite3Error(p->db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(p->db->mutex);\n    sqlite3_log(SQLITE_MISUSE, \n        \"bind on a busy prepared statement: [%s]\", p->zSql);\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( i<1 || i>p->nVar ){\n    sqlite3Error(p->db, SQLITE_RANGE);\n    sqlite3_mutex_leave(p->db->mutex);\n    return SQLITE_RANGE;\n  }\n  i--;\n  pVar = &p->aVar[i];\n  sqlite3VdbeMemRelease(pVar);\n  pVar->flags = MEM_Null;\n  sqlite3Error(p->db, SQLITE_OK);\n\n  /* If the bit corresponding to this variable in Vdbe.expmask is set, then \n  ** binding a new value to this variable invalidates the current query plan.\n  **\n  ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host\n  ** parameter in the WHERE clause might influence the choice of query plan\n  ** for a statement, then the statement will be automatically recompiled,\n  ** as if there had been a schema change, on the first sqlite3_step() call\n  ** following any change to the bindings of that parameter.\n  */\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){\n    p->expired = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Bind a text or BLOB value.\n*/\nstatic int bindText(\n  sqlite3_stmt *pStmt,   /* The statement to bind against */\n  int i,                 /* Index of the parameter to bind */\n  const void *zData,     /* Pointer to the data to be bound */\n  int nData,             /* Number of bytes of data to be bound */\n  void (*xDel)(void*),   /* Destructor for the data */\n  u8 encoding            /* Encoding for the data */\n){\n  Vdbe *p = (Vdbe *)pStmt;\n  Mem *pVar;\n  int rc;\n\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    if( zData!=0 ){\n      pVar = &p->aVar[i-1];\n      rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);\n      if( rc==SQLITE_OK && encoding!=0 ){\n        rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));\n      }\n      if( rc ){\n        sqlite3Error(p->db, rc);\n        rc = sqlite3ApiExit(p->db, rc);\n      }\n    }\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){\n    xDel((void*)zData);\n  }\n  return rc;\n}\n\n\n/*\n** Bind a blob value to an SQL statement variable.\n*/\nSQLITE_API int sqlite3_bind_blob(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( nData<0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return bindText(pStmt, i, zData, nData, xDel, 0);\n}\nSQLITE_API int sqlite3_bind_blob64(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*)\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    return bindText(pStmt, i, zData, (int)nData, xDel, 0);\n  }\n}\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){\n  return sqlite3_bind_int64(p, i, (i64)iValue);\n}\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_pointer(\n  sqlite3_stmt *pStmt,\n  int i,\n  void *pPtr,\n  const char *zPTtype,\n  void (*xDestructor)(void*)\n){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zPTtype, xDestructor);\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDestructor ){\n    xDestructor(pPtr);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_text( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);\n}\nSQLITE_API int sqlite3_bind_text64( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*),\n  unsigned char enc\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n    return bindText(pStmt, i, zData, (int)nData, xDel, enc);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_bind_text16(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){\n  int rc;\n  switch( sqlite3_value_type((sqlite3_value*)pValue) ){\n    case SQLITE_INTEGER: {\n      rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);\n      break;\n    }\n    case SQLITE_FLOAT: {\n      rc = sqlite3_bind_double(pStmt, i, pValue->u.r);\n      break;\n    }\n    case SQLITE_BLOB: {\n      if( pValue->flags & MEM_Zero ){\n        rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);\n      }else{\n        rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      rc = bindText(pStmt,i,  pValue->z, pValue->n, SQLITE_TRANSIENT,\n                              pValue->enc);\n      break;\n    }\n    default: {\n      rc = sqlite3_bind_null(pStmt, i);\n      break;\n    }\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  sqlite3_mutex_enter(p->db->mutex);\n  if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    rc = SQLITE_TOOBIG;\n  }else{\n    assert( (n & 0x7FFFFFFF)==n );\n    rc = sqlite3_bind_zeroblob(pStmt, i, n);\n  }\n  rc = sqlite3ApiExit(p->db, rc);\n  sqlite3_mutex_leave(p->db->mutex);\n  return rc;\n}\n\n/*\n** Return the number of wildcards that can be potentially bound to.\n** This routine is added to support DBD::SQLite.  \n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p ? p->nVar : 0;\n}\n\n/*\n** Return the name of a wildcard parameter.  Return NULL if the index\n** is out of range or if the wildcard is unnamed.\n**\n** The result is always UTF-8.\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){\n  Vdbe *p = (Vdbe*)pStmt;\n  if( p==0 ) return 0;\n  return sqlite3VListNumToName(p->pVList, i);\n}\n\n/*\n** Given a wildcard parameter name, return the index of the variable\n** with that name.  If there is no variable with the given name,\n** return 0.\n*/\nSQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){\n  if( p==0 || zName==0 ) return 0;\n  return sqlite3VListNameToNum(p->pVList, zName, nName);\n}\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){\n  return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));\n}\n\n/*\n** Transfer all bindings from the first statement over to the second.\n*/\nSQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  int i;\n  assert( pTo->db==pFrom->db );\n  assert( pTo->nVar==pFrom->nVar );\n  sqlite3_mutex_enter(pTo->db->mutex);\n  for(i=0; i<pFrom->nVar; i++){\n    sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);\n  }\n  sqlite3_mutex_leave(pTo->db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  Internal/core SQLite code\n** should call sqlite3TransferBindings.\n**\n** It is misuse to call this routine with statements from different\n** database connections.  But as this is a deprecated interface, we\n** will not bother to check for that condition.\n**\n** If the two statements contain a different number of bindings, then\n** an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise\n** SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  if( pFrom->nVar!=pTo->nVar ){\n    return SQLITE_ERROR;\n  }\n  assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );\n  if( pTo->expmask ){\n    pTo->expired = 1;\n  }\n  assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );\n  if( pFrom->expmask ){\n    pFrom->expired = 1;\n  }\n  return sqlite3TransferBindings(pFromStmt, pToStmt);\n}\n#endif\n\n/*\n** Return the sqlite3* database handle to which the prepared statement given\n** in the argument belongs.  This is the same database handle that was\n** the first argument to the sqlite3_prepare() that was used to create\n** the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->db : 0;\n}\n\n/*\n** Return true if the prepared statement is guaranteed to not modify the\n** database.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;\n}\n\n/*\n** Return true if the prepared statement is in need of being reset.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){\n  Vdbe *v = (Vdbe*)pStmt;\n  return v!=0 && v->magic==VDBE_MAGIC_RUN && v->pc>=0;\n}\n\n/*\n** Return a pointer to the next prepared statement after pStmt associated\n** with database connection pDb.  If pStmt is NULL, return the first\n** prepared statement for the database connection.  Return NULL if there\n** are no more.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){\n  sqlite3_stmt *pNext;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(pDb->mutex);\n  if( pStmt==0 ){\n    pNext = (sqlite3_stmt*)pDb->pVdbe;\n  }else{\n    pNext = (sqlite3_stmt*)((Vdbe*)pStmt)->pNext;\n  }\n  sqlite3_mutex_leave(pDb->mutex);\n  return pNext;\n}\n\n/*\n** Return the value of a status counter for a prepared statement\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){\n  Vdbe *pVdbe = (Vdbe*)pStmt;\n  u32 v;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !pStmt ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  if( op==SQLITE_STMTSTATUS_MEMUSED ){\n    sqlite3 *db = pVdbe->db;\n    sqlite3_mutex_enter(db->mutex);\n    v = 0;\n    db->pnBytesFreed = (int*)&v;\n    sqlite3VdbeClearObject(db, pVdbe);\n    sqlite3DbFree(db, pVdbe);\n    db->pnBytesFreed = 0;\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    v = pVdbe->aCounter[op];\n    if( resetFlag ) pVdbe->aCounter[op] = 0;\n  }\n  return (int)v;\n}\n\n/*\n** Return the SQL associated with a prepared statement\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe *)pStmt;\n  return p ? p->zSql : 0;\n}\n\n/*\n** Return the SQL associated with a prepared statement with\n** bound parameters expanded.  Space to hold the returned string is\n** obtained from sqlite3_malloc().  The caller is responsible for\n** freeing the returned string by passing it to sqlite3_free().\n**\n** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of\n** expanded bound parameters.\n*/\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){\n#ifdef SQLITE_OMIT_TRACE\n  return 0;\n#else\n  char *z = 0;\n  const char *zSql = sqlite3_sql(pStmt);\n  if( zSql ){\n    Vdbe *p = (Vdbe *)pStmt;\n    sqlite3_mutex_enter(p->db->mutex);\n    z = sqlite3VdbeExpandSql(p, zSql);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return z;\n#endif\n}\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Allocate and populate an UnpackedRecord structure based on the serialized\n** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure\n** if successful, or a NULL pointer if an OOM error is encountered.\n*/\nstatic UnpackedRecord *vdbeUnpackRecord(\n  KeyInfo *pKeyInfo, \n  int nKey, \n  const void *pKey\n){\n  UnpackedRecord *pRet;           /* Return value */\n\n  pRet = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n  if( pRet ){\n    memset(pRet->aMem, 0, sizeof(Mem)*(pKeyInfo->nKeyField+1));\n    sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, pRet);\n  }\n  return pRet;\n}\n\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or deleted.\n*/\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  Mem *pMem;\n  int rc = SQLITE_OK;\n\n  /* Test that this call is being made from within an SQLITE_DELETE or\n  ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */\n  if( !p || p->op==SQLITE_INSERT ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_old_out;\n  }\n  if( p->pPk ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_old_out;\n  }\n\n  /* If the old.* record has not yet been loaded into memory, do so now. */\n  if( p->pUnpacked==0 ){\n    u32 nRec;\n    u8 *aRec;\n\n    nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);\n    aRec = sqlite3DbMallocRaw(db, nRec);\n    if( !aRec ) goto preupdate_old_out;\n    rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);\n    if( rc==SQLITE_OK ){\n      p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);\n      if( !p->pUnpacked ) rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, aRec);\n      goto preupdate_old_out;\n    }\n    p->aRecord = aRec;\n  }\n\n  pMem = *ppValue = &p->pUnpacked->aMem[iIdx];\n  if( iIdx==p->pTab->iPKey ){\n    sqlite3VdbeMemSetInt64(pMem, p->iKey1);\n  }else if( iIdx>=p->pUnpacked->nField ){\n    *ppValue = (sqlite3_value *)columnNullValue();\n  }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){\n    if( pMem->flags & MEM_Int ){\n      sqlite3VdbeMemRealify(pMem);\n    }\n  }\n\n preupdate_old_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** the number of columns in the row being updated, deleted or inserted.\n*/\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->keyinfo.nKeyField : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is designed to be called from within a pre-update callback\n** only. It returns zero if the change that caused the callback was made\n** immediately by a user SQL statement. Or, if the change was made by a\n** trigger program, it returns the number of trigger programs currently\n** on the stack (1 for a top-level trigger, 2 for a trigger fired by a \n** top-level trigger etc.).\n**\n** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL\n** or SET DEFAULT action is considered a trigger.\n*/\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->v->nFrame : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or inserted.\n*/\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  int rc = SQLITE_OK;\n  Mem *pMem;\n\n  if( !p || p->op==SQLITE_DELETE ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_new_out;\n  }\n  if( p->pPk && p->op!=SQLITE_UPDATE ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_new_out;\n  }\n\n  if( p->op==SQLITE_INSERT ){\n    /* For an INSERT, memory cell p->iNewReg contains the serialized record\n    ** that is being inserted. Deserialize it. */\n    UnpackedRecord *pUnpack = p->pNewUnpacked;\n    if( !pUnpack ){\n      Mem *pData = &p->v->aMem[p->iNewReg];\n      rc = ExpandBlob(pData);\n      if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      pUnpack = vdbeUnpackRecord(&p->keyinfo, pData->n, pData->z);\n      if( !pUnpack ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n      p->pNewUnpacked = pUnpack;\n    }\n    pMem = &pUnpack->aMem[iIdx];\n    if( iIdx==p->pTab->iPKey ){\n      sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n    }else if( iIdx>=pUnpack->nField ){\n      pMem = (sqlite3_value *)columnNullValue();\n    }\n  }else{\n    /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required\n    ** value. Make a copy of the cell contents and return a pointer to it.\n    ** It is not safe to return a pointer to the memory cell itself as the\n    ** caller may modify the value text encoding.\n    */\n    assert( p->op==SQLITE_UPDATE );\n    if( !p->aNew ){\n      p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);\n      if( !p->aNew ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n    }\n    assert( iIdx>=0 && iIdx<p->pCsr->nField );\n    pMem = &p->aNew[iIdx];\n    if( pMem->flags==0 ){\n      if( iIdx==p->pTab->iPKey ){\n        sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n      }else{\n        rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);\n        if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      }\n    }\n  }\n  *ppValue = pMem;\n\n preupdate_new_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Return status data for a single loop within query pStmt.\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,            /* Prepared statement being queried */\n  int idx,                        /* Index of loop to report on */\n  int iScanStatusOp,              /* Which metric to return */\n  void *pOut                      /* OUT: Write the answer here */\n){\n  Vdbe *p = (Vdbe*)pStmt;\n  ScanStatus *pScan;\n  if( idx<0 || idx>=p->nScan ) return 1;\n  pScan = &p->aScan[idx];\n  switch( iScanStatusOp ){\n    case SQLITE_SCANSTAT_NLOOP: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrLoop];\n      break;\n    }\n    case SQLITE_SCANSTAT_NVISIT: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrVisit];\n      break;\n    }\n    case SQLITE_SCANSTAT_EST: {\n      double r = 1.0;\n      LogEst x = pScan->nEst;\n      while( x<100 ){\n        x += 10;\n        r *= 0.5;\n      }\n      *(double*)pOut = r*sqlite3LogEstToInt(x);\n      break;\n    }\n    case SQLITE_SCANSTAT_NAME: {\n      *(const char**)pOut = pScan->zName;\n      break;\n    }\n    case SQLITE_SCANSTAT_EXPLAIN: {\n      if( pScan->addrExplain ){\n        *(const char**)pOut = p->aOp[ pScan->addrExplain ].p4.z;\n      }else{\n        *(const char**)pOut = 0;\n      }\n      break;\n    }\n    case SQLITE_SCANSTAT_SELECTID: {\n      if( pScan->addrExplain ){\n        *(int*)pOut = p->aOp[ pScan->addrExplain ].p1;\n      }else{\n        *(int*)pOut = -1;\n      }\n      break;\n    }\n    default: {\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Zero all counters associated with the sqlite3_stmt_scanstatus() data.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  memset(p->anExec, 0, p->nOp * sizeof(i64));\n}\n#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */\n\n/************** End of vdbeapi.c *********************************************/\n/************** Begin file vdbetrace.c ***************************************/\n/*\n** 2009 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to insert the values of host parameters\n** (aka \"wildcards\") into the SQL text output by sqlite3_trace().\n**\n** The Vdbe parse-tree explainer is also found here.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_TRACE\n\n/*\n** zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of\n** bytes in this text up to but excluding the first character in\n** a host parameter.  If the text contains no host parameters, return\n** the total number of bytes in the text.\n*/\nstatic int findNextHostParameter(const char *zSql, int *pnToken){\n  int tokenType;\n  int nTotal = 0;\n  int n;\n\n  *pnToken = 0;\n  while( zSql[0] ){\n    n = sqlite3GetToken((u8*)zSql, &tokenType);\n    assert( n>0 && tokenType!=TK_ILLEGAL );\n    if( tokenType==TK_VARIABLE ){\n      *pnToken = n;\n      break;\n    }\n    nTotal += n;\n    zSql += n;\n  }\n  return nTotal;\n}\n\n/*\n** This function returns a pointer to a nul-terminated string in memory\n** obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the\n** string contains a copy of zRawSql but with host parameters expanded to \n** their current bindings. Or, if sqlite3.nVdbeExec is greater than 1, \n** then the returned string holds a copy of zRawSql with \"-- \" prepended\n** to each line of text.\n**\n** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then\n** then long strings and blobs are truncated to that many bytes.  This\n** can be used to prevent unreasonably large trace strings when dealing\n** with large (multi-megabyte) strings and blobs.\n**\n** The calling function is responsible for making sure the memory returned\n** is eventually freed.\n**\n** ALGORITHM:  Scan the input string looking for host parameters in any of\n** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within\n** string literals, quoted identifier names, and comments.  For text forms,\n** the host parameter index is found by scanning the prepared\n** statement for the corresponding OP_Variable opcode.  Once the host\n** parameter index is known, locate the value in p->aVar[].  Then render\n** the value as a literal in place of the host parameter name.\n*/\nSQLITE_PRIVATE char *sqlite3VdbeExpandSql(\n  Vdbe *p,                 /* The prepared statement being evaluated */\n  const char *zRawSql      /* Raw text of the SQL statement */\n){\n  sqlite3 *db;             /* The database connection */\n  int idx = 0;             /* Index of a host parameter */\n  int nextIndex = 1;       /* Index of next ? host parameter */\n  int n;                   /* Length of a token prefix */\n  int nToken;              /* Length of the parameter token */\n  int i;                   /* Loop counter */\n  Mem *pVar;               /* Value of a host parameter */\n  StrAccum out;            /* Accumulate the output here */\n#ifndef SQLITE_OMIT_UTF16\n  Mem utf8;                /* Used to convert UTF16 into UTF8 for display */\n#endif\n  char zBase[100];         /* Initial working space */\n\n  db = p->db;\n  sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), \n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  if( db->nVdbeExec>1 ){\n    while( *zRawSql ){\n      const char *zStart = zRawSql;\n      while( *(zRawSql++)!='\\n' && *zRawSql );\n      sqlite3StrAccumAppend(&out, \"-- \", 3);\n      assert( (zRawSql - zStart) > 0 );\n      sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));\n    }\n  }else if( p->nVar==0 ){\n    sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));\n  }else{\n    while( zRawSql[0] ){\n      n = findNextHostParameter(zRawSql, &nToken);\n      assert( n>0 );\n      sqlite3StrAccumAppend(&out, zRawSql, n);\n      zRawSql += n;\n      assert( zRawSql[0] || nToken==0 );\n      if( nToken==0 ) break;\n      if( zRawSql[0]=='?' ){\n        if( nToken>1 ){\n          assert( sqlite3Isdigit(zRawSql[1]) );\n          sqlite3GetInt32(&zRawSql[1], &idx);\n        }else{\n          idx = nextIndex;\n        }\n      }else{\n        assert( zRawSql[0]==':' || zRawSql[0]=='$' ||\n                zRawSql[0]=='@' || zRawSql[0]=='#' );\n        testcase( zRawSql[0]==':' );\n        testcase( zRawSql[0]=='$' );\n        testcase( zRawSql[0]=='@' );\n        testcase( zRawSql[0]=='#' );\n        idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);\n        assert( idx>0 );\n      }\n      zRawSql += nToken;\n      nextIndex = idx + 1;\n      assert( idx>0 && idx<=p->nVar );\n      pVar = &p->aVar[idx-1];\n      if( pVar->flags & MEM_Null ){\n        sqlite3StrAccumAppend(&out, \"NULL\", 4);\n      }else if( pVar->flags & MEM_Int ){\n        sqlite3XPrintf(&out, \"%lld\", pVar->u.i);\n      }else if( pVar->flags & MEM_Real ){\n        sqlite3XPrintf(&out, \"%!.15g\", pVar->u.r);\n      }else if( pVar->flags & MEM_Str ){\n        int nOut;  /* Number of bytes of the string text to include in output */\n#ifndef SQLITE_OMIT_UTF16\n        u8 enc = ENC(db);\n        if( enc!=SQLITE_UTF8 ){\n          memset(&utf8, 0, sizeof(utf8));\n          utf8.db = db;\n          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);\n          if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){\n            out.accError = STRACCUM_NOMEM;\n            out.nAlloc = 0;\n          }\n          pVar = &utf8;\n        }\n#endif\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){\n          nOut = SQLITE_TRACE_SIZE_LIMIT;\n          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }\n        }\n#endif    \n        sqlite3XPrintf(&out, \"'%.*q'\", nOut, pVar->z);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n#ifndef SQLITE_OMIT_UTF16\n        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);\n#endif\n      }else if( pVar->flags & MEM_Zero ){\n        sqlite3XPrintf(&out, \"zeroblob(%d)\", pVar->u.nZero);\n      }else{\n        int nOut;  /* Number of bytes of the blob to include in output */\n        assert( pVar->flags & MEM_Blob );\n        sqlite3StrAccumAppend(&out, \"x'\", 2);\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;\n#endif\n        for(i=0; i<nOut; i++){\n          sqlite3XPrintf(&out, \"%02x\", pVar->z[i]&0xff);\n        }\n        sqlite3StrAccumAppend(&out, \"'\", 1);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n      }\n    }\n  }\n  if( out.accError ) sqlite3StrAccumReset(&out);\n  return sqlite3StrAccumFinish(&out);\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRACE */\n\n/************** End of vdbetrace.c *******************************************/\n/************** Begin file vdbe.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** The code in this file implements the function that runs the\n** bytecode of a prepared statement.\n**\n** Various scripts scan this source file in order to generate HTML\n** documentation, headers files, or other derived files.  The formatting\n** of the code in this file is, therefore, important.  See other comments\n** in this file for details.  If in doubt, do not deviate from existing\n** commenting and indentation practices when changing or adding code.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Invoke this macro on memory cells just prior to changing the\n** value of the cell.  This macro verifies that shallow copies are\n** not misused.  A shallow copy of a string or blob just copies a\n** pointer to the string or blob, not the content.  If the original\n** is changed while the copy is still in use, the string or blob might\n** be changed out from under the copy.  This macro verifies that nothing\n** like that ever happens.\n*/\n#ifdef SQLITE_DEBUG\n# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)\n#else\n# define memAboutToChange(P,M)\n#endif\n\n/*\n** The following global variable is incremented every time a cursor\n** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test\n** procedures use this information to make sure that indices are\n** working correctly.  This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_search_count = 0;\n#endif\n\n/*\n** When this global variable is positive, it gets decremented once before\n** each instruction in the VDBE.  When it reaches zero, the u1.isInterrupted\n** field of the sqlite3 structure is set in order to simulate an interrupt.\n**\n** This facility is used for testing purposes only.  It does not function\n** in an ordinary build.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_interrupt_count = 0;\n#endif\n\n/*\n** The next global variable is incremented each type the OP_Sort opcode\n** is executed.  The test procedures use this information to make sure that\n** sorting is occurring or not occurring at appropriate times.   This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_sort_count = 0;\n#endif\n\n/*\n** The next global variable records the size of the largest MEM_Blob\n** or MEM_Str that has been used by a VDBE opcode.  The test procedures\n** use this information to make sure that the zero-blob functionality\n** is working correctly.   This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_max_blobsize = 0;\nstatic void updateMaxBlobsize(Mem *p){\n  if( (p->flags & (MEM_Str|MEM_Blob))!=0 && p->n>sqlite3_max_blobsize ){\n    sqlite3_max_blobsize = p->n;\n  }\n}\n#endif\n\n/*\n** This macro evaluates to true if either the update hook or the preupdate\n** hook are enabled for database connect DB.\n*/\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n# define HAS_UPDATE_HOOK(DB) ((DB)->xPreUpdateCallback||(DB)->xUpdateCallback)\n#else\n# define HAS_UPDATE_HOOK(DB) ((DB)->xUpdateCallback)\n#endif\n\n/*\n** The next global variable is incremented each time the OP_Found opcode\n** is executed. This is used to test whether or not the foreign key\n** operation implemented using OP_FkIsZero is working. This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_found_count = 0;\n#endif\n\n/*\n** Test a register to see if it exceeds the current maximum blob size.\n** If it does, record the new maximum blob size.\n*/\n#if defined(SQLITE_TEST) && !defined(SQLITE_UNTESTABLE)\n# define UPDATE_MAX_BLOBSIZE(P)  updateMaxBlobsize(P)\n#else\n# define UPDATE_MAX_BLOBSIZE(P)\n#endif\n\n/*\n** Invoke the VDBE coverage callback, if that callback is defined.  This\n** feature is used for test suite validation only and does not appear an\n** production builds.\n**\n** M is an integer, 2 or 3, that indices how many different ways the\n** branch can go.  It is usually 2.  \"I\" is the direction the branch\n** goes.  0 means falls through.  1 means branch is taken.  2 means the\n** second alternative branch is taken.\n**\n** iSrcLine is the source code line (from the __LINE__ macro) that\n** generated the VDBE instruction.  This instrumentation assumes that all\n** source code is in a single file (the amalgamation).  Special values 1\n** and 2 for the iSrcLine parameter mean that this particular branch is\n** always taken or never taken, respectively.\n*/\n#if !defined(SQLITE_VDBE_COVERAGE)\n# define VdbeBranchTaken(I,M)\n#else\n# define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)\n  static void vdbeTakeBranch(int iSrcLine, u8 I, u8 M){\n    if( iSrcLine<=2 && ALWAYS(iSrcLine>0) ){\n      M = iSrcLine;\n      /* Assert the truth of VdbeCoverageAlwaysTaken() and \n      ** VdbeCoverageNeverTaken() */\n      assert( (M & I)==I );\n    }else{\n      if( sqlite3GlobalConfig.xVdbeBranch==0 ) return;  /*NO_TEST*/\n      sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,\n                                      iSrcLine,I,M);\n    }\n  }\n#endif\n\n/*\n** Convert the given register into a string if it isn't one\n** already. Return non-zero if a malloc() fails.\n*/\n#define Stringify(P, enc) \\\n   if(((P)->flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc,0)) \\\n     { goto no_mem; }\n\n/*\n** An ephemeral string value (signified by the MEM_Ephem flag) contains\n** a pointer to a dynamically allocated string where some other entity\n** is responsible for deallocating that string.  Because the register\n** does not control the string, it might be deleted without the register\n** knowing it.\n**\n** This routine converts an ephemeral string into a dynamically allocated\n** string that the register itself controls.  In other words, it\n** converts an MEM_Ephem string into a string with P.z==P.zMalloc.\n*/\n#define Deephemeralize(P) \\\n   if( ((P)->flags&MEM_Ephem)!=0 \\\n       && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;}\n\n/* Return true if the cursor was opened using the OP_OpenSorter opcode. */\n#define isSorter(x) ((x)->eCurType==CURTYPE_SORTER)\n\n/*\n** Allocate VdbeCursor number iCur.  Return a pointer to it.  Return NULL\n** if we run out of memory.\n*/\nstatic VdbeCursor *allocateCursor(\n  Vdbe *p,              /* The virtual machine */\n  int iCur,             /* Index of the new VdbeCursor */\n  int nField,           /* Number of fields in the table or index */\n  int iDb,              /* Database the cursor belongs to, or -1 */\n  u8 eCurType           /* Type of the new cursor */\n){\n  /* Find the memory cell that will be used to store the blob of memory\n  ** required for this VdbeCursor structure. It is convenient to use a \n  ** vdbe memory cell to manage the memory allocation required for a\n  ** VdbeCursor structure for the following reasons:\n  **\n  **   * Sometimes cursor numbers are used for a couple of different\n  **     purposes in a vdbe program. The different uses might require\n  **     different sized allocations. Memory cells provide growable\n  **     allocations.\n  **\n  **   * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can\n  **     be freed lazily via the sqlite3_release_memory() API. This\n  **     minimizes the number of malloc calls made by the system.\n  **\n  ** The memory cell for cursor 0 is aMem[0]. The rest are allocated from\n  ** the top of the register space.  Cursor 1 is at Mem[p->nMem-1].\n  ** Cursor 2 is at Mem[p->nMem-2]. And so forth.\n  */\n  Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;\n\n  int nByte;\n  VdbeCursor *pCx = 0;\n  nByte = \n      ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + \n      (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);\n\n  assert( iCur>=0 && iCur<p->nCursor );\n  if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/\n    sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);\n    p->apCsr[iCur] = 0;\n  }\n  if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;\n    memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));\n    pCx->eCurType = eCurType;\n    pCx->iDb = iDb;\n    pCx->nField = nField;\n    pCx->aOffset = &pCx->aType[nField];\n    if( eCurType==CURTYPE_BTREE ){\n      pCx->uc.pCursor = (BtCursor*)\n          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];\n      sqlite3BtreeCursorZero(pCx->uc.pCursor);\n    }\n  }\n  return pCx;\n}\n\n/*\n** Try to convert a value into a numeric representation if we can\n** do so without loss of information.  In other words, if the string\n** looks like a number, convert it into a number.  If it does not\n** look like a number, leave it alone.\n**\n** If the bTryForInt flag is true, then extra effort is made to give\n** an integer representation.  Strings that look like floating point\n** values but which have no fractional component (example: '48.00')\n** will have a MEM_Int representation when bTryForInt is true.\n**\n** If bTryForInt is false, then if the input string contains a decimal\n** point or exponential notation, the result is only MEM_Real, even\n** if there is an exact integer representation of the quantity.\n*/\nstatic void applyNumericAffinity(Mem *pRec, int bTryForInt){\n  double rValue;\n  i64 iValue;\n  u8 enc = pRec->enc;\n  assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real))==MEM_Str );\n  if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;\n  if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){\n    pRec->u.i = iValue;\n    pRec->flags |= MEM_Int;\n  }else{\n    pRec->u.r = rValue;\n    pRec->flags |= MEM_Real;\n    if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);\n  }\n}\n\n/*\n** Processing is determine by the affinity parameter:\n**\n** SQLITE_AFF_INTEGER:\n** SQLITE_AFF_REAL:\n** SQLITE_AFF_NUMERIC:\n**    Try to convert pRec to an integer representation or a \n**    floating-point representation if an integer representation\n**    is not possible.  Note that the integer representation is\n**    always preferred, even if the affinity is REAL, because\n**    an integer representation is more space efficient on disk.\n**\n** SQLITE_AFF_TEXT:\n**    Convert pRec to a text representation.\n**\n** SQLITE_AFF_BLOB:\n**    No-op.  pRec is unchanged.\n*/\nstatic void applyAffinity(\n  Mem *pRec,          /* The value to apply affinity to */\n  char affinity,      /* The affinity to be applied */\n  u8 enc              /* Use this text encoding */\n){\n  if( affinity>=SQLITE_AFF_NUMERIC ){\n    assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL\n             || affinity==SQLITE_AFF_NUMERIC );\n    if( (pRec->flags & MEM_Int)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags & MEM_Real)==0 ){\n        if( pRec->flags & MEM_Str ) applyNumericAffinity(pRec,1);\n      }else{\n        sqlite3VdbeIntegerAffinity(pRec);\n      }\n    }\n  }else if( affinity==SQLITE_AFF_TEXT ){\n    /* Only attempt the conversion to TEXT if there is an integer or real\n    ** representation (blob and NULL do not get converted) but no string\n    ** representation.  It would be harmless to repeat the conversion if \n    ** there is already a string rep, but it is pointless to waste those\n    ** CPU cycles. */\n    if( 0==(pRec->flags&MEM_Str) ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags&(MEM_Real|MEM_Int)) ){\n        sqlite3VdbeMemStringify(pRec, enc, 1);\n      }\n    }\n    pRec->flags &= ~(MEM_Real|MEM_Int);\n  }\n}\n\n/*\n** Try to convert the type of a function argument or a result column\n** into a numeric representation.  Use either INTEGER or REAL whichever\n** is appropriate.  But only do the conversion if it is possible without\n** loss of information and return the revised type of the argument.\n*/\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){\n  int eType = sqlite3_value_type(pVal);\n  if( eType==SQLITE_TEXT ){\n    Mem *pMem = (Mem*)pVal;\n    applyNumericAffinity(pMem, 0);\n    eType = sqlite3_value_type(pVal);\n  }\n  return eType;\n}\n\n/*\n** Exported version of applyAffinity(). This one works on sqlite3_value*, \n** not the internal Mem* type.\n*/\nSQLITE_PRIVATE void sqlite3ValueApplyAffinity(\n  sqlite3_value *pVal, \n  u8 affinity, \n  u8 enc\n){\n  applyAffinity((Mem *)pVal, affinity, enc);\n}\n\n/*\n** pMem currently only holds a string type (or maybe a BLOB that we can\n** interpret as a string if we want to).  Compute its corresponding\n** numeric type, if has one.  Set the pMem->u.r and pMem->u.i fields\n** accordingly.\n*/\nstatic u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){\n  assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );\n  assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );\n  if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){\n    return 0;\n  }\n  if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){\n    return MEM_Int;\n  }\n  return MEM_Real;\n}\n\n/*\n** Return the numeric type for pMem, either MEM_Int or MEM_Real or both or\n** none.  \n**\n** Unlike applyNumericAffinity(), this routine does not modify pMem->flags.\n** But it does set pMem->u.r and pMem->u.i appropriately.\n*/\nstatic u16 numericType(Mem *pMem){\n  if( pMem->flags & (MEM_Int|MEM_Real) ){\n    return pMem->flags & (MEM_Int|MEM_Real);\n  }\n  if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return computeNumericType(pMem);\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Write a nice string representation of the contents of cell pMem\n** into buffer zBuf, length nBuf.\n*/\nSQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){\n  char *zCsr = zBuf;\n  int f = pMem->flags;\n\n  static const char *const encnames[] = {\"(X)\", \"(8)\", \"(16LE)\", \"(16BE)\"};\n\n  if( f&MEM_Blob ){\n    int i;\n    char c;\n    if( f & MEM_Dyn ){\n      c = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      c = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      c = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      c = 's';\n    }\n    *(zCsr++) = c;\n    sqlite3_snprintf(100, zCsr, \"%d[\", pMem->n);\n    zCsr += sqlite3Strlen30(zCsr);\n    for(i=0; i<16 && i<pMem->n; i++){\n      sqlite3_snprintf(100, zCsr, \"%02X\", ((int)pMem->z[i] & 0xFF));\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    for(i=0; i<16 && i<pMem->n; i++){\n      char z = pMem->z[i];\n      if( z<32 || z>126 ) *zCsr++ = '.';\n      else *zCsr++ = z;\n    }\n    *(zCsr++) = ']';\n    if( f & MEM_Zero ){\n      sqlite3_snprintf(100, zCsr,\"+%dz\",pMem->u.nZero);\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    *zCsr = '\\0';\n  }else if( f & MEM_Str ){\n    int j, k;\n    zBuf[0] = ' ';\n    if( f & MEM_Dyn ){\n      zBuf[1] = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      zBuf[1] = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      zBuf[1] = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      zBuf[1] = 's';\n    }\n    k = 2;\n    sqlite3_snprintf(100, &zBuf[k], \"%d\", pMem->n);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = '[';\n    for(j=0; j<15 && j<pMem->n; j++){\n      u8 c = pMem->z[j];\n      if( c>=0x20 && c<0x7f ){\n        zBuf[k++] = c;\n      }else{\n        zBuf[k++] = '.';\n      }\n    }\n    zBuf[k++] = ']';\n    sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = 0;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the value of a register for tracing purposes:\n*/\nstatic void memTracePrint(Mem *p){\n  if( p->flags & MEM_Undefined ){\n    printf(\" undefined\");\n  }else if( p->flags & MEM_Null ){\n    printf(\" NULL\");\n  }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){\n    printf(\" si:%lld\", p->u.i);\n  }else if( p->flags & MEM_Int ){\n    printf(\" i:%lld\", p->u.i);\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  }else if( p->flags & MEM_Real ){\n    printf(\" r:%g\", p->u.r);\n#endif\n  }else if( p->flags & MEM_RowSet ){\n    printf(\" (rowset)\");\n  }else{\n    char zBuf[200];\n    sqlite3VdbeMemPrettyPrint(p, zBuf);\n    printf(\" %s\", zBuf);\n  }\n  if( p->flags & MEM_Subtype ) printf(\" subtype=0x%02x\", p->eSubtype);\n}\nstatic void registerTrace(int iReg, Mem *p){\n  printf(\"REG[%d] = \", iReg);\n  memTracePrint(p);\n  printf(\"\\n\");\n  sqlite3VdbeCheckMemInvariants(p);\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n#  define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)\n#else\n#  define REGISTER_TRACE(R,M)\n#endif\n\n\n#ifdef VDBE_PROFILE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n/************** Include hwtime.h in the middle of vdbe.c *********************/\n/************** Begin file hwtime.h ******************************************/\n/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\nSQLITE_PRIVATE   sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n\n/************** End of hwtime.h **********************************************/\n/************** Continuing where we left off in vdbe.c ***********************/\n\n#endif\n\n#ifndef NDEBUG\n/*\n** This function is only called from within an assert() expression. It\n** checks that the sqlite3.nTransaction variable is correctly set to\n** the number of non-transaction savepoints currently in the \n** linked list starting at sqlite3.pSavepoint.\n** \n** Usage:\n**\n**     assert( checkSavepointCount(db) );\n*/\nstatic int checkSavepointCount(sqlite3 *db){\n  int n = 0;\n  Savepoint *p;\n  for(p=db->pSavepoint; p; p=p->pNext) n++;\n  assert( n==(db->nSavepoint + db->isTransactionSavepoint) );\n  return 1;\n}\n#endif\n\n/*\n** Return the register of pOp->p2 after first preparing it to be\n** overwritten with an integer value.\n*/\nstatic SQLITE_NOINLINE Mem *out2PrereleaseWithClear(Mem *pOut){\n  sqlite3VdbeMemSetNull(pOut);\n  pOut->flags = MEM_Int;\n  return pOut;\n}\nstatic Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){\n  Mem *pOut;\n  assert( pOp->p2>0 );\n  assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n  pOut = &p->aMem[pOp->p2];\n  memAboutToChange(p, pOut);\n  if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/\n    return out2PrereleaseWithClear(pOut);\n  }else{\n    pOut->flags = MEM_Int;\n    return pOut;\n  }\n}\n\n\n/*\n** Execute as much of a VDBE program as we can.\n** This is the core of sqlite3_step().  \n*/\nSQLITE_PRIVATE int sqlite3VdbeExec(\n  Vdbe *p                    /* The VDBE */\n){\n  Op *aOp = p->aOp;          /* Copy of p->aOp */\n  Op *pOp = aOp;             /* Current operation */\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  Op *pOrigOp;               /* Value of pOp at the top of the loop */\n#endif\n#ifdef SQLITE_DEBUG\n  int nExtraDelete = 0;      /* Verifies FORDELETE and AUXDELETE flags */\n#endif\n  int rc = SQLITE_OK;        /* Value to return */\n  sqlite3 *db = p->db;       /* The database */\n  u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */\n  u8 encoding = ENC(db);     /* The database encoding */\n  int iCompare = 0;          /* Result of last comparison */\n  unsigned nVmStep = 0;      /* Number of virtual machine steps */\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  unsigned nProgressLimit;   /* Invoke xProgress() when nVmStep reaches this */\n#endif\n  Mem *aMem = p->aMem;       /* Copy of p->aMem */\n  Mem *pIn1 = 0;             /* 1st input operand */\n  Mem *pIn2 = 0;             /* 2nd input operand */\n  Mem *pIn3 = 0;             /* 3rd input operand */\n  Mem *pOut = 0;             /* Output operand */\n#ifdef VDBE_PROFILE\n  u64 start;                 /* CPU clock count at start of opcode */\n#endif\n  /*** INSERT STACK UNION HERE ***/\n\n  assert( p->magic==VDBE_MAGIC_RUN );  /* sqlite3_step() verifies this */\n  sqlite3VdbeEnter(p);\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    goto no_mem;\n  }\n  assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY );\n  assert( p->bIsReader || p->readOnly!=0 );\n  p->iCurrentTime = 0;\n  assert( p->explain==0 );\n  p->pResultSet = 0;\n  db->busyHandler.nBusy = 0;\n  if( db->u1.isInterrupted ) goto abort_due_to_interrupt;\n  sqlite3VdbeIOTraceSql(p);\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  if( db->xProgress ){\n    u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];\n    assert( 0 < db->nProgressOps );\n    nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);\n  }else{\n    nProgressLimit = 0xffffffff;\n  }\n#endif\n#ifdef SQLITE_DEBUG\n  sqlite3BeginBenignMalloc();\n  if( p->pc==0\n   && (p->db->flags & (SQLITE_VdbeListing|SQLITE_VdbeEQP|SQLITE_VdbeTrace))!=0\n  ){\n    int i;\n    int once = 1;\n    sqlite3VdbePrintSql(p);\n    if( p->db->flags & SQLITE_VdbeListing ){\n      printf(\"VDBE Program Listing:\\n\");\n      for(i=0; i<p->nOp; i++){\n        sqlite3VdbePrintOp(stdout, i, &aOp[i]);\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeEQP ){\n      for(i=0; i<p->nOp; i++){\n        if( aOp[i].opcode==OP_Explain ){\n          if( once ) printf(\"VDBE Query Plan:\\n\");\n          printf(\"%s\\n\", aOp[i].p4.z);\n          once = 0;\n        }\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeTrace )  printf(\"VDBE Trace:\\n\");\n  }\n  sqlite3EndBenignMalloc();\n#endif\n  for(pOp=&aOp[p->pc]; 1; pOp++){\n    /* Errors are detected by individual opcodes, with an immediate\n    ** jumps to abort_due_to_error. */\n    assert( rc==SQLITE_OK );\n\n    assert( pOp>=aOp && pOp<&aOp[p->nOp]);\n#ifdef VDBE_PROFILE\n    start = sqlite3Hwtime();\n#endif\n    nVmStep++;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    if( p->anExec ) p->anExec[(int)(pOp-aOp)]++;\n#endif\n\n    /* Only allow tracing if SQLITE_DEBUG is defined.\n    */\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);\n    }\n#endif\n      \n\n    /* Check to see if we need to simulate an interrupt.  This only happens\n    ** if we have a special test build.\n    */\n#ifdef SQLITE_TEST\n    if( sqlite3_interrupt_count>0 ){\n      sqlite3_interrupt_count--;\n      if( sqlite3_interrupt_count==0 ){\n        sqlite3_interrupt(db);\n      }\n    }\n#endif\n\n    /* Sanity checking on other operands */\n#ifdef SQLITE_DEBUG\n    {\n      u8 opProperty = sqlite3OpcodeProperty[pOp->opcode];\n      if( (opProperty & OPFLG_IN1)!=0 ){\n        assert( pOp->p1>0 );\n        assert( pOp->p1<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p1]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );\n        REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);\n      }\n      if( (opProperty & OPFLG_IN2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p2]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p2]) );\n        REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_IN3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p3]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p3]) );\n        REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);\n      }\n      if( (opProperty & OPFLG_OUT2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_OUT3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p3]);\n      }\n    }\n#endif\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    pOrigOp = pOp;\n#endif\n  \n    switch( pOp->opcode ){\n\n/*****************************************************************************\n** What follows is a massive switch statement where each case implements a\n** separate instruction in the virtual machine.  If we follow the usual\n** indentation conventions, each case should be indented by 6 spaces.  But\n** that is a lot of wasted space on the left margin.  So the code within\n** the switch statement will break with convention and be flush-left. Another\n** big comment (similar to this one) will mark the point in the code where\n** we transition back to normal indentation.\n**\n** The formatting of each case is important.  The makefile for SQLite\n** generates two C files \"opcodes.h\" and \"opcodes.c\" by scanning this\n** file looking for lines that begin with \"case OP_\".  The opcodes.h files\n** will be filled with #defines that give unique integer values to each\n** opcode and the opcodes.c file is filled with an array of strings where\n** each string is the symbolic name for the corresponding opcode.  If the\n** case statement is followed by a comment of the form \"/# same as ... #/\"\n** that comment is used to determine the particular value of the opcode.\n**\n** Other keywords in the comment that follows each case are used to\n** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].\n** Keywords include: in1, in2, in3, out2, out3.  See\n** the mkopcodeh.awk script for additional information.\n**\n** Documentation about VDBE opcodes is generated by scanning this file\n** for lines of that contain \"Opcode:\".  That line and all subsequent\n** comment lines are used in the generation of the opcode.html documentation\n** file.\n**\n** SUMMARY:\n**\n**     Formatting is important to scripts that scan this file.\n**     Do not deviate from the formatting style currently in use.\n**\n*****************************************************************************/\n\n/* Opcode:  Goto * P2 * * *\n**\n** An unconditional jump to address P2.\n** The next instruction executed will be \n** the one at index P2 from the beginning of\n** the program.\n**\n** The P1 parameter is not actually used by this opcode.  However, it\n** is sometimes set to 1 instead of 0 as a hint to the command-line shell\n** that this Goto is the bottom of a loop and that the lines from P2 down\n** to the current line should be indented for EXPLAIN output.\n*/\ncase OP_Goto: {             /* jump */\njump_to_p2_and_check_for_interrupt:\n  pOp = &aOp[pOp->p2 - 1];\n\n  /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,\n  ** OP_VNext, or OP_SorterNext) all jump here upon\n  ** completion.  Check to see if sqlite3_interrupt() has been called\n  ** or if the progress callback needs to be invoked. \n  **\n  ** This code uses unstructured \"goto\" statements and does not look clean.\n  ** But that is not due to sloppy coding habits. The code is written this\n  ** way for performance, to avoid having to run the interrupt and progress\n  ** checks on every opcode.  This helps sqlite3_step() to run about 1.5%\n  ** faster according to \"valgrind --tool=cachegrind\" */\ncheck_for_interrupt:\n  if( db->u1.isInterrupted ) goto abort_due_to_interrupt;\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Call the progress callback if it is configured and the required number\n  ** of VDBE ops have been executed (either since this invocation of\n  ** sqlite3VdbeExec() or since last time the progress callback was called).\n  ** If the progress callback returns non-zero, exit the virtual machine with\n  ** a return code SQLITE_ABORT.\n  */\n  if( nVmStep>=nProgressLimit && db->xProgress!=0 ){\n    assert( db->nProgressOps!=0 );\n    nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);\n    if( db->xProgress(db->pProgressArg) ){\n      rc = SQLITE_INTERRUPT;\n      goto abort_due_to_error;\n    }\n  }\n#endif\n  \n  break;\n}\n\n/* Opcode:  Gosub P1 P2 * * *\n**\n** Write the current address onto register P1\n** and then jump to address P2.\n*/\ncase OP_Gosub: {            /* jump */\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  memAboutToChange(p, pIn1);\n  pIn1->flags = MEM_Int;\n  pIn1->u.i = (int)(pOp-aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n\n  /* Most jump operations do a goto to this spot in order to update\n  ** the pOp pointer. */\njump_to_p2:\n  pOp = &aOp[pOp->p2 - 1];\n  break;\n}\n\n/* Opcode:  Return P1 * * * *\n**\n** Jump to the next instruction after the address in register P1.  After\n** the jump, register P1 becomes undefined.\n*/\ncase OP_Return: {           /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  pOp = &aOp[pIn1->u.i];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode: InitCoroutine P1 P2 P3 * *\n**\n** Set up register P1 so that it will Yield to the coroutine\n** located at address P3.\n**\n** If P2!=0 then the coroutine implementation immediately follows\n** this opcode.  So jump over the coroutine implementation to\n** address P2.\n**\n** See also: EndCoroutine\n*/\ncase OP_InitCoroutine: {     /* jump */\n  assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );\n  assert( pOp->p2>=0 && pOp->p2<p->nOp );\n  assert( pOp->p3>=0 && pOp->p3<p->nOp );\n  pOut = &aMem[pOp->p1];\n  assert( !VdbeMemDynamic(pOut) );\n  pOut->u.i = pOp->p3 - 1;\n  pOut->flags = MEM_Int;\n  if( pOp->p2 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode:  EndCoroutine P1 * * * *\n**\n** The instruction at the address in register P1 is a Yield.\n** Jump to the P2 parameter of that Yield.\n** After the jump, register P1 becomes undefined.\n**\n** See also: InitCoroutine\n*/\ncase OP_EndCoroutine: {           /* in1 */\n  VdbeOp *pCaller;\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );\n  pCaller = &aOp[pIn1->u.i];\n  assert( pCaller->opcode==OP_Yield );\n  assert( pCaller->p2>=0 && pCaller->p2<p->nOp );\n  pOp = &aOp[pCaller->p2 - 1];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode:  Yield P1 P2 * * *\n**\n** Swap the program counter with the value in register P1.  This\n** has the effect of yielding to a coroutine.\n**\n** If the coroutine that is launched by this instruction ends with\n** Yield or Return then continue to the next instruction.  But if\n** the coroutine launched by this instruction ends with\n** EndCoroutine, then jump to P2 rather than continuing with the\n** next instruction.\n**\n** See also: InitCoroutine\n*/\ncase OP_Yield: {            /* in1, jump */\n  int pcDest;\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  pIn1->flags = MEM_Int;\n  pcDest = (int)pIn1->u.i;\n  pIn1->u.i = (int)(pOp - aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n  pOp = &aOp[pcDest];\n  break;\n}\n\n/* Opcode:  HaltIfNull  P1 P2 P3 P4 P5\n** Synopsis: if r[P3]=null halt\n**\n** Check the value in register P3.  If it is NULL then Halt using\n** parameter P1, P2, and P4 as if this were a Halt instruction.  If the\n** value in register P3 is not NULL, then this routine is a no-op.\n** The P5 parameter should be 1.\n*/\ncase OP_HaltIfNull: {      /* in3 */\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Null)==0 ) break;\n  /* Fall through into OP_Halt */\n}\n\n/* Opcode:  Halt P1 P2 * P4 P5\n**\n** Exit immediately.  All open cursors, etc are closed\n** automatically.\n**\n** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),\n** or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).\n** For errors, it can be some other value.  If P1!=0 then P2 will determine\n** whether or not to rollback the current transaction.  Do not rollback\n** if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,\n** then back out all changes that have occurred during this execution of the\n** VDBE, but do not rollback the transaction. \n**\n** If P4 is not null then it is an error message string.\n**\n** P5 is a value between 0 and 4, inclusive, that modifies the P4 string.\n**\n**    0:  (no change)\n**    1:  NOT NULL contraint failed: P4\n**    2:  UNIQUE constraint failed: P4\n**    3:  CHECK constraint failed: P4\n**    4:  FOREIGN KEY constraint failed: P4\n**\n** If P5 is not zero and P4 is NULL, then everything after the \":\" is\n** omitted.\n**\n** There is an implied \"Halt 0 0 0\" instruction inserted at the very end of\n** every program.  So a jump past the last instruction of the program\n** is the same as executing Halt.\n*/\ncase OP_Halt: {\n  VdbeFrame *pFrame;\n  int pcx;\n\n  pcx = (int)(pOp - aOp);\n  if( pOp->p1==SQLITE_OK && p->pFrame ){\n    /* Halt the sub-program. Return control to the parent frame. */\n    pFrame = p->pFrame;\n    p->pFrame = pFrame->pParent;\n    p->nFrame--;\n    sqlite3VdbeSetChanges(db, p->nChange);\n    pcx = sqlite3VdbeFrameRestore(pFrame);\n    if( pOp->p2==OE_Ignore ){\n      /* Instruction pcx is the OP_Program that invoked the sub-program \n      ** currently being halted. If the p2 instruction of this OP_Halt\n      ** instruction is set to OE_Ignore, then the sub-program is throwing\n      ** an IGNORE exception. In this case jump to the address specified\n      ** as the p2 of the calling OP_Program.  */\n      pcx = p->aOp[pcx].p2-1;\n    }\n    aOp = p->aOp;\n    aMem = p->aMem;\n    pOp = &aOp[pcx];\n    break;\n  }\n  p->rc = pOp->p1;\n  p->errorAction = (u8)pOp->p2;\n  p->pc = pcx;\n  assert( pOp->p5<=4 );\n  if( p->rc ){\n    if( pOp->p5 ){\n      static const char * const azType[] = { \"NOT NULL\", \"UNIQUE\", \"CHECK\",\n                                             \"FOREIGN KEY\" };\n      testcase( pOp->p5==1 );\n      testcase( pOp->p5==2 );\n      testcase( pOp->p5==3 );\n      testcase( pOp->p5==4 );\n      sqlite3VdbeError(p, \"%s constraint failed\", azType[pOp->p5-1]);\n      if( pOp->p4.z ){\n        p->zErrMsg = sqlite3MPrintf(db, \"%z: %s\", p->zErrMsg, pOp->p4.z);\n      }\n    }else{\n      sqlite3VdbeError(p, \"%s\", pOp->p4.z);\n    }\n    sqlite3_log(pOp->p1, \"abort at %d in [%s]: %s\", pcx, p->zSql, p->zErrMsg);\n  }\n  rc = sqlite3VdbeHalt(p);\n  assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );\n  if( rc==SQLITE_BUSY ){\n    p->rc = SQLITE_BUSY;\n  }else{\n    assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );\n    assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );\n    rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;\n  }\n  goto vdbe_return;\n}\n\n/* Opcode: Integer P1 P2 * * *\n** Synopsis: r[P2]=P1\n**\n** The 32-bit integer value P1 is written into register P2.\n*/\ncase OP_Integer: {         /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = pOp->p1;\n  break;\n}\n\n/* Opcode: Int64 * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit integer value.\n** Write that value into register P2.\n*/\ncase OP_Int64: {           /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p4.pI64!=0 );\n  pOut->u.i = *pOp->p4.pI64;\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: Real * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit floating point value.\n** Write that value into register P2.\n*/\ncase OP_Real: {            /* same as TK_FLOAT, out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Real;\n  assert( !sqlite3IsNaN(*pOp->p4.pReal) );\n  pOut->u.r = *pOp->p4.pReal;\n  break;\n}\n#endif\n\n/* Opcode: String8 * P2 * P4 *\n** Synopsis: r[P2]='P4'\n**\n** P4 points to a nul terminated UTF-8 string. This opcode is transformed \n** into a String opcode before it is executed for the first time.  During\n** this transformation, the length of string P4 is computed and stored\n** as the P1 parameter.\n*/\ncase OP_String8: {         /* same as TK_STRING, out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOp->opcode = OP_String;\n  pOp->p1 = sqlite3Strlen30(pOp->p4.z);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( encoding!=SQLITE_UTF8 ){\n    rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);\n    assert( rc==SQLITE_OK || rc==SQLITE_TOOBIG );\n    if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem;\n    assert( pOut->szMalloc>0 && pOut->zMalloc==pOut->z );\n    assert( VdbeMemDynamic(pOut)==0 );\n    pOut->szMalloc = 0;\n    pOut->flags |= MEM_Static;\n    if( pOp->p4type==P4_DYNAMIC ){\n      sqlite3DbFree(db, pOp->p4.z);\n    }\n    pOp->p4type = P4_DYNAMIC;\n    pOp->p4.z = pOut->z;\n    pOp->p1 = pOut->n;\n  }\n  testcase( rc==SQLITE_TOOBIG );\n#endif\n  if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  assert( rc==SQLITE_OK );\n  /* Fall through to the next case, OP_String */\n}\n  \n/* Opcode: String P1 P2 P3 P4 P5\n** Synopsis: r[P2]='P4' (len=P1)\n**\n** The string value P4 of length P1 (bytes) is stored in register P2.\n**\n** If P3 is not zero and the content of register P3 is equal to P5, then\n** the datatype of the register P2 is converted to BLOB.  The content is\n** the same sequence of bytes, it is merely interpreted as a BLOB instead\n** of a string, as if it had been CAST.  In other words:\n**\n** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB)\n*/\ncase OP_String: {          /* out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = pOp->p4.z;\n  pOut->n = pOp->p1;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( pOp->p3>0 ){\n    assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n    pIn3 = &aMem[pOp->p3];\n    assert( pIn3->flags & MEM_Int );\n    if( pIn3->u.i==pOp->p5 ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;\n  }\n#endif\n  break;\n}\n\n/* Opcode: Null P1 P2 P3 * *\n** Synopsis: r[P2..P3]=NULL\n**\n** Write a NULL into registers P2.  If P3 greater than P2, then also write\n** NULL into register P3 and every register in between P2 and P3.  If P3\n** is less than P2 (typically P3 is zero) then only register P2 is\n** set to NULL.\n**\n** If the P1 value is non-zero, then also set the MEM_Cleared flag so that\n** NULL values will not compare equal even if SQLITE_NULLEQ is set on\n** OP_Ne or OP_Eq.\n*/\ncase OP_Null: {           /* out2 */\n  int cnt;\n  u16 nullFlag;\n  pOut = out2Prerelease(p, pOp);\n  cnt = pOp->p3-pOp->p2;\n  assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;\n  pOut->n = 0;\n  while( cnt>0 ){\n    pOut++;\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemSetNull(pOut);\n    pOut->flags = nullFlag;\n    pOut->n = 0;\n    cnt--;\n  }\n  break;\n}\n\n/* Opcode: SoftNull P1 * * * *\n** Synopsis: r[P1]=NULL\n**\n** Set register P1 to have the value NULL as seen by the OP_MakeRecord\n** instruction, but do not free any string or blob memory associated with\n** the register, so that if the value was a string or blob that was\n** previously copied using OP_SCopy, the copies will continue to be valid.\n*/\ncase OP_SoftNull: {\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pOut = &aMem[pOp->p1];\n  pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null;\n  break;\n}\n\n/* Opcode: Blob P1 P2 * P4 *\n** Synopsis: r[P2]=P4 (len=P1)\n**\n** P4 points to a blob of data P1 bytes long.  Store this\n** blob in register P2.\n*/\ncase OP_Blob: {                /* out2 */\n  assert( pOp->p1 <= SQLITE_MAX_LENGTH );\n  pOut = out2Prerelease(p, pOp);\n  sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Variable P1 P2 * P4 *\n** Synopsis: r[P2]=parameter(P1,P4)\n**\n** Transfer the values of bound parameter P1 into register P2\n**\n** If the parameter is named, then its name appears in P4.\n** The P4 value is used by sqlite3_bind_parameter_name().\n*/\ncase OP_Variable: {            /* out2 */\n  Mem *pVar;       /* Value being transferred */\n\n  assert( pOp->p1>0 && pOp->p1<=p->nVar );\n  assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) );\n  pVar = &p->aVar[pOp->p1 - 1];\n  if( sqlite3VdbeMemTooBig(pVar) ){\n    goto too_big;\n  }\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Move P1 P2 P3 * *\n** Synopsis: r[P2@P3]=r[P1@P3]\n**\n** Move the P3 values in register P1..P1+P3-1 over into\n** registers P2..P2+P3-1.  Registers P1..P1+P3-1 are\n** left holding a NULL.  It is an error for register ranges\n** P1..P1+P3-1 and P2..P2+P3-1 to overlap.  It is an error\n** for P3 to be less than 1.\n*/\ncase OP_Move: {\n  int n;           /* Number of registers left to copy */\n  int p1;          /* Register to copy from */\n  int p2;          /* Register to copy to */\n\n  n = pOp->p3;\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n  assert( n>0 && p1>0 && p2>0 );\n  assert( p1+n<=p2 || p2+n<=p1 );\n\n  pIn1 = &aMem[p1];\n  pOut = &aMem[p2];\n  do{\n    assert( pOut<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( pIn1<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemMove(pOut, pIn1);\n#ifdef SQLITE_DEBUG\n    if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<pOut ){\n      pOut->pScopyFrom += pOp->p2 - p1;\n    }\n#endif\n    Deephemeralize(pOut);\n    REGISTER_TRACE(p2++, pOut);\n    pIn1++;\n    pOut++;\n  }while( --n );\n  break;\n}\n\n/* Opcode: Copy P1 P2 P3 * *\n** Synopsis: r[P2@P3+1]=r[P1@P3+1]\n**\n** Make a copy of registers P1..P1+P3 into registers P2..P2+P3.\n**\n** This instruction makes a deep copy of the value.  A duplicate\n** is made of any string or blob constant.  See also OP_SCopy.\n*/\ncase OP_Copy: {\n  int n;\n\n  n = pOp->p3;\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  while( 1 ){\n    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n    Deephemeralize(pOut);\n#ifdef SQLITE_DEBUG\n    pOut->pScopyFrom = 0;\n#endif\n    REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);\n    if( (n--)==0 ) break;\n    pOut++;\n    pIn1++;\n  }\n  break;\n}\n\n/* Opcode: SCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Make a shallow copy of register P1 into register P2.\n**\n** This instruction makes a shallow copy of the value.  If the value\n** is a string or blob, then the copy is only a pointer to the\n** original and hence if the original changes so will the copy.\n** Worse, if the original is deallocated, the copy becomes invalid.\n** Thus the program must guarantee that the original will not change\n** during the lifetime of the copy.  Use OP_Copy to make a complete\n** copy.\n*/\ncase OP_SCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n#ifdef SQLITE_DEBUG\n  if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;\n#endif\n  break;\n}\n\n/* Opcode: IntCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Transfer the integer value held in register P1 into register P2.\n**\n** This is an optimized version of SCopy that works only for integer\n** values.\n*/\ncase OP_IntCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Int)!=0 );\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);\n  break;\n}\n\n/* Opcode: ResultRow P1 P2 * * *\n** Synopsis: output=r[P1@P2]\n**\n** The registers P1 through P1+P2-1 contain a single row of\n** results. This opcode causes the sqlite3_step() call to terminate\n** with an SQLITE_ROW return code and it sets up the sqlite3_stmt\n** structure to provide access to the r(P1)..r(P1+P2-1) values as\n** the result row.\n*/\ncase OP_ResultRow: {\n  Mem *pMem;\n  int i;\n  assert( p->nResColumn==pOp->p2 );\n  assert( pOp->p1>0 );\n  assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 );\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Run the progress counter just before returning.\n  */\n  if( db->xProgress!=0\n   && nVmStep>=nProgressLimit \n   && db->xProgress(db->pProgressArg)!=0\n  ){\n    rc = SQLITE_INTERRUPT;\n    goto abort_due_to_error;\n  }\n#endif\n\n  /* If this statement has violated immediate foreign key constraints, do\n  ** not return the number of rows modified. And do not RELEASE the statement\n  ** transaction. It needs to be rolled back.  */\n  if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){\n    assert( db->flags&SQLITE_CountRows );\n    assert( p->usesStmtJournal );\n    goto abort_due_to_error;\n  }\n\n  /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then \n  ** DML statements invoke this opcode to return the number of rows \n  ** modified to the user. This is the only way that a VM that\n  ** opens a statement transaction may invoke this opcode.\n  **\n  ** In case this is such a statement, close any statement transaction\n  ** opened by this VM before returning control to the user. This is to\n  ** ensure that statement-transactions are always nested, not overlapping.\n  ** If the open statement-transaction is not closed here, then the user\n  ** may step another VM that opens its own statement transaction. This\n  ** may lead to overlapping statement transactions.\n  **\n  ** The statement transaction is never a top-level transaction.  Hence\n  ** the RELEASE call below can never fail.\n  */\n  assert( p->iStatement==0 || db->flags&SQLITE_CountRows );\n  rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);\n  assert( rc==SQLITE_OK );\n\n  /* Invalidate all ephemeral cursor row caches */\n  p->cacheCtr = (p->cacheCtr + 2)|1;\n\n  /* Make sure the results of the current row are \\000 terminated\n  ** and have an assigned type.  The results are de-ephemeralized as\n  ** a side effect.\n  */\n  pMem = p->pResultSet = &aMem[pOp->p1];\n  for(i=0; i<pOp->p2; i++){\n    assert( memIsValid(&pMem[i]) );\n    Deephemeralize(&pMem[i]);\n    assert( (pMem[i].flags & MEM_Ephem)==0\n            || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );\n    sqlite3VdbeMemNulTerminate(&pMem[i]);\n    REGISTER_TRACE(pOp->p1+i, &pMem[i]);\n  }\n  if( db->mallocFailed ) goto no_mem;\n\n  if( db->mTrace & SQLITE_TRACE_ROW ){\n    db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);\n  }\n\n  /* Return SQLITE_ROW\n  */\n  p->pc = (int)(pOp - aOp) + 1;\n  rc = SQLITE_ROW;\n  goto vdbe_return;\n}\n\n/* Opcode: Concat P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]+r[P1]\n**\n** Add the text in register P1 onto the end of the text in\n** register P2 and store the result in register P3.\n** If either the P1 or P2 text are NULL then store NULL in P3.\n**\n**   P3 = P2 || P1\n**\n** It is illegal for P1 and P3 to be the same register. Sometimes,\n** if P3 is the same register as P2, the implementation is able\n** to avoid a memcpy().\n*/\ncase OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */\n  i64 nByte;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  assert( pIn1!=pOut );\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  if( ExpandBlob(pIn1) || ExpandBlob(pIn2) ) goto no_mem;\n  Stringify(pIn1, encoding);\n  Stringify(pIn2, encoding);\n  nByte = pIn1->n + pIn2->n;\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){\n    goto no_mem;\n  }\n  MemSetTypeFlag(pOut, MEM_Str);\n  if( pOut!=pIn2 ){\n    memcpy(pOut->z, pIn2->z, pIn2->n);\n  }\n  memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);\n  pOut->z[nByte]=0;\n  pOut->z[nByte+1] = 0;\n  pOut->flags |= MEM_Term;\n  pOut->n = (int)nByte;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Add P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]+r[P2]\n**\n** Add the value in register P1 to the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Multiply P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]*r[P2]\n**\n**\n** Multiply the value in register P1 by the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Subtract P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]-r[P1]\n**\n** Subtract the value in register P1 from the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Divide P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]/r[P1]\n**\n** Divide the value in register P1 by the value in register P2\n** and store the result in register P3 (P3=P2/P1). If the value in \n** register P1 is zero, then the result is NULL. If either input is \n** NULL, the result is NULL.\n*/\n/* Opcode: Remainder P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]%r[P1]\n**\n** Compute the remainder after integer register P2 is divided by \n** register P1 and store the result in register P3. \n** If the value in register P1 is zero the result is NULL.\n** If either operand is NULL, the result is NULL.\n*/\ncase OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */\ncase OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */\ncase OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */\ncase OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */\ncase OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */\n  char bIntint;   /* Started out as two integer operands */\n  u16 flags;      /* Combined MEM_* flags from both inputs */\n  u16 type1;      /* Numeric type of left operand */\n  u16 type2;      /* Numeric type of right operand */\n  i64 iA;         /* Integer value of left operand */\n  i64 iB;         /* Integer value of right operand */\n  double rA;      /* Real value of left operand */\n  double rB;      /* Real value of right operand */\n\n  pIn1 = &aMem[pOp->p1];\n  type1 = numericType(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  type2 = numericType(pIn2);\n  pOut = &aMem[pOp->p3];\n  flags = pIn1->flags | pIn2->flags;\n  if( (type1 & type2 & MEM_Int)!=0 ){\n    iA = pIn1->u.i;\n    iB = pIn2->u.i;\n    bIntint = 1;\n    switch( pOp->opcode ){\n      case OP_Add:       if( sqlite3AddInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Subtract:  if( sqlite3SubInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Multiply:  if( sqlite3MulInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Divide: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 && iB==SMALLEST_INT64 ) goto fp_math;\n        iB /= iA;\n        break;\n      }\n      default: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        iB %= iA;\n        break;\n      }\n    }\n    pOut->u.i = iB;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }else if( (flags & MEM_Null)!=0 ){\n    goto arithmetic_result_is_null;\n  }else{\n    bIntint = 0;\nfp_math:\n    rA = sqlite3VdbeRealValue(pIn1);\n    rB = sqlite3VdbeRealValue(pIn2);\n    switch( pOp->opcode ){\n      case OP_Add:         rB += rA;       break;\n      case OP_Subtract:    rB -= rA;       break;\n      case OP_Multiply:    rB *= rA;       break;\n      case OP_Divide: {\n        /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n        if( rA==(double)0 ) goto arithmetic_result_is_null;\n        rB /= rA;\n        break;\n      }\n      default: {\n        iA = (i64)rA;\n        iB = (i64)rB;\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        rB = (double)(iB % iA);\n        break;\n      }\n    }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    pOut->u.i = rB;\n    MemSetTypeFlag(pOut, MEM_Int);\n#else\n    if( sqlite3IsNaN(rB) ){\n      goto arithmetic_result_is_null;\n    }\n    pOut->u.r = rB;\n    MemSetTypeFlag(pOut, MEM_Real);\n    if( ((type1|type2)&MEM_Real)==0 && !bIntint ){\n      sqlite3VdbeIntegerAffinity(pOut);\n    }\n#endif\n  }\n  break;\n\narithmetic_result_is_null:\n  sqlite3VdbeMemSetNull(pOut);\n  break;\n}\n\n/* Opcode: CollSeq P1 * * P4\n**\n** P4 is a pointer to a CollSeq object. If the next call to a user function\n** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will\n** be returned. This is used by the built-in min(), max() and nullif()\n** functions.\n**\n** If P1 is not zero, then it is a register that a subsequent min() or\n** max() aggregate will set to 1 if the current row is not the minimum or\n** maximum.  The P1 register is initialized to 0 by this instruction.\n**\n** The interface used by the implementation of the aforementioned functions\n** to retrieve the collation sequence set by this opcode is not available\n** publicly.  Only built-in functions have access to this feature.\n*/\ncase OP_CollSeq: {\n  assert( pOp->p4type==P4_COLLSEQ );\n  if( pOp->p1 ){\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);\n  }\n  break;\n}\n\n/* Opcode: BitAnd P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]&r[P2]\n**\n** Take the bit-wise AND of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: BitOr P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]|r[P2]\n**\n** Take the bit-wise OR of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftLeft P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]<<r[P1]\n**\n** Shift the integer value in register P2 to the left by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftRight P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]>>r[P1]\n**\n** Shift the integer value in register P2 to the right by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\ncase OP_BitAnd:                 /* same as TK_BITAND, in1, in2, out3 */\ncase OP_BitOr:                  /* same as TK_BITOR, in1, in2, out3 */\ncase OP_ShiftLeft:              /* same as TK_LSHIFT, in1, in2, out3 */\ncase OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */\n  i64 iA;\n  u64 uA;\n  i64 iB;\n  u8 op;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  iA = sqlite3VdbeIntValue(pIn2);\n  iB = sqlite3VdbeIntValue(pIn1);\n  op = pOp->opcode;\n  if( op==OP_BitAnd ){\n    iA &= iB;\n  }else if( op==OP_BitOr ){\n    iA |= iB;\n  }else if( iB!=0 ){\n    assert( op==OP_ShiftRight || op==OP_ShiftLeft );\n\n    /* If shifting by a negative amount, shift in the other direction */\n    if( iB<0 ){\n      assert( OP_ShiftRight==OP_ShiftLeft+1 );\n      op = 2*OP_ShiftLeft + 1 - op;\n      iB = iB>(-64) ? -iB : 64;\n    }\n\n    if( iB>=64 ){\n      iA = (iA>=0 || op==OP_ShiftLeft) ? 0 : -1;\n    }else{\n      memcpy(&uA, &iA, sizeof(uA));\n      if( op==OP_ShiftLeft ){\n        uA <<= iB;\n      }else{\n        uA >>= iB;\n        /* Sign-extend on a right shift of a negative number */\n        if( iA<0 ) uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-iB);\n      }\n      memcpy(&iA, &uA, sizeof(iA));\n    }\n  }\n  pOut->u.i = iA;\n  MemSetTypeFlag(pOut, MEM_Int);\n  break;\n}\n\n/* Opcode: AddImm  P1 P2 * * *\n** Synopsis: r[P1]=r[P1]+P2\n** \n** Add the constant P2 to the value in register P1.\n** The result is always an integer.\n**\n** To force any register to be an integer, just add 0.\n*/\ncase OP_AddImm: {            /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn1->u.i += pOp->p2;\n  break;\n}\n\n/* Opcode: MustBeInt P1 P2 * * *\n** \n** Force the value in register P1 to be an integer.  If the value\n** in P1 is not an integer and cannot be converted into an integer\n** without data loss, then jump immediately to P2, or if P2==0\n** raise an SQLITE_MISMATCH exception.\n*/\ncase OP_MustBeInt: {            /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Int)==0 ){\n    applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);\n    VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2);\n    if( (pIn1->flags & MEM_Int)==0 ){\n      if( pOp->p2==0 ){\n        rc = SQLITE_MISMATCH;\n        goto abort_due_to_error;\n      }else{\n        goto jump_to_p2;\n      }\n    }\n  }\n  MemSetTypeFlag(pIn1, MEM_Int);\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: RealAffinity P1 * * * *\n**\n** If register P1 holds an integer convert it to a real value.\n**\n** This opcode is used when extracting information from a column that\n** has REAL affinity.  Such column values may still be stored as\n** integers, for space efficiency, but after extraction we want them\n** to have only a real value.\n*/\ncase OP_RealAffinity: {                  /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Int ){\n    sqlite3VdbeMemRealify(pIn1);\n  }\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CAST\n/* Opcode: Cast P1 P2 * * *\n** Synopsis: affinity(r[P1])\n**\n** Force the value in register P1 to be the type defined by P2.\n** \n** <ul>\n** <li> P2=='A' &rarr; BLOB\n** <li> P2=='B' &rarr; TEXT\n** <li> P2=='C' &rarr; NUMERIC\n** <li> P2=='D' &rarr; INTEGER\n** <li> P2=='E' &rarr; REAL\n** </ul>\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_Cast: {                  /* in1 */\n  assert( pOp->p2>=SQLITE_AFF_BLOB && pOp->p2<=SQLITE_AFF_REAL );\n  testcase( pOp->p2==SQLITE_AFF_TEXT );\n  testcase( pOp->p2==SQLITE_AFF_BLOB );\n  testcase( pOp->p2==SQLITE_AFF_NUMERIC );\n  testcase( pOp->p2==SQLITE_AFF_INTEGER );\n  testcase( pOp->p2==SQLITE_AFF_REAL );\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  rc = ExpandBlob(pIn1);\n  sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_CAST */\n\n/* Opcode: Eq P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]==r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)==reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5, then\n** store the result of comparison in register P2.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n**\n** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either\n** true or false and is never NULL.  If both operands are NULL then the result\n** of comparison is true.  If either operand is NULL then the result is false.\n** If neither operand is NULL the result is the same as it would be if\n** the SQLITE_NULLEQ flag were omitted from P5.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 0 (false).\n** In other words, a prior r[P2] value will not be overwritten by 1 (true).\n*/\n/* Opcode: Ne P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]!=r[P1]\n**\n** This works just like the Eq opcode except that the jump is taken if\n** the operands in registers P1 and P3 are not equal.  See the Eq opcode for\n** additional information.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 1 (true).\n** In other words, a prior r[P2] value will not be overwritten by 0 (false).\n*/\n/* Opcode: Lt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5 store\n** the result of comparison (0 or 1 or NULL) into register P2.\n**\n** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or\n** reg(P3) is NULL then the take the jump.  If the SQLITE_JUMPIFNULL \n** bit is clear then fall through if either operand is NULL.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is  used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n*/\n/* Opcode: Le P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is less than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Gt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Ge P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\ncase OP_Eq:               /* same as TK_EQ, jump, in1, in3 */\ncase OP_Ne:               /* same as TK_NE, jump, in1, in3 */\ncase OP_Lt:               /* same as TK_LT, jump, in1, in3 */\ncase OP_Le:               /* same as TK_LE, jump, in1, in3 */\ncase OP_Gt:               /* same as TK_GT, jump, in1, in3 */\ncase OP_Ge: {             /* same as TK_GE, jump, in1, in3 */\n  int res, res2;      /* Result of the comparison of pIn1 against pIn3 */\n  char affinity;      /* Affinity to use for comparison */\n  u16 flags1;         /* Copy of initial value of pIn1->flags */\n  u16 flags3;         /* Copy of initial value of pIn3->flags */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  flags1 = pIn1->flags;\n  flags3 = pIn3->flags;\n  if( (flags1 | flags3)&MEM_Null ){\n    /* One or both operands are NULL */\n    if( pOp->p5 & SQLITE_NULLEQ ){\n      /* If SQLITE_NULLEQ is set (which will only happen if the operator is\n      ** OP_Eq or OP_Ne) then take the jump or not depending on whether\n      ** or not both operands are null.\n      */\n      assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );\n      assert( (flags1 & MEM_Cleared)==0 );\n      assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );\n      if( (flags1&flags3&MEM_Null)!=0\n       && (flags3&MEM_Cleared)==0\n      ){\n        res = 0;  /* Operands are equal */\n      }else{\n        res = 1;  /* Operands are not equal */\n      }\n    }else{\n      /* SQLITE_NULLEQ is clear and at least one operand is NULL,\n      ** then the result is always NULL.\n      ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.\n      */\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        pOut = &aMem[pOp->p2];\n        iCompare = 1;    /* Operands are not equal */\n        memAboutToChange(p, pOut);\n        MemSetTypeFlag(pOut, MEM_Null);\n        REGISTER_TRACE(pOp->p2, pOut);\n      }else{\n        VdbeBranchTaken(2,3);\n        if( pOp->p5 & SQLITE_JUMPIFNULL ){\n          goto jump_to_p2;\n        }\n      }\n      break;\n    }\n  }else{\n    /* Neither operand is NULL.  Do a comparison. */\n    affinity = pOp->p5 & SQLITE_AFF_MASK;\n    if( affinity>=SQLITE_AFF_NUMERIC ){\n      if( (flags1 | flags3)&MEM_Str ){\n        if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn1,0);\n          testcase( flags3!=pIn3->flags ); /* Possible if pIn1==pIn3 */\n          flags3 = pIn3->flags;\n        }\n        if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn3,0);\n        }\n      }\n      /* Handle the common case of integer comparison here, as an\n      ** optimization, to avoid a call to sqlite3MemCompare() */\n      if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){\n        if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }\n        if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }\n        res = 0;\n        goto compare_op;\n      }\n    }else if( affinity==SQLITE_AFF_TEXT ){\n      if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn1->flags & MEM_Int );\n        testcase( pIn1->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn1, encoding, 1);\n        testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );\n        flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);\n        assert( pIn1!=pIn3 );\n      }\n      if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn3->flags & MEM_Int );\n        testcase( pIn3->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn3, encoding, 1);\n        testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );\n        flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);\n      }\n    }\n    assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );\n    res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);\n  }\ncompare_op:\n  /* At this point, res is negative, zero, or positive if reg[P1] is\n  ** less than, equal to, or greater than reg[P3], respectively.  Compute\n  ** the answer to this operator in res2, depending on what the comparison\n  ** operator actually is.  The next block of code depends on the fact\n  ** that the 6 comparison operators are consecutive integers in this\n  ** order:  NE, EQ, GT, LE, LT, GE */\n  assert( OP_Eq==OP_Ne+1 ); assert( OP_Gt==OP_Ne+2 ); assert( OP_Le==OP_Ne+3 );\n  assert( OP_Lt==OP_Ne+4 ); assert( OP_Ge==OP_Ne+5 );\n  if( res<0 ){                        /* ne, eq, gt, le, lt, ge */\n    static const unsigned char aLTb[] = { 1,  0,  0,  1,  1,  0 };\n    res2 = aLTb[pOp->opcode - OP_Ne];\n  }else if( res==0 ){\n    static const unsigned char aEQb[] = { 0,  1,  0,  1,  0,  1 };\n    res2 = aEQb[pOp->opcode - OP_Ne];\n  }else{\n    static const unsigned char aGTb[] = { 1,  0,  1,  0,  0,  1 };\n    res2 = aGTb[pOp->opcode - OP_Ne];\n  }\n\n  /* Undo any changes made by applyAffinity() to the input registers. */\n  assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );\n  pIn1->flags = flags1;\n  assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );\n  pIn3->flags = flags3;\n\n  if( pOp->p5 & SQLITE_STOREP2 ){\n    pOut = &aMem[pOp->p2];\n    iCompare = res;\n    if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){\n      /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1\n      ** and prevents OP_Ne from overwriting NULL with 0.  This flag\n      ** is only used in contexts where either:\n      **   (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0)\n      **   (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1)\n      ** Therefore it is not necessary to check the content of r[P2] for\n      ** NULL. */\n      assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );\n      assert( res2==0 || res2==1 );\n      testcase( res2==0 && pOp->opcode==OP_Eq );\n      testcase( res2==1 && pOp->opcode==OP_Eq );\n      testcase( res2==0 && pOp->opcode==OP_Ne );\n      testcase( res2==1 && pOp->opcode==OP_Ne );\n      if( (pOp->opcode==OP_Eq)==res2 ) break;\n    }\n    memAboutToChange(p, pOut);\n    MemSetTypeFlag(pOut, MEM_Int);\n    pOut->u.i = res2;\n    REGISTER_TRACE(pOp->p2, pOut);\n  }else{\n    VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);\n    if( res2 ){\n      goto jump_to_p2;\n    }\n  }\n  break;\n}\n\n/* Opcode: ElseNotEq * P2 * * *\n**\n** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator.\n** If result of an OP_Eq comparison on the same two operands\n** would have be NULL or false (0), then then jump to P2. \n** If the result of an OP_Eq comparison on the two previous operands\n** would have been true (1), then fall through.\n*/\ncase OP_ElseNotEq: {       /* same as TK_ESCAPE, jump */\n  assert( pOp>aOp );\n  assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );\n  assert( pOp[-1].p5 & SQLITE_STOREP2 );\n  VdbeBranchTaken(iCompare!=0, 2);\n  if( iCompare!=0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: Permutation * * * P4 *\n**\n** Set the permutation used by the OP_Compare operator in the next\n** instruction.  The permutation is stored in the P4 operand.\n**\n** The permutation is only valid until the next OP_Compare that has\n** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should \n** occur immediately prior to the OP_Compare.\n**\n** The first integer in the P4 integer array is the length of the array\n** and does not become part of the permutation.\n*/\ncase OP_Permutation: {\n  assert( pOp->p4type==P4_INTARRAY );\n  assert( pOp->p4.ai );\n  assert( pOp[1].opcode==OP_Compare );\n  assert( pOp[1].p5 & OPFLAG_PERMUTE );\n  break;\n}\n\n/* Opcode: Compare P1 P2 P3 P4 P5\n** Synopsis: r[P1@P3] <-> r[P2@P3]\n**\n** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this\n** vector \"A\") and in reg(P2)..reg(P2+P3-1) (\"B\").  Save the result of\n** the comparison for use by the next OP_Jump instruct.\n**\n** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is\n** determined by the most recent OP_Permutation operator.  If the\n** OPFLAG_PERMUTE bit is clear, then register are compared in sequential\n** order.\n**\n** P4 is a KeyInfo structure that defines collating sequences and sort\n** orders for the comparison.  The permutation applies to registers\n** only.  The KeyInfo elements are used sequentially.\n**\n** The comparison is a sort comparison, so NULLs compare equal,\n** NULLs are less than numbers, numbers are less than strings,\n** and strings are less than blobs.\n*/\ncase OP_Compare: {\n  int n;\n  int i;\n  int p1;\n  int p2;\n  const KeyInfo *pKeyInfo;\n  int idx;\n  CollSeq *pColl;    /* Collating sequence to use on this term */\n  int bRev;          /* True for DESCENDING sort order */\n  int *aPermute;     /* The permutation */\n\n  if( (pOp->p5 & OPFLAG_PERMUTE)==0 ){\n    aPermute = 0;\n  }else{\n    assert( pOp>aOp );\n    assert( pOp[-1].opcode==OP_Permutation );\n    assert( pOp[-1].p4type==P4_INTARRAY );\n    aPermute = pOp[-1].p4.ai + 1;\n    assert( aPermute!=0 );\n  }\n  n = pOp->p3;\n  pKeyInfo = pOp->p4.pKeyInfo;\n  assert( n>0 );\n  assert( pKeyInfo!=0 );\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n#ifdef SQLITE_DEBUG\n  if( aPermute ){\n    int k, mx = 0;\n    for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];\n    assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );\n  }else{\n    assert( p1>0 && p1+n<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+n<=(p->nMem+1 - p->nCursor)+1 );\n  }\n#endif /* SQLITE_DEBUG */\n  for(i=0; i<n; i++){\n    idx = aPermute ? aPermute[i] : i;\n    assert( memIsValid(&aMem[p1+idx]) );\n    assert( memIsValid(&aMem[p2+idx]) );\n    REGISTER_TRACE(p1+idx, &aMem[p1+idx]);\n    REGISTER_TRACE(p2+idx, &aMem[p2+idx]);\n    assert( i<pKeyInfo->nKeyField );\n    pColl = pKeyInfo->aColl[i];\n    bRev = pKeyInfo->aSortOrder[i];\n    iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);\n    if( iCompare ){\n      if( bRev ) iCompare = -iCompare;\n      break;\n    }\n  }\n  break;\n}\n\n/* Opcode: Jump P1 P2 P3 * *\n**\n** Jump to the instruction at address P1, P2, or P3 depending on whether\n** in the most recent OP_Compare instruction the P1 vector was less than\n** equal to, or greater than the P2 vector, respectively.\n*/\ncase OP_Jump: {             /* jump */\n  if( iCompare<0 ){\n    VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];\n  }else if( iCompare==0 ){\n    VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];\n  }else{\n    VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];\n  }\n  break;\n}\n\n/* Opcode: And P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] && r[P2])\n**\n** Take the logical AND of the values in registers P1 and P2 and\n** write the result into register P3.\n**\n** If either P1 or P2 is 0 (false) then the result is 0 even if\n** the other input is NULL.  A NULL and true or two NULLs give\n** a NULL output.\n*/\n/* Opcode: Or P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] || r[P2])\n**\n** Take the logical OR of the values in register P1 and P2 and\n** store the answer in register P3.\n**\n** If either P1 or P2 is nonzero (true) then the result is 1 (true)\n** even if the other input is NULL.  A NULL and false or two NULLs\n** give a NULL output.\n*/\ncase OP_And:              /* same as TK_AND, in1, in2, out3 */\ncase OP_Or: {             /* same as TK_OR, in1, in2, out3 */\n  int v1;    /* Left operand:  0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n  int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    v1 = 2;\n  }else{\n    v1 = sqlite3VdbeIntValue(pIn1)!=0;\n  }\n  pIn2 = &aMem[pOp->p2];\n  if( pIn2->flags & MEM_Null ){\n    v2 = 2;\n  }else{\n    v2 = sqlite3VdbeIntValue(pIn2)!=0;\n  }\n  if( pOp->opcode==OP_And ){\n    static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 };\n    v1 = and_logic[v1*3+v2];\n  }else{\n    static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 };\n    v1 = or_logic[v1*3+v2];\n  }\n  pOut = &aMem[pOp->p3];\n  if( v1==2 ){\n    MemSetTypeFlag(pOut, MEM_Null);\n  }else{\n    pOut->u.i = v1;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }\n  break;\n}\n\n/* Opcode: Not P1 P2 * * *\n** Synopsis: r[P2]= !r[P1]\n**\n** Interpret the value in register P1 as a boolean value.  Store the\n** boolean complement in register P2.  If the value in register P1 is \n** NULL, then a NULL is stored in P2.\n*/\ncase OP_Not: {                /* same as TK_NOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetNull(pOut);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pOut->flags = MEM_Int;\n    pOut->u.i = !sqlite3VdbeIntValue(pIn1);\n  }\n  break;\n}\n\n/* Opcode: BitNot P1 P2 * * *\n** Synopsis: r[P1]= ~r[P1]\n**\n** Interpret the content of register P1 as an integer.  Store the\n** ones-complement of the P1 value into register P2.  If P1 holds\n** a NULL then store a NULL in P2.\n*/\ncase OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetNull(pOut);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pOut->flags = MEM_Int;\n    pOut->u.i = ~sqlite3VdbeIntValue(pIn1);\n  }\n  break;\n}\n\n/* Opcode: Once P1 P2 * * *\n**\n** Fall through to the next instruction the first time this opcode is\n** encountered on each invocation of the byte-code program.  Jump to P2\n** on the second and all subsequent encounters during the same invocation.\n**\n** Top-level programs determine first invocation by comparing the P1\n** operand against the P1 operand on the OP_Init opcode at the beginning\n** of the program.  If the P1 values differ, then fall through and make\n** the P1 of this opcode equal to the P1 of OP_Init.  If P1 values are\n** the same then take the jump.\n**\n** For subprograms, there is a bitmask in the VdbeFrame that determines\n** whether or not the jump should be taken.  The bitmask is necessary\n** because the self-altering code trick does not work for recursive\n** triggers.\n*/\ncase OP_Once: {             /* jump */\n  u32 iAddr;                /* Address of this instruction */\n  assert( p->aOp[0].opcode==OP_Init );\n  if( p->pFrame ){\n    iAddr = (int)(pOp - p->aOp);\n    if( (p->pFrame->aOnce[iAddr/8] & (1<<(iAddr & 7)))!=0 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n    p->pFrame->aOnce[iAddr/8] |= 1<<(iAddr & 7);\n  }else{\n    if( p->aOp[0].p1==pOp->p1 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n  }\n  VdbeBranchTaken(0, 2);\n  pOp->p1 = p->aOp[0].p1;\n  break;\n}\n\n/* Opcode: If P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is true.  The value\n** is considered true if it is numeric and non-zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\n/* Opcode: IfNot P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is False.  The value\n** is considered false if it has a numeric value of zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\ncase OP_If:                 /* jump, in1 */\ncase OP_IfNot: {            /* jump, in1 */\n  int c;\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    c = pOp->p3;\n  }else{\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    c = sqlite3VdbeIntValue(pIn1)!=0;\n#else\n    c = sqlite3VdbeRealValue(pIn1)!=0.0;\n#endif\n    if( pOp->opcode==OP_IfNot ) c = !c;\n  }\n  VdbeBranchTaken(c!=0, 2);\n  if( c ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IsNull P1 P2 * * *\n** Synopsis: if r[P1]==NULL goto P2\n**\n** Jump to P2 if the value in register P1 is NULL.\n*/\ncase OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);\n  if( (pIn1->flags & MEM_Null)!=0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: NotNull P1 P2 * * *\n** Synopsis: if r[P1]!=NULL goto P2\n**\n** Jump to P2 if the value in register P1 is not NULL.  \n*/\ncase OP_NotNull: {            /* same as TK_NOTNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfNullRow P1 P2 P3 * *\n** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2\n**\n** Check the cursor P1 to see if it is currently pointing at a NULL row.\n** If it is, then set register P3 to NULL and jump immediately to P2.\n** If P1 is not on a NULL row, then fall through without making any\n** changes.\n*/\ncase OP_IfNullRow: {         /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  if( p->apCsr[pOp->p1]->nullRow ){\n    sqlite3VdbeMemSetNull(aMem + pOp->p3);\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: Column P1 P2 P3 P4 P5\n** Synopsis: r[P3]=PX\n**\n** Interpret the data that cursor P1 points to as a structure built using\n** the MakeRecord instruction.  (See the MakeRecord opcode for additional\n** information about the format of the data.)  Extract the P2-th column\n** from this record.  If there are less that (P2+1) \n** values in the record, extract a NULL.\n**\n** The value extracted is stored in register P3.\n**\n** If the record contains fewer than P2 fields, then extract a NULL.  Or,\n** if the P4 argument is a P4_MEM use the value of the P4 argument as\n** the result.\n**\n** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,\n** then the cache of the cursor is reset prior to extracting the column.\n** The first OP_Column against a pseudo-table after the value of the content\n** register has changed should have this bit set.\n**\n** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then\n** the result is guaranteed to only be used as the argument of a length()\n** or typeof() function, respectively.  The loading of large blobs can be\n** skipped for length() and all content loading can be skipped for typeof().\n*/\ncase OP_Column: {\n  int p2;            /* column number to retrieve */\n  VdbeCursor *pC;    /* The VDBE cursor */\n  BtCursor *pCrsr;   /* The BTree cursor */\n  u32 *aOffset;      /* aOffset[i] is offset to start of data for i-th column */\n  int len;           /* The length of the serialized data for the column */\n  int i;             /* Loop counter */\n  Mem *pDest;        /* Where to write the extracted value */\n  Mem sMem;          /* For storing the record being decoded */\n  const u8 *zData;   /* Part of the record being decoded */\n  const u8 *zHdr;    /* Next unparsed byte of the header */\n  const u8 *zEndHdr; /* Pointer to first byte after the header */\n  u64 offset64;      /* 64-bit offset */\n  u32 t;             /* A type code from the record header */\n  Mem *pReg;         /* PseudoTable input register */\n\n  pC = p->apCsr[pOp->p1];\n  p2 = pOp->p2;\n\n  /* If the cursor cache is stale (meaning it is not currently point at\n  ** the correct row) then bring it up-to-date by doing the necessary \n  ** B-Tree seek. */\n  rc = sqlite3VdbeCursorMoveto(&pC, &p2);\n  if( rc ) goto abort_due_to_error;\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pC!=0 );\n  assert( p2<pC->nField );\n  aOffset = pC->aOffset;\n  assert( pC->eCurType!=CURTYPE_VTAB );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  assert( pC->eCurType!=CURTYPE_SORTER );\n\n  if( pC->cacheStatus!=p->cacheCtr ){                /*OPTIMIZATION-IF-FALSE*/\n    if( pC->nullRow ){\n      if( pC->eCurType==CURTYPE_PSEUDO ){\n        /* For the special case of as pseudo-cursor, the seekResult field\n        ** identifies the register that holds the record */\n        assert( pC->seekResult>0 );\n        pReg = &aMem[pC->seekResult];\n        assert( pReg->flags & MEM_Blob );\n        assert( memIsValid(pReg) );\n        pC->payloadSize = pC->szRow = pReg->n;\n        pC->aRow = (u8*)pReg->z;\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n        goto op_column_out;\n      }\n    }else{\n      pCrsr = pC->uc.pCursor;\n      assert( pC->eCurType==CURTYPE_BTREE );\n      assert( pCrsr );\n      assert( sqlite3BtreeCursorIsValid(pCrsr) );\n      pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);\n      pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);\n      assert( pC->szRow<=pC->payloadSize );\n      assert( pC->szRow<=65536 );  /* Maximum page size is 64KiB */\n      if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        goto too_big;\n      }\n    }\n    pC->cacheStatus = p->cacheCtr;\n    pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);\n    pC->nHdrParsed = 0;\n\n\n    if( pC->szRow<aOffset[0] ){      /*OPTIMIZATION-IF-FALSE*/\n      /* pC->aRow does not have to hold the entire row, but it does at least\n      ** need to cover the header of the record.  If pC->aRow does not contain\n      ** the complete header, then set it to zero, forcing the header to be\n      ** dynamically allocated. */\n      pC->aRow = 0;\n      pC->szRow = 0;\n\n      /* Make sure a corrupt database has not given us an oversize header.\n      ** Do this now to avoid an oversize memory allocation.\n      **\n      ** Type entries can be between 1 and 5 bytes each.  But 4 and 5 byte\n      ** types use so much data space that there can only be 4096 and 32 of\n      ** them, respectively.  So the maximum header length results from a\n      ** 3-byte type for each of the maximum of 32768 columns plus three\n      ** extra bytes for the header length itself.  32768*3 + 3 = 98307.\n      */\n      if( aOffset[0] > 98307 || aOffset[0] > pC->payloadSize ){\n        goto op_column_corrupt;\n      }\n    }else{\n      /* This is an optimization.  By skipping over the first few tests\n      ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a\n      ** measurable performance gain.\n      **\n      ** This branch is taken even if aOffset[0]==0.  Such a record is never\n      ** generated by SQLite, and could be considered corruption, but we\n      ** accept it for historical reasons.  When aOffset[0]==0, the code this\n      ** branch jumps to reads past the end of the record, but never more\n      ** than a few bytes.  Even if the record occurs at the end of the page\n      ** content area, the \"page header\" comes after the page content and so\n      ** this overread is harmless.  Similar overreads can occur for a corrupt\n      ** database file.\n      */\n      zData = pC->aRow;\n      assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */\n      testcase( aOffset[0]==0 );\n      goto op_column_read_header;\n    }\n  }\n\n  /* Make sure at least the first p2+1 entries of the header have been\n  ** parsed and valid information is in aOffset[] and pC->aType[].\n  */\n  if( pC->nHdrParsed<=p2 ){\n    /* If there is more header available for parsing in the record, try\n    ** to extract additional fields up through the p2+1-th field \n    */\n    if( pC->iHdrOffset<aOffset[0] ){\n      /* Make sure zData points to enough of the record to cover the header. */\n      if( pC->aRow==0 ){\n        memset(&sMem, 0, sizeof(sMem));\n        rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0], &sMem);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n        zData = (u8*)sMem.z;\n      }else{\n        zData = pC->aRow;\n      }\n  \n      /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */\n    op_column_read_header:\n      i = pC->nHdrParsed;\n      offset64 = aOffset[i];\n      zHdr = zData + pC->iHdrOffset;\n      zEndHdr = zData + aOffset[0];\n      testcase( zHdr>=zEndHdr );\n      do{\n        if( (t = zHdr[0])<0x80 ){\n          zHdr++;\n          offset64 += sqlite3VdbeOneByteSerialTypeLen(t);\n        }else{\n          zHdr += sqlite3GetVarint32(zHdr, &t);\n          offset64 += sqlite3VdbeSerialTypeLen(t);\n        }\n        pC->aType[i++] = t;\n        aOffset[i] = (u32)(offset64 & 0xffffffff);\n      }while( i<=p2 && zHdr<zEndHdr );\n\n      /* The record is corrupt if any of the following are true:\n      ** (1) the bytes of the header extend past the declared header size\n      ** (2) the entire header was used but not all data was used\n      ** (3) the end of the data extends beyond the end of the record.\n      */\n      if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize))\n       || (offset64 > pC->payloadSize)\n      ){\n        if( aOffset[0]==0 ){\n          i = 0;\n          zHdr = zEndHdr;\n        }else{\n          if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n          goto op_column_corrupt;\n        }\n      }\n\n      pC->nHdrParsed = i;\n      pC->iHdrOffset = (u32)(zHdr - zData);\n      if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n    }else{\n      t = 0;\n    }\n\n    /* If after trying to extract new entries from the header, nHdrParsed is\n    ** still not up to p2, that means that the record has fewer than p2\n    ** columns.  So the result will be either the default value or a NULL.\n    */\n    if( pC->nHdrParsed<=p2 ){\n      if( pOp->p4type==P4_MEM ){\n        sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n      }\n      goto op_column_out;\n    }\n  }else{\n    t = pC->aType[p2];\n  }\n\n  /* Extract the content for the p2+1-th column.  Control can only\n  ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are\n  ** all valid.\n  */\n  assert( p2<pC->nHdrParsed );\n  assert( rc==SQLITE_OK );\n  assert( sqlite3VdbeCheckMemInvariants(pDest) );\n  if( VdbeMemDynamic(pDest) ){\n    sqlite3VdbeMemSetNull(pDest);\n  }\n  assert( t==pC->aType[p2] );\n  if( pC->szRow>=aOffset[p2+1] ){\n    /* This is the common case where the desired content fits on the original\n    ** page - where the content is not on an overflow page */\n    zData = pC->aRow + aOffset[p2];\n    if( t<12 ){\n      sqlite3VdbeSerialGet(zData, t, pDest);\n    }else{\n      /* If the column value is a string, we need a persistent value, not\n      ** a MEM_Ephem value.  This branch is a fast short-cut that is equivalent\n      ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().\n      */\n      static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };\n      pDest->n = len = (t-12)/2;\n      pDest->enc = encoding;\n      if( pDest->szMalloc < len+2 ){\n        pDest->flags = MEM_Null;\n        if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;\n      }else{\n        pDest->z = pDest->zMalloc;\n      }\n      memcpy(pDest->z, zData, len);\n      pDest->z[len] = 0;\n      pDest->z[len+1] = 0;\n      pDest->flags = aFlag[t&1];\n    }\n  }else{\n    pDest->enc = encoding;\n    /* This branch happens only when content is on overflow pages */\n    if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0\n          && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))\n     || (len = sqlite3VdbeSerialTypeLen(t))==0\n    ){\n      /* Content is irrelevant for\n      **    1. the typeof() function,\n      **    2. the length(X) function if X is a blob, and\n      **    3. if the content length is zero.\n      ** So we might as well use bogus content rather than reading\n      ** content from disk. \n      **\n      ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the\n      ** buffer passed to it, debugging function VdbeMemPrettyPrint() may\n      ** read up to 16. So 16 bytes of bogus content is supplied.\n      */\n      static u8 aZero[16];  /* This is the bogus content */\n      sqlite3VdbeSerialGet(aZero, t, pDest);\n    }else{\n      rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);\n      pDest->flags &= ~MEM_Ephem;\n    }\n  }\n\nop_column_out:\n  UPDATE_MAX_BLOBSIZE(pDest);\n  REGISTER_TRACE(pOp->p3, pDest);\n  break;\n\nop_column_corrupt:\n  if( aOp[0].p3>0 ){\n    pOp = &aOp[aOp[0].p3-1];\n    break;\n  }else{\n    rc = SQLITE_CORRUPT_BKPT;\n    goto abort_due_to_error;\n  }\n}\n\n/* Opcode: Affinity P1 P2 * P4 *\n** Synopsis: affinity(r[P1@P2])\n**\n** Apply affinities to a range of P2 registers starting with P1.\n**\n** P4 is a string that is P2 characters long. The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** memory cell in the range.\n*/\ncase OP_Affinity: {\n  const char *zAffinity;   /* The affinity to be applied */\n\n  zAffinity = pOp->p4.z;\n  assert( zAffinity!=0 );\n  assert( pOp->p2>0 );\n  assert( zAffinity[pOp->p2]==0 );\n  pIn1 = &aMem[pOp->p1];\n  do{\n    assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    applyAffinity(pIn1, *(zAffinity++), encoding);\n    pIn1++;\n  }while( zAffinity[0] );\n  break;\n}\n\n/* Opcode: MakeRecord P1 P2 P3 P4 *\n** Synopsis: r[P3]=mkrec(r[P1@P2])\n**\n** Convert P2 registers beginning with P1 into the [record format]\n** use as a data record in a database table or as a key\n** in an index.  The OP_Column opcode can decode the record later.\n**\n** P4 may be a string that is P2 characters long.  The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** field of the index key.\n**\n** The mapping from character to affinity is given by the SQLITE_AFF_\n** macros defined in sqliteInt.h.\n**\n** If P4 is NULL then all index fields have the affinity BLOB.\n*/\ncase OP_MakeRecord: {\n  u8 *zNewRecord;        /* A buffer to hold the data for the new record */\n  Mem *pRec;             /* The new record */\n  u64 nData;             /* Number of bytes of data space */\n  int nHdr;              /* Number of bytes of header space */\n  i64 nByte;             /* Data space required for this record */\n  i64 nZero;             /* Number of zero bytes at the end of the record */\n  int nVarint;           /* Number of bytes in a varint */\n  u32 serial_type;       /* Type field */\n  Mem *pData0;           /* First field to be combined into the record */\n  Mem *pLast;            /* Last field of the record */\n  int nField;            /* Number of fields in the record */\n  char *zAffinity;       /* The affinity string for the record */\n  int file_format;       /* File format to use for encoding */\n  int i;                 /* Space used in zNewRecord[] header */\n  int j;                 /* Space used in zNewRecord[] content */\n  u32 len;               /* Length of a field */\n\n  /* Assuming the record contains N fields, the record format looks\n  ** like this:\n  **\n  ** ------------------------------------------------------------------------\n  ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | \n  ** ------------------------------------------------------------------------\n  **\n  ** Data(0) is taken from register P1.  Data(1) comes from register P1+1\n  ** and so forth.\n  **\n  ** Each type field is a varint representing the serial type of the \n  ** corresponding data element (see sqlite3VdbeSerialType()). The\n  ** hdr-size field is also a varint which is the offset from the beginning\n  ** of the record to data0.\n  */\n  nData = 0;         /* Number of bytes of data space */\n  nHdr = 0;          /* Number of bytes of header space */\n  nZero = 0;         /* Number of zero bytes at the end of the record */\n  nField = pOp->p1;\n  zAffinity = pOp->p4.z;\n  assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );\n  pData0 = &aMem[nField];\n  nField = pOp->p2;\n  pLast = &pData0[nField-1];\n  file_format = p->minWriteFileFormat;\n\n  /* Identify the output register */\n  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );\n  pOut = &aMem[pOp->p3];\n  memAboutToChange(p, pOut);\n\n  /* Apply the requested affinity to all inputs\n  */\n  assert( pData0<=pLast );\n  if( zAffinity ){\n    pRec = pData0;\n    do{\n      applyAffinity(pRec++, *(zAffinity++), encoding);\n      assert( zAffinity[0]==0 || pRec<=pLast );\n    }while( zAffinity[0] );\n  }\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n  /* NULLs can be safely trimmed from the end of the record, as long as\n  ** as the schema format is 2 or more and none of the omitted columns\n  ** have a non-NULL default value.  Also, the record must be left with\n  ** at least one field.  If P5>0 then it will be one more than the\n  ** index of the right-most column with a non-NULL default value */\n  if( pOp->p5 ){\n    while( (pLast->flags & MEM_Null)!=0 && nField>pOp->p5 ){\n      pLast--;\n      nField--;\n    }\n  }\n#endif\n\n  /* Loop through the elements that will make up the record to figure\n  ** out how much space is required for the new record.\n  */\n  pRec = pLast;\n  do{\n    assert( memIsValid(pRec) );\n    pRec->uTemp = serial_type = sqlite3VdbeSerialType(pRec, file_format, &len);\n    if( pRec->flags & MEM_Zero ){\n      if( nData ){\n        if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;\n      }else{\n        nZero += pRec->u.nZero;\n        len -= pRec->u.nZero;\n      }\n    }\n    nData += len;\n    testcase( serial_type==127 );\n    testcase( serial_type==128 );\n    nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);\n    if( pRec==pData0 ) break;\n    pRec--;\n  }while(1);\n\n  /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint\n  ** which determines the total number of bytes in the header. The varint\n  ** value is the size of the header in bytes including the size varint\n  ** itself. */\n  testcase( nHdr==126 );\n  testcase( nHdr==127 );\n  if( nHdr<=126 ){\n    /* The common case */\n    nHdr += 1;\n  }else{\n    /* Rare case of a really large header */\n    nVarint = sqlite3VarintLen(nHdr);\n    nHdr += nVarint;\n    if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;\n  }\n  nByte = nHdr+nData;\n  if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n\n  /* Make sure the output register has a buffer large enough to store \n  ** the new record. The output register (pOp->p3) is not allowed to\n  ** be one of the input registers (because the following call to\n  ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).\n  */\n  if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){\n    goto no_mem;\n  }\n  zNewRecord = (u8 *)pOut->z;\n\n  /* Write the record */\n  i = putVarint32(zNewRecord, nHdr);\n  j = nHdr;\n  assert( pData0<=pLast );\n  pRec = pData0;\n  do{\n    serial_type = pRec->uTemp;\n    /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more\n    ** additional varints, one per column. */\n    i += putVarint32(&zNewRecord[i], serial_type);            /* serial type */\n    /* EVIDENCE-OF: R-64536-51728 The values for each column in the record\n    ** immediately follow the header. */\n    j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, serial_type); /* content */\n  }while( (++pRec)<=pLast );\n  assert( i==nHdr );\n  assert( j==nByte );\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->n = (int)nByte;\n  pOut->flags = MEM_Blob;\n  if( nZero ){\n    pOut->u.nZero = nZero;\n    pOut->flags |= MEM_Zero;\n  }\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Count P1 P2 * * *\n** Synopsis: r[P2]=count()\n**\n** Store the number of entries (an integer value) in the table or index \n** opened by cursor P1 in register P2\n*/\n#ifndef SQLITE_OMIT_BTREECOUNT\ncase OP_Count: {         /* out2 */\n  i64 nEntry;\n  BtCursor *pCrsr;\n\n  assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );\n  pCrsr = p->apCsr[pOp->p1]->uc.pCursor;\n  assert( pCrsr );\n  nEntry = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3BtreeCount(pCrsr, &nEntry);\n  if( rc ) goto abort_due_to_error;\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = nEntry;\n  break;\n}\n#endif\n\n/* Opcode: Savepoint P1 * * P4 *\n**\n** Open, release or rollback the savepoint named by parameter P4, depending\n** on the value of P1. To open a new savepoint, P1==0. To release (commit) an\n** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.\n*/\ncase OP_Savepoint: {\n  int p1;                         /* Value of P1 operand */\n  char *zName;                    /* Name of savepoint */\n  int nName;\n  Savepoint *pNew;\n  Savepoint *pSavepoint;\n  Savepoint *pTmp;\n  int iSavepoint;\n  int ii;\n\n  p1 = pOp->p1;\n  zName = pOp->p4.z;\n\n  /* Assert that the p1 parameter is valid. Also that if there is no open\n  ** transaction, then there cannot be any savepoints. \n  */\n  assert( db->pSavepoint==0 || db->autoCommit==0 );\n  assert( p1==SAVEPOINT_BEGIN||p1==SAVEPOINT_RELEASE||p1==SAVEPOINT_ROLLBACK );\n  assert( db->pSavepoint || db->isTransactionSavepoint==0 );\n  assert( checkSavepointCount(db) );\n  assert( p->bIsReader );\n\n  if( p1==SAVEPOINT_BEGIN ){\n    if( db->nVdbeWrite>0 ){\n      /* A new savepoint cannot be created if there are active write \n      ** statements (i.e. open read/write incremental blob handles).\n      */\n      sqlite3VdbeError(p, \"cannot open savepoint - SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n      nName = sqlite3Strlen30(zName);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* This call is Ok even if this savepoint is actually a transaction\n      ** savepoint (and therefore should not prompt xSavepoint()) callbacks.\n      ** If this is a transaction savepoint being opened, it is guaranteed\n      ** that the db->aVTrans[] array is empty.  */\n      assert( db->autoCommit==0 || db->nVTrans==0 );\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,\n                                db->nStatement+db->nSavepoint);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n      /* Create a new savepoint structure. */\n      pNew = sqlite3DbMallocRawNN(db, sizeof(Savepoint)+nName+1);\n      if( pNew ){\n        pNew->zName = (char *)&pNew[1];\n        memcpy(pNew->zName, zName, nName+1);\n    \n        /* If there is no open transaction, then mark this as a special\n        ** \"transaction savepoint\". */\n        if( db->autoCommit ){\n          db->autoCommit = 0;\n          db->isTransactionSavepoint = 1;\n        }else{\n          db->nSavepoint++;\n        }\n\n        /* Link the new savepoint into the database handle's list. */\n        pNew->pNext = db->pSavepoint;\n        db->pSavepoint = pNew;\n        pNew->nDeferredCons = db->nDeferredCons;\n        pNew->nDeferredImmCons = db->nDeferredImmCons;\n      }\n    }\n  }else{\n    iSavepoint = 0;\n\n    /* Find the named savepoint. If there is no such savepoint, then an\n    ** an error is returned to the user.  */\n    for(\n      pSavepoint = db->pSavepoint; \n      pSavepoint && sqlite3StrICmp(pSavepoint->zName, zName);\n      pSavepoint = pSavepoint->pNext\n    ){\n      iSavepoint++;\n    }\n    if( !pSavepoint ){\n      sqlite3VdbeError(p, \"no such savepoint: %s\", zName);\n      rc = SQLITE_ERROR;\n    }else if( db->nVdbeWrite>0 && p1==SAVEPOINT_RELEASE ){\n      /* It is not possible to release (commit) a savepoint if there are \n      ** active write statements.\n      */\n      sqlite3VdbeError(p, \"cannot release savepoint - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n\n      /* Determine whether or not this is a transaction savepoint. If so,\n      ** and this is a RELEASE command, then the current transaction \n      ** is committed. \n      */\n      int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;\n      if( isTransaction && p1==SAVEPOINT_RELEASE ){\n        if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n          goto vdbe_return;\n        }\n        db->autoCommit = 1;\n        if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n          p->pc = (int)(pOp - aOp);\n          db->autoCommit = 0;\n          p->rc = rc = SQLITE_BUSY;\n          goto vdbe_return;\n        }\n        db->isTransactionSavepoint = 0;\n        rc = p->rc;\n      }else{\n        int isSchemaChange;\n        iSavepoint = db->nSavepoint - iSavepoint - 1;\n        if( p1==SAVEPOINT_ROLLBACK ){\n          isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;\n          for(ii=0; ii<db->nDb; ii++){\n            rc = sqlite3BtreeTripAllCursors(db->aDb[ii].pBt,\n                                       SQLITE_ABORT_ROLLBACK,\n                                       isSchemaChange==0);\n            if( rc!=SQLITE_OK ) goto abort_due_to_error;\n          }\n        }else{\n          isSchemaChange = 0;\n        }\n        for(ii=0; ii<db->nDb; ii++){\n          rc = sqlite3BtreeSavepoint(db->aDb[ii].pBt, p1, iSavepoint);\n          if( rc!=SQLITE_OK ){\n            goto abort_due_to_error;\n          }\n        }\n        if( isSchemaChange ){\n          sqlite3ExpirePreparedStatements(db);\n          sqlite3ResetAllSchemasOfConnection(db);\n          db->mDbFlags |= DBFLAG_SchemaChange;\n        }\n      }\n  \n      /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all \n      ** savepoints nested inside of the savepoint being operated on. */\n      while( db->pSavepoint!=pSavepoint ){\n        pTmp = db->pSavepoint;\n        db->pSavepoint = pTmp->pNext;\n        sqlite3DbFree(db, pTmp);\n        db->nSavepoint--;\n      }\n\n      /* If it is a RELEASE, then destroy the savepoint being operated on \n      ** too. If it is a ROLLBACK TO, then set the number of deferred \n      ** constraint violations present in the database to the value stored\n      ** when the savepoint was created.  */\n      if( p1==SAVEPOINT_RELEASE ){\n        assert( pSavepoint==db->pSavepoint );\n        db->pSavepoint = pSavepoint->pNext;\n        sqlite3DbFree(db, pSavepoint);\n        if( !isTransaction ){\n          db->nSavepoint--;\n        }\n      }else{\n        db->nDeferredCons = pSavepoint->nDeferredCons;\n        db->nDeferredImmCons = pSavepoint->nDeferredImmCons;\n      }\n\n      if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){\n        rc = sqlite3VtabSavepoint(db, p1, iSavepoint);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      }\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n\n  break;\n}\n\n/* Opcode: AutoCommit P1 P2 * * *\n**\n** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll\n** back any currently active btree transactions. If there are any active\n** VMs (apart from this one), then a ROLLBACK fails.  A COMMIT fails if\n** there are active writing VMs or active VMs that use shared cache.\n**\n** This instruction causes the VM to halt.\n*/\ncase OP_AutoCommit: {\n  int desiredAutoCommit;\n  int iRollback;\n\n  desiredAutoCommit = pOp->p1;\n  iRollback = pOp->p2;\n  assert( desiredAutoCommit==1 || desiredAutoCommit==0 );\n  assert( desiredAutoCommit==1 || iRollback==0 );\n  assert( db->nVdbeActive>0 );  /* At least this one VM is active */\n  assert( p->bIsReader );\n\n  if( desiredAutoCommit!=db->autoCommit ){\n    if( iRollback ){\n      assert( desiredAutoCommit==1 );\n      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n      db->autoCommit = 1;\n    }else if( desiredAutoCommit && db->nVdbeWrite>0 ){\n      /* If this instruction implements a COMMIT and other VMs are writing\n      ** return an error indicating that the other VMs must complete first. \n      */\n      sqlite3VdbeError(p, \"cannot commit transaction - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n      goto abort_due_to_error;\n    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n      goto vdbe_return;\n    }else{\n      db->autoCommit = (u8)desiredAutoCommit;\n    }\n    if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n      p->pc = (int)(pOp - aOp);\n      db->autoCommit = (u8)(1-desiredAutoCommit);\n      p->rc = rc = SQLITE_BUSY;\n      goto vdbe_return;\n    }\n    assert( db->nStatement==0 );\n    sqlite3CloseSavepoints(db);\n    if( p->rc==SQLITE_OK ){\n      rc = SQLITE_DONE;\n    }else{\n      rc = SQLITE_ERROR;\n    }\n    goto vdbe_return;\n  }else{\n    sqlite3VdbeError(p,\n        (!desiredAutoCommit)?\"cannot start a transaction within a transaction\":(\n        (iRollback)?\"cannot rollback - no transaction is active\":\n                   \"cannot commit - no transaction is active\"));\n         \n    rc = SQLITE_ERROR;\n    goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: Transaction P1 P2 P3 P4 P5\n**\n** Begin a transaction on database P1 if a transaction is not already\n** active.\n** If P2 is non-zero, then a write-transaction is started, or if a \n** read-transaction is already active, it is upgraded to a write-transaction.\n** If P2 is zero, then a read-transaction is started.\n**\n** P1 is the index of the database file on which the transaction is\n** started.  Index 0 is the main database file and index 1 is the\n** file used for temporary tables.  Indices of 2 or more are used for\n** attached databases.\n**\n** If a write-transaction is started and the Vdbe.usesStmtJournal flag is\n** true (this flag is set if the Vdbe may modify more than one row and may\n** throw an ABORT exception), a statement transaction may also be opened.\n** More specifically, a statement transaction is opened iff the database\n** connection is currently not in autocommit mode, or if there are other\n** active statements. A statement transaction allows the changes made by this\n** VDBE to be rolled back after an error without having to roll back the\n** entire transaction. If no error is encountered, the statement transaction\n** will automatically commit when the VDBE halts.\n**\n** If P5!=0 then this opcode also checks the schema cookie against P3\n** and the schema generation counter against P4.\n** The cookie changes its value whenever the database schema changes.\n** This operation is used to detect when that the cookie has changed\n** and that the current process needs to reread the schema.  If the schema\n** cookie in P3 differs from the schema cookie in the database header or\n** if the schema generation counter in P4 differs from the current\n** generation counter, then an SQLITE_SCHEMA error is raised and execution\n** halts.  The sqlite3_step() wrapper function might then reprepare the\n** statement and rerun it from the beginning.\n*/\ncase OP_Transaction: {\n  Btree *pBt;\n  int iMeta;\n  int iGen;\n\n  assert( p->bIsReader );\n  assert( p->readOnly==0 || pOp->p2==0 );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){\n    rc = SQLITE_READONLY;\n    goto abort_due_to_error;\n  }\n  pBt = db->aDb[pOp->p1].pBt;\n\n  if( pBt ){\n    rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);\n    testcase( rc==SQLITE_BUSY_SNAPSHOT );\n    testcase( rc==SQLITE_BUSY_RECOVERY );\n    if( rc!=SQLITE_OK ){\n      if( (rc&0xff)==SQLITE_BUSY ){\n        p->pc = (int)(pOp - aOp);\n        p->rc = rc;\n        goto vdbe_return;\n      }\n      goto abort_due_to_error;\n    }\n\n    if( pOp->p2 && p->usesStmtJournal \n     && (db->autoCommit==0 || db->nVdbeRead>1) \n    ){\n      assert( sqlite3BtreeIsInTrans(pBt) );\n      if( p->iStatement==0 ){\n        assert( db->nStatement>=0 && db->nSavepoint>=0 );\n        db->nStatement++; \n        p->iStatement = db->nSavepoint + db->nStatement;\n      }\n\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);\n      }\n\n      /* Store the current value of the database handles deferred constraint\n      ** counter. If the statement transaction needs to be rolled back,\n      ** the value of this counter needs to be restored too.  */\n      p->nStmtDefCons = db->nDeferredCons;\n      p->nStmtDefImmCons = db->nDeferredImmCons;\n    }\n\n    /* Gather the schema version number for checking:\n    ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema\n    ** version is checked to ensure that the schema has not changed since the\n    ** SQL statement was prepared.\n    */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);\n    iGen = db->aDb[pOp->p1].pSchema->iGeneration;\n  }else{\n    iGen = iMeta = 0;\n  }\n  assert( pOp->p5==0 || pOp->p4type==P4_INT32 );\n  if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, \"database schema has changed\");\n    /* If the schema-cookie from the database file matches the cookie \n    ** stored with the in-memory representation of the schema, do\n    ** not reload the schema from the database file.\n    **\n    ** If virtual-tables are in use, this is not just an optimization.\n    ** Often, v-tables store their data in other SQLite tables, which\n    ** are queried from within xNext() and other v-table methods using\n    ** prepared queries. If such a query is out-of-date, we do not want to\n    ** discard the database schema, as the user code implementing the\n    ** v-table would have to be ready for the sqlite3_vtab structure itself\n    ** to be invalidated whenever sqlite3_step() is called from within \n    ** a v-table method.\n    */\n    if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){\n      sqlite3ResetOneSchema(db, pOp->p1);\n    }\n    p->expired = 1;\n    rc = SQLITE_SCHEMA;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ReadCookie P1 P2 P3 * *\n**\n** Read cookie number P3 from database P1 and write it into register P2.\n** P3==1 is the schema version.  P3==2 is the database format.\n** P3==3 is the recommended pager cache size, and so forth.  P1==0 is\n** the main database file and P1==1 is the database file used to store\n** temporary tables.\n**\n** There must be a read-lock on the database (either a transaction\n** must be started or there must be an open cursor) before\n** executing this instruction.\n*/\ncase OP_ReadCookie: {               /* out2 */\n  int iMeta;\n  int iDb;\n  int iCookie;\n\n  assert( p->bIsReader );\n  iDb = pOp->p1;\n  iCookie = pOp->p3;\n  assert( pOp->p3<SQLITE_N_BTREE_META );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n\n  sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = iMeta;\n  break;\n}\n\n/* Opcode: SetCookie P1 P2 P3 * *\n**\n** Write the integer value P3 into cookie number P2 of database P1.\n** P2==1 is the schema version.  P2==2 is the database format.\n** P2==3 is the recommended pager cache \n** size, and so forth.  P1==0 is the main database file and P1==1 is the \n** database file used to store temporary tables.\n**\n** A transaction must be started before executing this opcode.\n*/\ncase OP_SetCookie: {\n  Db *pDb;\n  assert( pOp->p2<SQLITE_N_BTREE_META );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );\n  /* See note about index shifting on OP_ReadCookie */\n  rc = sqlite3BtreeUpdateMeta(pDb->pBt, pOp->p2, pOp->p3);\n  if( pOp->p2==BTREE_SCHEMA_VERSION ){\n    /* When the schema cookie changes, record the new cookie internally */\n    pDb->pSchema->schema_cookie = pOp->p3;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }else if( pOp->p2==BTREE_FILE_FORMAT ){\n    /* Record changes in the file format */\n    pDb->pSchema->file_format = pOp->p3;\n  }\n  if( pOp->p1==1 ){\n    /* Invalidate all prepared statements whenever the TEMP database\n    ** schema is changed.  Ticket #1644 */\n    sqlite3ExpirePreparedStatements(db);\n    p->expired = 0;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenRead P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read-only cursor for the database table whose root page is\n** P2 in a database file.  The database file is determined by P3. \n** P3==0 means the main database, P3==1 means the database used for \n** temporary tables, and P3>1 means used the corresponding attached\n** database.  Give the new cursor an identifier of P1.  The P1\n** values need not be contiguous but all P1 values should be small integers.\n** It is an error for P1 to be negative.\n**\n** If P5!=0 then use the content of register P2 as the root page, not\n** the value of P2 itself.\n**\n** There will be a read lock on the database whenever there is an\n** open cursor.  If the database was unlocked prior to this instruction\n** then a read lock is acquired as part of this instruction.  A read\n** lock allows other processes to read the database but prohibits\n** any other process from modifying the database.  The read lock is\n** released when all cursors are closed.  If this instruction attempts\n** to get a read lock but fails, the script terminates with an\n** SQLITE_BUSY error code.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table.\n**\n** See also: OpenWrite, ReopenIdx\n*/\n/* Opcode: ReopenIdx P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** The ReopenIdx opcode works exactly like ReadOpen except that it first\n** checks to see if the cursor on P1 is already open with a root page\n** number of P2 and if it is this opcode becomes a no-op.  In other words,\n** if the cursor is already open, do not reopen it.\n**\n** The ReopenIdx opcode may only be used with P5==0 and with P4 being\n** a P4_KEYINFO object.  Furthermore, the P3 value must be the same as\n** every other ReopenIdx or OpenRead for the same cursor number.\n**\n** See the OpenRead opcode documentation for additional information.\n*/\n/* Opcode: OpenWrite P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read/write cursor named P1 on the table or index whose root\n** page is P2.  Or if P5!=0 use the content of register P2 to find the\n** root page.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table, or to the\n** largest index of any column of the table that is actually used.\n**\n** This instruction works just like OpenRead except that it opens the cursor\n** in read/write mode.  For a given table, there can be one or more read-only\n** cursors or a single read/write cursor but not both.\n**\n** See also OpenRead.\n*/\ncase OP_ReopenIdx: {\n  int nField;\n  KeyInfo *pKeyInfo;\n  int p2;\n  int iDb;\n  int wrFlag;\n  Btree *pX;\n  VdbeCursor *pCur;\n  Db *pDb;\n\n  assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( pOp->p4type==P4_KEYINFO );\n  pCur = p->apCsr[pOp->p1];\n  if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){\n    assert( pCur->iDb==pOp->p3 );      /* Guaranteed by the code generator */\n    goto open_cursor_set_hints;\n  }\n  /* If the cursor is not currently open or is open on a different\n  ** index, then fall through into OP_OpenRead to force a reopen */\ncase OP_OpenRead:\ncase OP_OpenWrite:\n\n  assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( p->bIsReader );\n  assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx\n          || p->readOnly==0 );\n\n  if( p->expired ){\n    rc = SQLITE_ABORT_ROLLBACK;\n    goto abort_due_to_error;\n  }\n\n  nField = 0;\n  pKeyInfo = 0;\n  p2 = pOp->p2;\n  iDb = pOp->p3;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n  pDb = &db->aDb[iDb];\n  pX = pDb->pBt;\n  assert( pX!=0 );\n  if( pOp->opcode==OP_OpenWrite ){\n    assert( OPFLAG_FORDELETE==BTREE_FORDELETE );\n    wrFlag = BTREE_WRCSR | (pOp->p5 & OPFLAG_FORDELETE);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( pDb->pSchema->file_format < p->minWriteFileFormat ){\n      p->minWriteFileFormat = pDb->pSchema->file_format;\n    }\n  }else{\n    wrFlag = 0;\n  }\n  if( pOp->p5 & OPFLAG_P2ISREG ){\n    assert( p2>0 );\n    assert( p2<=(p->nMem+1 - p->nCursor) );\n    pIn2 = &aMem[p2];\n    assert( memIsValid(pIn2) );\n    assert( (pIn2->flags & MEM_Int)!=0 );\n    sqlite3VdbeMemIntegerify(pIn2);\n    p2 = (int)pIn2->u.i;\n    /* The p2 value always comes from a prior OP_CreateBtree opcode and\n    ** that opcode will always set the p2 value to 2 or more or else fail.\n    ** If there were a failure, the prepared statement would have halted\n    ** before reaching this instruction. */\n    assert( p2>=2 );\n  }\n  if( pOp->p4type==P4_KEYINFO ){\n    pKeyInfo = pOp->p4.pKeyInfo;\n    assert( pKeyInfo->enc==ENC(db) );\n    assert( pKeyInfo->db==db );\n    nField = pKeyInfo->nAllField;\n  }else if( pOp->p4type==P4_INT32 ){\n    nField = pOp->p4.i;\n  }\n  assert( pOp->p1>=0 );\n  assert( nField>=0 );\n  testcase( nField==0 );  /* Table with INTEGER PRIMARY KEY and nothing else */\n  pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);\n  if( pCur==0 ) goto no_mem;\n  pCur->nullRow = 1;\n  pCur->isOrdered = 1;\n  pCur->pgnoRoot = p2;\n#ifdef SQLITE_DEBUG\n  pCur->wrFlag = wrFlag;\n#endif\n  rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->uc.pCursor);\n  pCur->pKeyInfo = pKeyInfo;\n  /* Set the VdbeCursor.isTable variable. Previous versions of\n  ** SQLite used to check if the root-page flags were sane at this point\n  ** and report database corruption if they were not, but this check has\n  ** since moved into the btree layer.  */  \n  pCur->isTable = pOp->p4type!=P4_KEYINFO;\n\nopen_cursor_set_hints:\n  assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );\n  assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );\n  testcase( pOp->p5 & OPFLAG_BULKCSR );\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n  testcase( pOp->p2 & OPFLAG_SEEKEQ );\n#endif\n  sqlite3BtreeCursorHintFlags(pCur->uc.pCursor,\n                               (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenDup P1 P2 * * *\n**\n** Open a new cursor P1 that points to the same ephemeral table as\n** cursor P2.  The P2 cursor must have been opened by a prior OP_OpenEphemeral\n** opcode.  Only ephemeral cursors may be duplicated.\n**\n** Duplicate ephemeral cursors are used for self-joins of materialized views.\n*/\ncase OP_OpenDup: {\n  VdbeCursor *pOrig;    /* The original cursor to be duplicated */\n  VdbeCursor *pCx;      /* The new cursor */\n\n  pOrig = p->apCsr[pOp->p2];\n  assert( pOrig->pBtx!=0 );  /* Only ephemeral cursors can be duplicated */\n\n  pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->isEphemeral = 1;\n  pCx->pKeyInfo = pOrig->pKeyInfo;\n  pCx->isTable = pOrig->isTable;\n  rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR,\n                          pCx->pKeyInfo, pCx->uc.pCursor);\n  /* The sqlite3BtreeCursor() routine can only fail for the first cursor\n  ** opened for a database.  Since there is already an open cursor when this\n  ** opcode is run, the sqlite3BtreeCursor() cannot fail */\n  assert( rc==SQLITE_OK );\n  break;\n}\n\n\n/* Opcode: OpenEphemeral P1 P2 * P4 P5\n** Synopsis: nColumn=P2\n**\n** Open a new cursor P1 to a transient table.\n** The cursor is always opened read/write even if \n** the main database is read-only.  The ephemeral\n** table is deleted automatically when the cursor is closed.\n**\n** P2 is the number of columns in the ephemeral table.\n** The cursor points to a BTree table if P4==0 and to a BTree index\n** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure\n** that defines the format of keys in the index.\n**\n** The P5 parameter can be a mask of the BTREE_* flags defined\n** in btree.h.  These flags control aspects of the operation of\n** the btree.  The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are\n** added automatically.\n*/\n/* Opcode: OpenAutoindex P1 P2 * P4 *\n** Synopsis: nColumn=P2\n**\n** This opcode works the same as OP_OpenEphemeral.  It has a\n** different name to distinguish its use.  Tables created using\n** by this opcode will be used for automatically created transient\n** indices in joins.\n*/\ncase OP_OpenAutoindex: \ncase OP_OpenEphemeral: {\n  VdbeCursor *pCx;\n  KeyInfo *pKeyInfo;\n\n  static const int vfsFlags = \n      SQLITE_OPEN_READWRITE |\n      SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE |\n      SQLITE_OPEN_DELETEONCLOSE |\n      SQLITE_OPEN_TRANSIENT_DB;\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->isEphemeral = 1;\n  rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx, \n                        BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1);\n  }\n  if( rc==SQLITE_OK ){\n    /* If a transient index is required, create it by calling\n    ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before\n    ** opening it. If a transient table is required, just use the\n    ** automatically created table with root-page 1 (an BLOB_INTKEY table).\n    */\n    if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){\n      int pgno;\n      assert( pOp->p4type==P4_KEYINFO );\n      rc = sqlite3BtreeCreateTable(pCx->pBtx, &pgno, BTREE_BLOBKEY | pOp->p5); \n      if( rc==SQLITE_OK ){\n        assert( pgno==MASTER_ROOT+1 );\n        assert( pKeyInfo->db==db );\n        assert( pKeyInfo->enc==ENC(db) );\n        rc = sqlite3BtreeCursor(pCx->pBtx, pgno, BTREE_WRCSR,\n                                pKeyInfo, pCx->uc.pCursor);\n      }\n      pCx->isTable = 0;\n    }else{\n      rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,\n                              0, pCx->uc.pCursor);\n      pCx->isTable = 1;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);\n  break;\n}\n\n/* Opcode: SorterOpen P1 P2 P3 P4 *\n**\n** This opcode works like OP_OpenEphemeral except that it opens\n** a transient index that is specifically designed to sort large\n** tables using an external merge-sort algorithm.\n**\n** If argument P3 is non-zero, then it indicates that the sorter may\n** assume that a stable sort considering the first P3 fields of each\n** key is sufficient to produce the required results.\n*/\ncase OP_SorterOpen: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);\n  if( pCx==0 ) goto no_mem;\n  pCx->pKeyInfo = pOp->p4.pKeyInfo;\n  assert( pCx->pKeyInfo->db==db );\n  assert( pCx->pKeyInfo->enc==ENC(db) );\n  rc = sqlite3VdbeSorterInit(db, pOp->p3, pCx);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: SequenceTest P1 P2 * * *\n** Synopsis: if( cursor[P1].ctr++ ) pc = P2\n**\n** P1 is a sorter cursor. If the sequence counter is currently zero, jump\n** to P2. Regardless of whether or not the jump is taken, increment the\n** the sequence value.\n*/\ncase OP_SequenceTest: {\n  VdbeCursor *pC;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  if( (pC->seqCount++)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OpenPseudo P1 P2 P3 * *\n** Synopsis: P3 columns in r[P2]\n**\n** Open a new cursor that points to a fake table that contains a single\n** row of data.  The content of that one row is the content of memory\n** register P2.  In other words, cursor P1 becomes an alias for the \n** MEM_Blob content contained in register P2.\n**\n** A pseudo-table created by this opcode is used to hold a single\n** row output from the sorter so that the row can be decomposed into\n** individual columns using the OP_Column opcode.  The OP_Column opcode\n** is the only cursor opcode that works with a pseudo-table.\n**\n** P3 is the number of fields in the records that will be stored by\n** the pseudo-table.\n*/\ncase OP_OpenPseudo: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p3>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->seekResult = pOp->p2;\n  pCx->isTable = 1;\n  /* Give this pseudo-cursor a fake BtCursor pointer so that pCx\n  ** can be safely passed to sqlite3VdbeCursorMoveto().  This avoids a test\n  ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto()\n  ** which is a performance optimization */\n  pCx->uc.pCursor = sqlite3BtreeFakeValidCursor();\n  assert( pOp->p5==0 );\n  break;\n}\n\n/* Opcode: Close P1 * * * *\n**\n** Close a cursor previously opened as P1.  If P1 is not\n** currently open, this instruction is a no-op.\n*/\ncase OP_Close: {\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  sqlite3VdbeFreeCursor(p, p->apCsr[pOp->p1]);\n  p->apCsr[pOp->p1] = 0;\n  break;\n}\n\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n/* Opcode: ColumnsUsed P1 * * P4 *\n**\n** This opcode (which only exists if SQLite was compiled with\n** SQLITE_ENABLE_COLUMN_USED_MASK) identifies which columns of the\n** table or index for cursor P1 are used.  P4 is a 64-bit integer\n** (P4_INT64) in which the first 63 bits are one for each of the\n** first 63 columns of the table or index that are actually used\n** by the cursor.  The high-order bit is set if any column after\n** the 64th is used.\n*/\ncase OP_ColumnsUsed: {\n  VdbeCursor *pC;\n  pC = p->apCsr[pOp->p1];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pC->maskUsed = *(u64*)pOp->p4.pI64;\n  break;\n}\n#endif\n\n/* Opcode: SeekGE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as the key.  If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than or equal to the key value. If there are no records \n** greater than or equal to the key and P2 is not zero, then jump to P2.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxLE opcode with the same arguments.\n** The IdxLE opcode will be skipped if this opcode succeeds, but the\n** IdxLE opcode will be used on subsequent loop iterations.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGt, SeekLe\n*/\n/* Opcode: SeekGT P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than the key value. If there are no records greater than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLT P1 P2 P3 P4 * \n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the largest entry that \n** is less than the key value. If there are no records less than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that it points to the largest entry that \n** is less than or equal to the key value. If there are no records \n** less than or equal to the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxGE opcode with the same arguments.\n** The IdxGE opcode will be skipped if this opcode succeeds, but the\n** IdxGE opcode will be used on subsequent loop iterations.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLt\n*/\ncase OP_SeekLT:         /* jump, in3 */\ncase OP_SeekLE:         /* jump, in3 */\ncase OP_SeekGE:         /* jump, in3 */\ncase OP_SeekGT: {       /* jump, in3 */\n  int res;           /* Comparison result */\n  int oc;            /* Opcode */\n  VdbeCursor *pC;    /* The cursor to seek */\n  UnpackedRecord r;  /* The key to seek for */\n  int nField;        /* Number of columns or fields in the key */\n  i64 iKey;          /* The rowid we are to seek to */\n  int eqOnly;        /* Only interested in == results */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p2!=0 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( OP_SeekLE == OP_SeekLT+1 );\n  assert( OP_SeekGE == OP_SeekLT+2 );\n  assert( OP_SeekGT == OP_SeekLT+3 );\n  assert( pC->isOrdered );\n  assert( pC->uc.pCursor!=0 );\n  oc = pOp->opcode;\n  eqOnly = 0;\n  pC->nullRow = 0;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n\n  if( pC->isTable ){\n    /* The BTREE_SEEK_EQ flag is only set on index cursors */\n    assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0\n              || CORRUPT_DB );\n\n    /* The input value in P3 might be of any type: integer, real, string,\n    ** blob, or NULL.  But it needs to be an integer before we can do\n    ** the seek, so convert it. */\n    pIn3 = &aMem[pOp->p3];\n    if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n      applyNumericAffinity(pIn3, 0);\n    }\n    iKey = sqlite3VdbeIntValue(pIn3);\n\n    /* If the P3 value could not be converted into an integer without\n    ** loss of information, then special processing is required... */\n    if( (pIn3->flags & MEM_Int)==0 ){\n      if( (pIn3->flags & MEM_Real)==0 ){\n        /* If the P3 value cannot be converted into any kind of a number,\n        ** then the seek is not possible, so jump to P2 */\n        VdbeBranchTaken(1,2); goto jump_to_p2;\n        break;\n      }\n\n      /* If the approximation iKey is larger than the actual real search\n      ** term, substitute >= for > and < for <=. e.g. if the search term\n      ** is 4.9 and the integer approximation 5:\n      **\n      **        (x >  4.9)    ->     (x >= 5)\n      **        (x <= 4.9)    ->     (x <  5)\n      */\n      if( pIn3->u.r<(double)iKey ){\n        assert( OP_SeekGE==(OP_SeekGT-1) );\n        assert( OP_SeekLT==(OP_SeekLE-1) );\n        assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;\n      }\n\n      /* If the approximation iKey is smaller than the actual real search\n      ** term, substitute <= for < and > for >=.  */\n      else if( pIn3->u.r>(double)iKey ){\n        assert( OP_SeekLE==(OP_SeekLT+1) );\n        assert( OP_SeekGT==(OP_SeekGE+1) );\n        assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;\n      }\n    } \n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);\n    pC->movetoTarget = iKey;  /* Used by OP_Delete */\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n  }else{\n    /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and\n    ** OP_SeekLE opcodes are allowed, and these must be immediately followed\n    ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.\n    */\n    if( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ) ){\n      eqOnly = 1;\n      assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );\n      assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n      assert( pOp[1].p1==pOp[0].p1 );\n      assert( pOp[1].p2==pOp[0].p2 );\n      assert( pOp[1].p3==pOp[0].p3 );\n      assert( pOp[1].p4.i==pOp[0].p4.i );\n    }\n\n    nField = pOp->p4.i;\n    assert( pOp->p4type==P4_INT32 );\n    assert( nField>0 );\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)nField;\n\n    /* The next line of code computes as follows, only faster:\n    **   if( oc==OP_SeekGT || oc==OP_SeekLE ){\n    **     r.default_rc = -1;\n    **   }else{\n    **     r.default_rc = +1;\n    **   }\n    */\n    r.default_rc = ((1 & (oc - OP_SeekLT)) ? -1 : +1);\n    assert( oc!=OP_SeekGT || r.default_rc==-1 );\n    assert( oc!=OP_SeekLE || r.default_rc==-1 );\n    assert( oc!=OP_SeekGE || r.default_rc==+1 );\n    assert( oc!=OP_SeekLT || r.default_rc==+1 );\n\n    r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }\n#endif\n    r.eqSeen = 0;\n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( eqOnly && r.eqSeen==0 ){\n      assert( res!=0 );\n      goto seek_not_found;\n    }\n  }\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  if( oc>=OP_SeekGE ){  assert( oc==OP_SeekGE || oc==OP_SeekGT );\n    if( res<0 || (res==0 && oc==OP_SeekGT) ){\n      res = 0;\n      rc = sqlite3BtreeNext(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      res = 0;\n    }\n  }else{\n    assert( oc==OP_SeekLT || oc==OP_SeekLE );\n    if( res>0 || (res==0 && oc==OP_SeekLT) ){\n      res = 0;\n      rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      /* res might be negative because the table is empty.  Check to\n      ** see if this is the case.\n      */\n      res = sqlite3BtreeEof(pC->uc.pCursor);\n    }\n  }\nseek_not_found:\n  assert( pOp->p2>0 );\n  VdbeBranchTaken(res!=0,2);\n  if( res ){\n    goto jump_to_p2;\n  }else if( eqOnly ){\n    assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n    pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */\n  }\n  break;\n}\n\n/* Opcode: Found P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n**\n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is a prefix of any entry in P1 then a jump is made to P2 and\n** P1 is left pointing at the matching entry.\n**\n** This operation leaves the cursor in a state where it can be\n** advanced in the forward direction.  The Next instruction will work,\n** but not the Prev instruction.\n**\n** See also: NotFound, NoConflict, NotExists. SeekGe\n*/\n/* Opcode: NotFound P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 \n** does contain an entry whose prefix matches the P3/P4 record then control\n** falls through to the next instruction and P1 is left pointing at the\n** matching entry.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: Found, NotExists, NoConflict\n*/\n/* Opcode: NoConflict P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** contains any NULL value, jump immediately to P2.  If all terms of the\n** record are not-NULL then a check is done to determine if any row in the\n** P1 index btree has a matching key prefix.  If there are no matches, jump\n** immediately to P2.  If there is a match, fall through and leave the P1\n** cursor pointing to the matching row.\n**\n** This opcode is similar to OP_NotFound with the exceptions that the\n** branch is always taken if any part of the search key input is NULL.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: NotFound, Found, NotExists\n*/\ncase OP_NoConflict:     /* jump, in3 */\ncase OP_NotFound:       /* jump, in3 */\ncase OP_Found: {        /* jump, in3 */\n  int alreadyExists;\n  int takeJump;\n  int ii;\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord *pFree;\n  UnpackedRecord *pIdxKey;\n  UnpackedRecord r;\n\n#ifdef SQLITE_TEST\n  if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++;\n#endif\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_INT32 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  pIn3 = &aMem[pOp->p3];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  if( pOp->p4.i>0 ){\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)pOp->p4.i;\n    r.aMem = pIn3;\n#ifdef SQLITE_DEBUG\n    for(ii=0; ii<r.nField; ii++){\n      assert( memIsValid(&r.aMem[ii]) );\n      assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 );\n      if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);\n    }\n#endif\n    pIdxKey = &r;\n    pFree = 0;\n  }else{\n    assert( pIn3->flags & MEM_Blob );\n    rc = ExpandBlob(pIn3);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc ) goto no_mem;\n    pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);\n    if( pIdxKey==0 ) goto no_mem;\n    sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);\n  }\n  pIdxKey->default_rc = 0;\n  takeJump = 0;\n  if( pOp->opcode==OP_NoConflict ){\n    /* For the OP_NoConflict opcode, take the jump if any of the\n    ** input fields are NULL, since any key with a NULL will not\n    ** conflict */\n    for(ii=0; ii<pIdxKey->nField; ii++){\n      if( pIdxKey->aMem[ii].flags & MEM_Null ){\n        takeJump = 1;\n        break;\n      }\n    }\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);\n  if( pFree ) sqlite3DbFreeNN(db, pFree);\n  if( rc!=SQLITE_OK ){\n    goto abort_due_to_error;\n  }\n  pC->seekResult = res;\n  alreadyExists = (res==0);\n  pC->nullRow = 1-alreadyExists;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( pOp->opcode==OP_Found ){\n    VdbeBranchTaken(alreadyExists!=0,2);\n    if( alreadyExists ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(takeJump||alreadyExists==0,2);\n    if( takeJump || !alreadyExists ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: SeekRowid P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  If register P3 does not contain an integer or if P1 does not\n** contain a record with rowid P3 then jump immediately to P2.  \n** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain\n** a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_NotExists opcode performs the same operation, but with OP_NotExists\n** the P3 register must be guaranteed to contain an integer value.  With this\n** opcode, register P3 might not contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\n/* Opcode: NotExists P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  P3 is an integer rowid.  If P1 does not contain a record with\n** rowid P3 then jump immediately to P2.  Or, if P2 is 0, raise an\n** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_SeekRowid opcode performs the same operation but also allows the\n** P3 register to contain a non-integer value, in which case the jump is\n** always taken.  This opcode requires that P3 always contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\ncase OP_SeekRowid: {        /* jump, in3 */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  u64 iKey;\n\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Int)==0 ){\n    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);\n    if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;\n  }\n  /* Fall through into OP_NotExists */\ncase OP_NotExists:          /* jump, in3 */\n  pIn3 = &aMem[pOp->p3];\n  assert( pIn3->flags & MEM_Int );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = 0;\n#endif\n  assert( pC->isTable );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  res = 0;\n  iKey = pIn3->u.i;\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);\n  assert( rc==SQLITE_OK || res==0 );\n  pC->movetoTarget = iKey;  /* Used by OP_Delete */\n  pC->nullRow = 0;\n  pC->cacheStatus = CACHE_STALE;\n  pC->deferredMoveto = 0;\n  VdbeBranchTaken(res!=0,2);\n  pC->seekResult = res;\n  if( res!=0 ){\n    assert( rc==SQLITE_OK );\n    if( pOp->p2==0 ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      goto jump_to_p2;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: Sequence P1 P2 * * *\n** Synopsis: r[P2]=cursor[P1].ctr++\n**\n** Find the next available sequence number for cursor P1.\n** Write the sequence number into register P2.\n** The sequence number on the cursor is incremented after this\n** instruction.  \n*/\ncase OP_Sequence: {           /* out2 */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  assert( p->apCsr[pOp->p1]->eCurType!=CURTYPE_VTAB );\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = p->apCsr[pOp->p1]->seqCount++;\n  break;\n}\n\n\n/* Opcode: NewRowid P1 P2 P3 * *\n** Synopsis: r[P2]=rowid\n**\n** Get a new integer record number (a.k.a \"rowid\") used as the key to a table.\n** The record number is not previously used as a key in the database\n** table that cursor P1 points to.  The new record number is written\n** written to register P2.\n**\n** If P3>0 then P3 is a register in the root frame of this VDBE that holds \n** the largest previously generated record number. No new record numbers are\n** allowed to be less than this value. When this value reaches its maximum, \n** an SQLITE_FULL error is generated. The P3 register is updated with the '\n** generated record number. This P3 mechanism is used to help implement the\n** AUTOINCREMENT feature.\n*/\ncase OP_NewRowid: {           /* out2 */\n  i64 v;                 /* The new rowid */\n  VdbeCursor *pC;        /* Cursor of table to get the new rowid */\n  int res;               /* Result of an sqlite3BtreeLast() */\n  int cnt;               /* Counter to limit the number of searches */\n  Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */\n  VdbeFrame *pFrame;     /* Root frame of VDBE */\n\n  v = 0;\n  res = 0;\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  {\n    /* The next rowid or record number (different terms for the same\n    ** thing) is obtained in a two-step algorithm.\n    **\n    ** First we attempt to find the largest existing rowid and add one\n    ** to that.  But if the largest existing rowid is already the maximum\n    ** positive integer, we have to fall through to the second\n    ** probabilistic algorithm\n    **\n    ** The second algorithm is to select a rowid at random and see if\n    ** it already exists in the table.  If it does not exist, we have\n    ** succeeded.  If the random rowid does exist, we select a new one\n    ** and try again, up to 100 times.\n    */\n    assert( pC->isTable );\n\n#ifdef SQLITE_32BIT_ROWID\n#   define MAX_ROWID 0x7fffffff\n#else\n    /* Some compilers complain about constants of the form 0x7fffffffffffffff.\n    ** Others complain about 0x7ffffffffffffffffLL.  The following macro seems\n    ** to provide the constant while making all compilers happy.\n    */\n#   define MAX_ROWID  (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff )\n#endif\n\n    if( !pC->useRandomRowid ){\n      rc = sqlite3BtreeLast(pC->uc.pCursor, &res);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      if( res ){\n        v = 1;   /* IMP: R-61914-48074 */\n      }else{\n        assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );\n        v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n        if( v>=MAX_ROWID ){\n          pC->useRandomRowid = 1;\n        }else{\n          v++;   /* IMP: R-29538-34987 */\n        }\n      }\n    }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    if( pOp->p3 ){\n      /* Assert that P3 is a valid memory cell. */\n      assert( pOp->p3>0 );\n      if( p->pFrame ){\n        for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=pFrame->nMem );\n        pMem = &pFrame->aMem[pOp->p3];\n      }else{\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        pMem = &aMem[pOp->p3];\n        memAboutToChange(p, pMem);\n      }\n      assert( memIsValid(pMem) );\n\n      REGISTER_TRACE(pOp->p3, pMem);\n      sqlite3VdbeMemIntegerify(pMem);\n      assert( (pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */\n      if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){\n        rc = SQLITE_FULL;   /* IMP: R-17817-00630 */\n        goto abort_due_to_error;\n      }\n      if( v<pMem->u.i+1 ){\n        v = pMem->u.i + 1;\n      }\n      pMem->u.i = v;\n    }\n#endif\n    if( pC->useRandomRowid ){\n      /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the\n      ** largest possible integer (9223372036854775807) then the database\n      ** engine starts picking positive candidate ROWIDs at random until\n      ** it finds one that is not previously used. */\n      assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is\n                             ** an AUTOINCREMENT table. */\n      cnt = 0;\n      do{\n        sqlite3_randomness(sizeof(v), &v);\n        v &= (MAX_ROWID>>1); v++;  /* Ensure that v is greater than zero */\n      }while(  ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,\n                                                 0, &res))==SQLITE_OK)\n            && (res==0)\n            && (++cnt<100));\n      if( rc ) goto abort_due_to_error;\n      if( res==0 ){\n        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */\n        goto abort_due_to_error;\n      }\n      assert( v>0 );  /* EV: R-40812-03570 */\n    }\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: Insert P1 P2 P3 P4 P5\n** Synopsis: intkey=r[P3] data=r[P2]\n**\n** Write an entry into the table of cursor P1.  A new entry is\n** created if it doesn't already exist or the data for an existing\n** entry is overwritten.  The data is the value MEM_Blob stored in register\n** number P2. The key is stored in register P3. The key must\n** be a MEM_Int.\n**\n** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is\n** incremented (otherwise not).  If the OPFLAG_LASTROWID flag of P5 is set,\n** then rowid is stored for subsequent return by the\n** sqlite3_last_insert_rowid() function (otherwise it is unmodified).\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equal to P3.\n**\n** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an\n** UPDATE operation.  Otherwise (if the flag is clear) then this opcode\n** is part of an INSERT operation.  The difference is only important to\n** the update hook.\n**\n** Parameter P4 may point to a Table structure, or may be NULL. If it is \n** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked \n** following a successful insert.\n**\n** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically\n** allocated, then ownership of P2 is transferred to the pseudo-cursor\n** and register P2 becomes ephemeral.  If the cursor is changed, the\n** value of register P2 will then change.  Make sure this does not\n** cause any problems.)\n**\n** This instruction only works on tables.  The equivalent instruction\n** for indices is OP_IdxInsert.\n*/\n/* Opcode: InsertInt P1 P2 P3 P4 P5\n** Synopsis: intkey=P3 data=r[P2]\n**\n** This works exactly like OP_Insert except that the key is the\n** integer value P3, not the value of the integer stored in register P3.\n*/\ncase OP_Insert: \ncase OP_InsertInt: {\n  Mem *pData;       /* MEM cell holding data for the record to be inserted */\n  Mem *pKey;        /* MEM cell holding key  for the record */\n  VdbeCursor *pC;   /* Cursor to table into which insert is written */\n  int seekResult;   /* Result of prior seek or 0 if no USESEEKRESULT flag */\n  const char *zDb;  /* database name - used by the update hook */\n  Table *pTab;      /* Table structure - used by update and pre-update hooks */\n  int op;           /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */\n  BtreePayload x;   /* Payload to be inserted */\n\n  op = 0;\n  pData = &aMem[pOp->p2];\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( memIsValid(pData) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable );\n  assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );\n  REGISTER_TRACE(pOp->p2, pData);\n\n  if( pOp->opcode==OP_Insert ){\n    pKey = &aMem[pOp->p3];\n    assert( pKey->flags & MEM_Int );\n    assert( memIsValid(pKey) );\n    REGISTER_TRACE(pOp->p3, pKey);\n    x.nKey = pKey->u.i;\n  }else{\n    assert( pOp->opcode==OP_InsertInt );\n    x.nKey = pOp->p3;\n  }\n\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );\n    op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);\n  }else{\n    pTab = 0; /* Not needed.  Silence a compiler warning. */\n    zDb = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update hook, if any */\n  if( db->xPreUpdateCallback \n   && pOp->p4type==P4_TABLE\n   && !(pOp->p5 & OPFLAG_ISUPDATE)\n  ){\n    sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);\n  }\n  if( pOp->p5 & OPFLAG_ISNOOP ) break;\n#endif\n\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = x.nKey;\n  assert( pData->flags & (MEM_Blob|MEM_Str) );\n  x.pData = pData->z;\n  x.nData = pData->n;\n  seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);\n  if( pData->flags & MEM_Zero ){\n    x.nZero = pData->u.nZero;\n  }else{\n    x.nZero = 0;\n  }\n  x.pKey = 0;\n  rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n      (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), seekResult\n  );\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n\n  /* Invoke the update-hook if required. */\n  if( rc ) goto abort_due_to_error;\n  if( db->xUpdateCallback && op ){\n    db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);\n  }\n  break;\n}\n\n/* Opcode: Delete P1 P2 P3 P4 P5\n**\n** Delete the record at which the P1 cursor is currently pointing.\n**\n** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then\n** the cursor will be left pointing at  either the next or the previous\n** record in the table. If it is left pointing at the next record, then\n** the next Next instruction will be a no-op. As a result, in this case\n** it is ok to delete a record from within a Next loop. If \n** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be\n** left in an undefined state.\n**\n** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this\n** delete one of several associated with deleting a table row and all its\n** associated index entries.  Exactly one of those deletes is the \"primary\"\n** delete.  The others are all on OPFLAG_FORDELETE cursors or else are\n** marked with the AUXDELETE flag.\n**\n** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row\n** change count is incremented (otherwise not).\n**\n** P1 must not be pseudo-table.  It has to be a real table with\n** multiple rows.\n**\n** If P4 is not NULL then it points to a Table object. In this case either \n** the update or pre-update hook, or both, may be invoked. The P1 cursor must\n** have been positioned using OP_NotFound prior to invoking this opcode in \n** this case. Specifically, if one is configured, the pre-update hook is \n** invoked if P4 is not NULL. The update-hook is invoked if one is configured, \n** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2.\n**\n** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address\n** of the memory cell that contains the value that the rowid of the row will\n** be set to by the update.\n*/\ncase OP_Delete: {\n  VdbeCursor *pC;\n  const char *zDb;\n  Table *pTab;\n  int opflags;\n\n  opflags = pOp->p2;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->deferredMoveto==0 );\n\n#ifdef SQLITE_DEBUG\n  if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){\n    /* If p5 is zero, the seek operation that positioned the cursor prior to\n    ** OP_Delete will have also set the pC->movetoTarget field to the rowid of\n    ** the row that is being deleted */\n    i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    assert( pC->movetoTarget==iKey );\n  }\n#endif\n\n  /* If the update-hook or pre-update-hook will be invoked, set zDb to\n  ** the name of the db to pass as to it. Also set local pTab to a copy\n  ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was\n  ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set \n  ** VdbeCursor.movetoTarget to the current rowid.  */\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    assert( pOp->p4.pTab!=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){\n      pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    }\n  }else{\n    zDb = 0;   /* Not needed.  Silence a compiler warning. */\n    pTab = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update-hook if required. */\n  if( db->xPreUpdateCallback && pOp->p4.pTab ){\n    assert( !(opflags & OPFLAG_ISUPDATE) \n         || HasRowid(pTab)==0 \n         || (aMem[pOp->p3].flags & MEM_Int) \n    );\n    sqlite3VdbePreUpdateHook(p, pC,\n        (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, \n        zDb, pTab, pC->movetoTarget,\n        pOp->p3\n    );\n  }\n  if( opflags & OPFLAG_ISNOOP ) break;\n#endif\n \n  /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ \n  assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 );\n  assert( OPFLAG_SAVEPOSITION==BTREE_SAVEPOSITION );\n  assert( OPFLAG_AUXDELETE==BTREE_AUXDELETE );\n\n#ifdef SQLITE_DEBUG\n  if( p->pFrame==0 ){\n    if( pC->isEphemeral==0\n        && (pOp->p5 & OPFLAG_AUXDELETE)==0\n        && (pC->wrFlag & OPFLAG_FORDELETE)==0\n      ){\n      nExtraDelete++;\n    }\n    if( pOp->p2 & OPFLAG_NCHANGE ){\n      nExtraDelete--;\n    }\n  }\n#endif\n\n  rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  if( rc ) goto abort_due_to_error;\n\n  /* Invoke the update-hook if required. */\n  if( opflags & OPFLAG_NCHANGE ){\n    p->nChange++;\n    if( db->xUpdateCallback && HasRowid(pTab) ){\n      db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,\n          pC->movetoTarget);\n      assert( pC->iDb>=0 );\n    }\n  }\n\n  break;\n}\n/* Opcode: ResetCount * * * * *\n**\n** The value of the change counter is copied to the database handle\n** change counter (returned by subsequent calls to sqlite3_changes()).\n** Then the VMs internal change counter resets to 0.\n** This is used by trigger programs.\n*/\ncase OP_ResetCount: {\n  sqlite3VdbeSetChanges(db, p->nChange);\n  p->nChange = 0;\n  break;\n}\n\n/* Opcode: SorterCompare P1 P2 P3 P4\n** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2\n**\n** P1 is a sorter cursor. This instruction compares a prefix of the\n** record blob in register P3 against a prefix of the entry that \n** the sorter cursor currently points to.  Only the first P4 fields\n** of r[P3] and the sorter record are compared.\n**\n** If either P3 or the sorter contains a NULL in one of their significant\n** fields (not counting the P4 fields at the end which are ignored) then\n** the comparison is assumed to be equal.\n**\n** Fall through to next instruction if the two records compare equal to\n** each other.  Jump to P2 if they are different.\n*/\ncase OP_SorterCompare: {\n  VdbeCursor *pC;\n  int res;\n  int nKeyCol;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  assert( pOp->p4type==P4_INT32 );\n  pIn3 = &aMem[pOp->p3];\n  nKeyCol = pOp->p4.i;\n  res = 0;\n  rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);\n  VdbeBranchTaken(res!=0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res ) goto jump_to_p2;\n  break;\n};\n\n/* Opcode: SorterData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the current sorter data for sorter cursor P1.\n** Then clear the column header cache on cursor P3.\n**\n** This opcode is normally use to move a record out of the sorter and into\n** a register that is the source for a pseudo-table cursor created using\n** OpenPseudo.  That pseudo-table cursor is the one that is identified by\n** parameter P3.  Clearing the P3 column cache as part of this opcode saves\n** us from having to issue a separate NullRow instruction to clear that cache.\n*/\ncase OP_SorterData: {\n  VdbeCursor *pC;\n\n  pOut = &aMem[pOp->p2];\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterRowkey(pC, pOut);\n  assert( rc!=SQLITE_OK || (pOut->flags & MEM_Blob) );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  if( rc ) goto abort_due_to_error;\n  p->apCsr[pOp->p3]->cacheStatus = CACHE_STALE;\n  break;\n}\n\n/* Opcode: RowData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the complete row content for the row at \n** which cursor P1 is currently pointing.\n** There is no interpretation of the data.  \n** It is just copied onto the P2 register exactly as \n** it is found in the database file.\n**\n** If cursor P1 is an index, then the content is the key of the row.\n** If cursor P2 is a table, then the content extracted is the data.\n**\n** If the P1 cursor must be pointing to a valid row (not a NULL row)\n** of a real table, not a pseudo-table.\n**\n** If P3!=0 then this opcode is allowed to make an ephermeral pointer\n** into the database page.  That means that the content of the output\n** register will be invalidated as soon as the cursor moves - including\n** moves caused by other cursors that \"save\" the the current cursors\n** position in order that they can write to the same table.  If P3==0\n** then a copy of the data is made into memory.  P3!=0 is faster, but\n** P3==0 is safer.\n**\n** If P3!=0 then the content of the P2 register is unsuitable for use\n** in OP_Result and any OP_Result will invalidate the P2 register content.\n** The P2 register content is invalidated by opcodes like OP_Function or\n** by any use of another cursor pointing to the same table.\n*/\ncase OP_RowData: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  u32 n;\n\n  pOut = out2Prerelease(p, pOp);\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( isSorter(pC)==0 );\n  assert( pC->nullRow==0 );\n  assert( pC->uc.pCursor!=0 );\n  pCrsr = pC->uc.pCursor;\n\n  /* The OP_RowData opcodes always follow OP_NotExists or\n  ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions\n  ** that might invalidate the cursor.\n  ** If this where not the case, on of the following assert()s\n  ** would fail.  Should this ever change (because of changes in the code\n  ** generator) then the fix would be to insert a call to\n  ** sqlite3VdbeCursorMoveto().\n  */\n  assert( pC->deferredMoveto==0 );\n  assert( sqlite3BtreeCursorIsValid(pCrsr) );\n#if 0  /* Not required due to the previous to assert() statements */\n  rc = sqlite3VdbeCursorMoveto(pC);\n  if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n  n = sqlite3BtreePayloadSize(pCrsr);\n  if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  testcase( n==0 );\n  rc = sqlite3VdbeMemFromBtree(pCrsr, 0, n, pOut);\n  if( rc ) goto abort_due_to_error;\n  if( !pOp->p3 ) Deephemeralize(pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  REGISTER_TRACE(pOp->p2, pOut);\n  break;\n}\n\n/* Opcode: Rowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Store in register P2 an integer which is the key of the table entry that\n** P1 is currently point to.\n**\n** P1 can be either an ordinary table or a virtual table.  There used to\n** be a separate OP_VRowid opcode for use with virtual tables, but this\n** one opcode now works for both table types.\n*/\ncase OP_Rowid: {                 /* out2 */\n  VdbeCursor *pC;\n  i64 v;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  if( pC->nullRow ){\n    pOut->flags = MEM_Null;\n    break;\n  }else if( pC->deferredMoveto ){\n    v = pC->movetoTarget;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  }else if( pC->eCurType==CURTYPE_VTAB ){\n    assert( pC->uc.pVCur!=0 );\n    pVtab = pC->uc.pVCur->pVtab;\n    pModule = pVtab->pModule;\n    assert( pModule->xRowid );\n    rc = pModule->xRowid(pC->uc.pVCur, &v);\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc ) goto abort_due_to_error;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->uc.pCursor!=0 );\n    rc = sqlite3VdbeCursorRestore(pC);\n    if( rc ) goto abort_due_to_error;\n    if( pC->nullRow ){\n      pOut->flags = MEM_Null;\n      break;\n    }\n    v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: NullRow P1 * * * *\n**\n** Move the cursor P1 to a null row.  Any OP_Column operations\n** that occur while the cursor is on the null row will always\n** write a NULL.\n*/\ncase OP_NullRow: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pC->nullRow = 1;\n  pC->cacheStatus = CACHE_STALE;\n  if( pC->eCurType==CURTYPE_BTREE ){\n    assert( pC->uc.pCursor!=0 );\n    sqlite3BtreeClearCursor(pC->uc.pCursor);\n  }\n  break;\n}\n\n/* Opcode: SeekEnd P1 * * * *\n**\n** Position cursor P1 at the end of the btree for the purpose of\n** appending a new entry onto the btree.\n**\n** It is assumed that the cursor is used only for appending and so\n** if the cursor is valid, then the cursor must already be pointing\n** at the end of the btree and so no changes are made to\n** the cursor.\n*/\n/* Opcode: Last P1 P2 * * *\n**\n** The next use of the Rowid or Column or Prev instruction for P1 \n** will refer to the last entry in the database table or index.\n** If the table or index is empty and P2>0, then jump immediately to P2.\n** If P2 is 0 or if the table or index is not empty, fall through\n** to the following instruction.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n*/\ncase OP_SeekEnd:\ncase OP_Last: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  res = 0;\n  assert( pCrsr!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  if( pOp->opcode==OP_SeekEnd ){\n    assert( pOp->p2==0 );\n    pC->seekResult = -1;\n    if( sqlite3BtreeCursorIsValidNN(pCrsr) ){\n      break;\n    }\n  }\n  rc = sqlite3BtreeLast(pCrsr, &res);\n  pC->nullRow = (u8)res;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( rc ) goto abort_due_to_error;\n  if( pOp->p2>0 ){\n    VdbeBranchTaken(res!=0,2);\n    if( res ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfSmaller P1 P2 P3 * *\n**\n** Estimate the number of rows in the table P1.  Jump to P2 if that\n** estimate is less than approximately 2**(0.1*P3).\n*/\ncase OP_IfSmaller: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  i64 sz;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr );\n  rc = sqlite3BtreeFirst(pCrsr, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    sz = sqlite3BtreeRowCountEst(pCrsr);\n    if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;\n  }\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: SorterSort P1 P2 * * *\n**\n** After all records have been inserted into the Sorter object\n** identified by P1, invoke this opcode to actually do the sorting.\n** Jump to P2 if there are no records to be sorted.\n**\n** This opcode is an alias for OP_Sort and OP_Rewind that is used\n** for Sorter objects.\n*/\n/* Opcode: Sort P1 P2 * * *\n**\n** This opcode does exactly the same thing as OP_Rewind except that\n** it increments an undocumented global variable used for testing.\n**\n** Sorting is accomplished by writing records into a sorting index,\n** then rewinding that index and playing it back from beginning to\n** end.  We use the OP_Sort opcode instead of OP_Rewind to do the\n** rewinding so that the global variable will be incremented and\n** regression tests can determine whether or not the optimizer is\n** correctly optimizing out sorts.\n*/\ncase OP_SorterSort:    /* jump */\ncase OP_Sort: {        /* jump */\n#ifdef SQLITE_TEST\n  sqlite3_sort_count++;\n  sqlite3_search_count--;\n#endif\n  p->aCounter[SQLITE_STMTSTATUS_SORT]++;\n  /* Fall through into OP_Rewind */\n}\n/* Opcode: Rewind P1 P2 * * *\n**\n** The next use of the Rowid or Column or Next instruction for P1 \n** will refer to the first entry in the database table or index.\n** If the table or index is empty, jump immediately to P2.\n** If the table or index is not empty, fall through to the following \n** instruction.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n*/\ncase OP_Rewind: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );\n  res = 1;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = OP_Rewind;\n#endif\n  if( isSorter(pC) ){\n    rc = sqlite3VdbeSorterRewind(pC, &res);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    pCrsr = pC->uc.pCursor;\n    assert( pCrsr );\n    rc = sqlite3BtreeFirst(pCrsr, &res);\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc ) goto abort_due_to_error;\n  pC->nullRow = (u8)res;\n  assert( pOp->p2>0 && pOp->p2<p->nOp );\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Next P1 P2 P3 P4 P5\n**\n** Advance cursor P1 so that it points to the next key/data pair in its\n** table or index.  If there are no more key/value pairs then fall through\n** to the following instruction.  But if the cursor advance was successful,\n** jump immediately to P2.\n**\n** The Next opcode is only valid following an SeekGT, SeekGE, or\n** OP_Rewind opcode used to position the cursor.  Next is not allowed\n** to follow SeekLT, SeekLE, or OP_Last.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  P1 must have\n** been opened prior to this opcode or the program will segfault.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreeNext().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n**\n** See also: Prev, NextIfOpen\n*/\n/* Opcode: NextIfOpen P1 P2 P3 P4 P5\n**\n** This opcode works just like Next except that if cursor P1 is not\n** open it behaves a no-op.\n*/\n/* Opcode: Prev P1 P2 P3 P4 P5\n**\n** Back up cursor P1 so that it points to the previous key/data pair in its\n** table or index.  If there is no previous key/value pairs then fall through\n** to the following instruction.  But if the cursor backup was successful,\n** jump immediately to P2.\n**\n**\n** The Prev opcode is only valid following an SeekLT, SeekLE, or\n** OP_Last opcode used to position the cursor.  Prev is not allowed\n** to follow SeekGT, SeekGE, or OP_Rewind.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  If P1 is\n** not open then the behavior is undefined.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreePrevious().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n*/\n/* Opcode: PrevIfOpen P1 P2 P3 P4 P5\n**\n** This opcode works just like Prev except that if cursor P1 is not\n** open it behaves a no-op.\n*/\n/* Opcode: SorterNext P1 P2 * * P5\n**\n** This opcode works just like OP_Next except that P1 must be a\n** sorter object for which the OP_SorterSort opcode has been\n** invoked.  This opcode advances the cursor to the next sorted\n** record, or jumps to P2 if there are no more sorted records.\n*/\ncase OP_SorterNext: {  /* jump */\n  VdbeCursor *pC;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterNext(db, pC);\n  goto next_tail;\ncase OP_PrevIfOpen:    /* jump */\ncase OP_NextIfOpen:    /* jump */\n  if( p->apCsr[pOp->p1]==0 ) break;\n  /* Fall through */\ncase OP_Prev:          /* jump */\ncase OP_Next:          /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p5<ArraySize(p->aCounter) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->deferredMoveto==0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );\n  assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );\n  assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );\n  assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);\n\n  /* The Next opcode is only used after SeekGT, SeekGE, and Rewind.\n  ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */\n  assert( pOp->opcode!=OP_Next || pOp->opcode!=OP_NextIfOpen\n       || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE\n       || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);\n  assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen\n       || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE\n       || pC->seekOp==OP_Last );\n\n  rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);\nnext_tail:\n  pC->cacheStatus = CACHE_STALE;\n  VdbeBranchTaken(rc==SQLITE_OK,2);\n  if( rc==SQLITE_OK ){\n    pC->nullRow = 0;\n    p->aCounter[pOp->p5]++;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n  rc = SQLITE_OK;\n  pC->nullRow = 1;\n  goto check_for_interrupt;\n}\n\n/* Opcode: IdxInsert P1 P2 P3 P4 P5\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the index P1.  Data for the entry is nil.\n**\n** If P4 is not zero, then it is the number of values in the unpacked\n** key of reg(P2).  In that case, P3 is the index of the first register\n** for the unpacked key.  The availability of the unpacked key can sometimes\n** be an optimization.\n**\n** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer\n** that this insert is likely to be an append.\n**\n** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is\n** incremented by this instruction.  If the OPFLAG_NCHANGE bit is clear,\n** then the change counter is unchanged.\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equivalent\n** to P2. \n**\n** This instruction only works for indices.  The equivalent instruction\n** for tables is OP_Insert.\n*/\n/* Opcode: SorterInsert P1 P2 * * *\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the sorter P1.  Data for the entry is nil.\n*/\ncase OP_SorterInsert:       /* in2 */\ncase OP_IdxInsert: {        /* in2 */\n  VdbeCursor *pC;\n  BtreePayload x;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );\n  pIn2 = &aMem[pOp->p2];\n  assert( pIn2->flags & MEM_Blob );\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  assert( pC->eCurType==CURTYPE_BTREE || pOp->opcode==OP_SorterInsert );\n  assert( pC->isTable==0 );\n  rc = ExpandBlob(pIn2);\n  if( rc ) goto abort_due_to_error;\n  if( pOp->opcode==OP_SorterInsert ){\n    rc = sqlite3VdbeSorterWrite(pC, pIn2);\n  }else{\n    x.nKey = pIn2->n;\n    x.pKey = pIn2->z;\n    x.aMem = aMem + pOp->p3;\n    x.nMem = (u16)pOp->p4.i;\n    rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n         (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), \n        ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)\n        );\n    assert( pC->deferredMoveto==0 );\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: IdxDelete P1 P2 P3 * *\n** Synopsis: key=r[P2@P3]\n**\n** The content of P3 registers starting at register P2 form\n** an unpacked index key. This opcode removes that entry from the \n** index opened by cursor P1.\n*/\ncase OP_IdxDelete: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p3>0 );\n  assert( pOp->p2>0 && pOp->p2+pOp->p3<=(p->nMem+1 - p->nCursor)+1 );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  assert( pOp->p5==0 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p3;\n  r.default_rc = 0;\n  r.aMem = &aMem[pOp->p2];\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);\n    if( rc ) goto abort_due_to_error;\n  }\n  assert( pC->deferredMoveto==0 );\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  break;\n}\n\n/* Opcode: DeferredSeek P1 * P3 P4 *\n** Synopsis: Move P3 to P1.rowid if needed\n**\n** P1 is an open index cursor and P3 is a cursor on the corresponding\n** table.  This opcode does a deferred seek of the P3 table cursor\n** to the row that corresponds to the current row of P1.\n**\n** This is a deferred seek.  Nothing actually happens until\n** the cursor is used to read a record.  That way, if no reads\n** occur, no unnecessary I/O happens.\n**\n** P4 may be an array of integers (type P4_INTARRAY) containing\n** one entry for each column in the P3 table.  If array entry a(i)\n** is non-zero, then reading column a(i)-1 from cursor P3 is \n** equivalent to performing the deferred seek and then reading column i \n** from P1.  This information is stored in P3 and used to redirect\n** reads against P3 over to P1, thus possibly avoiding the need to\n** seek and read cursor P3.\n*/\n/* Opcode: IdxRowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Write into register P2 an integer which is the last entry in the record at\n** the end of the index key pointed to by cursor P1.  This integer should be\n** the rowid of the table entry to which this index entry points.\n**\n** See also: Rowid, MakeRecord.\n*/\ncase OP_DeferredSeek:\ncase OP_IdxRowid: {           /* out2 */\n  VdbeCursor *pC;             /* The P1 index cursor */\n  VdbeCursor *pTabCur;        /* The P2 table cursor (OP_DeferredSeek only) */\n  i64 rowid;                  /* Rowid that P1 current points to */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  assert( pC->deferredMoveto==0 );\n  assert( !pC->nullRow || pOp->opcode==OP_IdxRowid );\n\n  /* The IdxRowid and Seek opcodes are combined because of the commonality\n  ** of sqlite3VdbeCursorRestore() and sqlite3VdbeIdxRowid(). */\n  rc = sqlite3VdbeCursorRestore(pC);\n\n  /* sqlite3VbeCursorRestore() can only fail if the record has been deleted\n  ** out from under the cursor.  That will never happens for an IdxRowid\n  ** or Seek opcode */\n  if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;\n\n  if( !pC->nullRow ){\n    rowid = 0;  /* Not needed.  Only used to silence a warning. */\n    rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( pOp->opcode==OP_DeferredSeek ){\n      assert( pOp->p3>=0 && pOp->p3<p->nCursor );\n      pTabCur = p->apCsr[pOp->p3];\n      assert( pTabCur!=0 );\n      assert( pTabCur->eCurType==CURTYPE_BTREE );\n      assert( pTabCur->uc.pCursor!=0 );\n      assert( pTabCur->isTable );\n      pTabCur->nullRow = 0;\n      pTabCur->movetoTarget = rowid;\n      pTabCur->deferredMoveto = 1;\n      assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );\n      pTabCur->aAltMap = pOp->p4.ai;\n      pTabCur->pAltCursor = pC;\n    }else{\n      pOut = out2Prerelease(p, pOp);\n      pOut->u.i = rowid;\n    }\n  }else{\n    assert( pOp->opcode==OP_IdxRowid );\n    sqlite3VdbeMemSetNull(&aMem[pOp->p2]);\n  }\n  break;\n}\n\n/* Opcode: IdxGE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than or equal to the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxGT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than the key value then jump to P2.\n** Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than or equal to the key value then jump\n** to P2. Otherwise fall through to the next instruction.\n*/\ncase OP_IdxLE:          /* jump */\ncase OP_IdxGT:          /* jump */\ncase OP_IdxLT:          /* jump */\ncase OP_IdxGE:  {       /* jump */\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->isOrdered );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0);\n  assert( pC->deferredMoveto==0 );\n  assert( pOp->p5==0 || pOp->p5==1 );\n  assert( pOp->p4type==P4_INT32 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p4.i;\n  if( pOp->opcode<OP_IdxLT ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxGT );\n    r.default_rc = -1;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxLT );\n    r.default_rc = 0;\n  }\n  r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n  { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }\n#endif\n  res = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);\n  assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );\n  if( (pOp->opcode&1)==(OP_IdxLT&1) ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );\n    res = -res;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );\n    res++;\n  }\n  VdbeBranchTaken(res>0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res>0 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Destroy P1 P2 P3 * *\n**\n** Delete an entire database table or index whose root page in the database\n** file is given by P1.\n**\n** The table being destroyed is in the main database file if P3==0.  If\n** P3==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If AUTOVACUUM is enabled then it is possible that another root page\n** might be moved into the newly deleted root page in order to keep all\n** root pages contiguous at the beginning of the database.  The former\n** value of the root page that moved - its value before the move occurred -\n** is stored in register P2. If no page movement was required (because the\n** table being dropped was already the last one in the database) then a \n** zero is stored in register P2.  If AUTOVACUUM is disabled then a zero \n** is stored in register P2.\n**\n** This opcode throws an error if there are any active reader VMs when\n** it is invoked. This is done to avoid the difficulty associated with \n** updating existing cursors when a root page is moved in an AUTOVACUUM \n** database. This error is thrown even if the database is not an AUTOVACUUM \n** db in order to avoid introducing an incompatibility between autovacuum \n** and non-autovacuum modes.\n**\n** See also: Clear\n*/\ncase OP_Destroy: {     /* out2 */\n  int iMoved;\n  int iDb;\n\n  assert( p->readOnly==0 );\n  assert( pOp->p1>1 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Null;\n  if( db->nVdbeRead > db->nVDestroy+1 ){\n    rc = SQLITE_LOCKED;\n    p->errorAction = OE_Abort;\n    goto abort_due_to_error;\n  }else{\n    iDb = pOp->p3;\n    assert( DbMaskTest(p->btreeMask, iDb) );\n    iMoved = 0;  /* Not needed.  Only to silence a warning. */\n    rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);\n    pOut->flags = MEM_Int;\n    pOut->u.i = iMoved;\n    if( rc ) goto abort_due_to_error;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( iMoved!=0 ){\n      sqlite3RootPageMoved(db, iDb, iMoved, pOp->p1);\n      /* All OP_Destroy operations occur on the same btree */\n      assert( resetSchemaOnFault==0 || resetSchemaOnFault==iDb+1 );\n      resetSchemaOnFault = iDb+1;\n    }\n#endif\n  }\n  break;\n}\n\n/* Opcode: Clear P1 P2 P3\n**\n** Delete all contents of the database table or index whose root page\n** in the database file is given by P1.  But, unlike Destroy, do not\n** remove the table or index from the database file.\n**\n** The table being clear is in the main database file if P2==0.  If\n** P2==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If the P3 value is non-zero, then the table referred to must be an\n** intkey table (an SQL table, not an index). In this case the row change \n** count is incremented by the number of rows in the table being cleared. \n** If P3 is greater than zero, then the value stored in register P3 is\n** also incremented by the number of rows in the table being cleared.\n**\n** See also: Destroy\n*/\ncase OP_Clear: {\n  int nChange;\n \n  nChange = 0;\n  assert( p->readOnly==0 );\n  assert( DbMaskTest(p->btreeMask, pOp->p2) );\n  rc = sqlite3BtreeClearTable(\n      db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0)\n  );\n  if( pOp->p3 ){\n    p->nChange += nChange;\n    if( pOp->p3>0 ){\n      assert( memIsValid(&aMem[pOp->p3]) );\n      memAboutToChange(p, &aMem[pOp->p3]);\n      aMem[pOp->p3].u.i += nChange;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ResetSorter P1 * * * *\n**\n** Delete all contents from the ephemeral table or sorter\n** that is open on cursor P1.\n**\n** This opcode only works for cursors used for sorting and\n** opened with OP_OpenEphemeral or OP_SorterOpen.\n*/\ncase OP_ResetSorter: {\n  VdbeCursor *pC;\n \n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  if( isSorter(pC) ){\n    sqlite3VdbeSorterReset(db, pC->uc.pSorter);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->isEphemeral );\n    rc = sqlite3BtreeClearTableOfCursor(pC->uc.pCursor);\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: CreateBtree P1 P2 P3 * *\n** Synopsis: r[P2]=root iDb=P1 flags=P3\n**\n** Allocate a new b-tree in the main database file if P1==0 or in the\n** TEMP database file if P1==1 or in an attached database if\n** P1>1.  The P3 argument must be 1 (BTREE_INTKEY) for a rowid table\n** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.\n** The root page number of the new b-tree is stored in register P2.\n*/\ncase OP_CreateBtree: {          /* out2 */\n  int pgno;\n  Db *pDb;\n\n  pOut = out2Prerelease(p, pOp);\n  pgno = 0;\n  assert( pOp->p3==BTREE_INTKEY || pOp->p3==BTREE_BLOBKEY );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, pOp->p3);\n  if( rc ) goto abort_due_to_error;\n  pOut->u.i = pgno;\n  break;\n}\n\n/* Opcode: SqlExec * * * P4 *\n**\n** Run the SQL statement or statements specified in the P4 string.\n*/\ncase OP_SqlExec: {\n  db->nSqlExec++;\n  rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);\n  db->nSqlExec--;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ParseSchema P1 * * P4 *\n**\n** Read and parse all entries from the SQLITE_MASTER table of database P1\n** that match the WHERE clause P4. \n**\n** This opcode invokes the parser to create a new virtual machine,\n** then runs the new virtual machine.  It is thus a re-entrant opcode.\n*/\ncase OP_ParseSchema: {\n  int iDb;\n  const char *zMaster;\n  char *zSql;\n  InitData initData;\n\n  /* Any prepared statement that invokes this opcode will hold mutexes\n  ** on every btree.  This is a prerequisite for invoking \n  ** sqlite3InitCallback().\n  */\n#ifdef SQLITE_DEBUG\n  for(iDb=0; iDb<db->nDb; iDb++){\n    assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n  }\n#endif\n\n  iDb = pOp->p1;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );\n  /* Used to be a conditional */ {\n    zMaster = MASTER_NAME;\n    initData.db = db;\n    initData.iDb = pOp->p1;\n    initData.pzErrMsg = &p->zErrMsg;\n    zSql = sqlite3MPrintf(db,\n       \"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid\",\n       db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      assert( db->init.busy==0 );\n      db->init.busy = 1;\n      initData.rc = SQLITE_OK;\n      assert( !db->mallocFailed );\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n      if( rc==SQLITE_OK ) rc = initData.rc;\n      sqlite3DbFreeNN(db, zSql);\n      db->init.busy = 0;\n    }\n  }\n  if( rc ){\n    sqlite3ResetAllSchemasOfConnection(db);\n    if( rc==SQLITE_NOMEM ){\n      goto no_mem;\n    }\n    goto abort_due_to_error;\n  }\n  break;  \n}\n\n#if !defined(SQLITE_OMIT_ANALYZE)\n/* Opcode: LoadAnalysis P1 * * * *\n**\n** Read the sqlite_stat1 table for database P1 and load the content\n** of that table into the internal index hash table.  This will cause\n** the analysis to be used when preparing all subsequent queries.\n*/\ncase OP_LoadAnalysis: {\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  rc = sqlite3AnalysisLoad(db, pOp->p1);\n  if( rc ) goto abort_due_to_error;\n  break;  \n}\n#endif /* !defined(SQLITE_OMIT_ANALYZE) */\n\n/* Opcode: DropTable P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the table named P4 in database P1.  This is called after a table\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTable: {\n  sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropIndex P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the index named P4 in database P1.  This is called after an index\n** is dropped from disk (using the Destroy opcode)\n** in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropIndex: {\n  sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropTrigger P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the trigger named P4 in database P1.  This is called after a trigger\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTrigger: {\n  sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/* Opcode: IntegrityCk P1 P2 P3 P4 P5\n**\n** Do an analysis of the currently open database.  Store in\n** register P1 the text of an error message describing any problems.\n** If no problems are found, store a NULL in register P1.\n**\n** The register P3 contains one less than the maximum number of allowed errors.\n** At most reg(P3) errors will be reported.\n** In other words, the analysis stops as soon as reg(P1) errors are \n** seen.  Reg(P1) is updated with the number of errors remaining.\n**\n** The root page numbers of all tables in the database are integers\n** stored in P4_INTARRAY argument.\n**\n** If P5 is not zero, the check is done on the auxiliary database\n** file, not the main database file.\n**\n** This opcode is used to implement the integrity_check pragma.\n*/\ncase OP_IntegrityCk: {\n  int nRoot;      /* Number of tables to check.  (Number of root pages.) */\n  int *aRoot;     /* Array of rootpage numbers for tables to be checked */\n  int nErr;       /* Number of errors reported */\n  char *z;        /* Text of the error report */\n  Mem *pnErr;     /* Register keeping track of errors remaining */\n\n  assert( p->bIsReader );\n  nRoot = pOp->p2;\n  aRoot = pOp->p4.ai;\n  assert( nRoot>0 );\n  assert( aRoot[0]==nRoot );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pnErr = &aMem[pOp->p3];\n  assert( (pnErr->flags & MEM_Int)!=0 );\n  assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );\n  pIn1 = &aMem[pOp->p1];\n  assert( pOp->p5<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p5) );\n  z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,\n                                 (int)pnErr->u.i+1, &nErr);\n  sqlite3VdbeMemSetNull(pIn1);\n  if( nErr==0 ){\n    assert( z==0 );\n  }else if( z==0 ){\n    goto no_mem;\n  }else{\n    pnErr->u.i -= nErr-1;\n    sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);\n  }\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  sqlite3VdbeChangeEncoding(pIn1, encoding);\n  break;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/* Opcode: RowSetAdd P1 P2 * * *\n** Synopsis: rowset(P1)=r[P2]\n**\n** Insert the integer value held by register P2 into a RowSet object\n** held in register P1.\n**\n** An assertion fails if P2 is not an integer.\n*/\ncase OP_RowSetAdd: {       /* in1, in2 */\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  assert( (pIn2->flags & MEM_Int)!=0 );\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n  sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);\n  break;\n}\n\n/* Opcode: RowSetRead P1 P2 P3 * *\n** Synopsis: r[P3]=rowset(P1)\n**\n** Extract the smallest value from the RowSet object in P1\n** and put that value into register P3.\n** Or, if RowSet object P1 is initially empty, leave P3\n** unchanged and jump to instruction P2.\n*/\ncase OP_RowSetRead: {       /* jump, in1, out3 */\n  i64 val;\n\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_RowSet)==0 \n   || sqlite3RowSetNext(pIn1->u.pRowSet, &val)==0\n  ){\n    /* The boolean index is empty */\n    sqlite3VdbeMemSetNull(pIn1);\n    VdbeBranchTaken(1,2);\n    goto jump_to_p2_and_check_for_interrupt;\n  }else{\n    /* A value was pulled from the index */\n    VdbeBranchTaken(0,2);\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);\n  }\n  goto check_for_interrupt;\n}\n\n/* Opcode: RowSetTest P1 P2 P3 P4\n** Synopsis: if r[P3] in rowset(P1) goto P2\n**\n** Register P3 is assumed to hold a 64-bit integer value. If register P1\n** contains a RowSet object and that RowSet object contains\n** the value held in P3, jump to register P2. Otherwise, insert the\n** integer in P3 into the RowSet and continue on to the\n** next opcode.\n**\n** The RowSet object is optimized for the case where sets of integers\n** are inserted in distinct phases, which each set contains no duplicates.\n** Each set is identified by a unique P4 value. The first set\n** must have P4==0, the final set must have P4==-1, and for all other sets\n** must have P4>0.\n**\n** This allows optimizations: (a) when P4==0 there is no need to test\n** the RowSet object for P3, as it is guaranteed not to contain it,\n** (b) when P4==-1 there is no need to insert the value, as it will\n** never be tested for, and (c) when a value that is part of set X is\n** inserted, there is no need to search to see if the same value was\n** previously inserted as part of set X (only if it was previously\n** inserted as part of some other set).\n*/\ncase OP_RowSetTest: {                     /* jump, in1, in3 */\n  int iSet;\n  int exists;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  iSet = pOp->p4.i;\n  assert( pIn3->flags&MEM_Int );\n\n  /* If there is anything other than a rowset object in memory cell P1,\n  ** delete it now and initialize P1 with an empty rowset\n  */\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n\n  assert( pOp->p4type==P4_INT32 );\n  assert( iSet==-1 || iSet>=0 );\n  if( iSet ){\n    exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i);\n    VdbeBranchTaken(exists!=0,2);\n    if( exists ) goto jump_to_p2;\n  }\n  if( iSet>=0 ){\n    sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);\n  }\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_TRIGGER\n\n/* Opcode: Program P1 P2 P3 P4 P5\n**\n** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). \n**\n** P1 contains the address of the memory cell that contains the first memory \n** cell in an array of values used as arguments to the sub-program. P2 \n** contains the address to jump to if the sub-program throws an IGNORE \n** exception using the RAISE() function. Register P3 contains the address \n** of a memory cell in this (the parent) VM that is used to allocate the \n** memory required by the sub-vdbe at runtime.\n**\n** P4 is a pointer to the VM containing the trigger program.\n**\n** If P5 is non-zero, then recursive program invocation is enabled.\n*/\ncase OP_Program: {        /* jump */\n  int nMem;               /* Number of memory registers for sub-program */\n  int nByte;              /* Bytes of runtime space required for sub-program */\n  Mem *pRt;               /* Register to allocate runtime space */\n  Mem *pMem;              /* Used to iterate through memory cells */\n  Mem *pEnd;              /* Last memory cell in new array */\n  VdbeFrame *pFrame;      /* New vdbe frame to execute in */\n  SubProgram *pProgram;   /* Sub-program to execute */\n  void *t;                /* Token identifying trigger */\n\n  pProgram = pOp->p4.pProgram;\n  pRt = &aMem[pOp->p3];\n  assert( pProgram->nOp>0 );\n  \n  /* If the p5 flag is clear, then recursive invocation of triggers is \n  ** disabled for backwards compatibility (p5 is set if this sub-program\n  ** is really a trigger, not a foreign key action, and the flag set\n  ** and cleared by the \"PRAGMA recursive_triggers\" command is clear).\n  ** \n  ** It is recursive invocation of triggers, at the SQL level, that is \n  ** disabled. In some cases a single trigger may generate more than one \n  ** SubProgram (if the trigger may be executed with more than one different \n  ** ON CONFLICT algorithm). SubProgram structures associated with a\n  ** single trigger all have the same value for the SubProgram.token \n  ** variable.  */\n  if( pOp->p5 ){\n    t = pProgram->token;\n    for(pFrame=p->pFrame; pFrame && pFrame->token!=t; pFrame=pFrame->pParent);\n    if( pFrame ) break;\n  }\n\n  if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){\n    rc = SQLITE_ERROR;\n    sqlite3VdbeError(p, \"too many levels of trigger recursion\");\n    goto abort_due_to_error;\n  }\n\n  /* Register pRt is used to store the memory required to save the state\n  ** of the current program, and the memory required at runtime to execute\n  ** the trigger program. If this trigger has been fired before, then pRt \n  ** is already allocated. Otherwise, it must be initialized.  */\n  if( (pRt->flags&MEM_Frame)==0 ){\n    /* SubProgram.nMem is set to the number of memory cells used by the \n    ** program stored in SubProgram.aOp. As well as these, one memory\n    ** cell is required for each cursor used by the program. Set local\n    ** variable nMem (and later, VdbeFrame.nChildMem) to this value.\n    */\n    nMem = pProgram->nMem + pProgram->nCsr;\n    assert( nMem>0 );\n    if( pProgram->nCsr==0 ) nMem++;\n    nByte = ROUND8(sizeof(VdbeFrame))\n              + nMem * sizeof(Mem)\n              + pProgram->nCsr * sizeof(VdbeCursor*)\n              + (pProgram->nOp + 7)/8;\n    pFrame = sqlite3DbMallocZero(db, nByte);\n    if( !pFrame ){\n      goto no_mem;\n    }\n    sqlite3VdbeMemRelease(pRt);\n    pRt->flags = MEM_Frame;\n    pRt->u.pFrame = pFrame;\n\n    pFrame->v = p;\n    pFrame->nChildMem = nMem;\n    pFrame->nChildCsr = pProgram->nCsr;\n    pFrame->pc = (int)(pOp - aOp);\n    pFrame->aMem = p->aMem;\n    pFrame->nMem = p->nMem;\n    pFrame->apCsr = p->apCsr;\n    pFrame->nCursor = p->nCursor;\n    pFrame->aOp = p->aOp;\n    pFrame->nOp = p->nOp;\n    pFrame->token = pProgram->token;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    pFrame->anExec = p->anExec;\n#endif\n\n    pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];\n    for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){\n      pMem->flags = MEM_Undefined;\n      pMem->db = db;\n    }\n  }else{\n    pFrame = pRt->u.pFrame;\n    assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem \n        || (pProgram->nCsr==0 && pProgram->nMem+1==pFrame->nChildMem) );\n    assert( pProgram->nCsr==pFrame->nChildCsr );\n    assert( (int)(pOp - aOp)==pFrame->pc );\n  }\n\n  p->nFrame++;\n  pFrame->pParent = p->pFrame;\n  pFrame->lastRowid = db->lastRowid;\n  pFrame->nChange = p->nChange;\n  pFrame->nDbChange = p->db->nChange;\n  assert( pFrame->pAuxData==0 );\n  pFrame->pAuxData = p->pAuxData;\n  p->pAuxData = 0;\n  p->nChange = 0;\n  p->pFrame = pFrame;\n  p->aMem = aMem = VdbeFrameMem(pFrame);\n  p->nMem = pFrame->nChildMem;\n  p->nCursor = (u16)pFrame->nChildCsr;\n  p->apCsr = (VdbeCursor **)&aMem[p->nMem];\n  pFrame->aOnce = (u8*)&p->apCsr[pProgram->nCsr];\n  memset(pFrame->aOnce, 0, (pProgram->nOp + 7)/8);\n  p->aOp = aOp = pProgram->aOp;\n  p->nOp = pProgram->nOp;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  p->anExec = 0;\n#endif\n  pOp = &aOp[-1];\n\n  break;\n}\n\n/* Opcode: Param P1 P2 * * *\n**\n** This opcode is only ever present in sub-programs called via the \n** OP_Program instruction. Copy a value currently stored in a memory \n** cell of the calling (parent) frame to cell P2 in the current frames \n** address space. This is used by trigger programs to access the new.* \n** and old.* values.\n**\n** The address of the cell in the parent frame is determined by adding\n** the value of the P1 argument to the value of the P1 argument to the\n** calling OP_Program instruction.\n*/\ncase OP_Param: {           /* out2 */\n  VdbeFrame *pFrame;\n  Mem *pIn;\n  pOut = out2Prerelease(p, pOp);\n  pFrame = p->pFrame;\n  pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];   \n  sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);\n  break;\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRIGGER */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n/* Opcode: FkCounter P1 P2 * * *\n** Synopsis: fkctr[P1]+=P2\n**\n** Increment a \"constraint counter\" by P2 (P2 may be negative or positive).\n** If P1 is non-zero, the database constraint counter is incremented \n** (deferred foreign key constraints). Otherwise, if P1 is zero, the \n** statement counter is incremented (immediate foreign key constraints).\n*/\ncase OP_FkCounter: {\n  if( db->flags & SQLITE_DeferFKs ){\n    db->nDeferredImmCons += pOp->p2;\n  }else if( pOp->p1 ){\n    db->nDeferredCons += pOp->p2;\n  }else{\n    p->nFkConstraint += pOp->p2;\n  }\n  break;\n}\n\n/* Opcode: FkIfZero P1 P2 * * *\n** Synopsis: if fkctr[P1]==0 goto P2\n**\n** This opcode tests if a foreign key constraint-counter is currently zero.\n** If so, jump to instruction P2. Otherwise, fall through to the next \n** instruction.\n**\n** If P1 is non-zero, then the jump is taken if the database constraint-counter\n** is zero (the one that counts deferred constraint violations). If P1 is\n** zero, the jump is taken if the statement constraint-counter is zero\n** (immediate foreign key constraint violations).\n*/\ncase OP_FkIfZero: {         /* jump */\n  if( pOp->p1 ){\n    VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);\n    if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);\n    if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }\n  break;\n}\n#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/* Opcode: MemMax P1 P2 * * *\n** Synopsis: r[P1]=max(r[P1],r[P2])\n**\n** P1 is a register in the root frame of this VM (the root frame is\n** different from the current frame if this instruction is being executed\n** within a sub-program). Set the value of register P1 to the maximum of \n** its current value and the value in register P2.\n**\n** This instruction throws an error if the memory cell is not initially\n** an integer.\n*/\ncase OP_MemMax: {        /* in2 */\n  VdbeFrame *pFrame;\n  if( p->pFrame ){\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    pIn1 = &pFrame->aMem[pOp->p1];\n  }else{\n    pIn1 = &aMem[pOp->p1];\n  }\n  assert( memIsValid(pIn1) );\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  sqlite3VdbeMemIntegerify(pIn2);\n  if( pIn1->u.i<pIn2->u.i){\n    pIn1->u.i = pIn2->u.i;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n/* Opcode: IfPos P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2\n**\n** Register P1 must contain an integer.\n** If the value of register P1 is 1 or greater, subtract P3 from the\n** value in P1 and jump to P2.\n**\n** If the initial value of register P1 is less than 1, then the\n** value is unchanged and control passes through to the next instruction.\n*/\ncase OP_IfPos: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken( pIn1->u.i>0, 2);\n  if( pIn1->u.i>0 ){\n    pIn1->u.i -= pOp->p3;\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OffsetLimit P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)\n**\n** This opcode performs a commonly used computation associated with\n** LIMIT and OFFSET process.  r[P1] holds the limit counter.  r[P3]\n** holds the offset counter.  The opcode computes the combined value\n** of the LIMIT and OFFSET and stores that value in r[P2].  The r[P2]\n** value computed is the total number of rows that will need to be\n** visited in order to complete the query.\n**\n** If r[P3] is zero or negative, that means there is no OFFSET\n** and r[P2] is set to be the value of the LIMIT, r[P1].\n**\n** if r[P1] is zero or negative, that means there is no LIMIT\n** and r[P2] is set to -1. \n**\n** Otherwise, r[P2] is set to the sum of r[P1] and r[P3].\n*/\ncase OP_OffsetLimit: {    /* in1, out2, in3 */\n  i64 x;\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  pOut = out2Prerelease(p, pOp);\n  assert( pIn1->flags & MEM_Int );\n  assert( pIn3->flags & MEM_Int );\n  x = pIn1->u.i;\n  if( x<=0 || sqlite3AddInt64(&x, pIn3->u.i>0?pIn3->u.i:0) ){\n    /* If the LIMIT is less than or equal to zero, loop forever.  This\n    ** is documented.  But also, if the LIMIT+OFFSET exceeds 2^63 then\n    ** also loop forever.  This is undocumented.  In fact, one could argue\n    ** that the loop should terminate.  But assuming 1 billion iterations\n    ** per second (far exceeding the capabilities of any current hardware)\n    ** it would take nearly 300 years to actually reach the limit.  So\n    ** looping forever is a reasonable approximation. */\n    pOut->u.i = -1;\n  }else{\n    pOut->u.i = x;\n  }\n  break;\n}\n\n/* Opcode: IfNotZero P1 P2 * * *\n** Synopsis: if r[P1]!=0 then r[P1]--, goto P2\n**\n** Register P1 must contain an integer.  If the content of register P1 is\n** initially greater than zero, then decrement the value in register P1.\n** If it is non-zero (negative or positive) and then also jump to P2.  \n** If register P1 is initially zero, leave it unchanged and fall through.\n*/\ncase OP_IfNotZero: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken(pIn1->u.i<0, 2);\n  if( pIn1->u.i ){\n     if( pIn1->u.i>0 ) pIn1->u.i--;\n     goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: DecrJumpZero P1 P2 * * *\n** Synopsis: if (--r[P1])==0 goto P2\n**\n** Register P1 must hold an integer.  Decrement the value in P1\n** and jump to P2 if the new value is exactly zero.\n*/\ncase OP_DecrJumpZero: {      /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  if( pIn1->u.i>SMALLEST_INT64 ) pIn1->u.i--;\n  VdbeBranchTaken(pIn1->u.i==0, 2);\n  if( pIn1->u.i==0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: AggStep0 * P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the step function for an aggregate.  The\n** function has P5 arguments.   P4 is a pointer to the FuncDef\n** structure that specifies the function.  Register P3 is the\n** accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n*/\n/* Opcode: AggStep * P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the step function for an aggregate.  The\n** function has P5 arguments.   P4 is a pointer to an sqlite3_context\n** object that is used to run the function.  Register P3 is\n** as the accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n**\n** This opcode is initially coded as OP_AggStep0.  On first evaluation,\n** the FuncDef stored in P4 is converted into an sqlite3_context and\n** the opcode is changed.  In this way, the initialization of the\n** sqlite3_context only happens once, instead of on each call to the\n** step function.\n*/\ncase OP_AggStep0: {\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pMem = 0;\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n  pOp->opcode = OP_AggStep;\n  /* Fall through into OP_AggStep */\n}\ncase OP_AggStep: {\n  int i;\n  sqlite3_context *pCtx;\n  Mem *pMem;\n  Mem t;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n  pMem = &aMem[pOp->p3];\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  if( pCtx->pMem != pMem ){\n    pCtx->pMem = pMem;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n\n  pMem->n++;\n  sqlite3VdbeMemInit(&t, db, MEM_Null);\n  pCtx->pOut = &t;\n  pCtx->fErrorOrAux = 0;\n  pCtx->skipFlag = 0;\n  (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */\n  if( pCtx->fErrorOrAux ){\n    if( pCtx->isError ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(&t));\n      rc = pCtx->isError;\n    }\n    sqlite3VdbeMemRelease(&t);\n    if( rc ) goto abort_due_to_error;\n  }else{\n    assert( t.flags==MEM_Null );\n  }\n  if( pCtx->skipFlag ){\n    assert( pOp[-1].opcode==OP_CollSeq );\n    i = pOp[-1].p1;\n    if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1);\n  }\n  break;\n}\n\n/* Opcode: AggFinal P1 P2 * P4 *\n** Synopsis: accum=r[P1] N=P2\n**\n** Execute the finalizer function for an aggregate.  P1 is\n** the memory location that is the accumulator for the aggregate.\n**\n** P2 is the number of arguments that the step function takes and\n** P4 is a pointer to the FuncDef for this function.  The P2\n** argument is not used by this opcode.  It is only there to disambiguate\n** functions that can take varying numbers of arguments.  The\n** P4 argument is only needed for the degenerate case where\n** the step function was not previously called.\n*/\ncase OP_AggFinal: {\n  Mem *pMem;\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pMem = &aMem[pOp->p1];\n  assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );\n  rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);\n  if( rc ){\n    sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pMem));\n    goto abort_due_to_error;\n  }\n  sqlite3VdbeChangeEncoding(pMem, encoding);\n  UPDATE_MAX_BLOBSIZE(pMem);\n  if( sqlite3VdbeMemTooBig(pMem) ){\n    goto too_big;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/* Opcode: Checkpoint P1 P2 P3 * *\n**\n** Checkpoint database P1. This is a no-op if P1 is not currently in\n** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL,\n** RESTART, or TRUNCATE.  Write 1 or 0 into mem[P3] if the checkpoint returns\n** SQLITE_BUSY or not, respectively.  Write the number of pages in the\n** WAL after the checkpoint into mem[P3+1] and the number of pages\n** in the WAL that have been checkpointed after the checkpoint\n** completes into mem[P3+2].  However on an error, mem[P3+1] and\n** mem[P3+2] are initialized to -1.\n*/\ncase OP_Checkpoint: {\n  int i;                          /* Loop counter */\n  int aRes[3];                    /* Results */\n  Mem *pMem;                      /* Write results here */\n\n  assert( p->readOnly==0 );\n  aRes[0] = 0;\n  aRes[1] = aRes[2] = -1;\n  assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE\n       || pOp->p2==SQLITE_CHECKPOINT_FULL\n       || pOp->p2==SQLITE_CHECKPOINT_RESTART\n       || pOp->p2==SQLITE_CHECKPOINT_TRUNCATE\n  );\n  rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);\n  if( rc ){\n    if( rc!=SQLITE_BUSY ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    aRes[0] = 1;\n  }\n  for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){\n    sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);\n  }    \n  break;\n};  \n#endif\n\n#ifndef SQLITE_OMIT_PRAGMA\n/* Opcode: JournalMode P1 P2 P3 * *\n**\n** Change the journal mode of database P1 to P3. P3 must be one of the\n** PAGER_JOURNALMODE_XXX values. If changing between the various rollback\n** modes (delete, truncate, persist, off and memory), this is a simple\n** operation. No IO is required.\n**\n** If changing into or out of WAL mode the procedure is more complicated.\n**\n** Write a string containing the final journal-mode to register P2.\n*/\ncase OP_JournalMode: {    /* out2 */\n  Btree *pBt;                     /* Btree to change journal mode of */\n  Pager *pPager;                  /* Pager associated with pBt */\n  int eNew;                       /* New journal mode */\n  int eOld;                       /* The old journal mode */\n#ifndef SQLITE_OMIT_WAL\n  const char *zFilename;          /* Name of database file for pPager */\n#endif\n\n  pOut = out2Prerelease(p, pOp);\n  eNew = pOp->p3;\n  assert( eNew==PAGER_JOURNALMODE_DELETE \n       || eNew==PAGER_JOURNALMODE_TRUNCATE \n       || eNew==PAGER_JOURNALMODE_PERSIST \n       || eNew==PAGER_JOURNALMODE_OFF\n       || eNew==PAGER_JOURNALMODE_MEMORY\n       || eNew==PAGER_JOURNALMODE_WAL\n       || eNew==PAGER_JOURNALMODE_QUERY\n  );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( p->readOnly==0 );\n\n  pBt = db->aDb[pOp->p1].pBt;\n  pPager = sqlite3BtreePager(pBt);\n  eOld = sqlite3PagerGetJournalMode(pPager);\n  if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;\n  if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;\n\n#ifndef SQLITE_OMIT_WAL\n  zFilename = sqlite3PagerFilename(pPager, 1);\n\n  /* Do not allow a transition to journal_mode=WAL for a database\n  ** in temporary storage or if the VFS does not support shared memory \n  */\n  if( eNew==PAGER_JOURNALMODE_WAL\n   && (sqlite3Strlen30(zFilename)==0           /* Temp file */\n       || !sqlite3PagerWalSupported(pPager))   /* No shared-memory support */\n  ){\n    eNew = eOld;\n  }\n\n  if( (eNew!=eOld)\n   && (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)\n  ){\n    if( !db->autoCommit || db->nVdbeRead>1 ){\n      rc = SQLITE_ERROR;\n      sqlite3VdbeError(p,\n          \"cannot change %s wal mode from within a transaction\",\n          (eNew==PAGER_JOURNALMODE_WAL ? \"into\" : \"out of\")\n      );\n      goto abort_due_to_error;\n    }else{\n \n      if( eOld==PAGER_JOURNALMODE_WAL ){\n        /* If leaving WAL mode, close the log file. If successful, the call\n        ** to PagerCloseWal() checkpoints and deletes the write-ahead-log \n        ** file. An EXCLUSIVE lock may still be held on the database file \n        ** after a successful return. \n        */\n        rc = sqlite3PagerCloseWal(pPager, db);\n        if( rc==SQLITE_OK ){\n          sqlite3PagerSetJournalMode(pPager, eNew);\n        }\n      }else if( eOld==PAGER_JOURNALMODE_MEMORY ){\n        /* Cannot transition directly from MEMORY to WAL.  Use mode OFF\n        ** as an intermediate */\n        sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF);\n      }\n  \n      /* Open a transaction on the database file. Regardless of the journal\n      ** mode, this transaction always uses a rollback journal.\n      */\n      assert( sqlite3BtreeIsInTrans(pBt)==0 );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));\n      }\n    }\n  }\n#endif /* ifndef SQLITE_OMIT_WAL */\n\n  if( rc ) eNew = eOld;\n  eNew = sqlite3PagerSetJournalMode(pPager, eNew);\n\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = (char *)sqlite3JournalModename(eNew);\n  pOut->n = sqlite3Strlen30(pOut->z);\n  pOut->enc = SQLITE_UTF8;\n  sqlite3VdbeChangeEncoding(pOut, encoding);\n  if( rc ) goto abort_due_to_error;\n  break;\n};\n#endif /* SQLITE_OMIT_PRAGMA */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n/* Opcode: Vacuum P1 * * * *\n**\n** Vacuum the entire database P1.  P1 is 0 for \"main\", and 2 or more\n** for an attached database.  The \"temp\" database may not be vacuumed.\n*/\ncase OP_Vacuum: {\n  assert( p->readOnly==0 );\n  rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n/* Opcode: IncrVacuum P1 P2 * * *\n**\n** Perform a single step of the incremental vacuum procedure on\n** the P1 database. If the vacuum has finished, jump to instruction\n** P2. Otherwise, fall through to the next instruction.\n*/\ncase OP_IncrVacuum: {        /* jump */\n  Btree *pBt;\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pBt = db->aDb[pOp->p1].pBt;\n  rc = sqlite3BtreeIncrVacuum(pBt);\n  VdbeBranchTaken(rc==SQLITE_DONE,2);\n  if( rc ){\n    if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    goto jump_to_p2;\n  }\n  break;\n}\n#endif\n\n/* Opcode: Expire P1 * * * *\n**\n** Cause precompiled statements to expire.  When an expired statement\n** is executed using sqlite3_step() it will either automatically\n** reprepare itself (if it was originally created using sqlite3_prepare_v2())\n** or it will fail with SQLITE_SCHEMA.\n** \n** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,\n** then only the currently executing statement is expired.\n*/\ncase OP_Expire: {\n  if( !pOp->p1 ){\n    sqlite3ExpirePreparedStatements(db);\n  }else{\n    p->expired = 1;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/* Opcode: TableLock P1 P2 P3 P4 *\n** Synopsis: iDb=P1 root=P2 write=P3\n**\n** Obtain a lock on a particular table. This instruction is only used when\n** the shared-cache feature is enabled. \n**\n** P1 is the index of the database in sqlite3.aDb[] of the database\n** on which the lock is acquired.  A readlock is obtained if P3==0 or\n** a write lock if P3==1.\n**\n** P2 contains the root-page of the table to lock.\n**\n** P4 contains a pointer to the name of the table being locked. This is only\n** used to generate an error message if the lock cannot be obtained.\n*/\ncase OP_TableLock: {\n  u8 isWriteLock = (u8)pOp->p3;\n  if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){\n    int p1 = pOp->p1; \n    assert( p1>=0 && p1<db->nDb );\n    assert( DbMaskTest(p->btreeMask, p1) );\n    assert( isWriteLock==0 || isWriteLock==1 );\n    rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);\n    if( rc ){\n      if( (rc&0xFF)==SQLITE_LOCKED ){\n        const char *z = pOp->p4.z;\n        sqlite3VdbeError(p, \"database table is locked: %s\", z);\n      }\n      goto abort_due_to_error;\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VBegin * * * P4 *\n**\n** P4 may be a pointer to an sqlite3_vtab structure. If so, call the \n** xBegin method for that table.\n**\n** Also, whether or not P4 is set, check that this is not being called from\n** within a callback to a virtual table xSync() method. If it is, the error\n** code will be set to SQLITE_LOCKED.\n*/\ncase OP_VBegin: {\n  VTable *pVTab;\n  pVTab = pOp->p4.pVtab;\n  rc = sqlite3VtabBegin(db, pVTab);\n  if( pVTab ) sqlite3VtabImportErrmsg(p, pVTab->pVtab);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VCreate P1 P2 * * *\n**\n** P2 is a register that holds the name of a virtual table in database \n** P1. Call the xCreate method for that table.\n*/\ncase OP_VCreate: {\n  Mem sMem;          /* For storing the record being decoded */\n  const char *zTab;  /* Name of the virtual table */\n\n  memset(&sMem, 0, sizeof(sMem));\n  sMem.db = db;\n  /* Because P2 is always a static string, it is impossible for the\n  ** sqlite3VdbeMemCopy() to fail */\n  assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );\n  assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );\n  rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);\n  assert( rc==SQLITE_OK );\n  zTab = (const char*)sqlite3_value_text(&sMem);\n  assert( zTab || db->mallocFailed );\n  if( zTab ){\n    rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);\n  }\n  sqlite3VdbeMemRelease(&sMem);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VDestroy P1 * * P4 *\n**\n** P4 is the name of a virtual table in database P1.  Call the xDestroy method\n** of that table.\n*/\ncase OP_VDestroy: {\n  db->nVDestroy++;\n  rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);\n  db->nVDestroy--;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VOpen P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** P1 is a cursor number.  This opcode opens a cursor to the virtual\n** table and stores that cursor in P1.\n*/\ncase OP_VOpen: {\n  VdbeCursor *pCur;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  assert( p->bIsReader );\n  pCur = 0;\n  pVCur = 0;\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  rc = pModule->xOpen(pVtab, &pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n\n  /* Initialize sqlite3_vtab_cursor base class */\n  pVCur->pVtab = pVtab;\n\n  /* Initialize vdbe cursor object */\n  pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);\n  if( pCur ){\n    pCur->uc.pVCur = pVCur;\n    pVtab->nRef++;\n  }else{\n    assert( db->mallocFailed );\n    pModule->xClose(pVCur);\n    goto no_mem;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VFilter P1 P2 P3 P4 *\n** Synopsis: iplan=r[P3] zplan='P4'\n**\n** P1 is a cursor opened using VOpen.  P2 is an address to jump to if\n** the filtered result set is empty.\n**\n** P4 is either NULL or a string that was generated by the xBestIndex\n** method of the module.  The interpretation of the P4 string is left\n** to the module implementation.\n**\n** This opcode invokes the xFilter method on the virtual table specified\n** by P1.  The integer query plan parameter to xFilter is stored in register\n** P3. Register P3+1 stores the argc parameter to be passed to the\n** xFilter method. Registers P3+2..P3+1+argc are the argc\n** additional parameters which are passed to\n** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter.\n**\n** A jump is made to P2 if the result set after filtering would be empty.\n*/\ncase OP_VFilter: {   /* jump */\n  int nArg;\n  int iQuery;\n  const sqlite3_module *pModule;\n  Mem *pQuery;\n  Mem *pArgc;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  VdbeCursor *pCur;\n  int res;\n  int i;\n  Mem **apArg;\n\n  pQuery = &aMem[pOp->p3];\n  pArgc = &pQuery[1];\n  pCur = p->apCsr[pOp->p1];\n  assert( memIsValid(pQuery) );\n  REGISTER_TRACE(pOp->p3, pQuery);\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  pVCur = pCur->uc.pVCur;\n  pVtab = pVCur->pVtab;\n  pModule = pVtab->pModule;\n\n  /* Grab the index number and argc parameters */\n  assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );\n  nArg = (int)pArgc->u.i;\n  iQuery = (int)pQuery->u.i;\n\n  /* Invoke the xFilter method */\n  res = 0;\n  apArg = p->apArg;\n  for(i = 0; i<nArg; i++){\n    apArg[i] = &pArgc[i+1];\n  }\n  rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pVCur);\n  pCur->nullRow = 0;\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VColumn P1 P2 P3 * *\n** Synopsis: r[P3]=vcolumn(P2)\n**\n** Store the value of the P2-th column of\n** the row of the virtual-table that the \n** P1 cursor is pointing to into register P3.\n*/\ncase OP_VColumn: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  Mem *pDest;\n  sqlite3_context sContext;\n\n  VdbeCursor *pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  if( pCur->nullRow ){\n    sqlite3VdbeMemSetNull(pDest);\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xColumn );\n  memset(&sContext, 0, sizeof(sContext));\n  sContext.pOut = pDest;\n  MemSetTypeFlag(pDest, MEM_Null);\n  rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( sContext.isError ){\n    rc = sContext.isError;\n  }\n  sqlite3VdbeChangeEncoding(pDest, encoding);\n  REGISTER_TRACE(pOp->p3, pDest);\n  UPDATE_MAX_BLOBSIZE(pDest);\n\n  if( sqlite3VdbeMemTooBig(pDest) ){\n    goto too_big;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VNext P1 P2 * * *\n**\n** Advance virtual table P1 to the next row in its result set and\n** jump to instruction P2.  Or, if the virtual table has reached\n** the end of its result set, then fall through to the next instruction.\n*/\ncase OP_VNext: {   /* jump */\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int res;\n  VdbeCursor *pCur;\n\n  res = 0;\n  pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  if( pCur->nullRow ){\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xNext );\n\n  /* Invoke the xNext() method of the module. There is no way for the\n  ** underlying implementation to return an error if one occurs during\n  ** xNext(). Instead, if an error occurs, true is returned (indicating that \n  ** data is available) and the error code returned when xColumn or\n  ** some other method is next invoked on the save virtual table cursor.\n  */\n  rc = pModule->xNext(pCur->uc.pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pCur->uc.pVCur);\n  VdbeBranchTaken(!res,2);\n  if( !res ){\n    /* If there is data, jump to P2 */\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  goto check_for_interrupt;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VRename P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xRename method. The value\n** in register P1 is passed as the zName argument to the xRename method.\n*/\ncase OP_VRename: {\n  sqlite3_vtab *pVtab;\n  Mem *pName;\n\n  pVtab = pOp->p4.pVtab->pVtab;\n  pName = &aMem[pOp->p1];\n  assert( pVtab->pModule->xRename );\n  assert( memIsValid(pName) );\n  assert( p->readOnly==0 );\n  REGISTER_TRACE(pOp->p1, pName);\n  assert( pName->flags & MEM_Str );\n  testcase( pName->enc==SQLITE_UTF8 );\n  testcase( pName->enc==SQLITE_UTF16BE );\n  testcase( pName->enc==SQLITE_UTF16LE );\n  rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);\n  if( rc ) goto abort_due_to_error;\n  rc = pVtab->pModule->xRename(pVtab, pName->z);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  p->expired = 0;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VUpdate P1 P2 P3 P4 P5\n** Synopsis: data=r[P3@P2]\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xUpdate method. P2 values\n** are contiguous memory cells starting at P3 to pass to the xUpdate \n** invocation. The value in register (P3+P2-1) corresponds to the \n** p2th element of the argv array passed to xUpdate.\n**\n** The xUpdate method will do a DELETE or an INSERT or both.\n** The argv[0] element (which corresponds to memory cell P3)\n** is the rowid of a row to delete.  If argv[0] is NULL then no \n** deletion occurs.  The argv[1] element is the rowid of the new \n** row.  This can be NULL to have the virtual table select the new \n** rowid for itself.  The subsequent elements in the array are \n** the values of columns in the new row.\n**\n** If P2==1 then no insert is performed.  argv[0] is the rowid of\n** a row to delete.\n**\n** P1 is a boolean flag. If it is set to true and the xUpdate call\n** is successful, then the value returned by sqlite3_last_insert_rowid() \n** is set to the value of the rowid for the row just inserted.\n**\n** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to\n** apply in the case of a constraint failure on an insert or update.\n*/\ncase OP_VUpdate: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int nArg;\n  int i;\n  sqlite_int64 rowid;\n  Mem **apArg;\n  Mem *pX;\n\n  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback \n       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace\n  );\n  assert( p->readOnly==0 );\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  nArg = pOp->p2;\n  assert( pOp->p4type==P4_VTAB );\n  if( ALWAYS(pModule->xUpdate) ){\n    u8 vtabOnConflict = db->vtabOnConflict;\n    apArg = p->apArg;\n    pX = &aMem[pOp->p3];\n    for(i=0; i<nArg; i++){\n      assert( memIsValid(pX) );\n      memAboutToChange(p, pX);\n      apArg[i] = pX;\n      pX++;\n    }\n    db->vtabOnConflict = pOp->p5;\n    rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);\n    db->vtabOnConflict = vtabOnConflict;\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc==SQLITE_OK && pOp->p1 ){\n      assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );\n      db->lastRowid = rowid;\n    }\n    if( (rc&0xff)==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){\n      if( pOp->p5==OE_Ignore ){\n        rc = SQLITE_OK;\n      }else{\n        p->errorAction = ((pOp->p5==OE_Replace) ? OE_Abort : pOp->p5);\n      }\n    }else{\n      p->nChange++;\n    }\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: Pagecount P1 P2 * * *\n**\n** Write the current number of pages in database P1 to memory cell P2.\n*/\ncase OP_Pagecount: {            /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);\n  break;\n}\n#endif\n\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: MaxPgcnt P1 P2 P3 * *\n**\n** Try to set the maximum page count for database P1 to the value in P3.\n** Do not let the maximum page count fall below the current page count and\n** do not change the maximum page count value if P3==0.\n**\n** Store the maximum page count after the change in register P2.\n*/\ncase OP_MaxPgcnt: {            /* out2 */\n  unsigned int newMax;\n  Btree *pBt;\n\n  pOut = out2Prerelease(p, pOp);\n  pBt = db->aDb[pOp->p1].pBt;\n  newMax = 0;\n  if( pOp->p3 ){\n    newMax = sqlite3BtreeLastPage(pBt);\n    if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;\n  }\n  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);\n  break;\n}\n#endif\n\n/* Opcode: Function0 P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to a FuncDef object that\n** defines the function) with P5 arguments taken from register P2 and\n** successors.  The result of the function is stored in register P3.\n** Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** See also: Function, AggStep, AggFinal\n*/\n/* Opcode: Function P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to an sqlite3_context object that\n** contains a pointer to the function to be run) with P5 arguments taken\n** from register P2 and successors.  The result of the function is stored\n** in register P3.  Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** SQL functions are initially coded as OP_Function0 with P4 pointing\n** to a FuncDef object.  But on first evaluation, the P4 operand is\n** automatically converted into an sqlite3_context object and the operation\n** changed to this OP_Function opcode.  In this way, the initialization of\n** the sqlite3_context object occurs only once, rather than once for each\n** evaluation of the function.\n**\n** See also: Function0, AggStep, AggFinal\n*/\ncase OP_PureFunc0:\ncase OP_Function0: {\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pOut = 0;\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n  assert( OP_PureFunc == OP_PureFunc0+2 );\n  assert( OP_Function == OP_Function0+2 );\n  pOp->opcode += 2;\n  /* Fall through into OP_Function */\n}\ncase OP_PureFunc:\ncase OP_Function: {\n  int i;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  pOut = &aMem[pOp->p3];\n  if( pCtx->pOut != pOut ){\n    pCtx->pOut = pOut;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n  memAboutToChange(p, pOut);\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n  MemSetTypeFlag(pOut, MEM_Null);\n  pCtx->fErrorOrAux = 0;\n  (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */\n\n  /* If the function returned an error, throw an exception */\n  if( pCtx->fErrorOrAux ){\n    if( pCtx->isError ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pOut));\n      rc = pCtx->isError;\n    }\n    sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);\n    if( rc ) goto abort_due_to_error;\n  }\n\n  /* Copy the result of the function into register P3 */\n  if( pOut->flags & (MEM_Str|MEM_Blob) ){\n    sqlite3VdbeChangeEncoding(pOut, encoding);\n    if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;\n  }\n\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n\n/* Opcode: Init P1 P2 P3 P4 *\n** Synopsis: Start at P2\n**\n** Programs contain a single instance of this opcode as the very first\n** opcode.\n**\n** If tracing is enabled (by the sqlite3_trace()) interface, then\n** the UTF-8 string contained in P4 is emitted on the trace callback.\n** Or if P4 is blank, use the string returned by sqlite3_sql().\n**\n** If P2 is not zero, jump to instruction P2.\n**\n** Increment the value of P1 so that OP_Once opcodes will jump the\n** first time they are evaluated for this run.\n**\n** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT\n** error is encountered.\n*/\ncase OP_Init: {          /* jump */\n  char *zTrace;\n  int i;\n\n  /* If the P4 argument is not NULL, then it must be an SQL comment string.\n  ** The \"--\" string is broken up to prevent false-positives with srcck1.c.\n  **\n  ** This assert() provides evidence for:\n  ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that\n  ** would have been returned by the legacy sqlite3_trace() interface by\n  ** using the X argument when X begins with \"--\" and invoking\n  ** sqlite3_expanded_sql(P) otherwise.\n  */\n  assert( pOp->p4.z==0 || strncmp(pOp->p4.z, \"-\" \"- \", 3)==0 );\n  assert( pOp==p->aOp );  /* Always instruction 0 */\n\n#ifndef SQLITE_OMIT_TRACE\n  if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0\n   && !p->doingRerun\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    if( db->mTrace & SQLITE_TRACE_LEGACY ){\n      void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;\n      char *z = sqlite3VdbeExpandSql(p, zTrace);\n      x(db->pTraceArg, z);\n      sqlite3_free(z);\n    }else\n#endif\n    if( db->nVdbeExec>1 ){\n      char *z = sqlite3MPrintf(db, \"-- %s\", zTrace);\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, z);\n      sqlite3DbFree(db, z);\n    }else{\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);\n    }\n  }\n#ifdef SQLITE_USE_FCNTL_TRACE\n  zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);\n  if( zTrace ){\n    int j;\n    for(j=0; j<db->nDb; j++){\n      if( DbMaskTest(p->btreeMask, j)==0 ) continue;\n      sqlite3_file_control(db, db->aDb[j].zDbSName, SQLITE_FCNTL_TRACE, zTrace);\n    }\n  }\n#endif /* SQLITE_USE_FCNTL_TRACE */\n#ifdef SQLITE_DEBUG\n  if( (db->flags & SQLITE_SqlTrace)!=0\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n    sqlite3DebugPrintf(\"SQL-trace: %s\\n\", zTrace);\n  }\n#endif /* SQLITE_DEBUG */\n#endif /* SQLITE_OMIT_TRACE */\n  assert( pOp->p2>0 );\n  if( pOp->p1>=sqlite3GlobalConfig.iOnceResetThreshold ){\n    for(i=1; i<p->nOp; i++){\n      if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;\n    }\n    pOp->p1 = 0;\n  }\n  pOp->p1++;\n  p->aCounter[SQLITE_STMTSTATUS_RUN]++;\n  goto jump_to_p2;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/* Opcode: CursorHint P1 * * P4 *\n**\n** Provide a hint to cursor P1 that it only needs to return rows that\n** satisfy the Expr in P4.  TK_REGISTER terms in the P4 expression refer\n** to values currently held in registers.  TK_COLUMN terms in the P4\n** expression refer to columns in the b-tree to which cursor P1 is pointing.\n*/\ncase OP_CursorHint: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_EXPR );\n  pC = p->apCsr[pOp->p1];\n  if( pC ){\n    assert( pC->eCurType==CURTYPE_BTREE );\n    sqlite3BtreeCursorHint(pC->uc.pCursor, BTREE_HINT_RANGE,\n                           pOp->p4.pExpr, aMem);\n  }\n  break;\n}\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n/* Opcode: Noop * * * * *\n**\n** Do nothing.  This instruction is often useful as a jump\n** destination.\n*/\n/*\n** The magic Explain opcode are only inserted when explain==2 (which\n** is to say when the EXPLAIN QUERY PLAN syntax is used.)\n** This opcode records information from the optimizer.  It is the\n** the same as a no-op.  This opcodesnever appears in a real VM program.\n*/\ndefault: {          /* This is really OP_Noop and OP_Explain */\n  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );\n  break;\n}\n\n/*****************************************************************************\n** The cases of the switch statement above this line should all be indented\n** by 6 spaces.  But the left-most 6 spaces have been removed to improve the\n** readability.  From this point on down, the normal indentation rules are\n** restored.\n*****************************************************************************/\n    }\n\n#ifdef VDBE_PROFILE\n    {\n      u64 endTime = sqlite3Hwtime();\n      if( endTime>start ) pOrigOp->cycles += endTime - start;\n      pOrigOp->cnt++;\n    }\n#endif\n\n    /* The following code adds nothing to the actual functionality\n    ** of the program.  It is only here for testing and debugging.\n    ** On the other hand, it does burn CPU cycles every time through\n    ** the evaluator loop.  So we can leave it out when NDEBUG is defined.\n    */\n#ifndef NDEBUG\n    assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] );\n\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      u8 opProperty = sqlite3OpcodeProperty[pOrigOp->opcode];\n      if( rc!=0 ) printf(\"rc=%d\\n\",rc);\n      if( opProperty & (OPFLG_OUT2) ){\n        registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);\n      }\n      if( opProperty & OPFLG_OUT3 ){\n        registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);\n      }\n    }\n#endif  /* SQLITE_DEBUG */\n#endif  /* NDEBUG */\n  }  /* The end of the for(;;) loop the loops through opcodes */\n\n  /* If we reach this point, it means that execution is finished with\n  ** an error of some kind.\n  */\nabort_due_to_error:\n  if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT;\n  assert( rc );\n  if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){\n    sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  }\n  p->rc = rc;\n  sqlite3SystemError(db, rc);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(rc, \"statement aborts at %d: [%s] %s\", \n                   (int)(pOp - aOp), p->zSql, p->zErrMsg);\n  sqlite3VdbeHalt(p);\n  if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db);\n  rc = SQLITE_ERROR;\n  if( resetSchemaOnFault>0 ){\n    sqlite3ResetOneSchema(db, resetSchemaOnFault-1);\n  }\n\n  /* This is the only way out of this procedure.  We have to\n  ** release the mutexes on btrees that were acquired at the\n  ** top. */\nvdbe_return:\n  testcase( nVmStep>0 );\n  p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep;\n  sqlite3VdbeLeave(p);\n  assert( rc!=SQLITE_OK || nExtraDelete==0 \n       || sqlite3_strlike(\"DELETE%\",p->zSql,0)!=0 \n  );\n  return rc;\n\n  /* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH\n  ** is encountered.\n  */\ntoo_big:\n  sqlite3VdbeError(p, \"string or blob too big\");\n  rc = SQLITE_TOOBIG;\n  goto abort_due_to_error;\n\n  /* Jump to here if a malloc() fails.\n  */\nno_mem:\n  sqlite3OomFault(db);\n  sqlite3VdbeError(p, \"out of memory\");\n  rc = SQLITE_NOMEM_BKPT;\n  goto abort_due_to_error;\n\n  /* Jump to here if the sqlite3_interrupt() API sets the interrupt\n  ** flag.\n  */\nabort_due_to_interrupt:\n  assert( db->u1.isInterrupted );\n  rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n  p->rc = rc;\n  sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  goto abort_due_to_error;\n}\n\n\n/************** End of vdbe.c ************************************************/\n/************** Begin file vdbeblob.c ****************************************/\n/*\n** 2007 May 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement incremental BLOB I/O.\n*/\n\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#ifndef SQLITE_OMIT_INCRBLOB\n\n/*\n** Valid sqlite3_blob* handles point to Incrblob structures.\n*/\ntypedef struct Incrblob Incrblob;\nstruct Incrblob {\n  int nByte;              /* Size of open blob, in bytes */\n  int iOffset;            /* Byte offset of blob in cursor data */\n  u16 iCol;               /* Table column this handle is open on */\n  BtCursor *pCsr;         /* Cursor pointing at blob row */\n  sqlite3_stmt *pStmt;    /* Statement holding cursor open */\n  sqlite3 *db;            /* The associated database */\n  char *zDb;              /* Database name */\n  Table *pTab;            /* Table object */\n};\n\n\n/*\n** This function is used by both blob_open() and blob_reopen(). It seeks\n** the b-tree cursor associated with blob handle p to point to row iRow.\n** If successful, SQLITE_OK is returned and subsequent calls to\n** sqlite3_blob_read() or sqlite3_blob_write() access the specified row.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a value of type TEXT or BLOB in the column nominated when the\n** blob handle was opened, then an error code is returned and *pzErr may\n** be set to point to a buffer containing an error message. It is the\n** responsibility of the caller to free the error message buffer using\n** sqlite3DbFree().\n**\n** If an error does occur, then the b-tree cursor is closed. All subsequent\n** calls to sqlite3_blob_read(), blob_write() or blob_reopen() will \n** immediately return SQLITE_ABORT.\n*/\nstatic int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){\n  int rc;                         /* Error code */\n  char *zErr = 0;                 /* Error message */\n  Vdbe *v = (Vdbe *)p->pStmt;\n\n  /* Set the value of register r[1] in the SQL statement to integer iRow. \n  ** This is done directly as a performance optimization\n  */\n  v->aMem[1].flags = MEM_Int;\n  v->aMem[1].u.i = iRow;\n\n  /* If the statement has been run before (and is paused at the OP_ResultRow)\n  ** then back it up to the point where it does the OP_NotExists.  This could\n  ** have been down with an extra OP_Goto, but simply setting the program\n  ** counter is faster. */\n  if( v->pc>4 ){\n    v->pc = 4;\n    assert( v->aOp[v->pc].opcode==OP_NotExists );\n    rc = sqlite3VdbeExec(v);\n  }else{\n    rc = sqlite3_step(p->pStmt);\n  }\n  if( rc==SQLITE_ROW ){\n    VdbeCursor *pC = v->apCsr[0];\n    u32 type = pC->nHdrParsed>p->iCol ? pC->aType[p->iCol] : 0;\n    testcase( pC->nHdrParsed==p->iCol );\n    testcase( pC->nHdrParsed==p->iCol+1 );\n    if( type<12 ){\n      zErr = sqlite3MPrintf(p->db, \"cannot open value of type %s\",\n          type==0?\"null\": type==7?\"real\": \"integer\"\n      );\n      rc = SQLITE_ERROR;\n      sqlite3_finalize(p->pStmt);\n      p->pStmt = 0;\n    }else{\n      p->iOffset = pC->aType[p->iCol + pC->nField];\n      p->nByte = sqlite3VdbeSerialTypeLen(type);\n      p->pCsr =  pC->uc.pCursor;\n      sqlite3BtreeIncrblobCursor(p->pCsr);\n    }\n  }\n\n  if( rc==SQLITE_ROW ){\n    rc = SQLITE_OK;\n  }else if( p->pStmt ){\n    rc = sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n    if( rc==SQLITE_OK ){\n      zErr = sqlite3MPrintf(p->db, \"no such rowid: %lld\", iRow);\n      rc = SQLITE_ERROR;\n    }else{\n      zErr = sqlite3MPrintf(p->db, \"%s\", sqlite3_errmsg(p->db));\n    }\n  }\n\n  assert( rc!=SQLITE_OK || zErr==0 );\n  assert( rc!=SQLITE_ROW && rc!=SQLITE_DONE );\n\n  *pzErr = zErr;\n  return rc;\n}\n\n/*\n** Open a blob handle.\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3* db,            /* The database connection */\n  const char *zDb,        /* The attached database containing the blob */\n  const char *zTable,     /* The table containing the blob */\n  const char *zColumn,    /* The column containing the blob */\n  sqlite_int64 iRow,      /* The row containing the glob */\n  int wrFlag,             /* True -> read/write access, false -> read-only */\n  sqlite3_blob **ppBlob   /* Handle for accessing the blob returned here */\n){\n  int nAttempt = 0;\n  int iCol;               /* Index of zColumn in row-record */\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  Table *pTab;\n  Incrblob *pBlob = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppBlob==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  *ppBlob = 0;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  wrFlag = !!wrFlag;                /* wrFlag = (wrFlag ? 1 : 0); */\n\n  sqlite3_mutex_enter(db->mutex);\n\n  pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));\n  do {\n    memset(&sParse, 0, sizeof(Parse));\n    if( !pBlob ) goto blob_open_out;\n    sParse.db = db;\n    sqlite3DbFree(db, zErr);\n    zErr = 0;\n\n    sqlite3BtreeEnterAll(db);\n    pTab = sqlite3LocateTable(&sParse, 0, zTable, zDb);\n    if( pTab && IsVirtual(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open virtual table: %s\", zTable);\n    }\n    if( pTab && !HasRowid(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open table without rowid: %s\", zTable);\n    }\n#ifndef SQLITE_OMIT_VIEW\n    if( pTab && pTab->pSelect ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open view: %s\", zTable);\n    }\n#endif\n    if( !pTab ){\n      if( sParse.zErrMsg ){\n        sqlite3DbFree(db, zErr);\n        zErr = sParse.zErrMsg;\n        sParse.zErrMsg = 0;\n      }\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n    pBlob->pTab = pTab;\n    pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;\n\n    /* Now search pTab for the exact column. */\n    for(iCol=0; iCol<pTab->nCol; iCol++) {\n      if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      sqlite3DbFree(db, zErr);\n      zErr = sqlite3MPrintf(db, \"no such column: \\\"%s\\\"\", zColumn);\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n\n    /* If the value is being opened for writing, check that the\n    ** column is not indexed, and that it is not part of a foreign key. \n    */\n    if( wrFlag ){\n      const char *zFault = 0;\n      Index *pIdx;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n      if( db->flags&SQLITE_ForeignKeys ){\n        /* Check that the column is not part of an FK child key definition. It\n        ** is not necessary to check if it is part of a parent key, as parent\n        ** key columns must be indexed. The check below will pick up this \n        ** case.  */\n        FKey *pFKey;\n        for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n          int j;\n          for(j=0; j<pFKey->nCol; j++){\n            if( pFKey->aCol[j].iFrom==iCol ){\n              zFault = \"foreign key\";\n            }\n          }\n        }\n      }\n#endif\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        int j;\n        for(j=0; j<pIdx->nKeyCol; j++){\n          /* FIXME: Be smarter about indexes that use expressions */\n          if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){\n            zFault = \"indexed\";\n          }\n        }\n      }\n      if( zFault ){\n        sqlite3DbFree(db, zErr);\n        zErr = sqlite3MPrintf(db, \"cannot open %s column for writing\", zFault);\n        rc = SQLITE_ERROR;\n        sqlite3BtreeLeaveAll(db);\n        goto blob_open_out;\n      }\n    }\n\n    pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(&sParse);\n    assert( pBlob->pStmt || db->mallocFailed );\n    if( pBlob->pStmt ){\n      \n      /* This VDBE program seeks a btree cursor to the identified \n      ** db/table/row entry. The reason for using a vdbe program instead\n      ** of writing code to use the b-tree layer directly is that the\n      ** vdbe program will take advantage of the various transaction,\n      ** locking and error handling infrastructure built into the vdbe.\n      **\n      ** After seeking the cursor, the vdbe executes an OP_ResultRow.\n      ** Code external to the Vdbe then \"borrows\" the b-tree cursor and\n      ** uses it to implement the blob_read(), blob_write() and \n      ** blob_bytes() functions.\n      **\n      ** The sqlite3_blob_close() function finalizes the vdbe program,\n      ** which closes the b-tree cursor and (possibly) commits the \n      ** transaction.\n      */\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList openBlob[] = {\n        {OP_TableLock,      0, 0, 0},  /* 0: Acquire a read or write lock */\n        {OP_OpenRead,       0, 0, 0},  /* 1: Open a cursor */\n        /* blobSeekToRow() will initialize r[1] to the desired rowid */\n        {OP_NotExists,      0, 5, 1},  /* 2: Seek the cursor to rowid=r[1] */\n        {OP_Column,         0, 0, 1},  /* 3  */\n        {OP_ResultRow,      1, 0, 0},  /* 4  */\n        {OP_Halt,           0, 0, 0},  /* 5  */\n      };\n      Vdbe *v = (Vdbe *)pBlob->pStmt;\n      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      VdbeOp *aOp;\n\n      sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag, \n                           pTab->pSchema->schema_cookie,\n                           pTab->pSchema->iGeneration);\n      sqlite3VdbeChangeP5(v, 1);\n      assert( sqlite3VdbeCurrentAddr(v)==2 || db->mallocFailed );\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn);\n\n      /* Make sure a mutex is held on the table to be accessed */\n      sqlite3VdbeUsesBtree(v, iDb); \n\n      if( db->mallocFailed==0 ){\n        assert( aOp!=0 );\n        /* Configure the OP_TableLock instruction */\n#ifdef SQLITE_OMIT_SHARED_CACHE\n        aOp[0].opcode = OP_Noop;\n#else\n        aOp[0].p1 = iDb;\n        aOp[0].p2 = pTab->tnum;\n        aOp[0].p3 = wrFlag;\n        sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);\n      }\n      if( db->mallocFailed==0 ){\n#endif\n\n        /* Remove either the OP_OpenWrite or OpenRead. Set the P2 \n        ** parameter of the other to pTab->tnum.  */\n        if( wrFlag ) aOp[1].opcode = OP_OpenWrite;\n        aOp[1].p2 = pTab->tnum;\n        aOp[1].p3 = iDb;   \n\n        /* Configure the number of columns. Configure the cursor to\n        ** think that the table has one more column than it really\n        ** does. An OP_Column to retrieve this imaginary column will\n        ** always return an SQL NULL. This is useful because it means\n        ** we can invoke OP_Column to fill in the vdbe cursors type \n        ** and offset cache without causing any IO.\n        */\n        aOp[1].p4type = P4_INT32;\n        aOp[1].p4.i = pTab->nCol+1;\n        aOp[3].p2 = pTab->nCol;\n\n        sParse.nVar = 0;\n        sParse.nMem = 1;\n        sParse.nTab = 1;\n        sqlite3VdbeMakeReady(v, &sParse);\n      }\n    }\n   \n    pBlob->iCol = iCol;\n    pBlob->db = db;\n    sqlite3BtreeLeaveAll(db);\n    if( db->mallocFailed ){\n      goto blob_open_out;\n    }\n    rc = blobSeekToRow(pBlob, iRow, &zErr);\n  } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );\n\nblob_open_out:\n  if( rc==SQLITE_OK && db->mallocFailed==0 ){\n    *ppBlob = (sqlite3_blob *)pBlob;\n  }else{\n    if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);\n    sqlite3DbFree(db, pBlob);\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n  sqlite3DbFree(db, zErr);\n  sqlite3ParserReset(&sParse);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Close a blob handle that was previously created using\n** sqlite3_blob_open().\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  int rc;\n  sqlite3 *db;\n\n  if( p ){\n    db = p->db;\n    sqlite3_mutex_enter(db->mutex);\n    rc = sqlite3_finalize(p->pStmt);\n    sqlite3DbFree(db, p);\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Perform a read or write operation on a blob\n*/\nstatic int blobReadWrite(\n  sqlite3_blob *pBlob, \n  void *z, \n  int n, \n  int iOffset, \n  int (*xCall)(BtCursor*, u32, u32, void*)\n){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  Vdbe *v;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n  v = (Vdbe*)p->pStmt;\n\n  if( n<0 || iOffset<0 || ((sqlite3_int64)iOffset+n)>p->nByte ){\n    /* Request is out of range. Return a transient error. */\n    rc = SQLITE_ERROR;\n  }else if( v==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is\n    ** returned, clean-up the statement handle.\n    */\n    assert( db == v->db );\n    sqlite3BtreeEnterCursor(p->pCsr);\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    if( xCall==sqlite3BtreePutData && db->xPreUpdateCallback ){\n      /* If a pre-update hook is registered and this is a write cursor, \n      ** invoke it here. \n      ** \n      ** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this\n      ** operation should really be an SQLITE_UPDATE. This is probably\n      ** incorrect, but is convenient because at this point the new.* values \n      ** are not easily obtainable. And for the sessions module, an \n      ** SQLITE_UPDATE where the PK columns do not change is handled in the \n      ** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually\n      ** slightly more efficient). Since you cannot write to a PK column\n      ** using the incremental-blob API, this works. For the sessions module\n      ** anyhow.\n      */\n      sqlite3_int64 iKey;\n      iKey = sqlite3BtreeIntegerKey(p->pCsr);\n      sqlite3VdbePreUpdateHook(\n          v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1\n      );\n    }\n#endif\n\n    rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);\n    sqlite3BtreeLeaveCursor(p->pCsr);\n    if( rc==SQLITE_ABORT ){\n      sqlite3VdbeFinalize(v);\n      p->pStmt = 0;\n    }else{\n      v->rc = rc;\n    }\n  }\n  sqlite3Error(db, rc);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Read data from a blob handle.\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreePayloadChecked);\n}\n\n/*\n** Write data to a blob handle.\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);\n}\n\n/*\n** Query a blob handle for the size of the data.\n**\n** The Incrblob.nByte field is fixed for the lifetime of the Incrblob\n** so no mutex is required for access.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  return (p && p->pStmt) ? p->nByte : 0;\n}\n\n/*\n** Move an existing blob handle to point to a different row of the same\n** database table.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a blob or text value, then an error code is returned and the\n** database handle error code and message set. If this happens, then all \n** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) \n** immediately return SQLITE_ABORT.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n\n  if( p->pStmt==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    char *zErr;\n    rc = blobSeekToRow(p, iRow, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n      sqlite3DbFree(db, zErr);\n    }\n    assert( rc!=SQLITE_SCHEMA );\n  }\n\n  rc = sqlite3ApiExit(db, rc);\n  assert( rc==SQLITE_OK || p->pStmt==0 );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* #ifndef SQLITE_OMIT_INCRBLOB */\n\n/************** End of vdbeblob.c ********************************************/\n/************** Begin file vdbesort.c ****************************************/\n/*\n** 2011-07-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for the VdbeSorter object, used in concert with\n** a VdbeCursor to sort large numbers of keys for CREATE INDEX statements\n** or by SELECT statements with ORDER BY clauses that cannot be satisfied\n** using indexes and without LIMIT clauses.\n**\n** The VdbeSorter object implements a multi-threaded external merge sort\n** algorithm that is efficient even if the number of elements being sorted\n** exceeds the available memory.\n**\n** Here is the (internal, non-API) interface between this module and the\n** rest of the SQLite system:\n**\n**    sqlite3VdbeSorterInit()       Create a new VdbeSorter object.\n**\n**    sqlite3VdbeSorterWrite()      Add a single new row to the VdbeSorter\n**                                  object.  The row is a binary blob in the\n**                                  OP_MakeRecord format that contains both\n**                                  the ORDER BY key columns and result columns\n**                                  in the case of a SELECT w/ ORDER BY, or\n**                                  the complete record for an index entry\n**                                  in the case of a CREATE INDEX.\n**\n**    sqlite3VdbeSorterRewind()     Sort all content previously added.\n**                                  Position the read cursor on the\n**                                  first sorted element.\n**\n**    sqlite3VdbeSorterNext()       Advance the read cursor to the next sorted\n**                                  element.\n**\n**    sqlite3VdbeSorterRowkey()     Return the complete binary blob for the\n**                                  row currently under the read cursor.\n**\n**    sqlite3VdbeSorterCompare()    Compare the binary blob for the row\n**                                  currently under the read cursor against\n**                                  another binary blob X and report if\n**                                  X is strictly less than the read cursor.\n**                                  Used to enforce uniqueness in a\n**                                  CREATE UNIQUE INDEX statement.\n**\n**    sqlite3VdbeSorterClose()      Close the VdbeSorter object and reclaim\n**                                  all resources.\n**\n**    sqlite3VdbeSorterReset()      Refurbish the VdbeSorter for reuse.  This\n**                                  is like Close() followed by Init() only\n**                                  much faster.\n**\n** The interfaces above must be called in a particular order.  Write() can \n** only occur in between Init()/Reset() and Rewind().  Next(), Rowkey(), and\n** Compare() can only occur in between Rewind() and Close()/Reset(). i.e.\n**\n**   Init()\n**   for each record: Write()\n**   Rewind()\n**     Rowkey()/Compare()\n**   Next() \n**   Close()\n**\n** Algorithm:\n**\n** Records passed to the sorter via calls to Write() are initially held \n** unsorted in main memory. Assuming the amount of memory used never exceeds\n** a threshold, when Rewind() is called the set of records is sorted using\n** an in-memory merge sort. In this case, no temporary files are required\n** and subsequent calls to Rowkey(), Next() and Compare() read records \n** directly from main memory.\n**\n** If the amount of space used to store records in main memory exceeds the\n** threshold, then the set of records currently in memory are sorted and\n** written to a temporary file in \"Packed Memory Array\" (PMA) format.\n** A PMA created at this point is known as a \"level-0 PMA\". Higher levels\n** of PMAs may be created by merging existing PMAs together - for example\n** merging two or more level-0 PMAs together creates a level-1 PMA.\n**\n** The threshold for the amount of main memory to use before flushing \n** records to a PMA is roughly the same as the limit configured for the\n** page-cache of the main database. Specifically, the threshold is set to \n** the value returned by \"PRAGMA main.page_size\" multipled by \n** that returned by \"PRAGMA main.cache_size\", in bytes.\n**\n** If the sorter is running in single-threaded mode, then all PMAs generated\n** are appended to a single temporary file. Or, if the sorter is running in\n** multi-threaded mode then up to (N+1) temporary files may be opened, where\n** N is the configured number of worker threads. In this case, instead of\n** sorting the records and writing the PMA to a temporary file itself, the\n** calling thread usually launches a worker thread to do so. Except, if\n** there are already N worker threads running, the main thread does the work\n** itself.\n**\n** The sorter is running in multi-threaded mode if (a) the library was built\n** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater\n** than zero, and (b) worker threads have been enabled at runtime by calling\n** \"PRAGMA threads=N\" with some value of N greater than 0.\n**\n** When Rewind() is called, any data remaining in memory is flushed to a \n** final PMA. So at this point the data is stored in some number of sorted\n** PMAs within temporary files on disk.\n**\n** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the\n** sorter is running in single-threaded mode, then these PMAs are merged\n** incrementally as keys are retreived from the sorter by the VDBE.  The\n** MergeEngine object, described in further detail below, performs this\n** merge.\n**\n** Or, if running in multi-threaded mode, then a background thread is\n** launched to merge the existing PMAs. Once the background thread has\n** merged T bytes of data into a single sorted PMA, the main thread \n** begins reading keys from that PMA while the background thread proceeds\n** with merging the next T bytes of data. And so on.\n**\n** Parameter T is set to half the value of the memory threshold used \n** by Write() above to determine when to create a new PMA.\n**\n** If there are more than SORTER_MAX_MERGE_COUNT PMAs in total when \n** Rewind() is called, then a hierarchy of incremental-merges is used. \n** First, T bytes of data from the first SORTER_MAX_MERGE_COUNT PMAs on \n** disk are merged together. Then T bytes of data from the second set, and\n** so on, such that no operation ever merges more than SORTER_MAX_MERGE_COUNT\n** PMAs at a time. This done is to improve locality.\n**\n** If running in multi-threaded mode and there are more than\n** SORTER_MAX_MERGE_COUNT PMAs on disk when Rewind() is called, then more\n** than one background thread may be created. Specifically, there may be\n** one background thread for each temporary file on disk, and one background\n** thread to merge the output of each of the others to a single PMA for\n** the main thread to read from.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n/* \n** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various\n** messages to stderr that may be helpful in understanding the performance\n** characteristics of the sorter in multi-threaded mode.\n*/\n#if 0\n# define SQLITE_DEBUG_SORTER_THREADS 1\n#endif\n\n/*\n** Hard-coded maximum amount of data to accumulate in memory before flushing\n** to a level 0 PMA. The purpose of this limit is to prevent various integer\n** overflows. 512MiB.\n*/\n#define SQLITE_MAX_PMASZ    (1<<29)\n\n/*\n** Private objects used by the sorter\n*/\ntypedef struct MergeEngine MergeEngine;     /* Merge PMAs together */\ntypedef struct PmaReader PmaReader;         /* Incrementally read one PMA */\ntypedef struct PmaWriter PmaWriter;         /* Incrementally write one PMA */\ntypedef struct SorterRecord SorterRecord;   /* A record being sorted */\ntypedef struct SortSubtask SortSubtask;     /* A sub-task in the sort process */\ntypedef struct SorterFile SorterFile;       /* Temporary file object wrapper */\ntypedef struct SorterList SorterList;       /* In-memory list of records */\ntypedef struct IncrMerger IncrMerger;       /* Read & merge multiple PMAs */\n\n/*\n** A container for a temp file handle and the current amount of data \n** stored in the file.\n*/\nstruct SorterFile {\n  sqlite3_file *pFd;              /* File handle */\n  i64 iEof;                       /* Bytes of data stored in pFd */\n};\n\n/*\n** An in-memory list of objects to be sorted.\n**\n** If aMemory==0 then each object is allocated separately and the objects\n** are connected using SorterRecord.u.pNext.  If aMemory!=0 then all objects\n** are stored in the aMemory[] bulk memory, one right after the other, and\n** are connected using SorterRecord.u.iNext.\n*/\nstruct SorterList {\n  SorterRecord *pList;            /* Linked list of records */\n  u8 *aMemory;                    /* If non-NULL, bulk memory to hold pList */\n  int szPMA;                      /* Size of pList as PMA in bytes */\n};\n\n/*\n** The MergeEngine object is used to combine two or more smaller PMAs into\n** one big PMA using a merge operation.  Separate PMAs all need to be\n** combined into one big PMA in order to be able to step through the sorted\n** records in order.\n**\n** The aReadr[] array contains a PmaReader object for each of the PMAs being\n** merged.  An aReadr[] object either points to a valid key or else is at EOF.\n** (\"EOF\" means \"End Of File\".  When aReadr[] is at EOF there is no more data.)\n** For the purposes of the paragraphs below, we assume that the array is\n** actually N elements in size, where N is the smallest power of 2 greater\n** to or equal to the number of PMAs being merged. The extra aReadr[] elements\n** are treated as if they are empty (always at EOF).\n**\n** The aTree[] array is also N elements in size. The value of N is stored in\n** the MergeEngine.nTree variable.\n**\n** The final (N/2) elements of aTree[] contain the results of comparing\n** pairs of PMA keys together. Element i contains the result of \n** comparing aReadr[2*i-N] and aReadr[2*i-N+1]. Whichever key is smaller, the\n** aTree element is set to the index of it. \n**\n** For the purposes of this comparison, EOF is considered greater than any\n** other key value. If the keys are equal (only possible with two EOF\n** values), it doesn't matter which index is stored.\n**\n** The (N/4) elements of aTree[] that precede the final (N/2) described \n** above contains the index of the smallest of each block of 4 PmaReaders\n** And so on. So that aTree[1] contains the index of the PmaReader that \n** currently points to the smallest key value. aTree[0] is unused.\n**\n** Example:\n**\n**     aReadr[0] -> Banana\n**     aReadr[1] -> Feijoa\n**     aReadr[2] -> Elderberry\n**     aReadr[3] -> Currant\n**     aReadr[4] -> Grapefruit\n**     aReadr[5] -> Apple\n**     aReadr[6] -> Durian\n**     aReadr[7] -> EOF\n**\n**     aTree[] = { X, 5   0, 5    0, 3, 5, 6 }\n**\n** The current element is \"Apple\" (the value of the key indicated by \n** PmaReader 5). When the Next() operation is invoked, PmaReader 5 will\n** be advanced to the next key in its segment. Say the next key is\n** \"Eggplant\":\n**\n**     aReadr[5] -> Eggplant\n**\n** The contents of aTree[] are updated first by comparing the new PmaReader\n** 5 key to the current key of PmaReader 4 (still \"Grapefruit\"). The PmaReader\n** 5 value is still smaller, so aTree[6] is set to 5. And so on up the tree.\n** The value of PmaReader 6 - \"Durian\" - is now smaller than that of PmaReader\n** 5, so aTree[3] is set to 6. Key 0 is smaller than key 6 (Banana<Durian),\n** so the value written into element 1 of the array is 0. As follows:\n**\n**     aTree[] = { X, 0   0, 6    0, 3, 5, 6 }\n**\n** In other words, each time we advance to the next sorter element, log2(N)\n** key comparison operations are required, where N is the number of segments\n** being merged (rounded up to the next power of 2).\n*/\nstruct MergeEngine {\n  int nTree;                 /* Used size of aTree/aReadr (power of 2) */\n  SortSubtask *pTask;        /* Used by this thread only */\n  int *aTree;                /* Current state of incremental merge */\n  PmaReader *aReadr;         /* Array of PmaReaders to merge data from */\n};\n\n/*\n** This object represents a single thread of control in a sort operation.\n** Exactly VdbeSorter.nTask instances of this object are allocated\n** as part of each VdbeSorter object. Instances are never allocated any\n** other way. VdbeSorter.nTask is set to the number of worker threads allowed\n** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread).  Thus for\n** single-threaded operation, there is exactly one instance of this object\n** and for multi-threaded operation there are two or more instances.\n**\n** Essentially, this structure contains all those fields of the VdbeSorter\n** structure for which each thread requires a separate instance. For example,\n** each thread requries its own UnpackedRecord object to unpack records in\n** as part of comparison operations.\n**\n** Before a background thread is launched, variable bDone is set to 0. Then, \n** right before it exits, the thread itself sets bDone to 1. This is used for \n** two purposes:\n**\n**   1. When flushing the contents of memory to a level-0 PMA on disk, to\n**      attempt to select a SortSubtask for which there is not already an\n**      active background thread (since doing so causes the main thread\n**      to block until it finishes).\n**\n**   2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call\n**      to sqlite3ThreadJoin() is likely to block. Cases that are likely to\n**      block provoke debugging output.\n**\n** In both cases, the effects of the main thread seeing (bDone==0) even\n** after the thread has finished are not dire. So we don't worry about\n** memory barriers and such here.\n*/\ntypedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);\nstruct SortSubtask {\n  SQLiteThread *pThread;          /* Background thread, if any */\n  int bDone;                      /* Set if thread is finished but not joined */\n  VdbeSorter *pSorter;            /* Sorter that owns this sub-task */\n  UnpackedRecord *pUnpacked;      /* Space to unpack a record */\n  SorterList list;                /* List for thread to write to a PMA */\n  int nPMA;                       /* Number of PMAs currently in file */\n  SorterCompare xCompare;         /* Compare function to use */\n  SorterFile file;                /* Temp file for level-0 PMAs */\n  SorterFile file2;               /* Space for other PMAs */\n};\n\n\n/*\n** Main sorter structure. A single instance of this is allocated for each \n** sorter cursor created by the VDBE.\n**\n** mxKeysize:\n**   As records are added to the sorter by calls to sqlite3VdbeSorterWrite(),\n**   this variable is updated so as to be set to the size on disk of the\n**   largest record in the sorter.\n*/\nstruct VdbeSorter {\n  int mnPmaSize;                  /* Minimum PMA size, in bytes */\n  int mxPmaSize;                  /* Maximum PMA size, in bytes.  0==no limit */\n  int mxKeysize;                  /* Largest serialized key seen so far */\n  int pgsz;                       /* Main database page size */\n  PmaReader *pReader;             /* Readr data from here after Rewind() */\n  MergeEngine *pMerger;           /* Or here, if bUseThreads==0 */\n  sqlite3 *db;                    /* Database connection */\n  KeyInfo *pKeyInfo;              /* How to compare records */\n  UnpackedRecord *pUnpacked;      /* Used by VdbeSorterCompare() */\n  SorterList list;                /* List of in-memory records */\n  int iMemory;                    /* Offset of free space in list.aMemory */\n  int nMemory;                    /* Size of list.aMemory allocation in bytes */\n  u8 bUsePMA;                     /* True if one or more PMAs created */\n  u8 bUseThreads;                 /* True to use background threads */\n  u8 iPrev;                       /* Previous thread used to flush PMA */\n  u8 nTask;                       /* Size of aTask[] array */\n  u8 typeMask;\n  SortSubtask aTask[1];           /* One or more subtasks */\n};\n\n#define SORTER_TYPE_INTEGER 0x01\n#define SORTER_TYPE_TEXT    0x02\n\n/*\n** An instance of the following object is used to read records out of a\n** PMA, in sorted order.  The next key to be read is cached in nKey/aKey.\n** aKey might point into aMap or into aBuffer.  If neither of those locations\n** contain a contiguous representation of the key, then aAlloc is allocated\n** and the key is copied into aAlloc and aKey is made to poitn to aAlloc.\n**\n** pFd==0 at EOF.\n*/\nstruct PmaReader {\n  i64 iReadOff;               /* Current read offset */\n  i64 iEof;                   /* 1 byte past EOF for this PmaReader */\n  int nAlloc;                 /* Bytes of space at aAlloc */\n  int nKey;                   /* Number of bytes in key */\n  sqlite3_file *pFd;          /* File handle we are reading from */\n  u8 *aAlloc;                 /* Space for aKey if aBuffer and pMap wont work */\n  u8 *aKey;                   /* Pointer to current key */\n  u8 *aBuffer;                /* Current read buffer */\n  int nBuffer;                /* Size of read buffer in bytes */\n  u8 *aMap;                   /* Pointer to mapping of entire file */\n  IncrMerger *pIncr;          /* Incremental merger */\n};\n\n/*\n** Normally, a PmaReader object iterates through an existing PMA stored \n** within a temp file. However, if the PmaReader.pIncr variable points to\n** an object of the following type, it may be used to iterate/merge through\n** multiple PMAs simultaneously.\n**\n** There are two types of IncrMerger object - single (bUseThread==0) and \n** multi-threaded (bUseThread==1). \n**\n** A multi-threaded IncrMerger object uses two temporary files - aFile[0] \n** and aFile[1]. Neither file is allowed to grow to more than mxSz bytes in \n** size. When the IncrMerger is initialized, it reads enough data from \n** pMerger to populate aFile[0]. It then sets variables within the \n** corresponding PmaReader object to read from that file and kicks off \n** a background thread to populate aFile[1] with the next mxSz bytes of \n** sorted record data from pMerger. \n**\n** When the PmaReader reaches the end of aFile[0], it blocks until the\n** background thread has finished populating aFile[1]. It then exchanges\n** the contents of the aFile[0] and aFile[1] variables within this structure,\n** sets the PmaReader fields to read from the new aFile[0] and kicks off\n** another background thread to populate the new aFile[1]. And so on, until\n** the contents of pMerger are exhausted.\n**\n** A single-threaded IncrMerger does not open any temporary files of its\n** own. Instead, it has exclusive access to mxSz bytes of space beginning\n** at offset iStartOff of file pTask->file2. And instead of using a \n** background thread to prepare data for the PmaReader, with a single\n** threaded IncrMerger the allocate part of pTask->file2 is \"refilled\" with\n** keys from pMerger by the calling thread whenever the PmaReader runs out\n** of data.\n*/\nstruct IncrMerger {\n  SortSubtask *pTask;             /* Task that owns this merger */\n  MergeEngine *pMerger;           /* Merge engine thread reads data from */\n  i64 iStartOff;                  /* Offset to start writing file at */\n  int mxSz;                       /* Maximum bytes of data to store */\n  int bEof;                       /* Set to true when merge is finished */\n  int bUseThread;                 /* True to use a bg thread for this object */\n  SorterFile aFile[2];            /* aFile[0] for reading, [1] for writing */\n};\n\n/*\n** An instance of this object is used for writing a PMA.\n**\n** The PMA is written one record at a time.  Each record is of an arbitrary\n** size.  But I/O is more efficient if it occurs in page-sized blocks where\n** each block is aligned on a page boundary.  This object caches writes to\n** the PMA so that aligned, page-size blocks are written.\n*/\nstruct PmaWriter {\n  int eFWErr;                     /* Non-zero if in an error state */\n  u8 *aBuffer;                    /* Pointer to write buffer */\n  int nBuffer;                    /* Size of write buffer in bytes */\n  int iBufStart;                  /* First byte of buffer to write */\n  int iBufEnd;                    /* Last byte of buffer to write */\n  i64 iWriteOff;                  /* Offset of start of buffer in file */\n  sqlite3_file *pFd;              /* File handle to write to */\n};\n\n/*\n** This object is the header on a single record while that record is being\n** held in memory and prior to being written out as part of a PMA.\n**\n** How the linked list is connected depends on how memory is being managed\n** by this module. If using a separate allocation for each in-memory record\n** (VdbeSorter.list.aMemory==0), then the list is always connected using the\n** SorterRecord.u.pNext pointers.\n**\n** Or, if using the single large allocation method (VdbeSorter.list.aMemory!=0),\n** then while records are being accumulated the list is linked using the\n** SorterRecord.u.iNext offset. This is because the aMemory[] array may\n** be sqlite3Realloc()ed while records are being accumulated. Once the VM\n** has finished passing records to the sorter, or when the in-memory buffer\n** is full, the list is sorted. As part of the sorting process, it is\n** converted to use the SorterRecord.u.pNext pointers. See function\n** vdbeSorterSort() for details.\n*/\nstruct SorterRecord {\n  int nVal;                       /* Size of the record in bytes */\n  union {\n    SorterRecord *pNext;          /* Pointer to next record in list */\n    int iNext;                    /* Offset within aMemory of next record */\n  } u;\n  /* The data for the record immediately follows this header */\n};\n\n/* Return a pointer to the buffer containing the record data for SorterRecord\n** object p. Should be used as if:\n**\n**   void *SRVAL(SorterRecord *p) { return (void*)&p[1]; }\n*/\n#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))\n\n\n/* Maximum number of PMAs that a single MergeEngine can merge */\n#define SORTER_MAX_MERGE_COUNT 16\n\nstatic int vdbeIncrSwap(IncrMerger*);\nstatic void vdbeIncrFree(IncrMerger *);\n\n/*\n** Free all memory belonging to the PmaReader object passed as the\n** argument. All structure fields are set to zero before returning.\n*/\nstatic void vdbePmaReaderClear(PmaReader *pReadr){\n  sqlite3_free(pReadr->aAlloc);\n  sqlite3_free(pReadr->aBuffer);\n  if( pReadr->aMap ) sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n  vdbeIncrFree(pReadr->pIncr);\n  memset(pReadr, 0, sizeof(PmaReader));\n}\n\n/*\n** Read the next nByte bytes of data from the PMA p.\n** If successful, set *ppOut to point to a buffer containing the data\n** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite\n** error code.\n**\n** The buffer returned in *ppOut is only valid until the\n** next call to this function.\n*/\nstatic int vdbePmaReadBlob(\n  PmaReader *p,                   /* PmaReader from which to take the blob */\n  int nByte,                      /* Bytes of data to read */\n  u8 **ppOut                      /* OUT: Pointer to buffer containing data */\n){\n  int iBuf;                       /* Offset within buffer to read from */\n  int nAvail;                     /* Bytes of data available in buffer */\n\n  if( p->aMap ){\n    *ppOut = &p->aMap[p->iReadOff];\n    p->iReadOff += nByte;\n    return SQLITE_OK;\n  }\n\n  assert( p->aBuffer );\n\n  /* If there is no more data to be read from the buffer, read the next \n  ** p->nBuffer bytes of data from the file into it. Or, if there are less\n  ** than p->nBuffer bytes remaining in the PMA, read all remaining data.  */\n  iBuf = p->iReadOff % p->nBuffer;\n  if( iBuf==0 ){\n    int nRead;                    /* Bytes to read from disk */\n    int rc;                       /* sqlite3OsRead() return code */\n\n    /* Determine how many bytes of data to read. */\n    if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){\n      nRead = p->nBuffer;\n    }else{\n      nRead = (int)(p->iEof - p->iReadOff);\n    }\n    assert( nRead>0 );\n\n    /* Readr data from the file. Return early if an error occurs. */\n    rc = sqlite3OsRead(p->pFd, p->aBuffer, nRead, p->iReadOff);\n    assert( rc!=SQLITE_IOERR_SHORT_READ );\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nAvail = p->nBuffer - iBuf; \n\n  if( nByte<=nAvail ){\n    /* The requested data is available in the in-memory buffer. In this\n    ** case there is no need to make a copy of the data, just return a \n    ** pointer into the buffer to the caller.  */\n    *ppOut = &p->aBuffer[iBuf];\n    p->iReadOff += nByte;\n  }else{\n    /* The requested data is not all available in the in-memory buffer.\n    ** In this case, allocate space at p->aAlloc[] to copy the requested\n    ** range into. Then return a copy of pointer p->aAlloc to the caller.  */\n    int nRem;                     /* Bytes remaining to copy */\n\n    /* Extend the p->aAlloc[] allocation if required. */\n    if( p->nAlloc<nByte ){\n      u8 *aNew;\n      int nNew = MAX(128, p->nAlloc*2);\n      while( nByte>nNew ) nNew = nNew*2;\n      aNew = sqlite3Realloc(p->aAlloc, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      p->nAlloc = nNew;\n      p->aAlloc = aNew;\n    }\n\n    /* Copy as much data as is available in the buffer into the start of\n    ** p->aAlloc[].  */\n    memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail);\n    p->iReadOff += nAvail;\n    nRem = nByte - nAvail;\n\n    /* The following loop copies up to p->nBuffer bytes per iteration into\n    ** the p->aAlloc[] buffer.  */\n    while( nRem>0 ){\n      int rc;                     /* vdbePmaReadBlob() return code */\n      int nCopy;                  /* Number of bytes to copy */\n      u8 *aNext;                  /* Pointer to buffer to copy data from */\n\n      nCopy = nRem;\n      if( nRem>p->nBuffer ) nCopy = p->nBuffer;\n      rc = vdbePmaReadBlob(p, nCopy, &aNext);\n      if( rc!=SQLITE_OK ) return rc;\n      assert( aNext!=p->aAlloc );\n      memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);\n      nRem -= nCopy;\n    }\n\n    *ppOut = p->aAlloc;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Read a varint from the stream of data accessed by p. Set *pnOut to\n** the value read.\n*/\nstatic int vdbePmaReadVarint(PmaReader *p, u64 *pnOut){\n  int iBuf;\n\n  if( p->aMap ){\n    p->iReadOff += sqlite3GetVarint(&p->aMap[p->iReadOff], pnOut);\n  }else{\n    iBuf = p->iReadOff % p->nBuffer;\n    if( iBuf && (p->nBuffer-iBuf)>=9 ){\n      p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut);\n    }else{\n      u8 aVarint[16], *a;\n      int i = 0, rc;\n      do{\n        rc = vdbePmaReadBlob(p, 1, &a);\n        if( rc ) return rc;\n        aVarint[(i++)&0xf] = a[0];\n      }while( (a[0]&0x80)!=0 );\n      sqlite3GetVarint(aVarint, pnOut);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Attempt to memory map file pFile. If successful, set *pp to point to the\n** new mapping and return SQLITE_OK. If the mapping is not attempted \n** (because the file is too large or the VFS layer is configured not to use\n** mmap), return SQLITE_OK and set *pp to NULL.\n**\n** Or, if an error occurs, return an SQLite error code. The final value of\n** *pp is undefined in this case.\n*/\nstatic int vdbeSorterMapFile(SortSubtask *pTask, SorterFile *pFile, u8 **pp){\n  int rc = SQLITE_OK;\n  if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){\n    sqlite3_file *pFd = pFile->pFd;\n    if( pFd->pMethods->iVersion>=3 ){\n      rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp);\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** Attach PmaReader pReadr to file pFile (if it is not already attached to\n** that file) and seek it to offset iOff within the file.  Return SQLITE_OK \n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic int vdbePmaReaderSeek(\n  SortSubtask *pTask,             /* Task context */\n  PmaReader *pReadr,              /* Reader whose cursor is to be moved */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iOff                        /* Offset in pFile */\n){\n  int rc = SQLITE_OK;\n\n  assert( pReadr->pIncr==0 || pReadr->pIncr->bEof==0 );\n\n  if( sqlite3FaultSim(201) ) return SQLITE_IOERR_READ;\n  if( pReadr->aMap ){\n    sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n    pReadr->aMap = 0;\n  }\n  pReadr->iReadOff = iOff;\n  pReadr->iEof = pFile->iEof;\n  pReadr->pFd = pFile->pFd;\n\n  rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap);\n  if( rc==SQLITE_OK && pReadr->aMap==0 ){\n    int pgsz = pTask->pSorter->pgsz;\n    int iBuf = pReadr->iReadOff % pgsz;\n    if( pReadr->aBuffer==0 ){\n      pReadr->aBuffer = (u8*)sqlite3Malloc(pgsz);\n      if( pReadr->aBuffer==0 ) rc = SQLITE_NOMEM_BKPT;\n      pReadr->nBuffer = pgsz;\n    }\n    if( rc==SQLITE_OK && iBuf ){\n      int nRead = pgsz - iBuf;\n      if( (pReadr->iReadOff + nRead) > pReadr->iEof ){\n        nRead = (int)(pReadr->iEof - pReadr->iReadOff);\n      }\n      rc = sqlite3OsRead(\n          pReadr->pFd, &pReadr->aBuffer[iBuf], nRead, pReadr->iReadOff\n      );\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance PmaReader pReadr to the next key in its PMA. Return SQLITE_OK if\n** no error occurs, or an SQLite error code if one does.\n*/\nstatic int vdbePmaReaderNext(PmaReader *pReadr){\n  int rc = SQLITE_OK;             /* Return Code */\n  u64 nRec = 0;                   /* Size of record in bytes */\n\n\n  if( pReadr->iReadOff>=pReadr->iEof ){\n    IncrMerger *pIncr = pReadr->pIncr;\n    int bEof = 1;\n    if( pIncr ){\n      rc = vdbeIncrSwap(pIncr);\n      if( rc==SQLITE_OK && pIncr->bEof==0 ){\n        rc = vdbePmaReaderSeek(\n            pIncr->pTask, pReadr, &pIncr->aFile[0], pIncr->iStartOff\n        );\n        bEof = 0;\n      }\n    }\n\n    if( bEof ){\n      /* This is an EOF condition */\n      vdbePmaReaderClear(pReadr);\n      testcase( rc!=SQLITE_OK );\n      return rc;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReadVarint(pReadr, &nRec);\n  }\n  if( rc==SQLITE_OK ){\n    pReadr->nKey = (int)nRec;\n    rc = vdbePmaReadBlob(pReadr, (int)nRec, &pReadr->aKey);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  return rc;\n}\n\n/*\n** Initialize PmaReader pReadr to scan through the PMA stored in file pFile\n** starting at offset iStart and ending at offset iEof-1. This function \n** leaves the PmaReader pointing to the first key in the PMA (or EOF if the \n** PMA is empty).\n**\n** If the pnByte parameter is NULL, then it is assumed that the file \n** contains a single PMA, and that that PMA omits the initial length varint.\n*/\nstatic int vdbePmaReaderInit(\n  SortSubtask *pTask,             /* Task context */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iStart,                     /* Start offset in pFile */\n  PmaReader *pReadr,              /* PmaReader to populate */\n  i64 *pnByte                     /* IN/OUT: Increment this value by PMA size */\n){\n  int rc;\n\n  assert( pFile->iEof>iStart );\n  assert( pReadr->aAlloc==0 && pReadr->nAlloc==0 );\n  assert( pReadr->aBuffer==0 );\n  assert( pReadr->aMap==0 );\n\n  rc = vdbePmaReaderSeek(pTask, pReadr, pFile, iStart);\n  if( rc==SQLITE_OK ){\n    u64 nByte = 0;                 /* Size of PMA in bytes */\n    rc = vdbePmaReadVarint(pReadr, &nByte);\n    pReadr->iEof = pReadr->iReadOff + nByte;\n    *pnByte += nByte;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n  return rc;\n}\n\n/*\n** A version of vdbeSorterCompare() that assumes that it has already been\n** determined that the first field of key1 is equal to the first field of \n** key2.\n*/\nstatic int vdbeSorterCompareTail(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( *pbKey2Cached==0 ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1);\n}\n\n/*\n** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2, \n** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences\n** used by the comparison. Return the result of the comparison.\n**\n** If IN/OUT parameter *pbKey2Cached is true when this function is called,\n** it is assumed that (pTask->pUnpacked) contains the unpacked version\n** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked\n** version of key2 and *pbKey2Cached set to true before returning.\n**\n** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set\n** to SQLITE_NOMEM.\n*/\nstatic int vdbeSorterCompare(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( !*pbKey2Cached ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is a TEXT value and that the collation\n** sequence to compare them with is BINARY.\n*/\nstatic int vdbeSorterCompareText(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n\n  int n1;\n  int n2;\n  int res;\n\n  getVarint32(&p1[1], n1);\n  getVarint32(&p2[1], n2);\n  res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);\n  if( res==0 ){\n    res = n1 - n2;\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else{\n    if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n      res = res * -1;\n    }\n  }\n\n  return res;\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is an INTEGER value.\n*/\nstatic int vdbeSorterCompareInt(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const int s1 = p1[1];                 /* Left hand serial type */\n  const int s2 = p2[1];                 /* Right hand serial type */\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n  int res;                              /* Return value */\n\n  assert( (s1>0 && s1<7) || s1==8 || s1==9 );\n  assert( (s2>0 && s2<7) || s2==8 || s2==9 );\n\n  if( s1==s2 ){\n    /* The two values have the same sign. Compare using memcmp(). */\n    static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 };\n    const u8 n = aLen[s1];\n    int i;\n    res = 0;\n    for(i=0; i<n; i++){\n      if( (res = v1[i] - v2[i])!=0 ){\n        if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){\n          res = v1[0] & 0x80 ? -1 : +1;\n        }\n        break;\n      }\n    }\n  }else if( s1>7 && s2>7 ){\n    res = s1 - s2;\n  }else{\n    if( s2>7 ){\n      res = +1;\n    }else if( s1>7 ){\n      res = -1;\n    }else{\n      res = s1 - s2;\n    }\n    assert( res!=0 );\n\n    if( res>0 ){\n      if( *v1 & 0x80 ) res = -1;\n    }else{\n      if( *v2 & 0x80 ) res = +1;\n    }\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n    res = res * -1;\n  }\n\n  return res;\n}\n\n/*\n** Initialize the temporary index cursor just opened as a sorter cursor.\n**\n** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField)\n** to determine the number of fields that should be compared from the\n** records being sorted. However, if the value passed as argument nField\n** is non-zero and the sorter is able to guarantee a stable sort, nField\n** is used instead. This is used when sorting records for a CREATE INDEX\n** statement. In this case, keys are always delivered to the sorter in\n** order of the primary key, which happens to be make up the final part \n** of the records being sorted. So if the sort is stable, there is never\n** any reason to compare PK fields and they can be ignored for a small\n** performance boost.\n**\n** The sorter can guarantee a stable sort when running in single-threaded\n** mode, but not in multi-threaded mode.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterInit(\n  sqlite3 *db,                    /* Database connection (for malloc()) */\n  int nField,                     /* Number of key fields in each record */\n  VdbeCursor *pCsr                /* Cursor that holds the new sorter */\n){\n  int pgsz;                       /* Page size of main database */\n  int i;                          /* Used to iterate through aTask[] */\n  VdbeSorter *pSorter;            /* The new sorter */\n  KeyInfo *pKeyInfo;              /* Copy of pCsr->pKeyInfo with db==0 */\n  int szKeyInfo;                  /* Size of pCsr->pKeyInfo in bytes */\n  int sz;                         /* Size of pSorter in bytes */\n  int rc = SQLITE_OK;\n#if SQLITE_MAX_WORKER_THREADS==0\n# define nWorker 0\n#else\n  int nWorker;\n#endif\n\n  /* Initialize the upper limit on the number of worker threads */\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( sqlite3TempInMemory(db) || sqlite3GlobalConfig.bCoreMutex==0 ){\n    nWorker = 0;\n  }else{\n    nWorker = db->aLimit[SQLITE_LIMIT_WORKER_THREADS];\n  }\n#endif\n\n  /* Do not allow the total number of threads (main thread + all workers)\n  ** to exceed the maximum merge count */\n#if SQLITE_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT\n  if( nWorker>=SORTER_MAX_MERGE_COUNT ){\n    nWorker = SORTER_MAX_MERGE_COUNT-1;\n  }\n#endif\n\n  assert( pCsr->pKeyInfo && pCsr->pBtx==0 );\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);\n  sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);\n\n  pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);\n  pCsr->uc.pSorter = pSorter;\n  if( pSorter==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);\n    memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);\n    pKeyInfo->db = 0;\n    if( nField && nWorker==0 ){\n      pKeyInfo->nKeyField = nField;\n    }\n    pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n    pSorter->nTask = nWorker + 1;\n    pSorter->iPrev = (u8)(nWorker - 1);\n    pSorter->bUseThreads = (pSorter->nTask>1);\n    pSorter->db = db;\n    for(i=0; i<pSorter->nTask; i++){\n      SortSubtask *pTask = &pSorter->aTask[i];\n      pTask->pSorter = pSorter;\n    }\n\n    if( !sqlite3TempInMemory(db) ){\n      i64 mxCache;                /* Cache size in bytes*/\n      u32 szPma = sqlite3GlobalConfig.szPma;\n      pSorter->mnPmaSize = szPma * pgsz;\n\n      mxCache = db->aDb[0].pSchema->cache_size;\n      if( mxCache<0 ){\n        /* A negative cache-size value C indicates that the cache is abs(C)\n        ** KiB in size.  */\n        mxCache = mxCache * -1024;\n      }else{\n        mxCache = mxCache * pgsz;\n      }\n      mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);\n      pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);\n\n      /* Avoid large memory allocations if the application has requested\n      ** SQLITE_CONFIG_SMALL_MALLOC. */\n      if( sqlite3GlobalConfig.bSmallMalloc==0 ){\n        assert( pSorter->iMemory==0 );\n        pSorter->nMemory = pgsz;\n        pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);\n        if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n\n    if( pKeyInfo->nAllField<13 \n     && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)\n    ){\n      pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;\n    }\n  }\n\n  return rc;\n}\n#undef nWorker   /* Defined at the top of this function */\n\n/*\n** Free the list of sorted records starting at pRecord.\n*/\nstatic void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){\n  SorterRecord *p;\n  SorterRecord *pNext;\n  for(p=pRecord; p; p=pNext){\n    pNext = p->u.pNext;\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Free all resources owned by the object indicated by argument pTask. All \n** fields of *pTask are zeroed before returning.\n*/\nstatic void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){\n  sqlite3DbFree(db, pTask->pUnpacked);\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* pTask->list.aMemory can only be non-zero if it was handed memory\n  ** from the main thread.  That only occurs SQLITE_MAX_WORKER_THREADS>0 */\n  if( pTask->list.aMemory ){\n    sqlite3_free(pTask->list.aMemory);\n  }else\n#endif\n  {\n    assert( pTask->list.aMemory==0 );\n    vdbeSorterRecordFree(0, pTask->list.pList);\n  }\n  if( pTask->file.pFd ){\n    sqlite3OsCloseFree(pTask->file.pFd);\n  }\n  if( pTask->file2.pFd ){\n    sqlite3OsCloseFree(pTask->file2.pFd);\n  }\n  memset(pTask, 0, sizeof(SortSubtask));\n}\n\n#ifdef SQLITE_DEBUG_SORTER_THREADS\nstatic void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterRewindDebug(const char *zEvent){\n  i64 t;\n  sqlite3OsCurrentTimeInt64(sqlite3_vfs_find(0), &t);\n  fprintf(stderr, \"%lld:X %s\\n\", t, zEvent);\n}\nstatic void vdbeSorterPopulateDebug(\n  SortSubtask *pTask,\n  const char *zEvent\n){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:bg%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterBlockDebug(\n  SortSubtask *pTask,\n  int bBlocked,\n  const char *zEvent\n){\n  if( bBlocked ){\n    i64 t;\n    sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n    fprintf(stderr, \"%lld:main %s\\n\", t, zEvent);\n  }\n}\n#else\n# define vdbeSorterWorkDebug(x,y)\n# define vdbeSorterRewindDebug(y)\n# define vdbeSorterPopulateDebug(x,y)\n# define vdbeSorterBlockDebug(x,y,z)\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Join thread pTask->thread.\n*/\nstatic int vdbeSorterJoinThread(SortSubtask *pTask){\n  int rc = SQLITE_OK;\n  if( pTask->pThread ){\n#ifdef SQLITE_DEBUG_SORTER_THREADS\n    int bDone = pTask->bDone;\n#endif\n    void *pRet = SQLITE_INT_TO_PTR(SQLITE_ERROR);\n    vdbeSorterBlockDebug(pTask, !bDone, \"enter\");\n    (void)sqlite3ThreadJoin(pTask->pThread, &pRet);\n    vdbeSorterBlockDebug(pTask, !bDone, \"exit\");\n    rc = SQLITE_PTR_TO_INT(pRet);\n    assert( pTask->bDone==1 );\n    pTask->bDone = 0;\n    pTask->pThread = 0;\n  }\n  return rc;\n}\n\n/*\n** Launch a background thread to run xTask(pIn).\n*/\nstatic int vdbeSorterCreateThread(\n  SortSubtask *pTask,             /* Thread will use this task object */\n  void *(*xTask)(void*),          /* Routine to run in a separate thread */\n  void *pIn                       /* Argument passed into xTask() */\n){\n  assert( pTask->pThread==0 && pTask->bDone==0 );\n  return sqlite3ThreadCreate(&pTask->pThread, xTask, pIn);\n}\n\n/*\n** Join all outstanding threads launched by SorterWrite() to create \n** level-0 PMAs.\n*/\nstatic int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){\n  int rc = rcin;\n  int i;\n\n  /* This function is always called by the main user thread.\n  **\n  ** If this function is being called after SorterRewind() has been called, \n  ** it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread\n  ** is currently attempt to join one of the other threads. To avoid a race\n  ** condition where this thread also attempts to join the same object, join \n  ** thread pSorter->aTask[pSorter->nTask-1].pThread first. */\n  for(i=pSorter->nTask-1; i>=0; i--){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    int rc2 = vdbeSorterJoinThread(pTask);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  return rc;\n}\n#else\n# define vdbeSorterJoinAll(x,rcin) (rcin)\n# define vdbeSorterJoinThread(pTask) SQLITE_OK\n#endif\n\n/*\n** Allocate a new MergeEngine object capable of handling up to\n** nReader PmaReader inputs.\n**\n** nReader is automatically rounded up to the next power of two.\n** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.\n*/\nstatic MergeEngine *vdbeMergeEngineNew(int nReader){\n  int N = 2;                      /* Smallest power of two >= nReader */\n  int nByte;                      /* Total bytes of space to allocate */\n  MergeEngine *pNew;              /* Pointer to allocated object to return */\n\n  assert( nReader<=SORTER_MAX_MERGE_COUNT );\n\n  while( N<nReader ) N += N;\n  nByte = sizeof(MergeEngine) + N * (sizeof(int) + sizeof(PmaReader));\n\n  pNew = sqlite3FaultSim(100) ? 0 : (MergeEngine*)sqlite3MallocZero(nByte);\n  if( pNew ){\n    pNew->nTree = N;\n    pNew->pTask = 0;\n    pNew->aReadr = (PmaReader*)&pNew[1];\n    pNew->aTree = (int*)&pNew->aReadr[N];\n  }\n  return pNew;\n}\n\n/*\n** Free the MergeEngine object passed as the only argument.\n*/\nstatic void vdbeMergeEngineFree(MergeEngine *pMerger){\n  int i;\n  if( pMerger ){\n    for(i=0; i<pMerger->nTree; i++){\n      vdbePmaReaderClear(&pMerger->aReadr[i]);\n    }\n  }\n  sqlite3_free(pMerger);\n}\n\n/*\n** Free all resources associated with the IncrMerger object indicated by\n** the first argument.\n*/\nstatic void vdbeIncrFree(IncrMerger *pIncr){\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      vdbeSorterJoinThread(pIncr->pTask);\n      if( pIncr->aFile[0].pFd ) sqlite3OsCloseFree(pIncr->aFile[0].pFd);\n      if( pIncr->aFile[1].pFd ) sqlite3OsCloseFree(pIncr->aFile[1].pFd);\n    }\n#endif\n    vdbeMergeEngineFree(pIncr->pMerger);\n    sqlite3_free(pIncr);\n  }\n}\n\n/*\n** Reset a sorting cursor back to its original empty state.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSorterReset(sqlite3 *db, VdbeSorter *pSorter){\n  int i;\n  (void)vdbeSorterJoinAll(pSorter, SQLITE_OK);\n  assert( pSorter->bUseThreads || pSorter->pReader==0 );\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pSorter->pReader ){\n    vdbePmaReaderClear(pSorter->pReader);\n    sqlite3DbFree(db, pSorter->pReader);\n    pSorter->pReader = 0;\n  }\n#endif\n  vdbeMergeEngineFree(pSorter->pMerger);\n  pSorter->pMerger = 0;\n  for(i=0; i<pSorter->nTask; i++){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    vdbeSortSubtaskCleanup(db, pTask);\n    pTask->pSorter = pSorter;\n  }\n  if( pSorter->list.aMemory==0 ){\n    vdbeSorterRecordFree(0, pSorter->list.pList);\n  }\n  pSorter->list.pList = 0;\n  pSorter->list.szPMA = 0;\n  pSorter->bUsePMA = 0;\n  pSorter->iMemory = 0;\n  pSorter->mxKeysize = 0;\n  sqlite3DbFree(db, pSorter->pUnpacked);\n  pSorter->pUnpacked = 0;\n}\n\n/*\n** Free any cursor components allocated by sqlite3VdbeSorterXXX routines.\n*/\nSQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  if( pSorter ){\n    sqlite3VdbeSorterReset(db, pSorter);\n    sqlite3_free(pSorter->list.aMemory);\n    sqlite3DbFree(db, pSorter);\n    pCsr->uc.pSorter = 0;\n  }\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** The first argument is a file-handle open on a temporary file. The file\n** is guaranteed to be nByte bytes or smaller in size. This function\n** attempts to extend the file to nByte bytes in size and to ensure that\n** the VFS has memory mapped it.\n**\n** Whether or not the file does end up memory mapped of course depends on\n** the specific VFS implementation.\n*/\nstatic void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){\n  if( nByte<=(i64)(db->nMaxSorterMmap) && pFd->pMethods->iVersion>=3 ){\n    void *p = 0;\n    int chunksize = 4*1024;\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize);\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte);\n    sqlite3OsFetch(pFd, 0, (int)nByte, &p);\n    sqlite3OsUnfetch(pFd, 0, p);\n  }\n}\n#else\n# define vdbeSorterExtendFile(x,y,z)\n#endif\n\n/*\n** Allocate space for a file-handle and open a temporary file. If successful,\n** set *ppFd to point to the malloc'd file-handle and return SQLITE_OK.\n** Otherwise, set *ppFd to 0 and return an SQLite error code.\n*/\nstatic int vdbeSorterOpenTempFile(\n  sqlite3 *db,                    /* Database handle doing sort */\n  i64 nExtend,                    /* Attempt to extend file to this size */\n  sqlite3_file **ppFd\n){\n  int rc;\n  if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;\n  rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,\n      SQLITE_OPEN_TEMP_JOURNAL |\n      SQLITE_OPEN_READWRITE    | SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE    | SQLITE_OPEN_DELETEONCLOSE, &rc\n  );\n  if( rc==SQLITE_OK ){\n    i64 max = SQLITE_MAX_MMAP_SIZE;\n    sqlite3OsFileControlHint(*ppFd, SQLITE_FCNTL_MMAP_SIZE, (void*)&max);\n    if( nExtend>0 ){\n      vdbeSorterExtendFile(db, *ppFd, nExtend);\n    }\n  }\n  return rc;\n}\n\n/*\n** If it has not already been allocated, allocate the UnpackedRecord \n** structure at pTask->pUnpacked. Return SQLITE_OK if successful (or \n** if no allocation was required), or SQLITE_NOMEM otherwise.\n*/\nstatic int vdbeSortAllocUnpacked(SortSubtask *pTask){\n  if( pTask->pUnpacked==0 ){\n    pTask->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pTask->pSorter->pKeyInfo);\n    if( pTask->pUnpacked==0 ) return SQLITE_NOMEM_BKPT;\n    pTask->pUnpacked->nField = pTask->pSorter->pKeyInfo->nKeyField;\n    pTask->pUnpacked->errCode = 0;\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Merge the two sorted lists p1 and p2 into a single list.\n*/\nstatic SorterRecord *vdbeSorterMerge(\n  SortSubtask *pTask,             /* Calling thread context */\n  SorterRecord *p1,               /* First list to merge */\n  SorterRecord *p2                /* Second list to merge */\n){\n  SorterRecord *pFinal = 0;\n  SorterRecord **pp = &pFinal;\n  int bCached = 0;\n\n  assert( p1!=0 && p2!=0 );\n  for(;;){\n    int res;\n    res = pTask->xCompare(\n        pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal\n    );\n\n    if( res<=0 ){\n      *pp = p1;\n      pp = &p1->u.pNext;\n      p1 = p1->u.pNext;\n      if( p1==0 ){\n        *pp = p2;\n        break;\n      }\n    }else{\n      *pp = p2;\n      pp = &p2->u.pNext;\n      p2 = p2->u.pNext;\n      bCached = 0;\n      if( p2==0 ){\n        *pp = p1;\n        break;\n      }\n    }\n  }\n  return pFinal;\n}\n\n/*\n** Return the SorterCompare function to compare values collected by the\n** sorter object passed as the only argument.\n*/\nstatic SorterCompare vdbeSorterGetCompare(VdbeSorter *p){\n  if( p->typeMask==SORTER_TYPE_INTEGER ){\n    return vdbeSorterCompareInt;\n  }else if( p->typeMask==SORTER_TYPE_TEXT ){\n    return vdbeSorterCompareText; \n  }\n  return vdbeSorterCompare;\n}\n\n/*\n** Sort the linked list of records headed at pTask->pList. Return \n** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if \n** an error occurs.\n*/\nstatic int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){\n  int i;\n  SorterRecord **aSlot;\n  SorterRecord *p;\n  int rc;\n\n  rc = vdbeSortAllocUnpacked(pTask);\n  if( rc!=SQLITE_OK ) return rc;\n\n  p = pList->pList;\n  pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);\n\n  aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));\n  if( !aSlot ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  while( p ){\n    SorterRecord *pNext;\n    if( pList->aMemory ){\n      if( (u8*)p==pList->aMemory ){\n        pNext = 0;\n      }else{\n        assert( p->u.iNext<sqlite3MallocSize(pList->aMemory) );\n        pNext = (SorterRecord*)&pList->aMemory[p->u.iNext];\n      }\n    }else{\n      pNext = p->u.pNext;\n    }\n\n    p->u.pNext = 0;\n    for(i=0; aSlot[i]; i++){\n      p = vdbeSorterMerge(pTask, p, aSlot[i]);\n      aSlot[i] = 0;\n    }\n    aSlot[i] = p;\n    p = pNext;\n  }\n\n  p = 0;\n  for(i=0; i<64; i++){\n    if( aSlot[i]==0 ) continue;\n    p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];\n  }\n  pList->pList = p;\n\n  sqlite3_free(aSlot);\n  assert( pTask->pUnpacked->errCode==SQLITE_OK \n       || pTask->pUnpacked->errCode==SQLITE_NOMEM \n  );\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** Initialize a PMA-writer object.\n*/\nstatic void vdbePmaWriterInit(\n  sqlite3_file *pFd,              /* File handle to write to */\n  PmaWriter *p,                   /* Object to populate */\n  int nBuf,                       /* Buffer size */\n  i64 iStart                      /* Offset of pFd to begin writing at */\n){\n  memset(p, 0, sizeof(PmaWriter));\n  p->aBuffer = (u8*)sqlite3Malloc(nBuf);\n  if( !p->aBuffer ){\n    p->eFWErr = SQLITE_NOMEM_BKPT;\n  }else{\n    p->iBufEnd = p->iBufStart = (iStart % nBuf);\n    p->iWriteOff = iStart - p->iBufStart;\n    p->nBuffer = nBuf;\n    p->pFd = pFd;\n  }\n}\n\n/*\n** Write nData bytes of data to the PMA. Return SQLITE_OK\n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteBlob(PmaWriter *p, u8 *pData, int nData){\n  int nRem = nData;\n  while( nRem>0 && p->eFWErr==0 ){\n    int nCopy = nRem;\n    if( nCopy>(p->nBuffer - p->iBufEnd) ){\n      nCopy = p->nBuffer - p->iBufEnd;\n    }\n\n    memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy);\n    p->iBufEnd += nCopy;\n    if( p->iBufEnd==p->nBuffer ){\n      p->eFWErr = sqlite3OsWrite(p->pFd, \n          &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n          p->iWriteOff + p->iBufStart\n      );\n      p->iBufStart = p->iBufEnd = 0;\n      p->iWriteOff += p->nBuffer;\n    }\n    assert( p->iBufEnd<p->nBuffer );\n\n    nRem -= nCopy;\n  }\n}\n\n/*\n** Flush any buffered data to disk and clean up the PMA-writer object.\n** The results of using the PMA-writer after this call are undefined.\n** Return SQLITE_OK if flushing the buffered data succeeds or is not \n** required. Otherwise, return an SQLite error code.\n**\n** Before returning, set *piEof to the offset immediately following the\n** last byte written to the file.\n*/\nstatic int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){\n  int rc;\n  if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){\n    p->eFWErr = sqlite3OsWrite(p->pFd, \n        &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n        p->iWriteOff + p->iBufStart\n    );\n  }\n  *piEof = (p->iWriteOff + p->iBufEnd);\n  sqlite3_free(p->aBuffer);\n  rc = p->eFWErr;\n  memset(p, 0, sizeof(PmaWriter));\n  return rc;\n}\n\n/*\n** Write value iVal encoded as a varint to the PMA. Return \n** SQLITE_OK if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteVarint(PmaWriter *p, u64 iVal){\n  int nByte; \n  u8 aByte[10];\n  nByte = sqlite3PutVarint(aByte, iVal);\n  vdbePmaWriteBlob(p, aByte, nByte);\n}\n\n/*\n** Write the current contents of in-memory linked-list pList to a level-0\n** PMA in the temp file belonging to sub-task pTask. Return SQLITE_OK if \n** successful, or an SQLite error code otherwise.\n**\n** The format of a PMA is:\n**\n**     * A varint. This varint contains the total number of bytes of content\n**       in the PMA (not including the varint itself).\n**\n**     * One or more records packed end-to-end in order of ascending keys. \n**       Each record consists of a varint followed by a blob of data (the \n**       key). The varint is the number of bytes in the blob of data.\n*/\nstatic int vdbeSorterListToPMA(SortSubtask *pTask, SorterList *pList){\n  sqlite3 *db = pTask->pSorter->db;\n  int rc = SQLITE_OK;             /* Return code */\n  PmaWriter writer;               /* Object used to write to the file */\n\n#ifdef SQLITE_DEBUG\n  /* Set iSz to the expected size of file pTask->file after writing the PMA. \n  ** This is used by an assert() statement at the end of this function.  */\n  i64 iSz = pList->szPMA + sqlite3VarintLen(pList->szPMA) + pTask->file.iEof;\n#endif\n\n  vdbeSorterWorkDebug(pTask, \"enter\");\n  memset(&writer, 0, sizeof(PmaWriter));\n  assert( pList->szPMA>0 );\n\n  /* If the first temporary PMA file has not been opened, open it now. */\n  if( pTask->file.pFd==0 ){\n    rc = vdbeSorterOpenTempFile(db, 0, &pTask->file.pFd);\n    assert( rc!=SQLITE_OK || pTask->file.pFd );\n    assert( pTask->file.iEof==0 );\n    assert( pTask->nPMA==0 );\n  }\n\n  /* Try to get the file to memory map */\n  if( rc==SQLITE_OK ){\n    vdbeSorterExtendFile(db, pTask->file.pFd, pTask->file.iEof+pList->szPMA+9);\n  }\n\n  /* Sort the list */\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSort(pTask, pList);\n  }\n\n  if( rc==SQLITE_OK ){\n    SorterRecord *p;\n    SorterRecord *pNext = 0;\n\n    vdbePmaWriterInit(pTask->file.pFd, &writer, pTask->pSorter->pgsz,\n                      pTask->file.iEof);\n    pTask->nPMA++;\n    vdbePmaWriteVarint(&writer, pList->szPMA);\n    for(p=pList->pList; p; p=pNext){\n      pNext = p->u.pNext;\n      vdbePmaWriteVarint(&writer, p->nVal);\n      vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);\n      if( pList->aMemory==0 ) sqlite3_free(p);\n    }\n    pList->pList = p;\n    rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);\n  }\n\n  vdbeSorterWorkDebug(pTask, \"exit\");\n  assert( rc!=SQLITE_OK || pList->pList==0 );\n  assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );\n  return rc;\n}\n\n/*\n** Advance the MergeEngine to its next entry.\n** Set *pbEof to true there is no next entry because\n** the MergeEngine has reached the end of all its inputs.\n**\n** Return SQLITE_OK if successful or an error code if an error occurs.\n*/\nstatic int vdbeMergeEngineStep(\n  MergeEngine *pMerger,      /* The merge engine to advance to the next row */\n  int *pbEof                 /* Set TRUE at EOF.  Set false for more content */\n){\n  int rc;\n  int iPrev = pMerger->aTree[1];/* Index of PmaReader to advance */\n  SortSubtask *pTask = pMerger->pTask;\n\n  /* Advance the current PmaReader */\n  rc = vdbePmaReaderNext(&pMerger->aReadr[iPrev]);\n\n  /* Update contents of aTree[] */\n  if( rc==SQLITE_OK ){\n    int i;                      /* Index of aTree[] to recalculate */\n    PmaReader *pReadr1;         /* First PmaReader to compare */\n    PmaReader *pReadr2;         /* Second PmaReader to compare */\n    int bCached = 0;\n\n    /* Find the first two PmaReaders to compare. The one that was just\n    ** advanced (iPrev) and the one next to it in the array.  */\n    pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];\n    pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];\n\n    for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){\n      /* Compare pReadr1 and pReadr2. Store the result in variable iRes. */\n      int iRes;\n      if( pReadr1->pFd==0 ){\n        iRes = +1;\n      }else if( pReadr2->pFd==0 ){\n        iRes = -1;\n      }else{\n        iRes = pTask->xCompare(pTask, &bCached,\n            pReadr1->aKey, pReadr1->nKey, pReadr2->aKey, pReadr2->nKey\n        );\n      }\n\n      /* If pReadr1 contained the smaller value, set aTree[i] to its index.\n      ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this\n      ** case there is no cache of pReadr2 in pTask->pUnpacked, so set\n      ** pKey2 to point to the record belonging to pReadr2.\n      **\n      ** Alternatively, if pReadr2 contains the smaller of the two values,\n      ** set aTree[i] to its index and update pReadr1. If vdbeSorterCompare()\n      ** was actually called above, then pTask->pUnpacked now contains\n      ** a value equivalent to pReadr2. So set pKey2 to NULL to prevent\n      ** vdbeSorterCompare() from decoding pReadr2 again.\n      **\n      ** If the two values were equal, then the value from the oldest\n      ** PMA should be considered smaller. The VdbeSorter.aReadr[] array\n      ** is sorted from oldest to newest, so pReadr1 contains older values\n      ** than pReadr2 iff (pReadr1<pReadr2).  */\n      if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){\n        pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);\n        pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n        bCached = 0;\n      }else{\n        if( pReadr1->pFd ) bCached = 0;\n        pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);\n        pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n      }\n    }\n    *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);\n  }\n\n  return (rc==SQLITE_OK ? pTask->pUnpacked->errCode : rc);\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that write level-0 PMAs.\n*/\nstatic void *vdbeSorterFlushThread(void *pCtx){\n  SortSubtask *pTask = (SortSubtask*)pCtx;\n  int rc;                         /* Return code */\n  assert( pTask->bDone==0 );\n  rc = vdbeSorterListToPMA(pTask, &pTask->list);\n  pTask->bDone = 1;\n  return SQLITE_INT_TO_PTR(rc);\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n/*\n** Flush the current contents of VdbeSorter.list to a new PMA, possibly\n** using a background thread.\n*/\nstatic int vdbeSorterFlushPMA(VdbeSorter *pSorter){\n#if SQLITE_MAX_WORKER_THREADS==0\n  pSorter->bUsePMA = 1;\n  return vdbeSorterListToPMA(&pSorter->aTask[0], &pSorter->list);\n#else\n  int rc = SQLITE_OK;\n  int i;\n  SortSubtask *pTask = 0;    /* Thread context used to create new PMA */\n  int nWorker = (pSorter->nTask-1);\n\n  /* Set the flag to indicate that at least one PMA has been written. \n  ** Or will be, anyhow.  */\n  pSorter->bUsePMA = 1;\n\n  /* Select a sub-task to sort and flush the current list of in-memory\n  ** records to disk. If the sorter is running in multi-threaded mode,\n  ** round-robin between the first (pSorter->nTask-1) tasks. Except, if\n  ** the background thread from a sub-tasks previous turn is still running,\n  ** skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy,\n  ** fall back to using the final sub-task. The first (pSorter->nTask-1)\n  ** sub-tasks are prefered as they use background threads - the final \n  ** sub-task uses the main thread. */\n  for(i=0; i<nWorker; i++){\n    int iTest = (pSorter->iPrev + i + 1) % nWorker;\n    pTask = &pSorter->aTask[iTest];\n    if( pTask->bDone ){\n      rc = vdbeSorterJoinThread(pTask);\n    }\n    if( rc!=SQLITE_OK || pTask->pThread==0 ) break;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( i==nWorker ){\n      /* Use the foreground thread for this operation */\n      rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);\n    }else{\n      /* Launch a background thread for this operation */\n      u8 *aMem = pTask->list.aMemory;\n      void *pCtx = (void*)pTask;\n\n      assert( pTask->pThread==0 && pTask->bDone==0 );\n      assert( pTask->list.pList==0 );\n      assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );\n\n      pSorter->iPrev = (u8)(pTask - pSorter->aTask);\n      pTask->list = pSorter->list;\n      pSorter->list.pList = 0;\n      pSorter->list.szPMA = 0;\n      if( aMem ){\n        pSorter->list.aMemory = aMem;\n        pSorter->nMemory = sqlite3MallocSize(aMem);\n      }else if( pSorter->list.aMemory ){\n        pSorter->list.aMemory = sqlite3Malloc(pSorter->nMemory);\n        if( !pSorter->list.aMemory ) return SQLITE_NOMEM_BKPT;\n      }\n\n      rc = vdbeSorterCreateThread(pTask, vdbeSorterFlushThread, pCtx);\n    }\n  }\n\n  return rc;\n#endif /* SQLITE_MAX_WORKER_THREADS!=0 */\n}\n\n/*\n** Add a record to the sorter.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterWrite(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal                       /* Memory cell containing record */\n){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return Code */\n  SorterRecord *pNew;             /* New list element */\n  int bFlush;                     /* True to flush contents of memory to PMA */\n  int nReq;                       /* Bytes of memory required */\n  int nPMA;                       /* Bytes of PMA space required */\n  int t;                          /* serial type of first record field */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  getVarint32((const u8*)&pVal->z[1], t);\n  if( t>0 && t<10 && t!=7 ){\n    pSorter->typeMask &= SORTER_TYPE_INTEGER;\n  }else if( t>10 && (t & 0x01) ){\n    pSorter->typeMask &= SORTER_TYPE_TEXT;\n  }else{\n    pSorter->typeMask = 0;\n  }\n\n  assert( pSorter );\n\n  /* Figure out whether or not the current contents of memory should be\n  ** flushed to a PMA before continuing. If so, do so.\n  **\n  ** If using the single large allocation mode (pSorter->aMemory!=0), then\n  ** flush the contents of memory to a new PMA if (a) at least one value is\n  ** already in memory and (b) the new value will not fit in memory.\n  ** \n  ** Or, if using separate allocations for each record, flush the contents\n  ** of memory to a PMA if either of the following are true:\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * cache-size), or\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * 10) and sqlite3HeapNearlyFull() returns true.\n  */\n  nReq = pVal->n + sizeof(SorterRecord);\n  nPMA = pVal->n + sqlite3VarintLen(pVal->n);\n  if( pSorter->mxPmaSize ){\n    if( pSorter->list.aMemory ){\n      bFlush = pSorter->iMemory && (pSorter->iMemory+nReq) > pSorter->mxPmaSize;\n    }else{\n      bFlush = (\n          (pSorter->list.szPMA > pSorter->mxPmaSize)\n       || (pSorter->list.szPMA > pSorter->mnPmaSize && sqlite3HeapNearlyFull())\n      );\n    }\n    if( bFlush ){\n      rc = vdbeSorterFlushPMA(pSorter);\n      pSorter->list.szPMA = 0;\n      pSorter->iMemory = 0;\n      assert( rc!=SQLITE_OK || pSorter->list.pList==0 );\n    }\n  }\n\n  pSorter->list.szPMA += nPMA;\n  if( nPMA>pSorter->mxKeysize ){\n    pSorter->mxKeysize = nPMA;\n  }\n\n  if( pSorter->list.aMemory ){\n    int nMin = pSorter->iMemory + nReq;\n\n    if( nMin>pSorter->nMemory ){\n      u8 *aNew;\n      int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;\n      int nNew = pSorter->nMemory * 2;\n      while( nNew < nMin ) nNew = nNew*2;\n      if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize;\n      if( nNew < nMin ) nNew = nMin;\n\n      aNew = sqlite3Realloc(pSorter->list.aMemory, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      pSorter->list.pList = (SorterRecord*)&aNew[iListOff];\n      pSorter->list.aMemory = aNew;\n      pSorter->nMemory = nNew;\n    }\n\n    pNew = (SorterRecord*)&pSorter->list.aMemory[pSorter->iMemory];\n    pSorter->iMemory += ROUND8(nReq);\n    if( pSorter->list.pList ){\n      pNew->u.iNext = (int)((u8*)(pSorter->list.pList) - pSorter->list.aMemory);\n    }\n  }else{\n    pNew = (SorterRecord *)sqlite3Malloc(nReq);\n    if( pNew==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pNew->u.pNext = pSorter->list.pList;\n  }\n\n  memcpy(SRVAL(pNew), pVal->z, pVal->n);\n  pNew->nVal = pVal->n;\n  pSorter->list.pList = pNew;\n\n  return rc;\n}\n\n/*\n** Read keys from pIncr->pMerger and populate pIncr->aFile[1]. The format\n** of the data stored in aFile[1] is the same as that used by regular PMAs,\n** except that the number-of-bytes varint is omitted from the start.\n*/\nstatic int vdbeIncrPopulate(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n  int rc2;\n  i64 iStart = pIncr->iStartOff;\n  SorterFile *pOut = &pIncr->aFile[1];\n  SortSubtask *pTask = pIncr->pTask;\n  MergeEngine *pMerger = pIncr->pMerger;\n  PmaWriter writer;\n  assert( pIncr->bEof==0 );\n\n  vdbeSorterPopulateDebug(pTask, \"enter\");\n\n  vdbePmaWriterInit(pOut->pFd, &writer, pTask->pSorter->pgsz, iStart);\n  while( rc==SQLITE_OK ){\n    int dummy;\n    PmaReader *pReader = &pMerger->aReadr[ pMerger->aTree[1] ];\n    int nKey = pReader->nKey;\n    i64 iEof = writer.iWriteOff + writer.iBufEnd;\n\n    /* Check if the output file is full or if the input has been exhausted.\n    ** In either case exit the loop. */\n    if( pReader->pFd==0 ) break;\n    if( (iEof + nKey + sqlite3VarintLen(nKey))>(iStart + pIncr->mxSz) ) break;\n\n    /* Write the next key to the output. */\n    vdbePmaWriteVarint(&writer, nKey);\n    vdbePmaWriteBlob(&writer, pReader->aKey, nKey);\n    assert( pIncr->pMerger->pTask==pTask );\n    rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);\n  }\n\n  rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);\n  if( rc==SQLITE_OK ) rc = rc2;\n  vdbeSorterPopulateDebug(pTask, \"exit\");\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that populate aFile[1] of\n** multi-threaded IncrMerger objects.\n*/\nstatic void *vdbeIncrPopulateThread(void *pCtx){\n  IncrMerger *pIncr = (IncrMerger*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR( vdbeIncrPopulate(pIncr) );\n  pIncr->pTask->bDone = 1;\n  return pRet;\n}\n\n/*\n** Launch a background thread to populate aFile[1] of pIncr.\n*/\nstatic int vdbeIncrBgPopulate(IncrMerger *pIncr){\n  void *p = (void*)pIncr;\n  assert( pIncr->bUseThread );\n  return vdbeSorterCreateThread(pIncr->pTask, vdbeIncrPopulateThread, p);\n}\n#endif\n\n/*\n** This function is called when the PmaReader corresponding to pIncr has\n** finished reading the contents of aFile[0]. Its purpose is to \"refill\"\n** aFile[0] such that the PmaReader should start rereading it from the\n** beginning.\n**\n** For single-threaded objects, this is accomplished by literally reading \n** keys from pIncr->pMerger and repopulating aFile[0]. \n**\n** For multi-threaded objects, all that is required is to wait until the \n** background thread is finished (if it is not already) and then swap \n** aFile[0] and aFile[1] in place. If the contents of pMerger have not\n** been exhausted, this function also launches a new background thread\n** to populate the new aFile[1].\n**\n** SQLITE_OK is returned on success, or an SQLite error code otherwise.\n*/\nstatic int vdbeIncrSwap(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pIncr->bUseThread ){\n    rc = vdbeSorterJoinThread(pIncr->pTask);\n\n    if( rc==SQLITE_OK ){\n      SorterFile f0 = pIncr->aFile[0];\n      pIncr->aFile[0] = pIncr->aFile[1];\n      pIncr->aFile[1] = f0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n        pIncr->bEof = 1;\n      }else{\n        rc = vdbeIncrBgPopulate(pIncr);\n      }\n    }\n  }else\n#endif\n  {\n    rc = vdbeIncrPopulate(pIncr);\n    pIncr->aFile[0] = pIncr->aFile[1];\n    if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n      pIncr->bEof = 1;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and return a new IncrMerger object to read data from pMerger.\n**\n** If an OOM condition is encountered, return NULL. In this case free the\n** pMerger argument before returning.\n*/\nstatic int vdbeIncrMergerNew(\n  SortSubtask *pTask,     /* The thread that will be using the new IncrMerger */\n  MergeEngine *pMerger,   /* The MergeEngine that the IncrMerger will control */\n  IncrMerger **ppOut      /* Write the new IncrMerger here */\n){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = *ppOut = (IncrMerger*)\n       (sqlite3FaultSim(100) ? 0 : sqlite3MallocZero(sizeof(*pIncr)));\n  if( pIncr ){\n    pIncr->pMerger = pMerger;\n    pIncr->pTask = pTask;\n    pIncr->mxSz = MAX(pTask->pSorter->mxKeysize+9,pTask->pSorter->mxPmaSize/2);\n    pTask->file2.iEof += pIncr->mxSz;\n  }else{\n    vdbeMergeEngineFree(pMerger);\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Set the \"use-threads\" flag on object pIncr.\n*/\nstatic void vdbeIncrMergerSetThreads(IncrMerger *pIncr){\n  pIncr->bUseThread = 1;\n  pIncr->pTask->file2.iEof -= pIncr->mxSz;\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n\n\n/*\n** Recompute pMerger->aTree[iOut] by comparing the next keys on the\n** two PmaReaders that feed that entry.  Neither of the PmaReaders\n** are advanced.  This routine merely does the comparison.\n*/\nstatic void vdbeMergeEngineCompare(\n  MergeEngine *pMerger,  /* Merge engine containing PmaReaders to compare */\n  int iOut               /* Store the result in pMerger->aTree[iOut] */\n){\n  int i1;\n  int i2;\n  int iRes;\n  PmaReader *p1;\n  PmaReader *p2;\n\n  assert( iOut<pMerger->nTree && iOut>0 );\n\n  if( iOut>=(pMerger->nTree/2) ){\n    i1 = (iOut - pMerger->nTree/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pMerger->aTree[iOut*2];\n    i2 = pMerger->aTree[iOut*2+1];\n  }\n\n  p1 = &pMerger->aReadr[i1];\n  p2 = &pMerger->aReadr[i2];\n\n  if( p1->pFd==0 ){\n    iRes = i2;\n  }else if( p2->pFd==0 ){\n    iRes = i1;\n  }else{\n    SortSubtask *pTask = pMerger->pTask;\n    int bCached = 0;\n    int res;\n    assert( pTask->pUnpacked!=0 );  /* from vdbeSortSubtaskMain() */\n    res = pTask->xCompare(\n        pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey\n    );\n    if( res<=0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pMerger->aTree[iOut] = iRes;\n}\n\n/*\n** Allowed values for the eMode parameter to vdbeMergeEngineInit()\n** and vdbePmaReaderIncrMergeInit().\n**\n** Only INCRINIT_NORMAL is valid in single-threaded builds (when\n** SQLITE_MAX_WORKER_THREADS==0).  The other values are only used\n** when there exists one or more separate worker threads.\n*/\n#define INCRINIT_NORMAL 0\n#define INCRINIT_TASK   1\n#define INCRINIT_ROOT   2\n\n/* \n** Forward reference required as the vdbeIncrMergeInit() and\n** vdbePmaReaderIncrInit() routines are called mutually recursively when\n** building a merge tree.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode);\n\n/*\n** Initialize the MergeEngine object passed as the second argument. Once this\n** function returns, the first key of merged data may be read from the \n** MergeEngine object in the usual fashion.\n**\n** If argument eMode is INCRINIT_ROOT, then it is assumed that any IncrMerge\n** objects attached to the PmaReader objects that the merger reads from have\n** already been populated, but that they have not yet populated aFile[0] and\n** set the PmaReader objects up to read from it. In this case all that is\n** required is to call vdbePmaReaderNext() on each PmaReader to point it at\n** its first key.\n**\n** Otherwise, if eMode is any value other than INCRINIT_ROOT, then use \n** vdbePmaReaderIncrMergeInit() to initialize each PmaReader that feeds data \n** to pMerger.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeMergeEngineInit(\n  SortSubtask *pTask,             /* Thread that will run pMerger */\n  MergeEngine *pMerger,           /* MergeEngine to initialize */\n  int eMode                       /* One of the INCRINIT_XXX constants */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* For looping over PmaReader objects */\n  int nTree = pMerger->nTree;\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  /* Verify that the MergeEngine is assigned to a single thread */\n  assert( pMerger->pTask==0 );\n  pMerger->pTask = pTask;\n\n  for(i=0; i<nTree; i++){\n    if( SQLITE_MAX_WORKER_THREADS>0 && eMode==INCRINIT_ROOT ){\n      /* PmaReaders should be normally initialized in order, as if they are\n      ** reading from the same temp file this makes for more linear file IO.\n      ** However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is\n      ** in use it will block the vdbePmaReaderNext() call while it uses\n      ** the main thread to fill its buffer. So calling PmaReaderNext()\n      ** on this PmaReader before any of the multi-threaded PmaReaders takes\n      ** better advantage of multi-processor hardware. */\n      rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);\n    }else{\n      rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  for(i=pMerger->nTree-1; i>0; i--){\n    vdbeMergeEngineCompare(pMerger, i);\n  }\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** The PmaReader passed as the first argument is guaranteed to be an\n** incremental-reader (pReadr->pIncr!=0). This function serves to open\n** and/or initialize the temp file related fields of the IncrMerge\n** object at (pReadr->pIncr).\n**\n** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders\n** in the sub-tree headed by pReadr are also initialized. Data is then \n** loaded into the buffers belonging to pReadr and it is set to point to \n** the first key in its range.\n**\n** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed\n** to be a multi-threaded PmaReader and this function is being called in a\n** background thread. In this case all PmaReaders in the sub-tree are \n** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to\n** pReadr is populated. However, pReadr itself is not set up to point\n** to its first key. A call to vdbePmaReaderNext() is still required to do\n** that. \n**\n** The reason this function does not call vdbePmaReaderNext() immediately \n** in the INCRINIT_TASK case is that vdbePmaReaderNext() assumes that it has\n** to block on thread (pTask->thread) before accessing aFile[1]. But, since\n** this entire function is being run by thread (pTask->thread), that will\n** lead to the current background thread attempting to join itself.\n**\n** Finally, if argument eMode is set to INCRINIT_ROOT, it may be assumed\n** that pReadr->pIncr is a multi-threaded IncrMerge objects, and that all\n** child-trees have already been initialized using IncrInit(INCRINIT_TASK).\n** In this case vdbePmaReaderNext() is called on all child PmaReaders and\n** the current PmaReader set to point to the first key in its range.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = pReadr->pIncr;\n  SortSubtask *pTask = pIncr->pTask;\n  sqlite3 *db = pTask->pSorter->db;\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);\n\n  /* Set up the required files for pIncr. A multi-theaded IncrMerge object\n  ** requires two temp files to itself, whereas a single-threaded object\n  ** only requires a region of pTask->file2. */\n  if( rc==SQLITE_OK ){\n    int mxSz = pIncr->mxSz;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);\n      if( rc==SQLITE_OK ){\n        rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);\n      }\n    }else\n#endif\n    /*if( !pIncr->bUseThread )*/{\n      if( pTask->file2.pFd==0 ){\n        assert( pTask->file2.iEof>0 );\n        rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);\n        pTask->file2.iEof = 0;\n      }\n      if( rc==SQLITE_OK ){\n        pIncr->aFile[1].pFd = pTask->file2.pFd;\n        pIncr->iStartOff = pTask->file2.iEof;\n        pTask->file2.iEof += mxSz;\n      }\n    }\n  }\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( rc==SQLITE_OK && pIncr->bUseThread ){\n    /* Use the current thread to populate aFile[1], even though this\n    ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,\n    ** then this function is already running in background thread \n    ** pIncr->pTask->thread. \n    **\n    ** If this is the INCRINIT_ROOT object, then it is running in the \n    ** main VDBE thread. But that is Ok, as that thread cannot return\n    ** control to the VDBE or proceed with anything useful until the \n    ** first results are ready from this merger object anyway.\n    */\n    assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );\n    rc = vdbeIncrPopulate(pIncr);\n  }\n#endif\n\n  if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for vdbePmaReaderIncrMergeInit() operations run in \n** background threads.\n*/\nstatic void *vdbePmaReaderBgIncrInit(void *pCtx){\n  PmaReader *pReader = (PmaReader*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR(\n                  vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)\n               );\n  pReader->pIncr->pTask->bDone = 1;\n  return pRet;\n}\n#endif\n\n/*\n** If the PmaReader passed as the first argument is not an incremental-reader\n** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes\n** the vdbePmaReaderIncrMergeInit() function with the parameters passed to\n** this routine to initialize the incremental merge.\n** \n** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1), \n** then a background thread is launched to call vdbePmaReaderIncrMergeInit().\n** Or, if the IncrMerger is single threaded, the same function is called\n** using the current thread.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){\n  IncrMerger *pIncr = pReadr->pIncr;   /* Incremental merger */\n  int rc = SQLITE_OK;                  /* Return code */\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    assert( pIncr->bUseThread==0 || eMode==INCRINIT_TASK );\n    if( pIncr->bUseThread ){\n      void *pCtx = (void*)pReadr;\n      rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);\n    }else\n#endif\n    {\n      rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Allocate a new MergeEngine object to merge the contents of nPMA level-0\n** PMAs from pTask->file. If no error occurs, set *ppOut to point to\n** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut\n** to NULL and return an SQLite error code.\n**\n** When this function is called, *piOffset is set to the offset of the\n** first PMA to read from pTask->file. Assuming no error occurs, it is \n** set to the offset immediately following the last byte of the last\n** PMA before returning. If an error does occur, then the final value of\n** *piOffset is undefined.\n*/\nstatic int vdbeMergeEngineLevel0(\n  SortSubtask *pTask,             /* Sorter task to read from */\n  int nPMA,                       /* Number of PMAs to read */\n  i64 *piOffset,                  /* IN/OUT: Readr offset in pTask->file */\n  MergeEngine **ppOut             /* OUT: New merge-engine */\n){\n  MergeEngine *pNew;              /* Merge engine to return */\n  i64 iOff = *piOffset;\n  int i;\n  int rc = SQLITE_OK;\n\n  *ppOut = pNew = vdbeMergeEngineNew(nPMA);\n  if( pNew==0 ) rc = SQLITE_NOMEM_BKPT;\n\n  for(i=0; i<nPMA && rc==SQLITE_OK; i++){\n    i64 nDummy = 0;\n    PmaReader *pReadr = &pNew->aReadr[i];\n    rc = vdbePmaReaderInit(pTask, &pTask->file, iOff, pReadr, &nDummy);\n    iOff = pReadr->iEof;\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pNew);\n    *ppOut = 0;\n  }\n  *piOffset = iOff;\n  return rc;\n}\n\n/*\n** Return the depth of a tree comprising nPMA PMAs, assuming a fanout of\n** SORTER_MAX_MERGE_COUNT. The returned value does not include leaf nodes.\n**\n** i.e.\n**\n**   nPMA<=16    -> TreeDepth() == 0\n**   nPMA<=256   -> TreeDepth() == 1\n**   nPMA<=65536 -> TreeDepth() == 2\n*/\nstatic int vdbeSorterTreeDepth(int nPMA){\n  int nDepth = 0;\n  i64 nDiv = SORTER_MAX_MERGE_COUNT;\n  while( nDiv < (i64)nPMA ){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n    nDepth++;\n  }\n  return nDepth;\n}\n\n/*\n** pRoot is the root of an incremental merge-tree with depth nDepth (according\n** to vdbeSorterTreeDepth()). pLeaf is the iSeq'th leaf to be added to the\n** tree, counting from zero. This function adds pLeaf to the tree.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, an SQLite error\n** code is returned and pLeaf is freed.\n*/\nstatic int vdbeSorterAddToTree(\n  SortSubtask *pTask,             /* Task context */\n  int nDepth,                     /* Depth of tree according to TreeDepth() */\n  int iSeq,                       /* Sequence number of leaf within tree */\n  MergeEngine *pRoot,             /* Root of tree */\n  MergeEngine *pLeaf              /* Leaf to add to tree */\n){\n  int rc = SQLITE_OK;\n  int nDiv = 1;\n  int i;\n  MergeEngine *p = pRoot;\n  IncrMerger *pIncr;\n\n  rc = vdbeIncrMergerNew(pTask, pLeaf, &pIncr);\n\n  for(i=1; i<nDepth; i++){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n  }\n\n  for(i=1; i<nDepth && rc==SQLITE_OK; i++){\n    int iIter = (iSeq / nDiv) % SORTER_MAX_MERGE_COUNT;\n    PmaReader *pReadr = &p->aReadr[iIter];\n\n    if( pReadr->pIncr==0 ){\n      MergeEngine *pNew = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        rc = vdbeIncrMergerNew(pTask, pNew, &pReadr->pIncr);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      p = pReadr->pIncr->pMerger;\n      nDiv = nDiv / SORTER_MAX_MERGE_COUNT;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    p->aReadr[iSeq % SORTER_MAX_MERGE_COUNT].pIncr = pIncr;\n  }else{\n    vdbeIncrFree(pIncr);\n  }\n  return rc;\n}\n\n/*\n** This function is called as part of a SorterRewind() operation on a sorter\n** that has already written two or more level-0 PMAs to one or more temp\n** files. It builds a tree of MergeEngine/IncrMerger/PmaReader objects that \n** can be used to incrementally merge all PMAs on disk.\n**\n** If successful, SQLITE_OK is returned and *ppOut set to point to the\n** MergeEngine object at the root of the tree before returning. Or, if an\n** error occurs, an SQLite error code is returned and the final value \n** of *ppOut is undefined.\n*/\nstatic int vdbeSorterMergeTreeBuild(\n  VdbeSorter *pSorter,       /* The VDBE cursor that implements the sort */\n  MergeEngine **ppOut        /* Write the MergeEngine here */\n){\n  MergeEngine *pMain = 0;\n  int rc = SQLITE_OK;\n  int iTask;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* If the sorter uses more than one task, then create the top-level \n  ** MergeEngine here. This MergeEngine will read data from exactly \n  ** one PmaReader per sub-task.  */\n  assert( pSorter->bUseThreads || pSorter->nTask==1 );\n  if( pSorter->nTask>1 ){\n    pMain = vdbeMergeEngineNew(pSorter->nTask);\n    if( pMain==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n    SortSubtask *pTask = &pSorter->aTask[iTask];\n    assert( pTask->nPMA>0 || SQLITE_MAX_WORKER_THREADS>0 );\n    if( SQLITE_MAX_WORKER_THREADS==0 || pTask->nPMA ){\n      MergeEngine *pRoot = 0;     /* Root node of tree for this task */\n      int nDepth = vdbeSorterTreeDepth(pTask->nPMA);\n      i64 iReadOff = 0;\n\n      if( pTask->nPMA<=SORTER_MAX_MERGE_COUNT ){\n        rc = vdbeMergeEngineLevel0(pTask, pTask->nPMA, &iReadOff, &pRoot);\n      }else{\n        int i;\n        int iSeq = 0;\n        pRoot = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n        if( pRoot==0 ) rc = SQLITE_NOMEM_BKPT;\n        for(i=0; i<pTask->nPMA && rc==SQLITE_OK; i += SORTER_MAX_MERGE_COUNT){\n          MergeEngine *pMerger = 0; /* New level-0 PMA merger */\n          int nReader;              /* Number of level-0 PMAs to merge */\n\n          nReader = MIN(pTask->nPMA - i, SORTER_MAX_MERGE_COUNT);\n          rc = vdbeMergeEngineLevel0(pTask, nReader, &iReadOff, &pMerger);\n          if( rc==SQLITE_OK ){\n            rc = vdbeSorterAddToTree(pTask, nDepth, iSeq++, pRoot, pMerger);\n          }\n        }\n      }\n\n      if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS>0\n        if( pMain!=0 ){\n          rc = vdbeIncrMergerNew(pTask, pRoot, &pMain->aReadr[iTask].pIncr);\n        }else\n#endif\n        {\n          assert( pMain==0 );\n          pMain = pRoot;\n        }\n      }else{\n        vdbeMergeEngineFree(pRoot);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n    pMain = 0;\n  }\n  *ppOut = pMain;\n  return rc;\n}\n\n/*\n** This function is called as part of an sqlite3VdbeSorterRewind() operation\n** on a sorter that has written two or more PMAs to temporary files. It sets\n** up either VdbeSorter.pMerger (for single threaded sorters) or pReader\n** (for multi-threaded sorters) so that it can be used to iterate through\n** all records stored in the sorter.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeSorterSetupMerge(VdbeSorter *pSorter){\n  int rc;                         /* Return code */\n  SortSubtask *pTask0 = &pSorter->aTask[0];\n  MergeEngine *pMain = 0;\n#if SQLITE_MAX_WORKER_THREADS\n  sqlite3 *db = pTask0->pSorter->db;\n  int i;\n  SorterCompare xCompare = vdbeSorterGetCompare(pSorter);\n  for(i=0; i<pSorter->nTask; i++){\n    pSorter->aTask[i].xCompare = xCompare;\n  }\n#endif\n\n  rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);\n  if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS\n    assert( pSorter->bUseThreads==0 || pSorter->nTask>1 );\n    if( pSorter->bUseThreads ){\n      int iTask;\n      PmaReader *pReadr = 0;\n      SortSubtask *pLast = &pSorter->aTask[pSorter->nTask-1];\n      rc = vdbeSortAllocUnpacked(pLast);\n      if( rc==SQLITE_OK ){\n        pReadr = (PmaReader*)sqlite3DbMallocZero(db, sizeof(PmaReader));\n        pSorter->pReader = pReadr;\n        if( pReadr==0 ) rc = SQLITE_NOMEM_BKPT;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbeIncrMergerNew(pLast, pMain, &pReadr->pIncr);\n        if( rc==SQLITE_OK ){\n          vdbeIncrMergerSetThreads(pReadr->pIncr);\n          for(iTask=0; iTask<(pSorter->nTask-1); iTask++){\n            IncrMerger *pIncr;\n            if( (pIncr = pMain->aReadr[iTask].pIncr) ){\n              vdbeIncrMergerSetThreads(pIncr);\n              assert( pIncr->pTask!=pLast );\n            }\n          }\n          for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n            /* Check that:\n            **   \n            **   a) The incremental merge object is configured to use the\n            **      right task, and\n            **   b) If it is using task (nTask-1), it is configured to run\n            **      in single-threaded mode. This is important, as the\n            **      root merge (INCRINIT_ROOT) will be using the same task\n            **      object.\n            */\n            PmaReader *p = &pMain->aReadr[iTask];\n            assert( p->pIncr==0 || (\n                (p->pIncr->pTask==&pSorter->aTask[iTask])             /* a */\n             && (iTask!=pSorter->nTask-1 || p->pIncr->bUseThread==0)  /* b */\n            ));\n            rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);\n          }\n        }\n        pMain = 0;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbePmaReaderIncrMergeInit(pReadr, INCRINIT_ROOT);\n      }\n    }else\n#endif\n    {\n      rc = vdbeMergeEngineInit(pTask0, pMain, INCRINIT_NORMAL);\n      pSorter->pMerger = pMain;\n      pMain = 0;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n  }\n  return rc;\n}\n\n\n/*\n** Once the sorter has been populated by calls to sqlite3VdbeSorterWrite,\n** this function is called to prepare for iterating through the records\n** in sorted order.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRewind(const VdbeCursor *pCsr, int *pbEof){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter );\n\n  /* If no data has been written to disk, then do not do so now. Instead,\n  ** sort the VdbeSorter.pRecord list. The vdbe layer will read data directly\n  ** from the in-memory list.  */\n  if( pSorter->bUsePMA==0 ){\n    if( pSorter->list.pList ){\n      *pbEof = 0;\n      rc = vdbeSorterSort(&pSorter->aTask[0], &pSorter->list);\n    }else{\n      *pbEof = 1;\n    }\n    return rc;\n  }\n\n  /* Write the current in-memory list to a PMA. When the VdbeSorterWrite() \n  ** function flushes the contents of memory to disk, it immediately always\n  ** creates a new list consisting of a single key immediately afterwards.\n  ** So the list is never empty at this point.  */\n  assert( pSorter->list.pList );\n  rc = vdbeSorterFlushPMA(pSorter);\n\n  /* Join all threads */\n  rc = vdbeSorterJoinAll(pSorter, rc);\n\n  vdbeSorterRewindDebug(\"rewind\");\n\n  /* Assuming no errors have occurred, set up a merger structure to \n  ** incrementally read and merge all remaining PMAs.  */\n  assert( pSorter->pReader==0 );\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSetupMerge(pSorter);\n    *pbEof = 0;\n  }\n\n  vdbeSorterRewindDebug(\"rewinddone\");\n  return rc;\n}\n\n/*\n** Advance to the next element in the sorter.  Return value:\n**\n**    SQLITE_OK     success\n**    SQLITE_DONE   end of data\n**    otherwise     some kind of error.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  int rc;                         /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter->bUsePMA || (pSorter->pReader==0 && pSorter->pMerger==0) );\n  if( pSorter->bUsePMA ){\n    assert( pSorter->pReader==0 || pSorter->pMerger==0 );\n    assert( pSorter->bUseThreads==0 || pSorter->pReader );\n    assert( pSorter->bUseThreads==1 || pSorter->pMerger );\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      rc = vdbePmaReaderNext(pSorter->pReader);\n      if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/ {\n      int res = 0;\n      assert( pSorter->pMerger!=0 );\n      assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );\n      rc = vdbeMergeEngineStep(pSorter->pMerger, &res);\n      if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;\n    }\n  }else{\n    SorterRecord *pFree = pSorter->list.pList;\n    pSorter->list.pList = pFree->u.pNext;\n    pFree->u.pNext = 0;\n    if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);\n    rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to a buffer owned by the sorter that contains the \n** current key.\n*/\nstatic void *vdbeSorterRowkey(\n  const VdbeSorter *pSorter,      /* Sorter object */\n  int *pnKey                      /* OUT: Size of current key in bytes */\n){\n  void *pKey;\n  if( pSorter->bUsePMA ){\n    PmaReader *pReader;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      pReader = pSorter->pReader;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/{\n      pReader = &pSorter->pMerger->aReadr[pSorter->pMerger->aTree[1]];\n    }\n    *pnKey = pReader->nKey;\n    pKey = pReader->aKey;\n  }else{\n    *pnKey = pSorter->list.pList->nVal;\n    pKey = SRVAL(pSorter->list.pList);\n  }\n  return pKey;\n}\n\n/*\n** Copy the current sorter key into the memory cell pOut.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *pOut){\n  VdbeSorter *pSorter;\n  void *pKey; int nKey;           /* Sorter key to copy into pOut */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  if( sqlite3VdbeMemClearAndResize(pOut, nKey) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pOut->n = nKey;\n  MemSetTypeFlag(pOut, MEM_Blob);\n  memcpy(pOut->z, pKey, nKey);\n\n  return SQLITE_OK;\n}\n\n/*\n** Compare the key in memory cell pVal with the key that the sorter cursor\n** passed as the first argument currently points to. For the purposes of\n** the comparison, ignore the rowid field at the end of each record.\n**\n** If the sorter cursor key contains any NULL values, consider it to be\n** less than pVal. Even if pVal also contains NULL values.\n**\n** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).\n** Otherwise, set *pRes to a negative, zero or positive value if the\n** key in pVal is smaller than, equal to or larger than the current sorter\n** key.\n**\n** This routine forms the core of the OP_SorterCompare opcode, which in\n** turn is used to verify uniqueness when constructing a UNIQUE INDEX.\n*/\nSQLITE_PRIVATE int sqlite3VdbeSorterCompare(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal,                      /* Value to compare to current sorter key */\n  int nKeyCol,                    /* Compare this many columns */\n  int *pRes                       /* OUT: Result of comparison */\n){\n  VdbeSorter *pSorter;\n  UnpackedRecord *r2;\n  KeyInfo *pKeyInfo;\n  int i;\n  void *pKey; int nKey;           /* Sorter key to compare pVal with */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  r2 = pSorter->pUnpacked;\n  pKeyInfo = pCsr->pKeyInfo;\n  if( r2==0 ){\n    r2 = pSorter->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n    if( r2==0 ) return SQLITE_NOMEM_BKPT;\n    r2->nField = nKeyCol;\n  }\n  assert( r2->nField==nKeyCol );\n\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, r2);\n  for(i=0; i<nKeyCol; i++){\n    if( r2->aMem[i].flags & MEM_Null ){\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n  }\n\n  *pRes = sqlite3VdbeRecordCompare(pVal->n, pVal->z, r2);\n  return SQLITE_OK;\n}\n\n/************** End of vdbesort.c ********************************************/\n/************** Begin file memjournal.c **************************************/\n/*\n** 2008 October 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement an in-memory rollback journal.\n** The in-memory rollback journal is used to journal transactions for\n** \":memory:\" databases and when the journal_mode=MEMORY pragma is used.\n**\n** Update:  The in-memory journal is also used to temporarily cache\n** smaller journals that are not critical for power-loss recovery.\n** For example, statement journals that are not too big will be held\n** entirely in memory, thus reducing the number of file I/O calls, and\n** more importantly, reducing temporary file creation events.  If these\n** journals become too large for memory, they are spilled to disk.  But\n** in the common case, they are usually small and no file I/O needs to\n** occur.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Forward references to internal structures */\ntypedef struct MemJournal MemJournal;\ntypedef struct FilePoint FilePoint;\ntypedef struct FileChunk FileChunk;\n\n/*\n** The rollback journal is composed of a linked list of these structures.\n**\n** The zChunk array is always at least 8 bytes in size - usually much more.\n** Its actual size is stored in the MemJournal.nChunkSize variable.\n*/\nstruct FileChunk {\n  FileChunk *pNext;               /* Next chunk in the journal */\n  u8 zChunk[8];                   /* Content of this chunk */\n};\n\n/*\n** By default, allocate this many bytes of memory for each FileChunk object.\n*/\n#define MEMJOURNAL_DFLT_FILECHUNKSIZE 1024\n\n/*\n** For chunk size nChunkSize, return the number of bytes that should\n** be allocated for each FileChunk structure.\n*/\n#define fileChunkSize(nChunkSize) (sizeof(FileChunk) + ((nChunkSize)-8))\n\n/*\n** An instance of this object serves as a cursor into the rollback journal.\n** The cursor can be either for reading or writing.\n*/\nstruct FilePoint {\n  sqlite3_int64 iOffset;          /* Offset from the beginning of the file */\n  FileChunk *pChunk;              /* Specific chunk into which cursor points */\n};\n\n/*\n** This structure is a subclass of sqlite3_file. Each open memory-journal\n** is an instance of this class.\n*/\nstruct MemJournal {\n  const sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */\n  int nChunkSize;                 /* In-memory chunk-size */\n\n  int nSpill;                     /* Bytes of data before flushing */\n  int nSize;                      /* Bytes of data currently in memory */\n  FileChunk *pFirst;              /* Head of in-memory chunk-list */\n  FilePoint endpoint;             /* Pointer to the end of the file */\n  FilePoint readpoint;            /* Pointer to the end of the last xRead() */\n\n  int flags;                      /* xOpen flags */\n  sqlite3_vfs *pVfs;              /* The \"real\" underlying VFS */\n  const char *zJournal;           /* Name of the journal file */\n};\n\n/*\n** Read data from the in-memory journal file.  This is the implementation\n** of the sqlite3_vfs.xRead method.\n*/\nstatic int memjrnlRead(\n  sqlite3_file *pJfd,    /* The journal file from which to read */\n  void *zBuf,            /* Put the results here */\n  int iAmt,              /* Number of bytes to read */\n  sqlite_int64 iOfst     /* Begin reading at this offset */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  u8 *zOut = zBuf;\n  int nRead = iAmt;\n  int iChunkOffset;\n  FileChunk *pChunk;\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  if( (iAmt+iOfst)>p->endpoint.iOffset ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n#endif\n\n  assert( (iAmt+iOfst)<=p->endpoint.iOffset );\n  assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );\n  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){\n    sqlite3_int64 iOff = 0;\n    for(pChunk=p->pFirst; \n        ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;\n        pChunk=pChunk->pNext\n    ){\n      iOff += p->nChunkSize;\n    }\n  }else{\n    pChunk = p->readpoint.pChunk;\n    assert( pChunk!=0 );\n  }\n\n  iChunkOffset = (int)(iOfst%p->nChunkSize);\n  do {\n    int iSpace = p->nChunkSize - iChunkOffset;\n    int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));\n    memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);\n    zOut += nCopy;\n    nRead -= iSpace;\n    iChunkOffset = 0;\n  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );\n  p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;\n  p->readpoint.pChunk = pChunk;\n\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of FileChunk structures headed at MemJournal.pFirst.\n*/\nstatic void memjrnlFreeChunks(MemJournal *p){\n  FileChunk *pIter;\n  FileChunk *pNext;\n  for(pIter=p->pFirst; pIter; pIter=pNext){\n    pNext = pIter->pNext;\n    sqlite3_free(pIter);\n  } \n  p->pFirst = 0;\n}\n\n/*\n** Flush the contents of memory to a real file on disk.\n*/\nstatic int memjrnlCreateFile(MemJournal *p){\n  int rc;\n  sqlite3_file *pReal = (sqlite3_file*)p;\n  MemJournal copy = *p;\n\n  memset(p, 0, sizeof(MemJournal));\n  rc = sqlite3OsOpen(copy.pVfs, copy.zJournal, pReal, copy.flags, 0);\n  if( rc==SQLITE_OK ){\n    int nChunk = copy.nChunkSize;\n    i64 iOff = 0;\n    FileChunk *pIter;\n    for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){\n      if( iOff + nChunk > copy.endpoint.iOffset ){\n        nChunk = copy.endpoint.iOffset - iOff;\n      }\n      rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);\n      if( rc ) break;\n      iOff += nChunk;\n    }\n    if( rc==SQLITE_OK ){\n      /* No error has occurred. Free the in-memory buffers. */\n      memjrnlFreeChunks(&copy);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    /* If an error occurred while creating or writing to the file, restore\n    ** the original before returning. This way, SQLite uses the in-memory\n    ** journal data to roll back changes made to the internal page-cache\n    ** before this function was called.  */\n    sqlite3OsClose(pReal);\n    *p = copy;\n  }\n  return rc;\n}\n\n\n/*\n** Write data to the file.\n*/\nstatic int memjrnlWrite(\n  sqlite3_file *pJfd,    /* The journal file into which to write */\n  const void *zBuf,      /* Take data to be written from here */\n  int iAmt,              /* Number of bytes to write */\n  sqlite_int64 iOfst     /* Begin writing at this offset into the file */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  int nWrite = iAmt;\n  u8 *zWrite = (u8 *)zBuf;\n\n  /* If the file should be created now, create it and write the new data\n  ** into the file on disk. */\n  if( p->nSpill>0 && (iAmt+iOfst)>p->nSpill ){\n    int rc = memjrnlCreateFile(p);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsWrite(pJfd, zBuf, iAmt, iOfst);\n    }\n    return rc;\n  }\n\n  /* If the contents of this write should be stored in memory */\n  else{\n    /* An in-memory journal file should only ever be appended to. Random\n    ** access writes are not required. The only exception to this is when\n    ** the in-memory journal is being used by a connection using the\n    ** atomic-write optimization. In this case the first 28 bytes of the\n    ** journal file may be written as part of committing the transaction. */ \n    assert( iOfst==p->endpoint.iOffset || iOfst==0 );\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    if( iOfst==0 && p->pFirst ){\n      assert( p->nChunkSize>iAmt );\n      memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);\n    }else\n#else\n    assert( iOfst>0 || p->pFirst==0 );\n#endif\n    {\n      while( nWrite>0 ){\n        FileChunk *pChunk = p->endpoint.pChunk;\n        int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);\n        int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);\n\n        if( iChunkOffset==0 ){\n          /* New chunk is required to extend the file. */\n          FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));\n          if( !pNew ){\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          pNew->pNext = 0;\n          if( pChunk ){\n            assert( p->pFirst );\n            pChunk->pNext = pNew;\n          }else{\n            assert( !p->pFirst );\n            p->pFirst = pNew;\n          }\n          p->endpoint.pChunk = pNew;\n        }\n\n        memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);\n        zWrite += iSpace;\n        nWrite -= iSpace;\n        p->endpoint.iOffset += iSpace;\n      }\n      p->nSize = iAmt + iOfst;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Truncate the file.\n**\n** If the journal file is already on disk, truncate it there. Or, if it\n** is still in main memory but is being truncated to zero bytes in size,\n** ignore \n*/\nstatic int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){\n  MemJournal *p = (MemJournal *)pJfd;\n  if( ALWAYS(size==0) ){\n    memjrnlFreeChunks(p);\n    p->nSize = 0;\n    p->endpoint.pChunk = 0;\n    p->endpoint.iOffset = 0;\n    p->readpoint.pChunk = 0;\n    p->readpoint.iOffset = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int memjrnlClose(sqlite3_file *pJfd){\n  MemJournal *p = (MemJournal *)pJfd;\n  memjrnlFreeChunks(p);\n  return SQLITE_OK;\n}\n\n/*\n** Sync the file.\n**\n** If the real file has been created, call its xSync method. Otherwise, \n** syncing an in-memory journal is a no-op. \n*/\nstatic int memjrnlSync(sqlite3_file *pJfd, int flags){\n  UNUSED_PARAMETER2(pJfd, flags);\n  return SQLITE_OK;\n}\n\n/*\n** Query the size of the file in bytes.\n*/\nstatic int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){\n  MemJournal *p = (MemJournal *)pJfd;\n  *pSize = (sqlite_int64) p->endpoint.iOffset;\n  return SQLITE_OK;\n}\n\n/*\n** Table of methods for MemJournal sqlite3_file object.\n*/\nstatic const struct sqlite3_io_methods MemJournalMethods = {\n  1,                /* iVersion */\n  memjrnlClose,     /* xClose */\n  memjrnlRead,      /* xRead */\n  memjrnlWrite,     /* xWrite */\n  memjrnlTruncate,  /* xTruncate */\n  memjrnlSync,      /* xSync */\n  memjrnlFileSize,  /* xFileSize */\n  0,                /* xLock */\n  0,                /* xUnlock */\n  0,                /* xCheckReservedLock */\n  0,                /* xFileControl */\n  0,                /* xSectorSize */\n  0,                /* xDeviceCharacteristics */\n  0,                /* xShmMap */\n  0,                /* xShmLock */\n  0,                /* xShmBarrier */\n  0,                /* xShmUnmap */\n  0,                /* xFetch */\n  0                 /* xUnfetch */\n};\n\n/* \n** Open a journal file. \n**\n** The behaviour of the journal file depends on the value of parameter \n** nSpill. If nSpill is 0, then the journal file is always create and \n** accessed using the underlying VFS. If nSpill is less than zero, then\n** all content is always stored in main-memory. Finally, if nSpill is a\n** positive value, then the journal file is initially created in-memory\n** but may be flushed to disk later on. In this case the journal file is\n** flushed to disk either when it grows larger than nSpill bytes in size,\n** or when sqlite3JournalCreate() is called.\n*/\nSQLITE_PRIVATE int sqlite3JournalOpen(\n  sqlite3_vfs *pVfs,         /* The VFS to use for actual file I/O */\n  const char *zName,         /* Name of the journal file */\n  sqlite3_file *pJfd,        /* Preallocated, blank file handle */\n  int flags,                 /* Opening flags */\n  int nSpill                 /* Bytes buffered before opening the file */\n){\n  MemJournal *p = (MemJournal*)pJfd;\n\n  /* Zero the file-handle object. If nSpill was passed zero, initialize\n  ** it using the sqlite3OsOpen() function of the underlying VFS. In this\n  ** case none of the code in this module is executed as a result of calls\n  ** made on the journal file-handle.  */\n  memset(p, 0, sizeof(MemJournal));\n  if( nSpill==0 ){\n    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);\n  }\n\n  if( nSpill>0 ){\n    p->nChunkSize = nSpill;\n  }else{\n    p->nChunkSize = 8 + MEMJOURNAL_DFLT_FILECHUNKSIZE - sizeof(FileChunk);\n    assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );\n  }\n\n  p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;\n  p->nSpill = nSpill;\n  p->flags = flags;\n  p->zJournal = zName;\n  p->pVfs = pVfs;\n  return SQLITE_OK;\n}\n\n/*\n** Open an in-memory journal file.\n*/\nSQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *pJfd){\n  sqlite3JournalOpen(0, 0, pJfd, 0, -1);\n}\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n/*\n** If the argument p points to a MemJournal structure that is not an \n** in-memory-only journal file (i.e. is one that was opened with a +ve\n** nSpill parameter or as SQLITE_OPEN_MAIN_JOURNAL), and the underlying \n** file has not yet been created, create it now.\n*/\nSQLITE_PRIVATE int sqlite3JournalCreate(sqlite3_file *pJfd){\n  int rc = SQLITE_OK;\n  MemJournal *p = (MemJournal*)pJfd;\n  if( p->pMethod==&MemJournalMethods && (\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n     p->nSpill>0\n#else\n     /* While this appears to not be possible without ATOMIC_WRITE, the\n     ** paths are complex, so it seems prudent to leave the test in as\n     ** a NEVER(), in case our analysis is subtly flawed. */\n     NEVER(p->nSpill>0)\n#endif\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n     || (p->flags & SQLITE_OPEN_MAIN_JOURNAL)\n#endif\n  )){\n    rc = memjrnlCreateFile(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** The file-handle passed as the only argument is open on a journal file.\n** Return true if this \"journal file\" is currently stored in heap memory,\n** or false otherwise.\n*/\nSQLITE_PRIVATE int sqlite3JournalIsInMemory(sqlite3_file *p){\n  return p->pMethods==&MemJournalMethods;\n}\n\n/* \n** Return the number of bytes required to store a JournalFile that uses vfs\n** pVfs to create the underlying on-disk files.\n*/\nSQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){\n  return MAX(pVfs->szOsFile, (int)sizeof(MemJournal));\n}\n\n/************** End of memjournal.c ******************************************/\n/************** Begin file walker.c ******************************************/\n/*\n** 2008 August 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for walking the parser tree for\n** an SQL statement.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n\n/*\n** Walk an expression tree.  Invoke the callback once for each node\n** of the expression, while descending.  (In other words, the callback\n** is invoked before visiting children.)\n**\n** The return value from the callback should be one of the WRC_*\n** constants to specify how to proceed with the walk.\n**\n**    WRC_Continue      Continue descending down the tree.\n**\n**    WRC_Prune         Do not descend into child nodes, but allow\n**                      the walk to continue with sibling nodes.\n**\n**    WRC_Abort         Do no more callbacks.  Unwind the stack and\n**                      return from the top-level walk call.\n**\n** The return value from this routine is WRC_Abort to abandon the tree walk\n** and WRC_Continue to continue.\n*/\nstatic SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){\n  int rc;\n  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );\n  testcase( ExprHasProperty(pExpr, EP_Reduced) );\n  while(1){\n    rc = pWalker->xExprCallback(pWalker, pExpr);\n    if( rc ) return rc & WRC_Abort;\n    if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){\n      if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;\n       assert( pExpr->x.pList==0 || pExpr->pRight==0 );\n      if( pExpr->pRight ){\n        pExpr = pExpr->pRight;\n        continue;\n      }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;\n      }else if( pExpr->x.pList ){\n        if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;\n      }\n    }\n    break;\n  }\n  return WRC_Continue;\n}\nSQLITE_PRIVATE int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){\n  return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;\n}\n\n/*\n** Call sqlite3WalkExpr() for every expression in list p or until\n** an abort request is seen.\n*/\nSQLITE_PRIVATE int sqlite3WalkExprList(Walker *pWalker, ExprList *p){\n  int i;\n  struct ExprList_item *pItem;\n  if( p ){\n    for(i=p->nExpr, pItem=p->a; i>0; i--, pItem++){\n      if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Walk all expressions associated with SELECT statement p.  Do\n** not invoke the SELECT callback on p, but do (of course) invoke\n** any expr callbacks and SELECT callbacks that come from subqueries.\n** Return WRC_Abort or WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){\n  if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pOffset) ) return WRC_Abort;\n  return WRC_Continue;\n}\n\n/*\n** Walk the parse trees associated with all subqueries in the\n** FROM clause of SELECT statement p.  Do not invoke the select\n** callback on p, but do invoke it on each FROM clause subquery\n** and on any subqueries further down in the tree.  Return \n** WRC_Abort or WRC_Continue;\n*/\nSQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){\n  SrcList *pSrc;\n  int i;\n  struct SrcList_item *pItem;\n\n  pSrc = p->pSrc;\n  if( ALWAYS(pSrc) ){\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){\n        return WRC_Abort;\n      }\n      if( pItem->fg.isTabFunc\n       && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)\n      ){\n        return WRC_Abort;\n      }\n    }\n  }\n  return WRC_Continue;\n} \n\n/*\n** Call sqlite3WalkExpr() for every expression in Select statement p.\n** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and\n** on the compound select chain, p->pPrior. \n**\n** If it is not NULL, the xSelectCallback() callback is invoked before\n** the walk of the expressions and FROM clause. The xSelectCallback2()\n** method is invoked following the walk of the expressions and FROM clause,\n** but only if both xSelectCallback and xSelectCallback2 are both non-NULL\n** and if the expressions and FROM clause both return WRC_Continue;\n**\n** Return WRC_Continue under normal conditions.  Return WRC_Abort if\n** there is an abort request.\n**\n** If the Walker does not have an xSelectCallback() then this routine\n** is a no-op returning WRC_Continue.\n*/\nSQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){\n  int rc;\n  if( p==0 ) return WRC_Continue;\n  if( pWalker->xSelectCallback==0 ) return WRC_Continue;\n  do{\n    rc = pWalker->xSelectCallback(pWalker, p);\n    if( rc ) return rc & WRC_Abort;\n    if( sqlite3WalkSelectExpr(pWalker, p)\n     || sqlite3WalkSelectFrom(pWalker, p)\n    ){\n      return WRC_Abort;\n    }\n    if( pWalker->xSelectCallback2 ){\n      pWalker->xSelectCallback2(pWalker, p);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  return WRC_Continue;\n}\n\n/************** End of walker.c **********************************************/\n/************** Begin file resolve.c *****************************************/\n/*\n** 2008 August 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains routines used for walking the parser tree and\n** resolve all identifiers by associating them with a particular\n** table and column.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Walk the expression tree pExpr and increase the aggregate function\n** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node.\n** This needs to occur when copying a TK_AGG_FUNCTION node from an\n** outer query into an inner subquery.\n**\n** incrAggFunctionDepth(pExpr,n) is the main routine.  incrAggDepth(..)\n** is a helper function - a callback for the tree walker.\n*/\nstatic int incrAggDepth(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;\n  return WRC_Continue;\n}\nstatic void incrAggFunctionDepth(Expr *pExpr, int N){\n  if( N>0 ){\n    Walker w;\n    memset(&w, 0, sizeof(w));\n    w.xExprCallback = incrAggDepth;\n    w.u.n = N;\n    sqlite3WalkExpr(&w, pExpr);\n  }\n}\n\n/*\n** Turn the pExpr expression into an alias for the iCol-th column of the\n** result set in pEList.\n**\n** If the reference is followed by a COLLATE operator, then make sure\n** the COLLATE operator is preserved.  For example:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase;\n**\n** Should be transformed into:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;\n**\n** The nSubquery parameter specifies how many levels of subquery the\n** alias is removed from the original expression.  The usual value is\n** zero but it might be more if the alias is contained within a subquery\n** of the original expression.  The Expr.op2 field of TK_AGG_FUNCTION\n** structures must be increased by the nSubquery amount.\n*/\nstatic void resolveAlias(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pEList,      /* A result set */\n  int iCol,              /* A column in the result set.  0..pEList->nExpr-1 */\n  Expr *pExpr,           /* Transform this into an alias to the result set */\n  const char *zType,     /* \"GROUP\" or \"ORDER\" or \"\" */\n  int nSubquery          /* Number of subqueries that the label is moving */\n){\n  Expr *pOrig;           /* The iCol-th column of the result set */\n  Expr *pDup;            /* Copy of pOrig */\n  sqlite3 *db;           /* The database connection */\n\n  assert( iCol>=0 && iCol<pEList->nExpr );\n  pOrig = pEList->a[iCol].pExpr;\n  assert( pOrig!=0 );\n  db = pParse->db;\n  pDup = sqlite3ExprDup(db, pOrig, 0);\n  if( pDup==0 ) return;\n  if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery);\n  if( pExpr->op==TK_COLLATE ){\n    pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);\n  }\n  ExprSetProperty(pDup, EP_Alias);\n\n  /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This \n  ** prevents ExprDelete() from deleting the Expr structure itself,\n  ** allowing it to be repopulated by the memcpy() on the following line.\n  ** The pExpr->u.zToken might point into memory that will be freed by the\n  ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to\n  ** make a copy of the token before doing the sqlite3DbFree().\n  */\n  ExprSetProperty(pExpr, EP_Static);\n  sqlite3ExprDelete(db, pExpr);\n  memcpy(pExpr, pDup, sizeof(*pExpr));\n  if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){\n    assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );\n    pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);\n    pExpr->flags |= EP_MemToken;\n  }\n  sqlite3DbFree(db, pDup);\n}\n\n\n/*\n** Return TRUE if the name zCol occurs anywhere in the USING clause.\n**\n** Return FALSE if the USING clause is NULL or if it does not contain\n** zCol.\n*/\nstatic int nameInUsingClause(IdList *pUsing, const char *zCol){\n  if( pUsing ){\n    int k;\n    for(k=0; k<pUsing->nId; k++){\n      if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Subqueries stores the original database, table and column names for their\n** result sets in ExprList.a[].zSpan, in the form \"DATABASE.TABLE.COLUMN\".\n** Check to see if the zSpan given to this routine matches the zDb, zTab,\n** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will\n** match anything.\n*/\nSQLITE_PRIVATE int sqlite3MatchSpanName(\n  const char *zSpan,\n  const char *zCol,\n  const char *zTab,\n  const char *zDb\n){\n  int n;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up\n** that name in the set of source tables in pSrcList and make the pExpr \n** expression node refer back to that source column.  The following changes\n** are made to pExpr:\n**\n**    pExpr->iDb           Set the index in db->aDb[] of the database X\n**                         (even if X is implied).\n**    pExpr->iTable        Set to the cursor number for the table obtained\n**                         from pSrcList.\n**    pExpr->pTab          Points to the Table structure of X.Y (even if\n**                         X and/or Y are implied.)\n**    pExpr->iColumn       Set to the column number within the table.\n**    pExpr->op            Set to TK_COLUMN.\n**    pExpr->pLeft         Any expression this points to is deleted\n**    pExpr->pRight        Any expression this points to is deleted.\n**\n** The zDb variable is the name of the database (the \"X\").  This value may be\n** NULL meaning that name is of the form Y.Z or Z.  Any available database\n** can be used.  The zTable variable is the name of the table (the \"Y\").  This\n** value can be NULL if zDb is also NULL.  If zTable is NULL it\n** means that the form of the name is Z and that columns from any table\n** can be used.\n**\n** If the name cannot be resolved unambiguously, leave an error message\n** in pParse and return WRC_Abort.  Return WRC_Prune on success.\n*/\nstatic int lookupName(\n  Parse *pParse,       /* The parsing context */\n  const char *zDb,     /* Name of the database containing table, or NULL */\n  const char *zTab,    /* Name of table containing column, or NULL */\n  const char *zCol,    /* Name of the column. */\n  NameContext *pNC,    /* The name context used to resolve the name */\n  Expr *pExpr          /* Make this EXPR node point to the selected column */\n){\n  int i, j;                         /* Loop counters */\n  int cnt = 0;                      /* Number of matching column names */\n  int cntTab = 0;                   /* Number of matching table names */\n  int nSubquery = 0;                /* How many levels of subquery */\n  sqlite3 *db = pParse->db;         /* The database connection */\n  struct SrcList_item *pItem;       /* Use for looping over pSrcList items */\n  struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */\n  NameContext *pTopNC = pNC;        /* First namecontext in the list */\n  Schema *pSchema = 0;              /* Schema of the expression */\n  int isTrigger = 0;                /* True if resolved to a trigger column */\n  Table *pTab = 0;                  /* Table hold the row */\n  Column *pCol;                     /* A column of pTab */\n\n  assert( pNC );     /* the name context cannot be NULL. */\n  assert( zCol );    /* The Z in X.Y.Z cannot be NULL */\n  assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n\n  /* Initialize the node to no-match */\n  pExpr->iTable = -1;\n  pExpr->pTab = 0;\n  ExprSetVVAProperty(pExpr, EP_NoReduce);\n\n  /* Translate the schema name in zDb into a pointer to the corresponding\n  ** schema.  If not found, pSchema will remain NULL and nothing will match\n  ** resulting in an appropriate error message toward the end of this routine\n  */\n  if( zDb ){\n    testcase( pNC->ncFlags & NC_PartIdx );\n    testcase( pNC->ncFlags & NC_IsCheck );\n    if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){\n      /* Silently ignore database qualifiers inside CHECK constraints and\n      ** partial indices.  Do not raise errors because that might break\n      ** legacy and because it does not hurt anything to just ignore the\n      ** database name. */\n      zDb = 0;\n    }else{\n      for(i=0; i<db->nDb; i++){\n        assert( db->aDb[i].zDbSName );\n        if( sqlite3StrICmp(db->aDb[i].zDbSName,zDb)==0 ){\n          pSchema = db->aDb[i].pSchema;\n          break;\n        }\n      }\n    }\n  }\n\n  /* Start at the inner-most context and move outward until a match is found */\n  assert( pNC && cnt==0 );\n  do{\n    ExprList *pEList;\n    SrcList *pSrcList = pNC->pSrcList;\n\n    if( pSrcList ){\n      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){\n        pTab = pItem->pTab;\n        assert( pTab!=0 && pTab->zName!=0 );\n        assert( pTab->nCol>0 );\n        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){\n          int hit = 0;\n          pEList = pItem->pSelect->pEList;\n          for(j=0; j<pEList->nExpr; j++){\n            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){\n              cnt++;\n              cntTab = 2;\n              pMatch = pItem;\n              pExpr->iColumn = j;\n              hit = 1;\n            }\n          }\n          if( hit || zTab==0 ) continue;\n        }\n        if( zDb && pTab->pSchema!=pSchema ){\n          continue;\n        }\n        if( zTab ){\n          const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;\n          assert( zTabName!=0 );\n          if( sqlite3StrICmp(zTabName, zTab)!=0 ){\n            continue;\n          }\n        }\n        if( 0==(cntTab++) ){\n          pMatch = pItem;\n        }\n        for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            /* If there has been exactly one prior match and this match\n            ** is for the right-hand table of a NATURAL JOIN or is in a \n            ** USING clause, then skip this match.\n            */\n            if( cnt==1 ){\n              if( pItem->fg.jointype & JT_NATURAL ) continue;\n              if( nameInUsingClause(pItem->pUsing, zCol) ) continue;\n            }\n            cnt++;\n            pMatch = pItem;\n            /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */\n            pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;\n            break;\n          }\n        }\n      }\n      if( pMatch ){\n        pExpr->iTable = pMatch->iCursor;\n        pExpr->pTab = pMatch->pTab;\n        /* RIGHT JOIN not (yet) supported */\n        assert( (pMatch->fg.jointype & JT_RIGHT)==0 );\n        if( (pMatch->fg.jointype & JT_LEFT)!=0 ){\n          ExprSetProperty(pExpr, EP_CanBeNull);\n        }\n        pSchema = pExpr->pTab->pSchema;\n      }\n    } /* if( pSrcList ) */\n\n#ifndef SQLITE_OMIT_TRIGGER\n    /* If we have not already resolved the name, then maybe \n    ** it is a new.* or old.* trigger argument reference\n    */\n    if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){\n      int op = pParse->eTriggerOp;\n      assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );\n      if( op!=TK_DELETE && sqlite3StrICmp(\"new\",zTab) == 0 ){\n        pExpr->iTable = 1;\n        pTab = pParse->pTriggerTab;\n      }else if( op!=TK_INSERT && sqlite3StrICmp(\"old\",zTab)==0 ){\n        pExpr->iTable = 0;\n        pTab = pParse->pTriggerTab;\n      }else{\n        pTab = 0;\n      }\n\n      if( pTab ){ \n        int iCol;\n        pSchema = pTab->pSchema;\n        cntTab++;\n        for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            if( iCol==pTab->iPKey ){\n              iCol = -1;\n            }\n            break;\n          }\n        }\n        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){\n          /* IMP: R-51414-32910 */\n          iCol = -1;\n        }\n        if( iCol<pTab->nCol ){\n          cnt++;\n          if( iCol<0 ){\n            pExpr->affinity = SQLITE_AFF_INTEGER;\n          }else if( pExpr->iTable==0 ){\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }else{\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }\n          pExpr->iColumn = (i16)iCol;\n          pExpr->pTab = pTab;\n          isTrigger = 1;\n        }\n      }\n    }\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n    /*\n    ** Perhaps the name is a reference to the ROWID\n    */\n    if( cnt==0\n     && cntTab==1\n     && pMatch\n     && (pNC->ncFlags & NC_IdxExpr)==0\n     && sqlite3IsRowid(zCol)\n     && VisibleRowid(pMatch->pTab)\n    ){\n      cnt = 1;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n\n    /*\n    ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z\n    ** might refer to an result-set alias.  This happens, for example, when\n    ** we are resolving names in the WHERE clause of the following command:\n    **\n    **     SELECT a+b AS x FROM table WHERE x<10;\n    **\n    ** In cases like this, replace pExpr with a copy of the expression that\n    ** forms the result set entry (\"a+b\" in the example) and return immediately.\n    ** Note that the expression in the result set should have already been\n    ** resolved by the time the WHERE clause is resolved.\n    **\n    ** The ability to use an output result-set column in the WHERE, GROUP BY,\n    ** or HAVING clauses, or as part of a larger expression in the ORDER BY\n    ** clause is not standard SQL.  This is a (goofy) SQLite extension, that\n    ** is supported for backwards compatibility only. Hence, we issue a warning\n    ** on sqlite3_log() whenever the capability is used.\n    */\n    if( (pEList = pNC->pEList)!=0\n     && zTab==0\n     && cnt==0\n    ){\n      for(j=0; j<pEList->nExpr; j++){\n        char *zAs = pEList->a[j].zName;\n        if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n          Expr *pOrig;\n          assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n          assert( pExpr->x.pList==0 );\n          assert( pExpr->x.pSelect==0 );\n          pOrig = pEList->a[j].pExpr;\n          if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){\n            sqlite3ErrorMsg(pParse, \"misuse of aliased aggregate %s\", zAs);\n            return WRC_Abort;\n          }\n          if( sqlite3ExprVectorSize(pOrig)!=1 ){\n            sqlite3ErrorMsg(pParse, \"row value misused\");\n            return WRC_Abort;\n          }\n          resolveAlias(pParse, pEList, j, pExpr, \"\", nSubquery);\n          cnt = 1;\n          pMatch = 0;\n          assert( zTab==0 && zDb==0 );\n          goto lookupname_end;\n        }\n      } \n    }\n\n    /* Advance to the next name context.  The loop will exit when either\n    ** we have a match (cnt>0) or when we run out of name contexts.\n    */\n    if( cnt ) break;\n    pNC = pNC->pNext;\n    nSubquery++;\n  }while( pNC );\n\n\n  /*\n  ** If X and Y are NULL (in other words if only the column name Z is\n  ** supplied) and the value of Z is enclosed in double-quotes, then\n  ** Z is a string literal if it doesn't match any column names.  In that\n  ** case, we need to return right away and not make any changes to\n  ** pExpr.\n  **\n  ** Because no reference was made to outer contexts, the pNC->nRef\n  ** fields are not changed in any context.\n  */\n  if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){\n    pExpr->op = TK_STRING;\n    pExpr->pTab = 0;\n    return WRC_Prune;\n  }\n\n  /*\n  ** cnt==0 means there was not match.  cnt>1 means there were two or\n  ** more matches.  Either way, we have an error.\n  */\n  if( cnt!=1 ){\n    const char *zErr;\n    zErr = cnt==0 ? \"no such column\" : \"ambiguous column name\";\n    if( zDb ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s.%s\", zErr, zDb, zTab, zCol);\n    }else if( zTab ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zErr, zTab, zCol);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zErr, zCol);\n    }\n    pParse->checkSchema = 1;\n    pTopNC->nErr++;\n  }\n\n  /* If a column from a table in pSrcList is referenced, then record\n  ** this fact in the pSrcList.a[].colUsed bitmask.  Column 0 causes\n  ** bit 0 to be set.  Column 1 sets bit 1.  And so forth.  If the\n  ** column number is greater than the number of bits in the bitmask\n  ** then set the high-order bit of the bitmask.\n  */\n  if( pExpr->iColumn>=0 && pMatch!=0 ){\n    int n = pExpr->iColumn;\n    testcase( n==BMS-1 );\n    if( n>=BMS ){\n      n = BMS-1;\n    }\n    assert( pMatch->iCursor==pExpr->iTable );\n    pMatch->colUsed |= ((Bitmask)1)<<n;\n  }\n\n  /* Clean up and return\n  */\n  sqlite3ExprDelete(db, pExpr->pLeft);\n  pExpr->pLeft = 0;\n  sqlite3ExprDelete(db, pExpr->pRight);\n  pExpr->pRight = 0;\n  pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);\n  ExprSetProperty(pExpr, EP_Leaf);\nlookupname_end:\n  if( cnt==1 ){\n    assert( pNC!=0 );\n    if( !ExprHasProperty(pExpr, EP_Alias) ){\n      sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);\n    }\n    /* Increment the nRef value on all name contexts from TopNC up to\n    ** the point where the name matched. */\n    for(;;){\n      assert( pTopNC!=0 );\n      pTopNC->nRef++;\n      if( pTopNC==pNC ) break;\n      pTopNC = pTopNC->pNext;\n    }\n    return WRC_Prune;\n  } else {\n    return WRC_Abort;\n  }\n}\n\n/*\n** Allocate and return a pointer to an expression to load the column iCol\n** from datasource iSrc in SrcList pSrc.\n*/\nSQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){\n  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);\n  if( p ){\n    struct SrcList_item *pItem = &pSrc->a[iSrc];\n    p->pTab = pItem->pTab;\n    p->iTable = pItem->iCursor;\n    if( p->pTab->iPKey==iCol ){\n      p->iColumn = -1;\n    }else{\n      p->iColumn = (ynVar)iCol;\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);\n    }\n  }\n  return p;\n}\n\n/*\n** Report an error that an expression is not valid for some set of\n** pNC->ncFlags values determined by validMask.\n*/\nstatic void notValid(\n  Parse *pParse,       /* Leave error message here */\n  NameContext *pNC,    /* The name context */\n  const char *zMsg,    /* Type of error */\n  int validMask        /* Set of contexts for which prohibited */\n){\n  assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 );\n  if( (pNC->ncFlags & validMask)!=0 ){\n    const char *zIn = \"partial index WHERE clauses\";\n    if( pNC->ncFlags & NC_IdxExpr )      zIn = \"index expressions\";\n#ifndef SQLITE_OMIT_CHECK\n    else if( pNC->ncFlags & NC_IsCheck ) zIn = \"CHECK constraints\";\n#endif\n    sqlite3ErrorMsg(pParse, \"%s prohibited in %s\", zMsg, zIn);\n  }\n}\n\n/*\n** Expression p should encode a floating point value between 1.0 and 0.0.\n** Return 1024 times this value.  Or return -1 if p is not a floating point\n** value between 1.0 and 0.0.\n*/\nstatic int exprProbability(Expr *p){\n  double r = -1.0;\n  if( p->op!=TK_FLOAT ) return -1;\n  sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);\n  assert( r>=0.0 );\n  if( r>1.0 ) return -1;\n  return (int)(r*134217728.0);\n}\n\n/*\n** This routine is callback for sqlite3WalkExpr().\n**\n** Resolve symbolic names into TK_COLUMN operators for the current\n** node in the expression tree.  Return 0 to continue the search down\n** the tree or 2 to abort the tree walk.\n**\n** This routine also does error checking and name resolution for\n** function names.  The operator for aggregate functions is changed\n** to TK_AGG_FUNCTION.\n*/\nstatic int resolveExprStep(Walker *pWalker, Expr *pExpr){\n  NameContext *pNC;\n  Parse *pParse;\n\n  pNC = pWalker->u.pNC;\n  assert( pNC!=0 );\n  pParse = pNC->pParse;\n  assert( pParse==pWalker->pParse );\n\n#ifndef NDEBUG\n  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){\n    SrcList *pSrcList = pNC->pSrcList;\n    int i;\n    for(i=0; i<pNC->pSrcList->nSrc; i++){\n      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);\n    }\n  }\n#endif\n  switch( pExpr->op ){\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n    /* The special operator TK_ROW means use the rowid for the first\n    ** column in the FROM clause.  This is used by the LIMIT and ORDER BY\n    ** clause processing on UPDATE and DELETE statements.\n    */\n    case TK_ROW: {\n      SrcList *pSrcList = pNC->pSrcList;\n      struct SrcList_item *pItem;\n      assert( pSrcList && pSrcList->nSrc==1 );\n      pItem = pSrcList->a; \n      pExpr->op = TK_COLUMN;\n      pExpr->pTab = pItem->pTab;\n      pExpr->iTable = pItem->iCursor;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n      break;\n    }\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)\n          && !defined(SQLITE_OMIT_SUBQUERY) */\n\n    /* A column name:                    ID\n    ** Or table name and column name:    ID.ID\n    ** Or a database, table and column:  ID.ID.ID\n    **\n    ** The TK_ID and TK_OUT cases are combined so that there will only\n    ** be one call to lookupName().  Then the compiler will in-line \n    ** lookupName() for a size reduction and performance increase.\n    */\n    case TK_ID:\n    case TK_DOT: {\n      const char *zColumn;\n      const char *zTable;\n      const char *zDb;\n      Expr *pRight;\n\n      if( pExpr->op==TK_ID ){\n        zDb = 0;\n        zTable = 0;\n        zColumn = pExpr->u.zToken;\n      }else{\n        notValid(pParse, pNC, \"the \\\".\\\" operator\", NC_IdxExpr);\n        pRight = pExpr->pRight;\n        if( pRight->op==TK_ID ){\n          zDb = 0;\n          zTable = pExpr->pLeft->u.zToken;\n          zColumn = pRight->u.zToken;\n        }else{\n          assert( pRight->op==TK_DOT );\n          zDb = pExpr->pLeft->u.zToken;\n          zTable = pRight->pLeft->u.zToken;\n          zColumn = pRight->pRight->u.zToken;\n        }\n      }\n      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);\n    }\n\n    /* Resolve function names\n    */\n    case TK_FUNCTION: {\n      ExprList *pList = pExpr->x.pList;    /* The argument list */\n      int n = pList ? pList->nExpr : 0;    /* Number of arguments */\n      int no_such_func = 0;       /* True if no such function exists */\n      int wrong_num_args = 0;     /* True if wrong number of arguments */\n      int is_agg = 0;             /* True if is an aggregate function */\n      int nId;                    /* Number of characters in function name */\n      const char *zId;            /* The function name. */\n      FuncDef *pDef;              /* Information about the function */\n      u8 enc = ENC(pParse->db);   /* The database encoding */\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      zId = pExpr->u.zToken;\n      nId = sqlite3Strlen30(zId);\n      pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);\n      if( pDef==0 ){\n        pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);\n        if( pDef==0 ){\n          no_such_func = 1;\n        }else{\n          wrong_num_args = 1;\n        }\n      }else{\n        is_agg = pDef->xFinalize!=0;\n        if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n          ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);\n          if( n==2 ){\n            pExpr->iTable = exprProbability(pList->a[1].pExpr);\n            if( pExpr->iTable<0 ){\n              sqlite3ErrorMsg(pParse,\n                \"second argument to likelihood() must be a \"\n                \"constant between 0.0 and 1.0\");\n              pNC->nErr++;\n            }\n          }else{\n            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is\n            ** equivalent to likelihood(X, 0.0625).\n            ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is\n            ** short-hand for likelihood(X,0.0625).\n            ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand\n            ** for likelihood(X,0.9375).\n            ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent\n            ** to likelihood(X,0.9375). */\n            /* TUNING: unlikely() probability is 0.0625.  likely() is 0.9375 */\n            pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;\n          }             \n        }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n        {\n          int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);\n          if( auth!=SQLITE_OK ){\n            if( auth==SQLITE_DENY ){\n              sqlite3ErrorMsg(pParse, \"not authorized to use function: %s\",\n                                      pDef->zName);\n              pNC->nErr++;\n            }\n            pExpr->op = TK_NULL;\n            return WRC_Prune;\n          }\n        }\n#endif\n        if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){\n          /* For the purposes of the EP_ConstFunc flag, date and time\n          ** functions and other functions that change slowly are considered\n          ** constant because they are constant for the duration of one query */\n          ExprSetProperty(pExpr,EP_ConstFunc);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){\n          /* Date/time functions that use 'now', and other functions like\n          ** sqlite_version() that might change over time cannot be used\n          ** in an index. */\n          notValid(pParse, pNC, \"non-deterministic functions\",\n                   NC_IdxExpr|NC_PartIdx);\n        }\n      }\n      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate function %.*s()\", nId,zId);\n        pNC->nErr++;\n        is_agg = 0;\n      }else if( no_such_func && pParse->db->init.busy==0\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n                && pParse->explain==0\n#endif\n      ){\n        sqlite3ErrorMsg(pParse, \"no such function: %.*s\", nId, zId);\n        pNC->nErr++;\n      }else if( wrong_num_args ){\n        sqlite3ErrorMsg(pParse,\"wrong number of arguments to function %.*s()\",\n             nId, zId);\n        pNC->nErr++;\n      }\n      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;\n      sqlite3WalkExprList(pWalker, pList);\n      if( is_agg ){\n        NameContext *pNC2 = pNC;\n        pExpr->op = TK_AGG_FUNCTION;\n        pExpr->op2 = 0;\n        while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){\n          pExpr->op2++;\n          pNC2 = pNC2->pNext;\n        }\n        assert( pDef!=0 );\n        if( pNC2 ){\n          assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );\n          testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );\n          pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);\n\n        }\n        pNC->ncFlags |= NC_AllowAgg;\n      }\n      /* FIX ME:  Compute pExpr->affinity based on the expected return\n      ** type of the function \n      */\n      return WRC_Prune;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT:\n    case TK_EXISTS:  testcase( pExpr->op==TK_EXISTS );\n#endif\n    case TK_IN: {\n      testcase( pExpr->op==TK_IN );\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        int nRef = pNC->nRef;\n        notValid(pParse, pNC, \"subqueries\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n        sqlite3WalkSelect(pWalker, pExpr->x.pSelect);\n        assert( pNC->nRef>=nRef );\n        if( nRef!=pNC->nRef ){\n          ExprSetProperty(pExpr, EP_VarSelect);\n          pNC->ncFlags |= NC_VarSelect;\n        }\n      }\n      break;\n    }\n    case TK_VARIABLE: {\n      notValid(pParse, pNC, \"parameters\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n      break;\n    }\n    case TK_BETWEEN:\n    case TK_EQ:\n    case TK_NE:\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_IS:\n    case TK_ISNOT: {\n      int nLeft, nRight;\n      if( pParse->db->mallocFailed ) break;\n      assert( pExpr->pLeft!=0 );\n      nLeft = sqlite3ExprVectorSize(pExpr->pLeft);\n      if( pExpr->op==TK_BETWEEN ){\n        nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr);\n        if( nRight==nLeft ){\n          nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr);\n        }\n      }else{\n        assert( pExpr->pRight!=0 );\n        nRight = sqlite3ExprVectorSize(pExpr->pRight);\n      }\n      if( nLeft!=nRight ){\n        testcase( pExpr->op==TK_EQ );\n        testcase( pExpr->op==TK_NE );\n        testcase( pExpr->op==TK_LT );\n        testcase( pExpr->op==TK_LE );\n        testcase( pExpr->op==TK_GT );\n        testcase( pExpr->op==TK_GE );\n        testcase( pExpr->op==TK_IS );\n        testcase( pExpr->op==TK_ISNOT );\n        testcase( pExpr->op==TK_BETWEEN );\n        sqlite3ErrorMsg(pParse, \"row value misused\");\n      }\n      break; \n    }\n  }\n  return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;\n}\n\n/*\n** pEList is a list of expressions which are really the result set of the\n** a SELECT statement.  pE is a term in an ORDER BY or GROUP BY clause.\n** This routine checks to see if pE is a simple identifier which corresponds\n** to the AS-name of one of the terms of the expression list.  If it is,\n** this routine return an integer between 1 and N where N is the number of\n** elements in pEList, corresponding to the matching entry.  If there is\n** no match, or if pE is not a simple identifier, then this routine\n** return 0.\n**\n** pEList has been resolved.  pE has not.\n*/\nstatic int resolveAsName(\n  Parse *pParse,     /* Parsing context for error messages */\n  ExprList *pEList,  /* List of expressions to scan */\n  Expr *pE           /* Expression we are trying to match */\n){\n  int i;             /* Loop counter */\n\n  UNUSED_PARAMETER(pParse);\n\n  if( pE->op==TK_ID ){\n    char *zCol = pE->u.zToken;\n    for(i=0; i<pEList->nExpr; i++){\n      char *zAs = pEList->a[i].zName;\n      if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n        return i+1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** pE is a pointer to an expression which is a single term in the\n** ORDER BY of a compound SELECT.  The expression has not been\n** name resolved.\n**\n** At the point this routine is called, we already know that the\n** ORDER BY term is not an integer index into the result set.  That\n** case is handled by the calling routine.\n**\n** Attempt to match pE against result set columns in the left-most\n** SELECT statement.  Return the index i of the matching column,\n** as an indication to the caller that it should sort by the i-th column.\n** The left-most column is 1.  In other words, the value returned is the\n** same integer value that would be used in the SQL statement to indicate\n** the column.\n**\n** If there is no match, return 0.  Return -1 if an error occurs.\n*/\nstatic int resolveOrderByTermToExprList(\n  Parse *pParse,     /* Parsing context for error messages */\n  Select *pSelect,   /* The SELECT statement with the ORDER BY clause */\n  Expr *pE           /* The specific ORDER BY term */\n){\n  int i;             /* Loop counter */\n  ExprList *pEList;  /* The columns of the result set */\n  NameContext nc;    /* Name context for resolving pE */\n  sqlite3 *db;       /* Database connection */\n  int rc;            /* Return code from subprocedures */\n  u8 savedSuppErr;   /* Saved value of db->suppressErr */\n\n  assert( sqlite3ExprIsInteger(pE, &i)==0 );\n  pEList = pSelect->pEList;\n\n  /* Resolve all names in the ORDER BY term expression\n  */\n  memset(&nc, 0, sizeof(nc));\n  nc.pParse = pParse;\n  nc.pSrcList = pSelect->pSrc;\n  nc.pEList = pEList;\n  nc.ncFlags = NC_AllowAgg;\n  nc.nErr = 0;\n  db = pParse->db;\n  savedSuppErr = db->suppressErr;\n  db->suppressErr = 1;\n  rc = sqlite3ResolveExprNames(&nc, pE);\n  db->suppressErr = savedSuppErr;\n  if( rc ) return 0;\n\n  /* Try to match the ORDER BY expression against an expression\n  ** in the result set.  Return an 1-based index of the matching\n  ** result-set entry.\n  */\n  for(i=0; i<pEList->nExpr; i++){\n    if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){\n      return i+1;\n    }\n  }\n\n  /* If no match, return 0. */\n  return 0;\n}\n\n/*\n** Generate an ORDER BY or GROUP BY term out-of-range error.\n*/\nstatic void resolveOutOfRangeError(\n  Parse *pParse,         /* The error context into which to write the error */\n  const char *zType,     /* \"ORDER\" or \"GROUP\" */\n  int i,                 /* The index (1-based) of the term out of range */\n  int mx                 /* Largest permissible value of i */\n){\n  sqlite3ErrorMsg(pParse, \n    \"%r %s BY term out of range - should be \"\n    \"between 1 and %d\", i, zType, mx);\n}\n\n/*\n** Analyze the ORDER BY clause in a compound SELECT statement.   Modify\n** each term of the ORDER BY clause is a constant integer between 1\n** and N where N is the number of columns in the compound SELECT.\n**\n** ORDER BY terms that are already an integer between 1 and N are\n** unmodified.  ORDER BY terms that are integers outside the range of\n** 1 through N generate an error.  ORDER BY terms that are expressions\n** are matched against result set expressions of compound SELECT\n** beginning with the left-most SELECT and working toward the right.\n** At the first match, the ORDER BY expression is transformed into\n** the integer column number.\n**\n** Return the number of errors seen.\n*/\nstatic int resolveCompoundOrderBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect       /* The SELECT statement containing the ORDER BY */\n){\n  int i;\n  ExprList *pOrderBy;\n  ExprList *pEList;\n  sqlite3 *db;\n  int moreToDo = 1;\n\n  pOrderBy = pSelect->pOrderBy;\n  if( pOrderBy==0 ) return 0;\n  db = pParse->db;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in ORDER BY clause\");\n    return 1;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    pOrderBy->a[i].done = 0;\n  }\n  pSelect->pNext = 0;\n  while( pSelect->pPrior ){\n    pSelect->pPrior->pNext = pSelect;\n    pSelect = pSelect->pPrior;\n  }\n  while( pSelect && moreToDo ){\n    struct ExprList_item *pItem;\n    moreToDo = 0;\n    pEList = pSelect->pEList;\n    assert( pEList!=0 );\n    for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n      int iCol = -1;\n      Expr *pE, *pDup;\n      if( pItem->done ) continue;\n      pE = sqlite3ExprSkipCollate(pItem->pExpr);\n      if( sqlite3ExprIsInteger(pE, &iCol) ){\n        if( iCol<=0 || iCol>pEList->nExpr ){\n          resolveOutOfRangeError(pParse, \"ORDER\", i+1, pEList->nExpr);\n          return 1;\n        }\n      }else{\n        iCol = resolveAsName(pParse, pEList, pE);\n        if( iCol==0 ){\n          pDup = sqlite3ExprDup(db, pE, 0);\n          if( !db->mallocFailed ){\n            assert(pDup);\n            iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);\n          }\n          sqlite3ExprDelete(db, pDup);\n        }\n      }\n      if( iCol>0 ){\n        /* Convert the ORDER BY term into an integer column number iCol,\n        ** taking care to preserve the COLLATE clause if it exists */\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return 1;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = iCol;\n        if( pItem->pExpr==pE ){\n          pItem->pExpr = pNew;\n        }else{\n          Expr *pParent = pItem->pExpr;\n          assert( pParent->op==TK_COLLATE );\n          while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;\n          assert( pParent->pLeft==pE );\n          pParent->pLeft = pNew;\n        }\n        sqlite3ExprDelete(db, pE);\n        pItem->u.x.iOrderByCol = (u16)iCol;\n        pItem->done = 1;\n      }else{\n        moreToDo = 1;\n      }\n    }\n    pSelect = pSelect->pNext;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    if( pOrderBy->a[i].done==0 ){\n      sqlite3ErrorMsg(pParse, \"%r ORDER BY term does not match any \"\n            \"column in the result set\", i+1);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Check every term in the ORDER BY or GROUP BY clause pOrderBy of\n** the SELECT statement pSelect.  If any term is reference to a\n** result set expression (as determined by the ExprList.a.u.x.iOrderByCol\n** field) then convert that term into a copy of the corresponding result set\n** column.\n**\n** If any errors are detected, add an error message to pParse and\n** return non-zero.  Return zero if no errors are seen.\n*/\nSQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect,      /* The SELECT statement containing the clause */\n  ExprList *pOrderBy,   /* The ORDER BY or GROUP BY clause to be processed */\n  const char *zType     /* \"ORDER\" or \"GROUP\" */\n){\n  int i;\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;\n  struct ExprList_item *pItem;\n\n  if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in %s BY clause\", zType);\n    return 1;\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );  /* sqlite3SelectNew() guarantees this */\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    if( pItem->u.x.iOrderByCol ){\n      if( pItem->u.x.iOrderByCol>pEList->nExpr ){\n        resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);\n        return 1;\n      }\n      resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,\n                   zType,0);\n    }\n  }\n  return 0;\n}\n\n/*\n** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.\n** The Name context of the SELECT statement is pNC.  zType is either\n** \"ORDER\" or \"GROUP\" depending on which type of clause pOrderBy is.\n**\n** This routine resolves each term of the clause into an expression.\n** If the order-by term is an integer I between 1 and N (where N is the\n** number of columns in the result set of the SELECT) then the expression\n** in the resolution is a copy of the I-th result-set expression.  If\n** the order-by term is an identifier that corresponds to the AS-name of\n** a result-set expression, then the term resolves to a copy of the\n** result-set expression.  Otherwise, the expression is resolved in\n** the usual way - using sqlite3ResolveExprNames().\n**\n** This routine returns the number of errors.  If errors occur, then\n** an appropriate error message might be left in pParse.  (OOM errors\n** excepted.)\n*/\nstatic int resolveOrderGroupBy(\n  NameContext *pNC,     /* The name context of the SELECT statement */\n  Select *pSelect,      /* The SELECT statement holding pOrderBy */\n  ExprList *pOrderBy,   /* An ORDER BY or GROUP BY clause to resolve */\n  const char *zType     /* Either \"ORDER\" or \"GROUP\", as appropriate */\n){\n  int i, j;                      /* Loop counters */\n  int iCol;                      /* Column number */\n  struct ExprList_item *pItem;   /* A term of the ORDER BY clause */\n  Parse *pParse;                 /* Parsing context */\n  int nResult;                   /* Number of terms in the result set */\n\n  if( pOrderBy==0 ) return 0;\n  nResult = pSelect->pEList->nExpr;\n  pParse = pNC->pParse;\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    Expr *pE = pItem->pExpr;\n    Expr *pE2 = sqlite3ExprSkipCollate(pE);\n    if( zType[0]!='G' ){\n      iCol = resolveAsName(pParse, pSelect->pEList, pE2);\n      if( iCol>0 ){\n        /* If an AS-name match is found, mark this ORDER BY column as being\n        ** a copy of the iCol-th result-set column.  The subsequent call to\n        ** sqlite3ResolveOrderGroupBy() will convert the expression to a\n        ** copy of the iCol-th result-set expression. */\n        pItem->u.x.iOrderByCol = (u16)iCol;\n        continue;\n      }\n    }\n    if( sqlite3ExprIsInteger(pE2, &iCol) ){\n      /* The ORDER BY term is an integer constant.  Again, set the column\n      ** number so that sqlite3ResolveOrderGroupBy() will convert the\n      ** order-by term to a copy of the result-set expression */\n      if( iCol<1 || iCol>0xffff ){\n        resolveOutOfRangeError(pParse, zType, i+1, nResult);\n        return 1;\n      }\n      pItem->u.x.iOrderByCol = (u16)iCol;\n      continue;\n    }\n\n    /* Otherwise, treat the ORDER BY term as an ordinary expression */\n    pItem->u.x.iOrderByCol = 0;\n    if( sqlite3ResolveExprNames(pNC, pE) ){\n      return 1;\n    }\n    for(j=0; j<pSelect->pEList->nExpr; j++){\n      if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){\n        pItem->u.x.iOrderByCol = j+1;\n      }\n    }\n  }\n  return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);\n}\n\n/*\n** Resolve names in the SELECT statement p and all of its descendants.\n*/\nstatic int resolveSelectStep(Walker *pWalker, Select *p){\n  NameContext *pOuterNC;  /* Context that contains this SELECT */\n  NameContext sNC;        /* Name context of this SELECT */\n  int isCompound;         /* True if p is a compound select */\n  int nCompound;          /* Number of compound terms processed so far */\n  Parse *pParse;          /* Parsing context */\n  int i;                  /* Loop counter */\n  ExprList *pGroupBy;     /* The GROUP BY clause */\n  Select *pLeftmost;      /* Left-most of SELECT of a compound */\n  sqlite3 *db;            /* Database connection */\n  \n\n  assert( p!=0 );\n  if( p->selFlags & SF_Resolved ){\n    return WRC_Prune;\n  }\n  pOuterNC = pWalker->u.pNC;\n  pParse = pWalker->pParse;\n  db = pParse->db;\n\n  /* Normally sqlite3SelectExpand() will be called first and will have\n  ** already expanded this SELECT.  However, if this is a subquery within\n  ** an expression, sqlite3ResolveExprNames() will be called without a\n  ** prior call to sqlite3SelectExpand().  When that happens, let\n  ** sqlite3SelectPrep() do all of the processing for this SELECT.\n  ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and\n  ** this routine in the correct order.\n  */\n  if( (p->selFlags & SF_Expanded)==0 ){\n    sqlite3SelectPrep(pParse, p, pOuterNC);\n    return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;\n  }\n\n  isCompound = p->pPrior!=0;\n  nCompound = 0;\n  pLeftmost = p;\n  while( p ){\n    assert( (p->selFlags & SF_Expanded)!=0 );\n    assert( (p->selFlags & SF_Resolved)==0 );\n    p->selFlags |= SF_Resolved;\n\n    /* Resolve the expressions in the LIMIT and OFFSET clauses. These\n    ** are not allowed to refer to any names, so pass an empty NameContext.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||\n        sqlite3ResolveExprNames(&sNC, p->pOffset) ){\n      return WRC_Abort;\n    }\n\n    /* If the SF_Converted flags is set, then this Select object was\n    ** was created by the convertCompoundSelectToSubquery() function.\n    ** In this case the ORDER BY clause (p->pOrderBy) should be resolved\n    ** as if it were part of the sub-query, not the parent. This block\n    ** moves the pOrderBy down to the sub-query. It will be moved back\n    ** after the names have been resolved.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      assert( p->pSrc->nSrc==1 && p->pOrderBy );\n      assert( pSub->pPrior && pSub->pOrderBy==0 );\n      pSub->pOrderBy = p->pOrderBy;\n      p->pOrderBy = 0;\n    }\n  \n    /* Recursively resolve names in all subqueries\n    */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->pSelect ){\n        NameContext *pNC;         /* Used to iterate name contexts */\n        int nRef = 0;             /* Refcount for pOuterNC and outer contexts */\n        const char *zSavedContext = pParse->zAuthContext;\n\n        /* Count the total number of references to pOuterNC and all of its\n        ** parent contexts. After resolving references to expressions in\n        ** pItem->pSelect, check if this value has changed. If so, then\n        ** SELECT statement pItem->pSelect must be correlated. Set the\n        ** pItem->fg.isCorrelated flag if this is the case. */\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef;\n\n        if( pItem->zName ) pParse->zAuthContext = pItem->zName;\n        sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);\n        pParse->zAuthContext = zSavedContext;\n        if( pParse->nErr || db->mallocFailed ) return WRC_Abort;\n\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef;\n        assert( pItem->fg.isCorrelated==0 && nRef<=0 );\n        pItem->fg.isCorrelated = (nRef!=0);\n      }\n    }\n  \n    /* Set up the local name-context to pass to sqlite3ResolveExprNames() to\n    ** resolve the result-set expression list.\n    */\n    sNC.ncFlags = NC_AllowAgg;\n    sNC.pSrcList = p->pSrc;\n    sNC.pNext = pOuterNC;\n  \n    /* Resolve names in the result set. */\n    if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;\n  \n    /* If there are no aggregate functions in the result-set, and no GROUP BY \n    ** expression, do not allow aggregates in any of the other expressions.\n    */\n    assert( (p->selFlags & SF_Aggregate)==0 );\n    pGroupBy = p->pGroupBy;\n    if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){\n      assert( NC_MinMaxAgg==SF_MinMaxAgg );\n      p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);\n    }else{\n      sNC.ncFlags &= ~NC_AllowAgg;\n    }\n  \n    /* If a HAVING clause is present, then there must be a GROUP BY clause.\n    */\n    if( p->pHaving && !pGroupBy ){\n      sqlite3ErrorMsg(pParse, \"a GROUP BY clause is required before HAVING\");\n      return WRC_Abort;\n    }\n  \n    /* Add the output column list to the name-context before parsing the\n    ** other expressions in the SELECT statement. This is so that\n    ** expressions in the WHERE clause (etc.) can refer to expressions by\n    ** aliases in the result set.\n    **\n    ** Minor point: If this is the case, then the expression will be\n    ** re-evaluated for each reference to it.\n    */\n    sNC.pEList = p->pEList;\n    if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;\n    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;\n\n    /* Resolve names in table-valued-function arguments */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->fg.isTabFunc\n       && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) \n      ){\n        return WRC_Abort;\n      }\n    }\n\n    /* The ORDER BY and GROUP BY clauses may not refer to terms in\n    ** outer queries \n    */\n    sNC.pNext = 0;\n    sNC.ncFlags |= NC_AllowAgg;\n\n    /* If this is a converted compound query, move the ORDER BY clause from \n    ** the sub-query back to the parent query. At this point each term\n    ** within the ORDER BY clause has been transformed to an integer value.\n    ** These integers will be replaced by copies of the corresponding result\n    ** set expressions by the call to resolveOrderGroupBy() below.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      p->pOrderBy = pSub->pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n\n    /* Process the ORDER BY clause for singleton SELECT statements.\n    ** The ORDER BY clause for compounds SELECT statements is handled\n    ** below, after all of the result-sets for all of the elements of\n    ** the compound have been resolved.\n    **\n    ** If there is an ORDER BY clause on a term of a compound-select other\n    ** than the right-most term, then that is a syntax error.  But the error\n    ** is not detected until much later, and so we need to go ahead and\n    ** resolve those symbols on the incorrect ORDER BY for consistency.\n    */\n    if( isCompound<=nCompound  /* Defer right-most ORDER BY of a compound */\n     && resolveOrderGroupBy(&sNC, p, p->pOrderBy, \"ORDER\")\n    ){\n      return WRC_Abort;\n    }\n    if( db->mallocFailed ){\n      return WRC_Abort;\n    }\n  \n    /* Resolve the GROUP BY clause.  At the same time, make sure \n    ** the GROUP BY clause does not contain aggregate functions.\n    */\n    if( pGroupBy ){\n      struct ExprList_item *pItem;\n    \n      if( resolveOrderGroupBy(&sNC, p, pGroupBy, \"GROUP\") || db->mallocFailed ){\n        return WRC_Abort;\n      }\n      for(i=0, pItem=pGroupBy->a; i<pGroupBy->nExpr; i++, pItem++){\n        if( ExprHasProperty(pItem->pExpr, EP_Agg) ){\n          sqlite3ErrorMsg(pParse, \"aggregate functions are not allowed in \"\n              \"the GROUP BY clause\");\n          return WRC_Abort;\n        }\n      }\n    }\n\n    /* If this is part of a compound SELECT, check that it has the right\n    ** number of expressions in the select list. */\n    if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){\n      sqlite3SelectWrongNumTermsError(pParse, p->pNext);\n      return WRC_Abort;\n    }\n\n    /* Advance to the next term of the compound\n    */\n    p = p->pPrior;\n    nCompound++;\n  }\n\n  /* Resolve the ORDER BY on a compound SELECT after all terms of\n  ** the compound have been resolved.\n  */\n  if( isCompound && resolveCompoundOrderBy(pParse, pLeftmost) ){\n    return WRC_Abort;\n  }\n\n  return WRC_Prune;\n}\n\n/*\n** This routine walks an expression tree and resolves references to\n** table columns and result-set columns.  At the same time, do error\n** checking on function usage and set a flag if any aggregate functions\n** are seen.\n**\n** To resolve table columns references we look for nodes (or subtrees) of the \n** form X.Y.Z or Y.Z or just Z where\n**\n**      X:   The name of a database.  Ex:  \"main\" or \"temp\" or\n**           the symbolic name assigned to an ATTACH-ed database.\n**\n**      Y:   The name of a table in a FROM clause.  Or in a trigger\n**           one of the special names \"old\" or \"new\".\n**\n**      Z:   The name of a column in table Y.\n**\n** The node at the root of the subtree is modified as follows:\n**\n**    Expr.op        Changed to TK_COLUMN\n**    Expr.pTab      Points to the Table object for X.Y\n**    Expr.iColumn   The column index in X.Y.  -1 for the rowid.\n**    Expr.iTable    The VDBE cursor number for X.Y\n**\n**\n** To resolve result-set references, look for expression nodes of the\n** form Z (with no X and Y prefix) where the Z matches the right-hand\n** size of an AS clause in the result-set of a SELECT.  The Z expression\n** is replaced by a copy of the left-hand side of the result-set expression.\n** Table-name and function resolution occurs on the substituted expression\n** tree.  For example, in:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;\n**\n** The \"x\" term of the order by is replaced by \"a+b\" to render:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;\n**\n** Function calls are checked to make sure that the function is \n** defined and that the correct number of arguments are specified.\n** If the function is an aggregate function, then the NC_HasAgg flag is\n** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.\n** If an expression contains aggregate functions then the EP_Agg\n** property on the expression is set.\n**\n** An error message is left in pParse if anything is amiss.  The number\n** if errors is returned.\n*/\nSQLITE_PRIVATE int sqlite3ResolveExprNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  Expr *pExpr             /* The expression to be analyzed. */\n){\n  u16 savedHasAgg;\n  Walker w;\n\n  if( pExpr==0 ) return SQLITE_OK;\n  savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);\n  pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);\n  w.pParse = pNC->pParse;\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.u.pNC = pNC;\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight += pExpr->nHeight;\n  if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){\n    return SQLITE_ERROR;\n  }\n#endif\n  sqlite3WalkExpr(&w, pExpr);\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight -= pExpr->nHeight;\n#endif\n  if( pNC->ncFlags & NC_HasAgg ){\n    ExprSetProperty(pExpr, EP_Agg);\n  }\n  pNC->ncFlags |= savedHasAgg;\n  return pNC->nErr>0 || w.pParse->nErr>0;\n}\n\n/*\n** Resolve all names for all expression in an expression list.  This is\n** just like sqlite3ResolveExprNames() except that it works for an expression\n** list rather than a single expression.\n*/\nSQLITE_PRIVATE int sqlite3ResolveExprListNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  ExprList *pList         /* The expression list to be analyzed. */\n){\n  int i;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Resolve all names in all expressions of a SELECT and in all\n** decendents of the SELECT, including compounds off of p->pPrior,\n** subqueries in expressions, and subqueries used as FROM clause\n** terms.\n**\n** See sqlite3ResolveExprNames() for a description of the kinds of\n** transformations that occur.\n**\n** All SELECT statements should have been expanded using\n** sqlite3SelectExpand() prior to invoking this routine.\n*/\nSQLITE_PRIVATE void sqlite3ResolveSelectNames(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for parent SELECT statement */\n){\n  Walker w;\n\n  assert( p!=0 );\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.pParse = pParse;\n  w.u.pNC = pOuterNC;\n  sqlite3WalkSelect(&w, p);\n}\n\n/*\n** Resolve names in expressions that can only reference a single table:\n**\n**    *   CHECK constraints\n**    *   WHERE clauses on partial indices\n**\n** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression\n** is set to -1 and the Expr.iColumn value is set to the column number.\n**\n** Any errors cause an error message to be set in pParse.\n*/\nSQLITE_PRIVATE void sqlite3ResolveSelfReference(\n  Parse *pParse,      /* Parsing context */\n  Table *pTab,        /* The table being referenced */\n  int type,           /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */\n  Expr *pExpr,        /* Expression to resolve.  May be NULL. */\n  ExprList *pList     /* Expression list to resolve.  May be NUL. */\n){\n  SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */\n  NameContext sNC;                /* Name context for pParse->pNewTable */\n\n  assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );\n  memset(&sNC, 0, sizeof(sNC));\n  memset(&sSrc, 0, sizeof(sSrc));\n  sSrc.nSrc = 1;\n  sSrc.a[0].zName = pTab->zName;\n  sSrc.a[0].pTab = pTab;\n  sSrc.a[0].iCursor = -1;\n  sNC.pParse = pParse;\n  sNC.pSrcList = &sSrc;\n  sNC.ncFlags = type;\n  if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;\n  if( pList ) sqlite3ResolveExprListNames(&sNC, pList);\n}\n\n/************** End of resolve.c *********************************************/\n/************** Begin file expr.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for analyzing expressions and\n** for generating VDBE code that evaluates expressions in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/* Forward declarations */\nstatic void exprCodeBetween(Parse*,Expr*,int,void(*)(Parse*,Expr*,int,int),int);\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piToFree);\n\n/*\n** Return the affinity character for a single column of a table.\n*/\nSQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){\n  assert( iCol<pTab->nCol );\n  return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER;\n}\n\n/*\n** Return the 'affinity' of the expression pExpr if any.\n**\n** If pExpr is a column, a reference to a column via an 'AS' alias,\n** or a sub-select with a column as the return value, then the \n** affinity of that column is returned. Otherwise, 0x00 is returned,\n** indicating no affinity for the expression.\n**\n** i.e. the WHERE clause expressions in the following statements all\n** have an affinity:\n**\n** CREATE TABLE t1(a);\n** SELECT * FROM t1 WHERE a;\n** SELECT a AS b FROM t1 WHERE b;\n** SELECT * FROM t1 WHERE (select a from t1);\n*/\nSQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){\n  int op;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( pExpr->flags & EP_Generic ) return 0;\n  op = pExpr->op;\n  if( op==TK_SELECT ){\n    assert( pExpr->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);\n  }\n  if( op==TK_REGISTER ) op = pExpr->op2;\n#ifndef SQLITE_OMIT_CAST\n  if( op==TK_CAST ){\n    assert( !ExprHasProperty(pExpr, EP_IntValue) );\n    return sqlite3AffinityType(pExpr->u.zToken, 0);\n  }\n#endif\n  if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){\n    return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);\n  }\n  if( op==TK_SELECT_COLUMN ){\n    assert( pExpr->pLeft->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(\n        pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr\n    );\n  }\n  return pExpr->affinity;\n}\n\n/*\n** Set the collating sequence for expression pExpr to be the collating\n** sequence named by pToken.   Return a pointer to a new Expr node that\n** implements the COLLATE operator.\n**\n** If a memory allocation error occurs, that fact is recorded in pParse->db\n** and the pExpr parameter is returned unchanged.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(\n  Parse *pParse,           /* Parsing context */\n  Expr *pExpr,             /* Add the \"COLLATE\" clause to this expression */\n  const Token *pCollName,  /* Name of collating sequence */\n  int dequote              /* True to dequote pCollName */\n){\n  if( pCollName->n>0 ){\n    Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);\n    if( pNew ){\n      pNew->pLeft = pExpr;\n      pNew->flags |= EP_Collate|EP_Skip;\n      pExpr = pNew;\n    }\n  }\n  return pExpr;\n}\nSQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){\n  Token s;\n  assert( zC!=0 );\n  sqlite3TokenInit(&s, (char*)zC);\n  return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);\n}\n\n/*\n** Skip over any TK_COLLATE operators and any unlikely()\n** or likelihood() function at the root of an expression.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){\n  while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){\n    if( ExprHasProperty(pExpr, EP_Unlikely) ){\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      assert( pExpr->x.pList->nExpr>0 );\n      assert( pExpr->op==TK_FUNCTION );\n      pExpr = pExpr->x.pList->a[0].pExpr;\n    }else{\n      assert( pExpr->op==TK_COLLATE );\n      pExpr = pExpr->pLeft;\n    }\n  }   \n  return pExpr;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return NULL.\n**\n** See also: sqlite3ExprNNCollSeq()\n**\n** The sqlite3ExprNNCollSeq() works the same exact that it returns the\n** default collation if pExpr has no defined collation.\n**\n** The collating sequence might be determined by a COLLATE operator\n** or by the presence of a column with a defined collating sequence.\n** COLLATE operators take first precedence.  Left operands take\n** precedence over right operands.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){\n  sqlite3 *db = pParse->db;\n  CollSeq *pColl = 0;\n  Expr *p = pExpr;\n  while( p ){\n    int op = p->op;\n    if( p->flags & EP_Generic ) break;\n    if( op==TK_CAST || op==TK_UPLUS ){\n      p = p->pLeft;\n      continue;\n    }\n    if( op==TK_COLLATE || (op==TK_REGISTER && p->op2==TK_COLLATE) ){\n      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);\n      break;\n    }\n    if( (op==TK_AGG_COLUMN || op==TK_COLUMN\n          || op==TK_REGISTER || op==TK_TRIGGER)\n     && p->pTab!=0\n    ){\n      /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally\n      ** a TK_COLUMN but was previously evaluated and cached in a register */\n      int j = p->iColumn;\n      if( j>=0 ){\n        const char *zColl = p->pTab->aCol[j].zColl;\n        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n      }\n      break;\n    }\n    if( p->flags & EP_Collate ){\n      if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){\n        p = p->pLeft;\n      }else{\n        Expr *pNext  = p->pRight;\n        /* The Expr.x union is never used at the same time as Expr.pRight */\n        assert( p->x.pList==0 || p->pRight==0 );\n        /* p->flags holds EP_Collate and p->pLeft->flags does not.  And\n        ** p->x.pSelect cannot.  So if p->x.pLeft exists, it must hold at\n        ** least one EP_Collate. Thus the following two ALWAYS. */\n        if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){\n          int i;\n          for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){\n            if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){\n              pNext = p->x.pList->a[i].pExpr;\n              break;\n            }\n          }\n        }\n        p = pNext;\n      }\n    }else{\n      break;\n    }\n  }\n  if( sqlite3CheckCollSeq(pParse, pColl) ){ \n    pColl = 0;\n  }\n  return pColl;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return a pointer to the\n** defautl collation sequence.\n**\n** See also: sqlite3ExprCollSeq()\n**\n** The sqlite3ExprCollSeq() routine works the same except that it\n** returns NULL if there is no defined collation.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr){\n  CollSeq *p = sqlite3ExprCollSeq(pParse, pExpr);\n  if( p==0 ) p = pParse->db->pDfltColl;\n  assert( p!=0 );\n  return p;\n}\n\n/*\n** Return TRUE if the two expressions have equivalent collating sequences.\n*/\nSQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse *pParse, Expr *pE1, Expr *pE2){\n  CollSeq *pColl1 = sqlite3ExprNNCollSeq(pParse, pE1);\n  CollSeq *pColl2 = sqlite3ExprNNCollSeq(pParse, pE2);\n  return sqlite3StrICmp(pColl1->zName, pColl2->zName)==0;\n}\n\n/*\n** pExpr is an operand of a comparison operator.  aff2 is the\n** type affinity of the other operand.  This routine returns the\n** type affinity that should be used for the comparison operator.\n*/\nSQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2){\n  char aff1 = sqlite3ExprAffinity(pExpr);\n  if( aff1 && aff2 ){\n    /* Both sides of the comparison are columns. If one has numeric\n    ** affinity, use that. Otherwise use no affinity.\n    */\n    if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){\n      return SQLITE_AFF_NUMERIC;\n    }else{\n      return SQLITE_AFF_BLOB;\n    }\n  }else if( !aff1 && !aff2 ){\n    /* Neither side of the comparison is a column.  Compare the\n    ** results directly.\n    */\n    return SQLITE_AFF_BLOB;\n  }else{\n    /* One side is a column, the other is not. Use the columns affinity. */\n    assert( aff1==0 || aff2==0 );\n    return (aff1 + aff2);\n  }\n}\n\n/*\n** pExpr is a comparison operator.  Return the type affinity that should\n** be applied to both operands prior to doing the comparison.\n*/\nstatic char comparisonAffinity(Expr *pExpr){\n  char aff;\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||\n          pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||\n          pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );\n  assert( pExpr->pLeft );\n  aff = sqlite3ExprAffinity(pExpr->pLeft);\n  if( pExpr->pRight ){\n    aff = sqlite3CompareAffinity(pExpr->pRight, aff);\n  }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);\n  }else if( aff==0 ){\n    aff = SQLITE_AFF_BLOB;\n  }\n  return aff;\n}\n\n/*\n** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.\n** idx_affinity is the affinity of an indexed column. Return true\n** if the index with affinity idx_affinity may be used to implement\n** the comparison in pExpr.\n*/\nSQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){\n  char aff = comparisonAffinity(pExpr);\n  switch( aff ){\n    case SQLITE_AFF_BLOB:\n      return 1;\n    case SQLITE_AFF_TEXT:\n      return idx_affinity==SQLITE_AFF_TEXT;\n    default:\n      return sqlite3IsNumericAffinity(idx_affinity);\n  }\n}\n\n/*\n** Return the P5 value that should be used for a binary comparison\n** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.\n*/\nstatic u8 binaryCompareP5(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){\n  u8 aff = (char)sqlite3ExprAffinity(pExpr2);\n  aff = (u8)sqlite3CompareAffinity(pExpr1, aff) | (u8)jumpIfNull;\n  return aff;\n}\n\n/*\n** Return a pointer to the collation sequence that should be used by\n** a binary comparison operator comparing pLeft and pRight.\n**\n** If the left hand expression has a collating sequence type, then it is\n** used. Otherwise the collation sequence for the right hand expression\n** is used, or the default (BINARY) if neither expression has a collating\n** type.\n**\n** Argument pRight (but not pLeft) may be a null pointer. In this case,\n** it is not considered.\n*/\nSQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(\n  Parse *pParse, \n  Expr *pLeft, \n  Expr *pRight\n){\n  CollSeq *pColl;\n  assert( pLeft );\n  if( pLeft->flags & EP_Collate ){\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n  }else if( pRight && (pRight->flags & EP_Collate)!=0 ){\n    pColl = sqlite3ExprCollSeq(pParse, pRight);\n  }else{\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n    if( !pColl ){\n      pColl = sqlite3ExprCollSeq(pParse, pRight);\n    }\n  }\n  return pColl;\n}\n\n/*\n** Generate code for a comparison operator.\n*/\nstatic int codeCompare(\n  Parse *pParse,    /* The parsing (and code generating) context */\n  Expr *pLeft,      /* The left operand */\n  Expr *pRight,     /* The right operand */\n  int opcode,       /* The comparison opcode */\n  int in1, int in2, /* Register holding operands */\n  int dest,         /* Jump here if true.  */\n  int jumpIfNull    /* If true, jump if either operand is NULL */\n){\n  int p5;\n  int addr;\n  CollSeq *p4;\n\n  p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);\n  p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);\n  addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,\n                           (void*)p4, P4_COLLSEQ);\n  sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);\n  return addr;\n}\n\n/*\n** Return true if expression pExpr is a vector, or false otherwise.\n**\n** A vector is defined as any expression that results in two or more\n** columns of result.  Every TK_VECTOR node is an vector because the\n** parser will not generate a TK_VECTOR with fewer than two entries.\n** But a TK_SELECT might be either a vector or a scalar. It is only\n** considered a vector if it has two or more result columns.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){\n  return sqlite3ExprVectorSize(pExpr)>1;\n}\n\n/*\n** If the expression passed as the only argument is of type TK_VECTOR \n** return the number of expressions in the vector. Or, if the expression\n** is a sub-select, return the number of columns in the sub-select. For\n** any other type of expression, return 1.\n*/\nSQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){\n  u8 op = pExpr->op;\n  if( op==TK_REGISTER ) op = pExpr->op2;\n  if( op==TK_VECTOR ){\n    return pExpr->x.pList->nExpr;\n  }else if( op==TK_SELECT ){\n    return pExpr->x.pSelect->pEList->nExpr;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Return a pointer to a subexpression of pVector that is the i-th\n** column of the vector (numbered starting with 0).  The caller must\n** ensure that i is within range.\n**\n** If pVector is really a scalar (and \"scalar\" here includes subqueries\n** that return a single column!) then return pVector unmodified.\n**\n** pVector retains ownership of the returned subexpression.\n**\n** If the vector is a (SELECT ...) then the expression returned is\n** just the expression for the i-th term of the result set, and may\n** not be ready for evaluation because the table cursor has not yet\n** been positioned.\n*/\nSQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){\n  assert( i<sqlite3ExprVectorSize(pVector) );\n  if( sqlite3ExprIsVector(pVector) ){\n    assert( pVector->op2==0 || pVector->op==TK_REGISTER );\n    if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){\n      return pVector->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      return pVector->x.pList->a[i].pExpr;\n    }\n  }\n  return pVector;\n}\n\n/*\n** Compute and return a new Expr object which when passed to\n** sqlite3ExprCode() will generate all necessary code to compute\n** the iField-th column of the vector expression pVector.\n**\n** It is ok for pVector to be a scalar (as long as iField==0).  \n** In that case, this routine works like sqlite3ExprDup().\n**\n** The caller owns the returned Expr object and is responsible for\n** ensuring that the returned value eventually gets freed.\n**\n** The caller retains ownership of pVector.  If pVector is a TK_SELECT,\n** then the returned object will reference pVector and so pVector must remain\n** valid for the life of the returned object.  If pVector is a TK_VECTOR\n** or a scalar expression, then it can be deleted as soon as this routine\n** returns.\n**\n** A trick to cause a TK_SELECT pVector to be deleted together with\n** the returned Expr object is to attach the pVector to the pRight field\n** of the returned TK_SELECT_COLUMN Expr object.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprForVectorField(\n  Parse *pParse,       /* Parsing context */\n  Expr *pVector,       /* The vector.  List of expressions or a sub-SELECT */\n  int iField           /* Which column of the vector to return */\n){\n  Expr *pRet;\n  if( pVector->op==TK_SELECT ){\n    assert( pVector->flags & EP_xIsSelect );\n    /* The TK_SELECT_COLUMN Expr node:\n    **\n    ** pLeft:           pVector containing TK_SELECT.  Not deleted.\n    ** pRight:          not used.  But recursively deleted.\n    ** iColumn:         Index of a column in pVector\n    ** iTable:          0 or the number of columns on the LHS of an assignment\n    ** pLeft->iTable:   First in an array of register holding result, or 0\n    **                  if the result is not yet computed.\n    **\n    ** sqlite3ExprDelete() specifically skips the recursive delete of\n    ** pLeft on TK_SELECT_COLUMN nodes.  But pRight is followed, so pVector\n    ** can be attached to pRight to cause this node to take ownership of\n    ** pVector.  Typically there will be multiple TK_SELECT_COLUMN nodes\n    ** with the same pLeft pointer to the pVector, but only one of them\n    ** will own the pVector.\n    */\n    pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);\n    if( pRet ){\n      pRet->iColumn = iField;\n      pRet->pLeft = pVector;\n    }\n    assert( pRet==0 || pRet->iTable==0 );\n  }else{\n    if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;\n    pRet = sqlite3ExprDup(pParse->db, pVector, 0);\n  }\n  return pRet;\n}\n\n/*\n** If expression pExpr is of type TK_SELECT, generate code to evaluate\n** it. Return the register in which the result is stored (or, if the \n** sub-select returns more than one column, the first in an array\n** of registers in which the result is stored).\n**\n** If pExpr is not a TK_SELECT expression, return 0.\n*/\nstatic int exprCodeSubselect(Parse *pParse, Expr *pExpr){\n  int reg = 0;\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->op==TK_SELECT ){\n    reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);\n  }\n#endif\n  return reg;\n}\n\n/*\n** Argument pVector points to a vector expression - either a TK_VECTOR\n** or TK_SELECT that returns more than one column. This function returns\n** the register number of a register that contains the value of\n** element iField of the vector.\n**\n** If pVector is a TK_SELECT expression, then code for it must have \n** already been generated using the exprCodeSubselect() routine. In this\n** case parameter regSelect should be the first in an array of registers\n** containing the results of the sub-select. \n**\n** If pVector is of type TK_VECTOR, then code for the requested field\n** is generated. In this case (*pRegFree) may be set to the number of\n** a temporary register to be freed by the caller before returning.\n**\n** Before returning, output parameter (*ppExpr) is set to point to the\n** Expr object corresponding to element iElem of the vector.\n*/\nstatic int exprVectorRegister(\n  Parse *pParse,                  /* Parse context */\n  Expr *pVector,                  /* Vector to extract element from */\n  int iField,                     /* Field to extract from pVector */\n  int regSelect,                  /* First in array of registers */\n  Expr **ppExpr,                  /* OUT: Expression element */\n  int *pRegFree                   /* OUT: Temp register to free */\n){\n  u8 op = pVector->op;\n  assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );\n  if( op==TK_REGISTER ){\n    *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);\n    return pVector->iTable+iField;\n  }\n  if( op==TK_SELECT ){\n    *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;\n     return regSelect+iField;\n  }\n  *ppExpr = pVector->x.pList->a[iField].pExpr;\n  return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);\n}\n\n/*\n** Expression pExpr is a comparison between two vector values. Compute\n** the result of the comparison (1, 0, or NULL) and write that\n** result into register dest.\n**\n** The caller must satisfy the following preconditions:\n**\n**    if pExpr->op==TK_IS:      op==TK_EQ and p5==SQLITE_NULLEQ\n**    if pExpr->op==TK_ISNOT:   op==TK_NE and p5==SQLITE_NULLEQ\n**    otherwise:                op==pExpr->op and p5==0\n*/\nstatic void codeVectorCompare(\n  Parse *pParse,        /* Code generator context */\n  Expr *pExpr,          /* The comparison operation */\n  int dest,             /* Write results into this register */\n  u8 op,                /* Comparison operator */\n  u8 p5                 /* SQLITE_NULLEQ or zero */\n){\n  Vdbe *v = pParse->pVdbe;\n  Expr *pLeft = pExpr->pLeft;\n  Expr *pRight = pExpr->pRight;\n  int nLeft = sqlite3ExprVectorSize(pLeft);\n  int i;\n  int regLeft = 0;\n  int regRight = 0;\n  u8 opx = op;\n  int addrDone = sqlite3VdbeMakeLabel(v);\n\n  if( nLeft!=sqlite3ExprVectorSize(pRight) ){\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n    return;\n  }\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_NE \n       || pExpr->op==TK_IS || pExpr->op==TK_ISNOT \n       || pExpr->op==TK_LT || pExpr->op==TK_GT \n       || pExpr->op==TK_LE || pExpr->op==TK_GE \n  );\n  assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)\n            || (pExpr->op==TK_ISNOT && op==TK_NE) );\n  assert( p5==0 || pExpr->op!=op );\n  assert( p5==SQLITE_NULLEQ || pExpr->op==op );\n\n  p5 |= SQLITE_STOREP2;\n  if( opx==TK_LE ) opx = TK_LT;\n  if( opx==TK_GE ) opx = TK_GT;\n\n  regLeft = exprCodeSubselect(pParse, pLeft);\n  regRight = exprCodeSubselect(pParse, pRight);\n\n  for(i=0; 1 /*Loop exits by \"break\"*/; i++){\n    int regFree1 = 0, regFree2 = 0;\n    Expr *pL, *pR; \n    int r1, r2;\n    assert( i>=0 && i<nLeft );\n    if( i>0 ) sqlite3ExprCachePush(pParse);\n    r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);\n    r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);\n    codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);\n    testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n    testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n    testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n    testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n    testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n    testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n    sqlite3ReleaseTempReg(pParse, regFree1);\n    sqlite3ReleaseTempReg(pParse, regFree2);\n    if( i>0 ) sqlite3ExprCachePop(pParse);\n    if( i==nLeft-1 ){\n      break;\n    }\n    if( opx==TK_EQ ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else if( opx==TK_NE ){\n      sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else{\n      assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE );\n      sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone);\n      VdbeCoverageIf(v, op==TK_LT);\n      VdbeCoverageIf(v, op==TK_GT);\n      VdbeCoverageIf(v, op==TK_LE);\n      VdbeCoverageIf(v, op==TK_GE);\n      if( i==nLeft-2 ) opx = op;\n    }\n  }\n  sqlite3VdbeResolveLabel(v, addrDone);\n}\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n/*\n** Check that argument nHeight is less than or equal to the maximum\n** expression depth allowed. If it is not, leave an error message in\n** pParse.\n*/\nSQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse *pParse, int nHeight){\n  int rc = SQLITE_OK;\n  int mxHeight = pParse->db->aLimit[SQLITE_LIMIT_EXPR_DEPTH];\n  if( nHeight>mxHeight ){\n    sqlite3ErrorMsg(pParse, \n       \"Expression tree is too large (maximum depth %d)\", mxHeight\n    );\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/* The following three functions, heightOfExpr(), heightOfExprList()\n** and heightOfSelect(), are used to determine the maximum height\n** of any expression tree referenced by the structure passed as the\n** first argument.\n**\n** If this maximum height is greater than the current value pointed\n** to by pnHeight, the second parameter, then set *pnHeight to that\n** value.\n*/\nstatic void heightOfExpr(Expr *p, int *pnHeight){\n  if( p ){\n    if( p->nHeight>*pnHeight ){\n      *pnHeight = p->nHeight;\n    }\n  }\n}\nstatic void heightOfExprList(ExprList *p, int *pnHeight){\n  if( p ){\n    int i;\n    for(i=0; i<p->nExpr; i++){\n      heightOfExpr(p->a[i].pExpr, pnHeight);\n    }\n  }\n}\nstatic void heightOfSelect(Select *p, int *pnHeight){\n  if( p ){\n    heightOfExpr(p->pWhere, pnHeight);\n    heightOfExpr(p->pHaving, pnHeight);\n    heightOfExpr(p->pLimit, pnHeight);\n    heightOfExpr(p->pOffset, pnHeight);\n    heightOfExprList(p->pEList, pnHeight);\n    heightOfExprList(p->pGroupBy, pnHeight);\n    heightOfExprList(p->pOrderBy, pnHeight);\n    heightOfSelect(p->pPrior, pnHeight);\n  }\n}\n\n/*\n** Set the Expr.nHeight variable in the structure passed as an \n** argument. An expression with no children, Expr.pList or \n** Expr.pSelect member has a height of 1. Any other expression\n** has a height equal to the maximum height of any other \n** referenced Expr plus one.\n**\n** Also propagate EP_Propagate flags up from Expr.x.pList to Expr.flags,\n** if appropriate.\n*/\nstatic void exprSetHeight(Expr *p){\n  int nHeight = 0;\n  heightOfExpr(p->pLeft, &nHeight);\n  heightOfExpr(p->pRight, &nHeight);\n  if( ExprHasProperty(p, EP_xIsSelect) ){\n    heightOfSelect(p->x.pSelect, &nHeight);\n  }else if( p->x.pList ){\n    heightOfExprList(p->x.pList, &nHeight);\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n  p->nHeight = nHeight + 1;\n}\n\n/*\n** Set the Expr.nHeight variable using the exprSetHeight() function. If\n** the height is greater than the maximum allowed expression depth,\n** leave an error in pParse.\n**\n** Also propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( pParse->nErr ) return;\n  exprSetHeight(p);\n  sqlite3ExprCheckHeight(pParse, p->nHeight);\n}\n\n/*\n** Return the maximum height of any expression tree referenced\n** by the select statement passed as an argument.\n*/\nSQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){\n  int nHeight = 0;\n  heightOfSelect(p, &nHeight);\n  return nHeight;\n}\n#else /* ABOVE:  Height enforcement enabled.  BELOW: Height enforcement off */\n/*\n** Propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nSQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n}\n#define exprSetHeight(y)\n#endif /* SQLITE_MAX_EXPR_DEPTH>0 */\n\n/*\n** This routine is the core allocator for Expr nodes.\n**\n** Construct a new expression node and return a pointer to it.  Memory\n** for this node and for the pToken argument is a single allocation\n** obtained from sqlite3DbMalloc().  The calling function\n** is responsible for making sure the node eventually gets freed.\n**\n** If dequote is true, then the token (if it exists) is dequoted.\n** If dequote is false, no dequoting is performed.  The deQuote\n** parameter is ignored if pToken is NULL or if the token does not\n** appear to be quoted.  If the quotes were of the form \"...\" (double-quotes)\n** then the EP_DblQuoted flag is set on the expression node.\n**\n** Special case:  If op==TK_INTEGER and pToken points to a string that\n** can be translated into a 32-bit integer, then the token is not\n** stored in u.zToken.  Instead, the integer values is written\n** into u.iValue and the EP_IntValue flag is set.  No extra storage\n** is allocated to hold the integer text and the dequote flag is ignored.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAlloc(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */\n  int op,                 /* Expression opcode */\n  const Token *pToken,    /* Token argument.  Might be NULL */\n  int dequote             /* True to dequote */\n){\n  Expr *pNew;\n  int nExtra = 0;\n  int iValue = 0;\n\n  assert( db!=0 );\n  if( pToken ){\n    if( op!=TK_INTEGER || pToken->z==0\n          || sqlite3GetInt32(pToken->z, &iValue)==0 ){\n      nExtra = pToken->n+1;\n      assert( iValue>=0 );\n    }\n  }\n  pNew = sqlite3DbMallocRawNN(db, sizeof(Expr)+nExtra);\n  if( pNew ){\n    memset(pNew, 0, sizeof(Expr));\n    pNew->op = (u8)op;\n    pNew->iAgg = -1;\n    if( pToken ){\n      if( nExtra==0 ){\n        pNew->flags |= EP_IntValue|EP_Leaf;\n        pNew->u.iValue = iValue;\n      }else{\n        pNew->u.zToken = (char*)&pNew[1];\n        assert( pToken->z!=0 || pToken->n==0 );\n        if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);\n        pNew->u.zToken[pToken->n] = 0;\n        if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){\n          if( pNew->u.zToken[0]=='\"' ) pNew->flags |= EP_DblQuoted;\n          sqlite3Dequote(pNew->u.zToken);\n        }\n      }\n    }\n#if SQLITE_MAX_EXPR_DEPTH>0\n    pNew->nHeight = 1;\n#endif  \n  }\n  return pNew;\n}\n\n/*\n** Allocate a new expression node from a zero-terminated token that has\n** already been dequoted.\n*/\nSQLITE_PRIVATE Expr *sqlite3Expr(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocZero() (may be null) */\n  int op,                 /* Expression opcode */\n  const char *zToken      /* Token argument.  Might be NULL */\n){\n  Token x;\n  x.z = zToken;\n  x.n = sqlite3Strlen30(zToken);\n  return sqlite3ExprAlloc(db, op, &x, 0);\n}\n\n/*\n** Attach subtrees pLeft and pRight to the Expr node pRoot.\n**\n** If pRoot==NULL that means that a memory allocation error has occurred.\n** In that case, delete the subtrees pLeft and pRight.\n*/\nSQLITE_PRIVATE void sqlite3ExprAttachSubtrees(\n  sqlite3 *db,\n  Expr *pRoot,\n  Expr *pLeft,\n  Expr *pRight\n){\n  if( pRoot==0 ){\n    assert( db->mallocFailed );\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n  }else{\n    if( pRight ){\n      pRoot->pRight = pRight;\n      pRoot->flags |= EP_Propagate & pRight->flags;\n    }\n    if( pLeft ){\n      pRoot->pLeft = pLeft;\n      pRoot->flags |= EP_Propagate & pLeft->flags;\n    }\n    exprSetHeight(pRoot);\n  }\n}\n\n/*\n** Allocate an Expr node which joins as many as two subtrees.\n**\n** One or both of the subtrees can be NULL.  Return a pointer to the new\n** Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,\n** free the subtrees and return NULL.\n*/\nSQLITE_PRIVATE Expr *sqlite3PExpr(\n  Parse *pParse,          /* Parsing context */\n  int op,                 /* Expression opcode */\n  Expr *pLeft,            /* Left operand */\n  Expr *pRight            /* Right operand */\n){\n  Expr *p;\n  if( op==TK_AND && pParse->nErr==0 ){\n    /* Take advantage of short-circuit false optimization for AND */\n    p = sqlite3ExprAnd(pParse->db, pLeft, pRight);\n  }else{\n    p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr));\n    if( p ){\n      memset(p, 0, sizeof(Expr));\n      p->op = op & TKFLG_MASK;\n      p->iAgg = -1;\n    }\n    sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);\n  }\n  if( p ) {\n    sqlite3ExprCheckHeight(pParse, p->nHeight);\n  }\n  return p;\n}\n\n/*\n** Add pSelect to the Expr.x.pSelect field.  Or, if pExpr is NULL (due\n** do a memory allocation failure) then delete the pSelect object.\n*/\nSQLITE_PRIVATE void sqlite3PExprAddSelect(Parse *pParse, Expr *pExpr, Select *pSelect){\n  if( pExpr ){\n    pExpr->x.pSelect = pSelect;\n    ExprSetProperty(pExpr, EP_xIsSelect|EP_Subquery);\n    sqlite3ExprSetHeightAndFlags(pParse, pExpr);\n  }else{\n    assert( pParse->db->mallocFailed );\n    sqlite3SelectDelete(pParse->db, pSelect);\n  }\n}\n\n\n/*\n** If the expression is always either TRUE or FALSE (respectively),\n** then return 1.  If one cannot determine the truth value of the\n** expression at compile-time return 0.\n**\n** This is an optimization.  If is OK to return 0 here even if\n** the expression really is always false or false (a false negative).\n** But it is a bug to return 1 if the expression might have different\n** boolean values in different circumstances (a false positive.)\n**\n** Note that if the expression is part of conditional for a\n** LEFT JOIN, then we cannot determine at compile-time whether or not\n** is it true or false, so always return 0.\n*/\nstatic int exprAlwaysTrue(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v!=0;\n}\nstatic int exprAlwaysFalse(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v==0;\n}\n\n/*\n** Join two expressions using an AND operator.  If either expression is\n** NULL, then just return the other expression.\n**\n** If one side or the other of the AND is known to be false, then instead\n** of returning an AND expression, just return a constant expression with\n** a value of false.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){\n  if( pLeft==0 ){\n    return pRight;\n  }else if( pRight==0 ){\n    return pLeft;\n  }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n    return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);\n  }else{\n    Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);\n    sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);\n    return pNew;\n  }\n}\n\n/*\n** Construct a new expression node for a function with multiple\n** arguments.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){\n  Expr *pNew;\n  sqlite3 *db = pParse->db;\n  assert( pToken );\n  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);\n  if( pNew==0 ){\n    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */\n    return 0;\n  }\n  pNew->x.pList = pList;\n  assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n  sqlite3ExprSetHeightAndFlags(pParse, pNew);\n  return pNew;\n}\n\n/*\n** Assign a variable number to an expression that encodes a wildcard\n** in the original SQL statement.  \n**\n** Wildcards consisting of a single \"?\" are assigned the next sequential\n** variable number.\n**\n** Wildcards of the form \"?nnn\" are assigned the number \"nnn\".  We make\n** sure \"nnn\" is not too big to avoid a denial of service attack when\n** the SQL statement comes from an external source.\n**\n** Wildcards of the form \":aaa\", \"@aaa\", or \"$aaa\" are assigned the same number\n** as the previous instance of the same wildcard.  Or if this is the first\n** instance of the wildcard, the next sequential variable number is\n** assigned.\n*/\nSQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){\n  sqlite3 *db = pParse->db;\n  const char *z;\n  ynVar x;\n\n  if( pExpr==0 ) return;\n  assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );\n  z = pExpr->u.zToken;\n  assert( z!=0 );\n  assert( z[0]!=0 );\n  assert( n==(u32)sqlite3Strlen30(z) );\n  if( z[1]==0 ){\n    /* Wildcard of the form \"?\".  Assign the next variable number */\n    assert( z[0]=='?' );\n    x = (ynVar)(++pParse->nVar);\n  }else{\n    int doAdd = 0;\n    if( z[0]=='?' ){\n      /* Wildcard of the form \"?nnn\".  Convert \"nnn\" to an integer and\n      ** use it as the variable number */\n      i64 i;\n      int bOk;\n      if( n==2 ){ /*OPTIMIZATION-IF-TRUE*/\n        i = z[1]-'0';  /* The common case of ?N for a single digit N */\n        bOk = 1;\n      }else{\n        bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8);\n      }\n      testcase( i==0 );\n      testcase( i==1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );\n      if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n        sqlite3ErrorMsg(pParse, \"variable number must be between ?1 and ?%d\",\n            db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);\n        return;\n      }\n      x = (ynVar)i;\n      if( x>pParse->nVar ){\n        pParse->nVar = (int)x;\n        doAdd = 1;\n      }else if( sqlite3VListNumToName(pParse->pVList, x)==0 ){\n        doAdd = 1;\n      }\n    }else{\n      /* Wildcards like \":aaa\", \"$aaa\" or \"@aaa\".  Reuse the same variable\n      ** number as the prior appearance of the same name, or if the name\n      ** has never appeared before, reuse the same variable number\n      */\n      x = (ynVar)sqlite3VListNameToNum(pParse->pVList, z, n);\n      if( x==0 ){\n        x = (ynVar)(++pParse->nVar);\n        doAdd = 1;\n      }\n    }\n    if( doAdd ){\n      pParse->pVList = sqlite3VListAdd(db, pParse->pVList, z, n, x);\n    }\n  }\n  pExpr->iColumn = x;\n  if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n    sqlite3ErrorMsg(pParse, \"too many SQL variables\");\n  }\n}\n\n/*\n** Recursively delete an expression tree.\n*/\nstatic SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){\n  assert( p!=0 );\n  /* Sanity check: Assert that the IntValue is non-negative if it exists */\n  assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );\n#ifdef SQLITE_DEBUG\n  if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){\n    assert( p->pLeft==0 );\n    assert( p->pRight==0 );\n    assert( p->x.pSelect==0 );\n  }\n#endif\n  if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){\n    /* The Expr.x union is never used at the same time as Expr.pRight */\n    assert( p->x.pList==0 || p->pRight==0 );\n    if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);\n    if( p->pRight ){\n      sqlite3ExprDeleteNN(db, p->pRight);\n    }else if( ExprHasProperty(p, EP_xIsSelect) ){\n      sqlite3SelectDelete(db, p->x.pSelect);\n    }else{\n      sqlite3ExprListDelete(db, p->x.pList);\n    }\n  }\n  if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);\n  if( !ExprHasProperty(p, EP_Static) ){\n    sqlite3DbFreeNN(db, p);\n  }\n}\nSQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){\n  if( p ) sqlite3ExprDeleteNN(db, p);\n}\n\n/*\n** Return the number of bytes allocated for the expression structure \n** passed as the first argument. This is always one of EXPR_FULLSIZE,\n** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.\n*/\nstatic int exprStructSize(Expr *p){\n  if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;\n  if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;\n  return EXPR_FULLSIZE;\n}\n\n/*\n** The dupedExpr*Size() routines each return the number of bytes required\n** to store a copy of an expression or expression tree.  They differ in\n** how much of the tree is measured.\n**\n**     dupedExprStructSize()     Size of only the Expr structure \n**     dupedExprNodeSize()       Size of Expr + space for token\n**     dupedExprSize()           Expr + token + subtree components\n**\n***************************************************************************\n**\n** The dupedExprStructSize() function returns two values OR-ed together:  \n** (1) the space required for a copy of the Expr structure only and \n** (2) the EP_xxx flags that indicate what the structure size should be.\n** The return values is always one of:\n**\n**      EXPR_FULLSIZE\n**      EXPR_REDUCEDSIZE   | EP_Reduced\n**      EXPR_TOKENONLYSIZE | EP_TokenOnly\n**\n** The size of the structure can be found by masking the return value\n** of this routine with 0xfff.  The flags can be found by masking the\n** return value with EP_Reduced|EP_TokenOnly.\n**\n** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size\n** (unreduced) Expr objects as they or originally constructed by the parser.\n** During expression analysis, extra information is computed and moved into\n** later parts of teh Expr object and that extra information might get chopped\n** off if the expression is reduced.  Note also that it does not work to\n** make an EXPRDUP_REDUCE copy of a reduced expression.  It is only legal\n** to reduce a pristine expression tree from the parser.  The implementation\n** of dupedExprStructSize() contain multiple assert() statements that attempt\n** to enforce this constraint.\n*/\nstatic int dupedExprStructSize(Expr *p, int flags){\n  int nSize;\n  assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */\n  assert( EXPR_FULLSIZE<=0xfff );\n  assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );\n  if( 0==flags || p->op==TK_SELECT_COLUMN ){\n    nSize = EXPR_FULLSIZE;\n  }else{\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    assert( !ExprHasProperty(p, EP_FromJoin) ); \n    assert( !ExprHasProperty(p, EP_MemToken) );\n    assert( !ExprHasProperty(p, EP_NoReduce) );\n    if( p->pLeft || p->x.pList ){\n      nSize = EXPR_REDUCEDSIZE | EP_Reduced;\n    }else{\n      assert( p->pRight==0 );\n      nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly;\n    }\n  }\n  return nSize;\n}\n\n/*\n** This function returns the space in bytes required to store the copy \n** of the Expr structure and a copy of the Expr.u.zToken string (if that\n** string is defined.)\n*/\nstatic int dupedExprNodeSize(Expr *p, int flags){\n  int nByte = dupedExprStructSize(p, flags) & 0xfff;\n  if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n    nByte += sqlite3Strlen30(p->u.zToken)+1;\n  }\n  return ROUND8(nByte);\n}\n\n/*\n** Return the number of bytes required to create a duplicate of the \n** expression passed as the first argument. The second argument is a\n** mask containing EXPRDUP_XXX flags.\n**\n** The value returned includes space to create a copy of the Expr struct\n** itself and the buffer referred to by Expr.u.zToken, if any.\n**\n** If the EXPRDUP_REDUCE flag is set, then the return value includes \n** space to duplicate all Expr nodes in the tree formed by Expr.pLeft \n** and Expr.pRight variables (but not for any structures pointed to or \n** descended from the Expr.x.pList or Expr.x.pSelect variables).\n*/\nstatic int dupedExprSize(Expr *p, int flags){\n  int nByte = 0;\n  if( p ){\n    nByte = dupedExprNodeSize(p, flags);\n    if( flags&EXPRDUP_REDUCE ){\n      nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags);\n    }\n  }\n  return nByte;\n}\n\n/*\n** This function is similar to sqlite3ExprDup(), except that if pzBuffer \n** is not NULL then *pzBuffer is assumed to point to a buffer large enough \n** to store the copy of expression p, the copies of p->u.zToken\n** (if applicable), and the copies of the p->pLeft and p->pRight expressions,\n** if any. Before returning, *pzBuffer is set to the first byte past the\n** portion of the buffer copied into by this function.\n*/\nstatic Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){\n  Expr *pNew;           /* Value to return */\n  u8 *zAlloc;           /* Memory space from which to build Expr object */\n  u32 staticFlag;       /* EP_Static if space not obtained from malloc */\n\n  assert( db!=0 );\n  assert( p );\n  assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE );\n  assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE );\n\n  /* Figure out where to write the new Expr structure. */\n  if( pzBuffer ){\n    zAlloc = *pzBuffer;\n    staticFlag = EP_Static;\n  }else{\n    zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));\n    staticFlag = 0;\n  }\n  pNew = (Expr *)zAlloc;\n\n  if( pNew ){\n    /* Set nNewSize to the size allocated for the structure pointed to\n    ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or\n    ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed\n    ** by the copy of the p->u.zToken string (if any).\n    */\n    const unsigned nStructSize = dupedExprStructSize(p, dupFlags);\n    const int nNewSize = nStructSize & 0xfff;\n    int nToken;\n    if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n      nToken = sqlite3Strlen30(p->u.zToken) + 1;\n    }else{\n      nToken = 0;\n    }\n    if( dupFlags ){\n      assert( ExprHasProperty(p, EP_Reduced)==0 );\n      memcpy(zAlloc, p, nNewSize);\n    }else{\n      u32 nSize = (u32)exprStructSize(p);\n      memcpy(zAlloc, p, nSize);\n      if( nSize<EXPR_FULLSIZE ){ \n        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);\n      }\n    }\n\n    /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */\n    pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);\n    pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);\n    pNew->flags |= staticFlag;\n\n    /* Copy the p->u.zToken string, if any. */\n    if( nToken ){\n      char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize];\n      memcpy(zToken, p->u.zToken, nToken);\n    }\n\n    if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){\n      /* Fill in the pNew->x.pSelect or pNew->x.pList member. */\n      if( ExprHasProperty(p, EP_xIsSelect) ){\n        pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);\n      }else{\n        pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);\n      }\n    }\n\n    /* Fill in pNew->pLeft and pNew->pRight. */\n    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){\n      zAlloc += dupedExprNodeSize(p, dupFlags);\n      if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){\n        pNew->pLeft = p->pLeft ?\n                      exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;\n        pNew->pRight = p->pRight ?\n                       exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;\n      }\n      if( pzBuffer ){\n        *pzBuffer = zAlloc;\n      }\n    }else{\n      if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){\n        if( pNew->op==TK_SELECT_COLUMN ){\n          pNew->pLeft = p->pLeft;\n          assert( p->iColumn==0 || p->pRight==0 );\n          assert( p->pRight==0  || p->pRight==p->pLeft );\n        }else{\n          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);\n        }\n        pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);\n      }\n    }\n  }\n  return pNew;\n}\n\n/*\n** Create and return a deep copy of the object passed as the second \n** argument. If an OOM condition is encountered, NULL is returned\n** and the db->mallocFailed flag set.\n*/\n#ifndef SQLITE_OMIT_CTE\nstatic With *withDup(sqlite3 *db, With *p){\n  With *pRet = 0;\n  if( p ){\n    int nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);\n    pRet = sqlite3DbMallocZero(db, nByte);\n    if( pRet ){\n      int i;\n      pRet->nCte = p->nCte;\n      for(i=0; i<p->nCte; i++){\n        pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0);\n        pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0);\n        pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName);\n      }\n    }\n  }\n  return pRet;\n}\n#else\n# define withDup(x,y) 0\n#endif\n\n/*\n** The following group of routines make deep copies of expressions,\n** expression lists, ID lists, and select statements.  The copies can\n** be deleted (by being passed to their respective ...Delete() routines)\n** without effecting the originals.\n**\n** The expression list, ID, and source lists return by sqlite3ExprListDup(),\n** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded \n** by subsequent calls to sqlite*ListAppend() routines.\n**\n** Any tables that the SrcList might point to are not duplicated.\n**\n** The flags parameter contains a combination of the EXPRDUP_XXX flags.\n** If the EXPRDUP_REDUCE flag is set, then the structure returned is a\n** truncated version of the usual Expr structure that will be stored as\n** part of the in-memory representation of the database schema.\n*/\nSQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){\n  assert( flags==0 || flags==EXPRDUP_REDUCE );\n  return p ? exprDup(db, p, flags, 0) : 0;\n}\nSQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){\n  ExprList *pNew;\n  struct ExprList_item *pItem, *pOldItem;\n  int i;\n  Expr *pPriorSelectCol = 0;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));\n  if( pNew==0 ) return 0;\n  pNew->nExpr = p->nExpr;\n  pItem = pNew->a;\n  pOldItem = p->a;\n  for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){\n    Expr *pOldExpr = pOldItem->pExpr;\n    Expr *pNewExpr;\n    pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);\n    if( pOldExpr \n     && pOldExpr->op==TK_SELECT_COLUMN\n     && (pNewExpr = pItem->pExpr)!=0 \n    ){\n      assert( pNewExpr->iColumn==0 || i>0 );\n      if( pNewExpr->iColumn==0 ){\n        assert( pOldExpr->pLeft==pOldExpr->pRight );\n        pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;\n      }else{\n        assert( i>0 );\n        assert( pItem[-1].pExpr!=0 );\n        assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );\n        assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );\n        pNewExpr->pLeft = pPriorSelectCol;\n      }\n    }\n    pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);\n    pItem->sortOrder = pOldItem->sortOrder;\n    pItem->done = 0;\n    pItem->bSpanIsTab = pOldItem->bSpanIsTab;\n    pItem->u = pOldItem->u;\n  }\n  return pNew;\n}\n\n/*\n** If cursors, triggers, views and subqueries are all omitted from\n** the build, then none of the following routines, except for \n** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes\n** called with a NULL argument.\n*/\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \\\n || !defined(SQLITE_OMIT_SUBQUERY)\nSQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){\n  SrcList *pNew;\n  int i;\n  int nByte;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);\n  pNew = sqlite3DbMallocRawNN(db, nByte );\n  if( pNew==0 ) return 0;\n  pNew->nSrc = pNew->nAlloc = p->nSrc;\n  for(i=0; i<p->nSrc; i++){\n    struct SrcList_item *pNewItem = &pNew->a[i];\n    struct SrcList_item *pOldItem = &p->a[i];\n    Table *pTab;\n    pNewItem->pSchema = pOldItem->pSchema;\n    pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase);\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);\n    pNewItem->fg = pOldItem->fg;\n    pNewItem->iCursor = pOldItem->iCursor;\n    pNewItem->addrFillSub = pOldItem->addrFillSub;\n    pNewItem->regReturn = pOldItem->regReturn;\n    if( pNewItem->fg.isIndexedBy ){\n      pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy);\n    }\n    pNewItem->pIBIndex = pOldItem->pIBIndex;\n    if( pNewItem->fg.isTabFunc ){\n      pNewItem->u1.pFuncArg = \n          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);\n    }\n    pTab = pNewItem->pTab = pOldItem->pTab;\n    if( pTab ){\n      pTab->nTabRef++;\n    }\n    pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags);\n    pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags);\n    pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing);\n    pNewItem->colUsed = pOldItem->colUsed;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){\n  IdList *pNew;\n  int i;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  pNew->nId = p->nId;\n  pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) );\n  if( pNew->a==0 ){\n    sqlite3DbFreeNN(db, pNew);\n    return 0;\n  }\n  /* Note that because the size of the allocation for p->a[] is not\n  ** necessarily a power of two, sqlite3IdListAppend() may not be called\n  ** on the duplicate created by this function. */\n  for(i=0; i<p->nId; i++){\n    struct IdList_item *pNewItem = &pNew->a[i];\n    struct IdList_item *pOldItem = &p->a[i];\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->idx = pOldItem->idx;\n  }\n  return pNew;\n}\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){\n  Select *pRet = 0;\n  Select *pNext = 0;\n  Select **pp = &pRet;\n  Select *p;\n\n  assert( db!=0 );\n  for(p=pDup; p; p=p->pPrior){\n    Select *pNew = sqlite3DbMallocRawNN(db, sizeof(*p) );\n    if( pNew==0 ) break;\n    pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags);\n    pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags);\n    pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags);\n    pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags);\n    pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags);\n    pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags);\n    pNew->op = p->op;\n    pNew->pNext = pNext;\n    pNew->pPrior = 0;\n    pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags);\n    pNew->pOffset = sqlite3ExprDup(db, p->pOffset, flags);\n    pNew->iLimit = 0;\n    pNew->iOffset = 0;\n    pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;\n    pNew->addrOpenEphm[0] = -1;\n    pNew->addrOpenEphm[1] = -1;\n    pNew->nSelectRow = p->nSelectRow;\n    pNew->pWith = withDup(db, p->pWith);\n    sqlite3SelectSetName(pNew, p->zSelName);\n    *pp = pNew;\n    pp = &pNew->pPrior;\n    pNext = pNew;\n  }\n\n  return pRet;\n}\n#else\nSQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){\n  assert( p==0 );\n  return 0;\n}\n#endif\n\n\n/*\n** Add a new element to the end of an expression list.  If pList is\n** initially NULL, then create a new expression list.\n**\n** The pList argument must be either NULL or a pointer to an ExprList\n** obtained from a prior call to sqlite3ExprListAppend().  This routine\n** may not be used with an ExprList obtained from sqlite3ExprListDup().\n** Reason:  This routine assumes that the number of slots in pList->a[]\n** is a power of two.  That is true for sqlite3ExprListAppend() returns\n** but is not necessarily true from the return value of sqlite3ExprListDup().\n**\n** If a memory allocation error occurs, the entire list is freed and\n** NULL is returned.  If non-NULL is returned, then it is guaranteed\n** that the new entry was successfully appended.\n*/\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppend(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to append. Might be NULL */\n  Expr *pExpr             /* Expression to be appended. Might be NULL */\n){\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  assert( db!=0 );\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) );\n    if( pList==0 ){\n      goto no_mem;\n    }\n    pList->nExpr = 0;\n  }else if( (pList->nExpr & (pList->nExpr-1))==0 ){\n    ExprList *pNew;\n    pNew = sqlite3DbRealloc(db, pList, \n             sizeof(*pList)+(2*pList->nExpr - 1)*sizeof(pList->a[0]));\n    if( pNew==0 ){\n      goto no_mem;\n    }\n    pList = pNew;\n  }\n  pItem = &pList->a[pList->nExpr++];\n  assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) );\n  assert( offsetof(struct ExprList_item,pExpr)==0 );\n  memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName));\n  pItem->pExpr = pExpr;\n  return pList;\n\nno_mem:     \n  /* Avoid leaking memory if malloc has failed. */\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3ExprListDelete(db, pList);\n  return 0;\n}\n\n/*\n** pColumns and pExpr form a vector assignment which is part of the SET\n** clause of an UPDATE statement.  Like this:\n**\n**        (a,b,c) = (expr1,expr2,expr3)\n** Or:    (a,b,c) = (SELECT x,y,z FROM ....)\n**\n** For each term of the vector assignment, append new entries to the\n** expression list pList.  In the case of a subquery on the RHS, append\n** TK_SELECT_COLUMN expressions.\n*/\nSQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pList,       /* List to which to append. Might be NULL */\n  IdList *pColumns,      /* List of names of LHS of the assignment */\n  Expr *pExpr            /* Vector expression to be appended. Might be NULL */\n){\n  sqlite3 *db = pParse->db;\n  int n;\n  int i;\n  int iFirst = pList ? pList->nExpr : 0;\n  /* pColumns can only be NULL due to an OOM but an OOM will cause an\n  ** exit prior to this routine being invoked */\n  if( NEVER(pColumns==0) ) goto vector_append_error;\n  if( pExpr==0 ) goto vector_append_error;\n\n  /* If the RHS is a vector, then we can immediately check to see that \n  ** the size of the RHS and LHS match.  But if the RHS is a SELECT, \n  ** wildcards (\"*\") in the result set of the SELECT must be expanded before\n  ** we can do the size check, so defer the size check until code generation.\n  */\n  if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){\n    sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                    pColumns->nId, n);\n    goto vector_append_error;\n  }\n\n  for(i=0; i<pColumns->nId; i++){\n    Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);\n    pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);\n    if( pList ){\n      assert( pList->nExpr==iFirst+i+1 );\n      pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;\n      pColumns->a[i].zName = 0;\n    }\n  }\n\n  if( !db->mallocFailed && pExpr->op==TK_SELECT && ALWAYS(pList!=0) ){\n    Expr *pFirst = pList->a[iFirst].pExpr;\n    assert( pFirst!=0 );\n    assert( pFirst->op==TK_SELECT_COLUMN );\n     \n    /* Store the SELECT statement in pRight so it will be deleted when\n    ** sqlite3ExprListDelete() is called */\n    pFirst->pRight = pExpr;\n    pExpr = 0;\n\n    /* Remember the size of the LHS in iTable so that we can check that\n    ** the RHS and LHS sizes match during code generation. */\n    pFirst->iTable = pColumns->nId;\n  }\n\nvector_append_error:\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3IdListDelete(db, pColumns);\n  return pList;\n}\n\n/*\n** Set the sort order for the last element on the given ExprList.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){\n  if( p==0 ) return;\n  assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 );\n  assert( p->nExpr>0 );\n  if( iSortOrder<0 ){\n    assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC );\n    return;\n  }\n  p->a[p->nExpr-1].sortOrder = (u8)iSortOrder;\n}\n\n/*\n** Set the ExprList.a[].zName element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pName should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetName(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  Token *pName,           /* Name to be added */\n  int dequote             /* True to cause the name to be dequoted */\n){\n  assert( pList!=0 || pParse->db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem;\n    assert( pList->nExpr>0 );\n    pItem = &pList->a[pList->nExpr-1];\n    assert( pItem->zName==0 );\n    pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);\n    if( dequote ) sqlite3Dequote(pItem->zName);\n  }\n}\n\n/*\n** Set the ExprList.a[].zSpan element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pSpan should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nSQLITE_PRIVATE void sqlite3ExprListSetSpan(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  ExprSpan *pSpan         /* The span to be added */\n){\n  sqlite3 *db = pParse->db;\n  assert( pList!=0 || db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem = &pList->a[pList->nExpr-1];\n    assert( pList->nExpr>0 );\n    assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem->zSpan = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                    (int)(pSpan->zEnd - pSpan->zStart));\n  }\n}\n\n/*\n** If the expression list pEList contains more than iLimit elements,\n** leave an error message in pParse.\n*/\nSQLITE_PRIVATE void sqlite3ExprListCheckLength(\n  Parse *pParse,\n  ExprList *pEList,\n  const char *zObject\n){\n  int mx = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];\n  testcase( pEList && pEList->nExpr==mx );\n  testcase( pEList && pEList->nExpr==mx+1 );\n  if( pEList && pEList->nExpr>mx ){\n    sqlite3ErrorMsg(pParse, \"too many columns in %s\", zObject);\n  }\n}\n\n/*\n** Delete an entire expression list.\n*/\nstatic SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){\n  int i = pList->nExpr;\n  struct ExprList_item *pItem =  pList->a;\n  assert( pList->nExpr>0 );\n  do{\n    sqlite3ExprDelete(db, pItem->pExpr);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem++;\n  }while( --i>0 );\n  sqlite3DbFreeNN(db, pList);\n}\nSQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){\n  if( pList ) exprListDeleteNN(db, pList);\n}\n\n/*\n** Return the bitwise-OR of all Expr.flags fields in the given\n** ExprList.\n*/\nSQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){\n  int i;\n  u32 m = 0;\n  assert( pList!=0 );\n  for(i=0; i<pList->nExpr; i++){\n     Expr *pExpr = pList->a[i].pExpr;\n     assert( pExpr!=0 );\n     m |= pExpr->flags;\n  }\n  return m;\n}\n\n/*\n** This is a SELECT-node callback for the expression walker that\n** always \"fails\".  By \"fail\" in this case, we mean set\n** pWalker->eCode to zero and abort.\n**\n** This callback is used by multiple expression walkers.\n*/\nSQLITE_PRIVATE int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  pWalker->eCode = 0;\n  return WRC_Abort;\n}\n\n/*\n** These routines are Walker callbacks used to check expressions to\n** see if they are \"constant\" for some definition of constant.  The\n** Walker.eCode value determines the type of \"constant\" we are looking\n** for.\n**\n** These callback routines are used to implement the following:\n**\n**     sqlite3ExprIsConstant()                  pWalker->eCode==1\n**     sqlite3ExprIsConstantNotJoin()           pWalker->eCode==2\n**     sqlite3ExprIsTableConstant()             pWalker->eCode==3\n**     sqlite3ExprIsConstantOrFunction()        pWalker->eCode==4 or 5\n**\n** In all cases, the callbacks set Walker.eCode=0 and abort if the expression\n** is found to not be a constant.\n**\n** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions\n** in a CREATE TABLE statement.  The Walker.eCode value is 5 when parsing\n** an existing schema and 4 when processing a new statement.  A bound\n** parameter raises an error for new statements, but is silently converted\n** to NULL for existing schemas.  This allows sqlite_master tables that \n** contain a bound parameter because they were generated by older versions\n** of SQLite to be parsed by newer versions of SQLite without raising a\n** malformed schema error.\n*/\nstatic int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){\n\n  /* If pWalker->eCode is 2 then any term of the expression that comes from\n  ** the ON or USING clauses of a left join disqualifies the expression\n  ** from being considered constant. */\n  if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  switch( pExpr->op ){\n    /* Consider functions to be constant if all their arguments are constant\n    ** and either pWalker->eCode==4 or 5 or the function has the\n    ** SQLITE_FUNC_CONST flag. */\n    case TK_FUNCTION:\n      if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){\n        return WRC_Continue;\n      }else{\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n    case TK_ID:\n    case TK_COLUMN:\n    case TK_AGG_FUNCTION:\n    case TK_AGG_COLUMN:\n      testcase( pExpr->op==TK_ID );\n      testcase( pExpr->op==TK_COLUMN );\n      testcase( pExpr->op==TK_AGG_FUNCTION );\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){\n        return WRC_Continue;\n      }\n      /* Fall through */\n    case TK_IF_NULL_ROW:\n      testcase( pExpr->op==TK_IF_NULL_ROW );\n      pWalker->eCode = 0;\n      return WRC_Abort;\n    case TK_VARIABLE:\n      if( pWalker->eCode==5 ){\n        /* Silently convert bound parameters that appear inside of CREATE\n        ** statements into a NULL when parsing the CREATE statement text out\n        ** of the sqlite_master table */\n        pExpr->op = TK_NULL;\n      }else if( pWalker->eCode==4 ){\n        /* A bound parameter in a CREATE statement that originates from\n        ** sqlite3_prepare() causes an error */\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n      /* Fall through */\n    default:\n      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail will disallow */\n      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail will disallow */\n      return WRC_Continue;\n  }\n}\nstatic int exprIsConst(Expr *p, int initFlag, int iCur){\n  Walker w;\n  w.eCode = initFlag;\n  w.xExprCallback = exprNodeIsConstant;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  w.u.iCur = iCur;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** and 0 if it involves variables or function calls.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){\n  return exprIsConst(p, 1, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** that does no originate from the ON or USING clauses of a join.\n** Return 0 if it involves variables or function calls or terms from\n** an ON or USING clause.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){\n  return exprIsConst(p, 2, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** for any single row of the table with cursor iCur.  In other words, the\n** expression must not refer to any non-deterministic function nor any\n** table other than iCur.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){\n  return exprIsConst(p, 3, iCur);\n}\n\n\n/*\n** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy().\n*/\nstatic int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){\n  ExprList *pGroupBy = pWalker->u.pGroupBy;\n  int i;\n\n  /* Check if pExpr is identical to any GROUP BY term. If so, consider\n  ** it constant.  */\n  for(i=0; i<pGroupBy->nExpr; i++){\n    Expr *p = pGroupBy->a[i].pExpr;\n    if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pWalker->pParse, p);\n      if( sqlite3_stricmp(\"BINARY\", pColl->zName)==0 ){\n        return WRC_Prune;\n      }\n    }\n  }\n\n  /* Check if pExpr is a sub-select. If so, consider it variable. */\n  if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  return exprNodeIsConstant(pWalker, pExpr);\n}\n\n/*\n** Walk the expression tree passed as the first argument. Return non-zero\n** if the expression consists entirely of constants or copies of terms \n** in pGroupBy that sort with the BINARY collation sequence.\n**\n** This routine is used to determine if a term of the HAVING clause can\n** be promoted into the WHERE clause.  In order for such a promotion to work,\n** the value of the HAVING clause term must be the same for all members of\n** a \"group\".  The requirement that the GROUP BY term must be BINARY\n** assumes that no other collating sequence will have a finer-grained\n** grouping than binary.  In other words (A=B COLLATE binary) implies\n** A=B in every other collating sequence.  The requirement that the\n** GROUP BY be BINARY is stricter than necessary.  It would also work\n** to promote HAVING clauses that use the same alternative collating\n** sequence as the GROUP BY term, but that is much harder to check,\n** alternative collating sequences are uncommon, and this is only an\n** optimization, so we take the easy way out and simply require the\n** GROUP BY to use the BINARY collating sequence.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsConstantOrGroupBy;\n  w.xSelectCallback = 0;\n  w.u.pGroupBy = pGroupBy;\n  w.pParse = pParse;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** or a function call with constant arguments.  Return and 0 if there\n** are any variables.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){\n  assert( isInit==0 || isInit==1 );\n  return exprIsConst(p, 4+isInit, 0);\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Walk an expression tree.  Return 1 if the expression contains a\n** subquery of some kind.  Return 0 if there are no subqueries.\n*/\nSQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  sqlite3WalkExpr(&w, p);\n  return w.eCode==0;\n}\n#endif\n\n/*\n** If the expression p codes a constant integer that is small enough\n** to fit in a 32-bit integer, return 1 and put the value of the integer\n** in *pValue.  If the expression is not an integer or if it is too big\n** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.\n*/\nSQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){\n  int rc = 0;\n  if( p==0 ) return 0;  /* Can only happen following on OOM */\n\n  /* If an expression is an integer literal that fits in a signed 32-bit\n  ** integer, then the EP_IntValue flag will have already been set */\n  assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0\n           || sqlite3GetInt32(p->u.zToken, &rc)==0 );\n\n  if( p->flags & EP_IntValue ){\n    *pValue = p->u.iValue;\n    return 1;\n  }\n  switch( p->op ){\n    case TK_UPLUS: {\n      rc = sqlite3ExprIsInteger(p->pLeft, pValue);\n      break;\n    }\n    case TK_UMINUS: {\n      int v;\n      if( sqlite3ExprIsInteger(p->pLeft, &v) ){\n        assert( v!=(-2147483647-1) );\n        *pValue = -v;\n        rc = 1;\n      }\n      break;\n    }\n    default: break;\n  }\n  return rc;\n}\n\n/*\n** Return FALSE if there is no chance that the expression can be NULL.\n**\n** If the expression might be NULL or if the expression is too complex\n** to tell return TRUE.  \n**\n** This routine is used as an optimization, to skip OP_IsNull opcodes\n** when we know that a value cannot be NULL.  Hence, a false positive\n** (returning TRUE when in fact the expression can never be NULL) might\n** be a small performance hit but is otherwise harmless.  On the other\n** hand, a false negative (returning FALSE when the result could be NULL)\n** will likely result in an incorrect answer.  So when in doubt, return\n** TRUE.\n*/\nSQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){\n  u8 op;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER:\n    case TK_STRING:\n    case TK_FLOAT:\n    case TK_BLOB:\n      return 0;\n    case TK_COLUMN:\n      return ExprHasProperty(p, EP_CanBeNull) ||\n             p->pTab==0 ||  /* Reference to column of index on expression */\n             (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);\n    default:\n      return 1;\n  }\n}\n\n/*\n** Return TRUE if the given expression is a constant which would be\n** unchanged by OP_Affinity with the affinity given in the second\n** argument.\n**\n** This routine is used to determine if the OP_Affinity operation\n** can be omitted.  When in doubt return FALSE.  A false negative\n** is harmless.  A false positive, however, can result in the wrong\n** answer.\n*/\nSQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){\n  u8 op;\n  if( aff==SQLITE_AFF_BLOB ) return 1;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER: {\n      return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_FLOAT: {\n      return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_STRING: {\n      return aff==SQLITE_AFF_TEXT;\n    }\n    case TK_BLOB: {\n      return 1;\n    }\n    case TK_COLUMN: {\n      assert( p->iTable>=0 );  /* p cannot be part of a CHECK constraint */\n      return p->iColumn<0\n          && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);\n    }\n    default: {\n      return 0;\n    }\n  }\n}\n\n/*\n** Return TRUE if the given string is a row-id column name.\n*/\nSQLITE_PRIVATE int sqlite3IsRowid(const char *z){\n  if( sqlite3StrICmp(z, \"_ROWID_\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"ROWID\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"OID\")==0 ) return 1;\n  return 0;\n}\n\n/*\n** pX is the RHS of an IN operator.  If pX is a SELECT statement \n** that can be simplified to a direct table access, then return\n** a pointer to the SELECT statement.  If pX is not a SELECT statement,\n** or if the SELECT statement needs to be manifested into a transient\n** table, then return NULL.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nstatic Select *isCandidateForInOpt(Expr *pX){\n  Select *p;\n  SrcList *pSrc;\n  ExprList *pEList;\n  Table *pTab;\n  int i;\n  if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0;  /* Not a subquery */\n  if( ExprHasProperty(pX, EP_VarSelect)  ) return 0;  /* Correlated subq */\n  p = pX->x.pSelect;\n  if( p->pPrior ) return 0;              /* Not a compound SELECT */\n  if( p->selFlags & (SF_Distinct|SF_Aggregate) ){\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n    return 0; /* No DISTINCT keyword and no aggregate functions */\n  }\n  assert( p->pGroupBy==0 );              /* Has no GROUP BY clause */\n  if( p->pLimit ) return 0;              /* Has no LIMIT clause */\n  assert( p->pOffset==0 );               /* No LIMIT means no OFFSET */\n  if( p->pWhere ) return 0;              /* Has no WHERE clause */\n  pSrc = p->pSrc;\n  assert( pSrc!=0 );\n  if( pSrc->nSrc!=1 ) return 0;          /* Single term in FROM clause */\n  if( pSrc->a[0].pSelect ) return 0;     /* FROM is not a subquery or view */\n  pTab = pSrc->a[0].pTab;\n  assert( pTab!=0 );\n  assert( pTab->pSelect==0 );            /* FROM clause is not a view */\n  if( IsVirtual(pTab) ) return 0;        /* FROM clause not a virtual table */\n  pEList = p->pEList;\n  assert( pEList!=0 );\n  /* All SELECT results must be columns. */\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *pRes = pEList->a[i].pExpr;\n    if( pRes->op!=TK_COLUMN ) return 0;\n    assert( pRes->iTable==pSrc->a[0].iCursor );  /* Not a correlated subquery */\n  }\n  return p;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code that checks the left-most column of index table iCur to see if\n** it contains any NULL entries.  Cause the register at regHasNull to be set\n** to a non-NULL value if iCur contains no NULLs.  Cause register regHasNull\n** to be set to NULL if iCur contains one or more NULL values.\n*/\nstatic void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){\n  int addr1;\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regHasNull);\n  addr1 = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);\n  sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n  VdbeComment((v, \"first_entry_in(%d)\", iCur));\n  sqlite3VdbeJumpHere(v, addr1);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** The argument is an IN operator with a list (not a subquery) on the \n** right-hand side.  Return TRUE if that list is constant.\n*/\nstatic int sqlite3InRhsIsConstant(Expr *pIn){\n  Expr *pLHS;\n  int res;\n  assert( !ExprHasProperty(pIn, EP_xIsSelect) );\n  pLHS = pIn->pLeft;\n  pIn->pLeft = 0;\n  res = sqlite3ExprIsConstant(pIn);\n  pIn->pLeft = pLHS;\n  return res;\n}\n#endif\n\n/*\n** This function is used by the implementation of the IN (...) operator.\n** The pX parameter is the expression on the RHS of the IN operator, which\n** might be either a list of expressions or a subquery.\n**\n** The job of this routine is to find or create a b-tree object that can\n** be used either to test for membership in the RHS set or to iterate through\n** all members of the RHS set, skipping duplicates.\n**\n** A cursor is opened on the b-tree object that is the RHS of the IN operator\n** and pX->iTable is set to the index of that cursor.\n**\n** The returned value of this function indicates the b-tree type, as follows:\n**\n**   IN_INDEX_ROWID      - The cursor was opened on a database table.\n**   IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.\n**   IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.\n**   IN_INDEX_EPH        - The cursor was opened on a specially created and\n**                         populated epheremal table.\n**   IN_INDEX_NOOP       - No cursor was allocated.  The IN operator must be\n**                         implemented as a sequence of comparisons.\n**\n** An existing b-tree might be used if the RHS expression pX is a simple\n** subquery such as:\n**\n**     SELECT <column1>, <column2>... FROM <table>\n**\n** If the RHS of the IN operator is a list or a more complex subquery, then\n** an ephemeral table might need to be generated from the RHS and then\n** pX->iTable made to point to the ephemeral table instead of an\n** existing table.\n**\n** The inFlags parameter must contain exactly one of the bits\n** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP.  If inFlags contains\n** IN_INDEX_MEMBERSHIP, then the generated table will be used for a\n** fast membership test.  When the IN_INDEX_LOOP bit is set, the\n** IN index will be used to loop over all values of the RHS of the\n** IN operator.\n**\n** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate\n** through the set members) then the b-tree must not contain duplicates.\n** An epheremal table must be used unless the selected columns are guaranteed\n** to be unique - either because it is an INTEGER PRIMARY KEY or due to\n** a UNIQUE constraint or index.\n**\n** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used \n** for fast set membership tests) then an epheremal table must \n** be used unless <columns> is a single INTEGER PRIMARY KEY column or an \n** index can be found with the specified <columns> as its left-most.\n**\n** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and\n** if the RHS of the IN operator is a list (not a subquery) then this\n** routine might decide that creating an ephemeral b-tree for membership\n** testing is too expensive and return IN_INDEX_NOOP.  In that case, the\n** calling routine should implement the IN operator using a sequence\n** of Eq or Ne comparison operations.\n**\n** When the b-tree is being used for membership tests, the calling function\n** might need to know whether or not the RHS side of the IN operator\n** contains a NULL.  If prRhsHasNull is not a NULL pointer and \n** if there is any chance that the (...) might contain a NULL value at\n** runtime, then a register is allocated and the register number written\n** to *prRhsHasNull. If there is no chance that the (...) contains a\n** NULL value, then *prRhsHasNull is left unchanged.\n**\n** If a register is allocated and its location stored in *prRhsHasNull, then\n** the value in that register will be NULL if the b-tree contains one or more\n** NULL values, and it will be some non-NULL value if the b-tree contains no\n** NULL values.\n**\n** If the aiMap parameter is not NULL, it must point to an array containing\n** one element for each column returned by the SELECT statement on the RHS\n** of the IN(...) operator. The i'th entry of the array is populated with the\n** offset of the index column that matches the i'th column returned by the\n** SELECT. For example, if the expression and selected index are:\n**\n**   (?,?,?) IN (SELECT a, b, c FROM t1)\n**   CREATE INDEX i1 ON t1(b, c, a);\n**\n** then aiMap[] is populated with {2, 0, 1}.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3FindInIndex(\n  Parse *pParse,             /* Parsing context */\n  Expr *pX,                  /* The right-hand side (RHS) of the IN operator */\n  u32 inFlags,               /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */\n  int *prRhsHasNull,         /* Register holding NULL status.  See notes */\n  int *aiMap                 /* Mapping from Index fields to RHS fields */\n){\n  Select *p;                            /* SELECT to the right of IN operator */\n  int eType = 0;                        /* Type of RHS table. IN_INDEX_* */\n  int iTab = pParse->nTab++;            /* Cursor of the RHS table */\n  int mustBeUnique;                     /* True if RHS must be unique */\n  Vdbe *v = sqlite3GetVdbe(pParse);     /* Virtual machine being coded */\n\n  assert( pX->op==TK_IN );\n  mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;\n\n  /* If the RHS of this IN(...) operator is a SELECT, and if it matters \n  ** whether or not the SELECT result contains NULL values, check whether\n  ** or not NULL is actually possible (it may not be, for example, due \n  ** to NOT NULL constraints in the schema). If no NULL values are possible,\n  ** set prRhsHasNull to 0 before continuing.  */\n  if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){\n    int i;\n    ExprList *pEList = pX->x.pSelect->pEList;\n    for(i=0; i<pEList->nExpr; i++){\n      if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;\n    }\n    if( i==pEList->nExpr ){\n      prRhsHasNull = 0;\n    }\n  }\n\n  /* Check to see if an existing table or index can be used to\n  ** satisfy the query.  This is preferable to generating a new \n  ** ephemeral table.  */\n  if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){\n    sqlite3 *db = pParse->db;              /* Database connection */\n    Table *pTab;                           /* Table <table>. */\n    i16 iDb;                               /* Database idx for pTab */\n    ExprList *pEList = p->pEList;\n    int nExpr = pEList->nExpr;\n\n    assert( p->pEList!=0 );             /* Because of isCandidateForInOpt(p) */\n    assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */\n    assert( p->pSrc!=0 );               /* Because of isCandidateForInOpt(p) */\n    pTab = p->pSrc->a[0].pTab;\n\n    /* Code an OP_Transaction and OP_TableLock for <table>. */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3CodeVerifySchema(pParse, iDb);\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n    assert(v);  /* sqlite3GetVdbe() has always been previously called */\n    if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){\n      /* The \"x IN (SELECT rowid FROM table)\" case */\n      int iAddr = sqlite3VdbeAddOp0(v, OP_Once);\n      VdbeCoverage(v);\n\n      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n      eType = IN_INDEX_ROWID;\n\n      sqlite3VdbeJumpHere(v, iAddr);\n    }else{\n      Index *pIdx;                         /* Iterator variable */\n      int affinity_ok = 1;\n      int i;\n\n      /* Check that the affinity that will be used to perform each \n      ** comparison is the same as the affinity of each column in table\n      ** on the RHS of the IN operator.  If it not, it is not possible to\n      ** use any index of the RHS table.  */\n      for(i=0; i<nExpr && affinity_ok; i++){\n        Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n        int iCol = pEList->a[i].pExpr->iColumn;\n        char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */\n        char cmpaff = sqlite3CompareAffinity(pLhs, idxaff);\n        testcase( cmpaff==SQLITE_AFF_BLOB );\n        testcase( cmpaff==SQLITE_AFF_TEXT );\n        switch( cmpaff ){\n          case SQLITE_AFF_BLOB:\n            break;\n          case SQLITE_AFF_TEXT:\n            /* sqlite3CompareAffinity() only returns TEXT if one side or the\n            ** other has no affinity and the other side is TEXT.  Hence,\n            ** the only way for cmpaff to be TEXT is for idxaff to be TEXT\n            ** and for the term on the LHS of the IN to have no affinity. */\n            assert( idxaff==SQLITE_AFF_TEXT );\n            break;\n          default:\n            affinity_ok = sqlite3IsNumericAffinity(idxaff);\n        }\n      }\n\n      if( affinity_ok ){\n        /* Search for an existing index that will work for this IN operator */\n        for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){\n          Bitmask colUsed;      /* Columns of the index used */\n          Bitmask mCol;         /* Mask for the current column */\n          if( pIdx->nColumn<nExpr ) continue;\n          /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute\n          ** BITMASK(nExpr) without overflowing */\n          testcase( pIdx->nColumn==BMS-2 );\n          testcase( pIdx->nColumn==BMS-1 );\n          if( pIdx->nColumn>=BMS-1 ) continue;\n          if( mustBeUnique ){\n            if( pIdx->nKeyCol>nExpr\n             ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))\n            ){\n              continue;  /* This index is not unique over the IN RHS columns */\n            }\n          }\n  \n          colUsed = 0;   /* Columns of index used so far */\n          for(i=0; i<nExpr; i++){\n            Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n            Expr *pRhs = pEList->a[i].pExpr;\n            CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n            int j;\n  \n            assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );\n            for(j=0; j<nExpr; j++){\n              if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;\n              assert( pIdx->azColl[j] );\n              if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){\n                continue;\n              }\n              break;\n            }\n            if( j==nExpr ) break;\n            mCol = MASKBIT(j);\n            if( mCol & colUsed ) break; /* Each column used only once */\n            colUsed |= mCol;\n            if( aiMap ) aiMap[i] = j;\n          }\n  \n          assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );\n          if( colUsed==(MASKBIT(nExpr)-1) ){\n            /* If we reach this point, that means the index pIdx is usable */\n            int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n#ifndef SQLITE_OMIT_EXPLAIN\n            sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,\n              sqlite3MPrintf(db, \"USING INDEX %s FOR IN-OPERATOR\",pIdx->zName),\n              P4_DYNAMIC);\n#endif\n            sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n            VdbeComment((v, \"%s\", pIdx->zName));\n            assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );\n            eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];\n  \n            if( prRhsHasNull ){\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n              i64 mask = (1<<nExpr)-1;\n              sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, \n                  iTab, 0, 0, (u8*)&mask, P4_INT64);\n#endif\n              *prRhsHasNull = ++pParse->nMem;\n              if( nExpr==1 ){\n                sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);\n              }\n            }\n            sqlite3VdbeJumpHere(v, iAddr);\n          }\n        } /* End loop over indexes */\n      } /* End if( affinity_ok ) */\n    } /* End if not an rowid index */\n  } /* End attempt to optimize using an index */\n\n  /* If no preexisting index is available for the IN clause\n  ** and IN_INDEX_NOOP is an allowed reply\n  ** and the RHS of the IN operator is a list, not a subquery\n  ** and the RHS is not constant or has two or fewer terms,\n  ** then it is not worth creating an ephemeral table to evaluate\n  ** the IN operator so return IN_INDEX_NOOP.\n  */\n  if( eType==0\n   && (inFlags & IN_INDEX_NOOP_OK)\n   && !ExprHasProperty(pX, EP_xIsSelect)\n   && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)\n  ){\n    eType = IN_INDEX_NOOP;\n  }\n\n  if( eType==0 ){\n    /* Could not find an existing table or index to use as the RHS b-tree.\n    ** We will have to generate an ephemeral table to do the job.\n    */\n    u32 savedNQueryLoop = pParse->nQueryLoop;\n    int rMayHaveNull = 0;\n    eType = IN_INDEX_EPH;\n    if( inFlags & IN_INDEX_LOOP ){\n      pParse->nQueryLoop = 0;\n      if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){\n        eType = IN_INDEX_ROWID;\n      }\n    }else if( prRhsHasNull ){\n      *prRhsHasNull = rMayHaveNull = ++pParse->nMem;\n    }\n    sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);\n    pParse->nQueryLoop = savedNQueryLoop;\n  }else{\n    pX->iTable = iTab;\n  }\n\n  if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){\n    int i, n;\n    n = sqlite3ExprVectorSize(pX->pLeft);\n    for(i=0; i<n; i++) aiMap[i] = i;\n  }\n  return eType;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Argument pExpr is an (?, ?...) IN(...) expression. This \n** function allocates and returns a nul-terminated string containing \n** the affinities to be used for each column of the comparison.\n**\n** It is the responsibility of the caller to ensure that the returned\n** string is eventually freed using sqlite3DbFree().\n*/\nstatic char *exprINAffinity(Parse *pParse, Expr *pExpr){\n  Expr *pLeft = pExpr->pLeft;\n  int nVal = sqlite3ExprVectorSize(pLeft);\n  Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;\n  char *zRet;\n\n  assert( pExpr->op==TK_IN );\n  zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);\n  if( zRet ){\n    int i;\n    for(i=0; i<nVal; i++){\n      Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);\n      char a = sqlite3ExprAffinity(pA);\n      if( pSelect ){\n        zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);\n      }else{\n        zRet[i] = a;\n      }\n    }\n    zRet[nVal] = '\\0';\n  }\n  return zRet;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Load the Parse object passed as the first argument with an error \n** message of the form:\n**\n**   \"sub-select returns N columns - expected M\"\n*/   \nSQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){\n  const char *zFmt = \"sub-select returns %d columns - expected %d\";\n  sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);\n}\n#endif\n\n/*\n** Expression pExpr is a vector that has been used in a context where\n** it is not permitted. If pExpr is a sub-select vector, this routine \n** loads the Parse object with a message of the form:\n**\n**   \"sub-select returns N columns - expected 1\"\n**\n** Or, if it is a regular scalar vector:\n**\n**   \"row value misused\"\n*/   \nSQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->flags & EP_xIsSelect ){\n    sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1);\n  }else\n#endif\n  {\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n  }\n}\n\n/*\n** Generate code for scalar subqueries used as a subquery expression, EXISTS,\n** or IN operators.  Examples:\n**\n**     (SELECT a FROM b)          -- subquery\n**     EXISTS (SELECT a FROM b)   -- EXISTS subquery\n**     x IN (4,5,11)              -- IN operator with list on right-hand side\n**     x IN (SELECT a FROM b)     -- IN operator with subquery on the right\n**\n** The pExpr parameter describes the expression that contains the IN\n** operator or subquery.\n**\n** If parameter isRowid is non-zero, then expression pExpr is guaranteed\n** to be of the form \"<rowid> IN (?, ?, ?)\", where <rowid> is a reference\n** to some integer key column of a table B-Tree. In this case, use an\n** intkey B-Tree to store the set of IN(...) values instead of the usual\n** (slower) variable length keys B-Tree.\n**\n** If rMayHaveNull is non-zero, that means that the operation is an IN\n** (not a SELECT or EXISTS) and that the RHS might contains NULLs.\n** All this routine does is initialize the register given by rMayHaveNull\n** to NULL.  Calling routines will take care of changing this register\n** value to non-NULL if the RHS is NULL-free.\n**\n** For a SELECT or EXISTS operator, return the register that holds the\n** result.  For a multi-column SELECT, the result is stored in a contiguous\n** array of registers and the return value is the register of the left-most\n** result column.  Return 0 for IN operators or if an error occurs.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nSQLITE_PRIVATE int sqlite3CodeSubselect(\n  Parse *pParse,          /* Parsing context */\n  Expr *pExpr,            /* The IN, SELECT, or EXISTS operator */\n  int rHasNullFlag,       /* Register that records whether NULLs exist in RHS */\n  int isRowid             /* If true, LHS of IN operator is a rowid */\n){\n  int jmpIfDynamic = -1;                      /* One-time test address */\n  int rReg = 0;                           /* Register storing resulting */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return 0;\n  sqlite3ExprCachePush(pParse);\n\n  /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it\n  ** is encountered if any of the following is true:\n  **\n  **    *  The right-hand side is a correlated subquery\n  **    *  The right-hand side is an expression list containing variables\n  **    *  We are inside a trigger\n  **\n  ** If all of the above are false, then we can run this code just once\n  ** save the results, and reuse the same result on subsequent invocations.\n  */\n  if( !ExprHasProperty(pExpr, EP_VarSelect) ){\n    jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n  }\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( pParse->explain==2 ){\n    char *zMsg = sqlite3MPrintf(pParse->db, \"EXECUTE %s%s SUBQUERY %d\",\n        jmpIfDynamic>=0?\"\":\"CORRELATED \",\n        pExpr->op==TK_IN?\"LIST\":\"SCALAR\",\n        pParse->iNextSelectId\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n#endif\n\n  switch( pExpr->op ){\n    case TK_IN: {\n      int addr;                   /* Address of OP_OpenEphemeral instruction */\n      Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */\n      KeyInfo *pKeyInfo = 0;      /* Key information */\n      int nVal;                   /* Size of vector pLeft */\n      \n      nVal = sqlite3ExprVectorSize(pLeft);\n      assert( !isRowid || nVal==1 );\n\n      /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'\n      ** expression it is handled the same way.  An ephemeral table is \n      ** filled with index keys representing the results from the \n      ** SELECT or the <exprlist>.\n      **\n      ** If the 'x' expression is a column value, or the SELECT...\n      ** statement returns a column value, then the affinity of that\n      ** column is used to build the index keys. If both 'x' and the\n      ** SELECT... statement are columns, then numeric affinity is used\n      ** if either column has NUMERIC or INTEGER affinity. If neither\n      ** 'x' nor the SELECT... statement are columns, then numeric affinity\n      ** is used.\n      */\n      pExpr->iTable = pParse->nTab++;\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, \n          pExpr->iTable, (isRowid?0:nVal));\n      pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);\n\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* Case 1:     expr IN (SELECT ...)\n        **\n        ** Generate code to write the results of the select into the temporary\n        ** table allocated and opened above.\n        */\n        Select *pSelect = pExpr->x.pSelect;\n        ExprList *pEList = pSelect->pEList;\n\n        assert( !isRowid );\n        /* If the LHS and RHS of the IN operator do not match, that\n        ** error will have been caught long before we reach this point. */\n        if( ALWAYS(pEList->nExpr==nVal) ){\n          SelectDest dest;\n          int i;\n          sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);\n          dest.zAffSdst = exprINAffinity(pParse, pExpr);\n          pSelect->iLimit = 0;\n          testcase( pSelect->selFlags & SF_Distinct );\n          testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */\n          if( sqlite3Select(pParse, pSelect, &dest) ){\n            sqlite3DbFree(pParse->db, dest.zAffSdst);\n            sqlite3KeyInfoUnref(pKeyInfo);\n            return 0;\n          }\n          sqlite3DbFree(pParse->db, dest.zAffSdst);\n          assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */\n          assert( pEList!=0 );\n          assert( pEList->nExpr>0 );\n          assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n          for(i=0; i<nVal; i++){\n            Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);\n            pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(\n                pParse, p, pEList->a[i].pExpr\n            );\n          }\n        }\n      }else if( ALWAYS(pExpr->x.pList!=0) ){\n        /* Case 2:     expr IN (exprlist)\n        **\n        ** For each expression, build an index key from the evaluation and\n        ** store it in the temporary table. If <expr> is a column, then use\n        ** that columns affinity when building index keys. If <expr> is not\n        ** a column, use numeric affinity.\n        */\n        char affinity;            /* Affinity of the LHS of the IN */\n        int i;\n        ExprList *pList = pExpr->x.pList;\n        struct ExprList_item *pItem;\n        int r1, r2, r3;\n\n        affinity = sqlite3ExprAffinity(pLeft);\n        if( !affinity ){\n          affinity = SQLITE_AFF_BLOB;\n        }\n        if( pKeyInfo ){\n          assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n          pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n        }\n\n        /* Loop through each expression in <exprlist>. */\n        r1 = sqlite3GetTempReg(pParse);\n        r2 = sqlite3GetTempReg(pParse);\n        if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, \"\", P4_STATIC);\n        for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){\n          Expr *pE2 = pItem->pExpr;\n          int iValToIns;\n\n          /* If the expression is not constant then we will need to\n          ** disable the test that was generated above that makes sure\n          ** this code only executes once.  Because for a non-constant\n          ** expression we need to rerun this code each time.\n          */\n          if( jmpIfDynamic>=0 && !sqlite3ExprIsConstant(pE2) ){\n            sqlite3VdbeChangeToNoop(v, jmpIfDynamic);\n            jmpIfDynamic = -1;\n          }\n\n          /* Evaluate the expression and insert it into the temp table */\n          if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){\n            sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);\n          }else{\n            r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);\n            if( isRowid ){\n              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,\n                                sqlite3VdbeCurrentAddr(v)+2);\n              VdbeCoverage(v);\n              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);\n            }else{\n              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);\n              sqlite3ExprCacheAffinityChange(pParse, r3, 1);\n              sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);\n            }\n          }\n        }\n        sqlite3ReleaseTempReg(pParse, r1);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      if( pKeyInfo ){\n        sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);\n      }\n      break;\n    }\n\n    case TK_EXISTS:\n    case TK_SELECT:\n    default: {\n      /* Case 3:    (SELECT ... FROM ...)\n      **     or:    EXISTS(SELECT ... FROM ...)\n      **\n      ** For a SELECT, generate code to put the values for all columns of\n      ** the first row into an array of registers and return the index of\n      ** the first register.\n      **\n      ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)\n      ** into a register and return that register number.\n      **\n      ** In both cases, the query is augmented with \"LIMIT 1\".  Any \n      ** preexisting limit is discarded in place of the new LIMIT 1.\n      */\n      Select *pSel;                         /* SELECT statement to encode */\n      SelectDest dest;                      /* How to deal with SELECT result */\n      int nReg;                             /* Registers to allocate */\n\n      testcase( pExpr->op==TK_EXISTS );\n      testcase( pExpr->op==TK_SELECT );\n      assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n\n      pSel = pExpr->x.pSelect;\n      nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;\n      sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);\n      pParse->nMem += nReg;\n      if( pExpr->op==TK_SELECT ){\n        dest.eDest = SRT_Mem;\n        dest.iSdst = dest.iSDParm;\n        dest.nSdst = nReg;\n        sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);\n        VdbeComment((v, \"Init subquery result\"));\n      }else{\n        dest.eDest = SRT_Exists;\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);\n        VdbeComment((v, \"Init EXISTS result\"));\n      }\n      sqlite3ExprDelete(pParse->db, pSel->pLimit);\n      pSel->pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,\n                                  &sqlite3IntTokens[1], 0);\n      pSel->iLimit = 0;\n      pSel->selFlags &= ~SF_MultiValue;\n      if( sqlite3Select(pParse, pSel, &dest) ){\n        return 0;\n      }\n      rReg = dest.iSDParm;\n      ExprSetVVAProperty(pExpr, EP_NoReduce);\n      break;\n    }\n  }\n\n  if( rHasNullFlag ){\n    sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);\n  }\n\n  if( jmpIfDynamic>=0 ){\n    sqlite3VdbeJumpHere(v, jmpIfDynamic);\n  }\n  sqlite3ExprCachePop(pParse);\n\n  return rReg;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Expr pIn is an IN(...) expression. This function checks that the \n** sub-select on the RHS of the IN() operator has the same number of \n** columns as the vector on the LHS. Or, if the RHS of the IN() is not \n** a sub-query, that the LHS is a vector of size 1.\n*/\nSQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){\n  int nVector = sqlite3ExprVectorSize(pIn->pLeft);\n  if( (pIn->flags & EP_xIsSelect) ){\n    if( nVector!=pIn->x.pSelect->pEList->nExpr ){\n      sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);\n      return 1;\n    }\n  }else if( nVector!=1 ){\n    sqlite3VectorErrorMsg(pParse, pIn->pLeft);\n    return 1;\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code for an IN expression.\n**\n**      x IN (SELECT ...)\n**      x IN (value, value, ...)\n**\n** The left-hand side (LHS) is a scalar or vector expression.  The \n** right-hand side (RHS) is an array of zero or more scalar values, or a\n** subquery.  If the RHS is a subquery, the number of result columns must\n** match the number of columns in the vector on the LHS.  If the RHS is\n** a list of values, the LHS must be a scalar. \n**\n** The IN operator is true if the LHS value is contained within the RHS.\n** The result is false if the LHS is definitely not in the RHS.  The \n** result is NULL if the presence of the LHS in the RHS cannot be \n** determined due to NULLs.\n**\n** This routine generates code that jumps to destIfFalse if the LHS is not \n** contained within the RHS.  If due to NULLs we cannot determine if the LHS\n** is contained in the RHS then jump to destIfNull.  If the LHS is contained\n** within the RHS then fall through.\n**\n** See the separate in-operator.md documentation file in the canonical\n** SQLite source tree for additional information.\n*/\nstatic void sqlite3ExprCodeIN(\n  Parse *pParse,        /* Parsing and code generating context */\n  Expr *pExpr,          /* The IN expression */\n  int destIfFalse,      /* Jump here if LHS is not contained in the RHS */\n  int destIfNull        /* Jump here if the results are unknown due to NULLs */\n){\n  int rRhsHasNull = 0;  /* Register that is true if RHS contains NULL values */\n  int eType;            /* Type of the RHS */\n  int rLhs;             /* Register(s) holding the LHS values */\n  int rLhsOrig;         /* LHS values prior to reordering by aiMap[] */\n  Vdbe *v;              /* Statement under construction */\n  int *aiMap = 0;       /* Map from vector field to index column */\n  char *zAff = 0;       /* Affinity string for comparisons */\n  int nVector;          /* Size of vectors for this IN operator */\n  int iDummy;           /* Dummy parameter to exprCodeVector() */\n  Expr *pLeft;          /* The LHS of the IN operator */\n  int i;                /* loop counter */\n  int destStep2;        /* Where to jump when NULLs seen in step 2 */\n  int destStep6 = 0;    /* Start of code for Step 6 */\n  int addrTruthOp;      /* Address of opcode that determines the IN is true */\n  int destNotNull;      /* Jump here if a comparison is not true in step 6 */\n  int addrTop;          /* Top of the step-6 loop */ \n\n  pLeft = pExpr->pLeft;\n  if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n  zAff = exprINAffinity(pParse, pExpr);\n  nVector = sqlite3ExprVectorSize(pExpr->pLeft);\n  aiMap = (int*)sqlite3DbMallocZero(\n      pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1\n  );\n  if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;\n\n  /* Attempt to compute the RHS. After this step, if anything other than\n  ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable \n  ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,\n  ** the RHS has not yet been coded.  */\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* OOM detected prior to this routine */\n  VdbeNoopComment((v, \"begin IN expr\"));\n  eType = sqlite3FindInIndex(pParse, pExpr,\n                             IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,\n                             destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);\n\n  assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH\n       || eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC \n  );\n#ifdef SQLITE_DEBUG\n  /* Confirm that aiMap[] contains nVector integer values between 0 and\n  ** nVector-1. */\n  for(i=0; i<nVector; i++){\n    int j, cnt;\n    for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;\n    assert( cnt==1 );\n  }\n#endif\n\n  /* Code the LHS, the <expr> from \"<expr> IN (...)\". If the LHS is a \n  ** vector, then it is stored in an array of nVector registers starting \n  ** at r1.\n  **\n  ** sqlite3FindInIndex() might have reordered the fields of the LHS vector\n  ** so that the fields are in the same order as an existing index.   The\n  ** aiMap[] array contains a mapping from the original LHS field order to\n  ** the field order that matches the RHS index.\n  */\n  sqlite3ExprCachePush(pParse);\n  rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);\n  for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */\n  if( i==nVector ){\n    /* LHS fields are not reordered */\n    rLhs = rLhsOrig;\n  }else{\n    /* Need to reorder the LHS fields according to aiMap */\n    rLhs = sqlite3GetTempRange(pParse, nVector);\n    for(i=0; i<nVector; i++){\n      sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0);\n    }\n  }\n\n  /* If sqlite3FindInIndex() did not find or create an index that is\n  ** suitable for evaluating the IN operator, then evaluate using a\n  ** sequence of comparisons.\n  **\n  ** This is step (1) in the in-operator.md optimized algorithm.\n  */\n  if( eType==IN_INDEX_NOOP ){\n    ExprList *pList = pExpr->x.pList;\n    CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n    int labelOk = sqlite3VdbeMakeLabel(v);\n    int r2, regToFree;\n    int regCkNull = 0;\n    int ii;\n    assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n    if( destIfNull!=destIfFalse ){\n      regCkNull = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);\n    }\n    for(ii=0; ii<pList->nExpr; ii++){\n      r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);\n      if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){\n        sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);\n      }\n      if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){\n        sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,\n                          (void*)pColl, P4_COLLSEQ);\n        VdbeCoverageIf(v, ii<pList->nExpr-1);\n        VdbeCoverageIf(v, ii==pList->nExpr-1);\n        sqlite3VdbeChangeP5(v, zAff[0]);\n      }else{\n        assert( destIfNull==destIfFalse );\n        sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,\n                          (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);\n      }\n      sqlite3ReleaseTempReg(pParse, regToFree);\n    }\n    if( regCkNull ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, destIfFalse);\n    }\n    sqlite3VdbeResolveLabel(v, labelOk);\n    sqlite3ReleaseTempReg(pParse, regCkNull);\n    goto sqlite3ExprCodeIN_finished;\n  }\n\n  /* Step 2: Check to see if the LHS contains any NULL columns.  If the\n  ** LHS does contain NULLs then the result must be either FALSE or NULL.\n  ** We will then skip the binary search of the RHS.\n  */\n  if( destIfNull==destIfFalse ){\n    destStep2 = destIfFalse;\n  }else{\n    destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);\n    if( sqlite3ExprCanBeNull(p) ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);\n      VdbeCoverage(v);\n    }\n  }\n\n  /* Step 3.  The LHS is now known to be non-NULL.  Do the binary search\n  ** of the RHS using the LHS as a probe.  If found, the result is\n  ** true.\n  */\n  if( eType==IN_INDEX_ROWID ){\n    /* In this case, the RHS is the ROWID of table b-tree and so we also\n    ** know that the RHS is non-NULL.  Hence, we combine steps 3 and 4\n    ** into a single opcode. */\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);\n    VdbeCoverage(v);\n    addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto);  /* Return True */\n  }else{\n    sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);\n    if( destIfFalse==destIfNull ){\n      /* Combine Step 3 and Step 5 into a single opcode */\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,\n                           rLhs, nVector); VdbeCoverage(v);\n      goto sqlite3ExprCodeIN_finished;\n    }\n    /* Ordinary Step 3, for the case where FALSE and NULL are distinct */\n    addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,\n                                      rLhs, nVector); VdbeCoverage(v);\n  }\n\n  /* Step 4.  If the RHS is known to be non-NULL and we did not find\n  ** an match on the search above, then the result must be FALSE.\n  */\n  if( rRhsHasNull && nVector==1 ){\n    sqlite3VdbeAddOp2(v, OP_NotNull, rRhsHasNull, destIfFalse);\n    VdbeCoverage(v);\n  }\n\n  /* Step 5.  If we do not care about the difference between NULL and\n  ** FALSE, then just return false. \n  */\n  if( destIfFalse==destIfNull ) sqlite3VdbeGoto(v, destIfFalse);\n\n  /* Step 6: Loop through rows of the RHS.  Compare each row to the LHS.\n  ** If any comparison is NULL, then the result is NULL.  If all\n  ** comparisons are FALSE then the final result is FALSE.\n  **\n  ** For a scalar LHS, it is sufficient to check just the first row\n  ** of the RHS.\n  */\n  if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);\n  VdbeCoverage(v);\n  if( nVector>1 ){\n    destNotNull = sqlite3VdbeMakeLabel(v);\n  }else{\n    /* For nVector==1, combine steps 6 and 7 by immediately returning\n    ** FALSE if the first comparison is not NULL */\n    destNotNull = destIfFalse;\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p;\n    CollSeq *pColl;\n    int r3 = sqlite3GetTempReg(pParse);\n    p = sqlite3VectorFieldSubexpr(pLeft, i);\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);\n    sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,\n                      (void*)pColl, P4_COLLSEQ);\n    VdbeCoverage(v);\n    sqlite3ReleaseTempReg(pParse, r3);\n  }\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);\n  if( nVector>1 ){\n    sqlite3VdbeResolveLabel(v, destNotNull);\n    sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);\n    VdbeCoverage(v);\n\n    /* Step 7:  If we reach this point, we know that the result must\n    ** be false. */\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);\n  }\n\n  /* Jumps here in order to return true. */\n  sqlite3VdbeJumpHere(v, addrTruthOp);\n\nsqlite3ExprCodeIN_finished:\n  if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);\n  sqlite3ExprCachePop(pParse);\n  VdbeComment((v, \"end IN expr\"));\nsqlite3ExprCodeIN_oom_error:\n  sqlite3DbFree(pParse->db, aiMap);\n  sqlite3DbFree(pParse->db, zAff);\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Generate an instruction that will put the floating point\n** value described by z[0..n-1] into register iMem.\n**\n** The z[] string will probably not be zero-terminated.  But the \n** z[n] character is guaranteed to be something that does not look\n** like the continuation of the number.\n*/\nstatic void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){\n  if( ALWAYS(z!=0) ){\n    double value;\n    sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);\n    assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */\n    if( negateFlag ) value = -value;\n    sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);\n  }\n}\n#endif\n\n\n/*\n** Generate an instruction that will put the integer describe by\n** text z[0..n-1] into register iMem.\n**\n** Expr.u.zToken is always UTF8 and zero-terminated.\n*/\nstatic void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){\n  Vdbe *v = pParse->pVdbe;\n  if( pExpr->flags & EP_IntValue ){\n    int i = pExpr->u.iValue;\n    assert( i>=0 );\n    if( negFlag ) i = -i;\n    sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);\n  }else{\n    int c;\n    i64 value;\n    const char *z = pExpr->u.zToken;\n    assert( z!=0 );\n    c = sqlite3DecOrHexToI64(z, &value);\n    if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n      sqlite3ErrorMsg(pParse, \"oversized integer: %s%s\", negFlag ? \"-\" : \"\", z);\n#else\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( sqlite3_strnicmp(z,\"0x\",2)==0 ){\n        sqlite3ErrorMsg(pParse, \"hex literal too big: %s%s\", negFlag?\"-\":\"\",z);\n      }else\n#endif\n      {\n        codeReal(v, z, negFlag, iMem);\n      }\n#endif\n    }else{\n      if( negFlag ){ value = c==3 ? SMALLEST_INT64 : -value; }\n      sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, P4_INT64);\n    }\n  }\n}\n\n/*\n** Erase column-cache entry number i\n*/\nstatic void cacheEntryClear(Parse *pParse, int i){\n  if( pParse->aColCache[i].tempReg ){\n    if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n      pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;\n    }\n  }\n  pParse->nColCache--;\n  if( i<pParse->nColCache ){\n    pParse->aColCache[i] = pParse->aColCache[pParse->nColCache];\n  }\n}\n\n\n/*\n** Record in the column cache that a particular column from a\n** particular table is stored in a particular register.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){\n  int i;\n  int minLru;\n  int idxLru;\n  struct yColCache *p;\n\n  /* Unless an error has occurred, register numbers are always positive. */\n  assert( iReg>0 || pParse->nErr || pParse->db->mallocFailed );\n  assert( iCol>=-1 && iCol<32768 );  /* Finite column numbers */\n\n  /* The SQLITE_ColumnCache flag disables the column cache.  This is used\n  ** for testing only - to verify that SQLite always gets the same answer\n  ** with and without the column cache.\n  */\n  if( OptimizationDisabled(pParse->db, SQLITE_ColumnCache) ) return;\n\n  /* First replace any existing entry.\n  **\n  ** Actually, the way the column cache is currently used, we are guaranteed\n  ** that the object will never already be in cache.  Verify this guarantee.\n  */\n#ifndef NDEBUG\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    assert( p->iTable!=iTab || p->iColumn!=iCol );\n  }\n#endif\n\n  /* If the cache is already full, delete the least recently used entry */\n  if( pParse->nColCache>=SQLITE_N_COLCACHE ){\n    minLru = 0x7fffffff;\n    idxLru = -1;\n    for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n      if( p->lru<minLru ){\n        idxLru = i;\n        minLru = p->lru;\n      }\n    }\n    p = &pParse->aColCache[idxLru];\n  }else{\n    p = &pParse->aColCache[pParse->nColCache++];\n  }\n\n  /* Add the new entry to the end of the cache */\n  p->iLevel = pParse->iCacheLevel;\n  p->iTable = iTab;\n  p->iColumn = iCol;\n  p->iReg = iReg;\n  p->tempReg = 0;\n  p->lru = pParse->iCacheCnt++;\n}\n\n/*\n** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.\n** Purge the range of registers from the column cache.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){\n  int i = 0;\n  while( i<pParse->nColCache ){\n    struct yColCache *p = &pParse->aColCache[i];\n    if( p->iReg >= iReg && p->iReg < iReg+nReg ){\n      cacheEntryClear(pParse, i);\n    }else{\n      i++;\n    }\n  }\n}\n\n/*\n** Remember the current column cache context.  Any new entries added\n** added to the column cache after this call are removed when the\n** corresponding pop occurs.\n*/\nSQLITE_PRIVATE void sqlite3ExprCachePush(Parse *pParse){\n  pParse->iCacheLevel++;\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"PUSH to %d\\n\", pParse->iCacheLevel);\n  }\n#endif\n}\n\n/*\n** Remove from the column cache any entries that were added since the\n** the previous sqlite3ExprCachePush operation.  In other words, restore\n** the cache to the state it was in prior the most recent Push.\n*/\nSQLITE_PRIVATE void sqlite3ExprCachePop(Parse *pParse){\n  int i = 0;\n  assert( pParse->iCacheLevel>=1 );\n  pParse->iCacheLevel--;\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"POP  to %d\\n\", pParse->iCacheLevel);\n  }\n#endif\n  while( i<pParse->nColCache ){\n    if( pParse->aColCache[i].iLevel>pParse->iCacheLevel ){\n      cacheEntryClear(pParse, i);\n    }else{\n      i++;\n    }\n  }\n}\n\n/*\n** When a cached column is reused, make sure that its register is\n** no longer available as a temp register.  ticket #3879:  that same\n** register might be in the cache in multiple places, so be sure to\n** get them all.\n*/\nstatic void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    if( p->iReg==iReg ){\n      p->tempReg = 0;\n    }\n  }\n}\n\n/* Generate code that will load into register regOut a value that is\n** appropriate for the iIdxCol-th column of index pIdx.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(\n  Parse *pParse,  /* The parsing context */\n  Index *pIdx,    /* The index whose column is to be loaded */\n  int iTabCur,    /* Cursor pointing to a table row */\n  int iIdxCol,    /* The column of the index to be loaded */\n  int regOut      /* Store the index column value in this register */\n){\n  i16 iTabCol = pIdx->aiColumn[iIdxCol];\n  if( iTabCol==XN_EXPR ){\n    assert( pIdx->aColExpr );\n    assert( pIdx->aColExpr->nExpr>iIdxCol );\n    pParse->iSelfTab = iTabCur + 1;\n    sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);\n    pParse->iSelfTab = 0;\n  }else{\n    sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,\n                                    iTabCol, regOut);\n  }\n}\n\n/*\n** Generate code to extract the value of the iCol-th column of a table.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(\n  Vdbe *v,        /* The VDBE under construction */\n  Table *pTab,    /* The table containing the value */\n  int iTabCur,    /* The table cursor.  Or the PK cursor for WITHOUT ROWID */\n  int iCol,       /* Index of the column to extract */\n  int regOut      /* Extract the value into this register */\n){\n  if( pTab==0 ){\n    sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);\n    return;\n  }\n  if( iCol<0 || iCol==pTab->iPKey ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);\n  }else{\n    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;\n    int x = iCol;\n    if( !HasRowid(pTab) && !IsVirtual(pTab) ){\n      x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);\n    }\n    sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);\n  }\n  if( iCol>=0 ){\n    sqlite3ColumnDefault(v, pTab, iCol, regOut);\n  }\n}\n\n/*\n** Generate code that will extract the iColumn-th column from\n** table pTab and store the column value in a register. \n**\n** An effort is made to store the column value in register iReg.  This\n** is not garanteeed for GetColumn() - the result can be stored in\n** any register.  But the result is guaranteed to land in register iReg\n** for GetColumnToReg().\n**\n** There must be an open cursor to pTab in iTable when this routine\n** is called.  If iColumn<0 then code is generated that extracts the rowid.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeGetColumn(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg,        /* Store results here */\n  u8 p5            /* P5 value for OP_Column + FLAGS */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct yColCache *p;\n\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    if( p->iTable==iTable && p->iColumn==iColumn ){\n      p->lru = pParse->iCacheCnt++;\n      sqlite3ExprCachePinRegister(pParse, p->iReg);\n      return p->iReg;\n    }\n  }  \n  assert( v!=0 );\n  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);\n  if( p5 ){\n    sqlite3VdbeChangeP5(v, p5);\n  }else{   \n    sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);\n  }\n  return iReg;\n}\nSQLITE_PRIVATE void sqlite3ExprCodeGetColumnToReg(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg         /* Store results here */\n){\n  int r1 = sqlite3ExprCodeGetColumn(pParse, pTab, iColumn, iTable, iReg, 0);\n  if( r1!=iReg ) sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, r1, iReg);\n}\n\n\n/*\n** Clear all column cache entries.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){\n  int i;\n\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"CLEAR\\n\");\n  }\n#endif\n  for(i=0; i<pParse->nColCache; i++){\n    if( pParse->aColCache[i].tempReg\n     && pParse->nTempReg<ArraySize(pParse->aTempReg)\n    ){\n       pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;\n    }\n  }\n  pParse->nColCache = 0;\n}\n\n/*\n** Record the fact that an affinity change has occurred on iCount\n** registers starting with iStart.\n*/\nSQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){\n  sqlite3ExprCacheRemove(pParse, iStart, iCount);\n}\n\n/*\n** Generate code to move content from registers iFrom...iFrom+nReg-1\n** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){\n  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );\n  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);\n  sqlite3ExprCacheRemove(pParse, iFrom, nReg);\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n/*\n** Return true if any register in the range iFrom..iTo (inclusive)\n** is used as part of the column cache.\n**\n** This routine is used within assert() and testcase() macros only\n** and does not appear in a normal build.\n*/\nstatic int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    int r = p->iReg;\n    if( r>=iFrom && r<=iTo ) return 1;    /*NO_TEST*/\n  }\n  return 0;\n}\n#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */\n\n\n/*\n** Convert a scalar expression node to a TK_REGISTER referencing\n** register iReg.  The caller must ensure that iReg already contains\n** the correct value for the expression.\n*/\nstatic void exprToRegister(Expr *p, int iReg){\n  p->op2 = p->op;\n  p->op = TK_REGISTER;\n  p->iTable = iReg;\n  ExprClearProperty(p, EP_Skip);\n}\n\n/*\n** Evaluate an expression (either a vector or a scalar expression) and store\n** the result in continguous temporary registers.  Return the index of\n** the first register used to store the result.\n**\n** If the returned result register is a temporary scalar, then also write\n** that register number into *piFreeable.  If the returned result register\n** is not a temporary or if the expression is a vector set *piFreeable\n** to 0.\n*/\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){\n  int iResult;\n  int nResult = sqlite3ExprVectorSize(p);\n  if( nResult==1 ){\n    iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);\n  }else{\n    *piFreeable = 0;\n    if( p->op==TK_SELECT ){\n#if SQLITE_OMIT_SUBQUERY\n      iResult = 0;\n#else\n      iResult = sqlite3CodeSubselect(pParse, p, 0, 0);\n#endif\n    }else{\n      int i;\n      iResult = pParse->nMem+1;\n      pParse->nMem += nResult;\n      for(i=0; i<nResult; i++){\n        sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);\n      }\n    }\n  }\n  return iResult;\n}\n\n\n/*\n** Generate code into the current Vdbe to evaluate the given\n** expression.  Attempt to store the results in register \"target\".\n** Return the register where results are stored.\n**\n** With this routine, there is no guarantee that results will\n** be stored in target.  The result might be stored in some other\n** register if it is convenient to do so.  The calling function\n** must check the return code and move the results to the desired\n** register.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;  /* The VM under construction */\n  int op;                   /* The opcode being coded */\n  int inReg = target;       /* Results stored in register inReg */\n  int regFree1 = 0;         /* If non-zero free this temporary register */\n  int regFree2 = 0;         /* If non-zero free this temporary register */\n  int r1, r2;               /* Various register numbers */\n  Expr tempX;               /* Temporary expression node */\n  int p5 = 0;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( v==0 ){\n    assert( pParse->db->mallocFailed );\n    return 0;\n  }\n\n  if( pExpr==0 ){\n    op = TK_NULL;\n  }else{\n    op = pExpr->op;\n  }\n  switch( op ){\n    case TK_AGG_COLUMN: {\n      AggInfo *pAggInfo = pExpr->pAggInfo;\n      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];\n      if( !pAggInfo->directMode ){\n        assert( pCol->iMem>0 );\n        return pCol->iMem;\n      }else if( pAggInfo->useSortingIdx ){\n        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,\n                              pCol->iSorterColumn, target);\n        return target;\n      }\n      /* Otherwise, fall thru into the TK_COLUMN case */\n    }\n    case TK_COLUMN: {\n      int iTab = pExpr->iTable;\n      if( iTab<0 ){\n        if( pParse->iSelfTab<0 ){\n          /* Generating CHECK constraints or inserting into partial index */\n          return pExpr->iColumn - pParse->iSelfTab;\n        }else{\n          /* Coding an expression that is part of an index where column names\n          ** in the index refer to the table to which the index belongs */\n          iTab = pParse->iSelfTab - 1;\n        }\n      }\n      return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,\n                               pExpr->iColumn, iTab, target,\n                               pExpr->op2);\n    }\n    case TK_INTEGER: {\n      codeInteger(pParse, pExpr, 0, target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      codeReal(v, pExpr->u.zToken, 0, target);\n      return target;\n    }\n#endif\n    case TK_STRING: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      sqlite3VdbeLoadString(v, target, pExpr->u.zToken);\n      return target;\n    }\n    case TK_NULL: {\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      int n;\n      const char *z;\n      char *zBlob;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n      assert( pExpr->u.zToken[1]=='\\'' );\n      z = &pExpr->u.zToken[2];\n      n = sqlite3Strlen30(z) - 1;\n      assert( z[n]=='\\'' );\n      zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n);\n      sqlite3VdbeAddOp4(v, OP_Blob, n/2, target, 0, zBlob, P4_DYNAMIC);\n      return target;\n    }\n#endif\n    case TK_VARIABLE: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken!=0 );\n      assert( pExpr->u.zToken[0]!=0 );\n      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);\n      if( pExpr->u.zToken[1]!=0 ){\n        const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);\n        assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );\n        pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */\n        sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);\n      }\n      return target;\n    }\n    case TK_REGISTER: {\n      return pExpr->iTable;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      if( inReg!=target ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);\n        inReg = target;\n      }\n      sqlite3VdbeAddOp2(v, OP_Cast, target,\n                        sqlite3AffinityType(pExpr->u.zToken, 0));\n      testcase( usedAsColumnCache(pParse, inReg, inReg) );\n      sqlite3ExprCacheAffinityChange(pParse, inReg, 1);\n      return inReg;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_IS:\n    case TK_ISNOT:\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      p5 = SQLITE_NULLEQ;\n      /* fall-through */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      Expr *pLeft = pExpr->pLeft;\n      if( sqlite3ExprIsVector(pLeft) ){\n        codeVectorCompare(pParse, pExpr, target, op, p5);\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n        codeCompare(pParse, pLeft, pExpr->pRight, op,\n            r1, r2, inReg, SQLITE_STOREP2 | p5);\n        assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n        assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n        assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n        assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n        assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n        assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n        testcase( regFree1==0 );\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_AND:\n    case TK_OR:\n    case TK_PLUS:\n    case TK_STAR:\n    case TK_MINUS:\n    case TK_REM:\n    case TK_BITAND:\n    case TK_BITOR:\n    case TK_SLASH:\n    case TK_LSHIFT:\n    case TK_RSHIFT: \n    case TK_CONCAT: {\n      assert( TK_AND==OP_And );            testcase( op==TK_AND );\n      assert( TK_OR==OP_Or );              testcase( op==TK_OR );\n      assert( TK_PLUS==OP_Add );           testcase( op==TK_PLUS );\n      assert( TK_MINUS==OP_Subtract );     testcase( op==TK_MINUS );\n      assert( TK_REM==OP_Remainder );      testcase( op==TK_REM );\n      assert( TK_BITAND==OP_BitAnd );      testcase( op==TK_BITAND );\n      assert( TK_BITOR==OP_BitOr );        testcase( op==TK_BITOR );\n      assert( TK_SLASH==OP_Divide );       testcase( op==TK_SLASH );\n      assert( TK_LSHIFT==OP_ShiftLeft );   testcase( op==TK_LSHIFT );\n      assert( TK_RSHIFT==OP_ShiftRight );  testcase( op==TK_RSHIFT );\n      assert( TK_CONCAT==OP_Concat );      testcase( op==TK_CONCAT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      sqlite3VdbeAddOp3(v, op, r2, r1, target);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_UMINUS: {\n      Expr *pLeft = pExpr->pLeft;\n      assert( pLeft );\n      if( pLeft->op==TK_INTEGER ){\n        codeInteger(pParse, pLeft, 1, target);\n        return target;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      }else if( pLeft->op==TK_FLOAT ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        codeReal(v, pLeft->u.zToken, 1, target);\n        return target;\n#endif\n      }else{\n        tempX.op = TK_INTEGER;\n        tempX.flags = EP_IntValue|EP_TokenOnly;\n        tempX.u.iValue = 0;\n        r1 = sqlite3ExprCodeTemp(pParse, &tempX, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);\n        sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_BITNOT:\n    case TK_NOT: {\n      assert( TK_BITNOT==OP_BitNot );   testcase( op==TK_BITNOT );\n      assert( TK_NOT==OP_Not );         testcase( op==TK_NOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      sqlite3VdbeAddOp2(v, op, r1, inReg);\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      int addr;\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      addr = sqlite3VdbeAddOp1(v, op, r1);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, target);\n      sqlite3VdbeJumpHere(v, addr);\n      break;\n    }\n    case TK_AGG_FUNCTION: {\n      AggInfo *pInfo = pExpr->pAggInfo;\n      if( pInfo==0 ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate: %s()\", pExpr->u.zToken);\n      }else{\n        return pInfo->aFunc[pExpr->iAgg].iMem;\n      }\n      break;\n    }\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      int nFarg;             /* Number of function arguments */\n      FuncDef *pDef;         /* The function definition object */\n      const char *zId;       /* The function name */\n      u32 constMask = 0;     /* Mask of function arguments that are constant */\n      int i;                 /* Loop counter */\n      sqlite3 *db = pParse->db;  /* The database connection */\n      u8 enc = ENC(db);      /* The text encoding used by this database */\n      CollSeq *pColl = 0;    /* A collating sequence */\n\n      if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){\n        /* SQL functions can be expensive. So try to move constant functions\n        ** out of the inner loop, even if that means an extra OP_Copy. */\n        return sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n      }\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      nFarg = pFarg ? pFarg->nExpr : 0;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      zId = pExpr->u.zToken;\n      pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n      if( pDef==0 && pParse->explain ){\n        pDef = sqlite3FindFunction(db, \"unknown\", nFarg, enc, 0);\n      }\n#endif\n      if( pDef==0 || pDef->xFinalize!=0 ){\n        sqlite3ErrorMsg(pParse, \"unknown function: %s()\", zId);\n        break;\n      }\n\n      /* Attempt a direct implementation of the built-in COALESCE() and\n      ** IFNULL() functions.  This avoids unnecessary evaluation of\n      ** arguments past the first non-NULL argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){\n        int endCoalesce = sqlite3VdbeMakeLabel(v);\n        assert( nFarg>=2 );\n        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);\n        for(i=1; i<nFarg; i++){\n          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);\n          VdbeCoverage(v);\n          sqlite3ExprCacheRemove(pParse, target, 1);\n          sqlite3ExprCachePush(pParse);\n          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);\n          sqlite3ExprCachePop(pParse);\n        }\n        sqlite3VdbeResolveLabel(v, endCoalesce);\n        break;\n      }\n\n      /* The UNLIKELY() function is a no-op.  The result is the value\n      ** of the first argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n        assert( nFarg>=1 );\n        return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);\n      }\n\n#ifdef SQLITE_DEBUG\n      /* The AFFINITY() function evaluates to a string that describes\n      ** the type affinity of the argument.  This is used for testing of\n      ** the SQLite type logic.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){\n        const char *azAff[] = { \"blob\", \"text\", \"numeric\", \"integer\", \"real\" };\n        char aff;\n        assert( nFarg==1 );\n        aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);\n        sqlite3VdbeLoadString(v, target, \n                              aff ? azAff[aff-SQLITE_AFF_BLOB] : \"none\");\n        return target;\n      }\n#endif\n\n      for(i=0; i<nFarg; i++){\n        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){\n          testcase( i==31 );\n          constMask |= MASKBIT32(i);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){\n          pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);\n        }\n      }\n      if( pFarg ){\n        if( constMask ){\n          r1 = pParse->nMem+1;\n          pParse->nMem += nFarg;\n        }else{\n          r1 = sqlite3GetTempRange(pParse, nFarg);\n        }\n\n        /* For length() and typeof() functions with a column argument,\n        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG\n        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data\n        ** loading.\n        */\n        if( (pDef->funcFlags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){\n          u8 exprOp;\n          assert( nFarg==1 );\n          assert( pFarg->a[0].pExpr!=0 );\n          exprOp = pFarg->a[0].pExpr->op;\n          if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){\n            assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );\n            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );\n            testcase( pDef->funcFlags & OPFLAG_LENGTHARG );\n            pFarg->a[0].pExpr->op2 = \n                  pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);\n          }\n        }\n\n        sqlite3ExprCachePush(pParse);     /* Ticket 2ea2425d34be */\n        sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,\n                                SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);\n        sqlite3ExprCachePop(pParse);      /* Ticket 2ea2425d34be */\n      }else{\n        r1 = 0;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* Possibly overload the function if the first argument is\n      ** a virtual table column.\n      **\n      ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the\n      ** second argument, not the first, as the argument to test to\n      ** see if it is a column in a virtual table.  This is done because\n      ** the left operand of infix functions (the operand we want to\n      ** control overloading) ends up as the second argument to the\n      ** function.  The expression \"A glob B\" is equivalent to \n      ** \"glob(B,A).  We want to use the A in \"A glob B\" to test\n      ** for function overloading.  But we use the B term in \"glob(B,A)\".\n      */\n      if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);\n      }else if( nFarg>0 ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);\n      }\n#endif\n      if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n        if( !pColl ) pColl = db->pDfltColl; \n        sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);\n      }\n      sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,\n                        constMask, r1, target, (char*)pDef, P4_FUNCDEF);\n      sqlite3VdbeChangeP5(v, (u8)nFarg);\n      if( nFarg && constMask==0 ){\n        sqlite3ReleaseTempRange(pParse, r1, nFarg);\n      }\n      return target;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS:\n    case TK_SELECT: {\n      int nCol;\n      testcase( op==TK_EXISTS );\n      testcase( op==TK_SELECT );\n      if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){\n        sqlite3SubselectError(pParse, nCol, 1);\n      }else{\n        return sqlite3CodeSubselect(pParse, pExpr, 0, 0);\n      }\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      int n;\n      if( pExpr->pLeft->iTable==0 ){\n        pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);\n      }\n      assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );\n      if( pExpr->iTable\n       && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) \n      ){\n        sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                                pExpr->iTable, n);\n      }\n      return pExpr->pLeft->iTable + pExpr->iColumn;\n    }\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);\n      sqlite3VdbeResolveLabel(v, destIfNull);\n      return target;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      exprCodeBetween(pParse, pExpr, target, 0, 0);\n      return target;\n    }\n    case TK_SPAN:\n    case TK_COLLATE: \n    case TK_UPLUS: {\n      return sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n    }\n\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      **\n      ** The expression is implemented using an OP_Param opcode. The p1\n      ** parameter is set to 0 for an old.rowid reference, or to (i+1)\n      ** to reference another column of the old.* pseudo-table, where \n      ** i is the index of the column. For a new.rowid reference, p1 is\n      ** set to (n+1), where n is the number of columns in each pseudo-table.\n      ** For a reference to any other column in the new.* pseudo-table, p1\n      ** is set to (n+2+i), where n and i are as defined previously. For\n      ** example, if the table on which triggers are being fired is\n      ** declared as:\n      **\n      **   CREATE TABLE t1(a, b);\n      **\n      ** Then p1 is interpreted as follows:\n      **\n      **   p1==0   ->    old.rowid     p1==3   ->    new.rowid\n      **   p1==1   ->    old.a         p1==4   ->    new.a\n      **   p1==2   ->    old.b         p1==5   ->    new.b       \n      */\n      Table *pTab = pExpr->pTab;\n      int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;\n\n      assert( pExpr->iTable==0 || pExpr->iTable==1 );\n      assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );\n      assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );\n      assert( p1>=0 && p1<(pTab->nCol*2+2) );\n\n      sqlite3VdbeAddOp2(v, OP_Param, p1, target);\n      VdbeComment((v, \"%s.%s -> $%d\",\n        (pExpr->iTable ? \"new\" : \"old\"),\n        (pExpr->iColumn<0 ? \"rowid\" : pExpr->pTab->aCol[pExpr->iColumn].zName),\n        target\n      ));\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      /* If the column has REAL affinity, it may currently be stored as an\n      ** integer. Use OP_RealAffinity to make sure it is really real.\n      **\n      ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to\n      ** floating point when extracting it from the record.  */\n      if( pExpr->iColumn>=0 \n       && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL\n      ){\n        sqlite3VdbeAddOp1(v, OP_RealAffinity, target);\n      }\n#endif\n      break;\n    }\n\n    case TK_VECTOR: {\n      sqlite3ErrorMsg(pParse, \"row value misused\");\n      break;\n    }\n\n    case TK_IF_NULL_ROW: {\n      int addrINR;\n      addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);\n      sqlite3ExprCachePush(pParse);\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      sqlite3ExprCachePop(pParse);\n      sqlite3VdbeJumpHere(v, addrINR);\n      sqlite3VdbeChangeP3(v, addrINR, inReg);\n      break;\n    }\n\n    /*\n    ** Form A:\n    **   CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form B:\n    **   CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form A is can be transformed into the equivalent form B as follows:\n    **   CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...\n    **        WHEN x=eN THEN rN ELSE y END\n    **\n    ** X (if it exists) is in pExpr->pLeft.\n    ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is\n    ** odd.  The Y is also optional.  If the number of elements in x.pList\n    ** is even, then Y is omitted and the \"otherwise\" result is NULL.\n    ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].\n    **\n    ** The result of the expression is the Ri for the first matching Ei,\n    ** or if there is no matching Ei, the ELSE term Y, or if there is\n    ** no ELSE term, NULL.\n    */\n    default: assert( op==TK_CASE ); {\n      int endLabel;                     /* GOTO label for end of CASE stmt */\n      int nextCase;                     /* GOTO label for next WHEN clause */\n      int nExpr;                        /* 2x number of WHEN terms */\n      int i;                            /* Loop counter */\n      ExprList *pEList;                 /* List of WHEN terms */\n      struct ExprList_item *aListelem;  /* Array of WHEN terms */\n      Expr opCompare;                   /* The X==Ei expression */\n      Expr *pX;                         /* The X expression */\n      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */\n      VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );\n      assert(pExpr->x.pList->nExpr > 0);\n      pEList = pExpr->x.pList;\n      aListelem = pEList->a;\n      nExpr = pEList->nExpr;\n      endLabel = sqlite3VdbeMakeLabel(v);\n      if( (pX = pExpr->pLeft)!=0 ){\n        tempX = *pX;\n        testcase( pX->op==TK_COLUMN );\n        exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));\n        testcase( regFree1==0 );\n        memset(&opCompare, 0, sizeof(opCompare));\n        opCompare.op = TK_EQ;\n        opCompare.pLeft = &tempX;\n        pTest = &opCompare;\n        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:\n        ** The value in regFree1 might get SCopy-ed into the file result.\n        ** So make sure that the regFree1 register is not reused for other\n        ** purposes and possibly overwritten.  */\n        regFree1 = 0;\n      }\n      for(i=0; i<nExpr-1; i=i+2){\n        sqlite3ExprCachePush(pParse);\n        if( pX ){\n          assert( pTest!=0 );\n          opCompare.pRight = aListelem[i].pExpr;\n        }else{\n          pTest = aListelem[i].pExpr;\n        }\n        nextCase = sqlite3VdbeMakeLabel(v);\n        testcase( pTest->op==TK_COLUMN );\n        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);\n        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );\n        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);\n        sqlite3VdbeGoto(v, endLabel);\n        sqlite3ExprCachePop(pParse);\n        sqlite3VdbeResolveLabel(v, nextCase);\n      }\n      if( (nExpr&1)!=0 ){\n        sqlite3ExprCachePush(pParse);\n        sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);\n        sqlite3ExprCachePop(pParse);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      }\n      assert( pParse->db->mallocFailed || pParse->nErr>0 \n           || pParse->iCacheLevel==iCacheLevel );\n      sqlite3VdbeResolveLabel(v, endLabel);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      assert( pExpr->affinity==OE_Rollback \n           || pExpr->affinity==OE_Abort\n           || pExpr->affinity==OE_Fail\n           || pExpr->affinity==OE_Ignore\n      );\n      if( !pParse->pTriggerTab ){\n        sqlite3ErrorMsg(pParse,\n                       \"RAISE() may only be used within a trigger-program\");\n        return 0;\n      }\n      if( pExpr->affinity==OE_Abort ){\n        sqlite3MayAbort(pParse);\n      }\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      if( pExpr->affinity==OE_Ignore ){\n        sqlite3VdbeAddOp4(\n            v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);\n        VdbeCoverage(v);\n      }else{\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,\n                              pExpr->affinity, pExpr->u.zToken, 0, 0);\n      }\n\n      break;\n    }\n#endif\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n  return inReg;\n}\n\n/*\n** Factor out the code of the given expression to initialization time.\n**\n** If regDest>=0 then the result is always stored in that register and the\n** result is not reusable.  If regDest<0 then this routine is free to \n** store the value whereever it wants.  The register where the expression \n** is stored is returned.  When regDest<0, two identical expressions will\n** code to the same register.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeAtInit(\n  Parse *pParse,    /* Parsing context */\n  Expr *pExpr,      /* The expression to code when the VDBE initializes */\n  int regDest       /* Store the value in this register */\n){\n  ExprList *p;\n  assert( ConstFactorOk(pParse) );\n  p = pParse->pConstExpr;\n  if( regDest<0 && p ){\n    struct ExprList_item *pItem;\n    int i;\n    for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){\n      if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){\n        return pItem->u.iConstExprReg;\n      }\n    }\n  }\n  pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);\n  p = sqlite3ExprListAppend(pParse, p, pExpr);\n  if( p ){\n     struct ExprList_item *pItem = &p->a[p->nExpr-1];\n     pItem->reusable = regDest<0;\n     if( regDest<0 ) regDest = ++pParse->nMem;\n     pItem->u.iConstExprReg = regDest;\n  }\n  pParse->pConstExpr = p;\n  return regDest;\n}\n\n/*\n** Generate code to evaluate an expression and store the results\n** into a register.  Return the register number where the results\n** are stored.\n**\n** If the register is a temporary register that can be deallocated,\n** then write its number into *pReg.  If the result register is not\n** a temporary, then set *pReg to zero.\n**\n** If pExpr is a constant, then this routine might generate this\n** code to fill the register in the initialization section of the\n** VDBE program, in order to factor it out of the evaluation loop.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){\n  int r2;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( ConstFactorOk(pParse)\n   && pExpr->op!=TK_REGISTER\n   && sqlite3ExprIsConstantNotJoin(pExpr)\n  ){\n    *pReg  = 0;\n    r2 = sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n  }else{\n    int r1 = sqlite3GetTempReg(pParse);\n    r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);\n    if( r2==r1 ){\n      *pReg = r1;\n    }else{\n      sqlite3ReleaseTempReg(pParse, r1);\n      *pReg = 0;\n    }\n  }\n  return r2;\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.\n*/\nSQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){\n  int inReg;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( pExpr && pExpr->op==TK_REGISTER ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);\n  }else{\n    inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);\n    assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );\n    if( inReg!=target && pParse->pVdbe ){\n      sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);\n    }\n  }\n}\n\n/*\n** Make a transient copy of expression pExpr and then code it using\n** sqlite3ExprCode().  This routine works just like sqlite3ExprCode()\n** except that the input expression is guaranteed to be unchanged.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){\n  sqlite3 *db = pParse->db;\n  pExpr = sqlite3ExprDup(db, pExpr, 0);\n  if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);\n  sqlite3ExprDelete(db, pExpr);\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.  If the expression is constant, then this routine\n** might choose to code the expression at initialization time.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){\n  if( pParse->okConstFactor && sqlite3ExprIsConstant(pExpr) ){\n    sqlite3ExprCodeAtInit(pParse, pExpr, target);\n  }else{\n    sqlite3ExprCode(pParse, pExpr, target);\n  }\n}\n\n/*\n** Generate code that evaluates the given expression and puts the result\n** in register target.\n**\n** Also make a copy of the expression results into another \"cache\" register\n** and modify the expression so that the next time it is evaluated,\n** the result is a copy of the cache register.\n**\n** This routine is used for expressions that are used multiple \n** times.  They are evaluated once and the results of the expression\n** are reused.\n*/\nSQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;\n  int iMem;\n\n  assert( target>0 );\n  assert( pExpr->op!=TK_REGISTER );\n  sqlite3ExprCode(pParse, pExpr, target);\n  iMem = ++pParse->nMem;\n  sqlite3VdbeAddOp2(v, OP_Copy, target, iMem);\n  exprToRegister(pExpr, iMem);\n}\n\n/*\n** Generate code that pushes the value of every element of the given\n** expression list into a sequence of registers beginning at target.\n**\n** Return the number of elements evaluated.  The number returned will\n** usually be pList->nExpr but might be reduced if SQLITE_ECEL_OMITREF\n** is defined.\n**\n** The SQLITE_ECEL_DUP flag prevents the arguments from being\n** filled using OP_SCopy.  OP_Copy must be used instead.\n**\n** The SQLITE_ECEL_FACTOR argument allows constant arguments to be\n** factored out into initialization code.\n**\n** The SQLITE_ECEL_REF flag means that expressions in the list with\n** ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored\n** in registers at srcReg, and so the value can be copied from there.\n** If SQLITE_ECEL_OMITREF is also set, then the values with u.x.iOrderByCol>0\n** are simply omitted rather than being copied from srcReg.\n*/\nSQLITE_PRIVATE int sqlite3ExprCodeExprList(\n  Parse *pParse,     /* Parsing context */\n  ExprList *pList,   /* The expression list to be coded */\n  int target,        /* Where to write results */\n  int srcReg,        /* Source registers if SQLITE_ECEL_REF */\n  u8 flags           /* SQLITE_ECEL_* flags */\n){\n  struct ExprList_item *pItem;\n  int i, j, n;\n  u8 copyOp = (flags & SQLITE_ECEL_DUP) ? OP_Copy : OP_SCopy;\n  Vdbe *v = pParse->pVdbe;\n  assert( pList!=0 );\n  assert( target>0 );\n  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */\n  n = pList->nExpr;\n  if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;\n  for(pItem=pList->a, i=0; i<n; i++, pItem++){\n    Expr *pExpr = pItem->pExpr;\n    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){\n      if( flags & SQLITE_ECEL_OMITREF ){\n        i--;\n        n--;\n      }else{\n        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);\n      }\n    }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){\n      sqlite3ExprCodeAtInit(pParse, pExpr, target+i);\n    }else{\n      int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);\n      if( inReg!=target+i ){\n        VdbeOp *pOp;\n        if( copyOp==OP_Copy\n         && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy\n         && pOp->p1+pOp->p3+1==inReg\n         && pOp->p2+pOp->p3+1==target+i\n        ){\n          pOp->p3++;\n        }else{\n          sqlite3VdbeAddOp2(v, copyOp, inReg, target+i);\n        }\n      }\n    }\n  }\n  return n;\n}\n\n/*\n** Generate code for a BETWEEN operator.\n**\n**    x BETWEEN y AND z\n**\n** The above is equivalent to \n**\n**    x>=y AND x<=z\n**\n** Code it as such, taking care to do the common subexpression\n** elimination of x.\n**\n** The xJumpIf parameter determines details:\n**\n**    NULL:                   Store the boolean result in reg[dest]\n**    sqlite3ExprIfTrue:      Jump to dest if true\n**    sqlite3ExprIfFalse:     Jump to dest if false\n**\n** The jumpIfNull parameter is ignored if xJumpIf is NULL.\n*/\nstatic void exprCodeBetween(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* The BETWEEN expression */\n  int dest,         /* Jump destination or storage location */\n  void (*xJump)(Parse*,Expr*,int,int), /* Action to take */\n  int jumpIfNull    /* Take the jump if the BETWEEN is NULL */\n){\n Expr exprAnd;     /* The AND operator in  x>=y AND x<=z  */\n  Expr compLeft;    /* The  x>=y  term */\n  Expr compRight;   /* The  x<=z  term */\n  Expr exprX;       /* The  x  subexpression */\n  int regFree1 = 0; /* Temporary use register */\n\n\n  memset(&compLeft, 0, sizeof(Expr));\n  memset(&compRight, 0, sizeof(Expr));\n  memset(&exprAnd, 0, sizeof(Expr));\n\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  exprX = *pExpr->pLeft;\n  exprAnd.op = TK_AND;\n  exprAnd.pLeft = &compLeft;\n  exprAnd.pRight = &compRight;\n  compLeft.op = TK_GE;\n  compLeft.pLeft = &exprX;\n  compLeft.pRight = pExpr->x.pList->a[0].pExpr;\n  compRight.op = TK_LE;\n  compRight.pLeft = &exprX;\n  compRight.pRight = pExpr->x.pList->a[1].pExpr;\n  exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));\n  if( xJump ){\n    xJump(pParse, &exprAnd, dest, jumpIfNull);\n  }else{\n    /* Mark the expression is being from the ON or USING clause of a join\n    ** so that the sqlite3ExprCodeTarget() routine will not attempt to move\n    ** it into the Parse.pConstExpr list.  We should use a new bit for this,\n    ** for clarity, but we are out of bits in the Expr.flags field so we\n    ** have to reuse the EP_FromJoin bit.  Bummer. */\n    exprX.flags |= EP_FromJoin;\n    sqlite3ExprCodeTarget(pParse, &exprAnd, dest);\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n\n  /* Ensure adequate test coverage */\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==0 );\n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is true but execution\n** continues straight thru if the expression is false.\n**\n** If the expression evaluates to NULL (neither true nor false), then\n** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL.\n**\n** This code depends on the fact that certain token values (ex: TK_EQ)\n** are the same as opcode values (ex: OP_Eq) that implement the corresponding\n** operation.  Special comments in vdbe.c and the mkopcodeh.awk script in\n** the make process cause these values to align.  Assert()s in the code\n** below verify that the numbers are aligned correctly.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) )     return;  /* Existence of VDBE checked by caller */\n  if( NEVER(pExpr==0) ) return;  /* No way this can happen */\n  op = pExpr->op;\n  switch( op ){\n    case TK_AND: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_OR: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( op==TK_IS );\n      testcase( op==TK_ISNOT );\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = jumpIfNull ? dest : destIfFalse;\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeGoto(v, dest);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      break;\n    }\n#endif\n    default: {\n    default_expr:\n      if( exprAlwaysTrue(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysFalse(pExpr) ){\n        /* No-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);  \n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is false but execution\n** continues straight thru if the expression is true.\n**\n** If the expression evaluates to NULL (neither true nor false) then\n** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull\n** is 0.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */\n  if( pExpr==0 )    return;\n\n  /* The value of pExpr->op and op are related as follows:\n  **\n  **       pExpr->op            op\n  **       ---------          ----------\n  **       TK_ISNULL          OP_NotNull\n  **       TK_NOTNULL         OP_IsNull\n  **       TK_NE              OP_Eq\n  **       TK_EQ              OP_Ne\n  **       TK_GT              OP_Le\n  **       TK_LE              OP_Gt\n  **       TK_GE              OP_Lt\n  **       TK_LT              OP_Ge\n  **\n  ** For other values of pExpr->op, op is undefined and unused.\n  ** The value of TK_ and OP_ constants are arranged such that we\n  ** can compute the mapping above using the following expression.\n  ** Assert()s verify that the computation is correct.\n  */\n  op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);\n\n  /* Verify correct alignment of TK_ and OP_ constants\n  */\n  assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );\n  assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );\n  assert( pExpr->op!=TK_NE || op==OP_Eq );\n  assert( pExpr->op!=TK_EQ || op==OP_Ne );\n  assert( pExpr->op!=TK_LT || op==OP_Ge );\n  assert( pExpr->op!=TK_LE || op==OP_Gt );\n  assert( pExpr->op!=TK_GT || op==OP_Le );\n  assert( pExpr->op!=TK_GE || op==OP_Lt );\n\n  switch( pExpr->op ){\n    case TK_AND: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_OR: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( pExpr->op==TK_IS );\n      testcase( pExpr->op==TK_ISNOT );\n      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      testcase( op==TK_ISNULL );   VdbeCoverageIf(v, op==TK_ISNULL);\n      testcase( op==TK_NOTNULL );  VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      if( jumpIfNull ){\n        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);\n      }else{\n        int destIfNull = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);\n        sqlite3VdbeResolveLabel(v, destIfNull);\n      }\n      break;\n    }\n#endif\n    default: {\n    default_expr: \n      if( exprAlwaysFalse(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysTrue(pExpr) ){\n        /* no-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n}\n\n/*\n** Like sqlite3ExprIfFalse() except that a copy is made of pExpr before\n** code generation, and that copy is deleted after code generation. This\n** ensures that the original pExpr is unchanged.\n*/\nSQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,int jumpIfNull){\n  sqlite3 *db = pParse->db;\n  Expr *pCopy = sqlite3ExprDup(db, pExpr, 0);\n  if( db->mallocFailed==0 ){\n    sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);\n  }\n  sqlite3ExprDelete(db, pCopy);\n}\n\n/*\n** Expression pVar is guaranteed to be an SQL variable. pExpr may be any\n** type of expression.\n**\n** If pExpr is a simple SQL value - an integer, real, string, blob\n** or NULL value - then the VDBE currently being prepared is configured\n** to re-prepare each time a new value is bound to variable pVar.\n**\n** Additionally, if pExpr is a simple SQL value and the value is the\n** same as that currently bound to variable pVar, non-zero is returned.\n** Otherwise, if the values are not the same or if pExpr is not a simple\n** SQL value, zero is returned.\n*/\nstatic int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){\n  int res = 0;\n  int iVar;\n  sqlite3_value *pL, *pR = 0;\n  \n  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);\n  if( pR ){\n    iVar = pVar->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);\n    pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);\n    if( pL ){\n      if( sqlite3_value_type(pL)==SQLITE_TEXT ){\n        sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */\n      }\n      res =  0==sqlite3MemCompare(pL, pR, 0);\n    }\n    sqlite3ValueFree(pR);\n    sqlite3ValueFree(pL);\n  }\n\n  return res;\n}\n\n/*\n** Do a deep comparison of two expression trees.  Return 0 if the two\n** expressions are completely identical.  Return 1 if they differ only\n** by a COLLATE operator at the top level.  Return 2 if there are differences\n** other than the top-level COLLATE operator.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** The pA side might be using TK_REGISTER.  If that is the case and pB is\n** not using TK_REGISTER but is otherwise equivalent, then still return 0.\n**\n** Sometimes this routine will return 2 even if the two expressions\n** really are equivalent.  If we cannot prove that the expressions are\n** identical, we return 2 just to be safe.  So if this routine\n** returns 2, then you do not really know for certain if the two\n** expressions are the same.  But if you get a 0 or 1 return, then you\n** can be sure the expressions are the same.  In the places where\n** this routine is used, it does not hurt to get an extra 2 - that\n** just might result in some slightly slower code.  But returning\n** an incorrect 0 or 1 could lead to a malfunction.\n**\n** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in\n** pParse->pReprepare can be matched against literals in pB.  The \n** pParse->pVdbe->expmask bitmask is updated for each variable referenced.\n** If pParse is NULL (the normal case) then any TK_VARIABLE term in \n** Argument pParse should normally be NULL. If it is not NULL and pA or\n** pB causes a return value of 2.\n*/\nSQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){\n  u32 combinedFlags;\n  if( pA==0 || pB==0 ){\n    return pB==pA ? 0 : 2;\n  }\n  if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){\n    return 0;\n  }\n  combinedFlags = pA->flags | pB->flags;\n  if( combinedFlags & EP_IntValue ){\n    if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){\n      return 0;\n    }\n    return 2;\n  }\n  if( pA->op!=pB->op ){\n    if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){\n      return 1;\n    }\n    if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){\n      return 1;\n    }\n    return 2;\n  }\n  if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){\n    if( pA->op==TK_FUNCTION ){\n      if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;\n    }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){\n      return pA->op==TK_COLLATE ? 1 : 2;\n    }\n  }\n  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;\n  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){\n    if( combinedFlags & EP_xIsSelect ) return 2;\n    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;\n    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;\n    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;\n    if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){\n      if( pA->iColumn!=pB->iColumn ) return 2;\n      if( pA->iTable!=pB->iTable \n       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;\n    }\n  }\n  return 0;\n}\n\n/*\n** Compare two ExprList objects.  Return 0 if they are identical and \n** non-zero if they differ in any way.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** This routine might return non-zero for equivalent ExprLists.  The\n** only consequence will be disabled optimizations.  But this routine\n** must never return 0 if the two ExprList objects are different, or\n** a malfunction will result.\n**\n** Two NULL pointers are considered to be the same.  But a NULL pointer\n** always differs from a non-NULL pointer.\n*/\nSQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){\n  int i;\n  if( pA==0 && pB==0 ) return 0;\n  if( pA==0 || pB==0 ) return 1;\n  if( pA->nExpr!=pB->nExpr ) return 1;\n  for(i=0; i<pA->nExpr; i++){\n    Expr *pExprA = pA->a[i].pExpr;\n    Expr *pExprB = pB->a[i].pExpr;\n    if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;\n    if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Like sqlite3ExprCompare() except COLLATE operators at the top-level\n** are ignored.\n*/\nSQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){\n  return sqlite3ExprCompare(0,\n             sqlite3ExprSkipCollate(pA),\n             sqlite3ExprSkipCollate(pB),\n             iTab);\n}\n\n/*\n** Return true if we can prove the pE2 will always be true if pE1 is\n** true.  Return false if we cannot complete the proof or if pE2 might\n** be false.  Examples:\n**\n**     pE1: x==5       pE2: x==5             Result: true\n**     pE1: x>0        pE2: x==5             Result: false\n**     pE1: x=21       pE2: x=21 OR y=43     Result: true\n**     pE1: x!=123     pE2: x IS NOT NULL    Result: true\n**     pE1: x!=?1      pE2: x IS NOT NULL    Result: true\n**     pE1: x IS NULL  pE2: x IS NOT NULL    Result: false\n**     pE1: x IS ?2    pE2: x IS NOT NULL    Reuslt: false\n**\n** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has\n** Expr.iTable<0 then assume a table number given by iTab.\n**\n** If pParse is not NULL, then the values of bound variables in pE1 are \n** compared against literal values in pE2 and pParse->pVdbe->expmask is\n** modified to record which bound variables are referenced.  If pParse \n** is NULL, then false will be returned if pE1 contains any bound variables.\n**\n** When in doubt, return false.  Returning true might give a performance\n** improvement.  Returning false might cause a performance reduction, but\n** it will always give the correct answer and is hence always safe.\n*/\nSQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){\n  if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){\n    return 1;\n  }\n  if( pE2->op==TK_OR\n   && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)\n             || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )\n  ){\n    return 1;\n  }\n  if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){\n    Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);\n    testcase( pX!=pE1->pLeft );\n    if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;\n  }\n  return 0;\n}\n\n/*\n** An instance of the following structure is used by the tree walker\n** to determine if an expression can be evaluated by reference to the\n** index only, without having to do a search for the corresponding\n** table entry.  The IdxCover.pIdx field is the index.  IdxCover.iCur\n** is the cursor for the table.\n*/\nstruct IdxCover {\n  Index *pIdx;     /* The index to be tested for coverage */\n  int iCur;        /* Cursor number for the table corresponding to the index */\n};\n\n/*\n** Check to see if there are references to columns in table \n** pWalker->u.pIdxCover->iCur can be satisfied using the index\n** pWalker->u.pIdxCover->pIdx.\n*/\nstatic int exprIdxCover(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pWalker->u.pIdxCover->iCur\n   && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if an index pIdx on table with cursor iCur contains will\n** the expression pExpr.  Return true if the index does cover the\n** expression and false if the pExpr expression references table columns\n** that are not found in the index pIdx.\n**\n** An index covering an expression means that the expression can be\n** evaluated using only the index and without having to lookup the\n** corresponding table entry.\n*/\nSQLITE_PRIVATE int sqlite3ExprCoveredByIndex(\n  Expr *pExpr,        /* The index to be tested */\n  int iCur,           /* The cursor number for the corresponding table */\n  Index *pIdx         /* The index that might be used for coverage */\n){\n  Walker w;\n  struct IdxCover xcov;\n  memset(&w, 0, sizeof(w));\n  xcov.iCur = iCur;\n  xcov.pIdx = pIdx;\n  w.xExprCallback = exprIdxCover;\n  w.u.pIdxCover = &xcov;\n  sqlite3WalkExpr(&w, pExpr);\n  return !w.eCode;\n}\n\n\n/*\n** An instance of the following structure is used by the tree walker\n** to count references to table columns in the arguments of an \n** aggregate function, in order to implement the\n** sqlite3FunctionThisSrc() routine.\n*/\nstruct SrcCount {\n  SrcList *pSrc;   /* One particular FROM clause in a nested query */\n  int nThis;       /* Number of references to columns in pSrcList */\n  int nOther;      /* Number of references to columns in other FROM clauses */\n};\n\n/*\n** Count the number of references to columns.\n*/\nstatic int exprSrcCount(Walker *pWalker, Expr *pExpr){\n  /* The NEVER() on the second term is because sqlite3FunctionUsesThisSrc()\n  ** is always called before sqlite3ExprAnalyzeAggregates() and so the\n  ** TK_COLUMNs have not yet been converted into TK_AGG_COLUMN.  If\n  ** sqlite3FunctionUsesThisSrc() is used differently in the future, the\n  ** NEVER() will need to be removed. */\n  if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){\n    int i;\n    struct SrcCount *p = pWalker->u.pSrcCount;\n    SrcList *pSrc = p->pSrc;\n    int nSrc = pSrc ? pSrc->nSrc : 0;\n    for(i=0; i<nSrc; i++){\n      if( pExpr->iTable==pSrc->a[i].iCursor ) break;\n    }\n    if( i<nSrc ){\n      p->nThis++;\n    }else{\n      p->nOther++;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if any of the arguments to the pExpr Function reference\n** pSrcList.  Return true if they do.  Also return true if the function\n** has no arguments or has only constant arguments.  Return false if pExpr\n** references columns but not columns of tables found in pSrcList.\n*/\nSQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){\n  Walker w;\n  struct SrcCount cnt;\n  assert( pExpr->op==TK_AGG_FUNCTION );\n  w.xExprCallback = exprSrcCount;\n  w.xSelectCallback = 0;\n  w.u.pSrcCount = &cnt;\n  cnt.pSrc = pSrcList;\n  cnt.nThis = 0;\n  cnt.nOther = 0;\n  sqlite3WalkExprList(&w, pExpr->x.pList);\n  return cnt.nThis>0 || cnt.nOther==0;\n}\n\n/*\n** Add a new element to the pAggInfo->aCol[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoColumn(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aCol = sqlite3ArrayAllocate(\n       db,\n       pInfo->aCol,\n       sizeof(pInfo->aCol[0]),\n       &pInfo->nColumn,\n       &i\n  );\n  return i;\n}    \n\n/*\n** Add a new element to the pAggInfo->aFunc[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aFunc = sqlite3ArrayAllocate(\n       db, \n       pInfo->aFunc,\n       sizeof(pInfo->aFunc[0]),\n       &pInfo->nFunc,\n       &i\n  );\n  return i;\n}    \n\n/*\n** This is the xExprCallback for a tree walker.  It is used to\n** implement sqlite3ExprAnalyzeAggregates().  See sqlite3ExprAnalyzeAggregates\n** for additional information.\n*/\nstatic int analyzeAggregate(Walker *pWalker, Expr *pExpr){\n  int i;\n  NameContext *pNC = pWalker->u.pNC;\n  Parse *pParse = pNC->pParse;\n  SrcList *pSrcList = pNC->pSrcList;\n  AggInfo *pAggInfo = pNC->pAggInfo;\n\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      /* Check to see if the column is in one of the tables in the FROM\n      ** clause of the aggregate query */\n      if( ALWAYS(pSrcList!=0) ){\n        struct SrcList_item *pItem = pSrcList->a;\n        for(i=0; i<pSrcList->nSrc; i++, pItem++){\n          struct AggInfo_col *pCol;\n          assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n          if( pExpr->iTable==pItem->iCursor ){\n            /* If we reach this point, it means that pExpr refers to a table\n            ** that is in the FROM clause of the aggregate query.  \n            **\n            ** Make an entry for the column in pAggInfo->aCol[] if there\n            ** is not an entry there already.\n            */\n            int k;\n            pCol = pAggInfo->aCol;\n            for(k=0; k<pAggInfo->nColumn; k++, pCol++){\n              if( pCol->iTable==pExpr->iTable &&\n                  pCol->iColumn==pExpr->iColumn ){\n                break;\n              }\n            }\n            if( (k>=pAggInfo->nColumn)\n             && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 \n            ){\n              pCol = &pAggInfo->aCol[k];\n              pCol->pTab = pExpr->pTab;\n              pCol->iTable = pExpr->iTable;\n              pCol->iColumn = pExpr->iColumn;\n              pCol->iMem = ++pParse->nMem;\n              pCol->iSorterColumn = -1;\n              pCol->pExpr = pExpr;\n              if( pAggInfo->pGroupBy ){\n                int j, n;\n                ExprList *pGB = pAggInfo->pGroupBy;\n                struct ExprList_item *pTerm = pGB->a;\n                n = pGB->nExpr;\n                for(j=0; j<n; j++, pTerm++){\n                  Expr *pE = pTerm->pExpr;\n                  if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&\n                      pE->iColumn==pExpr->iColumn ){\n                    pCol->iSorterColumn = j;\n                    break;\n                  }\n                }\n              }\n              if( pCol->iSorterColumn<0 ){\n                pCol->iSorterColumn = pAggInfo->nSortingColumn++;\n              }\n            }\n            /* There is now an entry for pExpr in pAggInfo->aCol[] (either\n            ** because it was there before or because we just created it).\n            ** Convert the pExpr to be a TK_AGG_COLUMN referring to that\n            ** pAggInfo->aCol[] entry.\n            */\n            ExprSetVVAProperty(pExpr, EP_NoReduce);\n            pExpr->pAggInfo = pAggInfo;\n            pExpr->op = TK_AGG_COLUMN;\n            pExpr->iAgg = (i16)k;\n            break;\n          } /* endif pExpr->iTable==pItem->iCursor */\n        } /* end loop over pSrcList */\n      }\n      return WRC_Prune;\n    }\n    case TK_AGG_FUNCTION: {\n      if( (pNC->ncFlags & NC_InAggFunc)==0\n       && pWalker->walkerDepth==pExpr->op2\n      ){\n        /* Check to see if pExpr is a duplicate of another aggregate \n        ** function that is already in the pAggInfo structure\n        */\n        struct AggInfo_func *pItem = pAggInfo->aFunc;\n        for(i=0; i<pAggInfo->nFunc; i++, pItem++){\n          if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){\n            break;\n          }\n        }\n        if( i>=pAggInfo->nFunc ){\n          /* pExpr is original.  Make a new entry in pAggInfo->aFunc[]\n          */\n          u8 enc = ENC(pParse->db);\n          i = addAggInfoFunc(pParse->db, pAggInfo);\n          if( i>=0 ){\n            assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n            pItem = &pAggInfo->aFunc[i];\n            pItem->pExpr = pExpr;\n            pItem->iMem = ++pParse->nMem;\n            assert( !ExprHasProperty(pExpr, EP_IntValue) );\n            pItem->pFunc = sqlite3FindFunction(pParse->db,\n                   pExpr->u.zToken, \n                   pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);\n            if( pExpr->flags & EP_Distinct ){\n              pItem->iDistinct = pParse->nTab++;\n            }else{\n              pItem->iDistinct = -1;\n            }\n          }\n        }\n        /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry\n        */\n        assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n        ExprSetVVAProperty(pExpr, EP_NoReduce);\n        pExpr->iAgg = (i16)i;\n        pExpr->pAggInfo = pAggInfo;\n        return WRC_Prune;\n      }else{\n        return WRC_Continue;\n      }\n    }\n  }\n  return WRC_Continue;\n}\nstatic int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth++;\n  return WRC_Continue;\n}\nstatic void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth--;\n}\n\n/*\n** Analyze the pExpr expression looking for aggregate functions and\n** for variables that need to be added to AggInfo object that pNC->pAggInfo\n** points to.  Additional entries are made on the AggInfo object as\n** necessary.\n**\n** This routine should only be called after the expression has been\n** analyzed by sqlite3ResolveExprNames().\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){\n  Walker w;\n  w.xExprCallback = analyzeAggregate;\n  w.xSelectCallback = analyzeAggregatesInSelect;\n  w.xSelectCallback2 = analyzeAggregatesInSelectEnd;\n  w.walkerDepth = 0;\n  w.u.pNC = pNC;\n  assert( pNC->pSrcList!=0 );\n  sqlite3WalkExpr(&w, pExpr);\n}\n\n/*\n** Call sqlite3ExprAnalyzeAggregates() for every expression in an\n** expression list.  Return the number of errors.\n**\n** If an error is found, the analysis is cut short.\n*/\nSQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext *pNC, ExprList *pList){\n  struct ExprList_item *pItem;\n  int i;\n  if( pList ){\n    for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){\n      sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);\n    }\n  }\n}\n\n/*\n** Allocate a single new register for use to hold some intermediate result.\n*/\nSQLITE_PRIVATE int sqlite3GetTempReg(Parse *pParse){\n  if( pParse->nTempReg==0 ){\n    return ++pParse->nMem;\n  }\n  return pParse->aTempReg[--pParse->nTempReg];\n}\n\n/*\n** Deallocate a register, making available for reuse for some other\n** purpose.\n**\n** If a register is currently being used by the column cache, then\n** the deallocation is deferred until the column cache line that uses\n** the register becomes stale.\n*/\nSQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse *pParse, int iReg){\n  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n    int i;\n    struct yColCache *p;\n    for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n      if( p->iReg==iReg ){\n        p->tempReg = 1;\n        return;\n      }\n    }\n    pParse->aTempReg[pParse->nTempReg++] = iReg;\n  }\n}\n\n/*\n** Allocate or deallocate a block of nReg consecutive registers.\n*/\nSQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){\n  int i, n;\n  if( nReg==1 ) return sqlite3GetTempReg(pParse);\n  i = pParse->iRangeReg;\n  n = pParse->nRangeReg;\n  if( nReg<=n ){\n    assert( !usedAsColumnCache(pParse, i, i+n-1) );\n    pParse->iRangeReg += nReg;\n    pParse->nRangeReg -= nReg;\n  }else{\n    i = pParse->nMem+1;\n    pParse->nMem += nReg;\n  }\n  return i;\n}\nSQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){\n  if( nReg==1 ){\n    sqlite3ReleaseTempReg(pParse, iReg);\n    return;\n  }\n  sqlite3ExprCacheRemove(pParse, iReg, nReg);\n  if( nReg>pParse->nRangeReg ){\n    pParse->nRangeReg = nReg;\n    pParse->iRangeReg = iReg;\n  }\n}\n\n/*\n** Mark all temporary registers as being unavailable for reuse.\n*/\nSQLITE_PRIVATE void sqlite3ClearTempRegCache(Parse *pParse){\n  pParse->nTempReg = 0;\n  pParse->nRangeReg = 0;\n}\n\n/*\n** Validate that no temporary register falls within the range of\n** iFirst..iLast, inclusive.  This routine is only call from within assert()\n** statements.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){\n  int i;\n  if( pParse->nRangeReg>0\n   && pParse->iRangeReg+pParse->nRangeReg > iFirst\n   && pParse->iRangeReg <= iLast\n  ){\n     return 0;\n  }\n  for(i=0; i<pParse->nTempReg; i++){\n    if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n/************** End of expr.c ************************************************/\n/************** Begin file alter.c *******************************************/\n/*\n** 2005 February 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that used to generate VDBE code\n** that implements the ALTER TABLE command.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** The code in this file only exists if we are not omitting the\n** ALTER TABLE logic from the build.\n*/\n#ifndef SQLITE_OMIT_ALTERTABLE\n\n\n/*\n** This function is used by SQL generated to implement the \n** ALTER TABLE command. The first argument is the text of a CREATE TABLE or\n** CREATE INDEX command. The second is a table name. The table name in \n** the CREATE TABLE or CREATE INDEX statement is replaced with the third\n** argument and the result returned. Examples:\n**\n** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')\n**     -> 'CREATE TABLE def(a, b, c)'\n**\n** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')\n**     -> 'CREATE INDEX i ON def(a, b, c)'\n*/\nstatic void renameTableFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TABLE \n  ** statement is that the table name is the first non-space token that\n  ** is immediately followed by a TK_LP or TK_USING token.\n  */\n  if( zSql ){\n    do {\n      if( !*zCsr ){\n        /* Ran out of input before finding an opening bracket. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      } while( token==TK_SPACE );\n      assert( len>0 );\n    } while( token!=TK_LP && token!=TK_USING );\n\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", (int)(((u8*)tname.z) - zSql),\n       zSql, zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** This C function implements an SQL user function that is used by SQL code\n** generated by the ALTER TABLE ... RENAME command to modify the definition\n** of any foreign key constraints that use the table being renamed as the \n** parent table. It is passed three arguments:\n**\n**   1) The complete text of the CREATE TABLE statement being modified,\n**   2) The old name of the table being renamed, and\n**   3) The new name of the table being renamed.\n**\n** It returns the new CREATE TABLE statement. For example:\n**\n**   sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')\n**       -> 'CREATE TABLE t1(a REFERENCES t3)'\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic void renameParentFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zOutput = 0;\n  char *zResult;\n  unsigned char const *zInput = sqlite3_value_text(argv[0]);\n  unsigned char const *zOld = sqlite3_value_text(argv[1]);\n  unsigned char const *zNew = sqlite3_value_text(argv[2]);\n\n  unsigned const char *z;         /* Pointer to token */\n  int n;                          /* Length of token z */\n  int token;                      /* Type of token */\n\n  UNUSED_PARAMETER(NotUsed);\n  if( zInput==0 || zOld==0 ) return;\n  for(z=zInput; *z; z=z+n){\n    n = sqlite3GetToken(z, &token);\n    if( token==TK_REFERENCES ){\n      char *zParent;\n      do {\n        z += n;\n        n = sqlite3GetToken(z, &token);\n      }while( token==TK_SPACE );\n\n      if( token==TK_ILLEGAL ) break;\n      zParent = sqlite3DbStrNDup(db, (const char *)z, n);\n      if( zParent==0 ) break;\n      sqlite3Dequote(zParent);\n      if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){\n        char *zOut = sqlite3MPrintf(db, \"%s%.*s\\\"%w\\\"\", \n            (zOutput?zOutput:\"\"), (int)(z-zInput), zInput, (const char *)zNew\n        );\n        sqlite3DbFree(db, zOutput);\n        zOutput = zOut;\n        zInput = &z[n];\n      }\n      sqlite3DbFree(db, zParent);\n    }\n  }\n\n  zResult = sqlite3MPrintf(db, \"%s%s\", (zOutput?zOutput:\"\"), zInput), \n  sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);\n  sqlite3DbFree(db, zOutput);\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n/* This function is used by SQL generated to implement the\n** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER \n** statement. The second is a table name. The table name in the CREATE \n** TRIGGER statement is replaced with the third argument and the result \n** returned. This is analagous to renameTableFunc() above, except for CREATE\n** TRIGGER, not CREATE INDEX and CREATE TABLE.\n*/\nstatic void renameTriggerFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  int dist = 3;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TRIGGER \n  ** statement is that the table name is the first token that is immediately\n  ** preceded by either TK_ON or TK_DOT and immediately followed by one\n  ** of TK_WHEN, TK_BEGIN or TK_FOR.\n  */\n  if( zSql ){\n    do {\n\n      if( !*zCsr ){\n        /* Ran out of input before finding the table name. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      }while( token==TK_SPACE );\n      assert( len>0 );\n\n      /* Variable 'dist' stores the number of tokens read since the most\n      ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN \n      ** token is read and 'dist' equals 2, the condition stated above\n      ** to be met.\n      **\n      ** Note that ON cannot be a database, table or column name, so\n      ** there is no need to worry about syntax like \n      ** \"CREATE TRIGGER ... ON ON.ON BEGIN ...\" etc.\n      */\n      dist++;\n      if( token==TK_DOT || token==TK_ON ){\n        dist = 0;\n      }\n    } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );\n\n    /* Variable tname now contains the token that is the old table-name\n    ** in the CREATE TRIGGER statement.\n    */\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", (int)(((u8*)tname.z) - zSql),\n       zSql, zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n#endif   /* !SQLITE_OMIT_TRIGGER */\n\n/*\n** Register built-in functions used to help implement ALTER TABLE\n*/\nSQLITE_PRIVATE void sqlite3AlterFunctions(void){\n  static FuncDef aAlterTableFuncs[] = {\n    FUNCTION(sqlite_rename_table,   2, 0, 0, renameTableFunc),\n#ifndef SQLITE_OMIT_TRIGGER\n    FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    FUNCTION(sqlite_rename_parent,  3, 0, 0, renameParentFunc),\n#endif\n  };\n  sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));\n}\n\n/*\n** This function is used to create the text of expressions of the form:\n**\n**   name=<constant1> OR name=<constant2> OR ...\n**\n** If argument zWhere is NULL, then a pointer string containing the text \n** \"name=<constant>\" is returned, where <constant> is the quoted version\n** of the string passed as argument zConstant. The returned buffer is\n** allocated using sqlite3DbMalloc(). It is the responsibility of the\n** caller to ensure that it is eventually freed.\n**\n** If argument zWhere is not NULL, then the string returned is \n** \"<where> OR name=<constant>\", where <where> is the contents of zWhere.\n** In this case zWhere is passed to sqlite3DbFree() before returning.\n** \n*/\nstatic char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){\n  char *zNew;\n  if( !zWhere ){\n    zNew = sqlite3MPrintf(db, \"name=%Q\", zConstant);\n  }else{\n    zNew = sqlite3MPrintf(db, \"%s OR name=%Q\", zWhere, zConstant);\n    sqlite3DbFree(db, zWhere);\n  }\n  return zNew;\n}\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** tables that have foreign key constraints that refer to table pTab (i.e.\n** constraints for which pTab is the parent table) from the sqlite_master\n** table.\n*/\nstatic char *whereForeignKeys(Parse *pParse, Table *pTab){\n  FKey *p;\n  char *zWhere = 0;\n  for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n    zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);\n  }\n  return zWhere;\n}\n#endif\n\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** temporary triggers on table pTab from the sqlite_temp_master table. If\n** table pTab has no temporary triggers, or is itself stored in the \n** temporary database, NULL is returned.\n*/\nstatic char *whereTempTriggers(Parse *pParse, Table *pTab){\n  Trigger *pTrig;\n  char *zWhere = 0;\n  const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */\n\n  /* If the table is not located in the temp-db (in which case NULL is \n  ** returned, loop through the tables list of triggers. For each trigger\n  ** that is not part of the temp-db schema, add a clause to the WHERE \n  ** expression being built up in zWhere.\n  */\n  if( pTab->pSchema!=pTempSchema ){\n    sqlite3 *db = pParse->db;\n    for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n      if( pTrig->pSchema==pTempSchema ){\n        zWhere = whereOrName(db, zWhere, pTrig->zName);\n      }\n    }\n  }\n  if( zWhere ){\n    char *zNew = sqlite3MPrintf(pParse->db, \"type='trigger' AND (%s)\", zWhere);\n    sqlite3DbFree(pParse->db, zWhere);\n    zWhere = zNew;\n  }\n  return zWhere;\n}\n\n/*\n** Generate code to drop and reload the internal representation of table\n** pTab from the database, including triggers and temporary triggers.\n** Argument zName is the name of the table in the database schema at\n** the time the generated code is executed. This can be different from\n** pTab->zName if this function is being called to code part of an \n** \"ALTER TABLE RENAME TO\" statement.\n*/\nstatic void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){\n  Vdbe *v;\n  char *zWhere;\n  int iDb;                   /* Index of database containing pTab */\n#ifndef SQLITE_OMIT_TRIGGER\n  Trigger *pTrig;\n#endif\n\n  v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  assert( iDb>=0 );\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Drop any table triggers from the internal schema. */\n  for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n    int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n    assert( iTrigDb==iDb || iTrigDb==1 );\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);\n  }\n#endif\n\n  /* Drop the table and index from the internal schema.  */\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n\n  /* Reload the table, index and permanent trigger schemas. */\n  zWhere = sqlite3MPrintf(pParse->db, \"tbl_name=%Q\", zName);\n  if( !zWhere ) return;\n  sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Now, if the table is not stored in the temp database, reload any temp \n  ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. \n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);\n  }\n#endif\n}\n\n/*\n** Parameter zName is the name of a table that is about to be altered\n** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).\n** If the table is a system table, this function leaves an error message\n** in pParse->zErr (system tables may not be altered) and returns non-zero.\n**\n** Or, if zName is not a system table, zero is returned.\n*/\nstatic int isSystemTable(Parse *pParse, const char *zName){\n  if( 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be altered\", zName);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Generate code to implement the \"ALTER TABLE xxx RENAME TO yyy\" \n** command. \n*/\nSQLITE_PRIVATE void sqlite3AlterRenameTable(\n  Parse *pParse,            /* Parser context. */\n  SrcList *pSrc,            /* The table to rename. */\n  Token *pName              /* The new table name. */\n){\n  int iDb;                  /* Database that contains the table */\n  char *zDb;                /* Name of database iDb */\n  Table *pTab;              /* Table being renamed */\n  char *zName = 0;          /* NULL-terminated version of pName */ \n  sqlite3 *db = pParse->db; /* Database connection */\n  int nTabName;             /* Number of UTF-8 characters in zTabName */\n  const char *zTabName;     /* Original name of the table */\n  Vdbe *v;\n#ifndef SQLITE_OMIT_TRIGGER\n  char *zWhere = 0;         /* Where clause to locate temp triggers */\n#endif\n  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */\n  u32 savedDbFlags;         /* Saved value of db->mDbFlags */\n\n  savedDbFlags = db->mDbFlags;  \n  if( NEVER(db->mallocFailed) ) goto exit_rename_table;\n  assert( pSrc->nSrc==1 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_rename_table;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  db->mDbFlags |= DBFLAG_PreferBuiltin;\n\n  /* Get a NULL terminated version of the new table name. */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName ) goto exit_rename_table;\n\n  /* Check that a table or index named 'zName' does not already exist\n  ** in database iDb. If so, this is an error.\n  */\n  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){\n    sqlite3ErrorMsg(pParse, \n        \"there is already another table or index with this name: %s\", zName);\n    goto exit_rename_table;\n  }\n\n  /* Make sure it is not a system table being altered, or a reserved name\n  ** that the table is being renamed to.\n  */\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_rename_table;\n  }\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto\n    exit_rename_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"view %s may not be altered\", pTab->zName);\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_rename_table;\n  }\n  if( IsVirtual(pTab) ){\n    pVTab = sqlite3GetVTable(db, pTab);\n    if( pVTab->pVtab->pModule->xRename==0 ){\n      pVTab = 0;\n    }\n  }\n#endif\n\n  /* Begin a transaction for database iDb. \n  ** Then modify the schema cookie (since the ALTER TABLE modifies the\n  ** schema). Open a statement transaction if the table is a virtual\n  ** table.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto exit_rename_table;\n  }\n  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);\n  sqlite3ChangeCookie(pParse, iDb);\n\n  /* If this is a virtual table, invoke the xRename() function if\n  ** one is defined. The xRename() callback will modify the names\n  ** of any resources used by the v-table implementation (including other\n  ** SQLite tables) that are identified by the name of the virtual table.\n  */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pVTab ){\n    int i = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, i, zName);\n    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);\n    sqlite3MayAbort(pParse);\n  }\n#endif\n\n  /* figure out how many UTF-8 characters are in zName */\n  zTabName = pTab->zName;\n  nTabName = sqlite3Utf8CharLen(zTabName, -1);\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    /* If foreign-key support is enabled, rewrite the CREATE TABLE \n    ** statements corresponding to all child tables of foreign key constraints\n    ** for which the renamed table is the parent table.  */\n    if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){\n      sqlite3NestedParse(pParse, \n          \"UPDATE \\\"%w\\\".%s SET \"\n              \"sql = sqlite_rename_parent(sql, %Q, %Q) \"\n              \"WHERE %s;\", zDb, MASTER_NAME, zTabName, zName, zWhere);\n      sqlite3DbFree(db, zWhere);\n    }\n  }\n#endif\n\n  /* Modify the sqlite_master table to use the new table name. */\n  sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s SET \"\n#ifdef SQLITE_OMIT_TRIGGER\n          \"sql = sqlite_rename_table(sql, %Q), \"\n#else\n          \"sql = CASE \"\n            \"WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)\"\n            \"ELSE sqlite_rename_table(sql, %Q) END, \"\n#endif\n          \"tbl_name = %Q, \"\n          \"name = CASE \"\n            \"WHEN type='table' THEN %Q \"\n            \"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN \"\n             \"'sqlite_autoindex_' || %Q || substr(name,%d+18) \"\n            \"ELSE name END \"\n      \"WHERE tbl_name=%Q COLLATE nocase AND \"\n          \"(type='table' OR type='index' OR type='trigger');\", \n      zDb, MASTER_NAME, zName, zName, zName, \n#ifndef SQLITE_OMIT_TRIGGER\n      zName,\n#endif\n      zName, nTabName, zTabName\n  );\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* If the sqlite_sequence table exists in this database, then update \n  ** it with the new table name.\n  */\n  if( sqlite3FindTable(db, \"sqlite_sequence\", zDb) ){\n    sqlite3NestedParse(pParse,\n        \"UPDATE \\\"%w\\\".sqlite_sequence set name = %Q WHERE name = %Q\",\n        zDb, zName, pTab->zName);\n  }\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* If there are TEMP triggers on this table, modify the sqlite_temp_master\n  ** table. Don't do this if the table being ALTERed is itself located in\n  ** the temp database.\n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3NestedParse(pParse, \n        \"UPDATE sqlite_temp_master SET \"\n            \"sql = sqlite_rename_trigger(sql, %Q), \"\n            \"tbl_name = %Q \"\n            \"WHERE %s;\", zName, zName, zWhere);\n    sqlite3DbFree(db, zWhere);\n  }\n#endif\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Table *pFrom = p->pFrom;\n      if( pFrom!=pTab ){\n        reloadTableSchema(pParse, p->pFrom, pFrom->zName);\n      }\n    }\n  }\n#endif\n\n  /* Drop and reload the internal table schema. */\n  reloadTableSchema(pParse, pTab, zName);\n\nexit_rename_table:\n  sqlite3SrcListDelete(db, pSrc);\n  sqlite3DbFree(db, zName);\n  db->mDbFlags = savedDbFlags;\n}\n\n/*\n** This function is called after an \"ALTER TABLE ... ADD\" statement\n** has been parsed. Argument pColDef contains the text of the new\n** column definition.\n**\n** The Table structure pParse->pNewTable was extended to include\n** the new column during parsing.\n*/\nSQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){\n  Table *pNew;              /* Copy of pParse->pNewTable */\n  Table *pTab;              /* Table being altered */\n  int iDb;                  /* Database number */\n  const char *zDb;          /* Database name */\n  const char *zTab;         /* Table name */\n  char *zCol;               /* Null-terminated column definition */\n  Column *pCol;             /* The new column */\n  Expr *pDflt;              /* Default value for the new column */\n  sqlite3 *db;              /* The database connection; */\n  Vdbe *v = pParse->pVdbe;  /* The prepared statement under construction */\n  int r1;                   /* Temporary registers */\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ) return;\n  assert( v!=0 );\n  pNew = pParse->pNewTable;\n  assert( pNew );\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  zTab = &pNew->zName[16];  /* Skip the \"sqlite_altertab_\" prefix on the name */\n  pCol = &pNew->aCol[pNew->nCol-1];\n  pDflt = pCol->pDflt;\n  pTab = sqlite3FindTable(db, zTab, zDb);\n  assert( pTab );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    return;\n  }\n#endif\n\n  /* If the default value for the new column was specified with a \n  ** literal NULL, then set pDflt to 0. This simplifies checking\n  ** for an SQL NULL default below.\n  */\n  assert( pDflt==0 || pDflt->op==TK_SPAN );\n  if( pDflt && pDflt->pLeft->op==TK_NULL ){\n    pDflt = 0;\n  }\n\n  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.\n  ** If there is a NOT NULL constraint, then the default value for the\n  ** column must not be NULL.\n  */\n  if( pCol->colFlags & COLFLAG_PRIMKEY ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a PRIMARY KEY column\");\n    return;\n  }\n  if( pNew->pIndex ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a UNIQUE column\");\n    return;\n  }\n  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a REFERENCES column with non-NULL default value\");\n    return;\n  }\n  if( pCol->notNull && !pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a NOT NULL column with default value NULL\");\n    return;\n  }\n\n  /* Ensure the default expression is something that sqlite3ValueFromExpr()\n  ** can handle (i.e. not CURRENT_TIME etc.)\n  */\n  if( pDflt ){\n    sqlite3_value *pVal = 0;\n    int rc;\n    rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc!=SQLITE_OK ){\n      assert( db->mallocFailed == 1 );\n      return;\n    }\n    if( !pVal ){\n      sqlite3ErrorMsg(pParse, \"Cannot add a column with non-constant default\");\n      return;\n    }\n    sqlite3ValueFree(pVal);\n  }\n\n  /* Modify the CREATE TABLE statement. */\n  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);\n  if( zCol ){\n    char *zEnd = &zCol[pColDef->n-1];\n    u32 savedDbFlags = db->mDbFlags;\n    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){\n      *zEnd-- = '\\0';\n    }\n    db->mDbFlags |= DBFLAG_PreferBuiltin;\n    sqlite3NestedParse(pParse, \n        \"UPDATE \\\"%w\\\".%s SET \"\n          \"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) \"\n        \"WHERE type = 'table' AND name = %Q\", \n      zDb, MASTER_NAME, pNew->addColOffset, zCol, pNew->addColOffset+1,\n      zTab\n    );\n    sqlite3DbFree(db, zCol);\n    db->mDbFlags = savedDbFlags;\n  }\n\n  /* Make sure the schema version is at least 3.  But do not upgrade\n  ** from less than 3 to 4, as that will corrupt any preexisting DESC\n  ** index.\n  */\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);\n  sqlite3VdbeUsesBtree(v, iDb);\n  sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);\n  sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);\n  sqlite3ReleaseTempReg(pParse, r1);\n\n  /* Reload the schema of the modified table. */\n  reloadTableSchema(pParse, pTab, pTab->zName);\n}\n\n/*\n** This function is called by the parser after the table-name in\n** an \"ALTER TABLE <table-name> ADD\" statement is parsed. Argument \n** pSrc is the full-name of the table being altered.\n**\n** This routine makes a (partial) copy of the Table structure\n** for the table being altered and sets Parse.pNewTable to point\n** to it. Routines called by the parser as the column definition\n** is parsed (i.e. sqlite3AddColumn()) add the new Column data to \n** the copy. The copy of the Table structure is deleted by tokenize.c \n** after parsing is finished.\n**\n** Routine sqlite3AlterFinishAddColumn() will be called to complete\n** coding the \"ALTER TABLE ... ADD\" statement.\n*/\nSQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){\n  Table *pNew;\n  Table *pTab;\n  Vdbe *v;\n  int iDb;\n  int i;\n  int nAlloc;\n  sqlite3 *db = pParse->db;\n\n  /* Look up the table being altered. */\n  assert( pParse->pNewTable==0 );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  if( db->mallocFailed ) goto exit_begin_add_column;\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_begin_add_column;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be altered\");\n    goto exit_begin_add_column;\n  }\n#endif\n\n  /* Make sure this is not an attempt to ALTER a view. */\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a column to a view\");\n    goto exit_begin_add_column;\n  }\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_begin_add_column;\n  }\n\n  assert( pTab->addColOffset>0 );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n  /* Put a copy of the Table struct in Parse.pNewTable for the\n  ** sqlite3AddColumn() function and friends to modify.  But modify\n  ** the name by adding an \"sqlite_altertab_\" prefix.  By adding this\n  ** prefix, we insure that the name will not collide with an existing\n  ** table because user table are not allowed to have the \"sqlite_\"\n  ** prefix on their name.\n  */\n  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));\n  if( !pNew ) goto exit_begin_add_column;\n  pParse->pNewTable = pNew;\n  pNew->nTabRef = 1;\n  pNew->nCol = pTab->nCol;\n  assert( pNew->nCol>0 );\n  nAlloc = (((pNew->nCol-1)/8)*8)+8;\n  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );\n  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);\n  pNew->zName = sqlite3MPrintf(db, \"sqlite_altertab_%s\", pTab->zName);\n  if( !pNew->aCol || !pNew->zName ){\n    assert( db->mallocFailed );\n    goto exit_begin_add_column;\n  }\n  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);\n  for(i=0; i<pNew->nCol; i++){\n    Column *pCol = &pNew->aCol[i];\n    pCol->zName = sqlite3DbStrDup(db, pCol->zName);\n    pCol->zColl = 0;\n    pCol->pDflt = 0;\n  }\n  pNew->pSchema = db->aDb[iDb].pSchema;\n  pNew->addColOffset = pTab->addColOffset;\n  pNew->nTabRef = 1;\n\n  /* Begin a transaction and increment the schema cookie.  */\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) goto exit_begin_add_column;\n  sqlite3ChangeCookie(pParse, iDb);\n\nexit_begin_add_column:\n  sqlite3SrcListDelete(db, pSrc);\n  return;\n}\n#endif  /* SQLITE_ALTER_TABLE */\n\n/************** End of alter.c ***********************************************/\n/************** Begin file analyze.c *****************************************/\n/*\n** 2005-07-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code associated with the ANALYZE command.\n**\n** The ANALYZE command gather statistics about the content of tables\n** and indices.  These statistics are made available to the query planner\n** to help it make better decisions about how to perform queries.\n**\n** The following system tables are or have been supported:\n**\n**    CREATE TABLE sqlite_stat1(tbl, idx, stat);\n**    CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);\n**    CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);\n**    CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample);\n**\n** Additional tables might be added in future releases of SQLite.\n** The sqlite_stat2 table is not created or used unless the SQLite version\n** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled\n** with SQLITE_ENABLE_STAT2.  The sqlite_stat2 table is deprecated.\n** The sqlite_stat2 table is superseded by sqlite_stat3, which is only\n** created and used by SQLite versions 3.7.9 and later and with\n** SQLITE_ENABLE_STAT3 defined.  The functionality of sqlite_stat3\n** is a superset of sqlite_stat2.  The sqlite_stat4 is an enhanced\n** version of sqlite_stat3 and is only available when compiled with\n** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later.  It is\n** not possible to enable both STAT3 and STAT4 at the same time.  If they\n** are both enabled, then STAT4 takes precedence.\n**\n** For most applications, sqlite_stat1 provides all the statistics required\n** for the query planner to make good choices.\n**\n** Format of sqlite_stat1:\n**\n** There is normally one row per index, with the index identified by the\n** name in the idx column.  The tbl column is the name of the table to\n** which the index belongs.  In each such row, the stat column will be\n** a string consisting of a list of integers.  The first integer in this\n** list is the number of rows in the index.  (This is the same as the\n** number of rows in the table, except for partial indices.)  The second\n** integer is the average number of rows in the index that have the same\n** value in the first column of the index.  The third integer is the average\n** number of rows in the index that have the same value for the first two\n** columns.  The N-th integer (for N>1) is the average number of rows in \n** the index which have the same value for the first N-1 columns.  For\n** a K-column index, there will be K+1 integers in the stat column.  If\n** the index is unique, then the last integer will be 1.\n**\n** The list of integers in the stat column can optionally be followed\n** by the keyword \"unordered\".  The \"unordered\" keyword, if it is present,\n** must be separated from the last integer by a single space.  If the\n** \"unordered\" keyword is present, then the query planner assumes that\n** the index is unordered and will not use the index for a range query.\n** \n** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat\n** column contains a single integer which is the (estimated) number of\n** rows in the table identified by sqlite_stat1.tbl.\n**\n** Format of sqlite_stat2:\n**\n** The sqlite_stat2 is only created and is only used if SQLite is compiled\n** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between\n** 3.6.18 and 3.7.8.  The \"stat2\" table contains additional information\n** about the distribution of keys within an index.  The index is identified by\n** the \"idx\" column and the \"tbl\" column is the name of the table to which\n** the index belongs.  There are usually 10 rows in the sqlite_stat2\n** table for each index.\n**\n** The sqlite_stat2 entries for an index that have sampleno between 0 and 9\n** inclusive are samples of the left-most key value in the index taken at\n** evenly spaced points along the index.  Let the number of samples be S\n** (10 in the standard build) and let C be the number of rows in the index.\n** Then the sampled rows are given by:\n**\n**     rownumber = (i*C*2 + C)/(S*2)\n**\n** For i between 0 and S-1.  Conceptually, the index space is divided into\n** S uniform buckets and the samples are the middle row from each bucket.\n**\n** The format for sqlite_stat2 is recorded here for legacy reference.  This\n** version of SQLite does not support sqlite_stat2.  It neither reads nor\n** writes the sqlite_stat2 table.  This version of SQLite only supports\n** sqlite_stat3.\n**\n** Format for sqlite_stat3:\n**\n** The sqlite_stat3 format is a subset of sqlite_stat4.  Hence, the\n** sqlite_stat4 format will be described first.  Further information\n** about sqlite_stat3 follows the sqlite_stat4 description.\n**\n** Format for sqlite_stat4:\n**\n** As with sqlite_stat2, the sqlite_stat4 table contains histogram data\n** to aid the query planner in choosing good indices based on the values\n** that indexed columns are compared against in the WHERE clauses of\n** queries.\n**\n** The sqlite_stat4 table contains multiple entries for each index.\n** The idx column names the index and the tbl column is the table of the\n** index.  If the idx and tbl columns are the same, then the sample is\n** of the INTEGER PRIMARY KEY.  The sample column is a blob which is the\n** binary encoding of a key from the index.  The nEq column is a\n** list of integers.  The first integer is the approximate number\n** of entries in the index whose left-most column exactly matches\n** the left-most column of the sample.  The second integer in nEq\n** is the approximate number of entries in the index where the\n** first two columns match the first two columns of the sample.\n** And so forth.  nLt is another list of integers that show the approximate\n** number of entries that are strictly less than the sample.  The first\n** integer in nLt contains the number of entries in the index where the\n** left-most column is less than the left-most column of the sample.\n** The K-th integer in the nLt entry is the number of index entries \n** where the first K columns are less than the first K columns of the\n** sample.  The nDLt column is like nLt except that it contains the \n** number of distinct entries in the index that are less than the\n** sample.\n**\n** There can be an arbitrary number of sqlite_stat4 entries per index.\n** The ANALYZE command will typically generate sqlite_stat4 tables\n** that contain between 10 and 40 samples which are distributed across\n** the key space, though not uniformly, and which include samples with\n** large nEq values.\n**\n** Format for sqlite_stat3 redux:\n**\n** The sqlite_stat3 table is like sqlite_stat4 except that it only\n** looks at the left-most column of the index.  The sqlite_stat3.sample\n** column contains the actual value of the left-most column instead\n** of a blob encoding of the complete index key as is found in\n** sqlite_stat4.sample.  The nEq, nLt, and nDLt entries of sqlite_stat3\n** all contain just a single integer which is the same as the first\n** integer in the equivalent columns in sqlite_stat4.\n*/\n#ifndef SQLITE_OMIT_ANALYZE\n/* #include \"sqliteInt.h\" */\n\n#if defined(SQLITE_ENABLE_STAT4)\n# define IsStat4     1\n# define IsStat3     0\n#elif defined(SQLITE_ENABLE_STAT3)\n# define IsStat4     0\n# define IsStat3     1\n#else\n# define IsStat4     0\n# define IsStat3     0\n# undef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 1\n#endif\n#define IsStat34    (IsStat3+IsStat4)  /* 1 for STAT3 or STAT4. 0 otherwise */\n\n/*\n** This routine generates code that opens the sqlite_statN tables.\n** The sqlite_stat1 table is always relevant.  sqlite_stat2 is now\n** obsolete.  sqlite_stat3 and sqlite_stat4 are only opened when\n** appropriate compile-time options are provided.\n**\n** If the sqlite_statN tables do not previously exist, it is created.\n**\n** Argument zWhere may be a pointer to a buffer containing a table name,\n** or it may be a NULL pointer. If it is not NULL, then all entries in\n** the sqlite_statN tables associated with the named table are deleted.\n** If zWhere==0, then code is generated to delete all stat table entries.\n*/\nstatic void openStatTable(\n  Parse *pParse,          /* Parsing context */\n  int iDb,                /* The database we are looking in */\n  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */\n  const char *zWhere,     /* Delete entries for this table or index */\n  const char *zWhereType  /* Either \"tbl\" or \"idx\" */\n){\n  static const struct {\n    const char *zName;\n    const char *zCols;\n  } aTable[] = {\n    { \"sqlite_stat1\", \"tbl,idx,stat\" },\n#if defined(SQLITE_ENABLE_STAT4)\n    { \"sqlite_stat4\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat3\", 0 },\n#elif defined(SQLITE_ENABLE_STAT3)\n    { \"sqlite_stat3\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat4\", 0 },\n#else\n    { \"sqlite_stat3\", 0 },\n    { \"sqlite_stat4\", 0 },\n#endif\n  };\n  int i;\n  sqlite3 *db = pParse->db;\n  Db *pDb;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int aRoot[ArraySize(aTable)];\n  u8 aCreateTbl[ArraySize(aTable)];\n\n  if( v==0 ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3VdbeDb(v)==db );\n  pDb = &db->aDb[iDb];\n\n  /* Create new statistic tables if they do not exist, or clear them\n  ** if they do already exist.\n  */\n  for(i=0; i<ArraySize(aTable); i++){\n    const char *zTab = aTable[i].zName;\n    Table *pStat;\n    if( (pStat = sqlite3FindTable(db, zTab, pDb->zDbSName))==0 ){\n      if( aTable[i].zCols ){\n        /* The sqlite_statN table does not exist. Create it. Note that a \n        ** side-effect of the CREATE TABLE statement is to leave the rootpage \n        ** of the new table in register pParse->regRoot. This is important \n        ** because the OpenWrite opcode below will be needing it. */\n        sqlite3NestedParse(pParse,\n            \"CREATE TABLE %Q.%s(%s)\", pDb->zDbSName, zTab, aTable[i].zCols\n        );\n        aRoot[i] = pParse->regRoot;\n        aCreateTbl[i] = OPFLAG_P2ISREG;\n      }\n    }else{\n      /* The table already exists. If zWhere is not NULL, delete all entries \n      ** associated with the table zWhere. If zWhere is NULL, delete the\n      ** entire contents of the table. */\n      aRoot[i] = pStat->tnum;\n      aCreateTbl[i] = 0;\n      sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);\n      if( zWhere ){\n        sqlite3NestedParse(pParse,\n           \"DELETE FROM %Q.%s WHERE %s=%Q\",\n           pDb->zDbSName, zTab, zWhereType, zWhere\n        );\n      }else{\n        /* The sqlite_stat[134] table already exists.  Delete all rows. */\n        sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);\n      }\n    }\n  }\n\n  /* Open the sqlite_stat[134] tables for writing. */\n  for(i=0; aTable[i].zCols; i++){\n    assert( i<ArraySize(aTable) );\n    sqlite3VdbeAddOp4Int(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb, 3);\n    sqlite3VdbeChangeP5(v, aCreateTbl[i]);\n    VdbeComment((v, aTable[i].zName));\n  }\n}\n\n/*\n** Recommended number of samples for sqlite_stat4\n*/\n#ifndef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 24\n#endif\n\n/*\n** Three SQL functions - stat_init(), stat_push(), and stat_get() -\n** share an instance of the following structure to hold their state\n** information.\n*/\ntypedef struct Stat4Accum Stat4Accum;\ntypedef struct Stat4Sample Stat4Sample;\nstruct Stat4Sample {\n  tRowcnt *anEq;                  /* sqlite_stat4.nEq */\n  tRowcnt *anDLt;                 /* sqlite_stat4.nDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  tRowcnt *anLt;                  /* sqlite_stat4.nLt */\n  union {\n    i64 iRowid;                     /* Rowid in main table of the key */\n    u8 *aRowid;                     /* Key for WITHOUT ROWID tables */\n  } u;\n  u32 nRowid;                     /* Sizeof aRowid[] */\n  u8 isPSample;                   /* True if a periodic sample */\n  int iCol;                       /* If !isPSample, the reason for inclusion */\n  u32 iHash;                      /* Tiebreaker hash */\n#endif\n};                                                    \nstruct Stat4Accum {\n  tRowcnt nRow;             /* Number of rows in the entire table */\n  tRowcnt nPSample;         /* How often to do a periodic sample */\n  int nCol;                 /* Number of columns in index + pk/rowid */\n  int nKeyCol;              /* Number of index columns w/o the pk/rowid */\n  int mxSample;             /* Maximum number of samples to accumulate */\n  Stat4Sample current;      /* Current row as a Stat4Sample */\n  u32 iPrn;                 /* Pseudo-random number used for sampling */\n  Stat4Sample *aBest;       /* Array of nCol best samples */\n  int iMin;                 /* Index in a[] of entry with minimum score */\n  int nSample;              /* Current number of samples */\n  int nMaxEqZero;           /* Max leading 0 in anEq[] for any a[] entry */\n  int iGet;                 /* Index of current sample accessed by stat_get() */\n  Stat4Sample *a;           /* Array of mxSample Stat4Sample objects */\n  sqlite3 *db;              /* Database connection, for malloc() */\n};\n\n/* Reclaim memory used by a Stat4Sample\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleClear(sqlite3 *db, Stat4Sample *p){\n  assert( db!=0 );\n  if( p->nRowid ){\n    sqlite3DbFree(db, p->u.aRowid);\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the BLOB value of a ROWID\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->u.aRowid = sqlite3DbMallocRawNN(db, n);\n  if( p->u.aRowid ){\n    p->nRowid = n;\n    memcpy(p->u.aRowid, pData, n);\n  }else{\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the INTEGER value of a ROWID.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->nRowid = 0;\n  p->u.iRowid = iRowid;\n}\n#endif\n\n\n/*\n** Copy the contents of object (*pFrom) into (*pTo).\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){\n  pTo->isPSample = pFrom->isPSample;\n  pTo->iCol = pFrom->iCol;\n  pTo->iHash = pFrom->iHash;\n  memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol);\n  if( pFrom->nRowid ){\n    sampleSetRowid(p->db, pTo, pFrom->nRowid, pFrom->u.aRowid);\n  }else{\n    sampleSetRowidInt64(p->db, pTo, pFrom->u.iRowid);\n  }\n}\n#endif\n\n/*\n** Reclaim all memory of a Stat4Accum structure.\n*/\nstatic void stat4Destructor(void *pOld){\n  Stat4Accum *p = (Stat4Accum*)pOld;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int i;\n  for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);\n  for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);\n  sampleClear(p->db, &p->current);\n#endif\n  sqlite3DbFree(p->db, p);\n}\n\n/*\n** Implementation of the stat_init(N,K,C) SQL function. The three parameters\n** are:\n**     N:    The number of columns in the index including the rowid/pk (note 1)\n**     K:    The number of columns in the index excluding the rowid/pk.\n**     C:    The number of rows in the index (note 2)\n**\n** Note 1:  In the special case of the covering index that implements a\n** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the\n** total number of columns in the table.\n**\n** Note 2:  C is only used for STAT3 and STAT4.\n**\n** For indexes on ordinary rowid tables, N==K+1.  But for indexes on\n** WITHOUT ROWID tables, N=K+P where P is the number of columns in the\n** PRIMARY KEY of the table.  The covering index that implements the\n** original WITHOUT ROWID table as N==K as a special case.\n**\n** This routine allocates the Stat4Accum object in heap memory. The return \n** value is a pointer to the Stat4Accum object.  The datatype of the\n** return value is BLOB, but it is really just a pointer to the Stat4Accum\n** object.\n*/\nstatic void statInit(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p;\n  int nCol;                       /* Number of columns in index being sampled */\n  int nKeyCol;                    /* Number of key columns */\n  int nColUp;                     /* nCol rounded up for alignment */\n  int n;                          /* Bytes of space to allocate */\n  sqlite3 *db;                    /* Database connection */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int mxSample = SQLITE_STAT4_SAMPLES;\n#endif\n\n  /* Decode the three function arguments */\n  UNUSED_PARAMETER(argc);\n  nCol = sqlite3_value_int(argv[0]);\n  assert( nCol>0 );\n  nColUp = sizeof(tRowcnt)<8 ? (nCol+1)&~1 : nCol;\n  nKeyCol = sqlite3_value_int(argv[1]);\n  assert( nKeyCol<=nCol );\n  assert( nKeyCol>0 );\n\n  /* Allocate the space required for the Stat4Accum object */\n  n = sizeof(*p) \n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anEq */\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anLt */\n    + sizeof(Stat4Sample)*(nCol+mxSample)     /* Stat4Accum.aBest[], a[] */\n    + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)\n#endif\n  ;\n  db = sqlite3_context_db_handle(context);\n  p = sqlite3DbMallocZero(db, n);\n  if( p==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n\n  p->db = db;\n  p->nRow = 0;\n  p->nCol = nCol;\n  p->nKeyCol = nKeyCol;\n  p->current.anDLt = (tRowcnt*)&p[1];\n  p->current.anEq = &p->current.anDLt[nColUp];\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  {\n    u8 *pSpace;                     /* Allocated space not yet assigned */\n    int i;                          /* Used to iterate through p->aSample[] */\n\n    p->iGet = -1;\n    p->mxSample = mxSample;\n    p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1);\n    p->current.anLt = &p->current.anEq[nColUp];\n    p->iPrn = 0x689e962d*(u32)nCol ^ 0xd0944565*(u32)sqlite3_value_int(argv[2]);\n  \n    /* Set up the Stat4Accum.a[] and aBest[] arrays */\n    p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];\n    p->aBest = &p->a[mxSample];\n    pSpace = (u8*)(&p->a[mxSample+nCol]);\n    for(i=0; i<(mxSample+nCol); i++){\n      p->a[i].anEq = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anDLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n    }\n    assert( (pSpace - (u8*)p)==n );\n  \n    for(i=0; i<nCol; i++){\n      p->aBest[i].iCol = i;\n    }\n  }\n#endif\n\n  /* Return a pointer to the allocated object to the caller.  Note that\n  ** only the pointer (the 2nd parameter) matters.  The size of the object\n  ** (given by the 3rd parameter) is never used and can be any positive\n  ** value. */\n  sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);\n}\nstatic const FuncDef statInitFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statInit,        /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_init\",     /* zName */\n  {0}\n};\n\n#ifdef SQLITE_ENABLE_STAT4\n/*\n** pNew and pOld are both candidate non-periodic samples selected for \n** the same column (pNew->iCol==pOld->iCol). Ignoring this column and \n** considering only any trailing columns and the sample hash value, this\n** function returns true if sample pNew is to be preferred over pOld.\n** In other words, if we assume that the cardinalities of the selected\n** column for pNew and pOld are equal, is pNew to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid. \n*/\nstatic int sampleIsBetterPost(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  int nCol = pAccum->nCol;\n  int i;\n  assert( pNew->iCol==pOld->iCol );\n  for(i=pNew->iCol+1; i<nCol; i++){\n    if( pNew->anEq[i]>pOld->anEq[i] ) return 1;\n    if( pNew->anEq[i]<pOld->anEq[i] ) return 0;\n  }\n  if( pNew->iHash>pOld->iHash ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return true if pNew is to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid. \n*/\nstatic int sampleIsBetter(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  tRowcnt nEqNew = pNew->anEq[pNew->iCol];\n  tRowcnt nEqOld = pOld->anEq[pOld->iCol];\n\n  assert( pOld->isPSample==0 && pNew->isPSample==0 );\n  assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );\n\n  if( (nEqNew>nEqOld) ) return 1;\n#ifdef SQLITE_ENABLE_STAT4\n  if( nEqNew==nEqOld ){\n    if( pNew->iCol<pOld->iCol ) return 1;\n    return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));\n  }\n  return 0;\n#else\n  return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);\n#endif\n}\n\n/*\n** Copy the contents of sample *pNew into the p->a[] array. If necessary,\n** remove the least desirable sample from p->a[] to make room.\n*/\nstatic void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){\n  Stat4Sample *pSample = 0;\n  int i;\n\n  assert( IsStat4 || nEqZero==0 );\n\n#ifdef SQLITE_ENABLE_STAT4\n  /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0\n  ** values in the anEq[] array of any sample in Stat4Accum.a[]. In\n  ** other words, if nMaxEqZero is n, then it is guaranteed that there\n  ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */\n  if( nEqZero>p->nMaxEqZero ){\n    p->nMaxEqZero = nEqZero;\n  }\n  if( pNew->isPSample==0 ){\n    Stat4Sample *pUpgrade = 0;\n    assert( pNew->anEq[pNew->iCol]>0 );\n\n    /* This sample is being added because the prefix that ends in column \n    ** iCol occurs many times in the table. However, if we have already\n    ** added a sample that shares this prefix, there is no need to add\n    ** this one. Instead, upgrade the priority of the highest priority\n    ** existing sample that shares this prefix.  */\n    for(i=p->nSample-1; i>=0; i--){\n      Stat4Sample *pOld = &p->a[i];\n      if( pOld->anEq[pNew->iCol]==0 ){\n        if( pOld->isPSample ) return;\n        assert( pOld->iCol>pNew->iCol );\n        assert( sampleIsBetter(p, pNew, pOld) );\n        if( pUpgrade==0 || sampleIsBetter(p, pOld, pUpgrade) ){\n          pUpgrade = pOld;\n        }\n      }\n    }\n    if( pUpgrade ){\n      pUpgrade->iCol = pNew->iCol;\n      pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];\n      goto find_new_min;\n    }\n  }\n#endif\n\n  /* If necessary, remove sample iMin to make room for the new sample. */\n  if( p->nSample>=p->mxSample ){\n    Stat4Sample *pMin = &p->a[p->iMin];\n    tRowcnt *anEq = pMin->anEq;\n    tRowcnt *anLt = pMin->anLt;\n    tRowcnt *anDLt = pMin->anDLt;\n    sampleClear(p->db, pMin);\n    memmove(pMin, &pMin[1], sizeof(p->a[0])*(p->nSample-p->iMin-1));\n    pSample = &p->a[p->nSample-1];\n    pSample->nRowid = 0;\n    pSample->anEq = anEq;\n    pSample->anDLt = anDLt;\n    pSample->anLt = anLt;\n    p->nSample = p->mxSample-1;\n  }\n\n  /* The \"rows less-than\" for the rowid column must be greater than that\n  ** for the last sample in the p->a[] array. Otherwise, the samples would\n  ** be out of order. */\n#ifdef SQLITE_ENABLE_STAT4\n  assert( p->nSample==0 \n       || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );\n#endif\n\n  /* Insert the new sample */\n  pSample = &p->a[p->nSample];\n  sampleCopy(p, pSample, pNew);\n  p->nSample++;\n\n  /* Zero the first nEqZero entries in the anEq[] array. */\n  memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);\n\n#ifdef SQLITE_ENABLE_STAT4\n find_new_min:\n#endif\n  if( p->nSample>=p->mxSample ){\n    int iMin = -1;\n    for(i=0; i<p->mxSample; i++){\n      if( p->a[i].isPSample ) continue;\n      if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){\n        iMin = i;\n      }\n    }\n    assert( iMin>=0 );\n    p->iMin = iMin;\n  }\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Field iChng of the index being scanned has changed. So at this point\n** p->current contains a sample that reflects the previous row of the\n** index. The value of anEq[iChng] and subsequent anEq[] elements are\n** correct at this point.\n*/\nstatic void samplePushPrevious(Stat4Accum *p, int iChng){\n#ifdef SQLITE_ENABLE_STAT4\n  int i;\n\n  /* Check if any samples from the aBest[] array should be pushed\n  ** into IndexSample.a[] at this point.  */\n  for(i=(p->nCol-2); i>=iChng; i--){\n    Stat4Sample *pBest = &p->aBest[i];\n    pBest->anEq[i] = p->current.anEq[i];\n    if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){\n      sampleInsert(p, pBest, i);\n    }\n  }\n\n  /* Check that no sample contains an anEq[] entry with an index of\n  ** p->nMaxEqZero or greater set to zero. */\n  for(i=p->nSample-1; i>=0; i--){\n    int j;\n    for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );\n  }\n\n  /* Update the anEq[] fields of any samples already collected. */\n  if( iChng<p->nMaxEqZero ){\n    for(i=p->nSample-1; i>=0; i--){\n      int j;\n      for(j=iChng; j<p->nCol; j++){\n        if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];\n      }\n    }\n    p->nMaxEqZero = iChng;\n  }\n#endif\n\n#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)\n  if( iChng==0 ){\n    tRowcnt nLt = p->current.anLt[0];\n    tRowcnt nEq = p->current.anEq[0];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+nEq)/p->nPSample ){\n      p->current.isPSample = 1;\n      sampleInsert(p, &p->current, 0);\n      p->current.isPSample = 0;\n    }else \n\n    /* Or if it is a non-periodic sample. Add it in this case too. */\n    if( p->nSample<p->mxSample \n     || sampleIsBetter(p, &p->current, &p->a[p->iMin]) \n    ){\n      sampleInsert(p, &p->current, 0);\n    }\n  }\n#endif\n\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  UNUSED_PARAMETER( p );\n  UNUSED_PARAMETER( iChng );\n#endif\n}\n\n/*\n** Implementation of the stat_push SQL function:  stat_push(P,C,R)\n** Arguments:\n**\n**    P     Pointer to the Stat4Accum object created by stat_init()\n**    C     Index of left-most column to differ from previous row\n**    R     Rowid for the current row.  Might be a key record for\n**          WITHOUT ROWID tables.\n**\n** This SQL function always returns NULL.  It's purpose it to accumulate\n** statistical data and/or samples in the Stat4Accum object about the\n** index being analyzed.  The stat_get() SQL function will later be used to\n** extract relevant information for constructing the sqlite_statN tables.\n**\n** The R parameter is only used for STAT3 and STAT4\n*/\nstatic void statPush(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n\n  /* The three function arguments */\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n  int iChng = sqlite3_value_int(argv[1]);\n\n  UNUSED_PARAMETER( argc );\n  UNUSED_PARAMETER( context );\n  assert( p->nCol>0 );\n  assert( iChng<p->nCol );\n\n  if( p->nRow==0 ){\n    /* This is the first call to this function. Do initialization. */\n    for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;\n  }else{\n    /* Second and subsequent calls get processed here */\n    samplePushPrevious(p, iChng);\n\n    /* Update anDLt[], anLt[] and anEq[] to reflect the values that apply\n    ** to the current row of the index. */\n    for(i=0; i<iChng; i++){\n      p->current.anEq[i]++;\n    }\n    for(i=iChng; i<p->nCol; i++){\n      p->current.anDLt[i]++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n      p->current.anLt[i] += p->current.anEq[i];\n#endif\n      p->current.anEq[i] = 1;\n    }\n  }\n  p->nRow++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){\n    sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));\n  }else{\n    sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),\n                                       sqlite3_value_blob(argv[2]));\n  }\n  p->current.iHash = p->iPrn = p->iPrn*1103515245 + 12345;\n#endif\n\n#ifdef SQLITE_ENABLE_STAT4\n  {\n    tRowcnt nLt = p->current.anLt[p->nCol-1];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+1)/p->nPSample ){\n      p->current.isPSample = 1;\n      p->current.iCol = 0;\n      sampleInsert(p, &p->current, p->nCol-1);\n      p->current.isPSample = 0;\n    }\n\n    /* Update the aBest[] array. */\n    for(i=0; i<(p->nCol-1); i++){\n      p->current.iCol = i;\n      if( i>=iChng || sampleIsBetterPost(p, &p->current, &p->aBest[i]) ){\n        sampleCopy(p, &p->aBest[i], &p->current);\n      }\n    }\n  }\n#endif\n}\nstatic const FuncDef statPushFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statPush,        /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_push\",     /* zName */\n  {0}\n};\n\n#define STAT_GET_STAT1 0          /* \"stat\" column of stat1 table */\n#define STAT_GET_ROWID 1          /* \"rowid\" column of stat[34] entry */\n#define STAT_GET_NEQ   2          /* \"neq\" column of stat[34] entry */\n#define STAT_GET_NLT   3          /* \"nlt\" column of stat[34] entry */\n#define STAT_GET_NDLT  4          /* \"ndlt\" column of stat[34] entry */\n\n/*\n** Implementation of the stat_get(P,J) SQL function.  This routine is\n** used to query statistical information that has been gathered into\n** the Stat4Accum object by prior calls to stat_push().  The P parameter\n** has type BLOB but it is really just a pointer to the Stat4Accum object.\n** The content to returned is determined by the parameter J\n** which is one of the STAT_GET_xxxx values defined above.\n**\n** The stat_get(P,J) function is not available to generic SQL.  It is\n** inserted as part of a manually constructed bytecode program.  (See\n** the callStatGet() routine below.)  It is guaranteed that the P\n** parameter will always be a poiner to a Stat4Accum object, never a\n** NULL.\n**\n** If neither STAT3 nor STAT4 are enabled, then J is always\n** STAT_GET_STAT1 and is hence omitted and this routine becomes\n** a one-parameter function, stat_get(P), that always returns the\n** stat1 table entry information.\n*/\nstatic void statGet(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* STAT3 and STAT4 have a parameter on this routine. */\n  int eCall = sqlite3_value_int(argv[1]);\n  assert( argc==2 );\n  assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ \n       || eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT\n       || eCall==STAT_GET_NDLT \n  );\n  if( eCall==STAT_GET_STAT1 )\n#else\n  assert( argc==1 );\n#endif\n  {\n    /* Return the value to store in the \"stat\" column of the sqlite_stat1\n    ** table for this index.\n    **\n    ** The value is a string composed of a list of integers describing \n    ** the index. The first integer in the list is the total number of \n    ** entries in the index. There is one additional integer in the list \n    ** for each indexed column. This additional integer is an estimate of\n    ** the number of rows matched by a stabbing query on the index using\n    ** a key with the corresponding number of fields. In other words,\n    ** if the index is on columns (a,b) and the sqlite_stat1 value is \n    ** \"100 10 2\", then SQLite estimates that:\n    **\n    **   * the index contains 100 rows,\n    **   * \"WHERE a=?\" matches 10 rows, and\n    **   * \"WHERE a=? AND b=?\" matches 2 rows.\n    **\n    ** If D is the count of distinct values and K is the total number of \n    ** rows, then each estimate is computed as:\n    **\n    **        I = (K+D-1)/D\n    */\n    char *z;\n    int i;\n\n    char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 );\n    if( zRet==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n\n    sqlite3_snprintf(24, zRet, \"%llu\", (u64)p->nRow);\n    z = zRet + sqlite3Strlen30(zRet);\n    for(i=0; i<p->nKeyCol; i++){\n      u64 nDistinct = p->current.anDLt[i] + 1;\n      u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;\n      sqlite3_snprintf(24, z, \" %llu\", iVal);\n      z += sqlite3Strlen30(z);\n      assert( p->current.anEq[i] );\n    }\n    assert( z[0]=='\\0' && z>zRet );\n\n    sqlite3_result_text(context, zRet, -1, sqlite3_free);\n  }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( eCall==STAT_GET_ROWID ){\n    if( p->iGet<0 ){\n      samplePushPrevious(p, 0);\n      p->iGet = 0;\n    }\n    if( p->iGet<p->nSample ){\n      Stat4Sample *pS = p->a + p->iGet;\n      if( pS->nRowid==0 ){\n        sqlite3_result_int64(context, pS->u.iRowid);\n      }else{\n        sqlite3_result_blob(context, pS->u.aRowid, pS->nRowid,\n                            SQLITE_TRANSIENT);\n      }\n    }\n  }else{\n    tRowcnt *aCnt = 0;\n\n    assert( p->iGet<p->nSample );\n    switch( eCall ){\n      case STAT_GET_NEQ:  aCnt = p->a[p->iGet].anEq; break;\n      case STAT_GET_NLT:  aCnt = p->a[p->iGet].anLt; break;\n      default: {\n        aCnt = p->a[p->iGet].anDLt; \n        p->iGet++;\n        break;\n      }\n    }\n\n    if( IsStat3 ){\n      sqlite3_result_int64(context, (i64)aCnt[0]);\n    }else{\n      char *zRet = sqlite3MallocZero(p->nCol * 25);\n      if( zRet==0 ){\n        sqlite3_result_error_nomem(context);\n      }else{\n        int i;\n        char *z = zRet;\n        for(i=0; i<p->nCol; i++){\n          sqlite3_snprintf(24, z, \"%llu \", (u64)aCnt[i]);\n          z += sqlite3Strlen30(z);\n        }\n        assert( z[0]=='\\0' && z>zRet );\n        z[-1] = '\\0';\n        sqlite3_result_text(context, zRet, -1, sqlite3_free);\n      }\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( argc );\n#endif\n}\nstatic const FuncDef statGetFuncdef = {\n  1+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statGet,         /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_get\",      /* zName */\n  {0}\n};\n\nstatic void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){\n  assert( regOut!=regStat4 && regOut!=regStat4+1 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);\n#elif SQLITE_DEBUG\n  assert( iParam==STAT_GET_STAT1 );\n#else\n  UNUSED_PARAMETER( iParam );\n#endif\n  sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,\n                    (char*)&statGetFuncdef, P4_FUNCDEF);\n  sqlite3VdbeChangeP5(v, 1 + IsStat34);\n}\n\n/*\n** Generate code to do an analysis of all indices associated with\n** a single table.\n*/\nstatic void analyzeOneTable(\n  Parse *pParse,   /* Parser context */\n  Table *pTab,     /* Table whose indices are to be analyzed */\n  Index *pOnlyIdx, /* If not NULL, only analyze this one index */\n  int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */\n  int iMem,        /* Available memory locations begin here */\n  int iTab         /* Next available cursor */\n){\n  sqlite3 *db = pParse->db;    /* Database handle */\n  Index *pIdx;                 /* An index to being analyzed */\n  int iIdxCur;                 /* Cursor open on index being analyzed */\n  int iTabCur;                 /* Table cursor */\n  Vdbe *v;                     /* The virtual machine being built up */\n  int i;                       /* Loop counter */\n  int jZeroRows = -1;          /* Jump from here if number of rows is zero */\n  int iDb;                     /* Index of database containing pTab */\n  u8 needTableCnt = 1;         /* True to count the table */\n  int regNewRowid = iMem++;    /* Rowid for the inserted record */\n  int regStat4 = iMem++;       /* Register to hold Stat4Accum object */\n  int regChng = iMem++;        /* Index of changed index field */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int regRowid = iMem++;       /* Rowid argument passed to stat_push() */\n#endif\n  int regTemp = iMem++;        /* Temporary use register */\n  int regTabname = iMem++;     /* Register containing table name */\n  int regIdxname = iMem++;     /* Register containing index name */\n  int regStat1 = iMem++;       /* Value for the stat column of sqlite_stat1 */\n  int regPrev = iMem;          /* MUST BE LAST (see below) */\n\n  pParse->nMem = MAX(pParse->nMem, iMem);\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 || NEVER(pTab==0) ){\n    return;\n  }\n  if( pTab->tnum==0 ){\n    /* Do not gather statistics on views or virtual tables */\n    return;\n  }\n  if( sqlite3_strlike(\"sqlite_%\", pTab->zName, 0)==0 ){\n    /* Do not gather statistics on system tables */\n    return;\n  }\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n  /* Establish a read-lock on the table at the shared-cache level. \n  ** Open a read-only cursor on the table. Also allocate a cursor number\n  ** to use for scanning indexes (iIdxCur). No index cursor is opened at\n  ** this time though.  */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n  iTabCur = iTab++;\n  iIdxCur = iTab++;\n  pParse->nTab = MAX(pParse->nTab, iTab);\n  sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n  sqlite3VdbeLoadString(v, regTabname, pTab->zName);\n\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int nCol;                     /* Number of columns in pIdx. \"N\" */\n    int addrRewind;               /* Address of \"OP_Rewind iIdxCur\" */\n    int addrNextRow;              /* Address of \"next_row:\" */\n    const char *zIdxName;         /* Name of the index */\n    int nColTest;                 /* Number of columns to test for changes */\n\n    if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;\n    if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;\n    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){\n      nCol = pIdx->nKeyCol;\n      zIdxName = pTab->zName;\n      nColTest = nCol - 1;\n    }else{\n      nCol = pIdx->nColumn;\n      zIdxName = pIdx->zName;\n      nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;\n    }\n\n    /* Populate the register containing the index name. */\n    sqlite3VdbeLoadString(v, regIdxname, zIdxName);\n    VdbeComment((v, \"Analysis for %s.%s\", pTab->zName, zIdxName));\n\n    /*\n    ** Pseudo-code for loop that calls stat_push():\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto chng_addr_0;\n    **\n    **  next_row:\n    **   regChng = 0\n    **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n    **   regChng = 1\n    **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n    **   ...\n    **   regChng = N\n    **   goto chng_addr_N\n    **\n    **  chng_addr_0:\n    **   regPrev(0) = idx(0)\n    **  chng_addr_1:\n    **   regPrev(1) = idx(1)\n    **  ...\n    **\n    **  endDistinctTest:\n    **   regRowid = idx(rowid)\n    **   stat_push(P, regChng, regRowid)\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    **\n    **  end_of_scan:\n    */\n\n    /* Make sure there are enough memory cells allocated to accommodate \n    ** the regPrev array and a trailing rowid (the rowid slot is required\n    ** when building a record to insert into the sample column of \n    ** the sqlite_stat4 table.  */\n    pParse->nMem = MAX(pParse->nMem, regPrev+nColTest);\n\n    /* Open a read-only cursor on the index being analyzed. */\n    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n    VdbeComment((v, \"%s\", pIdx->zName));\n\n    /* Invoke the stat_init() function. The arguments are:\n    ** \n    **    (1) the number of columns in the index including the rowid\n    **        (or for a WITHOUT ROWID table, the number of PK columns),\n    **    (2) the number of columns in the key without the rowid/pk\n    **    (3) the number of rows in the index,\n    **\n    **\n    ** The third argument is only used for STAT3 and STAT4\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);\n#endif\n    sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);\n    sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,\n                     (char*)&statInitFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n\n    /* Implementation of the following:\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto next_push_0;\n    **\n    */\n    addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng);\n    addrNextRow = sqlite3VdbeCurrentAddr(v);\n\n    if( nColTest>0 ){\n      int endDistinctTest = sqlite3VdbeMakeLabel(v);\n      int *aGotoChng;               /* Array of jump instruction addresses */\n      aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);\n      if( aGotoChng==0 ) continue;\n\n      /*\n      **  next_row:\n      **   regChng = 0\n      **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n      **   regChng = 1\n      **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n      **   ...\n      **   regChng = N\n      **   goto endDistinctTest\n      */\n      sqlite3VdbeAddOp0(v, OP_Goto);\n      addrNextRow = sqlite3VdbeCurrentAddr(v);\n      if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){\n        /* For a single-column UNIQUE index, once we have found a non-NULL\n        ** row, we know that all the rest will be distinct, so skip \n        ** subsequent distinctness tests. */\n        sqlite3VdbeAddOp2(v, OP_NotNull, regPrev, endDistinctTest);\n        VdbeCoverage(v);\n      }\n      for(i=0; i<nColTest; i++){\n        char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);\n        sqlite3VdbeAddOp2(v, OP_Integer, i, regChng);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regTemp);\n        aGotoChng[i] = \n        sqlite3VdbeAddOp4(v, OP_Ne, regTemp, 0, regPrev+i, pColl, P4_COLLSEQ);\n        sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp2(v, OP_Integer, nColTest, regChng);\n      sqlite3VdbeGoto(v, endDistinctTest);\n  \n  \n      /*\n      **  chng_addr_0:\n      **   regPrev(0) = idx(0)\n      **  chng_addr_1:\n      **   regPrev(1) = idx(1)\n      **  ...\n      */\n      sqlite3VdbeJumpHere(v, addrNextRow-1);\n      for(i=0; i<nColTest; i++){\n        sqlite3VdbeJumpHere(v, aGotoChng[i]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regPrev+i);\n      }\n      sqlite3VdbeResolveLabel(v, endDistinctTest);\n      sqlite3DbFree(db, aGotoChng);\n    }\n  \n    /*\n    **  chng_addr_N:\n    **   regRowid = idx(rowid)            // STAT34 only\n    **   stat_push(P, regChng, regRowid)  // 3rd parameter STAT34 only\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    assert( regRowid==(regStat4+2) );\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);\n    }else{\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      int j, k, regKey;\n      regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        assert( k>=0 && k<pIdx->nColumn );\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);\n        VdbeComment((v, \"%s\", pTab->aCol[pPk->aiColumn[j]].zName));\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);\n      sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);\n    }\n#endif\n    assert( regChng==(regStat4+1) );\n    sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,\n                     (char*)&statPushFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n    sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);\n\n    /* Add the entry to the stat1 table. */\n    callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n\n    /* Add the entries to the stat3 or stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    {\n      int regEq = regStat1;\n      int regLt = regStat1+1;\n      int regDLt = regStat1+2;\n      int regSample = regStat1+3;\n      int regCol = regStat1+4;\n      int regSampleRowid = regCol + nCol;\n      int addrNext;\n      int addrIsNull;\n      u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n\n      pParse->nMem = MAX(pParse->nMem, regCol+nCol);\n\n      addrNext = sqlite3VdbeCurrentAddr(v);\n      callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);\n      addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);\n      VdbeCoverage(v);\n      callStatGet(v, regStat4, STAT_GET_NEQ, regEq);\n      callStatGet(v, regStat4, STAT_GET_NLT, regLt);\n      callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);\n      sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);\n      /* We know that the regSampleRowid row exists because it was read by\n      ** the previous loop.  Thus the not-found jump of seekOp will never\n      ** be taken */\n      VdbeCoverageNeverTaken(v);\n#ifdef SQLITE_ENABLE_STAT3\n      sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);\n#else\n      for(i=0; i<nCol; i++){\n        sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);\n#endif\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);\n      sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */\n      sqlite3VdbeJumpHere(v, addrIsNull);\n    }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n    /* End of analysis */\n    sqlite3VdbeJumpHere(v, addrRewind);\n  }\n\n\n  /* Create a single sqlite_stat1 entry containing NULL as the index\n  ** name and the row count as the content.\n  */\n  if( pOnlyIdx==0 && needTableCnt ){\n    VdbeComment((v, \"%s\", pTab->zName));\n    sqlite3VdbeAddOp2(v, OP_Count, iTabCur, regStat1);\n    jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeJumpHere(v, jZeroRows);\n  }\n}\n\n\n/*\n** Generate code that will cause the most recent index analysis to\n** be loaded into internal hash tables where is can be used.\n*/\nstatic void loadAnalysis(Parse *pParse, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb);\n  }\n}\n\n/*\n** Generate code that will do an analysis of an entire database\n*/\nstatic void analyzeDatabase(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Schema *pSchema = db->aDb[iDb].pSchema;    /* Schema of database iDb */\n  HashElem *k;\n  int iStatCur;\n  int iMem;\n  int iTab;\n\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  openStatTable(pParse, iDb, iStatCur, 0, 0);\n  iMem = pParse->nMem+1;\n  iTab = pParse->nTab;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n    Table *pTab = (Table*)sqliteHashData(k);\n    analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab);\n  }\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code that will do an analysis of a single table in\n** a database.  If pOnlyIdx is not NULL then it is a single index\n** in pTab that should be analyzed.\n*/\nstatic void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){\n  int iDb;\n  int iStatCur;\n\n  assert( pTab!=0 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  if( pOnlyIdx ){\n    openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, \"idx\");\n  }else{\n    openStatTable(pParse, iDb, iStatCur, pTab->zName, \"tbl\");\n  }\n  analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur,pParse->nMem+1,pParse->nTab);\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code for the ANALYZE command.  The parser calls this routine\n** when it recognizes an ANALYZE command.\n**\n**        ANALYZE                            -- 1\n**        ANALYZE  <database>                -- 2\n**        ANALYZE  ?<database>.?<tablename>  -- 3\n**\n** Form 1 causes all indices in all attached databases to be analyzed.\n** Form 2 analyzes all indices the single database named.\n** Form 3 analyzes all indices associated with the named table.\n*/\nSQLITE_PRIVATE void sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int i;\n  char *z, *zDb;\n  Table *pTab;\n  Index *pIdx;\n  Token *pTableName;\n  Vdbe *v;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  assert( pName2!=0 || pName1==0 );\n  if( pName1==0 ){\n    /* Form 1:  Analyze everything */\n    for(i=0; i<db->nDb; i++){\n      if( i==1 ) continue;  /* Do not analyze the TEMP database */\n      analyzeDatabase(pParse, i);\n    }\n  }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){\n    /* Analyze the schema named as the argument */\n    analyzeDatabase(pParse, iDb);\n  }else{\n    /* Form 3: Analyze the table or index named as an argument */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);\n    if( iDb>=0 ){\n      zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;\n      z = sqlite3NameFromToken(db, pTableName);\n      if( z ){\n        if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){\n          analyzeTable(pParse, pIdx->pTable, pIdx);\n        }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){\n          analyzeTable(pParse, pTab, 0);\n        }\n        sqlite3DbFree(db, z);\n      }\n    }\n  }\n  if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3VdbeAddOp0(v, OP_Expire);\n  }\n}\n\n/*\n** Used to pass information from the analyzer reader through to the\n** callback routine.\n*/\ntypedef struct analysisInfo analysisInfo;\nstruct analysisInfo {\n  sqlite3 *db;\n  const char *zDatabase;\n};\n\n/*\n** The first argument points to a nul-terminated string containing a\n** list of space separated integers. Read the first nOut of these into\n** the array aOut[].\n*/\nstatic void decodeIntArray(\n  char *zIntArray,       /* String containing int array to decode */\n  int nOut,              /* Number of slots in aOut[] */\n  tRowcnt *aOut,         /* Store integers here */\n  LogEst *aLog,          /* Or, if aOut==0, here */\n  Index *pIndex          /* Handle extra flags for this index, if not NULL */\n){\n  char *z = zIntArray;\n  int c;\n  int i;\n  tRowcnt v;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( z==0 ) z = \"\";\n#else\n  assert( z!=0 );\n#endif\n  for(i=0; *z && i<nOut; i++){\n    v = 0;\n    while( (c=z[0])>='0' && c<='9' ){\n      v = v*10 + c - '0';\n      z++;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    if( aOut ) aOut[i] = v;\n    if( aLog ) aLog[i] = sqlite3LogEst(v);\n#else\n    assert( aOut==0 );\n    UNUSED_PARAMETER(aOut);\n    assert( aLog!=0 );\n    aLog[i] = sqlite3LogEst(v);\n#endif\n    if( *z==' ' ) z++;\n  }\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  assert( pIndex!=0 ); {\n#else\n  if( pIndex ){\n#endif\n    pIndex->bUnordered = 0;\n    pIndex->noSkipScan = 0;\n    while( z[0] ){\n      if( sqlite3_strglob(\"unordered*\", z)==0 ){\n        pIndex->bUnordered = 1;\n      }else if( sqlite3_strglob(\"sz=[0-9]*\", z)==0 ){\n        pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));\n      }else if( sqlite3_strglob(\"noskipscan*\", z)==0 ){\n        pIndex->noSkipScan = 1;\n      }\n#ifdef SQLITE_ENABLE_COSTMULT\n      else if( sqlite3_strglob(\"costmult=[0-9]*\",z)==0 ){\n        pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));\n      }\n#endif\n      while( z[0]!=0 && z[0]!=' ' ) z++;\n      while( z[0]==' ' ) z++;\n    }\n  }\n}\n\n/*\n** This callback is invoked once for each index when reading the\n** sqlite_stat1 table.  \n**\n**     argv[0] = name of the table\n**     argv[1] = name of the index (might be NULL)\n**     argv[2] = results of analysis - on integer for each column\n**\n** Entries for which argv[1]==NULL simply record the number of rows in\n** the table.\n*/\nstatic int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){\n  analysisInfo *pInfo = (analysisInfo*)pData;\n  Index *pIndex;\n  Table *pTable;\n  const char *z;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n\n  if( argv==0 || argv[0]==0 || argv[2]==0 ){\n    return 0;\n  }\n  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);\n  if( pTable==0 ){\n    return 0;\n  }\n  if( argv[1]==0 ){\n    pIndex = 0;\n  }else if( sqlite3_stricmp(argv[0],argv[1])==0 ){\n    pIndex = sqlite3PrimaryKeyIndex(pTable);\n  }else{\n    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);\n  }\n  z = argv[2];\n\n  if( pIndex ){\n    tRowcnt *aiRowEst = 0;\n    int nCol = pIndex->nKeyCol+1;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    /* Index.aiRowEst may already be set here if there are duplicate \n    ** sqlite_stat1 entries for this index. In that case just clobber\n    ** the old data with the new instead of allocating a new array.  */\n    if( pIndex->aiRowEst==0 ){\n      pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);\n      if( pIndex->aiRowEst==0 ) sqlite3OomFault(pInfo->db);\n    }\n    aiRowEst = pIndex->aiRowEst;\n#endif\n    pIndex->bUnordered = 0;\n    decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);\n    pIndex->hasStat1 = 1;\n    if( pIndex->pPartIdxWhere==0 ){\n      pTable->nRowLogEst = pIndex->aiRowLogEst[0];\n      pTable->tabFlags |= TF_HasStat1;\n    }\n  }else{\n    Index fakeIdx;\n    fakeIdx.szIdxRow = pTable->szTabRow;\n#ifdef SQLITE_ENABLE_COSTMULT\n    fakeIdx.pTable = pTable;\n#endif\n    decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);\n    pTable->szTabRow = fakeIdx.szIdxRow;\n    pTable->tabFlags |= TF_HasStat1;\n  }\n\n  return 0;\n}\n\n/*\n** If the Index.aSample variable is not NULL, delete the aSample[] array\n** and its contents.\n*/\nSQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pIdx->aSample ){\n    int j;\n    for(j=0; j<pIdx->nSample; j++){\n      IndexSample *p = &pIdx->aSample[j];\n      sqlite3DbFree(db, p->p);\n    }\n    sqlite3DbFree(db, pIdx->aSample);\n  }\n  if( db && db->pnBytesFreed==0 ){\n    pIdx->nSample = 0;\n    pIdx->aSample = 0;\n  }\n#else\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pIdx);\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Populate the pIdx->aAvgEq[] array based on the samples currently\n** stored in pIdx->aSample[]. \n*/\nstatic void initAvgEq(Index *pIdx){\n  if( pIdx ){\n    IndexSample *aSample = pIdx->aSample;\n    IndexSample *pFinal = &aSample[pIdx->nSample-1];\n    int iCol;\n    int nCol = 1;\n    if( pIdx->nSampleCol>1 ){\n      /* If this is stat4 data, then calculate aAvgEq[] values for all\n      ** sample columns except the last. The last is always set to 1, as\n      ** once the trailing PK fields are considered all index keys are\n      ** unique.  */\n      nCol = pIdx->nSampleCol-1;\n      pIdx->aAvgEq[nCol] = 1;\n    }\n    for(iCol=0; iCol<nCol; iCol++){\n      int nSample = pIdx->nSample;\n      int i;                    /* Used to iterate through samples */\n      tRowcnt sumEq = 0;        /* Sum of the nEq values */\n      tRowcnt avgEq = 0;\n      tRowcnt nRow;             /* Number of rows in index */\n      i64 nSum100 = 0;          /* Number of terms contributing to sumEq */\n      i64 nDist100;             /* Number of distinct values in index */\n\n      if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){\n        nRow = pFinal->anLt[iCol];\n        nDist100 = (i64)100 * pFinal->anDLt[iCol];\n        nSample--;\n      }else{\n        nRow = pIdx->aiRowEst[0];\n        nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];\n      }\n      pIdx->nRowEst0 = nRow;\n\n      /* Set nSum to the number of distinct (iCol+1) field prefixes that\n      ** occur in the stat4 table for this index. Set sumEq to the sum of \n      ** the nEq values for column iCol for the same set (adding the value \n      ** only once where there exist duplicate prefixes).  */\n      for(i=0; i<nSample; i++){\n        if( i==(pIdx->nSample-1)\n         || aSample[i].anDLt[iCol]!=aSample[i+1].anDLt[iCol] \n        ){\n          sumEq += aSample[i].anEq[iCol];\n          nSum100 += 100;\n        }\n      }\n\n      if( nDist100>nSum100 && sumEq<nRow ){\n        avgEq = ((i64)100 * (nRow - sumEq))/(nDist100 - nSum100);\n      }\n      if( avgEq==0 ) avgEq = 1;\n      pIdx->aAvgEq[iCol] = avgEq;\n    }\n  }\n}\n\n/*\n** Look up an index by name.  Or, if the name of a WITHOUT ROWID table\n** is supplied instead, find the PRIMARY KEY index for that table.\n*/\nstatic Index *findIndexOrPrimaryKey(\n  sqlite3 *db,\n  const char *zName,\n  const char *zDb\n){\n  Index *pIdx = sqlite3FindIndex(db, zName, zDb);\n  if( pIdx==0 ){\n    Table *pTab = sqlite3FindTable(db, zName, zDb);\n    if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);\n  }\n  return pIdx;\n}\n\n/*\n** Load the content from either the sqlite_stat4 or sqlite_stat3 table \n** into the relevant Index.aSample[] arrays.\n**\n** Arguments zSql1 and zSql2 must point to SQL statements that return\n** data equivalent to the following (statements are different for stat3,\n** see the caller of this function for details):\n**\n**    zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\n**    zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\n**\n** where %Q is replaced with the database name before the SQL is executed.\n*/\nstatic int loadStatTbl(\n  sqlite3 *db,                  /* Database handle */\n  int bStat3,                   /* Assume single column records only */\n  const char *zSql1,            /* SQL statement 1 (see above) */\n  const char *zSql2,            /* SQL statement 2 (see above) */\n  const char *zDb               /* Database name (e.g. \"main\") */\n){\n  int rc;                       /* Result codes from subroutines */\n  sqlite3_stmt *pStmt = 0;      /* An SQL statement being run */\n  char *zSql;                   /* Text of the SQL statement */\n  Index *pPrevIdx = 0;          /* Previous index in the loop */\n  IndexSample *pSample;         /* A slot in pIdx->aSample[] */\n\n  assert( db->lookaside.bDisable );\n  zSql = sqlite3MPrintf(db, zSql1, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int nIdxCol = 1;              /* Number of columns in stat4 records */\n\n    char *zIndex;   /* Index name */\n    Index *pIdx;    /* Pointer to the index object */\n    int nSample;    /* Number of samples */\n    int nByte;      /* Bytes of space required */\n    int i;          /* Bytes of space required */\n    tRowcnt *pSpace;\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    nSample = sqlite3_column_int(pStmt, 1);\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    assert( pIdx==0 || bStat3 || pIdx->nSample==0 );\n    /* Index.nSample is non-zero at this point if data has already been\n    ** loaded from the stat4 table. In this case ignore stat3 data.  */\n    if( pIdx==0 || pIdx->nSample ) continue;\n    if( bStat3==0 ){\n      assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );\n      if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){\n        nIdxCol = pIdx->nKeyCol;\n      }else{\n        nIdxCol = pIdx->nColumn;\n      }\n    }\n    pIdx->nSampleCol = nIdxCol;\n    nByte = sizeof(IndexSample) * nSample;\n    nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;\n    nByte += nIdxCol * sizeof(tRowcnt);     /* Space for Index.aAvgEq[] */\n\n    pIdx->aSample = sqlite3DbMallocZero(db, nByte);\n    if( pIdx->aSample==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pSpace = (tRowcnt*)&pIdx->aSample[nSample];\n    pIdx->aAvgEq = pSpace; pSpace += nIdxCol;\n    for(i=0; i<nSample; i++){\n      pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;\n    }\n    assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc ) return rc;\n\n  zSql = sqlite3MPrintf(db, zSql2, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    char *zIndex;                 /* Index name */\n    Index *pIdx;                  /* Pointer to the index object */\n    int nCol = 1;                 /* Number of columns in index */\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    if( pIdx==0 ) continue;\n    /* This next condition is true if data has already been loaded from \n    ** the sqlite_stat4 table. In this case ignore stat3 data.  */\n    nCol = pIdx->nSampleCol;\n    if( bStat3 && nCol>1 ) continue;\n    if( pIdx!=pPrevIdx ){\n      initAvgEq(pPrevIdx);\n      pPrevIdx = pIdx;\n    }\n    pSample = &pIdx->aSample[pIdx->nSample];\n    decodeIntArray((char*)sqlite3_column_text(pStmt,1),nCol,pSample->anEq,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,2),nCol,pSample->anLt,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,3),nCol,pSample->anDLt,0,0);\n\n    /* Take a copy of the sample. Add two 0x00 bytes the end of the buffer.\n    ** This is in case the sample record is corrupted. In that case, the\n    ** sqlite3VdbeRecordCompare() may read up to two varints past the\n    ** end of the allocated buffer before it realizes it is dealing with\n    ** a corrupt record. Adding the two 0x00 bytes prevents this from causing\n    ** a buffer overread.  */\n    pSample->n = sqlite3_column_bytes(pStmt, 4);\n    pSample->p = sqlite3DbMallocZero(db, pSample->n + 2);\n    if( pSample->p==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pSample->n ){\n      memcpy(pSample->p, sqlite3_column_blob(pStmt, 4), pSample->n);\n    }\n    pIdx->nSample++;\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);\n  return rc;\n}\n\n/*\n** Load content from the sqlite_stat4 and sqlite_stat3 tables into \n** the Index.aSample[] arrays of all indices.\n*/\nstatic int loadStat4(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_OK;             /* Result codes from subroutines */\n\n  assert( db->lookaside.bDisable );\n  if( sqlite3FindTable(db, \"sqlite_stat4\", zDb) ){\n    rc = loadStatTbl(db, 0,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\",\n      zDb\n    );\n  }\n\n  if( rc==SQLITE_OK && sqlite3FindTable(db, \"sqlite_stat3\", zDb) ){\n    rc = loadStatTbl(db, 1,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sqlite_record(sample) FROM %Q.sqlite_stat3\",\n      zDb\n    );\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Load the content of the sqlite_stat1 and sqlite_stat3/4 tables. The\n** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]\n** arrays. The contents of sqlite_stat3/4 are used to populate the\n** Index.aSample[] arrays.\n**\n** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR\n** is returned. In this case, even if SQLITE_ENABLE_STAT3/4 was defined \n** during compilation and the sqlite_stat3/4 table is present, no data is \n** read from it.\n**\n** If SQLITE_ENABLE_STAT3/4 was defined during compilation and the \n** sqlite_stat4 table is not present in the database, SQLITE_ERROR is\n** returned. However, in this case, data is read from the sqlite_stat1\n** table (if it is present) before returning.\n**\n** If an OOM error occurs, this function always sets db->mallocFailed.\n** This means if the caller does not care about other errors, the return\n** code may be ignored.\n*/\nSQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){\n  analysisInfo sInfo;\n  HashElem *i;\n  char *zSql;\n  int rc = SQLITE_OK;\n  Schema *pSchema = db->aDb[iDb].pSchema;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n\n  /* Clear any prior statistics */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    pTab->tabFlags &= ~TF_HasStat1;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    pIdx->hasStat1 = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3DeleteIndexSamples(db, pIdx);\n    pIdx->aSample = 0;\n#endif\n  }\n\n  /* Load new statistics out of the sqlite_stat1 table */\n  sInfo.db = db;\n  sInfo.zDatabase = db->aDb[iDb].zDbSName;\n  if( sqlite3FindTable(db, \"sqlite_stat1\", sInfo.zDatabase)!=0 ){\n    zSql = sqlite3MPrintf(db, \n        \"SELECT tbl,idx,stat FROM %Q.sqlite_stat1\", sInfo.zDatabase);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);\n      sqlite3DbFree(db, zSql);\n    }\n  }\n\n  /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);\n  }\n\n  /* Load the statistics from the sqlite_stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){\n    db->lookaside.bDisable++;\n    rc = loadStat4(db, sInfo.zDatabase);\n    db->lookaside.bDisable--;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    sqlite3_free(pIdx->aiRowEst);\n    pIdx->aiRowEst = 0;\n  }\n#endif\n\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return rc;\n}\n\n\n#endif /* SQLITE_OMIT_ANALYZE */\n\n/************** End of analyze.c *********************************************/\n/************** Begin file attach.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the ATTACH and DETACH commands.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_ATTACH\n/*\n** Resolve an expression that was part of an ATTACH or DETACH statement. This\n** is slightly different from resolving a normal SQL expression, because simple\n** identifiers are treated as strings, not possible column names or aliases.\n**\n** i.e. if the parser sees:\n**\n**     ATTACH DATABASE abc AS def\n**\n** it treats the two expressions as literal strings 'abc' and 'def' instead of\n** looking for columns of the same name.\n**\n** This only applies to the root node of pExpr, so the statement:\n**\n**     ATTACH DATABASE abc||def AS 'db2'\n**\n** will fail because neither abc or def can be resolved.\n*/\nstatic int resolveAttachExpr(NameContext *pName, Expr *pExpr)\n{\n  int rc = SQLITE_OK;\n  if( pExpr ){\n    if( pExpr->op!=TK_ID ){\n      rc = sqlite3ResolveExprNames(pName, pExpr);\n    }else{\n      pExpr->op = TK_STRING;\n    }\n  }\n  return rc;\n}\n\n/*\n** An SQL user-function registered to do the work of an ATTACH statement. The\n** three arguments to the function come directly from an attach statement:\n**\n**     ATTACH DATABASE x AS y KEY z\n**\n**     SELECT sqlite_attach(x, y, z)\n**\n** If the optional \"KEY z\" syntax is omitted, an SQL NULL is passed as the\n** third argument.\n*/\nstatic void attachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  int i;\n  int rc = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zName;\n  const char *zFile;\n  char *zPath = 0;\n  char *zErr = 0;\n  unsigned int flags;\n  Db *aNew;                 /* New array of Db pointers */\n  Db *pNew;                 /* Db object for the newly attached database */\n  char *zErrDyn = 0;\n  sqlite3_vfs *pVfs;\n\n  UNUSED_PARAMETER(NotUsed);\n\n  zFile = (const char *)sqlite3_value_text(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[1]);\n  if( zFile==0 ) zFile = \"\";\n  if( zName==0 ) zName = \"\";\n\n  /* Check for the following errors:\n  **\n  **     * Too many attached databases,\n  **     * Transaction currently open\n  **     * Specified database name already being used.\n  */\n  if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){\n    zErrDyn = sqlite3MPrintf(db, \"too many attached databases - max %d\", \n      db->aLimit[SQLITE_LIMIT_ATTACHED]\n    );\n    goto attach_error;\n  }\n  for(i=0; i<db->nDb; i++){\n    char *z = db->aDb[i].zDbSName;\n    assert( z && zName );\n    if( sqlite3StrICmp(z, zName)==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"database %s is already in use\", zName);\n      goto attach_error;\n    }\n  }\n\n  /* Allocate the new entry in the db->aDb[] array and initialize the schema\n  ** hash tables.\n  */\n  if( db->aDb==db->aDbStatic ){\n    aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );\n    if( aNew==0 ) return;\n    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);\n  }else{\n    aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );\n    if( aNew==0 ) return;\n  }\n  db->aDb = aNew;\n  pNew = &db->aDb[db->nDb];\n  memset(pNew, 0, sizeof(*pNew));\n\n  /* Open the database file. If the btree is successfully opened, use\n  ** it to obtain the database schema. At this point the schema may\n  ** or may not be initialized.\n  */\n  flags = db->openFlags;\n  rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n  assert( pVfs );\n  flags |= SQLITE_OPEN_MAIN_DB;\n  rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);\n  sqlite3_free( zPath );\n  db->nDb++;\n  db->skipBtreeMutex = 0;\n  if( rc==SQLITE_CONSTRAINT ){\n    rc = SQLITE_ERROR;\n    zErrDyn = sqlite3MPrintf(db, \"database is already attached\");\n  }else if( rc==SQLITE_OK ){\n    Pager *pPager;\n    pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);\n    if( !pNew->pSchema ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){\n      zErrDyn = sqlite3MPrintf(db, \n        \"attached databases must use the same text encoding as main database\");\n      rc = SQLITE_ERROR;\n    }\n    sqlite3BtreeEnter(pNew->pBt);\n    pPager = sqlite3BtreePager(pNew->pBt);\n    sqlite3PagerLockingMode(pPager, db->dfltLockMode);\n    sqlite3BtreeSecureDelete(pNew->pBt,\n                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n    sqlite3BtreeSetPagerFlags(pNew->pBt,\n                      PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));\n#endif\n    sqlite3BtreeLeave(pNew->pBt);\n  }\n  pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  pNew->zDbSName = sqlite3DbStrDup(db, zName);\n  if( rc==SQLITE_OK && pNew->zDbSName==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n#ifdef SQLITE_HAS_CODEC\n  if( rc==SQLITE_OK ){\n    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    int t = sqlite3_value_type(argv[2]);\n    switch( t ){\n      case SQLITE_INTEGER:\n      case SQLITE_FLOAT:\n        zErrDyn = sqlite3DbStrDup(db, \"Invalid key value\");\n        rc = SQLITE_ERROR;\n        break;\n        \n      case SQLITE_TEXT:\n      case SQLITE_BLOB:\n        nKey = sqlite3_value_bytes(argv[2]);\n        zKey = (char *)sqlite3_value_blob(argv[2]);\n        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        break;\n\n      case SQLITE_NULL:\n        /* No key specified.  Use the key from the main database */\n        sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);\n        if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){\n          rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        }\n        break;\n    }\n  }\n#endif\n\n  /* If the file was opened successfully, read the schema for the new database.\n  ** If this fails, or if opening the file failed, then close the file and \n  ** remove the entry from the db->aDb[] array. i.e. put everything back the way\n  ** we found it.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3BtreeEnterAll(db);\n    rc = sqlite3Init(db, &zErrDyn);\n    sqlite3BtreeLeaveAll(db);\n  }\n#ifdef SQLITE_USER_AUTHENTICATION\n  if( rc==SQLITE_OK ){\n    u8 newAuth = 0;\n    rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);\n    if( newAuth<db->auth.authLevel ){\n      rc = SQLITE_AUTH_USER;\n    }\n  }\n#endif\n  if( rc ){\n    int iDb = db->nDb - 1;\n    assert( iDb>=2 );\n    if( db->aDb[iDb].pBt ){\n      sqlite3BtreeClose(db->aDb[iDb].pBt);\n      db->aDb[iDb].pBt = 0;\n      db->aDb[iDb].pSchema = 0;\n    }\n    sqlite3ResetAllSchemasOfConnection(db);\n    db->nDb = iDb;\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      sqlite3OomFault(db);\n      sqlite3DbFree(db, zErrDyn);\n      zErrDyn = sqlite3MPrintf(db, \"out of memory\");\n    }else if( zErrDyn==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"unable to open database: %s\", zFile);\n    }\n    goto attach_error;\n  }\n  \n  return;\n\nattach_error:\n  /* Return an error if we get here */\n  if( zErrDyn ){\n    sqlite3_result_error(context, zErrDyn, -1);\n    sqlite3DbFree(db, zErrDyn);\n  }\n  if( rc ) sqlite3_result_error_code(context, rc);\n}\n\n/*\n** An SQL user-function registered to do the work of an DETACH statement. The\n** three arguments to the function come directly from a detach statement:\n**\n**     DETACH DATABASE x\n**\n**     SELECT sqlite_detach(x)\n*/\nstatic void detachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *zName = (const char *)sqlite3_value_text(argv[0]);\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int i;\n  Db *pDb = 0;\n  char zErr[128];\n\n  UNUSED_PARAMETER(NotUsed);\n\n  if( zName==0 ) zName = \"\";\n  for(i=0; i<db->nDb; i++){\n    pDb = &db->aDb[i];\n    if( pDb->pBt==0 ) continue;\n    if( sqlite3StrICmp(pDb->zDbSName, zName)==0 ) break;\n  }\n\n  if( i>=db->nDb ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"no such database: %s\", zName);\n    goto detach_error;\n  }\n  if( i<2 ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"cannot detach database %s\", zName);\n    goto detach_error;\n  }\n  if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"database %s is locked\", zName);\n    goto detach_error;\n  }\n\n  sqlite3BtreeClose(pDb->pBt);\n  pDb->pBt = 0;\n  pDb->pSchema = 0;\n  sqlite3CollapseDatabaseArray(db);\n  return;\n\ndetach_error:\n  sqlite3_result_error(context, zErr, -1);\n}\n\n/*\n** This procedure generates VDBE code for a single invocation of either the\n** sqlite_detach() or sqlite_attach() SQL user functions.\n*/\nstatic void codeAttach(\n  Parse *pParse,       /* The parser context */\n  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */\n  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */\n  Expr *pAuthArg,      /* Expression to pass to authorization callback */\n  Expr *pFilename,     /* Name of database file */\n  Expr *pDbname,       /* Name of the database to use internally */\n  Expr *pKey           /* Database key for encryption extension */\n){\n  int rc;\n  NameContext sName;\n  Vdbe *v;\n  sqlite3* db = pParse->db;\n  int regArgs;\n\n  if( pParse->nErr ) goto attach_end;\n  memset(&sName, 0, sizeof(NameContext));\n  sName.pParse = pParse;\n\n  if( \n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))\n  ){\n    goto attach_end;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( pAuthArg ){\n    char *zAuthArg;\n    if( pAuthArg->op==TK_STRING ){\n      zAuthArg = pAuthArg->u.zToken;\n    }else{\n      zAuthArg = 0;\n    }\n    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);\n    if(rc!=SQLITE_OK ){\n      goto attach_end;\n    }\n  }\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n\n  v = sqlite3GetVdbe(pParse);\n  regArgs = sqlite3GetTempRange(pParse, 4);\n  sqlite3ExprCode(pParse, pFilename, regArgs);\n  sqlite3ExprCode(pParse, pDbname, regArgs+1);\n  sqlite3ExprCode(pParse, pKey, regArgs+2);\n\n  assert( v || db->mallocFailed );\n  if( v ){\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,\n                      (char *)pFunc, P4_FUNCDEF);\n    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );\n    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));\n \n    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this\n    ** statement only). For DETACH, set it to false (expire all existing\n    ** statements).\n    */\n    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));\n  }\n  \nattach_end:\n  sqlite3ExprDelete(db, pFilename);\n  sqlite3ExprDelete(db, pDbname);\n  sqlite3ExprDelete(db, pKey);\n}\n\n/*\n** Called by the parser to compile a DETACH statement.\n**\n**     DETACH pDbname\n*/\nSQLITE_PRIVATE void sqlite3Detach(Parse *pParse, Expr *pDbname){\n  static const FuncDef detach_func = {\n    1,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    detachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    \"sqlite_detach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);\n}\n\n/*\n** Called by the parser to compile an ATTACH statement.\n**\n**     ATTACH p AS pDbname KEY pKey\n*/\nSQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){\n  static const FuncDef attach_func = {\n    3,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    attachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    \"sqlite_attach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);\n}\n#endif /* SQLITE_OMIT_ATTACH */\n\n/*\n** Initialize a DbFixer structure.  This routine must be called prior\n** to passing the structure to one of the sqliteFixAAAA() routines below.\n*/\nSQLITE_PRIVATE void sqlite3FixInit(\n  DbFixer *pFix,      /* The fixer to be initialized */\n  Parse *pParse,      /* Error messages will be written here */\n  int iDb,            /* This is the database that must be used */\n  const char *zType,  /* \"view\", \"trigger\", or \"index\" */\n  const Token *pName  /* Name of the view, trigger, or index */\n){\n  sqlite3 *db;\n\n  db = pParse->db;\n  assert( db->nDb>iDb );\n  pFix->pParse = pParse;\n  pFix->zDb = db->aDb[iDb].zDbSName;\n  pFix->pSchema = db->aDb[iDb].pSchema;\n  pFix->zType = zType;\n  pFix->pName = pName;\n  pFix->bVarOnly = (iDb==1);\n}\n\n/*\n** The following set of routines walk through the parse tree and assign\n** a specific database to all table references where the database name\n** was left unspecified in the original SQL statement.  The pFix structure\n** must have been initialized by a prior call to sqlite3FixInit().\n**\n** These routines are used to make sure that an index, trigger, or\n** view in one database does not refer to objects in a different database.\n** (Exception: indices, triggers, and views in the TEMP database are\n** allowed to refer to anything.)  If a reference is explicitly made\n** to an object in a different database, an error message is added to\n** pParse->zErrMsg and these routines return non-zero.  If everything\n** checks out, these routines return 0.\n*/\nSQLITE_PRIVATE int sqlite3FixSrcList(\n  DbFixer *pFix,       /* Context of the fixation */\n  SrcList *pList       /* The Source list to check and modify */\n){\n  int i;\n  const char *zDb;\n  struct SrcList_item *pItem;\n\n  if( NEVER(pList==0) ) return 0;\n  zDb = pFix->zDb;\n  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n    if( pFix->bVarOnly==0 ){\n      if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){\n        sqlite3ErrorMsg(pFix->pParse,\n            \"%s %T cannot reference objects in database %s\",\n            pFix->zType, pFix->pName, pItem->zDatabase);\n        return 1;\n      }\n      sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);\n      pItem->zDatabase = 0;\n      pItem->pSchema = pFix->pSchema;\n    }\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\n    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;\n    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;\n#endif\n  }\n  return 0;\n}\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\nSQLITE_PRIVATE int sqlite3FixSelect(\n  DbFixer *pFix,       /* Context of the fixation */\n  Select *pSelect      /* The SELECT statement to be fixed to one database */\n){\n  while( pSelect ){\n    if( sqlite3FixExprList(pFix, pSelect->pEList) ){\n      return 1;\n    }\n    if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pHaving) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pLimit) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pOffset) ){\n      return 1;\n    }\n    pSelect = pSelect->pPrior;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExpr(\n  DbFixer *pFix,     /* Context of the fixation */\n  Expr *pExpr        /* The expression to be fixed to one database */\n){\n  while( pExpr ){\n    if( pExpr->op==TK_VARIABLE ){\n      if( pFix->pParse->db->init.busy ){\n        pExpr->op = TK_NULL;\n      }else{\n        sqlite3ErrorMsg(pFix->pParse, \"%s cannot use variables\", pFix->zType);\n        return 1;\n      }\n    }\n    if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;\n    }else{\n      if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;\n    }\n    if( sqlite3FixExpr(pFix, pExpr->pRight) ){\n      return 1;\n    }\n    pExpr = pExpr->pLeft;\n  }\n  return 0;\n}\nSQLITE_PRIVATE int sqlite3FixExprList(\n  DbFixer *pFix,     /* Context of the fixation */\n  ExprList *pList    /* The expression to be fixed to one database */\n){\n  int i;\n  struct ExprList_item *pItem;\n  if( pList==0 ) return 0;\n  for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){\n    if( sqlite3FixExpr(pFix, pItem->pExpr) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nSQLITE_PRIVATE int sqlite3FixTriggerStep(\n  DbFixer *pFix,     /* Context of the fixation */\n  TriggerStep *pStep /* The trigger step be fixed to one database */\n){\n  while( pStep ){\n    if( sqlite3FixSelect(pFix, pStep->pSelect) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pStep->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pStep->pExprList) ){\n      return 1;\n    }\n    pStep = pStep->pNext;\n  }\n  return 0;\n}\n#endif\n\n/************** End of attach.c **********************************************/\n/************** Begin file auth.c ********************************************/\n/*\n** 2003 January 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the sqlite3_set_authorizer()\n** API.  This facility is an optional feature of the library.  Embedded\n** systems that do not need this facility may omit it by recompiling\n** the library with -DSQLITE_OMIT_AUTHORIZATION=1\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** All of the code in this file may be omitted by defining a single\n** macro.\n*/\n#ifndef SQLITE_OMIT_AUTHORIZATION\n\n/*\n** Set or clear the access authorization function.\n**\n** The access authorization function is be called during the compilation\n** phase to verify that the user has read and/or write access permission on\n** various fields of the database.  The first argument to the auth function\n** is a copy of the 3rd argument to this routine.  The second argument\n** to the auth function is one of these constants:\n**\n**       SQLITE_CREATE_INDEX\n**       SQLITE_CREATE_TABLE\n**       SQLITE_CREATE_TEMP_INDEX\n**       SQLITE_CREATE_TEMP_TABLE\n**       SQLITE_CREATE_TEMP_TRIGGER\n**       SQLITE_CREATE_TEMP_VIEW\n**       SQLITE_CREATE_TRIGGER\n**       SQLITE_CREATE_VIEW\n**       SQLITE_DELETE\n**       SQLITE_DROP_INDEX\n**       SQLITE_DROP_TABLE\n**       SQLITE_DROP_TEMP_INDEX\n**       SQLITE_DROP_TEMP_TABLE\n**       SQLITE_DROP_TEMP_TRIGGER\n**       SQLITE_DROP_TEMP_VIEW\n**       SQLITE_DROP_TRIGGER\n**       SQLITE_DROP_VIEW\n**       SQLITE_INSERT\n**       SQLITE_PRAGMA\n**       SQLITE_READ\n**       SQLITE_SELECT\n**       SQLITE_TRANSACTION\n**       SQLITE_UPDATE\n**\n** The third and fourth arguments to the auth function are the name of\n** the table and the column that are being accessed.  The auth function\n** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If\n** SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY\n** means that the SQL statement will never-run - the sqlite3_exec() call\n** will return with an error.  SQLITE_IGNORE means that the SQL statement\n** should run but attempts to read the specified column will return NULL\n** and attempts to write the column will be ignored.\n**\n** Setting the auth function to NULL disables this hook.  The default\n** setting of the auth function is NULL.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3 *db,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xAuth = (sqlite3_xauth)xAuth;\n  db->pAuthArg = pArg;\n  sqlite3ExpirePreparedStatements(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into pParse->zErrMsg that explains that the\n** user-supplied authorization function returned an illegal value.\n*/\nstatic void sqliteAuthBadReturnCode(Parse *pParse){\n  sqlite3ErrorMsg(pParse, \"authorizer malfunction\");\n  pParse->rc = SQLITE_ERROR;\n}\n\n/*\n** Invoke the authorization callback for permission to read column zCol from\n** table zTab in database zDb. This function assumes that an authorization\n** callback has been registered (i.e. that sqlite3.xAuth is not NULL).\n**\n** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed\n** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE\n** is treated as SQLITE_DENY. In this case an error is left in pParse.\n*/\nSQLITE_PRIVATE int sqlite3AuthReadCol(\n  Parse *pParse,                  /* The parser context */\n  const char *zTab,               /* Table name */\n  const char *zCol,               /* Column name */\n  int iDb                         /* Index of containing database. */\n){\n  sqlite3 *db = pParse->db;          /* Database handle */\n  char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */\n  int rc;                            /* Auth callback return code */\n\n  if( db->init.busy ) return SQLITE_OK;\n  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    char *z = sqlite3_mprintf(\"%s.%s\", zTab, zCol);\n    if( db->nDb>2 || iDb!=0 ) z = sqlite3_mprintf(\"%s.%z\", zDb, z);\n    sqlite3ErrorMsg(pParse, \"access to %z is prohibited\", z);\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** The pExpr should be a TK_COLUMN expression.  The table referred to\n** is in pTabList or else it is the NEW or OLD table of a trigger.  \n** Check to see if it is OK to read this particular column.\n**\n** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN \n** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,\n** then generate an error.\n*/\nSQLITE_PRIVATE void sqlite3AuthRead(\n  Parse *pParse,        /* The parser context */\n  Expr *pExpr,          /* The expression to check authorization on */\n  Schema *pSchema,      /* The schema of the expression */\n  SrcList *pTabList     /* All table that pExpr might refer to */\n){\n  sqlite3 *db = pParse->db;\n  Table *pTab = 0;      /* The table being read */\n  const char *zCol;     /* Name of the column of the table */\n  int iSrc;             /* Index in pTabList->a[] of table being read */\n  int iDb;              /* The index of the database the expression refers to */\n  int iCol;             /* Index of column in table */\n\n  if( db->xAuth==0 ) return;\n  iDb = sqlite3SchemaToIndex(pParse->db, pSchema);\n  if( iDb<0 ){\n    /* An attempt to read a column out of a subquery or other\n    ** temporary table. */\n    return;\n  }\n\n  assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );\n  if( pExpr->op==TK_TRIGGER ){\n    pTab = pParse->pTriggerTab;\n  }else{\n    assert( pTabList );\n    for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){\n      if( pExpr->iTable==pTabList->a[iSrc].iCursor ){\n        pTab = pTabList->a[iSrc].pTab;\n        break;\n      }\n    }\n  }\n  iCol = pExpr->iColumn;\n  if( NEVER(pTab==0) ) return;\n\n  if( iCol>=0 ){\n    assert( iCol<pTab->nCol );\n    zCol = pTab->aCol[iCol].zName;\n  }else if( pTab->iPKey>=0 ){\n    assert( pTab->iPKey<pTab->nCol );\n    zCol = pTab->aCol[pTab->iPKey].zName;\n  }else{\n    zCol = \"ROWID\";\n  }\n  assert( iDb>=0 && iDb<db->nDb );\n  if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){\n    pExpr->op = TK_NULL;\n  }\n}\n\n/*\n** Do an authorization check using the code and arguments given.  Return\n** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY\n** is returned, then the error count and error message in pParse are\n** modified appropriately.\n*/\nSQLITE_PRIVATE int sqlite3AuthCheck(\n  Parse *pParse,\n  int code,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3\n){\n  sqlite3 *db = pParse->db;\n  int rc;\n\n  /* Don't do any authorization checks if the database is initialising\n  ** or if the parser is being invoked from within sqlite3_declare_vtab.\n  */\n  if( db->init.busy || IN_DECLARE_VTAB ){\n    return SQLITE_OK;\n  }\n\n  if( db->xAuth==0 ){\n    return SQLITE_OK;\n  }\n\n  /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the\n  ** callback are either NULL pointers or zero-terminated strings that\n  ** contain additional details about the action to be authorized.\n  **\n  ** The following testcase() macros show that any of the 3rd through 6th\n  ** parameters can be either NULL or a string. */\n  testcase( zArg1==0 );\n  testcase( zArg2==0 );\n  testcase( zArg3==0 );\n  testcase( pParse->zAuthContext==0 );\n\n  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    sqlite3ErrorMsg(pParse, \"not authorized\");\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){\n    rc = SQLITE_DENY;\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** Push an authorization context.  After this routine is called, the\n** zArg3 argument to authorization callbacks will be zContext until\n** popped.  Or if pParse==0, this routine is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPush(\n  Parse *pParse,\n  AuthContext *pContext, \n  const char *zContext\n){\n  assert( pParse );\n  pContext->pParse = pParse;\n  pContext->zAuthContext = pParse->zAuthContext;\n  pParse->zAuthContext = zContext;\n}\n\n/*\n** Pop an authorization context that was previously pushed\n** by sqlite3AuthContextPush\n*/\nSQLITE_PRIVATE void sqlite3AuthContextPop(AuthContext *pContext){\n  if( pContext->pParse ){\n    pContext->pParse->zAuthContext = pContext->zAuthContext;\n    pContext->pParse = 0;\n  }\n}\n\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n/************** End of auth.c ************************************************/\n/************** Begin file build.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the SQLite parser\n** when syntax rules are reduced.  The routines in this file handle the\n** following kinds of SQL syntax:\n**\n**     CREATE TABLE\n**     DROP TABLE\n**     CREATE INDEX\n**     DROP INDEX\n**     creating ID lists\n**     BEGIN TRANSACTION\n**     COMMIT\n**     ROLLBACK\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** The TableLock structure is only used by the sqlite3TableLock() and\n** codeTableLocks() functions.\n*/\nstruct TableLock {\n  int iDb;               /* The database containing the table to be locked */\n  int iTab;              /* The root page of the table to be locked */\n  u8 isWriteLock;        /* True for write lock.  False for a read lock */\n  const char *zLockName; /* Name of the table */\n};\n\n/*\n** Record the fact that we want to lock a table at run-time.  \n**\n** The table to be locked has root page iTab and is found in database iDb.\n** A read or a write lock can be taken depending on isWritelock.\n**\n** This routine just records the fact that the lock is desired.  The\n** code to make the lock occur is generated by a later call to\n** codeTableLocks() which occurs during sqlite3FinishCoding().\n*/\nSQLITE_PRIVATE void sqlite3TableLock(\n  Parse *pParse,     /* Parsing context */\n  int iDb,           /* Index of the database containing the table to lock */\n  int iTab,          /* Root page number of the table to be locked */\n  u8 isWriteLock,    /* True for a write lock */\n  const char *zName  /* Name of the table to be locked */\n){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i;\n  int nBytes;\n  TableLock *p;\n  assert( iDb>=0 );\n\n  if( iDb==1 ) return;\n  if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;\n  for(i=0; i<pToplevel->nTableLock; i++){\n    p = &pToplevel->aTableLock[i];\n    if( p->iDb==iDb && p->iTab==iTab ){\n      p->isWriteLock = (p->isWriteLock || isWriteLock);\n      return;\n    }\n  }\n\n  nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);\n  pToplevel->aTableLock =\n      sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);\n  if( pToplevel->aTableLock ){\n    p = &pToplevel->aTableLock[pToplevel->nTableLock++];\n    p->iDb = iDb;\n    p->iTab = iTab;\n    p->isWriteLock = isWriteLock;\n    p->zLockName = zName;\n  }else{\n    pToplevel->nTableLock = 0;\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Code an OP_TableLock instruction for each table locked by the\n** statement (configured by calls to sqlite3TableLock()).\n*/\nstatic void codeTableLocks(Parse *pParse){\n  int i;\n  Vdbe *pVdbe; \n\n  pVdbe = sqlite3GetVdbe(pParse);\n  assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */\n\n  for(i=0; i<pParse->nTableLock; i++){\n    TableLock *p = &pParse->aTableLock[i];\n    int p1 = p->iDb;\n    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,\n                      p->zLockName, P4_STATIC);\n  }\n}\n#else\n  #define codeTableLocks(x)\n#endif\n\n/*\n** Return TRUE if the given yDbMask object is empty - if it contains no\n** 1 bits.  This routine is used by the DbMaskAllZero() and DbMaskNotZero()\n** macros when SQLITE_MAX_ATTACHED is greater than 30.\n*/\n#if SQLITE_MAX_ATTACHED>30\nSQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask m){\n  int i;\n  for(i=0; i<sizeof(yDbMask); i++) if( m[i] ) return 0;\n  return 1;\n}\n#endif\n\n/*\n** This routine is called after a single SQL statement has been\n** parsed and a VDBE program to execute that statement has been\n** prepared.  This routine puts the finishing touches on the\n** VDBE program and resets the pParse structure for the next\n** parse.\n**\n** Note that if an error occurred, it might be the case that\n** no VDBE code was generated.\n*/\nSQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){\n  sqlite3 *db;\n  Vdbe *v;\n\n  assert( pParse->pToplevel==0 );\n  db = pParse->db;\n  if( pParse->nested ) return;\n  if( db->mallocFailed || pParse->nErr ){\n    if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;\n    return;\n  }\n\n  /* Begin by generating some termination code at the end of the\n  ** vdbe program\n  */\n  v = sqlite3GetVdbe(pParse);\n  assert( !pParse->isMultiWrite \n       || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));\n  if( v ){\n    sqlite3VdbeAddOp0(v, OP_Halt);\n\n#if SQLITE_USER_AUTHENTICATION\n    if( pParse->nTableLock>0 && db->init.busy==0 ){\n      sqlite3UserAuthInit(db);\n      if( db->auth.authLevel<UAUTH_User ){\n        sqlite3ErrorMsg(pParse, \"user not authenticated\");\n        pParse->rc = SQLITE_AUTH_USER;\n        return;\n      }\n    }\n#endif\n\n    /* The cookie mask contains one bit for each database file open.\n    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are\n    ** set for each database that is used.  Generate code to start a\n    ** transaction on each used database and to verify the schema cookie\n    ** on each used database.\n    */\n    if( db->mallocFailed==0 \n     && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)\n    ){\n      int iDb, i;\n      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );\n      sqlite3VdbeJumpHere(v, 0);\n      for(iDb=0; iDb<db->nDb; iDb++){\n        Schema *pSchema;\n        if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue;\n        sqlite3VdbeUsesBtree(v, iDb);\n        pSchema = db->aDb[iDb].pSchema;\n        sqlite3VdbeAddOp4Int(v,\n          OP_Transaction,                    /* Opcode */\n          iDb,                               /* P1 */\n          DbMaskTest(pParse->writeMask,iDb), /* P2 */\n          pSchema->schema_cookie,            /* P3 */\n          pSchema->iGeneration               /* P4 */\n        );\n        if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1);\n        VdbeComment((v,\n              \"usesStmtJournal=%d\", pParse->mayAbort && pParse->isMultiWrite));\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      for(i=0; i<pParse->nVtabLock; i++){\n        char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);\n        sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);\n      }\n      pParse->nVtabLock = 0;\n#endif\n\n      /* Once all the cookies have been verified and transactions opened, \n      ** obtain the required table-locks. This is a no-op unless the \n      ** shared-cache feature is enabled.\n      */\n      codeTableLocks(pParse);\n\n      /* Initialize any AUTOINCREMENT data structures required.\n      */\n      sqlite3AutoincrementBegin(pParse);\n\n      /* Code constant expressions that where factored out of inner loops */\n      if( pParse->pConstExpr ){\n        ExprList *pEL = pParse->pConstExpr;\n        pParse->okConstFactor = 0;\n        for(i=0; i<pEL->nExpr; i++){\n          sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);\n        }\n      }\n\n      /* Finally, jump back to the beginning of the executable code. */\n      sqlite3VdbeGoto(v, 1);\n    }\n  }\n\n\n  /* Get the VDBE program ready for execution\n  */\n  if( v && pParse->nErr==0 && !db->mallocFailed ){\n    assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */\n    /* A minimum of one cursor is required if autoincrement is used\n    *  See ticket [a696379c1f08866] */\n    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;\n    sqlite3VdbeMakeReady(v, pParse);\n    pParse->rc = SQLITE_DONE;\n  }else{\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Run the parser and code generator recursively in order to generate\n** code for the SQL statement given onto the end of the pParse context\n** currently under construction.  When the parser is run recursively\n** this way, the final OP_Halt is not appended and other initialization\n** and finalization steps are omitted because those are handling by the\n** outermost parser.\n**\n** Not everything is nestable.  This facility is designed to permit\n** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use\n** care if you decide to try to use this routine for some other purposes.\n*/\nSQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  char *zErrMsg = 0;\n  sqlite3 *db = pParse->db;\n  char saveBuf[PARSE_TAIL_SZ];\n\n  if( pParse->nErr ) return;\n  assert( pParse->nested<10 );  /* Nesting should only be of limited depth */\n  va_start(ap, zFormat);\n  zSql = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    return;   /* A malloc must have failed */\n  }\n  pParse->nested++;\n  memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);\n  memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);\n  sqlite3RunParser(pParse, zSql, &zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  sqlite3DbFree(db, zSql);\n  memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);\n  pParse->nested--;\n}\n\n#if SQLITE_USER_AUTHENTICATION\n/*\n** Return TRUE if zTable is the name of the system table that stores the\n** list of users and their access credentials.\n*/\nSQLITE_PRIVATE int sqlite3UserAuthTable(const char *zTable){\n  return sqlite3_stricmp(zTable, \"sqlite_user\")==0;\n}\n#endif\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the table and the\n** first matching table is returned.  (No checking for duplicate table\n** names is done.)  The search order is TEMP first, then MAIN, then any\n** auxiliary databases added using the ATTACH command.\n**\n** See also sqlite3LocateTable().\n*/\nSQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){\n  Table *p = 0;\n  int i;\n\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n#if SQLITE_USER_AUTHENTICATION\n  /* Only the admin user is allowed to know that the sqlite_user table\n  ** exists */\n  if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){\n    return 0;\n  }\n#endif\n  while(1){\n    for(i=OMIT_TEMPDB; i<db->nDb; i++){\n      int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */\n      if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){\n        assert( sqlite3SchemaMutexHeld(db, j, 0) );\n        p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);\n        if( p ) return p;\n      }\n    }\n    /* Not found.  If the name we were looking for was temp.sqlite_master\n    ** then change the name to sqlite_temp_master and try again. */\n    if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;\n    if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;\n    zName = TEMP_MASTER_NAME;\n  }\n  return 0;\n}\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.  Also leave an\n** error message in pParse->zErrMsg.\n**\n** The difference between this routine and sqlite3FindTable() is that this\n** routine leaves an error message in pParse->zErrMsg where\n** sqlite3FindTable() does not.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTable(\n  Parse *pParse,         /* context in which to report errors */\n  u32 flags,             /* LOCATE_VIEW or LOCATE_NOERR */\n  const char *zName,     /* Name of the table we are looking for */\n  const char *zDbase     /* Name of the database.  Might be NULL */\n){\n  Table *p;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return 0;\n  }\n\n  p = sqlite3FindTable(pParse->db, zName, zDbase);\n  if( p==0 ){\n    const char *zMsg = flags & LOCATE_VIEW ? \"no such view\" : \"no such table\";\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){\n      /* If zName is the not the name of a table in the schema created using\n      ** CREATE, then check to see if it is the name of an virtual table that\n      ** can be an eponymous virtual table. */\n      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);\n      if( pMod==0 && sqlite3_strnicmp(zName, \"pragma_\", 7)==0 ){\n        pMod = sqlite3PragmaVtabRegister(pParse->db, zName);\n      }\n      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){\n        return pMod->pEpoTab;\n      }\n    }\n#endif\n    if( (flags & LOCATE_NOERR)==0 ){\n      if( zDbase ){\n        sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zMsg, zDbase, zName);\n      }else{\n        sqlite3ErrorMsg(pParse, \"%s: %s\", zMsg, zName);\n      }\n      pParse->checkSchema = 1;\n    }\n  }\n\n  return p;\n}\n\n/*\n** Locate the table identified by *p.\n**\n** This is a wrapper around sqlite3LocateTable(). The difference between\n** sqlite3LocateTable() and this function is that this function restricts\n** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be\n** non-NULL if it is part of a view or trigger program definition. See\n** sqlite3FixSrcList() for details.\n*/\nSQLITE_PRIVATE Table *sqlite3LocateTableItem(\n  Parse *pParse, \n  u32 flags,\n  struct SrcList_item *p\n){\n  const char *zDb;\n  assert( p->pSchema==0 || p->zDatabase==0 );\n  if( p->pSchema ){\n    int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);\n    zDb = pParse->db->aDb[iDb].zDbSName;\n  }else{\n    zDb = p->zDatabase;\n  }\n  return sqlite3LocateTable(pParse, flags, p->zName, zDb);\n}\n\n/*\n** Locate the in-memory structure that describes \n** a particular index given the name of that index\n** and the name of the database that contains the index.\n** Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the\n** table and the first matching index is returned.  (No checking\n** for duplicate index names is done.)  The search order is\n** TEMP first, then MAIN, then any auxiliary databases added\n** using the ATTACH command.\n*/\nSQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){\n  Index *p = 0;\n  int i;\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    Schema *pSchema = db->aDb[j].pSchema;\n    assert( pSchema );\n    if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zDbSName) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    p = sqlite3HashFind(&pSchema->idxHash, zName);\n    if( p ) break;\n  }\n  return p;\n}\n\n/*\n** Reclaim the memory used by an index\n*/\nstatic void freeIndex(sqlite3 *db, Index *p){\n#ifndef SQLITE_OMIT_ANALYZE\n  sqlite3DeleteIndexSamples(db, p);\n#endif\n  sqlite3ExprDelete(db, p->pPartIdxWhere);\n  sqlite3ExprListDelete(db, p->aColExpr);\n  sqlite3DbFree(db, p->zColAff);\n  if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_free(p->aiRowEst);\n#endif\n  sqlite3DbFree(db, p);\n}\n\n/*\n** For the index called zIdxName which is found in the database iDb,\n** unlike that index from its Table then remove the index from\n** the index hash table and free all memory structures associated\n** with the index.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){\n  Index *pIndex;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &db->aDb[iDb].pSchema->idxHash;\n  pIndex = sqlite3HashInsert(pHash, zIdxName, 0);\n  if( ALWAYS(pIndex) ){\n    if( pIndex->pTable->pIndex==pIndex ){\n      pIndex->pTable->pIndex = pIndex->pNext;\n    }else{\n      Index *p;\n      /* Justification of ALWAYS();  The index must be on the list of\n      ** indices. */\n      p = pIndex->pTable->pIndex;\n      while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }\n      if( ALWAYS(p && p->pNext==pIndex) ){\n        p->pNext = pIndex->pNext;\n      }\n    }\n    freeIndex(db, pIndex);\n  }\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Look through the list of open database files in db->aDb[] and if\n** any have been closed, remove them from the list.  Reallocate the\n** db->aDb[] structure to a smaller size, if possible.\n**\n** Entry 0 (the \"main\" database) and entry 1 (the \"temp\" database)\n** are never candidates for being collapsed.\n*/\nSQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3 *db){\n  int i, j;\n  for(i=j=2; i<db->nDb; i++){\n    struct Db *pDb = &db->aDb[i];\n    if( pDb->pBt==0 ){\n      sqlite3DbFree(db, pDb->zDbSName);\n      pDb->zDbSName = 0;\n      continue;\n    }\n    if( j<i ){\n      db->aDb[j] = db->aDb[i];\n    }\n    j++;\n  }\n  db->nDb = j;\n  if( db->nDb<=2 && db->aDb!=db->aDbStatic ){\n    memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0]));\n    sqlite3DbFree(db, db->aDb);\n    db->aDb = db->aDbStatic;\n  }\n}\n\n/*\n** Reset the schema for the database at index iDb.  Also reset the\n** TEMP schema.  The reset is deferred if db->nSchemaLock is not zero.\n** Deferred resets may be run by calling with iDb<0.\n*/\nSQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3 *db, int iDb){\n  int i;\n  assert( iDb<db->nDb );\n\n  if( iDb>=0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    DbSetProperty(db, iDb, DB_ResetWanted);\n    DbSetProperty(db, 1, DB_ResetWanted);\n  }\n\n  if( db->nSchemaLock==0 ){\n    for(i=0; i<db->nDb; i++){\n      if( DbHasProperty(db, i, DB_ResetWanted) ){\n        sqlite3SchemaClear(db->aDb[i].pSchema);\n      }\n    }\n  }\n}\n\n/*\n** Erase all schema information from all attached databases (including\n** \"main\" and \"temp\") for a single database connection.\n*/\nSQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){\n  int i;\n  sqlite3BtreeEnterAll(db);\n  assert( db->nSchemaLock==0 );\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pSchema ){\n      sqlite3SchemaClear(pDb->pSchema);\n    }\n  }\n  db->mDbFlags &= ~DBFLAG_SchemaChange;\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n  sqlite3CollapseDatabaseArray(db);\n}\n\n/*\n** This routine is called when a commit occurs.\n*/\nSQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){\n  db->mDbFlags &= ~DBFLAG_SchemaChange;\n}\n\n/*\n** Delete memory allocated for the column names of a table or view (the\n** Table.aCol[] array).\n*/\nSQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){\n  int i;\n  Column *pCol;\n  assert( pTable!=0 );\n  if( (pCol = pTable->aCol)!=0 ){\n    for(i=0; i<pTable->nCol; i++, pCol++){\n      sqlite3DbFree(db, pCol->zName);\n      sqlite3ExprDelete(db, pCol->pDflt);\n      sqlite3DbFree(db, pCol->zColl);\n    }\n    sqlite3DbFree(db, pTable->aCol);\n  }\n}\n\n/*\n** Remove the memory data structures associated with the given\n** Table.  No changes are made to disk by this routine.\n**\n** This routine just deletes the data structure.  It does not unlink\n** the table data structure from the hash table.  But it does destroy\n** memory structures of the indices and foreign keys associated with \n** the table.\n**\n** The db parameter is optional.  It is needed if the Table object \n** contains lookaside memory.  (Table objects in the schema do not use\n** lookaside memory, but some ephemeral Table objects do.)  Or the\n** db parameter can be used with db->pnBytesFreed to measure the memory\n** used by the Table object.\n*/\nstatic void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){\n  Index *pIndex, *pNext;\n\n#ifdef SQLITE_DEBUG\n  /* Record the number of outstanding lookaside allocations in schema Tables\n  ** prior to doing any free() operations.  Since schema Tables do not use\n  ** lookaside, this number should not change. */\n  int nLookaside = 0;\n  if( db && (pTable->tabFlags & TF_Ephemeral)==0 ){\n    nLookaside = sqlite3LookasideUsed(db, 0);\n  }\n#endif\n\n  /* Delete all indices associated with this table. */\n  for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){\n    pNext = pIndex->pNext;\n    assert( pIndex->pSchema==pTable->pSchema\n         || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );\n    if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){\n      char *zName = pIndex->zName; \n      TESTONLY ( Index *pOld = ) sqlite3HashInsert(\n         &pIndex->pSchema->idxHash, zName, 0\n      );\n      assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n      assert( pOld==pIndex || pOld==0 );\n    }\n    freeIndex(db, pIndex);\n  }\n\n  /* Delete any foreign keys attached to this table. */\n  sqlite3FkDelete(db, pTable);\n\n  /* Delete the Table structure itself.\n  */\n  sqlite3DeleteColumnNames(db, pTable);\n  sqlite3DbFree(db, pTable->zName);\n  sqlite3DbFree(db, pTable->zColAff);\n  sqlite3SelectDelete(db, pTable->pSelect);\n  sqlite3ExprListDelete(db, pTable->pCheck);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3VtabClear(db, pTable);\n#endif\n  sqlite3DbFree(db, pTable);\n\n  /* Verify that no lookaside memory was used by schema tables */\n  assert( nLookaside==0 || nLookaside==sqlite3LookasideUsed(db,0) );\n}\nSQLITE_PRIVATE void sqlite3DeleteTable(sqlite3 *db, Table *pTable){\n  /* Do not delete the table until the reference count reaches zero. */\n  if( !pTable ) return;\n  if( ((!db || db->pnBytesFreed==0) && (--pTable->nTabRef)>0) ) return;\n  deleteTable(db, pTable);\n}\n\n\n/*\n** Unlink the given table from the hash tables and the delete the\n** table structure with all its indices and foreign keys.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){\n  Table *p;\n  Db *pDb;\n\n  assert( db!=0 );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( zTabName );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */\n  pDb = &db->aDb[iDb];\n  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, 0);\n  sqlite3DeleteTable(db, p);\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Given a token, return a string that consists of the text of that\n** token.  Space to hold the returned string\n** is obtained from sqliteMalloc() and must be freed by the calling\n** function.\n**\n** Any quotation marks (ex:  \"name\", 'name', [name], or `name`) that\n** surround the body of the token are removed.\n**\n** Tokens are often just pointers into the original SQL text and so\n** are not \\000 terminated and are not persistent.  The returned string\n** is \\000 terminated and is persistent.\n*/\nSQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){\n  char *zName;\n  if( pName ){\n    zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n);\n    sqlite3Dequote(zName);\n  }else{\n    zName = 0;\n  }\n  return zName;\n}\n\n/*\n** Open the sqlite_master table stored in database number iDb for\n** writing. The table is opened using cursor 0.\n*/\nSQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){\n  Vdbe *v = sqlite3GetVdbe(p);\n  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, MASTER_NAME);\n  sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5);\n  if( p->nTab==0 ){\n    p->nTab = 1;\n  }\n}\n\n/*\n** Parameter zName points to a nul-terminated buffer containing the name\n** of a database (\"main\", \"temp\" or the name of an attached db). This\n** function returns the index of the named database in db->aDb[], or\n** -1 if the named db cannot be found.\n*/\nSQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *db, const char *zName){\n  int i = -1;         /* Database number */\n  if( zName ){\n    Db *pDb;\n    for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){\n      if( 0==sqlite3_stricmp(pDb->zDbSName, zName) ) break;\n      /* \"main\" is always an acceptable alias for the primary database\n      ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */\n      if( i==0 && 0==sqlite3_stricmp(\"main\", zName) ) break;\n    }\n  }\n  return i;\n}\n\n/*\n** The token *pName contains the name of a database (either \"main\" or\n** \"temp\" or the name of an attached db). This routine returns the\n** index of the named database in db->aDb[], or -1 if the named db \n** does not exist.\n*/\nSQLITE_PRIVATE int sqlite3FindDb(sqlite3 *db, Token *pName){\n  int i;                               /* Database number */\n  char *zName;                         /* Name we are searching for */\n  zName = sqlite3NameFromToken(db, pName);\n  i = sqlite3FindDbName(db, zName);\n  sqlite3DbFree(db, zName);\n  return i;\n}\n\n/* The table or view or trigger name is passed to this routine via tokens\n** pName1 and pName2. If the table name was fully qualified, for example:\n**\n** CREATE TABLE xxx.yyy (...);\n** \n** Then pName1 is set to \"xxx\" and pName2 \"yyy\". On the other hand if\n** the table name is not fully qualified, i.e.:\n**\n** CREATE TABLE yyy(...);\n**\n** Then pName1 is set to \"yyy\" and pName2 is \"\".\n**\n** This routine sets the *ppUnqual pointer to point at the token (pName1 or\n** pName2) that stores the unqualified table name.  The index of the\n** database \"xxx\" is returned.\n*/\nSQLITE_PRIVATE int sqlite3TwoPartName(\n  Parse *pParse,      /* Parsing and code generating context */\n  Token *pName1,      /* The \"xxx\" in the name \"xxx.yyy\" or \"xxx\" */\n  Token *pName2,      /* The \"yyy\" in the name \"xxx.yyy\" */\n  Token **pUnqual     /* Write the unqualified object name here */\n){\n  int iDb;                    /* Database holding the object */\n  sqlite3 *db = pParse->db;\n\n  assert( pName2!=0 );\n  if( pName2->n>0 ){\n    if( db->init.busy ) {\n      sqlite3ErrorMsg(pParse, \"corrupt database\");\n      return -1;\n    }\n    *pUnqual = pName2;\n    iDb = sqlite3FindDb(db, pName1);\n    if( iDb<0 ){\n      sqlite3ErrorMsg(pParse, \"unknown database %T\", pName1);\n      return -1;\n    }\n  }else{\n    assert( db->init.iDb==0 || db->init.busy\n             || (db->mDbFlags & DBFLAG_Vacuum)!=0);\n    iDb = db->init.iDb;\n    *pUnqual = pName1;\n  }\n  return iDb;\n}\n\n/*\n** This routine is used to check if the UTF-8 string zName is a legal\n** unqualified name for a new schema object (table, index, view or\n** trigger). All names are legal except those that begin with the string\n** \"sqlite_\" (in upper, lower or mixed case). This portion of the namespace\n** is reserved for internal use.\n*/\nSQLITE_PRIVATE int sqlite3CheckObjectName(Parse *pParse, const char *zName){\n  if( !pParse->db->init.busy && pParse->nested==0 \n          && (pParse->db->flags & SQLITE_WriteSchema)==0\n          && 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"object name reserved for internal use: %s\", zName);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the PRIMARY KEY index of a table\n*/\nSQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){\n  Index *p;\n  for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}\n  return p;\n}\n\n/*\n** Return the column of index pIdx that corresponds to table\n** column iCol.  Return -1 if not found.\n*/\nSQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){\n  int i;\n  for(i=0; i<pIdx->nColumn; i++){\n    if( iCol==pIdx->aiColumn[i] ) return i;\n  }\n  return -1;\n}\n\n/*\n** Begin constructing a new table representation in memory.  This is\n** the first of several action routines that get called in response\n** to a CREATE TABLE statement.  In particular, this routine is called\n** after seeing tokens \"CREATE\" and \"TABLE\" and the table name. The isTemp\n** flag is true if the table should be stored in the auxiliary database\n** file instead of in the main database file.  This is normally the case\n** when the \"TEMP\" or \"TEMPORARY\" keyword occurs in between\n** CREATE and TABLE.\n**\n** The new table record is initialized and put in pParse->pNewTable.\n** As more of the CREATE TABLE statement is parsed, additional action\n** routines will be called to add more information to this record.\n** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine\n** is called to complete the construction of the new table record.\n*/\nSQLITE_PRIVATE void sqlite3StartTable(\n  Parse *pParse,   /* Parser context */\n  Token *pName1,   /* First part of the name of the table or view */\n  Token *pName2,   /* Second part of the name of the table or view */\n  int isTemp,      /* True if this is a TEMP table */\n  int isView,      /* True if this is a VIEW */\n  int isVirtual,   /* True if this is a VIRTUAL table */\n  int noErr        /* Do nothing if table already exists */\n){\n  Table *pTable;\n  char *zName = 0; /* The name of the new table */\n  sqlite3 *db = pParse->db;\n  Vdbe *v;\n  int iDb;         /* Database number to create the table in */\n  Token *pName;    /* Unqualified name of the table to create */\n\n  if( db->init.busy && db->init.newTnum==1 ){\n    /* Special case:  Parsing the sqlite_master or sqlite_temp_master schema */\n    iDb = db->init.iDb;\n    zName = sqlite3DbStrDup(db, SCHEMA_TABLE(iDb));\n    pName = pName1;\n  }else{\n    /* The common case */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) return;\n    if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){\n      /* If creating a temp table, the name may not be qualified. Unless \n      ** the database name is \"temp\" anyway.  */\n      sqlite3ErrorMsg(pParse, \"temporary table name must be unqualified\");\n      return;\n    }\n    if( !OMIT_TEMPDB && isTemp ) iDb = 1;\n    zName = sqlite3NameFromToken(db, pName);\n  }\n  pParse->sNameToken = *pName;\n  if( zName==0 ) return;\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto begin_table_error;\n  }\n  if( db->init.iDb==1 ) isTemp = 1;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  assert( isTemp==0 || isTemp==1 );\n  assert( isView==0 || isView==1 );\n  {\n    static const u8 aCode[] = {\n       SQLITE_CREATE_TABLE,\n       SQLITE_CREATE_TEMP_TABLE,\n       SQLITE_CREATE_VIEW,\n       SQLITE_CREATE_TEMP_VIEW\n    };\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){\n      goto begin_table_error;\n    }\n    if( !isVirtual && sqlite3AuthCheck(pParse, (int)aCode[isTemp+2*isView],\n                                       zName, 0, zDb) ){\n      goto begin_table_error;\n    }\n  }\n#endif\n\n  /* Make sure the new table name does not collide with an existing\n  ** index or table name in the same database.  Issue an error message if\n  ** it does. The exception is if the statement being parsed was passed\n  ** to an sqlite3_declare_vtab() call. In that case only the column names\n  ** and types will be used, so there is no need to test for namespace\n  ** collisions.\n  */\n  if( !IN_DECLARE_VTAB ){\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n      goto begin_table_error;\n    }\n    pTable = sqlite3FindTable(db, zName, zDb);\n    if( pTable ){\n      if( !noErr ){\n        sqlite3ErrorMsg(pParse, \"table %T already exists\", pName);\n      }else{\n        assert( !db->init.busy || CORRUPT_DB );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto begin_table_error;\n    }\n    if( sqlite3FindIndex(db, zName, zDb)!=0 ){\n      sqlite3ErrorMsg(pParse, \"there is already an index named %s\", zName);\n      goto begin_table_error;\n    }\n  }\n\n  pTable = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTable==0 ){\n    assert( db->mallocFailed );\n    pParse->rc = SQLITE_NOMEM_BKPT;\n    pParse->nErr++;\n    goto begin_table_error;\n  }\n  pTable->zName = zName;\n  pTable->iPKey = -1;\n  pTable->pSchema = db->aDb[iDb].pSchema;\n  pTable->nTabRef = 1;\n#ifdef SQLITE_DEFAULT_ROWEST\n  pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);\n#else\n  pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n#endif\n  assert( pParse->pNewTable==0 );\n  pParse->pNewTable = pTable;\n\n  /* If this is the magic sqlite_sequence table used by autoincrement,\n  ** then record a pointer to this table in the main database structure\n  ** so that INSERT can find the table easily.\n  */\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  if( !pParse->nested && strcmp(zName, \"sqlite_sequence\")==0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTable->pSchema->pSeqTab = pTable;\n  }\n#endif\n\n  /* Begin generating the code that will insert the table record into\n  ** the SQLITE_MASTER table.  Note in particular that we must go ahead\n  ** and allocate the record number for the table entry now.  Before any\n  ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause\n  ** indices to be created and the table record must come before the \n  ** indices.  Hence, the record number for the table must be allocated\n  ** now.\n  */\n  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){\n    int addr1;\n    int fileFormat;\n    int reg1, reg2, reg3;\n    /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */\n    static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( isVirtual ){\n      sqlite3VdbeAddOp0(v, OP_VBegin);\n    }\n#endif\n\n    /* If the file format and encoding in the database have not been set, \n    ** set them now.\n    */\n    reg1 = pParse->regRowid = ++pParse->nMem;\n    reg2 = pParse->regRoot = ++pParse->nMem;\n    reg3 = ++pParse->nMem;\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);\n    fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?\n                  1 : SQLITE_MAX_FILE_FORMAT;\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, ENC(db));\n    sqlite3VdbeJumpHere(v, addr1);\n\n    /* This just creates a place-holder record in the sqlite_master table.\n    ** The record created does not contain anything yet.  It will be replaced\n    ** by the real entry in code generated at sqlite3EndTable().\n    **\n    ** The rowid for the new entry is left in register pParse->regRowid.\n    ** The root page number of the new table is left in reg pParse->regRoot.\n    ** The rowid and root page number values are needed by the code that\n    ** sqlite3EndTable will generate.\n    */\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n    if( isView || isVirtual ){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);\n    }else\n#endif\n    {\n      pParse->addrCrTab =\n         sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);\n    }\n    sqlite3OpenMasterTable(pParse, iDb);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);\n    sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);\n    sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeAddOp0(v, OP_Close);\n  }\n\n  /* Normal (non-error) return. */\n  return;\n\n  /* If an error occurs, we jump here */\nbegin_table_error:\n  sqlite3DbFree(db, zName);\n  return;\n}\n\n/* Set properties of a table column based on the (magical)\n** name of the column.\n*/\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\nSQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){\n  if( sqlite3_strnicmp(pCol->zName, \"__hidden__\", 10)==0 ){\n    pCol->colFlags |= COLFLAG_HIDDEN;\n  }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){\n    pTab->tabFlags |= TF_OOOHidden;\n  }\n}\n#endif\n\n\n/*\n** Add a new column to the table currently being constructed.\n**\n** The parser calls this routine once for each column declaration\n** in a CREATE TABLE statement.  sqlite3StartTable() gets called\n** first to get things going.  Then this routine is called for each\n** column.\n*/\nSQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){\n  Table *p;\n  int i;\n  char *z;\n  char *zType;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  if( (p = pParse->pNewTable)==0 ) return;\n  if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns on %s\", p->zName);\n    return;\n  }\n  z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);\n  if( z==0 ) return;\n  memcpy(z, pName->z, pName->n);\n  z[pName->n] = 0;\n  sqlite3Dequote(z);\n  for(i=0; i<p->nCol; i++){\n    if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){\n      sqlite3ErrorMsg(pParse, \"duplicate column name: %s\", z);\n      sqlite3DbFree(db, z);\n      return;\n    }\n  }\n  if( (p->nCol & 0x7)==0 ){\n    Column *aNew;\n    aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));\n    if( aNew==0 ){\n      sqlite3DbFree(db, z);\n      return;\n    }\n    p->aCol = aNew;\n  }\n  pCol = &p->aCol[p->nCol];\n  memset(pCol, 0, sizeof(p->aCol[0]));\n  pCol->zName = z;\n  sqlite3ColumnPropertiesFromName(p, pCol);\n \n  if( pType->n==0 ){\n    /* If there is no type specified, columns have the default affinity\n    ** 'BLOB'. */\n    pCol->affinity = SQLITE_AFF_BLOB;\n    pCol->szEst = 1;\n  }else{\n    zType = z + sqlite3Strlen30(z) + 1;\n    memcpy(zType, pType->z, pType->n);\n    zType[pType->n] = 0;\n    sqlite3Dequote(zType);\n    pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);\n    pCol->colFlags |= COLFLAG_HASTYPE;\n  }\n  p->nCol++;\n  pParse->constraintName.n = 0;\n}\n\n/*\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.  A \"NOT NULL\" constraint has\n** been seen on a column.  This routine sets the notNull flag on\n** the column currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){\n  Table *p;\n  p = pParse->pNewTable;\n  if( p==0 || NEVER(p->nCol<1) ) return;\n  p->aCol[p->nCol-1].notNull = (u8)onError;\n  p->tabFlags |= TF_HasNotNull;\n}\n\n/*\n** Scan the column type name zType (length nType) and return the\n** associated affinity type.\n**\n** This routine does a case-independent search of zType for the \n** substrings in the following table. If one of the substrings is\n** found, the corresponding affinity is returned. If zType contains\n** more than one of the substrings, entries toward the top of \n** the table take priority. For example, if zType is 'BLOBINT', \n** SQLITE_AFF_INTEGER is returned.\n**\n** Substring     | Affinity\n** --------------------------------\n** 'INT'         | SQLITE_AFF_INTEGER\n** 'CHAR'        | SQLITE_AFF_TEXT\n** 'CLOB'        | SQLITE_AFF_TEXT\n** 'TEXT'        | SQLITE_AFF_TEXT\n** 'BLOB'        | SQLITE_AFF_BLOB\n** 'REAL'        | SQLITE_AFF_REAL\n** 'FLOA'        | SQLITE_AFF_REAL\n** 'DOUB'        | SQLITE_AFF_REAL\n**\n** If none of the substrings in the above table are found,\n** SQLITE_AFF_NUMERIC is returned.\n*/\nSQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){\n  u32 h = 0;\n  char aff = SQLITE_AFF_NUMERIC;\n  const char *zChar = 0;\n\n  assert( zIn!=0 );\n  while( zIn[0] ){\n    h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];\n    zIn++;\n    if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){             /* CHAR */\n      aff = SQLITE_AFF_TEXT;\n      zChar = zIn;\n    }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){       /* CLOB */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */\n        && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){\n      aff = SQLITE_AFF_BLOB;\n      if( zIn[0]=='(' ) zChar = zIn;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l')          /* REAL */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a')          /* FLOA */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b')          /* DOUB */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n#endif\n    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */\n      aff = SQLITE_AFF_INTEGER;\n      break;\n    }\n  }\n\n  /* If pszEst is not NULL, store an estimate of the field size.  The\n  ** estimate is scaled so that the size of an integer is 1.  */\n  if( pszEst ){\n    *pszEst = 1;   /* default size is approx 4 bytes */\n    if( aff<SQLITE_AFF_NUMERIC ){\n      if( zChar ){\n        while( zChar[0] ){\n          if( sqlite3Isdigit(zChar[0]) ){\n            int v = 0;\n            sqlite3GetInt32(zChar, &v);\n            v = v/4 + 1;\n            if( v>255 ) v = 255;\n            *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */\n            break;\n          }\n          zChar++;\n        }\n      }else{\n        *pszEst = 5;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/\n      }\n    }\n  }\n  return aff;\n}\n\n/*\n** The expression is the default value for the most recently added column\n** of the table currently under construction.\n**\n** Default value expressions must be constant.  Raise an exception if this\n** is not the case.\n**\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){\n  Table *p;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  p = pParse->pNewTable;\n  if( p!=0 ){\n    pCol = &(p->aCol[p->nCol-1]);\n    if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr, db->init.busy) ){\n      sqlite3ErrorMsg(pParse, \"default value of column [%s] is not constant\",\n          pCol->zName);\n    }else{\n      /* A copy of pExpr is used instead of the original, as pExpr contains\n      ** tokens that point to volatile memory. The 'span' of the expression\n      ** is required by pragma table_info.\n      */\n      Expr x;\n      sqlite3ExprDelete(db, pCol->pDflt);\n      memset(&x, 0, sizeof(x));\n      x.op = TK_SPAN;\n      x.u.zToken = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                    (int)(pSpan->zEnd - pSpan->zStart));\n      x.pLeft = pSpan->pExpr;\n      x.flags = EP_Skip;\n      pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);\n      sqlite3DbFree(db, x.u.zToken);\n    }\n  }\n  sqlite3ExprDelete(db, pSpan->pExpr);\n}\n\n/*\n** Backwards Compatibility Hack:\n** \n** Historical versions of SQLite accepted strings as column names in\n** indexes and PRIMARY KEY constraints and in UNIQUE constraints.  Example:\n**\n**     CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)\n**     CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);\n**\n** This is goofy.  But to preserve backwards compatibility we continue to\n** accept it.  This routine does the necessary conversion.  It converts\n** the expression given in its argument from a TK_STRING into a TK_ID\n** if the expression is just a TK_STRING with an optional COLLATE clause.\n** If the epxression is anything other than TK_STRING, the expression is\n** unchanged.\n*/\nstatic void sqlite3StringToId(Expr *p){\n  if( p->op==TK_STRING ){\n    p->op = TK_ID;\n  }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){\n    p->pLeft->op = TK_ID;\n  }\n}\n\n/*\n** Designate the PRIMARY KEY for the table.  pList is a list of names \n** of columns that form the primary key.  If pList is NULL, then the\n** most recently added column of the table is the primary key.\n**\n** A table can have at most one primary key.  If the table already has\n** a primary key (and this is the second primary key) then create an\n** error.\n**\n** If the PRIMARY KEY is on a single column whose datatype is INTEGER,\n** then we will try to use that column as the rowid.  Set the Table.iPKey\n** field of the table under construction to be the index of the\n** INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is\n** no INTEGER PRIMARY KEY.\n**\n** If the key is not an INTEGER PRIMARY KEY, then create a unique\n** index for the key.  No index is created for INTEGER PRIMARY KEYs.\n*/\nSQLITE_PRIVATE void sqlite3AddPrimaryKey(\n  Parse *pParse,    /* Parsing context */\n  ExprList *pList,  /* List of field names to be indexed */\n  int onError,      /* What to do with a uniqueness conflict */\n  int autoInc,      /* True if the AUTOINCREMENT keyword is present */\n  int sortOrder     /* SQLITE_SO_ASC or SQLITE_SO_DESC */\n){\n  Table *pTab = pParse->pNewTable;\n  Column *pCol = 0;\n  int iCol = -1, i;\n  int nTerm;\n  if( pTab==0 ) goto primary_key_exit;\n  if( pTab->tabFlags & TF_HasPrimaryKey ){\n    sqlite3ErrorMsg(pParse, \n      \"table \\\"%s\\\" has more than one primary key\", pTab->zName);\n    goto primary_key_exit;\n  }\n  pTab->tabFlags |= TF_HasPrimaryKey;\n  if( pList==0 ){\n    iCol = pTab->nCol - 1;\n    pCol = &pTab->aCol[iCol];\n    pCol->colFlags |= COLFLAG_PRIMKEY;\n    nTerm = 1;\n  }else{\n    nTerm = pList->nExpr;\n    for(i=0; i<nTerm; i++){\n      Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n      assert( pCExpr!=0 );\n      sqlite3StringToId(pCExpr);\n      if( pCExpr->op==TK_ID ){\n        const char *zCName = pCExpr->u.zToken;\n        for(iCol=0; iCol<pTab->nCol; iCol++){\n          if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){\n            pCol = &pTab->aCol[iCol];\n            pCol->colFlags |= COLFLAG_PRIMKEY;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( nTerm==1\n   && pCol\n   && sqlite3StrICmp(sqlite3ColumnType(pCol,\"\"), \"INTEGER\")==0\n   && sortOrder!=SQLITE_SO_DESC\n  ){\n    pTab->iPKey = iCol;\n    pTab->keyConf = (u8)onError;\n    assert( autoInc==0 || autoInc==1 );\n    pTab->tabFlags |= autoInc*TF_Autoincrement;\n    if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;\n  }else if( autoInc ){\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    sqlite3ErrorMsg(pParse, \"AUTOINCREMENT is only allowed on an \"\n       \"INTEGER PRIMARY KEY\");\n#endif\n  }else{\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,\n                           0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);\n    pList = 0;\n  }\n\nprimary_key_exit:\n  sqlite3ExprListDelete(pParse->db, pList);\n  return;\n}\n\n/*\n** Add a new CHECK constraint to the table currently under construction.\n*/\nSQLITE_PRIVATE void sqlite3AddCheckConstraint(\n  Parse *pParse,    /* Parsing context */\n  Expr *pCheckExpr  /* The check expression */\n){\n#ifndef SQLITE_OMIT_CHECK\n  Table *pTab = pParse->pNewTable;\n  sqlite3 *db = pParse->db;\n  if( pTab && !IN_DECLARE_VTAB\n   && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)\n  ){\n    pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);\n    if( pParse->constraintName.n ){\n      sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);\n    }\n  }else\n#endif\n  {\n    sqlite3ExprDelete(pParse->db, pCheckExpr);\n  }\n}\n\n/*\n** Set the collation function of the most recently parsed table column\n** to the CollSeq given.\n*/\nSQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){\n  Table *p;\n  int i;\n  char *zColl;              /* Dequoted name of collation sequence */\n  sqlite3 *db;\n\n  if( (p = pParse->pNewTable)==0 ) return;\n  i = p->nCol-1;\n  db = pParse->db;\n  zColl = sqlite3NameFromToken(db, pToken);\n  if( !zColl ) return;\n\n  if( sqlite3LocateCollSeq(pParse, zColl) ){\n    Index *pIdx;\n    sqlite3DbFree(db, p->aCol[i].zColl);\n    p->aCol[i].zColl = zColl;\n  \n    /* If the column is declared as \"<name> PRIMARY KEY COLLATE <type>\",\n    ** then an index may have been created on this column before the\n    ** collation type was added. Correct this if it is the case.\n    */\n    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->nKeyCol==1 );\n      if( pIdx->aiColumn[0]==i ){\n        pIdx->azColl[0] = p->aCol[i].zColl;\n      }\n    }\n  }else{\n    sqlite3DbFree(db, zColl);\n  }\n}\n\n/*\n** This function returns the collation sequence for database native text\n** encoding identified by the string zName, length nName.\n**\n** If the requested collation sequence is not available, or not available\n** in the database native encoding, the collation factory is invoked to\n** request it. If the collation factory does not supply such a sequence,\n** and the sequence is available in another text encoding, then that is\n** returned instead.\n**\n** If no versions of the requested collations sequence are available, or\n** another error occurs, NULL is returned and an error message written into\n** pParse.\n**\n** This routine is a wrapper around sqlite3FindCollSeq().  This routine\n** invokes the collation factory if the named collation cannot be found\n** and generates an error message.\n**\n** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){\n  sqlite3 *db = pParse->db;\n  u8 enc = ENC(db);\n  u8 initbusy = db->init.busy;\n  CollSeq *pColl;\n\n  pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);\n  if( !initbusy && (!pColl || !pColl->xCmp) ){\n    pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);\n  }\n\n  return pColl;\n}\n\n\n/*\n** Generate code that will increment the schema cookie.\n**\n** The schema cookie is used to determine when the schema for the\n** database changes.  After each schema change, the cookie value\n** changes.  When a process first reads the schema it records the\n** cookie.  Thereafter, whenever it goes to access the database,\n** it checks the cookie to make sure the schema has not changed\n** since it was last read.\n**\n** This plan is not completely bullet-proof.  It is possible for\n** the schema to change multiple times and for the cookie to be\n** set back to prior value.  But schema changes are infrequent\n** and the probability of hitting the same cookie value is only\n** 1 chance in 2^32.  So we're safe enough.\n**\n** IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments\n** the schema-version whenever the schema changes.\n*/\nSQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, \n                    db->aDb[iDb].pSchema->schema_cookie+1);\n}\n\n/*\n** Measure the number of characters needed to output the given\n** identifier.  The number returned includes any quotes used\n** but does not include the null terminator.\n**\n** The estimate is conservative.  It might be larger that what is\n** really needed.\n*/\nstatic int identLength(const char *z){\n  int n;\n  for(n=0; *z; n++, z++){\n    if( *z=='\"' ){ n++; }\n  }\n  return n + 2;\n}\n\n/*\n** The first parameter is a pointer to an output buffer. The second \n** parameter is a pointer to an integer that contains the offset at\n** which to write into the output buffer. This function copies the\n** nul-terminated string pointed to by the third parameter, zSignedIdent,\n** to the specified offset in the buffer and updates *pIdx to refer\n** to the first byte after the last byte written before returning.\n** \n** If the string zSignedIdent consists entirely of alpha-numeric\n** characters, does not begin with a digit and is not an SQL keyword,\n** then it is copied to the output buffer exactly as it is. Otherwise,\n** it is quoted using double-quotes.\n*/\nstatic void identPut(char *z, int *pIdx, char *zSignedIdent){\n  unsigned char *zIdent = (unsigned char*)zSignedIdent;\n  int i, j, needQuote;\n  i = *pIdx;\n\n  for(j=0; zIdent[j]; j++){\n    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;\n  }\n  needQuote = sqlite3Isdigit(zIdent[0])\n            || sqlite3KeywordCode(zIdent, j)!=TK_ID\n            || zIdent[j]!=0\n            || j==0;\n\n  if( needQuote ) z[i++] = '\"';\n  for(j=0; zIdent[j]; j++){\n    z[i++] = zIdent[j];\n    if( zIdent[j]=='\"' ) z[i++] = '\"';\n  }\n  if( needQuote ) z[i++] = '\"';\n  z[i] = 0;\n  *pIdx = i;\n}\n\n/*\n** Generate a CREATE TABLE statement appropriate for the given\n** table.  Memory to hold the text of the statement is obtained\n** from sqliteMalloc() and must be freed by the calling function.\n*/\nstatic char *createTableStmt(sqlite3 *db, Table *p){\n  int i, k, n;\n  char *zStmt;\n  char *zSep, *zSep2, *zEnd;\n  Column *pCol;\n  n = 0;\n  for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){\n    n += identLength(pCol->zName) + 5;\n  }\n  n += identLength(p->zName);\n  if( n<50 ){ \n    zSep = \"\";\n    zSep2 = \",\";\n    zEnd = \")\";\n  }else{\n    zSep = \"\\n  \";\n    zSep2 = \",\\n  \";\n    zEnd = \"\\n)\";\n  }\n  n += 35 + 6*p->nCol;\n  zStmt = sqlite3DbMallocRaw(0, n);\n  if( zStmt==0 ){\n    sqlite3OomFault(db);\n    return 0;\n  }\n  sqlite3_snprintf(n, zStmt, \"CREATE TABLE \");\n  k = sqlite3Strlen30(zStmt);\n  identPut(zStmt, &k, p->zName);\n  zStmt[k++] = '(';\n  for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){\n    static const char * const azType[] = {\n        /* SQLITE_AFF_BLOB    */ \"\",\n        /* SQLITE_AFF_TEXT    */ \" TEXT\",\n        /* SQLITE_AFF_NUMERIC */ \" NUM\",\n        /* SQLITE_AFF_INTEGER */ \" INT\",\n        /* SQLITE_AFF_REAL    */ \" REAL\"\n    };\n    int len;\n    const char *zType;\n\n    sqlite3_snprintf(n-k, &zStmt[k], zSep);\n    k += sqlite3Strlen30(&zStmt[k]);\n    zSep = zSep2;\n    identPut(zStmt, &k, pCol->zName);\n    assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );\n    assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );\n    testcase( pCol->affinity==SQLITE_AFF_BLOB );\n    testcase( pCol->affinity==SQLITE_AFF_TEXT );\n    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );\n    testcase( pCol->affinity==SQLITE_AFF_INTEGER );\n    testcase( pCol->affinity==SQLITE_AFF_REAL );\n    \n    zType = azType[pCol->affinity - SQLITE_AFF_BLOB];\n    len = sqlite3Strlen30(zType);\n    assert( pCol->affinity==SQLITE_AFF_BLOB \n            || pCol->affinity==sqlite3AffinityType(zType, 0) );\n    memcpy(&zStmt[k], zType, len);\n    k += len;\n    assert( k<=n );\n  }\n  sqlite3_snprintf(n-k, &zStmt[k], \"%s\", zEnd);\n  return zStmt;\n}\n\n/*\n** Resize an Index object to hold N columns total.  Return SQLITE_OK\n** on success and SQLITE_NOMEM on an OOM error.\n*/\nstatic int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){\n  char *zExtra;\n  int nByte;\n  if( pIdx->nColumn>=N ) return SQLITE_OK;\n  assert( pIdx->isResized==0 );\n  nByte = (sizeof(char*) + sizeof(i16) + 1)*N;\n  zExtra = sqlite3DbMallocZero(db, nByte);\n  if( zExtra==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);\n  pIdx->azColl = (const char**)zExtra;\n  zExtra += sizeof(char*)*N;\n  memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);\n  pIdx->aiColumn = (i16*)zExtra;\n  zExtra += sizeof(i16)*N;\n  memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);\n  pIdx->aSortOrder = (u8*)zExtra;\n  pIdx->nColumn = N;\n  pIdx->isResized = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Estimate the total row width for a table.\n*/\nstatic void estimateTableWidth(Table *pTab){\n  unsigned wTable = 0;\n  const Column *pTabCol;\n  int i;\n  for(i=pTab->nCol, pTabCol=pTab->aCol; i>0; i--, pTabCol++){\n    wTable += pTabCol->szEst;\n  }\n  if( pTab->iPKey<0 ) wTable++;\n  pTab->szTabRow = sqlite3LogEst(wTable*4);\n}\n\n/*\n** Estimate the average size of a row for an index.\n*/\nstatic void estimateIndexWidth(Index *pIdx){\n  unsigned wIndex = 0;\n  int i;\n  const Column *aCol = pIdx->pTable->aCol;\n  for(i=0; i<pIdx->nColumn; i++){\n    i16 x = pIdx->aiColumn[i];\n    assert( x<pIdx->pTable->nCol );\n    wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;\n  }\n  pIdx->szIdxRow = sqlite3LogEst(wIndex*4);\n}\n\n/* Return true if value x is found any of the first nCol entries of aiCol[]\n*/\nstatic int hasColumn(const i16 *aiCol, int nCol, int x){\n  while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;\n  return 0;\n}\n\n/*\n** This routine runs at the end of parsing a CREATE TABLE statement that\n** has a WITHOUT ROWID clause.  The job of this routine is to convert both\n** internal schema data structures and the generated VDBE code so that they\n** are appropriate for a WITHOUT ROWID table instead of a rowid table.\n** Changes include:\n**\n**     (1)  Set all columns of the PRIMARY KEY schema object to be NOT NULL.\n**     (2)  Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY \n**          into BTREE_BLOBKEY.\n**     (3)  Bypass the creation of the sqlite_master table entry\n**          for the PRIMARY KEY as the primary key index is now\n**          identified by the sqlite_master table entry of the table itself.\n**     (4)  Set the Index.tnum of the PRIMARY KEY Index object in the\n**          schema to the rootpage from the main table.\n**     (5)  Add all table columns to the PRIMARY KEY Index object\n**          so that the PRIMARY KEY is a covering index.  The surplus\n**          columns are part of KeyInfo.nAllField and are not used for\n**          sorting or lookup or uniqueness checks.\n**     (6)  Replace the rowid tail on all automatically generated UNIQUE\n**          indices with the PRIMARY KEY columns.\n**\n** For virtual tables, only (1) is performed.\n*/\nstatic void convertToWithoutRowidTable(Parse *pParse, Table *pTab){\n  Index *pIdx;\n  Index *pPk;\n  int nPk;\n  int i, j;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n\n  /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)\n  */\n  if( !db->init.imposterTable ){\n    for(i=0; i<pTab->nCol; i++){\n      if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){\n        pTab->aCol[i].notNull = OE_Abort;\n      }\n    }\n  }\n\n  /* The remaining transformations only apply to b-tree tables, not to\n  ** virtual tables */\n  if( IN_DECLARE_VTAB ) return;\n\n  /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY\n  ** into BTREE_BLOBKEY.\n  */\n  if( pParse->addrCrTab ){\n    assert( v );\n    sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY);\n  }\n\n  /* Locate the PRIMARY KEY index.  Or, if this table was originally\n  ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. \n  */\n  if( pTab->iPKey>=0 ){\n    ExprList *pList;\n    Token ipkToken;\n    sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);\n    pList = sqlite3ExprListAppend(pParse, 0, \n                  sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));\n    if( pList==0 ) return;\n    pList->a[0].sortOrder = pParse->iPkSortOrder;\n    assert( pParse->pNewTable==pTab );\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,\n                       SQLITE_IDXTYPE_PRIMARYKEY);\n    if( db->mallocFailed ) return;\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    pTab->iPKey = -1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n\n    /*\n    ** Remove all redundant columns from the PRIMARY KEY.  For example, change\n    ** \"PRIMARY KEY(a,b,a,b,c,b,c,d)\" into just \"PRIMARY KEY(a,b,c,d)\".  Later\n    ** code assumes the PRIMARY KEY contains no repeated columns.\n    */\n    for(i=j=1; i<pPk->nKeyCol; i++){\n      if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){\n        pPk->nColumn--;\n      }else{\n        pPk->aiColumn[j++] = pPk->aiColumn[i];\n      }\n    }\n    pPk->nKeyCol = j;\n  }\n  assert( pPk!=0 );\n  pPk->isCovering = 1;\n  if( !db->init.imposterTable ) pPk->uniqNotNull = 1;\n  nPk = pPk->nKeyCol;\n\n  /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master\n  ** table entry. This is only required if currently generating VDBE\n  ** code for a CREATE TABLE (not when parsing one as part of reading\n  ** a database schema).  */\n  if( v && pPk->tnum>0 ){\n    assert( db->init.busy==0 );\n    sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);\n  }\n\n  /* The root page of the PRIMARY KEY is the table root page */\n  pPk->tnum = pTab->tnum;\n\n  /* Update the in-memory representation of all UNIQUE indices by converting\n  ** the final rowid column into one or more columns of the PRIMARY KEY.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int n;\n    if( IsPrimaryKeyIndex(pIdx) ) continue;\n    for(i=n=0; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;\n    }\n    if( n==0 ){\n      /* This index is a superset of the primary key */\n      pIdx->nColumn = pIdx->nKeyCol;\n      continue;\n    }\n    if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;\n    for(i=0, j=pIdx->nKeyCol; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){\n        pIdx->aiColumn[j] = pPk->aiColumn[i];\n        pIdx->azColl[j] = pPk->azColl[i];\n        j++;\n      }\n    }\n    assert( pIdx->nColumn>=pIdx->nKeyCol+n );\n    assert( pIdx->nColumn>=j );\n  }\n\n  /* Add all table columns to the PRIMARY KEY index\n  */\n  if( nPk<pTab->nCol ){\n    if( resizeIndexObject(db, pPk, pTab->nCol) ) return;\n    for(i=0, j=nPk; i<pTab->nCol; i++){\n      if( !hasColumn(pPk->aiColumn, j, i) ){\n        assert( j<pPk->nColumn );\n        pPk->aiColumn[j] = i;\n        pPk->azColl[j] = sqlite3StrBINARY;\n        j++;\n      }\n    }\n    assert( pPk->nColumn==j );\n    assert( pTab->nCol==j );\n  }else{\n    pPk->nColumn = pTab->nCol;\n  }\n}\n\n/*\n** This routine is called to report the final \")\" that terminates\n** a CREATE TABLE statement.\n**\n** The table structure that other action routines have been building\n** is added to the internal hash tables, assuming no errors have\n** occurred.\n**\n** An entry for the table is made in the master table on disk, unless\n** this is a temporary table or db->init.busy==1.  When db->init.busy==1\n** it means we are reading the sqlite_master table because we just\n** connected to the database or because the sqlite_master table has\n** recently changed, so the entry for this table already exists in\n** the sqlite_master table.  We do not want to create it again.\n**\n** If the pSelect argument is not NULL, it means that this routine\n** was called to create a table generated from a \n** \"CREATE TABLE ... AS SELECT ...\" statement.  The column names of\n** the new table will match the result set of the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3EndTable(\n  Parse *pParse,          /* Parse context */\n  Token *pCons,           /* The ',' token after the last column defn. */\n  Token *pEnd,            /* The ')' before options in the CREATE TABLE */\n  u8 tabOpts,             /* Extra table options. Usually 0. */\n  Select *pSelect         /* Select from a \"CREATE ... AS SELECT\" */\n){\n  Table *p;                 /* The new table */\n  sqlite3 *db = pParse->db; /* The database connection */\n  int iDb;                  /* Database in which the table lives */\n  Index *pIdx;              /* An implied index of the table */\n\n  if( pEnd==0 && pSelect==0 ){\n    return;\n  }\n  assert( !db->mallocFailed );\n  p = pParse->pNewTable;\n  if( p==0 ) return;\n\n  assert( !db->init.busy || !pSelect );\n\n  /* If the db->init.busy is 1 it means we are reading the SQL off the\n  ** \"sqlite_master\" or \"sqlite_temp_master\" table on the disk.\n  ** So do not write to the disk again.  Extract the root page number\n  ** for the table from the db->init.newTnum field.  (The page number\n  ** should have been put there by the sqliteOpenCb routine.)\n  **\n  ** If the root page number is 1, that means this is the sqlite_master\n  ** table itself.  So mark it read-only.\n  */\n  if( db->init.busy ){\n    p->tnum = db->init.newTnum;\n    if( p->tnum==1 ) p->tabFlags |= TF_Readonly;\n  }\n\n  /* Special processing for WITHOUT ROWID Tables */\n  if( tabOpts & TF_WithoutRowid ){\n    if( (p->tabFlags & TF_Autoincrement) ){\n      sqlite3ErrorMsg(pParse,\n          \"AUTOINCREMENT not allowed on WITHOUT ROWID tables\");\n      return;\n    }\n    if( (p->tabFlags & TF_HasPrimaryKey)==0 ){\n      sqlite3ErrorMsg(pParse, \"PRIMARY KEY missing on table %s\", p->zName);\n    }else{\n      p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;\n      convertToWithoutRowidTable(pParse, p);\n    }\n  }\n\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n\n#ifndef SQLITE_OMIT_CHECK\n  /* Resolve names in all CHECK constraint expressions.\n  */\n  if( p->pCheck ){\n    sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* Estimate the average row size for the table and for all implied indices */\n  estimateTableWidth(p);\n  for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n    estimateIndexWidth(pIdx);\n  }\n\n  /* If not initializing, then create a record for the new table\n  ** in the SQLITE_MASTER table of the database.\n  **\n  ** If this is a TEMPORARY table, write the entry into the auxiliary\n  ** file instead of into the main database file.\n  */\n  if( !db->init.busy ){\n    int n;\n    Vdbe *v;\n    char *zType;    /* \"view\" or \"table\" */\n    char *zType2;   /* \"VIEW\" or \"TABLE\" */\n    char *zStmt;    /* Text of the CREATE TABLE or CREATE VIEW statement */\n\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;\n\n    sqlite3VdbeAddOp1(v, OP_Close, 0);\n\n    /* \n    ** Initialize zType for the new view or table.\n    */\n    if( p->pSelect==0 ){\n      /* A regular table */\n      zType = \"table\";\n      zType2 = \"TABLE\";\n#ifndef SQLITE_OMIT_VIEW\n    }else{\n      /* A view */\n      zType = \"view\";\n      zType2 = \"VIEW\";\n#endif\n    }\n\n    /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT\n    ** statement to populate the new table. The root-page number for the\n    ** new table is in register pParse->regRoot.\n    **\n    ** Once the SELECT has been coded by sqlite3Select(), it is in a\n    ** suitable state to query for the column names and types to be used\n    ** by the new table.\n    **\n    ** A shared-cache write-lock is not required to write to the new table,\n    ** as a schema-lock must have already been obtained to create it. Since\n    ** a schema-lock excludes all other database users, the write-lock would\n    ** be redundant.\n    */\n    if( pSelect ){\n      SelectDest dest;    /* Where the SELECT should store results */\n      int regYield;       /* Register holding co-routine entry-point */\n      int addrTop;        /* Top of the co-routine */\n      int regRec;         /* A record to be insert into the new table */\n      int regRowid;       /* Rowid of the next row to insert */\n      int addrInsLoop;    /* Top of the loop for inserting rows */\n      Table *pSelTab;     /* A table that describes the SELECT results */\n\n      regYield = ++pParse->nMem;\n      regRec = ++pParse->nMem;\n      regRowid = ++pParse->nMem;\n      assert(pParse->nTab==1);\n      sqlite3MayAbort(pParse);\n      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);\n      sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);\n      pParse->nTab = 2;\n      addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n      sqlite3Select(pParse, pSelect, &dest);\n      sqlite3VdbeEndCoroutine(v, regYield);\n      sqlite3VdbeJumpHere(v, addrTop - 1);\n      if( pParse->nErr ) return;\n      pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);\n      if( pSelTab==0 ) return;\n      assert( p->aCol==0 );\n      p->nCol = pSelTab->nCol;\n      p->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      sqlite3DeleteTable(db, pSelTab);\n      addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);\n      sqlite3TableAffinity(v, p, 0);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);\n      sqlite3VdbeGoto(v, addrInsLoop);\n      sqlite3VdbeJumpHere(v, addrInsLoop);\n      sqlite3VdbeAddOp1(v, OP_Close, 1);\n    }\n\n    /* Compute the complete text of the CREATE statement */\n    if( pSelect ){\n      zStmt = createTableStmt(db, p);\n    }else{\n      Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;\n      n = (int)(pEnd2->z - pParse->sNameToken.z);\n      if( pEnd2->z[0]!=';' ) n += pEnd2->n;\n      zStmt = sqlite3MPrintf(db, \n          \"CREATE %s %.*s\", zType2, n, pParse->sNameToken.z\n      );\n    }\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.\n    */\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      zType,\n      p->zName,\n      p->zName,\n      pParse->regRoot,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    sqlite3ChangeCookie(pParse, iDb);\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    /* Check to see if we need to create an sqlite_sequence table for\n    ** keeping track of autoincrement keys.\n    */\n    if( (p->tabFlags & TF_Autoincrement)!=0 ){\n      Db *pDb = &db->aDb[iDb];\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      if( pDb->pSchema->pSeqTab==0 ){\n        sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.sqlite_sequence(name,seq)\",\n          pDb->zDbSName\n        );\n      }\n    }\n#endif\n\n    /* Reparse everything to update our internal data structures */\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n           sqlite3MPrintf(db, \"tbl_name='%q' AND type!='trigger'\", p->zName));\n  }\n\n\n  /* Add the table to the in-memory representation of the database.\n  */\n  if( db->init.busy ){\n    Table *pOld;\n    Schema *pSchema = p->pSchema;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);\n    if( pOld ){\n      assert( p==pOld );  /* Malloc must have failed inside HashInsert() */\n      sqlite3OomFault(db);\n      return;\n    }\n    pParse->pNewTable = 0;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n    if( !p->pSelect ){\n      const char *zName = (const char *)pParse->sNameToken.z;\n      int nName;\n      assert( !pSelect && pCons && pEnd );\n      if( pCons->z==0 ){\n        pCons = pEnd;\n      }\n      nName = (int)((const char *)pCons->z - zName);\n      p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);\n    }\n#endif\n  }\n}\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** The parser calls this routine in order to create a new VIEW\n*/\nSQLITE_PRIVATE void sqlite3CreateView(\n  Parse *pParse,     /* The parsing context */\n  Token *pBegin,     /* The CREATE token that begins the statement */\n  Token *pName1,     /* The token that holds the name of the view */\n  Token *pName2,     /* The token that holds the name of the view */\n  ExprList *pCNames, /* Optional list of view column names */\n  Select *pSelect,   /* A SELECT statement that will become the new view */\n  int isTemp,        /* TRUE for a TEMPORARY view */\n  int noErr          /* Suppress error messages if VIEW already exists */\n){\n  Table *p;\n  int n;\n  const char *z;\n  Token sEnd;\n  DbFixer sFix;\n  Token *pName = 0;\n  int iDb;\n  sqlite3 *db = pParse->db;\n\n  if( pParse->nVar>0 ){\n    sqlite3ErrorMsg(pParse, \"parameters are not allowed in views\");\n    goto create_view_fail;\n  }\n  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);\n  p = pParse->pNewTable;\n  if( p==0 || pParse->nErr ) goto create_view_fail;\n  sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n  sqlite3FixInit(&sFix, pParse, iDb, \"view\", pName);\n  if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;\n\n  /* Make a copy of the entire SELECT statement that defines the view.\n  ** This will force all the Expr.token.z values to be dynamically\n  ** allocated rather than point to the input string - which means that\n  ** they will persist after the current sqlite3_exec() call returns.\n  */\n  p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n  p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);\n  if( db->mallocFailed ) goto create_view_fail;\n\n  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to\n  ** the end.\n  */\n  sEnd = pParse->sLastToken;\n  assert( sEnd.z[0]!=0 );\n  if( sEnd.z[0]!=';' ){\n    sEnd.z += sEnd.n;\n  }\n  sEnd.n = 0;\n  n = (int)(sEnd.z - pBegin->z);\n  assert( n>0 );\n  z = pBegin->z;\n  while( sqlite3Isspace(z[n-1]) ){ n--; }\n  sEnd.z = &z[n-1];\n  sEnd.n = 1;\n\n  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */\n  sqlite3EndTable(pParse, 0, &sEnd, 0, 0);\n\ncreate_view_fail:\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3ExprListDelete(db, pCNames);\n  return;\n}\n#endif /* SQLITE_OMIT_VIEW */\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n/*\n** The Table structure pTable is really a VIEW.  Fill in the names of\n** the columns of the view in the pTable structure.  Return the number\n** of errors.  If an error is seen leave an error message in pParse->zErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){\n  Table *pSelTab;   /* A fake table from which we get the result set */\n  Select *pSel;     /* Copy of the SELECT that implements the view */\n  int nErr = 0;     /* Number of errors encountered */\n  int n;            /* Temporarily holds the number of cursors assigned */\n  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\t\n  int rc;\n#endif\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;       /* Saved xAuth pointer */\n#endif\n\n  assert( pTable );\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  db->nSchemaLock++;\n  rc = sqlite3VtabCallConnect(pParse, pTable);\n  db->nSchemaLock--;\n  if( rc ){\n    return 1;\n  }\n  if( IsVirtual(pTable) ) return 0;\n#endif\n\n#ifndef SQLITE_OMIT_VIEW\n  /* A positive nCol means the columns names for this view are\n  ** already known.\n  */\n  if( pTable->nCol>0 ) return 0;\n\n  /* A negative nCol is a special marker meaning that we are currently\n  ** trying to compute the column names.  If we enter this routine with\n  ** a negative nCol, it means two or more views form a loop, like this:\n  **\n  **     CREATE VIEW one AS SELECT * FROM two;\n  **     CREATE VIEW two AS SELECT * FROM one;\n  **\n  ** Actually, the error above is now caught prior to reaching this point.\n  ** But the following test is still important as it does come up\n  ** in the following:\n  ** \n  **     CREATE TABLE main.ex1(a);\n  **     CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;\n  **     SELECT * FROM temp.ex1;\n  */\n  if( pTable->nCol<0 ){\n    sqlite3ErrorMsg(pParse, \"view %s is circularly defined\", pTable->zName);\n    return 1;\n  }\n  assert( pTable->nCol>=0 );\n\n  /* If we get this far, it means we need to compute the table names.\n  ** Note that the call to sqlite3ResultSetOfSelect() will expand any\n  ** \"*\" elements in the results set of the view and will assign cursors\n  ** to the elements of the FROM clause.  But we do not want these changes\n  ** to be permanent.  So the computation is done on a copy of the SELECT\n  ** statement that defines the view.\n  */\n  assert( pTable->pSelect );\n  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);\n  if( pSel ){\n    n = pParse->nTab;\n    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);\n    pTable->nCol = -1;\n    db->lookaside.bDisable++;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    xAuth = db->xAuth;\n    db->xAuth = 0;\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n    db->xAuth = xAuth;\n#else\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n#endif\n    pParse->nTab = n;\n    if( pTable->pCheck ){\n      /* CREATE VIEW name(arglist) AS ...\n      ** The names of the columns in the table are taken from\n      ** arglist which is stored in pTable->pCheck.  The pCheck field\n      ** normally holds CHECK constraints on an ordinary table, but for\n      ** a VIEW it holds the list of column names.\n      */\n      sqlite3ColumnsFromExprList(pParse, pTable->pCheck, \n                                 &pTable->nCol, &pTable->aCol);\n      if( db->mallocFailed==0 \n       && pParse->nErr==0\n       && pTable->nCol==pSel->pEList->nExpr\n      ){\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);\n      }\n    }else if( pSelTab ){\n      /* CREATE VIEW name AS...  without an argument list.  Construct\n      ** the column names from the SELECT statement that defines the view.\n      */\n      assert( pTable->aCol==0 );\n      pTable->nCol = pSelTab->nCol;\n      pTable->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );\n    }else{\n      pTable->nCol = 0;\n      nErr++;\n    }\n    sqlite3DeleteTable(db, pSelTab);\n    sqlite3SelectDelete(db, pSel);\n    db->lookaside.bDisable--;\n  } else {\n    nErr++;\n  }\n  pTable->pSchema->schemaFlags |= DB_UnresetViews;\n#endif /* SQLITE_OMIT_VIEW */\n  return nErr;  \n}\n#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** Clear the column names from every VIEW in database idx.\n*/\nstatic void sqliteViewResetAll(sqlite3 *db, int idx){\n  HashElem *i;\n  assert( sqlite3SchemaMutexHeld(db, idx, 0) );\n  if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;\n  for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    if( pTab->pSelect ){\n      sqlite3DeleteColumnNames(db, pTab);\n      pTab->aCol = 0;\n      pTab->nCol = 0;\n    }\n  }\n  DbClearProperty(db, idx, DB_UnresetViews);\n}\n#else\n# define sqliteViewResetAll(A,B)\n#endif /* SQLITE_OMIT_VIEW */\n\n/*\n** This function is called by the VDBE to adjust the internal schema\n** used by SQLite when the btree layer moves a table root page. The\n** root-page of a table or index in database iDb has changed from iFrom\n** to iTo.\n**\n** Ticket #1728:  The symbol table might still contain information\n** on tables and/or indices that are the process of being deleted.\n** If you are unlucky, one of those deleted indices or tables might\n** have the same rootpage number as the real table or index that is\n** being moved.  So we cannot stop searching after the first match \n** because the first match might be for one of the deleted indices\n** or tables and not the table/index that is actually being moved.\n** We must continue looping until all tables and indices with\n** rootpage==iFrom have been converted to have a rootpage of iTo\n** in order to be certain that we got the right one.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\nSQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){\n  HashElem *pElem;\n  Hash *pHash;\n  Db *pDb;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pDb = &db->aDb[iDb];\n  pHash = &pDb->pSchema->tblHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    if( pTab->tnum==iFrom ){\n      pTab->tnum = iTo;\n    }\n  }\n  pHash = &pDb->pSchema->idxHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Index *pIdx = sqliteHashData(pElem);\n    if( pIdx->tnum==iFrom ){\n      pIdx->tnum = iTo;\n    }\n  }\n}\n#endif\n\n/*\n** Write code to erase the table with root-page iTable from database iDb.\n** Also write code to modify the sqlite_master table and internal schema\n** if a root-page of another table is moved by the btree-layer whilst\n** erasing iTable (this can happen with an auto-vacuum database).\n*/ \nstatic void destroyRootPage(Parse *pParse, int iTable, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int r1 = sqlite3GetTempReg(pParse);\n  assert( iTable>1 );\n  sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);\n  sqlite3MayAbort(pParse);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* OP_Destroy stores an in integer r1. If this integer\n  ** is non-zero, then it is the root page number of a table moved to\n  ** location iTable. The following code modifies the sqlite_master table to\n  ** reflect this.\n  **\n  ** The \"#NNN\" in the SQL is a special constant that means whatever value\n  ** is in register NNN.  See grammar rules associated with the TK_REGISTER\n  ** token for additional information.\n  */\n  sqlite3NestedParse(pParse, \n     \"UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d\",\n     pParse->db->aDb[iDb].zDbSName, MASTER_NAME, iTable, r1, r1);\n#endif\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** Write VDBE code to erase table pTab and all associated indices on disk.\n** Code to update the sqlite_master tables and internal schema definitions\n** in case a root-page belonging to another table is moved by the btree layer\n** is also added (this can happen with an auto-vacuum database).\n*/\nstatic void destroyTable(Parse *pParse, Table *pTab){\n  /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM\n  ** is not defined), then it is important to call OP_Destroy on the\n  ** table and index root-pages in order, starting with the numerically \n  ** largest root-page number. This guarantees that none of the root-pages\n  ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the\n  ** following were coded:\n  **\n  ** OP_Destroy 4 0\n  ** ...\n  ** OP_Destroy 5 0\n  **\n  ** and root page 5 happened to be the largest root-page number in the\n  ** database, then root page 5 would be moved to page 4 by the \n  ** \"OP_Destroy 4 0\" opcode. The subsequent \"OP_Destroy 5 0\" would hit\n  ** a free-list page.\n  */\n  int iTab = pTab->tnum;\n  int iDestroyed = 0;\n\n  while( 1 ){\n    Index *pIdx;\n    int iLargest = 0;\n\n    if( iDestroyed==0 || iTab<iDestroyed ){\n      iLargest = iTab;\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int iIdx = pIdx->tnum;\n      assert( pIdx->pSchema==pTab->pSchema );\n      if( (iDestroyed==0 || (iIdx<iDestroyed)) && iIdx>iLargest ){\n        iLargest = iIdx;\n      }\n    }\n    if( iLargest==0 ){\n      return;\n    }else{\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      assert( iDb>=0 && iDb<pParse->db->nDb );\n      destroyRootPage(pParse, iLargest, iDb);\n      iDestroyed = iLargest;\n    }\n  }\n}\n\n/*\n** Remove entries from the sqlite_statN tables (for N in (1,2,3))\n** after a DROP INDEX or DROP TABLE command.\n*/\nstatic void sqlite3ClearStatTables(\n  Parse *pParse,         /* The parsing context */\n  int iDb,               /* The database number */\n  const char *zType,     /* \"idx\" or \"tbl\" */\n  const char *zName      /* Name of index or table */\n){\n  int i;\n  const char *zDbName = pParse->db->aDb[iDb].zDbSName;\n  for(i=1; i<=4; i++){\n    char zTab[24];\n    sqlite3_snprintf(sizeof(zTab),zTab,\"sqlite_stat%d\",i);\n    if( sqlite3FindTable(pParse->db, zTab, zDbName) ){\n      sqlite3NestedParse(pParse,\n        \"DELETE FROM %Q.%s WHERE %s=%Q\",\n        zDbName, zTab, zType, zName\n      );\n    }\n  }\n}\n\n/*\n** Generate code to drop a table.\n*/\nSQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  Trigger *pTrigger;\n  Db *pDb = &db->aDb[iDb];\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp0(v, OP_VBegin);\n  }\n#endif\n\n  /* Drop all triggers associated with the table being dropped. Code\n  ** is generated to remove entries from sqlite_master and/or\n  ** sqlite_temp_master if required.\n  */\n  pTrigger = sqlite3TriggerList(pParse, pTab);\n  while( pTrigger ){\n    assert( pTrigger->pSchema==pTab->pSchema || \n        pTrigger->pSchema==db->aDb[1].pSchema );\n    sqlite3DropTriggerPtr(pParse, pTrigger);\n    pTrigger = pTrigger->pNext;\n  }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* Remove any entries of the sqlite_sequence table associated with\n  ** the table being dropped. This is done before the table is dropped\n  ** at the btree level, in case the sqlite_sequence table needs to\n  ** move as a result of the drop (can happen in auto-vacuum mode).\n  */\n  if( pTab->tabFlags & TF_Autoincrement ){\n    sqlite3NestedParse(pParse,\n      \"DELETE FROM %Q.sqlite_sequence WHERE name=%Q\",\n      pDb->zDbSName, pTab->zName\n    );\n  }\n#endif\n\n  /* Drop all SQLITE_MASTER table and index entries that refer to the\n  ** table. The program name loops through the master table and deletes\n  ** every row that refers to a table of the same name as the one being\n  ** dropped. Triggers are handled separately because a trigger can be\n  ** created in the temp database that refers to a table in another\n  ** database.\n  */\n  sqlite3NestedParse(pParse, \n      \"DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'\",\n      pDb->zDbSName, MASTER_NAME, pTab->zName);\n  if( !isView && !IsVirtual(pTab) ){\n    destroyTable(pParse, pTab);\n  }\n\n  /* Remove the table entry from SQLite's internal schema and modify\n  ** the schema cookie.\n  */\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);\n  }\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n  sqlite3ChangeCookie(pParse, iDb);\n  sqliteViewResetAll(db, iDb);\n}\n\n/*\n** This routine is called to do the work of a DROP TABLE statement.\n** pName is the name of the table to be dropped.\n*/\nSQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){\n  Table *pTab;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  if( db->mallocFailed ){\n    goto exit_drop_table;\n  }\n  assert( pParse->nErr==0 );\n  assert( pName->nSrc==1 );\n  if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;\n  if( noErr ) db->suppressErr++;\n  assert( isView==0 || isView==LOCATE_VIEW );\n  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);\n  if( noErr ) db->suppressErr--;\n\n  if( pTab==0 ){\n    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    goto exit_drop_table;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n\n  /* If pTab is a virtual table, call ViewGetColumnNames() to ensure\n  ** it is initialized.\n  */\n  if( IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_drop_table;\n  }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zArg2 = 0;\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){\n      goto exit_drop_table;\n    }\n    if( isView ){\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_VIEW;\n      }else{\n        code = SQLITE_DROP_VIEW;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    }else if( IsVirtual(pTab) ){\n      code = SQLITE_DROP_VTABLE;\n      zArg2 = sqlite3GetVTable(db, pTab)->pMod->zName;\n#endif\n    }else{\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_TABLE;\n      }else{\n        code = SQLITE_DROP_TABLE;\n      }\n    }\n    if( sqlite3AuthCheck(pParse, code, pTab->zName, zArg2, zDb) ){\n      goto exit_drop_table;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){\n      goto exit_drop_table;\n    }\n  }\n#endif\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n    && sqlite3StrNICmp(pTab->zName, \"sqlite_stat\", 11)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be dropped\", pTab->zName);\n    goto exit_drop_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used\n  ** on a table.\n  */\n  if( isView && pTab->pSelect==0 ){\n    sqlite3ErrorMsg(pParse, \"use DROP TABLE to delete table %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n  if( !isView && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"use DROP VIEW to delete view %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n#endif\n\n  /* Generate code to remove the table from the master table\n  ** on disk.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3ClearStatTables(pParse, iDb, \"tbl\", pTab->zName);\n    sqlite3FkDropTable(pParse, pName, pTab);\n    sqlite3CodeDropTable(pParse, pTab, iDb, isView);\n  }\n\nexit_drop_table:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** This routine is called to create a new foreign key on the table\n** currently under construction.  pFromCol determines which columns\n** in the current table point to the foreign key.  If pFromCol==0 then\n** connect the key to the last column inserted.  pTo is the name of\n** the table referred to (a.k.a the \"parent\" table).  pToCol is a list\n** of tables in the parent pTo table.  flags contains all\n** information about the conflict resolution algorithms specified\n** in the ON DELETE, ON UPDATE and ON INSERT clauses.\n**\n** An FKey structure is created and added to the table currently\n** under construction in the pParse->pNewTable field.\n**\n** The foreign key is set for IMMEDIATE processing.  A subsequent call\n** to sqlite3DeferForeignKey() might change this to DEFERRED.\n*/\nSQLITE_PRIVATE void sqlite3CreateForeignKey(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pFromCol,  /* Columns in this table that point to other table */\n  Token *pTo,          /* Name of the other table */\n  ExprList *pToCol,    /* Columns in the other table */\n  int flags            /* Conflict resolution algorithms. */\n){\n  sqlite3 *db = pParse->db;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  FKey *pFKey = 0;\n  FKey *pNextTo;\n  Table *p = pParse->pNewTable;\n  int nByte;\n  int i;\n  int nCol;\n  char *z;\n\n  assert( pTo!=0 );\n  if( p==0 || IN_DECLARE_VTAB ) goto fk_end;\n  if( pFromCol==0 ){\n    int iCol = p->nCol-1;\n    if( NEVER(iCol<0) ) goto fk_end;\n    if( pToCol && pToCol->nExpr!=1 ){\n      sqlite3ErrorMsg(pParse, \"foreign key on %s\"\n         \" should reference only one column of table %T\",\n         p->aCol[iCol].zName, pTo);\n      goto fk_end;\n    }\n    nCol = 1;\n  }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){\n    sqlite3ErrorMsg(pParse,\n        \"number of columns in foreign key does not match the number of \"\n        \"columns in the referenced table\");\n    goto fk_end;\n  }else{\n    nCol = pFromCol->nExpr;\n  }\n  nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1;\n  if( pToCol ){\n    for(i=0; i<pToCol->nExpr; i++){\n      nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;\n    }\n  }\n  pFKey = sqlite3DbMallocZero(db, nByte );\n  if( pFKey==0 ){\n    goto fk_end;\n  }\n  pFKey->pFrom = p;\n  pFKey->pNextFrom = p->pFKey;\n  z = (char*)&pFKey->aCol[nCol];\n  pFKey->zTo = z;\n  memcpy(z, pTo->z, pTo->n);\n  z[pTo->n] = 0;\n  sqlite3Dequote(z);\n  z += pTo->n+1;\n  pFKey->nCol = nCol;\n  if( pFromCol==0 ){\n    pFKey->aCol[0].iFrom = p->nCol-1;\n  }else{\n    for(i=0; i<nCol; i++){\n      int j;\n      for(j=0; j<p->nCol; j++){\n        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){\n          pFKey->aCol[i].iFrom = j;\n          break;\n        }\n      }\n      if( j>=p->nCol ){\n        sqlite3ErrorMsg(pParse, \n          \"unknown column \\\"%s\\\" in foreign key definition\", \n          pFromCol->a[i].zName);\n        goto fk_end;\n      }\n    }\n  }\n  if( pToCol ){\n    for(i=0; i<nCol; i++){\n      int n = sqlite3Strlen30(pToCol->a[i].zName);\n      pFKey->aCol[i].zCol = z;\n      memcpy(z, pToCol->a[i].zName, n);\n      z[n] = 0;\n      z += n+1;\n    }\n  }\n  pFKey->isDeferred = 0;\n  pFKey->aAction[0] = (u8)(flags & 0xff);            /* ON DELETE action */\n  pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff);    /* ON UPDATE action */\n\n  assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n  pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, \n      pFKey->zTo, (void *)pFKey\n  );\n  if( pNextTo==pFKey ){\n    sqlite3OomFault(db);\n    goto fk_end;\n  }\n  if( pNextTo ){\n    assert( pNextTo->pPrevTo==0 );\n    pFKey->pNextTo = pNextTo;\n    pNextTo->pPrevTo = pFKey;\n  }\n\n  /* Link the foreign key to the table as the last step.\n  */\n  p->pFKey = pFKey;\n  pFKey = 0;\n\nfk_end:\n  sqlite3DbFree(db, pFKey);\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n  sqlite3ExprListDelete(db, pFromCol);\n  sqlite3ExprListDelete(db, pToCol);\n}\n\n/*\n** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED\n** clause is seen as part of a foreign key definition.  The isDeferred\n** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.\n** The behavior of the most recently created foreign key is adjusted\n** accordingly.\n*/\nSQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  Table *pTab;\n  FKey *pFKey;\n  if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;\n  assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */\n  pFKey->isDeferred = (u8)isDeferred;\n#endif\n}\n\n/*\n** Generate code that will erase and refill index *pIdx.  This is\n** used to initialize a newly created index or to recompute the\n** content of an index in response to a REINDEX command.\n**\n** if memRootPage is not negative, it means that the index is newly\n** created.  The register specified by memRootPage contains the\n** root page number of the index.  If memRootPage is negative, then\n** the index already exists and must be cleared before being refilled and\n** the root page number of the index is taken from pIndex->tnum.\n*/\nstatic void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){\n  Table *pTab = pIndex->pTable;  /* The table that is indexed */\n  int iTab = pParse->nTab++;     /* Btree cursor used for pTab */\n  int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */\n  int iSorter;                   /* Cursor opened by OpenSorter (if in use) */\n  int addr1;                     /* Address of top of loop */\n  int addr2;                     /* Address to jump to for next iteration */\n  int tnum;                      /* Root page of index */\n  int iPartIdxLabel;             /* Jump to this label to skip a row */\n  Vdbe *v;                       /* Generate code into this virtual machine */\n  KeyInfo *pKey;                 /* KeyInfo for index */\n  int regRecord;                 /* Register holding assembled index record */\n  sqlite3 *db = pParse->db;      /* The database connection */\n  int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n  /* Require a write-lock on the table to perform this operation */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) return;\n  if( memRootPage>=0 ){\n    tnum = memRootPage;\n  }else{\n    tnum = pIndex->tnum;\n  }\n  pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);\n  assert( pKey!=0 || db->mallocFailed || pParse->nErr );\n\n  /* Open the sorter cursor if we are to use one. */\n  iSorter = pParse->nTab++;\n  sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, pIndex->nKeyCol, (char*)\n                    sqlite3KeyInfoRef(pKey), P4_KEYINFO);\n\n  /* Open the table. Loop through all rows of the table, inserting index\n  ** records into the sorter. */\n  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);\n  regRecord = sqlite3GetTempReg(pParse);\n\n  sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);\n  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);\n  sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n  if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);\n  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, \n                    (char *)pKey, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));\n\n  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);\n  if( IsUniqueIndex(pIndex) ){\n    int j2 = sqlite3VdbeCurrentAddr(v) + 3;\n    sqlite3VdbeGoto(v, j2);\n    addr2 = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,\n                         pIndex->nKeyCol); VdbeCoverage(v);\n    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);\n  }else{\n    addr2 = sqlite3VdbeCurrentAddr(v);\n  }\n  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);\n  sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  sqlite3VdbeAddOp1(v, OP_Close, iTab);\n  sqlite3VdbeAddOp1(v, OP_Close, iIdx);\n  sqlite3VdbeAddOp1(v, OP_Close, iSorter);\n}\n\n/*\n** Allocate heap space to hold an Index object with nCol columns.\n**\n** Increase the allocation size to provide an extra nExtra bytes\n** of 8-byte aligned space after the Index object and return a\n** pointer to this extra space in *ppExtra.\n*/\nSQLITE_PRIVATE Index *sqlite3AllocateIndexObject(\n  sqlite3 *db,         /* Database connection */\n  i16 nCol,            /* Total number of columns in the index */\n  int nExtra,          /* Number of bytes of extra space to alloc */\n  char **ppExtra       /* Pointer to the \"extra\" space */\n){\n  Index *p;            /* Allocated index object */\n  int nByte;           /* Bytes of space for Index object + arrays */\n\n  nByte = ROUND8(sizeof(Index)) +              /* Index structure  */\n          ROUND8(sizeof(char*)*nCol) +         /* Index.azColl     */\n          ROUND8(sizeof(LogEst)*(nCol+1) +     /* Index.aiRowLogEst   */\n                 sizeof(i16)*nCol +            /* Index.aiColumn   */\n                 sizeof(u8)*nCol);             /* Index.aSortOrder */\n  p = sqlite3DbMallocZero(db, nByte + nExtra);\n  if( p ){\n    char *pExtra = ((char*)p)+ROUND8(sizeof(Index));\n    p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);\n    p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);\n    p->aiColumn = (i16*)pExtra;       pExtra += sizeof(i16)*nCol;\n    p->aSortOrder = (u8*)pExtra;\n    p->nColumn = nCol;\n    p->nKeyCol = nCol - 1;\n    *ppExtra = ((char*)p) + nByte;\n  }\n  return p;\n}\n\n/*\n** Create a new index for an SQL table.  pName1.pName2 is the name of the index \n** and pTblList is the name of the table that is to be indexed.  Both will \n** be NULL for a primary key or an index that is created to satisfy a\n** UNIQUE constraint.  If pTable and pIndex are NULL, use pParse->pNewTable\n** as the table to be indexed.  pParse->pNewTable is a table that is\n** currently being constructed by a CREATE TABLE statement.\n**\n** pList is a list of columns to be indexed.  pList will be NULL if this\n** is a primary key or unique-constraint on the most recent column added\n** to the table currently under construction.  \n*/\nSQLITE_PRIVATE void sqlite3CreateIndex(\n  Parse *pParse,     /* All information about this parse */\n  Token *pName1,     /* First part of index name. May be NULL */\n  Token *pName2,     /* Second part of index name. May be NULL */\n  SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */\n  ExprList *pList,   /* A list of columns to be indexed */\n  int onError,       /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  Token *pStart,     /* The CREATE token that begins this statement */\n  Expr *pPIWhere,    /* WHERE clause for partial indices */\n  int sortOrder,     /* Sort order of primary key when pList==NULL */\n  int ifNotExist,    /* Omit error if index already exists */\n  u8 idxType         /* The index type */\n){\n  Table *pTab = 0;     /* Table to be indexed */\n  Index *pIndex = 0;   /* The index to be created */\n  char *zName = 0;     /* Name of the index */\n  int nName;           /* Number of characters in zName */\n  int i, j;\n  DbFixer sFix;        /* For assigning database names to pTable */\n  int sortOrderMask;   /* 1 to honor DESC in index.  0 to ignore. */\n  sqlite3 *db = pParse->db;\n  Db *pDb;             /* The specific table containing the indexed database */\n  int iDb;             /* Index of the database that is being written */\n  Token *pName = 0;    /* Unqualified name of the index to create */\n  struct ExprList_item *pListItem; /* For looping over pList */\n  int nExtra = 0;                  /* Space allocated for zExtra[] */\n  int nExtraCol;                   /* Number of extra columns needed */\n  char *zExtra = 0;                /* Extra space after the Index object */\n  Index *pPk = 0;      /* PRIMARY KEY index for WITHOUT ROWID tables */\n\n  if( db->mallocFailed || pParse->nErr>0 ){\n    goto exit_create_index;\n  }\n  if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){\n    goto exit_create_index;\n  }\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_create_index;\n  }\n\n  /*\n  ** Find the table that is to be indexed.  Return early if not found.\n  */\n  if( pTblName!=0 ){\n\n    /* Use the two-part index name to determine the database \n    ** to search for the table. 'Fix' the table name to this db\n    ** before looking up the table.\n    */\n    assert( pName1 && pName2 );\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) goto exit_create_index;\n    assert( pName && pName->z );\n\n#ifndef SQLITE_OMIT_TEMPDB\n    /* If the index name was unqualified, check if the table\n    ** is a temp table. If so, set the database to 1. Do not do this\n    ** if initialising a database schema.\n    */\n    if( !db->init.busy ){\n      pTab = sqlite3SrcListLookup(pParse, pTblName);\n      if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){\n        iDb = 1;\n      }\n    }\n#endif\n\n    sqlite3FixInit(&sFix, pParse, iDb, \"index\", pName);\n    if( sqlite3FixSrcList(&sFix, pTblName) ){\n      /* Because the parser constructs pTblName from a single identifier,\n      ** sqlite3FixSrcList can never fail. */\n      assert(0);\n    }\n    pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);\n    assert( db->mallocFailed==0 || pTab==0 );\n    if( pTab==0 ) goto exit_create_index;\n    if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){\n      sqlite3ErrorMsg(pParse, \n           \"cannot create a TEMP index on non-TEMP table \\\"%s\\\"\",\n           pTab->zName);\n      goto exit_create_index;\n    }\n    if( !HasRowid(pTab) ) pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    assert( pName==0 );\n    assert( pStart==0 );\n    pTab = pParse->pNewTable;\n    if( !pTab ) goto exit_create_index;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  }\n  pDb = &db->aDb[iDb];\n\n  assert( pTab!=0 );\n  assert( pParse->nErr==0 );\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n       && db->init.busy==0\n#if SQLITE_USER_AUTHENTICATION\n       && sqlite3UserAuthTable(pTab->zName)==0\n#endif\n       && sqlite3StrNICmp(&pTab->zName[7],\"altertab_\",9)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be indexed\", pTab->zName);\n    goto exit_create_index;\n  }\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"views may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n\n  /*\n  ** Find the name of the index.  Make sure there is not already another\n  ** index or table with the same name.  \n  **\n  ** Exception:  If we are reading the names of permanent indices from the\n  ** sqlite_master table (because some other process changed the schema) and\n  ** one of the index names collides with the name of a temporary table or\n  ** index, then we will continue to process this index.\n  **\n  ** If pName==0 it means that we are\n  ** dealing with a primary key or UNIQUE constraint.  We have to invent our\n  ** own name.\n  */\n  if( pName ){\n    zName = sqlite3NameFromToken(db, pName);\n    if( zName==0 ) goto exit_create_index;\n    assert( pName->z!=0 );\n    if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n      goto exit_create_index;\n    }\n    if( !db->init.busy ){\n      if( sqlite3FindTable(db, zName, 0)!=0 ){\n        sqlite3ErrorMsg(pParse, \"there is already a table named %s\", zName);\n        goto exit_create_index;\n      }\n    }\n    if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){\n      if( !ifNotExist ){\n        sqlite3ErrorMsg(pParse, \"index %s already exists\", zName);\n      }else{\n        assert( !db->init.busy );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto exit_create_index;\n    }\n  }else{\n    int n;\n    Index *pLoop;\n    for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}\n    zName = sqlite3MPrintf(db, \"sqlite_autoindex_%s_%d\", pTab->zName, n);\n    if( zName==0 ){\n      goto exit_create_index;\n    }\n\n    /* Automatic index names generated from within sqlite3_declare_vtab()\n    ** must have names that are distinct from normal automatic index names.\n    ** The following statement converts \"sqlite3_autoindex...\" into\n    ** \"sqlite3_butoindex...\" in order to make the names distinct.\n    ** The \"vtab_err.test\" test demonstrates the need of this statement. */\n    if( IN_DECLARE_VTAB ) zName[7]++;\n  }\n\n  /* Check for authorization to create an index.\n  */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    const char *zDb = pDb->zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){\n      goto exit_create_index;\n    }\n    i = SQLITE_CREATE_INDEX;\n    if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){\n      goto exit_create_index;\n    }\n  }\n#endif\n\n  /* If pList==0, it means this routine was called to make a primary\n  ** key out of the last column added to the table under construction.\n  ** So create a fake list to simulate this.\n  */\n  if( pList==0 ){\n    Token prevCol;\n    sqlite3TokenInit(&prevCol, pTab->aCol[pTab->nCol-1].zName);\n    pList = sqlite3ExprListAppend(pParse, 0,\n              sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));\n    if( pList==0 ) goto exit_create_index;\n    assert( pList->nExpr==1 );\n    sqlite3ExprListSetSortOrder(pList, sortOrder);\n  }else{\n    sqlite3ExprListCheckLength(pParse, pList, \"index\");\n  }\n\n  /* Figure out how many bytes of space are required to store explicitly\n  ** specified collation sequence names.\n  */\n  for(i=0; i<pList->nExpr; i++){\n    Expr *pExpr = pList->a[i].pExpr;\n    assert( pExpr!=0 );\n    if( pExpr->op==TK_COLLATE ){\n      nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));\n    }\n  }\n\n  /* \n  ** Allocate the index structure. \n  */\n  nName = sqlite3Strlen30(zName);\n  nExtraCol = pPk ? pPk->nKeyCol : 1;\n  pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,\n                                      nName + nExtra + 1, &zExtra);\n  if( db->mallocFailed ){\n    goto exit_create_index;\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) );\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );\n  pIndex->zName = zExtra;\n  zExtra += nName + 1;\n  memcpy(pIndex->zName, zName, nName+1);\n  pIndex->pTable = pTab;\n  pIndex->onError = (u8)onError;\n  pIndex->uniqNotNull = onError!=OE_None;\n  pIndex->idxType = idxType;\n  pIndex->pSchema = db->aDb[iDb].pSchema;\n  pIndex->nKeyCol = pList->nExpr;\n  if( pPIWhere ){\n    sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);\n    pIndex->pPartIdxWhere = pPIWhere;\n    pPIWhere = 0;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n\n  /* Check to see if we should honor DESC requests on index columns\n  */\n  if( pDb->pSchema->file_format>=4 ){\n    sortOrderMask = -1;   /* Honor DESC */\n  }else{\n    sortOrderMask = 0;    /* Ignore DESC */\n  }\n\n  /* Analyze the list of expressions that form the terms of the index and\n  ** report any errors.  In the common case where the expression is exactly\n  ** a table column, store that column in aiColumn[].  For general expressions,\n  ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[].\n  **\n  ** TODO: Issue a warning if two or more columns of the index are identical.\n  ** TODO: Issue a warning if the table primary key is used as part of the\n  ** index key.\n  */\n  for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){\n    Expr *pCExpr;                  /* The i-th index expression */\n    int requestedSortOrder;        /* ASC or DESC on the i-th expression */\n    const char *zColl;             /* Collation sequence name */\n\n    sqlite3StringToId(pListItem->pExpr);\n    sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);\n    if( pParse->nErr ) goto exit_create_index;\n    pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);\n    if( pCExpr->op!=TK_COLUMN ){\n      if( pTab==pParse->pNewTable ){\n        sqlite3ErrorMsg(pParse, \"expressions prohibited in PRIMARY KEY and \"\n                                \"UNIQUE constraints\");\n        goto exit_create_index;\n      }\n      if( pIndex->aColExpr==0 ){\n        ExprList *pCopy = sqlite3ExprListDup(db, pList, 0);\n        pIndex->aColExpr = pCopy;\n        if( !db->mallocFailed ){\n          assert( pCopy!=0 );\n          pListItem = &pCopy->a[i];\n        }\n      }\n      j = XN_EXPR;\n      pIndex->aiColumn[i] = XN_EXPR;\n      pIndex->uniqNotNull = 0;\n    }else{\n      j = pCExpr->iColumn;\n      assert( j<=0x7fff );\n      if( j<0 ){\n        j = pTab->iPKey;\n      }else if( pTab->aCol[j].notNull==0 ){\n        pIndex->uniqNotNull = 0;\n      }\n      pIndex->aiColumn[i] = (i16)j;\n    }\n    zColl = 0;\n    if( pListItem->pExpr->op==TK_COLLATE ){\n      int nColl;\n      zColl = pListItem->pExpr->u.zToken;\n      nColl = sqlite3Strlen30(zColl) + 1;\n      assert( nExtra>=nColl );\n      memcpy(zExtra, zColl, nColl);\n      zColl = zExtra;\n      zExtra += nColl;\n      nExtra -= nColl;\n    }else if( j>=0 ){\n      zColl = pTab->aCol[j].zColl;\n    }\n    if( !zColl ) zColl = sqlite3StrBINARY;\n    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){\n      goto exit_create_index;\n    }\n    pIndex->azColl[i] = zColl;\n    requestedSortOrder = pListItem->sortOrder & sortOrderMask;\n    pIndex->aSortOrder[i] = (u8)requestedSortOrder;\n  }\n\n  /* Append the table key to the end of the index.  For WITHOUT ROWID\n  ** tables (when pPk!=0) this will be the declared PRIMARY KEY.  For\n  ** normal tables (when pPk==0) this will be the rowid.\n  */\n  if( pPk ){\n    for(j=0; j<pPk->nKeyCol; j++){\n      int x = pPk->aiColumn[j];\n      assert( x>=0 );\n      if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){\n        pIndex->nColumn--; \n      }else{\n        pIndex->aiColumn[i] = x;\n        pIndex->azColl[i] = pPk->azColl[j];\n        pIndex->aSortOrder[i] = pPk->aSortOrder[j];\n        i++;\n      }\n    }\n    assert( i==pIndex->nColumn );\n  }else{\n    pIndex->aiColumn[i] = XN_ROWID;\n    pIndex->azColl[i] = sqlite3StrBINARY;\n  }\n  sqlite3DefaultRowEst(pIndex);\n  if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);\n\n  /* If this index contains every column of its table, then mark\n  ** it as a covering index */\n  assert( HasRowid(pTab) \n      || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );\n  if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){\n    pIndex->isCovering = 1;\n    for(j=0; j<pTab->nCol; j++){\n      if( j==pTab->iPKey ) continue;\n      if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;\n      pIndex->isCovering = 0;\n      break;\n    }\n  }\n\n  if( pTab==pParse->pNewTable ){\n    /* This routine has been called to create an automatic index as a\n    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or\n    ** a PRIMARY KEY or UNIQUE clause following the column definitions.\n    ** i.e. one of:\n    **\n    ** CREATE TABLE t(x PRIMARY KEY, y);\n    ** CREATE TABLE t(x, y, UNIQUE(x, y));\n    **\n    ** Either way, check to see if the table already has such an index. If\n    ** so, don't bother creating this one. This only applies to\n    ** automatically created indices. Users can do as they wish with\n    ** explicit indices.\n    **\n    ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent\n    ** (and thus suppressing the second one) even if they have different\n    ** sort orders.\n    **\n    ** If there are different collating sequences or if the columns of\n    ** the constraint occur in different orders, then the constraints are\n    ** considered distinct and both result in separate indices.\n    */\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int k;\n      assert( IsUniqueIndex(pIdx) );\n      assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );\n      assert( IsUniqueIndex(pIndex) );\n\n      if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;\n      for(k=0; k<pIdx->nKeyCol; k++){\n        const char *z1;\n        const char *z2;\n        assert( pIdx->aiColumn[k]>=0 );\n        if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;\n        z1 = pIdx->azColl[k];\n        z2 = pIndex->azColl[k];\n        if( sqlite3StrICmp(z1, z2) ) break;\n      }\n      if( k==pIdx->nKeyCol ){\n        if( pIdx->onError!=pIndex->onError ){\n          /* This constraint creates the same index as a previous\n          ** constraint specified somewhere in the CREATE TABLE statement.\n          ** However the ON CONFLICT clauses are different. If both this \n          ** constraint and the previous equivalent constraint have explicit\n          ** ON CONFLICT clauses this is an error. Otherwise, use the\n          ** explicitly specified behavior for the index.\n          */\n          if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){\n            sqlite3ErrorMsg(pParse, \n                \"conflicting ON CONFLICT clauses specified\", 0);\n          }\n          if( pIdx->onError==OE_Default ){\n            pIdx->onError = pIndex->onError;\n          }\n        }\n        if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;\n        goto exit_create_index;\n      }\n    }\n  }\n\n  /* Link the new Index structure to its table and to the other\n  ** in-memory database structures. \n  */\n  assert( pParse->nErr==0 );\n  if( db->init.busy ){\n    Index *p;\n    assert( !IN_DECLARE_VTAB );\n    assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n    p = sqlite3HashInsert(&pIndex->pSchema->idxHash, \n                          pIndex->zName, pIndex);\n    if( p ){\n      assert( p==pIndex );  /* Malloc must have failed */\n      sqlite3OomFault(db);\n      goto exit_create_index;\n    }\n    db->mDbFlags |= DBFLAG_SchemaChange;\n    if( pTblName!=0 ){\n      pIndex->tnum = db->init.newTnum;\n    }\n  }\n\n  /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the\n  ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then\n  ** emit code to allocate the index rootpage on disk and make an entry for\n  ** the index in the sqlite_master table and populate the index with\n  ** content.  But, do not do this if we are simply reading the sqlite_master\n  ** table to parse the schema, or if this index is the PRIMARY KEY index\n  ** of a WITHOUT ROWID table.\n  **\n  ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY\n  ** or UNIQUE index in a CREATE TABLE statement.  Since the table\n  ** has just been created, it contains no data and the index initialization\n  ** step can be skipped.\n  */\n  else if( HasRowid(pTab) || pTblName!=0 ){\n    Vdbe *v;\n    char *zStmt;\n    int iMem = ++pParse->nMem;\n\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto exit_create_index;\n\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n    /* Create the rootpage for the index using CreateIndex. But before\n    ** doing so, code a Noop instruction and store its address in \n    ** Index.tnum. This is required in case this index is actually a \n    ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In \n    ** that case the convertToWithoutRowidTable() routine will replace\n    ** the Noop with a Goto to jump over the VDBE code generated below. */\n    pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);\n    sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);\n\n    /* Gather the complete text of the CREATE INDEX statement into\n    ** the zStmt variable\n    */\n    if( pStart ){\n      int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;\n      if( pName->z[n-1]==';' ) n--;\n      /* A named index with an explicit CREATE INDEX statement */\n      zStmt = sqlite3MPrintf(db, \"CREATE%s INDEX %.*s\",\n        onError==OE_None ? \"\" : \" UNIQUE\", n, pName->z);\n    }else{\n      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */\n      /* zStmt = sqlite3MPrintf(\"\"); */\n      zStmt = 0;\n    }\n\n    /* Add an entry in sqlite_master for this index\n    */\n    sqlite3NestedParse(pParse, \n        \"INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);\",\n        db->aDb[iDb].zDbSName, MASTER_NAME,\n        pIndex->zName,\n        pTab->zName,\n        iMem,\n        zStmt\n    );\n    sqlite3DbFree(db, zStmt);\n\n    /* Fill the index with data and reparse the schema. Code an OP_Expire\n    ** to invalidate all pre-compiled statements.\n    */\n    if( pTblName ){\n      sqlite3RefillIndex(pParse, pIndex, iMem);\n      sqlite3ChangeCookie(pParse, iDb);\n      sqlite3VdbeAddParseSchemaOp(v, iDb,\n         sqlite3MPrintf(db, \"name='%q' AND type='index'\", pIndex->zName));\n      sqlite3VdbeAddOp0(v, OP_Expire);\n    }\n\n    sqlite3VdbeJumpHere(v, pIndex->tnum);\n  }\n\n  /* When adding an index to the list of indices for a table, make\n  ** sure all indices labeled OE_Replace come after all those labeled\n  ** OE_Ignore.  This is necessary for the correct constraint check\n  ** processing (in sqlite3GenerateConstraintChecks()) as part of\n  ** UPDATE and INSERT statements.  \n  */\n  if( db->init.busy || pTblName==0 ){\n    if( onError!=OE_Replace || pTab->pIndex==0\n         || pTab->pIndex->onError==OE_Replace){\n      pIndex->pNext = pTab->pIndex;\n      pTab->pIndex = pIndex;\n    }else{\n      Index *pOther = pTab->pIndex;\n      while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){\n        pOther = pOther->pNext;\n      }\n      pIndex->pNext = pOther->pNext;\n      pOther->pNext = pIndex;\n    }\n    pIndex = 0;\n  }\n\n  /* Clean up before exiting */\nexit_create_index:\n  if( pIndex ) freeIndex(db, pIndex);\n  sqlite3ExprDelete(db, pPIWhere);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SrcListDelete(db, pTblName);\n  sqlite3DbFree(db, zName);\n}\n\n/*\n** Fill the Index.aiRowEst[] array with default information - information\n** to be used when we have not run the ANALYZE command.\n**\n** aiRowEst[0] is supposed to contain the number of elements in the index.\n** Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the\n** number of rows in the table that match any particular value of the\n** first column of the index.  aiRowEst[2] is an estimate of the number\n** of rows that match any particular combination of the first 2 columns\n** of the index.  And so forth.  It must always be the case that\n*\n**           aiRowEst[N]<=aiRowEst[N-1]\n**           aiRowEst[N]>=1\n**\n** Apart from that, we have little to go on besides intuition as to\n** how aiRowEst[] should be initialized.  The numbers generated here\n** are based on typical values found in actual indices.\n*/\nSQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){\n  /*                10,  9,  8,  7,  6 */\n  LogEst aVal[] = { 33, 32, 30, 28, 26 };\n  LogEst *a = pIdx->aiRowLogEst;\n  int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);\n  int i;\n\n  /* Indexes with default row estimates should not have stat1 data */\n  assert( !pIdx->hasStat1 );\n\n  /* Set the first entry (number of rows in the index) to the estimated \n  ** number of rows in the table, or half the number of rows in the table\n  ** for a partial index.   But do not let the estimate drop below 10. */\n  a[0] = pIdx->pTable->nRowLogEst;\n  if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10;  assert( 10==sqlite3LogEst(2) );\n  if( a[0]<33 ) a[0] = 33;                  assert( 33==sqlite3LogEst(10) );\n\n  /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is\n  ** 6 and each subsequent value (if any) is 5.  */\n  memcpy(&a[1], aVal, nCopy*sizeof(LogEst));\n  for(i=nCopy+1; i<=pIdx->nKeyCol; i++){\n    a[i] = 23;                    assert( 23==sqlite3LogEst(5) );\n  }\n\n  assert( 0==sqlite3LogEst(1) );\n  if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;\n}\n\n/*\n** This routine will drop an existing named index.  This routine\n** implements the DROP INDEX statement.\n*/\nSQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){\n  Index *pIndex;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  assert( pParse->nErr==0 );   /* Never called with prior errors */\n  if( db->mallocFailed ){\n    goto exit_drop_index;\n  }\n  assert( pName->nSrc==1 );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_drop_index;\n  }\n  pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);\n  if( pIndex==0 ){\n    if( !ifExists ){\n      sqlite3ErrorMsg(pParse, \"no such index: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    }\n    pParse->checkSchema = 1;\n    goto exit_drop_index;\n  }\n  if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){\n    sqlite3ErrorMsg(pParse, \"index associated with UNIQUE \"\n      \"or PRIMARY KEY constraint cannot be dropped\", 0);\n    goto exit_drop_index;\n  }\n  iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_INDEX;\n    Table *pTab = pIndex->pTable;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      goto exit_drop_index;\n    }\n    if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){\n      goto exit_drop_index;\n    }\n  }\n#endif\n\n  /* Generate code to remove the index and from the master table */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='index'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pIndex->zName\n    );\n    sqlite3ClearStatTables(pParse, iDb, \"idx\", pIndex->zName);\n    sqlite3ChangeCookie(pParse, iDb);\n    destroyRootPage(pParse, pIndex->tnum, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);\n  }\n\nexit_drop_index:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** pArray is a pointer to an array of objects. Each object in the\n** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()\n** to extend the array so that there is space for a new object at the end.\n**\n** When this function is called, *pnEntry contains the current size of\n** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes\n** in total).\n**\n** If the realloc() is successful (i.e. if no OOM condition occurs), the\n** space allocated for the new object is zeroed, *pnEntry updated to\n** reflect the new size of the array and a pointer to the new allocation\n** returned. *pIdx is set to the index of the new array entry in this case.\n**\n** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains\n** unchanged and a copy of pArray returned.\n*/\nSQLITE_PRIVATE void *sqlite3ArrayAllocate(\n  sqlite3 *db,      /* Connection to notify of malloc failures */\n  void *pArray,     /* Array of objects.  Might be reallocated */\n  int szEntry,      /* Size of each object in the array */\n  int *pnEntry,     /* Number of objects currently in use */\n  int *pIdx         /* Write the index of a new slot here */\n){\n  char *z;\n  int n = *pnEntry;\n  if( (n & (n-1))==0 ){\n    int sz = (n==0) ? 1 : 2*n;\n    void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry);\n    if( pNew==0 ){\n      *pIdx = -1;\n      return pArray;\n    }\n    pArray = pNew;\n  }\n  z = (char*)pArray;\n  memset(&z[n * szEntry], 0, szEntry);\n  *pIdx = n;\n  ++*pnEntry;\n  return pArray;\n}\n\n/*\n** Append a new element to the given IdList.  Create a new IdList if\n** need be.\n**\n** A new IdList is returned, or NULL if malloc() fails.\n*/\nSQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken){\n  int i;\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(IdList) );\n    if( pList==0 ) return 0;\n  }\n  pList->a = sqlite3ArrayAllocate(\n      db,\n      pList->a,\n      sizeof(pList->a[0]),\n      &pList->nId,\n      &i\n  );\n  if( i<0 ){\n    sqlite3IdListDelete(db, pList);\n    return 0;\n  }\n  pList->a[i].zName = sqlite3NameFromToken(db, pToken);\n  return pList;\n}\n\n/*\n** Delete an IdList.\n*/\nSQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nId; i++){\n    sqlite3DbFree(db, pList->a[i].zName);\n  }\n  sqlite3DbFree(db, pList->a);\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** Return the index in pList of the identifier named zId.  Return -1\n** if not found.\n*/\nSQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){\n  int i;\n  if( pList==0 ) return -1;\n  for(i=0; i<pList->nId; i++){\n    if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Expand the space allocated for the given SrcList object by\n** creating nExtra new slots beginning at iStart.  iStart is zero based.\n** New slots are zeroed.\n**\n** For example, suppose a SrcList initially contains two entries: A,B.\n** To append 3 new entries onto the end, do this:\n**\n**    sqlite3SrcListEnlarge(db, pSrclist, 3, 2);\n**\n** After the call above it would contain:  A, B, nil, nil, nil.\n** If the iStart argument had been 1 instead of 2, then the result\n** would have been:  A, nil, nil, nil, B.  To prepend the new slots,\n** the iStart value would be 0.  The result then would\n** be: nil, nil, nil, A, B.\n**\n** If a memory allocation fails the SrcList is unchanged.  The\n** db->mallocFailed flag will be set to true.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(\n  sqlite3 *db,       /* Database connection to notify of OOM errors */\n  SrcList *pSrc,     /* The SrcList to be enlarged */\n  int nExtra,        /* Number of new slots to add to pSrc->a[] */\n  int iStart         /* Index in pSrc->a[] of first new slot */\n){\n  int i;\n\n  /* Sanity checking on calling parameters */\n  assert( iStart>=0 );\n  assert( nExtra>=1 );\n  assert( pSrc!=0 );\n  assert( iStart<=pSrc->nSrc );\n\n  /* Allocate additional space if needed */\n  if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){\n    SrcList *pNew;\n    int nAlloc = pSrc->nSrc*2+nExtra;\n    int nGot;\n    pNew = sqlite3DbRealloc(db, pSrc,\n               sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );\n    if( pNew==0 ){\n      assert( db->mallocFailed );\n      return pSrc;\n    }\n    pSrc = pNew;\n    nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;\n    pSrc->nAlloc = nGot;\n  }\n\n  /* Move existing slots that come after the newly inserted slots\n  ** out of the way */\n  for(i=pSrc->nSrc-1; i>=iStart; i--){\n    pSrc->a[i+nExtra] = pSrc->a[i];\n  }\n  pSrc->nSrc += nExtra;\n\n  /* Zero the newly allocated slots */\n  memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);\n  for(i=iStart; i<iStart+nExtra; i++){\n    pSrc->a[i].iCursor = -1;\n  }\n\n  /* Return a pointer to the enlarged SrcList */\n  return pSrc;\n}\n\n\n/*\n** Append a new table name to the given SrcList.  Create a new SrcList if\n** need be.  A new entry is created in the SrcList even if pTable is NULL.\n**\n** A SrcList is returned, or NULL if there is an OOM error.  The returned\n** SrcList might be the same as the SrcList that was input or it might be\n** a new one.  If an OOM error does occurs, then the prior value of pList\n** that is input to this routine is automatically freed.\n**\n** If pDatabase is not null, it means that the table has an optional\n** database name prefix.  Like this:  \"database.table\".  The pDatabase\n** points to the table name and the pTable points to the database name.\n** The SrcList.a[].zName field is filled with the table name which might\n** come from pTable (if pDatabase is NULL) or from pDatabase.  \n** SrcList.a[].zDatabase is filled with the database name from pTable,\n** or with NULL if no database is specified.\n**\n** In other words, if call like this:\n**\n**         sqlite3SrcListAppend(D,A,B,0);\n**\n** Then B is a table name and the database name is unspecified.  If called\n** like this:\n**\n**         sqlite3SrcListAppend(D,A,B,C);\n**\n** Then C is the table name and B is the database name.  If C is defined\n** then so is B.  In other words, we never have a case where:\n**\n**         sqlite3SrcListAppend(D,A,0,C);\n**\n** Both pTable and pDatabase are assumed to be quoted.  They are dequoted\n** before being added to the SrcList.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppend(\n  sqlite3 *db,        /* Connection to notify of malloc failures */\n  SrcList *pList,     /* Append to this SrcList. NULL creates a new SrcList */\n  Token *pTable,      /* Table to append */\n  Token *pDatabase    /* Database of the table */\n){\n  struct SrcList_item *pItem;\n  assert( pDatabase==0 || pTable!=0 );  /* Cannot have C without B */\n  assert( db!=0 );\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(db, sizeof(SrcList) );\n    if( pList==0 ) return 0;\n    pList->nAlloc = 1;\n    pList->nSrc = 1;\n    memset(&pList->a[0], 0, sizeof(pList->a[0]));\n    pList->a[0].iCursor = -1;\n  }else{\n    pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);\n  }\n  if( db->mallocFailed ){\n    sqlite3SrcListDelete(db, pList);\n    return 0;\n  }\n  pItem = &pList->a[pList->nSrc-1];\n  if( pDatabase && pDatabase->z==0 ){\n    pDatabase = 0;\n  }\n  if( pDatabase ){\n    pItem->zName = sqlite3NameFromToken(db, pDatabase);\n    pItem->zDatabase = sqlite3NameFromToken(db, pTable);\n  }else{\n    pItem->zName = sqlite3NameFromToken(db, pTable);\n    pItem->zDatabase = 0;\n  }\n  return pList;\n}\n\n/*\n** Assign VdbeCursor index numbers to all tables in a SrcList\n*/\nSQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  assert(pList || pParse->db->mallocFailed );\n  if( pList ){\n    for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n      if( pItem->iCursor>=0 ) break;\n      pItem->iCursor = pParse->nTab++;\n      if( pItem->pSelect ){\n        sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);\n      }\n    }\n  }\n}\n\n/*\n** Delete an entire SrcList including all its substructure.\n*/\nSQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  if( pList==0 ) return;\n  for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){\n    sqlite3DbFree(db, pItem->zDatabase);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zAlias);\n    if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy);\n    if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg);\n    sqlite3DeleteTable(db, pItem->pTab);\n    sqlite3SelectDelete(db, pItem->pSelect);\n    sqlite3ExprDelete(db, pItem->pOn);\n    sqlite3IdListDelete(db, pItem->pUsing);\n  }\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** This routine is called by the parser to add a new term to the\n** end of a growing FROM clause.  The \"p\" parameter is the part of\n** the FROM clause that has already been constructed.  \"p\" is NULL\n** if this is the first term of the FROM clause.  pTable and pDatabase\n** are the name of the table and database named in the FROM clause term.\n** pDatabase is NULL if the database name qualifier is missing - the\n** usual case.  If the term has an alias, then pAlias points to the\n** alias token.  If the term is a subquery, then pSubquery is the\n** SELECT statement that the subquery encodes.  The pTable and\n** pDatabase parameters are NULL for subqueries.  The pOn and pUsing\n** parameters are the content of the ON and USING clauses.\n**\n** Return a new SrcList which encodes is the FROM with the new\n** term added.\n*/\nSQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(\n  Parse *pParse,          /* Parsing context */\n  SrcList *p,             /* The left part of the FROM clause already seen */\n  Token *pTable,          /* Name of the table to add to the FROM clause */\n  Token *pDatabase,       /* Name of the database containing pTable */\n  Token *pAlias,          /* The right-hand side of the AS subexpression */\n  Select *pSubquery,      /* A subquery used in place of a table name */\n  Expr *pOn,              /* The ON clause of a join */\n  IdList *pUsing          /* The USING clause of a join */\n){\n  struct SrcList_item *pItem;\n  sqlite3 *db = pParse->db;\n  if( !p && (pOn || pUsing) ){\n    sqlite3ErrorMsg(pParse, \"a JOIN clause is required before %s\", \n      (pOn ? \"ON\" : \"USING\")\n    );\n    goto append_from_error;\n  }\n  p = sqlite3SrcListAppend(db, p, pTable, pDatabase);\n  if( p==0 || NEVER(p->nSrc==0) ){\n    goto append_from_error;\n  }\n  pItem = &p->a[p->nSrc-1];\n  assert( pAlias!=0 );\n  if( pAlias->n ){\n    pItem->zAlias = sqlite3NameFromToken(db, pAlias);\n  }\n  pItem->pSelect = pSubquery;\n  pItem->pOn = pOn;\n  pItem->pUsing = pUsing;\n  return p;\n\n append_from_error:\n  assert( p==0 );\n  sqlite3ExprDelete(db, pOn);\n  sqlite3IdListDelete(db, pUsing);\n  sqlite3SelectDelete(db, pSubquery);\n  return 0;\n}\n\n/*\n** Add an INDEXED BY or NOT INDEXED clause to the most recently added \n** element of the source-list passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){\n  assert( pIndexedBy!=0 );\n  if( p && pIndexedBy->n>0 ){\n    struct SrcList_item *pItem;\n    assert( p->nSrc>0 );\n    pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    if( pIndexedBy->n==1 && !pIndexedBy->z ){\n      /* A \"NOT INDEXED\" clause was supplied. See parse.y \n      ** construct \"indexed_opt\" for details. */\n      pItem->fg.notIndexed = 1;\n    }else{\n      pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy);\n      pItem->fg.isIndexedBy = 1;\n    }\n  }\n}\n\n/*\n** Add the list of function arguments to the SrcList entry for a\n** table-valued-function.\n*/\nSQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){\n  if( p ){\n    struct SrcList_item *pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    pItem->u1.pFuncArg = pList;\n    pItem->fg.isTabFunc = 1;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n\n/*\n** When building up a FROM clause in the parser, the join operator\n** is initially attached to the left operand.  But the code generator\n** expects the join operator to be on the right operand.  This routine\n** Shifts all join operators from left to right for an entire FROM\n** clause.\n**\n** Example: Suppose the join is like this:\n**\n**           A natural cross join B\n**\n** The operator is \"natural cross join\".  The A and B operands are stored\n** in p->a[0] and p->a[1], respectively.  The parser initially stores the\n** operator with A.  This routine shifts that operator over to B.\n*/\nSQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){\n  if( p ){\n    int i;\n    for(i=p->nSrc-1; i>0; i--){\n      p->a[i].fg.jointype = p->a[i-1].fg.jointype;\n    }\n    p->a[0].fg.jointype = 0;\n  }\n}\n\n/*\n** Generate VDBE code for a BEGIN statement.\n*/\nSQLITE_PRIVATE void sqlite3BeginTransaction(Parse *pParse, int type){\n  sqlite3 *db;\n  Vdbe *v;\n  int i;\n\n  assert( pParse!=0 );\n  db = pParse->db;\n  assert( db!=0 );\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"BEGIN\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) return;\n  if( type!=TK_DEFERRED ){\n    for(i=0; i<db->nDb; i++){\n      sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);\n      sqlite3VdbeUsesBtree(v, i);\n    }\n  }\n  sqlite3VdbeAddOp0(v, OP_AutoCommit);\n}\n\n/*\n** Generate VDBE code for a COMMIT or ROLLBACK statement.\n** Code for ROLLBACK is generated if eType==TK_ROLLBACK.  Otherwise\n** code is generated for a COMMIT.\n*/\nSQLITE_PRIVATE void sqlite3EndTransaction(Parse *pParse, int eType){\n  Vdbe *v;\n  int isRollback;\n\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );\n  isRollback = eType==TK_ROLLBACK;\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \n       isRollback ? \"ROLLBACK\" : \"COMMIT\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);\n  }\n}\n\n/*\n** This function is called by the parser when it parses a command to create,\n** release or rollback an SQL savepoint. \n*/\nSQLITE_PRIVATE void sqlite3Savepoint(Parse *pParse, int op, Token *pName){\n  char *zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName ){\n    Vdbe *v = sqlite3GetVdbe(pParse);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    static const char * const az[] = { \"BEGIN\", \"RELEASE\", \"ROLLBACK\" };\n    assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );\n#endif\n    if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){\n      sqlite3DbFree(pParse->db, zName);\n      return;\n    }\n    sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);\n  }\n}\n\n/*\n** Make sure the TEMP database is open and available for use.  Return\n** the number of errors.  Leave any error messages in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt==0 && !pParse->explain ){\n    int rc;\n    Btree *pBt;\n    static const int flags = \n          SQLITE_OPEN_READWRITE |\n          SQLITE_OPEN_CREATE |\n          SQLITE_OPEN_EXCLUSIVE |\n          SQLITE_OPEN_DELETEONCLOSE |\n          SQLITE_OPEN_TEMP_DB;\n\n    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"unable to open a temporary database \"\n        \"file for storing temporary tables\");\n      pParse->rc = rc;\n      return 1;\n    }\n    db->aDb[1].pBt = pBt;\n    assert( db->aDb[1].pSchema );\n    if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){\n      sqlite3OomFault(db);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Record the fact that the schema cookie will need to be verified\n** for database iDb.  The code to actually verify the schema cookie\n** will occur at the end of the top-level VDBE and will be generated\n** later, by sqlite3FinishCoding().\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n\n  assert( iDb>=0 && iDb<pParse->db->nDb );\n  assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 );\n  assert( iDb<SQLITE_MAX_ATTACHED+2 );\n  assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) );\n  if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){\n    DbMaskSet(pToplevel->cookieMask, iDb);\n    if( !OMIT_TEMPDB && iDb==1 ){\n      sqlite3OpenTempDatabase(pToplevel);\n    }\n  }\n}\n\n/*\n** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each \n** attached database. Otherwise, invoke it for the database named zDb only.\n*/\nSQLITE_PRIVATE void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){\n  sqlite3 *db = pParse->db;\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zDbSName)) ){\n      sqlite3CodeVerifySchema(pParse, i);\n    }\n  }\n}\n\n/*\n** Generate VDBE code that prepares for doing an operation that\n** might change the database.\n**\n** This routine starts a new transaction if we are not already within\n** a transaction.  If we are already within a transaction, then a checkpoint\n** is set if the setStatement parameter is true.  A checkpoint should\n** be set for operations that might fail (due to a constraint) part of\n** the way through and which will need to undo some writes without having to\n** rollback the whole transaction.  For operations where all constraints\n** can be checked before any changes are made to the database, it is never\n** necessary to undo a write and the checkpoint should not be set.\n*/\nSQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  sqlite3CodeVerifySchema(pParse, iDb);\n  DbMaskSet(pToplevel->writeMask, iDb);\n  pToplevel->isMultiWrite |= setStatement;\n}\n\n/*\n** Indicate that the statement currently under construction might write\n** more than one entry (example: deleting one row then inserting another,\n** inserting multiple rows in a table, or inserting a row and index entries.)\n** If an abort occurs after some of these writes have completed, then it will\n** be necessary to undo the completed writes.\n*/\nSQLITE_PRIVATE void sqlite3MultiWrite(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->isMultiWrite = 1;\n}\n\n/* \n** The code generator calls this routine if is discovers that it is\n** possible to abort a statement prior to completion.  In order to \n** perform this abort without corrupting the database, we need to make\n** sure that the statement is protected by a statement transaction.\n**\n** Technically, we only need to set the mayAbort flag if the\n** isMultiWrite flag was previously set.  There is a time dependency\n** such that the abort must occur after the multiwrite.  This makes\n** some statements involving the REPLACE conflict resolution algorithm\n** go a little faster.  But taking advantage of this time dependency\n** makes it more difficult to prove that the code is correct (in \n** particular, it prevents us from writing an effective\n** implementation of sqlite3AssertMayAbort()) and so we have chosen\n** to take the safe route and skip the optimization.\n*/\nSQLITE_PRIVATE void sqlite3MayAbort(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->mayAbort = 1;\n}\n\n/*\n** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT\n** error. The onError parameter determines which (if any) of the statement\n** and/or current transaction is rolled back.\n*/\nSQLITE_PRIVATE void sqlite3HaltConstraint(\n  Parse *pParse,    /* Parsing context */\n  int errCode,      /* extended error code */\n  int onError,      /* Constraint type */\n  char *p4,         /* Error message */\n  i8 p4type,        /* P4_STATIC or P4_TRANSIENT */\n  u8 p5Errmsg       /* P5_ErrMsg type */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  assert( (errCode&0xff)==SQLITE_CONSTRAINT );\n  if( onError==OE_Abort ){\n    sqlite3MayAbort(pParse);\n  }\n  sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);\n  sqlite3VdbeChangeP5(v, p5Errmsg);\n}\n\n/*\n** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.\n*/\nSQLITE_PRIVATE void sqlite3UniqueConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Constraint type */\n  Index *pIdx       /* The index that triggers the constraint */\n){\n  char *zErr;\n  int j;\n  StrAccum errMsg;\n  Table *pTab = pIdx->pTable;\n\n  sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);\n  if( pIdx->aColExpr ){\n    sqlite3XPrintf(&errMsg, \"index '%q'\", pIdx->zName);\n  }else{\n    for(j=0; j<pIdx->nKeyCol; j++){\n      char *zCol;\n      assert( pIdx->aiColumn[j]>=0 );\n      zCol = pTab->aCol[pIdx->aiColumn[j]].zName;\n      if( j ) sqlite3StrAccumAppend(&errMsg, \", \", 2);\n      sqlite3StrAccumAppendAll(&errMsg, pTab->zName);\n      sqlite3StrAccumAppend(&errMsg, \".\", 1);\n      sqlite3StrAccumAppendAll(&errMsg, zCol);\n    }\n  }\n  zErr = sqlite3StrAccumFinish(&errMsg);\n  sqlite3HaltConstraint(pParse, \n    IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY \n                            : SQLITE_CONSTRAINT_UNIQUE,\n    onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);\n}\n\n\n/*\n** Code an OP_Halt due to non-unique rowid.\n*/\nSQLITE_PRIVATE void sqlite3RowidConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Conflict resolution algorithm */\n  Table *pTab       /* The table with the non-unique rowid */ \n){\n  char *zMsg;\n  int rc;\n  if( pTab->iPKey>=0 ){\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.%s\", pTab->zName,\n                          pTab->aCol[pTab->iPKey].zName);\n    rc = SQLITE_CONSTRAINT_PRIMARYKEY;\n  }else{\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.rowid\", pTab->zName);\n    rc = SQLITE_CONSTRAINT_ROWID;\n  }\n  sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,\n                        P5_ConstraintUnique);\n}\n\n/*\n** Check to see if pIndex uses the collating sequence pColl.  Return\n** true if it does and false if it does not.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic int collationMatch(const char *zColl, Index *pIndex){\n  int i;\n  assert( zColl!=0 );\n  for(i=0; i<pIndex->nColumn; i++){\n    const char *z = pIndex->azColl[i];\n    assert( z!=0 || pIndex->aiColumn[i]<0 );\n    if( pIndex->aiColumn[i]>=0 && 0==sqlite3StrICmp(z, zColl) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n/*\n** Recompute all indices of pTab that use the collating sequence pColl.\n** If pColl==0 then recompute all indices of pTab.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexTable(Parse *pParse, Table *pTab, char const *zColl){\n  Index *pIndex;              /* An index associated with pTab */\n\n  for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n    if( zColl==0 || collationMatch(zColl, pIndex) ){\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3RefillIndex(pParse, pIndex, -1);\n    }\n  }\n}\n#endif\n\n/*\n** Recompute all indices of all tables in all databases where the\n** indices use the collating sequence pColl.  If pColl==0 then recompute\n** all indices everywhere.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexDatabases(Parse *pParse, char const *zColl){\n  Db *pDb;                    /* A single database */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  HashElem *k;                /* For looping over tables in pDb */\n  Table *pTab;                /* A table in the database */\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );  /* Needed for schema access */\n  for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){\n    assert( pDb!=0 );\n    for(k=sqliteHashFirst(&pDb->pSchema->tblHash);  k; k=sqliteHashNext(k)){\n      pTab = (Table*)sqliteHashData(k);\n      reindexTable(pParse, pTab, zColl);\n    }\n  }\n}\n#endif\n\n/*\n** Generate code for the REINDEX command.\n**\n**        REINDEX                            -- 1\n**        REINDEX  <collation>               -- 2\n**        REINDEX  ?<database>.?<tablename>  -- 3\n**        REINDEX  ?<database>.?<indexname>  -- 4\n**\n** Form 1 causes all indices in all attached databases to be rebuilt.\n** Form 2 rebuilds all indices in all databases that use the named\n** collating function.  Forms 3 and 4 rebuild the named index or all\n** indices associated with the named table.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nSQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){\n  CollSeq *pColl;             /* Collating sequence to be reindexed, or NULL */\n  char *z;                    /* Name of a table or index */\n  const char *zDb;            /* Name of the database */\n  Table *pTab;                /* A table in the database */\n  Index *pIndex;              /* An index associated with pTab */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  Token *pObjName;            /* Name of the table or index to be reindexed */\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  if( pName1==0 ){\n    reindexDatabases(pParse, 0);\n    return;\n  }else if( NEVER(pName2==0) || pName2->z==0 ){\n    char *zColl;\n    assert( pName1->z );\n    zColl = sqlite3NameFromToken(pParse->db, pName1);\n    if( !zColl ) return;\n    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n    if( pColl ){\n      reindexDatabases(pParse, zColl);\n      sqlite3DbFree(db, zColl);\n      return;\n    }\n    sqlite3DbFree(db, zColl);\n  }\n  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);\n  if( iDb<0 ) return;\n  z = sqlite3NameFromToken(db, pObjName);\n  if( z==0 ) return;\n  zDb = db->aDb[iDb].zDbSName;\n  pTab = sqlite3FindTable(db, z, zDb);\n  if( pTab ){\n    reindexTable(pParse, pTab, 0);\n    sqlite3DbFree(db, z);\n    return;\n  }\n  pIndex = sqlite3FindIndex(db, z, zDb);\n  sqlite3DbFree(db, z);\n  if( pIndex ){\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3RefillIndex(pParse, pIndex, -1);\n    return;\n  }\n  sqlite3ErrorMsg(pParse, \"unable to identify the object to be reindexed\");\n}\n#endif\n\n/*\n** Return a KeyInfo structure that is appropriate for the given Index.\n**\n** The caller should invoke sqlite3KeyInfoUnref() on the returned object\n** when it has finished using it.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){\n  int i;\n  int nCol = pIdx->nColumn;\n  int nKey = pIdx->nKeyCol;\n  KeyInfo *pKey;\n  if( pParse->nErr ) return 0;\n  if( pIdx->uniqNotNull ){\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);\n  }else{\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);\n  }\n  if( pKey ){\n    assert( sqlite3KeyInfoIsWriteable(pKey) );\n    for(i=0; i<nCol; i++){\n      const char *zColl = pIdx->azColl[i];\n      pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :\n                        sqlite3LocateCollSeq(pParse, zColl);\n      pKey->aSortOrder[i] = pIdx->aSortOrder[i];\n    }\n    if( pParse->nErr ){\n      sqlite3KeyInfoUnref(pKey);\n      pKey = 0;\n    }\n  }\n  return pKey;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/* \n** This routine is invoked once per CTE by the parser while parsing a \n** WITH clause. \n*/\nSQLITE_PRIVATE With *sqlite3WithAdd(\n  Parse *pParse,          /* Parsing context */\n  With *pWith,            /* Existing WITH clause, or NULL */\n  Token *pName,           /* Name of the common-table */\n  ExprList *pArglist,     /* Optional column name list for the table */\n  Select *pQuery          /* Query used to initialize the table */\n){\n  sqlite3 *db = pParse->db;\n  With *pNew;\n  char *zName;\n\n  /* Check that the CTE name is unique within this WITH clause. If\n  ** not, store an error in the Parse structure. */\n  zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName && pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      if( sqlite3StrICmp(zName, pWith->a[i].zName)==0 ){\n        sqlite3ErrorMsg(pParse, \"duplicate WITH table name: %s\", zName);\n      }\n    }\n  }\n\n  if( pWith ){\n    int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte);\n    pNew = sqlite3DbRealloc(db, pWith, nByte);\n  }else{\n    pNew = sqlite3DbMallocZero(db, sizeof(*pWith));\n  }\n  assert( (pNew!=0 && zName!=0) || db->mallocFailed );\n\n  if( db->mallocFailed ){\n    sqlite3ExprListDelete(db, pArglist);\n    sqlite3SelectDelete(db, pQuery);\n    sqlite3DbFree(db, zName);\n    pNew = pWith;\n  }else{\n    pNew->a[pNew->nCte].pSelect = pQuery;\n    pNew->a[pNew->nCte].pCols = pArglist;\n    pNew->a[pNew->nCte].zName = zName;\n    pNew->a[pNew->nCte].zCteErr = 0;\n    pNew->nCte++;\n  }\n\n  return pNew;\n}\n\n/*\n** Free the contents of the With object passed as the second argument.\n*/\nSQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){\n  if( pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      struct Cte *pCte = &pWith->a[i];\n      sqlite3ExprListDelete(db, pCte->pCols);\n      sqlite3SelectDelete(db, pCte->pSelect);\n      sqlite3DbFree(db, pCte->zName);\n    }\n    sqlite3DbFree(db, pWith);\n  }\n}\n#endif /* !defined(SQLITE_OMIT_CTE) */\n\n/************** End of build.c ***********************************************/\n/************** Begin file callback.c ****************************************/\n/*\n** 2005 May 23 \n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains functions used to access the internal hash tables\n** of user defined functions and collation sequences.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Invoke the 'collation needed' callback to request a collation sequence\n** in the encoding enc of name zName, length nName.\n*/\nstatic void callCollNeeded(sqlite3 *db, int enc, const char *zName){\n  assert( !db->xCollNeeded || !db->xCollNeeded16 );\n  if( db->xCollNeeded ){\n    char *zExternal = sqlite3DbStrDup(db, zName);\n    if( !zExternal ) return;\n    db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);\n    sqlite3DbFree(db, zExternal);\n  }\n#ifndef SQLITE_OMIT_UTF16\n  if( db->xCollNeeded16 ){\n    char const *zExternal;\n    sqlite3_value *pTmp = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);\n    zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);\n    if( zExternal ){\n      db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);\n    }\n    sqlite3ValueFree(pTmp);\n  }\n#endif\n}\n\n/*\n** This routine is called if the collation factory fails to deliver a\n** collation function in the best encoding but there may be other versions\n** of this collation function (for other text encodings) available. Use one\n** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if\n** possible.\n*/\nstatic int synthCollSeq(sqlite3 *db, CollSeq *pColl){\n  CollSeq *pColl2;\n  char *z = pColl->zName;\n  int i;\n  static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };\n  for(i=0; i<3; i++){\n    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0);\n    if( pColl2->xCmp!=0 ){\n      memcpy(pColl, pColl2, sizeof(CollSeq));\n      pColl->xDel = 0;         /* Do not copy the destructor */\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** This function is responsible for invoking the collation factory callback\n** or substituting a collation sequence of a different encoding when the\n** requested collation sequence is not available in the desired encoding.\n** \n** If it is not NULL, then pColl must point to the database native encoding \n** collation sequence with name zName, length nName.\n**\n** The return value is either the collation sequence to be used in database\n** db for collation type name zName, length nName, or NULL, if no collation\n** sequence can be found.  If no collation is found, leave an error message.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(\n  Parse *pParse,        /* Parsing context */\n  u8 enc,               /* The desired encoding for the collating sequence */\n  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */\n  const char *zName     /* Collating sequence name */\n){\n  CollSeq *p;\n  sqlite3 *db = pParse->db;\n\n  p = pColl;\n  if( !p ){\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( !p || !p->xCmp ){\n    /* No collation sequence of this type for this encoding is registered.\n    ** Call the collation factory to see if it can supply us with one.\n    */\n    callCollNeeded(db, enc, zName);\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( p && !p->xCmp && synthCollSeq(db, p) ){\n    p = 0;\n  }\n  assert( !p || p->xCmp );\n  if( p==0 ){\n    sqlite3ErrorMsg(pParse, \"no such collation sequence: %s\", zName);\n  }\n  return p;\n}\n\n/*\n** This routine is called on a collation sequence before it is used to\n** check that it is defined. An undefined collation sequence exists when\n** a database is loaded that contains references to collation sequences\n** that have not been defined by sqlite3_create_collation() etc.\n**\n** If required, this routine calls the 'collation needed' callback to\n** request a definition of the collating sequence. If this doesn't work, \n** an equivalent collating sequence that uses a text encoding different\n** from the main database is substituted, if one is available.\n*/\nSQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){\n  if( pColl && pColl->xCmp==0 ){\n    const char *zName = pColl->zName;\n    sqlite3 *db = pParse->db;\n    CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);\n    if( !p ){\n      return SQLITE_ERROR;\n    }\n    assert( p==pColl );\n  }\n  return SQLITE_OK;\n}\n\n\n\n/*\n** Locate and return an entry from the db.aCollSeq hash table. If the entry\n** specified by zName and nName is not found and parameter 'create' is\n** true, then create a new entry. Otherwise return NULL.\n**\n** Each pointer stored in the sqlite3.aCollSeq hash table contains an\n** array of three CollSeq structures. The first is the collation sequence\n** preferred for UTF-8, the second UTF-16le, and the third UTF-16be.\n**\n** Stored immediately after the three collation sequences is a copy of\n** the collation sequence name. A pointer to this string is stored in\n** each collation sequence structure.\n*/\nstatic CollSeq *findCollSeqEntry(\n  sqlite3 *db,          /* Database connection */\n  const char *zName,    /* Name of the collating sequence */\n  int create            /* Create a new entry if true */\n){\n  CollSeq *pColl;\n  pColl = sqlite3HashFind(&db->aCollSeq, zName);\n\n  if( 0==pColl && create ){\n    int nName = sqlite3Strlen30(zName) + 1;\n    pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName);\n    if( pColl ){\n      CollSeq *pDel = 0;\n      pColl[0].zName = (char*)&pColl[3];\n      pColl[0].enc = SQLITE_UTF8;\n      pColl[1].zName = (char*)&pColl[3];\n      pColl[1].enc = SQLITE_UTF16LE;\n      pColl[2].zName = (char*)&pColl[3];\n      pColl[2].enc = SQLITE_UTF16BE;\n      memcpy(pColl[0].zName, zName, nName);\n      pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);\n\n      /* If a malloc() failure occurred in sqlite3HashInsert(), it will \n      ** return the pColl pointer to be deleted (because it wasn't added\n      ** to the hash table).\n      */\n      assert( pDel==0 || pDel==pColl );\n      if( pDel!=0 ){\n        sqlite3OomFault(db);\n        sqlite3DbFree(db, pDel);\n        pColl = 0;\n      }\n    }\n  }\n  return pColl;\n}\n\n/*\n** Parameter zName points to a UTF-8 encoded string nName bytes long.\n** Return the CollSeq* pointer for the collation sequence named zName\n** for the encoding 'enc' from the database 'db'.\n**\n** If the entry specified is not found and 'create' is true, then create a\n** new entry.  Otherwise return NULL.\n**\n** A separate function sqlite3LocateCollSeq() is a wrapper around\n** this routine.  sqlite3LocateCollSeq() invokes the collation factory\n** if necessary and generates an error message if the collating sequence\n** cannot be found.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()\n*/\nSQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(\n  sqlite3 *db,\n  u8 enc,\n  const char *zName,\n  int create\n){\n  CollSeq *pColl;\n  if( zName ){\n    pColl = findCollSeqEntry(db, zName, create);\n  }else{\n    pColl = db->pDfltColl;\n  }\n  assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n  assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );\n  if( pColl ) pColl += enc-1;\n  return pColl;\n}\n\n/* During the search for the best function definition, this procedure\n** is called to test how well the function passed as the first argument\n** matches the request for a function with nArg arguments in a system\n** that uses encoding enc. The value returned indicates how well the\n** request is matched. A higher value indicates a better match.\n**\n** If nArg is -1 that means to only return a match (non-zero) if p->nArg\n** is also -1.  In other words, we are searching for a function that\n** takes a variable number of arguments.\n**\n** If nArg is -2 that means that we are searching for any function \n** regardless of the number of arguments it uses, so return a positive\n** match score for any\n**\n** The returned value is always between 0 and 6, as follows:\n**\n** 0: Not a match.\n** 1: UTF8/16 conversion required and function takes any number of arguments.\n** 2: UTF16 byte order change required and function takes any number of args.\n** 3: encoding matches and function takes any number of arguments\n** 4: UTF8/16 conversion required - argument count matches exactly\n** 5: UTF16 byte order conversion required - argument count matches exactly\n** 6: Perfect match:  encoding and argument count match exactly.\n**\n** If nArg==(-2) then any function with a non-null xSFunc is\n** a perfect match and any function with xSFunc NULL is\n** a non-match.\n*/\n#define FUNC_PERFECT_MATCH 6  /* The score for a perfect match */\nstatic int matchQuality(\n  FuncDef *p,     /* The function we are evaluating for match quality */\n  int nArg,       /* Desired number of arguments.  (-1)==any */\n  u8 enc          /* Desired text encoding */\n){\n  int match;\n\n  /* nArg of -2 is a special case */\n  if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;\n\n  /* Wrong number of arguments means \"no match\" */\n  if( p->nArg!=nArg && p->nArg>=0 ) return 0;\n\n  /* Give a better score to a function with a specific number of arguments\n  ** than to function that accepts any number of arguments. */\n  if( p->nArg==nArg ){\n    match = 4;\n  }else{\n    match = 1;\n  }\n\n  /* Bonus points if the text encoding matches */\n  if( enc==(p->funcFlags & SQLITE_FUNC_ENCMASK) ){\n    match += 2;  /* Exact encoding match */\n  }else if( (enc & p->funcFlags & 2)!=0 ){\n    match += 1;  /* Both are UTF16, but with different byte orders */\n  }\n\n  return match;\n}\n\n/*\n** Search a FuncDefHash for a function with the given name.  Return\n** a pointer to the matching FuncDef if found, or 0 if there is no match.\n*/\nstatic FuncDef *functionSearch(\n  int h,               /* Hash of the name */\n  const char *zFunc    /* Name of function */\n){\n  FuncDef *p;\n  for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){\n    if( sqlite3StrICmp(p->zName, zFunc)==0 ){\n      return p;\n    }\n  }\n  return 0;\n}\n\n/*\n** Insert a new FuncDef into a FuncDefHash hash table.\n*/\nSQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(\n  FuncDef *aDef,      /* List of global functions to be inserted */\n  int nDef            /* Length of the apDef[] list */\n){\n  int i;\n  for(i=0; i<nDef; i++){\n    FuncDef *pOther;\n    const char *zName = aDef[i].zName;\n    int nName = sqlite3Strlen30(zName);\n    int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;\n    assert( zName[0]>='a' && zName[0]<='z' );\n    pOther = functionSearch(h, zName);\n    if( pOther ){\n      assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );\n      aDef[i].pNext = pOther->pNext;\n      pOther->pNext = &aDef[i];\n    }else{\n      aDef[i].pNext = 0;\n      aDef[i].u.pHash = sqlite3BuiltinFunctions.a[h];\n      sqlite3BuiltinFunctions.a[h] = &aDef[i];\n    }\n  }\n}\n  \n  \n\n/*\n** Locate a user function given a name, a number of arguments and a flag\n** indicating whether the function prefers UTF-16 over UTF-8.  Return a\n** pointer to the FuncDef structure that defines that function, or return\n** NULL if the function does not exist.\n**\n** If the createFlag argument is true, then a new (blank) FuncDef\n** structure is created and liked into the \"db\" structure if a\n** no matching function previously existed.\n**\n** If nArg is -2, then the first valid function found is returned.  A\n** function is valid if xSFunc is non-zero.  The nArg==(-2)\n** case is used to see if zName is a valid function name for some number\n** of arguments.  If nArg is -2, then createFlag must be 0.\n**\n** If createFlag is false, then a function with the required name and\n** number of arguments may be returned even if the eTextRep flag does not\n** match that requested.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3FindFunction(\n  sqlite3 *db,       /* An open database */\n  const char *zName, /* Name of the function.  zero-terminated */\n  int nArg,          /* Number of arguments.  -1 means any number */\n  u8 enc,            /* Preferred text encoding */\n  u8 createFlag      /* Create new entry if true and does not otherwise exist */\n){\n  FuncDef *p;         /* Iterator variable */\n  FuncDef *pBest = 0; /* Best match found so far */\n  int bestScore = 0;  /* Score of best match */\n  int h;              /* Hash value */\n  int nName;          /* Length of the name */\n\n  assert( nArg>=(-2) );\n  assert( nArg>=(-1) || createFlag==0 );\n  nName = sqlite3Strlen30(zName);\n\n  /* First search for a match amongst the application-defined functions.\n  */\n  p = (FuncDef*)sqlite3HashFind(&db->aFunc, zName);\n  while( p ){\n    int score = matchQuality(p, nArg, enc);\n    if( score>bestScore ){\n      pBest = p;\n      bestScore = score;\n    }\n    p = p->pNext;\n  }\n\n  /* If no match is found, search the built-in functions.\n  **\n  ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in\n  ** functions even if a prior app-defined function was found.  And give\n  ** priority to built-in functions.\n  **\n  ** Except, if createFlag is true, that means that we are trying to\n  ** install a new function.  Whatever FuncDef structure is returned it will\n  ** have fields overwritten with new information appropriate for the\n  ** new function.  But the FuncDefs for built-in functions are read-only.\n  ** So we must not search for built-ins when creating a new function.\n  */ \n  if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){\n    bestScore = 0;\n    h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;\n    p = functionSearch(h, zName);\n    while( p ){\n      int score = matchQuality(p, nArg, enc);\n      if( score>bestScore ){\n        pBest = p;\n        bestScore = score;\n      }\n      p = p->pNext;\n    }\n  }\n\n  /* If the createFlag parameter is true and the search did not reveal an\n  ** exact match for the name, number of arguments and encoding, then add a\n  ** new entry to the hash table and return it.\n  */\n  if( createFlag && bestScore<FUNC_PERFECT_MATCH && \n      (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){\n    FuncDef *pOther;\n    pBest->zName = (const char*)&pBest[1];\n    pBest->nArg = (u16)nArg;\n    pBest->funcFlags = enc;\n    memcpy((char*)&pBest[1], zName, nName+1);\n    pOther = (FuncDef*)sqlite3HashInsert(&db->aFunc, pBest->zName, pBest);\n    if( pOther==pBest ){\n      sqlite3DbFree(db, pBest);\n      sqlite3OomFault(db);\n      return 0;\n    }else{\n      pBest->pNext = pOther;\n    }\n  }\n\n  if( pBest && (pBest->xSFunc || createFlag) ){\n    return pBest;\n  }\n  return 0;\n}\n\n/*\n** Free all resources held by the schema structure. The void* argument points\n** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the \n** pointer itself, it just cleans up subsidiary resources (i.e. the contents\n** of the schema hash tables).\n**\n** The Schema.cache_size variable is not cleared.\n*/\nSQLITE_PRIVATE void sqlite3SchemaClear(void *p){\n  Hash temp1;\n  Hash temp2;\n  HashElem *pElem;\n  Schema *pSchema = (Schema *)p;\n\n  temp1 = pSchema->tblHash;\n  temp2 = pSchema->trigHash;\n  sqlite3HashInit(&pSchema->trigHash);\n  sqlite3HashClear(&pSchema->idxHash);\n  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){\n    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));\n  }\n  sqlite3HashClear(&temp2);\n  sqlite3HashInit(&pSchema->tblHash);\n  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    sqlite3DeleteTable(0, pTab);\n  }\n  sqlite3HashClear(&temp1);\n  sqlite3HashClear(&pSchema->fkeyHash);\n  pSchema->pSeqTab = 0;\n  if( pSchema->schemaFlags & DB_SchemaLoaded ){\n    pSchema->iGeneration++;\n  }\n  pSchema->schemaFlags &= ~(DB_SchemaLoaded|DB_ResetWanted);\n}\n\n/*\n** Find and return the schema associated with a BTree.  Create\n** a new one if necessary.\n*/\nSQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){\n  Schema * p;\n  if( pBt ){\n    p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);\n  }else{\n    p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));\n  }\n  if( !p ){\n    sqlite3OomFault(db);\n  }else if ( 0==p->file_format ){\n    sqlite3HashInit(&p->tblHash);\n    sqlite3HashInit(&p->idxHash);\n    sqlite3HashInit(&p->trigHash);\n    sqlite3HashInit(&p->fkeyHash);\n    p->enc = SQLITE_UTF8;\n  }\n  return p;\n}\n\n/************** End of callback.c ********************************************/\n/************** Begin file delete.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** in order to generate code for DELETE FROM statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** While a SrcList can in general represent multiple tables and subqueries\n** (as in the FROM clause of a SELECT statement) in this case it contains\n** the name of a single table, as one might find in an INSERT, DELETE,\n** or UPDATE statement.  Look up that table in the symbol table and\n** return a pointer.  Set an error message and return NULL if the table \n** name is not found or if any other error occurs.\n**\n** The following fields are initialized appropriate in pSrc:\n**\n**    pSrc->a[0].pTab       Pointer to the Table object\n**    pSrc->a[0].pIndex     Pointer to the INDEXED BY index, if there is one\n**\n*/\nSQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){\n  struct SrcList_item *pItem = pSrc->a;\n  Table *pTab;\n  assert( pItem && pSrc->nSrc==1 );\n  pTab = sqlite3LocateTableItem(pParse, 0, pItem);\n  sqlite3DeleteTable(pParse->db, pItem->pTab);\n  pItem->pTab = pTab;\n  if( pTab ){\n    pTab->nTabRef++;\n  }\n  if( sqlite3IndexedByLookup(pParse, pItem) ){\n    pTab = 0;\n  }\n  return pTab;\n}\n\n/*\n** Check to make sure the given table is writable.  If it is not\n** writable, generate an error message and return 1.  If it is\n** writable return 0;\n*/\nSQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){\n  /* A table is not writable under the following circumstances:\n  **\n  **   1) It is a virtual table and no implementation of the xUpdate method\n  **      has been provided, or\n  **   2) It is a system table (i.e. sqlite_master), this call is not\n  **      part of a nested parse and writable_schema pragma has not \n  **      been specified.\n  **\n  ** In either case leave an error message in pParse and return non-zero.\n  */\n  if( ( IsVirtual(pTab) \n     && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 )\n   || ( (pTab->tabFlags & TF_Readonly)!=0\n     && (pParse->db->flags & SQLITE_WriteSchema)==0\n     && pParse->nested==0 )\n  ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be modified\", pTab->zName);\n    return 1;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( !viewOk && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse,\"cannot modify %s because it is a view\",pTab->zName);\n    return 1;\n  }\n#endif\n  return 0;\n}\n\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Evaluate a view and store its result in an ephemeral table.  The\n** pWhere argument is an optional WHERE clause that restricts the\n** set of rows in the view that are to be added to the ephemeral table.\n*/\nSQLITE_PRIVATE void sqlite3MaterializeView(\n  Parse *pParse,       /* Parsing context */\n  Table *pView,        /* View definition */\n  Expr *pWhere,        /* Optional WHERE clause to be added */\n  int iCur             /* Cursor number for ephemeral table */\n){\n  SelectDest dest;\n  Select *pSel;\n  SrcList *pFrom;\n  sqlite3 *db = pParse->db;\n  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);\n  pWhere = sqlite3ExprDup(db, pWhere, 0);\n  pFrom = sqlite3SrcListAppend(db, 0, 0, 0);\n  if( pFrom ){\n    assert( pFrom->nSrc==1 );\n    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);\n    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);\n    assert( pFrom->a[0].pOn==0 );\n    assert( pFrom->a[0].pUsing==0 );\n  }\n  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, \n                          SF_IncludeHidden, 0, 0);\n  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);\n  sqlite3Select(pParse, pSel, &dest);\n  sqlite3SelectDelete(db, pSel);\n}\n#endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Generate an expression tree to implement the WHERE, ORDER BY,\n** and LIMIT/OFFSET portion of DELETE and UPDATE statements.\n**\n**     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;\n**                            \\__________________________/\n**                               pLimitWhere (pInClause)\n*/\nSQLITE_PRIVATE Expr *sqlite3LimitWhere(\n  Parse *pParse,               /* The parser context */\n  SrcList *pSrc,               /* the FROM clause -- which tables to scan */\n  Expr *pWhere,                /* The WHERE clause.  May be null */\n  ExprList *pOrderBy,          /* The ORDER BY clause.  May be null */\n  Expr *pLimit,                /* The LIMIT clause.  May be null */\n  Expr *pOffset,               /* The OFFSET clause.  May be null */\n  char *zStmtType              /* Either DELETE or UPDATE.  For err msgs. */\n){\n  Expr *pWhereRowid = NULL;    /* WHERE rowid .. */\n  Expr *pInClause = NULL;      /* WHERE rowid IN ( select ) */\n  Expr *pSelectRowid = NULL;   /* SELECT rowid ... */\n  ExprList *pEList = NULL;     /* Expression list contaning only pSelectRowid */\n  SrcList *pSelectSrc = NULL;  /* SELECT rowid FROM x ... (dup of pSrc) */\n  Select *pSelect = NULL;      /* Complete SELECT tree */\n\n  /* Check that there isn't an ORDER BY without a LIMIT clause.\n  */\n  if( pOrderBy && (pLimit == 0) ) {\n    sqlite3ErrorMsg(pParse, \"ORDER BY without LIMIT on %s\", zStmtType);\n    goto limit_where_cleanup;\n  }\n\n  /* We only need to generate a select expression if there\n  ** is a limit/offset term to enforce.\n  */\n  if( pLimit == 0 ) {\n    /* if pLimit is null, pOffset will always be null as well. */\n    assert( pOffset == 0 );\n    return pWhere;\n  }\n\n  /* Generate a select expression tree to enforce the limit/offset \n  ** term for the DELETE or UPDATE statement.  For example:\n  **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  ** becomes:\n  **   DELETE FROM table_a WHERE rowid IN ( \n  **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  **   );\n  */\n\n  pSelectRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0);\n  if( pSelectRowid == 0 ) goto limit_where_cleanup;\n  pEList = sqlite3ExprListAppend(pParse, 0, pSelectRowid);\n  if( pEList == 0 ) goto limit_where_cleanup;\n\n  /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree\n  ** and the SELECT subtree. */\n  pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);\n  if( pSelectSrc == 0 ) {\n    sqlite3ExprListDelete(pParse->db, pEList);\n    goto limit_where_cleanup;\n  }\n\n  /* generate the SELECT expression tree. */\n  pSelect = sqlite3SelectNew(pParse,pEList,pSelectSrc,pWhere,0,0,\n                             pOrderBy,0,pLimit,pOffset);\n  if( pSelect == 0 ) return 0;\n\n  /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */\n  pWhereRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0);\n  pInClause = pWhereRowid ? sqlite3PExpr(pParse, TK_IN, pWhereRowid, 0) : 0;\n  sqlite3PExprAddSelect(pParse, pInClause, pSelect);\n  return pInClause;\n\nlimit_where_cleanup:\n  sqlite3ExprDelete(pParse->db, pWhere);\n  sqlite3ExprListDelete(pParse->db, pOrderBy);\n  sqlite3ExprDelete(pParse->db, pLimit);\n  sqlite3ExprDelete(pParse->db, pOffset);\n  return 0;\n}\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) */\n       /*      && !defined(SQLITE_OMIT_SUBQUERY) */\n\n/*\n** Generate code for a DELETE FROM statement.\n**\n**     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;\n**                 \\________/       \\________________/\n**                  pTabList              pWhere\n*/\nSQLITE_PRIVATE void sqlite3DeleteFrom(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table from which we should delete things */\n  Expr *pWhere           /* The WHERE clause.  May be null */\n){\n  Vdbe *v;               /* The virtual database engine */\n  Table *pTab;           /* The table from which records will be deleted */\n  int i;                 /* Loop counter */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Index *pIdx;           /* For looping over indices of the table */\n  int iTabCur;           /* Cursor number for the table */\n  int iDataCur = 0;      /* VDBE cursor for the canonical data source */\n  int iIdxCur = 0;       /* Cursor number of the first index */\n  int nIdx;              /* Number of indices */\n  sqlite3 *db;           /* Main database structure */\n  AuthContext sContext;  /* Authorization context */\n  NameContext sNC;       /* Name context to resolve expressions in */\n  int iDb;               /* Database number */\n  int memCnt = -1;       /* Memory cell used for change counting */\n  int rcauth;            /* Value returned by authorization callback */\n  int eOnePass;          /* ONEPASS_OFF or _SINGLE or _MULTI */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */\n  Index *pPk;            /* The PRIMARY KEY index on the table */\n  int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */\n  i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */\n  int iKey;              /* Memory cell holding key of row to be deleted */\n  i16 nKey;              /* Number of memory cells in the row key */\n  int iEphCur = 0;       /* Ephemeral table holding all primary key values */\n  int iRowSet = 0;       /* Register for rowset of rows to delete */\n  int addrBypass = 0;    /* Address of jump over the delete logic */\n  int addrLoop = 0;      /* Top of the delete loop */\n  int addrEphOpen = 0;   /* Instruction to open the Ephemeral table */\n  int bComplex;          /* True if there are triggers or FKs or\n                         ** subqueries in the WHERE clause */\n \n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                  /* True if attempting to delete from a view */\n  Trigger *pTrigger;           /* List of table triggers, if required */\n#endif\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto delete_from_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to delete.  This table has to be\n  ** put in an SrcList structure because some of the subroutines we\n  ** will be calling are designed to work with multiple tables and expect\n  ** an SrcList* parameter instead of just a Table* parameter.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 )  goto delete_from_cleanup;\n\n  /* Figure out if we have any triggers and if the table being\n  ** deleted from is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n  isView = pTab->pSelect!=0;\n  bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);\n#else\n# define pTrigger 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  /* If pTab is really a view, make sure it has been initialized.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto delete_from_cleanup;\n  }\n\n  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){\n    goto delete_from_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, \n                            db->aDb[iDb].zDbSName);\n  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );\n  if( rcauth==SQLITE_DENY ){\n    goto delete_from_cleanup;\n  }\n  assert(!isView || pTrigger);\n\n  /* Assign cursor numbers to the table and all its indices.\n  */\n  assert( pTabList->nSrc==1 );\n  iTabCur = pTabList->a[0].iCursor = pParse->nTab++;\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    pParse->nTab++;\n  }\n\n  /* Start the view context\n  */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* Begin generating code.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto delete_from_cleanup;\n  }\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n  /* If we are trying to delete from a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iTabCur);\n    iDataCur = iIdxCur = iTabCur;\n  }\n#endif\n\n  /* Resolve the column names in the WHERE clause.\n  */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto delete_from_cleanup;\n  }\n\n  /* Initialize the counter of the number of rows deleted, if\n  ** we are counting rows.\n  */\n  if( db->flags & SQLITE_CountRows ){\n    memCnt = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);\n  }\n\n#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  /* Special case: A DELETE without a WHERE clause deletes everything.\n  ** It is easier just to erase the whole table. Prior to version 3.6.5,\n  ** this optimization caused the row change count (the value returned by \n  ** API function sqlite3_count_changes) to be set incorrectly.\n  **\n  ** The \"rcauth==SQLITE_OK\" terms is the\n  ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and\n  ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but\n  ** the truncate optimization is disabled and all rows are deleted\n  ** individually.\n  */\n  if( rcauth==SQLITE_OK\n   && pWhere==0\n   && !bComplex\n   && !IsVirtual(pTab)\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n   && db->xPreUpdateCallback==0\n#endif\n  ){\n    assert( !isView );\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,\n                        pTab->zName, P4_STATIC);\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->pSchema==pTab->pSchema );\n      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);\n    }\n  }else\n#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */\n  {\n    u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK|WHERE_SEEK_TABLE;\n    if( sNC.ncFlags & NC_VarSelect ) bComplex = 1;\n    wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW);\n    if( HasRowid(pTab) ){\n      /* For a rowid table, initialize the RowSet to an empty set */\n      pPk = 0;\n      nPk = 1;\n      iRowSet = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);\n    }else{\n      /* For a WITHOUT ROWID table, create an ephemeral table used to\n      ** hold all primary keys for rows to be deleted. */\n      pPk = sqlite3PrimaryKeyIndex(pTab);\n      assert( pPk!=0 );\n      nPk = pPk->nKeyCol;\n      iPk = pParse->nMem+1;\n      pParse->nMem += nPk;\n      iEphCur = pParse->nTab++;\n      addrEphOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEphCur, nPk);\n      sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    }\n  \n    /* Construct a query to find the rowid or primary key for every row\n    ** to be deleted, based on the WHERE clause. Set variable eOnePass\n    ** to indicate the strategy used to implement this delete:\n    **\n    **  ONEPASS_OFF:    Two-pass approach - use a FIFO for rowids/PK values.\n    **  ONEPASS_SINGLE: One-pass approach - at most one row deleted.\n    **  ONEPASS_MULTI:  One-pass approach - any number of rows may be deleted.\n    */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);\n    if( pWInfo==0 ) goto delete_from_cleanup;\n    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n    assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );\n    assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );\n  \n    /* Keep track of the number of rows to be deleted */\n    if( db->flags & SQLITE_CountRows ){\n      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);\n    }\n  \n    /* Extract the rowid or primary key for the current row */\n    if( pPk ){\n      for(i=0; i<nPk; i++){\n        assert( pPk->aiColumn[i]>=0 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,\n                                        pPk->aiColumn[i], iPk+i);\n      }\n      iKey = iPk;\n    }else{\n      iKey = pParse->nMem + 1;\n      iKey = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iTabCur, iKey, 0);\n      if( iKey>pParse->nMem ) pParse->nMem = iKey;\n    }\n  \n    if( eOnePass!=ONEPASS_OFF ){\n      /* For ONEPASS, no need to store the rowid/primary-key. There is only\n      ** one, so just keep it in its register(s) and fall through to the\n      ** delete code.  */\n      nKey = nPk; /* OP_Found will use an unpacked key */\n      aToOpen = sqlite3DbMallocRawNN(db, nIdx+2);\n      if( aToOpen==0 ){\n        sqlite3WhereEnd(pWInfo);\n        goto delete_from_cleanup;\n      }\n      memset(aToOpen, 1, nIdx+1);\n      aToOpen[nIdx+1] = 0;\n      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iTabCur] = 0;\n      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iTabCur] = 0;\n      if( addrEphOpen ) sqlite3VdbeChangeToNoop(v, addrEphOpen);\n    }else{\n      if( pPk ){\n        /* Add the PK key for this row to the temporary table */\n        iKey = ++pParse->nMem;\n        nKey = 0;   /* Zero tells OP_Found to use a composite key */\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,\n            sqlite3IndexAffinityStr(pParse->db, pPk), nPk);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);\n      }else{\n        /* Add the rowid of the row to be deleted to the RowSet */\n        nKey = 1;  /* OP_DeferredSeek always uses a single rowid */\n        sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);\n      }\n    }\n  \n    /* If this DELETE cannot use the ONEPASS strategy, this is the \n    ** end of the WHERE loop */\n    if( eOnePass!=ONEPASS_OFF ){\n      addrBypass = sqlite3VdbeMakeLabel(v);\n    }else{\n      sqlite3WhereEnd(pWInfo);\n    }\n  \n    /* Unless this is a view, open cursors for the table we are \n    ** deleting from and all its indices. If this is a view, then the\n    ** only effect this statement has is to fire the INSTEAD OF \n    ** triggers.\n    */\n    if( !isView ){\n      int iAddrOnce = 0;\n      if( eOnePass==ONEPASS_MULTI ){\n        iAddrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n      }\n      testcase( IsVirtual(pTab) );\n      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE,\n                                 iTabCur, aToOpen, &iDataCur, &iIdxCur);\n      assert( pPk || IsVirtual(pTab) || iDataCur==iTabCur );\n      assert( pPk || IsVirtual(pTab) || iIdxCur==iDataCur+1 );\n      if( eOnePass==ONEPASS_MULTI ) sqlite3VdbeJumpHere(v, iAddrOnce);\n    }\n  \n    /* Set up a loop over the rowids/primary-keys that were found in the\n    ** where-clause loop above.\n    */\n    if( eOnePass!=ONEPASS_OFF ){\n      assert( nKey==nPk );  /* OP_Found will use an unpacked key */\n      if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){\n        assert( pPk!=0 || pTab->pSelect!=0 );\n        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);\n        VdbeCoverage(v);\n      }\n    }else if( pPk ){\n      addrLoop = sqlite3VdbeAddOp1(v, OP_Rewind, iEphCur); VdbeCoverage(v);\n      if( IsVirtual(pTab) ){\n        sqlite3VdbeAddOp3(v, OP_Column, iEphCur, 0, iKey);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_RowData, iEphCur, iKey);\n      }\n      assert( nKey==0 );  /* OP_Found will use a composite key */\n    }else{\n      addrLoop = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, 0, iKey);\n      VdbeCoverage(v);\n      assert( nKey==1 );\n    }  \n  \n    /* Delete the row */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, OE_Abort);\n      assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );\n      sqlite3MayAbort(pParse);\n      if( eOnePass==ONEPASS_SINGLE && sqlite3IsToplevel(pParse) ){\n        pParse->isMultiWrite = 0;\n      }\n    }else\n#endif\n    {\n      int count = (pParse->nested==0);    /* True to count changes */\n      sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n          iKey, nKey, count, OE_Default, eOnePass, aiCurOnePass[1]);\n    }\n  \n    /* End of the loop over all rowids/primary-keys. */\n    if( eOnePass!=ONEPASS_OFF ){\n      sqlite3VdbeResolveLabel(v, addrBypass);\n      sqlite3WhereEnd(pWInfo);\n    }else if( pPk ){\n      sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }else{\n      sqlite3VdbeGoto(v, addrLoop);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }     \n  } /* End non-truncate path */\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /* Return the number of rows that were deleted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows deleted\", SQLITE_STATIC);\n  }\n\ndelete_from_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprDelete(db, pWhere);\n  sqlite3DbFree(db, aToOpen);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n/*\n** This routine generates VDBE code that causes a single row of a\n** single table to be deleted.  Both the original table entry and\n** all indices are removed.\n**\n** Preconditions:\n**\n**   1.  iDataCur is an open cursor on the btree that is the canonical data\n**       store for the table.  (This will be either the table itself,\n**       in the case of a rowid table, or the PRIMARY KEY index in the case\n**       of a WITHOUT ROWID table.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.\n**\n**   3.  The primary key for the row to be deleted must be stored in a\n**       sequence of nPk memory cells starting at iPk.  If nPk==0 that means\n**       that a search record formed from OP_MakeRecord is contained in the\n**       single memory location iPk.\n**\n** eMode:\n**   Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or\n**   ONEPASS_MULTI.  If eMode is not ONEPASS_OFF, then the cursor\n**   iDataCur already points to the row to delete. If eMode is ONEPASS_OFF\n**   then this function must seek iDataCur to the entry identified by iPk\n**   and nPk before reading from it.\n**\n**   If eMode is ONEPASS_MULTI, then this call is being made as part\n**   of a ONEPASS delete that affects multiple rows. In this case, if \n**   iIdxNoSeek is a valid cursor number (>=0) and is not the same as\n**   iDataCur, then its position should be preserved following the delete\n**   operation. Or, if iIdxNoSeek is not a valid cursor number, the\n**   position of iDataCur should be preserved instead.\n**\n** iIdxNoSeek:\n**   If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur,\n**   then it identifies an index cursor (from within array of cursors\n**   starting at iIdxCur) that already points to the index entry to be deleted.\n**   Except, this optimization is disabled if there are BEFORE triggers since\n**   the trigger body might have moved the cursor.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowDelete(\n  Parse *pParse,     /* Parsing context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  Trigger *pTrigger, /* List of triggers to (potentially) fire */\n  int iDataCur,      /* Cursor from which column data is extracted */\n  int iIdxCur,       /* First index cursor */\n  int iPk,           /* First memory cell containing the PRIMARY KEY */\n  i16 nPk,           /* Number of PRIMARY KEY memory cells */\n  u8 count,          /* If non-zero, increment the row change counter */\n  u8 onconf,         /* Default ON CONFLICT policy for triggers */\n  u8 eMode,          /* ONEPASS_OFF, _SINGLE, or _MULTI.  See above */\n  int iIdxNoSeek     /* Cursor number of cursor that does not need seeking */\n){\n  Vdbe *v = pParse->pVdbe;        /* Vdbe */\n  int iOld = 0;                   /* First register in OLD.* array */\n  int iLabel;                     /* Label resolved to end of generated code */\n  u8 opSeek;                      /* Seek opcode */\n\n  /* Vdbe is guaranteed to have been allocated by this stage. */\n  assert( v );\n  VdbeModuleComment((v, \"BEGIN: GenRowDel(%d,%d,%d,%d)\",\n                         iDataCur, iIdxCur, iPk, (int)nPk));\n\n  /* Seek cursor iCur to the row to delete. If this row no longer exists \n  ** (this can happen if a trigger program has already deleted it), do\n  ** not attempt to delete it or fire any DELETE triggers.  */\n  iLabel = sqlite3VdbeMakeLabel(v);\n  opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n  if( eMode==ONEPASS_OFF ){\n    sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n    VdbeCoverageIf(v, opSeek==OP_NotExists);\n    VdbeCoverageIf(v, opSeek==OP_NotFound);\n  }\n \n  /* If there are any triggers to fire, allocate a range of registers to\n  ** use for the old.* references in the triggers.  */\n  if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){\n    u32 mask;                     /* Mask of OLD.* columns in use */\n    int iCol;                     /* Iterator used while populating OLD.* */\n    int addrStart;                /* Start of BEFORE trigger programs */\n\n    /* TODO: Could use temporary registers here. Also could attempt to\n    ** avoid copying the contents of the rowid register.  */\n    mask = sqlite3TriggerColmask(\n        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf\n    );\n    mask |= sqlite3FkOldmask(pParse, pTab);\n    iOld = pParse->nMem+1;\n    pParse->nMem += (1 + pTab->nCol);\n\n    /* Populate the OLD.* pseudo-table register array. These values will be \n    ** used by any BEFORE and AFTER triggers that exist.  */\n    sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      testcase( mask!=0xffffffff && iCol==31 );\n      testcase( mask!=0xffffffff && iCol==32 );\n      if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);\n      }\n    }\n\n    /* Invoke BEFORE DELETE trigger programs. */\n    addrStart = sqlite3VdbeCurrentAddr(v);\n    sqlite3CodeRowTrigger(pParse, pTrigger, \n        TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel\n    );\n\n    /* If any BEFORE triggers were coded, then seek the cursor to the \n    ** row to be deleted again. It may be that the BEFORE triggers moved\n    ** the cursor or already deleted the row that the cursor was\n    ** pointing to.\n    **\n    ** Also disable the iIdxNoSeek optimization since the BEFORE trigger\n    ** may have moved that cursor.\n    */\n    if( addrStart<sqlite3VdbeCurrentAddr(v) ){\n      sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n      VdbeCoverageIf(v, opSeek==OP_NotExists);\n      VdbeCoverageIf(v, opSeek==OP_NotFound);\n      testcase( iIdxNoSeek>=0 );\n      iIdxNoSeek = -1;\n    }\n\n    /* Do FK processing. This call checks that any FK constraints that\n    ** refer to this table (i.e. constraints attached to other tables) \n    ** are not violated by deleting this row.  */\n    sqlite3FkCheck(pParse, pTab, iOld, 0, 0, 0);\n  }\n\n  /* Delete the index and table entries. Skip this step if pTab is really\n  ** a view (in which case the only effect of the DELETE statement is to\n  ** fire the INSTEAD OF triggers).  \n  **\n  ** If variable 'count' is non-zero, then this OP_Delete instruction should\n  ** invoke the update-hook. The pre-update-hook, on the other hand should\n  ** be invoked unless table pTab is a system table. The difference is that\n  ** the update-hook is not invoked for rows removed by REPLACE, but the \n  ** pre-update-hook is.\n  */ \n  if( pTab->pSelect==0 ){\n    u8 p5 = 0;\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);\n    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));\n    if( pParse->nested==0 ){\n      sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE);\n    }\n    if( eMode!=ONEPASS_OFF ){\n      sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);\n    }\n    if( iIdxNoSeek>=0 && iIdxNoSeek!=iDataCur ){\n      sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);\n    }\n    if( eMode==ONEPASS_MULTI ) p5 |= OPFLAG_SAVEPOSITION;\n    sqlite3VdbeChangeP5(v, p5);\n  }\n\n  /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n  ** handle rows (possibly in other tables) that refer via a foreign key\n  ** to the row just deleted. */ \n  sqlite3FkActions(pParse, pTab, 0, iOld, 0, 0);\n\n  /* Invoke AFTER DELETE trigger programs. */\n  sqlite3CodeRowTrigger(pParse, pTrigger, \n      TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel\n  );\n\n  /* Jump here if the row had already been deleted before any BEFORE\n  ** trigger programs were invoked. Or if a trigger program throws a \n  ** RAISE(IGNORE) exception.  */\n  sqlite3VdbeResolveLabel(v, iLabel);\n  VdbeModuleComment((v, \"END: GenRowDel()\"));\n}\n\n/*\n** This routine generates VDBE code that causes the deletion of all\n** index entries associated with a single row of a single table, pTab\n**\n** Preconditions:\n**\n**   1.  A read/write cursor \"iDataCur\" must be open on the canonical storage\n**       btree for the table pTab.  (This will be either the table itself\n**       for rowid tables or to the primary key index for WITHOUT ROWID\n**       tables.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.  (The pTab->pIndex\n**       index is the 0-th index.)\n**\n**   3.  The \"iDataCur\" cursor must be already be positioned on the row\n**       that is to be deleted.\n*/\nSQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  int iDataCur,      /* Cursor of table holding data. */\n  int iIdxCur,       /* First index cursor */\n  int *aRegIdx,      /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */\n  int iIdxNoSeek     /* Do not delete from this cursor */\n){\n  int i;             /* Index loop counter */\n  int r1 = -1;       /* Register holding an index key */\n  int iPartIdxLabel; /* Jump destination for skipping partial index entries */\n  Index *pIdx;       /* Current index */\n  Index *pPrior = 0; /* Prior index */\n  Vdbe *v;           /* The prepared statement under construction */\n  Index *pPk;        /* PRIMARY KEY index, or NULL for rowid tables */\n\n  v = pParse->pVdbe;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){\n    assert( iIdxCur+i!=iDataCur || pPk==pIdx );\n    if( aRegIdx!=0 && aRegIdx[i]==0 ) continue;\n    if( pIdx==pPk ) continue;\n    if( iIdxCur+i==iIdxNoSeek ) continue;\n    VdbeModuleComment((v, \"GenRowIdxDel for %s\", pIdx->zName));\n    r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,\n        &iPartIdxLabel, pPrior, r1);\n    sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,\n        pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);\n    sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n    pPrior = pIdx;\n  }\n}\n\n/*\n** Generate code that will assemble an index key and stores it in register\n** regOut.  The key with be for index pIdx which is an index on pTab.\n** iCur is the index of a cursor open on the pTab table and pointing to\n** the entry that needs indexing.  If pTab is a WITHOUT ROWID table, then\n** iCur must be the cursor of the PRIMARY KEY index.\n**\n** Return a register number which is the first in a block of\n** registers that holds the elements of the index key.  The\n** block of registers has already been deallocated by the time\n** this routine returns.\n**\n** If *piPartIdxLabel is not NULL, fill it in with a label and jump\n** to that label if pIdx is a partial index that should be skipped.\n** The label should be resolved using sqlite3ResolvePartIdxLabel().\n** A partial index should be skipped if its WHERE clause evaluates\n** to false or null.  If pIdx is not a partial index, *piPartIdxLabel\n** will be set to zero which is an empty label that is ignored by\n** sqlite3ResolvePartIdxLabel().\n**\n** The pPrior and regPrior parameters are used to implement a cache to\n** avoid unnecessary register loads.  If pPrior is not NULL, then it is\n** a pointer to a different index for which an index key has just been\n** computed into register regPrior.  If the current pIdx index is generating\n** its key into the same sequence of registers and if pPrior and pIdx share\n** a column in common, then the register corresponding to that column already\n** holds the correct value and the loading of that register is skipped.\n** This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK \n** on a table with multiple indices, and especially with the ROWID or\n** PRIMARY KEY columns of the index.\n*/\nSQLITE_PRIVATE int sqlite3GenerateIndexKey(\n  Parse *pParse,       /* Parsing context */\n  Index *pIdx,         /* The index for which to generate a key */\n  int iDataCur,        /* Cursor number from which to take column data */\n  int regOut,          /* Put the new key into this register if not 0 */\n  int prefixOnly,      /* Compute only a unique prefix of the key */\n  int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */\n  Index *pPrior,       /* Previously generated index key */\n  int regPrior         /* Register holding previous generated key */\n){\n  Vdbe *v = pParse->pVdbe;\n  int j;\n  int regBase;\n  int nCol;\n\n  if( piPartIdxLabel ){\n    if( pIdx->pPartIdxWhere ){\n      *piPartIdxLabel = sqlite3VdbeMakeLabel(v);\n      pParse->iSelfTab = iDataCur + 1;\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, \n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }else{\n      *piPartIdxLabel = 0;\n    }\n  }\n  nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;\n  regBase = sqlite3GetTempRange(pParse, nCol);\n  if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;\n  for(j=0; j<nCol; j++){\n    if( pPrior\n     && pPrior->aiColumn[j]==pIdx->aiColumn[j]\n     && pPrior->aiColumn[j]!=XN_EXPR\n    ){\n      /* This column was already computed by the previous index */\n      continue;\n    }\n    sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);\n    /* If the column affinity is REAL but the number is an integer, then it\n    ** might be stored in the table as an integer (using a compact\n    ** representation) then converted to REAL by an OP_RealAffinity opcode.\n    ** But we are getting ready to store this value back into an index, where\n    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity\n    ** opcode if it is present */\n    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);\n  }\n  if( regOut ){\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);\n    if( pIdx->pTable->pSelect ){\n      const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);\n      sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);\n    }\n  }\n  sqlite3ReleaseTempRange(pParse, regBase, nCol);\n  return regBase;\n}\n\n/*\n** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label\n** because it was a partial index, then this routine should be called to\n** resolve that label.\n*/\nSQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){\n  if( iLabel ){\n    sqlite3VdbeResolveLabel(pParse->pVdbe, iLabel);\n    sqlite3ExprCachePop(pParse);\n  }\n}\n\n/************** End of delete.c **********************************************/\n/************** Begin file func.c ********************************************/\n/*\n** 2002 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C-language implementations for many of the SQL\n** functions of SQLite.  (Some function, and in particular the date and\n** time functions, are implemented separately.)\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n/* #include <assert.h> */\n/* #include \"vdbeInt.h\" */\n\n/*\n** Return the collating function associated with a function.\n*/\nstatic CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){\n  VdbeOp *pOp;\n  assert( context->pVdbe!=0 );\n  pOp = &context->pVdbe->aOp[context->iOp-1];\n  assert( pOp->opcode==OP_CollSeq );\n  assert( pOp->p4type==P4_COLLSEQ );\n  return pOp->p4.pColl;\n}\n\n/*\n** Indicate that the accumulator load should be skipped on this\n** iteration of the aggregate loop.\n*/\nstatic void sqlite3SkipAccumulatorLoad(sqlite3_context *context){\n  context->skipFlag = 1;\n}\n\n/*\n** Implementation of the non-aggregate min() and max() functions\n*/\nstatic void minmaxFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  int mask;    /* 0 for min() or 0xffffffff for max() */\n  int iBest;\n  CollSeq *pColl;\n\n  assert( argc>1 );\n  mask = sqlite3_user_data(context)==0 ? 0 : -1;\n  pColl = sqlite3GetFuncCollSeq(context);\n  assert( pColl );\n  assert( mask==-1 || mask==0 );\n  iBest = 0;\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  for(i=1; i<argc; i++){\n    if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;\n    if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){\n      testcase( mask==0 );\n      iBest = i;\n    }\n  }\n  sqlite3_result_value(context, argv[iBest]);\n}\n\n/*\n** Return the type of the argument.\n*/\nstatic void typeofFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  static const char *azType[] = { \"integer\", \"real\", \"text\", \"blob\", \"null\" };\n  int i = sqlite3_value_type(argv[0]) - 1;\n  UNUSED_PARAMETER(NotUsed);\n  assert( i>=0 && i<ArraySize(azType) );\n  assert( SQLITE_INTEGER==1 );\n  assert( SQLITE_FLOAT==2 );\n  assert( SQLITE_TEXT==3 );\n  assert( SQLITE_BLOB==4 );\n  assert( SQLITE_NULL==5 );\n  /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns\n  ** the datatype code for the initial datatype of the sqlite3_value object\n  ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,\n  ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */\n  sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);\n}\n\n\n/*\n** Implementation of the length() function\n*/\nstatic void lengthFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int len;\n\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_BLOB:\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_value_text(argv[0]);\n      if( z==0 ) return;\n      len = 0;\n      while( *z ){\n        len++;\n        SQLITE_SKIP_UTF8(z);\n      }\n      sqlite3_result_int(context, len);\n      break;\n    }\n    default: {\n      sqlite3_result_null(context);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the abs() function.\n**\n** IMP: R-23979-26855 The abs(X) function returns the absolute value of\n** the numeric argument X. \n*/\nstatic void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_INTEGER: {\n      i64 iVal = sqlite3_value_int64(argv[0]);\n      if( iVal<0 ){\n        if( iVal==SMALLEST_INT64 ){\n          /* IMP: R-31676-45509 If X is the integer -9223372036854775808\n          ** then abs(X) throws an integer overflow error since there is no\n          ** equivalent positive 64-bit two complement value. */\n          sqlite3_result_error(context, \"integer overflow\", -1);\n          return;\n        }\n        iVal = -iVal;\n      } \n      sqlite3_result_int64(context, iVal);\n      break;\n    }\n    case SQLITE_NULL: {\n      /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */\n      sqlite3_result_null(context);\n      break;\n    }\n    default: {\n      /* Because sqlite3_value_double() returns 0.0 if the argument is not\n      ** something that can be converted into a number, we have:\n      ** IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob\n      ** that cannot be converted to a numeric value.\n      */\n      double rVal = sqlite3_value_double(argv[0]);\n      if( rVal<0 ) rVal = -rVal;\n      sqlite3_result_double(context, rVal);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the instr() function.\n**\n** instr(haystack,needle) finds the first occurrence of needle\n** in haystack and returns the number of previous characters plus 1,\n** or 0 if needle does not occur within haystack.\n**\n** If both haystack and needle are BLOBs, then the result is one more than\n** the number of bytes in haystack prior to the first occurrence of needle,\n** or 0 if needle never occurs in haystack.\n*/\nstatic void instrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zHaystack;\n  const unsigned char *zNeedle;\n  int nHaystack;\n  int nNeedle;\n  int typeHaystack, typeNeedle;\n  int N = 1;\n  int isText;\n\n  UNUSED_PARAMETER(argc);\n  typeHaystack = sqlite3_value_type(argv[0]);\n  typeNeedle = sqlite3_value_type(argv[1]);\n  if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;\n  nHaystack = sqlite3_value_bytes(argv[0]);\n  nNeedle = sqlite3_value_bytes(argv[1]);\n  if( nNeedle>0 ){\n    if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){\n      zHaystack = sqlite3_value_blob(argv[0]);\n      zNeedle = sqlite3_value_blob(argv[1]);\n      isText = 0;\n    }else{\n      zHaystack = sqlite3_value_text(argv[0]);\n      zNeedle = sqlite3_value_text(argv[1]);\n      isText = 1;\n    }\n    if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;\n    while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){\n      N++;\n      do{\n        nHaystack--;\n        zHaystack++;\n      }while( isText && (zHaystack[0]&0xc0)==0x80 );\n    }\n    if( nNeedle>nHaystack ) N = 0;\n  }\n  sqlite3_result_int(context, N);\n}\n\n/*\n** Implementation of the printf() function.\n*/\nstatic void printfFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  PrintfArguments x;\n  StrAccum str;\n  const char *zFormat;\n  int n;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    x.nArg = argc-1;\n    x.nUsed = 0;\n    x.apArg = argv+1;\n    sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);\n    str.printfFlags = SQLITE_PRINTF_SQLFUNC;\n    sqlite3XPrintf(&str, zFormat, &x);\n    n = str.nChar;\n    sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,\n                        SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Implementation of the substr() function.\n**\n** substr(x,p1,p2)  returns p2 characters of x[] beginning with p1.\n** p1 is 1-indexed.  So substr(x,1,1) returns the first character\n** of x.  If x is text, then we actually count UTF-8 characters.\n** If x is a blob, then we count bytes.\n**\n** If p1 is negative, then we begin abs(p1) from the end of x[].\n**\n** If p2 is negative, return the p2 characters preceding p1.\n*/\nstatic void substrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z;\n  const unsigned char *z2;\n  int len;\n  int p0type;\n  i64 p1, p2;\n  int negP2 = 0;\n\n  assert( argc==3 || argc==2 );\n  if( sqlite3_value_type(argv[1])==SQLITE_NULL\n   || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)\n  ){\n    return;\n  }\n  p0type = sqlite3_value_type(argv[0]);\n  p1 = sqlite3_value_int(argv[1]);\n  if( p0type==SQLITE_BLOB ){\n    len = sqlite3_value_bytes(argv[0]);\n    z = sqlite3_value_blob(argv[0]);\n    if( z==0 ) return;\n    assert( len==sqlite3_value_bytes(argv[0]) );\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( z==0 ) return;\n    len = 0;\n    if( p1<0 ){\n      for(z2=z; *z2; len++){\n        SQLITE_SKIP_UTF8(z2);\n      }\n    }\n  }\n#ifdef SQLITE_SUBSTR_COMPATIBILITY\n  /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as\n  ** as substr(X,1,N) - it returns the first N characters of X.  This\n  ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]\n  ** from 2009-02-02 for compatibility of applications that exploited the\n  ** old buggy behavior. */\n  if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */\n#endif\n  if( argc==3 ){\n    p2 = sqlite3_value_int(argv[2]);\n    if( p2<0 ){\n      p2 = -p2;\n      negP2 = 1;\n    }\n  }else{\n    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  if( p1<0 ){\n    p1 += len;\n    if( p1<0 ){\n      p2 += p1;\n      if( p2<0 ) p2 = 0;\n      p1 = 0;\n    }\n  }else if( p1>0 ){\n    p1--;\n  }else if( p2>0 ){\n    p2--;\n  }\n  if( negP2 ){\n    p1 -= p2;\n    if( p1<0 ){\n      p2 += p1;\n      p1 = 0;\n    }\n  }\n  assert( p1>=0 && p2>=0 );\n  if( p0type!=SQLITE_BLOB ){\n    while( *z && p1 ){\n      SQLITE_SKIP_UTF8(z);\n      p1--;\n    }\n    for(z2=z; *z2 && p2; p2--){\n      SQLITE_SKIP_UTF8(z2);\n    }\n    sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,\n                          SQLITE_UTF8);\n  }else{\n    if( p1+p2>len ){\n      p2 = len-p1;\n      if( p2<0 ) p2 = 0;\n    }\n    sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n** Implementation of the round() function\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\nstatic void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  int n = 0;\n  double r;\n  char *zBuf;\n  assert( argc==1 || argc==2 );\n  if( argc==2 ){\n    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;\n    n = sqlite3_value_int(argv[1]);\n    if( n>30 ) n = 30;\n    if( n<0 ) n = 0;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  r = sqlite3_value_double(argv[0]);\n  /* If Y==0 and X will fit in a 64-bit int,\n  ** handle the rounding directly,\n  ** otherwise use printf.\n  */\n  if( n==0 && r>=0 && r<LARGEST_INT64-1 ){\n    r = (double)((sqlite_int64)(r+0.5));\n  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){\n    r = -(double)((sqlite_int64)((-r)+0.5));\n  }else{\n    zBuf = sqlite3_mprintf(\"%.*f\",n,r);\n    if( zBuf==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);\n    sqlite3_free(zBuf);\n  }\n  sqlite3_result_double(context, r);\n}\n#endif\n\n/*\n** Allocate nByte bytes of space using sqlite3Malloc(). If the\n** allocation fails, call sqlite3_result_error_nomem() to notify\n** the database handle that malloc() has failed and return NULL.\n** If nByte is larger than the maximum string or blob length, then\n** raise an SQLITE_TOOBIG exception and return NULL.\n*/\nstatic void *contextMalloc(sqlite3_context *context, i64 nByte){\n  char *z;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  assert( nByte>0 );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    z = 0;\n  }else{\n    z = sqlite3Malloc(nByte);\n    if( !z ){\n      sqlite3_result_error_nomem(context);\n    }\n  }\n  return z;\n}\n\n/*\n** Implementation of the upper() and lower() SQL functions.\n*/\nstatic void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = (char)sqlite3Toupper(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\nstatic void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = sqlite3Tolower(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\n\n/*\n** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented\n** as VDBE code so that unused argument values do not have to be computed.\n** However, we still need some kind of function implementation for this\n** routines in the function table.  The noopFunc macro provides this.\n** noopFunc will never be called so it doesn't matter what the implementation\n** is.  We might as well use the \"version()\" function as a substitute.\n*/\n#define noopFunc versionFunc   /* Substitute function - never called */\n\n/*\n** Implementation of random().  Return a random integer.  \n*/\nstatic void randomFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite_int64 r;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_randomness(sizeof(r), &r);\n  if( r<0 ){\n    /* We need to prevent a random number of 0x8000000000000000 \n    ** (or -9223372036854775808) since when you do abs() of that\n    ** number of you get the same value back again.  To do this\n    ** in a way that is testable, mask the sign bit off of negative\n    ** values, resulting in a positive value.  Then take the \n    ** 2s complement of that positive value.  The end result can\n    ** therefore be no less than -9223372036854775807.\n    */\n    r = -(r & LARGEST_INT64);\n  }\n  sqlite3_result_int64(context, r);\n}\n\n/*\n** Implementation of randomblob(N).  Return a random blob\n** that is N bytes long.\n*/\nstatic void randomBlob(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  unsigned char *p;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int(argv[0]);\n  if( n<1 ){\n    n = 1;\n  }\n  p = contextMalloc(context, n);\n  if( p ){\n    sqlite3_randomness(n, p);\n    sqlite3_result_blob(context, (char*)p, n, sqlite3_free);\n  }\n}\n\n/*\n** Implementation of the last_insert_rowid() SQL function.  The return\n** value is the same as the sqlite3_last_insert_rowid() API function.\n*/\nstatic void last_insert_rowid(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a\n  ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface\n  ** function. */\n  sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));\n}\n\n/*\n** Implementation of the changes() SQL function.\n**\n** IMP: R-62073-11209 The changes() SQL function is a wrapper\n** around the sqlite3_changes() C/C++ function and hence follows the same\n** rules for counting changes.\n*/\nstatic void changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_result_int(context, sqlite3_changes(db));\n}\n\n/*\n** Implementation of the total_changes() SQL function.  The return value is\n** the same as the sqlite3_total_changes() API function.\n*/\nstatic void total_changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-52756-41993 This function is a wrapper around the\n  ** sqlite3_total_changes() C/C++ interface. */\n  sqlite3_result_int(context, sqlite3_total_changes(db));\n}\n\n/*\n** A structure defining how to do GLOB-style comparisons.\n*/\nstruct compareInfo {\n  u8 matchAll;          /* \"*\" or \"%\" */\n  u8 matchOne;          /* \"?\" or \"_\" */\n  u8 matchSet;          /* \"[\" or 0 */\n  u8 noCase;            /* true to ignore case differences */\n};\n\n/*\n** For LIKE and GLOB matching on EBCDIC machines, assume that every\n** character is exactly one byte in size.  Also, provde the Utf8Read()\n** macro for fast reading of the next character in the common case where\n** the next character is ASCII.\n*/\n#if defined(SQLITE_EBCDIC)\n# define sqlite3Utf8Read(A)        (*((*A)++))\n# define Utf8Read(A)               (*(A++))\n#else\n# define Utf8Read(A)               (A[0]<0x80?*(A++):sqlite3Utf8Read(&A))\n#endif\n\nstatic const struct compareInfo globInfo = { '*', '?', '[', 0 };\n/* The correct SQL-92 behavior is for the LIKE operator to ignore\n** case.  Thus  'a' LIKE 'A' would be true. */\nstatic const struct compareInfo likeInfoNorm = { '%', '_',   0, 1 };\n/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator\n** is case sensitive causing 'a' LIKE 'A' to be false */\nstatic const struct compareInfo likeInfoAlt = { '%', '_',   0, 0 };\n\n/*\n** Possible error returns from patternMatch()\n*/\n#define SQLITE_MATCH             0\n#define SQLITE_NOMATCH           1\n#define SQLITE_NOWILDCARDMATCH   2\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a GLOB or LIKE expression.  Return values:\n**\n**    SQLITE_MATCH:            Match\n**    SQLITE_NOMATCH:          No match\n**    SQLITE_NOWILDCARDMATCH:  No match in spite of having * or % wildcards.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n** With the [...] and [^...] matching, a ']' character can be included\n** in the list by making it the first character after '[' or '^'.  A\n** range of characters can be specified using '-'.  Example:\n** \"[a-z]\" matches any single lower-case letter.  To match a '-', make\n** it the last character in the list.\n**\n** Like matching rules:\n** \n**      '%'       Matches any sequence of zero or more characters\n**\n***     '_'       Matches any one character\n**\n**      Ec        Where E is the \"esc\" character and c is any other\n**                character, including '%', '_', and esc, match exactly c.\n**\n** The comments within this routine usually assume glob matching.\n**\n** This routine is usually quick, but can be N**2 in the worst case.\n*/\nstatic int patternCompare(\n  const u8 *zPattern,              /* The glob pattern */\n  const u8 *zString,               /* The string to compare against the glob */\n  const struct compareInfo *pInfo, /* Information about how to do the compare */\n  u32 matchOther                   /* The escape char (LIKE) or '[' (GLOB) */\n){\n  u32 c, c2;                       /* Next pattern and input string chars */\n  u32 matchOne = pInfo->matchOne;  /* \"?\" or \"_\" */\n  u32 matchAll = pInfo->matchAll;  /* \"*\" or \"%\" */\n  u8 noCase = pInfo->noCase;       /* True if uppercase==lowercase */\n  const u8 *zEscaped = 0;          /* One past the last escaped input char */\n  \n  while( (c = Utf8Read(zPattern))!=0 ){\n    if( c==matchAll ){  /* Match \"*\" */\n      /* Skip over multiple \"*\" characters in the pattern.  If there\n      ** are also \"?\" characters, skip those as well, but consume a\n      ** single character of the input string for each \"?\" skipped */\n      while( (c=Utf8Read(zPattern)) == matchAll || c == matchOne ){\n        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n      if( c==0 ){\n        return SQLITE_MATCH;   /* \"*\" at the end of the pattern matches */\n      }else if( c==matchOther ){\n        if( pInfo->matchSet==0 ){\n          c = sqlite3Utf8Read(&zPattern);\n          if( c==0 ) return SQLITE_NOWILDCARDMATCH;\n        }else{\n          /* \"[...]\" immediately follows the \"*\".  We have to do a slow\n          ** recursive search in this case, but it is an unusual case. */\n          assert( matchOther<0x80 );  /* '[' is a single-byte character */\n          while( *zString ){\n            int bMatch = patternCompare(&zPattern[-1],zString,pInfo,matchOther);\n            if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n            SQLITE_SKIP_UTF8(zString);\n          }\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n\n      /* At this point variable c contains the first character of the\n      ** pattern string past the \"*\".  Search in the input string for the\n      ** first matching character and recursively continue the match from\n      ** that point.\n      **\n      ** For a case-insensitive search, set variable cx to be the same as\n      ** c but in the other case and search the input string for either\n      ** c or cx.\n      */\n      if( c<=0x80 ){\n        u32 cx;\n        int bMatch;\n        if( noCase ){\n          cx = sqlite3Toupper(c);\n          c = sqlite3Tolower(c);\n        }else{\n          cx = c;\n        }\n        while( (c2 = *(zString++))!=0 ){\n          if( c2!=c && c2!=cx ) continue;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }else{\n        int bMatch;\n        while( (c2 = Utf8Read(zString))!=0 ){\n          if( c2!=c ) continue;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }\n      return SQLITE_NOWILDCARDMATCH;\n    }\n    if( c==matchOther ){\n      if( pInfo->matchSet==0 ){\n        c = sqlite3Utf8Read(&zPattern);\n        if( c==0 ) return SQLITE_NOMATCH;\n        zEscaped = zPattern;\n      }else{\n        u32 prior_c = 0;\n        int seen = 0;\n        int invert = 0;\n        c = sqlite3Utf8Read(&zString);\n        if( c==0 ) return SQLITE_NOMATCH;\n        c2 = sqlite3Utf8Read(&zPattern);\n        if( c2=='^' ){\n          invert = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==']' ){\n          if( c==']' ) seen = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        while( c2 && c2!=']' ){\n          if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){\n            c2 = sqlite3Utf8Read(&zPattern);\n            if( c>=prior_c && c<=c2 ) seen = 1;\n            prior_c = 0;\n          }else{\n            if( c==c2 ){\n              seen = 1;\n            }\n            prior_c = c2;\n          }\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==0 || (seen ^ invert)==0 ){\n          return SQLITE_NOMATCH;\n        }\n        continue;\n      }\n    }\n    c2 = Utf8Read(zString);\n    if( c==c2 ) continue;\n    if( noCase  && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){\n      continue;\n    }\n    if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;\n    return SQLITE_NOMATCH;\n  }\n  return *zString==0 ? SQLITE_MATCH : SQLITE_NOMATCH;\n}\n\n/*\n** The sqlite3_strglob() interface.  Return 0 on a match (like strcmp()) and\n** non-zero if there is no match.\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){\n  return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');\n}\n\n/*\n** The sqlite3_strlike() interface.  Return 0 on a match and non-zero for\n** a miss - like strcmp().\n*/\nSQLITE_API int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){\n  return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);\n}\n\n/*\n** Count the number of times that the LIKE operator (or GLOB which is\n** just a variation of LIKE) gets called.  This is used for testing\n** only.\n*/\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_like_count = 0;\n#endif\n\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B,A).\n**\n** This same function (with a different compareInfo structure) computes\n** the GLOB operator.\n*/\nstatic void likeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA, *zB;\n  u32 escape;\n  int nPat;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  struct compareInfo *pInfo = sqlite3_user_data(context);\n\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( sqlite3_value_type(argv[0])==SQLITE_BLOB\n   || sqlite3_value_type(argv[1])==SQLITE_BLOB\n  ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context, 0);\n    return;\n  }\n#endif\n  zB = sqlite3_value_text(argv[0]);\n  zA = sqlite3_value_text(argv[1]);\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  nPat = sqlite3_value_bytes(argv[0]);\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );\n  if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n  assert( zB==sqlite3_value_text(argv[0]) );  /* Encoding did not change */\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    const unsigned char *zEsc = sqlite3_value_text(argv[2]);\n    if( zEsc==0 ) return;\n    if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n    escape = sqlite3Utf8Read(&zEsc);\n  }else{\n    escape = pInfo->matchSet;\n  }\n  if( zA && zB ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context,\n                      patternCompare(zB, zA, pInfo, escape)==SQLITE_MATCH);\n  }\n}\n\n/*\n** Implementation of the NULLIF(x,y) function.  The result is the first\n** argument if the arguments are different.  The result is NULL if the\n** arguments are equal to each other.\n*/\nstatic void nullifFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n  UNUSED_PARAMETER(NotUsed);\n  if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){\n    sqlite3_result_value(context, argv[0]);\n  }\n}\n\n/*\n** Implementation of the sqlite_version() function.  The result is the version\n** of the SQLite library that is running.\n*/\nstatic void versionFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-48699-48617 This function is an SQL wrapper around the\n  ** sqlite3_libversion() C-interface. */\n  sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_source_id() function. The result is a string\n** that identifies the particular version of the source code used to build\n** SQLite.\n*/\nstatic void sourceidFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-24470-31136 This function is an SQL wrapper around the\n  ** sqlite3_sourceid() C interface. */\n  sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_log() function.  This is a wrapper around\n** sqlite3_log().  The return value is NULL.  The function exists purely for\n** its side-effects.\n*/\nstatic void errlogFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(context);\n  sqlite3_log(sqlite3_value_int(argv[0]), \"%s\", sqlite3_value_text(argv[1]));\n}\n\n/*\n** Implementation of the sqlite_compileoption_used() function.\n** The result is an integer that identifies if the compiler option\n** was used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptionusedFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zOptName;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL\n  ** function is a wrapper around the sqlite3_compileoption_used() C/C++\n  ** function.\n  */\n  if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    sqlite3_result_int(context, sqlite3_compileoption_used(zOptName));\n  }\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/*\n** Implementation of the sqlite_compileoption_get() function. \n** The result is a string that identifies the compiler options \n** used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptiongetFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function\n  ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.\n  */\n  n = sqlite3_value_int(argv[0]);\n  sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC);\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/* Array for converting from half-bytes (nybbles) into ASCII hex\n** digits. */\nstatic const char hexdigits[] = {\n  '0', '1', '2', '3', '4', '5', '6', '7',\n  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' \n};\n\n/*\n** Implementation of the QUOTE() function.  This function takes a single\n** argument.  If the argument is numeric, the return value is the same as\n** the argument.  If the argument is NULL, the return value is the string\n** \"NULL\".  Otherwise, the argument is enclosed in single quotes with\n** single-quote escapes.\n*/\nstatic void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      double r1, r2;\n      char zBuf[50];\n      r1 = sqlite3_value_double(argv[0]);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.15g\", r1);\n      sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);\n      if( r1!=r2 ){\n        sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.20e\", r1);\n      }\n      sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_result_value(context, argv[0]);\n      break;\n    }\n    case SQLITE_BLOB: {\n      char *zText = 0;\n      char const *zBlob = sqlite3_value_blob(argv[0]);\n      int nBlob = sqlite3_value_bytes(argv[0]);\n      assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */\n      zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4); \n      if( zText ){\n        int i;\n        for(i=0; i<nBlob; i++){\n          zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];\n          zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F];\n        }\n        zText[(nBlob*2)+2] = '\\'';\n        zText[(nBlob*2)+3] = '\\0';\n        zText[0] = 'X';\n        zText[1] = '\\'';\n        sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);\n        sqlite3_free(zText);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      int i,j;\n      u64 n;\n      const unsigned char *zArg = sqlite3_value_text(argv[0]);\n      char *z;\n\n      if( zArg==0 ) return;\n      for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\\'' ) n++; }\n      z = contextMalloc(context, ((i64)i)+((i64)n)+3);\n      if( z ){\n        z[0] = '\\'';\n        for(i=0, j=1; zArg[i]; i++){\n          z[j++] = zArg[i];\n          if( zArg[i]=='\\'' ){\n            z[j++] = '\\'';\n          }\n        }\n        z[j++] = '\\'';\n        z[j] = 0;\n        sqlite3_result_text(context, z, j, sqlite3_free);\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      sqlite3_result_text(context, \"NULL\", 4, SQLITE_STATIC);\n      break;\n    }\n  }\n}\n\n/*\n** The unicode() function.  Return the integer unicode code-point value\n** for the first character of the input string. \n*/\nstatic void unicodeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z = sqlite3_value_text(argv[0]);\n  (void)argc;\n  if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z));\n}\n\n/*\n** The char() function takes zero or more arguments, each of which is\n** an integer.  It constructs a string where each character of the string\n** is the unicode character for the corresponding integer argument.\n*/\nstatic void charFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  unsigned char *z, *zOut;\n  int i;\n  zOut = z = sqlite3_malloc64( argc*4+1 );\n  if( z==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  for(i=0; i<argc; i++){\n    sqlite3_int64 x;\n    unsigned c;\n    x = sqlite3_value_int64(argv[i]);\n    if( x<0 || x>0x10ffff ) x = 0xfffd;\n    c = (unsigned)(x & 0x1fffff);\n    if( c<0x00080 ){\n      *zOut++ = (u8)(c&0xFF);\n    }else if( c<0x00800 ){\n      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else if( c<0x10000 ){\n      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else{\n      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);\n      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }                                                    \\\n  }\n  sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8);\n}\n\n/*\n** The hex() function.  Interpret the argument as a blob.  Return\n** a hexadecimal rendering as text.\n*/\nstatic void hexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i, n;\n  const unsigned char *pBlob;\n  char *zHex, *z;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  pBlob = sqlite3_value_blob(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  assert( pBlob==sqlite3_value_blob(argv[0]) );  /* No encoding change */\n  z = zHex = contextMalloc(context, ((i64)n)*2 + 1);\n  if( zHex ){\n    for(i=0; i<n; i++, pBlob++){\n      unsigned char c = *pBlob;\n      *(z++) = hexdigits[(c>>4)&0xf];\n      *(z++) = hexdigits[c&0xf];\n    }\n    *z = 0;\n    sqlite3_result_text(context, zHex, n*2, sqlite3_free);\n  }\n}\n\n/*\n** The zeroblob(N) function returns a zero-filled blob of size N bytes.\n*/\nstatic void zeroblobFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  i64 n;\n  int rc;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int64(argv[0]);\n  if( n<0 ) n = 0;\n  rc = sqlite3_result_zeroblob64(context, n); /* IMP: R-00293-64994 */\n  if( rc ){\n    sqlite3_result_error_code(context, rc);\n  }\n}\n\n/*\n** The replace() function.  Three arguments are all strings: call\n** them A, B, and C. The result is also a string which is derived\n** from A by replacing every occurrence of B with C.  The match\n** must be exact.  Collating sequences are not used.\n*/\nstatic void replaceFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zStr;        /* The input string A */\n  const unsigned char *zPattern;    /* The pattern string B */\n  const unsigned char *zRep;        /* The replacement string C */\n  unsigned char *zOut;              /* The output */\n  int nStr;                /* Size of zStr */\n  int nPattern;            /* Size of zPattern */\n  int nRep;                /* Size of zRep */\n  i64 nOut;                /* Maximum size of zOut */\n  int loopLimit;           /* Last zStr[] that might match zPattern[] */\n  int i, j;                /* Loop counters */\n\n  assert( argc==3 );\n  UNUSED_PARAMETER(argc);\n  zStr = sqlite3_value_text(argv[0]);\n  if( zStr==0 ) return;\n  nStr = sqlite3_value_bytes(argv[0]);\n  assert( zStr==sqlite3_value_text(argv[0]) );  /* No encoding change */\n  zPattern = sqlite3_value_text(argv[1]);\n  if( zPattern==0 ){\n    assert( sqlite3_value_type(argv[1])==SQLITE_NULL\n            || sqlite3_context_db_handle(context)->mallocFailed );\n    return;\n  }\n  if( zPattern[0]==0 ){\n    assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );\n    sqlite3_result_value(context, argv[0]);\n    return;\n  }\n  nPattern = sqlite3_value_bytes(argv[1]);\n  assert( zPattern==sqlite3_value_text(argv[1]) );  /* No encoding change */\n  zRep = sqlite3_value_text(argv[2]);\n  if( zRep==0 ) return;\n  nRep = sqlite3_value_bytes(argv[2]);\n  assert( zRep==sqlite3_value_text(argv[2]) );\n  nOut = nStr + 1;\n  assert( nOut<SQLITE_MAX_LENGTH );\n  zOut = contextMalloc(context, (i64)nOut);\n  if( zOut==0 ){\n    return;\n  }\n  loopLimit = nStr - nPattern;  \n  for(i=j=0; i<=loopLimit; i++){\n    if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){\n      zOut[j++] = zStr[i];\n    }else{\n      u8 *zOld;\n      sqlite3 *db = sqlite3_context_db_handle(context);\n      nOut += nRep - nPattern;\n      testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        sqlite3_result_error_toobig(context);\n        sqlite3_free(zOut);\n        return;\n      }\n      zOld = zOut;\n      zOut = sqlite3_realloc64(zOut, (int)nOut);\n      if( zOut==0 ){\n        sqlite3_result_error_nomem(context);\n        sqlite3_free(zOld);\n        return;\n      }\n      memcpy(&zOut[j], zRep, nRep);\n      j += nRep;\n      i += nPattern-1;\n    }\n  }\n  assert( j+nStr-i+1==nOut );\n  memcpy(&zOut[j], &zStr[i], nStr-i);\n  j += nStr - i;\n  assert( j<=nOut );\n  zOut[j] = 0;\n  sqlite3_result_text(context, (char*)zOut, j, sqlite3_free);\n}\n\n/*\n** Implementation of the TRIM(), LTRIM(), and RTRIM() functions.\n** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both.\n*/\nstatic void trimFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;         /* Input string */\n  const unsigned char *zCharSet;    /* Set of characters to trim */\n  int nIn;                          /* Number of bytes in input */\n  int flags;                        /* 1: trimleft  2: trimright  3: trim */\n  int i;                            /* Loop counter */\n  unsigned char *aLen = 0;          /* Length of each character in zCharSet */\n  unsigned char **azChar = 0;       /* Individual characters in zCharSet */\n  int nChar;                        /* Number of characters in zCharSet */\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    return;\n  }\n  zIn = sqlite3_value_text(argv[0]);\n  if( zIn==0 ) return;\n  nIn = sqlite3_value_bytes(argv[0]);\n  assert( zIn==sqlite3_value_text(argv[0]) );\n  if( argc==1 ){\n    static const unsigned char lenOne[] = { 1 };\n    static unsigned char * const azOne[] = { (u8*)\" \" };\n    nChar = 1;\n    aLen = (u8*)lenOne;\n    azChar = (unsigned char **)azOne;\n    zCharSet = 0;\n  }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){\n    return;\n  }else{\n    const unsigned char *z;\n    for(z=zCharSet, nChar=0; *z; nChar++){\n      SQLITE_SKIP_UTF8(z);\n    }\n    if( nChar>0 ){\n      azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));\n      if( azChar==0 ){\n        return;\n      }\n      aLen = (unsigned char*)&azChar[nChar];\n      for(z=zCharSet, nChar=0; *z; nChar++){\n        azChar[nChar] = (unsigned char *)z;\n        SQLITE_SKIP_UTF8(z);\n        aLen[nChar] = (u8)(z - azChar[nChar]);\n      }\n    }\n  }\n  if( nChar>0 ){\n    flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));\n    if( flags & 1 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        zIn += len;\n        nIn -= len;\n      }\n    }\n    if( flags & 2 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        nIn -= len;\n      }\n    }\n    if( zCharSet ){\n      sqlite3_free(azChar);\n    }\n  }\n  sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);\n}\n\n\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n/*\n** The \"unknown\" function is automatically substituted in place of\n** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN\n** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.\n** When the \"sqlite3\" command-line shell is built using this functionality,\n** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries\n** involving application-defined functions to be examined in a generic\n** sqlite3 shell.\n*/\nstatic void unknownFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  /* no-op */\n}\n#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/\n\n\n/* IMP: R-25361-16150 This function is omitted from SQLite by default. It\n** is only available if the SQLITE_SOUNDEX compile-time option is used\n** when SQLite is built.\n*/\n#ifdef SQLITE_SOUNDEX\n/*\n** Compute the soundex encoding of a word.\n**\n** IMP: R-59782-00072 The soundex(X) function returns a string that is the\n** soundex encoding of the string X. \n*/\nstatic void soundexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  char zResult[8];\n  const u8 *zIn;\n  int i, j;\n  static const unsigned char iCode[] = {\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n  };\n  assert( argc==1 );\n  zIn = (u8*)sqlite3_value_text(argv[0]);\n  if( zIn==0 ) zIn = (u8*)\"\";\n  for(i=0; zIn[i] && !sqlite3Isalpha(zIn[i]); i++){}\n  if( zIn[i] ){\n    u8 prevcode = iCode[zIn[i]&0x7f];\n    zResult[0] = sqlite3Toupper(zIn[i]);\n    for(j=1; j<4 && zIn[i]; i++){\n      int code = iCode[zIn[i]&0x7f];\n      if( code>0 ){\n        if( code!=prevcode ){\n          prevcode = code;\n          zResult[j++] = code + '0';\n        }\n      }else{\n        prevcode = 0;\n      }\n    }\n    while( j<4 ){\n      zResult[j++] = '0';\n    }\n    zResult[j] = 0;\n    sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);\n  }else{\n    /* IMP: R-64894-50321 The string \"?000\" is returned if the argument\n    ** is NULL or contains no ASCII alphabetic characters. */\n    sqlite3_result_text(context, \"?000\", 4, SQLITE_STATIC);\n  }\n}\n#endif /* SQLITE_SOUNDEX */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** A function that loads a shared-library extension then returns NULL.\n*/\nstatic void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){\n  const char *zFile = (const char *)sqlite3_value_text(argv[0]);\n  const char *zProc;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zErrMsg = 0;\n\n  /* Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc\n  ** flag is set.  See the sqlite3_enable_load_extension() API.\n  */\n  if( (db->flags & SQLITE_LoadExtFunc)==0 ){\n    sqlite3_result_error(context, \"not authorized\", -1);\n    return;\n  }\n\n  if( argc==2 ){\n    zProc = (const char *)sqlite3_value_text(argv[1]);\n  }else{\n    zProc = 0;\n  }\n  if( zFile && sqlite3_load_extension(db, zFile, zProc, &zErrMsg) ){\n    sqlite3_result_error(context, zErrMsg, -1);\n    sqlite3_free(zErrMsg);\n  }\n}\n#endif\n\n\n/*\n** An instance of the following structure holds the context of a\n** sum() or avg() aggregate computation.\n*/\ntypedef struct SumCtx SumCtx;\nstruct SumCtx {\n  double rSum;      /* Floating point sum */\n  i64 iSum;         /* Integer sum */   \n  i64 cnt;          /* Number of elements summed */\n  u8 overflow;      /* True if integer overflow seen */\n  u8 approx;        /* True if non-integer value was input to the sum */\n};\n\n/*\n** Routines used to compute the sum, average, and total.\n**\n** The SUM() function follows the (broken) SQL standard which means\n** that it returns NULL if it sums over no inputs.  TOTAL returns\n** 0.0 in that case.  In addition, TOTAL always returns a float where\n** SUM might return an integer if it never encounters a floating point\n** value.  TOTAL never fails, but SUM might through an exception if\n** it overflows an integer.\n*/\nstatic void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  SumCtx *p;\n  int type;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  type = sqlite3_value_numeric_type(argv[0]);\n  if( p && type!=SQLITE_NULL ){\n    p->cnt++;\n    if( type==SQLITE_INTEGER ){\n      i64 v = sqlite3_value_int64(argv[0]);\n      p->rSum += v;\n      if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){\n        p->overflow = 1;\n      }\n    }else{\n      p->rSum += sqlite3_value_double(argv[0]);\n      p->approx = 1;\n    }\n  }\n}\nstatic void sumFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    if( p->overflow ){\n      sqlite3_result_error(context,\"integer overflow\",-1);\n    }else if( p->approx ){\n      sqlite3_result_double(context, p->rSum);\n    }else{\n      sqlite3_result_int64(context, p->iSum);\n    }\n  }\n}\nstatic void avgFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    sqlite3_result_double(context, p->rSum/(double)p->cnt);\n  }\n}\nstatic void totalFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  sqlite3_result_double(context, p ? p->rSum : (double)0);\n}\n\n/*\n** The following structure keeps track of state information for the\n** count() aggregate function.\n*/\ntypedef struct CountCtx CountCtx;\nstruct CountCtx {\n  i64 n;\n};\n\n/*\n** Routines to implement the count() aggregate function.\n*/\nstatic void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){\n    p->n++;\n  }\n\n#ifndef SQLITE_OMIT_DEPRECATED\n  /* The sqlite3_aggregate_count() function is deprecated.  But just to make\n  ** sure it still operates correctly, verify that its count agrees with our \n  ** internal count when using count(*) and when the total count can be\n  ** expressed as a 32-bit integer. */\n  assert( argc==1 || p==0 || p->n>0x7fffffff\n          || p->n==sqlite3_aggregate_count(context) );\n#endif\n}   \nstatic void countFinalize(sqlite3_context *context){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  sqlite3_result_int64(context, p ? p->n : 0);\n}\n\n/*\n** Routines to implement min() and max() aggregate functions.\n*/\nstatic void minmaxStep(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **argv\n){\n  Mem *pArg  = (Mem *)argv[0];\n  Mem *pBest;\n  UNUSED_PARAMETER(NotUsed);\n\n  pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));\n  if( !pBest ) return;\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);\n  }else if( pBest->flags ){\n    int max;\n    int cmp;\n    CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n    /* This step function is used for both the min() and max() aggregates,\n    ** the only difference between the two being that the sense of the\n    ** comparison is inverted. For the max() aggregate, the\n    ** sqlite3_user_data() function returns (void *)-1. For min() it\n    ** returns (void *)db, where db is the sqlite3* database pointer.\n    ** Therefore the next statement sets variable 'max' to 1 for the max()\n    ** aggregate, or 0 for min().\n    */\n    max = sqlite3_user_data(context)!=0;\n    cmp = sqlite3MemCompare(pBest, pArg, pColl);\n    if( (max && cmp<0) || (!max && cmp>0) ){\n      sqlite3VdbeMemCopy(pBest, pArg);\n    }else{\n      sqlite3SkipAccumulatorLoad(context);\n    }\n  }else{\n    pBest->db = sqlite3_context_db_handle(context);\n    sqlite3VdbeMemCopy(pBest, pArg);\n  }\n}\nstatic void minMaxFinalize(sqlite3_context *context){\n  sqlite3_value *pRes;\n  pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);\n  if( pRes ){\n    if( pRes->flags ){\n      sqlite3_result_value(context, pRes);\n    }\n    sqlite3VdbeMemRelease(pRes);\n  }\n}\n\n/*\n** group_concat(EXPR, ?SEPARATOR?)\n*/\nstatic void groupConcatStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zVal;\n  StrAccum *pAccum;\n  const char *zSep;\n  int nVal, nSep;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));\n\n  if( pAccum ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    int firstTerm = pAccum->mxAlloc==0;\n    pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];\n    if( !firstTerm ){\n      if( argc==2 ){\n        zSep = (char*)sqlite3_value_text(argv[1]);\n        nSep = sqlite3_value_bytes(argv[1]);\n      }else{\n        zSep = \",\";\n        nSep = 1;\n      }\n      if( zSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep);\n    }\n    zVal = (char*)sqlite3_value_text(argv[0]);\n    nVal = sqlite3_value_bytes(argv[0]);\n    if( zVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal);\n  }\n}\nstatic void groupConcatFinalize(sqlite3_context *context){\n  StrAccum *pAccum;\n  pAccum = sqlite3_aggregate_context(context, 0);\n  if( pAccum ){\n    if( pAccum->accError==STRACCUM_TOOBIG ){\n      sqlite3_result_error_toobig(context);\n    }else if( pAccum->accError==STRACCUM_NOMEM ){\n      sqlite3_result_error_nomem(context);\n    }else{    \n      sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, \n                          sqlite3_free);\n    }\n  }\n}\n\n/*\n** This routine does per-connection function registration.  Most\n** of the built-in functions above are part of the global function set.\n** This routine only deals with those that are not global.\n*/\nSQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){\n  int rc = sqlite3_overload_function(db, \"MATCH\", 2);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n}\n\n/*\n** Set the LIKEOPT flag on the 2-argument function with the given name.\n*/\nstatic void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){\n  FuncDef *pDef;\n  pDef = sqlite3FindFunction(db, zName, 2, SQLITE_UTF8, 0);\n  if( ALWAYS(pDef) ){\n    pDef->funcFlags |= flagVal;\n  }\n}\n\n/*\n** Register the built-in LIKE and GLOB functions.  The caseSensitive\n** parameter determines whether or not the LIKE operator is case\n** sensitive.  GLOB is always case sensitive.\n*/\nSQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){\n  struct compareInfo *pInfo;\n  if( caseSensitive ){\n    pInfo = (struct compareInfo*)&likeInfoAlt;\n  }else{\n    pInfo = (struct compareInfo*)&likeInfoNorm;\n  }\n  sqlite3CreateFunc(db, \"like\", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"like\", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"glob\", 2, SQLITE_UTF8, \n      (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);\n  setLikeOptFlag(db, \"glob\", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);\n  setLikeOptFlag(db, \"like\", \n      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);\n}\n\n/*\n** pExpr points to an expression which implements a function.  If\n** it is appropriate to apply the LIKE optimization to that function\n** then set aWc[0] through aWc[2] to the wildcard characters and the\n** escape character and then return TRUE.  If the function is not a \n** LIKE-style function then return FALSE.\n**\n** The expression \"a LIKE b ESCAPE c\" is only considered a valid LIKE\n** operator if c is a string literal that is exactly one byte in length.\n** That one byte is stored in aWc[3].  aWc[3] is set to zero if there is\n** no ESCAPE clause.\n**\n** *pIsNocase is set to true if uppercase and lowercase are equivalent for\n** the function (default for LIKE).  If the function makes the distinction\n** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to\n** false.\n*/\nSQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){\n  FuncDef *pDef;\n  int nExpr;\n  if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){\n    return 0;\n  }\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  nExpr = pExpr->x.pList->nExpr;\n  pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);\n  if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){\n    return 0;\n  }\n  if( nExpr<3 ){\n    aWc[3] = 0;\n  }else{\n    Expr *pEscape = pExpr->x.pList->a[2].pExpr;\n    char *zEscape;\n    if( pEscape->op!=TK_STRING ) return 0;\n    zEscape = pEscape->u.zToken;\n    if( zEscape[0]==0 || zEscape[1]!=0 ) return 0;\n    aWc[3] = zEscape[0];\n  }\n\n  /* The memcpy() statement assumes that the wildcard characters are\n  ** the first three statements in the compareInfo structure.  The\n  ** asserts() that follow verify that assumption\n  */\n  memcpy(aWc, pDef->pUserData, 3);\n  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );\n  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );\n  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );\n  *pIsNocase = (pDef->funcFlags & SQLITE_FUNC_CASE)==0;\n  return 1;\n}\n\n/*\n** All of the FuncDef structures in the aBuiltinFunc[] array above\n** to the global function hash table.  This occurs at start-time (as\n** a consequence of calling sqlite3_initialize()).\n**\n** After this routine runs\n*/\nSQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){\n  /*\n  ** The following array holds FuncDef structures for all of the functions\n  ** defined in this file.\n  **\n  ** The array cannot be constant since changes are made to the\n  ** FuncDef.pHash elements at start-time.  The elements of this array\n  ** are read-only after initialization is complete.\n  **\n  ** For peak efficiency, put the most frequently used function last.\n  */\n  static FuncDef aBuiltinFunc[] = {\n#ifdef SQLITE_SOUNDEX\n    FUNCTION(soundex,            1, 0, 0, soundexFunc      ),\n#endif\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    VFUNCTION(load_extension,    1, 0, 0, loadExt          ),\n    VFUNCTION(load_extension,    2, 0, 0, loadExt          ),\n#endif\n#if SQLITE_USER_AUTHENTICATION\n    FUNCTION(sqlite_crypt,       2, 0, 0, sqlite3CryptFunc ),\n#endif\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n    DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),\n    DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n    FUNCTION2(unlikely,          1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likelihood,        2, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likely,            1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n#ifdef SQLITE_DEBUG\n    FUNCTION2(affinity,          1, 0, 0, noopFunc,  SQLITE_FUNC_AFFINITY),\n#endif\n    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),\n    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),\n    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),\n    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),\n    FUNCTION(trim,               1, 3, 0, trimFunc         ),\n    FUNCTION(trim,               2, 3, 0, trimFunc         ),\n    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),\n    FUNCTION(min,                0, 0, 1, 0                ),\n    AGGREGATE2(min,              1, 0, 1, minmaxStep,      minMaxFinalize,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),\n    FUNCTION(max,                0, 1, 1, 0                ),\n    AGGREGATE2(max,              1, 1, 1, minmaxStep,      minMaxFinalize,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION2(typeof,            1, 0, 0, typeofFunc,  SQLITE_FUNC_TYPEOF),\n    FUNCTION2(length,            1, 0, 0, lengthFunc,  SQLITE_FUNC_LENGTH),\n    FUNCTION(instr,              2, 0, 0, instrFunc        ),\n    FUNCTION(printf,            -1, 0, 0, printfFunc       ),\n    FUNCTION(unicode,            1, 0, 0, unicodeFunc      ),\n    FUNCTION(char,              -1, 0, 0, charFunc         ),\n    FUNCTION(abs,                1, 0, 0, absFunc          ),\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    FUNCTION(round,              1, 0, 0, roundFunc        ),\n    FUNCTION(round,              2, 0, 0, roundFunc        ),\n#endif\n    FUNCTION(upper,              1, 0, 0, upperFunc        ),\n    FUNCTION(lower,              1, 0, 0, lowerFunc        ),\n    FUNCTION(hex,                1, 0, 0, hexFunc          ),\n    FUNCTION2(ifnull,            2, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n    VFUNCTION(random,            0, 0, 0, randomFunc       ),\n    VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),\n    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),\n    DFUNCTION(sqlite_version,    0, 0, 0, versionFunc      ),\n    DFUNCTION(sqlite_source_id,  0, 0, 0, sourceidFunc     ),\n    FUNCTION(sqlite_log,         2, 0, 0, errlogFunc       ),\n    FUNCTION(quote,              1, 0, 0, quoteFunc        ),\n    VFUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid),\n    VFUNCTION(changes,           0, 0, 0, changes          ),\n    VFUNCTION(total_changes,     0, 0, 0, total_changes    ),\n    FUNCTION(replace,            3, 0, 0, replaceFunc      ),\n    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),\n    FUNCTION(substr,             2, 0, 0, substrFunc       ),\n    FUNCTION(substr,             3, 0, 0, substrFunc       ),\n    AGGREGATE(sum,               1, 0, 0, sumStep,         sumFinalize    ),\n    AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),\n    AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),\n    AGGREGATE2(count,            0, 0, 0, countStep,       countFinalize,\n               SQLITE_FUNC_COUNT  ),\n    AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),\n    AGGREGATE(group_concat,      1, 0, 0, groupConcatStep, groupConcatFinalize),\n    AGGREGATE(group_concat,      2, 0, 0, groupConcatStep, groupConcatFinalize),\n  \n    LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#ifdef SQLITE_CASE_SENSITIVE_LIKE\n    LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n    LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#else\n    LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),\n    LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),\n#endif\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n    FUNCTION(unknown,           -1, 0, 0, unknownFunc      ),\n#endif\n    FUNCTION(coalesce,           1, 0, 0, 0                ),\n    FUNCTION(coalesce,           0, 0, 0, 0                ),\n    FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n  };\n#ifndef SQLITE_OMIT_ALTERTABLE\n  sqlite3AlterFunctions();\n#endif\n#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)\n  sqlite3AnalyzeFunctions();\n#endif\n  sqlite3RegisterDateTimeFunctions();\n  sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));\n\n#if 0  /* Enable to print out how the built-in functions are hashed */\n  {\n    int i;\n    FuncDef *p;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      printf(\"FUNC-HASH %02d:\", i);\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){\n        int n = sqlite3Strlen30(p->zName);\n        int h = p->zName[0] + n;\n        printf(\" %s(%d)\", p->zName, h);\n      }\n      printf(\"\\n\");\n    }\n  }\n#endif\n}\n\n/************** End of func.c ************************************************/\n/************** Begin file fkey.c ********************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used by the compiler to add foreign key\n** support to compiled SQL statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n\n/*\n** Deferred and Immediate FKs\n** --------------------------\n**\n** Foreign keys in SQLite come in two flavours: deferred and immediate.\n** If an immediate foreign key constraint is violated,\n** SQLITE_CONSTRAINT_FOREIGNKEY is returned and the current\n** statement transaction rolled back. If a \n** deferred foreign key constraint is violated, no action is taken \n** immediately. However if the application attempts to commit the \n** transaction before fixing the constraint violation, the attempt fails.\n**\n** Deferred constraints are implemented using a simple counter associated\n** with the database handle. The counter is set to zero each time a \n** database transaction is opened. Each time a statement is executed \n** that causes a foreign key violation, the counter is incremented. Each\n** time a statement is executed that removes an existing violation from\n** the database, the counter is decremented. When the transaction is\n** committed, the commit fails if the current value of the counter is\n** greater than zero. This scheme has two big drawbacks:\n**\n**   * When a commit fails due to a deferred foreign key constraint, \n**     there is no way to tell which foreign constraint is not satisfied,\n**     or which row it is not satisfied for.\n**\n**   * If the database contains foreign key violations when the \n**     transaction is opened, this may cause the mechanism to malfunction.\n**\n** Despite these problems, this approach is adopted as it seems simpler\n** than the alternatives.\n**\n** INSERT operations:\n**\n**   I.1) For each FK for which the table is the child table, search\n**        the parent table for a match. If none is found increment the\n**        constraint counter.\n**\n**   I.2) For each FK for which the table is the parent table, \n**        search the child table for rows that correspond to the new\n**        row in the parent table. Decrement the counter for each row\n**        found (as the constraint is now satisfied).\n**\n** DELETE operations:\n**\n**   D.1) For each FK for which the table is the child table, \n**        search the parent table for a row that corresponds to the \n**        deleted row in the child table. If such a row is not found, \n**        decrement the counter.\n**\n**   D.2) For each FK for which the table is the parent table, search \n**        the child table for rows that correspond to the deleted row \n**        in the parent table. For each found increment the counter.\n**\n** UPDATE operations:\n**\n**   An UPDATE command requires that all 4 steps above are taken, but only\n**   for FK constraints for which the affected columns are actually \n**   modified (values must be compared at runtime).\n**\n** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.\n** This simplifies the implementation a bit.\n**\n** For the purposes of immediate FK constraints, the OR REPLACE conflict\n** resolution is considered to delete rows before the new row is inserted.\n** If a delete caused by OR REPLACE violates an FK constraint, an exception\n** is thrown, even if the FK constraint would be satisfied after the new \n** row is inserted.\n**\n** Immediate constraints are usually handled similarly. The only difference \n** is that the counter used is stored as part of each individual statement\n** object (struct Vdbe). If, after the statement has run, its immediate\n** constraint counter is greater than zero,\n** it returns SQLITE_CONSTRAINT_FOREIGNKEY\n** and the statement transaction is rolled back. An exception is an INSERT\n** statement that inserts a single row only (no triggers). In this case,\n** instead of using a counter, an exception is thrown immediately if the\n** INSERT violates a foreign key constraint. This is necessary as such\n** an INSERT does not open a statement transaction.\n**\n** TODO: How should dropping a table be handled? How should renaming a \n** table be handled?\n**\n**\n** Query API Notes\n** ---------------\n**\n** Before coding an UPDATE or DELETE row operation, the code-generator\n** for those two operations needs to know whether or not the operation\n** requires any FK processing and, if so, which columns of the original\n** row are required by the FK processing VDBE code (i.e. if FKs were\n** implemented using triggers, which of the old.* columns would be \n** accessed). No information is required by the code-generator before\n** coding an INSERT operation. The functions used by the UPDATE/DELETE\n** generation code to query for this information are:\n**\n**   sqlite3FkRequired() - Test to see if FK processing is required.\n**   sqlite3FkOldmask()  - Query for the set of required old.* columns.\n**\n**\n** Externally accessible module functions\n** --------------------------------------\n**\n**   sqlite3FkCheck()    - Check for foreign key violations.\n**   sqlite3FkActions()  - Code triggers for ON UPDATE/ON DELETE actions.\n**   sqlite3FkDelete()   - Delete an FKey structure.\n*/\n\n/*\n** VDBE Calling Convention\n** -----------------------\n**\n** Example:\n**\n**   For the following INSERT statement:\n**\n**     CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);\n**     INSERT INTO t1 VALUES(1, 2, 3.1);\n**\n**   Register (x):        2    (type integer)\n**   Register (x+1):      1    (type integer)\n**   Register (x+2):      NULL (type NULL)\n**   Register (x+3):      3.1  (type real)\n*/\n\n/*\n** A foreign key constraint requires that the key columns in the parent\n** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.\n** Given that pParent is the parent table for foreign key constraint pFKey, \n** search the schema for a unique index on the parent key columns. \n**\n** If successful, zero is returned. If the parent key is an INTEGER PRIMARY \n** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx \n** is set to point to the unique index. \n** \n** If the parent key consists of a single column (the foreign key constraint\n** is not a composite foreign key), output variable *paiCol is set to NULL.\n** Otherwise, it is set to point to an allocated array of size N, where\n** N is the number of columns in the parent key. The first element of the\n** array is the index of the child table column that is mapped by the FK\n** constraint to the parent table column stored in the left-most column\n** of index *ppIdx. The second element of the array is the index of the\n** child table column that corresponds to the second left-most column of\n** *ppIdx, and so on.\n**\n** If the required index cannot be found, either because:\n**\n**   1) The named parent key columns do not exist, or\n**\n**   2) The named parent key columns do exist, but are not subject to a\n**      UNIQUE or PRIMARY KEY constraint, or\n**\n**   3) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the parent table does not have a\n**      PRIMARY KEY, or\n**\n**   4) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the PRIMARY KEY of the parent table \n**      consists of a different number of columns to the child key in \n**      the child table.\n**\n** then non-zero is returned, and a \"foreign key mismatch\" error loaded\n** into pParse. If an OOM error occurs, non-zero is returned and the\n** pParse->db->mallocFailed flag is set.\n*/\nSQLITE_PRIVATE int sqlite3FkLocateIndex(\n  Parse *pParse,                  /* Parse context to store any error in */\n  Table *pParent,                 /* Parent table of FK constraint pFKey */\n  FKey *pFKey,                    /* Foreign key to find index for */\n  Index **ppIdx,                  /* OUT: Unique index on parent table */\n  int **paiCol                    /* OUT: Map of index columns in pFKey */\n){\n  Index *pIdx = 0;                    /* Value to return via *ppIdx */\n  int *aiCol = 0;                     /* Value to return via *paiCol */\n  int nCol = pFKey->nCol;             /* Number of columns in parent key */\n  char *zKey = pFKey->aCol[0].zCol;   /* Name of left-most parent key column */\n\n  /* The caller is responsible for zeroing output parameters. */\n  assert( ppIdx && *ppIdx==0 );\n  assert( !paiCol || *paiCol==0 );\n  assert( pParse );\n\n  /* If this is a non-composite (single column) foreign key, check if it \n  ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx \n  ** and *paiCol set to zero and return early. \n  **\n  ** Otherwise, for a composite foreign key (more than one column), allocate\n  ** space for the aiCol array (returned via output parameter *paiCol).\n  ** Non-composite foreign keys do not require the aiCol array.\n  */\n  if( nCol==1 ){\n    /* The FK maps to the IPK if any of the following are true:\n    **\n    **   1) There is an INTEGER PRIMARY KEY column and the FK is implicitly \n    **      mapped to the primary key of table pParent, or\n    **   2) The FK is explicitly mapped to a column declared as INTEGER\n    **      PRIMARY KEY.\n    */\n    if( pParent->iPKey>=0 ){\n      if( !zKey ) return 0;\n      if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;\n    }\n  }else if( paiCol ){\n    assert( nCol>1 );\n    aiCol = (int *)sqlite3DbMallocRawNN(pParse->db, nCol*sizeof(int));\n    if( !aiCol ) return 1;\n    *paiCol = aiCol;\n  }\n\n  for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){ \n      /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number\n      ** of columns. If each indexed column corresponds to a foreign key\n      ** column of pFKey, then this index is a winner.  */\n\n      if( zKey==0 ){\n        /* If zKey is NULL, then this foreign key is implicitly mapped to \n        ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be \n        ** identified by the test.  */\n        if( IsPrimaryKeyIndex(pIdx) ){\n          if( aiCol ){\n            int i;\n            for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;\n          }\n          break;\n        }\n      }else{\n        /* If zKey is non-NULL, then this foreign key was declared to\n        ** map to an explicit list of columns in table pParent. Check if this\n        ** index matches those columns. Also, check that the index uses\n        ** the default collation sequences for each column. */\n        int i, j;\n        for(i=0; i<nCol; i++){\n          i16 iCol = pIdx->aiColumn[i];     /* Index of column in parent tbl */\n          const char *zDfltColl;            /* Def. collation for column */\n          char *zIdxCol;                    /* Name of indexed column */\n\n          if( iCol<0 ) break; /* No foreign keys against expression indexes */\n\n          /* If the index uses a collation sequence that is different from\n          ** the default collation sequence for the column, this index is\n          ** unusable. Bail out early in this case.  */\n          zDfltColl = pParent->aCol[iCol].zColl;\n          if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;\n          if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;\n\n          zIdxCol = pParent->aCol[iCol].zName;\n          for(j=0; j<nCol; j++){\n            if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){\n              if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;\n              break;\n            }\n          }\n          if( j==nCol ) break;\n        }\n        if( i==nCol ) break;      /* pIdx is usable */\n      }\n    }\n  }\n\n  if( !pIdx ){\n    if( !pParse->disableTriggers ){\n      sqlite3ErrorMsg(pParse,\n           \"foreign key mismatch - \\\"%w\\\" referencing \\\"%w\\\"\",\n           pFKey->pFrom->zName, pFKey->zTo);\n    }\n    sqlite3DbFree(pParse->db, aiCol);\n    return 1;\n  }\n\n  *ppIdx = pIdx;\n  return 0;\n}\n\n/*\n** This function is called when a row is inserted into or deleted from the \n** child table of foreign key constraint pFKey. If an SQL UPDATE is executed \n** on the child table of pFKey, this function is invoked twice for each row\n** affected - once to \"delete\" the old row, and then again to \"insert\" the\n** new row.\n**\n** Each time it is called, this function generates VDBE code to locate the\n** row in the parent table that corresponds to the row being inserted into \n** or deleted from the child table. If the parent row can be found, no \n** special action is taken. Otherwise, if the parent row can *not* be\n** found in the parent table:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   INSERT      immediate   Increment the \"immediate constraint counter\".\n**\n**   DELETE      immediate   Decrement the \"immediate constraint counter\".\n**\n**   INSERT      deferred    Increment the \"deferred constraint counter\".\n**\n**   DELETE      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.1\" and \"D.1\".\n*/\nstatic void fkLookupParent(\n  Parse *pParse,        /* Parse context */\n  int iDb,              /* Index of database housing pTab */\n  Table *pTab,          /* Parent table of FK pFKey */\n  Index *pIdx,          /* Unique index on parent key columns in pTab */\n  FKey *pFKey,          /* Foreign key constraint */\n  int *aiCol,           /* Map from parent key columns to child table columns */\n  int regData,          /* Address of array containing child table row */\n  int nIncr,            /* Increment constraint counter by this */\n  int isIgnore          /* If true, pretend pTab contains all NULL values */\n){\n  int i;                                    /* Iterator variable */\n  Vdbe *v = sqlite3GetVdbe(pParse);         /* Vdbe to add code to */\n  int iCur = pParse->nTab - 1;              /* Cursor number to use */\n  int iOk = sqlite3VdbeMakeLabel(v);        /* jump here if parent key found */\n\n  /* If nIncr is less than zero, then check at runtime if there are any\n  ** outstanding constraints to resolve. If there are not, there is no need\n  ** to check if deleting this row resolves any outstanding violations.\n  **\n  ** Check if any of the key columns in the child table row are NULL. If \n  ** any are, then the constraint is considered satisfied. No need to \n  ** search for a matching row in the parent table.  */\n  if( nIncr<0 ){\n    sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);\n    VdbeCoverage(v);\n  }\n  for(i=0; i<pFKey->nCol; i++){\n    int iReg = aiCol[i] + regData + 1;\n    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);\n  }\n\n  if( isIgnore==0 ){\n    if( pIdx==0 ){\n      /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY\n      ** column of the parent table (table pTab).  */\n      int iMustBeInt;               /* Address of MustBeInt instruction */\n      int regTemp = sqlite3GetTempReg(pParse);\n  \n      /* Invoke MustBeInt to coerce the child key value to an integer (i.e. \n      ** apply the affinity of the parent key). If this fails, then there\n      ** is no matching parent key. Before using MustBeInt, make a copy of\n      ** the value. Otherwise, the value inserted into the child key column\n      ** will have INTEGER affinity applied to it, which may not be correct.  */\n      sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);\n      iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);\n      VdbeCoverage(v);\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter.  */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      }\n  \n      sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, iOk);\n      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      sqlite3VdbeJumpHere(v, iMustBeInt);\n      sqlite3ReleaseTempReg(pParse, regTemp);\n    }else{\n      int nCol = pFKey->nCol;\n      int regTemp = sqlite3GetTempRange(pParse, nCol);\n      int regRec = sqlite3GetTempReg(pParse);\n  \n      sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      for(i=0; i<nCol; i++){\n        sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);\n      }\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter. \n      **\n      ** If any of the parent-key values are NULL, then the row cannot match \n      ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any\n      ** of the parent-key values are NULL (at this point it is known that\n      ** none of the child key values are).\n      */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;\n        for(i=0; i<nCol; i++){\n          int iChild = aiCol[i]+1+regData;\n          int iParent = pIdx->aiColumn[i]+1+regData;\n          assert( pIdx->aiColumn[i]>=0 );\n          assert( aiCol[i]!=pTab->iPKey );\n          if( pIdx->aiColumn[i]==pTab->iPKey ){\n            /* The parent key is a composite key that includes the IPK column */\n            iParent = regData;\n          }\n          sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); VdbeCoverage(v);\n          sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);\n        }\n        sqlite3VdbeGoto(v, iOk);\n      }\n  \n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec,\n                        sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);\n      sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); VdbeCoverage(v);\n  \n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempRange(pParse, regTemp, nCol);\n    }\n  }\n\n  if( !pFKey->isDeferred && !(pParse->db->flags & SQLITE_DeferFKs)\n   && !pParse->pToplevel \n   && !pParse->isMultiWrite \n  ){\n    /* Special case: If this is an INSERT statement that will insert exactly\n    ** one row into the table, raise a constraint immediately instead of\n    ** incrementing a counter. This is necessary as the VM code is being\n    ** generated for will not open a statement transaction.  */\n    assert( nIncr==1 );\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n        OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n  }else{\n    if( nIncr>0 && pFKey->isDeferred==0 ){\n      sqlite3MayAbort(pParse);\n    }\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n  }\n\n  sqlite3VdbeResolveLabel(v, iOk);\n  sqlite3VdbeAddOp1(v, OP_Close, iCur);\n}\n\n\n/*\n** Return an Expr object that refers to a memory register corresponding\n** to column iCol of table pTab.\n**\n** regBase is the first of an array of register that contains the data\n** for pTab.  regBase itself holds the rowid.  regBase+1 holds the first\n** column.  regBase+2 holds the second column, and so forth.\n*/\nstatic Expr *exprTableRegister(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* The table whose content is at r[regBase]... */\n  int regBase,       /* Contents of table pTab */\n  i16 iCol           /* Which column of pTab is desired */\n){\n  Expr *pExpr;\n  Column *pCol;\n  const char *zColl;\n  sqlite3 *db = pParse->db;\n\n  pExpr = sqlite3Expr(db, TK_REGISTER, 0);\n  if( pExpr ){\n    if( iCol>=0 && iCol!=pTab->iPKey ){\n      pCol = &pTab->aCol[iCol];\n      pExpr->iTable = regBase + iCol + 1;\n      pExpr->affinity = pCol->affinity;\n      zColl = pCol->zColl;\n      if( zColl==0 ) zColl = db->pDfltColl->zName;\n      pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);\n    }else{\n      pExpr->iTable = regBase;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n  }\n  return pExpr;\n}\n\n/*\n** Return an Expr object that refers to column iCol of table pTab which\n** has cursor iCur.\n*/\nstatic Expr *exprTableColumn(\n  sqlite3 *db,      /* The database connection */\n  Table *pTab,      /* The table whose column is desired */\n  int iCursor,      /* The open cursor on the table */\n  i16 iCol          /* The column that is wanted */\n){\n  Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);\n  if( pExpr ){\n    pExpr->pTab = pTab;\n    pExpr->iTable = iCursor;\n    pExpr->iColumn = iCol;\n  }\n  return pExpr;\n}\n\n/*\n** This function is called to generate code executed when a row is deleted\n** from the parent table of foreign key constraint pFKey and, if pFKey is \n** deferred, when a row is inserted into the same table. When generating\n** code for an SQL UPDATE operation, this function may be called twice -\n** once to \"delete\" the old row and once to \"insert\" the new row.\n**\n** Parameter nIncr is passed -1 when inserting a row (as this may decrease\n** the number of FK violations in the db) or +1 when deleting one (as this\n** may increase the number of FK constraint problems).\n**\n** The code generated by this function scans through the rows in the child\n** table that correspond to the parent table row being deleted or inserted.\n** For each child row found, one of the following actions is taken:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   DELETE      immediate   Increment the \"immediate constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      immediate   Decrement the \"immediate constraint counter\".\n**\n**   DELETE      deferred    Increment the \"deferred constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.2\" and \"D.2\".\n*/\nstatic void fkScanChildren(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pSrc,                  /* The child table to be scanned */\n  Table *pTab,                    /* The parent table */\n  Index *pIdx,                    /* Index on parent covering the foreign key */\n  FKey *pFKey,                    /* The foreign key linking pSrc to pTab */\n  int *aiCol,                     /* Map from pIdx cols to child table cols */\n  int regData,                    /* Parent row data starts here */\n  int nIncr                       /* Amount to increment deferred counter by */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int i;                          /* Iterator variable */\n  Expr *pWhere = 0;               /* WHERE clause to scan with */\n  NameContext sNameContext;       /* Context used to resolve WHERE clause */\n  WhereInfo *pWInfo;              /* Context used by sqlite3WhereXXX() */\n  int iFkIfZero = 0;              /* Address of OP_FkIfZero */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n\n  assert( pIdx==0 || pIdx->pTable==pTab );\n  assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );\n  assert( pIdx!=0 || pFKey->nCol==1 );\n  assert( pIdx!=0 || HasRowid(pTab) );\n\n  if( nIncr<0 ){\n    iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);\n    VdbeCoverage(v);\n  }\n\n  /* Create an Expr object representing an SQL expression like:\n  **\n  **   <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...\n  **\n  ** The collation sequence used for the comparison should be that of\n  ** the parent key columns. The affinity of the parent key column should\n  ** be applied to each child key value before the comparison takes place.\n  */\n  for(i=0; i<pFKey->nCol; i++){\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    Expr *pEq;                    /* Expression (pLeft = pRight) */\n    i16 iCol;                     /* Index of column in child table */ \n    const char *zCol;             /* Name of column in child table */\n\n    iCol = pIdx ? pIdx->aiColumn[i] : -1;\n    pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n    iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n    assert( iCol>=0 );\n    zCol = pFKey->pFrom->aCol[iCol].zName;\n    pRight = sqlite3Expr(db, TK_ID, zCol);\n    pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);\n    pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n  }\n\n  /* If the child table is the same as the parent table, then add terms\n  ** to the WHERE clause that prevent this entry from being scanned.\n  ** The added WHERE clause terms are like this:\n  **\n  **     $current_rowid!=rowid\n  **     NOT( $current_a==a AND $current_b==b AND ... )\n  **\n  ** The first form is used for rowid tables.  The second form is used\n  ** for WITHOUT ROWID tables.  In the second form, the primary key is\n  ** (a,b,...)\n  */\n  if( pTab==pFKey->pFrom && nIncr>0 ){\n    Expr *pNe;                    /* Expression (pLeft != pRight) */\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    if( HasRowid(pTab) ){\n      pLeft = exprTableRegister(pParse, pTab, regData, -1);\n      pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, -1);\n      pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight);\n    }else{\n      Expr *pEq, *pAll = 0;\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      assert( pIdx!=0 );\n      for(i=0; i<pPk->nKeyCol; i++){\n        i16 iCol = pIdx->aiColumn[i];\n        assert( iCol>=0 );\n        pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n        pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, iCol);\n        pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);\n        pAll = sqlite3ExprAnd(db, pAll, pEq);\n      }\n      pNe = sqlite3PExpr(pParse, TK_NOT, pAll, 0);\n    }\n    pWhere = sqlite3ExprAnd(db, pWhere, pNe);\n  }\n\n  /* Resolve the references in the WHERE clause. */\n  memset(&sNameContext, 0, sizeof(NameContext));\n  sNameContext.pSrcList = pSrc;\n  sNameContext.pParse = pParse;\n  sqlite3ResolveExprNames(&sNameContext, pWhere);\n\n  /* Create VDBE to loop through the entries in pSrc that match the WHERE\n  ** clause. For each row found, increment either the deferred or immediate\n  ** foreign key constraint counter. */\n  if( pParse->nErr==0 ){\n    pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n    if( pWInfo ){\n      sqlite3WhereEnd(pWInfo);\n    }\n  }\n\n  /* Clean up the WHERE clause constructed above. */\n  sqlite3ExprDelete(db, pWhere);\n  if( iFkIfZero ){\n    sqlite3VdbeJumpHere(v, iFkIfZero);\n  }\n}\n\n/*\n** This function returns a linked list of FKey objects (connected by\n** FKey.pNextTo) holding all children of table pTab.  For example,\n** given the following schema:\n**\n**   CREATE TABLE t1(a PRIMARY KEY);\n**   CREATE TABLE t2(b REFERENCES t1(a);\n**\n** Calling this function with table \"t1\" as an argument returns a pointer\n** to the FKey structure representing the foreign key constraint on table\n** \"t2\". Calling this function with \"t2\" as the argument would return a\n** NULL pointer (as there are no FK constraints for which t2 is the parent\n** table).\n*/\nSQLITE_PRIVATE FKey *sqlite3FkReferences(Table *pTab){\n  return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName);\n}\n\n/*\n** The second argument is a Trigger structure allocated by the \n** fkActionTrigger() routine. This function deletes the Trigger structure\n** and all of its sub-components.\n**\n** The Trigger structure or any of its sub-components may be allocated from\n** the lookaside buffer belonging to database handle dbMem.\n*/\nstatic void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){\n  if( p ){\n    TriggerStep *pStep = p->step_list;\n    sqlite3ExprDelete(dbMem, pStep->pWhere);\n    sqlite3ExprListDelete(dbMem, pStep->pExprList);\n    sqlite3SelectDelete(dbMem, pStep->pSelect);\n    sqlite3ExprDelete(dbMem, p->pWhen);\n    sqlite3DbFree(dbMem, p);\n  }\n}\n\n/*\n** This function is called to generate code that runs when table pTab is\n** being dropped from the database. The SrcList passed as the second argument\n** to this function contains a single entry guaranteed to resolve to\n** table pTab.\n**\n** Normally, no code is required. However, if either\n**\n**   (a) The table is the parent table of a FK constraint, or\n**   (b) The table is the child table of a deferred FK constraint and it is\n**       determined at runtime that there are outstanding deferred FK \n**       constraint violations in the database,\n**\n** then the equivalent of \"DELETE FROM <tbl>\" is executed before dropping\n** the table from the database. Triggers are disabled while running this\n** DELETE, but foreign key actions are not.\n*/\nSQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){\n  sqlite3 *db = pParse->db;\n  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){\n    int iSkip = 0;\n    Vdbe *v = sqlite3GetVdbe(pParse);\n\n    assert( v );                  /* VDBE has already been allocated */\n    if( sqlite3FkReferences(pTab)==0 ){\n      /* Search for a deferred foreign key constraint for which this table\n      ** is the child table. If one cannot be found, return without \n      ** generating any VDBE code. If one can be found, then jump over\n      ** the entire DELETE if there are no outstanding deferred constraints\n      ** when this statement is run.  */\n      FKey *p;\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;\n      }\n      if( !p ) return;\n      iSkip = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);\n    }\n\n    pParse->disableTriggers = 1;\n    sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);\n    pParse->disableTriggers = 0;\n\n    /* If the DELETE has generated immediate foreign key constraint \n    ** violations, halt the VDBE and return an error at this point, before\n    ** any modifications to the schema are made. This is because statement\n    ** transactions are not able to rollback schema changes.  \n    **\n    ** If the SQLITE_DeferFKs flag is set, then this is not required, as\n    ** the statement transaction will not be rolled back even if FK\n    ** constraints are violated.\n    */\n    if( (db->flags & SQLITE_DeferFKs)==0 ){\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n      sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n          OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n    }\n\n    if( iSkip ){\n      sqlite3VdbeResolveLabel(v, iSkip);\n    }\n  }\n}\n\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the child table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** child key for FK constraint *p are modified.\n*/\nstatic int fkChildIsModified(\n  Table *pTab,                    /* Table being updated */\n  FKey *p,                        /* Foreign key for which pTab is the child */\n  int *aChange,                   /* Array indicating modified columns */\n  int bChngRowid                  /* True if rowid is modified by this update */\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    int iChildKey = p->aCol[i].iFrom;\n    if( aChange[iChildKey]>=0 ) return 1;\n    if( iChildKey==pTab->iPKey && bChngRowid ) return 1;\n  }\n  return 0;\n}\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the parent table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** parent key for FK constraint *p are modified.\n*/\nstatic int fkParentIsModified(\n  Table *pTab, \n  FKey *p, \n  int *aChange, \n  int bChngRowid\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    char *zKey = p->aCol[i].zCol;\n    int iKey;\n    for(iKey=0; iKey<pTab->nCol; iKey++){\n      if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){\n        Column *pCol = &pTab->aCol[iKey];\n        if( zKey ){\n          if( 0==sqlite3StrICmp(pCol->zName, zKey) ) return 1;\n        }else if( pCol->colFlags & COLFLAG_PRIMKEY ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Return true if the parser passed as the first argument is being\n** used to code a trigger that is really a \"SET NULL\" action belonging\n** to trigger pFKey.\n*/\nstatic int isSetNullAction(Parse *pParse, FKey *pFKey){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  if( pTop->pTriggerPrg ){\n    Trigger *p = pTop->pTriggerPrg->pTrigger;\n    if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull)\n     || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is called when inserting, deleting or updating a row of\n** table pTab to generate VDBE code to perform foreign key constraint \n** processing for the operation.\n**\n** For a DELETE operation, parameter regOld is passed the index of the\n** first register in an array of (pTab->nCol+1) registers containing the\n** rowid of the row being deleted, followed by each of the column values\n** of the row being deleted, from left to right. Parameter regNew is passed\n** zero in this case.\n**\n** For an INSERT operation, regOld is passed zero and regNew is passed the\n** first register of an array of (pTab->nCol+1) registers containing the new\n** row data.\n**\n** For an UPDATE operation, this function is called twice. Once before\n** the original record is deleted from the table using the calling convention\n** described for DELETE. Then again after the original record is deleted\n** but before the new record is inserted using the INSERT convention. \n*/\nSQLITE_PRIVATE void sqlite3FkCheck(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Row is being deleted from this table */ \n  int regOld,                     /* Previous row data is stored here */\n  int regNew,                     /* New row data is stored here */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  FKey *pFKey;                    /* Used to iterate through FKs */\n  int iDb;                        /* Index of database containing pTab */\n  const char *zDb;                /* Name of database containing pTab */\n  int isIgnoreErrors = pParse->disableTriggers;\n\n  /* Exactly one of regOld and regNew should be non-zero. */\n  assert( (regOld==0)!=(regNew==0) );\n\n  /* If foreign-keys are disabled, this function is a no-op. */\n  if( (db->flags&SQLITE_ForeignKeys)==0 ) return;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n\n  /* Loop through all the foreign key constraints for which pTab is the\n  ** child table (the table that the foreign key definition is part of).  */\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n    Table *pTo;                   /* Parent table of foreign key pFKey */\n    Index *pIdx = 0;              /* Index on key columns in pTo */\n    int *aiFree = 0;\n    int *aiCol;\n    int iCol;\n    int i;\n    int bIgnore = 0;\n\n    if( aChange \n     && sqlite3_stricmp(pTab->zName, pFKey->zTo)!=0\n     && fkChildIsModified(pTab, pFKey, aChange, bChngRowid)==0 \n    ){\n      continue;\n    }\n\n    /* Find the parent table of this foreign key. Also find a unique index \n    ** on the parent key columns in the parent table. If either of these \n    ** schema items cannot be located, set an error in pParse and return \n    ** early.  */\n    if( pParse->disableTriggers ){\n      pTo = sqlite3FindTable(db, pFKey->zTo, zDb);\n    }else{\n      pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);\n    }\n    if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){\n      assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      if( pTo==0 ){\n        /* If isIgnoreErrors is true, then a table is being dropped. In this\n        ** case SQLite runs a \"DELETE FROM xxx\" on the table being dropped\n        ** before actually dropping it in order to check FK constraints.\n        ** If the parent table of an FK constraint on the current table is\n        ** missing, behave as if it is empty. i.e. decrement the relevant\n        ** FK counter for each row of the current table with non-NULL keys.\n        */\n        Vdbe *v = sqlite3GetVdbe(pParse);\n        int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;\n        for(i=0; i<pFKey->nCol; i++){\n          int iReg = pFKey->aCol[i].iFrom + regOld + 1;\n          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);\n      }\n      continue;\n    }\n    assert( pFKey->nCol==1 || (aiFree && pIdx) );\n\n    if( aiFree ){\n      aiCol = aiFree;\n    }else{\n      iCol = pFKey->aCol[0].iFrom;\n      aiCol = &iCol;\n    }\n    for(i=0; i<pFKey->nCol; i++){\n      if( aiCol[i]==pTab->iPKey ){\n        aiCol[i] = -1;\n      }\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      /* Request permission to read the parent key columns. If the \n      ** authorization callback returns SQLITE_IGNORE, behave as if any\n      ** values read from the parent table are NULL. */\n      if( db->xAuth ){\n        int rcauth;\n        char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;\n        rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);\n        bIgnore = (rcauth==SQLITE_IGNORE);\n      }\n#endif\n    }\n\n    /* Take a shared-cache advisory read-lock on the parent table. Allocate \n    ** a cursor to use to search the unique index on the parent key columns \n    ** in the parent table.  */\n    sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);\n    pParse->nTab++;\n\n    if( regOld!=0 ){\n      /* A row is being removed from the child table. Search for the parent.\n      ** If the parent does not exist, removing the child row resolves an \n      ** outstanding foreign key constraint violation. */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);\n    }\n    if( regNew!=0 && !isSetNullAction(pParse, pFKey) ){\n      /* A row is being added to the child table. If a parent row cannot\n      ** be found, adding the child row has violated the FK constraint. \n      **\n      ** If this operation is being performed as part of a trigger program\n      ** that is actually a \"SET NULL\" action belonging to this very \n      ** foreign key, then omit this scan altogether. As all child key\n      ** values are guaranteed to be NULL, it is not possible for adding\n      ** this row to cause an FK violation.  */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);\n    }\n\n    sqlite3DbFree(db, aiFree);\n  }\n\n  /* Loop through all the foreign key constraints that refer to this table.\n  ** (the \"child\" constraints) */\n  for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n    Index *pIdx = 0;              /* Foreign key index for pFKey */\n    SrcList *pSrc;\n    int *aiCol = 0;\n\n    if( aChange && fkParentIsModified(pTab, pFKey, aChange, bChngRowid)==0 ){\n      continue;\n    }\n\n    if( !pFKey->isDeferred && !(db->flags & SQLITE_DeferFKs) \n     && !pParse->pToplevel && !pParse->isMultiWrite \n    ){\n      assert( regOld==0 && regNew!=0 );\n      /* Inserting a single row into a parent table cannot cause (or fix)\n      ** an immediate foreign key violation. So do nothing in this case.  */\n      continue;\n    }\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      continue;\n    }\n    assert( aiCol || pFKey->nCol==1 );\n\n    /* Create a SrcList structure containing the child table.  We need the\n    ** child table as a SrcList for sqlite3WhereBegin() */\n    pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n    if( pSrc ){\n      struct SrcList_item *pItem = pSrc->a;\n      pItem->pTab = pFKey->pFrom;\n      pItem->zName = pFKey->pFrom->zName;\n      pItem->pTab->nTabRef++;\n      pItem->iCursor = pParse->nTab++;\n  \n      if( regNew!=0 ){\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);\n      }\n      if( regOld!=0 ){\n        int eAction = pFKey->aAction[aChange!=0];\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);\n        /* If this is a deferred FK constraint, or a CASCADE or SET NULL\n        ** action applies, then any foreign key violations caused by\n        ** removing the parent key will be rectified by the action trigger.\n        ** So do not set the \"may-abort\" flag in this case.\n        **\n        ** Note 1: If the FK is declared \"ON UPDATE CASCADE\", then the\n        ** may-abort flag will eventually be set on this statement anyway\n        ** (when this function is called as part of processing the UPDATE\n        ** within the action trigger).\n        **\n        ** Note 2: At first glance it may seem like SQLite could simply omit\n        ** all OP_FkCounter related scans when either CASCADE or SET NULL\n        ** applies. The trouble starts if the CASCADE or SET NULL action \n        ** trigger causes other triggers or action rules attached to the \n        ** child table to fire. In these cases the fk constraint counters\n        ** might be set incorrectly if any OP_FkCounter related scans are \n        ** omitted.  */\n        if( !pFKey->isDeferred && eAction!=OE_Cascade && eAction!=OE_SetNull ){\n          sqlite3MayAbort(pParse);\n        }\n      }\n      pItem->zName = 0;\n      sqlite3SrcListDelete(db, pSrc);\n    }\n    sqlite3DbFree(db, aiCol);\n  }\n}\n\n#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab.\n*/\nSQLITE_PRIVATE u32 sqlite3FkOldmask(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab                     /* Table being modified */\n){\n  u32 mask = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    int i;\n    for(p=pTab->pFKey; p; p=p->pNextFrom){\n      for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);\n    }\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Index *pIdx = 0;\n      sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);\n      if( pIdx ){\n        for(i=0; i<pIdx->nKeyCol; i++){\n          assert( pIdx->aiColumn[i]>=0 );\n          mask |= COLUMN_MASK(pIdx->aiColumn[i]);\n        }\n      }\n    }\n  }\n  return mask;\n}\n\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab. If the operation is a DELETE, then\n** parameter aChange is passed a NULL value. For an UPDATE, aChange points\n** to an array of size N, where N is the number of columns in table pTab.\n** If the i'th column is not modified by the UPDATE, then the corresponding \n** entry in the aChange[] array is set to -1. If the column is modified,\n** the value is 0 or greater. Parameter chngRowid is set to true if the\n** UPDATE statement modifies the rowid fields of the table.\n**\n** If any foreign key processing will be required, this function returns\n** non-zero. If there is no foreign key related processing, this function \n** returns zero.\n**\n** For an UPDATE, this function returns 2 if:\n**\n**   * There are any FKs for which pTab is the child and the parent table, or\n**   * the UPDATE modifies one or more parent keys for which the action is\n**     not \"NO ACTION\" (i.e. is CASCADE, SET DEFAULT or SET NULL).\n**\n** Or, assuming some other foreign key processing is required, 1.\n*/\nSQLITE_PRIVATE int sqlite3FkRequired(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being modified */\n  int *aChange,                   /* Non-NULL for UPDATE operations */\n  int chngRowid                   /* True for UPDATE that affects rowid */\n){\n  int eRet = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    if( !aChange ){\n      /* A DELETE operation. Foreign key processing is required if the \n      ** table in question is either the child or parent table for any \n      ** foreign key constraint.  */\n      eRet = (sqlite3FkReferences(pTab) || pTab->pFKey);\n    }else{\n      /* This is an UPDATE. Foreign key processing is only required if the\n      ** operation modifies one or more child or parent key columns. */\n      FKey *p;\n\n      /* Check if any child key columns are being modified. */\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2;\n        if( fkChildIsModified(pTab, p, aChange, chngRowid) ){\n          eRet = 1;\n        }\n      }\n\n      /* Check if any parent key columns are being modified. */\n      for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n        if( fkParentIsModified(pTab, p, aChange, chngRowid) ){\n          if( p->aAction[1]!=OE_None ) return 2;\n          eRet = 1;\n        }\n      }\n    }\n  }\n  return eRet;\n}\n\n/*\n** This function is called when an UPDATE or DELETE operation is being \n** compiled on table pTab, which is the parent table of foreign-key pFKey.\n** If the current operation is an UPDATE, then the pChanges parameter is\n** passed a pointer to the list of columns being modified. If it is a\n** DELETE, pChanges is passed a NULL pointer.\n**\n** It returns a pointer to a Trigger structure containing a trigger\n** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.\n** If the action is \"NO ACTION\" or \"RESTRICT\", then a NULL pointer is\n** returned (these actions require no special handling by the triggers\n** sub-system, code for them is created by fkScanChildren()).\n**\n** For example, if pFKey is the foreign key and pTab is table \"p\" in \n** the following schema:\n**\n**   CREATE TABLE p(pk PRIMARY KEY);\n**   CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);\n**\n** then the returned trigger structure is equivalent to:\n**\n**   CREATE TRIGGER ... DELETE ON p BEGIN\n**     DELETE FROM c WHERE ck = old.pk;\n**   END;\n**\n** The returned pointer is cached as part of the foreign key object. It\n** is eventually freed along with the rest of the foreign key object by \n** sqlite3FkDelete().\n*/\nstatic Trigger *fkActionTrigger(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  FKey *pFKey,                    /* Foreign key to get action for */\n  ExprList *pChanges              /* Change-list for UPDATE, NULL for DELETE */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int action;                     /* One of OE_None, OE_Cascade etc. */\n  Trigger *pTrigger;              /* Trigger definition to return */\n  int iAction = (pChanges!=0);    /* 1 for UPDATE, 0 for DELETE */\n\n  action = pFKey->aAction[iAction];\n  if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){\n    return 0;\n  }\n  pTrigger = pFKey->apTrigger[iAction];\n\n  if( action!=OE_None && !pTrigger ){\n    char const *zFrom;            /* Name of child table */\n    int nFrom;                    /* Length in bytes of zFrom */\n    Index *pIdx = 0;              /* Parent key index for this FK */\n    int *aiCol = 0;               /* child table cols -> parent key cols */\n    TriggerStep *pStep = 0;        /* First (only) step of trigger program */\n    Expr *pWhere = 0;             /* WHERE clause of trigger step */\n    ExprList *pList = 0;          /* Changes list if ON UPDATE CASCADE */\n    Select *pSelect = 0;          /* If RESTRICT, \"SELECT RAISE(...)\" */\n    int i;                        /* Iterator variable */\n    Expr *pWhen = 0;              /* WHEN clause for the trigger */\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;\n    assert( aiCol || pFKey->nCol==1 );\n\n    for(i=0; i<pFKey->nCol; i++){\n      Token tOld = { \"old\", 3 };  /* Literal \"old\" token */\n      Token tNew = { \"new\", 3 };  /* Literal \"new\" token */\n      Token tFromCol;             /* Name of column in child table */\n      Token tToCol;               /* Name of column in parent table */\n      int iFromCol;               /* Idx of column in child table */\n      Expr *pEq;                  /* tFromCol = OLD.tToCol */\n\n      iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n      assert( iFromCol>=0 );\n      assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n      sqlite3TokenInit(&tToCol,\n                   pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);\n      sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zName);\n\n      /* Create the expression \"OLD.zToCol = zFromCol\". It is important\n      ** that the \"OLD.zToCol\" term is on the LHS of the = operator, so\n      ** that the affinity and collation sequence associated with the\n      ** parent table are used for the comparison. */\n      pEq = sqlite3PExpr(pParse, TK_EQ,\n          sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n          sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0)\n      );\n      pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n\n      /* For ON UPDATE, construct the next term of the WHEN clause.\n      ** The final WHEN clause will be like this:\n      **\n      **    WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)\n      */\n      if( pChanges ){\n        pEq = sqlite3PExpr(pParse, TK_IS,\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0))\n            );\n        pWhen = sqlite3ExprAnd(db, pWhen, pEq);\n      }\n  \n      if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){\n        Expr *pNew;\n        if( action==OE_Cascade ){\n          pNew = sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));\n        }else if( action==OE_SetDflt ){\n          Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;\n          if( pDflt ){\n            pNew = sqlite3ExprDup(db, pDflt, 0);\n          }else{\n            pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n          }\n        }else{\n          pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n        }\n        pList = sqlite3ExprListAppend(pParse, pList, pNew);\n        sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);\n      }\n    }\n    sqlite3DbFree(db, aiCol);\n\n    zFrom = pFKey->pFrom->zName;\n    nFrom = sqlite3Strlen30(zFrom);\n\n    if( action==OE_Restrict ){\n      Token tFrom;\n      Expr *pRaise; \n\n      tFrom.z = zFrom;\n      tFrom.n = nFrom;\n      pRaise = sqlite3Expr(db, TK_RAISE, \"FOREIGN KEY constraint failed\");\n      if( pRaise ){\n        pRaise->affinity = OE_Abort;\n      }\n      pSelect = sqlite3SelectNew(pParse, \n          sqlite3ExprListAppend(pParse, 0, pRaise),\n          sqlite3SrcListAppend(db, 0, &tFrom, 0),\n          pWhere,\n          0, 0, 0, 0, 0, 0\n      );\n      pWhere = 0;\n    }\n\n    /* Disable lookaside memory allocation */\n    db->lookaside.bDisable++;\n\n    pTrigger = (Trigger *)sqlite3DbMallocZero(db, \n        sizeof(Trigger) +         /* struct Trigger */\n        sizeof(TriggerStep) +     /* Single step in trigger program */\n        nFrom + 1                 /* Space for pStep->zTarget */\n    );\n    if( pTrigger ){\n      pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];\n      pStep->zTarget = (char *)&pStep[1];\n      memcpy((char *)pStep->zTarget, zFrom, nFrom);\n  \n      pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n      pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);\n      pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n      if( pWhen ){\n        pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0);\n        pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n      }\n    }\n\n    /* Re-enable the lookaside buffer, if it was disabled earlier. */\n    db->lookaside.bDisable--;\n\n    sqlite3ExprDelete(db, pWhere);\n    sqlite3ExprDelete(db, pWhen);\n    sqlite3ExprListDelete(db, pList);\n    sqlite3SelectDelete(db, pSelect);\n    if( db->mallocFailed==1 ){\n      fkTriggerDelete(db, pTrigger);\n      return 0;\n    }\n    assert( pStep!=0 );\n\n    switch( action ){\n      case OE_Restrict:\n        pStep->op = TK_SELECT; \n        break;\n      case OE_Cascade: \n        if( !pChanges ){ \n          pStep->op = TK_DELETE; \n          break; \n        }\n      default:\n        pStep->op = TK_UPDATE;\n    }\n    pStep->pTrig = pTrigger;\n    pTrigger->pSchema = pTab->pSchema;\n    pTrigger->pTabSchema = pTab->pSchema;\n    pFKey->apTrigger[iAction] = pTrigger;\n    pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);\n  }\n\n  return pTrigger;\n}\n\n/*\n** This function is called when deleting or updating a row to implement\n** any required CASCADE, SET NULL or SET DEFAULT actions.\n*/\nSQLITE_PRIVATE void sqlite3FkActions(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  ExprList *pChanges,             /* Change-list for UPDATE, NULL for DELETE */\n  int regOld,                     /* Address of array containing old row */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  /* If foreign-key support is enabled, iterate through all FKs that \n  ** refer to table pTab. If there is an action associated with the FK \n  ** for this operation (either update or delete), invoke the associated \n  ** trigger sub-program.  */\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *pFKey;                  /* Iterator variable */\n    for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n      if( aChange==0 || fkParentIsModified(pTab, pFKey, aChange, bChngRowid) ){\n        Trigger *pAct = fkActionTrigger(pParse, pTab, pFKey, pChanges);\n        if( pAct ){\n          sqlite3CodeRowTriggerDirect(pParse, pAct, pTab, regOld, OE_Abort, 0);\n        }\n      }\n    }\n  }\n}\n\n#endif /* ifndef SQLITE_OMIT_TRIGGER */\n\n/*\n** Free all memory associated with foreign key definitions attached to\n** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash\n** hash table.\n*/\nSQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){\n  FKey *pFKey;                    /* Iterator variable */\n  FKey *pNext;                    /* Copy of pFKey->pNextFrom */\n\n  assert( db==0 || IsVirtual(pTab)\n         || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){\n\n    /* Remove the FK from the fkeyHash hash table. */\n    if( !db || db->pnBytesFreed==0 ){\n      if( pFKey->pPrevTo ){\n        pFKey->pPrevTo->pNextTo = pFKey->pNextTo;\n      }else{\n        void *p = (void *)pFKey->pNextTo;\n        const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo);\n        sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, p);\n      }\n      if( pFKey->pNextTo ){\n        pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;\n      }\n    }\n\n    /* EV: R-30323-21917 Each foreign key constraint in SQLite is\n    ** classified as either immediate or deferred.\n    */\n    assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );\n\n    /* Delete any triggers created to implement actions for this FK. */\n#ifndef SQLITE_OMIT_TRIGGER\n    fkTriggerDelete(db, pFKey->apTrigger[0]);\n    fkTriggerDelete(db, pFKey->apTrigger[1]);\n#endif\n\n    pNext = pFKey->pNextFrom;\n    sqlite3DbFree(db, pFKey);\n  }\n}\n#endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n/************** End of fkey.c ************************************************/\n/************** Begin file insert.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle INSERT statements in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Generate code that will \n**\n**   (1) acquire a lock for table pTab then\n**   (2) open pTab as cursor iCur.\n**\n** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index\n** for that table that is actually opened.\n*/\nSQLITE_PRIVATE void sqlite3OpenTable(\n  Parse *pParse,  /* Generate code into this VDBE */\n  int iCur,       /* The cursor number of the table */\n  int iDb,        /* The database index in sqlite3.aDb[] */\n  Table *pTab,    /* The table to be opened */\n  int opcode      /* OP_OpenRead or OP_OpenWrite */\n){\n  Vdbe *v;\n  assert( !IsVirtual(pTab) );\n  v = sqlite3GetVdbe(pParse);\n  assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );\n  sqlite3TableLock(pParse, iDb, pTab->tnum, \n                   (opcode==OP_OpenWrite)?1:0, pTab->zName);\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }else{\n    Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->tnum==pTab->tnum );\n    sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }\n}\n\n/*\n** Return a pointer to the column affinity string associated with index\n** pIdx. A column affinity string has one character for each column in \n** the table, according to the affinity of the column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'F'            REAL\n**\n** An extra 'D' is appended to the end of the string to cover the\n** rowid that appears as the last column in every index.\n**\n** Memory for the buffer containing the column index affinity string\n** is managed along with the rest of the Index structure. It will be\n** released when sqlite3DeleteIndex() is called.\n*/\nSQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){\n  if( !pIdx->zColAff ){\n    /* The first time a column affinity string for a particular index is\n    ** required, it is allocated and populated here. It is then stored as\n    ** a member of the Index structure for subsequent use.\n    **\n    ** The column affinity string will eventually be deleted by\n    ** sqliteDeleteIndex() when the Index structure itself is cleaned\n    ** up.\n    */\n    int n;\n    Table *pTab = pIdx->pTable;\n    pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);\n    if( !pIdx->zColAff ){\n      sqlite3OomFault(db);\n      return 0;\n    }\n    for(n=0; n<pIdx->nColumn; n++){\n      i16 x = pIdx->aiColumn[n];\n      if( x>=0 ){\n        pIdx->zColAff[n] = pTab->aCol[x].affinity;\n      }else if( x==XN_ROWID ){\n        pIdx->zColAff[n] = SQLITE_AFF_INTEGER;\n      }else{\n        char aff;\n        assert( x==XN_EXPR );\n        assert( pIdx->aColExpr!=0 );\n        aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);\n        if( aff==0 ) aff = SQLITE_AFF_BLOB;\n        pIdx->zColAff[n] = aff;\n      }\n    }\n    pIdx->zColAff[n] = 0;\n  }\n \n  return pIdx->zColAff;\n}\n\n/*\n** Compute the affinity string for table pTab, if it has not already been\n** computed.  As an optimization, omit trailing SQLITE_AFF_BLOB affinities.\n**\n** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and\n** if iReg>0 then code an OP_Affinity opcode that will set the affinities\n** for register iReg and following.  Or if affinities exists and iReg==0,\n** then just set the P4 operand of the previous opcode (which should  be\n** an OP_MakeRecord) to the affinity string.\n**\n** A column affinity string has one character per column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'E'            REAL\n*/\nSQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){\n  int i;\n  char *zColAff = pTab->zColAff;\n  if( zColAff==0 ){\n    sqlite3 *db = sqlite3VdbeDb(v);\n    zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);\n    if( !zColAff ){\n      sqlite3OomFault(db);\n      return;\n    }\n\n    for(i=0; i<pTab->nCol; i++){\n      zColAff[i] = pTab->aCol[i].affinity;\n    }\n    do{\n      zColAff[i--] = 0;\n    }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );\n    pTab->zColAff = zColAff;\n  }\n  i = sqlite3Strlen30(zColAff);\n  if( i ){\n    if( iReg ){\n      sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);\n    }else{\n      sqlite3VdbeChangeP4(v, -1, zColAff, i);\n    }\n  }\n}\n\n/*\n** Return non-zero if the table pTab in database iDb or any of its indices\n** have been opened at any point in the VDBE program. This is used to see if \n** a statement of the form  \"INSERT INTO <iDb, pTab> SELECT ...\" can \n** run without using a temporary table for the results of the SELECT. \n*/\nstatic int readsTable(Parse *p, int iDb, Table *pTab){\n  Vdbe *v = sqlite3GetVdbe(p);\n  int i;\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  VTable *pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p->db, pTab) : 0;\n#endif\n\n  for(i=1; i<iEnd; i++){\n    VdbeOp *pOp = sqlite3VdbeGetOp(v, i);\n    assert( pOp!=0 );\n    if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){\n      Index *pIndex;\n      int tnum = pOp->p2;\n      if( tnum==pTab->tnum ){\n        return 1;\n      }\n      for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n        if( tnum==pIndex->tnum ){\n          return 1;\n        }\n      }\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( pOp->opcode==OP_VOpen && pOp->p4.pVtab==pVTab ){\n      assert( pOp->p4.pVtab!=0 );\n      assert( pOp->p4type==P4_VTAB );\n      return 1;\n    }\n#endif\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/*\n** Locate or create an AutoincInfo structure associated with table pTab\n** which is in database iDb.  Return the register number for the register\n** that holds the maximum rowid.  Return zero if pTab is not an AUTOINCREMENT\n** table.  (Also return zero when doing a VACUUM since we do not want to\n** update the AUTOINCREMENT counters during a VACUUM.)\n**\n** There is at most one AutoincInfo structure per table even if the\n** same table is autoincremented multiple times due to inserts within\n** triggers.  A new AutoincInfo structure is created if this is the\n** first use of table pTab.  On 2nd and subsequent uses, the original\n** AutoincInfo structure is used.\n**\n** Three memory locations are allocated:\n**\n**   (1)  Register to hold the name of the pTab table.\n**   (2)  Register to hold the maximum ROWID of pTab.\n**   (3)  Register to hold the rowid in sqlite_sequence of pTab\n**\n** The 2nd register is the one that is returned.  That is all the\n** insert routine needs to know about.\n*/\nstatic int autoIncBegin(\n  Parse *pParse,      /* Parsing context */\n  int iDb,            /* Index of the database holding pTab */\n  Table *pTab         /* The table we are writing to */\n){\n  int memId = 0;      /* Register holding maximum rowid */\n  if( (pTab->tabFlags & TF_Autoincrement)!=0\n   && (pParse->db->mDbFlags & DBFLAG_Vacuum)==0\n  ){\n    Parse *pToplevel = sqlite3ParseToplevel(pParse);\n    AutoincInfo *pInfo;\n\n    pInfo = pToplevel->pAinc;\n    while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }\n    if( pInfo==0 ){\n      pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo));\n      if( pInfo==0 ) return 0;\n      pInfo->pNext = pToplevel->pAinc;\n      pToplevel->pAinc = pInfo;\n      pInfo->pTab = pTab;\n      pInfo->iDb = iDb;\n      pToplevel->nMem++;                  /* Register to hold name of table */\n      pInfo->regCtr = ++pToplevel->nMem;  /* Max rowid register */\n      pToplevel->nMem++;                  /* Rowid in sqlite_sequence */\n    }\n    memId = pInfo->regCtr;\n  }\n  return memId;\n}\n\n/*\n** This routine generates code that will initialize all of the\n** register used by the autoincrement tracker.  \n*/\nSQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse){\n  AutoincInfo *p;            /* Information about an AUTOINCREMENT */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  Db *pDb;                   /* Database only autoinc table */\n  int memId;                 /* Register holding max rowid */\n  Vdbe *v = pParse->pVdbe;   /* VDBE under construction */\n\n  /* This routine is never called during trigger-generation.  It is\n  ** only called from the top-level */\n  assert( pParse->pTriggerTab==0 );\n  assert( sqlite3IsToplevel(pParse) );\n\n  assert( v );   /* We failed long ago if this is not so */\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoInc[] = {\n      /* 0  */ {OP_Null,    0,  0, 0},\n      /* 1  */ {OP_Rewind,  0,  9, 0},\n      /* 2  */ {OP_Column,  0,  0, 0},\n      /* 3  */ {OP_Ne,      0,  7, 0},\n      /* 4  */ {OP_Rowid,   0,  0, 0},\n      /* 5  */ {OP_Column,  0,  1, 0},\n      /* 6  */ {OP_Goto,    0,  9, 0},\n      /* 7  */ {OP_Next,    0,  2, 0},\n      /* 8  */ {OP_Integer, 0,  0, 0},\n      /* 9  */ {OP_Close,   0,  0, 0} \n    };\n    VdbeOp *aOp;\n    pDb = &db->aDb[p->iDb];\n    memId = p->regCtr;\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);\n    sqlite3VdbeLoadString(v, memId-1, p->pTab->zName);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoInc), autoInc, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p2 = memId;\n    aOp[0].p3 = memId+1;\n    aOp[2].p3 = memId;\n    aOp[3].p1 = memId-1;\n    aOp[3].p3 = memId;\n    aOp[3].p5 = SQLITE_JUMPIFNULL;\n    aOp[4].p2 = memId+1;\n    aOp[5].p3 = memId;\n    aOp[8].p2 = memId;\n  }\n}\n\n/*\n** Update the maximum rowid for an autoincrement calculation.\n**\n** This routine should be called when the regRowid register holds a\n** new rowid that is about to be inserted.  If that new rowid is\n** larger than the maximum rowid in the memId memory cell, then the\n** memory cell is updated.\n*/\nstatic void autoIncStep(Parse *pParse, int memId, int regRowid){\n  if( memId>0 ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_MemMax, memId, regRowid);\n  }\n}\n\n/*\n** This routine generates the code needed to write autoincrement\n** maximum rowid values back into the sqlite_sequence register.\n** Every statement that might do an INSERT into an autoincrement\n** table (either directly or through triggers) needs to call this\n** routine just before the \"exit\" code.\n*/\nstatic SQLITE_NOINLINE void autoIncrementEnd(Parse *pParse){\n  AutoincInfo *p;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( v );\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoIncEnd[] = {\n      /* 0 */ {OP_NotNull,     0, 2, 0},\n      /* 1 */ {OP_NewRowid,    0, 0, 0},\n      /* 2 */ {OP_MakeRecord,  0, 2, 0},\n      /* 3 */ {OP_Insert,      0, 0, 0},\n      /* 4 */ {OP_Close,       0, 0, 0}\n    };\n    VdbeOp *aOp;\n    Db *pDb = &db->aDb[p->iDb];\n    int iRec;\n    int memId = p->regCtr;\n\n    iRec = sqlite3GetTempReg(pParse);\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoIncEnd), autoIncEnd, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p1 = memId+1;\n    aOp[1].p2 = memId+1;\n    aOp[2].p1 = memId-1;\n    aOp[2].p3 = iRec;\n    aOp[3].p2 = iRec;\n    aOp[3].p3 = memId+1;\n    aOp[3].p5 = OPFLAG_APPEND;\n    sqlite3ReleaseTempReg(pParse, iRec);\n  }\n}\nSQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse){\n  if( pParse->pAinc ) autoIncrementEnd(pParse);\n}\n#else\n/*\n** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines\n** above are all no-ops\n*/\n# define autoIncBegin(A,B,C) (0)\n# define autoIncStep(A,B,C)\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n\n/* Forward declaration */\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n);\n\n/*\n** This routine is called to handle SQL of the following forms:\n**\n**    insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...\n**    insert into TABLE (IDLIST) select\n**    insert into TABLE (IDLIST) default values\n**\n** The IDLIST following the table name is always optional.  If omitted,\n** then a list of all (non-hidden) columns for the table is substituted.\n** The IDLIST appears in the pColumn parameter.  pColumn is NULL if IDLIST\n** is omitted.\n**\n** For the pSelect parameter holds the values to be inserted for the\n** first two forms shown above.  A VALUES clause is really just short-hand\n** for a SELECT statement that omits the FROM clause and everything else\n** that follows.  If the pSelect parameter is NULL, that means that the\n** DEFAULT VALUES form of the INSERT statement is intended.\n**\n** The code generated follows one of four templates.  For a simple\n** insert with data coming from a single-row VALUES clause, the code executes\n** once straight down through.  Pseudo-code follows (we call this\n** the \"1st template\"):\n**\n**         open write cursor to <table> and its indices\n**         put VALUES clause expressions into registers\n**         write the resulting record into <table>\n**         cleanup\n**\n** The three remaining templates assume the statement is of the form\n**\n**   INSERT INTO <table> SELECT ...\n**\n** If the SELECT clause is of the restricted form \"SELECT * FROM <table2>\" -\n** in other words if the SELECT pulls all columns from a single table\n** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and\n** if <table2> and <table1> are distinct tables but have identical\n** schemas, including all the same indices, then a special optimization\n** is invoked that copies raw records from <table2> over to <table1>.\n** See the xferOptimization() function for the implementation of this\n** template.  This is the 2nd template.\n**\n**         open a write cursor to <table>\n**         open read cursor on <table2>\n**         transfer all records in <table2> over to <table>\n**         close cursors\n**         foreach index on <table>\n**           open a write cursor on the <table> index\n**           open a read cursor on the corresponding <table2> index\n**           transfer all records from the read to the write cursors\n**           close cursors\n**         end foreach\n**\n** The 3rd template is for when the second template does not apply\n** and the SELECT clause does not read from <table> at any time.\n** The generated code follows this template:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the rows in the SELECT\n**           load values into registers R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end-coroutine X\n**      B: open write cursor to <table> and its indices\n**      C: yield X, at EOF goto D\n**         insert the select result into <table> from R..R+n\n**         goto C\n**      D: cleanup\n**\n** The 4th template is used if the insert statement takes its\n** values from a SELECT but the data is being inserted into a table\n** that is also read as part of the SELECT.  In the third form,\n** we have to use an intermediate table to store the results of\n** the select.  The template is like this:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the tables in the SELECT\n**           load value into register R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end co-routine R\n**      B: open temp table\n**      L: yield X, at EOF goto M\n**         insert row from R..R+n into temp table\n**         goto L\n**      M: open write cursor to <table> and its indices\n**         rewind temp table\n**      C: loop over rows of intermediate table\n**           transfer values form intermediate table into <table>\n**         end loop\n**      D: cleanup\n*/\nSQLITE_PRIVATE void sqlite3Insert(\n  Parse *pParse,        /* Parser context */\n  SrcList *pTabList,    /* Name of table into which we are inserting */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  IdList *pColumn,      /* Column names corresponding to IDLIST. */\n  int onError           /* How to handle constraint errors */\n){\n  sqlite3 *db;          /* The main database structure */\n  Table *pTab;          /* The table to insert into.  aka TABLE */\n  int i, j;             /* Loop counters */\n  Vdbe *v;              /* Generate code into this virtual machine */\n  Index *pIdx;          /* For looping over indices of the table */\n  int nColumn;          /* Number of columns in the data */\n  int nHidden = 0;      /* Number of hidden columns if TABLE is virtual */\n  int iDataCur = 0;     /* VDBE cursor that is the main data repository */\n  int iIdxCur = 0;      /* First index cursor */\n  int ipkColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */\n  int endOfLoop;        /* Label for the end of the insertion loop */\n  int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */\n  int addrInsTop = 0;   /* Jump to label \"D\" */\n  int addrCont = 0;     /* Top of insert loop. Label \"C\" in templates 3 and 4 */\n  SelectDest dest;      /* Destination for SELECT on rhs of INSERT */\n  int iDb;              /* Index of database holding TABLE */\n  u8 useTempTable = 0;  /* Store SELECT results in intermediate table */\n  u8 appendFlag = 0;    /* True if the insert is likely to be an append */\n  u8 withoutRowid;      /* 0 for normal table.  1 for WITHOUT ROWID table */\n  u8 bIdListInOrder;    /* True if IDLIST is in table order */\n  ExprList *pList = 0;  /* List of VALUES() to be inserted  */\n\n  /* Register allocations */\n  int regFromSelect = 0;/* Base register for data coming from SELECT */\n  int regAutoinc = 0;   /* Register holding the AUTOINCREMENT counter */\n  int regRowCount = 0;  /* Memory cell used for the row counter */\n  int regIns;           /* Block of regs holding rowid+data being inserted */\n  int regRowid;         /* registers holding insert rowid */\n  int regData;          /* register holding first column to insert */\n  int *aRegIdx = 0;     /* One register allocated to each index */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                 /* True if attempting to insert into a view */\n  Trigger *pTrigger;          /* List of triggers on pTab, if required */\n  int tmask;                  /* Mask of trigger times */\n#endif\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto insert_cleanup;\n  }\n  dest.iSDParm = 0;  /* Suppress a harmless compiler warning */\n\n  /* If the Select object is really just a simple VALUES() list with a\n  ** single row (the common case) then keep that one row of values\n  ** and discard the other (unused) parts of the pSelect object\n  */\n  if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){\n    pList = pSelect->pEList;\n    pSelect->pEList = 0;\n    sqlite3SelectDelete(db, pSelect);\n    pSelect = 0;\n  }\n\n  /* Locate the table into which we will be inserting new information.\n  */\n  assert( pTabList->nSrc==1 );\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ){\n    goto insert_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0,\n                       db->aDb[iDb].zDbSName) ){\n    goto insert_cleanup;\n  }\n  withoutRowid = !HasRowid(pTab);\n\n  /* Figure out if we have any triggers and if the table being\n  ** inserted into is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define tmask 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n  assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) );\n\n  /* If pTab is really a view, make sure it has been initialized.\n  ** ViewGetColumnNames() is a no-op if pTab is not a view.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto insert_cleanup;\n  }\n\n  /* Cannot insert into a read-only table.\n  */\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto insert_cleanup;\n  }\n\n  /* Allocate a VDBE\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto insert_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, pSelect || pTrigger, iDb);\n\n#ifndef SQLITE_OMIT_XFER_OPT\n  /* If the statement is of the form\n  **\n  **       INSERT INTO <table1> SELECT * FROM <table2>;\n  **\n  ** Then special optimizations can be applied that make the transfer\n  ** very fast and which reduce fragmentation of indices.\n  **\n  ** This is the 2nd template.\n  */\n  if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){\n    assert( !pTrigger );\n    assert( pList==0 );\n    goto insert_end;\n  }\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n  /* If this is an AUTOINCREMENT table, look up the sequence number in the\n  ** sqlite_sequence table and store it in memory cell regAutoinc.\n  */\n  regAutoinc = autoIncBegin(pParse, iDb, pTab);\n\n  /* Allocate registers for holding the rowid of the new row,\n  ** the content of the new row, and the assembled row record.\n  */\n  regRowid = regIns = pParse->nMem+1;\n  pParse->nMem += pTab->nCol + 1;\n  if( IsVirtual(pTab) ){\n    regRowid++;\n    pParse->nMem++;\n  }\n  regData = regRowid+1;\n\n  /* If the INSERT statement included an IDLIST term, then make sure\n  ** all elements of the IDLIST really are columns of the table and \n  ** remember the column indices.\n  **\n  ** If the table has an INTEGER PRIMARY KEY column and that column\n  ** is named in the IDLIST, then record in the ipkColumn variable\n  ** the index into IDLIST of the primary key column.  ipkColumn is\n  ** the index of the primary key as it appears in IDLIST, not as\n  ** is appears in the original table.  (The index of the INTEGER\n  ** PRIMARY KEY in the original table is pTab->iPKey.)\n  */\n  bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;\n  if( pColumn ){\n    for(i=0; i<pColumn->nId; i++){\n      pColumn->a[i].idx = -1;\n    }\n    for(i=0; i<pColumn->nId; i++){\n      for(j=0; j<pTab->nCol; j++){\n        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){\n          pColumn->a[i].idx = j;\n          if( i!=j ) bIdListInOrder = 0;\n          if( j==pTab->iPKey ){\n            ipkColumn = i;  assert( !withoutRowid );\n          }\n          break;\n        }\n      }\n      if( j>=pTab->nCol ){\n        if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){\n          ipkColumn = i;\n          bIdListInOrder = 0;\n        }else{\n          sqlite3ErrorMsg(pParse, \"table %S has no column named %s\",\n              pTabList, 0, pColumn->a[i].zName);\n          pParse->checkSchema = 1;\n          goto insert_cleanup;\n        }\n      }\n    }\n  }\n\n  /* Figure out how many columns of data are supplied.  If the data\n  ** is coming from a SELECT statement, then generate a co-routine that\n  ** produces a single row of the SELECT on each invocation.  The\n  ** co-routine is the common header to the 3rd and 4th templates.\n  */\n  if( pSelect ){\n    /* Data is coming from a SELECT or from a multi-row VALUES clause.\n    ** Generate a co-routine to run the SELECT. */\n    int regYield;       /* Register holding co-routine entry-point */\n    int addrTop;        /* Top of the co-routine */\n    int rc;             /* Result code */\n\n    regYield = ++pParse->nMem;\n    addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n    dest.iSdst = bIdListInOrder ? regData : 0;\n    dest.nSdst = pTab->nCol;\n    rc = sqlite3Select(pParse, pSelect, &dest);\n    regFromSelect = dest.iSdst;\n    if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;\n    sqlite3VdbeEndCoroutine(v, regYield);\n    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */\n    assert( pSelect->pEList );\n    nColumn = pSelect->pEList->nExpr;\n\n    /* Set useTempTable to TRUE if the result of the SELECT statement\n    ** should be written into a temporary table (template 4).  Set to\n    ** FALSE if each output row of the SELECT can be written directly into\n    ** the destination table (template 3).\n    **\n    ** A temp table must be used if the table being updated is also one\n    ** of the tables being read by the SELECT statement.  Also use a \n    ** temp table in the case of row triggers.\n    */\n    if( pTrigger || readsTable(pParse, iDb, pTab) ){\n      useTempTable = 1;\n    }\n\n    if( useTempTable ){\n      /* Invoke the coroutine to extract information from the SELECT\n      ** and add it to a transient table srcTab.  The code generated\n      ** here is from the 4th template:\n      **\n      **      B: open temp table\n      **      L: yield X, goto M at EOF\n      **         insert row from R..R+n into temp table\n      **         goto L\n      **      M: ...\n      */\n      int regRec;          /* Register to hold packed record */\n      int regTempRowid;    /* Register to hold temp table ROWID */\n      int addrL;           /* Label \"L\" */\n\n      srcTab = pParse->nTab++;\n      regRec = sqlite3GetTempReg(pParse);\n      regTempRowid = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn);\n      addrL = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid);\n      sqlite3VdbeGoto(v, addrL);\n      sqlite3VdbeJumpHere(v, addrL);\n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempReg(pParse, regTempRowid);\n    }\n  }else{\n    /* This is the case if the data for the INSERT is coming from a \n    ** single-row VALUES clause\n    */\n    NameContext sNC;\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    srcTab = -1;\n    assert( useTempTable==0 );\n    if( pList ){\n      nColumn = pList->nExpr;\n      if( sqlite3ResolveExprListNames(&sNC, pList) ){\n        goto insert_cleanup;\n      }\n    }else{\n      nColumn = 0;\n    }\n  }\n\n  /* If there is no IDLIST term but the table has an integer primary\n  ** key, the set the ipkColumn variable to the integer primary key \n  ** column index in the original table definition.\n  */\n  if( pColumn==0 && nColumn>0 ){\n    ipkColumn = pTab->iPKey;\n  }\n\n  /* Make sure the number of columns in the source data matches the number\n  ** of columns to be inserted into the table.\n  */\n  for(i=0; i<pTab->nCol; i++){\n    nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);\n  }\n  if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){\n    sqlite3ErrorMsg(pParse, \n       \"table %S has %d columns but %d values were supplied\",\n       pTabList, 0, pTab->nCol-nHidden, nColumn);\n    goto insert_cleanup;\n  }\n  if( pColumn!=0 && nColumn!=pColumn->nId ){\n    sqlite3ErrorMsg(pParse, \"%d values for %d columns\", nColumn, pColumn->nId);\n    goto insert_cleanup;\n  }\n    \n  /* Initialize the count of rows to be inserted\n  */\n  if( db->flags & SQLITE_CountRows ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  /* If this is not a view, open the table and and all indices */\n  if( !isView ){\n    int nIdx;\n    nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, -1, 0,\n                                      &iDataCur, &iIdxCur);\n    aRegIdx = sqlite3DbMallocRawNN(db, sizeof(int)*(nIdx+1));\n    if( aRegIdx==0 ){\n      goto insert_cleanup;\n    }\n    for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){\n      assert( pIdx );\n      aRegIdx[i] = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }\n  }\n\n  /* This is the top of the main insertion loop */\n  if( useTempTable ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 4):\n    **\n    **         rewind temp table, if empty goto D\n    **      C: loop over rows of intermediate table\n    **           transfer values form intermediate table into <table>\n    **         end loop\n    **      D: ...\n    */\n    addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab); VdbeCoverage(v);\n    addrCont = sqlite3VdbeCurrentAddr(v);\n  }else if( pSelect ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 3):\n    **\n    **      C: yield X, at EOF goto D\n    **         insert the select result into <table> from R..R+n\n    **         goto C\n    **      D: ...\n    */\n    addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n    VdbeCoverage(v);\n  }\n\n  /* Run the BEFORE and INSTEAD OF triggers, if there are any\n  */\n  endOfLoop = sqlite3VdbeMakeLabel(v);\n  if( tmask & TRIGGER_BEFORE ){\n    int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);\n\n    /* build the NEW.* reference row.  Note that if there is an INTEGER\n    ** PRIMARY KEY into which a NULL is being inserted, that NULL will be\n    ** translated into a unique ID for the row.  But on a BEFORE trigger,\n    ** we do not know what the unique ID will be (because the insert has\n    ** not happened yet) so we substitute a rowid of -1\n    */\n    if( ipkColumn<0 ){\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n    }else{\n      int addr1;\n      assert( !withoutRowid );\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regCols);\n      }else{\n        assert( pSelect==0 );  /* Otherwise useTempTable is true */\n        sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols);\n      }\n      addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n      sqlite3VdbeJumpHere(v, addr1);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v);\n    }\n\n    /* Cannot have triggers on a virtual table. If it were possible,\n    ** this block would have to account for hidden column.\n    */\n    assert( !IsVirtual(pTab) );\n\n    /* Create the new column data\n    */\n    for(i=j=0; i<pTab->nCol; i++){\n      if( pColumn ){\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)\n            || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); \n      }else{\n        assert( pSelect==0 ); /* Otherwise useTempTable is true */\n        sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);\n      }\n      if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;\n    }\n\n    /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,\n    ** do not attempt any conversions before assembling the record.\n    ** If this is a real table, attempt conversions as required by the\n    ** table column affinities.\n    */\n    if( !isView ){\n      sqlite3TableAffinity(v, pTab, regCols+1);\n    }\n\n    /* Fire BEFORE or INSTEAD OF triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE, \n        pTab, regCols-pTab->nCol-1, onError, endOfLoop);\n\n    sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);\n  }\n\n  /* Compute the content of the next row to insert into a range of\n  ** registers beginning at regIns.\n  */\n  if( !isView ){\n    if( IsVirtual(pTab) ){\n      /* The row that the VUpdate opcode will delete: none */\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);\n    }\n    if( ipkColumn>=0 ){\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);\n      }else if( pSelect ){\n        sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);\n      }else{\n        VdbeOp *pOp;\n        sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);\n        pOp = sqlite3VdbeGetOp(v, -1);\n        if( ALWAYS(pOp) && pOp->opcode==OP_Null && !IsVirtual(pTab) ){\n          appendFlag = 1;\n          pOp->opcode = OP_NewRowid;\n          pOp->p1 = iDataCur;\n          pOp->p2 = regRowid;\n          pOp->p3 = regAutoinc;\n        }\n      }\n      /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid\n      ** to generate a unique primary key value.\n      */\n      if( !appendFlag ){\n        int addr1;\n        if( !IsVirtual(pTab) ){\n          addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); VdbeCoverage(v);\n          sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n          sqlite3VdbeJumpHere(v, addr1);\n        }else{\n          addr1 = sqlite3VdbeCurrentAddr(v);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, addr1+2); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); VdbeCoverage(v);\n      }\n    }else if( IsVirtual(pTab) || withoutRowid ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n      appendFlag = 1;\n    }\n    autoIncStep(pParse, regAutoinc, regRowid);\n\n    /* Compute data for all columns of the new entry, beginning\n    ** with the first column.\n    */\n    nHidden = 0;\n    for(i=0; i<pTab->nCol; i++){\n      int iRegStore = regRowid+1+i;\n      if( i==pTab->iPKey ){\n        /* The value of the INTEGER PRIMARY KEY column is always a NULL.\n        ** Whenever this column is read, the rowid will be substituted\n        ** in its place.  Hence, fill this column with a NULL to avoid\n        ** taking up data space with information that will never be used.\n        ** As there may be shallow copies of this value, make it a soft-NULL */\n        sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);\n        continue;\n      }\n      if( pColumn==0 ){\n        if( IsHiddenColumn(&pTab->aCol[i]) ){\n          j = -1;\n          nHidden++;\n        }else{\n          j = i - nHidden;\n        }\n      }else{\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){\n        sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); \n      }else if( pSelect ){\n        if( regFromSelect!=regData ){\n          sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);\n        }\n      }else{\n        sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);\n      }\n    }\n\n    /* Generate code to check constraints and generate index keys and\n    ** do the insertion.\n    */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab->nCol+2, regIns, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n      sqlite3MayAbort(pParse);\n    }else\n#endif\n    {\n      int isReplace;    /* Set to true if constraints may cause a replace */\n      int bUseSeek;     /* True to use OPFLAG_SEEKRESULT */\n      sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0\n      );\n      sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);\n\n      /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE\n      ** constraints or (b) there are no triggers and this table is not a\n      ** parent table in a foreign key constraint. It is safe to set the\n      ** flag in the second case as if any REPLACE constraint is hit, an\n      ** OP_Delete or OP_IdxDelete instruction will be executed on each \n      ** cursor that is disturbed. And these instructions both clear the\n      ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT\n      ** functionality.  */\n      bUseSeek = (isReplace==0 || (pTrigger==0 &&\n          ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0)\n      ));\n      sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,\n          regIns, aRegIdx, 0, appendFlag, bUseSeek\n      );\n    }\n  }\n\n  /* Update the count of rows that are inserted\n  */\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  if( pTrigger ){\n    /* Code AFTER triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, \n        pTab, regData-2-pTab->nCol, onError, endOfLoop);\n  }\n\n  /* The bottom of the main insertion loop, if the data source\n  ** is a SELECT statement.\n  */\n  sqlite3VdbeResolveLabel(v, endOfLoop);\n  if( useTempTable ){\n    sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n    sqlite3VdbeAddOp1(v, OP_Close, srcTab);\n  }else if( pSelect ){\n    sqlite3VdbeGoto(v, addrCont);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n  }\n\ninsert_end:\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows inserted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows inserted\", SQLITE_STATIC);\n  }\n\ninsert_cleanup:\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3IdListDelete(db, pColumn);\n  sqlite3DbFree(db, aRegIdx);\n}\n\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n#ifdef tmask\n #undef tmask\n#endif\n\n/*\n** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()\n*/\n#define CKCNSTRNT_COLUMN   0x01    /* CHECK constraint uses a changing column */\n#define CKCNSTRNT_ROWID    0x02    /* CHECK constraint references the ROWID */\n\n/* This is the Walker callback from checkConstraintUnchanged().  Set\n** bit 0x01 of pWalker->eCode if\n** pWalker->eCode to 0 if this expression node references any of the\n** columns that are being modifed by an UPDATE statement.\n*/\nstatic int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN ){\n    assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );\n    if( pExpr->iColumn>=0 ){\n      if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){\n        pWalker->eCode |= CKCNSTRNT_COLUMN;\n      }\n    }else{\n      pWalker->eCode |= CKCNSTRNT_ROWID;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** pExpr is a CHECK constraint on a row that is being UPDATE-ed.  The\n** only columns that are modified by the UPDATE are those for which\n** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.\n**\n** Return true if CHECK constraint pExpr does not use any of the\n** changing columns (or the rowid if it is changing).  In other words,\n** return true if this CHECK constraint can be skipped when validating\n** the new row in the UPDATE statement.\n*/\nstatic int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 0;\n  w.xExprCallback = checkConstraintExprNode;\n  w.u.aiCol = aiChng;\n  sqlite3WalkExpr(&w, pExpr);\n  if( !chngRowid ){\n    testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 );\n    w.eCode &= ~CKCNSTRNT_ROWID;\n  }\n  testcase( w.eCode==0 );\n  testcase( w.eCode==CKCNSTRNT_COLUMN );\n  testcase( w.eCode==CKCNSTRNT_ROWID );\n  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );\n  return !w.eCode;\n}\n\n/*\n** Generate code to do constraint checks prior to an INSERT or an UPDATE\n** on table pTab.\n**\n** The regNewData parameter is the first register in a range that contains\n** the data to be inserted or the data after the update.  There will be\n** pTab->nCol+1 registers in this range.  The first register (the one\n** that regNewData points to) will contain the new rowid, or NULL in the\n** case of a WITHOUT ROWID table.  The second register in the range will\n** contain the content of the first table column.  The third register will\n** contain the content of the second table column.  And so forth.\n**\n** The regOldData parameter is similar to regNewData except that it contains\n** the data prior to an UPDATE rather than afterwards.  regOldData is zero\n** for an INSERT.  This routine can distinguish between UPDATE and INSERT by\n** checking regOldData for zero.\n**\n** For an UPDATE, the pkChng boolean is true if the true primary key (the\n** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)\n** might be modified by the UPDATE.  If pkChng is false, then the key of\n** the iDataCur content table is guaranteed to be unchanged by the UPDATE.\n**\n** For an INSERT, the pkChng boolean indicates whether or not the rowid\n** was explicitly specified as part of the INSERT statement.  If pkChng\n** is zero, it means that the either rowid is computed automatically or\n** that the table is a WITHOUT ROWID table and has no rowid.  On an INSERT,\n** pkChng will only be true if the INSERT statement provides an integer\n** value for either the rowid column or its INTEGER PRIMARY KEY alias.\n**\n** The code generated by this routine will store new index entries into\n** registers identified by aRegIdx[].  No index entry is created for\n** indices where aRegIdx[i]==0.  The order of indices in aRegIdx[] is\n** the same as the order of indices on the linked list of indices\n** at pTab->pIndex.\n**\n** The caller must have already opened writeable cursors on the main\n** table and all applicable indices (that is to say, all indices for which\n** aRegIdx[] is not zero).  iDataCur is the cursor for the main table when\n** inserting or updating a rowid table, or the cursor for the PRIMARY KEY\n** index when operating on a WITHOUT ROWID table.  iIdxCur is the cursor\n** for the first index in the pTab->pIndex list.  Cursors for other indices\n** are at iIdxCur+N for the N-th element of the pTab->pIndex list.\n**\n** This routine also generates code to check constraints.  NOT NULL,\n** CHECK, and UNIQUE constraints are all checked.  If a constraint fails,\n** then the appropriate action is performed.  There are five possible\n** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.\n**\n**  Constraint type  Action       What Happens\n**  ---------------  ----------   ----------------------------------------\n**  any              ROLLBACK     The current transaction is rolled back and\n**                                sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.\n**\n**  any              ABORT        Back out changes from the current command\n**                                only (do not do a complete rollback) then\n**                                cause sqlite3_step() to return immediately\n**                                with SQLITE_CONSTRAINT.\n**\n**  any              FAIL         Sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.  The\n**                                transaction is not rolled back and any\n**                                changes to prior rows are retained.\n**\n**  any              IGNORE       The attempt in insert or update the current\n**                                row is skipped, without throwing an error.\n**                                Processing continues with the next row.\n**                                (There is an immediate jump to ignoreDest.)\n**\n**  NOT NULL         REPLACE      The NULL value is replace by the default\n**                                value for that column.  If the default value\n**                                is NULL, the action is the same as ABORT.\n**\n**  UNIQUE           REPLACE      The other row that conflicts with the row\n**                                being inserted is removed.\n**\n**  CHECK            REPLACE      Illegal.  The results in an exception.\n**\n** Which action to take is determined by the overrideError parameter.\n** Or if overrideError==OE_Default, then the pParse->onError parameter\n** is used.  Or if pParse->onError==OE_Default then the onError value\n** for the constraint is used.\n*/\nSQLITE_PRIVATE void sqlite3GenerateConstraintChecks(\n  Parse *pParse,       /* The parser context */\n  Table *pTab,         /* The table being inserted or updated */\n  int *aRegIdx,        /* Use register aRegIdx[i] for index i.  0 for unused */\n  int iDataCur,        /* Canonical data cursor (main table or PK index) */\n  int iIdxCur,         /* First index cursor */\n  int regNewData,      /* First register in a range holding values to insert */\n  int regOldData,      /* Previous content.  0 for INSERTs */\n  u8 pkChng,           /* Non-zero if the rowid or PRIMARY KEY changed */\n  u8 overrideError,    /* Override onError to this if not OE_Default */\n  int ignoreDest,      /* Jump to this label on an OE_Ignore resolution */\n  int *pbMayReplace,   /* OUT: Set to true if constraint may cause a replace */\n  int *aiChng          /* column i is unchanged if aiChng[i]<0 */\n){\n  Vdbe *v;             /* VDBE under constrution */\n  Index *pIdx;         /* Pointer to one of the indices */\n  Index *pPk = 0;      /* The PRIMARY KEY index */\n  sqlite3 *db;         /* Database connection */\n  int i;               /* loop counter */\n  int ix;              /* Index loop counter */\n  int nCol;            /* Number of columns */\n  int onError;         /* Conflict resolution strategy */\n  int addr1;           /* Address of jump instruction */\n  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */\n  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */\n  int ipkTop = 0;      /* Top of the rowid change constraint check */\n  int ipkBottom = 0;   /* Bottom of the rowid change constraint check */\n  u8 isUpdate;         /* True if this is an UPDATE operation */\n  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */\n\n  isUpdate = regOldData!=0;\n  db = pParse->db;\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  nCol = pTab->nCol;\n  \n  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for\n  ** normal rowid tables.  nPkField is the number of key fields in the \n  ** pPk index or 1 for a rowid table.  In other words, nPkField is the\n  ** number of fields in the true primary key of the table. */\n  if( HasRowid(pTab) ){\n    pPk = 0;\n    nPkField = 1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    nPkField = pPk->nKeyCol;\n  }\n\n  /* Record that this module has started */\n  VdbeModuleComment((v, \"BEGIN: GenCnstCks(%d,%d,%d,%d,%d)\",\n                     iDataCur, iIdxCur, regNewData, regOldData, pkChng));\n\n  /* Test all NOT NULL constraints.\n  */\n  for(i=0; i<nCol; i++){\n    if( i==pTab->iPKey ){\n      continue;        /* ROWID is never NULL */\n    }\n    if( aiChng && aiChng[i]<0 ){\n      /* Don't bother checking for NOT NULL on columns that do not change */\n      continue;\n    }\n    onError = pTab->aCol[i].notNull;\n    if( onError==OE_None ) continue;  /* This column is allowed to be NULL */\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){\n      onError = OE_Abort;\n    }\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Abort:\n        sqlite3MayAbort(pParse);\n        /* Fall through */\n      case OE_Rollback:\n      case OE_Fail: {\n        char *zMsg = sqlite3MPrintf(db, \"%s.%s\", pTab->zName,\n                                    pTab->aCol[i].zName);\n        sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,\n                          regNewData+1+i);\n        sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);\n        sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);\n        VdbeCoverage(v);\n        break;\n      }\n      case OE_Ignore: {\n        sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);\n        VdbeCoverage(v);\n        break;\n      }\n      default: {\n        assert( onError==OE_Replace );\n        addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i);\n           VdbeCoverage(v);\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);\n        sqlite3VdbeJumpHere(v, addr1);\n        break;\n      }\n    }\n  }\n\n  /* Test all CHECK constraints\n  */\n#ifndef SQLITE_OMIT_CHECK\n  if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n    ExprList *pCheck = pTab->pCheck;\n    pParse->iSelfTab = -(regNewData+1);\n    onError = overrideError!=OE_Default ? overrideError : OE_Abort;\n    for(i=0; i<pCheck->nExpr; i++){\n      int allOk;\n      Expr *pExpr = pCheck->a[i].pExpr;\n      if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;\n      allOk = sqlite3VdbeMakeLabel(v);\n      sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);\n      if( onError==OE_Ignore ){\n        sqlite3VdbeGoto(v, ignoreDest);\n      }else{\n        char *zName = pCheck->a[i].zName;\n        if( zName==0 ) zName = pTab->zName;\n        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,\n                              onError, zName, P4_TRANSIENT,\n                              P5_ConstraintCheck);\n      }\n      sqlite3VdbeResolveLabel(v, allOk);\n    }\n    pParse->iSelfTab = 0;\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* If rowid is changing, make sure the new rowid does not previously\n  ** exist in the table.\n  */\n  if( pkChng && pPk==0 ){\n    int addrRowidOk = sqlite3VdbeMakeLabel(v);\n\n    /* Figure out what action to take in case of a rowid collision */\n    onError = pTab->keyConf;\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    if( isUpdate ){\n      /* pkChng!=0 does not mean that the rowid has changed, only that\n      ** it might have changed.  Skip the conflict logic below if the rowid\n      ** is unchanged. */\n      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);\n      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      VdbeCoverage(v);\n    }\n\n    /* If the response to a rowid conflict is REPLACE but the response\n    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need\n    ** to defer the running of the rowid conflict checking until after\n    ** the UNIQUE constraints have run.\n    */\n    if( onError==OE_Replace && overrideError!=OE_Replace ){\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){\n          ipkTop = sqlite3VdbeAddOp0(v, OP_Goto);\n          break;\n        }\n      }\n    }\n\n    /* Check to see if the new rowid already exists in the table.  Skip\n    ** the following conflict logic if it does not. */\n    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);\n    VdbeCoverage(v);\n\n    /* Generate code that deals with a rowid collision */\n    switch( onError ){\n      default: {\n        onError = OE_Abort;\n        /* Fall thru into the next case */\n      }\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        sqlite3RowidConstraint(pParse, onError, pTab);\n        break;\n      }\n      case OE_Replace: {\n        /* If there are DELETE triggers on this table and the\n        ** recursive-triggers flag is set, call GenerateRowDelete() to\n        ** remove the conflicting row from the table. This will fire\n        ** the triggers and remove both the table and index b-tree entries.\n        **\n        ** Otherwise, if there are no triggers or the recursive-triggers\n        ** flag is not set, but the table has one or more indexes, call \n        ** GenerateRowIndexDelete(). This removes the index b-tree entries \n        ** only. The table b-tree entry will be replaced by the new entry \n        ** when it is inserted.  \n        **\n        ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,\n        ** also invoke MultiWrite() to indicate that this VDBE may require\n        ** statement rollback (if the statement is aborted after the delete\n        ** takes place). Earlier versions called sqlite3MultiWrite() regardless,\n        ** but being more selective here allows statements like:\n        **\n        **   REPLACE INTO t(rowid) VALUES($newrowid)\n        **\n        ** to run without a statement journal if there are no indexes on the\n        ** table.\n        */\n        Trigger *pTrigger = 0;\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){\n          sqlite3MultiWrite(pParse);\n          sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n                                   regNewData, 1, 0, OE_Replace, 1, -1);\n        }else{\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n          if( HasRowid(pTab) ){\n            /* This OP_Delete opcode fires the pre-update-hook only. It does\n            ** not modify the b-tree. It is more efficient to let the coming\n            ** OP_Insert replace the existing entry than it is to delete the\n            ** existing entry and then insert a new one. */\n            sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);\n            sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n          }\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n          if( pTab->pIndex ){\n            sqlite3MultiWrite(pParse);\n            sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);\n          }\n        }\n        seenReplace = 1;\n        break;\n      }\n      case OE_Ignore: {\n        /*assert( seenReplace==0 );*/\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n    }\n    sqlite3VdbeResolveLabel(v, addrRowidOk);\n    if( ipkTop ){\n      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);\n      sqlite3VdbeJumpHere(v, ipkTop);\n    }\n  }\n\n  /* Test all UNIQUE constraints by creating entries for each UNIQUE\n  ** index and making sure that duplicate entries do not already exist.\n  ** Compute the revised record entries for indices as we go.\n  **\n  ** This loop also handles the case of the PRIMARY KEY index for a\n  ** WITHOUT ROWID table.\n  */\n  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){\n    int regIdx;          /* Range of registers hold conent for pIdx */\n    int regR;            /* Range of registers holding conflicting PK */\n    int iThisCur;        /* Cursor for this UNIQUE index */\n    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */\n\n    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */\n    if( bAffinityDone==0 ){\n      sqlite3TableAffinity(v, pTab, regNewData+1);\n      bAffinityDone = 1;\n    }\n    iThisCur = iIdxCur+ix;\n    addrUniqueOk = sqlite3VdbeMakeLabel(v);\n\n    /* Skip partial indices for which the WHERE clause is not true */\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);\n      pParse->iSelfTab = -(regNewData+1);\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,\n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }\n\n    /* Create a record for this index entry as it should appear after\n    ** the insert or update.  Store that record in the aRegIdx[ix] register\n    */\n    regIdx = aRegIdx[ix]+1;\n    for(i=0; i<pIdx->nColumn; i++){\n      int iField = pIdx->aiColumn[i];\n      int x;\n      if( iField==XN_EXPR ){\n        pParse->iSelfTab = -(regNewData+1);\n        sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);\n        pParse->iSelfTab = 0;\n        VdbeComment((v, \"%s column %d\", pIdx->zName, i));\n      }else{\n        if( iField==XN_ROWID || iField==pTab->iPKey ){\n          x = regNewData;\n        }else{\n          x = iField + regNewData + 1;\n        }\n        sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);\n        VdbeComment((v, \"%s\", iField<0 ? \"rowid\" : pTab->aCol[iField].zName));\n      }\n    }\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);\n    VdbeComment((v, \"for %s\", pIdx->zName));\n#ifdef SQLITE_ENABLE_NULL_TRIM\n    if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);\n#endif\n\n    /* In an UPDATE operation, if this index is the PRIMARY KEY index \n    ** of a WITHOUT ROWID table and there has been no change the\n    ** primary key, then no collision is possible.  The collision detection\n    ** logic below can all be skipped. */\n    if( isUpdate && pPk==pIdx && pkChng==0 ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n\n    /* Find out what action to take in case there is a uniqueness conflict */\n    onError = pIdx->onError;\n    if( onError==OE_None ){ \n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;  /* pIdx is not a UNIQUE index */\n    }\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    /* Collision detection may be omitted if all of the following are true:\n    **   (1) The conflict resolution algorithm is REPLACE\n    **   (2) The table is a WITHOUT ROWID table\n    **   (3) There are no secondary indexes on the table\n    **   (4) No delete triggers need to be fired if there is a conflict\n    **   (5) No FK constraint counters need to be updated if a conflict occurs.\n    */ \n    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */\n     && pPk==pIdx                                   /* Condition 2 */\n     && onError==OE_Replace                         /* Condition 1 */\n     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */\n          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))\n     && ( 0==(db->flags&SQLITE_ForeignKeys) ||      /* Condition 5 */\n         (0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))\n    ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n\n    /* Check to see if the new index entry will be unique */\n    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,\n                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);\n\n    /* Generate code to handle collisions */\n    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);\n    if( isUpdate || onError==OE_Replace ){\n      if( HasRowid(pTab) ){\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR);\n        /* Conflict only if the rowid of the existing index entry\n        ** is different from old-rowid */\n        if( isUpdate ){\n          sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData);\n          sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n          VdbeCoverage(v);\n        }\n      }else{\n        int x;\n        /* Extract the PRIMARY KEY from the end of the index entry and\n        ** store it in registers regR..regR+nPk-1 */\n        if( pIdx!=pPk ){\n          for(i=0; i<pPk->nKeyCol; i++){\n            assert( pPk->aiColumn[i]>=0 );\n            x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);\n            sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);\n            VdbeComment((v, \"%s.%s\", pTab->zName,\n                         pTab->aCol[pPk->aiColumn[i]].zName));\n          }\n        }\n        if( isUpdate ){\n          /* If currently processing the PRIMARY KEY of a WITHOUT ROWID \n          ** table, only conflict if the new PRIMARY KEY values are actually\n          ** different from the old.\n          **\n          ** For a UNIQUE index, only conflict if the PRIMARY KEY values\n          ** of the matched index row are different from the original PRIMARY\n          ** KEY values of this row before the update.  */\n          int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;\n          int op = OP_Ne;\n          int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);\n  \n          for(i=0; i<pPk->nKeyCol; i++){\n            char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);\n            x = pPk->aiColumn[i];\n            assert( x>=0 );\n            if( i==(pPk->nKeyCol-1) ){\n              addrJump = addrUniqueOk;\n              op = OP_Eq;\n            }\n            sqlite3VdbeAddOp4(v, op, \n                regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ\n            );\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            VdbeCoverageIf(v, op==OP_Eq);\n            VdbeCoverageIf(v, op==OP_Ne);\n          }\n        }\n      }\n    }\n\n    /* Generate code that executes if the new index entry is not unique */\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        sqlite3UniqueConstraint(pParse, onError, pIdx);\n        break;\n      }\n      case OE_Ignore: {\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n      default: {\n        Trigger *pTrigger = 0;\n        assert( onError==OE_Replace );\n        sqlite3MultiWrite(pParse);\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n            regR, nPkField, 0, OE_Replace,\n            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);\n        seenReplace = 1;\n        break;\n      }\n    }\n    sqlite3VdbeResolveLabel(v, addrUniqueOk);\n    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);\n  }\n  if( ipkTop ){\n    sqlite3VdbeGoto(v, ipkTop+1);\n    sqlite3VdbeJumpHere(v, ipkBottom);\n  }\n  \n  *pbMayReplace = seenReplace;\n  VdbeModuleComment((v, \"END: GenCnstCks(%d)\", seenReplace));\n}\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n/*\n** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)\n** to be the number of columns in table pTab that must not be NULL-trimmed.\n**\n** Or if no columns of pTab may be NULL-trimmed, leave P5 at zero.\n*/\nSQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){\n  u16 i;\n\n  /* Records with omitted columns are only allowed for schema format\n  ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */\n  if( pTab->pSchema->file_format<2 ) return;\n\n  for(i=pTab->nCol-1; i>0; i--){\n    if( pTab->aCol[i].pDflt!=0 ) break;\n    if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;\n  }\n  sqlite3VdbeChangeP5(v, i+1);\n}\n#endif\n\n/*\n** This routine generates code to finish the INSERT or UPDATE operation\n** that was started by a prior call to sqlite3GenerateConstraintChecks.\n** A consecutive range of registers starting at regNewData contains the\n** rowid and the content to be inserted.\n**\n** The arguments to this routine should be the same as the first six\n** arguments to sqlite3GenerateConstraintChecks.\n*/\nSQLITE_PRIVATE void sqlite3CompleteInsertion(\n  Parse *pParse,      /* The parser context */\n  Table *pTab,        /* the table into which we are inserting */\n  int iDataCur,       /* Cursor of the canonical data source */\n  int iIdxCur,        /* First index cursor */\n  int regNewData,     /* Range of content */\n  int *aRegIdx,       /* Register used by each index.  0 for unused indices */\n  int update_flags,   /* True for UPDATE, False for INSERT */\n  int appendBias,     /* True if this is likely to be an append */\n  int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */\n){\n  Vdbe *v;            /* Prepared statements under construction */\n  Index *pIdx;        /* An index being inserted or updated */\n  u8 pik_flags;       /* flag values passed to the btree insert */\n  int regData;        /* Content registers (after the rowid) */\n  int regRec;         /* Register holding assembled record for the table */\n  int i;              /* Loop counter */\n  u8 bAffinityDone = 0; /* True if OP_Affinity has been run already */\n\n  assert( update_flags==0\n       || update_flags==OPFLAG_ISUPDATE\n       || update_flags==(OPFLAG_ISUPDATE|OPFLAG_SAVEPOSITION)\n  );\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    if( aRegIdx[i]==0 ) continue;\n    bAffinityDone = 1;\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n    }\n    pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      assert( pParse->nested==0 );\n      pik_flags |= OPFLAG_NCHANGE;\n      pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n      if( update_flags==0 ){\n        sqlite3VdbeAddOp4(v, OP_InsertInt, \n            iIdxCur+i, aRegIdx[i], 0, (char*)pTab, P4_TABLE\n        );\n        sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);\n      }\n#endif\n    }\n    sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i],\n                         aRegIdx[i]+1,\n                         pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);\n    sqlite3VdbeChangeP5(v, pik_flags);\n  }\n  if( !HasRowid(pTab) ) return;\n  regData = regNewData + 1;\n  regRec = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);\n  sqlite3SetMakeRecordP5(v, pTab);\n  if( !bAffinityDone ){\n    sqlite3TableAffinity(v, pTab, 0);\n    sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);\n  }\n  if( pParse->nested ){\n    pik_flags = 0;\n  }else{\n    pik_flags = OPFLAG_NCHANGE;\n    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);\n  }\n  if( appendBias ){\n    pik_flags |= OPFLAG_APPEND;\n  }\n  if( useSeekResult ){\n    pik_flags |= OPFLAG_USESEEKRESULT;\n  }\n  sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);\n  if( !pParse->nested ){\n    sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n  }\n  sqlite3VdbeChangeP5(v, pik_flags);\n}\n\n/*\n** Allocate cursors for the pTab table and all its indices and generate\n** code to open and initialized those cursors.\n**\n** The cursor for the object that contains the complete data (normally\n** the table itself, but the PRIMARY KEY index in the case of a WITHOUT\n** ROWID table) is returned in *piDataCur.  The first index cursor is\n** returned in *piIdxCur.  The number of indices is returned.\n**\n** Use iBase as the first cursor (either the *piDataCur for rowid tables\n** or the first index for WITHOUT ROWID tables) if it is non-negative.\n** If iBase is negative, then allocate the next available cursor.\n**\n** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.\n** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range\n** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the\n** pTab->pIndex list.\n**\n** If pTab is a virtual table, then this routine is a no-op and the\n** *piDataCur and *piIdxCur values are left uninitialized.\n*/\nSQLITE_PRIVATE int sqlite3OpenTableAndIndices(\n  Parse *pParse,   /* Parsing context */\n  Table *pTab,     /* Table to be opened */\n  int op,          /* OP_OpenRead or OP_OpenWrite */\n  u8 p5,           /* P5 value for OP_Open* opcodes (except on WITHOUT ROWID) */\n  int iBase,       /* Use this for the table cursor, if there is one */\n  u8 *aToOpen,     /* If not NULL: boolean for each table and index */\n  int *piDataCur,  /* Write the database source cursor number here */\n  int *piIdxCur    /* Write the first index cursor number here */\n){\n  int i;\n  int iDb;\n  int iDataCur;\n  Index *pIdx;\n  Vdbe *v;\n\n  assert( op==OP_OpenRead || op==OP_OpenWrite );\n  assert( op==OP_OpenWrite || p5==0 );\n  if( IsVirtual(pTab) ){\n    /* This routine is a no-op for virtual tables. Leave the output\n    ** variables *piDataCur and *piIdxCur uninitialized so that valgrind\n    ** can detect if they are used by mistake in the caller. */\n    return 0;\n  }\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  if( iBase<0 ) iBase = pParse->nTab;\n  iDataCur = iBase++;\n  if( piDataCur ) *piDataCur = iDataCur;\n  if( HasRowid(pTab) && (aToOpen==0 || aToOpen[0]) ){\n    sqlite3OpenTable(pParse, iDataCur, iDb, pTab, op);\n  }else{\n    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);\n  }\n  if( piIdxCur ) *piIdxCur = iBase;\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    int iIdxCur = iBase++;\n    assert( pIdx->pSchema==pTab->pSchema );\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      if( piDataCur ) *piDataCur = iIdxCur;\n      p5 = 0;\n    }\n    if( aToOpen==0 || aToOpen[i+1] ){\n      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      sqlite3VdbeChangeP5(v, p5);\n      VdbeComment((v, \"%s\", pIdx->zName));\n    }\n  }\n  if( iBase>pParse->nTab ) pParse->nTab = iBase;\n  return i;\n}\n\n\n#ifdef SQLITE_TEST\n/*\n** The following global variable is incremented whenever the\n** transfer optimization is used.  This is used for testing\n** purposes only - to make sure the transfer optimization really\n** is happening when it is supposed to.\n*/\nSQLITE_API int sqlite3_xferopt_count;\n#endif /* SQLITE_TEST */\n\n\n#ifndef SQLITE_OMIT_XFER_OPT\n/*\n** Check to see if index pSrc is compatible as a source of data\n** for index pDest in an insert transfer optimization.  The rules\n** for a compatible index:\n**\n**    *   The index is over the same set of columns\n**    *   The same DESC and ASC markings occurs on all columns\n**    *   The same onError processing (OE_Abort, OE_Ignore, etc)\n**    *   The same collating sequence on each column\n**    *   The index has the exact same WHERE clause\n*/\nstatic int xferCompatibleIndex(Index *pDest, Index *pSrc){\n  int i;\n  assert( pDest && pSrc );\n  assert( pDest->pTable!=pSrc->pTable );\n  if( pDest->nKeyCol!=pSrc->nKeyCol ){\n    return 0;   /* Different number of columns */\n  }\n  if( pDest->onError!=pSrc->onError ){\n    return 0;   /* Different conflict resolution strategies */\n  }\n  for(i=0; i<pSrc->nKeyCol; i++){\n    if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){\n      return 0;   /* Different columns indexed */\n    }\n    if( pSrc->aiColumn[i]==XN_EXPR ){\n      assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );\n      if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,\n                             pDest->aColExpr->a[i].pExpr, -1)!=0 ){\n        return 0;   /* Different expressions in the index */\n      }\n    }\n    if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){\n      return 0;   /* Different sort orders */\n    }\n    if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){\n      return 0;   /* Different collating sequences */\n    }\n  }\n  if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){\n    return 0;     /* Different WHERE clauses */\n  }\n\n  /* If no test above fails then the indices must be compatible */\n  return 1;\n}\n\n/*\n** Attempt the transfer optimization on INSERTs of the form\n**\n**     INSERT INTO tab1 SELECT * FROM tab2;\n**\n** The xfer optimization transfers raw records from tab2 over to tab1.  \n** Columns are not decoded and reassembled, which greatly improves\n** performance.  Raw index records are transferred in the same way.\n**\n** The xfer optimization is only attempted if tab1 and tab2 are compatible.\n** There are lots of rules for determining compatibility - see comments\n** embedded in the code for details.\n**\n** This routine returns TRUE if the optimization is guaranteed to be used.\n** Sometimes the xfer optimization will only work if the destination table\n** is empty - a factor that can only be determined at run-time.  In that\n** case, this routine generates code for the xfer optimization but also\n** does a test to see if the destination table is empty and jumps over the\n** xfer optimization code if the test fails.  In that case, this routine\n** returns FALSE so that the caller will know to go ahead and generate\n** an unoptimized transfer.  This routine also returns FALSE if there\n** is no chance that the xfer optimization can be applied.\n**\n** This optimization is particularly useful at making VACUUM run faster.\n*/\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n){\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;                /* The result set of the SELECT */\n  Table *pSrc;                     /* The table in the FROM clause of SELECT */\n  Index *pSrcIdx, *pDestIdx;       /* Source and destination indices */\n  struct SrcList_item *pItem;      /* An element of pSelect->pSrc */\n  int i;                           /* Loop counter */\n  int iDbSrc;                      /* The database of pSrc */\n  int iSrc, iDest;                 /* Cursors from source and destination */\n  int addr1, addr2;                /* Loop addresses */\n  int emptyDestTest = 0;           /* Address of test for empty pDest */\n  int emptySrcTest = 0;            /* Address of test for empty pSrc */\n  Vdbe *v;                         /* The VDBE we are building */\n  int regAutoinc;                  /* Memory register used by AUTOINC */\n  int destHasUniqueIdx = 0;        /* True if pDest has a UNIQUE index */\n  int regData, regRowid;           /* Registers holding data and rowid */\n\n  if( pSelect==0 ){\n    return 0;   /* Must be of the form  INSERT INTO ... SELECT ... */\n  }\n  if( pParse->pWith || pSelect->pWith ){\n    /* Do not attempt to process this query if there are an WITH clauses\n    ** attached to it. Proceeding may generate a false \"no such table: xxx\"\n    ** error if pSelect reads from a CTE named \"xxx\".  */\n    return 0;\n  }\n  if( sqlite3TriggerList(pParse, pDest) ){\n    return 0;   /* tab1 must not have triggers */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pDest) ){\n    return 0;   /* tab1 must not be a virtual table */\n  }\n#endif\n  if( onError==OE_Default ){\n    if( pDest->iPKey>=0 ) onError = pDest->keyConf;\n    if( onError==OE_Default ) onError = OE_Abort;\n  }\n  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */\n  if( pSelect->pSrc->nSrc!=1 ){\n    return 0;   /* FROM clause must have exactly one term */\n  }\n  if( pSelect->pSrc->a[0].pSelect ){\n    return 0;   /* FROM clause cannot contain a subquery */\n  }\n  if( pSelect->pWhere ){\n    return 0;   /* SELECT may not have a WHERE clause */\n  }\n  if( pSelect->pOrderBy ){\n    return 0;   /* SELECT may not have an ORDER BY clause */\n  }\n  /* Do not need to test for a HAVING clause.  If HAVING is present but\n  ** there is no ORDER BY, we will get an error. */\n  if( pSelect->pGroupBy ){\n    return 0;   /* SELECT may not have a GROUP BY clause */\n  }\n  if( pSelect->pLimit ){\n    return 0;   /* SELECT may not have a LIMIT clause */\n  }\n  assert( pSelect->pOffset==0 );  /* Must be so if pLimit==0 */\n  if( pSelect->pPrior ){\n    return 0;   /* SELECT may not be a compound query */\n  }\n  if( pSelect->selFlags & SF_Distinct ){\n    return 0;   /* SELECT may not be DISTINCT */\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );\n  if( pEList->nExpr!=1 ){\n    return 0;   /* The result set must have exactly one column */\n  }\n  assert( pEList->a[0].pExpr );\n  if( pEList->a[0].pExpr->op!=TK_ASTERISK ){\n    return 0;   /* The result set must be the special operator \"*\" */\n  }\n\n  /* At this point we have established that the statement is of the\n  ** correct syntactic form to participate in this optimization.  Now\n  ** we have to check the semantics.\n  */\n  pItem = pSelect->pSrc->a;\n  pSrc = sqlite3LocateTableItem(pParse, 0, pItem);\n  if( pSrc==0 ){\n    return 0;   /* FROM clause does not contain a real table */\n  }\n  if( pSrc==pDest ){\n    return 0;   /* tab1 and tab2 may not be the same table */\n  }\n  if( HasRowid(pDest)!=HasRowid(pSrc) ){\n    return 0;   /* source and destination must both be WITHOUT ROWID or not */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pSrc) ){\n    return 0;   /* tab2 must not be a virtual table */\n  }\n#endif\n  if( pSrc->pSelect ){\n    return 0;   /* tab2 may not be a view */\n  }\n  if( pDest->nCol!=pSrc->nCol ){\n    return 0;   /* Number of columns must be the same in tab1 and tab2 */\n  }\n  if( pDest->iPKey!=pSrc->iPKey ){\n    return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */\n  }\n  for(i=0; i<pDest->nCol; i++){\n    Column *pDestCol = &pDest->aCol[i];\n    Column *pSrcCol = &pSrc->aCol[i];\n#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS\n    if( (db->mDbFlags & DBFLAG_Vacuum)==0 \n     && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN \n    ){\n      return 0;    /* Neither table may have __hidden__ columns */\n    }\n#endif\n    if( pDestCol->affinity!=pSrcCol->affinity ){\n      return 0;    /* Affinity must be the same on all columns */\n    }\n    if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){\n      return 0;    /* Collating sequence must be the same on all columns */\n    }\n    if( pDestCol->notNull && !pSrcCol->notNull ){\n      return 0;    /* tab2 must be NOT NULL if tab1 is */\n    }\n    /* Default values for second and subsequent columns need to match. */\n    if( i>0 ){\n      assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );\n      assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );\n      if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0) \n       || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,\n                                       pSrcCol->pDflt->u.zToken)!=0)\n      ){\n        return 0;    /* Default values must be the same for all columns */\n      }\n    }\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    if( IsUniqueIndex(pDestIdx) ){\n      destHasUniqueIdx = 1;\n    }\n    for(pSrcIdx=pSrc->pIndex; pSrcIdx; pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    if( pSrcIdx==0 ){\n      return 0;    /* pDestIdx has no corresponding index in pSrc */\n    }\n  }\n#ifndef SQLITE_OMIT_CHECK\n  if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){\n    return 0;   /* Tables have different CHECK constraints.  Ticket #2252 */\n  }\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  /* Disallow the transfer optimization if the destination table constains\n  ** any foreign key constraints.  This is more restrictive than necessary.\n  ** But the main beneficiary of the transfer optimization is the VACUUM \n  ** command, and the VACUUM command disables foreign key constraints.  So\n  ** the extra complication to make this rule less restrictive is probably\n  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]\n  */\n  if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){\n    return 0;\n  }\n#endif\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    return 0;  /* xfer opt does not play well with PRAGMA count_changes */\n  }\n\n  /* If we get this far, it means that the xfer optimization is at\n  ** least a possibility, though it might only work if the destination\n  ** table (tab1) is initially empty.\n  */\n#ifdef SQLITE_TEST\n  sqlite3_xferopt_count++;\n#endif\n  iDbSrc = sqlite3SchemaToIndex(db, pSrc->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  sqlite3CodeVerifySchema(pParse, iDbSrc);\n  iSrc = pParse->nTab++;\n  iDest = pParse->nTab++;\n  regAutoinc = autoIncBegin(pParse, iDbDest, pDest);\n  regData = sqlite3GetTempReg(pParse);\n  regRowid = sqlite3GetTempReg(pParse);\n  sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);\n  assert( HasRowid(pDest) || destHasUniqueIdx );\n  if( (db->mDbFlags & DBFLAG_Vacuum)==0 && (\n      (pDest->iPKey<0 && pDest->pIndex!=0)          /* (1) */\n   || destHasUniqueIdx                              /* (2) */\n   || (onError!=OE_Abort && onError!=OE_Rollback)   /* (3) */\n  )){\n    /* In some circumstances, we are able to run the xfer optimization\n    ** only if the destination table is initially empty. Unless the\n    ** DBFLAG_Vacuum flag is set, this block generates code to make\n    ** that determination. If DBFLAG_Vacuum is set, then the destination\n    ** table is always empty.\n    **\n    ** Conditions under which the destination must be empty:\n    **\n    ** (1) There is no INTEGER PRIMARY KEY but there are indices.\n    **     (If the destination is not initially empty, the rowid fields\n    **     of index entries might need to change.)\n    **\n    ** (2) The destination has a unique index.  (The xfer optimization \n    **     is unable to test uniqueness.)\n    **\n    ** (3) onError is something other than OE_Abort and OE_Rollback.\n    */\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); VdbeCoverage(v);\n    emptyDestTest = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, addr1);\n  }\n  if( HasRowid(pSrc) ){\n    u8 insFlags;\n    sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);\n    emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    if( pDest->iPKey>=0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);\n      VdbeCoverage(v);\n      sqlite3RowidConstraint(pParse, onError, pDest);\n      sqlite3VdbeJumpHere(v, addr2);\n      autoIncStep(pParse, regAutoinc, regRowid);\n    }else if( pDest->pIndex==0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);\n    }else{\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      assert( (pDest->tabFlags & TF_Autoincrement)==0 );\n    }\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|\n                           OPFLAG_APPEND|OPFLAG_USESEEKRESULT;\n    }else{\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND;\n    }\n    sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid,\n                      (char*)pDest, P4_TABLE);\n    sqlite3VdbeChangeP5(v, insFlags);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }else{\n    sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);\n    sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    u8 idxInsFlags = 0;\n    for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    assert( pSrcIdx );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);\n    sqlite3VdbeSetP4KeyInfo(pParse, pSrcIdx);\n    VdbeComment((v, \"%s\", pSrcIdx->zName));\n    sqlite3VdbeAddOp3(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest);\n    sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);\n    sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);\n    VdbeComment((v, \"%s\", pDestIdx->zName));\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      /* This INSERT command is part of a VACUUM operation, which guarantees\n      ** that the destination table is empty. If all indexed columns use\n      ** collation sequence BINARY, then it can also be assumed that the\n      ** index will be populated by inserting keys in strictly sorted \n      ** order. In this case, instead of seeking within the b-tree as part\n      ** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the\n      ** OP_IdxInsert to seek to the point within the b-tree where each key \n      ** should be inserted. This is faster.\n      **\n      ** If any of the indexed columns use a collation sequence other than\n      ** BINARY, this optimization is disabled. This is because the user \n      ** might change the definition of a collation sequence and then run\n      ** a VACUUM command. In that case keys may not be written in strictly\n      ** sorted order.  */\n      for(i=0; i<pSrcIdx->nColumn; i++){\n        const char *zColl = pSrcIdx->azColl[i];\n        if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break;\n      }\n      if( i==pSrcIdx->nColumn ){\n        idxInsFlags = OPFLAG_USESEEKRESULT;\n        sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      }\n    }\n    if( !HasRowid(pSrc) && pDestIdx->idxType==2 ){\n      idxInsFlags |= OPFLAG_NCHANGE;\n    }\n    sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, regData);\n    sqlite3VdbeChangeP5(v, idxInsFlags|OPFLAG_APPEND);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }\n  if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest);\n  sqlite3ReleaseTempReg(pParse, regRowid);\n  sqlite3ReleaseTempReg(pParse, regData);\n  if( emptyDestTest ){\n    sqlite3AutoincrementEnd(pParse);\n    sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0);\n    sqlite3VdbeJumpHere(v, emptyDestTest);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n    return 0;\n  }else{\n    return 1;\n  }\n}\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n/************** End of insert.c **********************************************/\n/************** Begin file legacy.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Execute SQL code.  Return one of the SQLITE_ success/failure\n** codes.  Also write an error message into memory obtained from\n** malloc() and make *pzErrMsg point to that message.\n**\n** If the SQL is a query, then for each row in the query result\n** the xCallback() function is called.  pArg becomes the first\n** argument to xCallback().  If xCallback=NULL then no callback\n** is invoked, even for queries.\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  sqlite3_callback xCallback, /* Invoke this callback routine */\n  void *pArg,                 /* First argument to xCallback() */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc = SQLITE_OK;         /* Return code */\n  const char *zLeftover;      /* Tail of unprocessed SQL */\n  sqlite3_stmt *pStmt = 0;    /* The current SQL statement */\n  char **azCols = 0;          /* Names of result columns */\n  int callbackIsInit;         /* True if callback data is initialized */\n\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n  if( zSql==0 ) zSql = \"\";\n\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3Error(db, SQLITE_OK);\n  while( rc==SQLITE_OK && zSql[0] ){\n    int nCol;\n    char **azVals = 0;\n\n    pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    assert( rc==SQLITE_OK || pStmt==0 );\n    if( rc!=SQLITE_OK ){\n      continue;\n    }\n    if( !pStmt ){\n      /* this happens for a comment or white-space */\n      zSql = zLeftover;\n      continue;\n    }\n\n    callbackIsInit = 0;\n    nCol = sqlite3_column_count(pStmt);\n\n    while( 1 ){\n      int i;\n      rc = sqlite3_step(pStmt);\n\n      /* Invoke the callback function if required */\n      if( xCallback && (SQLITE_ROW==rc || \n          (SQLITE_DONE==rc && !callbackIsInit\n                           && db->flags&SQLITE_NullCallback)) ){\n        if( !callbackIsInit ){\n          azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));\n          if( azCols==0 ){\n            goto exec_out;\n          }\n          for(i=0; i<nCol; i++){\n            azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n            /* sqlite3VdbeSetColName() installs column names as UTF8\n            ** strings so there is no way for sqlite3_column_name() to fail. */\n            assert( azCols[i]!=0 );\n          }\n          callbackIsInit = 1;\n        }\n        if( rc==SQLITE_ROW ){\n          azVals = &azCols[nCol];\n          for(i=0; i<nCol; i++){\n            azVals[i] = (char *)sqlite3_column_text(pStmt, i);\n            if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n              sqlite3OomFault(db);\n              goto exec_out;\n            }\n          }\n          azVals[i] = 0;\n        }\n        if( xCallback(pArg, nCol, azVals, azCols) ){\n          /* EVIDENCE-OF: R-38229-40159 If the callback function to\n          ** sqlite3_exec() returns non-zero, then sqlite3_exec() will\n          ** return SQLITE_ABORT. */\n          rc = SQLITE_ABORT;\n          sqlite3VdbeFinalize((Vdbe *)pStmt);\n          pStmt = 0;\n          sqlite3Error(db, SQLITE_ABORT);\n          goto exec_out;\n        }\n      }\n\n      if( rc!=SQLITE_ROW ){\n        rc = sqlite3VdbeFinalize((Vdbe *)pStmt);\n        pStmt = 0;\n        zSql = zLeftover;\n        while( sqlite3Isspace(zSql[0]) ) zSql++;\n        break;\n      }\n    }\n\n    sqlite3DbFree(db, azCols);\n    azCols = 0;\n  }\n\nexec_out:\n  if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);\n  sqlite3DbFree(db, azCols);\n\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && pzErrMsg ){\n    *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));\n    if( *pzErrMsg==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      sqlite3Error(db, SQLITE_NOMEM);\n    }\n  }else if( pzErrMsg ){\n    *pzErrMsg = 0;\n  }\n\n  assert( (rc&db->errMask)==rc );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/************** End of legacy.c **********************************************/\n/************** Begin file loadext.c *****************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to dynamically load extensions into\n** the SQLite library.\n*/\n\n#ifndef SQLITE_CORE\n  #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */\n#endif\n/************** Include sqlite3ext.h in the middle of loadext.c **************/\n/************** Begin file sqlite3ext.h **************************************/\n/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef SQLITE3EXT_H\n#define SQLITE3EXT_H\n/* #include \"sqlite3.h\" */\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each other's shared\n** libraries!\n*/\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n  int  (*global_recover)(void);\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*xsnprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*xvsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n  /* Version 3.8.7 and later */\n  int (*auto_extension)(void(*)(void));\n  int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,\n                     void(*)(void*));\n  int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,\n                      void(*)(void*),unsigned char);\n  int (*cancel_auto_extension)(void(*)(void));\n  int (*load_extension)(sqlite3*,const char*,const char*,char**);\n  void *(*malloc64)(sqlite3_uint64);\n  sqlite3_uint64 (*msize)(void*);\n  void *(*realloc64)(void*,sqlite3_uint64);\n  void (*reset_auto_extension)(void);\n  void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,\n                        void(*)(void*));\n  void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,\n                         void(*)(void*), unsigned char);\n  int (*strglob)(const char*,const char*);\n  /* Version 3.8.11 and later */\n  sqlite3_value *(*value_dup)(const sqlite3_value*);\n  void (*value_free)(sqlite3_value*);\n  int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);\n  int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);\n  /* Version 3.9.0 and later */\n  unsigned int (*value_subtype)(sqlite3_value*);\n  void (*result_subtype)(sqlite3_context*,unsigned int);\n  /* Version 3.10.0 and later */\n  int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);\n  int (*strlike)(const char*,const char*,unsigned int);\n  int (*db_cacheflush)(sqlite3*);\n  /* Version 3.12.0 and later */\n  int (*system_errno)(sqlite3*);\n  /* Version 3.14.0 and later */\n  int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);\n  char *(*expanded_sql)(sqlite3_stmt*);\n  /* Version 3.18.0 and later */\n  void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);\n  /* Version 3.20.0 and later */\n  int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,\n                    sqlite3_stmt**,const char**);\n  int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,\n                      sqlite3_stmt**,const void**);\n  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));\n  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));\n  void *(*value_pointer)(sqlite3_value*,const char*);\n};\n\n/*\n** This is the function signature used for all extension entry points.  It\n** is also defined in the file \"loadext.c\".\n*/\ntypedef int (*sqlite3_loadext_entry)(\n  sqlite3 *db,                       /* Handle to the database. */\n  char **pzErrMsg,                   /* Used to set error string on failure. */\n  const sqlite3_api_routines *pThunk /* Extension API function pointers. */\n);\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected through the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->xsnprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_vsnprintf              sqlite3_api->xvsnprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->xvsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n/* Version 3.8.7 and later */\n#define sqlite3_auto_extension         sqlite3_api->auto_extension\n#define sqlite3_bind_blob64            sqlite3_api->bind_blob64\n#define sqlite3_bind_text64            sqlite3_api->bind_text64\n#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension\n#define sqlite3_load_extension         sqlite3_api->load_extension\n#define sqlite3_malloc64               sqlite3_api->malloc64\n#define sqlite3_msize                  sqlite3_api->msize\n#define sqlite3_realloc64              sqlite3_api->realloc64\n#define sqlite3_reset_auto_extension   sqlite3_api->reset_auto_extension\n#define sqlite3_result_blob64          sqlite3_api->result_blob64\n#define sqlite3_result_text64          sqlite3_api->result_text64\n#define sqlite3_strglob                sqlite3_api->strglob\n/* Version 3.8.11 and later */\n#define sqlite3_value_dup              sqlite3_api->value_dup\n#define sqlite3_value_free             sqlite3_api->value_free\n#define sqlite3_result_zeroblob64      sqlite3_api->result_zeroblob64\n#define sqlite3_bind_zeroblob64        sqlite3_api->bind_zeroblob64\n/* Version 3.9.0 and later */\n#define sqlite3_value_subtype          sqlite3_api->value_subtype\n#define sqlite3_result_subtype         sqlite3_api->result_subtype\n/* Version 3.10.0 and later */\n#define sqlite3_status64               sqlite3_api->status64\n#define sqlite3_strlike                sqlite3_api->strlike\n#define sqlite3_db_cacheflush          sqlite3_api->db_cacheflush\n/* Version 3.12.0 and later */\n#define sqlite3_system_errno           sqlite3_api->system_errno\n/* Version 3.14.0 and later */\n#define sqlite3_trace_v2               sqlite3_api->trace_v2\n#define sqlite3_expanded_sql           sqlite3_api->expanded_sql\n/* Version 3.18.0 and later */\n#define sqlite3_set_last_insert_rowid  sqlite3_api->set_last_insert_rowid\n/* Version 3.20.0 and later */\n#define sqlite3_prepare_v3             sqlite3_api->prepare_v3\n#define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3\n#define sqlite3_bind_pointer           sqlite3_api->bind_pointer\n#define sqlite3_result_pointer         sqlite3_api->result_pointer\n#define sqlite3_value_pointer          sqlite3_api->value_pointer\n#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n# define SQLITE_EXTENSION_INIT3     \\\n    extern const sqlite3_api_routines *sqlite3_api;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n# define SQLITE_EXTENSION_INIT3     /*no-op*/\n#endif\n\n#endif /* SQLITE3EXT_H */\n\n/************** End of sqlite3ext.h ******************************************/\n/************** Continuing where we left off in loadext.c ********************/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Some API routines are omitted when various features are\n** excluded from a build of SQLite.  Substitute a NULL pointer\n** for any missing APIs.\n*/\n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n# define sqlite3_column_database_name   0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name      0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name     0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_AUTHORIZATION\n# define sqlite3_set_authorizer         0\n#endif\n\n#ifdef SQLITE_OMIT_UTF16\n# define sqlite3_bind_text16            0\n# define sqlite3_collation_needed16     0\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_name16          0\n# define sqlite3_column_text16          0\n# define sqlite3_complete16             0\n# define sqlite3_create_collation16     0\n# define sqlite3_create_function16      0\n# define sqlite3_errmsg16               0\n# define sqlite3_open16                 0\n# define sqlite3_prepare16              0\n# define sqlite3_prepare16_v2           0\n# define sqlite3_prepare16_v3           0\n# define sqlite3_result_error16         0\n# define sqlite3_result_text16          0\n# define sqlite3_result_text16be        0\n# define sqlite3_result_text16le        0\n# define sqlite3_value_text16           0\n# define sqlite3_value_text16be         0\n# define sqlite3_value_text16le         0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_COMPLETE\n# define sqlite3_complete 0\n# define sqlite3_complete16 0\n#endif\n\n#ifdef SQLITE_OMIT_DECLTYPE\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_decltype        0\n#endif\n\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n# define sqlite3_progress_handler 0\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# define sqlite3_create_module 0\n# define sqlite3_create_module_v2 0\n# define sqlite3_declare_vtab 0\n# define sqlite3_vtab_config 0\n# define sqlite3_vtab_on_conflict 0\n#endif\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n# define sqlite3_enable_shared_cache 0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)\n# define sqlite3_profile       0\n# define sqlite3_trace         0\n#endif\n\n#ifdef SQLITE_OMIT_GET_TABLE\n# define sqlite3_free_table    0\n# define sqlite3_get_table     0\n#endif\n\n#ifdef SQLITE_OMIT_INCRBLOB\n#define sqlite3_bind_zeroblob  0\n#define sqlite3_blob_bytes     0\n#define sqlite3_blob_close     0\n#define sqlite3_blob_open      0\n#define sqlite3_blob_read      0\n#define sqlite3_blob_write     0\n#define sqlite3_blob_reopen    0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE)\n# define sqlite3_trace_v2      0\n#endif\n\n/*\n** The following structure contains pointers to all SQLite API routines.\n** A pointer to this structure is passed into extensions when they are\n** loaded so that the extension can make calls back into the SQLite\n** library.\n**\n** When adding new APIs, add them to the bottom of this structure\n** in order to preserve backwards compatibility.\n**\n** Extensions that use newer APIs should first call the\n** sqlite3_libversion_number() to make sure that the API they\n** intend to use is supported by the library.  Extensions should\n** also check to make sure that the pointer to the function is\n** not NULL before calling it.\n*/\nstatic const sqlite3_api_routines sqlite3Apis = {\n  sqlite3_aggregate_context,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_aggregate_count,\n#else\n  0,\n#endif\n  sqlite3_bind_blob,\n  sqlite3_bind_double,\n  sqlite3_bind_int,\n  sqlite3_bind_int64,\n  sqlite3_bind_null,\n  sqlite3_bind_parameter_count,\n  sqlite3_bind_parameter_index,\n  sqlite3_bind_parameter_name,\n  sqlite3_bind_text,\n  sqlite3_bind_text16,\n  sqlite3_bind_value,\n  sqlite3_busy_handler,\n  sqlite3_busy_timeout,\n  sqlite3_changes,\n  sqlite3_close,\n  sqlite3_collation_needed,\n  sqlite3_collation_needed16,\n  sqlite3_column_blob,\n  sqlite3_column_bytes,\n  sqlite3_column_bytes16,\n  sqlite3_column_count,\n  sqlite3_column_database_name,\n  sqlite3_column_database_name16,\n  sqlite3_column_decltype,\n  sqlite3_column_decltype16,\n  sqlite3_column_double,\n  sqlite3_column_int,\n  sqlite3_column_int64,\n  sqlite3_column_name,\n  sqlite3_column_name16,\n  sqlite3_column_origin_name,\n  sqlite3_column_origin_name16,\n  sqlite3_column_table_name,\n  sqlite3_column_table_name16,\n  sqlite3_column_text,\n  sqlite3_column_text16,\n  sqlite3_column_type,\n  sqlite3_column_value,\n  sqlite3_commit_hook,\n  sqlite3_complete,\n  sqlite3_complete16,\n  sqlite3_create_collation,\n  sqlite3_create_collation16,\n  sqlite3_create_function,\n  sqlite3_create_function16,\n  sqlite3_create_module,\n  sqlite3_data_count,\n  sqlite3_db_handle,\n  sqlite3_declare_vtab,\n  sqlite3_enable_shared_cache,\n  sqlite3_errcode,\n  sqlite3_errmsg,\n  sqlite3_errmsg16,\n  sqlite3_exec,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_expired,\n#else\n  0,\n#endif\n  sqlite3_finalize,\n  sqlite3_free,\n  sqlite3_free_table,\n  sqlite3_get_autocommit,\n  sqlite3_get_auxdata,\n  sqlite3_get_table,\n  0,     /* Was sqlite3_global_recover(), but that function is deprecated */\n  sqlite3_interrupt,\n  sqlite3_last_insert_rowid,\n  sqlite3_libversion,\n  sqlite3_libversion_number,\n  sqlite3_malloc,\n  sqlite3_mprintf,\n  sqlite3_open,\n  sqlite3_open16,\n  sqlite3_prepare,\n  sqlite3_prepare16,\n  sqlite3_profile,\n  sqlite3_progress_handler,\n  sqlite3_realloc,\n  sqlite3_reset,\n  sqlite3_result_blob,\n  sqlite3_result_double,\n  sqlite3_result_error,\n  sqlite3_result_error16,\n  sqlite3_result_int,\n  sqlite3_result_int64,\n  sqlite3_result_null,\n  sqlite3_result_text,\n  sqlite3_result_text16,\n  sqlite3_result_text16be,\n  sqlite3_result_text16le,\n  sqlite3_result_value,\n  sqlite3_rollback_hook,\n  sqlite3_set_authorizer,\n  sqlite3_set_auxdata,\n  sqlite3_snprintf,\n  sqlite3_step,\n  sqlite3_table_column_metadata,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup,\n#else\n  0,\n#endif\n  sqlite3_total_changes,\n  sqlite3_trace,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_transfer_bindings,\n#else\n  0,\n#endif\n  sqlite3_update_hook,\n  sqlite3_user_data,\n  sqlite3_value_blob,\n  sqlite3_value_bytes,\n  sqlite3_value_bytes16,\n  sqlite3_value_double,\n  sqlite3_value_int,\n  sqlite3_value_int64,\n  sqlite3_value_numeric_type,\n  sqlite3_value_text,\n  sqlite3_value_text16,\n  sqlite3_value_text16be,\n  sqlite3_value_text16le,\n  sqlite3_value_type,\n  sqlite3_vmprintf,\n  /*\n  ** The original API set ends here.  All extensions can call any\n  ** of the APIs above provided that the pointer is not NULL.  But\n  ** before calling APIs that follow, extension should check the\n  ** sqlite3_libversion_number() to make sure they are dealing with\n  ** a library that is new enough to support that API.\n  *************************************************************************\n  */\n  sqlite3_overload_function,\n\n  /*\n  ** Added after 3.3.13\n  */\n  sqlite3_prepare_v2,\n  sqlite3_prepare16_v2,\n  sqlite3_clear_bindings,\n\n  /*\n  ** Added for 3.4.1\n  */\n  sqlite3_create_module_v2,\n\n  /*\n  ** Added for 3.5.0\n  */\n  sqlite3_bind_zeroblob,\n  sqlite3_blob_bytes,\n  sqlite3_blob_close,\n  sqlite3_blob_open,\n  sqlite3_blob_read,\n  sqlite3_blob_write,\n  sqlite3_create_collation_v2,\n  sqlite3_file_control,\n  sqlite3_memory_highwater,\n  sqlite3_memory_used,\n#ifdef SQLITE_MUTEX_OMIT\n  0, \n  0, \n  0,\n  0,\n  0,\n#else\n  sqlite3_mutex_alloc,\n  sqlite3_mutex_enter,\n  sqlite3_mutex_free,\n  sqlite3_mutex_leave,\n  sqlite3_mutex_try,\n#endif\n  sqlite3_open_v2,\n  sqlite3_release_memory,\n  sqlite3_result_error_nomem,\n  sqlite3_result_error_toobig,\n  sqlite3_sleep,\n  sqlite3_soft_heap_limit,\n  sqlite3_vfs_find,\n  sqlite3_vfs_register,\n  sqlite3_vfs_unregister,\n\n  /*\n  ** Added for 3.5.8\n  */\n  sqlite3_threadsafe,\n  sqlite3_result_zeroblob,\n  sqlite3_result_error_code,\n  sqlite3_test_control,\n  sqlite3_randomness,\n  sqlite3_context_db_handle,\n\n  /*\n  ** Added for 3.6.0\n  */\n  sqlite3_extended_result_codes,\n  sqlite3_limit,\n  sqlite3_next_stmt,\n  sqlite3_sql,\n  sqlite3_status,\n\n  /*\n  ** Added for 3.7.4\n  */\n  sqlite3_backup_finish,\n  sqlite3_backup_init,\n  sqlite3_backup_pagecount,\n  sqlite3_backup_remaining,\n  sqlite3_backup_step,\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  sqlite3_compileoption_get,\n  sqlite3_compileoption_used,\n#else\n  0,\n  0,\n#endif\n  sqlite3_create_function_v2,\n  sqlite3_db_config,\n  sqlite3_db_mutex,\n  sqlite3_db_status,\n  sqlite3_extended_errcode,\n  sqlite3_log,\n  sqlite3_soft_heap_limit64,\n  sqlite3_sourceid,\n  sqlite3_stmt_status,\n  sqlite3_strnicmp,\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  sqlite3_unlock_notify,\n#else\n  0,\n#endif\n#ifndef SQLITE_OMIT_WAL\n  sqlite3_wal_autocheckpoint,\n  sqlite3_wal_checkpoint,\n  sqlite3_wal_hook,\n#else\n  0,\n  0,\n  0,\n#endif\n  sqlite3_blob_reopen,\n  sqlite3_vtab_config,\n  sqlite3_vtab_on_conflict,\n  sqlite3_close_v2,\n  sqlite3_db_filename,\n  sqlite3_db_readonly,\n  sqlite3_db_release_memory,\n  sqlite3_errstr,\n  sqlite3_stmt_busy,\n  sqlite3_stmt_readonly,\n  sqlite3_stricmp,\n  sqlite3_uri_boolean,\n  sqlite3_uri_int64,\n  sqlite3_uri_parameter,\n  sqlite3_vsnprintf,\n  sqlite3_wal_checkpoint_v2,\n  /* Version 3.8.7 and later */\n  sqlite3_auto_extension,\n  sqlite3_bind_blob64,\n  sqlite3_bind_text64,\n  sqlite3_cancel_auto_extension,\n  sqlite3_load_extension,\n  sqlite3_malloc64,\n  sqlite3_msize,\n  sqlite3_realloc64,\n  sqlite3_reset_auto_extension,\n  sqlite3_result_blob64,\n  sqlite3_result_text64,\n  sqlite3_strglob,\n  /* Version 3.8.11 and later */\n  (sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup,\n  sqlite3_value_free,\n  sqlite3_result_zeroblob64,\n  sqlite3_bind_zeroblob64,\n  /* Version 3.9.0 and later */\n  sqlite3_value_subtype,\n  sqlite3_result_subtype,\n  /* Version 3.10.0 and later */\n  sqlite3_status64,\n  sqlite3_strlike,\n  sqlite3_db_cacheflush,\n  /* Version 3.12.0 and later */\n  sqlite3_system_errno,\n  /* Version 3.14.0 and later */\n  sqlite3_trace_v2,\n  sqlite3_expanded_sql,\n  /* Version 3.18.0 and later */\n  sqlite3_set_last_insert_rowid,\n  /* Version 3.20.0 and later */\n  sqlite3_prepare_v3,\n  sqlite3_prepare16_v3,\n  sqlite3_bind_pointer,\n  sqlite3_result_pointer,\n  sqlite3_value_pointer\n};\n\n/*\n** Attempt to load an SQLite extension library contained in the file\n** zFile.  The entry point is zProc.  zProc may be 0 in which case a\n** default entry point name (sqlite3_extension_init) is used.  Use\n** of the default name is recommended.\n**\n** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.\n**\n** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with \n** error message text.  The calling function should free this memory\n** by calling sqlite3DbFree(db, ).\n*/\nstatic int sqlite3LoadExtension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  sqlite3_vfs *pVfs = db->pVfs;\n  void *handle;\n  sqlite3_loadext_entry xInit;\n  char *zErrmsg = 0;\n  const char *zEntry;\n  char *zAltEntry = 0;\n  void **aHandle;\n  u64 nMsg = 300 + sqlite3Strlen30(zFile);\n  int ii;\n  int rc;\n\n  /* Shared library endings to try if zFile cannot be loaded as written */\n  static const char *azEndings[] = {\n#if SQLITE_OS_WIN\n     \"dll\"   \n#elif defined(__APPLE__)\n     \"dylib\"\n#else\n     \"so\"\n#endif\n  };\n\n\n  if( pzErrMsg ) *pzErrMsg = 0;\n\n  /* Ticket #1863.  To avoid a creating security problems for older\n  ** applications that relink against newer versions of SQLite, the\n  ** ability to run load_extension is turned off by default.  One\n  ** must call either sqlite3_enable_load_extension(db) or\n  ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0)\n  ** to turn on extension loading.\n  */\n  if( (db->flags & SQLITE_LoadExtension)==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"not authorized\");\n    }\n    return SQLITE_ERROR;\n  }\n\n  zEntry = zProc ? zProc : \"sqlite3_extension_init\";\n\n  handle = sqlite3OsDlOpen(pVfs, zFile);\n#if SQLITE_OS_UNIX || SQLITE_OS_WIN\n  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){\n    char *zAltFile = sqlite3_mprintf(\"%s.%s\", zFile, azEndings[ii]);\n    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;\n    handle = sqlite3OsDlOpen(pVfs, zAltFile);\n    sqlite3_free(zAltFile);\n  }\n#endif\n  if( handle==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg, \n            \"unable to open shared library [%s]\", zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    return SQLITE_ERROR;\n  }\n  xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n\n  /* If no entry point was specified and the default legacy\n  ** entry point name \"sqlite3_extension_init\" was not found, then\n  ** construct an entry point name \"sqlite3_X_init\" where the X is\n  ** replaced by the lowercase value of every ASCII alphabetic \n  ** character in the filename after the last \"/\" upto the first \".\",\n  ** and eliding the first three characters if they are \"lib\".  \n  ** Examples:\n  **\n  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init\n  **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init\n  */\n  if( xInit==0 && zProc==0 ){\n    int iFile, iEntry, c;\n    int ncFile = sqlite3Strlen30(zFile);\n    zAltEntry = sqlite3_malloc64(ncFile+30);\n    if( zAltEntry==0 ){\n      sqlite3OsDlClose(pVfs, handle);\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(zAltEntry, \"sqlite3_\", 8);\n    for(iFile=ncFile-1; iFile>=0 && zFile[iFile]!='/'; iFile--){}\n    iFile++;\n    if( sqlite3_strnicmp(zFile+iFile, \"lib\", 3)==0 ) iFile += 3;\n    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){\n      if( sqlite3Isalpha(c) ){\n        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];\n      }\n    }\n    memcpy(zAltEntry+iEntry, \"_init\", 6);\n    zEntry = zAltEntry;\n    xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n  }\n  if( xInit==0 ){\n    if( pzErrMsg ){\n      nMsg += sqlite3Strlen30(zEntry);\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg,\n            \"no entry point [%s] in shared library [%s]\", zEntry, zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    sqlite3OsDlClose(pVfs, handle);\n    sqlite3_free(zAltEntry);\n    return SQLITE_ERROR;\n  }\n  sqlite3_free(zAltEntry);\n  rc = xInit(db, &zErrmsg, &sqlite3Apis);\n  if( rc ){\n    if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"error during initialization: %s\", zErrmsg);\n    }\n    sqlite3_free(zErrmsg);\n    sqlite3OsDlClose(pVfs, handle);\n    return SQLITE_ERROR;\n  }\n\n  /* Append the new shared library handle to the db->aExtension array. */\n  aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1));\n  if( aHandle==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  if( db->nExtension>0 ){\n    memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension);\n  }\n  sqlite3DbFree(db, db->aExtension);\n  db->aExtension = aHandle;\n\n  db->aExtension[db->nExtension++] = handle;\n  return SQLITE_OK;\n}\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Call this routine when the database connection is closing in order\n** to clean up loaded extensions\n*/\nSQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){\n  int i;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nExtension; i++){\n    sqlite3OsDlClose(db->pVfs, db->aExtension[i]);\n  }\n  sqlite3DbFree(db, db->aExtension);\n}\n\n/*\n** Enable or disable extension loading.  Extension loading is disabled by\n** default so as not to open security holes in older applications.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){\n  sqlite3_mutex_enter(db->mutex);\n  if( onoff ){\n    db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;\n  }else{\n    db->flags &= ~(SQLITE_LoadExtension|SQLITE_LoadExtFunc);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n/*\n** The following object holds the list of automatically loaded\n** extensions.\n**\n** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MASTER\n** mutex must be held while accessing this list.\n*/\ntypedef struct sqlite3AutoExtList sqlite3AutoExtList;\nstatic SQLITE_WSD struct sqlite3AutoExtList {\n  u32 nExt;              /* Number of entries in aExt[] */          \n  void (**aExt)(void);   /* Pointers to the extension init functions */\n} sqlite3Autoext = { 0, 0 };\n\n/* The \"wsdAutoext\" macro will resolve to the autoextension\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Autoext\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdAutoextInit \\\n  sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext)\n# define wsdAutoext x[0]\n#else\n# define wsdAutoextInit\n# define wsdAutoext sqlite3Autoext\n#endif\n\n\n/*\n** Register a statically linked extension that is automatically\n** loaded by every new database connection.\n*/\nSQLITE_API int sqlite3_auto_extension(\n  void (*xInit)(void)\n){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ){\n    return rc;\n  }else\n#endif\n  {\n    u32 i;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    for(i=0; i<wsdAutoext.nExt; i++){\n      if( wsdAutoext.aExt[i]==xInit ) break;\n    }\n    if( i==wsdAutoext.nExt ){\n      u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);\n      void (**aNew)(void);\n      aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte);\n      if( aNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        wsdAutoext.aExt = aNew;\n        wsdAutoext.aExt[wsdAutoext.nExt] = xInit;\n        wsdAutoext.nExt++;\n      }\n    }\n    sqlite3_mutex_leave(mutex);\n    assert( (rc&0xff)==rc );\n    return rc;\n  }\n}\n\n/*\n** Cancel a prior call to sqlite3_auto_extension.  Remove xInit from the\n** set of routines that is invoked for each new database connection, if it\n** is currently on the list.  If xInit is not on the list, then this\n** routine is a no-op.\n**\n** Return 1 if xInit was found on the list and removed.  Return 0 if xInit\n** was not on the list.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(\n  void (*xInit)(void)\n){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  int i;\n  int n = 0;\n  wsdAutoextInit;\n  sqlite3_mutex_enter(mutex);\n  for(i=(int)wsdAutoext.nExt-1; i>=0; i--){\n    if( wsdAutoext.aExt[i]==xInit ){\n      wsdAutoext.nExt--;\n      wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];\n      n++;\n      break;\n    }\n  }\n  sqlite3_mutex_leave(mutex);\n  return n;\n}\n\n/*\n** Reset the automatic extension loading mechanism.\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize()==SQLITE_OK )\n#endif\n  {\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    sqlite3_free(wsdAutoext.aExt);\n    wsdAutoext.aExt = 0;\n    wsdAutoext.nExt = 0;\n    sqlite3_mutex_leave(mutex);\n  }\n}\n\n/*\n** Load all automatic extensions.\n**\n** If anything goes wrong, set an error in the database connection.\n*/\nSQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){\n  u32 i;\n  int go = 1;\n  int rc;\n  sqlite3_loadext_entry xInit;\n\n  wsdAutoextInit;\n  if( wsdAutoext.nExt==0 ){\n    /* Common case: early out without every having to acquire a mutex */\n    return;\n  }\n  for(i=0; go; i++){\n    char *zErrmsg;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n    const sqlite3_api_routines *pThunk = 0;\n#else\n    const sqlite3_api_routines *pThunk = &sqlite3Apis;\n#endif\n    sqlite3_mutex_enter(mutex);\n    if( i>=wsdAutoext.nExt ){\n      xInit = 0;\n      go = 0;\n    }else{\n      xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i];\n    }\n    sqlite3_mutex_leave(mutex);\n    zErrmsg = 0;\n    if( xInit && (rc = xInit(db, &zErrmsg, pThunk))!=0 ){\n      sqlite3ErrorWithMsg(db, rc,\n            \"automatic extension loading failed: %s\", zErrmsg);\n      go = 0;\n    }\n    sqlite3_free(zErrmsg);\n  }\n}\n\n/************** End of loadext.c *********************************************/\n/************** Begin file pragma.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the PRAGMA command.\n*/\n/* #include \"sqliteInt.h\" */\n\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/***************************************************************************\n** The \"pragma.h\" include file is an automatically generated file that\n** that includes the PragType_XXXX macro definitions and the aPragmaName[]\n** object.  This ensures that the aPragmaName[] table is arranged in\n** lexicographical order to facility a binary search of the pragma name.\n** Do not edit pragma.h directly.  Edit and rerun the script in at \n** ../tool/mkpragmatab.tcl. */\n/************** Include pragma.h in the middle of pragma.c *******************/\n/************** Begin file pragma.h ******************************************/\n/* DO NOT EDIT!\n** This file is automatically generated by the script at\n** ../tool/mkpragmatab.tcl.  To update the set of pragmas, edit\n** that script and rerun it.\n*/\n\n/* The various pragma types */\n#define PragTyp_HEADER_VALUE                   0\n#define PragTyp_AUTO_VACUUM                    1\n#define PragTyp_FLAG                           2\n#define PragTyp_BUSY_TIMEOUT                   3\n#define PragTyp_CACHE_SIZE                     4\n#define PragTyp_CACHE_SPILL                    5\n#define PragTyp_CASE_SENSITIVE_LIKE            6\n#define PragTyp_COLLATION_LIST                 7\n#define PragTyp_COMPILE_OPTIONS                8\n#define PragTyp_DATA_STORE_DIRECTORY           9\n#define PragTyp_DATABASE_LIST                 10\n#define PragTyp_DEFAULT_CACHE_SIZE            11\n#define PragTyp_ENCODING                      12\n#define PragTyp_FOREIGN_KEY_CHECK             13\n#define PragTyp_FOREIGN_KEY_LIST              14\n#define PragTyp_FUNCTION_LIST                 15\n#define PragTyp_INCREMENTAL_VACUUM            16\n#define PragTyp_INDEX_INFO                    17\n#define PragTyp_INDEX_LIST                    18\n#define PragTyp_INTEGRITY_CHECK               19\n#define PragTyp_JOURNAL_MODE                  20\n#define PragTyp_JOURNAL_SIZE_LIMIT            21\n#define PragTyp_LOCK_PROXY_FILE               22\n#define PragTyp_LOCKING_MODE                  23\n#define PragTyp_PAGE_COUNT                    24\n#define PragTyp_MMAP_SIZE                     25\n#define PragTyp_MODULE_LIST                   26\n#define PragTyp_OPTIMIZE                      27\n#define PragTyp_PAGE_SIZE                     28\n#define PragTyp_PRAGMA_LIST                   29\n#define PragTyp_SECURE_DELETE                 30\n#define PragTyp_SHRINK_MEMORY                 31\n#define PragTyp_SOFT_HEAP_LIMIT               32\n#define PragTyp_SYNCHRONOUS                   33\n#define PragTyp_TABLE_INFO                    34\n#define PragTyp_TEMP_STORE                    35\n#define PragTyp_TEMP_STORE_DIRECTORY          36\n#define PragTyp_THREADS                       37\n#define PragTyp_WAL_AUTOCHECKPOINT            38\n#define PragTyp_WAL_CHECKPOINT                39\n#define PragTyp_ACTIVATE_EXTENSIONS           40\n#define PragTyp_HEXKEY                        41\n#define PragTyp_KEY                           42\n#define PragTyp_REKEY                         43\n#define PragTyp_LOCK_STATUS                   44\n#define PragTyp_PARSER_TRACE                  45\n#define PragTyp_STATS                         46\n\n/* Property flags associated with various pragma. */\n#define PragFlg_NeedSchema 0x01 /* Force schema load before running */\n#define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */\n#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */\n#define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */\n#define PragFlg_Result0    0x10 /* Acts as query when no argument */\n#define PragFlg_Result1    0x20 /* Acts as query when has one argument */\n#define PragFlg_SchemaOpt  0x40 /* Schema restricts name search if present */\n#define PragFlg_SchemaReq  0x80 /* Schema required - \"main\" is default */\n\n/* Names of columns for pragmas that return multi-column result\n** or that return single-column results where the name of the\n** result column is different from the name of the pragma\n*/\nstatic const char *const pragCName[] = {\n  /*   0 */ \"cache_size\",  /* Used by: default_cache_size */\n  /*   1 */ \"cid\",         /* Used by: table_info */\n  /*   2 */ \"name\",       \n  /*   3 */ \"type\",       \n  /*   4 */ \"notnull\",    \n  /*   5 */ \"dflt_value\", \n  /*   6 */ \"pk\",         \n  /*   7 */ \"tbl\",         /* Used by: stats */\n  /*   8 */ \"idx\",        \n  /*   9 */ \"wdth\",       \n  /*  10 */ \"hght\",       \n  /*  11 */ \"flgs\",       \n  /*  12 */ \"seqno\",       /* Used by: index_info */\n  /*  13 */ \"cid\",        \n  /*  14 */ \"name\",       \n  /*  15 */ \"seqno\",       /* Used by: index_xinfo */\n  /*  16 */ \"cid\",        \n  /*  17 */ \"name\",       \n  /*  18 */ \"desc\",       \n  /*  19 */ \"coll\",       \n  /*  20 */ \"key\",        \n  /*  21 */ \"seq\",         /* Used by: index_list */\n  /*  22 */ \"name\",       \n  /*  23 */ \"unique\",     \n  /*  24 */ \"origin\",     \n  /*  25 */ \"partial\",    \n  /*  26 */ \"seq\",         /* Used by: database_list */\n  /*  27 */ \"name\",       \n  /*  28 */ \"file\",       \n  /*  29 */ \"name\",        /* Used by: function_list */\n  /*  30 */ \"builtin\",    \n  /*  31 */ \"name\",        /* Used by: module_list pragma_list */\n  /*  32 */ \"seq\",         /* Used by: collation_list */\n  /*  33 */ \"name\",       \n  /*  34 */ \"id\",          /* Used by: foreign_key_list */\n  /*  35 */ \"seq\",        \n  /*  36 */ \"table\",      \n  /*  37 */ \"from\",       \n  /*  38 */ \"to\",         \n  /*  39 */ \"on_update\",  \n  /*  40 */ \"on_delete\",  \n  /*  41 */ \"match\",      \n  /*  42 */ \"table\",       /* Used by: foreign_key_check */\n  /*  43 */ \"rowid\",      \n  /*  44 */ \"parent\",     \n  /*  45 */ \"fkid\",       \n  /*  46 */ \"busy\",        /* Used by: wal_checkpoint */\n  /*  47 */ \"log\",        \n  /*  48 */ \"checkpointed\",\n  /*  49 */ \"timeout\",     /* Used by: busy_timeout */\n  /*  50 */ \"database\",    /* Used by: lock_status */\n  /*  51 */ \"status\",     \n};\n\n/* Definitions of all built-in pragmas */\ntypedef struct PragmaName {\n  const char *const zName; /* Name of pragma */\n  u8 ePragTyp;             /* PragTyp_XXX value */\n  u8 mPragFlg;             /* Zero or more PragFlg_XXX values */\n  u8 iPragCName;           /* Start of column names in pragCName[] */\n  u8 nPragCName;           /* Num of col names. 0 means use pragma name */\n  u32 iArg;                /* Extra argument */\n} PragmaName;\nstatic const PragmaName aPragmaName[] = {\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n {/* zName:     */ \"activate_extensions\",\n  /* ePragTyp:  */ PragTyp_ACTIVATE_EXTENSIONS,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"application_id\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_APPLICATION_ID },\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"auto_vacuum\",\n  /* ePragTyp:  */ PragTyp_AUTO_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)\n {/* zName:     */ \"automatic_index\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_AutoIndex },\n#endif\n#endif\n {/* zName:     */ \"busy_timeout\",\n  /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 49, 1,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"cache_size\",\n  /* ePragTyp:  */ PragTyp_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"cache_spill\",\n  /* ePragTyp:  */ PragTyp_CACHE_SPILL,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n {/* zName:     */ \"case_sensitive_like\",\n  /* ePragTyp:  */ PragTyp_CASE_SENSITIVE_LIKE,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"cell_size_check\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CellSizeCk },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"checkpoint_fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CkptFullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"collation_list\",\n  /* ePragTyp:  */ PragTyp_COLLATION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 32, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)\n {/* zName:     */ \"compile_options\",\n  /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"count_changes\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CountRows },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN\n {/* zName:     */ \"data_store_directory\",\n  /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"data_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_DATA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"database_list\",\n  /* ePragTyp:  */ PragTyp_DATABASE_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 26, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n {/* zName:     */ \"default_cache_size\",\n  /* ePragTyp:  */ PragTyp_DEFAULT_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"defer_foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_DeferFKs },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"empty_result_callbacks\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_NullCallback },\n#endif\n#if !defined(SQLITE_OMIT_UTF16)\n {/* zName:     */ \"encoding\",\n  /* ePragTyp:  */ PragTyp_ENCODING,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_key_check\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 42, 4,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY)\n {/* zName:     */ \"foreign_key_list\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 34, 8,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ForeignKeys },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"freelist_count\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_FREE_PAGE_COUNT },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"full_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullColNames },\n {/* zName:     */ \"fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"function_list\",\n  /* ePragTyp:  */ PragTyp_FUNCTION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 29, 2,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"hexkey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"hexrekey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_CHECK)\n {/* zName:     */ \"ignore_check_constraints\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_IgnoreChecks },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"incremental_vacuum\",\n  /* ePragTyp:  */ PragTyp_INCREMENTAL_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"index_info\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 12, 3,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_list\",\n  /* ePragTyp:  */ PragTyp_INDEX_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 21, 5,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_xinfo\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 15, 6,\n  /* iArg:      */ 1 },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"integrity_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"journal_mode\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_MODE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"journal_size_limit\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_SIZE_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"key\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"legacy_file_format\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_LegacyFileFmt },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE\n {/* zName:     */ \"lock_proxy_file\",\n  /* ePragTyp:  */ PragTyp_LOCK_PROXY_FILE,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n {/* zName:     */ \"lock_status\",\n  /* ePragTyp:  */ PragTyp_LOCK_STATUS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 50, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"locking_mode\",\n  /* ePragTyp:  */ PragTyp_LOCKING_MODE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"max_page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"mmap_size\",\n  /* ePragTyp:  */ PragTyp_MMAP_SIZE,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if !defined(SQLITE_OMIT_VIRTUALTABLE)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"module_list\",\n  /* ePragTyp:  */ PragTyp_MODULE_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 31, 1,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#endif\n {/* zName:     */ \"optimize\",\n  /* ePragTyp:  */ PragTyp_OPTIMIZE,\n  /* ePragFlg:  */ PragFlg_Result1|PragFlg_NeedSchema,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"page_size\",\n  /* ePragTyp:  */ PragTyp_PAGE_SIZE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)\n {/* zName:     */ \"parser_trace\",\n  /* ePragTyp:  */ PragTyp_PARSER_TRACE,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"pragma_list\",\n  /* ePragTyp:  */ PragTyp_PRAGMA_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 31, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"query_only\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_QueryOnly },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"quick_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"read_uncommitted\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReadUncommit },\n {/* zName:     */ \"recursive_triggers\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_RecTriggers },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"rekey\",\n  /* ePragTyp:  */ PragTyp_REKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"reverse_unordered_selects\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReverseOrder },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"schema_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_SCHEMA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"secure_delete\",\n  /* ePragTyp:  */ PragTyp_SECURE_DELETE,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"short_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ShortColNames },\n#endif\n {/* zName:     */ \"shrink_memory\",\n  /* ePragTyp:  */ PragTyp_SHRINK_MEMORY,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"soft_heap_limit\",\n  /* ePragTyp:  */ PragTyp_SOFT_HEAP_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"sql_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)\n {/* zName:     */ \"stats\",\n  /* ePragTyp:  */ PragTyp_STATS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 7, 5,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"synchronous\",\n  /* ePragTyp:  */ PragTyp_SYNCHRONOUS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"table_info\",\n  /* ePragTyp:  */ PragTyp_TABLE_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 1, 6,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"temp_store\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"temp_store_directory\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n {/* zName:     */ \"threads\",\n  /* ePragTyp:  */ PragTyp_THREADS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"user_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_USER_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"vdbe_addoptrace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeAddopTrace },\n {/* zName:     */ \"vdbe_debug\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },\n {/* zName:     */ \"vdbe_eqp\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeEQP },\n {/* zName:     */ \"vdbe_listing\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeListing },\n {/* zName:     */ \"vdbe_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_WAL)\n {/* zName:     */ \"wal_autocheckpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"wal_checkpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,\n  /* ePragFlg:  */ PragFlg_NeedSchema,\n  /* ColNames:  */ 46, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"writable_schema\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_WriteSchema },\n#endif\n};\n/* Number of pragmas: 60 on by default, 77 total. */\n\n/************** End of pragma.h **********************************************/\n/************** Continuing where we left off in pragma.c *********************/\n\n/*\n** Interpret the given string as a safety level.  Return 0 for OFF,\n** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA.  Return 1 for an empty or \n** unrecognized string argument.  The FULL and EXTRA option is disallowed\n** if the omitFull parameter it 1.\n**\n** Note that the values returned are one less that the values that\n** should be passed into sqlite3BtreeSetSafetyLevel().  The is done\n** to support legacy SQL code.  The safety level used to be boolean\n** and older scripts may have used numbers 0 for OFF and 1 for ON.\n*/\nstatic u8 getSafetyLevel(const char *z, int omitFull, u8 dflt){\n                             /* 123456789 123456789 123 */\n  static const char zText[] = \"onoffalseyestruextrafull\";\n  static const u8 iOffset[] = {0, 1, 2,  4,    9,  12,  15,   20};\n  static const u8 iLength[] = {2, 2, 3,  5,    3,   4,   5,    4};\n  static const u8 iValue[] =  {1, 0, 0,  0,    1,   1,   3,    2};\n                            /* on no off false yes true extra full */\n  int i, n;\n  if( sqlite3Isdigit(*z) ){\n    return (u8)sqlite3Atoi(z);\n  }\n  n = sqlite3Strlen30(z);\n  for(i=0; i<ArraySize(iLength); i++){\n    if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0\n     && (!omitFull || iValue[i]<=1)\n    ){\n      return iValue[i];\n    }\n  }\n  return dflt;\n}\n\n/*\n** Interpret the given string as a boolean value.\n*/\nSQLITE_PRIVATE u8 sqlite3GetBoolean(const char *z, u8 dflt){\n  return getSafetyLevel(z,1,dflt)!=0;\n}\n\n/* The sqlite3GetBoolean() function is used by other modules but the\n** remainder of this file is specific to PRAGMA processing.  So omit\n** the rest of the file if PRAGMAs are omitted from the build.\n*/\n#if !defined(SQLITE_OMIT_PRAGMA)\n\n/*\n** Interpret the given string as a locking mode value.\n*/\nstatic int getLockingMode(const char *z){\n  if( z ){\n    if( 0==sqlite3StrICmp(z, \"exclusive\") ) return PAGER_LOCKINGMODE_EXCLUSIVE;\n    if( 0==sqlite3StrICmp(z, \"normal\") ) return PAGER_LOCKINGMODE_NORMAL;\n  }\n  return PAGER_LOCKINGMODE_QUERY;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Interpret the given string as an auto-vacuum mode value.\n**\n** The following strings, \"none\", \"full\" and \"incremental\" are \n** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.\n*/\nstatic int getAutoVacuum(const char *z){\n  int i;\n  if( 0==sqlite3StrICmp(z, \"none\") ) return BTREE_AUTOVACUUM_NONE;\n  if( 0==sqlite3StrICmp(z, \"full\") ) return BTREE_AUTOVACUUM_FULL;\n  if( 0==sqlite3StrICmp(z, \"incremental\") ) return BTREE_AUTOVACUUM_INCR;\n  i = sqlite3Atoi(z);\n  return (u8)((i>=0&&i<=2)?i:0);\n}\n#endif /* ifndef SQLITE_OMIT_AUTOVACUUM */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Interpret the given string as a temp db location. Return 1 for file\n** backed temporary databases, 2 for the Red-Black tree in memory database\n** and 0 to use the compile-time default.\n*/\nstatic int getTempStore(const char *z){\n  if( z[0]>='0' && z[0]<='2' ){\n    return z[0] - '0';\n  }else if( sqlite3StrICmp(z, \"file\")==0 ){\n    return 1;\n  }else if( sqlite3StrICmp(z, \"memory\")==0 ){\n    return 2;\n  }else{\n    return 0;\n  }\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Invalidate temp storage, either when the temp storage is changed\n** from default, or when 'file' and the temp_store_directory has changed\n*/\nstatic int invalidateTempStorage(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt!=0 ){\n    if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){\n      sqlite3ErrorMsg(pParse, \"temporary storage cannot be changed \"\n        \"from within a transaction\");\n      return SQLITE_ERROR;\n    }\n    sqlite3BtreeClose(db->aDb[1].pBt);\n    db->aDb[1].pBt = 0;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** If the TEMP database is open, close it and mark the database schema\n** as needing reloading.  This must be done when using the SQLITE_TEMP_STORE\n** or DEFAULT_TEMP_STORE pragmas.\n*/\nstatic int changeTempStorage(Parse *pParse, const char *zStorageType){\n  int ts = getTempStore(zStorageType);\n  sqlite3 *db = pParse->db;\n  if( db->temp_store==ts ) return SQLITE_OK;\n  if( invalidateTempStorage( pParse ) != SQLITE_OK ){\n    return SQLITE_ERROR;\n  }\n  db->temp_store = (u8)ts;\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n/*\n** Set result column names for a pragma.\n*/\nstatic void setPragmaResultColumnNames(\n  Vdbe *v,                     /* The query under construction */\n  const PragmaName *pPragma    /* The pragma */\n){\n  u8 n = pPragma->nPragCName;\n  sqlite3VdbeSetNumCols(v, n==0 ? 1 : n);\n  if( n==0 ){\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, pPragma->zName, SQLITE_STATIC);\n  }else{\n    int i, j;\n    for(i=0, j=pPragma->iPragCName; i<n; i++, j++){\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, pragCName[j], SQLITE_STATIC);\n    }\n  }\n}\n\n/*\n** Generate code to return a single integer value.\n*/\nstatic void returnSingleInt(Vdbe *v, i64 value){\n  sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, 1, 0, (const u8*)&value, P4_INT64);\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n}\n\n/*\n** Generate code to return a single text value.\n*/\nstatic void returnSingleText(\n  Vdbe *v,                /* Prepared statement under construction */\n  const char *zValue      /* Value to be returned */\n){\n  if( zValue ){\n    sqlite3VdbeLoadString(v, 1, (const char*)zValue);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n  }\n}\n\n\n/*\n** Set the safety_level and pager flags for pager iDb.  Or if iDb<0\n** set these values for all pagers.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nstatic void setAllPagerFlags(sqlite3 *db){\n  if( db->autoCommit ){\n    Db *pDb = db->aDb;\n    int n = db->nDb;\n    assert( SQLITE_FullFSync==PAGER_FULLFSYNC );\n    assert( SQLITE_CkptFullFSync==PAGER_CKPT_FULLFSYNC );\n    assert( SQLITE_CacheSpill==PAGER_CACHESPILL );\n    assert( (PAGER_FULLFSYNC | PAGER_CKPT_FULLFSYNC | PAGER_CACHESPILL)\n             ==  PAGER_FLAGS_MASK );\n    assert( (pDb->safety_level & PAGER_SYNCHRONOUS_MASK)==pDb->safety_level );\n    while( (n--) > 0 ){\n      if( pDb->pBt ){\n        sqlite3BtreeSetPagerFlags(pDb->pBt,\n                 pDb->safety_level | (db->flags & PAGER_FLAGS_MASK) );\n      }\n      pDb++;\n    }\n  }\n}\n#else\n# define setAllPagerFlags(X)  /* no-op */\n#endif\n\n\n/*\n** Return a human-readable name for a constraint resolution action.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic const char *actionName(u8 action){\n  const char *zName;\n  switch( action ){\n    case OE_SetNull:  zName = \"SET NULL\";        break;\n    case OE_SetDflt:  zName = \"SET DEFAULT\";     break;\n    case OE_Cascade:  zName = \"CASCADE\";         break;\n    case OE_Restrict: zName = \"RESTRICT\";        break;\n    default:          zName = \"NO ACTION\";  \n                      assert( action==OE_None ); break;\n  }\n  return zName;\n}\n#endif\n\n\n/*\n** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants\n** defined in pager.h. This function returns the associated lowercase\n** journal-mode name.\n*/\nSQLITE_PRIVATE const char *sqlite3JournalModename(int eMode){\n  static char * const azModeName[] = {\n    \"delete\", \"persist\", \"off\", \"truncate\", \"memory\"\n#ifndef SQLITE_OMIT_WAL\n     , \"wal\"\n#endif\n  };\n  assert( PAGER_JOURNALMODE_DELETE==0 );\n  assert( PAGER_JOURNALMODE_PERSIST==1 );\n  assert( PAGER_JOURNALMODE_OFF==2 );\n  assert( PAGER_JOURNALMODE_TRUNCATE==3 );\n  assert( PAGER_JOURNALMODE_MEMORY==4 );\n  assert( PAGER_JOURNALMODE_WAL==5 );\n  assert( eMode>=0 && eMode<=ArraySize(azModeName) );\n\n  if( eMode==ArraySize(azModeName) ) return 0;\n  return azModeName[eMode];\n}\n\n/*\n** Locate a pragma in the aPragmaName[] array.\n*/\nstatic const PragmaName *pragmaLocate(const char *zName){\n  int upr, lwr, mid = 0, rc;\n  lwr = 0;\n  upr = ArraySize(aPragmaName)-1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    rc = sqlite3_stricmp(zName, aPragmaName[mid].zName);\n    if( rc==0 ) break;\n    if( rc<0 ){\n      upr = mid - 1;\n    }else{\n      lwr = mid + 1;\n    }\n  }\n  return lwr>upr ? 0 : &aPragmaName[mid];\n}\n\n/*\n** Helper subroutine for PRAGMA integrity_check:\n**\n** Generate code to output a single-column result row with a value of the\n** string held in register 3.  Decrement the result count in register 1\n** and halt if the maximum number of result rows have been issued.\n*/\nstatic int integrityCheckResultRow(Vdbe *v){\n  int addr;\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);\n  addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp0(v, OP_Halt);\n  return addr;\n}\n\n/*\n** Process a pragma statement.  \n**\n** Pragmas are of this form:\n**\n**      PRAGMA [schema.]id [= value]\n**\n** The identifier might also be a string.  The value is a string, and\n** identifier, or a number.  If minusFlag is true, then the value is\n** a number that was preceded by a minus sign.\n**\n** If the left side is \"database.id\" then pId1 is the database name\n** and pId2 is the id.  If the left side is just \"id\" then pId1 is the\n** id and pId2 is any empty string.\n*/\nSQLITE_PRIVATE void sqlite3Pragma(\n  Parse *pParse, \n  Token *pId1,        /* First part of [schema.]id field */\n  Token *pId2,        /* Second part of [schema.]id field, or NULL */\n  Token *pValue,      /* Token for <value>, or NULL */\n  int minusFlag       /* True if a '-' sign preceded <value> */\n){\n  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */\n  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */\n  const char *zDb = 0;   /* The database name */\n  Token *pId;            /* Pointer to <id> token */\n  char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */\n  int iDb;               /* Database index for <database> */\n  int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */\n  sqlite3 *db = pParse->db;    /* The database connection */\n  Db *pDb;                     /* The specific database being pragmaed */\n  Vdbe *v = sqlite3GetVdbe(pParse);  /* Prepared statement */\n  const PragmaName *pPragma;   /* The pragma */\n\n  if( v==0 ) return;\n  sqlite3VdbeRunOnlyOnce(v);\n  pParse->nMem = 2;\n\n  /* Interpret the [schema.] part of the pragma statement. iDb is the\n  ** index of the database this pragma is being applied to in db.aDb[]. */\n  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);\n  if( iDb<0 ) return;\n  pDb = &db->aDb[iDb];\n\n  /* If the temp database has been explicitly named as part of the \n  ** pragma, make sure it is open. \n  */\n  if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){\n    return;\n  }\n\n  zLeft = sqlite3NameFromToken(db, pId);\n  if( !zLeft ) return;\n  if( minusFlag ){\n    zRight = sqlite3MPrintf(db, \"-%T\", pValue);\n  }else{\n    zRight = sqlite3NameFromToken(db, pValue);\n  }\n\n  assert( pId2 );\n  zDb = pId2->n>0 ? pDb->zDbSName : 0;\n  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){\n    goto pragma_out;\n  }\n\n  /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS\n  ** connection.  If it returns SQLITE_OK, then assume that the VFS\n  ** handled the pragma and generate a no-op prepared statement.\n  **\n  ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,\n  ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file\n  ** object corresponding to the database file to which the pragma\n  ** statement refers.\n  **\n  ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA\n  ** file control is an array of pointers to strings (char**) in which the\n  ** second element of the array is the name of the pragma and the third\n  ** element is the argument to the pragma or NULL if the pragma has no\n  ** argument.\n  */\n  aFcntl[0] = 0;\n  aFcntl[1] = zLeft;\n  aFcntl[2] = zRight;\n  aFcntl[3] = 0;\n  db->busyHandler.nBusy = 0;\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, aFcntl[0], SQLITE_TRANSIENT);\n    returnSingleText(v, aFcntl[0]);\n    sqlite3_free(aFcntl[0]);\n    goto pragma_out;\n  }\n  if( rc!=SQLITE_NOTFOUND ){\n    if( aFcntl[0] ){\n      sqlite3ErrorMsg(pParse, \"%s\", aFcntl[0]);\n      sqlite3_free(aFcntl[0]);\n    }\n    pParse->nErr++;\n    pParse->rc = rc;\n    goto pragma_out;\n  }\n\n  /* Locate the pragma in the lookup table */\n  pPragma = pragmaLocate(zLeft);\n  if( pPragma==0 ) goto pragma_out;\n\n  /* Make sure the database schema is loaded if the pragma requires that */\n  if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n  }\n\n  /* Register the result column names for pragmas that return results */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns)==0 \n   && ((pPragma->mPragFlg & PragFlg_NoColumns1)==0 || zRight==0)\n  ){\n    setPragmaResultColumnNames(v, pPragma);\n  }\n\n  /* Jump to the appropriate pragma handler */\n  switch( pPragma->ePragTyp ){\n  \n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n  /*\n  **  PRAGMA [schema.]default_cache_size\n  **  PRAGMA [schema.]default_cache_size=N\n  **\n  ** The first form reports the current persistent setting for the\n  ** page cache size.  The value returned is the maximum number of\n  ** pages in the page cache.  The second form sets both the current\n  ** page cache size value and the persistent page cache size value\n  ** stored in the database file.\n  **\n  ** Older versions of SQLite would set the default cache size to a\n  ** negative number to indicate synchronous=OFF.  These days, synchronous\n  ** is always on by default regardless of the sign of the default cache\n  ** size.  But continue to take the absolute value of the default cache\n  ** size of historical compatibility.\n  */\n  case PragTyp_DEFAULT_CACHE_SIZE: {\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList getCacheSize[] = {\n      { OP_Transaction, 0, 0,        0},                         /* 0 */\n      { OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE},  /* 1 */\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 2,        0},\n      { OP_Subtract,    1, 2,        1},\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 1,        0},                         /* 6 */\n      { OP_Noop,        0, 0,        0},\n      { OP_ResultRow,   1, 1,        0},\n    };\n    VdbeOp *aOp;\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( !zRight ){\n      pParse->nMem += 2;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE;\n    }else{\n      int size = sqlite3AbsInt32(sqlite3Atoi(zRight));\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size);\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n#endif /* !SQLITE_OMIT_PAGER_PRAGMAS && !SQLITE_OMIT_DEPRECATED */\n\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n  /*\n  **  PRAGMA [schema.]page_size\n  **  PRAGMA [schema.]page_size=N\n  **\n  ** The first form reports the current setting for the\n  ** database page size in bytes.  The second form sets the\n  ** database page size value.  The value can only be set if\n  ** the database has not yet been created.\n  */\n  case PragTyp_PAGE_SIZE: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;\n      returnSingleInt(v, size);\n    }else{\n      /* Malloc may fail when setting the page-size, as there is an internal\n      ** buffer that the pager module resizes using sqlite3_realloc().\n      */\n      db->nextPagesize = sqlite3Atoi(zRight);\n      if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){\n        sqlite3OomFault(db);\n      }\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]secure_delete\n  **  PRAGMA [schema.]secure_delete=ON/OFF/FAST\n  **\n  ** The first form reports the current setting for the\n  ** secure_delete flag.  The second form changes the secure_delete\n  ** flag setting and reports the new value.\n  */\n  case PragTyp_SECURE_DELETE: {\n    Btree *pBt = pDb->pBt;\n    int b = -1;\n    assert( pBt!=0 );\n    if( zRight ){\n      if( sqlite3_stricmp(zRight, \"fast\")==0 ){\n        b = 2;\n      }else{\n        b = sqlite3GetBoolean(zRight, 0);\n      }\n    }\n    if( pId2->n==0 && b>=0 ){\n      int ii;\n      for(ii=0; ii<db->nDb; ii++){\n        sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);\n      }\n    }\n    b = sqlite3BtreeSecureDelete(pBt, b);\n    returnSingleInt(v, b);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]max_page_count\n  **  PRAGMA [schema.]max_page_count=N\n  **\n  ** The first form reports the current setting for the\n  ** maximum number of pages in the database file.  The \n  ** second form attempts to change this setting.  Both\n  ** forms return the current setting.\n  **\n  ** The absolute value of N is used.  This is undocumented and might\n  ** change.  The only purpose is to provide an easy way to test\n  ** the sqlite3AbsInt32() function.\n  **\n  **  PRAGMA [schema.]page_count\n  **\n  ** Return the number of pages in the specified database.\n  */\n  case PragTyp_PAGE_COUNT: {\n    int iReg;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    iReg = ++pParse->nMem;\n    if( sqlite3Tolower(zLeft[0])=='p' ){\n      sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, \n                        sqlite3AbsInt32(sqlite3Atoi(zRight)));\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]locking_mode\n  **  PRAGMA [schema.]locking_mode = (normal|exclusive)\n  */\n  case PragTyp_LOCKING_MODE: {\n    const char *zRet = \"normal\";\n    int eMode = getLockingMode(zRight);\n\n    if( pId2->n==0 && eMode==PAGER_LOCKINGMODE_QUERY ){\n      /* Simple \"PRAGMA locking_mode;\" statement. This is a query for\n      ** the current default locking mode (which may be different to\n      ** the locking-mode of the main database).\n      */\n      eMode = db->dfltLockMode;\n    }else{\n      Pager *pPager;\n      if( pId2->n==0 ){\n        /* This indicates that no database name was specified as part\n        ** of the PRAGMA command. In this case the locking-mode must be\n        ** set on all attached databases, as well as the main db file.\n        **\n        ** Also, the sqlite3.dfltLockMode variable is set so that\n        ** any subsequently attached databases also use the specified\n        ** locking mode.\n        */\n        int ii;\n        assert(pDb==&db->aDb[0]);\n        for(ii=2; ii<db->nDb; ii++){\n          pPager = sqlite3BtreePager(db->aDb[ii].pBt);\n          sqlite3PagerLockingMode(pPager, eMode);\n        }\n        db->dfltLockMode = (u8)eMode;\n      }\n      pPager = sqlite3BtreePager(pDb->pBt);\n      eMode = sqlite3PagerLockingMode(pPager, eMode);\n    }\n\n    assert( eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n    if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){\n      zRet = \"exclusive\";\n    }\n    returnSingleText(v, zRet);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_mode\n  **  PRAGMA [schema.]journal_mode =\n  **                      (delete|persist|off|truncate|memory|wal|off)\n  */\n  case PragTyp_JOURNAL_MODE: {\n    int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */\n    int ii;           /* Loop counter */\n\n    if( zRight==0 ){\n      /* If there is no \"=MODE\" part of the pragma, do a query for the\n      ** current mode */\n      eMode = PAGER_JOURNALMODE_QUERY;\n    }else{\n      const char *zMode;\n      int n = sqlite3Strlen30(zRight);\n      for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){\n        if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;\n      }\n      if( !zMode ){\n        /* If the \"=MODE\" part does not match any known journal mode,\n        ** then do a query */\n        eMode = PAGER_JOURNALMODE_QUERY;\n      }\n    }\n    if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){\n      /* Convert \"PRAGMA journal_mode\" into \"PRAGMA main.journal_mode\" */\n      iDb = 0;\n      pId2->n = 1;\n    }\n    for(ii=db->nDb-1; ii>=0; ii--){\n      if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n        sqlite3VdbeUsesBtree(v, ii);\n        sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_size_limit\n  **  PRAGMA [schema.]journal_size_limit=N\n  **\n  ** Get or set the size limit on rollback journal files.\n  */\n  case PragTyp_JOURNAL_SIZE_LIMIT: {\n    Pager *pPager = sqlite3BtreePager(pDb->pBt);\n    i64 iLimit = -2;\n    if( zRight ){\n      sqlite3DecOrHexToI64(zRight, &iLimit);\n      if( iLimit<-1 ) iLimit = -1;\n    }\n    iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);\n    returnSingleInt(v, iLimit);\n    break;\n  }\n\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n  /*\n  **  PRAGMA [schema.]auto_vacuum\n  **  PRAGMA [schema.]auto_vacuum=N\n  **\n  ** Get or set the value of the database 'auto-vacuum' parameter.\n  ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_AUTO_VACUUM: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      returnSingleInt(v, sqlite3BtreeGetAutoVacuum(pBt));\n    }else{\n      int eAuto = getAutoVacuum(zRight);\n      assert( eAuto>=0 && eAuto<=2 );\n      db->nextAutovac = (u8)eAuto;\n      /* Call SetAutoVacuum() to set initialize the internal auto and\n      ** incr-vacuum flags. This is required in case this connection\n      ** creates the database file. It is important that it is created\n      ** as an auto-vacuum capable db.\n      */\n      rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);\n      if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){\n        /* When setting the auto_vacuum mode to either \"full\" or \n        ** \"incremental\", write the value of meta[6] in the database\n        ** file. Before writing to meta[6], check that meta[3] indicates\n        ** that this really is an auto-vacuum capable database.\n        */\n        static const int iLn = VDBE_OFFSET_LINENO(2);\n        static const VdbeOpList setMeta6[] = {\n          { OP_Transaction,    0,         1,                 0},    /* 0 */\n          { OP_ReadCookie,     0,         1,         BTREE_LARGEST_ROOT_PAGE},\n          { OP_If,             1,         0,                 0},    /* 2 */\n          { OP_Halt,           SQLITE_OK, OE_Abort,          0},    /* 3 */\n          { OP_SetCookie,      0,         BTREE_INCR_VACUUM, 0},    /* 4 */\n        };\n        VdbeOp *aOp;\n        int iAddr = sqlite3VdbeCurrentAddr(v);\n        sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setMeta6));\n        aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn);\n        if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n        aOp[0].p1 = iDb;\n        aOp[1].p1 = iDb;\n        aOp[2].p2 = iAddr+4;\n        aOp[4].p1 = iDb;\n        aOp[4].p3 = eAuto - 1;\n        sqlite3VdbeUsesBtree(v, iDb);\n      }\n    }\n    break;\n  }\n#endif\n\n  /*\n  **  PRAGMA [schema.]incremental_vacuum(N)\n  **\n  ** Do N steps of incremental vacuuming on a database.\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_INCREMENTAL_VACUUM: {\n    int iLimit, addr;\n    if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){\n      iLimit = 0x7fffffff;\n    }\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);\n    addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb); VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_ResultRow, 1);\n    sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);\n    sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    break;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n  /*\n  **  PRAGMA [schema.]cache_size\n  **  PRAGMA [schema.]cache_size=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache size. The second form sets the local\n  ** page cache size value.  If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  */\n  case PragTyp_CACHE_SIZE: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v, pDb->pSchema->cache_size);\n    }else{\n      int size = sqlite3Atoi(zRight);\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]cache_spill\n  **  PRAGMA cache_spill=BOOLEAN\n  **  PRAGMA [schema.]cache_spill=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache spill size. The second form turns cache spill on\n  ** or off.  When turnning cache spill on, the size is set to the\n  ** current cache_size.  The third form sets a spill size that\n  ** may be different form the cache size.\n  ** If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  **\n  ** If the number of cache_spill pages is less then the number of\n  ** cache_size pages, no spilling occurs until the page count exceeds\n  ** the number of cache_size pages.\n  **\n  ** The cache_spill=BOOLEAN setting applies to all attached schemas,\n  ** not just the schema specified.\n  */\n  case PragTyp_CACHE_SPILL: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v,\n         (db->flags & SQLITE_CacheSpill)==0 ? 0 : \n            sqlite3BtreeSetSpillSize(pDb->pBt,0));\n    }else{\n      int size = 1;\n      if( sqlite3GetInt32(zRight, &size) ){\n        sqlite3BtreeSetSpillSize(pDb->pBt, size);\n      }\n      if( sqlite3GetBoolean(zRight, size!=0) ){\n        db->flags |= SQLITE_CacheSpill;\n      }else{\n        db->flags &= ~SQLITE_CacheSpill;\n      }\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]mmap_size(N)\n  **\n  ** Used to set mapping size limit. The mapping size limit is\n  ** used to limit the aggregate size of all memory mapped regions of the\n  ** database file. If this parameter is set to zero, then memory mapping\n  ** is not used at all.  If N is negative, then the default memory map\n  ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set.\n  ** The parameter N is measured in bytes.\n  **\n  ** This value is advisory.  The underlying VFS is free to memory map\n  ** as little or as much as it wants.  Except, if N is set to 0 then the\n  ** upper layers will never invoke the xFetch interfaces to the VFS.\n  */\n  case PragTyp_MMAP_SIZE: {\n    sqlite3_int64 sz;\n#if SQLITE_MAX_MMAP_SIZE>0\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( zRight ){\n      int ii;\n      sqlite3DecOrHexToI64(zRight, &sz);\n      if( sz<0 ) sz = sqlite3GlobalConfig.szMmap;\n      if( pId2->n==0 ) db->szMmap = sz;\n      for(ii=db->nDb-1; ii>=0; ii--){\n        if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n          sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz);\n        }\n      }\n    }\n    sz = -1;\n    rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);\n#else\n    sz = 0;\n    rc = SQLITE_OK;\n#endif\n    if( rc==SQLITE_OK ){\n      returnSingleInt(v, sz);\n    }else if( rc!=SQLITE_NOTFOUND ){\n      pParse->nErr++;\n      pParse->rc = rc;\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store\n  **   PRAGMA temp_store = \"default\"|\"memory\"|\"file\"\n  **\n  ** Return or set the local value of the temp_store flag.  Changing\n  ** the local value does not make changes to the disk file and the default\n  ** value will be restored the next time the database is opened.\n  **\n  ** Note that it is possible for the library compile-time options to\n  ** override this setting\n  */\n  case PragTyp_TEMP_STORE: {\n    if( !zRight ){\n      returnSingleInt(v, db->temp_store);\n    }else{\n      changeTempStorage(pParse, zRight);\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store_directory\n  **   PRAGMA temp_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the temp_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for temporary files.\n  ** Setting to a null string reverts to the default temporary directory search.\n  ** If temporary directory is changed, then invalidateTempStorage.\n  **\n  */\n  case PragTyp_TEMP_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_temp_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      if( SQLITE_TEMP_STORE==0\n       || (SQLITE_TEMP_STORE==1 && db->temp_store<=1)\n       || (SQLITE_TEMP_STORE==2 && db->temp_store==1)\n      ){\n        invalidateTempStorage(pParse);\n      }\n      sqlite3_free(sqlite3_temp_directory);\n      if( zRight[0] ){\n        sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_temp_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n\n#if SQLITE_OS_WIN\n  /*\n  **   PRAGMA data_store_directory\n  **   PRAGMA data_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the data_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for database files that\n  ** were specified with a relative pathname.  Setting to a null string reverts\n  ** to the default database directory, which for database files specified with\n  ** a relative path will probably be based on the current directory for the\n  ** process.  Database file specified with an absolute path are not impacted\n  ** by this setting, regardless of its value.\n  **\n  */\n  case PragTyp_DATA_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_data_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      sqlite3_free(sqlite3_data_directory);\n      if( zRight[0] ){\n        sqlite3_data_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_data_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n  /*\n  **   PRAGMA [schema.]lock_proxy_file\n  **   PRAGMA [schema.]lock_proxy_file = \":auto:\"|\"lock_file_path\"\n  **\n  ** Return or set the value of the lock_proxy_file flag.  Changing\n  ** the value sets a specific file to be used for database access locks.\n  **\n  */\n  case PragTyp_LOCK_PROXY_FILE: {\n    if( !zRight ){\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      char *proxy_file_path = NULL;\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, \n                           &proxy_file_path);\n      returnSingleText(v, proxy_file_path);\n    }else{\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      int res;\n      if( zRight[0] ){\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     zRight);\n      } else {\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     NULL);\n      }\n      if( res!=SQLITE_OK ){\n        sqlite3ErrorMsg(pParse, \"failed to set lock proxy file\");\n        goto pragma_out;\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */      \n    \n  /*\n  **   PRAGMA [schema.]synchronous\n  **   PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA\n  **\n  ** Return or set the local value of the synchronous flag.  Changing\n  ** the local value does not make changes to the disk file and the\n  ** default value will be restored the next time the database is\n  ** opened.\n  */\n  case PragTyp_SYNCHRONOUS: {\n    if( !zRight ){\n      returnSingleInt(v, pDb->safety_level-1);\n    }else{\n      if( !db->autoCommit ){\n        sqlite3ErrorMsg(pParse, \n            \"Safety level may not be changed inside a transaction\");\n      }else if( iDb!=1 ){\n        int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;\n        if( iLevel==0 ) iLevel = 1;\n        pDb->safety_level = iLevel;\n        pDb->bSyncSet = 1;\n        setAllPagerFlags(db);\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FLAG_PRAGMAS\n  case PragTyp_FLAG: {\n    if( zRight==0 ){\n      setPragmaResultColumnNames(v, pPragma);\n      returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );\n    }else{\n      int mask = pPragma->iArg;    /* Mask of bits to set or clear. */\n      if( db->autoCommit==0 ){\n        /* Foreign key support may not be enabled or disabled while not\n        ** in auto-commit mode.  */\n        mask &= ~(SQLITE_ForeignKeys);\n      }\n#if SQLITE_USER_AUTHENTICATION\n      if( db->auth.authLevel==UAUTH_User ){\n        /* Do not allow non-admin users to modify the schema arbitrarily */\n        mask &= ~(SQLITE_WriteSchema);\n      }\n#endif\n\n      if( sqlite3GetBoolean(zRight, 0) ){\n        db->flags |= mask;\n      }else{\n        db->flags &= ~mask;\n        if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;\n      }\n\n      /* Many of the flag-pragmas modify the code generated by the SQL \n      ** compiler (eg. count_changes). So add an opcode to expire all\n      ** compiled SQL statements after modifying a pragma value.\n      */\n      sqlite3VdbeAddOp0(v, OP_Expire);\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_FLAG_PRAGMAS */\n\n#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS\n  /*\n  **   PRAGMA table_info(<table>)\n  **\n  ** Return a single row for each column of the named table. The columns of\n  ** the returned data set are:\n  **\n  ** cid:        Column id (numbered from left to right, starting at 0)\n  ** name:       Column name\n  ** type:       Column declaration type.\n  ** notnull:    True if 'NOT NULL' is part of column declaration\n  ** dflt_value: The default value for the column, if any.\n  */\n  case PragTyp_TABLE_INFO: if( zRight ){\n    Table *pTab;\n    pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);\n    if( pTab ){\n      int i, k;\n      int nHidden = 0;\n      Column *pCol;\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      pParse->nMem = 6;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      sqlite3ViewGetColumnNames(pParse, pTab);\n      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n        if( IsHiddenColumn(pCol) ){\n          nHidden++;\n          continue;\n        }\n        if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){\n          k = 0;\n        }else if( pPk==0 ){\n          k = 1;\n        }else{\n          for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}\n        }\n        assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );\n        sqlite3VdbeMultiLoad(v, 1, \"issisi\",\n               i-nHidden,\n               pCol->zName,\n               sqlite3ColumnType(pCol,\"\"),\n               pCol->notNull ? 1 : 0,\n               pCol->pDflt ? pCol->pDflt->u.zToken : 0,\n               k);\n      }\n    }\n  }\n  break;\n\n#ifdef SQLITE_DEBUG\n  case PragTyp_STATS: {\n    Index *pIdx;\n    HashElem *i;\n    pParse->nMem = 5;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){\n      Table *pTab = sqliteHashData(i);\n      sqlite3VdbeMultiLoad(v, 1, \"ssiii\",\n           pTab->zName,\n           0,\n           pTab->szTabRow,\n           pTab->nRowLogEst,\n           pTab->tabFlags);\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        sqlite3VdbeMultiLoad(v, 2, \"siiiX\",\n           pIdx->zName,\n           pIdx->szIdxRow,\n           pIdx->aiRowLogEst[0],\n           pIdx->hasStat1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);\n      }\n    }\n  }\n  break;\n#endif\n\n  case PragTyp_INDEX_INFO: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    pIdx = sqlite3FindIndex(db, zRight, zDb);\n    if( pIdx ){\n      int i;\n      int mx;\n      if( pPragma->iArg ){\n        /* PRAGMA index_xinfo (newer version with more rows and columns) */\n        mx = pIdx->nColumn;\n        pParse->nMem = 6;\n      }else{\n        /* PRAGMA index_info (legacy version) */\n        mx = pIdx->nKeyCol;\n        pParse->nMem = 3;\n      }\n      pTab = pIdx->pTable;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      assert( pParse->nMem<=pPragma->nPragCName );\n      for(i=0; i<mx; i++){\n        i16 cnum = pIdx->aiColumn[i];\n        sqlite3VdbeMultiLoad(v, 1, \"iisX\", i, cnum,\n                             cnum<0 ? 0 : pTab->aCol[cnum].zName);\n        if( pPragma->iArg ){\n          sqlite3VdbeMultiLoad(v, 4, \"isiX\",\n            pIdx->aSortOrder[i],\n            pIdx->azColl[i],\n            i<pIdx->nKeyCol);\n        }\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_INDEX_LIST: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    int i;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      pParse->nMem = 5;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){\n        const char *azOrigin[] = { \"c\", \"u\", \"pk\" };\n        sqlite3VdbeMultiLoad(v, 1, \"isisi\",\n           i,\n           pIdx->zName,\n           IsUniqueIndex(pIdx),\n           azOrigin[pIdx->idxType],\n           pIdx->pPartIdxWhere!=0);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_DATABASE_LIST: {\n    int i;\n    pParse->nMem = 3;\n    for(i=0; i<db->nDb; i++){\n      if( db->aDb[i].pBt==0 ) continue;\n      assert( db->aDb[i].zDbSName!=0 );\n      sqlite3VdbeMultiLoad(v, 1, \"iss\",\n         i,\n         db->aDb[i].zDbSName,\n         sqlite3BtreeGetFilename(db->aDb[i].pBt));\n    }\n  }\n  break;\n\n  case PragTyp_COLLATION_LIST: {\n    int i = 0;\n    HashElem *p;\n    pParse->nMem = 2;\n    for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){\n      CollSeq *pColl = (CollSeq *)sqliteHashData(p);\n      sqlite3VdbeMultiLoad(v, 1, \"is\", i++, pColl->zName);\n    }\n  }\n  break;\n\n#ifdef SQLITE_INTROSPECTION_PRAGMAS\n  case PragTyp_FUNCTION_LIST: {\n    int i;\n    HashElem *j;\n    FuncDef *p;\n    pParse->nMem = 2;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){\n        sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 1);\n      }\n    }\n    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){\n      p = (FuncDef*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 0);\n    }\n  }\n  break;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  case PragTyp_MODULE_LIST: {\n    HashElem *j;\n    pParse->nMem = 1;\n    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){\n      Module *pMod = (Module*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"s\", pMod->zName);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  case PragTyp_PRAGMA_LIST: {\n    int i;\n    for(i=0; i<ArraySize(aPragmaName); i++){\n      sqlite3VdbeMultiLoad(v, 1, \"s\", aPragmaName[i].zName);\n    }\n  }\n  break;\n#endif /* SQLITE_INTROSPECTION_PRAGMAS */\n\n#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  case PragTyp_FOREIGN_KEY_LIST: if( zRight ){\n    FKey *pFK;\n    Table *pTab;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      pFK = pTab->pFKey;\n      if( pFK ){\n        int i = 0; \n        pParse->nMem = 8;\n        sqlite3CodeVerifySchema(pParse, iDb);\n        while(pFK){\n          int j;\n          for(j=0; j<pFK->nCol; j++){\n            sqlite3VdbeMultiLoad(v, 1, \"iissssss\",\n                   i,\n                   j,\n                   pFK->zTo,\n                   pTab->aCol[pFK->aCol[j].iFrom].zName,\n                   pFK->aCol[j].zCol,\n                   actionName(pFK->aAction[1]),  /* ON UPDATE */\n                   actionName(pFK->aAction[0]),  /* ON DELETE */\n                   \"NONE\");\n          }\n          ++i;\n          pFK = pFK->pNextFrom;\n        }\n      }\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n  case PragTyp_FOREIGN_KEY_CHECK: {\n    FKey *pFK;             /* A foreign key constraint */\n    Table *pTab;           /* Child table contain \"REFERENCES\" keyword */\n    Table *pParent;        /* Parent table that child points to */\n    Index *pIdx;           /* Index in the parent table */\n    int i;                 /* Loop counter:  Foreign key number for pTab */\n    int j;                 /* Loop counter:  Field of the foreign key */\n    HashElem *k;           /* Loop counter:  Next table in schema */\n    int x;                 /* result variable */\n    int regResult;         /* 3 registers to hold a result row */\n    int regKey;            /* Register to hold key for checking the FK */\n    int regRow;            /* Registers to hold a row from pTab */\n    int addrTop;           /* Top of a loop checking foreign keys */\n    int addrOk;            /* Jump here if the key is OK */\n    int *aiCols;           /* child to parent column mapping */\n\n    regResult = pParse->nMem+1;\n    pParse->nMem += 4;\n    regKey = ++pParse->nMem;\n    regRow = ++pParse->nMem;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);\n    while( k ){\n      if( zRight ){\n        pTab = sqlite3LocateTable(pParse, 0, zRight, zDb);\n        k = 0;\n      }else{\n        pTab = (Table*)sqliteHashData(k);\n        k = sqliteHashNext(k);\n      }\n      if( pTab==0 || pTab->pFKey==0 ) continue;\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n      if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;\n      sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeLoadString(v, regResult, pTab->zName);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        if( pParent==0 ) continue;\n        pIdx = 0;\n        sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);\n        x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);\n        if( x==0 ){\n          if( pIdx==0 ){\n            sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n          }\n        }else{\n          k = 0;\n          break;\n        }\n      }\n      assert( pParse->nErr>0 || pFK==0 );\n      if( pFK ) break;\n      if( pParse->nTab<i ) pParse->nTab = i;\n      addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        pIdx = 0;\n        aiCols = 0;\n        if( pParent ){\n          x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);\n          assert( x==0 );\n        }\n        addrOk = sqlite3VdbeMakeLabel(v);\n\n        /* Generate code to read the child key values into registers\n        ** regRow..regRow+n. If any of the child key values are NULL, this \n        ** row cannot cause an FK violation. Jump directly to addrOk in \n        ** this case. */\n        for(j=0; j<pFK->nCol; j++){\n          int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);\n        }\n\n        /* Generate code to query the parent index for a matching parent\n        ** key. If a match is found, jump to addrOk. */\n        if( pIdx ){\n          sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey,\n              sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);\n          sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);\n          VdbeCoverage(v);\n        }else if( pParent ){\n          int jmp = sqlite3VdbeCurrentAddr(v)+2;\n          sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v);\n          sqlite3VdbeGoto(v, addrOk);\n          assert( pFK->nCol==1 );\n        }\n\n        /* Generate code to report an FK violation to the caller. */\n        if( HasRowid(pTab) ){\n          sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);\n        }else{\n          sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);\n        }\n        sqlite3VdbeMultiLoad(v, regResult+2, \"siX\", pFK->zTo, i-1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);\n        sqlite3VdbeResolveLabel(v, addrOk);\n        sqlite3DbFree(db, aiCols);\n      }\n      sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrTop);\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef NDEBUG\n  case PragTyp_PARSER_TRACE: {\n    if( zRight ){\n      if( sqlite3GetBoolean(zRight, 0) ){\n        sqlite3ParserTrace(stdout, \"parser: \");\n      }else{\n        sqlite3ParserTrace(0, 0);\n      }\n    }\n  }\n  break;\n#endif\n\n  /* Reinstall the LIKE and GLOB functions.  The variant of LIKE\n  ** used will be case sensitive or not depending on the RHS.\n  */\n  case PragTyp_CASE_SENSITIVE_LIKE: {\n    if( zRight ){\n      sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0));\n    }\n  }\n  break;\n\n#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100\n#endif\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n  /*    PRAGMA integrity_check\n  **    PRAGMA integrity_check(N)\n  **    PRAGMA quick_check\n  **    PRAGMA quick_check(N)\n  **\n  ** Verify the integrity of the database.\n  **\n  ** The \"quick_check\" is reduced version of \n  ** integrity_check designed to detect most database corruption\n  ** without the overhead of cross-checking indexes.  Quick_check\n  ** is linear time wherease integrity_check is O(NlogN).\n  */\n  case PragTyp_INTEGRITY_CHECK: {\n    int i, j, addr, mxErr;\n\n    int isQuick = (sqlite3Tolower(zLeft[0])=='q');\n\n    /* If the PRAGMA command was of the form \"PRAGMA <db>.integrity_check\",\n    ** then iDb is set to the index of the database identified by <db>.\n    ** In this case, the integrity of database iDb only is verified by\n    ** the VDBE created below.\n    **\n    ** Otherwise, if the command was simply \"PRAGMA integrity_check\" (or\n    ** \"PRAGMA quick_check\"), then iDb is set to 0. In this case, set iDb\n    ** to -1 here, to indicate that the VDBE should verify the integrity\n    ** of all attached databases.  */\n    assert( iDb>=0 );\n    assert( iDb==0 || pId2->z );\n    if( pId2->z==0 ) iDb = -1;\n\n    /* Initialize the VDBE program */\n    pParse->nMem = 6;\n\n    /* Set the maximum error count */\n    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n    if( zRight ){\n      sqlite3GetInt32(zRight, &mxErr);\n      if( mxErr<=0 ){\n        mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */\n\n    /* Do an integrity check on each database file */\n    for(i=0; i<db->nDb; i++){\n      HashElem *x;     /* For looping over tables in the schema */\n      Hash *pTbls;     /* Set of all tables in the schema */\n      int *aRoot;      /* Array of root page numbers of all btrees */\n      int cnt = 0;     /* Number of entries in aRoot[] */\n      int mxIdx = 0;   /* Maximum number of indexes for any table */\n\n      if( OMIT_TEMPDB && i==1 ) continue;\n      if( iDb>=0 && i!=iDb ) continue;\n\n      sqlite3CodeVerifySchema(pParse, i);\n\n      /* Do an integrity check of the B-Tree\n      **\n      ** Begin by finding the root pages numbers\n      ** for all tables and indices in the database.\n      */\n      assert( sqlite3SchemaMutexHeld(db, i, 0) );\n      pTbls = &db->aDb[i].pSchema->tblHash;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);  /* Current table */\n        Index *pIdx;                      /* An index on pTab */\n        int nIdx;                         /* Number of indexes on pTab */\n        if( HasRowid(pTab) ) cnt++;\n        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }\n        if( nIdx>mxIdx ) mxIdx = nIdx;\n      }\n      aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));\n      if( aRoot==0 ) break;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx;\n        if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          aRoot[++cnt] = pIdx->tnum;\n        }\n      }\n      aRoot[0] = cnt;\n\n      /* Make sure sufficient number of registers have been allocated */\n      pParse->nMem = MAX( pParse->nMem, 8+mxIdx );\n      sqlite3ClearTempRegCache(pParse);\n\n      /* Do the b-tree integrity checks */\n      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);\n      sqlite3VdbeChangeP5(v, (u8)i);\n      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n         sqlite3MPrintf(db, \"*** in database %s ***\\n\", db->aDb[i].zDbSName),\n         P4_DYNAMIC);\n      sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);\n      integrityCheckResultRow(v);\n      sqlite3VdbeJumpHere(v, addr);\n\n      /* Make sure all the indices are constructed correctly.\n      */\n      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx, *pPk;\n        Index *pPrior = 0;\n        int loopTop;\n        int iDataCur, iIdxCur;\n        int r1 = -1;\n\n        if( pTab->tnum<1 ) continue;  /* Skip VIEWs or VIRTUAL TABLEs */\n        pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n        sqlite3ExprCacheClear(pParse);\n        sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,\n                                   1, 0, &iDataCur, &iIdxCur);\n        /* reg[7] counts the number of entries in the table.\n        ** reg[8+i] counts the number of entries in the i-th index \n        */\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);\n        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n          sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */\n        }\n        assert( pParse->nMem>=8+j );\n        assert( sqlite3NoTempsInRange(pParse,1,7+j) );\n        sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);\n        loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);\n        /* Verify that all NOT NULL columns really are NOT NULL */\n        for(j=0; j<pTab->nCol; j++){\n          char *zErr;\n          int jmp2;\n          if( j==pTab->iPKey ) continue;\n          if( pTab->aCol[j].notNull==0 ) continue;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n          jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);\n          zErr = sqlite3MPrintf(db, \"NULL value in %s.%s\", pTab->zName,\n                              pTab->aCol[j].zName);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n          integrityCheckResultRow(v);\n          sqlite3VdbeJumpHere(v, jmp2);\n        }\n        /* Verify CHECK constraints */\n        if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n          ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);\n          if( db->mallocFailed==0 ){\n            int addrCkFault = sqlite3VdbeMakeLabel(v);\n            int addrCkOk = sqlite3VdbeMakeLabel(v);\n            char *zErr;\n            int k;\n            pParse->iSelfTab = iDataCur + 1;\n            sqlite3ExprCachePush(pParse);\n            for(k=pCheck->nExpr-1; k>0; k--){\n              sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);\n            }\n            sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, \n                SQLITE_JUMPIFNULL);\n            sqlite3VdbeResolveLabel(v, addrCkFault);\n            pParse->iSelfTab = 0;\n            zErr = sqlite3MPrintf(db, \"CHECK constraint failed in %s\",\n                pTab->zName);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n            integrityCheckResultRow(v);\n            sqlite3VdbeResolveLabel(v, addrCkOk);\n            sqlite3ExprCachePop(pParse);\n          }\n          sqlite3ExprListDelete(db, pCheck);\n        }\n        if( !isQuick ){ /* Omit the remaining tests for quick_check */\n          /* Sanity check on record header decoding */\n          sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n          /* Validate index entries for the current row */\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            int jmp2, jmp3, jmp4, jmp5;\n            int ckUniq = sqlite3VdbeMakeLabel(v);\n            if( pPk==pIdx ) continue;\n            r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,\n                                         pPrior, r1);\n            pPrior = pIdx;\n            sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */\n            /* Verify that an index entry exists for the current table row */\n            jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,\n                                        pIdx->nColumn); VdbeCoverage(v);\n            sqlite3VdbeLoadString(v, 3, \"row \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);\n            sqlite3VdbeLoadString(v, 4, \" missing from index \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp4 = integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, jmp2);\n            /* For UNIQUE indexes, verify that only one entry exists with the\n            ** current key.  The entry is unique if (1) any column is NULL\n            ** or (2) the next entry has a different key */\n            if( IsUniqueIndex(pIdx) ){\n              int uniqOk = sqlite3VdbeMakeLabel(v);\n              int jmp6;\n              int kk;\n              for(kk=0; kk<pIdx->nKeyCol; kk++){\n                int iCol = pIdx->aiColumn[kk];\n                assert( iCol!=XN_ROWID && iCol<pTab->nCol );\n                if( iCol>=0 && pTab->aCol[iCol].notNull ) continue;\n                sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk);\n                VdbeCoverage(v);\n              }\n              jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);\n              sqlite3VdbeGoto(v, uniqOk);\n              sqlite3VdbeJumpHere(v, jmp6);\n              sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,\n                                   pIdx->nKeyCol); VdbeCoverage(v);\n              sqlite3VdbeLoadString(v, 3, \"non-unique entry in index \");\n              sqlite3VdbeGoto(v, jmp5);\n              sqlite3VdbeResolveLabel(v, uniqOk);\n            }\n            sqlite3VdbeJumpHere(v, jmp4);\n            sqlite3ResolvePartIdxLabel(pParse, jmp3);\n          }\n        }\n        sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);\n        sqlite3VdbeJumpHere(v, loopTop-1);\n#ifndef SQLITE_OMIT_BTREECOUNT\n        if( !isQuick ){\n          sqlite3VdbeLoadString(v, 2, \"wrong # of entries in index \");\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            if( pPk==pIdx ) continue;\n            sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);\n            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);\n            integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, addr);\n          }\n        }\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      } \n    }\n    {\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList endCode[] = {\n        { OP_AddImm,      1, 0,        0},    /* 0 */\n        { OP_IfNotZero,   1, 4,        0},    /* 1 */\n        { OP_String8,     0, 3,        0},    /* 2 */\n        { OP_ResultRow,   3, 1,        0},    /* 3 */\n        { OP_Halt,        0, 0,        0},    /* 4 */\n        { OP_String8,     0, 3,        0},    /* 5 */\n        { OP_Goto,        0, 3,        0},    /* 6 */\n      };\n      VdbeOp *aOp;\n\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);\n      if( aOp ){\n        aOp[0].p2 = 1-mxErr;\n        aOp[2].p4type = P4_STATIC;\n        aOp[2].p4.z = \"ok\";\n        aOp[5].p4type = P4_STATIC;\n        aOp[5].p4.z = (char*)sqlite3ErrStr(SQLITE_CORRUPT);\n      }\n      sqlite3VdbeChangeP3(v, 0, sqlite3VdbeCurrentAddr(v)-2);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_UTF16\n  /*\n  **   PRAGMA encoding\n  **   PRAGMA encoding = \"utf-8\"|\"utf-16\"|\"utf-16le\"|\"utf-16be\"\n  **\n  ** In its first form, this pragma returns the encoding of the main\n  ** database. If the database is not initialized, it is initialized now.\n  **\n  ** The second form of this pragma is a no-op if the main database file\n  ** has not already been initialized. In this case it sets the default\n  ** encoding that will be used for the main database file if a new file\n  ** is created. If an existing main database file is opened, then the\n  ** default text encoding for the existing database is used.\n  ** \n  ** In all cases new databases created using the ATTACH command are\n  ** created to use the same default text encoding as the main database. If\n  ** the main database has not been initialized and/or created when ATTACH\n  ** is executed, this is done before the ATTACH operation.\n  **\n  ** In the second form this pragma sets the text encoding to be used in\n  ** new database files created using this database handle. It is only\n  ** useful if invoked immediately after the main database i\n  */\n  case PragTyp_ENCODING: {\n    static const struct EncName {\n      char *zName;\n      u8 enc;\n    } encnames[] = {\n      { \"UTF8\",     SQLITE_UTF8        },\n      { \"UTF-8\",    SQLITE_UTF8        },  /* Must be element [1] */\n      { \"UTF-16le\", SQLITE_UTF16LE     },  /* Must be element [2] */\n      { \"UTF-16be\", SQLITE_UTF16BE     },  /* Must be element [3] */\n      { \"UTF16le\",  SQLITE_UTF16LE     },\n      { \"UTF16be\",  SQLITE_UTF16BE     },\n      { \"UTF-16\",   0                  }, /* SQLITE_UTF16NATIVE */\n      { \"UTF16\",    0                  }, /* SQLITE_UTF16NATIVE */\n      { 0, 0 }\n    };\n    const struct EncName *pEnc;\n    if( !zRight ){    /* \"PRAGMA encoding\" */\n      if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n      assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );\n      assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );\n      assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );\n      returnSingleText(v, encnames[ENC(pParse->db)].zName);\n    }else{                        /* \"PRAGMA encoding = XXX\" */\n      /* Only change the value of sqlite.enc if the database handle is not\n      ** initialized. If the main database exists, the new sqlite.enc value\n      ** will be overwritten when the schema is next loaded. If it does not\n      ** already exists, it will be created to use the new encoding value.\n      */\n      if( \n        !(DbHasProperty(db, 0, DB_SchemaLoaded)) || \n        DbHasProperty(db, 0, DB_Empty) \n      ){\n        for(pEnc=&encnames[0]; pEnc->zName; pEnc++){\n          if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){\n            SCHEMA_ENC(db) = ENC(db) =\n                pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;\n            break;\n          }\n        }\n        if( !pEnc->zName ){\n          sqlite3ErrorMsg(pParse, \"unsupported encoding: %s\", zRight);\n        }\n      }\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  /*\n  **   PRAGMA [schema.]schema_version\n  **   PRAGMA [schema.]schema_version = <integer>\n  **\n  **   PRAGMA [schema.]user_version\n  **   PRAGMA [schema.]user_version = <integer>\n  **\n  **   PRAGMA [schema.]freelist_count\n  **\n  **   PRAGMA [schema.]data_version\n  **\n  **   PRAGMA [schema.]application_id\n  **   PRAGMA [schema.]application_id = <integer>\n  **\n  ** The pragma's schema_version and user_version are used to set or get\n  ** the value of the schema-version and user-version, respectively. Both\n  ** the schema-version and the user-version are 32-bit signed integers\n  ** stored in the database header.\n  **\n  ** The schema-cookie is usually only manipulated internally by SQLite. It\n  ** is incremented by SQLite whenever the database schema is modified (by\n  ** creating or dropping a table or index). The schema version is used by\n  ** SQLite each time a query is executed to ensure that the internal cache\n  ** of the schema used when compiling the SQL query matches the schema of\n  ** the database against which the compiled query is actually executed.\n  ** Subverting this mechanism by using \"PRAGMA schema_version\" to modify\n  ** the schema-version is potentially dangerous and may lead to program\n  ** crashes or database corruption. Use with caution!\n  **\n  ** The user-version is not used internally by SQLite. It may be used by\n  ** applications for any purpose.\n  */\n  case PragTyp_HEADER_VALUE: {\n    int iCookie = pPragma->iArg;  /* Which cookie to read or write */\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( zRight && (pPragma->mPragFlg & PragFlg_ReadOnly)==0 ){\n      /* Write the specified cookie value */\n      static const VdbeOpList setCookie[] = {\n        { OP_Transaction,    0,  1,  0},    /* 0 */\n        { OP_SetCookie,      0,  0,  0},    /* 1 */\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p2 = iCookie;\n      aOp[1].p3 = sqlite3Atoi(zRight);\n    }else{\n      /* Read the specified cookie value */\n      static const VdbeOpList readCookie[] = {\n        { OP_Transaction,     0,  0,  0},    /* 0 */\n        { OP_ReadCookie,      0,  1,  0},    /* 1 */\n        { OP_ResultRow,       1,  1,  0}\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p3 = iCookie;\n      sqlite3VdbeReusable(v);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  /*\n  **   PRAGMA compile_options\n  **\n  ** Return the names of all compile-time options used in this build,\n  ** one option per row.\n  */\n  case PragTyp_COMPILE_OPTIONS: {\n    int i = 0;\n    const char *zOpt;\n    pParse->nMem = 1;\n    while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){\n      sqlite3VdbeLoadString(v, 1, zOpt);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    }\n    sqlite3VdbeReusable(v);\n  }\n  break;\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n#ifndef SQLITE_OMIT_WAL\n  /*\n  **   PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate\n  **\n  ** Checkpoint the database.\n  */\n  case PragTyp_WAL_CHECKPOINT: {\n    int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);\n    int eMode = SQLITE_CHECKPOINT_PASSIVE;\n    if( zRight ){\n      if( sqlite3StrICmp(zRight, \"full\")==0 ){\n        eMode = SQLITE_CHECKPOINT_FULL;\n      }else if( sqlite3StrICmp(zRight, \"restart\")==0 ){\n        eMode = SQLITE_CHECKPOINT_RESTART;\n      }else if( sqlite3StrICmp(zRight, \"truncate\")==0 ){\n        eMode = SQLITE_CHECKPOINT_TRUNCATE;\n      }\n    }\n    pParse->nMem = 3;\n    sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n  }\n  break;\n\n  /*\n  **   PRAGMA wal_autocheckpoint\n  **   PRAGMA wal_autocheckpoint = N\n  **\n  ** Configure a database connection to automatically checkpoint a database\n  ** after accumulating N frames in the log. Or query for the current value\n  ** of N.\n  */\n  case PragTyp_WAL_AUTOCHECKPOINT: {\n    if( zRight ){\n      sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, \n       db->xWalCallback==sqlite3WalDefaultHook ? \n           SQLITE_PTR_TO_INT(db->pWalArg) : 0);\n  }\n  break;\n#endif\n\n  /*\n  **  PRAGMA shrink_memory\n  **\n  ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database\n  ** connection on which it is invoked to free up as much memory as it\n  ** can, by calling sqlite3_db_release_memory().\n  */\n  case PragTyp_SHRINK_MEMORY: {\n    sqlite3_db_release_memory(db);\n    break;\n  }\n\n  /*\n  **  PRAGMA optimize\n  **  PRAGMA optimize(MASK)\n  **  PRAGMA schema.optimize\n  **  PRAGMA schema.optimize(MASK)\n  **\n  ** Attempt to optimize the database.  All schemas are optimized in the first\n  ** two forms, and only the specified schema is optimized in the latter two.\n  **\n  ** The details of optimizations performed by this pragma are expected\n  ** to change and improve over time.  Applications should anticipate that\n  ** this pragma will perform new optimizations in future releases.\n  **\n  ** The optional argument is a bitmask of optimizations to perform:\n  **\n  **    0x0001    Debugging mode.  Do not actually perform any optimizations\n  **              but instead return one line of text for each optimization\n  **              that would have been done.  Off by default.\n  **\n  **    0x0002    Run ANALYZE on tables that might benefit.  On by default.\n  **              See below for additional information.\n  **\n  **    0x0004    (Not yet implemented) Record usage and performance \n  **              information from the current session in the\n  **              database file so that it will be available to \"optimize\"\n  **              pragmas run by future database connections.\n  **\n  **    0x0008    (Not yet implemented) Create indexes that might have\n  **              been helpful to recent queries\n  **\n  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all\n  ** of the optimizations listed above except Debug Mode, including new\n  ** optimizations that have not yet been invented.  If new optimizations are\n  ** ever added that should be off by default, those off-by-default \n  ** optimizations will have bitmasks of 0x10000 or larger.\n  **\n  ** DETERMINATION OF WHEN TO RUN ANALYZE\n  **\n  ** In the current implementation, a table is analyzed if only if all of\n  ** the following are true:\n  **\n  ** (1) MASK bit 0x02 is set.\n  **\n  ** (2) The query planner used sqlite_stat1-style statistics for one or\n  **     more indexes of the table at some point during the lifetime of\n  **     the current connection.\n  **\n  ** (3) One or more indexes of the table are currently unanalyzed OR\n  **     the number of rows in the table has increased by 25 times or more\n  **     since the last time ANALYZE was run.\n  **\n  ** The rules for when tables are analyzed are likely to change in\n  ** future releases.\n  */\n  case PragTyp_OPTIMIZE: {\n    int iDbLast;           /* Loop termination point for the schema loop */\n    int iTabCur;           /* Cursor for a table whose size needs checking */\n    HashElem *k;           /* Loop over tables of a schema */\n    Schema *pSchema;       /* The current schema */\n    Table *pTab;           /* A table in the schema */\n    Index *pIdx;           /* An index of the table */\n    LogEst szThreshold;    /* Size threshold above which reanalysis is needd */\n    char *zSubSql;         /* SQL statement for the OP_SqlExec opcode */\n    u32 opMask;            /* Mask of operations to perform */\n\n    if( zRight ){\n      opMask = (u32)sqlite3Atoi(zRight);\n      if( (opMask & 0x02)==0 ) break;\n    }else{\n      opMask = 0xfffe;\n    }\n    iTabCur = pParse->nTab++;\n    for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){\n      if( iDb==1 ) continue;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      pSchema = db->aDb[iDb].pSchema;\n      for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n        pTab = (Table*)sqliteHashData(k);\n\n        /* If table pTab has not been used in a way that would benefit from\n        ** having analysis statistics during the current session, then skip it.\n        ** This also has the effect of skipping virtual tables and views */\n        if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;\n\n        /* Reanalyze if the table is 25 times larger than the last analysis */\n        szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( !pIdx->hasStat1 ){\n            szThreshold = 0; /* Always analyze if any index lacks statistics */\n            break;\n          }\n        }\n        if( szThreshold ){\n          sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n          sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur, \n                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);\n          VdbeCoverage(v);\n        }\n        zSubSql = sqlite3MPrintf(db, \"ANALYZE \\\"%w\\\".\\\"%w\\\"\",\n                                 db->aDb[iDb].zDbSName, pTab->zName);\n        if( opMask & 0x01 ){\n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);\n          sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);\n        }else{\n          sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);\n        }\n      }\n    }\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    break;\n  }\n\n  /*\n  **   PRAGMA busy_timeout\n  **   PRAGMA busy_timeout = N\n  **\n  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value\n  ** if one is set.  If no busy handler or a different busy handler is set\n  ** then 0 is returned.  Setting the busy_timeout to 0 or negative\n  ** disables the timeout.\n  */\n  /*case PragTyp_BUSY_TIMEOUT*/ default: {\n    assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT );\n    if( zRight ){\n      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, db->busyTimeout);\n    break;\n  }\n\n  /*\n  **   PRAGMA soft_heap_limit\n  **   PRAGMA soft_heap_limit = N\n  **\n  ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the\n  ** sqlite3_soft_heap_limit64() interface with the argument N, if N is\n  ** specified and is a non-negative integer.\n  ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always\n  ** returns the same integer that would be returned by the\n  ** sqlite3_soft_heap_limit64(-1) C-language function.\n  */\n  case PragTyp_SOFT_HEAP_LIMIT: {\n    sqlite3_int64 N;\n    if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){\n      sqlite3_soft_heap_limit64(N);\n    }\n    returnSingleInt(v, sqlite3_soft_heap_limit64(-1));\n    break;\n  }\n\n  /*\n  **   PRAGMA threads\n  **   PRAGMA threads = N\n  **\n  ** Configure the maximum number of worker threads.  Return the new\n  ** maximum, which might be less than requested.\n  */\n  case PragTyp_THREADS: {\n    sqlite3_int64 N;\n    if( zRight\n     && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK\n     && N>=0\n    ){\n      sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, (int)(N&0x7fffffff));\n    }\n    returnSingleInt(v, sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1));\n    break;\n  }\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Report the current state of file logs for all databases\n  */\n  case PragTyp_LOCK_STATUS: {\n    static const char *const azLockName[] = {\n      \"unlocked\", \"shared\", \"reserved\", \"pending\", \"exclusive\"\n    };\n    int i;\n    pParse->nMem = 2;\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt;\n      const char *zState = \"unknown\";\n      int j;\n      if( db->aDb[i].zDbSName==0 ) continue;\n      pBt = db->aDb[i].pBt;\n      if( pBt==0 || sqlite3BtreePager(pBt)==0 ){\n        zState = \"closed\";\n      }else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0, \n                                     SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){\n         zState = azLockName[j];\n      }\n      sqlite3VdbeMultiLoad(v, 1, \"ss\", db->aDb[i].zDbSName, zState);\n    }\n    break;\n  }\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n  case PragTyp_KEY: {\n    if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight));\n    break;\n  }\n  case PragTyp_REKEY: {\n    if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));\n    break;\n  }\n  case PragTyp_HEXKEY: {\n    if( zRight ){\n      u8 iByte;\n      int i;\n      char zKey[40];\n      for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){\n        iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);\n        if( (i&1)!=0 ) zKey[i/2] = iByte;\n      }\n      if( (zLeft[3] & 0xf)==0xb ){\n        sqlite3_key_v2(db, zDb, zKey, i/2);\n      }else{\n        sqlite3_rekey_v2(db, zDb, zKey, i/2);\n      }\n    }\n    break;\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n  case PragTyp_ACTIVATE_EXTENSIONS: if( zRight ){\n#ifdef SQLITE_HAS_CODEC\n    if( sqlite3StrNICmp(zRight, \"see-\", 4)==0 ){\n      sqlite3_activate_see(&zRight[4]);\n    }\n#endif\n#ifdef SQLITE_ENABLE_CEROD\n    if( sqlite3StrNICmp(zRight, \"cerod-\", 6)==0 ){\n      sqlite3_activate_cerod(&zRight[6]);\n    }\n#endif\n  }\n  break;\n#endif\n\n  } /* End of the PRAGMA switch */\n\n  /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only\n  ** purpose is to execute assert() statements to verify that if the\n  ** PragFlg_NoColumns1 flag is set and the caller specified an argument\n  ** to the PRAGMA, the implementation has not added any OP_ResultRow \n  ** instructions to the VM.  */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns1) && zRight ){\n    sqlite3VdbeVerifyNoResultRow(v);\n  }\n\npragma_out:\n  sqlite3DbFree(db, zLeft);\n  sqlite3DbFree(db, zRight);\n}\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*****************************************************************************\n** Implementation of an eponymous virtual table that runs a pragma.\n**\n*/\ntypedef struct PragmaVtab PragmaVtab;\ntypedef struct PragmaVtabCursor PragmaVtabCursor;\nstruct PragmaVtab {\n  sqlite3_vtab base;        /* Base class.  Must be first */\n  sqlite3 *db;              /* The database connection to which it belongs */\n  const PragmaName *pName;  /* Name of the pragma */\n  u8 nHidden;               /* Number of hidden columns */\n  u8 iHidden;               /* Index of the first hidden column */\n};\nstruct PragmaVtabCursor {\n  sqlite3_vtab_cursor base; /* Base class.  Must be first */\n  sqlite3_stmt *pPragma;    /* The pragma statement to run */\n  sqlite_int64 iRowid;      /* Current rowid */\n  char *azArg[2];           /* Value of the argument and schema */\n};\n\n/* \n** Pragma virtual table module xConnect method.\n*/\nstatic int pragmaVtabConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  const PragmaName *pPragma = (const PragmaName*)pAux;\n  PragmaVtab *pTab = 0;\n  int rc;\n  int i, j;\n  char cSep = '(';\n  StrAccum acc;\n  char zBuf[200];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  sqlite3StrAccumAppendAll(&acc, \"CREATE TABLE x\");\n  for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){\n    sqlite3XPrintf(&acc, \"%c\\\"%s\\\"\", cSep, pragCName[j]);\n    cSep = ',';\n  }\n  if( i==0 ){\n    sqlite3XPrintf(&acc, \"(\\\"%s\\\"\", pPragma->zName);\n    cSep = ',';\n    i++;\n  }\n  j = 0;\n  if( pPragma->mPragFlg & PragFlg_Result1 ){\n    sqlite3StrAccumAppendAll(&acc, \",arg HIDDEN\");\n    j++;\n  }\n  if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){\n    sqlite3StrAccumAppendAll(&acc, \",schema HIDDEN\");\n    j++;\n  }\n  sqlite3StrAccumAppend(&acc, \")\", 1);\n  sqlite3StrAccumFinish(&acc);\n  assert( strlen(zBuf) < sizeof(zBuf)-1 );\n  rc = sqlite3_declare_vtab(db, zBuf);\n  if( rc==SQLITE_OK ){\n    pTab = (PragmaVtab*)sqlite3_malloc(sizeof(PragmaVtab));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pTab, 0, sizeof(PragmaVtab));\n      pTab->pName = pPragma;\n      pTab->db = db;\n      pTab->iHidden = i;\n      pTab->nHidden = j;\n    }\n  }else{\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/* \n** Pragma virtual table module xDisconnect method.\n*/\nstatic int pragmaVtabDisconnect(sqlite3_vtab *pVtab){\n  PragmaVtab *pTab = (PragmaVtab*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/* Figure out the best index to use to search a pragma virtual table.\n**\n** There are not really any index choices.  But we want to encourage the\n** query planner to give == constraints on as many hidden parameters as\n** possible, and especially on the first hidden parameter.  So return a\n** high cost if hidden parameters are unconstrained.\n*/\nstatic int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  PragmaVtab *pTab = (PragmaVtab*)tab;\n  const struct sqlite3_index_constraint *pConstraint;\n  int i, j;\n  int seen[2];\n\n  pIdxInfo->estimatedCost = (double)1;\n  if( pTab->nHidden==0 ){ return SQLITE_OK; }\n  pConstraint = pIdxInfo->aConstraint;\n  seen[0] = 0;\n  seen[1] = 0;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( pConstraint->iColumn < pTab->iHidden ) continue;\n    j = pConstraint->iColumn - pTab->iHidden;\n    assert( j < 2 );\n    seen[j] = i+1;\n  }\n  if( seen[0]==0 ){\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n    return SQLITE_OK;\n  }\n  j = seen[0]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 1;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  if( seen[1]==0 ) return SQLITE_OK;\n  pIdxInfo->estimatedCost = (double)20;\n  pIdxInfo->estimatedRows = 20;\n  j = seen[1]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 2;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  return SQLITE_OK;\n}\n\n/* Create a new cursor for the pragma virtual table */\nstatic int pragmaVtabOpen(sqlite3_vtab *pVtab, sqlite3_vtab_cursor **ppCursor){\n  PragmaVtabCursor *pCsr;\n  pCsr = (PragmaVtabCursor*)sqlite3_malloc(sizeof(*pCsr));\n  if( pCsr==0 ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(PragmaVtabCursor));\n  pCsr->base.pVtab = pVtab;\n  *ppCursor = &pCsr->base;\n  return SQLITE_OK;\n}\n\n/* Clear all content from pragma virtual table cursor. */\nstatic void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){\n  int i;\n  sqlite3_finalize(pCsr->pPragma);\n  pCsr->pPragma = 0;\n  for(i=0; i<ArraySize(pCsr->azArg); i++){\n    sqlite3_free(pCsr->azArg[i]);\n    pCsr->azArg[i] = 0;\n  }\n}\n\n/* Close a pragma virtual table cursor */\nstatic int pragmaVtabClose(sqlite3_vtab_cursor *cur){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)cur;\n  pragmaVtabCursorClear(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/* Advance the pragma virtual table cursor to the next row */\nstatic int pragmaVtabNext(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Increment the xRowid value */\n  pCsr->iRowid++;\n  assert( pCsr->pPragma );\n  if( SQLITE_ROW!=sqlite3_step(pCsr->pPragma) ){\n    rc = sqlite3_finalize(pCsr->pPragma);\n    pCsr->pPragma = 0;\n    pragmaVtabCursorClear(pCsr);\n  }\n  return rc;\n}\n\n/* \n** Pragma virtual table module xFilter method.\n*/\nstatic int pragmaVtabFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  int rc;\n  int i, j;\n  StrAccum acc;\n  char *zSql;\n\n  UNUSED_PARAMETER(idxNum);\n  UNUSED_PARAMETER(idxStr);\n  pragmaVtabCursorClear(pCsr);\n  j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;\n  for(i=0; i<argc; i++, j++){\n    const char *zText = (const char*)sqlite3_value_text(argv[i]);\n    assert( j<ArraySize(pCsr->azArg) );\n    assert( pCsr->azArg[j]==0 );\n    if( zText ){\n      pCsr->azArg[j] = sqlite3_mprintf(\"%s\", zText);\n      if( pCsr->azArg[j]==0 ){\n        return SQLITE_NOMEM;\n      }\n    }\n  }\n  sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);\n  sqlite3StrAccumAppendAll(&acc, \"PRAGMA \");\n  if( pCsr->azArg[1] ){\n    sqlite3XPrintf(&acc, \"%Q.\", pCsr->azArg[1]);\n  }\n  sqlite3StrAccumAppendAll(&acc, pTab->pName->zName);\n  if( pCsr->azArg[0] ){\n    sqlite3XPrintf(&acc, \"=%Q\", pCsr->azArg[0]);\n  }\n  zSql = sqlite3StrAccumFinish(&acc);\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);\n  sqlite3_free(zSql);\n  if( rc!=SQLITE_OK ){\n    pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pTab->db));\n    return rc;\n  }\n  return pragmaVtabNext(pVtabCursor);\n}\n\n/*\n** Pragma virtual table module xEof method.\n*/\nstatic int pragmaVtabEof(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  return (pCsr->pPragma==0);\n}\n\n/* The xColumn method simply returns the corresponding column from\n** the PRAGMA.  \n*/\nstatic int pragmaVtabColumn(\n  sqlite3_vtab_cursor *pVtabCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  if( i<pTab->iHidden ){\n    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pPragma, i));\n  }else{\n    sqlite3_result_text(ctx, pCsr->azArg[i-pTab->iHidden],-1,SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Pragma virtual table module xRowid method.\n*/\nstatic int pragmaVtabRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *p){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  *p = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/* The pragma virtual table object */\nstatic const sqlite3_module pragmaVtabModule = {\n  0,                           /* iVersion */\n  0,                           /* xCreate - create a table */\n  pragmaVtabConnect,           /* xConnect - connect to an existing table */\n  pragmaVtabBestIndex,         /* xBestIndex - Determine search strategy */\n  pragmaVtabDisconnect,        /* xDisconnect - Disconnect from a table */\n  0,                           /* xDestroy - Drop a table */\n  pragmaVtabOpen,              /* xOpen - open a cursor */\n  pragmaVtabClose,             /* xClose - close a cursor */\n  pragmaVtabFilter,            /* xFilter - configure scan constraints */\n  pragmaVtabNext,              /* xNext - advance a cursor */\n  pragmaVtabEof,               /* xEof */\n  pragmaVtabColumn,            /* xColumn - read data */\n  pragmaVtabRowid,             /* xRowid - read data */\n  0,                           /* xUpdate - write data */\n  0,                           /* xBegin - begin transaction */\n  0,                           /* xSync - sync transaction */\n  0,                           /* xCommit - commit transaction */\n  0,                           /* xRollback - rollback transaction */\n  0,                           /* xFindFunction - function overloading */\n  0,                           /* xRename - rename the table */\n  0,                           /* xSavepoint */\n  0,                           /* xRelease */\n  0                            /* xRollbackTo */\n};\n\n/*\n** Check to see if zTabName is really the name of a pragma.  If it is,\n** then register an eponymous virtual table for that pragma and return\n** a pointer to the Module object for the new virtual table.\n*/\nSQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3 *db, const char *zName){\n  const PragmaName *pName;\n  assert( sqlite3_strnicmp(zName, \"pragma_\", 7)==0 );\n  pName = pragmaLocate(zName+7);\n  if( pName==0 ) return 0;\n  if( (pName->mPragFlg & (PragFlg_Result0|PragFlg_Result1))==0 ) return 0;\n  assert( sqlite3HashFind(&db->aModule, zName)==0 );\n  return sqlite3VtabCreateModule(db, zName, &pragmaVtabModule, (void*)pName, 0);\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#endif /* SQLITE_OMIT_PRAGMA */\n\n/************** End of pragma.c **********************************************/\n/************** Begin file prepare.c *****************************************/\n/*\n** 2005 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_prepare()\n** interface, and routines that contribute to loading the database schema\n** from disk.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Fill the InitData structure with an error message that indicates\n** that the database is corrupt.\n*/\nstatic void corruptSchema(\n  InitData *pData,     /* Initialization context */\n  const char *zObj,    /* Object being parsed at the point of error */\n  const char *zExtra   /* Error information */\n){\n  sqlite3 *db = pData->db;\n  if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){\n    char *z;\n    if( zObj==0 ) zObj = \"?\";\n    z = sqlite3MPrintf(db, \"malformed database schema (%s)\", zObj);\n    if( zExtra ) z = sqlite3MPrintf(db, \"%z - %s\", z, zExtra);\n    sqlite3DbFree(db, *pData->pzErrMsg);\n    *pData->pzErrMsg = z;\n  }\n  pData->rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** This is the callback routine for the code that initializes the\n** database.  See sqlite3Init() below for additional information.\n** This routine is also called from the OP_ParseSchema opcode of the VDBE.\n**\n** Each callback contains the following information:\n**\n**     argv[0] = name of thing being created\n**     argv[1] = root page number for table or index. 0 for trigger or view.\n**     argv[2] = SQL text for the CREATE statement.\n**\n*/\nSQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){\n  InitData *pData = (InitData*)pInit;\n  sqlite3 *db = pData->db;\n  int iDb = pData->iDb;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n  assert( sqlite3_mutex_held(db->mutex) );\n  DbClearProperty(db, iDb, DB_Empty);\n  if( db->mallocFailed ){\n    corruptSchema(pData, argv[0], 0);\n    return 1;\n  }\n\n  assert( iDb>=0 && iDb<db->nDb );\n  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */\n  if( argv[1]==0 ){\n    corruptSchema(pData, argv[0], 0);\n  }else if( sqlite3_strnicmp(argv[2],\"create \",7)==0 ){\n    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.\n    ** But because db->init.busy is set to 1, no VDBE code is generated\n    ** or executed.  All the parser does is build the internal data\n    ** structures that describe the table, index, or view.\n    */\n    int rc;\n    u8 saved_iDb = db->init.iDb;\n    sqlite3_stmt *pStmt;\n    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */\n\n    assert( db->init.busy );\n    db->init.iDb = iDb;\n    db->init.newTnum = sqlite3Atoi(argv[1]);\n    db->init.orphanTrigger = 0;\n    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);\n    rc = db->errCode;\n    assert( (rc&0xFF)==(rcp&0xFF) );\n    db->init.iDb = saved_iDb;\n    assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 );\n    if( SQLITE_OK!=rc ){\n      if( db->init.orphanTrigger ){\n        assert( iDb==1 );\n      }else{\n        pData->rc = rc;\n        if( rc==SQLITE_NOMEM ){\n          sqlite3OomFault(db);\n        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){\n          corruptSchema(pData, argv[0], sqlite3_errmsg(db));\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){\n    corruptSchema(pData, argv[0], 0);\n  }else{\n    /* If the SQL column is blank it means this is an index that\n    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE\n    ** constraint for a CREATE TABLE.  The index should have already\n    ** been created when we processed the CREATE TABLE.  All we have\n    ** to do here is record the root page number for that index.\n    */\n    Index *pIndex;\n    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);\n    if( pIndex==0 ){\n      /* This can occur if there exists an index on a TEMP table which\n      ** has the same name as another index on a permanent index.  Since\n      ** the permanent table is hidden by the TEMP table, we can also\n      ** safely ignore the index on the permanent table.\n      */\n      /* Do Nothing */;\n    }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){\n      corruptSchema(pData, argv[0], \"invalid rootpage\");\n    }\n  }\n  return 0;\n}\n\n/*\n** Attempt to read the database schema and initialize internal\n** data structures for a single database file.  The index of the\n** database file is given by iDb.  iDb==0 is used for the main\n** database.  iDb==1 should never be used.  iDb>=2 is used for\n** auxiliary databases.  Return one of the SQLITE_ error codes to\n** indicate success or failure.\n*/\nstatic int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){\n  int rc;\n  int i;\n#ifndef SQLITE_OMIT_DEPRECATED\n  int size;\n#endif\n  Db *pDb;\n  char const *azArg[4];\n  int meta[5];\n  InitData initData;\n  const char *zMasterName;\n  int openedTransaction = 0;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n\n  db->init.busy = 1;\n\n  /* Construct the in-memory representation schema tables (sqlite_master or\n  ** sqlite_temp_master) by invoking the parser directly.  The appropriate\n  ** table name will be inserted automatically by the parser so we can just\n  ** use the abbreviation \"x\" here.  The parser will also automatically tag\n  ** the schema table as read-only. */\n  azArg[0] = zMasterName = SCHEMA_TABLE(iDb);\n  azArg[1] = \"1\";\n  azArg[2] = \"CREATE TABLE x(type text,name text,tbl_name text,\"\n                            \"rootpage int,sql text)\";\n  azArg[3] = 0;\n  initData.db = db;\n  initData.iDb = iDb;\n  initData.rc = SQLITE_OK;\n  initData.pzErrMsg = pzErrMsg;\n  sqlite3InitCallback(&initData, 3, (char **)azArg, 0);\n  if( initData.rc ){\n    rc = initData.rc;\n    goto error_out;\n  }\n\n  /* Create a cursor to hold the database open\n  */\n  pDb = &db->aDb[iDb];\n  if( pDb->pBt==0 ){\n    assert( iDb==1 );\n    DbSetProperty(db, 1, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n    goto error_out;\n  }\n\n  /* If there is not already a read-only (or read-write) transaction opened\n  ** on the b-tree database, open one now. If a transaction is opened, it \n  ** will be closed before this function returns.  */\n  sqlite3BtreeEnter(pDb->pBt);\n  if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){\n    rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));\n      goto initone_error_out;\n    }\n    openedTransaction = 1;\n  }\n\n  /* Get the database meta information.\n  **\n  ** Meta values are as follows:\n  **    meta[0]   Schema cookie.  Changes with each schema change.\n  **    meta[1]   File format of schema layer.\n  **    meta[2]   Size of the page cache.\n  **    meta[3]   Largest rootpage (auto/incr_vacuum mode)\n  **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE\n  **    meta[5]   User version\n  **    meta[6]   Incremental vacuum mode\n  **    meta[7]   unused\n  **    meta[8]   unused\n  **    meta[9]   unused\n  **\n  ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to\n  ** the possible values of meta[4].\n  */\n  for(i=0; i<ArraySize(meta); i++){\n    sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);\n  }\n  pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];\n\n  /* If opening a non-empty database, check the text encoding. For the\n  ** main database, set sqlite3.enc to the encoding of the main database.\n  ** For an attached db, it is an error if the encoding is not the same\n  ** as sqlite3.enc.\n  */\n  if( meta[BTREE_TEXT_ENCODING-1] ){  /* text encoding */\n    if( iDb==0 ){\n#ifndef SQLITE_OMIT_UTF16\n      u8 encoding;\n      /* If opening the main database, set ENC(db). */\n      encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;\n      if( encoding==0 ) encoding = SQLITE_UTF8;\n      ENC(db) = encoding;\n#else\n      ENC(db) = SQLITE_UTF8;\n#endif\n    }else{\n      /* If opening an attached database, the encoding much match ENC(db) */\n      if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){\n        sqlite3SetString(pzErrMsg, db, \"attached databases must use the same\"\n            \" text encoding as main database\");\n        rc = SQLITE_ERROR;\n        goto initone_error_out;\n      }\n    }\n  }else{\n    DbSetProperty(db, iDb, DB_Empty);\n  }\n  pDb->pSchema->enc = ENC(db);\n\n  if( pDb->pSchema->cache_size==0 ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    size = sqlite3AbsInt32(meta[BTREE_DEFAULT_CACHE_SIZE-1]);\n    if( size==0 ){ size = SQLITE_DEFAULT_CACHE_SIZE; }\n    pDb->pSchema->cache_size = size;\n#else\n    pDb->pSchema->cache_size = SQLITE_DEFAULT_CACHE_SIZE;\n#endif\n    sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n  }\n\n  /*\n  ** file_format==1    Version 3.0.0.\n  ** file_format==2    Version 3.1.3.  // ALTER TABLE ADD COLUMN\n  ** file_format==3    Version 3.1.4.  // ditto but with non-NULL defaults\n  ** file_format==4    Version 3.3.0.  // DESC indices.  Boolean constants\n  */\n  pDb->pSchema->file_format = (u8)meta[BTREE_FILE_FORMAT-1];\n  if( pDb->pSchema->file_format==0 ){\n    pDb->pSchema->file_format = 1;\n  }\n  if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){\n    sqlite3SetString(pzErrMsg, db, \"unsupported file format\");\n    rc = SQLITE_ERROR;\n    goto initone_error_out;\n  }\n\n  /* Ticket #2804:  When we open a database in the newer file format,\n  ** clear the legacy_file_format pragma flag so that a VACUUM will\n  ** not downgrade the database and thus invalidate any descending\n  ** indices that the user might have created.\n  */\n  if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){\n    db->flags &= ~SQLITE_LegacyFileFmt;\n  }\n\n  /* Read the schema information out of the schema tables\n  */\n  assert( db->init.busy );\n  {\n    char *zSql;\n    zSql = sqlite3MPrintf(db, \n        \"SELECT name, rootpage, sql FROM \\\"%w\\\".%s ORDER BY rowid\",\n        db->aDb[iDb].zDbSName, zMasterName);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      sqlite3_xauth xAuth;\n      xAuth = db->xAuth;\n      db->xAuth = 0;\n#endif\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      db->xAuth = xAuth;\n    }\n#endif\n    if( rc==SQLITE_OK ) rc = initData.rc;\n    sqlite3DbFree(db, zSql);\n#ifndef SQLITE_OMIT_ANALYZE\n    if( rc==SQLITE_OK ){\n      sqlite3AnalysisLoad(db, iDb);\n    }\n#endif\n  }\n  if( db->mallocFailed ){\n    rc = SQLITE_NOMEM_BKPT;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){\n    /* Black magic: If the SQLITE_WriteSchema flag is set, then consider\n    ** the schema loaded, even if errors occurred. In this situation the \n    ** current sqlite3_prepare() operation will fail, but the following one\n    ** will attempt to compile the supplied statement against whatever subset\n    ** of the schema was loaded before the error occurred. The primary\n    ** purpose of this is to allow access to the sqlite_master table\n    ** even when its contents have been corrupted.\n    */\n    DbSetProperty(db, iDb, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n  }\n\n  /* Jump here for an error that occurs after successfully allocating\n  ** curMain and calling sqlite3BtreeEnter(). For an error that occurs\n  ** before that point, jump to error_out.\n  */\ninitone_error_out:\n  if( openedTransaction ){\n    sqlite3BtreeCommit(pDb->pBt);\n  }\n  sqlite3BtreeLeave(pDb->pBt);\n\nerror_out:\n  if( rc ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    sqlite3ResetOneSchema(db, iDb);\n  }\n  db->init.busy = 0;\n  return rc;\n}\n\n/*\n** Initialize all database files - the main database file, the file\n** used to store temporary tables, and any additional database files\n** created using ATTACH statements.  Return a success code.  If an\n** error occurs, write an error message into *pzErrMsg.\n**\n** After a database is initialized, the DB_SchemaLoaded bit is set\n** bit is set in the flags field of the Db structure. If the database\n** file was of zero-length, then the DB_Empty flag is also set.\n*/\nSQLITE_PRIVATE int sqlite3Init(sqlite3 *db, char **pzErrMsg){\n  int i, rc;\n  int commit_internal = !(db->mDbFlags&DBFLAG_SchemaChange);\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( sqlite3BtreeHoldsMutex(db->aDb[0].pBt) );\n  assert( db->init.busy==0 );\n  ENC(db) = SCHEMA_ENC(db);\n  assert( db->nDb>0 );\n  /* Do the main schema first */\n  if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){\n    rc = sqlite3InitOne(db, 0, pzErrMsg);\n    if( rc ) return rc;\n  }\n  /* All other schemas after the main schema. The \"temp\" schema must be last */\n  for(i=db->nDb-1; i>0; i--){\n    if( !DbHasProperty(db, i, DB_SchemaLoaded) ){\n      rc = sqlite3InitOne(db, i, pzErrMsg);\n      if( rc ) return rc;\n    }\n  }\n  if( commit_internal ){\n    sqlite3CommitInternalChanges(db);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This routine is a no-op if the database schema is already initialized.\n** Otherwise, the schema is loaded. An error code is returned.\n*/\nSQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){\n  int rc = SQLITE_OK;\n  sqlite3 *db = pParse->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( !db->init.busy ){\n    rc = sqlite3Init(db, &pParse->zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    pParse->rc = rc;\n    pParse->nErr++;\n  }\n  return rc;\n}\n\n\n/*\n** Check schema cookies in all databases.  If any cookie is out\n** of date set pParse->rc to SQLITE_SCHEMA.  If all schema cookies\n** make no changes to pParse->rc.\n*/\nstatic void schemaIsValid(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int rc;\n  int cookie;\n\n  assert( pParse->checkSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(iDb=0; iDb<db->nDb; iDb++){\n    int openedTransaction = 0;         /* True if a transaction is opened */\n    Btree *pBt = db->aDb[iDb].pBt;     /* Btree database to read cookie from */\n    if( pBt==0 ) continue;\n\n    /* If there is not already a read-only (or read-write) transaction opened\n    ** on the b-tree database, open one now. If a transaction is opened, it \n    ** will be closed immediately after reading the meta-value. */\n    if( !sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0);\n      if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n        sqlite3OomFault(db);\n      }\n      if( rc!=SQLITE_OK ) return;\n      openedTransaction = 1;\n    }\n\n    /* Read the schema cookie from the database. If it does not match the \n    ** value stored as part of the in-memory schema representation,\n    ** set Parse.rc to SQLITE_SCHEMA. */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){\n      sqlite3ResetOneSchema(db, iDb);\n      pParse->rc = SQLITE_SCHEMA;\n    }\n\n    /* Close the transaction, if one was opened. */\n    if( openedTransaction ){\n      sqlite3BtreeCommit(pBt);\n    }\n  }\n}\n\n/*\n** Convert a schema pointer into the iDb index that indicates\n** which database file in db->aDb[] the schema refers to.\n**\n** If the same database is attached more than once, the first\n** attached database is returned.\n*/\nSQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){\n  int i = -1000000;\n\n  /* If pSchema is NULL, then return -1000000. This happens when code in \n  ** expr.c is trying to resolve a reference to a transient table (i.e. one\n  ** created by a sub-select). In this case the return value of this \n  ** function should never be used.\n  **\n  ** We return -1000000 instead of the more usual -1 simply because using\n  ** -1000000 as the incorrect index into db->aDb[] is much \n  ** more likely to cause a segfault than -1 (of course there are assert()\n  ** statements too, but it never hurts to play the odds).\n  */\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( pSchema ){\n    for(i=0; ALWAYS(i<db->nDb); i++){\n      if( db->aDb[i].pSchema==pSchema ){\n        break;\n      }\n    }\n    assert( i>=0 && i<db->nDb );\n  }\n  return i;\n}\n\n/*\n** Free all memory allocations in the pParse object\n*/\nSQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  sqlite3DbFree(db, pParse->aLabel);\n  sqlite3ExprListDelete(db, pParse->pConstExpr);\n  if( db ){\n    assert( db->lookaside.bDisable >= pParse->disableLookaside );\n    db->lookaside.bDisable -= pParse->disableLookaside;\n  }\n  pParse->disableLookaside = 0;\n}\n\n/*\n** Compile the UTF-8 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pReprepare,         /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  char *zErrMsg = 0;        /* Error message */\n  int rc = SQLITE_OK;       /* Result code */\n  int i;                    /* Loop counter */\n  Parse sParse;             /* Parsing context */\n\n  memset(&sParse, 0, PARSE_HDR_SZ);\n  memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);\n  sParse.pReprepare = pReprepare;\n  assert( ppStmt && *ppStmt==0 );\n  /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* For a long-term use prepared statement avoid the use of\n  ** lookaside memory.\n  */\n  if( prepFlags & SQLITE_PREPARE_PERSISTENT ){\n    sParse.disableLookaside++;\n    db->lookaside.bDisable++;\n  }\n\n  /* Check to verify that it is possible to get a read lock on all\n  ** database schemas.  The inability to get a read lock indicates that\n  ** some other database connection is holding a write-lock, which in\n  ** turn means that the other connection has made uncommitted changes\n  ** to the schema.\n  **\n  ** Were we to proceed and prepare the statement against the uncommitted\n  ** schema changes and if those schema changes are subsequently rolled\n  ** back and different changes are made in their place, then when this\n  ** prepared statement goes to run the schema cookie would fail to detect\n  ** the schema change.  Disaster would follow.\n  **\n  ** This thread is currently holding mutexes on all Btrees (because\n  ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it\n  ** is not possible for another thread to start a new schema change\n  ** while this routine is running.  Hence, we do not need to hold \n  ** locks on the schema, we just need to make sure nobody else is \n  ** holding them.\n  **\n  ** Note that setting READ_UNCOMMITTED overrides most lock detection,\n  ** but it does *not* override schema lock detection, so this all still\n  ** works even if READ_UNCOMMITTED is set.\n  */\n  for(i=0; i<db->nDb; i++) {\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      assert( sqlite3BtreeHoldsMutex(pBt) );\n      rc = sqlite3BtreeSchemaLocked(pBt);\n      if( rc ){\n        const char *zDb = db->aDb[i].zDbSName;\n        sqlite3ErrorWithMsg(db, rc, \"database schema is locked: %s\", zDb);\n        testcase( db->flags & SQLITE_ReadUncommit );\n        goto end_prepare;\n      }\n    }\n  }\n\n  sqlite3VtabUnlockList(db);\n\n  sParse.db = db;\n  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){\n    char *zSqlCopy;\n    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n    testcase( nBytes==mxLen );\n    testcase( nBytes==mxLen+1 );\n    if( nBytes>mxLen ){\n      sqlite3ErrorWithMsg(db, SQLITE_TOOBIG, \"statement too long\");\n      rc = sqlite3ApiExit(db, SQLITE_TOOBIG);\n      goto end_prepare;\n    }\n    zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);\n    if( zSqlCopy ){\n      sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);\n      sParse.zTail = &zSql[sParse.zTail-zSqlCopy];\n      sqlite3DbFree(db, zSqlCopy);\n    }else{\n      sParse.zTail = &zSql[nBytes];\n    }\n  }else{\n    sqlite3RunParser(&sParse, zSql, &zErrMsg);\n  }\n  assert( 0==sParse.nQueryLoop );\n\n  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;\n  if( sParse.checkSchema ){\n    schemaIsValid(&sParse);\n  }\n  if( db->mallocFailed ){\n    sParse.rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pzTail ){\n    *pzTail = sParse.zTail;\n  }\n  rc = sParse.rc;\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){\n    static const char * const azColName[] = {\n       \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\",\n       \"selectid\", \"order\", \"from\", \"detail\"\n    };\n    int iFirst, mx;\n    if( sParse.explain==2 ){\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 4);\n      iFirst = 8;\n      mx = 12;\n    }else{\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 8);\n      iFirst = 0;\n      mx = 8;\n    }\n    for(i=iFirst; i<mx; i++){\n      sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME,\n                            azColName[i], SQLITE_STATIC);\n    }\n  }\n#endif\n\n  if( db->init.busy==0 ){\n    sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);\n  }\n  if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n    assert(!(*ppStmt));\n  }else{\n    *ppStmt = (sqlite3_stmt*)sParse.pVdbe;\n  }\n\n  if( zErrMsg ){\n    sqlite3ErrorWithMsg(db, rc, \"%s\", zErrMsg);\n    sqlite3DbFree(db, zErrMsg);\n  }else{\n    sqlite3Error(db, rc);\n  }\n\n  /* Delete any TriggerPrg structures allocated while parsing this statement. */\n  while( sParse.pTriggerPrg ){\n    TriggerPrg *pT = sParse.pTriggerPrg;\n    sParse.pTriggerPrg = pT->pNext;\n    sqlite3DbFree(db, pT);\n  }\n\nend_prepare:\n\n  sqlite3ParserReset(&sParse);\n  rc = sqlite3ApiExit(db, rc);\n  assert( (rc&db->errMask)==rc );\n  return rc;\n}\nstatic int sqlite3LockAndPrepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pOld,               /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);\n  if( rc==SQLITE_SCHEMA ){\n    sqlite3ResetOneSchema(db, -1);\n    sqlite3_finalize(*ppStmt);\n    rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  assert( rc==SQLITE_OK || *ppStmt==0 );\n  return rc;\n}\n\n/*\n** Rerun the compilation of a statement after a schema change.\n**\n** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,\n** if the statement cannot be recompiled because another connection has\n** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error\n** occurs, return SQLITE_SCHEMA.\n*/\nSQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){\n  int rc;\n  sqlite3_stmt *pNew;\n  const char *zSql;\n  sqlite3 *db;\n  u8 prepFlags;\n\n  assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );\n  zSql = sqlite3_sql((sqlite3_stmt *)p);\n  assert( zSql!=0 );  /* Reprepare only called for prepare_v2() statements */\n  db = sqlite3VdbeDb(p);\n  assert( sqlite3_mutex_held(db->mutex) );\n  prepFlags = sqlite3VdbePrepareFlags(p);\n  rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);\n  if( rc ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    assert( pNew==0 );\n    return rc;\n  }else{\n    assert( pNew!=0 );\n  }\n  sqlite3VdbeSwap((Vdbe*)pNew, p);\n  sqlite3TransferBindings(pNew, (sqlite3_stmt*)p);\n  sqlite3VdbeResetStepResult((Vdbe*)pNew);\n  sqlite3VdbeFinalize((Vdbe*)pNew);\n  return SQLITE_OK;\n}\n\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works\n  ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags\n  ** parameter.\n  **\n  ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,\n                             ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from\n  ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,\n  ** which is a bit array consisting of zero or more of the\n  ** SQLITE_PREPARE_* flags.\n  **\n  ** Proof by comparison to the implementation of sqlite3_prepare_v2()\n  ** directly above. */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,\n                 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n                 0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Compile the UTF-16 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  /* This function currently works by first transforming the UTF-16\n  ** encoded string to UTF-8, then invoking sqlite3_prepare(). The\n  ** tricky bit is figuring out the pointer to return in *pzTail.\n  */\n  char *zSql8;\n  const char *zTail8 = 0;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( nBytes>=0 ){\n    int sz;\n    const char *z = (const char*)zSql;\n    for(sz=0; sz<nBytes && (z[sz]!=0 || z[sz+1]!=0); sz += 2){}\n    nBytes = sz;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);\n  if( zSql8 ){\n    rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);\n  }\n\n  if( zTail8 && pzTail ){\n    /* If sqlite3_prepare returns a tail pointer, we calculate the\n    ** equivalent pointer into the UTF-16 string by counting the unicode\n    ** characters between zSql8 and zTail8, and then returning a pointer\n    ** the same number of characters into the UTF-16 string.\n    */\n    int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));\n    *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);\n  }\n  sqlite3DbFree(db, zSql8); \n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,\n         SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n         ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_UTF16 */\n\n/************** End of prepare.c *********************************************/\n/************** Begin file select.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle SELECT statements in SQLite.\n*/\n/* #include \"sqliteInt.h\" */\n\n/*\n** Trace output macros\n*/\n#if SELECTTRACE_ENABLED\n/***/ int sqlite3SelectTrace = 0;\n# define SELECTTRACE(K,P,S,X)  \\\n  if(sqlite3SelectTrace&(K))   \\\n    sqlite3DebugPrintf(\"%*s%s.%p: \",(P)->nSelectIndent*2-2,\"\",\\\n        (S)->zSelName,(S)),\\\n    sqlite3DebugPrintf X\n#else\n# define SELECTTRACE(K,P,S,X)\n#endif\n\n\n/*\n** An instance of the following object is used to record information about\n** how to process the DISTINCT keyword, to simplify passing that information\n** into the selectInnerLoop() routine.\n*/\ntypedef struct DistinctCtx DistinctCtx;\nstruct DistinctCtx {\n  u8 isTnct;      /* True if the DISTINCT keyword is present */\n  u8 eTnctType;   /* One of the WHERE_DISTINCT_* operators */\n  int tabTnct;    /* Ephemeral table used for DISTINCT processing */\n  int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */\n};\n\n/*\n** An instance of the following object is used to record information about\n** the ORDER BY (or GROUP BY) clause of query is being coded.\n*/\ntypedef struct SortCtx SortCtx;\nstruct SortCtx {\n  ExprList *pOrderBy;   /* The ORDER BY (or GROUP BY clause) */\n  int nOBSat;           /* Number of ORDER BY terms satisfied by indices */\n  int iECursor;         /* Cursor number for the sorter */\n  int regReturn;        /* Register holding block-output return address */\n  int labelBkOut;       /* Start label for the block-output subroutine */\n  int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */\n  int labelDone;        /* Jump here when done, ex: LIMIT reached */\n  u8 sortFlags;         /* Zero or more SORTFLAG_* bits */\n  u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */\n};\n#define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */\n\n/*\n** Delete all the content of a Select structure.  Deallocate the structure\n** itself only if bFree is true.\n*/\nstatic void clearSelect(sqlite3 *db, Select *p, int bFree){\n  while( p ){\n    Select *pPrior = p->pPrior;\n    sqlite3ExprListDelete(db, p->pEList);\n    sqlite3SrcListDelete(db, p->pSrc);\n    sqlite3ExprDelete(db, p->pWhere);\n    sqlite3ExprListDelete(db, p->pGroupBy);\n    sqlite3ExprDelete(db, p->pHaving);\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    sqlite3ExprDelete(db, p->pLimit);\n    sqlite3ExprDelete(db, p->pOffset);\n    if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);\n    if( bFree ) sqlite3DbFreeNN(db, p);\n    p = pPrior;\n    bFree = 1;\n  }\n}\n\n/*\n** Initialize a SelectDest structure.\n*/\nSQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){\n  pDest->eDest = (u8)eDest;\n  pDest->iSDParm = iParm;\n  pDest->zAffSdst = 0;\n  pDest->iSdst = 0;\n  pDest->nSdst = 0;\n}\n\n\n/*\n** Allocate a new Select structure and return a pointer to that\n** structure.\n*/\nSQLITE_PRIVATE Select *sqlite3SelectNew(\n  Parse *pParse,        /* Parsing context */\n  ExprList *pEList,     /* which columns to include in the result */\n  SrcList *pSrc,        /* the FROM clause -- which tables to scan */\n  Expr *pWhere,         /* the WHERE clause */\n  ExprList *pGroupBy,   /* the GROUP BY clause */\n  Expr *pHaving,        /* the HAVING clause */\n  ExprList *pOrderBy,   /* the ORDER BY clause */\n  u32 selFlags,         /* Flag parameters, such as SF_Distinct */\n  Expr *pLimit,         /* LIMIT value.  NULL means not used */\n  Expr *pOffset         /* OFFSET value.  NULL means no offset */\n){\n  Select *pNew;\n  Select standin;\n  pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) );\n  if( pNew==0 ){\n    assert( pParse->db->mallocFailed );\n    pNew = &standin;\n  }\n  if( pEList==0 ){\n    pEList = sqlite3ExprListAppend(pParse, 0,\n                                   sqlite3Expr(pParse->db,TK_ASTERISK,0));\n  }\n  pNew->pEList = pEList;\n  pNew->op = TK_SELECT;\n  pNew->selFlags = selFlags;\n  pNew->iLimit = 0;\n  pNew->iOffset = 0;\n#if SELECTTRACE_ENABLED\n  pNew->zSelName[0] = 0;\n#endif\n  pNew->addrOpenEphm[0] = -1;\n  pNew->addrOpenEphm[1] = -1;\n  pNew->nSelectRow = 0;\n  if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));\n  pNew->pSrc = pSrc;\n  pNew->pWhere = pWhere;\n  pNew->pGroupBy = pGroupBy;\n  pNew->pHaving = pHaving;\n  pNew->pOrderBy = pOrderBy;\n  pNew->pPrior = 0;\n  pNew->pNext = 0;\n  pNew->pLimit = pLimit;\n  pNew->pOffset = pOffset;\n  pNew->pWith = 0;\n  assert( pOffset==0 || pLimit!=0 || pParse->nErr>0\n                     || pParse->db->mallocFailed!=0 );\n  if( pParse->db->mallocFailed ) {\n    clearSelect(pParse->db, pNew, pNew!=&standin);\n    pNew = 0;\n  }else{\n    assert( pNew->pSrc!=0 || pParse->nErr>0 );\n  }\n  assert( pNew!=&standin );\n  return pNew;\n}\n\n#if SELECTTRACE_ENABLED\n/*\n** Set the name of a Select object\n*/\nSQLITE_PRIVATE void sqlite3SelectSetName(Select *p, const char *zName){\n  if( p && zName ){\n    sqlite3_snprintf(sizeof(p->zSelName), p->zSelName, \"%s\", zName);\n  }\n}\n#endif\n\n\n/*\n** Delete the given Select structure and all of its substructures.\n*/\nSQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){\n  if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);\n}\n\n/*\n** Return a pointer to the right-most SELECT statement in a compound.\n*/\nstatic Select *findRightmost(Select *p){\n  while( p->pNext ) p = p->pNext;\n  return p;\n}\n\n/*\n** Given 1 to 3 identifiers preceding the JOIN keyword, determine the\n** type of join.  Return an integer constant that expresses that type\n** in terms of the following bit values:\n**\n**     JT_INNER\n**     JT_CROSS\n**     JT_OUTER\n**     JT_NATURAL\n**     JT_LEFT\n**     JT_RIGHT\n**\n** A full outer join is the combination of JT_LEFT and JT_RIGHT.\n**\n** If an illegal or unsupported join type is seen, then still return\n** a join type, but put an error in the pParse structure.\n*/\nSQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){\n  int jointype = 0;\n  Token *apAll[3];\n  Token *p;\n                             /*   0123456789 123456789 123456789 123 */\n  static const char zKeyText[] = \"naturaleftouterightfullinnercross\";\n  static const struct {\n    u8 i;        /* Beginning of keyword text in zKeyText[] */\n    u8 nChar;    /* Length of the keyword in characters */\n    u8 code;     /* Join type mask */\n  } aKeyword[] = {\n    /* natural */ { 0,  7, JT_NATURAL                },\n    /* left    */ { 6,  4, JT_LEFT|JT_OUTER          },\n    /* outer   */ { 10, 5, JT_OUTER                  },\n    /* right   */ { 14, 5, JT_RIGHT|JT_OUTER         },\n    /* full    */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER },\n    /* inner   */ { 23, 5, JT_INNER                  },\n    /* cross   */ { 28, 5, JT_INNER|JT_CROSS         },\n  };\n  int i, j;\n  apAll[0] = pA;\n  apAll[1] = pB;\n  apAll[2] = pC;\n  for(i=0; i<3 && apAll[i]; i++){\n    p = apAll[i];\n    for(j=0; j<ArraySize(aKeyword); j++){\n      if( p->n==aKeyword[j].nChar \n          && sqlite3StrNICmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0 ){\n        jointype |= aKeyword[j].code;\n        break;\n      }\n    }\n    testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );\n    if( j>=ArraySize(aKeyword) ){\n      jointype |= JT_ERROR;\n      break;\n    }\n  }\n  if(\n     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||\n     (jointype & JT_ERROR)!=0\n  ){\n    const char *zSp = \" \";\n    assert( pB!=0 );\n    if( pC==0 ){ zSp++; }\n    sqlite3ErrorMsg(pParse, \"unknown or unsupported join type: \"\n       \"%T %T%s%T\", pA, pB, zSp, pC);\n    jointype = JT_INNER;\n  }else if( (jointype & JT_OUTER)!=0 \n         && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){\n    sqlite3ErrorMsg(pParse, \n      \"RIGHT and FULL OUTER JOINs are not currently supported\");\n    jointype = JT_INNER;\n  }\n  return jointype;\n}\n\n/*\n** Return the index of a column in a table.  Return -1 if the column\n** is not contained in the table.\n*/\nstatic int columnIndex(Table *pTab, const char *zCol){\n  int i;\n  for(i=0; i<pTab->nCol; i++){\n    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Search the first N tables in pSrc, from left to right, looking for a\n** table that has a column named zCol.  \n**\n** When found, set *piTab and *piCol to the table index and column index\n** of the matching column and return TRUE.\n**\n** If not found, return FALSE.\n*/\nstatic int tableAndColumnIndex(\n  SrcList *pSrc,       /* Array of tables to search */\n  int N,               /* Number of tables in pSrc->a[] to search */\n  const char *zCol,    /* Name of the column we are looking for */\n  int *piTab,          /* Write index of pSrc->a[] here */\n  int *piCol           /* Write index of pSrc->a[*piTab].pTab->aCol[] here */\n){\n  int i;               /* For looping over tables in pSrc */\n  int iCol;            /* Index of column matching zCol */\n\n  assert( (piTab==0)==(piCol==0) );  /* Both or neither are NULL */\n  for(i=0; i<N; i++){\n    iCol = columnIndex(pSrc->a[i].pTab, zCol);\n    if( iCol>=0 ){\n      if( piTab ){\n        *piTab = i;\n        *piCol = iCol;\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is used to add terms implied by JOIN syntax to the\n** WHERE clause expression of a SELECT statement. The new term, which\n** is ANDed with the existing WHERE clause, is of the form:\n**\n**    (tab1.col1 = tab2.col2)\n**\n** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the \n** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is\n** column iColRight of tab2.\n*/\nstatic void addWhereTerm(\n  Parse *pParse,                  /* Parsing context */\n  SrcList *pSrc,                  /* List of tables in FROM clause */\n  int iLeft,                      /* Index of first table to join in pSrc */\n  int iColLeft,                   /* Index of column in first table */\n  int iRight,                     /* Index of second table in pSrc */\n  int iColRight,                  /* Index of column in second table */\n  int isOuterJoin,                /* True if this is an OUTER join */\n  Expr **ppWhere                  /* IN/OUT: The WHERE clause to add to */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pE1;\n  Expr *pE2;\n  Expr *pEq;\n\n  assert( iLeft<iRight );\n  assert( pSrc->nSrc>iRight );\n  assert( pSrc->a[iLeft].pTab );\n  assert( pSrc->a[iRight].pTab );\n\n  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);\n  pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);\n\n  pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2);\n  if( pEq && isOuterJoin ){\n    ExprSetProperty(pEq, EP_FromJoin);\n    assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(pEq, EP_NoReduce);\n    pEq->iRightJoinTable = (i16)pE2->iTable;\n  }\n  *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);\n}\n\n/*\n** Set the EP_FromJoin property on all terms of the given expression.\n** And set the Expr.iRightJoinTable to iTable for every term in the\n** expression.\n**\n** The EP_FromJoin property is used on terms of an expression to tell\n** the LEFT OUTER JOIN processing logic that this term is part of the\n** join restriction specified in the ON or USING clause and not a part\n** of the more general WHERE clause.  These terms are moved over to the\n** WHERE clause during join processing but we need to remember that they\n** originated in the ON or USING clause.\n**\n** The Expr.iRightJoinTable tells the WHERE clause processing that the\n** expression depends on table iRightJoinTable even if that table is not\n** explicitly mentioned in the expression.  That information is needed\n** for cases like this:\n**\n**    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5\n**\n** The where clause needs to defer the handling of the t1.x=5\n** term until after the t2 loop of the join.  In that way, a\n** NULL t2 row will be inserted whenever t1.x!=5.  If we do not\n** defer the handling of t1.x=5, it will be processed immediately\n** after the t1 loop and rows with t1.x!=5 will never appear in\n** the output, which is incorrect.\n*/\nstatic void setJoinExpr(Expr *p, int iTable){\n  while( p ){\n    ExprSetProperty(p, EP_FromJoin);\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(p, EP_NoReduce);\n    p->iRightJoinTable = (i16)iTable;\n    if( p->op==TK_FUNCTION && p->x.pList ){\n      int i;\n      for(i=0; i<p->x.pList->nExpr; i++){\n        setJoinExpr(p->x.pList->a[i].pExpr, iTable);\n      }\n    }\n    setJoinExpr(p->pLeft, iTable);\n    p = p->pRight;\n  } \n}\n\n/*\n** This routine processes the join information for a SELECT statement.\n** ON and USING clauses are converted into extra terms of the WHERE clause.\n** NATURAL joins also create extra WHERE clause terms.\n**\n** The terms of a FROM clause are contained in the Select.pSrc structure.\n** The left most table is the first entry in Select.pSrc.  The right-most\n** table is the last entry.  The join operator is held in the entry to\n** the left.  Thus entry 0 contains the join operator for the join between\n** entries 0 and 1.  Any ON or USING clauses associated with the join are\n** also attached to the left entry.\n**\n** This routine returns the number of errors encountered.\n*/\nstatic int sqliteProcessJoin(Parse *pParse, Select *p){\n  SrcList *pSrc;                  /* All tables in the FROM clause */\n  int i, j;                       /* Loop counters */\n  struct SrcList_item *pLeft;     /* Left table being joined */\n  struct SrcList_item *pRight;    /* Right table being joined */\n\n  pSrc = p->pSrc;\n  pLeft = &pSrc->a[0];\n  pRight = &pLeft[1];\n  for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){\n    Table *pRightTab = pRight->pTab;\n    int isOuter;\n\n    if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue;\n    isOuter = (pRight->fg.jointype & JT_OUTER)!=0;\n\n    /* When the NATURAL keyword is present, add WHERE clause terms for\n    ** every column that the two tables have in common.\n    */\n    if( pRight->fg.jointype & JT_NATURAL ){\n      if( pRight->pOn || pRight->pUsing ){\n        sqlite3ErrorMsg(pParse, \"a NATURAL join may not have \"\n           \"an ON or USING clause\", 0);\n        return 1;\n      }\n      for(j=0; j<pRightTab->nCol; j++){\n        char *zName;   /* Name of column in the right table */\n        int iLeft;     /* Matching left table */\n        int iLeftCol;  /* Matching column in the left table */\n\n        zName = pRightTab->aCol[j].zName;\n        if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){\n          addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,\n                       isOuter, &p->pWhere);\n        }\n      }\n    }\n\n    /* Disallow both ON and USING clauses in the same join\n    */\n    if( pRight->pOn && pRight->pUsing ){\n      sqlite3ErrorMsg(pParse, \"cannot have both ON and USING \"\n        \"clauses in the same join\");\n      return 1;\n    }\n\n    /* Add the ON clause to the end of the WHERE clause, connected by\n    ** an AND operator.\n    */\n    if( pRight->pOn ){\n      if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);\n      p->pWhere = sqlite3ExprAnd(pParse->db, p->pWhere, pRight->pOn);\n      pRight->pOn = 0;\n    }\n\n    /* Create extra terms on the WHERE clause for each column named\n    ** in the USING clause.  Example: If the two tables to be joined are \n    ** A and B and the USING clause names X, Y, and Z, then add this\n    ** to the WHERE clause:    A.X=B.X AND A.Y=B.Y AND A.Z=B.Z\n    ** Report an error if any column mentioned in the USING clause is\n    ** not contained in both tables to be joined.\n    */\n    if( pRight->pUsing ){\n      IdList *pList = pRight->pUsing;\n      for(j=0; j<pList->nId; j++){\n        char *zName;     /* Name of the term in the USING clause */\n        int iLeft;       /* Table on the left with matching column name */\n        int iLeftCol;    /* Column number of matching column on the left */\n        int iRightCol;   /* Column number of matching column on the right */\n\n        zName = pList->a[j].zName;\n        iRightCol = columnIndex(pRightTab, zName);\n        if( iRightCol<0\n         || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)\n        ){\n          sqlite3ErrorMsg(pParse, \"cannot join using column %s - column \"\n            \"not present in both tables\", zName);\n          return 1;\n        }\n        addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,\n                     isOuter, &p->pWhere);\n      }\n    }\n  }\n  return 0;\n}\n\n/* Forward reference */\nstatic KeyInfo *keyInfoFromExprList(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pList,     /* Form the KeyInfo object from this ExprList */\n  int iStart,          /* Begin with this column of pList */\n  int nExtra           /* Add this many extra columns to the end */\n);\n\n/*\n** Generate code that will push the record in registers regData\n** through regData+nData-1 onto the sorter.\n*/\nstatic void pushOntoSorter(\n  Parse *pParse,         /* Parser context */\n  SortCtx *pSort,        /* Information about the ORDER BY clause */\n  Select *pSelect,       /* The whole SELECT statement */\n  int regData,           /* First register holding data to be sorted */\n  int regOrigData,       /* First register holding data before packing */\n  int nData,             /* Number of elements in the data array */\n  int nPrefixReg         /* No. of reg prior to regData available for use */\n){\n  Vdbe *v = pParse->pVdbe;                         /* Stmt under construction */\n  int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0);\n  int nExpr = pSort->pOrderBy->nExpr;              /* No. of ORDER BY terms */\n  int nBase = nExpr + bSeq + nData;                /* Fields in sorter record */\n  int regBase;                                     /* Regs for sorter record */\n  int regRecord = ++pParse->nMem;                  /* Assembled sorter record */\n  int nOBSat = pSort->nOBSat;                      /* ORDER BY terms to skip */\n  int op;                            /* Opcode to add sorter record to sorter */\n  int iLimit;                        /* LIMIT counter */\n\n  assert( bSeq==0 || bSeq==1 );\n  assert( nData==1 || regData==regOrigData || regOrigData==0 );\n  if( nPrefixReg ){\n    assert( nPrefixReg==nExpr+bSeq );\n    regBase = regData - nExpr - bSeq;\n  }else{\n    regBase = pParse->nMem + 1;\n    pParse->nMem += nBase;\n  }\n  assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );\n  iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;\n  pSort->labelDone = sqlite3VdbeMakeLabel(v);\n  sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,\n                          SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));\n  if( bSeq ){\n    sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr);\n  }\n  if( nPrefixReg==0 && nData>0 ){\n    sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);\n  }\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord);\n  if( nOBSat>0 ){\n    int regPrevKey;   /* The first nOBSat columns of the previous row */\n    int addrFirst;    /* Address of the OP_IfNot opcode */\n    int addrJmp;      /* Address of the OP_Jump opcode */\n    VdbeOp *pOp;      /* Opcode that opens the sorter */\n    int nKey;         /* Number of sorting key columns, including OP_Sequence */\n    KeyInfo *pKI;     /* Original KeyInfo on the sorter table */\n\n    regPrevKey = pParse->nMem+1;\n    pParse->nMem += pSort->nOBSat;\n    nKey = nExpr - pSort->nOBSat + bSeq;\n    if( bSeq ){\n      addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); \n    }else{\n      addrFirst = sqlite3VdbeAddOp1(v, OP_SequenceTest, pSort->iECursor);\n    }\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);\n    pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);\n    if( pParse->db->mallocFailed ) return;\n    pOp->p2 = nKey + nData;\n    pKI = pOp->p4.pKeyInfo;\n    memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */\n    sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);\n    testcase( pKI->nAllField > pKI->nKeyField+2 );\n    pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,\n                                           pKI->nAllField-pKI->nKeyField-1);\n    addrJmp = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);\n    pSort->labelBkOut = sqlite3VdbeMakeLabel(v);\n    pSort->regReturn = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);\n    if( iLimit ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone);\n      VdbeCoverage(v);\n    }\n    sqlite3VdbeJumpHere(v, addrFirst);\n    sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);\n    sqlite3VdbeJumpHere(v, addrJmp);\n  }\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    op = OP_SorterInsert;\n  }else{\n    op = OP_IdxInsert;\n  }\n  sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,\n                       regBase+nOBSat, nBase-nOBSat);\n  if( iLimit ){\n    int addr;\n    int r1 = 0;\n    /* Fill the sorter until it contains LIMIT+OFFSET entries.  (The iLimit\n    ** register is initialized with value of LIMIT+OFFSET.)  After the sorter\n    ** fills up, delete the least entry in the sorter after each insert.\n    ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */\n    addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);\n    if( pSort->bOrderedInnerLoop ){\n      r1 = ++pParse->nMem;\n      sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);\n      VdbeComment((v, \"seq\"));\n    }\n    sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);\n    if( pSort->bOrderedInnerLoop ){\n      /* If the inner loop is driven by an index such that values from\n      ** the same iteration of the inner loop are in sorted order, then\n      ** immediately jump to the next iteration of an inner loop if the\n      ** entry from the current iteration does not fit into the top\n      ** LIMIT+OFFSET entries of the sorter. */\n      int iBrk = sqlite3VdbeCurrentAddr(v) + 2;\n      sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);\n      sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n      VdbeCoverage(v);\n    }\n    sqlite3VdbeJumpHere(v, addr);\n  }\n}\n\n/*\n** Add code to implement the OFFSET\n*/\nstatic void codeOffset(\n  Vdbe *v,          /* Generate code into this VM */\n  int iOffset,      /* Register holding the offset counter */\n  int iContinue     /* Jump here to skip the current record */\n){\n  if( iOffset>0 ){\n    sqlite3VdbeAddOp3(v, OP_IfPos, iOffset, iContinue, 1); VdbeCoverage(v);\n    VdbeComment((v, \"OFFSET\"));\n  }\n}\n\n/*\n** Add code that will check to make sure the N registers starting at iMem\n** form a distinct entry.  iTab is a sorting index that holds previously\n** seen combinations of the N values.  A new entry is made in iTab\n** if the current N values are new.\n**\n** A jump to addrRepeat is made and the N+1 values are popped from the\n** stack if the top N elements are not distinct.\n*/\nstatic void codeDistinct(\n  Parse *pParse,     /* Parsing and code generating context */\n  int iTab,          /* A sorting index used to test for distinctness */\n  int addrRepeat,    /* Jump to here if not distinct */\n  int N,             /* Number of elements */\n  int iMem           /* First element */\n){\n  Vdbe *v;\n  int r1;\n\n  v = pParse->pVdbe;\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);\n  sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** This routine generates the code for the inside of the inner loop\n** of a SELECT.\n**\n** If srcTab is negative, then the p->pEList expressions\n** are evaluated in order to get the data for this row.  If srcTab is\n** zero or more, then data is pulled from srcTab and p->pEList is used only \n** to get the number of columns and the collation sequence for each column.\n*/\nstatic void selectInnerLoop(\n  Parse *pParse,          /* The parser context */\n  Select *p,              /* The complete select statement being coded */\n  int srcTab,             /* Pull data from this table if non-negative */\n  SortCtx *pSort,         /* If not NULL, info on how to process ORDER BY */\n  DistinctCtx *pDistinct, /* If not NULL, info on how to process DISTINCT */\n  SelectDest *pDest,      /* How to dispose of the results */\n  int iContinue,          /* Jump here to continue with next row */\n  int iBreak              /* Jump here to break out of the inner loop */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int hasDistinct;            /* True if the DISTINCT keyword is present */\n  int eDest = pDest->eDest;   /* How to dispose of results */\n  int iParm = pDest->iSDParm; /* First argument to disposal method */\n  int nResultCol;             /* Number of result columns */\n  int nPrefixReg = 0;         /* Number of extra registers before regResult */\n\n  /* Usually, regResult is the first cell in an array of memory cells\n  ** containing the current result row. In this case regOrig is set to the\n  ** same value. However, if the results are being sent to the sorter, the\n  ** values for any expressions that are also part of the sort-key are omitted\n  ** from this array. In this case regOrig is set to zero.  */\n  int regResult;              /* Start of memory holding current results */\n  int regOrig;                /* Start of memory holding full result (or 0) */\n\n  assert( v );\n  assert( p->pEList!=0 );\n  hasDistinct = pDistinct ? pDistinct->eTnctType : WHERE_DISTINCT_NOOP;\n  if( pSort && pSort->pOrderBy==0 ) pSort = 0;\n  if( pSort==0 && !hasDistinct ){\n    assert( iContinue!=0 );\n    codeOffset(v, p->iOffset, iContinue);\n  }\n\n  /* Pull the requested columns.\n  */\n  nResultCol = p->pEList->nExpr;\n\n  if( pDest->iSdst==0 ){\n    if( pSort ){\n      nPrefixReg = pSort->pOrderBy->nExpr;\n      if( !(pSort->sortFlags & SORTFLAG_UseSorter) ) nPrefixReg++;\n      pParse->nMem += nPrefixReg;\n    }\n    pDest->iSdst = pParse->nMem+1;\n    pParse->nMem += nResultCol;\n  }else if( pDest->iSdst+nResultCol > pParse->nMem ){\n    /* This is an error condition that can result, for example, when a SELECT\n    ** on the right-hand side of an INSERT contains more result columns than\n    ** there are columns in the table on the left.  The error will be caught\n    ** and reported later.  But we need to make sure enough memory is allocated\n    ** to avoid other spurious errors in the meantime. */\n    pParse->nMem += nResultCol;\n  }\n  pDest->nSdst = nResultCol;\n  regOrig = regResult = pDest->iSdst;\n  if( srcTab>=0 ){\n    for(i=0; i<nResultCol; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);\n      VdbeComment((v, \"%s\", p->pEList->a[i].zName));\n    }\n  }else if( eDest!=SRT_Exists ){\n    /* If the destination is an EXISTS(...) expression, the actual\n    ** values returned by the SELECT are not required.\n    */\n    u8 ecelFlags;\n    if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){\n      ecelFlags = SQLITE_ECEL_DUP;\n    }else{\n      ecelFlags = 0;\n    }\n    if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab && eDest!=SRT_Table ){\n      /* For each expression in p->pEList that is a copy of an expression in\n      ** the ORDER BY clause (pSort->pOrderBy), set the associated \n      ** iOrderByCol value to one more than the index of the ORDER BY \n      ** expression within the sort-key that pushOntoSorter() will generate.\n      ** This allows the p->pEList field to be omitted from the sorted record,\n      ** saving space and CPU cycles.  */\n      ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);\n      for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){\n        int j;\n        if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){\n          p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;\n        }\n      }\n      regOrig = 0;\n      assert( eDest==SRT_Set || eDest==SRT_Mem \n           || eDest==SRT_Coroutine || eDest==SRT_Output );\n    }\n    nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult,\n                                         0,ecelFlags);\n  }\n\n  /* If the DISTINCT keyword was present on the SELECT statement\n  ** and this row has been seen before, then do not make this row\n  ** part of the result.\n  */\n  if( hasDistinct ){\n    switch( pDistinct->eTnctType ){\n      case WHERE_DISTINCT_ORDERED: {\n        VdbeOp *pOp;            /* No longer required OpenEphemeral instr. */\n        int iJump;              /* Jump destination */\n        int regPrev;            /* Previous row content */\n\n        /* Allocate space for the previous row */\n        regPrev = pParse->nMem+1;\n        pParse->nMem += nResultCol;\n\n        /* Change the OP_OpenEphemeral coded earlier to an OP_Null\n        ** sets the MEM_Cleared bit on the first register of the\n        ** previous value.  This will cause the OP_Ne below to always\n        ** fail on the first iteration of the loop even if the first\n        ** row is all NULLs.\n        */\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);\n        pOp->opcode = OP_Null;\n        pOp->p1 = 1;\n        pOp->p2 = regPrev;\n\n        iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;\n        for(i=0; i<nResultCol; i++){\n          CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);\n          if( i<nResultCol-1 ){\n            sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i);\n            VdbeCoverage(v);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i);\n            VdbeCoverage(v);\n           }\n          sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ);\n          sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        }\n        assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed );\n        sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1);\n        break;\n      }\n\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        break;\n      }\n\n      default: {\n        assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED );\n        codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol,\n                     regResult);\n        break;\n      }\n    }\n    if( pSort==0 ){\n      codeOffset(v, p->iOffset, iContinue);\n    }\n  }\n\n  switch( eDest ){\n    /* In this mode, write each query result to the key of the temporary\n    ** table iParm.\n    */\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n    case SRT_Union: {\n      int r1;\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* Construct a record from the query result, but instead of\n    ** saving that record, use it as a key to delete elements from\n    ** the temporary table iParm.\n    */\n    case SRT_Except: {\n      sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nResultCol);\n      break;\n    }\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n    /* Store the result as data using a unique key.\n    */\n    case SRT_Fifo:\n    case SRT_DistFifo:\n    case SRT_Table:\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempRange(pParse, nPrefixReg+1);\n      testcase( eDest==SRT_Table );\n      testcase( eDest==SRT_EphemTab );\n      testcase( eDest==SRT_Fifo );\n      testcase( eDest==SRT_DistFifo );\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg);\n#ifndef SQLITE_OMIT_CTE\n      if( eDest==SRT_DistFifo ){\n        /* If the destination is DistFifo, then cursor (iParm+1) is open\n        ** on an ephemeral index. If the current row is already present\n        ** in the index, do not write it to the output. If not, add the\n        ** current row to the index and proceed with writing it to the\n        ** output table as well.  */\n        int addr = sqlite3VdbeCurrentAddr(v) + 4;\n        sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, addr, r1, 0);\n        VdbeCoverage(v);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm+1, r1,regResult,nResultCol);\n        assert( pSort==0 );\n      }\n#endif\n      if( pSort ){\n        pushOntoSorter(pParse, pSort, p, r1+nPrefixReg,regResult,1,nPrefixReg);\n      }else{\n        int r2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);\n        sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);\n        sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      sqlite3ReleaseTempRange(pParse, r1, nPrefixReg+1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\" construct,\n    ** then there should be a single item on the stack.  Write this\n    ** item into the set table with bogus data.\n    */\n    case SRT_Set: {\n      if( pSort ){\n        /* At first glance you would think we could optimize out the\n        ** ORDER BY in this case since the order of entries in the set\n        ** does not matter.  But there might be a LIMIT clause, in which\n        ** case the order does matter */\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        int r1 = sqlite3GetTempReg(pParse);\n        assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, \n            r1, pDest->zAffSdst, nResultCol);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n        sqlite3ReleaseTempReg(pParse, r1);\n      }\n      break;\n    }\n\n    /* If any row exist in the result set, record that fact and abort.\n    */\n    case SRT_Exists: {\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell or array of \n    ** memory cells and break out of the scan loop.\n    */\n    case SRT_Mem: {\n      if( pSort ){\n        assert( nResultCol<=pDest->nSdst );\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        assert( nResultCol==pDest->nSdst );\n        assert( regResult==iParm );\n        /* The LIMIT clause will jump out of the loop for us */\n      }\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    case SRT_Coroutine:       /* Send data to a co-routine */\n    case SRT_Output: {        /* Return the results */\n      testcase( eDest==SRT_Coroutine );\n      testcase( eDest==SRT_Output );\n      if( pSort ){\n        pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol,\n                       nPrefixReg);\n      }else if( eDest==SRT_Coroutine ){\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);\n      }\n      break;\n    }\n\n#ifndef SQLITE_OMIT_CTE\n    /* Write the results into a priority queue that is order according to\n    ** pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an\n    ** index with pSO->nExpr+2 columns.  Build a key using pSO for the first\n    ** pSO->nExpr columns, then make sure all keys are unique by adding a\n    ** final OP_Sequence column.  The last column is the record as a blob.\n    */\n    case SRT_DistQueue:\n    case SRT_Queue: {\n      int nKey;\n      int r1, r2, r3;\n      int addrTest = 0;\n      ExprList *pSO;\n      pSO = pDest->pOrderBy;\n      assert( pSO );\n      nKey = pSO->nExpr;\n      r1 = sqlite3GetTempReg(pParse);\n      r2 = sqlite3GetTempRange(pParse, nKey+2);\n      r3 = r2+nKey+1;\n      if( eDest==SRT_DistQueue ){\n        /* If the destination is DistQueue, then cursor (iParm+1) is open\n        ** on a second ephemeral index that holds all values every previously\n        ** added to the queue. */\n        addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, \n                                        regResult, nResultCol);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r3);\n      if( eDest==SRT_DistQueue ){\n        sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);\n        sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n      }\n      for(i=0; i<nKey; i++){\n        sqlite3VdbeAddOp2(v, OP_SCopy,\n                          regResult + pSO->a[i].u.x.iOrderByCol - 1,\n                          r2+i);\n      }\n      sqlite3VdbeAddOp2(v, OP_Sequence, iParm, r2+nKey);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, r2, nKey+2, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, r2, nKey+2);\n      if( addrTest ) sqlite3VdbeJumpHere(v, addrTest);\n      sqlite3ReleaseTempReg(pParse, r1);\n      sqlite3ReleaseTempRange(pParse, r2, nKey+2);\n      break;\n    }\n#endif /* SQLITE_OMIT_CTE */\n\n\n\n#if !defined(SQLITE_OMIT_TRIGGER)\n    /* Discard the results.  This is used for SELECT statements inside\n    ** the body of a TRIGGER.  The purpose of such selects is to call\n    ** user-defined functions that have side effects.  We do not care\n    ** about the actual results of the select.\n    */\n    default: {\n      assert( eDest==SRT_Discard );\n      break;\n    }\n#endif\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.  Except, if\n  ** there is a sorter, in which case the sorter has already limited\n  ** the output for us.\n  */\n  if( pSort==0 && p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n}\n\n/*\n** Allocate a KeyInfo object sufficient for an index of N key columns and\n** X extra columns.\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){\n  int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);\n  KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);\n  if( p ){\n    p->aSortOrder = (u8*)&p->aColl[N+X];\n    p->nKeyField = (u16)N;\n    p->nAllField = (u16)(N+X);\n    p->enc = ENC(db);\n    p->db = db;\n    p->nRef = 1;\n    memset(&p[1], 0, nExtra);\n  }else{\n    sqlite3OomFault(db);\n  }\n  return p;\n}\n\n/*\n** Deallocate a KeyInfo object\n*/\nSQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef--;\n    if( p->nRef==0 ) sqlite3DbFreeNN(p->db, p);\n  }\n}\n\n/*\n** Make a new pointer to a KeyInfo object\n*/\nSQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef++;\n  }\n  return p;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return TRUE if a KeyInfo object can be change.  The KeyInfo object\n** can only be changed if this is just a single reference to the object.\n**\n** This routine is used only inside of assert() statements.\n*/\nSQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo *p){ return p->nRef==1; }\n#endif /* SQLITE_DEBUG */\n\n/*\n** Given an expression list, generate a KeyInfo structure that records\n** the collating sequence for each expression in that expression list.\n**\n** If the ExprList is an ORDER BY or GROUP BY clause then the resulting\n** KeyInfo structure is appropriate for initializing a virtual index to\n** implement that clause.  If the ExprList is the result set of a SELECT\n** then the KeyInfo structure is appropriate for initializing a virtual\n** index to implement a DISTINCT test.\n**\n** Space to hold the KeyInfo structure is obtained from malloc.  The calling\n** function is responsible for seeing that this structure is eventually\n** freed.\n*/\nstatic KeyInfo *keyInfoFromExprList(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pList,     /* Form the KeyInfo object from this ExprList */\n  int iStart,          /* Begin with this column of pList */\n  int nExtra           /* Add this many extra columns to the end */\n){\n  int nExpr;\n  KeyInfo *pInfo;\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  int i;\n\n  nExpr = pList->nExpr;\n  pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);\n  if( pInfo ){\n    assert( sqlite3KeyInfoIsWriteable(pInfo) );\n    for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){\n      pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);\n      pInfo->aSortOrder[i-iStart] = pItem->sortOrder;\n    }\n  }\n  return pInfo;\n}\n\n/*\n** Name of the connection operator, used for error messages.\n*/\nstatic const char *selectOpName(int id){\n  char *z;\n  switch( id ){\n    case TK_ALL:       z = \"UNION ALL\";   break;\n    case TK_INTERSECT: z = \"INTERSECT\";   break;\n    case TK_EXCEPT:    z = \"EXCEPT\";      break;\n    default:           z = \"UNION\";       break;\n  }\n  return z;\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of the form:\n**\n**   \"USE TEMP B-TREE FOR xxx\"\n**\n** where xxx is one of \"DISTINCT\", \"ORDER BY\" or \"GROUP BY\". Exactly which\n** is determined by the zUsage argument.\n*/\nstatic void explainTempTable(Parse *pParse, const char *zUsage){\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(pParse->db, \"USE TEMP B-TREE FOR %s\", zUsage);\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n\n/*\n** Assign expression b to lvalue a. A second, no-op, version of this macro\n** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code\n** in sqlite3Select() to assign values to structure member variables that\n** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the\n** code with #ifndef directives.\n*/\n# define explainSetInteger(a, b) a = b\n\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainTempTable(y,z)\n# define explainSetInteger(y,z)\n#endif\n\n#if !defined(SQLITE_OMIT_EXPLAIN) && !defined(SQLITE_OMIT_COMPOUND_SELECT)\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of one of the two forms:\n**\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 (op)\"\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)\"\n**\n** where iSub1 and iSub2 are the integers passed as the corresponding\n** function parameters, and op is the text representation of the parameter\n** of the same name. The parameter \"op\" must be one of TK_UNION, TK_EXCEPT,\n** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is \n** false, or the second form if it is true.\n*/\nstatic void explainComposite(\n  Parse *pParse,                  /* Parse context */\n  int op,                         /* One of TK_UNION, TK_EXCEPT etc. */\n  int iSub1,                      /* Subquery id 1 */\n  int iSub2,                      /* Subquery id 2 */\n  int bUseTmp                     /* True if a temp table was used */\n){\n  assert( op==TK_UNION || op==TK_EXCEPT || op==TK_INTERSECT || op==TK_ALL );\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(\n        pParse->db, \"COMPOUND SUBQUERIES %d AND %d %s(%s)\", iSub1, iSub2,\n        bUseTmp?\"USING TEMP B-TREE \":\"\", selectOpName(op)\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainComposite(v,w,x,y,z)\n#endif\n\n/*\n** If the inner loop was generated using a non-null pOrderBy argument,\n** then the results were placed in a sorter.  After the loop is terminated\n** we need to run the sorter and output the results.  The following\n** routine generates the code needed to do that.\n*/\nstatic void generateSortTail(\n  Parse *pParse,    /* Parsing context */\n  Select *p,        /* The SELECT statement */\n  SortCtx *pSort,   /* Information on the ORDER BY clause */\n  int nColumn,      /* Number of columns of data */\n  SelectDest *pDest /* Write the sorted results here */\n){\n  Vdbe *v = pParse->pVdbe;                     /* The prepared statement */\n  int addrBreak = pSort->labelDone;            /* Jump here to exit loop */\n  int addrContinue = sqlite3VdbeMakeLabel(v);  /* Jump here for next cycle */\n  int addr;\n  int addrOnce = 0;\n  int iTab;\n  ExprList *pOrderBy = pSort->pOrderBy;\n  int eDest = pDest->eDest;\n  int iParm = pDest->iSDParm;\n  int regRow;\n  int regRowid;\n  int iCol;\n  int nKey;\n  int iSortTab;                   /* Sorter cursor to read from */\n  int nSortData;                  /* Trailing values to read from sorter */\n  int i;\n  int bSeq;                       /* True if sorter record includes seq. no. */\n  struct ExprList_item *aOutEx = p->pEList->a;\n\n  assert( addrBreak<0 );\n  if( pSort->labelBkOut ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeGoto(v, addrBreak);\n    sqlite3VdbeResolveLabel(v, pSort->labelBkOut);\n  }\n  iTab = pSort->iECursor;\n  if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){\n    regRowid = 0;\n    regRow = pDest->iSdst;\n    nSortData = nColumn;\n  }else{\n    regRowid = sqlite3GetTempReg(pParse);\n    regRow = sqlite3GetTempRange(pParse, nColumn);\n    nSortData = nColumn;\n  }\n  nKey = pOrderBy->nExpr - pSort->nOBSat;\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    int regSortOut = ++pParse->nMem;\n    iSortTab = pParse->nTab++;\n    if( pSort->labelBkOut ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n    }\n    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);\n    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);\n    VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);\n    bSeq = 0;\n  }else{\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    iSortTab = iTab;\n    bSeq = 1;\n  }\n  for(i=0, iCol=nKey+bSeq; i<nSortData; i++){\n    int iRead;\n    if( aOutEx[i].u.x.iOrderByCol ){\n      iRead = aOutEx[i].u.x.iOrderByCol-1;\n    }else{\n      iRead = iCol++;\n    }\n    sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);\n    VdbeComment((v, \"%s\", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));\n  }\n  switch( eDest ){\n    case SRT_Table:\n    case SRT_EphemTab: {\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case SRT_Set: {\n      assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,\n                        pDest->zAffSdst, nColumn);\n      sqlite3ExprCacheAffinityChange(pParse, regRow, nColumn);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, regRowid, regRow, nColumn);\n      break;\n    }\n    case SRT_Mem: {\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n#endif\n    default: {\n      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); \n      testcase( eDest==SRT_Output );\n      testcase( eDest==SRT_Coroutine );\n      if( eDest==SRT_Output ){\n        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);\n        sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn);\n      }else{\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }\n      break;\n    }\n  }\n  if( regRowid ){\n    if( eDest==SRT_Set ){\n      sqlite3ReleaseTempRange(pParse, regRow, nColumn);\n    }else{\n      sqlite3ReleaseTempReg(pParse, regRow);\n    }\n    sqlite3ReleaseTempReg(pParse, regRowid);\n  }\n  /* The bottom of the loop\n  */\n  sqlite3VdbeResolveLabel(v, addrContinue);\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); VdbeCoverage(v);\n  }\n  if( pSort->regReturn ) sqlite3VdbeAddOp1(v, OP_Return, pSort->regReturn);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n}\n\n/*\n** Return a pointer to a string containing the 'declaration type' of the\n** expression pExpr. The string may be treated as static by the caller.\n**\n** Also try to estimate the size of the returned value and return that\n** result in *pEstWidth.\n**\n** The declaration type is the exact datatype definition extracted from the\n** original CREATE TABLE statement if the expression is a column. The\n** declaration type for a ROWID field is INTEGER. Exactly when an expression\n** is considered a column can be complex in the presence of subqueries. The\n** result-set expression in all of the following SELECT statements is \n** considered a column by this function.\n**\n**   SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl);\n**   SELECT abc FROM (SELECT col AS abc FROM tbl);\n** \n** The declaration type for any expression other than a column is NULL.\n**\n** This routine has either 3 or 6 parameters depending on whether or not\n** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.\n*/\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B,C,D,E)\n#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B)\n#endif\nstatic const char *columnTypeImpl(\n  NameContext *pNC, \n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n  Expr *pExpr\n#else\n  Expr *pExpr,\n  const char **pzOrigDb,\n  const char **pzOrigTab,\n  const char **pzOrigCol\n#endif\n){\n  char const *zType = 0;\n  int j;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n  char const *zOrigDb = 0;\n  char const *zOrigTab = 0;\n  char const *zOrigCol = 0;\n#endif\n\n  assert( pExpr!=0 );\n  assert( pNC->pSrcList!=0 );\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      /* The expression is a column. Locate the table the column is being\n      ** extracted from in NameContext.pSrcList. This table may be real\n      ** database table or a subquery.\n      */\n      Table *pTab = 0;            /* Table structure column is extracted from */\n      Select *pS = 0;             /* Select the column is extracted from */\n      int iCol = pExpr->iColumn;  /* Index of column in pTab */\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      while( pNC && !pTab ){\n        SrcList *pTabList = pNC->pSrcList;\n        for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);\n        if( j<pTabList->nSrc ){\n          pTab = pTabList->a[j].pTab;\n          pS = pTabList->a[j].pSelect;\n        }else{\n          pNC = pNC->pNext;\n        }\n      }\n\n      if( pTab==0 ){\n        /* At one time, code such as \"SELECT new.x\" within a trigger would\n        ** cause this condition to run.  Since then, we have restructured how\n        ** trigger code is generated and so this condition is no longer \n        ** possible. However, it can still be true for statements like\n        ** the following:\n        **\n        **   CREATE TABLE t1(col INTEGER);\n        **   SELECT (SELECT t1.col) FROM FROM t1;\n        **\n        ** when columnType() is called on the expression \"t1.col\" in the \n        ** sub-select. In this case, set the column type to NULL, even\n        ** though it should really be \"INTEGER\".\n        **\n        ** This is not a problem, as the column type of \"t1.col\" is never\n        ** used. When columnType() is called on the expression \n        ** \"(SELECT t1.col)\", the correct type is returned (see the TK_SELECT\n        ** branch below.  */\n        break;\n      }\n\n      assert( pTab && pExpr->pTab==pTab );\n      if( pS ){\n        /* The \"table\" is actually a sub-select or a view in the FROM clause\n        ** of the SELECT statement. Return the declaration type and origin\n        ** data for the result-set column of the sub-select.\n        */\n        if( iCol>=0 && iCol<pS->pEList->nExpr ){\n          /* If iCol is less than zero, then the expression requests the\n          ** rowid of the sub-select or view. This expression is legal (see \n          ** test case misc2.2.2) - it always evaluates to NULL.\n          */\n          NameContext sNC;\n          Expr *p = pS->pEList->a[iCol].pExpr;\n          sNC.pSrcList = pS->pSrc;\n          sNC.pNext = pNC;\n          sNC.pParse = pNC->pParse;\n          zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol); \n        }\n      }else{\n        /* A real table or a CTE table */\n        assert( !pS );\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n        if( iCol<0 ) iCol = pTab->iPKey;\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n          zOrigCol = \"rowid\";\n        }else{\n          zOrigCol = pTab->aCol[iCol].zName;\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n        zOrigTab = pTab->zName;\n        if( pNC->pParse && pTab->pSchema ){\n          int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);\n          zOrigDb = pNC->pParse->db->aDb[iDb].zDbSName;\n        }\n#else\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n        }else{\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n#endif\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT: {\n      /* The expression is a sub-select. Return the declaration type and\n      ** origin info for the single column in the result set of the SELECT\n      ** statement.\n      */\n      NameContext sNC;\n      Select *pS = pExpr->x.pSelect;\n      Expr *p = pS->pEList->a[0].pExpr;\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n      sNC.pSrcList = pS->pSrc;\n      sNC.pNext = pNC;\n      sNC.pParse = pNC->pParse;\n      zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); \n      break;\n    }\n#endif\n  }\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA  \n  if( pzOrigDb ){\n    assert( pzOrigTab && pzOrigCol );\n    *pzOrigDb = zOrigDb;\n    *pzOrigTab = zOrigTab;\n    *pzOrigCol = zOrigCol;\n  }\n#endif\n  return zType;\n}\n\n/*\n** Generate code that will tell the VDBE the declaration types of columns\n** in the result set.\n*/\nstatic void generateColumnTypes(\n  Parse *pParse,      /* Parser context */\n  SrcList *pTabList,  /* List of tables */\n  ExprList *pEList    /* Expressions defining the result set */\n){\n#ifndef SQLITE_OMIT_DECLTYPE\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  NameContext sNC;\n  sNC.pSrcList = pTabList;\n  sNC.pParse = pParse;\n  sNC.pNext = 0;\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n    const char *zType;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n    const char *zOrigDb = 0;\n    const char *zOrigTab = 0;\n    const char *zOrigCol = 0;\n    zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);\n\n    /* The vdbe must make its own copy of the column-type and other \n    ** column specific strings, in case the schema is reset before this\n    ** virtual machine is deleted.\n    */\n    sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);\n#else\n    zType = columnType(&sNC, p, 0, 0, 0);\n#endif\n    sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);\n  }\n#endif /* !defined(SQLITE_OMIT_DECLTYPE) */\n}\n\n\n/*\n** Compute the column names for a SELECT statement.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: sqlite3ColumnsFromExprList()\n**\n** The PRAGMA short_column_names and PRAGMA full_column_names settings are\n** deprecated.  The default setting is short=ON, full=OFF.  99.9% of all\n** applications should operate this way.  Nevertheless, we need to support the\n** other modes for legacy:\n**\n**    short=OFF, full=OFF:      Column name is the text of the expression has it\n**                              originally appears in the SELECT statement.  In\n**                              other words, the zSpan of the result expression.\n**\n**    short=ON, full=OFF:       (This is the default setting).  If the result\n**                              refers directly to a table column, then the\n**                              result column name is just the table column\n**                              name: COLUMN.  Otherwise use zSpan.\n**\n**    full=ON, short=ANY:       If the result refers directly to a table column,\n**                              then the result column name with the table name\n**                              prefix, ex: TABLE.COLUMN.  Otherwise use zSpan.\n*/\nstatic void generateColumnNames(\n  Parse *pParse,      /* Parser context */\n  Select *pSelect     /* Generate column names for this SELECT statement */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  Table *pTab;\n  SrcList *pTabList;\n  ExprList *pEList;\n  sqlite3 *db = pParse->db;\n  int fullName;    /* TABLE.COLUMN if no AS clause and is a direct table ref */\n  int srcName;     /* COLUMN or TABLE.COLUMN if no AS clause and is direct */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  /* If this is an EXPLAIN, skip this step */\n  if( pParse->explain ){\n    return;\n  }\n#endif\n\n  if( pParse->colNamesSet || db->mallocFailed ) return;\n  /* Column names are determined by the left-most term of a compound select */\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  pTabList = pSelect->pSrc;\n  pEList = pSelect->pEList;\n  assert( v!=0 );\n  assert( pTabList!=0 );\n  pParse->colNamesSet = 1;\n  fullName = (db->flags & SQLITE_FullColNames)!=0;\n  srcName = (db->flags & SQLITE_ShortColNames)!=0 || fullName;\n  sqlite3VdbeSetNumCols(v, pEList->nExpr);\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n\n    assert( p!=0 );\n    assert( p->op!=TK_AGG_COLUMN );  /* Agg processing has not run yet */\n    assert( p->op!=TK_COLUMN || p->pTab!=0 ); /* Covering idx not yet coded */\n    if( pEList->a[i].zName ){\n      /* An AS clause always takes first priority */\n      char *zName = pEList->a[i].zName;\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);\n    }else if( srcName && p->op==TK_COLUMN ){\n      char *zCol;\n      int iCol = p->iColumn;\n      pTab = p->pTab;\n      assert( pTab!=0 );\n      if( iCol<0 ) iCol = pTab->iPKey;\n      assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );\n      if( iCol<0 ){\n        zCol = \"rowid\";\n      }else{\n        zCol = pTab->aCol[iCol].zName;\n      }\n      if( fullName ){\n        char *zName = 0;\n        zName = sqlite3MPrintf(db, \"%s.%s\", pTab->zName, zCol);\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);\n      }else{\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);\n      }\n    }else{\n      const char *z = pEList->a[i].zSpan;\n      z = z==0 ? sqlite3MPrintf(db, \"column%d\", i+1) : sqlite3DbStrDup(db, z);\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);\n    }\n  }\n  generateColumnTypes(pParse, pTabList, pEList);\n}\n\n/*\n** Given an expression list (which is really the list of expressions\n** that form the result set of a SELECT statement) compute appropriate\n** column names for a table that would hold the expression list.\n**\n** All column names will be unique.\n**\n** Only the column names are computed.  Column.zType, Column.zColl,\n** and other fields of Column are zeroed.\n**\n** Return SQLITE_OK on success.  If a memory allocation error occurs,\n** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: generateColumnNames()\n*/\nSQLITE_PRIVATE int sqlite3ColumnsFromExprList(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pEList,       /* Expr list from which to derive column names */\n  i16 *pnCol,             /* Write the number of columns here */\n  Column **paCol          /* Write the new column list here */\n){\n  sqlite3 *db = pParse->db;   /* Database connection */\n  int i, j;                   /* Loop counters */\n  u32 cnt;                    /* Index added to make the name unique */\n  Column *aCol, *pCol;        /* For looping over result columns */\n  int nCol;                   /* Number of columns in the result set */\n  char *zName;                /* Column name */\n  int nName;                  /* Size of name in zName[] */\n  Hash ht;                    /* Hash table of column names */\n\n  sqlite3HashInit(&ht);\n  if( pEList ){\n    nCol = pEList->nExpr;\n    aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);\n    testcase( aCol==0 );\n    if( nCol>32767 ) nCol = 32767;\n  }else{\n    nCol = 0;\n    aCol = 0;\n  }\n  assert( nCol==(i16)nCol );\n  *pnCol = nCol;\n  *paCol = aCol;\n\n  for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){\n    /* Get an appropriate name for the column\n    */\n    if( (zName = pEList->a[i].zName)!=0 ){\n      /* If the column contains an \"AS <name>\" phrase, use <name> as the name */\n    }else{\n      Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr);\n      while( pColExpr->op==TK_DOT ){\n        pColExpr = pColExpr->pRight;\n        assert( pColExpr!=0 );\n      }\n      if( (pColExpr->op==TK_COLUMN || pColExpr->op==TK_AGG_COLUMN)\n       && pColExpr->pTab!=0 \n      ){\n        /* For columns use the column name name */\n        int iCol = pColExpr->iColumn;\n        Table *pTab = pColExpr->pTab;\n        if( iCol<0 ) iCol = pTab->iPKey;\n        zName = iCol>=0 ? pTab->aCol[iCol].zName : \"rowid\";\n      }else if( pColExpr->op==TK_ID ){\n        assert( !ExprHasProperty(pColExpr, EP_IntValue) );\n        zName = pColExpr->u.zToken;\n      }else{\n        /* Use the original text of the column expression as its name */\n        zName = pEList->a[i].zSpan;\n      }\n    }\n    if( zName ){\n      zName = sqlite3DbStrDup(db, zName);\n    }else{\n      zName = sqlite3MPrintf(db,\"column%d\",i+1);\n    }\n\n    /* Make sure the column name is unique.  If the name is not unique,\n    ** append an integer to the name so that it becomes unique.\n    */\n    cnt = 0;\n    while( zName && sqlite3HashFind(&ht, zName)!=0 ){\n      nName = sqlite3Strlen30(zName);\n      if( nName>0 ){\n        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}\n        if( zName[j]==':' ) nName = j;\n      }\n      zName = sqlite3MPrintf(db, \"%.*z:%u\", nName, zName, ++cnt);\n      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);\n    }\n    pCol->zName = zName;\n    sqlite3ColumnPropertiesFromName(0, pCol);\n    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){\n      sqlite3OomFault(db);\n    }\n  }\n  sqlite3HashClear(&ht);\n  if( db->mallocFailed ){\n    for(j=0; j<i; j++){\n      sqlite3DbFree(db, aCol[j].zName);\n    }\n    sqlite3DbFree(db, aCol);\n    *paCol = 0;\n    *pnCol = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Add type and collation information to a column list based on\n** a SELECT statement.\n** \n** The column list presumably came from selectColumnNamesFromExprList().\n** The column list has only names, not types or collations.  This\n** routine goes through and adds the types and collations.\n**\n** This routine requires that all identifiers in the SELECT\n** statement be resolved.\n*/\nSQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(\n  Parse *pParse,        /* Parsing contexts */\n  Table *pTab,          /* Add column type information to this table */\n  Select *pSelect       /* SELECT used to determine types and collations */\n){\n  sqlite3 *db = pParse->db;\n  NameContext sNC;\n  Column *pCol;\n  CollSeq *pColl;\n  int i;\n  Expr *p;\n  struct ExprList_item *a;\n\n  assert( pSelect!=0 );\n  assert( (pSelect->selFlags & SF_Resolved)!=0 );\n  assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );\n  if( db->mallocFailed ) return;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pSrcList = pSelect->pSrc;\n  a = pSelect->pEList->a;\n  for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n    const char *zType;\n    int n, m;\n    p = a[i].pExpr;\n    zType = columnType(&sNC, p, 0, 0, 0);\n    /* pCol->szEst = ... // Column size est for SELECT tables never used */\n    pCol->affinity = sqlite3ExprAffinity(p);\n    if( zType ){\n      m = sqlite3Strlen30(zType);\n      n = sqlite3Strlen30(pCol->zName);\n      pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);\n      if( pCol->zName ){\n        memcpy(&pCol->zName[n+1], zType, m+1);\n        pCol->colFlags |= COLFLAG_HASTYPE;\n      }\n    }\n    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    if( pColl && pCol->zColl==0 ){\n      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);\n    }\n  }\n  pTab->szTabRow = 1; /* Any non-zero value works */\n}\n\n/*\n** Given a SELECT statement, generate a Table structure that describes\n** the result set of that SELECT.\n*/\nSQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){\n  Table *pTab;\n  sqlite3 *db = pParse->db;\n  int savedFlags;\n\n  savedFlags = db->flags;\n  db->flags &= ~SQLITE_FullColNames;\n  db->flags |= SQLITE_ShortColNames;\n  sqlite3SelectPrep(pParse, pSelect, 0);\n  if( pParse->nErr ) return 0;\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  db->flags = savedFlags;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table) );\n  if( pTab==0 ){\n    return 0;\n  }\n  /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside\n  ** is disabled */\n  assert( db->lookaside.bDisable );\n  pTab->nTabRef = 1;\n  pTab->zName = 0;\n  pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n  sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);\n  sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);\n  pTab->iPKey = -1;\n  if( db->mallocFailed ){\n    sqlite3DeleteTable(db, pTab);\n    return 0;\n  }\n  return pTab;\n}\n\n/*\n** Get a VDBE for the given parser context.  Create a new one if necessary.\n** If an error occurs, return NULL and leave a message in pParse.\n*/\nSQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse *pParse){\n  if( pParse->pVdbe ){\n    return pParse->pVdbe;\n  }\n  if( pParse->pToplevel==0\n   && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)\n  ){\n    pParse->okConstFactor = 1;\n  }\n  return sqlite3VdbeCreate(pParse);\n}\n\n\n/*\n** Compute the iLimit and iOffset fields of the SELECT based on the\n** pLimit and pOffset expressions.  pLimit and pOffset hold the expressions\n** that appear in the original SQL statement after the LIMIT and OFFSET\n** keywords.  Or NULL if those keywords are omitted. iLimit and iOffset \n** are the integer memory register numbers for counters used to compute \n** the limit and offset.  If there is no limit and/or offset, then \n** iLimit and iOffset are negative.\n**\n** This routine changes the values of iLimit and iOffset only if\n** a limit or offset is defined by pLimit and pOffset.  iLimit and\n** iOffset should have been preset to appropriate default values (zero)\n** prior to calling this routine.\n**\n** The iOffset register (if it exists) is initialized to the value\n** of the OFFSET.  The iLimit register is initialized to LIMIT.  Register\n** iOffset+1 is initialized to LIMIT+OFFSET.\n**\n** Only if pLimit!=0 or pOffset!=0 do the limit registers get\n** redefined.  The UNION ALL operator uses this property to force\n** the reuse of the same limit and offset registers across multiple\n** SELECT statements.\n*/\nstatic void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){\n  Vdbe *v = 0;\n  int iLimit = 0;\n  int iOffset;\n  int n;\n  if( p->iLimit ) return;\n\n  /* \n  ** \"LIMIT -1\" always shows all rows.  There is some\n  ** controversy about what the correct behavior should be.\n  ** The current implementation interprets \"LIMIT 0\" to mean\n  ** no rows.\n  */\n  sqlite3ExprCacheClear(pParse);\n  assert( p->pOffset==0 || p->pLimit!=0 );\n  if( p->pLimit ){\n    p->iLimit = iLimit = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    assert( v!=0 );\n    if( sqlite3ExprIsInteger(p->pLimit, &n) ){\n      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      if( n==0 ){\n        sqlite3VdbeGoto(v, iBreak);\n      }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){\n        p->nSelectRow = sqlite3LogEst((u64)n);\n        p->selFlags |= SF_FixedLimit;\n      }\n    }else{\n      sqlite3ExprCode(pParse, p->pLimit, iLimit);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);\n      VdbeComment((v, \"LIMIT counter\"));\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);\n    }\n    if( p->pOffset ){\n      p->iOffset = iOffset = ++pParse->nMem;\n      pParse->nMem++;   /* Allocate an extra register for limit+offset */\n      sqlite3ExprCode(pParse, p->pOffset, iOffset);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v);\n      VdbeComment((v, \"OFFSET counter\"));\n      sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset);\n      VdbeComment((v, \"LIMIT+OFFSET\"));\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** Return the appropriate collating sequence for the iCol-th column of\n** the result set for the compound-select statement \"p\".  Return NULL if\n** the column has no default collating sequence.\n**\n** The collating sequence for the compound select is taken from the\n** left-most term of the select that has a collating sequence.\n*/\nstatic CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){\n  CollSeq *pRet;\n  if( p->pPrior ){\n    pRet = multiSelectCollSeq(pParse, p->pPrior, iCol);\n  }else{\n    pRet = 0;\n  }\n  assert( iCol>=0 );\n  /* iCol must be less than p->pEList->nExpr.  Otherwise an error would\n  ** have been thrown during name resolution and we would not have gotten\n  ** this far */\n  if( pRet==0 && ALWAYS(iCol<p->pEList->nExpr) ){\n    pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);\n  }\n  return pRet;\n}\n\n/*\n** The select statement passed as the second parameter is a compound SELECT\n** with an ORDER BY clause. This function allocates and returns a KeyInfo\n** structure suitable for implementing the ORDER BY.\n**\n** Space to hold the KeyInfo structure is obtained from malloc. The calling\n** function is responsible for ensuring that this structure is eventually\n** freed.\n*/\nstatic KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){\n  ExprList *pOrderBy = p->pOrderBy;\n  int nOrderBy = p->pOrderBy->nExpr;\n  sqlite3 *db = pParse->db;\n  KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);\n  if( pRet ){\n    int i;\n    for(i=0; i<nOrderBy; i++){\n      struct ExprList_item *pItem = &pOrderBy->a[i];\n      Expr *pTerm = pItem->pExpr;\n      CollSeq *pColl;\n\n      if( pTerm->flags & EP_Collate ){\n        pColl = sqlite3ExprCollSeq(pParse, pTerm);\n      }else{\n        pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);\n        if( pColl==0 ) pColl = db->pDfltColl;\n        pOrderBy->a[i].pExpr =\n          sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);\n      }\n      assert( sqlite3KeyInfoIsWriteable(pRet) );\n      pRet->aColl[i] = pColl;\n      pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;\n    }\n  }\n\n  return pRet;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** This routine generates VDBE code to compute the content of a WITH RECURSIVE\n** query of the form:\n**\n**   <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)\n**                         \\___________/             \\_______________/\n**                           p->pPrior                      p\n**\n**\n** There is exactly one reference to the recursive-table in the FROM clause\n** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag.\n**\n** The setup-query runs once to generate an initial set of rows that go\n** into a Queue table.  Rows are extracted from the Queue table one by\n** one.  Each row extracted from Queue is output to pDest.  Then the single\n** extracted row (now in the iCurrent table) becomes the content of the\n** recursive-table for a recursive-query run.  The output of the recursive-query\n** is added back into the Queue table.  Then another row is extracted from Queue\n** and the iteration continues until the Queue table is empty.\n**\n** If the compound query operator is UNION then no duplicate rows are ever\n** inserted into the Queue table.  The iDistinct table keeps a copy of all rows\n** that have ever been inserted into Queue and causes duplicates to be\n** discarded.  If the operator is UNION ALL, then duplicates are allowed.\n** \n** If the query has an ORDER BY, then entries in the Queue table are kept in\n** ORDER BY order and the first entry is extracted for each cycle.  Without\n** an ORDER BY, the Queue table is just a FIFO.\n**\n** If a LIMIT clause is provided, then the iteration stops after LIMIT rows\n** have been output to pDest.  A LIMIT of zero means to output no rows and a\n** negative LIMIT means to output all rows.  If there is also an OFFSET clause\n** with a positive value, then the first OFFSET outputs are discarded rather\n** than being sent to pDest.  The LIMIT count does not begin until after OFFSET\n** rows have been skipped.\n*/\nstatic void generateWithRecursiveQuery(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The recursive SELECT to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  SrcList *pSrc = p->pSrc;      /* The FROM clause of the recursive query */\n  int nCol = p->pEList->nExpr;  /* Number of columns in the recursive table */\n  Vdbe *v = pParse->pVdbe;      /* The prepared statement under construction */\n  Select *pSetup = p->pPrior;   /* The setup query */\n  int addrTop;                  /* Top of the loop */\n  int addrCont, addrBreak;      /* CONTINUE and BREAK addresses */\n  int iCurrent = 0;             /* The Current table */\n  int regCurrent;               /* Register holding Current table */\n  int iQueue;                   /* The Queue table */\n  int iDistinct = 0;            /* To ensure unique results if UNION */\n  int eDest = SRT_Fifo;         /* How to write to Queue */\n  SelectDest destQueue;         /* SelectDest targetting the Queue table */\n  int i;                        /* Loop counter */\n  int rc;                       /* Result code */\n  ExprList *pOrderBy;           /* The ORDER BY clause */\n  Expr *pLimit, *pOffset;       /* Saved LIMIT and OFFSET */\n  int regLimit, regOffset;      /* Registers used by LIMIT and OFFSET */\n\n  /* Obtain authorization to do a recursive query */\n  if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;\n\n  /* Process the LIMIT and OFFSET clauses, if they exist */\n  addrBreak = sqlite3VdbeMakeLabel(v);\n  p->nSelectRow = 320;  /* 4 billion rows */\n  computeLimitRegisters(pParse, p, addrBreak);\n  pLimit = p->pLimit;\n  pOffset = p->pOffset;\n  regLimit = p->iLimit;\n  regOffset = p->iOffset;\n  p->pLimit = p->pOffset = 0;\n  p->iLimit = p->iOffset = 0;\n  pOrderBy = p->pOrderBy;\n\n  /* Locate the cursor number of the Current table */\n  for(i=0; ALWAYS(i<pSrc->nSrc); i++){\n    if( pSrc->a[i].fg.isRecursive ){\n      iCurrent = pSrc->a[i].iCursor;\n      break;\n    }\n  }\n\n  /* Allocate cursors numbers for Queue and Distinct.  The cursor number for\n  ** the Distinct table must be exactly one greater than Queue in order\n  ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */\n  iQueue = pParse->nTab++;\n  if( p->op==TK_UNION ){\n    eDest = pOrderBy ? SRT_DistQueue : SRT_DistFifo;\n    iDistinct = pParse->nTab++;\n  }else{\n    eDest = pOrderBy ? SRT_Queue : SRT_Fifo;\n  }\n  sqlite3SelectDestInit(&destQueue, eDest, iQueue);\n\n  /* Allocate cursors for Current, Queue, and Distinct. */\n  regCurrent = ++pParse->nMem;\n  sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);\n  if( pOrderBy ){\n    KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);\n    sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,\n                      (char*)pKeyInfo, P4_KEYINFO);\n    destQueue.pOrderBy = pOrderBy;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);\n  }\n  VdbeComment((v, \"Queue table\"));\n  if( iDistinct ){\n    p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);\n    p->selFlags |= SF_UsesEphemeral;\n  }\n\n  /* Detach the ORDER BY clause from the compound SELECT */\n  p->pOrderBy = 0;\n\n  /* Store the results of the setup-query in Queue. */\n  pSetup->pNext = 0;\n  rc = sqlite3Select(pParse, pSetup, &destQueue);\n  pSetup->pNext = p;\n  if( rc ) goto end_of_recursive_query;\n\n  /* Find the next row in the Queue and output that row */\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);\n\n  /* Transfer the next row in Queue over to Current */\n  sqlite3VdbeAddOp1(v, OP_NullRow, iCurrent); /* To reset column cache */\n  if( pOrderBy ){\n    sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent);\n  }\n  sqlite3VdbeAddOp1(v, OP_Delete, iQueue);\n\n  /* Output the single row in Current */\n  addrCont = sqlite3VdbeMakeLabel(v);\n  codeOffset(v, regOffset, addrCont);\n  selectInnerLoop(pParse, p, iCurrent,\n      0, 0, pDest, addrCont, addrBreak);\n  if( regLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);\n    VdbeCoverage(v);\n  }\n  sqlite3VdbeResolveLabel(v, addrCont);\n\n  /* Execute the recursive SELECT taking the single row in Current as\n  ** the value for the recursive-table. Store the results in the Queue.\n  */\n  if( p->selFlags & SF_Aggregate ){\n    sqlite3ErrorMsg(pParse, \"recursive aggregate queries not supported\");\n  }else{\n    p->pPrior = 0;\n    sqlite3Select(pParse, p, &destQueue);\n    assert( p->pPrior==0 );\n    p->pPrior = pSetup;\n  }\n\n  /* Keep running the loop until the Queue is empty */\n  sqlite3VdbeGoto(v, addrTop);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n\nend_of_recursive_query:\n  sqlite3ExprListDelete(pParse->db, p->pOrderBy);\n  p->pOrderBy = pOrderBy;\n  p->pLimit = pLimit;\n  p->pOffset = pOffset;\n  return;\n}\n#endif /* SQLITE_OMIT_CTE */\n\n/* Forward references */\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n);\n\n/*\n** Handle the special case of a compound-select that originates from a\n** VALUES clause.  By handling this as a special case, we avoid deep\n** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT\n** on a VALUES clause.\n**\n** Because the Select object originates from a VALUES clause:\n**   (1) It has no LIMIT or OFFSET\n**   (2) All terms are UNION ALL\n**   (3) There is no ORDER BY clause\n*/\nstatic int multiSelectValues(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  Select *pPrior;\n  int nRow = 1;\n  int rc = 0;\n  assert( p->selFlags & SF_MultiValue );\n  do{\n    assert( p->selFlags & SF_Values );\n    assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );\n    assert( p->pLimit==0 );\n    assert( p->pOffset==0 );\n    assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );\n    if( p->pPrior==0 ) break;\n    assert( p->pPrior->pNext==p );\n    p = p->pPrior;\n    nRow++;\n  }while(1);\n  while( p ){\n    pPrior = p->pPrior;\n    p->pPrior = 0;\n    rc = sqlite3Select(pParse, p, pDest);\n    p->pPrior = pPrior;\n    if( rc ) break;\n    p->nSelectRow = nRow;\n    p = p->pNext;\n  }\n  return rc;\n}\n\n/*\n** This routine is called to process a compound query form from\n** two or more separate queries using UNION, UNION ALL, EXCEPT, or\n** INTERSECT\n**\n** \"p\" points to the right-most of the two queries.  the query on the\n** left is p->pPrior.  The left query could also be a compound query\n** in which case this routine will be called recursively. \n**\n** The results of the total query are to be written into a destination\n** of type eDest with parameter iParm.\n**\n** Example 1:  Consider a three-way compound SQL statement.\n**\n**     SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3\n**\n** This statement is parsed up as follows:\n**\n**     SELECT c FROM t3\n**      |\n**      `----->  SELECT b FROM t2\n**                |\n**                `------>  SELECT a FROM t1\n**\n** The arrows in the diagram above represent the Select.pPrior pointer.\n** So if this routine is called with p equal to the t3 query, then\n** pPrior will be the t2 query.  p->op will be TK_UNION in this case.\n**\n** Notice that because of the way SQLite parses compound SELECTs, the\n** individual selects always group from left to right.\n*/\nstatic int multiSelect(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int rc = SQLITE_OK;   /* Success code from a subroutine */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest dest;      /* Alternative data destination */\n  Select *pDelete = 0;  /* Chain of simple selects to delete */\n  sqlite3 *db;          /* Database connection */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1 = 0;        /* EQP id of left-hand query */\n  int iSub2 = 0;        /* EQP id of right-hand query */\n#endif\n\n  /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only\n  ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.\n  */\n  assert( p && p->pPrior );  /* Calling function guarantees this much */\n  assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );\n  db = pParse->db;\n  pPrior = p->pPrior;\n  dest = *pDest;\n  if( pPrior->pOrderBy || pPrior->pLimit ){\n    sqlite3ErrorMsg(pParse,\"%s clause should come after %s not before\",\n      pPrior->pOrderBy!=0 ? \"ORDER BY\" : \"LIMIT\", selectOpName(p->op));\n    rc = 1;\n    goto multi_select_end;\n  }\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );  /* The VDBE already created by calling function */\n\n  /* Create the destination temporary table if necessary\n  */\n  if( dest.eDest==SRT_EphemTab ){\n    assert( p->pEList );\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);\n    dest.eDest = SRT_Table;\n  }\n\n  /* Special handling for a compound-select that originates as a VALUES clause.\n  */\n  if( p->selFlags & SF_MultiValue ){\n    rc = multiSelectValues(pParse, p, &dest);\n    goto multi_select_end;\n  }\n\n  /* Make sure all SELECTs in the statement have the same number of elements\n  ** in their result sets.\n  */\n  assert( p->pEList && pPrior->pEList );\n  assert( p->pEList->nExpr==pPrior->pEList->nExpr );\n\n#ifndef SQLITE_OMIT_CTE\n  if( p->selFlags & SF_Recursive ){\n    generateWithRecursiveQuery(pParse, p, &dest);\n  }else\n#endif\n\n  /* Compound SELECTs that have an ORDER BY clause are handled separately.\n  */\n  if( p->pOrderBy ){\n    return multiSelectOrderBy(pParse, p, pDest);\n  }else\n\n  /* Generate code for the left and right SELECT statements.\n  */\n  switch( p->op ){\n    case TK_ALL: {\n      int addr = 0;\n      int nLimit;\n      assert( !pPrior->pLimit );\n      pPrior->iLimit = p->iLimit;\n      pPrior->iOffset = p->iOffset;\n      pPrior->pLimit = p->pLimit;\n      pPrior->pOffset = p->pOffset;\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &dest);\n      p->pLimit = 0;\n      p->pOffset = 0;\n      if( rc ){\n        goto multi_select_end;\n      }\n      p->pPrior = 0;\n      p->iLimit = pPrior->iLimit;\n      p->iOffset = pPrior->iOffset;\n      if( p->iLimit ){\n        addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);\n        VdbeComment((v, \"Jump ahead if LIMIT reached\"));\n        if( p->iOffset ){\n          sqlite3VdbeAddOp3(v, OP_OffsetLimit,\n                            p->iLimit, p->iOffset+1, p->iOffset);\n        }\n      }\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &dest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n      if( pPrior->pLimit\n       && sqlite3ExprIsInteger(pPrior->pLimit, &nLimit)\n       && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) \n      ){\n        p->nSelectRow = sqlite3LogEst((u64)nLimit);\n      }\n      if( addr ){\n        sqlite3VdbeJumpHere(v, addr);\n      }\n      break;\n    }\n    case TK_EXCEPT:\n    case TK_UNION: {\n      int unionTab;    /* Cursor number of the temporary table holding result */\n      u8 op = 0;       /* One of the SRT_ operations to apply to self */\n      int priorOp;     /* The SRT_ operation to apply to prior selects */\n      Expr *pLimit, *pOffset; /* Saved values of p->nLimit and p->nOffset */\n      int addr;\n      SelectDest uniondest;\n\n      testcase( p->op==TK_EXCEPT );\n      testcase( p->op==TK_UNION );\n      priorOp = SRT_Union;\n      if( dest.eDest==priorOp ){\n        /* We can reuse a temporary table generated by a SELECT to our\n        ** right.\n        */\n        assert( p->pLimit==0 );      /* Not allowed on leftward elements */\n        assert( p->pOffset==0 );     /* Not allowed on leftward elements */\n        unionTab = dest.iSDParm;\n      }else{\n        /* We will need to create our own temporary table to hold the\n        ** intermediate results.\n        */\n        unionTab = pParse->nTab++;\n        assert( p->pOrderBy==0 );\n        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);\n        assert( p->addrOpenEphm[0] == -1 );\n        p->addrOpenEphm[0] = addr;\n        findRightmost(p)->selFlags |= SF_UsesEphemeral;\n        assert( p->pEList );\n      }\n\n      /* Code the SELECT statements to our left\n      */\n      assert( !pPrior->pOrderBy );\n      sqlite3SelectDestInit(&uniondest, priorOp, unionTab);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &uniondest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT statement\n      */\n      if( p->op==TK_EXCEPT ){\n        op = SRT_Except;\n      }else{\n        assert( p->op==TK_UNION );\n        op = SRT_Union;\n      }\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      uniondest.eDest = op;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &uniondest);\n      testcase( rc!=SQLITE_OK );\n      /* Query flattening in sqlite3Select() might refill p->pOrderBy.\n      ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */\n      sqlite3ExprListDelete(db, p->pOrderBy);\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->pOrderBy = 0;\n      if( p->op==TK_UNION ){\n        p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n      }\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n      p->iLimit = 0;\n      p->iOffset = 0;\n\n      /* Convert the data in the temporary table into whatever form\n      ** it is that we currently need.\n      */\n      assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );\n      if( dest.eDest!=priorOp ){\n        int iCont, iBreak, iStart;\n        assert( p->pEList );\n        iBreak = sqlite3VdbeMakeLabel(v);\n        iCont = sqlite3VdbeMakeLabel(v);\n        computeLimitRegisters(pParse, p, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);\n        iStart = sqlite3VdbeCurrentAddr(v);\n        selectInnerLoop(pParse, p, unionTab,\n                        0, 0, &dest, iCont, iBreak);\n        sqlite3VdbeResolveLabel(v, iCont);\n        sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);\n        sqlite3VdbeResolveLabel(v, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);\n      }\n      break;\n    }\n    default: assert( p->op==TK_INTERSECT ); {\n      int tab1, tab2;\n      int iCont, iBreak, iStart;\n      Expr *pLimit, *pOffset;\n      int addr;\n      SelectDest intersectdest;\n      int r1;\n\n      /* INTERSECT is different from the others since it requires\n      ** two temporary tables.  Hence it has its own case.  Begin\n      ** by allocating the tables we will need.\n      */\n      tab1 = pParse->nTab++;\n      tab2 = pParse->nTab++;\n      assert( p->pOrderBy==0 );\n\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);\n      assert( p->addrOpenEphm[0] == -1 );\n      p->addrOpenEphm[0] = addr;\n      findRightmost(p)->selFlags |= SF_UsesEphemeral;\n      assert( p->pEList );\n\n      /* Code the SELECTs to our left into temporary table \"tab1\".\n      */\n      sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &intersectdest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT into temporary table \"tab2\"\n      */\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);\n      assert( p->addrOpenEphm[1] == -1 );\n      p->addrOpenEphm[1] = addr;\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      intersectdest.iSDParm = tab2;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &intersectdest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      if( p->nSelectRow>pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n\n      /* Generate code to take the intersection of the two temporary\n      ** tables.\n      */\n      assert( p->pEList );\n      iBreak = sqlite3VdbeMakeLabel(v);\n      iCont = sqlite3VdbeMakeLabel(v);\n      computeLimitRegisters(pParse, p, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);\n      r1 = sqlite3GetTempReg(pParse);\n      iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); VdbeCoverage(v);\n      sqlite3ReleaseTempReg(pParse, r1);\n      selectInnerLoop(pParse, p, tab1,\n                      0, 0, &dest, iCont, iBreak);\n      sqlite3VdbeResolveLabel(v, iCont);\n      sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);\n      sqlite3VdbeResolveLabel(v, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);\n      sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);\n      break;\n    }\n  }\n\n  explainComposite(pParse, p->op, iSub1, iSub2, p->op!=TK_ALL);\n\n  /* Compute collating sequences used by \n  ** temporary tables needed to implement the compound select.\n  ** Attach the KeyInfo structure to all temporary tables.\n  **\n  ** This section is run by the right-most SELECT statement only.\n  ** SELECT statements to the left always skip this part.  The right-most\n  ** SELECT might also skip this part if it has no ORDER BY clause and\n  ** no temp tables are required.\n  */\n  if( p->selFlags & SF_UsesEphemeral ){\n    int i;                        /* Loop counter */\n    KeyInfo *pKeyInfo;            /* Collating sequence for the result set */\n    Select *pLoop;                /* For looping through SELECT statements */\n    CollSeq **apColl;             /* For looping through pKeyInfo->aColl[] */\n    int nCol;                     /* Number of columns in result set */\n\n    assert( p->pNext==0 );\n    nCol = p->pEList->nExpr;\n    pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);\n    if( !pKeyInfo ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto multi_select_end;\n    }\n    for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){\n      *apColl = multiSelectCollSeq(pParse, p, i);\n      if( 0==*apColl ){\n        *apColl = db->pDfltColl;\n      }\n    }\n\n    for(pLoop=p; pLoop; pLoop=pLoop->pPrior){\n      for(i=0; i<2; i++){\n        int addr = pLoop->addrOpenEphm[i];\n        if( addr<0 ){\n          /* If [0] is unused then [1] is also unused.  So we can\n          ** always safely abort as soon as the first unused slot is found */\n          assert( pLoop->addrOpenEphm[1]<0 );\n          break;\n        }\n        sqlite3VdbeChangeP2(v, addr, nCol);\n        sqlite3VdbeChangeP4(v, addr, (char*)sqlite3KeyInfoRef(pKeyInfo),\n                            P4_KEYINFO);\n        pLoop->addrOpenEphm[i] = -1;\n      }\n    }\n    sqlite3KeyInfoUnref(pKeyInfo);\n  }\n\nmulti_select_end:\n  pDest->iSdst = dest.iSdst;\n  pDest->nSdst = dest.nSdst;\n  sqlite3SelectDelete(db, pDelete);\n  return rc;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n/*\n** Error message for when two or more terms of a compound select have different\n** size result sets.\n*/\nSQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){\n  if( p->selFlags & SF_Values ){\n    sqlite3ErrorMsg(pParse, \"all VALUES must have the same number of terms\");\n  }else{\n    sqlite3ErrorMsg(pParse, \"SELECTs to the left and right of %s\"\n      \" do not have the same number of result columns\", selectOpName(p->op));\n  }\n}\n\n/*\n** Code an output subroutine for a coroutine implementation of a\n** SELECT statment.\n**\n** The data to be output is contained in pIn->iSdst.  There are\n** pIn->nSdst columns to be output.  pDest is where the output should\n** be sent.\n**\n** regReturn is the number of the register holding the subroutine\n** return address.\n**\n** If regPrev>0 then it is the first register in a vector that\n** records the previous output.  mem[regPrev] is a flag that is false\n** if there has been no previous output.  If regPrev>0 then code is\n** generated to suppress duplicates.  pKeyInfo is used for comparing\n** keys.\n**\n** If the LIMIT found in p->iLimit is reached, jump immediately to\n** iBreak.\n*/\nstatic int generateOutputSubroutine(\n  Parse *pParse,          /* Parsing context */\n  Select *p,              /* The SELECT statement */\n  SelectDest *pIn,        /* Coroutine supplying data */\n  SelectDest *pDest,      /* Where to send the data */\n  int regReturn,          /* The return address register */\n  int regPrev,            /* Previous result register.  No uniqueness if 0 */\n  KeyInfo *pKeyInfo,      /* For comparing with previous entry */\n  int iBreak              /* Jump here if we hit the LIMIT */\n){\n  Vdbe *v = pParse->pVdbe;\n  int iContinue;\n  int addr;\n\n  addr = sqlite3VdbeCurrentAddr(v);\n  iContinue = sqlite3VdbeMakeLabel(v);\n\n  /* Suppress duplicates for UNION, EXCEPT, and INTERSECT \n  */\n  if( regPrev ){\n    int addr1, addr2;\n    addr1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);\n    addr2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,\n                              (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n    sqlite3VdbeAddOp3(v, OP_Jump, addr2+2, iContinue, addr2+2); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);\n  }\n  if( pParse->db->mallocFailed ) return 0;\n\n  /* Suppress the first OFFSET entries if there is an OFFSET clause\n  */\n  codeOffset(v, p->iOffset, iContinue);\n\n  assert( pDest->eDest!=SRT_Exists );\n  assert( pDest->eDest!=SRT_Table );\n  switch( pDest->eDest ){\n    /* Store the result as data using a unique key.\n    */\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempReg(pParse);\n      int r2 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);\n      sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      sqlite3ReleaseTempReg(pParse, r2);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\".\n    */\n    case SRT_Set: {\n      int r1;\n      testcase( pIn->nSdst>1 );\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, \n          r1, pDest->zAffSdst, pIn->nSdst);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1,\n                           pIn->iSdst, pIn->nSdst);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell and break out\n    ** of the scan loop.\n    */\n    case SRT_Mem: {\n      assert( pIn->nSdst==1 || pParse->nErr>0 );  testcase( pIn->nSdst!=1 );\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);\n      /* The LIMIT clause will jump out of the loop for us */\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    /* The results are stored in a sequence of registers\n    ** starting at pDest->iSdst.  Then the co-routine yields.\n    */\n    case SRT_Coroutine: {\n      if( pDest->iSdst==0 ){\n        pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);\n        pDest->nSdst = pIn->nSdst;\n      }\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);\n      sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      break;\n    }\n\n    /* If none of the above, then the result destination must be\n    ** SRT_Output.  This routine is never called with any other\n    ** destination other than the ones handled above or SRT_Output.\n    **\n    ** For SRT_Output, results are stored in a sequence of registers.  \n    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to\n    ** return the next row of result.\n    */\n    default: {\n      assert( pDest->eDest==SRT_Output );\n      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);\n      break;\n    }\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.\n  */\n  if( p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n\n  /* Generate the subroutine return\n  */\n  sqlite3VdbeResolveLabel(v, iContinue);\n  sqlite3VdbeAddOp1(v, OP_Return, regReturn);\n\n  return addr;\n}\n\n/*\n** Alternative compound select code generator for cases when there\n** is an ORDER BY clause.\n**\n** We assume a query of the following form:\n**\n**      <selectA>  <operator>  <selectB>  ORDER BY <orderbylist>\n**\n** <operator> is one of UNION ALL, UNION, EXCEPT, or INTERSECT.  The idea\n** is to code both <selectA> and <selectB> with the ORDER BY clause as\n** co-routines.  Then run the co-routines in parallel and merge the results\n** into the output.  In addition to the two coroutines (called selectA and\n** selectB) there are 7 subroutines:\n**\n**    outA:    Move the output of the selectA coroutine into the output\n**             of the compound query.\n**\n**    outB:    Move the output of the selectB coroutine into the output\n**             of the compound query.  (Only generated for UNION and\n**             UNION ALL.  EXCEPT and INSERTSECT never output a row that\n**             appears only in B.)\n**\n**    AltB:    Called when there is data from both coroutines and A<B.\n**\n**    AeqB:    Called when there is data from both coroutines and A==B.\n**\n**    AgtB:    Called when there is data from both coroutines and A>B.\n**\n**    EofA:    Called when data is exhausted from selectA.\n**\n**    EofB:    Called when data is exhausted from selectB.\n**\n** The implementation of the latter five subroutines depend on which \n** <operator> is used:\n**\n**\n**             UNION ALL         UNION            EXCEPT          INTERSECT\n**          -------------  -----------------  --------------  -----------------\n**   AltB:   outA, nextA      outA, nextA       outA, nextA         nextA\n**\n**   AeqB:   outA, nextA         nextA             nextA         outA, nextA\n**\n**   AgtB:   outB, nextB      outB, nextB          nextB            nextB\n**\n**   EofA:   outB, nextB      outB, nextB          halt             halt\n**\n**   EofB:   outA, nextA      outA, nextA       outA, nextA         halt\n**\n** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA\n** causes an immediate jump to EofA and an EOF on B following nextB causes\n** an immediate jump to EofB.  Within EofA and EofB, and EOF on entry or\n** following nextX causes a jump to the end of the select processing.\n**\n** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled\n** within the output subroutine.  The regPrev register set holds the previously\n** output value.  A comparison is made against this value and the output\n** is skipped if the next results would be the same as the previous.\n**\n** The implementation plan is to implement the two coroutines and seven\n** subroutines first, then put the control logic at the bottom.  Like this:\n**\n**          goto Init\n**     coA: coroutine for left query (A)\n**     coB: coroutine for right query (B)\n**    outA: output one row of A\n**    outB: output one row of B (UNION and UNION ALL only)\n**    EofA: ...\n**    EofB: ...\n**    AltB: ...\n**    AeqB: ...\n**    AgtB: ...\n**    Init: initialize coroutine registers\n**          yield coA\n**          if eof(A) goto EofA\n**          yield coB\n**          if eof(B) goto EofB\n**    Cmpr: Compare A, B\n**          Jump AltB, AeqB, AgtB\n**     End: ...\n**\n** We call AltB, AeqB, AgtB, EofA, and EofB \"subroutines\" but they are not\n** actually called using Gosub and they do not Return.  EofA and EofB loop\n** until all data is exhausted then jump to the \"end\" labe.  AltB, AeqB,\n** and AgtB jump to either L2 or to one of EofA or EofB.\n*/\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int i, j;             /* Loop counters */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest destA;     /* Destination for coroutine A */\n  SelectDest destB;     /* Destination for coroutine B */\n  int regAddrA;         /* Address register for select-A coroutine */\n  int regAddrB;         /* Address register for select-B coroutine */\n  int addrSelectA;      /* Address of the select-A coroutine */\n  int addrSelectB;      /* Address of the select-B coroutine */\n  int regOutA;          /* Address register for the output-A subroutine */\n  int regOutB;          /* Address register for the output-B subroutine */\n  int addrOutA;         /* Address of the output-A subroutine */\n  int addrOutB = 0;     /* Address of the output-B subroutine */\n  int addrEofA;         /* Address of the select-A-exhausted subroutine */\n  int addrEofA_noB;     /* Alternate addrEofA if B is uninitialized */\n  int addrEofB;         /* Address of the select-B-exhausted subroutine */\n  int addrAltB;         /* Address of the A<B subroutine */\n  int addrAeqB;         /* Address of the A==B subroutine */\n  int addrAgtB;         /* Address of the A>B subroutine */\n  int regLimitA;        /* Limit register for select-A */\n  int regLimitB;        /* Limit register for select-A */\n  int regPrev;          /* A range of registers to hold previous output */\n  int savedLimit;       /* Saved value of p->iLimit */\n  int savedOffset;      /* Saved value of p->iOffset */\n  int labelCmpr;        /* Label for the start of the merge algorithm */\n  int labelEnd;         /* Label for the end of the overall SELECT stmt */\n  int addr1;            /* Jump instructions that get retargetted */\n  int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */\n  KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */\n  KeyInfo *pKeyMerge;   /* Comparison information for merging rows */\n  sqlite3 *db;          /* Database connection */\n  ExprList *pOrderBy;   /* The ORDER BY clause */\n  int nOrderBy;         /* Number of terms in the ORDER BY clause */\n  int *aPermute;        /* Mapping from ORDER BY terms to result set columns */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1;            /* EQP id of left-hand query */\n  int iSub2;            /* EQP id of right-hand query */\n#endif\n\n  assert( p->pOrderBy!=0 );\n  assert( pKeyDup==0 ); /* \"Managed\" code needs this.  Ticket #3382. */\n  db = pParse->db;\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* Already thrown the error if VDBE alloc failed */\n  labelEnd = sqlite3VdbeMakeLabel(v);\n  labelCmpr = sqlite3VdbeMakeLabel(v);\n\n\n  /* Patch up the ORDER BY clause\n  */\n  op = p->op;  \n  pPrior = p->pPrior;\n  assert( pPrior->pOrderBy==0 );\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy );\n  nOrderBy = pOrderBy->nExpr;\n\n  /* For operators other than UNION ALL we have to make sure that\n  ** the ORDER BY clause covers every term of the result set.  Add\n  ** terms to the ORDER BY clause as necessary.\n  */\n  if( op!=TK_ALL ){\n    for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){\n      struct ExprList_item *pItem;\n      for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){\n        assert( pItem->u.x.iOrderByCol>0 );\n        if( pItem->u.x.iOrderByCol==i ) break;\n      }\n      if( j==nOrderBy ){\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = i;\n        p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew);\n        if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i;\n      }\n    }\n  }\n\n  /* Compute the comparison permutation and keyinfo that is used with\n  ** the permutation used to determine if the next\n  ** row of results comes from selectA or selectB.  Also add explicit\n  ** collations to the ORDER BY clause terms so that when the subqueries\n  ** to the right and the left are evaluated, they use the correct\n  ** collation.\n  */\n  aPermute = sqlite3DbMallocRawNN(db, sizeof(int)*(nOrderBy + 1));\n  if( aPermute ){\n    struct ExprList_item *pItem;\n    aPermute[0] = nOrderBy;\n    for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){\n      assert( pItem->u.x.iOrderByCol>0 );\n      assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );\n      aPermute[i] = pItem->u.x.iOrderByCol - 1;\n    }\n    pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);\n  }else{\n    pKeyMerge = 0;\n  }\n\n  /* Reattach the ORDER BY clause to the query.\n  */\n  p->pOrderBy = pOrderBy;\n  pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);\n\n  /* Allocate a range of temporary registers and the KeyInfo needed\n  ** for the logic that removes duplicate result rows when the\n  ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).\n  */\n  if( op==TK_ALL ){\n    regPrev = 0;\n  }else{\n    int nExpr = p->pEList->nExpr;\n    assert( nOrderBy>=nExpr || db->mallocFailed );\n    regPrev = pParse->nMem+1;\n    pParse->nMem += nExpr+1;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);\n    pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);\n    if( pKeyDup ){\n      assert( sqlite3KeyInfoIsWriteable(pKeyDup) );\n      for(i=0; i<nExpr; i++){\n        pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);\n        pKeyDup->aSortOrder[i] = 0;\n      }\n    }\n  }\n \n  /* Separate the left and the right query from one another\n  */\n  p->pPrior = 0;\n  pPrior->pNext = 0;\n  sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, \"ORDER\");\n  if( pPrior->pPrior==0 ){\n    sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, \"ORDER\");\n  }\n\n  /* Compute the limit registers */\n  computeLimitRegisters(pParse, p, labelEnd);\n  if( p->iLimit && op==TK_ALL ){\n    regLimitA = ++pParse->nMem;\n    regLimitB = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit,\n                                  regLimitA);\n    sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB);\n  }else{\n    regLimitA = regLimitB = 0;\n  }\n  sqlite3ExprDelete(db, p->pLimit);\n  p->pLimit = 0;\n  sqlite3ExprDelete(db, p->pOffset);\n  p->pOffset = 0;\n\n  regAddrA = ++pParse->nMem;\n  regAddrB = ++pParse->nMem;\n  regOutA = ++pParse->nMem;\n  regOutB = ++pParse->nMem;\n  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);\n  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);\n\n  /* Generate a coroutine to evaluate the SELECT statement to the\n  ** left of the compound operator - the \"A\" select.\n  */\n  addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);\n  VdbeComment((v, \"left SELECT\"));\n  pPrior->iLimit = regLimitA;\n  explainSetInteger(iSub1, pParse->iNextSelectId);\n  sqlite3Select(pParse, pPrior, &destA);\n  sqlite3VdbeEndCoroutine(v, regAddrA);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  /* Generate a coroutine to evaluate the SELECT statement on \n  ** the right - the \"B\" select\n  */\n  addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);\n  VdbeComment((v, \"right SELECT\"));\n  savedLimit = p->iLimit;\n  savedOffset = p->iOffset;\n  p->iLimit = regLimitB;\n  p->iOffset = 0;  \n  explainSetInteger(iSub2, pParse->iNextSelectId);\n  sqlite3Select(pParse, p, &destB);\n  p->iLimit = savedLimit;\n  p->iOffset = savedOffset;\n  sqlite3VdbeEndCoroutine(v, regAddrB);\n\n  /* Generate a subroutine that outputs the current row of the A\n  ** select as the next output row of the compound select.\n  */\n  VdbeNoopComment((v, \"Output routine for A\"));\n  addrOutA = generateOutputSubroutine(pParse,\n                 p, &destA, pDest, regOutA,\n                 regPrev, pKeyDup, labelEnd);\n  \n  /* Generate a subroutine that outputs the current row of the B\n  ** select as the next output row of the compound select.\n  */\n  if( op==TK_ALL || op==TK_UNION ){\n    VdbeNoopComment((v, \"Output routine for B\"));\n    addrOutB = generateOutputSubroutine(pParse,\n                 p, &destB, pDest, regOutB,\n                 regPrev, pKeyDup, labelEnd);\n  }\n  sqlite3KeyInfoUnref(pKeyDup);\n\n  /* Generate a subroutine to run when the results from select A\n  ** are exhausted and only data in select B remains.\n  */\n  if( op==TK_EXCEPT || op==TK_INTERSECT ){\n    addrEofA_noB = addrEofA = labelEnd;\n  }else{  \n    VdbeNoopComment((v, \"eof-A subroutine\"));\n    addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n    addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd);\n                                     VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofA);\n    p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n  }\n\n  /* Generate a subroutine to run when the results from select B\n  ** are exhausted and only data in select A remains.\n  */\n  if( op==TK_INTERSECT ){\n    addrEofB = addrEofA;\n    if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n  }else{  \n    VdbeNoopComment((v, \"eof-B subroutine\"));\n    addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofB);\n  }\n\n  /* Generate code to handle the case of A<B\n  */\n  VdbeNoopComment((v, \"A-lt-B subroutine\"));\n  addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* Generate code to handle the case of A==B\n  */\n  if( op==TK_ALL ){\n    addrAeqB = addrAltB;\n  }else if( op==TK_INTERSECT ){\n    addrAeqB = addrAltB;\n    addrAltB++;\n  }else{\n    VdbeNoopComment((v, \"A-eq-B subroutine\"));\n    addrAeqB =\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, labelCmpr);\n  }\n\n  /* Generate code to handle the case of A>B\n  */\n  VdbeNoopComment((v, \"A-gt-B subroutine\"));\n  addrAgtB = sqlite3VdbeCurrentAddr(v);\n  if( op==TK_ALL || op==TK_UNION ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n  }\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* This code runs once to initialize everything.\n  */\n  sqlite3VdbeJumpHere(v, addr1);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n\n  /* Implement the main merge loop\n  */\n  sqlite3VdbeResolveLabel(v, labelCmpr);\n  sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);\n  sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,\n                         (char*)pKeyMerge, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);\n  sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); VdbeCoverage(v);\n\n  /* Jump to the this point in order to terminate the query.\n  */\n  sqlite3VdbeResolveLabel(v, labelEnd);\n\n  /* Reassembly the compound query so that it will be freed correctly\n  ** by the calling function */\n  if( p->pPrior ){\n    sqlite3SelectDelete(db, p->pPrior);\n  }\n  p->pPrior = pPrior;\n  pPrior->pNext = p;\n\n  /*** TBD:  Insert subroutine calls to close cursors on incomplete\n  **** subqueries ****/\n  explainComposite(pParse, p->op, iSub1, iSub2, 0);\n  return pParse->nErr!=0;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n\n/* An instance of the SubstContext object describes an substitution edit\n** to be performed on a parse tree.\n**\n** All references to columns in table iTable are to be replaced by corresponding\n** expressions in pEList.\n*/\ntypedef struct SubstContext {\n  Parse *pParse;            /* The parsing context */\n  int iTable;               /* Replace references to this table */\n  int iNewTable;            /* New table number */\n  int isLeftJoin;           /* Add TK_IF_NULL_ROW opcodes on each replacement */\n  ExprList *pEList;         /* Replacement expressions */\n} SubstContext;\n\n/* Forward Declarations */\nstatic void substExprList(SubstContext*, ExprList*);\nstatic void substSelect(SubstContext*, Select*, int);\n\n/*\n** Scan through the expression pExpr.  Replace every reference to\n** a column in table number iTable with a copy of the iColumn-th\n** entry in pEList.  (But leave references to the ROWID column \n** unchanged.)\n**\n** This routine is part of the flattening procedure.  A subquery\n** whose result set is defined by pEList appears as entry in the\n** FROM clause of a SELECT such that the VDBE cursor assigned to that\n** FORM clause entry is iTable.  This routine makes the necessary \n** changes to pExpr so that it refers directly to the source table\n** of the subquery rather the result set of the subquery.\n*/\nstatic Expr *substExpr(\n  SubstContext *pSubst,  /* Description of the substitution */\n  Expr *pExpr            /* Expr in which substitution occurs */\n){\n  if( pExpr==0 ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin)\n   && pExpr->iRightJoinTable==pSubst->iTable\n  ){\n    pExpr->iRightJoinTable = pSubst->iNewTable;\n  }\n  if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){\n    if( pExpr->iColumn<0 ){\n      pExpr->op = TK_NULL;\n    }else{\n      Expr *pNew;\n      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;\n      Expr ifNullRow;\n      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );\n      assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n      if( sqlite3ExprIsVector(pCopy) ){\n        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);\n      }else{\n        sqlite3 *db = pSubst->pParse->db;\n        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){\n          memset(&ifNullRow, 0, sizeof(ifNullRow));\n          ifNullRow.op = TK_IF_NULL_ROW;\n          ifNullRow.pLeft = pCopy;\n          ifNullRow.iTable = pSubst->iNewTable;\n          pCopy = &ifNullRow;\n        }\n        pNew = sqlite3ExprDup(db, pCopy, 0);\n        if( pNew && pSubst->isLeftJoin ){\n          ExprSetProperty(pNew, EP_CanBeNull);\n        }\n        if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){\n          pNew->iRightJoinTable = pExpr->iRightJoinTable;\n          ExprSetProperty(pNew, EP_FromJoin);\n        }\n        sqlite3ExprDelete(db, pExpr);\n        pExpr = pNew;\n      }\n    }\n  }else{\n    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){\n      pExpr->iTable = pSubst->iNewTable;\n    }\n    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);\n    pExpr->pRight = substExpr(pSubst, pExpr->pRight);\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      substSelect(pSubst, pExpr->x.pSelect, 1);\n    }else{\n      substExprList(pSubst, pExpr->x.pList);\n    }\n  }\n  return pExpr;\n}\nstatic void substExprList(\n  SubstContext *pSubst, /* Description of the substitution */\n  ExprList *pList       /* List to scan and in which to make substitutes */\n){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nExpr; i++){\n    pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr);\n  }\n}\nstatic void substSelect(\n  SubstContext *pSubst, /* Description of the substitution */\n  Select *p,            /* SELECT statement in which to make substitutions */\n  int doPrior           /* Do substitutes on p->pPrior too */\n){\n  SrcList *pSrc;\n  struct SrcList_item *pItem;\n  int i;\n  if( !p ) return;\n  do{\n    substExprList(pSubst, p->pEList);\n    substExprList(pSubst, p->pGroupBy);\n    substExprList(pSubst, p->pOrderBy);\n    p->pHaving = substExpr(pSubst, p->pHaving);\n    p->pWhere = substExpr(pSubst, p->pWhere);\n    pSrc = p->pSrc;\n    assert( pSrc!=0 );\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      substSelect(pSubst, pItem->pSelect, 1);\n      if( pItem->fg.isTabFunc ){\n        substExprList(pSubst, pItem->u1.pFuncArg);\n      }\n    }\n  }while( doPrior && (p = p->pPrior)!=0 );\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** This routine attempts to flatten subqueries as a performance optimization.\n** This routine returns 1 if it makes changes and 0 if no flattening occurs.\n**\n** To understand the concept of flattening, consider the following\n** query:\n**\n**     SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5\n**\n** The default way of implementing this query is to execute the\n** subquery first and store the results in a temporary table, then\n** run the outer query on that temporary table.  This requires two\n** passes over the data.  Furthermore, because the temporary table\n** has no indices, the WHERE clause on the outer query cannot be\n** optimized.\n**\n** This routine attempts to rewrite queries such as the above into\n** a single flat select, like this:\n**\n**     SELECT x+y AS a FROM t1 WHERE z<100 AND a>5\n**\n** The code generated for this simplification gives the same result\n** but only has to scan the data once.  And because indices might \n** exist on the table t1, a complete scan of the data might be\n** avoided.\n**\n** Flattening is subject to the following constraints:\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        The subquery and the outer query cannot both be aggregates.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        (2) If the subquery is an aggregate then\n**        (2a) the outer query must not be a join and\n**        (2b) the outer query must not use subqueries\n**             other than the one FROM-clause subquery that is a candidate\n**             for flattening.  (This is due to ticket [2f7170d73bf9abf80]\n**             from 2015-02-09.)\n**\n**   (3)  If the subquery is the right operand of a LEFT JOIN then\n**        (3a) the subquery may not be a join and\n**        (3b) the FROM clause of the subquery may not contain a virtual\n**             table and\n**        (3c) the outer query may not be an aggregate.\n**\n**   (4)  The subquery can not be DISTINCT.\n**\n**  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT\n**        sub-queries that were excluded from this optimization. Restriction \n**        (4) has since been expanded to exclude all DISTINCT subqueries.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        If the subquery is aggregate, the outer query may not be DISTINCT.\n**\n**   (7)  The subquery must have a FROM clause.  TODO:  For subqueries without\n**        A FROM clause, consider adding a FROM clause with the special\n**        table sqlite_once that consists of a single row containing a\n**        single NULL.\n**\n**   (8)  If the subquery uses LIMIT then the outer query may not be a join.\n**\n**   (9)  If the subquery uses LIMIT then the outer query may not be aggregate.\n**\n**  (**)  Restriction (10) was removed from the code on 2005-02-05 but we\n**        accidently carried the comment forward until 2014-09-15.  Original\n**        constraint: \"If the subquery is aggregate then the outer query \n**        may not use LIMIT.\"\n**\n**  (11)  The subquery and the outer query may not both have ORDER BY clauses.\n**\n**  (**)  Not implemented.  Subsumed into restriction (3).  Was previously\n**        a separate restriction deriving from ticket #350.\n**\n**  (13)  The subquery and outer query may not both use LIMIT.\n**\n**  (14)  The subquery may not use OFFSET.\n**\n**  (15)  If the outer query is part of a compound select, then the\n**        subquery may not use LIMIT.\n**        (See ticket #2339 and ticket [02a8e81d44]).\n**\n**  (16)  If the outer query is aggregate, then the subquery may not\n**        use ORDER BY.  (Ticket #2942)  This used to not matter\n**        until we introduced the group_concat() function.  \n**\n**  (17)  If the subquery is a compound select, then\n**        (17a) all compound operators must be a UNION ALL, and\n**        (17b) no terms within the subquery compound may be aggregate\n**              or DISTINCT, and\n**        (17c) every term within the subquery compound must have a FROM clause\n**        (17d) the outer query may not be\n**              (17d1) aggregate, or\n**              (17d2) DISTINCT, or\n**              (17d3) a join.\n**\n**        The parent and sub-query may contain WHERE clauses. Subject to\n**        rules (11), (13) and (14), they may also contain ORDER BY,\n**        LIMIT and OFFSET clauses.  The subquery cannot use any compound\n**        operator other than UNION ALL because all the other compound\n**        operators have an implied DISTINCT which is disallowed by\n**        restriction (4).\n**\n**        Also, each component of the sub-query must return the same number\n**        of result columns. This is actually a requirement for any compound\n**        SELECT statement, but all the code here does is make sure that no\n**        such (illegal) sub-query is flattened. The caller will detect the\n**        syntax error and return a detailed message.\n**\n**  (18)  If the sub-query is a compound select, then all terms of the\n**        ORDER BY clause of the parent must be simple references to \n**        columns of the sub-query.\n**\n**  (19)  If the subquery uses LIMIT then the outer query may not\n**        have a WHERE clause.\n**\n**  (**)  Subsumed into (17d3).  Was: If the sub-query is a compound select,\n**        then it must not use an ORDER BY clause - Ticket #3773.  Because\n**        of (17d3), then only way to have a compound subquery is if it is\n**        the only term in the FROM clause of the outer query.  But if the\n**        only term in the FROM clause has an ORDER BY, then it will be\n**        implemented as a co-routine and the flattener will never be called.\n**\n**  (21)  If the subquery uses LIMIT then the outer query may not be\n**        DISTINCT.  (See ticket [752e1646fc]).\n**\n**  (22)  The subquery may not be a recursive CTE.\n**\n**  (**)  Subsumed into restriction (17d3).  Was: If the outer query is\n**        a recursive CTE, then the sub-query may not be a compound query.\n**        This restriction is because transforming the\n**        parent to a compound query confuses the code that handles\n**        recursive queries in multiSelect().\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        The subquery may not be an aggregate that uses the built-in min() or \n**        or max() functions.  (Without this restriction, a query like:\n**        \"SELECT x FROM (SELECT max(y), x FROM t1)\" would not necessarily\n**        return the value X for which Y was maximal.)\n**\n**\n** In this routine, the \"p\" parameter is a pointer to the outer query.\n** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query\n** uses aggregates.\n**\n** If flattening is not attempted, this routine is a no-op and returns 0.\n** If flattening is attempted this routine returns 1.\n**\n** All of the expression analysis must occur on both the outer query and\n** the subquery before this routine runs.\n*/\nstatic int flattenSubquery(\n  Parse *pParse,       /* Parsing context */\n  Select *p,           /* The parent or outer SELECT statement */\n  int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */\n  int isAgg            /* True if outer SELECT uses aggregate functions */\n){\n  const char *zSavedAuthContext = pParse->zAuthContext;\n  Select *pParent;    /* Current UNION ALL term of the other query */\n  Select *pSub;       /* The inner query or \"subquery\" */\n  Select *pSub1;      /* Pointer to the rightmost select in sub-query */\n  SrcList *pSrc;      /* The FROM clause of the outer query */\n  SrcList *pSubSrc;   /* The FROM clause of the subquery */\n  int iParent;        /* VDBE cursor number of the pSub result set temp table */\n  int iNewParent = -1;/* Replacement table for iParent */\n  int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */    \n  int i;              /* Loop counter */\n  Expr *pWhere;                    /* The WHERE clause */\n  struct SrcList_item *pSubitem;   /* The subquery */\n  sqlite3 *db = pParse->db;\n\n  /* Check to see if flattening is permitted.  Return 0 if not.\n  */\n  assert( p!=0 );\n  assert( p->pPrior==0 );\n  if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;\n  pSrc = p->pSrc;\n  assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );\n  pSubitem = &pSrc->a[iFrom];\n  iParent = pSubitem->iCursor;\n  pSub = pSubitem->pSelect;\n  assert( pSub!=0 );\n\n  pSubSrc = pSub->pSrc;\n  assert( pSubSrc );\n  /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,\n  ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET\n  ** because they could be computed at compile-time.  But when LIMIT and OFFSET\n  ** became arbitrary expressions, we were forced to add restrictions (13)\n  ** and (14). */\n  if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */\n  if( pSub->pOffset ) return 0;                          /* Restriction (14) */\n  if( (p->selFlags & SF_Compound)!=0 && pSub->pLimit ){\n    return 0;                                            /* Restriction (15) */\n  }\n  if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */\n  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (4)  */\n  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){\n     return 0;         /* Restrictions (8)(9) */\n  }\n  if( p->pOrderBy && pSub->pOrderBy ){\n     return 0;                                           /* Restriction (11) */\n  }\n  if( isAgg && pSub->pOrderBy ) return 0;                /* Restriction (16) */\n  if( pSub->pLimit && p->pWhere ) return 0;              /* Restriction (19) */\n  if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){\n     return 0;         /* Restriction (21) */\n  }\n  if( pSub->selFlags & (SF_Recursive) ){\n    return 0; /* Restrictions (22) */\n  }\n\n  /*\n  ** If the subquery is the right operand of a LEFT JOIN, then the\n  ** subquery may not be a join itself (3a). Example of why this is not\n  ** allowed:\n  **\n  **         t1 LEFT OUTER JOIN (t2 JOIN t3)\n  **\n  ** If we flatten the above, we would get\n  **\n  **         (t1 LEFT OUTER JOIN t2) JOIN t3\n  **\n  ** which is not at all the same thing.\n  **\n  ** If the subquery is the right operand of a LEFT JOIN, then the outer\n  ** query cannot be an aggregate. (3c)  This is an artifact of the way\n  ** aggregates are processed - there is no mechanism to determine if\n  ** the LEFT JOIN table should be all-NULL.\n  **\n  ** See also tickets #306, #350, and #3300.\n  */\n  if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){\n    isLeftJoin = 1;\n    if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){\n      /*  (3a)             (3c)     (3b) */\n      return 0;\n    }\n  }\n#ifdef SQLITE_EXTRA_IFNULLROW\n  else if( iFrom>0 && !isAgg ){\n    /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for\n    ** every reference to any result column from subquery in a join, even\n    ** though they are not necessary.  This will stress-test the OP_IfNullRow \n    ** opcode. */\n    isLeftJoin = -1;\n  }\n#endif\n\n  /* Restriction (17): If the sub-query is a compound SELECT, then it must\n  ** use only the UNION ALL operator. And none of the simple select queries\n  ** that make up the compound SELECT are allowed to be aggregate or distinct\n  ** queries.\n  */\n  if( pSub->pPrior ){\n    if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){\n      return 0; /* (17d1), (17d2), or (17d3) */\n    }\n    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n      assert( pSub->pSrc!=0 );\n      assert( pSub->pEList->nExpr==pSub1->pEList->nExpr );\n      if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0    /* (17b) */\n       || (pSub1->pPrior && pSub1->op!=TK_ALL)                 /* (17a) */\n       || pSub1->pSrc->nSrc<1                                  /* (17c) */\n      ){\n        return 0;\n      }\n      testcase( pSub1->pSrc->nSrc>1 );\n    }\n\n    /* Restriction (18). */\n    if( p->pOrderBy ){\n      int ii;\n      for(ii=0; ii<p->pOrderBy->nExpr; ii++){\n        if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0;\n      }\n    }\n  }\n\n  /* Ex-restriction (23):\n  ** The only way that the recursive part of a CTE can contain a compound\n  ** subquery is for the subquery to be one term of a join.  But if the\n  ** subquery is a join, then the flattening has already been stopped by\n  ** restriction (17d3)\n  */\n  assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );\n\n  /* Ex-restriction (20):\n  ** A compound subquery must be the only term in the FROM clause of the\n  ** outer query by restriction (17d3).  But if that term also has an\n  ** ORDER BY clause, then the subquery will be implemented by co-routine\n  ** and so the flattener will never be invoked.  Hence, it is not possible\n  ** for the subquery to be a compound and have an ORDER BY clause.\n  */\n  assert( pSub->pPrior==0 || pSub->pOrderBy==0 );\n\n  /***** If we reach this point, flattening is permitted. *****/\n  SELECTTRACE(1,pParse,p,(\"flatten %s.%p from term %d\\n\",\n                   pSub->zSelName, pSub, iFrom));\n\n  /* Authorize the subquery */\n  pParse->zAuthContext = pSubitem->zName;\n  TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);\n  testcase( i==SQLITE_DENY );\n  pParse->zAuthContext = zSavedAuthContext;\n\n  /* If the sub-query is a compound SELECT statement, then (by restrictions\n  ** 17 and 18 above) it must be a UNION ALL and the parent query must \n  ** be of the form:\n  **\n  **     SELECT <expr-list> FROM (<sub-query>) <where-clause> \n  **\n  ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block\n  ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or \n  ** OFFSET clauses and joins them to the left-hand-side of the original\n  ** using UNION ALL operators. In this case N is the number of simple\n  ** select statements in the compound sub-query.\n  **\n  ** Example:\n  **\n  **     SELECT a+1 FROM (\n  **        SELECT x FROM tab\n  **        UNION ALL\n  **        SELECT y FROM tab\n  **        UNION ALL\n  **        SELECT abs(z*2) FROM tab2\n  **     ) WHERE a!=5 ORDER BY 1\n  **\n  ** Transformed into:\n  **\n  **     SELECT x+1 FROM tab WHERE x+1!=5\n  **     UNION ALL\n  **     SELECT y+1 FROM tab WHERE y+1!=5\n  **     UNION ALL\n  **     SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5\n  **     ORDER BY 1\n  **\n  ** We call this the \"compound-subquery flattening\".\n  */\n  for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){\n    Select *pNew;\n    ExprList *pOrderBy = p->pOrderBy;\n    Expr *pLimit = p->pLimit;\n    Expr *pOffset = p->pOffset;\n    Select *pPrior = p->pPrior;\n    p->pOrderBy = 0;\n    p->pSrc = 0;\n    p->pPrior = 0;\n    p->pLimit = 0;\n    p->pOffset = 0;\n    pNew = sqlite3SelectDup(db, p, 0);\n    sqlite3SelectSetName(pNew, pSub->zSelName);\n    p->pOffset = pOffset;\n    p->pLimit = pLimit;\n    p->pOrderBy = pOrderBy;\n    p->pSrc = pSrc;\n    p->op = TK_ALL;\n    if( pNew==0 ){\n      p->pPrior = pPrior;\n    }else{\n      pNew->pPrior = pPrior;\n      if( pPrior ) pPrior->pNext = pNew;\n      pNew->pNext = p;\n      p->pPrior = pNew;\n      SELECTTRACE(2,pParse,p,\n         (\"compound-subquery flattener creates %s.%p as peer\\n\",\n         pNew->zSelName, pNew));\n    }\n    if( db->mallocFailed ) return 1;\n  }\n\n  /* Begin flattening the iFrom-th entry of the FROM clause \n  ** in the outer query.\n  */\n  pSub = pSub1 = pSubitem->pSelect;\n\n  /* Delete the transient table structure associated with the\n  ** subquery\n  */\n  sqlite3DbFree(db, pSubitem->zDatabase);\n  sqlite3DbFree(db, pSubitem->zName);\n  sqlite3DbFree(db, pSubitem->zAlias);\n  pSubitem->zDatabase = 0;\n  pSubitem->zName = 0;\n  pSubitem->zAlias = 0;\n  pSubitem->pSelect = 0;\n\n  /* Defer deleting the Table object associated with the\n  ** subquery until code generation is\n  ** complete, since there may still exist Expr.pTab entries that\n  ** refer to the subquery even after flattening.  Ticket #3346.\n  **\n  ** pSubitem->pTab is always non-NULL by test restrictions and tests above.\n  */\n  if( ALWAYS(pSubitem->pTab!=0) ){\n    Table *pTabToDel = pSubitem->pTab;\n    if( pTabToDel->nTabRef==1 ){\n      Parse *pToplevel = sqlite3ParseToplevel(pParse);\n      pTabToDel->pNextZombie = pToplevel->pZombieTab;\n      pToplevel->pZombieTab = pTabToDel;\n    }else{\n      pTabToDel->nTabRef--;\n    }\n    pSubitem->pTab = 0;\n  }\n\n  /* The following loop runs once for each term in a compound-subquery\n  ** flattening (as described above).  If we are doing a different kind\n  ** of flattening - a flattening other than a compound-subquery flattening -\n  ** then this loop only runs once.\n  **\n  ** This loop moves all of the FROM elements of the subquery into the\n  ** the FROM clause of the outer query.  Before doing this, remember\n  ** the cursor number for the original outer query FROM element in\n  ** iParent.  The iParent cursor will never be used.  Subsequent code\n  ** will scan expressions looking for iParent references and replace\n  ** those references with expressions that resolve to the subquery FROM\n  ** elements we are now copying in.\n  */\n  for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){\n    int nSubSrc;\n    u8 jointype = 0;\n    pSubSrc = pSub->pSrc;     /* FROM clause of subquery */\n    nSubSrc = pSubSrc->nSrc;  /* Number of terms in subquery FROM clause */\n    pSrc = pParent->pSrc;     /* FROM clause of the outer query */\n\n    if( pSrc ){\n      assert( pParent==p );  /* First time through the loop */\n      jointype = pSubitem->fg.jointype;\n    }else{\n      assert( pParent!=p );  /* 2nd and subsequent times through the loop */\n      pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n      if( pSrc==0 ){\n        assert( db->mallocFailed );\n        break;\n      }\n    }\n\n    /* The subquery uses a single slot of the FROM clause of the outer\n    ** query.  If the subquery has more than one element in its FROM clause,\n    ** then expand the outer query to make space for it to hold all elements\n    ** of the subquery.\n    **\n    ** Example:\n    **\n    **    SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;\n    **\n    ** The outer query has 3 slots in its FROM clause.  One slot of the\n    ** outer query (the middle slot) is used by the subquery.  The next\n    ** block of code will expand the outer query FROM clause to 4 slots.\n    ** The middle slot is expanded to two slots in order to make space\n    ** for the two elements in the FROM clause of the subquery.\n    */\n    if( nSubSrc>1 ){\n      pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);\n      if( db->mallocFailed ){\n        break;\n      }\n    }\n\n    /* Transfer the FROM clause terms from the subquery into the\n    ** outer query.\n    */\n    for(i=0; i<nSubSrc; i++){\n      sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing);\n      assert( pSrc->a[i+iFrom].fg.isTabFunc==0 );\n      pSrc->a[i+iFrom] = pSubSrc->a[i];\n      iNewParent = pSubSrc->a[i].iCursor;\n      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));\n    }\n    pSrc->a[iFrom].fg.jointype = jointype;\n  \n    /* Now begin substituting subquery result set expressions for \n    ** references to the iParent in the outer query.\n    ** \n    ** Example:\n    **\n    **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;\n    **   \\                     \\_____________ subquery __________/          /\n    **    \\_____________________ outer query ______________________________/\n    **\n    ** We look at every expression in the outer query and every place we see\n    ** \"a\" we substitute \"x*3\" and every place we see \"b\" we substitute \"y+10\".\n    */\n    if( pSub->pOrderBy ){\n      /* At this point, any non-zero iOrderByCol values indicate that the\n      ** ORDER BY column expression is identical to the iOrderByCol'th\n      ** expression returned by SELECT statement pSub. Since these values\n      ** do not necessarily correspond to columns in SELECT statement pParent,\n      ** zero them before transfering the ORDER BY clause.\n      **\n      ** Not doing this may cause an error if a subsequent call to this\n      ** function attempts to flatten a compound sub-query into pParent\n      ** (the only way this can happen is if the compound sub-query is\n      ** currently part of pSub->pSrc). See ticket [d11a6e908f].  */\n      ExprList *pOrderBy = pSub->pOrderBy;\n      for(i=0; i<pOrderBy->nExpr; i++){\n        pOrderBy->a[i].u.x.iOrderByCol = 0;\n      }\n      assert( pParent->pOrderBy==0 );\n      assert( pSub->pPrior==0 );\n      pParent->pOrderBy = pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n    pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);\n    if( isLeftJoin>0 ){\n      setJoinExpr(pWhere, iNewParent);\n    }\n    pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);\n    if( db->mallocFailed==0 ){\n      SubstContext x;\n      x.pParse = pParse;\n      x.iTable = iParent;\n      x.iNewTable = iNewParent;\n      x.isLeftJoin = isLeftJoin;\n      x.pEList = pSub->pEList;\n      substSelect(&x, pParent, 0);\n    }\n  \n    /* The flattened query is distinct if either the inner or the\n    ** outer query is distinct. \n    */\n    pParent->selFlags |= pSub->selFlags & SF_Distinct;\n  \n    /*\n    ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;\n    **\n    ** One is tempted to try to add a and b to combine the limits.  But this\n    ** does not work if either limit is negative.\n    */\n    if( pSub->pLimit ){\n      pParent->pLimit = pSub->pLimit;\n      pSub->pLimit = 0;\n    }\n  }\n\n  /* Finially, delete what is left of the subquery and return\n  ** success.\n  */\n  sqlite3SelectDelete(db, pSub1);\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x100 ){\n    SELECTTRACE(0x100,pParse,p,(\"After flattening:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  return 1;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** Make copies of relevant WHERE clause terms of the outer query into\n** the WHERE clause of subquery.  Example:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10;\n**\n** Transformed into:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1 WHERE a=5 AND c-d=10)\n**     WHERE x=5 AND y=10;\n**\n** The hope is that the terms added to the inner query will make it more\n** efficient.\n**\n** Do not attempt this optimization if:\n**\n**   (1) (** This restriction was removed on 2017-09-29.  We used to\n**           disallow this optimization for aggregate subqueries, but now\n**           it is allowed by putting the extra terms on the HAVING clause.\n**           The added HAVING clause is pointless if the subquery lacks\n**           a GROUP BY clause.  But such a HAVING clause is also harmless\n**           so there does not appear to be any reason to add extra logic\n**           to suppress it. **)\n**\n**   (2) The inner query is the recursive part of a common table expression.\n**\n**   (3) The inner query has a LIMIT clause (since the changes to the WHERE\n**       close would change the meaning of the LIMIT).\n**\n**   (4) The inner query is the right operand of a LEFT JOIN.  (The caller\n**       enforces this restriction since this routine does not have enough\n**       information to know.)\n**\n**   (5) The WHERE clause expression originates in the ON or USING clause\n**       of a LEFT JOIN.\n**\n** Return 0 if no changes are made and non-zero if one or more WHERE clause\n** terms are duplicated into the subquery.\n*/\nstatic int pushDownWhereTerms(\n  Parse *pParse,        /* Parse context (for malloc() and error reporting) */\n  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */\n  Expr *pWhere,         /* The WHERE clause of the outer query */\n  int iCursor           /* Cursor number of the subquery */\n){\n  Expr *pNew;\n  int nChng = 0;\n  if( pWhere==0 ) return 0;\n  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */\n\n#ifdef SQLITE_DEBUG\n  /* Only the first term of a compound can have a WITH clause.  But make\n  ** sure no other terms are marked SF_Recursive in case something changes\n  ** in the future.\n  */\n  {\n    Select *pX;  \n    for(pX=pSubq; pX; pX=pX->pPrior){\n      assert( (pX->selFlags & (SF_Recursive))==0 );\n    }\n  }\n#endif\n\n  if( pSubq->pLimit!=0 ){\n    return 0; /* restriction (3) */\n  }\n  while( pWhere->op==TK_AND ){\n    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, iCursor);\n    pWhere = pWhere->pLeft;\n  }\n  if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction (5) */\n  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){\n    nChng++;\n    while( pSubq ){\n      SubstContext x;\n      pNew = sqlite3ExprDup(pParse->db, pWhere, 0);\n      x.pParse = pParse;\n      x.iTable = iCursor;\n      x.iNewTable = iCursor;\n      x.isLeftJoin = 0;\n      x.pEList = pSubq->pEList;\n      pNew = substExpr(&x, pNew);\n      if( pSubq->selFlags & SF_Aggregate ){\n        pSubq->pHaving = sqlite3ExprAnd(pParse->db, pSubq->pHaving, pNew);\n      }else{\n        pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew);\n      }\n      pSubq = pSubq->pPrior;\n    }\n  }\n  return nChng;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n/*\n** Based on the contents of the AggInfo structure indicated by the first\n** argument, this function checks if the following are true:\n**\n**    * the query contains just a single aggregate function,\n**    * the aggregate function is either min() or max(), and\n**    * the argument to the aggregate function is a column value.\n**\n** If all of the above are true, then WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX\n** is returned as appropriate. Also, *ppMinMax is set to point to the \n** list of arguments passed to the aggregate before returning.\n**\n** Or, if the conditions above are not met, *ppMinMax is set to 0 and\n** WHERE_ORDERBY_NORMAL is returned.\n*/\nstatic u8 minMaxQuery(AggInfo *pAggInfo, ExprList **ppMinMax){\n  int eRet = WHERE_ORDERBY_NORMAL;          /* Return value */\n\n  *ppMinMax = 0;\n  if( pAggInfo->nFunc==1 ){\n    Expr *pExpr = pAggInfo->aFunc[0].pExpr; /* Aggregate function */\n    ExprList *pEList = pExpr->x.pList;      /* Arguments to agg function */\n\n    assert( pExpr->op==TK_AGG_FUNCTION );\n    if( pEList && pEList->nExpr==1 && pEList->a[0].pExpr->op==TK_AGG_COLUMN ){\n      const char *zFunc = pExpr->u.zToken;\n      if( sqlite3StrICmp(zFunc, \"min\")==0 ){\n        eRet = WHERE_ORDERBY_MIN;\n        *ppMinMax = pEList;\n      }else if( sqlite3StrICmp(zFunc, \"max\")==0 ){\n        eRet = WHERE_ORDERBY_MAX;\n        *ppMinMax = pEList;\n      }\n    }\n  }\n\n  assert( *ppMinMax==0 || (*ppMinMax)->nExpr==1 );\n  return eRet;\n}\n\n/*\n** The select statement passed as the first argument is an aggregate query.\n** The second argument is the associated aggregate-info object. This \n** function tests if the SELECT is of the form:\n**\n**   SELECT count(*) FROM <tbl>\n**\n** where table is a database table, not a sub-select or view. If the query\n** does match this pattern, then a pointer to the Table object representing\n** <tbl> is returned. Otherwise, 0 is returned.\n*/\nstatic Table *isSimpleCount(Select *p, AggInfo *pAggInfo){\n  Table *pTab;\n  Expr *pExpr;\n\n  assert( !p->pGroupBy );\n\n  if( p->pWhere || p->pEList->nExpr!=1 \n   || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect\n  ){\n    return 0;\n  }\n  pTab = p->pSrc->a[0].pTab;\n  pExpr = p->pEList->a[0].pExpr;\n  assert( pTab && !pTab->pSelect && pExpr );\n\n  if( IsVirtual(pTab) ) return 0;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;\n  if( NEVER(pAggInfo->nFunc==0) ) return 0;\n  if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;\n  if( pExpr->flags&EP_Distinct ) return 0;\n\n  return pTab;\n}\n\n/*\n** If the source-list item passed as an argument was augmented with an\n** INDEXED BY clause, then try to locate the specified index. If there\n** was such a clause and the named index cannot be found, return \n** SQLITE_ERROR and leave an error in pParse. Otherwise, populate \n** pFrom->pIndex and return SQLITE_OK.\n*/\nSQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->pTab && pFrom->fg.isIndexedBy ){\n    Table *pTab = pFrom->pTab;\n    char *zIndexedBy = pFrom->u1.zIndexedBy;\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; \n        pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); \n        pIdx=pIdx->pNext\n    );\n    if( !pIdx ){\n      sqlite3ErrorMsg(pParse, \"no such index: %s\", zIndexedBy, 0);\n      pParse->checkSchema = 1;\n      return SQLITE_ERROR;\n    }\n    pFrom->pIBIndex = pIdx;\n  }\n  return SQLITE_OK;\n}\n/*\n** Detect compound SELECT statements that use an ORDER BY clause with \n** an alternative collating sequence.\n**\n**    SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ...\n**\n** These are rewritten as a subquery:\n**\n**    SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2)\n**     ORDER BY ... COLLATE ...\n**\n** This transformation is necessary because the multiSelectOrderBy() routine\n** above that generates the code for a compound SELECT with an ORDER BY clause\n** uses a merge algorithm that requires the same collating sequence on the\n** result columns as on the ORDER BY clause.  See ticket\n** http://www.sqlite.org/src/info/6709574d2a\n**\n** This transformation is only needed for EXCEPT, INTERSECT, and UNION.\n** The UNION ALL operator works fine with multiSelectOrderBy() even when\n** there are COLLATE terms in the ORDER BY.\n*/\nstatic int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){\n  int i;\n  Select *pNew;\n  Select *pX;\n  sqlite3 *db;\n  struct ExprList_item *a;\n  SrcList *pNewSrc;\n  Parse *pParse;\n  Token dummy;\n\n  if( p->pPrior==0 ) return WRC_Continue;\n  if( p->pOrderBy==0 ) return WRC_Continue;\n  for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){}\n  if( pX==0 ) return WRC_Continue;\n  a = p->pOrderBy->a;\n  for(i=p->pOrderBy->nExpr-1; i>=0; i--){\n    if( a[i].pExpr->flags & EP_Collate ) break;\n  }\n  if( i<0 ) return WRC_Continue;\n\n  /* If we reach this point, that means the transformation is required. */\n\n  pParse = pWalker->pParse;\n  db = pParse->db;\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );\n  if( pNew==0 ) return WRC_Abort;\n  memset(&dummy, 0, sizeof(dummy));\n  pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);\n  if( pNewSrc==0 ) return WRC_Abort;\n  *pNew = *p;\n  p->pSrc = pNewSrc;\n  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0));\n  p->op = TK_SELECT;\n  p->pWhere = 0;\n  pNew->pGroupBy = 0;\n  pNew->pHaving = 0;\n  pNew->pOrderBy = 0;\n  p->pPrior = 0;\n  p->pNext = 0;\n  p->pWith = 0;\n  p->selFlags &= ~SF_Compound;\n  assert( (p->selFlags & SF_Converted)==0 );\n  p->selFlags |= SF_Converted;\n  assert( pNew->pPrior!=0 );\n  pNew->pPrior->pNext = pNew;\n  pNew->pLimit = 0;\n  pNew->pOffset = 0;\n  return WRC_Continue;\n}\n\n/*\n** Check to see if the FROM clause term pFrom has table-valued function\n** arguments.  If it does, leave an error message in pParse and return\n** non-zero, since pFrom is not allowed to be a table-valued function.\n*/\nstatic int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->fg.isTabFunc ){\n    sqlite3ErrorMsg(pParse, \"'%s' is not a function\", pFrom->zName);\n    return 1;\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** Argument pWith (which may be NULL) points to a linked list of nested \n** WITH contexts, from inner to outermost. If the table identified by \n** FROM clause element pItem is really a common-table-expression (CTE) \n** then return a pointer to the CTE definition for that table. Otherwise\n** return NULL.\n**\n** If a non-NULL value is returned, set *ppContext to point to the With\n** object that the returned CTE belongs to.\n*/\nstatic struct Cte *searchWith(\n  With *pWith,                    /* Current innermost WITH clause */\n  struct SrcList_item *pItem,     /* FROM clause element to resolve */\n  With **ppContext                /* OUT: WITH clause return value belongs to */\n){\n  const char *zName;\n  if( pItem->zDatabase==0 && (zName = pItem->zName)!=0 ){\n    With *p;\n    for(p=pWith; p; p=p->pOuter){\n      int i;\n      for(i=0; i<p->nCte; i++){\n        if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){\n          *ppContext = p;\n          return &p->a[i];\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/* The code generator maintains a stack of active WITH clauses\n** with the inner-most WITH clause being at the top of the stack.\n**\n** This routine pushes the WITH clause passed as the second argument\n** onto the top of the stack. If argument bFree is true, then this\n** WITH clause will never be popped from the stack. In this case it\n** should be freed along with the Parse object. In other cases, when\n** bFree==0, the With object will be freed along with the SELECT \n** statement with which it is associated.\n*/\nSQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){\n  assert( bFree==0 || (pParse->pWith==0 && pParse->pWithToFree==0) );\n  if( pWith ){\n    assert( pParse->pWith!=pWith );\n    pWith->pOuter = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bFree ) pParse->pWithToFree = pWith;\n  }\n}\n\n/*\n** This function checks if argument pFrom refers to a CTE declared by \n** a WITH clause on the stack currently maintained by the parser. And,\n** if currently processing a CTE expression, if it is a recursive\n** reference to the current CTE.\n**\n** If pFrom falls into either of the two categories above, pFrom->pTab\n** and other fields are populated accordingly. The caller should check\n** (pFrom->pTab!=0) to determine whether or not a successful match\n** was found.\n**\n** Whether or not a match is found, SQLITE_OK is returned if no error\n** occurs. If an error does occur, an error message is stored in the\n** parser and some error code other than SQLITE_OK returned.\n*/\nstatic int withExpand(\n  Walker *pWalker, \n  struct SrcList_item *pFrom\n){\n  Parse *pParse = pWalker->pParse;\n  sqlite3 *db = pParse->db;\n  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */\n  With *pWith;                    /* WITH clause that pCte belongs to */\n\n  assert( pFrom->pTab==0 );\n\n  pCte = searchWith(pParse->pWith, pFrom, &pWith);\n  if( pCte ){\n    Table *pTab;\n    ExprList *pEList;\n    Select *pSel;\n    Select *pLeft;                /* Left-most SELECT statement */\n    int bMayRecursive;            /* True if compound joined by UNION [ALL] */\n    With *pSavedWith;             /* Initial value of pParse->pWith */\n\n    /* If pCte->zCteErr is non-NULL at this point, then this is an illegal\n    ** recursive reference to CTE pCte. Leave an error in pParse and return\n    ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.\n    ** In this case, proceed.  */\n    if( pCte->zCteErr ){\n      sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName);\n      return SQLITE_ERROR;\n    }\n    if( cannotBeFunction(pParse, pFrom) ) return SQLITE_ERROR;\n\n    assert( pFrom->pTab==0 );\n    pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n    if( pTab==0 ) return WRC_Abort;\n    pTab->nTabRef = 1;\n    pTab->zName = sqlite3DbStrDup(db, pCte->zName);\n    pTab->iPKey = -1;\n    pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n    pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;\n    pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);\n    if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n    assert( pFrom->pSelect );\n\n    /* Check if this is a recursive CTE. */\n    pSel = pFrom->pSelect;\n    bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );\n    if( bMayRecursive ){\n      int i;\n      SrcList *pSrc = pFrom->pSelect->pSrc;\n      for(i=0; i<pSrc->nSrc; i++){\n        struct SrcList_item *pItem = &pSrc->a[i];\n        if( pItem->zDatabase==0 \n         && pItem->zName!=0 \n         && 0==sqlite3StrICmp(pItem->zName, pCte->zName)\n          ){\n          pItem->pTab = pTab;\n          pItem->fg.isRecursive = 1;\n          pTab->nTabRef++;\n          pSel->selFlags |= SF_Recursive;\n        }\n      }\n    }\n\n    /* Only one recursive reference is permitted. */ \n    if( pTab->nTabRef>2 ){\n      sqlite3ErrorMsg(\n          pParse, \"multiple references to recursive table: %s\", pCte->zName\n      );\n      return SQLITE_ERROR;\n    }\n    assert( pTab->nTabRef==1 || \n            ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));\n\n    pCte->zCteErr = \"circular reference: %s\";\n    pSavedWith = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bMayRecursive ){\n      Select *pPrior = pSel->pPrior;\n      assert( pPrior->pWith==0 );\n      pPrior->pWith = pSel->pWith;\n      sqlite3WalkSelect(pWalker, pPrior);\n      pPrior->pWith = 0;\n    }else{\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pParse->pWith = pWith;\n\n    for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);\n    pEList = pLeft->pEList;\n    if( pCte->pCols ){\n      if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){\n        sqlite3ErrorMsg(pParse, \"table %s has %d values for %d columns\",\n            pCte->zName, pEList->nExpr, pCte->pCols->nExpr\n        );\n        pParse->pWith = pSavedWith;\n        return SQLITE_ERROR;\n      }\n      pEList = pCte->pCols;\n    }\n\n    sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol);\n    if( bMayRecursive ){\n      if( pSel->selFlags & SF_Recursive ){\n        pCte->zCteErr = \"multiple recursive references: %s\";\n      }else{\n        pCte->zCteErr = \"recursive reference in a subquery: %s\";\n      }\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pCte->zCteErr = 0;\n    pParse->pWith = pSavedWith;\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** If the SELECT passed as the second argument has an associated WITH \n** clause, pop it from the stack stored as part of the Parse object.\n**\n** This function is used as the xSelectCallback2() callback by\n** sqlite3SelectExpand() when walking a SELECT tree to resolve table\n** names and other FROM clause elements. \n*/\nstatic void selectPopWith(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){\n    With *pWith = findRightmost(p)->pWith;\n    if( pWith!=0 ){\n      assert( pParse->pWith==pWith );\n      pParse->pWith = pWith->pOuter;\n    }\n  }\n}\n#else\n#define selectPopWith 0\n#endif\n\n/*\n** This routine is a Walker callback for \"expanding\" a SELECT statement.\n** \"Expanding\" means to do the following:\n**\n**    (1)  Make sure VDBE cursor numbers have been assigned to every\n**         element of the FROM clause.\n**\n**    (2)  Fill in the pTabList->a[].pTab fields in the SrcList that \n**         defines FROM clause.  When views appear in the FROM clause,\n**         fill pTabList->a[].pSelect with a copy of the SELECT statement\n**         that implements the view.  A copy is made of the view's SELECT\n**         statement so that we can freely modify or delete that statement\n**         without worrying about messing up the persistent representation\n**         of the view.\n**\n**    (3)  Add terms to the WHERE clause to accommodate the NATURAL keyword\n**         on joins and the ON and USING clause of joins.\n**\n**    (4)  Scan the list of columns in the result set (pEList) looking\n**         for instances of the \"*\" operator or the TABLE.* operator.\n**         If found, expand each \"*\" to be every column in every table\n**         and TABLE.* to be every column in TABLE.\n**\n*/\nstatic int selectExpander(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  int i, j, k;\n  SrcList *pTabList;\n  ExprList *pEList;\n  struct SrcList_item *pFrom;\n  sqlite3 *db = pParse->db;\n  Expr *pE, *pRight, *pExpr;\n  u16 selFlags = p->selFlags;\n\n  p->selFlags |= SF_Expanded;\n  if( db->mallocFailed  ){\n    return WRC_Abort;\n  }\n  if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){\n    return WRC_Prune;\n  }\n  pTabList = p->pSrc;\n  pEList = p->pEList;\n  if( OK_IF_ALWAYS_TRUE(p->pWith) ){\n    sqlite3WithPush(pParse, p->pWith, 0);\n  }\n\n  /* Make sure cursor numbers have been assigned to all entries in\n  ** the FROM clause of the SELECT statement.\n  */\n  sqlite3SrcListAssignCursors(pParse, pTabList);\n\n  /* Look up every table named in the FROM clause of the select.  If\n  ** an entry of the FROM clause is a subquery instead of a table or view,\n  ** then create a transient table structure to describe the subquery.\n  */\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab;\n    assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 );\n    if( pFrom->fg.isRecursive ) continue;\n    assert( pFrom->pTab==0 );\n#ifndef SQLITE_OMIT_CTE\n    if( withExpand(pWalker, pFrom) ) return WRC_Abort;\n    if( pFrom->pTab ) {} else\n#endif\n    if( pFrom->zName==0 ){\n#ifndef SQLITE_OMIT_SUBQUERY\n      Select *pSel = pFrom->pSelect;\n      /* A sub-query in the FROM clause of a SELECT */\n      assert( pSel!=0 );\n      assert( pFrom->pTab==0 );\n      if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;\n      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n      if( pTab==0 ) return WRC_Abort;\n      pTab->nTabRef = 1;\n      if( pFrom->zAlias ){\n        pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);\n      }else{\n        pTab->zName = sqlite3MPrintf(db, \"subquery_%p\", (void*)pTab);\n      }\n      while( pSel->pPrior ){ pSel = pSel->pPrior; }\n      sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);\n      pTab->iPKey = -1;\n      pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n      pTab->tabFlags |= TF_Ephemeral;\n#endif\n    }else{\n      /* An ordinary table or view name in the FROM clause */\n      assert( pFrom->pTab==0 );\n      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);\n      if( pTab==0 ) return WRC_Abort;\n      if( pTab->nTabRef>=0xffff ){\n        sqlite3ErrorMsg(pParse, \"too many references to \\\"%s\\\": max 65535\",\n           pTab->zName);\n        pFrom->pTab = 0;\n        return WRC_Abort;\n      }\n      pTab->nTabRef++;\n      if( !IsVirtual(pTab) && cannotBeFunction(pParse, pFrom) ){\n        return WRC_Abort;\n      }\n#if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE)\n      if( IsVirtual(pTab) || pTab->pSelect ){\n        i16 nCol;\n        if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;\n        assert( pFrom->pSelect==0 );\n        pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);\n        sqlite3SelectSetName(pFrom->pSelect, pTab->zName);\n        nCol = pTab->nCol;\n        pTab->nCol = -1;\n        sqlite3WalkSelect(pWalker, pFrom->pSelect);\n        pTab->nCol = nCol;\n      }\n#endif\n    }\n\n    /* Locate the index named by the INDEXED BY clause, if any. */\n    if( sqlite3IndexedByLookup(pParse, pFrom) ){\n      return WRC_Abort;\n    }\n  }\n\n  /* Process NATURAL keywords, and ON and USING clauses of joins.\n  */\n  if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){\n    return WRC_Abort;\n  }\n\n  /* For every \"*\" that occurs in the column list, insert the names of\n  ** all columns in all tables.  And for every TABLE.* insert the names\n  ** of all columns in TABLE.  The parser inserted a special expression\n  ** with the TK_ASTERISK operator for each \"*\" that it found in the column\n  ** list.  The following code just has to locate the TK_ASTERISK\n  ** expressions and expand each one to the list of all columns in\n  ** all tables.\n  **\n  ** The first loop just checks to see if there are any \"*\" operators\n  ** that need expanding.\n  */\n  for(k=0; k<pEList->nExpr; k++){\n    pE = pEList->a[k].pExpr;\n    if( pE->op==TK_ASTERISK ) break;\n    assert( pE->op!=TK_DOT || pE->pRight!=0 );\n    assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );\n    if( pE->op==TK_DOT && pE->pRight->op==TK_ASTERISK ) break;\n  }\n  if( k<pEList->nExpr ){\n    /*\n    ** If we get here it means the result set contains one or more \"*\"\n    ** operators that need to be expanded.  Loop through each expression\n    ** in the result set and expand them one by one.\n    */\n    struct ExprList_item *a = pEList->a;\n    ExprList *pNew = 0;\n    int flags = pParse->db->flags;\n    int longNames = (flags & SQLITE_FullColNames)!=0\n                      && (flags & SQLITE_ShortColNames)==0;\n\n    for(k=0; k<pEList->nExpr; k++){\n      pE = a[k].pExpr;\n      pRight = pE->pRight;\n      assert( pE->op!=TK_DOT || pRight!=0 );\n      if( pE->op!=TK_ASTERISK\n       && (pE->op!=TK_DOT || pRight->op!=TK_ASTERISK)\n      ){\n        /* This particular expression does not need to be expanded.\n        */\n        pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);\n        if( pNew ){\n          pNew->a[pNew->nExpr-1].zName = a[k].zName;\n          pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;\n          a[k].zName = 0;\n          a[k].zSpan = 0;\n        }\n        a[k].pExpr = 0;\n      }else{\n        /* This expression is a \"*\" or a \"TABLE.*\" and needs to be\n        ** expanded. */\n        int tableSeen = 0;      /* Set to 1 when TABLE matches */\n        char *zTName = 0;       /* text of name of TABLE */\n        if( pE->op==TK_DOT ){\n          assert( pE->pLeft!=0 );\n          assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );\n          zTName = pE->pLeft->u.zToken;\n        }\n        for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n          Table *pTab = pFrom->pTab;\n          Select *pSub = pFrom->pSelect;\n          char *zTabName = pFrom->zAlias;\n          const char *zSchemaName = 0;\n          int iDb;\n          if( zTabName==0 ){\n            zTabName = pTab->zName;\n          }\n          if( db->mallocFailed ) break;\n          if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){\n            pSub = 0;\n            if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){\n              continue;\n            }\n            iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n            zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : \"*\";\n          }\n          for(j=0; j<pTab->nCol; j++){\n            char *zName = pTab->aCol[j].zName;\n            char *zColname;  /* The computed column name */\n            char *zToFree;   /* Malloced string that needs to be freed */\n            Token sColname;  /* Computed column name as a token */\n\n            assert( zName );\n            if( zTName && pSub\n             && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0\n            ){\n              continue;\n            }\n\n            /* If a column is marked as 'hidden', omit it from the expanded\n            ** result-set list unless the SELECT has the SF_IncludeHidden\n            ** bit set.\n            */\n            if( (p->selFlags & SF_IncludeHidden)==0\n             && IsHiddenColumn(&pTab->aCol[j]) \n            ){\n              continue;\n            }\n            tableSeen = 1;\n\n            if( i>0 && zTName==0 ){\n              if( (pFrom->fg.jointype & JT_NATURAL)!=0\n                && tableAndColumnIndex(pTabList, i, zName, 0, 0)\n              ){\n                /* In a NATURAL join, omit the join columns from the \n                ** table to the right of the join */\n                continue;\n              }\n              if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){\n                /* In a join with a USING clause, omit columns in the\n                ** using clause from the table on the right. */\n                continue;\n              }\n            }\n            pRight = sqlite3Expr(db, TK_ID, zName);\n            zColname = zName;\n            zToFree = 0;\n            if( longNames || pTabList->nSrc>1 ){\n              Expr *pLeft;\n              pLeft = sqlite3Expr(db, TK_ID, zTabName);\n              pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n              if( zSchemaName ){\n                pLeft = sqlite3Expr(db, TK_ID, zSchemaName);\n                pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr);\n              }\n              if( longNames ){\n                zColname = sqlite3MPrintf(db, \"%s.%s\", zTabName, zName);\n                zToFree = zColname;\n              }\n            }else{\n              pExpr = pRight;\n            }\n            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);\n            sqlite3TokenInit(&sColname, zColname);\n            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);\n            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){\n              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];\n              if( pSub ){\n                pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);\n                testcase( pX->zSpan==0 );\n              }else{\n                pX->zSpan = sqlite3MPrintf(db, \"%s.%s.%s\",\n                                           zSchemaName, zTabName, zColname);\n                testcase( pX->zSpan==0 );\n              }\n              pX->bSpanIsTab = 1;\n            }\n            sqlite3DbFree(db, zToFree);\n          }\n        }\n        if( !tableSeen ){\n          if( zTName ){\n            sqlite3ErrorMsg(pParse, \"no such table: %s\", zTName);\n          }else{\n            sqlite3ErrorMsg(pParse, \"no tables specified\");\n          }\n        }\n      }\n    }\n    sqlite3ExprListDelete(db, pEList);\n    p->pEList = pNew;\n  }\n  if( p->pEList && p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns in result set\");\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker.\n**\n** When this routine is the Walker.xExprCallback then expression trees\n** are walked without any actions being taken at each node.  Presumably,\n** when this routine is used for Walker.xExprCallback then \n** Walker.xSelectCallback is set to do something useful for every \n** subquery in the parser tree.\n*/\nSQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker for SELECT statements.\n** subquery in the parser tree.\n*/\nSQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n#if SQLITE_DEBUG\n/*\n** Always assert.  This xSelectCallback2 implementation proves that the\n** xSelectCallback2 is never invoked.\n*/\nSQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  assert( 0 );\n}\n#endif\n/*\n** This routine \"expands\" a SELECT statement and all of its subqueries.\n** For additional information on what it means to \"expand\" a SELECT\n** statement, see the comment on the selectExpand worker callback above.\n**\n** Expanding a SELECT statement is the first step in processing a\n** SELECT statement.  The SELECT statement must be expanded before\n** name resolution is performed.\n**\n** If anything goes wrong, an error message is written into pParse.\n** The calling function can detect the problem by looking at pParse->nErr\n** and/or pParse->db->mallocFailed.\n*/\nstatic void sqlite3SelectExpand(Parse *pParse, Select *pSelect){\n  Walker w;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->hasCompound) ){\n    w.xSelectCallback = convertCompoundSelectToSubquery;\n    w.xSelectCallback2 = 0;\n    sqlite3WalkSelect(&w, pSelect);\n  }\n  w.xSelectCallback = selectExpander;\n  w.xSelectCallback2 = selectPopWith;\n  sqlite3WalkSelect(&w, pSelect);\n}\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()\n** interface.\n**\n** For each FROM-clause subquery, add Column.zType and Column.zColl\n** information to the Table structure that represents the result set\n** of that subquery.\n**\n** The Table structure that represents the result set was constructed\n** by selectExpander() but the type and collation information was omitted\n** at that point because identifiers had not yet been resolved.  This\n** routine is called after identifier resolution.\n*/\nstatic void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){\n  Parse *pParse;\n  int i;\n  SrcList *pTabList;\n  struct SrcList_item *pFrom;\n\n  assert( p->selFlags & SF_Resolved );\n  assert( (p->selFlags & SF_HasTypeInfo)==0 );\n  p->selFlags |= SF_HasTypeInfo;\n  pParse = pWalker->pParse;\n  pTabList = p->pSrc;\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab = pFrom->pTab;\n    assert( pTab!=0 );\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 ){\n      /* A sub-query in the FROM clause of a SELECT */\n      Select *pSel = pFrom->pSelect;\n      if( pSel ){\n        while( pSel->pPrior ) pSel = pSel->pPrior;\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);\n      }\n    }\n  }\n}\n#endif\n\n\n/*\n** This routine adds datatype and collating sequence information to\n** the Table structures of all FROM-clause subqueries in a\n** SELECT statement.\n**\n** Use this routine after name resolution.\n*/\nstatic void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){\n#ifndef SQLITE_OMIT_SUBQUERY\n  Walker w;\n  w.xSelectCallback = sqlite3SelectWalkNoop;\n  w.xSelectCallback2 = selectAddSubqueryTypeInfo;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  sqlite3WalkSelect(&w, pSelect);\n#endif\n}\n\n\n/*\n** This routine sets up a SELECT statement for processing.  The\n** following is accomplished:\n**\n**     *  VDBE Cursor numbers are assigned to all FROM-clause terms.\n**     *  Ephemeral Table objects are created for all FROM-clause subqueries.\n**     *  ON and USING clauses are shifted into WHERE statements\n**     *  Wildcards \"*\" and \"TABLE.*\" in result sets are expanded.\n**     *  Identifiers in expression are matched to tables.\n**\n** This routine acts recursively on all subqueries within the SELECT.\n*/\nSQLITE_PRIVATE void sqlite3SelectPrep(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for container */\n){\n  assert( p!=0 || pParse->db->mallocFailed );\n  if( pParse->db->mallocFailed ) return;\n  if( p->selFlags & SF_HasTypeInfo ) return;\n  sqlite3SelectExpand(pParse, p);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3ResolveSelectNames(pParse, p, pOuterNC);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3SelectAddTypeInfo(pParse, p);\n}\n\n/*\n** Reset the aggregate accumulator.\n**\n** The aggregate accumulator is a set of memory cells that hold\n** intermediate results while calculating an aggregate.  This\n** routine generates code that stores NULLs in all of those memory\n** cells.\n*/\nstatic void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pFunc;\n  int nReg = pAggInfo->nFunc + pAggInfo->nColumn;\n  if( nReg==0 ) return;\n#ifdef SQLITE_DEBUG\n  /* Verify that all AggInfo registers are within the range specified by\n  ** AggInfo.mnReg..AggInfo.mxReg */\n  assert( nReg==pAggInfo->mxReg-pAggInfo->mnReg+1 );\n  for(i=0; i<pAggInfo->nColumn; i++){\n    assert( pAggInfo->aCol[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aCol[i].iMem<=pAggInfo->mxReg );\n  }\n  for(i=0; i<pAggInfo->nFunc; i++){\n    assert( pAggInfo->aFunc[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aFunc[i].iMem<=pAggInfo->mxReg );\n  }\n#endif\n  sqlite3VdbeAddOp3(v, OP_Null, 0, pAggInfo->mnReg, pAggInfo->mxReg);\n  for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){\n    if( pFunc->iDistinct>=0 ){\n      Expr *pE = pFunc->pExpr;\n      assert( !ExprHasProperty(pE, EP_xIsSelect) );\n      if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){\n        sqlite3ErrorMsg(pParse, \"DISTINCT aggregates must have exactly one \"\n           \"argument\");\n        pFunc->iDistinct = -1;\n      }else{\n        KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0, 0);\n        sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,\n                          (char*)pKeyInfo, P4_KEYINFO);\n      }\n    }\n  }\n}\n\n/*\n** Invoke the OP_AggFinalize opcode for every aggregate function\n** in the AggInfo structure.\n*/\nstatic void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pF;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n  }\n}\n\n/*\n** Update the accumulator memory cells for an aggregate based on\n** the current cursor position.\n*/\nstatic void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int regHit = 0;\n  int addrHitTest = 0;\n  struct AggInfo_func *pF;\n  struct AggInfo_col *pC;\n\n  pAggInfo->directMode = 1;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    int nArg;\n    int addrNext = 0;\n    int regAgg;\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    if( pList ){\n      nArg = pList->nExpr;\n      regAgg = sqlite3GetTempRange(pParse, nArg);\n      sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);\n    }else{\n      nArg = 0;\n      regAgg = 0;\n    }\n    if( pF->iDistinct>=0 ){\n      addrNext = sqlite3VdbeMakeLabel(v);\n      testcase( nArg==0 );  /* Error condition */\n      testcase( nArg>1 );   /* Also an error */\n      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);\n    }\n    if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n      CollSeq *pColl = 0;\n      struct ExprList_item *pItem;\n      int j;\n      assert( pList!=0 );  /* pList!=0 if pF->pFunc has NEEDCOLL */\n      for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){\n        pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);\n      }\n      if( !pColl ){\n        pColl = pParse->db->pDfltColl;\n      }\n      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;\n      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);\n    }\n    sqlite3VdbeAddOp3(v, OP_AggStep0, 0, regAgg, pF->iMem);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, (u8)nArg);\n    sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);\n    sqlite3ReleaseTempRange(pParse, regAgg, nArg);\n    if( addrNext ){\n      sqlite3VdbeResolveLabel(v, addrNext);\n      sqlite3ExprCacheClear(pParse);\n    }\n  }\n\n  /* Before populating the accumulator registers, clear the column cache.\n  ** Otherwise, if any of the required column values are already present \n  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value\n  ** to pC->iMem. But by the time the value is used, the original register\n  ** may have been used, invalidating the underlying buffer holding the\n  ** text or blob value. See ticket [883034dcb5].\n  **\n  ** Another solution would be to change the OP_SCopy used to copy cached\n  ** values to an OP_Copy.\n  */\n  if( regHit ){\n    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);\n  }\n  sqlite3ExprCacheClear(pParse);\n  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){\n    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);\n  }\n  pAggInfo->directMode = 0;\n  sqlite3ExprCacheClear(pParse);\n  if( addrHitTest ){\n    sqlite3VdbeJumpHere(v, addrHitTest);\n  }\n}\n\n/*\n** Add a single OP_Explain instruction to the VDBE to explain a simple\n** count(*) query (\"SELECT count(*) FROM pTab\").\n*/\n#ifndef SQLITE_OMIT_EXPLAIN\nstatic void explainSimpleCount(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being queried */\n  Index *pIdx                     /* Index used to optimize scan, or NULL */\n){\n  if( pParse->explain==2 ){\n    int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));\n    char *zEqp = sqlite3MPrintf(pParse->db, \"SCAN TABLE %s%s%s\",\n        pTab->zName,\n        bCover ? \" USING COVERING INDEX \" : \"\",\n        bCover ? pIdx->zName : \"\"\n    );\n    sqlite3VdbeAddOp4(\n        pParse->pVdbe, OP_Explain, pParse->iSelectId, 0, 0, zEqp, P4_DYNAMIC\n    );\n  }\n}\n#else\n# define explainSimpleCount(a,b,c)\n#endif\n\n/*\n** Context object for havingToWhereExprCb().\n*/\nstruct HavingToWhereCtx {\n  Expr **ppWhere;\n  ExprList *pGroupBy;\n};\n\n/*\n** sqlite3WalkExpr() callback used by havingToWhere().\n**\n** If the node passed to the callback is a TK_AND node, return \n** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes.\n**\n** Otherwise, return WRC_Prune. In this case, also check if the \n** sub-expression matches the criteria for being moved to the WHERE\n** clause. If so, add it to the WHERE clause and replace the sub-expression\n** within the HAVING expression with a constant \"1\".\n*/\nstatic int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op!=TK_AND ){\n    struct HavingToWhereCtx *p = pWalker->u.pHavingCtx;\n    if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){\n      sqlite3 *db = pWalker->pParse->db;\n      Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);\n      if( pNew ){\n        Expr *pWhere = *(p->ppWhere);\n        SWAP(Expr, *pNew, *pExpr);\n        pNew = sqlite3ExprAnd(db, pWhere, pNew);\n        *(p->ppWhere) = pNew;\n      }\n    }\n    return WRC_Prune;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Transfer eligible terms from the HAVING clause of a query, which is\n** processed after grouping, to the WHERE clause, which is processed before\n** grouping. For example, the query:\n**\n**   SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=?\n**\n** can be rewritten as:\n**\n**   SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=?\n**\n** A term of the HAVING expression is eligible for transfer if it consists\n** entirely of constants and expressions that are also GROUP BY terms that\n** use the \"BINARY\" collation sequence.\n*/\nstatic void havingToWhere(\n  Parse *pParse,\n  ExprList *pGroupBy,\n  Expr *pHaving, \n  Expr **ppWhere\n){\n  struct HavingToWhereCtx sCtx;\n  Walker sWalker;\n\n  sCtx.ppWhere = ppWhere;\n  sCtx.pGroupBy = pGroupBy;\n\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.xExprCallback = havingToWhereExprCb;\n  sWalker.u.pHavingCtx = &sCtx;\n  sqlite3WalkExpr(&sWalker, pHaving);\n}\n\n/*\n** Check to see if the pThis entry of pTabList is a self-join of a prior view.\n** If it is, then return the SrcList_item for the prior view.  If it is not,\n** then return 0.\n*/\nstatic struct SrcList_item *isSelfJoinView(\n  SrcList *pTabList,           /* Search for self-joins in this FROM clause */\n  struct SrcList_item *pThis   /* Search for prior reference to this subquery */\n){\n  struct SrcList_item *pItem;\n  for(pItem = pTabList->a; pItem<pThis; pItem++){\n    if( pItem->pSelect==0 ) continue;\n    if( pItem->fg.viaCoroutine ) continue;\n    if( pItem->zName==0 ) continue;\n    if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;\n    if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;\n    if( sqlite3ExprCompare(0, \n          pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) \n    ){\n      /* The view was modified by some other optimization such as\n      ** pushDownWhereTerms() */\n      continue;\n    }\n    return pItem;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n/*\n** Attempt to transform a query of the form\n**\n**    SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)\n**\n** Into this:\n**\n**    SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)\n**\n** The transformation only works if all of the following are true:\n**\n**   *  The subquery is a UNION ALL of two or more terms\n**   *  There is no WHERE or GROUP BY or HAVING clauses on the subqueries\n**   *  The outer query is a simple count(*)\n**\n** Return TRUE if the optimization is undertaken.\n*/\nstatic int countOfViewOptimization(Parse *pParse, Select *p){\n  Select *pSub, *pPrior;\n  Expr *pExpr;\n  Expr *pCount;\n  sqlite3 *db;\n  if( (p->selFlags & SF_Aggregate)==0 ) return 0;   /* This is an aggregate */\n  if( p->pEList->nExpr!=1 ) return 0;               /* Single result column */\n  pExpr = p->pEList->a[0].pExpr;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;        /* Result is an aggregate */\n  if( sqlite3_stricmp(pExpr->u.zToken,\"count\") ) return 0;  /* Is count() */\n  if( pExpr->x.pList!=0 ) return 0;                 /* Must be count(*) */\n  if( p->pSrc->nSrc!=1 ) return 0;                  /* One table in FROM  */\n  pSub = p->pSrc->a[0].pSelect;\n  if( pSub==0 ) return 0;                           /* The FROM is a subquery */\n  if( pSub->pPrior==0 ) return 0;                   /* Must be a compound ry */\n  do{\n    if( pSub->op!=TK_ALL && pSub->pPrior ) return 0;  /* Must be UNION ALL */\n    if( pSub->pWhere ) return 0;                      /* No WHERE clause */\n    if( pSub->selFlags & SF_Aggregate ) return 0;     /* Not an aggregate */\n    pSub = pSub->pPrior;                              /* Repeat over compound */\n  }while( pSub );\n\n  /* If we reach this point then it is OK to perform the transformation */\n\n  db = pParse->db;\n  pCount = pExpr;\n  pExpr = 0;\n  pSub = p->pSrc->a[0].pSelect;\n  p->pSrc->a[0].pSelect = 0;\n  sqlite3SrcListDelete(db, p->pSrc);\n  p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));\n  while( pSub ){\n    Expr *pTerm;\n    pPrior = pSub->pPrior;\n    pSub->pPrior = 0;\n    pSub->pNext = 0;\n    pSub->selFlags |= SF_Aggregate;\n    pSub->selFlags &= ~SF_Compound;\n    pSub->nSelectRow = 0;\n    sqlite3ExprListDelete(db, pSub->pEList);\n    pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;\n    pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);\n    pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, pTerm, pSub);\n    if( pExpr==0 ){\n      pExpr = pTerm;\n    }else{\n      pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);\n    }\n    pSub = pPrior;\n  }\n  p->pEList->a[0].pExpr = pExpr;\n  p->selFlags &= ~SF_Aggregate;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After count-of-view optimization:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n  return 1;\n}\n#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */\n\n/*\n** Generate code for the SELECT statement given in the p argument.  \n**\n** The results are returned according to the SelectDest structure.\n** See comments in sqliteInt.h for further information.\n**\n** This routine returns the number of errors.  If any errors are\n** encountered, then an appropriate error message is left in\n** pParse->zErrMsg.\n**\n** This routine does NOT free the Select structure passed in.  The\n** calling function needs to do that.\n*/\nSQLITE_PRIVATE int sqlite3Select(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  SelectDest *pDest      /* What to do with the query results */\n){\n  int i, j;              /* Loop counters */\n  WhereInfo *pWInfo;     /* Return from sqlite3WhereBegin() */\n  Vdbe *v;               /* The virtual machine under construction */\n  int isAgg;             /* True for select lists like \"count(*)\" */\n  ExprList *pEList = 0;  /* List of columns to extract. */\n  SrcList *pTabList;     /* List of tables to select from */\n  Expr *pWhere;          /* The WHERE clause.  May be NULL */\n  ExprList *pGroupBy;    /* The GROUP BY clause.  May be NULL */\n  Expr *pHaving;         /* The HAVING clause.  May be NULL */\n  int rc = 1;            /* Value to return from this function */\n  DistinctCtx sDistinct; /* Info on how to code the DISTINCT keyword */\n  SortCtx sSort;         /* Info on how to code the ORDER BY clause */\n  AggInfo sAggInfo;      /* Information used by aggregate queries */\n  int iEnd;              /* Address of the end of the query */\n  sqlite3 *db;           /* The database connection */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iRestoreSelectId = pParse->iSelectId;\n  pParse->iSelectId = pParse->iNextSelectId++;\n#endif\n\n  db = pParse->db;\n  if( p==0 || db->mallocFailed || pParse->nErr ){\n    return 1;\n  }\n  if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;\n  memset(&sAggInfo, 0, sizeof(sAggInfo));\n#if SELECTTRACE_ENABLED\n  pParse->nSelectIndent++;\n  SELECTTRACE(1,pParse,p, (\"begin processing:\\n\"));\n  if( sqlite3SelectTrace & 0x100 ){\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Queue );\n  if( IgnorableOrderby(pDest) ){\n    assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || \n           pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||\n           pDest->eDest==SRT_Queue  || pDest->eDest==SRT_DistFifo ||\n           pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);\n    /* If ORDER BY makes no difference in the output then neither does\n    ** DISTINCT so it can be removed too. */\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    p->pOrderBy = 0;\n    p->selFlags &= ~SF_Distinct;\n  }\n  sqlite3SelectPrep(pParse, p, 0);\n  memset(&sSort, 0, sizeof(sSort));\n  sSort.pOrderBy = p->pOrderBy;\n  pTabList = p->pSrc;\n  if( pParse->nErr || db->mallocFailed ){\n    goto select_end;\n  }\n  assert( p->pEList!=0 );\n  isAgg = (p->selFlags & SF_Aggregate)!=0;\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x100 ){\n    SELECTTRACE(0x100,pParse,p, (\"after name resolution:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  /* Get a pointer the VDBE under construction, allocating a new VDBE if one\n  ** does not already exist */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto select_end;\n  if( pDest->eDest==SRT_Output ){\n    generateColumnNames(pParse, p);\n  }\n\n  /* Try to flatten subqueries in the FROM clause up into the main query\n  */\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    Select *pSub = pItem->pSelect;\n    Table *pTab = pItem->pTab;\n    if( pSub==0 ) continue;\n\n    /* Catch mismatch in the declared columns of a view and the number of\n    ** columns in the SELECT on the RHS */\n    if( pTab->nCol!=pSub->pEList->nExpr ){\n      sqlite3ErrorMsg(pParse, \"expected %d columns for '%s' but got %d\",\n                      pTab->nCol, pTab->zName, pSub->pEList->nExpr);\n      goto select_end;\n    }\n\n    /* Do not try to flatten an aggregate subquery.\n    **\n    ** Flattening an aggregate subquery is only possible if the outer query\n    ** is not a join.  But if the outer query is not a join, then the subquery\n    ** will be implemented as a co-routine and there is no advantage to\n    ** flattening in that case.\n    */\n    if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;\n    assert( pSub->pGroupBy==0 );\n\n    /* If the subquery contains an ORDER BY clause and if\n    ** it will be implemented as a co-routine, then do not flatten.  This\n    ** restriction allows SQL constructs like this:\n    **\n    **  SELECT expensive_function(x)\n    **    FROM (SELECT x FROM tab ORDER BY y LIMIT 10);\n    **\n    ** The expensive_function() is only computed on the 10 rows that\n    ** are output, rather than every row of the table.\n    */\n    if( pSub->pOrderBy!=0\n     && i==0\n     && (pTabList->nSrc==1\n         || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)\n    ){\n      continue;\n    }\n\n    if( flattenSubquery(pParse, p, i, isAgg) ){\n      /* This subquery can be absorbed into its parent. */\n      i = -1;\n    }\n    pTabList = p->pSrc;\n    if( db->mallocFailed ) goto select_end;\n    if( !IgnorableOrderby(pDest) ){\n      sSort.pOrderBy = p->pOrderBy;\n    }\n  }\n#endif\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n  /* Handle compound SELECT statements using the separate multiSelect()\n  ** procedure.\n  */\n  if( p->pPrior ){\n    rc = multiSelect(pParse, p, pDest);\n    explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n#if SELECTTRACE_ENABLED\n    SELECTTRACE(1,pParse,p,(\"end compound-select processing\\n\"));\n    pParse->nSelectIndent--;\n#endif\n    return rc;\n  }\n#endif\n\n  /* For each term in the FROM clause, do two things:\n  ** (1) Authorized unreferenced tables\n  ** (2) Generate code for all sub-queries\n  */\n  for(i=0; i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    SelectDest dest;\n    Select *pSub;\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    const char *zSavedAuthContext;\n#endif\n\n    /* Issue SQLITE_READ authorizations with a fake column name for any\n    ** tables that are referenced but from which no values are extracted.\n    ** Examples of where these kinds of null SQLITE_READ authorizations\n    ** would occur:\n    **\n    **     SELECT count(*) FROM t1;   -- SQLITE_READ t1.\"\"\n    **     SELECT t1.* FROM t1, t2;   -- SQLITE_READ t2.\"\"\n    **\n    ** The fake column name is an empty string.  It is possible for a table to\n    ** have a column named by the empty string, in which case there is no way to\n    ** distinguish between an unreferenced table and an actual reference to the\n    ** \"\" column. The original design was for the fake column name to be a NULL,\n    ** which would be unambiguous.  But legacy authorization callbacks might\n    ** assume the column name is non-NULL and segfault.  The use of an empty\n    ** string for the fake column name seems safer.\n    */\n    if( pItem->colUsed==0 ){\n      sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, \"\", pItem->zDatabase);\n    }\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    /* Generate code for all sub-queries in the FROM clause\n    */\n    pSub = pItem->pSelect;\n    if( pSub==0 ) continue;\n\n    /* Sometimes the code for a subquery will be generated more than\n    ** once, if the subquery is part of the WHERE clause in a LEFT JOIN,\n    ** for example.  In that case, do not regenerate the code to manifest\n    ** a view or the co-routine to implement a view.  The first instance\n    ** is sufficient, though the subroutine to manifest the view does need\n    ** to be invoked again. */\n    if( pItem->addrFillSub ){\n      if( pItem->fg.viaCoroutine==0 ){\n        /* The subroutine that manifests the view might be a one-time routine,\n        ** or it might need to be rerun on each iteration because it\n        ** encodes a correlated subquery. */\n        testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once );\n        sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub);\n      }\n      continue;\n    }\n\n    /* Increment Parse.nHeight by the height of the largest expression\n    ** tree referred to by this, the parent select. The child select\n    ** may contain expression trees of at most\n    ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit\n    ** more conservative than necessary, but much easier than enforcing\n    ** an exact limit.\n    */\n    pParse->nHeight += sqlite3SelectExprHeight(p);\n\n    /* Make copies of constant WHERE-clause terms in the outer query down\n    ** inside the subquery.  This can help the subquery to run more efficiently.\n    */\n    if( (pItem->fg.jointype & JT_OUTER)==0\n     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor)\n    ){\n#if SELECTTRACE_ENABLED\n      if( sqlite3SelectTrace & 0x100 ){\n        SELECTTRACE(0x100,pParse,p,(\"After WHERE-clause push-down:\\n\"));\n        sqlite3TreeViewSelect(0, p, 0);\n      }\n#endif\n    }\n\n    zSavedAuthContext = pParse->zAuthContext;\n    pParse->zAuthContext = pItem->zName;\n\n    /* Generate code to implement the subquery\n    **\n    ** The subquery is implemented as a co-routine if the subquery is\n    ** guaranteed to be the outer loop (so that it does not need to be\n    ** computed more than once)\n    **\n    ** TODO: Are there other reasons beside (1) to use a co-routine\n    ** implementation?\n    */\n    if( i==0\n     && (pTabList->nSrc==1\n            || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)  /* (1) */\n    ){\n      /* Implement a co-routine that will return a single row of the result\n      ** set on each invocation.\n      */\n      int addrTop = sqlite3VdbeCurrentAddr(v)+1;\n     \n      pItem->regReturn = ++pParse->nMem;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);\n      VdbeComment((v, \"%s\", pItem->pTab->zName));\n      pItem->addrFillSub = addrTop;\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);\n      explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n      sqlite3Select(pParse, pSub, &dest);\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      pItem->fg.viaCoroutine = 1;\n      pItem->regResult = dest.iSdst;\n      sqlite3VdbeEndCoroutine(v, pItem->regReturn);\n      sqlite3VdbeJumpHere(v, addrTop-1);\n      sqlite3ClearTempRegCache(pParse);\n    }else{\n      /* Generate a subroutine that will fill an ephemeral table with\n      ** the content of this subquery.  pItem->addrFillSub will point\n      ** to the address of the generated subroutine.  pItem->regReturn\n      ** is a register allocated to hold the subroutine return address\n      */\n      int topAddr;\n      int onceAddr = 0;\n      int retAddr;\n      struct SrcList_item *pPrior;\n\n      assert( pItem->addrFillSub==0 );\n      pItem->regReturn = ++pParse->nMem;\n      topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);\n      pItem->addrFillSub = topAddr+1;\n      if( pItem->fg.isCorrelated==0 ){\n        /* If the subquery is not correlated and if we are not inside of\n        ** a trigger, then we only need to compute the value of the subquery\n        ** once. */\n        onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n        VdbeComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }else{\n        VdbeNoopComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }\n      pPrior = isSelfJoinView(pTabList, pItem);\n      if( pPrior ){\n        sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);\n        explainSetInteger(pItem->iSelectId, pPrior->iSelectId);\n        assert( pPrior->pSelect!=0 );\n        pSub->nSelectRow = pPrior->pSelect->nSelectRow;\n      }else{\n        sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);\n        explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n        sqlite3Select(pParse, pSub, &dest);\n      }\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);\n      retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);\n      VdbeComment((v, \"end %s\", pItem->pTab->zName));\n      sqlite3VdbeChangeP1(v, topAddr, retAddr);\n      sqlite3ClearTempRegCache(pParse);\n    }\n    if( db->mallocFailed ) goto select_end;\n    pParse->nHeight -= sqlite3SelectExprHeight(p);\n    pParse->zAuthContext = zSavedAuthContext;\n#endif\n  }\n\n  /* Various elements of the SELECT copied into local variables for\n  ** convenience */\n  pEList = p->pEList;\n  pWhere = p->pWhere;\n  pGroupBy = p->pGroupBy;\n  pHaving = p->pHaving;\n  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After all FROM-clause analysis:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n  if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)\n   && countOfViewOptimization(pParse, p)\n  ){\n    if( db->mallocFailed ) goto select_end;\n    pEList = p->pEList;\n    pTabList = p->pSrc;\n  }\n#endif\n\n  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and \n  ** if the select-list is the same as the ORDER BY list, then this query\n  ** can be rewritten as a GROUP BY. In other words, this:\n  **\n  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz\n  **\n  ** is transformed to:\n  **\n  **     SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz\n  **\n  ** The second form is preferred as a single index (or temp-table) may be \n  ** used for both the ORDER BY and DISTINCT processing. As originally \n  ** written the query must use a temp-table for at least one of the ORDER \n  ** BY and DISTINCT, and an index or separate temp-table for the other.\n  */\n  if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct \n   && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0\n  ){\n    p->selFlags &= ~SF_Distinct;\n    pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);\n    /* Notice that even thought SF_Distinct has been cleared from p->selFlags,\n    ** the sDistinct.isTnct is still set.  Hence, isTnct represents the\n    ** original setting of the SF_Distinct flag, not the current setting */\n    assert( sDistinct.isTnct );\n\n#if SELECTTRACE_ENABLED\n    if( sqlite3SelectTrace & 0x400 ){\n      SELECTTRACE(0x400,pParse,p,(\"Transform DISTINCT into GROUP BY:\\n\"));\n      sqlite3TreeViewSelect(0, p, 0);\n    }\n#endif\n  }\n\n  /* If there is an ORDER BY clause, then create an ephemeral index to\n  ** do the sorting.  But this sorting ephemeral index might end up\n  ** being unused if the data can be extracted in pre-sorted order.\n  ** If that is the case, then the OP_OpenEphemeral instruction will be\n  ** changed to an OP_Noop once we figure out that the sorting index is\n  ** not needed.  The sSort.addrSortIndex variable is used to facilitate\n  ** that change.\n  */\n  if( sSort.pOrderBy ){\n    KeyInfo *pKeyInfo;\n    pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);\n    sSort.iECursor = pParse->nTab++;\n    sSort.addrSortIndex =\n      sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n          sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,\n          (char*)pKeyInfo, P4_KEYINFO\n      );\n  }else{\n    sSort.addrSortIndex = -1;\n  }\n\n  /* If the output is destined for a temporary table, open that table.\n  */\n  if( pDest->eDest==SRT_EphemTab ){\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr);\n  }\n\n  /* Set the limiter.\n  */\n  iEnd = sqlite3VdbeMakeLabel(v);\n  if( (p->selFlags & SF_FixedLimit)==0 ){\n    p->nSelectRow = 320;  /* 4 billion rows */\n  }\n  computeLimitRegisters(pParse, p, iEnd);\n  if( p->iLimit==0 && sSort.addrSortIndex>=0 ){\n    sqlite3VdbeChangeOpcode(v, sSort.addrSortIndex, OP_SorterOpen);\n    sSort.sortFlags |= SORTFLAG_UseSorter;\n  }\n\n  /* Open an ephemeral index to use for the distinct set.\n  */\n  if( p->selFlags & SF_Distinct ){\n    sDistinct.tabTnct = pParse->nTab++;\n    sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n                             sDistinct.tabTnct, 0, 0,\n                             (char*)keyInfoFromExprList(pParse, p->pEList,0,0),\n                             P4_KEYINFO);\n    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n    sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;\n  }else{\n    sDistinct.eTnctType = WHERE_DISTINCT_NOOP;\n  }\n\n  if( !isAgg && pGroupBy==0 ){\n    /* No aggregate functions and no GROUP BY clause */\n    u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0);\n    assert( WHERE_USE_LIMIT==SF_FixedLimit );\n    wctrlFlags |= p->selFlags & SF_FixedLimit;\n\n    /* Begin the database scan. */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,\n                               p->pEList, wctrlFlags, p->nSelectRow);\n    if( pWInfo==0 ) goto select_end;\n    if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){\n      p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);\n    }\n    if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){\n      sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);\n    }\n    if( sSort.pOrderBy ){\n      sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);\n      sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);\n      if( sSort.nOBSat==sSort.pOrderBy->nExpr ){\n        sSort.pOrderBy = 0;\n      }\n    }\n\n    /* If sorting index that was created by a prior OP_OpenEphemeral \n    ** instruction ended up not being needed, then change the OP_OpenEphemeral\n    ** into an OP_Noop.\n    */\n    if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){\n      sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n    }\n\n    /* Use the standard inner loop. */\n    assert( p->pEList==pEList );\n    selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,\n                    sqlite3WhereContinueLabel(pWInfo),\n                    sqlite3WhereBreakLabel(pWInfo));\n\n    /* End the database scan loop.\n    */\n    sqlite3WhereEnd(pWInfo);\n  }else{\n    /* This case when there exist aggregate functions or a GROUP BY clause\n    ** or both */\n    NameContext sNC;    /* Name context for processing aggregate information */\n    int iAMem;          /* First Mem address for storing current GROUP BY */\n    int iBMem;          /* First Mem address for previous GROUP BY */\n    int iUseFlag;       /* Mem address holding flag indicating that at least\n                        ** one row of the input to the aggregator has been\n                        ** processed */\n    int iAbortFlag;     /* Mem address which causes query abort if positive */\n    int groupBySort;    /* Rows come from source in GROUP BY order */\n    int addrEnd;        /* End of processing for this SELECT */\n    int sortPTab = 0;   /* Pseudotable used to decode sorting results */\n    int sortOut = 0;    /* Output register from the sorter */\n    int orderByGrp = 0; /* True if the GROUP BY and ORDER BY are the same */\n\n    /* Remove any and all aliases between the result set and the\n    ** GROUP BY clause.\n    */\n    if( pGroupBy ){\n      int k;                        /* Loop counter */\n      struct ExprList_item *pItem;  /* For looping over expression in a list */\n\n      for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      assert( 66==sqlite3LogEst(100) );\n      if( p->nSelectRow>66 ) p->nSelectRow = 66;\n    }else{\n      assert( 0==sqlite3LogEst(1) );\n      p->nSelectRow = 0;\n    }\n\n    /* If there is both a GROUP BY and an ORDER BY clause and they are\n    ** identical, then it may be possible to disable the ORDER BY clause \n    ** on the grounds that the GROUP BY will cause elements to come out \n    ** in the correct order. It also may not - the GROUP BY might use a\n    ** database index that causes rows to be grouped together as required\n    ** but not actually sorted. Either way, record the fact that the\n    ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp\n    ** variable.  */\n    if( sqlite3ExprListCompare(pGroupBy, sSort.pOrderBy, -1)==0 ){\n      orderByGrp = 1;\n    }\n \n    /* Create a label to jump to when we want to abort the query */\n    addrEnd = sqlite3VdbeMakeLabel(v);\n\n    /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in\n    ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the\n    ** SELECT statement.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    sNC.pSrcList = pTabList;\n    sNC.pAggInfo = &sAggInfo;\n    sAggInfo.mnReg = pParse->nMem+1;\n    sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;\n    sAggInfo.pGroupBy = pGroupBy;\n    sqlite3ExprAnalyzeAggList(&sNC, pEList);\n    sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy);\n    if( pHaving ){\n      if( pGroupBy ){\n        assert( pWhere==p->pWhere );\n        havingToWhere(pParse, pGroupBy, pHaving, &p->pWhere);\n        pWhere = p->pWhere;\n      }\n      sqlite3ExprAnalyzeAggregates(&sNC, pHaving);\n    }\n    sAggInfo.nAccumulator = sAggInfo.nColumn;\n    for(i=0; i<sAggInfo.nFunc; i++){\n      assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );\n      sNC.ncFlags |= NC_InAggFunc;\n      sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);\n      sNC.ncFlags &= ~NC_InAggFunc;\n    }\n    sAggInfo.mxReg = pParse->nMem;\n    if( db->mallocFailed ) goto select_end;\n\n    /* Processing for aggregates with GROUP BY is very different and\n    ** much more complex than aggregates without a GROUP BY.\n    */\n    if( pGroupBy ){\n      KeyInfo *pKeyInfo;  /* Keying information for the group by clause */\n      int addr1;          /* A-vs-B comparision jump */\n      int addrOutputRow;  /* Start of subroutine that outputs a result row */\n      int regOutputRow;   /* Return address register for output subroutine */\n      int addrSetAbort;   /* Set the abort flag and return */\n      int addrTopOfLoop;  /* Top of the input loop */\n      int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */\n      int addrReset;      /* Subroutine for resetting the accumulator */\n      int regReset;       /* Return address register for reset subroutine */\n\n      /* If there is a GROUP BY clause we might need a sorting index to\n      ** implement it.  Allocate that sorting index now.  If it turns out\n      ** that we do not need it after all, the OP_SorterOpen instruction\n      ** will be converted into a Noop.  \n      */\n      sAggInfo.sortingIdx = pParse->nTab++;\n      pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);\n      addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen, \n          sAggInfo.sortingIdx, sAggInfo.nSortingColumn, \n          0, (char*)pKeyInfo, P4_KEYINFO);\n\n      /* Initialize memory locations used by GROUP BY aggregate processing\n      */\n      iUseFlag = ++pParse->nMem;\n      iAbortFlag = ++pParse->nMem;\n      regOutputRow = ++pParse->nMem;\n      addrOutputRow = sqlite3VdbeMakeLabel(v);\n      regReset = ++pParse->nMem;\n      addrReset = sqlite3VdbeMakeLabel(v);\n      iAMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      iBMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);\n      VdbeComment((v, \"clear abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);\n      VdbeComment((v, \"indicate accumulator empty\"));\n      sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);\n\n      /* Begin a loop that will extract all source rows in GROUP BY order.\n      ** This might involve two separate loops with an OP_Sort in between, or\n      ** it might be a single loop that uses an index to extract information\n      ** in the right order to begin with.\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0,\n          WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0\n      );\n      if( pWInfo==0 ) goto select_end;\n      if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){\n        /* The optimizer is able to deliver rows in group by order so\n        ** we do not have to sort.  The OP_OpenEphemeral table will be\n        ** cancelled later because we still need to use the pKeyInfo\n        */\n        groupBySort = 0;\n      }else{\n        /* Rows are coming out in undetermined order.  We have to push\n        ** each row into a sorting index, terminate the first loop,\n        ** then loop over the sorting index in order to get the output\n        ** in sorted order\n        */\n        int regBase;\n        int regRecord;\n        int nCol;\n        int nGroupBy;\n\n        explainTempTable(pParse, \n            (sDistinct.isTnct && (p->selFlags&SF_Distinct)==0) ?\n                    \"DISTINCT\" : \"GROUP BY\");\n\n        groupBySort = 1;\n        nGroupBy = pGroupBy->nExpr;\n        nCol = nGroupBy;\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          if( sAggInfo.aCol[i].iSorterColumn>=j ){\n            nCol++;\n            j++;\n          }\n        }\n        regBase = sqlite3GetTempRange(pParse, nCol);\n        sqlite3ExprCacheClear(pParse);\n        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0);\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          struct AggInfo_col *pCol = &sAggInfo.aCol[i];\n          if( pCol->iSorterColumn>=j ){\n            int r1 = j + regBase;\n            sqlite3ExprCodeGetColumnToReg(pParse, \n                               pCol->pTab, pCol->iColumn, pCol->iTable, r1);\n            j++;\n          }\n        }\n        regRecord = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);\n        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);\n        sqlite3ReleaseTempReg(pParse, regRecord);\n        sqlite3ReleaseTempRange(pParse, regBase, nCol);\n        sqlite3WhereEnd(pWInfo);\n        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;\n        sortOut = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);\n        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);\n        VdbeComment((v, \"GROUP BY sort\")); VdbeCoverage(v);\n        sAggInfo.useSortingIdx = 1;\n        sqlite3ExprCacheClear(pParse);\n\n      }\n\n      /* If the index or temporary table used by the GROUP BY sort\n      ** will naturally deliver rows in the order required by the ORDER BY\n      ** clause, cancel the ephemeral table open coded earlier.\n      **\n      ** This is an optimization - the correct answer should result regardless.\n      ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to \n      ** disable this optimization for testing purposes.  */\n      if( orderByGrp && OptimizationEnabled(db, SQLITE_GroupByOrder) \n       && (groupBySort || sqlite3WhereIsSorted(pWInfo))\n      ){\n        sSort.pOrderBy = 0;\n        sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n      }\n\n      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...\n      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)\n      ** Then compare the current GROUP BY terms against the GROUP BY terms\n      ** from the previous row currently stored in a0, a1, a2...\n      */\n      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);\n      sqlite3ExprCacheClear(pParse);\n      if( groupBySort ){\n        sqlite3VdbeAddOp3(v, OP_SorterData, sAggInfo.sortingIdx,\n                          sortOut, sortPTab);\n      }\n      for(j=0; j<pGroupBy->nExpr; j++){\n        if( groupBySort ){\n          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);\n        }else{\n          sAggInfo.directMode = 1;\n          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);\n        }\n      }\n      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,\n                          (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n      addr1 = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp3(v, OP_Jump, addr1+1, 0, addr1+1); VdbeCoverage(v);\n\n      /* Generate code that runs whenever the GROUP BY changes.\n      ** Changes in the GROUP BY are detected by the previous code\n      ** block.  If there were no changes, this block is skipped.\n      **\n      ** This code copies current group by terms in b0,b1,b2,...\n      ** over to a0,a1,a2.  It then calls the output subroutine\n      ** and resets the aggregate accumulator registers in preparation\n      ** for the next GROUP BY batch.\n      */\n      sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output one row\"));\n      sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);\n      VdbeComment((v, \"check abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      VdbeComment((v, \"reset accumulator\"));\n\n      /* Update the aggregate accumulators based on the content of\n      ** the current row\n      */\n      sqlite3VdbeJumpHere(v, addr1);\n      updateAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);\n      VdbeComment((v, \"indicate data in accumulator\"));\n\n      /* End of the loop\n      */\n      if( groupBySort ){\n        sqlite3VdbeAddOp2(v, OP_SorterNext, sAggInfo.sortingIdx, addrTopOfLoop);\n        VdbeCoverage(v);\n      }else{\n        sqlite3WhereEnd(pWInfo);\n        sqlite3VdbeChangeToNoop(v, addrSortingIdx);\n      }\n\n      /* Output the final row of result\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output final row\"));\n\n      /* Jump over the subroutines\n      */\n      sqlite3VdbeGoto(v, addrEnd);\n\n      /* Generate a subroutine that outputs a single row of the result\n      ** set.  This subroutine first looks at the iUseFlag.  If iUseFlag\n      ** is less than or equal to zero, the subroutine is a no-op.  If\n      ** the processing calls for the query to abort, this subroutine\n      ** increments the iAbortFlag memory location before returning in\n      ** order to signal the caller to abort.\n      */\n      addrSetAbort = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag);\n      VdbeComment((v, \"set abort flag\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      sqlite3VdbeResolveLabel(v, addrOutputRow);\n      addrOutputRow = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);\n      VdbeCoverage(v);\n      VdbeComment((v, \"Groupby result generator entry point\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      finalizeAggFunctions(pParse, &sAggInfo);\n      sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, &sSort,\n                      &sDistinct, pDest,\n                      addrOutputRow+1, addrSetAbort);\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      VdbeComment((v, \"end groupby result generator\"));\n\n      /* Generate a subroutine that will reset the group-by accumulator\n      */\n      sqlite3VdbeResolveLabel(v, addrReset);\n      resetAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp1(v, OP_Return, regReset);\n     \n    } /* endif pGroupBy.  Begin aggregate queries without GROUP BY: */\n    else {\n      ExprList *pDel = 0;\n#ifndef SQLITE_OMIT_BTREECOUNT\n      Table *pTab;\n      if( (pTab = isSimpleCount(p, &sAggInfo))!=0 ){\n        /* If isSimpleCount() returns a pointer to a Table structure, then\n        ** the SQL statement is of the form:\n        **\n        **   SELECT count(*) FROM <tbl>\n        **\n        ** where the Table structure returned represents table <tbl>.\n        **\n        ** This statement is so common that it is optimized specially. The\n        ** OP_Count instruction is executed either on the intkey table that\n        ** contains the data for table <tbl> or on one of its indexes. It\n        ** is better to execute the op on an index, as indexes are almost\n        ** always spread across less pages than their corresponding tables.\n        */\n        const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n        const int iCsr = pParse->nTab++;     /* Cursor to scan b-tree */\n        Index *pIdx;                         /* Iterator variable */\n        KeyInfo *pKeyInfo = 0;               /* Keyinfo for scanned index */\n        Index *pBest = 0;                    /* Best index found so far */\n        int iRoot = pTab->tnum;              /* Root page of scanned b-tree */\n\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n        /* Search for the index that has the lowest scan cost.\n        **\n        ** (2011-04-15) Do not do a full scan of an unordered index.\n        **\n        ** (2013-10-03) Do not count the entries in a partial index.\n        **\n        ** In practice the KeyInfo structure will not be used. It is only \n        ** passed to keep OP_OpenRead happy.\n        */\n        if( !HasRowid(pTab) ) pBest = sqlite3PrimaryKeyIndex(pTab);\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( pIdx->bUnordered==0\n           && pIdx->szIdxRow<pTab->szTabRow\n           && pIdx->pPartIdxWhere==0\n           && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)\n          ){\n            pBest = pIdx;\n          }\n        }\n        if( pBest ){\n          iRoot = pBest->tnum;\n          pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pBest);\n        }\n\n        /* Open a read-only cursor, execute the OP_Count, close the cursor. */\n        sqlite3VdbeAddOp4Int(v, OP_OpenRead, iCsr, iRoot, iDb, 1);\n        if( pKeyInfo ){\n          sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO);\n        }\n        sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem);\n        sqlite3VdbeAddOp1(v, OP_Close, iCsr);\n        explainSimpleCount(pParse, pTab, pBest);\n      }else\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      {\n        /* Check if the query is of one of the following forms:\n        **\n        **   SELECT min(x) FROM ...\n        **   SELECT max(x) FROM ...\n        **\n        ** If it is, then ask the code in where.c to attempt to sort results\n        ** as if there was an \"ORDER ON x\" or \"ORDER ON x DESC\" clause. \n        ** If where.c is able to produce results sorted in this order, then\n        ** add vdbe code to break out of the processing loop after the \n        ** first iteration (since the first iteration of the loop is \n        ** guaranteed to operate on the row with the minimum or maximum \n        ** value of x, the only row required).\n        **\n        ** A special flag must be passed to sqlite3WhereBegin() to slightly\n        ** modify behavior as follows:\n        **\n        **   + If the query is a \"SELECT min(x)\", then the loop coded by\n        **     where.c should not iterate over any values with a NULL value\n        **     for x.\n        **\n        **   + The optimizer code in where.c (the thing that decides which\n        **     index or indices to use) should place a different priority on \n        **     satisfying the 'ORDER BY' clause than it does in other cases.\n        **     Refer to code and comments in where.c for details.\n        */\n        ExprList *pMinMax = 0;\n        u8 flag = WHERE_ORDERBY_NORMAL;\n        \n        assert( p->pGroupBy==0 );\n        assert( flag==0 );\n        if( p->pHaving==0 ){\n          flag = minMaxQuery(&sAggInfo, &pMinMax);\n        }\n        assert( flag==0 || (pMinMax!=0 && pMinMax->nExpr==1) );\n\n        if( flag ){\n          pMinMax = sqlite3ExprListDup(db, pMinMax, 0);\n          pDel = pMinMax;\n          assert( db->mallocFailed || pMinMax!=0 );\n          if( !db->mallocFailed ){\n            pMinMax->a[0].sortOrder = flag!=WHERE_ORDERBY_MIN ?1:0;\n            pMinMax->a[0].pExpr->op = TK_COLUMN;\n          }\n        }\n  \n        /* This case runs if the aggregate has no GROUP BY clause.  The\n        ** processing is much simpler since there is only a single row\n        ** of output.\n        */\n        resetAccumulator(pParse, &sAggInfo);\n        pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMax, 0,flag,0);\n        if( pWInfo==0 ){\n          sqlite3ExprListDelete(db, pDel);\n          goto select_end;\n        }\n        updateAccumulator(pParse, &sAggInfo);\n        assert( pMinMax==0 || pMinMax->nExpr==1 );\n        if( sqlite3WhereIsOrdered(pWInfo)>0 ){\n          sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));\n          VdbeComment((v, \"%s() by index\",\n                (flag==WHERE_ORDERBY_MIN?\"min\":\"max\")));\n        }\n        sqlite3WhereEnd(pWInfo);\n        finalizeAggFunctions(pParse, &sAggInfo);\n      }\n\n      sSort.pOrderBy = 0;\n      sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, 0, 0, \n                      pDest, addrEnd, addrEnd);\n      sqlite3ExprListDelete(db, pDel);\n    }\n    sqlite3VdbeResolveLabel(v, addrEnd);\n    \n  } /* endif aggregate query */\n\n  if( sDistinct.eTnctType==WHERE_DISTINCT_UNORDERED ){\n    explainTempTable(pParse, \"DISTINCT\");\n  }\n\n  /* If there is an ORDER BY clause, then we need to sort the results\n  ** and send them to the callback one by one.\n  */\n  if( sSort.pOrderBy ){\n    explainTempTable(pParse,\n                     sSort.nOBSat>0 ? \"RIGHT PART OF ORDER BY\":\"ORDER BY\");\n    generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);\n  }\n\n  /* Jump here to skip this query\n  */\n  sqlite3VdbeResolveLabel(v, iEnd);\n\n  /* The SELECT has been coded. If there is an error in the Parse structure,\n  ** set the return code to 1. Otherwise 0. */\n  rc = (pParse->nErr>0);\n\n  /* Control jumps to here if an error is encountered above, or upon\n  ** successful coding of the SELECT.\n  */\nselect_end:\n  explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n\n  sqlite3DbFree(db, sAggInfo.aCol);\n  sqlite3DbFree(db, sAggInfo.aFunc);\n#if SELECTTRACE_ENABLED\n  SELECTTRACE(1,pParse,p,(\"end processing\\n\"));\n  pParse->nSelectIndent--;\n#endif\n  return rc;\n}\n\n/************** End of select.c **********************************************/\n/************** Begin file table.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the sqlite3_get_table() and sqlite3_free_table()\n** interface routines.  These are just wrappers around the main\n** interface routine of sqlite3_exec().\n**\n** These routines are in a separate files so that they will not be linked\n** if they are not used.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_GET_TABLE\n\n/*\n** This structure is used to pass data from sqlite3_get_table() through\n** to the callback function is uses to build the result.\n*/\ntypedef struct TabResult {\n  char **azResult;   /* Accumulated output */\n  char *zErrMsg;     /* Error message text, if an error occurs */\n  u32 nAlloc;        /* Slots allocated for azResult[] */\n  u32 nRow;          /* Number of rows in the result */\n  u32 nColumn;       /* Number of columns in the result */\n  u32 nData;         /* Slots used in azResult[].  (nRow+1)*nColumn */\n  int rc;            /* Return code from sqlite3_exec() */\n} TabResult;\n\n/*\n** This routine is called once for each row in the result table.  Its job\n** is to fill in the TabResult structure appropriately, allocating new\n** memory as necessary.\n*/\nstatic int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){\n  TabResult *p = (TabResult*)pArg;  /* Result accumulator */\n  int need;                         /* Slots needed in p->azResult[] */\n  int i;                            /* Loop counter */\n  char *z;                          /* A single column of result */\n\n  /* Make sure there is enough space in p->azResult to hold everything\n  ** we need to remember from this invocation of the callback.\n  */\n  if( p->nRow==0 && argv!=0 ){\n    need = nCol*2;\n  }else{\n    need = nCol;\n  }\n  if( p->nData + need > p->nAlloc ){\n    char **azNew;\n    p->nAlloc = p->nAlloc*2 + need;\n    azNew = sqlite3_realloc64( p->azResult, sizeof(char*)*p->nAlloc );\n    if( azNew==0 ) goto malloc_failed;\n    p->azResult = azNew;\n  }\n\n  /* If this is the first row, then generate an extra row containing\n  ** the names of all columns.\n  */\n  if( p->nRow==0 ){\n    p->nColumn = nCol;\n    for(i=0; i<nCol; i++){\n      z = sqlite3_mprintf(\"%s\", colv[i]);\n      if( z==0 ) goto malloc_failed;\n      p->azResult[p->nData++] = z;\n    }\n  }else if( (int)p->nColumn!=nCol ){\n    sqlite3_free(p->zErrMsg);\n    p->zErrMsg = sqlite3_mprintf(\n       \"sqlite3_get_table() called with two or more incompatible queries\"\n    );\n    p->rc = SQLITE_ERROR;\n    return 1;\n  }\n\n  /* Copy over the row data\n  */\n  if( argv!=0 ){\n    for(i=0; i<nCol; i++){\n      if( argv[i]==0 ){\n        z = 0;\n      }else{\n        int n = sqlite3Strlen30(argv[i])+1;\n        z = sqlite3_malloc64( n );\n        if( z==0 ) goto malloc_failed;\n        memcpy(z, argv[i], n);\n      }\n      p->azResult[p->nData++] = z;\n    }\n    p->nRow++;\n  }\n  return 0;\n\nmalloc_failed:\n  p->rc = SQLITE_NOMEM_BKPT;\n  return 1;\n}\n\n/*\n** Query the database.  But instead of invoking a callback for each row,\n** malloc() for space to hold the result and return the entire results\n** at the conclusion of the call.\n**\n** The result that is written to ***pazResult is held in memory obtained\n** from malloc().  But the caller cannot free this memory directly.  \n** Instead, the entire table should be passed to sqlite3_free_table() when\n** the calling procedure is finished using it.\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  char ***pazResult,          /* Write the result table here */\n  int *pnRow,                 /* Write the number of rows in the result here */\n  int *pnColumn,              /* Write the number of columns of result here */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc;\n  TabResult res;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *pazResult = 0;\n  if( pnColumn ) *pnColumn = 0;\n  if( pnRow ) *pnRow = 0;\n  if( pzErrMsg ) *pzErrMsg = 0;\n  res.zErrMsg = 0;\n  res.nRow = 0;\n  res.nColumn = 0;\n  res.nData = 1;\n  res.nAlloc = 20;\n  res.rc = SQLITE_OK;\n  res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );\n  if( res.azResult==0 ){\n     db->errCode = SQLITE_NOMEM;\n     return SQLITE_NOMEM_BKPT;\n  }\n  res.azResult[0] = 0;\n  rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);\n  assert( sizeof(res.azResult[0])>= sizeof(res.nData) );\n  res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);\n  if( (rc&0xff)==SQLITE_ABORT ){\n    sqlite3_free_table(&res.azResult[1]);\n    if( res.zErrMsg ){\n      if( pzErrMsg ){\n        sqlite3_free(*pzErrMsg);\n        *pzErrMsg = sqlite3_mprintf(\"%s\",res.zErrMsg);\n      }\n      sqlite3_free(res.zErrMsg);\n    }\n    db->errCode = res.rc;  /* Assume 32-bit assignment is atomic */\n    return res.rc;\n  }\n  sqlite3_free(res.zErrMsg);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free_table(&res.azResult[1]);\n    return rc;\n  }\n  if( res.nAlloc>res.nData ){\n    char **azNew;\n    azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );\n    if( azNew==0 ){\n      sqlite3_free_table(&res.azResult[1]);\n      db->errCode = SQLITE_NOMEM;\n      return SQLITE_NOMEM_BKPT;\n    }\n    res.azResult = azNew;\n  }\n  *pazResult = &res.azResult[1];\n  if( pnColumn ) *pnColumn = res.nColumn;\n  if( pnRow ) *pnRow = res.nRow;\n  return rc;\n}\n\n/*\n** This routine frees the space the sqlite3_get_table() malloced.\n*/\nSQLITE_API void sqlite3_free_table(\n  char **azResult            /* Result returned from sqlite3_get_table() */\n){\n  if( azResult ){\n    int i, n;\n    azResult--;\n    assert( azResult!=0 );\n    n = SQLITE_PTR_TO_INT(azResult[0]);\n    for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }\n    sqlite3_free(azResult);\n  }\n}\n\n#endif /* SQLITE_OMIT_GET_TABLE */\n\n/************** End of table.c ***********************************************/\n/************** Begin file trigger.c *****************************************/\n/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation for TRIGGERs\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_TRIGGER\n/*\n** Delete a linked list of TriggerStep structures.\n*/\nSQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){\n  while( pTriggerStep ){\n    TriggerStep * pTmp = pTriggerStep;\n    pTriggerStep = pTriggerStep->pNext;\n\n    sqlite3ExprDelete(db, pTmp->pWhere);\n    sqlite3ExprListDelete(db, pTmp->pExprList);\n    sqlite3SelectDelete(db, pTmp->pSelect);\n    sqlite3IdListDelete(db, pTmp->pIdList);\n\n    sqlite3DbFree(db, pTmp);\n  }\n}\n\n/*\n** Given table pTab, return a list of all the triggers attached to \n** the table. The list is connected by Trigger.pNext pointers.\n**\n** All of the triggers on pTab that are in the same database as pTab\n** are already attached to pTab->pTrigger.  But there might be additional\n** triggers on pTab in the TEMP schema.  This routine prepends all\n** TEMP triggers on pTab to the beginning of the pTab->pTrigger list\n** and returns the combined list.\n**\n** To state it another way:  This routine returns a list of all triggers\n** that fire off of pTab.  The list will include any TEMP triggers on\n** pTab as well as the triggers lised in pTab->pTrigger.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){\n  Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;\n  Trigger *pList = 0;                  /* List of triggers to return */\n\n  if( pParse->disableTriggers ){\n    return 0;\n  }\n\n  if( pTmpSchema!=pTab->pSchema ){\n    HashElem *p;\n    assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) );\n    for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){\n      Trigger *pTrig = (Trigger *)sqliteHashData(p);\n      if( pTrig->pTabSchema==pTab->pSchema\n       && 0==sqlite3StrICmp(pTrig->table, pTab->zName) \n      ){\n        pTrig->pNext = (pList ? pList : pTab->pTrigger);\n        pList = pTrig;\n      }\n    }\n  }\n\n  return (pList ? pList : pTab->pTrigger);\n}\n\n/*\n** This is called by the parser when it sees a CREATE TRIGGER statement\n** up to the point of the BEGIN before the trigger actions.  A Trigger\n** structure is generated based on the information available and stored\n** in pParse->pNewTrigger.  After the trigger actions have been parsed, the\n** sqlite3FinishTrigger() function is called to complete the trigger\n** construction process.\n*/\nSQLITE_PRIVATE void sqlite3BeginTrigger(\n  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */\n  Token *pName1,      /* The name of the trigger */\n  Token *pName2,      /* The name of the trigger */\n  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */\n  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */\n  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */\n  SrcList *pTableName,/* The name of the table/view the trigger applies to */\n  Expr *pWhen,        /* WHEN clause */\n  int isTemp,         /* True if the TEMPORARY keyword is present */\n  int noErr           /* Suppress errors if the trigger already exists */\n){\n  Trigger *pTrigger = 0;  /* The new trigger */\n  Table *pTab;            /* Table that the trigger fires off of */\n  char *zName = 0;        /* Name of the trigger */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  int iDb;                /* The database to store the trigger in */\n  Token *pName;           /* The unqualified db name */\n  DbFixer sFix;           /* State vector for the DB fixer */\n\n  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */\n  assert( pName2!=0 );\n  assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );\n  assert( op>0 && op<0xff );\n  if( isTemp ){\n    /* If TEMP was specified, then the trigger name may not be qualified. */\n    if( pName2->n>0 ){\n      sqlite3ErrorMsg(pParse, \"temporary trigger may not have qualified name\");\n      goto trigger_cleanup;\n    }\n    iDb = 1;\n    pName = pName1;\n  }else{\n    /* Figure out the db that the trigger will be created in */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ){\n      goto trigger_cleanup;\n    }\n  }\n  if( !pTableName || db->mallocFailed ){\n    goto trigger_cleanup;\n  }\n\n  /* A long-standing parser bug is that this syntax was allowed:\n  **\n  **    CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....\n  **                                                 ^^^^^^^^\n  **\n  ** To maintain backwards compatibility, ignore the database\n  ** name on pTableName if we are reparsing out of SQLITE_MASTER.\n  */\n  if( db->init.busy && iDb!=1 ){\n    sqlite3DbFree(db, pTableName->a[0].zDatabase);\n    pTableName->a[0].zDatabase = 0;\n  }\n\n  /* If the trigger name was unqualified, and the table is a temp table,\n  ** then set iDb to 1 to create the trigger in the temporary database.\n  ** If sqlite3SrcListLookup() returns 0, indicating the table does not\n  ** exist, the error is caught by the block below.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( db->init.busy==0 && pName2->n==0 && pTab\n        && pTab->pSchema==db->aDb[1].pSchema ){\n    iDb = 1;\n  }\n\n  /* Ensure the table name matches database name and that the table exists */\n  if( db->mallocFailed ) goto trigger_cleanup;\n  assert( pTableName->nSrc==1 );\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", pName);\n  if( sqlite3FixSrcList(&sFix, pTableName) ){\n    goto trigger_cleanup;\n  }\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( !pTab ){\n    /* The table does not exist. */\n    if( db->init.iDb==1 ){\n      /* Ticket #3810.\n      ** Normally, whenever a table is dropped, all associated triggers are\n      ** dropped too.  But if a TEMP trigger is created on a non-TEMP table\n      ** and the table is dropped by a different database connection, the\n      ** trigger is not visible to the database connection that does the\n      ** drop so the trigger cannot be dropped.  This results in an\n      ** \"orphaned trigger\" - a trigger whose associated table is missing.\n      */\n      db->init.orphanTrigger = 1;\n    }\n    goto trigger_cleanup;\n  }\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"cannot create triggers on virtual tables\");\n    goto trigger_cleanup;\n  }\n\n  /* Check that the trigger name is not reserved and that no trigger of the\n  ** specified name exists */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto trigger_cleanup;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"trigger %T already exists\", pName);\n    }else{\n      assert( !db->init.busy );\n      sqlite3CodeVerifySchema(pParse, iDb);\n    }\n    goto trigger_cleanup;\n  }\n\n  /* Do not create a trigger on a system table */\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 ){\n    sqlite3ErrorMsg(pParse, \"cannot create trigger on system table\");\n    goto trigger_cleanup;\n  }\n\n  /* INSTEAD of triggers are only for views and views only support INSTEAD\n  ** of triggers.\n  */\n  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create %s trigger on view: %S\", \n        (tr_tm == TK_BEFORE)?\"BEFORE\":\"AFTER\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create INSTEAD OF\"\n        \" trigger on table: %S\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    int code = SQLITE_CREATE_TRIGGER;\n    const char *zDb = db->aDb[iTabDb].zDbSName;\n    const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;\n    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){\n      goto trigger_cleanup;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){\n      goto trigger_cleanup;\n    }\n  }\n#endif\n\n  /* INSTEAD OF triggers can only appear on views and BEFORE triggers\n  ** cannot appear on views.  So we might as well translate every\n  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code\n  ** elsewhere.\n  */\n  if (tr_tm == TK_INSTEAD){\n    tr_tm = TK_BEFORE;\n  }\n\n  /* Build the Trigger object */\n  pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));\n  if( pTrigger==0 ) goto trigger_cleanup;\n  pTrigger->zName = zName;\n  zName = 0;\n  pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);\n  pTrigger->pSchema = db->aDb[iDb].pSchema;\n  pTrigger->pTabSchema = pTab->pSchema;\n  pTrigger->op = (u8)op;\n  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;\n  pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n  pTrigger->pColumns = sqlite3IdListDup(db, pColumns);\n  assert( pParse->pNewTrigger==0 );\n  pParse->pNewTrigger = pTrigger;\n\ntrigger_cleanup:\n  sqlite3DbFree(db, zName);\n  sqlite3SrcListDelete(db, pTableName);\n  sqlite3IdListDelete(db, pColumns);\n  sqlite3ExprDelete(db, pWhen);\n  if( !pParse->pNewTrigger ){\n    sqlite3DeleteTrigger(db, pTrigger);\n  }else{\n    assert( pParse->pNewTrigger==pTrigger );\n  }\n}\n\n/*\n** This routine is called after all of the trigger actions have been parsed\n** in order to complete the process of building the trigger.\n*/\nSQLITE_PRIVATE void sqlite3FinishTrigger(\n  Parse *pParse,          /* Parser context */\n  TriggerStep *pStepList, /* The triggered program */\n  Token *pAll             /* Token that describes the complete CREATE TRIGGER */\n){\n  Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */\n  char *zName;                            /* Name of trigger */\n  sqlite3 *db = pParse->db;               /* The database */\n  DbFixer sFix;                           /* Fixer object */\n  int iDb;                                /* Database containing the trigger */\n  Token nameToken;                        /* Trigger name for error reporting */\n\n  pParse->pNewTrigger = 0;\n  if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;\n  zName = pTrig->zName;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n  pTrig->step_list = pStepList;\n  while( pStepList ){\n    pStepList->pTrig = pTrig;\n    pStepList = pStepList->pNext;\n  }\n  sqlite3TokenInit(&nameToken, pTrig->zName);\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", &nameToken);\n  if( sqlite3FixTriggerStep(&sFix, pTrig->step_list) \n   || sqlite3FixExpr(&sFix, pTrig->pWhen) \n  ){\n    goto triggerfinish_cleanup;\n  }\n\n  /* if we are not initializing,\n  ** build the sqlite_master entry\n  */\n  if( !db->init.busy ){\n    Vdbe *v;\n    char *z;\n\n    /* Make an entry in the sqlite_master table */\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto triggerfinish_cleanup;\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);\n    testcase( z==0 );\n    sqlite3NestedParse(pParse,\n       \"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, zName,\n       pTrig->table, z);\n    sqlite3DbFree(db, z);\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n        sqlite3MPrintf(db, \"type='trigger' AND name='%q'\", zName));\n  }\n\n  if( db->init.busy ){\n    Trigger *pLink = pTrig;\n    Hash *pHash = &db->aDb[iDb].pSchema->trigHash;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTrig = sqlite3HashInsert(pHash, zName, pTrig);\n    if( pTrig ){\n      sqlite3OomFault(db);\n    }else if( pLink->pSchema==pLink->pTabSchema ){\n      Table *pTab;\n      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);\n      assert( pTab!=0 );\n      pLink->pNext = pTab->pTrigger;\n      pTab->pTrigger = pLink;\n    }\n  }\n\ntriggerfinish_cleanup:\n  sqlite3DeleteTrigger(db, pTrig);\n  assert( !pParse->pNewTrigger );\n  sqlite3DeleteTriggerStep(db, pStepList);\n}\n\n/*\n** Turn a SELECT statement (that the pSelect parameter points to) into\n** a trigger step.  Return a pointer to a TriggerStep structure.\n**\n** The parser calls this routine when it finds a SELECT statement in\n** body of a TRIGGER.  \n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){\n  TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));\n  if( pTriggerStep==0 ) {\n    sqlite3SelectDelete(db, pSelect);\n    return 0;\n  }\n  pTriggerStep->op = TK_SELECT;\n  pTriggerStep->pSelect = pSelect;\n  pTriggerStep->orconf = OE_Default;\n  return pTriggerStep;\n}\n\n/*\n** Allocate space to hold a new trigger step.  The allocated space\n** holds both the TriggerStep object and the TriggerStep.target.z string.\n**\n** If an OOM error occurs, NULL is returned and db->mallocFailed is set.\n*/\nstatic TriggerStep *triggerStepAllocate(\n  sqlite3 *db,                /* Database connection */\n  u8 op,                      /* Trigger opcode */\n  Token *pName                /* The target name */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);\n  if( pTriggerStep ){\n    char *z = (char*)&pTriggerStep[1];\n    memcpy(z, pName->z, pName->n);\n    sqlite3Dequote(z);\n    pTriggerStep->zTarget = z;\n    pTriggerStep->op = op;\n  }\n  return pTriggerStep;\n}\n\n/*\n** Build a trigger step out of an INSERT statement.  Return a pointer\n** to the new trigger step.\n**\n** The parser calls this routine when it sees an INSERT inside the\n** body of a trigger.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(\n  sqlite3 *db,        /* The database connection */\n  Token *pTableName,  /* Name of the table into which we insert */\n  IdList *pColumn,    /* List of columns in pTableName to insert into */\n  Select *pSelect,    /* A SELECT statement that supplies values */\n  u8 orconf           /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */\n){\n  TriggerStep *pTriggerStep;\n\n  assert(pSelect != 0 || db->mallocFailed);\n\n  pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n    pTriggerStep->pIdList = pColumn;\n    pTriggerStep->orconf = orconf;\n  }else{\n    sqlite3IdListDelete(db, pColumn);\n  }\n  sqlite3SelectDelete(db, pSelect);\n\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements an UPDATE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees an UPDATE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(\n  sqlite3 *db,         /* The database connection */\n  Token *pTableName,   /* Name of the table to be updated */\n  ExprList *pEList,    /* The SET clause: list of column and new values */\n  Expr *pWhere,        /* The WHERE clause */\n  u8 orconf            /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = orconf;\n  }\n  sqlite3ExprListDelete(db, pEList);\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements a DELETE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees a DELETE statement inside the body of a CREATE TRIGGER.\n*/\nSQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(\n  sqlite3 *db,            /* Database connection */\n  Token *pTableName,      /* The table from which rows are deleted */\n  Expr *pWhere            /* The WHERE clause */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = OE_Default;\n  }\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/* \n** Recursively delete a Trigger structure\n*/\nSQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){\n  if( pTrigger==0 ) return;\n  sqlite3DeleteTriggerStep(db, pTrigger->step_list);\n  sqlite3DbFree(db, pTrigger->zName);\n  sqlite3DbFree(db, pTrigger->table);\n  sqlite3ExprDelete(db, pTrigger->pWhen);\n  sqlite3IdListDelete(db, pTrigger->pColumns);\n  sqlite3DbFree(db, pTrigger);\n}\n\n/*\n** This function is called to drop a trigger from the database schema. \n**\n** This may be called directly from the parser and therefore identifies\n** the trigger by name.  The sqlite3DropTriggerPtr() routine does the\n** same job as this routine except it takes a pointer to the trigger\n** instead of the trigger name.\n**/\nSQLITE_PRIVATE void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){\n  Trigger *pTrigger = 0;\n  int i;\n  const char *zDb;\n  const char *zName;\n  sqlite3 *db = pParse->db;\n\n  if( db->mallocFailed ) goto drop_trigger_cleanup;\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto drop_trigger_cleanup;\n  }\n\n  assert( pName->nSrc==1 );\n  zDb = pName->a[0].zDatabase;\n  zName = pName->a[0].zName;\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    if( zDb && sqlite3StrICmp(db->aDb[j].zDbSName, zDb) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName);\n    if( pTrigger ) break;\n  }\n  if( !pTrigger ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"no such trigger: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, zDb);\n    }\n    pParse->checkSchema = 1;\n    goto drop_trigger_cleanup;\n  }\n  sqlite3DropTriggerPtr(pParse, pTrigger);\n\ndrop_trigger_cleanup:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** Return a pointer to the Table structure for the table that a trigger\n** is set on.\n*/\nstatic Table *tableOfTrigger(Trigger *pTrigger){\n  return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);\n}\n\n\n/*\n** Drop a trigger given a pointer to that trigger. \n*/\nSQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){\n  Table   *pTable;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  pTable = tableOfTrigger(pTrigger);\n  assert( pTable );\n  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_TRIGGER;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||\n      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      return;\n    }\n  }\n#endif\n\n  /* Generate code to destroy the database record of the trigger.\n  */\n  assert( pTable!=0 );\n  if( (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName\n    );\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);\n  }\n}\n\n/*\n** Remove a trigger from the hash tables of the sqlite* pointer.\n*/\nSQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){\n  Trigger *pTrigger;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &(db->aDb[iDb].pSchema->trigHash);\n  pTrigger = sqlite3HashInsert(pHash, zName, 0);\n  if( ALWAYS(pTrigger) ){\n    if( pTrigger->pSchema==pTrigger->pTabSchema ){\n      Table *pTab = tableOfTrigger(pTrigger);\n      Trigger **pp;\n      for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));\n      *pp = (*pp)->pNext;\n    }\n    sqlite3DeleteTrigger(db, pTrigger);\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }\n}\n\n/*\n** pEList is the SET clause of an UPDATE statement.  Each entry\n** in pEList is of the format <id>=<expr>.  If any of the entries\n** in pEList have an <id> which matches an identifier in pIdList,\n** then return TRUE.  If pIdList==NULL, then it is considered a\n** wildcard that matches anything.  Likewise if pEList==NULL then\n** it matches anything so always return true.  Return false only\n** if there is no match.\n*/\nstatic int checkColumnOverlap(IdList *pIdList, ExprList *pEList){\n  int e;\n  if( pIdList==0 || NEVER(pEList==0) ) return 1;\n  for(e=0; e<pEList->nExpr; e++){\n    if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1;\n  }\n  return 0; \n}\n\n/*\n** Return a list of all triggers on table pTab if there exists at least\n** one trigger that must be fired when an operation of type 'op' is \n** performed on the table, and, if that operation is an UPDATE, if at\n** least one of the columns in pChanges is being modified.\n*/\nSQLITE_PRIVATE Trigger *sqlite3TriggersExist(\n  Parse *pParse,          /* Parse context */\n  Table *pTab,            /* The table the contains the triggers */\n  int op,                 /* one of TK_DELETE, TK_INSERT, TK_UPDATE */\n  ExprList *pChanges,     /* Columns that change in an UPDATE statement */\n  int *pMask              /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n){\n  int mask = 0;\n  Trigger *pList = 0;\n  Trigger *p;\n\n  if( (pParse->db->flags & SQLITE_EnableTrigger)!=0 ){\n    pList = sqlite3TriggerList(pParse, pTab);\n  }\n  assert( pList==0 || IsVirtual(pTab)==0 );\n  for(p=pList; p; p=p->pNext){\n    if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){\n      mask |= p->tr_tm;\n    }\n  }\n  if( pMask ){\n    *pMask = mask;\n  }\n  return (mask ? pList : 0);\n}\n\n/*\n** Convert the pStep->zTarget string into a SrcList and return a pointer\n** to that SrcList.\n**\n** This routine adds a specific database name, if needed, to the target when\n** forming the SrcList.  This prevents a trigger in one database from\n** referring to a target in another database.  An exception is when the\n** trigger is in TEMP in which case it can refer to any other database it\n** wants.\n*/\nstatic SrcList *targetSrcList(\n  Parse *pParse,       /* The parsing context */\n  TriggerStep *pStep   /* The trigger containing the target token */\n){\n  sqlite3 *db = pParse->db;\n  int iDb;             /* Index of the database to use */\n  SrcList *pSrc;       /* SrcList to be returned */\n\n  pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n  if( pSrc ){\n    assert( pSrc->nSrc>0 );\n    pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);\n    iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema);\n    if( iDb==0 || iDb>=2 ){\n      const char *zDb;\n      assert( iDb<db->nDb );\n      zDb = db->aDb[iDb].zDbSName;\n      pSrc->a[pSrc->nSrc-1].zDatabase =  sqlite3DbStrDup(db, zDb);\n    }\n  }\n  return pSrc;\n}\n\n/*\n** Generate VDBE code for the statements inside the body of a single \n** trigger.\n*/\nstatic int codeTriggerProgram(\n  Parse *pParse,            /* The parser context */\n  TriggerStep *pStepList,   /* List of statements inside the trigger body */\n  int orconf                /* Conflict algorithm. (OE_Abort, etc) */  \n){\n  TriggerStep *pStep;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( pParse->pTriggerTab && pParse->pToplevel );\n  assert( pStepList );\n  assert( v!=0 );\n  for(pStep=pStepList; pStep; pStep=pStep->pNext){\n    /* Figure out the ON CONFLICT policy that will be used for this step\n    ** of the trigger program. If the statement that caused this trigger\n    ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use\n    ** the ON CONFLICT policy that was specified as part of the trigger\n    ** step statement. Example:\n    **\n    **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;\n    **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);\n    **   END;\n    **\n    **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy\n    **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy\n    */\n    pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;\n    assert( pParse->okConstFactor==0 );\n\n    switch( pStep->op ){\n      case TK_UPDATE: {\n        sqlite3Update(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprListDup(db, pStep->pExprList, 0), \n          sqlite3ExprDup(db, pStep->pWhere, 0), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_INSERT: {\n        sqlite3Insert(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3SelectDup(db, pStep->pSelect, 0), \n          sqlite3IdListDup(db, pStep->pIdList), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_DELETE: {\n        sqlite3DeleteFrom(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprDup(db, pStep->pWhere, 0)\n        );\n        break;\n      }\n      default: assert( pStep->op==TK_SELECT ); {\n        SelectDest sDest;\n        Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);\n        sqlite3SelectDestInit(&sDest, SRT_Discard, 0);\n        sqlite3Select(pParse, pSelect, &sDest);\n        sqlite3SelectDelete(db, pSelect);\n        break;\n      }\n    } \n    if( pStep->op!=TK_SELECT ){\n      sqlite3VdbeAddOp0(v, OP_ResetCount);\n    }\n  }\n\n  return 0;\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** This function is used to add VdbeComment() annotations to a VDBE\n** program. It is not used in production code, only for debugging.\n*/\nstatic const char *onErrorText(int onError){\n  switch( onError ){\n    case OE_Abort:    return \"abort\";\n    case OE_Rollback: return \"rollback\";\n    case OE_Fail:     return \"fail\";\n    case OE_Replace:  return \"replace\";\n    case OE_Ignore:   return \"ignore\";\n    case OE_Default:  return \"default\";\n  }\n  return \"n/a\";\n}\n#endif\n\n/*\n** Parse context structure pFrom has just been used to create a sub-vdbe\n** (trigger program). If an error has occurred, transfer error information\n** from pFrom to pTo.\n*/\nstatic void transferParseError(Parse *pTo, Parse *pFrom){\n  assert( pFrom->zErrMsg==0 || pFrom->nErr );\n  assert( pTo->zErrMsg==0 || pTo->nErr );\n  if( pTo->nErr==0 ){\n    pTo->zErrMsg = pFrom->zErrMsg;\n    pTo->nErr = pFrom->nErr;\n    pTo->rc = pFrom->rc;\n  }else{\n    sqlite3DbFree(pFrom->db, pFrom->zErrMsg);\n  }\n}\n\n/*\n** Create and populate a new TriggerPrg object with a sub-program \n** implementing trigger pTrigger with ON CONFLICT policy orconf.\n*/\nstatic TriggerPrg *codeRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table pTrigger is attached to */\n  int orconf           /* ON CONFLICT policy to code trigger program with */\n){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  sqlite3 *db = pParse->db;   /* Database handle */\n  TriggerPrg *pPrg;           /* Value to return */\n  Expr *pWhen = 0;            /* Duplicate of trigger WHEN expression */\n  Vdbe *v;                    /* Temporary VM */\n  NameContext sNC;            /* Name context for sub-vdbe */\n  SubProgram *pProgram = 0;   /* Sub-vdbe for trigger program */\n  Parse *pSubParse;           /* Parse context for sub-vdbe */\n  int iEndTrigger = 0;        /* Label to jump to if WHEN is false */\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n  assert( pTop->pVdbe );\n\n  /* Allocate the TriggerPrg and SubProgram objects. To ensure that they\n  ** are freed if an error occurs, link them into the Parse.pTriggerPrg \n  ** list of the top-level Parse object sooner rather than later.  */\n  pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));\n  if( !pPrg ) return 0;\n  pPrg->pNext = pTop->pTriggerPrg;\n  pTop->pTriggerPrg = pPrg;\n  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));\n  if( !pProgram ) return 0;\n  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);\n  pPrg->pTrigger = pTrigger;\n  pPrg->orconf = orconf;\n  pPrg->aColmask[0] = 0xffffffff;\n  pPrg->aColmask[1] = 0xffffffff;\n\n  /* Allocate and populate a new Parse context to use for coding the \n  ** trigger sub-program.  */\n  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));\n  if( !pSubParse ) return 0;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pSubParse;\n  pSubParse->db = db;\n  pSubParse->pTriggerTab = pTab;\n  pSubParse->pToplevel = pTop;\n  pSubParse->zAuthContext = pTrigger->zName;\n  pSubParse->eTriggerOp = pTrigger->op;\n  pSubParse->nQueryLoop = pParse->nQueryLoop;\n\n  v = sqlite3GetVdbe(pSubParse);\n  if( v ){\n    VdbeComment((v, \"Start: %s.%s (%s %s%s%s ON %s)\", \n      pTrigger->zName, onErrorText(orconf),\n      (pTrigger->tr_tm==TRIGGER_BEFORE ? \"BEFORE\" : \"AFTER\"),\n        (pTrigger->op==TK_UPDATE ? \"UPDATE\" : \"\"),\n        (pTrigger->op==TK_INSERT ? \"INSERT\" : \"\"),\n        (pTrigger->op==TK_DELETE ? \"DELETE\" : \"\"),\n      pTab->zName\n    ));\n#ifndef SQLITE_OMIT_TRACE\n    sqlite3VdbeChangeP4(v, -1, \n      sqlite3MPrintf(db, \"-- TRIGGER %s\", pTrigger->zName), P4_DYNAMIC\n    );\n#endif\n\n    /* If one was specified, code the WHEN clause. If it evaluates to false\n    ** (or NULL) the sub-vdbe is immediately halted by jumping to the \n    ** OP_Halt inserted at the end of the program.  */\n    if( pTrigger->pWhen ){\n      pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);\n      if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) \n       && db->mallocFailed==0 \n      ){\n        iEndTrigger = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);\n      }\n      sqlite3ExprDelete(db, pWhen);\n    }\n\n    /* Code the trigger program into the sub-vdbe. */\n    codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);\n\n    /* Insert an OP_Halt at the end of the sub-program. */\n    if( iEndTrigger ){\n      sqlite3VdbeResolveLabel(v, iEndTrigger);\n    }\n    sqlite3VdbeAddOp0(v, OP_Halt);\n    VdbeComment((v, \"End: %s.%s\", pTrigger->zName, onErrorText(orconf)));\n\n    transferParseError(pParse, pSubParse);\n    if( db->mallocFailed==0 ){\n      pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);\n    }\n    pProgram->nMem = pSubParse->nMem;\n    pProgram->nCsr = pSubParse->nTab;\n    pProgram->token = (void *)pTrigger;\n    pPrg->aColmask[0] = pSubParse->oldmask;\n    pPrg->aColmask[1] = pSubParse->newmask;\n    sqlite3VdbeDelete(v);\n  }\n\n  assert( !pSubParse->pAinc       && !pSubParse->pZombieTab );\n  assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );\n  sqlite3ParserReset(pSubParse);\n  sqlite3StackFree(db, pSubParse);\n\n  return pPrg;\n}\n    \n/*\n** Return a pointer to a TriggerPrg object containing the sub-program for\n** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such\n** TriggerPrg object exists, a new object is allocated and populated before\n** being returned.\n*/\nstatic TriggerPrg *getRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table trigger pTrigger is attached to */\n  int orconf           /* ON CONFLICT algorithm. */\n){\n  Parse *pRoot = sqlite3ParseToplevel(pParse);\n  TriggerPrg *pPrg;\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n\n  /* It may be that this trigger has already been coded (or is in the\n  ** process of being coded). If this is the case, then an entry with\n  ** a matching TriggerPrg.pTrigger field will be present somewhere\n  ** in the Parse.pTriggerPrg list. Search for such an entry.  */\n  for(pPrg=pRoot->pTriggerPrg; \n      pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf); \n      pPrg=pPrg->pNext\n  );\n\n  /* If an existing TriggerPrg could not be located, create a new one. */\n  if( !pPrg ){\n    pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);\n  }\n\n  return pPrg;\n}\n\n/*\n** Generate code for the trigger program associated with trigger p on \n** table pTab. The reg, orconf and ignoreJump parameters passed to this\n** function are the same as those described in the header function for\n** sqlite3CodeRowTrigger()\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(\n  Parse *pParse,       /* Parse context */\n  Trigger *p,          /* Trigger to code */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* Reg array containing OLD.* and NEW.* values */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */\n  TriggerPrg *pPrg;\n  pPrg = getRowTrigger(pParse, p, pTab, orconf);\n  assert( pPrg || pParse->nErr || pParse->db->mallocFailed );\n\n  /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program \n  ** is a pointer to the sub-vdbe containing the trigger program.  */\n  if( pPrg ){\n    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));\n\n    sqlite3VdbeAddOp4(v, OP_Program, reg, ignoreJump, ++pParse->nMem,\n                      (const char *)pPrg->pProgram, P4_SUBPROGRAM);\n    VdbeComment(\n        (v, \"Call: %s.%s\", (p->zName?p->zName:\"fkey\"), onErrorText(orconf)));\n\n    /* Set the P5 operand of the OP_Program instruction to non-zero if\n    ** recursive invocation of this trigger program is disallowed. Recursive\n    ** invocation is disallowed if (a) the sub-program is really a trigger,\n    ** not a foreign key action, and (b) the flag to enable recursive triggers\n    ** is clear.  */\n    sqlite3VdbeChangeP5(v, (u8)bRecursive);\n  }\n}\n\n/*\n** This is called to code the required FOR EACH ROW triggers for an operation\n** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)\n** is given by the op parameter. The tr_tm parameter determines whether the\n** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then\n** parameter pChanges is passed the list of columns being modified.\n**\n** If there are no triggers that fire at the specified time for the specified\n** operation on pTab, this function is a no-op.\n**\n** The reg argument is the address of the first in an array of registers \n** that contain the values substituted for the new.* and old.* references\n** in the trigger program. If N is the number of columns in table pTab\n** (a copy of pTab->nCol), then registers are populated as follows:\n**\n**   Register       Contains\n**   ------------------------------------------------------\n**   reg+0          OLD.rowid\n**   reg+1          OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N          OLD.* value of right-most column of pTab\n**   reg+N+1        NEW.rowid\n**   reg+N+2        OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N+N+1      NEW.* value of right-most column of pTab\n**\n** For ON DELETE triggers, the registers containing the NEW.* values will\n** never be accessed by the trigger program, so they are not allocated or \n** populated by the caller (there is no data to populate them with anyway). \n** Similarly, for ON INSERT triggers the values stored in the OLD.* registers\n** are never accessed, and so are not allocated by the caller. So, for an\n** ON INSERT trigger, the value passed to this function as parameter reg\n** is not a readable register, although registers (reg+N) through \n** (reg+N+N+1) are.\n**\n** Parameter orconf is the default conflict resolution algorithm for the\n** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump\n** is the instruction that control should jump to if a trigger program\n** raises an IGNORE exception.\n*/\nSQLITE_PRIVATE void sqlite3CodeRowTrigger(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  int op,              /* One of TK_UPDATE, TK_INSERT, TK_DELETE */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int tr_tm,           /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* The first in an array of registers (see above) */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Trigger *p;          /* Used to iterate through pTrigger list */\n\n  assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );\n  assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );\n  assert( (op==TK_UPDATE)==(pChanges!=0) );\n\n  for(p=pTrigger; p; p=p->pNext){\n\n    /* Sanity checking:  The schema for the trigger and for the table are\n    ** always defined.  The trigger must be in the same schema as the table\n    ** or else it must be a TEMP trigger. */\n    assert( p->pSchema!=0 );\n    assert( p->pTabSchema!=0 );\n    assert( p->pSchema==p->pTabSchema \n         || p->pSchema==pParse->db->aDb[1].pSchema );\n\n    /* Determine whether we should code this trigger */\n    if( p->op==op \n     && p->tr_tm==tr_tm \n     && checkColumnOverlap(p->pColumns, pChanges)\n    ){\n      sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);\n    }\n  }\n}\n\n/*\n** Triggers may access values stored in the old.* or new.* pseudo-table. \n** This function returns a 32-bit bitmask indicating which columns of the \n** old.* or new.* tables actually are used by triggers. This information \n** may be used by the caller, for example, to avoid having to load the entire\n** old.* record into memory when executing an UPDATE or DELETE command.\n**\n** Bit 0 of the returned mask is set if the left-most column of the\n** table may be accessed using an [old|new].<col> reference. Bit 1 is set if\n** the second leftmost column value is required, and so on. If there\n** are more than 32 columns in the table, and at least one of the columns\n** with an index greater than 32 may be accessed, 0xffffffff is returned.\n**\n** It is not possible to determine if the old.rowid or new.rowid column is \n** accessed by triggers. The caller must always assume that it is.\n**\n** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned\n** applies to the old.* table. If 1, the new.* table.\n**\n** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE\n** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only\n** included in the returned mask if the TRIGGER_BEFORE bit is set in the\n** tr_tm parameter. Similarly, values accessed by AFTER triggers are only\n** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.\n*/\nSQLITE_PRIVATE u32 sqlite3TriggerColmask(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int isNew,           /* 1 for new.* ref mask, 0 for old.* ref mask */\n  int tr_tm,           /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int orconf           /* Default ON CONFLICT policy for trigger steps */\n){\n  const int op = pChanges ? TK_UPDATE : TK_DELETE;\n  u32 mask = 0;\n  Trigger *p;\n\n  assert( isNew==1 || isNew==0 );\n  for(p=pTrigger; p; p=p->pNext){\n    if( p->op==op && (tr_tm&p->tr_tm)\n     && checkColumnOverlap(p->pColumns,pChanges)\n    ){\n      TriggerPrg *pPrg;\n      pPrg = getRowTrigger(pParse, p, pTab, orconf);\n      if( pPrg ){\n        mask |= pPrg->aColmask[isNew];\n      }\n    }\n  }\n\n  return mask;\n}\n\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n/************** End of trigger.c *********************************************/\n/************** Begin file update.c ******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle UPDATE statements.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Forward declaration */\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowidExpr,    /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** The most recently coded instruction was an OP_Column to retrieve the\n** i-th column of table pTab. This routine sets the P4 parameter of the \n** OP_Column to the default value, if any.\n**\n** The default value of a column is specified by a DEFAULT clause in the \n** column definition. This was either supplied by the user when the table\n** was created, or added later to the table definition by an ALTER TABLE\n** command. If the latter, then the row-records in the table btree on disk\n** may not contain a value for the column and the default value, taken\n** from the P4 parameter of the OP_Column instruction, is returned instead.\n** If the former, then all row-records are guaranteed to include a value\n** for the column and the P4 value is not required.\n**\n** Column definitions created by an ALTER TABLE command may only have \n** literal default values specified: a number, null or a string. (If a more\n** complicated default expression value was provided, it is evaluated \n** when the ALTER TABLE is executed and one of the literal values written\n** into the sqlite_master table.)\n**\n** Therefore, the P4 parameter is only required if the default value for\n** the column is a literal number, string or null. The sqlite3ValueFromExpr()\n** function is capable of transforming these types of expressions into\n** sqlite3_value objects.\n**\n** If parameter iReg is not negative, code an OP_RealAffinity instruction\n** on register iReg. This is used when an equivalent integer value is \n** stored in place of an 8-byte floating point value in order to save \n** space.\n*/\nSQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){\n  assert( pTab!=0 );\n  if( !pTab->pSelect ){\n    sqlite3_value *pValue = 0;\n    u8 enc = ENC(sqlite3VdbeDb(v));\n    Column *pCol = &pTab->aCol[i];\n    VdbeComment((v, \"%s.%s\", pTab->zName, pCol->zName));\n    assert( i<pTab->nCol );\n    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, \n                         pCol->affinity, &pValue);\n    if( pValue ){\n      sqlite3VdbeAppendP4(v, pValue, P4_MEM);\n    }\n  }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){\n    sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);\n  }\n#endif\n}\n\n/*\n** Process an UPDATE statement.\n**\n**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;\n**          \\_______/ \\________/     \\______/       \\________________/\n*            onError   pTabList      pChanges             pWhere\n*/\nSQLITE_PRIVATE void sqlite3Update(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table in which we should change things */\n  ExprList *pChanges,    /* Things to be changed */\n  Expr *pWhere,          /* The WHERE clause.  May be null */\n  int onError            /* How to handle constraint errors */\n){\n  int i, j;              /* Loop counters */\n  Table *pTab;           /* The table to be updated */\n  int addrTop = 0;       /* VDBE instruction address of the start of the loop */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Vdbe *v;               /* The virtual database engine */\n  Index *pIdx;           /* For looping over indices */\n  Index *pPk;            /* The PRIMARY KEY index for WITHOUT ROWID tables */\n  int nIdx;              /* Number of indices that need updating */\n  int iBaseCur;          /* Base cursor number */\n  int iDataCur;          /* Cursor for the canonical data btree */\n  int iIdxCur;           /* Cursor for the first index */\n  sqlite3 *db;           /* The database structure */\n  int *aRegIdx = 0;      /* First register in array assigned to each index */\n  int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the\n                         ** an expression for the i-th column of the table.\n                         ** aXRef[i]==-1 if the i-th column is not changed. */\n  u8 *aToOpen;           /* 1 for tables and indices to be opened */\n  u8 chngPk;             /* PRIMARY KEY changed in a WITHOUT ROWID table */\n  u8 chngRowid;          /* Rowid changed in a normal table */\n  u8 chngKey;            /* Either chngPk or chngRowid */\n  Expr *pRowidExpr = 0;  /* Expression defining the new record number */\n  AuthContext sContext;  /* The authorization context */\n  NameContext sNC;       /* The name-context to resolve expressions in */\n  int iDb;               /* Database containing the table being updated */\n  int eOnePass;          /* ONEPASS_XXX value from where.c */\n  int hasFK;             /* True if foreign key processing is required */\n  int labelBreak;        /* Jump here to break out of UPDATE loop */\n  int labelContinue;     /* Jump here to continue next step of UPDATE loop */\n  int flags;             /* Flags for sqlite3WhereBegin() */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;            /* True when updating a view (INSTEAD OF trigger) */\n  Trigger *pTrigger;     /* List of triggers on pTab, if required */\n  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n#endif\n  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */\n  int iEph = 0;          /* Ephemeral table holding all primary key values */\n  int nKey = 0;          /* Number of elements in regKey for WITHOUT ROWID */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  int addrOpen = 0;      /* Address of OP_OpenEphemeral */\n  int iPk = 0;           /* First of nPk cells holding PRIMARY KEY value */\n  i16 nPk = 0;           /* Number of components of the PRIMARY KEY */\n  int bReplace = 0;      /* True if REPLACE conflict resolution might happen */\n\n  /* Register Allocations */\n  int regRowCount = 0;   /* A count of rows changed */\n  int regOldRowid = 0;   /* The old rowid */\n  int regNewRowid = 0;   /* The new rowid */\n  int regNew = 0;        /* Content of the NEW.* table in triggers */\n  int regOld = 0;        /* Content of OLD.* table in triggers */\n  int regRowSet = 0;     /* Rowset of rows to be updated */\n  int regKey = 0;        /* composite PRIMARY KEY value */\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto update_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to update. \n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ) goto update_cleanup;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n\n  /* Figure out if we have any triggers and if the table being\n  ** updated is a view.\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);\n  isView = pTab->pSelect!=0;\n  assert( pTrigger || tmask==0 );\n#else\n# define pTrigger 0\n# define isView 0\n# define tmask 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto update_cleanup;\n  }\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto update_cleanup;\n  }\n\n  /* Allocate a cursors for the main database table and for all indices.\n  ** The index cursors might not be used, but if they are used they\n  ** need to occur right after the database cursor.  So go ahead and\n  ** allocate enough space, just in case.\n  */\n  pTabList->a[0].iCursor = iBaseCur = iDataCur = pParse->nTab++;\n  iIdxCur = iDataCur+1;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){\n      iDataCur = pParse->nTab;\n      pTabList->a[0].iCursor = iDataCur;\n    }\n    pParse->nTab++;\n  }\n\n  /* Allocate space for aXRef[], aRegIdx[], and aToOpen[].  \n  ** Initialize aXRef[] and aToOpen[] to their default values.\n  */\n  aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 );\n  if( aXRef==0 ) goto update_cleanup;\n  aRegIdx = aXRef+pTab->nCol;\n  aToOpen = (u8*)(aRegIdx+nIdx);\n  memset(aToOpen, 1, nIdx+1);\n  aToOpen[nIdx+1] = 0;\n  for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;\n\n  /* Initialize the name-context */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n\n  /* Resolve the column names in all the expressions of the\n  ** of the UPDATE statement.  Also find the column index\n  ** for each column to be updated in the pChanges array.  For each\n  ** column to be updated, make sure we have authorization to change\n  ** that column.\n  */\n  chngRowid = chngPk = 0;\n  for(i=0; i<pChanges->nExpr; i++){\n    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){\n      goto update_cleanup;\n    }\n    for(j=0; j<pTab->nCol; j++){\n      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){\n        if( j==pTab->iPKey ){\n          chngRowid = 1;\n          pRowidExpr = pChanges->a[i].pExpr;\n        }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){\n          chngPk = 1;\n        }\n        aXRef[j] = i;\n        break;\n      }\n    }\n    if( j>=pTab->nCol ){\n      if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){\n        j = -1;\n        chngRowid = 1;\n        pRowidExpr = pChanges->a[i].pExpr;\n      }else{\n        sqlite3ErrorMsg(pParse, \"no such column: %s\", pChanges->a[i].zName);\n        pParse->checkSchema = 1;\n        goto update_cleanup;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      int rc;\n      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,\n                            j<0 ? \"ROWID\" : pTab->aCol[j].zName,\n                            db->aDb[iDb].zDbSName);\n      if( rc==SQLITE_DENY ){\n        goto update_cleanup;\n      }else if( rc==SQLITE_IGNORE ){\n        aXRef[j] = -1;\n      }\n    }\n#endif\n  }\n  assert( (chngRowid & chngPk)==0 );\n  assert( chngRowid==0 || chngRowid==1 );\n  assert( chngPk==0 || chngPk==1 );\n  chngKey = chngRowid + chngPk;\n\n  /* The SET expressions are not actually used inside the WHERE loop.  \n  ** So reset the colUsed mask. Unless this is a virtual table. In that\n  ** case, set all bits of the colUsed mask (to ensure that the virtual\n  ** table implementation makes all columns available).\n  */\n  pTabList->a[0].colUsed = IsVirtual(pTab) ? ALLBITS : 0;\n\n  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);\n\n  /* There is one entry in the aRegIdx[] array for each index on the table\n  ** being updated.  Fill in aRegIdx[] with a register number that will hold\n  ** the key for accessing each index.\n  **\n  ** FIXME:  Be smarter about omitting indexes that use expressions.\n  */\n  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n    int reg;\n    if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){\n      reg = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }else{\n      reg = 0;\n      for(i=0; i<pIdx->nKeyCol; i++){\n        i16 iIdxCol = pIdx->aiColumn[i];\n        if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){\n          reg = ++pParse->nMem;\n          pParse->nMem += pIdx->nColumn;\n          if( (onError==OE_Replace)\n           || (onError==OE_Default && pIdx->onError==OE_Replace) \n          ){\n            bReplace = 1;\n          }\n          break;\n        }\n      }\n    }\n    if( reg==0 ) aToOpen[j+1] = 0;\n    aRegIdx[j] = reg;\n  }\n  if( bReplace ){\n    /* If REPLACE conflict resolution might be invoked, open cursors on all \n    ** indexes in case they are needed to delete records.  */\n    memset(aToOpen, 1, nIdx+1);\n  }\n\n  /* Begin generating code. */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto update_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n  /* Allocate required registers. */\n  if( !IsVirtual(pTab) ){\n    regRowSet = ++pParse->nMem;\n    regOldRowid = regNewRowid = ++pParse->nMem;\n    if( chngPk || pTrigger || hasFK ){\n      regOld = pParse->nMem + 1;\n      pParse->nMem += pTab->nCol;\n    }\n    if( chngKey || pTrigger || hasFK ){\n      regNewRowid = ++pParse->nMem;\n    }\n    regNew = pParse->nMem + 1;\n    pParse->nMem += pTab->nCol;\n  }\n\n  /* Start the view context. */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* If we are trying to update a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iDataCur);\n  }\n#endif\n\n  /* Resolve the column names in all the expressions in the\n  ** WHERE clause.\n  */\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto update_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Virtual tables must be handled separately */\n  if( IsVirtual(pTab) ){\n    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,\n                       pWhere, onError);\n    goto update_cleanup;\n  }\n#endif\n\n  /* Initialize the count of updated rows */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);\n  }else{\n    assert( pPk!=0 );\n    nPk = pPk->nKeyCol;\n    iPk = pParse->nMem+1;\n    pParse->nMem += nPk;\n    regKey = ++pParse->nMem;\n    iEph = pParse->nTab++;\n\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iPk);\n    addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);\n    sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n  }\n\n  /* Begin the database scan. \n  **\n  ** Do not consider a single-pass strategy for a multi-row update if\n  ** there are any triggers or foreign keys to process, or rows may\n  ** be deleted as a result of REPLACE conflict handling. Any of these\n  ** things might disturb a cursor being used to scan through the table\n  ** or index, causing a single-pass approach to malfunction.  */\n  flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;\n  if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){\n    flags |= WHERE_ONEPASS_MULTIROW;\n  }\n  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);\n  if( pWInfo==0 ) goto update_cleanup;\n\n  /* A one-pass strategy that might update more than one row may not\n  ** be used if any column of the index used for the scan is being\n  ** updated. Otherwise, if there is an index on \"b\", statements like\n  ** the following could create an infinite loop:\n  **\n  **   UPDATE t1 SET b=b+1 WHERE b>?\n  **\n  ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI\n  ** strategy that uses an index for which one or more columns are being\n  ** updated.  */\n  eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n  if( eOnePass==ONEPASS_MULTI ){\n    int iCur = aiCurOnePass[1];\n    if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){\n      eOnePass = ONEPASS_OFF;\n    }\n    assert( iCur!=iDataCur || !HasRowid(pTab) );\n  }\n  \n  if( HasRowid(pTab) ){\n    /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF\n    ** mode, write the rowid into the FIFO. In either of the one-pass modes,\n    ** leave it in register regOldRowid.  */\n    sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid);\n    if( eOnePass==ONEPASS_OFF ){\n      sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);\n    }\n  }else{\n    /* Read the PK of the current row into an array of registers. In\n    ** ONEPASS_OFF mode, serialize the array into a record and store it in\n    ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change\n    ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table \n    ** is not required) and leave the PK fields in the array of registers.  */\n    for(i=0; i<nPk; i++){\n      assert( pPk->aiColumn[i]>=0 );\n      sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);\n    }\n    if( eOnePass ){\n      sqlite3VdbeChangeToNoop(v, addrOpen);\n      nKey = nPk;\n      regKey = iPk;\n    }else{\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey,\n                        sqlite3IndexAffinityStr(db, pPk), nPk);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk);\n    }\n  }\n\n  if( eOnePass!=ONEPASS_MULTI ){\n    sqlite3WhereEnd(pWInfo);\n  }\n\n  labelBreak = sqlite3VdbeMakeLabel(v);\n  if( !isView ){\n    int addrOnce = 0;\n\n    /* Open every index that needs updating. */\n    if( eOnePass!=ONEPASS_OFF ){\n      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;\n      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;\n    }\n\n    if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n    }\n    sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen,\n                               0, 0);\n    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n  }\n\n  /* Top of the update loop */\n  if( eOnePass!=ONEPASS_OFF ){\n    if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){\n      assert( pPk );\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey, nKey);\n      VdbeCoverageNeverTaken(v);\n    }\n    if( eOnePass==ONEPASS_SINGLE ){\n      labelContinue = labelBreak;\n    }else{\n      labelContinue = sqlite3VdbeMakeLabel(v);\n    }\n    sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);\n    VdbeCoverageIf(v, pPk==0);\n    VdbeCoverageIf(v, pPk!=0);\n  }else if( pPk ){\n    labelContinue = sqlite3VdbeMakeLabel(v);\n    sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);\n    addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);\n    sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);\n    VdbeCoverage(v);\n  }else{\n    labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,\n                             regOldRowid);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n    VdbeCoverage(v);\n  }\n\n  /* If the record number will change, set register regNewRowid to\n  ** contain the new value. If the record number is not being modified,\n  ** then regNewRowid is the same register as regOldRowid, which is\n  ** already populated.  */\n  assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );\n  if( chngRowid ){\n    sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);\n    sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v);\n  }\n\n  /* Compute the old pre-UPDATE content of the row being changed, if that\n  ** information is needed */\n  if( chngPk || hasFK || pTrigger ){\n    u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);\n    oldmask |= sqlite3TriggerColmask(pParse, \n        pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError\n    );\n    for(i=0; i<pTab->nCol; i++){\n      if( oldmask==0xffffffff\n       || (i<32 && (oldmask & MASKBIT32(i))!=0)\n       || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0\n      ){\n        testcase(  oldmask!=0xffffffff && i==31 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);\n      }\n    }\n    if( chngRowid==0 && pPk==0 ){\n      sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);\n    }\n  }\n\n  /* Populate the array of registers beginning at regNew with the new\n  ** row data. This array is used to check constants, create the new\n  ** table and index records, and as the values for any new.* references\n  ** made by triggers.\n  **\n  ** If there are one or more BEFORE triggers, then do not populate the\n  ** registers associated with columns that are (a) not modified by\n  ** this UPDATE statement and (b) not accessed by new.* references. The\n  ** values for registers not modified by the UPDATE must be reloaded from \n  ** the database after the BEFORE triggers are fired anyway (as the trigger \n  ** may have modified them). So not loading those that are not going to\n  ** be used eliminates some redundant opcodes.\n  */\n  newmask = sqlite3TriggerColmask(\n      pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError\n  );\n  for(i=0; i<pTab->nCol; i++){\n    if( i==pTab->iPKey ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n    }else{\n      j = aXRef[i];\n      if( j>=0 ){\n        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);\n      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){\n        /* This branch loads the value of a column that will not be changed \n        ** into a register. This is done if there are no BEFORE triggers, or\n        ** if there are one or more BEFORE triggers that use this value via\n        ** a new.* reference in a trigger program.\n        */\n        testcase( i==31 );\n        testcase( i==32 );\n        sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n      }\n    }\n  }\n\n  /* Fire any BEFORE UPDATE triggers. This happens before constraints are\n  ** verified. One could argue that this is wrong.\n  */\n  if( tmask&TRIGGER_BEFORE ){\n    sqlite3TableAffinity(v, pTab, regNew);\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n        TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue);\n\n    /* The row-trigger may have deleted the row being updated. In this\n    ** case, jump to the next row. No updates or AFTER triggers are \n    ** required. This behavior - what happens when the row being updated\n    ** is deleted or renamed by a BEFORE trigger - is left undefined in the\n    ** documentation.\n    */\n    if( pPk ){\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue,regKey,nKey);\n      VdbeCoverage(v);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n      VdbeCoverage(v);\n    }\n\n    /* If it did not delete it, the row-trigger may still have modified \n    ** some of the columns of the row being updated. Load the values for \n    ** all columns not modified by the update statement into their \n    ** registers in case this has happened.\n    */\n    for(i=0; i<pTab->nCol; i++){\n      if( aXRef[i]<0 && i!=pTab->iPKey ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);\n      }\n    }\n  }\n\n  if( !isView ){\n    int addr1 = 0;        /* Address of jump instruction */\n\n    /* Do constraint checks. */\n    assert( regOldRowid>0 );\n    sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n        regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,\n        aXRef);\n\n    /* Do FK constraint checks. */\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);\n    }\n\n    /* Delete the index entries associated with the current record.  */\n    if( bReplace || chngKey ){\n      if( pPk ){\n        addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);\n      }else{\n        addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);\n      }\n      VdbeCoverageNeverTaken(v);\n    }\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);\n\n    /* If changing the rowid value, or if there are foreign key constraints\n    ** to process, delete the old record. Otherwise, add a noop OP_Delete\n    ** to invoke the pre-update hook.\n    **\n    ** That (regNew==regnewRowid+1) is true is also important for the \n    ** pre-update hook. If the caller invokes preupdate_new(), the returned\n    ** value is copied from memory cell (regNewRowid+1+iCol), where iCol\n    ** is the column index supplied by the user.\n    */\n    assert( regNew==regNewRowid+1 );\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    sqlite3VdbeAddOp3(v, OP_Delete, iDataCur,\n        OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP),\n        regNewRowid\n    );\n    if( eOnePass==ONEPASS_MULTI ){\n      assert( hasFK==0 && chngKey==0 );\n      sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);\n    }\n    if( !pParse->nested ){\n      sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n    }\n#else\n    if( hasFK>1 || chngKey ){\n      sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);\n    }\n#endif\n    if( bReplace || chngKey ){\n      sqlite3VdbeJumpHere(v, addr1);\n    }\n\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);\n    }\n  \n    /* Insert the new index entries and the new record. */\n    sqlite3CompleteInsertion(\n        pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, \n        OPFLAG_ISUPDATE | (eOnePass==ONEPASS_MULTI ? OPFLAG_SAVEPOSITION : 0), \n        0, 0\n    );\n\n    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n    ** handle rows (possibly in other tables) that refer via a foreign key\n    ** to the row just updated. */ \n    if( hasFK ){\n      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);\n    }\n  }\n\n  /* Increment the row counter \n  */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n      TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);\n\n  /* Repeat the above with the next record to be updated, until\n  ** all record selected by the WHERE clause have been updated.\n  */\n  if( eOnePass==ONEPASS_SINGLE ){\n    /* Nothing to do at end-of-loop for a single-pass */\n  }else if( eOnePass==ONEPASS_MULTI ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3WhereEnd(pWInfo);\n  }else if( pPk ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeGoto(v, labelContinue);\n  }\n  sqlite3VdbeResolveLabel(v, labelBreak);\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows that were changed. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows updated\", SQLITE_STATIC);\n  }\n\nupdate_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pChanges);\n  sqlite3ExprDelete(db, pWhere);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Generate code for an UPDATE of a virtual table.\n**\n** There are two possible strategies - the default and the special \n** \"onepass\" strategy. Onepass is only used if the virtual table \n** implementation indicates that pWhere may match at most one row.\n**\n** The default strategy is to create an ephemeral table that contains\n** for each row to be changed:\n**\n**   (A)  The original rowid of that row.\n**   (B)  The revised rowid for the row.\n**   (C)  The content of every column in the row.\n**\n** Then loop through the contents of this ephemeral table executing a\n** VUpdate for each row. When finished, drop the ephemeral table.\n**\n** The \"onepass\" strategy does not use an ephemeral table. Instead, it\n** stores the same values (A, B and C above) in a register array and\n** makes a single invocation of VUpdate.\n*/\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowid,        /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n){\n  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */\n  int ephemTab;             /* Table holding the result of the SELECT */\n  int i;                    /* Loop counter */\n  sqlite3 *db = pParse->db; /* Database connection */\n  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);\n  WhereInfo *pWInfo;\n  int nArg = 2 + pTab->nCol;      /* Number of arguments to VUpdate */\n  int regArg;                     /* First register in VUpdate arg array */\n  int regRec;                     /* Register in which to assemble record */\n  int regRowid;                   /* Register for ephem table rowid */\n  int iCsr = pSrc->a[0].iCursor;  /* Cursor used for virtual table scan */\n  int aDummy[2];                  /* Unused arg for sqlite3WhereOkOnePass() */\n  int bOnePass;                   /* True to use onepass strategy */\n  int addr;                       /* Address of OP_OpenEphemeral */\n\n  /* Allocate nArg registers to martial the arguments to VUpdate. Then\n  ** create and open the ephemeral table in which the records created from\n  ** these arguments will be temporarily stored. */\n  assert( v );\n  ephemTab = pParse->nTab++;\n  addr= sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, nArg);\n  regArg = pParse->nMem + 1;\n  pParse->nMem += nArg;\n  regRec = ++pParse->nMem;\n  regRowid = ++pParse->nMem;\n\n  /* Start scanning the virtual table */\n  pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);\n  if( pWInfo==0 ) return;\n\n  /* Populate the argument registers. */\n  for(i=0; i<pTab->nCol; i++){\n    if( aXRef[i]>=0 ){\n      sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);\n    }\n  }\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);\n    if( pRowid ){\n      sqlite3ExprCode(pParse, pRowid, regArg+1);\n    }else{\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg+1);\n    }\n  }else{\n    Index *pPk;   /* PRIMARY KEY index */\n    i16 iPk;      /* PRIMARY KEY column */\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->nKeyCol==1 );\n    iPk = pPk->aiColumn[0];\n    sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, iPk, regArg);\n    sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);\n  }\n\n  bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);\n\n  if( bOnePass ){\n    /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded\n    ** above. Also, if this is a top-level parse (not a trigger), clear the\n    ** multi-write flag so that the VM does not open a statement journal */\n    sqlite3VdbeChangeToNoop(v, addr);\n    if( sqlite3IsToplevel(pParse) ){\n      pParse->isMultiWrite = 0;\n    }\n  }else{\n    /* Create a record from the argument register contents and insert it into\n    ** the ephemeral table. */\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid);\n  }\n\n\n  if( bOnePass==0 ){\n    /* End the virtual table scan */\n    sqlite3WhereEnd(pWInfo);\n\n    /* Begin scannning through the ephemeral table. */\n    addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v);\n\n    /* Extract arguments from the current row of the ephemeral table and \n    ** invoke the VUpdate method.  */\n    for(i=0; i<nArg; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i, regArg+i);\n    }\n  }\n  sqlite3VtabMakeWritable(pParse, pTab);\n  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, nArg, regArg, pVTab, P4_VTAB);\n  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n  sqlite3MayAbort(pParse);\n\n  /* End of the ephemeral table scan. Or, if using the onepass strategy,\n  ** jump to here if the scan visited zero rows. */\n  if( bOnePass==0 ){\n    sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);\n  }else{\n    sqlite3WhereEnd(pWInfo);\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of update.c **********************************************/\n/************** Begin file vacuum.c ******************************************/\n/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the VACUUM command.\n**\n** Most of the code in this file may be omitted by defining the\n** SQLITE_OMIT_VACUUM macro.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"vdbeInt.h\" */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n\n/*\n** Execute zSql on database db.\n**\n** If zSql returns rows, then each row will have exactly one\n** column.  (This will only happen if zSql begins with \"SELECT\".)\n** Take each row of result and call execSql() again recursively.\n**\n** The execSqlF() routine does the same thing, except it accepts\n** a format string as its third argument\n*/\nstatic int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  /* printf(\"SQL: [%s]\\n\", zSql); fflush(stdout); */\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n    const char *zSubSql = (const char*)sqlite3_column_text(pStmt,0);\n    assert( sqlite3_strnicmp(zSql,\"SELECT\",6)==0 );\n    if( zSubSql ){\n      assert( zSubSql[0]!='S' );\n      rc = execSql(db, pzErrMsg, zSubSql);\n      if( rc!=SQLITE_OK ) break;\n    }\n  }\n  assert( rc!=SQLITE_ROW );\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  if( rc ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n  }\n  (void)sqlite3_finalize(pStmt);\n  return rc;\n}\nstatic int execSqlF(sqlite3 *db, char **pzErrMsg, const char *zSql, ...){\n  char *z;\n  va_list ap;\n  int rc;\n  va_start(ap, zSql);\n  z = sqlite3VMPrintf(db, zSql, ap);\n  va_end(ap);\n  if( z==0 ) return SQLITE_NOMEM;\n  rc = execSql(db, pzErrMsg, z);\n  sqlite3DbFree(db, z);\n  return rc;\n}\n\n/*\n** The VACUUM command is used to clean up the database,\n** collapse free space, etc.  It is modelled after the VACUUM command\n** in PostgreSQL.  The VACUUM command works as follows:\n**\n**   (1)  Create a new transient database file\n**   (2)  Copy all content from the database being vacuumed into\n**        the new transient database file\n**   (3)  Copy content from the transient database back into the\n**        original database.\n**\n** The transient database requires temporary disk space approximately\n** equal to the size of the original database.  The copy operation of\n** step (3) requires additional temporary disk space approximately equal\n** to the size of the original database for the rollback journal.\n** Hence, temporary disk space that is approximately 2x the size of the\n** original database is required.  Every page of the database is written\n** approximately 3 times:  Once for step (2) and twice for step (3).\n** Two writes per page are required in step (3) because the original\n** database content must be written into the rollback journal prior to\n** overwriting the database with the vacuumed content.\n**\n** Only 1x temporary space and only 1x writes would be required if\n** the copy of step (3) were replaced by deleting the original database\n** and renaming the transient database as the original.  But that will\n** not work if other processes are attached to the original database.\n** And a power loss in between deleting the original and renaming the\n** transient would cause the database file to appear to be deleted\n** following reboot.\n*/\nSQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int iDb = 0;\n  if( v==0 ) return;\n  if( pNm ){\n#ifndef SQLITE_BUG_COMPATIBLE_20160819\n    /* Default behavior:  Report an error if the argument to VACUUM is\n    ** not recognized */\n    iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);\n    if( iDb<0 ) return;\n#else\n    /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments\n    ** to VACUUM are silently ignored.  This is a back-out of a bug fix that\n    ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).\n    ** The buggy behavior is required for binary compatibility with some\n    ** legacy applications. */\n    iDb = sqlite3FindDb(pParse->db, pNm);\n    if( iDb<0 ) iDb = 0;\n#endif\n  }\n  if( iDb!=1 ){\n    sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);\n    sqlite3VdbeUsesBtree(v, iDb);\n  }\n  return;\n}\n\n/*\n** This routine implements the OP_Vacuum opcode of the VDBE.\n*/\nSQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){\n  int rc = SQLITE_OK;     /* Return code from service routines */\n  Btree *pMain;           /* The database being vacuumed */\n  Btree *pTemp;           /* The temporary database we vacuum into */\n  u16 saved_mDbFlags;     /* Saved value of db->mDbFlags */\n  u32 saved_flags;        /* Saved value of db->flags */\n  int saved_nChange;      /* Saved value of db->nChange */\n  int saved_nTotalChange; /* Saved value of db->nTotalChange */\n  u8 saved_mTrace;        /* Saved trace settings */\n  Db *pDb = 0;            /* Database to detach at end of vacuum */\n  int isMemDb;            /* True if vacuuming a :memory: database */\n  int nRes;               /* Bytes of reserved space at the end of each page */\n  int nDb;                /* Number of attached databases */\n  const char *zDbMain;    /* Schema name of database to vacuum */\n\n  if( !db->autoCommit ){\n    sqlite3SetString(pzErrMsg, db, \"cannot VACUUM from within a transaction\");\n    return SQLITE_ERROR;\n  }\n  if( db->nVdbeActive>1 ){\n    sqlite3SetString(pzErrMsg, db,\"cannot VACUUM - SQL statements in progress\");\n    return SQLITE_ERROR;\n  }\n\n  /* Save the current value of the database flags so that it can be \n  ** restored before returning. Then set the writable-schema flag, and\n  ** disable CHECK and foreign key constraints.  */\n  saved_flags = db->flags;\n  saved_mDbFlags = db->mDbFlags;\n  saved_nChange = db->nChange;\n  saved_nTotalChange = db->nTotalChange;\n  saved_mTrace = db->mTrace;\n  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;\n  db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;\n  db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_CountRows);\n  db->mTrace = 0;\n\n  zDbMain = db->aDb[iDb].zDbSName;\n  pMain = db->aDb[iDb].pBt;\n  isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));\n\n  /* Attach the temporary database as 'vacuum_db'. The synchronous pragma\n  ** can be set to 'off' for this file, as it is not recovered if a crash\n  ** occurs anyway. The integrity of the database is maintained by a\n  ** (possibly synchronous) transaction opened on the main database before\n  ** sqlite3BtreeCopyFile() is called.\n  **\n  ** An optimisation would be to use a non-journaled pager.\n  ** (Later:) I tried setting \"PRAGMA vacuum_db.journal_mode=OFF\" but\n  ** that actually made the VACUUM run slower.  Very little journalling\n  ** actually occurs when doing a vacuum since the vacuum_db is initially\n  ** empty.  Only the journal header is written.  Apparently it takes more\n  ** time to parse and run the PRAGMA to turn journalling off than it does\n  ** to write the journal header file.\n  */\n  nDb = db->nDb;\n  rc = execSql(db, pzErrMsg, \"ATTACH''AS vacuum_db\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  assert( (db->nDb-1)==nDb );\n  pDb = &db->aDb[nDb];\n  assert( strcmp(pDb->zDbSName,\"vacuum_db\")==0 );\n  pTemp = pDb->pBt;\n\n  /* The call to execSql() to attach the temp database has left the file\n  ** locked (as there was more than one active statement when the transaction\n  ** to read the schema was concluded. Unlock it here so that this doesn't\n  ** cause problems for the call to BtreeSetPageSize() below.  */\n  sqlite3BtreeCommit(pTemp);\n\n  nRes = sqlite3BtreeGetOptimalReserve(pMain);\n\n  /* A VACUUM cannot change the pagesize of an encrypted database. */\n#ifdef SQLITE_HAS_CODEC\n  if( db->nextPagesize ){\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey);\n    if( nKey ) db->nextPagesize = 0;\n  }\n#endif\n\n  sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);\n  sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));\n  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);\n\n  /* Begin a transaction and take an exclusive lock on the main database\n  ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,\n  ** to ensure that we do not try to change the page-size on a WAL database.\n  */\n  rc = execSql(db, pzErrMsg, \"BEGIN\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = sqlite3BtreeBeginTrans(pMain, 2);\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Do not attempt to change the page size for a WAL database */\n  if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))\n                                               ==PAGER_JOURNALMODE_WAL ){\n    db->nextPagesize = 0;\n  }\n\n  if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)\n   || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))\n   || NEVER(db->mallocFailed)\n  ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_of_vacuum;\n  }\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  sqlite3BtreeSetAutoVacuum(pTemp, db->nextAutovac>=0 ? db->nextAutovac :\n                                           sqlite3BtreeGetAutoVacuum(pMain));\n#endif\n\n  /* Query the schema of the main database. Create a mirror schema\n  ** in the temporary database.\n  */\n  db->init.iDb = nDb; /* force new CREATE statements into vacuum_db */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='table'AND name<>'sqlite_sequence'\"\n      \" AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='index' AND length(sql)>10\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  db->init.iDb = 0;\n\n  /* Loop through the tables in the main database. For each, do\n  ** an \"INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;\" to copy\n  ** the contents to the temporary database.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT'INSERT INTO vacuum_db.'||quote(name)\"\n      \"||' SELECT*FROM\\\"%w\\\".'||quote(name)\"\n      \"FROM vacuum_db.sqlite_master \"\n      \"WHERE type='table'AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  assert( (db->mDbFlags & DBFLAG_Vacuum)!=0 );\n  db->mDbFlags &= ~DBFLAG_Vacuum;\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Copy the triggers, views, and virtual tables from the main database\n  ** over to the temporary database.  None of these objects has any\n  ** associated storage, so all we have to do is copy their entries\n  ** from the SQLITE_MASTER table.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"INSERT INTO vacuum_db.sqlite_master\"\n      \" SELECT*FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type IN('view','trigger')\"\n      \" OR(type='table'AND rootpage=0)\",\n      zDbMain\n  );\n  if( rc ) goto end_of_vacuum;\n\n  /* At this point, there is a write transaction open on both the \n  ** vacuum database and the main database. Assuming no error occurs,\n  ** both transactions are closed by this block - the main database\n  ** transaction by sqlite3BtreeCopyFile() and the other by an explicit\n  ** call to sqlite3BtreeCommit().\n  */\n  {\n    u32 meta;\n    int i;\n\n    /* This array determines which meta meta values are preserved in the\n    ** vacuum.  Even entries are the meta value number and odd entries\n    ** are an increment to apply to the meta value after the vacuum.\n    ** The increment is used to increase the schema cookie so that other\n    ** connections to the same database will know to reread the schema.\n    */\n    static const unsigned char aCopy[] = {\n       BTREE_SCHEMA_VERSION,     1,  /* Add one to the old schema cookie */\n       BTREE_DEFAULT_CACHE_SIZE, 0,  /* Preserve the default page cache size */\n       BTREE_TEXT_ENCODING,      0,  /* Preserve the text encoding */\n       BTREE_USER_VERSION,       0,  /* Preserve the user version */\n       BTREE_APPLICATION_ID,     0,  /* Preserve the application id */\n    };\n\n    assert( 1==sqlite3BtreeIsInTrans(pTemp) );\n    assert( 1==sqlite3BtreeIsInTrans(pMain) );\n\n    /* Copy Btree meta values */\n    for(i=0; i<ArraySize(aCopy); i+=2){\n      /* GetMeta() and UpdateMeta() cannot fail in this context because\n      ** we already have page 1 loaded into cache and marked dirty. */\n      sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);\n      rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);\n      if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;\n    }\n\n    rc = sqlite3BtreeCopyFile(pMain, pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n    rc = sqlite3BtreeCommit(pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));\n#endif\n  }\n\n  assert( rc==SQLITE_OK );\n  rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);\n\nend_of_vacuum:\n  /* Restore the original value of db->flags */\n  db->init.iDb = 0;\n  db->mDbFlags = saved_mDbFlags;\n  db->flags = saved_flags;\n  db->nChange = saved_nChange;\n  db->nTotalChange = saved_nTotalChange;\n  db->mTrace = saved_mTrace;\n  sqlite3BtreeSetPageSize(pMain, -1, -1, 1);\n\n  /* Currently there is an SQL level transaction open on the vacuum\n  ** database. No locks are held on any other files (since the main file\n  ** was committed at the btree level). So it safe to end the transaction\n  ** by manually setting the autoCommit flag to true and detaching the\n  ** vacuum database. The vacuum_db journal file is deleted when the pager\n  ** is closed by the DETACH.\n  */\n  db->autoCommit = 1;\n\n  if( pDb ){\n    sqlite3BtreeClose(pDb->pBt);\n    pDb->pBt = 0;\n    pDb->pSchema = 0;\n  }\n\n  /* This both clears the schemas and reduces the size of the db->aDb[]\n  ** array. */ \n  sqlite3ResetAllSchemasOfConnection(db);\n\n  return rc;\n}\n\n#endif  /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */\n\n/************** End of vacuum.c **********************************************/\n/************** Begin file vtab.c ********************************************/\n/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to help implement virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* #include \"sqliteInt.h\" */\n\n/*\n** Before a virtual table xCreate() or xConnect() method is invoked, the\n** sqlite3.pVtabCtx member variable is set to point to an instance of\n** this struct allocated on the stack. It is used by the implementation of \n** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which\n** are invoked only from within xCreate and xConnect methods.\n*/\nstruct VtabCtx {\n  VTable *pVTable;    /* The virtual table being constructed */\n  Table *pTab;        /* The Table object to which the virtual table belongs */\n  VtabCtx *pPrior;    /* Parent context (if any) */\n  int bDeclared;      /* True after sqlite3_declare_vtab() is called */\n};\n\n/*\n** Construct and install a Module object for a virtual table.  When this\n** routine is called, it is guaranteed that all appropriate locks are held\n** and the module is not already part of the connection.\n*/\nSQLITE_PRIVATE Module *sqlite3VtabCreateModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  Module *pMod;\n  int nName = sqlite3Strlen30(zName);\n  pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);\n  if( pMod==0 ){\n    sqlite3OomFault(db);\n  }else{\n    Module *pDel;\n    char *zCopy = (char *)(&pMod[1]);\n    memcpy(zCopy, zName, nName+1);\n    pMod->zName = zCopy;\n    pMod->pModule = pModule;\n    pMod->pAux = pAux;\n    pMod->xDestroy = xDestroy;\n    pMod->pEpoTab = 0;\n    pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);\n    assert( pDel==0 || pDel==pMod );\n    if( pDel ){\n      sqlite3OomFault(db);\n      sqlite3DbFree(db, pDel);\n      pMod = 0;\n    }\n  }\n  return pMod;\n}\n\n/*\n** The actual function that does the work of creating a new module.\n** This function implements the sqlite3_create_module() and\n** sqlite3_create_module_v2() interfaces.\n*/\nstatic int createModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3HashFind(&db->aModule, zName) ){\n    rc = SQLITE_MISUSE_BKPT;\n  }else{\n    (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux                      /* Context pointer for xCreate/xConnect */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, 0);\n}\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, xDestroy);\n}\n\n/*\n** Lock the virtual table so that it cannot be disconnected.\n** Locks nest.  Every lock should have a corresponding unlock.\n** If an unlock is omitted, resources leaks will occur.  \n**\n** If a disconnect is attempted while a virtual table is locked,\n** the disconnect is deferred until all locks have been removed.\n*/\nSQLITE_PRIVATE void sqlite3VtabLock(VTable *pVTab){\n  pVTab->nRef++;\n}\n\n\n/*\n** pTab is a pointer to a Table structure representing a virtual-table.\n** Return a pointer to the VTable object used by connection db to access \n** this virtual-table, if one has been created, or NULL otherwise.\n*/\nSQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){\n  VTable *pVtab;\n  assert( IsVirtual(pTab) );\n  for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);\n  return pVtab;\n}\n\n/*\n** Decrement the ref-count on a virtual table object. When the ref-count\n** reaches zero, call the xDisconnect() method to delete the object.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlock(VTable *pVTab){\n  sqlite3 *db = pVTab->db;\n\n  assert( db );\n  assert( pVTab->nRef>0 );\n  assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );\n\n  pVTab->nRef--;\n  if( pVTab->nRef==0 ){\n    sqlite3_vtab *p = pVTab->pVtab;\n    if( p ){\n      p->pModule->xDisconnect(p);\n    }\n    sqlite3DbFree(db, pVTab);\n  }\n}\n\n/*\n** Table p is a virtual table. This function moves all elements in the\n** p->pVTable list to the sqlite3.pDisconnect lists of their associated\n** database connections to be disconnected at the next opportunity. \n** Except, if argument db is not NULL, then the entry associated with\n** connection db is left in the p->pVTable list.\n*/\nstatic VTable *vtabDisconnectAll(sqlite3 *db, Table *p){\n  VTable *pRet = 0;\n  VTable *pVTable = p->pVTable;\n  p->pVTable = 0;\n\n  /* Assert that the mutex (if any) associated with the BtShared database \n  ** that contains table p is held by the caller. See header comments \n  ** above function sqlite3VtabUnlockList() for an explanation of why\n  ** this makes it safe to access the sqlite3.pDisconnect list of any\n  ** database connection that may have an entry in the p->pVTable list.\n  */\n  assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n\n  while( pVTable ){\n    sqlite3 *db2 = pVTable->db;\n    VTable *pNext = pVTable->pNext;\n    assert( db2 );\n    if( db2==db ){\n      pRet = pVTable;\n      p->pVTable = pRet;\n      pRet->pNext = 0;\n    }else{\n      pVTable->pNext = db2->pDisconnect;\n      db2->pDisconnect = pVTable;\n    }\n    pVTable = pNext;\n  }\n\n  assert( !db || pRet );\n  return pRet;\n}\n\n/*\n** Table *p is a virtual table. This function removes the VTable object\n** for table *p associated with database connection db from the linked\n** list in p->pVTab. It also decrements the VTable ref count. This is\n** used when closing database connection db to free all of its VTable\n** objects without disturbing the rest of the Schema object (which may\n** be being used by other shared-cache connections).\n*/\nSQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){\n  VTable **ppVTab;\n\n  assert( IsVirtual(p) );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){\n    if( (*ppVTab)->db==db  ){\n      VTable *pVTab = *ppVTab;\n      *ppVTab = pVTab->pNext;\n      sqlite3VtabUnlock(pVTab);\n      break;\n    }\n  }\n}\n\n\n/*\n** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.\n**\n** This function may only be called when the mutexes associated with all\n** shared b-tree databases opened using connection db are held by the \n** caller. This is done to protect the sqlite3.pDisconnect list. The\n** sqlite3.pDisconnect list is accessed only as follows:\n**\n**   1) By this function. In this case, all BtShared mutexes and the mutex\n**      associated with the database handle itself must be held.\n**\n**   2) By function vtabDisconnectAll(), when it adds a VTable entry to\n**      the sqlite3.pDisconnect list. In this case either the BtShared mutex\n**      associated with the database the virtual table is stored in is held\n**      or, if the virtual table is stored in a non-sharable database, then\n**      the database handle mutex is held.\n**\n** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously \n** by multiple threads. It is thread-safe.\n*/\nSQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){\n  VTable *p = db->pDisconnect;\n  db->pDisconnect = 0;\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  if( p ){\n    sqlite3ExpirePreparedStatements(db);\n    do {\n      VTable *pNext = p->pNext;\n      sqlite3VtabUnlock(p);\n      p = pNext;\n    }while( p );\n  }\n}\n\n/*\n** Clear any and all virtual-table information from the Table record.\n** This routine is called, for example, just before deleting the Table\n** record.\n**\n** Since it is a virtual-table, the Table structure contains a pointer\n** to the head of a linked list of VTable structures. Each VTable \n** structure is associated with a single sqlite3* user of the schema.\n** The reference count of the VTable structure associated with database \n** connection db is decremented immediately (which may lead to the \n** structure being xDisconnected and free). Any other VTable structures\n** in the list are moved to the sqlite3.pDisconnect list of the associated \n** database connection.\n*/\nSQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){\n  if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);\n  if( p->azModuleArg ){\n    int i;\n    for(i=0; i<p->nModuleArg; i++){\n      if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);\n    }\n    sqlite3DbFree(db, p->azModuleArg);\n  }\n}\n\n/*\n** Add a new module argument to pTable->azModuleArg[].\n** The string is not copied - the pointer is stored.  The\n** string will be freed automatically when the table is\n** deleted.\n*/\nstatic void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){\n  int nBytes = sizeof(char *)*(2+pTable->nModuleArg);\n  char **azModuleArg;\n  azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);\n  if( azModuleArg==0 ){\n    sqlite3DbFree(db, zArg);\n  }else{\n    int i = pTable->nModuleArg++;\n    azModuleArg[i] = zArg;\n    azModuleArg[i+1] = 0;\n    pTable->azModuleArg = azModuleArg;\n  }\n}\n\n/*\n** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE\n** statement.  The module name has been parsed, but the optional list\n** of parameters that follow the module name are still pending.\n*/\nSQLITE_PRIVATE void sqlite3VtabBeginParse(\n  Parse *pParse,        /* Parsing context */\n  Token *pName1,        /* Name of new table, or database name */\n  Token *pName2,        /* Name of new table or NULL */\n  Token *pModuleName,   /* Name of the module for the virtual table */\n  int ifNotExists       /* No error if the table already exists */\n){\n  int iDb;              /* The database the table is being created in */\n  Table *pTable;        /* The new virtual table */\n  sqlite3 *db;          /* Database connection */\n\n  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);\n  pTable = pParse->pNewTable;\n  if( pTable==0 ) return;\n  assert( 0==pTable->pIndex );\n\n  db = pParse->db;\n  iDb = sqlite3SchemaToIndex(db, pTable->pSchema);\n  assert( iDb>=0 );\n\n  assert( pTable->nModuleArg==0 );\n  addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));\n  addModuleArgument(db, pTable, 0);\n  addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));\n  assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)\n       || (pParse->sNameToken.z==pName1->z && pName2->z==0)\n  );\n  pParse->sNameToken.n = (int)(\n      &pModuleName->z[pModuleName->n] - pParse->sNameToken.z\n  );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Creating a virtual table invokes the authorization callback twice.\n  ** The first invocation, to obtain permission to INSERT a row into the\n  ** sqlite_master table, has already been made by sqlite3StartTable().\n  ** The second call, to obtain permission to create the table, is made now.\n  */\n  if( pTable->azModuleArg ){\n    sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, \n            pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);\n  }\n#endif\n}\n\n/*\n** This routine takes the module argument that has been accumulating\n** in pParse->zArg[] and appends it to the list of arguments on the\n** virtual table currently under construction in pParse->pTable.\n*/\nstatic void addArgumentToVtab(Parse *pParse){\n  if( pParse->sArg.z && pParse->pNewTable ){\n    const char *z = (const char*)pParse->sArg.z;\n    int n = pParse->sArg.n;\n    sqlite3 *db = pParse->db;\n    addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n));\n  }\n}\n\n/*\n** The parser calls this routine after the CREATE VIRTUAL TABLE statement\n** has been completely parsed.\n*/\nSQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){\n  Table *pTab = pParse->pNewTable;  /* The table being constructed */\n  sqlite3 *db = pParse->db;         /* The database connection */\n\n  if( pTab==0 ) return;\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  if( pTab->nModuleArg<1 ) return;\n  \n  /* If the CREATE VIRTUAL TABLE statement is being entered for the\n  ** first time (in other words if the virtual table is actually being\n  ** created now instead of just being read out of sqlite_master) then\n  ** do additional initialization work and store the statement text\n  ** in the sqlite_master table.\n  */\n  if( !db->init.busy ){\n    char *zStmt;\n    char *zWhere;\n    int iDb;\n    int iReg;\n    Vdbe *v;\n\n    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */\n    if( pEnd ){\n      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;\n    }\n    zStmt = sqlite3MPrintf(db, \"CREATE VIRTUAL TABLE %T\", &pParse->sNameToken);\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.  \n    **\n    ** The VM register number pParse->regRowid holds the rowid of an\n    ** entry in the sqlite_master table tht was created for this vtab\n    ** by sqlite3StartTable().\n    */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      pTab->zName,\n      pTab->zName,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    v = sqlite3GetVdbe(pParse);\n    sqlite3ChangeCookie(pParse, iDb);\n\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    zWhere = sqlite3MPrintf(db, \"name='%q' AND type='table'\", pTab->zName);\n    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n    iReg = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, iReg, pTab->zName);\n    sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);\n  }\n\n  /* If we are rereading the sqlite_master table create the in-memory\n  ** record of the table. The xConnect() method is not called until\n  ** the first time the virtual table is used in an SQL statement. This\n  ** allows a schema that contains virtual tables to be loaded before\n  ** the required virtual table implementations are registered.  */\n  else {\n    Table *pOld;\n    Schema *pSchema = pTab->pSchema;\n    const char *zName = pTab->zName;\n    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab);\n    if( pOld ){\n      sqlite3OomFault(db);\n      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */\n      return;\n    }\n    pParse->pNewTable = 0;\n  }\n}\n\n/*\n** The parser calls this routine when it sees the first token\n** of an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgInit(Parse *pParse){\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  pParse->sArg.n = 0;\n}\n\n/*\n** The parser calls this routine for each token after the first token\n** in an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nSQLITE_PRIVATE void sqlite3VtabArgExtend(Parse *pParse, Token *p){\n  Token *pArg = &pParse->sArg;\n  if( pArg->z==0 ){\n    pArg->z = p->z;\n    pArg->n = p->n;\n  }else{\n    assert(pArg->z <= p->z);\n    pArg->n = (int)(&p->z[p->n] - pArg->z);\n  }\n}\n\n/*\n** Invoke a virtual table constructor (either xCreate or xConnect). The\n** pointer to the function to invoke is passed as the fourth parameter\n** to this procedure.\n*/\nstatic int vtabCallConstructor(\n  sqlite3 *db, \n  Table *pTab,\n  Module *pMod,\n  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),\n  char **pzErr\n){\n  VtabCtx sCtx;\n  VTable *pVTable;\n  int rc;\n  const char *const*azArg = (const char *const*)pTab->azModuleArg;\n  int nArg = pTab->nModuleArg;\n  char *zErr = 0;\n  char *zModuleName;\n  int iDb;\n  VtabCtx *pCtx;\n\n  /* Check that the virtual-table is not already being initialized */\n  for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){\n    if( pCtx->pTab==pTab ){\n      *pzErr = sqlite3MPrintf(db, \n          \"vtable constructor called recursively: %s\", pTab->zName\n      );\n      return SQLITE_LOCKED;\n    }\n  }\n\n  zModuleName = sqlite3DbStrDup(db, pTab->zName);\n  if( !zModuleName ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pVTable = sqlite3MallocZero(sizeof(VTable));\n  if( !pVTable ){\n    sqlite3OomFault(db);\n    sqlite3DbFree(db, zModuleName);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pVTable->db = db;\n  pVTable->pMod = pMod;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;\n\n  /* Invoke the virtual table constructor */\n  assert( &db->pVtabCtx );\n  assert( xConstruct );\n  sCtx.pTab = pTab;\n  sCtx.pVTable = pVTable;\n  sCtx.pPrior = db->pVtabCtx;\n  sCtx.bDeclared = 0;\n  db->pVtabCtx = &sCtx;\n  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);\n  db->pVtabCtx = sCtx.pPrior;\n  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n  assert( sCtx.pTab==pTab );\n\n  if( SQLITE_OK!=rc ){\n    if( zErr==0 ){\n      *pzErr = sqlite3MPrintf(db, \"vtable constructor failed: %s\", zModuleName);\n    }else {\n      *pzErr = sqlite3MPrintf(db, \"%s\", zErr);\n      sqlite3_free(zErr);\n    }\n    sqlite3DbFree(db, pVTable);\n  }else if( ALWAYS(pVTable->pVtab) ){\n    /* Justification of ALWAYS():  A correct vtab constructor must allocate\n    ** the sqlite3_vtab object if successful.  */\n    memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));\n    pVTable->pVtab->pModule = pMod->pModule;\n    pVTable->nRef = 1;\n    if( sCtx.bDeclared==0 ){\n      const char *zFormat = \"vtable constructor did not declare schema: %s\";\n      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);\n      sqlite3VtabUnlock(pVTable);\n      rc = SQLITE_ERROR;\n    }else{\n      int iCol;\n      u8 oooHidden = 0;\n      /* If everything went according to plan, link the new VTable structure\n      ** into the linked list headed by pTab->pVTable. Then loop through the \n      ** columns of the table to see if any of them contain the token \"hidden\".\n      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from\n      ** the type string.  */\n      pVTable->pNext = pTab->pVTable;\n      pTab->pVTable = pVTable;\n\n      for(iCol=0; iCol<pTab->nCol; iCol++){\n        char *zType = sqlite3ColumnType(&pTab->aCol[iCol], \"\");\n        int nType;\n        int i = 0;\n        nType = sqlite3Strlen30(zType);\n        for(i=0; i<nType; i++){\n          if( 0==sqlite3StrNICmp(\"hidden\", &zType[i], 6)\n           && (i==0 || zType[i-1]==' ')\n           && (zType[i+6]=='\\0' || zType[i+6]==' ')\n          ){\n            break;\n          }\n        }\n        if( i<nType ){\n          int j;\n          int nDel = 6 + (zType[i+6] ? 1 : 0);\n          for(j=i; (j+nDel)<=nType; j++){\n            zType[j] = zType[j+nDel];\n          }\n          if( zType[i]=='\\0' && i>0 ){\n            assert(zType[i-1]==' ');\n            zType[i-1] = '\\0';\n          }\n          pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;\n          oooHidden = TF_OOOHidden;\n        }else{\n          pTab->tabFlags |= oooHidden;\n        }\n      }\n    }\n  }\n\n  sqlite3DbFree(db, zModuleName);\n  return rc;\n}\n\n/*\n** This function is invoked by the parser to call the xConnect() method\n** of the virtual table pTab. If an error occurs, an error code is returned \n** and an error left in pParse.\n**\n** This call is a no-op if table pTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){\n  sqlite3 *db = pParse->db;\n  const char *zMod;\n  Module *pMod;\n  int rc;\n\n  assert( pTab );\n  if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){\n    return SQLITE_OK;\n  }\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  if( !pMod ){\n    const char *zModule = pTab->azModuleArg[0];\n    sqlite3ErrorMsg(pParse, \"no such module: %s\", zModule);\n    rc = SQLITE_ERROR;\n  }else{\n    char *zErr = 0;\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"%s\", zErr);\n      pParse->rc = rc;\n    }\n    sqlite3DbFree(db, zErr);\n  }\n\n  return rc;\n}\n/*\n** Grow the db->aVTrans[] array so that there is room for at least one\n** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.\n*/\nstatic int growVTrans(sqlite3 *db){\n  const int ARRAY_INCR = 5;\n\n  /* Grow the sqlite3.aVTrans array if required */\n  if( (db->nVTrans%ARRAY_INCR)==0 ){\n    VTable **aVTrans;\n    int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);\n    aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);\n    if( !aVTrans ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);\n    db->aVTrans = aVTrans;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should\n** have already been reserved using growVTrans().\n*/\nstatic void addToVTrans(sqlite3 *db, VTable *pVTab){\n  /* Add pVtab to the end of sqlite3.aVTrans */\n  db->aVTrans[db->nVTrans++] = pVTab;\n  sqlite3VtabLock(pVTab);\n}\n\n/*\n** This function is invoked by the vdbe to call the xCreate method\n** of the virtual table named zTab in database iDb. \n**\n** If an error occurs, *pzErr is set to point to an English language\n** description of the error and an SQLITE_XXX error code is returned.\n** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){\n  int rc = SQLITE_OK;\n  Table *pTab;\n  Module *pMod;\n  const char *zMod;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  assert( pTab && IsVirtual(pTab) && !pTab->pVTable );\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  /* If the module has been registered and includes a Create method, \n  ** invoke it now. If the module has not been registered, return an \n  ** error. Otherwise, do nothing.\n  */\n  if( pMod==0 || pMod->pModule->xCreate==0 || pMod->pModule->xDestroy==0 ){\n    *pzErr = sqlite3MPrintf(db, \"no such module: %s\", zMod);\n    rc = SQLITE_ERROR;\n  }else{\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);\n  }\n\n  /* Justification of ALWAYS():  The xConstructor method is required to\n  ** create a valid sqlite3_vtab if it returns SQLITE_OK. */\n  if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      addToVTrans(db, sqlite3GetVTable(db, pTab));\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to set the schema of a virtual table.  It is only\n** valid to call this function from within the xCreate() or xConnect() of a\n** virtual table module.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){\n  VtabCtx *pCtx;\n  int rc = SQLITE_OK;\n  Table *pTab;\n  char *zErr = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pCtx = db->pVtabCtx;\n  if( !pCtx || pCtx->bDeclared ){\n    sqlite3Error(db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_MISUSE_BKPT;\n  }\n  pTab = pCtx->pTab;\n  assert( IsVirtual(pTab) );\n\n  memset(&sParse, 0, sizeof(sParse));\n  sParse.declareVtab = 1;\n  sParse.db = db;\n  sParse.nQueryLoop = 1;\n  if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr) \n   && sParse.pNewTable\n   && !db->mallocFailed\n   && !sParse.pNewTable->pSelect\n   && !IsVirtual(sParse.pNewTable)\n  ){\n    if( !pTab->aCol ){\n      Table *pNew = sParse.pNewTable;\n      Index *pIdx;\n      pTab->aCol = pNew->aCol;\n      pTab->nCol = pNew->nCol;\n      pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);\n      pNew->nCol = 0;\n      pNew->aCol = 0;\n      assert( pTab->pIndex==0 );\n      assert( HasRowid(pNew) || sqlite3PrimaryKeyIndex(pNew)!=0 );\n      if( !HasRowid(pNew)\n       && pCtx->pVTable->pMod->pModule->xUpdate!=0\n       && sqlite3PrimaryKeyIndex(pNew)->nKeyCol!=1\n      ){\n        /* WITHOUT ROWID virtual tables must either be read-only (xUpdate==0)\n        ** or else must have a single-column PRIMARY KEY */\n        rc = SQLITE_ERROR;\n      }\n      pIdx = pNew->pIndex;\n      if( pIdx ){\n        assert( pIdx->pNext==0 );\n        pTab->pIndex = pIdx;\n        pNew->pIndex = 0;\n        pIdx->pTable = pTab;\n      }\n    }\n    pCtx->bDeclared = 1;\n  }else{\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? \"%s\" : 0), zErr);\n    sqlite3DbFree(db, zErr);\n    rc = SQLITE_ERROR;\n  }\n  sParse.declareVtab = 0;\n\n  if( sParse.pVdbe ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n  }\n  sqlite3DeleteTable(db, sParse.pNewTable);\n  sqlite3ParserReset(&sParse);\n\n  assert( (rc&0xff)==rc );\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is invoked by the vdbe to call the xDestroy method\n** of the virtual table named zTab in database iDb. This occurs\n** when a DROP TABLE is mentioned.\n**\n** This call is a no-op if zTab is not a virtual table.\n*/\nSQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){\n  int rc = SQLITE_OK;\n  Table *pTab;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){\n    VTable *p;\n    int (*xDestroy)(sqlite3_vtab *);\n    for(p=pTab->pVTable; p; p=p->pNext){\n      assert( p->pVtab );\n      if( p->pVtab->nRef>0 ){\n        return SQLITE_LOCKED;\n      }\n    }\n    p = vtabDisconnectAll(db, pTab);\n    xDestroy = p->pMod->pModule->xDestroy;\n    assert( xDestroy!=0 );  /* Checked before the virtual table is created */\n    rc = xDestroy(p->pVtab);\n    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */\n    if( rc==SQLITE_OK ){\n      assert( pTab->pVTable==p && p->pNext==0 );\n      p->pVtab = 0;\n      pTab->pVTable = 0;\n      sqlite3VtabUnlock(p);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function invokes either the xRollback or xCommit method\n** of each of the virtual tables in the sqlite3.aVTrans array. The method\n** called is identified by the second argument, \"offset\", which is\n** the offset of the method to call in the sqlite3_module structure.\n**\n** The array is cleared after invoking the callbacks. \n*/\nstatic void callFinaliser(sqlite3 *db, int offset){\n  int i;\n  if( db->aVTrans ){\n    VTable **aVTrans = db->aVTrans;\n    db->aVTrans = 0;\n    for(i=0; i<db->nVTrans; i++){\n      VTable *pVTab = aVTrans[i];\n      sqlite3_vtab *p = pVTab->pVtab;\n      if( p ){\n        int (*x)(sqlite3_vtab *);\n        x = *(int (**)(sqlite3_vtab *))((char *)p->pModule + offset);\n        if( x ) x(p);\n      }\n      pVTab->iSavepoint = 0;\n      sqlite3VtabUnlock(pVTab);\n    }\n    sqlite3DbFree(db, aVTrans);\n    db->nVTrans = 0;\n  }\n}\n\n/*\n** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans\n** array. Return the error code for the first error that occurs, or\n** SQLITE_OK if all xSync operations are successful.\n**\n** If an error message is available, leave it in p->zErrMsg.\n*/\nSQLITE_PRIVATE int sqlite3VtabSync(sqlite3 *db, Vdbe *p){\n  int i;\n  int rc = SQLITE_OK;\n  VTable **aVTrans = db->aVTrans;\n\n  db->aVTrans = 0;\n  for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n    int (*x)(sqlite3_vtab *);\n    sqlite3_vtab *pVtab = aVTrans[i]->pVtab;\n    if( pVtab && (x = pVtab->pModule->xSync)!=0 ){\n      rc = x(pVtab);\n      sqlite3VtabImportErrmsg(p, pVtab);\n    }\n  }\n  db->aVTrans = aVTrans;\n  return rc;\n}\n\n/*\n** Invoke the xRollback method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabRollback(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xRollback));\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xCommit method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nSQLITE_PRIVATE int sqlite3VtabCommit(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xCommit));\n  return SQLITE_OK;\n}\n\n/*\n** If the virtual table pVtab supports the transaction interface\n** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is\n** not currently open, invoke the xBegin method now.\n**\n** If the xBegin call is successful, place the sqlite3_vtab pointer\n** in the sqlite3.aVTrans array.\n*/\nSQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){\n  int rc = SQLITE_OK;\n  const sqlite3_module *pModule;\n\n  /* Special case: If db->aVTrans is NULL and db->nVTrans is greater\n  ** than zero, then this function is being called from within a\n  ** virtual module xSync() callback. It is illegal to write to \n  ** virtual module tables in this case, so return SQLITE_LOCKED.\n  */\n  if( sqlite3VtabInSync(db) ){\n    return SQLITE_LOCKED;\n  }\n  if( !pVTab ){\n    return SQLITE_OK;\n  } \n  pModule = pVTab->pVtab->pModule;\n\n  if( pModule->xBegin ){\n    int i;\n\n    /* If pVtab is already in the aVTrans array, return early */\n    for(i=0; i<db->nVTrans; i++){\n      if( db->aVTrans[i]==pVTab ){\n        return SQLITE_OK;\n      }\n    }\n\n    /* Invoke the xBegin method. If successful, add the vtab to the \n    ** sqlite3.aVTrans[] array. */\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      rc = pModule->xBegin(pVTab->pVtab);\n      if( rc==SQLITE_OK ){\n        int iSvpt = db->nStatement + db->nSavepoint;\n        addToVTrans(db, pVTab);\n        if( iSvpt && pModule->xSavepoint ){\n          pVTab->iSavepoint = iSvpt;\n          rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke either the xSavepoint, xRollbackTo or xRelease method of all\n** virtual tables that currently have an open transaction. Pass iSavepoint\n** as the second argument to the virtual table method invoked.\n**\n** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is\n** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is \n** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with\n** an open transaction is invoked.\n**\n** If any virtual table method returns an error code other than SQLITE_OK, \n** processing is abandoned and the error returned to the caller of this\n** function immediately. If all calls to virtual table methods are successful,\n** SQLITE_OK is returned.\n*/\nSQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n\n  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );\n  assert( iSavepoint>=-1 );\n  if( db->aVTrans ){\n    int i;\n    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n      VTable *pVTab = db->aVTrans[i];\n      const sqlite3_module *pMod = pVTab->pMod->pModule;\n      if( pVTab->pVtab && pMod->iVersion>=2 ){\n        int (*xMethod)(sqlite3_vtab *, int);\n        switch( op ){\n          case SAVEPOINT_BEGIN:\n            xMethod = pMod->xSavepoint;\n            pVTab->iSavepoint = iSavepoint+1;\n            break;\n          case SAVEPOINT_ROLLBACK:\n            xMethod = pMod->xRollbackTo;\n            break;\n          default:\n            xMethod = pMod->xRelease;\n            break;\n        }\n        if( xMethod && pVTab->iSavepoint>iSavepoint ){\n          rc = xMethod(pVTab->pVtab, iSavepoint);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The first parameter (pDef) is a function implementation.  The\n** second parameter (pExpr) is the first argument to this function.\n** If pExpr is a column in a virtual table, then let the virtual\n** table implementation have an opportunity to overload the function.\n**\n** This routine is used to allow virtual table implementations to\n** overload MATCH, LIKE, GLOB, and REGEXP operators.\n**\n** Return either the pDef argument (indicating no change) or a \n** new FuncDef structure that is marked as ephemeral using the\n** SQLITE_FUNC_EPHEM flag.\n*/\nSQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(\n  sqlite3 *db,    /* Database connection for reporting malloc problems */\n  FuncDef *pDef,  /* Function to possibly overload */\n  int nArg,       /* Number of arguments to the function */\n  Expr *pExpr     /* First argument to the function */\n){\n  Table *pTab;\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pMod;\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0;\n  void *pArg = 0;\n  FuncDef *pNew;\n  int rc = 0;\n  char *zLowerName;\n  unsigned char *z;\n\n\n  /* Check to see the left operand is a column in a virtual table */\n  if( NEVER(pExpr==0) ) return pDef;\n  if( pExpr->op!=TK_COLUMN ) return pDef;\n  pTab = pExpr->pTab;\n  if( pTab==0 ) return pDef;\n  if( !IsVirtual(pTab) ) return pDef;\n  pVtab = sqlite3GetVTable(db, pTab)->pVtab;\n  assert( pVtab!=0 );\n  assert( pVtab->pModule!=0 );\n  pMod = (sqlite3_module *)pVtab->pModule;\n  if( pMod->xFindFunction==0 ) return pDef;\n \n  /* Call the xFindFunction method on the virtual table implementation\n  ** to see if the implementation wants to overload this function \n  */\n  zLowerName = sqlite3DbStrDup(db, pDef->zName);\n  if( zLowerName ){\n    for(z=(unsigned char*)zLowerName; *z; z++){\n      *z = sqlite3UpperToLower[*z];\n    }\n    rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg);\n    sqlite3DbFree(db, zLowerName);\n  }\n  if( rc==0 ){\n    return pDef;\n  }\n\n  /* Create a new ephemeral function definition for the overloaded\n  ** function */\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)\n                             + sqlite3Strlen30(pDef->zName) + 1);\n  if( pNew==0 ){\n    return pDef;\n  }\n  *pNew = *pDef;\n  pNew->zName = (const char*)&pNew[1];\n  memcpy((char*)&pNew[1], pDef->zName, sqlite3Strlen30(pDef->zName)+1);\n  pNew->xSFunc = xSFunc;\n  pNew->pUserData = pArg;\n  pNew->funcFlags |= SQLITE_FUNC_EPHEM;\n  return pNew;\n}\n\n/*\n** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]\n** array so that an OP_VBegin will get generated for it.  Add pTab to the\n** array if it is missing.  If pTab is already in the array, this routine\n** is a no-op.\n*/\nSQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i, n;\n  Table **apVtabLock;\n\n  assert( IsVirtual(pTab) );\n  for(i=0; i<pToplevel->nVtabLock; i++){\n    if( pTab==pToplevel->apVtabLock[i] ) return;\n  }\n  n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);\n  apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);\n  if( apVtabLock ){\n    pToplevel->apVtabLock = apVtabLock;\n    pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;\n  }else{\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Check to see if virtual table module pMod can be have an eponymous\n** virtual table instance.  If it can, create one if one does not already\n** exist. Return non-zero if the eponymous virtual table instance exists\n** when this routine returns, and return zero if it does not exist.\n**\n** An eponymous virtual table instance is one that is named after its\n** module, and more importantly, does not require a CREATE VIRTUAL TABLE\n** statement in order to come into existance.  Eponymous virtual table\n** instances always exist.  They cannot be DROP-ed.\n**\n** Any virtual table module for which xConnect and xCreate are the same\n** method can have an eponymous virtual table instance.\n*/\nSQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){\n  const sqlite3_module *pModule = pMod->pModule;\n  Table *pTab;\n  char *zErr = 0;\n  int rc;\n  sqlite3 *db = pParse->db;\n  if( pMod->pEpoTab ) return 1;\n  if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTab==0 ) return 0;\n  pTab->zName = sqlite3DbStrDup(db, pMod->zName);\n  if( pTab->zName==0 ){\n    sqlite3DbFree(db, pTab);\n    return 0;\n  }\n  pMod->pEpoTab = pTab;\n  pTab->nTabRef = 1;\n  pTab->pSchema = db->aDb[0].pSchema;\n  assert( pTab->nModuleArg==0 );\n  pTab->iPKey = -1;\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  addModuleArgument(db, pTab, 0);\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);\n  if( rc ){\n    sqlite3ErrorMsg(pParse, \"%s\", zErr);\n    sqlite3DbFree(db, zErr);\n    sqlite3VtabEponymousTableClear(db, pMod);\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Erase the eponymous virtual table instance associated with\n** virtual table module pMod, if it exists.\n*/\nSQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){\n  Table *pTab = pMod->pEpoTab;\n  if( pTab!=0 ){\n    /* Mark the table as Ephemeral prior to deleting it, so that the\n    ** sqlite3DeleteTable() routine will know that it is not stored in \n    ** the schema. */\n    pTab->tabFlags |= TF_Ephemeral;\n    sqlite3DeleteTable(db, pTab);\n    pMod->pEpoTab = 0;\n  }\n}\n\n/*\n** Return the ON CONFLICT resolution mode in effect for the virtual\n** table update operation currently in progress.\n**\n** The results of this routine are undefined unless it is called from\n** within an xUpdate method.\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){\n  static const unsigned char aMap[] = { \n    SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE \n  };\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 );\n  assert( OE_Ignore==4 && OE_Replace==5 );\n  assert( db->vtabOnConflict>=1 && db->vtabOnConflict<=5 );\n  return (int)aMap[db->vtabOnConflict-1];\n}\n\n/*\n** Call from within the xCreate() or xConnect() methods to provide \n** the SQLite core with additional information about the behavior\n** of the virtual table being implemented.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_VTAB_CONSTRAINT_SUPPORT: {\n      VtabCtx *p = db->pVtabCtx;\n      if( !p ){\n        rc = SQLITE_MISUSE_BKPT;\n      }else{\n        assert( p->pTab==0 || IsVirtual(p->pTab) );\n        p->pVTable->bConstraint = (u8)va_arg(ap, int);\n      }\n      break;\n    }\n    default:\n      rc = SQLITE_MISUSE_BKPT;\n      break;\n  }\n  va_end(ap);\n\n  if( rc!=SQLITE_OK ) sqlite3Error(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/************** End of vtab.c ************************************************/\n/************** Begin file wherecode.c ***************************************/\n/*\n** 2015-06-06\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was split off from where.c on 2015-06-06 in order to reduce the\n** size of where.c and make it easier to edit.  This file contains the routines\n** that actually generate the bulk of the WHERE loop code.  The original where.c\n** file retains the code that does query planning and analysis.\n*/\n/* #include \"sqliteInt.h\" */\n/************** Include whereInt.h in the middle of wherecode.c **************/\n/************** Begin file whereInt.h ****************************************/\n/*\n** 2013-11-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains structure and macro definitions for the query\n** planner logic in \"where.c\".  These definitions are broken out into\n** a separate source file for easier editing.\n*/\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace;\n#endif\n#if defined(SQLITE_DEBUG) \\\n    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))\n# define WHERETRACE(K,X)  if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X\n# define WHERETRACE_ENABLED 1\n#else\n# define WHERETRACE(K,X)\n#endif\n\n/* Forward references\n*/\ntypedef struct WhereClause WhereClause;\ntypedef struct WhereMaskSet WhereMaskSet;\ntypedef struct WhereOrInfo WhereOrInfo;\ntypedef struct WhereAndInfo WhereAndInfo;\ntypedef struct WhereLevel WhereLevel;\ntypedef struct WhereLoop WhereLoop;\ntypedef struct WherePath WherePath;\ntypedef struct WhereTerm WhereTerm;\ntypedef struct WhereLoopBuilder WhereLoopBuilder;\ntypedef struct WhereScan WhereScan;\ntypedef struct WhereOrCost WhereOrCost;\ntypedef struct WhereOrSet WhereOrSet;\n\n/*\n** This object contains information needed to implement a single nested\n** loop in WHERE clause.\n**\n** Contrast this object with WhereLoop.  This object describes the\n** implementation of the loop.  WhereLoop describes the algorithm.\n** This object contains a pointer to the WhereLoop algorithm as one of\n** its elements.\n**\n** The WhereInfo object contains a single instance of this object for\n** each term in the FROM clause (which is to say, for each of the\n** nested loops as implemented).  The order of WhereLevel objects determines\n** the loop nested order, with WhereInfo.a[0] being the outer loop and\n** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.\n*/\nstruct WhereLevel {\n  int iLeftJoin;        /* Memory cell used to implement LEFT OUTER JOIN */\n  int iTabCur;          /* The VDBE cursor used to access the table */\n  int iIdxCur;          /* The VDBE cursor used to access pIdx */\n  int addrBrk;          /* Jump here to break out of the loop */\n  int addrNxt;          /* Jump here to start the next IN combination */\n  int addrSkip;         /* Jump here for next iteration of skip-scan */\n  int addrCont;         /* Jump here to continue with the next loop cycle */\n  int addrFirst;        /* First instruction of interior of the loop */\n  int addrBody;         /* Beginning of the body of this loop */\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  u32 iLikeRepCntr;     /* LIKE range processing counter register (times 2) */\n  int addrLikeRep;      /* LIKE range processing address */\n#endif\n  u8 iFrom;             /* Which entry in the FROM clause */\n  u8 op, p3, p5;        /* Opcode, P3 & P5 of the opcode that ends the loop */\n  int p1, p2;           /* Operands of the opcode used to ends the loop */\n  union {               /* Information that depends on pWLoop->wsFlags */\n    struct {\n      int nIn;              /* Number of entries in aInLoop[] */\n      struct InLoop {\n        int iCur;              /* The VDBE cursor used by this IN operator */\n        int addrInTop;         /* Top of the IN loop */\n        u8 eEndLoopOp;         /* IN Loop terminator. OP_Next or OP_Prev */\n      } *aInLoop;           /* Information about each nested IN operator */\n    } in;                 /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */\n    Index *pCovidx;       /* Possible covering index for WHERE_MULTI_OR */\n  } u;\n  struct WhereLoop *pWLoop;  /* The selected WhereLoop object */\n  Bitmask notReady;          /* FROM entries not usable at this level */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  int addrVisit;        /* Address at which row is visited */\n#endif\n};\n\n/*\n** Each instance of this object represents an algorithm for evaluating one\n** term of a join.  Every term of the FROM clause will have at least\n** one corresponding WhereLoop object (unless INDEXED BY constraints\n** prevent a query solution - which is an error) and many terms of the\n** FROM clause will have multiple WhereLoop objects, each describing a\n** potential way of implementing that FROM-clause term, together with\n** dependencies and cost estimates for using the chosen algorithm.\n**\n** Query planning consists of building up a collection of these WhereLoop\n** objects, then computing a particular sequence of WhereLoop objects, with\n** one WhereLoop object per FROM clause term, that satisfy all dependencies\n** and that minimize the overall cost.\n*/\nstruct WhereLoop {\n  Bitmask prereq;       /* Bitmask of other loops that must run first */\n  Bitmask maskSelf;     /* Bitmask identifying table iTab */\n#ifdef SQLITE_DEBUG\n  char cId;             /* Symbolic ID of this loop for debugging use */\n#endif\n  u8 iTab;              /* Position in FROM clause of table for this loop */\n  u8 iSortIdx;          /* Sorting index number.  0==None */\n  LogEst rSetup;        /* One-time setup cost (ex: create transient index) */\n  LogEst rRun;          /* Cost of running each loop */\n  LogEst nOut;          /* Estimated number of output rows */\n  union {\n    struct {               /* Information for internal btree tables */\n      u16 nEq;               /* Number of equality constraints */\n      u16 nBtm;              /* Size of BTM vector */\n      u16 nTop;              /* Size of TOP vector */\n      u16 nIdxCol;           /* Index column used for ORDER BY */\n      Index *pIndex;         /* Index used, or NULL */\n    } btree;\n    struct {               /* Information for virtual tables */\n      int idxNum;            /* Index number */\n      u8 needFree;           /* True if sqlite3_free(idxStr) is needed */\n      i8 isOrdered;          /* True if satisfies ORDER BY */\n      u16 omitMask;          /* Terms that may be omitted */\n      char *idxStr;          /* Index identifier string */\n    } vtab;\n  } u;\n  u32 wsFlags;          /* WHERE_* flags describing the plan */\n  u16 nLTerm;           /* Number of entries in aLTerm[] */\n  u16 nSkip;            /* Number of NULL aLTerm[] entries */\n  /**** whereLoopXfer() copies fields above ***********************/\n# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)\n  u16 nLSlot;           /* Number of slots allocated for aLTerm[] */\n  WhereTerm **aLTerm;   /* WhereTerms used */\n  WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */\n  WhereTerm *aLTermSpace[3];  /* Initial aLTerm[] space */\n};\n\n/* This object holds the prerequisites and the cost of running a\n** subquery on one operand of an OR operator in the WHERE clause.\n** See WhereOrSet for additional information \n*/\nstruct WhereOrCost {\n  Bitmask prereq;     /* Prerequisites */\n  LogEst rRun;        /* Cost of running this subquery */\n  LogEst nOut;        /* Number of outputs for this subquery */\n};\n\n/* The WhereOrSet object holds a set of possible WhereOrCosts that\n** correspond to the subquery(s) of OR-clause processing.  Only the\n** best N_OR_COST elements are retained.\n*/\n#define N_OR_COST 3\nstruct WhereOrSet {\n  u16 n;                      /* Number of valid a[] entries */\n  WhereOrCost a[N_OR_COST];   /* Set of best costs */\n};\n\n/*\n** Each instance of this object holds a sequence of WhereLoop objects\n** that implement some or all of a query plan.\n**\n** Think of each WhereLoop object as a node in a graph with arcs\n** showing dependencies and costs for travelling between nodes.  (That is\n** not a completely accurate description because WhereLoop costs are a\n** vector, not a scalar, and because dependencies are many-to-one, not\n** one-to-one as are graph nodes.  But it is a useful visualization aid.)\n** Then a WherePath object is a path through the graph that visits some\n** or all of the WhereLoop objects once.\n**\n** The \"solver\" works by creating the N best WherePath objects of length\n** 1.  Then using those as a basis to compute the N best WherePath objects\n** of length 2.  And so forth until the length of WherePaths equals the\n** number of nodes in the FROM clause.  The best (lowest cost) WherePath\n** at the end is the chosen query plan.\n*/\nstruct WherePath {\n  Bitmask maskLoop;     /* Bitmask of all WhereLoop objects in this path */\n  Bitmask revLoop;      /* aLoop[]s that should be reversed for ORDER BY */\n  LogEst nRow;          /* Estimated number of rows generated by this path */\n  LogEst rCost;         /* Total cost of this path */\n  LogEst rUnsorted;     /* Total cost of this path ignoring sorting costs */\n  i8 isOrdered;         /* No. of ORDER BY terms satisfied. -1 for unknown */\n  WhereLoop **aLoop;    /* Array of WhereLoop objects implementing this path */\n};\n\n/*\n** The query generator uses an array of instances of this structure to\n** help it analyze the subexpressions of the WHERE clause.  Each WHERE\n** clause subexpression is separated from the others by AND operators,\n** usually, or sometimes subexpressions separated by OR.\n**\n** All WhereTerms are collected into a single WhereClause structure.  \n** The following identity holds:\n**\n**        WhereTerm.pWC->a[WhereTerm.idx] == WhereTerm\n**\n** When a term is of the form:\n**\n**              X <op> <expr>\n**\n** where X is a column name and <op> is one of certain operators,\n** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the\n** cursor number and column number for X.  WhereTerm.eOperator records\n** the <op> using a bitmask encoding defined by WO_xxx below.  The\n** use of a bitmask encoding for the operator allows us to search\n** quickly for terms that match any of several different operators.\n**\n** A WhereTerm might also be two or more subterms connected by OR:\n**\n**         (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....\n**\n** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR\n** and the WhereTerm.u.pOrInfo field points to auxiliary information that\n** is collected about the OR clause.\n**\n** If a term in the WHERE clause does not match either of the two previous\n** categories, then eOperator==0.  The WhereTerm.pExpr field is still set\n** to the original subexpression content and wtFlags is set up appropriately\n** but no other fields in the WhereTerm object are meaningful.\n**\n** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers,\n** but they do so indirectly.  A single WhereMaskSet structure translates\n** cursor number into bits and the translated bit is stored in the prereq\n** fields.  The translation is used in order to maximize the number of\n** bits that will fit in a Bitmask.  The VDBE cursor numbers might be\n** spread out over the non-negative integers.  For example, the cursor\n** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45.  The WhereMaskSet\n** translates these sparse cursor numbers into consecutive integers\n** beginning with 0 in order to make the best possible use of the available\n** bits in the Bitmask.  So, in the example above, the cursor numbers\n** would be mapped into integers 0 through 7.\n**\n** The number of terms in a join is limited by the number of bits\n** in prereqRight and prereqAll.  The default is 64 bits, hence SQLite\n** is only able to process joins with 64 or fewer tables.\n*/\nstruct WhereTerm {\n  Expr *pExpr;            /* Pointer to the subexpression that is this term */\n  WhereClause *pWC;       /* The clause this term is part of */\n  LogEst truthProb;       /* Probability of truth for this expression */\n  u16 wtFlags;            /* TERM_xxx bit flags.  See below */\n  u16 eOperator;          /* A WO_xx value describing <op> */\n  u8 nChild;              /* Number of children that must disable us */\n  u8 eMatchOp;            /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */\n  int iParent;            /* Disable pWC->a[iParent] when this term disabled */\n  int leftCursor;         /* Cursor number of X in \"X <op> <expr>\" */\n  int iField;             /* Field in (?,?,?) IN (SELECT...) vector */\n  union {\n    int leftColumn;         /* Column number of X in \"X <op> <expr>\" */\n    WhereOrInfo *pOrInfo;   /* Extra information if (eOperator & WO_OR)!=0 */\n    WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */\n  } u;\n  Bitmask prereqRight;    /* Bitmask of tables used by pExpr->pRight */\n  Bitmask prereqAll;      /* Bitmask of tables referenced by pExpr */\n};\n\n/*\n** Allowed values of WhereTerm.wtFlags\n*/\n#define TERM_DYNAMIC    0x01   /* Need to call sqlite3ExprDelete(db, pExpr) */\n#define TERM_VIRTUAL    0x02   /* Added by the optimizer.  Do not code */\n#define TERM_CODED      0x04   /* This term is already coded */\n#define TERM_COPIED     0x08   /* Has a child */\n#define TERM_ORINFO     0x10   /* Need to free the WhereTerm.u.pOrInfo object */\n#define TERM_ANDINFO    0x20   /* Need to free the WhereTerm.u.pAndInfo obj */\n#define TERM_OR_OK      0x40   /* Used during OR-clause processing */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n#  define TERM_VNULL    0x80   /* Manufactured x>NULL or x<=NULL term */\n#else\n#  define TERM_VNULL    0x00   /* Disabled if not using stat3 */\n#endif\n#define TERM_LIKEOPT    0x100  /* Virtual terms from the LIKE optimization */\n#define TERM_LIKECOND   0x200  /* Conditionally this LIKE operator term */\n#define TERM_LIKE       0x400  /* The original LIKE operator */\n#define TERM_IS         0x800  /* Term.pExpr is an IS operator */\n#define TERM_VARSELECT  0x1000 /* Term.pExpr contains a correlated sub-query */\n\n/*\n** An instance of the WhereScan object is used as an iterator for locating\n** terms in the WHERE clause that are useful to the query planner.\n*/\nstruct WhereScan {\n  WhereClause *pOrigWC;      /* Original, innermost WhereClause */\n  WhereClause *pWC;          /* WhereClause currently being scanned */\n  const char *zCollName;     /* Required collating sequence, if not NULL */\n  Expr *pIdxExpr;            /* Search for this index expression */\n  char idxaff;               /* Must match this affinity, if zCollName!=NULL */\n  unsigned char nEquiv;      /* Number of entries in aEquiv[] */\n  unsigned char iEquiv;      /* Next unused slot in aEquiv[] */\n  u32 opMask;                /* Acceptable operators */\n  int k;                     /* Resume scanning at this->pWC->a[this->k] */\n  int aiCur[11];             /* Cursors in the equivalence class */\n  i16 aiColumn[11];          /* Corresponding column number in the eq-class */\n};\n\n/*\n** An instance of the following structure holds all information about a\n** WHERE clause.  Mostly this is a container for one or more WhereTerms.\n**\n** Explanation of pOuter:  For a WHERE clause of the form\n**\n**           a AND ((b AND c) OR (d AND e)) AND f\n**\n** There are separate WhereClause objects for the whole clause and for\n** the subclauses \"(b AND c)\" and \"(d AND e)\".  The pOuter field of the\n** subclauses points to the WhereClause object for the whole clause.\n*/\nstruct WhereClause {\n  WhereInfo *pWInfo;       /* WHERE clause processing context */\n  WhereClause *pOuter;     /* Outer conjunction */\n  u8 op;                   /* Split operator.  TK_AND or TK_OR */\n  int nTerm;               /* Number of terms */\n  int nSlot;               /* Number of entries in a[] */\n  WhereTerm *a;            /* Each a[] describes a term of the WHERE cluase */\n#if defined(SQLITE_SMALL_STACK)\n  WhereTerm aStatic[1];    /* Initial static space for a[] */\n#else\n  WhereTerm aStatic[8];    /* Initial static space for a[] */\n#endif\n};\n\n/*\n** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereOrInfo {\n  WhereClause wc;          /* Decomposition into subterms */\n  Bitmask indexable;       /* Bitmask of all indexable tables in the clause */\n};\n\n/*\n** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereAndInfo {\n  WhereClause wc;          /* The subexpression broken out */\n};\n\n/*\n** An instance of the following structure keeps track of a mapping\n** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.\n**\n** The VDBE cursor numbers are small integers contained in \n** SrcList_item.iCursor and Expr.iTable fields.  For any given WHERE \n** clause, the cursor numbers might not begin with 0 and they might\n** contain gaps in the numbering sequence.  But we want to make maximum\n** use of the bits in our bitmasks.  This structure provides a mapping\n** from the sparse cursor numbers into consecutive integers beginning\n** with 0.\n**\n** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask\n** corresponds VDBE cursor number B.  The A-th bit of a bitmask is 1<<A.\n**\n** For example, if the WHERE clause expression used these VDBE\n** cursors:  4, 5, 8, 29, 57, 73.  Then the  WhereMaskSet structure\n** would map those cursor numbers into bits 0 through 5.\n**\n** Note that the mapping is not necessarily ordered.  In the example\n** above, the mapping might go like this:  4->3, 5->1, 8->2, 29->0,\n** 57->5, 73->4.  Or one of 719 other combinations might be used. It\n** does not really matter.  What is important is that sparse cursor\n** numbers all get mapped into bit numbers that begin with 0 and contain\n** no gaps.\n*/\nstruct WhereMaskSet {\n  int bVarSelect;               /* Used by sqlite3WhereExprUsage() */\n  int n;                        /* Number of assigned cursor values */\n  int ix[BMS];                  /* Cursor assigned to each bit */\n};\n\n/*\n** Initialize a WhereMaskSet object\n*/\n#define initMaskSet(P)  (P)->n=0\n\n/*\n** This object is a convenience wrapper holding all information needed\n** to construct WhereLoop objects for a particular query.\n*/\nstruct WhereLoopBuilder {\n  WhereInfo *pWInfo;        /* Information about this WHERE */\n  WhereClause *pWC;         /* WHERE clause terms */\n  ExprList *pOrderBy;       /* ORDER BY clause */\n  WhereLoop *pNew;          /* Template WhereLoop */\n  WhereOrSet *pOrSet;       /* Record best loops here, if not NULL */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  UnpackedRecord *pRec;     /* Probe for stat4 (if required) */\n  int nRecValid;            /* Number of valid fields currently in pRec */\n#endif\n  unsigned int bldFlags;    /* SQLITE_BLDF_* flags */\n};\n\n/* Allowed values for WhereLoopBuider.bldFlags */\n#define SQLITE_BLDF_INDEXED  0x0001   /* An index is used */\n#define SQLITE_BLDF_UNIQUE   0x0002   /* All keys of a UNIQUE index used */\n\n/*\n** The WHERE clause processing routine has two halves.  The\n** first part does the start of the WHERE loop and the second\n** half does the tail of the WHERE loop.  An instance of\n** this structure is returned by the first half and passed\n** into the second half to give some continuity.\n**\n** An instance of this object holds the complete state of the query\n** planner.\n*/\nstruct WhereInfo {\n  Parse *pParse;            /* Parsing and code generating context */\n  SrcList *pTabList;        /* List of tables in the join */\n  ExprList *pOrderBy;       /* The ORDER BY clause or NULL */\n  ExprList *pResultSet;     /* Result set of the query */\n  Expr *pWhere;             /* The complete WHERE clause */\n  LogEst iLimit;            /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */\n  int aiCurOnePass[2];      /* OP_OpenWrite cursors for the ONEPASS opt */\n  int iContinue;            /* Jump here to continue with next record */\n  int iBreak;               /* Jump here to break out of the loop */\n  int savedNQueryLoop;      /* pParse->nQueryLoop outside the WHERE loop */\n  u16 wctrlFlags;           /* Flags originally passed to sqlite3WhereBegin() */\n  u8 nLevel;                /* Number of nested loop */\n  i8 nOBSat;                /* Number of ORDER BY terms satisfied by indices */\n  u8 sorted;                /* True if really sorted (not just grouped) */\n  u8 eOnePass;              /* ONEPASS_OFF, or _SINGLE, or _MULTI */\n  u8 untestedTerms;         /* Not all WHERE terms resolved by outer loop */\n  u8 eDistinct;             /* One of the WHERE_DISTINCT_* values */\n  u8 bOrderedInnerLoop;     /* True if only the inner-most loop is ordered */\n  int iTop;                 /* The very beginning of the WHERE loop */\n  WhereLoop *pLoops;        /* List of all WhereLoop objects */\n  Bitmask revMask;          /* Mask of ORDER BY terms that need reversing */\n  LogEst nRowOut;           /* Estimated number of output rows */\n  WhereClause sWC;          /* Decomposition of the WHERE clause */\n  WhereMaskSet sMaskSet;    /* Map cursor numbers to bitmasks */\n  WhereLevel a[1];          /* Information about each nest loop in WHERE */\n};\n\n/*\n** Private interfaces - callable only by other where.c routines.\n**\n** where.c:\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int);\n#ifdef WHERETRACE_ENABLED\nSQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC);\n#endif\nSQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n);\n\n/* wherecode.c: */\n#ifndef SQLITE_OMIT_EXPLAIN\nSQLITE_PRIVATE int sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  int iLevel,                     /* Value for \"level\" column of output */\n  int iFrom,                      /* Value for \"from\" column of output */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n);\n#else\n# define sqlite3WhereExplainOneScan(u,v,w,x,y,z) 0\n#endif /* SQLITE_OMIT_EXPLAIN */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nSQLITE_PRIVATE void sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n);\n#else\n# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)\n#endif\nSQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  Bitmask notReady     /* Which tables are currently available */\n);\n\n/* whereexpr.c: */\nSQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);\nSQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);\nSQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);\nSQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);\nSQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*);\nSQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);\n\n\n\n\n\n/*\n** Bitmasks for the operators on WhereTerm objects.  These are all\n** operators that are of interest to the query planner.  An\n** OR-ed combination of these values can be used when searching for\n** particular WhereTerms within a WhereClause.\n**\n** Value constraints:\n**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ\n**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT\n**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE\n**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT\n**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE\n*/\n#define WO_IN     0x0001\n#define WO_EQ     0x0002\n#define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))\n#define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))\n#define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))\n#define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))\n#define WO_AUX    0x0040       /* Op useful to virtual tables only */\n#define WO_IS     0x0080\n#define WO_ISNULL 0x0100\n#define WO_OR     0x0200       /* Two or more OR-connected terms */\n#define WO_AND    0x0400       /* Two or more AND-connected terms */\n#define WO_EQUIV  0x0800       /* Of the form A==B, both columns */\n#define WO_NOOP   0x1000       /* This term does not restrict search space */\n\n#define WO_ALL    0x1fff       /* Mask of all possible WO_* values */\n#define WO_SINGLE 0x01ff       /* Mask of all non-compound WO_* values */\n\n/*\n** These are definitions of bits in the WhereLoop.wsFlags field.\n** The particular combination of bits in each WhereLoop help to\n** determine the algorithm that WhereLoop represents.\n*/\n#define WHERE_COLUMN_EQ    0x00000001  /* x=EXPR */\n#define WHERE_COLUMN_RANGE 0x00000002  /* x<EXPR and/or x>EXPR */\n#define WHERE_COLUMN_IN    0x00000004  /* x IN (...) */\n#define WHERE_COLUMN_NULL  0x00000008  /* x IS NULL */\n#define WHERE_CONSTRAINT   0x0000000f  /* Any of the WHERE_COLUMN_xxx values */\n#define WHERE_TOP_LIMIT    0x00000010  /* x<EXPR or x<=EXPR constraint */\n#define WHERE_BTM_LIMIT    0x00000020  /* x>EXPR or x>=EXPR constraint */\n#define WHERE_BOTH_LIMIT   0x00000030  /* Both x>EXPR and x<EXPR */\n#define WHERE_IDX_ONLY     0x00000040  /* Use index only - omit table */\n#define WHERE_IPK          0x00000100  /* x is the INTEGER PRIMARY KEY */\n#define WHERE_INDEXED      0x00000200  /* WhereLoop.u.btree.pIndex is valid */\n#define WHERE_VIRTUALTABLE 0x00000400  /* WhereLoop.u.vtab is valid */\n#define WHERE_IN_ABLE      0x00000800  /* Able to support an IN operator */\n#define WHERE_ONEROW       0x00001000  /* Selects no more than one row */\n#define WHERE_MULTI_OR     0x00002000  /* OR using multiple indices */\n#define WHERE_AUTO_INDEX   0x00004000  /* Uses an ephemeral index */\n#define WHERE_SKIPSCAN     0x00008000  /* Uses the skip-scan algorithm */\n#define WHERE_UNQ_WANTED   0x00010000  /* WHERE_ONEROW would have been helpful*/\n#define WHERE_PARTIALIDX   0x00020000  /* The automatic index is partial */\n\n/************** End of whereInt.h ********************************************/\n/************** Continuing where we left off in wherecode.c ******************/\n\n#ifndef SQLITE_OMIT_EXPLAIN\n\n/*\n** Return the name of the i-th column of the pIdx index.\n*/\nstatic const char *explainIndexColumnName(Index *pIdx, int i){\n  i = pIdx->aiColumn[i];\n  if( i==XN_EXPR ) return \"<expr>\";\n  if( i==XN_ROWID ) return \"rowid\";\n  return pIdx->pTable->aCol[i].zName;\n}\n\n/*\n** This routine is a helper for explainIndexRange() below\n**\n** pStr holds the text of an expression that we are building up one term\n** at a time.  This routine adds a new term to the end of the expression.\n** Terms are separated by AND so add the \"AND\" text for second and subsequent\n** terms only.\n*/\nstatic void explainAppendTerm(\n  StrAccum *pStr,             /* The text expression being built */\n  Index *pIdx,                /* Index to read column names from */\n  int nTerm,                  /* Number of terms */\n  int iTerm,                  /* Zero-based index of first term. */\n  int bAnd,                   /* Non-zero to append \" AND \" */\n  const char *zOp             /* Name of the operator */\n){\n  int i;\n\n  assert( nTerm>=1 );\n  if( bAnd ) sqlite3StrAccumAppend(pStr, \" AND \", 5);\n\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3StrAccumAppend(pStr, \",\", 1);\n    sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));\n  }\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \")\", 1);\n\n  sqlite3StrAccumAppend(pStr, zOp, 1);\n\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3StrAccumAppend(pStr, \",\", 1);\n    sqlite3StrAccumAppend(pStr, \"?\", 1);\n  }\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \")\", 1);\n}\n\n/*\n** Argument pLevel describes a strategy for scanning table pTab. This \n** function appends text to pStr that describes the subset of table\n** rows scanned by the strategy in the form of an SQL expression.\n**\n** For example, if the query:\n**\n**   SELECT * FROM t1 WHERE a=1 AND b>2;\n**\n** is run and there is an index on (a, b), then this function returns a\n** string similar to:\n**\n**   \"a=? AND b>?\"\n*/\nstatic void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){\n  Index *pIndex = pLoop->u.btree.pIndex;\n  u16 nEq = pLoop->u.btree.nEq;\n  u16 nSkip = pLoop->nSkip;\n  int i, j;\n\n  if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;\n  sqlite3StrAccumAppend(pStr, \" (\", 2);\n  for(i=0; i<nEq; i++){\n    const char *z = explainIndexColumnName(pIndex, i);\n    if( i ) sqlite3StrAccumAppend(pStr, \" AND \", 5);\n    sqlite3XPrintf(pStr, i>=nSkip ? \"%s=?\" : \"ANY(%s)\", z);\n  }\n\n  j = i;\n  if( pLoop->wsFlags&WHERE_BTM_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, \">\");\n    i = 1;\n  }\n  if( pLoop->wsFlags&WHERE_TOP_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, \"<\");\n  }\n  sqlite3StrAccumAppend(pStr, \")\", 1);\n}\n\n/*\n** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN\n** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was\n** defined at compile-time. If it is not a no-op, a single OP_Explain opcode \n** is added to the output to describe the table scan strategy in pLevel.\n**\n** If an OP_Explain opcode is added to the VM, its address is returned.\n** Otherwise, if no OP_Explain is coded, zero is returned.\n*/\nSQLITE_PRIVATE int sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  int iLevel,                     /* Value for \"level\" column of output */\n  int iFrom,                      /* Value for \"from\" column of output */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n){\n  int ret = 0;\n#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n  if( pParse->explain==2 )\n#endif\n  {\n    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];\n    Vdbe *v = pParse->pVdbe;      /* VM being constructed */\n    sqlite3 *db = pParse->db;     /* Database handle */\n    int iId = pParse->iSelectId;  /* Select id (left-most output column) */\n    int isSearch;                 /* True for a SEARCH. False for SCAN. */\n    WhereLoop *pLoop;             /* The controlling WhereLoop object */\n    u32 flags;                    /* Flags that describe this loop */\n    char *zMsg;                   /* Text to add to EQP output */\n    StrAccum str;                 /* EQP output string */\n    char zBuf[100];               /* Initial space for EQP output string */\n\n    pLoop = pLevel->pWLoop;\n    flags = pLoop->wsFlags;\n    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;\n\n    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0\n            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))\n            || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));\n\n    sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);\n    sqlite3StrAccumAppendAll(&str, isSearch ? \"SEARCH\" : \"SCAN\");\n    if( pItem->pSelect ){\n      sqlite3XPrintf(&str, \" SUBQUERY %d\", pItem->iSelectId);\n    }else{\n      sqlite3XPrintf(&str, \" TABLE %s\", pItem->zName);\n    }\n\n    if( pItem->zAlias ){\n      sqlite3XPrintf(&str, \" AS %s\", pItem->zAlias);\n    }\n    if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){\n      const char *zFmt = 0;\n      Index *pIdx;\n\n      assert( pLoop->u.btree.pIndex!=0 );\n      pIdx = pLoop->u.btree.pIndex;\n      assert( !(flags&WHERE_AUTO_INDEX) || (flags&WHERE_IDX_ONLY) );\n      if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){\n        if( isSearch ){\n          zFmt = \"PRIMARY KEY\";\n        }\n      }else if( flags & WHERE_PARTIALIDX ){\n        zFmt = \"AUTOMATIC PARTIAL COVERING INDEX\";\n      }else if( flags & WHERE_AUTO_INDEX ){\n        zFmt = \"AUTOMATIC COVERING INDEX\";\n      }else if( flags & WHERE_IDX_ONLY ){\n        zFmt = \"COVERING INDEX %s\";\n      }else{\n        zFmt = \"INDEX %s\";\n      }\n      if( zFmt ){\n        sqlite3StrAccumAppend(&str, \" USING \", 7);\n        sqlite3XPrintf(&str, zFmt, pIdx->zName);\n        explainIndexRange(&str, pLoop);\n      }\n    }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){\n      const char *zRangeOp;\n      if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){\n        zRangeOp = \"=\";\n      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){\n        zRangeOp = \">? AND rowid<\";\n      }else if( flags&WHERE_BTM_LIMIT ){\n        zRangeOp = \">\";\n      }else{\n        assert( flags&WHERE_TOP_LIMIT);\n        zRangeOp = \"<\";\n      }\n      sqlite3XPrintf(&str, \" USING INTEGER PRIMARY KEY (rowid%s?)\",zRangeOp);\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){\n      sqlite3XPrintf(&str, \" VIRTUAL TABLE INDEX %d:%s\",\n                  pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);\n    }\n#endif\n#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS\n    if( pLoop->nOut>=10 ){\n      sqlite3XPrintf(&str, \" (~%llu rows)\", sqlite3LogEstToInt(pLoop->nOut));\n    }else{\n      sqlite3StrAccumAppend(&str, \" (~1 row)\", 9);\n    }\n#endif\n    zMsg = sqlite3StrAccumFinish(&str);\n    ret = sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,P4_DYNAMIC);\n  }\n  return ret;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Configure the VM passed as the first argument with an\n** sqlite3_stmt_scanstatus() entry corresponding to the scan used to \n** implement level pLvl. Argument pSrclist is a pointer to the FROM \n** clause that the scan reads data from.\n**\n** If argument addrExplain is not 0, it must be the address of an \n** OP_Explain instruction that describes the same loop.\n*/\nSQLITE_PRIVATE void sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n){\n  const char *zObj = 0;\n  WhereLoop *pLoop = pLvl->pWLoop;\n  if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0  &&  pLoop->u.btree.pIndex!=0 ){\n    zObj = pLoop->u.btree.pIndex->zName;\n  }else{\n    zObj = pSrclist->a[pLvl->iFrom].zName;\n  }\n  sqlite3VdbeScanStatus(\n      v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj\n  );\n}\n#endif\n\n\n/*\n** Disable a term in the WHERE clause.  Except, do not disable the term\n** if it controls a LEFT OUTER JOIN and it did not originate in the ON\n** or USING clause of that join.\n**\n** Consider the term t2.z='ok' in the following queries:\n**\n**   (1)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'\n**   (2)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'\n**   (3)  SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'\n**\n** The t2.z='ok' is disabled in the in (2) because it originates\n** in the ON clause.  The term is disabled in (3) because it is not part\n** of a LEFT OUTER JOIN.  In (1), the term is not disabled.\n**\n** Disabling a term causes that term to not be tested in the inner loop\n** of the join.  Disabling is an optimization.  When terms are satisfied\n** by indices, we disable them to prevent redundant tests in the inner\n** loop.  We would get the correct results if nothing were ever disabled,\n** but joins might run a little slower.  The trick is to disable as much\n** as we can without disabling too much.  If we disabled in (1), we'd get\n** the wrong answer.  See ticket #813.\n**\n** If all the children of a term are disabled, then that term is also\n** automatically disabled.  In this way, terms get disabled if derived\n** virtual terms are tested first.  For example:\n**\n**      x GLOB 'abc*' AND x>='abc' AND x<'acd'\n**      \\___________/     \\______/     \\_____/\n**         parent          child1       child2\n**\n** Only the parent term was in the original WHERE clause.  The child1\n** and child2 terms were added by the LIKE optimization.  If both of\n** the virtual child terms are valid, then testing of the parent can be \n** skipped.\n**\n** Usually the parent term is marked as TERM_CODED.  But if the parent\n** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.\n** The TERM_LIKECOND marking indicates that the term should be coded inside\n** a conditional such that is only evaluated on the second pass of a\n** LIKE-optimization loop, when scanning BLOBs instead of strings.\n*/\nstatic void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){\n  int nLoop = 0;\n  while( ALWAYS(pTerm!=0)\n      && (pTerm->wtFlags & TERM_CODED)==0\n      && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n      && (pLevel->notReady & pTerm->prereqAll)==0\n  ){\n    if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){\n      pTerm->wtFlags |= TERM_LIKECOND;\n    }else{\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    if( pTerm->iParent<0 ) break;\n    pTerm = &pTerm->pWC->a[pTerm->iParent];\n    pTerm->nChild--;\n    if( pTerm->nChild!=0 ) break;\n    nLoop++;\n  }\n}\n\n/*\n** Code an OP_Affinity opcode to apply the column affinity string zAff\n** to the n registers starting at base. \n**\n** As an optimization, SQLITE_AFF_BLOB entries (which are no-ops) at the\n** beginning and end of zAff are ignored.  If all entries in zAff are\n** SQLITE_AFF_BLOB, then no code gets generated.\n**\n** This routine makes its own copy of zAff so that the caller is free\n** to modify zAff after this routine returns.\n*/\nstatic void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){\n  Vdbe *v = pParse->pVdbe;\n  if( zAff==0 ){\n    assert( pParse->db->mallocFailed );\n    return;\n  }\n  assert( v!=0 );\n\n  /* Adjust base and n to skip over SQLITE_AFF_BLOB entries at the beginning\n  ** and end of the affinity string.\n  */\n  while( n>0 && zAff[0]==SQLITE_AFF_BLOB ){\n    n--;\n    base++;\n    zAff++;\n  }\n  while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){\n    n--;\n  }\n\n  /* Code the OP_Affinity opcode if there is anything left to do. */\n  if( n>0 ){\n    sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);\n    sqlite3ExprCacheAffinityChange(pParse, base, n);\n  }\n}\n\n/*\n** Expression pRight, which is the RHS of a comparison operation, is \n** either a vector of n elements or, if n==1, a scalar expression.\n** Before the comparison operation, affinity zAff is to be applied\n** to the pRight values. This function modifies characters within the\n** affinity string to SQLITE_AFF_BLOB if either:\n**\n**   * the comparison will be performed with no affinity, or\n**   * the affinity change in zAff is guaranteed not to change the value.\n*/\nstatic void updateRangeAffinityStr(\n  Expr *pRight,                   /* RHS of comparison */\n  int n,                          /* Number of vector elements in comparison */\n  char *zAff                      /* Affinity string to modify */\n){\n  int i;\n  for(i=0; i<n; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pRight, i);\n    if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB\n     || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])\n    ){\n      zAff[i] = SQLITE_AFF_BLOB;\n    }\n  }\n}\n\n/*\n** Generate code for a single equality term of the WHERE clause.  An equality\n** term can be either X=expr or X IN (...).   pTerm is the term to be \n** coded.\n**\n** The current value for the constraint is left in a register, the index\n** of which is returned.  An attempt is made store the result in iTarget but\n** this is only guaranteed for TK_ISNULL and TK_IN constraints.  If the\n** constraint is a TK_EQ or TK_IS, then the current value might be left in\n** some other register and it is the caller's responsibility to compensate.\n**\n** For a constraint of the form X=expr, the expression is evaluated in\n** straight-line code.  For constraints of the form X IN (...)\n** this routine sets up a loop that will iterate over all values of X.\n*/\nstatic int codeEqualityTerm(\n  Parse *pParse,      /* The parsing context */\n  WhereTerm *pTerm,   /* The term of the WHERE clause to be coded */\n  WhereLevel *pLevel, /* The level of the FROM clause we are working on */\n  int iEq,            /* Index of the equality term within this level */\n  int bRev,           /* True for reverse-order IN operations */\n  int iTarget         /* Attempt to leave results in this register */\n){\n  Expr *pX = pTerm->pExpr;\n  Vdbe *v = pParse->pVdbe;\n  int iReg;                  /* Register holding results */\n\n  assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );\n  assert( iTarget>0 );\n  if( pX->op==TK_EQ || pX->op==TK_IS ){\n    iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);\n  }else if( pX->op==TK_ISNULL ){\n    iReg = iTarget;\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);\n#ifndef SQLITE_OMIT_SUBQUERY\n  }else{\n    int eType = IN_INDEX_NOOP;\n    int iTab;\n    struct InLoop *pIn;\n    WhereLoop *pLoop = pLevel->pWLoop;\n    int i;\n    int nEq = 0;\n    int *aiMap = 0;\n\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0\n      && pLoop->u.btree.pIndex!=0\n      && pLoop->u.btree.pIndex->aSortOrder[iEq]\n    ){\n      testcase( iEq==0 );\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    assert( pX->op==TK_IN );\n    iReg = iTarget;\n\n    for(i=0; i<iEq; i++){\n      if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){\n        disableTerm(pLevel, pTerm);\n        return iTarget;\n      }\n    }\n    for(i=iEq;i<pLoop->nLTerm; i++){\n      if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;\n    }\n\n    if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){\n      eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);\n    }else{\n      Select *pSelect = pX->x.pSelect;\n      sqlite3 *db = pParse->db;\n      u16 savedDbOptFlags = db->dbOptFlags;\n      ExprList *pOrigRhs = pSelect->pEList;\n      ExprList *pOrigLhs = pX->pLeft->x.pList;\n      ExprList *pRhs = 0;         /* New Select.pEList for RHS */\n      ExprList *pLhs = 0;         /* New pX->pLeft vector */\n\n      for(i=iEq;i<pLoop->nLTerm; i++){\n        if( pLoop->aLTerm[i]->pExpr==pX ){\n          int iField = pLoop->aLTerm[i]->iField - 1;\n          Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);\n          Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);\n\n          pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);\n          pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);\n        }\n      }\n      if( !db->mallocFailed ){\n        Expr *pLeft = pX->pLeft;\n\n        if( pSelect->pOrderBy ){\n          /* If the SELECT statement has an ORDER BY clause, zero the \n          ** iOrderByCol variables. These are set to non-zero when an \n          ** ORDER BY term exactly matches one of the terms of the \n          ** result-set. Since the result-set of the SELECT statement may\n          ** have been modified or reordered, these variables are no longer \n          ** set correctly.  Since setting them is just an optimization, \n          ** it's easiest just to zero them here.  */\n          ExprList *pOrderBy = pSelect->pOrderBy;\n          for(i=0; i<pOrderBy->nExpr; i++){\n            pOrderBy->a[i].u.x.iOrderByCol = 0;\n          }\n        }\n\n        /* Take care here not to generate a TK_VECTOR containing only a\n        ** single value. Since the parser never creates such a vector, some\n        ** of the subroutines do not handle this case.  */\n        if( pLhs->nExpr==1 ){\n          pX->pLeft = pLhs->a[0].pExpr;\n        }else{\n          pLeft->x.pList = pLhs;\n          aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq);\n          testcase( aiMap==0 );\n        }\n        pSelect->pEList = pRhs;\n        db->dbOptFlags |= SQLITE_QueryFlattener;\n        eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);\n        db->dbOptFlags = savedDbOptFlags;\n        testcase( aiMap!=0 && aiMap[0]!=0 );\n        pSelect->pEList = pOrigRhs;\n        pLeft->x.pList = pOrigLhs;\n        pX->pLeft = pLeft;\n      }\n      sqlite3ExprListDelete(pParse->db, pLhs);\n      sqlite3ExprListDelete(pParse->db, pRhs);\n    }\n\n    if( eType==IN_INDEX_INDEX_DESC ){\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    iTab = pX->iTable;\n    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);\n    VdbeCoverageIf(v, bRev);\n    VdbeCoverageIf(v, !bRev);\n    assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );\n\n    pLoop->wsFlags |= WHERE_IN_ABLE;\n    if( pLevel->u.in.nIn==0 ){\n      pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n    }\n\n    i = pLevel->u.in.nIn;\n    pLevel->u.in.nIn += nEq;\n    pLevel->u.in.aInLoop =\n       sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,\n                              sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);\n    pIn = pLevel->u.in.aInLoop;\n    if( pIn ){\n      int iMap = 0;               /* Index in aiMap[] */\n      pIn += i;\n      for(i=iEq;i<pLoop->nLTerm; i++){\n        if( pLoop->aLTerm[i]->pExpr==pX ){\n          int iOut = iReg + i - iEq;\n          if( eType==IN_INDEX_ROWID ){\n            testcase( nEq>1 );  /* Happens with a UNIQUE index on ROWID */\n            pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut);\n          }else{\n            int iCol = aiMap ? aiMap[iMap++] : 0;\n            pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);\n          }\n          sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);\n          if( i==iEq ){\n            pIn->iCur = iTab;\n            pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;\n          }else{\n            pIn->eEndLoopOp = OP_Noop;\n          }\n          pIn++;\n        }\n      }\n    }else{\n      pLevel->u.in.nIn = 0;\n    }\n    sqlite3DbFree(pParse->db, aiMap);\n#endif\n  }\n  disableTerm(pLevel, pTerm);\n  return iReg;\n}\n\n/*\n** Generate code that will evaluate all == and IN constraints for an\n** index scan.\n**\n** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).\n** Suppose the WHERE clause is this:  a==5 AND b IN (1,2,3) AND c>5 AND c<10\n** The index has as many as three equality constraints, but in this\n** example, the third \"c\" value is an inequality.  So only two \n** constraints are coded.  This routine will generate code to evaluate\n** a==5 and b IN (1,2,3).  The current values for a and b will be stored\n** in consecutive registers and the index of the first register is returned.\n**\n** In the example above nEq==2.  But this subroutine works for any value\n** of nEq including 0.  If nEq==0, this routine is nearly a no-op.\n** The only thing it does is allocate the pLevel->iMem memory cell and\n** compute the affinity string.\n**\n** The nExtraReg parameter is 0 or 1.  It is 0 if all WHERE clause constraints\n** are == or IN and are covered by the nEq.  nExtraReg is 1 if there is\n** an inequality constraint (such as the \"c>=5 AND c<10\" in the example) that\n** occurs after the nEq quality constraints.\n**\n** This routine allocates a range of nEq+nExtraReg memory cells and returns\n** the index of the first memory cell in that range. The code that\n** calls this routine will use that memory range to store keys for\n** start and termination conditions of the loop.\n** key value of the loop.  If one or more IN operators appear, then\n** this routine allocates an additional nEq memory cells for internal\n** use.\n**\n** Before returning, *pzAff is set to point to a buffer containing a\n** copy of the column affinity string of the index allocated using\n** sqlite3DbMalloc(). Except, entries in the copy of the string associated\n** with equality constraints that use BLOB or NONE affinity are set to\n** SQLITE_AFF_BLOB. This is to deal with SQL such as the following:\n**\n**   CREATE TABLE t1(a TEXT PRIMARY KEY, b);\n**   SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;\n**\n** In the example above, the index on t1(a) has TEXT affinity. But since\n** the right hand side of the equality constraint (t2.b) has BLOB/NONE affinity,\n** no conversion should be attempted before using a t2.b value as part of\n** a key to search the index. Hence the first byte in the returned affinity\n** string in this example would be set to SQLITE_AFF_BLOB.\n*/\nstatic int codeAllEqualityTerms(\n  Parse *pParse,        /* Parsing context */\n  WhereLevel *pLevel,   /* Which nested loop of the FROM we are coding */\n  int bRev,             /* Reverse the order of IN operators */\n  int nExtraReg,        /* Number of extra registers to allocate */\n  char **pzAff          /* OUT: Set to point to affinity string */\n){\n  u16 nEq;                      /* The number of == or IN constraints to code */\n  u16 nSkip;                    /* Number of left-most columns to skip */\n  Vdbe *v = pParse->pVdbe;      /* The vm under construction */\n  Index *pIdx;                  /* The index being used for this loop */\n  WhereTerm *pTerm;             /* A single constraint term */\n  WhereLoop *pLoop;             /* The WhereLoop object */\n  int j;                        /* Loop counter */\n  int regBase;                  /* Base register */\n  int nReg;                     /* Number of registers to allocate */\n  char *zAff;                   /* Affinity string to return */\n\n  /* This module is only called on query plans that use an index. */\n  pLoop = pLevel->pWLoop;\n  assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  nEq = pLoop->u.btree.nEq;\n  nSkip = pLoop->nSkip;\n  pIdx = pLoop->u.btree.pIndex;\n  assert( pIdx!=0 );\n\n  /* Figure out how many memory cells we will need then allocate them.\n  */\n  regBase = pParse->nMem + 1;\n  nReg = pLoop->u.btree.nEq + nExtraReg;\n  pParse->nMem += nReg;\n\n  zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));\n  assert( zAff!=0 || pParse->db->mallocFailed );\n\n  if( nSkip ){\n    int iIdxCur = pLevel->iIdxCur;\n    sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    VdbeComment((v, \"begin skip-scan on %s\", pIdx->zName));\n    j = sqlite3VdbeAddOp0(v, OP_Goto);\n    pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),\n                            iIdxCur, 0, regBase, nSkip);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    sqlite3VdbeJumpHere(v, j);\n    for(j=0; j<nSkip; j++){\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);\n      testcase( pIdx->aiColumn[j]==XN_EXPR );\n      VdbeComment((v, \"%s\", explainIndexColumnName(pIdx, j)));\n    }\n  }    \n\n  /* Evaluate the equality constraints\n  */\n  assert( zAff==0 || (int)strlen(zAff)>=nEq );\n  for(j=nSkip; j<nEq; j++){\n    int r1;\n    pTerm = pLoop->aLTerm[j];\n    assert( pTerm!=0 );\n    /* The following testcase is true for indices with redundant columns. \n    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */\n    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);\n    if( r1!=regBase+j ){\n      if( nReg==1 ){\n        sqlite3ReleaseTempReg(pParse, regBase);\n        regBase = r1;\n      }else{\n        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);\n      }\n    }\n    if( pTerm->eOperator & WO_IN ){\n      if( pTerm->pExpr->flags & EP_xIsSelect ){\n        /* No affinity ever needs to be (or should be) applied to a value\n        ** from the RHS of an \"? IN (SELECT ...)\" expression. The \n        ** sqlite3FindInIndex() routine has already ensured that the \n        ** affinity of the comparison has been applied to the value.  */\n        if( zAff ) zAff[j] = SQLITE_AFF_BLOB;\n      }\n    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){\n      Expr *pRight = pTerm->pExpr->pRight;\n      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);\n        VdbeCoverage(v);\n      }\n      if( zAff ){\n        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n      }\n    }\n  }\n  *pzAff = zAff;\n  return regBase;\n}\n\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n/*\n** If the most recently coded instruction is a constant range constraint\n** (a string literal) that originated from the LIKE optimization, then \n** set P3 and P5 on the OP_String opcode so that the string will be cast\n** to a BLOB at appropriate times.\n**\n** The LIKE optimization trys to evaluate \"x LIKE 'abc%'\" as a range\n** expression: \"x>='ABC' AND x<'abd'\".  But this requires that the range\n** scan loop run twice, once for strings and a second time for BLOBs.\n** The OP_String opcodes on the second pass convert the upper and lower\n** bound string constants to blobs.  This routine makes the necessary changes\n** to the OP_String opcodes for that to happen.\n**\n** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then\n** only the one pass through the string space is required, so this routine\n** becomes a no-op.\n*/\nstatic void whereLikeOptimizationStringFixup(\n  Vdbe *v,                /* prepared statement under construction */\n  WhereLevel *pLevel,     /* The loop that contains the LIKE operator */\n  WhereTerm *pTerm        /* The upper or lower bound just coded */\n){\n  if( pTerm->wtFlags & TERM_LIKEOPT ){\n    VdbeOp *pOp;\n    assert( pLevel->iLikeRepCntr>0 );\n    pOp = sqlite3VdbeGetOp(v, -1);\n    assert( pOp!=0 );\n    assert( pOp->opcode==OP_String8 \n            || pTerm->pWC->pWInfo->pParse->db->mallocFailed );\n    pOp->p3 = (int)(pLevel->iLikeRepCntr>>1);  /* Register holding counter */\n    pOp->p5 = (u8)(pLevel->iLikeRepCntr&1);    /* ASC or DESC */\n  }\n}\n#else\n# define whereLikeOptimizationStringFixup(A,B,C)\n#endif\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Information is passed from codeCursorHint() down to individual nodes of\n** the expression tree (by sqlite3WalkExpr()) using an instance of this\n** structure.\n*/\nstruct CCurHint {\n  int iTabCur;    /* Cursor for the main table */\n  int iIdxCur;    /* Cursor for the index, if pIdx!=0.  Unused otherwise */\n  Index *pIdx;    /* The index used to access the table */\n};\n\n/*\n** This function is called for every node of an expression that is a candidate\n** for a cursor hint on an index cursor.  For TK_COLUMN nodes that reference\n** the table CCurHint.iTabCur, verify that the same column can be\n** accessed through the index.  If it cannot, then set pWalker->eCode to 1.\n*/\nstatic int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  assert( pHint->pIdx!=0 );\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pHint->iTabCur\n   && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Test whether or not expression pExpr, which was part of a WHERE clause,\n** should be included in the cursor-hint for a table that is on the rhs\n** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the \n** expression is not suitable.\n**\n** An expression is unsuitable if it might evaluate to non NULL even if\n** a TK_COLUMN node that does affect the value of the expression is set\n** to NULL. For example:\n**\n**   col IS NULL\n**   col IS NOT NULL\n**   coalesce(col, 1)\n**   CASE WHEN col THEN 0 ELSE 1 END\n*/\nstatic int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_IS \n   || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT \n   || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE \n  ){\n    pWalker->eCode = 1;\n  }else if( pExpr->op==TK_FUNCTION ){\n    int d1;\n    char d2[4];\n    if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){\n      pWalker->eCode = 1;\n    }\n  }\n\n  return WRC_Continue;\n}\n\n\n/*\n** This function is called on every node of an expression tree used as an\n** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN\n** that accesses any table other than the one identified by\n** CCurHint.iTabCur, then do the following:\n**\n**   1) allocate a register and code an OP_Column instruction to read \n**      the specified column into the new register, and\n**\n**   2) transform the expression node to a TK_REGISTER node that reads \n**      from the newly populated register.\n**\n** Also, if the node is a TK_COLUMN that does access the table idenified\n** by pCCurHint.iTabCur, and an index is being used (which we will\n** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into\n** an access of the index rather than the original table.\n*/\nstatic int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){\n  int rc = WRC_Continue;\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  if( pExpr->op==TK_COLUMN ){\n    if( pExpr->iTable!=pHint->iTabCur ){\n      Vdbe *v = pWalker->pParse->pVdbe;\n      int reg = ++pWalker->pParse->nMem;   /* Register for column value */\n      sqlite3ExprCodeGetColumnOfTable(\n          v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg\n      );\n      pExpr->op = TK_REGISTER;\n      pExpr->iTable = reg;\n    }else if( pHint->pIdx!=0 ){\n      pExpr->iTable = pHint->iIdxCur;\n      pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);\n      assert( pExpr->iColumn>=0 );\n    }\n  }else if( pExpr->op==TK_AGG_FUNCTION ){\n    /* An aggregate function in the WHERE clause of a query means this must\n    ** be a correlated sub-query, and expression pExpr is an aggregate from\n    ** the parent context. Do not walk the function arguments in this case.\n    **\n    ** todo: It should be possible to replace this node with a TK_REGISTER\n    ** expression, as the result of the expression must be stored in a \n    ** register at this point. The same holds for TK_AGG_COLUMN nodes. */\n    rc = WRC_Prune;\n  }\n  return rc;\n}\n\n/*\n** Insert an OP_CursorHint instruction if it is appropriate to do so.\n*/\nstatic void codeCursorHint(\n  struct SrcList_item *pTabItem,  /* FROM clause item */\n  WhereInfo *pWInfo,    /* The where clause */\n  WhereLevel *pLevel,   /* Which loop to provide hints for */\n  WhereTerm *pEndRange  /* Hint this end-of-scan boundary term if not NULL */\n){\n  Parse *pParse = pWInfo->pParse;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  Expr *pExpr = 0;\n  WhereLoop *pLoop = pLevel->pWLoop;\n  int iCur;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  int i, j;\n  struct CCurHint sHint;\n  Walker sWalker;\n\n  if( OptimizationDisabled(db, SQLITE_CursorHints) ) return;\n  iCur = pLevel->iTabCur;\n  assert( iCur==pWInfo->pTabList->a[pLevel->iFrom].iCursor );\n  sHint.iTabCur = iCur;\n  sHint.iIdxCur = pLevel->iIdxCur;\n  sHint.pIdx = pLoop->u.btree.pIndex;\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.u.pCCurHint = &sHint;\n  pWC = &pWInfo->sWC;\n  for(i=0; i<pWC->nTerm; i++){\n    pTerm = &pWC->a[i];\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( pTerm->prereqAll & pLevel->notReady ) continue;\n\n    /* Any terms specified as part of the ON(...) clause for any LEFT \n    ** JOIN for which the current table is not the rhs are omitted\n    ** from the cursor-hint. \n    **\n    ** If this table is the rhs of a LEFT JOIN, \"IS\" or \"IS NULL\" terms \n    ** that were specified as part of the WHERE clause must be excluded.\n    ** This is to address the following:\n    **\n    **   SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;\n    **\n    ** Say there is a single row in t2 that matches (t1.a=t2.b), but its\n    ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is \n    ** pushed down to the cursor, this row is filtered out, causing\n    ** SQLite to synthesize a row of NULL values. Which does match the\n    ** WHERE clause, and so the query returns a row. Which is incorrect.\n    **\n    ** For the same reason, WHERE terms such as:\n    **\n    **   WHERE 1 = (t2.c IS NULL)\n    **\n    ** are also excluded. See codeCursorHintIsOrFunction() for details.\n    */\n    if( pTabItem->fg.jointype & JT_LEFT ){\n      Expr *pExpr = pTerm->pExpr;\n      if( !ExprHasProperty(pExpr, EP_FromJoin) \n       || pExpr->iRightJoinTable!=pTabItem->iCursor\n      ){\n        sWalker.eCode = 0;\n        sWalker.xExprCallback = codeCursorHintIsOrFunction;\n        sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n        if( sWalker.eCode ) continue;\n      }\n    }else{\n      if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;\n    }\n\n    /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize\n    ** the cursor.  These terms are not needed as hints for a pure range\n    ** scan (that has no == terms) so omit them. */\n    if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){\n      for(j=0; j<pLoop->nLTerm && pLoop->aLTerm[j]!=pTerm; j++){}\n      if( j<pLoop->nLTerm ) continue;\n    }\n\n    /* No subqueries or non-deterministic functions allowed */\n    if( sqlite3ExprContainsSubquery(pTerm->pExpr) ) continue;\n\n    /* For an index scan, make sure referenced columns are actually in\n    ** the index. */\n    if( sHint.pIdx!=0 ){\n      sWalker.eCode = 0;\n      sWalker.xExprCallback = codeCursorHintCheckExpr;\n      sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n      if( sWalker.eCode ) continue;\n    }\n\n    /* If we survive all prior tests, that means this term is worth hinting */\n    pExpr = sqlite3ExprAnd(db, pExpr, sqlite3ExprDup(db, pTerm->pExpr, 0));\n  }\n  if( pExpr!=0 ){\n    sWalker.xExprCallback = codeCursorHintFixExpr;\n    sqlite3WalkExpr(&sWalker, pExpr);\n    sqlite3VdbeAddOp4(v, OP_CursorHint, \n                      (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,\n                      (const char*)pExpr, P4_EXPR);\n  }\n}\n#else\n# define codeCursorHint(A,B,C,D)  /* No-op */\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n/*\n** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains\n** a rowid value just read from cursor iIdxCur, open on index pIdx. This\n** function generates code to do a deferred seek of cursor iCur to the \n** rowid stored in register iRowid.\n**\n** Normally, this is just:\n**\n**   OP_DeferredSeek $iCur $iRowid\n**\n** However, if the scan currently being coded is a branch of an OR-loop and\n** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek\n** is set to iIdxCur and P4 is set to point to an array of integers\n** containing one entry for each column of the table cursor iCur is open \n** on. For each table column, if the column is the i'th column of the \n** index, then the corresponding array entry is set to (i+1). If the column\n** does not appear in the index at all, the array entry is set to 0.\n*/\nstatic void codeDeferredSeek(\n  WhereInfo *pWInfo,              /* Where clause context */\n  Index *pIdx,                    /* Index scan is using */\n  int iCur,                       /* Cursor for IPK b-tree */\n  int iIdxCur                     /* Index cursor */\n){\n  Parse *pParse = pWInfo->pParse; /* Parse context */\n  Vdbe *v = pParse->pVdbe;        /* Vdbe to generate code within */\n\n  assert( iIdxCur>0 );\n  assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );\n  \n  sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur);\n  if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)\n   && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)\n  ){\n    int i;\n    Table *pTab = pIdx->pTable;\n    int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));\n    if( ai ){\n      ai[0] = pTab->nCol;\n      for(i=0; i<pIdx->nColumn-1; i++){\n        assert( pIdx->aiColumn[i]<pTab->nCol );\n        if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;\n      }\n      sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);\n    }\n  }\n}\n\n/*\n** If the expression passed as the second argument is a vector, generate\n** code to write the first nReg elements of the vector into an array\n** of registers starting with iReg.\n**\n** If the expression is not a vector, then nReg must be passed 1. In\n** this case, generate code to evaluate the expression and leave the\n** result in register iReg.\n*/\nstatic void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){\n  assert( nReg>0 );\n  if( p && sqlite3ExprIsVector(p) ){\n#ifndef SQLITE_OMIT_SUBQUERY\n    if( (p->flags & EP_xIsSelect) ){\n      Vdbe *v = pParse->pVdbe;\n      int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);\n      sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);\n    }else\n#endif\n    {\n      int i;\n      ExprList *pList = p->x.pList;\n      assert( nReg<=pList->nExpr );\n      for(i=0; i<nReg; i++){\n        sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);\n      }\n    }\n  }else{\n    assert( nReg==1 );\n    sqlite3ExprCode(pParse, p, iReg);\n  }\n}\n\n/* An instance of the IdxExprTrans object carries information about a\n** mapping from an expression on table columns into a column in an index\n** down through the Walker.\n*/\ntypedef struct IdxExprTrans {\n  Expr *pIdxExpr;    /* The index expression */\n  int iTabCur;       /* The cursor of the corresponding table */\n  int iIdxCur;       /* The cursor for the index */\n  int iIdxCol;       /* The column for the index */\n} IdxExprTrans;\n\n/* The walker node callback used to transform matching expressions into\n** a reference to an index column for an index on an expression.\n**\n** If pExpr matches, then transform it into a reference to the index column\n** that contains the value of pExpr.\n*/\nstatic int whereIndexExprTransNode(Walker *p, Expr *pExpr){\n  IdxExprTrans *pX = p->u.pIdxTrans;\n  if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){\n    pExpr->op = TK_COLUMN;\n    pExpr->iTable = pX->iIdxCur;\n    pExpr->iColumn = pX->iIdxCol;\n    pExpr->pTab = 0;\n    return WRC_Prune;\n  }else{\n    return WRC_Continue;\n  }\n}\n\n/*\n** For an indexes on expression X, locate every instance of expression X\n** in pExpr and change that subexpression into a reference to the appropriate\n** column of the index.\n*/\nstatic void whereIndexExprTrans(\n  Index *pIdx,      /* The Index */\n  int iTabCur,      /* Cursor of the table that is being indexed */\n  int iIdxCur,      /* Cursor of the index itself */\n  WhereInfo *pWInfo /* Transform expressions in this WHERE clause */\n){\n  int iIdxCol;               /* Column number of the index */\n  ExprList *aColExpr;        /* Expressions that are indexed */\n  Walker w;\n  IdxExprTrans x;\n  aColExpr = pIdx->aColExpr;\n  if( aColExpr==0 ) return;  /* Not an index on expressions */\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = whereIndexExprTransNode;\n  w.u.pIdxTrans = &x;\n  x.iTabCur = iTabCur;\n  x.iIdxCur = iIdxCur;\n  for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){\n    if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;\n    assert( aColExpr->a[iIdxCol].pExpr!=0 );\n    x.iIdxCol = iIdxCol;\n    x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;\n    sqlite3WalkExpr(&w, pWInfo->pWhere);\n    sqlite3WalkExprList(&w, pWInfo->pOrderBy);\n    sqlite3WalkExprList(&w, pWInfo->pResultSet);\n  }\n}\n\n/*\n** Generate code for the start of the iLevel-th loop in the WHERE clause\n** implementation described by pWInfo.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  Bitmask notReady     /* Which tables are currently available */\n){\n  int j, k;            /* Loop counters */\n  int iCur;            /* The VDBE cursor for the table */\n  int addrNxt;         /* Where to jump to continue with the next IN case */\n  int omitTable;       /* True if we use the index only */\n  int bRev;            /* True if we need to scan in reverse order */\n  WhereLevel *pLevel;  /* The where level to be coded */\n  WhereLoop *pLoop;    /* The WhereLoop object being coded */\n  WhereClause *pWC;    /* Decomposition of the entire WHERE clause */\n  WhereTerm *pTerm;               /* A WHERE clause term */\n  Parse *pParse;                  /* Parsing context */\n  sqlite3 *db;                    /* Database connection */\n  Vdbe *v;                        /* The prepared stmt under constructions */\n  struct SrcList_item *pTabItem;  /* FROM clause term being coded */\n  int addrBrk;                    /* Jump here to break out of the loop */\n  int addrHalt;                   /* addrBrk for the outermost loop */\n  int addrCont;                   /* Jump here to continue with next cycle */\n  int iRowidReg = 0;        /* Rowid is stored in this register, if not zero */\n  int iReleaseReg = 0;      /* Temp register to free before returning */\n  Index *pIdx = 0;          /* Index used by loop (if any) */\n  int iLoop;                /* Iteration of constraint generator loop */\n\n  pParse = pWInfo->pParse;\n  v = pParse->pVdbe;\n  pWC = &pWInfo->sWC;\n  db = pParse->db;\n  pLevel = &pWInfo->a[iLevel];\n  pLoop = pLevel->pWLoop;\n  pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];\n  iCur = pTabItem->iCursor;\n  pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);\n  bRev = (pWInfo->revMask>>iLevel)&1;\n  omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 \n           && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;\n  VdbeModuleComment((v, \"Begin WHERE-loop%d: %s\",iLevel,pTabItem->pTab->zName));\n\n  /* Create labels for the \"break\" and \"continue\" instructions\n  ** for the current loop.  Jump to addrBrk to break out of a loop.\n  ** Jump to cont to go immediately to the next iteration of the\n  ** loop.\n  **\n  ** When there is an IN operator, we also have a \"addrNxt\" label that\n  ** means to continue with the next IN value combination.  When\n  ** there are no IN operators in the constraints, the \"addrNxt\" label\n  ** is the same as \"addrBrk\".\n  */\n  addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n  addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);\n\n  /* If this is the right table of a LEFT OUTER JOIN, allocate and\n  ** initialize a memory cell that records if this table matches any\n  ** row of the left table of the join.\n  */\n  if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){\n    pLevel->iLeftJoin = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);\n    VdbeComment((v, \"init LEFT JOIN no-match flag\"));\n  }\n\n  /* Compute a safe address to jump to if we discover that the table for\n  ** this loop is empty and can never contribute content. */\n  for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}\n  addrHalt = pWInfo->a[j].addrBrk;\n\n  /* Special case of a FROM clause subquery implemented as a co-routine */\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    pLevel->p2 =  sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of \\\"%s\\\"\", pTabItem->pTab->zName));\n    pLevel->op = OP_Goto;\n  }else\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if(  (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n    /* Case 1:  The table is a virtual-table.  Use the VFilter and VNext\n    **          to access the data.\n    */\n    int iReg;   /* P3 Value for OP_VFilter */\n    int addrNotFound;\n    int nConstraint = pLoop->nLTerm;\n    int iIn;    /* Counter for IN constraints */\n\n    sqlite3ExprCachePush(pParse);\n    iReg = sqlite3GetTempRange(pParse, nConstraint+2);\n    addrNotFound = pLevel->addrBrk;\n    for(j=0; j<nConstraint; j++){\n      int iTarget = iReg+j+2;\n      pTerm = pLoop->aLTerm[j];\n      if( NEVER(pTerm==0) ) continue;\n      if( pTerm->eOperator & WO_IN ){\n        codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);\n        addrNotFound = pLevel->addrNxt;\n      }else{\n        Expr *pRight = pTerm->pExpr->pRight;\n        codeExprOrVector(pParse, pRight, iTarget, 1);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);\n    sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);\n    sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,\n                      pLoop->u.vtab.idxStr,\n                      pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);\n    VdbeCoverage(v);\n    pLoop->u.vtab.needFree = 0;\n    pLevel->p1 = iCur;\n    pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n    iIn = pLevel->u.in.nIn;\n    for(j=nConstraint-1; j>=0; j--){\n      pTerm = pLoop->aLTerm[j];\n      if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){\n        disableTerm(pLevel, pTerm);\n      }else if( (pTerm->eOperator & WO_IN)!=0 ){\n        Expr *pCompare;  /* The comparison operator */\n        Expr *pRight;    /* RHS of the comparison */\n        VdbeOp *pOp;     /* Opcode to access the value of the IN constraint */\n\n        /* Reload the constraint value into reg[iReg+j+2].  The same value\n        ** was loaded into the same register prior to the OP_VFilter, but\n        ** the xFilter implementation might have changed the datatype or\n        ** encoding of the value in the register, so it *must* be reloaded. */\n        assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );\n        if( !db->mallocFailed ){\n          assert( iIn>0 );\n          pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop);\n          assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );\n          assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );\n          assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );\n          testcase( pOp->opcode==OP_Rowid );\n          sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);\n        }\n\n        /* Generate code that will continue to the next row if \n        ** the IN constraint is not satisfied */\n        pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);\n        assert( pCompare!=0 || db->mallocFailed );\n        if( pCompare ){\n          pCompare->pLeft = pTerm->pExpr->pLeft;\n          pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);\n          if( pRight ){\n            pRight->iTable = iReg+j+2;\n            sqlite3ExprIfFalse(pParse, pCompare, pLevel->addrCont, 0);\n          }\n          pCompare->pLeft = 0;\n          sqlite3ExprDelete(db, pCompare);\n        }\n      }\n    }\n    /* These registers need to be preserved in case there is an IN operator\n    ** loop.  So we could deallocate the registers here (and potentially\n    ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0.  But it seems\n    ** simpler and safer to simply not reuse the registers.\n    **\n    **    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);\n    */\n    sqlite3ExprCachePop(pParse);\n  }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  if( (pLoop->wsFlags & WHERE_IPK)!=0\n   && (pLoop->wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_EQ))!=0\n  ){\n    /* Case 2:  We can directly reference a single row using an\n    **          equality comparison against the ROWID field.  Or\n    **          we reference multiple rows using a \"rowid IN (...)\"\n    **          construct.\n    */\n    assert( pLoop->u.btree.nEq==1 );\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->pExpr!=0 );\n    assert( omitTable==0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    iReleaseReg = ++pParse->nMem;\n    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);\n    if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);\n    addrNxt = pLevel->addrNxt;\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);\n    VdbeCoverage(v);\n    sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);\n    sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n    VdbeComment((v, \"pk\"));\n    pLevel->op = OP_Noop;\n  }else if( (pLoop->wsFlags & WHERE_IPK)!=0\n         && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0\n  ){\n    /* Case 3:  We have an inequality comparison against the ROWID field.\n    */\n    int testOp = OP_Noop;\n    int start;\n    int memEndValue = 0;\n    WhereTerm *pStart, *pEnd;\n\n    assert( omitTable==0 );\n    j = 0;\n    pStart = pEnd = 0;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ) pStart = pLoop->aLTerm[j++];\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ) pEnd = pLoop->aLTerm[j++];\n    assert( pStart!=0 || pEnd!=0 );\n    if( bRev ){\n      pTerm = pStart;\n      pStart = pEnd;\n      pEnd = pTerm;\n    }\n    codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);\n    if( pStart ){\n      Expr *pX;             /* The expression that defines the start bound */\n      int r1, rTemp;        /* Registers for holding the start boundary */\n      int op;               /* Cursor seek operation */\n\n      /* The following constant maps TK_xx codes into corresponding \n      ** seek opcodes.  It depends on a particular ordering of TK_xx\n      */\n      const u8 aMoveOp[] = {\n           /* TK_GT */  OP_SeekGT,\n           /* TK_LE */  OP_SeekLE,\n           /* TK_LT */  OP_SeekLT,\n           /* TK_GE */  OP_SeekGE\n      };\n      assert( TK_LE==TK_GT+1 );      /* Make sure the ordering.. */\n      assert( TK_LT==TK_GT+2 );      /*  ... of the TK_xx values... */\n      assert( TK_GE==TK_GT+3 );      /*  ... is correcct. */\n\n      assert( (pStart->wtFlags & TERM_VNULL)==0 );\n      testcase( pStart->wtFlags & TERM_VIRTUAL );\n      pX = pStart->pExpr;\n      assert( pX!=0 );\n      testcase( pStart->leftCursor!=iCur ); /* transitive constraints */\n      if( sqlite3ExprIsVector(pX->pRight) ){\n        r1 = rTemp = sqlite3GetTempReg(pParse);\n        codeExprOrVector(pParse, pX->pRight, r1, 1);\n        op = aMoveOp[(pX->op - TK_GT) | 0x0001];\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);\n        disableTerm(pLevel, pStart);\n        op = aMoveOp[(pX->op - TK_GT)];\n      }\n      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);\n      VdbeComment((v, \"pk\"));\n      VdbeCoverageIf(v, pX->op==TK_GT);\n      VdbeCoverageIf(v, pX->op==TK_LE);\n      VdbeCoverageIf(v, pX->op==TK_LT);\n      VdbeCoverageIf(v, pX->op==TK_GE);\n      sqlite3ExprCacheAffinityChange(pParse, r1, 1);\n      sqlite3ReleaseTempReg(pParse, rTemp);\n    }else{\n      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n    }\n    if( pEnd ){\n      Expr *pX;\n      pX = pEnd->pExpr;\n      assert( pX!=0 );\n      assert( (pEnd->wtFlags & TERM_VNULL)==0 );\n      testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */\n      testcase( pEnd->wtFlags & TERM_VIRTUAL );\n      memEndValue = ++pParse->nMem;\n      codeExprOrVector(pParse, pX->pRight, memEndValue, 1);\n      if( 0==sqlite3ExprIsVector(pX->pRight) \n       && (pX->op==TK_LT || pX->op==TK_GT) \n      ){\n        testOp = bRev ? OP_Le : OP_Ge;\n      }else{\n        testOp = bRev ? OP_Lt : OP_Gt;\n      }\n      if( 0==sqlite3ExprIsVector(pX->pRight) ){\n        disableTerm(pLevel, pEnd);\n      }\n    }\n    start = sqlite3VdbeCurrentAddr(v);\n    pLevel->op = bRev ? OP_Prev : OP_Next;\n    pLevel->p1 = iCur;\n    pLevel->p2 = start;\n    assert( pLevel->p5==0 );\n    if( testOp!=OP_Noop ){\n      iRowidReg = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);\n      sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);\n      VdbeCoverageIf(v, testOp==OP_Le);\n      VdbeCoverageIf(v, testOp==OP_Lt);\n      VdbeCoverageIf(v, testOp==OP_Ge);\n      VdbeCoverageIf(v, testOp==OP_Gt);\n      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);\n    }\n  }else if( pLoop->wsFlags & WHERE_INDEXED ){\n    /* Case 4: A scan using an index.\n    **\n    **         The WHERE clause may contain zero or more equality \n    **         terms (\"==\" or \"IN\" operators) that refer to the N\n    **         left-most columns of the index. It may also contain\n    **         inequality constraints (>, <, >= or <=) on the indexed\n    **         column that immediately follows the N equalities. Only \n    **         the right-most column can be an inequality - the rest must\n    **         use the \"==\" and \"IN\" operators. For example, if the \n    **         index is on (x,y,z), then the following clauses are all \n    **         optimized:\n    **\n    **            x=5\n    **            x=5 AND y=10\n    **            x=5 AND y<10\n    **            x=5 AND y>5 AND y<10\n    **            x=5 AND y=5 AND z<=10\n    **\n    **         The z<10 term of the following cannot be used, only\n    **         the x=5 term:\n    **\n    **            x=5 AND z<10\n    **\n    **         N may be zero if there are inequality constraints.\n    **         If there are no inequality constraints, then N is at\n    **         least one.\n    **\n    **         This case is also used when there are no WHERE clause\n    **         constraints but an index is selected anyway, in order\n    **         to force the output order to conform to an ORDER BY.\n    */  \n    static const u8 aStartOp[] = {\n      0,\n      0,\n      OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */\n      OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */\n      OP_SeekGT,           /* 4: (start_constraints  && !startEq && !bRev) */\n      OP_SeekLT,           /* 5: (start_constraints  && !startEq &&  bRev) */\n      OP_SeekGE,           /* 6: (start_constraints  &&  startEq && !bRev) */\n      OP_SeekLE            /* 7: (start_constraints  &&  startEq &&  bRev) */\n    };\n    static const u8 aEndOp[] = {\n      OP_IdxGE,            /* 0: (end_constraints && !bRev && !endEq) */\n      OP_IdxGT,            /* 1: (end_constraints && !bRev &&  endEq) */\n      OP_IdxLE,            /* 2: (end_constraints &&  bRev && !endEq) */\n      OP_IdxLT,            /* 3: (end_constraints &&  bRev &&  endEq) */\n    };\n    u16 nEq = pLoop->u.btree.nEq;     /* Number of == or IN terms */\n    u16 nBtm = pLoop->u.btree.nBtm;   /* Length of BTM vector */\n    u16 nTop = pLoop->u.btree.nTop;   /* Length of TOP vector */\n    int regBase;                 /* Base register holding constraint values */\n    WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */\n    WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */\n    int startEq;                 /* True if range start uses ==, >= or <= */\n    int endEq;                   /* True if range end uses ==, >= or <= */\n    int start_constraints;       /* Start of range is constrained */\n    int nConstraint;             /* Number of constraint terms */\n    int iIdxCur;                 /* The VDBE cursor for the index */\n    int nExtraReg = 0;           /* Number of extra registers needed */\n    int op;                      /* Instruction opcode */\n    char *zStartAff;             /* Affinity for start of range constraint */\n    char *zEndAff = 0;           /* Affinity for end of range constraint */\n    u8 bSeekPastNull = 0;        /* True to seek past initial nulls */\n    u8 bStopAtNull = 0;          /* Add condition to terminate at NULLs */\n\n    pIdx = pLoop->u.btree.pIndex;\n    iIdxCur = pLevel->iIdxCur;\n    assert( nEq>=pLoop->nSkip );\n\n    /* If this loop satisfies a sort order (pOrderBy) request that \n    ** was passed to this function to implement a \"SELECT min(x) ...\" \n    ** query, then the caller will only allow the loop to run for\n    ** a single iteration. This means that the first row returned\n    ** should not have a NULL value stored in 'x'. If column 'x' is\n    ** the first one after the nEq equality constraints in the index,\n    ** this requires some special handling.\n    */\n    assert( pWInfo->pOrderBy==0\n         || pWInfo->pOrderBy->nExpr==1\n         || (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );\n    if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0\n     && pWInfo->nOBSat>0\n     && (pIdx->nKeyCol>nEq)\n    ){\n      assert( pLoop->nSkip==0 );\n      bSeekPastNull = 1;\n      nExtraReg = 1;\n    }\n\n    /* Find any inequality constraint terms for the start and end \n    ** of the range. \n    */\n    j = nEq;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ){\n      pRangeStart = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);\n      /* Like optimization range constraints always occur in pairs */\n      assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 || \n              (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );\n    }\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ){\n      pRangeEnd = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n      if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){\n        assert( pRangeStart!=0 );                     /* LIKE opt constraints */\n        assert( pRangeStart->wtFlags & TERM_LIKEOPT );   /* occur in pairs */\n        pLevel->iLikeRepCntr = (u32)++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Integer, 1, (int)pLevel->iLikeRepCntr);\n        VdbeComment((v, \"LIKE loop counter\"));\n        pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);\n        /* iLikeRepCntr actually stores 2x the counter register number.  The\n        ** bottom bit indicates whether the search order is ASC or DESC. */\n        testcase( bRev );\n        testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );\n        assert( (bRev & ~1)==0 );\n        pLevel->iLikeRepCntr <<=1;\n        pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);\n      }\n#endif\n      if( pRangeStart==0 ){\n        j = pIdx->aiColumn[nEq];\n        if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){\n          bSeekPastNull = 1;\n        }\n      }\n    }\n    assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );\n\n    /* If we are doing a reverse order scan on an ascending index, or\n    ** a forward order scan on a descending index, interchange the \n    ** start and end terms (pRangeStart and pRangeEnd).\n    */\n    if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))\n     || (bRev && pIdx->nKeyCol==nEq)\n    ){\n      SWAP(WhereTerm *, pRangeEnd, pRangeStart);\n      SWAP(u8, bSeekPastNull, bStopAtNull);\n      SWAP(u8, nBtm, nTop);\n    }\n\n    /* Generate code to evaluate all constraint terms using == or IN\n    ** and store the values of those terms in an array of registers\n    ** starting at regBase.\n    */\n    codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);\n    regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);\n    assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );\n    if( zStartAff && nTop ){\n      zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);\n    }\n    addrNxt = pLevel->addrNxt;\n\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );\n    startEq = !pRangeStart || pRangeStart->eOperator & (WO_LE|WO_GE);\n    endEq =   !pRangeEnd || pRangeEnd->eOperator & (WO_LE|WO_GE);\n    start_constraints = pRangeStart || nEq>0;\n\n    /* Seek the index cursor to the start of the range. */\n    nConstraint = nEq;\n    if( pRangeStart ){\n      Expr *pRight = pRangeStart->pExpr->pRight;\n      codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);\n      if( (pRangeStart->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zStartAff ){\n        updateRangeAffinityStr(pRight, nBtm, &zStartAff[nEq]);\n      }  \n      nConstraint += nBtm;\n      testcase( pRangeStart->wtFlags & TERM_VIRTUAL );\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeStart);\n      }else{\n        startEq = 1;\n      }\n      bSeekPastNull = 0;\n    }else if( bSeekPastNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      nConstraint++;\n      startEq = 0;\n      start_constraints = 1;\n    }\n    codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);\n    if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){\n      /* The skip-scan logic inside the call to codeAllEqualityConstraints()\n      ** above has already left the cursor sitting on the correct row,\n      ** so no further seeking is needed */\n    }else{\n      op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];\n      assert( op!=0 );\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, op==OP_Rewind);  testcase( op==OP_Rewind );\n      VdbeCoverageIf(v, op==OP_Last);    testcase( op==OP_Last );\n      VdbeCoverageIf(v, op==OP_SeekGT);  testcase( op==OP_SeekGT );\n      VdbeCoverageIf(v, op==OP_SeekGE);  testcase( op==OP_SeekGE );\n      VdbeCoverageIf(v, op==OP_SeekLE);  testcase( op==OP_SeekLE );\n      VdbeCoverageIf(v, op==OP_SeekLT);  testcase( op==OP_SeekLT );\n    }\n\n    /* Load the value for the inequality constraint at the end of the\n    ** range (if any).\n    */\n    nConstraint = nEq;\n    if( pRangeEnd ){\n      Expr *pRight = pRangeEnd->pExpr->pRight;\n      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);\n      codeExprOrVector(pParse, pRight, regBase+nEq, nTop);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);\n      if( (pRangeEnd->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zEndAff ){\n        updateRangeAffinityStr(pRight, nTop, zEndAff);\n        codeApplyAffinity(pParse, regBase+nEq, nTop, zEndAff);\n      }else{\n        assert( pParse->db->mallocFailed );\n      }\n      nConstraint += nTop;\n      testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );\n\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeEnd);\n      }else{\n        endEq = 1;\n      }\n    }else if( bStopAtNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      endEq = 0;\n      nConstraint++;\n    }\n    sqlite3DbFree(db, zStartAff);\n    sqlite3DbFree(db, zEndAff);\n\n    /* Top of the loop body */\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n\n    /* Check if the index cursor is past the end of the range. */\n    if( nConstraint ){\n      op = aEndOp[bRev*2 + endEq];\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      testcase( op==OP_IdxGT );  VdbeCoverageIf(v, op==OP_IdxGT );\n      testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );\n      testcase( op==OP_IdxLT );  VdbeCoverageIf(v, op==OP_IdxLT );\n      testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );\n    }\n\n    /* Seek the table cursor, if required */\n    if( omitTable ){\n      /* pIdx is a covering index.  No need to access the main table. */\n    }else if( HasRowid(pIdx->pTable) ){\n      if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (\n          (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) \n       && (pWInfo->eOnePass==ONEPASS_SINGLE)\n      )){\n        iRowidReg = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);\n        sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n        sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);\n        VdbeCoverage(v);\n      }else{\n        codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);\n      }\n    }else if( iCur!=iIdxCur ){\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);\n      }\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,\n                           iRowidReg, pPk->nKeyCol); VdbeCoverage(v);\n    }\n\n    /* If pIdx is an index on one or more expressions, then look through\n    ** all the expressions in pWInfo and try to transform matching expressions\n    ** into reference to index columns.\n    */\n    whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);\n\n\n    /* Record the instruction used to terminate the loop. */\n    if( pLoop->wsFlags & WHERE_ONEROW ){\n      pLevel->op = OP_Noop;\n    }else if( bRev ){\n      pLevel->op = OP_Prev;\n    }else{\n      pLevel->op = OP_Next;\n    }\n    pLevel->p1 = iIdxCur;\n    pLevel->p3 = (pLoop->wsFlags&WHERE_UNQ_WANTED)!=0 ? 1:0;\n    if( (pLoop->wsFlags & WHERE_CONSTRAINT)==0 ){\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }else{\n      assert( pLevel->p5==0 );\n    }\n    if( omitTable ) pIdx = 0;\n  }else\n\n#ifndef SQLITE_OMIT_OR_OPTIMIZATION\n  if( pLoop->wsFlags & WHERE_MULTI_OR ){\n    /* Case 5:  Two or more separately indexed terms connected by OR\n    **\n    ** Example:\n    **\n    **   CREATE TABLE t1(a,b,c,d);\n    **   CREATE INDEX i1 ON t1(a);\n    **   CREATE INDEX i2 ON t1(b);\n    **   CREATE INDEX i3 ON t1(c);\n    **\n    **   SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)\n    **\n    ** In the example, there are three indexed terms connected by OR.\n    ** The top of the loop looks like this:\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **\n    ** Then, for each indexed term, the following. The arguments to\n    ** RowSetTest are such that the rowid of the current row is inserted\n    ** into the RowSet. If it is already present, control skips the\n    ** Gosub opcode and jumps straight to the code generated by WhereEnd().\n    **\n    **        sqlite3WhereBegin(<term>)\n    **          RowSetTest                  # Insert rowid into rowset\n    **          Gosub      2 A\n    **        sqlite3WhereEnd()\n    **\n    ** Following the above, code to terminate the loop. Label A, the target\n    ** of the Gosub above, jumps to the instruction right after the Goto.\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **          Goto       B                # The loop is finished.\n    **\n    **       A: <loop body>                 # Return data, whatever.\n    **\n    **          Return     2                # Jump back to the Gosub\n    **\n    **       B: <after the loop>\n    **\n    ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then\n    ** use an ephemeral index instead of a RowSet to record the primary\n    ** keys of the rows we have already seen.\n    **\n    */\n    WhereClause *pOrWc;    /* The OR-clause broken out into subterms */\n    SrcList *pOrTab;       /* Shortened table list or OR-clause generation */\n    Index *pCov = 0;             /* Potential covering index (or NULL) */\n    int iCovCur = pParse->nTab++;  /* Cursor used for index scans (if any) */\n\n    int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */\n    int regRowset = 0;                        /* Register for RowSet object */\n    int regRowid = 0;                         /* Register holding rowid */\n    int iLoopBody = sqlite3VdbeMakeLabel(v);  /* Start of loop body */\n    int iRetInit;                             /* Address of regReturn init */\n    int untestedTerms = 0;             /* Some terms not completely tested */\n    int ii;                            /* Loop counter */\n    u16 wctrlFlags;                    /* Flags for sub-WHERE clause */\n    Expr *pAndExpr = 0;                /* An \".. AND (...)\" expression */\n    Table *pTab = pTabItem->pTab;\n\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->eOperator & WO_OR );\n    assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );\n    pOrWc = &pTerm->u.pOrInfo->wc;\n    pLevel->op = OP_Return;\n    pLevel->p1 = regReturn;\n\n    /* Set up a new SrcList in pOrTab containing the table being scanned\n    ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.\n    ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().\n    */\n    if( pWInfo->nLevel>1 ){\n      int nNotReady;                 /* The number of notReady tables */\n      struct SrcList_item *origSrc;     /* Original list of tables */\n      nNotReady = pWInfo->nLevel - iLevel - 1;\n      pOrTab = sqlite3StackAllocRaw(db,\n                            sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));\n      if( pOrTab==0 ) return notReady;\n      pOrTab->nAlloc = (u8)(nNotReady + 1);\n      pOrTab->nSrc = pOrTab->nAlloc;\n      memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));\n      origSrc = pWInfo->pTabList->a;\n      for(k=1; k<=nNotReady; k++){\n        memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));\n      }\n    }else{\n      pOrTab = pWInfo->pTabList;\n    }\n\n    /* Initialize the rowset register to contain NULL. An SQL NULL is \n    ** equivalent to an empty rowset.  Or, create an ephemeral index\n    ** capable of holding primary keys in the case of a WITHOUT ROWID.\n    **\n    ** Also initialize regReturn to contain the address of the instruction \n    ** immediately following the OP_Return at the bottom of the loop. This\n    ** is required in a few obscure LEFT JOIN cases where control jumps\n    ** over the top of the loop into the body of it. In this case the \n    ** correct response for the end-of-loop code (the OP_Return) is to \n    ** fall through to the next instruction, just as an OP_Next does if\n    ** called on an uninitialized cursor.\n    */\n    if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n      if( HasRowid(pTab) ){\n        regRowset = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset);\n      }else{\n        Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n        regRowset = pParse->nTab++;\n        sqlite3VdbeAddOp2(v, OP_OpenEphemeral, regRowset, pPk->nKeyCol);\n        sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n      }\n      regRowid = ++pParse->nMem;\n    }\n    iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);\n\n    /* If the original WHERE clause is z of the form:  (x1 OR x2 OR ...) AND y\n    ** Then for every term xN, evaluate as the subexpression: xN AND z\n    ** That way, terms in y that are factored into the disjunction will\n    ** be picked up by the recursive calls to sqlite3WhereBegin() below.\n    **\n    ** Actually, each subexpression is converted to \"xN AND w\" where w is\n    ** the \"interesting\" terms of z - terms that did not originate in the\n    ** ON or USING clause of a LEFT JOIN, and terms that are usable as \n    ** indices.\n    **\n    ** This optimization also only applies if the (x1 OR x2 OR ...) term\n    ** is not contained in the ON clause of a LEFT JOIN.\n    ** See ticket http://www.sqlite.org/src/info/f2369304e4\n    */\n    if( pWC->nTerm>1 ){\n      int iTerm;\n      for(iTerm=0; iTerm<pWC->nTerm; iTerm++){\n        Expr *pExpr = pWC->a[iTerm].pExpr;\n        if( &pWC->a[iTerm] == pTerm ) continue;\n        if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );\n        testcase( pWC->a[iTerm].wtFlags & TERM_CODED );\n        if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;\n        if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );\n        pExpr = sqlite3ExprDup(db, pExpr, 0);\n        pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);\n      }\n      if( pAndExpr ){\n        pAndExpr = sqlite3PExpr(pParse, TK_AND|TKFLG_DONTFOLD, 0, pAndExpr);\n      }\n    }\n\n    /* Run a separate WHERE clause for each term of the OR clause.  After\n    ** eliminating duplicates from other WHERE clauses, the action for each\n    ** sub-WHERE clause is to to invoke the main loop body as a subroutine.\n    */\n    wctrlFlags =  WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);\n    for(ii=0; ii<pOrWc->nTerm; ii++){\n      WhereTerm *pOrTerm = &pOrWc->a[ii];\n      if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){\n        WhereInfo *pSubWInfo;           /* Info for single OR-term scan */\n        Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */\n        int jmp1 = 0;                   /* Address of jump operation */\n        if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){\n          pAndExpr->pLeft = pOrExpr;\n          pOrExpr = pAndExpr;\n        }\n        /* Loop through table entries that match term pOrTerm. */\n        WHERETRACE(0xffff, (\"Subplan for OR-clause:\\n\"));\n        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,\n                                      wctrlFlags, iCovCur);\n        assert( pSubWInfo || pParse->nErr || db->mallocFailed );\n        if( pSubWInfo ){\n          WhereLoop *pSubLoop;\n          int addrExplain = sqlite3WhereExplainOneScan(\n              pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0\n          );\n          sqlite3WhereAddScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);\n\n          /* This is the sub-WHERE clause body.  First skip over\n          ** duplicate rows from prior sub-WHERE clauses, and record the\n          ** rowid (or PRIMARY KEY) for the current row so that the same\n          ** row will be skipped in subsequent sub-WHERE clauses.\n          */\n          if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n            int r;\n            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);\n            if( HasRowid(pTab) ){\n              r = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, regRowid, 0);\n              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,\n                                           r,iSet);\n              VdbeCoverage(v);\n            }else{\n              Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n              int nPk = pPk->nKeyCol;\n              int iPk;\n\n              /* Read the PK into an array of temp registers. */\n              r = sqlite3GetTempRange(pParse, nPk);\n              for(iPk=0; iPk<nPk; iPk++){\n                int iCol = pPk->aiColumn[iPk];\n                sqlite3ExprCodeGetColumnToReg(pParse, pTab, iCol, iCur, r+iPk);\n              }\n\n              /* Check if the temp table already contains this key. If so,\n              ** the row has already been included in the result set and\n              ** can be ignored (by jumping past the Gosub below). Otherwise,\n              ** insert the key into the temp table and proceed with processing\n              ** the row.\n              **\n              ** Use some of the same optimizations as OP_RowSetTest: If iSet\n              ** is zero, assume that the key cannot already be present in\n              ** the temp table. And if iSet is -1, assume that there is no \n              ** need to insert the key into the temp table, as it will never \n              ** be tested for.  */ \n              if( iSet ){\n                jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk);\n                VdbeCoverage(v);\n              }\n              if( iSet>=0 ){\n                sqlite3VdbeAddOp3(v, OP_MakeRecord, r, nPk, regRowid);\n                sqlite3VdbeAddOp4Int(v, OP_IdxInsert, regRowset, regRowid,\n                                     r, nPk);\n                if( iSet ) sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n              }\n\n              /* Release the array of temp registers */\n              sqlite3ReleaseTempRange(pParse, r, nPk);\n            }\n          }\n\n          /* Invoke the main loop body as a subroutine */\n          sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);\n\n          /* Jump here (skipping the main loop body subroutine) if the\n          ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */\n          if( jmp1 ) sqlite3VdbeJumpHere(v, jmp1);\n\n          /* The pSubWInfo->untestedTerms flag means that this OR term\n          ** contained one or more AND term from a notReady table.  The\n          ** terms from the notReady table could not be tested and will\n          ** need to be tested later.\n          */\n          if( pSubWInfo->untestedTerms ) untestedTerms = 1;\n\n          /* If all of the OR-connected terms are optimized using the same\n          ** index, and the index is opened using the same cursor number\n          ** by each call to sqlite3WhereBegin() made by this loop, it may\n          ** be possible to use that index as a covering index.\n          **\n          ** If the call to sqlite3WhereBegin() above resulted in a scan that\n          ** uses an index, and this is either the first OR-connected term\n          ** processed or the index is the same as that used by all previous\n          ** terms, set pCov to the candidate covering index. Otherwise, set \n          ** pCov to NULL to indicate that no candidate covering index will \n          ** be available.\n          */\n          pSubLoop = pSubWInfo->a[0].pWLoop;\n          assert( (pSubLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n          if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0\n           && (ii==0 || pSubLoop->u.btree.pIndex==pCov)\n           && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))\n          ){\n            assert( pSubWInfo->a[0].iIdxCur==iCovCur );\n            pCov = pSubLoop->u.btree.pIndex;\n          }else{\n            pCov = 0;\n          }\n\n          /* Finish the loop through table entries that match term pOrTerm. */\n          sqlite3WhereEnd(pSubWInfo);\n        }\n      }\n    }\n    pLevel->u.pCovidx = pCov;\n    if( pCov ) pLevel->iIdxCur = iCovCur;\n    if( pAndExpr ){\n      pAndExpr->pLeft = 0;\n      sqlite3ExprDelete(db, pAndExpr);\n    }\n    sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));\n    sqlite3VdbeGoto(v, pLevel->addrBrk);\n    sqlite3VdbeResolveLabel(v, iLoopBody);\n\n    if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);\n    if( !untestedTerms ) disableTerm(pLevel, pTerm);\n  }else\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n  {\n    /* Case 6:  There is no usable index.  We must do a complete\n    **          scan of the entire table.\n    */\n    static const u8 aStep[] = { OP_Next, OP_Prev };\n    static const u8 aStart[] = { OP_Rewind, OP_Last };\n    assert( bRev==0 || bRev==1 );\n    if( pTabItem->fg.isRecursive ){\n      /* Tables marked isRecursive have only a single row that is stored in\n      ** a pseudo-cursor.  No need to Rewind or Next such cursors. */\n      pLevel->op = OP_Noop;\n    }else{\n      codeCursorHint(pTabItem, pWInfo, pLevel, 0);\n      pLevel->op = aStep[bRev];\n      pLevel->p1 = iCur;\n      pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  pLevel->addrVisit = sqlite3VdbeCurrentAddr(v);\n#endif\n\n  /* Insert code to test every subexpression that can be completely\n  ** computed using the current set of tables.\n  **\n  ** This loop may run between one and three times, depending on the\n  ** constraints to be generated. The value of stack variable iLoop\n  ** determines the constraints coded by each iteration, as follows:\n  **\n  ** iLoop==1: Code only expressions that are entirely covered by pIdx.\n  ** iLoop==2: Code remaining expressions that do not contain correlated\n  **           sub-queries.  \n  ** iLoop==3: Code all remaining expressions.\n  **\n  ** An effort is made to skip unnecessary iterations of the loop.\n  */\n  iLoop = (pIdx ? 1 : 2);\n  do{\n    int iNext = 0;                /* Next value for iLoop */\n    for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n      Expr *pE;\n      int skipLikeAddr = 0;\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        testcase( pWInfo->untestedTerms==0\n            && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );\n        pWInfo->untestedTerms = 1;\n        continue;\n      }\n      pE = pTerm->pExpr;\n      assert( pE!=0 );\n      if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){\n        continue;\n      }\n      \n      if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){\n        iNext = 2;\n        continue;\n      }\n      if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){\n        if( iNext==0 ) iNext = 3;\n        continue;\n      }\n\n      if( pTerm->wtFlags & TERM_LIKECOND ){\n        /* If the TERM_LIKECOND flag is set, that means that the range search\n        ** is sufficient to guarantee that the LIKE operator is true, so we\n        ** can skip the call to the like(A,B) function.  But this only works\n        ** for strings.  So do not skip the call to the function on the pass\n        ** that compares BLOBs. */\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n        continue;\n#else\n        u32 x = pLevel->iLikeRepCntr;\n        assert( x>0 );\n        skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));\n        VdbeCoverage(v);\n#endif\n      }\n#ifdef WHERETRACE_ENABLED /* 0xffff */\n      if( sqlite3WhereTrace ){\n        VdbeNoopComment((v, \"WhereTerm[%d] (%p) priority=%d\",\n                         pWC->nTerm-j, pTerm, iLoop));\n      }\n#endif\n      sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);\n      if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    iLoop = iNext;\n  }while( iLoop>0 );\n\n  /* Insert code to test for implied constraints based on transitivity\n  ** of the \"==\" operator.\n  **\n  ** Example: If the WHERE clause contains \"t1.a=t2.b\" and \"t2.b=123\"\n  ** and we are coding the t1 loop and the t2 loop has not yet coded,\n  ** then we cannot use the \"t1.a=t2.b\" constraint, but we can code\n  ** the implied \"t1.a=123\" constraint.\n  */\n  for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n    Expr *pE, sEAlt;\n    WhereTerm *pAlt;\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue;\n    if( (pTerm->eOperator & WO_EQUIV)==0 ) continue;\n    if( pTerm->leftCursor!=iCur ) continue;\n    if( pLevel->iLeftJoin ) continue;\n    pE = pTerm->pExpr;\n    assert( !ExprHasProperty(pE, EP_FromJoin) );\n    assert( (pTerm->prereqRight & pLevel->notReady)!=0 );\n    pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,\n                    WO_EQ|WO_IN|WO_IS, 0);\n    if( pAlt==0 ) continue;\n    if( pAlt->wtFlags & (TERM_CODED) ) continue;\n    testcase( pAlt->eOperator & WO_EQ );\n    testcase( pAlt->eOperator & WO_IS );\n    testcase( pAlt->eOperator & WO_IN );\n    VdbeModuleComment((v, \"begin transitive constraint\"));\n    sEAlt = *pAlt->pExpr;\n    sEAlt.pLeft = pE->pLeft;\n    sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL);\n  }\n\n  /* For a LEFT OUTER JOIN, generate code that will record the fact that\n  ** at least one row of the right table has matched the left table.  \n  */\n  if( pLevel->iLeftJoin ){\n    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);\n    VdbeComment((v, \"record LEFT JOIN hit\"));\n    sqlite3ExprCacheClear(pParse);\n    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        assert( pWInfo->untestedTerms );\n        continue;\n      }\n      assert( pTerm->pExpr );\n      sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n  }\n\n  return pLevel->notReady;\n}\n\n/************** End of wherecode.c *******************************************/\n/************** Begin file whereexpr.c ***************************************/\n/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was originally part of where.c but was split out to improve\n** readability and editabiliity.  This file contains utility routines for\n** analyzing Expr objects in the WHERE clause.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"whereInt.h\" */\n\n/* Forward declarations */\nstatic void exprAnalyze(SrcList*, WhereClause*, int);\n\n/*\n** Deallocate all memory associated with a WhereOrInfo object.\n*/\nstatic void whereOrInfoDelete(sqlite3 *db, WhereOrInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Deallocate all memory associated with a WhereAndInfo object.\n*/\nstatic void whereAndInfoDelete(sqlite3 *db, WhereAndInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Add a single new WhereTerm entry to the WhereClause object pWC.\n** The new WhereTerm object is constructed from Expr p and with wtFlags.\n** The index in pWC->a[] of the new WhereTerm is returned on success.\n** 0 is returned if the new WhereTerm could not be added due to a memory\n** allocation error.  The memory allocation failure will be recorded in\n** the db->mallocFailed flag so that higher-level functions can detect it.\n**\n** This routine will increase the size of the pWC->a[] array as necessary.\n**\n** If the wtFlags argument includes TERM_DYNAMIC, then responsibility\n** for freeing the expression p is assumed by the WhereClause object pWC.\n** This is true even if this routine fails to allocate a new WhereTerm.\n**\n** WARNING:  This routine might reallocate the space used to store\n** WhereTerms.  All pointers to WhereTerms should be invalidated after\n** calling this routine.  Such pointers may be reinitialized by referencing\n** the pWC->a[] array.\n*/\nstatic int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){\n  WhereTerm *pTerm;\n  int idx;\n  testcase( wtFlags & TERM_VIRTUAL );\n  if( pWC->nTerm>=pWC->nSlot ){\n    WhereTerm *pOld = pWC->a;\n    sqlite3 *db = pWC->pWInfo->pParse->db;\n    pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 );\n    if( pWC->a==0 ){\n      if( wtFlags & TERM_DYNAMIC ){\n        sqlite3ExprDelete(db, p);\n      }\n      pWC->a = pOld;\n      return 0;\n    }\n    memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);\n    if( pOld!=pWC->aStatic ){\n      sqlite3DbFree(db, pOld);\n    }\n    pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);\n  }\n  pTerm = &pWC->a[idx = pWC->nTerm++];\n  if( p && ExprHasProperty(p, EP_Unlikely) ){\n    pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;\n  }else{\n    pTerm->truthProb = 1;\n  }\n  pTerm->pExpr = sqlite3ExprSkipCollate(p);\n  pTerm->wtFlags = wtFlags;\n  pTerm->pWC = pWC;\n  pTerm->iParent = -1;\n  memset(&pTerm->eOperator, 0,\n         sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));\n  return idx;\n}\n\n/*\n** Return TRUE if the given operator is one of the operators that is\n** allowed for an indexable WHERE clause term.  The allowed operators are\n** \"=\", \"<\", \">\", \"<=\", \">=\", \"IN\", \"IS\", and \"IS NULL\"\n*/\nstatic int allowedOp(int op){\n  assert( TK_GT>TK_EQ && TK_GT<TK_GE );\n  assert( TK_LT>TK_EQ && TK_LT<TK_GE );\n  assert( TK_LE>TK_EQ && TK_LE<TK_GE );\n  assert( TK_GE==TK_EQ+4 );\n  return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS;\n}\n\n/*\n** Commute a comparison operator.  Expressions of the form \"X op Y\"\n** are converted into \"Y op X\".\n**\n** If left/right precedence rules come into play when determining the\n** collating sequence, then COLLATE operators are adjusted to ensure\n** that the collating sequence does not change.  For example:\n** \"Y collate NOCASE op X\" becomes \"X op Y\" because any collation sequence on\n** the left hand side of a comparison overrides any collation sequence \n** attached to the right. For the same reason the EP_Collate flag\n** is not commuted.\n*/\nstatic void exprCommute(Parse *pParse, Expr *pExpr){\n  u16 expRight = (pExpr->pRight->flags & EP_Collate);\n  u16 expLeft = (pExpr->pLeft->flags & EP_Collate);\n  assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );\n  if( expRight==expLeft ){\n    /* Either X and Y both have COLLATE operator or neither do */\n    if( expRight ){\n      /* Both X and Y have COLLATE operators.  Make sure X is always\n      ** used by clearing the EP_Collate flag from Y. */\n      pExpr->pRight->flags &= ~EP_Collate;\n    }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){\n      /* Neither X nor Y have COLLATE operators, but X has a non-default\n      ** collating sequence.  So add the EP_Collate marker on X to cause\n      ** it to be searched first. */\n      pExpr->pLeft->flags |= EP_Collate;\n    }\n  }\n  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);\n  if( pExpr->op>=TK_GT ){\n    assert( TK_LT==TK_GT+2 );\n    assert( TK_GE==TK_LE+2 );\n    assert( TK_GT>TK_EQ );\n    assert( TK_GT<TK_LE );\n    assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );\n    pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;\n  }\n}\n\n/*\n** Translate from TK_xx operator to WO_xx bitmask.\n*/\nstatic u16 operatorMask(int op){\n  u16 c;\n  assert( allowedOp(op) );\n  if( op==TK_IN ){\n    c = WO_IN;\n  }else if( op==TK_ISNULL ){\n    c = WO_ISNULL;\n  }else if( op==TK_IS ){\n    c = WO_IS;\n  }else{\n    assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff );\n    c = (u16)(WO_EQ<<(op-TK_EQ));\n  }\n  assert( op!=TK_ISNULL || c==WO_ISNULL );\n  assert( op!=TK_IN || c==WO_IN );\n  assert( op!=TK_EQ || c==WO_EQ );\n  assert( op!=TK_LT || c==WO_LT );\n  assert( op!=TK_LE || c==WO_LE );\n  assert( op!=TK_GT || c==WO_GT );\n  assert( op!=TK_GE || c==WO_GE );\n  assert( op!=TK_IS || c==WO_IS );\n  return c;\n}\n\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n/*\n** Check to see if the given expression is a LIKE or GLOB operator that\n** can be optimized using inequality constraints.  Return TRUE if it is\n** so and false if not.\n**\n** In order for the operator to be optimizible, the RHS must be a string\n** literal that does not begin with a wildcard.  The LHS must be a column\n** that may only be NULL, a string, or a BLOB, never a number. (This means\n** that virtual tables cannot participate in the LIKE optimization.)  The\n** collating sequence for the column on the LHS must be appropriate for\n** the operator.\n*/\nstatic int isLikeOrGlob(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* Test this expression */\n  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */\n  int *pisComplete, /* True if the only wildcard is % in the last character */\n  int *pnoCase      /* True if uppercase is equivalent to lowercase */\n){\n  const u8 *z = 0;         /* String on RHS of LIKE operator */\n  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */\n  ExprList *pList;           /* List of operands to the LIKE operator */\n  int c;                     /* One character in z[] */\n  int cnt;                   /* Number of non-wildcard prefix characters */\n  char wc[4];                /* Wildcard characters */\n  sqlite3 *db = pParse->db;  /* Database connection */\n  sqlite3_value *pVal = 0;\n  int op;                    /* Opcode of pRight */\n  int rc;                    /* Result code to return */\n\n  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){\n    return 0;\n  }\n#ifdef SQLITE_EBCDIC\n  if( *pnoCase ) return 0;\n#endif\n  pList = pExpr->x.pList;\n  pLeft = pList->a[1].pExpr;\n\n  pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);\n  op = pRight->op;\n  if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *pReprepare = pParse->pReprepare;\n    int iCol = pRight->iColumn;\n    pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);\n    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){\n      z = sqlite3_value_text(pVal);\n    }\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);\n    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );\n  }else if( op==TK_STRING ){\n    z = (u8*)pRight->u.zToken;\n  }\n  if( z ){\n\n    /* If the RHS begins with a digit or a minus sign, then the LHS must\n    ** be an ordinary column (not a virtual table column) with TEXT affinity.\n    ** Otherwise the LHS might be numeric and \"lhs >= rhs\" would be false\n    ** even though \"lhs LIKE rhs\" is true.  But if the RHS does not start\n    ** with a digit or '-', then \"lhs LIKE rhs\" will always be false if\n    ** the LHS is numeric and so the optimization still works.\n    */\n    if( sqlite3Isdigit(z[0]) || z[0]=='-' ){\n      if( pLeft->op!=TK_COLUMN \n       || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT \n       || IsVirtual(pLeft->pTab)  /* Value might be numeric */\n      ){\n        sqlite3ValueFree(pVal);\n        return 0;\n      }\n    }\n\n    /* Count the number of prefix characters prior to the first wildcard */\n    cnt = 0;\n    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){\n      cnt++;\n      if( c==wc[3] && z[cnt]!=0 ) cnt++;\n    }\n\n    /* The optimization is possible only if (1) the pattern does not begin\n    ** with a wildcard and if (2) the non-wildcard prefix does not end with\n    ** an (illegal 0xff) character.  The second condition is necessary so\n    ** that we can increment the prefix key to find an upper bound for the\n    ** range search. \n    */\n    if( cnt!=0 && 255!=(u8)z[cnt-1] ){\n      Expr *pPrefix;\n\n      /* A \"complete\" match if the pattern ends with \"*\" or \"%\" */\n      *pisComplete = c==wc[0] && z[cnt+1]==0;\n\n      /* Get the pattern prefix.  Remove all escapes from the prefix. */\n      pPrefix = sqlite3Expr(db, TK_STRING, (char*)z);\n      if( pPrefix ){\n        int iFrom, iTo;\n        char *zNew = pPrefix->u.zToken;\n        zNew[cnt] = 0;\n        for(iFrom=iTo=0; iFrom<cnt; iFrom++){\n          if( zNew[iFrom]==wc[3] ) iFrom++;\n          zNew[iTo++] = zNew[iFrom];\n        }\n        zNew[iTo] = 0;\n      }\n      *ppPrefix = pPrefix;\n\n      /* If the RHS pattern is a bound parameter, make arrangements to\n      ** reprepare the statement when that parameter is rebound */\n      if( op==TK_VARIABLE ){\n        Vdbe *v = pParse->pVdbe;\n        sqlite3VdbeSetVarmask(v, pRight->iColumn);\n        if( *pisComplete && pRight->u.zToken[1] ){\n          /* If the rhs of the LIKE expression is a variable, and the current\n          ** value of the variable means there is no need to invoke the LIKE\n          ** function, then no OP_Variable will be added to the program.\n          ** This causes problems for the sqlite3_bind_parameter_name()\n          ** API. To work around them, add a dummy OP_Variable here.\n          */ \n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3ExprCodeTarget(pParse, pRight, r1);\n          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);\n          sqlite3ReleaseTempReg(pParse, r1);\n        }\n      }\n    }else{\n      z = 0;\n    }\n  }\n\n  rc = (z!=0);\n  sqlite3ValueFree(pVal);\n  return rc;\n}\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Check to see if the pExpr expression is a form that needs to be passed\n** to the xBestIndex method of virtual tables.  Forms of interest include:\n**\n**          Expression                   Virtual Table Operator\n**          -----------------------      ---------------------------------\n**      1.  column MATCH expr            SQLITE_INDEX_CONSTRAINT_MATCH\n**      2.  column GLOB expr             SQLITE_INDEX_CONSTRAINT_GLOB\n**      3.  column LIKE expr             SQLITE_INDEX_CONSTRAINT_LIKE\n**      4.  column REGEXP expr           SQLITE_INDEX_CONSTRAINT_REGEXP\n**      5.  column != expr               SQLITE_INDEX_CONSTRAINT_NE\n**      6.  expr != column               SQLITE_INDEX_CONSTRAINT_NE\n**      7.  column IS NOT expr           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      8.  expr IS NOT column           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      9.  column IS NOT NULL           SQLITE_INDEX_CONSTRAINT_ISNOTNULL\n**\n** In every case, \"column\" must be a column of a virtual table.  If there\n** is a match, set *ppLeft to the \"column\" expression, set *ppRight to the \n** \"expr\" expression (even though in forms (6) and (8) the column is on the\n** right and the expression is on the left).  Also set *peOp2 to the\n** appropriate virtual table operator.  The return value is 1 or 2 if there\n** is a match.  The usual return is 1, but if the RHS is also a column\n** of virtual table in forms (5) or (7) then return 2.\n**\n** If the expression matches none of the patterns above, return 0.\n*/\nstatic int isAuxiliaryVtabOperator(\n  Expr *pExpr,                    /* Test this expression */\n  unsigned char *peOp2,           /* OUT: 0 for MATCH, or else an op2 value */\n  Expr **ppLeft,                  /* Column expression to left of MATCH/op2 */\n  Expr **ppRight                  /* Expression to left of MATCH/op2 */\n){\n  if( pExpr->op==TK_FUNCTION ){\n    static const struct Op2 {\n      const char *zOp;\n      unsigned char eOp2;\n    } aOp[] = {\n      { \"match\",  SQLITE_INDEX_CONSTRAINT_MATCH },\n      { \"glob\",   SQLITE_INDEX_CONSTRAINT_GLOB },\n      { \"like\",   SQLITE_INDEX_CONSTRAINT_LIKE },\n      { \"regexp\", SQLITE_INDEX_CONSTRAINT_REGEXP }\n    };\n    ExprList *pList;\n    Expr *pCol;                     /* Column reference */\n    int i;\n\n    pList = pExpr->x.pList;\n    if( pList==0 || pList->nExpr!=2 ){\n      return 0;\n    }\n    pCol = pList->a[1].pExpr;\n    if( pCol->op!=TK_COLUMN || !IsVirtual(pCol->pTab) ){\n      return 0;\n    }\n    for(i=0; i<ArraySize(aOp); i++){\n      if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){\n        *peOp2 = aOp[i].eOp2;\n        *ppRight = pList->a[0].pExpr;\n        *ppLeft = pCol;\n        return 1;\n      }\n    }\n  }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){\n    int res = 0;\n    Expr *pLeft = pExpr->pLeft;\n    Expr *pRight = pExpr->pRight;\n    if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->pTab) ){\n      res++;\n    }\n    if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->pTab) ){\n      res++;\n      SWAP(Expr*, pLeft, pRight);\n    }\n    *ppLeft = pLeft;\n    *ppRight = pRight;\n    if( pExpr->op==TK_NE ) *peOp2 = SQLITE_INDEX_CONSTRAINT_NE;\n    if( pExpr->op==TK_ISNOT ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOT;\n    if( pExpr->op==TK_NOTNULL ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOTNULL;\n    return res;\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** If the pBase expression originated in the ON or USING clause of\n** a join, then transfer the appropriate markings over to derived.\n*/\nstatic void transferJoinMarkings(Expr *pDerived, Expr *pBase){\n  if( pDerived ){\n    pDerived->flags |= pBase->flags & EP_FromJoin;\n    pDerived->iRightJoinTable = pBase->iRightJoinTable;\n  }\n}\n\n/*\n** Mark term iChild as being a child of term iParent\n*/\nstatic void markTermAsChild(WhereClause *pWC, int iChild, int iParent){\n  pWC->a[iChild].iParent = iParent;\n  pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;\n  pWC->a[iParent].nChild++;\n}\n\n/*\n** Return the N-th AND-connected subterm of pTerm.  Or if pTerm is not\n** a conjunction, then return just pTerm when N==0.  If N is exceeds\n** the number of available subterms, return NULL.\n*/\nstatic WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){\n  if( pTerm->eOperator!=WO_AND ){\n    return N==0 ? pTerm : 0;\n  }\n  if( N<pTerm->u.pAndInfo->wc.nTerm ){\n    return &pTerm->u.pAndInfo->wc.a[N];\n  }\n  return 0;\n}\n\n/*\n** Subterms pOne and pTwo are contained within WHERE clause pWC.  The\n** two subterms are in disjunction - they are OR-ed together.\n**\n** If these two terms are both of the form:  \"A op B\" with the same\n** A and B values but different operators and if the operators are\n** compatible (if one is = and the other is <, for example) then\n** add a new virtual AND term to pWC that is the combination of the\n** two.\n**\n** Some examples:\n**\n**    x<y OR x=y    -->     x<=y\n**    x=y OR x=y    -->     x=y\n**    x<=y OR x<y   -->     x<=y\n**\n** The following is NOT generated:\n**\n**    x<y OR x>y    -->     x!=y     \n*/\nstatic void whereCombineDisjuncts(\n  SrcList *pSrc,         /* the FROM clause */\n  WhereClause *pWC,      /* The complete WHERE clause */\n  WhereTerm *pOne,       /* First disjunct */\n  WhereTerm *pTwo        /* Second disjunct */\n){\n  u16 eOp = pOne->eOperator | pTwo->eOperator;\n  sqlite3 *db;           /* Database connection (for malloc) */\n  Expr *pNew;            /* New virtual expression */\n  int op;                /* Operator for the combined expression */\n  int idxNew;            /* Index in pWC of the next virtual term */\n\n  if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp\n   && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;\n  assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );\n  assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );\n  if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;\n  if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;\n  /* If we reach this point, it means the two subterms can be combined */\n  if( (eOp & (eOp-1))!=0 ){\n    if( eOp & (WO_LT|WO_LE) ){\n      eOp = WO_LE;\n    }else{\n      assert( eOp & (WO_GT|WO_GE) );\n      eOp = WO_GE;\n    }\n  }\n  db = pWC->pWInfo->pParse->db;\n  pNew = sqlite3ExprDup(db, pOne->pExpr, 0);\n  if( pNew==0 ) return;\n  for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }\n  pNew->op = op;\n  idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n  exprAnalyze(pSrc, pWC, idxNew);\n}\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Analyze a term that consists of two or more OR-connected\n** subterms.  So in:\n**\n**     ... WHERE  (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13)\n**                          ^^^^^^^^^^^^^^^^^^^^\n**\n** This routine analyzes terms such as the middle term in the above example.\n** A WhereOrTerm object is computed and attached to the term under\n** analysis, regardless of the outcome of the analysis.  Hence:\n**\n**     WhereTerm.wtFlags   |=  TERM_ORINFO\n**     WhereTerm.u.pOrInfo  =  a dynamically allocated WhereOrTerm object\n**\n** The term being analyzed must have two or more of OR-connected subterms.\n** A single subterm might be a set of AND-connected sub-subterms.\n** Examples of terms under analysis:\n**\n**     (A)     t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5\n**     (B)     x=expr1 OR expr2=x OR x=expr3\n**     (C)     t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)\n**     (D)     x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')\n**     (E)     (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)\n**     (F)     x>A OR (x=A AND y>=B)\n**\n** CASE 1:\n**\n** If all subterms are of the form T.C=expr for some single column of C and\n** a single table T (as shown in example B above) then create a new virtual\n** term that is an equivalent IN expression.  In other words, if the term\n** being analyzed is:\n**\n**      x = expr1  OR  expr2 = x  OR  x = expr3\n**\n** then create a new virtual term like this:\n**\n**      x IN (expr1,expr2,expr3)\n**\n** CASE 2:\n**\n** If there are exactly two disjuncts and one side has x>A and the other side\n** has x=A (for the same x and A) then add a new virtual conjunct term to the\n** WHERE clause of the form \"x>=A\".  Example:\n**\n**      x>A OR (x=A AND y>B)    adds:    x>=A\n**\n** The added conjunct can sometimes be helpful in query planning.\n**\n** CASE 3:\n**\n** If all subterms are indexable by a single table T, then set\n**\n**     WhereTerm.eOperator              =  WO_OR\n**     WhereTerm.u.pOrInfo->indexable  |=  the cursor number for table T\n**\n** A subterm is \"indexable\" if it is of the form\n** \"T.C <op> <expr>\" where C is any column of table T and \n** <op> is one of \"=\", \"<\", \"<=\", \">\", \">=\", \"IS NULL\", or \"IN\".\n** A subterm is also indexable if it is an AND of two or more\n** subsubterms at least one of which is indexable.  Indexable AND \n** subterms have their eOperator set to WO_AND and they have\n** u.pAndInfo set to a dynamically allocated WhereAndTerm object.\n**\n** From another point of view, \"indexable\" means that the subterm could\n** potentially be used with an index if an appropriate index exists.\n** This analysis does not consider whether or not the index exists; that\n** is decided elsewhere.  This analysis only looks at whether subterms\n** appropriate for indexing exist.\n**\n** All examples A through E above satisfy case 3.  But if a term\n** also satisfies case 1 (such as B) we know that the optimizer will\n** always prefer case 1, so in that case we pretend that case 3 is not\n** satisfied.\n**\n** It might be the case that multiple tables are indexable.  For example,\n** (E) above is indexable on tables P, Q, and R.\n**\n** Terms that satisfy case 3 are candidates for lookup by using\n** separate indices to find rowids for each subterm and composing\n** the union of all rowids using a RowSet object.  This is similar\n** to \"bitmap indices\" in other database engines.\n**\n** OTHERWISE:\n**\n** If none of cases 1, 2, or 3 apply, then leave the eOperator set to\n** zero.  This term is not useful for search.\n*/\nstatic void exprAnalyzeOrTerm(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the complete WHERE clause */\n  int idxTerm               /* Index of the OR-term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo;        /* WHERE clause processing context */\n  Parse *pParse = pWInfo->pParse;         /* Parser context */\n  sqlite3 *db = pParse->db;               /* Database connection */\n  WhereTerm *pTerm = &pWC->a[idxTerm];    /* The term to be analyzed */\n  Expr *pExpr = pTerm->pExpr;             /* The expression of the term */\n  int i;                                  /* Loop counters */\n  WhereClause *pOrWc;       /* Breakup of pTerm into subterms */\n  WhereTerm *pOrTerm;       /* A Sub-term within the pOrWc */\n  WhereOrInfo *pOrInfo;     /* Additional information associated with pTerm */\n  Bitmask chngToIN;         /* Tables that might satisfy case 1 */\n  Bitmask indexable;        /* Tables that are indexable, satisfying case 2 */\n\n  /*\n  ** Break the OR clause into its separate subterms.  The subterms are\n  ** stored in a WhereClause structure containing within the WhereOrInfo\n  ** object that is attached to the original OR clause term.\n  */\n  assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );\n  assert( pExpr->op==TK_OR );\n  pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));\n  if( pOrInfo==0 ) return;\n  pTerm->wtFlags |= TERM_ORINFO;\n  pOrWc = &pOrInfo->wc;\n  memset(pOrWc->aStatic, 0, sizeof(pOrWc->aStatic));\n  sqlite3WhereClauseInit(pOrWc, pWInfo);\n  sqlite3WhereSplit(pOrWc, pExpr, TK_OR);\n  sqlite3WhereExprAnalyze(pSrc, pOrWc);\n  if( db->mallocFailed ) return;\n  assert( pOrWc->nTerm>=2 );\n\n  /*\n  ** Compute the set of tables that might satisfy cases 1 or 3.\n  */\n  indexable = ~(Bitmask)0;\n  chngToIN = ~(Bitmask)0;\n  for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0 && indexable; i--, pOrTerm++){\n    if( (pOrTerm->eOperator & WO_SINGLE)==0 ){\n      WhereAndInfo *pAndInfo;\n      assert( (pOrTerm->wtFlags & (TERM_ANDINFO|TERM_ORINFO))==0 );\n      chngToIN = 0;\n      pAndInfo = sqlite3DbMallocRawNN(db, sizeof(*pAndInfo));\n      if( pAndInfo ){\n        WhereClause *pAndWC;\n        WhereTerm *pAndTerm;\n        int j;\n        Bitmask b = 0;\n        pOrTerm->u.pAndInfo = pAndInfo;\n        pOrTerm->wtFlags |= TERM_ANDINFO;\n        pOrTerm->eOperator = WO_AND;\n        pAndWC = &pAndInfo->wc;\n        memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));\n        sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);\n        sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);\n        sqlite3WhereExprAnalyze(pSrc, pAndWC);\n        pAndWC->pOuter = pWC;\n        if( !db->mallocFailed ){\n          for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){\n            assert( pAndTerm->pExpr );\n            if( allowedOp(pAndTerm->pExpr->op) \n             || pAndTerm->eOperator==WO_AUX\n            ){\n              b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);\n            }\n          }\n        }\n        indexable &= b;\n      }\n    }else if( pOrTerm->wtFlags & TERM_COPIED ){\n      /* Skip this term for now.  We revisit it when we process the\n      ** corresponding TERM_VIRTUAL term */\n    }else{\n      Bitmask b;\n      b = sqlite3WhereGetMask(&pWInfo->sMaskSet, pOrTerm->leftCursor);\n      if( pOrTerm->wtFlags & TERM_VIRTUAL ){\n        WhereTerm *pOther = &pOrWc->a[pOrTerm->iParent];\n        b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pOther->leftCursor);\n      }\n      indexable &= b;\n      if( (pOrTerm->eOperator & WO_EQ)==0 ){\n        chngToIN = 0;\n      }else{\n        chngToIN &= b;\n      }\n    }\n  }\n\n  /*\n  ** Record the set of tables that satisfy case 3.  The set might be\n  ** empty.\n  */\n  pOrInfo->indexable = indexable;\n  pTerm->eOperator = indexable==0 ? 0 : WO_OR;\n\n  /* For a two-way OR, attempt to implementation case 2.\n  */\n  if( indexable && pOrWc->nTerm==2 ){\n    int iOne = 0;\n    WhereTerm *pOne;\n    while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){\n      int iTwo = 0;\n      WhereTerm *pTwo;\n      while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){\n        whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);\n      }\n    }\n  }\n\n  /*\n  ** chngToIN holds a set of tables that *might* satisfy case 1.  But\n  ** we have to do some additional checking to see if case 1 really\n  ** is satisfied.\n  **\n  ** chngToIN will hold either 0, 1, or 2 bits.  The 0-bit case means\n  ** that there is no possibility of transforming the OR clause into an\n  ** IN operator because one or more terms in the OR clause contain\n  ** something other than == on a column in the single table.  The 1-bit\n  ** case means that every term of the OR clause is of the form\n  ** \"table.column=expr\" for some single table.  The one bit that is set\n  ** will correspond to the common table.  We still need to check to make\n  ** sure the same column is used on all terms.  The 2-bit case is when\n  ** the all terms are of the form \"table1.column=table2.column\".  It\n  ** might be possible to form an IN operator with either table1.column\n  ** or table2.column as the LHS if either is common to every term of\n  ** the OR clause.\n  **\n  ** Note that terms of the form \"table.column1=table.column2\" (the\n  ** same table on both sizes of the ==) cannot be optimized.\n  */\n  if( chngToIN ){\n    int okToChngToIN = 0;     /* True if the conversion to IN is valid */\n    int iColumn = -1;         /* Column index on lhs of IN operator */\n    int iCursor = -1;         /* Table cursor common to all terms */\n    int j = 0;                /* Loop counter */\n\n    /* Search for a table and column that appears on one side or the\n    ** other of the == operator in every subterm.  That table and column\n    ** will be recorded in iCursor and iColumn.  There might not be any\n    ** such table and column.  Set okToChngToIN if an appropriate table\n    ** and column is found but leave okToChngToIN false if not found.\n    */\n    for(j=0; j<2 && !okToChngToIN; j++){\n      pOrTerm = pOrWc->a;\n      for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        pOrTerm->wtFlags &= ~TERM_OR_OK;\n        if( pOrTerm->leftCursor==iCursor ){\n          /* This is the 2-bit case and we are on the second iteration and\n          ** current term is from the first iteration.  So skip this term. */\n          assert( j==1 );\n          continue;\n        }\n        if( (chngToIN & sqlite3WhereGetMask(&pWInfo->sMaskSet,\n                                            pOrTerm->leftCursor))==0 ){\n          /* This term must be of the form t1.a==t2.b where t2 is in the\n          ** chngToIN set but t1 is not.  This term will be either preceded\n          ** or follwed by an inverted copy (t2.b==t1.a).  Skip this term \n          ** and use its inversion. */\n          testcase( pOrTerm->wtFlags & TERM_COPIED );\n          testcase( pOrTerm->wtFlags & TERM_VIRTUAL );\n          assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );\n          continue;\n        }\n        iColumn = pOrTerm->u.leftColumn;\n        iCursor = pOrTerm->leftCursor;\n        break;\n      }\n      if( i<0 ){\n        /* No candidate table+column was found.  This can only occur\n        ** on the second iteration */\n        assert( j==1 );\n        assert( IsPowerOfTwo(chngToIN) );\n        assert( chngToIN==sqlite3WhereGetMask(&pWInfo->sMaskSet, iCursor) );\n        break;\n      }\n      testcase( j==1 );\n\n      /* We have found a candidate table and column.  Check to see if that\n      ** table and column is common to every term in the OR clause */\n      okToChngToIN = 1;\n      for(; i>=0 && okToChngToIN; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        if( pOrTerm->leftCursor!=iCursor ){\n          pOrTerm->wtFlags &= ~TERM_OR_OK;\n        }else if( pOrTerm->u.leftColumn!=iColumn ){\n          okToChngToIN = 0;\n        }else{\n          int affLeft, affRight;\n          /* If the right-hand side is also a column, then the affinities\n          ** of both right and left sides must be such that no type\n          ** conversions are required on the right.  (Ticket #2249)\n          */\n          affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);\n          affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);\n          if( affRight!=0 && affRight!=affLeft ){\n            okToChngToIN = 0;\n          }else{\n            pOrTerm->wtFlags |= TERM_OR_OK;\n          }\n        }\n      }\n    }\n\n    /* At this point, okToChngToIN is true if original pTerm satisfies\n    ** case 1.  In that case, construct a new virtual term that is \n    ** pTerm converted into an IN operator.\n    */\n    if( okToChngToIN ){\n      Expr *pDup;            /* A transient duplicate expression */\n      ExprList *pList = 0;   /* The RHS of the IN operator */\n      Expr *pLeft = 0;       /* The LHS of the IN operator */\n      Expr *pNew;            /* The complete IN operator */\n\n      for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){\n        if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;\n        assert( pOrTerm->eOperator & WO_EQ );\n        assert( pOrTerm->leftCursor==iCursor );\n        assert( pOrTerm->u.leftColumn==iColumn );\n        pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);\n        pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);\n        pLeft = pOrTerm->pExpr->pLeft;\n      }\n      assert( pLeft!=0 );\n      pDup = sqlite3ExprDup(db, pLeft, 0);\n      pNew = sqlite3PExpr(pParse, TK_IN, pDup, 0);\n      if( pNew ){\n        int idxNew;\n        transferJoinMarkings(pNew, pExpr);\n        assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n        pNew->x.pList = pList;\n        idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        exprAnalyze(pSrc, pWC, idxNew);\n        pTerm = &pWC->a[idxTerm];\n        markTermAsChild(pWC, idxNew, idxTerm);\n      }else{\n        sqlite3ExprListDelete(db, pList);\n      }\n      pTerm->eOperator = WO_NOOP;  /* case 1 trumps case 3 */\n    }\n  }\n}\n#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */\n\n/*\n** We already know that pExpr is a binary operator where both operands are\n** column references.  This routine checks to see if pExpr is an equivalence\n** relation:\n**   1.  The SQLITE_Transitive optimization must be enabled\n**   2.  Must be either an == or an IS operator\n**   3.  Not originating in the ON clause of an OUTER JOIN\n**   4.  The affinities of A and B must be compatible\n**   5a. Both operands use the same collating sequence OR\n**   5b. The overall collating sequence is BINARY\n** If this routine returns TRUE, that means that the RHS can be substituted\n** for the LHS anyplace else in the WHERE clause where the LHS column occurs.\n** This is an optimization.  No harm comes from returning 0.  But if 1 is\n** returned when it should not be, then incorrect answers might result.\n*/\nstatic int termIsEquivalence(Parse *pParse, Expr *pExpr){\n  char aff1, aff2;\n  CollSeq *pColl;\n  if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0;\n  if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0;\n  aff1 = sqlite3ExprAffinity(pExpr->pLeft);\n  aff2 = sqlite3ExprAffinity(pExpr->pRight);\n  if( aff1!=aff2\n   && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))\n  ){\n    return 0;\n  }\n  pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);\n  if( pColl==0 || sqlite3StrICmp(pColl->zName, \"BINARY\")==0 ) return 1;\n  return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);\n}\n\n/*\n** Recursively walk the expressions of a SELECT statement and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nstatic Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){\n  Bitmask mask = 0;\n  while( pS ){\n    SrcList *pSrc = pS->pSrc;\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pEList);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pGroupBy);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pOrderBy);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);\n    if( ALWAYS(pSrc!=0) ){\n      int i;\n      for(i=0; i<pSrc->nSrc; i++){\n        mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);\n        mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);\n      }\n    }\n    pS = pS->pPrior;\n  }\n  return mask;\n}\n\n/*\n** Expression pExpr is one operand of a comparison operator that might\n** be useful for indexing.  This routine checks to see if pExpr appears\n** in any index.  Return TRUE (1) if pExpr is an indexed term and return\n** FALSE (0) if not.  If TRUE is returned, also set aiCurCol[0] to the cursor\n** number of the table that is indexed and aiCurCol[1] to the column number\n** of the column that is indexed, or XN_EXPR (-2) if an expression is being\n** indexed.\n**\n** If pExpr is a TK_COLUMN column reference, then this routine always returns\n** true even if that particular column is not indexed, because the column\n** might be added to an automatic index later.\n*/\nstatic SQLITE_NOINLINE int exprMightBeIndexed2(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor and column here */\n  Expr *pExpr            /* An operand of a comparison operator */\n){\n  Index *pIdx;\n  int i;\n  int iCur;\n  for(i=0; mPrereq>1; i++, mPrereq>>=1){}\n  iCur = pFrom->a[i].iCursor;\n  for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->aColExpr==0 ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( pIdx->aiColumn[i]!=XN_EXPR ) continue;\n      if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){\n        aiCurCol[0] = iCur;\n        aiCurCol[1] = XN_EXPR;\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\nstatic int exprMightBeIndexed(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor & column here */\n  Expr *pExpr,           /* An operand of a comparison operator */\n  int op                 /* The specific comparison operator */\n){\n  /* If this expression is a vector to the left or right of a \n  ** inequality constraint (>, <, >= or <=), perform the processing \n  ** on the first element of the vector.  */\n  assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );\n  assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );\n  assert( op<=TK_GE );\n  if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){\n    pExpr = pExpr->x.pList->a[0].pExpr;\n  }\n\n  if( pExpr->op==TK_COLUMN ){\n    aiCurCol[0] = pExpr->iTable;\n    aiCurCol[1] = pExpr->iColumn;\n    return 1;\n  }\n  if( mPrereq==0 ) return 0;                 /* No table references */\n  if( (mPrereq&(mPrereq-1))!=0 ) return 0;   /* Refs more than one table */\n  return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);\n}\n\n/*\n** The input to this routine is an WhereTerm structure with only the\n** \"pExpr\" field filled in.  The job of this routine is to analyze the\n** subexpression and populate all the other fields of the WhereTerm\n** structure.\n**\n** If the expression is of the form \"<expr> <op> X\" it gets commuted\n** to the standard form of \"X <op> <expr>\".\n**\n** If the expression is of the form \"X <op> Y\" where both X and Y are\n** columns, then the original expression is unchanged and a new virtual\n** term of the form \"Y <op> X\" is added to the WHERE clause and\n** analyzed separately.  The original term is marked with TERM_COPIED\n** and the new term is marked with TERM_DYNAMIC (because it's pExpr\n** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it\n** is a commuted copy of a prior term.)  The original term has nChild=1\n** and the copy has idxParent set to the index of the original term.\n*/\nstatic void exprAnalyze(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the WHERE clause */\n  int idxTerm               /* Index of the term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo; /* WHERE clause processing context */\n  WhereTerm *pTerm;                /* The term to be analyzed */\n  WhereMaskSet *pMaskSet;          /* Set of table index masks */\n  Expr *pExpr;                     /* The expression to be analyzed */\n  Bitmask prereqLeft;              /* Prerequesites of the pExpr->pLeft */\n  Bitmask prereqAll;               /* Prerequesites of pExpr */\n  Bitmask extraRight = 0;          /* Extra dependencies on LEFT JOIN */\n  Expr *pStr1 = 0;                 /* RHS of LIKE/GLOB operator */\n  int isComplete = 0;              /* RHS of LIKE/GLOB ends with wildcard */\n  int noCase = 0;                  /* uppercase equivalent to lowercase */\n  int op;                          /* Top-level operator.  pExpr->op */\n  Parse *pParse = pWInfo->pParse;  /* Parsing context */\n  sqlite3 *db = pParse->db;        /* Database connection */\n  unsigned char eOp2;              /* op2 value for LIKE/REGEXP/GLOB */\n  int nLeft;                       /* Number of elements on left side vector */\n\n  if( db->mallocFailed ){\n    return;\n  }\n  pTerm = &pWC->a[idxTerm];\n  pMaskSet = &pWInfo->sMaskSet;\n  pExpr = pTerm->pExpr;\n  assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );\n  prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);\n  op = pExpr->op;\n  if( op==TK_IN ){\n    assert( pExpr->pRight==0 );\n    if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);\n    }else{\n      pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);\n    }\n  }else if( op==TK_ISNULL ){\n    pTerm->prereqRight = 0;\n  }else{\n    pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);\n  }\n  pMaskSet->bVarSelect = 0;\n  prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);\n  if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ){\n    Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);\n    prereqAll |= x;\n    extraRight = x-1;  /* ON clause terms may not be used with an index\n                       ** on left table of a LEFT JOIN.  Ticket #3015 */\n    if( (prereqAll>>1)>=x ){\n      sqlite3ErrorMsg(pParse, \"ON clause references tables to its right\");\n      return;\n    }\n  }\n  pTerm->prereqAll = prereqAll;\n  pTerm->leftCursor = -1;\n  pTerm->iParent = -1;\n  pTerm->eOperator = 0;\n  if( allowedOp(op) ){\n    int aiCurCol[2];\n    Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);\n    Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);\n    u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;\n\n    if( pTerm->iField>0 ){\n      assert( op==TK_IN );\n      assert( pLeft->op==TK_VECTOR );\n      pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;\n    }\n\n    if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){\n      pTerm->leftCursor = aiCurCol[0];\n      pTerm->u.leftColumn = aiCurCol[1];\n      pTerm->eOperator = operatorMask(op) & opMask;\n    }\n    if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;\n    if( pRight \n     && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)\n    ){\n      WhereTerm *pNew;\n      Expr *pDup;\n      u16 eExtraOp = 0;        /* Extra bits for pNew->eOperator */\n      assert( pTerm->iField==0 );\n      if( pTerm->leftCursor>=0 ){\n        int idxNew;\n        pDup = sqlite3ExprDup(db, pExpr, 0);\n        if( db->mallocFailed ){\n          sqlite3ExprDelete(db, pDup);\n          return;\n        }\n        idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);\n        if( idxNew==0 ) return;\n        pNew = &pWC->a[idxNew];\n        markTermAsChild(pWC, idxNew, idxTerm);\n        if( op==TK_IS ) pNew->wtFlags |= TERM_IS;\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n\n        if( termIsEquivalence(pParse, pDup) ){\n          pTerm->eOperator |= WO_EQUIV;\n          eExtraOp = WO_EQUIV;\n        }\n      }else{\n        pDup = pExpr;\n        pNew = pTerm;\n      }\n      exprCommute(pParse, pDup);\n      pNew->leftCursor = aiCurCol[0];\n      pNew->u.leftColumn = aiCurCol[1];\n      testcase( (prereqLeft | extraRight) != prereqLeft );\n      pNew->prereqRight = prereqLeft | extraRight;\n      pNew->prereqAll = prereqAll;\n      pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;\n    }\n  }\n\n#ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  /* If a term is the BETWEEN operator, create two new virtual terms\n  ** that define the range that the BETWEEN implements.  For example:\n  **\n  **      a BETWEEN b AND c\n  **\n  ** is converted into:\n  **\n  **      (a BETWEEN b AND c) AND (a>=b) AND (a<=c)\n  **\n  ** The two new terms are added onto the end of the WhereClause object.\n  ** The new terms are \"dynamic\" and are children of the original BETWEEN\n  ** term.  That means that if the BETWEEN term is coded, the children are\n  ** skipped.  Or, if the children are satisfied by an index, the original\n  ** BETWEEN term is skipped.\n  */\n  else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){\n    ExprList *pList = pExpr->x.pList;\n    int i;\n    static const u8 ops[] = {TK_GE, TK_LE};\n    assert( pList!=0 );\n    assert( pList->nExpr==2 );\n    for(i=0; i<2; i++){\n      Expr *pNewExpr;\n      int idxNew;\n      pNewExpr = sqlite3PExpr(pParse, ops[i], \n                             sqlite3ExprDup(db, pExpr->pLeft, 0),\n                             sqlite3ExprDup(db, pList->a[i].pExpr, 0));\n      transferJoinMarkings(pNewExpr, pExpr);\n      idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n      testcase( idxNew==0 );\n      exprAnalyze(pSrc, pWC, idxNew);\n      pTerm = &pWC->a[idxTerm];\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n  /* Analyze a term that is composed of two or more subterms connected by\n  ** an OR operator.\n  */\n  else if( pExpr->op==TK_OR ){\n    assert( pWC->op==TK_AND );\n    exprAnalyzeOrTerm(pSrc, pWC, idxTerm);\n    pTerm = &pWC->a[idxTerm];\n  }\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n  /* Add constraints to reduce the search space on a LIKE or GLOB\n  ** operator.\n  **\n  ** A like pattern of the form \"x LIKE 'aBc%'\" is changed into constraints\n  **\n  **          x>='ABC' AND x<'abd' AND x LIKE 'aBc%'\n  **\n  ** The last character of the prefix \"abc\" is incremented to form the\n  ** termination condition \"abd\".  If case is not significant (the default\n  ** for LIKE) then the lower-bound is made all uppercase and the upper-\n  ** bound is made all lowercase so that the bounds also work when comparing\n  ** BLOBs.\n  */\n  if( pWC->op==TK_AND \n   && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)\n  ){\n    Expr *pLeft;       /* LHS of LIKE/GLOB operator */\n    Expr *pStr2;       /* Copy of pStr1 - RHS of LIKE/GLOB operator */\n    Expr *pNewExpr1;\n    Expr *pNewExpr2;\n    int idxNew1;\n    int idxNew2;\n    const char *zCollSeqName;     /* Name of collating sequence */\n    const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;\n\n    pLeft = pExpr->x.pList->a[1].pExpr;\n    pStr2 = sqlite3ExprDup(db, pStr1, 0);\n\n    /* Convert the lower bound to upper-case and the upper bound to\n    ** lower-case (upper-case is less than lower-case in ASCII) so that\n    ** the range constraints also work for BLOBs\n    */\n    if( noCase && !pParse->db->mallocFailed ){\n      int i;\n      char c;\n      pTerm->wtFlags |= TERM_LIKE;\n      for(i=0; (c = pStr1->u.zToken[i])!=0; i++){\n        pStr1->u.zToken[i] = sqlite3Toupper(c);\n        pStr2->u.zToken[i] = sqlite3Tolower(c);\n      }\n    }\n\n    if( !db->mallocFailed ){\n      u8 c, *pC;       /* Last character before the first wildcard */\n      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];\n      c = *pC;\n      if( noCase ){\n        /* The point is to increment the last character before the first\n        ** wildcard.  But if we increment '@', that will push it into the\n        ** alphabetic range where case conversions will mess up the \n        ** inequality.  To avoid this, make sure to also run the full\n        ** LIKE on all candidate expressions by clearing the isComplete flag\n        */\n        if( c=='A'-1 ) isComplete = 0;\n        c = sqlite3UpperToLower[c];\n      }\n      *pC = c + 1;\n    }\n    zCollSeqName = noCase ? \"NOCASE\" : \"BINARY\";\n    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr1 = sqlite3PExpr(pParse, TK_GE,\n           sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),\n           pStr1);\n    transferJoinMarkings(pNewExpr1, pExpr);\n    idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);\n    testcase( idxNew1==0 );\n    exprAnalyze(pSrc, pWC, idxNew1);\n    pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr2 = sqlite3PExpr(pParse, TK_LT,\n           sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),\n           pStr2);\n    transferJoinMarkings(pNewExpr2, pExpr);\n    idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);\n    testcase( idxNew2==0 );\n    exprAnalyze(pSrc, pWC, idxNew2);\n    pTerm = &pWC->a[idxTerm];\n    if( isComplete ){\n      markTermAsChild(pWC, idxNew1, idxTerm);\n      markTermAsChild(pWC, idxNew2, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Add a WO_AUX auxiliary term to the constraint set if the\n  ** current expression is of the form \"column OP expr\" where OP\n  ** is an operator that gets passed into virtual tables but which is\n  ** not normally optimized for ordinary tables.  In other words, OP\n  ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.\n  ** This information is used by the xBestIndex methods of\n  ** virtual tables.  The native query optimizer does not attempt\n  ** to do anything with MATCH functions.\n  */\n  if( pWC->op==TK_AND ){\n    Expr *pRight, *pLeft;\n    int res = isAuxiliaryVtabOperator(pExpr, &eOp2, &pLeft, &pRight);\n    while( res-- > 0 ){\n      int idxNew;\n      WhereTerm *pNewTerm;\n      Bitmask prereqColumn, prereqExpr;\n\n      prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight);\n      prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);\n      if( (prereqExpr & prereqColumn)==0 ){\n        Expr *pNewExpr;\n        pNewExpr = sqlite3PExpr(pParse, TK_MATCH, \n            0, sqlite3ExprDup(db, pRight, 0));\n        if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){\n          ExprSetProperty(pNewExpr, EP_FromJoin);\n        }\n        idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        pNewTerm = &pWC->a[idxNew];\n        pNewTerm->prereqRight = prereqExpr;\n        pNewTerm->leftCursor = pLeft->iTable;\n        pNewTerm->u.leftColumn = pLeft->iColumn;\n        pNewTerm->eOperator = WO_AUX;\n        pNewTerm->eMatchOp = eOp2;\n        markTermAsChild(pWC, idxNew, idxTerm);\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n        pNewTerm->prereqAll = pTerm->prereqAll;\n      }\n      SWAP(Expr*, pLeft, pRight);\n    }\n  }\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  /* If there is a vector == or IS term - e.g. \"(a, b) == (?, ?)\" - create\n  ** new terms for each component comparison - \"a = ?\" and \"b = ?\".  The\n  ** new terms completely replace the original vector comparison, which is\n  ** no longer used.\n  **\n  ** This is only required if at least one side of the comparison operation\n  ** is not a sub-select.  */\n  if( pWC->op==TK_AND \n  && (pExpr->op==TK_EQ || pExpr->op==TK_IS)\n  && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1\n  && sqlite3ExprVectorSize(pExpr->pRight)==nLeft\n  && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 \n    || (pExpr->pRight->flags & EP_xIsSelect)==0)\n  ){\n    int i;\n    for(i=0; i<nLeft; i++){\n      int idxNew;\n      Expr *pNew;\n      Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);\n      Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);\n\n      pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);\n      transferJoinMarkings(pNew, pExpr);\n      idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);\n      exprAnalyze(pSrc, pWC, idxNew);\n    }\n    pTerm = &pWC->a[idxTerm];\n    pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL;  /* Disable the original */\n    pTerm->eOperator = 0;\n  }\n\n  /* If there is a vector IN term - e.g. \"(a, b) IN (SELECT ...)\" - create\n  ** a virtual term for each vector component. The expression object\n  ** used by each such virtual term is pExpr (the full vector IN(...) \n  ** expression). The WhereTerm.iField variable identifies the index within\n  ** the vector on the LHS that the virtual term represents.\n  **\n  ** This only works if the RHS is a simple SELECT, not a compound\n  */\n  if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0\n   && pExpr->pLeft->op==TK_VECTOR\n   && pExpr->x.pSelect->pPrior==0\n  ){\n    int i;\n    for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){\n      int idxNew;\n      idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);\n      pWC->a[idxNew].iField = i+1;\n      exprAnalyze(pSrc, pWC, idxNew);\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* When sqlite_stat3 histogram data is available an operator of the\n  ** form \"x IS NOT NULL\" can sometimes be evaluated more efficiently\n  ** as \"x>NULL\" if x is not an INTEGER PRIMARY KEY.  So construct a\n  ** virtual term of that form.\n  **\n  ** Note that the virtual term must be tagged with TERM_VNULL.\n  */\n  if( pExpr->op==TK_NOTNULL\n   && pExpr->pLeft->op==TK_COLUMN\n   && pExpr->pLeft->iColumn>=0\n   && OptimizationEnabled(db, SQLITE_Stat34)\n  ){\n    Expr *pNewExpr;\n    Expr *pLeft = pExpr->pLeft;\n    int idxNew;\n    WhereTerm *pNewTerm;\n\n    pNewExpr = sqlite3PExpr(pParse, TK_GT,\n                            sqlite3ExprDup(db, pLeft, 0),\n                            sqlite3ExprAlloc(db, TK_NULL, 0, 0));\n\n    idxNew = whereClauseInsert(pWC, pNewExpr,\n                              TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);\n    if( idxNew ){\n      pNewTerm = &pWC->a[idxNew];\n      pNewTerm->prereqRight = 0;\n      pNewTerm->leftCursor = pLeft->iTable;\n      pNewTerm->u.leftColumn = pLeft->iColumn;\n      pNewTerm->eOperator = WO_GT;\n      markTermAsChild(pWC, idxNew, idxTerm);\n      pTerm = &pWC->a[idxTerm];\n      pTerm->wtFlags |= TERM_COPIED;\n      pNewTerm->prereqAll = pTerm->prereqAll;\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n  /* Prevent ON clause terms of a LEFT JOIN from being used to drive\n  ** an index for tables to the left of the join.\n  */\n  testcase( pTerm!=&pWC->a[idxTerm] );\n  pTerm = &pWC->a[idxTerm];\n  pTerm->prereqRight |= extraRight;\n}\n\n/***************************************************************************\n** Routines with file scope above.  Interface to the rest of the where.c\n** subsystem follows.\n***************************************************************************/\n\n/*\n** This routine identifies subexpressions in the WHERE clause where\n** each subexpression is separated by the AND operator or some other\n** operator specified in the op parameter.  The WhereClause structure\n** is filled with pointers to subexpressions.  For example:\n**\n**    WHERE  a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)\n**           \\________/     \\_______________/     \\________________/\n**            slot[0]            slot[1]               slot[2]\n**\n** The original WHERE clause in pExpr is unaltered.  All this routine\n** does is make slot[] entries point to substructure within pExpr.\n**\n** In the previous sentence and in the diagram, \"slot[]\" refers to\n** the WhereClause.a[] array.  The slot[] array grows as needed to contain\n** all terms of the WHERE clause.\n*/\nSQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){\n  Expr *pE2 = sqlite3ExprSkipCollate(pExpr);\n  pWC->op = op;\n  if( pE2==0 ) return;\n  if( pE2->op!=op ){\n    whereClauseInsert(pWC, pExpr, 0);\n  }else{\n    sqlite3WhereSplit(pWC, pE2->pLeft, op);\n    sqlite3WhereSplit(pWC, pE2->pRight, op);\n  }\n}\n\n/*\n** Initialize a preallocated WhereClause structure.\n*/\nSQLITE_PRIVATE void sqlite3WhereClauseInit(\n  WhereClause *pWC,        /* The WhereClause to be initialized */\n  WhereInfo *pWInfo        /* The WHERE processing context */\n){\n  pWC->pWInfo = pWInfo;\n  pWC->pOuter = 0;\n  pWC->nTerm = 0;\n  pWC->nSlot = ArraySize(pWC->aStatic);\n  pWC->a = pWC->aStatic;\n}\n\n/*\n** Deallocate a WhereClause structure.  The WhereClause structure\n** itself is not freed.  This routine is the inverse of\n** sqlite3WhereClauseInit().\n*/\nSQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){\n  int i;\n  WhereTerm *a;\n  sqlite3 *db = pWC->pWInfo->pParse->db;\n  for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){\n    if( a->wtFlags & TERM_DYNAMIC ){\n      sqlite3ExprDelete(db, a->pExpr);\n    }\n    if( a->wtFlags & TERM_ORINFO ){\n      whereOrInfoDelete(db, a->u.pOrInfo);\n    }else if( a->wtFlags & TERM_ANDINFO ){\n      whereAndInfoDelete(db, a->u.pAndInfo);\n    }\n  }\n  if( pWC->a!=pWC->aStatic ){\n    sqlite3DbFree(db, pWC->a);\n  }\n}\n\n\n/*\n** These routines walk (recursively) an expression tree and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){\n  Bitmask mask;\n  if( p==0 ) return 0;\n  if( p->op==TK_COLUMN ){\n    return sqlite3WhereGetMask(pMaskSet, p->iTable);\n  }\n  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;\n  assert( !ExprHasProperty(p, EP_TokenOnly) );\n  if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);\n  if( p->pRight ){\n    mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);\n    assert( p->x.pList==0 );\n  }else if( ExprHasProperty(p, EP_xIsSelect) ){\n    if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;\n    mask |= exprSelectUsage(pMaskSet, p->x.pSelect);\n  }else if( p->x.pList ){\n    mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);\n  }\n  return mask;\n}\nSQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){\n  int i;\n  Bitmask mask = 0;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      mask |= sqlite3WhereExprUsage(pMaskSet, pList->a[i].pExpr);\n    }\n  }\n  return mask;\n}\n\n\n/*\n** Call exprAnalyze on all terms in a WHERE clause.  \n**\n** Note that exprAnalyze() might add new virtual terms onto the\n** end of the WHERE clause.  We do not want to analyze these new\n** virtual terms, so start analyzing at the end and work forward\n** so that the added virtual terms are never processed.\n*/\nSQLITE_PRIVATE void sqlite3WhereExprAnalyze(\n  SrcList *pTabList,       /* the FROM clause */\n  WhereClause *pWC         /* the WHERE clause to be analyzed */\n){\n  int i;\n  for(i=pWC->nTerm-1; i>=0; i--){\n    exprAnalyze(pTabList, pWC, i);\n  }\n}\n\n/*\n** For table-valued-functions, transform the function arguments into\n** new WHERE clause terms.  \n**\n** Each function argument translates into an equality constraint against\n** a HIDDEN column in the table.\n*/\nSQLITE_PRIVATE void sqlite3WhereTabFuncArgs(\n  Parse *pParse,                    /* Parsing context */\n  struct SrcList_item *pItem,       /* The FROM clause term to process */\n  WhereClause *pWC                  /* Xfer function arguments to here */\n){\n  Table *pTab;\n  int j, k;\n  ExprList *pArgs;\n  Expr *pColRef;\n  Expr *pTerm;\n  if( pItem->fg.isTabFunc==0 ) return;\n  pTab = pItem->pTab;\n  assert( pTab!=0 );\n  pArgs = pItem->u1.pFuncArg;\n  if( pArgs==0 ) return;\n  for(j=k=0; j<pArgs->nExpr; j++){\n    while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}\n    if( k>=pTab->nCol ){\n      sqlite3ErrorMsg(pParse, \"too many arguments on %s() - max %d\",\n                      pTab->zName, j);\n      return;\n    }\n    pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);\n    if( pColRef==0 ) return;\n    pColRef->iTable = pItem->iCursor;\n    pColRef->iColumn = k++;\n    pColRef->pTab = pTab;\n    pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef,\n                         sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0));\n    whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);\n  }\n}\n\n/************** End of whereexpr.c *******************************************/\n/************** Begin file where.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.  This module is responsible for\n** generating the code that loops through a table looking for applicable\n** rows.  Indices are selected and used to speed the search when doing\n** so is applicable.  Because this module is responsible for selecting\n** indices, you might also think of this module as the \"query optimizer\".\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"whereInt.h\" */\n\n/* Forward declaration of methods */\nstatic int whereLoopResize(sqlite3*, WhereLoop*, int);\n\n/* Test variable that can be set to enable WHERE tracing */\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace = 0;\n#endif\n\n\n/*\n** Return the estimated number of output rows from a WHERE clause\n*/\nSQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo *pWInfo){\n  return pWInfo->nRowOut;\n}\n\n/*\n** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this\n** WHERE clause returns outputs for DISTINCT processing.\n*/\nSQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo *pWInfo){\n  return pWInfo->eDistinct;\n}\n\n/*\n** Return TRUE if the WHERE clause returns rows in ORDER BY order.\n** Return FALSE if the output needs to be sorted.\n*/\nSQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){\n  return pWInfo->nOBSat;\n}\n\n/*\n** Return TRUE if the innermost loop of the WHERE clause implementation\n** returns rows in ORDER BY order for complete run of the inner loop.\n**\n** Across multiple iterations of outer loops, the output rows need not be\n** sorted.  As long as rows are sorted for just the innermost loop, this\n** routine can return TRUE.\n*/\nSQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){\n  return pWInfo->bOrderedInnerLoop;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to continue\n** immediately with the next row of a WHERE clause.\n*/\nSQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo *pWInfo){\n  assert( pWInfo->iContinue!=0 );\n  return pWInfo->iContinue;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to break\n** out of a WHERE loop.\n*/\nSQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo *pWInfo){\n  return pWInfo->iBreak;\n}\n\n/*\n** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to\n** operate directly on the rowis returned by a WHERE clause.  Return\n** ONEPASS_SINGLE (1) if the statement can operation directly because only\n** a single row is to be changed.  Return ONEPASS_MULTI (2) if the one-pass\n** optimization can be used on multiple \n**\n** If the ONEPASS optimization is used (if this routine returns true)\n** then also write the indices of open cursors used by ONEPASS\n** into aiCur[0] and aiCur[1].  iaCur[0] gets the cursor of the data\n** table and iaCur[1] gets the cursor used by an auxiliary index.\n** Either value may be -1, indicating that cursor is not used.\n** Any cursors returned will have been opened for writing.\n**\n** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is\n** unable to use the ONEPASS optimization.\n*/\nSQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo *pWInfo, int *aiCur){\n  memcpy(aiCur, pWInfo->aiCurOnePass, sizeof(int)*2);\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace && pWInfo->eOnePass!=ONEPASS_OFF ){\n    sqlite3DebugPrintf(\"%s cursors: %d %d\\n\",\n         pWInfo->eOnePass==ONEPASS_SINGLE ? \"ONEPASS_SINGLE\" : \"ONEPASS_MULTI\",\n         aiCur[0], aiCur[1]);\n  }\n#endif\n  return pWInfo->eOnePass;\n}\n\n/*\n** Move the content of pSrc into pDest\n*/\nstatic void whereOrMove(WhereOrSet *pDest, WhereOrSet *pSrc){\n  pDest->n = pSrc->n;\n  memcpy(pDest->a, pSrc->a, pDest->n*sizeof(pDest->a[0]));\n}\n\n/*\n** Try to insert a new prerequisite/cost entry into the WhereOrSet pSet.\n**\n** The new entry might overwrite an existing entry, or it might be\n** appended, or it might be discarded.  Do whatever is the right thing\n** so that pSet keeps the N_OR_COST best entries seen so far.\n*/\nstatic int whereOrInsert(\n  WhereOrSet *pSet,      /* The WhereOrSet to be updated */\n  Bitmask prereq,        /* Prerequisites of the new entry */\n  LogEst rRun,           /* Run-cost of the new entry */\n  LogEst nOut            /* Number of outputs for the new entry */\n){\n  u16 i;\n  WhereOrCost *p;\n  for(i=pSet->n, p=pSet->a; i>0; i--, p++){\n    if( rRun<=p->rRun && (prereq & p->prereq)==prereq ){\n      goto whereOrInsert_done;\n    }\n    if( p->rRun<=rRun && (p->prereq & prereq)==p->prereq ){\n      return 0;\n    }\n  }\n  if( pSet->n<N_OR_COST ){\n    p = &pSet->a[pSet->n++];\n    p->nOut = nOut;\n  }else{\n    p = pSet->a;\n    for(i=1; i<pSet->n; i++){\n      if( p->rRun>pSet->a[i].rRun ) p = pSet->a + i;\n    }\n    if( p->rRun<=rRun ) return 0;\n  }\nwhereOrInsert_done:\n  p->prereq = prereq;\n  p->rRun = rRun;\n  if( p->nOut>nOut ) p->nOut = nOut;\n  return 1;\n}\n\n/*\n** Return the bitmask for the given cursor number.  Return 0 if\n** iCursor is not in the set.\n*/\nSQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){\n  int i;\n  assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );\n  for(i=0; i<pMaskSet->n; i++){\n    if( pMaskSet->ix[i]==iCursor ){\n      return MASKBIT(i);\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a new mask for cursor iCursor.\n**\n** There is one cursor per table in the FROM clause.  The number of\n** tables in the FROM clause is limited by a test early in the\n** sqlite3WhereBegin() routine.  So we know that the pMaskSet->ix[]\n** array will never overflow.\n*/\nstatic void createMask(WhereMaskSet *pMaskSet, int iCursor){\n  assert( pMaskSet->n < ArraySize(pMaskSet->ix) );\n  pMaskSet->ix[pMaskSet->n++] = iCursor;\n}\n\n/*\n** Advance to the next WhereTerm that matches according to the criteria\n** established when the pScan object was initialized by whereScanInit().\n** Return NULL if there are no more matching WhereTerms.\n*/\nstatic WhereTerm *whereScanNext(WhereScan *pScan){\n  int iCur;            /* The cursor on the LHS of the term */\n  i16 iColumn;         /* The column on the LHS of the term.  -1 for IPK */\n  Expr *pX;            /* An expression being tested */\n  WhereClause *pWC;    /* Shorthand for pScan->pWC */\n  WhereTerm *pTerm;    /* The term being tested */\n  int k = pScan->k;    /* Where to start scanning */\n\n  assert( pScan->iEquiv<=pScan->nEquiv );\n  pWC = pScan->pWC;\n  while(1){\n    iColumn = pScan->aiColumn[pScan->iEquiv-1];\n    iCur = pScan->aiCur[pScan->iEquiv-1];\n    assert( pWC!=0 );\n    do{\n      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){\n        if( pTerm->leftCursor==iCur\n         && pTerm->u.leftColumn==iColumn\n         && (iColumn!=XN_EXPR\n             || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,\n                                       pScan->pIdxExpr,iCur)==0)\n         && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n        ){\n          if( (pTerm->eOperator & WO_EQUIV)!=0\n           && pScan->nEquiv<ArraySize(pScan->aiCur)\n           && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN\n          ){\n            int j;\n            for(j=0; j<pScan->nEquiv; j++){\n              if( pScan->aiCur[j]==pX->iTable\n               && pScan->aiColumn[j]==pX->iColumn ){\n                  break;\n              }\n            }\n            if( j==pScan->nEquiv ){\n              pScan->aiCur[j] = pX->iTable;\n              pScan->aiColumn[j] = pX->iColumn;\n              pScan->nEquiv++;\n            }\n          }\n          if( (pTerm->eOperator & pScan->opMask)!=0 ){\n            /* Verify the affinity and collating sequence match */\n            if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){\n              CollSeq *pColl;\n              Parse *pParse = pWC->pWInfo->pParse;\n              pX = pTerm->pExpr;\n              if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){\n                continue;\n              }\n              assert(pX->pLeft);\n              pColl = sqlite3BinaryCompareCollSeq(pParse,\n                                                  pX->pLeft, pX->pRight);\n              if( pColl==0 ) pColl = pParse->db->pDfltColl;\n              if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){\n                continue;\n              }\n            }\n            if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0\n             && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN\n             && pX->iTable==pScan->aiCur[0]\n             && pX->iColumn==pScan->aiColumn[0]\n            ){\n              testcase( pTerm->eOperator & WO_IS );\n              continue;\n            }\n            pScan->pWC = pWC;\n            pScan->k = k+1;\n            return pTerm;\n          }\n        }\n      }\n      pWC = pWC->pOuter;\n      k = 0;\n    }while( pWC!=0 );\n    if( pScan->iEquiv>=pScan->nEquiv ) break;\n    pWC = pScan->pOrigWC;\n    k = 0;\n    pScan->iEquiv++;\n  }\n  return 0;\n}\n\n/*\n** Initialize a WHERE clause scanner object.  Return a pointer to the\n** first match.  Return NULL if there are no matches.\n**\n** The scanner will be searching the WHERE clause pWC.  It will look\n** for terms of the form \"X <op> <expr>\" where X is column iColumn of table\n** iCur.   Or if pIdx!=0 then X is column iColumn of index pIdx.  pIdx\n** must be one of the indexes of table iCur.\n**\n** The <op> must be one of the operators described by opMask.\n**\n** If the search is for X and the WHERE clause contains terms of the\n** form X=Y then this routine might also return terms of the form\n** \"Y <op> <expr>\".  The number of levels of transitivity is limited,\n** but is enough to handle most commonly occurring SQL statements.\n**\n** If X is not the INTEGER PRIMARY KEY then X must be compatible with\n** index pIdx.\n*/\nstatic WhereTerm *whereScanInit(\n  WhereScan *pScan,       /* The WhereScan object being initialized */\n  WhereClause *pWC,       /* The WHERE clause to be scanned */\n  int iCur,               /* Cursor to scan for */\n  int iColumn,            /* Column to scan for */\n  u32 opMask,             /* Operator(s) to scan for */\n  Index *pIdx             /* Must be compatible with this index */\n){\n  pScan->pOrigWC = pWC;\n  pScan->pWC = pWC;\n  pScan->pIdxExpr = 0;\n  pScan->idxaff = 0;\n  pScan->zCollName = 0;\n  if( pIdx ){\n    int j = iColumn;\n    iColumn = pIdx->aiColumn[j];\n    if( iColumn==XN_EXPR ){\n      pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;\n      pScan->zCollName = pIdx->azColl[j];\n    }else if( iColumn==pIdx->pTable->iPKey ){\n      iColumn = XN_ROWID;\n    }else if( iColumn>=0 ){\n      pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;\n      pScan->zCollName = pIdx->azColl[j];\n    }\n  }else if( iColumn==XN_EXPR ){\n    return 0;\n  }\n  pScan->opMask = opMask;\n  pScan->k = 0;\n  pScan->aiCur[0] = iCur;\n  pScan->aiColumn[0] = iColumn;\n  pScan->nEquiv = 1;\n  pScan->iEquiv = 1;\n  return whereScanNext(pScan);\n}\n\n/*\n** Search for a term in the WHERE clause that is of the form \"X <op> <expr>\"\n** where X is a reference to the iColumn of table iCur or of index pIdx\n** if pIdx!=0 and <op> is one of the WO_xx operator codes specified by\n** the op parameter.  Return a pointer to the term.  Return 0 if not found.\n**\n** If pIdx!=0 then it must be one of the indexes of table iCur.  \n** Search for terms matching the iColumn-th column of pIdx\n** rather than the iColumn-th column of table iCur.\n**\n** The term returned might by Y=<expr> if there is another constraint in\n** the WHERE clause that specifies that X=Y.  Any such constraints will be\n** identified by the WO_EQUIV bit in the pTerm->eOperator field.  The\n** aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11\n** slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10\n** other equivalent values.  Hence a search for X will return <expr> if X=A1\n** and A1=A2 and A2=A3 and ... and A9=A10 and A10=<expr>.\n**\n** If there are multiple terms in the WHERE clause of the form \"X <op> <expr>\"\n** then try for the one with no dependencies on <expr> - in other words where\n** <expr> is a constant expression of some kind.  Only return entries of\n** the form \"X <op> Y\" where Y is a column in another table if no terms of\n** the form \"X <op> <const-expr>\" exist.   If no terms with a constant RHS\n** exist, try to return a term that does not use WO_EQUIV.\n*/\nSQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n){\n  WhereTerm *pResult = 0;\n  WhereTerm *p;\n  WhereScan scan;\n\n  p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);\n  op &= WO_EQ|WO_IS;\n  while( p ){\n    if( (p->prereqRight & notReady)==0 ){\n      if( p->prereqRight==0 && (p->eOperator&op)!=0 ){\n        testcase( p->eOperator & WO_IS );\n        return p;\n      }\n      if( pResult==0 ) pResult = p;\n    }\n    p = whereScanNext(&scan);\n  }\n  return pResult;\n}\n\n/*\n** This function searches pList for an entry that matches the iCol-th column\n** of index pIdx.\n**\n** If such an expression is found, its index in pList->a[] is returned. If\n** no expression is found, -1 is returned.\n*/\nstatic int findIndexCol(\n  Parse *pParse,                  /* Parse context */\n  ExprList *pList,                /* Expression list to search */\n  int iBase,                      /* Cursor for table associated with pIdx */\n  Index *pIdx,                    /* Index to match column of */\n  int iCol                        /* Column of index to match */\n){\n  int i;\n  const char *zColl = pIdx->azColl[iCol];\n\n  for(i=0; i<pList->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n    if( p->op==TK_COLUMN\n     && p->iColumn==pIdx->aiColumn[iCol]\n     && p->iTable==iBase\n    ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);\n      if( 0==sqlite3StrICmp(pColl->zName, zColl) ){\n        return i;\n      }\n    }\n  }\n\n  return -1;\n}\n\n/*\n** Return TRUE if the iCol-th column of index pIdx is NOT NULL\n*/\nstatic int indexColumnNotNull(Index *pIdx, int iCol){\n  int j;\n  assert( pIdx!=0 );\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  j = pIdx->aiColumn[iCol];\n  if( j>=0 ){\n    return pIdx->pTable->aCol[j].notNull;\n  }else if( j==(-1) ){\n    return 1;\n  }else{\n    assert( j==(-2) );\n    return 0;  /* Assume an indexed expression can always yield a NULL */\n\n  }\n}\n\n/*\n** Return true if the DISTINCT expression-list passed as the third argument\n** is redundant.\n**\n** A DISTINCT list is redundant if any subset of the columns in the\n** DISTINCT list are collectively unique and individually non-null.\n*/\nstatic int isDistinctRedundant(\n  Parse *pParse,            /* Parsing context */\n  SrcList *pTabList,        /* The FROM clause */\n  WhereClause *pWC,         /* The WHERE clause */\n  ExprList *pDistinct       /* The result set that needs to be DISTINCT */\n){\n  Table *pTab;\n  Index *pIdx;\n  int i;                          \n  int iBase;\n\n  /* If there is more than one table or sub-select in the FROM clause of\n  ** this query, then it will not be possible to show that the DISTINCT \n  ** clause is redundant. */\n  if( pTabList->nSrc!=1 ) return 0;\n  iBase = pTabList->a[0].iCursor;\n  pTab = pTabList->a[0].pTab;\n\n  /* If any of the expressions is an IPK column on table iBase, then return \n  ** true. Note: The (p->iTable==iBase) part of this test may be false if the\n  ** current SELECT is a correlated sub-query.\n  */\n  for(i=0; i<pDistinct->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);\n    if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;\n  }\n\n  /* Loop through all indices on the table, checking each to see if it makes\n  ** the DISTINCT qualifier redundant. It does so if:\n  **\n  **   1. The index is itself UNIQUE, and\n  **\n  **   2. All of the columns in the index are either part of the pDistinct\n  **      list, or else the WHERE clause contains a term of the form \"col=X\",\n  **      where X is a constant value. The collation sequences of the\n  **      comparison and select-list expressions must match those of the index.\n  **\n  **   3. All of those index columns for which the WHERE clause does not\n  **      contain a \"col=X\" term are subject to a NOT NULL constraint.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( !IsUniqueIndex(pIdx) ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){\n        if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;\n        if( indexColumnNotNull(pIdx, i)==0 ) break;\n      }\n    }\n    if( i==pIdx->nKeyCol ){\n      /* This index implies that the DISTINCT qualifier is redundant. */\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\n\n/*\n** Estimate the logarithm of the input value to base 2.\n*/\nstatic LogEst estLog(LogEst N){\n  return N<=10 ? 0 : sqlite3LogEst(N) - 33;\n}\n\n/*\n** Convert OP_Column opcodes to OP_Copy in previously generated code.\n**\n** This routine runs over generated VDBE code and translates OP_Column\n** opcodes into OP_Copy when the table is being accessed via co-routine \n** instead of via table lookup.\n**\n** If the bIncrRowid parameter is 0, then any OP_Rowid instructions on\n** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,\n** then each OP_Rowid is transformed into an instruction to increment the\n** value stored in its output register.\n*/\nstatic void translateColumnToCopy(\n  Parse *pParse,      /* Parsing context */\n  int iStart,         /* Translate from this opcode to the end */\n  int iTabCur,        /* OP_Column/OP_Rowid references to this table */\n  int iRegister,      /* The first column is in this register */\n  int bIncrRowid      /* If non-zero, transform OP_rowid to OP_AddImm(1) */\n){\n  Vdbe *v = pParse->pVdbe;\n  VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n  if( pParse->db->mallocFailed ) return;\n  for(; iStart<iEnd; iStart++, pOp++){\n    if( pOp->p1!=iTabCur ) continue;\n    if( pOp->opcode==OP_Column ){\n      pOp->opcode = OP_Copy;\n      pOp->p1 = pOp->p2 + iRegister;\n      pOp->p2 = pOp->p3;\n      pOp->p3 = 0;\n    }else if( pOp->opcode==OP_Rowid ){\n      if( bIncrRowid ){\n        /* Increment the value stored in the P2 operand of the OP_Rowid. */\n        pOp->opcode = OP_AddImm;\n        pOp->p1 = pOp->p2;\n        pOp->p2 = 1;\n      }else{\n        pOp->opcode = OP_Null;\n        pOp->p1 = 0;\n        pOp->p3 = 0;\n      }\n    }\n  }\n}\n\n/*\n** Two routines for printing the content of an sqlite3_index_info\n** structure.  Used for testing and debugging only.  If neither\n** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines\n** are no-ops.\n*/\n#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED)\nstatic void TRACE_IDX_INPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  constraint[%d]: col=%d termid=%d op=%d usabled=%d\\n\",\n       i,\n       p->aConstraint[i].iColumn,\n       p->aConstraint[i].iTermOffset,\n       p->aConstraint[i].op,\n       p->aConstraint[i].usable);\n  }\n  for(i=0; i<p->nOrderBy; i++){\n    sqlite3DebugPrintf(\"  orderby[%d]: col=%d desc=%d\\n\",\n       i,\n       p->aOrderBy[i].iColumn,\n       p->aOrderBy[i].desc);\n  }\n}\nstatic void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  usage[%d]: argvIdx=%d omit=%d\\n\",\n       i,\n       p->aConstraintUsage[i].argvIndex,\n       p->aConstraintUsage[i].omit);\n  }\n  sqlite3DebugPrintf(\"  idxNum=%d\\n\", p->idxNum);\n  sqlite3DebugPrintf(\"  idxStr=%s\\n\", p->idxStr);\n  sqlite3DebugPrintf(\"  orderByConsumed=%d\\n\", p->orderByConsumed);\n  sqlite3DebugPrintf(\"  estimatedCost=%g\\n\", p->estimatedCost);\n  sqlite3DebugPrintf(\"  estimatedRows=%lld\\n\", p->estimatedRows);\n}\n#else\n#define TRACE_IDX_INPUTS(A)\n#define TRACE_IDX_OUTPUTS(A)\n#endif\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Return TRUE if the WHERE clause term pTerm is of a form where it\n** could be used with an index to access pSrc, assuming an appropriate\n** index existed.\n*/\nstatic int termCanDriveIndex(\n  WhereTerm *pTerm,              /* WHERE clause term to check */\n  struct SrcList_item *pSrc,     /* Table we are trying to access */\n  Bitmask notReady               /* Tables in outer loops of the join */\n){\n  char aff;\n  if( pTerm->leftCursor!=pSrc->iCursor ) return 0;\n  if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0;\n  if( (pSrc->fg.jointype & JT_LEFT) \n   && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n   && (pTerm->eOperator & WO_IS)\n  ){\n    /* Cannot use an IS term from the WHERE clause as an index driver for\n    ** the RHS of a LEFT JOIN. Such a term can only be used if it is from\n    ** the ON clause.  */\n    return 0;\n  }\n  if( (pTerm->prereqRight & notReady)!=0 ) return 0;\n  if( pTerm->u.leftColumn<0 ) return 0;\n  aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;\n  if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;\n  testcase( pTerm->pExpr->op==TK_IS );\n  return 1;\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Generate code to construct the Index object for an automatic index\n** and to set up the WhereLevel object pLevel so that the code generator\n** makes use of the automatic index.\n*/\nstatic void constructAutomaticIndex(\n  Parse *pParse,              /* The parsing context */\n  WhereClause *pWC,           /* The WHERE clause */\n  struct SrcList_item *pSrc,  /* The FROM clause term to get the next index */\n  Bitmask notReady,           /* Mask of cursors that are not available */\n  WhereLevel *pLevel          /* Write new index here */\n){\n  int nKeyCol;                /* Number of columns in the constructed index */\n  WhereTerm *pTerm;           /* A single term of the WHERE clause */\n  WhereTerm *pWCEnd;          /* End of pWC->a[] */\n  Index *pIdx;                /* Object describing the transient index */\n  Vdbe *v;                    /* Prepared statement under construction */\n  int addrInit;               /* Address of the initialization bypass jump */\n  Table *pTable;              /* The table being indexed */\n  int addrTop;                /* Top of the index fill loop */\n  int regRecord;              /* Register holding an index record */\n  int n;                      /* Column counter */\n  int i;                      /* Loop counter */\n  int mxBitCol;               /* Maximum column in pSrc->colUsed */\n  CollSeq *pColl;             /* Collating sequence to on a column */\n  WhereLoop *pLoop;           /* The Loop object */\n  char *zNotUsed;             /* Extra space on the end of pIdx */\n  Bitmask idxCols;            /* Bitmap of columns used for indexing */\n  Bitmask extraCols;          /* Bitmap of additional columns */\n  u8 sentWarning = 0;         /* True if a warnning has been issued */\n  Expr *pPartial = 0;         /* Partial Index Expression */\n  int iContinue = 0;          /* Jump here to skip excluded rows */\n  struct SrcList_item *pTabItem;  /* FROM clause term being indexed */\n  int addrCounter = 0;        /* Address where integer counter is initialized */\n  int regBase;                /* Array of registers where record is assembled */\n\n  /* Generate code to skip over the creation and initialization of the\n  ** transient index on 2nd and subsequent iterations of the loop. */\n  v = pParse->pVdbe;\n  assert( v!=0 );\n  addrInit = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n\n  /* Count the number of columns that will be added to the index\n  ** and used to match WHERE clause constraints */\n  nKeyCol = 0;\n  pTable = pSrc->pTab;\n  pWCEnd = &pWC->a[pWC->nTerm];\n  pLoop = pLevel->pWLoop;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    assert( !ExprHasProperty(pExpr, EP_FromJoin)    /* prereq always non-zero */\n         || pExpr->iRightJoinTable!=pSrc->iCursor   /*   for the right-hand   */\n         || pLoop->prereq!=0 );                     /*   table of a LEFT JOIN */\n    if( pLoop->prereq==0\n     && (pTerm->wtFlags & TERM_VIRTUAL)==0\n     && !ExprHasProperty(pExpr, EP_FromJoin)\n     && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){\n      pPartial = sqlite3ExprAnd(pParse->db, pPartial,\n                                sqlite3ExprDup(pParse->db, pExpr, 0));\n    }\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      if( !sentWarning ){\n        sqlite3_log(SQLITE_WARNING_AUTOINDEX,\n            \"automatic index on %s(%s)\", pTable->zName,\n            pTable->aCol[iCol].zName);\n        sentWarning = 1;\n      }\n      if( (idxCols & cMask)==0 ){\n        if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ){\n          goto end_auto_index_create;\n        }\n        pLoop->aLTerm[nKeyCol++] = pTerm;\n        idxCols |= cMask;\n      }\n    }\n  }\n  assert( nKeyCol>0 );\n  pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol;\n  pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED\n                     | WHERE_AUTO_INDEX;\n\n  /* Count the number of additional columns needed to create a\n  ** covering index.  A \"covering index\" is an index that contains all\n  ** columns that are needed by the query.  With a covering index, the\n  ** original table never needs to be accessed.  Automatic indices must\n  ** be a covering index because the index will not be updated if the\n  ** original table changes and the index and table cannot both be used\n  ** if they go out of sync.\n  */\n  extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));\n  mxBitCol = MIN(BMS-1,pTable->nCol);\n  testcase( pTable->nCol==BMS-1 );\n  testcase( pTable->nCol==BMS-2 );\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ) nKeyCol++;\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    nKeyCol += pTable->nCol - BMS + 1;\n  }\n\n  /* Construct the Index object to describe this index */\n  pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);\n  if( pIdx==0 ) goto end_auto_index_create;\n  pLoop->u.btree.pIndex = pIdx;\n  pIdx->zName = \"auto-index\";\n  pIdx->pTable = pTable;\n  n = 0;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS-1 );\n      testcase( iCol==BMS );\n      if( (idxCols & cMask)==0 ){\n        Expr *pX = pTerm->pExpr;\n        idxCols |= cMask;\n        pIdx->aiColumn[n] = pTerm->u.leftColumn;\n        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);\n        pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;\n        n++;\n      }\n    }\n  }\n  assert( (u32)n==pLoop->u.btree.nEq );\n\n  /* Add additional columns needed to make the automatic index into\n  ** a covering index */\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    for(i=BMS-1; i<pTable->nCol; i++){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  assert( n==nKeyCol );\n  pIdx->aiColumn[n] = XN_ROWID;\n  pIdx->azColl[n] = sqlite3StrBINARY;\n\n  /* Create the automatic index */\n  assert( pLevel->iIdxCur>=0 );\n  pLevel->iIdxCur = pParse->nTab++;\n  sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);\n  sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n  VdbeComment((v, \"for %s\", pTable->zName));\n\n  /* Fill the automatic index with content */\n  sqlite3ExprCachePush(pParse);\n  pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    addrTop =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of \\\"%s\\\"\", pTabItem->pTab->zName));\n  }else{\n    addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);\n  }\n  if( pPartial ){\n    iContinue = sqlite3VdbeMakeLabel(v);\n    sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);\n    pLoop->wsFlags |= WHERE_PARTIALIDX;\n  }\n  regRecord = sqlite3GetTempReg(pParse);\n  regBase = sqlite3GenerateIndexKey(\n      pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0\n  );\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);\n  if( pTabItem->fg.viaCoroutine ){\n    sqlite3VdbeChangeP2(v, addrCounter, regBase+n);\n    testcase( pParse->db->mallocFailed );\n    translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,\n                          pTabItem->regResult, 1);\n    sqlite3VdbeGoto(v, addrTop);\n    pTabItem->fg.viaCoroutine = 0;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);\n  }\n  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);\n  sqlite3VdbeJumpHere(v, addrTop);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3ExprCachePop(pParse);\n  \n  /* Jump here when skipping the initialization */\n  sqlite3VdbeJumpHere(v, addrInit);\n\nend_auto_index_create:\n  sqlite3ExprDelete(pParse->db, pPartial);\n}\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Allocate and populate an sqlite3_index_info structure. It is the \n** responsibility of the caller to eventually release the structure\n** by passing the pointer returned by this function to sqlite3_free().\n*/\nstatic sqlite3_index_info *allocateIndexInfo(\n  Parse *pParse,\n  WhereClause *pWC,\n  Bitmask mUnusable,              /* Ignore terms with these prereqs */\n  struct SrcList_item *pSrc,\n  ExprList *pOrderBy,\n  u16 *pmNoOmit                   /* Mask of terms not to omit */\n){\n  int i, j;\n  int nTerm;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_orderby *pIdxOrderBy;\n  struct sqlite3_index_constraint_usage *pUsage;\n  WhereTerm *pTerm;\n  int nOrderBy;\n  sqlite3_index_info *pIdxInfo;\n  u16 mNoOmit = 0;\n\n  /* Count the number of possible WHERE clause constraints referring\n  ** to this virtual table */\n  for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    assert( pTerm->u.leftColumn>=(-1) );\n    nTerm++;\n  }\n\n  /* If the ORDER BY clause contains only columns in the current \n  ** virtual table then allocate space for the aOrderBy part of\n  ** the sqlite3_index_info structure.\n  */\n  nOrderBy = 0;\n  if( pOrderBy ){\n    int n = pOrderBy->nExpr;\n    for(i=0; i<n; i++){\n      Expr *pExpr = pOrderBy->a[i].pExpr;\n      if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;\n    }\n    if( i==n){\n      nOrderBy = n;\n    }\n  }\n\n  /* Allocate the sqlite3_index_info structure\n  */\n  pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)\n                           + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm\n                           + sizeof(*pIdxOrderBy)*nOrderBy );\n  if( pIdxInfo==0 ){\n    sqlite3ErrorMsg(pParse, \"out of memory\");\n    return 0;\n  }\n\n  /* Initialize the structure.  The sqlite3_index_info structure contains\n  ** many fields that are declared \"const\" to prevent xBestIndex from\n  ** changing them.  We have to do some funky casting in order to\n  ** initialize those fields.\n  */\n  pIdxCons = (struct sqlite3_index_constraint*)&pIdxInfo[1];\n  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];\n  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];\n  *(int*)&pIdxInfo->nConstraint = nTerm;\n  *(int*)&pIdxInfo->nOrderBy = nOrderBy;\n  *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons;\n  *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy;\n  *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =\n                                                                   pUsage;\n\n  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    u16 op;\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    assert( pTerm->u.leftColumn>=(-1) );\n    pIdxCons[j].iColumn = pTerm->u.leftColumn;\n    pIdxCons[j].iTermOffset = i;\n    op = pTerm->eOperator & WO_ALL;\n    if( op==WO_IN ) op = WO_EQ;\n    if( op==WO_AUX ){\n      pIdxCons[j].op = pTerm->eMatchOp;\n    }else if( op & (WO_ISNULL|WO_IS) ){\n      if( op==WO_ISNULL ){\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL;\n      }else{\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS;\n      }\n    }else{\n      pIdxCons[j].op = (u8)op;\n      /* The direct assignment in the previous line is possible only because\n      ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The\n      ** following asserts verify this fact. */\n      assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );\n      assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT );\n      assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );\n      assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );\n      assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );\n      assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );\n\n      if( op & (WO_LT|WO_LE|WO_GT|WO_GE)\n       && sqlite3ExprIsVector(pTerm->pExpr->pRight) \n      ){\n        if( i<16 ) mNoOmit |= (1 << i);\n        if( op==WO_LT ) pIdxCons[j].op = WO_LE;\n        if( op==WO_GT ) pIdxCons[j].op = WO_GE;\n      }\n    }\n\n    j++;\n  }\n  for(i=0; i<nOrderBy; i++){\n    Expr *pExpr = pOrderBy->a[i].pExpr;\n    pIdxOrderBy[i].iColumn = pExpr->iColumn;\n    pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;\n  }\n\n  *pmNoOmit = mNoOmit;\n  return pIdxInfo;\n}\n\n/*\n** The table object reference passed as the second argument to this function\n** must represent a virtual table. This function invokes the xBestIndex()\n** method of the virtual table with the sqlite3_index_info object that\n** comes in as the 3rd argument to this function.\n**\n** If an error occurs, pParse is populated with an error message and a\n** non-zero value is returned. Otherwise, 0 is returned and the output\n** part of the sqlite3_index_info structure is left populated.\n**\n** Whether or not an error is returned, it is the responsibility of the\n** caller to eventually free p->idxStr if p->needToFreeIdxStr indicates\n** that this is required.\n*/\nstatic int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){\n  sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;\n  int rc;\n\n  TRACE_IDX_INPUTS(p);\n  rc = pVtab->pModule->xBestIndex(pVtab, p);\n  TRACE_IDX_OUTPUTS(p);\n\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(pParse->db);\n    }else if( !pVtab->zErrMsg ){\n      sqlite3ErrorMsg(pParse, \"%s\", sqlite3ErrStr(rc));\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s\", pVtab->zErrMsg);\n    }\n  }\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = 0;\n\n#if 0\n  /* This error is now caught by the caller.\n  ** Search for \"xBestIndex malfunction\" below */\n  for(i=0; i<p->nConstraint; i++){\n    if( !p->aConstraint[i].usable && p->aConstraintUsage[i].argvIndex>0 ){\n      sqlite3ErrorMsg(pParse, \n          \"table %s: xBestIndex returned an invalid plan\", pTab->zName);\n    }\n  }\n#endif\n\n  return pParse->nErr;\n}\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the location of a particular key among all keys in an\n** index.  Store the results in aStat as follows:\n**\n**    aStat[0]      Est. number of rows less than pRec\n**    aStat[1]      Est. number of rows equal to pRec\n**\n** Return the index of the sample that is the smallest sample that\n** is greater than or equal to pRec. Note that this index is not an index\n** into the aSample[] array - it is an index into a virtual set of samples\n** based on the contents of aSample[] and the number of fields in record \n** pRec. \n*/\nstatic int whereKeyStats(\n  Parse *pParse,              /* Database connection */\n  Index *pIdx,                /* Index to consider domain of */\n  UnpackedRecord *pRec,       /* Vector of values to consider */\n  int roundUp,                /* Round up if true.  Round down if false */\n  tRowcnt *aStat              /* OUT: stats written here */\n){\n  IndexSample *aSample = pIdx->aSample;\n  int iCol;                   /* Index of required stats in anEq[] etc. */\n  int i;                      /* Index of first sample >= pRec */\n  int iSample;                /* Smallest sample larger than or equal to pRec */\n  int iMin = 0;               /* Smallest sample not yet tested */\n  int iTest;                  /* Next sample to test */\n  int res;                    /* Result of comparison operation */\n  int nField;                 /* Number of fields in pRec */\n  tRowcnt iLower = 0;         /* anLt[] + anEq[] of largest sample pRec is > */\n\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( pParse );\n#endif\n  assert( pRec!=0 );\n  assert( pIdx->nSample>0 );\n  assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );\n\n  /* Do a binary search to find the first sample greater than or equal\n  ** to pRec. If pRec contains a single field, the set of samples to search\n  ** is simply the aSample[] array. If the samples in aSample[] contain more\n  ** than one fields, all fields following the first are ignored.\n  **\n  ** If pRec contains N fields, where N is more than one, then as well as the\n  ** samples in aSample[] (truncated to N fields), the search also has to\n  ** consider prefixes of those samples. For example, if the set of samples\n  ** in aSample is:\n  **\n  **     aSample[0] = (a, 5) \n  **     aSample[1] = (a, 10) \n  **     aSample[2] = (b, 5) \n  **     aSample[3] = (c, 100) \n  **     aSample[4] = (c, 105)\n  **\n  ** Then the search space should ideally be the samples above and the \n  ** unique prefixes [a], [b] and [c]. But since that is hard to organize, \n  ** the code actually searches this set:\n  **\n  **     0: (a) \n  **     1: (a, 5) \n  **     2: (a, 10) \n  **     3: (a, 10) \n  **     4: (b) \n  **     5: (b, 5) \n  **     6: (c) \n  **     7: (c, 100) \n  **     8: (c, 105)\n  **     9: (c, 105)\n  **\n  ** For each sample in the aSample[] array, N samples are present in the\n  ** effective sample array. In the above, samples 0 and 1 are based on \n  ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.\n  **\n  ** Often, sample i of each block of N effective samples has (i+1) fields.\n  ** Except, each sample may be extended to ensure that it is greater than or\n  ** equal to the previous sample in the array. For example, in the above, \n  ** sample 2 is the first sample of a block of N samples, so at first it \n  ** appears that it should be 1 field in size. However, that would make it \n  ** smaller than sample 1, so the binary search would not work. As a result, \n  ** it is extended to two fields. The duplicates that this creates do not \n  ** cause any problems.\n  */\n  nField = pRec->nField;\n  iCol = 0;\n  iSample = pIdx->nSample * nField;\n  do{\n    int iSamp;                    /* Index in aSample[] of test sample */\n    int n;                        /* Number of fields in test sample */\n\n    iTest = (iMin+iSample)/2;\n    iSamp = iTest / nField;\n    if( iSamp>0 ){\n      /* The proposed effective sample is a prefix of sample aSample[iSamp].\n      ** Specifically, the shortest prefix of at least (1 + iTest%nField) \n      ** fields that is greater than the previous effective sample.  */\n      for(n=(iTest % nField) + 1; n<nField; n++){\n        if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;\n      }\n    }else{\n      n = iTest + 1;\n    }\n\n    pRec->nField = n;\n    res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);\n    if( res<0 ){\n      iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];\n      iMin = iTest+1;\n    }else if( res==0 && n<nField ){\n      iLower = aSample[iSamp].anLt[n-1];\n      iMin = iTest+1;\n      res = -1;\n    }else{\n      iSample = iTest;\n      iCol = n-1;\n    }\n  }while( res && iMin<iSample );\n  i = iSample / nField;\n\n#ifdef SQLITE_DEBUG\n  /* The following assert statements check that the binary search code\n  ** above found the right answer. This block serves no purpose other\n  ** than to invoke the asserts.  */\n  if( pParse->db->mallocFailed==0 ){\n    if( res==0 ){\n      /* If (res==0) is true, then pRec must be equal to sample i. */\n      assert( i<pIdx->nSample );\n      assert( iCol==nField-1 );\n      pRec->nField = nField;\n      assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec) \n           || pParse->db->mallocFailed \n      );\n    }else{\n      /* Unless i==pIdx->nSample, indicating that pRec is larger than\n      ** all samples in the aSample[] array, pRec must be smaller than the\n      ** (iCol+1) field prefix of sample i.  */\n      assert( i<=pIdx->nSample && i>=0 );\n      pRec->nField = iCol+1;\n      assert( i==pIdx->nSample \n           || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0\n           || pParse->db->mallocFailed );\n\n      /* if i==0 and iCol==0, then record pRec is smaller than all samples\n      ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must\n      ** be greater than or equal to the (iCol) field prefix of sample i.\n      ** If (i>0), then pRec must also be greater than sample (i-1).  */\n      if( iCol>0 ){\n        pRec->nField = iCol;\n        assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0\n             || pParse->db->mallocFailed );\n      }\n      if( i>0 ){\n        pRec->nField = nField;\n        assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0\n             || pParse->db->mallocFailed );\n      }\n    }\n  }\n#endif /* ifdef SQLITE_DEBUG */\n\n  if( res==0 ){\n    /* Record pRec is equal to sample i */\n    assert( iCol==nField-1 );\n    aStat[0] = aSample[i].anLt[iCol];\n    aStat[1] = aSample[i].anEq[iCol];\n  }else{\n    /* At this point, the (iCol+1) field prefix of aSample[i] is the first \n    ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec\n    ** is larger than all samples in the array. */\n    tRowcnt iUpper, iGap;\n    if( i>=pIdx->nSample ){\n      iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);\n    }else{\n      iUpper = aSample[i].anLt[iCol];\n    }\n\n    if( iLower>=iUpper ){\n      iGap = 0;\n    }else{\n      iGap = iUpper - iLower;\n    }\n    if( roundUp ){\n      iGap = (iGap*2)/3;\n    }else{\n      iGap = iGap/3;\n    }\n    aStat[0] = iLower + iGap;\n    aStat[1] = pIdx->aAvgEq[nField-1];\n  }\n\n  /* Restore the pRec->nField value before returning.  */\n  pRec->nField = nField;\n  return i;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** If it is not NULL, pTerm is a term that provides an upper or lower\n** bound on a range scan. Without considering pTerm, it is estimated \n** that the scan will visit nNew rows. This function returns the number\n** estimated to be visited after taking pTerm into account.\n**\n** If the user explicitly specified a likelihood() value for this term,\n** then the return value is the likelihood multiplied by the number of\n** input rows. Otherwise, this function assumes that an \"IS NOT NULL\" term\n** has a likelihood of 0.50, and any other term a likelihood of 0.25.\n*/\nstatic LogEst whereRangeAdjust(WhereTerm *pTerm, LogEst nNew){\n  LogEst nRet = nNew;\n  if( pTerm ){\n    if( pTerm->truthProb<=0 ){\n      nRet += pTerm->truthProb;\n    }else if( (pTerm->wtFlags & TERM_VNULL)==0 ){\n      nRet -= 20;        assert( 20==sqlite3LogEst(4) );\n    }\n  }\n  return nRet;\n}\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return the affinity for a single column of an index.\n*/\nSQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  if( !pIdx->zColAff ){\n    if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;\n  }\n  return pIdx->zColAff[iCol];\n}\n#endif\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/* \n** This function is called to estimate the number of rows visited by a\n** range-scan on a skip-scan index. For example:\n**\n**   CREATE INDEX i1 ON t1(a, b, c);\n**   SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?;\n**\n** Value pLoop->nOut is currently set to the estimated number of rows \n** visited for scanning (a=? AND b=?). This function reduces that estimate \n** by some factor to account for the (c BETWEEN ? AND ?) expression based\n** on the stat4 data for the index. this scan will be peformed multiple \n** times (once for each (a,b) combination that matches a=?) is dealt with \n** by the caller.\n**\n** It does this by scanning through all stat4 samples, comparing values\n** extracted from pLower and pUpper with the corresponding column in each\n** sample. If L and U are the number of samples found to be less than or\n** equal to the values extracted from pLower and pUpper respectively, and\n** N is the total number of samples, the pLoop->nOut value is adjusted\n** as follows:\n**\n**   nOut = nOut * ( min(U - L, 1) / N )\n**\n** If pLower is NULL, or a value cannot be extracted from the term, L is\n** set to zero. If pUpper is NULL, or a value cannot be extracted from it,\n** U is set to N.\n**\n** Normally, this function sets *pbDone to 1 before returning. However,\n** if no value can be extracted from either pLower or pUpper (and so the\n** estimate of the number of rows delivered remains unchanged), *pbDone\n** is left as is.\n**\n** If an error occurs, an SQLite error code is returned. Otherwise, \n** SQLITE_OK.\n*/\nstatic int whereRangeSkipScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop,    /* Update the .nOut value of this loop */\n  int *pbDone          /* Set to true if at least one expr. value extracted */\n){\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n  sqlite3 *db = pParse->db;\n  int nLower = -1;\n  int nUpper = p->nSample+1;\n  int rc = SQLITE_OK;\n  u8 aff = sqlite3IndexColumnAffinity(db, p, nEq);\n  CollSeq *pColl;\n  \n  sqlite3_value *p1 = 0;          /* Value extracted from pLower */\n  sqlite3_value *p2 = 0;          /* Value extracted from pUpper */\n  sqlite3_value *pVal = 0;        /* Value extracted from record */\n\n  pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]);\n  if( pLower ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);\n    nLower = 0;\n  }\n  if( pUpper && rc==SQLITE_OK ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);\n    nUpper = p2 ? 0 : p->nSample;\n  }\n\n  if( p1 || p2 ){\n    int i;\n    int nDiff;\n    for(i=0; rc==SQLITE_OK && i<p->nSample; i++){\n      rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal);\n      if( rc==SQLITE_OK && p1 ){\n        int res = sqlite3MemCompare(p1, pVal, pColl);\n        if( res>=0 ) nLower++;\n      }\n      if( rc==SQLITE_OK && p2 ){\n        int res = sqlite3MemCompare(p2, pVal, pColl);\n        if( res>=0 ) nUpper++;\n      }\n    }\n    nDiff = (nUpper - nLower);\n    if( nDiff<=0 ) nDiff = 1;\n\n    /* If there is both an upper and lower bound specified, and the \n    ** comparisons indicate that they are close together, use the fallback\n    ** method (assume that the scan visits 1/64 of the rows) for estimating\n    ** the number of rows visited. Otherwise, estimate the number of rows\n    ** using the method described in the header comment for this function. */\n    if( nDiff!=1 || pUpper==0 || pLower==0 ){\n      int nAdjust = (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff));\n      pLoop->nOut -= nAdjust;\n      *pbDone = 1;\n      WHERETRACE(0x10, (\"range skip-scan regions: %u..%u  adjust=%d est=%d\\n\",\n                           nLower, nUpper, nAdjust*-1, pLoop->nOut));\n    }\n\n  }else{\n    assert( *pbDone==0 );\n  }\n\n  sqlite3ValueFree(p1);\n  sqlite3ValueFree(p2);\n  sqlite3ValueFree(pVal);\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** This function is used to estimate the number of rows that will be visited\n** by scanning an index for a range of values. The range may have an upper\n** bound, a lower bound, or both. The WHERE clause terms that set the upper\n** and lower bounds are represented by pLower and pUpper respectively. For\n** example, assuming that index p is on t1(a):\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**                    |_____|   |_____|\n**                       |         |\n**                     pLower    pUpper\n**\n** If either of the upper or lower bound is not present, then NULL is passed in\n** place of the corresponding WhereTerm.\n**\n** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index\n** column subject to the range constraint. Or, equivalently, the number of\n** equality constraints optimized by the proposed index scan. For example,\n** assuming index p is on t1(a, b), and the SQL query is:\n**\n**   ... FROM t1 WHERE a = ? AND b > ? AND b < ? ...\n**\n** then nEq is set to 1 (as the range restricted column, b, is the second \n** left-most column of the index). Or, if the query is:\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**\n** then nEq is set to 0.\n**\n** When this function is called, *pnOut is set to the sqlite3LogEst() of the\n** number of rows that the index scan is expected to visit without \n** considering the range constraints. If nEq is 0, then *pnOut is the number of \n** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)\n** to account for the range constraints pLower and pUpper.\n** \n** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be\n** used, a single range inequality reduces the search space by a factor of 4. \n** and a pair of constraints (x>? AND x<?) reduces the expected number of\n** rows visited by a factor of 64.\n*/\nstatic int whereRangeScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop     /* Modify the .nOut and maybe .rRun fields */\n){\n  int rc = SQLITE_OK;\n  int nOut = pLoop->nOut;\n  LogEst nNew;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n\n  if( p->nSample>0 && nEq<p->nSampleCol ){\n    if( nEq==pBuilder->nRecValid ){\n      UnpackedRecord *pRec = pBuilder->pRec;\n      tRowcnt a[2];\n      int nBtm = pLoop->u.btree.nBtm;\n      int nTop = pLoop->u.btree.nTop;\n\n      /* Variable iLower will be set to the estimate of the number of rows in \n      ** the index that are less than the lower bound of the range query. The\n      ** lower bound being the concatenation of $P and $L, where $P is the\n      ** key-prefix formed by the nEq values matched against the nEq left-most\n      ** columns of the index, and $L is the value in pLower.\n      **\n      ** Or, if pLower is NULL or $L cannot be extracted from it (because it\n      ** is not a simple variable or literal value), the lower bound of the\n      ** range is $P. Due to a quirk in the way whereKeyStats() works, even\n      ** if $L is available, whereKeyStats() is called for both ($P) and \n      ** ($P:$L) and the larger of the two returned values is used.\n      **\n      ** Similarly, iUpper is to be set to the estimate of the number of rows\n      ** less than the upper bound of the range query. Where the upper bound\n      ** is either ($P) or ($P:$U). Again, even if $U is available, both values\n      ** of iUpper are requested of whereKeyStats() and the smaller used.\n      **\n      ** The number of rows between the two bounds is then just iUpper-iLower.\n      */\n      tRowcnt iLower;     /* Rows less than the lower bound */\n      tRowcnt iUpper;     /* Rows less than the upper bound */\n      int iLwrIdx = -2;   /* aSample[] for the lower bound */\n      int iUprIdx = -1;   /* aSample[] for the upper bound */\n\n      if( pRec ){\n        testcase( pRec->nField!=pBuilder->nRecValid );\n        pRec->nField = pBuilder->nRecValid;\n      }\n      /* Determine iLower and iUpper using ($P) only. */\n      if( nEq==0 ){\n        iLower = 0;\n        iUpper = p->nRowEst0;\n      }else{\n        /* Note: this call could be optimized away - since the same values must \n        ** have been requested when testing key $P in whereEqualScanEst().  */\n        whereKeyStats(pParse, p, pRec, 0, a);\n        iLower = a[0];\n        iUpper = a[0] + a[1];\n      }\n\n      assert( pLower==0 || (pLower->eOperator & (WO_GT|WO_GE))!=0 );\n      assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );\n      assert( p->aSortOrder!=0 );\n      if( p->aSortOrder[nEq] ){\n        /* The roles of pLower and pUpper are swapped for a DESC index */\n        SWAP(WhereTerm*, pLower, pUpper);\n        SWAP(int, nBtm, nTop);\n      }\n\n      /* If possible, improve on the iLower estimate using ($P:$L). */\n      if( pLower ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pLower->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);\n          iNew = a[0] + ((pLower->eOperator & mask) ? a[1] : 0);\n          if( iNew>iLower ) iLower = iNew;\n          nOut--;\n          pLower = 0;\n        }\n      }\n\n      /* If possible, improve on the iUpper estimate using ($P:$U). */\n      if( pUpper ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pUpper->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);\n          iNew = a[0] + ((pUpper->eOperator & mask) ? a[1] : 0);\n          if( iNew<iUpper ) iUpper = iNew;\n          nOut--;\n          pUpper = 0;\n        }\n      }\n\n      pBuilder->pRec = pRec;\n      if( rc==SQLITE_OK ){\n        if( iUpper>iLower ){\n          nNew = sqlite3LogEst(iUpper - iLower);\n          /* TUNING:  If both iUpper and iLower are derived from the same\n          ** sample, then assume they are 4x more selective.  This brings\n          ** the estimated selectivity more in line with what it would be\n          ** if estimated without the use of STAT3/4 tables. */\n          if( iLwrIdx==iUprIdx ) nNew -= 20;  assert( 20==sqlite3LogEst(4) );\n        }else{\n          nNew = 10;        assert( 10==sqlite3LogEst(2) );\n        }\n        if( nNew<nOut ){\n          nOut = nNew;\n        }\n        WHERETRACE(0x10, (\"STAT4 range scan: %u..%u  est=%d\\n\",\n                           (u32)iLower, (u32)iUpper, nOut));\n      }\n    }else{\n      int bDone = 0;\n      rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone);\n      if( bDone ) return rc;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pParse);\n  UNUSED_PARAMETER(pBuilder);\n  assert( pLower || pUpper );\n#endif\n  assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );\n  nNew = whereRangeAdjust(pLower, nOut);\n  nNew = whereRangeAdjust(pUpper, nNew);\n\n  /* TUNING: If there is both an upper and lower limit and neither limit\n  ** has an application-defined likelihood(), assume the range is\n  ** reduced by an additional 75%. This means that, by default, an open-ended\n  ** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the\n  ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to\n  ** match 1/64 of the index. */ \n  if( pLower && pLower->truthProb>0 && pUpper && pUpper->truthProb>0 ){\n    nNew -= 20;\n  }\n\n  nOut -= (pLower!=0) + (pUpper!=0);\n  if( nNew<10 ) nNew = 10;\n  if( nNew<nOut ) nOut = nNew;\n#if defined(WHERETRACE_ENABLED)\n  if( pLoop->nOut>nOut ){\n    WHERETRACE(0x10,(\"Range scan lowers nOut from %d to %d\\n\",\n                    pLoop->nOut, nOut));\n  }\n#endif\n  pLoop->nOut = (LogEst)nOut;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an equality constraint x=VALUE and where that VALUE occurs in\n** the histogram data.  This only works when x is the left-most\n** column of an index and sqlite_stat3 histogram data is available\n** for that index.  When pExpr==NULL that means the constraint is\n** \"x IS NULL\" instead of \"x=VALUE\".\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereEqualScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  Expr *pExpr,         /* Expression for VALUE in the x=VALUE constraint */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  int nEq = pBuilder->pNew->u.btree.nEq;\n  UnpackedRecord *pRec = pBuilder->pRec;\n  int rc;                   /* Subfunction return code */\n  tRowcnt a[2];             /* Statistics */\n  int bOk;\n\n  assert( nEq>=1 );\n  assert( nEq<=p->nColumn );\n  assert( p->aSample!=0 );\n  assert( p->nSample>0 );\n  assert( pBuilder->nRecValid<nEq );\n\n  /* If values are not available for all fields of the index to the left\n  ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */\n  if( pBuilder->nRecValid<(nEq-1) ){\n    return SQLITE_NOTFOUND;\n  }\n\n  /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue()\n  ** below would return the same value.  */\n  if( nEq>=p->nColumn ){\n    *pnRow = 1;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);\n  pBuilder->pRec = pRec;\n  if( rc!=SQLITE_OK ) return rc;\n  if( bOk==0 ) return SQLITE_NOTFOUND;\n  pBuilder->nRecValid = nEq;\n\n  whereKeyStats(pParse, p, pRec, 0, a);\n  WHERETRACE(0x10,(\"equality scan regions %s(%d): %d\\n\",\n                   p->zName, nEq-1, (int)a[1]));\n  *pnRow = a[1];\n  \n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an IN constraint where the right-hand side of the IN operator\n** is a list of values.  Example:\n**\n**        WHERE x IN (1,2,3,4)\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereInScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  ExprList *pList,     /* The value list on the RHS of \"x IN (v1,v2,v3,...)\" */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  i64 nRow0 = sqlite3LogEstToInt(p->aiRowLogEst[0]);\n  int nRecValid = pBuilder->nRecValid;\n  int rc = SQLITE_OK;     /* Subfunction return code */\n  tRowcnt nEst;           /* Number of rows for a single term */\n  tRowcnt nRowEst = 0;    /* New estimate of the number of rows */\n  int i;                  /* Loop counter */\n\n  assert( p->aSample!=0 );\n  for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){\n    nEst = nRow0;\n    rc = whereEqualScanEst(pParse, pBuilder, pList->a[i].pExpr, &nEst);\n    nRowEst += nEst;\n    pBuilder->nRecValid = nRecValid;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( nRowEst > nRow0 ) nRowEst = nRow0;\n    *pnRow = nRowEst;\n    WHERETRACE(0x10,(\"IN row estimate: est=%d\\n\", nRowEst));\n  }\n  assert( pBuilder->nRecValid==nRecValid );\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print the content of a WhereTerm object\n*/\nstatic void whereTermPrint(WhereTerm *pTerm, int iTerm){\n  if( pTerm==0 ){\n    sqlite3DebugPrintf(\"TERM-%-3d NULL\\n\", iTerm);\n  }else{\n    char zType[4];\n    char zLeft[50];\n    memcpy(zType, \"...\", 4);\n    if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';\n    if( pTerm->eOperator & WO_EQUIV  ) zType[1] = 'E';\n    if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';\n    if( pTerm->eOperator & WO_SINGLE ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left={%d:%d}\",\n                       pTerm->leftCursor, pTerm->u.leftColumn);\n    }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"indexable=0x%lld\", \n                       pTerm->u.pOrInfo->indexable);\n    }else{\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left=%d\", pTerm->leftCursor);\n    }\n    sqlite3DebugPrintf(\n       \"TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\",\n       iTerm, pTerm, zType, zLeft, pTerm->truthProb,\n       pTerm->eOperator, pTerm->wtFlags);\n    if( pTerm->iField ){\n      sqlite3DebugPrintf(\" iField=%d\\n\", pTerm->iField);\n    }else{\n      sqlite3DebugPrintf(\"\\n\");\n    }\n    sqlite3TreeViewExpr(0, pTerm->pExpr, 0);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Show the complete content of a WhereClause\n*/\nSQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){\n  int i;\n  for(i=0; i<pWC->nTerm; i++){\n    whereTermPrint(&pWC->a[i], i);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print a WhereLoop object for debugging purposes\n*/\nstatic void whereLoopPrint(WhereLoop *p, WhereClause *pWC){\n  WhereInfo *pWInfo = pWC->pWInfo;\n  int nb = 1+(pWInfo->pTabList->nSrc+3)/4;\n  struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab;\n  Table *pTab = pItem->pTab;\n  Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;\n  sqlite3DebugPrintf(\"%c%2d.%0*llx.%0*llx\", p->cId,\n                     p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);\n  sqlite3DebugPrintf(\" %12s\",\n                     pItem->zAlias ? pItem->zAlias : pTab->zName);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    const char *zName;\n    if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){\n      if( strncmp(zName, \"sqlite_autoindex_\", 17)==0 ){\n        int i = sqlite3Strlen30(zName) - 1;\n        while( zName[i]!='_' ) i--;\n        zName += i;\n      }\n      sqlite3DebugPrintf(\".%-16s %2d\", zName, p->u.btree.nEq);\n    }else{\n      sqlite3DebugPrintf(\"%20s\",\"\");\n    }\n  }else{\n    char *z;\n    if( p->u.vtab.idxStr ){\n      z = sqlite3_mprintf(\"(%d,\\\"%s\\\",%x)\",\n                p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);\n    }else{\n      z = sqlite3_mprintf(\"(%d,%x)\", p->u.vtab.idxNum, p->u.vtab.omitMask);\n    }\n    sqlite3DebugPrintf(\" %-19s\", z);\n    sqlite3_free(z);\n  }\n  if( p->wsFlags & WHERE_SKIPSCAN ){\n    sqlite3DebugPrintf(\" f %05x %d-%d\", p->wsFlags, p->nLTerm,p->nSkip);\n  }else{\n    sqlite3DebugPrintf(\" f %05x N %d\", p->wsFlags, p->nLTerm);\n  }\n  sqlite3DebugPrintf(\" cost %d,%d,%d\\n\", p->rSetup, p->rRun, p->nOut);\n  if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){\n    int i;\n    for(i=0; i<p->nLTerm; i++){\n      whereTermPrint(p->aLTerm[i], i);\n    }\n  }\n}\n#endif\n\n/*\n** Convert bulk memory into a valid WhereLoop that can be passed\n** to whereLoopClear harmlessly.\n*/\nstatic void whereLoopInit(WhereLoop *p){\n  p->aLTerm = p->aLTermSpace;\n  p->nLTerm = 0;\n  p->nLSlot = ArraySize(p->aLTermSpace);\n  p->wsFlags = 0;\n}\n\n/*\n** Clear the WhereLoop.u union.  Leave WhereLoop.pLTerm intact.\n*/\nstatic void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){\n  if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){\n    if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){\n      sqlite3_free(p->u.vtab.idxStr);\n      p->u.vtab.needFree = 0;\n      p->u.vtab.idxStr = 0;\n    }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){\n      sqlite3DbFree(db, p->u.btree.pIndex->zColAff);\n      sqlite3DbFreeNN(db, p->u.btree.pIndex);\n      p->u.btree.pIndex = 0;\n    }\n  }\n}\n\n/*\n** Deallocate internal memory used by a WhereLoop object\n*/\nstatic void whereLoopClear(sqlite3 *db, WhereLoop *p){\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  whereLoopClearUnion(db, p);\n  whereLoopInit(p);\n}\n\n/*\n** Increase the memory allocation for pLoop->aLTerm[] to be at least n.\n*/\nstatic int whereLoopResize(sqlite3 *db, WhereLoop *p, int n){\n  WhereTerm **paNew;\n  if( p->nLSlot>=n ) return SQLITE_OK;\n  n = (n+7)&~7;\n  paNew = sqlite3DbMallocRawNN(db, sizeof(p->aLTerm[0])*n);\n  if( paNew==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0])*p->nLSlot);\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  p->aLTerm = paNew;\n  p->nLSlot = n;\n  return SQLITE_OK;\n}\n\n/*\n** Transfer content from the second pLoop into the first.\n*/\nstatic int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){\n  whereLoopClearUnion(db, pTo);\n  if( whereLoopResize(db, pTo, pFrom->nLTerm) ){\n    memset(&pTo->u, 0, sizeof(pTo->u));\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);\n  memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));\n  if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){\n    pFrom->u.vtab.needFree = 0;\n  }else if( (pFrom->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n    pFrom->u.btree.pIndex = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Delete a WhereLoop object\n*/\nstatic void whereLoopDelete(sqlite3 *db, WhereLoop *p){\n  whereLoopClear(db, p);\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Free a WhereInfo structure\n*/\nstatic void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){\n  if( ALWAYS(pWInfo) ){\n    int i;\n    for(i=0; i<pWInfo->nLevel; i++){\n      WhereLevel *pLevel = &pWInfo->a[i];\n      if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){\n        sqlite3DbFree(db, pLevel->u.in.aInLoop);\n      }\n    }\n    sqlite3WhereClauseClear(&pWInfo->sWC);\n    while( pWInfo->pLoops ){\n      WhereLoop *p = pWInfo->pLoops;\n      pWInfo->pLoops = p->pNextLoop;\n      whereLoopDelete(db, p);\n    }\n    sqlite3DbFreeNN(db, pWInfo);\n  }\n}\n\n/*\n** Return TRUE if all of the following are true:\n**\n**   (1)  X has the same or lower cost that Y\n**   (2)  X uses fewer WHERE clause terms than Y\n**   (3)  Every WHERE clause term used by X is also used by Y\n**   (4)  X skips at least as many columns as Y\n**   (5)  If X is a covering index, than Y is too\n**\n** Conditions (2) and (3) mean that X is a \"proper subset\" of Y.\n** If X is a proper subset of Y then Y is a better choice and ought\n** to have a lower cost.  This routine returns TRUE when that cost \n** relationship is inverted and needs to be adjusted.  Constraint (4)\n** was added because if X uses skip-scan less than Y it still might\n** deserve a lower cost even if it is a proper subset of Y.  Constraint (5)\n** was added because a covering index probably deserves to have a lower cost\n** than a non-covering index even if it is a proper subset.\n*/\nstatic int whereLoopCheaperProperSubset(\n  const WhereLoop *pX,       /* First WhereLoop to compare */\n  const WhereLoop *pY        /* Compare against this WhereLoop */\n){\n  int i, j;\n  if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){\n    return 0; /* X is not a subset of Y */\n  }\n  if( pY->nSkip > pX->nSkip ) return 0;\n  if( pX->rRun >= pY->rRun ){\n    if( pX->rRun > pY->rRun ) return 0;    /* X costs more than Y */\n    if( pX->nOut > pY->nOut ) return 0;    /* X costs more than Y */\n  }\n  for(i=pX->nLTerm-1; i>=0; i--){\n    if( pX->aLTerm[i]==0 ) continue;\n    for(j=pY->nLTerm-1; j>=0; j--){\n      if( pY->aLTerm[j]==pX->aLTerm[i] ) break;\n    }\n    if( j<0 ) return 0;  /* X not a subset of Y since term X[i] not used by Y */\n  }\n  if( (pX->wsFlags&WHERE_IDX_ONLY)!=0 \n   && (pY->wsFlags&WHERE_IDX_ONLY)==0 ){\n    return 0;  /* Constraint (5) */\n  }\n  return 1;  /* All conditions meet */\n}\n\n/*\n** Try to adjust the cost of WhereLoop pTemplate upwards or downwards so\n** that:\n**\n**   (1) pTemplate costs less than any other WhereLoops that are a proper\n**       subset of pTemplate\n**\n**   (2) pTemplate costs more than any other WhereLoops for which pTemplate\n**       is a proper subset.\n**\n** To say \"WhereLoop X is a proper subset of Y\" means that X uses fewer\n** WHERE clause terms than Y and that every WHERE clause term used by X is\n** also used by Y.\n*/\nstatic void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){\n  if( (pTemplate->wsFlags & WHERE_INDEXED)==0 ) return;\n  for(; p; p=p->pNextLoop){\n    if( p->iTab!=pTemplate->iTab ) continue;\n    if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;\n    if( whereLoopCheaperProperSubset(p, pTemplate) ){\n      /* Adjust pTemplate cost downward so that it is cheaper than its \n      ** subset p. */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut - 1;\n    }else if( whereLoopCheaperProperSubset(pTemplate, p) ){\n      /* Adjust pTemplate cost upward so that it is costlier than p since\n      ** pTemplate is a proper subset of p */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut+1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut + 1;\n    }\n  }\n}\n\n/*\n** Search the list of WhereLoops in *ppPrev looking for one that can be\n** replaced by pTemplate.\n**\n** Return NULL if pTemplate does not belong on the WhereLoop list.\n** In other words if pTemplate ought to be dropped from further consideration.\n**\n** If pX is a WhereLoop that pTemplate can replace, then return the\n** link that points to pX.\n**\n** If pTemplate cannot replace any existing element of the list but needs\n** to be added to the list as a new entry, then return a pointer to the\n** tail of the list.\n*/\nstatic WhereLoop **whereLoopFindLesser(\n  WhereLoop **ppPrev,\n  const WhereLoop *pTemplate\n){\n  WhereLoop *p;\n  for(p=(*ppPrev); p; ppPrev=&p->pNextLoop, p=*ppPrev){\n    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){\n      /* If either the iTab or iSortIdx values for two WhereLoop are different\n      ** then those WhereLoops need to be considered separately.  Neither is\n      ** a candidate to replace the other. */\n      continue;\n    }\n    /* In the current implementation, the rSetup value is either zero\n    ** or the cost of building an automatic index (NlogN) and the NlogN\n    ** is the same for compatible WhereLoops. */\n    assert( p->rSetup==0 || pTemplate->rSetup==0 \n                 || p->rSetup==pTemplate->rSetup );\n\n    /* whereLoopAddBtree() always generates and inserts the automatic index\n    ** case first.  Hence compatible candidate WhereLoops never have a larger\n    ** rSetup. Call this SETUP-INVARIANT */\n    assert( p->rSetup>=pTemplate->rSetup );\n\n    /* Any loop using an appliation-defined index (or PRIMARY KEY or\n    ** UNIQUE constraint) with one or more == constraints is better\n    ** than an automatic index. Unless it is a skip-scan. */\n    if( (p->wsFlags & WHERE_AUTO_INDEX)!=0\n     && (pTemplate->nSkip)==0\n     && (pTemplate->wsFlags & WHERE_INDEXED)!=0\n     && (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0\n     && (p->prereq & pTemplate->prereq)==pTemplate->prereq\n    ){\n      break;\n    }\n\n    /* If existing WhereLoop p is better than pTemplate, pTemplate can be\n    ** discarded.  WhereLoop p is better if:\n    **   (1)  p has no more dependencies than pTemplate, and\n    **   (2)  p has an equal or lower cost than pTemplate\n    */\n    if( (p->prereq & pTemplate->prereq)==p->prereq    /* (1)  */\n     && p->rSetup<=pTemplate->rSetup                  /* (2a) */\n     && p->rRun<=pTemplate->rRun                      /* (2b) */\n     && p->nOut<=pTemplate->nOut                      /* (2c) */\n    ){\n      return 0;  /* Discard pTemplate */\n    }\n\n    /* If pTemplate is always better than p, then cause p to be overwritten\n    ** with pTemplate.  pTemplate is better than p if:\n    **   (1)  pTemplate has no more dependences than p, and\n    **   (2)  pTemplate has an equal or lower cost than p.\n    */\n    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq   /* (1)  */\n     && p->rRun>=pTemplate->rRun                             /* (2a) */\n     && p->nOut>=pTemplate->nOut                             /* (2b) */\n    ){\n      assert( p->rSetup>=pTemplate->rSetup ); /* SETUP-INVARIANT above */\n      break;   /* Cause p to be overwritten by pTemplate */\n    }\n  }\n  return ppPrev;\n}\n\n/*\n** Insert or replace a WhereLoop entry using the template supplied.\n**\n** An existing WhereLoop entry might be overwritten if the new template\n** is better and has fewer dependencies.  Or the template will be ignored\n** and no insert will occur if an existing WhereLoop is faster and has\n** fewer dependencies than the template.  Otherwise a new WhereLoop is\n** added based on the template.\n**\n** If pBuilder->pOrSet is not NULL then we care about only the\n** prerequisites and rRun and nOut costs of the N best loops.  That\n** information is gathered in the pBuilder->pOrSet object.  This special\n** processing mode is used only for OR clause processing.\n**\n** When accumulating multiple loops (when pBuilder->pOrSet is NULL) we\n** still might overwrite similar loops with the new template if the\n** new template is better.  Loops may be overwritten if the following \n** conditions are met:\n**\n**    (1)  They have the same iTab.\n**    (2)  They have the same iSortIdx.\n**    (3)  The template has same or fewer dependencies than the current loop\n**    (4)  The template has the same or lower cost than the current loop\n*/\nstatic int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){\n  WhereLoop **ppPrev, *p;\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc;\n\n  /* If pBuilder->pOrSet is defined, then only keep track of the costs\n  ** and prereqs.\n  */\n  if( pBuilder->pOrSet!=0 ){\n    if( pTemplate->nLTerm ){\n#if WHERETRACE_ENABLED\n      u16 n = pBuilder->pOrSet->n;\n      int x =\n#endif\n      whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun,\n                                    pTemplate->nOut);\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(x?\"   or-%d:  \":\"   or-X:  \", n);\n        whereLoopPrint(pTemplate, pBuilder->pWC);\n      }\n#endif\n    }\n    return SQLITE_OK;\n  }\n\n  /* Look for an existing WhereLoop to replace with pTemplate\n  */\n  whereLoopAdjustCost(pWInfo->pLoops, pTemplate);\n  ppPrev = whereLoopFindLesser(&pWInfo->pLoops, pTemplate);\n\n  if( ppPrev==0 ){\n    /* There already exists a WhereLoop on the list that is better\n    ** than pTemplate, so just ignore pTemplate */\n#if WHERETRACE_ENABLED /* 0x8 */\n    if( sqlite3WhereTrace & 0x8 ){\n      sqlite3DebugPrintf(\"   skip: \");\n      whereLoopPrint(pTemplate, pBuilder->pWC);\n    }\n#endif\n    return SQLITE_OK;  \n  }else{\n    p = *ppPrev;\n  }\n\n  /* If we reach this point it means that either p[] should be overwritten\n  ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new\n  ** WhereLoop and insert it.\n  */\n#if WHERETRACE_ENABLED /* 0x8 */\n  if( sqlite3WhereTrace & 0x8 ){\n    if( p!=0 ){\n      sqlite3DebugPrintf(\"replace: \");\n      whereLoopPrint(p, pBuilder->pWC);\n      sqlite3DebugPrintf(\"   with: \");\n    }else{\n      sqlite3DebugPrintf(\"    add: \");\n    }\n    whereLoopPrint(pTemplate, pBuilder->pWC);\n  }\n#endif\n  if( p==0 ){\n    /* Allocate a new WhereLoop to add to the end of the list */\n    *ppPrev = p = sqlite3DbMallocRawNN(db, sizeof(WhereLoop));\n    if( p==0 ) return SQLITE_NOMEM_BKPT;\n    whereLoopInit(p);\n    p->pNextLoop = 0;\n  }else{\n    /* We will be overwriting WhereLoop p[].  But before we do, first\n    ** go through the rest of the list and delete any other entries besides\n    ** p[] that are also supplated by pTemplate */\n    WhereLoop **ppTail = &p->pNextLoop;\n    WhereLoop *pToDel;\n    while( *ppTail ){\n      ppTail = whereLoopFindLesser(ppTail, pTemplate);\n      if( ppTail==0 ) break;\n      pToDel = *ppTail;\n      if( pToDel==0 ) break;\n      *ppTail = pToDel->pNextLoop;\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(\" delete: \");\n        whereLoopPrint(pToDel, pBuilder->pWC);\n      }\n#endif\n      whereLoopDelete(db, pToDel);\n    }\n  }\n  rc = whereLoopXfer(db, p, pTemplate);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    Index *pIndex = p->u.btree.pIndex;\n    if( pIndex && pIndex->tnum==0 ){\n      p->u.btree.pIndex = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Adjust the WhereLoop.nOut value downward to account for terms of the\n** WHERE clause that reference the loop but which are not used by an\n** index.\n*\n** For every WHERE clause term that is not used by the index\n** and which has a truth probability assigned by one of the likelihood(),\n** likely(), or unlikely() SQL functions, reduce the estimated number\n** of output rows by the probability specified.\n**\n** TUNING:  For every WHERE clause term that is not used by the index\n** and which does not have an assigned truth probability, heuristics\n** described below are used to try to estimate the truth probability.\n** TODO --> Perhaps this is something that could be improved by better\n** table statistics.\n**\n** Heuristic 1:  Estimate the truth probability as 93.75%.  The 93.75%\n** value corresponds to -1 in LogEst notation, so this means decrement\n** the WhereLoop.nOut field for every such WHERE clause term.\n**\n** Heuristic 2:  If there exists one or more WHERE clause terms of the\n** form \"x==EXPR\" and EXPR is not a constant 0 or 1, then make sure the\n** final output row estimate is no greater than 1/4 of the total number\n** of rows in the table.  In other words, assume that x==EXPR will filter\n** out at least 3 out of 4 rows.  If EXPR is -1 or 0 or 1, then maybe the\n** \"x\" column is boolean or else -1 or 0 or 1 is a common default value\n** on the \"x\" column and so in that case only cap the output row estimate\n** at 1/2 instead of 1/4.\n*/\nstatic void whereLoopOutputAdjust(\n  WhereClause *pWC,      /* The WHERE clause */\n  WhereLoop *pLoop,      /* The loop to adjust downward */\n  LogEst nRow            /* Number of rows in the entire table */\n){\n  WhereTerm *pTerm, *pX;\n  Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);\n  int i, j, k;\n  LogEst iReduce = 0;    /* pLoop->nOut should not exceed nRow-iReduce */\n\n  assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n  for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){\n    if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;\n    if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;\n    if( (pTerm->prereqAll & notAllowed)!=0 ) continue;\n    for(j=pLoop->nLTerm-1; j>=0; j--){\n      pX = pLoop->aLTerm[j];\n      if( pX==0 ) continue;\n      if( pX==pTerm ) break;\n      if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;\n    }\n    if( j<0 ){\n      if( pTerm->truthProb<=0 ){\n        /* If a truth probability is specified using the likelihood() hints,\n        ** then use the probability provided by the application. */\n        pLoop->nOut += pTerm->truthProb;\n      }else{\n        /* In the absence of explicit truth probabilities, use heuristics to\n        ** guess a reasonable truth probability. */\n        pLoop->nOut--;\n        if( pTerm->eOperator&(WO_EQ|WO_IS) ){\n          Expr *pRight = pTerm->pExpr->pRight;\n          testcase( pTerm->pExpr->op==TK_IS );\n          if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){\n            k = 10;\n          }else{\n            k = 20;\n          }\n          if( iReduce<k ) iReduce = k;\n        }\n      }\n    }\n  }\n  if( pLoop->nOut > nRow-iReduce )  pLoop->nOut = nRow - iReduce;\n}\n\n/* \n** Term pTerm is a vector range comparison operation. The first comparison\n** in the vector can be optimized using column nEq of the index. This\n** function returns the total number of vector elements that can be used\n** as part of the range comparison.\n**\n** For example, if the query is:\n**\n**   WHERE a = ? AND (b, c, d) > (?, ?, ?)\n**\n** and the index:\n**\n**   CREATE INDEX ... ON (a, b, c, d, e)\n**\n** then this function would be invoked with nEq=1. The value returned in\n** this case is 3.\n*/\nstatic int whereRangeVectorLen(\n  Parse *pParse,       /* Parsing context */\n  int iCur,            /* Cursor open on pIdx */\n  Index *pIdx,         /* The index to be used for a inequality constraint */\n  int nEq,             /* Number of prior equality constraints on same index */\n  WhereTerm *pTerm     /* The vector inequality constraint */\n){\n  int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);\n  int i;\n\n  nCmp = MIN(nCmp, (pIdx->nColumn - nEq));\n  for(i=1; i<nCmp; i++){\n    /* Test if comparison i of pTerm is compatible with column (i+nEq) \n    ** of the index. If not, exit the loop.  */\n    char aff;                     /* Comparison affinity */\n    char idxaff = 0;              /* Indexed columns affinity */\n    CollSeq *pColl;               /* Comparison collation sequence */\n    Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;\n    Expr *pRhs = pTerm->pExpr->pRight;\n    if( pRhs->flags & EP_xIsSelect ){\n      pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      pRhs = pRhs->x.pList->a[i].pExpr;\n    }\n\n    /* Check that the LHS of the comparison is a column reference to\n    ** the right column of the right source table. And that the sort\n    ** order of the index column is the same as the sort order of the\n    ** leftmost index column.  */\n    if( pLhs->op!=TK_COLUMN \n     || pLhs->iTable!=iCur \n     || pLhs->iColumn!=pIdx->aiColumn[i+nEq] \n     || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]\n    ){\n      break;\n    }\n\n    testcase( pLhs->iColumn==XN_ROWID );\n    aff = sqlite3CompareAffinity(pRhs, sqlite3ExprAffinity(pLhs));\n    idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);\n    if( aff!=idxaff ) break;\n\n    pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n    if( pColl==0 ) break;\n    if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;\n  }\n  return i;\n}\n\n/*\n** Adjust the cost C by the costMult facter T.  This only occurs if\n** compiled with -DSQLITE_ENABLE_COSTMULT\n*/\n#ifdef SQLITE_ENABLE_COSTMULT\n# define ApplyCostMultiplier(C,T)  C += T\n#else\n# define ApplyCostMultiplier(C,T)\n#endif\n\n/*\n** We have so far matched pBuilder->pNew->u.btree.nEq terms of the \n** index pIndex. Try to match one more.\n**\n** When this function is called, pBuilder->pNew->nOut contains the \n** number of rows expected to be visited by filtering using the nEq \n** terms only. If it is modified, this value is restored before this \n** function returns.\n**\n** If pProbe->tnum==0, that means pIndex is a fake index used for the\n** INTEGER PRIMARY KEY.\n*/\nstatic int whereLoopAddBtreeIndex(\n  WhereLoopBuilder *pBuilder,     /* The WhereLoop factory */\n  struct SrcList_item *pSrc,      /* FROM clause term being analyzed */\n  Index *pProbe,                  /* An index on pSrc */\n  LogEst nInMul                   /* log(Number of iterations due to IN) */\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;  /* WHERE analyse context */\n  Parse *pParse = pWInfo->pParse;        /* Parsing context */\n  sqlite3 *db = pParse->db;       /* Database connection malloc context */\n  WhereLoop *pNew;                /* Template WhereLoop under construction */\n  WhereTerm *pTerm;               /* A WhereTerm under consideration */\n  int opMask;                     /* Valid operators for constraints */\n  WhereScan scan;                 /* Iterator for WHERE terms */\n  Bitmask saved_prereq;           /* Original value of pNew->prereq */\n  u16 saved_nLTerm;               /* Original value of pNew->nLTerm */\n  u16 saved_nEq;                  /* Original value of pNew->u.btree.nEq */\n  u16 saved_nBtm;                 /* Original value of pNew->u.btree.nBtm */\n  u16 saved_nTop;                 /* Original value of pNew->u.btree.nTop */\n  u16 saved_nSkip;                /* Original value of pNew->nSkip */\n  u32 saved_wsFlags;              /* Original value of pNew->wsFlags */\n  LogEst saved_nOut;              /* Original value of pNew->nOut */\n  int rc = SQLITE_OK;             /* Return code */\n  LogEst rSize;                   /* Number of rows in the table */\n  LogEst rLogSize;                /* Logarithm of table size */\n  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */\n\n  pNew = pBuilder->pNew;\n  if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n  WHERETRACE(0x800, (\"BEGIN addBtreeIdx(%s), nEq=%d\\n\",\n                     pProbe->zName, pNew->u.btree.nEq));\n\n  assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );\n  if( pNew->wsFlags & WHERE_BTM_LIMIT ){\n    opMask = WO_LT|WO_LE;\n  }else{\n    assert( pNew->u.btree.nBtm==0 );\n    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;\n  }\n  if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);\n\n  assert( pNew->u.btree.nEq<pProbe->nColumn );\n\n  saved_nEq = pNew->u.btree.nEq;\n  saved_nBtm = pNew->u.btree.nBtm;\n  saved_nTop = pNew->u.btree.nTop;\n  saved_nSkip = pNew->nSkip;\n  saved_nLTerm = pNew->nLTerm;\n  saved_wsFlags = pNew->wsFlags;\n  saved_prereq = pNew->prereq;\n  saved_nOut = pNew->nOut;\n  pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, saved_nEq,\n                        opMask, pProbe);\n  pNew->rSetup = 0;\n  rSize = pProbe->aiRowLogEst[0];\n  rLogSize = estLog(rSize);\n  for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){\n    u16 eOp = pTerm->eOperator;   /* Shorthand for pTerm->eOperator */\n    LogEst rCostIdx;\n    LogEst nOutUnadjusted;        /* nOut before IN() and WHERE adjustments */\n    int nIn = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    int nRecValid = pBuilder->nRecValid;\n#endif\n    if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)\n     && indexColumnNotNull(pProbe, saved_nEq)\n    ){\n      continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */\n    }\n    if( pTerm->prereqRight & pNew->maskSelf ) continue;\n\n    /* Do not allow the upper bound of a LIKE optimization range constraint\n    ** to mix with a lower range bound from some other source */\n    if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;\n\n    /* Do not allow IS constraints from the WHERE clause to be used by the\n    ** right table of a LEFT JOIN.  Only constraints in the ON clause are\n    ** allowed */\n    if( (pSrc->fg.jointype & JT_LEFT)!=0\n     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n     && (eOp & (WO_IS|WO_ISNULL))!=0\n    ){\n      testcase( eOp & WO_IS );\n      testcase( eOp & WO_ISNULL );\n      continue;\n    }\n\n    if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){\n      pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;\n    }else{\n      pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;\n    }\n    pNew->wsFlags = saved_wsFlags;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->u.btree.nBtm = saved_nBtm;\n    pNew->u.btree.nTop = saved_nTop;\n    pNew->nLTerm = saved_nLTerm;\n    if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n    pNew->aLTerm[pNew->nLTerm++] = pTerm;\n    pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;\n\n    assert( nInMul==0\n        || (pNew->wsFlags & WHERE_COLUMN_NULL)!=0 \n        || (pNew->wsFlags & WHERE_COLUMN_IN)!=0 \n        || (pNew->wsFlags & WHERE_SKIPSCAN)!=0 \n    );\n\n    if( eOp & WO_IN ){\n      Expr *pExpr = pTerm->pExpr;\n      pNew->wsFlags |= WHERE_COLUMN_IN;\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* \"x IN (SELECT ...)\":  TUNING: the SELECT returns 25 rows */\n        int i;\n        nIn = 46;  assert( 46==sqlite3LogEst(25) );\n\n        /* The expression may actually be of the form (x, y) IN (SELECT...).\n        ** In this case there is a separate term for each of (x) and (y).\n        ** However, the nIn multiplier should only be applied once, not once\n        ** for each such term. The following loop checks that pTerm is the\n        ** first such term in use, and sets nIn back to 0 if it is not. */\n        for(i=0; i<pNew->nLTerm-1; i++){\n          if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;\n        }\n      }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){\n        /* \"x IN (value, value, ...)\" */\n        nIn = sqlite3LogEst(pExpr->x.pList->nExpr);\n        assert( nIn>0 );  /* RHS always has 2 or more terms...  The parser\n                          ** changes \"x IN (?)\" into \"x=?\". */\n      }\n    }else if( eOp & (WO_EQ|WO_IS) ){\n      int iCol = pProbe->aiColumn[saved_nEq];\n      pNew->wsFlags |= WHERE_COLUMN_EQ;\n      assert( saved_nEq==pNew->u.btree.nEq );\n      if( iCol==XN_ROWID \n       || (iCol>0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1)\n      ){\n        if( iCol>=0 && pProbe->uniqNotNull==0 ){\n          pNew->wsFlags |= WHERE_UNQ_WANTED;\n        }else{\n          pNew->wsFlags |= WHERE_ONEROW;\n        }\n      }\n    }else if( eOp & WO_ISNULL ){\n      pNew->wsFlags |= WHERE_COLUMN_NULL;\n    }else if( eOp & (WO_GT|WO_GE) ){\n      testcase( eOp & WO_GT );\n      testcase( eOp & WO_GE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;\n      pNew->u.btree.nBtm = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pBtm = pTerm;\n      pTop = 0;\n      if( pTerm->wtFlags & TERM_LIKEOPT ){\n        /* Range contraints that come from the LIKE optimization are\n        ** always used in pairs. */\n        pTop = &pTerm[1];\n        assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );\n        assert( pTop->wtFlags & TERM_LIKEOPT );\n        assert( pTop->eOperator==WO_LT );\n        if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n        pNew->aLTerm[pNew->nLTerm++] = pTop;\n        pNew->wsFlags |= WHERE_TOP_LIMIT;\n        pNew->u.btree.nTop = 1;\n      }\n    }else{\n      assert( eOp & (WO_LT|WO_LE) );\n      testcase( eOp & WO_LT );\n      testcase( eOp & WO_LE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;\n      pNew->u.btree.nTop = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pTop = pTerm;\n      pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?\n                     pNew->aLTerm[pNew->nLTerm-2] : 0;\n    }\n\n    /* At this point pNew->nOut is set to the number of rows expected to\n    ** be visited by the index scan before considering term pTerm, or the\n    ** values of nIn and nInMul. In other words, assuming that all \n    ** \"x IN(...)\" terms are replaced with \"x = ?\". This block updates\n    ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul).  */\n    assert( pNew->nOut==saved_nOut );\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      /* Adjust nOut using stat3/stat4 data. Or, if there is no stat3/stat4\n      ** data, using some other estimate.  */\n      whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);\n    }else{\n      int nEq = ++pNew->u.btree.nEq;\n      assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );\n\n      assert( pNew->nOut==saved_nOut );\n      if( pTerm->truthProb<=0 && pProbe->aiColumn[saved_nEq]>=0 ){\n        assert( (eOp & WO_IN) || nIn==0 );\n        testcase( eOp & WO_IN );\n        pNew->nOut += pTerm->truthProb;\n        pNew->nOut -= nIn;\n      }else{\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n        tRowcnt nOut = 0;\n        if( nInMul==0 \n         && pProbe->nSample \n         && pNew->u.btree.nEq<=pProbe->nSampleCol\n         && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))\n        ){\n          Expr *pExpr = pTerm->pExpr;\n          if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){\n            testcase( eOp & WO_EQ );\n            testcase( eOp & WO_IS );\n            testcase( eOp & WO_ISNULL );\n            rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);\n          }else{\n            rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);\n          }\n          if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n          if( rc!=SQLITE_OK ) break;          /* Jump out of the pTerm loop */\n          if( nOut ){\n            pNew->nOut = sqlite3LogEst(nOut);\n            if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;\n            pNew->nOut -= nIn;\n          }\n        }\n        if( nOut==0 )\n#endif\n        {\n          pNew->nOut += (pProbe->aiRowLogEst[nEq] - pProbe->aiRowLogEst[nEq-1]);\n          if( eOp & WO_ISNULL ){\n            /* TUNING: If there is no likelihood() value, assume that a \n            ** \"col IS NULL\" expression matches twice as many rows \n            ** as (col=?). */\n            pNew->nOut += 10;\n          }\n        }\n      }\n    }\n\n    /* Set rCostIdx to the cost of visiting selected rows in index. Add\n    ** it to pNew->rRun, which is currently set to the cost of the index\n    ** seek only. Then, if this is a non-covering index, add the cost of\n    ** visiting the rows in the main table.  */\n    rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;\n    pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);\n    if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){\n      pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);\n    }\n    ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult);\n\n    nOutUnadjusted = pNew->nOut;\n    pNew->rRun += nInMul + nIn;\n    pNew->nOut += nInMul + nIn;\n    whereLoopOutputAdjust(pBuilder->pWC, pNew, rSize);\n    rc = whereLoopInsert(pBuilder, pNew);\n\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      pNew->nOut = saved_nOut;\n    }else{\n      pNew->nOut = nOutUnadjusted;\n    }\n\n    if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0\n     && pNew->u.btree.nEq<pProbe->nColumn\n    ){\n      whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);\n    }\n    pNew->nOut = saved_nOut;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    pBuilder->nRecValid = nRecValid;\n#endif\n  }\n  pNew->prereq = saved_prereq;\n  pNew->u.btree.nEq = saved_nEq;\n  pNew->u.btree.nBtm = saved_nBtm;\n  pNew->u.btree.nTop = saved_nTop;\n  pNew->nSkip = saved_nSkip;\n  pNew->wsFlags = saved_wsFlags;\n  pNew->nOut = saved_nOut;\n  pNew->nLTerm = saved_nLTerm;\n\n  /* Consider using a skip-scan if there are no WHERE clause constraints\n  ** available for the left-most terms of the index, and if the average\n  ** number of repeats in the left-most terms is at least 18. \n  **\n  ** The magic number 18 is selected on the basis that scanning 17 rows\n  ** is almost always quicker than an index seek (even though if the index\n  ** contains fewer than 2^17 rows we assume otherwise in other parts of\n  ** the code). And, even if it is not, it should not be too much slower. \n  ** On the other hand, the extra seeks could end up being significantly\n  ** more expensive.  */\n  assert( 42==sqlite3LogEst(18) );\n  if( saved_nEq==saved_nSkip\n   && saved_nEq+1<pProbe->nKeyCol\n   && pProbe->noSkipScan==0\n   && pProbe->aiRowLogEst[saved_nEq+1]>=42  /* TUNING: Minimum for skip-scan */\n   && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK\n  ){\n    LogEst nIter;\n    pNew->u.btree.nEq++;\n    pNew->nSkip++;\n    pNew->aLTerm[pNew->nLTerm++] = 0;\n    pNew->wsFlags |= WHERE_SKIPSCAN;\n    nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];\n    pNew->nOut -= nIter;\n    /* TUNING:  Because uncertainties in the estimates for skip-scan queries,\n    ** add a 1.375 fudge factor to make skip-scan slightly less likely. */\n    nIter += 5;\n    whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);\n    pNew->nOut = saved_nOut;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->nSkip = saved_nSkip;\n    pNew->wsFlags = saved_wsFlags;\n  }\n\n  WHERETRACE(0x800, (\"END addBtreeIdx(%s), nEq=%d, rc=%d\\n\",\n                      pProbe->zName, saved_nEq, rc));\n  return rc;\n}\n\n/*\n** Return True if it is possible that pIndex might be useful in\n** implementing the ORDER BY clause in pBuilder.\n**\n** Return False if pBuilder does not contain an ORDER BY clause or\n** if there is no way for pIndex to be useful in implementing that\n** ORDER BY clause.\n*/\nstatic int indexMightHelpWithOrderBy(\n  WhereLoopBuilder *pBuilder,\n  Index *pIndex,\n  int iCursor\n){\n  ExprList *pOB;\n  ExprList *aColExpr;\n  int ii, jj;\n\n  if( pIndex->bUnordered ) return 0;\n  if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;\n  for(ii=0; ii<pOB->nExpr; ii++){\n    Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);\n    if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){\n      if( pExpr->iColumn<0 ) return 1;\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;\n      }\n    }else if( (aColExpr = pIndex->aColExpr)!=0 ){\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;\n        if( sqlite3ExprCompareSkip(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Return a bitmask where 1s indicate that the corresponding column of\n** the table is used by an index.  Only the first 63 columns are considered.\n*/\nstatic Bitmask columnsInIndex(Index *pIdx){\n  Bitmask m = 0;\n  int j;\n  for(j=pIdx->nColumn-1; j>=0; j--){\n    int x = pIdx->aiColumn[j];\n    if( x>=0 ){\n      testcase( x==BMS-1 );\n      testcase( x==BMS-2 );\n      if( x<BMS-1 ) m |= MASKBIT(x);\n    }\n  }\n  return m;\n}\n\n/* Check to see if a partial index with pPartIndexWhere can be used\n** in the current query.  Return true if it can be and false if not.\n*/\nstatic int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){\n  int i;\n  WhereTerm *pTerm;\n  Parse *pParse = pWC->pWInfo->pParse;\n  while( pWhere->op==TK_AND ){\n    if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;\n    pWhere = pWhere->pRight;\n  }\n  if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;\n  for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)\n     && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) \n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Add all WhereLoop objects for a single table of the join where the table\n** is identified by pBuilder->pNew->iTab.  That table is guaranteed to be\n** a b-tree table, not a virtual table.\n**\n** The costs (WhereLoop.rRun) of the b-tree loops added by this function\n** are calculated as follows:\n**\n** For a full scan, assuming the table (or index) contains nRow rows:\n**\n**     cost = nRow * 3.0                    // full-table scan\n**     cost = nRow * K                      // scan of covering index\n**     cost = nRow * (K+3.0)                // scan of non-covering index\n**\n** where K is a value between 1.1 and 3.0 set based on the relative \n** estimated average size of the index and table records.\n**\n** For an index scan, where nVisit is the number of index rows visited\n** by the scan, and nSeek is the number of seek operations required on \n** the index b-tree:\n**\n**     cost = nSeek * (log(nRow) + K * nVisit)          // covering index\n**     cost = nSeek * (log(nRow) + (K+3.0) * nVisit)    // non-covering index\n**\n** Normally, nSeek is 1. nSeek values greater than 1 come about if the \n** WHERE clause includes \"x IN (....)\" terms used in place of \"x=?\". Or when \n** implicit \"x IN (SELECT x FROM tbl)\" terms are added for skip-scans.\n**\n** The estimated values (nRow, nVisit, nSeek) often contain a large amount\n** of uncertainty.  For this reason, scoring is designed to pick plans that\n** \"do the least harm\" if the estimates are inaccurate.  For example, a\n** log(nRow) factor is omitted from a non-covering index scan in order to\n** bias the scoring in favor of using an index, since the worst-case\n** performance of using an index is far better than the worst-case performance\n** of a full table scan.\n*/\nstatic int whereLoopAddBtree(\n  WhereLoopBuilder *pBuilder, /* WHERE clause information */\n  Bitmask mPrereq             /* Extra prerequesites for using this table */\n){\n  WhereInfo *pWInfo;          /* WHERE analysis context */\n  Index *pProbe;              /* An index we are evaluating */\n  Index sPk;                  /* A fake index object for the primary key */\n  LogEst aiRowEstPk[2];       /* The aiRowLogEst[] value for the sPk index */\n  i16 aiColumnPk = -1;        /* The aColumn[] value for the sPk index */\n  SrcList *pTabList;          /* The FROM clause */\n  struct SrcList_item *pSrc;  /* The FROM clause btree term to add */\n  WhereLoop *pNew;            /* Template WhereLoop object */\n  int rc = SQLITE_OK;         /* Return code */\n  int iSortIdx = 1;           /* Index number */\n  int b;                      /* A boolean value */\n  LogEst rSize;               /* number of rows in the table */\n  LogEst rLogSize;            /* Logarithm of the number of rows in the table */\n  WhereClause *pWC;           /* The parsed WHERE clause */\n  Table *pTab;                /* Table being queried */\n  \n  pNew = pBuilder->pNew;\n  pWInfo = pBuilder->pWInfo;\n  pTabList = pWInfo->pTabList;\n  pSrc = pTabList->a + pNew->iTab;\n  pTab = pSrc->pTab;\n  pWC = pBuilder->pWC;\n  assert( !IsVirtual(pSrc->pTab) );\n\n  if( pSrc->pIBIndex ){\n    /* An INDEXED BY clause specifies a particular index to use */\n    pProbe = pSrc->pIBIndex;\n  }else if( !HasRowid(pTab) ){\n    pProbe = pTab->pIndex;\n  }else{\n    /* There is no INDEXED BY clause.  Create a fake Index object in local\n    ** variable sPk to represent the rowid primary key index.  Make this\n    ** fake index the first in a chain of Index objects with all of the real\n    ** indices to follow */\n    Index *pFirst;                  /* First of real indices on the table */\n    memset(&sPk, 0, sizeof(Index));\n    sPk.nKeyCol = 1;\n    sPk.nColumn = 1;\n    sPk.aiColumn = &aiColumnPk;\n    sPk.aiRowLogEst = aiRowEstPk;\n    sPk.onError = OE_Replace;\n    sPk.pTable = pTab;\n    sPk.szIdxRow = pTab->szTabRow;\n    aiRowEstPk[0] = pTab->nRowLogEst;\n    aiRowEstPk[1] = 0;\n    pFirst = pSrc->pTab->pIndex;\n    if( pSrc->fg.notIndexed==0 ){\n      /* The real indices of the table are only considered if the\n      ** NOT INDEXED qualifier is omitted from the FROM clause */\n      sPk.pNext = pFirst;\n    }\n    pProbe = &sPk;\n  }\n  rSize = pTab->nRowLogEst;\n  rLogSize = estLog(rSize);\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n  /* Automatic indexes */\n  if( !pBuilder->pOrSet      /* Not part of an OR optimization */\n   && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n   && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0\n   && pSrc->pIBIndex==0      /* Has no INDEXED BY clause */\n   && !pSrc->fg.notIndexed   /* Has no NOT INDEXED clause */\n   && HasRowid(pTab)         /* Not WITHOUT ROWID table. (FIXME: Why not?) */\n   && !pSrc->fg.isCorrelated /* Not a correlated subquery */\n   && !pSrc->fg.isRecursive  /* Not a recursive common table expression. */\n  ){\n    /* Generate auto-index WhereLoops */\n    WhereTerm *pTerm;\n    WhereTerm *pWCEnd = pWC->a + pWC->nTerm;\n    for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){\n      if( pTerm->prereqRight & pNew->maskSelf ) continue;\n      if( termCanDriveIndex(pTerm, pSrc, 0) ){\n        pNew->u.btree.nEq = 1;\n        pNew->nSkip = 0;\n        pNew->u.btree.pIndex = 0;\n        pNew->nLTerm = 1;\n        pNew->aLTerm[0] = pTerm;\n        /* TUNING: One-time cost for computing the automatic index is\n        ** estimated to be X*N*log2(N) where N is the number of rows in\n        ** the table being indexed and where X is 7 (LogEst=28) for normal\n        ** tables or 1.375 (LogEst=4) for views and subqueries.  The value\n        ** of X is smaller for views and subqueries so that the query planner\n        ** will be more aggressive about generating automatic indexes for\n        ** those objects, since there is no opportunity to add schema\n        ** indexes on subqueries and views. */\n        pNew->rSetup = rLogSize + rSize + 4;\n        if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){\n          pNew->rSetup += 24;\n        }\n        ApplyCostMultiplier(pNew->rSetup, pTab->costMult);\n        if( pNew->rSetup<0 ) pNew->rSetup = 0;\n        /* TUNING: Each index lookup yields 20 rows in the table.  This\n        ** is more than the usual guess of 10 rows, since we have no way\n        ** of knowing how selective the index will ultimately be.  It would\n        ** not be unreasonable to make this value much larger. */\n        pNew->nOut = 43;  assert( 43==sqlite3LogEst(20) );\n        pNew->rRun = sqlite3LogEstAdd(rLogSize,pNew->nOut);\n        pNew->wsFlags = WHERE_AUTO_INDEX;\n        pNew->prereq = mPrereq | pTerm->prereqRight;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n    }\n  }\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n  /* Loop over all indices\n  */\n  for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){\n    if( pProbe->pPartIdxWhere!=0\n     && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){\n      testcase( pNew->iTab!=pSrc->iCursor );  /* See ticket [98d973b8f5] */\n      continue;  /* Partial index inappropriate for this query */\n    }\n    rSize = pProbe->aiRowLogEst[0];\n    pNew->u.btree.nEq = 0;\n    pNew->u.btree.nBtm = 0;\n    pNew->u.btree.nTop = 0;\n    pNew->nSkip = 0;\n    pNew->nLTerm = 0;\n    pNew->iSortIdx = 0;\n    pNew->rSetup = 0;\n    pNew->prereq = mPrereq;\n    pNew->nOut = rSize;\n    pNew->u.btree.pIndex = pProbe;\n    b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);\n    /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */\n    assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );\n    if( pProbe->tnum<=0 ){\n      /* Integer primary key index */\n      pNew->wsFlags = WHERE_IPK;\n\n      /* Full table scan */\n      pNew->iSortIdx = b ? iSortIdx : 0;\n      /* TUNING: Cost of full table scan is (N*3.0). */\n      pNew->rRun = rSize + 16;\n      ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n      whereLoopOutputAdjust(pWC, pNew, rSize);\n      rc = whereLoopInsert(pBuilder, pNew);\n      pNew->nOut = rSize;\n      if( rc ) break;\n    }else{\n      Bitmask m;\n      if( pProbe->isCovering ){\n        pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;\n        m = 0;\n      }else{\n        m = pSrc->colUsed & ~columnsInIndex(pProbe);\n        pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;\n      }\n\n      /* Full scan via index */\n      if( b\n       || !HasRowid(pTab)\n       || pProbe->pPartIdxWhere!=0\n       || ( m==0\n         && pProbe->bUnordered==0\n         && (pProbe->szIdxRow<pTab->szTabRow)\n         && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0\n         && sqlite3GlobalConfig.bUseCis\n         && OptimizationEnabled(pWInfo->pParse->db, SQLITE_CoverIdxScan)\n          )\n      ){\n        pNew->iSortIdx = b ? iSortIdx : 0;\n\n        /* The cost of visiting the index rows is N*K, where K is\n        ** between 1.1 and 3.0, depending on the relative sizes of the\n        ** index and table rows. */\n        pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;\n        if( m!=0 ){\n          /* If this is a non-covering index scan, add in the cost of\n          ** doing table lookups.  The cost will be 3x the number of\n          ** lookups.  Take into account WHERE clause terms that can be\n          ** satisfied using just the index, and that do not require a\n          ** table lookup. */\n          LogEst nLookup = rSize + 16;  /* Base cost:  N*3 */\n          int ii;\n          int iCur = pSrc->iCursor;\n          WhereClause *pWC2 = &pWInfo->sWC;\n          for(ii=0; ii<pWC2->nTerm; ii++){\n            WhereTerm *pTerm = &pWC2->a[ii];\n            if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){\n              break;\n            }\n            /* pTerm can be evaluated using just the index.  So reduce\n            ** the expected number of table lookups accordingly */\n            if( pTerm->truthProb<=0 ){\n              nLookup += pTerm->truthProb;\n            }else{\n              nLookup--;\n              if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19;\n            }\n          }\n          \n          pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup);\n        }\n        ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n        whereLoopOutputAdjust(pWC, pNew, rSize);\n        rc = whereLoopInsert(pBuilder, pNew);\n        pNew->nOut = rSize;\n        if( rc ) break;\n      }\n    }\n\n    pBuilder->bldFlags = 0;\n    rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);\n    if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){\n      /* If a non-unique index is used, or if a prefix of the key for\n      ** unique index is used (making the index functionally non-unique)\n      ** then the sqlite_stat1 data becomes important for scoring the\n      ** plan */\n      pTab->tabFlags |= TF_StatsUsed;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3Stat4ProbeFree(pBuilder->pRec);\n    pBuilder->nRecValid = 0;\n    pBuilder->pRec = 0;\n#endif\n\n    /* If there was an INDEXED BY clause, then only that one index is\n    ** considered. */\n    if( pSrc->pIBIndex ) break;\n  }\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Argument pIdxInfo is already populated with all constraints that may\n** be used by the virtual table identified by pBuilder->pNew->iTab. This\n** function marks a subset of those constraints usable, invokes the\n** xBestIndex method and adds the returned plan to pBuilder.\n**\n** A constraint is marked usable if:\n**\n**   * Argument mUsable indicates that its prerequisites are available, and\n**\n**   * It is not one of the operators specified in the mExclude mask passed\n**     as the fourth argument (which in practice is either WO_IN or 0).\n**\n** Argument mPrereq is a mask of tables that must be scanned before the\n** virtual table in question. These are added to the plans prerequisites\n** before it is added to pBuilder.\n**\n** Output parameter *pbIn is set to true if the plan added to pBuilder\n** uses one or more WO_IN terms, or false otherwise.\n*/\nstatic int whereLoopAddVirtualOne(\n  WhereLoopBuilder *pBuilder,\n  Bitmask mPrereq,                /* Mask of tables that must be used. */\n  Bitmask mUsable,                /* Mask of usable tables */\n  u16 mExclude,                   /* Exclude terms using these operators */\n  sqlite3_index_info *pIdxInfo,   /* Populated object for xBestIndex */\n  u16 mNoOmit,                    /* Do not omit these constraints */\n  int *pbIn                       /* OUT: True if plan uses an IN(...) op */\n){\n  WhereClause *pWC = pBuilder->pWC;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;\n  int i;\n  int mxTerm;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew = pBuilder->pNew;\n  Parse *pParse = pBuilder->pWInfo->pParse;\n  struct SrcList_item *pSrc = &pBuilder->pWInfo->pTabList->a[pNew->iTab];\n  int nConstraint = pIdxInfo->nConstraint;\n\n  assert( (mUsable & mPrereq)==mPrereq );\n  *pbIn = 0;\n  pNew->prereq = mPrereq;\n\n  /* Set the usable flag on the subset of constraints identified by \n  ** arguments mUsable and mExclude. */\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    WhereTerm *pTerm = &pWC->a[pIdxCons->iTermOffset];\n    pIdxCons->usable = 0;\n    if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight \n     && (pTerm->eOperator & mExclude)==0\n    ){\n      pIdxCons->usable = 1;\n    }\n  }\n\n  /* Initialize the output fields of the sqlite3_index_info structure */\n  memset(pUsage, 0, sizeof(pUsage[0])*nConstraint);\n  assert( pIdxInfo->needToFreeIdxStr==0 );\n  pIdxInfo->idxStr = 0;\n  pIdxInfo->idxNum = 0;\n  pIdxInfo->orderByConsumed = 0;\n  pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;\n  pIdxInfo->estimatedRows = 25;\n  pIdxInfo->idxFlags = 0;\n  pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;\n\n  /* Invoke the virtual table xBestIndex() method */\n  rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);\n  if( rc ) return rc;\n\n  mxTerm = -1;\n  assert( pNew->nLSlot>=nConstraint );\n  for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;\n  pNew->u.vtab.omitMask = 0;\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    int iTerm;\n    if( (iTerm = pUsage[i].argvIndex - 1)>=0 ){\n      WhereTerm *pTerm;\n      int j = pIdxCons->iTermOffset;\n      if( iTerm>=nConstraint\n       || j<0\n       || j>=pWC->nTerm\n       || pNew->aLTerm[iTerm]!=0\n       || pIdxCons->usable==0\n      ){\n        rc = SQLITE_ERROR;\n        sqlite3ErrorMsg(pParse,\"%s.xBestIndex malfunction\",pSrc->pTab->zName);\n        return rc;\n      }\n      testcase( iTerm==nConstraint-1 );\n      testcase( j==0 );\n      testcase( j==pWC->nTerm-1 );\n      pTerm = &pWC->a[j];\n      pNew->prereq |= pTerm->prereqRight;\n      assert( iTerm<pNew->nLSlot );\n      pNew->aLTerm[iTerm] = pTerm;\n      if( iTerm>mxTerm ) mxTerm = iTerm;\n      testcase( iTerm==15 );\n      testcase( iTerm==16 );\n      if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm;\n      if( (pTerm->eOperator & WO_IN)!=0 ){\n        /* A virtual table that is constrained by an IN clause may not\n        ** consume the ORDER BY clause because (1) the order of IN terms\n        ** is not necessarily related to the order of output terms and\n        ** (2) Multiple outputs from a single IN value will not merge\n        ** together.  */\n        pIdxInfo->orderByConsumed = 0;\n        pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;\n        *pbIn = 1; assert( (mExclude & WO_IN)==0 );\n      }\n    }\n  }\n  pNew->u.vtab.omitMask &= ~mNoOmit;\n\n  pNew->nLTerm = mxTerm+1;\n  assert( pNew->nLTerm<=pNew->nLSlot );\n  pNew->u.vtab.idxNum = pIdxInfo->idxNum;\n  pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;\n  pIdxInfo->needToFreeIdxStr = 0;\n  pNew->u.vtab.idxStr = pIdxInfo->idxStr;\n  pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ?\n      pIdxInfo->nOrderBy : 0);\n  pNew->rSetup = 0;\n  pNew->rRun = sqlite3LogEstFromDouble(pIdxInfo->estimatedCost);\n  pNew->nOut = sqlite3LogEst(pIdxInfo->estimatedRows);\n\n  /* Set the WHERE_ONEROW flag if the xBestIndex() method indicated\n  ** that the scan will visit at most one row. Clear it otherwise. */\n  if( pIdxInfo->idxFlags & SQLITE_INDEX_SCAN_UNIQUE ){\n    pNew->wsFlags |= WHERE_ONEROW;\n  }else{\n    pNew->wsFlags &= ~WHERE_ONEROW;\n  }\n  rc = whereLoopInsert(pBuilder, pNew);\n  if( pNew->u.vtab.needFree ){\n    sqlite3_free(pNew->u.vtab.idxStr);\n    pNew->u.vtab.needFree = 0;\n  }\n  WHERETRACE(0xffff, (\"  bIn=%d prereqIn=%04llx prereqOut=%04llx\\n\",\n                      *pbIn, (sqlite3_uint64)mPrereq,\n                      (sqlite3_uint64)(pNew->prereq & ~mPrereq)));\n\n  return rc;\n}\n\n\n/*\n** Add all WhereLoop objects for a table of the join identified by\n** pBuilder->pNew->iTab.  That table is guaranteed to be a virtual table.\n**\n** If there are no LEFT or CROSS JOIN joins in the query, both mPrereq and\n** mUnusable are set to 0. Otherwise, mPrereq is a mask of all FROM clause\n** entries that occur before the virtual table in the FROM clause and are\n** separated from it by at least one LEFT or CROSS JOIN. Similarly, the\n** mUnusable mask contains all FROM clause entries that occur after the\n** virtual table and are separated from it by at least one LEFT or \n** CROSS JOIN. \n**\n** For example, if the query were:\n**\n**   ... FROM t1, t2 LEFT JOIN t3, t4, vt CROSS JOIN t5, t6;\n**\n** then mPrereq corresponds to (t1, t2) and mUnusable to (t5, t6).\n**\n** All the tables in mPrereq must be scanned before the current virtual \n** table. So any terms for which all prerequisites are satisfied by \n** mPrereq may be specified as \"usable\" in all calls to xBestIndex. \n** Conversely, all tables in mUnusable must be scanned after the current\n** virtual table, so any terms for which the prerequisites overlap with\n** mUnusable should always be configured as \"not-usable\" for xBestIndex.\n*/\nstatic int whereLoopAddVirtual(\n  WhereLoopBuilder *pBuilder,  /* WHERE clause information */\n  Bitmask mPrereq,             /* Tables that must be scanned before this one */\n  Bitmask mUnusable            /* Tables that must be scanned after this one */\n){\n  int rc = SQLITE_OK;          /* Return code */\n  WhereInfo *pWInfo;           /* WHERE analysis context */\n  Parse *pParse;               /* The parsing context */\n  WhereClause *pWC;            /* The WHERE clause */\n  struct SrcList_item *pSrc;   /* The FROM clause term to search */\n  sqlite3_index_info *p;       /* Object to pass to xBestIndex() */\n  int nConstraint;             /* Number of constraints in p */\n  int bIn;                     /* True if plan uses IN(...) operator */\n  WhereLoop *pNew;\n  Bitmask mBest;               /* Tables used by best possible plan */\n  u16 mNoOmit;\n\n  assert( (mPrereq & mUnusable)==0 );\n  pWInfo = pBuilder->pWInfo;\n  pParse = pWInfo->pParse;\n  pWC = pBuilder->pWC;\n  pNew = pBuilder->pNew;\n  pSrc = &pWInfo->pTabList->a[pNew->iTab];\n  assert( IsVirtual(pSrc->pTab) );\n  p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy, \n      &mNoOmit);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  pNew->rSetup = 0;\n  pNew->wsFlags = WHERE_VIRTUALTABLE;\n  pNew->nLTerm = 0;\n  pNew->u.vtab.needFree = 0;\n  nConstraint = p->nConstraint;\n  if( whereLoopResize(pParse->db, pNew, nConstraint) ){\n    sqlite3DbFree(pParse->db, p);\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* First call xBestIndex() with all constraints usable. */\n  WHERETRACE(0x40, (\"  VirtualOne: all usable\\n\"));\n  rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);\n\n  /* If the call to xBestIndex() with all terms enabled produced a plan\n  ** that does not require any source tables (IOW: a plan with mBest==0),\n  ** then there is no point in making any further calls to xBestIndex() \n  ** since they will all return the same result (if the xBestIndex()\n  ** implementation is sane). */\n  if( rc==SQLITE_OK && (mBest = (pNew->prereq & ~mPrereq))!=0 ){\n    int seenZero = 0;             /* True if a plan with no prereqs seen */\n    int seenZeroNoIN = 0;         /* Plan with no prereqs and no IN(...) seen */\n    Bitmask mPrev = 0;\n    Bitmask mBestNoIn = 0;\n\n    /* If the plan produced by the earlier call uses an IN(...) term, call\n    ** xBestIndex again, this time with IN(...) terms disabled. */\n    if( bIn ){\n      WHERETRACE(0x40, (\"  VirtualOne: all usable w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);\n      assert( bIn==0 );\n      mBestNoIn = pNew->prereq & ~mPrereq;\n      if( mBestNoIn==0 ){\n        seenZero = 1;\n        seenZeroNoIN = 1;\n      }\n    }\n\n    /* Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) \n    ** in the set of terms that apply to the current virtual table.  */\n    while( rc==SQLITE_OK ){\n      int i;\n      Bitmask mNext = ALLBITS;\n      assert( mNext>0 );\n      for(i=0; i<nConstraint; i++){\n        Bitmask mThis = (\n            pWC->a[p->aConstraint[i].iTermOffset].prereqRight & ~mPrereq\n        );\n        if( mThis>mPrev && mThis<mNext ) mNext = mThis;\n      }\n      mPrev = mNext;\n      if( mNext==ALLBITS ) break;\n      if( mNext==mBest || mNext==mBestNoIn ) continue;\n      WHERETRACE(0x40, (\"  VirtualOne: mPrev=%04llx mNext=%04llx\\n\",\n                       (sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);\n      if( pNew->prereq==mPrereq ){\n        seenZero = 1;\n        if( bIn==0 ) seenZeroNoIN = 1;\n      }\n    }\n\n    /* If the calls to xBestIndex() in the above loop did not find a plan\n    ** that requires no source tables at all (i.e. one guaranteed to be\n    ** usable), make a call here with all source tables disabled */\n    if( rc==SQLITE_OK && seenZero==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);\n      if( bIn==0 ) seenZeroNoIN = 1;\n    }\n\n    /* If the calls to xBestIndex() have so far failed to find a plan\n    ** that requires no source tables at all and does not use an IN(...)\n    ** operator, make a final call to obtain one here.  */\n    if( rc==SQLITE_OK && seenZeroNoIN==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled and w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);\n    }\n  }\n\n  if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);\n  sqlite3DbFreeNN(pParse->db, p);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Add WhereLoop entries to handle OR terms.  This works for either\n** btrees or virtual tables.\n*/\nstatic int whereLoopAddOr(\n  WhereLoopBuilder *pBuilder, \n  Bitmask mPrereq, \n  Bitmask mUnusable\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  WhereClause *pWC;\n  WhereLoop *pNew;\n  WhereTerm *pTerm, *pWCEnd;\n  int rc = SQLITE_OK;\n  int iCur;\n  WhereClause tempWC;\n  WhereLoopBuilder sSubBuild;\n  WhereOrSet sSum, sCur;\n  struct SrcList_item *pItem;\n  \n  pWC = pBuilder->pWC;\n  pWCEnd = pWC->a + pWC->nTerm;\n  pNew = pBuilder->pNew;\n  memset(&sSum, 0, sizeof(sSum));\n  pItem = pWInfo->pTabList->a + pNew->iTab;\n  iCur = pItem->iCursor;\n\n  for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){\n    if( (pTerm->eOperator & WO_OR)!=0\n     && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 \n    ){\n      WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;\n      WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];\n      WhereTerm *pOrTerm;\n      int once = 1;\n      int i, j;\n    \n      sSubBuild = *pBuilder;\n      sSubBuild.pOrderBy = 0;\n      sSubBuild.pOrSet = &sCur;\n\n      WHERETRACE(0x200, (\"Begin processing OR-clause %p\\n\", pTerm));\n      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){\n        if( (pOrTerm->eOperator & WO_AND)!=0 ){\n          sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;\n        }else if( pOrTerm->leftCursor==iCur ){\n          tempWC.pWInfo = pWC->pWInfo;\n          tempWC.pOuter = pWC;\n          tempWC.op = TK_AND;\n          tempWC.nTerm = 1;\n          tempWC.a = pOrTerm;\n          sSubBuild.pWC = &tempWC;\n        }else{\n          continue;\n        }\n        sCur.n = 0;\n#ifdef WHERETRACE_ENABLED\n        WHERETRACE(0x200, (\"OR-term %d of %p has %d subterms:\\n\", \n                   (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));\n        if( sqlite3WhereTrace & 0x400 ){\n          sqlite3WhereClausePrint(sSubBuild.pWC);\n        }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        if( IsVirtual(pItem->pTab) ){\n          rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);\n        }else\n#endif\n        {\n          rc = whereLoopAddBtree(&sSubBuild, mPrereq);\n        }\n        if( rc==SQLITE_OK ){\n          rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);\n        }\n        assert( rc==SQLITE_OK || sCur.n==0 );\n        if( sCur.n==0 ){\n          sSum.n = 0;\n          break;\n        }else if( once ){\n          whereOrMove(&sSum, &sCur);\n          once = 0;\n        }else{\n          WhereOrSet sPrev;\n          whereOrMove(&sPrev, &sSum);\n          sSum.n = 0;\n          for(i=0; i<sPrev.n; i++){\n            for(j=0; j<sCur.n; j++){\n              whereOrInsert(&sSum, sPrev.a[i].prereq | sCur.a[j].prereq,\n                            sqlite3LogEstAdd(sPrev.a[i].rRun, sCur.a[j].rRun),\n                            sqlite3LogEstAdd(sPrev.a[i].nOut, sCur.a[j].nOut));\n            }\n          }\n        }\n      }\n      pNew->nLTerm = 1;\n      pNew->aLTerm[0] = pTerm;\n      pNew->wsFlags = WHERE_MULTI_OR;\n      pNew->rSetup = 0;\n      pNew->iSortIdx = 0;\n      memset(&pNew->u, 0, sizeof(pNew->u));\n      for(i=0; rc==SQLITE_OK && i<sSum.n; i++){\n        /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs\n        ** of all sub-scans required by the OR-scan. However, due to rounding\n        ** errors, it may be that the cost of the OR-scan is equal to its\n        ** most expensive sub-scan. Add the smallest possible penalty \n        ** (equivalent to multiplying the cost by 1.07) to ensure that \n        ** this does not happen. Otherwise, for WHERE clauses such as the\n        ** following where there is an index on \"y\":\n        **\n        **     WHERE likelihood(x=?, 0.99) OR y=?\n        **\n        ** the planner may elect to \"OR\" together a full-table scan and an\n        ** index lookup. And other similarly odd results.  */\n        pNew->rRun = sSum.a[i].rRun + 1;\n        pNew->nOut = sSum.a[i].nOut;\n        pNew->prereq = sSum.a[i].prereq;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n      WHERETRACE(0x200, (\"End processing OR-clause %p\\n\", pTerm));\n    }\n  }\n  return rc;\n}\n\n/*\n** Add all WhereLoop objects for all tables \n*/\nstatic int whereLoopAddAll(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  Bitmask mPrereq = 0;\n  Bitmask mPrior = 0;\n  int iTab;\n  SrcList *pTabList = pWInfo->pTabList;\n  struct SrcList_item *pItem;\n  struct SrcList_item *pEnd = &pTabList->a[pWInfo->nLevel];\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew;\n  u8 priorJointype = 0;\n\n  /* Loop over the tables in the join, from left to right */\n  pNew = pBuilder->pNew;\n  whereLoopInit(pNew);\n  for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){\n    Bitmask mUnusable = 0;\n    pNew->iTab = iTab;\n    pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);\n    if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){\n      /* This condition is true when pItem is the FROM clause term on the\n      ** right-hand-side of a LEFT or CROSS JOIN.  */\n      mPrereq = mPrior;\n    }\n    priorJointype = pItem->fg.jointype;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pItem->pTab) ){\n      struct SrcList_item *p;\n      for(p=&pItem[1]; p<pEnd; p++){\n        if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){\n          mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);\n        }\n      }\n      rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);\n    }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n    {\n      rc = whereLoopAddBtree(pBuilder, mPrereq);\n    }\n    if( rc==SQLITE_OK ){\n      rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);\n    }\n    mPrior |= pNew->maskSelf;\n    if( rc || db->mallocFailed ) break;\n  }\n\n  whereLoopClear(db, pNew);\n  return rc;\n}\n\n/*\n** Examine a WherePath (with the addition of the extra WhereLoop of the 6th\n** parameters) to see if it outputs rows in the requested ORDER BY\n** (or GROUP BY) without requiring a separate sort operation.  Return N:\n** \n**   N>0:   N terms of the ORDER BY clause are satisfied\n**   N==0:  No terms of the ORDER BY clause are satisfied\n**   N<0:   Unknown yet how many terms of ORDER BY might be satisfied.   \n**\n** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as\n** strict.  With GROUP BY and DISTINCT the only requirement is that\n** equivalent rows appear immediately adjacent to one another.  GROUP BY\n** and DISTINCT do not require rows to appear in any particular order as long\n** as equivalent rows are grouped together.  Thus for GROUP BY and DISTINCT\n** the pOrderBy terms can be matched in any order.  With ORDER BY, the \n** pOrderBy terms must be matched in strict left-to-right order.\n*/\nstatic i8 wherePathSatisfiesOrderBy(\n  WhereInfo *pWInfo,    /* The WHERE clause */\n  ExprList *pOrderBy,   /* ORDER BY or GROUP BY or DISTINCT clause to check */\n  WherePath *pPath,     /* The WherePath to check */\n  u16 wctrlFlags,       /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */\n  u16 nLoop,            /* Number of entries in pPath->aLoop[] */\n  WhereLoop *pLast,     /* Add this WhereLoop to the end of pPath->aLoop[] */\n  Bitmask *pRevMask     /* OUT: Mask of WhereLoops to run in reverse order */\n){\n  u8 revSet;            /* True if rev is known */\n  u8 rev;               /* Composite sort order */\n  u8 revIdx;            /* Index sort order */\n  u8 isOrderDistinct;   /* All prior WhereLoops are order-distinct */\n  u8 distinctColumns;   /* True if the loop has UNIQUE NOT NULL columns */\n  u8 isMatch;           /* iColumn matches a term of the ORDER BY clause */\n  u16 eqOpMask;         /* Allowed equality operators */\n  u16 nKeyCol;          /* Number of key columns in pIndex */\n  u16 nColumn;          /* Total number of ordered columns in the index */\n  u16 nOrderBy;         /* Number terms in the ORDER BY clause */\n  int iLoop;            /* Index of WhereLoop in pPath being processed */\n  int i, j;             /* Loop counters */\n  int iCur;             /* Cursor number for current WhereLoop */\n  int iColumn;          /* A column number within table iCur */\n  WhereLoop *pLoop = 0; /* Current WhereLoop being processed. */\n  WhereTerm *pTerm;     /* A single term of the WHERE clause */\n  Expr *pOBExpr;        /* An expression from the ORDER BY clause */\n  CollSeq *pColl;       /* COLLATE function from an ORDER BY clause term */\n  Index *pIndex;        /* The index associated with pLoop */\n  sqlite3 *db = pWInfo->pParse->db;  /* Database connection */\n  Bitmask obSat = 0;    /* Mask of ORDER BY terms satisfied so far */\n  Bitmask obDone;       /* Mask of all ORDER BY terms */\n  Bitmask orderDistinctMask;  /* Mask of all well-ordered loops */\n  Bitmask ready;              /* Mask of inner loops */\n\n  /*\n  ** We say the WhereLoop is \"one-row\" if it generates no more than one\n  ** row of output.  A WhereLoop is one-row if all of the following are true:\n  **  (a) All index columns match with WHERE_COLUMN_EQ.\n  **  (b) The index is unique\n  ** Any WhereLoop with an WHERE_COLUMN_EQ constraint on the rowid is one-row.\n  ** Every one-row WhereLoop will have the WHERE_ONEROW bit set in wsFlags.\n  **\n  ** We say the WhereLoop is \"order-distinct\" if the set of columns from\n  ** that WhereLoop that are in the ORDER BY clause are different for every\n  ** row of the WhereLoop.  Every one-row WhereLoop is automatically\n  ** order-distinct.   A WhereLoop that has no columns in the ORDER BY clause\n  ** is not order-distinct. To be order-distinct is not quite the same as being\n  ** UNIQUE since a UNIQUE column or index can have multiple rows that \n  ** are NULL and NULL values are equivalent for the purpose of order-distinct.\n  ** To be order-distinct, the columns must be UNIQUE and NOT NULL.\n  **\n  ** The rowid for a table is always UNIQUE and NOT NULL so whenever the\n  ** rowid appears in the ORDER BY clause, the corresponding WhereLoop is\n  ** automatically order-distinct.\n  */\n\n  assert( pOrderBy!=0 );\n  if( nLoop && OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ) return 0;\n\n  nOrderBy = pOrderBy->nExpr;\n  testcase( nOrderBy==BMS-1 );\n  if( nOrderBy>BMS-1 ) return 0;  /* Cannot optimize overly large ORDER BYs */\n  isOrderDistinct = 1;\n  obDone = MASKBIT(nOrderBy)-1;\n  orderDistinctMask = 0;\n  ready = 0;\n  eqOpMask = WO_EQ | WO_IS | WO_ISNULL;\n  if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;\n  for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){\n    if( iLoop>0 ) ready |= pLoop->maskSelf;\n    if( iLoop<nLoop ){\n      pLoop = pPath->aLoop[iLoop];\n      if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;\n    }else{\n      pLoop = pLast;\n    }\n    if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){\n      if( pLoop->u.vtab.isOrdered ) obSat = obDone;\n      break;\n    }else{\n      pLoop->u.btree.nIdxCol = 0;\n    }\n    iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;\n\n    /* Mark off any ORDER BY term X that is a column in the table of\n    ** the current loop for which there is term in the WHERE\n    ** clause of the form X IS NULL or X=? that reference only outer\n    ** loops.\n    */\n    for(i=0; i<nOrderBy; i++){\n      if( MASKBIT(i) & obSat ) continue;\n      pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n      if( pOBExpr->op!=TK_COLUMN ) continue;\n      if( pOBExpr->iTable!=iCur ) continue;\n      pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,\n                       ~ready, eqOpMask, 0);\n      if( pTerm==0 ) continue;\n      if( pTerm->eOperator==WO_IN ){\n        /* IN terms are only valid for sorting in the ORDER BY LIMIT \n        ** optimization, and then only if they are actually used\n        ** by the query plan */\n        assert( wctrlFlags & WHERE_ORDERBY_LIMIT );\n        for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}\n        if( j>=pLoop->nLTerm ) continue;\n      }\n      if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){\n        if( sqlite3ExprCollSeqMatch(pWInfo->pParse, \n                  pOrderBy->a[i].pExpr, pTerm->pExpr)==0 ){\n          continue;\n        }\n        testcase( pTerm->pExpr->op==TK_IS );\n      }\n      obSat |= MASKBIT(i);\n    }\n\n    if( (pLoop->wsFlags & WHERE_ONEROW)==0 ){\n      if( pLoop->wsFlags & WHERE_IPK ){\n        pIndex = 0;\n        nKeyCol = 0;\n        nColumn = 1;\n      }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){\n        return 0;\n      }else{\n        nKeyCol = pIndex->nKeyCol;\n        nColumn = pIndex->nColumn;\n        assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );\n        assert( pIndex->aiColumn[nColumn-1]==XN_ROWID\n                          || !HasRowid(pIndex->pTable));\n        isOrderDistinct = IsUniqueIndex(pIndex);\n      }\n\n      /* Loop through all columns of the index and deal with the ones\n      ** that are not constrained by == or IN.\n      */\n      rev = revSet = 0;\n      distinctColumns = 0;\n      for(j=0; j<nColumn; j++){\n        u8 bOnce = 1; /* True to run the ORDER BY search loop */\n\n        assert( j>=pLoop->u.btree.nEq \n            || (pLoop->aLTerm[j]==0)==(j<pLoop->nSkip)\n        );\n        if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){\n          u16 eOp = pLoop->aLTerm[j]->eOperator;\n\n          /* Skip over == and IS and ISNULL terms.  (Also skip IN terms when\n          ** doing WHERE_ORDERBY_LIMIT processing). \n          **\n          ** If the current term is a column of an ((?,?) IN (SELECT...)) \n          ** expression for which the SELECT returns more than one column,\n          ** check that it is the only column used by this loop. Otherwise,\n          ** if it is one of two or more, none of the columns can be\n          ** considered to match an ORDER BY term.  */\n          if( (eOp & eqOpMask)!=0 ){\n            if( eOp & WO_ISNULL ){\n              testcase( isOrderDistinct );\n              isOrderDistinct = 0;\n            }\n            continue;  \n          }else if( ALWAYS(eOp & WO_IN) ){\n            /* ALWAYS() justification: eOp is an equality operator due to the\n            ** j<pLoop->u.btree.nEq constraint above.  Any equality other\n            ** than WO_IN is captured by the previous \"if\".  So this one\n            ** always has to be WO_IN. */\n            Expr *pX = pLoop->aLTerm[j]->pExpr;\n            for(i=j+1; i<pLoop->u.btree.nEq; i++){\n              if( pLoop->aLTerm[i]->pExpr==pX ){\n                assert( (pLoop->aLTerm[i]->eOperator & WO_IN) );\n                bOnce = 0;\n                break;\n              }\n            }\n          }\n        }\n\n        /* Get the column number in the table (iColumn) and sort order\n        ** (revIdx) for the j-th column of the index.\n        */\n        if( pIndex ){\n          iColumn = pIndex->aiColumn[j];\n          revIdx = pIndex->aSortOrder[j];\n          if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;\n        }else{\n          iColumn = XN_ROWID;\n          revIdx = 0;\n        }\n\n        /* An unconstrained column that might be NULL means that this\n        ** WhereLoop is not well-ordered\n        */\n        if( isOrderDistinct\n         && iColumn>=0\n         && j>=pLoop->u.btree.nEq\n         && pIndex->pTable->aCol[iColumn].notNull==0\n        ){\n          isOrderDistinct = 0;\n        }\n\n        /* Find the ORDER BY term that corresponds to the j-th column\n        ** of the index and mark that ORDER BY term off \n        */\n        isMatch = 0;\n        for(i=0; bOnce && i<nOrderBy; i++){\n          if( MASKBIT(i) & obSat ) continue;\n          pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n          testcase( wctrlFlags & WHERE_GROUPBY );\n          testcase( wctrlFlags & WHERE_DISTINCTBY );\n          if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;\n          if( iColumn>=XN_ROWID ){\n            if( pOBExpr->op!=TK_COLUMN ) continue;\n            if( pOBExpr->iTable!=iCur ) continue;\n            if( pOBExpr->iColumn!=iColumn ) continue;\n          }else{\n            Expr *pIdxExpr = pIndex->aColExpr->a[j].pExpr;\n            if( sqlite3ExprCompareSkip(pOBExpr, pIdxExpr, iCur) ){\n              continue;\n            }\n          }\n          if( iColumn!=XN_ROWID ){\n            pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);\n            if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;\n          }\n          pLoop->u.btree.nIdxCol = j+1;\n          isMatch = 1;\n          break;\n        }\n        if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){\n          /* Make sure the sort order is compatible in an ORDER BY clause.\n          ** Sort order is irrelevant for a GROUP BY clause. */\n          if( revSet ){\n            if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;\n          }else{\n            rev = revIdx ^ pOrderBy->a[i].sortOrder;\n            if( rev ) *pRevMask |= MASKBIT(iLoop);\n            revSet = 1;\n          }\n        }\n        if( isMatch ){\n          if( iColumn==XN_ROWID ){\n            testcase( distinctColumns==0 );\n            distinctColumns = 1;\n          }\n          obSat |= MASKBIT(i);\n        }else{\n          /* No match found */\n          if( j==0 || j<nKeyCol ){\n            testcase( isOrderDistinct!=0 );\n            isOrderDistinct = 0;\n          }\n          break;\n        }\n      } /* end Loop over all index columns */\n      if( distinctColumns ){\n        testcase( isOrderDistinct==0 );\n        isOrderDistinct = 1;\n      }\n    } /* end-if not one-row */\n\n    /* Mark off any other ORDER BY terms that reference pLoop */\n    if( isOrderDistinct ){\n      orderDistinctMask |= pLoop->maskSelf;\n      for(i=0; i<nOrderBy; i++){\n        Expr *p;\n        Bitmask mTerm;\n        if( MASKBIT(i) & obSat ) continue;\n        p = pOrderBy->a[i].pExpr;\n        mTerm = sqlite3WhereExprUsage(&pWInfo->sMaskSet,p);\n        if( mTerm==0 && !sqlite3ExprIsConstant(p) ) continue;\n        if( (mTerm&~orderDistinctMask)==0 ){\n          obSat |= MASKBIT(i);\n        }\n      }\n    }\n  } /* End the loop over all WhereLoops from outer-most down to inner-most */\n  if( obSat==obDone ) return (i8)nOrderBy;\n  if( !isOrderDistinct ){\n    for(i=nOrderBy-1; i>0; i--){\n      Bitmask m = MASKBIT(i) - 1;\n      if( (obSat&m)==m ) return i;\n    }\n    return 0;\n  }\n  return -1;\n}\n\n\n/*\n** If the WHERE_GROUPBY flag is set in the mask passed to sqlite3WhereBegin(),\n** the planner assumes that the specified pOrderBy list is actually a GROUP\n** BY clause - and so any order that groups rows as required satisfies the\n** request.\n**\n** Normally, in this case it is not possible for the caller to determine\n** whether or not the rows are really being delivered in sorted order, or\n** just in some other order that provides the required grouping. However,\n** if the WHERE_SORTBYGROUP flag is also passed to sqlite3WhereBegin(), then\n** this function may be called on the returned WhereInfo object. It returns\n** true if the rows really will be sorted in the specified order, or false\n** otherwise.\n**\n** For example, assuming:\n**\n**   CREATE INDEX i1 ON t1(x, Y);\n**\n** then\n**\n**   SELECT * FROM t1 GROUP BY x,y ORDER BY x,y;   -- IsSorted()==1\n**   SELECT * FROM t1 GROUP BY y,x ORDER BY y,x;   -- IsSorted()==0\n*/\nSQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo *pWInfo){\n  assert( pWInfo->wctrlFlags & WHERE_GROUPBY );\n  assert( pWInfo->wctrlFlags & WHERE_SORTBYGROUP );\n  return pWInfo->sorted;\n}\n\n#ifdef WHERETRACE_ENABLED\n/* For debugging use only: */\nstatic const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){\n  static char zName[65];\n  int i;\n  for(i=0; i<nLoop; i++){ zName[i] = pPath->aLoop[i]->cId; }\n  if( pLast ) zName[i++] = pLast->cId;\n  zName[i] = 0;\n  return zName;\n}\n#endif\n\n/*\n** Return the cost of sorting nRow rows, assuming that the keys have \n** nOrderby columns and that the first nSorted columns are already in\n** order.\n*/\nstatic LogEst whereSortingCost(\n  WhereInfo *pWInfo,\n  LogEst nRow,\n  int nOrderBy,\n  int nSorted\n){\n  /* TUNING: Estimated cost of a full external sort, where N is \n  ** the number of rows to sort is:\n  **\n  **   cost = (3.0 * N * log(N)).\n  ** \n  ** Or, if the order-by clause has X terms but only the last Y \n  ** terms are out of order, then block-sorting will reduce the \n  ** sorting cost to:\n  **\n  **   cost = (3.0 * N * log(N)) * (Y/X)\n  **\n  ** The (Y/X) term is implemented using stack variable rScale\n  ** below.  */\n  LogEst rScale, rSortCost;\n  assert( nOrderBy>0 && 66==sqlite3LogEst(100) );\n  rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;\n  rSortCost = nRow + rScale + 16;\n\n  /* Multiple by log(M) where M is the number of output rows.\n  ** Use the LIMIT for M if it is smaller */\n  if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){\n    nRow = pWInfo->iLimit;\n  }\n  rSortCost += estLog(nRow);\n  return rSortCost;\n}\n\n/*\n** Given the list of WhereLoop objects at pWInfo->pLoops, this routine\n** attempts to find the lowest cost path that visits each WhereLoop\n** once.  This path is then loaded into the pWInfo->a[].pWLoop fields.\n**\n** Assume that the total number of output rows that will need to be sorted\n** will be nRowEst (in the 10*log2 representation).  Or, ignore sorting\n** costs if nRowEst==0.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation\n** error occurs.\n*/\nstatic int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){\n  int mxChoice;             /* Maximum number of simultaneous paths tracked */\n  int nLoop;                /* Number of terms in the join */\n  Parse *pParse;            /* Parsing context */\n  sqlite3 *db;              /* The database connection */\n  int iLoop;                /* Loop counter over the terms of the join */\n  int ii, jj;               /* Loop counters */\n  int mxI = 0;              /* Index of next entry to replace */\n  int nOrderBy;             /* Number of ORDER BY clause terms */\n  LogEst mxCost = 0;        /* Maximum cost of a set of paths */\n  LogEst mxUnsorted = 0;    /* Maximum unsorted cost of a set of path */\n  int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */\n  WherePath *aFrom;         /* All nFrom paths at the previous level */\n  WherePath *aTo;           /* The nTo best paths at the current level */\n  WherePath *pFrom;         /* An element of aFrom[] that we are working on */\n  WherePath *pTo;           /* An element of aTo[] that we are working on */\n  WhereLoop *pWLoop;        /* One of the WhereLoop objects */\n  WhereLoop **pX;           /* Used to divy up the pSpace memory */\n  LogEst *aSortCost = 0;    /* Sorting and partial sorting costs */\n  char *pSpace;             /* Temporary memory used by this routine */\n  int nSpace;               /* Bytes of space allocated at pSpace */\n\n  pParse = pWInfo->pParse;\n  db = pParse->db;\n  nLoop = pWInfo->nLevel;\n  /* TUNING: For simple queries, only the best path is tracked.\n  ** For 2-way joins, the 5 best paths are followed.\n  ** For joins of 3 or more tables, track the 10 best paths */\n  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);\n  assert( nLoop<=pWInfo->pTabList->nSrc );\n  WHERETRACE(0x002, (\"---- begin solver.  (nRowEst=%d)\\n\", nRowEst));\n\n  /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this\n  ** case the purpose of this call is to estimate the number of rows returned\n  ** by the overall query. Once this estimate has been obtained, the caller\n  ** will invoke this function a second time, passing the estimate as the\n  ** nRowEst parameter.  */\n  if( pWInfo->pOrderBy==0 || nRowEst==0 ){\n    nOrderBy = 0;\n  }else{\n    nOrderBy = pWInfo->pOrderBy->nExpr;\n  }\n\n  /* Allocate and initialize space for aTo, aFrom and aSortCost[] */\n  nSpace = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;\n  nSpace += sizeof(LogEst) * nOrderBy;\n  pSpace = sqlite3DbMallocRawNN(db, nSpace);\n  if( pSpace==0 ) return SQLITE_NOMEM_BKPT;\n  aTo = (WherePath*)pSpace;\n  aFrom = aTo+mxChoice;\n  memset(aFrom, 0, sizeof(aFrom[0]));\n  pX = (WhereLoop**)(aFrom+mxChoice);\n  for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){\n    pFrom->aLoop = pX;\n  }\n  if( nOrderBy ){\n    /* If there is an ORDER BY clause and it is not being ignored, set up\n    ** space for the aSortCost[] array. Each element of the aSortCost array\n    ** is either zero - meaning it has not yet been initialized - or the\n    ** cost of sorting nRowEst rows of data where the first X terms of\n    ** the ORDER BY clause are already in order, where X is the array \n    ** index.  */\n    aSortCost = (LogEst*)pX;\n    memset(aSortCost, 0, sizeof(LogEst) * nOrderBy);\n  }\n  assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );\n  assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );\n\n  /* Seed the search with a single WherePath containing zero WhereLoops.\n  **\n  ** TUNING: Do not let the number of iterations go above 28.  If the cost\n  ** of computing an automatic index is not paid back within the first 28\n  ** rows, then do not use the automatic index. */\n  aFrom[0].nRow = MIN(pParse->nQueryLoop, 48);  assert( 48==sqlite3LogEst(28) );\n  nFrom = 1;\n  assert( aFrom[0].isOrdered==0 );\n  if( nOrderBy ){\n    /* If nLoop is zero, then there are no FROM terms in the query. Since\n    ** in this case the query may return a maximum of one row, the results\n    ** are already in the requested order. Set isOrdered to nOrderBy to\n    ** indicate this. Or, if nLoop is greater than zero, set isOrdered to\n    ** -1, indicating that the result set may or may not be ordered, \n    ** depending on the loops added to the current plan.  */\n    aFrom[0].isOrdered = nLoop>0 ? -1 : nOrderBy;\n  }\n\n  /* Compute successively longer WherePaths using the previous generation\n  ** of WherePaths as the basis for the next.  Keep track of the mxChoice\n  ** best paths at each generation */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    nTo = 0;\n    for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){\n      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){\n        LogEst nOut;                      /* Rows visited by (pFrom+pWLoop) */\n        LogEst rCost;                     /* Cost of path (pFrom+pWLoop) */\n        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */\n        i8 isOrdered = pFrom->isOrdered;  /* isOrdered for (pFrom+pWLoop) */\n        Bitmask maskNew;                  /* Mask of src visited by (..) */\n        Bitmask revMask = 0;              /* Mask of rev-order loops for (..) */\n\n        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<10 ){\n          /* Do not use an automatic index if the this loop is expected\n          ** to run less than 2 times. */\n          assert( 10==sqlite3LogEst(2) );\n          continue;\n        }\n        /* At this point, pWLoop is a candidate to be the next loop. \n        ** Compute its cost */\n        rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);\n        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);\n        nOut = pFrom->nRow + pWLoop->nOut;\n        maskNew = pFrom->maskLoop | pWLoop->maskSelf;\n        if( isOrdered<0 ){\n          isOrdered = wherePathSatisfiesOrderBy(pWInfo,\n                       pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,\n                       iLoop, pWLoop, &revMask);\n        }else{\n          revMask = pFrom->revLoop;\n        }\n        if( isOrdered>=0 && isOrdered<nOrderBy ){\n          if( aSortCost[isOrdered]==0 ){\n            aSortCost[isOrdered] = whereSortingCost(\n                pWInfo, nRowEst, nOrderBy, isOrdered\n            );\n          }\n          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);\n\n          WHERETRACE(0x002,\n              (\"---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\\n\",\n               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, \n               rUnsorted, rCost));\n        }else{\n          rCost = rUnsorted;\n          rUnsorted -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */\n        }\n\n        /* Check to see if pWLoop should be added to the set of\n        ** mxChoice best-so-far paths.\n        **\n        ** First look for an existing path among best-so-far paths\n        ** that covers the same set of loops and has the same isOrdered\n        ** setting as the current path candidate.\n        **\n        ** The term \"((pTo->isOrdered^isOrdered)&0x80)==0\" is equivalent\n        ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))\" for the range\n        ** of legal values for isOrdered, -1..64.\n        */\n        for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){\n          if( pTo->maskLoop==maskNew\n           && ((pTo->isOrdered^isOrdered)&0x80)==0\n          ){\n            testcase( jj==nTo-1 );\n            break;\n          }\n        }\n        if( jj>=nTo ){\n          /* None of the existing best-so-far paths match the candidate. */\n          if( nTo>=mxChoice\n           && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))\n          ){\n            /* The current candidate is no better than any of the mxChoice\n            ** paths currently in the best-so-far buffer.  So discard\n            ** this candidate as not viable. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\"Skip   %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n            }\n#endif\n            continue;\n          }\n          /* If we reach this points it means that the new candidate path\n          ** needs to be added to the set of best-so-far paths. */\n          if( nTo<mxChoice ){\n            /* Increase the size of the aTo set by one */\n            jj = nTo++;\n          }else{\n            /* New path replaces the prior worst to keep count below mxChoice */\n            jj = mxI;\n          }\n          pTo = &aTo[jj];\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\"New    %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n          }\n#endif\n        }else{\n          /* Control reaches here if best-so-far path pTo=aTo[jj] covers the\n          ** same set of loops and has the same isOrdered setting as the\n          ** candidate path.  Check to see if the candidate should replace\n          ** pTo or if the candidate should be skipped.\n          ** \n          ** The conditional is an expanded vector comparison equivalent to:\n          **   (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)\n          */\n          if( pTo->rCost<rCost \n           || (pTo->rCost==rCost\n               && (pTo->nRow<nOut\n                   || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)\n                  )\n              )\n          ){\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\n                  \"Skip   %s cost=%-3d,%3d,%3d order=%c\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n              sqlite3DebugPrintf(\"   vs %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                  pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n            }\n#endif\n            /* Discard the candidate path from further consideration */\n            testcase( pTo->rCost==rCost );\n            continue;\n          }\n          testcase( pTo->rCost==rCost+1 );\n          /* Control reaches here if the candidate path is better than the\n          ** pTo path.  Replace pTo with the candidate. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\n                \"Update %s cost=%-3d,%3d,%3d order=%c\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n            sqlite3DebugPrintf(\"  was %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n          }\n#endif\n        }\n        /* pWLoop is a winner.  Add it to the set of best so far */\n        pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;\n        pTo->revLoop = revMask;\n        pTo->nRow = nOut;\n        pTo->rCost = rCost;\n        pTo->rUnsorted = rUnsorted;\n        pTo->isOrdered = isOrdered;\n        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);\n        pTo->aLoop[iLoop] = pWLoop;\n        if( nTo>=mxChoice ){\n          mxI = 0;\n          mxCost = aTo[0].rCost;\n          mxUnsorted = aTo[0].nRow;\n          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){\n            if( pTo->rCost>mxCost \n             || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) \n            ){\n              mxCost = pTo->rCost;\n              mxUnsorted = pTo->rUnsorted;\n              mxI = jj;\n            }\n          }\n        }\n      }\n    }\n\n#ifdef WHERETRACE_ENABLED  /* >=2 */\n    if( sqlite3WhereTrace & 0x02 ){\n      sqlite3DebugPrintf(\"---- after round %d ----\\n\", iLoop);\n      for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){\n        sqlite3DebugPrintf(\" %s cost=%-3d nrow=%-3d order=%c\",\n           wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n           pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');\n        if( pTo->isOrdered>0 ){\n          sqlite3DebugPrintf(\" rev=0x%llx\\n\", pTo->revLoop);\n        }else{\n          sqlite3DebugPrintf(\"\\n\");\n        }\n      }\n    }\n#endif\n\n    /* Swap the roles of aFrom and aTo for the next generation */\n    pFrom = aTo;\n    aTo = aFrom;\n    aFrom = pFrom;\n    nFrom = nTo;\n  }\n\n  if( nFrom==0 ){\n    sqlite3ErrorMsg(pParse, \"no query solution\");\n    sqlite3DbFreeNN(db, pSpace);\n    return SQLITE_ERROR;\n  }\n  \n  /* Find the lowest cost path.  pFrom will be left pointing to that path */\n  pFrom = aFrom;\n  for(ii=1; ii<nFrom; ii++){\n    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];\n  }\n  assert( pWInfo->nLevel==nLoop );\n  /* Load the lowest cost path into pWInfo */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    WhereLevel *pLevel = pWInfo->a + iLoop;\n    pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];\n    pLevel->iFrom = pWLoop->iTab;\n    pLevel->iTabCur = pWInfo->pTabList->a[pLevel->iFrom].iCursor;\n  }\n  if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0\n   && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0\n   && pWInfo->eDistinct==WHERE_DISTINCT_NOOP\n   && nRowEst\n  ){\n    Bitmask notUsed;\n    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,\n                 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);\n    if( rc==pWInfo->pResultSet->nExpr ){\n      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n    }\n  }\n  if( pWInfo->pOrderBy ){\n    if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){\n      if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){\n        pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n      }\n    }else{\n      pWInfo->nOBSat = pFrom->isOrdered;\n      pWInfo->revMask = pFrom->revLoop;\n      if( pWInfo->nOBSat<=0 ){\n        pWInfo->nOBSat = 0;\n        if( nLoop>0 ){\n          u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags;\n          if( (wsFlags & WHERE_ONEROW)==0 \n           && (wsFlags&(WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN)\n          ){\n            Bitmask m = 0;\n            int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,\n                      WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);\n            testcase( wsFlags & WHERE_IPK );\n            testcase( wsFlags & WHERE_COLUMN_IN );\n            if( rc==pWInfo->pOrderBy->nExpr ){\n              pWInfo->bOrderedInnerLoop = 1;\n              pWInfo->revMask = m;\n            }\n          }\n        }\n      }\n    }\n    if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)\n        && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0\n    ){\n      Bitmask revMask = 0;\n      int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, \n          pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask\n      );\n      assert( pWInfo->sorted==0 );\n      if( nOrder==pWInfo->pOrderBy->nExpr ){\n        pWInfo->sorted = 1;\n        pWInfo->revMask = revMask;\n      }\n    }\n  }\n\n\n  pWInfo->nRowOut = pFrom->nRow;\n\n  /* Free temporary memory and return success */\n  sqlite3DbFreeNN(db, pSpace);\n  return SQLITE_OK;\n}\n\n/*\n** Most queries use only a single table (they are not joins) and have\n** simple == constraints against indexed fields.  This routine attempts\n** to plan those simple cases using much less ceremony than the\n** general-purpose query planner, and thereby yield faster sqlite3_prepare()\n** times for the common case.\n**\n** Return non-zero on success, if this query can be handled by this\n** no-frills query planner.  Return zero if this query needs the \n** general-purpose query planner.\n*/\nstatic int whereShortCut(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo;\n  struct SrcList_item *pItem;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  WhereLoop *pLoop;\n  int iCur;\n  int j;\n  Table *pTab;\n  Index *pIdx;\n\n  pWInfo = pBuilder->pWInfo;\n  if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;\n  assert( pWInfo->pTabList->nSrc>=1 );\n  pItem = pWInfo->pTabList->a;\n  pTab = pItem->pTab;\n  if( IsVirtual(pTab) ) return 0;\n  if( pItem->fg.isIndexedBy ) return 0;\n  iCur = pItem->iCursor;\n  pWC = &pWInfo->sWC;\n  pLoop = pBuilder->pNew;\n  pLoop->wsFlags = 0;\n  pLoop->nSkip = 0;\n  pTerm = sqlite3WhereFindTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0);\n  if( pTerm ){\n    testcase( pTerm->eOperator & WO_IS );\n    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;\n    pLoop->aLTerm[0] = pTerm;\n    pLoop->nLTerm = 1;\n    pLoop->u.btree.nEq = 1;\n    /* TUNING: Cost of a rowid lookup is 10 */\n    pLoop->rRun = 33;  /* 33==sqlite3LogEst(10) */\n  }else{\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int opMask;\n      assert( pLoop->aLTermSpace==pLoop->aLTerm );\n      if( !IsUniqueIndex(pIdx)\n       || pIdx->pPartIdxWhere!=0 \n       || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) \n      ) continue;\n      opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;\n      for(j=0; j<pIdx->nKeyCol; j++){\n        pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);\n        if( pTerm==0 ) break;\n        testcase( pTerm->eOperator & WO_IS );\n        pLoop->aLTerm[j] = pTerm;\n      }\n      if( j!=pIdx->nKeyCol ) continue;\n      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;\n      if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){\n        pLoop->wsFlags |= WHERE_IDX_ONLY;\n      }\n      pLoop->nLTerm = j;\n      pLoop->u.btree.nEq = j;\n      pLoop->u.btree.pIndex = pIdx;\n      /* TUNING: Cost of a unique index lookup is 15 */\n      pLoop->rRun = 39;  /* 39==sqlite3LogEst(15) */\n      break;\n    }\n  }\n  if( pLoop->wsFlags ){\n    pLoop->nOut = (LogEst)1;\n    pWInfo->a[0].pWLoop = pLoop;\n    assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] );\n    pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */\n    pWInfo->a[0].iTabCur = iCur;\n    pWInfo->nRowOut = 1;\n    if( pWInfo->pOrderBy ) pWInfo->nOBSat =  pWInfo->pOrderBy->nExpr;\n    if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n#ifdef SQLITE_DEBUG\n    pLoop->cId = '0';\n#endif\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Helper function for exprIsDeterministic().\n*/\nstatic int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Return true if the expression contains no non-deterministic SQL \n** functions. Do not consider non-deterministic SQL functions that are \n** part of sub-select statements.\n*/\nstatic int exprIsDeterministic(Expr *p){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsDeterministic;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Generate the beginning of the loop used for WHERE clause processing.\n** The return value is a pointer to an opaque structure that contains\n** information needed to terminate the loop.  Later, the calling routine\n** should invoke sqlite3WhereEnd() with the return value of this function\n** in order to complete the WHERE clause processing.\n**\n** If an error occurs, this routine returns NULL.\n**\n** The basic idea is to do a nested loop, one loop for each table in\n** the FROM clause of a select.  (INSERT and UPDATE statements are the\n** same as a SELECT with only a single table in the FROM clause.)  For\n** example, if the SQL is this:\n**\n**       SELECT * FROM t1, t2, t3 WHERE ...;\n**\n** Then the code generated is conceptually like the following:\n**\n**      foreach row1 in t1 do       \\    Code generated\n**        foreach row2 in t2 do      |-- by sqlite3WhereBegin()\n**          foreach row3 in t3 do   /\n**            ...\n**          end                     \\    Code generated\n**        end                        |-- by sqlite3WhereEnd()\n**      end                         /\n**\n** Note that the loops might not be nested in the order in which they\n** appear in the FROM clause if a different order is better able to make\n** use of indices.  Note also that when the IN operator appears in\n** the WHERE clause, it might result in additional nested loops for\n** scanning through all values on the right-hand side of the IN.\n**\n** There are Btree cursors associated with each table.  t1 uses cursor\n** number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor.\n** And so forth.  This routine generates code to open those VDBE cursors\n** and sqlite3WhereEnd() generates the code to close them.\n**\n** The code that sqlite3WhereBegin() generates leaves the cursors named\n** in pTabList pointing at their appropriate entries.  The [...] code\n** can use OP_Column and OP_Rowid opcodes on these cursors to extract\n** data from the various tables of the loop.\n**\n** If the WHERE clause is empty, the foreach loops must each scan their\n** entire tables.  Thus a three-way join is an O(N^3) operation.  But if\n** the tables have indices and there are terms in the WHERE clause that\n** refer to those indices, a complete table scan can be avoided and the\n** code will run much faster.  Most of the work of this routine is checking\n** to see if there are indices that can be used to speed up the loop.\n**\n** Terms of the WHERE clause are also used to limit which rows actually\n** make it to the \"...\" in the middle of the loop.  After each \"foreach\",\n** terms of the WHERE clause that use only terms in that loop and outer\n** loops are evaluated and if false a jump is made around all subsequent\n** inner loops (or around the \"...\" if the test occurs within the inner-\n** most loop)\n**\n** OUTER JOINS\n**\n** An outer join of tables t1 and t2 is conceptally coded as follows:\n**\n**    foreach row1 in t1 do\n**      flag = 0\n**      foreach row2 in t2 do\n**        start:\n**          ...\n**          flag = 1\n**      end\n**      if flag==0 then\n**        move the row2 cursor to a null row\n**        goto start\n**      fi\n**    end\n**\n** ORDER BY CLAUSE PROCESSING\n**\n** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause\n** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement\n** if there is one.  If there is no ORDER BY clause or if this routine\n** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.\n**\n** The iIdxCur parameter is the cursor number of an index.  If \n** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index\n** to use for OR clause processing.  The WHERE clause should use this\n** specific cursor.  If WHERE_ONEPASS_DESIRED is set, then iIdxCur is\n** the first cursor in an array of cursors for all indices.  iIdxCur should\n** be used to compute the appropriate cursor depending on which index is\n** used.\n*/\nSQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(\n  Parse *pParse,          /* The parser context */\n  SrcList *pTabList,      /* FROM clause: A list of all tables to be scanned */\n  Expr *pWhere,           /* The WHERE clause */\n  ExprList *pOrderBy,     /* An ORDER BY (or GROUP BY) clause, or NULL */\n  ExprList *pResultSet,   /* Query result set.  Req'd for DISTINCT */\n  u16 wctrlFlags,         /* The WHERE_* flags defined in sqliteInt.h */\n  int iAuxArg             /* If WHERE_OR_SUBCLAUSE is set, index cursor number\n                          ** If WHERE_USE_LIMIT, then the limit amount */\n){\n  int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */\n  int nTabList;              /* Number of elements in pTabList */\n  WhereInfo *pWInfo;         /* Will become the return value of this function */\n  Vdbe *v = pParse->pVdbe;   /* The virtual database engine */\n  Bitmask notReady;          /* Cursors that are not yet positioned */\n  WhereLoopBuilder sWLB;     /* The WhereLoop builder */\n  WhereMaskSet *pMaskSet;    /* The expression mask set */\n  WhereLevel *pLevel;        /* A single level in pWInfo->a[] */\n  WhereLoop *pLoop;          /* Pointer to a single WhereLoop object */\n  int ii;                    /* Loop counter */\n  sqlite3 *db;               /* Database connection */\n  int rc;                    /* Return code */\n  u8 bFordelete = 0;         /* OPFLAG_FORDELETE or zero, as appropriate */\n\n  assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (\n        (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 \n     && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 \n  ));\n\n  /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */\n  assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n            || (wctrlFlags & WHERE_USE_LIMIT)==0 );\n\n  /* Variable initialization */\n  db = pParse->db;\n  memset(&sWLB, 0, sizeof(sWLB));\n\n  /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */\n  testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );\n  if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;\n  sWLB.pOrderBy = pOrderBy;\n\n  /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via\n  ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */\n  if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){\n    wctrlFlags &= ~WHERE_WANT_DISTINCT;\n  }\n\n  /* The number of tables in the FROM clause is limited by the number of\n  ** bits in a Bitmask \n  */\n  testcase( pTabList->nSrc==BMS );\n  if( pTabList->nSrc>BMS ){\n    sqlite3ErrorMsg(pParse, \"at most %d tables in a join\", BMS);\n    return 0;\n  }\n\n  /* This function normally generates a nested loop for all tables in \n  ** pTabList.  But if the WHERE_OR_SUBCLAUSE flag is set, then we should\n  ** only generate code for the first table in pTabList and assume that\n  ** any cursors associated with subsequent tables are uninitialized.\n  */\n  nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;\n\n  /* Allocate and initialize the WhereInfo structure that will become the\n  ** return value. A single allocation is used to store the WhereInfo\n  ** struct, the contents of WhereInfo.a[], the WhereClause structure\n  ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte\n  ** field (type Bitmask) it must be aligned on an 8-byte boundary on\n  ** some architectures. Hence the ROUND8() below.\n  */\n  nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));\n  pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop));\n  if( db->mallocFailed ){\n    sqlite3DbFree(db, pWInfo);\n    pWInfo = 0;\n    goto whereBeginError;\n  }\n  pWInfo->pParse = pParse;\n  pWInfo->pTabList = pTabList;\n  pWInfo->pOrderBy = pOrderBy;\n  pWInfo->pWhere = pWhere;\n  pWInfo->pResultSet = pResultSet;\n  pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;\n  pWInfo->nLevel = nTabList;\n  pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);\n  pWInfo->wctrlFlags = wctrlFlags;\n  pWInfo->iLimit = iAuxArg;\n  pWInfo->savedNQueryLoop = pParse->nQueryLoop;\n  memset(&pWInfo->nOBSat, 0, \n         offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));\n  memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));\n  assert( pWInfo->eOnePass==ONEPASS_OFF );  /* ONEPASS defaults to OFF */\n  pMaskSet = &pWInfo->sMaskSet;\n  sWLB.pWInfo = pWInfo;\n  sWLB.pWC = &pWInfo->sWC;\n  sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);\n  assert( EIGHT_BYTE_ALIGNMENT(sWLB.pNew) );\n  whereLoopInit(sWLB.pNew);\n#ifdef SQLITE_DEBUG\n  sWLB.pNew->cId = '*';\n#endif\n\n  /* Split the WHERE clause into separate subexpressions where each\n  ** subexpression is separated by an AND operator.\n  */\n  initMaskSet(pMaskSet);\n  sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);\n  sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);\n    \n  /* Special case: No FROM clause\n  */\n  if( nTabList==0 ){\n    if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;\n    if( wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n  }else{\n    /* Assign a bit from the bitmask to every term in the FROM clause.\n    **\n    ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.\n    **\n    ** The rule of the previous sentence ensures thta if X is the bitmask for\n    ** a table T, then X-1 is the bitmask for all other tables to the left of T.\n    ** Knowing the bitmask for all tables to the left of a left join is\n    ** important.  Ticket #3015.\n    **\n    ** Note that bitmasks are created for all pTabList->nSrc tables in\n    ** pTabList, not just the first nTabList tables.  nTabList is normally\n    ** equal to pTabList->nSrc but might be shortened to 1 if the\n    ** WHERE_OR_SUBCLAUSE flag is set.\n    */\n    ii = 0;\n    do{\n      createMask(pMaskSet, pTabList->a[ii].iCursor);\n      sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);\n    }while( (++ii)<pTabList->nSrc );\n  #ifdef SQLITE_DEBUG\n    {\n      Bitmask mx = 0;\n      for(ii=0; ii<pTabList->nSrc; ii++){\n        Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);\n        assert( m>=mx );\n        mx = m;\n      }\n    }\n  #endif\n  }\n  \n  /* Analyze all of the subexpressions. */\n  sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Special case: WHERE terms that do not refer to any tables in the join\n  ** (constant expressions). Evaluate each such term, and jump over all the\n  ** generated code if the result is not true.  \n  **\n  ** Do not do this if the expression contains non-deterministic functions\n  ** that are not within a sub-select. This is not strictly required, but\n  ** preserves SQLite's legacy behaviour in the following two cases:\n  **\n  **   FROM ... WHERE random()>0;           -- eval random() once per row\n  **   FROM ... WHERE (SELECT random())>0;  -- eval random() once overall\n  */\n  for(ii=0; ii<sWLB.pWC->nTerm; ii++){\n    WhereTerm *pT = &sWLB.pWC->a[ii];\n    if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){\n      sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);\n      pT->wtFlags |= TERM_CODED;\n    }\n  }\n\n  if( wctrlFlags & WHERE_WANT_DISTINCT ){\n    if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){\n      /* The DISTINCT marking is pointless.  Ignore it. */\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }else if( pOrderBy==0 ){\n      /* Try to ORDER BY the result set to make distinct processing easier */\n      pWInfo->wctrlFlags |= WHERE_DISTINCTBY;\n      pWInfo->pOrderBy = pResultSet;\n    }\n  }\n\n  /* Construct the WhereLoop objects */\n#if defined(WHERETRACE_ENABLED)\n  if( sqlite3WhereTrace & 0xffff ){\n    sqlite3DebugPrintf(\"*** Optimizer Start *** (wctrlFlags: 0x%x\",wctrlFlags);\n    if( wctrlFlags & WHERE_USE_LIMIT ){\n      sqlite3DebugPrintf(\", limit: %d\", iAuxArg);\n    }\n    sqlite3DebugPrintf(\")\\n\");\n  }\n  if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */\n    sqlite3WhereClausePrint(sWLB.pWC);\n  }\n#endif\n\n  if( nTabList!=1 || whereShortCut(&sWLB)==0 ){\n    rc = whereLoopAddAll(&sWLB);\n    if( rc ) goto whereBeginError;\n  \n#ifdef WHERETRACE_ENABLED\n    if( sqlite3WhereTrace ){    /* Display all of the WhereLoop objects */\n      WhereLoop *p;\n      int i;\n      static const char zLabel[] = \"0123456789abcdefghijklmnopqrstuvwyxz\"\n                                             \"ABCDEFGHIJKLMNOPQRSTUVWYXZ\";\n      for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){\n        p->cId = zLabel[i%(sizeof(zLabel)-1)];\n        whereLoopPrint(p, sWLB.pWC);\n      }\n    }\n#endif\n  \n    wherePathSolver(pWInfo, 0);\n    if( db->mallocFailed ) goto whereBeginError;\n    if( pWInfo->pOrderBy ){\n       wherePathSolver(pWInfo, pWInfo->nRowOut+1);\n       if( db->mallocFailed ) goto whereBeginError;\n    }\n  }\n  if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){\n     pWInfo->revMask = ALLBITS;\n  }\n  if( pParse->nErr || NEVER(db->mallocFailed) ){\n    goto whereBeginError;\n  }\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace ){\n    sqlite3DebugPrintf(\"---- Solution nRow=%d\", pWInfo->nRowOut);\n    if( pWInfo->nOBSat>0 ){\n      sqlite3DebugPrintf(\" ORDERBY=%d,0x%llx\", pWInfo->nOBSat, pWInfo->revMask);\n    }\n    switch( pWInfo->eDistinct ){\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3DebugPrintf(\"  DISTINCT=unique\");\n        break;\n      }\n      case WHERE_DISTINCT_ORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=ordered\");\n        break;\n      }\n      case WHERE_DISTINCT_UNORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=unordered\");\n        break;\n      }\n    }\n    sqlite3DebugPrintf(\"\\n\");\n    for(ii=0; ii<pWInfo->nLevel; ii++){\n      whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);\n    }\n  }\n#endif\n  /* Attempt to omit tables from the join that do not effect the result */\n  if( pWInfo->nLevel>=2\n   && pResultSet!=0\n   && OptimizationEnabled(db, SQLITE_OmitNoopJoin)\n  ){\n    Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);\n    if( sWLB.pOrderBy ){\n      tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);\n    }\n    while( pWInfo->nLevel>=2 ){\n      WhereTerm *pTerm, *pEnd;\n      pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;\n      if( (pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 ) break;\n      if( (wctrlFlags & WHERE_WANT_DISTINCT)==0\n       && (pLoop->wsFlags & WHERE_ONEROW)==0\n      ){\n        break;\n      }\n      if( (tabUsed & pLoop->maskSelf)!=0 ) break;\n      pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;\n      for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){\n        if( (pTerm->prereqAll & pLoop->maskSelf)!=0\n         && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n        ){\n          break;\n        }\n      }\n      if( pTerm<pEnd ) break;\n      WHERETRACE(0xffff, (\"-> drop loop %c not used\\n\", pLoop->cId));\n      pWInfo->nLevel--;\n      nTabList--;\n    }\n  }\n  WHERETRACE(0xffff,(\"*** Optimizer Finished ***\\n\"));\n  pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;\n\n  /* If the caller is an UPDATE or DELETE statement that is requesting\n  ** to use a one-pass algorithm, determine if this is appropriate.\n  */\n  assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 );\n  if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){\n    int wsFlags = pWInfo->a[0].pWLoop->wsFlags;\n    int bOnerow = (wsFlags & WHERE_ONEROW)!=0;\n    if( bOnerow\n     || ((wctrlFlags & WHERE_ONEPASS_MULTIROW)!=0\n           && 0==(wsFlags & WHERE_VIRTUALTABLE))\n    ){\n      pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;\n      if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){\n        if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){\n          bFordelete = OPFLAG_FORDELETE;\n        }\n        pWInfo->a[0].pWLoop->wsFlags = (wsFlags & ~WHERE_IDX_ONLY);\n      }\n    }\n  }\n\n  /* Open all tables in the pTabList and any indices selected for\n  ** searching those tables.\n  */\n  for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){\n    Table *pTab;     /* Table to open */\n    int iDb;         /* Index of database containing table/index */\n    struct SrcList_item *pTabItem;\n\n    pTabItem = &pTabList->a[pLevel->iFrom];\n    pTab = pTabItem->pTab;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    pLoop = pLevel->pWLoop;\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){\n      /* Do nothing */\n    }else\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      int iCur = pTabItem->iCursor;\n      sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);\n    }else if( IsVirtual(pTab) ){\n      /* noop */\n    }else\n#endif\n    if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0\n         && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){\n      int op = OP_OpenRead;\n      if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[0] = pTabItem->iCursor;\n      };\n      sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);\n      assert( pTabItem->iCursor==pLevel->iTabCur );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );\n      if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol<BMS && HasRowid(pTab) ){\n        Bitmask b = pTabItem->colUsed;\n        int n = 0;\n        for(; b; b=b>>1, n++){}\n        sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);\n        assert( n<=pTab->nCol );\n      }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n      if( pLoop->u.btree.pIndex!=0 ){\n        sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ|bFordelete);\n      }else\n#endif\n      {\n        sqlite3VdbeChangeP5(v, bFordelete);\n      }\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n      sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,\n                            (const u8*)&pTabItem->colUsed, P4_INT64);\n#endif\n    }else{\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n    }\n    if( pLoop->wsFlags & WHERE_INDEXED ){\n      Index *pIx = pLoop->u.btree.pIndex;\n      int iIndexCur;\n      int op = OP_OpenRead;\n      /* iAuxArg is always set to a positive value if ONEPASS is possible */\n      assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );\n      if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)\n       && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0\n      ){\n        /* This is one term of an OR-optimization using the PRIMARY KEY of a\n        ** WITHOUT ROWID table.  No need for a separate index */\n        iIndexCur = pLevel->iTabCur;\n        op = 0;\n      }else if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        Index *pJ = pTabItem->pTab->pIndex;\n        iIndexCur = iAuxArg;\n        assert( wctrlFlags & WHERE_ONEPASS_DESIRED );\n        while( ALWAYS(pJ) && pJ!=pIx ){\n          iIndexCur++;\n          pJ = pJ->pNext;\n        }\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[1] = iIndexCur;\n      }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){\n        iIndexCur = iAuxArg;\n        op = OP_ReopenIdx;\n      }else{\n        iIndexCur = pParse->nTab++;\n      }\n      pLevel->iIdxCur = iIndexCur;\n      assert( pIx->pSchema==pTab->pSchema );\n      assert( iIndexCur>=0 );\n      if( op ){\n        sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);\n        sqlite3VdbeSetP4KeyInfo(pParse, pIx);\n        if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0\n         && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0\n         && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0\n         && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED\n        ){\n          sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */\n        }\n        VdbeComment((v, \"%s\", pIx->zName));\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n        {\n          u64 colUsed = 0;\n          int ii, jj;\n          for(ii=0; ii<pIx->nColumn; ii++){\n            jj = pIx->aiColumn[ii];\n            if( jj<0 ) continue;\n            if( jj>63 ) jj = 63;\n            if( (pTabItem->colUsed & MASKBIT(jj))==0 ) continue;\n            colUsed |= ((u64)1)<<(ii<63 ? ii : 63);\n          }\n          sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, iIndexCur, 0, 0,\n                                (u8*)&colUsed, P4_INT64);\n        }\n#endif /* SQLITE_ENABLE_COLUMN_USED_MASK */\n      }\n    }\n    if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);\n  }\n  pWInfo->iTop = sqlite3VdbeCurrentAddr(v);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Generate the code to do the search.  Each iteration of the for\n  ** loop below generates code for a single nested loop of the VM\n  ** program.\n  */\n  notReady = ~(Bitmask)0;\n  for(ii=0; ii<nTabList; ii++){\n    int addrExplain;\n    int wsFlags;\n    pLevel = &pWInfo->a[ii];\n    wsFlags = pLevel->pWLoop->wsFlags;\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n    if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n      constructAutomaticIndex(pParse, &pWInfo->sWC,\n                &pTabList->a[pLevel->iFrom], notReady, pLevel);\n      if( db->mallocFailed ) goto whereBeginError;\n    }\n#endif\n    addrExplain = sqlite3WhereExplainOneScan(\n        pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags\n    );\n    pLevel->addrBody = sqlite3VdbeCurrentAddr(v);\n    notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);\n    pWInfo->iContinue = pLevel->addrCont;\n    if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){\n      sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);\n    }\n  }\n\n  /* Done. */\n  VdbeModuleComment((v, \"Begin WHERE-core\"));\n  return pWInfo;\n\n  /* Jump here if malloc fails */\nwhereBeginError:\n  if( pWInfo ){\n    pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n    whereInfoFree(db, pWInfo);\n  }\n  return 0;\n}\n\n/*\n** Generate the end of the WHERE loop.  See comments on \n** sqlite3WhereBegin() for additional information.\n*/\nSQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){\n  Parse *pParse = pWInfo->pParse;\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  WhereLevel *pLevel;\n  WhereLoop *pLoop;\n  SrcList *pTabList = pWInfo->pTabList;\n  sqlite3 *db = pParse->db;\n\n  /* Generate loop termination code.\n  */\n  VdbeModuleComment((v, \"End WHERE-core\"));\n  sqlite3ExprCacheClear(pParse);\n  for(i=pWInfo->nLevel-1; i>=0; i--){\n    int addr;\n    pLevel = &pWInfo->a[i];\n    pLoop = pLevel->pWLoop;\n    if( pLevel->op!=OP_Noop ){\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      int addrSeek = 0;\n      Index *pIdx;\n      int n;\n      if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED\n       && (pLoop->wsFlags & WHERE_INDEXED)!=0\n       && (pIdx = pLoop->u.btree.pIndex)->hasStat1\n       && (n = pLoop->u.btree.nIdxCol)>0\n       && pIdx->aiRowLogEst[n]>=36\n      ){\n        int r1 = pParse->nMem+1;\n        int j, op;\n        for(j=0; j<n; j++){\n          sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);\n        }\n        pParse->nMem += n+1;\n        op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;\n        addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);\n        VdbeCoverageIf(v, op==OP_SeekLT);\n        VdbeCoverageIf(v, op==OP_SeekGT);\n        sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);\n      }\n#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */\n      /* The common case: Advance to the next row */\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n      sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);\n      sqlite3VdbeChangeP5(v, pLevel->p5);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, pLevel->op==OP_Next);\n      VdbeCoverageIf(v, pLevel->op==OP_Prev);\n      VdbeCoverageIf(v, pLevel->op==OP_VNext);\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);\n#endif\n    }else{\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n    }\n    if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){\n      struct InLoop *pIn;\n      int j;\n      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);\n      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){\n        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);\n        if( pIn->eEndLoopOp!=OP_Noop ){\n          sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);\n          VdbeCoverage(v);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);\n        }\n        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);\n      }\n    }\n    sqlite3VdbeResolveLabel(v, pLevel->addrBrk);\n    if( pLevel->addrSkip ){\n      sqlite3VdbeGoto(v, pLevel->addrSkip);\n      VdbeComment((v, \"next skip-scan on %s\", pLoop->u.btree.pIndex->zName));\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip);\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);\n    }\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n    if( pLevel->addrLikeRep ){\n      sqlite3VdbeAddOp2(v, OP_DecrJumpZero, (int)(pLevel->iLikeRepCntr>>1),\n                        pLevel->addrLikeRep);\n      VdbeCoverage(v);\n    }\n#endif\n    if( pLevel->iLeftJoin ){\n      int ws = pLoop->wsFlags;\n      addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);\n      assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );\n      if( (ws & WHERE_IDX_ONLY)==0 ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);\n      }\n      if( (ws & WHERE_INDEXED) \n       || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx) \n      ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);\n      }\n      if( pLevel->op==OP_Return ){\n        sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);\n      }else{\n        sqlite3VdbeGoto(v, pLevel->addrFirst);\n      }\n      sqlite3VdbeJumpHere(v, addr);\n    }\n    VdbeModuleComment((v, \"End WHERE-loop%d: %s\", i,\n                     pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));\n  }\n\n  /* The \"break\" point is here, just past the end of the outer loop.\n  ** Set it.\n  */\n  sqlite3VdbeResolveLabel(v, pWInfo->iBreak);\n\n  assert( pWInfo->nLevel<=pTabList->nSrc );\n  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){\n    int k, last;\n    VdbeOp *pOp;\n    Index *pIdx = 0;\n    struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];\n    Table *pTab = pTabItem->pTab;\n    assert( pTab!=0 );\n    pLoop = pLevel->pWLoop;\n\n    /* For a co-routine, change all OP_Column references to the table of\n    ** the co-routine into OP_Copy of result contained in a register.\n    ** OP_Rowid becomes OP_Null.\n    */\n    if( pTabItem->fg.viaCoroutine ){\n      testcase( pParse->db->mallocFailed );\n      translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,\n                            pTabItem->regResult, 0);\n      continue;\n    }\n\n    /* If this scan uses an index, make VDBE code substitutions to read data\n    ** from the index instead of from the table where possible.  In some cases\n    ** this optimization prevents the table from ever being read, which can\n    ** yield a significant performance boost.\n    ** \n    ** Calls to the code generator in between sqlite3WhereBegin and\n    ** sqlite3WhereEnd will have created code that references the table\n    ** directly.  This loop scans all that code looking for opcodes\n    ** that reference the table and converts them into opcodes that\n    ** reference the index.\n    */\n    if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){\n      pIdx = pLoop->u.btree.pIndex;\n    }else if( pLoop->wsFlags & WHERE_MULTI_OR ){\n      pIdx = pLevel->u.pCovidx;\n    }\n    if( pIdx\n     && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))\n     && !db->mallocFailed\n    ){\n      last = sqlite3VdbeCurrentAddr(v);\n      k = pLevel->addrBody;\n      pOp = sqlite3VdbeGetOp(v, k);\n      for(; k<last; k++, pOp++){\n        if( pOp->p1!=pLevel->iTabCur ) continue;\n        if( pOp->opcode==OP_Column ){\n          int x = pOp->p2;\n          assert( pIdx->pTable==pTab );\n          if( !HasRowid(pTab) ){\n            Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n            x = pPk->aiColumn[x];\n            assert( x>=0 );\n          }\n          x = sqlite3ColumnOfIndex(pIdx, x);\n          if( x>=0 ){\n            pOp->p2 = x;\n            pOp->p1 = pLevel->iIdxCur;\n          }\n          assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 \n              || pWInfo->eOnePass );\n        }else if( pOp->opcode==OP_Rowid ){\n          pOp->p1 = pLevel->iIdxCur;\n          pOp->opcode = OP_IdxRowid;\n        }else if( pOp->opcode==OP_IfNullRow ){\n          pOp->p1 = pLevel->iIdxCur;\n        }\n      }\n    }\n  }\n\n  /* Final cleanup\n  */\n  pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n  whereInfoFree(db, pWInfo);\n  return;\n}\n\n/************** End of where.c ***********************************************/\n/************** Begin file parse.c *******************************************/\n/*\n** 2000-05-29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Driver template for the LEMON parser generator.\n**\n** The \"lemon\" program processes an LALR(1) input grammar file, then uses\n** this template to construct a parser.  The \"lemon\" program inserts text\n** at each \"%%\" line.  Also, any \"P-a-r-s-e\" identifer prefix (without the\n** interstitial \"-\" characters) contained in this template is changed into\n** the value of the %name directive from the grammar.  Otherwise, the content\n** of this template is copied straight through into the generate parser\n** source file.\n**\n** The following is the concatenation of all %include directives from the\n** input grammar file:\n*/\n/* #include <stdio.h> */\n/************ Begin %include sections from the grammar ************************/\n\n/* #include \"sqliteInt.h\" */\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define YYNOERRORRECOVERY 1\n\n/*\n** Make yytestcase() the same as testcase()\n*/\n#define yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define YYPARSEFREENEVERNULL 1\n\n/*\n** In the amalgamation, the parse.c file generated by lemon and the\n** tokenize.c file are concatenated.  In that case, sqlite3RunParser()\n** has access to the the size of the yyParser object and so the parser\n** engine can be allocated from stack.  In that case, only the\n** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked\n** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be\n** omitted.\n*/\n#ifdef SQLITE_AMALGAMATION\n# define sqlite3Parser_ENGINEALWAYSONSTACK 1\n#endif\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define YYMALLOCARGTYPE  u64\n\n/*\n** An instance of this structure holds information about the\n** LIMIT clause of a SELECT statement.\n*/\nstruct LimitVal {\n  Expr *pLimit;    /* The LIMIT expression.  NULL if there is no limit */\n  Expr *pOffset;   /* The OFFSET expression.  NULL if there is none */\n};\n\n/*\n** An instance of the following structure describes the event of a\n** TRIGGER.  \"a\" is the event type, one of TK_UPDATE, TK_INSERT,\n** TK_DELETE, or TK_INSTEAD.  If the event is of the form\n**\n**      UPDATE ON (a,b,c)\n**\n** Then the \"b\" IdList records the list \"a,b,c\".\n*/\nstruct TrigEvent { int a; IdList * b; };\n\n/*\n** Disable lookaside memory allocation for objects that might be\n** shared across database connections.\n*/\nstatic void disableLookaside(Parse *pParse){\n  pParse->disableLookaside++;\n  pParse->db->lookaside.bDisable++;\n}\n\n\n  /*\n  ** For a compound SELECT statement, make sure p->pPrior->pNext==p for\n  ** all elements in the list.  And make sure list length does not exceed\n  ** SQLITE_LIMIT_COMPOUND_SELECT.\n  */\n  static void parserDoubleLinkSelect(Parse *pParse, Select *p){\n    if( p->pPrior ){\n      Select *pNext = 0, *pLoop;\n      int mxSelect, cnt = 0;\n      for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){\n        pLoop->pNext = pNext;\n        pLoop->selFlags |= SF_Compound;\n      }\n      if( (p->selFlags & SF_MultiValue)==0 && \n        (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&\n        cnt>mxSelect\n      ){\n        sqlite3ErrorMsg(pParse, \"too many terms in compound SELECT\");\n      }\n    }\n  }\n\n  /* This is a utility routine used to set the ExprSpan.zStart and\n  ** ExprSpan.zEnd values of pOut so that the span covers the complete\n  ** range of text beginning with pStart and going to the end of pEnd.\n  */\n  static void spanSet(ExprSpan *pOut, Token *pStart, Token *pEnd){\n    pOut->zStart = pStart->z;\n    pOut->zEnd = &pEnd->z[pEnd->n];\n  }\n\n  /* Construct a new Expr object from a single identifier.  Use the\n  ** new Expr to populate pOut.  Set the span of pOut to be the identifier\n  ** that created the expression.\n  */\n  static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token t){\n    Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);\n    if( p ){\n      memset(p, 0, sizeof(Expr));\n      p->op = (u8)op;\n      p->flags = EP_Leaf;\n      p->iAgg = -1;\n      p->u.zToken = (char*)&p[1];\n      memcpy(p->u.zToken, t.z, t.n);\n      p->u.zToken[t.n] = 0;\n      if( sqlite3Isquote(p->u.zToken[0]) ){\n        if( p->u.zToken[0]=='\"' ) p->flags |= EP_DblQuoted;\n        sqlite3Dequote(p->u.zToken);\n      }\n#if SQLITE_MAX_EXPR_DEPTH>0\n      p->nHeight = 1;\n#endif  \n    }\n    pOut->pExpr = p;\n    pOut->zStart = t.z;\n    pOut->zEnd = &t.z[t.n];\n  }\n\n  /* This routine constructs a binary expression node out of two ExprSpan\n  ** objects and uses the result to populate a new ExprSpan object.\n  */\n  static void spanBinaryExpr(\n    Parse *pParse,      /* The parsing context.  Errors accumulate here */\n    int op,             /* The binary operation */\n    ExprSpan *pLeft,    /* The left operand, and output */\n    ExprSpan *pRight    /* The right operand */\n  ){\n    pLeft->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr);\n    pLeft->zEnd = pRight->zEnd;\n  }\n\n  /* If doNot is true, then add a TK_NOT Expr-node wrapper around the\n  ** outside of *ppExpr.\n  */\n  static void exprNot(Parse *pParse, int doNot, ExprSpan *pSpan){\n    if( doNot ){\n      pSpan->pExpr = sqlite3PExpr(pParse, TK_NOT, pSpan->pExpr, 0);\n    }\n  }\n\n  /* Construct an expression node for a unary postfix operator\n  */\n  static void spanUnaryPostfix(\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand, and output */\n    Token *pPostOp         /* The operand token for setting the span */\n  ){\n    pOperand->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);\n    pOperand->zEnd = &pPostOp->z[pPostOp->n];\n  }                           \n\n  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a\n  ** unary TK_ISNULL or TK_NOTNULL expression. */\n  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){\n    sqlite3 *db = pParse->db;\n    if( pA && pY && pY->op==TK_NULL ){\n      pA->op = (u8)op;\n      sqlite3ExprDelete(db, pA->pRight);\n      pA->pRight = 0;\n    }\n  }\n\n  /* Construct an expression node for a unary prefix operator\n  */\n  static void spanUnaryPrefix(\n    ExprSpan *pOut,        /* Write the new expression node here */\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand */\n    Token *pPreOp         /* The operand token for setting the span */\n  ){\n    pOut->zStart = pPreOp->z;\n    pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);\n    pOut->zEnd = pOperand->zEnd;\n  }\n\n  /* Add a single new term to an ExprList that is used to store a\n  ** list of identifiers.  Report an error if the ID list contains\n  ** a COLLATE clause or an ASC or DESC keyword, except ignore the\n  ** error while parsing a legacy schema.\n  */\n  static ExprList *parserAddExprIdListTerm(\n    Parse *pParse,\n    ExprList *pPrior,\n    Token *pIdToken,\n    int hasCollate,\n    int sortOrder\n  ){\n    ExprList *p = sqlite3ExprListAppend(pParse, pPrior, 0);\n    if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED)\n        && pParse->db->init.busy==0\n    ){\n      sqlite3ErrorMsg(pParse, \"syntax error after column name \\\"%.*s\\\"\",\n                         pIdToken->n, pIdToken->z);\n    }\n    sqlite3ExprListSetName(pParse, p, pIdToken, 1);\n    return p;\n  }\n/**************** End of %include directives **********************************/\n/* These constants specify the various numeric values for terminal symbols\n** in a format understandable to \"makeheaders\".  This section is blank unless\n** \"lemon\" is run with the \"-m\" command-line option.\n***************** Begin makeheaders token definitions *************************/\n/**************** End makeheaders token definitions ***************************/\n\n/* The next sections is a series of control #defines.\n** various aspects of the generated parser.\n**    YYCODETYPE         is the data type used to store the integer codes\n**                       that represent terminal and non-terminal symbols.\n**                       \"unsigned char\" is used if there are fewer than\n**                       256 symbols.  Larger types otherwise.\n**    YYNOCODE           is a number of type YYCODETYPE that is not used for\n**                       any terminal or nonterminal symbol.\n**    YYFALLBACK         If defined, this indicates that one or more tokens\n**                       (also known as: \"terminal symbols\") have fall-back\n**                       values which should be used if the original symbol\n**                       would not parse.  This permits keywords to sometimes\n**                       be used as identifiers, for example.\n**    YYACTIONTYPE       is the data type used for \"action codes\" - numbers\n**                       that indicate what to do in response to the next\n**                       token.\n**    sqlite3ParserTOKENTYPE     is the data type used for minor type for terminal\n**                       symbols.  Background: A \"minor type\" is a semantic\n**                       value associated with a terminal or non-terminal\n**                       symbols.  For example, for an \"ID\" terminal symbol,\n**                       the minor type might be the name of the identifier.\n**                       Each non-terminal can have a different minor type.\n**                       Terminal symbols all have the same minor type, though.\n**                       This macros defines the minor type for terminal \n**                       symbols.\n**    YYMINORTYPE        is the data type used for all minor types.\n**                       This is typically a union of many types, one of\n**                       which is sqlite3ParserTOKENTYPE.  The entry in the union\n**                       for terminal symbols is called \"yy0\".\n**    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If\n**                       zero the stack is dynamically sized using realloc()\n**    sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument\n**    sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument\n**    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser\n**    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser\n**    YYERRORSYMBOL      is the code number of the error symbol.  If not\n**                       defined, then do no error processing.\n**    YYNSTATE           the combined number of states.\n**    YYNRULE            the number of rules in the grammar\n**    YY_MAX_SHIFT       Maximum value for shift actions\n**    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions\n**    YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions\n**    YY_MIN_REDUCE      Minimum value for reduce actions\n**    YY_MAX_REDUCE      Maximum value for reduce actions\n**    YY_ERROR_ACTION    The yy_action[] code for syntax error\n**    YY_ACCEPT_ACTION   The yy_action[] code for accept\n**    YY_NO_ACTION       The yy_action[] code for no-op\n*/\n#ifndef INTERFACE\n# define INTERFACE 1\n#endif\n/************* Begin control #defines *****************************************/\n#define YYCODETYPE unsigned char\n#define YYNOCODE 252\n#define YYACTIONTYPE unsigned short int\n#define YYWILDCARD 83\n#define sqlite3ParserTOKENTYPE Token\ntypedef union {\n  int yyinit;\n  sqlite3ParserTOKENTYPE yy0;\n  Expr* yy72;\n  TriggerStep* yy145;\n  ExprList* yy148;\n  SrcList* yy185;\n  ExprSpan yy190;\n  int yy194;\n  Select* yy243;\n  IdList* yy254;\n  With* yy285;\n  struct TrigEvent yy332;\n  struct LimitVal yy354;\n  struct {int value; int mask;} yy497;\n} YYMINORTYPE;\n#ifndef YYSTACKDEPTH\n#define YYSTACKDEPTH 100\n#endif\n#define sqlite3ParserARG_SDECL Parse *pParse;\n#define sqlite3ParserARG_PDECL ,Parse *pParse\n#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse\n#define sqlite3ParserARG_STORE yypParser->pParse = pParse\n#define YYFALLBACK 1\n#define YYNSTATE             455\n#define YYNRULE              329\n#define YY_MAX_SHIFT         454\n#define YY_MIN_SHIFTREDUCE   664\n#define YY_MAX_SHIFTREDUCE   992\n#define YY_MIN_REDUCE        993\n#define YY_MAX_REDUCE        1321\n#define YY_ERROR_ACTION      1322\n#define YY_ACCEPT_ACTION     1323\n#define YY_NO_ACTION         1324\n/************* End control #defines *******************************************/\n\n/* Define the yytestcase() macro to be a no-op if is not already defined\n** otherwise.\n**\n** Applications can choose to define yytestcase() in the %include section\n** to a macro that can assist in verifying code coverage.  For production\n** code the yytestcase() macro should be turned off.  But it is useful\n** for testing.\n*/\n#ifndef yytestcase\n# define yytestcase(X)\n#endif\n\n\n/* Next are the tables used to determine what action to take based on the\n** current state and lookahead token.  These tables are used to implement\n** functions that take a state number and lookahead value and return an\n** action integer.  \n**\n** Suppose the action integer is N.  Then the action is determined as\n** follows\n**\n**   0 <= N <= YY_MAX_SHIFT             Shift N.  That is, push the lookahead\n**                                      token onto the stack and goto state N.\n**\n**   N between YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then\n**     and YY_MAX_SHIFTREDUCE           reduce by rule N-YY_MIN_SHIFTREDUCE.\n**\n**   N between YY_MIN_REDUCE            Reduce by rule N-YY_MIN_REDUCE\n**     and YY_MAX_REDUCE\n**\n**   N == YY_ERROR_ACTION               A syntax error has occurred.\n**\n**   N == YY_ACCEPT_ACTION              The parser accepts its input.\n**\n**   N == YY_NO_ACTION                  No such action.  Denotes unused\n**                                      slots in the yy_action[] table.\n**\n** The action table is constructed as a single large table named yy_action[].\n** Given state S and lookahead X, the action is computed as either:\n**\n**    (A)   N = yy_action[ yy_shift_ofst[S] + X ]\n**    (B)   N = yy_default[S]\n**\n** The (A) formula is preferred.  The B formula is used instead if:\n**    (1)  The yy_shift_ofst[S]+X value is out of range, or\n**    (2)  yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or\n**    (3)  yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.\n** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that\n** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.\n** Hence only tests (1) and (2) need to be evaluated.)\n**\n** The formulas above are for computing the action when the lookahead is\n** a terminal symbol.  If the lookahead is a non-terminal (as occurs after\n** a reduce action) then the yy_reduce_ofst[] array is used in place of\n** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of\n** YY_SHIFT_USE_DFLT.\n**\n** The following are the tables generated in this section:\n**\n**  yy_action[]        A single table containing all actions.\n**  yy_lookahead[]     A table containing the lookahead for each entry in\n**                     yy_action.  Used to detect hash collisions.\n**  yy_shift_ofst[]    For each state, the offset into yy_action for\n**                     shifting terminals.\n**  yy_reduce_ofst[]   For each state, the offset into yy_action for\n**                     shifting non-terminals after a reduce.\n**  yy_default[]       Default action for each state.\n**\n*********** Begin parsing tables **********************************************/\n#define YY_ACTTAB_COUNT (1566)\nstatic const YYACTIONTYPE yy_action[] = {\n /*     0 */   324, 1323,  155,  155,    2,  203,   94,   94,   94,   93,\n /*    10 */   350,   98,   98,   98,   98,   91,   95,   95,   94,   94,\n /*    20 */    94,   93,  350,  268,   99,  100,   90,  971,  971,  847,\n /*    30 */   850,  839,  839,   97,   97,   98,   98,   98,   98,  350,\n /*    40 */   969,   96,   96,   96,   96,   95,   95,   94,   94,   94,\n /*    50 */    93,  350,  950,   96,   96,   96,   96,   95,   95,   94,\n /*    60 */    94,   94,   93,  350,  250,   96,   96,   96,   96,   95,\n /*    70 */    95,   94,   94,   94,   93,  350,  224,  224,  969,  132,\n /*    80 */   888,  348,  347,  415,  172,  324, 1286,  449,  414,  950,\n /*    90 */   951,  952,  808,  977, 1032,  950,  300,  786,  428,  132,\n /*   100 */   975,  362,  976,    9,    9,  787,  132,   52,   52,   99,\n /*   110 */   100,   90,  971,  971,  847,  850,  839,  839,   97,   97,\n /*   120 */    98,   98,   98,   98,  372,  978,  241,  978,  262,  369,\n /*   130 */   261,  120,  950,  951,  952,  194,   58,  324,  401,  398,\n /*   140 */   397,  808,  427,  429,   75,  808, 1260, 1260,  132,  396,\n /*   150 */    96,   96,   96,   96,   95,   95,   94,   94,   94,   93,\n /*   160 */   350,   99,  100,   90,  971,  971,  847,  850,  839,  839,\n /*   170 */    97,   97,   98,   98,   98,   98,  786,  262,  369,  261,\n /*   180 */   826,  262,  364,  251,  787, 1084,  101, 1114,   72,  324,\n /*   190 */   227, 1113,  242,  411,  442,  819,   92,   89,  178,  818,\n /*   200 */  1022,  268,   96,   96,   96,   96,   95,   95,   94,   94,\n /*   210 */    94,   93,  350,   99,  100,   90,  971,  971,  847,  850,\n /*   220 */   839,  839,   97,   97,   98,   98,   98,   98,  449,  372,\n /*   230 */   818,  818,  820,   92,   89,  178,   60,   92,   89,  178,\n /*   240 */  1025,  324,  357,  930, 1316,  300,   61, 1316,   52,   52,\n /*   250 */   836,  836,  848,  851,   96,   96,   96,   96,   95,   95,\n /*   260 */    94,   94,   94,   93,  350,   99,  100,   90,  971,  971,\n /*   270 */   847,  850,  839,  839,   97,   97,   98,   98,   98,   98,\n /*   280 */    92,   89,  178,  427,  412,  198,  930, 1317,  454,  995,\n /*   290 */  1317,  355, 1024,  324,  243,  231,  114,  277,  348,  347,\n /*   300 */  1242,  950,  416, 1071,  928,  840,   96,   96,   96,   96,\n /*   310 */    95,   95,   94,   94,   94,   93,  350,   99,  100,   90,\n /*   320 */   971,  971,  847,  850,  839,  839,   97,   97,   98,   98,\n /*   330 */    98,   98,  449,  328,  449,  120,   23,  256,  950,  951,\n /*   340 */   952,  968,  978,  438,  978,  324,  329,  928,  954,  701,\n /*   350 */   200,  175,   52,   52,   52,   52,  939,  353,   96,   96,\n /*   360 */    96,   96,   95,   95,   94,   94,   94,   93,  350,   99,\n /*   370 */   100,   90,  971,  971,  847,  850,  839,  839,   97,   97,\n /*   380 */    98,   98,   98,   98,  354,  449,  954,  427,  417,  427,\n /*   390 */   426, 1290,   92,   89,  178,  268,  253,  324,  255, 1058,\n /*   400 */  1037,  694,   93,  350,  383,   52,   52,  380, 1058,  374,\n /*   410 */    96,   96,   96,   96,   95,   95,   94,   94,   94,   93,\n /*   420 */   350,   99,  100,   90,  971,  971,  847,  850,  839,  839,\n /*   430 */    97,   97,   98,   98,   98,   98,  228,  449,  167,  449,\n /*   440 */   427,  407,  157,  446,  446,  446,  349,  349,  349,  324,\n /*   450 */   310,  316,  991,  827,  320,  242,  411,   51,   51,   36,\n /*   460 */    36,  254,   96,   96,   96,   96,   95,   95,   94,   94,\n /*   470 */    94,   93,  350,   99,  100,   90,  971,  971,  847,  850,\n /*   480 */   839,  839,   97,   97,   98,   98,   98,   98,  194,  316,\n /*   490 */   929,  401,  398,  397,  224,  224, 1265,  939,  353, 1318,\n /*   500 */   317,  324,  396, 1063, 1063,  813,  414, 1061, 1061,  950,\n /*   510 */   299,  448,  992,  268,   96,   96,   96,   96,   95,   95,\n /*   520 */    94,   94,   94,   93,  350,   99,  100,   90,  971,  971,\n /*   530 */   847,  850,  839,  839,   97,   97,   98,   98,   98,   98,\n /*   540 */   757, 1041,  449,  893,  893,  386,  950,  951,  952,  410,\n /*   550 */   992,  747,  747,  324,  229,  268,  221,  296,  268,  771,\n /*   560 */   890,  378,   52,   52,  890,  421,   96,   96,   96,   96,\n /*   570 */    95,   95,   94,   94,   94,   93,  350,   99,  100,   90,\n /*   580 */   971,  971,  847,  850,  839,  839,   97,   97,   98,   98,\n /*   590 */    98,   98,  103,  449,  275,  384, 1241,  343,  157, 1207,\n /*   600 */   909,  669,  670,  671,  176,  197,  196,  195,  324,  298,\n /*   610 */   319, 1266,    2,   37,   37,  910, 1134, 1040,   96,   96,\n /*   620 */    96,   96,   95,   95,   94,   94,   94,   93,  350,  697,\n /*   630 */   911,  177,   99,  100,   90,  971,  971,  847,  850,  839,\n /*   640 */   839,   97,   97,   98,   98,   98,   98,  230,  146,  120,\n /*   650 */   735, 1235,  826,  270, 1141,  273, 1141,  771,  171,  170,\n /*   660 */   736, 1141,   82,  324,   80,  268,  697,  819,  158,  268,\n /*   670 */   378,  818,   78,   96,   96,   96,   96,   95,   95,   94,\n /*   680 */    94,   94,   93,  350,  120,  950,  393,   99,  100,   90,\n /*   690 */   971,  971,  847,  850,  839,  839,   97,   97,   98,   98,\n /*   700 */    98,   98,  818,  818,  820, 1141, 1070,  370,  331,  133,\n /*   710 */  1066, 1141, 1250,  198,  268,  324, 1016,  330,  245,  333,\n /*   720 */    24,  334,  950,  951,  952,  368,  335,   81,   96,   96,\n /*   730 */    96,   96,   95,   95,   94,   94,   94,   93,  350,   99,\n /*   740 */   100,   90,  971,  971,  847,  850,  839,  839,   97,   97,\n /*   750 */    98,   98,   98,   98,  132,  267,  260,  445,  330,  223,\n /*   760 */   175, 1289,  925,  752,  724,  318, 1073,  324,  751,  246,\n /*   770 */   385,  301,  301,  378,  329,  361,  344,  414, 1233,  280,\n /*   780 */    96,   96,   96,   96,   95,   95,   94,   94,   94,   93,\n /*   790 */   350,   99,   88,   90,  971,  971,  847,  850,  839,  839,\n /*   800 */    97,   97,   98,   98,   98,   98,  337,  346,  721,  722,\n /*   810 */   449,  120,  118,  887,  162,  887,  810,  371,  324,  202,\n /*   820 */   202,  373,  249,  263,  202,  394,   74,  704,  208, 1069,\n /*   830 */    12,   12,   96,   96,   96,   96,   95,   95,   94,   94,\n /*   840 */    94,   93,  350,  100,   90,  971,  971,  847,  850,  839,\n /*   850 */   839,   97,   97,   98,   98,   98,   98,  449,  771,  232,\n /*   860 */   449,  278,  120,  286,   74,  704,  714,  713,  324,  342,\n /*   870 */   749,  877, 1209,   77,  285, 1255,  780,   52,   52,  202,\n /*   880 */    27,   27,  418,   96,   96,   96,   96,   95,   95,   94,\n /*   890 */    94,   94,   93,  350,   90,  971,  971,  847,  850,  839,\n /*   900 */   839,   97,   97,   98,   98,   98,   98,   86,  444,  877,\n /*   910 */     3, 1193,  422, 1013,  873,  435,  886,  208,  886,  689,\n /*   920 */  1091,  257,  116,  822,  447, 1230,  117, 1229,   86,  444,\n /*   930 */   177,    3,  381,   96,   96,   96,   96,   95,   95,   94,\n /*   940 */    94,   94,   93,  350,  339,  447,  120,  351,  120,  212,\n /*   950 */   169,  287,  404,  282,  403,  199,  771,  950,  433,  419,\n /*   960 */   439,  822,  280,  691, 1039,  264,  269,  132,  351,  153,\n /*   970 */   826,  376,   74,  272,  274,  276,   83,   84, 1054,  433,\n /*   980 */   147, 1038,  443,   85,  351,  451,  450,  281,  132,  818,\n /*   990 */    25,  826,  449,  120,  950,  951,  952,   83,   84,   86,\n /*  1000 */   444,  691,    3,  408,   85,  351,  451,  450,  449,    5,\n /*  1010 */   818,  203,   32,   32, 1107,  120,  447,  950,  225, 1140,\n /*  1020 */   818,  818,  820,  821,   19,  203,  226,  950,   38,   38,\n /*  1030 */  1087,  314,  314,  313,  215,  311,  120,  449,  678,  351,\n /*  1040 */   237,  818,  818,  820,  821,   19,  969,  409,  377,    1,\n /*  1050 */   433,  180,  706,  248,  950,  951,  952,   10,   10,  449,\n /*  1060 */   969,  247,  826, 1098,  950,  951,  952,  430,   83,   84,\n /*  1070 */   756,  336,  950,   20,  431,   85,  351,  451,  450,   10,\n /*  1080 */    10,  818,   86,  444,  969,    3,  950,  449,  302,  303,\n /*  1090 */   182,  950, 1146,  338, 1021, 1015, 1004,  183,  969,  447,\n /*  1100 */   132,  181,   76,  444,   21,    3,  449,   10,   10,  950,\n /*  1110 */   951,  952,  818,  818,  820,  821,   19,  715, 1279,  447,\n /*  1120 */   389,  233,  351,  950,  951,  952,   10,   10,  950,  951,\n /*  1130 */   952, 1003,  218,  433, 1005,  325, 1273,  773,  289,  291,\n /*  1140 */   424,  293,  351,    7,  159,  826,  363,  402,  315,  360,\n /*  1150 */  1129,   83,   84,  433, 1232,  716,  772,  259,   85,  351,\n /*  1160 */   451,  450,  358,  375,  818,  826,  360,  359,  399, 1211,\n /*  1170 */   157,   83,   84,  681,   98,   98,   98,   98,   85,  351,\n /*  1180 */   451,  450,  323,  252,  818,  295, 1211, 1213, 1235,  173,\n /*  1190 */  1037,  284,  434,  340, 1204,  818,  818,  820,  821,   19,\n /*  1200 */   308,  234,  449,  234,   96,   96,   96,   96,   95,   95,\n /*  1210 */    94,   94,   94,   93,  350,  818,  818,  820,  821,   19,\n /*  1220 */   909,  120,   39,   39, 1203,  449,  168,  360,  449, 1276,\n /*  1230 */   367,  449,  135,  449,  986,  910,  449, 1249,  449, 1247,\n /*  1240 */   449,  205,  983,  449,  370,   40,   40, 1211,   41,   41,\n /*  1250 */   911,   42,   42,   28,   28,  870,   29,   29,   31,   31,\n /*  1260 */    43,   43,  379,   44,   44,  449,   59,  449,  332,  449,\n /*  1270 */   432,   62,  144,  156,  449,  130,  449,   72,  449,  137,\n /*  1280 */   449,  365,  449,  392,  139,   45,   45,   11,   11,   46,\n /*  1290 */    46,  140, 1200,  449,  105,  105,   47,   47,   48,   48,\n /*  1300 */    33,   33,   49,   49, 1126,  449,  141,  366,  449,  185,\n /*  1310 */   142,  449, 1234,   50,   50,  449,  160,  449,  148,  449,\n /*  1320 */  1136,  382,  449,   67,  449,   34,   34,  449,  122,  122,\n /*  1330 */   449,  123,  123,  449, 1198,  124,  124,   56,   56,   35,\n /*  1340 */    35,  449,  106,  106,   53,   53,  449,  107,  107,  449,\n /*  1350 */   108,  108,  449,  104,  104,  449,  406,  449,  388,  449,\n /*  1360 */   189,  121,  121,  449,  190,  449,  119,  119,  449,  112,\n /*  1370 */   112,  449,  111,  111, 1218,  109,  109,  110,  110,   55,\n /*  1380 */    55,  266,  752,   57,   57,   54,   54,  751,   26,   26,\n /*  1390 */  1099,   30,   30,  219,  154,  390,  271,  191,  321, 1006,\n /*  1400 */   192,  405, 1057, 1056, 1055,  341, 1048,  706, 1047, 1029,\n /*  1410 */   322,  420, 1028,   71, 1095,  283,  288, 1027, 1288,  204,\n /*  1420 */     6,  297,   79, 1184,  437, 1096, 1094,  290,  345,  292,\n /*  1430 */   441, 1093,  294,  102,  425,   73,  423,  213, 1012,   22,\n /*  1440 */   452,  945,  214, 1077,  216,  217,  238,  453,  306,  304,\n /*  1450 */   307,  239,  240, 1001,  305,  125,  996,  126,  115,  235,\n /*  1460 */   127,  665,  352,  166,  244,  179,  356,  113,  885,  883,\n /*  1470 */   806,  136,  128,  738,  326,  138,  327,  258,  184,  899,\n /*  1480 */   143,  129,  145,   63,   64,   65,   66,  902,  186,  187,\n /*  1490 */   898,    8,   13,  188,  134,  265,  891,  202,  980,  387,\n /*  1500 */   150,  149,  680,  161,  391,  193,  285,  279,  395,  151,\n /*  1510 */    68,  717,   14,   15,  400,   69,   16,  131,  236,  825,\n /*  1520 */   824,  853,  746,  750,    4,   70,  174,  413,  220,  222,\n /*  1530 */   152,  779,  774,   77,  868,   74,  854,  201,   17,  852,\n /*  1540 */   908,  206,  907,  207,   18,  857,  934,  163,  436,  210,\n /*  1550 */   935,  164,  209,  165,  440,  856,  823,  312,  690,   87,\n /*  1560 */   211,  309, 1281,  940,  995, 1280,\n};\nstatic const YYCODETYPE yy_lookahead[] = {\n /*     0 */    19,  144,  145,  146,  147,   24,   90,   91,   92,   93,\n /*    10 */    94,   54,   55,   56,   57,   58,   88,   89,   90,   91,\n /*    20 */    92,   93,   94,  152,   43,   44,   45,   46,   47,   48,\n /*    30 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   94,\n /*    40 */    59,   84,   85,   86,   87,   88,   89,   90,   91,   92,\n /*    50 */    93,   94,   59,   84,   85,   86,   87,   88,   89,   90,\n /*    60 */    91,   92,   93,   94,  193,   84,   85,   86,   87,   88,\n /*    70 */    89,   90,   91,   92,   93,   94,  194,  195,   97,   79,\n /*    80 */    11,   88,   89,  152,   26,   19,  171,  152,  206,   96,\n /*    90 */    97,   98,   72,  100,  179,   59,  152,   31,  163,   79,\n /*   100 */   107,  219,  109,  172,  173,   39,   79,  172,  173,   43,\n /*   110 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*   120 */    54,   55,   56,   57,  152,  132,  199,  134,  108,  109,\n /*   130 */   110,  196,   96,   97,   98,   99,  209,   19,  102,  103,\n /*   140 */   104,   72,  207,  208,   26,   72,  119,  120,   79,  113,\n /*   150 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,\n /*   160 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,\n /*   170 */    52,   53,   54,   55,   56,   57,   31,  108,  109,  110,\n /*   180 */    82,  108,  109,  110,   39,  210,   68,  175,  130,   19,\n /*   190 */   218,  175,  119,  120,  250,   97,  221,  222,  223,  101,\n /*   200 */   172,  152,   84,   85,   86,   87,   88,   89,   90,   91,\n /*   210 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,\n /*   220 */    50,   51,   52,   53,   54,   55,   56,   57,  152,  152,\n /*   230 */   132,  133,  134,  221,  222,  223,   66,  221,  222,  223,\n /*   240 */   172,   19,  193,   22,   23,  152,   24,   26,  172,  173,\n /*   250 */    46,   47,   48,   49,   84,   85,   86,   87,   88,   89,\n /*   260 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,\n /*   270 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,\n /*   280 */   221,  222,  223,  207,  208,   46,   22,   23,  148,  149,\n /*   290 */    26,  242,  172,   19,  154,  218,  156,   23,   88,   89,\n /*   300 */   241,   59,  163,  163,   83,  101,   84,   85,   86,   87,\n /*   310 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,\n /*   320 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,\n /*   330 */    56,   57,  152,  157,  152,  196,  196,   16,   96,   97,\n /*   340 */    98,   26,  132,  250,  134,   19,  107,   83,   59,   23,\n /*   350 */   211,  212,  172,  173,  172,  173,    1,    2,   84,   85,\n /*   360 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,\n /*   370 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*   380 */    54,   55,   56,   57,  244,  152,   97,  207,  208,  207,\n /*   390 */   208,  185,  221,  222,  223,  152,   75,   19,   77,  179,\n /*   400 */   180,   23,   93,   94,  228,  172,  173,  231,  188,  152,\n /*   410 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,\n /*   420 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,\n /*   430 */    52,   53,   54,   55,   56,   57,  193,  152,  123,  152,\n /*   440 */   207,  208,  152,  168,  169,  170,  168,  169,  170,   19,\n /*   450 */   160,   22,   23,   23,  164,  119,  120,  172,  173,  172,\n /*   460 */   173,  140,   84,   85,   86,   87,   88,   89,   90,   91,\n /*   470 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,\n /*   480 */    50,   51,   52,   53,   54,   55,   56,   57,   99,   22,\n /*   490 */    23,  102,  103,  104,  194,  195,    0,    1,    2,  247,\n /*   500 */   248,   19,  113,  190,  191,   23,  206,  190,  191,   59,\n /*   510 */   225,  152,   83,  152,   84,   85,   86,   87,   88,   89,\n /*   520 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,\n /*   530 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,\n /*   540 */    90,  181,  152,  108,  109,  110,   96,   97,   98,  115,\n /*   550 */    83,  117,  118,   19,  193,  152,   23,  152,  152,   26,\n /*   560 */    29,  152,  172,  173,   33,  152,   84,   85,   86,   87,\n /*   570 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,\n /*   580 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,\n /*   590 */    56,   57,   22,  152,   16,   64,  193,  207,  152,  193,\n /*   600 */    12,    7,    8,    9,  152,  108,  109,  110,   19,  152,\n /*   610 */   164,  146,  147,  172,  173,   27,  163,  181,   84,   85,\n /*   620 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   59,\n /*   630 */    42,   98,   43,   44,   45,   46,   47,   48,   49,   50,\n /*   640 */    51,   52,   53,   54,   55,   56,   57,  238,   22,  196,\n /*   650 */    62,  163,   82,   75,  152,   77,  152,  124,   88,   89,\n /*   660 */    72,  152,  137,   19,  139,  152,   96,   97,   24,  152,\n /*   670 */   152,  101,  138,   84,   85,   86,   87,   88,   89,   90,\n /*   680 */    91,   92,   93,   94,  196,   59,   19,   43,   44,   45,\n /*   690 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,\n /*   700 */    56,   57,  132,  133,  134,  152,  193,  219,  245,  246,\n /*   710 */   193,  152,  152,   46,  152,   19,  166,  167,  152,  217,\n /*   720 */   232,  217,   96,   97,   98,  237,  217,  138,   84,   85,\n /*   730 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,\n /*   740 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,\n /*   750 */    54,   55,   56,   57,   79,  193,  238,  166,  167,  211,\n /*   760 */   212,   23,   23,  116,   26,   26,  195,   19,  121,  152,\n /*   770 */   217,  152,  152,  152,  107,  100,  217,  206,  163,  112,\n /*   780 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,\n /*   790 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,\n /*   800 */    52,   53,   54,   55,   56,   57,  187,  187,    7,    8,\n /*   810 */   152,  196,   22,  132,   24,  134,   23,   23,   19,   26,\n /*   820 */    26,   23,  152,   23,   26,   23,   26,   59,   26,  163,\n /*   830 */   172,  173,   84,   85,   86,   87,   88,   89,   90,   91,\n /*   840 */    92,   93,   94,   44,   45,   46,   47,   48,   49,   50,\n /*   850 */    51,   52,   53,   54,   55,   56,   57,  152,   26,  238,\n /*   860 */   152,   23,  196,  101,   26,   97,  100,  101,   19,   19,\n /*   870 */    23,   59,  152,   26,  112,  152,   23,  172,  173,   26,\n /*   880 */   172,  173,   19,   84,   85,   86,   87,   88,   89,   90,\n /*   890 */    91,   92,   93,   94,   45,   46,   47,   48,   49,   50,\n /*   900 */    51,   52,   53,   54,   55,   56,   57,   19,   20,   97,\n /*   910 */    22,   23,  207,  163,   23,  163,  132,   26,  134,   23,\n /*   920 */   213,  152,   26,   59,   36,  152,   22,  152,   19,   20,\n /*   930 */    98,   22,  152,   84,   85,   86,   87,   88,   89,   90,\n /*   940 */    91,   92,   93,   94,   94,   36,  196,   59,  196,   99,\n /*   950 */   100,  101,  102,  103,  104,  105,  124,   59,   70,   96,\n /*   960 */   163,   97,  112,   59,  181,  152,  152,   79,   59,   71,\n /*   970 */    82,   19,   26,  152,  152,  152,   88,   89,  152,   70,\n /*   980 */    22,  152,  163,   95,   96,   97,   98,  152,   79,  101,\n /*   990 */    22,   82,  152,  196,   96,   97,   98,   88,   89,   19,\n /*  1000 */    20,   97,   22,  163,   95,   96,   97,   98,  152,   22,\n /*  1010 */   101,   24,  172,  173,  152,  196,   36,   59,   22,  152,\n /*  1020 */   132,  133,  134,  135,  136,   24,    5,   59,  172,  173,\n /*  1030 */   152,   10,   11,   12,   13,   14,  196,  152,   17,   59,\n /*  1040 */   210,  132,  133,  134,  135,  136,   59,  207,   96,   22,\n /*  1050 */    70,   30,  106,   32,   96,   97,   98,  172,  173,  152,\n /*  1060 */    59,   40,   82,  152,   96,   97,   98,  152,   88,   89,\n /*  1070 */    90,  186,   59,   22,  191,   95,   96,   97,   98,  172,\n /*  1080 */   173,  101,   19,   20,   97,   22,   59,  152,  152,  152,\n /*  1090 */    69,   59,  152,  186,  152,  152,  152,   76,   97,   36,\n /*  1100 */    79,   80,   19,   20,   53,   22,  152,  172,  173,   96,\n /*  1110 */    97,   98,  132,  133,  134,  135,  136,   35,  122,   36,\n /*  1120 */   234,  186,   59,   96,   97,   98,  172,  173,   96,   97,\n /*  1130 */    98,  152,  233,   70,  152,  114,  152,  124,  210,  210,\n /*  1140 */   186,  210,   59,  198,  197,   82,  214,   65,  150,  152,\n /*  1150 */   201,   88,   89,   70,  201,   73,  124,  239,   95,   96,\n /*  1160 */    97,   98,  141,  239,  101,   82,  169,  170,  176,  152,\n /*  1170 */   152,   88,   89,   21,   54,   55,   56,   57,   95,   96,\n /*  1180 */    97,   98,  164,  214,  101,  214,  169,  170,  163,  184,\n /*  1190 */   180,  175,  227,  111,  175,  132,  133,  134,  135,  136,\n /*  1200 */   200,  183,  152,  185,   84,   85,   86,   87,   88,   89,\n /*  1210 */    90,   91,   92,   93,   94,  132,  133,  134,  135,  136,\n /*  1220 */    12,  196,  172,  173,  175,  152,  198,  230,  152,  155,\n /*  1230 */    78,  152,  243,  152,   60,   27,  152,  159,  152,  159,\n /*  1240 */   152,  122,   38,  152,  219,  172,  173,  230,  172,  173,\n /*  1250 */    42,  172,  173,  172,  173,  103,  172,  173,  172,  173,\n /*  1260 */   172,  173,  237,  172,  173,  152,  240,  152,  159,  152,\n /*  1270 */    62,  240,   22,  220,  152,   43,  152,  130,  152,  189,\n /*  1280 */   152,   18,  152,   18,  192,  172,  173,  172,  173,  172,\n /*  1290 */   173,  192,  140,  152,  172,  173,  172,  173,  172,  173,\n /*  1300 */   172,  173,  172,  173,  201,  152,  192,  159,  152,  158,\n /*  1310 */   192,  152,  201,  172,  173,  152,  220,  152,  189,  152,\n /*  1320 */   189,  159,  152,  137,  152,  172,  173,  152,  172,  173,\n /*  1330 */   152,  172,  173,  152,  201,  172,  173,  172,  173,  172,\n /*  1340 */   173,  152,  172,  173,  172,  173,  152,  172,  173,  152,\n /*  1350 */   172,  173,  152,  172,  173,  152,   90,  152,   61,  152,\n /*  1360 */   158,  172,  173,  152,  158,  152,  172,  173,  152,  172,\n /*  1370 */   173,  152,  172,  173,  236,  172,  173,  172,  173,  172,\n /*  1380 */   173,  235,  116,  172,  173,  172,  173,  121,  172,  173,\n /*  1390 */   159,  172,  173,  159,   22,  177,  159,  158,  177,  159,\n /*  1400 */   158,  107,  174,  174,  174,   63,  182,  106,  182,  174,\n /*  1410 */   177,  125,  176,  107,  216,  174,  215,  174,  174,  159,\n /*  1420 */    22,  159,  137,  224,  177,  216,  216,  215,   94,  215,\n /*  1430 */   177,  216,  215,  129,  126,  128,  127,   25,  162,   26,\n /*  1440 */   161,   13,  153,  205,  153,    6,  226,  151,  202,  204,\n /*  1450 */   201,  229,  229,  151,  203,  165,  151,  165,  178,  178,\n /*  1460 */   165,    4,    3,   22,  142,   15,   81,   16,   23,   23,\n /*  1470 */   120,  131,  111,   20,  249,  123,  249,   16,  125,    1,\n /*  1480 */   123,  111,  131,   53,   53,   53,   53,   96,   34,  122,\n /*  1490 */     1,    5,   22,  107,  246,  140,   67,   26,   74,   41,\n /*  1500 */   107,   67,   20,   24,   19,  105,  112,   23,   66,   22,\n /*  1510 */    22,   28,   22,   22,   66,   22,   22,   37,   66,   23,\n /*  1520 */    23,   23,  116,   23,   22,   26,  122,   26,   23,   23,\n /*  1530 */    22,   96,  124,   26,   23,   26,   23,   34,   34,   23,\n /*  1540 */    23,   26,   23,   22,   34,   11,   23,   22,   24,  122,\n /*  1550 */    23,   22,   26,   22,   24,   23,   23,   15,   23,   22,\n /*  1560 */   122,   23,  122,    1,  251,  122,\n};\n#define YY_SHIFT_USE_DFLT (1566)\n#define YY_SHIFT_COUNT    (454)\n#define YY_SHIFT_MIN      (-84)\n#define YY_SHIFT_MAX      (1562)\nstatic const short yy_shift_ofst[] = {\n /*     0 */   355,  888, 1021,  909, 1063, 1063, 1063, 1063,   20,  -19,\n /*    10 */    66,   66,  170, 1063, 1063, 1063, 1063, 1063, 1063, 1063,\n /*    20 */    -7,   -7,   36,   73,   69,   27,  118,  222,  274,  326,\n /*    30 */   378,  430,  482,  534,  589,  644,  696,  696,  696,  696,\n /*    40 */   696,  696,  696,  696,  696,  696,  696,  696,  696,  696,\n /*    50 */   696,  696,  696,  748,  696,  799,  849,  849,  980, 1063,\n /*    60 */  1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,\n /*    70 */  1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,\n /*    80 */  1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,\n /*    90 */  1083, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063,\n /*   100 */  1063, 1063, 1063, 1063,  -43, 1120, 1120, 1120, 1120, 1120,\n /*   110 */   -31,  -72,  -84,  242, 1152,  667,  210,  210,  242,  309,\n /*   120 */   336,  -55, 1566, 1566, 1566,  850,  850,  850,  626,  626,\n /*   130 */   588,  588,  898,  221,  264,  242,  242,  242,  242,  242,\n /*   140 */   242,  242,  242,  242,  242,  242,  242,  242,  242,  242,\n /*   150 */   242,  242,  242,  242,  242,  496,  675,  289,  289,  336,\n /*   160 */     0,    0,    0,    0,    0,    0, 1566, 1566, 1566,  570,\n /*   170 */    98,   98,  958,  389,  450,  968, 1013, 1032, 1027,  242,\n /*   180 */   242,  242,  242,  242,  242,  242,  242,  242,  242,  242,\n /*   190 */   242,  242,  242,  242,  242, 1082, 1082, 1082,  242,  242,\n /*   200 */   533,  242,  242,  242,  987,  242,  242, 1208,  242,  242,\n /*   210 */   242,  242,  242,  242,  242,  242,  242,  242,  435,  531,\n /*   220 */  1001, 1001, 1001,  832,  434, 1266,  594,   58,  863,  863,\n /*   230 */   952,   58,  952,  946,  738,  239,  145,  863,  525,  145,\n /*   240 */   145,  315,  647,  790, 1174, 1119, 1119, 1204, 1204, 1119,\n /*   250 */  1250, 1232, 1147, 1263, 1263, 1263, 1263, 1119, 1265, 1147,\n /*   260 */  1250, 1232, 1232, 1147, 1119, 1265, 1186, 1297, 1119, 1119,\n /*   270 */  1265, 1372, 1119, 1265, 1119, 1265, 1372, 1294, 1294, 1294,\n /*   280 */  1342, 1372, 1294, 1301, 1294, 1342, 1294, 1294, 1286, 1306,\n /*   290 */  1286, 1306, 1286, 1306, 1286, 1306, 1119, 1398, 1119, 1285,\n /*   300 */  1372, 1334, 1334, 1372, 1304, 1308, 1307, 1309, 1147, 1412,\n /*   310 */  1413, 1428, 1428, 1439, 1439, 1439, 1566, 1566, 1566, 1566,\n /*   320 */  1566, 1566, 1566, 1566,  204,  321,  429,  467,  578,  497,\n /*   330 */   904,  739, 1051,  793,  794,  798,  800,  802,  838,  768,\n /*   340 */   766,  801,  762,  847,  853,  812,  891,  681,  784,  896,\n /*   350 */   864,  996, 1457, 1459, 1441, 1322, 1450, 1385, 1451, 1445,\n /*   360 */  1446, 1350, 1340, 1361, 1352, 1453, 1353, 1461, 1478, 1357,\n /*   370 */  1351, 1430, 1431, 1432, 1433, 1370, 1391, 1454, 1367, 1489,\n /*   380 */  1486, 1470, 1386, 1355, 1429, 1471, 1434, 1424, 1458, 1393,\n /*   390 */  1479, 1482, 1485, 1394, 1400, 1487, 1442, 1488, 1490, 1484,\n /*   400 */  1491, 1448, 1483, 1493, 1452, 1480, 1496, 1497, 1498, 1499,\n /*   410 */  1406, 1494, 1500, 1502, 1501, 1404, 1505, 1506, 1435, 1503,\n /*   420 */  1508, 1408, 1507, 1504, 1509, 1510, 1511, 1507, 1513, 1516,\n /*   430 */  1517, 1515, 1519, 1521, 1534, 1523, 1525, 1524, 1526, 1527,\n /*   440 */  1529, 1530, 1526, 1532, 1531, 1533, 1535, 1537, 1427, 1438,\n /*   450 */  1440, 1443, 1538, 1542, 1562,\n};\n#define YY_REDUCE_USE_DFLT (-144)\n#define YY_REDUCE_COUNT (323)\n#define YY_REDUCE_MIN   (-143)\n#define YY_REDUCE_MAX   (1305)\nstatic const short yy_reduce_ofst[] = {\n /*     0 */  -143,  -65,  140,  840,   76,  180,  182,  233,  488,  -25,\n /*    10 */    12,   16,   59,  885,  907,  935,  390,  705,  954,  285,\n /*    20 */   997, 1017, 1018, -118, 1025,  139,  171,  171,  171,  171,\n /*    30 */   171,  171,  171,  171,  171,  171,  171,  171,  171,  171,\n /*    40 */   171,  171,  171,  171,  171,  171,  171,  171,  171,  171,\n /*    50 */   171,  171,  171,  171,  171,  171,  171,  171,  -69,  287,\n /*    60 */   441,  658,  708,  856, 1050, 1073, 1076, 1079, 1081, 1084,\n /*    70 */  1086, 1088, 1091, 1113, 1115, 1117, 1122, 1124, 1126, 1128,\n /*    80 */  1130, 1141, 1153, 1156, 1159, 1163, 1165, 1167, 1170, 1172,\n /*    90 */  1175, 1178, 1181, 1189, 1194, 1197, 1200, 1203, 1205, 1207,\n /*   100 */  1211, 1213, 1216, 1219,  171,  171,  171,  171,  171,  171,\n /*   110 */   171,  171,  171,   49,  176,  220,  275,  278,  290,  171,\n /*   120 */   300,  171,  171,  171,  171,  -85,  -85,  -85,  -28,   77,\n /*   130 */   313,  317,  -56,  252,  252,  446, -129,  243,  361,  403,\n /*   140 */   406,  513,  517,  409,  502,  518,  504,  509,  621,  553,\n /*   150 */   562,  619,  559,   93,  620,  465,  453,  550,  591,  571,\n /*   160 */   615,  666,  750,  752,  797,  819,  463,  548,  -73,   28,\n /*   170 */    68,  120,  257,  206,  359,  405,  413,  452,  457,  560,\n /*   180 */   566,  617,  670,  720,  723,  769,  773,  775,  780,  813,\n /*   190 */   814,  821,  822,  823,  826,  360,  436,  783,  829,  835,\n /*   200 */   707,  862,  867,  878,  830,  911,  915,  883,  936,  937,\n /*   210 */   940,  359,  942,  943,  944,  979,  982,  984,  886,  899,\n /*   220 */   928,  929,  931,  707,  947,  945,  998,  949,  932,  969,\n /*   230 */   918,  953,  924,  992, 1005, 1010, 1016,  971,  965, 1019,\n /*   240 */  1049, 1000, 1028, 1074,  989, 1078, 1080, 1026, 1031, 1109,\n /*   250 */  1053, 1090, 1103, 1092, 1099, 1114, 1118, 1148, 1151, 1111,\n /*   260 */  1096, 1129, 1131, 1133, 1162, 1202, 1138, 1146, 1231, 1234,\n /*   270 */  1206, 1218, 1237, 1239, 1240, 1242, 1221, 1228, 1229, 1230,\n /*   280 */  1224, 1233, 1235, 1236, 1241, 1226, 1243, 1244, 1198, 1201,\n /*   290 */  1209, 1212, 1210, 1214, 1215, 1217, 1260, 1199, 1262, 1220,\n /*   300 */  1247, 1222, 1223, 1253, 1238, 1245, 1251, 1246, 1249, 1276,\n /*   310 */  1279, 1289, 1291, 1296, 1302, 1305, 1225, 1227, 1248, 1290,\n /*   320 */  1292, 1280, 1281, 1295,\n};\nstatic const YYACTIONTYPE yy_default[] = {\n /*     0 */  1270, 1260, 1260, 1260, 1193, 1193, 1193, 1193, 1260, 1088,\n /*    10 */  1117, 1117, 1244, 1322, 1322, 1322, 1322, 1322, 1322, 1192,\n /*    20 */  1322, 1322, 1322, 1322, 1260, 1092, 1123, 1322, 1322, 1322,\n /*    30 */  1322, 1194, 1195, 1322, 1322, 1322, 1243, 1245, 1133, 1132,\n /*    40 */  1131, 1130, 1226, 1104, 1128, 1121, 1125, 1194, 1188, 1189,\n /*    50 */  1187, 1191, 1195, 1322, 1124, 1158, 1172, 1157, 1322, 1322,\n /*    60 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*    70 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*    80 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*    90 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   100 */  1322, 1322, 1322, 1322, 1166, 1171, 1178, 1170, 1167, 1160,\n /*   110 */  1159, 1161, 1162, 1322, 1011, 1059, 1322, 1322, 1322, 1163,\n /*   120 */  1322, 1164, 1175, 1174, 1173, 1251, 1278, 1277, 1322, 1322,\n /*   130 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   140 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   150 */  1322, 1322, 1322, 1322, 1322, 1270, 1260, 1017, 1017, 1322,\n /*   160 */  1260, 1260, 1260, 1260, 1260, 1260, 1256, 1092, 1083, 1322,\n /*   170 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   180 */  1248, 1246, 1322, 1208, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   190 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   200 */  1322, 1322, 1322, 1322, 1088, 1322, 1322, 1322, 1322, 1322,\n /*   210 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1272, 1322, 1221,\n /*   220 */  1088, 1088, 1088, 1090, 1072, 1082,  997, 1127, 1106, 1106,\n /*   230 */  1311, 1127, 1311, 1034, 1292, 1031, 1117, 1106, 1190, 1117,\n /*   240 */  1117, 1089, 1082, 1322, 1314, 1097, 1097, 1313, 1313, 1097,\n /*   250 */  1138, 1062, 1127, 1068, 1068, 1068, 1068, 1097, 1008, 1127,\n /*   260 */  1138, 1062, 1062, 1127, 1097, 1008, 1225, 1308, 1097, 1097,\n /*   270 */  1008, 1201, 1097, 1008, 1097, 1008, 1201, 1060, 1060, 1060,\n /*   280 */  1049, 1201, 1060, 1034, 1060, 1049, 1060, 1060, 1110, 1105,\n /*   290 */  1110, 1105, 1110, 1105, 1110, 1105, 1097, 1196, 1097, 1322,\n /*   300 */  1201, 1205, 1205, 1201, 1122, 1111, 1120, 1118, 1127, 1014,\n /*   310 */  1052, 1275, 1275, 1271, 1271, 1271, 1319, 1319, 1256, 1287,\n /*   320 */  1287, 1036, 1036, 1287, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   330 */  1282, 1322, 1210, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   340 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   350 */  1322, 1143, 1322,  993, 1253, 1322, 1322, 1252, 1322, 1322,\n /*   360 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   370 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1310, 1322,\n /*   380 */  1322, 1322, 1322, 1322, 1322, 1224, 1223, 1322, 1322, 1322,\n /*   390 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   400 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322,\n /*   410 */  1074, 1322, 1322, 1322, 1296, 1322, 1322, 1322, 1322, 1322,\n /*   420 */  1322, 1322, 1119, 1322, 1112, 1322, 1322, 1301, 1322, 1322,\n /*   430 */  1322, 1322, 1322, 1322, 1322, 1322, 1322, 1322, 1262, 1322,\n /*   440 */  1322, 1322, 1261, 1322, 1322, 1322, 1322, 1322, 1145, 1322,\n /*   450 */  1144, 1148, 1322, 1002, 1322,\n};\n/********** End of lemon-generated parsing tables *****************************/\n\n/* The next table maps tokens (terminal symbols) into fallback tokens.  \n** If a construct like the following:\n** \n**      %fallback ID X Y Z.\n**\n** appears in the grammar, then ID becomes a fallback token for X, Y,\n** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser\n** but it does not parse, the type of the token is changed to ID and\n** the parse is retried before an error is thrown.\n**\n** This feature can be used, for example, to cause some keywords in a language\n** to revert to identifiers if they keyword does not apply in the context where\n** it appears.\n*/\n#ifdef YYFALLBACK\nstatic const YYCODETYPE yyFallback[] = {\n    0,  /*          $ => nothing */\n    0,  /*       SEMI => nothing */\n   59,  /*    EXPLAIN => ID */\n   59,  /*      QUERY => ID */\n   59,  /*       PLAN => ID */\n   59,  /*      BEGIN => ID */\n    0,  /* TRANSACTION => nothing */\n   59,  /*   DEFERRED => ID */\n   59,  /*  IMMEDIATE => ID */\n   59,  /*  EXCLUSIVE => ID */\n    0,  /*     COMMIT => nothing */\n   59,  /*        END => ID */\n   59,  /*   ROLLBACK => ID */\n   59,  /*  SAVEPOINT => ID */\n   59,  /*    RELEASE => ID */\n    0,  /*         TO => nothing */\n    0,  /*      TABLE => nothing */\n    0,  /*     CREATE => nothing */\n   59,  /*         IF => ID */\n    0,  /*        NOT => nothing */\n    0,  /*     EXISTS => nothing */\n   59,  /*       TEMP => ID */\n    0,  /*         LP => nothing */\n    0,  /*         RP => nothing */\n    0,  /*         AS => nothing */\n   59,  /*    WITHOUT => ID */\n    0,  /*      COMMA => nothing */\n   59,  /*      ABORT => ID */\n   59,  /*     ACTION => ID */\n   59,  /*      AFTER => ID */\n   59,  /*    ANALYZE => ID */\n   59,  /*        ASC => ID */\n   59,  /*     ATTACH => ID */\n   59,  /*     BEFORE => ID */\n   59,  /*         BY => ID */\n   59,  /*    CASCADE => ID */\n   59,  /*       CAST => ID */\n   59,  /*   CONFLICT => ID */\n   59,  /*   DATABASE => ID */\n   59,  /*       DESC => ID */\n   59,  /*     DETACH => ID */\n   59,  /*       EACH => ID */\n   59,  /*       FAIL => ID */\n    0,  /*         OR => nothing */\n    0,  /*        AND => nothing */\n    0,  /*         IS => nothing */\n   59,  /*      MATCH => ID */\n   59,  /*    LIKE_KW => ID */\n    0,  /*    BETWEEN => nothing */\n    0,  /*         IN => nothing */\n    0,  /*     ISNULL => nothing */\n    0,  /*    NOTNULL => nothing */\n    0,  /*         NE => nothing */\n    0,  /*         EQ => nothing */\n    0,  /*         GT => nothing */\n    0,  /*         LE => nothing */\n    0,  /*         LT => nothing */\n    0,  /*         GE => nothing */\n    0,  /*     ESCAPE => nothing */\n    0,  /*         ID => nothing */\n   59,  /*   COLUMNKW => ID */\n   59,  /*        FOR => ID */\n   59,  /*     IGNORE => ID */\n   59,  /*  INITIALLY => ID */\n   59,  /*    INSTEAD => ID */\n   59,  /*         NO => ID */\n   59,  /*        KEY => ID */\n   59,  /*         OF => ID */\n   59,  /*     OFFSET => ID */\n   59,  /*     PRAGMA => ID */\n   59,  /*      RAISE => ID */\n   59,  /*  RECURSIVE => ID */\n   59,  /*    REPLACE => ID */\n   59,  /*   RESTRICT => ID */\n   59,  /*        ROW => ID */\n   59,  /*    TRIGGER => ID */\n   59,  /*     VACUUM => ID */\n   59,  /*       VIEW => ID */\n   59,  /*    VIRTUAL => ID */\n   59,  /*       WITH => ID */\n   59,  /*    REINDEX => ID */\n   59,  /*     RENAME => ID */\n   59,  /*   CTIME_KW => ID */\n};\n#endif /* YYFALLBACK */\n\n/* The following structure represents a single element of the\n** parser's stack.  Information stored includes:\n**\n**   +  The state number for the parser at this level of the stack.\n**\n**   +  The value of the token stored at this level of the stack.\n**      (In other words, the \"major\" token.)\n**\n**   +  The semantic value stored at this level of the stack.  This is\n**      the information used by the action routines in the grammar.\n**      It is sometimes called the \"minor\" token.\n**\n** After the \"shift\" half of a SHIFTREDUCE action, the stateno field\n** actually contains the reduce action for the second half of the\n** SHIFTREDUCE.\n*/\nstruct yyStackEntry {\n  YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */\n  YYCODETYPE major;      /* The major token value.  This is the code\n                         ** number for the token at this stack level */\n  YYMINORTYPE minor;     /* The user-supplied minor token value.  This\n                         ** is the value of the token  */\n};\ntypedef struct yyStackEntry yyStackEntry;\n\n/* The state of the parser is completely contained in an instance of\n** the following structure */\nstruct yyParser {\n  yyStackEntry *yytos;          /* Pointer to top element of the stack */\n#ifdef YYTRACKMAXSTACKDEPTH\n  int yyhwm;                    /* High-water mark of the stack */\n#endif\n#ifndef YYNOERRORRECOVERY\n  int yyerrcnt;                 /* Shifts left before out of the error */\n#endif\n  sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */\n#if YYSTACKDEPTH<=0\n  int yystksz;                  /* Current side of the stack */\n  yyStackEntry *yystack;        /* The parser's stack */\n  yyStackEntry yystk0;          /* First stack entry */\n#else\n  yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */\n  yyStackEntry *yystackEnd;            /* Last entry in the stack */\n#endif\n};\ntypedef struct yyParser yyParser;\n\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic FILE *yyTraceFILE = 0;\nstatic char *yyTracePrompt = 0;\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* \n** Turn parser tracing on by giving a stream to which to write the trace\n** and a prompt to preface each trace message.  Tracing is turned off\n** by making either argument NULL \n**\n** Inputs:\n** <ul>\n** <li> A FILE* to which trace output should be written.\n**      If NULL, then tracing is turned off.\n** <li> A prefix string written at the beginning of every\n**      line of trace output.  If NULL, then tracing is\n**      turned off.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3ParserTrace(FILE *TraceFILE, char *zTracePrompt){\n  yyTraceFILE = TraceFILE;\n  yyTracePrompt = zTracePrompt;\n  if( yyTraceFILE==0 ) yyTracePrompt = 0;\n  else if( yyTracePrompt==0 ) yyTraceFILE = 0;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing shifts, the names of all terminals and nonterminals\n** are required.  The following table supplies these names */\nstatic const char *const yyTokenName[] = { \n  \"$\",             \"SEMI\",          \"EXPLAIN\",       \"QUERY\",       \n  \"PLAN\",          \"BEGIN\",         \"TRANSACTION\",   \"DEFERRED\",    \n  \"IMMEDIATE\",     \"EXCLUSIVE\",     \"COMMIT\",        \"END\",         \n  \"ROLLBACK\",      \"SAVEPOINT\",     \"RELEASE\",       \"TO\",          \n  \"TABLE\",         \"CREATE\",        \"IF\",            \"NOT\",         \n  \"EXISTS\",        \"TEMP\",          \"LP\",            \"RP\",          \n  \"AS\",            \"WITHOUT\",       \"COMMA\",         \"ABORT\",       \n  \"ACTION\",        \"AFTER\",         \"ANALYZE\",       \"ASC\",         \n  \"ATTACH\",        \"BEFORE\",        \"BY\",            \"CASCADE\",     \n  \"CAST\",          \"CONFLICT\",      \"DATABASE\",      \"DESC\",        \n  \"DETACH\",        \"EACH\",          \"FAIL\",          \"OR\",          \n  \"AND\",           \"IS\",            \"MATCH\",         \"LIKE_KW\",     \n  \"BETWEEN\",       \"IN\",            \"ISNULL\",        \"NOTNULL\",     \n  \"NE\",            \"EQ\",            \"GT\",            \"LE\",          \n  \"LT\",            \"GE\",            \"ESCAPE\",        \"ID\",          \n  \"COLUMNKW\",      \"FOR\",           \"IGNORE\",        \"INITIALLY\",   \n  \"INSTEAD\",       \"NO\",            \"KEY\",           \"OF\",          \n  \"OFFSET\",        \"PRAGMA\",        \"RAISE\",         \"RECURSIVE\",   \n  \"REPLACE\",       \"RESTRICT\",      \"ROW\",           \"TRIGGER\",     \n  \"VACUUM\",        \"VIEW\",          \"VIRTUAL\",       \"WITH\",        \n  \"REINDEX\",       \"RENAME\",        \"CTIME_KW\",      \"ANY\",         \n  \"BITAND\",        \"BITOR\",         \"LSHIFT\",        \"RSHIFT\",      \n  \"PLUS\",          \"MINUS\",         \"STAR\",          \"SLASH\",       \n  \"REM\",           \"CONCAT\",        \"COLLATE\",       \"BITNOT\",      \n  \"INDEXED\",       \"STRING\",        \"JOIN_KW\",       \"CONSTRAINT\",  \n  \"DEFAULT\",       \"NULL\",          \"PRIMARY\",       \"UNIQUE\",      \n  \"CHECK\",         \"REFERENCES\",    \"AUTOINCR\",      \"ON\",          \n  \"INSERT\",        \"DELETE\",        \"UPDATE\",        \"SET\",         \n  \"DEFERRABLE\",    \"FOREIGN\",       \"DROP\",          \"UNION\",       \n  \"ALL\",           \"EXCEPT\",        \"INTERSECT\",     \"SELECT\",      \n  \"VALUES\",        \"DISTINCT\",      \"DOT\",           \"FROM\",        \n  \"JOIN\",          \"USING\",         \"ORDER\",         \"GROUP\",       \n  \"HAVING\",        \"LIMIT\",         \"WHERE\",         \"INTO\",        \n  \"FLOAT\",         \"BLOB\",          \"INTEGER\",       \"VARIABLE\",    \n  \"CASE\",          \"WHEN\",          \"THEN\",          \"ELSE\",        \n  \"INDEX\",         \"ALTER\",         \"ADD\",           \"error\",       \n  \"input\",         \"cmdlist\",       \"ecmd\",          \"explain\",     \n  \"cmdx\",          \"cmd\",           \"transtype\",     \"trans_opt\",   \n  \"nm\",            \"savepoint_opt\",  \"create_table\",  \"create_table_args\",\n  \"createkw\",      \"temp\",          \"ifnotexists\",   \"dbnm\",        \n  \"columnlist\",    \"conslist_opt\",  \"table_options\",  \"select\",      \n  \"columnname\",    \"carglist\",      \"typetoken\",     \"typename\",    \n  \"signed\",        \"plus_num\",      \"minus_num\",     \"ccons\",       \n  \"term\",          \"expr\",          \"onconf\",        \"sortorder\",   \n  \"autoinc\",       \"eidlist_opt\",   \"refargs\",       \"defer_subclause\",\n  \"refarg\",        \"refact\",        \"init_deferred_pred_opt\",  \"conslist\",    \n  \"tconscomma\",    \"tcons\",         \"sortlist\",      \"eidlist\",     \n  \"defer_subclause_opt\",  \"orconf\",        \"resolvetype\",   \"raisetype\",   \n  \"ifexists\",      \"fullname\",      \"selectnowith\",  \"oneselect\",   \n  \"with\",          \"multiselect_op\",  \"distinct\",      \"selcollist\",  \n  \"from\",          \"where_opt\",     \"groupby_opt\",   \"having_opt\",  \n  \"orderby_opt\",   \"limit_opt\",     \"values\",        \"nexprlist\",   \n  \"exprlist\",      \"sclp\",          \"as\",            \"seltablist\",  \n  \"stl_prefix\",    \"joinop\",        \"indexed_opt\",   \"on_opt\",      \n  \"using_opt\",     \"idlist\",        \"setlist\",       \"insert_cmd\",  \n  \"idlist_opt\",    \"likeop\",        \"between_op\",    \"in_op\",       \n  \"paren_exprlist\",  \"case_operand\",  \"case_exprlist\",  \"case_else\",   \n  \"uniqueflag\",    \"collate\",       \"nmnum\",         \"trigger_decl\",\n  \"trigger_cmd_list\",  \"trigger_time\",  \"trigger_event\",  \"foreach_clause\",\n  \"when_clause\",   \"trigger_cmd\",   \"trnm\",          \"tridxby\",     \n  \"database_kw_opt\",  \"key_opt\",       \"add_column_fullname\",  \"kwcolumn_opt\",\n  \"create_vtab\",   \"vtabarglist\",   \"vtabarg\",       \"vtabargtoken\",\n  \"lp\",            \"anylist\",       \"wqlist\",      \n};\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing reduce actions, the names of all rules are required.\n*/\nstatic const char *const yyRuleName[] = {\n /*   0 */ \"explain ::= EXPLAIN\",\n /*   1 */ \"explain ::= EXPLAIN QUERY PLAN\",\n /*   2 */ \"cmdx ::= cmd\",\n /*   3 */ \"cmd ::= BEGIN transtype trans_opt\",\n /*   4 */ \"transtype ::=\",\n /*   5 */ \"transtype ::= DEFERRED\",\n /*   6 */ \"transtype ::= IMMEDIATE\",\n /*   7 */ \"transtype ::= EXCLUSIVE\",\n /*   8 */ \"cmd ::= COMMIT|END trans_opt\",\n /*   9 */ \"cmd ::= ROLLBACK trans_opt\",\n /*  10 */ \"cmd ::= SAVEPOINT nm\",\n /*  11 */ \"cmd ::= RELEASE savepoint_opt nm\",\n /*  12 */ \"cmd ::= ROLLBACK trans_opt TO savepoint_opt nm\",\n /*  13 */ \"create_table ::= createkw temp TABLE ifnotexists nm dbnm\",\n /*  14 */ \"createkw ::= CREATE\",\n /*  15 */ \"ifnotexists ::=\",\n /*  16 */ \"ifnotexists ::= IF NOT EXISTS\",\n /*  17 */ \"temp ::= TEMP\",\n /*  18 */ \"temp ::=\",\n /*  19 */ \"create_table_args ::= LP columnlist conslist_opt RP table_options\",\n /*  20 */ \"create_table_args ::= AS select\",\n /*  21 */ \"table_options ::=\",\n /*  22 */ \"table_options ::= WITHOUT nm\",\n /*  23 */ \"columnname ::= nm typetoken\",\n /*  24 */ \"typetoken ::=\",\n /*  25 */ \"typetoken ::= typename LP signed RP\",\n /*  26 */ \"typetoken ::= typename LP signed COMMA signed RP\",\n /*  27 */ \"typename ::= typename ID|STRING\",\n /*  28 */ \"ccons ::= CONSTRAINT nm\",\n /*  29 */ \"ccons ::= DEFAULT term\",\n /*  30 */ \"ccons ::= DEFAULT LP expr RP\",\n /*  31 */ \"ccons ::= DEFAULT PLUS term\",\n /*  32 */ \"ccons ::= DEFAULT MINUS term\",\n /*  33 */ \"ccons ::= DEFAULT ID|INDEXED\",\n /*  34 */ \"ccons ::= NOT NULL onconf\",\n /*  35 */ \"ccons ::= PRIMARY KEY sortorder onconf autoinc\",\n /*  36 */ \"ccons ::= UNIQUE onconf\",\n /*  37 */ \"ccons ::= CHECK LP expr RP\",\n /*  38 */ \"ccons ::= REFERENCES nm eidlist_opt refargs\",\n /*  39 */ \"ccons ::= defer_subclause\",\n /*  40 */ \"ccons ::= COLLATE ID|STRING\",\n /*  41 */ \"autoinc ::=\",\n /*  42 */ \"autoinc ::= AUTOINCR\",\n /*  43 */ \"refargs ::=\",\n /*  44 */ \"refargs ::= refargs refarg\",\n /*  45 */ \"refarg ::= MATCH nm\",\n /*  46 */ \"refarg ::= ON INSERT refact\",\n /*  47 */ \"refarg ::= ON DELETE refact\",\n /*  48 */ \"refarg ::= ON UPDATE refact\",\n /*  49 */ \"refact ::= SET NULL\",\n /*  50 */ \"refact ::= SET DEFAULT\",\n /*  51 */ \"refact ::= CASCADE\",\n /*  52 */ \"refact ::= RESTRICT\",\n /*  53 */ \"refact ::= NO ACTION\",\n /*  54 */ \"defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt\",\n /*  55 */ \"defer_subclause ::= DEFERRABLE init_deferred_pred_opt\",\n /*  56 */ \"init_deferred_pred_opt ::=\",\n /*  57 */ \"init_deferred_pred_opt ::= INITIALLY DEFERRED\",\n /*  58 */ \"init_deferred_pred_opt ::= INITIALLY IMMEDIATE\",\n /*  59 */ \"conslist_opt ::=\",\n /*  60 */ \"tconscomma ::= COMMA\",\n /*  61 */ \"tcons ::= CONSTRAINT nm\",\n /*  62 */ \"tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf\",\n /*  63 */ \"tcons ::= UNIQUE LP sortlist RP onconf\",\n /*  64 */ \"tcons ::= CHECK LP expr RP onconf\",\n /*  65 */ \"tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt\",\n /*  66 */ \"defer_subclause_opt ::=\",\n /*  67 */ \"onconf ::=\",\n /*  68 */ \"onconf ::= ON CONFLICT resolvetype\",\n /*  69 */ \"orconf ::=\",\n /*  70 */ \"orconf ::= OR resolvetype\",\n /*  71 */ \"resolvetype ::= IGNORE\",\n /*  72 */ \"resolvetype ::= REPLACE\",\n /*  73 */ \"cmd ::= DROP TABLE ifexists fullname\",\n /*  74 */ \"ifexists ::= IF EXISTS\",\n /*  75 */ \"ifexists ::=\",\n /*  76 */ \"cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select\",\n /*  77 */ \"cmd ::= DROP VIEW ifexists fullname\",\n /*  78 */ \"cmd ::= select\",\n /*  79 */ \"select ::= with selectnowith\",\n /*  80 */ \"selectnowith ::= selectnowith multiselect_op oneselect\",\n /*  81 */ \"multiselect_op ::= UNION\",\n /*  82 */ \"multiselect_op ::= UNION ALL\",\n /*  83 */ \"multiselect_op ::= EXCEPT|INTERSECT\",\n /*  84 */ \"oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt\",\n /*  85 */ \"values ::= VALUES LP nexprlist RP\",\n /*  86 */ \"values ::= values COMMA LP exprlist RP\",\n /*  87 */ \"distinct ::= DISTINCT\",\n /*  88 */ \"distinct ::= ALL\",\n /*  89 */ \"distinct ::=\",\n /*  90 */ \"sclp ::=\",\n /*  91 */ \"selcollist ::= sclp expr as\",\n /*  92 */ \"selcollist ::= sclp STAR\",\n /*  93 */ \"selcollist ::= sclp nm DOT STAR\",\n /*  94 */ \"as ::= AS nm\",\n /*  95 */ \"as ::=\",\n /*  96 */ \"from ::=\",\n /*  97 */ \"from ::= FROM seltablist\",\n /*  98 */ \"stl_prefix ::= seltablist joinop\",\n /*  99 */ \"stl_prefix ::=\",\n /* 100 */ \"seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt\",\n /* 101 */ \"seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt\",\n /* 102 */ \"seltablist ::= stl_prefix LP select RP as on_opt using_opt\",\n /* 103 */ \"seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt\",\n /* 104 */ \"dbnm ::=\",\n /* 105 */ \"dbnm ::= DOT nm\",\n /* 106 */ \"fullname ::= nm dbnm\",\n /* 107 */ \"joinop ::= COMMA|JOIN\",\n /* 108 */ \"joinop ::= JOIN_KW JOIN\",\n /* 109 */ \"joinop ::= JOIN_KW nm JOIN\",\n /* 110 */ \"joinop ::= JOIN_KW nm nm JOIN\",\n /* 111 */ \"on_opt ::= ON expr\",\n /* 112 */ \"on_opt ::=\",\n /* 113 */ \"indexed_opt ::=\",\n /* 114 */ \"indexed_opt ::= INDEXED BY nm\",\n /* 115 */ \"indexed_opt ::= NOT INDEXED\",\n /* 116 */ \"using_opt ::= USING LP idlist RP\",\n /* 117 */ \"using_opt ::=\",\n /* 118 */ \"orderby_opt ::=\",\n /* 119 */ \"orderby_opt ::= ORDER BY sortlist\",\n /* 120 */ \"sortlist ::= sortlist COMMA expr sortorder\",\n /* 121 */ \"sortlist ::= expr sortorder\",\n /* 122 */ \"sortorder ::= ASC\",\n /* 123 */ \"sortorder ::= DESC\",\n /* 124 */ \"sortorder ::=\",\n /* 125 */ \"groupby_opt ::=\",\n /* 126 */ \"groupby_opt ::= GROUP BY nexprlist\",\n /* 127 */ \"having_opt ::=\",\n /* 128 */ \"having_opt ::= HAVING expr\",\n /* 129 */ \"limit_opt ::=\",\n /* 130 */ \"limit_opt ::= LIMIT expr\",\n /* 131 */ \"limit_opt ::= LIMIT expr OFFSET expr\",\n /* 132 */ \"limit_opt ::= LIMIT expr COMMA expr\",\n /* 133 */ \"cmd ::= with DELETE FROM fullname indexed_opt where_opt\",\n /* 134 */ \"where_opt ::=\",\n /* 135 */ \"where_opt ::= WHERE expr\",\n /* 136 */ \"cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt\",\n /* 137 */ \"setlist ::= setlist COMMA nm EQ expr\",\n /* 138 */ \"setlist ::= setlist COMMA LP idlist RP EQ expr\",\n /* 139 */ \"setlist ::= nm EQ expr\",\n /* 140 */ \"setlist ::= LP idlist RP EQ expr\",\n /* 141 */ \"cmd ::= with insert_cmd INTO fullname idlist_opt select\",\n /* 142 */ \"cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES\",\n /* 143 */ \"insert_cmd ::= INSERT orconf\",\n /* 144 */ \"insert_cmd ::= REPLACE\",\n /* 145 */ \"idlist_opt ::=\",\n /* 146 */ \"idlist_opt ::= LP idlist RP\",\n /* 147 */ \"idlist ::= idlist COMMA nm\",\n /* 148 */ \"idlist ::= nm\",\n /* 149 */ \"expr ::= LP expr RP\",\n /* 150 */ \"expr ::= ID|INDEXED\",\n /* 151 */ \"expr ::= JOIN_KW\",\n /* 152 */ \"expr ::= nm DOT nm\",\n /* 153 */ \"expr ::= nm DOT nm DOT nm\",\n /* 154 */ \"term ::= NULL|FLOAT|BLOB\",\n /* 155 */ \"term ::= STRING\",\n /* 156 */ \"term ::= INTEGER\",\n /* 157 */ \"expr ::= VARIABLE\",\n /* 158 */ \"expr ::= expr COLLATE ID|STRING\",\n /* 159 */ \"expr ::= CAST LP expr AS typetoken RP\",\n /* 160 */ \"expr ::= ID|INDEXED LP distinct exprlist RP\",\n /* 161 */ \"expr ::= ID|INDEXED LP STAR RP\",\n /* 162 */ \"term ::= CTIME_KW\",\n /* 163 */ \"expr ::= LP nexprlist COMMA expr RP\",\n /* 164 */ \"expr ::= expr AND expr\",\n /* 165 */ \"expr ::= expr OR expr\",\n /* 166 */ \"expr ::= expr LT|GT|GE|LE expr\",\n /* 167 */ \"expr ::= expr EQ|NE expr\",\n /* 168 */ \"expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr\",\n /* 169 */ \"expr ::= expr PLUS|MINUS expr\",\n /* 170 */ \"expr ::= expr STAR|SLASH|REM expr\",\n /* 171 */ \"expr ::= expr CONCAT expr\",\n /* 172 */ \"likeop ::= NOT LIKE_KW|MATCH\",\n /* 173 */ \"expr ::= expr likeop expr\",\n /* 174 */ \"expr ::= expr likeop expr ESCAPE expr\",\n /* 175 */ \"expr ::= expr ISNULL|NOTNULL\",\n /* 176 */ \"expr ::= expr NOT NULL\",\n /* 177 */ \"expr ::= expr IS expr\",\n /* 178 */ \"expr ::= expr IS NOT expr\",\n /* 179 */ \"expr ::= NOT expr\",\n /* 180 */ \"expr ::= BITNOT expr\",\n /* 181 */ \"expr ::= MINUS expr\",\n /* 182 */ \"expr ::= PLUS expr\",\n /* 183 */ \"between_op ::= BETWEEN\",\n /* 184 */ \"between_op ::= NOT BETWEEN\",\n /* 185 */ \"expr ::= expr between_op expr AND expr\",\n /* 186 */ \"in_op ::= IN\",\n /* 187 */ \"in_op ::= NOT IN\",\n /* 188 */ \"expr ::= expr in_op LP exprlist RP\",\n /* 189 */ \"expr ::= LP select RP\",\n /* 190 */ \"expr ::= expr in_op LP select RP\",\n /* 191 */ \"expr ::= expr in_op nm dbnm paren_exprlist\",\n /* 192 */ \"expr ::= EXISTS LP select RP\",\n /* 193 */ \"expr ::= CASE case_operand case_exprlist case_else END\",\n /* 194 */ \"case_exprlist ::= case_exprlist WHEN expr THEN expr\",\n /* 195 */ \"case_exprlist ::= WHEN expr THEN expr\",\n /* 196 */ \"case_else ::= ELSE expr\",\n /* 197 */ \"case_else ::=\",\n /* 198 */ \"case_operand ::= expr\",\n /* 199 */ \"case_operand ::=\",\n /* 200 */ \"exprlist ::=\",\n /* 201 */ \"nexprlist ::= nexprlist COMMA expr\",\n /* 202 */ \"nexprlist ::= expr\",\n /* 203 */ \"paren_exprlist ::=\",\n /* 204 */ \"paren_exprlist ::= LP exprlist RP\",\n /* 205 */ \"cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt\",\n /* 206 */ \"uniqueflag ::= UNIQUE\",\n /* 207 */ \"uniqueflag ::=\",\n /* 208 */ \"eidlist_opt ::=\",\n /* 209 */ \"eidlist_opt ::= LP eidlist RP\",\n /* 210 */ \"eidlist ::= eidlist COMMA nm collate sortorder\",\n /* 211 */ \"eidlist ::= nm collate sortorder\",\n /* 212 */ \"collate ::=\",\n /* 213 */ \"collate ::= COLLATE ID|STRING\",\n /* 214 */ \"cmd ::= DROP INDEX ifexists fullname\",\n /* 215 */ \"cmd ::= VACUUM\",\n /* 216 */ \"cmd ::= VACUUM nm\",\n /* 217 */ \"cmd ::= PRAGMA nm dbnm\",\n /* 218 */ \"cmd ::= PRAGMA nm dbnm EQ nmnum\",\n /* 219 */ \"cmd ::= PRAGMA nm dbnm LP nmnum RP\",\n /* 220 */ \"cmd ::= PRAGMA nm dbnm EQ minus_num\",\n /* 221 */ \"cmd ::= PRAGMA nm dbnm LP minus_num RP\",\n /* 222 */ \"plus_num ::= PLUS INTEGER|FLOAT\",\n /* 223 */ \"minus_num ::= MINUS INTEGER|FLOAT\",\n /* 224 */ \"cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END\",\n /* 225 */ \"trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause\",\n /* 226 */ \"trigger_time ::= BEFORE|AFTER\",\n /* 227 */ \"trigger_time ::= INSTEAD OF\",\n /* 228 */ \"trigger_time ::=\",\n /* 229 */ \"trigger_event ::= DELETE|INSERT\",\n /* 230 */ \"trigger_event ::= UPDATE\",\n /* 231 */ \"trigger_event ::= UPDATE OF idlist\",\n /* 232 */ \"when_clause ::=\",\n /* 233 */ \"when_clause ::= WHEN expr\",\n /* 234 */ \"trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI\",\n /* 235 */ \"trigger_cmd_list ::= trigger_cmd SEMI\",\n /* 236 */ \"trnm ::= nm DOT nm\",\n /* 237 */ \"tridxby ::= INDEXED BY nm\",\n /* 238 */ \"tridxby ::= NOT INDEXED\",\n /* 239 */ \"trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt\",\n /* 240 */ \"trigger_cmd ::= insert_cmd INTO trnm idlist_opt select\",\n /* 241 */ \"trigger_cmd ::= DELETE FROM trnm tridxby where_opt\",\n /* 242 */ \"trigger_cmd ::= select\",\n /* 243 */ \"expr ::= RAISE LP IGNORE RP\",\n /* 244 */ \"expr ::= RAISE LP raisetype COMMA nm RP\",\n /* 245 */ \"raisetype ::= ROLLBACK\",\n /* 246 */ \"raisetype ::= ABORT\",\n /* 247 */ \"raisetype ::= FAIL\",\n /* 248 */ \"cmd ::= DROP TRIGGER ifexists fullname\",\n /* 249 */ \"cmd ::= ATTACH database_kw_opt expr AS expr key_opt\",\n /* 250 */ \"cmd ::= DETACH database_kw_opt expr\",\n /* 251 */ \"key_opt ::=\",\n /* 252 */ \"key_opt ::= KEY expr\",\n /* 253 */ \"cmd ::= REINDEX\",\n /* 254 */ \"cmd ::= REINDEX nm dbnm\",\n /* 255 */ \"cmd ::= ANALYZE\",\n /* 256 */ \"cmd ::= ANALYZE nm dbnm\",\n /* 257 */ \"cmd ::= ALTER TABLE fullname RENAME TO nm\",\n /* 258 */ \"cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist\",\n /* 259 */ \"add_column_fullname ::= fullname\",\n /* 260 */ \"cmd ::= create_vtab\",\n /* 261 */ \"cmd ::= create_vtab LP vtabarglist RP\",\n /* 262 */ \"create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm\",\n /* 263 */ \"vtabarg ::=\",\n /* 264 */ \"vtabargtoken ::= ANY\",\n /* 265 */ \"vtabargtoken ::= lp anylist RP\",\n /* 266 */ \"lp ::= LP\",\n /* 267 */ \"with ::=\",\n /* 268 */ \"with ::= WITH wqlist\",\n /* 269 */ \"with ::= WITH RECURSIVE wqlist\",\n /* 270 */ \"wqlist ::= nm eidlist_opt AS LP select RP\",\n /* 271 */ \"wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP\",\n /* 272 */ \"input ::= cmdlist\",\n /* 273 */ \"cmdlist ::= cmdlist ecmd\",\n /* 274 */ \"cmdlist ::= ecmd\",\n /* 275 */ \"ecmd ::= SEMI\",\n /* 276 */ \"ecmd ::= explain cmdx SEMI\",\n /* 277 */ \"explain ::=\",\n /* 278 */ \"trans_opt ::=\",\n /* 279 */ \"trans_opt ::= TRANSACTION\",\n /* 280 */ \"trans_opt ::= TRANSACTION nm\",\n /* 281 */ \"savepoint_opt ::= SAVEPOINT\",\n /* 282 */ \"savepoint_opt ::=\",\n /* 283 */ \"cmd ::= create_table create_table_args\",\n /* 284 */ \"columnlist ::= columnlist COMMA columnname carglist\",\n /* 285 */ \"columnlist ::= columnname carglist\",\n /* 286 */ \"nm ::= ID|INDEXED\",\n /* 287 */ \"nm ::= STRING\",\n /* 288 */ \"nm ::= JOIN_KW\",\n /* 289 */ \"typetoken ::= typename\",\n /* 290 */ \"typename ::= ID|STRING\",\n /* 291 */ \"signed ::= plus_num\",\n /* 292 */ \"signed ::= minus_num\",\n /* 293 */ \"carglist ::= carglist ccons\",\n /* 294 */ \"carglist ::=\",\n /* 295 */ \"ccons ::= NULL onconf\",\n /* 296 */ \"conslist_opt ::= COMMA conslist\",\n /* 297 */ \"conslist ::= conslist tconscomma tcons\",\n /* 298 */ \"conslist ::= tcons\",\n /* 299 */ \"tconscomma ::=\",\n /* 300 */ \"defer_subclause_opt ::= defer_subclause\",\n /* 301 */ \"resolvetype ::= raisetype\",\n /* 302 */ \"selectnowith ::= oneselect\",\n /* 303 */ \"oneselect ::= values\",\n /* 304 */ \"sclp ::= selcollist COMMA\",\n /* 305 */ \"as ::= ID|STRING\",\n /* 306 */ \"expr ::= term\",\n /* 307 */ \"likeop ::= LIKE_KW|MATCH\",\n /* 308 */ \"exprlist ::= nexprlist\",\n /* 309 */ \"nmnum ::= plus_num\",\n /* 310 */ \"nmnum ::= nm\",\n /* 311 */ \"nmnum ::= ON\",\n /* 312 */ \"nmnum ::= DELETE\",\n /* 313 */ \"nmnum ::= DEFAULT\",\n /* 314 */ \"plus_num ::= INTEGER|FLOAT\",\n /* 315 */ \"foreach_clause ::=\",\n /* 316 */ \"foreach_clause ::= FOR EACH ROW\",\n /* 317 */ \"trnm ::= nm\",\n /* 318 */ \"tridxby ::=\",\n /* 319 */ \"database_kw_opt ::= DATABASE\",\n /* 320 */ \"database_kw_opt ::=\",\n /* 321 */ \"kwcolumn_opt ::=\",\n /* 322 */ \"kwcolumn_opt ::= COLUMNKW\",\n /* 323 */ \"vtabarglist ::= vtabarg\",\n /* 324 */ \"vtabarglist ::= vtabarglist COMMA vtabarg\",\n /* 325 */ \"vtabarg ::= vtabarg vtabargtoken\",\n /* 326 */ \"anylist ::=\",\n /* 327 */ \"anylist ::= anylist LP anylist RP\",\n /* 328 */ \"anylist ::= anylist ANY\",\n};\n#endif /* NDEBUG */\n\n\n#if YYSTACKDEPTH<=0\n/*\n** Try to increase the size of the parser stack.  Return the number\n** of errors.  Return 0 on success.\n*/\nstatic int yyGrowStack(yyParser *p){\n  int newSize;\n  int idx;\n  yyStackEntry *pNew;\n\n  newSize = p->yystksz*2 + 100;\n  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;\n  if( p->yystack==&p->yystk0 ){\n    pNew = malloc(newSize*sizeof(pNew[0]));\n    if( pNew ) pNew[0] = p->yystk0;\n  }else{\n    pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));\n  }\n  if( pNew ){\n    p->yystack = pNew;\n    p->yytos = &p->yystack[idx];\n#ifndef NDEBUG\n    if( yyTraceFILE ){\n      fprintf(yyTraceFILE,\"%sStack grows from %d to %d entries.\\n\",\n              yyTracePrompt, p->yystksz, newSize);\n    }\n#endif\n    p->yystksz = newSize;\n  }\n  return pNew==0; \n}\n#endif\n\n/* Datatype of the argument to the memory allocated passed as the\n** second argument to sqlite3ParserAlloc() below.  This can be changed by\n** putting an appropriate #define in the %include section of the input\n** grammar.\n*/\n#ifndef YYMALLOCARGTYPE\n# define YYMALLOCARGTYPE size_t\n#endif\n\n/* Initialize a new parser that has already been allocated.\n*/\nSQLITE_PRIVATE void sqlite3ParserInit(void *yypParser){\n  yyParser *pParser = (yyParser*)yypParser;\n#ifdef YYTRACKMAXSTACKDEPTH\n  pParser->yyhwm = 0;\n#endif\n#if YYSTACKDEPTH<=0\n  pParser->yytos = NULL;\n  pParser->yystack = NULL;\n  pParser->yystksz = 0;\n  if( yyGrowStack(pParser) ){\n    pParser->yystack = &pParser->yystk0;\n    pParser->yystksz = 1;\n  }\n#endif\n#ifndef YYNOERRORRECOVERY\n  pParser->yyerrcnt = -1;\n#endif\n  pParser->yytos = pParser->yystack;\n  pParser->yystack[0].stateno = 0;\n  pParser->yystack[0].major = 0;\n#if YYSTACKDEPTH>0\n  pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];\n#endif\n}\n\n#ifndef sqlite3Parser_ENGINEALWAYSONSTACK\n/* \n** This function allocates a new parser.\n** The only argument is a pointer to a function which works like\n** malloc.\n**\n** Inputs:\n** A pointer to the function used to allocate memory.\n**\n** Outputs:\n** A pointer to a parser.  This pointer is used in subsequent calls\n** to sqlite3Parser and sqlite3ParserFree.\n*/\nSQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){\n  yyParser *pParser;\n  pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );\n  if( pParser ) sqlite3ParserInit(pParser);\n  return pParser;\n}\n#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */\n\n\n/* The following function deletes the \"minor type\" or semantic value\n** associated with a symbol.  The symbol can be either a terminal\n** or nonterminal. \"yymajor\" is the symbol code, and \"yypminor\" is\n** a pointer to the value to be deleted.  The code used to do the \n** deletions is derived from the %destructor and/or %token_destructor\n** directives of the input grammar.\n*/\nstatic void yy_destructor(\n  yyParser *yypParser,    /* The parser */\n  YYCODETYPE yymajor,     /* Type code for object to destroy */\n  YYMINORTYPE *yypminor   /* The object to be destroyed */\n){\n  sqlite3ParserARG_FETCH;\n  switch( yymajor ){\n    /* Here is inserted the actions which take place when a\n    ** terminal or non-terminal is destroyed.  This can happen\n    ** when the symbol is popped from the stack during a\n    ** reduce or during error processing or when a parser is \n    ** being destroyed before it is finished parsing.\n    **\n    ** Note: during a reduce, the only symbols destroyed are those\n    ** which appear on the RHS of the rule, but which are *not* used\n    ** inside the C code.\n    */\n/********* Begin destructor definitions ***************************************/\n    case 163: /* select */\n    case 194: /* selectnowith */\n    case 195: /* oneselect */\n    case 206: /* values */\n{\nsqlite3SelectDelete(pParse->db, (yypminor->yy243));\n}\n      break;\n    case 172: /* term */\n    case 173: /* expr */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr);\n}\n      break;\n    case 177: /* eidlist_opt */\n    case 186: /* sortlist */\n    case 187: /* eidlist */\n    case 199: /* selcollist */\n    case 202: /* groupby_opt */\n    case 204: /* orderby_opt */\n    case 207: /* nexprlist */\n    case 208: /* exprlist */\n    case 209: /* sclp */\n    case 218: /* setlist */\n    case 224: /* paren_exprlist */\n    case 226: /* case_exprlist */\n{\nsqlite3ExprListDelete(pParse->db, (yypminor->yy148));\n}\n      break;\n    case 193: /* fullname */\n    case 200: /* from */\n    case 211: /* seltablist */\n    case 212: /* stl_prefix */\n{\nsqlite3SrcListDelete(pParse->db, (yypminor->yy185));\n}\n      break;\n    case 196: /* with */\n    case 250: /* wqlist */\n{\nsqlite3WithDelete(pParse->db, (yypminor->yy285));\n}\n      break;\n    case 201: /* where_opt */\n    case 203: /* having_opt */\n    case 215: /* on_opt */\n    case 225: /* case_operand */\n    case 227: /* case_else */\n    case 236: /* when_clause */\n    case 241: /* key_opt */\n{\nsqlite3ExprDelete(pParse->db, (yypminor->yy72));\n}\n      break;\n    case 216: /* using_opt */\n    case 217: /* idlist */\n    case 220: /* idlist_opt */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy254));\n}\n      break;\n    case 232: /* trigger_cmd_list */\n    case 237: /* trigger_cmd */\n{\nsqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145));\n}\n      break;\n    case 234: /* trigger_event */\n{\nsqlite3IdListDelete(pParse->db, (yypminor->yy332).b);\n}\n      break;\n/********* End destructor definitions *****************************************/\n    default:  break;   /* If no destructor action specified: do nothing */\n  }\n}\n\n/*\n** Pop the parser's stack once.\n**\n** If there is a destructor routine associated with the token which\n** is popped from the stack, then call it.\n*/\nstatic void yy_pop_parser_stack(yyParser *pParser){\n  yyStackEntry *yytos;\n  assert( pParser->yytos!=0 );\n  assert( pParser->yytos > pParser->yystack );\n  yytos = pParser->yytos--;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sPopping %s\\n\",\n      yyTracePrompt,\n      yyTokenName[yytos->major]);\n  }\n#endif\n  yy_destructor(pParser, yytos->major, &yytos->minor);\n}\n\n/*\n** Clear all secondary memory allocations from the parser\n*/\nSQLITE_PRIVATE void sqlite3ParserFinalize(void *p){\n  yyParser *pParser = (yyParser*)p;\n  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);\n#if YYSTACKDEPTH<=0\n  if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack);\n#endif\n}\n\n#ifndef sqlite3Parser_ENGINEALWAYSONSTACK\n/* \n** Deallocate and destroy a parser.  Destructors are called for\n** all stack elements before shutting the parser down.\n**\n** If the YYPARSEFREENEVERNULL macro exists (for example because it\n** is defined in a %include section of the input grammar) then it is\n** assumed that the input pointer is never NULL.\n*/\nSQLITE_PRIVATE void sqlite3ParserFree(\n  void *p,                    /* The parser to be deleted */\n  void (*freeProc)(void*)     /* Function used to reclaim memory */\n){\n#ifndef YYPARSEFREENEVERNULL\n  if( p==0 ) return;\n#endif\n  sqlite3ParserFinalize(p);\n  (*freeProc)(p);\n}\n#endif /* sqlite3Parser_ENGINEALWAYSONSTACK */\n\n/*\n** Return the peak depth of the stack for a parser.\n*/\n#ifdef YYTRACKMAXSTACKDEPTH\nSQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){\n  yyParser *pParser = (yyParser*)p;\n  return pParser->yyhwm;\n}\n#endif\n\n/*\n** Find the appropriate action for a parser given the terminal\n** look-ahead token iLookAhead.\n*/\nstatic unsigned int yy_find_shift_action(\n  yyParser *pParser,        /* The parser */\n  YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n  int stateno = pParser->yytos->stateno;\n \n  if( stateno>=YY_MIN_REDUCE ) return stateno;\n  assert( stateno <= YY_SHIFT_COUNT );\n  do{\n    i = yy_shift_ofst[stateno];\n    assert( iLookAhead!=YYNOCODE );\n    i += iLookAhead;\n    if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){\n#ifdef YYFALLBACK\n      YYCODETYPE iFallback;            /* Fallback token */\n      if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])\n             && (iFallback = yyFallback[iLookAhead])!=0 ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE, \"%sFALLBACK %s => %s\\n\",\n             yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]);\n        }\n#endif\n        assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */\n        iLookAhead = iFallback;\n        continue;\n      }\n#endif\n#ifdef YYWILDCARD\n      {\n        int j = i - iLookAhead + YYWILDCARD;\n        if( \n#if YY_SHIFT_MIN+YYWILDCARD<0\n          j>=0 &&\n#endif\n#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT\n          j<YY_ACTTAB_COUNT &&\n#endif\n          yy_lookahead[j]==YYWILDCARD && iLookAhead>0\n        ){\n#ifndef NDEBUG\n          if( yyTraceFILE ){\n            fprintf(yyTraceFILE, \"%sWILDCARD %s => %s\\n\",\n               yyTracePrompt, yyTokenName[iLookAhead],\n               yyTokenName[YYWILDCARD]);\n          }\n#endif /* NDEBUG */\n          return yy_action[j];\n        }\n      }\n#endif /* YYWILDCARD */\n      return yy_default[stateno];\n    }else{\n      return yy_action[i];\n    }\n  }while(1);\n}\n\n/*\n** Find the appropriate action for a parser given the non-terminal\n** look-ahead token iLookAhead.\n*/\nstatic int yy_find_reduce_action(\n  int stateno,              /* Current state number */\n  YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n#ifdef YYERRORSYMBOL\n  if( stateno>YY_REDUCE_COUNT ){\n    return yy_default[stateno];\n  }\n#else\n  assert( stateno<=YY_REDUCE_COUNT );\n#endif\n  i = yy_reduce_ofst[stateno];\n  assert( i!=YY_REDUCE_USE_DFLT );\n  assert( iLookAhead!=YYNOCODE );\n  i += iLookAhead;\n#ifdef YYERRORSYMBOL\n  if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){\n    return yy_default[stateno];\n  }\n#else\n  assert( i>=0 && i<YY_ACTTAB_COUNT );\n  assert( yy_lookahead[i]==iLookAhead );\n#endif\n  return yy_action[i];\n}\n\n/*\n** The following routine is called if the stack overflows.\n*/\nstatic void yyStackOverflow(yyParser *yypParser){\n   sqlite3ParserARG_FETCH;\n#ifndef NDEBUG\n   if( yyTraceFILE ){\n     fprintf(yyTraceFILE,\"%sStack Overflow!\\n\",yyTracePrompt);\n   }\n#endif\n   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);\n   /* Here code is inserted which will execute if the parser\n   ** stack every overflows */\n/******** Begin %stack_overflow code ******************************************/\n\n  sqlite3ErrorMsg(pParse, \"parser stack overflow\");\n/******** End %stack_overflow code ********************************************/\n   sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */\n}\n\n/*\n** Print tracing information for a SHIFT action\n*/\n#ifndef NDEBUG\nstatic void yyTraceShift(yyParser *yypParser, int yyNewState){\n  if( yyTraceFILE ){\n    if( yyNewState<YYNSTATE ){\n      fprintf(yyTraceFILE,\"%sShift '%s', go to state %d\\n\",\n         yyTracePrompt,yyTokenName[yypParser->yytos->major],\n         yyNewState);\n    }else{\n      fprintf(yyTraceFILE,\"%sShift '%s'\\n\",\n         yyTracePrompt,yyTokenName[yypParser->yytos->major]);\n    }\n  }\n}\n#else\n# define yyTraceShift(X,Y)\n#endif\n\n/*\n** Perform a shift action.\n*/\nstatic void yy_shift(\n  yyParser *yypParser,          /* The parser to be shifted */\n  int yyNewState,               /* The new state to shift in */\n  int yyMajor,                  /* The major token to shift in */\n  sqlite3ParserTOKENTYPE yyMinor        /* The minor token to shift in */\n){\n  yyStackEntry *yytos;\n  yypParser->yytos++;\n#ifdef YYTRACKMAXSTACKDEPTH\n  if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){\n    yypParser->yyhwm++;\n    assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) );\n  }\n#endif\n#if YYSTACKDEPTH>0 \n  if( yypParser->yytos>yypParser->yystackEnd ){\n    yypParser->yytos--;\n    yyStackOverflow(yypParser);\n    return;\n  }\n#else\n  if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){\n    if( yyGrowStack(yypParser) ){\n      yypParser->yytos--;\n      yyStackOverflow(yypParser);\n      return;\n    }\n  }\n#endif\n  if( yyNewState > YY_MAX_SHIFT ){\n    yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;\n  }\n  yytos = yypParser->yytos;\n  yytos->stateno = (YYACTIONTYPE)yyNewState;\n  yytos->major = (YYCODETYPE)yyMajor;\n  yytos->minor.yy0 = yyMinor;\n  yyTraceShift(yypParser, yyNewState);\n}\n\n/* The following table contains information about every rule that\n** is used during the reduce.\n*/\nstatic const struct {\n  YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */\n  signed char nrhs;     /* Negative of the number of RHS symbols in the rule */\n} yyRuleInfo[] = {\n  { 147, -1 },\n  { 147, -3 },\n  { 148, -1 },\n  { 149, -3 },\n  { 150, 0 },\n  { 150, -1 },\n  { 150, -1 },\n  { 150, -1 },\n  { 149, -2 },\n  { 149, -2 },\n  { 149, -2 },\n  { 149, -3 },\n  { 149, -5 },\n  { 154, -6 },\n  { 156, -1 },\n  { 158, 0 },\n  { 158, -3 },\n  { 157, -1 },\n  { 157, 0 },\n  { 155, -5 },\n  { 155, -2 },\n  { 162, 0 },\n  { 162, -2 },\n  { 164, -2 },\n  { 166, 0 },\n  { 166, -4 },\n  { 166, -6 },\n  { 167, -2 },\n  { 171, -2 },\n  { 171, -2 },\n  { 171, -4 },\n  { 171, -3 },\n  { 171, -3 },\n  { 171, -2 },\n  { 171, -3 },\n  { 171, -5 },\n  { 171, -2 },\n  { 171, -4 },\n  { 171, -4 },\n  { 171, -1 },\n  { 171, -2 },\n  { 176, 0 },\n  { 176, -1 },\n  { 178, 0 },\n  { 178, -2 },\n  { 180, -2 },\n  { 180, -3 },\n  { 180, -3 },\n  { 180, -3 },\n  { 181, -2 },\n  { 181, -2 },\n  { 181, -1 },\n  { 181, -1 },\n  { 181, -2 },\n  { 179, -3 },\n  { 179, -2 },\n  { 182, 0 },\n  { 182, -2 },\n  { 182, -2 },\n  { 161, 0 },\n  { 184, -1 },\n  { 185, -2 },\n  { 185, -7 },\n  { 185, -5 },\n  { 185, -5 },\n  { 185, -10 },\n  { 188, 0 },\n  { 174, 0 },\n  { 174, -3 },\n  { 189, 0 },\n  { 189, -2 },\n  { 190, -1 },\n  { 190, -1 },\n  { 149, -4 },\n  { 192, -2 },\n  { 192, 0 },\n  { 149, -9 },\n  { 149, -4 },\n  { 149, -1 },\n  { 163, -2 },\n  { 194, -3 },\n  { 197, -1 },\n  { 197, -2 },\n  { 197, -1 },\n  { 195, -9 },\n  { 206, -4 },\n  { 206, -5 },\n  { 198, -1 },\n  { 198, -1 },\n  { 198, 0 },\n  { 209, 0 },\n  { 199, -3 },\n  { 199, -2 },\n  { 199, -4 },\n  { 210, -2 },\n  { 210, 0 },\n  { 200, 0 },\n  { 200, -2 },\n  { 212, -2 },\n  { 212, 0 },\n  { 211, -7 },\n  { 211, -9 },\n  { 211, -7 },\n  { 211, -7 },\n  { 159, 0 },\n  { 159, -2 },\n  { 193, -2 },\n  { 213, -1 },\n  { 213, -2 },\n  { 213, -3 },\n  { 213, -4 },\n  { 215, -2 },\n  { 215, 0 },\n  { 214, 0 },\n  { 214, -3 },\n  { 214, -2 },\n  { 216, -4 },\n  { 216, 0 },\n  { 204, 0 },\n  { 204, -3 },\n  { 186, -4 },\n  { 186, -2 },\n  { 175, -1 },\n  { 175, -1 },\n  { 175, 0 },\n  { 202, 0 },\n  { 202, -3 },\n  { 203, 0 },\n  { 203, -2 },\n  { 205, 0 },\n  { 205, -2 },\n  { 205, -4 },\n  { 205, -4 },\n  { 149, -6 },\n  { 201, 0 },\n  { 201, -2 },\n  { 149, -8 },\n  { 218, -5 },\n  { 218, -7 },\n  { 218, -3 },\n  { 218, -5 },\n  { 149, -6 },\n  { 149, -7 },\n  { 219, -2 },\n  { 219, -1 },\n  { 220, 0 },\n  { 220, -3 },\n  { 217, -3 },\n  { 217, -1 },\n  { 173, -3 },\n  { 173, -1 },\n  { 173, -1 },\n  { 173, -3 },\n  { 173, -5 },\n  { 172, -1 },\n  { 172, -1 },\n  { 172, -1 },\n  { 173, -1 },\n  { 173, -3 },\n  { 173, -6 },\n  { 173, -5 },\n  { 173, -4 },\n  { 172, -1 },\n  { 173, -5 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -3 },\n  { 221, -2 },\n  { 173, -3 },\n  { 173, -5 },\n  { 173, -2 },\n  { 173, -3 },\n  { 173, -3 },\n  { 173, -4 },\n  { 173, -2 },\n  { 173, -2 },\n  { 173, -2 },\n  { 173, -2 },\n  { 222, -1 },\n  { 222, -2 },\n  { 173, -5 },\n  { 223, -1 },\n  { 223, -2 },\n  { 173, -5 },\n  { 173, -3 },\n  { 173, -5 },\n  { 173, -5 },\n  { 173, -4 },\n  { 173, -5 },\n  { 226, -5 },\n  { 226, -4 },\n  { 227, -2 },\n  { 227, 0 },\n  { 225, -1 },\n  { 225, 0 },\n  { 208, 0 },\n  { 207, -3 },\n  { 207, -1 },\n  { 224, 0 },\n  { 224, -3 },\n  { 149, -12 },\n  { 228, -1 },\n  { 228, 0 },\n  { 177, 0 },\n  { 177, -3 },\n  { 187, -5 },\n  { 187, -3 },\n  { 229, 0 },\n  { 229, -2 },\n  { 149, -4 },\n  { 149, -1 },\n  { 149, -2 },\n  { 149, -3 },\n  { 149, -5 },\n  { 149, -6 },\n  { 149, -5 },\n  { 149, -6 },\n  { 169, -2 },\n  { 170, -2 },\n  { 149, -5 },\n  { 231, -11 },\n  { 233, -1 },\n  { 233, -2 },\n  { 233, 0 },\n  { 234, -1 },\n  { 234, -1 },\n  { 234, -3 },\n  { 236, 0 },\n  { 236, -2 },\n  { 232, -3 },\n  { 232, -2 },\n  { 238, -3 },\n  { 239, -3 },\n  { 239, -2 },\n  { 237, -7 },\n  { 237, -5 },\n  { 237, -5 },\n  { 237, -1 },\n  { 173, -4 },\n  { 173, -6 },\n  { 191, -1 },\n  { 191, -1 },\n  { 191, -1 },\n  { 149, -4 },\n  { 149, -6 },\n  { 149, -3 },\n  { 241, 0 },\n  { 241, -2 },\n  { 149, -1 },\n  { 149, -3 },\n  { 149, -1 },\n  { 149, -3 },\n  { 149, -6 },\n  { 149, -7 },\n  { 242, -1 },\n  { 149, -1 },\n  { 149, -4 },\n  { 244, -8 },\n  { 246, 0 },\n  { 247, -1 },\n  { 247, -3 },\n  { 248, -1 },\n  { 196, 0 },\n  { 196, -2 },\n  { 196, -3 },\n  { 250, -6 },\n  { 250, -8 },\n  { 144, -1 },\n  { 145, -2 },\n  { 145, -1 },\n  { 146, -1 },\n  { 146, -3 },\n  { 147, 0 },\n  { 151, 0 },\n  { 151, -1 },\n  { 151, -2 },\n  { 153, -1 },\n  { 153, 0 },\n  { 149, -2 },\n  { 160, -4 },\n  { 160, -2 },\n  { 152, -1 },\n  { 152, -1 },\n  { 152, -1 },\n  { 166, -1 },\n  { 167, -1 },\n  { 168, -1 },\n  { 168, -1 },\n  { 165, -2 },\n  { 165, 0 },\n  { 171, -2 },\n  { 161, -2 },\n  { 183, -3 },\n  { 183, -1 },\n  { 184, 0 },\n  { 188, -1 },\n  { 190, -1 },\n  { 194, -1 },\n  { 195, -1 },\n  { 209, -2 },\n  { 210, -1 },\n  { 173, -1 },\n  { 221, -1 },\n  { 208, -1 },\n  { 230, -1 },\n  { 230, -1 },\n  { 230, -1 },\n  { 230, -1 },\n  { 230, -1 },\n  { 169, -1 },\n  { 235, 0 },\n  { 235, -3 },\n  { 238, -1 },\n  { 239, 0 },\n  { 240, -1 },\n  { 240, 0 },\n  { 243, 0 },\n  { 243, -1 },\n  { 245, -1 },\n  { 245, -3 },\n  { 246, -2 },\n  { 249, 0 },\n  { 249, -4 },\n  { 249, -2 },\n};\n\nstatic void yy_accept(yyParser*);  /* Forward Declaration */\n\n/*\n** Perform a reduce action and the shift that must immediately\n** follow the reduce.\n*/\nstatic void yy_reduce(\n  yyParser *yypParser,         /* The parser */\n  unsigned int yyruleno        /* Number of the rule by which to reduce */\n){\n  int yygoto;                     /* The next state */\n  int yyact;                      /* The next action */\n  yyStackEntry *yymsp;            /* The top of the parser's stack */\n  int yysize;                     /* Amount to pop the stack */\n  sqlite3ParserARG_FETCH;\n  yymsp = yypParser->yytos;\n#ifndef NDEBUG\n  if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){\n    yysize = yyRuleInfo[yyruleno].nrhs;\n    fprintf(yyTraceFILE, \"%sReduce [%s], go to state %d.\\n\", yyTracePrompt,\n      yyRuleName[yyruleno], yymsp[yysize].stateno);\n  }\n#endif /* NDEBUG */\n\n  /* Check that the stack is large enough to grow by a single entry\n  ** if the RHS of the rule is empty.  This ensures that there is room\n  ** enough on the stack to push the LHS value */\n  if( yyRuleInfo[yyruleno].nrhs==0 ){\n#ifdef YYTRACKMAXSTACKDEPTH\n    if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){\n      yypParser->yyhwm++;\n      assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));\n    }\n#endif\n#if YYSTACKDEPTH>0 \n    if( yypParser->yytos>=yypParser->yystackEnd ){\n      yyStackOverflow(yypParser);\n      return;\n    }\n#else\n    if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){\n      if( yyGrowStack(yypParser) ){\n        yyStackOverflow(yypParser);\n        return;\n      }\n      yymsp = yypParser->yytos;\n    }\n#endif\n  }\n\n  switch( yyruleno ){\n  /* Beginning here are the reduction cases.  A typical example\n  ** follows:\n  **   case 0:\n  **  #line <lineno> <grammarfile>\n  **     { ... }           // User supplied code\n  **  #line <lineno> <thisfile>\n  **     break;\n  */\n/********** Begin reduce actions **********************************************/\n        YYMINORTYPE yylhsminor;\n      case 0: /* explain ::= EXPLAIN */\n{ pParse->explain = 1; }\n        break;\n      case 1: /* explain ::= EXPLAIN QUERY PLAN */\n{ pParse->explain = 2; }\n        break;\n      case 2: /* cmdx ::= cmd */\n{ sqlite3FinishCoding(pParse); }\n        break;\n      case 3: /* cmd ::= BEGIN transtype trans_opt */\n{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);}\n        break;\n      case 4: /* transtype ::= */\n{yymsp[1].minor.yy194 = TK_DEFERRED;}\n        break;\n      case 5: /* transtype ::= DEFERRED */\n      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);\n      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);\n{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/}\n        break;\n      case 8: /* cmd ::= COMMIT|END trans_opt */\n      case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);\n{sqlite3EndTransaction(pParse,yymsp[-1].major);}\n        break;\n      case 10: /* cmd ::= SAVEPOINT nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);\n}\n        break;\n      case 11: /* cmd ::= RELEASE savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);\n}\n        break;\n      case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */\n{\n  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);\n}\n        break;\n      case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */\n{\n   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194);\n}\n        break;\n      case 14: /* createkw ::= CREATE */\n{disableLookaside(pParse);}\n        break;\n      case 15: /* ifnotexists ::= */\n      case 18: /* temp ::= */ yytestcase(yyruleno==18);\n      case 21: /* table_options ::= */ yytestcase(yyruleno==21);\n      case 41: /* autoinc ::= */ yytestcase(yyruleno==41);\n      case 56: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==56);\n      case 66: /* defer_subclause_opt ::= */ yytestcase(yyruleno==66);\n      case 75: /* ifexists ::= */ yytestcase(yyruleno==75);\n      case 89: /* distinct ::= */ yytestcase(yyruleno==89);\n      case 212: /* collate ::= */ yytestcase(yyruleno==212);\n{yymsp[1].minor.yy194 = 0;}\n        break;\n      case 16: /* ifnotexists ::= IF NOT EXISTS */\n{yymsp[-2].minor.yy194 = 1;}\n        break;\n      case 17: /* temp ::= TEMP */\n      case 42: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==42);\n{yymsp[0].minor.yy194 = 1;}\n        break;\n      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */\n{\n  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0);\n}\n        break;\n      case 20: /* create_table_args ::= AS select */\n{\n  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);\n}\n        break;\n      case 22: /* table_options ::= WITHOUT nm */\n{\n  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,\"rowid\",5)==0 ){\n    yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid;\n  }else{\n    yymsp[-1].minor.yy194 = 0;\n    sqlite3ErrorMsg(pParse, \"unknown table option: %.*s\", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);\n  }\n}\n        break;\n      case 23: /* columnname ::= nm typetoken */\n{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}\n        break;\n      case 24: /* typetoken ::= */\n      case 59: /* conslist_opt ::= */ yytestcase(yyruleno==59);\n      case 95: /* as ::= */ yytestcase(yyruleno==95);\n{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}\n        break;\n      case 25: /* typetoken ::= typename LP signed RP */\n{\n  yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);\n}\n        break;\n      case 26: /* typetoken ::= typename LP signed COMMA signed RP */\n{\n  yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);\n}\n        break;\n      case 27: /* typename ::= typename ID|STRING */\n{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}\n        break;\n      case 28: /* ccons ::= CONSTRAINT nm */\n      case 61: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==61);\n{pParse->constraintName = yymsp[0].minor.yy0;}\n        break;\n      case 29: /* ccons ::= DEFAULT term */\n      case 31: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==31);\n{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);}\n        break;\n      case 30: /* ccons ::= DEFAULT LP expr RP */\n{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);}\n        break;\n      case 32: /* ccons ::= DEFAULT MINUS term */\n{\n  ExprSpan v;\n  v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0);\n  v.zStart = yymsp[-1].minor.yy0.z;\n  v.zEnd = yymsp[0].minor.yy190.zEnd;\n  sqlite3AddDefaultValue(pParse,&v);\n}\n        break;\n      case 33: /* ccons ::= DEFAULT ID|INDEXED */\n{\n  ExprSpan v;\n  spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0);\n  sqlite3AddDefaultValue(pParse,&v);\n}\n        break;\n      case 34: /* ccons ::= NOT NULL onconf */\n{sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);}\n        break;\n      case 35: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */\n{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);}\n        break;\n      case 36: /* ccons ::= UNIQUE onconf */\n{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0,\n                                   SQLITE_IDXTYPE_UNIQUE);}\n        break;\n      case 37: /* ccons ::= CHECK LP expr RP */\n{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);}\n        break;\n      case 38: /* ccons ::= REFERENCES nm eidlist_opt refargs */\n{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);}\n        break;\n      case 39: /* ccons ::= defer_subclause */\n{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);}\n        break;\n      case 40: /* ccons ::= COLLATE ID|STRING */\n{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}\n        break;\n      case 43: /* refargs ::= */\n{ yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */}\n        break;\n      case 44: /* refargs ::= refargs refarg */\n{ yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; }\n        break;\n      case 45: /* refarg ::= MATCH nm */\n{ yymsp[-1].minor.yy497.value = 0;     yymsp[-1].minor.yy497.mask = 0x000000; }\n        break;\n      case 46: /* refarg ::= ON INSERT refact */\n{ yymsp[-2].minor.yy497.value = 0;     yymsp[-2].minor.yy497.mask = 0x000000; }\n        break;\n      case 47: /* refarg ::= ON DELETE refact */\n{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194;     yymsp[-2].minor.yy497.mask = 0x0000ff; }\n        break;\n      case 48: /* refarg ::= ON UPDATE refact */\n{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8;  yymsp[-2].minor.yy497.mask = 0x00ff00; }\n        break;\n      case 49: /* refact ::= SET NULL */\n{ yymsp[-1].minor.yy194 = OE_SetNull;  /* EV: R-33326-45252 */}\n        break;\n      case 50: /* refact ::= SET DEFAULT */\n{ yymsp[-1].minor.yy194 = OE_SetDflt;  /* EV: R-33326-45252 */}\n        break;\n      case 51: /* refact ::= CASCADE */\n{ yymsp[0].minor.yy194 = OE_Cascade;  /* EV: R-33326-45252 */}\n        break;\n      case 52: /* refact ::= RESTRICT */\n{ yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */}\n        break;\n      case 53: /* refact ::= NO ACTION */\n{ yymsp[-1].minor.yy194 = OE_None;     /* EV: R-33326-45252 */}\n        break;\n      case 54: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */\n{yymsp[-2].minor.yy194 = 0;}\n        break;\n      case 55: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */\n      case 70: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==70);\n      case 143: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==143);\n{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}\n        break;\n      case 57: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */\n      case 74: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==74);\n      case 184: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==184);\n      case 187: /* in_op ::= NOT IN */ yytestcase(yyruleno==187);\n      case 213: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==213);\n{yymsp[-1].minor.yy194 = 1;}\n        break;\n      case 58: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */\n{yymsp[-1].minor.yy194 = 0;}\n        break;\n      case 60: /* tconscomma ::= COMMA */\n{pParse->constraintName.n = 0;}\n        break;\n      case 62: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */\n{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);}\n        break;\n      case 63: /* tcons ::= UNIQUE LP sortlist RP onconf */\n{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0,\n                                       SQLITE_IDXTYPE_UNIQUE);}\n        break;\n      case 64: /* tcons ::= CHECK LP expr RP onconf */\n{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);}\n        break;\n      case 65: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */\n{\n    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194);\n    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194);\n}\n        break;\n      case 67: /* onconf ::= */\n      case 69: /* orconf ::= */ yytestcase(yyruleno==69);\n{yymsp[1].minor.yy194 = OE_Default;}\n        break;\n      case 68: /* onconf ::= ON CONFLICT resolvetype */\n{yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;}\n        break;\n      case 71: /* resolvetype ::= IGNORE */\n{yymsp[0].minor.yy194 = OE_Ignore;}\n        break;\n      case 72: /* resolvetype ::= REPLACE */\n      case 144: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==144);\n{yymsp[0].minor.yy194 = OE_Replace;}\n        break;\n      case 73: /* cmd ::= DROP TABLE ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194);\n}\n        break;\n      case 76: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */\n{\n  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194);\n}\n        break;\n      case 77: /* cmd ::= DROP VIEW ifexists fullname */\n{\n  sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194);\n}\n        break;\n      case 78: /* cmd ::= select */\n{\n  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};\n  sqlite3Select(pParse, yymsp[0].minor.yy243, &dest);\n  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243);\n}\n        break;\n      case 79: /* select ::= with selectnowith */\n{\n  Select *p = yymsp[0].minor.yy243;\n  if( p ){\n    p->pWith = yymsp[-1].minor.yy285;\n    parserDoubleLinkSelect(pParse, p);\n  }else{\n    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285);\n  }\n  yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/\n}\n        break;\n      case 80: /* selectnowith ::= selectnowith multiselect_op oneselect */\n{\n  Select *pRhs = yymsp[0].minor.yy243;\n  Select *pLhs = yymsp[-2].minor.yy243;\n  if( pRhs && pRhs->pPrior ){\n    SrcList *pFrom;\n    Token x;\n    x.n = 0;\n    parserDoubleLinkSelect(pParse, pRhs);\n    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);\n    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);\n  }\n  if( pRhs ){\n    pRhs->op = (u8)yymsp[-1].minor.yy194;\n    pRhs->pPrior = pLhs;\n    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;\n    pRhs->selFlags &= ~SF_MultiValue;\n    if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1;\n  }else{\n    sqlite3SelectDelete(pParse->db, pLhs);\n  }\n  yymsp[-2].minor.yy243 = pRhs;\n}\n        break;\n      case 81: /* multiselect_op ::= UNION */\n      case 83: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==83);\n{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/}\n        break;\n      case 82: /* multiselect_op ::= UNION ALL */\n{yymsp[-1].minor.yy194 = TK_ALL;}\n        break;\n      case 84: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */\n{\n#if SELECTTRACE_ENABLED\n  Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/\n#endif\n  yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset);\n#if SELECTTRACE_ENABLED\n  /* Populate the Select.zSelName[] string that is used to help with\n  ** query planner debugging, to differentiate between multiple Select\n  ** objects in a complex query.\n  **\n  ** If the SELECT keyword is immediately followed by a C-style comment\n  ** then extract the first few alphanumeric characters from within that\n  ** comment to be the zSelName value.  Otherwise, the label is #N where\n  ** is an integer that is incremented with each SELECT statement seen.\n  */\n  if( yymsp[-8].minor.yy243!=0 ){\n    const char *z = s.z+6;\n    int i;\n    sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, \"#%d\",\n                     ++pParse->nSelect);\n    while( z[0]==' ' ) z++;\n    if( z[0]=='/' && z[1]=='*' ){\n      z += 2;\n      while( z[0]==' ' ) z++;\n      for(i=0; sqlite3Isalnum(z[i]); i++){}\n      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, \"%.*s\", i, z);\n    }\n  }\n#endif /* SELECTRACE_ENABLED */\n}\n        break;\n      case 85: /* values ::= VALUES LP nexprlist RP */\n{\n  yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0);\n}\n        break;\n      case 86: /* values ::= values COMMA LP exprlist RP */\n{\n  Select *pRight, *pLeft = yymsp[-4].minor.yy243;\n  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);\n  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;\n  if( pRight ){\n    pRight->op = TK_ALL;\n    pRight->pPrior = pLeft;\n    yymsp[-4].minor.yy243 = pRight;\n  }else{\n    yymsp[-4].minor.yy243 = pLeft;\n  }\n}\n        break;\n      case 87: /* distinct ::= DISTINCT */\n{yymsp[0].minor.yy194 = SF_Distinct;}\n        break;\n      case 88: /* distinct ::= ALL */\n{yymsp[0].minor.yy194 = SF_All;}\n        break;\n      case 90: /* sclp ::= */\n      case 118: /* orderby_opt ::= */ yytestcase(yyruleno==118);\n      case 125: /* groupby_opt ::= */ yytestcase(yyruleno==125);\n      case 200: /* exprlist ::= */ yytestcase(yyruleno==200);\n      case 203: /* paren_exprlist ::= */ yytestcase(yyruleno==203);\n      case 208: /* eidlist_opt ::= */ yytestcase(yyruleno==208);\n{yymsp[1].minor.yy148 = 0;}\n        break;\n      case 91: /* selcollist ::= sclp expr as */\n{\n   yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);\n   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1);\n   sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190);\n}\n        break;\n      case 92: /* selcollist ::= sclp STAR */\n{\n  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);\n  yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p);\n}\n        break;\n      case 93: /* selcollist ::= sclp nm DOT STAR */\n{\n  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);\n  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n  yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);\n}\n        break;\n      case 94: /* as ::= AS nm */\n      case 105: /* dbnm ::= DOT nm */ yytestcase(yyruleno==105);\n      case 222: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==222);\n      case 223: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==223);\n{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}\n        break;\n      case 96: /* from ::= */\n{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}\n        break;\n      case 97: /* from ::= FROM seltablist */\n{\n  yymsp[-1].minor.yy185 = yymsp[0].minor.yy185;\n  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185);\n}\n        break;\n      case 98: /* stl_prefix ::= seltablist joinop */\n{\n   if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194;\n}\n        break;\n      case 99: /* stl_prefix ::= */\n{yymsp[1].minor.yy185 = 0;}\n        break;\n      case 100: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */\n{\n  yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);\n  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0);\n}\n        break;\n      case 101: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */\n{\n  yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);\n  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148);\n}\n        break;\n      case 102: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */\n{\n    yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);\n  }\n        break;\n      case 103: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */\n{\n    if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){\n      yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185;\n    }else if( yymsp[-4].minor.yy185->nSrc==1 ){\n      yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);\n      if( yymsp[-6].minor.yy185 ){\n        struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1];\n        struct SrcList_item *pOld = yymsp[-4].minor.yy185->a;\n        pNew->zName = pOld->zName;\n        pNew->zDatabase = pOld->zDatabase;\n        pNew->pSelect = pOld->pSelect;\n        pOld->zName = pOld->zDatabase = 0;\n        pOld->pSelect = 0;\n      }\n      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185);\n    }else{\n      Select *pSubquery;\n      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185);\n      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0);\n      yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254);\n    }\n  }\n        break;\n      case 104: /* dbnm ::= */\n      case 113: /* indexed_opt ::= */ yytestcase(yyruleno==113);\n{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}\n        break;\n      case 106: /* fullname ::= nm dbnm */\n{yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 107: /* joinop ::= COMMA|JOIN */\n{ yymsp[0].minor.yy194 = JT_INNER; }\n        break;\n      case 108: /* joinop ::= JOIN_KW JOIN */\n{yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}\n        break;\n      case 109: /* joinop ::= JOIN_KW nm JOIN */\n{yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}\n        break;\n      case 110: /* joinop ::= JOIN_KW nm nm JOIN */\n{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}\n        break;\n      case 111: /* on_opt ::= ON expr */\n      case 128: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==128);\n      case 135: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==135);\n      case 196: /* case_else ::= ELSE expr */ yytestcase(yyruleno==196);\n{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}\n        break;\n      case 112: /* on_opt ::= */\n      case 127: /* having_opt ::= */ yytestcase(yyruleno==127);\n      case 134: /* where_opt ::= */ yytestcase(yyruleno==134);\n      case 197: /* case_else ::= */ yytestcase(yyruleno==197);\n      case 199: /* case_operand ::= */ yytestcase(yyruleno==199);\n{yymsp[1].minor.yy72 = 0;}\n        break;\n      case 114: /* indexed_opt ::= INDEXED BY nm */\n{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}\n        break;\n      case 115: /* indexed_opt ::= NOT INDEXED */\n{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}\n        break;\n      case 116: /* using_opt ::= USING LP idlist RP */\n{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}\n        break;\n      case 117: /* using_opt ::= */\n      case 145: /* idlist_opt ::= */ yytestcase(yyruleno==145);\n{yymsp[1].minor.yy254 = 0;}\n        break;\n      case 119: /* orderby_opt ::= ORDER BY sortlist */\n      case 126: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==126);\n{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;}\n        break;\n      case 120: /* sortlist ::= sortlist COMMA expr sortorder */\n{\n  yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr);\n  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194);\n}\n        break;\n      case 121: /* sortlist ::= expr sortorder */\n{\n  yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/\n  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194);\n}\n        break;\n      case 122: /* sortorder ::= ASC */\n{yymsp[0].minor.yy194 = SQLITE_SO_ASC;}\n        break;\n      case 123: /* sortorder ::= DESC */\n{yymsp[0].minor.yy194 = SQLITE_SO_DESC;}\n        break;\n      case 124: /* sortorder ::= */\n{yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;}\n        break;\n      case 129: /* limit_opt ::= */\n{yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;}\n        break;\n      case 130: /* limit_opt ::= LIMIT expr */\n{yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;}\n        break;\n      case 131: /* limit_opt ::= LIMIT expr OFFSET expr */\n{yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;}\n        break;\n      case 132: /* limit_opt ::= LIMIT expr COMMA expr */\n{yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;}\n        break;\n      case 133: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */\n{\n  sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);\n  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0);\n  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72);\n}\n        break;\n      case 136: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */\n{\n  sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1);\n  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0);\n  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,\"set list\"); \n  sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194);\n}\n        break;\n      case 137: /* setlist ::= setlist COMMA nm EQ expr */\n{\n  yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);\n  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1);\n}\n        break;\n      case 138: /* setlist ::= setlist COMMA LP idlist RP EQ expr */\n{\n  yymsp[-6].minor.yy148 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy148, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);\n}\n        break;\n      case 139: /* setlist ::= nm EQ expr */\n{\n  yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr);\n  sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1);\n}\n  yymsp[-2].minor.yy148 = yylhsminor.yy148;\n        break;\n      case 140: /* setlist ::= LP idlist RP EQ expr */\n{\n  yymsp[-4].minor.yy148 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy190.pExpr);\n}\n        break;\n      case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */\n{\n  sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1);\n  sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194);\n}\n        break;\n      case 142: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */\n{\n  sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1);\n  sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194);\n}\n        break;\n      case 146: /* idlist_opt ::= LP idlist RP */\n{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}\n        break;\n      case 147: /* idlist ::= idlist COMMA nm */\n{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}\n        break;\n      case 148: /* idlist ::= nm */\n{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}\n        break;\n      case 149: /* expr ::= LP expr RP */\n{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/  yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;}\n        break;\n      case 150: /* expr ::= ID|INDEXED */\n      case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151);\n{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 152: /* expr ::= nm DOT nm */\n{\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);\n  spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/\n  yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);\n}\n        break;\n      case 153: /* expr ::= nm DOT nm DOT nm */\n{\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);\n  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);\n  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);\n  spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/\n  yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);\n}\n        break;\n      case 154: /* term ::= NULL|FLOAT|BLOB */\n      case 155: /* term ::= STRING */ yytestcase(yyruleno==155);\n{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}\n        break;\n      case 156: /* term ::= INTEGER */\n{\n  yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);\n  yylhsminor.yy190.zStart = yymsp[0].minor.yy0.z;\n  yylhsminor.yy190.zEnd = yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n;\n}\n  yymsp[0].minor.yy190 = yylhsminor.yy190;\n        break;\n      case 157: /* expr ::= VARIABLE */\n{\n  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){\n    u32 n = yymsp[0].minor.yy0.n;\n    spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0);\n    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr, n);\n  }else{\n    /* When doing a nested parse, one can include terms in an expression\n    ** that look like this:   #1 #2 ...  These terms refer to registers\n    ** in the virtual machine.  #N is the N-th register. */\n    Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/\n    assert( t.n>=2 );\n    spanSet(&yymsp[0].minor.yy190, &t, &t);\n    if( pParse->nested==0 ){\n      sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &t);\n      yymsp[0].minor.yy190.pExpr = 0;\n    }else{\n      yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);\n      if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable);\n    }\n  }\n}\n        break;\n      case 158: /* expr ::= expr COLLATE ID|STRING */\n{\n  yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1);\n  yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n}\n        break;\n      case 159: /* expr ::= CAST LP expr AS typetoken RP */\n{\n  spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/\n  yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);\n  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, 0);\n}\n        break;\n      case 160: /* expr ::= ID|INDEXED LP distinct exprlist RP */\n{\n  if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){\n    sqlite3ErrorMsg(pParse, \"too many arguments on function %T\", &yymsp[-4].minor.yy0);\n  }\n  yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0);\n  spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);\n  if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){\n    yylhsminor.yy190.pExpr->flags |= EP_Distinct;\n  }\n}\n  yymsp[-4].minor.yy190 = yylhsminor.yy190;\n        break;\n      case 161: /* expr ::= ID|INDEXED LP STAR RP */\n{\n  yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);\n  spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);\n}\n  yymsp[-3].minor.yy190 = yylhsminor.yy190;\n        break;\n      case 162: /* term ::= CTIME_KW */\n{\n  yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);\n  spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);\n}\n  yymsp[0].minor.yy190 = yylhsminor.yy190;\n        break;\n      case 163: /* expr ::= LP nexprlist COMMA expr RP */\n{\n  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy148, yymsp[-1].minor.yy190.pExpr);\n  yylhsminor.yy190.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);\n  if( yylhsminor.yy190.pExpr ){\n    yylhsminor.yy190.pExpr->x.pList = pList;\n    spanSet(&yylhsminor.yy190, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0);\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n  yymsp[-4].minor.yy190 = yylhsminor.yy190;\n        break;\n      case 164: /* expr ::= expr AND expr */\n      case 165: /* expr ::= expr OR expr */ yytestcase(yyruleno==165);\n      case 166: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==166);\n      case 167: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==167);\n      case 168: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==168);\n      case 169: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==169);\n      case 170: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==170);\n      case 171: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==171);\n{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}\n        break;\n      case 172: /* likeop ::= NOT LIKE_KW|MATCH */\n{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}\n        break;\n      case 173: /* expr ::= expr likeop expr */\n{\n  ExprList *pList;\n  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;\n  yymsp[-1].minor.yy0.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr);\n  yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);\n  exprNot(pParse, bNot, &yymsp[-2].minor.yy190);\n  yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;\n  if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;\n}\n        break;\n      case 174: /* expr ::= expr likeop expr ESCAPE expr */\n{\n  ExprList *pList;\n  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;\n  yymsp[-3].minor.yy0.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);\n  yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);\n  exprNot(pParse, bNot, &yymsp[-4].minor.yy190);\n  yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;\n  if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;\n}\n        break;\n      case 175: /* expr ::= expr ISNULL|NOTNULL */\n{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}\n        break;\n      case 176: /* expr ::= expr NOT NULL */\n{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}\n        break;\n      case 177: /* expr ::= expr IS expr */\n{\n  spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);\n}\n        break;\n      case 178: /* expr ::= expr IS NOT expr */\n{\n  spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);\n  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);\n}\n        break;\n      case 179: /* expr ::= NOT expr */\n      case 180: /* expr ::= BITNOT expr */ yytestcase(yyruleno==180);\n{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}\n        break;\n      case 181: /* expr ::= MINUS expr */\n{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}\n        break;\n      case 182: /* expr ::= PLUS expr */\n{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}\n        break;\n      case 183: /* between_op ::= BETWEEN */\n      case 186: /* in_op ::= IN */ yytestcase(yyruleno==186);\n{yymsp[0].minor.yy194 = 0;}\n        break;\n      case 185: /* expr ::= expr between_op expr AND expr */\n{\n  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);\n  yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);\n  if( yymsp[-4].minor.yy190.pExpr ){\n    yymsp[-4].minor.yy190.pExpr->x.pList = pList;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  } \n  exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);\n  yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;\n}\n        break;\n      case 188: /* expr ::= expr in_op LP exprlist RP */\n{\n    if( yymsp[-1].minor.yy148==0 ){\n      /* Expressions of the form\n      **\n      **      expr1 IN ()\n      **      expr1 NOT IN ()\n      **\n      ** simplify to constants 0 (false) and 1 (true), respectively,\n      ** regardless of the value of expr1.\n      */\n      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr);\n      yymsp[-4].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy194],1);\n    }else if( yymsp[-1].minor.yy148->nExpr==1 ){\n      /* Expressions of the form:\n      **\n      **      expr1 IN (?1)\n      **      expr1 NOT IN (?2)\n      **\n      ** with exactly one value on the RHS can be simplified to something\n      ** like this:\n      **\n      **      expr1 == ?1\n      **      expr1 <> ?2\n      **\n      ** But, the RHS of the == or <> is marked with the EP_Generic flag\n      ** so that it may not contribute to the computation of comparison\n      ** affinity or the collating sequence to use for comparison.  Otherwise,\n      ** the semantics would be subtly different from IN or NOT IN.\n      */\n      Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr;\n      yymsp[-1].minor.yy148->a[0].pExpr = 0;\n      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);\n      /* pRHS cannot be NULL because a malloc error would have been detected\n      ** before now and control would have never reached this point */\n      if( ALWAYS(pRHS) ){\n        pRHS->flags &= ~EP_Collate;\n        pRHS->flags |= EP_Generic;\n      }\n      yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS);\n    }else{\n      yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);\n      if( yymsp[-4].minor.yy190.pExpr ){\n        yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148;\n        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);\n      }else{\n        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148);\n      }\n      exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);\n    }\n    yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 189: /* expr ::= LP select RP */\n{\n    spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/\n    yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);\n  }\n        break;\n      case 190: /* expr ::= expr in_op LP select RP */\n{\n    yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);\n    exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);\n    yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];\n  }\n        break;\n      case 191: /* expr ::= expr in_op nm dbnm paren_exprlist */\n{\n    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);\n    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);\n    if( yymsp[0].minor.yy148 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);\n    yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);\n    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);\n    exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);\n    yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];\n  }\n        break;\n      case 192: /* expr ::= EXISTS LP select RP */\n{\n    Expr *p;\n    spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/\n    p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);\n    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);\n  }\n        break;\n      case 193: /* expr ::= CASE case_operand case_exprlist case_else END */\n{\n  spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);  /*A-overwrites-C*/\n  yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);\n  if( yymsp[-4].minor.yy190.pExpr ){\n    yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;\n    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr);\n  }else{\n    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);\n    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);\n  }\n}\n        break;\n      case 194: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */\n{\n  yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);\n  yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);\n}\n        break;\n      case 195: /* case_exprlist ::= WHEN expr THEN expr */\n{\n  yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);\n  yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);\n}\n        break;\n      case 198: /* case_operand ::= expr */\n{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}\n        break;\n      case 201: /* nexprlist ::= nexprlist COMMA expr */\n{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}\n        break;\n      case 202: /* nexprlist ::= expr */\n{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}\n        break;\n      case 204: /* paren_exprlist ::= LP exprlist RP */\n      case 209: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==209);\n{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}\n        break;\n      case 205: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */\n{\n  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, \n                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,\n                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);\n}\n        break;\n      case 206: /* uniqueflag ::= UNIQUE */\n      case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246);\n{yymsp[0].minor.yy194 = OE_Abort;}\n        break;\n      case 207: /* uniqueflag ::= */\n{yymsp[1].minor.yy194 = OE_None;}\n        break;\n      case 210: /* eidlist ::= eidlist COMMA nm collate sortorder */\n{\n  yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);\n}\n        break;\n      case 211: /* eidlist ::= nm collate sortorder */\n{\n  yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/\n}\n        break;\n      case 214: /* cmd ::= DROP INDEX ifexists fullname */\n{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}\n        break;\n      case 215: /* cmd ::= VACUUM */\n{sqlite3Vacuum(pParse,0);}\n        break;\n      case 216: /* cmd ::= VACUUM nm */\n{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 217: /* cmd ::= PRAGMA nm dbnm */\n{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}\n        break;\n      case 218: /* cmd ::= PRAGMA nm dbnm EQ nmnum */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}\n        break;\n      case 219: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}\n        break;\n      case 220: /* cmd ::= PRAGMA nm dbnm EQ minus_num */\n{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}\n        break;\n      case 221: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */\n{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}\n        break;\n      case 224: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */\n{\n  Token all;\n  all.z = yymsp[-3].minor.yy0.z;\n  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;\n  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);\n}\n        break;\n      case 225: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */\n{\n  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);\n  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/\n}\n        break;\n      case 226: /* trigger_time ::= BEFORE|AFTER */\n{ yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/ }\n        break;\n      case 227: /* trigger_time ::= INSTEAD OF */\n{ yymsp[-1].minor.yy194 = TK_INSTEAD;}\n        break;\n      case 228: /* trigger_time ::= */\n{ yymsp[1].minor.yy194 = TK_BEFORE; }\n        break;\n      case 229: /* trigger_event ::= DELETE|INSERT */\n      case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230);\n{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}\n        break;\n      case 231: /* trigger_event ::= UPDATE OF idlist */\n{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}\n        break;\n      case 232: /* when_clause ::= */\n      case 251: /* key_opt ::= */ yytestcase(yyruleno==251);\n{ yymsp[1].minor.yy72 = 0; }\n        break;\n      case 233: /* when_clause ::= WHEN expr */\n      case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252);\n{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }\n        break;\n      case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */\n{\n  assert( yymsp[-2].minor.yy145!=0 );\n  yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;\n  yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;\n}\n        break;\n      case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */\n{ \n  assert( yymsp[-1].minor.yy145!=0 );\n  yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;\n}\n        break;\n      case 236: /* trnm ::= nm DOT nm */\n{\n  yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;\n  sqlite3ErrorMsg(pParse, \n        \"qualified table names are not allowed on INSERT, UPDATE, and DELETE \"\n        \"statements within triggers\");\n}\n        break;\n      case 237: /* tridxby ::= INDEXED BY nm */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the INDEXED BY clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 238: /* tridxby ::= NOT INDEXED */\n{\n  sqlite3ErrorMsg(pParse,\n        \"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n        break;\n      case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */\n{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}\n        break;\n      case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */\n{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}\n        break;\n      case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */\n{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}\n        break;\n      case 242: /* trigger_cmd ::= select */\n{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}\n        break;\n      case 243: /* expr ::= RAISE LP IGNORE RP */\n{\n  spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);  /*A-overwrites-X*/\n  yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0); \n  if( yymsp[-3].minor.yy190.pExpr ){\n    yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;\n  }\n}\n        break;\n      case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */\n{\n  spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);  /*A-overwrites-X*/\n  yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); \n  if( yymsp[-5].minor.yy190.pExpr ) {\n    yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;\n  }\n}\n        break;\n      case 245: /* raisetype ::= ROLLBACK */\n{yymsp[0].minor.yy194 = OE_Rollback;}\n        break;\n      case 247: /* raisetype ::= FAIL */\n{yymsp[0].minor.yy194 = OE_Fail;}\n        break;\n      case 248: /* cmd ::= DROP TRIGGER ifexists fullname */\n{\n  sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);\n}\n        break;\n      case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */\n{\n  sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);\n}\n        break;\n      case 250: /* cmd ::= DETACH database_kw_opt expr */\n{\n  sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);\n}\n        break;\n      case 253: /* cmd ::= REINDEX */\n{sqlite3Reindex(pParse, 0, 0);}\n        break;\n      case 254: /* cmd ::= REINDEX nm dbnm */\n{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 255: /* cmd ::= ANALYZE */\n{sqlite3Analyze(pParse, 0, 0);}\n        break;\n      case 256: /* cmd ::= ANALYZE nm dbnm */\n{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}\n        break;\n      case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */\n{\n  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);\n}\n        break;\n      case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */\n{\n  yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;\n  sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);\n}\n        break;\n      case 259: /* add_column_fullname ::= fullname */\n{\n  disableLookaside(pParse);\n  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);\n}\n        break;\n      case 260: /* cmd ::= create_vtab */\n{sqlite3VtabFinishParse(pParse,0);}\n        break;\n      case 261: /* cmd ::= create_vtab LP vtabarglist RP */\n{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */\n{\n    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);\n}\n        break;\n      case 263: /* vtabarg ::= */\n{sqlite3VtabArgInit(pParse);}\n        break;\n      case 264: /* vtabargtoken ::= ANY */\n      case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265);\n      case 266: /* lp ::= LP */ yytestcase(yyruleno==266);\n{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}\n        break;\n      case 267: /* with ::= */\n{yymsp[1].minor.yy285 = 0;}\n        break;\n      case 268: /* with ::= WITH wqlist */\n{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }\n        break;\n      case 269: /* with ::= WITH RECURSIVE wqlist */\n{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }\n        break;\n      case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */\n{\n  yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/\n}\n        break;\n      case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */\n{\n  yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);\n}\n        break;\n      default:\n      /* (272) input ::= cmdlist */ yytestcase(yyruleno==272);\n      /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273);\n      /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274);\n      /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275);\n      /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276);\n      /* (277) explain ::= */ yytestcase(yyruleno==277);\n      /* (278) trans_opt ::= */ yytestcase(yyruleno==278);\n      /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279);\n      /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280);\n      /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281);\n      /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282);\n      /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283);\n      /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284);\n      /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285);\n      /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286);\n      /* (287) nm ::= STRING */ yytestcase(yyruleno==287);\n      /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288);\n      /* (289) typetoken ::= typename */ yytestcase(yyruleno==289);\n      /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290);\n      /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291);\n      /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292);\n      /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293);\n      /* (294) carglist ::= */ yytestcase(yyruleno==294);\n      /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295);\n      /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296);\n      /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297);\n      /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298);\n      /* (299) tconscomma ::= */ yytestcase(yyruleno==299);\n      /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300);\n      /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301);\n      /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302);\n      /* (303) oneselect ::= values */ yytestcase(yyruleno==303);\n      /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304);\n      /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305);\n      /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306);\n      /* (307) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==307);\n      /* (308) exprlist ::= nexprlist */ yytestcase(yyruleno==308);\n      /* (309) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=309);\n      /* (310) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=310);\n      /* (311) nmnum ::= ON */ yytestcase(yyruleno==311);\n      /* (312) nmnum ::= DELETE */ yytestcase(yyruleno==312);\n      /* (313) nmnum ::= DEFAULT */ yytestcase(yyruleno==313);\n      /* (314) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==314);\n      /* (315) foreach_clause ::= */ yytestcase(yyruleno==315);\n      /* (316) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==316);\n      /* (317) trnm ::= nm */ yytestcase(yyruleno==317);\n      /* (318) tridxby ::= */ yytestcase(yyruleno==318);\n      /* (319) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==319);\n      /* (320) database_kw_opt ::= */ yytestcase(yyruleno==320);\n      /* (321) kwcolumn_opt ::= */ yytestcase(yyruleno==321);\n      /* (322) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==322);\n      /* (323) vtabarglist ::= vtabarg */ yytestcase(yyruleno==323);\n      /* (324) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==324);\n      /* (325) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==325);\n      /* (326) anylist ::= */ yytestcase(yyruleno==326);\n      /* (327) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==327);\n      /* (328) anylist ::= anylist ANY */ yytestcase(yyruleno==328);\n        break;\n/********** End reduce actions ************************************************/\n  };\n  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );\n  yygoto = yyRuleInfo[yyruleno].lhs;\n  yysize = yyRuleInfo[yyruleno].nrhs;\n  yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);\n\n  /* There are no SHIFTREDUCE actions on nonterminals because the table\n  ** generator has simplified them to pure REDUCE actions. */\n  assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) );\n\n  /* It is not possible for a REDUCE to be followed by an error */\n  assert( yyact!=YY_ERROR_ACTION );\n\n  if( yyact==YY_ACCEPT_ACTION ){\n    yypParser->yytos += yysize;\n    yy_accept(yypParser);\n  }else{\n    yymsp += yysize+1;\n    yypParser->yytos = yymsp;\n    yymsp->stateno = (YYACTIONTYPE)yyact;\n    yymsp->major = (YYCODETYPE)yygoto;\n    yyTraceShift(yypParser, yyact);\n  }\n}\n\n/*\n** The following code executes when the parse fails\n*/\n#ifndef YYNOERRORRECOVERY\nstatic void yy_parse_failed(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sFail!\\n\",yyTracePrompt);\n  }\n#endif\n  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser fails */\n/************ Begin %parse_failure code ***************************************/\n/************ End %parse_failure code *****************************************/\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n#endif /* YYNOERRORRECOVERY */\n\n/*\n** The following code executes when a syntax error first occurs.\n*/\nstatic void yy_syntax_error(\n  yyParser *yypParser,           /* The parser */\n  int yymajor,                   /* The major type of the error token */\n  sqlite3ParserTOKENTYPE yyminor         /* The minor type of the error token */\n){\n  sqlite3ParserARG_FETCH;\n#define TOKEN yyminor\n/************ Begin %syntax_error code ****************************************/\n\n  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */\n  assert( TOKEN.z[0] );  /* The tokenizer always gives us a token */\n  sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &TOKEN);\n/************ End %syntax_error code ******************************************/\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/*\n** The following is executed when the parser accepts\n*/\nstatic void yy_accept(\n  yyParser *yypParser           /* The parser */\n){\n  sqlite3ParserARG_FETCH;\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sAccept!\\n\",yyTracePrompt);\n  }\n#endif\n#ifndef YYNOERRORRECOVERY\n  yypParser->yyerrcnt = -1;\n#endif\n  assert( yypParser->yytos==yypParser->yystack );\n  /* Here code is inserted which will be executed whenever the\n  ** parser accepts */\n/*********** Begin %parse_accept code *****************************************/\n/*********** End %parse_accept code *******************************************/\n  sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/* The main parser program.\n** The first argument is a pointer to a structure obtained from\n** \"sqlite3ParserAlloc\" which describes the current state of the parser.\n** The second argument is the major token number.  The third is\n** the minor token.  The fourth optional argument is whatever the\n** user wants (and specified in the grammar) and is available for\n** use by the action routines.\n**\n** Inputs:\n** <ul>\n** <li> A pointer to the parser (an opaque structure.)\n** <li> The major token number.\n** <li> The minor token number.\n** <li> An option argument of a grammar-specified type.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nSQLITE_PRIVATE void sqlite3Parser(\n  void *yyp,                   /* The parser */\n  int yymajor,                 /* The major token code number */\n  sqlite3ParserTOKENTYPE yyminor       /* The value for the token */\n  sqlite3ParserARG_PDECL               /* Optional %extra_argument parameter */\n){\n  YYMINORTYPE yyminorunion;\n  unsigned int yyact;   /* The parser action. */\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  int yyendofinput;     /* True if we are at the end of input */\n#endif\n#ifdef YYERRORSYMBOL\n  int yyerrorhit = 0;   /* True if yymajor has invoked an error */\n#endif\n  yyParser *yypParser;  /* The parser */\n\n  yypParser = (yyParser*)yyp;\n  assert( yypParser->yytos!=0 );\n#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)\n  yyendofinput = (yymajor==0);\n#endif\n  sqlite3ParserARG_STORE;\n\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    fprintf(yyTraceFILE,\"%sInput '%s'\\n\",yyTracePrompt,yyTokenName[yymajor]);\n  }\n#endif\n\n  do{\n    yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);\n    if( yyact <= YY_MAX_SHIFTREDUCE ){\n      yy_shift(yypParser,yyact,yymajor,yyminor);\n#ifndef YYNOERRORRECOVERY\n      yypParser->yyerrcnt--;\n#endif\n      yymajor = YYNOCODE;\n    }else if( yyact <= YY_MAX_REDUCE ){\n      yy_reduce(yypParser,yyact-YY_MIN_REDUCE);\n    }else{\n      assert( yyact == YY_ERROR_ACTION );\n      yyminorunion.yy0 = yyminor;\n#ifdef YYERRORSYMBOL\n      int yymx;\n#endif\n#ifndef NDEBUG\n      if( yyTraceFILE ){\n        fprintf(yyTraceFILE,\"%sSyntax Error!\\n\",yyTracePrompt);\n      }\n#endif\n#ifdef YYERRORSYMBOL\n      /* A syntax error has occurred.\n      ** The response to an error depends upon whether or not the\n      ** grammar defines an error token \"ERROR\".  \n      **\n      ** This is what we do if the grammar does define ERROR:\n      **\n      **  * Call the %syntax_error function.\n      **\n      **  * Begin popping the stack until we enter a state where\n      **    it is legal to shift the error symbol, then shift\n      **    the error symbol.\n      **\n      **  * Set the error count to three.\n      **\n      **  * Begin accepting and shifting new tokens.  No new error\n      **    processing will occur until three tokens have been\n      **    shifted successfully.\n      **\n      */\n      if( yypParser->yyerrcnt<0 ){\n        yy_syntax_error(yypParser,yymajor,yyminor);\n      }\n      yymx = yypParser->yytos->major;\n      if( yymx==YYERRORSYMBOL || yyerrorhit ){\n#ifndef NDEBUG\n        if( yyTraceFILE ){\n          fprintf(yyTraceFILE,\"%sDiscard input token %s\\n\",\n             yyTracePrompt,yyTokenName[yymajor]);\n        }\n#endif\n        yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);\n        yymajor = YYNOCODE;\n      }else{\n        while( yypParser->yytos >= yypParser->yystack\n            && yymx != YYERRORSYMBOL\n            && (yyact = yy_find_reduce_action(\n                        yypParser->yytos->stateno,\n                        YYERRORSYMBOL)) >= YY_MIN_REDUCE\n        ){\n          yy_pop_parser_stack(yypParser);\n        }\n        if( yypParser->yytos < yypParser->yystack || yymajor==0 ){\n          yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n          yy_parse_failed(yypParser);\n#ifndef YYNOERRORRECOVERY\n          yypParser->yyerrcnt = -1;\n#endif\n          yymajor = YYNOCODE;\n        }else if( yymx!=YYERRORSYMBOL ){\n          yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor);\n        }\n      }\n      yypParser->yyerrcnt = 3;\n      yyerrorhit = 1;\n#elif defined(YYNOERRORRECOVERY)\n      /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to\n      ** do any kind of error recovery.  Instead, simply invoke the syntax\n      ** error routine and continue going as if nothing had happened.\n      **\n      ** Applications can set this macro (for example inside %include) if\n      ** they intend to abandon the parse upon the first syntax error seen.\n      */\n      yy_syntax_error(yypParser,yymajor, yyminor);\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      yymajor = YYNOCODE;\n      \n#else  /* YYERRORSYMBOL is not defined */\n      /* This is what we do if the grammar does not define ERROR:\n      **\n      **  * Report an error message, and throw away the input token.\n      **\n      **  * If the input token is $, then fail the parse.\n      **\n      ** As before, subsequent error messages are suppressed until\n      ** three input tokens have been successfully shifted.\n      */\n      if( yypParser->yyerrcnt<=0 ){\n        yy_syntax_error(yypParser,yymajor, yyminor);\n      }\n      yypParser->yyerrcnt = 3;\n      yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);\n      if( yyendofinput ){\n        yy_parse_failed(yypParser);\n#ifndef YYNOERRORRECOVERY\n        yypParser->yyerrcnt = -1;\n#endif\n      }\n      yymajor = YYNOCODE;\n#endif\n    }\n  }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );\n#ifndef NDEBUG\n  if( yyTraceFILE ){\n    yyStackEntry *i;\n    char cDiv = '[';\n    fprintf(yyTraceFILE,\"%sReturn. Stack=\",yyTracePrompt);\n    for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){\n      fprintf(yyTraceFILE,\"%c%s\", cDiv, yyTokenName[i->major]);\n      cDiv = ' ';\n    }\n    fprintf(yyTraceFILE,\"]\\n\");\n  }\n#endif\n  return;\n}\n\n/************** End of parse.c ***********************************************/\n/************** Begin file tokenize.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that splits an SQL input string up into\n** individual tokens and sends those tokens one-by-one over to the\n** parser for analysis.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include <stdlib.h> */\n\n/* Character classes for tokenizing\n**\n** In the sqlite3GetToken() function, a switch() on aiClass[c] is implemented\n** using a lookup table, whereas a switch() directly on c uses a binary search.\n** The lookup table is much faster.  To maximize speed, and to ensure that\n** a lookup table is used, all of the classes need to be small integers and\n** all of them need to be used within the switch.\n*/\n#define CC_X          0    /* The letter 'x', or start of BLOB literal */\n#define CC_KYWD       1    /* Alphabetics or '_'.  Usable in a keyword */\n#define CC_ID         2    /* unicode characters usable in IDs */\n#define CC_DIGIT      3    /* Digits */\n#define CC_DOLLAR     4    /* '$' */\n#define CC_VARALPHA   5    /* '@', '#', ':'.  Alphabetic SQL variables */\n#define CC_VARNUM     6    /* '?'.  Numeric SQL variables */\n#define CC_SPACE      7    /* Space characters */\n#define CC_QUOTE      8    /* '\"', '\\'', or '`'.  String literals, quoted ids */\n#define CC_QUOTE2     9    /* '['.   [...] style quoted ids */\n#define CC_PIPE      10    /* '|'.   Bitwise OR or concatenate */\n#define CC_MINUS     11    /* '-'.  Minus or SQL-style comment */\n#define CC_LT        12    /* '<'.  Part of < or <= or <> */\n#define CC_GT        13    /* '>'.  Part of > or >= */\n#define CC_EQ        14    /* '='.  Part of = or == */\n#define CC_BANG      15    /* '!'.  Part of != */\n#define CC_SLASH     16    /* '/'.  / or c-style comment */\n#define CC_LP        17    /* '(' */\n#define CC_RP        18    /* ')' */\n#define CC_SEMI      19    /* ';' */\n#define CC_PLUS      20    /* '+' */\n#define CC_STAR      21    /* '*' */\n#define CC_PERCENT   22    /* '%' */\n#define CC_COMMA     23    /* ',' */\n#define CC_AND       24    /* '&' */\n#define CC_TILDA     25    /* '~' */\n#define CC_DOT       26    /* '.' */\n#define CC_ILLEGAL   27    /* Illegal character */\n\nstatic const unsigned char aiClass[] = {\n#ifdef SQLITE_ASCII\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   27, 27, 27, 27, 27, 27, 27, 27, 27,  7,  7, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */    7, 15,  8,  5,  4, 22, 24,  8, 17, 18, 21, 20, 23, 11, 26, 16,\n/* 3x */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  5, 19, 12, 14, 13,  6,\n/* 4x */    5,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 5x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  9, 27, 27, 27,  1,\n/* 6x */    8,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 7x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1, 27, 10, 27, 25, 27,\n/* 8x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* 9x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ax */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Bx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Cx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Dx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ex */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Fx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2\n#endif\n#ifdef SQLITE_EBCDIC\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 3x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 4x */    7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 12, 17, 20, 10,\n/* 5x */   24, 27, 27, 27, 27, 27, 27, 27, 27, 27, 15,  4, 21, 18, 19, 27,\n/* 6x */   11, 16, 27, 27, 27, 27, 27, 27, 27, 27, 27, 23, 22,  1, 13,  6,\n/* 7x */   27, 27, 27, 27, 27, 27, 27, 27, 27,  8,  5,  5,  5,  8, 14,  8,\n/* 8x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* 9x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ax */   27, 25,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Bx */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  9, 27, 27, 27, 27, 27,\n/* Cx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Dx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ex */   27, 27,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Fx */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3, 27, 27, 27, 27, 27, 27,\n#endif\n};\n\n/*\n** The charMap() macro maps alphabetic characters (only) into their\n** lower-case ASCII equivalent.  On ASCII machines, this is just\n** an upper-to-lower case map.  On EBCDIC machines we also need\n** to adjust the encoding.  The mapping is only valid for alphabetics\n** which are the only characters for which this feature is used. \n**\n** Used by keywordhash.h\n*/\n#ifdef SQLITE_ASCII\n# define charMap(X) sqlite3UpperToLower[(unsigned char)X]\n#endif\n#ifdef SQLITE_EBCDIC\n# define charMap(X) ebcdicToAscii[(unsigned char)X]\nconst unsigned char ebcdicToAscii[] = {\n/* 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 0x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 1x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 2x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 3x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 4x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 5x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 95,  0,  0,  /* 6x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 7x */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* 8x */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* 9x */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ax */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Bx */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* Cx */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* Dx */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ex */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Fx */\n};\n#endif\n\n/*\n** The sqlite3KeywordCode function looks up an identifier to determine if\n** it is a keyword.  If it is a keyword, the token code of that keyword is \n** returned.  If the input is not a keyword, TK_ID is returned.\n**\n** The implementation of this routine was generated by a program,\n** mkkeywordhash.c, located in the tool subdirectory of the distribution.\n** The output of the mkkeywordhash.c program is written into a file\n** named keywordhash.h and then included into this source file by\n** the #include below.\n*/\n/************** Include keywordhash.h in the middle of tokenize.c ************/\n/************** Begin file keywordhash.h *************************************/\n/***** This file contains automatically generated code ******\n**\n** The code in this file has been automatically generated by\n**\n**   sqlite/tool/mkkeywordhash.c\n**\n** The code in this file implements a function that determines whether\n** or not a given identifier is really an SQL keyword.  The same thing\n** might be implemented more directly using a hand-written hash table.\n** But by using this automatically generated code, the size of the code\n** is substantially reduced.  This is important for embedded applications\n** on platforms with limited memory.\n*/\n/* Hash score: 182 */\n/* zKWText[] encodes 834 bytes of keyword text in 554 bytes */\n/*   REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT       */\n/*   ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE         */\n/*   XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY         */\n/*   UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE         */\n/*   BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH     */\n/*   IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN     */\n/*   WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT         */\n/*   CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL        */\n/*   FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWUNIONUSING        */\n/*   VACUUMVIEWINITIALLY                                                */\nstatic const char zKWText[553] = {\n  'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',\n  'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',\n  'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',\n  'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',\n  'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',\n  'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',\n  'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',\n  'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',\n  'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',\n  'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',\n  'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',\n  'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',\n  'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',\n  'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',\n  'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',\n  'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',\n  'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',\n  'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',\n  'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',\n  'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',\n  'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',\n  'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',\n  'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',\n  'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',\n  'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',\n  'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',\n  'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',\n  'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',\n  'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',\n  'O','W','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U','M',\n  'V','I','E','W','I','N','I','T','I','A','L','L','Y',\n};\n/* aKWHash[i] is the hash value for the i-th keyword */\nstatic const unsigned char aKWHash[127] = {\n    76, 105, 117,  74,   0,  45,   0,   0,  82,   0,  77,   0,   0,\n    42,  12,  78,  15,   0, 116,  85,  54, 112,   0,  19,   0,   0,\n   121,   0, 119, 115,   0,  22,  93,   0,   9,   0,   0,  70,  71,\n     0,  69,   6,   0,  48,  90, 102,   0, 118, 101,   0,   0,  44,\n     0, 103,  24,   0,  17,   0, 122,  53,  23,   0,   5, 110,  25,\n    96,   0,   0, 124, 106,  60, 123,  57,  28,  55,   0,  91,   0,\n   100,  26,   0,  99,   0,   0,   0,  95,  92,  97,  88, 109,  14,\n    39, 108,   0,  81,   0,  18,  89, 111,  32,   0, 120,  80, 113,\n    62,  46,  84,   0,   0,  94,  40,  59, 114,   0,  36,   0,   0,\n    29,   0,  86,  63,  64,   0,  20,  61,   0,  56,\n};\n/* aKWNext[] forms the hash collision chain.  If aKWHash[i]==0\n** then the i-th keyword has no more hash collisions.  Otherwise,\n** the next keyword with the same hash is aKWHash[i]-1. */\nstatic const unsigned char aKWNext[124] = {\n     0,   0,   0,   0,   4,   0,   0,   0,   0,   0,   0,   0,   0,\n     0,   2,   0,   0,   0,   0,   0,   0,  13,   0,   0,   0,   0,\n     0,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,\n     0,   0,   0,   0,  33,   0,  21,   0,   0,   0,   0,   0,  50,\n     0,  43,   3,  47,   0,   0,   0,   0,  30,   0,  58,   0,  38,\n     0,   0,   0,   1,  66,   0,   0,  67,   0,  41,   0,   0,   0,\n     0,   0,   0,  49,  65,   0,   0,   0,   0,  31,  52,  16,  34,\n    10,   0,   0,   0,   0,   0,   0,   0,  11,  72,  79,   0,   8,\n     0, 104,  98,   0, 107,   0,  87,   0,  75,  51,   0,  27,  37,\n    73,  83,   0,  35,  68,   0,   0,\n};\n/* aKWLen[i] is the length (in bytes) of the i-th keyword */\nstatic const unsigned char aKWLen[124] = {\n     7,   7,   5,   4,   6,   4,   5,   3,   6,   7,   3,   6,   6,\n     7,   7,   3,   8,   2,   6,   5,   4,   4,   3,  10,   4,   6,\n    11,   6,   2,   7,   5,   5,   9,   6,   9,   9,   7,  10,  10,\n     4,   6,   2,   3,   9,   4,   2,   6,   5,   7,   4,   5,   7,\n     6,   6,   5,   6,   5,   5,   9,   7,   7,   3,   2,   4,   4,\n     7,   3,   6,   4,   7,   6,  12,   6,   9,   4,   6,   5,   4,\n     7,   6,   5,   6,   7,   5,   4,   5,   6,   5,   7,   3,   7,\n    13,   2,   2,   4,   6,   6,   8,   5,  17,  12,   7,   8,   8,\n     2,   4,   4,   4,   4,   4,   2,   2,   6,   5,   8,   5,   8,\n     3,   5,   5,   6,   4,   9,   3,\n};\n/* aKWOffset[i] is the index into zKWText[] of the start of\n** the text for the i-th keyword. */\nstatic const unsigned short int aKWOffset[124] = {\n     0,   2,   2,   8,   9,  14,  16,  20,  23,  25,  25,  29,  33,\n    36,  41,  46,  48,  53,  54,  59,  62,  65,  67,  69,  78,  81,\n    86,  91,  95,  96, 101, 105, 109, 117, 122, 128, 136, 142, 152,\n   159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,\n   199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,\n   250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,\n   320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,\n   387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,\n   460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,\n   521, 524, 529, 534, 540, 544, 549,\n};\n/* aKWCode[i] is the parser symbol code for the i-th keyword */\nstatic const unsigned char aKWCode[124] = {\n  TK_REINDEX,    TK_INDEXED,    TK_INDEX,      TK_DESC,       TK_ESCAPE,     \n  TK_EACH,       TK_CHECK,      TK_KEY,        TK_BEFORE,     TK_FOREIGN,    \n  TK_FOR,        TK_IGNORE,     TK_LIKE_KW,    TK_EXPLAIN,    TK_INSTEAD,    \n  TK_ADD,        TK_DATABASE,   TK_AS,         TK_SELECT,     TK_TABLE,      \n  TK_JOIN_KW,    TK_THEN,       TK_END,        TK_DEFERRABLE, TK_ELSE,       \n  TK_EXCEPT,     TK_TRANSACTION,TK_ACTION,     TK_ON,         TK_JOIN_KW,    \n  TK_ALTER,      TK_RAISE,      TK_EXCLUSIVE,  TK_EXISTS,     TK_SAVEPOINT,  \n  TK_INTERSECT,  TK_TRIGGER,    TK_REFERENCES, TK_CONSTRAINT, TK_INTO,       \n  TK_OFFSET,     TK_OF,         TK_SET,        TK_TEMP,       TK_TEMP,       \n  TK_OR,         TK_UNIQUE,     TK_QUERY,      TK_WITHOUT,    TK_WITH,       \n  TK_JOIN_KW,    TK_RELEASE,    TK_ATTACH,     TK_HAVING,     TK_GROUP,      \n  TK_UPDATE,     TK_BEGIN,      TK_JOIN_KW,    TK_RECURSIVE,  TK_BETWEEN,    \n  TK_NOTNULL,    TK_NOT,        TK_NO,         TK_NULL,       TK_LIKE_KW,    \n  TK_CASCADE,    TK_ASC,        TK_DELETE,     TK_CASE,       TK_COLLATE,    \n  TK_CREATE,     TK_CTIME_KW,   TK_DETACH,     TK_IMMEDIATE,  TK_JOIN,       \n  TK_INSERT,     TK_MATCH,      TK_PLAN,       TK_ANALYZE,    TK_PRAGMA,     \n  TK_ABORT,      TK_VALUES,     TK_VIRTUAL,    TK_LIMIT,      TK_WHEN,       \n  TK_WHERE,      TK_RENAME,     TK_AFTER,      TK_REPLACE,    TK_AND,        \n  TK_DEFAULT,    TK_AUTOINCR,   TK_TO,         TK_IN,         TK_CAST,       \n  TK_COLUMNKW,   TK_COMMIT,     TK_CONFLICT,   TK_JOIN_KW,    TK_CTIME_KW,   \n  TK_CTIME_KW,   TK_PRIMARY,    TK_DEFERRED,   TK_DISTINCT,   TK_IS,         \n  TK_DROP,       TK_FAIL,       TK_FROM,       TK_JOIN_KW,    TK_LIKE_KW,    \n  TK_BY,         TK_IF,         TK_ISNULL,     TK_ORDER,      TK_RESTRICT,   \n  TK_JOIN_KW,    TK_ROLLBACK,   TK_ROW,        TK_UNION,      TK_USING,      \n  TK_VACUUM,     TK_VIEW,       TK_INITIALLY,  TK_ALL,        \n};\n/* Check to see if z[0..n-1] is a keyword. If it is, write the\n** parser symbol code for that keyword into *pType.  Always\n** return the integer n (the length of the token). */\nstatic int keywordCode(const char *z, int n, int *pType){\n  int i, j;\n  const char *zKW;\n  if( n>=2 ){\n    i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127;\n    for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){\n      if( aKWLen[i]!=n ) continue;\n      j = 0;\n      zKW = &zKWText[aKWOffset[i]];\n#ifdef SQLITE_ASCII\n      while( j<n && (z[j]&~0x20)==zKW[j] ){ j++; }\n#endif\n#ifdef SQLITE_EBCDIC\n      while( j<n && toupper(z[j])==zKW[j] ){ j++; }\n#endif\n      if( j<n ) continue;\n      testcase( i==0 ); /* REINDEX */\n      testcase( i==1 ); /* INDEXED */\n      testcase( i==2 ); /* INDEX */\n      testcase( i==3 ); /* DESC */\n      testcase( i==4 ); /* ESCAPE */\n      testcase( i==5 ); /* EACH */\n      testcase( i==6 ); /* CHECK */\n      testcase( i==7 ); /* KEY */\n      testcase( i==8 ); /* BEFORE */\n      testcase( i==9 ); /* FOREIGN */\n      testcase( i==10 ); /* FOR */\n      testcase( i==11 ); /* IGNORE */\n      testcase( i==12 ); /* REGEXP */\n      testcase( i==13 ); /* EXPLAIN */\n      testcase( i==14 ); /* INSTEAD */\n      testcase( i==15 ); /* ADD */\n      testcase( i==16 ); /* DATABASE */\n      testcase( i==17 ); /* AS */\n      testcase( i==18 ); /* SELECT */\n      testcase( i==19 ); /* TABLE */\n      testcase( i==20 ); /* LEFT */\n      testcase( i==21 ); /* THEN */\n      testcase( i==22 ); /* END */\n      testcase( i==23 ); /* DEFERRABLE */\n      testcase( i==24 ); /* ELSE */\n      testcase( i==25 ); /* EXCEPT */\n      testcase( i==26 ); /* TRANSACTION */\n      testcase( i==27 ); /* ACTION */\n      testcase( i==28 ); /* ON */\n      testcase( i==29 ); /* NATURAL */\n      testcase( i==30 ); /* ALTER */\n      testcase( i==31 ); /* RAISE */\n      testcase( i==32 ); /* EXCLUSIVE */\n      testcase( i==33 ); /* EXISTS */\n      testcase( i==34 ); /* SAVEPOINT */\n      testcase( i==35 ); /* INTERSECT */\n      testcase( i==36 ); /* TRIGGER */\n      testcase( i==37 ); /* REFERENCES */\n      testcase( i==38 ); /* CONSTRAINT */\n      testcase( i==39 ); /* INTO */\n      testcase( i==40 ); /* OFFSET */\n      testcase( i==41 ); /* OF */\n      testcase( i==42 ); /* SET */\n      testcase( i==43 ); /* TEMPORARY */\n      testcase( i==44 ); /* TEMP */\n      testcase( i==45 ); /* OR */\n      testcase( i==46 ); /* UNIQUE */\n      testcase( i==47 ); /* QUERY */\n      testcase( i==48 ); /* WITHOUT */\n      testcase( i==49 ); /* WITH */\n      testcase( i==50 ); /* OUTER */\n      testcase( i==51 ); /* RELEASE */\n      testcase( i==52 ); /* ATTACH */\n      testcase( i==53 ); /* HAVING */\n      testcase( i==54 ); /* GROUP */\n      testcase( i==55 ); /* UPDATE */\n      testcase( i==56 ); /* BEGIN */\n      testcase( i==57 ); /* INNER */\n      testcase( i==58 ); /* RECURSIVE */\n      testcase( i==59 ); /* BETWEEN */\n      testcase( i==60 ); /* NOTNULL */\n      testcase( i==61 ); /* NOT */\n      testcase( i==62 ); /* NO */\n      testcase( i==63 ); /* NULL */\n      testcase( i==64 ); /* LIKE */\n      testcase( i==65 ); /* CASCADE */\n      testcase( i==66 ); /* ASC */\n      testcase( i==67 ); /* DELETE */\n      testcase( i==68 ); /* CASE */\n      testcase( i==69 ); /* COLLATE */\n      testcase( i==70 ); /* CREATE */\n      testcase( i==71 ); /* CURRENT_DATE */\n      testcase( i==72 ); /* DETACH */\n      testcase( i==73 ); /* IMMEDIATE */\n      testcase( i==74 ); /* JOIN */\n      testcase( i==75 ); /* INSERT */\n      testcase( i==76 ); /* MATCH */\n      testcase( i==77 ); /* PLAN */\n      testcase( i==78 ); /* ANALYZE */\n      testcase( i==79 ); /* PRAGMA */\n      testcase( i==80 ); /* ABORT */\n      testcase( i==81 ); /* VALUES */\n      testcase( i==82 ); /* VIRTUAL */\n      testcase( i==83 ); /* LIMIT */\n      testcase( i==84 ); /* WHEN */\n      testcase( i==85 ); /* WHERE */\n      testcase( i==86 ); /* RENAME */\n      testcase( i==87 ); /* AFTER */\n      testcase( i==88 ); /* REPLACE */\n      testcase( i==89 ); /* AND */\n      testcase( i==90 ); /* DEFAULT */\n      testcase( i==91 ); /* AUTOINCREMENT */\n      testcase( i==92 ); /* TO */\n      testcase( i==93 ); /* IN */\n      testcase( i==94 ); /* CAST */\n      testcase( i==95 ); /* COLUMN */\n      testcase( i==96 ); /* COMMIT */\n      testcase( i==97 ); /* CONFLICT */\n      testcase( i==98 ); /* CROSS */\n      testcase( i==99 ); /* CURRENT_TIMESTAMP */\n      testcase( i==100 ); /* CURRENT_TIME */\n      testcase( i==101 ); /* PRIMARY */\n      testcase( i==102 ); /* DEFERRED */\n      testcase( i==103 ); /* DISTINCT */\n      testcase( i==104 ); /* IS */\n      testcase( i==105 ); /* DROP */\n      testcase( i==106 ); /* FAIL */\n      testcase( i==107 ); /* FROM */\n      testcase( i==108 ); /* FULL */\n      testcase( i==109 ); /* GLOB */\n      testcase( i==110 ); /* BY */\n      testcase( i==111 ); /* IF */\n      testcase( i==112 ); /* ISNULL */\n      testcase( i==113 ); /* ORDER */\n      testcase( i==114 ); /* RESTRICT */\n      testcase( i==115 ); /* RIGHT */\n      testcase( i==116 ); /* ROLLBACK */\n      testcase( i==117 ); /* ROW */\n      testcase( i==118 ); /* UNION */\n      testcase( i==119 ); /* USING */\n      testcase( i==120 ); /* VACUUM */\n      testcase( i==121 ); /* VIEW */\n      testcase( i==122 ); /* INITIALLY */\n      testcase( i==123 ); /* ALL */\n      *pType = aKWCode[i];\n      break;\n    }\n  }\n  return n;\n}\nSQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){\n  int id = TK_ID;\n  keywordCode((char*)z, n, &id);\n  return id;\n}\n#define SQLITE_N_KEYWORD 124\n\n/************** End of keywordhash.h *****************************************/\n/************** Continuing where we left off in tokenize.c *******************/\n\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** For EBCDIC, the rules are more complex but have the same\n** end result.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identifiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 4x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  /* 5x */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0,  /* 6x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,  /* 7x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,  /* 8x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,  /* 9x */\n    1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,  /* Ax */\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* Bx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Cx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Dx */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Ex */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0,  /* Fx */\n};\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n\n/* Make the IdChar function accessible from ctime.c */\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_PRIVATE int sqlite3IsIdChar(u8 c){ return IdChar(c); }\n#endif\n\n\n/*\n** Return the length (in bytes) of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nSQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){\n  int i, c;\n  switch( aiClass[*z] ){  /* Switch on the character-class of the first byte\n                          ** of the token. See the comment on the CC_ defines\n                          ** above. */\n    case CC_SPACE: {\n      testcase( z[0]==' ' );\n      testcase( z[0]=='\\t' );\n      testcase( z[0]=='\\n' );\n      testcase( z[0]=='\\f' );\n      testcase( z[0]=='\\r' );\n      for(i=1; sqlite3Isspace(z[i]); i++){}\n      *tokenType = TK_SPACE;\n      return i;\n    }\n    case CC_MINUS: {\n      if( z[1]=='-' ){\n        for(i=2; (c=z[i])!=0 && c!='\\n'; i++){}\n        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n        return i;\n      }\n      *tokenType = TK_MINUS;\n      return 1;\n    }\n    case CC_LP: {\n      *tokenType = TK_LP;\n      return 1;\n    }\n    case CC_RP: {\n      *tokenType = TK_RP;\n      return 1;\n    }\n    case CC_SEMI: {\n      *tokenType = TK_SEMI;\n      return 1;\n    }\n    case CC_PLUS: {\n      *tokenType = TK_PLUS;\n      return 1;\n    }\n    case CC_STAR: {\n      *tokenType = TK_STAR;\n      return 1;\n    }\n    case CC_SLASH: {\n      if( z[1]!='*' || z[2]==0 ){\n        *tokenType = TK_SLASH;\n        return 1;\n      }\n      for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}\n      if( c ) i++;\n      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n      return i;\n    }\n    case CC_PERCENT: {\n      *tokenType = TK_REM;\n      return 1;\n    }\n    case CC_EQ: {\n      *tokenType = TK_EQ;\n      return 1 + (z[1]=='=');\n    }\n    case CC_LT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_LE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_NE;\n        return 2;\n      }else if( c=='<' ){\n        *tokenType = TK_LSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_LT;\n        return 1;\n      }\n    }\n    case CC_GT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_GE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_RSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_GT;\n        return 1;\n      }\n    }\n    case CC_BANG: {\n      if( z[1]!='=' ){\n        *tokenType = TK_ILLEGAL;\n        return 1;\n      }else{\n        *tokenType = TK_NE;\n        return 2;\n      }\n    }\n    case CC_PIPE: {\n      if( z[1]!='|' ){\n        *tokenType = TK_BITOR;\n        return 1;\n      }else{\n        *tokenType = TK_CONCAT;\n        return 2;\n      }\n    }\n    case CC_COMMA: {\n      *tokenType = TK_COMMA;\n      return 1;\n    }\n    case CC_AND: {\n      *tokenType = TK_BITAND;\n      return 1;\n    }\n    case CC_TILDA: {\n      *tokenType = TK_BITNOT;\n      return 1;\n    }\n    case CC_QUOTE: {\n      int delim = z[0];\n      testcase( delim=='`' );\n      testcase( delim=='\\'' );\n      testcase( delim=='\"' );\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      if( c=='\\'' ){\n        *tokenType = TK_STRING;\n        return i+1;\n      }else if( c!=0 ){\n        *tokenType = TK_ID;\n        return i+1;\n      }else{\n        *tokenType = TK_ILLEGAL;\n        return i;\n      }\n    }\n    case CC_DOT: {\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( !sqlite3Isdigit(z[1]) )\n#endif\n      {\n        *tokenType = TK_DOT;\n        return 1;\n      }\n      /* If the next character is a digit, this is a floating point\n      ** number that begins with \".\".  Fall thru into the next case */\n    }\n    case CC_DIGIT: {\n      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );\n      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );\n      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );\n      testcase( z[0]=='9' );\n      *tokenType = TK_INTEGER;\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){\n        for(i=3; sqlite3Isxdigit(z[i]); i++){}\n        return i;\n      }\n#endif\n      for(i=0; sqlite3Isdigit(z[i]); i++){}\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( z[i]=='.' ){\n        i++;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n      if( (z[i]=='e' || z[i]=='E') &&\n           ( sqlite3Isdigit(z[i+1]) \n            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))\n           )\n      ){\n        i += 2;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n#endif\n      while( IdChar(z[i]) ){\n        *tokenType = TK_ILLEGAL;\n        i++;\n      }\n      return i;\n    }\n    case CC_QUOTE2: {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = c==']' ? TK_ID : TK_ILLEGAL;\n      return i;\n    }\n    case CC_VARNUM: {\n      *tokenType = TK_VARIABLE;\n      for(i=1; sqlite3Isdigit(z[i]); i++){}\n      return i;\n    }\n    case CC_DOLLAR:\n    case CC_VARALPHA: {\n      int n = 0;\n      testcase( z[0]=='$' );  testcase( z[0]=='@' );\n      testcase( z[0]==':' );  testcase( z[0]=='#' );\n      *tokenType = TK_VARIABLE;\n      for(i=1; (c=z[i])!=0; i++){\n        if( IdChar(c) ){\n          n++;\n#ifndef SQLITE_OMIT_TCL_VARIABLE\n        }else if( c=='(' && n>0 ){\n          do{\n            i++;\n          }while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );\n          if( c==')' ){\n            i++;\n          }else{\n            *tokenType = TK_ILLEGAL;\n          }\n          break;\n        }else if( c==':' && z[i+1]==':' ){\n          i++;\n#endif\n        }else{\n          break;\n        }\n      }\n      if( n==0 ) *tokenType = TK_ILLEGAL;\n      return i;\n    }\n    case CC_KYWD: {\n      for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}\n      if( IdChar(z[i]) ){\n        /* This token started out using characters that can appear in keywords,\n        ** but z[i] is a character not allowed within keywords, so this must\n        ** be an identifier instead */\n        i++;\n        break;\n      }\n      *tokenType = TK_ID;\n      return keywordCode((char*)z, i, tokenType);\n    }\n    case CC_X: {\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n      testcase( z[0]=='x' ); testcase( z[0]=='X' );\n      if( z[1]=='\\'' ){\n        *tokenType = TK_BLOB;\n        for(i=2; sqlite3Isxdigit(z[i]); i++){}\n        if( z[i]!='\\'' || i%2 ){\n          *tokenType = TK_ILLEGAL;\n          while( z[i] && z[i]!='\\'' ){ i++; }\n        }\n        if( z[i] ) i++;\n        return i;\n      }\n#endif\n      /* If it is not a BLOB literal, then it must be an ID, since no\n      ** SQL keywords start with the letter 'x'.  Fall through */\n    }\n    case CC_ID: {\n      i = 1;\n      break;\n    }\n    default: {\n      *tokenType = TK_ILLEGAL;\n      return 1;\n    }\n  }\n  while( IdChar(z[i]) ){ i++; }\n  *tokenType = TK_ID;\n  return i;\n}\n\n/*\n** Run the parser on the given SQL string.  The parser structure is\n** passed in.  An SQLITE_ status code is returned.  If an error occurs\n** then an and attempt is made to write an error message into \n** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that\n** error message.\n*/\nSQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){\n  int nErr = 0;                   /* Number of errors encountered */\n  void *pEngine;                  /* The LEMON-generated LALR(1) parser */\n  int n = 0;                      /* Length of the next token token */\n  int tokenType;                  /* type of the next token */\n  int lastTokenParsed = -1;       /* type of the previous token */\n  sqlite3 *db = pParse->db;       /* The database connection */\n  int mxSqlLen;                   /* Max length of an SQL string */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  yyParser sEngine;    /* Space to hold the Lemon-generated Parser object */\n#endif\n\n  assert( zSql!=0 );\n  mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n  pParse->rc = SQLITE_OK;\n  pParse->zTail = zSql;\n  assert( pzErrMsg!=0 );\n  /* sqlite3ParserTrace(stdout, \"parser: \"); */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  pEngine = &sEngine;\n  sqlite3ParserInit(pEngine);\n#else\n  pEngine = sqlite3ParserAlloc(sqlite3Malloc);\n  if( pEngine==0 ){\n    sqlite3OomFault(db);\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n  assert( pParse->pNewTable==0 );\n  assert( pParse->pNewTrigger==0 );\n  assert( pParse->nVar==0 );\n  assert( pParse->pVList==0 );\n  while( 1 ){\n    if( zSql[0]!=0 ){\n      n = sqlite3GetToken((u8*)zSql, &tokenType);\n      mxSqlLen -= n;\n      if( mxSqlLen<0 ){\n        pParse->rc = SQLITE_TOOBIG;\n        break;\n      }\n    }else{\n      /* Upon reaching the end of input, call the parser two more times\n      ** with tokens TK_SEMI and 0, in that order. */\n      if( lastTokenParsed==TK_SEMI ){\n        tokenType = 0;\n      }else if( lastTokenParsed==0 ){\n        break;\n      }else{\n        tokenType = TK_SEMI;\n      }\n      zSql -= n;\n    }\n    if( tokenType>=TK_SPACE ){\n      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );\n      if( db->u1.isInterrupted ){\n        pParse->rc = SQLITE_INTERRUPT;\n        break;\n      }\n      if( tokenType==TK_ILLEGAL ){\n        sqlite3ErrorMsg(pParse, \"unrecognized token: \\\"%.*s\\\"\", n, zSql);\n        break;\n      }\n      zSql += n;\n    }else{\n      pParse->sLastToken.z = zSql;\n      pParse->sLastToken.n = n;\n      sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);\n      lastTokenParsed = tokenType;\n      zSql += n;\n      if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;\n    }\n  }\n  assert( nErr==0 );\n  pParse->zTail = zSql;\n#ifdef YYTRACKMAXSTACKDEPTH\n  sqlite3_mutex_enter(sqlite3MallocMutex());\n  sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,\n      sqlite3ParserStackPeak(pEngine)\n  );\n  sqlite3_mutex_leave(sqlite3MallocMutex());\n#endif /* YYDEBUG */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  sqlite3ParserFinalize(pEngine);\n#else\n  sqlite3ParserFree(pEngine, sqlite3_free);\n#endif\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){\n    pParse->zErrMsg = sqlite3MPrintf(db, \"%s\", sqlite3ErrStr(pParse->rc));\n  }\n  assert( pzErrMsg!=0 );\n  if( pParse->zErrMsg ){\n    *pzErrMsg = pParse->zErrMsg;\n    sqlite3_log(pParse->rc, \"%s\", *pzErrMsg);\n    pParse->zErrMsg = 0;\n    nErr++;\n  }\n  if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){\n    sqlite3VdbeDelete(pParse->pVdbe);\n    pParse->pVdbe = 0;\n  }\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  if( pParse->nested==0 ){\n    sqlite3DbFree(db, pParse->aTableLock);\n    pParse->aTableLock = 0;\n    pParse->nTableLock = 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_free(pParse->apVtabLock);\n#endif\n\n  if( !IN_DECLARE_VTAB ){\n    /* If the pParse->declareVtab flag is set, do not delete any table \n    ** structure built up in pParse->pNewTable. The calling code (see vtab.c)\n    ** will take responsibility for freeing the Table structure.\n    */\n    sqlite3DeleteTable(db, pParse->pNewTable);\n  }\n\n  if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);\n  sqlite3DeleteTrigger(db, pParse->pNewTrigger);\n  sqlite3DbFree(db, pParse->pVList);\n  while( pParse->pAinc ){\n    AutoincInfo *p = pParse->pAinc;\n    pParse->pAinc = p->pNext;\n    sqlite3DbFreeNN(db, p);\n  }\n  while( pParse->pZombieTab ){\n    Table *p = pParse->pZombieTab;\n    pParse->pZombieTab = p->pNextZombie;\n    sqlite3DeleteTable(db, p);\n  }\n  assert( nErr==0 || pParse->rc!=SQLITE_OK );\n  return nErr;\n}\n\n/************** End of tokenize.c ********************************************/\n/************** Begin file complete.c ****************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that implements the sqlite3_complete() API.\n** This code used to be part of the tokenizer.c source file.  But by\n** separating it out, the code will be automatically omitted from\n** static links that do not use it.\n*/\n/* #include \"sqliteInt.h\" */\n#ifndef SQLITE_OMIT_COMPLETE\n\n/*\n** This is defined in tokenize.c.  We just have to import the definition.\n*/\n#ifndef SQLITE_AMALGAMATION\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nSQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n#endif /* SQLITE_AMALGAMATION */\n\n\n/*\n** Token types used by the sqlite3_complete() routine.  See the header\n** comments on that procedure for additional information.\n*/\n#define tkSEMI    0\n#define tkWS      1\n#define tkOTHER   2\n#ifndef SQLITE_OMIT_TRIGGER\n#define tkEXPLAIN 3\n#define tkCREATE  4\n#define tkTEMP    5\n#define tkTRIGGER 6\n#define tkEND     7\n#endif\n\n/*\n** Return TRUE if the given SQL string ends in a semicolon.\n**\n** Special handling is require for CREATE TRIGGER statements.\n** Whenever the CREATE TRIGGER keywords are seen, the statement\n** must end with \";END;\".\n**\n** This implementation uses a state machine with 8 states:\n**\n**   (0) INVALID   We have not yet seen a non-whitespace character.\n**\n**   (1) START     At the beginning or end of an SQL statement.  This routine\n**                 returns 1 if it ends in the START state and 0 if it ends\n**                 in any other state.\n**\n**   (2) NORMAL    We are in the middle of statement which ends with a single\n**                 semicolon.\n**\n**   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of \n**                 a statement.\n**\n**   (4) CREATE    The keyword CREATE has been seen at the beginning of a\n**                 statement, possibly preceded by EXPLAIN and/or followed by\n**                 TEMP or TEMPORARY\n**\n**   (5) TRIGGER   We are in the middle of a trigger definition that must be\n**                 ended by a semicolon, the keyword END, and another semicolon.\n**\n**   (6) SEMI      We've seen the first semicolon in the \";END;\" that occurs at\n**                 the end of a trigger definition.\n**\n**   (7) END       We've seen the \";END\" of the \";END;\" that occurs at the end\n**                 of a trigger definition.\n**\n** Transitions between states above are determined by tokens extracted\n** from the input.  The following tokens are significant:\n**\n**   (0) tkSEMI      A semicolon.\n**   (1) tkWS        Whitespace.\n**   (2) tkOTHER     Any other SQL token.\n**   (3) tkEXPLAIN   The \"explain\" keyword.\n**   (4) tkCREATE    The \"create\" keyword.\n**   (5) tkTEMP      The \"temp\" or \"temporary\" keyword.\n**   (6) tkTRIGGER   The \"trigger\" keyword.\n**   (7) tkEND       The \"end\" keyword.\n**\n** Whitespace never causes a state transition and is always ignored.\n** This means that a SQL string of all whitespace is invalid.\n**\n** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed\n** to recognize the end of a trigger can be omitted.  All we have to do\n** is look for a semicolon that is not part of an string or comment.\n*/\nSQLITE_API int sqlite3_complete(const char *zSql){\n  u8 state = 0;   /* Current state, using numbers defined in header comment */\n  u8 token;       /* Value of the next token */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* A complex statement machine used to detect the end of a CREATE TRIGGER\n  ** statement.  This is the normal case.\n  */\n  static const u8 trans[8][8] = {\n                     /* Token:                                                */\n     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */\n     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },\n     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },\n     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },\n     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },\n     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },\n     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },\n     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },\n     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },\n  };\n#else\n  /* If triggers are not supported by this compile then the statement machine\n  ** used to detect the end of a statement is much simpler\n  */\n  static const u8 trans[3][3] = {\n                     /* Token:           */\n     /* State:       **  SEMI  WS  OTHER */\n     /* 0 INVALID: */ {    1,  0,     2, },\n     /* 1   START: */ {    1,  1,     2, },\n     /* 2  NORMAL: */ {    1,  2,     2, },\n  };\n#endif /* SQLITE_OMIT_TRIGGER */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zSql==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  while( *zSql ){\n    switch( *zSql ){\n      case ';': {  /* A semicolon */\n        token = tkSEMI;\n        break;\n      }\n      case ' ':\n      case '\\r':\n      case '\\t':\n      case '\\n':\n      case '\\f': {  /* White space is ignored */\n        token = tkWS;\n        break;\n      }\n      case '/': {   /* C-style comments */\n        if( zSql[1]!='*' ){\n          token = tkOTHER;\n          break;\n        }\n        zSql += 2;\n        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }\n        if( zSql[0]==0 ) return 0;\n        zSql++;\n        token = tkWS;\n        break;\n      }\n      case '-': {   /* SQL-style comments from \"--\" to end of line */\n        if( zSql[1]!='-' ){\n          token = tkOTHER;\n          break;\n        }\n        while( *zSql && *zSql!='\\n' ){ zSql++; }\n        if( *zSql==0 ) return state==1;\n        token = tkWS;\n        break;\n      }\n      case '[': {   /* Microsoft-style identifiers in [...] */\n        zSql++;\n        while( *zSql && *zSql!=']' ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      case '`':     /* Grave-accent quoted symbols used by MySQL */\n      case '\"':     /* single- and double-quoted strings */\n      case '\\'': {\n        int c = *zSql;\n        zSql++;\n        while( *zSql && *zSql!=c ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      default: {\n#ifdef SQLITE_EBCDIC\n        unsigned char c;\n#endif\n        if( IdChar((u8)*zSql) ){\n          /* Keywords and unquoted identifiers */\n          int nId;\n          for(nId=1; IdChar(zSql[nId]); nId++){}\n#ifdef SQLITE_OMIT_TRIGGER\n          token = tkOTHER;\n#else\n          switch( *zSql ){\n            case 'c': case 'C': {\n              if( nId==6 && sqlite3StrNICmp(zSql, \"create\", 6)==0 ){\n                token = tkCREATE;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 't': case 'T': {\n              if( nId==7 && sqlite3StrNICmp(zSql, \"trigger\", 7)==0 ){\n                token = tkTRIGGER;\n              }else if( nId==4 && sqlite3StrNICmp(zSql, \"temp\", 4)==0 ){\n                token = tkTEMP;\n              }else if( nId==9 && sqlite3StrNICmp(zSql, \"temporary\", 9)==0 ){\n                token = tkTEMP;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 'e':  case 'E': {\n              if( nId==3 && sqlite3StrNICmp(zSql, \"end\", 3)==0 ){\n                token = tkEND;\n              }else\n#ifndef SQLITE_OMIT_EXPLAIN\n              if( nId==7 && sqlite3StrNICmp(zSql, \"explain\", 7)==0 ){\n                token = tkEXPLAIN;\n              }else\n#endif\n              {\n                token = tkOTHER;\n              }\n              break;\n            }\n            default: {\n              token = tkOTHER;\n              break;\n            }\n          }\n#endif /* SQLITE_OMIT_TRIGGER */\n          zSql += nId-1;\n        }else{\n          /* Operators and special symbols */\n          token = tkOTHER;\n        }\n        break;\n      }\n    }\n    state = trans[state][token];\n    zSql++;\n  }\n  return state==1;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine is the same as the sqlite3_complete() routine described\n** above, except that the parameter is required to be UTF-16 encoded, not\n** UTF-8.\n*/\nSQLITE_API int sqlite3_complete16(const void *zSql){\n  sqlite3_value *pVal;\n  char const *zSql8;\n  int rc;\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zSql8 ){\n    rc = sqlite3_complete(zSql8);\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_COMPLETE */\n\n/************** End of complete.c ********************************************/\n/************** Begin file main.c ********************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n/* #include \"sqliteInt.h\" */\n\n#ifdef SQLITE_ENABLE_FTS3\n/************** Include fts3.h in the middle of main.c ***********************/\n/************** Begin file fts3.h ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** FTS3 library.  All it does is declare the sqlite3Fts3Init() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of fts3.h ************************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_RTREE\n/************** Include rtree.h in the middle of main.c **********************/\n/************** Begin file rtree.h *******************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** RTREE library.  All it does is declare the sqlite3RtreeInit() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n/************** End of rtree.h ***********************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_ICU\n/************** Include sqliteicu.h in the middle of main.c ******************/\n/************** Begin file sqliteicu.h ***************************************/\n/*\n** 2008 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file is used by programs that want to link against the\n** ICU extension.  All it does is declare the sqlite3IcuInit() interface.\n*/\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif  /* __cplusplus */\n\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db);\n\n#if 0\n}  /* extern \"C\" */\n#endif  /* __cplusplus */\n\n\n/************** End of sqliteicu.h *******************************************/\n/************** Continuing where we left off in main.c ***********************/\n#endif\n#ifdef SQLITE_ENABLE_JSON1\nSQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_STMTVTAB\nSQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_FTS5\nSQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);\n#endif\n\n#ifndef SQLITE_AMALGAMATION\n/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant\n** contains the text of SQLITE_VERSION macro. \n*/\nSQLITE_API const char sqlite3_version[] = SQLITE_VERSION;\n#endif\n\n/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns\n** a pointer to the to the sqlite3_version[] string constant. \n*/\nSQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }\n\n/* IMPLEMENTATION-OF: R-25063-23286 The sqlite3_sourceid() function returns a\n** pointer to a string constant whose value is the same as the\n** SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using\n** an edited copy of the amalgamation, then the last four characters of\n** the hash might be different from SQLITE_SOURCE_ID.\n*/\n/* SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } */\n\n/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function\n** returns an integer equal to SQLITE_VERSION_NUMBER.\n*/\nSQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }\n\n/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns\n** zero if and only if SQLite was compiled with mutexing code omitted due to\n** the SQLITE_THREADSAFE compile-time option being set to 0.\n*/\nSQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }\n\n/*\n** When compiling the test fixture or with debugging enabled (on Win32),\n** this variable being set to non-zero will cause OSTRACE macros to emit\n** extra diagnostic information.\n*/\n#ifdef SQLITE_HAVE_OS_TRACE\n# ifndef SQLITE_DEBUG_OS_TRACE\n#   define SQLITE_DEBUG_OS_TRACE 0\n# endif\n  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** If the following function pointer is not NULL and if\n** SQLITE_ENABLE_IOTRACE is enabled, then messages describing\n** I/O active are written using this function.  These messages\n** are intended for debugging activity only.\n*/\nSQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;\n#endif\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** temporary files.\n**\n** See also the \"PRAGMA temp_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_temp_directory = 0;\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** all database files specified with a relative pathname.\n**\n** See also the \"PRAGMA data_store_directory\" SQL command.\n*/\nSQLITE_API char *sqlite3_data_directory = 0;\n\n/*\n** Initialize SQLite.  \n**\n** This routine must be called to initialize the memory allocation,\n** VFS, and mutex subsystems prior to doing any serious work with\n** SQLite.  But as long as you do not compile with SQLITE_OMIT_AUTOINIT\n** this routine will be called automatically by key routines such as\n** sqlite3_open().  \n**\n** This routine is a no-op except on its very first call for the process,\n** or for the first call after a call to sqlite3_shutdown.\n**\n** The first thread to call this routine runs the initialization to\n** completion.  If subsequent threads call this routine before the first\n** thread has finished the initialization process, then the subsequent\n** threads must block until the first thread finishes with the initialization.\n**\n** The first thread might call this routine recursively.  Recursive\n** calls to this routine should not block, of course.  Otherwise the\n** initialization process would never complete.\n**\n** Let X be the first thread to enter this routine.  Let Y be some other\n** thread.  Then while the initial invocation of this routine by X is\n** incomplete, it is required that:\n**\n**    *  Calls to this routine from Y must block until the outer-most\n**       call by X completes.\n**\n**    *  Recursive calls to this routine from thread X return immediately\n**       without blocking.\n*/\nSQLITE_API int sqlite3_initialize(void){\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )       /* The main static mutex */\n  int rc;                                      /* Result code */\n#ifdef SQLITE_EXTRA_INIT\n  int bRunExtraInit = 0;                       /* Extra initialization needed */\n#endif\n\n#ifdef SQLITE_OMIT_WSD\n  rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  /* If the following assert() fails on some obscure processor/compiler\n  ** combination, the work-around is to set the correct pointer\n  ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */\n  assert( SQLITE_PTRSIZE==sizeof(char*) );\n\n  /* If SQLite is already completely initialized, then this call\n  ** to sqlite3_initialize() should be a no-op.  But the initialization\n  ** must be complete.  So isInit must not be set until the very end\n  ** of this routine.\n  */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;\n\n  /* Make sure the mutex subsystem is initialized.  If unable to \n  ** initialize the mutex subsystem, return early with the error.\n  ** If the system is so sick that we are unable to allocate a mutex,\n  ** there is not much SQLite is going to be able to do.\n  **\n  ** The mutex subsystem must take care of serializing its own\n  ** initialization.\n  */\n  rc = sqlite3MutexInit();\n  if( rc ) return rc;\n\n  /* Initialize the malloc() system and the recursive pInitMutex mutex.\n  ** This operation is protected by the STATIC_MASTER mutex.  Note that\n  ** MutexAlloc() is called for a static mutex prior to initializing the\n  ** malloc subsystem - this implies that the allocation of a static\n  ** mutex must not require support from the malloc subsystem.\n  */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.isMutexInit = 1;\n  if( !sqlite3GlobalConfig.isMallocInit ){\n    rc = sqlite3MallocInit();\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.isMallocInit = 1;\n    if( !sqlite3GlobalConfig.pInitMutex ){\n      sqlite3GlobalConfig.pInitMutex =\n           sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n      if( sqlite3GlobalConfig.bCoreMutex && !sqlite3GlobalConfig.pInitMutex ){\n        rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.nRefInitMutex++;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* If rc is not SQLITE_OK at this point, then either the malloc\n  ** subsystem could not be initialized or the system failed to allocate\n  ** the pInitMutex mutex. Return an error in either case.  */\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Do the rest of the initialization under the recursive mutex so\n  ** that we will be able to handle recursive calls into\n  ** sqlite3_initialize().  The recursive calls normally come through\n  ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other\n  ** recursive calls might also be possible.\n  **\n  ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls\n  ** to the xInit method, so the xInit method need not be threadsafe.\n  **\n  ** The following mutex is what serializes access to the appdef pcache xInit\n  ** methods.  The sqlite3_pcache_methods.xInit() all is embedded in the\n  ** call to sqlite3PcacheInitialize().\n  */\n  sqlite3_mutex_enter(sqlite3GlobalConfig.pInitMutex);\n  if( sqlite3GlobalConfig.isInit==0 && sqlite3GlobalConfig.inProgress==0 ){\n    sqlite3GlobalConfig.inProgress = 1;\n#ifdef SQLITE_ENABLE_SQLLOG\n    {\n      extern void sqlite3_init_sqllog(void);\n      sqlite3_init_sqllog();\n    }\n#endif\n    memset(&sqlite3BuiltinFunctions, 0, sizeof(sqlite3BuiltinFunctions));\n    sqlite3RegisterBuiltinFunctions();\n    if( sqlite3GlobalConfig.isPCacheInit==0 ){\n      rc = sqlite3PcacheInitialize();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3GlobalConfig.isPCacheInit = 1;\n      rc = sqlite3OsInit();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, \n          sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);\n      sqlite3GlobalConfig.isInit = 1;\n#ifdef SQLITE_EXTRA_INIT\n      bRunExtraInit = 1;\n#endif\n    }\n    sqlite3GlobalConfig.inProgress = 0;\n  }\n  sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex);\n\n  /* Go back under the static mutex and clean up the recursive\n  ** mutex to prevent a resource leak.\n  */\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.nRefInitMutex--;\n  if( sqlite3GlobalConfig.nRefInitMutex<=0 ){\n    assert( sqlite3GlobalConfig.nRefInitMutex==0 );\n    sqlite3_mutex_free(sqlite3GlobalConfig.pInitMutex);\n    sqlite3GlobalConfig.pInitMutex = 0;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* The following is just a sanity check to make sure SQLite has\n  ** been compiled correctly.  It is important to run this code, but\n  ** we don't want to run it too often and soak up CPU cycles for no\n  ** reason.  So we run it once during initialization.\n  */\n#ifndef NDEBUG\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  /* This section of code's only \"output\" is via assert() statements. */\n  if ( rc==SQLITE_OK ){\n    u64 x = (((u64)1)<<63)-1;\n    double y;\n    assert(sizeof(x)==8);\n    assert(sizeof(x)==sizeof(y));\n    memcpy(&y, &x, 8);\n    assert( sqlite3IsNaN(y) );\n  }\n#endif\n#endif\n\n  /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT\n  ** compile-time option.\n  */\n#ifdef SQLITE_EXTRA_INIT\n  if( bRunExtraInit ){\n    int SQLITE_EXTRA_INIT(const char*);\n    rc = SQLITE_EXTRA_INIT(0);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Undo the effects of sqlite3_initialize().  Must not be called while\n** there are outstanding database connections or memory allocations or\n** while any part of SQLite is otherwise in use in any thread.  This\n** routine is not threadsafe.  But it is safe to invoke this routine\n** on when SQLite is already shut down.  If SQLite is already shut down\n** when this routine is invoked, then this routine is a harmless no-op.\n*/\nSQLITE_API int sqlite3_shutdown(void){\n#ifdef SQLITE_OMIT_WSD\n  int rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  if( sqlite3GlobalConfig.isInit ){\n#ifdef SQLITE_EXTRA_SHUTDOWN\n    void SQLITE_EXTRA_SHUTDOWN(void);\n    SQLITE_EXTRA_SHUTDOWN();\n#endif\n    sqlite3_os_end();\n    sqlite3_reset_auto_extension();\n    sqlite3GlobalConfig.isInit = 0;\n  }\n  if( sqlite3GlobalConfig.isPCacheInit ){\n    sqlite3PcacheShutdown();\n    sqlite3GlobalConfig.isPCacheInit = 0;\n  }\n  if( sqlite3GlobalConfig.isMallocInit ){\n    sqlite3MallocEnd();\n    sqlite3GlobalConfig.isMallocInit = 0;\n\n#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n    /* The heap subsystem has now been shutdown and these values are supposed\n    ** to be NULL or point to memory that was obtained from sqlite3_malloc(),\n    ** which would rely on that heap subsystem; therefore, make sure these\n    ** values cannot refer to heap memory that was just invalidated when the\n    ** heap subsystem was shutdown.  This is only done if the current call to\n    ** this function resulted in the heap subsystem actually being shutdown.\n    */\n    sqlite3_data_directory = 0;\n    sqlite3_temp_directory = 0;\n#endif\n  }\n  if( sqlite3GlobalConfig.isMutexInit ){\n    sqlite3MutexEnd();\n    sqlite3GlobalConfig.isMutexInit = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This API allows applications to modify the global configuration of\n** the SQLite library at run-time.\n**\n** This routine should only be called when there are no outstanding\n** database connections or memory allocations.  This routine is not\n** threadsafe.  Failure to heed these warnings can lead to unpredictable\n** behavior.\n*/\nSQLITE_API int sqlite3_config(int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n  /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while\n  ** the SQLite library is in use. */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT;\n\n  va_start(ap, op);\n  switch( op ){\n\n    /* Mutex configuration options are only available in a threadsafe\n    ** compile.\n    */\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0  /* IMP: R-54466-46756 */\n    case SQLITE_CONFIG_SINGLETHREAD: {\n      /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to\n      ** Single-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 0;  /* Disable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */\n    case SQLITE_CONFIG_MULTITHREAD: {\n      /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to\n      ** Multi-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */\n    case SQLITE_CONFIG_SERIALIZED: {\n      /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to\n      ** Serialized. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 1;  /* Enable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */\n    case SQLITE_CONFIG_MUTEX: {\n      /* Specify an alternative mutex implementation */\n      sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-14450-37597 */\n    case SQLITE_CONFIG_GETMUTEX: {\n      /* Retrieve the current mutex implementation */\n      *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MALLOC: {\n      /* EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The argument specifies alternative\n      ** low-level memory allocation routines to be used in place of the memory\n      ** allocation routines built into SQLite. */\n      sqlite3GlobalConfig.m = *va_arg(ap, sqlite3_mem_methods*);\n      break;\n    }\n    case SQLITE_CONFIG_GETMALLOC: {\n      /* EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The sqlite3_mem_methods structure is\n      ** filled with the currently defined memory allocation routines. */\n      if( sqlite3GlobalConfig.m.xMalloc==0 ) sqlite3MemSetDefault();\n      *va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;\n      break;\n    }\n    case SQLITE_CONFIG_MEMSTATUS: {\n      /* EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes\n      ** single argument of type int, interpreted as a boolean, which enables\n      ** or disables the collection of memory allocation statistics. */\n      sqlite3GlobalConfig.bMemstat = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_SMALL_MALLOC: {\n      sqlite3GlobalConfig.bSmallMalloc = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PAGECACHE: {\n      /* EVIDENCE-OF: R-18761-36601 There are three arguments to\n      ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem),\n      ** the size of each page cache line (sz), and the number of cache lines\n      ** (N). */\n      sqlite3GlobalConfig.pPage = va_arg(ap, void*);\n      sqlite3GlobalConfig.szPage = va_arg(ap, int);\n      sqlite3GlobalConfig.nPage = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PCACHE_HDRSZ: {\n      /* EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes\n      ** a single parameter which is a pointer to an integer and writes into\n      ** that integer the number of extra bytes per page required for each page\n      ** in SQLITE_CONFIG_PAGECACHE. */\n      *va_arg(ap, int*) = \n          sqlite3HeaderSizeBtree() +\n          sqlite3HeaderSizePcache() +\n          sqlite3HeaderSizePcache1();\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE: {\n      /* no-op */\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE: {\n      /* now an error */\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE2: {\n      /* EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. This object specifies the interface to a custom page cache\n      ** implementation. */\n      sqlite3GlobalConfig.pcache2 = *va_arg(ap, sqlite3_pcache_methods2*);\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE2: {\n      /* EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. SQLite copies of the current page cache implementation into\n      ** that object. */\n      if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n        sqlite3PCacheSetDefault();\n      }\n      *va_arg(ap, sqlite3_pcache_methods2*) = sqlite3GlobalConfig.pcache2;\n      break;\n    }\n\n/* EVIDENCE-OF: R-06626-12911 The SQLITE_CONFIG_HEAP option is only\n** available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or\n** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n    case SQLITE_CONFIG_HEAP: {\n      /* EVIDENCE-OF: R-19854-42126 There are three arguments to\n      ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the\n      ** number of bytes in the memory buffer, and the minimum allocation size.\n      */\n      sqlite3GlobalConfig.pHeap = va_arg(ap, void*);\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      sqlite3GlobalConfig.mnReq = va_arg(ap, int);\n\n      if( sqlite3GlobalConfig.mnReq<1 ){\n        sqlite3GlobalConfig.mnReq = 1;\n      }else if( sqlite3GlobalConfig.mnReq>(1<<12) ){\n        /* cap min request size at 2^12 */\n        sqlite3GlobalConfig.mnReq = (1<<12);\n      }\n\n      if( sqlite3GlobalConfig.pHeap==0 ){\n        /* EVIDENCE-OF: R-49920-60189 If the first pointer (the memory pointer)\n        ** is NULL, then SQLite reverts to using its default memory allocator\n        ** (the system malloc() implementation), undoing any prior invocation of\n        ** SQLITE_CONFIG_MALLOC.\n        **\n        ** Setting sqlite3GlobalConfig.m to all zeros will cause malloc to\n        ** revert to its default implementation when sqlite3_initialize() is run\n        */\n        memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));\n      }else{\n        /* EVIDENCE-OF: R-61006-08918 If the memory pointer is not NULL then the\n        ** alternative memory allocator is engaged to handle all of SQLites\n        ** memory allocation needs. */\n#ifdef SQLITE_ENABLE_MEMSYS3\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys5();\n#endif\n      }\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_LOOKASIDE: {\n      sqlite3GlobalConfig.szLookaside = va_arg(ap, int);\n      sqlite3GlobalConfig.nLookaside = va_arg(ap, int);\n      break;\n    }\n    \n    /* Record a pointer to the logger function and its first argument.\n    ** The default is NULL.  Logging is disabled if the function pointer is\n    ** NULL.\n    */\n    case SQLITE_CONFIG_LOG: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*));\n      */\n      typedef void(*LOGFUNC_t)(void*,int,const char*);\n      sqlite3GlobalConfig.xLog = va_arg(ap, LOGFUNC_t);\n      sqlite3GlobalConfig.pLogArg = va_arg(ap, void*);\n      break;\n    }\n\n    /* EVIDENCE-OF: R-55548-33817 The compile-time setting for URI filenames\n    ** can be changed at start-time using the\n    ** sqlite3_config(SQLITE_CONFIG_URI,1) or\n    ** sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls.\n    */\n    case SQLITE_CONFIG_URI: {\n      /* EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single\n      ** argument of type int. If non-zero, then URI handling is globally\n      ** enabled. If the parameter is zero, then URI handling is globally\n      ** disabled. */\n      sqlite3GlobalConfig.bOpenUri = va_arg(ap, int);\n      break;\n    }\n\n    case SQLITE_CONFIG_COVERING_INDEX_SCAN: {\n      /* EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN\n      ** option takes a single integer argument which is interpreted as a\n      ** boolean in order to enable or disable the use of covering indices for\n      ** full table scans in the query optimizer. */\n      sqlite3GlobalConfig.bUseCis = va_arg(ap, int);\n      break;\n    }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n    case SQLITE_CONFIG_SQLLOG: {\n      typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);\n      sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);\n      sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MMAP_SIZE: {\n      /* EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit\n      ** integer (sqlite3_int64) values that are the default mmap size limit\n      ** (the default setting for PRAGMA mmap_size) and the maximum allowed\n      ** mmap size limit. */\n      sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);\n      sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);\n      /* EVIDENCE-OF: R-53367-43190 If either argument to this option is\n      ** negative, then that argument is changed to its compile-time default.\n      **\n      ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be\n      ** silently truncated if necessary so that it does not exceed the\n      ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE\n      ** compile-time option.\n      */\n      if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){\n        mxMmap = SQLITE_MAX_MMAP_SIZE;\n      }\n      if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;\n      if( szMmap>mxMmap) szMmap = mxMmap;\n      sqlite3GlobalConfig.mxMmap = mxMmap;\n      sqlite3GlobalConfig.szMmap = szMmap;\n      break;\n    }\n\n#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) /* IMP: R-04780-55815 */\n    case SQLITE_CONFIG_WIN32_HEAPSIZE: {\n      /* EVIDENCE-OF: R-34926-03360 SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit\n      ** unsigned integer value that specifies the maximum size of the created\n      ** heap. */\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_PMASZ: {\n      sqlite3GlobalConfig.szPma = va_arg(ap, unsigned int);\n      break;\n    }\n\n    case SQLITE_CONFIG_STMTJRNL_SPILL: {\n      sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int);\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Set up the lookaside buffers for a database connection.\n** Return SQLITE_OK on success.  \n** If lookaside is already active, return SQLITE_BUSY.\n**\n** The sz parameter is the number of bytes in each lookaside slot.\n** The cnt parameter is the number of slots.  If pStart is NULL the\n** space for the lookaside memory is obtained from sqlite3_malloc().\n** If pStart is not NULL then it is sz*cnt bytes of memory to use for\n** the lookaside memory.\n*/\nstatic int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  void *pStart;\n  \n  if( sqlite3LookasideUsed(db,0)>0 ){\n    return SQLITE_BUSY;\n  }\n  /* Free any existing lookaside buffer for this handle before\n  ** allocating a new one so we don't have to have space for \n  ** both at the same time.\n  */\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger\n  ** than a pointer to be useful.\n  */\n  sz = ROUNDDOWN8(sz);  /* IMP: R-33038-09382 */\n  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;\n  if( cnt<0 ) cnt = 0;\n  if( sz==0 || cnt==0 ){\n    sz = 0;\n    pStart = 0;\n  }else if( pBuf==0 ){\n    sqlite3BeginBenignMalloc();\n    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */\n    sqlite3EndBenignMalloc();\n    if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;\n  }else{\n    pStart = pBuf;\n  }\n  db->lookaside.pStart = pStart;\n  db->lookaside.pInit = 0;\n  db->lookaside.pFree = 0;\n  db->lookaside.sz = (u16)sz;\n  if( pStart ){\n    int i;\n    LookasideSlot *p;\n    assert( sz > (int)sizeof(LookasideSlot*) );\n    db->lookaside.nSlot = cnt;\n    p = (LookasideSlot*)pStart;\n    for(i=cnt-1; i>=0; i--){\n      p->pNext = db->lookaside.pInit;\n      db->lookaside.pInit = p;\n      p = (LookasideSlot*)&((u8*)p)[sz];\n    }\n    db->lookaside.pEnd = p;\n    db->lookaside.bDisable = 0;\n    db->lookaside.bMalloced = pBuf==0 ?1:0;\n  }else{\n    db->lookaside.pStart = db;\n    db->lookaside.pEnd = db;\n    db->lookaside.bDisable = 1;\n    db->lookaside.bMalloced = 0;\n    db->lookaside.nSlot = 0;\n  }\n#endif /* SQLITE_OMIT_LOOKASIDE */\n  return SQLITE_OK;\n}\n\n/*\n** Return the mutex associated with a database connection.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->mutex;\n}\n\n/*\n** Free up as much memory as we can from the given database\n** connection.\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3 *db){\n  int i;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      sqlite3PagerShrink(pPager);\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Flush any dirty pages in the pager-cache for any attached database\n** to disk.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3 *db){\n  int i;\n  int rc = SQLITE_OK;\n  int bSeenBusy = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt && sqlite3BtreeIsInTrans(pBt) ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      rc = sqlite3PagerFlush(pPager);\n      if( rc==SQLITE_BUSY ){\n        bSeenBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);\n}\n\n/*\n** Configuration settings for an individual database connection\n*/\nSQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc;\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_DBCONFIG_MAINDBNAME: {\n      /* IMP: R-06824-28531 */\n      /* IMP: R-36257-52125 */\n      db->aDb[0].zDbSName = va_arg(ap,char*);\n      rc = SQLITE_OK;\n      break;\n    }\n    case SQLITE_DBCONFIG_LOOKASIDE: {\n      void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */\n      int sz = va_arg(ap, int);       /* IMP: R-47871-25994 */\n      int cnt = va_arg(ap, int);      /* IMP: R-04460-53386 */\n      rc = setupLookaside(db, pBuf, sz, cnt);\n      break;\n    }\n    default: {\n      static const struct {\n        int op;      /* The opcode */\n        u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */\n      } aFlagOp[] = {\n        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },\n        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },\n        { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },\n        { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension  },\n        { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,      SQLITE_NoCkptOnClose  },\n        { SQLITE_DBCONFIG_ENABLE_QPSG,           SQLITE_EnableQPSG     },\n      };\n      unsigned int i;\n      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */\n      for(i=0; i<ArraySize(aFlagOp); i++){\n        if( aFlagOp[i].op==op ){\n          int onoff = va_arg(ap, int);\n          int *pRes = va_arg(ap, int*);\n          u32 oldFlags = db->flags;\n          if( onoff>0 ){\n            db->flags |= aFlagOp[i].mask;\n          }else if( onoff==0 ){\n            db->flags &= ~aFlagOp[i].mask;\n          }\n          if( oldFlags!=db->flags ){\n            sqlite3ExpirePreparedStatements(db);\n          }\n          if( pRes ){\n            *pRes = (db->flags & aFlagOp[i].mask)!=0;\n          }\n          rc = SQLITE_OK;\n          break;\n        }\n      }\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n\n/*\n** Return true if the buffer z[0..n-1] contains all spaces.\n*/\nstatic int allSpaces(const char *z, int n){\n  while( n>0 && z[n-1]==' ' ){ n--; }\n  return n==0;\n}\n\n/*\n** This is the default collating function named \"BINARY\" which is always\n** available.\n**\n** If the padFlag argument is not NULL then space padding at the end\n** of strings is ignored.  This implements the RTRIM collation.\n*/\nstatic int binCollFunc(\n  void *padFlag,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares\n  ** strings byte by byte using the memcmp() function from the standard C\n  ** library. */\n  assert( pKey1 && pKey2 );\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ){\n    if( padFlag\n     && allSpaces(((char*)pKey1)+n, nKey1-n)\n     && allSpaces(((char*)pKey2)+n, nKey2-n)\n    ){\n      /* EVIDENCE-OF: R-31624-24737 RTRIM is like BINARY except that extra\n      ** spaces at the end of either string do not change the result. In other\n      ** words, strings will compare equal to one another as long as they\n      ** differ only in the number of spaces at the end.\n      */\n    }else{\n      rc = nKey1 - nKey2;\n    }\n  }\n  return rc;\n}\n\n/*\n** Another built-in collating sequence: NOCASE. \n**\n** This collating sequence is intended to be used for \"case independent\n** comparison\". SQLite's knowledge of upper and lower case equivalents\n** extends only to the 26 characters used in the English language.\n**\n** At the moment there is only a UTF-8 implementation.\n*/\nstatic int nocaseCollatingFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int r = sqlite3StrNICmp(\n      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);\n  UNUSED_PARAMETER(NotUsed);\n  if( 0==r ){\n    r = nKey1-nKey2;\n  }\n  return r;\n}\n\n/*\n** Return the ROWID of the most recent insert\n*/\nSQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->lastRowid;\n}\n\n/*\n** Set the value returned by the sqlite3_last_insert_rowid() API function.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->lastRowid = iRowid;\n  sqlite3_mutex_leave(db->mutex);\n}\n\n/*\n** Return the number of changes in the most recent call to sqlite3_exec().\n*/\nSQLITE_API int sqlite3_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nChange;\n}\n\n/*\n** Return the number of changes since the database handle was opened.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nTotalChange;\n}\n\n/*\n** Close all open savepoints. This function only manipulates fields of the\n** database handle object, it does not close any savepoints that may be open\n** at the b-tree/pager level.\n*/\nSQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *db){\n  while( db->pSavepoint ){\n    Savepoint *pTmp = db->pSavepoint;\n    db->pSavepoint = pTmp->pNext;\n    sqlite3DbFree(db, pTmp);\n  }\n  db->nSavepoint = 0;\n  db->nStatement = 0;\n  db->isTransactionSavepoint = 0;\n}\n\n/*\n** Invoke the destructor function associated with FuncDef p, if any. Except,\n** if this is not the last copy of the function, do not invoke it. Multiple\n** copies of a single function are created when create_function() is called\n** with SQLITE_ANY as the encoding.\n*/\nstatic void functionDestroy(sqlite3 *db, FuncDef *p){\n  FuncDestructor *pDestructor = p->u.pDestructor;\n  if( pDestructor ){\n    pDestructor->nRef--;\n    if( pDestructor->nRef==0 ){\n      pDestructor->xDestroy(pDestructor->pUserData);\n      sqlite3DbFree(db, pDestructor);\n    }\n  }\n}\n\n/*\n** Disconnect all sqlite3_vtab objects that belong to database connection\n** db. This is called when db is being closed.\n*/\nstatic void disconnectAllVtab(sqlite3 *db){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int i;\n  HashElem *p;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Schema *pSchema = db->aDb[i].pSchema;\n    if( db->aDb[i].pSchema ){\n      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n        Table *pTab = (Table *)sqliteHashData(p);\n        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);\n      }\n    }\n  }\n  for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){\n    Module *pMod = (Module *)sqliteHashData(p);\n    if( pMod->pEpoTab ){\n      sqlite3VtabDisconnect(db, pMod->pEpoTab);\n    }\n  }\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n#else\n  UNUSED_PARAMETER(db);\n#endif\n}\n\n/*\n** Return TRUE if database connection db has unfinalized prepared\n** statements or unfinished sqlite3_backup objects.  \n*/\nstatic int connectionIsBusy(sqlite3 *db){\n  int j;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->pVdbe ) return 1;\n  for(j=0; j<db->nDb; j++){\n    Btree *pBt = db->aDb[j].pBt;\n    if( pBt && sqlite3BtreeIsInBackup(pBt) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Close an existing SQLite database\n*/\nstatic int sqlite3Close(sqlite3 *db, int forceZombie){\n  if( !db ){\n    /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or\n    ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */\n    return SQLITE_OK;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mTrace & SQLITE_TRACE_CLOSE ){\n    db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);\n  }\n\n  /* Force xDisconnect calls on all virtual tables */\n  disconnectAllVtab(db);\n\n  /* If a transaction is open, the disconnectAllVtab() call above\n  ** will not have called the xDisconnect() method on any virtual\n  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()\n  ** call will do so. We need to do this before the check for active\n  ** SQL statements below, as the v-table implementation may be storing\n  ** some prepared statements internally.\n  */\n  sqlite3VtabRollback(db);\n\n  /* Legacy behavior (sqlite3_close() behavior) is to return\n  ** SQLITE_BUSY if the connection can not be closed immediately.\n  */\n  if( !forceZombie && connectionIsBusy(db) ){\n    sqlite3ErrorWithMsg(db, SQLITE_BUSY, \"unable to close due to unfinalized \"\n       \"statements or unfinished backups\");\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_BUSY;\n  }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Closing the handle. Fourth parameter is passed the value 2. */\n    sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);\n  }\n#endif\n\n  /* Convert the connection into a zombie and then close it.\n  */\n  db->magic = SQLITE_MAGIC_ZOMBIE;\n  sqlite3LeaveMutexAndCloseZombie(db);\n  return SQLITE_OK;\n}\n\n/*\n** Two variations on the public interface for closing a database\n** connection. The sqlite3_close() version returns SQLITE_BUSY and\n** leaves the connection option if there are unfinalized prepared\n** statements or unfinished sqlite3_backups.  The sqlite3_close_v2()\n** version forces the connection to become a zombie if there are\n** unclosed resources, and arranges for deallocation when the last\n** prepare statement or sqlite3_backup closes.\n*/\nSQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }\nSQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }\n\n\n/*\n** Close the mutex on database connection db.\n**\n** Furthermore, if database connection db is a zombie (meaning that there\n** has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and\n** every sqlite3_stmt has now been finalized and every sqlite3_backup has\n** finished, then free all resources.\n*/\nSQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){\n  HashElem *i;                    /* Hash table iterator */\n  int j;\n\n  /* If there are outstanding sqlite3_stmt or sqlite3_backup objects\n  ** or if the connection has not yet been closed by sqlite3_close_v2(),\n  ** then just leave the mutex and return.\n  */\n  if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){\n    sqlite3_mutex_leave(db->mutex);\n    return;\n  }\n\n  /* If we reach this point, it means that the database connection has\n  ** closed all sqlite3_stmt and sqlite3_backup objects and has been\n  ** passed to sqlite3_close (meaning that it is a zombie).  Therefore,\n  ** go ahead and free all resources.\n  */\n\n  /* If a transaction is open, roll it back. This also ensures that if\n  ** any database schemas have been modified by an uncommitted transaction\n  ** they are reset. And that the required b-tree mutex is held to make\n  ** the pager rollback and schema reset an atomic operation. */\n  sqlite3RollbackAll(db, SQLITE_OK);\n\n  /* Free any outstanding Savepoint structures. */\n  sqlite3CloseSavepoints(db);\n\n  /* Close all database connections */\n  for(j=0; j<db->nDb; j++){\n    struct Db *pDb = &db->aDb[j];\n    if( pDb->pBt ){\n      sqlite3BtreeClose(pDb->pBt);\n      pDb->pBt = 0;\n      if( j!=1 ){\n        pDb->pSchema = 0;\n      }\n    }\n  }\n  /* Clear the TEMP schema separately and last */\n  if( db->aDb[1].pSchema ){\n    sqlite3SchemaClear(db->aDb[1].pSchema);\n  }\n  sqlite3VtabUnlockList(db);\n\n  /* Free up the array of auxiliary databases */\n  sqlite3CollapseDatabaseArray(db);\n  assert( db->nDb<=2 );\n  assert( db->aDb==db->aDbStatic );\n\n  /* Tell the code in notify.c that the connection no longer holds any\n  ** locks and does not require any further unlock-notify callbacks.\n  */\n  sqlite3ConnectionClosed(db);\n\n  for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){\n    FuncDef *pNext, *p;\n    p = sqliteHashData(i);\n    do{\n      functionDestroy(db, p);\n      pNext = p->pNext;\n      sqlite3DbFree(db, p);\n      p = pNext;\n    }while( p );\n  }\n  sqlite3HashClear(&db->aFunc);\n  for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){\n    CollSeq *pColl = (CollSeq *)sqliteHashData(i);\n    /* Invoke any destructors registered for collation sequence user data. */\n    for(j=0; j<3; j++){\n      if( pColl[j].xDel ){\n        pColl[j].xDel(pColl[j].pUser);\n      }\n    }\n    sqlite3DbFree(db, pColl);\n  }\n  sqlite3HashClear(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){\n    Module *pMod = (Module *)sqliteHashData(i);\n    if( pMod->xDestroy ){\n      pMod->xDestroy(pMod->pAux);\n    }\n    sqlite3VtabEponymousTableClear(db, pMod);\n    sqlite3DbFree(db, pMod);\n  }\n  sqlite3HashClear(&db->aModule);\n#endif\n\n  sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */\n  sqlite3ValueFree(db->pErr);\n  sqlite3CloseExtensions(db);\n#if SQLITE_USER_AUTHENTICATION\n  sqlite3_free(db->auth.zAuthUser);\n  sqlite3_free(db->auth.zAuthPW);\n#endif\n\n  db->magic = SQLITE_MAGIC_ERROR;\n\n  /* The temp-database schema is allocated differently from the other schema\n  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).\n  ** So it needs to be freed here. Todo: Why not roll the temp schema into\n  ** the same sqliteMalloc() as the one that allocates the database \n  ** structure?\n  */\n  sqlite3DbFree(db, db->aDb[1].pSchema);\n  sqlite3_mutex_leave(db->mutex);\n  db->magic = SQLITE_MAGIC_CLOSED;\n  sqlite3_mutex_free(db->mutex);\n  assert( sqlite3LookasideUsed(db,0)==0 );\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  sqlite3_free(db);\n}\n\n/*\n** Rollback all database files.  If tripCode is not SQLITE_OK, then\n** any write cursors are invalidated (\"tripped\" - as in \"tripping a circuit\n** breaker\") and made to return tripCode if there are any further\n** attempts to use that cursor.  Read cursors remain open and valid\n** but are \"saved\" in case the table pages are moved around.\n*/\nSQLITE_PRIVATE void sqlite3RollbackAll(sqlite3 *db, int tripCode){\n  int i;\n  int inTrans = 0;\n  int schemaChange;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3BeginBenignMalloc();\n\n  /* Obtain all b-tree mutexes before making any calls to BtreeRollback(). \n  ** This is important in case the transaction being rolled back has\n  ** modified the database schema. If the b-tree mutexes are not taken\n  ** here, then another shared-cache connection might sneak in between\n  ** the database rollback and schema reset, which can cause false\n  ** corruption reports in some cases.  */\n  sqlite3BtreeEnterAll(db);\n  schemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0 && db->init.busy==0;\n\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      if( sqlite3BtreeIsInTrans(p) ){\n        inTrans = 1;\n      }\n      sqlite3BtreeRollback(p, tripCode, !schemaChange);\n    }\n  }\n  sqlite3VtabRollback(db);\n  sqlite3EndBenignMalloc();\n\n  if( (db->mDbFlags&DBFLAG_SchemaChange)!=0 && db->init.busy==0 ){\n    sqlite3ExpirePreparedStatements(db);\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  sqlite3BtreeLeaveAll(db);\n\n  /* Any deferred constraint violations have now been resolved. */\n  db->nDeferredCons = 0;\n  db->nDeferredImmCons = 0;\n  db->flags &= ~SQLITE_DeferFKs;\n\n  /* If one has been configured, invoke the rollback-hook callback */\n  if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){\n    db->xRollbackCallback(db->pRollbackArg);\n  }\n}\n\n/*\n** Return a static string containing the name corresponding to the error code\n** specified in the argument.\n*/\n#if defined(SQLITE_NEED_ERR_NAME)\nSQLITE_PRIVATE const char *sqlite3ErrName(int rc){\n  const char *zName = 0;\n  int i, origRc = rc;\n  for(i=0; i<2 && zName==0; i++, rc &= 0xff){\n    switch( rc ){\n      case SQLITE_OK:                 zName = \"SQLITE_OK\";                break;\n      case SQLITE_ERROR:              zName = \"SQLITE_ERROR\";             break;\n      case SQLITE_INTERNAL:           zName = \"SQLITE_INTERNAL\";          break;\n      case SQLITE_PERM:               zName = \"SQLITE_PERM\";              break;\n      case SQLITE_ABORT:              zName = \"SQLITE_ABORT\";             break;\n      case SQLITE_ABORT_ROLLBACK:     zName = \"SQLITE_ABORT_ROLLBACK\";    break;\n      case SQLITE_BUSY:               zName = \"SQLITE_BUSY\";              break;\n      case SQLITE_BUSY_RECOVERY:      zName = \"SQLITE_BUSY_RECOVERY\";     break;\n      case SQLITE_BUSY_SNAPSHOT:      zName = \"SQLITE_BUSY_SNAPSHOT\";     break;\n      case SQLITE_LOCKED:             zName = \"SQLITE_LOCKED\";            break;\n      case SQLITE_LOCKED_SHAREDCACHE: zName = \"SQLITE_LOCKED_SHAREDCACHE\";break;\n      case SQLITE_NOMEM:              zName = \"SQLITE_NOMEM\";             break;\n      case SQLITE_READONLY:           zName = \"SQLITE_READONLY\";          break;\n      case SQLITE_READONLY_RECOVERY:  zName = \"SQLITE_READONLY_RECOVERY\"; break;\n      case SQLITE_READONLY_CANTLOCK:  zName = \"SQLITE_READONLY_CANTLOCK\"; break;\n      case SQLITE_READONLY_ROLLBACK:  zName = \"SQLITE_READONLY_ROLLBACK\"; break;\n      case SQLITE_READONLY_DBMOVED:   zName = \"SQLITE_READONLY_DBMOVED\";  break;\n      case SQLITE_INTERRUPT:          zName = \"SQLITE_INTERRUPT\";         break;\n      case SQLITE_IOERR:              zName = \"SQLITE_IOERR\";             break;\n      case SQLITE_IOERR_READ:         zName = \"SQLITE_IOERR_READ\";        break;\n      case SQLITE_IOERR_SHORT_READ:   zName = \"SQLITE_IOERR_SHORT_READ\";  break;\n      case SQLITE_IOERR_WRITE:        zName = \"SQLITE_IOERR_WRITE\";       break;\n      case SQLITE_IOERR_FSYNC:        zName = \"SQLITE_IOERR_FSYNC\";       break;\n      case SQLITE_IOERR_DIR_FSYNC:    zName = \"SQLITE_IOERR_DIR_FSYNC\";   break;\n      case SQLITE_IOERR_TRUNCATE:     zName = \"SQLITE_IOERR_TRUNCATE\";    break;\n      case SQLITE_IOERR_FSTAT:        zName = \"SQLITE_IOERR_FSTAT\";       break;\n      case SQLITE_IOERR_UNLOCK:       zName = \"SQLITE_IOERR_UNLOCK\";      break;\n      case SQLITE_IOERR_RDLOCK:       zName = \"SQLITE_IOERR_RDLOCK\";      break;\n      case SQLITE_IOERR_DELETE:       zName = \"SQLITE_IOERR_DELETE\";      break;\n      case SQLITE_IOERR_NOMEM:        zName = \"SQLITE_IOERR_NOMEM\";       break;\n      case SQLITE_IOERR_ACCESS:       zName = \"SQLITE_IOERR_ACCESS\";      break;\n      case SQLITE_IOERR_CHECKRESERVEDLOCK:\n                                zName = \"SQLITE_IOERR_CHECKRESERVEDLOCK\"; break;\n      case SQLITE_IOERR_LOCK:         zName = \"SQLITE_IOERR_LOCK\";        break;\n      case SQLITE_IOERR_CLOSE:        zName = \"SQLITE_IOERR_CLOSE\";       break;\n      case SQLITE_IOERR_DIR_CLOSE:    zName = \"SQLITE_IOERR_DIR_CLOSE\";   break;\n      case SQLITE_IOERR_SHMOPEN:      zName = \"SQLITE_IOERR_SHMOPEN\";     break;\n      case SQLITE_IOERR_SHMSIZE:      zName = \"SQLITE_IOERR_SHMSIZE\";     break;\n      case SQLITE_IOERR_SHMLOCK:      zName = \"SQLITE_IOERR_SHMLOCK\";     break;\n      case SQLITE_IOERR_SHMMAP:       zName = \"SQLITE_IOERR_SHMMAP\";      break;\n      case SQLITE_IOERR_SEEK:         zName = \"SQLITE_IOERR_SEEK\";        break;\n      case SQLITE_IOERR_DELETE_NOENT: zName = \"SQLITE_IOERR_DELETE_NOENT\";break;\n      case SQLITE_IOERR_MMAP:         zName = \"SQLITE_IOERR_MMAP\";        break;\n      case SQLITE_IOERR_GETTEMPPATH:  zName = \"SQLITE_IOERR_GETTEMPPATH\"; break;\n      case SQLITE_IOERR_CONVPATH:     zName = \"SQLITE_IOERR_CONVPATH\";    break;\n      case SQLITE_CORRUPT:            zName = \"SQLITE_CORRUPT\";           break;\n      case SQLITE_CORRUPT_VTAB:       zName = \"SQLITE_CORRUPT_VTAB\";      break;\n      case SQLITE_NOTFOUND:           zName = \"SQLITE_NOTFOUND\";          break;\n      case SQLITE_FULL:               zName = \"SQLITE_FULL\";              break;\n      case SQLITE_CANTOPEN:           zName = \"SQLITE_CANTOPEN\";          break;\n      case SQLITE_CANTOPEN_NOTEMPDIR: zName = \"SQLITE_CANTOPEN_NOTEMPDIR\";break;\n      case SQLITE_CANTOPEN_ISDIR:     zName = \"SQLITE_CANTOPEN_ISDIR\";    break;\n      case SQLITE_CANTOPEN_FULLPATH:  zName = \"SQLITE_CANTOPEN_FULLPATH\"; break;\n      case SQLITE_CANTOPEN_CONVPATH:  zName = \"SQLITE_CANTOPEN_CONVPATH\"; break;\n      case SQLITE_PROTOCOL:           zName = \"SQLITE_PROTOCOL\";          break;\n      case SQLITE_EMPTY:              zName = \"SQLITE_EMPTY\";             break;\n      case SQLITE_SCHEMA:             zName = \"SQLITE_SCHEMA\";            break;\n      case SQLITE_TOOBIG:             zName = \"SQLITE_TOOBIG\";            break;\n      case SQLITE_CONSTRAINT:         zName = \"SQLITE_CONSTRAINT\";        break;\n      case SQLITE_CONSTRAINT_UNIQUE:  zName = \"SQLITE_CONSTRAINT_UNIQUE\"; break;\n      case SQLITE_CONSTRAINT_TRIGGER: zName = \"SQLITE_CONSTRAINT_TRIGGER\";break;\n      case SQLITE_CONSTRAINT_FOREIGNKEY:\n                                zName = \"SQLITE_CONSTRAINT_FOREIGNKEY\";   break;\n      case SQLITE_CONSTRAINT_CHECK:   zName = \"SQLITE_CONSTRAINT_CHECK\";  break;\n      case SQLITE_CONSTRAINT_PRIMARYKEY:\n                                zName = \"SQLITE_CONSTRAINT_PRIMARYKEY\";   break;\n      case SQLITE_CONSTRAINT_NOTNULL: zName = \"SQLITE_CONSTRAINT_NOTNULL\";break;\n      case SQLITE_CONSTRAINT_COMMITHOOK:\n                                zName = \"SQLITE_CONSTRAINT_COMMITHOOK\";   break;\n      case SQLITE_CONSTRAINT_VTAB:    zName = \"SQLITE_CONSTRAINT_VTAB\";   break;\n      case SQLITE_CONSTRAINT_FUNCTION:\n                                zName = \"SQLITE_CONSTRAINT_FUNCTION\";     break;\n      case SQLITE_CONSTRAINT_ROWID:   zName = \"SQLITE_CONSTRAINT_ROWID\";  break;\n      case SQLITE_MISMATCH:           zName = \"SQLITE_MISMATCH\";          break;\n      case SQLITE_MISUSE:             zName = \"SQLITE_MISUSE\";            break;\n      case SQLITE_NOLFS:              zName = \"SQLITE_NOLFS\";             break;\n      case SQLITE_AUTH:               zName = \"SQLITE_AUTH\";              break;\n      case SQLITE_FORMAT:             zName = \"SQLITE_FORMAT\";            break;\n      case SQLITE_RANGE:              zName = \"SQLITE_RANGE\";             break;\n      case SQLITE_NOTADB:             zName = \"SQLITE_NOTADB\";            break;\n      case SQLITE_ROW:                zName = \"SQLITE_ROW\";               break;\n      case SQLITE_NOTICE:             zName = \"SQLITE_NOTICE\";            break;\n      case SQLITE_NOTICE_RECOVER_WAL: zName = \"SQLITE_NOTICE_RECOVER_WAL\";break;\n      case SQLITE_NOTICE_RECOVER_ROLLBACK:\n                                zName = \"SQLITE_NOTICE_RECOVER_ROLLBACK\"; break;\n      case SQLITE_WARNING:            zName = \"SQLITE_WARNING\";           break;\n      case SQLITE_WARNING_AUTOINDEX:  zName = \"SQLITE_WARNING_AUTOINDEX\"; break;\n      case SQLITE_DONE:               zName = \"SQLITE_DONE\";              break;\n    }\n  }\n  if( zName==0 ){\n    static char zBuf[50];\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"SQLITE_UNKNOWN(%d)\", origRc);\n    zName = zBuf;\n  }\n  return zName;\n}\n#endif\n\n/*\n** Return a static string that describes the kind of error specified in the\n** argument.\n*/\nSQLITE_PRIVATE const char *sqlite3ErrStr(int rc){\n  static const char* const aMsg[] = {\n    /* SQLITE_OK          */ \"not an error\",\n    /* SQLITE_ERROR       */ \"SQL logic error\",\n    /* SQLITE_INTERNAL    */ 0,\n    /* SQLITE_PERM        */ \"access permission denied\",\n    /* SQLITE_ABORT       */ \"query aborted\",\n    /* SQLITE_BUSY        */ \"database is locked\",\n    /* SQLITE_LOCKED      */ \"database table is locked\",\n    /* SQLITE_NOMEM       */ \"out of memory\",\n    /* SQLITE_READONLY    */ \"attempt to write a readonly database\",\n    /* SQLITE_INTERRUPT   */ \"interrupted\",\n    /* SQLITE_IOERR       */ \"disk I/O error\",\n    /* SQLITE_CORRUPT     */ \"database disk image is malformed\",\n    /* SQLITE_NOTFOUND    */ \"unknown operation\",\n    /* SQLITE_FULL        */ \"database or disk is full\",\n    /* SQLITE_CANTOPEN    */ \"unable to open database file\",\n    /* SQLITE_PROTOCOL    */ \"locking protocol\",\n    /* SQLITE_EMPTY       */ 0,\n    /* SQLITE_SCHEMA      */ \"database schema has changed\",\n    /* SQLITE_TOOBIG      */ \"string or blob too big\",\n    /* SQLITE_CONSTRAINT  */ \"constraint failed\",\n    /* SQLITE_MISMATCH    */ \"datatype mismatch\",\n    /* SQLITE_MISUSE      */ \"bad parameter or other API misuse\",\n#ifdef SQLITE_DISABLE_LFS\n    /* SQLITE_NOLFS       */ \"large file support is disabled\",\n#else\n    /* SQLITE_NOLFS       */ 0,\n#endif\n    /* SQLITE_AUTH        */ \"authorization denied\",\n    /* SQLITE_FORMAT      */ 0,\n    /* SQLITE_RANGE       */ \"column index out of range\",\n    /* SQLITE_NOTADB      */ \"file is not a database\",\n  };\n  const char *zErr = \"unknown error\";\n  switch( rc ){\n    case SQLITE_ABORT_ROLLBACK: {\n      zErr = \"abort due to ROLLBACK\";\n      break;\n    }\n    default: {\n      rc &= 0xff;\n      if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){\n        zErr = aMsg[rc];\n      }\n      break;\n    }\n  }\n  return zErr;\n}\n\n/*\n** This routine implements a busy callback that sleeps and tries\n** again until a timeout value is reached.  The timeout value is\n** an integer number of milliseconds passed in as the first\n** argument.\n*/\nstatic int sqliteDefaultBusyCallback(\n void *ptr,               /* Database connection */\n int count                /* Number of times table has been busy */\n){\n#if SQLITE_OS_WIN || HAVE_USLEEP\n  static const u8 delays[] =\n     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };\n  static const u8 totals[] =\n     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };\n# define NDELAY ArraySize(delays)\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = db->busyTimeout;\n  int delay, prior;\n\n  assert( count>=0 );\n  if( count < NDELAY ){\n    delay = delays[count];\n    prior = totals[count];\n  }else{\n    delay = delays[NDELAY-1];\n    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));\n  }\n  if( prior + delay > timeout ){\n    delay = timeout - prior;\n    if( delay<=0 ) return 0;\n  }\n  sqlite3OsSleep(db->pVfs, delay*1000);\n  return 1;\n#else\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = ((sqlite3 *)ptr)->busyTimeout;\n  if( (count+1)*1000 > timeout ){\n    return 0;\n  }\n  sqlite3OsSleep(db->pVfs, 1000000);\n  return 1;\n#endif\n}\n\n/*\n** Invoke the given busy handler.\n**\n** This routine is called when an operation failed with a lock.\n** If this routine returns non-zero, the lock is retried.  If it\n** returns 0, the operation aborts with an SQLITE_BUSY error.\n*/\nSQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p){\n  int rc;\n  if( NEVER(p==0) || p->xFunc==0 || p->nBusy<0 ) return 0;\n  rc = p->xFunc(p->pArg, p->nBusy);\n  if( rc==0 ){\n    p->nBusy = -1;\n  }else{\n    p->nBusy++;\n  }\n  return rc; \n}\n\n/*\n** This routine sets the busy callback for an Sqlite database to the\n** given callback function with the given argument.\n*/\nSQLITE_API int sqlite3_busy_handler(\n  sqlite3 *db,\n  int (*xBusy)(void*,int),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->busyHandler.xFunc = xBusy;\n  db->busyHandler.pArg = pArg;\n  db->busyHandler.nBusy = 0;\n  db->busyTimeout = 0;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This routine sets the progress callback for an Sqlite database to the\n** given callback function with the given argument. The progress callback will\n** be invoked every nOps opcodes.\n*/\nSQLITE_API void sqlite3_progress_handler(\n  sqlite3 *db, \n  int nOps,\n  int (*xProgress)(void*), \n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( nOps>0 ){\n    db->xProgress = xProgress;\n    db->nProgressOps = (unsigned)nOps;\n    db->pProgressArg = pArg;\n  }else{\n    db->xProgress = 0;\n    db->nProgressOps = 0;\n    db->pProgressArg = 0;\n  }\n  sqlite3_mutex_leave(db->mutex);\n}\n#endif\n\n\n/*\n** This routine installs a default busy handler that waits for the\n** specified number of milliseconds before returning 0.\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( ms>0 ){\n    sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);\n    db->busyTimeout = ms;\n  }else{\n    sqlite3_busy_handler(db, 0, 0);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Cause any pending operation to stop at its earliest opportunity.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  db->u1.isInterrupted = 1;\n}\n\n\n/*\n** This function is exactly the same as sqlite3_create_function(), except\n** that it is designed to be called by internal code. The difference is\n** that if a malloc() fails in sqlite3_create_function(), an error code\n** is returned and the mallocFailed flag cleared. \n*/\nSQLITE_PRIVATE int sqlite3CreateFunc(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int enc,\n  void *pUserData,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  FuncDestructor *pDestructor\n){\n  FuncDef *p;\n  int nName;\n  int extraFlags;\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( zFunctionName==0 ||\n      (xSFunc && (xFinal || xStep)) || \n      (!xSFunc && (xFinal && !xStep)) ||\n      (!xSFunc && (!xFinal && xStep)) ||\n      (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||\n      (255<(nName = sqlite3Strlen30( zFunctionName))) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );\n  extraFlags = enc &  SQLITE_DETERMINISTIC;\n  enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);\n  \n#ifndef SQLITE_OMIT_UTF16\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  **\n  ** If SQLITE_ANY is specified, add three versions of the function\n  ** to the hash table.\n  */\n  if( enc==SQLITE_UTF16 ){\n    enc = SQLITE_UTF16NATIVE;\n  }else if( enc==SQLITE_ANY ){\n    int rc;\n    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,\n         pUserData, xSFunc, xStep, xFinal, pDestructor);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,\n          pUserData, xSFunc, xStep, xFinal, pDestructor);\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    enc = SQLITE_UTF16BE;\n  }\n#else\n  enc = SQLITE_UTF8;\n#endif\n  \n  /* Check if an existing function is being overridden or deleted. If so,\n  ** and there are active VMs, then return SQLITE_BUSY. If a function\n  ** is being overridden/deleted but there are no active VMs, allow the\n  ** operation to continue but invalidate all precompiled statements.\n  */\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);\n  if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==enc && p->nArg==nArg ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify user-function due to active statements\");\n      assert( !db->mallocFailed );\n      return SQLITE_BUSY;\n    }else{\n      sqlite3ExpirePreparedStatements(db);\n    }\n  }\n\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);\n  assert(p || db->mallocFailed);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* If an older version of the function with a configured destructor is\n  ** being replaced invoke the destructor function here. */\n  functionDestroy(db, p);\n\n  if( pDestructor ){\n    pDestructor->nRef++;\n  }\n  p->u.pDestructor = pDestructor;\n  p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;\n  testcase( p->funcFlags & SQLITE_DETERMINISTIC );\n  p->xSFunc = xSFunc ? xSFunc : xStep;\n  p->xFinalize = xFinal;\n  p->pUserData = pUserData;\n  p->nArg = (u16)nArg;\n  return SQLITE_OK;\n}\n\n/*\n** Create new user functions.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*)\n){\n  return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep,\n                                    xFinal, 0);\n}\n\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xDestroy)(void *)\n){\n  int rc = SQLITE_ERROR;\n  FuncDestructor *pArg = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( xDestroy ){\n    pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));\n    if( !pArg ){\n      xDestroy(p);\n      goto out;\n    }\n    pArg->xDestroy = xDestroy;\n    pArg->pUserData = p;\n  }\n  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);\n  if( pArg && pArg->nRef==0 ){\n    assert( rc!=SQLITE_OK );\n    xDestroy(p);\n    sqlite3DbFree(db, pArg);\n  }\n\n out:\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n){\n  int rc;\n  char *zFunc8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);\n  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0);\n  sqlite3DbFree(db, zFunc8);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif\n\n\n/*\n** Declare that a function has been overloaded by a virtual table.\n**\n** If the function already exists as a regular global function, then\n** this routine is a no-op.  If the function does not exist, then create\n** a new one that always throws a run-time error.  \n**\n** When virtual tables intend to provide an overloaded function, they\n** should call this routine to make sure the global function exists.\n** A global function must exist in order for name resolution to work\n** properly.\n*/\nSQLITE_API int sqlite3_overload_function(\n  sqlite3 *db,\n  const char *zName,\n  int nArg\n){\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)==0 ){\n    rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,\n                           0, sqlite3InvalidFunction, 0, 0, 0);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Register a trace function.  The pArg from the previously registered trace\n** is returned.  \n**\n** A NULL trace function means that no tracing is executes.  A non-NULL\n** trace is a pointer to a function that is invoked at the start of each\n** SQL statement.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API void *sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pTraceArg;\n  db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;\n  db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n/* Register a trace callback using the version-2 interface.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3 *db,                               /* Trace this connection */\n  unsigned mTrace,                           /* Mask of events to be traced */\n  int(*xTrace)(unsigned,void*,void*,void*),  /* Callback to invoke */\n  void *pArg                                 /* Context */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( mTrace==0 ) xTrace = 0;\n  if( xTrace==0 ) mTrace = 0;\n  db->mTrace = mTrace;\n  db->xTrace = xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Register a profile function.  The pArg from the previously registered \n** profile function is returned.  \n**\n** A NULL profile function means that no profiling is executes.  A non-NULL\n** profile is a pointer to a function that is invoked at the conclusion of\n** each SQL statement that is run.\n*/\nSQLITE_API void *sqlite3_profile(\n  sqlite3 *db,\n  void (*xProfile)(void*,const char*,sqlite_uint64),\n  void *pArg\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pProfileArg;\n  db->xProfile = xProfile;\n  db->pProfileArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n#endif /* SQLITE_OMIT_TRACE */\n\n/*\n** Register a function to be invoked when a transaction commits.\n** If the invoked function returns non-zero, then the commit becomes a\n** rollback.\n*/\nSQLITE_API void *sqlite3_commit_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  int (*xCallback)(void*),  /* Function to invoke on each commit */\n  void *pArg                /* Argument to the function */\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pCommitArg;\n  db->xCommitCallback = xCallback;\n  db->pCommitArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pUpdateArg;\n  db->xUpdateCallback = xCallback;\n  db->pUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is rolled\n** back by this database connection.\n*/\nSQLITE_API void *sqlite3_rollback_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*), /* Callback function */\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pRollbackArg;\n  db->xRollbackCallback = xCallback;\n  db->pRollbackArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void(*xCallback)(         /* Callback function */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64),\n  void *pArg                /* First callback argument */\n){\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pPreUpdateArg;\n  db->xPreUpdateCallback = xCallback;\n  db->pPreUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().\n** Invoke sqlite3_wal_checkpoint if the number of frames in the log file\n** is greater than sqlite3.pWalArg cast to an integer (the value configured by\n** wal_autocheckpoint()).\n*/ \nSQLITE_PRIVATE int sqlite3WalDefaultHook(\n  void *pClientData,     /* Argument */\n  sqlite3 *db,           /* Connection */\n  const char *zDb,       /* Database */\n  int nFrame             /* Size of WAL */\n){\n  if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){\n    sqlite3BeginBenignMalloc();\n    sqlite3_wal_checkpoint(db, zDb);\n    sqlite3EndBenignMalloc();\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** Configure an sqlite3_wal_hook() callback to automatically checkpoint\n** a database after committing a transaction if there are nFrame or\n** more frames in the log file. Passing zero or a negative value as the\n** nFrame parameter disables automatic checkpoints entirely.\n**\n** The callback registered by this function replaces any existing callback\n** registered using sqlite3_wal_hook(). Likewise, registering a callback\n** using sqlite3_wal_hook() disables the automatic checkpoint mechanism\n** configured by this function.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){\n#ifdef SQLITE_OMIT_WAL\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(nFrame);\n#else\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( nFrame>0 ){\n    sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));\n  }else{\n    sqlite3_wal_hook(db, 0, 0);\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is written\n** into the write-ahead-log by this database connection.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3 *db,                    /* Attach the hook to this db handle */\n  int(*xCallback)(void *, sqlite3*, const char*, int),\n  void *pArg                      /* First argument passed to xCallback() */\n){\n#ifndef SQLITE_OMIT_WAL\n  void *pRet;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pWalArg;\n  db->xWalCallback = xCallback;\n  db->pWalArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n#else\n  return 0;\n#endif\n}\n\n/*\n** Checkpoint database zDb.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n){\n#ifdef SQLITE_OMIT_WAL\n  return SQLITE_OK;\n#else\n  int rc;                         /* Return code */\n  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  /* Initialize the output variables to -1 in case an error occurs. */\n  if( pnLog ) *pnLog = -1;\n  if( pnCkpt ) *pnCkpt = -1;\n\n  assert( SQLITE_CHECKPOINT_PASSIVE==0 );\n  assert( SQLITE_CHECKPOINT_FULL==1 );\n  assert( SQLITE_CHECKPOINT_RESTART==2 );\n  assert( SQLITE_CHECKPOINT_TRUNCATE==3 );\n  if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){\n    /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint\n    ** mode: */\n    return SQLITE_MISUSE;\n  }\n\n  sqlite3_mutex_enter(db->mutex);\n  if( zDb && zDb[0] ){\n    iDb = sqlite3FindDbName(db, zDb);\n  }\n  if( iDb<0 ){\n    rc = SQLITE_ERROR;\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"unknown database: %s\", zDb);\n  }else{\n    db->busyHandler.nBusy = 0;\n    rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);\n    sqlite3Error(db, rc);\n  }\n  rc = sqlite3ApiExit(db, rc);\n\n  /* If there are no active statements, clear the interrupt flag at this\n  ** point.  */\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n#endif\n}\n\n\n/*\n** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points\n** to contains a zero-length string, all attached databases are \n** checkpointed.\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){\n  /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to\n  ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */\n  return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on database iDb. This is a no-op if database iDb is\n** not currently open in WAL mode.\n**\n** If a transaction is open on the database being checkpointed, this \n** function returns SQLITE_LOCKED and a checkpoint is not attempted. If \n** an error occurs while running the checkpoint, an SQLite error code is \n** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.\n**\n** The mutex on database handle db should be held by the caller. The mutex\n** associated with the specific b-tree being checkpointed is taken by\n** this function while the checkpoint is running.\n**\n** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are\n** checkpointed. If an error is encountered it is returned immediately -\n** no attempt is made to checkpoint any remaining databases.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART\n** or TRUNCATE.\n*/\nSQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Used to iterate through attached dbs */\n  int bBusy = 0;                  /* True if SQLITE_BUSY has been encountered */\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( !pnLog || *pnLog==-1 );\n  assert( !pnCkpt || *pnCkpt==-1 );\n\n  for(i=0; i<db->nDb && rc==SQLITE_OK; i++){\n    if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){\n      rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);\n      pnLog = 0;\n      pnCkpt = 0;\n      if( rc==SQLITE_BUSY ){\n        bBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** This function returns true if main-memory should be used instead of\n** a temporary file for transient pager files and statement journals.\n** The value returned depends on the value of db->temp_store (runtime\n** parameter) and the compile time value of SQLITE_TEMP_STORE. The\n** following table describes the relationship between these two values\n** and this functions return value.\n**\n**   SQLITE_TEMP_STORE     db->temp_store     Location of temporary database\n**   -----------------     --------------     ------------------------------\n**   0                     any                file      (return 0)\n**   1                     1                  file      (return 0)\n**   1                     2                  memory    (return 1)\n**   1                     0                  file      (return 0)\n**   2                     1                  file      (return 0)\n**   2                     2                  memory    (return 1)\n**   2                     0                  memory    (return 1)\n**   3                     any                memory    (return 1)\n*/\nSQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){\n#if SQLITE_TEMP_STORE==1\n  return ( db->temp_store==2 );\n#endif\n#if SQLITE_TEMP_STORE==2\n  return ( db->temp_store!=1 );\n#endif\n#if SQLITE_TEMP_STORE==3\n  UNUSED_PARAMETER(db);\n  return 1;\n#endif\n#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3\n  UNUSED_PARAMETER(db);\n  return 0;\n#endif\n}\n\n/*\n** Return UTF-8 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const char *sqlite3_errmsg(sqlite3 *db){\n  const char *z;\n  if( !db ){\n    return sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return sqlite3ErrStr(SQLITE_MISUSE_BKPT);\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }else{\n    testcase( db->pErr==0 );\n    z = (char*)sqlite3_value_text(db->pErr);\n    assert( !db->mallocFailed );\n    if( z==0 ){\n      z = sqlite3ErrStr(db->errCode);\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Return UTF-16 encoded English language explanation of the most recent\n** error.\n*/\nSQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){\n  static const u16 outOfMem[] = {\n    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0\n  };\n  static const u16 misuse[] = {\n    'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ',\n    'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ',\n    'm', 'i', 's', 'u', 's', 'e', 0\n  };\n\n  const void *z;\n  if( !db ){\n    return (void *)outOfMem;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return (void *)misuse;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = (void *)outOfMem;\n  }else{\n    z = sqlite3_value_text16(db->pErr);\n    if( z==0 ){\n      sqlite3ErrorWithMsg(db, db->errCode, sqlite3ErrStr(db->errCode));\n      z = sqlite3_value_text16(db->pErr);\n    }\n    /* A malloc() may have failed within the call to sqlite3_value_text16()\n    ** above. If this is the case, then the db->mallocFailed flag needs to\n    ** be cleared before returning. Do this directly, instead of via\n    ** sqlite3ApiExit(), to avoid setting the database handle error message.\n    */\n    sqlite3OomClear(db);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the most recent error code generated by an SQLite routine. If NULL is\n** passed to this function, we assume a malloc() failed during sqlite3_open().\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode & db->errMask;\n}\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode;\n}\nSQLITE_API int sqlite3_system_errno(sqlite3 *db){\n  return db ? db->iSysErrno : 0;\n}  \n\n/*\n** Return a string that describes the kind of error specified in the\n** argument.  For now, this simply calls the internal sqlite3ErrStr()\n** function.\n*/\nSQLITE_API const char *sqlite3_errstr(int rc){\n  return sqlite3ErrStr(rc);\n}\n\n/*\n** Create a new collating function for database \"db\".  The name is zName\n** and the encoding is enc.\n*/\nstatic int createCollation(\n  sqlite3* db,\n  const char *zName, \n  u8 enc,\n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  CollSeq *pColl;\n  int enc2;\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  */\n  enc2 = enc;\n  testcase( enc2==SQLITE_UTF16 );\n  testcase( enc2==SQLITE_UTF16_ALIGNED );\n  if( enc2==SQLITE_UTF16 || enc2==SQLITE_UTF16_ALIGNED ){\n    enc2 = SQLITE_UTF16NATIVE;\n  }\n  if( enc2<SQLITE_UTF8 || enc2>SQLITE_UTF16BE ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  /* Check if this call is removing or replacing an existing collation \n  ** sequence. If so, and there are active VMs, return busy. If there\n  ** are no active VMs, invalidate any pre-compiled statements.\n  */\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);\n  if( pColl && pColl->xCmp ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify collation sequence due to active statements\");\n      return SQLITE_BUSY;\n    }\n    sqlite3ExpirePreparedStatements(db);\n\n    /* If collation sequence pColl was created directly by a call to\n    ** sqlite3_create_collation, and not generated by synthCollSeq(),\n    ** then any copies made by synthCollSeq() need to be invalidated.\n    ** Also, collation destructor - CollSeq.xDel() - function may need\n    ** to be called.\n    */ \n    if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){\n      CollSeq *aColl = sqlite3HashFind(&db->aCollSeq, zName);\n      int j;\n      for(j=0; j<3; j++){\n        CollSeq *p = &aColl[j];\n        if( p->enc==pColl->enc ){\n          if( p->xDel ){\n            p->xDel(p->pUser);\n          }\n          p->xCmp = 0;\n        }\n      }\n    }\n  }\n\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1);\n  if( pColl==0 ) return SQLITE_NOMEM_BKPT;\n  pColl->xCmp = xCompare;\n  pColl->pUser = pCtx;\n  pColl->xDel = xDel;\n  pColl->enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED));\n  sqlite3Error(db, SQLITE_OK);\n  return SQLITE_OK;\n}\n\n\n/*\n** This array defines hard upper bounds on limit values.  The\n** initializer must be kept in sync with the SQLITE_LIMIT_*\n** #defines in sqlite3.h.\n*/\nstatic const int aHardLimit[] = {\n  SQLITE_MAX_LENGTH,\n  SQLITE_MAX_SQL_LENGTH,\n  SQLITE_MAX_COLUMN,\n  SQLITE_MAX_EXPR_DEPTH,\n  SQLITE_MAX_COMPOUND_SELECT,\n  SQLITE_MAX_VDBE_OP,\n  SQLITE_MAX_FUNCTION_ARG,\n  SQLITE_MAX_ATTACHED,\n  SQLITE_MAX_LIKE_PATTERN_LENGTH,\n  SQLITE_MAX_VARIABLE_NUMBER,      /* IMP: R-38091-32352 */\n  SQLITE_MAX_TRIGGER_DEPTH,\n  SQLITE_MAX_WORKER_THREADS,\n};\n\n/*\n** Make sure the hard limits are set to reasonable values\n*/\n#if SQLITE_MAX_LENGTH<100\n# error SQLITE_MAX_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH<100\n# error SQLITE_MAX_SQL_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH\n# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH\n#endif\n#if SQLITE_MAX_COMPOUND_SELECT<2\n# error SQLITE_MAX_COMPOUND_SELECT must be at least 2\n#endif\n#if SQLITE_MAX_VDBE_OP<40\n# error SQLITE_MAX_VDBE_OP must be at least 40\n#endif\n#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127\n# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127\n#endif\n#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125\n# error SQLITE_MAX_ATTACHED must be between 0 and 125\n#endif\n#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1\n# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1\n#endif\n#if SQLITE_MAX_COLUMN>32767\n# error SQLITE_MAX_COLUMN must not exceed 32767\n#endif\n#if SQLITE_MAX_TRIGGER_DEPTH<1\n# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1\n#endif\n#if SQLITE_MAX_WORKER_THREADS<0 || SQLITE_MAX_WORKER_THREADS>50\n# error SQLITE_MAX_WORKER_THREADS must be between 0 and 50\n#endif\n\n\n/*\n** Change the value of a limit.  Report the old value.\n** If an invalid limit index is supplied, report -1.\n** Make no changes but still report the old value if the\n** new limit is negative.\n**\n** A new lower limit does not shrink existing constructs.\n** It merely prevents new constructs that exceed the limit\n** from forming.\n*/\nSQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){\n  int oldLimit;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n\n  /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME\n  ** there is a hard upper bound set at compile-time by a C preprocessor\n  ** macro called SQLITE_MAX_NAME. (The \"_LIMIT_\" in the name is changed to\n  ** \"_MAX_\".)\n  */\n  assert( aHardLimit[SQLITE_LIMIT_LENGTH]==SQLITE_MAX_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH]==SQLITE_MAX_SQL_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_COLUMN]==SQLITE_MAX_COLUMN );\n  assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH]==SQLITE_MAX_EXPR_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT]==SQLITE_MAX_COMPOUND_SELECT);\n  assert( aHardLimit[SQLITE_LIMIT_VDBE_OP]==SQLITE_MAX_VDBE_OP );\n  assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG]==SQLITE_MAX_FUNCTION_ARG );\n  assert( aHardLimit[SQLITE_LIMIT_ATTACHED]==SQLITE_MAX_ATTACHED );\n  assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]==\n                                               SQLITE_MAX_LIKE_PATTERN_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER]==SQLITE_MAX_VARIABLE_NUMBER);\n  assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH]==SQLITE_MAX_TRIGGER_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_WORKER_THREADS]==SQLITE_MAX_WORKER_THREADS );\n  assert( SQLITE_LIMIT_WORKER_THREADS==(SQLITE_N_LIMIT-1) );\n\n\n  if( limitId<0 || limitId>=SQLITE_N_LIMIT ){\n    return -1;\n  }\n  oldLimit = db->aLimit[limitId];\n  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */\n    if( newLimit>aHardLimit[limitId] ){\n      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */\n    }\n    db->aLimit[limitId] = newLimit;\n  }\n  return oldLimit;                     /* IMP: R-53341-35419 */\n}\n\n/*\n** This function is used to parse both URIs and non-URI filenames passed by the\n** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database\n** URIs specified as part of ATTACH statements.\n**\n** The first argument to this function is the name of the VFS to use (or\n** a NULL to signify the default VFS) if the URI does not contain a \"vfs=xxx\"\n** query parameter. The second argument contains the URI (or non-URI filename)\n** itself. When this function is called the *pFlags variable should contain\n** the default flags to open the database handle with. The value stored in\n** *pFlags may be updated before returning if the URI filename contains \n** \"cache=xxx\" or \"mode=xxx\" query parameters.\n**\n** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to\n** the VFS that should be used to open the database file. *pzFile is set to\n** point to a buffer containing the name of the file to open. It is the \n** responsibility of the caller to eventually call sqlite3_free() to release\n** this buffer.\n**\n** If an error occurs, then an SQLite error code is returned and *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to eventually release\n** this buffer by calling sqlite3_free().\n*/\nSQLITE_PRIVATE int sqlite3ParseUri(\n  const char *zDefaultVfs,        /* VFS to use if no \"vfs=xxx\" query option */\n  const char *zUri,               /* Nul-terminated URI to parse */\n  unsigned int *pFlags,           /* IN/OUT: SQLITE_OPEN_XXX flags */\n  sqlite3_vfs **ppVfs,            /* OUT: VFS to use */ \n  char **pzFile,                  /* OUT: Filename component of URI */\n  char **pzErrMsg                 /* OUT: Error message (if rc!=SQLITE_OK) */\n){\n  int rc = SQLITE_OK;\n  unsigned int flags = *pFlags;\n  const char *zVfs = zDefaultVfs;\n  char *zFile;\n  char c;\n  int nUri = sqlite3Strlen30(zUri);\n\n  assert( *pzErrMsg==0 );\n\n  if( ((flags & SQLITE_OPEN_URI)             /* IMP: R-48725-32206 */\n            || sqlite3GlobalConfig.bOpenUri) /* IMP: R-51689-46548 */\n   && nUri>=5 && memcmp(zUri, \"file:\", 5)==0 /* IMP: R-57884-37496 */\n  ){\n    char *zOpt;\n    int eState;                   /* Parser state when parsing URI */\n    int iIn;                      /* Input character index */\n    int iOut = 0;                 /* Output character index */\n    u64 nByte = nUri+2;           /* Bytes of space to allocate */\n\n    /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen \n    ** method that there may be extra parameters following the file-name.  */\n    flags |= SQLITE_OPEN_URI;\n\n    for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');\n    zFile = sqlite3_malloc64(nByte);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n\n    iIn = 5;\n#ifdef SQLITE_ALLOW_URI_AUTHORITY\n    if( strncmp(zUri+5, \"///\", 3)==0 ){\n      iIn = 7;\n      /* The following condition causes URIs with five leading / characters\n      ** like file://///host/path to be converted into UNCs like //host/path.\n      ** The correct URI for that UNC has only two or four leading / characters\n      ** file://host/path or file:////host/path.  But 5 leading slashes is a \n      ** common error, we are told, so we handle it as a special case. */\n      if( strncmp(zUri+7, \"///\", 3)==0 ){ iIn++; }\n    }else if( strncmp(zUri+5, \"//localhost/\", 12)==0 ){\n      iIn = 16;\n    }\n#else\n    /* Discard the scheme and authority segments of the URI. */\n    if( zUri[5]=='/' && zUri[6]=='/' ){\n      iIn = 7;\n      while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;\n      if( iIn!=7 && (iIn!=16 || memcmp(\"localhost\", &zUri[7], 9)) ){\n        *pzErrMsg = sqlite3_mprintf(\"invalid uri authority: %.*s\", \n            iIn-7, &zUri[7]);\n        rc = SQLITE_ERROR;\n        goto parse_uri_out;\n      }\n    }\n#endif\n\n    /* Copy the filename and any query parameters into the zFile buffer. \n    ** Decode %HH escape codes along the way. \n    **\n    ** Within this loop, variable eState may be set to 0, 1 or 2, depending\n    ** on the parsing context. As follows:\n    **\n    **   0: Parsing file-name.\n    **   1: Parsing name section of a name=value query parameter.\n    **   2: Parsing value section of a name=value query parameter.\n    */\n    eState = 0;\n    while( (c = zUri[iIn])!=0 && c!='#' ){\n      iIn++;\n      if( c=='%' \n       && sqlite3Isxdigit(zUri[iIn]) \n       && sqlite3Isxdigit(zUri[iIn+1]) \n      ){\n        int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);\n        octet += sqlite3HexToInt(zUri[iIn++]);\n\n        assert( octet>=0 && octet<256 );\n        if( octet==0 ){\n#ifndef SQLITE_ENABLE_URI_00_ERROR\n          /* This branch is taken when \"%00\" appears within the URI. In this\n          ** case we ignore all text in the remainder of the path, name or\n          ** value currently being parsed. So ignore the current character\n          ** and skip to the next \"?\", \"=\" or \"&\", as appropriate. */\n          while( (c = zUri[iIn])!=0 && c!='#' \n              && (eState!=0 || c!='?')\n              && (eState!=1 || (c!='=' && c!='&'))\n              && (eState!=2 || c!='&')\n          ){\n            iIn++;\n          }\n          continue;\n#else\n          /* If ENABLE_URI_00_ERROR is defined, \"%00\" in a URI is an error. */\n          *pzErrMsg = sqlite3_mprintf(\"unexpected %%00 in uri\");\n          rc = SQLITE_ERROR;\n          goto parse_uri_out;\n#endif\n        }\n        c = octet;\n      }else if( eState==1 && (c=='&' || c=='=') ){\n        if( zFile[iOut-1]==0 ){\n          /* An empty option name. Ignore this option altogether. */\n          while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++;\n          continue;\n        }\n        if( c=='&' ){\n          zFile[iOut++] = '\\0';\n        }else{\n          eState = 2;\n        }\n        c = 0;\n      }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){\n        c = 0;\n        eState = 1;\n      }\n      zFile[iOut++] = c;\n    }\n    if( eState==1 ) zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n\n    /* Check if there were any options specified that should be interpreted \n    ** here. Options that are interpreted here include \"vfs\" and those that\n    ** correspond to flags that may be passed to the sqlite3_open_v2()\n    ** method. */\n    zOpt = &zFile[sqlite3Strlen30(zFile)+1];\n    while( zOpt[0] ){\n      int nOpt = sqlite3Strlen30(zOpt);\n      char *zVal = &zOpt[nOpt+1];\n      int nVal = sqlite3Strlen30(zVal);\n\n      if( nOpt==3 && memcmp(\"vfs\", zOpt, 3)==0 ){\n        zVfs = zVal;\n      }else{\n        struct OpenMode {\n          const char *z;\n          int mode;\n        } *aMode = 0;\n        char *zModeType = 0;\n        int mask = 0;\n        int limit = 0;\n\n        if( nOpt==5 && memcmp(\"cache\", zOpt, 5)==0 ){\n          static struct OpenMode aCacheMode[] = {\n            { \"shared\",  SQLITE_OPEN_SHAREDCACHE },\n            { \"private\", SQLITE_OPEN_PRIVATECACHE },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE;\n          aMode = aCacheMode;\n          limit = mask;\n          zModeType = \"cache\";\n        }\n        if( nOpt==4 && memcmp(\"mode\", zOpt, 4)==0 ){\n          static struct OpenMode aOpenMode[] = {\n            { \"ro\",  SQLITE_OPEN_READONLY },\n            { \"rw\",  SQLITE_OPEN_READWRITE }, \n            { \"rwc\", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE },\n            { \"memory\", SQLITE_OPEN_MEMORY },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE\n                   | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY;\n          aMode = aOpenMode;\n          limit = mask & flags;\n          zModeType = \"access\";\n        }\n\n        if( aMode ){\n          int i;\n          int mode = 0;\n          for(i=0; aMode[i].z; i++){\n            const char *z = aMode[i].z;\n            if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){\n              mode = aMode[i].mode;\n              break;\n            }\n          }\n          if( mode==0 ){\n            *pzErrMsg = sqlite3_mprintf(\"no such %s mode: %s\", zModeType, zVal);\n            rc = SQLITE_ERROR;\n            goto parse_uri_out;\n          }\n          if( (mode & ~SQLITE_OPEN_MEMORY)>limit ){\n            *pzErrMsg = sqlite3_mprintf(\"%s mode not allowed: %s\",\n                                        zModeType, zVal);\n            rc = SQLITE_PERM;\n            goto parse_uri_out;\n          }\n          flags = (flags & ~mask) | mode;\n        }\n      }\n\n      zOpt = &zVal[nVal+1];\n    }\n\n  }else{\n    zFile = sqlite3_malloc64(nUri+2);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n    if( nUri ){\n      memcpy(zFile, zUri, nUri);\n    }\n    zFile[nUri] = '\\0';\n    zFile[nUri+1] = '\\0';\n    flags &= ~SQLITE_OPEN_URI;\n  }\n\n  *ppVfs = sqlite3_vfs_find(zVfs);\n  if( *ppVfs==0 ){\n    *pzErrMsg = sqlite3_mprintf(\"no such vfs: %s\", zVfs);\n    rc = SQLITE_ERROR;\n  }\n parse_uri_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zFile);\n    zFile = 0;\n  }\n  *pFlags = flags;\n  *pzFile = zFile;\n  return rc;\n}\n\n\n/*\n** This routine does the work of opening a database on behalf of\n** sqlite3_open() and sqlite3_open16(). The database filename \"zFilename\"  \n** is UTF-8 encoded.\n*/\nstatic int openDatabase(\n  const char *zFilename, /* Database filename UTF-8 encoded */\n  sqlite3 **ppDb,        /* OUT: Returned database handle */\n  unsigned int flags,    /* Operational flags */\n  const char *zVfs       /* Name of the VFS to use */\n){\n  sqlite3 *db;                    /* Store allocated handle here */\n  int rc;                         /* Return code */\n  int isThreadsafe;               /* True for threadsafe connections */\n  char *zOpen = 0;                /* Filename argument to pass to BtreeOpen() */\n  char *zErrMsg = 0;              /* Error message from sqlite3ParseUri() */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n\n  if( sqlite3GlobalConfig.bCoreMutex==0 ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_NOMUTEX ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_FULLMUTEX ){\n    isThreadsafe = 1;\n  }else{\n    isThreadsafe = sqlite3GlobalConfig.bFullMutex;\n  }\n  if( flags & SQLITE_OPEN_PRIVATECACHE ){\n    flags &= ~SQLITE_OPEN_SHAREDCACHE;\n  }else if( sqlite3GlobalConfig.sharedCacheEnabled ){\n    flags |= SQLITE_OPEN_SHAREDCACHE;\n  }\n\n  /* Remove harmful bits from the flags parameter\n  **\n  ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were\n  ** dealt with in the previous code block.  Besides these, the only\n  ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,\n  ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,\n  ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits.  Silently mask\n  ** off all other flags.\n  */\n  flags &=  ~( SQLITE_OPEN_DELETEONCLOSE |\n               SQLITE_OPEN_EXCLUSIVE |\n               SQLITE_OPEN_MAIN_DB |\n               SQLITE_OPEN_TEMP_DB | \n               SQLITE_OPEN_TRANSIENT_DB | \n               SQLITE_OPEN_MAIN_JOURNAL | \n               SQLITE_OPEN_TEMP_JOURNAL | \n               SQLITE_OPEN_SUBJOURNAL | \n               SQLITE_OPEN_MASTER_JOURNAL |\n               SQLITE_OPEN_NOMUTEX |\n               SQLITE_OPEN_FULLMUTEX |\n               SQLITE_OPEN_WAL\n             );\n\n  /* Allocate the sqlite data structure */\n  db = sqlite3MallocZero( sizeof(sqlite3) );\n  if( db==0 ) goto opendb_out;\n  if( isThreadsafe ){\n    db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n    if( db->mutex==0 ){\n      sqlite3_free(db);\n      db = 0;\n      goto opendb_out;\n    }\n  }\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = 0xff;\n  db->nDb = 2;\n  db->magic = SQLITE_MAGIC_BUSY;\n  db->aDb = db->aDbStatic;\n\n  assert( sizeof(db->aLimit)==sizeof(aHardLimit) );\n  memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));\n  db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;\n  db->autoCommit = 1;\n  db->nextAutovac = -1;\n  db->szMmap = sqlite3GlobalConfig.szMmap;\n  db->nextPagesize = 0;\n  db->nMaxSorterMmap = 0x7FFFFFFF;\n  db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill\n#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX\n                 | SQLITE_AutoIndex\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n                 | SQLITE_CkptFullFSync\n#endif\n#if SQLITE_DEFAULT_FILE_FORMAT<4\n                 | SQLITE_LegacyFileFmt\n#endif\n#ifdef SQLITE_ENABLE_LOAD_EXTENSION\n                 | SQLITE_LoadExtension\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n                 | SQLITE_RecTriggers\n#endif\n#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS\n                 | SQLITE_ForeignKeys\n#endif\n#if defined(SQLITE_REVERSE_UNORDERED_SELECTS)\n                 | SQLITE_ReverseOrder\n#endif\n#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n                 | SQLITE_CellSizeCk\n#endif\n#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)\n                 | SQLITE_Fts3Tokenizer\n#endif\n#if defined(SQLITE_ENABLE_QPSG)\n                 | SQLITE_EnableQPSG\n#endif\n      ;\n  sqlite3HashInit(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3HashInit(&db->aModule);\n#endif\n\n  /* Add the default collation sequence BINARY. BINARY works for both UTF-8\n  ** and UTF-16, so add a version for each to avoid any unnecessary\n  ** conversions. The only error that can occur here is a malloc() failure.\n  **\n  ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating\n  ** functions:\n  */\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0);\n  createCollation(db, \"NOCASE\", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);\n  createCollation(db, \"RTRIM\", SQLITE_UTF8, (void*)1, binCollFunc, 0);\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n  /* EVIDENCE-OF: R-08308-17224 The default collating function for all\n  ** strings is BINARY. \n  */\n  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);\n  assert( db->pDfltColl!=0 );\n\n  /* Parse the filename/URI argument\n  **\n  ** Only allow sensible combinations of bits in the flags argument.  \n  ** Throw an error if any non-sense combination is used.  If we\n  ** do not block illegal combinations here, it could trigger\n  ** assert() statements in deeper layers.  Sensible combinations\n  ** are:\n  **\n  **  1:  SQLITE_OPEN_READONLY\n  **  2:  SQLITE_OPEN_READWRITE\n  **  6:  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE\n  */\n  db->openFlags = flags;\n  assert( SQLITE_OPEN_READONLY  == 0x01 );\n  assert( SQLITE_OPEN_READWRITE == 0x02 );\n  assert( SQLITE_OPEN_CREATE    == 0x04 );\n  testcase( (1<<(flags&7))==0x02 ); /* READONLY */\n  testcase( (1<<(flags&7))==0x04 ); /* READWRITE */\n  testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */\n  if( ((1<<(flags&7)) & 0x46)==0 ){\n    rc = SQLITE_MISUSE_BKPT;  /* IMP: R-65497-44594 */\n  }else{\n    rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n    sqlite3ErrorWithMsg(db, rc, zErrMsg ? \"%s\" : 0, zErrMsg);\n    sqlite3_free(zErrMsg);\n    goto opendb_out;\n  }\n\n  /* Open the backend database driver */\n  rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,\n                        flags | SQLITE_OPEN_MAIN_DB);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    sqlite3Error(db, rc);\n    goto opendb_out;\n  }\n  sqlite3BtreeEnter(db->aDb[0].pBt);\n  db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);\n  if( !db->mallocFailed ) ENC(db) = SCHEMA_ENC(db);\n  sqlite3BtreeLeave(db->aDb[0].pBt);\n  db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);\n\n  /* The default safety_level for the main database is FULL; for the temp\n  ** database it is OFF. This matches the pager layer defaults.  \n  */\n  db->aDb[0].zDbSName = \"main\";\n  db->aDb[0].safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  db->aDb[1].zDbSName = \"temp\";\n  db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF;\n\n  db->magic = SQLITE_MAGIC_OPEN;\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n\n  /* Register all built-in functions, but do not attempt to read the\n  ** database schema yet. This is delayed until the first time the database\n  ** is accessed.\n  */\n  sqlite3Error(db, SQLITE_OK);\n  sqlite3RegisterPerConnectionBuiltinFunctions(db);\n  rc = sqlite3_errcode(db);\n\n#ifdef SQLITE_ENABLE_FTS5\n  /* Register any built-in FTS5 module before loading the automatic\n  ** extensions. This allows automatic extensions to register FTS5 \n  ** tokenizers and auxiliary functions.  */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts5Init(db);\n  }\n#endif\n\n  /* Load automatic extensions - extensions that have been registered\n  ** using the sqlite3_automatic_extension() API.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3AutoLoadExtensions(db);\n    rc = sqlite3_errcode(db);\n    if( rc!=SQLITE_OK ){\n      goto opendb_out;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_FTS1\n  if( !db->mallocFailed ){\n    extern int sqlite3Fts1Init(sqlite3*);\n    rc = sqlite3Fts1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS2\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    extern int sqlite3Fts2Init(sqlite3*);\n    rc = sqlite3Fts2Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts3Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3IcuInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3RtreeInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBPAGE_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbpageRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBSTAT_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbstatRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_JSON1\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3Json1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_STMTVTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3StmtVtabInit(db);\n  }\n#endif\n\n  /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking\n  ** mode.  -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking\n  ** mode.  Doing nothing at all also makes NORMAL the default.\n  */\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE;\n  sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt),\n                          SQLITE_DEFAULT_LOCKING_MODE);\n#endif\n\n  if( rc ) sqlite3Error(db, rc);\n\n  /* Enable the lookaside-malloc subsystem */\n  setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,\n                        sqlite3GlobalConfig.nLookaside);\n\n  sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);\n\nopendb_out:\n  if( db ){\n    assert( db->mutex!=0 || isThreadsafe==0\n           || sqlite3GlobalConfig.bFullMutex==0 );\n    sqlite3_mutex_leave(db->mutex);\n  }\n  rc = sqlite3_errcode(db);\n  assert( db!=0 || rc==SQLITE_NOMEM );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_close(db);\n    db = 0;\n  }else if( rc!=SQLITE_OK ){\n    db->magic = SQLITE_MAGIC_SICK;\n  }\n  *ppDb = db;\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Opening a db handle. Fourth parameter is passed 0. */\n    void *pArg = sqlite3GlobalConfig.pSqllogArg;\n    sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC)\n  if( rc==SQLITE_OK ){\n    const char *zKey;\n    if( (zKey = sqlite3_uri_parameter(zOpen, \"hexkey\"))!=0 && zKey[0] ){\n      u8 iByte;\n      int i;\n      char zDecoded[40];\n      for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){\n        iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);\n        if( (i&1)!=0 ) zDecoded[i/2] = iByte;\n      }\n      sqlite3_key_v2(db, 0, zDecoded, i/2);\n    }else if( (zKey = sqlite3_uri_parameter(zOpen, \"key\"))!=0 ){\n      sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));\n    }\n  }\n#endif\n  sqlite3_free(zOpen);\n  return rc & 0xff;\n}\n\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open(\n  const char *zFilename, \n  sqlite3 **ppDb \n){\n  return openDatabase(zFilename, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n}\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n){\n  return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Open a new database handle.\n*/\nSQLITE_API int sqlite3_open16(\n  const void *zFilename, \n  sqlite3 **ppDb\n){\n  char const *zFilename8;   /* zFilename encoded in UTF-8 instead of UTF-16 */\n  sqlite3_value *pVal;\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( zFilename==0 ) zFilename = \"\\000\\000\";\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zFilename8 ){\n    rc = openDatabase(zFilename8, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n    assert( *ppDb || rc==SQLITE_NOMEM );\n    if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){\n      SCHEMA_ENC(*ppDb) = ENC(*ppDb) = SQLITE_UTF16NATIVE;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  return sqlite3_create_collation_v2(db, zName, enc, pCtx, xCompare, 0);\n}\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a new collation sequence with the database handle db.\n*/\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3* db, \n  const void *zName,\n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  int rc = SQLITE_OK;\n  char *zName8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);\n  if( zName8 ){\n    rc = createCollation(db, zName8, (u8)enc, pCtx, xCompare, 0);\n    sqlite3DbFree(db, zName8);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = xCollNeeded;\n  db->xCollNeeded16 = 0;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = 0;\n  db->xCollNeeded16 = xCollNeeded16;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This function is now an anachronism. It used to be used to recover from a\n** malloc() failure, but SQLite now does this automatically.\n*/\nSQLITE_API int sqlite3_global_recover(void){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Test to see whether or not the database connection is in autocommit\n** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on\n** by default.  Autocommit is disabled by a BEGIN statement and reenabled\n** by the next COMMIT or ROLLBACK.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->autoCommit;\n}\n\n/*\n** The following routines are substitutes for constants SQLITE_CORRUPT,\n** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error\n** constants.  They serve two purposes:\n**\n**   1.  Serve as a convenient place to set a breakpoint in a debugger\n**       to detect when version error conditions occurs.\n**\n**   2.  Invoke sqlite3_log() to provide the source code location where\n**       a low-level error is first detected.\n*/\nstatic int reportError(int iErr, int lineno, const char *zType){\n  sqlite3_log(iErr, \"%s at line %d of [%.10s]\",\n              zType, lineno, 20+sqlite3_sourceid());\n  return iErr;\n}\nSQLITE_PRIVATE int sqlite3CorruptError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CORRUPT, lineno, \"database corruption\");\n}\nSQLITE_PRIVATE int sqlite3MisuseError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_MISUSE, lineno, \"misuse\");\n}\nSQLITE_PRIVATE int sqlite3CantopenError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CANTOPEN, lineno, \"cannot open file\");\n}\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3CorruptPgnoError(int lineno, Pgno pgno){\n  char zMsg[100];\n  sqlite3_snprintf(sizeof(zMsg), zMsg, \"database corruption page %d\", pgno);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CORRUPT, lineno, zMsg);\n}\nSQLITE_PRIVATE int sqlite3NomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_NOMEM, lineno, \"OOM\");\n}\nSQLITE_PRIVATE int sqlite3IoerrnomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_IOERR_NOMEM, lineno, \"I/O OOM error\");\n}\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This is a convenience routine that makes sure that all thread-specific\n** data for this thread has been deallocated.\n**\n** SQLite no longer uses thread-specific data so this routine is now a\n** no-op.  It is retained for historical compatibility.\n*/\nSQLITE_API void sqlite3_thread_cleanup(void){\n}\n#endif\n\n/*\n** Return meta information about a specific column of a database table.\n** See comment in sqlite3.h (sqlite.h.in) for details.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n){\n  int rc;\n  char *zErrMsg = 0;\n  Table *pTab = 0;\n  Column *pCol = 0;\n  int iCol = 0;\n  char const *zDataType = 0;\n  char const *zCollSeq = 0;\n  int notnull = 0;\n  int primarykey = 0;\n  int autoinc = 0;\n\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTableName==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  /* Ensure the database schema has been loaded */\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Init(db, &zErrMsg);\n  if( SQLITE_OK!=rc ){\n    goto error_out;\n  }\n\n  /* Locate the table in question */\n  pTab = sqlite3FindTable(db, zTableName, zDbName);\n  if( !pTab || pTab->pSelect ){\n    pTab = 0;\n    goto error_out;\n  }\n\n  /* Find the column for which info is requested */\n  if( zColumnName==0 ){\n    /* Query for existance of table only */\n  }else{\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      pCol = &pTab->aCol[iCol];\n      if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){\n        iCol = pTab->iPKey;\n        pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;\n      }else{\n        pTab = 0;\n        goto error_out;\n      }\n    }\n  }\n\n  /* The following block stores the meta information that will be returned\n  ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey\n  ** and autoinc. At this point there are two possibilities:\n  ** \n  **     1. The specified column name was rowid\", \"oid\" or \"_rowid_\" \n  **        and there is no explicitly declared IPK column. \n  **\n  **     2. The table is not a view and the column name identified an \n  **        explicitly declared column. Copy meta information from *pCol.\n  */ \n  if( pCol ){\n    zDataType = sqlite3ColumnType(pCol,0);\n    zCollSeq = pCol->zColl;\n    notnull = pCol->notNull!=0;\n    primarykey  = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;\n    autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;\n  }else{\n    zDataType = \"INTEGER\";\n    primarykey = 1;\n  }\n  if( !zCollSeq ){\n    zCollSeq = sqlite3StrBINARY;\n  }\n\nerror_out:\n  sqlite3BtreeLeaveAll(db);\n\n  /* Whether the function call succeeded or failed, set the output parameters\n  ** to whatever their local counterparts contain. If an error did occur,\n  ** this has the effect of zeroing all output parameters.\n  */\n  if( pzDataType ) *pzDataType = zDataType;\n  if( pzCollSeq ) *pzCollSeq = zCollSeq;\n  if( pNotNull ) *pNotNull = notnull;\n  if( pPrimaryKey ) *pPrimaryKey = primarykey;\n  if( pAutoinc ) *pAutoinc = autoinc;\n\n  if( SQLITE_OK==rc && !pTab ){\n    sqlite3DbFree(db, zErrMsg);\n    zErrMsg = sqlite3MPrintf(db, \"no such table column: %s.%s\", zTableName,\n        zColumnName);\n    rc = SQLITE_ERROR;\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErrMsg?\"%s\":0), zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nSQLITE_API int sqlite3_sleep(int ms){\n  sqlite3_vfs *pVfs;\n  int rc;\n  pVfs = sqlite3_vfs_find(0);\n  if( pVfs==0 ) return 0;\n\n  /* This function works in milliseconds, but the underlying OsSleep() \n  ** API uses microseconds. Hence the 1000's.\n  */\n  rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);\n  return rc;\n}\n\n/*\n** Enable or disable the extended result codes.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = onoff ? 0xffffffff : 0xff;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xFileControl method on a particular database.\n*/\nSQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){\n  int rc = SQLITE_ERROR;\n  Btree *pBtree;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pBtree = sqlite3DbNameToBtree(db, zDbName);\n  if( pBtree ){\n    Pager *pPager;\n    sqlite3_file *fd;\n    sqlite3BtreeEnter(pBtree);\n    pPager = sqlite3BtreePager(pBtree);\n    assert( pPager!=0 );\n    fd = sqlite3PagerFile(pPager);\n    assert( fd!=0 );\n    if( op==SQLITE_FCNTL_FILE_POINTER ){\n      *(sqlite3_file**)pArg = fd;\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_VFS_POINTER ){\n      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){\n      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);\n      rc = SQLITE_OK;\n    }else if( fd->pMethods ){\n      rc = sqlite3OsFileControl(fd, op, pArg);\n    }else{\n      rc = SQLITE_NOTFOUND;\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Interface to the testing logic.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...){\n  int rc = 0;\n#ifdef SQLITE_UNTESTABLE\n  UNUSED_PARAMETER(op);\n#else\n  va_list ap;\n  va_start(ap, op);\n  switch( op ){\n\n    /*\n    ** Save the current state of the PRNG.\n    */\n    case SQLITE_TESTCTRL_PRNG_SAVE: {\n      sqlite3PrngSaveState();\n      break;\n    }\n\n    /*\n    ** Restore the state of the PRNG to the last state saved using\n    ** PRNG_SAVE.  If PRNG_SAVE has never before been called, then\n    ** this verb acts like PRNG_RESET.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESTORE: {\n      sqlite3PrngRestoreState();\n      break;\n    }\n\n    /*\n    ** Reset the PRNG back to its uninitialized state.  The next call\n    ** to sqlite3_randomness() will reseed the PRNG using a single call\n    ** to the xRandomness method of the default VFS.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESET: {\n      sqlite3_randomness(0,0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BITVEC_TEST, size, program)\n    **\n    ** Run a test against a Bitvec object of size.  The program argument\n    ** is an array of integers that defines the test.  Return -1 on a\n    ** memory allocation error, 0 on success, or non-zero for an error.\n    ** See the sqlite3BitvecBuiltinTest() for additional information.\n    */\n    case SQLITE_TESTCTRL_BITVEC_TEST: {\n      int sz = va_arg(ap, int);\n      int *aProg = va_arg(ap, int*);\n      rc = sqlite3BitvecBuiltinTest(sz, aProg);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(FAULT_INSTALL, xCallback)\n    **\n    ** Arrange to invoke xCallback() whenever sqlite3FaultSim() is called,\n    ** if xCallback is not NULL.\n    **\n    ** As a test of the fault simulator mechanism itself, sqlite3FaultSim(0)\n    ** is called immediately after installing the new callback and the return\n    ** value from sqlite3FaultSim(0) becomes the return from\n    ** sqlite3_test_control().\n    */\n    case SQLITE_TESTCTRL_FAULT_INSTALL: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));\n      */\n      typedef int(*TESTCALLBACKFUNC_t)(int);\n      sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);\n      rc = sqlite3FaultSim(0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)\n    **\n    ** Register hooks to call to indicate which malloc() failures \n    ** are benign.\n    */\n    case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: {\n      typedef void (*void_function)(void);\n      void_function xBenignBegin;\n      void_function xBenignEnd;\n      xBenignBegin = va_arg(ap, void_function);\n      xBenignEnd = va_arg(ap, void_function);\n      sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X)\n    **\n    ** Set the PENDING byte to the value in the argument, if X>0.\n    ** Make no changes if X==0.  Return the value of the pending byte\n    ** as it existing before this routine was called.\n    **\n    ** IMPORTANT:  Changing the PENDING byte from 0x40000000 results in\n    ** an incompatible database file format.  Changing the PENDING byte\n    ** while any database connection is open results in undefined and\n    ** deleterious behavior.\n    */\n    case SQLITE_TESTCTRL_PENDING_BYTE: {\n      rc = PENDING_BYTE;\n#ifndef SQLITE_OMIT_WSD\n      {\n        unsigned int newVal = va_arg(ap, unsigned int);\n        if( newVal ) sqlite3PendingByte = newVal;\n      }\n#endif\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X)\n    **\n    ** This action provides a run-time test to see whether or not\n    ** assert() was enabled at compile-time.  If X is true and assert()\n    ** is enabled, then the return value is true.  If X is true and\n    ** assert() is disabled, then the return value is zero.  If X is\n    ** false and assert() is enabled, then the assertion fires and the\n    ** process aborts.  If X is false and assert() is disabled, then the\n    ** return value is zero.\n    */\n    case SQLITE_TESTCTRL_ASSERT: {\n      volatile int x = 0;\n      assert( /*side-effects-ok*/ (x = va_arg(ap,int))!=0 );\n      rc = x;\n      break;\n    }\n\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X)\n    **\n    ** This action provides a run-time test to see how the ALWAYS and\n    ** NEVER macros were defined at compile-time.\n    **\n    ** The return value is ALWAYS(X) if X is true, or 0 if X is false.\n    **\n    ** The recommended test is X==2.  If the return value is 2, that means\n    ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the\n    ** default setting.  If the return value is 1, then ALWAYS() is either\n    ** hard-coded to true or else it asserts if its argument is false.\n    ** The first behavior (hard-coded to true) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second\n    ** behavior (assert if the argument to ALWAYS() is false) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled.\n    **\n    ** The run-time test procedure might look something like this:\n    **\n    **    if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){\n    **      // ALWAYS() and NEVER() are no-op pass-through macros\n    **    }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){\n    **      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.\n    **    }else{\n    **      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.\n    **    }\n    */\n    case SQLITE_TESTCTRL_ALWAYS: {\n      int x = va_arg(ap,int);\n      rc = x ? ALWAYS(x) : 0;\n      break;\n    }\n\n    /*\n    **   sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER);\n    **\n    ** The integer returned reveals the byte-order of the computer on which\n    ** SQLite is running:\n    **\n    **       1     big-endian,    determined at run-time\n    **      10     little-endian, determined at run-time\n    **  432101     big-endian,    determined at compile-time\n    **  123410     little-endian, determined at compile-time\n    */ \n    case SQLITE_TESTCTRL_BYTEORDER: {\n      rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN;\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)\n    **\n    ** Set the nReserve size to N for the main database on the database\n    ** connection db.\n    */\n    case SQLITE_TESTCTRL_RESERVE: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      int x = va_arg(ap,int);\n      sqlite3_mutex_enter(db->mutex);\n      sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)\n    **\n    ** Enable or disable various optimizations for testing purposes.  The \n    ** argument N is a bitmask of optimizations to be disabled.  For normal\n    ** operation N should be 0.  The idea is that a test program (like the\n    ** SQL Logic Test or SLT test module) can run the same SQL multiple times\n    ** with various optimizations disabled to verify that the same answer\n    ** is obtained in every case.\n    */\n    case SQLITE_TESTCTRL_OPTIMIZATIONS: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);\n      break;\n    }\n\n#ifdef SQLITE_N_KEYWORD\n    /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)\n    **\n    ** If zWord is a keyword recognized by the parser, then return the\n    ** number of keywords.  Or if zWord is not a keyword, return 0.\n    ** \n    ** This test feature is only available in the amalgamation since\n    ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite\n    ** is built using separate source files.\n    */\n    case SQLITE_TESTCTRL_ISKEYWORD: {\n      const char *zWord = va_arg(ap, const char*);\n      int n = sqlite3Strlen30(zWord);\n      rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;\n      break;\n    }\n#endif \n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);\n    **\n    ** If parameter onoff is non-zero, configure the wrappers so that all\n    ** subsequent calls to localtime() and variants fail. If onoff is zero,\n    ** undo this setting.\n    */\n    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {\n      sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);\n    **\n    ** Set or clear a flag that indicates that the database file is always well-\n    ** formed and never corrupt.  This flag is clear by default, indicating that\n    ** database files might have arbitrary corruption.  Setting the flag during\n    ** testing causes certain assert() statements in the code to be activated\n    ** that demonstrat invariants on well-formed database files.\n    */\n    case SQLITE_TESTCTRL_NEVER_CORRUPT: {\n      sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);\n      break;\n    }\n\n    /* Set the threshold at which OP_Once counters reset back to zero.\n    ** By default this is 0x7ffffffe (over 2 billion), but that value is\n    ** too big to test in a reasonable amount of time, so this control is\n    ** provided to set a small and easily reachable reset value.\n    */\n    case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: {\n      sqlite3GlobalConfig.iOnceResetThreshold = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE, xCallback, ptr);\n    **\n    ** Set the VDBE coverage callback function to xCallback with context \n    ** pointer ptr.\n    */\n    case SQLITE_TESTCTRL_VDBE_COVERAGE: {\n#ifdef SQLITE_VDBE_COVERAGE\n      typedef void (*branch_callback)(void*,int,u8,u8);\n      sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);\n      sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);\n#endif\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); */\n    case SQLITE_TESTCTRL_SORTER_MMAP: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->nMaxSorterMmap = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_ISINIT);\n    **\n    ** Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if\n    ** not.\n    */\n    case SQLITE_TESTCTRL_ISINIT: {\n      if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);\n    **\n    ** This test control is used to create imposter tables.  \"db\" is a pointer\n    ** to the database connection.  dbName is the database name (ex: \"main\" or\n    ** \"temp\") which will receive the imposter.  \"onOff\" turns imposter mode on\n    ** or off.  \"tnum\" is the root page of the b-tree to which the imposter\n    ** table should connect.\n    **\n    ** Enable imposter mode only when the schema has already been parsed.  Then\n    ** run a single CREATE TABLE statement to construct the imposter table in\n    ** the parsed schema.  Then turn imposter mode back off again.\n    **\n    ** If onOff==0 and tnum>0 then reset the schema for all databases, causing\n    ** the schema to be reparsed the next time it is needed.  This has the\n    ** effect of erasing all imposter tables.\n    */\n    case SQLITE_TESTCTRL_IMPOSTER: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      sqlite3_mutex_enter(db->mutex);\n      db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*));\n      db->init.busy = db->init.imposterTable = va_arg(ap,int);\n      db->init.newTnum = va_arg(ap,int);\n      if( db->init.busy==0 && db->init.newTnum>0 ){\n        sqlite3ResetAllSchemasOfConnection(db);\n      }\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n  }\n  va_end(ap);\n#endif /* SQLITE_UNTESTABLE */\n  return rc;\n}\n\n/*\n** This is a utility routine, useful to VFS implementations, that checks\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of the query parameter.\n**\n** The zFilename argument is the filename pointer passed into the xOpen()\n** method of a VFS implementation.  The zParam argument is the name of the\n** query parameter we seek.  This routine returns the value of the zParam\n** parameter if it exists.  If the parameter does not exist, this routine\n** returns a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){\n  if( zFilename==0 || zParam==0 ) return 0;\n  zFilename += sqlite3Strlen30(zFilename) + 1;\n  while( zFilename[0] ){\n    int x = strcmp(zFilename, zParam);\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n    if( x==0 ) return zFilename;\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n  }\n  return 0;\n}\n\n/*\n** Return a boolean value for a query parameter.\n*/\nSQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  bDflt = bDflt!=0;\n  return z ? sqlite3GetBoolean(z, bDflt) : bDflt;\n}\n\n/*\n** Return a 64-bit integer value for a query parameter.\n*/\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(\n  const char *zFilename,    /* Filename as passed to xOpen */\n  const char *zParam,       /* URI parameter sought */\n  sqlite3_int64 bDflt       /* return if parameter is missing */\n){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  sqlite3_int64 v;\n  if( z && sqlite3DecOrHexToI64(z, &v)==0 ){\n    bDflt = v;\n  }\n  return bDflt;\n}\n\n/*\n** Return the Btree pointer identified by zDbName.  Return NULL if not found.\n*/\nSQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){\n  int iDb = zDbName ? sqlite3FindDbName(db, zDbName) : 0;\n  return iDb<0 ? 0 : db->aDb[iDb].pBt;\n}\n\n/*\n** Return the filename of the database associated with a database\n** connection.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeGetFilename(pBt) : 0;\n}\n\n/*\n** Return 1 if database is read-only or 0 if read/write.  Return -1 if\n** no such database exists.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeIsReadonly(pBt) : -1;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Obtain a snapshot handle for the snapshot of database zDb currently \n** being read by handle db.\n*/\nSQLITE_API int sqlite3_snapshot_get(\n  sqlite3 *db, \n  const char *zDb,\n  sqlite3_snapshot **ppSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n\n  if( db->autoCommit==0 ){\n    int iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( 0==sqlite3BtreeIsInTrans(pBt) ){\n        rc = sqlite3BtreeBeginTrans(pBt, 0);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Open a read-transaction on the snapshot idendified by pSnapshot.\n*/\nSQLITE_API int sqlite3_snapshot_open(\n  sqlite3 *db, \n  const char *zDb, \n  sqlite3_snapshot *pSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( db->autoCommit==0 ){\n    int iDb;\n    iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( 0==sqlite3BtreeIsInReadTrans(pBt) ){\n        rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3BtreeBeginTrans(pBt, 0);\n          sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Recover as many snapshots as possible from the wal file associated with\n** schema zDb of database db.\n*/\nSQLITE_API int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_ERROR;\n  int iDb;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  sqlite3_mutex_enter(db->mutex);\n  iDb = sqlite3FindDbName(db, zDb);\n  if( iDb==0 || iDb>1 ){\n    Btree *pBt = db->aDb[iDb].pBt;\n    if( 0==sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));\n        sqlite3BtreeCommit(pBt);\n      }\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Free a snapshot handle obtained from sqlite3_snapshot_get().\n*/\nSQLITE_API void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){\n  sqlite3_free(pSnapshot);\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n/*\n** Given the name of a compile-time option, return true if that option\n** was used and false if not.\n**\n** The name can optionally begin with \"SQLITE_\" but the \"SQLITE_\" prefix\n** is not required for a match.\n*/\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName){\n  int i, n;\n  int nOpt;\n  const char **azCompileOpt;\n \n#if SQLITE_ENABLE_API_ARMOR\n  if( zOptName==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n\n  if( sqlite3StrNICmp(zOptName, \"SQLITE_\", 7)==0 ) zOptName += 7;\n  n = sqlite3Strlen30(zOptName);\n\n  /* Since nOpt is normally in single digits, a linear search is \n  ** adequate. No need for a binary search. */\n  for(i=0; i<nOpt; i++){\n    if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0\n     && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return the N-th compile-time option string.  If N is out of range,\n** return a NULL pointer.\n*/\nSQLITE_API const char *sqlite3_compileoption_get(int N){\n  int nOpt;\n  const char **azCompileOpt;\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n  if( N>=0 && N<nOpt ){\n    return azCompileOpt[N];\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/************** End of main.c ************************************************/\n/************** Begin file notify.c ******************************************/\n/*\n** 2009 March 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of the sqlite3_unlock_notify()\n** API method and its associated functionality.\n*/\n/* #include \"sqliteInt.h\" */\n/* #include \"btreeInt.h\" */\n\n/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n\n/*\n** Public interfaces:\n**\n**   sqlite3ConnectionBlocked()\n**   sqlite3ConnectionUnlocked()\n**   sqlite3ConnectionClosed()\n**   sqlite3_unlock_notify()\n*/\n\n#define assertMutexHeld() \\\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) )\n\n/*\n** Head of a linked list of all sqlite3 objects created by this process\n** for which either sqlite3.pBlockingConnection or sqlite3.pUnlockConnection\n** is not NULL. This variable may only accessed while the STATIC_MASTER\n** mutex is held.\n*/\nstatic sqlite3 *SQLITE_WSD sqlite3BlockedList = 0;\n\n#ifndef NDEBUG\n/*\n** This function is a complex assert() that verifies the following \n** properties of the blocked connections list:\n**\n**   1) Each entry in the list has a non-NULL value for either \n**      pUnlockConnection or pBlockingConnection, or both.\n**\n**   2) All entries in the list that share a common value for \n**      xUnlockNotify are grouped together.\n**\n**   3) If the argument db is not NULL, then none of the entries in the\n**      blocked connections list have pUnlockConnection or pBlockingConnection\n**      set to db. This is used when closing connection db.\n*/\nstatic void checkListProperties(sqlite3 *db){\n  sqlite3 *p;\n  for(p=sqlite3BlockedList; p; p=p->pNextBlocked){\n    int seen = 0;\n    sqlite3 *p2;\n\n    /* Verify property (1) */\n    assert( p->pUnlockConnection || p->pBlockingConnection );\n\n    /* Verify property (2) */\n    for(p2=sqlite3BlockedList; p2!=p; p2=p2->pNextBlocked){\n      if( p2->xUnlockNotify==p->xUnlockNotify ) seen = 1;\n      assert( p2->xUnlockNotify==p->xUnlockNotify || !seen );\n      assert( db==0 || p->pUnlockConnection!=db );\n      assert( db==0 || p->pBlockingConnection!=db );\n    }\n  }\n}\n#else\n# define checkListProperties(x)\n#endif\n\n/*\n** Remove connection db from the blocked connections list. If connection\n** db is not currently a part of the list, this function is a no-op.\n*/\nstatic void removeFromBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(pp=&sqlite3BlockedList; *pp; pp = &(*pp)->pNextBlocked){\n    if( *pp==db ){\n      *pp = (*pp)->pNextBlocked;\n      break;\n    }\n  }\n}\n\n/*\n** Add connection db to the blocked connections list. It is assumed\n** that it is not already a part of the list.\n*/\nstatic void addToBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(\n    pp=&sqlite3BlockedList; \n    *pp && (*pp)->xUnlockNotify!=db->xUnlockNotify; \n    pp=&(*pp)->pNextBlocked\n  );\n  db->pNextBlocked = *pp;\n  *pp = db;\n}\n\n/*\n** Obtain the STATIC_MASTER mutex.\n*/\nstatic void enterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  checkListProperties(0);\n}\n\n/*\n** Release the STATIC_MASTER mutex.\n*/\nstatic void leaveMutex(void){\n  assertMutexHeld();\n  checkListProperties(0);\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n\n/*\n** Register an unlock-notify callback.\n**\n** This is called after connection \"db\" has attempted some operation\n** but has received an SQLITE_LOCKED error because another connection\n** (call it pOther) in the same process was busy using the same shared\n** cache.  pOther is found by looking at db->pBlockingConnection.\n**\n** If there is no blocking connection, the callback is invoked immediately,\n** before this routine returns.\n**\n** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate\n** a deadlock.\n**\n** Otherwise, make arrangements to invoke xNotify when pOther drops\n** its locks.\n**\n** Each call to this routine overrides any prior callbacks registered\n** on the same \"db\".  If xNotify==0 then any prior callbacks are immediately\n** cancelled.\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *db,\n  void (*xNotify)(void **, int),\n  void *pArg\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  enterMutex();\n\n  if( xNotify==0 ){\n    removeFromBlockedList(db);\n    db->pBlockingConnection = 0;\n    db->pUnlockConnection = 0;\n    db->xUnlockNotify = 0;\n    db->pUnlockArg = 0;\n  }else if( 0==db->pBlockingConnection ){\n    /* The blocking transaction has been concluded. Or there never was a \n    ** blocking transaction. In either case, invoke the notify callback\n    ** immediately. \n    */\n    xNotify(&pArg, 1);\n  }else{\n    sqlite3 *p;\n\n    for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}\n    if( p ){\n      rc = SQLITE_LOCKED;              /* Deadlock detected. */\n    }else{\n      db->pUnlockConnection = db->pBlockingConnection;\n      db->xUnlockNotify = xNotify;\n      db->pUnlockArg = pArg;\n      removeFromBlockedList(db);\n      addToBlockedList(db);\n    }\n  }\n\n  leaveMutex();\n  assert( !db->mallocFailed );\n  sqlite3ErrorWithMsg(db, rc, (rc?\"database is deadlocked\":0));\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is called while stepping or preparing a statement \n** associated with connection db. The operation will return SQLITE_LOCKED\n** to the user because it requires a lock that will not be available\n** until connection pBlocker concludes its current transaction.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionBlocked(sqlite3 *db, sqlite3 *pBlocker){\n  enterMutex();\n  if( db->pBlockingConnection==0 && db->pUnlockConnection==0 ){\n    addToBlockedList(db);\n  }\n  db->pBlockingConnection = pBlocker;\n  leaveMutex();\n}\n\n/*\n** This function is called when\n** the transaction opened by database db has just finished. Locks held \n** by database connection db have been released.\n**\n** This function loops through each entry in the blocked connections\n** list and does the following:\n**\n**   1) If the sqlite3.pBlockingConnection member of a list entry is\n**      set to db, then set pBlockingConnection=0.\n**\n**   2) If the sqlite3.pUnlockConnection member of a list entry is\n**      set to db, then invoke the configured unlock-notify callback and\n**      set pUnlockConnection=0.\n**\n**   3) If the two steps above mean that pBlockingConnection==0 and\n**      pUnlockConnection==0, remove the entry from the blocked connections\n**      list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionUnlocked(sqlite3 *db){\n  void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */\n  int nArg = 0;                            /* Number of entries in aArg[] */\n  sqlite3 **pp;                            /* Iterator variable */\n  void **aArg;               /* Arguments to the unlock callback */\n  void **aDyn = 0;           /* Dynamically allocated space for aArg[] */\n  void *aStatic[16];         /* Starter space for aArg[].  No malloc required */\n\n  aArg = aStatic;\n  enterMutex();         /* Enter STATIC_MASTER mutex */\n\n  /* This loop runs once for each entry in the blocked-connections list. */\n  for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){\n    sqlite3 *p = *pp;\n\n    /* Step 1. */\n    if( p->pBlockingConnection==db ){\n      p->pBlockingConnection = 0;\n    }\n\n    /* Step 2. */\n    if( p->pUnlockConnection==db ){\n      assert( p->xUnlockNotify );\n      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){\n        xUnlockNotify(aArg, nArg);\n        nArg = 0;\n      }\n\n      sqlite3BeginBenignMalloc();\n      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );\n      assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );\n      if( (!aDyn && nArg==(int)ArraySize(aStatic))\n       || (aDyn && nArg==(int)(sqlite3MallocSize(aDyn)/sizeof(void*)))\n      ){\n        /* The aArg[] array needs to grow. */\n        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);\n        if( pNew ){\n          memcpy(pNew, aArg, nArg*sizeof(void *));\n          sqlite3_free(aDyn);\n          aDyn = aArg = pNew;\n        }else{\n          /* This occurs when the array of context pointers that need to\n          ** be passed to the unlock-notify callback is larger than the\n          ** aStatic[] array allocated on the stack and the attempt to \n          ** allocate a larger array from the heap has failed.\n          **\n          ** This is a difficult situation to handle. Returning an error\n          ** code to the caller is insufficient, as even if an error code\n          ** is returned the transaction on connection db will still be\n          ** closed and the unlock-notify callbacks on blocked connections\n          ** will go unissued. This might cause the application to wait\n          ** indefinitely for an unlock-notify callback that will never \n          ** arrive.\n          **\n          ** Instead, invoke the unlock-notify callback with the context\n          ** array already accumulated. We can then clear the array and\n          ** begin accumulating any further context pointers without \n          ** requiring any dynamic allocation. This is sub-optimal because\n          ** it means that instead of one callback with a large array of\n          ** context pointers the application will receive two or more\n          ** callbacks with smaller arrays of context pointers, which will\n          ** reduce the applications ability to prioritize multiple \n          ** connections. But it is the best that can be done under the\n          ** circumstances.\n          */\n          xUnlockNotify(aArg, nArg);\n          nArg = 0;\n        }\n      }\n      sqlite3EndBenignMalloc();\n\n      aArg[nArg++] = p->pUnlockArg;\n      xUnlockNotify = p->xUnlockNotify;\n      p->pUnlockConnection = 0;\n      p->xUnlockNotify = 0;\n      p->pUnlockArg = 0;\n    }\n\n    /* Step 3. */\n    if( p->pBlockingConnection==0 && p->pUnlockConnection==0 ){\n      /* Remove connection p from the blocked connections list. */\n      *pp = p->pNextBlocked;\n      p->pNextBlocked = 0;\n    }else{\n      pp = &p->pNextBlocked;\n    }\n  }\n\n  if( nArg!=0 ){\n    xUnlockNotify(aArg, nArg);\n  }\n  sqlite3_free(aDyn);\n  leaveMutex();         /* Leave STATIC_MASTER mutex */\n}\n\n/*\n** This is called when the database connection passed as an argument is \n** being closed. The connection is removed from the blocked list.\n*/\nSQLITE_PRIVATE void sqlite3ConnectionClosed(sqlite3 *db){\n  sqlite3ConnectionUnlocked(db);\n  enterMutex();\n  removeFromBlockedList(db);\n  checkListProperties(db);\n  leaveMutex();\n}\n#endif\n\n/************** End of notify.c **********************************************/\n/************** Begin file fts3.c ********************************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n\n/* The full-text index is stored in a series of b+tree (-like)\n** structures called segments which map terms to doclists.  The\n** structures are like b+trees in layout, but are constructed from the\n** bottom up in optimal fashion and are not updatable.  Since trees\n** are built from the bottom up, things will be described from the\n** bottom up.\n**\n**\n**** Varints ****\n** The basic unit of encoding is a variable-length integer called a\n** varint.  We encode variable-length integers in little-endian order\n** using seven bits * per byte as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** and so on.\n**\n** This is similar in concept to how sqlite encodes \"varints\" but\n** the encoding is not the same.  SQLite varints are big-endian\n** are are limited to 9 bytes in length whereas FTS3 varints are\n** little-endian and can be up to 10 bytes in length (in theory).\n**\n** Example encodings:\n**\n**     1:    0x01\n**   127:    0x7f\n**   128:    0x81 0x00\n**\n**\n**** Document lists ****\n** A doclist (document list) holds a docid-sorted list of hits for a\n** given term.  Doclists hold docids and associated token positions.\n** A docid is the unique integer identifier for a single document.\n** A position is the index of a word within the document.  The first \n** word of the document has a position of 0.\n**\n** FTS3 used to optionally store character offsets using a compile-time\n** option.  But that functionality is no longer supported.\n**\n** A doclist is stored like this:\n**\n** array {\n**   varint docid;          (delta from previous doclist)\n**   array {                (position list for column 0)\n**     varint position;     (2 more than the delta from previous position)\n**   }\n**   array {\n**     varint POS_COLUMN;   (marks start of position list for new column)\n**     varint column;       (index of new column)\n**     array {\n**       varint position;   (2 more than the delta from previous position)\n**     }\n**   }\n**   varint POS_END;        (marks end of positions for this document.\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.  A \"position\" is an index of a token in the token stream\n** generated by the tokenizer. Note that POS_END and POS_COLUMN occur \n** in the same logical place as the position element, and act as sentinals\n** ending a position list array.  POS_END is 0.  POS_COLUMN is 1.\n** The positions numbers are not stored literally but rather as two more\n** than the difference from the prior position, or the just the position plus\n** 2 for the first position.  Example:\n**\n**   label:       A B C D E  F  G H   I  J K\n**   value:     123 5 9 1 1 14 35 0 234 72 0\n**\n** The 123 value is the first docid.  For column zero in this document\n** there are two matches at positions 3 and 10 (5-2 and 9-2+3).  The 1\n** at D signals the start of a new column; the 1 at E indicates that the\n** new column is column number 1.  There are two positions at 12 and 45\n** (14-2 and 35-2+12).  The 0 at H indicate the end-of-document.  The\n** 234 at I is the delta to next docid (357).  It has one position 70\n** (72-2) and then terminates with the 0 at K.\n**\n** A \"position-list\" is the list of positions for multiple columns for\n** a single docid.  A \"column-list\" is the set of positions for a single\n** column.  Hence, a position-list consists of one or more column-lists,\n** a document record consists of a docid followed by a position-list and\n** a doclist consists of one or more document records.\n**\n** A bare doclist omits the position information, becoming an \n** array of varint-encoded docids.\n**\n**** Segment leaf nodes ****\n** Segment leaf nodes store terms and doclists, ordered by term.  Leaf\n** nodes are written using LeafWriter, and read using LeafReader (to\n** iterate through a single leaf node's data) and LeavesReader (to\n** iterate through a segment's entire leaf layer).  Leaf nodes have\n** the format:\n**\n** varint iHeight;             (height from leaf level, always 0)\n** varint nTerm;               (length of first term)\n** char pTerm[nTerm];          (content of first term)\n** varint nDoclist;            (length of term's associated doclist)\n** char pDoclist[nDoclist];    (content of doclist)\n** array {\n**                             (further terms are delta-encoded)\n**   varint nPrefix;           (length of prefix shared with previous term)\n**   varint nSuffix;           (length of unshared suffix)\n**   char pTermSuffix[nSuffix];(unshared suffix of next term)\n**   varint nDoclist;          (length of term's associated doclist)\n**   char pDoclist[nDoclist];  (content of doclist)\n** }\n**\n** Here, array { X } means zero or more occurrences of X, adjacent in\n** memory.\n**\n** Leaf nodes are broken into blocks which are stored contiguously in\n** the %_segments table in sorted order.  This means that when the end\n** of a node is reached, the next term is in the node with the next\n** greater node id.\n**\n** New data is spilled to a new leaf node when the current node\n** exceeds LEAF_MAX bytes (default 2048).  New data which itself is\n** larger than STANDALONE_MIN (default 1024) is placed in a standalone\n** node (a leaf node with a single term and doclist).  The goal of\n** these settings is to pack together groups of small doclists while\n** making it efficient to directly access large doclists.  The\n** assumption is that large doclists represent terms which are more\n** likely to be query targets.\n**\n** TODO(shess) It may be useful for blocking decisions to be more\n** dynamic.  For instance, it may make more sense to have a 2.5k leaf\n** node rather than splitting into 2k and .5k nodes.  My intuition is\n** that this might extend through 2x or 4x the pagesize.\n**\n**\n**** Segment interior nodes ****\n** Segment interior nodes store blockids for subtree nodes and terms\n** to describe what data is stored by the each subtree.  Interior\n** nodes are written using InteriorWriter, and read using\n** InteriorReader.  InteriorWriters are created as needed when\n** SegmentWriter creates new leaf nodes, or when an interior node\n** itself grows too big and must be split.  The format of interior\n** nodes:\n**\n** varint iHeight;           (height from leaf level, always >0)\n** varint iBlockid;          (block id of node's leftmost subtree)\n** optional {\n**   varint nTerm;           (length of first term)\n**   char pTerm[nTerm];      (content of first term)\n**   array {\n**                                (further terms are delta-encoded)\n**     varint nPrefix;            (length of shared prefix with previous term)\n**     varint nSuffix;            (length of unshared suffix)\n**     char pTermSuffix[nSuffix]; (unshared suffix of next term)\n**   }\n** }\n**\n** Here, optional { X } means an optional element, while array { X }\n** means zero or more occurrences of X, adjacent in memory.\n**\n** An interior node encodes n terms separating n+1 subtrees.  The\n** subtree blocks are contiguous, so only the first subtree's blockid\n** is encoded.  The subtree at iBlockid will contain all terms less\n** than the first term encoded (or all terms if no term is encoded).\n** Otherwise, for terms greater than or equal to pTerm[i] but less\n** than pTerm[i+1], the subtree for that term will be rooted at\n** iBlockid+i.  Interior nodes only store enough term data to\n** distinguish adjacent children (if the rightmost term of the left\n** child is \"something\", and the leftmost term of the right child is\n** \"wicked\", only \"w\" is stored).\n**\n** New data is spilled to a new interior node at the same height when\n** the current node exceeds INTERIOR_MAX bytes (default 2048).\n** INTERIOR_MIN_TERMS (default 7) keeps large terms from monopolizing\n** interior nodes and making the tree too skinny.  The interior nodes\n** at a given height are naturally tracked by interior nodes at\n** height+1, and so on.\n**\n**\n**** Segment directory ****\n** The segment directory in table %_segdir stores meta-information for\n** merging and deleting segments, and also the root node of the\n** segment's tree.\n**\n** The root node is the top node of the segment's tree after encoding\n** the entire segment, restricted to ROOT_MAX bytes (default 1024).\n** This could be either a leaf node or an interior node.  If the top\n** node requires more than ROOT_MAX bytes, it is flushed to %_segments\n** and a new root interior node is generated (which should always fit\n** within ROOT_MAX because it only needs space for 2 varints, the\n** height and the blockid of the previous root).\n**\n** The meta-information in the segment directory is:\n**   level               - segment level (see below)\n**   idx                 - index within level\n**                       - (level,idx uniquely identify a segment)\n**   start_block         - first leaf node\n**   leaves_end_block    - last leaf node\n**   end_block           - last block (including interior nodes)\n**   root                - contents of root node\n**\n** If the root node is a leaf node, then start_block,\n** leaves_end_block, and end_block are all 0.\n**\n**\n**** Segment merging ****\n** To amortize update costs, segments are grouped into levels and\n** merged in batches.  Each increase in level represents exponentially\n** more documents.\n**\n** New documents (actually, document updates) are tokenized and\n** written individually (using LeafWriter) to a level 0 segment, with\n** incrementing idx.  When idx reaches MERGE_COUNT (default 16), all\n** level 0 segments are merged into a single level 1 segment.  Level 1\n** is populated like level 0, and eventually MERGE_COUNT level 1\n** segments are merged to a single level 2 segment (representing\n** MERGE_COUNT^2 updates), and so on.\n**\n** A segment merge traverses all segments at a given level in\n** parallel, performing a straightforward sorted merge.  Since segment\n** leaf nodes are written in to the %_segments table in order, this\n** merge traverses the underlying sqlite disk structures efficiently.\n** After the merge, all segment blocks from the merged level are\n** deleted.\n**\n** MERGE_COUNT controls how often we merge segments.  16 seems to be\n** somewhat of a sweet spot for insertion performance.  32 and 64 show\n** very similar performance numbers to 16 on insertion, though they're\n** a tiny bit slower (perhaps due to more overhead in merge-time\n** sorting).  8 is about 20% slower than 16, 4 about 50% slower than\n** 16, 2 about 66% slower than 16.\n**\n** At query time, high MERGE_COUNT increases the number of segments\n** which need to be scanned and merged.  For instance, with 100k docs\n** inserted:\n**\n**    MERGE_COUNT   segments\n**       16           25\n**        8           12\n**        4           10\n**        2            6\n**\n** This appears to have only a moderate impact on queries for very\n** frequent terms (which are somewhat dominated by segment merge\n** costs), and infrequent and non-existent terms still seem to be fast\n** even with many segments.\n**\n** TODO(shess) That said, it would be nice to have a better query-side\n** argument for MERGE_COUNT of 16.  Also, it is possible/likely that\n** optimizations to things like doclist merging will swing the sweet\n** spot around.\n**\n**\n**\n**** Handling of deletions and updates ****\n** Since we're using a segmented structure, with no docid-oriented\n** index into the term index, we clearly cannot simply update the term\n** index when a document is deleted or updated.  For deletions, we\n** write an empty doclist (varint(docid) varint(POS_END)), for updates\n** we simply write the new doclist.  Segment merges overwrite older\n** data for a particular docid with newer data, so deletes or updates\n** will eventually overtake the earlier data and knock it out.  The\n** query logic likewise merges doclists so that newer data knocks out\n** older data.\n*/\n\n/************** Include fts3Int.h in the middle of fts3.c ********************/\n/************** Begin file fts3Int.h *****************************************/\n/*\n** 2009 Nov 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTSINT_H\n#define _FTSINT_H\n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/* FTS3/FTS4 require virtual tables */\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all\n** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3\n#endif\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* If not building as part of the core, include sqlite3ext.h. */\n#ifndef SQLITE_CORE\n/* # include \"sqlite3ext.h\"  */\nSQLITE_EXTENSION_INIT3\n#endif\n\n/* #include \"sqlite3.h\" */\n/************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/\n/************** Begin file fts3_tokenizer.h **********************************/\n/*\n** 2006 July 10\n**\n** The author disclaims copyright to this source code.\n**\n*************************************************************************\n** Defines the interface to tokenizers used by fulltext-search.  There\n** are three basic components:\n**\n** sqlite3_tokenizer_module is a singleton defining the tokenizer\n** interface functions.  This is essentially the class structure for\n** tokenizers.\n**\n** sqlite3_tokenizer is used to define a particular tokenizer, perhaps\n** including customization information defined at creation time.\n**\n** sqlite3_tokenizer_cursor is generated by a tokenizer to generate\n** tokens from a particular input.\n*/\n#ifndef _FTS3_TOKENIZER_H_\n#define _FTS3_TOKENIZER_H_\n\n/* TODO(shess) Only used for SQLITE_OK and SQLITE_DONE at this time.\n** If tokenizers are to be allowed to call sqlite3_*() functions, then\n** we will need a way to register the API consistently.\n*/\n/* #include \"sqlite3.h\" */\n\n/*\n** Structures used by the tokenizer interface. When a new tokenizer\n** implementation is registered, the caller provides a pointer to\n** an sqlite3_tokenizer_module containing pointers to the callback\n** functions that make up an implementation.\n**\n** When an fts3 table is created, it passes any arguments passed to\n** the tokenizer clause of the CREATE VIRTUAL TABLE statement to the\n** sqlite3_tokenizer_module.xCreate() function of the requested tokenizer\n** implementation. The xCreate() function in turn returns an \n** sqlite3_tokenizer structure representing the specific tokenizer to\n** be used for the fts3 table (customized by the tokenizer clause arguments).\n**\n** To tokenize an input buffer, the sqlite3_tokenizer_module.xOpen()\n** method is called. It returns an sqlite3_tokenizer_cursor object\n** that may be used to tokenize a specific input buffer based on\n** the tokenization rules supplied by a specific sqlite3_tokenizer\n** object.\n*/\ntypedef struct sqlite3_tokenizer_module sqlite3_tokenizer_module;\ntypedef struct sqlite3_tokenizer sqlite3_tokenizer;\ntypedef struct sqlite3_tokenizer_cursor sqlite3_tokenizer_cursor;\n\nstruct sqlite3_tokenizer_module {\n\n  /*\n  ** Structure version. Should always be set to 0 or 1.\n  */\n  int iVersion;\n\n  /*\n  ** Create a new tokenizer. The values in the argv[] array are the\n  ** arguments passed to the \"tokenizer\" clause of the CREATE VIRTUAL\n  ** TABLE statement that created the fts3 table. For example, if\n  ** the following SQL is executed:\n  **\n  **   CREATE .. USING fts3( ... , tokenizer <tokenizer-name> arg1 arg2)\n  **\n  ** then argc is set to 2, and the argv[] array contains pointers\n  ** to the strings \"arg1\" and \"arg2\".\n  **\n  ** This method should return either SQLITE_OK (0), or an SQLite error \n  ** code. If SQLITE_OK is returned, then *ppTokenizer should be set\n  ** to point at the newly created tokenizer structure. The generic\n  ** sqlite3_tokenizer.pModule variable should not be initialized by\n  ** this callback. The caller will do so.\n  */\n  int (*xCreate)(\n    int argc,                           /* Size of argv array */\n    const char *const*argv,             /* Tokenizer argument strings */\n    sqlite3_tokenizer **ppTokenizer     /* OUT: Created tokenizer */\n  );\n\n  /*\n  ** Destroy an existing tokenizer. The fts3 module calls this method\n  ** exactly once for each successful call to xCreate().\n  */\n  int (*xDestroy)(sqlite3_tokenizer *pTokenizer);\n\n  /*\n  ** Create a tokenizer cursor to tokenize an input buffer. The caller\n  ** is responsible for ensuring that the input buffer remains valid\n  ** until the cursor is closed (using the xClose() method). \n  */\n  int (*xOpen)(\n    sqlite3_tokenizer *pTokenizer,       /* Tokenizer object */\n    const char *pInput, int nBytes,      /* Input buffer */\n    sqlite3_tokenizer_cursor **ppCursor  /* OUT: Created tokenizer cursor */\n  );\n\n  /*\n  ** Destroy an existing tokenizer cursor. The fts3 module calls this \n  ** method exactly once for each successful call to xOpen().\n  */\n  int (*xClose)(sqlite3_tokenizer_cursor *pCursor);\n\n  /*\n  ** Retrieve the next token from the tokenizer cursor pCursor. This\n  ** method should either return SQLITE_OK and set the values of the\n  ** \"OUT\" variables identified below, or SQLITE_DONE to indicate that\n  ** the end of the buffer has been reached, or an SQLite error code.\n  **\n  ** *ppToken should be set to point at a buffer containing the \n  ** normalized version of the token (i.e. after any case-folding and/or\n  ** stemming has been performed). *pnBytes should be set to the length\n  ** of this buffer in bytes. The input text that generated the token is\n  ** identified by the byte offsets returned in *piStartOffset and\n  ** *piEndOffset. *piStartOffset should be set to the index of the first\n  ** byte of the token in the input buffer. *piEndOffset should be set\n  ** to the index of the first byte just past the end of the token in\n  ** the input buffer.\n  **\n  ** The buffer *ppToken is set to point at is managed by the tokenizer\n  ** implementation. It is only required to be valid until the next call\n  ** to xNext() or xClose(). \n  */\n  /* TODO(shess) current implementation requires pInput to be\n  ** nul-terminated.  This should either be fixed, or pInput/nBytes\n  ** should be converted to zInput.\n  */\n  int (*xNext)(\n    sqlite3_tokenizer_cursor *pCursor,   /* Tokenizer cursor */\n    const char **ppToken, int *pnBytes,  /* OUT: Normalized text for token */\n    int *piStartOffset,  /* OUT: Byte offset of token in input buffer */\n    int *piEndOffset,    /* OUT: Byte offset of end of token in input buffer */\n    int *piPosition      /* OUT: Number of tokens returned before this one */\n  );\n\n  /***********************************************************************\n  ** Methods below this point are only available if iVersion>=1.\n  */\n\n  /* \n  ** Configure the language id of a tokenizer cursor.\n  */\n  int (*xLanguageid)(sqlite3_tokenizer_cursor *pCsr, int iLangid);\n};\n\nstruct sqlite3_tokenizer {\n  const sqlite3_tokenizer_module *pModule;  /* The module for this tokenizer */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nstruct sqlite3_tokenizer_cursor {\n  sqlite3_tokenizer *pTokenizer;       /* Tokenizer for this cursor. */\n  /* Tokenizer implementations will typically add additional fields */\n};\n\nint fts3_global_term_cnt(int iTerm, int iCol);\nint fts3_term_cnt(int iTerm, int iCol);\n\n\n#endif /* _FTS3_TOKENIZER_H_ */\n\n/************** End of fts3_tokenizer.h **************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n/************** Include fts3_hash.h in the middle of fts3Int.h ***************/\n/************** Begin file fts3_hash.h ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.  We've modified it slightly to serve as a standalone\n** hash table implementation for the full-text indexing module.\n**\n*/\n#ifndef _FTS3_HASH_H_\n#define _FTS3_HASH_H_\n\n/* Forward declarations of structures. */\ntypedef struct Fts3Hash Fts3Hash;\ntypedef struct Fts3HashElem Fts3HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, many of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n*/\nstruct Fts3Hash {\n  char keyClass;          /* HASH_INT, _POINTER, _STRING, _BINARY */\n  char copyKey;           /* True if copy of key made on insert */\n  int count;              /* Number of entries in this table */\n  Fts3HashElem *first;    /* The first element of the array */\n  int htsize;             /* Number of buckets in the hash table */\n  struct _fts3ht {        /* the hash table */\n    int count;               /* Number of entries with this hash */\n    Fts3HashElem *chain;     /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct Fts3HashElem {\n  Fts3HashElem *next, *prev; /* Next and previous elements in the table */\n  void *data;                /* Data associated with this element */\n  void *pKey; int nKey;      /* Key associated with this element */\n};\n\n/*\n** There are 2 different modes of operation for a hash table:\n**\n**   FTS3_HASH_STRING        pKey points to a string that is nKey bytes long\n**                           (including the null-terminator, if any).  Case\n**                           is respected in comparisons.\n**\n**   FTS3_HASH_BINARY        pKey points to binary data nKey bytes long. \n**                           memcmp() is used to compare keys.\n**\n** A copy of the key is made if the copyKey parameter to fts3HashInit is 1.  \n*/\n#define FTS3_HASH_STRING    1\n#define FTS3_HASH_BINARY    2\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);\n\n/*\n** Shorthand for the functions above\n*/\n#define fts3HashInit     sqlite3Fts3HashInit\n#define fts3HashInsert   sqlite3Fts3HashInsert\n#define fts3HashFind     sqlite3Fts3HashFind\n#define fts3HashClear    sqlite3Fts3HashClear\n#define fts3HashFindElem sqlite3Fts3HashFindElem\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Fts3Hash h;\n**   Fts3HashElem *p;\n**   ...\n**   for(p=fts3HashFirst(&h); p; p=fts3HashNext(p)){\n**     SomeStructure *pData = fts3HashData(p);\n**     // do something with pData\n**   }\n*/\n#define fts3HashFirst(H)  ((H)->first)\n#define fts3HashNext(E)   ((E)->next)\n#define fts3HashData(E)   ((E)->data)\n#define fts3HashKey(E)    ((E)->pKey)\n#define fts3HashKeysize(E) ((E)->nKey)\n\n/*\n** Number of entries in a hash table\n*/\n#define fts3HashCount(H)  ((H)->count)\n\n#endif /* _FTS3_HASH_H_ */\n\n/************** End of fts3_hash.h *******************************************/\n/************** Continuing where we left off in fts3Int.h ********************/\n\n/*\n** This constant determines the maximum depth of an FTS expression tree\n** that the library will create and use. FTS uses recursion to perform \n** various operations on the query tree, so the disadvantage of a large\n** limit is that it may allow very large queries to use large amounts\n** of stack space (perhaps causing a stack overflow).\n*/\n#ifndef SQLITE_FTS3_MAX_EXPR_DEPTH\n# define SQLITE_FTS3_MAX_EXPR_DEPTH 12\n#endif\n\n\n/*\n** This constant controls how often segments are merged. Once there are\n** FTS3_MERGE_COUNT segments of level N, they are merged into a single\n** segment of level N+1.\n*/\n#define FTS3_MERGE_COUNT 16\n\n/*\n** This is the maximum amount of data (in bytes) to store in the \n** Fts3Table.pendingTerms hash table. Normally, the hash table is\n** populated as documents are inserted/updated/deleted in a transaction\n** and used to create a new segment when the transaction is committed.\n** However if this limit is reached midway through a transaction, a new \n** segment is created and the hash table cleared immediately.\n*/\n#define FTS3_MAX_PENDING_DATA (1*1024*1024)\n\n/*\n** Macro to return the number of elements in an array. SQLite has a\n** similar macro called ArraySize(). Use a different name to avoid\n** a collision when building an amalgamation with built-in FTS3.\n*/\n#define SizeofArray(X) ((int)(sizeof(X)/sizeof(X[0])))\n\n\n#ifndef MIN\n# define MIN(x,y) ((x)<(y)?(x):(y))\n#endif\n#ifndef MAX\n# define MAX(x,y) ((x)>(y)?(x):(y))\n#endif\n\n/*\n** Maximum length of a varint encoded integer. The varint format is different\n** from that used by SQLite, so the maximum length is 10, not 9.\n*/\n#define FTS3_VARINT_MAX 10\n\n/*\n** FTS4 virtual tables may maintain multiple indexes - one index of all terms\n** in the document set and zero or more prefix indexes. All indexes are stored\n** as one or more b+-trees in the %_segments and %_segdir tables. \n**\n** It is possible to determine which index a b+-tree belongs to based on the\n** value stored in the \"%_segdir.level\" column. Given this value L, the index\n** that the b+-tree belongs to is (L<<10). In other words, all b+-trees with\n** level values between 0 and 1023 (inclusive) belong to index 0, all levels\n** between 1024 and 2047 to index 1, and so on.\n**\n** It is considered impossible for an index to use more than 1024 levels. In \n** theory though this may happen, but only after at least \n** (FTS3_MERGE_COUNT^1024) separate flushes of the pending-terms tables.\n*/\n#define FTS3_SEGDIR_MAXLEVEL      1024\n#define FTS3_SEGDIR_MAXLEVEL_STR \"1024\"\n\n/*\n** The testcase() macro is only used by the amalgamation.  If undefined,\n** make it a no-op.\n*/\n#ifndef testcase\n# define testcase(X)\n#endif\n\n/*\n** Terminator values for position-lists and column-lists.\n*/\n#define POS_COLUMN  (1)     /* Column-list terminator */\n#define POS_END     (0)     /* Position-list terminator */ \n\n/*\n** This section provides definitions to allow the\n** FTS3 extension to be compiled outside of the \n** amalgamation.\n*/\n#ifndef SQLITE_AMALGAMATION\n/*\n** Macros indicating that conditional expressions are always true or\n** false.\n*/\n#ifdef SQLITE_COVERAGE_TEST\n# define ALWAYS(x) (1)\n# define NEVER(X)  (0)\n#elif defined(SQLITE_DEBUG)\n# define ALWAYS(x) sqlite3Fts3Always((x)!=0)\n# define NEVER(x) sqlite3Fts3Never((x)!=0)\nSQLITE_PRIVATE int sqlite3Fts3Always(int b);\nSQLITE_PRIVATE int sqlite3Fts3Never(int b);\n#else\n# define ALWAYS(x) (x)\n# define NEVER(x)  (x)\n#endif\n\n/*\n** Internal types used by SQLite.\n*/\ntypedef unsigned char u8;         /* 1-byte (or larger) unsigned integer */\ntypedef short int i16;            /* 2-byte (or larger) signed integer */\ntypedef unsigned int u32;         /* 4-byte unsigned integer */\ntypedef sqlite3_uint64 u64;       /* 8-byte unsigned integer */\ntypedef sqlite3_int64 i64;        /* 8-byte signed integer */\n\n/*\n** Macro used to suppress compiler warnings for unused parameters.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** Activate assert() only if SQLITE_TEST is enabled.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n#endif /* SQLITE_AMALGAMATION */\n\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(void);\n# define FTS_CORRUPT_VTAB sqlite3Fts3Corrupt()\n#else\n# define FTS_CORRUPT_VTAB SQLITE_CORRUPT_VTAB\n#endif\n\ntypedef struct Fts3Table Fts3Table;\ntypedef struct Fts3Cursor Fts3Cursor;\ntypedef struct Fts3Expr Fts3Expr;\ntypedef struct Fts3Phrase Fts3Phrase;\ntypedef struct Fts3PhraseToken Fts3PhraseToken;\n\ntypedef struct Fts3Doclist Fts3Doclist;\ntypedef struct Fts3SegFilter Fts3SegFilter;\ntypedef struct Fts3DeferredToken Fts3DeferredToken;\ntypedef struct Fts3SegReader Fts3SegReader;\ntypedef struct Fts3MultiSegReader Fts3MultiSegReader;\n\ntypedef struct MatchinfoBuffer MatchinfoBuffer;\n\n/*\n** A connection to a fulltext index is an instance of the following\n** structure. The xCreate and xConnect methods create an instance\n** of this structure and xDestroy and xDisconnect free that instance.\n** All other methods receive a pointer to the structure as one of their\n** arguments.\n*/\nstruct Fts3Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  sqlite3 *db;                    /* The database connection */\n  const char *zDb;                /* logical database name */\n  const char *zName;              /* virtual table name */\n  int nColumn;                    /* number of named columns in virtual table */\n  char **azColumn;                /* column names.  malloced */\n  u8 *abNotindexed;               /* True for 'notindexed' columns */\n  sqlite3_tokenizer *pTokenizer;  /* tokenizer for inserts and queries */\n  char *zContentTbl;              /* content=xxx option, or NULL */\n  char *zLanguageid;              /* languageid=xxx option, or NULL */\n  int nAutoincrmerge;             /* Value configured by 'automerge' */\n  u32 nLeafAdd;                   /* Number of leaf blocks added this trans */\n\n  /* Precompiled statements used by the implementation. Each of these \n  ** statements is run and reset within a single virtual table API call. \n  */\n  sqlite3_stmt *aStmt[40];\n  sqlite3_stmt *pSeekStmt;        /* Cache for fts3CursorSeekStmt() */\n\n  char *zReadExprlist;\n  char *zWriteExprlist;\n\n  int nNodeSize;                  /* Soft limit for node size */\n  u8 bFts4;                       /* True for FTS4, false for FTS3 */\n  u8 bHasStat;                    /* True if %_stat table exists (2==unknown) */\n  u8 bHasDocsize;                 /* True if %_docsize table exists */\n  u8 bDescIdx;                    /* True if doclists are in reverse order */\n  u8 bIgnoreSavepoint;            /* True to ignore xSavepoint invocations */\n  int nPgsz;                      /* Page size for host database */\n  char *zSegmentsTbl;             /* Name of %_segments table */\n  sqlite3_blob *pSegments;        /* Blob handle open on %_segments table */\n\n  /* \n  ** The following array of hash tables is used to buffer pending index \n  ** updates during transactions. All pending updates buffered at any one\n  ** time must share a common language-id (see the FTS4 langid= feature).\n  ** The current language id is stored in variable iPrevLangid.\n  **\n  ** A single FTS4 table may have multiple full-text indexes. For each index\n  ** there is an entry in the aIndex[] array. Index 0 is an index of all the\n  ** terms that appear in the document set. Each subsequent index in aIndex[]\n  ** is an index of prefixes of a specific length.\n  **\n  ** Variable nPendingData contains an estimate the memory consumed by the \n  ** pending data structures, including hash table overhead, but not including\n  ** malloc overhead.  When nPendingData exceeds nMaxPendingData, all hash\n  ** tables are flushed to disk. Variable iPrevDocid is the docid of the most \n  ** recently inserted record.\n  */\n  int nIndex;                     /* Size of aIndex[] */\n  struct Fts3Index {\n    int nPrefix;                  /* Prefix length (0 for main terms index) */\n    Fts3Hash hPending;            /* Pending terms table for this index */\n  } *aIndex;\n  int nMaxPendingData;            /* Max pending data before flush to disk */\n  int nPendingData;               /* Current bytes of pending data */\n  sqlite_int64 iPrevDocid;        /* Docid of most recently inserted document */\n  int iPrevLangid;                /* Langid of recently inserted document */\n  int bPrevDelete;                /* True if last operation was a delete */\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n  /* State variables used for validating that the transaction control\n  ** methods of the virtual table are called at appropriate times.  These\n  ** values do not contribute to FTS functionality; they are used for\n  ** verifying the operation of the SQLite core.\n  */\n  int inTransaction;     /* True after xBegin but before xCommit/xRollback */\n  int mxSavepoint;       /* Largest valid xSavepoint integer */\n#endif\n\n#ifdef SQLITE_TEST\n  /* True to disable the incremental doclist optimization. This is controled\n  ** by special insert command 'test-no-incr-doclist'.  */\n  int bNoIncrDoclist;\n#endif\n};\n\n/*\n** When the core wants to read from the virtual table, it creates a\n** virtual table cursor (an instance of the following structure) using\n** the xOpen method. Cursors are destroyed using the xClose method.\n*/\nstruct Fts3Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  i16 eSearch;                    /* Search strategy (see below) */\n  u8 isEof;                       /* True if at End Of Results */\n  u8 isRequireSeek;               /* True if must seek pStmt to %_content row */\n  u8 bSeekStmt;                   /* True if pStmt is a seek */\n  sqlite3_stmt *pStmt;            /* Prepared statement in use by the cursor */\n  Fts3Expr *pExpr;                /* Parsed MATCH query string */\n  int iLangid;                    /* Language being queried for */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  Fts3DeferredToken *pDeferred;   /* Deferred search tokens, if any */\n  sqlite3_int64 iPrevId;          /* Previous id read from aDoclist */\n  char *pNextId;                  /* Pointer into the body of aDoclist */\n  char *aDoclist;                 /* List of docids for full-text queries */\n  int nDoclist;                   /* Size of buffer at aDoclist */\n  u8 bDesc;                       /* True to sort in descending order */\n  int eEvalmode;                  /* An FTS3_EVAL_XX constant */\n  int nRowAvg;                    /* Average size of database rows, in pages */\n  sqlite3_int64 nDoc;             /* Documents in table */\n  i64 iMinDocid;                  /* Minimum docid to return */\n  i64 iMaxDocid;                  /* Maximum docid to return */\n  int isMatchinfoNeeded;          /* True when aMatchinfo[] needs filling in */\n  MatchinfoBuffer *pMIBuffer;     /* Buffer for matchinfo data */\n};\n\n#define FTS3_EVAL_FILTER    0\n#define FTS3_EVAL_NEXT      1\n#define FTS3_EVAL_MATCHINFO 2\n\n/*\n** The Fts3Cursor.eSearch member is always set to one of the following.\n** Actualy, Fts3Cursor.eSearch can be greater than or equal to\n** FTS3_FULLTEXT_SEARCH.  If so, then Fts3Cursor.eSearch - 2 is the index\n** of the column to be searched.  For example, in\n**\n**     CREATE VIRTUAL TABLE ex1 USING fts3(a,b,c,d);\n**     SELECT docid FROM ex1 WHERE b MATCH 'one two three';\n** \n** Because the LHS of the MATCH operator is 2nd column \"b\",\n** Fts3Cursor.eSearch will be set to FTS3_FULLTEXT_SEARCH+1.  (+0 for a,\n** +1 for b, +2 for c, +3 for d.)  If the LHS of MATCH were \"ex1\" \n** indicating that all columns should be searched,\n** then eSearch would be set to FTS3_FULLTEXT_SEARCH+4.\n*/\n#define FTS3_FULLSCAN_SEARCH 0    /* Linear scan of %_content table */\n#define FTS3_DOCID_SEARCH    1    /* Lookup by rowid on %_content table */\n#define FTS3_FULLTEXT_SEARCH 2    /* Full-text index search */\n\n/*\n** The lower 16-bits of the sqlite3_index_info.idxNum value set by\n** the xBestIndex() method contains the Fts3Cursor.eSearch value described\n** above. The upper 16-bits contain a combination of the following\n** bits, used to describe extra constraints on full-text searches.\n*/\n#define FTS3_HAVE_LANGID    0x00010000      /* languageid=? */\n#define FTS3_HAVE_DOCID_GE  0x00020000      /* docid>=? */\n#define FTS3_HAVE_DOCID_LE  0x00040000      /* docid<=? */\n\nstruct Fts3Doclist {\n  char *aAll;                    /* Array containing doclist (or NULL) */\n  int nAll;                      /* Size of a[] in bytes */\n  char *pNextDocid;              /* Pointer to next docid */\n\n  sqlite3_int64 iDocid;          /* Current docid (if pList!=0) */\n  int bFreeList;                 /* True if pList should be sqlite3_free()d */\n  char *pList;                   /* Pointer to position list following iDocid */\n  int nList;                     /* Length of position list */\n};\n\n/*\n** A \"phrase\" is a sequence of one or more tokens that must match in\n** sequence.  A single token is the base case and the most common case.\n** For a sequence of tokens contained in double-quotes (i.e. \"one two three\")\n** nToken will be the number of tokens in the string.\n*/\nstruct Fts3PhraseToken {\n  char *z;                        /* Text of the token */\n  int n;                          /* Number of bytes in buffer z */\n  int isPrefix;                   /* True if token ends with a \"*\" character */\n  int bFirst;                     /* True if token must appear at position 0 */\n\n  /* Variables above this point are populated when the expression is\n  ** parsed (by code in fts3_expr.c). Below this point the variables are\n  ** used when evaluating the expression. */\n  Fts3DeferredToken *pDeferred;   /* Deferred token object for this token */\n  Fts3MultiSegReader *pSegcsr;    /* Segment-reader for this token */\n};\n\nstruct Fts3Phrase {\n  /* Cache of doclist for this phrase. */\n  Fts3Doclist doclist;\n  int bIncr;                 /* True if doclist is loaded incrementally */\n  int iDoclistToken;\n\n  /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an\n  ** OR condition.  */\n  char *pOrPoslist;\n  i64 iOrDocid;\n\n  /* Variables below this point are populated by fts3_expr.c when parsing \n  ** a MATCH expression. Everything above is part of the evaluation phase. \n  */\n  int nToken;                /* Number of tokens in the phrase */\n  int iColumn;               /* Index of column this phrase must match */\n  Fts3PhraseToken aToken[1]; /* One entry for each token in the phrase */\n};\n\n/*\n** A tree of these objects forms the RHS of a MATCH operator.\n**\n** If Fts3Expr.eType is FTSQUERY_PHRASE and isLoaded is true, then aDoclist \n** points to a malloced buffer, size nDoclist bytes, containing the results \n** of this phrase query in FTS3 doclist format. As usual, the initial \n** \"Length\" field found in doclists stored on disk is omitted from this \n** buffer.\n**\n** Variable aMI is used only for FTSQUERY_NEAR nodes to store the global\n** matchinfo data. If it is not NULL, it points to an array of size nCol*3,\n** where nCol is the number of columns in the queried FTS table. The array\n** is populated as follows:\n**\n**   aMI[iCol*3 + 0] = Undefined\n**   aMI[iCol*3 + 1] = Number of occurrences\n**   aMI[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** The aMI array is allocated using sqlite3_malloc(). It should be freed \n** when the expression node is.\n*/\nstruct Fts3Expr {\n  int eType;                 /* One of the FTSQUERY_XXX values defined below */\n  int nNear;                 /* Valid if eType==FTSQUERY_NEAR */\n  Fts3Expr *pParent;         /* pParent->pLeft==this or pParent->pRight==this */\n  Fts3Expr *pLeft;           /* Left operand */\n  Fts3Expr *pRight;          /* Right operand */\n  Fts3Phrase *pPhrase;       /* Valid if eType==FTSQUERY_PHRASE */\n\n  /* The following are used by the fts3_eval.c module. */\n  sqlite3_int64 iDocid;      /* Current docid */\n  u8 bEof;                   /* True this expression is at EOF already */\n  u8 bStart;                 /* True if iDocid is valid */\n  u8 bDeferred;              /* True if this expression is entirely deferred */\n\n  /* The following are used by the fts3_snippet.c module. */\n  int iPhrase;               /* Index of this phrase in matchinfo() results */\n  u32 *aMI;                  /* See above */\n};\n\n/*\n** Candidate values for Fts3Query.eType. Note that the order of the first\n** four values is in order of precedence when parsing expressions. For \n** example, the following:\n**\n**   \"a OR b AND c NOT d NEAR e\"\n**\n** is equivalent to:\n**\n**   \"a OR (b AND (c NOT (d NEAR e)))\"\n*/\n#define FTSQUERY_NEAR   1\n#define FTSQUERY_NOT    2\n#define FTSQUERY_AND    3\n#define FTSQUERY_OR     4\n#define FTSQUERY_PHRASE 5\n\n\n/* fts3_write.c */\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(sqlite3_vtab*,int,sqlite3_value**,sqlite3_int64*);\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(int, int, sqlite3_int64,\n  sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table*,int,const char*,int,int,Fts3SegReader**);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *);\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(Fts3Table*, int, int, int, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*, int*);\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(Fts3Table *, sqlite3_stmt **);\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(Fts3Table *, sqlite3_int64, sqlite3_stmt **);\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(Fts3DeferredToken *, char **, int *);\n#else\n# define sqlite3Fts3FreeDeferredTokens(x)\n# define sqlite3Fts3DeferToken(x,y,z) SQLITE_OK\n# define sqlite3Fts3CacheDeferredDoclists(x) SQLITE_OK\n# define sqlite3Fts3FreeDeferredDoclists(x)\n# define sqlite3Fts3DeferredTokenList(x,y,z) SQLITE_OK\n#endif\n\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);\n\n/* Special values interpreted by sqlite3SegReaderCursor() */\n#define FTS3_SEGCURSOR_PENDING        -1\n#define FTS3_SEGCURSOR_ALL            -2\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(Fts3Table*, Fts3MultiSegReader*, Fts3SegFilter*);\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(Fts3Table *, Fts3MultiSegReader *);\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(Fts3MultiSegReader *);\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(Fts3Table *, \n    int, int, int, const char *, int, int, int, Fts3MultiSegReader *);\n\n/* Flags allowed as part of the 4th argument to SegmentReaderIterate() */\n#define FTS3_SEGMENT_REQUIRE_POS   0x00000001\n#define FTS3_SEGMENT_IGNORE_EMPTY  0x00000002\n#define FTS3_SEGMENT_COLUMN_FILTER 0x00000004\n#define FTS3_SEGMENT_PREFIX        0x00000008\n#define FTS3_SEGMENT_SCAN          0x00000010\n#define FTS3_SEGMENT_FIRST         0x00000020\n\n/* Type passed as 4th argument to SegmentReaderIterate() */\nstruct Fts3SegFilter {\n  const char *zTerm;\n  int nTerm;\n  int iCol;\n  int flags;\n};\n\nstruct Fts3MultiSegReader {\n  /* Used internally by sqlite3Fts3SegReaderXXX() calls */\n  Fts3SegReader **apSegment;      /* Array of Fts3SegReader objects */\n  int nSegment;                   /* Size of apSegment array */\n  int nAdvance;                   /* How many seg-readers to advance */\n  Fts3SegFilter *pFilter;         /* Pointer to filter object */\n  char *aBuffer;                  /* Buffer to merge doclists in */\n  int nBuffer;                    /* Allocated size of aBuffer[] in bytes */\n\n  int iColFilter;                 /* If >=0, filter for this column */\n  int bRestart;\n\n  /* Used by fts3.c only. */\n  int nCost;                      /* Cost of running iterator */\n  int bLookup;                    /* True if a lookup of a single entry. */\n\n  /* Output values. Valid only after Fts3SegReaderStep() returns SQLITE_ROW. */\n  char *zTerm;                    /* Pointer to term buffer */\n  int nTerm;                      /* Size of zTerm in bytes */\n  char *aDoclist;                 /* Pointer to doclist buffer */\n  int nDoclist;                   /* Size of aDoclist[] in bytes */\n};\n\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);\n\n#define fts3GetVarint32(p, piVal) (                                           \\\n  (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \\\n)\n\n/* fts3.c */\nSQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *);\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);\nSQLITE_PRIVATE int sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc);\n\n/* fts3_tokenizer.c */\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, \n    sqlite3_tokenizer **, char **\n);\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char);\n\n/* fts3_snippet.c */\nSQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);\nSQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context *, Fts3Cursor *, const char *,\n  const char *, const char *, int, int\n);\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *, const char *);\nSQLITE_PRIVATE void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p);\n\n/* fts3_expr.c */\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, int,\n  char **, int, int, int, const char *, int, Fts3Expr **, char **\n);\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);\n#ifdef SQLITE_TEST\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);\nSQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db);\n#endif\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int,\n  sqlite3_tokenizer_cursor **\n);\n\n/* fts3_aux.c */\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db);\n\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *);\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n    Fts3Table*, Fts3MultiSegReader*, int, const char*, int);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n    Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **); \nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);\n\n/* fts3_tokenize_vtab.c */\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);\n\n/* fts3_unicode2.c (functions generated by parsing unicode text files) */\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int);\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);\n#endif\n\n#endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */\n#endif /* _FTSINT_H */\n\n/************** End of fts3Int.h *********************************************/\n/************** Continuing where we left off in fts3.c ***********************/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE)\n# define SQLITE_CORE 1\n#endif\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stddef.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n/* #include <stdarg.h> */\n\n/* #include \"fts3.h\" */\n#ifndef SQLITE_CORE \n/* # include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#endif\n\nstatic int fts3EvalNext(Fts3Cursor *pCsr);\nstatic int fts3EvalStart(Fts3Cursor *pCsr);\nstatic int fts3TermSegReaderCursor(\n    Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);\n\n#ifndef SQLITE_AMALGAMATION\n# if defined(SQLITE_DEBUG)\nSQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }\nSQLITE_PRIVATE int sqlite3Fts3Never(int b)  { assert( !b ); return b; }\n# endif\n#endif\n\n/* \n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.\n** The number of bytes written is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){\n  unsigned char *q = (unsigned char *) p;\n  sqlite_uint64 vu = v;\n  do{\n    *q++ = (unsigned char) ((vu & 0x7f) | 0x80);\n    vu >>= 7;\n  }while( vu!=0 );\n  q[-1] &= 0x7f;  /* turn off high bit in final byte */\n  assert( q - (unsigned char *)p <= FTS3_VARINT_MAX );\n  return (int) (q - (unsigned char *)p);\n}\n\n#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (v & mask1) | ( (*ptr++) << shift );                    \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \\\n  v = (*ptr++);                                               \\\n  if( (v & mask2)==0 ){ var = v; return ret; }\n\n/* \n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read, or 0 on error.\n** The value is stored in *v.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){\n  const unsigned char *p = (const unsigned char*)pBuf;\n  const unsigned char *pStart = p;\n  u32 a;\n  u64 b;\n  int shift;\n\n  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *v, 1);\n  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *v, 2);\n  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *v, 3);\n  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *v, 4);\n  b = (a & 0x0FFFFFFF );\n\n  for(shift=28; shift<=63; shift+=7){\n    u64 c = *p++;\n    b += (c&0x7F) << shift;\n    if( (c & 0x80)==0 ) break;\n  }\n  *v = b;\n  return (int)(p - pStart);\n}\n\n/*\n** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to \n** a non-negative 32-bit integer before it is returned.\n*/\nSQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){\n  u32 a;\n\n#ifndef fts3GetVarint32\n  GETVARINT_INIT(a, p, 0,  0x00,     0x80, *pi, 1);\n#else\n  a = (*p++);\n  assert( a & 0x80 );\n#endif\n\n  GETVARINT_STEP(a, p, 7,  0x7F,     0x4000, *pi, 2);\n  GETVARINT_STEP(a, p, 14, 0x3FFF,   0x200000, *pi, 3);\n  GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);\n  a = (a & 0x0FFFFFFF );\n  *pi = (int)(a | ((u32)(*p & 0x07) << 28));\n  assert( 0==(a & 0x80000000) );\n  assert( *pi>=0 );\n  return 5;\n}\n\n/*\n** Return the number of bytes required to encode v as a varint\n*/\nSQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64 v){\n  int i = 0;\n  do{\n    i++;\n    v >>= 7;\n  }while( v!=0 );\n  return i;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n**\n*/\nSQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    int iIn = 1;                  /* Index of next byte to read from input */\n    int iOut = 0;                 /* Index of next byte to write to output */\n\n    /* If the first byte was a '[', then the close-quote character is a ']' */\n    if( quote=='[' ) quote = ']';  \n\n    while( z[iIn] ){\n      if( z[iIn]==quote ){\n        if( z[iIn+1]!=quote ) break;\n        z[iOut++] = quote;\n        iIn += 2;\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** Read a single varint from the doclist at *pp and advance *pp to point\n** to the first byte past the end of the varint.  Add the value of the varint\n** to *pVal.\n*/\nstatic void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){\n  sqlite3_int64 iVal;\n  *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n  *pVal += iVal;\n}\n\n/*\n** When this function is called, *pp points to the first byte following a\n** varint that is part of a doclist (or position-list, or any other list\n** of varints). This function moves *pp to point to the start of that varint,\n** and sets *pVal by the varint value.\n**\n** Argument pStart points to the first byte of the doclist that the\n** varint is part of.\n*/\nstatic void fts3GetReverseVarint(\n  char **pp, \n  char *pStart, \n  sqlite3_int64 *pVal\n){\n  sqlite3_int64 iVal;\n  char *p;\n\n  /* Pointer p now points at the first byte past the varint we are \n  ** interested in. So, unless the doclist is corrupt, the 0x80 bit is\n  ** clear on character p[-1]. */\n  for(p = (*pp)-2; p>=pStart && *p&0x80; p--);\n  p++;\n  *pp = p;\n\n  sqlite3Fts3GetVarint(p, &iVal);\n  *pVal = iVal;\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts3DisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int i;\n\n  assert( p->nPendingData==0 );\n  assert( p->pSegments==0 );\n\n  /* Free any prepared statements held */\n  sqlite3_finalize(p->pSeekStmt);\n  for(i=0; i<SizeofArray(p->aStmt); i++){\n    sqlite3_finalize(p->aStmt[i]);\n  }\n  sqlite3_free(p->zSegmentsTbl);\n  sqlite3_free(p->zReadExprlist);\n  sqlite3_free(p->zWriteExprlist);\n  sqlite3_free(p->zContentTbl);\n  sqlite3_free(p->zLanguageid);\n\n  /* Invoke the tokenizer destructor to free the tokenizer. */\n  p->pTokenizer->pModule->xDestroy(p->pTokenizer);\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into *pzErr\n*/\nSQLITE_PRIVATE void sqlite3Fts3ErrMsg(char **pzErr, const char *zFormat, ...){\n  va_list ap;\n  sqlite3_free(*pzErr);\n  va_start(ap, zFormat);\n  *pzErr = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Construct one or more SQL statements from the format string given\n** and then evaluate those statements. The success code is written\n** into *pRc.\n**\n** If *pRc is initially non-zero then this routine is a no-op.\n*/\nstatic void fts3DbExec(\n  int *pRc,              /* Success code */\n  sqlite3 *db,           /* Database in which to run SQL */\n  const char *zFormat,   /* Format string for SQL */\n  ...                    /* Arguments to the format string */\n){\n  va_list ap;\n  char *zSql;\n  if( *pRc ) return;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    *pRc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts3DestroyMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;              /* Return code */\n  const char *zDb = p->zDb;        /* Name of database (e.g. \"main\", \"temp\") */\n  sqlite3 *db = p->db;             /* Database handle */\n\n  /* Drop the shadow tables */\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_content'\", zDb, p->zName);\n  }\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segments'\", zDb,p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_segdir'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_docsize'\", zDb, p->zName);\n  fts3DbExec(&rc, db, \"DROP TABLE IF EXISTS %Q.'%q_stat'\", zDb, p->zName);\n\n  /* If everything has worked, invoke fts3DisconnectMethod() to free the\n  ** memory associated with the Fts3Table structure and return SQLITE_OK.\n  ** Otherwise, return an SQLite error code.\n  */\n  return (rc==SQLITE_OK ? fts3DisconnectMethod(pVtab) : rc);\n}\n\n\n/*\n** Invoke sqlite3_declare_vtab() to declare the schema for the FTS3 table\n** passed as the first argument. This is done as part of the xConnect()\n** and xCreate() methods.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DeclareVtab(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int i;                        /* Iterator variable */\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL statement passed to declare_vtab() */\n    char *zCols;                  /* List of user defined columns */\n    const char *zLanguageid;\n\n    zLanguageid = (p->zLanguageid ? p->zLanguageid : \"__langid\");\n    sqlite3_vtab_config(p->db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n    /* Create a list of user columns for the virtual table */\n    zCols = sqlite3_mprintf(\"%Q, \", p->azColumn[0]);\n    for(i=1; zCols && i<p->nColumn; i++){\n      zCols = sqlite3_mprintf(\"%z%Q, \", zCols, p->azColumn[i]);\n    }\n\n    /* Create the whole \"CREATE TABLE\" statement to pass to SQLite */\n    zSql = sqlite3_mprintf(\n        \"CREATE TABLE x(%s %Q HIDDEN, docid HIDDEN, %Q HIDDEN)\", \n        zCols, p->zName, zLanguageid\n    );\n    if( !zCols || !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_declare_vtab(p->db, zSql);\n    }\n\n    sqlite3_free(zSql);\n    sqlite3_free(zCols);\n    *pRc = rc;\n  }\n}\n\n/*\n** Create the %_stat table if it does not already exist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){\n  fts3DbExec(pRc, p->db, \n      \"CREATE TABLE IF NOT EXISTS %Q.'%q_stat'\"\n          \"(id INTEGER PRIMARY KEY, value BLOB);\",\n      p->zDb, p->zName\n  );\n  if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;\n}\n\n/*\n** Create the backing store tables (%_content, %_segments and %_segdir)\n** required by the FTS3 table passed as the only argument. This is done\n** as part of the vtab xCreate() method.\n**\n** If the p->bHasDocsize boolean is true (indicating that this is an\n** FTS4 table, not an FTS3 table) then also create the %_docsize and\n** %_stat tables required by FTS4.\n*/\nstatic int fts3CreateTables(Fts3Table *p){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  sqlite3 *db = p->db;            /* The database connection */\n\n  if( p->zContentTbl==0 ){\n    const char *zLanguageid = p->zLanguageid;\n    char *zContentCols;           /* Columns of %_content table */\n\n    /* Create a list of user columns for the content table */\n    zContentCols = sqlite3_mprintf(\"docid INTEGER PRIMARY KEY\");\n    for(i=0; zContentCols && i<p->nColumn; i++){\n      char *z = p->azColumn[i];\n      zContentCols = sqlite3_mprintf(\"%z, 'c%d%q'\", zContentCols, i, z);\n    }\n    if( zLanguageid && zContentCols ){\n      zContentCols = sqlite3_mprintf(\"%z, langid\", zContentCols, zLanguageid);\n    }\n    if( zContentCols==0 ) rc = SQLITE_NOMEM;\n  \n    /* Create the content table */\n    fts3DbExec(&rc, db, \n       \"CREATE TABLE %Q.'%q_content'(%s)\",\n       p->zDb, p->zName, zContentCols\n    );\n    sqlite3_free(zContentCols);\n  }\n\n  /* Create other tables */\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segments'(blockid INTEGER PRIMARY KEY, block BLOB);\",\n      p->zDb, p->zName\n  );\n  fts3DbExec(&rc, db, \n      \"CREATE TABLE %Q.'%q_segdir'(\"\n        \"level INTEGER,\"\n        \"idx INTEGER,\"\n        \"start_block INTEGER,\"\n        \"leaves_end_block INTEGER,\"\n        \"end_block INTEGER,\"\n        \"root BLOB,\"\n        \"PRIMARY KEY(level, idx)\"\n      \");\",\n      p->zDb, p->zName\n  );\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db, \n        \"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);\",\n        p->zDb, p->zName\n    );\n  }\n  assert( p->bHasStat==p->bFts4 );\n  if( p->bHasStat ){\n    sqlite3Fts3CreateStatTable(&rc, p);\n  }\n  return rc;\n}\n\n/*\n** Store the current database page-size in bytes in p->nPgsz.\n**\n** If *pRc is non-zero when this function is called, it is a no-op. \n** Otherwise, if an error occurs, an SQLite error code is stored in *pRc\n** before returning.\n*/\nstatic void fts3DatabasePageSize(int *pRc, Fts3Table *p){\n  if( *pRc==SQLITE_OK ){\n    int rc;                       /* Return code */\n    char *zSql;                   /* SQL text \"PRAGMA %Q.page_size\" */\n    sqlite3_stmt *pStmt;          /* Compiled \"PRAGMA %Q.page_size\" statement */\n  \n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", p->zDb);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_step(pStmt);\n        p->nPgsz = sqlite3_column_int(pStmt, 0);\n        rc = sqlite3_finalize(pStmt);\n      }else if( rc==SQLITE_AUTH ){\n        p->nPgsz = 1024;\n        rc = SQLITE_OK;\n      }\n    }\n    assert( p->nPgsz>0 || rc!=SQLITE_OK );\n    sqlite3_free(zSql);\n    *pRc = rc;\n  }\n}\n\n/*\n** \"Special\" FTS4 arguments are column specifications of the following form:\n**\n**   <key> = <value>\n**\n** There may not be whitespace surrounding the \"=\" character. The <value> \n** term may be quoted, but the <key> may not.\n*/\nstatic int fts3IsSpecialColumn(\n  const char *z, \n  int *pnKey,\n  char **pzValue\n){\n  char *zValue;\n  const char *zCsr = z;\n\n  while( *zCsr!='=' ){\n    if( *zCsr=='\\0' ) return 0;\n    zCsr++;\n  }\n\n  *pnKey = (int)(zCsr-z);\n  zValue = sqlite3_mprintf(\"%s\", &zCsr[1]);\n  if( zValue ){\n    sqlite3Fts3Dequote(zValue);\n  }\n  *pzValue = zValue;\n  return 1;\n}\n\n/*\n** Append the output of a printf() style formatting to an existing string.\n*/\nstatic void fts3Appendf(\n  int *pRc,                       /* IN/OUT: Error code */\n  char **pz,                      /* IN/OUT: Pointer to string buffer */\n  const char *zFormat,            /* Printf format string to append */\n  ...                             /* Arguments for printf format string */\n){\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    char *z;\n    va_start(ap, zFormat);\n    z = sqlite3_vmprintf(zFormat, ap);\n    va_end(ap);\n    if( z && *pz ){\n      char *z2 = sqlite3_mprintf(\"%s%s\", *pz, z);\n      sqlite3_free(z);\n      z = z2;\n    }\n    if( z==0 ) *pRc = SQLITE_NOMEM;\n    sqlite3_free(*pz);\n    *pz = z;\n  }\n}\n\n/*\n** Return a copy of input string zInput enclosed in double-quotes (\") and\n** with all double quote characters escaped. For example:\n**\n**     fts3QuoteId(\"un \\\"zip\\\"\")   ->    \"un \\\"\\\"zip\\\"\\\"\"\n**\n** The pointer returned points to memory obtained from sqlite3_malloc(). It\n** is the callers responsibility to call sqlite3_free() to release this\n** memory.\n*/\nstatic char *fts3QuoteId(char const *zInput){\n  int nRet;\n  char *zRet;\n  nRet = 2 + (int)strlen(zInput)*2 + 1;\n  zRet = sqlite3_malloc(nRet);\n  if( zRet ){\n    int i;\n    char *z = zRet;\n    *(z++) = '\"';\n    for(i=0; zInput[i]; i++){\n      if( zInput[i]=='\"' ) *(z++) = '\"';\n      *(z++) = zInput[i];\n    }\n    *(z++) = '\"';\n    *(z++) = '\\0';\n  }\n  return zRet;\n}\n\n/*\n** Return a list of comma separated SQL expressions and a FROM clause that \n** could be used in a SELECT statement such as the following:\n**\n**     SELECT <list of expressions> FROM %_content AS x ...\n**\n** to return the docid, followed by each column of text data in order\n** from left to write. If parameter zFunc is not NULL, then instead of\n** being returned directly each column of text data is passed to an SQL\n** function named zFunc first. For example, if zFunc is \"unzip\" and the\n** table has the three user-defined columns \"a\", \"b\", and \"c\", the following\n** string is returned:\n**\n**     \"docid, unzip(x.'a'), unzip(x.'b'), unzip(x.'c') FROM %_content AS x\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3ReadExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( p->zContentTbl==0 ){\n    if( !zFunc ){\n      zFunction = \"\";\n    }else{\n      zFree = zFunction = fts3QuoteId(zFunc);\n    }\n    fts3Appendf(pRc, &zRet, \"docid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \",%s(x.'c%d%q')\", zFunction, i, p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", \"langid\");\n    }\n    sqlite3_free(zFree);\n  }else{\n    fts3Appendf(pRc, &zRet, \"rowid\");\n    for(i=0; i<p->nColumn; i++){\n      fts3Appendf(pRc, &zRet, \", x.'%q'\", p->azColumn[i]);\n    }\n    if( p->zLanguageid ){\n      fts3Appendf(pRc, &zRet, \", x.%Q\", p->zLanguageid);\n    }\n  }\n  fts3Appendf(pRc, &zRet, \" FROM '%q'.'%q%s' AS x\", \n      p->zDb,\n      (p->zContentTbl ? p->zContentTbl : p->zName),\n      (p->zContentTbl ? \"\" : \"_content\")\n  );\n  return zRet;\n}\n\n/*\n** Return a list of N comma separated question marks, where N is the number\n** of columns in the %_content table (one for the docid plus one for each\n** user-defined text column).\n**\n** If argument zFunc is not NULL, then all but the first question mark\n** is preceded by zFunc and an open bracket, and followed by a closed\n** bracket. For example, if zFunc is \"zip\" and the FTS3 table has three \n** user-defined text columns, the following string is returned:\n**\n**     \"?, zip(?), zip(?), zip(?)\"\n**\n** The pointer returned points to a buffer allocated by sqlite3_malloc(). It\n** is the responsibility of the caller to eventually free it.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op (and\n** a NULL pointer is returned). Otherwise, if an OOM error is encountered\n** by this function, NULL is returned and *pRc is set to SQLITE_NOMEM. If\n** no error occurs, *pRc is left unmodified.\n*/\nstatic char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){\n  char *zRet = 0;\n  char *zFree = 0;\n  char *zFunction;\n  int i;\n\n  if( !zFunc ){\n    zFunction = \"\";\n  }else{\n    zFree = zFunction = fts3QuoteId(zFunc);\n  }\n  fts3Appendf(pRc, &zRet, \"?\");\n  for(i=0; i<p->nColumn; i++){\n    fts3Appendf(pRc, &zRet, \",%s(?)\", zFunction);\n  }\n  if( p->zLanguageid ){\n    fts3Appendf(pRc, &zRet, \", ?\");\n  }\n  sqlite3_free(zFree);\n  return zRet;\n}\n\n/*\n** This function interprets the string at (*pp) as a non-negative integer\n** value. It reads the integer and sets *pnOut to the value read, then \n** sets *pp to point to the byte immediately following the last byte of\n** the integer value.\n**\n** Only decimal digits ('0'..'9') may be part of an integer value. \n**\n** If *pp does not being with a decimal digit SQLITE_ERROR is returned and\n** the output value undefined. Otherwise SQLITE_OK is returned.\n**\n** This function is used when parsing the \"prefix=\" FTS4 parameter.\n*/\nstatic int fts3GobbleInt(const char **pp, int *pnOut){\n  const int MAX_NPREFIX = 10000000;\n  const char *p;                  /* Iterator pointer */\n  int nInt = 0;                   /* Output value */\n\n  for(p=*pp; p[0]>='0' && p[0]<='9'; p++){\n    nInt = nInt * 10 + (p[0] - '0');\n    if( nInt>MAX_NPREFIX ){\n      nInt = 0;\n      break;\n    }\n  }\n  if( p==*pp ) return SQLITE_ERROR;\n  *pnOut = nInt;\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called to allocate an array of Fts3Index structures\n** representing the indexes maintained by the current FTS table. FTS tables\n** always maintain the main \"terms\" index, but may also maintain one or\n** more \"prefix\" indexes, depending on the value of the \"prefix=\" parameter\n** (if any) specified as part of the CREATE VIRTUAL TABLE statement.\n**\n** Argument zParam is passed the value of the \"prefix=\" option if one was\n** specified, or NULL otherwise.\n**\n** If no error occurs, SQLITE_OK is returned and *apIndex set to point to\n** the allocated array. *pnIndex is set to the number of elements in the\n** array. If an error does occur, an SQLite error code is returned.\n**\n** Regardless of whether or not an error is returned, it is the responsibility\n** of the caller to call sqlite3_free() on the output array to free it.\n*/\nstatic int fts3PrefixParameter(\n  const char *zParam,             /* ABC in prefix=ABC parameter to parse */\n  int *pnIndex,                   /* OUT: size of *apIndex[] array */\n  struct Fts3Index **apIndex      /* OUT: Array of indexes for this table */\n){\n  struct Fts3Index *aIndex;       /* Allocated array */\n  int nIndex = 1;                 /* Number of entries in array */\n\n  if( zParam && zParam[0] ){\n    const char *p;\n    nIndex++;\n    for(p=zParam; *p; p++){\n      if( *p==',' ) nIndex++;\n    }\n  }\n\n  aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);\n  *apIndex = aIndex;\n  if( !aIndex ){\n    return SQLITE_NOMEM;\n  }\n\n  memset(aIndex, 0, sizeof(struct Fts3Index) * nIndex);\n  if( zParam ){\n    const char *p = zParam;\n    int i;\n    for(i=1; i<nIndex; i++){\n      int nPrefix = 0;\n      if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;\n      assert( nPrefix>=0 );\n      if( nPrefix==0 ){\n        nIndex--;\n        i--;\n      }else{\n        aIndex[i].nPrefix = nPrefix;\n      }\n      p++;\n    }\n  }\n\n  *pnIndex = nIndex;\n  return SQLITE_OK;\n}\n\n/*\n** This function is called when initializing an FTS4 table that uses the\n** content=xxx option. It determines the number of and names of the columns\n** of the new FTS4 table.\n**\n** The third argument passed to this function is the value passed to the\n** config=xxx option (i.e. \"xxx\"). This function queries the database for\n** a table of that name. If found, the output variables are populated\n** as follows:\n**\n**   *pnCol:   Set to the number of columns table xxx has,\n**\n**   *pnStr:   Set to the total amount of space required to store a copy\n**             of each columns name, including the nul-terminator.\n**\n**   *pazCol:  Set to point to an array of *pnCol strings. Each string is\n**             the name of the corresponding column in table xxx. The array\n**             and its contents are allocated using a single allocation. It\n**             is the responsibility of the caller to free this allocation\n**             by eventually passing the *pazCol value to sqlite3_free().\n**\n** If the table cannot be found, an error code is returned and the output\n** variables are undefined. Or, if an OOM is encountered, SQLITE_NOMEM is\n** returned (and the output variables are undefined).\n*/\nstatic int fts3ContentColumns(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (i.e. \"main\", \"temp\" etc.) */\n  const char *zTbl,               /* Name of content table */\n  const char ***pazCol,           /* OUT: Malloc'd array of column names */\n  int *pnCol,                     /* OUT: Size of array *pazCol */\n  int *pnStr,                     /* OUT: Bytes of string content */\n  char **pzErr                    /* OUT: error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  char *zSql;                     /* \"SELECT *\" statement on zTbl */  \n  sqlite3_stmt *pStmt = 0;        /* Compiled version of zSql */\n\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", zDb, zTbl);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"%s\", sqlite3_errmsg(db));\n    }\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    const char **azCol;           /* Output array */\n    int nStr = 0;                 /* Size of all column names (incl. 0x00) */\n    int nCol;                     /* Number of table columns */\n    int i;                        /* Used to iterate through columns */\n\n    /* Loop through the returned columns. Set nStr to the number of bytes of\n    ** space required to store a copy of each column name, including the\n    ** nul-terminator byte.  */\n    nCol = sqlite3_column_count(pStmt);\n    for(i=0; i<nCol; i++){\n      const char *zCol = sqlite3_column_name(pStmt, i);\n      nStr += (int)strlen(zCol) + 1;\n    }\n\n    /* Allocate and populate the array to return. */\n    azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);\n    if( azCol==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *p = (char *)&azCol[nCol];\n      for(i=0; i<nCol; i++){\n        const char *zCol = sqlite3_column_name(pStmt, i);\n        int n = (int)strlen(zCol)+1;\n        memcpy(p, zCol, n);\n        azCol[i] = p;\n        p += n;\n      }\n    }\n    sqlite3_finalize(pStmt);\n\n    /* Set the output variables. */\n    *pnCol = nCol;\n    *pnStr = nStr;\n    *pazCol = azCol;\n  }\n\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts3\" or \"fts4\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts3InitVtab(\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts3Hash *pHash = (Fts3Hash *)pAux;\n  Fts3Table *p = 0;               /* Pointer to allocated vtab */\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Iterator variable */\n  int nByte;                      /* Size of allocation used for *p */\n  int iCol;                       /* Column index */\n  int nString = 0;                /* Bytes required to hold all column names */\n  int nCol = 0;                   /* Number of columns in the FTS table */\n  char *zCsr;                     /* Space for holding column names */\n  int nDb;                        /* Bytes required to hold database name */\n  int nName;                      /* Bytes required to hold table name */\n  int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */\n  const char **aCol;              /* Array of column names */\n  sqlite3_tokenizer *pTokenizer = 0;        /* Tokenizer for this table */\n\n  int nIndex = 0;                 /* Size of aIndex[] array */\n  struct Fts3Index *aIndex = 0;   /* Array of indexes for this table */\n\n  /* The results of parsing supported FTS4 key=value options: */\n  int bNoDocsize = 0;             /* True to omit %_docsize table */\n  int bDescIdx = 0;               /* True to store descending indexes */\n  char *zPrefix = 0;              /* Prefix parameter value (or NULL) */\n  char *zCompress = 0;            /* compress=? parameter (or NULL) */\n  char *zUncompress = 0;          /* uncompress=? parameter (or NULL) */\n  char *zContent = 0;             /* content=? parameter (or NULL) */\n  char *zLanguageid = 0;          /* languageid=? parameter (or NULL) */\n  char **azNotindexed = 0;        /* The set of notindexed= columns */\n  int nNotindexed = 0;            /* Size of azNotindexed[] array */\n\n  assert( strlen(argv[0])==4 );\n  assert( (sqlite3_strnicmp(argv[0], \"fts4\", 4)==0 && isFts4)\n       || (sqlite3_strnicmp(argv[0], \"fts3\", 4)==0 && !isFts4)\n  );\n\n  nDb = (int)strlen(argv[1]) + 1;\n  nName = (int)strlen(argv[2]) + 1;\n\n  nByte = sizeof(const char *) * (argc-2);\n  aCol = (const char **)sqlite3_malloc(nByte);\n  if( aCol ){\n    memset((void*)aCol, 0, nByte);\n    azNotindexed = (char **)sqlite3_malloc(nByte);\n  }\n  if( azNotindexed ){\n    memset(azNotindexed, 0, nByte);\n  }\n  if( !aCol || !azNotindexed ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n\n  /* Loop through all of the arguments passed by the user to the FTS3/4\n  ** module (i.e. all the column names and special arguments). This loop\n  ** does the following:\n  **\n  **   + Figures out the number of columns the FTSX table will have, and\n  **     the number of bytes of space that must be allocated to store copies\n  **     of the column names.\n  **\n  **   + If there is a tokenizer specification included in the arguments,\n  **     initializes the tokenizer pTokenizer.\n  */\n  for(i=3; rc==SQLITE_OK && i<argc; i++){\n    char const *z = argv[i];\n    int nKey;\n    char *zVal;\n\n    /* Check if this is a tokenizer specification */\n    if( !pTokenizer \n     && strlen(z)>8\n     && 0==sqlite3_strnicmp(z, \"tokenize\", 8) \n     && 0==sqlite3Fts3IsIdChar(z[8])\n    ){\n      rc = sqlite3Fts3InitTokenizer(pHash, &z[9], &pTokenizer, pzErr);\n    }\n\n    /* Check if it is an FTS4 special argument. */\n    else if( isFts4 && fts3IsSpecialColumn(z, &nKey, &zVal) ){\n      struct Fts4Option {\n        const char *zOpt;\n        int nOpt;\n      } aFts4Opt[] = {\n        { \"matchinfo\",   9 },     /* 0 -> MATCHINFO */\n        { \"prefix\",      6 },     /* 1 -> PREFIX */\n        { \"compress\",    8 },     /* 2 -> COMPRESS */\n        { \"uncompress\", 10 },     /* 3 -> UNCOMPRESS */\n        { \"order\",       5 },     /* 4 -> ORDER */\n        { \"content\",     7 },     /* 5 -> CONTENT */\n        { \"languageid\", 10 },     /* 6 -> LANGUAGEID */\n        { \"notindexed\", 10 }      /* 7 -> NOTINDEXED */\n      };\n\n      int iOpt;\n      if( !zVal ){\n        rc = SQLITE_NOMEM;\n      }else{\n        for(iOpt=0; iOpt<SizeofArray(aFts4Opt); iOpt++){\n          struct Fts4Option *pOp = &aFts4Opt[iOpt];\n          if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){\n            break;\n          }\n        }\n        switch( iOpt ){\n          case 0:               /* MATCHINFO */\n            if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"fts3\", 4) ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bNoDocsize = 1;\n            break;\n\n          case 1:               /* PREFIX */\n            sqlite3_free(zPrefix);\n            zPrefix = zVal;\n            zVal = 0;\n            break;\n\n          case 2:               /* COMPRESS */\n            sqlite3_free(zCompress);\n            zCompress = zVal;\n            zVal = 0;\n            break;\n\n          case 3:               /* UNCOMPRESS */\n            sqlite3_free(zUncompress);\n            zUncompress = zVal;\n            zVal = 0;\n            break;\n\n          case 4:               /* ORDER */\n            if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, \"asc\", 3)) \n             && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, \"desc\", 4)) \n            ){\n              sqlite3Fts3ErrMsg(pzErr, \"unrecognized order: %s\", zVal);\n              rc = SQLITE_ERROR;\n            }\n            bDescIdx = (zVal[0]=='d' || zVal[0]=='D');\n            break;\n\n          case 5:              /* CONTENT */\n            sqlite3_free(zContent);\n            zContent = zVal;\n            zVal = 0;\n            break;\n\n          case 6:              /* LANGUAGEID */\n            assert( iOpt==6 );\n            sqlite3_free(zLanguageid);\n            zLanguageid = zVal;\n            zVal = 0;\n            break;\n\n          case 7:              /* NOTINDEXED */\n            azNotindexed[nNotindexed++] = zVal;\n            zVal = 0;\n            break;\n\n          default:\n            assert( iOpt==SizeofArray(aFts4Opt) );\n            sqlite3Fts3ErrMsg(pzErr, \"unrecognized parameter: %s\", z);\n            rc = SQLITE_ERROR;\n            break;\n        }\n        sqlite3_free(zVal);\n      }\n    }\n\n    /* Otherwise, the argument is a column name. */\n    else {\n      nString += (int)(strlen(z) + 1);\n      aCol[nCol++] = z;\n    }\n  }\n\n  /* If a content=xxx option was specified, the following:\n  **\n  **   1. Ignore any compress= and uncompress= options.\n  **\n  **   2. If no column names were specified as part of the CREATE VIRTUAL\n  **      TABLE statement, use all columns from the content table.\n  */\n  if( rc==SQLITE_OK && zContent ){\n    sqlite3_free(zCompress); \n    sqlite3_free(zUncompress); \n    zCompress = 0;\n    zUncompress = 0;\n    if( nCol==0 ){\n      sqlite3_free((void*)aCol); \n      aCol = 0;\n      rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);\n\n      /* If a languageid= option was specified, remove the language id\n      ** column from the aCol[] array. */ \n      if( rc==SQLITE_OK && zLanguageid ){\n        int j;\n        for(j=0; j<nCol; j++){\n          if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){\n            int k;\n            for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];\n            nCol--;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  if( nCol==0 ){\n    assert( nString==0 );\n    aCol[0] = \"content\";\n    nString = 8;\n    nCol = 1;\n  }\n\n  if( pTokenizer==0 ){\n    rc = sqlite3Fts3InitTokenizer(pHash, \"simple\", &pTokenizer, pzErr);\n    if( rc!=SQLITE_OK ) goto fts3_init_out;\n  }\n  assert( pTokenizer );\n\n  rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);\n  if( rc==SQLITE_ERROR ){\n    assert( zPrefix );\n    sqlite3Fts3ErrMsg(pzErr, \"error parsing prefix parameter: %s\", zPrefix);\n  }\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* Allocate and populate the Fts3Table structure. */\n  nByte = sizeof(Fts3Table) +                  /* Fts3Table */\n          nCol * sizeof(char *) +              /* azColumn */\n          nIndex * sizeof(struct Fts3Index) +  /* aIndex */\n          nCol * sizeof(u8) +                  /* abNotindexed */\n          nName +                              /* zName */\n          nDb +                                /* zDb */\n          nString;                             /* Space for azColumn strings */\n  p = (Fts3Table*)sqlite3_malloc(nByte);\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n    goto fts3_init_out;\n  }\n  memset(p, 0, nByte);\n  p->db = db;\n  p->nColumn = nCol;\n  p->nPendingData = 0;\n  p->azColumn = (char **)&p[1];\n  p->pTokenizer = pTokenizer;\n  p->nMaxPendingData = FTS3_MAX_PENDING_DATA;\n  p->bHasDocsize = (isFts4 && bNoDocsize==0);\n  p->bHasStat = (u8)isFts4;\n  p->bFts4 = (u8)isFts4;\n  p->bDescIdx = (u8)bDescIdx;\n  p->nAutoincrmerge = 0xff;   /* 0xff means setting unknown */\n  p->zContentTbl = zContent;\n  p->zLanguageid = zLanguageid;\n  zContent = 0;\n  zLanguageid = 0;\n  TESTONLY( p->inTransaction = -1 );\n  TESTONLY( p->mxSavepoint = -1 );\n\n  p->aIndex = (struct Fts3Index *)&p->azColumn[nCol];\n  memcpy(p->aIndex, aIndex, sizeof(struct Fts3Index) * nIndex);\n  p->nIndex = nIndex;\n  for(i=0; i<nIndex; i++){\n    fts3HashInit(&p->aIndex[i].hPending, FTS3_HASH_STRING, 1);\n  }\n  p->abNotindexed = (u8 *)&p->aIndex[nIndex];\n\n  /* Fill in the zName and zDb fields of the vtab structure. */\n  zCsr = (char *)&p->abNotindexed[nCol];\n  p->zName = zCsr;\n  memcpy(zCsr, argv[2], nName);\n  zCsr += nName;\n  p->zDb = zCsr;\n  memcpy(zCsr, argv[1], nDb);\n  zCsr += nDb;\n\n  /* Fill in the azColumn array */\n  for(iCol=0; iCol<nCol; iCol++){\n    char *z; \n    int n = 0;\n    z = (char *)sqlite3Fts3NextToken(aCol[iCol], &n);\n    if( n>0 ){\n      memcpy(zCsr, z, n);\n    }\n    zCsr[n] = '\\0';\n    sqlite3Fts3Dequote(zCsr);\n    p->azColumn[iCol] = zCsr;\n    zCsr += n+1;\n    assert( zCsr <= &((char *)p)[nByte] );\n  }\n\n  /* Fill in the abNotindexed array */\n  for(iCol=0; iCol<nCol; iCol++){\n    int n = (int)strlen(p->azColumn[iCol]);\n    for(i=0; i<nNotindexed; i++){\n      char *zNot = azNotindexed[i];\n      if( zNot && n==(int)strlen(zNot)\n       && 0==sqlite3_strnicmp(p->azColumn[iCol], zNot, n) \n      ){\n        p->abNotindexed[iCol] = 1;\n        sqlite3_free(zNot);\n        azNotindexed[i] = 0;\n      }\n    }\n  }\n  for(i=0; i<nNotindexed; i++){\n    if( azNotindexed[i] ){\n      sqlite3Fts3ErrMsg(pzErr, \"no such column: %s\", azNotindexed[i]);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){\n    char const *zMiss = (zCompress==0 ? \"compress\" : \"uncompress\");\n    rc = SQLITE_ERROR;\n    sqlite3Fts3ErrMsg(pzErr, \"missing %s parameter in fts4 constructor\", zMiss);\n  }\n  p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);\n  p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);\n  if( rc!=SQLITE_OK ) goto fts3_init_out;\n\n  /* If this is an xCreate call, create the underlying tables in the \n  ** database. TODO: For xConnect(), it could verify that said tables exist.\n  */\n  if( isCreate ){\n    rc = fts3CreateTables(p);\n  }\n\n  /* Check to see if a legacy fts3 table has been \"upgraded\" by the\n  ** addition of a %_stat table so that it can use incremental merge.\n  */\n  if( !isFts4 && !isCreate ){\n    p->bHasStat = 2;\n  }\n\n  /* Figure out the page-size for the database. This is required in order to\n  ** estimate the cost of loading large doclists from the database.  */\n  fts3DatabasePageSize(&rc, p);\n  p->nNodeSize = p->nPgsz-35;\n\n  /* Declare the table schema to SQLite. */\n  fts3DeclareVtab(&rc, p);\n\nfts3_init_out:\n  sqlite3_free(zPrefix);\n  sqlite3_free(aIndex);\n  sqlite3_free(zCompress);\n  sqlite3_free(zUncompress);\n  sqlite3_free(zContent);\n  sqlite3_free(zLanguageid);\n  for(i=0; i<nNotindexed; i++) sqlite3_free(azNotindexed[i]);\n  sqlite3_free((void *)aCol);\n  sqlite3_free((void *)azNotindexed);\n  if( rc!=SQLITE_OK ){\n    if( p ){\n      fts3DisconnectMethod((sqlite3_vtab *)p);\n    }else if( pTokenizer ){\n      pTokenizer->pModule->xDestroy(pTokenizer);\n    }\n  }else{\n    assert( p->pSegments==0 );\n    *ppVTab = &p->base;\n  }\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts3InitVtab().\n*/\nstatic int fts3ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts3CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts3InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** Set the pIdxInfo->estimatedRows variable to nRow. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support estimatedRows. In that case this function is a no-op.\n*/\nstatic void fts3SetEstimatedRows(sqlite3_index_info *pIdxInfo, i64 nRow){\n#if SQLITE_VERSION_NUMBER>=3008002\n  if( sqlite3_libversion_number()>=3008002 ){\n    pIdxInfo->estimatedRows = nRow;\n  }\n#endif\n}\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts3SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n  if( sqlite3_libversion_number()>=3008012 ){\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/* \n** Implementation of the xBestIndex method for FTS3 tables. There\n** are three possible strategies, in order of preference:\n**\n**   1. Direct lookup by rowid or docid. \n**   2. Full-text search using a MATCH operator on a non-docid column.\n**   3. Linear scan of %_content table.\n*/\nstatic int fts3BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts3Table *p = (Fts3Table *)pVTab;\n  int i;                          /* Iterator variable */\n  int iCons = -1;                 /* Index of constraint to use */\n\n  int iLangidCons = -1;           /* Index of langid=x constraint, if present */\n  int iDocidGe = -1;              /* Index of docid>=x constraint, if present */\n  int iDocidLe = -1;              /* Index of docid<=x constraint, if present */\n  int iIdx;\n\n  /* By default use a full table scan. This is an expensive option,\n  ** so search through the constraints to see if a more efficient \n  ** strategy is possible.\n  */\n  pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n  pInfo->estimatedCost = 5000000;\n  for(i=0; i<pInfo->nConstraint; i++){\n    int bDocid;                 /* True if this constraint is on docid */\n    struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];\n    if( pCons->usable==0 ){\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n        /* There exists an unusable MATCH constraint. This means that if\n        ** the planner does elect to use the results of this call as part\n        ** of the overall query plan the user will see an \"unable to use\n        ** function MATCH in the requested context\" error. To discourage\n        ** this, return a very high cost here.  */\n        pInfo->idxNum = FTS3_FULLSCAN_SEARCH;\n        pInfo->estimatedCost = 1e50;\n        fts3SetEstimatedRows(pInfo, ((sqlite3_int64)1) << 50);\n        return SQLITE_OK;\n      }\n      continue;\n    }\n\n    bDocid = (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1);\n\n    /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */\n    if( iCons<0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && bDocid ){\n      pInfo->idxNum = FTS3_DOCID_SEARCH;\n      pInfo->estimatedCost = 1.0;\n      iCons = i;\n    }\n\n    /* A MATCH constraint. Use a full-text search.\n    **\n    ** If there is more than one MATCH constraint available, use the first\n    ** one encountered. If there is both a MATCH constraint and a direct\n    ** rowid/docid lookup, prefer the MATCH strategy. This is done even \n    ** though the rowid/docid lookup is faster than a MATCH query, selecting\n    ** it would lead to an \"unable to use function MATCH in the requested \n    ** context\" error.\n    */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH \n     && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn\n    ){\n      pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;\n      pInfo->estimatedCost = 2.0;\n      iCons = i;\n    }\n\n    /* Equality constraint on the langid column */\n    if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ \n     && pCons->iColumn==p->nColumn + 2\n    ){\n      iLangidCons = i;\n    }\n\n    if( bDocid ){\n      switch( pCons->op ){\n        case SQLITE_INDEX_CONSTRAINT_GE:\n        case SQLITE_INDEX_CONSTRAINT_GT:\n          iDocidGe = i;\n          break;\n\n        case SQLITE_INDEX_CONSTRAINT_LE:\n        case SQLITE_INDEX_CONSTRAINT_LT:\n          iDocidLe = i;\n          break;\n      }\n    }\n  }\n\n  /* If using a docid=? or rowid=? strategy, set the UNIQUE flag. */\n  if( pInfo->idxNum==FTS3_DOCID_SEARCH ) fts3SetUniqueFlag(pInfo);\n\n  iIdx = 1;\n  if( iCons>=0 ){\n    pInfo->aConstraintUsage[iCons].argvIndex = iIdx++;\n    pInfo->aConstraintUsage[iCons].omit = 1;\n  } \n  if( iLangidCons>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_LANGID;\n    pInfo->aConstraintUsage[iLangidCons].argvIndex = iIdx++;\n  } \n  if( iDocidGe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_GE;\n    pInfo->aConstraintUsage[iDocidGe].argvIndex = iIdx++;\n  } \n  if( iDocidLe>=0 ){\n    pInfo->idxNum |= FTS3_HAVE_DOCID_LE;\n    pInfo->aConstraintUsage[iDocidLe].argvIndex = iIdx++;\n  } \n\n  /* Regardless of the strategy selected, FTS can deliver rows in rowid (or\n  ** docid) order. Both ascending and descending are possible. \n  */\n  if( pInfo->nOrderBy==1 ){\n    struct sqlite3_index_orderby *pOrder = &pInfo->aOrderBy[0];\n    if( pOrder->iColumn<0 || pOrder->iColumn==p->nColumn+1 ){\n      if( pOrder->desc ){\n        pInfo->idxStr = \"DESC\";\n      }else{\n        pInfo->idxStr = \"ASC\";\n      }\n      pInfo->orderByConsumed = 1;\n    }\n  }\n\n  assert( p->pSegments==0 );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts3OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  sqlite3_vtab_cursor *pCsr;               /* Allocated cursor */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* Allocate a buffer large enough for an Fts3Cursor structure. If the\n  ** allocation succeeds, zero it and return SQLITE_OK. Otherwise, \n  ** if the allocation fails, return SQLITE_NOMEM.\n  */\n  *ppCsr = pCsr = (sqlite3_vtab_cursor *)sqlite3_malloc(sizeof(Fts3Cursor));\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3Cursor));\n  return SQLITE_OK;\n}\n\n/*\n** Finalize the statement handle at pCsr->pStmt.\n**\n** Or, if that statement handle is one created by fts3CursorSeekStmt(),\n** and the Fts3Table.pSeekStmt slot is currently NULL, save the statement\n** pointer there instead of finalizing it.\n*/\nstatic void fts3CursorFinalizeStmt(Fts3Cursor *pCsr){\n  if( pCsr->bSeekStmt ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    if( p->pSeekStmt==0 ){\n      p->pSeekStmt = pCsr->pStmt;\n      sqlite3_reset(pCsr->pStmt);\n      pCsr->pStmt = 0;\n    }\n    pCsr->bSeekStmt = 0;\n  }\n  sqlite3_finalize(pCsr->pStmt);\n}\n\n/*\n** Free all resources currently held by the cursor passed as the only\n** argument.\n*/\nstatic void fts3ClearCursor(Fts3Cursor *pCsr){\n  fts3CursorFinalizeStmt(pCsr);\n  sqlite3Fts3FreeDeferredTokens(pCsr);\n  sqlite3_free(pCsr->aDoclist);\n  sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n  sqlite3Fts3ExprFree(pCsr->pExpr);\n  memset(&(&pCsr->base)[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  fts3ClearCursor(pCsr);\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** If pCsr->pStmt has not been prepared (i.e. if pCsr->pStmt==0), then\n** compose and prepare an SQL statement of the form:\n**\n**    \"SELECT <columns> FROM %_content WHERE rowid = ?\"\n**\n** (or the equivalent for a content=xxx table) and set pCsr->pStmt to\n** it. If an error occurs, return an SQLite error code.\n*/\nstatic int fts3CursorSeekStmt(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->pStmt==0 ){\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    char *zSql;\n    if( p->pSeekStmt ){\n      pCsr->pStmt = p->pSeekStmt;\n      p->pSeekStmt = 0;\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s WHERE rowid = ?\", p->zReadExprlist);\n      if( !zSql ) return SQLITE_NOMEM;\n      rc = sqlite3_prepare_v3(p->db, zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }\n    if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1;\n  }\n  return rc;\n}\n\n/*\n** Position the pCsr->pStmt statement so that it is on the row\n** of the %_content table that contains the last match.  Return\n** SQLITE_OK on success.  \n*/\nstatic int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;\n  if( pCsr->isRequireSeek ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);\n      pCsr->isRequireSeek = 0;\n      if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){\n        return SQLITE_OK;\n      }else{\n        rc = sqlite3_reset(pCsr->pStmt);\n        if( rc==SQLITE_OK && ((Fts3Table *)pCsr->base.pVtab)->zContentTbl==0 ){\n          /* If no row was found and no error has occurred, then the %_content\n          ** table is missing a row that is present in the full-text index.\n          ** The data structures are corrupt.  */\n          rc = FTS_CORRUPT_VTAB;\n          pCsr->isEof = 1;\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK && pContext ){\n    sqlite3_result_error_code(pContext, rc);\n  }\n  return rc;\n}\n\n/*\n** This function is used to process a single interior node when searching\n** a b-tree for a term or term prefix. The node data is passed to this \n** function via the zNode/nNode parameters. The term to search for is\n** passed in zTerm/nTerm.\n**\n** If piFirst is not NULL, then this function sets *piFirst to the blockid\n** of the child node that heads the sub-tree that may contain the term.\n**\n** If piLast is not NULL, then *piLast is set to the right-most child node\n** that heads a sub-tree that may contain a term for which zTerm/nTerm is\n** a prefix.\n**\n** If an OOM error occurs, SQLITE_NOMEM is returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3ScanInteriorNode(\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piFirst,         /* OUT: Selected child node */\n  sqlite3_int64 *piLast           /* OUT: Selected child node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *zCsr = zNode;       /* Cursor to iterate through node */\n  const char *zEnd = &zCsr[nNode];/* End of interior node buffer */\n  char *zBuffer = 0;              /* Buffer to load terms into */\n  int nAlloc = 0;                 /* Size of allocated buffer */\n  int isFirstTerm = 1;            /* True when processing first term on page */\n  sqlite3_int64 iChild;           /* Block id of child node to descend to */\n\n  /* Skip over the 'height' varint that occurs at the start of every \n  ** interior node. Then load the blockid of the left-child of the b-tree\n  ** node into variable iChild.  \n  **\n  ** Even if the data structure on disk is corrupted, this (reading two\n  ** varints from the buffer) does not risk an overread. If zNode is a\n  ** root node, then the buffer comes from a SELECT statement. SQLite does\n  ** not make this guarantee explicitly, but in practice there are always\n  ** either more than 20 bytes of allocated space following the nNode bytes of\n  ** contents, or two zero bytes. Or, if the node is read from the %_segments\n  ** table, then there are always 20 bytes of zeroed padding following the\n  ** nNode bytes of content (see sqlite3Fts3ReadBlock() for details).\n  */\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  zCsr += sqlite3Fts3GetVarint(zCsr, &iChild);\n  if( zCsr>zEnd ){\n    return FTS_CORRUPT_VTAB;\n  }\n  \n  while( zCsr<zEnd && (piFirst || piLast) ){\n    int cmp;                      /* memcmp() result */\n    int nSuffix;                  /* Size of term suffix */\n    int nPrefix = 0;              /* Size of term prefix */\n    int nBuffer;                  /* Total term size */\n  \n    /* Load the next term on the node into zBuffer. Use realloc() to expand\n    ** the size of zBuffer if required.  */\n    if( !isFirstTerm ){\n      zCsr += fts3GetVarint32(zCsr, &nPrefix);\n    }\n    isFirstTerm = 0;\n    zCsr += fts3GetVarint32(zCsr, &nSuffix);\n    \n    assert( nPrefix>=0 && nSuffix>=0 );\n    if( &zCsr[nSuffix]>zEnd ){\n      rc = FTS_CORRUPT_VTAB;\n      goto finish_scan;\n    }\n    if( nPrefix+nSuffix>nAlloc ){\n      char *zNew;\n      nAlloc = (nPrefix+nSuffix) * 2;\n      zNew = (char *)sqlite3_realloc(zBuffer, nAlloc);\n      if( !zNew ){\n        rc = SQLITE_NOMEM;\n        goto finish_scan;\n      }\n      zBuffer = zNew;\n    }\n    assert( zBuffer );\n    memcpy(&zBuffer[nPrefix], zCsr, nSuffix);\n    nBuffer = nPrefix + nSuffix;\n    zCsr += nSuffix;\n\n    /* Compare the term we are searching for with the term just loaded from\n    ** the interior node. If the specified term is greater than or equal\n    ** to the term from the interior node, then all terms on the sub-tree \n    ** headed by node iChild are smaller than zTerm. No need to search \n    ** iChild.\n    **\n    ** If the interior node term is larger than the specified term, then\n    ** the tree headed by iChild may contain the specified term.\n    */\n    cmp = memcmp(zTerm, zBuffer, (nBuffer>nTerm ? nTerm : nBuffer));\n    if( piFirst && (cmp<0 || (cmp==0 && nBuffer>nTerm)) ){\n      *piFirst = iChild;\n      piFirst = 0;\n    }\n\n    if( piLast && cmp<0 ){\n      *piLast = iChild;\n      piLast = 0;\n    }\n\n    iChild++;\n  };\n\n  if( piFirst ) *piFirst = iChild;\n  if( piLast ) *piLast = iChild;\n\n finish_scan:\n  sqlite3_free(zBuffer);\n  return rc;\n}\n\n\n/*\n** The buffer pointed to by argument zNode (size nNode bytes) contains an\n** interior node of a b-tree segment. The zTerm buffer (size nTerm bytes)\n** contains a term. This function searches the sub-tree headed by the zNode\n** node for the range of leaf nodes that may contain the specified term\n** or terms for which the specified term is a prefix.\n**\n** If piLeaf is not NULL, then *piLeaf is set to the blockid of the \n** left-most leaf node in the tree that may contain the specified term.\n** If piLeaf2 is not NULL, then *piLeaf2 is set to the blockid of the\n** right-most leaf node that may contain a term for which the specified\n** term is a prefix.\n**\n** It is possible that the range of returned leaf nodes does not contain \n** the specified term or any terms for which it is a prefix. However, if the \n** segment does contain any such terms, they are stored within the identified\n** range. Because this function only inspects interior segment nodes (and\n** never loads leaf nodes into memory), it is not possible to be sure.\n**\n** If an error occurs, an error code other than SQLITE_OK is returned.\n*/ \nstatic int fts3SelectLeaf(\n  Fts3Table *p,                   /* Virtual table handle */\n  const char *zTerm,              /* Term to select leaves for */\n  int nTerm,                      /* Size of term zTerm in bytes */\n  const char *zNode,              /* Buffer containing segment interior node */\n  int nNode,                      /* Size of buffer at zNode */\n  sqlite3_int64 *piLeaf,          /* Selected leaf node */\n  sqlite3_int64 *piLeaf2          /* Selected leaf node */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int iHeight;                    /* Height of this node in tree */\n\n  assert( piLeaf || piLeaf2 );\n\n  fts3GetVarint32(zNode, &iHeight);\n  rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);\n  assert( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );\n\n  if( rc==SQLITE_OK && iHeight>1 ){\n    char *zBlob = 0;              /* Blob read from %_segments table */\n    int nBlob = 0;                /* Size of zBlob in bytes */\n\n    if( piLeaf && piLeaf2 && (*piLeaf!=*piLeaf2) ){\n      rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);\n      if( rc==SQLITE_OK ){\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, 0);\n      }\n      sqlite3_free(zBlob);\n      piLeaf = 0;\n      zBlob = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3ReadBlock(p, piLeaf?*piLeaf:*piLeaf2, &zBlob, &nBlob, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3SelectLeaf(p, zTerm, nTerm, zBlob, nBlob, piLeaf, piLeaf2);\n    }\n    sqlite3_free(zBlob);\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to create delta-encoded serialized lists of FTS3 \n** varints. Each call to this function appends a single varint to a list.\n*/\nstatic void fts3PutDeltaVarint(\n  char **pp,                      /* IN/OUT: Output pointer */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );\n  *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);\n  *piPrev = iVal;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a position-list. After it returns, *ppPoslist points to the\n** first byte after the position-list.\n**\n** A position list is list of positions (delta encoded) and columns for \n** a single document record of a doclist.  So, in other words, this\n** routine advances *ppPoslist so that it points to the next docid in\n** the doclist, or to the first byte past the end of the doclist.\n**\n** If pp is not NULL, then the contents of the position list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.\n*/\nstatic void fts3PoslistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* The end of a position list is marked by a zero encoded as an FTS3 \n  ** varint. A single POS_END (0) byte. Except, if the 0 byte is preceded by\n  ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail\n  ** of some other, multi-byte, value.\n  **\n  ** The following while-loop moves pEnd to point to the first byte that is not \n  ** immediately preceded by a byte with the 0x80 bit set. Then increments\n  ** pEnd once more so that it points to the byte immediately following the\n  ** last byte in the position-list.\n  */\n  while( *pEnd | c ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && (*pEnd)==0 );\n  }\n  pEnd++;  /* Advance past the POS_END terminator byte */\n\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** When this function is called, *ppPoslist is assumed to point to the \n** start of a column-list. After it returns, *ppPoslist points to the\n** to the terminator (POS_COLUMN or POS_END) byte of the column-list.\n**\n** A column-list is list of delta-encoded positions for a single column\n** within a single document within a doclist.\n**\n** The column-list is terminated either by a POS_COLUMN varint (1) or\n** a POS_END varint (0).  This routine leaves *ppPoslist pointing to\n** the POS_COLUMN or POS_END that terminates the column-list.\n**\n** If pp is not NULL, then the contents of the column-list are copied\n** to *pp. *pp is set to point to the first byte past the last byte copied\n** before this function returns.  The POS_COLUMN or POS_END terminator\n** is not copied into *pp.\n*/\nstatic void fts3ColumnlistCopy(char **pp, char **ppPoslist){\n  char *pEnd = *ppPoslist;\n  char c = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00 byte that is\n  ** not part of a multi-byte varint.\n  */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    testcase( c!=0 && ((*pEnd)&0xfe)==0 );\n  }\n  if( pp ){\n    int n = (int)(pEnd - *ppPoslist);\n    char *p = *pp;\n    memcpy(p, *ppPoslist, n);\n    p += n;\n    *pp = p;\n  }\n  *ppPoslist = pEnd;\n}\n\n/*\n** Value used to signify the end of an position-list. This is safe because\n** it is not possible to have a document with 2^31 terms.\n*/\n#define POSITION_LIST_END 0x7fffffff\n\n/*\n** This function is used to help parse position-lists. When this function is\n** called, *pp may point to the start of the next varint in the position-list\n** being parsed, or it may point to 1 byte past the end of the position-list\n** (in which case **pp will be a terminator bytes POS_END (0) or\n** (1)).\n**\n** If *pp points past the end of the current position-list, set *pi to \n** POSITION_LIST_END and return. Otherwise, read the next varint from *pp,\n** increment the current value of *pi by the value read, and set *pp to\n** point to the next value before returning.\n**\n** Before calling this routine *pi must be initialized to the value of\n** the previous position, or zero if we are reading the first position\n** in the position-list.  Because positions are delta-encoded, the value\n** of the previous position is needed in order to compute the value of\n** the next position.\n*/\nstatic void fts3ReadNextPos(\n  char **pp,                    /* IN/OUT: Pointer into position-list buffer */\n  sqlite3_int64 *pi             /* IN/OUT: Value read from position-list */\n){\n  if( (**pp)&0xFE ){\n    fts3GetDeltaVarint(pp, pi);\n    *pi -= 2;\n  }else{\n    *pi = POSITION_LIST_END;\n  }\n}\n\n/*\n** If parameter iCol is not 0, write an POS_COLUMN (1) byte followed by\n** the value of iCol encoded as a varint to *pp.   This will start a new\n** column list.\n**\n** Set *pp to point to the byte just after the last byte written before \n** returning (do not modify it if iCol==0). Return the total number of bytes\n** written (0 if iCol==0).\n*/\nstatic int fts3PutColNumber(char **pp, int iCol){\n  int n = 0;                      /* Number of bytes written */\n  if( iCol ){\n    char *p = *pp;                /* Output pointer */\n    n = 1 + sqlite3Fts3PutVarint(&p[1], iCol);\n    *p = 0x01;\n    *pp = &p[n];\n  }\n  return n;\n}\n\n/*\n** Compute the union of two position lists.  The output written\n** into *pp contains all positions of both *pp1 and *pp2 in sorted\n** order and with any duplicates removed.  All pointers are\n** updated appropriately.   The caller is responsible for insuring\n** that there is enough space in *pp to hold the complete output.\n*/\nstatic void fts3PoslistMerge(\n  char **pp,                      /* Output buffer */\n  char **pp1,                     /* Left input list */\n  char **pp2                      /* Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  while( *p1 || *p2 ){\n    int iCol1;         /* The current column index in pp1 */\n    int iCol2;         /* The current column index in pp2 */\n\n    if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);\n    else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;\n    else iCol1 = 0;\n\n    if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);\n    else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;\n    else iCol2 = 0;\n\n    if( iCol1==iCol2 ){\n      sqlite3_int64 i1 = 0;       /* Last position from pp1 */\n      sqlite3_int64 i2 = 0;       /* Last position from pp2 */\n      sqlite3_int64 iPrev = 0;\n      int n = fts3PutColNumber(&p, iCol1);\n      p1 += n;\n      p2 += n;\n\n      /* At this point, both p1 and p2 point to the start of column-lists\n      ** for the same column (the column with index iCol1 and iCol2).\n      ** A column-list is a list of non-negative delta-encoded varints, each \n      ** incremented by 2 before being stored. Each list is terminated by a\n      ** POS_END (0) or POS_COLUMN (1). The following block merges the two lists\n      ** and writes the results to buffer p. p is left pointing to the byte\n      ** after the list written. No terminator (POS_END or POS_COLUMN) is\n      ** written to the output.\n      */\n      fts3GetDeltaVarint(&p1, &i1);\n      fts3GetDeltaVarint(&p2, &i2);\n      do {\n        fts3PutDeltaVarint(&p, &iPrev, (i1<i2) ? i1 : i2); \n        iPrev -= 2;\n        if( i1==i2 ){\n          fts3ReadNextPos(&p1, &i1);\n          fts3ReadNextPos(&p2, &i2);\n        }else if( i1<i2 ){\n          fts3ReadNextPos(&p1, &i1);\n        }else{\n          fts3ReadNextPos(&p2, &i2);\n        }\n      }while( i1!=POSITION_LIST_END || i2!=POSITION_LIST_END );\n    }else if( iCol1<iCol2 ){\n      p1 += fts3PutColNumber(&p, iCol1);\n      fts3ColumnlistCopy(&p, &p1);\n    }else{\n      p2 += fts3PutColNumber(&p, iCol2);\n      fts3ColumnlistCopy(&p, &p2);\n    }\n  }\n\n  *p++ = POS_END;\n  *pp = p;\n  *pp1 = p1 + 1;\n  *pp2 = p2 + 1;\n}\n\n/*\n** This function is used to merge two position lists into one. When it is\n** called, *pp1 and *pp2 must both point to position lists. A position-list is\n** the part of a doclist that follows each document id. For example, if a row\n** contains:\n**\n**     'a b c'|'x y z'|'a b b a'\n**\n** Then the position list for this row for token 'b' would consist of:\n**\n**     0x02 0x01 0x02 0x03 0x03 0x00\n**\n** When this function returns, both *pp1 and *pp2 are left pointing to the\n** byte following the 0x00 terminator of their respective position lists.\n**\n** If isSaveLeft is 0, an entry is added to the output position list for \n** each position in *pp2 for which there exists one or more positions in\n** *pp1 so that (pos(*pp2)>pos(*pp1) && pos(*pp2)-pos(*pp1)<=nToken). i.e.\n** when the *pp1 token appears before the *pp2 token, but not more than nToken\n** slots before it.\n**\n** e.g. nToken==1 searches for adjacent positions.\n*/\nstatic int fts3PoslistPhraseMerge(\n  char **pp,                      /* IN/OUT: Preallocated output buffer */\n  int nToken,                     /* Maximum difference in token positions */\n  int isSaveLeft,                 /* Save the left position */\n  int isExact,                    /* If *pp1 is exactly nTokens before *pp2 */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p = *pp;\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n  int iCol1 = 0;\n  int iCol2 = 0;\n\n  /* Never set both isSaveLeft and isExact for the same invocation. */\n  assert( isSaveLeft==0 || isExact==0 );\n\n  assert( p!=0 && *p1!=0 && *p2!=0 );\n  if( *p1==POS_COLUMN ){ \n    p1++;\n    p1 += fts3GetVarint32(p1, &iCol1);\n  }\n  if( *p2==POS_COLUMN ){ \n    p2++;\n    p2 += fts3GetVarint32(p2, &iCol2);\n  }\n\n  while( 1 ){\n    if( iCol1==iCol2 ){\n      char *pSave = p;\n      sqlite3_int64 iPrev = 0;\n      sqlite3_int64 iPos1 = 0;\n      sqlite3_int64 iPos2 = 0;\n\n      if( iCol1 ){\n        *p++ = POS_COLUMN;\n        p += sqlite3Fts3PutVarint(p, iCol1);\n      }\n\n      assert( *p1!=POS_END && *p1!=POS_COLUMN );\n      assert( *p2!=POS_END && *p2!=POS_COLUMN );\n      fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n      fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n\n      while( 1 ){\n        if( iPos2==iPos1+nToken \n         || (isExact==0 && iPos2>iPos1 && iPos2<=iPos1+nToken) \n        ){\n          sqlite3_int64 iSave;\n          iSave = isSaveLeft ? iPos1 : iPos2;\n          fts3PutDeltaVarint(&p, &iPrev, iSave+2); iPrev -= 2;\n          pSave = 0;\n          assert( p );\n        }\n        if( (!isSaveLeft && iPos2<=(iPos1+nToken)) || iPos2<=iPos1 ){\n          if( (*p2&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;\n        }else{\n          if( (*p1&0xFE)==0 ) break;\n          fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;\n        }\n      }\n\n      if( pSave ){\n        assert( pp && p );\n        p = pSave;\n      }\n\n      fts3ColumnlistCopy(0, &p1);\n      fts3ColumnlistCopy(0, &p2);\n      assert( (*p1&0xFE)==0 && (*p2&0xFE)==0 );\n      if( 0==*p1 || 0==*p2 ) break;\n\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n\n    /* Advance pointer p1 or p2 (whichever corresponds to the smaller of\n    ** iCol1 and iCol2) so that it points to either the 0x00 that marks the\n    ** end of the position list, or the 0x01 that precedes the next \n    ** column-number in the position list. \n    */\n    else if( iCol1<iCol2 ){\n      fts3ColumnlistCopy(0, &p1);\n      if( 0==*p1 ) break;\n      p1++;\n      p1 += fts3GetVarint32(p1, &iCol1);\n    }else{\n      fts3ColumnlistCopy(0, &p2);\n      if( 0==*p2 ) break;\n      p2++;\n      p2 += fts3GetVarint32(p2, &iCol2);\n    }\n  }\n\n  fts3PoslistCopy(0, &p2);\n  fts3PoslistCopy(0, &p1);\n  *pp1 = p1;\n  *pp2 = p2;\n  if( *pp==p ){\n    return 0;\n  }\n  *p++ = 0x00;\n  *pp = p;\n  return 1;\n}\n\n/*\n** Merge two position-lists as required by the NEAR operator. The argument\n** position lists correspond to the left and right phrases of an expression \n** like:\n**\n**     \"phrase 1\" NEAR \"phrase number 2\"\n**\n** Position list *pp1 corresponds to the left-hand side of the NEAR \n** expression and *pp2 to the right. As usual, the indexes in the position \n** lists are the offsets of the last token in each phrase (tokens \"1\" and \"2\" \n** in the example above).\n**\n** The output position list - written to *pp - is a copy of *pp2 with those\n** entries that are not sufficiently NEAR entries in *pp1 removed.\n*/\nstatic int fts3PoslistNearMerge(\n  char **pp,                      /* Output buffer */\n  char *aTmp,                     /* Temporary buffer space */\n  int nRight,                     /* Maximum difference in token positions */\n  int nLeft,                      /* Maximum difference in token positions */\n  char **pp1,                     /* IN/OUT: Left input list */\n  char **pp2                      /* IN/OUT: Right input list */\n){\n  char *p1 = *pp1;\n  char *p2 = *pp2;\n\n  char *pTmp1 = aTmp;\n  char *pTmp2;\n  char *aTmp2;\n  int res = 1;\n\n  fts3PoslistPhraseMerge(&pTmp1, nRight, 0, 0, pp1, pp2);\n  aTmp2 = pTmp2 = pTmp1;\n  *pp1 = p1;\n  *pp2 = p2;\n  fts3PoslistPhraseMerge(&pTmp2, nLeft, 1, 0, pp2, pp1);\n  if( pTmp1!=aTmp && pTmp2!=aTmp2 ){\n    fts3PoslistMerge(pp, &aTmp, &aTmp2);\n  }else if( pTmp1!=aTmp ){\n    fts3PoslistCopy(pp, &aTmp);\n  }else if( pTmp2!=aTmp2 ){\n    fts3PoslistCopy(pp, &aTmp2);\n  }else{\n    res = 0;\n  }\n\n  return res;\n}\n\n/* \n** An instance of this function is used to merge together the (potentially\n** large number of) doclists for each term that matches a prefix query.\n** See function fts3TermSelectMerge() for details.\n*/\ntypedef struct TermSelect TermSelect;\nstruct TermSelect {\n  char *aaOutput[16];             /* Malloc'd output buffers */\n  int anOutput[16];               /* Size each output buffer in bytes */\n};\n\n/*\n** This function is used to read a single varint from a buffer. Parameter\n** pEnd points 1 byte past the end of the buffer. When this function is\n** called, if *pp points to pEnd or greater, then the end of the buffer\n** has been reached. In this case *pp is set to 0 and the function returns.\n**\n** If *pp does not point to or past pEnd, then a single varint is read\n** from *pp. *pp is then set to point 1 byte past the end of the read varint.\n**\n** If bDescIdx is false, the value read is added to *pVal before returning.\n** If it is true, the value read is subtracted from *pVal before this \n** function returns.\n*/\nstatic void fts3GetDeltaVarint3(\n  char **pp,                      /* IN/OUT: Point to read varint from */\n  char *pEnd,                     /* End of buffer */\n  int bDescIdx,                   /* True if docids are descending */\n  sqlite3_int64 *pVal             /* IN/OUT: Integer value */\n){\n  if( *pp>=pEnd ){\n    *pp = 0;\n  }else{\n    sqlite3_int64 iVal;\n    *pp += sqlite3Fts3GetVarint(*pp, &iVal);\n    if( bDescIdx ){\n      *pVal -= iVal;\n    }else{\n      *pVal += iVal;\n    }\n  }\n}\n\n/*\n** This function is used to write a single varint to a buffer. The varint\n** is written to *pp. Before returning, *pp is set to point 1 byte past the\n** end of the value written.\n**\n** If *pbFirst is zero when this function is called, the value written to\n** the buffer is that of parameter iVal. \n**\n** If *pbFirst is non-zero when this function is called, then the value \n** written is either (iVal-*piPrev) (if bDescIdx is zero) or (*piPrev-iVal)\n** (if bDescIdx is non-zero).\n**\n** Before returning, this function always sets *pbFirst to 1 and *piPrev\n** to the value of parameter iVal.\n*/\nstatic void fts3PutDeltaVarint3(\n  char **pp,                      /* IN/OUT: Output pointer */\n  int bDescIdx,                   /* True for descending docids */\n  sqlite3_int64 *piPrev,          /* IN/OUT: Previous value written to list */\n  int *pbFirst,                   /* IN/OUT: True after first int written */\n  sqlite3_int64 iVal              /* Write this value to the list */\n){\n  sqlite3_int64 iWrite;\n  if( bDescIdx==0 || *pbFirst==0 ){\n    iWrite = iVal - *piPrev;\n  }else{\n    iWrite = *piPrev - iVal;\n  }\n  assert( *pbFirst || *piPrev==0 );\n  assert( *pbFirst==0 || iWrite>0 );\n  *pp += sqlite3Fts3PutVarint(*pp, iWrite);\n  *piPrev = iVal;\n  *pbFirst = 1;\n}\n\n\n/*\n** This macro is used by various functions that merge doclists. The two\n** arguments are 64-bit docid values. If the value of the stack variable\n** bDescDoclist is 0 when this macro is invoked, then it returns (i1-i2). \n** Otherwise, (i2-i1).\n**\n** Using this makes it easier to write code that can merge doclists that are\n** sorted in either ascending or descending order.\n*/\n#define DOCID_CMP(i1, i2) ((bDescDoclist?-1:1) * (i1-i2))\n\n/*\n** This function does an \"OR\" merge of two doclists (output contains all\n** positions contained in either argument doclist). If the docids in the \n** input doclists are sorted in ascending order, parameter bDescDoclist\n** should be false. If they are sorted in ascending order, it should be\n** passed a non-zero value.\n**\n** If no error occurs, *paOut is set to point at an sqlite3_malloc'd buffer\n** containing the output doclist and SQLITE_OK is returned. In this case\n** *pnOut is set to the number of bytes in the output doclist.\n**\n** If an error occurs, an SQLite error code is returned. The output values\n** are undefined in this case.\n*/\nstatic int fts3DoclistOrMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  char *a1, int n1,               /* First doclist */\n  char *a2, int n2,               /* Second doclist */\n  char **paOut, int *pnOut        /* OUT: Malloc'd doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *pEnd1 = &a1[n1];\n  char *pEnd2 = &a2[n2];\n  char *p1 = a1;\n  char *p2 = a2;\n  char *p;\n  char *aOut;\n  int bFirstOut = 0;\n\n  *paOut = 0;\n  *pnOut = 0;\n\n  /* Allocate space for the output. Both the input and output doclists\n  ** are delta encoded. If they are in ascending order (bDescDoclist==0),\n  ** then the first docid in each list is simply encoded as a varint. For\n  ** each subsequent docid, the varint stored is the difference between the\n  ** current and previous docid (a positive number - since the list is in\n  ** ascending order).\n  **\n  ** The first docid written to the output is therefore encoded using the \n  ** same number of bytes as it is in whichever of the input lists it is\n  ** read from. And each subsequent docid read from the same input list \n  ** consumes either the same or less bytes as it did in the input (since\n  ** the difference between it and the previous value in the output must\n  ** be a positive value less than or equal to the delta value read from \n  ** the input list). The same argument applies to all but the first docid\n  ** read from the 'other' list. And to the contents of all position lists\n  ** that will be copied and merged from the input to the output.\n  **\n  ** However, if the first docid copied to the output is a negative number,\n  ** then the encoding of the first docid from the 'other' input list may\n  ** be larger in the output than it was in the input (since the delta value\n  ** may be a larger positive integer than the actual docid).\n  **\n  ** The space required to store the output is therefore the sum of the\n  ** sizes of the two inputs, plus enough space for exactly one of the input\n  ** docids to grow. \n  **\n  ** A symetric argument may be made if the doclists are in descending \n  ** order.\n  */\n  aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);\n  if( !aOut ) return SQLITE_NOMEM;\n\n  p = aOut;\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n  while( p1 || p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n\n    if( p2 && p1 && iDiff==0 ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistMerge(&p, &p1, &p2);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( !p2 || (p1 && iDiff<0) ){\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      fts3PoslistCopy(&p, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i2);\n      fts3PoslistCopy(&p, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *paOut = aOut;\n  *pnOut = (int)(p-aOut);\n  assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );\n  return SQLITE_OK;\n}\n\n/*\n** This function does a \"phrase\" merge of two doclists. In a phrase merge,\n** the output contains a copy of each position from the right-hand input\n** doclist for which there is a position in the left-hand input doclist\n** exactly nDist tokens before it.\n**\n** If the docids in the input doclists are sorted in ascending order,\n** parameter bDescDoclist should be false. If they are sorted in ascending \n** order, it should be passed a non-zero value.\n**\n** The right-hand input doclist is overwritten by this function.\n*/\nstatic int fts3DoclistPhraseMerge(\n  int bDescDoclist,               /* True if arguments are desc */\n  int nDist,                      /* Distance from left to right (1=adjacent) */\n  char *aLeft, int nLeft,         /* Left doclist */\n  char **paRight, int *pnRight    /* IN/OUT: Right/output doclist */\n){\n  sqlite3_int64 i1 = 0;\n  sqlite3_int64 i2 = 0;\n  sqlite3_int64 iPrev = 0;\n  char *aRight = *paRight;\n  char *pEnd1 = &aLeft[nLeft];\n  char *pEnd2 = &aRight[*pnRight];\n  char *p1 = aLeft;\n  char *p2 = aRight;\n  char *p;\n  int bFirstOut = 0;\n  char *aOut;\n\n  assert( nDist>0 );\n  if( bDescDoclist ){\n    aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);\n    if( aOut==0 ) return SQLITE_NOMEM;\n  }else{\n    aOut = aRight;\n  }\n  p = aOut;\n\n  fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);\n  fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);\n\n  while( p1 && p2 ){\n    sqlite3_int64 iDiff = DOCID_CMP(i1, i2);\n    if( iDiff==0 ){\n      char *pSave = p;\n      sqlite3_int64 iPrevSave = iPrev;\n      int bFirstOutSave = bFirstOut;\n\n      fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);\n      if( 0==fts3PoslistPhraseMerge(&p, nDist, 0, 1, &p1, &p2) ){\n        p = pSave;\n        iPrev = iPrevSave;\n        bFirstOut = bFirstOutSave;\n      }\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }else if( iDiff<0 ){\n      fts3PoslistCopy(0, &p1);\n      fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);\n    }else{\n      fts3PoslistCopy(0, &p2);\n      fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);\n    }\n  }\n\n  *pnRight = (int)(p - aOut);\n  if( bDescDoclist ){\n    sqlite3_free(aRight);\n    *paRight = aOut;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Argument pList points to a position list nList bytes in size. This\n** function checks to see if the position list contains any entries for\n** a token in position 0 (of any column). If so, it writes argument iDelta\n** to the output buffer pOut, followed by a position list consisting only\n** of the entries from pList at position 0, and terminated by an 0x00 byte.\n** The value returned is the number of bytes written to pOut (if any).\n*/\nSQLITE_PRIVATE int sqlite3Fts3FirstFilter(\n  sqlite3_int64 iDelta,           /* Varint that may be written to pOut */\n  char *pList,                    /* Position list (no 0x00 term) */\n  int nList,                      /* Size of pList in bytes */\n  char *pOut                      /* Write output here */\n){\n  int nOut = 0;\n  int bWritten = 0;               /* True once iDelta has been written */\n  char *p = pList;\n  char *pEnd = &pList[nList];\n\n  if( *p!=0x01 ){\n    if( *p==0x02 ){\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n      pOut[nOut++] = 0x02;\n      bWritten = 1;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n\n  while( p<pEnd ){\n    sqlite3_int64 iCol;\n    p++;\n    p += sqlite3Fts3GetVarint(p, &iCol);\n    if( *p==0x02 ){\n      if( bWritten==0 ){\n        nOut += sqlite3Fts3PutVarint(&pOut[nOut], iDelta);\n        bWritten = 1;\n      }\n      pOut[nOut++] = 0x01;\n      nOut += sqlite3Fts3PutVarint(&pOut[nOut], iCol);\n      pOut[nOut++] = 0x02;\n    }\n    fts3ColumnlistCopy(0, &p);\n  }\n  if( bWritten ){\n    pOut[nOut++] = 0x00;\n  }\n\n  return nOut;\n}\n\n\n/*\n** Merge all doclists in the TermSelect.aaOutput[] array into a single\n** doclist stored in TermSelect.aaOutput[0]. If successful, delete all\n** other doclists (except the aaOutput[0] one) and return SQLITE_OK.\n**\n** If an OOM error occurs, return SQLITE_NOMEM. In this case it is\n** the responsibility of the caller to free any doclists left in the\n** TermSelect.aaOutput[] array.\n*/\nstatic int fts3TermSelectFinishMerge(Fts3Table *p, TermSelect *pTS){\n  char *aOut = 0;\n  int nOut = 0;\n  int i;\n\n  /* Loop through the doclists in the aaOutput[] array. Merge them all\n  ** into a single doclist.\n  */\n  for(i=0; i<SizeofArray(pTS->aaOutput); i++){\n    if( pTS->aaOutput[i] ){\n      if( !aOut ){\n        aOut = pTS->aaOutput[i];\n        nOut = pTS->anOutput[i];\n        pTS->aaOutput[i] = 0;\n      }else{\n        int nNew;\n        char *aNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, \n            pTS->aaOutput[i], pTS->anOutput[i], aOut, nOut, &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aOut);\n          return rc;\n        }\n\n        sqlite3_free(pTS->aaOutput[i]);\n        sqlite3_free(aOut);\n        pTS->aaOutput[i] = 0;\n        aOut = aNew;\n        nOut = nNew;\n      }\n    }\n  }\n\n  pTS->aaOutput[0] = aOut;\n  pTS->anOutput[0] = nOut;\n  return SQLITE_OK;\n}\n\n/*\n** Merge the doclist aDoclist/nDoclist into the TermSelect object passed\n** as the first argument. The merge is an \"OR\" merge (see function\n** fts3DoclistOrMerge() for details).\n**\n** This function is called with the doclist for each term that matches\n** a queried prefix. It merges all these doclists into one, the doclist\n** for the specified prefix. Since there can be a very large number of\n** doclists to merge, the merging is done pair-wise using the TermSelect\n** object.\n**\n** This function returns SQLITE_OK if the merge is successful, or an\n** SQLite error code (SQLITE_NOMEM) if an error occurs.\n*/\nstatic int fts3TermSelectMerge(\n  Fts3Table *p,                   /* FTS table handle */\n  TermSelect *pTS,                /* TermSelect object to merge into */\n  char *aDoclist,                 /* Pointer to doclist */\n  int nDoclist                    /* Size of aDoclist in bytes */\n){\n  if( pTS->aaOutput[0]==0 ){\n    /* If this is the first term selected, copy the doclist to the output\n    ** buffer using memcpy(). \n    **\n    ** Add FTS3_VARINT_MAX bytes of unused space to the end of the \n    ** allocation. This is so as to ensure that the buffer is big enough\n    ** to hold the current doclist AND'd with any other doclist. If the\n    ** doclists are stored in order=ASC order, this padding would not be\n    ** required (since the size of [doclistA AND doclistB] is always less\n    ** than or equal to the size of [doclistA] in that case). But this is\n    ** not true for order=DESC. For example, a doclist containing (1, -1) \n    ** may be smaller than (-1), as in the first example the -1 may be stored\n    ** as a single-byte delta, whereas in the second it must be stored as a\n    ** FTS3_VARINT_MAX byte varint.\n    **\n    ** Similar padding is added in the fts3DoclistOrMerge() function.\n    */\n    pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);\n    pTS->anOutput[0] = nDoclist;\n    if( pTS->aaOutput[0] ){\n      memcpy(pTS->aaOutput[0], aDoclist, nDoclist);\n    }else{\n      return SQLITE_NOMEM;\n    }\n  }else{\n    char *aMerge = aDoclist;\n    int nMerge = nDoclist;\n    int iOut;\n\n    for(iOut=0; iOut<SizeofArray(pTS->aaOutput); iOut++){\n      if( pTS->aaOutput[iOut]==0 ){\n        assert( iOut>0 );\n        pTS->aaOutput[iOut] = aMerge;\n        pTS->anOutput[iOut] = nMerge;\n        break;\n      }else{\n        char *aNew;\n        int nNew;\n\n        int rc = fts3DoclistOrMerge(p->bDescIdx, aMerge, nMerge, \n            pTS->aaOutput[iOut], pTS->anOutput[iOut], &aNew, &nNew\n        );\n        if( rc!=SQLITE_OK ){\n          if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n          return rc;\n        }\n\n        if( aMerge!=aDoclist ) sqlite3_free(aMerge);\n        sqlite3_free(pTS->aaOutput[iOut]);\n        pTS->aaOutput[iOut] = 0;\n  \n        aMerge = aNew;\n        nMerge = nNew;\n        if( (iOut+1)==SizeofArray(pTS->aaOutput) ){\n          pTS->aaOutput[iOut] = aMerge;\n          pTS->anOutput[iOut] = nMerge;\n        }\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Append SegReader object pNew to the end of the pCsr->apSegment[] array.\n*/\nstatic int fts3SegReaderCursorAppend(\n  Fts3MultiSegReader *pCsr, \n  Fts3SegReader *pNew\n){\n  if( (pCsr->nSegment%16)==0 ){\n    Fts3SegReader **apNew;\n    int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);\n    apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);\n    if( !apNew ){\n      sqlite3Fts3SegReaderFree(pNew);\n      return SQLITE_NOMEM;\n    }\n    pCsr->apSegment = apNew;\n  }\n  pCsr->apSegment[pCsr->nSegment++] = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add seg-reader objects to the Fts3MultiSegReader object passed as the\n** 8th argument.\n**\n** This function returns SQLITE_OK if successful, or an SQLite error code\n** otherwise.\n*/\nstatic int fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc = SQLITE_OK;             /* Error code */\n  sqlite3_stmt *pStmt = 0;        /* Statement to iterate through segments */\n  int rc2;                        /* Result of sqlite3_reset() */\n\n  /* If iLevel is less than 0 and this is not a scan, include a seg-reader \n  ** for the pending-terms. If this is a scan, then this call must be being\n  ** made by an fts4aux module, not an FTS table. In this case calling\n  ** Fts3SegReaderPending might segfault, as the data structures used by \n  ** fts4aux are not completely populated. So it's easiest to filter these\n  ** calls out here.  */\n  if( iLevel<0 && p->aIndex ){\n    Fts3SegReader *pSeg = 0;\n    rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);\n    if( rc==SQLITE_OK && pSeg ){\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3AllSegdirs(p, iLangid, iIndex, iLevel, &pStmt);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n      Fts3SegReader *pSeg = 0;\n\n      /* Read the values returned by the SELECT into local variables. */\n      sqlite3_int64 iStartBlock = sqlite3_column_int64(pStmt, 1);\n      sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);\n      sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);\n      int nRoot = sqlite3_column_bytes(pStmt, 4);\n      char const *zRoot = sqlite3_column_blob(pStmt, 4);\n\n      /* If zTerm is not NULL, and this segment is not stored entirely on its\n      ** root node, the range of leaves scanned can be reduced. Do this. */\n      if( iStartBlock && zTerm ){\n        sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);\n        rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);\n        if( rc!=SQLITE_OK ) goto finished;\n        if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;\n      }\n \n      rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, \n          (isPrefix==0 && isScan==0),\n          iStartBlock, iLeavesEndBlock, \n          iEndBlock, zRoot, nRoot, &pSeg\n      );\n      if( rc!=SQLITE_OK ) goto finished;\n      rc = fts3SegReaderCursorAppend(pCsr, pSeg);\n    }\n  }\n\n finished:\n  rc2 = sqlite3_reset(pStmt);\n  if( rc==SQLITE_DONE ) rc = rc2;\n\n  return rc;\n}\n\n/*\n** Set up a cursor object for iterating through a full-text index or a \n** single level therein.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language-id to search */\n  int iIndex,                     /* Index to search (from 0 to p->nIndex-1) */\n  int iLevel,                     /* Level of segments to scan */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  int isScan,                     /* True to scan from zTerm to EOF */\n  Fts3MultiSegReader *pCsr       /* Cursor object to populate */\n){\n  assert( iIndex>=0 && iIndex<p->nIndex );\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n      ||  iLevel==FTS3_SEGCURSOR_PENDING \n      ||  iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );\n  assert( isPrefix==0 || isScan==0 );\n\n  memset(pCsr, 0, sizeof(Fts3MultiSegReader));\n  return fts3SegReaderCursor(\n      p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr\n  );\n}\n\n/*\n** In addition to its current configuration, have the Fts3MultiSegReader\n** passed as the 4th argument also scan the doclist for term zTerm/nTerm.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3SegReaderCursorAddZero(\n  Fts3Table *p,                   /* FTS virtual table handle */\n  int iLangid,\n  const char *zTerm,              /* Term to scan doclist of */\n  int nTerm,                      /* Number of bytes in zTerm */\n  Fts3MultiSegReader *pCsr        /* Fts3MultiSegReader to modify */\n){\n  return fts3SegReaderCursor(p, \n      iLangid, 0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0,pCsr\n  );\n}\n\n/*\n** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,\n** if isPrefix is true, to scan the doclist for all terms for which \n** zTerm/nTerm is a prefix. If successful, return SQLITE_OK and write\n** a pointer to the new Fts3MultiSegReader to *ppSegcsr. Otherwise, return\n** an SQLite error code.\n**\n** It is the responsibility of the caller to free this object by eventually\n** passing it to fts3SegReaderCursorFree() \n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n** Output parameter *ppSegcsr is set to 0 if an error occurs.\n*/\nstatic int fts3TermSegReaderCursor(\n  Fts3Cursor *pCsr,               /* Virtual table cursor handle */\n  const char *zTerm,              /* Term to query for */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int isPrefix,                   /* True for a prefix search */\n  Fts3MultiSegReader **ppSegcsr   /* OUT: Allocated seg-reader cursor */\n){\n  Fts3MultiSegReader *pSegcsr;    /* Object to allocate and return */\n  int rc = SQLITE_NOMEM;          /* Return code */\n\n  pSegcsr = sqlite3_malloc(sizeof(Fts3MultiSegReader));\n  if( pSegcsr ){\n    int i;\n    int bFound = 0;               /* True once an index has been found */\n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n\n    if( isPrefix ){\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 0, 0, pSegcsr\n          );\n          pSegcsr->bLookup = 1;\n        }\n      }\n\n      for(i=1; bFound==0 && i<p->nIndex; i++){\n        if( p->aIndex[i].nPrefix==nTerm+1 ){\n          bFound = 1;\n          rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n              i, FTS3_SEGCURSOR_ALL, zTerm, nTerm, 1, 0, pSegcsr\n          );\n          if( rc==SQLITE_OK ){\n            rc = fts3SegReaderCursorAddZero(\n                p, pCsr->iLangid, zTerm, nTerm, pSegcsr\n            );\n          }\n        }\n      }\n    }\n\n    if( bFound==0 ){\n      rc = sqlite3Fts3SegReaderCursor(p, pCsr->iLangid, \n          0, FTS3_SEGCURSOR_ALL, zTerm, nTerm, isPrefix, 0, pSegcsr\n      );\n      pSegcsr->bLookup = !isPrefix;\n    }\n  }\n\n  *ppSegcsr = pSegcsr;\n  return rc;\n}\n\n/*\n** Free an Fts3MultiSegReader allocated by fts3TermSegReaderCursor().\n*/\nstatic void fts3SegReaderCursorFree(Fts3MultiSegReader *pSegcsr){\n  sqlite3Fts3SegReaderFinish(pSegcsr);\n  sqlite3_free(pSegcsr);\n}\n\n/*\n** This function retrieves the doclist for the specified term (or term\n** prefix) from the database.\n*/\nstatic int fts3TermSelect(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3PhraseToken *pTok,          /* Token to query for */\n  int iColumn,                    /* Column to query (or -ve for all columns) */\n  int *pnOut,                     /* OUT: Size of buffer at *ppOut */\n  char **ppOut                    /* OUT: Malloced result buffer */\n){\n  int rc;                         /* Return code */\n  Fts3MultiSegReader *pSegcsr;    /* Seg-reader cursor for this term */\n  TermSelect tsc;                 /* Object for pair-wise doclist merging */\n  Fts3SegFilter filter;           /* Segment term filter configuration */\n\n  pSegcsr = pTok->pSegcsr;\n  memset(&tsc, 0, sizeof(TermSelect));\n\n  filter.flags = FTS3_SEGMENT_IGNORE_EMPTY | FTS3_SEGMENT_REQUIRE_POS\n        | (pTok->isPrefix ? FTS3_SEGMENT_PREFIX : 0)\n        | (pTok->bFirst ? FTS3_SEGMENT_FIRST : 0)\n        | (iColumn<p->nColumn ? FTS3_SEGMENT_COLUMN_FILTER : 0);\n  filter.iCol = iColumn;\n  filter.zTerm = pTok->z;\n  filter.nTerm = pTok->n;\n\n  rc = sqlite3Fts3SegReaderStart(p, pSegcsr, &filter);\n  while( SQLITE_OK==rc\n      && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pSegcsr)) \n  ){\n    rc = fts3TermSelectMerge(p, &tsc, pSegcsr->aDoclist, pSegcsr->nDoclist);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3TermSelectFinishMerge(p, &tsc);\n  }\n  if( rc==SQLITE_OK ){\n    *ppOut = tsc.aaOutput[0];\n    *pnOut = tsc.anOutput[0];\n  }else{\n    int i;\n    for(i=0; i<SizeofArray(tsc.aaOutput); i++){\n      sqlite3_free(tsc.aaOutput[i]);\n    }\n  }\n\n  fts3SegReaderCursorFree(pSegcsr);\n  pTok->pSegcsr = 0;\n  return rc;\n}\n\n/*\n** This function counts the total number of docids in the doclist stored\n** in buffer aList[], size nList bytes.\n**\n** If the isPoslist argument is true, then it is assumed that the doclist\n** contains a position-list following each docid. Otherwise, it is assumed\n** that the doclist is simply a list of docids stored as delta encoded \n** varints.\n*/\nstatic int fts3DoclistCountDocids(char *aList, int nList){\n  int nDoc = 0;                   /* Return value */\n  if( aList ){\n    char *aEnd = &aList[nList];   /* Pointer to one byte after EOF */\n    char *p = aList;              /* Cursor */\n    while( p<aEnd ){\n      nDoc++;\n      while( (*p++)&0x80 );     /* Skip docid varint */\n      fts3PoslistCopy(0, &p);   /* Skip over position list */\n    }\n  }\n\n  return nDoc;\n}\n\n/*\n** Advance the cursor to the next row in the %_content table that\n** matches the search criteria.  For a MATCH search, this will be\n** the next row that matches. For a full-table scan, this will be\n** simply the next row in the %_content table.  For a docid lookup,\n** this routine simply sets the EOF flag.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts3EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts3NextMethod(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n  if( pCsr->eSearch==FTS3_DOCID_SEARCH || pCsr->eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( SQLITE_ROW!=sqlite3_step(pCsr->pStmt) ){\n      pCsr->isEof = 1;\n      rc = sqlite3_reset(pCsr->pStmt);\n    }else{\n      pCsr->iPrevId = sqlite3_column_int64(pCsr->pStmt, 0);\n      rc = SQLITE_OK;\n    }\n  }else{\n    rc = fts3EvalNext((Fts3Cursor *)pCursor);\n  }\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/*\n** The following are copied from sqliteInt.h.\n**\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** If the numeric type of argument pVal is \"integer\", then return it\n** converted to a 64-bit signed integer. Otherwise, return a copy of\n** the second parameter, iDefault.\n*/\nstatic sqlite3_int64 fts3DocidRange(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n**\n** If idxNum==FTS3_FULLSCAN_SEARCH then do a full table scan against\n** the %_content table.\n**\n** If idxNum==FTS3_DOCID_SEARCH then do a docid lookup for a single entry\n** in the %_content table.\n**\n** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index.  The\n** column on the left-hand side of the MATCH operator is column\n** number idxNum-FTS3_FULLTEXT_SEARCH, 0 indexed.  argv[0] is the right-hand\n** side of the MATCH operator.\n*/\nstatic int fts3FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_OK;\n  char *zSql;                     /* SQL statement used to access %_content */\n  int eSearch;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n  Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;\n\n  sqlite3_value *pCons = 0;       /* The MATCH or rowid constraint, if any */\n  sqlite3_value *pLangid = 0;     /* The \"langid = ?\" constraint, if any */\n  sqlite3_value *pDocidGe = 0;    /* The \"docid >= ?\" constraint, if any */\n  sqlite3_value *pDocidLe = 0;    /* The \"docid <= ?\" constraint, if any */\n  int iIdx;\n\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  eSearch = (idxNum & 0x0000FFFF);\n  assert( eSearch>=0 && eSearch<=(FTS3_FULLTEXT_SEARCH+p->nColumn) );\n  assert( p->pSegments==0 );\n\n  /* Collect arguments into local variables */\n  iIdx = 0;\n  if( eSearch!=FTS3_FULLSCAN_SEARCH ) pCons = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_LANGID ) pLangid = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++];\n  if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++];\n  assert( iIdx==nVal );\n\n  /* In case the cursor has been used before, clear it now. */\n  fts3ClearCursor(pCsr);\n\n  /* Set the lower and upper bounds on docids to return */\n  pCsr->iMinDocid = fts3DocidRange(pDocidGe, SMALLEST_INT64);\n  pCsr->iMaxDocid = fts3DocidRange(pDocidLe, LARGEST_INT64);\n\n  if( idxStr ){\n    pCsr->bDesc = (idxStr[0]=='D');\n  }else{\n    pCsr->bDesc = p->bDescIdx;\n  }\n  pCsr->eSearch = (i16)eSearch;\n\n  if( eSearch!=FTS3_DOCID_SEARCH && eSearch!=FTS3_FULLSCAN_SEARCH ){\n    int iCol = eSearch-FTS3_FULLTEXT_SEARCH;\n    const char *zQuery = (const char *)sqlite3_value_text(pCons);\n\n    if( zQuery==0 && sqlite3_value_type(pCons)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n\n    pCsr->iLangid = 0;\n    if( pLangid ) pCsr->iLangid = sqlite3_value_int(pLangid);\n\n    assert( p->base.zErrMsg==0 );\n    rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,\n        p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr, \n        &p->base.zErrMsg\n    );\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    rc = fts3EvalStart(pCsr);\n    sqlite3Fts3SegmentsClose(p);\n    if( rc!=SQLITE_OK ) return rc;\n    pCsr->pNextId = pCsr->aDoclist;\n    pCsr->iPrevId = 0;\n  }\n\n  /* Compile a SELECT statement for this cursor. For a full-table-scan, the\n  ** statement loops through all rows of the %_content table. For a\n  ** full-text query or docid lookup, the statement retrieves a single\n  ** row by docid.\n  */\n  if( eSearch==FTS3_FULLSCAN_SEARCH ){\n    if( pDocidGe || pDocidLe ){\n      zSql = sqlite3_mprintf(\n          \"SELECT %s WHERE rowid BETWEEN %lld AND %lld ORDER BY rowid %s\",\n          p->zReadExprlist, pCsr->iMinDocid, pCsr->iMaxDocid,\n          (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }else{\n      zSql = sqlite3_mprintf(\"SELECT %s ORDER BY rowid %s\", \n          p->zReadExprlist, (pCsr->bDesc ? \"DESC\" : \"ASC\")\n      );\n    }\n    if( zSql ){\n      rc = sqlite3_prepare_v3(p->db,zSql,-1,SQLITE_PREPARE_PERSISTENT,&pCsr->pStmt,0);\n      sqlite3_free(zSql);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }else if( eSearch==FTS3_DOCID_SEARCH ){\n    rc = fts3CursorSeekStmt(pCsr);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons);\n    }\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  return fts3NextMethod(pCursor);\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts3EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Cursor *pCsr = (Fts3Cursor*)pCursor;\n  if( pCsr->isEof ){\n    fts3ClearCursor(pCsr);\n    pCsr->isEof = 1;\n  }\n  return pCsr->isEof;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts3\n** exposes %_content.docid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts3RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  *pRowid = pCsr->iPrevId;\n  return SQLITE_OK;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n**\n** If:\n**\n**   (iCol <  p->nColumn)   -> The value of the iCol'th user column.\n**   (iCol == p->nColumn)   -> Magic column with the same name as the table.\n**   (iCol == p->nColumn+1) -> Docid column\n**   (iCol == p->nColumn+2) -> Langid column\n*/\nstatic int fts3ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Cursor *pCsr = (Fts3Cursor *) pCursor;\n  Fts3Table *p = (Fts3Table *)pCursor->pVtab;\n\n  /* The column value supplied by SQLite must be in range. */\n  assert( iCol>=0 && iCol<=p->nColumn+2 );\n\n  switch( iCol-p->nColumn ){\n    case 0:\n      /* The special 'table-name' column */\n      sqlite3_result_pointer(pCtx, pCsr, \"fts3cursor\", 0);\n      break;\n\n    case 1:\n      /* The docid column */\n      sqlite3_result_int64(pCtx, pCsr->iPrevId);\n      break;\n\n    case 2:\n      if( pCsr->pExpr ){\n        sqlite3_result_int64(pCtx, pCsr->iLangid);\n        break;\n      }else if( p->zLanguageid==0 ){\n        sqlite3_result_int(pCtx, 0);\n        break;\n      }else{\n        iCol = p->nColumn;\n        /* fall-through */\n      }\n\n    default:\n      /* A user column. Or, if this is a full-table scan, possibly the\n      ** language-id column. Seek the cursor. */\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){\n        sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n      }\n      break;\n  }\n\n  assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 );\n  return rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n*/\nstatic int fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  return sqlite3Fts3UpdateMethod(pVtab, nArg, apVal, pRowid);\n}\n\n/*\n** Implementation of xSync() method. Flush the contents of the pending-terms\n** hash-table to the database.\n*/\nstatic int fts3SyncMethod(sqlite3_vtab *pVtab){\n\n  /* Following an incremental-merge operation, assuming that the input\n  ** segments are not completely consumed (the usual case), they are updated\n  ** in place to remove the entries that have already been merged. This\n  ** involves updating the leaf block that contains the smallest unmerged\n  ** entry and each block (if any) between the leaf and the root node. So\n  ** if the height of the input segment b-trees is N, and input segments\n  ** are merged eight at a time, updating the input segments at the end\n  ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually\n  ** small - often between 0 and 2. So the overhead of the incremental\n  ** merge is somewhere between 8 and 24 blocks. To avoid this overhead\n  ** dwarfing the actual productive work accomplished, the incremental merge\n  ** is only attempted if it will write at least 64 leaf blocks. Hence\n  ** nMinMerge.\n  **\n  ** Of course, updating the input segments also involves deleting a bunch\n  ** of blocks from the segments table. But this is not considered overhead\n  ** as it would also be required by a crisis-merge that used the same input \n  ** segments.\n  */\n  const u32 nMinMerge = 64;       /* Minimum amount of incr-merge work to do */\n\n  Fts3Table *p = (Fts3Table*)pVtab;\n  int rc;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->db);\n\n  rc = sqlite3Fts3PendingTermsFlush(p);\n  if( rc==SQLITE_OK \n   && p->nLeafAdd>(nMinMerge/16) \n   && p->nAutoincrmerge && p->nAutoincrmerge!=0xff\n  ){\n    int mxLevel = 0;              /* Maximum relative level value in db */\n    int A;                        /* Incr-merge parameter A */\n\n    rc = sqlite3Fts3MaxLevel(p, &mxLevel);\n    assert( rc==SQLITE_OK || mxLevel==0 );\n    A = p->nLeafAdd * mxLevel;\n    A += (A/2);\n    if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);\n  }\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3_set_last_insert_rowid(p->db, iLastRowid);\n  return rc;\n}\n\n/*\n** If it is currently unknown whether or not the FTS table has an %_stat\n** table (if p->bHasStat==2), attempt to determine this (set p->bHasStat\n** to 0 or 1). Return SQLITE_OK if successful, or an SQLite error code\n** if an error occurs.\n*/\nstatic int fts3SetHasStat(Fts3Table *p){\n  int rc = SQLITE_OK;\n  if( p->bHasStat==2 ){\n    char *zTbl = sqlite3_mprintf(\"%s_stat\", p->zName);\n    if( zTbl ){\n      int res = sqlite3_table_column_metadata(p->db, p->zDb, zTbl, 0,0,0,0,0,0);\n      sqlite3_free(zTbl);\n      p->bHasStat = (res==SQLITE_OK);\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts3BeginMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(pVtab);\n  assert( p->pSegments==0 );\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=1 );\n  TESTONLY( p->inTransaction = 1 );\n  TESTONLY( p->mxSavepoint = -1; );\n  p->nLeafAdd = 0;\n  return fts3SetHasStat(p);\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts3SyncMethod().\n*/\nstatic int fts3CommitMethod(sqlite3_vtab *pVtab){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(pVtab);\n  assert( p->nPendingData==0 );\n  assert( p->inTransaction!=0 );\n  assert( p->pSegments==0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts3RollbackMethod(sqlite3_vtab *pVtab){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  sqlite3Fts3PendingTermsClear(p);\n  assert( p->inTransaction!=0 );\n  TESTONLY( p->inTransaction = 0 );\n  TESTONLY( p->mxSavepoint = -1; );\n  return SQLITE_OK;\n}\n\n/*\n** When called, *ppPoslist must point to the byte immediately following the\n** end of a position-list. i.e. ( (*ppPoslist)[-1]==POS_END ). This function\n** moves *ppPoslist so that it instead points to the first byte of the\n** same position list.\n*/\nstatic void fts3ReversePoslist(char *pStart, char **ppPoslist){\n  char *p = &(*ppPoslist)[-2];\n  char c = 0;\n\n  /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */\n  while( p>pStart && (c=*p--)==0 );\n\n  /* Search backwards for a varint with value zero (the end of the previous \n  ** poslist). This is an 0x00 byte preceded by some byte that does not\n  ** have the 0x80 bit set.  */\n  while( p>pStart && (*p & 0x80) | c ){ \n    c = *p--; \n  }\n  assert( p==pStart || c==0 );\n\n  /* At this point p points to that preceding byte without the 0x80 bit\n  ** set. So to find the start of the poslist, skip forward 2 bytes then\n  ** over a varint. \n  **\n  ** Normally. The other case is that p==pStart and the poslist to return\n  ** is the first in the doclist. In this case do not skip forward 2 bytes.\n  ** The second part of the if condition (c==0 && *ppPoslist>&p[2])\n  ** is required for cases where the first byte of a doclist and the\n  ** doclist is empty. For example, if the first docid is 10, a doclist\n  ** that begins with:\n  **\n  **   0x0A 0x00 <next docid delta varint>\n  */\n  if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; }\n  while( *p++&0x80 );\n  *ppPoslist = p;\n}\n\n/*\n** Helper function used by the implementation of the overloaded snippet(),\n** offsets() and optimize() SQL functions.\n**\n** If the value passed as the third argument is a blob of size\n** sizeof(Fts3Cursor*), then the blob contents are copied to the \n** output variable *ppCsr and SQLITE_OK is returned. Otherwise, an error\n** message is written to context pContext and SQLITE_ERROR returned. The\n** string passed via zFunc is used as part of the error message.\n*/\nstatic int fts3FunctionArg(\n  sqlite3_context *pContext,      /* SQL function call context */\n  const char *zFunc,              /* Function name */\n  sqlite3_value *pVal,            /* argv[0] passed to function */\n  Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */\n){\n  int rc;\n  *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, \"fts3cursor\");\n  if( (*ppCsr)!=0 ){\n    rc = SQLITE_OK;\n  }else{\n    char *zErr = sqlite3_mprintf(\"illegal first argument to %s\", zFunc);\n    sqlite3_result_error(pContext, zErr, -1);\n    sqlite3_free(zErr);\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the snippet() function for FTS3\n*/\nstatic void fts3SnippetFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of apVal[] array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  const char *zStart = \"<b>\";\n  const char *zEnd = \"</b>\";\n  const char *zEllipsis = \"<b>...</b>\";\n  int iCol = -1;\n  int nToken = 15;                /* Default number of tokens in snippet */\n\n  /* There must be at least one argument passed to this function (otherwise\n  ** the non-overloaded version would have been called instead of this one).\n  */\n  assert( nVal>=1 );\n\n  if( nVal>6 ){\n    sqlite3_result_error(pContext, \n        \"wrong number of arguments to function snippet()\", -1);\n    return;\n  }\n  if( fts3FunctionArg(pContext, \"snippet\", apVal[0], &pCsr) ) return;\n\n  switch( nVal ){\n    case 6: nToken = sqlite3_value_int(apVal[5]);\n    case 5: iCol = sqlite3_value_int(apVal[4]);\n    case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);\n    case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);\n    case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);\n  }\n  if( !zEllipsis || !zEnd || !zStart ){\n    sqlite3_result_error_nomem(pContext);\n  }else if( nToken==0 ){\n    sqlite3_result_text(pContext, \"\", -1, SQLITE_STATIC);\n  }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);\n  }\n}\n\n/*\n** Implementation of the offsets() function for FTS3\n*/\nstatic void fts3OffsetsFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"offsets\", apVal[0], &pCsr) ) return;\n  assert( pCsr );\n  if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){\n    sqlite3Fts3Offsets(pContext, pCsr);\n  }\n}\n\n/* \n** Implementation of the special optimize() function for FTS3. This \n** function merges all segments in the database to a single segment.\n** Example usage is:\n**\n**   SELECT optimize(t) FROM t LIMIT 1;\n**\n** where 't' is the name of an FTS3 table.\n*/\nstatic void fts3OptimizeFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  int rc;                         /* Return code */\n  Fts3Table *p;                   /* Virtual table handle */\n  Fts3Cursor *pCursor;            /* Cursor handle passed through apVal[0] */\n\n  UNUSED_PARAMETER(nVal);\n\n  assert( nVal==1 );\n  if( fts3FunctionArg(pContext, \"optimize\", apVal[0], &pCursor) ) return;\n  p = (Fts3Table *)pCursor->base.pVtab;\n  assert( p );\n\n  rc = sqlite3Fts3Optimize(p);\n\n  switch( rc ){\n    case SQLITE_OK:\n      sqlite3_result_text(pContext, \"Index optimized\", -1, SQLITE_STATIC);\n      break;\n    case SQLITE_DONE:\n      sqlite3_result_text(pContext, \"Index already optimal\", -1, SQLITE_STATIC);\n      break;\n    default:\n      sqlite3_result_error_code(pContext, rc);\n      break;\n  }\n}\n\n/*\n** Implementation of the matchinfo() function for FTS3\n*/\nstatic void fts3MatchinfoFunc(\n  sqlite3_context *pContext,      /* SQLite function call context */\n  int nVal,                       /* Size of argument array */\n  sqlite3_value **apVal           /* Array of arguments */\n){\n  Fts3Cursor *pCsr;               /* Cursor handle passed through apVal[0] */\n  assert( nVal==1 || nVal==2 );\n  if( SQLITE_OK==fts3FunctionArg(pContext, \"matchinfo\", apVal[0], &pCsr) ){\n    const char *zArg = 0;\n    if( nVal>1 ){\n      zArg = (const char *)sqlite3_value_text(apVal[1]);\n    }\n    sqlite3Fts3Matchinfo(pContext, pCsr, zArg);\n  }\n}\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts3FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* Unused */\n){\n  struct Overloaded {\n    const char *zName;\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aOverload[] = {\n    { \"snippet\", fts3SnippetFunc },\n    { \"offsets\", fts3OffsetsFunc },\n    { \"optimize\", fts3OptimizeFunc },\n    { \"matchinfo\", fts3MatchinfoFunc },\n  };\n  int i;                          /* Iterator variable */\n\n  UNUSED_PARAMETER(pVtab);\n  UNUSED_PARAMETER(nArg);\n  UNUSED_PARAMETER(ppArg);\n\n  for(i=0; i<SizeofArray(aOverload); i++){\n    if( strcmp(zName, aOverload[i].zName)==0 ){\n      *pxFunc = aOverload[i].xFunc;\n      return 1;\n    }\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS3 xRename method. Rename an fts3 table.\n*/\nstatic int fts3RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  sqlite3 *db = p->db;            /* Database connection */\n  int rc;                         /* Return Code */\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  rc = fts3SetHasStat(p);\n  \n  /* As it happens, the pending terms table is always empty here. This is\n  ** because an \"ALTER TABLE RENAME TABLE\" statement inside a transaction \n  ** always opens a savepoint transaction. And the xSavepoint() method \n  ** flushes the pending terms table. But leave the (no-op) call to\n  ** PendingTermsFlush() in in case that changes.\n  */\n  assert( p->nPendingData==0 );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3PendingTermsFlush(p);\n  }\n\n  if( p->zContentTbl==0 ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_content'  RENAME TO '%q_content';\",\n      p->zDb, p->zName, zName\n    );\n  }\n\n  if( p->bHasDocsize ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_docsize'  RENAME TO '%q_docsize';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  if( p->bHasStat ){\n    fts3DbExec(&rc, db,\n      \"ALTER TABLE %Q.'%q_stat'  RENAME TO '%q_stat';\",\n      p->zDb, p->zName, zName\n    );\n  }\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';\",\n    p->zDb, p->zName, zName\n  );\n  fts3DbExec(&rc, db,\n    \"ALTER TABLE %Q.'%q_segdir'   RENAME TO '%q_segdir';\",\n    p->zDb, p->zName, zName\n  );\n  return rc;\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( ((Fts3Table *)pVtab)->inTransaction );\n  assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );\n  TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );\n  if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){\n    rc = fts3SyncMethod(pVtab);\n  }\n  return rc;\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts3ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );\n  UNUSED_PARAMETER(iSavepoint);\n  UNUSED_PARAMETER(pVtab);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint-1 );\n  return SQLITE_OK;\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts3Table *p = (Fts3Table*)pVtab;\n  UNUSED_PARAMETER(iSavepoint);\n  assert( p->inTransaction );\n  assert( p->mxSavepoint >= iSavepoint );\n  TESTONLY( p->mxSavepoint = iSavepoint );\n  sqlite3Fts3PendingTermsClear(p);\n  return SQLITE_OK;\n}\n\nstatic const sqlite3_module fts3Module = {\n  /* iVersion      */ 2,\n  /* xCreate       */ fts3CreateMethod,\n  /* xConnect      */ fts3ConnectMethod,\n  /* xBestIndex    */ fts3BestIndexMethod,\n  /* xDisconnect   */ fts3DisconnectMethod,\n  /* xDestroy      */ fts3DestroyMethod,\n  /* xOpen         */ fts3OpenMethod,\n  /* xClose        */ fts3CloseMethod,\n  /* xFilter       */ fts3FilterMethod,\n  /* xNext         */ fts3NextMethod,\n  /* xEof          */ fts3EofMethod,\n  /* xColumn       */ fts3ColumnMethod,\n  /* xRowid        */ fts3RowidMethod,\n  /* xUpdate       */ fts3UpdateMethod,\n  /* xBegin        */ fts3BeginMethod,\n  /* xSync         */ fts3SyncMethod,\n  /* xCommit       */ fts3CommitMethod,\n  /* xRollback     */ fts3RollbackMethod,\n  /* xFindFunction */ fts3FindFunctionMethod,\n  /* xRename */       fts3RenameMethod,\n  /* xSavepoint    */ fts3SavepointMethod,\n  /* xRelease      */ fts3ReleaseMethod,\n  /* xRollbackTo   */ fts3RollbackToMethod,\n};\n\n/*\n** This function is registered as the module destructor (called when an\n** FTS3 enabled database connection is closed). It frees the memory\n** allocated for the tokenizer hash table.\n*/\nstatic void hashDestroy(void *p){\n  Fts3Hash *pHash = (Fts3Hash *)p;\n  sqlite3Fts3HashClear(pHash);\n  sqlite3_free(pHash);\n}\n\n/*\n** The fts3 built-in tokenizers - \"simple\", \"porter\" and \"icu\"- are \n** implemented in files fts3_tokenizer1.c, fts3_porter.c and fts3_icu.c\n** respectively. The following three forward declarations are for functions\n** declared in these files used to retrieve the respective implementations.\n**\n** Calling sqlite3Fts3SimpleTokenizerModule() sets the value pointed\n** to by the argument to point to the \"simple\" tokenizer implementation.\n** And so on.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule);\n#endif\n#ifdef SQLITE_ENABLE_ICU\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n#endif\n\n/*\n** Initialize the fts3 extension. If this extension is built as part\n** of the sqlite library, then this function is called directly by\n** SQLite. If fts3 is built as a dynamically loadable extension, this\n** function is called by the sqlite3_extension_init() entry point.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  Fts3Hash *pHash = 0;\n  const sqlite3_tokenizer_module *pSimple = 0;\n  const sqlite3_tokenizer_module *pPorter = 0;\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  const sqlite3_tokenizer_module *pUnicode = 0;\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  const sqlite3_tokenizer_module *pIcu = 0;\n  sqlite3Fts3IcuTokenizerModule(&pIcu);\n#endif\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n  sqlite3Fts3UnicodeTokenizer(&pUnicode);\n#endif\n\n#ifdef SQLITE_TEST\n  rc = sqlite3Fts3InitTerm(db);\n  if( rc!=SQLITE_OK ) return rc;\n#endif\n\n  rc = sqlite3Fts3InitAux(db);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3Fts3SimpleTokenizerModule(&pSimple);\n  sqlite3Fts3PorterTokenizerModule(&pPorter);\n\n  /* Allocate and initialize the hash-table used to store tokenizers. */\n  pHash = sqlite3_malloc(sizeof(Fts3Hash));\n  if( !pHash ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n  }\n\n  /* Load the built-in tokenizers into the hash table */\n  if( rc==SQLITE_OK ){\n    if( sqlite3Fts3HashInsert(pHash, \"simple\", 7, (void *)pSimple)\n     || sqlite3Fts3HashInsert(pHash, \"porter\", 7, (void *)pPorter) \n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n     || sqlite3Fts3HashInsert(pHash, \"unicode61\", 10, (void *)pUnicode) \n#endif\n#ifdef SQLITE_ENABLE_ICU\n     || (pIcu && sqlite3Fts3HashInsert(pHash, \"icu\", 4, (void *)pIcu))\n#endif\n    ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n#ifdef SQLITE_TEST\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3ExprInitTestInterface(db);\n  }\n#endif\n\n  /* Create the virtual table wrapper around the hash-table and overload \n  ** the four scalar functions. If this is successful, register the\n  ** module with sqlite.\n  */\n  if( SQLITE_OK==rc \n   && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, \"fts3_tokenizer\"))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"snippet\", -1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"offsets\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 1))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"matchinfo\", 2))\n   && SQLITE_OK==(rc = sqlite3_overload_function(db, \"optimize\", 1))\n  ){\n    rc = sqlite3_create_module_v2(\n        db, \"fts3\", &fts3Module, (void *)pHash, hashDestroy\n    );\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_module_v2(\n          db, \"fts4\", &fts3Module, (void *)pHash, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3InitTok(db, (void *)pHash);\n    }\n    return rc;\n  }\n\n\n  /* An error has occurred. Delete the hash table and return the error code. */\n  assert( rc!=SQLITE_OK );\n  if( pHash ){\n    sqlite3Fts3HashClear(pHash);\n    sqlite3_free(pHash);\n  }\n  return rc;\n}\n\n/*\n** Allocate an Fts3MultiSegReader for each token in the expression headed\n** by pExpr. \n**\n** An Fts3SegReader object is a cursor that can seek or scan a range of\n** entries within a single segment b-tree. An Fts3MultiSegReader uses multiple\n** Fts3SegReader objects internally to provide an interface to seek or scan\n** within the union of all segments of a b-tree. Hence the name.\n**\n** If the allocated Fts3MultiSegReader just seeks to a single entry in a\n** segment b-tree (if the term is not a prefix or it is a prefix for which\n** there exists prefix b-tree of the right length) then it may be traversed\n** and merged incrementally. Otherwise, it has to be merged into an in-memory \n** doclist and then traversed.\n*/\nstatic void fts3EvalAllocateReaders(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Allocate readers for this expression */\n  int *pnToken,                   /* OUT: Total number of tokens in phrase. */\n  int *pnOr,                      /* OUT: Total number of OR nodes in expr. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int i;\n      int nToken = pExpr->pPhrase->nToken;\n      *pnToken += nToken;\n      for(i=0; i<nToken; i++){\n        Fts3PhraseToken *pToken = &pExpr->pPhrase->aToken[i];\n        int rc = fts3TermSegReaderCursor(pCsr, \n            pToken->z, pToken->n, pToken->isPrefix, &pToken->pSegcsr\n        );\n        if( rc!=SQLITE_OK ){\n          *pRc = rc;\n          return;\n        }\n      }\n      assert( pExpr->pPhrase->iDoclistToken==0 );\n      pExpr->pPhrase->iDoclistToken = -1;\n    }else{\n      *pnOr += (pExpr->eType==FTSQUERY_OR);\n      fts3EvalAllocateReaders(pCsr, pExpr->pLeft, pnToken, pnOr, pRc);\n      fts3EvalAllocateReaders(pCsr, pExpr->pRight, pnToken, pnOr, pRc);\n    }\n  }\n}\n\n/*\n** Arguments pList/nList contain the doclist for token iToken of phrase p.\n** It is merged into the main doclist stored in p->doclist.aAll/nAll.\n**\n** This function assumes that pList points to a buffer allocated using\n** sqlite3_malloc(). This function takes responsibility for eventually\n** freeing the buffer.\n**\n** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.\n*/\nstatic int fts3EvalPhraseMergeToken(\n  Fts3Table *pTab,                /* FTS Table pointer */\n  Fts3Phrase *p,                  /* Phrase to merge pList/nList into */\n  int iToken,                     /* Token pList/nList corresponds to */\n  char *pList,                    /* Pointer to doclist */\n  int nList                       /* Number of bytes in pList */\n){\n  int rc = SQLITE_OK;\n  assert( iToken!=p->iDoclistToken );\n\n  if( pList==0 ){\n    sqlite3_free(p->doclist.aAll);\n    p->doclist.aAll = 0;\n    p->doclist.nAll = 0;\n  }\n\n  else if( p->iDoclistToken<0 ){\n    p->doclist.aAll = pList;\n    p->doclist.nAll = nList;\n  }\n\n  else if( p->doclist.aAll==0 ){\n    sqlite3_free(pList);\n  }\n\n  else {\n    char *pLeft;\n    char *pRight;\n    int nLeft;\n    int nRight;\n    int nDiff;\n\n    if( p->iDoclistToken<iToken ){\n      pLeft = p->doclist.aAll;\n      nLeft = p->doclist.nAll;\n      pRight = pList;\n      nRight = nList;\n      nDiff = iToken - p->iDoclistToken;\n    }else{\n      pRight = p->doclist.aAll;\n      nRight = p->doclist.nAll;\n      pLeft = pList;\n      nLeft = nList;\n      nDiff = p->iDoclistToken - iToken;\n    }\n\n    rc = fts3DoclistPhraseMerge(\n        pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight\n    );\n    sqlite3_free(pLeft);\n    p->doclist.aAll = pRight;\n    p->doclist.nAll = nRight;\n  }\n\n  if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;\n  return rc;\n}\n\n/*\n** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist\n** does not take deferred tokens into account.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseLoad(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p                   /* Phrase object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int iToken;\n  int rc = SQLITE_OK;\n\n  for(iToken=0; rc==SQLITE_OK && iToken<p->nToken; iToken++){\n    Fts3PhraseToken *pToken = &p->aToken[iToken];\n    assert( pToken->pDeferred==0 || pToken->pSegcsr==0 );\n\n    if( pToken->pSegcsr ){\n      int nThis = 0;\n      char *pThis = 0;\n      rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);\n      }\n    }\n    assert( pToken->pSegcsr==0 );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called on each phrase after the position lists for\n** any deferred tokens have been loaded into memory. It updates the phrases\n** current position list to include only those positions that are really\n** instances of the phrase (after considering deferred tokens). If this\n** means that the phrase does not appear in the current row, doclist.pList\n** and doclist.nList are both zeroed.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){\n  int iToken;                     /* Used to iterate through phrase tokens */\n  char *aPoslist = 0;             /* Position list for deferred tokens */\n  int nPoslist = 0;               /* Number of bytes in aPoslist */\n  int iPrev = -1;                 /* Token number of previous deferred token */\n\n  assert( pPhrase->doclist.bFreeList==0 );\n\n  for(iToken=0; iToken<pPhrase->nToken; iToken++){\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    Fts3DeferredToken *pDeferred = pToken->pDeferred;\n\n    if( pDeferred ){\n      char *pList;\n      int nList;\n      int rc = sqlite3Fts3DeferredTokenList(pDeferred, &pList, &nList);\n      if( rc!=SQLITE_OK ) return rc;\n\n      if( pList==0 ){\n        sqlite3_free(aPoslist);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n        return SQLITE_OK;\n\n      }else if( aPoslist==0 ){\n        aPoslist = pList;\n        nPoslist = nList;\n\n      }else{\n        char *aOut = pList;\n        char *p1 = aPoslist;\n        char *p2 = aOut;\n\n        assert( iPrev>=0 );\n        fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);\n        sqlite3_free(aPoslist);\n        aPoslist = pList;\n        nPoslist = (int)(aOut - aPoslist);\n        if( nPoslist==0 ){\n          sqlite3_free(aPoslist);\n          pPhrase->doclist.pList = 0;\n          pPhrase->doclist.nList = 0;\n          return SQLITE_OK;\n        }\n      }\n      iPrev = iToken;\n    }\n  }\n\n  if( iPrev>=0 ){\n    int nMaxUndeferred = pPhrase->iDoclistToken;\n    if( nMaxUndeferred<0 ){\n      pPhrase->doclist.pList = aPoslist;\n      pPhrase->doclist.nList = nPoslist;\n      pPhrase->doclist.iDocid = pCsr->iPrevId;\n      pPhrase->doclist.bFreeList = 1;\n    }else{\n      int nDistance;\n      char *p1;\n      char *p2;\n      char *aOut;\n\n      if( nMaxUndeferred>iPrev ){\n        p1 = aPoslist;\n        p2 = pPhrase->doclist.pList;\n        nDistance = nMaxUndeferred - iPrev;\n      }else{\n        p1 = pPhrase->doclist.pList;\n        p2 = aPoslist;\n        nDistance = iPrev - nMaxUndeferred;\n      }\n\n      aOut = (char *)sqlite3_malloc(nPoslist+8);\n      if( !aOut ){\n        sqlite3_free(aPoslist);\n        return SQLITE_NOMEM;\n      }\n      \n      pPhrase->doclist.pList = aOut;\n      if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){\n        pPhrase->doclist.bFreeList = 1;\n        pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);\n      }else{\n        sqlite3_free(aOut);\n        pPhrase->doclist.pList = 0;\n        pPhrase->doclist.nList = 0;\n      }\n      sqlite3_free(aPoslist);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Maximum number of tokens a phrase may have to be considered for the\n** incremental doclists strategy.\n*/\n#define MAX_INCR_PHRASE_TOKENS 4\n\n/*\n** This function is called for each Fts3Phrase in a full-text query \n** expression to initialize the mechanism for returning rows. Once this\n** function has been called successfully on an Fts3Phrase, it may be\n** used with fts3EvalPhraseNext() to iterate through the matching docids.\n**\n** If parameter bOptOk is true, then the phrase may (or may not) use the\n** incremental loading strategy. Otherwise, the entire doclist is loaded into\n** memory within this call.\n**\n** SQLITE_OK is returned if no error occurs, otherwise an SQLite error code.\n*/\nstatic int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;             /* Error code */\n  int i;\n\n  /* Determine if doclists may be loaded from disk incrementally. This is\n  ** possible if the bOptOk argument is true, the FTS doclists will be\n  ** scanned in forward order, and the phrase consists of \n  ** MAX_INCR_PHRASE_TOKENS or fewer tokens, none of which are are \"^first\"\n  ** tokens or prefix tokens that cannot use a prefix-index.  */\n  int bHaveIncr = 0;\n  int bIncrOk = (bOptOk \n   && pCsr->bDesc==pTab->bDescIdx \n   && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0\n#ifdef SQLITE_TEST\n   && pTab->bNoIncrDoclist==0\n#endif\n  );\n  for(i=0; bIncrOk==1 && i<p->nToken; i++){\n    Fts3PhraseToken *pToken = &p->aToken[i];\n    if( pToken->bFirst || (pToken->pSegcsr!=0 && !pToken->pSegcsr->bLookup) ){\n      bIncrOk = 0;\n    }\n    if( pToken->pSegcsr ) bHaveIncr = 1;\n  }\n\n  if( bIncrOk && bHaveIncr ){\n    /* Use the incremental approach. */\n    int iCol = (p->iColumn >= pTab->nColumn ? -1 : p->iColumn);\n    for(i=0; rc==SQLITE_OK && i<p->nToken; i++){\n      Fts3PhraseToken *pToken = &p->aToken[i];\n      Fts3MultiSegReader *pSegcsr = pToken->pSegcsr;\n      if( pSegcsr ){\n        rc = sqlite3Fts3MsrIncrStart(pTab, pSegcsr, iCol, pToken->z, pToken->n);\n      }\n    }\n    p->bIncr = 1;\n  }else{\n    /* Load the full doclist for the phrase into memory. */\n    rc = fts3EvalPhraseLoad(pCsr, p);\n    p->bIncr = 0;\n  }\n\n  assert( rc!=SQLITE_OK || p->nToken<1 || p->aToken[0].pSegcsr==0 || p->bIncr );\n  return rc;\n}\n\n/*\n** This function is used to iterate backwards (from the end to start) \n** through doclists. It is used by this module to iterate through phrase\n** doclists in reverse and by the fts3_write.c module to iterate through\n** pending-terms lists when writing to databases with \"order=desc\".\n**\n** The doclist may be sorted in ascending (parameter bDescIdx==0) or \n** descending (parameter bDescIdx==1) order of docid. Regardless, this\n** function iterates from the end of the doclist to the beginning.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistPrev(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  int *pnList,                    /* OUT: List length pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    sqlite3_int64 iDocid = 0;\n    char *pNext = 0;\n    char *pDocid = aDoclist;\n    char *pEnd = &aDoclist[nDoclist];\n    int iMul = 1;\n\n    while( pDocid<pEnd ){\n      sqlite3_int64 iDelta;\n      pDocid += sqlite3Fts3GetVarint(pDocid, &iDelta);\n      iDocid += (iMul * iDelta);\n      pNext = pDocid;\n      fts3PoslistCopy(0, &pDocid);\n      while( pDocid<pEnd && *pDocid==0 ) pDocid++;\n      iMul = (bDescIdx ? -1 : 1);\n    }\n\n    *pnList = (int)(pEnd - pNext);\n    *ppIter = pNext;\n    *piDocid = iDocid;\n  }else{\n    int iMul = (bDescIdx ? -1 : 1);\n    sqlite3_int64 iDelta;\n    fts3GetReverseVarint(&p, aDoclist, &iDelta);\n    *piDocid -= (iMul * iDelta);\n\n    if( p==aDoclist ){\n      *pbEof = 1;\n    }else{\n      char *pSave = p;\n      fts3ReversePoslist(aDoclist, &p);\n      *pnList = (int)(pSave - p);\n    }\n    *ppIter = p;\n  }\n}\n\n/*\n** Iterate forwards through a doclist.\n*/\nSQLITE_PRIVATE void sqlite3Fts3DoclistNext(\n  int bDescIdx,                   /* True if the doclist is desc */\n  char *aDoclist,                 /* Pointer to entire doclist */\n  int nDoclist,                   /* Length of aDoclist in bytes */\n  char **ppIter,                  /* IN/OUT: Iterator pointer */\n  sqlite3_int64 *piDocid,         /* IN/OUT: Docid pointer */\n  u8 *pbEof                       /* OUT: End-of-file flag */\n){\n  char *p = *ppIter;\n\n  assert( nDoclist>0 );\n  assert( *pbEof==0 );\n  assert( p || *piDocid==0 );\n  assert( !p || (p>=aDoclist && p<=&aDoclist[nDoclist]) );\n\n  if( p==0 ){\n    p = aDoclist;\n    p += sqlite3Fts3GetVarint(p, piDocid);\n  }else{\n    fts3PoslistCopy(0, &p);\n    while( p<&aDoclist[nDoclist] && *p==0 ) p++; \n    if( p>=&aDoclist[nDoclist] ){\n      *pbEof = 1;\n    }else{\n      sqlite3_int64 iVar;\n      p += sqlite3Fts3GetVarint(p, &iVar);\n      *piDocid += ((bDescIdx ? -1 : 1) * iVar);\n    }\n  }\n\n  *ppIter = p;\n}\n\n/*\n** Advance the iterator pDL to the next entry in pDL->aAll/nAll. Set *pbEof\n** to true if EOF is reached.\n*/\nstatic void fts3EvalDlPhraseNext(\n  Fts3Table *pTab,\n  Fts3Doclist *pDL,\n  u8 *pbEof\n){\n  char *pIter;                            /* Used to iterate through aAll */\n  char *pEnd = &pDL->aAll[pDL->nAll];     /* 1 byte past end of aAll */\n \n  if( pDL->pNextDocid ){\n    pIter = pDL->pNextDocid;\n  }else{\n    pIter = pDL->aAll;\n  }\n\n  if( pIter>=pEnd ){\n    /* We have already reached the end of this doclist. EOF. */\n    *pbEof = 1;\n  }else{\n    sqlite3_int64 iDelta;\n    pIter += sqlite3Fts3GetVarint(pIter, &iDelta);\n    if( pTab->bDescIdx==0 || pDL->pNextDocid==0 ){\n      pDL->iDocid += iDelta;\n    }else{\n      pDL->iDocid -= iDelta;\n    }\n    pDL->pList = pIter;\n    fts3PoslistCopy(0, &pIter);\n    pDL->nList = (int)(pIter - pDL->pList);\n\n    /* pIter now points just past the 0x00 that terminates the position-\n    ** list for document pDL->iDocid. However, if this position-list was\n    ** edited in place by fts3EvalNearTrim(), then pIter may not actually\n    ** point to the start of the next docid value. The following line deals\n    ** with this case by advancing pIter past the zero-padding added by\n    ** fts3EvalNearTrim().  */\n    while( pIter<pEnd && *pIter==0 ) pIter++;\n\n    pDL->pNextDocid = pIter;\n    assert( pIter>=&pDL->aAll[pDL->nAll] || *pIter );\n    *pbEof = 0;\n  }\n}\n\n/*\n** Helper type used by fts3EvalIncrPhraseNext() and incrPhraseTokenNext().\n*/\ntypedef struct TokenDoclist TokenDoclist;\nstruct TokenDoclist {\n  int bIgnore;\n  sqlite3_int64 iDocid;\n  char *pList;\n  int nList;\n};\n\n/*\n** Token pToken is an incrementally loaded token that is part of a \n** multi-token phrase. Advance it to the next matching document in the\n** database and populate output variable *p with the details of the new\n** entry. Or, if the iterator has reached EOF, set *pbEof to true.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int incrPhraseTokenNext(\n  Fts3Table *pTab,                /* Virtual table handle */\n  Fts3Phrase *pPhrase,            /* Phrase to advance token of */\n  int iToken,                     /* Specific token to advance */\n  TokenDoclist *p,                /* OUT: Docid and doclist for new entry */\n  u8 *pbEof                       /* OUT: True if iterator is at EOF */\n){\n  int rc = SQLITE_OK;\n\n  if( pPhrase->iDoclistToken==iToken ){\n    assert( p->bIgnore==0 );\n    assert( pPhrase->aToken[iToken].pSegcsr==0 );\n    fts3EvalDlPhraseNext(pTab, &pPhrase->doclist, pbEof);\n    p->pList = pPhrase->doclist.pList;\n    p->nList = pPhrase->doclist.nList;\n    p->iDocid = pPhrase->doclist.iDocid;\n  }else{\n    Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];\n    assert( pToken->pDeferred==0 );\n    assert( pToken->pSegcsr || pPhrase->iDoclistToken>=0 );\n    if( pToken->pSegcsr ){\n      assert( p->bIgnore==0 );\n      rc = sqlite3Fts3MsrIncrNext(\n          pTab, pToken->pSegcsr, &p->iDocid, &p->pList, &p->nList\n      );\n      if( p->pList==0 ) *pbEof = 1;\n    }else{\n      p->bIgnore = 1;\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** The phrase iterator passed as the second argument:\n**\n**   * features at least one token that uses an incremental doclist, and \n**\n**   * does not contain any deferred tokens.\n**\n** Advance it to the next matching documnent in the database and populate\n** the Fts3Doclist.pList and nList fields. \n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n*/\nstatic int fts3EvalIncrPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  u8 bEof = 0;\n\n  /* This is only called if it is guaranteed that the phrase has at least\n  ** one incremental token. In which case the bIncr flag is set. */\n  assert( p->bIncr==1 );\n\n  if( p->nToken==1 ){\n    rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, \n        &pDL->iDocid, &pDL->pList, &pDL->nList\n    );\n    if( pDL->pList==0 ) bEof = 1;\n  }else{\n    int bDescDoclist = pCsr->bDesc;\n    struct TokenDoclist a[MAX_INCR_PHRASE_TOKENS];\n\n    memset(a, 0, sizeof(a));\n    assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );\n    assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );\n\n    while( bEof==0 ){\n      int bMaxSet = 0;\n      sqlite3_int64 iMax = 0;     /* Largest docid for all iterators */\n      int i;                      /* Used to iterate through tokens */\n\n      /* Advance the iterator for each token in the phrase once. */\n      for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){\n        rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n        if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){\n          iMax = a[i].iDocid;\n          bMaxSet = 1;\n        }\n      }\n      assert( rc!=SQLITE_OK || (p->nToken>=1 && a[p->nToken-1].bIgnore==0) );\n      assert( rc!=SQLITE_OK || bMaxSet );\n\n      /* Keep advancing iterators until they all point to the same document */\n      for(i=0; i<p->nToken; i++){\n        while( rc==SQLITE_OK && bEof==0 \n            && a[i].bIgnore==0 && DOCID_CMP(a[i].iDocid, iMax)<0 \n        ){\n          rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);\n          if( DOCID_CMP(a[i].iDocid, iMax)>0 ){\n            iMax = a[i].iDocid;\n            i = 0;\n          }\n        }\n      }\n\n      /* Check if the current entries really are a phrase match */\n      if( bEof==0 ){\n        int nList = 0;\n        int nByte = a[p->nToken-1].nList;\n        char *aDoclist = sqlite3_malloc(nByte+1);\n        if( !aDoclist ) return SQLITE_NOMEM;\n        memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);\n\n        for(i=0; i<(p->nToken-1); i++){\n          if( a[i].bIgnore==0 ){\n            char *pL = a[i].pList;\n            char *pR = aDoclist;\n            char *pOut = aDoclist;\n            int nDist = p->nToken-1-i;\n            int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);\n            if( res==0 ) break;\n            nList = (int)(pOut - aDoclist);\n          }\n        }\n        if( i==(p->nToken-1) ){\n          pDL->iDocid = iMax;\n          pDL->pList = aDoclist;\n          pDL->nList = nList;\n          pDL->bFreeList = 1;\n          break;\n        }\n        sqlite3_free(aDoclist);\n      }\n    }\n  }\n\n  *pbEof = bEof;\n  return rc;\n}\n\n/*\n** Attempt to move the phrase iterator to point to the next matching docid. \n** If an error occurs, return an SQLite error code. Otherwise, return \n** SQLITE_OK.\n**\n** If there is no \"next\" entry and no error occurs, then *pbEof is set to\n** 1 before returning. Otherwise, if no error occurs and the iterator is\n** successfully advanced, *pbEof is set to 0.\n*/\nstatic int fts3EvalPhraseNext(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Phrase *p,                  /* Phrase object to advance to next docid */\n  u8 *pbEof                       /* OUT: Set to 1 if EOF */\n){\n  int rc = SQLITE_OK;\n  Fts3Doclist *pDL = &p->doclist;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n\n  if( p->bIncr ){\n    rc = fts3EvalIncrPhraseNext(pCsr, p, pbEof);\n  }else if( pCsr->bDesc!=pTab->bDescIdx && pDL->nAll ){\n    sqlite3Fts3DoclistPrev(pTab->bDescIdx, pDL->aAll, pDL->nAll, \n        &pDL->pNextDocid, &pDL->iDocid, &pDL->nList, pbEof\n    );\n    pDL->pList = pDL->pNextDocid;\n  }else{\n    fts3EvalDlPhraseNext(pTab, pDL, pbEof);\n  }\n\n  return rc;\n}\n\n/*\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, fts3EvalPhraseStart() is called on all phrases within the\n** expression. Also the Fts3Expr.bDeferred variable is set to true for any\n** expressions for which all descendent tokens are deferred.\n**\n** If parameter bOptOk is zero, then it is guaranteed that the\n** Fts3Phrase.doclist.aAll/nAll variables contain the entire doclist for\n** each phrase in the expression (subject to deferred token processing).\n** Or, if bOptOk is non-zero, then one or more tokens within the expression\n** may be loaded incrementally, meaning doclist.aAll/nAll is not available.\n**\n** If an error occurs within this function, *pRc is set to an SQLite error\n** code before returning.\n*/\nstatic void fts3EvalStartReaders(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expression to initialize phrases in */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( pExpr && SQLITE_OK==*pRc ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      int nToken = pExpr->pPhrase->nToken;\n      if( nToken ){\n        int i;\n        for(i=0; i<nToken; i++){\n          if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;\n        }\n        pExpr->bDeferred = (i==nToken);\n      }\n      *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);\n    }else{\n      fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);\n      fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);\n      pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);\n    }\n  }\n}\n\n/*\n** An array of the following structures is assembled as part of the process\n** of selecting tokens to defer before the query starts executing (as part\n** of the xFilter() method). There is one element in the array for each\n** token in the FTS expression.\n**\n** Tokens are divided into AND/NEAR clusters. All tokens in a cluster belong\n** to phrases that are connected only by AND and NEAR operators (not OR or\n** NOT). When determining tokens to defer, each AND/NEAR cluster is considered\n** separately. The root of a tokens AND/NEAR cluster is stored in \n** Fts3TokenAndCost.pRoot.\n*/\ntypedef struct Fts3TokenAndCost Fts3TokenAndCost;\nstruct Fts3TokenAndCost {\n  Fts3Phrase *pPhrase;            /* The phrase the token belongs to */\n  int iToken;                     /* Position of token in phrase */\n  Fts3PhraseToken *pToken;        /* The token itself */\n  Fts3Expr *pRoot;                /* Root of NEAR/AND cluster */\n  int nOvfl;                      /* Number of overflow pages to load doclist */\n  int iCol;                       /* The column the token must match */\n};\n\n/*\n** This function is used to populate an allocated Fts3TokenAndCost array.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if an error occurs during execution, *pRc is set to an\n** SQLite error code.\n*/\nstatic void fts3EvalTokenCosts(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Root of current AND/NEAR cluster */\n  Fts3Expr *pExpr,                /* Expression to consider */\n  Fts3TokenAndCost **ppTC,        /* Write new entries to *(*ppTC)++ */\n  Fts3Expr ***ppOr,               /* Write new OR root to *(*ppOr)++ */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    if( pExpr->eType==FTSQUERY_PHRASE ){\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      for(i=0; *pRc==SQLITE_OK && i<pPhrase->nToken; i++){\n        Fts3TokenAndCost *pTC = (*ppTC)++;\n        pTC->pPhrase = pPhrase;\n        pTC->iToken = i;\n        pTC->pRoot = pRoot;\n        pTC->pToken = &pPhrase->aToken[i];\n        pTC->iCol = pPhrase->iColumn;\n        *pRc = sqlite3Fts3MsrOvfl(pCsr, pTC->pToken->pSegcsr, &pTC->nOvfl);\n      }\n    }else if( pExpr->eType!=FTSQUERY_NOT ){\n      assert( pExpr->eType==FTSQUERY_OR\n           || pExpr->eType==FTSQUERY_AND\n           || pExpr->eType==FTSQUERY_NEAR\n      );\n      assert( pExpr->pLeft && pExpr->pRight );\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pLeft;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pLeft, ppTC, ppOr, pRc);\n      if( pExpr->eType==FTSQUERY_OR ){\n        pRoot = pExpr->pRight;\n        **ppOr = pRoot;\n        (*ppOr)++;\n      }\n      fts3EvalTokenCosts(pCsr, pRoot, pExpr->pRight, ppTC, ppOr, pRc);\n    }\n  }\n}\n\n/*\n** Determine the average document (row) size in pages. If successful,\n** write this value to *pnPage and return SQLITE_OK. Otherwise, return\n** an SQLite error code.\n**\n** The average document size in pages is calculated by first calculating \n** determining the average size in bytes, B. If B is less than the amount\n** of data that will fit on a single leaf page of an intkey table in\n** this database, then the average docsize is 1. Otherwise, it is 1 plus\n** the number of overflow pages consumed by a record B bytes in size.\n*/\nstatic int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){\n  int rc = SQLITE_OK;\n  if( pCsr->nRowAvg==0 ){\n    /* The average document size, which is required to calculate the cost\n    ** of each doclist, has not yet been determined. Read the required \n    ** data from the %_stat table to calculate it.\n    **\n    ** Entry 0 of the %_stat table is a blob containing (nCol+1) FTS3 \n    ** varints, where nCol is the number of columns in the FTS3 table.\n    ** The first varint is the number of documents currently stored in\n    ** the table. The following nCol varints contain the total amount of\n    ** data stored in all rows of each column of the table, from left\n    ** to right.\n    */\n    Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n    sqlite3_stmt *pStmt;\n    sqlite3_int64 nDoc = 0;\n    sqlite3_int64 nByte = 0;\n    const char *pEnd;\n    const char *a;\n\n    rc = sqlite3Fts3SelectDoctotal(p, &pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n    a = sqlite3_column_blob(pStmt, 0);\n    assert( a );\n\n    pEnd = &a[sqlite3_column_bytes(pStmt, 0)];\n    a += sqlite3Fts3GetVarint(a, &nDoc);\n    while( a<pEnd ){\n      a += sqlite3Fts3GetVarint(a, &nByte);\n    }\n    if( nDoc==0 || nByte==0 ){\n      sqlite3_reset(pStmt);\n      return FTS_CORRUPT_VTAB;\n    }\n\n    pCsr->nDoc = nDoc;\n    pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz);\n    assert( pCsr->nRowAvg>0 ); \n    rc = sqlite3_reset(pStmt);\n  }\n\n  *pnPage = pCsr->nRowAvg;\n  return rc;\n}\n\n/*\n** This function is called to select the tokens (if any) that will be \n** deferred. The array aTC[] has already been populated when this is\n** called.\n**\n** This function is called once for each AND/NEAR cluster in the \n** expression. Each invocation determines which tokens to defer within\n** the cluster with root node pRoot. See comments above the definition\n** of struct Fts3TokenAndCost for more details.\n**\n** If no error occurs, SQLITE_OK is returned and sqlite3Fts3DeferToken()\n** called on each token to defer. Otherwise, an SQLite error code is\n** returned.\n*/\nstatic int fts3EvalSelectDeferred(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pRoot,                /* Consider tokens with this root node */\n  Fts3TokenAndCost *aTC,          /* Array of expression tokens and costs */\n  int nTC                         /* Number of entries in aTC[] */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int nDocSize = 0;               /* Number of pages per doc loaded */\n  int rc = SQLITE_OK;             /* Return code */\n  int ii;                         /* Iterator variable for various purposes */\n  int nOvfl = 0;                  /* Total overflow pages used by doclists */\n  int nToken = 0;                 /* Total number of tokens in cluster */\n\n  int nMinEst = 0;                /* The minimum count for any phrase so far. */\n  int nLoad4 = 1;                 /* (Phrases that will be loaded)^4. */\n\n  /* Tokens are never deferred for FTS tables created using the content=xxx\n  ** option. The reason being that it is not guaranteed that the content\n  ** table actually contains the same data as the index. To prevent this from\n  ** causing any problems, the deferred token optimization is completely\n  ** disabled for content=xxx tables. */\n  if( pTab->zContentTbl ){\n    return SQLITE_OK;\n  }\n\n  /* Count the tokens in this AND/NEAR cluster. If none of the doclists\n  ** associated with the tokens spill onto overflow pages, or if there is\n  ** only 1 token, exit early. No tokens to defer in this case. */\n  for(ii=0; ii<nTC; ii++){\n    if( aTC[ii].pRoot==pRoot ){\n      nOvfl += aTC[ii].nOvfl;\n      nToken++;\n    }\n  }\n  if( nOvfl==0 || nToken<2 ) return SQLITE_OK;\n\n  /* Obtain the average docsize (in pages). */\n  rc = fts3EvalAverageDocsize(pCsr, &nDocSize);\n  assert( rc!=SQLITE_OK || nDocSize>0 );\n\n\n  /* Iterate through all tokens in this AND/NEAR cluster, in ascending order \n  ** of the number of overflow pages that will be loaded by the pager layer \n  ** to retrieve the entire doclist for the token from the full-text index.\n  ** Load the doclists for tokens that are either:\n  **\n  **   a. The cheapest token in the entire query (i.e. the one visited by the\n  **      first iteration of this loop), or\n  **\n  **   b. Part of a multi-token phrase.\n  **\n  ** After each token doclist is loaded, merge it with the others from the\n  ** same phrase and count the number of documents that the merged doclist\n  ** contains. Set variable \"nMinEst\" to the smallest number of documents in \n  ** any phrase doclist for which 1 or more token doclists have been loaded.\n  ** Let nOther be the number of other phrases for which it is certain that\n  ** one or more tokens will not be deferred.\n  **\n  ** Then, for each token, defer it if loading the doclist would result in\n  ** loading N or more overflow pages into memory, where N is computed as:\n  **\n  **    (nMinEst + 4^nOther - 1) / (4^nOther)\n  */\n  for(ii=0; ii<nToken && rc==SQLITE_OK; ii++){\n    int iTC;                      /* Used to iterate through aTC[] array. */\n    Fts3TokenAndCost *pTC = 0;    /* Set to cheapest remaining token. */\n\n    /* Set pTC to point to the cheapest remaining token. */\n    for(iTC=0; iTC<nTC; iTC++){\n      if( aTC[iTC].pToken && aTC[iTC].pRoot==pRoot \n       && (!pTC || aTC[iTC].nOvfl<pTC->nOvfl) \n      ){\n        pTC = &aTC[iTC];\n      }\n    }\n    assert( pTC );\n\n    if( ii && pTC->nOvfl>=((nMinEst+(nLoad4/4)-1)/(nLoad4/4))*nDocSize ){\n      /* The number of overflow pages to load for this (and therefore all\n      ** subsequent) tokens is greater than the estimated number of pages \n      ** that will be loaded if all subsequent tokens are deferred.\n      */\n      Fts3PhraseToken *pToken = pTC->pToken;\n      rc = sqlite3Fts3DeferToken(pCsr, pToken, pTC->iCol);\n      fts3SegReaderCursorFree(pToken->pSegcsr);\n      pToken->pSegcsr = 0;\n    }else{\n      /* Set nLoad4 to the value of (4^nOther) for the next iteration of the\n      ** for-loop. Except, limit the value to 2^24 to prevent it from \n      ** overflowing the 32-bit integer it is stored in. */\n      if( ii<12 ) nLoad4 = nLoad4*4;\n\n      if( ii==0 || (pTC->pPhrase->nToken>1 && ii!=nToken-1) ){\n        /* Either this is the cheapest token in the entire query, or it is\n        ** part of a multi-token phrase. Either way, the entire doclist will\n        ** (eventually) be loaded into memory. It may as well be now. */\n        Fts3PhraseToken *pToken = pTC->pToken;\n        int nList = 0;\n        char *pList = 0;\n        rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);\n        assert( rc==SQLITE_OK || pList==0 );\n        if( rc==SQLITE_OK ){\n          rc = fts3EvalPhraseMergeToken(\n              pTab, pTC->pPhrase, pTC->iToken,pList,nList\n          );\n        }\n        if( rc==SQLITE_OK ){\n          int nCount;\n          nCount = fts3DoclistCountDocids(\n              pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll\n          );\n          if( ii==0 || nCount<nMinEst ) nMinEst = nCount;\n        }\n      }\n    }\n    pTC->pToken = 0;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called from within the xFilter method. It initializes\n** the full-text query currently stored in pCsr->pExpr. To iterate through\n** the results of a query, the caller does:\n**\n**    fts3EvalStart(pCsr);\n**    while( 1 ){\n**      fts3EvalNext(pCsr);\n**      if( pCsr->bEof ) break;\n**      ... return row pCsr->iPrevId to the caller ...\n**    }\n*/\nstatic int fts3EvalStart(Fts3Cursor *pCsr){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int nToken = 0;\n  int nOr = 0;\n\n  /* Allocate a MultiSegReader for each token in the expression. */\n  fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);\n\n  /* Determine which, if any, tokens in the expression should be deferred. */\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n  if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){\n    Fts3TokenAndCost *aTC;\n    Fts3Expr **apOr;\n    aTC = (Fts3TokenAndCost *)sqlite3_malloc(\n        sizeof(Fts3TokenAndCost) * nToken\n      + sizeof(Fts3Expr *) * nOr * 2\n    );\n    apOr = (Fts3Expr **)&aTC[nToken];\n\n    if( !aTC ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int ii;\n      Fts3TokenAndCost *pTC = aTC;\n      Fts3Expr **ppOr = apOr;\n\n      fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);\n      nToken = (int)(pTC-aTC);\n      nOr = (int)(ppOr-apOr);\n\n      if( rc==SQLITE_OK ){\n        rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);\n        for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){\n          rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);\n        }\n      }\n\n      sqlite3_free(aTC);\n    }\n  }\n#endif\n\n  fts3EvalStartReaders(pCsr, pCsr->pExpr, &rc);\n  return rc;\n}\n\n/*\n** Invalidate the current position list for phrase pPhrase.\n*/\nstatic void fts3EvalInvalidatePoslist(Fts3Phrase *pPhrase){\n  if( pPhrase->doclist.bFreeList ){\n    sqlite3_free(pPhrase->doclist.pList);\n  }\n  pPhrase->doclist.pList = 0;\n  pPhrase->doclist.nList = 0;\n  pPhrase->doclist.bFreeList = 0;\n}\n\n/*\n** This function is called to edit the position list associated with\n** the phrase object passed as the fifth argument according to a NEAR\n** condition. For example:\n**\n**     abc NEAR/5 \"def ghi\"\n**\n** Parameter nNear is passed the NEAR distance of the expression (5 in\n** the example above). When this function is called, *paPoslist points to\n** the position list, and *pnToken is the number of phrase tokens in, the\n** phrase on the other side of the NEAR operator to pPhrase. For example,\n** if pPhrase refers to the \"def ghi\" phrase, then *paPoslist points to\n** the position list associated with phrase \"abc\".\n**\n** All positions in the pPhrase position list that are not sufficiently\n** close to a position in the *paPoslist position list are removed. If this\n** leaves 0 positions, zero is returned. Otherwise, non-zero.\n**\n** Before returning, *paPoslist is set to point to the position lsit \n** associated with pPhrase. And *pnToken is set to the number of tokens in\n** pPhrase.\n*/\nstatic int fts3EvalNearTrim(\n  int nNear,                      /* NEAR distance. As in \"NEAR/nNear\". */\n  char *aTmp,                     /* Temporary space to use */\n  char **paPoslist,               /* IN/OUT: Position list */\n  int *pnToken,                   /* IN/OUT: Tokens in phrase of *paPoslist */\n  Fts3Phrase *pPhrase             /* The phrase object to trim the doclist of */\n){\n  int nParam1 = nNear + pPhrase->nToken;\n  int nParam2 = nNear + *pnToken;\n  int nNew;\n  char *p2; \n  char *pOut; \n  int res;\n\n  assert( pPhrase->doclist.pList );\n\n  p2 = pOut = pPhrase->doclist.pList;\n  res = fts3PoslistNearMerge(\n    &pOut, aTmp, nParam1, nParam2, paPoslist, &p2\n  );\n  if( res ){\n    nNew = (int)(pOut - pPhrase->doclist.pList) - 1;\n    assert( pPhrase->doclist.pList[nNew]=='\\0' );\n    assert( nNew<=pPhrase->doclist.nList && nNew>0 );\n    memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);\n    pPhrase->doclist.nList = nNew;\n    *paPoslist = pPhrase->doclist.pList;\n    *pnToken = pPhrase->nToken;\n  }\n\n  return res;\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is called.\n** Otherwise, it advances the expression passed as the second argument to\n** point to the next matching row in the database. Expressions iterate through\n** matching rows in docid order. Ascending order if Fts3Cursor.bDesc is zero,\n** or descending if it is non-zero.\n**\n** If an error occurs, *pRc is set to an SQLite error code. Otherwise, if\n** successful, the following variables in pExpr are set:\n**\n**   Fts3Expr.bEof                (non-zero if EOF - there is no next row)\n**   Fts3Expr.iDocid              (valid if bEof==0. The docid of the next row)\n**\n** If the expression is of type FTSQUERY_PHRASE, and the expression is not\n** at EOF, then the following variables are populated with the position list\n** for the phrase for the visited row:\n**\n**   FTs3Expr.pPhrase->doclist.nList        (length of pList in bytes)\n**   FTs3Expr.pPhrase->doclist.pList        (pointer to position list)\n**\n** It says above that this function advances the expression to the next\n** matching row. This is usually true, but there are the following exceptions:\n**\n**   1. Deferred tokens are not taken into account. If a phrase consists\n**      entirely of deferred tokens, it is assumed to match every row in\n**      the db. In this case the position-list is not populated at all. \n**\n**      Or, if a phrase contains one or more deferred tokens and one or\n**      more non-deferred tokens, then the expression is advanced to the \n**      next possible match, considering only non-deferred tokens. In other\n**      words, if the phrase is \"A B C\", and \"B\" is deferred, the expression\n**      is advanced to the next row that contains an instance of \"A * C\", \n**      where \"*\" may match any single token. The position list in this case\n**      is populated as for \"A * C\" before returning.\n**\n**   2. NEAR is treated as AND. If the expression is \"x NEAR y\", it is \n**      advanced to point to the next row that matches \"x AND y\".\n** \n** See sqlite3Fts3EvalTestDeferred() for details on testing if a row is\n** really a match, taking into account deferred tokens and NEAR operators.\n*/\nstatic void fts3EvalNextRow(\n  Fts3Cursor *pCsr,               /* FTS Cursor handle */\n  Fts3Expr *pExpr,                /* Expr. to advance to next matching row */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int bDescDoclist = pCsr->bDesc;         /* Used by DOCID_CMP() macro */\n    assert( pExpr->bEof==0 );\n    pExpr->bStart = 1;\n\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        assert( !pLeft->bDeferred || !pRight->bDeferred );\n\n        if( pLeft->bDeferred ){\n          /* LHS is entirely deferred. So we assume it matches every row.\n          ** Advance the RHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          pExpr->iDocid = pRight->iDocid;\n          pExpr->bEof = pRight->bEof;\n        }else if( pRight->bDeferred ){\n          /* RHS is entirely deferred. So we assume it matches every row.\n          ** Advance the LHS iterator to find the next row visited. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = pLeft->bEof;\n        }else{\n          /* Neither the RHS or LHS are deferred. */\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          while( !pLeft->bEof && !pRight->bEof && *pRc==SQLITE_OK ){\n            sqlite3_int64 iDiff = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n            if( iDiff==0 ) break;\n            if( iDiff<0 ){\n              fts3EvalNextRow(pCsr, pLeft, pRc);\n            }else{\n              fts3EvalNextRow(pCsr, pRight, pRc);\n            }\n          }\n          pExpr->iDocid = pLeft->iDocid;\n          pExpr->bEof = (pLeft->bEof || pRight->bEof);\n          if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){\n            assert( pRight->eType==FTSQUERY_PHRASE );\n            if( pRight->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pRight->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pRight->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pRight, pRc);\n              }\n            }\n            if( pLeft->pPhrase && pLeft->pPhrase->doclist.aAll ){\n              Fts3Doclist *pDl = &pLeft->pPhrase->doclist;\n              while( *pRc==SQLITE_OK && pLeft->bEof==0 ){\n                memset(pDl->pList, 0, pDl->nList);\n                fts3EvalNextRow(pCsr, pLeft, pRc);\n              }\n            }\n          }\n        }\n        break;\n      }\n  \n      case FTSQUERY_OR: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n        sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n\n        assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid );\n        assert( pRight->bStart || pLeft->iDocid==pRight->iDocid );\n\n        if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n        }else if( pLeft->bEof || iCmp>0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }else{\n          fts3EvalNextRow(pCsr, pLeft, pRc);\n          fts3EvalNextRow(pCsr, pRight, pRc);\n        }\n\n        pExpr->bEof = (pLeft->bEof && pRight->bEof);\n        iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid);\n        if( pRight->bEof || (pLeft->bEof==0 &&  iCmp<0) ){\n          pExpr->iDocid = pLeft->iDocid;\n        }else{\n          pExpr->iDocid = pRight->iDocid;\n        }\n\n        break;\n      }\n\n      case FTSQUERY_NOT: {\n        Fts3Expr *pLeft = pExpr->pLeft;\n        Fts3Expr *pRight = pExpr->pRight;\n\n        if( pRight->bStart==0 ){\n          fts3EvalNextRow(pCsr, pRight, pRc);\n          assert( *pRc!=SQLITE_OK || pRight->bStart );\n        }\n\n        fts3EvalNextRow(pCsr, pLeft, pRc);\n        if( pLeft->bEof==0 ){\n          while( !*pRc \n              && !pRight->bEof \n              && DOCID_CMP(pLeft->iDocid, pRight->iDocid)>0 \n          ){\n            fts3EvalNextRow(pCsr, pRight, pRc);\n          }\n        }\n        pExpr->iDocid = pLeft->iDocid;\n        pExpr->bEof = pLeft->bEof;\n        break;\n      }\n\n      default: {\n        Fts3Phrase *pPhrase = pExpr->pPhrase;\n        fts3EvalInvalidatePoslist(pPhrase);\n        *pRc = fts3EvalPhraseNext(pCsr, pPhrase, &pExpr->bEof);\n        pExpr->iDocid = pPhrase->doclist.iDocid;\n        break;\n      }\n    }\n  }\n}\n\n/*\n** If *pRc is not SQLITE_OK, or if pExpr is not the root node of a NEAR\n** cluster, then this function returns 1 immediately.\n**\n** Otherwise, it checks if the current row really does match the NEAR \n** expression, using the data currently stored in the position lists \n** (Fts3Expr->pPhrase.doclist.pList/nList) for each phrase in the expression. \n**\n** If the current row is a match, the position list associated with each\n** phrase in the NEAR expression is edited in place to contain only those\n** phrase instances sufficiently close to their peers to satisfy all NEAR\n** constraints. In this case it returns 1. If the NEAR expression does not \n** match the current row, 0 is returned. The position lists may or may not\n** be edited if 0 is returned.\n*/\nstatic int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){\n  int res = 1;\n\n  /* The following block runs if pExpr is the root of a NEAR query.\n  ** For example, the query:\n  **\n  **         \"w\" NEAR \"x\" NEAR \"y\" NEAR \"z\"\n  **\n  ** which is represented in tree form as:\n  **\n  **                               |\n  **                          +--NEAR--+      <-- root of NEAR query\n  **                          |        |\n  **                     +--NEAR--+   \"z\"\n  **                     |        |\n  **                +--NEAR--+   \"y\"\n  **                |        |\n  **               \"w\"      \"x\"\n  **\n  ** The right-hand child of a NEAR node is always a phrase. The \n  ** left-hand child may be either a phrase or a NEAR node. There are\n  ** no exceptions to this - it's the way the parser in fts3_expr.c works.\n  */\n  if( *pRc==SQLITE_OK \n   && pExpr->eType==FTSQUERY_NEAR \n   && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n  ){\n    Fts3Expr *p; \n    int nTmp = 0;                 /* Bytes of temp space */\n    char *aTmp;                   /* Temp space for PoslistNearMerge() */\n\n    /* Allocate temporary working space. */\n    for(p=pExpr; p->pLeft; p=p->pLeft){\n      assert( p->pRight->pPhrase->doclist.nList>0 );\n      nTmp += p->pRight->pPhrase->doclist.nList;\n    }\n    nTmp += p->pPhrase->doclist.nList;\n    aTmp = sqlite3_malloc(nTmp*2);\n    if( !aTmp ){\n      *pRc = SQLITE_NOMEM;\n      res = 0;\n    }else{\n      char *aPoslist = p->pPhrase->doclist.pList;\n      int nToken = p->pPhrase->nToken;\n\n      for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){\n        Fts3Phrase *pPhrase = p->pRight->pPhrase;\n        int nNear = p->nNear;\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n\n      aPoslist = pExpr->pRight->pPhrase->doclist.pList;\n      nToken = pExpr->pRight->pPhrase->nToken;\n      for(p=pExpr->pLeft; p && res; p=p->pLeft){\n        int nNear;\n        Fts3Phrase *pPhrase;\n        assert( p->pParent && p->pParent->pLeft==p );\n        nNear = p->pParent->nNear;\n        pPhrase = (\n            p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase\n        );\n        res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);\n      }\n    }\n\n    sqlite3_free(aTmp);\n  }\n\n  return res;\n}\n\n/*\n** This function is a helper function for sqlite3Fts3EvalTestDeferred().\n** Assuming no error occurs or has occurred, It returns non-zero if the\n** expression passed as the second argument matches the row that pCsr \n** currently points to, or zero if it does not.\n**\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** If an error occurs during execution of this function, *pRc is set to \n** the appropriate SQLite error code. In this case the returned value is \n** undefined.\n*/\nstatic int fts3EvalTestExpr(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Expr to test. May or may not be root. */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int bHit = 1;                   /* Return value */\n  if( *pRc==SQLITE_OK ){\n    switch( pExpr->eType ){\n      case FTSQUERY_NEAR:\n      case FTSQUERY_AND:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n         && fts3EvalNearTest(pExpr, pRc)\n        );\n\n        /* If the NEAR expression does not match any rows, zero the doclist for \n        ** all phrases involved in the NEAR. This is because the snippet(),\n        ** offsets() and matchinfo() functions are not supposed to recognize \n        ** any instances of phrases that are part of unmatched NEAR queries. \n        ** For example if this expression:\n        **\n        **    ... MATCH 'a OR (b NEAR c)'\n        **\n        ** is matched against a row containing:\n        **\n        **        'a b d e'\n        **\n        ** then any snippet() should ony highlight the \"a\" term, not the \"b\"\n        ** (as \"b\" is part of a non-matching NEAR clause).\n        */\n        if( bHit==0 \n         && pExpr->eType==FTSQUERY_NEAR \n         && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)\n        ){\n          Fts3Expr *p;\n          for(p=pExpr; p->pPhrase==0; p=p->pLeft){\n            if( p->pRight->iDocid==pCsr->iPrevId ){\n              fts3EvalInvalidatePoslist(p->pRight->pPhrase);\n            }\n          }\n          if( p->iDocid==pCsr->iPrevId ){\n            fts3EvalInvalidatePoslist(p->pPhrase);\n          }\n        }\n\n        break;\n\n      case FTSQUERY_OR: {\n        int bHit1 = fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc);\n        int bHit2 = fts3EvalTestExpr(pCsr, pExpr->pRight, pRc);\n        bHit = bHit1 || bHit2;\n        break;\n      }\n\n      case FTSQUERY_NOT:\n        bHit = (\n            fts3EvalTestExpr(pCsr, pExpr->pLeft, pRc)\n         && !fts3EvalTestExpr(pCsr, pExpr->pRight, pRc)\n        );\n        break;\n\n      default: {\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n        if( pCsr->pDeferred \n         && (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)\n        ){\n          Fts3Phrase *pPhrase = pExpr->pPhrase;\n          assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );\n          if( pExpr->bDeferred ){\n            fts3EvalInvalidatePoslist(pPhrase);\n          }\n          *pRc = fts3EvalDeferredPhrase(pCsr, pPhrase);\n          bHit = (pPhrase->doclist.pList!=0);\n          pExpr->iDocid = pCsr->iPrevId;\n        }else\n#endif\n        {\n          bHit = (pExpr->bEof==0 && pExpr->iDocid==pCsr->iPrevId);\n        }\n        break;\n      }\n    }\n  }\n  return bHit;\n}\n\n/*\n** This function is called as the second part of each xNext operation when\n** iterating through the results of a full-text query. At this point the\n** cursor points to a row that matches the query expression, with the\n** following caveats:\n**\n**   * Up until this point, \"NEAR\" operators in the expression have been\n**     treated as \"AND\".\n**\n**   * Deferred tokens have not yet been considered.\n**\n** If *pRc is not SQLITE_OK when this function is called, it immediately\n** returns 0. Otherwise, it tests whether or not after considering NEAR\n** operators and deferred tokens the current row is still a match for the\n** expression. It returns 1 if both of the following are true:\n**\n**   1. *pRc is SQLITE_OK when this function returns, and\n**\n**   2. After scanning the current FTS table row for the deferred tokens,\n**      it is determined that the row does *not* match the query.\n**\n** Or, if no error occurs and it seems the current row does match the FTS\n** query, return 0.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalTestDeferred(Fts3Cursor *pCsr, int *pRc){\n  int rc = *pRc;\n  int bMiss = 0;\n  if( rc==SQLITE_OK ){\n\n    /* If there are one or more deferred tokens, load the current row into\n    ** memory and scan it to determine the position list for each deferred\n    ** token. Then, see if this row is really a match, considering deferred\n    ** tokens and NEAR operators (neither of which were taken into account\n    ** earlier, by fts3EvalNextRow()). \n    */\n    if( pCsr->pDeferred ){\n      rc = fts3CursorSeek(0, pCsr);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts3CacheDeferredDoclists(pCsr);\n      }\n    }\n    bMiss = (0==fts3EvalTestExpr(pCsr, pCsr->pExpr, &rc));\n\n    /* Free the position-lists accumulated for each deferred token above. */\n    sqlite3Fts3FreeDeferredDoclists(pCsr);\n    *pRc = rc;\n  }\n  return (rc==SQLITE_OK && bMiss);\n}\n\n/*\n** Advance to the next document that matches the FTS expression in\n** Fts3Cursor.pExpr.\n*/\nstatic int fts3EvalNext(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Expr *pExpr = pCsr->pExpr;\n  assert( pCsr->isEof==0 );\n  if( pExpr==0 ){\n    pCsr->isEof = 1;\n  }else{\n    do {\n      if( pCsr->isRequireSeek==0 ){\n        sqlite3_reset(pCsr->pStmt);\n      }\n      assert( sqlite3_data_count(pCsr->pStmt)==0 );\n      fts3EvalNextRow(pCsr, pExpr, &rc);\n      pCsr->isEof = pExpr->bEof;\n      pCsr->isRequireSeek = 1;\n      pCsr->isMatchinfoNeeded = 1;\n      pCsr->iPrevId = pExpr->iDocid;\n    }while( pCsr->isEof==0 && sqlite3Fts3EvalTestDeferred(pCsr, &rc) );\n  }\n\n  /* Check if the cursor is past the end of the docid range specified\n  ** by Fts3Cursor.iMinDocid/iMaxDocid. If so, set the EOF flag.  */\n  if( rc==SQLITE_OK && (\n        (pCsr->bDesc==0 && pCsr->iPrevId>pCsr->iMaxDocid)\n     || (pCsr->bDesc!=0 && pCsr->iPrevId<pCsr->iMinDocid)\n  )){\n    pCsr->isEof = 1;\n  }\n\n  return rc;\n}\n\n/*\n** Restart interation for expression pExpr so that the next call to\n** fts3EvalNext() visits the first row. Do not allow incremental \n** loading or merging of phrase doclists for this iteration.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op. If an error occurs within this function, *pRc is set to an\n** SQLite error code before returning.\n*/\nstatic void fts3EvalRestart(\n  Fts3Cursor *pCsr,\n  Fts3Expr *pExpr,\n  int *pRc\n){\n  if( pExpr && *pRc==SQLITE_OK ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n\n    if( pPhrase ){\n      fts3EvalInvalidatePoslist(pPhrase);\n      if( pPhrase->bIncr ){\n        int i;\n        for(i=0; i<pPhrase->nToken; i++){\n          Fts3PhraseToken *pToken = &pPhrase->aToken[i];\n          assert( pToken->pDeferred==0 );\n          if( pToken->pSegcsr ){\n            sqlite3Fts3MsrIncrRestart(pToken->pSegcsr);\n          }\n        }\n        *pRc = fts3EvalPhraseStart(pCsr, 0, pPhrase);\n      }\n      pPhrase->doclist.pNextDocid = 0;\n      pPhrase->doclist.iDocid = 0;\n      pPhrase->pOrPoslist = 0;\n    }\n\n    pExpr->iDocid = 0;\n    pExpr->bEof = 0;\n    pExpr->bStart = 0;\n\n    fts3EvalRestart(pCsr, pExpr->pLeft, pRc);\n    fts3EvalRestart(pCsr, pExpr->pRight, pRc);\n  }\n}\n\n/*\n** After allocating the Fts3Expr.aMI[] array for each phrase in the \n** expression rooted at pExpr, the cursor iterates through all rows matched\n** by pExpr, calling this function for each row. This function increments\n** the values in Fts3Expr.aMI[] according to the position-list currently\n** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase \n** expression nodes.\n*/\nstatic void fts3EvalUpdateCounts(Fts3Expr *pExpr){\n  if( pExpr ){\n    Fts3Phrase *pPhrase = pExpr->pPhrase;\n    if( pPhrase && pPhrase->doclist.pList ){\n      int iCol = 0;\n      char *p = pPhrase->doclist.pList;\n\n      assert( *p );\n      while( 1 ){\n        u8 c = 0;\n        int iCnt = 0;\n        while( 0xFE & (*p | c) ){\n          if( (c&0x80)==0 ) iCnt++;\n          c = *p++ & 0x80;\n        }\n\n        /* aMI[iCol*3 + 1] = Number of occurrences\n        ** aMI[iCol*3 + 2] = Number of rows containing at least one instance\n        */\n        pExpr->aMI[iCol*3 + 1] += iCnt;\n        pExpr->aMI[iCol*3 + 2] += (iCnt>0);\n        if( *p==0x00 ) break;\n        p++;\n        p += fts3GetVarint32(p, &iCol);\n      }\n    }\n\n    fts3EvalUpdateCounts(pExpr->pLeft);\n    fts3EvalUpdateCounts(pExpr->pRight);\n  }\n}\n\n/*\n** Expression pExpr must be of type FTSQUERY_PHRASE.\n**\n** If it is not already allocated and populated, this function allocates and\n** populates the Fts3Expr.aMI[] array for expression pExpr. If pExpr is part\n** of a NEAR expression, then it also allocates and populates the same array\n** for all other phrases that are part of the NEAR expression.\n**\n** SQLITE_OK is returned if the aMI[] array is successfully allocated and\n** populated. Otherwise, if an error occurs, an SQLite error code is returned.\n*/\nstatic int fts3EvalGatherStats(\n  Fts3Cursor *pCsr,               /* Cursor object */\n  Fts3Expr *pExpr                 /* FTSQUERY_PHRASE expression */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pExpr->eType==FTSQUERY_PHRASE );\n  if( pExpr->aMI==0 ){\n    Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n    Fts3Expr *pRoot;                /* Root of NEAR expression */\n    Fts3Expr *p;                    /* Iterator used for several purposes */\n\n    sqlite3_int64 iPrevId = pCsr->iPrevId;\n    sqlite3_int64 iDocid;\n    u8 bEof;\n\n    /* Find the root of the NEAR expression */\n    pRoot = pExpr;\n    while( pRoot->pParent && pRoot->pParent->eType==FTSQUERY_NEAR ){\n      pRoot = pRoot->pParent;\n    }\n    iDocid = pRoot->iDocid;\n    bEof = pRoot->bEof;\n    assert( pRoot->bStart );\n\n    /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */\n    for(p=pRoot; p; p=p->pLeft){\n      Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);\n      assert( pE->aMI==0 );\n      pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));\n      if( !pE->aMI ) return SQLITE_NOMEM;\n      memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));\n    }\n\n    fts3EvalRestart(pCsr, pRoot, &rc);\n\n    while( pCsr->isEof==0 && rc==SQLITE_OK ){\n\n      do {\n        /* Ensure the %_content statement is reset. */\n        if( pCsr->isRequireSeek==0 ) sqlite3_reset(pCsr->pStmt);\n        assert( sqlite3_data_count(pCsr->pStmt)==0 );\n\n        /* Advance to the next document */\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        pCsr->isEof = pRoot->bEof;\n        pCsr->isRequireSeek = 1;\n        pCsr->isMatchinfoNeeded = 1;\n        pCsr->iPrevId = pRoot->iDocid;\n      }while( pCsr->isEof==0 \n           && pRoot->eType==FTSQUERY_NEAR \n           && sqlite3Fts3EvalTestDeferred(pCsr, &rc) \n      );\n\n      if( rc==SQLITE_OK && pCsr->isEof==0 ){\n        fts3EvalUpdateCounts(pRoot);\n      }\n    }\n\n    pCsr->isEof = 0;\n    pCsr->iPrevId = iPrevId;\n\n    if( bEof ){\n      pRoot->bEof = bEof;\n    }else{\n      /* Caution: pRoot may iterate through docids in ascending or descending\n      ** order. For this reason, even though it seems more defensive, the \n      ** do loop can not be written:\n      **\n      **   do {...} while( pRoot->iDocid<iDocid && rc==SQLITE_OK );\n      */\n      fts3EvalRestart(pCsr, pRoot, &rc);\n      do {\n        fts3EvalNextRow(pCsr, pRoot, &rc);\n        assert( pRoot->bEof==0 );\n      }while( pRoot->iDocid!=iDocid && rc==SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used by the matchinfo() module to query a phrase \n** expression node for the following information:\n**\n**   1. The total number of occurrences of the phrase in each column of \n**      the FTS table (considering all rows), and\n**\n**   2. For each column, the number of rows in the table for which the\n**      column contains at least one instance of the phrase.\n**\n** If no error occurs, SQLITE_OK is returned and the values for each column\n** written into the array aiOut as follows:\n**\n**   aiOut[iCol*3 + 1] = Number of occurrences\n**   aiOut[iCol*3 + 2] = Number of rows containing at least one instance\n**\n** Caveats:\n**\n**   * If a phrase consists entirely of deferred tokens, then all output \n**     values are set to the number of documents in the table. In other\n**     words we assume that very common tokens occur exactly once in each \n**     column of each row of the table.\n**\n**   * If a phrase contains some deferred tokens (and some non-deferred \n**     tokens), count the potential occurrence identified by considering\n**     the non-deferred tokens instead of actual phrase occurrences.\n**\n**   * If the phrase is part of a NEAR expression, then only phrase instances\n**     that meet the NEAR constraint are included in the counts.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(\n  Fts3Cursor *pCsr,               /* FTS cursor handle */\n  Fts3Expr *pExpr,                /* Phrase expression */\n  u32 *aiOut                      /* Array to write results into (see above) */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int iCol;\n\n  if( pExpr->bDeferred && pExpr->pParent->eType!=FTSQUERY_NEAR ){\n    assert( pCsr->nDoc>0 );\n    for(iCol=0; iCol<pTab->nColumn; iCol++){\n      aiOut[iCol*3 + 1] = (u32)pCsr->nDoc;\n      aiOut[iCol*3 + 2] = (u32)pCsr->nDoc;\n    }\n  }else{\n    rc = fts3EvalGatherStats(pCsr, pExpr);\n    if( rc==SQLITE_OK ){\n      assert( pExpr->aMI );\n      for(iCol=0; iCol<pTab->nColumn; iCol++){\n        aiOut[iCol*3 + 1] = pExpr->aMI[iCol*3 + 1];\n        aiOut[iCol*3 + 2] = pExpr->aMI[iCol*3 + 2];\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The expression pExpr passed as the second argument to this function\n** must be of type FTSQUERY_PHRASE. \n**\n** The returned value is either NULL or a pointer to a buffer containing\n** a position-list indicating the occurrences of the phrase in column iCol\n** of the current row. \n**\n** More specifically, the returned buffer contains 1 varint for each \n** occurrence of the phrase in the column, stored using the normal (delta+2) \n** compression and is terminated by either an 0x01 or 0x00 byte. For example,\n** if the requested column contains \"a b X c d X X\" and the position-list\n** for 'X' is requested, the buffer returned may contain:\n**\n**     0x04 0x05 0x03 0x01   or   0x04 0x05 0x03 0x00\n**\n** This function works regardless of whether or not the phrase is deferred,\n** incremental, or neither.\n*/\nSQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  Fts3Expr *pExpr,                /* Phrase to return doclist for */\n  int iCol,                       /* Column to return position list for */\n  char **ppOut                    /* OUT: Pointer to position list */\n){\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  char *pIter;\n  int iThis;\n  sqlite3_int64 iDocid;\n\n  /* If this phrase is applies specifically to some column other than \n  ** column iCol, return a NULL pointer.  */\n  *ppOut = 0;\n  assert( iCol>=0 && iCol<pTab->nColumn );\n  if( (pPhrase->iColumn<pTab->nColumn && pPhrase->iColumn!=iCol) ){\n    return SQLITE_OK;\n  }\n\n  iDocid = pExpr->iDocid;\n  pIter = pPhrase->doclist.pList;\n  if( iDocid!=pCsr->iPrevId || pExpr->bEof ){\n    int rc = SQLITE_OK;\n    int bDescDoclist = pTab->bDescIdx;      /* For DOCID_CMP macro */\n    int bOr = 0;\n    u8 bTreeEof = 0;\n    Fts3Expr *p;                  /* Used to iterate from pExpr to root */\n    Fts3Expr *pNear;              /* Most senior NEAR ancestor (or pExpr) */\n    int bMatch;\n\n    /* Check if this phrase descends from an OR expression node. If not, \n    ** return NULL. Otherwise, the entry that corresponds to docid \n    ** pCsr->iPrevId may lie earlier in the doclist buffer. Or, if the\n    ** tree that the node is part of has been marked as EOF, but the node\n    ** itself is not EOF, then it may point to an earlier entry. */\n    pNear = pExpr;\n    for(p=pExpr->pParent; p; p=p->pParent){\n      if( p->eType==FTSQUERY_OR ) bOr = 1;\n      if( p->eType==FTSQUERY_NEAR ) pNear = p;\n      if( p->bEof ) bTreeEof = 1;\n    }\n    if( bOr==0 ) return SQLITE_OK;\n\n    /* This is the descendent of an OR node. In this case we cannot use\n    ** an incremental phrase. Load the entire doclist for the phrase\n    ** into memory in this case.  */\n    if( pPhrase->bIncr ){\n      int bEofSave = pNear->bEof;\n      fts3EvalRestart(pCsr, pNear, &rc);\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n        if( bEofSave==0 && pNear->iDocid==iDocid ) break;\n      }\n      assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );\n    }\n    if( bTreeEof ){\n      while( rc==SQLITE_OK && !pNear->bEof ){\n        fts3EvalNextRow(pCsr, pNear, &rc);\n      }\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    bMatch = 1;\n    for(p=pNear; p; p=p->pLeft){\n      u8 bEof = 0;\n      Fts3Expr *pTest = p;\n      Fts3Phrase *pPh;\n      assert( pTest->eType==FTSQUERY_NEAR || pTest->eType==FTSQUERY_PHRASE );\n      if( pTest->eType==FTSQUERY_NEAR ) pTest = pTest->pRight;\n      assert( pTest->eType==FTSQUERY_PHRASE );\n      pPh = pTest->pPhrase;\n\n      pIter = pPh->pOrPoslist;\n      iDocid = pPh->iOrDocid;\n      if( pCsr->bDesc==bDescDoclist ){\n        bEof = !pPh->doclist.nAll ||\n          (pIter >= (pPh->doclist.aAll + pPh->doclist.nAll));\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){\n          sqlite3Fts3DoclistNext(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &bEof\n          );\n        }\n      }else{\n        bEof = !pPh->doclist.nAll || (pIter && pIter<=pPh->doclist.aAll);\n        while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){\n          int dummy;\n          sqlite3Fts3DoclistPrev(\n              bDescDoclist, pPh->doclist.aAll, pPh->doclist.nAll, \n              &pIter, &iDocid, &dummy, &bEof\n              );\n        }\n      }\n      pPh->pOrPoslist = pIter;\n      pPh->iOrDocid = iDocid;\n      if( bEof || iDocid!=pCsr->iPrevId ) bMatch = 0;\n    }\n\n    if( bMatch ){\n      pIter = pPhrase->pOrPoslist;\n    }else{\n      pIter = 0;\n    }\n  }\n  if( pIter==0 ) return SQLITE_OK;\n\n  if( *pIter==0x01 ){\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }else{\n    iThis = 0;\n  }\n  while( iThis<iCol ){\n    fts3ColumnlistCopy(0, &pIter);\n    if( *pIter==0x00 ) return SQLITE_OK;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iThis);\n  }\n  if( *pIter==0x00 ){\n    pIter = 0;\n  }\n\n  *ppOut = ((iCol==iThis)?pIter:0);\n  return SQLITE_OK;\n}\n\n/*\n** Free all components of the Fts3Phrase structure that were allocated by\n** the eval module. Specifically, this means to free:\n**\n**   * the contents of pPhrase->doclist, and\n**   * any Fts3MultiSegReader objects held by phrase tokens.\n*/\nSQLITE_PRIVATE void sqlite3Fts3EvalPhraseCleanup(Fts3Phrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    sqlite3_free(pPhrase->doclist.aAll);\n    fts3EvalInvalidatePoslist(pPhrase);\n    memset(&pPhrase->doclist, 0, sizeof(Fts3Doclist));\n    for(i=0; i<pPhrase->nToken; i++){\n      fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);\n      pPhrase->aToken[i].pSegcsr = 0;\n    }\n  }\n}\n\n\n/*\n** Return SQLITE_CORRUPT_VTAB.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_PRIVATE int sqlite3Fts3Corrupt(){\n  return SQLITE_CORRUPT_VTAB;\n}\n#endif\n\n#if !SQLITE_CORE\n/*\n** Initialize API pointer table, if required.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts3_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3Fts3Init(db);\n}\n#endif\n\n#endif\n\n/************** End of fts3.c ************************************************/\n/************** Begin file fts3_aux.c ****************************************/\n/*\n** 2011 Jan 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3auxTable Fts3auxTable;\ntypedef struct Fts3auxCursor Fts3auxCursor;\n\nstruct Fts3auxTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts3Table *pFts3Tab;\n};\n\nstruct Fts3auxCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts3MultiSegReader csr;        /* Must be right after \"base\" */\n  Fts3SegFilter filter;\n  char *zStop;\n  int nStop;                      /* Byte-length of string zStop */\n  int iLangid;                    /* Language id to query */\n  int isEof;                      /* True if cursor is at EOF */\n  sqlite3_int64 iRowid;           /* Current rowid */\n\n  int iCol;                       /* Current value of 'col' column */\n  int nStat;                      /* Size of aStat[] array */\n  struct Fts3auxColstats {\n    sqlite3_int64 nDoc;           /* 'documents' values for current csr row */\n    sqlite3_int64 nOcc;           /* 'occurrences' values for current csr row */\n  } *aStat;\n};\n\n/*\n** Schema of the terms table.\n*/\n#define FTS3_AUX_SCHEMA \\\n  \"CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n*/\nstatic int fts3auxConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pUnused,                  /* Unused */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  char const *zDb;                /* Name of database (e.g. \"main\") */\n  char const *zFts3;              /* Name of fts3 table */\n  int nDb;                        /* Result of strlen(zDb) */\n  int nFts3;                      /* Result of strlen(zFts3) */\n  int nByte;                      /* Bytes of space to allocate here */\n  int rc;                         /* value returned by declare_vtab() */\n  Fts3auxTable *p;                /* Virtual table object to return */\n\n  UNUSED_PARAMETER(pUnused);\n\n  /* The user should invoke this in one of two forms:\n  **\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table);\n  **     CREATE VIRTUAL TABLE xxx USING fts4aux(fts4-table-db, fts4-table);\n  */\n  if( argc!=4 && argc!=5 ) goto bad_args;\n\n  zDb = argv[1]; \n  nDb = (int)strlen(zDb);\n  if( argc==5 ){\n    if( nDb==4 && 0==sqlite3_strnicmp(\"temp\", zDb, 4) ){\n      zDb = argv[3]; \n      nDb = (int)strlen(zDb);\n      zFts3 = argv[4];\n    }else{\n      goto bad_args;\n    }\n  }else{\n    zFts3 = argv[3];\n  }\n  nFts3 = (int)strlen(zFts3);\n\n  rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;\n  p = (Fts3auxTable *)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFts3Tab = (Fts3Table *)&p[1];\n  p->pFts3Tab->zDb = (char *)&p->pFts3Tab[1];\n  p->pFts3Tab->zName = &p->pFts3Tab->zDb[nDb+1];\n  p->pFts3Tab->db = db;\n  p->pFts3Tab->nIndex = 1;\n\n  memcpy((char *)p->pFts3Tab->zDb, zDb, nDb);\n  memcpy((char *)p->pFts3Tab->zName, zFts3, nFts3);\n  sqlite3Fts3Dequote((char *)p->pFts3Tab->zName);\n\n  *ppVtab = (sqlite3_vtab *)p;\n  return SQLITE_OK;\n\n bad_args:\n  sqlite3Fts3ErrMsg(pzErr, \"invalid arguments to fts4aux constructor\");\n  return SQLITE_ERROR;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3auxDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3auxTable *p = (Fts3auxTable *)pVtab;\n  Fts3Table *pFts3 = p->pFts3Tab;\n  int i;\n\n  /* Free any prepared statements held */\n  for(i=0; i<SizeofArray(pFts3->aStmt); i++){\n    sqlite3_finalize(pFts3->aStmt[i]);\n  }\n  sqlite3_free(pFts3->zSegmentsTbl);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n#define FTS4AUX_EQ_CONSTRAINT 1\n#define FTS4AUX_GE_CONSTRAINT 2\n#define FTS4AUX_LE_CONSTRAINT 4\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3auxBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iEq = -1;\n  int iGe = -1;\n  int iLe = -1;\n  int iLangid = -1;\n  int iNext = 1;                  /* Next free argvIndex value */\n\n  UNUSED_PARAMETER(pVTab);\n\n  /* This vtab delivers always results in \"ORDER BY term ASC\" order. */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  /* Search for equality and range constraints on the \"term\" column. \n  ** And equality constraints on the hidden \"languageid\" column. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable ){\n      int op = pInfo->aConstraint[i].op;\n      int iCol = pInfo->aConstraint[i].iColumn;\n\n      if( iCol==0 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;\n        if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;\n      }\n      if( iCol==4 ){\n        if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;\n      }\n    }\n  }\n\n  if( iEq>=0 ){\n    pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;\n    pInfo->aConstraintUsage[iEq].argvIndex = iNext++;\n    pInfo->estimatedCost = 5;\n  }else{\n    pInfo->idxNum = 0;\n    pInfo->estimatedCost = 20000;\n    if( iGe>=0 ){\n      pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;\n      pInfo->aConstraintUsage[iGe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n    if( iLe>=0 ){\n      pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;\n      pInfo->aConstraintUsage[iLe].argvIndex = iNext++;\n      pInfo->estimatedCost /= 2;\n    }\n  }\n  if( iLangid>=0 ){\n    pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;\n    pInfo->estimatedCost--;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3auxOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3auxCursor *pCsr;            /* Pointer to cursor object to return */\n\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3auxCursor *)sqlite3_malloc(sizeof(Fts3auxCursor));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(Fts3auxCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n\n  sqlite3Fts3SegmentsClose(pFts3);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->zStop);\n  sqlite3_free(pCsr->aStat);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){\n  if( nSize>pCsr->nStat ){\n    struct Fts3auxColstats *aNew;\n    aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat, \n        sizeof(struct Fts3auxColstats) * nSize\n    );\n    if( aNew==0 ) return SQLITE_NOMEM;\n    memset(&aNew[pCsr->nStat], 0, \n        sizeof(struct Fts3auxColstats) * (nSize - pCsr->nStat)\n    );\n    pCsr->aStat = aNew;\n    pCsr->nStat = nSize;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n\n  /* Increment our pretend rowid value. */\n  pCsr->iRowid++;\n\n  for(pCsr->iCol++; pCsr->iCol<pCsr->nStat; pCsr->iCol++){\n    if( pCsr->aStat[pCsr->iCol].nDoc>0 ) return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3SegReaderStep(pFts3, &pCsr->csr);\n  if( rc==SQLITE_ROW ){\n    int i = 0;\n    int nDoclist = pCsr->csr.nDoclist;\n    char *aDoclist = pCsr->csr.aDoclist;\n    int iCol;\n\n    int eState = 0;\n\n    if( pCsr->zStop ){\n      int n = (pCsr->nStop<pCsr->csr.nTerm) ? pCsr->nStop : pCsr->csr.nTerm;\n      int mc = memcmp(pCsr->zStop, pCsr->csr.zTerm, n);\n      if( mc<0 || (mc==0 && pCsr->csr.nTerm>pCsr->nStop) ){\n        pCsr->isEof = 1;\n        return SQLITE_OK;\n      }\n    }\n\n    if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM;\n    memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat);\n    iCol = 0;\n\n    while( i<nDoclist ){\n      sqlite3_int64 v = 0;\n\n      i += sqlite3Fts3GetVarint(&aDoclist[i], &v);\n      switch( eState ){\n        /* State 0. In this state the integer just read was a docid. */\n        case 0:\n          pCsr->aStat[0].nDoc++;\n          eState = 1;\n          iCol = 0;\n          break;\n\n        /* State 1. In this state we are expecting either a 1, indicating\n        ** that the following integer will be a column number, or the\n        ** start of a position list for column 0.  \n        ** \n        ** The only difference between state 1 and state 2 is that if the\n        ** integer encountered in state 1 is not 0 or 1, then we need to\n        ** increment the column 0 \"nDoc\" count for this term.\n        */\n        case 1:\n          assert( iCol==0 );\n          if( v>1 ){\n            pCsr->aStat[1].nDoc++;\n          }\n          eState = 2;\n          /* fall through */\n\n        case 2:\n          if( v==0 ){       /* 0x00. Next integer will be a docid. */\n            eState = 0;\n          }else if( v==1 ){ /* 0x01. Next integer will be a column number. */\n            eState = 3;\n          }else{            /* 2 or greater. A position. */\n            pCsr->aStat[iCol+1].nOcc++;\n            pCsr->aStat[0].nOcc++;\n          }\n          break;\n\n        /* State 3. The integer just read is a column number. */\n        default: assert( eState==3 );\n          iCol = (int)v;\n          if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM;\n          pCsr->aStat[iCol+1].nDoc++;\n          eState = 2;\n          break;\n      }\n    }\n\n    pCsr->iCol = 0;\n    rc = SQLITE_OK;\n  }else{\n    pCsr->isEof = 1;\n  }\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3auxFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;\n  int rc;\n  int isScan = 0;\n  int iLangVal = 0;               /* Language id to query */\n\n  int iEq = -1;                   /* Index of term=? value in apVal */\n  int iGe = -1;                   /* Index of term>=? value in apVal */\n  int iLe = -1;                   /* Index of term<=? value in apVal */\n  int iLangid = -1;               /* Index of languageid=? value in apVal */\n  int iNext = 0;\n\n  UNUSED_PARAMETER(nVal);\n  UNUSED_PARAMETER(idxStr);\n\n  assert( idxStr==0 );\n  assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0\n       || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT\n       || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)\n  );\n\n  if( idxNum==FTS4AUX_EQ_CONSTRAINT ){\n    iEq = iNext++;\n  }else{\n    isScan = 1;\n    if( idxNum & FTS4AUX_GE_CONSTRAINT ){\n      iGe = iNext++;\n    }\n    if( idxNum & FTS4AUX_LE_CONSTRAINT ){\n      iLe = iNext++;\n    }\n  }\n  if( iNext<nVal ){\n    iLangid = iNext++;\n  }\n\n  /* In case this cursor is being reused, close and zero it. */\n  testcase(pCsr->filter.zTerm);\n  sqlite3Fts3SegReaderFinish(&pCsr->csr);\n  sqlite3_free((void *)pCsr->filter.zTerm);\n  sqlite3_free(pCsr->aStat);\n  memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);\n\n  pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;\n\n  if( iEq>=0 || iGe>=0 ){\n    const unsigned char *zStr = sqlite3_value_text(apVal[0]);\n    assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );\n    if( zStr ){\n      pCsr->filter.zTerm = sqlite3_mprintf(\"%s\", zStr);\n      pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);\n      if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;\n    }\n  }\n\n  if( iLe>=0 ){\n    pCsr->zStop = sqlite3_mprintf(\"%s\", sqlite3_value_text(apVal[iLe]));\n    pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);\n    if( pCsr->zStop==0 ) return SQLITE_NOMEM;\n  }\n  \n  if( iLangid>=0 ){\n    iLangVal = sqlite3_value_int(apVal[iLangid]);\n\n    /* If the user specified a negative value for the languageid, use zero\n    ** instead. This works, as the \"languageid=?\" constraint will also\n    ** be tested by the VDBE layer. The test will always be false (since\n    ** this module will not return a row with a negative languageid), and\n    ** so the overall query will return zero rows.  */\n    if( iLangVal<0 ) iLangVal = 0;\n  }\n  pCsr->iLangid = iLangVal;\n\n  rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,\n      pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);\n  }\n\n  if( rc==SQLITE_OK ) rc = fts3auxNextMethod(pCursor);\n  return rc;\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3auxEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  return pCsr->isEof;\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3auxColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3auxCursor *p = (Fts3auxCursor *)pCursor;\n\n  assert( p->isEof==0 );\n  switch( iCol ){\n    case 0: /* term */\n      sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);\n      break;\n\n    case 1: /* col */\n      if( p->iCol ){\n        sqlite3_result_int(pCtx, p->iCol-1);\n      }else{\n        sqlite3_result_text(pCtx, \"*\", -1, SQLITE_STATIC);\n      }\n      break;\n\n    case 2: /* documents */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);\n      break;\n\n    case 3: /* occurrences */\n      sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);\n      break;\n\n    default: /* languageid */\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, p->iLangid);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3auxRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3aux module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitAux(sqlite3 *db){\n  static const sqlite3_module fts3aux_module = {\n     0,                           /* iVersion      */\n     fts3auxConnectMethod,        /* xCreate       */\n     fts3auxConnectMethod,        /* xConnect      */\n     fts3auxBestIndexMethod,      /* xBestIndex    */\n     fts3auxDisconnectMethod,     /* xDisconnect   */\n     fts3auxDisconnectMethod,     /* xDestroy      */\n     fts3auxOpenMethod,           /* xOpen         */\n     fts3auxCloseMethod,          /* xClose        */\n     fts3auxFilterMethod,         /* xFilter       */\n     fts3auxNextMethod,           /* xNext         */\n     fts3auxEofMethod,            /* xEof          */\n     fts3auxColumnMethod,         /* xColumn       */\n     fts3auxRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts4aux\", &fts3aux_module, 0);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_aux.c ********************************************/\n/************** Begin file fts3_expr.c ***************************************/\n/*\n** 2008 Nov 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This module contains code that implements a parser for fts3 query strings\n** (the right-hand argument to the MATCH operator). Because the supported \n** syntax is relatively simple, the whole tokenizer/parser system is\n** hand-coded. \n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/*\n** By default, this module parses the legacy syntax that has been \n** traditionally used by fts3. Or, if SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined, then it uses the new syntax. The differences between\n** the new and the old syntaxes are:\n**\n**  a) The new syntax supports parenthesis. The old does not.\n**\n**  b) The new syntax supports the AND and NOT operators. The old does not.\n**\n**  c) The old syntax supports the \"-\" token qualifier. This is not \n**     supported by the new syntax (it is replaced by the NOT operator).\n**\n**  d) When using the old syntax, the OR operator has a greater precedence\n**     than an implicit AND. When using the new, both implicity and explicit\n**     AND operators have a higher precedence than OR.\n**\n** If compiled with SQLITE_TEST defined, then this module exports the\n** symbol \"int sqlite3_fts3_enable_parentheses\". Setting this variable\n** to zero causes the module to use the old syntax. If it is set to \n** non-zero the new syntax is activated. This is so both syntaxes can\n** be tested using a single build of testfixture.\n**\n** The following describes the syntax supported by the fts3 MATCH\n** operator in a similar format to that used by the lemon parser\n** generator. This module does not use actually lemon, it uses a\n** custom parser.\n**\n**   query ::= andexpr (OR andexpr)*.\n**\n**   andexpr ::= notexpr (AND? notexpr)*.\n**\n**   notexpr ::= nearexpr (NOT nearexpr|-TOKEN)*.\n**   notexpr ::= LP query RP.\n**\n**   nearexpr ::= phrase (NEAR distance_opt nearexpr)*.\n**\n**   distance_opt ::= .\n**   distance_opt ::= / INTEGER.\n**\n**   phrase ::= TOKEN.\n**   phrase ::= COLUMN:TOKEN.\n**   phrase ::= \"TOKEN TOKEN TOKEN...\".\n*/\n\n#ifdef SQLITE_TEST\nSQLITE_API int sqlite3_fts3_enable_parentheses = 0;\n#else\n# ifdef SQLITE_ENABLE_FTS3_PARENTHESIS \n#  define sqlite3_fts3_enable_parentheses 1\n# else\n#  define sqlite3_fts3_enable_parentheses 0\n# endif\n#endif\n\n/*\n** Default span for NEAR operators.\n*/\n#define SQLITE_FTS3_DEFAULT_NEAR_PARAM 10\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** isNot:\n**   This variable is used by function getNextNode(). When getNextNode() is\n**   called, it sets ParseContext.isNot to true if the 'next node' is a \n**   FTSQUERY_PHRASE with a unary \"-\" attached to it. i.e. \"mysql\" in the\n**   FTS3 query \"sqlite -mysql\". Otherwise, ParseContext.isNot is set to\n**   zero.\n*/\ntypedef struct ParseContext ParseContext;\nstruct ParseContext {\n  sqlite3_tokenizer *pTokenizer;      /* Tokenizer module */\n  int iLangid;                        /* Language id used with tokenizer */\n  const char **azCol;                 /* Array of column names for fts3 table */\n  int bFts4;                          /* True to allow FTS4-only syntax */\n  int nCol;                           /* Number of entries in azCol[] */\n  int iDefaultCol;                    /* Default column to query */\n  int isNot;                          /* True if getNextNode() sees a unary - */\n  sqlite3_context *pCtx;              /* Write error message here */\n  int nNest;                          /* Number of nested brackets */\n};\n\n/*\n** This function is equivalent to the standard isspace() function. \n**\n** The standard isspace() can be awkward to use safely, because although it\n** is defined to accept an argument of type int, its behavior when passed\n** an integer that falls outside of the range of the unsigned char type\n** is undefined (and sometimes, \"undefined\" means segfault). This wrapper\n** is defined to accept an argument of type char, and always returns 0 for\n** any values that fall outside of the range of the unsigned char type (i.e.\n** negative values).\n*/\nstatic int fts3isspace(char c){\n  return c==' ' || c=='\\t' || c=='\\n' || c=='\\r' || c=='\\v' || c=='\\f';\n}\n\n/*\n** Allocate nByte bytes of memory using sqlite3_malloc(). If successful,\n** zero the memory before returning a pointer to it. If unsuccessful, \n** return NULL.\n*/\nstatic void *fts3MallocZero(int nByte){\n  void *pRet = sqlite3_malloc(nByte);\n  if( pRet ) memset(pRet, 0, nByte);\n  return pRet;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(\n  sqlite3_tokenizer *pTokenizer,\n  int iLangid,\n  const char *z,\n  int n,\n  sqlite3_tokenizer_cursor **ppCsr\n){\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n  int rc;\n\n  rc = pModule->xOpen(pTokenizer, z, n, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( rc==SQLITE_OK ){\n    pCsr->pTokenizer = pTokenizer;\n    if( pModule->iVersion>=1 ){\n      rc = pModule->xLanguageid(pCsr, iLangid);\n      if( rc!=SQLITE_OK ){\n        pModule->xClose(pCsr);\n        pCsr = 0;\n      }\n    }\n  }\n  *ppCsr = pCsr;\n  return rc;\n}\n\n/*\n** Function getNextNode(), which is called by fts3ExprParse(), may itself\n** call fts3ExprParse(). So this forward declaration is required.\n*/\nstatic int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *);\n\n/*\n** Extract the next token from buffer z (length n) using the tokenizer\n** and other information (column names etc.) in pParse. Create an Fts3Expr\n** structure of type FTSQUERY_PHRASE containing a phrase consisting of this\n** single token and set *ppExpr to point to it. If the end of the buffer is\n** reached before a token is found, set *ppExpr to zero. It is the\n** responsibility of the caller to eventually deallocate the allocated \n** Fts3Expr structure (if any) by passing it to sqlite3_free().\n**\n** Return SQLITE_OK if successful, or SQLITE_NOMEM if a memory allocation\n** fails.\n*/\nstatic int getNextToken(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  int iCol,                               /* Value for Fts3Phrase.iColumn */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  sqlite3_tokenizer_cursor *pCursor;\n  Fts3Expr *pRet = 0;\n  int i = 0;\n\n  /* Set variable i to the maximum number of bytes of input to tokenize. */\n  for(i=0; i<n; i++){\n    if( sqlite3_fts3_enable_parentheses && (z[i]=='(' || z[i]==')') ) break;\n    if( z[i]=='\"' ) break;\n  }\n\n  *pnConsumed = i;\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor);\n  if( rc==SQLITE_OK ){\n    const char *zToken;\n    int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;\n    int nByte;                               /* total space to allocate */\n\n    rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);\n    if( rc==SQLITE_OK ){\n      nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;\n      pRet = (Fts3Expr *)fts3MallocZero(nByte);\n      if( !pRet ){\n        rc = SQLITE_NOMEM;\n      }else{\n        pRet->eType = FTSQUERY_PHRASE;\n        pRet->pPhrase = (Fts3Phrase *)&pRet[1];\n        pRet->pPhrase->nToken = 1;\n        pRet->pPhrase->iColumn = iCol;\n        pRet->pPhrase->aToken[0].n = nToken;\n        pRet->pPhrase->aToken[0].z = (char *)&pRet->pPhrase[1];\n        memcpy(pRet->pPhrase->aToken[0].z, zToken, nToken);\n\n        if( iEnd<n && z[iEnd]=='*' ){\n          pRet->pPhrase->aToken[0].isPrefix = 1;\n          iEnd++;\n        }\n\n        while( 1 ){\n          if( !sqlite3_fts3_enable_parentheses \n           && iStart>0 && z[iStart-1]=='-' \n          ){\n            pParse->isNot = 1;\n            iStart--;\n          }else if( pParse->bFts4 && iStart>0 && z[iStart-1]=='^' ){\n            pRet->pPhrase->aToken[0].bFirst = 1;\n            iStart--;\n          }else{\n            break;\n          }\n        }\n\n      }\n      *pnConsumed = iEnd;\n    }else if( i && rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pModule->xClose(pCursor);\n  }\n  \n  *ppExpr = pRet;\n  return rc;\n}\n\n\n/*\n** Enlarge a memory allocation.  If an out-of-memory allocation occurs,\n** then free the old allocation.\n*/\nstatic void *fts3ReallocOrFree(void *pOrig, int nNew){\n  void *pRet = sqlite3_realloc(pOrig, nNew);\n  if( !pRet ){\n    sqlite3_free(pOrig);\n  }\n  return pRet;\n}\n\n/*\n** Buffer zInput, length nInput, contains the contents of a quoted string\n** that appeared as part of an fts3 query expression. Neither quote character\n** is included in the buffer. This function attempts to tokenize the entire\n** input buffer and create an Fts3Expr structure of type FTSQUERY_PHRASE \n** containing the results.\n**\n** If successful, SQLITE_OK is returned and *ppExpr set to point at the\n** allocated Fts3Expr structure. Otherwise, either SQLITE_NOMEM (out of memory\n** error) or SQLITE_ERROR (tokenization error) is returned and *ppExpr set\n** to 0.\n*/\nstatic int getNextString(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *zInput, int nInput,         /* Input string */\n  Fts3Expr **ppExpr                       /* OUT: expression */\n){\n  sqlite3_tokenizer *pTokenizer = pParse->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  int rc;\n  Fts3Expr *p = 0;\n  sqlite3_tokenizer_cursor *pCursor = 0;\n  char *zTemp = 0;\n  int nTemp = 0;\n\n  const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);\n  int nToken = 0;\n\n  /* The final Fts3Expr data structure, including the Fts3Phrase,\n  ** Fts3PhraseToken structures token buffers are all stored as a single \n  ** allocation so that the expression can be freed with a single call to\n  ** sqlite3_free(). Setting this up requires a two pass approach.\n  **\n  ** The first pass, in the block below, uses a tokenizer cursor to iterate\n  ** through the tokens in the expression. This pass uses fts3ReallocOrFree()\n  ** to assemble data in two dynamic buffers:\n  **\n  **   Buffer p: Points to the Fts3Expr structure, followed by the Fts3Phrase\n  **             structure, followed by the array of Fts3PhraseToken \n  **             structures. This pass only populates the Fts3PhraseToken array.\n  **\n  **   Buffer zTemp: Contains copies of all tokens.\n  **\n  ** The second pass, in the block that begins \"if( rc==SQLITE_DONE )\" below,\n  ** appends buffer zTemp to buffer p, and fills in the Fts3Expr and Fts3Phrase\n  ** structures.\n  */\n  rc = sqlite3Fts3OpenTokenizer(\n      pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);\n  if( rc==SQLITE_OK ){\n    int ii;\n    for(ii=0; rc==SQLITE_OK; ii++){\n      const char *zByte;\n      int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;\n      rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);\n      if( rc==SQLITE_OK ){\n        Fts3PhraseToken *pToken;\n\n        p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));\n        if( !p ) goto no_mem;\n\n        zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);\n        if( !zTemp ) goto no_mem;\n\n        assert( nToken==ii );\n        pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];\n        memset(pToken, 0, sizeof(Fts3PhraseToken));\n\n        memcpy(&zTemp[nTemp], zByte, nByte);\n        nTemp += nByte;\n\n        pToken->n = nByte;\n        pToken->isPrefix = (iEnd<nInput && zInput[iEnd]=='*');\n        pToken->bFirst = (iBegin>0 && zInput[iBegin-1]=='^');\n        nToken = ii+1;\n      }\n    }\n\n    pModule->xClose(pCursor);\n    pCursor = 0;\n  }\n\n  if( rc==SQLITE_DONE ){\n    int jj;\n    char *zBuf = 0;\n\n    p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);\n    if( !p ) goto no_mem;\n    memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);\n    p->eType = FTSQUERY_PHRASE;\n    p->pPhrase = (Fts3Phrase *)&p[1];\n    p->pPhrase->iColumn = pParse->iDefaultCol;\n    p->pPhrase->nToken = nToken;\n\n    zBuf = (char *)&p->pPhrase->aToken[nToken];\n    if( zTemp ){\n      memcpy(zBuf, zTemp, nTemp);\n      sqlite3_free(zTemp);\n    }else{\n      assert( nTemp==0 );\n    }\n\n    for(jj=0; jj<p->pPhrase->nToken; jj++){\n      p->pPhrase->aToken[jj].z = zBuf;\n      zBuf += p->pPhrase->aToken[jj].n;\n    }\n    rc = SQLITE_OK;\n  }\n\n  *ppExpr = p;\n  return rc;\nno_mem:\n\n  if( pCursor ){\n    pModule->xClose(pCursor);\n  }\n  sqlite3_free(zTemp);\n  sqlite3_free(p);\n  *ppExpr = 0;\n  return SQLITE_NOMEM;\n}\n\n/*\n** The output variable *ppExpr is populated with an allocated Fts3Expr \n** structure, or set to 0 if the end of the input buffer is reached.\n**\n** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM\n** if a malloc failure occurs, or SQLITE_ERROR if a parse error is encountered.\n** If SQLITE_ERROR is returned, pContext is populated with an error message.\n*/\nstatic int getNextNode(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Input string */\n  Fts3Expr **ppExpr,                      /* OUT: expression */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  static const struct Fts3Keyword {\n    char *z;                              /* Keyword text */\n    unsigned char n;                      /* Length of the keyword */\n    unsigned char parenOnly;              /* Only valid in paren mode */\n    unsigned char eType;                  /* Keyword code */\n  } aKeyword[] = {\n    { \"OR\" ,  2, 0, FTSQUERY_OR   },\n    { \"AND\",  3, 1, FTSQUERY_AND  },\n    { \"NOT\",  3, 1, FTSQUERY_NOT  },\n    { \"NEAR\", 4, 0, FTSQUERY_NEAR }\n  };\n  int ii;\n  int iCol;\n  int iColLen;\n  int rc;\n  Fts3Expr *pRet = 0;\n\n  const char *zInput = z;\n  int nInput = n;\n\n  pParse->isNot = 0;\n\n  /* Skip over any whitespace before checking for a keyword, an open or\n  ** close bracket, or a quoted string. \n  */\n  while( nInput>0 && fts3isspace(*zInput) ){\n    nInput--;\n    zInput++;\n  }\n  if( nInput==0 ){\n    return SQLITE_DONE;\n  }\n\n  /* See if we are dealing with a keyword. */\n  for(ii=0; ii<(int)(sizeof(aKeyword)/sizeof(struct Fts3Keyword)); ii++){\n    const struct Fts3Keyword *pKey = &aKeyword[ii];\n\n    if( (pKey->parenOnly & ~sqlite3_fts3_enable_parentheses)!=0 ){\n      continue;\n    }\n\n    if( nInput>=pKey->n && 0==memcmp(zInput, pKey->z, pKey->n) ){\n      int nNear = SQLITE_FTS3_DEFAULT_NEAR_PARAM;\n      int nKey = pKey->n;\n      char cNext;\n\n      /* If this is a \"NEAR\" keyword, check for an explicit nearness. */\n      if( pKey->eType==FTSQUERY_NEAR ){\n        assert( nKey==4 );\n        if( zInput[4]=='/' && zInput[5]>='0' && zInput[5]<='9' ){\n          nNear = 0;\n          for(nKey=5; zInput[nKey]>='0' && zInput[nKey]<='9'; nKey++){\n            nNear = nNear * 10 + (zInput[nKey] - '0');\n          }\n        }\n      }\n\n      /* At this point this is probably a keyword. But for that to be true,\n      ** the next byte must contain either whitespace, an open or close\n      ** parenthesis, a quote character, or EOF. \n      */\n      cNext = zInput[nKey];\n      if( fts3isspace(cNext) \n       || cNext=='\"' || cNext=='(' || cNext==')' || cNext==0\n      ){\n        pRet = (Fts3Expr *)fts3MallocZero(sizeof(Fts3Expr));\n        if( !pRet ){\n          return SQLITE_NOMEM;\n        }\n        pRet->eType = pKey->eType;\n        pRet->nNear = nNear;\n        *ppExpr = pRet;\n        *pnConsumed = (int)((zInput - z) + nKey);\n        return SQLITE_OK;\n      }\n\n      /* Turns out that wasn't a keyword after all. This happens if the\n      ** user has supplied a token such as \"ORacle\". Continue.\n      */\n    }\n  }\n\n  /* See if we are dealing with a quoted phrase. If this is the case, then\n  ** search for the closing quote and pass the whole string to getNextString()\n  ** for processing. This is easy to do, as fts3 has no syntax for escaping\n  ** a quote character embedded in a string.\n  */\n  if( *zInput=='\"' ){\n    for(ii=1; ii<nInput && zInput[ii]!='\"'; ii++);\n    *pnConsumed = (int)((zInput - z) + ii + 1);\n    if( ii==nInput ){\n      return SQLITE_ERROR;\n    }\n    return getNextString(pParse, &zInput[1], ii-1, ppExpr);\n  }\n\n  if( sqlite3_fts3_enable_parentheses ){\n    if( *zInput=='(' ){\n      int nConsumed = 0;\n      pParse->nNest++;\n      rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);\n      if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; }\n      *pnConsumed = (int)(zInput - z) + 1 + nConsumed;\n      return rc;\n    }else if( *zInput==')' ){\n      pParse->nNest--;\n      *pnConsumed = (int)((zInput - z) + 1);\n      *ppExpr = 0;\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If control flows to this point, this must be a regular token, or \n  ** the end of the input. Read a regular token using the sqlite3_tokenizer\n  ** interface. Before doing so, figure out if there is an explicit\n  ** column specifier for the token. \n  **\n  ** TODO: Strangely, it is not possible to associate a column specifier\n  ** with a quoted phrase, only with a single token. Not sure if this was\n  ** an implementation artifact or an intentional decision when fts3 was\n  ** first implemented. Whichever it was, this module duplicates the \n  ** limitation.\n  */\n  iCol = pParse->iDefaultCol;\n  iColLen = 0;\n  for(ii=0; ii<pParse->nCol; ii++){\n    const char *zStr = pParse->azCol[ii];\n    int nStr = (int)strlen(zStr);\n    if( nInput>nStr && zInput[nStr]==':' \n     && sqlite3_strnicmp(zStr, zInput, nStr)==0 \n    ){\n      iCol = ii;\n      iColLen = (int)((zInput - z) + nStr + 1);\n      break;\n    }\n  }\n  rc = getNextToken(pParse, iCol, &z[iColLen], n-iColLen, ppExpr, pnConsumed);\n  *pnConsumed += iColLen;\n  return rc;\n}\n\n/*\n** The argument is an Fts3Expr structure for a binary operator (any type\n** except an FTSQUERY_PHRASE). Return an integer value representing the\n** precedence of the operator. Lower values have a higher precedence (i.e.\n** group more tightly). For example, in the C language, the == operator\n** groups more tightly than ||, and would therefore have a higher precedence.\n**\n** When using the new fts3 query syntax (when SQLITE_ENABLE_FTS3_PARENTHESIS\n** is defined), the order of the operators in precedence from highest to\n** lowest is:\n**\n**   NEAR\n**   NOT\n**   AND (including implicit ANDs)\n**   OR\n**\n** Note that when using the old query syntax, the OR operator has a higher\n** precedence than the AND operator.\n*/\nstatic int opPrecedence(Fts3Expr *p){\n  assert( p->eType!=FTSQUERY_PHRASE );\n  if( sqlite3_fts3_enable_parentheses ){\n    return p->eType;\n  }else if( p->eType==FTSQUERY_NEAR ){\n    return 1;\n  }else if( p->eType==FTSQUERY_OR ){\n    return 2;\n  }\n  assert( p->eType==FTSQUERY_AND );\n  return 3;\n}\n\n/*\n** Argument ppHead contains a pointer to the current head of a query \n** expression tree being parsed. pPrev is the expression node most recently\n** inserted into the tree. This function adds pNew, which is always a binary\n** operator node, into the expression tree based on the relative precedence\n** of pNew and the existing nodes of the tree. This may result in the head\n** of the tree changing, in which case *ppHead is set to the new root node.\n*/\nstatic void insertBinaryOperator(\n  Fts3Expr **ppHead,       /* Pointer to the root node of a tree */\n  Fts3Expr *pPrev,         /* Node most recently inserted into the tree */\n  Fts3Expr *pNew           /* New binary node to insert into expression tree */\n){\n  Fts3Expr *pSplit = pPrev;\n  while( pSplit->pParent && opPrecedence(pSplit->pParent)<=opPrecedence(pNew) ){\n    pSplit = pSplit->pParent;\n  }\n\n  if( pSplit->pParent ){\n    assert( pSplit->pParent->pRight==pSplit );\n    pSplit->pParent->pRight = pNew;\n    pNew->pParent = pSplit->pParent;\n  }else{\n    *ppHead = pNew;\n  }\n  pNew->pLeft = pSplit;\n  pSplit->pParent = pNew;\n}\n\n/*\n** Parse the fts3 query expression found in buffer z, length n. This function\n** returns either when the end of the buffer is reached or an unmatched \n** closing bracket - ')' - is encountered.\n**\n** If successful, SQLITE_OK is returned, *ppExpr is set to point to the\n** parsed form of the expression and *pnConsumed is set to the number of\n** bytes read from buffer z. Otherwise, *ppExpr is set to 0 and SQLITE_NOMEM\n** (out of memory error) or SQLITE_ERROR (parse error) is returned.\n*/\nstatic int fts3ExprParse(\n  ParseContext *pParse,                   /* fts3 query parse context */\n  const char *z, int n,                   /* Text of MATCH query */\n  Fts3Expr **ppExpr,                      /* OUT: Parsed query structure */\n  int *pnConsumed                         /* OUT: Number of bytes consumed */\n){\n  Fts3Expr *pRet = 0;\n  Fts3Expr *pPrev = 0;\n  Fts3Expr *pNotBranch = 0;               /* Only used in legacy parse mode */\n  int nIn = n;\n  const char *zIn = z;\n  int rc = SQLITE_OK;\n  int isRequirePhrase = 1;\n\n  while( rc==SQLITE_OK ){\n    Fts3Expr *p = 0;\n    int nByte = 0;\n\n    rc = getNextNode(pParse, zIn, nIn, &p, &nByte);\n    assert( nByte>0 || (rc!=SQLITE_OK && p==0) );\n    if( rc==SQLITE_OK ){\n      if( p ){\n        int isPhrase;\n\n        if( !sqlite3_fts3_enable_parentheses \n            && p->eType==FTSQUERY_PHRASE && pParse->isNot \n        ){\n          /* Create an implicit NOT operator. */\n          Fts3Expr *pNot = fts3MallocZero(sizeof(Fts3Expr));\n          if( !pNot ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_NOMEM;\n            goto exprparse_out;\n          }\n          pNot->eType = FTSQUERY_NOT;\n          pNot->pRight = p;\n          p->pParent = pNot;\n          if( pNotBranch ){\n            pNot->pLeft = pNotBranch;\n            pNotBranch->pParent = pNot;\n          }\n          pNotBranch = pNot;\n          p = pPrev;\n        }else{\n          int eType = p->eType;\n          isPhrase = (eType==FTSQUERY_PHRASE || p->pLeft);\n\n          /* The isRequirePhrase variable is set to true if a phrase or\n          ** an expression contained in parenthesis is required. If a\n          ** binary operator (AND, OR, NOT or NEAR) is encounted when\n          ** isRequirePhrase is set, this is a syntax error.\n          */\n          if( !isPhrase && isRequirePhrase ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase && !isRequirePhrase ){\n            /* Insert an implicit AND operator. */\n            Fts3Expr *pAnd;\n            assert( pRet && pPrev );\n            pAnd = fts3MallocZero(sizeof(Fts3Expr));\n            if( !pAnd ){\n              sqlite3Fts3ExprFree(p);\n              rc = SQLITE_NOMEM;\n              goto exprparse_out;\n            }\n            pAnd->eType = FTSQUERY_AND;\n            insertBinaryOperator(&pRet, pPrev, pAnd);\n            pPrev = pAnd;\n          }\n\n          /* This test catches attempts to make either operand of a NEAR\n           ** operator something other than a phrase. For example, either of\n           ** the following:\n           **\n           **    (bracketed expression) NEAR phrase\n           **    phrase NEAR (bracketed expression)\n           **\n           ** Return an error in either case.\n           */\n          if( pPrev && (\n            (eType==FTSQUERY_NEAR && !isPhrase && pPrev->eType!=FTSQUERY_PHRASE)\n         || (eType!=FTSQUERY_PHRASE && isPhrase && pPrev->eType==FTSQUERY_NEAR)\n          )){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_ERROR;\n            goto exprparse_out;\n          }\n\n          if( isPhrase ){\n            if( pRet ){\n              assert( pPrev && pPrev->pLeft && pPrev->pRight==0 );\n              pPrev->pRight = p;\n              p->pParent = pPrev;\n            }else{\n              pRet = p;\n            }\n          }else{\n            insertBinaryOperator(&pRet, pPrev, p);\n          }\n          isRequirePhrase = !isPhrase;\n        }\n        pPrev = p;\n      }\n      assert( nByte>0 );\n    }\n    assert( rc!=SQLITE_OK || (nByte>0 && nByte<=nIn) );\n    nIn -= nByte;\n    zIn += nByte;\n  }\n\n  if( rc==SQLITE_DONE && pRet && isRequirePhrase ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    if( !sqlite3_fts3_enable_parentheses && pNotBranch ){\n      if( !pRet ){\n        rc = SQLITE_ERROR;\n      }else{\n        Fts3Expr *pIter = pNotBranch;\n        while( pIter->pLeft ){\n          pIter = pIter->pLeft;\n        }\n        pIter->pLeft = pRet;\n        pRet->pParent = pIter;\n        pRet = pNotBranch;\n      }\n    }\n  }\n  *pnConsumed = n - nIn;\n\nexprparse_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRet);\n    sqlite3Fts3ExprFree(pNotBranch);\n    pRet = 0;\n  }\n  *ppExpr = pRet;\n  return rc;\n}\n\n/*\n** Return SQLITE_ERROR if the maximum depth of the expression tree passed \n** as the only argument is more than nMaxDepth.\n*/\nstatic int fts3ExprCheckDepth(Fts3Expr *p, int nMaxDepth){\n  int rc = SQLITE_OK;\n  if( p ){\n    if( nMaxDepth<0 ){ \n      rc = SQLITE_TOOBIG;\n    }else{\n      rc = fts3ExprCheckDepth(p->pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprCheckDepth(p->pRight, nMaxDepth-1);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** This function attempts to transform the expression tree at (*pp) to\n** an equivalent but more balanced form. The tree is modified in place.\n** If successful, SQLITE_OK is returned and (*pp) set to point to the \n** new root expression node. \n**\n** nMaxDepth is the maximum allowable depth of the balanced sub-tree.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and \n** expression (*pp) freed.\n*/\nstatic int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts3Expr *pRoot = *pp;          /* Initial root node */\n  Fts3Expr *pFree = 0;            /* List of free nodes. Linked by pParent. */\n  int eType = pRoot->eType;       /* Type of node in this tree */\n\n  if( nMaxDepth==0 ){\n    rc = SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){\n      Fts3Expr **apLeaf;\n      apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);\n      if( 0==apLeaf ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(apLeaf, 0, sizeof(Fts3Expr *) * nMaxDepth);\n      }\n\n      if( rc==SQLITE_OK ){\n        int i;\n        Fts3Expr *p;\n\n        /* Set $p to point to the left-most leaf in the tree of eType nodes. */\n        for(p=pRoot; p->eType==eType; p=p->pLeft){\n          assert( p->pParent==0 || p->pParent->pLeft==p );\n          assert( p->pLeft && p->pRight );\n        }\n\n        /* This loop runs once for each leaf in the tree of eType nodes. */\n        while( 1 ){\n          int iLvl;\n          Fts3Expr *pParent = p->pParent;     /* Current parent of p */\n\n          assert( pParent==0 || pParent->pLeft==p );\n          p->pParent = 0;\n          if( pParent ){\n            pParent->pLeft = 0;\n          }else{\n            pRoot = 0;\n          }\n          rc = fts3ExprBalance(&p, nMaxDepth-1);\n          if( rc!=SQLITE_OK ) break;\n\n          for(iLvl=0; p && iLvl<nMaxDepth; iLvl++){\n            if( apLeaf[iLvl]==0 ){\n              apLeaf[iLvl] = p;\n              p = 0;\n            }else{\n              assert( pFree );\n              pFree->pLeft = apLeaf[iLvl];\n              pFree->pRight = p;\n              pFree->pLeft->pParent = pFree;\n              pFree->pRight->pParent = pFree;\n\n              p = pFree;\n              pFree = pFree->pParent;\n              p->pParent = 0;\n              apLeaf[iLvl] = 0;\n            }\n          }\n          if( p ){\n            sqlite3Fts3ExprFree(p);\n            rc = SQLITE_TOOBIG;\n            break;\n          }\n\n          /* If that was the last leaf node, break out of the loop */\n          if( pParent==0 ) break;\n\n          /* Set $p to point to the next leaf in the tree of eType nodes */\n          for(p=pParent->pRight; p->eType==eType; p=p->pLeft);\n\n          /* Remove pParent from the original tree. */\n          assert( pParent->pParent==0 || pParent->pParent->pLeft==pParent );\n          pParent->pRight->pParent = pParent->pParent;\n          if( pParent->pParent ){\n            pParent->pParent->pLeft = pParent->pRight;\n          }else{\n            assert( pParent==pRoot );\n            pRoot = pParent->pRight;\n          }\n\n          /* Link pParent into the free node list. It will be used as an\n          ** internal node of the new tree.  */\n          pParent->pParent = pFree;\n          pFree = pParent;\n        }\n\n        if( rc==SQLITE_OK ){\n          p = 0;\n          for(i=0; i<nMaxDepth; i++){\n            if( apLeaf[i] ){\n              if( p==0 ){\n                p = apLeaf[i];\n                p->pParent = 0;\n              }else{\n                assert( pFree!=0 );\n                pFree->pRight = p;\n                pFree->pLeft = apLeaf[i];\n                pFree->pLeft->pParent = pFree;\n                pFree->pRight->pParent = pFree;\n\n                p = pFree;\n                pFree = pFree->pParent;\n                p->pParent = 0;\n              }\n            }\n          }\n          pRoot = p;\n        }else{\n          /* An error occurred. Delete the contents of the apLeaf[] array \n          ** and pFree list. Everything else is cleaned up by the call to\n          ** sqlite3Fts3ExprFree(pRoot) below.  */\n          Fts3Expr *pDel;\n          for(i=0; i<nMaxDepth; i++){\n            sqlite3Fts3ExprFree(apLeaf[i]);\n          }\n          while( (pDel=pFree)!=0 ){\n            pFree = pDel->pParent;\n            sqlite3_free(pDel);\n          }\n        }\n\n        assert( pFree==0 );\n        sqlite3_free( apLeaf );\n      }\n    }else if( eType==FTSQUERY_NOT ){\n      Fts3Expr *pLeft = pRoot->pLeft;\n      Fts3Expr *pRight = pRoot->pRight;\n\n      pRoot->pLeft = 0;\n      pRoot->pRight = 0;\n      pLeft->pParent = 0;\n      pRight->pParent = 0;\n\n      rc = fts3ExprBalance(&pLeft, nMaxDepth-1);\n      if( rc==SQLITE_OK ){\n        rc = fts3ExprBalance(&pRight, nMaxDepth-1);\n      }\n\n      if( rc!=SQLITE_OK ){\n        sqlite3Fts3ExprFree(pRight);\n        sqlite3Fts3ExprFree(pLeft);\n      }else{\n        assert( pLeft && pRight );\n        pRoot->pLeft = pLeft;\n        pLeft->pParent = pRoot;\n        pRoot->pRight = pRight;\n        pRight->pParent = pRoot;\n      }\n    }\n  }\n  \n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(pRoot);\n    pRoot = 0;\n  }\n  *pp = pRoot;\n  return rc;\n}\n\n/*\n** This function is similar to sqlite3Fts3ExprParse(), with the following\n** differences:\n**\n**   1. It does not do expression rebalancing.\n**   2. It does not check that the expression does not exceed the \n**      maximum allowable depth.\n**   3. Even if it fails, *ppExpr may still be set to point to an \n**      expression tree. It should be deleted using sqlite3Fts3ExprFree()\n**      in this case.\n*/\nstatic int fts3ExprParseUnbalanced(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr                   /* OUT: Parsed query structure */\n){\n  int nParsed;\n  int rc;\n  ParseContext sParse;\n\n  memset(&sParse, 0, sizeof(ParseContext));\n  sParse.pTokenizer = pTokenizer;\n  sParse.iLangid = iLangid;\n  sParse.azCol = (const char **)azCol;\n  sParse.nCol = nCol;\n  sParse.iDefaultCol = iDefaultCol;\n  sParse.bFts4 = bFts4;\n  if( z==0 ){\n    *ppExpr = 0;\n    return SQLITE_OK;\n  }\n  if( n<0 ){\n    n = (int)strlen(z);\n  }\n  rc = fts3ExprParse(&sParse, z, n, ppExpr, &nParsed);\n  assert( rc==SQLITE_OK || *ppExpr==0 );\n\n  /* Check for mismatched parenthesis */\n  if( rc==SQLITE_OK && sParse.nNest ){\n    rc = SQLITE_ERROR;\n  }\n  \n  return rc;\n}\n\n/*\n** Parameters z and n contain a pointer to and length of a buffer containing\n** an fts3 query expression, respectively. This function attempts to parse the\n** query expression and create a tree of Fts3Expr structures representing the\n** parsed expression. If successful, *ppExpr is set to point to the head\n** of the parsed expression tree and SQLITE_OK is returned. If an error\n** occurs, either SQLITE_NOMEM (out-of-memory error) or SQLITE_ERROR (parse\n** error) is returned and *ppExpr is set to 0.\n**\n** If parameter n is a negative number, then z is assumed to point to a\n** nul-terminated string and the length is determined using strlen().\n**\n** The first parameter, pTokenizer, is passed the fts3 tokenizer module to\n** use to normalize query tokens while parsing the expression. The azCol[]\n** array, which is assumed to contain nCol entries, should contain the names\n** of each column in the target fts3 table, in order from left to right. \n** Column names must be nul-terminated strings.\n**\n** The iDefaultCol parameter should be passed the index of the table column\n** that appears on the left-hand-side of the MATCH operator (the default\n** column to match against for tokens for which a column name is not explicitly\n** specified as part of the query string), or -1 if tokens may by default\n** match any table column.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprParse(\n  sqlite3_tokenizer *pTokenizer,      /* Tokenizer module */\n  int iLangid,                        /* Language id for tokenizer */\n  char **azCol,                       /* Array of column names for fts3 table */\n  int bFts4,                          /* True to allow FTS4-only syntax */\n  int nCol,                           /* Number of entries in azCol[] */\n  int iDefaultCol,                    /* Default column to query */\n  const char *z, int n,               /* Text of MATCH query */\n  Fts3Expr **ppExpr,                  /* OUT: Parsed query structure */\n  char **pzErr                        /* OUT: Error message (sqlite3_malloc) */\n){\n  int rc = fts3ExprParseUnbalanced(\n      pTokenizer, iLangid, azCol, bFts4, nCol, iDefaultCol, z, n, ppExpr\n  );\n  \n  /* Rebalance the expression. And check that its depth does not exceed\n  ** SQLITE_FTS3_MAX_EXPR_DEPTH.  */\n  if( rc==SQLITE_OK && *ppExpr ){\n    rc = fts3ExprBalance(ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    if( rc==SQLITE_OK ){\n      rc = fts3ExprCheckDepth(*ppExpr, SQLITE_FTS3_MAX_EXPR_DEPTH);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts3ExprFree(*ppExpr);\n    *ppExpr = 0;\n    if( rc==SQLITE_TOOBIG ){\n      sqlite3Fts3ErrMsg(pzErr,\n          \"FTS expression tree is too large (maximum depth %d)\", \n          SQLITE_FTS3_MAX_EXPR_DEPTH\n      );\n      rc = SQLITE_ERROR;\n    }else if( rc==SQLITE_ERROR ){\n      sqlite3Fts3ErrMsg(pzErr, \"malformed MATCH expression: [%s]\", z);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free a single node of an expression tree.\n*/\nstatic void fts3FreeExprNode(Fts3Expr *p){\n  assert( p->eType==FTSQUERY_PHRASE || p->pPhrase==0 );\n  sqlite3Fts3EvalPhraseCleanup(p->pPhrase);\n  sqlite3_free(p->aMI);\n  sqlite3_free(p);\n}\n\n/*\n** Free a parsed fts3 query expression allocated by sqlite3Fts3ExprParse().\n**\n** This function would be simpler if it recursively called itself. But\n** that would mean passing a sufficiently large expression to ExprParse()\n** could cause a stack overflow.\n*/\nSQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *pDel){\n  Fts3Expr *p;\n  assert( pDel==0 || pDel->pParent==0 );\n  for(p=pDel; p && (p->pLeft||p->pRight); p=(p->pLeft ? p->pLeft : p->pRight)){\n    assert( p->pParent==0 || p==p->pParent->pRight || p==p->pParent->pLeft );\n  }\n  while( p ){\n    Fts3Expr *pParent = p->pParent;\n    fts3FreeExprNode(p);\n    if( pParent && p==pParent->pLeft && pParent->pRight ){\n      p = pParent->pRight;\n      while( p && (p->pLeft || p->pRight) ){\n        assert( p==p->pParent->pRight || p==p->pParent->pLeft );\n        p = (p->pLeft ? p->pLeft : p->pRight);\n      }\n    }else{\n      p = pParent;\n    }\n  }\n}\n\n/****************************************************************************\n*****************************************************************************\n** Everything after this point is just test code.\n*/\n\n#ifdef SQLITE_TEST\n\n/* #include <stdio.h> */\n\n/*\n** Function to query the hash-table of tokenizers (see README.tokenizers).\n*/\nstatic int queryTestTokenizer(\n  sqlite3 *db, \n  const char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\n/*\n** Return a pointer to a buffer containing a text representation of the\n** expression passed as the first argument. The buffer is obtained from\n** sqlite3_malloc(). It is the responsibility of the caller to use \n** sqlite3_free() to release the memory. If an OOM condition is encountered,\n** NULL is returned.\n**\n** If the second argument is not NULL, then its contents are prepended to \n** the returned expression text and then freed using sqlite3_free().\n*/\nstatic char *exprToString(Fts3Expr *pExpr, char *zBuf){\n  if( pExpr==0 ){\n    return sqlite3_mprintf(\"\");\n  }\n  switch( pExpr->eType ){\n    case FTSQUERY_PHRASE: {\n      Fts3Phrase *pPhrase = pExpr->pPhrase;\n      int i;\n      zBuf = sqlite3_mprintf(\n          \"%zPHRASE %d 0\", zBuf, pPhrase->iColumn);\n      for(i=0; zBuf && i<pPhrase->nToken; i++){\n        zBuf = sqlite3_mprintf(\"%z %.*s%s\", zBuf, \n            pPhrase->aToken[i].n, pPhrase->aToken[i].z,\n            (pPhrase->aToken[i].isPrefix?\"+\":\"\")\n        );\n      }\n      return zBuf;\n    }\n\n    case FTSQUERY_NEAR:\n      zBuf = sqlite3_mprintf(\"%zNEAR/%d \", zBuf, pExpr->nNear);\n      break;\n    case FTSQUERY_NOT:\n      zBuf = sqlite3_mprintf(\"%zNOT \", zBuf);\n      break;\n    case FTSQUERY_AND:\n      zBuf = sqlite3_mprintf(\"%zAND \", zBuf);\n      break;\n    case FTSQUERY_OR:\n      zBuf = sqlite3_mprintf(\"%zOR \", zBuf);\n      break;\n  }\n\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z{\", zBuf);\n  if( zBuf ) zBuf = exprToString(pExpr->pLeft, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z} {\", zBuf);\n\n  if( zBuf ) zBuf = exprToString(pExpr->pRight, zBuf);\n  if( zBuf ) zBuf = sqlite3_mprintf(\"%z}\", zBuf);\n\n  return zBuf;\n}\n\n/*\n** This is the implementation of a scalar SQL function used to test the \n** expression parser. It should be called as follows:\n**\n**   fts3_exprtest(<tokenizer>, <expr>, <column 1>, ...);\n**\n** The first argument, <tokenizer>, is the name of the fts3 tokenizer used\n** to parse the query expression (see README.tokenizers). The second argument\n** is the query expression to parse. Each subsequent argument is the name\n** of a column of the fts3 table that the query expression may refer to.\n** For example:\n**\n**   SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');\n*/\nstatic void fts3ExprTest(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_tokenizer_module const *pModule = 0;\n  sqlite3_tokenizer *pTokenizer = 0;\n  int rc;\n  char **azCol = 0;\n  const char *zExpr;\n  int nExpr;\n  int nCol;\n  int ii;\n  Fts3Expr *pExpr;\n  char *zBuf = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc<3 ){\n    sqlite3_result_error(context, \n        \"Usage: fts3_exprtest(tokenizer, expr, col1, ...\", -1\n    );\n    return;\n  }\n\n  rc = queryTestTokenizer(db,\n                          (const char *)sqlite3_value_text(argv[0]), &pModule);\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }else if( !pModule ){\n    sqlite3_result_error(context, \"No such tokenizer module\", -1);\n    goto exprtest_out;\n  }\n\n  rc = pModule->xCreate(0, 0, &pTokenizer);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  pTokenizer->pModule = pModule;\n\n  zExpr = (const char *)sqlite3_value_text(argv[1]);\n  nExpr = sqlite3_value_bytes(argv[1]);\n  nCol = argc-2;\n  azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));\n  if( !azCol ){\n    sqlite3_result_error_nomem(context);\n    goto exprtest_out;\n  }\n  for(ii=0; ii<nCol; ii++){\n    azCol[ii] = (char *)sqlite3_value_text(argv[ii+2]);\n  }\n\n  if( sqlite3_user_data(context) ){\n    char *zDummy = 0;\n    rc = sqlite3Fts3ExprParse(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr, &zDummy\n    );\n    assert( rc==SQLITE_OK || pExpr==0 );\n    sqlite3_free(zDummy);\n  }else{\n    rc = fts3ExprParseUnbalanced(\n        pTokenizer, 0, azCol, 0, nCol, nCol, zExpr, nExpr, &pExpr\n    );\n  }\n\n  if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM ){\n    sqlite3Fts3ExprFree(pExpr);\n    sqlite3_result_error(context, \"Error parsing expression\", -1);\n  }else if( rc==SQLITE_NOMEM || !(zBuf = exprToString(pExpr, 0)) ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n    sqlite3_free(zBuf);\n  }\n\n  sqlite3Fts3ExprFree(pExpr);\n\nexprtest_out:\n  if( pModule && pTokenizer ){\n    rc = pModule->xDestroy(pTokenizer);\n  }\n  sqlite3_free(azCol);\n}\n\n/*\n** Register the query expression parser test function fts3_exprtest() \n** with database connection db. \n*/\nSQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){\n  int rc = sqlite3_create_function(\n      db, \"fts3_exprtest\", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"fts3_exprtest_rebalance\", \n        -1, SQLITE_UTF8, (void *)1, fts3ExprTest, 0, 0\n    );\n  }\n  return rc;\n}\n\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_expr.c *******************************************/\n/************** Begin file fts3_hash.c ***************************************/\n/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables used in SQLite.\n** We've modified it slightly to serve as a standalone hash table\n** implementation for the full-text indexing module.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_hash.h\" */\n\n/*\n** Malloc and Free functions\n*/\nstatic void *fts3HashMalloc(int n){\n  void *p = sqlite3_malloc(n);\n  if( p ){\n    memset(p, 0, n);\n  }\n  return p;\n}\nstatic void fts3HashFree(void *p){\n  sqlite3_free(p);\n}\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n** keyClass is one of the constants \n** FTS3_HASH_BINARY or FTS3_HASH_STRING.  The value of keyClass \n** determines what kind of key the hash table will use.  \"copyKey\" is\n** true if the hash table should make its own private copy of keys and\n** false if it should just use the supplied pointer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey){\n  assert( pNew!=0 );\n  assert( keyClass>=FTS3_HASH_STRING && keyClass<=FTS3_HASH_BINARY );\n  pNew->keyClass = keyClass;\n  pNew->copyKey = copyKey;\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nSQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash *pH){\n  Fts3HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  fts3HashFree(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    Fts3HashElem *next_elem = elem->next;\n    if( pH->copyKey && elem->pKey ){\n      fts3HashFree(elem->pKey);\n    }\n    fts3HashFree(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_STRING\n*/\nstatic int fts3StrHash(const void *pKey, int nKey){\n  const char *z = (const char *)pKey;\n  unsigned h = 0;\n  if( nKey<=0 ) nKey = (int) strlen(z);\n  while( nKey > 0  ){\n    h = (h<<3) ^ h ^ *z++;\n    nKey--;\n  }\n  return (int)(h & 0x7fffffff);\n}\nstatic int fts3StrCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return strncmp((const char*)pKey1,(const char*)pKey2,n1);\n}\n\n/*\n** Hash and comparison functions when the mode is FTS3_HASH_BINARY\n*/\nstatic int fts3BinHash(const void *pKey, int nKey){\n  int h = 0;\n  const char *z = (const char *)pKey;\n  while( nKey-- > 0 ){\n    h = (h<<3) ^ h ^ *(z++);\n  }\n  return h & 0x7fffffff;\n}\nstatic int fts3BinCompare(const void *pKey1, int n1, const void *pKey2, int n2){\n  if( n1!=n2 ) return 1;\n  return memcmp(pKey1,pKey2,n1);\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** The C syntax in this function definition may be unfamilar to some \n** programmers, so we provide the following additional explanation:\n**\n** The name of the function is \"ftsHashFunction\".  The function takes a\n** single parameter \"keyClass\".  The return value of ftsHashFunction()\n** is a pointer to another function.  Specifically, the return value\n** of ftsHashFunction() is a pointer to a function that takes two parameters\n** with types \"const void*\" and \"int\" and returns an \"int\".\n*/\nstatic int (*ftsHashFunction(int keyClass))(const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrHash;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinHash;\n  }\n}\n\n/*\n** Return a pointer to the appropriate hash function given the key class.\n**\n** For help in interpreted the obscure C code in the function definition,\n** see the header comment on the previous function.\n*/\nstatic int (*ftsCompareFunction(int keyClass))(const void*,int,const void*,int){\n  if( keyClass==FTS3_HASH_STRING ){\n    return &fts3StrCompare;\n  }else{\n    assert( keyClass==FTS3_HASH_BINARY );\n    return &fts3BinCompare;\n  }\n}\n\n/* Link an element into the hash table\n*/\nstatic void fts3HashInsertElement(\n  Fts3Hash *pH,            /* The complete hash table */\n  struct _fts3ht *pEntry,  /* The entry into which pNew is inserted */\n  Fts3HashElem *pNew       /* The element to be inserted */\n){\n  Fts3HashElem *pHead;     /* First element already in pEntry */\n  pHead = pEntry->chain;\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n  pEntry->count++;\n  pEntry->chain = pNew;\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n** \"new_size\" must be a power of 2.  The hash table might fail \n** to resize if sqliteMalloc() fails.\n**\n** Return non-zero if a memory allocation error occurs.\n*/\nstatic int fts3Rehash(Fts3Hash *pH, int new_size){\n  struct _fts3ht *new_ht;          /* The new hash table */\n  Fts3HashElem *elem, *next_elem;  /* For looping over existing elements */\n  int (*xHash)(const void*,int);   /* The hash function */\n\n  assert( (new_size & (new_size-1))==0 );\n  new_ht = (struct _fts3ht *)fts3HashMalloc( new_size*sizeof(struct _fts3ht) );\n  if( new_ht==0 ) return 1;\n  fts3HashFree(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size;\n  xHash = ftsHashFunction(pH->keyClass);\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);\n    next_elem = elem->next;\n    fts3HashInsertElement(pH, &new_ht[h], elem);\n  }\n  return 0;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  The hash for this key has\n** already been computed and is passed as the 4th parameter.\n*/\nstatic Fts3HashElem *fts3FindElementByHash(\n  const Fts3Hash *pH, /* The pH to be searched */\n  const void *pKey,   /* The key we are searching for */\n  int nKey,\n  int h               /* The hash for this key. */\n){\n  Fts3HashElem *elem;            /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */\n\n  if( pH->ht ){\n    struct _fts3ht *pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n    xCompare = ftsCompareFunction(pH->keyClass);\n    while( count-- && elem ){\n      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ \n        return elem;\n      }\n      elem = elem->next;\n    }\n  }\n  return 0;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void fts3RemoveElementByHash(\n  Fts3Hash *pH,         /* The pH containing \"elem\" */\n  Fts3HashElem* elem,   /* The element to be removed from the pH */\n  int h                 /* Hash value for the element */\n){\n  struct _fts3ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  pEntry = &pH->ht[h];\n  if( pEntry->chain==elem ){\n    pEntry->chain = elem->next;\n  }\n  pEntry->count--;\n  if( pEntry->count<=0 ){\n    pEntry->chain = 0;\n  }\n  if( pH->copyKey && elem->pKey ){\n    fts3HashFree(elem->pKey);\n  }\n  fts3HashFree( elem );\n  pH->count--;\n  if( pH->count<=0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    fts3HashClear(pH);\n  }\n}\n\nSQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(\n  const Fts3Hash *pH, \n  const void *pKey, \n  int nKey\n){\n  int h;                          /* A hash on key */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  if( pH==0 || pH->ht==0 ) return 0;\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  h = (*xHash)(pKey,nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));\n}\n\n/* \n** Attempt to locate an element of the hash table pH with a key\n** that matches pKey,nKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){\n  Fts3HashElem *pElem;            /* The element that matches key (if any) */\n\n  pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);\n  return pElem ? pElem->data : 0;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey,nKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created.  A copy of the key is made if the copyKey\n** flag is set.  NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nSQLITE_PRIVATE void *sqlite3Fts3HashInsert(\n  Fts3Hash *pH,        /* The hash table to insert into */\n  const void *pKey,    /* The key */\n  int nKey,            /* Number of bytes in the key */\n  void *data           /* The data */\n){\n  int hraw;                 /* Raw hash value of the key */\n  int h;                    /* the hash of the key modulo hash table size */\n  Fts3HashElem *elem;       /* Used to loop thru the element list */\n  Fts3HashElem *new_elem;   /* New element added to the pH */\n  int (*xHash)(const void*,int);  /* The hash function */\n\n  assert( pH!=0 );\n  xHash = ftsHashFunction(pH->keyClass);\n  assert( xHash!=0 );\n  hraw = (*xHash)(pKey, nKey);\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  elem = fts3FindElementByHash(pH,pKey,nKey,h);\n  if( elem ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      fts3RemoveElementByHash(pH,elem,h);\n    }else{\n      elem->data = data;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  if( (pH->htsize==0 && fts3Rehash(pH,8))\n   || (pH->count>=pH->htsize && fts3Rehash(pH, pH->htsize*2))\n  ){\n    pH->count = 0;\n    return data;\n  }\n  assert( pH->htsize>0 );\n  new_elem = (Fts3HashElem*)fts3HashMalloc( sizeof(Fts3HashElem) );\n  if( new_elem==0 ) return data;\n  if( pH->copyKey && pKey!=0 ){\n    new_elem->pKey = fts3HashMalloc( nKey );\n    if( new_elem->pKey==0 ){\n      fts3HashFree(new_elem);\n      return data;\n    }\n    memcpy((void*)new_elem->pKey, pKey, nKey);\n  }else{\n    new_elem->pKey = (void*)pKey;\n  }\n  new_elem->nKey = nKey;\n  pH->count++;\n  assert( pH->htsize>0 );\n  assert( (pH->htsize & (pH->htsize-1))==0 );\n  h = hraw & (pH->htsize-1);\n  fts3HashInsertElement(pH, &pH->ht[h], new_elem);\n  new_elem->data = data;\n  return 0;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_hash.c *******************************************/\n/************** Begin file fts3_porter.c *************************************/\n/*\n** 2006 September 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Implementation of the full-text-search tokenizer that implements\n** a Porter stemmer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\n/*\n** Class derived from sqlite3_tokenizer\n*/\ntypedef struct porter_tokenizer {\n  sqlite3_tokenizer base;      /* Base class */\n} porter_tokenizer;\n\n/*\n** Class derived from sqlite3_tokenizer_cursor\n*/\ntypedef struct porter_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *zInput;          /* input we are tokenizing */\n  int nInput;                  /* size of the input */\n  int iOffset;                 /* current position in zInput */\n  int iToken;                  /* index of next token to be returned */\n  char *zToken;                /* storage for current token */\n  int nAllocated;              /* space allocated to zToken buffer */\n} porter_tokenizer_cursor;\n\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int porterCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  porter_tokenizer *t;\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  t = (porter_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int porterDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is zInput[0..nInput-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int porterOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput, int nInput,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  porter_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (porter_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->zInput = zInput;\n  if( zInput==0 ){\n    c->nInput = 0;\n  }else if( nInput<0 ){\n    c->nInput = (int)strlen(zInput);\n  }else{\n    c->nInput = nInput;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->zToken = NULL;               /* no space allocated, yet. */\n  c->nAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** porterOpen() above.\n*/\nstatic int porterClose(sqlite3_tokenizer_cursor *pCursor){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->zToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n/*\n** Vowel or consonant\n*/\nstatic const char cType[] = {\n   0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0,\n   1, 1, 1, 2, 1\n};\n\n/*\n** isConsonant() and isVowel() determine if their first character in\n** the string they point to is a consonant or a vowel, according\n** to Porter ruls.  \n**\n** A consonate is any letter other than 'a', 'e', 'i', 'o', or 'u'.\n** 'Y' is a consonant unless it follows another consonant,\n** in which case it is a vowel.\n**\n** In these routine, the letters are in reverse order.  So the 'y' rule\n** is that 'y' is a consonant unless it is followed by another\n** consonent.\n*/\nstatic int isVowel(const char*);\nstatic int isConsonant(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return j;\n  return z[1]==0 || isVowel(z + 1);\n}\nstatic int isVowel(const char *z){\n  int j;\n  char x = *z;\n  if( x==0 ) return 0;\n  assert( x>='a' && x<='z' );\n  j = cType[x-'a'];\n  if( j<2 ) return 1-j;\n  return isConsonant(z + 1);\n}\n\n/*\n** Let any sequence of one or more vowels be represented by V and let\n** C be sequence of one or more consonants.  Then every word can be\n** represented as:\n**\n**           [C] (VC){m} [V]\n**\n** In prose:  A word is an optional consonant followed by zero or\n** vowel-consonant pairs followed by an optional vowel.  \"m\" is the\n** number of vowel consonant pairs.  This routine computes the value\n** of m for the first i bytes of a word.\n**\n** Return true if the m-value for z is 1 or more.  In other words,\n** return true if z contains at least one vowel that is followed\n** by a consonant.\n**\n** In this routine z[] is in reverse order.  So we are really looking\n** for an instance of a consonant followed by a vowel.\n*/\nstatic int m_gt_0(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/* Like mgt0 above except we are looking for a value of m which is\n** exactly 1\n*/\nstatic int m_eq_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 1;\n  while( isConsonant(z) ){ z++; }\n  return *z==0;\n}\n\n/* Like mgt0 above except we are looking for a value of m>1 instead\n** or m>0\n*/\nstatic int m_gt_1(const char *z){\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isVowel(z) ){ z++; }\n  if( *z==0 ) return 0;\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if there is a vowel anywhere within z[0..n-1]\n*/\nstatic int hasVowel(const char *z){\n  while( isConsonant(z) ){ z++; }\n  return *z!=0;\n}\n\n/*\n** Return TRUE if the word ends in a double consonant.\n**\n** The text is reversed here. So we are really looking at\n** the first two characters of z[].\n*/\nstatic int doubleConsonant(const char *z){\n  return isConsonant(z) && z[0]==z[1];\n}\n\n/*\n** Return TRUE if the word ends with three letters which\n** are consonant-vowel-consonent and where the final consonant\n** is not 'w', 'x', or 'y'.\n**\n** The word is reversed here.  So we are really checking the\n** first three letters and the first one cannot be in [wxy].\n*/\nstatic int star_oh(const char *z){\n  return\n    isConsonant(z) &&\n    z[0]!='w' && z[0]!='x' && z[0]!='y' &&\n    isVowel(z+1) &&\n    isConsonant(z+2);\n}\n\n/*\n** If the word ends with zFrom and xCond() is true for the stem\n** of the word that preceeds the zFrom ending, then change the \n** ending to zTo.\n**\n** The input word *pz and zFrom are both in reverse order.  zTo\n** is in normal order. \n**\n** Return TRUE if zFrom matches.  Return FALSE if zFrom does not\n** match.  Not that TRUE is returned even if xCond() fails and\n** no substitution occurs.\n*/\nstatic int stem(\n  char **pz,             /* The word being stemmed (Reversed) */\n  const char *zFrom,     /* If the ending matches this... (Reversed) */\n  const char *zTo,       /* ... change the ending to this (not reversed) */\n  int (*xCond)(const char*)   /* Condition that must be true */\n){\n  char *z = *pz;\n  while( *zFrom && *zFrom==*z ){ z++; zFrom++; }\n  if( *zFrom!=0 ) return 0;\n  if( xCond && !xCond(z) ) return 1;\n  while( *zTo ){\n    *(--z) = *(zTo++);\n  }\n  *pz = z;\n  return 1;\n}\n\n/*\n** This is the fallback stemmer used when the porter stemmer is\n** inappropriate.  The input word is copied into the output with\n** US-ASCII case folding.  If the input word is too long (more\n** than 20 bytes if it contains no digits or more than 6 bytes if\n** it contains digits) then word is truncated to 20 or 6 bytes\n** by taking 10 or 3 bytes from the beginning and end.\n*/\nstatic void copy_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, mx, j;\n  int hasDigit = 0;\n  for(i=0; i<nIn; i++){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zOut[i] = c - 'A' + 'a';\n    }else{\n      if( c>='0' && c<='9' ) hasDigit = 1;\n      zOut[i] = c;\n    }\n  }\n  mx = hasDigit ? 3 : 10;\n  if( nIn>mx*2 ){\n    for(j=mx, i=nIn-mx; i<nIn; i++, j++){\n      zOut[j] = zOut[i];\n    }\n    i = j;\n  }\n  zOut[i] = 0;\n  *pnOut = i;\n}\n\n\n/*\n** Stem the input word zIn[0..nIn-1].  Store the output in zOut.\n** zOut is at least big enough to hold nIn bytes.  Write the actual\n** size of the output word (exclusive of the '\\0' terminator) into *pnOut.\n**\n** Any upper-case characters in the US-ASCII character set ([A-Z])\n** are converted to lower case.  Upper-case UTF characters are\n** unchanged.\n**\n** Words that are longer than about 20 bytes are stemmed by retaining\n** a few bytes from the beginning and the end of the word.  If the\n** word contains digits, 3 bytes are taken from the beginning and\n** 3 bytes from the end.  For long words without digits, 10 bytes\n** are taken from each end.  US-ASCII case folding still applies.\n** \n** If the input word contains not digits but does characters not \n** in [a-zA-Z] then no stemming is attempted and this routine just \n** copies the input into the input into the output with US-ASCII\n** case folding.\n**\n** Stemming never increases the length of the word.  So there is\n** no chance of overflowing the zOut buffer.\n*/\nstatic void porter_stemmer(const char *zIn, int nIn, char *zOut, int *pnOut){\n  int i, j;\n  char zReverse[28];\n  char *z, *z2;\n  if( nIn<3 || nIn>=(int)sizeof(zReverse)-7 ){\n    /* The word is too big or too small for the porter stemmer.\n    ** Fallback to the copy stemmer */\n    copy_stemmer(zIn, nIn, zOut, pnOut);\n    return;\n  }\n  for(i=0, j=sizeof(zReverse)-6; i<nIn; i++, j--){\n    char c = zIn[i];\n    if( c>='A' && c<='Z' ){\n      zReverse[j] = c + 'a' - 'A';\n    }else if( c>='a' && c<='z' ){\n      zReverse[j] = c;\n    }else{\n      /* The use of a character not in [a-zA-Z] means that we fallback\n      ** to the copy stemmer */\n      copy_stemmer(zIn, nIn, zOut, pnOut);\n      return;\n    }\n  }\n  memset(&zReverse[sizeof(zReverse)-5], 0, 5);\n  z = &zReverse[j+1];\n\n\n  /* Step 1a */\n  if( z[0]=='s' ){\n    if(\n     !stem(&z, \"sess\", \"ss\", 0) &&\n     !stem(&z, \"sei\", \"i\", 0)  &&\n     !stem(&z, \"ss\", \"ss\", 0)\n    ){\n      z++;\n    }\n  }\n\n  /* Step 1b */  \n  z2 = z;\n  if( stem(&z, \"dee\", \"ee\", m_gt_0) ){\n    /* Do nothing.  The work was all in the test */\n  }else if( \n     (stem(&z, \"gni\", \"\", hasVowel) || stem(&z, \"de\", \"\", hasVowel))\n      && z!=z2\n  ){\n     if( stem(&z, \"ta\", \"ate\", 0) ||\n         stem(&z, \"lb\", \"ble\", 0) ||\n         stem(&z, \"zi\", \"ize\", 0) ){\n       /* Do nothing.  The work was all in the test */\n     }else if( doubleConsonant(z) && (*z!='l' && *z!='s' && *z!='z') ){\n       z++;\n     }else if( m_eq_1(z) && star_oh(z) ){\n       *(--z) = 'e';\n     }\n  }\n\n  /* Step 1c */\n  if( z[0]=='y' && hasVowel(z+1) ){\n    z[0] = 'i';\n  }\n\n  /* Step 2 */\n  switch( z[1] ){\n   case 'a':\n     if( !stem(&z, \"lanoita\", \"ate\", m_gt_0) ){\n       stem(&z, \"lanoit\", \"tion\", m_gt_0);\n     }\n     break;\n   case 'c':\n     if( !stem(&z, \"icne\", \"ence\", m_gt_0) ){\n       stem(&z, \"icna\", \"ance\", m_gt_0);\n     }\n     break;\n   case 'e':\n     stem(&z, \"rezi\", \"ize\", m_gt_0);\n     break;\n   case 'g':\n     stem(&z, \"igol\", \"log\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"ilb\", \"ble\", m_gt_0) \n      && !stem(&z, \"illa\", \"al\", m_gt_0)\n      && !stem(&z, \"iltne\", \"ent\", m_gt_0)\n      && !stem(&z, \"ile\", \"e\", m_gt_0)\n     ){\n       stem(&z, \"ilsuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 'o':\n     if( !stem(&z, \"noitazi\", \"ize\", m_gt_0)\n      && !stem(&z, \"noita\", \"ate\", m_gt_0)\n     ){\n       stem(&z, \"rota\", \"ate\", m_gt_0);\n     }\n     break;\n   case 's':\n     if( !stem(&z, \"msila\", \"al\", m_gt_0)\n      && !stem(&z, \"ssenevi\", \"ive\", m_gt_0)\n      && !stem(&z, \"ssenluf\", \"ful\", m_gt_0)\n     ){\n       stem(&z, \"ssensuo\", \"ous\", m_gt_0);\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"itila\", \"al\", m_gt_0)\n      && !stem(&z, \"itivi\", \"ive\", m_gt_0)\n     ){\n       stem(&z, \"itilib\", \"ble\", m_gt_0);\n     }\n     break;\n  }\n\n  /* Step 3 */\n  switch( z[0] ){\n   case 'e':\n     if( !stem(&z, \"etaci\", \"ic\", m_gt_0)\n      && !stem(&z, \"evita\", \"\", m_gt_0)\n     ){\n       stem(&z, \"ezila\", \"al\", m_gt_0);\n     }\n     break;\n   case 'i':\n     stem(&z, \"itici\", \"ic\", m_gt_0);\n     break;\n   case 'l':\n     if( !stem(&z, \"laci\", \"ic\", m_gt_0) ){\n       stem(&z, \"luf\", \"\", m_gt_0);\n     }\n     break;\n   case 's':\n     stem(&z, \"ssen\", \"\", m_gt_0);\n     break;\n  }\n\n  /* Step 4 */\n  switch( z[1] ){\n   case 'a':\n     if( z[0]=='l' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'c':\n     if( z[0]=='e' && z[2]=='n' && (z[3]=='a' || z[3]=='e')  && m_gt_1(z+4)  ){\n       z += 4;\n     }\n     break;\n   case 'e':\n     if( z[0]=='r' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'i':\n     if( z[0]=='c' && m_gt_1(z+2) ){\n       z += 2;\n     }\n     break;\n   case 'l':\n     if( z[0]=='e' && z[2]=='b' && (z[3]=='a' || z[3]=='i') && m_gt_1(z+4) ){\n       z += 4;\n     }\n     break;\n   case 'n':\n     if( z[0]=='t' ){\n       if( z[2]=='a' ){\n         if( m_gt_1(z+3) ){\n           z += 3;\n         }\n       }else if( z[2]=='e' ){\n         if( !stem(&z, \"tneme\", \"\", m_gt_1)\n          && !stem(&z, \"tnem\", \"\", m_gt_1)\n         ){\n           stem(&z, \"tne\", \"\", m_gt_1);\n         }\n       }\n     }\n     break;\n   case 'o':\n     if( z[0]=='u' ){\n       if( m_gt_1(z+2) ){\n         z += 2;\n       }\n     }else if( z[3]=='s' || z[3]=='t' ){\n       stem(&z, \"noi\", \"\", m_gt_1);\n     }\n     break;\n   case 's':\n     if( z[0]=='m' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 't':\n     if( !stem(&z, \"eta\", \"\", m_gt_1) ){\n       stem(&z, \"iti\", \"\", m_gt_1);\n     }\n     break;\n   case 'u':\n     if( z[0]=='s' && z[2]=='o' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n   case 'v':\n   case 'z':\n     if( z[0]=='e' && z[2]=='i' && m_gt_1(z+3) ){\n       z += 3;\n     }\n     break;\n  }\n\n  /* Step 5a */\n  if( z[0]=='e' ){\n    if( m_gt_1(z+1) ){\n      z++;\n    }else if( m_eq_1(z+1) && !star_oh(z+1) ){\n      z++;\n    }\n  }\n\n  /* Step 5b */\n  if( m_gt_1(z) && z[0]=='l' && z[1]=='l' ){\n    z++;\n  }\n\n  /* z[] is now the stemmed word in reverse order.  Flip it back\n  ** around into forward order and return.\n  */\n  *pnOut = i = (int)strlen(z);\n  zOut[i] = 0;\n  while( *z ){\n    zOut[--i] = *(z++);\n  }\n}\n\n/*\n** Characters that can be part of a token.  We assume any character\n** whose value is greater than 0x80 (any UTF character) can be\n** part of a token.  In other words, delimiters all must have\n** values of 0x7f or lower.\n*/\nstatic const char porterIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n};\n#define isDelim(C) (((ch=C)&0x80)==0 && (ch<0x30 || !porterIdChar[ch-0x30]))\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to porterOpen().\n*/\nstatic int porterNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by porterOpen */\n  const char **pzToken,               /* OUT: *pzToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  porter_tokenizer_cursor *c = (porter_tokenizer_cursor *) pCursor;\n  const char *z = c->zInput;\n\n  while( c->iOffset<c->nInput ){\n    int iStartOffset, ch;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nInput && isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nInput && !isDelim(z[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int n = c->iOffset-iStartOffset;\n      if( n>c->nAllocated ){\n        char *pNew;\n        c->nAllocated = n+20;\n        pNew = sqlite3_realloc(c->zToken, c->nAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->zToken = pNew;\n      }\n      porter_stemmer(&z[iStartOffset], n, c->zToken, pnBytes);\n      *pzToken = c->zToken;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the porter-stemmer tokenizer\n*/\nstatic const sqlite3_tokenizer_module porterTokenizerModule = {\n  0,\n  porterCreate,\n  porterDestroy,\n  porterOpen,\n  porterClose,\n  porterNext,\n  0\n};\n\n/*\n** Allocate a new porter tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &porterTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_porter.c *****************************************/\n/************** Begin file fts3_tokenizer.c **********************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is part of an SQLite module implementing full-text search.\n** This particular file implements the generic tokenizer interface.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <string.h> */\n\n/*\n** Return true if the two-argument version of fts3_tokenizer()\n** has been activated via a prior call to sqlite3_db_config(db,\n** SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, 0);\n*/\nstatic int fts3TokenizerEnabled(sqlite3_context *context){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int isEnabled = 0;\n  sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,-1,&isEnabled);\n  return isEnabled;\n}\n\n/*\n** Implementation of the SQL scalar function for accessing the underlying \n** hash table. This function may be called as follows:\n**\n**   SELECT <function-name>(<key-name>);\n**   SELECT <function-name>(<key-name>, <pointer>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer').\n**\n** If the <pointer> argument is specified, it must be a blob value\n** containing a pointer to be stored as the hash data corresponding\n** to the string <key-name>. If <pointer> is not specified, then\n** the string <key-name> must already exist in the has table. Otherwise,\n** an error is returned.\n**\n** Whether or not the <pointer> argument is specified, the value returned\n** is a blob containing the pointer stored as the hash data corresponding\n** to string <key-name> (after the hash-table is updated, if applicable).\n*/\nstatic void fts3TokenizerFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  void *pPtr = 0;\n  const unsigned char *zName;\n  int nName;\n\n  assert( argc==1 || argc==2 );\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n\n  zName = sqlite3_value_text(argv[0]);\n  nName = sqlite3_value_bytes(argv[0])+1;\n\n  if( argc==2 ){\n    if( fts3TokenizerEnabled(context) ){\n      void *pOld;\n      int n = sqlite3_value_bytes(argv[1]);\n      if( zName==0 || n!=sizeof(pPtr) ){\n        sqlite3_result_error(context, \"argument type mismatch\", -1);\n        return;\n      }\n      pPtr = *(void **)sqlite3_value_blob(argv[1]);\n      pOld = sqlite3Fts3HashInsert(pHash, (void *)zName, nName, pPtr);\n      if( pOld==pPtr ){\n        sqlite3_result_error(context, \"out of memory\", -1);\n      }\n    }else{\n      sqlite3_result_error(context, \"fts3tokenize disabled\", -1);\n      return;\n    }\n  }else{\n    if( zName ){\n      pPtr = sqlite3Fts3HashFind(pHash, zName, nName);\n    }\n    if( !pPtr ){\n      char *zErr = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n      sqlite3_result_error(context, zErr, -1);\n      sqlite3_free(zErr);\n      return;\n    }\n  }\n  sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){\n  static const char isFtsIdChar[] = {\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 0x */\n      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 1x */\n      0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* 2x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 3x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 4x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  /* 5x */\n      0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  /* 6x */\n      1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  /* 7x */\n  };\n  return (c&0x80 || isFtsIdChar[(int)(c)]);\n}\n\nSQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *zStr, int *pn){\n  const char *z1;\n  const char *z2 = 0;\n\n  /* Find the start of the next token. */\n  z1 = zStr;\n  while( z2==0 ){\n    char c = *z1;\n    switch( c ){\n      case '\\0': return 0;        /* No more tokens here */\n      case '\\'':\n      case '\"':\n      case '`': {\n        z2 = z1;\n        while( *++z2 && (*z2!=c || *++z2==c) );\n        break;\n      }\n      case '[':\n        z2 = &z1[1];\n        while( *z2 && z2[0]!=']' ) z2++;\n        if( *z2 ) z2++;\n        break;\n\n      default:\n        if( sqlite3Fts3IsIdChar(*z1) ){\n          z2 = &z1[1];\n          while( sqlite3Fts3IsIdChar(*z2) ) z2++;\n        }else{\n          z1++;\n        }\n    }\n  }\n\n  *pn = (int)(z2-z1);\n  return z1;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3InitTokenizer(\n  Fts3Hash *pHash,                /* Tokenizer hash table */\n  const char *zArg,               /* Tokenizer name */\n  sqlite3_tokenizer **ppTok,      /* OUT: Tokenizer (if applicable) */\n  char **pzErr                    /* OUT: Set to malloced error message */\n){\n  int rc;\n  char *z = (char *)zArg;\n  int n = 0;\n  char *zCopy;\n  char *zEnd;                     /* Pointer to nul-term of zCopy */\n  sqlite3_tokenizer_module *m;\n\n  zCopy = sqlite3_mprintf(\"%s\", zArg);\n  if( !zCopy ) return SQLITE_NOMEM;\n  zEnd = &zCopy[strlen(zCopy)];\n\n  z = (char *)sqlite3Fts3NextToken(zCopy, &n);\n  if( z==0 ){\n    assert( n==0 );\n    z = zCopy;\n  }\n  z[n] = '\\0';\n  sqlite3Fts3Dequote(z);\n\n  m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);\n  if( !m ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", z);\n    rc = SQLITE_ERROR;\n  }else{\n    char const **aArg = 0;\n    int iArg = 0;\n    z = &z[n+1];\n    while( z<zEnd && (NULL!=(z = (char *)sqlite3Fts3NextToken(z, &n))) ){\n      int nNew = sizeof(char *)*(iArg+1);\n      char const **aNew = (const char **)sqlite3_realloc((void *)aArg, nNew);\n      if( !aNew ){\n        sqlite3_free(zCopy);\n        sqlite3_free((void *)aArg);\n        return SQLITE_NOMEM;\n      }\n      aArg = aNew;\n      aArg[iArg++] = z;\n      z[n] = '\\0';\n      sqlite3Fts3Dequote(z);\n      z = &z[n+1];\n    }\n    rc = m->xCreate(iArg, aArg, ppTok);\n    assert( rc!=SQLITE_OK || *ppTok );\n    if( rc!=SQLITE_OK ){\n      sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer\");\n    }else{\n      (*ppTok)->pModule = m; \n    }\n    sqlite3_free((void *)aArg);\n  }\n\n  sqlite3_free(zCopy);\n  return rc;\n}\n\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n/* #include <string.h> */\n\n/*\n** Implementation of a special SQL scalar function for testing tokenizers \n** designed to be used in concert with the Tcl testing framework. This\n** function must be called with two or more arguments:\n**\n**   SELECT <function-name>(<key-name>, ..., <input-string>);\n**\n** where <function-name> is the name passed as the second argument\n** to the sqlite3Fts3InitHashTable() function (e.g. 'fts3_tokenizer')\n** concatenated with the string '_test' (e.g. 'fts3_tokenizer_test').\n**\n** The return value is a string that may be interpreted as a Tcl\n** list. For each token in the <input-string>, three elements are\n** added to the returned list. The first is the token position, the \n** second is the token text (folded, stemmed, etc.) and the third is the\n** substring of <input-string> associated with the token. For example, \n** using the built-in \"simple\" tokenizer:\n**\n**   SELECT fts_tokenizer_test('simple', 'I don't see how');\n**\n** will return the string:\n**\n**   \"{0 i I 1 dont don't 2 see see 3 how how}\"\n**   \n*/\nstatic void testFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Fts3Hash *pHash;\n  sqlite3_tokenizer_module *p;\n  sqlite3_tokenizer *pTokenizer = 0;\n  sqlite3_tokenizer_cursor *pCsr = 0;\n\n  const char *zErr = 0;\n\n  const char *zName;\n  int nName;\n  const char *zInput;\n  int nInput;\n\n  const char *azArg[64];\n\n  const char *zToken;\n  int nToken = 0;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int i;\n\n  Tcl_Obj *pRet;\n\n  if( argc<2 ){\n    sqlite3_result_error(context, \"insufficient arguments\", -1);\n    return;\n  }\n\n  nName = sqlite3_value_bytes(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[0]);\n  nInput = sqlite3_value_bytes(argv[argc-1]);\n  zInput = (const char *)sqlite3_value_text(argv[argc-1]);\n\n  pHash = (Fts3Hash *)sqlite3_user_data(context);\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n\n  if( !p ){\n    char *zErr2 = sqlite3_mprintf(\"unknown tokenizer: %s\", zName);\n    sqlite3_result_error(context, zErr2, -1);\n    sqlite3_free(zErr2);\n    return;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  for(i=1; i<argc-1; i++){\n    azArg[i-1] = (const char *)sqlite3_value_text(argv[i]);\n  }\n\n  if( SQLITE_OK!=p->xCreate(argc-2, azArg, &pTokenizer) ){\n    zErr = \"error in xCreate()\";\n    goto finish;\n  }\n  pTokenizer->pModule = p;\n  if( sqlite3Fts3OpenTokenizer(pTokenizer, 0, zInput, nInput, &pCsr) ){\n    zErr = \"error in xOpen()\";\n    goto finish;\n  }\n\n  while( SQLITE_OK==p->xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos) ){\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(iPos));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n    zToken = &zInput[iStart];\n    nToken = iEnd-iStart;\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zToken, nToken));\n  }\n\n  if( SQLITE_OK!=p->xClose(pCsr) ){\n    zErr = \"error in xClose()\";\n    goto finish;\n  }\n  if( SQLITE_OK!=p->xDestroy(pTokenizer) ){\n    zErr = \"error in xDestroy()\";\n    goto finish;\n  }\n\nfinish:\n  if( zErr ){\n    sqlite3_result_error(context, zErr, -1);\n  }else{\n    sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  }\n  Tcl_DecrRefCount(pRet);\n}\n\nstatic\nint registerTokenizer(\n  sqlite3 *db, \n  char *zName, \n  const sqlite3_tokenizer_module *p\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?, ?)\";\n\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  sqlite3_bind_blob(pStmt, 2, &p, sizeof(p), SQLITE_STATIC);\n  sqlite3_step(pStmt);\n\n  return sqlite3_finalize(pStmt);\n}\n\n\nstatic\nint queryTokenizer(\n  sqlite3 *db, \n  char *zName,  \n  const sqlite3_tokenizer_module **pp\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n  const char zSql[] = \"SELECT fts3_tokenizer(?)\";\n\n  *pp = 0;\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    if( sqlite3_column_type(pStmt, 0)==SQLITE_BLOB ){\n      memcpy((void *)pp, sqlite3_column_blob(pStmt, 0), sizeof(*pp));\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule);\n\n/*\n** Implementation of the scalar function fts3_tokenizer_internal_test().\n** This function is used for testing only, it is not included in the\n** build unless SQLITE_TEST is defined.\n**\n** The purpose of this is to test that the fts3_tokenizer() function\n** can be used as designed by the C-code in the queryTokenizer and\n** registerTokenizer() functions above. These two functions are repeated\n** in the README.tokenizer file as an example, so it is important to\n** test them.\n**\n** To run the tests, evaluate the fts3_tokenizer_internal_test() scalar\n** function with no arguments. An assert() will fail if a problem is\n** detected. i.e.:\n**\n**     SELECT fts3_tokenizer_internal_test();\n**\n*/\nstatic void intTestFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc;\n  const sqlite3_tokenizer_module *p1;\n  const sqlite3_tokenizer_module *p2;\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  /* Test the query function */\n  sqlite3Fts3SimpleTokenizerModule(&p1);\n  rc = queryTokenizer(db, \"simple\", &p2);\n  assert( rc==SQLITE_OK );\n  assert( p1==p2 );\n  rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n  assert( rc==SQLITE_ERROR );\n  assert( p2==0 );\n  assert( 0==strcmp(sqlite3_errmsg(db), \"unknown tokenizer: nosuchtokenizer\") );\n\n  /* Test the storage function */\n  if( fts3TokenizerEnabled(context) ){\n    rc = registerTokenizer(db, \"nosuchtokenizer\", p1);\n    assert( rc==SQLITE_OK );\n    rc = queryTokenizer(db, \"nosuchtokenizer\", &p2);\n    assert( rc==SQLITE_OK );\n    assert( p2==p1 );\n  }\n\n  sqlite3_result_text(context, \"ok\", -1, SQLITE_STATIC);\n}\n\n#endif\n\n/*\n** Set up SQL objects in database db used to access the contents of\n** the hash table pointed to by argument pHash. The hash table must\n** been initialized to use string keys, and to take a private copy \n** of the key when a value is inserted. i.e. by a call similar to:\n**\n**    sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);\n**\n** This function adds a scalar function (see header comment above\n** fts3TokenizerFunc() in this file for details) and, if ENABLE_TABLE is\n** defined at compilation time, a temporary virtual table (see header \n** comment above struct HashTableVtab) to the database schema. Both \n** provide read/write access to the contents of *pHash.\n**\n** The third argument to this function, zName, is used as the name\n** of both the scalar and, if created, the virtual table.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitHashTable(\n  sqlite3 *db, \n  Fts3Hash *pHash, \n  const char *zName\n){\n  int rc = SQLITE_OK;\n  void *p = (void *)pHash;\n  const int any = SQLITE_ANY;\n\n#ifdef SQLITE_TEST\n  char *zTest = 0;\n  char *zTest2 = 0;\n  void *pdb = (void *)db;\n  zTest = sqlite3_mprintf(\"%s_test\", zName);\n  zTest2 = sqlite3_mprintf(\"%s_internal_test\", zName);\n  if( !zTest || !zTest2 ){\n    rc = SQLITE_NOMEM;\n  }\n#endif\n\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 1, any, p, fts3TokenizerFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zName, 2, any, p, fts3TokenizerFunc, 0, 0);\n  }\n#ifdef SQLITE_TEST\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest, -1, any, p, testFunc, 0, 0);\n  }\n  if( SQLITE_OK==rc ){\n    rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0);\n  }\n#endif\n\n#ifdef SQLITE_TEST\n  sqlite3_free(zTest);\n  sqlite3_free(zTest2);\n#endif\n\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer.c **************************************/\n/************** Begin file fts3_tokenizer1.c *********************************/\n/*\n** 2006 Oct 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"simple\" full-text-search tokenizer.\n*/\n\n/*\n** The code in this file is only compiled if:\n**\n**     * The FTS3 module is being built as an extension\n**       (in which case SQLITE_CORE is not defined), or\n**\n**     * The FTS3 module is being built into the core of\n**       SQLite (in which case SQLITE_ENABLE_FTS3 is defined).\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\ntypedef struct simple_tokenizer {\n  sqlite3_tokenizer base;\n  char delim[128];             /* flag ASCII delimiters */\n} simple_tokenizer;\n\ntypedef struct simple_tokenizer_cursor {\n  sqlite3_tokenizer_cursor base;\n  const char *pInput;          /* input we are tokenizing */\n  int nBytes;                  /* size of the input */\n  int iOffset;                 /* current position in pInput */\n  int iToken;                  /* index of next token to be returned */\n  char *pToken;                /* storage for current token */\n  int nTokenAllocated;         /* space allocated to zToken buffer */\n} simple_tokenizer_cursor;\n\n\nstatic int simpleDelim(simple_tokenizer *t, unsigned char c){\n  return c<0x80 && t->delim[c];\n}\nstatic int fts3_isalnum(int x){\n  return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int simpleCreate(\n  int argc, const char * const *argv,\n  sqlite3_tokenizer **ppTokenizer\n){\n  simple_tokenizer *t;\n\n  t = (simple_tokenizer *) sqlite3_malloc(sizeof(*t));\n  if( t==NULL ) return SQLITE_NOMEM;\n  memset(t, 0, sizeof(*t));\n\n  /* TODO(shess) Delimiters need to remain the same from run to run,\n  ** else we need to reindex.  One solution would be a meta-table to\n  ** track such information in the database, then we'd only want this\n  ** information on the initial create.\n  */\n  if( argc>1 ){\n    int i, n = (int)strlen(argv[1]);\n    for(i=0; i<n; i++){\n      unsigned char ch = argv[1][i];\n      /* We explicitly don't support UTF-8 delimiters for now. */\n      if( ch>=0x80 ){\n        sqlite3_free(t);\n        return SQLITE_ERROR;\n      }\n      t->delim[ch] = 1;\n    }\n  } else {\n    /* Mark non-alphanumeric ASCII characters as delimiters */\n    int i;\n    for(i=1; i<0x80; i++){\n      t->delim[i] = !fts3_isalnum(i) ? -1 : 0;\n    }\n  }\n\n  *ppTokenizer = &t->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int simpleDestroy(sqlite3_tokenizer *pTokenizer){\n  sqlite3_free(pTokenizer);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int simpleOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *pInput, int nBytes,        /* String to be tokenized */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  simple_tokenizer_cursor *c;\n\n  UNUSED_PARAMETER(pTokenizer);\n\n  c = (simple_tokenizer_cursor *) sqlite3_malloc(sizeof(*c));\n  if( c==NULL ) return SQLITE_NOMEM;\n\n  c->pInput = pInput;\n  if( pInput==0 ){\n    c->nBytes = 0;\n  }else if( nBytes<0 ){\n    c->nBytes = (int)strlen(pInput);\n  }else{\n    c->nBytes = nBytes;\n  }\n  c->iOffset = 0;                 /* start tokenizing at the beginning */\n  c->iToken = 0;\n  c->pToken = NULL;               /* no space allocated, yet. */\n  c->nTokenAllocated = 0;\n\n  *ppCursor = &c->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int simpleClose(sqlite3_tokenizer_cursor *pCursor){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  sqlite3_free(c->pToken);\n  sqlite3_free(c);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int simpleNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  simple_tokenizer_cursor *c = (simple_tokenizer_cursor *) pCursor;\n  simple_tokenizer *t = (simple_tokenizer *) pCursor->pTokenizer;\n  unsigned char *p = (unsigned char *)c->pInput;\n\n  while( c->iOffset<c->nBytes ){\n    int iStartOffset;\n\n    /* Scan past delimiter characters */\n    while( c->iOffset<c->nBytes && simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    /* Count non-delimiter characters. */\n    iStartOffset = c->iOffset;\n    while( c->iOffset<c->nBytes && !simpleDelim(t, p[c->iOffset]) ){\n      c->iOffset++;\n    }\n\n    if( c->iOffset>iStartOffset ){\n      int i, n = c->iOffset-iStartOffset;\n      if( n>c->nTokenAllocated ){\n        char *pNew;\n        c->nTokenAllocated = n+20;\n        pNew = sqlite3_realloc(c->pToken, c->nTokenAllocated);\n        if( !pNew ) return SQLITE_NOMEM;\n        c->pToken = pNew;\n      }\n      for(i=0; i<n; i++){\n        /* TODO(shess) This needs expansion to handle UTF-8\n        ** case-insensitivity.\n        */\n        unsigned char ch = p[iStartOffset+i];\n        c->pToken[i] = (char)((ch>='A' && ch<='Z') ? ch-'A'+'a' : ch);\n      }\n      *ppToken = c->pToken;\n      *pnBytes = n;\n      *piStartOffset = iStartOffset;\n      *piEndOffset = c->iOffset;\n      *piPosition = c->iToken++;\n\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_DONE;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module simpleTokenizerModule = {\n  0,\n  simpleCreate,\n  simpleDestroy,\n  simpleOpen,\n  simpleClose,\n  simpleNext,\n  0,\n};\n\n/*\n** Allocate a new simple tokenizer.  Return a pointer to the new\n** tokenizer in *ppModule\n*/\nSQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &simpleTokenizerModule;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenizer1.c *************************************/\n/************** Begin file fts3_tokenize_vtab.c ******************************/\n/*\n** 2013 Apr 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for the \"fts3tokenize\" virtual table module.\n** An fts3tokenize virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE <tbl> USING fts3tokenize(\n**       <tokenizer-name>, <arg-1>, ...\n**   );\n**\n** The table created has the following schema:\n**\n**   CREATE TABLE <tbl>(input, token, start, end, position)\n**\n** When queried, the query must include a WHERE clause of type:\n**\n**   input = <string>\n**\n** The virtual table module tokenizes this <string>, using the FTS3 \n** tokenizer specified by the arguments to the CREATE VIRTUAL TABLE \n** statement and returns one row for each token in the result. With\n** fields set as follows:\n**\n**   input:   Always set to a copy of <string>\n**   token:   A token from the input.\n**   start:   Byte offset of the token within the input <string>.\n**   end:     Byte offset of the byte immediately following the end of the\n**            token within the input string.\n**   pos:     Token offset of token within input.\n**\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\ntypedef struct Fts3tokTable Fts3tokTable;\ntypedef struct Fts3tokCursor Fts3tokCursor;\n\n/*\n** Virtual table structure.\n*/\nstruct Fts3tokTable {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  const sqlite3_tokenizer_module *pMod;\n  sqlite3_tokenizer *pTok;\n};\n\n/*\n** Virtual table cursor structure.\n*/\nstruct Fts3tokCursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  char *zInput;                   /* Input string */\n  sqlite3_tokenizer_cursor *pCsr; /* Cursor to iterate through zInput */\n  int iRowid;                     /* Current 'rowid' value */\n  const char *zToken;             /* Current 'token' value */\n  int nToken;                     /* Size of zToken in bytes */\n  int iStart;                     /* Current 'start' value */\n  int iEnd;                       /* Current 'end' value */\n  int iPos;                       /* Current 'pos' value */\n};\n\n/*\n** Query FTS for the tokenizer implementation named zName.\n*/\nstatic int fts3tokQueryTokenizer(\n  Fts3Hash *pHash,\n  const char *zName,\n  const sqlite3_tokenizer_module **pp,\n  char **pzErr\n){\n  sqlite3_tokenizer_module *p;\n  int nName = (int)strlen(zName);\n\n  p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);\n  if( !p ){\n    sqlite3Fts3ErrMsg(pzErr, \"unknown tokenizer: %s\", zName);\n    return SQLITE_ERROR;\n  }\n\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** The second argument, argv[], is an array of pointers to nul-terminated\n** strings. This function makes a copy of the array and strings into a \n** single block of memory. It then dequotes any of the strings that appear\n** to be quoted.\n**\n** If successful, output parameter *pazDequote is set to point at the\n** array of dequoted strings and SQLITE_OK is returned. The caller is\n** responsible for eventually calling sqlite3_free() to free the array\n** in this case. Or, if an error occurs, an SQLite error code is returned.\n** The final value of *pazDequote is undefined in this case.\n*/\nstatic int fts3tokDequoteArray(\n  int argc,                       /* Number of elements in argv[] */\n  const char * const *argv,       /* Input array */\n  char ***pazDequote              /* Output array */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( argc==0 ){\n    *pazDequote = 0;\n  }else{\n    int i;\n    int nByte = 0;\n    char **azDequote;\n\n    for(i=0; i<argc; i++){\n      nByte += (int)(strlen(argv[i]) + 1);\n    }\n\n    *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);\n    if( azDequote==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      char *pSpace = (char *)&azDequote[argc];\n      for(i=0; i<argc; i++){\n        int n = (int)strlen(argv[i]);\n        azDequote[i] = pSpace;\n        memcpy(pSpace, argv[i], n+1);\n        sqlite3Fts3Dequote(pSpace);\n        pSpace += (n+1);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Schema of the tokenizer table.\n*/\n#define FTS3_TOK_SCHEMA \"CREATE TABLE x(input, token, start, end, position)\"\n\n/*\n** This function does all the work for both the xConnect and xCreate methods.\n** These tables have no persistent representation of their own, so xConnect\n** and xCreate are identical operations.\n**\n**   argv[0]: module name\n**   argv[1]: database name \n**   argv[2]: table name\n**   argv[3]: first argument (tokenizer name)\n*/\nstatic int fts3tokConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pHash,                    /* Hash table of tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  Fts3tokTable *pTab = 0;\n  const sqlite3_tokenizer_module *pMod = 0;\n  sqlite3_tokenizer *pTok = 0;\n  int rc;\n  char **azDequote = 0;\n  int nDequote;\n\n  rc = sqlite3_declare_vtab(db, FTS3_TOK_SCHEMA);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nDequote = argc-3;\n  rc = fts3tokDequoteArray(nDequote, &argv[3], &azDequote);\n\n  if( rc==SQLITE_OK ){\n    const char *zModule;\n    if( nDequote<1 ){\n      zModule = \"simple\";\n    }else{\n      zModule = azDequote[0];\n    }\n    rc = fts3tokQueryTokenizer((Fts3Hash*)pHash, zModule, &pMod, pzErr);\n  }\n\n  assert( (rc==SQLITE_OK)==(pMod!=0) );\n  if( rc==SQLITE_OK ){\n    const char * const *azArg = (const char * const *)&azDequote[1];\n    rc = pMod->xCreate((nDequote>1 ? nDequote-1 : 0), azArg, &pTok);\n  }\n\n  if( rc==SQLITE_OK ){\n    pTab = (Fts3tokTable *)sqlite3_malloc(sizeof(Fts3tokTable));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(Fts3tokTable));\n    pTab->pMod = pMod;\n    pTab->pTok = pTok;\n    *ppVtab = &pTab->base;\n  }else{\n    if( pTok ){\n      pMod->xDestroy(pTok);\n    }\n  }\n\n  sqlite3_free(azDequote);\n  return rc;\n}\n\n/*\n** This function does the work for both the xDisconnect and xDestroy methods.\n** These tables have no persistent representation of their own, so xDisconnect\n** and xDestroy are identical operations.\n*/\nstatic int fts3tokDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts3tokTable *pTab = (Fts3tokTable *)pVtab;\n\n  pTab->pMod->xDestroy(pTab->pTok);\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex - Analyze a WHERE and ORDER BY clause.\n*/\nstatic int fts3tokBestIndexMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_index_info *pInfo\n){\n  int i;\n  UNUSED_PARAMETER(pVTab);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    if( pInfo->aConstraint[i].usable \n     && pInfo->aConstraint[i].iColumn==0 \n     && pInfo->aConstraint[i].op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      pInfo->idxNum = 1;\n      pInfo->aConstraintUsage[i].argvIndex = 1;\n      pInfo->aConstraintUsage[i].omit = 1;\n      pInfo->estimatedCost = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  pInfo->idxNum = 0;\n  assert( pInfo->estimatedCost>1000000.0 );\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen - Open a cursor.\n*/\nstatic int fts3tokOpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts3tokCursor *pCsr;\n  UNUSED_PARAMETER(pVTab);\n\n  pCsr = (Fts3tokCursor *)sqlite3_malloc(sizeof(Fts3tokCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(Fts3tokCursor));\n\n  *ppCsr = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Reset the tokenizer cursor passed as the only argument. As if it had\n** just been returned by fts3tokOpenMethod().\n*/\nstatic void fts3tokResetCursor(Fts3tokCursor *pCsr){\n  if( pCsr->pCsr ){\n    Fts3tokTable *pTab = (Fts3tokTable *)(pCsr->base.pVtab);\n    pTab->pMod->xClose(pCsr->pCsr);\n    pCsr->pCsr = 0;\n  }\n  sqlite3_free(pCsr->zInput);\n  pCsr->zInput = 0;\n  pCsr->zToken = 0;\n  pCsr->nToken = 0;\n  pCsr->iStart = 0;\n  pCsr->iEnd = 0;\n  pCsr->iPos = 0;\n  pCsr->iRowid = 0;\n}\n\n/*\n** xClose - Close a cursor.\n*/\nstatic int fts3tokCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  fts3tokResetCursor(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** xNext - Advance the cursor to the next row, if any.\n*/\nstatic int fts3tokNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  int rc;                         /* Return code */\n\n  pCsr->iRowid++;\n  rc = pTab->pMod->xNext(pCsr->pCsr,\n      &pCsr->zToken, &pCsr->nToken,\n      &pCsr->iStart, &pCsr->iEnd, &pCsr->iPos\n  );\n\n  if( rc!=SQLITE_OK ){\n    fts3tokResetCursor(pCsr);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n\n  return rc;\n}\n\n/*\n** xFilter - Initialize a cursor to point at the start of its data.\n*/\nstatic int fts3tokFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *idxStr,             /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  int rc = SQLITE_ERROR;\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  Fts3tokTable *pTab = (Fts3tokTable *)(pCursor->pVtab);\n  UNUSED_PARAMETER(idxStr);\n  UNUSED_PARAMETER(nVal);\n\n  fts3tokResetCursor(pCsr);\n  if( idxNum==1 ){\n    const char *zByte = (const char *)sqlite3_value_text(apVal[0]);\n    int nByte = sqlite3_value_bytes(apVal[0]);\n    pCsr->zInput = sqlite3_malloc(nByte+1);\n    if( pCsr->zInput==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memcpy(pCsr->zInput, zByte, nByte);\n      pCsr->zInput[nByte] = 0;\n      rc = pTab->pMod->xOpen(pTab->pTok, pCsr->zInput, nByte, &pCsr->pCsr);\n      if( rc==SQLITE_OK ){\n        pCsr->pCsr->pTokenizer = pTab->pTok;\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ) return rc;\n  return fts3tokNextMethod(pCursor);\n}\n\n/*\n** xEof - Return true if the cursor is at EOF, or false otherwise.\n*/\nstatic int fts3tokEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  return (pCsr->zToken==0);\n}\n\n/*\n** xColumn - Return a column value.\n*/\nstatic int fts3tokColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n\n  /* CREATE TABLE x(input, token, start, end, position) */\n  switch( iCol ){\n    case 0:\n      sqlite3_result_text(pCtx, pCsr->zInput, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:\n      sqlite3_result_text(pCtx, pCsr->zToken, pCsr->nToken, SQLITE_TRANSIENT);\n      break;\n    case 2:\n      sqlite3_result_int(pCtx, pCsr->iStart);\n      break;\n    case 3:\n      sqlite3_result_int(pCtx, pCsr->iEnd);\n      break;\n    default:\n      assert( iCol==4 );\n      sqlite3_result_int(pCtx, pCsr->iPos);\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** xRowid - Return the current rowid for the cursor.\n*/\nstatic int fts3tokRowidMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite_int64 *pRowid            /* OUT: Rowid value */\n){\n  Fts3tokCursor *pCsr = (Fts3tokCursor *)pCursor;\n  *pRowid = (sqlite3_int64)pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Register the fts3tok module with database connection db. Return SQLITE_OK\n** if successful or an error code if sqlite3_create_module() fails.\n*/\nSQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){\n  static const sqlite3_module fts3tok_module = {\n     0,                           /* iVersion      */\n     fts3tokConnectMethod,        /* xCreate       */\n     fts3tokConnectMethod,        /* xConnect      */\n     fts3tokBestIndexMethod,      /* xBestIndex    */\n     fts3tokDisconnectMethod,     /* xDisconnect   */\n     fts3tokDisconnectMethod,     /* xDestroy      */\n     fts3tokOpenMethod,           /* xOpen         */\n     fts3tokCloseMethod,          /* xClose        */\n     fts3tokFilterMethod,         /* xFilter       */\n     fts3tokNextMethod,           /* xNext         */\n     fts3tokEofMethod,            /* xEof          */\n     fts3tokColumnMethod,         /* xColumn       */\n     fts3tokRowidMethod,          /* xRowid        */\n     0,                           /* xUpdate       */\n     0,                           /* xBegin        */\n     0,                           /* xSync         */\n     0,                           /* xCommit       */\n     0,                           /* xRollback     */\n     0,                           /* xFindFunction */\n     0,                           /* xRename       */\n     0,                           /* xSavepoint    */\n     0,                           /* xRelease      */\n     0                            /* xRollbackTo   */\n  };\n  int rc;                         /* Return code */\n\n  rc = sqlite3_create_module(db, \"fts3tokenize\", &fts3tok_module, (void*)pHash);\n  return rc;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_tokenize_vtab.c **********************************/\n/************** Begin file fts3_write.c **************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file is part of the SQLite FTS3 extension module. Specifically,\n** this file contains code to insert, update and delete rows from FTS3\n** tables. It also contains code to merge FTS3 b-tree segments. Some\n** of the sub-routines used to merge segments are also used by the query \n** code in fts3.c.\n*/\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n\n\n#define FTS_MAX_APPENDABLE_HEIGHT 16\n\n/*\n** When full-text index nodes are loaded from disk, the buffer that they\n** are loaded into has the following number of bytes of padding at the end \n** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer\n** of 920 bytes is allocated for it.\n**\n** This means that if we have a pointer into a buffer containing node data,\n** it is always safe to read up to two varints from it without risking an\n** overread, even if the node data is corrupted.\n*/\n#define FTS3_NODE_PADDING (FTS3_VARINT_MAX*2)\n\n/*\n** Under certain circumstances, b-tree nodes (doclists) can be loaded into\n** memory incrementally instead of all at once. This can be a big performance\n** win (reduced IO and CPU) if SQLite stops calling the virtual table xNext()\n** method before retrieving all query results (as may happen, for example,\n** if a query has a LIMIT clause).\n**\n** Incremental loading is used for b-tree nodes FTS3_NODE_CHUNK_THRESHOLD \n** bytes and larger. Nodes are loaded in chunks of FTS3_NODE_CHUNKSIZE bytes.\n** The code is written so that the hard lower-limit for each of these values \n** is 1. Clearly such small values would be inefficient, but can be useful \n** for testing purposes.\n**\n** If this module is built with SQLITE_TEST defined, these constants may\n** be overridden at runtime for testing purposes. File fts3_test.c contains\n** a Tcl interface to read and write the values.\n*/\n#ifdef SQLITE_TEST\nint test_fts3_node_chunksize = (4*1024);\nint test_fts3_node_chunk_threshold = (4*1024)*4;\n# define FTS3_NODE_CHUNKSIZE       test_fts3_node_chunksize\n# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold\n#else\n# define FTS3_NODE_CHUNKSIZE (4*1024) \n# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)\n#endif\n\n/*\n** The two values that may be meaningfully bound to the :1 parameter in\n** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.\n*/\n#define FTS_STAT_DOCTOTAL      0\n#define FTS_STAT_INCRMERGEHINT 1\n#define FTS_STAT_AUTOINCRMERGE 2\n\n/*\n** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic\n** and incremental merge operation that takes place. This is used for \n** debugging FTS only, it should not usually be turned on in production\n** systems.\n*/\n#ifdef FTS3_LOG_MERGES\nstatic void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){\n  sqlite3_log(SQLITE_OK, \"%d-way merge from level %d\", nMerge, (int)iAbsLevel);\n}\n#else\n#define fts3LogMerge(x, y)\n#endif\n\n\ntypedef struct PendingList PendingList;\ntypedef struct SegmentNode SegmentNode;\ntypedef struct SegmentWriter SegmentWriter;\n\n/*\n** An instance of the following data structure is used to build doclists\n** incrementally. See function fts3PendingListAppend() for details.\n*/\nstruct PendingList {\n  int nData;\n  char *aData;\n  int nSpace;\n  sqlite3_int64 iLastDocid;\n  sqlite3_int64 iLastCol;\n  sqlite3_int64 iLastPos;\n};\n\n\n/*\n** Each cursor has a (possibly empty) linked list of the following objects.\n*/\nstruct Fts3DeferredToken {\n  Fts3PhraseToken *pToken;        /* Pointer to corresponding expr token */\n  int iCol;                       /* Column token must occur in */\n  Fts3DeferredToken *pNext;       /* Next in list of deferred tokens */\n  PendingList *pList;             /* Doclist is assembled here */\n};\n\n/*\n** An instance of this structure is used to iterate through the terms on\n** a contiguous set of segment b-tree leaf nodes. Although the details of\n** this structure are only manipulated by code in this file, opaque handles\n** of type Fts3SegReader* are also used by code in fts3.c to iterate through\n** terms when querying the full-text index. See functions:\n**\n**   sqlite3Fts3SegReaderNew()\n**   sqlite3Fts3SegReaderFree()\n**   sqlite3Fts3SegReaderIterate()\n**\n** Methods used to manipulate Fts3SegReader structures:\n**\n**   fts3SegReaderNext()\n**   fts3SegReaderFirstDocid()\n**   fts3SegReaderNextDocid()\n*/\nstruct Fts3SegReader {\n  int iIdx;                       /* Index within level, or 0x7FFFFFFF for PT */\n  u8 bLookup;                     /* True for a lookup only */\n  u8 rootOnly;                    /* True for a root-only reader */\n\n  sqlite3_int64 iStartBlock;      /* Rowid of first leaf block to traverse */\n  sqlite3_int64 iLeafEndBlock;    /* Rowid of final leaf block to traverse */\n  sqlite3_int64 iEndBlock;        /* Rowid of final block in segment (or 0) */\n  sqlite3_int64 iCurrentBlock;    /* Current leaf block (or 0) */\n\n  char *aNode;                    /* Pointer to node data (or NULL) */\n  int nNode;                      /* Size of buffer at aNode (or 0) */\n  int nPopulate;                  /* If >0, bytes of buffer aNode[] loaded */\n  sqlite3_blob *pBlob;            /* If not NULL, blob handle to read node */\n\n  Fts3HashElem **ppNextElem;\n\n  /* Variables set by fts3SegReaderNext(). These may be read directly\n  ** by the caller. They are valid from the time SegmentReaderNew() returns\n  ** until SegmentReaderNext() returns something other than SQLITE_OK\n  ** (i.e. SQLITE_DONE).\n  */\n  int nTerm;                      /* Number of bytes in current term */\n  char *zTerm;                    /* Pointer to current term */\n  int nTermAlloc;                 /* Allocated size of zTerm buffer */\n  char *aDoclist;                 /* Pointer to doclist of current entry */\n  int nDoclist;                   /* Size of doclist in current entry */\n\n  /* The following variables are used by fts3SegReaderNextDocid() to iterate \n  ** through the current doclist (aDoclist/nDoclist).\n  */\n  char *pOffsetList;\n  int nOffsetList;                /* For descending pending seg-readers only */\n  sqlite3_int64 iDocid;\n};\n\n#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)\n#define fts3SegReaderIsRootOnly(p) ((p)->rootOnly!=0)\n\n/*\n** An instance of this structure is used to create a segment b-tree in the\n** database. The internal details of this type are only accessed by the\n** following functions:\n**\n**   fts3SegWriterAdd()\n**   fts3SegWriterFlush()\n**   fts3SegWriterFree()\n*/\nstruct SegmentWriter {\n  SegmentNode *pTree;             /* Pointer to interior tree structure */\n  sqlite3_int64 iFirst;           /* First slot in %_segments written */\n  sqlite3_int64 iFree;            /* Next free slot in %_segments */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nSize;                      /* Size of allocation at aData */\n  int nData;                      /* Bytes of data in aData */\n  char *aData;                    /* Pointer to block from malloc() */\n  i64 nLeafData;                  /* Number of bytes of leaf data written */\n};\n\n/*\n** Type SegmentNode is used by the following three functions to create\n** the interior part of the segment b+-tree structures (everything except\n** the leaf nodes). These functions and type are only ever used by code\n** within the fts3SegWriterXXX() family of functions described above.\n**\n**   fts3NodeAddTerm()\n**   fts3NodeWrite()\n**   fts3NodeFree()\n**\n** When a b+tree is written to the database (either as a result of a merge\n** or the pending-terms table being flushed), leaves are written into the \n** database file as soon as they are completely populated. The interior of\n** the tree is assembled in memory and written out only once all leaves have\n** been populated and stored. This is Ok, as the b+-tree fanout is usually\n** very large, meaning that the interior of the tree consumes relatively \n** little memory.\n*/\nstruct SegmentNode {\n  SegmentNode *pParent;           /* Parent node (or NULL for root node) */\n  SegmentNode *pRight;            /* Pointer to right-sibling */\n  SegmentNode *pLeftmost;         /* Pointer to left-most node of this depth */\n  int nEntry;                     /* Number of terms written to node so far */\n  char *zTerm;                    /* Pointer to previous term buffer */\n  int nTerm;                      /* Number of bytes in zTerm */\n  int nMalloc;                    /* Size of malloc'd buffer at zMalloc */\n  char *zMalloc;                  /* Malloc'd space (possibly) used for zTerm */\n  int nData;                      /* Bytes of valid data so far */\n  char *aData;                    /* Node data */\n};\n\n/*\n** Valid values for the second argument to fts3SqlStmt().\n*/\n#define SQL_DELETE_CONTENT             0\n#define SQL_IS_EMPTY                   1\n#define SQL_DELETE_ALL_CONTENT         2 \n#define SQL_DELETE_ALL_SEGMENTS        3\n#define SQL_DELETE_ALL_SEGDIR          4\n#define SQL_DELETE_ALL_DOCSIZE         5\n#define SQL_DELETE_ALL_STAT            6\n#define SQL_SELECT_CONTENT_BY_ROWID    7\n#define SQL_NEXT_SEGMENT_INDEX         8\n#define SQL_INSERT_SEGMENTS            9\n#define SQL_NEXT_SEGMENTS_ID          10\n#define SQL_INSERT_SEGDIR             11\n#define SQL_SELECT_LEVEL              12\n#define SQL_SELECT_LEVEL_RANGE        13\n#define SQL_SELECT_LEVEL_COUNT        14\n#define SQL_SELECT_SEGDIR_MAX_LEVEL   15\n#define SQL_DELETE_SEGDIR_LEVEL       16\n#define SQL_DELETE_SEGMENTS_RANGE     17\n#define SQL_CONTENT_INSERT            18\n#define SQL_DELETE_DOCSIZE            19\n#define SQL_REPLACE_DOCSIZE           20\n#define SQL_SELECT_DOCSIZE            21\n#define SQL_SELECT_STAT               22\n#define SQL_REPLACE_STAT              23\n\n#define SQL_SELECT_ALL_PREFIX_LEVEL   24\n#define SQL_DELETE_ALL_TERMS_SEGDIR   25\n#define SQL_DELETE_SEGDIR_RANGE       26\n#define SQL_SELECT_ALL_LANGID         27\n#define SQL_FIND_MERGE_LEVEL          28\n#define SQL_MAX_LEAF_NODE_ESTIMATE    29\n#define SQL_DELETE_SEGDIR_ENTRY       30\n#define SQL_SHIFT_SEGDIR_ENTRY        31\n#define SQL_SELECT_SEGDIR             32\n#define SQL_CHOMP_SEGDIR              33\n#define SQL_SEGMENT_IS_APPENDABLE     34\n#define SQL_SELECT_INDEXES            35\n#define SQL_SELECT_MXLEVEL            36\n\n#define SQL_SELECT_LEVEL_RANGE2       37\n#define SQL_UPDATE_LEVEL_IDX          38\n#define SQL_UPDATE_LEVEL              39\n\n/*\n** This function is used to obtain an SQLite prepared statement handle\n** for the statement identified by the second argument. If successful,\n** *pp is set to the requested statement handle and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned and *pp is set to 0.\n**\n** If argument apVal is not NULL, then it must point to an array with\n** at least as many entries as the requested statement has bound \n** parameters. The values are bound to the statements parameters before\n** returning.\n*/\nstatic int fts3SqlStmt(\n  Fts3Table *p,                   /* Virtual table handle */\n  int eStmt,                      /* One of the SQL_XXX constants above */\n  sqlite3_stmt **pp,              /* OUT: Statement handle */\n  sqlite3_value **apVal           /* Values to bind to statement */\n){\n  const char *azSql[] = {\n/* 0  */  \"DELETE FROM %Q.'%q_content' WHERE rowid = ?\",\n/* 1  */  \"SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)\",\n/* 2  */  \"DELETE FROM %Q.'%q_content'\",\n/* 3  */  \"DELETE FROM %Q.'%q_segments'\",\n/* 4  */  \"DELETE FROM %Q.'%q_segdir'\",\n/* 5  */  \"DELETE FROM %Q.'%q_docsize'\",\n/* 6  */  \"DELETE FROM %Q.'%q_stat'\",\n/* 7  */  \"SELECT %s WHERE rowid=?\",\n/* 8  */  \"SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1\",\n/* 9  */  \"REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)\",\n/* 10 */  \"SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)\",\n/* 11 */  \"REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 12 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC\",\n/* 13 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\"\n            \"ORDER BY level DESC, idx ASC\",\n\n/* 14 */  \"SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 15 */  \"SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n\n/* 16 */  \"DELETE FROM %Q.'%q_segdir' WHERE level = ?\",\n/* 17 */  \"DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?\",\n/* 18 */  \"INSERT INTO %Q.'%q_content' VALUES(%s)\",\n/* 19 */  \"DELETE FROM %Q.'%q_docsize' WHERE docid = ?\",\n/* 20 */  \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",\n/* 21 */  \"SELECT size FROM %Q.'%q_docsize' WHERE docid=?\",\n/* 22 */  \"SELECT value FROM %Q.'%q_stat' WHERE id=?\",\n/* 23 */  \"REPLACE INTO %Q.'%q_stat' VALUES(?,?)\",\n/* 24 */  \"\",\n/* 25 */  \"\",\n\n/* 26 */ \"DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\",\n/* 27 */ \"SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'\",\n\n/* This statement is used to determine which level to read the input from\n** when performing an incremental merge. It returns the absolute level number\n** of the oldest level in the db that contains at least ? segments. Or,\n** if no level in the FTS index contains more than ? segments, the statement\n** returns zero rows.  */\n/* 28 */ \"SELECT level, count(*) AS cnt FROM %Q.'%q_segdir' \"\n         \"  GROUP BY level HAVING cnt>=?\"\n         \"  ORDER BY (level %% 1024) ASC LIMIT 1\",\n\n/* Estimate the upper limit on the number of leaf nodes in a new segment\n** created by merging the oldest :2 segments from absolute level :1. See \n** function sqlite3Fts3Incrmerge() for details.  */\n/* 29 */ \"SELECT 2 * total(1 + leaves_end_block - start_block) \"\n         \"  FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?\",\n\n/* SQL_DELETE_SEGDIR_ENTRY\n**   Delete the %_segdir entry on absolute level :1 with index :2.  */\n/* 30 */ \"DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_SHIFT_SEGDIR_ENTRY\n**   Modify the idx value for the segment with idx=:3 on absolute level :2\n**   to :1.  */\n/* 31 */ \"UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?\",\n\n/* SQL_SELECT_SEGDIR\n**   Read a single entry from the %_segdir table. The entry from absolute \n**   level :1 with index value :2.  */\n/* 32 */  \"SELECT idx, start_block, leaves_end_block, end_block, root \"\n            \"FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?\",\n\n/* SQL_CHOMP_SEGDIR\n**   Update the start_block (:1) and root (:2) fields of the %_segdir\n**   entry located on absolute level :3 with index :4.  */\n/* 33 */  \"UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?\"\n            \"WHERE level = ? AND idx = ?\",\n\n/* SQL_SEGMENT_IS_APPENDABLE\n**   Return a single row if the segment with end_block=? is appendable. Or\n**   no rows otherwise.  */\n/* 34 */  \"SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL\",\n\n/* SQL_SELECT_INDEXES\n**   Return the list of valid segment indexes for absolute level ?  */\n/* 35 */  \"SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC\",\n\n/* SQL_SELECT_MXLEVEL\n**   Return the largest relative level in the FTS index or indexes.  */\n/* 36 */  \"SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'\",\n\n          /* Return segments in order from oldest to newest.*/ \n/* 37 */  \"SELECT level, idx, end_block \"\n            \"FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ? \"\n            \"ORDER BY level DESC, idx ASC\",\n\n          /* Update statements used while promoting segments */\n/* 38 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=-1,idx=? \"\n            \"WHERE level=? AND idx=?\",\n/* 39 */  \"UPDATE OR FAIL %Q.'%q_segdir' SET level=? WHERE level=-1\"\n\n  };\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt;\n\n  assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );\n  assert( eStmt<SizeofArray(azSql) && eStmt>=0 );\n  \n  pStmt = p->aStmt[eStmt];\n  if( !pStmt ){\n    char *zSql;\n    if( eStmt==SQL_CONTENT_INSERT ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);\n    }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);\n    }else{\n      zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);\n    }\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,\n                              &pStmt, NULL);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pStmt==0 );\n      p->aStmt[eStmt] = pStmt;\n    }\n  }\n  if( apVal ){\n    int i;\n    int nParam = sqlite3_bind_parameter_count(pStmt);\n    for(i=0; rc==SQLITE_OK && i<nParam; i++){\n      rc = sqlite3_bind_value(pStmt, i+1, apVal[i]);\n    }\n  }\n  *pp = pStmt;\n  return rc;\n}\n\n\nstatic int fts3SelectDocsize(\n  Fts3Table *pTab,                /* FTS3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to bind for SQL_SELECT_DOCSIZE */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;        /* Statement requested from fts3SqlStmt() */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iDocid);\n    rc = sqlite3_step(pStmt);\n    if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n    if( sqlite3_step(pStmt)!=SQLITE_ROW\n     || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB\n    ){\n      rc = sqlite3_reset(pStmt);\n      if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;\n      pStmt = 0;\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SelectDocsize(\n  Fts3Table *pTab,                /* Fts3 table handle */\n  sqlite3_int64 iDocid,           /* Docid to read size data for */\n  sqlite3_stmt **ppStmt           /* OUT: Statement handle */\n){\n  return fts3SelectDocsize(pTab, iDocid, ppStmt);\n}\n\n/*\n** Similar to fts3SqlStmt(). Except, after binding the parameters in\n** array apVal[] to the SQL statement identified by eStmt, the statement\n** is executed.\n**\n** Returns SQLITE_OK if the statement is successfully executed, or an\n** SQLite error code otherwise.\n*/\nstatic void fts3SqlExec(\n  int *pRC,                /* Result code */\n  Fts3Table *p,            /* The FTS3 table */\n  int eStmt,               /* Index of statement to evaluate */\n  sqlite3_value **apVal    /* Parameters to bind */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, eStmt, &pStmt, apVal); \n  if( rc==SQLITE_OK ){\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  *pRC = rc;\n}\n\n\n/*\n** This function ensures that the caller has obtained an exclusive \n** shared-cache table-lock on the %_segdir table. This is required before \n** writing data to the fts3 table. If this lock is not acquired first, then\n** the caller may end up attempting to take this lock as part of committing\n** a transaction, causing SQLite to return SQLITE_LOCKED or \n** LOCKED_SHAREDCACHEto a COMMIT command.\n**\n** It is best to avoid this because if FTS3 returns any error when \n** committing a transaction, the whole transaction will be rolled back. \n** And this is not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. \n** It can still happen if the user locks the underlying tables directly \n** instead of accessing them via FTS.\n*/\nstatic int fts3Writelock(Fts3Table *p){\n  int rc = SQLITE_OK;\n  \n  if( p->nPendingData==0 ){\n    sqlite3_stmt *pStmt;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pStmt, 1);\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** FTS maintains a separate indexes for each language-id (a 32-bit integer).\n** Within each language id, a separate index is maintained to store the\n** document terms, and each configured prefix size (configured the FTS \n** \"prefix=\" option). And each index consists of multiple levels (\"relative\n** levels\").\n**\n** All three of these values (the language id, the specific index and the\n** level within the index) are encoded in 64-bit integer values stored\n** in the %_segdir table on disk. This function is used to convert three\n** separate component values into the single 64-bit integer value that\n** can be used to query the %_segdir table.\n**\n** Specifically, each language-id/index combination is allocated 1024 \n** 64-bit integer level values (\"absolute levels\"). The main terms index\n** for language-id 0 is allocate values 0-1023. The first prefix index\n** (if any) for language-id 0 is allocated values 1024-2047. And so on.\n** Language 1 indexes are allocated immediately following language 0.\n**\n** So, for a system with nPrefix prefix indexes configured, the block of\n** absolute levels that corresponds to language-id iLangid and index \n** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).\n*/\nstatic sqlite3_int64 getAbsoluteLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index in p->aIndex[] */\n  int iLevel                      /* Level of segments */\n){\n  sqlite3_int64 iBase;            /* First absolute level for iLangid/iIndex */\n  assert( iLangid>=0 );\n  assert( p->nIndex>0 );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;\n  return iBase + iLevel;\n}\n\n/*\n** Set *ppStmt to a statement handle that may be used to iterate through\n** all rows in the %_segdir table, from oldest to newest. If successful,\n** return SQLITE_OK. If an error occurs while preparing the statement, \n** return an SQLite error code.\n**\n** There is only ever one instance of this SQL statement compiled for\n** each FTS3 table.\n**\n** The statement returns the following columns from the %_segdir table:\n**\n**   0: idx\n**   1: start_block\n**   2: leaves_end_block\n**   3: end_block\n**   4: root\n*/\nSQLITE_PRIVATE int sqlite3Fts3AllSegdirs(\n  Fts3Table *p,                   /* FTS3 table */\n  int iLangid,                    /* Language being queried */\n  int iIndex,                     /* Index for p->aIndex[] */\n  int iLevel,                     /* Level to select (relative level) */\n  sqlite3_stmt **ppStmt           /* OUT: Compiled statement */\n){\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL || iLevel>=0 );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  if( iLevel<0 ){\n    /* \"SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pStmt, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    /* \"SELECT * FROM %_segdir WHERE level = ? ORDER BY ...\" */\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n    if( rc==SQLITE_OK ){ \n      sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));\n    }\n  }\n  *ppStmt = pStmt;\n  return rc;\n}\n\n\n/*\n** Append a single varint to a PendingList buffer. SQLITE_OK is returned\n** if successful, or an SQLite error code otherwise.\n**\n** This function also serves to allocate the PendingList structure itself.\n** For example, to create a new PendingList structure containing two\n** varints:\n**\n**   PendingList *p = 0;\n**   fts3PendingListAppendVarint(&p, 1);\n**   fts3PendingListAppendVarint(&p, 2);\n*/\nstatic int fts3PendingListAppendVarint(\n  PendingList **pp,               /* IN/OUT: Pointer to PendingList struct */\n  sqlite3_int64 i                 /* Value to append to data */\n){\n  PendingList *p = *pp;\n\n  /* Allocate or grow the PendingList as required. */\n  if( !p ){\n    p = sqlite3_malloc(sizeof(*p) + 100);\n    if( !p ){\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = 100;\n    p->aData = (char *)&p[1];\n    p->nData = 0;\n  }\n  else if( p->nData+FTS3_VARINT_MAX+1>p->nSpace ){\n    int nNew = p->nSpace * 2;\n    p = sqlite3_realloc(p, sizeof(*p) + nNew);\n    if( !p ){\n      sqlite3_free(*pp);\n      *pp = 0;\n      return SQLITE_NOMEM;\n    }\n    p->nSpace = nNew;\n    p->aData = (char *)&p[1];\n  }\n\n  /* Append the new serialized varint to the end of the list. */\n  p->nData += sqlite3Fts3PutVarint(&p->aData[p->nData], i);\n  p->aData[p->nData] = '\\0';\n  *pp = p;\n  return SQLITE_OK;\n}\n\n/*\n** Add a docid/column/position entry to a PendingList structure. Non-zero\n** is returned if the structure is sqlite3_realloced as part of adding\n** the entry. Otherwise, zero.\n**\n** If an OOM error occurs, *pRc is set to SQLITE_NOMEM before returning.\n** Zero is always returned in this case. Otherwise, if no OOM error occurs,\n** it is set to SQLITE_OK.\n*/\nstatic int fts3PendingListAppend(\n  PendingList **pp,               /* IN/OUT: PendingList structure */\n  sqlite3_int64 iDocid,           /* Docid for entry to add */\n  sqlite3_int64 iCol,             /* Column for entry to add */\n  sqlite3_int64 iPos,             /* Position of term for entry to add */\n  int *pRc                        /* OUT: Return code */\n){\n  PendingList *p = *pp;\n  int rc = SQLITE_OK;\n\n  assert( !p || p->iLastDocid<=iDocid );\n\n  if( !p || p->iLastDocid!=iDocid ){\n    sqlite3_int64 iDelta = iDocid - (p ? p->iLastDocid : 0);\n    if( p ){\n      assert( p->nData<p->nSpace );\n      assert( p->aData[p->nData]==0 );\n      p->nData++;\n    }\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iDelta)) ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = -1;\n    p->iLastPos = 0;\n    p->iLastDocid = iDocid;\n  }\n  if( iCol>0 && p->iLastCol!=iCol ){\n    if( SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, 1))\n     || SQLITE_OK!=(rc = fts3PendingListAppendVarint(&p, iCol))\n    ){\n      goto pendinglistappend_out;\n    }\n    p->iLastCol = iCol;\n    p->iLastPos = 0;\n  }\n  if( iCol>=0 ){\n    assert( iPos>p->iLastPos || (iPos==0 && p->iLastPos==0) );\n    rc = fts3PendingListAppendVarint(&p, 2+iPos-p->iLastPos);\n    if( rc==SQLITE_OK ){\n      p->iLastPos = iPos;\n    }\n  }\n\n pendinglistappend_out:\n  *pRc = rc;\n  if( p!=*pp ){\n    *pp = p;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Free a PendingList object allocated by fts3PendingListAppend().\n*/\nstatic void fts3PendingListDelete(PendingList *pList){\n  sqlite3_free(pList);\n}\n\n/*\n** Add an entry to one of the pending-terms hash tables.\n*/\nstatic int fts3PendingTermsAddOne(\n  Fts3Table *p,\n  int iCol,\n  int iPos,\n  Fts3Hash *pHash,                /* Pending terms hash table to add entry to */\n  const char *zToken,\n  int nToken\n){\n  PendingList *pList;\n  int rc = SQLITE_OK;\n\n  pList = (PendingList *)fts3HashFind(pHash, zToken, nToken);\n  if( pList ){\n    p->nPendingData -= (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  if( fts3PendingListAppend(&pList, p->iPrevDocid, iCol, iPos, &rc) ){\n    if( pList==fts3HashInsert(pHash, zToken, nToken, pList) ){\n      /* Malloc failed while inserting the new entry. This can only \n      ** happen if there was no previous entry for this token.\n      */\n      assert( 0==fts3HashFind(pHash, zToken, nToken) );\n      sqlite3_free(pList);\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    p->nPendingData += (pList->nData + nToken + sizeof(Fts3HashElem));\n  }\n  return rc;\n}\n\n/*\n** Tokenize the nul-terminated string zText and add all tokens to the\n** pending-terms hash-table. The docid used is that currently stored in\n** p->iPrevDocid, and the column is specified by argument iCol.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3PendingTermsAdd(\n  Fts3Table *p,                   /* Table into which text will be inserted */\n  int iLangid,                    /* Language id to use */\n  const char *zText,              /* Text of document to be inserted */\n  int iCol,                       /* Column into which text is being inserted */\n  u32 *pnWord                     /* IN/OUT: Incr. by number tokens inserted */\n){\n  int rc;\n  int iStart = 0;\n  int iEnd = 0;\n  int iPos = 0;\n  int nWord = 0;\n\n  char const *zToken;\n  int nToken = 0;\n\n  sqlite3_tokenizer *pTokenizer = p->pTokenizer;\n  sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;\n  sqlite3_tokenizer_cursor *pCsr;\n  int (*xNext)(sqlite3_tokenizer_cursor *pCursor,\n      const char**,int*,int*,int*,int*);\n\n  assert( pTokenizer && pModule );\n\n  /* If the user has inserted a NULL value, this function may be called with\n  ** zText==0. In this case, add zero token entries to the hash table and \n  ** return early. */\n  if( zText==0 ){\n    *pnWord = 0;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Fts3OpenTokenizer(pTokenizer, iLangid, zText, -1, &pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  xNext = pModule->xNext;\n  while( SQLITE_OK==rc\n      && SQLITE_OK==(rc = xNext(pCsr, &zToken, &nToken, &iStart, &iEnd, &iPos))\n  ){\n    int i;\n    if( iPos>=nWord ) nWord = iPos+1;\n\n    /* Positions cannot be negative; we use -1 as a terminator internally.\n    ** Tokens must have a non-zero length.\n    */\n    if( iPos<0 || !zToken || nToken<=0 ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    /* Add the term to the terms index */\n    rc = fts3PendingTermsAddOne(\n        p, iCol, iPos, &p->aIndex[0].hPending, zToken, nToken\n    );\n    \n    /* Add the term to each of the prefix indexes that it is not too \n    ** short for. */\n    for(i=1; rc==SQLITE_OK && i<p->nIndex; i++){\n      struct Fts3Index *pIndex = &p->aIndex[i];\n      if( nToken<pIndex->nPrefix ) continue;\n      rc = fts3PendingTermsAddOne(\n          p, iCol, iPos, &pIndex->hPending, zToken, pIndex->nPrefix\n      );\n    }\n  }\n\n  pModule->xClose(pCsr);\n  *pnWord += nWord;\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/* \n** Calling this function indicates that subsequent calls to \n** fts3PendingTermsAdd() are to add term/position-list pairs for the\n** contents of the document with docid iDocid.\n*/\nstatic int fts3PendingTermsDocid(\n  Fts3Table *p,                   /* Full-text table handle */\n  int bDelete,                    /* True if this op is a delete */\n  int iLangid,                    /* Language id of row being written */\n  sqlite_int64 iDocid             /* Docid of row being written */\n){\n  assert( iLangid>=0 );\n  assert( bDelete==1 || bDelete==0 );\n\n  /* TODO(shess) Explore whether partially flushing the buffer on\n  ** forced-flush would provide better performance.  I suspect that if\n  ** we ordered the doclists by size and flushed the largest until the\n  ** buffer was half empty, that would let the less frequent terms\n  ** generate longer doclists.\n  */\n  if( iDocid<p->iPrevDocid \n   || (iDocid==p->iPrevDocid && p->bPrevDelete==0)\n   || p->iPrevLangid!=iLangid\n   || p->nPendingData>p->nMaxPendingData \n  ){\n    int rc = sqlite3Fts3PendingTermsFlush(p);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  p->iPrevDocid = iDocid;\n  p->iPrevLangid = iLangid;\n  p->bPrevDelete = bDelete;\n  return SQLITE_OK;\n}\n\n/*\n** Discard the contents of the pending-terms hash tables. \n*/\nSQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *p){\n  int i;\n  for(i=0; i<p->nIndex; i++){\n    Fts3HashElem *pElem;\n    Fts3Hash *pHash = &p->aIndex[i].hPending;\n    for(pElem=fts3HashFirst(pHash); pElem; pElem=fts3HashNext(pElem)){\n      PendingList *pList = (PendingList *)fts3HashData(pElem);\n      fts3PendingListDelete(pList);\n    }\n    fts3HashClear(pHash);\n  }\n  p->nPendingData = 0;\n}\n\n/*\n** This function is called by the xUpdate() method as part of an INSERT\n** operation. It adds entries for each term in the new record to the\n** pendingTerms hash table.\n**\n** Argument apVal is the same as the similarly named argument passed to\n** fts3InsertData(). Parameter iDocid is the docid of the new row.\n*/\nstatic int fts3InsertTerms(\n  Fts3Table *p, \n  int iLangid, \n  sqlite3_value **apVal, \n  u32 *aSz\n){\n  int i;                          /* Iterator variable */\n  for(i=2; i<p->nColumn+2; i++){\n    int iCol = i-2;\n    if( p->abNotindexed[iCol]==0 ){\n      const char *zText = (const char *)sqlite3_value_text(apVal[i]);\n      int rc = fts3PendingTermsAdd(p, iLangid, zText, iCol, &aSz[iCol]);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      aSz[p->nColumn] += sqlite3_value_bytes(apVal[i]);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is called by the xUpdate() method for an INSERT operation.\n** The apVal parameter is passed a copy of the apVal argument passed by\n** SQLite to the xUpdate() method. i.e:\n**\n**   apVal[0]                Not used for INSERT.\n**   apVal[1]                rowid\n**   apVal[2]                Left-most user-defined column\n**   ...\n**   apVal[p->nColumn+1]     Right-most user-defined column\n**   apVal[p->nColumn+2]     Hidden column with same name as table\n**   apVal[p->nColumn+3]     Hidden \"docid\" column (alias for rowid)\n**   apVal[p->nColumn+4]     Hidden languageid column\n*/\nstatic int fts3InsertData(\n  Fts3Table *p,                   /* Full-text table */\n  sqlite3_value **apVal,          /* Array of values to insert */\n  sqlite3_int64 *piDocid          /* OUT: Docid for row just inserted */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pContentInsert;   /* INSERT INTO %_content VALUES(...) */\n\n  if( p->zContentTbl ){\n    sqlite3_value *pRowid = apVal[p->nColumn+3];\n    if( sqlite3_value_type(pRowid)==SQLITE_NULL ){\n      pRowid = apVal[1];\n    }\n    if( sqlite3_value_type(pRowid)!=SQLITE_INTEGER ){\n      return SQLITE_CONSTRAINT;\n    }\n    *piDocid = sqlite3_value_int64(pRowid);\n    return SQLITE_OK;\n  }\n\n  /* Locate the statement handle used to insert data into the %_content\n  ** table. The SQL for this statement is:\n  **\n  **   INSERT INTO %_content VALUES(?, ?, ?, ...)\n  **\n  ** The statement features N '?' variables, where N is the number of user\n  ** defined columns in the FTS3 table, plus one for the docid field.\n  */\n  rc = fts3SqlStmt(p, SQL_CONTENT_INSERT, &pContentInsert, &apVal[1]);\n  if( rc==SQLITE_OK && p->zLanguageid ){\n    rc = sqlite3_bind_int(\n        pContentInsert, p->nColumn+2, \n        sqlite3_value_int(apVal[p->nColumn+4])\n    );\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* There is a quirk here. The users INSERT statement may have specified\n  ** a value for the \"rowid\" field, for the \"docid\" field, or for both.\n  ** Which is a problem, since \"rowid\" and \"docid\" are aliases for the\n  ** same value. For example:\n  **\n  **   INSERT INTO fts3tbl(rowid, docid) VALUES(1, 2);\n  **\n  ** In FTS3, this is an error. It is an error to specify non-NULL values\n  ** for both docid and some other rowid alias.\n  */\n  if( SQLITE_NULL!=sqlite3_value_type(apVal[3+p->nColumn]) ){\n    if( SQLITE_NULL==sqlite3_value_type(apVal[0])\n     && SQLITE_NULL!=sqlite3_value_type(apVal[1])\n    ){\n      /* A rowid/docid conflict. */\n      return SQLITE_ERROR;\n    }\n    rc = sqlite3_bind_value(pContentInsert, 1, apVal[3+p->nColumn]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  /* Execute the statement to insert the record. Set *piDocid to the \n  ** new docid value. \n  */\n  sqlite3_step(pContentInsert);\n  rc = sqlite3_reset(pContentInsert);\n\n  *piDocid = sqlite3_last_insert_rowid(p->db);\n  return rc;\n}\n\n\n\n/*\n** Remove all data from the FTS3 table. Clear the hash table containing\n** pending terms.\n*/\nstatic int fts3DeleteAll(Fts3Table *p, int bContent){\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* Discard the contents of the pending-terms hash table. */\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Delete everything from the shadow tables. Except, leave %_content as\n  ** is if bContent is false.  */\n  assert( p->zContentTbl==0 || bContent==0 );\n  if( bContent ) fts3SqlExec(&rc, p, SQL_DELETE_ALL_CONTENT, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGMENTS, 0);\n  fts3SqlExec(&rc, p, SQL_DELETE_ALL_SEGDIR, 0);\n  if( p->bHasDocsize ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_DOCSIZE, 0);\n  }\n  if( p->bHasStat ){\n    fts3SqlExec(&rc, p, SQL_DELETE_ALL_STAT, 0);\n  }\n  return rc;\n}\n\n/*\n**\n*/\nstatic int langidFromSelect(Fts3Table *p, sqlite3_stmt *pSelect){\n  int iLangid = 0;\n  if( p->zLanguageid ) iLangid = sqlite3_column_int(pSelect, p->nColumn+1);\n  return iLangid;\n}\n\n/*\n** The first element in the apVal[] array is assumed to contain the docid\n** (an integer) of a row about to be deleted. Remove all terms from the\n** full-text index.\n*/\nstatic void fts3DeleteTerms( \n  int *pRC,               /* Result code */\n  Fts3Table *p,           /* The FTS table to delete from */\n  sqlite3_value *pRowid,  /* The docid to be deleted */\n  u32 *aSz,               /* Sizes of deleted document written here */\n  int *pbFound            /* OUT: Set to true if row really does exist */\n){\n  int rc;\n  sqlite3_stmt *pSelect;\n\n  assert( *pbFound==0 );\n  if( *pRC ) return;\n  rc = fts3SqlStmt(p, SQL_SELECT_CONTENT_BY_ROWID, &pSelect, &pRowid);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      int i;\n      int iLangid = langidFromSelect(p, pSelect);\n      i64 iDocid = sqlite3_column_int64(pSelect, 0);\n      rc = fts3PendingTermsDocid(p, 1, iLangid, iDocid);\n      for(i=1; rc==SQLITE_OK && i<=p->nColumn; i++){\n        int iCol = i-1;\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pSelect, i);\n          rc = fts3PendingTermsAdd(p, iLangid, zText, -1, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pSelect, i);\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_reset(pSelect);\n        *pRC = rc;\n        return;\n      }\n      *pbFound = 1;\n    }\n    rc = sqlite3_reset(pSelect);\n  }else{\n    sqlite3_reset(pSelect);\n  }\n  *pRC = rc;\n}\n\n/*\n** Forward declaration to account for the circular dependency between\n** functions fts3SegmentMerge() and fts3AllocateSegdirIdx().\n*/\nstatic int fts3SegmentMerge(Fts3Table *, int, int, int);\n\n/* \n** This function allocates a new level iLevel index in the segdir table.\n** Usually, indexes are allocated within a level sequentially starting\n** with 0, so the allocated index is one greater than the value returned\n** by:\n**\n**   SELECT max(idx) FROM %_segdir WHERE level = :iLevel\n**\n** However, if there are already FTS3_MERGE_COUNT indexes at the requested\n** level, they are merged into a single level (iLevel+1) segment and the \n** allocated index is 0.\n**\n** If successful, *piIdx is set to the allocated index slot and SQLITE_OK\n** returned. Otherwise, an SQLite error code is returned.\n*/\nstatic int fts3AllocateSegdirIdx(\n  Fts3Table *p, \n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel, \n  int *piIdx\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pNextIdx;         /* Query for next idx at level iLevel */\n  int iNext = 0;                  /* Result of query pNextIdx */\n\n  assert( iLangid>=0 );\n  assert( p->nIndex>=1 );\n\n  /* Set variable iNext to the next available segdir index at level iLevel. */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pNextIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(\n        pNextIdx, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n    );\n    if( SQLITE_ROW==sqlite3_step(pNextIdx) ){\n      iNext = sqlite3_column_int(pNextIdx, 0);\n    }\n    rc = sqlite3_reset(pNextIdx);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* If iNext is FTS3_MERGE_COUNT, indicating that level iLevel is already\n    ** full, merge all segments in level iLevel into a single iLevel+1\n    ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,\n    ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.\n    */\n    if( iNext>=FTS3_MERGE_COUNT ){\n      fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));\n      rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);\n      *piIdx = 0;\n    }else{\n      *piIdx = iNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The %_segments table is declared as follows:\n**\n**   CREATE TABLE %_segments(blockid INTEGER PRIMARY KEY, block BLOB)\n**\n** This function reads data from a single row of the %_segments table. The\n** specific row is identified by the iBlockid parameter. If paBlob is not\n** NULL, then a buffer is allocated using sqlite3_malloc() and populated\n** with the contents of the blob stored in the \"block\" column of the \n** identified table row is. Whether or not paBlob is NULL, *pnBlob is set\n** to the size of the blob in bytes before returning.\n**\n** If an error occurs, or the table does not contain the specified row,\n** an SQLite error code is returned. Otherwise, SQLITE_OK is returned. If\n** paBlob is non-NULL, then it is the responsibility of the caller to\n** eventually free the returned buffer.\n**\n** This function may leave an open sqlite3_blob* handle in the\n** Fts3Table.pSegments variable. This handle is reused by subsequent calls\n** to this function. The handle may be closed by calling the\n** sqlite3Fts3SegmentsClose() function. Reusing a blob handle is a handy\n** performance improvement, but the blob handle should always be closed\n** before control is returned to the user (to prevent a lock being held\n** on the database file for longer than necessary). Thus, any virtual table\n** method (xFilter etc.) that may directly or indirectly call this function\n** must call sqlite3Fts3SegmentsClose() before returning.\n*/\nSQLITE_PRIVATE int sqlite3Fts3ReadBlock(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iBlockid,         /* Access the row with blockid=$iBlockid */\n  char **paBlob,                  /* OUT: Blob data in malloc'd buffer */\n  int *pnBlob,                    /* OUT: Size of blob data */\n  int *pnLoad                     /* OUT: Bytes actually loaded */\n){\n  int rc;                         /* Return code */\n\n  /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */\n  assert( pnBlob );\n\n  if( p->pSegments ){\n    rc = sqlite3_blob_reopen(p->pSegments, iBlockid);\n  }else{\n    if( 0==p->zSegmentsTbl ){\n      p->zSegmentsTbl = sqlite3_mprintf(\"%s_segments\", p->zName);\n      if( 0==p->zSegmentsTbl ) return SQLITE_NOMEM;\n    }\n    rc = sqlite3_blob_open(\n       p->db, p->zDb, p->zSegmentsTbl, \"block\", iBlockid, 0, &p->pSegments\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = sqlite3_blob_bytes(p->pSegments);\n    *pnBlob = nByte;\n    if( paBlob ){\n      char *aByte = sqlite3_malloc(nByte + FTS3_NODE_PADDING);\n      if( !aByte ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pnLoad && nByte>(FTS3_NODE_CHUNK_THRESHOLD) ){\n          nByte = FTS3_NODE_CHUNKSIZE;\n          *pnLoad = nByte;\n        }\n        rc = sqlite3_blob_read(p->pSegments, aByte, nByte, 0);\n        memset(&aByte[nByte], 0, FTS3_NODE_PADDING);\n        if( rc!=SQLITE_OK ){\n          sqlite3_free(aByte);\n          aByte = 0;\n        }\n      }\n      *paBlob = aByte;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Close the blob handle at p->pSegments, if it is open. See comments above\n** the sqlite3Fts3ReadBlock() function for details.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *p){\n  sqlite3_blob_close(p->pSegments);\n  p->pSegments = 0;\n}\n    \nstatic int fts3SegReaderIncrRead(Fts3SegReader *pReader){\n  int nRead;                      /* Number of bytes to read */\n  int rc;                         /* Return code */\n\n  nRead = MIN(pReader->nNode - pReader->nPopulate, FTS3_NODE_CHUNKSIZE);\n  rc = sqlite3_blob_read(\n      pReader->pBlob, \n      &pReader->aNode[pReader->nPopulate],\n      nRead,\n      pReader->nPopulate\n  );\n\n  if( rc==SQLITE_OK ){\n    pReader->nPopulate += nRead;\n    memset(&pReader->aNode[pReader->nPopulate], 0, FTS3_NODE_PADDING);\n    if( pReader->nPopulate==pReader->nNode ){\n      sqlite3_blob_close(pReader->pBlob);\n      pReader->pBlob = 0;\n      pReader->nPopulate = 0;\n    }\n  }\n  return rc;\n}\n\nstatic int fts3SegReaderRequire(Fts3SegReader *pReader, char *pFrom, int nByte){\n  int rc = SQLITE_OK;\n  assert( !pReader->pBlob \n       || (pFrom>=pReader->aNode && pFrom<&pReader->aNode[pReader->nNode])\n  );\n  while( pReader->pBlob && rc==SQLITE_OK \n     &&  (pFrom - pReader->aNode + nByte)>pReader->nPopulate\n  ){\n    rc = fts3SegReaderIncrRead(pReader);\n  }\n  return rc;\n}\n\n/*\n** Set an Fts3SegReader cursor to point at EOF.\n*/\nstatic void fts3SegReaderSetEof(Fts3SegReader *pSeg){\n  if( !fts3SegReaderIsRootOnly(pSeg) ){\n    sqlite3_free(pSeg->aNode);\n    sqlite3_blob_close(pSeg->pBlob);\n    pSeg->pBlob = 0;\n  }\n  pSeg->aNode = 0;\n}\n\n/*\n** Move the iterator passed as the first argument to the next term in the\n** segment. If successful, SQLITE_OK is returned. If there is no next term,\n** SQLITE_DONE. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegReaderNext(\n  Fts3Table *p, \n  Fts3SegReader *pReader,\n  int bIncr\n){\n  int rc;                         /* Return code of various sub-routines */\n  char *pNext;                    /* Cursor variable */\n  int nPrefix;                    /* Number of bytes in term prefix */\n  int nSuffix;                    /* Number of bytes in term suffix */\n\n  if( !pReader->aDoclist ){\n    pNext = pReader->aNode;\n  }else{\n    pNext = &pReader->aDoclist[pReader->nDoclist];\n  }\n\n  if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){\n\n    if( fts3SegReaderIsPending(pReader) ){\n      Fts3HashElem *pElem = *(pReader->ppNextElem);\n      sqlite3_free(pReader->aNode);\n      pReader->aNode = 0;\n      if( pElem ){\n        char *aCopy;\n        PendingList *pList = (PendingList *)fts3HashData(pElem);\n        int nCopy = pList->nData+1;\n        pReader->zTerm = (char *)fts3HashKey(pElem);\n        pReader->nTerm = fts3HashKeysize(pElem);\n        aCopy = (char*)sqlite3_malloc(nCopy);\n        if( !aCopy ) return SQLITE_NOMEM;\n        memcpy(aCopy, pList->aData, nCopy);\n        pReader->nNode = pReader->nDoclist = nCopy;\n        pReader->aNode = pReader->aDoclist = aCopy;\n        pReader->ppNextElem++;\n        assert( pReader->aNode );\n      }\n      return SQLITE_OK;\n    }\n\n    fts3SegReaderSetEof(pReader);\n\n    /* If iCurrentBlock>=iLeafEndBlock, this is an EOF condition. All leaf \n    ** blocks have already been traversed.  */\n    assert( pReader->iCurrentBlock<=pReader->iLeafEndBlock );\n    if( pReader->iCurrentBlock>=pReader->iLeafEndBlock ){\n      return SQLITE_OK;\n    }\n\n    rc = sqlite3Fts3ReadBlock(\n        p, ++pReader->iCurrentBlock, &pReader->aNode, &pReader->nNode, \n        (bIncr ? &pReader->nPopulate : 0)\n    );\n    if( rc!=SQLITE_OK ) return rc;\n    assert( pReader->pBlob==0 );\n    if( bIncr && pReader->nPopulate<pReader->nNode ){\n      pReader->pBlob = p->pSegments;\n      p->pSegments = 0;\n    }\n    pNext = pReader->aNode;\n  }\n\n  assert( !fts3SegReaderIsPending(pReader) );\n\n  rc = fts3SegReaderRequire(pReader, pNext, FTS3_VARINT_MAX*2);\n  if( rc!=SQLITE_OK ) return rc;\n  \n  /* Because of the FTS3_NODE_PADDING bytes of padding, the following is \n  ** safe (no risk of overread) even if the node data is corrupted. */\n  pNext += fts3GetVarint32(pNext, &nPrefix);\n  pNext += fts3GetVarint32(pNext, &nSuffix);\n  if( nPrefix<0 || nSuffix<=0 \n   || &pNext[nSuffix]>&pReader->aNode[pReader->nNode] \n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n\n  if( nPrefix+nSuffix>pReader->nTermAlloc ){\n    int nNew = (nPrefix+nSuffix)*2;\n    char *zNew = sqlite3_realloc(pReader->zTerm, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pReader->zTerm = zNew;\n    pReader->nTermAlloc = nNew;\n  }\n\n  rc = fts3SegReaderRequire(pReader, pNext, nSuffix+FTS3_VARINT_MAX);\n  if( rc!=SQLITE_OK ) return rc;\n\n  memcpy(&pReader->zTerm[nPrefix], pNext, nSuffix);\n  pReader->nTerm = nPrefix+nSuffix;\n  pNext += nSuffix;\n  pNext += fts3GetVarint32(pNext, &pReader->nDoclist);\n  pReader->aDoclist = pNext;\n  pReader->pOffsetList = 0;\n\n  /* Check that the doclist does not appear to extend past the end of the\n  ** b-tree node. And that the final byte of the doclist is 0x00. If either \n  ** of these statements is untrue, then the data structure is corrupt.\n  */\n  if( &pReader->aDoclist[pReader->nDoclist]>&pReader->aNode[pReader->nNode] \n   || (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])\n  ){\n    return FTS_CORRUPT_VTAB;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Set the SegReader to point to the first docid in the doclist associated\n** with the current term.\n*/\nstatic int fts3SegReaderFirstDocid(Fts3Table *pTab, Fts3SegReader *pReader){\n  int rc = SQLITE_OK;\n  assert( pReader->aDoclist );\n  assert( !pReader->pOffsetList );\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    u8 bEof = 0;\n    pReader->iDocid = 0;\n    pReader->nOffsetList = 0;\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &pReader->pOffsetList, \n        &pReader->iDocid, &pReader->nOffsetList, &bEof\n    );\n  }else{\n    rc = fts3SegReaderRequire(pReader, pReader->aDoclist, FTS3_VARINT_MAX);\n    if( rc==SQLITE_OK ){\n      int n = sqlite3Fts3GetVarint(pReader->aDoclist, &pReader->iDocid);\n      pReader->pOffsetList = &pReader->aDoclist[n];\n    }\n  }\n  return rc;\n}\n\n/*\n** Advance the SegReader to point to the next docid in the doclist\n** associated with the current term.\n** \n** If arguments ppOffsetList and pnOffsetList are not NULL, then \n** *ppOffsetList is set to point to the first column-offset list\n** in the doclist entry (i.e. immediately past the docid varint).\n** *pnOffsetList is set to the length of the set of column-offset\n** lists, not including the nul-terminator byte. For example:\n*/\nstatic int fts3SegReaderNextDocid(\n  Fts3Table *pTab,\n  Fts3SegReader *pReader,         /* Reader to advance to next docid */\n  char **ppOffsetList,            /* OUT: Pointer to current position-list */\n  int *pnOffsetList               /* OUT: Length of *ppOffsetList in bytes */\n){\n  int rc = SQLITE_OK;\n  char *p = pReader->pOffsetList;\n  char c = 0;\n\n  assert( p );\n\n  if( pTab->bDescIdx && fts3SegReaderIsPending(pReader) ){\n    /* A pending-terms seg-reader for an FTS4 table that uses order=desc.\n    ** Pending-terms doclists are always built up in ascending order, so\n    ** we have to iterate through them backwards here. */\n    u8 bEof = 0;\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = pReader->nOffsetList - 1;\n    }\n    sqlite3Fts3DoclistPrev(0,\n        pReader->aDoclist, pReader->nDoclist, &p, &pReader->iDocid,\n        &pReader->nOffsetList, &bEof\n    );\n    if( bEof ){\n      pReader->pOffsetList = 0;\n    }else{\n      pReader->pOffsetList = p;\n    }\n  }else{\n    char *pEnd = &pReader->aDoclist[pReader->nDoclist];\n\n    /* Pointer p currently points at the first byte of an offset list. The\n    ** following block advances it to point one byte past the end of\n    ** the same offset list. */\n    while( 1 ){\n  \n      /* The following line of code (and the \"p++\" below the while() loop) is\n      ** normally all that is required to move pointer p to the desired \n      ** position. The exception is if this node is being loaded from disk\n      ** incrementally and pointer \"p\" now points to the first byte past\n      ** the populated part of pReader->aNode[].\n      */\n      while( *p | c ) c = *p++ & 0x80;\n      assert( *p==0 );\n  \n      if( pReader->pBlob==0 || p<&pReader->aNode[pReader->nPopulate] ) break;\n      rc = fts3SegReaderIncrRead(pReader);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    p++;\n  \n    /* If required, populate the output variables with a pointer to and the\n    ** size of the previous offset-list.\n    */\n    if( ppOffsetList ){\n      *ppOffsetList = pReader->pOffsetList;\n      *pnOffsetList = (int)(p - pReader->pOffsetList - 1);\n    }\n\n    /* List may have been edited in place by fts3EvalNearTrim() */\n    while( p<pEnd && *p==0 ) p++;\n  \n    /* If there are no more entries in the doclist, set pOffsetList to\n    ** NULL. Otherwise, set Fts3SegReader.iDocid to the next docid and\n    ** Fts3SegReader.pOffsetList to point to the next offset list before\n    ** returning.\n    */\n    if( p>=pEnd ){\n      pReader->pOffsetList = 0;\n    }else{\n      rc = fts3SegReaderRequire(pReader, p, FTS3_VARINT_MAX);\n      if( rc==SQLITE_OK ){\n        sqlite3_int64 iDelta;\n        pReader->pOffsetList = p + sqlite3Fts3GetVarint(p, &iDelta);\n        if( pTab->bDescIdx ){\n          pReader->iDocid -= iDelta;\n        }else{\n          pReader->iDocid += iDelta;\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3MsrOvfl(\n  Fts3Cursor *pCsr, \n  Fts3MultiSegReader *pMsr,\n  int *pnOvfl\n){\n  Fts3Table *p = (Fts3Table*)pCsr->base.pVtab;\n  int nOvfl = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int pgsz = p->nPgsz;\n\n  assert( p->bFts4 );\n  assert( pgsz>0 );\n\n  for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){\n    Fts3SegReader *pReader = pMsr->apSegment[ii];\n    if( !fts3SegReaderIsPending(pReader) \n     && !fts3SegReaderIsRootOnly(pReader) \n    ){\n      sqlite3_int64 jj;\n      for(jj=pReader->iStartBlock; jj<=pReader->iLeafEndBlock; jj++){\n        int nBlob;\n        rc = sqlite3Fts3ReadBlock(p, jj, 0, &nBlob, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( (nBlob+35)>pgsz ){\n          nOvfl += (nBlob + 34)/pgsz;\n        }\n      }\n    }\n  }\n  *pnOvfl = nOvfl;\n  return rc;\n}\n\n/*\n** Free all allocations associated with the iterator passed as the \n** second argument.\n*/\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){\n  if( pReader ){\n    if( !fts3SegReaderIsPending(pReader) ){\n      sqlite3_free(pReader->zTerm);\n    }\n    if( !fts3SegReaderIsRootOnly(pReader) ){\n      sqlite3_free(pReader->aNode);\n    }\n    sqlite3_blob_close(pReader->pBlob);\n  }\n  sqlite3_free(pReader);\n}\n\n/*\n** Allocate a new SegReader object.\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderNew(\n  int iAge,                       /* Segment \"age\". */\n  int bLookup,                    /* True for a lookup only */\n  sqlite3_int64 iStartLeaf,       /* First leaf to traverse */\n  sqlite3_int64 iEndLeaf,         /* Final leaf to traverse */\n  sqlite3_int64 iEndBlock,        /* Final block of segment */\n  const char *zRoot,              /* Buffer containing root node */\n  int nRoot,                      /* Size of buffer containing root node */\n  Fts3SegReader **ppReader        /* OUT: Allocated Fts3SegReader */\n){\n  Fts3SegReader *pReader;         /* Newly allocated SegReader object */\n  int nExtra = 0;                 /* Bytes to allocate segment root node */\n\n  assert( iStartLeaf<=iEndLeaf );\n  if( iStartLeaf==0 ){\n    nExtra = nRoot + FTS3_NODE_PADDING;\n  }\n\n  pReader = (Fts3SegReader *)sqlite3_malloc(sizeof(Fts3SegReader) + nExtra);\n  if( !pReader ){\n    return SQLITE_NOMEM;\n  }\n  memset(pReader, 0, sizeof(Fts3SegReader));\n  pReader->iIdx = iAge;\n  pReader->bLookup = bLookup!=0;\n  pReader->iStartBlock = iStartLeaf;\n  pReader->iLeafEndBlock = iEndLeaf;\n  pReader->iEndBlock = iEndBlock;\n\n  if( nExtra ){\n    /* The entire segment is stored in the root node. */\n    pReader->aNode = (char *)&pReader[1];\n    pReader->rootOnly = 1;\n    pReader->nNode = nRoot;\n    memcpy(pReader->aNode, zRoot, nRoot);\n    memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);\n  }else{\n    pReader->iCurrentBlock = iStartLeaf-1;\n  }\n  *ppReader = pReader;\n  return SQLITE_OK;\n}\n\n/*\n** This is a comparison function used as a qsort() callback when sorting\n** an array of pending terms by term. This occurs as part of flushing\n** the contents of the pending-terms hash table to the database.\n*/\nstatic int SQLITE_CDECL fts3CompareElemByTerm(\n  const void *lhs,\n  const void *rhs\n){\n  char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);\n  char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);\n  int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);\n  int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);\n\n  int n = (n1<n2 ? n1 : n2);\n  int c = memcmp(z1, z2, n);\n  if( c==0 ){\n    c = n1 - n2;\n  }\n  return c;\n}\n\n/*\n** This function is used to allocate an Fts3SegReader that iterates through\n** a subset of the terms stored in the Fts3Table.pendingTerms array.\n**\n** If the isPrefixIter parameter is zero, then the returned SegReader iterates\n** through each term in the pending-terms table. Or, if isPrefixIter is\n** non-zero, it iterates through each term and its prefixes. For example, if\n** the pending terms hash table contains the terms \"sqlite\", \"mysql\" and\n** \"firebird\", then the iterator visits the following 'terms' (in the order\n** shown):\n**\n**   f fi fir fire fireb firebi firebir firebird\n**   m my mys mysq mysql\n**   s sq sql sqli sqlit sqlite\n**\n** Whereas if isPrefixIter is zero, the terms visited are:\n**\n**   firebird mysql sqlite\n*/\nSQLITE_PRIVATE int sqlite3Fts3SegReaderPending(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iIndex,                     /* Index for p->aIndex */\n  const char *zTerm,              /* Term to search for */\n  int nTerm,                      /* Size of buffer zTerm */\n  int bPrefix,                    /* True for a prefix iterator */\n  Fts3SegReader **ppReader        /* OUT: SegReader for pending-terms */\n){\n  Fts3SegReader *pReader = 0;     /* Fts3SegReader object to return */\n  Fts3HashElem *pE;               /* Iterator variable */\n  Fts3HashElem **aElem = 0;       /* Array of term hash entries to scan */\n  int nElem = 0;                  /* Size of array at aElem */\n  int rc = SQLITE_OK;             /* Return Code */\n  Fts3Hash *pHash;\n\n  pHash = &p->aIndex[iIndex].hPending;\n  if( bPrefix ){\n    int nAlloc = 0;               /* Size of allocated array at aElem */\n\n    for(pE=fts3HashFirst(pHash); pE; pE=fts3HashNext(pE)){\n      char *zKey = (char *)fts3HashKey(pE);\n      int nKey = fts3HashKeysize(pE);\n      if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){\n        if( nElem==nAlloc ){\n          Fts3HashElem **aElem2;\n          nAlloc += 16;\n          aElem2 = (Fts3HashElem **)sqlite3_realloc(\n              aElem, nAlloc*sizeof(Fts3HashElem *)\n          );\n          if( !aElem2 ){\n            rc = SQLITE_NOMEM;\n            nElem = 0;\n            break;\n          }\n          aElem = aElem2;\n        }\n\n        aElem[nElem++] = pE;\n      }\n    }\n\n    /* If more than one term matches the prefix, sort the Fts3HashElem\n    ** objects in term order using qsort(). This uses the same comparison\n    ** callback as is used when flushing terms to disk.\n    */\n    if( nElem>1 ){\n      qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);\n    }\n\n  }else{\n    /* The query is a simple term lookup that matches at most one term in\n    ** the index. All that is required is a straight hash-lookup. \n    **\n    ** Because the stack address of pE may be accessed via the aElem pointer\n    ** below, the \"Fts3HashElem *pE\" must be declared so that it is valid\n    ** within this entire function, not just this \"else{...}\" block.\n    */\n    pE = fts3HashFindElem(pHash, zTerm, nTerm);\n    if( pE ){\n      aElem = &pE;\n      nElem = 1;\n    }\n  }\n\n  if( nElem>0 ){\n    int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);\n    pReader = (Fts3SegReader *)sqlite3_malloc(nByte);\n    if( !pReader ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pReader, 0, nByte);\n      pReader->iIdx = 0x7FFFFFFF;\n      pReader->ppNextElem = (Fts3HashElem **)&pReader[1];\n      memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));\n    }\n  }\n\n  if( bPrefix ){\n    sqlite3_free(aElem);\n  }\n  *ppReader = pReader;\n  return rc;\n}\n\n/*\n** Compare the entries pointed to by two Fts3SegReader structures. \n** Comparison is as follows:\n**\n**   1) EOF is greater than not EOF.\n**\n**   2) The current terms (if any) are compared using memcmp(). If one\n**      term is a prefix of another, the longer term is considered the\n**      larger.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc;\n  if( pLhs->aNode && pRhs->aNode ){\n    int rc2 = pLhs->nTerm - pRhs->nTerm;\n    if( rc2<0 ){\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pLhs->nTerm);\n    }else{\n      rc = memcmp(pLhs->zTerm, pRhs->zTerm, pRhs->nTerm);\n    }\n    if( rc==0 ){\n      rc = rc2;\n    }\n  }else{\n    rc = (pLhs->aNode==0) - (pRhs->aNode==0);\n  }\n  if( rc==0 ){\n    rc = pRhs->iIdx - pLhs->iIdx;\n  }\n  assert( rc!=0 );\n  return rc;\n}\n\n/*\n** A different comparison function for SegReader structures. In this\n** version, it is assumed that each SegReader points to an entry in\n** a doclist for identical terms. Comparison is made as follows:\n**\n**   1) EOF (end of doclist in this case) is greater than not EOF.\n**\n**   2) By current docid.\n**\n**   3) By segment age. An older segment is considered larger.\n*/\nstatic int fts3SegReaderDoclistCmp(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid > pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\nstatic int fts3SegReaderDoclistCmpRev(Fts3SegReader *pLhs, Fts3SegReader *pRhs){\n  int rc = (pLhs->pOffsetList==0)-(pRhs->pOffsetList==0);\n  if( rc==0 ){\n    if( pLhs->iDocid==pRhs->iDocid ){\n      rc = pRhs->iIdx - pLhs->iIdx;\n    }else{\n      rc = (pLhs->iDocid < pRhs->iDocid) ? 1 : -1;\n    }\n  }\n  assert( pLhs->aNode && pRhs->aNode );\n  return rc;\n}\n\n/*\n** Compare the term that the Fts3SegReader object passed as the first argument\n** points to with the term specified by arguments zTerm and nTerm. \n**\n** If the pSeg iterator is already at EOF, return 0. Otherwise, return\n** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are\n** equal, or +ve if the pSeg term is greater than zTerm/nTerm.\n*/\nstatic int fts3SegReaderTermCmp(\n  Fts3SegReader *pSeg,            /* Segment reader object */\n  const char *zTerm,              /* Term to compare to */\n  int nTerm                       /* Size of term zTerm in bytes */\n){\n  int res = 0;\n  if( pSeg->aNode ){\n    if( pSeg->nTerm>nTerm ){\n      res = memcmp(pSeg->zTerm, zTerm, nTerm);\n    }else{\n      res = memcmp(pSeg->zTerm, zTerm, pSeg->nTerm);\n    }\n    if( res==0 ){\n      res = pSeg->nTerm-nTerm;\n    }\n  }\n  return res;\n}\n\n/*\n** Argument apSegment is an array of nSegment elements. It is known that\n** the final (nSegment-nSuspect) members are already in sorted order\n** (according to the comparison function provided). This function shuffles\n** the array around until all entries are in sorted order.\n*/\nstatic void fts3SegReaderSort(\n  Fts3SegReader **apSegment,                     /* Array to sort entries of */\n  int nSegment,                                  /* Size of apSegment array */\n  int nSuspect,                                  /* Unsorted entry count */\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *)  /* Comparison function */\n){\n  int i;                          /* Iterator variable */\n\n  assert( nSuspect<=nSegment );\n\n  if( nSuspect==nSegment ) nSuspect--;\n  for(i=nSuspect-1; i>=0; i--){\n    int j;\n    for(j=i; j<(nSegment-1); j++){\n      Fts3SegReader *pTmp;\n      if( xCmp(apSegment[j], apSegment[j+1])<0 ) break;\n      pTmp = apSegment[j+1];\n      apSegment[j+1] = apSegment[j];\n      apSegment[j] = pTmp;\n    }\n  }\n\n#ifndef NDEBUG\n  /* Check that the list really is sorted now. */\n  for(i=0; i<(nSuspect-1); i++){\n    assert( xCmp(apSegment[i], apSegment[i+1])<0 );\n  }\n#endif\n}\n\n/* \n** Insert a record into the %_segments table.\n*/\nstatic int fts3WriteSegment(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iBlock,           /* Block id for new block */\n  char *z,                        /* Pointer to buffer containing block data */\n  int n                           /* Size of buffer z in bytes */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iBlock);\n    sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Find the largest relative level number in the table. If successful, set\n** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,\n** set *pnMax to zero and return an SQLite error code.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){\n  int rc;\n  int mxLevel = 0;\n  sqlite3_stmt *pStmt = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      mxLevel = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_reset(pStmt);\n  }\n  *pnMax = mxLevel;\n  return rc;\n}\n\n/* \n** Insert a record into the %_segdir table.\n*/\nstatic int fts3WriteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  sqlite3_int64 iLevel,           /* Value for \"level\" field (absolute level) */\n  int iIdx,                       /* Value for \"idx\" field */\n  sqlite3_int64 iStartBlock,      /* Value for \"start_block\" field */\n  sqlite3_int64 iLeafEndBlock,    /* Value for \"leaves_end_block\" field */\n  sqlite3_int64 iEndBlock,        /* Value for \"end_block\" field */\n  sqlite3_int64 nLeafData,        /* Bytes of leaf data in segment */\n  char *zRoot,                    /* Blob value for \"root\" field */\n  int nRoot                       /* Number of bytes in buffer zRoot */\n){\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pStmt, 1, iLevel);\n    sqlite3_bind_int(pStmt, 2, iIdx);\n    sqlite3_bind_int64(pStmt, 3, iStartBlock);\n    sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);\n    if( nLeafData==0 ){\n      sqlite3_bind_int64(pStmt, 5, iEndBlock);\n    }else{\n      char *zEnd = sqlite3_mprintf(\"%lld %lld\", iEndBlock, nLeafData);\n      if( !zEnd ) return SQLITE_NOMEM;\n      sqlite3_bind_text(pStmt, 5, zEnd, -1, sqlite3_free);\n    }\n    sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);\n    sqlite3_step(pStmt);\n    rc = sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** Return the size of the common prefix (if any) shared by zPrev and\n** zNext, in bytes. For example, \n**\n**   fts3PrefixCompress(\"abc\", 3, \"abcdef\", 6)   // returns 3\n**   fts3PrefixCompress(\"abX\", 3, \"abcdef\", 6)   // returns 2\n**   fts3PrefixCompress(\"abX\", 3, \"Xbcdef\", 6)   // returns 0\n*/\nstatic int fts3PrefixCompress(\n  const char *zPrev,              /* Buffer containing previous term */\n  int nPrev,                      /* Size of buffer zPrev in bytes */\n  const char *zNext,              /* Buffer containing next term */\n  int nNext                       /* Size of buffer zNext in bytes */\n){\n  int n;\n  UNUSED_PARAMETER(nNext);\n  for(n=0; n<nPrev && zPrev[n]==zNext[n]; n++);\n  return n;\n}\n\n/*\n** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger\n** (according to memcmp) than the previous term.\n*/\nstatic int fts3NodeAddTerm(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode **ppTree,           /* IN/OUT: SegmentNode handle */ \n  int isCopyTerm,                 /* True if zTerm/nTerm is transient */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm                       /* Size of term in bytes */\n){\n  SegmentNode *pTree = *ppTree;\n  int rc;\n  SegmentNode *pNew;\n\n  /* First try to append the term to the current node. Return early if \n  ** this is possible.\n  */\n  if( pTree ){\n    int nData = pTree->nData;     /* Current size of node in bytes */\n    int nReq = nData;             /* Required space after adding zTerm */\n    int nPrefix;                  /* Number of bytes of prefix compression */\n    int nSuffix;                  /* Suffix length */\n\n    nPrefix = fts3PrefixCompress(pTree->zTerm, pTree->nTerm, zTerm, nTerm);\n    nSuffix = nTerm-nPrefix;\n\n    nReq += sqlite3Fts3VarintLen(nPrefix)+sqlite3Fts3VarintLen(nSuffix)+nSuffix;\n    if( nReq<=p->nNodeSize || !pTree->zTerm ){\n\n      if( nReq>p->nNodeSize ){\n        /* An unusual case: this is the first term to be added to the node\n        ** and the static node buffer (p->nNodeSize bytes) is not large\n        ** enough. Use a separately malloced buffer instead This wastes\n        ** p->nNodeSize bytes, but since this scenario only comes about when\n        ** the database contain two terms that share a prefix of almost 2KB, \n        ** this is not expected to be a serious problem. \n        */\n        assert( pTree->aData==(char *)&pTree[1] );\n        pTree->aData = (char *)sqlite3_malloc(nReq);\n        if( !pTree->aData ){\n          return SQLITE_NOMEM;\n        }\n      }\n\n      if( pTree->zTerm ){\n        /* There is no prefix-length field for first term in a node */\n        nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nPrefix);\n      }\n\n      nData += sqlite3Fts3PutVarint(&pTree->aData[nData], nSuffix);\n      memcpy(&pTree->aData[nData], &zTerm[nPrefix], nSuffix);\n      pTree->nData = nData + nSuffix;\n      pTree->nEntry++;\n\n      if( isCopyTerm ){\n        if( pTree->nMalloc<nTerm ){\n          char *zNew = sqlite3_realloc(pTree->zMalloc, nTerm*2);\n          if( !zNew ){\n            return SQLITE_NOMEM;\n          }\n          pTree->nMalloc = nTerm*2;\n          pTree->zMalloc = zNew;\n        }\n        pTree->zTerm = pTree->zMalloc;\n        memcpy(pTree->zTerm, zTerm, nTerm);\n        pTree->nTerm = nTerm;\n      }else{\n        pTree->zTerm = (char *)zTerm;\n        pTree->nTerm = nTerm;\n      }\n      return SQLITE_OK;\n    }\n  }\n\n  /* If control flows to here, it was not possible to append zTerm to the\n  ** current node. Create a new node (a right-sibling of the current node).\n  ** If this is the first node in the tree, the term is added to it.\n  **\n  ** Otherwise, the term is not added to the new node, it is left empty for\n  ** now. Instead, the term is inserted into the parent of pTree. If pTree \n  ** has no parent, one is created here.\n  */\n  pNew = (SegmentNode *)sqlite3_malloc(sizeof(SegmentNode) + p->nNodeSize);\n  if( !pNew ){\n    return SQLITE_NOMEM;\n  }\n  memset(pNew, 0, sizeof(SegmentNode));\n  pNew->nData = 1 + FTS3_VARINT_MAX;\n  pNew->aData = (char *)&pNew[1];\n\n  if( pTree ){\n    SegmentNode *pParent = pTree->pParent;\n    rc = fts3NodeAddTerm(p, &pParent, isCopyTerm, zTerm, nTerm);\n    if( pTree->pParent==0 ){\n      pTree->pParent = pParent;\n    }\n    pTree->pRight = pNew;\n    pNew->pLeftmost = pTree->pLeftmost;\n    pNew->pParent = pParent;\n    pNew->zMalloc = pTree->zMalloc;\n    pNew->nMalloc = pTree->nMalloc;\n    pTree->zMalloc = 0;\n  }else{\n    pNew->pLeftmost = pNew;\n    rc = fts3NodeAddTerm(p, &pNew, isCopyTerm, zTerm, nTerm); \n  }\n\n  *ppTree = pNew;\n  return rc;\n}\n\n/*\n** Helper function for fts3NodeWrite().\n*/\nstatic int fts3TreeFinishNode(\n  SegmentNode *pTree, \n  int iHeight, \n  sqlite3_int64 iLeftChild\n){\n  int nStart;\n  assert( iHeight>=1 && iHeight<128 );\n  nStart = FTS3_VARINT_MAX - sqlite3Fts3VarintLen(iLeftChild);\n  pTree->aData[nStart] = (char)iHeight;\n  sqlite3Fts3PutVarint(&pTree->aData[nStart+1], iLeftChild);\n  return nStart;\n}\n\n/*\n** Write the buffer for the segment node pTree and all of its peers to the\n** database. Then call this function recursively to write the parent of \n** pTree and its peers to the database. \n**\n** Except, if pTree is a root node, do not write it to the database. Instead,\n** set output variables *paRoot and *pnRoot to contain the root node.\n**\n** If successful, SQLITE_OK is returned and output variable *piLast is\n** set to the largest blockid written to the database (or zero if no\n** blocks were written to the db). Otherwise, an SQLite error code is \n** returned.\n*/\nstatic int fts3NodeWrite(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentNode *pTree,             /* SegmentNode handle */\n  int iHeight,                    /* Height of this node in tree */\n  sqlite3_int64 iLeaf,            /* Block id of first leaf node */\n  sqlite3_int64 iFree,            /* Block id of next free slot in %_segments */\n  sqlite3_int64 *piLast,          /* OUT: Block id of last entry written */\n  char **paRoot,                  /* OUT: Data for root node */\n  int *pnRoot                     /* OUT: Size of root node in bytes */\n){\n  int rc = SQLITE_OK;\n\n  if( !pTree->pParent ){\n    /* Root node of the tree. */\n    int nStart = fts3TreeFinishNode(pTree, iHeight, iLeaf);\n    *piLast = iFree-1;\n    *pnRoot = pTree->nData - nStart;\n    *paRoot = &pTree->aData[nStart];\n  }else{\n    SegmentNode *pIter;\n    sqlite3_int64 iNextFree = iFree;\n    sqlite3_int64 iNextLeaf = iLeaf;\n    for(pIter=pTree->pLeftmost; pIter && rc==SQLITE_OK; pIter=pIter->pRight){\n      int nStart = fts3TreeFinishNode(pIter, iHeight, iNextLeaf);\n      int nWrite = pIter->nData - nStart;\n  \n      rc = fts3WriteSegment(p, iNextFree, &pIter->aData[nStart], nWrite);\n      iNextFree++;\n      iNextLeaf += (pIter->nEntry+1);\n    }\n    if( rc==SQLITE_OK ){\n      assert( iNextLeaf==iFree );\n      rc = fts3NodeWrite(\n          p, pTree->pParent, iHeight+1, iFree, iNextFree, piLast, paRoot, pnRoot\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Free all memory allocations associated with the tree pTree.\n*/\nstatic void fts3NodeFree(SegmentNode *pTree){\n  if( pTree ){\n    SegmentNode *p = pTree->pLeftmost;\n    fts3NodeFree(p->pParent);\n    while( p ){\n      SegmentNode *pRight = p->pRight;\n      if( p->aData!=(char *)&p[1] ){\n        sqlite3_free(p->aData);\n      }\n      assert( pRight==0 || p->zMalloc==0 );\n      sqlite3_free(p->zMalloc);\n      sqlite3_free(p);\n      p = pRight;\n    }\n  }\n}\n\n/*\n** Add a term to the segment being constructed by the SegmentWriter object\n** *ppWriter. When adding the first term to a segment, *ppWriter should\n** be passed NULL. This function will allocate a new SegmentWriter object\n** and return it via the input/output variable *ppWriter in this case.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterAdd(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter **ppWriter,       /* IN/OUT: SegmentWriter handle */ \n  int isCopyTerm,                 /* True if buffer zTerm must be copied */\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of term in bytes */\n  const char *aDoclist,           /* Pointer to buffer containing doclist */\n  int nDoclist                    /* Size of doclist in bytes */\n){\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n  int nReq;                       /* Number of bytes required on leaf page */\n  int nData;\n  SegmentWriter *pWriter = *ppWriter;\n\n  if( !pWriter ){\n    int rc;\n    sqlite3_stmt *pStmt;\n\n    /* Allocate the SegmentWriter structure */\n    pWriter = (SegmentWriter *)sqlite3_malloc(sizeof(SegmentWriter));\n    if( !pWriter ) return SQLITE_NOMEM;\n    memset(pWriter, 0, sizeof(SegmentWriter));\n    *ppWriter = pWriter;\n\n    /* Allocate a buffer in which to accumulate data */\n    pWriter->aData = (char *)sqlite3_malloc(p->nNodeSize);\n    if( !pWriter->aData ) return SQLITE_NOMEM;\n    pWriter->nSize = p->nNodeSize;\n\n    /* Find the next free blockid in the %_segments table */\n    rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pStmt, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      pWriter->iFree = sqlite3_column_int64(pStmt, 0);\n      pWriter->iFirst = pWriter->iFree;\n    }\n    rc = sqlite3_reset(pStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nData = pWriter->nData;\n\n  nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);\n  nSuffix = nTerm-nPrefix;\n\n  /* Figure out how many bytes are required by this new entry */\n  nReq = sqlite3Fts3VarintLen(nPrefix) +    /* varint containing prefix size */\n    sqlite3Fts3VarintLen(nSuffix) +         /* varint containing suffix size */\n    nSuffix +                               /* Term suffix */\n    sqlite3Fts3VarintLen(nDoclist) +        /* Size of doclist */\n    nDoclist;                               /* Doclist data */\n\n  if( nData>0 && nData+nReq>p->nNodeSize ){\n    int rc;\n\n    /* The current leaf node is full. Write it out to the database. */\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);\n    if( rc!=SQLITE_OK ) return rc;\n    p->nLeafAdd++;\n\n    /* Add the current term to the interior node tree. The term added to\n    ** the interior tree must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pWriter->zTerm), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    assert( nPrefix<nTerm );\n    rc = fts3NodeAddTerm(p, &pWriter->pTree, isCopyTerm, zTerm, nPrefix+1);\n    if( rc!=SQLITE_OK ) return rc;\n\n    nData = 0;\n    pWriter->nTerm = 0;\n\n    nPrefix = 0;\n    nSuffix = nTerm;\n    nReq = 1 +                              /* varint containing prefix size */\n      sqlite3Fts3VarintLen(nTerm) +         /* varint containing suffix size */\n      nTerm +                               /* Term suffix */\n      sqlite3Fts3VarintLen(nDoclist) +      /* Size of doclist */\n      nDoclist;                             /* Doclist data */\n  }\n\n  /* Increase the total number of bytes written to account for the new entry. */\n  pWriter->nLeafData += nReq;\n\n  /* If the buffer currently allocated is too small for this entry, realloc\n  ** the buffer to make it large enough.\n  */\n  if( nReq>pWriter->nSize ){\n    char *aNew = sqlite3_realloc(pWriter->aData, nReq);\n    if( !aNew ) return SQLITE_NOMEM;\n    pWriter->aData = aNew;\n    pWriter->nSize = nReq;\n  }\n  assert( nData+nReq<=pWriter->nSize );\n\n  /* Append the prefix-compressed term and doclist to the buffer. */\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nPrefix);\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nSuffix);\n  memcpy(&pWriter->aData[nData], &zTerm[nPrefix], nSuffix);\n  nData += nSuffix;\n  nData += sqlite3Fts3PutVarint(&pWriter->aData[nData], nDoclist);\n  memcpy(&pWriter->aData[nData], aDoclist, nDoclist);\n  pWriter->nData = nData + nDoclist;\n\n  /* Save the current term so that it can be used to prefix-compress the next.\n  ** If the isCopyTerm parameter is true, then the buffer pointed to by\n  ** zTerm is transient, so take a copy of the term data. Otherwise, just\n  ** store a copy of the pointer.\n  */\n  if( isCopyTerm ){\n    if( nTerm>pWriter->nMalloc ){\n      char *zNew = sqlite3_realloc(pWriter->zMalloc, nTerm*2);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pWriter->nMalloc = nTerm*2;\n      pWriter->zMalloc = zNew;\n      pWriter->zTerm = zNew;\n    }\n    assert( pWriter->zTerm==pWriter->zMalloc );\n    memcpy(pWriter->zTerm, zTerm, nTerm);\n  }else{\n    pWriter->zTerm = (char *)zTerm;\n  }\n  pWriter->nTerm = nTerm;\n\n  return SQLITE_OK;\n}\n\n/*\n** Flush all data associated with the SegmentWriter object pWriter to the\n** database. This function must be called after all terms have been added\n** to the segment using fts3SegWriterAdd(). If successful, SQLITE_OK is\n** returned. Otherwise, an SQLite error code.\n*/\nstatic int fts3SegWriterFlush(\n  Fts3Table *p,                   /* Virtual table handle */\n  SegmentWriter *pWriter,         /* SegmentWriter to flush to the db */\n  sqlite3_int64 iLevel,           /* Value for 'level' column of %_segdir */\n  int iIdx                        /* Value for 'idx' column of %_segdir */\n){\n  int rc;                         /* Return code */\n  if( pWriter->pTree ){\n    sqlite3_int64 iLast = 0;      /* Largest block id written to database */\n    sqlite3_int64 iLastLeaf;      /* Largest leaf block id written to db */\n    char *zRoot = NULL;           /* Pointer to buffer containing root node */\n    int nRoot = 0;                /* Size of buffer zRoot */\n\n    iLastLeaf = pWriter->iFree;\n    rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, pWriter->nData);\n    if( rc==SQLITE_OK ){\n      rc = fts3NodeWrite(p, pWriter->pTree, 1,\n          pWriter->iFirst, pWriter->iFree, &iLast, &zRoot, &nRoot);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegdir(p, iLevel, iIdx, \n          pWriter->iFirst, iLastLeaf, iLast, pWriter->nLeafData, zRoot, nRoot);\n    }\n  }else{\n    /* The entire tree fits on the root node. Write it to the segdir table. */\n    rc = fts3WriteSegdir(p, iLevel, iIdx, \n        0, 0, 0, pWriter->nLeafData, pWriter->aData, pWriter->nData);\n  }\n  p->nLeafAdd++;\n  return rc;\n}\n\n/*\n** Release all memory held by the SegmentWriter object passed as the \n** first argument.\n*/\nstatic void fts3SegWriterFree(SegmentWriter *pWriter){\n  if( pWriter ){\n    sqlite3_free(pWriter->aData);\n    sqlite3_free(pWriter->zMalloc);\n    fts3NodeFree(pWriter->pTree);\n    sqlite3_free(pWriter);\n  }\n}\n\n/*\n** The first value in the apVal[] array is assumed to contain an integer.\n** This function tests if there exist any documents with docid values that\n** are different from that integer. i.e. if deleting the document with docid\n** pRowid would mean the FTS3 table were empty.\n**\n** If successful, *pisEmpty is set to true if the table is empty except for\n** document pRowid, or false otherwise, and SQLITE_OK is returned. If an\n** error occurs, an SQLite error code is returned.\n*/\nstatic int fts3IsEmpty(Fts3Table *p, sqlite3_value *pRowid, int *pisEmpty){\n  sqlite3_stmt *pStmt;\n  int rc;\n  if( p->zContentTbl ){\n    /* If using the content=xxx option, assume the table is never empty */\n    *pisEmpty = 0;\n    rc = SQLITE_OK;\n  }else{\n    rc = fts3SqlStmt(p, SQL_IS_EMPTY, &pStmt, &pRowid);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *pisEmpty = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Set *pnMax to the largest segment level in the database for the index\n** iIndex.\n**\n** Segment levels are stored in the 'level' column of the %_segdir table.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if not.\n*/\nstatic int fts3SegmentMaxLevel(\n  Fts3Table *p, \n  int iLangid,\n  int iIndex, \n  sqlite3_int64 *pnMax\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n  sqlite3_bind_int64(pStmt, 2, \n      getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n  );\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pnMax = sqlite3_column_int64(pStmt, 0);\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** iAbsLevel is an absolute level that may be assumed to exist within\n** the database. This function checks if it is the largest level number\n** within its index. Assuming no error occurs, *pbMax is set to 1 if\n** iAbsLevel is indeed the largest level, or 0 otherwise, and SQLITE_OK\n** is returned. If an error occurs, an error code is returned and the\n** final value of *pbMax is undefined.\n*/\nstatic int fts3SegmentIsMaxLevel(Fts3Table *p, i64 iAbsLevel, int *pbMax){\n\n  /* Set pStmt to the compiled version of:\n  **\n  **   SELECT max(level) FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?\n  **\n  ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).\n  */\n  sqlite3_stmt *pStmt;\n  int rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  sqlite3_bind_int64(pStmt, 1, iAbsLevel+1);\n  sqlite3_bind_int64(pStmt, 2, \n      ((iAbsLevel/FTS3_SEGDIR_MAXLEVEL)+1) * FTS3_SEGDIR_MAXLEVEL\n  );\n\n  *pbMax = 0;\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    *pbMax = sqlite3_column_type(pStmt, 0)==SQLITE_NULL;\n  }\n  return sqlite3_reset(pStmt);\n}\n\n/*\n** Delete all entries in the %_segments table associated with the segment\n** opened with seg-reader pSeg. This function does not affect the contents\n** of the %_segdir table.\n*/\nstatic int fts3DeleteSegment(\n  Fts3Table *p,                   /* FTS table handle */\n  Fts3SegReader *pSeg             /* Segment to delete */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pSeg->iStartBlock ){\n    sqlite3_stmt *pDelete;        /* SQL statement to delete rows */\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);\n      sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);\n      sqlite3_step(pDelete);\n      rc = sqlite3_reset(pDelete);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is used after merging multiple segments into a single large\n** segment to delete the old, now redundant, segment b-trees. Specifically,\n** it:\n** \n**   1) Deletes all %_segments entries for the segments associated with \n**      each of the SegReader objects in the array passed as the third \n**      argument, and\n**\n**   2) deletes all %_segdir entries with level iLevel, or all %_segdir\n**      entries regardless of level if (iLevel<0).\n**\n** SQLITE_OK is returned if successful, otherwise an SQLite error code.\n*/\nstatic int fts3DeleteSegdir(\n  Fts3Table *p,                   /* Virtual table handle */\n  int iLangid,                    /* Language id */\n  int iIndex,                     /* Index for p->aIndex */\n  int iLevel,                     /* Level of %_segdir entries to delete */\n  Fts3SegReader **apSegment,      /* Array of SegReader objects */\n  int nReader                     /* Size of array apSegment */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pDelete = 0;      /* SQL statement to delete rows */\n\n  for(i=0; rc==SQLITE_OK && i<nReader; i++){\n    rc = fts3DeleteSegment(p, apSegment[i]);\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));\n      sqlite3_bind_int64(pDelete, 2, \n          getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)\n      );\n    }\n  }else{\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(\n          pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** When this function is called, buffer *ppList (size *pnList bytes) contains \n** a position list that may (or may not) feature multiple columns. This\n** function adjusts the pointer *ppList and the length *pnList so that they\n** identify the subset of the position list that corresponds to column iCol.\n**\n** If there are no entries in the input position list for column iCol, then\n** *pnList is set to zero before returning.\n**\n** If parameter bZero is non-zero, then any part of the input list following\n** the end of the output list is zeroed before returning.\n*/\nstatic void fts3ColumnFilter(\n  int iCol,                       /* Column to filter on */\n  int bZero,                      /* Zero out anything following *ppList */\n  char **ppList,                  /* IN/OUT: Pointer to position list */\n  int *pnList                     /* IN/OUT: Size of buffer *ppList in bytes */\n){\n  char *pList = *ppList;\n  int nList = *pnList;\n  char *pEnd = &pList[nList];\n  int iCurrent = 0;\n  char *p = pList;\n\n  assert( iCol>=0 );\n  while( 1 ){\n    char c = 0;\n    while( p<pEnd && (c | *p)&0xFE ) c = *p++ & 0x80;\n  \n    if( iCol==iCurrent ){\n      nList = (int)(p - pList);\n      break;\n    }\n\n    nList -= (int)(p - pList);\n    pList = p;\n    if( nList==0 ){\n      break;\n    }\n    p = &pList[1];\n    p += fts3GetVarint32(p, &iCurrent);\n  }\n\n  if( bZero && &pList[nList]!=pEnd ){\n    memset(&pList[nList], 0, pEnd - &pList[nList]);\n  }\n  *ppList = pList;\n  *pnList = nList;\n}\n\n/*\n** Cache data in the Fts3MultiSegReader.aBuffer[] buffer (overwriting any\n** existing data). Grow the buffer if required.\n**\n** If successful, return SQLITE_OK. Otherwise, if an OOM error is encountered\n** trying to resize the buffer, return SQLITE_NOMEM.\n*/\nstatic int fts3MsrBufferData(\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  char *pList,\n  int nList\n){\n  if( nList>pMsr->nBuffer ){\n    char *pNew;\n    pMsr->nBuffer = nList*2;\n    pNew = (char *)sqlite3_realloc(pMsr->aBuffer, pMsr->nBuffer);\n    if( !pNew ) return SQLITE_NOMEM;\n    pMsr->aBuffer = pNew;\n  }\n\n  memcpy(pMsr->aBuffer, pList, nList);\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pMsr,       /* Multi-segment-reader handle */\n  sqlite3_int64 *piDocid,         /* OUT: Docid value */\n  char **paPoslist,               /* OUT: Pointer to position list */\n  int *pnPoslist                  /* OUT: Size of position list in bytes */\n){\n  int nMerge = pMsr->nAdvance;\n  Fts3SegReader **apSegment = pMsr->apSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( nMerge==0 ){\n    *paPoslist = 0;\n    return SQLITE_OK;\n  }\n\n  while( 1 ){\n    Fts3SegReader *pSeg;\n    pSeg = pMsr->apSegment[0];\n\n    if( pSeg->pOffsetList==0 ){\n      *paPoslist = 0;\n      break;\n    }else{\n      int rc;\n      char *pList;\n      int nList;\n      int j;\n      sqlite3_int64 iDocid = apSegment[0]->iDocid;\n\n      rc = fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n      j = 1;\n      while( rc==SQLITE_OK \n        && j<nMerge\n        && apSegment[j]->pOffsetList\n        && apSegment[j]->iDocid==iDocid\n      ){\n        rc = fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n        j++;\n      }\n      if( rc!=SQLITE_OK ) return rc;\n      fts3SegReaderSort(pMsr->apSegment, nMerge, j, xCmp);\n\n      if( nList>0 && fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pMsr, pList, nList+1);\n        if( rc!=SQLITE_OK ) return rc;\n        assert( (pMsr->aBuffer[nList] & 0xFE)==0x00 );\n        pList = pMsr->aBuffer;\n      }\n\n      if( pMsr->iColFilter>=0 ){\n        fts3ColumnFilter(pMsr->iColFilter, 1, &pList, &nList);\n      }\n\n      if( nList>0 ){\n        *paPoslist = pList;\n        *piDocid = iDocid;\n        *pnPoslist = nList;\n        break;\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  const char *zTerm,              /* Term searched for (or NULL) */\n  int nTerm                       /* Length of zTerm in bytes */\n){\n  int i;\n  int nSeg = pCsr->nSegment;\n\n  /* If the Fts3SegFilter defines a specific term (or term prefix) to search \n  ** for, then advance each segment iterator until it points to a term of\n  ** equal or greater value than the specified term. This prevents many\n  ** unnecessary merge/sort operations for the case where single segment\n  ** b-tree leaf nodes contain more than one term.\n  */\n  for(i=0; pCsr->bRestart==0 && i<pCsr->nSegment; i++){\n    int res = 0;\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    do {\n      int rc = fts3SegReaderNext(p, pSeg, 0);\n      if( rc!=SQLITE_OK ) return rc;\n    }while( zTerm && (res = fts3SegReaderTermCmp(pSeg, zTerm, nTerm))<0 );\n\n    if( pSeg->bLookup && res!=0 ){\n      fts3SegReaderSetEof(pSeg);\n    }\n  }\n  fts3SegReaderSort(pCsr->apSegment, nSeg, nSeg, fts3SegReaderCmp);\n\n  return SQLITE_OK;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  Fts3SegFilter *pFilter          /* Restrictions on range of iteration */\n){\n  pCsr->pFilter = pFilter;\n  return fts3SegReaderStart(p, pCsr, pFilter->zTerm, pFilter->nTerm);\n}\n\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrStart(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr,       /* Cursor object */\n  int iCol,                       /* Column to match on. */\n  const char *zTerm,              /* Term to iterate through a doclist for */\n  int nTerm                       /* Number of bytes in zTerm */\n){\n  int i;\n  int rc;\n  int nSegment = pCsr->nSegment;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  assert( pCsr->pFilter==0 );\n  assert( zTerm && nTerm>0 );\n\n  /* Advance each segment iterator until it points to the term zTerm/nTerm. */\n  rc = fts3SegReaderStart(p, pCsr, zTerm, nTerm);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Determine how many of the segments actually point to zTerm/nTerm. */\n  for(i=0; i<nSegment; i++){\n    Fts3SegReader *pSeg = pCsr->apSegment[i];\n    if( !pSeg->aNode || fts3SegReaderTermCmp(pSeg, zTerm, nTerm) ){\n      break;\n    }\n  }\n  pCsr->nAdvance = i;\n\n  /* Advance each of the segments to point to the first docid. */\n  for(i=0; i<pCsr->nAdvance; i++){\n    rc = fts3SegReaderFirstDocid(p, pCsr->apSegment[i]);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  fts3SegReaderSort(pCsr->apSegment, i, i, xCmp);\n\n  assert( iCol<0 || iCol<p->nColumn );\n  pCsr->iColFilter = iCol;\n\n  return SQLITE_OK;\n}\n\n/*\n** This function is called on a MultiSegReader that has been started using\n** sqlite3Fts3MsrIncrStart(). One or more calls to MsrIncrNext() may also\n** have been made. Calling this function puts the MultiSegReader in such\n** a state that if the next two calls are:\n**\n**   sqlite3Fts3SegReaderStart()\n**   sqlite3Fts3SegReaderStep()\n**\n** then the entire doclist for the term is available in \n** MultiSegReader.aDoclist/nDoclist.\n*/\nSQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr){\n  int i;                          /* Used to iterate through segment-readers */\n\n  assert( pCsr->zTerm==0 );\n  assert( pCsr->nTerm==0 );\n  assert( pCsr->aDoclist==0 );\n  assert( pCsr->nDoclist==0 );\n\n  pCsr->nAdvance = 0;\n  pCsr->bRestart = 1;\n  for(i=0; i<pCsr->nSegment; i++){\n    pCsr->apSegment[i]->pOffsetList = 0;\n    pCsr->apSegment[i]->nOffsetList = 0;\n    pCsr->apSegment[i]->iDocid = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n\nSQLITE_PRIVATE int sqlite3Fts3SegReaderStep(\n  Fts3Table *p,                   /* Virtual table handle */\n  Fts3MultiSegReader *pCsr        /* Cursor object */\n){\n  int rc = SQLITE_OK;\n\n  int isIgnoreEmpty =  (pCsr->pFilter->flags & FTS3_SEGMENT_IGNORE_EMPTY);\n  int isRequirePos =   (pCsr->pFilter->flags & FTS3_SEGMENT_REQUIRE_POS);\n  int isColFilter =    (pCsr->pFilter->flags & FTS3_SEGMENT_COLUMN_FILTER);\n  int isPrefix =       (pCsr->pFilter->flags & FTS3_SEGMENT_PREFIX);\n  int isScan =         (pCsr->pFilter->flags & FTS3_SEGMENT_SCAN);\n  int isFirst =        (pCsr->pFilter->flags & FTS3_SEGMENT_FIRST);\n\n  Fts3SegReader **apSegment = pCsr->apSegment;\n  int nSegment = pCsr->nSegment;\n  Fts3SegFilter *pFilter = pCsr->pFilter;\n  int (*xCmp)(Fts3SegReader *, Fts3SegReader *) = (\n    p->bDescIdx ? fts3SegReaderDoclistCmpRev : fts3SegReaderDoclistCmp\n  );\n\n  if( pCsr->nSegment==0 ) return SQLITE_OK;\n\n  do {\n    int nMerge;\n    int i;\n  \n    /* Advance the first pCsr->nAdvance entries in the apSegment[] array\n    ** forward. Then sort the list in order of current term again.  \n    */\n    for(i=0; i<pCsr->nAdvance; i++){\n      Fts3SegReader *pSeg = apSegment[i];\n      if( pSeg->bLookup ){\n        fts3SegReaderSetEof(pSeg);\n      }else{\n        rc = fts3SegReaderNext(p, pSeg, 0);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    fts3SegReaderSort(apSegment, nSegment, pCsr->nAdvance, fts3SegReaderCmp);\n    pCsr->nAdvance = 0;\n\n    /* If all the seg-readers are at EOF, we're finished. return SQLITE_OK. */\n    assert( rc==SQLITE_OK );\n    if( apSegment[0]->aNode==0 ) break;\n\n    pCsr->nTerm = apSegment[0]->nTerm;\n    pCsr->zTerm = apSegment[0]->zTerm;\n\n    /* If this is a prefix-search, and if the term that apSegment[0] points\n    ** to does not share a suffix with pFilter->zTerm/nTerm, then all \n    ** required callbacks have been made. In this case exit early.\n    **\n    ** Similarly, if this is a search for an exact match, and the first term\n    ** of segment apSegment[0] is not a match, exit early.\n    */\n    if( pFilter->zTerm && !isScan ){\n      if( pCsr->nTerm<pFilter->nTerm \n       || (!isPrefix && pCsr->nTerm>pFilter->nTerm)\n       || memcmp(pCsr->zTerm, pFilter->zTerm, pFilter->nTerm) \n      ){\n        break;\n      }\n    }\n\n    nMerge = 1;\n    while( nMerge<nSegment \n        && apSegment[nMerge]->aNode\n        && apSegment[nMerge]->nTerm==pCsr->nTerm \n        && 0==memcmp(pCsr->zTerm, apSegment[nMerge]->zTerm, pCsr->nTerm)\n    ){\n      nMerge++;\n    }\n\n    assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );\n    if( nMerge==1 \n     && !isIgnoreEmpty \n     && !isFirst \n     && (p->bDescIdx==0 || fts3SegReaderIsPending(apSegment[0])==0)\n    ){\n      pCsr->nDoclist = apSegment[0]->nDoclist;\n      if( fts3SegReaderIsPending(apSegment[0]) ){\n        rc = fts3MsrBufferData(pCsr, apSegment[0]->aDoclist, pCsr->nDoclist);\n        pCsr->aDoclist = pCsr->aBuffer;\n      }else{\n        pCsr->aDoclist = apSegment[0]->aDoclist;\n      }\n      if( rc==SQLITE_OK ) rc = SQLITE_ROW;\n    }else{\n      int nDoclist = 0;           /* Size of doclist */\n      sqlite3_int64 iPrev = 0;    /* Previous docid stored in doclist */\n\n      /* The current term of the first nMerge entries in the array\n      ** of Fts3SegReader objects is the same. The doclists must be merged\n      ** and a single term returned with the merged doclist.\n      */\n      for(i=0; i<nMerge; i++){\n        fts3SegReaderFirstDocid(p, apSegment[i]);\n      }\n      fts3SegReaderSort(apSegment, nMerge, nMerge, xCmp);\n      while( apSegment[0]->pOffsetList ){\n        int j;                    /* Number of segments that share a docid */\n        char *pList = 0;\n        int nList = 0;\n        int nByte;\n        sqlite3_int64 iDocid = apSegment[0]->iDocid;\n        fts3SegReaderNextDocid(p, apSegment[0], &pList, &nList);\n        j = 1;\n        while( j<nMerge\n            && apSegment[j]->pOffsetList\n            && apSegment[j]->iDocid==iDocid\n        ){\n          fts3SegReaderNextDocid(p, apSegment[j], 0, 0);\n          j++;\n        }\n\n        if( isColFilter ){\n          fts3ColumnFilter(pFilter->iCol, 0, &pList, &nList);\n        }\n\n        if( !isIgnoreEmpty || nList>0 ){\n\n          /* Calculate the 'docid' delta value to write into the merged \n          ** doclist. */\n          sqlite3_int64 iDelta;\n          if( p->bDescIdx && nDoclist>0 ){\n            iDelta = iPrev - iDocid;\n          }else{\n            iDelta = iDocid - iPrev;\n          }\n          assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );\n          assert( nDoclist>0 || iDelta==iDocid );\n\n          nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);\n          if( nDoclist+nByte>pCsr->nBuffer ){\n            char *aNew;\n            pCsr->nBuffer = (nDoclist+nByte)*2;\n            aNew = sqlite3_realloc(pCsr->aBuffer, pCsr->nBuffer);\n            if( !aNew ){\n              return SQLITE_NOMEM;\n            }\n            pCsr->aBuffer = aNew;\n          }\n\n          if( isFirst ){\n            char *a = &pCsr->aBuffer[nDoclist];\n            int nWrite;\n           \n            nWrite = sqlite3Fts3FirstFilter(iDelta, pList, nList, a);\n            if( nWrite ){\n              iPrev = iDocid;\n              nDoclist += nWrite;\n            }\n          }else{\n            nDoclist += sqlite3Fts3PutVarint(&pCsr->aBuffer[nDoclist], iDelta);\n            iPrev = iDocid;\n            if( isRequirePos ){\n              memcpy(&pCsr->aBuffer[nDoclist], pList, nList);\n              nDoclist += nList;\n              pCsr->aBuffer[nDoclist++] = '\\0';\n            }\n          }\n        }\n\n        fts3SegReaderSort(apSegment, nMerge, j, xCmp);\n      }\n      if( nDoclist>0 ){\n        pCsr->aDoclist = pCsr->aBuffer;\n        pCsr->nDoclist = nDoclist;\n        rc = SQLITE_ROW;\n      }\n    }\n    pCsr->nAdvance = nMerge;\n  }while( rc==SQLITE_OK );\n\n  return rc;\n}\n\n\nSQLITE_PRIVATE void sqlite3Fts3SegReaderFinish(\n  Fts3MultiSegReader *pCsr       /* Cursor object */\n){\n  if( pCsr ){\n    int i;\n    for(i=0; i<pCsr->nSegment; i++){\n      sqlite3Fts3SegReaderFree(pCsr->apSegment[i]);\n    }\n    sqlite3_free(pCsr->apSegment);\n    sqlite3_free(pCsr->aBuffer);\n\n    pCsr->nSegment = 0;\n    pCsr->apSegment = 0;\n    pCsr->aBuffer = 0;\n  }\n}\n\n/*\n** Decode the \"end_block\" field, selected by column iCol of the SELECT \n** statement passed as the first argument. \n**\n** The \"end_block\" field may contain either an integer, or a text field\n** containing the text representation of two non-negative integers separated \n** by one or more space (0x20) characters. In the first case, set *piEndBlock \n** to the integer value and *pnByte to zero before returning. In the second, \n** set *piEndBlock to the first value and *pnByte to the second.\n*/\nstatic void fts3ReadEndBlockField(\n  sqlite3_stmt *pStmt, \n  int iCol, \n  i64 *piEndBlock,\n  i64 *pnByte\n){\n  const unsigned char *zText = sqlite3_column_text(pStmt, iCol);\n  if( zText ){\n    int i;\n    int iMul = 1;\n    i64 iVal = 0;\n    for(i=0; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *piEndBlock = iVal;\n    while( zText[i]==' ' ) i++;\n    iVal = 0;\n    if( zText[i]=='-' ){\n      i++;\n      iMul = -1;\n    }\n    for(/* no-op */; zText[i]>='0' && zText[i]<='9'; i++){\n      iVal = iVal*10 + (zText[i] - '0');\n    }\n    *pnByte = (iVal * (i64)iMul);\n  }\n}\n\n\n/*\n** A segment of size nByte bytes has just been written to absolute level\n** iAbsLevel. Promote any segments that should be promoted as a result.\n*/\nstatic int fts3PromoteSegments(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level just updated */\n  sqlite3_int64 nByte             /* Size of new segment at iAbsLevel */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pRange;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE2, &pRange, 0);\n\n  if( rc==SQLITE_OK ){\n    int bOk = 0;\n    i64 iLast = (iAbsLevel/FTS3_SEGDIR_MAXLEVEL + 1) * FTS3_SEGDIR_MAXLEVEL - 1;\n    i64 nLimit = (nByte*3)/2;\n\n    /* Loop through all entries in the %_segdir table corresponding to \n    ** segments in this index on levels greater than iAbsLevel. If there is\n    ** at least one such segment, and it is possible to determine that all \n    ** such segments are smaller than nLimit bytes in size, they will be \n    ** promoted to level iAbsLevel.  */\n    sqlite3_bind_int64(pRange, 1, iAbsLevel+1);\n    sqlite3_bind_int64(pRange, 2, iLast);\n    while( SQLITE_ROW==sqlite3_step(pRange) ){\n      i64 nSize = 0, dummy;\n      fts3ReadEndBlockField(pRange, 2, &dummy, &nSize);\n      if( nSize<=0 || nSize>nLimit ){\n        /* If nSize==0, then the %_segdir.end_block field does not not \n        ** contain a size value. This happens if it was written by an\n        ** old version of FTS. In this case it is not possible to determine\n        ** the size of the segment, and so segment promotion does not\n        ** take place.  */\n        bOk = 0;\n        break;\n      }\n      bOk = 1;\n    }\n    rc = sqlite3_reset(pRange);\n\n    if( bOk ){\n      int iIdx = 0;\n      sqlite3_stmt *pUpdate1 = 0;\n      sqlite3_stmt *pUpdate2 = 0;\n\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL_IDX, &pUpdate1, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL, &pUpdate2, 0);\n      }\n\n      if( rc==SQLITE_OK ){\n\n        /* Loop through all %_segdir entries for segments in this index with\n        ** levels equal to or greater than iAbsLevel. As each entry is visited,\n        ** updated it to set (level = -1) and (idx = N), where N is 0 for the\n        ** oldest segment in the range, 1 for the next oldest, and so on.\n        **\n        ** In other words, move all segments being promoted to level -1,\n        ** setting the \"idx\" fields as appropriate to keep them in the same\n        ** order. The contents of level -1 (which is never used, except\n        ** transiently here), will be moved back to level iAbsLevel below.  */\n        sqlite3_bind_int64(pRange, 1, iAbsLevel);\n        while( SQLITE_ROW==sqlite3_step(pRange) ){\n          sqlite3_bind_int(pUpdate1, 1, iIdx++);\n          sqlite3_bind_int(pUpdate1, 2, sqlite3_column_int(pRange, 0));\n          sqlite3_bind_int(pUpdate1, 3, sqlite3_column_int(pRange, 1));\n          sqlite3_step(pUpdate1);\n          rc = sqlite3_reset(pUpdate1);\n          if( rc!=SQLITE_OK ){\n            sqlite3_reset(pRange);\n            break;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_reset(pRange);\n      }\n\n      /* Move level -1 to level iAbsLevel */\n      if( rc==SQLITE_OK ){\n        sqlite3_bind_int64(pUpdate2, 1, iAbsLevel);\n        sqlite3_step(pUpdate2);\n        rc = sqlite3_reset(pUpdate2);\n      }\n    }\n  }\n\n\n  return rc;\n}\n\n/*\n** Merge all level iLevel segments in the database into a single \n** iLevel+1 segment. Or, if iLevel<0, merge all segments into a\n** single segment with a level equal to the numerically largest level \n** currently present in the database.\n**\n** If this function is called with iLevel<0, but there is only one\n** segment in the database, SQLITE_DONE is returned immediately. \n** Otherwise, if successful, SQLITE_OK is returned. If an error occurs, \n** an SQLite error code is returned.\n*/\nstatic int fts3SegmentMerge(\n  Fts3Table *p, \n  int iLangid,                    /* Language id to merge */\n  int iIndex,                     /* Index in p->aIndex[] to merge */\n  int iLevel                      /* Level to merge */\n){\n  int rc;                         /* Return code */\n  int iIdx = 0;                   /* Index of new segment */\n  sqlite3_int64 iNewLevel = 0;    /* Level/index to create new segment at */\n  SegmentWriter *pWriter = 0;     /* Used to write the new, merged, segment */\n  Fts3SegFilter filter;           /* Segment term filter condition */\n  Fts3MultiSegReader csr;         /* Cursor to iterate through level(s) */\n  int bIgnoreEmpty = 0;           /* True to ignore empty segments */\n  i64 iMaxLevel = 0;              /* Max level number for this index/langid */\n\n  assert( iLevel==FTS3_SEGCURSOR_ALL\n       || iLevel==FTS3_SEGCURSOR_PENDING\n       || iLevel>=0\n  );\n  assert( iLevel<FTS3_SEGDIR_MAXLEVEL );\n  assert( iIndex>=0 && iIndex<p->nIndex );\n\n  rc = sqlite3Fts3SegReaderCursor(p, iLangid, iIndex, iLevel, 0, 0, 1, 0, &csr);\n  if( rc!=SQLITE_OK || csr.nSegment==0 ) goto finished;\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3SegmentMaxLevel(p, iLangid, iIndex, &iMaxLevel);\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n\n  if( iLevel==FTS3_SEGCURSOR_ALL ){\n    /* This call is to merge all segments in the database to a single\n    ** segment. The level of the new segment is equal to the numerically\n    ** greatest segment level currently present in the database for this\n    ** index. The idx of the new segment is always 0.  */\n    if( csr.nSegment==1 && 0==fts3SegReaderIsPending(csr.apSegment[0]) ){\n      rc = SQLITE_DONE;\n      goto finished;\n    }\n    iNewLevel = iMaxLevel;\n    bIgnoreEmpty = 1;\n\n  }else{\n    /* This call is to merge all segments at level iLevel. find the next\n    ** available segment index at level iLevel+1. The call to\n    ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to \n    ** a single iLevel+2 segment if necessary.  */\n    assert( FTS3_SEGCURSOR_PENDING==-1 );\n    iNewLevel = getAbsoluteLevel(p, iLangid, iIndex, iLevel+1);\n    rc = fts3AllocateSegdirIdx(p, iLangid, iIndex, iLevel+1, &iIdx);\n    bIgnoreEmpty = (iLevel!=FTS3_SEGCURSOR_PENDING) && (iNewLevel>iMaxLevel);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n\n  assert( csr.nSegment>0 );\n  assert( iNewLevel>=getAbsoluteLevel(p, iLangid, iIndex, 0) );\n  assert( iNewLevel<getAbsoluteLevel(p, iLangid, iIndex,FTS3_SEGDIR_MAXLEVEL) );\n\n  memset(&filter, 0, sizeof(Fts3SegFilter));\n  filter.flags = FTS3_SEGMENT_REQUIRE_POS;\n  filter.flags |= (bIgnoreEmpty ? FTS3_SEGMENT_IGNORE_EMPTY : 0);\n\n  rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  while( SQLITE_OK==rc ){\n    rc = sqlite3Fts3SegReaderStep(p, &csr);\n    if( rc!=SQLITE_ROW ) break;\n    rc = fts3SegWriterAdd(p, &pWriter, 1, \n        csr.zTerm, csr.nTerm, csr.aDoclist, csr.nDoclist);\n  }\n  if( rc!=SQLITE_OK ) goto finished;\n  assert( pWriter || bIgnoreEmpty );\n\n  if( iLevel!=FTS3_SEGCURSOR_PENDING ){\n    rc = fts3DeleteSegdir(\n        p, iLangid, iIndex, iLevel, csr.apSegment, csr.nSegment\n    );\n    if( rc!=SQLITE_OK ) goto finished;\n  }\n  if( pWriter ){\n    rc = fts3SegWriterFlush(p, pWriter, iNewLevel, iIdx);\n    if( rc==SQLITE_OK ){\n      if( iLevel==FTS3_SEGCURSOR_PENDING || iNewLevel<iMaxLevel ){\n        rc = fts3PromoteSegments(p, iNewLevel, pWriter->nLeafData);\n      }\n    }\n  }\n\n finished:\n  fts3SegWriterFree(pWriter);\n  sqlite3Fts3SegReaderFinish(&csr);\n  return rc;\n}\n\n\n/* \n** Flush the contents of pendingTerms to level 0 segments. \n*/\nSQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){\n  int rc = SQLITE_OK;\n  int i;\n        \n  for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n    rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);\n    if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  }\n  sqlite3Fts3PendingTermsClear(p);\n\n  /* Determine the auto-incr-merge setting if unknown.  If enabled,\n  ** estimate the number of leaf blocks of content to be written\n  */\n  if( rc==SQLITE_OK && p->bHasStat\n   && p->nAutoincrmerge==0xff && p->nLeafAdd>0\n  ){\n    sqlite3_stmt *pStmt = 0;\n    rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n      rc = sqlite3_step(pStmt);\n      if( rc==SQLITE_ROW ){\n        p->nAutoincrmerge = sqlite3_column_int(pStmt, 0);\n        if( p->nAutoincrmerge==1 ) p->nAutoincrmerge = 8;\n      }else if( rc==SQLITE_DONE ){\n        p->nAutoincrmerge = 0;\n      }\n      rc = sqlite3_reset(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** Encode N integers as varints into a blob.\n*/\nstatic void fts3EncodeIntArray(\n  int N,             /* The number of integers to encode */\n  u32 *a,            /* The integer values */\n  char *zBuf,        /* Write the BLOB here */\n  int *pNBuf         /* Write number of bytes if zBuf[] used here */\n){\n  int i, j;\n  for(i=j=0; i<N; i++){\n    j += sqlite3Fts3PutVarint(&zBuf[j], (sqlite3_int64)a[i]);\n  }\n  *pNBuf = j;\n}\n\n/*\n** Decode a blob of varints into N integers\n*/\nstatic void fts3DecodeIntArray(\n  int N,             /* The number of integers to decode */\n  u32 *a,            /* Write the integer values */\n  const char *zBuf,  /* The BLOB containing the varints */\n  int nBuf           /* size of the BLOB */\n){\n  int i, j;\n  UNUSED_PARAMETER(nBuf);\n  for(i=j=0; i<N; i++){\n    sqlite3_int64 x;\n    j += sqlite3Fts3GetVarint(&zBuf[j], &x);\n    assert(j<=nBuf);\n    a[i] = (u32)(x & 0xffffffff);\n  }\n}\n\n/*\n** Insert the sizes (in tokens) for each column of the document\n** with docid equal to p->iPrevDocid.  The sizes are encoded as\n** a blob of varints.\n*/\nstatic void fts3InsertDocsize(\n  int *pRC,                       /* Result code */\n  Fts3Table *p,                   /* Table into which to insert */\n  u32 *aSz                        /* Sizes of each column, in tokens */\n){\n  char *pBlob;             /* The BLOB encoding of the document size */\n  int nBlob;               /* Number of bytes in the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement used to insert the encoding */\n  int rc;                  /* Result code from subfunctions */\n\n  if( *pRC ) return;\n  pBlob = sqlite3_malloc( 10*p->nColumn );\n  if( pBlob==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  fts3EncodeIntArray(p->nColumn, aSz, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_DOCSIZE, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(pBlob);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int64(pStmt, 1, p->iPrevDocid);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, sqlite3_free);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n}\n\n/*\n** Record 0 of the %_stat table contains a blob consisting of N varints,\n** where N is the number of user defined columns in the fts3 table plus\n** two. If nCol is the number of user defined columns, then values of the \n** varints are set as follows:\n**\n**   Varint 0:       Total number of rows in the table.\n**\n**   Varint 1..nCol: For each column, the total number of tokens stored in\n**                   the column for all rows of the table.\n**\n**   Varint 1+nCol:  The total size, in bytes, of all text values in all\n**                   columns of all rows of the table.\n**\n*/\nstatic void fts3UpdateDocTotals(\n  int *pRC,                       /* The result code */\n  Fts3Table *p,                   /* Table being updated */\n  u32 *aSzIns,                    /* Size increases */\n  u32 *aSzDel,                    /* Size decreases */\n  int nChng                       /* Change in the number of documents */\n){\n  char *pBlob;             /* Storage for BLOB written into %_stat */\n  int nBlob;               /* Size of BLOB written into %_stat */\n  u32 *a;                  /* Array of integers that becomes the BLOB */\n  sqlite3_stmt *pStmt;     /* Statement for reading and writing */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subfunctions */\n\n  const int nStat = p->nColumn+2;\n\n  if( *pRC ) return;\n  a = sqlite3_malloc( (sizeof(u32)+10)*nStat );\n  if( a==0 ){\n    *pRC = SQLITE_NOMEM;\n    return;\n  }\n  pBlob = (char*)&a[nStat];\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    fts3DecodeIntArray(nStat, a,\n         sqlite3_column_blob(pStmt, 0),\n         sqlite3_column_bytes(pStmt, 0));\n  }else{\n    memset(a, 0, sizeof(u32)*(nStat) );\n  }\n  rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  if( nChng<0 && a[0]<(u32)(-nChng) ){\n    a[0] = 0;\n  }else{\n    a[0] += nChng;\n  }\n  for(i=0; i<p->nColumn+1; i++){\n    u32 x = a[i+1];\n    if( x+aSzIns[i] < aSzDel[i] ){\n      x = 0;\n    }else{\n      x = x + aSzIns[i] - aSzDel[i];\n    }\n    a[i+1] = x;\n  }\n  fts3EncodeIntArray(nStat, a, pBlob, &nBlob);\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ){\n    sqlite3_free(a);\n    *pRC = rc;\n    return;\n  }\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);\n  sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);\n  sqlite3_step(pStmt);\n  *pRC = sqlite3_reset(pStmt);\n  sqlite3_free(a);\n}\n\n/*\n** Merge the entire database so that there is one segment for each \n** iIndex/iLangid combination.\n*/\nstatic int fts3DoOptimize(Fts3Table *p, int bReturnDone){\n  int bSeenDone = 0;\n  int rc;\n  sqlite3_stmt *pAllLangid = 0;\n\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int i;\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){\n        rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);\n        if( rc==SQLITE_DONE ){\n          bSeenDone = 1;\n          rc = SQLITE_OK;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  sqlite3Fts3SegmentsClose(p);\n  sqlite3Fts3PendingTermsClear(p);\n\n  return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;\n}\n\n/*\n** This function is called when the user executes the following statement:\n**\n**     INSERT INTO <tbl>(<tbl>) VALUES('rebuild');\n**\n** The entire FTS index is discarded and rebuilt. If the table is one \n** created using the content=xxx option, then the new index is based on\n** the current contents of the xxx table. Otherwise, it is rebuilt based\n** on the contents of the %_content table.\n*/\nstatic int fts3DoRebuild(Fts3Table *p){\n  int rc;                         /* Return Code */\n\n  rc = fts3DeleteAll(p, 0);\n  if( rc==SQLITE_OK ){\n    u32 *aSz = 0;\n    u32 *aSzIns = 0;\n    u32 *aSzDel = 0;\n    sqlite3_stmt *pStmt = 0;\n    int nEntry = 0;\n\n    /* Compose and prepare an SQL statement to loop through the content table */\n    char *zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    if( rc==SQLITE_OK ){\n      int nByte = sizeof(u32) * (p->nColumn+1)*3;\n      aSz = (u32 *)sqlite3_malloc(nByte);\n      if( aSz==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(aSz, 0, nByte);\n        aSzIns = &aSz[p->nColumn+1];\n        aSzDel = &aSzIns[p->nColumn+1];\n      }\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      int iCol;\n      int iLangid = langidFromSelect(p, pStmt);\n      rc = fts3PendingTermsDocid(p, 0, iLangid, sqlite3_column_int64(pStmt, 0));\n      memset(aSz, 0, sizeof(aSz[0]) * (p->nColumn+1));\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *z = (const char *) sqlite3_column_text(pStmt, iCol+1);\n          rc = fts3PendingTermsAdd(p, iLangid, z, iCol, &aSz[iCol]);\n          aSz[p->nColumn] += sqlite3_column_bytes(pStmt, iCol+1);\n        }\n      }\n      if( p->bHasDocsize ){\n        fts3InsertDocsize(&rc, p, aSz);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_finalize(pStmt);\n        pStmt = 0;\n      }else{\n        nEntry++;\n        for(iCol=0; iCol<=p->nColumn; iCol++){\n          aSzIns[iCol] += aSz[iCol];\n        }\n      }\n    }\n    if( p->bFts4 ){\n      fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);\n    }\n    sqlite3_free(aSz);\n\n    if( pStmt ){\n      int rc2 = sqlite3_finalize(pStmt);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\n/*\n** This function opens a cursor used to read the input data for an \n** incremental merge operation. Specifically, it opens a cursor to scan\n** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute \n** level iAbsLevel.\n*/\nstatic int fts3IncrmergeCsr(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to open */\n  int nSeg,                       /* Number of segments to merge */\n  Fts3MultiSegReader *pCsr        /* Cursor object to populate */\n){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pStmt = 0;        /* Statement used to read %_segdir entry */  \n  int nByte;                      /* Bytes allocated at pCsr->apSegment[] */\n\n  /* Allocate space for the Fts3MultiSegReader.aCsr[] array */\n  memset(pCsr, 0, sizeof(*pCsr));\n  nByte = sizeof(Fts3SegReader *) * nSeg;\n  pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);\n\n  if( pCsr->apSegment==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(pCsr->apSegment, 0, nByte);\n    rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);\n  }\n  if( rc==SQLITE_OK ){\n    int i;\n    int rc2;\n    sqlite3_bind_int64(pStmt, 1, iAbsLevel);\n    assert( pCsr->nSegment==0 );\n    for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){\n      rc = sqlite3Fts3SegReaderNew(i, 0,\n          sqlite3_column_int64(pStmt, 1),        /* segdir.start_block */\n          sqlite3_column_int64(pStmt, 2),        /* segdir.leaves_end_block */\n          sqlite3_column_int64(pStmt, 3),        /* segdir.end_block */\n          sqlite3_column_blob(pStmt, 4),         /* segdir.root */\n          sqlite3_column_bytes(pStmt, 4),        /* segdir.root */\n          &pCsr->apSegment[i]\n      );\n      pCsr->nSegment++;\n    }\n    rc2 = sqlite3_reset(pStmt);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\ntypedef struct IncrmergeWriter IncrmergeWriter;\ntypedef struct NodeWriter NodeWriter;\ntypedef struct Blob Blob;\ntypedef struct NodeReader NodeReader;\n\n/*\n** An instance of the following structure is used as a dynamic buffer\n** to build up nodes or other blobs of data in.\n**\n** The function blobGrowBuffer() is used to extend the allocation.\n*/\nstruct Blob {\n  char *a;                        /* Pointer to allocation */\n  int n;                          /* Number of valid bytes of data in a[] */\n  int nAlloc;                     /* Allocated size of a[] (nAlloc>=n) */\n};\n\n/*\n** This structure is used to build up buffers containing segment b-tree \n** nodes (blocks).\n*/\nstruct NodeWriter {\n  sqlite3_int64 iBlock;           /* Current block id */\n  Blob key;                       /* Last key written to the current block */\n  Blob block;                     /* Current block image */\n};\n\n/*\n** An object of this type contains the state required to create or append\n** to an appendable b-tree segment.\n*/\nstruct IncrmergeWriter {\n  int nLeafEst;                   /* Space allocated for leaf blocks */\n  int nWork;                      /* Number of leaf pages flushed */\n  sqlite3_int64 iAbsLevel;        /* Absolute level of input segments */\n  int iIdx;                       /* Index of *output* segment in iAbsLevel+1 */\n  sqlite3_int64 iStart;           /* Block number of first allocated block */\n  sqlite3_int64 iEnd;             /* Block number of last allocated block */\n  sqlite3_int64 nLeafData;        /* Bytes of leaf page data so far */\n  u8 bNoLeafData;                 /* If true, store 0 for segment size */\n  NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];\n};\n\n/*\n** An object of the following type is used to read data from a single\n** FTS segment node. See the following functions:\n**\n**     nodeReaderInit()\n**     nodeReaderNext()\n**     nodeReaderRelease()\n*/\nstruct NodeReader {\n  const char *aNode;\n  int nNode;\n  int iOff;                       /* Current offset within aNode[] */\n\n  /* Output variables. Containing the current node entry. */\n  sqlite3_int64 iChild;           /* Pointer to child node */\n  Blob term;                      /* Current term */\n  const char *aDoclist;           /* Pointer to doclist */\n  int nDoclist;                   /* Size of doclist in bytes */\n};\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, if the allocation at pBlob->a is not already at least nMin\n** bytes in size, extend (realloc) it to be so.\n**\n** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a\n** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc\n** to reflect the new size of the pBlob->a[] buffer.\n*/\nstatic void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){\n  if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){\n    int nAlloc = nMin;\n    char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);\n    if( a ){\n      pBlob->nAlloc = nAlloc;\n      pBlob->a = a;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Attempt to advance the node-reader object passed as the first argument to\n** the next entry on the node. \n**\n** Return an error code if an error occurs (SQLITE_NOMEM is possible). \n** Otherwise return SQLITE_OK. If there is no next entry on the node\n** (e.g. because the current entry is the last) set NodeReader->aNode to\n** NULL to indicate EOF. Otherwise, populate the NodeReader structure output \n** variables for the new entry.\n*/\nstatic int nodeReaderNext(NodeReader *p){\n  int bFirst = (p->term.n==0);    /* True for first term on the node */\n  int nPrefix = 0;                /* Bytes to copy from previous term */\n  int nSuffix = 0;                /* Bytes to append to the prefix */\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( p->aNode );\n  if( p->iChild && bFirst==0 ) p->iChild++;\n  if( p->iOff>=p->nNode ){\n    /* EOF */\n    p->aNode = 0;\n  }else{\n    if( bFirst==0 ){\n      p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);\n    }\n    p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);\n\n    blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);\n    if( rc==SQLITE_OK ){\n      memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);\n      p->term.n = nPrefix+nSuffix;\n      p->iOff += nSuffix;\n      if( p->iChild==0 ){\n        p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);\n        p->aDoclist = &p->aNode[p->iOff];\n        p->iOff += p->nDoclist;\n      }\n    }\n  }\n\n  assert( p->iOff<=p->nNode );\n\n  return rc;\n}\n\n/*\n** Release all dynamic resources held by node-reader object *p.\n*/\nstatic void nodeReaderRelease(NodeReader *p){\n  sqlite3_free(p->term.a);\n}\n\n/*\n** Initialize a node-reader object to read the node in buffer aNode/nNode.\n**\n** If successful, SQLITE_OK is returned and the NodeReader object set to \n** point to the first entry on the node (if any). Otherwise, an SQLite\n** error code is returned.\n*/\nstatic int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){\n  memset(p, 0, sizeof(NodeReader));\n  p->aNode = aNode;\n  p->nNode = nNode;\n\n  /* Figure out if this is a leaf or an internal node. */\n  if( p->aNode[0] ){\n    /* An internal node. */\n    p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);\n  }else{\n    p->iOff = 1;\n  }\n\n  return nodeReaderNext(p);\n}\n\n/*\n** This function is called while writing an FTS segment each time a leaf o\n** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed\n** to be greater than the largest key on the node just written, but smaller\n** than or equal to the first key that will be written to the next leaf\n** node.\n**\n** The block id of the leaf node just written to disk may be found in\n** (pWriter->aNodeWriter[0].iBlock) when this function is called.\n*/\nstatic int fts3IncrmergePush(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  const char *zTerm,              /* Term to write to internal node */\n  int nTerm                       /* Bytes at zTerm */\n){\n  sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;\n  int iLayer;\n\n  assert( nTerm>0 );\n  for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){\n    sqlite3_int64 iNextPtr = 0;\n    NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];\n    int rc = SQLITE_OK;\n    int nPrefix;\n    int nSuffix;\n    int nSpace;\n\n    /* Figure out how much space the key will consume if it is written to\n    ** the current node of layer iLayer. Due to the prefix compression, \n    ** the space required changes depending on which node the key is to\n    ** be added to.  */\n    nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);\n    nSuffix = nTerm - nPrefix;\n    nSpace  = sqlite3Fts3VarintLen(nPrefix);\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n\n    if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){ \n      /* If the current node of layer iLayer contains zero keys, or if adding\n      ** the key to it will not cause it to grow to larger than nNodeSize \n      ** bytes in size, write the key here.  */\n\n      Blob *pBlk = &pNode->block;\n      if( pBlk->n==0 ){\n        blobGrowBuffer(pBlk, p->nNodeSize, &rc);\n        if( rc==SQLITE_OK ){\n          pBlk->a[0] = (char)iLayer;\n          pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);\n        }\n      }\n      blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);\n      blobGrowBuffer(&pNode->key, nTerm, &rc);\n\n      if( rc==SQLITE_OK ){\n        if( pNode->key.n ){\n          pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);\n        }\n        pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);\n        memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);\n        pBlk->n += nSuffix;\n\n        memcpy(pNode->key.a, zTerm, nTerm);\n        pNode->key.n = nTerm;\n      }\n    }else{\n      /* Otherwise, flush the current node of layer iLayer to disk.\n      ** Then allocate a new, empty sibling node. The key will be written\n      ** into the parent of this node. */\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n\n      assert( pNode->block.nAlloc>=p->nNodeSize );\n      pNode->block.a[0] = (char)iLayer;\n      pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);\n\n      iNextPtr = pNode->iBlock;\n      pNode->iBlock++;\n      pNode->key.n = 0;\n    }\n\n    if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;\n    iPtr = iNextPtr;\n  }\n\n  assert( 0 );\n  return 0;\n}\n\n/*\n** Append a term and (optionally) doclist to the FTS segment node currently\n** stored in blob *pNode. The node need not contain any terms, but the\n** header must be written before this function is called.\n**\n** A node header is a single 0x00 byte for a leaf node, or a height varint\n** followed by the left-hand-child varint for an internal node.\n**\n** The term to be appended is passed via arguments zTerm/nTerm. For a \n** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal\n** node, both aDoclist and nDoclist must be passed 0.\n**\n** If the size of the value in blob pPrev is zero, then this is the first\n** term written to the node. Otherwise, pPrev contains a copy of the \n** previous term. Before this function returns, it is updated to contain a\n** copy of zTerm/nTerm.\n**\n** It is assumed that the buffer associated with pNode is already large\n** enough to accommodate the new entry. The buffer associated with pPrev\n** is extended by this function if requrired.\n**\n** If an error (i.e. OOM condition) occurs, an SQLite error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic int fts3AppendToNode(\n  Blob *pNode,                    /* Current node image to append to */\n  Blob *pPrev,                    /* Buffer containing previous term written */\n  const char *zTerm,              /* New term to write */\n  int nTerm,                      /* Size of zTerm in bytes */\n  const char *aDoclist,           /* Doclist (or NULL) to write */\n  int nDoclist                    /* Size of aDoclist in bytes */ \n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFirst = (pPrev->n==0);     /* True if this is the first term written */\n  int nPrefix;                    /* Size of term prefix in bytes */\n  int nSuffix;                    /* Size of term suffix in bytes */\n\n  /* Node must have already been started. There must be a doclist for a\n  ** leaf node, and there must not be a doclist for an internal node.  */\n  assert( pNode->n>0 );\n  assert( (pNode->a[0]=='\\0')==(aDoclist!=0) );\n\n  blobGrowBuffer(pPrev, nTerm, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n  memcpy(pPrev->a, zTerm, nTerm);\n  pPrev->n = nTerm;\n\n  if( bFirst==0 ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);\n  }\n  pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);\n  memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);\n  pNode->n += nSuffix;\n\n  if( aDoclist ){\n    pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);\n    memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);\n    pNode->n += nDoclist;\n  }\n\n  assert( pNode->n<=pNode->nAlloc );\n\n  return SQLITE_OK;\n}\n\n/*\n** Append the current term and doclist pointed to by cursor pCsr to the\n** appendable b-tree segment opened for writing by pWriter.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int fts3IncrmergeAppend(\n  Fts3Table *p,                   /* Fts3 table handle */\n  IncrmergeWriter *pWriter,       /* Writer object */\n  Fts3MultiSegReader *pCsr        /* Cursor containing term and doclist */\n){\n  const char *zTerm = pCsr->zTerm;\n  int nTerm = pCsr->nTerm;\n  const char *aDoclist = pCsr->aDoclist;\n  int nDoclist = pCsr->nDoclist;\n  int rc = SQLITE_OK;           /* Return code */\n  int nSpace;                   /* Total space in bytes required on leaf */\n  int nPrefix;                  /* Size of prefix shared with previous term */\n  int nSuffix;                  /* Size of suffix (nTerm - nPrefix) */\n  NodeWriter *pLeaf;            /* Object used to write leaf nodes */\n\n  pLeaf = &pWriter->aNodeWriter[0];\n  nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);\n  nSuffix = nTerm - nPrefix;\n\n  nSpace  = sqlite3Fts3VarintLen(nPrefix);\n  nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n  nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n\n  /* If the current block is not empty, and if adding this term/doclist\n  ** to the current block would make it larger than Fts3Table.nNodeSize\n  ** bytes, write this block out to the database. */\n  if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){\n    rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);\n    pWriter->nWork++;\n\n    /* Add the current term to the parent node. The term added to the \n    ** parent must:\n    **\n    **   a) be greater than the largest term on the leaf node just written\n    **      to the database (still available in pLeaf->key), and\n    **\n    **   b) be less than or equal to the term about to be added to the new\n    **      leaf node (zTerm/nTerm).\n    **\n    ** In other words, it must be the prefix of zTerm 1 byte longer than\n    ** the common prefix (if any) of zTerm and pWriter->zTerm.\n    */\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);\n    }\n\n    /* Advance to the next output block */\n    pLeaf->iBlock++;\n    pLeaf->key.n = 0;\n    pLeaf->block.n = 0;\n\n    nSuffix = nTerm;\n    nSpace  = 1;\n    nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;\n    nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;\n  }\n\n  pWriter->nLeafData += nSpace;\n  blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);\n  if( rc==SQLITE_OK ){\n    if( pLeaf->block.n==0 ){\n      pLeaf->block.n = 1;\n      pLeaf->block.a[0] = '\\0';\n    }\n    rc = fts3AppendToNode(\n        &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist\n    );\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to release all dynamic resources held by the\n** merge-writer object pWriter, and if no error has occurred, to flush\n** all outstanding node buffers held by pWriter to disk.\n**\n** If *pRc is not SQLITE_OK when this function is called, then no attempt\n** is made to write any data to disk. Instead, this function serves only\n** to release outstanding resources.\n**\n** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while\n** flushing buffers to disk, *pRc is set to an SQLite error code before\n** returning.\n*/\nstatic void fts3IncrmergeRelease(\n  Fts3Table *p,                   /* FTS3 table handle */\n  IncrmergeWriter *pWriter,       /* Merge-writer object */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int i;                          /* Used to iterate through non-root layers */\n  int iRoot;                      /* Index of root in pWriter->aNodeWriter */\n  NodeWriter *pRoot;              /* NodeWriter for root node */\n  int rc = *pRc;                  /* Error code */\n\n  /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment \n  ** root node. If the segment fits entirely on a single leaf node, iRoot\n  ** will be set to 0. If the root node is the parent of the leaves, iRoot\n  ** will be 1. And so on.  */\n  for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){\n    NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];\n    if( pNode->block.n>0 ) break;\n    assert( *pRc || pNode->block.nAlloc==0 );\n    assert( *pRc || pNode->key.nAlloc==0 );\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Empty output segment. This is a no-op. */\n  if( iRoot<0 ) return;\n\n  /* The entire output segment fits on a single node. Normally, this means\n  ** the node would be stored as a blob in the \"root\" column of the %_segdir\n  ** table. However, this is not permitted in this case. The problem is that \n  ** space has already been reserved in the %_segments table, and so the \n  ** start_block and end_block fields of the %_segdir table must be populated. \n  ** And, by design or by accident, released versions of FTS cannot handle \n  ** segments that fit entirely on the root node with start_block!=0.\n  **\n  ** Instead, create a synthetic root node that contains nothing but a \n  ** pointer to the single content node. So that the segment consists of a\n  ** single leaf and a single interior (root) node.\n  **\n  ** Todo: Better might be to defer allocating space in the %_segments \n  ** table until we are sure it is needed.\n  */\n  if( iRoot==0 ){\n    Blob *pBlock = &pWriter->aNodeWriter[1].block;\n    blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);\n    if( rc==SQLITE_OK ){\n      pBlock->a[0] = 0x01;\n      pBlock->n = 1 + sqlite3Fts3PutVarint(\n          &pBlock->a[1], pWriter->aNodeWriter[0].iBlock\n      );\n    }\n    iRoot = 1;\n  }\n  pRoot = &pWriter->aNodeWriter[iRoot];\n\n  /* Flush all currently outstanding nodes to disk. */\n  for(i=0; i<iRoot; i++){\n    NodeWriter *pNode = &pWriter->aNodeWriter[i];\n    if( pNode->block.n>0 && rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);\n    }\n    sqlite3_free(pNode->block.a);\n    sqlite3_free(pNode->key.a);\n  }\n\n  /* Write the %_segdir record. */\n  if( rc==SQLITE_OK ){\n    rc = fts3WriteSegdir(p, \n        pWriter->iAbsLevel+1,               /* level */\n        pWriter->iIdx,                      /* idx */\n        pWriter->iStart,                    /* start_block */\n        pWriter->aNodeWriter[0].iBlock,     /* leaves_end_block */\n        pWriter->iEnd,                      /* end_block */\n        (pWriter->bNoLeafData==0 ? pWriter->nLeafData : 0),   /* end_block */\n        pRoot->block.a, pRoot->block.n      /* root */\n    );\n  }\n  sqlite3_free(pRoot->block.a);\n  sqlite3_free(pRoot->key.a);\n\n  *pRc = rc;\n}\n\n/*\n** Compare the term in buffer zLhs (size in bytes nLhs) with that in\n** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of\n** the other, it is considered to be smaller than the other.\n**\n** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve\n** if it is greater.\n*/\nstatic int fts3TermCmp(\n  const char *zLhs, int nLhs,     /* LHS of comparison */\n  const char *zRhs, int nRhs      /* RHS of comparison */\n){\n  int nCmp = MIN(nLhs, nRhs);\n  int res;\n\n  res = memcmp(zLhs, zRhs, nCmp);\n  if( res==0 ) res = nLhs - nRhs;\n\n  return res;\n}\n\n\n/*\n** Query to see if the entry in the %_segments table with blockid iEnd is \n** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before\n** returning. Otherwise, set *pbRes to 0. \n**\n** Or, if an error occurs while querying the database, return an SQLite \n** error code. The final value of *pbRes is undefined in this case.\n**\n** This is used to test if a segment is an \"appendable\" segment. If it\n** is, then a NULL entry has been inserted into the %_segments table\n** with blockid %_segdir.end_block.\n*/\nstatic int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){\n  int bRes = 0;                   /* Result to set *pbRes to */\n  sqlite3_stmt *pCheck = 0;       /* Statement to query database with */\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pCheck, 1, iEnd);\n    if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;\n    rc = sqlite3_reset(pCheck);\n  }\n  \n  *pbRes = bRes;\n  return rc;\n}\n\n/*\n** This function is called when initializing an incremental-merge operation.\n** It checks if the existing segment with index value iIdx at absolute level \n** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the\n** merge-writer object *pWriter is initialized to write to it.\n**\n** An existing segment can be appended to by an incremental merge if:\n**\n**   * It was initially created as an appendable segment (with all required\n**     space pre-allocated), and\n**\n**   * The first key read from the input (arguments zKey and nKey) is \n**     greater than the largest key currently stored in the potential\n**     output segment.\n*/\nstatic int fts3IncrmergeLoad(\n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of candidate output segment */\n  const char *zKey,               /* First key to write */\n  int nKey,                       /* Number of bytes in nKey */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSelect = 0;      /* SELECT to read %_segdir entry */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_int64 iStart = 0;     /* Value of %_segdir.start_block */\n    sqlite3_int64 iLeafEnd = 0;   /* Value of %_segdir.leaves_end_block */\n    sqlite3_int64 iEnd = 0;       /* Value of %_segdir.end_block */\n    const char *aRoot = 0;        /* Pointer to %_segdir.root buffer */\n    int nRoot = 0;                /* Size of aRoot[] in bytes */\n    int rc2;                      /* Return code from sqlite3_reset() */\n    int bAppendable = 0;          /* Set to true if segment is appendable */\n\n    /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);\n    sqlite3_bind_int(pSelect, 2, iIdx);\n    if( sqlite3_step(pSelect)==SQLITE_ROW ){\n      iStart = sqlite3_column_int64(pSelect, 1);\n      iLeafEnd = sqlite3_column_int64(pSelect, 2);\n      fts3ReadEndBlockField(pSelect, 3, &iEnd, &pWriter->nLeafData);\n      if( pWriter->nLeafData<0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      pWriter->bNoLeafData = (pWriter->nLeafData==0);\n      nRoot = sqlite3_column_bytes(pSelect, 4);\n      aRoot = sqlite3_column_blob(pSelect, 4);\n    }else{\n      return sqlite3_reset(pSelect);\n    }\n\n    /* Check for the zero-length marker in the %_segments table */\n    rc = fts3IsAppendable(p, iEnd, &bAppendable);\n\n    /* Check that zKey/nKey is larger than the largest key the candidate */\n    if( rc==SQLITE_OK && bAppendable ){\n      char *aLeaf = 0;\n      int nLeaf = 0;\n\n      rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);\n      if( rc==SQLITE_OK ){\n        NodeReader reader;\n        for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);\n            rc==SQLITE_OK && reader.aNode;\n            rc = nodeReaderNext(&reader)\n        ){\n          assert( reader.aNode );\n        }\n        if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){\n          bAppendable = 0;\n        }\n        nodeReaderRelease(&reader);\n      }\n      sqlite3_free(aLeaf);\n    }\n\n    if( rc==SQLITE_OK && bAppendable ){\n      /* It is possible to append to this segment. Set up the IncrmergeWriter\n      ** object to do so.  */\n      int i;\n      int nHeight = (int)aRoot[0];\n      NodeWriter *pNode;\n\n      pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;\n      pWriter->iStart = iStart;\n      pWriter->iEnd = iEnd;\n      pWriter->iAbsLevel = iAbsLevel;\n      pWriter->iIdx = iIdx;\n\n      for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n        pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n      }\n\n      pNode = &pWriter->aNodeWriter[nHeight];\n      pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;\n      blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);\n      if( rc==SQLITE_OK ){\n        memcpy(pNode->block.a, aRoot, nRoot);\n        pNode->block.n = nRoot;\n      }\n\n      for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){\n        NodeReader reader;\n        pNode = &pWriter->aNodeWriter[i];\n\n        rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);\n        while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);\n        blobGrowBuffer(&pNode->key, reader.term.n, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pNode->key.a, reader.term.a, reader.term.n);\n          pNode->key.n = reader.term.n;\n          if( i>0 ){\n            char *aBlock = 0;\n            int nBlock = 0;\n            pNode = &pWriter->aNodeWriter[i-1];\n            pNode->iBlock = reader.iChild;\n            rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);\n            blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);\n            if( rc==SQLITE_OK ){\n              memcpy(pNode->block.a, aBlock, nBlock);\n              pNode->block.n = nBlock;\n            }\n            sqlite3_free(aBlock);\n          }\n        }\n        nodeReaderRelease(&reader);\n      }\n    }\n\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** Determine the largest segment index value that exists within absolute\n** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus\n** one before returning SQLITE_OK. Or, if there are no segments at all \n** within level iAbsLevel, set *piIdx to zero.\n**\n** If an error occurs, return an SQLite error code. The final value of\n** *piIdx is undefined in this case.\n*/\nstatic int fts3IncrmergeOutputIdx( \n  Fts3Table *p,                   /* FTS Table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute index of input segments */\n  int *piIdx                      /* OUT: Next free index at iAbsLevel+1 */\n){\n  int rc;\n  sqlite3_stmt *pOutputIdx = 0;   /* SQL used to find output index */\n\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);\n    sqlite3_step(pOutputIdx);\n    *piIdx = sqlite3_column_int(pOutputIdx, 0);\n    rc = sqlite3_reset(pOutputIdx);\n  }\n\n  return rc;\n}\n\n/* \n** Allocate an appendable output segment on absolute level iAbsLevel+1\n** with idx value iIdx.\n**\n** In the %_segdir table, a segment is defined by the values in three\n** columns:\n**\n**     start_block\n**     leaves_end_block\n**     end_block\n**\n** When an appendable segment is allocated, it is estimated that the\n** maximum number of leaf blocks that may be required is the sum of the\n** number of leaf blocks consumed by the input segments, plus the number\n** of input segments, multiplied by two. This value is stored in stack \n** variable nLeafEst.\n**\n** A total of 16*nLeafEst blocks are allocated when an appendable segment\n** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous\n** array of leaf nodes starts at the first block allocated. The array\n** of interior nodes that are parents of the leaf nodes start at block\n** (start_block + (1 + end_block - start_block) / 16). And so on.\n**\n** In the actual code below, the value \"16\" is replaced with the \n** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.\n*/\nstatic int fts3IncrmergeWriter( \n  Fts3Table *p,                   /* Fts3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of input segments */\n  int iIdx,                       /* Index of new output segment */\n  Fts3MultiSegReader *pCsr,       /* Cursor that data will be read from */\n  IncrmergeWriter *pWriter        /* Populate this object */\n){\n  int rc;                         /* Return Code */\n  int i;                          /* Iterator variable */\n  int nLeafEst = 0;               /* Blocks allocated for leaf nodes */\n  sqlite3_stmt *pLeafEst = 0;     /* SQL used to determine nLeafEst */\n  sqlite3_stmt *pFirstBlock = 0;  /* SQL used to determine first block */\n\n  /* Calculate nLeafEst. */\n  rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);\n    sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);\n    if( SQLITE_ROW==sqlite3_step(pLeafEst) ){\n      nLeafEst = sqlite3_column_int(pLeafEst, 0);\n    }\n    rc = sqlite3_reset(pLeafEst);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Calculate the first block to use in the output segment */\n  rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);\n  if( rc==SQLITE_OK ){\n    if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){\n      pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);\n      pWriter->iEnd = pWriter->iStart - 1;\n      pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;\n    }\n    rc = sqlite3_reset(pFirstBlock);\n  }\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Insert the marker in the %_segments table to make sure nobody tries\n  ** to steal the space just allocated. This is also used to identify \n  ** appendable segments.  */\n  rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pWriter->iAbsLevel = iAbsLevel;\n  pWriter->nLeafEst = nLeafEst;\n  pWriter->iIdx = iIdx;\n\n  /* Set up the array of NodeWriter objects */\n  for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){\n    pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Remove an entry from the %_segdir table. This involves running the \n** following two statements:\n**\n**   DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx\n**   UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx\n**\n** The DELETE statement removes the specific %_segdir level. The UPDATE \n** statement ensures that the remaining segments have contiguously allocated\n** idx values.\n*/\nstatic int fts3RemoveSegdirEntry(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level to delete from */\n  int iIdx                        /* Index of %_segdir entry to delete */\n){\n  int rc;                         /* Return code */\n  sqlite3_stmt *pDelete = 0;      /* DELETE statement */\n\n  rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pDelete, 1, iAbsLevel);\n    sqlite3_bind_int(pDelete, 2, iIdx);\n    sqlite3_step(pDelete);\n    rc = sqlite3_reset(pDelete);\n  }\n\n  return rc;\n}\n\n/*\n** One or more segments have just been removed from absolute level iAbsLevel.\n** Update the 'idx' values of the remaining segments in the level so that\n** the idx values are a contiguous sequence starting from 0.\n*/\nstatic int fts3RepackSegdirLevel(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel         /* Absolute level to repack */\n){\n  int rc;                         /* Return code */\n  int *aIdx = 0;                  /* Array of remaining idx values */\n  int nIdx = 0;                   /* Valid entries in aIdx[] */\n  int nAlloc = 0;                 /* Allocated size of aIdx[] */\n  int i;                          /* Iterator variable */\n  sqlite3_stmt *pSelect = 0;      /* Select statement to read idx values */\n  sqlite3_stmt *pUpdate = 0;      /* Update statement to modify idx values */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int64(pSelect, 1, iAbsLevel);\n    while( SQLITE_ROW==sqlite3_step(pSelect) ){\n      if( nIdx>=nAlloc ){\n        int *aNew;\n        nAlloc += 16;\n        aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));\n        if( !aNew ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        aIdx = aNew;\n      }\n      aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pUpdate, 2, iAbsLevel);\n  }\n\n  assert( p->bIgnoreSavepoint==0 );\n  p->bIgnoreSavepoint = 1;\n  for(i=0; rc==SQLITE_OK && i<nIdx; i++){\n    if( aIdx[i]!=i ){\n      sqlite3_bind_int(pUpdate, 3, aIdx[i]);\n      sqlite3_bind_int(pUpdate, 1, i);\n      sqlite3_step(pUpdate);\n      rc = sqlite3_reset(pUpdate);\n    }\n  }\n  p->bIgnoreSavepoint = 0;\n\n  sqlite3_free(aIdx);\n  return rc;\n}\n\nstatic void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){\n  pNode->a[0] = (char)iHeight;\n  if( iChild ){\n    assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );\n    pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);\n  }else{\n    assert( pNode->nAlloc>=1 );\n    pNode->n = 1;\n  }\n}\n\n/*\n** The first two arguments are a pointer to and the size of a segment b-tree\n** node. The node may be a leaf or an internal node.\n**\n** This function creates a new node image in blob object *pNew by copying\n** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)\n** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.\n*/\nstatic int fts3TruncateNode(\n  const char *aNode,              /* Current node image */\n  int nNode,                      /* Size of aNode in bytes */\n  Blob *pNew,                     /* OUT: Write new node image here */\n  const char *zTerm,              /* Omit all terms smaller than this */\n  int nTerm,                      /* Size of zTerm in bytes */\n  sqlite3_int64 *piBlock          /* OUT: Block number in next layer down */\n){\n  NodeReader reader;              /* Reader object */\n  Blob prev = {0, 0, 0};          /* Previous term written to new node */\n  int rc = SQLITE_OK;             /* Return code */\n  int bLeaf = aNode[0]=='\\0';     /* True for a leaf node */\n\n  /* Allocate required output space */\n  blobGrowBuffer(pNew, nNode, &rc);\n  if( rc!=SQLITE_OK ) return rc;\n  pNew->n = 0;\n\n  /* Populate new node buffer */\n  for(rc = nodeReaderInit(&reader, aNode, nNode); \n      rc==SQLITE_OK && reader.aNode; \n      rc = nodeReaderNext(&reader)\n  ){\n    if( pNew->n==0 ){\n      int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);\n      if( res<0 || (bLeaf==0 && res==0) ) continue;\n      fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n      *piBlock = reader.iChild;\n    }\n    rc = fts3AppendToNode(\n        pNew, &prev, reader.term.a, reader.term.n,\n        reader.aDoclist, reader.nDoclist\n    );\n    if( rc!=SQLITE_OK ) break;\n  }\n  if( pNew->n==0 ){\n    fts3StartNode(pNew, (int)aNode[0], reader.iChild);\n    *piBlock = reader.iChild;\n  }\n  assert( pNew->n<=pNew->nAlloc );\n\n  nodeReaderRelease(&reader);\n  sqlite3_free(prev.a);\n  return rc;\n}\n\n/*\n** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute \n** level iAbsLevel. This may involve deleting entries from the %_segments\n** table, and modifying existing entries in both the %_segments and %_segdir\n** tables.\n**\n** SQLITE_OK is returned if the segment is updated successfully. Or an\n** SQLite error code otherwise.\n*/\nstatic int fts3TruncateSegment(\n  Fts3Table *p,                   /* FTS3 table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level of segment to modify */\n  int iIdx,                       /* Index within level of segment to modify */\n  const char *zTerm,              /* Remove terms smaller than this */\n  int nTerm                      /* Number of bytes in buffer zTerm */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Blob root = {0,0,0};            /* New root page image */\n  Blob block = {0,0,0};           /* Buffer used for any other block */\n  sqlite3_int64 iBlock = 0;       /* Block id */\n  sqlite3_int64 iNewStart = 0;    /* New value for iStartBlock */\n  sqlite3_int64 iOldStart = 0;    /* Old value for iStartBlock */\n  sqlite3_stmt *pFetch = 0;       /* Statement used to fetch segdir */\n\n  rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;                      /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pFetch, 1, iAbsLevel);\n    sqlite3_bind_int(pFetch, 2, iIdx);\n    if( SQLITE_ROW==sqlite3_step(pFetch) ){\n      const char *aRoot = sqlite3_column_blob(pFetch, 4);\n      int nRoot = sqlite3_column_bytes(pFetch, 4);\n      iOldStart = sqlite3_column_int64(pFetch, 1);\n      rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);\n    }\n    rc2 = sqlite3_reset(pFetch);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  while( rc==SQLITE_OK && iBlock ){\n    char *aBlock = 0;\n    int nBlock = 0;\n    iNewStart = iBlock;\n\n    rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);\n    if( rc==SQLITE_OK ){\n      rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);\n    }\n    if( rc==SQLITE_OK ){\n      rc = fts3WriteSegment(p, iNewStart, block.a, block.n);\n    }\n    sqlite3_free(aBlock);\n  }\n\n  /* Variable iNewStart now contains the first valid leaf node. */\n  if( rc==SQLITE_OK && iNewStart ){\n    sqlite3_stmt *pDel = 0;\n    rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iOldStart);\n      sqlite3_bind_int64(pDel, 2, iNewStart-1);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sqlite3_stmt *pChomp = 0;\n    rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pChomp, 1, iNewStart);\n      sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);\n      sqlite3_bind_int64(pChomp, 3, iAbsLevel);\n      sqlite3_bind_int(pChomp, 4, iIdx);\n      sqlite3_step(pChomp);\n      rc = sqlite3_reset(pChomp);\n    }\n  }\n\n  sqlite3_free(root.a);\n  sqlite3_free(block.a);\n  return rc;\n}\n\n/*\n** This function is called after an incrmental-merge operation has run to\n** merge (or partially merge) two or more segments from absolute level\n** iAbsLevel.\n**\n** Each input segment is either removed from the db completely (if all of\n** its data was copied to the output segment by the incrmerge operation)\n** or modified in place so that it no longer contains those entries that\n** have been duplicated in the output segment.\n*/\nstatic int fts3IncrmergeChomp(\n  Fts3Table *p,                   /* FTS table handle */\n  sqlite3_int64 iAbsLevel,        /* Absolute level containing segments */\n  Fts3MultiSegReader *pCsr,       /* Chomp all segments opened by this cursor */\n  int *pnRem                      /* Number of segments not deleted */\n){\n  int i;\n  int nRem = 0;\n  int rc = SQLITE_OK;\n\n  for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){\n    Fts3SegReader *pSeg = 0;\n    int j;\n\n    /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding\n    ** somewhere in the pCsr->apSegment[] array.  */\n    for(j=0; ALWAYS(j<pCsr->nSegment); j++){\n      pSeg = pCsr->apSegment[j];\n      if( pSeg->iIdx==i ) break;\n    }\n    assert( j<pCsr->nSegment && pSeg->iIdx==i );\n\n    if( pSeg->aNode==0 ){\n      /* Seg-reader is at EOF. Remove the entire input segment. */\n      rc = fts3DeleteSegment(p, pSeg);\n      if( rc==SQLITE_OK ){\n        rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);\n      }\n      *pnRem = 0;\n    }else{\n      /* The incremental merge did not copy all the data from this \n      ** segment to the upper level. The segment is modified in place\n      ** so that it contains no keys smaller than zTerm/nTerm. */ \n      const char *zTerm = pSeg->zTerm;\n      int nTerm = pSeg->nTerm;\n      rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);\n      nRem++;\n    }\n  }\n\n  if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){\n    rc = fts3RepackSegdirLevel(p, iAbsLevel);\n  }\n\n  *pnRem = nRem;\n  return rc;\n}\n\n/*\n** Store an incr-merge hint in the database.\n*/\nstatic int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pReplace = 0;\n  int rc;                         /* Return code */\n\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);\n    sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n  }\n\n  return rc;\n}\n\n/*\n** Load an incr-merge hint from the database. The incr-merge hint, if one \n** exists, is stored in the rowid==1 row of the %_stat table.\n**\n** If successful, populate blob *pHint with the value read from the %_stat\n** table and return SQLITE_OK. Otherwise, if an error occurs, return an\n** SQLite error code.\n*/\nstatic int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){\n  sqlite3_stmt *pSelect = 0;\n  int rc;\n\n  pHint->n = 0;\n  rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);\n    if( SQLITE_ROW==sqlite3_step(pSelect) ){\n      const char *aHint = sqlite3_column_blob(pSelect, 0);\n      int nHint = sqlite3_column_bytes(pSelect, 0);\n      if( aHint ){\n        blobGrowBuffer(pHint, nHint, &rc);\n        if( rc==SQLITE_OK ){\n          memcpy(pHint->a, aHint, nHint);\n          pHint->n = nHint;\n        }\n      }\n    }\n    rc2 = sqlite3_reset(pSelect);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  return rc;\n}\n\n/*\n** If *pRc is not SQLITE_OK when this function is called, it is a no-op.\n** Otherwise, append an entry to the hint stored in blob *pHint. Each entry\n** consists of two varints, the absolute level number of the input segments \n** and the number of input segments.\n**\n** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,\n** set *pRc to an SQLite error code before returning.\n*/\nstatic void fts3IncrmergeHintPush(\n  Blob *pHint,                    /* Hint blob to append to */\n  i64 iAbsLevel,                  /* First varint to store in hint */\n  int nInput,                     /* Second varint to store in hint */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);\n  if( *pRc==SQLITE_OK ){\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);\n    pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);\n  }\n}\n\n/*\n** Read the last entry (most recently pushed) from the hint blob *pHint\n** and then remove the entry. Write the two values read to *piAbsLevel and \n** *pnInput before returning.\n**\n** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does\n** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.\n*/\nstatic int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){\n  const int nHint = pHint->n;\n  int i;\n\n  i = pHint->n-2;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n  while( i>0 && (pHint->a[i-1] & 0x80) ) i--;\n\n  pHint->n = i;\n  i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);\n  i += fts3GetVarint32(&pHint->a[i], pnInput);\n  if( i!=nHint ) return FTS_CORRUPT_VTAB;\n\n  return SQLITE_OK;\n}\n\n\n/*\n** Attempt an incremental merge that writes nMerge leaf blocks.\n**\n** Incremental merges happen nMin segments at a time. The segments \n** to be merged are the nMin oldest segments (the ones with the smallest \n** values for the _segdir.idx field) in the highest level that contains \n** at least nMin segments. Multiple merges might occur in an attempt to \n** write the quota of nMerge leaf blocks.\n*/\nSQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){\n  int rc;                         /* Return code */\n  int nRem = nMerge;              /* Number of leaf pages yet to  be written */\n  Fts3MultiSegReader *pCsr;       /* Cursor used to read input data */\n  Fts3SegFilter *pFilter;         /* Filter used with cursor pCsr */\n  IncrmergeWriter *pWriter;       /* Writer object */\n  int nSeg = 0;                   /* Number of input segments */\n  sqlite3_int64 iAbsLevel = 0;    /* Absolute level number to work on */\n  Blob hint = {0, 0, 0};          /* Hint read from %_stat table */\n  int bDirtyHint = 0;             /* True if blob 'hint' has been modified */\n\n  /* Allocate space for the cursor, filter and writer objects */\n  const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);\n  pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);\n  if( !pWriter ) return SQLITE_NOMEM;\n  pFilter = (Fts3SegFilter *)&pWriter[1];\n  pCsr = (Fts3MultiSegReader *)&pFilter[1];\n\n  rc = fts3IncrmergeHintLoad(p, &hint);\n  while( rc==SQLITE_OK && nRem>0 ){\n    const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;\n    sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */\n    int bUseHint = 0;             /* True if attempting to append */\n    int iIdx = 0;                 /* Largest idx in level (iAbsLevel+1) */\n\n    /* Search the %_segdir table for the absolute level with the smallest\n    ** relative level number that contains at least nMin segments, if any.\n    ** If one is found, set iAbsLevel to the absolute level number and\n    ** nSeg to nMin. If no level with at least nMin segments can be found, \n    ** set nSeg to -1.\n    */\n    rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);\n    sqlite3_bind_int(pFindLevel, 1, MAX(2, nMin));\n    if( sqlite3_step(pFindLevel)==SQLITE_ROW ){\n      iAbsLevel = sqlite3_column_int64(pFindLevel, 0);\n      nSeg = sqlite3_column_int(pFindLevel, 1);\n      assert( nSeg>=2 );\n    }else{\n      nSeg = -1;\n    }\n    rc = sqlite3_reset(pFindLevel);\n\n    /* If the hint read from the %_stat table is not empty, check if the\n    ** last entry in it specifies a relative level smaller than or equal\n    ** to the level identified by the block above (if any). If so, this \n    ** iteration of the loop will work on merging at the hinted level.\n    */\n    if( rc==SQLITE_OK && hint.n ){\n      int nHint = hint.n;\n      sqlite3_int64 iHintAbsLevel = 0;      /* Hint level */\n      int nHintSeg = 0;                     /* Hint number of segments */\n\n      rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);\n      if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){\n        iAbsLevel = iHintAbsLevel;\n        nSeg = nHintSeg;\n        bUseHint = 1;\n        bDirtyHint = 1;\n      }else{\n        /* This undoes the effect of the HintPop() above - so that no entry\n        ** is removed from the hint blob.  */\n        hint.n = nHint;\n      }\n    }\n\n    /* If nSeg is less that zero, then there is no level with at least\n    ** nMin segments and no hint in the %_stat table. No work to do.\n    ** Exit early in this case.  */\n    if( nSeg<0 ) break;\n\n    /* Open a cursor to iterate through the contents of the oldest nSeg \n    ** indexes of absolute level iAbsLevel. If this cursor is opened using \n    ** the 'hint' parameters, it is possible that there are less than nSeg\n    ** segments available in level iAbsLevel. In this case, no work is\n    ** done on iAbsLevel - fall through to the next iteration of the loop \n    ** to start work on some other level.  */\n    memset(pWriter, 0, nAlloc);\n    pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);\n      assert( bUseHint==1 || bUseHint==0 );\n      if( iIdx==0 || (bUseHint && iIdx==1) ){\n        int bIgnore = 0;\n        rc = fts3SegmentIsMaxLevel(p, iAbsLevel+1, &bIgnore);\n        if( bIgnore ){\n          pFilter->flags |= FTS3_SEGMENT_IGNORE_EMPTY;\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);\n    }\n    if( SQLITE_OK==rc && pCsr->nSegment==nSeg\n     && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))\n     && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))\n    ){\n      if( bUseHint && iIdx>0 ){\n        const char *zKey = pCsr->zTerm;\n        int nKey = pCsr->nTerm;\n        rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);\n      }else{\n        rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);\n      }\n\n      if( rc==SQLITE_OK && pWriter->nLeafEst ){\n        fts3LogMerge(nSeg, iAbsLevel);\n        do {\n          rc = fts3IncrmergeAppend(p, pWriter, pCsr);\n          if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);\n          if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;\n        }while( rc==SQLITE_ROW );\n\n        /* Update or delete the input segments */\n        if( rc==SQLITE_OK ){\n          nRem -= (1 + pWriter->nWork);\n          rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);\n          if( nSeg!=0 ){\n            bDirtyHint = 1;\n            fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);\n          }\n        }\n      }\n\n      if( nSeg!=0 ){\n        pWriter->nLeafData = pWriter->nLeafData * -1;\n      }\n      fts3IncrmergeRelease(p, pWriter, &rc);\n      if( nSeg==0 && pWriter->bNoLeafData==0 ){\n        fts3PromoteSegments(p, iAbsLevel+1, pWriter->nLeafData);\n      }\n    }\n\n    sqlite3Fts3SegReaderFinish(pCsr);\n  }\n\n  /* Write the hint values into the %_stat table for the next incr-merger */\n  if( bDirtyHint && rc==SQLITE_OK ){\n    rc = fts3IncrmergeHintStore(p, &hint);\n  }\n\n  sqlite3_free(pWriter);\n  sqlite3_free(hint.a);\n  return rc;\n}\n\n/*\n** Convert the text beginning at *pz into an integer and return\n** its value.  Advance *pz to point to the first character past\n** the integer.\n**\n** This function used for parameters to merge= and incrmerge=\n** commands. \n*/\nstatic int fts3Getint(const char **pz){\n  const char *z = *pz;\n  int i = 0;\n  while( (*z)>='0' && (*z)<='9' && i<214748363 ) i = 10*i + *(z++) - '0';\n  *pz = z;\n  return i;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('merge=A,B');\n**\n** A and B are integers that decode to be the number of leaf pages\n** written for the merge, and the minimum number of segments on a level\n** before it will be selected for a merge, respectively.\n*/\nstatic int fts3DoIncrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing \"A,B\" */\n){\n  int rc;\n  int nMin = (FTS3_MERGE_COUNT / 2);\n  int nMerge = 0;\n  const char *z = zParam;\n\n  /* Read the first integer value */\n  nMerge = fts3Getint(&z);\n\n  /* If the first integer value is followed by a ',',  read the second\n  ** integer value. */\n  if( z[0]==',' && z[1]!='\\0' ){\n    z++;\n    nMin = fts3Getint(&z);\n  }\n\n  if( z[0]!='\\0' || nMin<2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = SQLITE_OK;\n    if( !p->bHasStat ){\n      assert( p->bFts4==0 );\n      sqlite3Fts3CreateStatTable(&rc, p);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);\n    }\n    sqlite3Fts3SegmentsClose(p);\n  }\n  return rc;\n}\n\n/*\n** Process statements of the form:\n**\n**    INSERT INTO table(table) VALUES('automerge=X');\n**\n** where X is an integer.  X==0 means to turn automerge off.  X!=0 means\n** turn it on.  The setting is persistent.\n*/\nstatic int fts3DoAutoincrmerge(\n  Fts3Table *p,                   /* FTS3 table handle */\n  const char *zParam              /* Nul-terminated string containing boolean */\n){\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  p->nAutoincrmerge = fts3Getint(&zParam);\n  if( p->nAutoincrmerge==1 || p->nAutoincrmerge>FTS3_MERGE_COUNT ){\n    p->nAutoincrmerge = 8;\n  }\n  if( !p->bHasStat ){\n    assert( p->bFts4==0 );\n    sqlite3Fts3CreateStatTable(&rc, p);\n    if( rc ) return rc;\n  }\n  rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);\n  if( rc ) return rc;\n  sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);\n  sqlite3_bind_int(pStmt, 2, p->nAutoincrmerge);\n  sqlite3_step(pStmt);\n  rc = sqlite3_reset(pStmt);\n  return rc;\n}\n\n/*\n** Return a 64-bit checksum for the FTS index entry specified by the\n** arguments to this function.\n*/\nstatic u64 fts3ChecksumEntry(\n  const char *zTerm,              /* Pointer to buffer containing term */\n  int nTerm,                      /* Size of zTerm in bytes */\n  int iLangid,                    /* Language id for current row */\n  int iIndex,                     /* Index (0..Fts3Table.nIndex-1) */\n  i64 iDocid,                     /* Docid for current row. */\n  int iCol,                       /* Column number */\n  int iPos                        /* Position */\n){\n  int i;\n  u64 ret = (u64)iDocid;\n\n  ret += (ret<<3) + iLangid;\n  ret += (ret<<3) + iIndex;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];\n\n  return ret;\n}\n\n/*\n** Return a checksum of all entries in the FTS index that correspond to\n** language id iLangid. The checksum is calculated by XORing the checksums\n** of each individual entry (see fts3ChecksumEntry()) together.\n**\n** If successful, the checksum value is returned and *pRc set to SQLITE_OK.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The\n** return value is undefined in this case.\n*/\nstatic u64 fts3ChecksumIndex(\n  Fts3Table *p,                   /* FTS3 table handle */\n  int iLangid,                    /* Language id to return cksum for */\n  int iIndex,                     /* Index to cksum (0..p->nIndex-1) */\n  int *pRc                        /* OUT: Return code */\n){\n  Fts3SegFilter filter;\n  Fts3MultiSegReader csr;\n  int rc;\n  u64 cksum = 0;\n\n  assert( *pRc==SQLITE_OK );\n\n  memset(&filter, 0, sizeof(filter));\n  memset(&csr, 0, sizeof(csr));\n  filter.flags =  FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;\n  filter.flags |= FTS3_SEGMENT_SCAN;\n\n  rc = sqlite3Fts3SegReaderCursor(\n      p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);\n  }\n\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){\n      char *pCsr = csr.aDoclist;\n      char *pEnd = &pCsr[csr.nDoclist];\n\n      i64 iDocid = 0;\n      i64 iCol = 0;\n      i64 iPos = 0;\n\n      pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);\n      while( pCsr<pEnd ){\n        i64 iVal = 0;\n        pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n        if( pCsr<pEnd ){\n          if( iVal==0 || iVal==1 ){\n            iCol = 0;\n            iPos = 0;\n            if( iVal ){\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);\n            }else{\n              pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);\n              iDocid += iVal;\n            }\n          }else{\n            iPos += (iVal - 2);\n            cksum = cksum ^ fts3ChecksumEntry(\n                csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,\n                (int)iCol, (int)iPos\n            );\n          }\n        }\n      }\n    }\n  }\n  sqlite3Fts3SegReaderFinish(&csr);\n\n  *pRc = rc;\n  return cksum;\n}\n\n/*\n** Check if the contents of the FTS index match the current contents of the\n** content table. If no error occurs and the contents do match, set *pbOk\n** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk\n** to false before returning.\n**\n** If an error occurs (e.g. an OOM or IO error), return an SQLite error \n** code. The final value of *pbOk is undefined in this case.\n*/\nstatic int fts3IntegrityCheck(Fts3Table *p, int *pbOk){\n  int rc = SQLITE_OK;             /* Return code */\n  u64 cksum1 = 0;                 /* Checksum based on FTS index contents */\n  u64 cksum2 = 0;                 /* Checksum based on %_content contents */\n  sqlite3_stmt *pAllLangid = 0;   /* Statement to return all language-ids */\n\n  /* This block calculates the checksum according to the FTS index. */\n  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);\n    sqlite3_bind_int(pAllLangid, 2, p->nIndex);\n    while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){\n      int iLangid = sqlite3_column_int(pAllLangid, 0);\n      int i;\n      for(i=0; i<p->nIndex; i++){\n        cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);\n      }\n    }\n    rc2 = sqlite3_reset(pAllLangid);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* This block calculates the checksum according to the %_content table */\n  if( rc==SQLITE_OK ){\n    sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;\n    sqlite3_stmt *pStmt = 0;\n    char *zSql;\n   \n    zSql = sqlite3_mprintf(\"SELECT %s\" , p->zReadExprlist);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n      sqlite3_free(zSql);\n    }\n\n    while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      i64 iDocid = sqlite3_column_int64(pStmt, 0);\n      int iLang = langidFromSelect(p, pStmt);\n      int iCol;\n\n      for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){\n        if( p->abNotindexed[iCol]==0 ){\n          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);\n          int nText = sqlite3_column_bytes(pStmt, iCol+1);\n          sqlite3_tokenizer_cursor *pT = 0;\n\n          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);\n          while( rc==SQLITE_OK ){\n            char const *zToken;       /* Buffer containing token */\n            int nToken = 0;           /* Number of bytes in token */\n            int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n            int iPos = 0;             /* Position of token in zText */\n\n            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n            if( rc==SQLITE_OK ){\n              int i;\n              cksum2 = cksum2 ^ fts3ChecksumEntry(\n                  zToken, nToken, iLang, 0, iDocid, iCol, iPos\n              );\n              for(i=1; i<p->nIndex; i++){\n                if( p->aIndex[i].nPrefix<=nToken ){\n                  cksum2 = cksum2 ^ fts3ChecksumEntry(\n                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos\n                  );\n                }\n              }\n            }\n          }\n          if( pT ) pModule->xClose(pT);\n          if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        }\n      }\n    }\n\n    sqlite3_finalize(pStmt);\n  }\n\n  *pbOk = (cksum1==cksum2);\n  return rc;\n}\n\n/*\n** Run the integrity-check. If no error occurs and the current contents of\n** the FTS index are correct, return SQLITE_OK. Or, if the contents of the\n** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.\n**\n** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite \n** error code.\n**\n** The integrity-check works as follows. For each token and indexed token\n** prefix in the document set, a 64-bit checksum is calculated (by code\n** in fts3ChecksumEntry()) based on the following:\n**\n**     + The index number (0 for the main index, 1 for the first prefix\n**       index etc.),\n**     + The token (or token prefix) text itself, \n**     + The language-id of the row it appears in,\n**     + The docid of the row it appears in,\n**     + The column it appears in, and\n**     + The tokens position within that column.\n**\n** The checksums for all entries in the index are XORed together to create\n** a single checksum for the entire index.\n**\n** The integrity-check code calculates the same checksum in two ways:\n**\n**     1. By scanning the contents of the FTS index, and \n**     2. By scanning and tokenizing the content table.\n**\n** If the two checksums are identical, the integrity-check is deemed to have\n** passed.\n*/\nstatic int fts3DoIntegrityCheck(\n  Fts3Table *p                    /* FTS3 table handle */\n){\n  int rc;\n  int bOk = 0;\n  rc = fts3IntegrityCheck(p, &bOk);\n  if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;\n  return rc;\n}\n\n/*\n** Handle a 'special' INSERT of the form:\n**\n**   \"INSERT INTO tbl(tbl) VALUES(<expr>)\"\n**\n** Argument pVal contains the result of <expr>. Currently the only \n** meaningful value to insert is the text 'optimize'.\n*/\nstatic int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){\n  int rc;                         /* Return Code */\n  const char *zVal = (const char *)sqlite3_value_text(pVal);\n  int nVal = sqlite3_value_bytes(pVal);\n\n  if( !zVal ){\n    return SQLITE_NOMEM;\n  }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, \"optimize\", 8) ){\n    rc = fts3DoOptimize(p, 0);\n  }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, \"rebuild\", 7) ){\n    rc = fts3DoRebuild(p);\n  }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, \"integrity-check\", 15) ){\n    rc = fts3DoIntegrityCheck(p);\n  }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, \"merge=\", 6) ){\n    rc = fts3DoIncrmerge(p, &zVal[6]);\n  }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, \"automerge=\", 10) ){\n    rc = fts3DoAutoincrmerge(p, &zVal[10]);\n#ifdef SQLITE_TEST\n  }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, \"nodesize=\", 9) ){\n    p->nNodeSize = atoi(&zVal[9]);\n    rc = SQLITE_OK;\n  }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, \"maxpending=\", 9) ){\n    p->nMaxPendingData = atoi(&zVal[11]);\n    rc = SQLITE_OK;\n  }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, \"test-no-incr-doclist=\", 21) ){\n    p->bNoIncrDoclist = atoi(&zVal[21]);\n    rc = SQLITE_OK;\n#endif\n  }else{\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n#ifndef SQLITE_DISABLE_FTS4_DEFERRED\n/*\n** Delete all cached deferred doclists. Deferred doclists are cached\n** (allocated) by the sqlite3Fts3CacheDeferredDoclists() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pDef->pNext){\n    fts3PendingListDelete(pDef->pList);\n    pDef->pList = 0;\n  }\n}\n\n/*\n** Free all entries in the pCsr->pDeffered list. Entries are added to \n** this list using sqlite3Fts3DeferToken().\n*/\nSQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *pCsr){\n  Fts3DeferredToken *pDef;\n  Fts3DeferredToken *pNext;\n  for(pDef=pCsr->pDeferred; pDef; pDef=pNext){\n    pNext = pDef->pNext;\n    fts3PendingListDelete(pDef->pList);\n    sqlite3_free(pDef);\n  }\n  pCsr->pDeferred = 0;\n}\n\n/*\n** Generate deferred-doclists for all tokens in the pCsr->pDeferred list\n** based on the row that pCsr currently points to.\n**\n** A deferred-doclist is like any other doclist with position information\n** included, except that it only contains entries for a single row of the\n** table, not for all rows.\n*/\nSQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *pCsr){\n  int rc = SQLITE_OK;             /* Return code */\n  if( pCsr->pDeferred ){\n    int i;                        /* Used to iterate through table columns */\n    sqlite3_int64 iDocid;         /* Docid of the row pCsr points to */\n    Fts3DeferredToken *pDef;      /* Used to iterate through deferred tokens */\n  \n    Fts3Table *p = (Fts3Table *)pCsr->base.pVtab;\n    sqlite3_tokenizer *pT = p->pTokenizer;\n    sqlite3_tokenizer_module const *pModule = pT->pModule;\n   \n    assert( pCsr->isRequireSeek==0 );\n    iDocid = sqlite3_column_int64(pCsr->pStmt, 0);\n  \n    for(i=0; i<p->nColumn && rc==SQLITE_OK; i++){\n      if( p->abNotindexed[i]==0 ){\n        const char *zText = (const char *)sqlite3_column_text(pCsr->pStmt, i+1);\n        sqlite3_tokenizer_cursor *pTC = 0;\n\n        rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);\n        while( rc==SQLITE_OK ){\n          char const *zToken;       /* Buffer containing token */\n          int nToken = 0;           /* Number of bytes in token */\n          int iDum1 = 0, iDum2 = 0; /* Dummy variables */\n          int iPos = 0;             /* Position of token in zText */\n\n          rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);\n          for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n            Fts3PhraseToken *pPT = pDef->pToken;\n            if( (pDef->iCol>=p->nColumn || pDef->iCol==i)\n                && (pPT->bFirst==0 || iPos==0)\n                && (pPT->n==nToken || (pPT->isPrefix && pPT->n<nToken))\n                && (0==memcmp(zToken, pPT->z, pPT->n))\n              ){\n              fts3PendingListAppend(&pDef->pList, iDocid, i, iPos, &rc);\n            }\n          }\n        }\n        if( pTC ) pModule->xClose(pTC);\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n      }\n    }\n\n    for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){\n      if( pDef->pList ){\n        rc = fts3PendingListAppendVarint(&pDef->pList, 0);\n      }\n    }\n  }\n\n  return rc;\n}\n\nSQLITE_PRIVATE int sqlite3Fts3DeferredTokenList(\n  Fts3DeferredToken *p, \n  char **ppData, \n  int *pnData\n){\n  char *pRet;\n  int nSkip;\n  sqlite3_int64 dummy;\n\n  *ppData = 0;\n  *pnData = 0;\n\n  if( p->pList==0 ){\n    return SQLITE_OK;\n  }\n\n  pRet = (char *)sqlite3_malloc(p->pList->nData);\n  if( !pRet ) return SQLITE_NOMEM;\n\n  nSkip = sqlite3Fts3GetVarint(p->pList->aData, &dummy);\n  *pnData = p->pList->nData - nSkip;\n  *ppData = pRet;\n  \n  memcpy(pRet, &p->pList->aData[nSkip], *pnData);\n  return SQLITE_OK;\n}\n\n/*\n** Add an entry for token pToken to the pCsr->pDeferred list.\n*/\nSQLITE_PRIVATE int sqlite3Fts3DeferToken(\n  Fts3Cursor *pCsr,               /* Fts3 table cursor */\n  Fts3PhraseToken *pToken,        /* Token to defer */\n  int iCol                        /* Column that token must appear in (or -1) */\n){\n  Fts3DeferredToken *pDeferred;\n  pDeferred = sqlite3_malloc(sizeof(*pDeferred));\n  if( !pDeferred ){\n    return SQLITE_NOMEM;\n  }\n  memset(pDeferred, 0, sizeof(*pDeferred));\n  pDeferred->pToken = pToken;\n  pDeferred->pNext = pCsr->pDeferred; \n  pDeferred->iCol = iCol;\n  pCsr->pDeferred = pDeferred;\n\n  assert( pToken->pDeferred==0 );\n  pToken->pDeferred = pDeferred;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** SQLite value pRowid contains the rowid of a row that may or may not be\n** present in the FTS3 table. If it is, delete it and adjust the contents\n** of subsiduary data structures accordingly.\n*/\nstatic int fts3DeleteByRowid(\n  Fts3Table *p, \n  sqlite3_value *pRowid, \n  int *pnChng,                    /* IN/OUT: Decrement if row is deleted */\n  u32 *aSzDel\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int bFound = 0;                 /* True if *pRowid really is in the table */\n\n  fts3DeleteTerms(&rc, p, pRowid, aSzDel, &bFound);\n  if( bFound && rc==SQLITE_OK ){\n    int isEmpty = 0;              /* Deleting *pRowid leaves the table empty */\n    rc = fts3IsEmpty(p, pRowid, &isEmpty);\n    if( rc==SQLITE_OK ){\n      if( isEmpty ){\n        /* Deleting this row means the whole table is empty. In this case\n        ** delete the contents of all three tables and throw away any\n        ** data in the pendingTerms hash table.  */\n        rc = fts3DeleteAll(p, 1);\n        *pnChng = 0;\n        memset(aSzDel, 0, sizeof(u32) * (p->nColumn+1) * 2);\n      }else{\n        *pnChng = *pnChng - 1;\n        if( p->zContentTbl==0 ){\n          fts3SqlExec(&rc, p, SQL_DELETE_CONTENT, &pRowid);\n        }\n        if( p->bHasDocsize ){\n          fts3SqlExec(&rc, p, SQL_DELETE_DOCSIZE, &pRowid);\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function does the work for the xUpdate method of FTS3 virtual\n** tables. The schema of the virtual table being:\n**\n**     CREATE TABLE <table name>( \n**       <user columns>,\n**       <table name> HIDDEN, \n**       docid HIDDEN, \n**       <langid> HIDDEN\n**     );\n**\n** \n*/\nSQLITE_PRIVATE int sqlite3Fts3UpdateMethod(\n  sqlite3_vtab *pVtab,            /* FTS3 vtab object */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts3Table *p = (Fts3Table *)pVtab;\n  int rc = SQLITE_OK;             /* Return Code */\n  int isRemove = 0;               /* True for an UPDATE or DELETE */\n  u32 *aSzIns = 0;                /* Sizes of inserted documents */\n  u32 *aSzDel = 0;                /* Sizes of deleted documents */\n  int nChng = 0;                  /* Net change in number of documents */\n  int bInsertDone = 0;\n\n  /* At this point it must be known if the %_stat table exists or not.\n  ** So bHasStat may not be 2.  */\n  assert( p->bHasStat==0 || p->bHasStat==1 );\n\n  assert( p->pSegments==0 );\n  assert( \n      nArg==1                     /* DELETE operations */\n   || nArg==(2 + p->nColumn + 3)  /* INSERT or UPDATE operations */\n  );\n\n  /* Check for a \"special\" INSERT operation. One of the form:\n  **\n  **   INSERT INTO xyz(xyz) VALUES('command');\n  */\n  if( nArg>1 \n   && sqlite3_value_type(apVal[0])==SQLITE_NULL \n   && sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL \n  ){\n    rc = fts3SpecialInsert(p, apVal[p->nColumn+2]);\n    goto update_out;\n  }\n\n  if( nArg>1 && sqlite3_value_int(apVal[2 + p->nColumn + 2])<0 ){\n    rc = SQLITE_CONSTRAINT;\n    goto update_out;\n  }\n\n  /* Allocate space to hold the change in document sizes */\n  aSzDel = sqlite3_malloc( sizeof(aSzDel[0])*(p->nColumn+1)*2 );\n  if( aSzDel==0 ){\n    rc = SQLITE_NOMEM;\n    goto update_out;\n  }\n  aSzIns = &aSzDel[p->nColumn+1];\n  memset(aSzDel, 0, sizeof(aSzDel[0])*(p->nColumn+1)*2);\n\n  rc = fts3Writelock(p);\n  if( rc!=SQLITE_OK ) goto update_out;\n\n  /* If this is an INSERT operation, or an UPDATE that modifies the rowid\n  ** value, then this operation requires constraint handling.\n  **\n  ** If the on-conflict mode is REPLACE, this means that the existing row\n  ** should be deleted from the database before inserting the new row. Or,\n  ** if the on-conflict mode is other than REPLACE, then this method must\n  ** detect the conflict and return SQLITE_CONSTRAINT before beginning to\n  ** modify the database file.\n  */\n  if( nArg>1 && p->zContentTbl==0 ){\n    /* Find the value object that holds the new rowid value. */\n    sqlite3_value *pNewRowid = apVal[3+p->nColumn];\n    if( sqlite3_value_type(pNewRowid)==SQLITE_NULL ){\n      pNewRowid = apVal[1];\n    }\n\n    if( sqlite3_value_type(pNewRowid)!=SQLITE_NULL && ( \n        sqlite3_value_type(apVal[0])==SQLITE_NULL\n     || sqlite3_value_int64(apVal[0])!=sqlite3_value_int64(pNewRowid)\n    )){\n      /* The new rowid is not NULL (in this case the rowid will be\n      ** automatically assigned and there is no chance of a conflict), and \n      ** the statement is either an INSERT or an UPDATE that modifies the\n      ** rowid column. So if the conflict mode is REPLACE, then delete any\n      ** existing row with rowid=pNewRowid. \n      **\n      ** Or, if the conflict mode is not REPLACE, insert the new record into \n      ** the %_content table. If we hit the duplicate rowid constraint (or any\n      ** other error) while doing so, return immediately.\n      **\n      ** This branch may also run if pNewRowid contains a value that cannot\n      ** be losslessly converted to an integer. In this case, the eventual \n      ** call to fts3InsertData() (either just below or further on in this\n      ** function) will return SQLITE_MISMATCH. If fts3DeleteByRowid is \n      ** invoked, it will delete zero rows (since no row will have\n      ** docid=$pNewRowid if $pNewRowid is not an integer value).\n      */\n      if( sqlite3_vtab_on_conflict(p->db)==SQLITE_REPLACE ){\n        rc = fts3DeleteByRowid(p, pNewRowid, &nChng, aSzDel);\n      }else{\n        rc = fts3InsertData(p, apVal, pRowid);\n        bInsertDone = 1;\n      }\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    goto update_out;\n  }\n\n  /* If this is a DELETE or UPDATE operation, remove the old record. */\n  if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){\n    assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER );\n    rc = fts3DeleteByRowid(p, apVal[0], &nChng, aSzDel);\n    isRemove = 1;\n  }\n  \n  /* If this is an INSERT or UPDATE operation, insert the new record. */\n  if( nArg>1 && rc==SQLITE_OK ){\n    int iLangid = sqlite3_value_int(apVal[2 + p->nColumn + 2]);\n    if( bInsertDone==0 ){\n      rc = fts3InsertData(p, apVal, pRowid);\n      if( rc==SQLITE_CONSTRAINT && p->zContentTbl==0 ){\n        rc = FTS_CORRUPT_VTAB;\n      }\n    }\n    if( rc==SQLITE_OK && (!isRemove || *pRowid!=p->iPrevDocid ) ){\n      rc = fts3PendingTermsDocid(p, 0, iLangid, *pRowid);\n    }\n    if( rc==SQLITE_OK ){\n      assert( p->iPrevDocid==*pRowid );\n      rc = fts3InsertTerms(p, iLangid, apVal, aSzIns);\n    }\n    if( p->bHasDocsize ){\n      fts3InsertDocsize(&rc, p, aSzIns);\n    }\n    nChng++;\n  }\n\n  if( p->bFts4 ){\n    fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);\n  }\n\n update_out:\n  sqlite3_free(aSzDel);\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n/* \n** Flush any data in the pending-terms hash table to disk. If successful,\n** merge all segments in the database (including the new segment, if \n** there was any data to flush) into a single segment. \n*/\nSQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){\n  int rc;\n  rc = sqlite3_exec(p->db, \"SAVEPOINT fts3\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = fts3DoOptimize(p, 1);\n    if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n      int rc2 = sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n      if( rc2!=SQLITE_OK ) rc = rc2;\n    }else{\n      sqlite3_exec(p->db, \"ROLLBACK TO fts3\", 0, 0, 0);\n      sqlite3_exec(p->db, \"RELEASE fts3\", 0, 0, 0);\n    }\n  }\n  sqlite3Fts3SegmentsClose(p);\n  return rc;\n}\n\n#endif\n\n/************** End of fts3_write.c ******************************************/\n/************** Begin file fts3_snippet.c ************************************/\n/*\n** 2009 Oct 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n/*\n** Characters that may appear in the second argument to matchinfo().\n*/\n#define FTS3_MATCHINFO_NPHRASE   'p'        /* 1 value */\n#define FTS3_MATCHINFO_NCOL      'c'        /* 1 value */\n#define FTS3_MATCHINFO_NDOC      'n'        /* 1 value */\n#define FTS3_MATCHINFO_AVGLENGTH 'a'        /* nCol values */\n#define FTS3_MATCHINFO_LENGTH    'l'        /* nCol values */\n#define FTS3_MATCHINFO_LCS       's'        /* nCol values */\n#define FTS3_MATCHINFO_HITS      'x'        /* 3*nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS     'y'        /* nCol*nPhrase values */\n#define FTS3_MATCHINFO_LHITS_BM  'b'        /* nCol*nPhrase values */\n\n/*\n** The default value for the second argument to matchinfo(). \n*/\n#define FTS3_MATCHINFO_DEFAULT   \"pcx\"\n\n\n/*\n** Used as an fts3ExprIterate() context when loading phrase doclists to\n** Fts3Expr.aDoclist[]/nDoclist.\n*/\ntypedef struct LoadDoclistCtx LoadDoclistCtx;\nstruct LoadDoclistCtx {\n  Fts3Cursor *pCsr;               /* FTS3 Cursor */\n  int nPhrase;                    /* Number of phrases seen so far */\n  int nToken;                     /* Number of tokens seen so far */\n};\n\n/*\n** The following types are used as part of the implementation of the \n** fts3BestSnippet() routine.\n*/\ntypedef struct SnippetIter SnippetIter;\ntypedef struct SnippetPhrase SnippetPhrase;\ntypedef struct SnippetFragment SnippetFragment;\n\nstruct SnippetIter {\n  Fts3Cursor *pCsr;               /* Cursor snippet is being generated from */\n  int iCol;                       /* Extract snippet from this column */\n  int nSnippet;                   /* Requested snippet length (in tokens) */\n  int nPhrase;                    /* Number of phrases in query */\n  SnippetPhrase *aPhrase;         /* Array of size nPhrase */\n  int iCurrent;                   /* First token of current snippet */\n};\n\nstruct SnippetPhrase {\n  int nToken;                     /* Number of tokens in phrase */\n  char *pList;                    /* Pointer to start of phrase position list */\n  int iHead;                      /* Next value in position list */\n  char *pHead;                    /* Position list data following iHead */\n  int iTail;                      /* Next value in trailing position list */\n  char *pTail;                    /* Position list data following iTail */\n};\n\nstruct SnippetFragment {\n  int iCol;                       /* Column snippet is extracted from */\n  int iPos;                       /* Index of first token in snippet */\n  u64 covered;                    /* Mask of query phrases covered */\n  u64 hlmask;                     /* Mask of snippet terms to highlight */\n};\n\n/*\n** This type is used as an fts3ExprIterate() context object while \n** accumulating the data returned by the matchinfo() function.\n*/\ntypedef struct MatchInfo MatchInfo;\nstruct MatchInfo {\n  Fts3Cursor *pCursor;            /* FTS3 Cursor */\n  int nCol;                       /* Number of columns in table */\n  int nPhrase;                    /* Number of matchable phrases in query */\n  sqlite3_int64 nDoc;             /* Number of docs in database */\n  char flag;\n  u32 *aMatchinfo;                /* Pre-allocated buffer */\n};\n\n/*\n** An instance of this structure is used to manage a pair of buffers, each\n** (nElem * sizeof(u32)) bytes in size. See the MatchinfoBuffer code below\n** for details.\n*/\nstruct MatchinfoBuffer {\n  u8 aRef[3];\n  int nElem;\n  int bGlobal;                    /* Set if global data is loaded */\n  char *zMatchinfo;\n  u32 aMatchinfo[1];\n};\n\n\n/*\n** The snippet() and offsets() functions both return text values. An instance\n** of the following structure is used to accumulate those values while the\n** functions are running. See fts3StringAppend() for details.\n*/\ntypedef struct StrBuffer StrBuffer;\nstruct StrBuffer {\n  char *z;                        /* Pointer to buffer containing string */\n  int n;                          /* Length of z in bytes (excl. nul-term) */\n  int nAlloc;                     /* Allocated size of buffer z in bytes */\n};\n\n\n/*************************************************************************\n** Start of MatchinfoBuffer code.\n*/\n\n/*\n** Allocate a two-slot MatchinfoBuffer object.\n*/\nstatic MatchinfoBuffer *fts3MIBufferNew(int nElem, const char *zMatchinfo){\n  MatchinfoBuffer *pRet;\n  int nByte = sizeof(u32) * (2*nElem + 1) + sizeof(MatchinfoBuffer);\n  int nStr = (int)strlen(zMatchinfo);\n\n  pRet = sqlite3_malloc(nByte + nStr+1);\n  if( pRet ){\n    memset(pRet, 0, nByte);\n    pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet;\n    pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] + sizeof(u32)*(nElem+1);\n    pRet->nElem = nElem;\n    pRet->zMatchinfo = ((char*)pRet) + nByte;\n    memcpy(pRet->zMatchinfo, zMatchinfo, nStr+1);\n    pRet->aRef[0] = 1;\n  }\n\n  return pRet;\n}\n\nstatic void fts3MIBufferFree(void *p){\n  MatchinfoBuffer *pBuf = (MatchinfoBuffer*)((u8*)p - ((u32*)p)[-1]);\n\n  assert( (u32*)p==&pBuf->aMatchinfo[1] \n       || (u32*)p==&pBuf->aMatchinfo[pBuf->nElem+2] \n  );\n  if( (u32*)p==&pBuf->aMatchinfo[1] ){\n    pBuf->aRef[1] = 0;\n  }else{\n    pBuf->aRef[2] = 0;\n  }\n\n  if( pBuf->aRef[0]==0 && pBuf->aRef[1]==0 && pBuf->aRef[2]==0 ){\n    sqlite3_free(pBuf);\n  }\n}\n\nstatic void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){\n  void (*xRet)(void*) = 0;\n  u32 *aOut = 0;\n\n  if( p->aRef[1]==0 ){\n    p->aRef[1] = 1;\n    aOut = &p->aMatchinfo[1];\n    xRet = fts3MIBufferFree;\n  }\n  else if( p->aRef[2]==0 ){\n    p->aRef[2] = 1;\n    aOut = &p->aMatchinfo[p->nElem+2];\n    xRet = fts3MIBufferFree;\n  }else{\n    aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32));\n    if( aOut ){\n      xRet = sqlite3_free;\n      if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));\n    }\n  }\n\n  *paOut = aOut;\n  return xRet;\n}\n\nstatic void fts3MIBufferSetGlobal(MatchinfoBuffer *p){\n  p->bGlobal = 1;\n  memcpy(&p->aMatchinfo[2+p->nElem], &p->aMatchinfo[1], p->nElem*sizeof(u32));\n}\n\n/*\n** Free a MatchinfoBuffer object allocated using fts3MIBufferNew()\n*/\nSQLITE_PRIVATE void sqlite3Fts3MIBufferFree(MatchinfoBuffer *p){\n  if( p ){\n    assert( p->aRef[0]==1 );\n    p->aRef[0] = 0;\n    if( p->aRef[0]==0 && p->aRef[1]==0 && p->aRef[2]==0 ){\n      sqlite3_free(p);\n    }\n  }\n}\n\n/* \n** End of MatchinfoBuffer code.\n*************************************************************************/\n\n\n/*\n** This function is used to help iterate through a position-list. A position\n** list is a list of unique integers, sorted from smallest to largest. Each\n** element of the list is represented by an FTS3 varint that takes the value\n** of the difference between the current element and the previous one plus\n** two. For example, to store the position-list:\n**\n**     4 9 113\n**\n** the three varints:\n**\n**     6 7 106\n**\n** are encoded.\n**\n** When this function is called, *pp points to the start of an element of\n** the list. *piPos contains the value of the previous entry in the list.\n** After it returns, *piPos contains the value of the next element of the\n** list and *pp is advanced to the following varint.\n*/\nstatic void fts3GetDeltaPosition(char **pp, int *piPos){\n  int iVal;\n  *pp += fts3GetVarint32(*pp, &iVal);\n  *piPos += (iVal-2);\n}\n\n/*\n** Helper function for fts3ExprIterate() (see below).\n*/\nstatic int fts3ExprIterate2(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int *piPhrase,                  /* Pointer to phrase counter */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int rc;                         /* Return code */\n  int eType = pExpr->eType;     /* Type of expression node pExpr */\n\n  if( eType!=FTSQUERY_PHRASE ){\n    assert( pExpr->pLeft && pExpr->pRight );\n    rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);\n    if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){\n      rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);\n    }\n  }else{\n    rc = x(pExpr, *piPhrase, pCtx);\n    (*piPhrase)++;\n  }\n  return rc;\n}\n\n/*\n** Iterate through all phrase nodes in an FTS3 query, except those that\n** are part of a sub-tree that is the right-hand-side of a NOT operator.\n** For each phrase node found, the supplied callback function is invoked.\n**\n** If the callback function returns anything other than SQLITE_OK, \n** the iteration is abandoned and the error code returned immediately.\n** Otherwise, SQLITE_OK is returned after a callback has been made for\n** all eligible phrase nodes.\n*/\nstatic int fts3ExprIterate(\n  Fts3Expr *pExpr,                /* Expression to iterate phrases of */\n  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */\n  void *pCtx                      /* Second argument to pass to callback */\n){\n  int iPhrase = 0;                /* Variable used as the phrase counter */\n  return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);\n}\n\n\n/*\n** This is an fts3ExprIterate() callback used while loading the doclists\n** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also\n** fts3ExprLoadDoclists().\n*/\nstatic int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  int rc = SQLITE_OK;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;\n\n  UNUSED_PARAMETER(iPhrase);\n\n  p->nPhrase++;\n  p->nToken += pPhrase->nToken;\n\n  return rc;\n}\n\n/*\n** Load the doclists for each phrase in the query associated with FTS3 cursor\n** pCsr. \n**\n** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable \n** phrases in the expression (all phrases except those directly or \n** indirectly descended from the right-hand-side of a NOT operator). If \n** pnToken is not NULL, then it is set to the number of tokens in all\n** matchable phrases of the expression.\n*/\nstatic int fts3ExprLoadDoclists(\n  Fts3Cursor *pCsr,               /* Fts3 cursor for current query */\n  int *pnPhrase,                  /* OUT: Number of phrases in query */\n  int *pnToken                    /* OUT: Number of tokens in query */\n){\n  int rc;                         /* Return Code */\n  LoadDoclistCtx sCtx = {0,0,0};  /* Context for fts3ExprIterate() */\n  sCtx.pCsr = pCsr;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);\n  if( pnPhrase ) *pnPhrase = sCtx.nPhrase;\n  if( pnToken ) *pnToken = sCtx.nToken;\n  return rc;\n}\n\nstatic int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  (*(int *)ctx)++;\n  pExpr->iPhrase = iPhrase;\n  return SQLITE_OK;\n}\nstatic int fts3ExprPhraseCount(Fts3Expr *pExpr){\n  int nPhrase = 0;\n  (void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);\n  return nPhrase;\n}\n\n/*\n** Advance the position list iterator specified by the first two \n** arguments so that it points to the first element with a value greater\n** than or equal to parameter iNext.\n*/\nstatic void fts3SnippetAdvance(char **ppIter, int *piIter, int iNext){\n  char *pIter = *ppIter;\n  if( pIter ){\n    int iIter = *piIter;\n\n    while( iIter<iNext ){\n      if( 0==(*pIter & 0xFE) ){\n        iIter = -1;\n        pIter = 0;\n        break;\n      }\n      fts3GetDeltaPosition(&pIter, &iIter);\n    }\n\n    *piIter = iIter;\n    *ppIter = pIter;\n  }\n}\n\n/*\n** Advance the snippet iterator to the next candidate snippet.\n*/\nstatic int fts3SnippetNextCandidate(SnippetIter *pIter){\n  int i;                          /* Loop counter */\n\n  if( pIter->iCurrent<0 ){\n    /* The SnippetIter object has just been initialized. The first snippet\n    ** candidate always starts at offset 0 (even if this candidate has a\n    ** score of 0.0).\n    */\n    pIter->iCurrent = 0;\n\n    /* Advance the 'head' iterator of each phrase to the first offset that\n    ** is greater than or equal to (iNext+nSnippet).\n    */\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, pIter->nSnippet);\n    }\n  }else{\n    int iStart;\n    int iEnd = 0x7FFFFFFF;\n\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      if( pPhrase->pHead && pPhrase->iHead<iEnd ){\n        iEnd = pPhrase->iHead;\n      }\n    }\n    if( iEnd==0x7FFFFFFF ){\n      return 1;\n    }\n\n    pIter->iCurrent = iStart = iEnd - pIter->nSnippet + 1;\n    for(i=0; i<pIter->nPhrase; i++){\n      SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n      fts3SnippetAdvance(&pPhrase->pHead, &pPhrase->iHead, iEnd+1);\n      fts3SnippetAdvance(&pPhrase->pTail, &pPhrase->iTail, iStart);\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Retrieve information about the current candidate snippet of snippet \n** iterator pIter.\n*/\nstatic void fts3SnippetDetails(\n  SnippetIter *pIter,             /* Snippet iterator */\n  u64 mCovered,                   /* Bitmask of phrases already covered */\n  int *piToken,                   /* OUT: First token of proposed snippet */\n  int *piScore,                   /* OUT: \"Score\" for this snippet */\n  u64 *pmCover,                   /* OUT: Bitmask of phrases covered */\n  u64 *pmHighlight                /* OUT: Bitmask of terms to highlight */\n){\n  int iStart = pIter->iCurrent;   /* First token of snippet */\n  int iScore = 0;                 /* Score of this snippet */\n  int i;                          /* Loop counter */\n  u64 mCover = 0;                 /* Mask of phrases covered by this snippet */\n  u64 mHighlight = 0;             /* Mask of tokens to highlight in snippet */\n\n  for(i=0; i<pIter->nPhrase; i++){\n    SnippetPhrase *pPhrase = &pIter->aPhrase[i];\n    if( pPhrase->pTail ){\n      char *pCsr = pPhrase->pTail;\n      int iCsr = pPhrase->iTail;\n\n      while( iCsr<(iStart+pIter->nSnippet) ){\n        int j;\n        u64 mPhrase = (u64)1 << i;\n        u64 mPos = (u64)1 << (iCsr - iStart);\n        assert( iCsr>=iStart );\n        if( (mCover|mCovered)&mPhrase ){\n          iScore++;\n        }else{\n          iScore += 1000;\n        }\n        mCover |= mPhrase;\n\n        for(j=0; j<pPhrase->nToken; j++){\n          mHighlight |= (mPos>>j);\n        }\n\n        if( 0==(*pCsr & 0x0FE) ) break;\n        fts3GetDeltaPosition(&pCsr, &iCsr);\n      }\n    }\n  }\n\n  /* Set the output variables before returning. */\n  *piToken = iStart;\n  *piScore = iScore;\n  *pmCover = mCover;\n  *pmHighlight = mHighlight;\n}\n\n/*\n** This function is an fts3ExprIterate() callback used by fts3BestSnippet().\n** Each invocation populates an element of the SnippetIter.aPhrase[] array.\n*/\nstatic int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  SnippetIter *p = (SnippetIter *)ctx;\n  SnippetPhrase *pPhrase = &p->aPhrase[iPhrase];\n  char *pCsr;\n  int rc;\n\n  pPhrase->nToken = pExpr->pPhrase->nToken;\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr);\n  assert( rc==SQLITE_OK || pCsr==0 );\n  if( pCsr ){\n    int iFirst = 0;\n    pPhrase->pList = pCsr;\n    fts3GetDeltaPosition(&pCsr, &iFirst);\n    assert( iFirst>=0 );\n    pPhrase->pHead = pCsr;\n    pPhrase->pTail = pCsr;\n    pPhrase->iHead = iFirst;\n    pPhrase->iTail = iFirst;\n  }else{\n    assert( rc!=SQLITE_OK || (\n       pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0 \n    ));\n  }\n\n  return rc;\n}\n\n/*\n** Select the fragment of text consisting of nFragment contiguous tokens \n** from column iCol that represent the \"best\" snippet. The best snippet\n** is the snippet with the highest score, where scores are calculated\n** by adding:\n**\n**   (a) +1 point for each occurrence of a matchable phrase in the snippet.\n**\n**   (b) +1000 points for the first occurrence of each matchable phrase in \n**       the snippet for which the corresponding mCovered bit is not set.\n**\n** The selected snippet parameters are stored in structure *pFragment before\n** returning. The score of the selected snippet is stored in *piScore\n** before returning.\n*/\nstatic int fts3BestSnippet(\n  int nSnippet,                   /* Desired snippet length */\n  Fts3Cursor *pCsr,               /* Cursor to create snippet for */\n  int iCol,                       /* Index of column to create snippet from */\n  u64 mCovered,                   /* Mask of phrases already covered */\n  u64 *pmSeen,                    /* IN/OUT: Mask of phrases seen */\n  SnippetFragment *pFragment,     /* OUT: Best snippet found */\n  int *piScore                    /* OUT: Score of snippet pFragment */\n){\n  int rc;                         /* Return Code */\n  int nList;                      /* Number of phrases in expression */\n  SnippetIter sIter;              /* Iterates through snippet candidates */\n  int nByte;                      /* Number of bytes of space to allocate */\n  int iBestScore = -1;            /* Best snippet score found so far */\n  int i;                          /* Loop counter */\n\n  memset(&sIter, 0, sizeof(sIter));\n\n  /* Iterate through the phrases in the expression to count them. The same\n  ** callback makes sure the doclists are loaded for each phrase.\n  */\n  rc = fts3ExprLoadDoclists(pCsr, &nList, 0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Now that it is known how many phrases there are, allocate and zero\n  ** the required space using malloc().\n  */\n  nByte = sizeof(SnippetPhrase) * nList;\n  sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);\n  if( !sIter.aPhrase ){\n    return SQLITE_NOMEM;\n  }\n  memset(sIter.aPhrase, 0, nByte);\n\n  /* Initialize the contents of the SnippetIter object. Then iterate through\n  ** the set of phrases in the expression to populate the aPhrase[] array.\n  */\n  sIter.pCsr = pCsr;\n  sIter.iCol = iCol;\n  sIter.nSnippet = nSnippet;\n  sIter.nPhrase = nList;\n  sIter.iCurrent = -1;\n  rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);\n  if( rc==SQLITE_OK ){\n\n    /* Set the *pmSeen output variable. */\n    for(i=0; i<nList; i++){\n      if( sIter.aPhrase[i].pHead ){\n        *pmSeen |= (u64)1 << i;\n      }\n    }\n\n    /* Loop through all candidate snippets. Store the best snippet in \n     ** *pFragment. Store its associated 'score' in iBestScore.\n     */\n    pFragment->iCol = iCol;\n    while( !fts3SnippetNextCandidate(&sIter) ){\n      int iPos;\n      int iScore;\n      u64 mCover;\n      u64 mHighlite;\n      fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover,&mHighlite);\n      assert( iScore>=0 );\n      if( iScore>iBestScore ){\n        pFragment->iPos = iPos;\n        pFragment->hlmask = mHighlite;\n        pFragment->covered = mCover;\n        iBestScore = iScore;\n      }\n    }\n\n    *piScore = iBestScore;\n  }\n  sqlite3_free(sIter.aPhrase);\n  return rc;\n}\n\n\n/*\n** Append a string to the string-buffer passed as the first argument.\n**\n** If nAppend is negative, then the length of the string zAppend is\n** determined using strlen().\n*/\nstatic int fts3StringAppend(\n  StrBuffer *pStr,                /* Buffer to append to */\n  const char *zAppend,            /* Pointer to data to append to buffer */\n  int nAppend                     /* Size of zAppend in bytes (or -1) */\n){\n  if( nAppend<0 ){\n    nAppend = (int)strlen(zAppend);\n  }\n\n  /* If there is insufficient space allocated at StrBuffer.z, use realloc()\n  ** to grow the buffer until so that it is big enough to accomadate the\n  ** appended data.\n  */\n  if( pStr->n+nAppend+1>=pStr->nAlloc ){\n    int nAlloc = pStr->nAlloc+nAppend+100;\n    char *zNew = sqlite3_realloc(pStr->z, nAlloc);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pStr->z = zNew;\n    pStr->nAlloc = nAlloc;\n  }\n  assert( pStr->z!=0 && (pStr->nAlloc >= pStr->n+nAppend+1) );\n\n  /* Append the data to the string buffer. */\n  memcpy(&pStr->z[pStr->n], zAppend, nAppend);\n  pStr->n += nAppend;\n  pStr->z[pStr->n] = '\\0';\n\n  return SQLITE_OK;\n}\n\n/*\n** The fts3BestSnippet() function often selects snippets that end with a\n** query term. That is, the final term of the snippet is always a term\n** that requires highlighting. For example, if 'X' is a highlighted term\n** and '.' is a non-highlighted term, BestSnippet() may select:\n**\n**     ........X.....X\n**\n** This function \"shifts\" the beginning of the snippet forward in the \n** document so that there are approximately the same number of \n** non-highlighted terms to the right of the final highlighted term as there\n** are to the left of the first highlighted term. For example, to this:\n**\n**     ....X.....X....\n**\n** This is done as part of extracting the snippet text, not when selecting\n** the snippet. Snippet selection is done based on doclists only, so there\n** is no way for fts3BestSnippet() to know whether or not the document \n** actually contains terms that follow the final highlighted term. \n*/\nstatic int fts3SnippetShift(\n  Fts3Table *pTab,                /* FTS3 table snippet comes from */\n  int iLangid,                    /* Language id to use in tokenizing */\n  int nSnippet,                   /* Number of tokens desired for snippet */\n  const char *zDoc,               /* Document text to extract snippet from */\n  int nDoc,                       /* Size of buffer zDoc in bytes */\n  int *piPos,                     /* IN/OUT: First token of snippet */\n  u64 *pHlmask                    /* IN/OUT: Mask of tokens to highlight */\n){\n  u64 hlmask = *pHlmask;          /* Local copy of initial highlight-mask */\n\n  if( hlmask ){\n    int nLeft;                    /* Tokens to the left of first highlight */\n    int nRight;                   /* Tokens to the right of last highlight */\n    int nDesired;                 /* Ideal number of tokens to shift forward */\n\n    for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);\n    for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);\n    nDesired = (nLeft-nRight)/2;\n\n    /* Ideally, the start of the snippet should be pushed forward in the\n    ** document nDesired tokens. This block checks if there are actually\n    ** nDesired tokens to the right of the snippet. If so, *piPos and\n    ** *pHlMask are updated to shift the snippet nDesired tokens to the\n    ** right. Otherwise, the snippet is shifted by the number of tokens\n    ** available.\n    */\n    if( nDesired>0 ){\n      int nShift;                 /* Number of tokens to shift snippet by */\n      int iCurrent = 0;           /* Token counter */\n      int rc;                     /* Return Code */\n      sqlite3_tokenizer_module *pMod;\n      sqlite3_tokenizer_cursor *pC;\n      pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n\n      /* Open a cursor on zDoc/nDoc. Check if there are (nSnippet+nDesired)\n      ** or more tokens in zDoc/nDoc.\n      */\n      rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){\n        const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;\n        rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);\n      }\n      pMod->xClose(pC);\n      if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }\n\n      nShift = (rc==SQLITE_DONE)+iCurrent-nSnippet;\n      assert( nShift<=nDesired );\n      if( nShift>0 ){\n        *piPos += nShift;\n        *pHlmask = hlmask >> nShift;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Extract the snippet text for fragment pFragment from cursor pCsr and\n** append it to string buffer pOut.\n*/\nstatic int fts3SnippetText(\n  Fts3Cursor *pCsr,               /* FTS3 Cursor */\n  SnippetFragment *pFragment,     /* Snippet to extract */\n  int iFragment,                  /* Fragment number */\n  int isLast,                     /* True for final fragment in snippet */\n  int nSnippet,                   /* Number of tokens in extracted snippet */\n  const char *zOpen,              /* String inserted before highlighted term */\n  const char *zClose,             /* String inserted after highlighted term */\n  const char *zEllipsis,          /* String inserted between snippets */\n  StrBuffer *pOut                 /* Write output here */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc;                         /* Return code */\n  const char *zDoc;               /* Document text to extract snippet from */\n  int nDoc;                       /* Size of zDoc in bytes */\n  int iCurrent = 0;               /* Current token number of document */\n  int iEnd = 0;                   /* Byte offset of end of current token */\n  int isShiftDone = 0;            /* True after snippet is shifted */\n  int iPos = pFragment->iPos;     /* First token of snippet */\n  u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */\n  int iCol = pFragment->iCol+1;   /* Query column to extract text from */\n  sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */\n  sqlite3_tokenizer_cursor *pC;   /* Tokenizer cursor open on zDoc/nDoc */\n  \n  zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);\n  if( zDoc==0 ){\n    if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){\n      return SQLITE_NOMEM;\n    }\n    return SQLITE_OK;\n  }\n  nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol);\n\n  /* Open a token cursor on the document. */\n  pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;\n  rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid, zDoc,nDoc,&pC);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  while( rc==SQLITE_OK ){\n    const char *ZDUMMY;           /* Dummy argument used with tokenizer */\n    int DUMMY1 = -1;              /* Dummy argument used with tokenizer */\n    int iBegin = 0;               /* Offset in zDoc of start of token */\n    int iFin = 0;                 /* Offset in zDoc of end of token */\n    int isHighlight = 0;          /* True for highlighted terms */\n\n    /* Variable DUMMY1 is initialized to a negative value above. Elsewhere\n    ** in the FTS code the variable that the third argument to xNext points to\n    ** is initialized to zero before the first (*but not necessarily\n    ** subsequent*) call to xNext(). This is done for a particular application\n    ** that needs to know whether or not the tokenizer is being used for\n    ** snippet generation or for some other purpose.\n    **\n    ** Extreme care is required when writing code to depend on this\n    ** initialization. It is not a documented part of the tokenizer interface.\n    ** If a tokenizer is used directly by any code outside of FTS, this\n    ** convention might not be respected.  */\n    rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);\n    if( rc!=SQLITE_OK ){\n      if( rc==SQLITE_DONE ){\n        /* Special case - the last token of the snippet is also the last token\n        ** of the column. Append any punctuation that occurred between the end\n        ** of the previous token and the end of the document to the output. \n        ** Then break out of the loop. */\n        rc = fts3StringAppend(pOut, &zDoc[iEnd], -1);\n      }\n      break;\n    }\n    if( iCurrent<iPos ){ continue; }\n\n    if( !isShiftDone ){\n      int n = nDoc - iBegin;\n      rc = fts3SnippetShift(\n          pTab, pCsr->iLangid, nSnippet, &zDoc[iBegin], n, &iPos, &hlmask\n      );\n      isShiftDone = 1;\n\n      /* Now that the shift has been done, check if the initial \"...\" are\n      ** required. They are required if (a) this is not the first fragment,\n      ** or (b) this fragment does not begin at position 0 of its column. \n      */\n      if( rc==SQLITE_OK ){\n        if( iPos>0 || iFragment>0 ){\n          rc = fts3StringAppend(pOut, zEllipsis, -1);\n        }else if( iBegin ){\n          rc = fts3StringAppend(pOut, zDoc, iBegin);\n        }\n      }\n      if( rc!=SQLITE_OK || iCurrent<iPos ) continue;\n    }\n\n    if( iCurrent>=(iPos+nSnippet) ){\n      if( isLast ){\n        rc = fts3StringAppend(pOut, zEllipsis, -1);\n      }\n      break;\n    }\n\n    /* Set isHighlight to true if this term should be highlighted. */\n    isHighlight = (hlmask & ((u64)1 << (iCurrent-iPos)))!=0;\n\n    if( iCurrent>iPos ) rc = fts3StringAppend(pOut, &zDoc[iEnd], iBegin-iEnd);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zOpen, -1);\n    if( rc==SQLITE_OK ) rc = fts3StringAppend(pOut, &zDoc[iBegin], iFin-iBegin);\n    if( rc==SQLITE_OK && isHighlight ) rc = fts3StringAppend(pOut, zClose, -1);\n\n    iEnd = iFin;\n  }\n\n  pMod->xClose(pC);\n  return rc;\n}\n\n\n/*\n** This function is used to count the entries in a column-list (a \n** delta-encoded list of term offsets within a single column of a single \n** row). When this function is called, *ppCollist should point to the\n** beginning of the first varint in the column-list (the varint that\n** contains the position of the first matching term in the column data).\n** Before returning, *ppCollist is set to point to the first byte after\n** the last varint in the column-list (either the 0x00 signifying the end\n** of the position-list, or the 0x01 that precedes the column number of\n** the next column in the position-list).\n**\n** The number of elements in the column-list is returned.\n*/\nstatic int fts3ColumnlistCount(char **ppCollist){\n  char *pEnd = *ppCollist;\n  char c = 0;\n  int nEntry = 0;\n\n  /* A column-list is terminated by either a 0x01 or 0x00. */\n  while( 0xFE & (*pEnd | c) ){\n    c = *pEnd++ & 0x80;\n    if( !c ) nEntry++;\n  }\n\n  *ppCollist = pEnd;\n  return nEntry;\n}\n\n/*\n** This function gathers 'y' or 'b' data for a single phrase.\n*/\nstatic void fts3ExprLHits(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  MatchInfo *p                    /* Matchinfo context */\n){\n  Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;\n  int iStart;\n  Fts3Phrase *pPhrase = pExpr->pPhrase;\n  char *pIter = pPhrase->doclist.pList;\n  int iCol = 0;\n\n  assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS );\n  if( p->flag==FTS3_MATCHINFO_LHITS ){\n    iStart = pExpr->iPhrase * p->nCol;\n  }else{\n    iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);\n  }\n\n  while( 1 ){\n    int nHit = fts3ColumnlistCount(&pIter);\n    if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){\n      if( p->flag==FTS3_MATCHINFO_LHITS ){\n        p->aMatchinfo[iStart + iCol] = (u32)nHit;\n      }else if( nHit ){\n        p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));\n      }\n    }\n    assert( *pIter==0x00 || *pIter==0x01 );\n    if( *pIter!=0x01 ) break;\n    pIter++;\n    pIter += fts3GetVarint32(pIter, &iCol);\n  }\n}\n\n/*\n** Gather the results for matchinfo directives 'y' and 'b'.\n*/\nstatic void fts3ExprLHitGather(\n  Fts3Expr *pExpr,\n  MatchInfo *p\n){\n  assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );\n  if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){\n    if( pExpr->pLeft ){\n      fts3ExprLHitGather(pExpr->pLeft, p);\n      fts3ExprLHitGather(pExpr->pRight, p);\n    }else{\n      fts3ExprLHits(pExpr, p);\n    }\n  }\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"global\" matchinfo stats\n** for a single query. \n**\n** fts3ExprIterate() callback to load the 'global' elements of a\n** FTS3_MATCHINFO_HITS matchinfo array. The global stats are those elements \n** of the matchinfo array that are constant for all rows returned by the \n** current query.\n**\n** Argument pCtx is actually a pointer to a struct of type MatchInfo. This\n** function populates Matchinfo.aMatchinfo[] as follows:\n**\n**   for(iCol=0; iCol<nCol; iCol++){\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 1] = X;\n**     aMatchinfo[3*iPhrase*nCol + 3*iCol + 2] = Y;\n**   }\n**\n** where X is the number of matches for phrase iPhrase is column iCol of all\n** rows of the table. Y is the number of rows for which column iCol contains\n** at least one instance of phrase iPhrase.\n**\n** If the phrase pExpr consists entirely of deferred tokens, then all X and\n** Y values are set to nDoc, where nDoc is the number of documents in the \n** file system. This is done because the full-text index doclist is required\n** to calculate these values properly, and the full-text index doclist is\n** not available for deferred tokens.\n*/\nstatic int fts3ExprGlobalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  MatchInfo *p = (MatchInfo *)pCtx;\n  return sqlite3Fts3EvalPhraseStats(\n      p->pCursor, pExpr, &p->aMatchinfo[3*iPhrase*p->nCol]\n  );\n}\n\n/*\n** fts3ExprIterate() callback used to collect the \"local\" part of the\n** FTS3_MATCHINFO_HITS array. The local stats are those elements of the \n** array that are different for each row returned by the query.\n*/\nstatic int fts3ExprLocalHitsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  int rc = SQLITE_OK;\n  MatchInfo *p = (MatchInfo *)pCtx;\n  int iStart = iPhrase * p->nCol * 3;\n  int i;\n\n  for(i=0; i<p->nCol && rc==SQLITE_OK; i++){\n    char *pCsr;\n    rc = sqlite3Fts3EvalPhrasePoslist(p->pCursor, pExpr, i, &pCsr);\n    if( pCsr ){\n      p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);\n    }else{\n      p->aMatchinfo[iStart+i*3] = 0;\n    }\n  }\n\n  return rc;\n}\n\nstatic int fts3MatchinfoCheck(\n  Fts3Table *pTab, \n  char cArg,\n  char **pzErr\n){\n  if( (cArg==FTS3_MATCHINFO_NPHRASE)\n   || (cArg==FTS3_MATCHINFO_NCOL)\n   || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)\n   || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)\n   || (cArg==FTS3_MATCHINFO_LCS)\n   || (cArg==FTS3_MATCHINFO_HITS)\n   || (cArg==FTS3_MATCHINFO_LHITS)\n   || (cArg==FTS3_MATCHINFO_LHITS_BM)\n  ){\n    return SQLITE_OK;\n  }\n  sqlite3Fts3ErrMsg(pzErr, \"unrecognized matchinfo request: %c\", cArg);\n  return SQLITE_ERROR;\n}\n\nstatic int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){\n  int nVal;                       /* Number of integers output by cArg */\n\n  switch( cArg ){\n    case FTS3_MATCHINFO_NDOC:\n    case FTS3_MATCHINFO_NPHRASE: \n    case FTS3_MATCHINFO_NCOL: \n      nVal = 1;\n      break;\n\n    case FTS3_MATCHINFO_AVGLENGTH:\n    case FTS3_MATCHINFO_LENGTH:\n    case FTS3_MATCHINFO_LCS:\n      nVal = pInfo->nCol;\n      break;\n\n    case FTS3_MATCHINFO_LHITS:\n      nVal = pInfo->nCol * pInfo->nPhrase;\n      break;\n\n    case FTS3_MATCHINFO_LHITS_BM:\n      nVal = pInfo->nPhrase * ((pInfo->nCol + 31) / 32);\n      break;\n\n    default:\n      assert( cArg==FTS3_MATCHINFO_HITS );\n      nVal = pInfo->nCol * pInfo->nPhrase * 3;\n      break;\n  }\n\n  return nVal;\n}\n\nstatic int fts3MatchinfoSelectDoctotal(\n  Fts3Table *pTab,\n  sqlite3_stmt **ppStmt,\n  sqlite3_int64 *pnDoc,\n  const char **paLen\n){\n  sqlite3_stmt *pStmt;\n  const char *a;\n  sqlite3_int64 nDoc;\n\n  if( !*ppStmt ){\n    int rc = sqlite3Fts3SelectDoctotal(pTab, ppStmt);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  pStmt = *ppStmt;\n  assert( sqlite3_data_count(pStmt)==1 );\n\n  a = sqlite3_column_blob(pStmt, 0);\n  a += sqlite3Fts3GetVarint(a, &nDoc);\n  if( nDoc==0 ) return FTS_CORRUPT_VTAB;\n  *pnDoc = (u32)nDoc;\n\n  if( paLen ) *paLen = a;\n  return SQLITE_OK;\n}\n\n/*\n** An instance of the following structure is used to store state while \n** iterating through a multi-column position-list corresponding to the\n** hits for a single phrase on a single row in order to calculate the\n** values for a matchinfo() FTS3_MATCHINFO_LCS request.\n*/\ntypedef struct LcsIterator LcsIterator;\nstruct LcsIterator {\n  Fts3Expr *pExpr;                /* Pointer to phrase expression */\n  int iPosOffset;                 /* Tokens count up to end of this phrase */\n  char *pRead;                    /* Cursor used to iterate through aDoclist */\n  int iPos;                       /* Current position */\n};\n\n/* \n** If LcsIterator.iCol is set to the following value, the iterator has\n** finished iterating through all offsets for all columns.\n*/\n#define LCS_ITERATOR_FINISHED 0x7FFFFFFF;\n\nstatic int fts3MatchinfoLcsCb(\n  Fts3Expr *pExpr,                /* Phrase expression node */\n  int iPhrase,                    /* Phrase number (numbered from zero) */\n  void *pCtx                      /* Pointer to MatchInfo structure */\n){\n  LcsIterator *aIter = (LcsIterator *)pCtx;\n  aIter[iPhrase].pExpr = pExpr;\n  return SQLITE_OK;\n}\n\n/*\n** Advance the iterator passed as an argument to the next position. Return\n** 1 if the iterator is at EOF or if it now points to the start of the\n** position list for the next column.\n*/\nstatic int fts3LcsIteratorAdvance(LcsIterator *pIter){\n  char *pRead = pIter->pRead;\n  sqlite3_int64 iRead;\n  int rc = 0;\n\n  pRead += sqlite3Fts3GetVarint(pRead, &iRead);\n  if( iRead==0 || iRead==1 ){\n    pRead = 0;\n    rc = 1;\n  }else{\n    pIter->iPos += (int)(iRead-2);\n  }\n\n  pIter->pRead = pRead;\n  return rc;\n}\n  \n/*\n** This function implements the FTS3_MATCHINFO_LCS matchinfo() flag. \n**\n** If the call is successful, the longest-common-substring lengths for each\n** column are written into the first nCol elements of the pInfo->aMatchinfo[] \n** array before returning. SQLITE_OK is returned in this case.\n**\n** Otherwise, if an error occurs, an SQLite error code is returned and the\n** data written to the first nCol elements of pInfo->aMatchinfo[] is \n** undefined.\n*/\nstatic int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){\n  LcsIterator *aIter;\n  int i;\n  int iCol;\n  int nToken = 0;\n\n  /* Allocate and populate the array of LcsIterator objects. The array\n  ** contains one element for each matchable phrase in the query.\n  **/\n  aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);\n  if( !aIter ) return SQLITE_NOMEM;\n  memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);\n  (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);\n\n  for(i=0; i<pInfo->nPhrase; i++){\n    LcsIterator *pIter = &aIter[i];\n    nToken -= pIter->pExpr->pPhrase->nToken;\n    pIter->iPosOffset = nToken;\n  }\n\n  for(iCol=0; iCol<pInfo->nCol; iCol++){\n    int nLcs = 0;                 /* LCS value for this column */\n    int nLive = 0;                /* Number of iterators in aIter not at EOF */\n\n    for(i=0; i<pInfo->nPhrase; i++){\n      int rc;\n      LcsIterator *pIt = &aIter[i];\n      rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);\n      if( rc!=SQLITE_OK ) return rc;\n      if( pIt->pRead ){\n        pIt->iPos = pIt->iPosOffset;\n        fts3LcsIteratorAdvance(&aIter[i]);\n        nLive++;\n      }\n    }\n\n    while( nLive>0 ){\n      LcsIterator *pAdv = 0;      /* The iterator to advance by one position */\n      int nThisLcs = 0;           /* LCS for the current iterator positions */\n\n      for(i=0; i<pInfo->nPhrase; i++){\n        LcsIterator *pIter = &aIter[i];\n        if( pIter->pRead==0 ){\n          /* This iterator is already at EOF for this column. */\n          nThisLcs = 0;\n        }else{\n          if( pAdv==0 || pIter->iPos<pAdv->iPos ){\n            pAdv = pIter;\n          }\n          if( nThisLcs==0 || pIter->iPos==pIter[-1].iPos ){\n            nThisLcs++;\n          }else{\n            nThisLcs = 1;\n          }\n          if( nThisLcs>nLcs ) nLcs = nThisLcs;\n        }\n      }\n      if( fts3LcsIteratorAdvance(pAdv) ) nLive--;\n    }\n\n    pInfo->aMatchinfo[iCol] = nLcs;\n  }\n\n  sqlite3_free(aIter);\n  return SQLITE_OK;\n}\n\n/*\n** Populate the buffer pInfo->aMatchinfo[] with an array of integers to\n** be returned by the matchinfo() function. Argument zArg contains the \n** format string passed as the second argument to matchinfo (or the\n** default value \"pcx\" if no second argument was specified). The format\n** string has already been validated and the pInfo->aMatchinfo[] array\n** is guaranteed to be large enough for the output.\n**\n** If bGlobal is true, then populate all fields of the matchinfo() output.\n** If it is false, then assume that those fields that do not change between\n** rows (i.e. FTS3_MATCHINFO_NPHRASE, NCOL, NDOC, AVGLENGTH and part of HITS)\n** have already been populated.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error \n** occurs. If a value other than SQLITE_OK is returned, the state the\n** pInfo->aMatchinfo[] buffer is left in is undefined.\n*/\nstatic int fts3MatchinfoValues(\n  Fts3Cursor *pCsr,               /* FTS3 cursor object */\n  int bGlobal,                    /* True to grab the global stats */\n  MatchInfo *pInfo,               /* Matchinfo context object */\n  const char *zArg                /* Matchinfo format string */\n){\n  int rc = SQLITE_OK;\n  int i;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_stmt *pSelect = 0;\n\n  for(i=0; rc==SQLITE_OK && zArg[i]; i++){\n    pInfo->flag = zArg[i];\n    switch( zArg[i] ){\n      case FTS3_MATCHINFO_NPHRASE:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nPhrase;\n        break;\n\n      case FTS3_MATCHINFO_NCOL:\n        if( bGlobal ) pInfo->aMatchinfo[0] = pInfo->nCol;\n        break;\n        \n      case FTS3_MATCHINFO_NDOC:\n        if( bGlobal ){\n          sqlite3_int64 nDoc = 0;\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, 0);\n          pInfo->aMatchinfo[0] = (u32)nDoc;\n        }\n        break;\n\n      case FTS3_MATCHINFO_AVGLENGTH: \n        if( bGlobal ){\n          sqlite3_int64 nDoc;     /* Number of rows in table */\n          const char *a;          /* Aggregate column length array */\n\n          rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &nDoc, &a);\n          if( rc==SQLITE_OK ){\n            int iCol;\n            for(iCol=0; iCol<pInfo->nCol; iCol++){\n              u32 iVal;\n              sqlite3_int64 nToken;\n              a += sqlite3Fts3GetVarint(a, &nToken);\n              iVal = (u32)(((u32)(nToken&0xffffffff)+nDoc/2)/nDoc);\n              pInfo->aMatchinfo[iCol] = iVal;\n            }\n          }\n        }\n        break;\n\n      case FTS3_MATCHINFO_LENGTH: {\n        sqlite3_stmt *pSelectDocsize = 0;\n        rc = sqlite3Fts3SelectDocsize(pTab, pCsr->iPrevId, &pSelectDocsize);\n        if( rc==SQLITE_OK ){\n          int iCol;\n          const char *a = sqlite3_column_blob(pSelectDocsize, 0);\n          for(iCol=0; iCol<pInfo->nCol; iCol++){\n            sqlite3_int64 nToken;\n            a += sqlite3Fts3GetVarint(a, &nToken);\n            pInfo->aMatchinfo[iCol] = (u32)nToken;\n          }\n        }\n        sqlite3_reset(pSelectDocsize);\n        break;\n      }\n\n      case FTS3_MATCHINFO_LCS:\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc==SQLITE_OK ){\n          rc = fts3MatchinfoLcs(pCsr, pInfo);\n        }\n        break;\n\n      case FTS3_MATCHINFO_LHITS_BM:\n      case FTS3_MATCHINFO_LHITS: {\n        int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);\n        memset(pInfo->aMatchinfo, 0, nZero);\n        fts3ExprLHitGather(pCsr->pExpr, pInfo);\n        break;\n      }\n\n      default: {\n        Fts3Expr *pExpr;\n        assert( zArg[i]==FTS3_MATCHINFO_HITS );\n        pExpr = pCsr->pExpr;\n        rc = fts3ExprLoadDoclists(pCsr, 0, 0);\n        if( rc!=SQLITE_OK ) break;\n        if( bGlobal ){\n          if( pCsr->pDeferred ){\n            rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);\n            if( rc!=SQLITE_OK ) break;\n          }\n          rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);\n          sqlite3Fts3EvalTestDeferred(pCsr, &rc);\n          if( rc!=SQLITE_OK ) break;\n        }\n        (void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);\n        break;\n      }\n    }\n\n    pInfo->aMatchinfo += fts3MatchinfoSize(pInfo, zArg[i]);\n  }\n\n  sqlite3_reset(pSelect);\n  return rc;\n}\n\n\n/*\n** Populate pCsr->aMatchinfo[] with data for the current row. The \n** 'matchinfo' data is an array of 32-bit unsigned integers (C type u32).\n*/\nstatic void fts3GetMatchinfo(\n  sqlite3_context *pCtx,        /* Return results here */\n  Fts3Cursor *pCsr,               /* FTS3 Cursor object */\n  const char *zArg                /* Second argument to matchinfo() function */\n){\n  MatchInfo sInfo;\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int bGlobal = 0;                /* Collect 'global' stats as well as local */\n\n  u32 *aOut = 0;\n  void (*xDestroyOut)(void*) = 0;\n\n  memset(&sInfo, 0, sizeof(MatchInfo));\n  sInfo.pCursor = pCsr;\n  sInfo.nCol = pTab->nColumn;\n\n  /* If there is cached matchinfo() data, but the format string for the \n  ** cache does not match the format string for this request, discard \n  ** the cached data. */\n  if( pCsr->pMIBuffer && strcmp(pCsr->pMIBuffer->zMatchinfo, zArg) ){\n    sqlite3Fts3MIBufferFree(pCsr->pMIBuffer);\n    pCsr->pMIBuffer = 0;\n  }\n\n  /* If Fts3Cursor.pMIBuffer is NULL, then this is the first time the\n  ** matchinfo function has been called for this query. In this case \n  ** allocate the array used to accumulate the matchinfo data and\n  ** initialize those elements that are constant for every row.\n  */\n  if( pCsr->pMIBuffer==0 ){\n    int nMatchinfo = 0;           /* Number of u32 elements in match-info */\n    int i;                        /* Used to iterate through zArg */\n\n    /* Determine the number of phrases in the query */\n    pCsr->nPhrase = fts3ExprPhraseCount(pCsr->pExpr);\n    sInfo.nPhrase = pCsr->nPhrase;\n\n    /* Determine the number of integers in the buffer returned by this call. */\n    for(i=0; zArg[i]; i++){\n      char *zErr = 0;\n      if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){\n        sqlite3_result_error(pCtx, zErr, -1);\n        sqlite3_free(zErr);\n        return;\n      }\n      nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);\n    }\n\n    /* Allocate space for Fts3Cursor.aMatchinfo[] and Fts3Cursor.zMatchinfo. */\n    pCsr->pMIBuffer = fts3MIBufferNew(nMatchinfo, zArg);\n    if( !pCsr->pMIBuffer ) rc = SQLITE_NOMEM;\n\n    pCsr->isMatchinfoNeeded = 1;\n    bGlobal = 1;\n  }\n\n  if( rc==SQLITE_OK ){\n    xDestroyOut = fts3MIBufferAlloc(pCsr->pMIBuffer, &aOut);\n    if( xDestroyOut==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    sInfo.aMatchinfo = aOut;\n    sInfo.nPhrase = pCsr->nPhrase;\n    rc = fts3MatchinfoValues(pCsr, bGlobal, &sInfo, zArg);\n    if( bGlobal ){\n      fts3MIBufferSetGlobal(pCsr->pMIBuffer);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    if( xDestroyOut ) xDestroyOut(aOut);\n  }else{\n    int n = pCsr->pMIBuffer->nElem * sizeof(u32);\n    sqlite3_result_blob(pCtx, aOut, n, xDestroyOut);\n  }\n}\n\n/*\n** Implementation of snippet() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Snippet(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr,               /* Cursor object */\n  const char *zStart,             /* Snippet start text - \"<b>\" */\n  const char *zEnd,               /* Snippet end text - \"</b>\" */\n  const char *zEllipsis,          /* Snippet ellipsis text - \"<b>...</b>\" */\n  int iCol,                       /* Extract snippet from this column */\n  int nToken                      /* Approximate number of tokens in snippet */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  int rc = SQLITE_OK;\n  int i;\n  StrBuffer res = {0, 0, 0};\n\n  /* The returned text includes up to four fragments of text extracted from\n  ** the data in the current row. The first iteration of the for(...) loop\n  ** below attempts to locate a single fragment of text nToken tokens in \n  ** size that contains at least one instance of all phrases in the query\n  ** expression that appear in the current row. If such a fragment of text\n  ** cannot be found, the second iteration of the loop attempts to locate\n  ** a pair of fragments, and so on.\n  */\n  int nSnippet = 0;               /* Number of fragments in this snippet */\n  SnippetFragment aSnippet[4];    /* Maximum of 4 fragments per snippet */\n  int nFToken = -1;               /* Number of tokens in each fragment */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(nSnippet=1; 1; nSnippet++){\n\n    int iSnip;                    /* Loop counter 0..nSnippet-1 */\n    u64 mCovered = 0;             /* Bitmask of phrases covered by snippet */\n    u64 mSeen = 0;                /* Bitmask of phrases seen by BestSnippet() */\n\n    if( nToken>=0 ){\n      nFToken = (nToken+nSnippet-1) / nSnippet;\n    }else{\n      nFToken = -1 * nToken;\n    }\n\n    for(iSnip=0; iSnip<nSnippet; iSnip++){\n      int iBestScore = -1;        /* Best score of columns checked so far */\n      int iRead;                  /* Used to iterate through columns */\n      SnippetFragment *pFragment = &aSnippet[iSnip];\n\n      memset(pFragment, 0, sizeof(*pFragment));\n\n      /* Loop through all columns of the table being considered for snippets.\n      ** If the iCol argument to this function was negative, this means all\n      ** columns of the FTS3 table. Otherwise, only column iCol is considered.\n      */\n      for(iRead=0; iRead<pTab->nColumn; iRead++){\n        SnippetFragment sF = {0, 0, 0, 0};\n        int iS = 0;\n        if( iCol>=0 && iRead!=iCol ) continue;\n\n        /* Find the best snippet of nFToken tokens in column iRead. */\n        rc = fts3BestSnippet(nFToken, pCsr, iRead, mCovered, &mSeen, &sF, &iS);\n        if( rc!=SQLITE_OK ){\n          goto snippet_out;\n        }\n        if( iS>iBestScore ){\n          *pFragment = sF;\n          iBestScore = iS;\n        }\n      }\n\n      mCovered |= pFragment->covered;\n    }\n\n    /* If all query phrases seen by fts3BestSnippet() are present in at least\n    ** one of the nSnippet snippet fragments, break out of the loop.\n    */\n    assert( (mCovered&mSeen)==mCovered );\n    if( mSeen==mCovered || nSnippet==SizeofArray(aSnippet) ) break;\n  }\n\n  assert( nFToken>0 );\n\n  for(i=0; i<nSnippet && rc==SQLITE_OK; i++){\n    rc = fts3SnippetText(pCsr, &aSnippet[i], \n        i, (i==nSnippet-1), nFToken, zStart, zEnd, zEllipsis, &res\n    );\n  }\n\n snippet_out:\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, -1, sqlite3_free);\n  }\n}\n\n\ntypedef struct TermOffset TermOffset;\ntypedef struct TermOffsetCtx TermOffsetCtx;\n\nstruct TermOffset {\n  char *pList;                    /* Position-list */\n  int iPos;                       /* Position just read from pList */\n  int iOff;                       /* Offset of this term from read positions */\n};\n\nstruct TermOffsetCtx {\n  Fts3Cursor *pCsr;\n  int iCol;                       /* Column of table to populate aTerm for */\n  int iTerm;\n  sqlite3_int64 iDocid;\n  TermOffset *aTerm;\n};\n\n/*\n** This function is an fts3ExprIterate() callback used by sqlite3Fts3Offsets().\n*/\nstatic int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){\n  TermOffsetCtx *p = (TermOffsetCtx *)ctx;\n  int nTerm;                      /* Number of tokens in phrase */\n  int iTerm;                      /* For looping through nTerm phrase terms */\n  char *pList;                    /* Pointer to position list for phrase */\n  int iPos = 0;                   /* First position in position-list */\n  int rc;\n\n  UNUSED_PARAMETER(iPhrase);\n  rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pList);\n  nTerm = pExpr->pPhrase->nToken;\n  if( pList ){\n    fts3GetDeltaPosition(&pList, &iPos);\n    assert( iPos>=0 );\n  }\n\n  for(iTerm=0; iTerm<nTerm; iTerm++){\n    TermOffset *pT = &p->aTerm[p->iTerm++];\n    pT->iOff = nTerm-iTerm-1;\n    pT->pList = pList;\n    pT->iPos = iPos;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of offsets() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Offsets(\n  sqlite3_context *pCtx,          /* SQLite function call context */\n  Fts3Cursor *pCsr                /* Cursor object */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;\n  int rc;                         /* Return Code */\n  int nToken;                     /* Number of tokens in query */\n  int iCol;                       /* Column currently being processed */\n  StrBuffer res = {0, 0, 0};      /* Result string */\n  TermOffsetCtx sCtx;             /* Context for fts3ExprTermOffsetInit() */\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_text(pCtx, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  memset(&sCtx, 0, sizeof(sCtx));\n  assert( pCsr->isRequireSeek==0 );\n\n  /* Count the number of terms in the query */\n  rc = fts3ExprLoadDoclists(pCsr, 0, &nToken);\n  if( rc!=SQLITE_OK ) goto offsets_out;\n\n  /* Allocate the array of TermOffset iterators. */\n  sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);\n  if( 0==sCtx.aTerm ){\n    rc = SQLITE_NOMEM;\n    goto offsets_out;\n  }\n  sCtx.iDocid = pCsr->iPrevId;\n  sCtx.pCsr = pCsr;\n\n  /* Loop through the table columns, appending offset information to \n  ** string-buffer res for each column.\n  */\n  for(iCol=0; iCol<pTab->nColumn; iCol++){\n    sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */\n    const char *ZDUMMY;           /* Dummy argument used with xNext() */\n    int NDUMMY = 0;               /* Dummy argument used with xNext() */\n    int iStart = 0;\n    int iEnd = 0;\n    int iCurrent = 0;\n    const char *zDoc;\n    int nDoc;\n\n    /* Initialize the contents of sCtx.aTerm[] for column iCol. There is \n    ** no way that this operation can fail, so the return code from\n    ** fts3ExprIterate() can be discarded.\n    */\n    sCtx.iCol = iCol;\n    sCtx.iTerm = 0;\n    (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);\n\n    /* Retreive the text stored in column iCol. If an SQL NULL is stored \n    ** in column iCol, jump immediately to the next iteration of the loop.\n    ** If an OOM occurs while retrieving the data (this can happen if SQLite\n    ** needs to transform the data from utf-16 to utf-8), return SQLITE_NOMEM \n    ** to the caller. \n    */\n    zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);\n    nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    if( zDoc==0 ){\n      if( sqlite3_column_type(pCsr->pStmt, iCol+1)==SQLITE_NULL ){\n        continue;\n      }\n      rc = SQLITE_NOMEM;\n      goto offsets_out;\n    }\n\n    /* Initialize a tokenizer iterator to iterate through column iCol. */\n    rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, pCsr->iLangid,\n        zDoc, nDoc, &pC\n    );\n    if( rc!=SQLITE_OK ) goto offsets_out;\n\n    rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n    while( rc==SQLITE_OK ){\n      int i;                      /* Used to loop through terms */\n      int iMinPos = 0x7FFFFFFF;   /* Position of next token */\n      TermOffset *pTerm = 0;      /* TermOffset associated with next token */\n\n      for(i=0; i<nToken; i++){\n        TermOffset *pT = &sCtx.aTerm[i];\n        if( pT->pList && (pT->iPos-pT->iOff)<iMinPos ){\n          iMinPos = pT->iPos-pT->iOff;\n          pTerm = pT;\n        }\n      }\n\n      if( !pTerm ){\n        /* All offsets for this column have been gathered. */\n        rc = SQLITE_DONE;\n      }else{\n        assert( iCurrent<=iMinPos );\n        if( 0==(0xFE&*pTerm->pList) ){\n          pTerm->pList = 0;\n        }else{\n          fts3GetDeltaPosition(&pTerm->pList, &pTerm->iPos);\n        }\n        while( rc==SQLITE_OK && iCurrent<iMinPos ){\n          rc = pMod->xNext(pC, &ZDUMMY, &NDUMMY, &iStart, &iEnd, &iCurrent);\n        }\n        if( rc==SQLITE_OK ){\n          char aBuffer[64];\n          sqlite3_snprintf(sizeof(aBuffer), aBuffer, \n              \"%d %d %d %d \", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart\n          );\n          rc = fts3StringAppend(&res, aBuffer, -1);\n        }else if( rc==SQLITE_DONE && pTab->zContentTbl==0 ){\n          rc = FTS_CORRUPT_VTAB;\n        }\n      }\n    }\n    if( rc==SQLITE_DONE ){\n      rc = SQLITE_OK;\n    }\n\n    pMod->xClose(pC);\n    if( rc!=SQLITE_OK ) goto offsets_out;\n  }\n\n offsets_out:\n  sqlite3_free(sCtx.aTerm);\n  assert( rc!=SQLITE_DONE );\n  sqlite3Fts3SegmentsClose(pTab);\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx,  rc);\n    sqlite3_free(res.z);\n  }else{\n    sqlite3_result_text(pCtx, res.z, res.n-1, sqlite3_free);\n  }\n  return;\n}\n\n/*\n** Implementation of matchinfo() function.\n*/\nSQLITE_PRIVATE void sqlite3Fts3Matchinfo(\n  sqlite3_context *pContext,      /* Function call context */\n  Fts3Cursor *pCsr,               /* FTS3 table cursor */\n  const char *zArg                /* Second arg to matchinfo() function */\n){\n  Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;\n  const char *zFormat;\n\n  if( zArg ){\n    zFormat = zArg;\n  }else{\n    zFormat = FTS3_MATCHINFO_DEFAULT;\n  }\n\n  if( !pCsr->pExpr ){\n    sqlite3_result_blob(pContext, \"\", 0, SQLITE_STATIC);\n    return;\n  }else{\n    /* Retrieve matchinfo() data. */\n    fts3GetMatchinfo(pContext, pCsr, zFormat);\n    sqlite3Fts3SegmentsClose(pTab);\n  }\n}\n\n#endif\n\n/************** End of fts3_snippet.c ****************************************/\n/************** Begin file fts3_unicode.c ************************************/\n/*\n** 2012 May 24\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Implementation of the \"unicode\" full-text-search tokenizer.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n\n/* #include <assert.h> */\n/* #include <stdlib.h> */\n/* #include <stdio.h> */\n/* #include <string.h> */\n\n/* #include \"fts3_tokenizer.h\" */\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct unicode_tokenizer unicode_tokenizer;\ntypedef struct unicode_cursor unicode_cursor;\n\nstruct unicode_tokenizer {\n  sqlite3_tokenizer base;\n  int bRemoveDiacritic;\n  int nException;\n  int *aiException;\n};\n\nstruct unicode_cursor {\n  sqlite3_tokenizer_cursor base;\n  const unsigned char *aInput;    /* Input text being tokenized */\n  int nInput;                     /* Size of aInput[] in bytes */\n  int iOff;                       /* Current offset within aInput[] */\n  int iToken;                     /* Index of next token to be returned */\n  char *zToken;                   /* storage for current token */\n  int nAlloc;                     /* space allocated at zToken */\n};\n\n\n/*\n** Destroy a tokenizer allocated by unicodeCreate().\n*/\nstatic int unicodeDestroy(sqlite3_tokenizer *pTokenizer){\n  if( pTokenizer ){\n    unicode_tokenizer *p = (unicode_tokenizer *)pTokenizer;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** As part of a tokenchars= or separators= option, the CREATE VIRTUAL TABLE\n** statement has specified that the tokenizer for this table shall consider\n** all characters in string zIn/nIn to be separators (if bAlnum==0) or\n** token characters (if bAlnum==1).\n**\n** For each codepoint in the zIn/nIn string, this function checks if the\n** sqlite3FtsUnicodeIsalnum() function already returns the desired result.\n** If so, no action is taken. Otherwise, the codepoint is added to the \n** unicode_tokenizer.aiException[] array. For the purposes of tokenization,\n** the return value of sqlite3FtsUnicodeIsalnum() is inverted for all\n** codepoints in the aiException[] array.\n**\n** If a standalone diacritic mark (one that sqlite3FtsUnicodeIsdiacritic()\n** identifies as a diacritic) occurs in the zIn/nIn string it is ignored.\n** It is not possible to change the behavior of the tokenizer with respect\n** to these codepoints.\n*/\nstatic int unicodeAddExceptions(\n  unicode_tokenizer *p,           /* Tokenizer to add exceptions to */\n  int bAlnum,                     /* Replace Isalnum() return value with this */\n  const char *zIn,                /* Array of characters to make exceptions */\n  int nIn                         /* Length of z in bytes */\n){\n  const unsigned char *z = (const unsigned char *)zIn;\n  const unsigned char *zTerm = &z[nIn];\n  unsigned int iCode;\n  int nEntry = 0;\n\n  assert( bAlnum==0 || bAlnum==1 );\n\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    assert( (sqlite3FtsUnicodeIsalnum((int)iCode) & 0xFFFFFFFE)==0 );\n    if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n     && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0 \n    ){\n      nEntry++;\n    }\n  }\n\n  if( nEntry ){\n    int *aNew;                    /* New aiException[] array */\n    int nNew;                     /* Number of valid entries in array aNew[] */\n\n    aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    nNew = p->nException;\n\n    z = (const unsigned char *)zIn;\n    while( z<zTerm ){\n      READ_UTF8(z, zTerm, iCode);\n      if( sqlite3FtsUnicodeIsalnum((int)iCode)!=bAlnum \n       && sqlite3FtsUnicodeIsdiacritic((int)iCode)==0\n      ){\n        int i, j;\n        for(i=0; i<nNew && aNew[i]<(int)iCode; i++);\n        for(j=nNew; j>i; j--) aNew[j] = aNew[j-1];\n        aNew[i] = (int)iCode;\n        nNew++;\n      }\n    }\n    p->aiException = aNew;\n    p->nException = nNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int unicodeIsException(unicode_tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Return true if, for the purposes of tokenization, codepoint iCode is\n** considered a token character (not a separator).\n*/\nstatic int unicodeIsAlnum(unicode_tokenizer *p, int iCode){\n  assert( (sqlite3FtsUnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3FtsUnicodeIsalnum(iCode) ^ unicodeIsException(p, iCode);\n}\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int unicodeCreate(\n  int nArg,                       /* Size of array argv[] */\n  const char * const *azArg,      /* Tokenizer creation arguments */\n  sqlite3_tokenizer **pp          /* OUT: New tokenizer handle */\n){\n  unicode_tokenizer *pNew;        /* New tokenizer object */\n  int i;\n  int rc = SQLITE_OK;\n\n  pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));\n  if( pNew==NULL ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(unicode_tokenizer));\n  pNew->bRemoveDiacritic = 1;\n\n  for(i=0; rc==SQLITE_OK && i<nArg; i++){\n    const char *z = azArg[i];\n    int n = (int)strlen(z);\n\n    if( n==19 && memcmp(\"remove_diacritics=1\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 1;\n    }\n    else if( n==19 && memcmp(\"remove_diacritics=0\", z, 19)==0 ){\n      pNew->bRemoveDiacritic = 0;\n    }\n    else if( n>=11 && memcmp(\"tokenchars=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);\n    }\n    else if( n>=11 && memcmp(\"separators=\", z, 11)==0 ){\n      rc = unicodeAddExceptions(pNew, 0, &z[11], n-11);\n    }\n    else{\n      /* Unrecognized argument */\n      rc  = SQLITE_ERROR;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    unicodeDestroy((sqlite3_tokenizer *)pNew);\n    pNew = 0;\n  }\n  *pp = (sqlite3_tokenizer *)pNew;\n  return rc;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int unicodeOpen(\n  sqlite3_tokenizer *p,           /* The tokenizer */\n  const char *aInput,             /* Input string */\n  int nInput,                     /* Size of string aInput in bytes */\n  sqlite3_tokenizer_cursor **pp   /* OUT: New cursor object */\n){\n  unicode_cursor *pCsr;\n\n  pCsr = (unicode_cursor *)sqlite3_malloc(sizeof(unicode_cursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(unicode_cursor));\n\n  pCsr->aInput = (const unsigned char *)aInput;\n  if( aInput==0 ){\n    pCsr->nInput = 0;\n  }else if( nInput<0 ){\n    pCsr->nInput = (int)strlen(aInput);\n  }else{\n    pCsr->nInput = nInput;\n  }\n\n  *pp = &pCsr->base;\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to\n** simpleOpen() above.\n*/\nstatic int unicodeClose(sqlite3_tokenizer_cursor *pCursor){\n  unicode_cursor *pCsr = (unicode_cursor *) pCursor;\n  sqlite3_free(pCsr->zToken);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.  The cursor must\n** have been opened by a prior call to simpleOpen().\n*/\nstatic int unicodeNext(\n  sqlite3_tokenizer_cursor *pC,   /* Cursor returned by simpleOpen */\n  const char **paToken,           /* OUT: Token text */\n  int *pnToken,                   /* OUT: Number of bytes at *paToken */\n  int *piStart,                   /* OUT: Starting offset of token */\n  int *piEnd,                     /* OUT: Ending offset of token */\n  int *piPos                      /* OUT: Position integer of token */\n){\n  unicode_cursor *pCsr = (unicode_cursor *)pC;\n  unicode_tokenizer *p = ((unicode_tokenizer *)pCsr->base.pTokenizer);\n  unsigned int iCode = 0;\n  char *zOut;\n  const unsigned char *z = &pCsr->aInput[pCsr->iOff];\n  const unsigned char *zStart = z;\n  const unsigned char *zEnd;\n  const unsigned char *zTerm = &pCsr->aInput[pCsr->nInput];\n\n  /* Scan past any delimiter characters before the start of the next token.\n  ** Return SQLITE_DONE early if this takes us all the way to the end of \n  ** the input.  */\n  while( z<zTerm ){\n    READ_UTF8(z, zTerm, iCode);\n    if( unicodeIsAlnum(p, (int)iCode) ) break;\n    zStart = z;\n  }\n  if( zStart>=zTerm ) return SQLITE_DONE;\n\n  zOut = pCsr->zToken;\n  do {\n    int iOut;\n\n    /* Grow the output buffer if required. */\n    if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){\n      char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);\n      if( !zNew ) return SQLITE_NOMEM;\n      zOut = &zNew[zOut - pCsr->zToken];\n      pCsr->zToken = zNew;\n      pCsr->nAlloc += 64;\n    }\n\n    /* Write the folded case of the last character read to the output */\n    zEnd = z;\n    iOut = sqlite3FtsUnicodeFold((int)iCode, p->bRemoveDiacritic);\n    if( iOut ){\n      WRITE_UTF8(zOut, iOut);\n    }\n\n    /* If the cursor is not at EOF, read the next character */\n    if( z>=zTerm ) break;\n    READ_UTF8(z, zTerm, iCode);\n  }while( unicodeIsAlnum(p, (int)iCode) \n       || sqlite3FtsUnicodeIsdiacritic((int)iCode)\n  );\n\n  /* Set the output variables and return. */\n  pCsr->iOff = (int)(z - pCsr->aInput);\n  *paToken = pCsr->zToken;\n  *pnToken = (int)(zOut - pCsr->zToken);\n  *piStart = (int)(zStart - pCsr->aInput);\n  *piEnd = (int)(zEnd - pCsr->aInput);\n  *piPos = pCsr->iToken++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppModule to a pointer to the sqlite3_tokenizer_module \n** structure for the unicode tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const **ppModule){\n  static const sqlite3_tokenizer_module module = {\n    0,\n    unicodeCreate,\n    unicodeDestroy,\n    unicodeOpen,\n    unicodeClose,\n    unicodeNext,\n    0,\n  };\n  *ppModule = &module;\n}\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n#endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */\n\n/************** End of fts3_unicode.c ****************************************/\n/************** Begin file fts3_unicode2.c ***********************************/\n/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n#ifndef SQLITE_DISABLE_FTS3_UNICODE\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n\n/* #include <assert.h> */\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  static const unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,\n    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,\n    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,\n    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,\n    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,\n    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,\n    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,\n    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,\n    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,\n    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,\n    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,\n    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,\n    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,\n    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,\n    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,\n    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,\n    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,\n    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,\n    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,\n    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,\n    0x380400F0,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & ((unsigned int)1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int remove_diacritic(int c){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3896,  3912,  3928, \n     3968,  4008,  4040,  4106,  4138,  4170,  4202,  4234, \n     4266,  4296,  4312,  4344,  4408,  4424,  4472,  4504, \n     6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529, \n    61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, \n    61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, \n    62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, \n    62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, \n    62924, 63050, 63082, 63274, 63390, \n  };\n  char aChar[] = {\n    '\\0', 'a',  'c',  'e',  'i',  'n',  'o',  'u',  'y',  'y',  'a',  'c',  \n    'd',  'e',  'e',  'g',  'h',  'i',  'j',  'k',  'l',  'n',  'o',  'r',  \n    's',  't',  'u',  'u',  'w',  'y',  'z',  'o',  'u',  'a',  'i',  'o',  \n    'u',  'g',  'k',  'o',  'j',  'g',  'n',  'a',  'e',  'i',  'o',  'r',  \n    'u',  's',  't',  'h',  'a',  'e',  'o',  'y',  '\\0', '\\0', '\\0', '\\0', \n    '\\0', '\\0', '\\0', '\\0', 'a',  'b',  'd',  'd',  'e',  'f',  'g',  'h',  \n    'h',  'i',  'k',  'l',  'l',  'm',  'n',  'p',  'r',  'r',  's',  't',  \n    'u',  'v',  'w',  'w',  'x',  'y',  'z',  'h',  't',  'w',  'y',  'a',  \n    'e',  'i',  'o',  'u',  'y',  \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & (1 << (c-768))) :\n      (mask1 & (1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nSQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( bRemoveDiacritic ) ret = remove_diacritic(ret);\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n#endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */\n#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */\n\n/************** End of fts3_unicode2.c ***************************************/\n/************** Begin file rtree.c *******************************************/\n/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for implementations of the r-tree and r*-tree\n** algorithms packaged as an SQLite virtual table module.\n*/\n\n/*\n** Database Format of R-Tree Tables\n** --------------------------------\n**\n** The data structure for a single virtual r-tree table is stored in three \n** native SQLite tables declared as follows. In each case, the '%' character\n** in the table name is replaced with the user-supplied name of the r-tree\n** table.\n**\n**   CREATE TABLE %_node(nodeno INTEGER PRIMARY KEY, data BLOB)\n**   CREATE TABLE %_parent(nodeno INTEGER PRIMARY KEY, parentnode INTEGER)\n**   CREATE TABLE %_rowid(rowid INTEGER PRIMARY KEY, nodeno INTEGER)\n**\n** The data for each node of the r-tree structure is stored in the %_node\n** table. For each node that is not the root node of the r-tree, there is\n** an entry in the %_parent table associating the node with its parent.\n** And for each row of data in the table, there is an entry in the %_rowid\n** table that maps from the entries rowid to the id of the node that it\n** is stored on.\n**\n** The root node of an r-tree always exists, even if the r-tree table is\n** empty. The nodeno of the root node is always 1. All other nodes in the\n** table must be the same size as the root node. The content of each node\n** is formatted as follows:\n**\n**   1. If the node is the root node (node 1), then the first 2 bytes\n**      of the node contain the tree depth as a big-endian integer.\n**      For non-root nodes, the first 2 bytes are left unused.\n**\n**   2. The next 2 bytes contain the number of entries currently \n**      stored in the node.\n**\n**   3. The remainder of the node contains the node entries. Each entry\n**      consists of a single 8-byte integer followed by an even number\n**      of 4-byte coordinates. For leaf nodes the integer is the rowid\n**      of a record. For internal nodes it is the node number of a\n**      child page.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RTREE)\n\n#ifndef SQLITE_CORE\n/*   #include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#else\n/*   #include \"sqlite3.h\" */\n#endif\n\n/* #include <string.h> */\n/* #include <assert.h> */\n/* #include <stdio.h> */\n\n#ifndef SQLITE_AMALGAMATION\n#include \"sqlite3rtree.h\"\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\ntypedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\n#endif\n\n/*  The following macro is used to suppress compiler warnings.\n*/\n#ifndef UNUSED_PARAMETER\n# define UNUSED_PARAMETER(x) (void)(x)\n#endif\n\ntypedef struct Rtree Rtree;\ntypedef struct RtreeCursor RtreeCursor;\ntypedef struct RtreeNode RtreeNode;\ntypedef struct RtreeCell RtreeCell;\ntypedef struct RtreeConstraint RtreeConstraint;\ntypedef struct RtreeMatchArg RtreeMatchArg;\ntypedef struct RtreeGeomCallback RtreeGeomCallback;\ntypedef union RtreeCoord RtreeCoord;\ntypedef struct RtreeSearchPoint RtreeSearchPoint;\n\n/* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */\n#define RTREE_MAX_DIMENSIONS 5\n\n/* Size of hash table Rtree.aHash. This hash table is not expected to\n** ever contain very many entries, so a fixed number of buckets is \n** used.\n*/\n#define HASHSIZE 97\n\n/* The xBestIndex method of this virtual table requires an estimate of\n** the number of rows in the virtual table to calculate the costs of\n** various strategies. If possible, this estimate is loaded from the\n** sqlite_stat1 table (with RTREE_MIN_ROWEST as a hard-coded minimum).\n** Otherwise, if no sqlite_stat1 entry is available, use \n** RTREE_DEFAULT_ROWEST.\n*/\n#define RTREE_DEFAULT_ROWEST 1048576\n#define RTREE_MIN_ROWEST         100\n\n/* \n** An rtree virtual-table object.\n*/\nstruct Rtree {\n  sqlite3_vtab base;          /* Base class.  Must be first */\n  sqlite3 *db;                /* Host database connection */\n  int iNodeSize;              /* Size in bytes of each node in the node table */\n  u8 nDim;                    /* Number of dimensions */\n  u8 nDim2;                   /* Twice the number of dimensions */\n  u8 eCoordType;              /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */\n  u8 nBytesPerCell;           /* Bytes consumed per cell */\n  u8 inWrTrans;               /* True if inside write transaction */\n  int iDepth;                 /* Current depth of the r-tree structure */\n  char *zDb;                  /* Name of database containing r-tree table */\n  char *zName;                /* Name of r-tree table */ \n  u32 nBusy;                  /* Current number of users of this structure */\n  i64 nRowEst;                /* Estimated number of rows in this table */\n  u32 nCursor;                /* Number of open cursors */\n\n  /* List of nodes removed during a CondenseTree operation. List is\n  ** linked together via the pointer normally used for hash chains -\n  ** RtreeNode.pNext. RtreeNode.iNode stores the depth of the sub-tree \n  ** headed by the node (leaf nodes have RtreeNode.iNode==0).\n  */\n  RtreeNode *pDeleted;\n  int iReinsertHeight;        /* Height of sub-trees Reinsert() has run on */\n\n  /* Blob I/O on xxx_node */\n  sqlite3_blob *pNodeBlob;\n\n  /* Statements to read/write/delete a record from xxx_node */\n  sqlite3_stmt *pWriteNode;\n  sqlite3_stmt *pDeleteNode;\n\n  /* Statements to read/write/delete a record from xxx_rowid */\n  sqlite3_stmt *pReadRowid;\n  sqlite3_stmt *pWriteRowid;\n  sqlite3_stmt *pDeleteRowid;\n\n  /* Statements to read/write/delete a record from xxx_parent */\n  sqlite3_stmt *pReadParent;\n  sqlite3_stmt *pWriteParent;\n  sqlite3_stmt *pDeleteParent;\n\n  RtreeNode *aHash[HASHSIZE]; /* Hash table of in-memory nodes. */ \n};\n\n/* Possible values for Rtree.eCoordType: */\n#define RTREE_COORD_REAL32 0\n#define RTREE_COORD_INT32  1\n\n/*\n** If SQLITE_RTREE_INT_ONLY is defined, then this virtual table will\n** only deal with integer coordinates.  No floating point operations\n** will be done.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 RtreeDValue;       /* High accuracy coordinate */\n  typedef int RtreeValue;                  /* Low accuracy coordinate */\n# define RTREE_ZERO 0\n#else\n  typedef double RtreeDValue;              /* High accuracy coordinate */\n  typedef float RtreeValue;                /* Low accuracy coordinate */\n# define RTREE_ZERO 0.0\n#endif\n\n/*\n** When doing a search of an r-tree, instances of the following structure\n** record intermediate results from the tree walk.\n**\n** The id is always a node-id.  For iLevel>=1 the id is the node-id of\n** the node that the RtreeSearchPoint represents.  When iLevel==0, however,\n** the id is of the parent node and the cell that RtreeSearchPoint\n** represents is the iCell-th entry in the parent node.\n*/\nstruct RtreeSearchPoint {\n  RtreeDValue rScore;    /* The score for this node.  Smallest goes first. */\n  sqlite3_int64 id;      /* Node ID */\n  u8 iLevel;             /* 0=entries.  1=leaf node.  2+ for higher */\n  u8 eWithin;            /* PARTLY_WITHIN or FULLY_WITHIN */\n  u8 iCell;              /* Cell index within the node */\n};\n\n/*\n** The minimum number of cells allowed for a node is a third of the \n** maximum. In Gutman's notation:\n**\n**     m = M/3\n**\n** If an R*-tree \"Reinsert\" operation is required, the same number of\n** cells are removed from the overfull node and reinserted into the tree.\n*/\n#define RTREE_MINCELLS(p) ((((p)->iNodeSize-4)/(p)->nBytesPerCell)/3)\n#define RTREE_REINSERT(p) RTREE_MINCELLS(p)\n#define RTREE_MAXCELLS 51\n\n/*\n** The smallest possible node-size is (512-64)==448 bytes. And the largest\n** supported cell size is 48 bytes (8 byte rowid + ten 4 byte coordinates).\n** Therefore all non-root nodes must contain at least 3 entries. Since \n** 2^40 is greater than 2^64, an r-tree structure always has a depth of\n** 40 or less.\n*/\n#define RTREE_MAX_DEPTH 40\n\n\n/*\n** Number of entries in the cursor RtreeNode cache.  The first entry is\n** used to cache the RtreeNode for RtreeCursor.sPoint.  The remaining\n** entries cache the RtreeNode for the first elements of the priority queue.\n*/\n#define RTREE_CACHE_SZ  5\n\n/* \n** An rtree cursor object.\n*/\nstruct RtreeCursor {\n  sqlite3_vtab_cursor base;         /* Base class.  Must be first */\n  u8 atEOF;                         /* True if at end of search */\n  u8 bPoint;                        /* True if sPoint is valid */\n  int iStrategy;                    /* Copy of idxNum search parameter */\n  int nConstraint;                  /* Number of entries in aConstraint */\n  RtreeConstraint *aConstraint;     /* Search constraints. */\n  int nPointAlloc;                  /* Number of slots allocated for aPoint[] */\n  int nPoint;                       /* Number of slots used in aPoint[] */\n  int mxLevel;                      /* iLevel value for root of the tree */\n  RtreeSearchPoint *aPoint;         /* Priority queue for search points */\n  RtreeSearchPoint sPoint;          /* Cached next search point */\n  RtreeNode *aNode[RTREE_CACHE_SZ]; /* Rtree node cache */\n  u32 anQueue[RTREE_MAX_DEPTH+1];   /* Number of queued entries by iLevel */\n};\n\n/* Return the Rtree of a RtreeCursor */\n#define RTREE_OF_CURSOR(X)   ((Rtree*)((X)->base.pVtab))\n\n/*\n** A coordinate can be either a floating point number or a integer.  All\n** coordinates within a single R-Tree are always of the same time.\n*/\nunion RtreeCoord {\n  RtreeValue f;      /* Floating point value */\n  int i;             /* Integer value */\n  u32 u;             /* Unsigned for byte-order conversions */\n};\n\n/*\n** The argument is an RtreeCoord. Return the value stored within the RtreeCoord\n** formatted as a RtreeDValue (double or int64). This macro assumes that local\n** variable pRtree points to the Rtree structure associated with the\n** RtreeCoord.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n# define DCOORD(coord) ((RtreeDValue)coord.i)\n#else\n# define DCOORD(coord) (                           \\\n    (pRtree->eCoordType==RTREE_COORD_REAL32) ?      \\\n      ((double)coord.f) :                           \\\n      ((double)coord.i)                             \\\n  )\n#endif\n\n/*\n** A search constraint.\n*/\nstruct RtreeConstraint {\n  int iCoord;                     /* Index of constrained coordinate */\n  int op;                         /* Constraining operation */\n  union {\n    RtreeDValue rValue;             /* Constraint value. */\n    int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*);\n    int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  } u;\n  sqlite3_rtree_query_info *pInfo;  /* xGeom and xQueryFunc argument */\n};\n\n/* Possible values for RtreeConstraint.op */\n#define RTREE_EQ    0x41  /* A */\n#define RTREE_LE    0x42  /* B */\n#define RTREE_LT    0x43  /* C */\n#define RTREE_GE    0x44  /* D */\n#define RTREE_GT    0x45  /* E */\n#define RTREE_MATCH 0x46  /* F: Old-style sqlite3_rtree_geometry_callback() */\n#define RTREE_QUERY 0x47  /* G: New-style sqlite3_rtree_query_callback() */\n\n\n/* \n** An rtree structure node.\n*/\nstruct RtreeNode {\n  RtreeNode *pParent;         /* Parent node */\n  i64 iNode;                  /* The node number */\n  int nRef;                   /* Number of references to this node */\n  int isDirty;                /* True if the node needs to be written to disk */\n  u8 *zData;                  /* Content of the node, as should be on disk */\n  RtreeNode *pNext;           /* Next node in this hash collision chain */\n};\n\n/* Return the number of cells in a node  */\n#define NCELL(pNode) readInt16(&(pNode)->zData[2])\n\n/* \n** A single cell from a node, deserialized\n*/\nstruct RtreeCell {\n  i64 iRowid;                                 /* Node or entry ID */\n  RtreeCoord aCoord[RTREE_MAX_DIMENSIONS*2];  /* Bounding box coordinates */\n};\n\n\n/*\n** This object becomes the sqlite3_user_data() for the SQL functions\n** that are created by sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() and which appear on the right of MATCH\n** operators in order to constrain a search.\n**\n** xGeom and xQueryFunc are the callback functions.  Exactly one of \n** xGeom and xQueryFunc fields is non-NULL, depending on whether the\n** SQL function was created using sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback().\n** \n** This object is deleted automatically by the destructor mechanism in\n** sqlite3_create_function_v2().\n*/\nstruct RtreeGeomCallback {\n  int (*xGeom)(sqlite3_rtree_geometry*, int, RtreeDValue*, int*);\n  int (*xQueryFunc)(sqlite3_rtree_query_info*);\n  void (*xDestructor)(void*);\n  void *pContext;\n};\n\n/*\n** An instance of this structure (in the form of a BLOB) is returned by\n** the SQL functions that sqlite3_rtree_geometry_callback() and\n** sqlite3_rtree_query_callback() create, and is read as the right-hand\n** operand to the MATCH operator of an R-Tree.\n*/\nstruct RtreeMatchArg {\n  u32 iSize;                  /* Size of this object */\n  RtreeGeomCallback cb;       /* Info about the callback functions */\n  int nParam;                 /* Number of parameters to the SQL function */\n  sqlite3_value **apSqlParam; /* Original SQL parameter values */\n  RtreeDValue aParam[1];      /* Values for parameters to the SQL function */\n};\n\n#ifndef MAX\n# define MAX(x,y) ((x) < (y) ? (y) : (x))\n#endif\n#ifndef MIN\n# define MIN(x,y) ((x) > (y) ? (y) : (x))\n#endif\n\n/* What version of GCC is being used.  0 means GCC is not being used .\n** Note that the GCC_VERSION macro will also be set correctly when using\n** clang, since clang works hard to be gcc compatible.  So the gcc\n** optimizations will also work when compiling with clang.\n*/\n#ifndef GCC_VERSION\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#endif\n\n/* The testcase() macro should already be defined in the amalgamation.  If\n** it is not, make it a no-op.\n*/\n#ifndef SQLITE_AMALGAMATION\n# define testcase(X)\n#endif\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n#if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n    defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n    defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n    defined(__arm__)\n# define SQLITE_BYTEORDER    1234\n#elif defined(sparc)    || defined(__ppc__)\n# define SQLITE_BYTEORDER    4321\n#else\n# define SQLITE_BYTEORDER    0     /* 0 means \"unknown at compile-time\" */\n#endif\n#endif\n\n\n/* What version of MSVC is being used.  0 means MSVC is not being used */\n#ifndef MSVC_VERSION\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n#endif\n\n/*\n** Functions to deserialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The deserialized value is returned.\n*/\nstatic int readInt16(u8 *p){\n  return (p[0]<<8) + p[1];\n}\nstatic void readCoord(u8 *p, RtreeCoord *pCoord){\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  pCoord->u = _byteswap_ulong(*(u32*)p);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  pCoord->u = __builtin_bswap32(*(u32*)p);\n#elif SQLITE_BYTEORDER==4321\n  pCoord->u = *(u32*)p;\n#else\n  pCoord->u = (\n    (((u32)p[0]) << 24) + \n    (((u32)p[1]) << 16) + \n    (((u32)p[2]) <<  8) + \n    (((u32)p[3]) <<  0)\n  );\n#endif\n}\nstatic i64 readInt64(u8 *p){\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)_byteswap_uint64(x);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u64 x;\n  memcpy(&x, p, 8);\n  return (i64)__builtin_bswap64(x);\n#elif SQLITE_BYTEORDER==4321\n  i64 x;\n  memcpy(&x, p, 8);\n  return x;\n#else\n  return (i64)(\n    (((u64)p[0]) << 56) + \n    (((u64)p[1]) << 48) + \n    (((u64)p[2]) << 40) + \n    (((u64)p[3]) << 32) + \n    (((u64)p[4]) << 24) + \n    (((u64)p[5]) << 16) + \n    (((u64)p[6]) <<  8) + \n    (((u64)p[7]) <<  0)\n  );\n#endif\n}\n\n/*\n** Functions to serialize a 16 bit integer, 32 bit real number and\n** 64 bit integer. The value returned is the number of bytes written\n** to the argument buffer (always 2, 4 and 8 respectively).\n*/\nstatic void writeInt16(u8 *p, int i){\n  p[0] = (i>> 8)&0xFF;\n  p[1] = (i>> 0)&0xFF;\n}\nstatic int writeCoord(u8 *p, RtreeCoord *pCoord){\n  u32 i;\n  assert( ((((char*)p) - (char*)0)&3)==0 );  /* p is always 4-byte aligned */\n  assert( sizeof(RtreeCoord)==4 );\n  assert( sizeof(u32)==4 );\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = __builtin_bswap32(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = _byteswap_ulong(pCoord->u);\n  memcpy(p, &i, 4);\n#elif SQLITE_BYTEORDER==4321\n  i = pCoord->u;\n  memcpy(p, &i, 4);\n#else\n  i = pCoord->u;\n  p[0] = (i>>24)&0xFF;\n  p[1] = (i>>16)&0xFF;\n  p[2] = (i>> 8)&0xFF;\n  p[3] = (i>> 0)&0xFF;\n#endif\n  return 4;\n}\nstatic int writeInt64(u8 *p, i64 i){\n#if SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  i = (i64)__builtin_bswap64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  i = (i64)_byteswap_uint64((u64)i);\n  memcpy(p, &i, 8);\n#elif SQLITE_BYTEORDER==4321\n  memcpy(p, &i, 8);\n#else\n  p[0] = (i>>56)&0xFF;\n  p[1] = (i>>48)&0xFF;\n  p[2] = (i>>40)&0xFF;\n  p[3] = (i>>32)&0xFF;\n  p[4] = (i>>24)&0xFF;\n  p[5] = (i>>16)&0xFF;\n  p[6] = (i>> 8)&0xFF;\n  p[7] = (i>> 0)&0xFF;\n#endif\n  return 8;\n}\n\n/*\n** Increment the reference count of node p.\n*/\nstatic void nodeReference(RtreeNode *p){\n  if( p ){\n    p->nRef++;\n  }\n}\n\n/*\n** Clear the content of node p (set all bytes to 0x00).\n*/\nstatic void nodeZero(Rtree *pRtree, RtreeNode *p){\n  memset(&p->zData[2], 0, pRtree->iNodeSize-2);\n  p->isDirty = 1;\n}\n\n/*\n** Given a node number iNode, return the corresponding key to use\n** in the Rtree.aHash table.\n*/\nstatic int nodeHash(i64 iNode){\n  return iNode % HASHSIZE;\n}\n\n/*\n** Search the node hash table for node iNode. If found, return a pointer\n** to it. Otherwise, return 0.\n*/\nstatic RtreeNode *nodeHashLookup(Rtree *pRtree, i64 iNode){\n  RtreeNode *p;\n  for(p=pRtree->aHash[nodeHash(iNode)]; p && p->iNode!=iNode; p=p->pNext);\n  return p;\n}\n\n/*\n** Add node pNode to the node hash table.\n*/\nstatic void nodeHashInsert(Rtree *pRtree, RtreeNode *pNode){\n  int iHash;\n  assert( pNode->pNext==0 );\n  iHash = nodeHash(pNode->iNode);\n  pNode->pNext = pRtree->aHash[iHash];\n  pRtree->aHash[iHash] = pNode;\n}\n\n/*\n** Remove node pNode from the node hash table.\n*/\nstatic void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode **pp;\n  if( pNode->iNode!=0 ){\n    pp = &pRtree->aHash[nodeHash(pNode->iNode)];\n    for( ; (*pp)!=pNode; pp = &(*pp)->pNext){ assert(*pp); }\n    *pp = pNode->pNext;\n    pNode->pNext = 0;\n  }\n}\n\n/*\n** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0),\n** indicating that node has not yet been assigned a node number. It is\n** assigned a node number when nodeWrite() is called to write the\n** node contents out to the database.\n*/\nstatic RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){\n  RtreeNode *pNode;\n  pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);\n  if( pNode ){\n    memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);\n    pNode->zData = (u8 *)&pNode[1];\n    pNode->nRef = 1;\n    pNode->pParent = pParent;\n    pNode->isDirty = 1;\n    nodeReference(pParent);\n  }\n  return pNode;\n}\n\n/*\n** Clear the Rtree.pNodeBlob object\n*/\nstatic void nodeBlobReset(Rtree *pRtree){\n  if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    sqlite3_blob_close(pBlob);\n  }\n}\n\n/*\n** Obtain a reference to an r-tree node.\n*/\nstatic int nodeAcquire(\n  Rtree *pRtree,             /* R-tree structure */\n  i64 iNode,                 /* Node number to load */\n  RtreeNode *pParent,        /* Either the parent node or NULL */\n  RtreeNode **ppNode         /* OUT: Acquired node */\n){\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = 0;\n\n  /* Check if the requested node is already in the hash table. If so,\n  ** increase its reference count and return it.\n  */\n  if( (pNode = nodeHashLookup(pRtree, iNode)) ){\n    assert( !pParent || !pNode->pParent || pNode->pParent==pParent );\n    if( pParent && !pNode->pParent ){\n      nodeReference(pParent);\n      pNode->pParent = pParent;\n    }\n    pNode->nRef++;\n    *ppNode = pNode;\n    return SQLITE_OK;\n  }\n\n  if( pRtree->pNodeBlob ){\n    sqlite3_blob *pBlob = pRtree->pNodeBlob;\n    pRtree->pNodeBlob = 0;\n    rc = sqlite3_blob_reopen(pBlob, iNode);\n    pRtree->pNodeBlob = pBlob;\n    if( rc ){\n      nodeBlobReset(pRtree);\n      if( rc==SQLITE_NOMEM ) return SQLITE_NOMEM;\n    }\n  }\n  if( pRtree->pNodeBlob==0 ){\n    char *zTab = sqlite3_mprintf(\"%s_node\", pRtree->zName);\n    if( zTab==0 ) return SQLITE_NOMEM;\n    rc = sqlite3_blob_open(pRtree->db, pRtree->zDb, zTab, \"data\", iNode, 0,\n                           &pRtree->pNodeBlob);\n    sqlite3_free(zTab);\n  }\n  if( rc ){\n    nodeBlobReset(pRtree);\n    *ppNode = 0;\n    /* If unable to open an sqlite3_blob on the desired row, that can only\n    ** be because the shadow tables hold erroneous data. */\n    if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB;\n  }else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){\n    pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);\n    if( !pNode ){\n      rc = SQLITE_NOMEM;\n    }else{\n      pNode->pParent = pParent;\n      pNode->zData = (u8 *)&pNode[1];\n      pNode->nRef = 1;\n      pNode->iNode = iNode;\n      pNode->isDirty = 0;\n      pNode->pNext = 0;\n      rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,\n                             pRtree->iNodeSize, 0);\n      nodeReference(pParent);\n    }\n  }\n\n  /* If the root node was just loaded, set pRtree->iDepth to the height\n  ** of the r-tree structure. A height of zero means all data is stored on\n  ** the root node. A height of one means the children of the root node\n  ** are the leaves, and so on. If the depth as specified on the root node\n  ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt.\n  */\n  if( pNode && iNode==1 ){\n    pRtree->iDepth = readInt16(pNode->zData);\n    if( pRtree->iDepth>RTREE_MAX_DEPTH ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  /* If no error has occurred so far, check if the \"number of entries\"\n  ** field on the node is too large. If so, set the return code to \n  ** SQLITE_CORRUPT_VTAB.\n  */\n  if( pNode && rc==SQLITE_OK ){\n    if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( pNode!=0 ){\n      nodeHashInsert(pRtree, pNode);\n    }else{\n      rc = SQLITE_CORRUPT_VTAB;\n    }\n    *ppNode = pNode;\n  }else{\n    sqlite3_free(pNode);\n    *ppNode = 0;\n  }\n\n  return rc;\n}\n\n/*\n** Overwrite cell iCell of node pNode with the contents of pCell.\n*/\nstatic void nodeOverwriteCell(\n  Rtree *pRtree,             /* The overall R-Tree */\n  RtreeNode *pNode,          /* The node into which the cell is to be written */\n  RtreeCell *pCell,          /* The cell to write */\n  int iCell                  /* Index into pNode into which pCell is written */\n){\n  int ii;\n  u8 *p = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  p += writeInt64(p, pCell->iRowid);\n  for(ii=0; ii<pRtree->nDim2; ii++){\n    p += writeCoord(p, &pCell->aCoord[ii]);\n  }\n  pNode->isDirty = 1;\n}\n\n/*\n** Remove the cell with index iCell from node pNode.\n*/\nstatic void nodeDeleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell){\n  u8 *pDst = &pNode->zData[4 + pRtree->nBytesPerCell*iCell];\n  u8 *pSrc = &pDst[pRtree->nBytesPerCell];\n  int nByte = (NCELL(pNode) - iCell - 1) * pRtree->nBytesPerCell;\n  memmove(pDst, pSrc, nByte);\n  writeInt16(&pNode->zData[2], NCELL(pNode)-1);\n  pNode->isDirty = 1;\n}\n\n/*\n** Insert the contents of cell pCell into node pNode. If the insert\n** is successful, return SQLITE_OK.\n**\n** If there is not enough free space in pNode, return SQLITE_FULL.\n*/\nstatic int nodeInsertCell(\n  Rtree *pRtree,                /* The overall R-Tree */\n  RtreeNode *pNode,             /* Write new cell into this node */\n  RtreeCell *pCell              /* The cell to be inserted */\n){\n  int nCell;                    /* Current number of cells in pNode */\n  int nMaxCell;                 /* Maximum number of cells for pNode */\n\n  nMaxCell = (pRtree->iNodeSize-4)/pRtree->nBytesPerCell;\n  nCell = NCELL(pNode);\n\n  assert( nCell<=nMaxCell );\n  if( nCell<nMaxCell ){\n    nodeOverwriteCell(pRtree, pNode, pCell, nCell);\n    writeInt16(&pNode->zData[2], nCell+1);\n    pNode->isDirty = 1;\n  }\n\n  return (nCell==nMaxCell);\n}\n\n/*\n** If the node is dirty, write it out to the database.\n*/\nstatic int nodeWrite(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode->isDirty ){\n    sqlite3_stmt *p = pRtree->pWriteNode;\n    if( pNode->iNode ){\n      sqlite3_bind_int64(p, 1, pNode->iNode);\n    }else{\n      sqlite3_bind_null(p, 1);\n    }\n    sqlite3_bind_blob(p, 2, pNode->zData, pRtree->iNodeSize, SQLITE_STATIC);\n    sqlite3_step(p);\n    pNode->isDirty = 0;\n    rc = sqlite3_reset(p);\n    if( pNode->iNode==0 && rc==SQLITE_OK ){\n      pNode->iNode = sqlite3_last_insert_rowid(pRtree->db);\n      nodeHashInsert(pRtree, pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Release a reference to a node. If the node is dirty and the reference\n** count drops to zero, the node data is written to the database.\n*/\nstatic int nodeRelease(Rtree *pRtree, RtreeNode *pNode){\n  int rc = SQLITE_OK;\n  if( pNode ){\n    assert( pNode->nRef>0 );\n    pNode->nRef--;\n    if( pNode->nRef==0 ){\n      if( pNode->iNode==1 ){\n        pRtree->iDepth = -1;\n      }\n      if( pNode->pParent ){\n        rc = nodeRelease(pRtree, pNode->pParent);\n      }\n      if( rc==SQLITE_OK ){\n        rc = nodeWrite(pRtree, pNode);\n      }\n      nodeHashDelete(pRtree, pNode);\n      sqlite3_free(pNode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the 64-bit integer value associated with cell iCell of\n** node pNode. If pNode is a leaf node, this is a rowid. If it is\n** an internal node, then the 64-bit integer is a child page number.\n*/\nstatic i64 nodeGetRowid(\n  Rtree *pRtree,       /* The overall R-Tree */\n  RtreeNode *pNode,    /* The node from which to extract the ID */\n  int iCell            /* The cell index from which to extract the ID */\n){\n  assert( iCell<NCELL(pNode) );\n  return readInt64(&pNode->zData[4 + pRtree->nBytesPerCell*iCell]);\n}\n\n/*\n** Return coordinate iCoord from cell iCell in node pNode.\n*/\nstatic void nodeGetCoord(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node from which to extract a coordinate */\n  int iCell,                   /* The index of the cell within the node */\n  int iCoord,                  /* Which coordinate to extract */\n  RtreeCoord *pCoord           /* OUT: Space to write result to */\n){\n  readCoord(&pNode->zData[12 + pRtree->nBytesPerCell*iCell + 4*iCoord], pCoord);\n}\n\n/*\n** Deserialize cell iCell of node pNode. Populate the structure pointed\n** to by pCell with the results.\n*/\nstatic void nodeGetCell(\n  Rtree *pRtree,               /* The overall R-Tree */\n  RtreeNode *pNode,            /* The node containing the cell to be read */\n  int iCell,                   /* Index of the cell within the node */\n  RtreeCell *pCell             /* OUT: Write the cell contents here */\n){\n  u8 *pData;\n  RtreeCoord *pCoord;\n  int ii = 0;\n  pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);\n  pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell);\n  pCoord = pCell->aCoord;\n  do{\n    readCoord(pData, &pCoord[ii]);\n    readCoord(pData+4, &pCoord[ii+1]);\n    pData += 8;\n    ii += 2;\n  }while( ii<pRtree->nDim2 );\n}\n\n\n/* Forward declaration for the function that does the work of\n** the virtual table module xCreate() and xConnect() methods.\n*/\nstatic int rtreeInit(\n  sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **, int\n);\n\n/* \n** Rtree virtual table module xCreate method.\n*/\nstatic int rtreeCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 1);\n}\n\n/* \n** Rtree virtual table module xConnect method.\n*/\nstatic int rtreeConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  return rtreeInit(db, pAux, argc, argv, ppVtab, pzErr, 0);\n}\n\n/*\n** Increment the r-tree reference count.\n*/\nstatic void rtreeReference(Rtree *pRtree){\n  pRtree->nBusy++;\n}\n\n/*\n** Decrement the r-tree reference count. When the reference count reaches\n** zero the structure is deleted.\n*/\nstatic void rtreeRelease(Rtree *pRtree){\n  pRtree->nBusy--;\n  if( pRtree->nBusy==0 ){\n    pRtree->inWrTrans = 0;\n    pRtree->nCursor = 0;\n    nodeBlobReset(pRtree);\n    sqlite3_finalize(pRtree->pWriteNode);\n    sqlite3_finalize(pRtree->pDeleteNode);\n    sqlite3_finalize(pRtree->pReadRowid);\n    sqlite3_finalize(pRtree->pWriteRowid);\n    sqlite3_finalize(pRtree->pDeleteRowid);\n    sqlite3_finalize(pRtree->pReadParent);\n    sqlite3_finalize(pRtree->pWriteParent);\n    sqlite3_finalize(pRtree->pDeleteParent);\n    sqlite3_free(pRtree);\n  }\n}\n\n/* \n** Rtree virtual table module xDisconnect method.\n*/\nstatic int rtreeDisconnect(sqlite3_vtab *pVtab){\n  rtreeRelease((Rtree *)pVtab);\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xDestroy method.\n*/\nstatic int rtreeDestroy(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc;\n  char *zCreate = sqlite3_mprintf(\n    \"DROP TABLE '%q'.'%q_node';\"\n    \"DROP TABLE '%q'.'%q_rowid';\"\n    \"DROP TABLE '%q'.'%q_parent';\",\n    pRtree->zDb, pRtree->zName, \n    pRtree->zDb, pRtree->zName,\n    pRtree->zDb, pRtree->zName\n  );\n  if( !zCreate ){\n    rc = SQLITE_NOMEM;\n  }else{\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n  }\n  if( rc==SQLITE_OK ){\n    rtreeRelease(pRtree);\n  }\n\n  return rc;\n}\n\n/* \n** Rtree virtual table module xOpen method.\n*/\nstatic int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  Rtree *pRtree = (Rtree *)pVTab;\n  RtreeCursor *pCsr;\n\n  pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));\n  if( pCsr ){\n    memset(pCsr, 0, sizeof(RtreeCursor));\n    pCsr->base.pVtab = pVTab;\n    rc = SQLITE_OK;\n    pRtree->nCursor++;\n  }\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n\n  return rc;\n}\n\n\n/*\n** Free the RtreeCursor.aConstraint[] array and its contents.\n*/\nstatic void freeCursorConstraints(RtreeCursor *pCsr){\n  if( pCsr->aConstraint ){\n    int i;                        /* Used to iterate through constraint array */\n    for(i=0; i<pCsr->nConstraint; i++){\n      sqlite3_rtree_query_info *pInfo = pCsr->aConstraint[i].pInfo;\n      if( pInfo ){\n        if( pInfo->xDelUser ) pInfo->xDelUser(pInfo->pUser);\n        sqlite3_free(pInfo);\n      }\n    }\n    sqlite3_free(pCsr->aConstraint);\n    pCsr->aConstraint = 0;\n  }\n}\n\n/* \n** Rtree virtual table module xClose method.\n*/\nstatic int rtreeClose(sqlite3_vtab_cursor *cur){\n  Rtree *pRtree = (Rtree *)(cur->pVtab);\n  int ii;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  assert( pRtree->nCursor>0 );\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  for(ii=0; ii<RTREE_CACHE_SZ; ii++) nodeRelease(pRtree, pCsr->aNode[ii]);\n  sqlite3_free(pCsr);\n  pRtree->nCursor--;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** Rtree virtual table module xEof method.\n**\n** Return non-zero if the cursor does not currently point to a valid \n** record (i.e if the scan has finished), or zero otherwise.\n*/\nstatic int rtreeEof(sqlite3_vtab_cursor *cur){\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  return pCsr->atEOF;\n}\n\n/*\n** Convert raw bits from the on-disk RTree record into a coordinate value.\n** The on-disk format is big-endian and needs to be converted for little-\n** endian platforms.  The on-disk record stores integer coordinates if\n** eInt is true and it stores 32-bit floating point records if eInt is\n** false.  a[] is the four bytes of the on-disk record to be decoded.\n** Store the results in \"r\".\n**\n** There are five versions of this macro.  The last one is generic.  The\n** other four are various architectures-specific optimizations.\n*/\n#if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = _byteswap_ulong(*(u32*)a);                            \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = __builtin_bswap32(*(u32*)a);                          \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==1234\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    c.u = ((c.u>>24)&0xff)|((c.u>>8)&0xff00)|                   \\\n          ((c.u&0xff)<<24)|((c.u&0xff00)<<8);                   \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#elif SQLITE_BYTEORDER==4321\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    memcpy(&c.u,a,4);                                           \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#else\n#define RTREE_DECODE_COORD(eInt, a, r) {                        \\\n    RtreeCoord c;    /* Coordinate decoded */                   \\\n    c.u = ((u32)a[0]<<24) + ((u32)a[1]<<16)                     \\\n           +((u32)a[2]<<8) + a[3];                              \\\n    r = eInt ? (sqlite3_rtree_dbl)c.i : (sqlite3_rtree_dbl)c.f; \\\n}\n#endif\n\n/*\n** Check the RTree node or entry given by pCellData and p against the MATCH\n** constraint pConstraint.  \n*/\nstatic int rtreeCallbackConstraint(\n  RtreeConstraint *pConstraint,  /* The constraint to test */\n  int eInt,                      /* True if RTree holding integer coordinates */\n  u8 *pCellData,                 /* Raw cell content */\n  RtreeSearchPoint *pSearch,     /* Container of this cell */\n  sqlite3_rtree_dbl *prScore,    /* OUT: score for the cell */\n  int *peWithin                  /* OUT: visibility of the cell */\n){\n  sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */\n  int nCoord = pInfo->nCoord;                           /* No. of coordinates */\n  int rc;                                             /* Callback return code */\n  RtreeCoord c;                                       /* Translator union */\n  sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2];   /* Decoded coordinates */\n\n  assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY );\n  assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 );\n\n  if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){\n    pInfo->iRowid = readInt64(pCellData);\n  }\n  pCellData += 8;\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( eInt==0 ){\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.f;\n                readCoord(pCellData+32, &c); aCoord[8] = c.f;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.f;\n                readCoord(pCellData+24, &c); aCoord[6] = c.f;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.f;\n                readCoord(pCellData+16, &c); aCoord[4] = c.f;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.f;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.f;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.f;\n                readCoord(pCellData,    &c); aCoord[0] = c.f;\n    }\n  }else\n#endif\n  {\n    switch( nCoord ){\n      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.i;\n                readCoord(pCellData+32, &c); aCoord[8] = c.i;\n      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.i;\n                readCoord(pCellData+24, &c); aCoord[6] = c.i;\n      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.i;\n                readCoord(pCellData+16, &c); aCoord[4] = c.i;\n      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.i;\n                readCoord(pCellData+8,  &c); aCoord[2] = c.i;\n      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.i;\n                readCoord(pCellData,    &c); aCoord[0] = c.i;\n    }\n  }\n  if( pConstraint->op==RTREE_MATCH ){\n    int eWithin = 0;\n    rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo,\n                              nCoord, aCoord, &eWithin);\n    if( eWithin==0 ) *peWithin = NOT_WITHIN;\n    *prScore = RTREE_ZERO;\n  }else{\n    pInfo->aCoord = aCoord;\n    pInfo->iLevel = pSearch->iLevel - 1;\n    pInfo->rScore = pInfo->rParentScore = pSearch->rScore;\n    pInfo->eWithin = pInfo->eParentWithin = pSearch->eWithin;\n    rc = pConstraint->u.xQueryFunc(pInfo);\n    if( pInfo->eWithin<*peWithin ) *peWithin = pInfo->eWithin;\n    if( pInfo->rScore<*prScore || *prScore<RTREE_ZERO ){\n      *prScore = pInfo->rScore;\n    }\n  }\n  return rc;\n}\n\n/* \n** Check the internal RTree node given by pCellData against constraint p.\n** If this constraint cannot be satisfied by any child within the node,\n** set *peWithin to NOT_WITHIN.\n*/\nstatic void rtreeNonleafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  sqlite3_rtree_dbl val;     /* Coordinate value convert to a double */\n\n  /* p->iCoord might point to either a lower or upper bound coordinate\n  ** in a coordinate pair.  But make pCellData point to the lower bound.\n  */\n  pCellData += 8 + 4*(p->iCoord&0xfe);\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  switch( p->op ){\n    case RTREE_LE:\n    case RTREE_LT:\n    case RTREE_EQ:\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the lower bound of the coordinate pair */\n      if( p->u.rValue>=val ) return;\n      if( p->op!=RTREE_EQ ) break;  /* RTREE_LE and RTREE_LT end here */\n      /* Fall through for the RTREE_EQ case */\n\n    default: /* RTREE_GT or RTREE_GE,  or fallthrough of RTREE_EQ */\n      pCellData += 4;\n      RTREE_DECODE_COORD(eInt, pCellData, val);\n      /* val now holds the upper bound of the coordinate pair */\n      if( p->u.rValue<=val ) return;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** Check the leaf RTree cell given by pCellData against constraint p.\n** If this constraint is not satisfied, set *peWithin to NOT_WITHIN.\n** If the constraint is satisfied, leave *peWithin unchanged.\n**\n** The constraint is of the form:  xN op $val\n**\n** The op is given by p->op.  The xN is p->iCoord-th coordinate in\n** pCellData.  $val is given by p->u.rValue.\n*/\nstatic void rtreeLeafConstraint(\n  RtreeConstraint *p,        /* The constraint to test */\n  int eInt,                  /* True if RTree holds integer coordinates */\n  u8 *pCellData,             /* Raw cell content as appears on disk */\n  int *peWithin              /* Adjust downward, as appropriate */\n){\n  RtreeDValue xN;      /* Coordinate value converted to a double */\n\n  assert(p->op==RTREE_LE || p->op==RTREE_LT || p->op==RTREE_GE \n      || p->op==RTREE_GT || p->op==RTREE_EQ );\n  pCellData += 8 + p->iCoord*4;\n  assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */\n  RTREE_DECODE_COORD(eInt, pCellData, xN);\n  switch( p->op ){\n    case RTREE_LE: if( xN <= p->u.rValue ) return;  break;\n    case RTREE_LT: if( xN <  p->u.rValue ) return;  break;\n    case RTREE_GE: if( xN >= p->u.rValue ) return;  break;\n    case RTREE_GT: if( xN >  p->u.rValue ) return;  break;\n    default:       if( xN == p->u.rValue ) return;  break;\n  }\n  *peWithin = NOT_WITHIN;\n}\n\n/*\n** One of the cells in node pNode is guaranteed to have a 64-bit \n** integer value equal to iRowid. Return the index of this cell.\n*/\nstatic int nodeRowidIndex(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  i64 iRowid,\n  int *piIndex\n){\n  int ii;\n  int nCell = NCELL(pNode);\n  assert( nCell<200 );\n  for(ii=0; ii<nCell; ii++){\n    if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){\n      *piIndex = ii;\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_CORRUPT_VTAB;\n}\n\n/*\n** Return the index of the cell containing a pointer to node pNode\n** in its parent. If pNode is the root node, return -1.\n*/\nstatic int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){\n  RtreeNode *pParent = pNode->pParent;\n  if( pParent ){\n    return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex);\n  }\n  *piIndex = -1;\n  return SQLITE_OK;\n}\n\n/*\n** Compare two search points.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second.\n**\n** The rScore is the primary key.  Smaller rScore values come first.\n** If the rScore is a tie, then use iLevel as the tie breaker with smaller\n** iLevel values coming first.  In this way, if rScore is the same for all\n** SearchPoints, then iLevel becomes the deciding factor and the result\n** is a depth-first search, which is the desired default behavior.\n*/\nstatic int rtreeSearchPointCompare(\n  const RtreeSearchPoint *pA,\n  const RtreeSearchPoint *pB\n){\n  if( pA->rScore<pB->rScore ) return -1;\n  if( pA->rScore>pB->rScore ) return +1;\n  if( pA->iLevel<pB->iLevel ) return -1;\n  if( pA->iLevel>pB->iLevel ) return +1;\n  return 0;\n}\n\n/*\n** Interchange two search points in a cursor.\n*/\nstatic void rtreeSearchPointSwap(RtreeCursor *p, int i, int j){\n  RtreeSearchPoint t = p->aPoint[i];\n  assert( i<j );\n  p->aPoint[i] = p->aPoint[j];\n  p->aPoint[j] = t;\n  i++; j++;\n  if( i<RTREE_CACHE_SZ ){\n    if( j>=RTREE_CACHE_SZ ){\n      nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n      p->aNode[i] = 0;\n    }else{\n      RtreeNode *pTemp = p->aNode[i];\n      p->aNode[i] = p->aNode[j];\n      p->aNode[j] = pTemp;\n    }\n  }\n}\n\n/*\n** Return the search point with the lowest current score.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointFirst(RtreeCursor *pCur){\n  return pCur->bPoint ? &pCur->sPoint : pCur->nPoint ? pCur->aPoint : 0;\n}\n\n/*\n** Get the RtreeNode for the search point with the lowest score.\n*/\nstatic RtreeNode *rtreeNodeOfFirstSearchPoint(RtreeCursor *pCur, int *pRC){\n  sqlite3_int64 id;\n  int ii = 1 - pCur->bPoint;\n  assert( ii==0 || ii==1 );\n  assert( pCur->bPoint || pCur->nPoint );\n  if( pCur->aNode[ii]==0 ){\n    assert( pRC!=0 );\n    id = ii ? pCur->aPoint[0].id : pCur->sPoint.id;\n    *pRC = nodeAcquire(RTREE_OF_CURSOR(pCur), id, 0, &pCur->aNode[ii]);\n  }\n  return pCur->aNode[ii];\n}\n\n/*\n** Push a new element onto the priority queue\n*/\nstatic RtreeSearchPoint *rtreeEnqueue(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  int i, j;\n  RtreeSearchPoint *pNew;\n  if( pCur->nPoint>=pCur->nPointAlloc ){\n    int nNew = pCur->nPointAlloc*2 + 8;\n    pNew = sqlite3_realloc(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));\n    if( pNew==0 ) return 0;\n    pCur->aPoint = pNew;\n    pCur->nPointAlloc = nNew;\n  }\n  i = pCur->nPoint++;\n  pNew = pCur->aPoint + i;\n  pNew->rScore = rScore;\n  pNew->iLevel = iLevel;\n  assert( iLevel<=RTREE_MAX_DEPTH );\n  while( i>0 ){\n    RtreeSearchPoint *pParent;\n    j = (i-1)/2;\n    pParent = pCur->aPoint + j;\n    if( rtreeSearchPointCompare(pNew, pParent)>=0 ) break;\n    rtreeSearchPointSwap(pCur, j, i);\n    i = j;\n    pNew = pParent;\n  }\n  return pNew;\n}\n\n/*\n** Allocate a new RtreeSearchPoint and return a pointer to it.  Return\n** NULL if malloc fails.\n*/\nstatic RtreeSearchPoint *rtreeSearchPointNew(\n  RtreeCursor *pCur,    /* The cursor */\n  RtreeDValue rScore,   /* Score for the new search point */\n  u8 iLevel             /* Level for the new search point */\n){\n  RtreeSearchPoint *pNew, *pFirst;\n  pFirst = rtreeSearchPointFirst(pCur);\n  pCur->anQueue[iLevel]++;\n  if( pFirst==0\n   || pFirst->rScore>rScore \n   || (pFirst->rScore==rScore && pFirst->iLevel>iLevel)\n  ){\n    if( pCur->bPoint ){\n      int ii;\n      pNew = rtreeEnqueue(pCur, rScore, iLevel);\n      if( pNew==0 ) return 0;\n      ii = (int)(pNew - pCur->aPoint) + 1;\n      if( ii<RTREE_CACHE_SZ ){\n        assert( pCur->aNode[ii]==0 );\n        pCur->aNode[ii] = pCur->aNode[0];\n       }else{\n        nodeRelease(RTREE_OF_CURSOR(pCur), pCur->aNode[0]);\n      }\n      pCur->aNode[0] = 0;\n      *pNew = pCur->sPoint;\n    }\n    pCur->sPoint.rScore = rScore;\n    pCur->sPoint.iLevel = iLevel;\n    pCur->bPoint = 1;\n    return &pCur->sPoint;\n  }else{\n    return rtreeEnqueue(pCur, rScore, iLevel);\n  }\n}\n\n#if 0\n/* Tracing routines for the RtreeSearchPoint queue */\nstatic void tracePoint(RtreeSearchPoint *p, int idx, RtreeCursor *pCur){\n  if( idx<0 ){ printf(\" s\"); }else{ printf(\"%2d\", idx); }\n  printf(\" %d.%05lld.%02d %g %d\",\n    p->iLevel, p->id, p->iCell, p->rScore, p->eWithin\n  );\n  idx++;\n  if( idx<RTREE_CACHE_SZ ){\n    printf(\" %p\\n\", pCur->aNode[idx]);\n  }else{\n    printf(\"\\n\");\n  }\n}\nstatic void traceQueue(RtreeCursor *pCur, const char *zPrefix){\n  int ii;\n  printf(\"=== %9s \", zPrefix);\n  if( pCur->bPoint ){\n    tracePoint(&pCur->sPoint, -1, pCur);\n  }\n  for(ii=0; ii<pCur->nPoint; ii++){\n    if( ii>0 || pCur->bPoint ) printf(\"              \");\n    tracePoint(&pCur->aPoint[ii], ii, pCur);\n  }\n}\n# define RTREE_QUEUE_TRACE(A,B) traceQueue(A,B)\n#else\n# define RTREE_QUEUE_TRACE(A,B)   /* no-op */\n#endif\n\n/* Remove the search point with the lowest current score.\n*/\nstatic void rtreeSearchPointPop(RtreeCursor *p){\n  int i, j, k, n;\n  i = 1 - p->bPoint;\n  assert( i==0 || i==1 );\n  if( p->aNode[i] ){\n    nodeRelease(RTREE_OF_CURSOR(p), p->aNode[i]);\n    p->aNode[i] = 0;\n  }\n  if( p->bPoint ){\n    p->anQueue[p->sPoint.iLevel]--;\n    p->bPoint = 0;\n  }else if( p->nPoint ){\n    p->anQueue[p->aPoint[0].iLevel]--;\n    n = --p->nPoint;\n    p->aPoint[0] = p->aPoint[n];\n    if( n<RTREE_CACHE_SZ-1 ){\n      p->aNode[1] = p->aNode[n+1];\n      p->aNode[n+1] = 0;\n    }\n    i = 0;\n    while( (j = i*2+1)<n ){\n      k = j+1;\n      if( k<n && rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[j])<0 ){\n        if( rtreeSearchPointCompare(&p->aPoint[k], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, k);\n          i = k;\n        }else{\n          break;\n        }\n      }else{\n        if( rtreeSearchPointCompare(&p->aPoint[j], &p->aPoint[i])<0 ){\n          rtreeSearchPointSwap(p, i, j);\n          i = j;\n        }else{\n          break;\n        }\n      }\n    }\n  }\n}\n\n\n/*\n** Continue the search on cursor pCur until the front of the queue\n** contains an entry suitable for returning as a result-set row,\n** or until the RtreeSearchPoint queue is empty, indicating that the\n** query has completed.\n*/\nstatic int rtreeStepToLeaf(RtreeCursor *pCur){\n  RtreeSearchPoint *p;\n  Rtree *pRtree = RTREE_OF_CURSOR(pCur);\n  RtreeNode *pNode;\n  int eWithin;\n  int rc = SQLITE_OK;\n  int nCell;\n  int nConstraint = pCur->nConstraint;\n  int ii;\n  int eInt;\n  RtreeSearchPoint x;\n\n  eInt = pRtree->eCoordType==RTREE_COORD_INT32;\n  while( (p = rtreeSearchPointFirst(pCur))!=0 && p->iLevel>0 ){\n    pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);\n    if( rc ) return rc;\n    nCell = NCELL(pNode);\n    assert( nCell<200 );\n    while( p->iCell<nCell ){\n      sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;\n      u8 *pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);\n      eWithin = FULLY_WITHIN;\n      for(ii=0; ii<nConstraint; ii++){\n        RtreeConstraint *pConstraint = pCur->aConstraint + ii;\n        if( pConstraint->op>=RTREE_MATCH ){\n          rc = rtreeCallbackConstraint(pConstraint, eInt, pCellData, p,\n                                       &rScore, &eWithin);\n          if( rc ) return rc;\n        }else if( p->iLevel==1 ){\n          rtreeLeafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }else{\n          rtreeNonleafConstraint(pConstraint, eInt, pCellData, &eWithin);\n        }\n        if( eWithin==NOT_WITHIN ) break;\n      }\n      p->iCell++;\n      if( eWithin==NOT_WITHIN ) continue;\n      x.iLevel = p->iLevel - 1;\n      if( x.iLevel ){\n        x.id = readInt64(pCellData);\n        x.iCell = 0;\n      }else{\n        x.id = p->id;\n        x.iCell = p->iCell - 1;\n      }\n      if( p->iCell>=nCell ){\n        RTREE_QUEUE_TRACE(pCur, \"POP-S:\");\n        rtreeSearchPointPop(pCur);\n      }\n      if( rScore<RTREE_ZERO ) rScore = RTREE_ZERO;\n      p = rtreeSearchPointNew(pCur, rScore, x.iLevel);\n      if( p==0 ) return SQLITE_NOMEM;\n      p->eWithin = (u8)eWithin;\n      p->id = x.id;\n      p->iCell = x.iCell;\n      RTREE_QUEUE_TRACE(pCur, \"PUSH-S:\");\n      break;\n    }\n    if( p->iCell>=nCell ){\n      RTREE_QUEUE_TRACE(pCur, \"POP-Se:\");\n      rtreeSearchPointPop(pCur);\n    }\n  }\n  pCur->atEOF = p==0;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xNext method.\n*/\nstatic int rtreeNext(sqlite3_vtab_cursor *pVtabCursor){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Move to the next entry that matches the configured constraints. */\n  RTREE_QUEUE_TRACE(pCsr, \"POP-Nx:\");\n  rtreeSearchPointPop(pCsr);\n  rc = rtreeStepToLeaf(pCsr);\n  return rc;\n}\n\n/* \n** Rtree virtual table module xRowid method.\n*/\nstatic int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n  if( rc==SQLITE_OK && p ){\n    *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell);\n  }\n  return rc;\n}\n\n/* \n** Rtree virtual table module xColumn method.\n*/\nstatic int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Rtree *pRtree = (Rtree *)cur->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)cur;\n  RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr);\n  RtreeCoord c;\n  int rc = SQLITE_OK;\n  RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc);\n\n  if( rc ) return rc;\n  if( p==0 ) return SQLITE_OK;\n  if( i==0 ){\n    sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell));\n  }else{\n    nodeGetCoord(pRtree, pNode, p->iCell, i-1, &c);\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      sqlite3_result_double(ctx, c.f);\n    }else\n#endif\n    {\n      assert( pRtree->eCoordType==RTREE_COORD_INT32 );\n      sqlite3_result_int(ctx, c.i);\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Use nodeAcquire() to obtain the leaf node containing the record with \n** rowid iRowid. If successful, set *ppLeaf to point to the node and\n** return SQLITE_OK. If there is no such record in the table, set\n** *ppLeaf to 0 and return SQLITE_OK. If an error occurs, set *ppLeaf\n** to zero and return an SQLite error code.\n*/\nstatic int findLeafNode(\n  Rtree *pRtree,              /* RTree to search */\n  i64 iRowid,                 /* The rowid searching for */\n  RtreeNode **ppLeaf,         /* Write the node here */\n  sqlite3_int64 *piNode       /* Write the node-id here */\n){\n  int rc;\n  *ppLeaf = 0;\n  sqlite3_bind_int64(pRtree->pReadRowid, 1, iRowid);\n  if( sqlite3_step(pRtree->pReadRowid)==SQLITE_ROW ){\n    i64 iNode = sqlite3_column_int64(pRtree->pReadRowid, 0);\n    if( piNode ) *piNode = iNode;\n    rc = nodeAcquire(pRtree, iNode, 0, ppLeaf);\n    sqlite3_reset(pRtree->pReadRowid);\n  }else{\n    rc = sqlite3_reset(pRtree->pReadRowid);\n  }\n  return rc;\n}\n\n/*\n** This function is called to configure the RtreeConstraint object passed\n** as the second argument for a MATCH constraint. The value passed as the\n** first argument to this function is the right-hand operand to the MATCH\n** operator.\n*/\nstatic int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){\n  RtreeMatchArg *pBlob, *pSrc;       /* BLOB returned by geometry function */\n  sqlite3_rtree_query_info *pInfo;   /* Callback information */\n\n  pSrc = sqlite3_value_pointer(pValue, \"RtreeMatchArg\");\n  if( pSrc==0 ) return SQLITE_ERROR;\n  pInfo = (sqlite3_rtree_query_info*)\n                sqlite3_malloc64( sizeof(*pInfo)+pSrc->iSize );\n  if( !pInfo ) return SQLITE_NOMEM;\n  memset(pInfo, 0, sizeof(*pInfo));\n  pBlob = (RtreeMatchArg*)&pInfo[1];\n  memcpy(pBlob, pSrc, pSrc->iSize);\n  pInfo->pContext = pBlob->cb.pContext;\n  pInfo->nParam = pBlob->nParam;\n  pInfo->aParam = pBlob->aParam;\n  pInfo->apSqlParam = pBlob->apSqlParam;\n\n  if( pBlob->cb.xGeom ){\n    pCons->u.xGeom = pBlob->cb.xGeom;\n  }else{\n    pCons->op = RTREE_QUERY;\n    pCons->u.xQueryFunc = pBlob->cb.xQueryFunc;\n  }\n  pCons->pInfo = pInfo;\n  return SQLITE_OK;\n}\n\n/* \n** Rtree virtual table module xFilter method.\n*/\nstatic int rtreeFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  Rtree *pRtree = (Rtree *)pVtabCursor->pVtab;\n  RtreeCursor *pCsr = (RtreeCursor *)pVtabCursor;\n  RtreeNode *pRoot = 0;\n  int ii;\n  int rc = SQLITE_OK;\n  int iCell = 0;\n\n  rtreeReference(pRtree);\n\n  /* Reset the cursor to the same state as rtreeOpen() leaves it in. */\n  freeCursorConstraints(pCsr);\n  sqlite3_free(pCsr->aPoint);\n  memset(pCsr, 0, sizeof(RtreeCursor));\n  pCsr->base.pVtab = (sqlite3_vtab*)pRtree;\n\n  pCsr->iStrategy = idxNum;\n  if( idxNum==1 ){\n    /* Special case - lookup by rowid. */\n    RtreeNode *pLeaf;        /* Leaf on which the required cell resides */\n    RtreeSearchPoint *p;     /* Search point for the leaf */\n    i64 iRowid = sqlite3_value_int64(argv[0]);\n    i64 iNode = 0;\n    rc = findLeafNode(pRtree, iRowid, &pLeaf, &iNode);\n    if( rc==SQLITE_OK && pLeaf!=0 ){\n      p = rtreeSearchPointNew(pCsr, RTREE_ZERO, 0);\n      assert( p!=0 );  /* Always returns pCsr->sPoint */\n      pCsr->aNode[0] = pLeaf;\n      p->id = iNode;\n      p->eWithin = PARTLY_WITHIN;\n      rc = nodeRowidIndex(pRtree, pLeaf, iRowid, &iCell);\n      p->iCell = (u8)iCell;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-F1:\");\n    }else{\n      pCsr->atEOF = 1;\n    }\n  }else{\n    /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array \n    ** with the configured constraints. \n    */\n    rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n    if( rc==SQLITE_OK && argc>0 ){\n      pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);\n      pCsr->nConstraint = argc;\n      if( !pCsr->aConstraint ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pCsr->aConstraint, 0, sizeof(RtreeConstraint)*argc);\n        memset(pCsr->anQueue, 0, sizeof(u32)*(pRtree->iDepth + 1));\n        assert( (idxStr==0 && argc==0)\n                || (idxStr && (int)strlen(idxStr)==argc*2) );\n        for(ii=0; ii<argc; ii++){\n          RtreeConstraint *p = &pCsr->aConstraint[ii];\n          p->op = idxStr[ii*2];\n          p->iCoord = idxStr[ii*2+1]-'0';\n          if( p->op>=RTREE_MATCH ){\n            /* A MATCH operator. The right-hand-side must be a blob that\n            ** can be cast into an RtreeMatchArg object. One created using\n            ** an sqlite3_rtree_geometry_callback() SQL user function.\n            */\n            rc = deserializeGeometry(argv[ii], p);\n            if( rc!=SQLITE_OK ){\n              break;\n            }\n            p->pInfo->nCoord = pRtree->nDim2;\n            p->pInfo->anQueue = pCsr->anQueue;\n            p->pInfo->mxLevel = pRtree->iDepth + 1;\n          }else{\n#ifdef SQLITE_RTREE_INT_ONLY\n            p->u.rValue = sqlite3_value_int64(argv[ii]);\n#else\n            p->u.rValue = sqlite3_value_double(argv[ii]);\n#endif\n          }\n        }\n      }\n    }\n    if( rc==SQLITE_OK ){\n      RtreeSearchPoint *pNew;\n      pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1));\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->id = 1;\n      pNew->iCell = 0;\n      pNew->eWithin = PARTLY_WITHIN;\n      assert( pCsr->bPoint==1 );\n      pCsr->aNode[0] = pRoot;\n      pRoot = 0;\n      RTREE_QUEUE_TRACE(pCsr, \"PUSH-Fm:\");\n      rc = rtreeStepToLeaf(pCsr);\n    }\n  }\n\n  nodeRelease(pRtree, pRoot);\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Rtree virtual table module xBestIndex method. There are three\n** table scan strategies to choose from (in order from most to \n** least desirable):\n**\n**   idxNum     idxStr        Strategy\n**   ------------------------------------------------\n**     1        Unused        Direct lookup by rowid.\n**     2        See below     R-tree query or full-table scan.\n**   ------------------------------------------------\n**\n** If strategy 1 is used, then idxStr is not meaningful. If strategy\n** 2 is used, idxStr is formatted to contain 2 bytes for each \n** constraint used. The first two bytes of idxStr correspond to \n** the constraint in sqlite3_index_info.aConstraintUsage[] with\n** (argvIndex==1) etc.\n**\n** The first of each pair of bytes in idxStr identifies the constraint\n** operator as follows:\n**\n**   Operator    Byte Value\n**   ----------------------\n**      =        0x41 ('A')\n**     <=        0x42 ('B')\n**      <        0x43 ('C')\n**     >=        0x44 ('D')\n**      >        0x45 ('E')\n**   MATCH       0x46 ('F')\n**   ----------------------\n**\n** The second of each pair of bytes identifies the coordinate column\n** to which the constraint applies. The leftmost coordinate column\n** is 'a', the second from the left 'b' etc.\n*/\nstatic int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  Rtree *pRtree = (Rtree*)tab;\n  int rc = SQLITE_OK;\n  int ii;\n  int bMatch = 0;                 /* True if there exists a MATCH constraint */\n  i64 nRow;                       /* Estimated rows returned by this scan */\n\n  int iIdx = 0;\n  char zIdxStr[RTREE_MAX_DIMENSIONS*8+1];\n  memset(zIdxStr, 0, sizeof(zIdxStr));\n\n  /* Check if there exists a MATCH constraint - even an unusable one. If there\n  ** is, do not consider the lookup-by-rowid plan as using such a plan would\n  ** require the VDBE to evaluate the MATCH constraint, which is not currently\n  ** possible. */\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    if( pIdxInfo->aConstraint[ii].op==SQLITE_INDEX_CONSTRAINT_MATCH ){\n      bMatch = 1;\n    }\n  }\n\n  assert( pIdxInfo->idxStr==0 );\n  for(ii=0; ii<pIdxInfo->nConstraint && iIdx<(int)(sizeof(zIdxStr)-1); ii++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii];\n\n    if( bMatch==0 && p->usable \n     && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ \n    ){\n      /* We have an equality constraint on the rowid. Use strategy 1. */\n      int jj;\n      for(jj=0; jj<ii; jj++){\n        pIdxInfo->aConstraintUsage[jj].argvIndex = 0;\n        pIdxInfo->aConstraintUsage[jj].omit = 0;\n      }\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[ii].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[jj].omit = 1;\n\n      /* This strategy involves a two rowid lookups on an B-Tree structures\n      ** and then a linear search of an R-Tree node. This should be \n      ** considered almost as quick as a direct rowid lookup (for which \n      ** sqlite uses an internal cost of 0.0). It is expected to return\n      ** a single row.\n      */ \n      pIdxInfo->estimatedCost = 30.0;\n      pIdxInfo->estimatedRows = 1;\n      return SQLITE_OK;\n    }\n\n    if( p->usable && (p->iColumn>0 || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){\n      u8 op;\n      switch( p->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;\n        case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;\n        case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;\n        case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;\n        case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;\n        default:\n          assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );\n          op = RTREE_MATCH; \n          break;\n      }\n      zIdxStr[iIdx++] = op;\n      zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');\n      pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);\n      pIdxInfo->aConstraintUsage[ii].omit = 1;\n    }\n  }\n\n  pIdxInfo->idxNum = 2;\n  pIdxInfo->needToFreeIdxStr = 1;\n  if( iIdx>0 && 0==(pIdxInfo->idxStr = sqlite3_mprintf(\"%s\", zIdxStr)) ){\n    return SQLITE_NOMEM;\n  }\n\n  nRow = pRtree->nRowEst >> (iIdx/2);\n  pIdxInfo->estimatedCost = (double)6.0 * (double)nRow;\n  pIdxInfo->estimatedRows = nRow;\n\n  return rc;\n}\n\n/*\n** Return the N-dimensional volumn of the cell stored in *p.\n*/\nstatic RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue area = (RtreeDValue)1;\n  assert( pRtree->nDim>=1 && pRtree->nDim<=5 );\n#ifndef SQLITE_RTREE_INT_ONLY\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    switch( pRtree->nDim ){\n      case 5:  area  = p->aCoord[9].f - p->aCoord[8].f;\n      case 4:  area *= p->aCoord[7].f - p->aCoord[6].f;\n      case 3:  area *= p->aCoord[5].f - p->aCoord[4].f;\n      case 2:  area *= p->aCoord[3].f - p->aCoord[2].f;\n      default: area *= p->aCoord[1].f - p->aCoord[0].f;\n    }\n  }else\n#endif\n  {\n    switch( pRtree->nDim ){\n      case 5:  area  = p->aCoord[9].i - p->aCoord[8].i;\n      case 4:  area *= p->aCoord[7].i - p->aCoord[6].i;\n      case 3:  area *= p->aCoord[5].i - p->aCoord[4].i;\n      case 2:  area *= p->aCoord[3].i - p->aCoord[2].i;\n      default: area *= p->aCoord[1].i - p->aCoord[0].i;\n    }\n  }\n  return area;\n}\n\n/*\n** Return the margin length of cell p. The margin length is the sum\n** of the objects size in each dimension.\n*/\nstatic RtreeDValue cellMargin(Rtree *pRtree, RtreeCell *p){\n  RtreeDValue margin = 0;\n  int ii = pRtree->nDim2 - 2;\n  do{\n    margin += (DCOORD(p->aCoord[ii+1]) - DCOORD(p->aCoord[ii]));\n    ii -= 2;\n  }while( ii>=0 );\n  return margin;\n}\n\n/*\n** Store the union of cells p1 and p2 in p1.\n*/\nstatic void cellUnion(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii = 0;\n  if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n    do{\n      p1->aCoord[ii].f = MIN(p1->aCoord[ii].f, p2->aCoord[ii].f);\n      p1->aCoord[ii+1].f = MAX(p1->aCoord[ii+1].f, p2->aCoord[ii+1].f);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }else{\n    do{\n      p1->aCoord[ii].i = MIN(p1->aCoord[ii].i, p2->aCoord[ii].i);\n      p1->aCoord[ii+1].i = MAX(p1->aCoord[ii+1].i, p2->aCoord[ii+1].i);\n      ii += 2;\n    }while( ii<pRtree->nDim2 );\n  }\n}\n\n/*\n** Return true if the area covered by p2 is a subset of the area covered\n** by p1. False otherwise.\n*/\nstatic int cellContains(Rtree *pRtree, RtreeCell *p1, RtreeCell *p2){\n  int ii;\n  int isInt = (pRtree->eCoordType==RTREE_COORD_INT32);\n  for(ii=0; ii<pRtree->nDim2; ii+=2){\n    RtreeCoord *a1 = &p1->aCoord[ii];\n    RtreeCoord *a2 = &p2->aCoord[ii];\n    if( (!isInt && (a2[0].f<a1[0].f || a2[1].f>a1[1].f)) \n     || ( isInt && (a2[0].i<a1[0].i || a2[1].i>a1[1].i)) \n    ){\n      return 0;\n    }\n  }\n  return 1;\n}\n\n/*\n** Return the amount cell p would grow by if it were unioned with pCell.\n*/\nstatic RtreeDValue cellGrowth(Rtree *pRtree, RtreeCell *p, RtreeCell *pCell){\n  RtreeDValue area;\n  RtreeCell cell;\n  memcpy(&cell, p, sizeof(RtreeCell));\n  area = cellArea(pRtree, &cell);\n  cellUnion(pRtree, &cell, pCell);\n  return (cellArea(pRtree, &cell)-area);\n}\n\nstatic RtreeDValue cellOverlap(\n  Rtree *pRtree, \n  RtreeCell *p, \n  RtreeCell *aCell, \n  int nCell\n){\n  int ii;\n  RtreeDValue overlap = RTREE_ZERO;\n  for(ii=0; ii<nCell; ii++){\n    int jj;\n    RtreeDValue o = (RtreeDValue)1;\n    for(jj=0; jj<pRtree->nDim2; jj+=2){\n      RtreeDValue x1, x2;\n      x1 = MAX(DCOORD(p->aCoord[jj]), DCOORD(aCell[ii].aCoord[jj]));\n      x2 = MIN(DCOORD(p->aCoord[jj+1]), DCOORD(aCell[ii].aCoord[jj+1]));\n      if( x2<x1 ){\n        o = (RtreeDValue)0;\n        break;\n      }else{\n        o = o * (x2-x1);\n      }\n    }\n    overlap += o;\n  }\n  return overlap;\n}\n\n\n/*\n** This function implements the ChooseLeaf algorithm from Gutman[84].\n** ChooseSubTree in r*tree terminology.\n*/\nstatic int ChooseLeaf(\n  Rtree *pRtree,               /* Rtree table */\n  RtreeCell *pCell,            /* Cell to insert into rtree */\n  int iHeight,                 /* Height of sub-tree rooted at pCell */\n  RtreeNode **ppLeaf           /* OUT: Selected leaf page */\n){\n  int rc;\n  int ii;\n  RtreeNode *pNode;\n  rc = nodeAcquire(pRtree, 1, 0, &pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){\n    int iCell;\n    sqlite3_int64 iBest = 0;\n\n    RtreeDValue fMinGrowth = RTREE_ZERO;\n    RtreeDValue fMinArea = RTREE_ZERO;\n\n    int nCell = NCELL(pNode);\n    RtreeCell cell;\n    RtreeNode *pChild;\n\n    RtreeCell *aCell = 0;\n\n    /* Select the child node which will be enlarged the least if pCell\n    ** is inserted into it. Resolve ties by choosing the entry with\n    ** the smallest area.\n    */\n    for(iCell=0; iCell<nCell; iCell++){\n      int bBest = 0;\n      RtreeDValue growth;\n      RtreeDValue area;\n      nodeGetCell(pRtree, pNode, iCell, &cell);\n      growth = cellGrowth(pRtree, &cell, pCell);\n      area = cellArea(pRtree, &cell);\n      if( iCell==0||growth<fMinGrowth||(growth==fMinGrowth && area<fMinArea) ){\n        bBest = 1;\n      }\n      if( bBest ){\n        fMinGrowth = growth;\n        fMinArea = area;\n        iBest = cell.iRowid;\n      }\n    }\n\n    sqlite3_free(aCell);\n    rc = nodeAcquire(pRtree, iBest, pNode, &pChild);\n    nodeRelease(pRtree, pNode);\n    pNode = pChild;\n  }\n\n  *ppLeaf = pNode;\n  return rc;\n}\n\n/*\n** A cell with the same content as pCell has just been inserted into\n** the node pNode. This function updates the bounding box cells in\n** all ancestor elements.\n*/\nstatic int AdjustTree(\n  Rtree *pRtree,                    /* Rtree table */\n  RtreeNode *pNode,                 /* Adjust ancestry of this node. */\n  RtreeCell *pCell                  /* This cell was just inserted */\n){\n  RtreeNode *p = pNode;\n  while( p->pParent ){\n    RtreeNode *pParent = p->pParent;\n    RtreeCell cell;\n    int iCell;\n\n    if( nodeParentIndex(pRtree, p, &iCell) ){\n      return SQLITE_CORRUPT_VTAB;\n    }\n\n    nodeGetCell(pRtree, pParent, iCell, &cell);\n    if( !cellContains(pRtree, &cell, pCell) ){\n      cellUnion(pRtree, &cell, pCell);\n      nodeOverwriteCell(pRtree, pParent, &cell, iCell);\n    }\n \n    p = pParent;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Write mapping (iRowid->iNode) to the <rtree>_rowid table.\n*/\nstatic int rowidWrite(Rtree *pRtree, sqlite3_int64 iRowid, sqlite3_int64 iNode){\n  sqlite3_bind_int64(pRtree->pWriteRowid, 1, iRowid);\n  sqlite3_bind_int64(pRtree->pWriteRowid, 2, iNode);\n  sqlite3_step(pRtree->pWriteRowid);\n  return sqlite3_reset(pRtree->pWriteRowid);\n}\n\n/*\n** Write mapping (iNode->iPar) to the <rtree>_parent table.\n*/\nstatic int parentWrite(Rtree *pRtree, sqlite3_int64 iNode, sqlite3_int64 iPar){\n  sqlite3_bind_int64(pRtree->pWriteParent, 1, iNode);\n  sqlite3_bind_int64(pRtree->pWriteParent, 2, iPar);\n  sqlite3_step(pRtree->pWriteParent);\n  return sqlite3_reset(pRtree->pWriteParent);\n}\n\nstatic int rtreeInsertCell(Rtree *, RtreeNode *, RtreeCell *, int);\n\n\n/*\n** Arguments aIdx, aDistance and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to the indexed values in aDistance. For\n** example, assuming the inputs:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**   aDistance = { 5.0, 2.0, 7.0, 6.0 }\n**\n** this function sets the aIdx array to contain:\n**\n**   aIdx      = { 0,   1,   2,   3 }\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDistance(\n  int *aIdx, \n  int nIdx, \n  RtreeDValue *aDistance, \n  int *aSpare\n){\n  if( nIdx>1 ){\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDistance(aLeft, nLeft, aDistance, aSpare);\n    SortByDistance(aRight, nRight, aDistance, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n\n    while( iLeft<nLeft || iRight<nRight ){\n      if( iLeft==nLeft ){\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }else if( iRight==nRight ){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        RtreeDValue fLeft = aDistance[aLeft[iLeft]];\n        RtreeDValue fRight = aDistance[aRight[iRight]];\n        if( fLeft<fRight ){\n          aIdx[iLeft+iRight] = aLeft[iLeft];\n          iLeft++;\n        }else{\n          aIdx[iLeft+iRight] = aRight[iRight];\n          iRight++;\n        }\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue left = aDistance[aIdx[jj-1]];\n        RtreeDValue right = aDistance[aIdx[jj]];\n        assert( left<=right );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Arguments aIdx, aCell and aSpare all point to arrays of size\n** nIdx. The aIdx array contains the set of integers from 0 to \n** (nIdx-1) in no particular order. This function sorts the values\n** in aIdx according to dimension iDim of the cells in aCell. The\n** minimum value of dimension iDim is considered first, the\n** maximum used to break ties.\n**\n** The aSpare array is used as temporary working space by the\n** sorting algorithm.\n*/\nstatic void SortByDimension(\n  Rtree *pRtree,\n  int *aIdx, \n  int nIdx, \n  int iDim, \n  RtreeCell *aCell, \n  int *aSpare\n){\n  if( nIdx>1 ){\n\n    int iLeft = 0;\n    int iRight = 0;\n\n    int nLeft = nIdx/2;\n    int nRight = nIdx-nLeft;\n    int *aLeft = aIdx;\n    int *aRight = &aIdx[nLeft];\n\n    SortByDimension(pRtree, aLeft, nLeft, iDim, aCell, aSpare);\n    SortByDimension(pRtree, aRight, nRight, iDim, aCell, aSpare);\n\n    memcpy(aSpare, aLeft, sizeof(int)*nLeft);\n    aLeft = aSpare;\n    while( iLeft<nLeft || iRight<nRight ){\n      RtreeDValue xleft1 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2]);\n      RtreeDValue xleft2 = DCOORD(aCell[aLeft[iLeft]].aCoord[iDim*2+1]);\n      RtreeDValue xright1 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2]);\n      RtreeDValue xright2 = DCOORD(aCell[aRight[iRight]].aCoord[iDim*2+1]);\n      if( (iLeft!=nLeft) && ((iRight==nRight)\n       || (xleft1<xright1)\n       || (xleft1==xright1 && xleft2<xright2)\n      )){\n        aIdx[iLeft+iRight] = aLeft[iLeft];\n        iLeft++;\n      }else{\n        aIdx[iLeft+iRight] = aRight[iRight];\n        iRight++;\n      }\n    }\n\n#if 0\n    /* Check that the sort worked */\n    {\n      int jj;\n      for(jj=1; jj<nIdx; jj++){\n        RtreeDValue xleft1 = aCell[aIdx[jj-1]].aCoord[iDim*2];\n        RtreeDValue xleft2 = aCell[aIdx[jj-1]].aCoord[iDim*2+1];\n        RtreeDValue xright1 = aCell[aIdx[jj]].aCoord[iDim*2];\n        RtreeDValue xright2 = aCell[aIdx[jj]].aCoord[iDim*2+1];\n        assert( xleft1<=xright1 && (xleft1<xright1 || xleft2<=xright2) );\n      }\n    }\n#endif\n  }\n}\n\n/*\n** Implementation of the R*-tree variant of SplitNode from Beckman[1990].\n*/\nstatic int splitNodeStartree(\n  Rtree *pRtree,\n  RtreeCell *aCell,\n  int nCell,\n  RtreeNode *pLeft,\n  RtreeNode *pRight,\n  RtreeCell *pBboxLeft,\n  RtreeCell *pBboxRight\n){\n  int **aaSorted;\n  int *aSpare;\n  int ii;\n\n  int iBestDim = 0;\n  int iBestSplit = 0;\n  RtreeDValue fBestMargin = RTREE_ZERO;\n\n  int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));\n\n  aaSorted = (int **)sqlite3_malloc(nByte);\n  if( !aaSorted ){\n    return SQLITE_NOMEM;\n  }\n\n  aSpare = &((int *)&aaSorted[pRtree->nDim])[pRtree->nDim*nCell];\n  memset(aaSorted, 0, nByte);\n  for(ii=0; ii<pRtree->nDim; ii++){\n    int jj;\n    aaSorted[ii] = &((int *)&aaSorted[pRtree->nDim])[ii*nCell];\n    for(jj=0; jj<nCell; jj++){\n      aaSorted[ii][jj] = jj;\n    }\n    SortByDimension(pRtree, aaSorted[ii], nCell, ii, aCell, aSpare);\n  }\n\n  for(ii=0; ii<pRtree->nDim; ii++){\n    RtreeDValue margin = RTREE_ZERO;\n    RtreeDValue fBestOverlap = RTREE_ZERO;\n    RtreeDValue fBestArea = RTREE_ZERO;\n    int iBestLeft = 0;\n    int nLeft;\n\n    for(\n      nLeft=RTREE_MINCELLS(pRtree); \n      nLeft<=(nCell-RTREE_MINCELLS(pRtree)); \n      nLeft++\n    ){\n      RtreeCell left;\n      RtreeCell right;\n      int kk;\n      RtreeDValue overlap;\n      RtreeDValue area;\n\n      memcpy(&left, &aCell[aaSorted[ii][0]], sizeof(RtreeCell));\n      memcpy(&right, &aCell[aaSorted[ii][nCell-1]], sizeof(RtreeCell));\n      for(kk=1; kk<(nCell-1); kk++){\n        if( kk<nLeft ){\n          cellUnion(pRtree, &left, &aCell[aaSorted[ii][kk]]);\n        }else{\n          cellUnion(pRtree, &right, &aCell[aaSorted[ii][kk]]);\n        }\n      }\n      margin += cellMargin(pRtree, &left);\n      margin += cellMargin(pRtree, &right);\n      overlap = cellOverlap(pRtree, &left, &right, 1);\n      area = cellArea(pRtree, &left) + cellArea(pRtree, &right);\n      if( (nLeft==RTREE_MINCELLS(pRtree))\n       || (overlap<fBestOverlap)\n       || (overlap==fBestOverlap && area<fBestArea)\n      ){\n        iBestLeft = nLeft;\n        fBestOverlap = overlap;\n        fBestArea = area;\n      }\n    }\n\n    if( ii==0 || margin<fBestMargin ){\n      iBestDim = ii;\n      fBestMargin = margin;\n      iBestSplit = iBestLeft;\n    }\n  }\n\n  memcpy(pBboxLeft, &aCell[aaSorted[iBestDim][0]], sizeof(RtreeCell));\n  memcpy(pBboxRight, &aCell[aaSorted[iBestDim][iBestSplit]], sizeof(RtreeCell));\n  for(ii=0; ii<nCell; ii++){\n    RtreeNode *pTarget = (ii<iBestSplit)?pLeft:pRight;\n    RtreeCell *pBbox = (ii<iBestSplit)?pBboxLeft:pBboxRight;\n    RtreeCell *pCell = &aCell[aaSorted[iBestDim][ii]];\n    nodeInsertCell(pRtree, pTarget, pCell);\n    cellUnion(pRtree, pBbox, pCell);\n  }\n\n  sqlite3_free(aaSorted);\n  return SQLITE_OK;\n}\n\n\nstatic int updateMapping(\n  Rtree *pRtree, \n  i64 iRowid, \n  RtreeNode *pNode, \n  int iHeight\n){\n  int (*xSetMapping)(Rtree *, sqlite3_int64, sqlite3_int64);\n  xSetMapping = ((iHeight==0)?rowidWrite:parentWrite);\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  return xSetMapping(pRtree, iRowid, pNode->iNode);\n}\n\nstatic int SplitNode(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int i;\n  int newCellIsRight = 0;\n\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n  RtreeCell *aCell;\n  int *aiUsed;\n\n  RtreeNode *pLeft = 0;\n  RtreeNode *pRight = 0;\n\n  RtreeCell leftbbox;\n  RtreeCell rightbbox;\n\n  /* Allocate an array and populate it with a copy of pCell and \n  ** all cells from node pLeft. Then zero the original node.\n  */\n  aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));\n  if( !aCell ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n  aiUsed = (int *)&aCell[nCell+1];\n  memset(aiUsed, 0, sizeof(int)*(nCell+1));\n  for(i=0; i<nCell; i++){\n    nodeGetCell(pRtree, pNode, i, &aCell[i]);\n  }\n  nodeZero(pRtree, pNode);\n  memcpy(&aCell[nCell], pCell, sizeof(RtreeCell));\n  nCell++;\n\n  if( pNode->iNode==1 ){\n    pRight = nodeNew(pRtree, pNode);\n    pLeft = nodeNew(pRtree, pNode);\n    pRtree->iDepth++;\n    pNode->isDirty = 1;\n    writeInt16(pNode->zData, pRtree->iDepth);\n  }else{\n    pLeft = pNode;\n    pRight = nodeNew(pRtree, pLeft->pParent);\n    nodeReference(pLeft);\n  }\n\n  if( !pLeft || !pRight ){\n    rc = SQLITE_NOMEM;\n    goto splitnode_out;\n  }\n\n  memset(pLeft->zData, 0, pRtree->iNodeSize);\n  memset(pRight->zData, 0, pRtree->iNodeSize);\n\n  rc = splitNodeStartree(pRtree, aCell, nCell, pLeft, pRight,\n                         &leftbbox, &rightbbox);\n  if( rc!=SQLITE_OK ){\n    goto splitnode_out;\n  }\n\n  /* Ensure both child nodes have node numbers assigned to them by calling\n  ** nodeWrite(). Node pRight always needs a node number, as it was created\n  ** by nodeNew() above. But node pLeft sometimes already has a node number.\n  ** In this case avoid the all to nodeWrite().\n  */\n  if( SQLITE_OK!=(rc = nodeWrite(pRtree, pRight))\n   || (0==pLeft->iNode && SQLITE_OK!=(rc = nodeWrite(pRtree, pLeft)))\n  ){\n    goto splitnode_out;\n  }\n\n  rightbbox.iRowid = pRight->iNode;\n  leftbbox.iRowid = pLeft->iNode;\n\n  if( pNode->iNode==1 ){\n    rc = rtreeInsertCell(pRtree, pLeft->pParent, &leftbbox, iHeight+1);\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }else{\n    RtreeNode *pParent = pLeft->pParent;\n    int iCell;\n    rc = nodeParentIndex(pRtree, pLeft, &iCell);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell);\n      rc = AdjustTree(pRtree, pParent, &leftbbox);\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( (rc = rtreeInsertCell(pRtree, pRight->pParent, &rightbbox, iHeight+1)) ){\n    goto splitnode_out;\n  }\n\n  for(i=0; i<NCELL(pRight); i++){\n    i64 iRowid = nodeGetRowid(pRtree, pRight, i);\n    rc = updateMapping(pRtree, iRowid, pRight, iHeight);\n    if( iRowid==pCell->iRowid ){\n      newCellIsRight = 1;\n    }\n    if( rc!=SQLITE_OK ){\n      goto splitnode_out;\n    }\n  }\n  if( pNode->iNode==1 ){\n    for(i=0; i<NCELL(pLeft); i++){\n      i64 iRowid = nodeGetRowid(pRtree, pLeft, i);\n      rc = updateMapping(pRtree, iRowid, pLeft, iHeight);\n      if( rc!=SQLITE_OK ){\n        goto splitnode_out;\n      }\n    }\n  }else if( newCellIsRight==0 ){\n    rc = updateMapping(pRtree, pCell->iRowid, pLeft, iHeight);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRight);\n    pRight = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pLeft);\n    pLeft = 0;\n  }\n\nsplitnode_out:\n  nodeRelease(pRtree, pRight);\n  nodeRelease(pRtree, pLeft);\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** If node pLeaf is not the root of the r-tree and its pParent pointer is \n** still NULL, load all ancestor nodes of pLeaf into memory and populate\n** the pLeaf->pParent chain all the way up to the root node.\n**\n** This operation is required when a row is deleted (or updated - an update\n** is implemented as a delete followed by an insert). SQLite provides the\n** rowid of the row to delete, which can be used to find the leaf on which\n** the entry resides (argument pLeaf). Once the leaf is located, this \n** function is called to determine its ancestry.\n*/\nstatic int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){\n  int rc = SQLITE_OK;\n  RtreeNode *pChild = pLeaf;\n  while( rc==SQLITE_OK && pChild->iNode!=1 && pChild->pParent==0 ){\n    int rc2 = SQLITE_OK;          /* sqlite3_reset() return code */\n    sqlite3_bind_int64(pRtree->pReadParent, 1, pChild->iNode);\n    rc = sqlite3_step(pRtree->pReadParent);\n    if( rc==SQLITE_ROW ){\n      RtreeNode *pTest;           /* Used to test for reference loops */\n      i64 iNode;                  /* Node number of parent node */\n\n      /* Before setting pChild->pParent, test that we are not creating a\n      ** loop of references (as we would if, say, pChild==pParent). We don't\n      ** want to do this as it leads to a memory leak when trying to delete\n      ** the referenced counted node structures.\n      */\n      iNode = sqlite3_column_int64(pRtree->pReadParent, 0);\n      for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent);\n      if( !pTest ){\n        rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent);\n      }\n    }\n    rc = sqlite3_reset(pRtree->pReadParent);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;\n    pChild = pChild->pParent;\n  }\n  return rc;\n}\n\nstatic int deleteCell(Rtree *, RtreeNode *, int, int);\n\nstatic int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){\n  int rc;\n  int rc2;\n  RtreeNode *pParent = 0;\n  int iCell;\n\n  assert( pNode->nRef==1 );\n\n  /* Remove the entry in the parent cell. */\n  rc = nodeParentIndex(pRtree, pNode, &iCell);\n  if( rc==SQLITE_OK ){\n    pParent = pNode->pParent;\n    pNode->pParent = 0;\n    rc = deleteCell(pRtree, pParent, iCell, iHeight+1);\n  }\n  rc2 = nodeRelease(pRtree, pParent);\n  if( rc==SQLITE_OK ){\n    rc = rc2;\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Remove the xxx_node entry. */\n  sqlite3_bind_int64(pRtree->pDeleteNode, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteNode);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteNode)) ){\n    return rc;\n  }\n\n  /* Remove the xxx_parent entry. */\n  sqlite3_bind_int64(pRtree->pDeleteParent, 1, pNode->iNode);\n  sqlite3_step(pRtree->pDeleteParent);\n  if( SQLITE_OK!=(rc = sqlite3_reset(pRtree->pDeleteParent)) ){\n    return rc;\n  }\n  \n  /* Remove the node from the in-memory hash table and link it into\n  ** the Rtree.pDeleted list. Its contents will be re-inserted later on.\n  */\n  nodeHashDelete(pRtree, pNode);\n  pNode->iNode = iHeight;\n  pNode->pNext = pRtree->pDeleted;\n  pNode->nRef++;\n  pRtree->pDeleted = pNode;\n\n  return SQLITE_OK;\n}\n\nstatic int fixBoundingBox(Rtree *pRtree, RtreeNode *pNode){\n  RtreeNode *pParent = pNode->pParent;\n  int rc = SQLITE_OK; \n  if( pParent ){\n    int ii; \n    int nCell = NCELL(pNode);\n    RtreeCell box;                            /* Bounding box for pNode */\n    nodeGetCell(pRtree, pNode, 0, &box);\n    for(ii=1; ii<nCell; ii++){\n      RtreeCell cell;\n      nodeGetCell(pRtree, pNode, ii, &cell);\n      cellUnion(pRtree, &box, &cell);\n    }\n    box.iRowid = pNode->iNode;\n    rc = nodeParentIndex(pRtree, pNode, &ii);\n    if( rc==SQLITE_OK ){\n      nodeOverwriteCell(pRtree, pParent, &box, ii);\n      rc = fixBoundingBox(pRtree, pParent);\n    }\n  }\n  return rc;\n}\n\n/*\n** Delete the cell at index iCell of node pNode. After removing the\n** cell, adjust the r-tree data structure if required.\n*/\nstatic int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){\n  RtreeNode *pParent;\n  int rc;\n\n  if( SQLITE_OK!=(rc = fixLeafParent(pRtree, pNode)) ){\n    return rc;\n  }\n\n  /* Remove the cell from the node. This call just moves bytes around\n  ** the in-memory node image, so it cannot fail.\n  */\n  nodeDeleteCell(pRtree, pNode, iCell);\n\n  /* If the node is not the tree root and now has less than the minimum\n  ** number of cells, remove it from the tree. Otherwise, update the\n  ** cell in the parent node so that it tightly contains the updated\n  ** node.\n  */\n  pParent = pNode->pParent;\n  assert( pParent || pNode->iNode==1 );\n  if( pParent ){\n    if( NCELL(pNode)<RTREE_MINCELLS(pRtree) ){\n      rc = removeNode(pRtree, pNode, iHeight);\n    }else{\n      rc = fixBoundingBox(pRtree, pNode);\n    }\n  }\n\n  return rc;\n}\n\nstatic int Reinsert(\n  Rtree *pRtree, \n  RtreeNode *pNode, \n  RtreeCell *pCell, \n  int iHeight\n){\n  int *aOrder;\n  int *aSpare;\n  RtreeCell *aCell;\n  RtreeDValue *aDistance;\n  int nCell;\n  RtreeDValue aCenterCoord[RTREE_MAX_DIMENSIONS];\n  int iDim;\n  int ii;\n  int rc = SQLITE_OK;\n  int n;\n\n  memset(aCenterCoord, 0, sizeof(RtreeDValue)*RTREE_MAX_DIMENSIONS);\n\n  nCell = NCELL(pNode)+1;\n  n = (nCell+1)&(~1);\n\n  /* Allocate the buffers used by this operation. The allocation is\n  ** relinquished before this function returns.\n  */\n  aCell = (RtreeCell *)sqlite3_malloc(n * (\n    sizeof(RtreeCell)     +         /* aCell array */\n    sizeof(int)           +         /* aOrder array */\n    sizeof(int)           +         /* aSpare array */\n    sizeof(RtreeDValue)             /* aDistance array */\n  ));\n  if( !aCell ){\n    return SQLITE_NOMEM;\n  }\n  aOrder    = (int *)&aCell[n];\n  aSpare    = (int *)&aOrder[n];\n  aDistance = (RtreeDValue *)&aSpare[n];\n\n  for(ii=0; ii<nCell; ii++){\n    if( ii==(nCell-1) ){\n      memcpy(&aCell[ii], pCell, sizeof(RtreeCell));\n    }else{\n      nodeGetCell(pRtree, pNode, ii, &aCell[ii]);\n    }\n    aOrder[ii] = ii;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2]);\n      aCenterCoord[iDim] += DCOORD(aCell[ii].aCoord[iDim*2+1]);\n    }\n  }\n  for(iDim=0; iDim<pRtree->nDim; iDim++){\n    aCenterCoord[iDim] = (aCenterCoord[iDim]/(nCell*(RtreeDValue)2));\n  }\n\n  for(ii=0; ii<nCell; ii++){\n    aDistance[ii] = RTREE_ZERO;\n    for(iDim=0; iDim<pRtree->nDim; iDim++){\n      RtreeDValue coord = (DCOORD(aCell[ii].aCoord[iDim*2+1]) - \n                               DCOORD(aCell[ii].aCoord[iDim*2]));\n      aDistance[ii] += (coord-aCenterCoord[iDim])*(coord-aCenterCoord[iDim]);\n    }\n  }\n\n  SortByDistance(aOrder, nCell, aDistance, aSpare);\n  nodeZero(pRtree, pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<(nCell-(RTREE_MINCELLS(pRtree)+1)); ii++){\n    RtreeCell *p = &aCell[aOrder[ii]];\n    nodeInsertCell(pRtree, pNode, p);\n    if( p->iRowid==pCell->iRowid ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, p->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, p->iRowid, pNode->iNode);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = fixBoundingBox(pRtree, pNode);\n  }\n  for(; rc==SQLITE_OK && ii<nCell; ii++){\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    RtreeNode *pInsert;\n    RtreeCell *p = &aCell[aOrder[ii]];\n    rc = ChooseLeaf(pRtree, p, iHeight, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, p, iHeight);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\n  sqlite3_free(aCell);\n  return rc;\n}\n\n/*\n** Insert cell pCell into node pNode. Node pNode is the head of a \n** subtree iHeight high (leaf nodes have iHeight==0).\n*/\nstatic int rtreeInsertCell(\n  Rtree *pRtree,\n  RtreeNode *pNode,\n  RtreeCell *pCell,\n  int iHeight\n){\n  int rc = SQLITE_OK;\n  if( iHeight>0 ){\n    RtreeNode *pChild = nodeHashLookup(pRtree, pCell->iRowid);\n    if( pChild ){\n      nodeRelease(pRtree, pChild->pParent);\n      nodeReference(pNode);\n      pChild->pParent = pNode;\n    }\n  }\n  if( nodeInsertCell(pRtree, pNode, pCell) ){\n    if( iHeight<=pRtree->iReinsertHeight || pNode->iNode==1){\n      rc = SplitNode(pRtree, pNode, pCell, iHeight);\n    }else{\n      pRtree->iReinsertHeight = iHeight;\n      rc = Reinsert(pRtree, pNode, pCell, iHeight);\n    }\n  }else{\n    rc = AdjustTree(pRtree, pNode, pCell);\n    if( rc==SQLITE_OK ){\n      if( iHeight==0 ){\n        rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }else{\n        rc = parentWrite(pRtree, pCell->iRowid, pNode->iNode);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int reinsertNodeContent(Rtree *pRtree, RtreeNode *pNode){\n  int ii;\n  int rc = SQLITE_OK;\n  int nCell = NCELL(pNode);\n\n  for(ii=0; rc==SQLITE_OK && ii<nCell; ii++){\n    RtreeNode *pInsert;\n    RtreeCell cell;\n    nodeGetCell(pRtree, pNode, ii, &cell);\n\n    /* Find a node to store this cell in. pNode->iNode currently contains\n    ** the height of the sub-tree headed by the cell.\n    */\n    rc = ChooseLeaf(pRtree, &cell, (int)pNode->iNode, &pInsert);\n    if( rc==SQLITE_OK ){\n      int rc2;\n      rc = rtreeInsertCell(pRtree, pInsert, &cell, (int)pNode->iNode);\n      rc2 = nodeRelease(pRtree, pInsert);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Select a currently unused rowid for a new r-tree record.\n*/\nstatic int newRowid(Rtree *pRtree, i64 *piRowid){\n  int rc;\n  sqlite3_bind_null(pRtree->pWriteRowid, 1);\n  sqlite3_bind_null(pRtree->pWriteRowid, 2);\n  sqlite3_step(pRtree->pWriteRowid);\n  rc = sqlite3_reset(pRtree->pWriteRowid);\n  *piRowid = sqlite3_last_insert_rowid(pRtree->db);\n  return rc;\n}\n\n/*\n** Remove the entry with rowid=iDelete from the r-tree structure.\n*/\nstatic int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){\n  int rc;                         /* Return code */\n  RtreeNode *pLeaf = 0;           /* Leaf node containing record iDelete */\n  int iCell;                      /* Index of iDelete cell in pLeaf */\n  RtreeNode *pRoot = 0;           /* Root node of rtree structure */\n\n\n  /* Obtain a reference to the root node to initialize Rtree.iDepth */\n  rc = nodeAcquire(pRtree, 1, 0, &pRoot);\n\n  /* Obtain a reference to the leaf node that contains the entry \n  ** about to be deleted. \n  */\n  if( rc==SQLITE_OK ){\n    rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);\n  }\n\n  /* Delete the cell in question from the leaf node. */\n  if( rc==SQLITE_OK ){\n    int rc2;\n    rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);\n    if( rc==SQLITE_OK ){\n      rc = deleteCell(pRtree, pLeaf, iCell, 0);\n    }\n    rc2 = nodeRelease(pRtree, pLeaf);\n    if( rc==SQLITE_OK ){\n      rc = rc2;\n    }\n  }\n\n  /* Delete the corresponding entry in the <rtree>_rowid table. */\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int64(pRtree->pDeleteRowid, 1, iDelete);\n    sqlite3_step(pRtree->pDeleteRowid);\n    rc = sqlite3_reset(pRtree->pDeleteRowid);\n  }\n\n  /* Check if the root node now has exactly one child. If so, remove\n  ** it, schedule the contents of the child for reinsertion and \n  ** reduce the tree height by one.\n  **\n  ** This is equivalent to copying the contents of the child into\n  ** the root node (the operation that Gutman's paper says to perform \n  ** in this scenario).\n  */\n  if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){\n    int rc2;\n    RtreeNode *pChild;\n    i64 iChild = nodeGetRowid(pRtree, pRoot, 0);\n    rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);\n    if( rc==SQLITE_OK ){\n      rc = removeNode(pRtree, pChild, pRtree->iDepth-1);\n    }\n    rc2 = nodeRelease(pRtree, pChild);\n    if( rc==SQLITE_OK ) rc = rc2;\n    if( rc==SQLITE_OK ){\n      pRtree->iDepth--;\n      writeInt16(pRoot->zData, pRtree->iDepth);\n      pRoot->isDirty = 1;\n    }\n  }\n\n  /* Re-insert the contents of any underfull nodes removed from the tree. */\n  for(pLeaf=pRtree->pDeleted; pLeaf; pLeaf=pRtree->pDeleted){\n    if( rc==SQLITE_OK ){\n      rc = reinsertNodeContent(pRtree, pLeaf);\n    }\n    pRtree->pDeleted = pLeaf->pNext;\n    sqlite3_free(pLeaf);\n  }\n\n  /* Release the reference to the root node. */\n  if( rc==SQLITE_OK ){\n    rc = nodeRelease(pRtree, pRoot);\n  }else{\n    nodeRelease(pRtree, pRoot);\n  }\n\n  return rc;\n}\n\n/*\n** Rounding constants for float->double conversion.\n*/\n#define RNDTOWARDS  (1.0 - 1.0/8388608.0)  /* Round towards zero */\n#define RNDAWAY     (1.0 + 1.0/8388608.0)  /* Round away from zero */\n\n#if !defined(SQLITE_RTREE_INT_ONLY)\n/*\n** Convert an sqlite3_value into an RtreeValue (presumably a float)\n** while taking care to round toward negative or positive, respectively.\n*/\nstatic RtreeValue rtreeValueDown(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f>d ){\n    f = (float)(d*(d<0 ? RNDAWAY : RNDTOWARDS));\n  }\n  return f;\n}\nstatic RtreeValue rtreeValueUp(sqlite3_value *v){\n  double d = sqlite3_value_double(v);\n  float f = (float)d;\n  if( f<d ){\n    f = (float)(d*(d<0 ? RNDTOWARDS : RNDAWAY));\n  }\n  return f;\n}\n#endif /* !defined(SQLITE_RTREE_INT_ONLY) */\n\n/*\n** A constraint has failed while inserting a row into an rtree table. \n** Assuming no OOM error occurs, this function sets the error message \n** (at pRtree->base.zErrMsg) to an appropriate value and returns\n** SQLITE_CONSTRAINT.\n**\n** Parameter iCol is the index of the leftmost column involved in the\n** constraint failure. If it is 0, then the constraint that failed is\n** the unique constraint on the id column. Otherwise, it is the rtree\n** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.\n**\n** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.\n*/\nstatic int rtreeConstraintError(Rtree *pRtree, int iCol){\n  sqlite3_stmt *pStmt = 0;\n  char *zSql; \n  int rc;\n\n  assert( iCol==0 || iCol%2 );\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", pRtree->zDb, pRtree->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    if( iCol==0 ){\n      const char *zCol = sqlite3_column_name(pStmt, 0);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"UNIQUE constraint failed: %s.%s\", pRtree->zName, zCol\n      );\n    }else{\n      const char *zCol1 = sqlite3_column_name(pStmt, iCol);\n      const char *zCol2 = sqlite3_column_name(pStmt, iCol+1);\n      pRtree->base.zErrMsg = sqlite3_mprintf(\n          \"rtree constraint failed: %s.(%s<=%s)\", pRtree->zName, zCol1, zCol2\n      );\n    }\n  }\n\n  sqlite3_finalize(pStmt);\n  return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc);\n}\n\n\n\n/*\n** The xUpdate method for rtree module virtual tables.\n*/\nstatic int rtreeUpdate(\n  sqlite3_vtab *pVtab, \n  int nData, \n  sqlite3_value **azData, \n  sqlite_int64 *pRowid\n){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_OK;\n  RtreeCell cell;                 /* New cell to insert if nData>1 */\n  int bHaveRowid = 0;             /* Set to 1 after new rowid is determined */\n\n  rtreeReference(pRtree);\n  assert(nData>=1);\n\n  cell.iRowid = 0;  /* Used only to suppress a compiler warning */\n\n  /* Constraint handling. A write operation on an r-tree table may return\n  ** SQLITE_CONSTRAINT for two reasons:\n  **\n  **   1. A duplicate rowid value, or\n  **   2. The supplied data violates the \"x2>=x1\" constraint.\n  **\n  ** In the first case, if the conflict-handling mode is REPLACE, then\n  ** the conflicting row can be removed before proceeding. In the second\n  ** case, SQLITE_CONSTRAINT must be returned regardless of the\n  ** conflict-handling mode specified by the user.\n  */\n  if( nData>1 ){\n    int ii;\n\n    /* Populate the cell.aCoord[] array. The first coordinate is azData[3].\n    **\n    ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared\n    ** with \"column\" that are interpreted as table constraints.\n    ** Example:  CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));\n    ** This problem was discovered after years of use, so we silently ignore\n    ** these kinds of misdeclared tables to avoid breaking any legacy.\n    */\n    assert( nData<=(pRtree->nDim2 + 3) );\n\n#ifndef SQLITE_RTREE_INT_ONLY\n    if( pRtree->eCoordType==RTREE_COORD_REAL32 ){\n      for(ii=0; ii<nData-4; ii+=2){\n        cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);\n        cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);\n        if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }else\n#endif\n    {\n      for(ii=0; ii<nData-4; ii+=2){\n        cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);\n        cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);\n        if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){\n          rc = rtreeConstraintError(pRtree, ii+1);\n          goto constraint;\n        }\n      }\n    }\n\n    /* If a rowid value was supplied, check if it is already present in \n    ** the table. If so, the constraint has failed. */\n    if( sqlite3_value_type(azData[2])!=SQLITE_NULL ){\n      cell.iRowid = sqlite3_value_int64(azData[2]);\n      if( sqlite3_value_type(azData[0])==SQLITE_NULL\n       || sqlite3_value_int64(azData[0])!=cell.iRowid\n      ){\n        int steprc;\n        sqlite3_bind_int64(pRtree->pReadRowid, 1, cell.iRowid);\n        steprc = sqlite3_step(pRtree->pReadRowid);\n        rc = sqlite3_reset(pRtree->pReadRowid);\n        if( SQLITE_ROW==steprc ){\n          if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){\n            rc = rtreeDeleteRowid(pRtree, cell.iRowid);\n          }else{\n            rc = rtreeConstraintError(pRtree, 0);\n            goto constraint;\n          }\n        }\n      }\n      bHaveRowid = 1;\n    }\n  }\n\n  /* If azData[0] is not an SQL NULL value, it is the rowid of a\n  ** record to delete from the r-tree table. The following block does\n  ** just that.\n  */\n  if( sqlite3_value_type(azData[0])!=SQLITE_NULL ){\n    rc = rtreeDeleteRowid(pRtree, sqlite3_value_int64(azData[0]));\n  }\n\n  /* If the azData[] array contains more than one element, elements\n  ** (azData[2]..azData[argc-1]) contain a new record to insert into\n  ** the r-tree structure.\n  */\n  if( rc==SQLITE_OK && nData>1 ){\n    /* Insert the new record into the r-tree */\n    RtreeNode *pLeaf = 0;\n\n    /* Figure out the rowid of the new row. */\n    if( bHaveRowid==0 ){\n      rc = newRowid(pRtree, &cell.iRowid);\n    }\n    *pRowid = cell.iRowid;\n\n    if( rc==SQLITE_OK ){\n      rc = ChooseLeaf(pRtree, &cell, 0, &pLeaf);\n    }\n    if( rc==SQLITE_OK ){\n      int rc2;\n      pRtree->iReinsertHeight = -1;\n      rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0);\n      rc2 = nodeRelease(pRtree, pLeaf);\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n\nconstraint:\n  rtreeRelease(pRtree);\n  return rc;\n}\n\n/*\n** Called when a transaction starts.\n*/\nstatic int rtreeBeginTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  assert( pRtree->inWrTrans==0 );\n  pRtree->inWrTrans++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a transaction completes (either by COMMIT or ROLLBACK).\n** The sqlite3_blob object should be released at this point.\n*/\nstatic int rtreeEndTransaction(sqlite3_vtab *pVtab){\n  Rtree *pRtree = (Rtree *)pVtab;\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  return SQLITE_OK;\n}\n\n/*\n** The xRename method for rtree module virtual tables.\n*/\nstatic int rtreeRename(sqlite3_vtab *pVtab, const char *zNewName){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int rc = SQLITE_NOMEM;\n  char *zSql = sqlite3_mprintf(\n    \"ALTER TABLE %Q.'%q_node'   RENAME TO \\\"%w_node\\\";\"\n    \"ALTER TABLE %Q.'%q_parent' RENAME TO \\\"%w_parent\\\";\"\n    \"ALTER TABLE %Q.'%q_rowid'  RENAME TO \\\"%w_rowid\\\";\"\n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName \n    , pRtree->zDb, pRtree->zName, zNewName\n  );\n  if( zSql ){\n    nodeBlobReset(pRtree);\n    rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** The xSavepoint method.\n**\n** This module does not need to do anything to support savepoints. However,\n** it uses this hook to close any open blob handle. This is done because a \n** DROP TABLE command - which fortunately always opens a savepoint - cannot \n** succeed if there are any open blob handles. i.e. if the blob handle were\n** not closed here, the following would fail:\n**\n**   BEGIN;\n**     INSERT INTO rtree...\n**     DROP TABLE <tablename>;    -- Would fail with SQLITE_LOCKED\n**   COMMIT;\n*/\nstatic int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){\n  Rtree *pRtree = (Rtree *)pVtab;\n  int iwt = pRtree->inWrTrans;\n  UNUSED_PARAMETER(iSavepoint);\n  pRtree->inWrTrans = 0;\n  nodeBlobReset(pRtree);\n  pRtree->inWrTrans = iwt;\n  return SQLITE_OK;\n}\n\n/*\n** This function populates the pRtree->nRowEst variable with an estimate\n** of the number of rows in the virtual table. If possible, this is based\n** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST.\n*/\nstatic int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){\n  const char *zFmt = \"SELECT stat FROM %Q.sqlite_stat1 WHERE tbl = '%q_rowid'\";\n  char *zSql;\n  sqlite3_stmt *p;\n  int rc;\n  i64 nRow = 0;\n\n  rc = sqlite3_table_column_metadata(\n      db, pRtree->zDb, \"sqlite_stat1\",0,0,0,0,0,0\n  );\n  if( rc!=SQLITE_OK ){\n    pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n    return rc==SQLITE_ERROR ? SQLITE_OK : rc;\n  }\n  zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0);\n    if( rc==SQLITE_OK ){\n      if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0);\n      rc = sqlite3_finalize(p);\n    }else if( rc!=SQLITE_NOMEM ){\n      rc = SQLITE_OK;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( nRow==0 ){\n        pRtree->nRowEst = RTREE_DEFAULT_ROWEST;\n      }else{\n        pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST);\n      }\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\nstatic sqlite3_module rtreeModule = {\n  2,                          /* iVersion */\n  rtreeCreate,                /* xCreate - create a table */\n  rtreeConnect,               /* xConnect - connect to an existing table */\n  rtreeBestIndex,             /* xBestIndex - Determine search strategy */\n  rtreeDisconnect,            /* xDisconnect - Disconnect from a table */\n  rtreeDestroy,               /* xDestroy - Drop a table */\n  rtreeOpen,                  /* xOpen - open a cursor */\n  rtreeClose,                 /* xClose - close a cursor */\n  rtreeFilter,                /* xFilter - configure scan constraints */\n  rtreeNext,                  /* xNext - advance a cursor */\n  rtreeEof,                   /* xEof */\n  rtreeColumn,                /* xColumn - read data */\n  rtreeRowid,                 /* xRowid - read data */\n  rtreeUpdate,                /* xUpdate - write data */\n  rtreeBeginTransaction,      /* xBegin - begin transaction */\n  rtreeEndTransaction,        /* xSync - sync transaction */\n  rtreeEndTransaction,        /* xCommit - commit transaction */\n  rtreeEndTransaction,        /* xRollback - rollback transaction */\n  0,                          /* xFindFunction - function overloading */\n  rtreeRename,                /* xRename - rename the table */\n  rtreeSavepoint,             /* xSavepoint */\n  0,                          /* xRelease */\n  0,                          /* xRollbackTo */\n};\n\nstatic int rtreeSqlInit(\n  Rtree *pRtree, \n  sqlite3 *db, \n  const char *zDb, \n  const char *zPrefix, \n  int isCreate\n){\n  int rc = SQLITE_OK;\n\n  #define N_STATEMENT 8\n  static const char *azSql[N_STATEMENT] = {\n    /* Write the xxx_node table */\n    \"INSERT OR REPLACE INTO '%q'.'%q_node' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_node' WHERE nodeno = :1\",\n\n    /* Read and write the xxx_rowid table */\n    \"SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_rowid' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_rowid' WHERE rowid = :1\",\n\n    /* Read and write the xxx_parent table */\n    \"SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1\",\n    \"INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(:1, :2)\",\n    \"DELETE FROM '%q'.'%q_parent' WHERE nodeno = :1\"\n  };\n  sqlite3_stmt **appStmt[N_STATEMENT];\n  int i;\n\n  pRtree->db = db;\n\n  if( isCreate ){\n    char *zCreate = sqlite3_mprintf(\n\"CREATE TABLE \\\"%w\\\".\\\"%w_node\\\"(nodeno INTEGER PRIMARY KEY, data BLOB);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_rowid\\\"(rowid INTEGER PRIMARY KEY, nodeno INTEGER);\"\n\"CREATE TABLE \\\"%w\\\".\\\"%w_parent\\\"(nodeno INTEGER PRIMARY KEY,\"\n                                  \" parentnode INTEGER);\"\n\"INSERT INTO '%q'.'%q_node' VALUES(1, zeroblob(%d))\",\n      zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, zDb, zPrefix, pRtree->iNodeSize\n    );\n    if( !zCreate ){\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_exec(db, zCreate, 0, 0, 0);\n    sqlite3_free(zCreate);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  appStmt[0] = &pRtree->pWriteNode;\n  appStmt[1] = &pRtree->pDeleteNode;\n  appStmt[2] = &pRtree->pReadRowid;\n  appStmt[3] = &pRtree->pWriteRowid;\n  appStmt[4] = &pRtree->pDeleteRowid;\n  appStmt[5] = &pRtree->pReadParent;\n  appStmt[6] = &pRtree->pWriteParent;\n  appStmt[7] = &pRtree->pDeleteParent;\n\n  rc = rtreeQueryStat1(db, pRtree);\n  for(i=0; i<N_STATEMENT && rc==SQLITE_OK; i++){\n    char *zSql = sqlite3_mprintf(azSql[i], zDb, zPrefix);\n    if( zSql ){\n      rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,\n                              appStmt[i], 0); \n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\n/*\n** The second argument to this function contains the text of an SQL statement\n** that returns a single integer value. The statement is compiled and executed\n** using database connection db. If successful, the integer value returned\n** is written to *piVal and SQLITE_OK returned. Otherwise, an SQLite error\n** code is returned and the value of *piVal after returning is not defined.\n*/\nstatic int getIntFromStmt(sqlite3 *db, const char *zSql, int *piVal){\n  int rc = SQLITE_NOMEM;\n  if( zSql ){\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        *piVal = sqlite3_column_int(pStmt, 0);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is called from within the xConnect() or xCreate() method to\n** determine the node-size used by the rtree table being created or connected\n** to. If successful, pRtree->iNodeSize is populated and SQLITE_OK returned.\n** Otherwise, an SQLite error code is returned.\n**\n** If this function is being called as part of an xConnect(), then the rtree\n** table already exists. In this case the node-size is determined by inspecting\n** the root node of the tree.\n**\n** Otherwise, for an xCreate(), use 64 bytes less than the database page-size. \n** This ensures that each node is stored on a single database page. If the \n** database page-size is so large that more than RTREE_MAXCELLS entries \n** would fit in a single node, use a smaller node-size.\n*/\nstatic int getNodeSize(\n  sqlite3 *db,                    /* Database handle */\n  Rtree *pRtree,                  /* Rtree handle */\n  int isCreate,                   /* True for xCreate, false for xConnect */\n  char **pzErr                    /* OUT: Error message, if any */\n){\n  int rc;\n  char *zSql;\n  if( isCreate ){\n    int iPageSize = 0;\n    zSql = sqlite3_mprintf(\"PRAGMA %Q.page_size\", pRtree->zDb);\n    rc = getIntFromStmt(db, zSql, &iPageSize);\n    if( rc==SQLITE_OK ){\n      pRtree->iNodeSize = iPageSize-64;\n      if( (4+pRtree->nBytesPerCell*RTREE_MAXCELLS)<pRtree->iNodeSize ){\n        pRtree->iNodeSize = 4+pRtree->nBytesPerCell*RTREE_MAXCELLS;\n      }\n    }else{\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }else{\n    zSql = sqlite3_mprintf(\n        \"SELECT length(data) FROM '%q'.'%q_node' WHERE nodeno = 1\",\n        pRtree->zDb, pRtree->zName\n    );\n    rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else if( pRtree->iNodeSize<(512-64) ){\n      rc = SQLITE_CORRUPT_VTAB;\n      *pzErr = sqlite3_mprintf(\"undersize RTree blobs in \\\"%q_node\\\"\",\n                               pRtree->zName);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/* \n** This function is the implementation of both the xConnect and xCreate\n** methods of the r-tree virtual table.\n**\n**   argv[0]   -> module name\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> column names...\n*/\nstatic int rtreeInit(\n  sqlite3 *db,                        /* Database connection */\n  void *pAux,                         /* One of the RTREE_COORD_* constants */\n  int argc, const char *const*argv,   /* Parameters to CREATE TABLE statement */\n  sqlite3_vtab **ppVtab,              /* OUT: New virtual table */\n  char **pzErr,                       /* OUT: Error message, if any */\n  int isCreate                        /* True for xCreate, false for xConnect */\n){\n  int rc = SQLITE_OK;\n  Rtree *pRtree;\n  int nDb;              /* Length of string argv[1] */\n  int nName;            /* Length of string argv[2] */\n  int eCoordType = (pAux ? RTREE_COORD_INT32 : RTREE_COORD_REAL32);\n\n  const char *aErrMsg[] = {\n    0,                                                    /* 0 */\n    \"Wrong number of columns for an rtree table\",         /* 1 */\n    \"Too few columns for an rtree table\",                 /* 2 */\n    \"Too many columns for an rtree table\"                 /* 3 */\n  };\n\n  int iErr = (argc<6) ? 2 : argc>(RTREE_MAX_DIMENSIONS*2+4) ? 3 : argc%2;\n  if( aErrMsg[iErr] ){\n    *pzErr = sqlite3_mprintf(\"%s\", aErrMsg[iErr]);\n    return SQLITE_ERROR;\n  }\n\n  sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);\n\n  /* Allocate the sqlite3_vtab structure */\n  nDb = (int)strlen(argv[1]);\n  nName = (int)strlen(argv[2]);\n  pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);\n  if( !pRtree ){\n    return SQLITE_NOMEM;\n  }\n  memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);\n  pRtree->nBusy = 1;\n  pRtree->base.pModule = &rtreeModule;\n  pRtree->zDb = (char *)&pRtree[1];\n  pRtree->zName = &pRtree->zDb[nDb+1];\n  pRtree->nDim = (u8)((argc-4)/2);\n  pRtree->nDim2 = pRtree->nDim*2;\n  pRtree->nBytesPerCell = 8 + pRtree->nDim2*4;\n  pRtree->eCoordType = (u8)eCoordType;\n  memcpy(pRtree->zDb, argv[1], nDb);\n  memcpy(pRtree->zName, argv[2], nName);\n\n  /* Figure out the node size to use. */\n  rc = getNodeSize(db, pRtree, isCreate, pzErr);\n\n  /* Create/Connect to the underlying relational database schema. If\n  ** that is successful, call sqlite3_declare_vtab() to configure\n  ** the r-tree table schema.\n  */\n  if( rc==SQLITE_OK ){\n    if( (rc = rtreeSqlInit(pRtree, db, argv[1], argv[2], isCreate)) ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }else{\n      char *zSql = sqlite3_mprintf(\"CREATE TABLE x(%s\", argv[3]);\n      char *zTmp;\n      int ii;\n      for(ii=4; zSql && ii<argc; ii++){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s, %s\", zTmp, argv[ii]);\n        sqlite3_free(zTmp);\n      }\n      if( zSql ){\n        zTmp = zSql;\n        zSql = sqlite3_mprintf(\"%s);\", zTmp);\n        sqlite3_free(zTmp);\n      }\n      if( !zSql ){\n        rc = SQLITE_NOMEM;\n      }else if( SQLITE_OK!=(rc = sqlite3_declare_vtab(db, zSql)) ){\n        *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      }\n      sqlite3_free(zSql);\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    *ppVtab = (sqlite3_vtab *)pRtree;\n  }else{\n    assert( *ppVtab==0 );\n    assert( pRtree->nBusy==1 );\n    rtreeRelease(pRtree);\n  }\n  return rc;\n}\n\n\n/*\n** Implementation of a scalar function that decodes r-tree nodes to\n** human readable strings. This can be used for debugging and analysis.\n**\n** The scalar function takes two arguments: (1) the number of dimensions\n** to the rtree (between 1 and 5, inclusive) and (2) a blob of data containing\n** an r-tree node.  For a two-dimensional r-tree structure called \"rt\", to\n** deserialize all nodes, a statement like:\n**\n**   SELECT rtreenode(2, data) FROM rt_node;\n**\n** The human readable string takes the form of a Tcl list with one\n** entry for each cell in the r-tree node. Each entry is itself a\n** list, containing the 8-byte rowid/pageno followed by the \n** <num-dimension>*2 coordinates.\n*/\nstatic void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  char *zText = 0;\n  RtreeNode node;\n  Rtree tree;\n  int ii;\n\n  UNUSED_PARAMETER(nArg);\n  memset(&node, 0, sizeof(RtreeNode));\n  memset(&tree, 0, sizeof(Rtree));\n  tree.nDim = (u8)sqlite3_value_int(apArg[0]);\n  tree.nDim2 = tree.nDim*2;\n  tree.nBytesPerCell = 8 + 8 * tree.nDim;\n  node.zData = (u8 *)sqlite3_value_blob(apArg[1]);\n\n  for(ii=0; ii<NCELL(&node); ii++){\n    char zCell[512];\n    int nCell = 0;\n    RtreeCell cell;\n    int jj;\n\n    nodeGetCell(&tree, &node, ii, &cell);\n    sqlite3_snprintf(512-nCell,&zCell[nCell],\"%lld\", cell.iRowid);\n    nCell = (int)strlen(zCell);\n    for(jj=0; jj<tree.nDim2; jj++){\n#ifndef SQLITE_RTREE_INT_ONLY\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %g\",\n                       (double)cell.aCoord[jj].f);\n#else\n      sqlite3_snprintf(512-nCell,&zCell[nCell], \" %d\",\n                       cell.aCoord[jj].i);\n#endif\n      nCell = (int)strlen(zCell);\n    }\n\n    if( zText ){\n      char *zTextNew = sqlite3_mprintf(\"%s {%s}\", zText, zCell);\n      sqlite3_free(zText);\n      zText = zTextNew;\n    }else{\n      zText = sqlite3_mprintf(\"{%s}\", zCell);\n    }\n  }\n  \n  sqlite3_result_text(ctx, zText, -1, sqlite3_free);\n}\n\n/* This routine implements an SQL function that returns the \"depth\" parameter\n** from the front of a blob that is an r-tree node.  For example:\n**\n**     SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1;\n**\n** The depth value is 0 for all nodes other than the root node, and the root\n** node always has nodeno=1, so the example above is the primary use for this\n** routine.  This routine is intended for testing and analysis only.\n*/\nstatic void rtreedepth(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){\n  UNUSED_PARAMETER(nArg);\n  if( sqlite3_value_type(apArg[0])!=SQLITE_BLOB \n   || sqlite3_value_bytes(apArg[0])<2\n  ){\n    sqlite3_result_error(ctx, \"Invalid argument to rtreedepth()\", -1); \n  }else{\n    u8 *zBlob = (u8 *)sqlite3_value_blob(apArg[0]);\n    sqlite3_result_int(ctx, readInt16(zBlob));\n  }\n}\n\n/*\n** Register the r-tree module with database handle db. This creates the\n** virtual table module \"rtree\" and the debugging/analysis scalar \n** function \"rtreenode\".\n*/\nSQLITE_PRIVATE int sqlite3RtreeInit(sqlite3 *db){\n  const int utf8 = SQLITE_UTF8;\n  int rc;\n\n  rc = sqlite3_create_function(db, \"rtreenode\", 2, utf8, 0, rtreenode, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"rtreedepth\", 1, utf8, 0,rtreedepth, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n#ifdef SQLITE_RTREE_INT_ONLY\n    void *c = (void *)RTREE_COORD_INT32;\n#else\n    void *c = (void *)RTREE_COORD_REAL32;\n#endif\n    rc = sqlite3_create_module_v2(db, \"rtree\", &rtreeModule, c, 0);\n  }\n  if( rc==SQLITE_OK ){\n    void *c = (void *)RTREE_COORD_INT32;\n    rc = sqlite3_create_module_v2(db, \"rtree_i32\", &rtreeModule, c, 0);\n  }\n\n  return rc;\n}\n\n/*\n** This routine deletes the RtreeGeomCallback object that was attached\n** one of the SQL functions create by sqlite3_rtree_geometry_callback()\n** or sqlite3_rtree_query_callback().  In other words, this routine is the\n** destructor for an RtreeGeomCallback objecct.  This routine is called when\n** the corresponding SQL function is deleted.\n*/\nstatic void rtreeFreeCallback(void *p){\n  RtreeGeomCallback *pInfo = (RtreeGeomCallback*)p;\n  if( pInfo->xDestructor ) pInfo->xDestructor(pInfo->pContext);\n  sqlite3_free(p);\n}\n\n/*\n** This routine frees the BLOB that is returned by geomCallback().\n*/\nstatic void rtreeMatchArgFree(void *pArg){\n  int i;\n  RtreeMatchArg *p = (RtreeMatchArg*)pArg;\n  for(i=0; i<p->nParam; i++){\n    sqlite3_value_free(p->apSqlParam[i]);\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Each call to sqlite3_rtree_geometry_callback() or\n** sqlite3_rtree_query_callback() creates an ordinary SQLite\n** scalar function that is implemented by this routine.\n**\n** All this function does is construct an RtreeMatchArg object that\n** contains the geometry-checking callback routines and a list of\n** parameters to this function, then return that RtreeMatchArg object\n** as a BLOB.\n**\n** The R-Tree MATCH operator will read the returned BLOB, deserialize\n** the RtreeMatchArg object, and use the RtreeMatchArg object to figure\n** out which elements of the R-Tree should be returned by the query.\n*/\nstatic void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n  RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);\n  RtreeMatchArg *pBlob;\n  int nBlob;\n  int memErr = 0;\n\n  nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue)\n           + nArg*sizeof(sqlite3_value*);\n  pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);\n  if( !pBlob ){\n    sqlite3_result_error_nomem(ctx);\n  }else{\n    int i;\n    pBlob->iSize = nBlob;\n    pBlob->cb = pGeomCtx[0];\n    pBlob->apSqlParam = (sqlite3_value**)&pBlob->aParam[nArg];\n    pBlob->nParam = nArg;\n    for(i=0; i<nArg; i++){\n      pBlob->apSqlParam[i] = sqlite3_value_dup(aArg[i]);\n      if( pBlob->apSqlParam[i]==0 ) memErr = 1;\n#ifdef SQLITE_RTREE_INT_ONLY\n      pBlob->aParam[i] = sqlite3_value_int64(aArg[i]);\n#else\n      pBlob->aParam[i] = sqlite3_value_double(aArg[i]);\n#endif\n    }\n    if( memErr ){\n      sqlite3_result_error_nomem(ctx);\n      rtreeMatchArgFree(pBlob);\n    }else{\n      sqlite3_result_pointer(ctx, pBlob, \"RtreeMatchArg\", rtreeMatchArgFree);\n    }\n  }\n}\n\n/*\n** Register a new geometry function for use with the r-tree MATCH operator.\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,                  /* Register SQL function on this connection */\n  const char *zGeom,            /* Name of the new SQL function */\n  int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */\n  void *pContext                /* Extra data associated with the callback */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = xGeom;\n  pGeomCtx->xQueryFunc = 0;\n  pGeomCtx->xDestructor = 0;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zGeom, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n/*\n** Register a new 2nd-generation geometry function for use with the\n** r-tree MATCH operator.\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,                 /* Register SQL function on this connection */\n  const char *zQueryFunc,      /* Name of new SQL function */\n  int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */\n  void *pContext,              /* Extra data passed into the callback */\n  void (*xDestructor)(void*)   /* Destructor for the extra data */\n){\n  RtreeGeomCallback *pGeomCtx;      /* Context object for new user-function */\n\n  /* Allocate and populate the context object. */\n  pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback));\n  if( !pGeomCtx ) return SQLITE_NOMEM;\n  pGeomCtx->xGeom = 0;\n  pGeomCtx->xQueryFunc = xQueryFunc;\n  pGeomCtx->xDestructor = xDestructor;\n  pGeomCtx->pContext = pContext;\n  return sqlite3_create_function_v2(db, zQueryFunc, -1, SQLITE_ANY, \n      (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback\n  );\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_rtree_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3RtreeInit(db);\n}\n#endif\n\n#endif\n\n/************** End of rtree.c ***********************************************/\n/************** Begin file icu.c *********************************************/\n/*\n** 2007 May 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** $Id: icu.c,v 1.7 2007/12/13 21:54:11 drh Exp $\n**\n** This file implements an integration between the ICU library \n** (\"International Components for Unicode\", an open-source library \n** for handling unicode data) and SQLite. The integration uses \n** ICU to provide the following to SQLite:\n**\n**   * An implementation of the SQL regexp() function (and hence REGEXP\n**     operator) using the ICU uregex_XX() APIs.\n**\n**   * Implementations of the SQL scalar upper() and lower() functions\n**     for case mapping.\n**\n**   * Integration of ICU and SQLite collation sequences.\n**\n**   * An implementation of the LIKE operator that uses ICU to \n**     provide case-independent matching.\n*/\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)\n\n/* Include ICU headers */\n#include <unicode/utypes.h>\n#include <unicode/uregex.h>\n#include <unicode/ustring.h>\n#include <unicode/ucol.h>\n\n/* #include <assert.h> */\n\n#ifndef SQLITE_CORE\n/*   #include \"sqlite3ext.h\" */\n  SQLITE_EXTENSION_INIT1\n#else\n/*   #include \"sqlite3.h\" */\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Version of sqlite3_free() that is always a function, never a macro.\n*/\nstatic void xFree(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character. It is copied here from SQLite source\n** code file utf8.c.\n*/\nstatic const unsigned char icuUtf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define SQLITE_ICU_READ_UTF8(zIn, c)                       \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = icuUtf8Trans1[c-0xc0];                             \\\n    while( (*zIn & 0xc0)==0x80 ){                          \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n  }\n\n#define SQLITE_ICU_SKIP_UTF8(zIn)                          \\\n  assert( *zIn );                                          \\\n  if( *(zIn++)>=0xc0 ){                                    \\\n    while( (*zIn & 0xc0)==0x80 ){zIn++;}                   \\\n  }\n\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a \"LIKE\" expression. Return true (1) if they are the same and \n** false (0) if they are different.\n*/\nstatic int icuLikeCompare(\n  const uint8_t *zPattern,   /* LIKE pattern */\n  const uint8_t *zString,    /* The UTF-8 string to compare against */\n  const UChar32 uEsc         /* The escape character */\n){\n  static const uint32_t MATCH_ONE = (uint32_t)'_';\n  static const uint32_t MATCH_ALL = (uint32_t)'%';\n\n  int prevEscape = 0;     /* True if the previous character was uEsc */\n\n  while( 1 ){\n\n    /* Read (and consume) the next character from the input pattern. */\n    uint32_t uPattern;\n    SQLITE_ICU_READ_UTF8(zPattern, uPattern);\n    if( uPattern==0 ) break;\n\n    /* There are now 4 possibilities:\n    **\n    **     1. uPattern is an unescaped match-all character \"%\",\n    **     2. uPattern is an unescaped match-one character \"_\",\n    **     3. uPattern is an unescaped escape character, or\n    **     4. uPattern is to be handled as an ordinary character\n    */\n    if( !prevEscape && uPattern==MATCH_ALL ){\n      /* Case 1. */\n      uint8_t c;\n\n      /* Skip any MATCH_ALL or MATCH_ONE characters that follow a\n      ** MATCH_ALL. For each MATCH_ONE, skip one character in the \n      ** test string.\n      */\n      while( (c=*zPattern) == MATCH_ALL || c == MATCH_ONE ){\n        if( c==MATCH_ONE ){\n          if( *zString==0 ) return 0;\n          SQLITE_ICU_SKIP_UTF8(zString);\n        }\n        zPattern++;\n      }\n\n      if( *zPattern==0 ) return 1;\n\n      while( *zString ){\n        if( icuLikeCompare(zPattern, zString, uEsc) ){\n          return 1;\n        }\n        SQLITE_ICU_SKIP_UTF8(zString);\n      }\n      return 0;\n\n    }else if( !prevEscape && uPattern==MATCH_ONE ){\n      /* Case 2. */\n      if( *zString==0 ) return 0;\n      SQLITE_ICU_SKIP_UTF8(zString);\n\n    }else if( !prevEscape && uPattern==(uint32_t)uEsc){\n      /* Case 3. */\n      prevEscape = 1;\n\n    }else{\n      /* Case 4. */\n      uint32_t uString;\n      SQLITE_ICU_READ_UTF8(zString, uString);\n      uString = (uint32_t)u_foldCase((UChar32)uString, U_FOLD_CASE_DEFAULT);\n      uPattern = (uint32_t)u_foldCase((UChar32)uPattern, U_FOLD_CASE_DEFAULT);\n      if( uString!=uPattern ){\n        return 0;\n      }\n      prevEscape = 0;\n    }\n  }\n\n  return *zString==0;\n}\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B, A). If there is an escape character E, \n**\n**       A LIKE B ESCAPE E\n**\n** is mapped to like(B, A, E).\n*/\nstatic void icuLikeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA = sqlite3_value_text(argv[0]);\n  const unsigned char *zB = sqlite3_value_text(argv[1]);\n  UChar32 uEsc = 0;\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  if( sqlite3_value_bytes(argv[0])>SQLITE_MAX_LIKE_PATTERN_LENGTH ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    int nE= sqlite3_value_bytes(argv[2]);\n    const unsigned char *zE = sqlite3_value_text(argv[2]);\n    int i = 0;\n    if( zE==0 ) return;\n    U8_NEXT(zE, i, nE, uEsc);\n    if( i!=nE){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n  }\n\n  if( zA && zB ){\n    sqlite3_result_int(context, icuLikeCompare(zA, zB, uEsc));\n  }\n}\n\n/*\n** This function is called when an ICU function called from within\n** the implementation of an SQL scalar function returns an error.\n**\n** The scalar function context passed as the first argument is \n** loaded with an error message based on the following two args.\n*/\nstatic void icuFunctionError(\n  sqlite3_context *pCtx,       /* SQLite scalar function context */\n  const char *zName,           /* Name of ICU function that failed */\n  UErrorCode e                 /* Error code returned by ICU function */\n){\n  char zBuf[128];\n  sqlite3_snprintf(128, zBuf, \"ICU error: %s(): %s\", zName, u_errorName(e));\n  zBuf[127] = '\\0';\n  sqlite3_result_error(pCtx, zBuf, -1);\n}\n\n/*\n** Function to delete compiled regexp objects. Registered as\n** a destructor function with sqlite3_set_auxdata().\n*/\nstatic void icuRegexpDelete(void *p){\n  URegularExpression *pExpr = (URegularExpression *)p;\n  uregex_close(pExpr);\n}\n\n/*\n** Implementation of SQLite REGEXP operator. This scalar function takes\n** two arguments. The first is a regular expression pattern to compile\n** the second is a string to match against that pattern. If either \n** argument is an SQL NULL, then NULL Is returned. Otherwise, the result\n** is 1 if the string matches the pattern, or 0 otherwise.\n**\n** SQLite maps the regexp() function to the regexp() operator such\n** that the following two are equivalent:\n**\n**     zString REGEXP zPattern\n**     regexp(zPattern, zString)\n**\n** Uses the following ICU regexp APIs:\n**\n**     uregex_open()\n**     uregex_matches()\n**     uregex_close()\n*/\nstatic void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  UErrorCode status = U_ZERO_ERROR;\n  URegularExpression *pExpr;\n  UBool res;\n  const UChar *zString = sqlite3_value_text16(apArg[1]);\n\n  (void)nArg;  /* Unused parameter */\n\n  /* If the left hand side of the regexp operator is NULL, \n  ** then the result is also NULL. \n  */\n  if( !zString ){\n    return;\n  }\n\n  pExpr = sqlite3_get_auxdata(p, 0);\n  if( !pExpr ){\n    const UChar *zPattern = sqlite3_value_text16(apArg[0]);\n    if( !zPattern ){\n      return;\n    }\n    pExpr = uregex_open(zPattern, -1, 0, 0, &status);\n\n    if( U_SUCCESS(status) ){\n      sqlite3_set_auxdata(p, 0, pExpr, icuRegexpDelete);\n    }else{\n      assert(!pExpr);\n      icuFunctionError(p, \"uregex_open\", status);\n      return;\n    }\n  }\n\n  /* Configure the text that the regular expression operates on. */\n  uregex_setText(pExpr, zString, -1, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_setText\", status);\n    return;\n  }\n\n  /* Attempt the match */\n  res = uregex_matches(pExpr, 0, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"uregex_matches\", status);\n    return;\n  }\n\n  /* Set the text that the regular expression operates on to a NULL\n  ** pointer. This is not really necessary, but it is tidier than \n  ** leaving the regular expression object configured with an invalid\n  ** pointer after this function returns.\n  */\n  uregex_setText(pExpr, 0, 0, &status);\n\n  /* Return 1 or 0. */\n  sqlite3_result_int(p, res ? 1 : 0);\n}\n\n/*\n** Implementations of scalar functions for case mapping - upper() and \n** lower(). Function upper() converts its input to upper-case (ABC).\n** Function lower() converts to lower-case (abc).\n**\n** ICU provides two types of case mapping, \"general\" case mapping and\n** \"language specific\". Refer to ICU documentation for the differences\n** between the two.\n**\n** To utilise \"general\" case mapping, the upper() or lower() scalar \n** functions are invoked with one argument:\n**\n**     upper('ABC') -> 'abc'\n**     lower('abc') -> 'ABC'\n**\n** To access ICU \"language specific\" case mapping, upper() or lower()\n** should be invoked with two arguments. The second argument is the name\n** of the locale to use. Passing an empty string (\"\") or SQL NULL value\n** as the second argument is the same as invoking the 1 argument version\n** of upper() or lower().\n**\n**     lower('I', 'en_us') -> 'i'\n**     lower('I', 'tr_tr') -> '\\u131' (small dotless i)\n**\n** http://www.icu-project.org/userguide/posix.html#case_mappings\n*/\nstatic void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){\n  const UChar *zInput;            /* Pointer to input string */\n  UChar *zOutput = 0;             /* Pointer to output buffer */\n  int nInput;                     /* Size of utf-16 input string in bytes */\n  int nOut;                       /* Size of output buffer in bytes */\n  int cnt;\n  int bToUpper;                   /* True for toupper(), false for tolower() */\n  UErrorCode status;\n  const char *zLocale = 0;\n\n  assert(nArg==1 || nArg==2);\n  bToUpper = (sqlite3_user_data(p)!=0);\n  if( nArg==2 ){\n    zLocale = (const char *)sqlite3_value_text(apArg[1]);\n  }\n\n  zInput = sqlite3_value_text16(apArg[0]);\n  if( !zInput ){\n    return;\n  }\n  nOut = nInput = sqlite3_value_bytes16(apArg[0]);\n  if( nOut==0 ){\n    sqlite3_result_text16(p, \"\", 0, SQLITE_STATIC);\n    return;\n  }\n\n  for(cnt=0; cnt<2; cnt++){\n    UChar *zNew = sqlite3_realloc(zOutput, nOut);\n    if( zNew==0 ){\n      sqlite3_free(zOutput);\n      sqlite3_result_error_nomem(p);\n      return;\n    }\n    zOutput = zNew;\n    status = U_ZERO_ERROR;\n    if( bToUpper ){\n      nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }else{\n      nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);\n    }\n\n    if( U_SUCCESS(status) ){\n      sqlite3_result_text16(p, zOutput, nOut, xFree);\n    }else if( status==U_BUFFER_OVERFLOW_ERROR ){\n      assert( cnt==0 );\n      continue;\n    }else{\n      icuFunctionError(p, bToUpper ? \"u_strToUpper\" : \"u_strToLower\", status);\n    }\n    return;\n  }\n  assert( 0 );     /* Unreachable */\n}\n\n/*\n** Collation sequence destructor function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic void icuCollationDel(void *pCtx){\n  UCollator *p = (UCollator *)pCtx;\n  ucol_close(p);\n}\n\n/*\n** Collation sequence comparison function. The pCtx argument points to\n** a UCollator structure previously allocated using ucol_open().\n*/\nstatic int icuCollationColl(\n  void *pCtx,\n  int nLeft,\n  const void *zLeft,\n  int nRight,\n  const void *zRight\n){\n  UCollationResult res;\n  UCollator *p = (UCollator *)pCtx;\n  res = ucol_strcoll(p, (UChar *)zLeft, nLeft/2, (UChar *)zRight, nRight/2);\n  switch( res ){\n    case UCOL_LESS:    return -1;\n    case UCOL_GREATER: return +1;\n    case UCOL_EQUAL:   return 0;\n  }\n  assert(!\"Unexpected return value from ucol_strcoll()\");\n  return 0;\n}\n\n/*\n** Implementation of the scalar function icu_load_collation().\n**\n** This scalar function is used to add ICU collation based collation \n** types to an SQLite database connection. It is intended to be called\n** as follows:\n**\n**     SELECT icu_load_collation(<locale>, <collation-name>);\n**\n** Where <locale> is a string containing an ICU locale identifier (i.e.\n** \"en_AU\", \"tr_TR\" etc.) and <collation-name> is the name of the\n** collation sequence to create.\n*/\nstatic void icuLoadCollation(\n  sqlite3_context *p, \n  int nArg, \n  sqlite3_value **apArg\n){\n  sqlite3 *db = (sqlite3 *)sqlite3_user_data(p);\n  UErrorCode status = U_ZERO_ERROR;\n  const char *zLocale;      /* Locale identifier - (eg. \"jp_JP\") */\n  const char *zName;        /* SQL Collation sequence name (eg. \"japanese\") */\n  UCollator *pUCollator;    /* ICU library collation object */\n  int rc;                   /* Return code from sqlite3_create_collation_x() */\n\n  assert(nArg==2);\n  (void)nArg; /* Unused parameter */\n  zLocale = (const char *)sqlite3_value_text(apArg[0]);\n  zName = (const char *)sqlite3_value_text(apArg[1]);\n\n  if( !zLocale || !zName ){\n    return;\n  }\n\n  pUCollator = ucol_open(zLocale, &status);\n  if( !U_SUCCESS(status) ){\n    icuFunctionError(p, \"ucol_open\", status);\n    return;\n  }\n  assert(p);\n\n  rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator, \n      icuCollationColl, icuCollationDel\n  );\n  if( rc!=SQLITE_OK ){\n    ucol_close(pUCollator);\n    sqlite3_result_error(p, \"Error registering collation function\", -1);\n  }\n}\n\n/*\n** Register the ICU extension functions with database db.\n*/\nSQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){\n  static const struct IcuScalar {\n    const char *zName;                        /* Function name */\n    unsigned char nArg;                       /* Number of arguments */\n    unsigned short enc;                       /* Optimal text encoding */\n    unsigned char iContext;                   /* sqlite3_user_data() context */\n    void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } scalars[] = {\n    {\"icu_load_collation\",  2, SQLITE_UTF8,                1, icuLoadCollation},\n    {\"regexp\", 2, SQLITE_ANY|SQLITE_DETERMINISTIC,         0, icuRegexpFunc},\n    {\"lower\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF16|SQLITE_DETERMINISTIC,       1, icuCaseFunc16},\n    {\"lower\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"lower\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuCaseFunc16},\n    {\"upper\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"upper\",  2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        1, icuCaseFunc16},\n    {\"like\",   2, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n    {\"like\",   3, SQLITE_UTF8|SQLITE_DETERMINISTIC,        0, icuLikeFunc},\n  };\n  int rc = SQLITE_OK;\n  int i;\n\n  \n  for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){\n    const struct IcuScalar *p = &scalars[i];\n    rc = sqlite3_create_function(\n        db, p->zName, p->nArg, p->enc, \n        p->iContext ? (void*)db : (void*)0,\n        p->xFunc, 0, 0\n    );\n  }\n\n  return rc;\n}\n\n#if !SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_icu_init(\n  sqlite3 *db, \n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi)\n  return sqlite3IcuInit(db);\n}\n#endif\n\n#endif\n\n/************** End of icu.c *************************************************/\n/************** Begin file fts3_icu.c ****************************************/\n/*\n** 2007 June 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a tokenizer for fts3 based on the ICU library.\n*/\n/* #include \"fts3Int.h\" */\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)\n#ifdef SQLITE_ENABLE_ICU\n\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include \"fts3_tokenizer.h\" */\n\n#include <unicode/ubrk.h>\n/* #include <unicode/ucol.h> */\n/* #include <unicode/ustring.h> */\n#include <unicode/utf16.h>\n\ntypedef struct IcuTokenizer IcuTokenizer;\ntypedef struct IcuCursor IcuCursor;\n\nstruct IcuTokenizer {\n  sqlite3_tokenizer base;\n  char *zLocale;\n};\n\nstruct IcuCursor {\n  sqlite3_tokenizer_cursor base;\n\n  UBreakIterator *pIter;      /* ICU break-iterator object */\n  int nChar;                  /* Number of UChar elements in pInput */\n  UChar *aChar;               /* Copy of input using utf-16 encoding */\n  int *aOffset;               /* Offsets of each character in utf-8 input */\n\n  int nBuffer;\n  char *zBuffer;\n\n  int iToken;\n};\n\n/*\n** Create a new tokenizer instance.\n*/\nstatic int icuCreate(\n  int argc,                            /* Number of entries in argv[] */\n  const char * const *argv,            /* Tokenizer creation arguments */\n  sqlite3_tokenizer **ppTokenizer      /* OUT: Created tokenizer */\n){\n  IcuTokenizer *p;\n  int n = 0;\n\n  if( argc>0 ){\n    n = strlen(argv[0])+1;\n  }\n  p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);\n  if( !p ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(IcuTokenizer));\n\n  if( n ){\n    p->zLocale = (char *)&p[1];\n    memcpy(p->zLocale, argv[0], n);\n  }\n\n  *ppTokenizer = (sqlite3_tokenizer *)p;\n\n  return SQLITE_OK;\n}\n\n/*\n** Destroy a tokenizer\n*/\nstatic int icuDestroy(sqlite3_tokenizer *pTokenizer){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Prepare to begin tokenizing a particular string.  The input\n** string to be tokenized is pInput[0..nBytes-1].  A cursor\n** used to incrementally tokenize this string is returned in \n** *ppCursor.\n*/\nstatic int icuOpen(\n  sqlite3_tokenizer *pTokenizer,         /* The tokenizer */\n  const char *zInput,                    /* Input string */\n  int nInput,                            /* Length of zInput in bytes */\n  sqlite3_tokenizer_cursor **ppCursor    /* OUT: Tokenization cursor */\n){\n  IcuTokenizer *p = (IcuTokenizer *)pTokenizer;\n  IcuCursor *pCsr;\n\n  const int32_t opt = U_FOLD_CASE_DEFAULT;\n  UErrorCode status = U_ZERO_ERROR;\n  int nChar;\n\n  UChar32 c;\n  int iInput = 0;\n  int iOut = 0;\n\n  *ppCursor = 0;\n\n  if( zInput==0 ){\n    nInput = 0;\n    zInput = \"\";\n  }else if( nInput<0 ){\n    nInput = strlen(zInput);\n  }\n  nChar = nInput+1;\n  pCsr = (IcuCursor *)sqlite3_malloc(\n      sizeof(IcuCursor) +                /* IcuCursor */\n      ((nChar+3)&~3) * sizeof(UChar) +   /* IcuCursor.aChar[] */\n      (nChar+1) * sizeof(int)            /* IcuCursor.aOffset[] */\n  );\n  if( !pCsr ){\n    return SQLITE_NOMEM;\n  }\n  memset(pCsr, 0, sizeof(IcuCursor));\n  pCsr->aChar = (UChar *)&pCsr[1];\n  pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];\n\n  pCsr->aOffset[iOut] = iInput;\n  U8_NEXT(zInput, iInput, nInput, c); \n  while( c>0 ){\n    int isError = 0;\n    c = u_foldCase(c, opt);\n    U16_APPEND(pCsr->aChar, iOut, nChar, c, isError);\n    if( isError ){\n      sqlite3_free(pCsr);\n      return SQLITE_ERROR;\n    }\n    pCsr->aOffset[iOut] = iInput;\n\n    if( iInput<nInput ){\n      U8_NEXT(zInput, iInput, nInput, c);\n    }else{\n      c = 0;\n    }\n  }\n\n  pCsr->pIter = ubrk_open(UBRK_WORD, p->zLocale, pCsr->aChar, iOut, &status);\n  if( !U_SUCCESS(status) ){\n    sqlite3_free(pCsr);\n    return SQLITE_ERROR;\n  }\n  pCsr->nChar = iOut;\n\n  ubrk_first(pCsr->pIter);\n  *ppCursor = (sqlite3_tokenizer_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tokenization cursor previously opened by a call to icuOpen().\n*/\nstatic int icuClose(sqlite3_tokenizer_cursor *pCursor){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n  ubrk_close(pCsr->pIter);\n  sqlite3_free(pCsr->zBuffer);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Extract the next token from a tokenization cursor.\n*/\nstatic int icuNext(\n  sqlite3_tokenizer_cursor *pCursor,  /* Cursor returned by simpleOpen */\n  const char **ppToken,               /* OUT: *ppToken is the token text */\n  int *pnBytes,                       /* OUT: Number of bytes in token */\n  int *piStartOffset,                 /* OUT: Starting offset of token */\n  int *piEndOffset,                   /* OUT: Ending offset of token */\n  int *piPosition                     /* OUT: Position integer of token */\n){\n  IcuCursor *pCsr = (IcuCursor *)pCursor;\n\n  int iStart = 0;\n  int iEnd = 0;\n  int nByte = 0;\n\n  while( iStart==iEnd ){\n    UChar32 c;\n\n    iStart = ubrk_current(pCsr->pIter);\n    iEnd = ubrk_next(pCsr->pIter);\n    if( iEnd==UBRK_DONE ){\n      return SQLITE_DONE;\n    }\n\n    while( iStart<iEnd ){\n      int iWhite = iStart;\n      U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c);\n      if( u_isspace(c) ){\n        iStart = iWhite;\n      }else{\n        break;\n      }\n    }\n    assert(iStart<=iEnd);\n  }\n\n  do {\n    UErrorCode status = U_ZERO_ERROR;\n    if( nByte ){\n      char *zNew = sqlite3_realloc(pCsr->zBuffer, nByte);\n      if( !zNew ){\n        return SQLITE_NOMEM;\n      }\n      pCsr->zBuffer = zNew;\n      pCsr->nBuffer = nByte;\n    }\n\n    u_strToUTF8(\n        pCsr->zBuffer, pCsr->nBuffer, &nByte,    /* Output vars */\n        &pCsr->aChar[iStart], iEnd-iStart,       /* Input vars */\n        &status                                  /* Output success/failure */\n    );\n  } while( nByte>pCsr->nBuffer );\n\n  *ppToken = pCsr->zBuffer;\n  *pnBytes = nByte;\n  *piStartOffset = pCsr->aOffset[iStart];\n  *piEndOffset = pCsr->aOffset[iEnd];\n  *piPosition = pCsr->iToken++;\n\n  return SQLITE_OK;\n}\n\n/*\n** The set of routines that implement the simple tokenizer\n*/\nstatic const sqlite3_tokenizer_module icuTokenizerModule = {\n  0,                           /* iVersion    */\n  icuCreate,                   /* xCreate     */\n  icuDestroy,                  /* xCreate     */\n  icuOpen,                     /* xOpen       */\n  icuClose,                    /* xClose      */\n  icuNext,                     /* xNext       */\n  0,                           /* xLanguageid */\n};\n\n/*\n** Set *ppModule to point at the implementation of the ICU tokenizer.\n*/\nSQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(\n  sqlite3_tokenizer_module const**ppModule\n){\n  *ppModule = &icuTokenizerModule;\n}\n\n#endif /* defined(SQLITE_ENABLE_ICU) */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */\n\n/************** End of fts3_icu.c ********************************************/\n/************** Begin file sqlite3rbu.c **************************************/\n/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**\n** OVERVIEW \n**\n**  The RBU extension requires that the RBU update be packaged as an\n**  SQLite database. The tables it expects to find are described in\n**  sqlite3rbu.h.  Essentially, for each table xyz in the target database\n**  that the user wishes to write to, a corresponding data_xyz table is\n**  created in the RBU database and populated with one row for each row to\n**  update, insert or delete from the target table.\n** \n**  The update proceeds in three stages:\n** \n**  1) The database is updated. The modified database pages are written\n**     to a *-oal file. A *-oal file is just like a *-wal file, except\n**     that it is named \"<database>-oal\" instead of \"<database>-wal\".\n**     Because regular SQLite clients do not look for file named\n**     \"<database>-oal\", they go on using the original database in\n**     rollback mode while the *-oal file is being generated.\n** \n**     During this stage RBU does not update the database by writing\n**     directly to the target tables. Instead it creates \"imposter\"\n**     tables using the SQLITE_TESTCTRL_IMPOSTER interface that it uses\n**     to update each b-tree individually. All updates required by each\n**     b-tree are completed before moving on to the next, and all\n**     updates are done in sorted key order.\n** \n**  2) The \"<database>-oal\" file is moved to the equivalent \"<database>-wal\"\n**     location using a call to rename(2). Before doing this the RBU\n**     module takes an EXCLUSIVE lock on the database file, ensuring\n**     that there are no other active readers.\n** \n**     Once the EXCLUSIVE lock is released, any other database readers\n**     detect the new *-wal file and read the database in wal mode. At\n**     this point they see the new version of the database - including\n**     the updates made as part of the RBU update.\n** \n**  3) The new *-wal file is checkpointed. This proceeds in the same way \n**     as a regular database checkpoint, except that a single frame is\n**     checkpointed each time sqlite3rbu_step() is called. If the RBU\n**     handle is closed before the entire *-wal file is checkpointed,\n**     the checkpoint progress is saved in the RBU database and the\n**     checkpoint can be resumed by another RBU client at some point in\n**     the future.\n**\n** POTENTIAL PROBLEMS\n** \n**  The rename() call might not be portable. And RBU is not currently\n**  syncing the directory after renaming the file.\n**\n**  When state is saved, any commit to the *-oal file and the commit to\n**  the RBU update database are not atomic. So if the power fails at the\n**  wrong moment they might get out of sync. As the main database will be\n**  committed before the RBU update database this will likely either just\n**  pass unnoticed, or result in SQLITE_CONSTRAINT errors (due to UNIQUE\n**  constraint violations).\n**\n**  If some client does modify the target database mid RBU update, or some\n**  other error occurs, the RBU extension will keep throwing errors. It's\n**  not really clear how to get out of this state. The system could just\n**  by delete the RBU update database and *-oal file and have the device\n**  download the update again and start over.\n**\n**  At present, for an UPDATE, both the new.* and old.* records are\n**  collected in the rbu_xyz table. And for both UPDATEs and DELETEs all\n**  fields are collected.  This means we're probably writing a lot more\n**  data to disk when saving the state of an ongoing update to the RBU\n**  update database than is strictly necessary.\n** \n*/\n\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include <stdio.h> */\n\n/* #include \"sqlite3.h\" */\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU)\n/************** Include sqlite3rbu.h in the middle of sqlite3rbu.c ***********/\n/************** Begin file sqlite3rbu.h **************************************/\n/*\n** 2014 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the public interface for the RBU extension. \n*/\n\n/*\n** SUMMARY\n**\n** Writing a transaction containing a large number of operations on \n** b-tree indexes that are collectively larger than the available cache\n** memory can be very inefficient. \n**\n** The problem is that in order to update a b-tree, the leaf page (at least)\n** containing the entry being inserted or deleted must be modified. If the\n** working set of leaves is larger than the available cache memory, then a \n** single leaf that is modified more than once as part of the transaction \n** may be loaded from or written to the persistent media multiple times.\n** Additionally, because the index updates are likely to be applied in\n** random order, access to pages within the database is also likely to be in \n** random order, which is itself quite inefficient.\n**\n** One way to improve the situation is to sort the operations on each index\n** by index key before applying them to the b-tree. This leads to an IO\n** pattern that resembles a single linear scan through the index b-tree,\n** and all but guarantees each modified leaf page is loaded and stored \n** exactly once. SQLite uses this trick to improve the performance of\n** CREATE INDEX commands. This extension allows it to be used to improve\n** the performance of large transactions on existing databases.\n**\n** Additionally, this extension allows the work involved in writing the \n** large transaction to be broken down into sub-transactions performed \n** sequentially by separate processes. This is useful if the system cannot \n** guarantee that a single update process will run for long enough to apply \n** the entire update, for example because the update is being applied on a \n** mobile device that is frequently rebooted. Even after the writer process \n** has committed one or more sub-transactions, other database clients continue\n** to read from the original database snapshot. In other words, partially \n** applied transactions are not visible to other clients. \n**\n** \"RBU\" stands for \"Resumable Bulk Update\". As in a large database update\n** transmitted via a wireless network to a mobile device. A transaction\n** applied using this extension is hence refered to as an \"RBU update\".\n**\n**\n** LIMITATIONS\n**\n** An \"RBU update\" transaction is subject to the following limitations:\n**\n**   * The transaction must consist of INSERT, UPDATE and DELETE operations\n**     only.\n**\n**   * INSERT statements may not use any default values.\n**\n**   * UPDATE and DELETE statements must identify their target rows by \n**     non-NULL PRIMARY KEY values. Rows with NULL values stored in PRIMARY\n**     KEY fields may not be updated or deleted. If the table being written \n**     has no PRIMARY KEY, affected rows must be identified by rowid.\n**\n**   * UPDATE statements may not modify PRIMARY KEY columns.\n**\n**   * No triggers will be fired.\n**\n**   * No foreign key violations are detected or reported.\n**\n**   * CHECK constraints are not enforced.\n**\n**   * No constraint handling mode except for \"OR ROLLBACK\" is supported.\n**\n**\n** PREPARATION\n**\n** An \"RBU update\" is stored as a separate SQLite database. A database\n** containing an RBU update is an \"RBU database\". For each table in the \n** target database to be updated, the RBU database should contain a table\n** named \"data_<target name>\" containing the same set of columns as the\n** target table, and one more - \"rbu_control\". The data_% table should \n** have no PRIMARY KEY or UNIQUE constraints, but each column should have\n** the same type as the corresponding column in the target database.\n** The \"rbu_control\" column should have no type at all. For example, if\n** the target database contains:\n**\n**   CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c UNIQUE);\n**\n** Then the RBU database should contain:\n**\n**   CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control);\n**\n** The order of the columns in the data_% table does not matter.\n**\n** Instead of a regular table, the RBU database may also contain virtual\n** tables or view named using the data_<target> naming scheme. \n**\n** Instead of the plain data_<target> naming scheme, RBU database tables \n** may also be named data<integer>_<target>, where <integer> is any sequence\n** of zero or more numeric characters (0-9). This can be significant because\n** tables within the RBU database are always processed in order sorted by \n** name. By judicious selection of the <integer> portion of the names\n** of the RBU tables the user can therefore control the order in which they\n** are processed. This can be useful, for example, to ensure that \"external\n** content\" FTS4 tables are updated before their underlying content tables.\n**\n** If the target database table is a virtual table or a table that has no\n** PRIMARY KEY declaration, the data_% table must also contain a column \n** named \"rbu_rowid\". This column is mapped to the tables implicit primary \n** key column - \"rowid\". Virtual tables for which the \"rowid\" column does \n** not function like a primary key value cannot be updated using RBU. For \n** example, if the target db contains either of the following:\n**\n**   CREATE VIRTUAL TABLE x1 USING fts3(a, b);\n**   CREATE TABLE x1(a, b)\n**\n** then the RBU database should contain:\n**\n**   CREATE TABLE data_x1(a, b, rbu_rowid, rbu_control);\n**\n** All non-hidden columns (i.e. all columns matched by \"SELECT *\") of the\n** target table must be present in the input table. For virtual tables,\n** hidden columns are optional - they are updated by RBU if present in\n** the input table, or not otherwise. For example, to write to an fts4\n** table with a hidden languageid column such as:\n**\n**   CREATE VIRTUAL TABLE ft1 USING fts4(a, b, languageid='langid');\n**\n** Either of the following input table schemas may be used:\n**\n**   CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);\n**   CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);\n**\n** For each row to INSERT into the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 0. The\n** other columns should be set to the values that make up the new record \n** to insert. \n**\n** If the target database table has an INTEGER PRIMARY KEY, it is not \n** possible to insert a NULL value into the IPK column. Attempting to \n** do so results in an SQLITE_MISMATCH error.\n**\n** For each row to DELETE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain integer value 1. The\n** real primary key values of the row to delete should be stored in the\n** corresponding columns of the data_% table. The values stored in the\n** other columns are not used.\n**\n** For each row to UPDATE from the target database as part of the RBU \n** update, the corresponding data_% table should contain a single record\n** with the \"rbu_control\" column set to contain a value of type text.\n** The real primary key values identifying the row to update should be \n** stored in the corresponding columns of the data_% table row, as should\n** the new values of all columns being update. The text value in the \n** \"rbu_control\" column must contain the same number of characters as\n** there are columns in the target database table, and must consist entirely\n** of 'x' and '.' characters (or in some special cases 'd' - see below). For \n** each column that is being updated, the corresponding character is set to\n** 'x'. For those that remain as they are, the corresponding character of the\n** rbu_control value should be set to '.'. For example, given the tables \n** above, the update statement:\n**\n**   UPDATE t1 SET c = 'usa' WHERE a = 4;\n**\n** is represented by the data_t1 row created by:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..x');\n**\n** Instead of an 'x' character, characters of the rbu_control value specified\n** for UPDATEs may also be set to 'd'. In this case, instead of updating the\n** target table with the value stored in the corresponding data_% column, the\n** user-defined SQL function \"rbu_delta()\" is invoked and the result stored in\n** the target table column. rbu_delta() is invoked with two arguments - the\n** original value currently stored in the target table column and the \n** value specified in the data_xxx table.\n**\n** For example, this row:\n**\n**   INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d');\n**\n** is similar to an UPDATE statement such as: \n**\n**   UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4;\n**\n** Finally, if an 'f' character appears in place of a 'd' or 's' in an \n** ota_control string, the contents of the data_xxx table column is assumed\n** to be a \"fossil delta\" - a patch to be applied to a blob value in the\n** format used by the fossil source-code management system. In this case\n** the existing value within the target database table must be of type BLOB. \n** It is replaced by the result of applying the specified fossil delta to\n** itself.\n**\n** If the target database table is a virtual table or a table with no PRIMARY\n** KEY, the rbu_control value should not include a character corresponding \n** to the rbu_rowid value. For example, this:\n**\n**   INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control) \n**       VALUES(NULL, 'usa', 12, '.x');\n**\n** causes a result similar to:\n**\n**   UPDATE ft1 SET b = 'usa' WHERE rowid = 12;\n**\n** The data_xxx tables themselves should have no PRIMARY KEY declarations.\n** However, RBU is more efficient if reading the rows in from each data_xxx\n** table in \"rowid\" order is roughly the same as reading them sorted by\n** the PRIMARY KEY of the corresponding target database table. In other \n** words, rows should be sorted using the destination table PRIMARY KEY \n** fields before they are inserted into the data_xxx tables.\n**\n** USAGE\n**\n** The API declared below allows an application to apply an RBU update \n** stored on disk to an existing target database. Essentially, the \n** application:\n**\n**     1) Opens an RBU handle using the sqlite3rbu_open() function.\n**\n**     2) Registers any required virtual table modules with the database\n**        handle returned by sqlite3rbu_db(). Also, if required, register\n**        the rbu_delta() implementation.\n**\n**     3) Calls the sqlite3rbu_step() function one or more times on\n**        the new handle. Each call to sqlite3rbu_step() performs a single\n**        b-tree operation, so thousands of calls may be required to apply \n**        a complete update.\n**\n**     4) Calls sqlite3rbu_close() to close the RBU update handle. If\n**        sqlite3rbu_step() has been called enough times to completely\n**        apply the update to the target database, then the RBU database\n**        is marked as fully applied. Otherwise, the state of the RBU \n**        update application is saved in the RBU database for later \n**        resumption.\n**\n** See comments below for more detail on APIs.\n**\n** If an update is only partially applied to the target database by the\n** time sqlite3rbu_close() is called, various state information is saved \n** within the RBU database. This allows subsequent processes to automatically\n** resume the RBU update from where it left off.\n**\n** To remove all RBU extension state information, returning an RBU database \n** to its original contents, it is sufficient to drop all tables that begin\n** with the prefix \"rbu_\"\n**\n** DATABASE LOCKING\n**\n** An RBU update may not be applied to a database in WAL mode. Attempting\n** to do so is an error (SQLITE_ERROR).\n**\n** While an RBU handle is open, a SHARED lock may be held on the target\n** database file. This means it is possible for other clients to read the\n** database, but not to write it.\n**\n** If an RBU update is started and then suspended before it is completed,\n** then an external client writes to the database, then attempting to resume\n** the suspended RBU update is also an error (SQLITE_BUSY).\n*/\n\n#ifndef _SQLITE3RBU_H\n#define _SQLITE3RBU_H\n\n/* #include \"sqlite3.h\"              ** Required for error code definitions ** */\n\n#if 0\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3rbu sqlite3rbu;\n\n/*\n** Open an RBU handle.\n**\n** Argument zTarget is the path to the target database. Argument zRbu is\n** the path to the RBU database. Each call to this function must be matched\n** by a call to sqlite3rbu_close(). When opening the databases, RBU passes\n** the SQLITE_CONFIG_URI flag to sqlite3_open_v2(). So if either zTarget\n** or zRbu begin with \"file:\", it will be interpreted as an SQLite \n** database URI, not a regular file name.\n**\n** If the zState argument is passed a NULL value, the RBU extension stores \n** the current state of the update (how many rows have been updated, which \n** indexes are yet to be updated etc.) within the RBU database itself. This\n** can be convenient, as it means that the RBU application does not need to\n** organize removing a separate state file after the update is concluded. \n** Or, if zState is non-NULL, it must be a path to a database file in which \n** the RBU extension can store the state of the update.\n**\n** When resuming an RBU update, the zState argument must be passed the same\n** value as when the RBU update was started.\n**\n** Once the RBU update is finished, the RBU extension does not \n** automatically remove any zState database file, even if it created it.\n**\n** By default, RBU uses the default VFS to access the files on disk. To\n** use a VFS other than the default, an SQLite \"file:\" URI containing a\n** \"vfs=...\" option may be passed as the zTarget option.\n**\n** IMPORTANT NOTE FOR ZIPVFS USERS: The RBU extension works with all of\n** SQLite's built-in VFSs, including the multiplexor VFS. However it does\n** not work out of the box with zipvfs. Refer to the comment describing\n** the zipvfs_create_vfs() API below for details on using RBU with zipvfs.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n);\n\n/*\n** Open an RBU handle to perform an RBU vacuum on database file zTarget.\n** An RBU vacuum is similar to SQLite's built-in VACUUM command, except\n** that it can be suspended and resumed like an RBU update.\n**\n** The second argument to this function identifies a database in which \n** to store the state of the RBU vacuum operation if it is suspended. The \n** first time sqlite3rbu_vacuum() is called, to start an RBU vacuum\n** operation, the state database should either not exist or be empty\n** (contain no tables). If an RBU vacuum is suspended by calling \n** sqlite3rbu_close() on the RBU handle before sqlite3rbu_step() has\n** returned SQLITE_DONE, the vacuum state is stored in the state database. \n** The vacuum can be resumed by calling this function to open a new RBU\n** handle specifying the same target and state databases.\n**\n** If the second argument passed to this function is NULL, then the\n** name of the state database is \"<database>-vacuum\", where <database>\n** is the name of the target database file. In this case, on UNIX, if the\n** state database is not already present in the file-system, it is created\n** with the same permissions as the target db is made.\n**\n** This function does not delete the state database after an RBU vacuum\n** is completed, even if it created it. However, if the call to\n** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents\n** of the state tables within the state database are zeroed. This way,\n** the next call to sqlite3rbu_vacuum() opens a handle that starts a \n** new RBU vacuum operation.\n**\n** As with sqlite3rbu_open(), Zipvfs users should rever to the comment\n** describing the sqlite3rbu_create_vfs() API function below for \n** a description of the complications associated with using RBU with \n** zipvfs databases.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n);\n\n/*\n** Configure a limit for the amount of temp space that may be used by\n** the RBU handle passed as the first argument. The new limit is specified\n** in bytes by the second parameter. If it is positive, the limit is updated.\n** If the second parameter to this function is passed zero, then the limit\n** is removed entirely. If the second parameter is negative, the limit is\n** not modified (this is useful for querying the current limit).\n**\n** In all cases the returned value is the current limit in bytes (zero \n** indicates unlimited).\n**\n** If the temp space limit is exceeded during operation, an SQLITE_FULL\n** error is returned.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu*, sqlite3_int64);\n\n/*\n** Return the current amount of temp file space, in bytes, currently used by \n** the RBU handle passed as the only argument.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu*);\n\n/*\n** Internally, each RBU connection uses a separate SQLite database \n** connection to access the target and rbu update databases. This\n** API allows the application direct access to these database handles.\n**\n** The first argument passed to this function must be a valid, open, RBU\n** handle. The second argument should be passed zero to access the target\n** database handle, or non-zero to access the rbu update database handle.\n** Accessing the underlying database handles may be useful in the\n** following scenarios:\n**\n**   * If any target tables are virtual tables, it may be necessary to\n**     call sqlite3_create_module() on the target database handle to \n**     register the required virtual table implementations.\n**\n**   * If the data_xxx tables in the RBU source database are virtual \n**     tables, the application may need to call sqlite3_create_module() on\n**     the rbu update db handle to any required virtual table\n**     implementations.\n**\n**   * If the application uses the \"rbu_delta()\" feature described above,\n**     it must use sqlite3_create_function() or similar to register the\n**     rbu_delta() implementation with the target database handle.\n**\n** If an error has occurred, either while opening or stepping the RBU object,\n** this function may return NULL. The error code and message may be collected\n** when sqlite3rbu_close() is called.\n**\n** Database handles returned by this function remain valid until the next\n** call to any sqlite3rbu_xxx() function other than sqlite3rbu_db().\n*/\nSQLITE_API sqlite3 *sqlite3rbu_db(sqlite3rbu*, int bRbu);\n\n/*\n** Do some work towards applying the RBU update to the target db. \n**\n** Return SQLITE_DONE if the update has been completely applied, or \n** SQLITE_OK if no error occurs but there remains work to do to apply\n** the RBU update. If an error does occur, some other error code is \n** returned. \n**\n** Once a call to sqlite3rbu_step() has returned a value other than\n** SQLITE_OK, all subsequent calls on the same RBU handle are no-ops\n** that immediately return the same value.\n*/\nSQLITE_API int sqlite3rbu_step(sqlite3rbu *pRbu);\n\n/*\n** Force RBU to save its state to disk.\n**\n** If a power failure or application crash occurs during an update, following\n** system recovery RBU may resume the update from the point at which the state\n** was last saved. In other words, from the most recent successful call to \n** sqlite3rbu_close() or this function.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_API int sqlite3rbu_savestate(sqlite3rbu *pRbu);\n\n/*\n** Close an RBU handle. \n**\n** If the RBU update has been completely applied, mark the RBU database\n** as fully applied. Otherwise, assuming no error has occurred, save the\n** current state of the RBU update appliation to the RBU database.\n**\n** If an error has already occurred as part of an sqlite3rbu_step()\n** or sqlite3rbu_open() call, or if one occurs within this function, an\n** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,\n** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted\n** English language error message. It is the responsibility of the caller to\n** eventually free any such buffer using sqlite3_free().\n**\n** Otherwise, if no error occurs, this function returns SQLITE_OK if the\n** update has been partially applied, or SQLITE_DONE if it has been \n** completely applied.\n*/\nSQLITE_API int sqlite3rbu_close(sqlite3rbu *pRbu, char **pzErrmsg);\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu);\n\n/*\n** Obtain permyriadage (permyriadage is to 10000 as percentage is to 100) \n** progress indications for the two stages of an RBU update. This API may\n** be useful for driving GUI progress indicators and similar.\n**\n** An RBU update is divided into two stages:\n**\n**   * Stage 1, in which changes are accumulated in an oal/wal file, and\n**   * Stage 2, in which the contents of the wal file are copied into the\n**     main database.\n**\n** The update is visible to non-RBU clients during stage 2. During stage 1\n** non-RBU reader clients may see the original database.\n**\n** If this API is called during stage 2 of the update, output variable \n** (*pnOne) is set to 10000 to indicate that stage 1 has finished and (*pnTwo)\n** to a value between 0 and 10000 to indicate the permyriadage progress of\n** stage 2. A value of 5000 indicates that stage 2 is half finished, \n** 9000 indicates that it is 90% finished, and so on.\n**\n** If this API is called during stage 1 of the update, output variable \n** (*pnTwo) is set to 0 to indicate that stage 2 has not yet started. The\n** value to which (*pnOne) is set depends on whether or not the RBU \n** database contains an \"rbu_count\" table. The rbu_count table, if it \n** exists, must contain the same columns as the following:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There must be one row in the table for each source (data_xxx) table within\n** the RBU database. The 'tbl' column should contain the name of the source\n** table. The 'cnt' column should contain the number of rows within the\n** source table.\n**\n** If the rbu_count table is present and populated correctly and this\n** API is called during stage 1, the *pnOne output variable is set to the\n** permyriadage progress of the same stage. If the rbu_count table does\n** not exist, then (*pnOne) is set to -1 during stage 1. If the rbu_count\n** table exists but is not correctly populated, the value of the *pnOne\n** output variable during stage 1 is undefined.\n*/\nSQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int*pnTwo);\n\n/*\n** Obtain an indication as to the current stage of an RBU update or vacuum.\n** This function always returns one of the SQLITE_RBU_STATE_XXX constants\n** defined in this file. Return values should be interpreted as follows:\n**\n** SQLITE_RBU_STATE_OAL:\n**   RBU is currently building a *-oal file. The next call to sqlite3rbu_step()\n**   may either add further data to the *-oal file, or compute data that will\n**   be added by a subsequent call.\n**\n** SQLITE_RBU_STATE_MOVE:\n**   RBU has finished building the *-oal file. The next call to sqlite3rbu_step()\n**   will move the *-oal file to the equivalent *-wal path. If the current\n**   operation is an RBU update, then the updated version of the database\n**   file will become visible to ordinary SQLite clients following the next\n**   call to sqlite3rbu_step().\n**\n** SQLITE_RBU_STATE_CHECKPOINT:\n**   RBU is currently performing an incremental checkpoint. The next call to\n**   sqlite3rbu_step() will copy a page of data from the *-wal file into\n**   the target database file.\n**\n** SQLITE_RBU_STATE_DONE:\n**   The RBU operation has finished. Any subsequent calls to sqlite3rbu_step()\n**   will immediately return SQLITE_DONE.\n**\n** SQLITE_RBU_STATE_ERROR:\n**   An error has occurred. Any subsequent calls to sqlite3rbu_step() will\n**   immediately return the SQLite error code associated with the error.\n*/\n#define SQLITE_RBU_STATE_OAL        1\n#define SQLITE_RBU_STATE_MOVE       2\n#define SQLITE_RBU_STATE_CHECKPOINT 3\n#define SQLITE_RBU_STATE_DONE       4\n#define SQLITE_RBU_STATE_ERROR      5\n\nSQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. Or, if the zParent parameter is passed NULL, \n** then the new RBU VFS uses the default system VFS to access the file-system.\n** The new object is registered as a non-default VFS with SQLite before \n** returning.\n**\n** Part of the RBU implementation uses a custom VFS object. Usually, this\n** object is created and deleted automatically by RBU. \n**\n** The exception is for applications that also use zipvfs. In this case,\n** the custom VFS must be explicitly created by the user before the RBU\n** handle is opened. The RBU VFS should be installed so that the zipvfs\n** VFS uses the RBU VFS, which in turn uses any other VFS layers in use \n** (for example multiplexor) to access the file-system. For example,\n** to assemble an RBU enabled VFS stack that uses both zipvfs and \n** multiplexor (error checking omitted):\n**\n**     // Create a VFS named \"multiplex\" (not the default).\n**     sqlite3_multiplex_initialize(0, 0);\n**\n**     // Create an rbu VFS named \"rbu\" that uses multiplexor. If the\n**     // second argument were replaced with NULL, the \"rbu\" VFS would\n**     // access the file-system via the system default VFS, bypassing the\n**     // multiplexor.\n**     sqlite3rbu_create_vfs(\"rbu\", \"multiplex\");\n**\n**     // Create a zipvfs VFS named \"zipvfs\" that uses rbu.\n**     zipvfs_create_vfs_v3(\"zipvfs\", \"rbu\", 0, xCompressorAlgorithmDetector);\n**\n**     // Make zipvfs the default VFS.\n**     sqlite3_vfs_register(sqlite3_vfs_find(\"zipvfs\"), 1);\n**\n** Because the default VFS created above includes a RBU functionality, it\n** may be used by RBU clients. Attempting to use RBU with a zipvfs VFS stack\n** that does not include the RBU layer results in an error.\n**\n** The overhead of adding the \"rbu\" VFS to the system is negligible for \n** non-RBU users. There is no harm in an application accessing the \n** file-system via \"rbu\" all the time, even if it only uses RBU functionality \n** occasionally.\n*/\nSQLITE_API int sqlite3rbu_create_vfs(const char *zName, const char *zParent);\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n**\n** VFS objects are not reference counted. If a VFS object is destroyed\n** before all database handles that use it have been closed, the results\n** are undefined.\n*/\nSQLITE_API void sqlite3rbu_destroy_vfs(const char *zName);\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _SQLITE3RBU_H */\n\n/************** End of sqlite3rbu.h ******************************************/\n/************** Continuing where we left off in sqlite3rbu.c *****************/\n\n#if defined(_WIN32_WCE)\n/* #include \"windows.h\" */\n#endif\n\n/* Maximum number of prepared UPDATE statements held by this module */\n#define SQLITE_RBU_UPDATE_CACHESIZE 16\n\n/* Delta checksums disabled by default.  Compile with -DRBU_ENABLE_DELTA_CKSUM\n** to enable checksum verification.\n*/\n#ifndef RBU_ENABLE_DELTA_CKSUM\n# define RBU_ENABLE_DELTA_CKSUM 0\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#if !defined(SQLITE_AMALGAMATION)\n# define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n#endif\n\n/*\n** The rbu_state table is used to save the state of a partially applied\n** update so that it can be resumed later. The table consists of integer\n** keys mapped to values as follows:\n**\n** RBU_STATE_STAGE:\n**   May be set to integer values 1, 2, 4 or 5. As follows:\n**       1: the *-rbu file is currently under construction.\n**       2: the *-rbu file has been constructed, but not yet moved \n**          to the *-wal path.\n**       4: the checkpoint is underway.\n**       5: the rbu update has been checkpointed.\n**\n** RBU_STATE_TBL:\n**   Only valid if STAGE==1. The target database name of the table \n**   currently being written.\n**\n** RBU_STATE_IDX:\n**   Only valid if STAGE==1. The target database name of the index \n**   currently being written, or NULL if the main table is currently being\n**   updated.\n**\n** RBU_STATE_ROW:\n**   Only valid if STAGE==1. Number of rows already processed for the current\n**   table/index.\n**\n** RBU_STATE_PROGRESS:\n**   Trbul number of sqlite3rbu_step() calls made so far as part of this\n**   rbu update.\n**\n** RBU_STATE_CKPT:\n**   Valid if STAGE==4. The 64-bit checksum associated with the wal-index\n**   header created by recovering the *-wal file. This is used to detect\n**   cases when another client appends frames to the *-wal file in the\n**   middle of an incremental checkpoint (an incremental checkpoint cannot\n**   be continued if this happens).\n**\n** RBU_STATE_COOKIE:\n**   Valid if STAGE==1. The current change-counter cookie value in the \n**   target db file.\n**\n** RBU_STATE_OALSZ:\n**   Valid if STAGE==1. The size in bytes of the *-oal file.\n*/\n#define RBU_STATE_STAGE        1\n#define RBU_STATE_TBL          2\n#define RBU_STATE_IDX          3\n#define RBU_STATE_ROW          4\n#define RBU_STATE_PROGRESS     5\n#define RBU_STATE_CKPT         6\n#define RBU_STATE_COOKIE       7\n#define RBU_STATE_OALSZ        8\n#define RBU_STATE_PHASEONESTEP 9\n\n#define RBU_STAGE_OAL         1\n#define RBU_STAGE_MOVE        2\n#define RBU_STAGE_CAPTURE     3\n#define RBU_STAGE_CKPT        4\n#define RBU_STAGE_DONE        5\n\n\n#define RBU_CREATE_STATE \\\n  \"CREATE TABLE IF NOT EXISTS %s.rbu_state(k INTEGER PRIMARY KEY, v)\"\n\ntypedef struct RbuFrame RbuFrame;\ntypedef struct RbuObjIter RbuObjIter;\ntypedef struct RbuState RbuState;\ntypedef struct rbu_vfs rbu_vfs;\ntypedef struct rbu_file rbu_file;\ntypedef struct RbuUpdateStmt RbuUpdateStmt;\n\n#if !defined(SQLITE_AMALGAMATION)\ntypedef unsigned int u32;\ntypedef unsigned short u16;\ntypedef unsigned char u8;\ntypedef sqlite3_int64 i64;\n#endif\n\n/*\n** These values must match the values defined in wal.c for the equivalent\n** locks. These are not magic numbers as they are part of the SQLite file\n** format.\n*/\n#define WAL_LOCK_WRITE  0\n#define WAL_LOCK_CKPT   1\n#define WAL_LOCK_READ0  3\n\n#define SQLITE_FCNTL_RBUCNT    5149216\n\n/*\n** A structure to store values read from the rbu_state table in memory.\n*/\nstruct RbuState {\n  int eStage;\n  char *zTbl;\n  char *zIdx;\n  i64 iWalCksum;\n  int nRow;\n  i64 nProgress;\n  u32 iCookie;\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n};\n\nstruct RbuUpdateStmt {\n  char *zMask;                    /* Copy of update mask used with pUpdate */\n  sqlite3_stmt *pUpdate;          /* Last update statement (or NULL) */\n  RbuUpdateStmt *pNext;\n};\n\n/*\n** An iterator of this type is used to iterate through all objects in\n** the target database that require updating. For each such table, the\n** iterator visits, in order:\n**\n**     * the table itself, \n**     * each index of the table (zero or more points to visit), and\n**     * a special \"cleanup table\" state.\n**\n** abIndexed:\n**   If the table has no indexes on it, abIndexed is set to NULL. Otherwise,\n**   it points to an array of flags nTblCol elements in size. The flag is\n**   set for each column that is either a part of the PK or a part of an\n**   index. Or clear otherwise.\n**   \n*/\nstruct RbuObjIter {\n  sqlite3_stmt *pTblIter;         /* Iterate through tables */\n  sqlite3_stmt *pIdxIter;         /* Index iterator */\n  int nTblCol;                    /* Size of azTblCol[] array */\n  char **azTblCol;                /* Array of unquoted target column names */\n  char **azTblType;               /* Array of target column types */\n  int *aiSrcOrder;                /* src table col -> target table col */\n  u8 *abTblPk;                    /* Array of flags, set on target PK columns */\n  u8 *abNotNull;                  /* Array of flags, set on NOT NULL columns */\n  u8 *abIndexed;                  /* Array of flags, set on indexed & PK cols */\n  int eType;                      /* Table type - an RBU_PK_XXX value */\n\n  /* Output variables. zTbl==0 implies EOF. */\n  int bCleanup;                   /* True in \"cleanup\" state */\n  const char *zTbl;               /* Name of target db table */\n  const char *zDataTbl;           /* Name of rbu db table (or null) */\n  const char *zIdx;               /* Name of target db index (or null) */\n  int iTnum;                      /* Root page of current object */\n  int iPkTnum;                    /* If eType==EXTERNAL, root of PK index */\n  int bUnique;                    /* Current index is unique */\n  int nIndex;                     /* Number of aux. indexes on table zTbl */\n\n  /* Statements created by rbuObjIterPrepareAll() */\n  int nCol;                       /* Number of columns in current object */\n  sqlite3_stmt *pSelect;          /* Source data */\n  sqlite3_stmt *pInsert;          /* Statement for INSERT operations */\n  sqlite3_stmt *pDelete;          /* Statement for DELETE ops */\n  sqlite3_stmt *pTmpInsert;       /* Insert into rbu_tmp_$zDataTbl */\n\n  /* Last UPDATE used (for PK b-tree updates only), or NULL. */\n  RbuUpdateStmt *pRbuUpdate;\n};\n\n/*\n** Values for RbuObjIter.eType\n**\n**     0: Table does not exist (error)\n**     1: Table has an implicit rowid.\n**     2: Table has an explicit IPK column.\n**     3: Table has an external PK index.\n**     4: Table is WITHOUT ROWID.\n**     5: Table is a virtual table.\n*/\n#define RBU_PK_NOTABLE        0\n#define RBU_PK_NONE           1\n#define RBU_PK_IPK            2\n#define RBU_PK_EXTERNAL       3\n#define RBU_PK_WITHOUT_ROWID  4\n#define RBU_PK_VTAB           5\n\n\n/*\n** Within the RBU_STAGE_OAL stage, each call to sqlite3rbu_step() performs\n** one of the following operations.\n*/\n#define RBU_INSERT     1          /* Insert on a main table b-tree */\n#define RBU_DELETE     2          /* Delete a row from a main table b-tree */\n#define RBU_REPLACE    3          /* Delete and then insert a row */\n#define RBU_IDX_DELETE 4          /* Delete a row from an aux. index b-tree */\n#define RBU_IDX_INSERT 5          /* Insert on an aux. index b-tree */\n\n#define RBU_UPDATE     6          /* Update a row in a main table b-tree */\n\n/*\n** A single step of an incremental checkpoint - frame iWalFrame of the wal\n** file should be copied to page iDbPage of the database file.\n*/\nstruct RbuFrame {\n  u32 iDbPage;\n  u32 iWalFrame;\n};\n\n/*\n** RBU handle.\n**\n** nPhaseOneStep:\n**   If the RBU database contains an rbu_count table, this value is set to\n**   a running estimate of the number of b-tree operations required to \n**   finish populating the *-oal file. This allows the sqlite3_bp_progress()\n**   API to calculate the permyriadage progress of populating the *-oal file\n**   using the formula:\n**\n**     permyriadage = (10000 * nProgress) / nPhaseOneStep\n**\n**   nPhaseOneStep is initialized to the sum of:\n**\n**     nRow * (nIndex + 1)\n**\n**   for all source tables in the RBU database, where nRow is the number\n**   of rows in the source table and nIndex the number of indexes on the\n**   corresponding target database table.\n**\n**   This estimate is accurate if the RBU update consists entirely of\n**   INSERT operations. However, it is inaccurate if:\n**\n**     * the RBU update contains any UPDATE operations. If the PK specified\n**       for an UPDATE operation does not exist in the target table, then\n**       no b-tree operations are required on index b-trees. Or if the \n**       specified PK does exist, then (nIndex*2) such operations are\n**       required (one delete and one insert on each index b-tree).\n**\n**     * the RBU update contains any DELETE operations for which the specified\n**       PK does not exist. In this case no operations are required on index\n**       b-trees.\n**\n**     * the RBU update contains REPLACE operations. These are similar to\n**       UPDATE operations.\n**\n**   nPhaseOneStep is updated to account for the conditions above during the\n**   first pass of each source table. The updated nPhaseOneStep value is\n**   stored in the rbu_state table if the RBU update is suspended.\n*/\nstruct sqlite3rbu {\n  int eStage;                     /* Value of RBU_STATE_STAGE field */\n  sqlite3 *dbMain;                /* target database handle */\n  sqlite3 *dbRbu;                 /* rbu database handle */\n  char *zTarget;                  /* Path to target db */\n  char *zRbu;                     /* Path to rbu db */\n  char *zState;                   /* Path to state db (or NULL if zRbu) */\n  char zStateDb[5];               /* Db name for state (\"stat\" or \"main\") */\n  int rc;                         /* Value returned by last rbu_step() call */\n  char *zErrmsg;                  /* Error message if rc!=SQLITE_OK */\n  int nStep;                      /* Rows processed for current object */\n  int nProgress;                  /* Rows processed for all objects */\n  RbuObjIter objiter;             /* Iterator for skipping through tbl/idx */\n  const char *zVfsName;           /* Name of automatically created rbu vfs */\n  rbu_file *pTargetFd;            /* File handle open on target db */\n  int nPagePerSector;             /* Pages per sector for pTargetFd */\n  i64 iOalSz;\n  i64 nPhaseOneStep;\n\n  /* The following state variables are used as part of the incremental\n  ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding\n  ** function rbuSetupCheckpoint() for details.  */\n  u32 iMaxFrame;                  /* Largest iWalFrame value in aFrame[] */\n  u32 mLock;\n  int nFrame;                     /* Entries in aFrame[] array */\n  int nFrameAlloc;                /* Allocated size of aFrame[] array */\n  RbuFrame *aFrame;\n  int pgsz;\n  u8 *aBuf;\n  i64 iWalCksum;\n  i64 szTemp;                     /* Current size of all temp files in use */\n  i64 szTempLimit;                /* Total size limit for temp files */\n\n  /* Used in RBU vacuum mode only */\n  int nRbu;                       /* Number of RBU VFS in the stack */\n  rbu_file *pRbuFd;               /* Fd for main db of dbRbu */\n};\n\n/*\n** An rbu VFS is implemented using an instance of this structure.\n**\n** Variable pRbu is only non-NULL for automatically created RBU VFS objects.\n** It is NULL for RBU VFS objects created explicitly using\n** sqlite3rbu_create_vfs(). It is used to track the total amount of temp\n** space used by the RBU handle.\n*/\nstruct rbu_vfs {\n  sqlite3_vfs base;               /* rbu VFS shim methods */\n  sqlite3_vfs *pRealVfs;          /* Underlying VFS */\n  sqlite3_mutex *mutex;           /* Mutex to protect pMain */\n  sqlite3rbu *pRbu;               /* Owner RBU object */\n  rbu_file *pMain;                /* Linked list of main db files */\n};\n\n/*\n** Each file opened by an rbu VFS is represented by an instance of\n** the following structure.\n**\n** If this is a temporary file (pRbu!=0 && flags&DELETE_ON_CLOSE), variable\n** \"sz\" is set to the current size of the database file.\n*/\nstruct rbu_file {\n  sqlite3_file base;              /* sqlite3_file methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  rbu_vfs *pRbuVfs;               /* Pointer to the rbu_vfs object */\n  sqlite3rbu *pRbu;               /* Pointer to rbu object (rbu target only) */\n  i64 sz;                         /* Size of file in bytes (temp only) */\n\n  int openFlags;                  /* Flags this file was opened with */\n  u32 iCookie;                    /* Cookie value for main db files */\n  u8 iWriteVer;                   /* \"write-version\" value for main db files */\n  u8 bNolock;                     /* True to fail EXCLUSIVE locks */\n\n  int nShm;                       /* Number of entries in apShm[] array */\n  char **apShm;                   /* Array of mmap'd *-shm regions */\n  char *zDel;                     /* Delete this when closing file */\n\n  const char *zWal;               /* Wal filename for this main db file */\n  rbu_file *pWalFd;               /* Wal file descriptor for this main db */\n  rbu_file *pMainNext;            /* Next MAIN_DB file */\n};\n\n/*\n** True for an RBU vacuum handle, or false otherwise.\n*/\n#define rbuIsVacuum(p) ((p)->zTarget==0)\n\n\n/*************************************************************************\n** The following three functions, found below:\n**\n**   rbuDeltaGetInt()\n**   rbuDeltaChecksum()\n**   rbuDeltaApply()\n**\n** are lifted from the fossil source code (http://fossil-scm.org). They\n** are used to implement the scalar SQL function rbu_fossil_delta().\n*/\n\n/*\n** Read bytes from *pz and convert them into a positive integer.  When\n** finished, leave *pz pointing to the first character past the end of\n** the integer.  The *pLen parameter holds the length of the string\n** in *pz and is decremented once for each character in the integer.\n*/\nstatic unsigned int rbuDeltaGetInt(const char **pz, int *pLen){\n  static const signed char zValue[] = {\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n    -1, -1, -1, -1, -1, -1, -1, -1,   -1, -1, -1, -1, -1, -1, -1, -1,\n     0,  1,  2,  3,  4,  5,  6,  7,    8,  9, -1, -1, -1, -1, -1, -1,\n    -1, 10, 11, 12, 13, 14, 15, 16,   17, 18, 19, 20, 21, 22, 23, 24,\n    25, 26, 27, 28, 29, 30, 31, 32,   33, 34, 35, -1, -1, -1, -1, 36,\n    -1, 37, 38, 39, 40, 41, 42, 43,   44, 45, 46, 47, 48, 49, 50, 51,\n    52, 53, 54, 55, 56, 57, 58, 59,   60, 61, 62, -1, -1, -1, 63, -1,\n  };\n  unsigned int v = 0;\n  int c;\n  unsigned char *z = (unsigned char*)*pz;\n  unsigned char *zStart = z;\n  while( (c = zValue[0x7f&*(z++)])>=0 ){\n     v = (v<<6) + c;\n  }\n  z--;\n  *pLen -= z - zStart;\n  *pz = (char*)z;\n  return v;\n}\n\n#if RBU_ENABLE_DELTA_CKSUM\n/*\n** Compute a 32-bit checksum on the N-byte buffer.  Return the result.\n*/\nstatic unsigned int rbuDeltaChecksum(const char *zIn, size_t N){\n  const unsigned char *z = (const unsigned char *)zIn;\n  unsigned sum0 = 0;\n  unsigned sum1 = 0;\n  unsigned sum2 = 0;\n  unsigned sum3 = 0;\n  while(N >= 16){\n    sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]);\n    sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]);\n    sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]);\n    sum3 += ((unsigned)z[3] + z[7] + z[11]+ z[15]);\n    z += 16;\n    N -= 16;\n  }\n  while(N >= 4){\n    sum0 += z[0];\n    sum1 += z[1];\n    sum2 += z[2];\n    sum3 += z[3];\n    z += 4;\n    N -= 4;\n  }\n  sum3 += (sum2 << 8) + (sum1 << 16) + (sum0 << 24);\n  switch(N){\n    case 3:   sum3 += (z[2] << 8);\n    case 2:   sum3 += (z[1] << 16);\n    case 1:   sum3 += (z[0] << 24);\n    default:  ;\n  }\n  return sum3;\n}\n#endif\n\n/*\n** Apply a delta.\n**\n** The output buffer should be big enough to hold the whole output\n** file and a NUL terminator at the end.  The delta_output_size()\n** routine will determine this size for you.\n**\n** The delta string should be null-terminated.  But the delta string\n** may contain embedded NUL characters (if the input and output are\n** binary files) so we also have to pass in the length of the delta in\n** the lenDelta parameter.\n**\n** This function returns the size of the output file in bytes (excluding\n** the final NUL terminator character).  Except, if the delta string is\n** malformed or intended for use with a source file other than zSrc,\n** then this routine returns -1.\n**\n** Refer to the delta_create() documentation above for a description\n** of the delta file format.\n*/\nstatic int rbuDeltaApply(\n  const char *zSrc,      /* The source or pattern file */\n  int lenSrc,            /* Length of the source file */\n  const char *zDelta,    /* Delta to apply to the pattern */\n  int lenDelta,          /* Length of the delta */\n  char *zOut             /* Write the output into this preallocated buffer */\n){\n  unsigned int limit;\n  unsigned int total = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n  char *zOrigOut = zOut;\n#endif\n\n  limit = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  zDelta++; lenDelta--;\n  while( *zDelta && lenDelta>0 ){\n    unsigned int cnt, ofst;\n    cnt = rbuDeltaGetInt(&zDelta, &lenDelta);\n    switch( zDelta[0] ){\n      case '@': {\n        zDelta++; lenDelta--;\n        ofst = rbuDeltaGetInt(&zDelta, &lenDelta);\n        if( lenDelta>0 && zDelta[0]!=',' ){\n          /* ERROR: copy command not terminated by ',' */\n          return -1;\n        }\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR: copy exceeds output file size */\n          return -1;\n        }\n        if( (int)(ofst+cnt) > lenSrc ){\n          /* ERROR: copy extends past end of input */\n          return -1;\n        }\n        memcpy(zOut, &zSrc[ofst], cnt);\n        zOut += cnt;\n        break;\n      }\n      case ':': {\n        zDelta++; lenDelta--;\n        total += cnt;\n        if( total>limit ){\n          /* ERROR:  insert command gives an output larger than predicted */\n          return -1;\n        }\n        if( (int)cnt>lenDelta ){\n          /* ERROR: insert count exceeds size of delta */\n          return -1;\n        }\n        memcpy(zOut, zDelta, cnt);\n        zOut += cnt;\n        zDelta += cnt;\n        lenDelta -= cnt;\n        break;\n      }\n      case ';': {\n        zDelta++; lenDelta--;\n        zOut[0] = 0;\n#if RBU_ENABLE_DELTA_CKSUM\n        if( cnt!=rbuDeltaChecksum(zOrigOut, total) ){\n          /* ERROR:  bad checksum */\n          return -1;\n        }\n#endif\n        if( total!=limit ){\n          /* ERROR: generated size does not match predicted size */\n          return -1;\n        }\n        return total;\n      }\n      default: {\n        /* ERROR: unknown delta operator */\n        return -1;\n      }\n    }\n  }\n  /* ERROR: unterminated delta */\n  return -1;\n}\n\nstatic int rbuDeltaOutputSize(const char *zDelta, int lenDelta){\n  int size;\n  size = rbuDeltaGetInt(&zDelta, &lenDelta);\n  if( *zDelta!='\\n' ){\n    /* ERROR: size integer not terminated by \"\\n\" */\n    return -1;\n  }\n  return size;\n}\n\n/*\n** End of code taken from fossil.\n*************************************************************************/\n\n/*\n** Implementation of SQL scalar function rbu_fossil_delta().\n**\n** This function applies a fossil delta patch to a blob. Exactly two\n** arguments must be passed to this function. The first is the blob to\n** patch and the second the patch to apply. If no error occurs, this\n** function returns the patched blob.\n*/\nstatic void rbuFossilDeltaFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *aDelta;\n  int nDelta;\n  const char *aOrig;\n  int nOrig;\n\n  int nOut;\n  int nOut2;\n  char *aOut;\n\n  assert( argc==2 );\n\n  nOrig = sqlite3_value_bytes(argv[0]);\n  aOrig = (const char*)sqlite3_value_blob(argv[0]);\n  nDelta = sqlite3_value_bytes(argv[1]);\n  aDelta = (const char*)sqlite3_value_blob(argv[1]);\n\n  /* Figure out the size of the output */\n  nOut = rbuDeltaOutputSize(aDelta, nDelta);\n  if( nOut<0 ){\n    sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    return;\n  }\n\n  aOut = sqlite3_malloc(nOut+1);\n  if( aOut==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    nOut2 = rbuDeltaApply(aOrig, nOrig, aDelta, nDelta, aOut);\n    if( nOut2!=nOut ){\n      sqlite3_result_error(context, \"corrupt fossil delta\", -1);\n    }else{\n      sqlite3_result_blob(context, aOut, nOut, sqlite3_free);\n    }\n  }\n}\n\n\n/*\n** Prepare the SQL statement in buffer zSql against database handle db.\n** If successful, set *ppStmt to point to the new statement and return\n** SQLITE_OK. \n**\n** Otherwise, if an error does occur, set *ppStmt to NULL and return\n** an SQLite error code. Additionally, set output variable *pzErrmsg to\n** point to a buffer containing an error message. It is the responsibility\n** of the caller to (eventually) free this buffer using sqlite3_free().\n*/\nstatic int prepareAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  const char *zSql\n){\n  int rc = sqlite3_prepare_v2(db, zSql, -1, ppStmt, 0);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    *ppStmt = 0;\n  }\n  return rc;\n}\n\n/*\n** Reset the SQL statement passed as the first argument. Return a copy\n** of the value returned by sqlite3_reset().\n**\n** If an error has occurred, then set *pzErrmsg to point to a buffer\n** containing an error message. It is the responsibility of the caller\n** to eventually free this buffer using sqlite3_free().\n*/\nstatic int resetAndCollectError(sqlite3_stmt *pStmt, char **pzErrmsg){\n  int rc = sqlite3_reset(pStmt);\n  if( rc!=SQLITE_OK ){\n    *pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(sqlite3_db_handle(pStmt)));\n  }\n  return rc;\n}\n\n/*\n** Unless it is NULL, argument zSql points to a buffer allocated using\n** sqlite3_malloc containing an SQL statement. This function prepares the SQL\n** statement against database db and frees the buffer. If statement \n** compilation is successful, *ppStmt is set to point to the new statement \n** handle and SQLITE_OK is returned. \n**\n** Otherwise, if an error occurs, *ppStmt is set to NULL and an error code\n** returned. In this case, *pzErrmsg may also be set to point to an error\n** message. It is the responsibility of the caller to free this error message\n** buffer using sqlite3_free().\n**\n** If argument zSql is NULL, this function assumes that an OOM has occurred.\n** In this case SQLITE_NOMEM is returned and *ppStmt set to NULL.\n*/\nstatic int prepareFreeAndCollectError(\n  sqlite3 *db, \n  sqlite3_stmt **ppStmt,\n  char **pzErrmsg,\n  char *zSql\n){\n  int rc;\n  assert( *pzErrmsg==0 );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n    *ppStmt = 0;\n  }else{\n    rc = prepareAndCollectError(db, ppStmt, pzErrmsg, zSql);\n    sqlite3_free(zSql);\n  }\n  return rc;\n}\n\n/*\n** Free the RbuObjIter.azTblCol[] and RbuObjIter.abTblPk[] arrays allocated\n** by an earlier call to rbuObjIterCacheTableInfo().\n*/\nstatic void rbuObjIterFreeCols(RbuObjIter *pIter){\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    sqlite3_free(pIter->azTblCol[i]);\n    sqlite3_free(pIter->azTblType[i]);\n  }\n  sqlite3_free(pIter->azTblCol);\n  pIter->azTblCol = 0;\n  pIter->azTblType = 0;\n  pIter->aiSrcOrder = 0;\n  pIter->abTblPk = 0;\n  pIter->abNotNull = 0;\n  pIter->nTblCol = 0;\n  pIter->eType = 0;               /* Invalid value */\n}\n\n/*\n** Finalize all statements and free all allocations that are specific to\n** the current object (table/index pair).\n*/\nstatic void rbuObjIterClearStatements(RbuObjIter *pIter){\n  RbuUpdateStmt *pUp;\n\n  sqlite3_finalize(pIter->pSelect);\n  sqlite3_finalize(pIter->pInsert);\n  sqlite3_finalize(pIter->pDelete);\n  sqlite3_finalize(pIter->pTmpInsert);\n  pUp = pIter->pRbuUpdate;\n  while( pUp ){\n    RbuUpdateStmt *pTmp = pUp->pNext;\n    sqlite3_finalize(pUp->pUpdate);\n    sqlite3_free(pUp);\n    pUp = pTmp;\n  }\n  \n  pIter->pSelect = 0;\n  pIter->pInsert = 0;\n  pIter->pDelete = 0;\n  pIter->pRbuUpdate = 0;\n  pIter->pTmpInsert = 0;\n  pIter->nCol = 0;\n}\n\n/*\n** Clean up any resources allocated as part of the iterator object passed\n** as the only argument.\n*/\nstatic void rbuObjIterFinalize(RbuObjIter *pIter){\n  rbuObjIterClearStatements(pIter);\n  sqlite3_finalize(pIter->pTblIter);\n  sqlite3_finalize(pIter->pIdxIter);\n  rbuObjIterFreeCols(pIter);\n  memset(pIter, 0, sizeof(RbuObjIter));\n}\n\n/*\n** Advance the iterator to the next position.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the next entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterNext(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc = p->rc;\n  if( rc==SQLITE_OK ){\n\n    /* Free any SQLite statements used while processing the previous object */ \n    rbuObjIterClearStatements(pIter);\n    if( pIter->zIdx==0 ){\n      rc = sqlite3_exec(p->dbMain,\n          \"DROP TRIGGER IF EXISTS temp.rbu_insert_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update1_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_update2_tr;\"\n          \"DROP TRIGGER IF EXISTS temp.rbu_delete_tr;\"\n          , 0, 0, &p->zErrmsg\n      );\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIter->bCleanup ){\n        rbuObjIterFreeCols(pIter);\n        pIter->bCleanup = 0;\n        rc = sqlite3_step(pIter->pTblIter);\n        if( rc!=SQLITE_ROW ){\n          rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg);\n          pIter->zTbl = 0;\n        }else{\n          pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0);\n          pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1);\n          rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM;\n        }\n      }else{\n        if( pIter->zIdx==0 ){\n          sqlite3_stmt *pIdx = pIter->pIdxIter;\n          rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3_step(pIter->pIdxIter);\n          if( rc!=SQLITE_ROW ){\n            rc = resetAndCollectError(pIter->pIdxIter, &p->zErrmsg);\n            pIter->bCleanup = 1;\n            pIter->zIdx = 0;\n          }else{\n            pIter->zIdx = (const char*)sqlite3_column_text(pIter->pIdxIter, 0);\n            pIter->iTnum = sqlite3_column_int(pIter->pIdxIter, 1);\n            pIter->bUnique = sqlite3_column_int(pIter->pIdxIter, 2);\n            rc = pIter->zIdx ? SQLITE_OK : SQLITE_NOMEM;\n          }\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    rbuObjIterFinalize(pIter);\n    p->rc = rc;\n  }\n  return rc;\n}\n\n\n/*\n** The implementation of the rbu_target_name() SQL function. This function\n** accepts one or two arguments. The first argument is the name of a table -\n** the name of a table in the RBU database.  The second, if it is present, is 1\n** for a view or 0 for a table. \n**\n** For a non-vacuum RBU handle, if the table name matches the pattern:\n**\n**     data[0-9]_<name>\n**\n** where <name> is any sequence of 1 or more characters, <name> is returned.\n** Otherwise, if the only argument does not match the above pattern, an SQL\n** NULL is returned.\n**\n**     \"data_t1\"     -> \"t1\"\n**     \"data0123_t2\" -> \"t2\"\n**     \"dataAB_t3\"   -> NULL\n**\n** For an rbu vacuum handle, a copy of the first argument is returned if\n** the second argument is either missing or 0 (not a view).\n*/\nstatic void rbuTargetNameFunc(\n  sqlite3_context *pCtx,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  const char *zIn;\n  assert( argc==1 || argc==2 );\n\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  if( zIn ){\n    if( rbuIsVacuum(p) ){\n      if( argc==1 || 0==sqlite3_value_int(argv[1]) ){\n        sqlite3_result_text(pCtx, zIn, -1, SQLITE_STATIC);\n      }\n    }else{\n      if( strlen(zIn)>4 && memcmp(\"data\", zIn, 4)==0 ){\n        int i;\n        for(i=4; zIn[i]>='0' && zIn[i]<='9'; i++);\n        if( zIn[i]=='_' && zIn[i+1] ){\n          sqlite3_result_text(pCtx, &zIn[i+1], -1, SQLITE_STATIC);\n        }\n      }\n    }\n  }\n}\n\n/*\n** Initialize the iterator structure passed as the second argument.\n**\n** If no error occurs, SQLITE_OK is returned and the iterator is left \n** pointing to the first entry. Otherwise, an error code and message is \n** left in the RBU handle passed as the first argument. A copy of the \n** error code is returned.\n*/\nstatic int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){\n  int rc;\n  memset(pIter, 0, sizeof(RbuObjIter));\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, \n    sqlite3_mprintf(\n      \"SELECT rbu_target_name(name, type='view') AS target, name \"\n      \"FROM sqlite_master \"\n      \"WHERE type IN ('table', 'view') AND target IS NOT NULL \"\n      \" %s \"\n      \"ORDER BY name\"\n  , rbuIsVacuum(p) ? \"AND rootpage!=0 AND rootpage IS NOT NULL\" : \"\"));\n\n  if( rc==SQLITE_OK ){\n    rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg,\n        \"SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' \"\n        \"  FROM main.sqlite_master \"\n        \"  WHERE type='index' AND tbl_name = ?\"\n    );\n  }\n\n  pIter->bCleanup = 1;\n  p->rc = rc;\n  return rbuObjIterNext(p, pIter);\n}\n\n/*\n** This is a wrapper around \"sqlite3_mprintf(zFmt, ...)\". If an OOM occurs,\n** an error code is stored in the RBU handle passed as the first argument.\n**\n** If an error has already occurred (p->rc is already set to something other\n** than SQLITE_OK), then this function returns NULL without modifying the\n** stored error code. In this case it still calls sqlite3_free() on any \n** printf() parameters associated with %z conversions.\n*/\nstatic char *rbuMPrintf(sqlite3rbu *p, const char *zFmt, ...){\n  char *zSql = 0;\n  va_list ap;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ) p->rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_free(zSql);\n    zSql = 0;\n  }\n  va_end(ap);\n  return zSql;\n}\n\n/*\n** Argument zFmt is a sqlite3_mprintf() style format string. The trailing\n** arguments are the usual subsitution values. This function performs\n** the printf() style substitutions and executes the result as an SQL\n** statement on the RBU handles database.\n**\n** If an error occurs, an error code and error message is stored in the\n** RBU handle. If an error has already occurred when this function is\n** called, it is a no-op.\n*/\nstatic int rbuMPrintfExec(sqlite3rbu *p, sqlite3 *db, const char *zFmt, ...){\n  va_list ap;\n  char *zSql;\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( p->rc==SQLITE_OK ){\n    if( zSql==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      p->rc = sqlite3_exec(db, zSql, 0, 0, &p->zErrmsg);\n    }\n  }\n  sqlite3_free(zSql);\n  va_end(ap);\n  return p->rc;\n}\n\n/*\n** Attempt to allocate and return a pointer to a zeroed block of nByte \n** bytes. \n**\n** If an error (i.e. an OOM condition) occurs, return NULL and leave an \n** error code in the rbu handle passed as the first argument. Or, if an \n** error has already occurred when this function is called, return NULL \n** immediately without attempting the allocation or modifying the stored\n** error code.\n*/\nstatic void *rbuMalloc(sqlite3rbu *p, int nByte){\n  void *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    assert( nByte>0 );\n    pRet = sqlite3_malloc64(nByte);\n    if( pRet==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n\n/*\n** Allocate and zero the pIter->azTblCol[] and abTblPk[] arrays so that\n** there is room for at least nCol elements. If an OOM occurs, store an\n** error code in the RBU handle passed as the first argument.\n*/\nstatic void rbuAllocateIterArrays(sqlite3rbu *p, RbuObjIter *pIter, int nCol){\n  int nByte = (2*sizeof(char*) + sizeof(int) + 3*sizeof(u8)) * nCol;\n  char **azNew;\n\n  azNew = (char**)rbuMalloc(p, nByte);\n  if( azNew ){\n    pIter->azTblCol = azNew;\n    pIter->azTblType = &azNew[nCol];\n    pIter->aiSrcOrder = (int*)&pIter->azTblType[nCol];\n    pIter->abTblPk = (u8*)&pIter->aiSrcOrder[nCol];\n    pIter->abNotNull = (u8*)&pIter->abTblPk[nCol];\n    pIter->abIndexed = (u8*)&pIter->abNotNull[nCol];\n  }\n}\n\n/*\n** The first argument must be a nul-terminated string. This function\n** returns a copy of the string in memory obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free this memory\n** using sqlite3_free().\n**\n** If an OOM condition is encountered when attempting to allocate memory,\n** output variable (*pRc) is set to SQLITE_NOMEM before returning. Otherwise,\n** if the allocation succeeds, (*pRc) is left unchanged.\n*/\nstatic char *rbuStrndup(const char *zStr, int *pRc){\n  char *zRet = 0;\n\n  assert( *pRc==SQLITE_OK );\n  if( zStr ){\n    size_t nCopy = strlen(zStr) + 1;\n    zRet = (char*)sqlite3_malloc64(nCopy);\n    if( zRet ){\n      memcpy(zRet, zStr, nCopy);\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** Finalize the statement passed as the second argument.\n**\n** If the sqlite3_finalize() call indicates that an error occurs, and the\n** rbu handle error code is not already set, set the error code and error\n** message accordingly.\n*/\nstatic void rbuFinalize(sqlite3rbu *p, sqlite3_stmt *pStmt){\n  sqlite3 *db = sqlite3_db_handle(pStmt);\n  int rc = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK && rc!=SQLITE_OK ){\n    p->rc = rc;\n    p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n}\n\n/* Determine the type of a table.\n**\n**   peType is of type (int*), a pointer to an output parameter of type\n**   (int). This call sets the output parameter as follows, depending\n**   on the type of the table specified by parameters dbName and zTbl.\n**\n**     RBU_PK_NOTABLE:       No such table.\n**     RBU_PK_NONE:          Table has an implicit rowid.\n**     RBU_PK_IPK:           Table has an explicit IPK column.\n**     RBU_PK_EXTERNAL:      Table has an external PK index.\n**     RBU_PK_WITHOUT_ROWID: Table is WITHOUT ROWID.\n**     RBU_PK_VTAB:          Table is a virtual table.\n**\n**   Argument *piPk is also of type (int*), and also points to an output\n**   parameter. Unless the table has an external primary key index \n**   (i.e. unless *peType is set to 3), then *piPk is set to zero. Or,\n**   if the table does have an external primary key index, then *piPk\n**   is set to the root page number of the primary key index before\n**   returning.\n**\n** ALGORITHM:\n**\n**   if( no entry exists in sqlite_master ){\n**     return RBU_PK_NOTABLE\n**   }else if( sql for the entry starts with \"CREATE VIRTUAL\" ){\n**     return RBU_PK_VTAB\n**   }else if( \"PRAGMA index_list()\" for the table contains a \"pk\" index ){\n**     if( the index that is the pk exists in sqlite_master ){\n**       *piPK = rootpage of that index.\n**       return RBU_PK_EXTERNAL\n**     }else{\n**       return RBU_PK_WITHOUT_ROWID\n**     }\n**   }else if( \"PRAGMA table_info()\" lists one or more \"pk\" columns ){\n**     return RBU_PK_IPK\n**   }else{\n**     return RBU_PK_NONE\n**   }\n*/\nstatic void rbuTableType(\n  sqlite3rbu *p,\n  const char *zTab,\n  int *peType,\n  int *piTnum,\n  int *piPk\n){\n  /*\n  ** 0) SELECT count(*) FROM sqlite_master where name=%Q AND IsVirtual(%Q)\n  ** 1) PRAGMA index_list = ?\n  ** 2) SELECT count(*) FROM sqlite_master where name=%Q \n  ** 3) PRAGMA table_info = ?\n  */\n  sqlite3_stmt *aStmt[4] = {0, 0, 0, 0};\n\n  *peType = RBU_PK_NOTABLE;\n  *piPk = 0;\n\n  assert( p->rc==SQLITE_OK );\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg, \n    sqlite3_mprintf(\n          \"SELECT (sql LIKE 'create virtual%%'), rootpage\"\n          \"  FROM sqlite_master\"\n          \" WHERE name=%Q\", zTab\n  ));\n  if( p->rc!=SQLITE_OK || sqlite3_step(aStmt[0])!=SQLITE_ROW ){\n    /* Either an error, or no such table. */\n    goto rbuTableType_end;\n  }\n  if( sqlite3_column_int(aStmt[0], 0) ){\n    *peType = RBU_PK_VTAB;                     /* virtual table */\n    goto rbuTableType_end;\n  }\n  *piTnum = sqlite3_column_int(aStmt[0], 1);\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[1], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA index_list=%Q\",zTab)\n  );\n  if( p->rc ) goto rbuTableType_end;\n  while( sqlite3_step(aStmt[1])==SQLITE_ROW ){\n    const u8 *zOrig = sqlite3_column_text(aStmt[1], 3);\n    const u8 *zIdx = sqlite3_column_text(aStmt[1], 1);\n    if( zOrig && zIdx && zOrig[0]=='p' ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[2], &p->zErrmsg, \n          sqlite3_mprintf(\n            \"SELECT rootpage FROM sqlite_master WHERE name = %Q\", zIdx\n      ));\n      if( p->rc==SQLITE_OK ){\n        if( sqlite3_step(aStmt[2])==SQLITE_ROW ){\n          *piPk = sqlite3_column_int(aStmt[2], 0);\n          *peType = RBU_PK_EXTERNAL;\n        }else{\n          *peType = RBU_PK_WITHOUT_ROWID;\n        }\n      }\n      goto rbuTableType_end;\n    }\n  }\n\n  p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[3], &p->zErrmsg, \n    sqlite3_mprintf(\"PRAGMA table_info=%Q\",zTab)\n  );\n  if( p->rc==SQLITE_OK ){\n    while( sqlite3_step(aStmt[3])==SQLITE_ROW ){\n      if( sqlite3_column_int(aStmt[3],5)>0 ){\n        *peType = RBU_PK_IPK;                /* explicit IPK column */\n        goto rbuTableType_end;\n      }\n    }\n    *peType = RBU_PK_NONE;\n  }\n\nrbuTableType_end: {\n    unsigned int i;\n    for(i=0; i<sizeof(aStmt)/sizeof(aStmt[0]); i++){\n      rbuFinalize(p, aStmt[i]);\n    }\n  }\n}\n\n/*\n** This is a helper function for rbuObjIterCacheTableInfo(). It populates\n** the pIter->abIndexed[] array.\n*/\nstatic void rbuObjIterCacheIndexedCols(sqlite3rbu *p, RbuObjIter *pIter){\n  sqlite3_stmt *pList = 0;\n  int bIndex = 0;\n\n  if( p->rc==SQLITE_OK ){\n    memcpy(pIter->abIndexed, pIter->abTblPk, sizeof(u8)*pIter->nTblCol);\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n  }\n\n  pIter->nIndex = 0;\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pList) ){\n    const char *zIdx = (const char*)sqlite3_column_text(pList, 1);\n    sqlite3_stmt *pXInfo = 0;\n    if( zIdx==0 ) break;\n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int iCid = sqlite3_column_int(pXInfo, 1);\n      if( iCid>=0 ) pIter->abIndexed[iCid] = 1;\n    }\n    rbuFinalize(p, pXInfo);\n    bIndex = 1;\n    pIter->nIndex++;\n  }\n\n  if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n    /* \"PRAGMA index_list\" includes the main PK b-tree */\n    pIter->nIndex--;\n  }\n\n  rbuFinalize(p, pList);\n  if( bIndex==0 ) pIter->abIndexed = 0;\n}\n\n\n/*\n** If they are not already populated, populate the pIter->azTblCol[],\n** pIter->abTblPk[], pIter->nTblCol and pIter->bRowid variables according to\n** the table (not index) that the iterator currently points to.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. If\n** an error does occur, an error code and error message are also left in \n** the RBU handle.\n*/\nstatic int rbuObjIterCacheTableInfo(sqlite3rbu *p, RbuObjIter *pIter){\n  if( pIter->azTblCol==0 ){\n    sqlite3_stmt *pStmt = 0;\n    int nCol = 0;\n    int i;                        /* for() loop iterator variable */\n    int bRbuRowid = 0;            /* If input table has column \"rbu_rowid\" */\n    int iOrder = 0;\n    int iTnum = 0;\n\n    /* Figure out the type of table this step will deal with. */\n    assert( pIter->eType==0 );\n    rbuTableType(p, pIter->zTbl, &pIter->eType, &iTnum, &pIter->iPkTnum);\n    if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_NOTABLE ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"no such table: %s\", pIter->zTbl);\n    }\n    if( p->rc ) return p->rc;\n    if( pIter->zIdx==0 ) pIter->iTnum = iTnum;\n\n    assert( pIter->eType==RBU_PK_NONE || pIter->eType==RBU_PK_IPK \n         || pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_WITHOUT_ROWID\n         || pIter->eType==RBU_PK_VTAB\n    );\n\n    /* Populate the azTblCol[] and nTblCol variables based on the columns\n    ** of the input table. Ignore any input table columns that begin with\n    ** \"rbu_\".  */\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n        sqlite3_mprintf(\"SELECT * FROM '%q'\", pIter->zDataTbl)\n    );\n    if( p->rc==SQLITE_OK ){\n      nCol = sqlite3_column_count(pStmt);\n      rbuAllocateIterArrays(p, pIter, nCol);\n    }\n    for(i=0; p->rc==SQLITE_OK && i<nCol; i++){\n      const char *zName = (const char*)sqlite3_column_name(pStmt, i);\n      if( sqlite3_strnicmp(\"rbu_\", zName, 4) ){\n        char *zCopy = rbuStrndup(zName, &p->rc);\n        pIter->aiSrcOrder[pIter->nTblCol] = pIter->nTblCol;\n        pIter->azTblCol[pIter->nTblCol++] = zCopy;\n      }\n      else if( 0==sqlite3_stricmp(\"rbu_rowid\", zName) ){\n        bRbuRowid = 1;\n      }\n    }\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n\n    if( p->rc==SQLITE_OK\n     && rbuIsVacuum(p)==0\n     && bRbuRowid!=(pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE)\n    ){\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\n          \"table %q %s rbu_rowid column\", pIter->zDataTbl,\n          (bRbuRowid ? \"may not have\" : \"requires\")\n      );\n    }\n\n    /* Check that all non-HIDDEN columns in the destination table are also\n    ** present in the input table. Populate the abTblPk[], azTblType[] and\n    ** aiTblOrder[] arrays at the same time.  */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &p->zErrmsg, \n          sqlite3_mprintf(\"PRAGMA table_info(%Q)\", pIter->zTbl)\n      );\n    }\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;  /* An OOM - finalize() below returns S_NOMEM */\n      for(i=iOrder; i<pIter->nTblCol; i++){\n        if( 0==strcmp(zName, pIter->azTblCol[i]) ) break;\n      }\n      if( i==pIter->nTblCol ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"column missing from %q: %s\",\n            pIter->zDataTbl, zName\n        );\n      }else{\n        int iPk = sqlite3_column_int(pStmt, 5);\n        int bNotNull = sqlite3_column_int(pStmt, 3);\n        const char *zType = (const char*)sqlite3_column_text(pStmt, 2);\n\n        if( i!=iOrder ){\n          SWAP(int, pIter->aiSrcOrder[i], pIter->aiSrcOrder[iOrder]);\n          SWAP(char*, pIter->azTblCol[i], pIter->azTblCol[iOrder]);\n        }\n\n        pIter->azTblType[iOrder] = rbuStrndup(zType, &p->rc);\n        pIter->abTblPk[iOrder] = (iPk!=0);\n        pIter->abNotNull[iOrder] = (u8)bNotNull || (iPk!=0);\n        iOrder++;\n      }\n    }\n\n    rbuFinalize(p, pStmt);\n    rbuObjIterCacheIndexedCols(p, pIter);\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->abIndexed==0 );\n    assert( pIter->eType!=RBU_PK_VTAB || pIter->nIndex==0 );\n  }\n\n  return p->rc;\n}\n\n/*\n** This function constructs and returns a pointer to a nul-terminated \n** string containing some SQL clause or list based on one or more of the \n** column names currently stored in the pIter->azTblCol[] array.\n*/\nstatic char *rbuObjIterGetCollist(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter               /* Object iterator for column names */\n){\n  char *zList = 0;\n  const char *zSep = \"\";\n  int i;\n  for(i=0; i<pIter->nTblCol; i++){\n    const char *z = pIter->azTblCol[i];\n    zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"\", zList, zSep, z);\n    zSep = \", \";\n  }\n  return zList;\n}\n\n/*\n** This function is used to create a SELECT list (the list of SQL \n** expressions that follows a SELECT keyword) for a SELECT statement \n** used to read from an data_xxx or rbu_tmp_xxx table while updating the \n** index object currently indicated by the iterator object passed as the \n** second argument. A \"PRAGMA index_xinfo = <idxname>\" statement is used \n** to obtain the required information.\n**\n** If the index is of the following form:\n**\n**   CREATE INDEX i1 ON t1(c, b COLLATE nocase);\n**\n** and \"t1\" is a table with an explicit INTEGER PRIMARY KEY column \n** \"ipk\", the returned string is:\n**\n**   \"`c` COLLATE 'BINARY', `b` COLLATE 'NOCASE', `ipk` COLLATE 'BINARY'\"\n**\n** As well as the returned string, three other malloc'd strings are \n** returned via output parameters. As follows:\n**\n**   pzImposterCols: ...\n**   pzImposterPk: ...\n**   pzWhere: ...\n*/\nstatic char *rbuObjIterGetIndexCols(\n  sqlite3rbu *p,                  /* RBU object */\n  RbuObjIter *pIter,              /* Object iterator for column names */\n  char **pzImposterCols,          /* OUT: Columns for imposter table */\n  char **pzImposterPk,            /* OUT: Imposter PK clause */\n  char **pzWhere,                 /* OUT: WHERE clause */\n  int *pnBind                     /* OUT: Trbul number of columns */\n){\n  int rc = p->rc;                 /* Error code */\n  int rc2;                        /* sqlite3_finalize() return code */\n  char *zRet = 0;                 /* String to return */\n  char *zImpCols = 0;             /* String to return via *pzImposterCols */\n  char *zImpPK = 0;               /* String to return via *pzImposterPK */\n  char *zWhere = 0;               /* String to return via *pzWhere */\n  int nBind = 0;                  /* Value to return via *pnBind */\n  const char *zCom = \"\";          /* Set to \", \" later on */\n  const char *zAnd = \"\";          /* Set to \" AND \" later on */\n  sqlite3_stmt *pXInfo = 0;       /* PRAGMA index_xinfo = ? */\n\n  if( rc==SQLITE_OK ){\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", pIter->zIdx)\n    );\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n    int iCid = sqlite3_column_int(pXInfo, 1);\n    int bDesc = sqlite3_column_int(pXInfo, 3);\n    const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n    const char *zCol;\n    const char *zType;\n\n    if( iCid<0 ){\n      /* An integer primary key. If the table has an explicit IPK, use\n      ** its name. Otherwise, use \"rbu_rowid\".  */\n      if( pIter->eType==RBU_PK_IPK ){\n        int i;\n        for(i=0; pIter->abTblPk[i]==0; i++);\n        assert( i<pIter->nTblCol );\n        zCol = pIter->azTblCol[i];\n      }else if( rbuIsVacuum(p) ){\n        zCol = \"_rowid_\";\n      }else{\n        zCol = \"rbu_rowid\";\n      }\n      zType = \"INTEGER\";\n    }else{\n      zCol = pIter->azTblCol[iCid];\n      zType = pIter->azTblType[iCid];\n    }\n\n    zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\" COLLATE %Q\", zRet, zCom, zCol, zCollate);\n    if( pIter->bUnique==0 || sqlite3_column_int(pXInfo, 5) ){\n      const char *zOrder = (bDesc ? \" DESC\" : \"\");\n      zImpPK = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\"%s\", \n          zImpPK, zCom, nBind, zCol, zOrder\n      );\n    }\n    zImpCols = sqlite3_mprintf(\"%z%s\\\"rbu_imp_%d%w\\\" %s COLLATE %Q\", \n        zImpCols, zCom, nBind, zCol, zType, zCollate\n    );\n    zWhere = sqlite3_mprintf(\n        \"%z%s\\\"rbu_imp_%d%w\\\" IS ?\", zWhere, zAnd, nBind, zCol\n    );\n    if( zRet==0 || zImpPK==0 || zImpCols==0 || zWhere==0 ) rc = SQLITE_NOMEM;\n    zCom = \", \";\n    zAnd = \" AND \";\n    nBind++;\n  }\n\n  rc2 = sqlite3_finalize(pXInfo);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRet);\n    sqlite3_free(zImpCols);\n    sqlite3_free(zImpPK);\n    sqlite3_free(zWhere);\n    zRet = 0;\n    zImpCols = 0;\n    zImpPK = 0;\n    zWhere = 0;\n    p->rc = rc;\n  }\n\n  *pzImposterCols = zImpCols;\n  *pzImposterPk = zImpPK;\n  *pzWhere = zWhere;\n  *pnBind = nBind;\n  return zRet;\n}\n\n/*\n** Assuming the current table columns are \"a\", \"b\" and \"c\", and the zObj\n** paramter is passed \"old\", return a string of the form:\n**\n**     \"old.a, old.b, old.b\"\n**\n** With the column names escaped.\n**\n** For tables with implicit rowids - RBU_PK_EXTERNAL and RBU_PK_NONE, append\n** the text \", old._rowid_\" to the returned value.\n*/\nstatic char *rbuObjIterGetOldlist(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zObj\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK && pIter->abIndexed ){\n    const char *zS = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abIndexed[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = sqlite3_mprintf(\"%z%s%s.\\\"%w\\\"\", zList, zS, zObj, zCol);\n      }else{\n        zList = sqlite3_mprintf(\"%z%sNULL\", zList, zS);\n      }\n      zS = \", \";\n      if( zList==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n    }\n\n    /* For a table with implicit rowids, append \"old._rowid_\" to the list. */\n    if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n      zList = rbuMPrintf(p, \"%z, %s._rowid_\", zList, zObj);\n    }\n  }\n  return zList;\n}\n\n/*\n** Return an expression that can be used in a WHERE clause to match the\n** primary key of the current table. For example, if the table is:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c));\n**\n** Return the string:\n**\n**   \"b = ?1 AND c = ?2\"\n*/\nstatic char *rbuObjIterGetWhere(\n  sqlite3rbu *p, \n  RbuObjIter *pIter\n){\n  char *zList = 0;\n  if( pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE ){\n    zList = rbuMPrintf(p, \"_rowid_ = ?%d\", pIter->nTblCol+1);\n  }else if( pIter->eType==RBU_PK_EXTERNAL ){\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        zList = rbuMPrintf(p, \"%z%sc%d=?%d\", zList, zSep, i, i+1);\n        zSep = \" AND \";\n      }\n    }\n    zList = rbuMPrintf(p, \n        \"_rowid_ = (SELECT id FROM rbu_imposter2 WHERE %z)\", zList\n    );\n\n  }else{\n    const char *zSep = \"\";\n    int i;\n    for(i=0; i<pIter->nTblCol; i++){\n      if( pIter->abTblPk[i] ){\n        const char *zCol = pIter->azTblCol[i];\n        zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", zList, zSep, zCol, i+1);\n        zSep = \" AND \";\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. However, there\n** is something wrong with the rbu_control value in the rbu_control value\n** stored in the (p->nCol+1)'th column. Set the error code and error message\n** of the RBU handle to something reflecting this.\n*/\nstatic void rbuBadControlError(sqlite3rbu *p){\n  p->rc = SQLITE_ERROR;\n  p->zErrmsg = sqlite3_mprintf(\"invalid rbu_control value\");\n}\n\n\n/*\n** Return a nul-terminated string containing the comma separated list of\n** assignments that should be included following the \"SET\" keyword of\n** an UPDATE statement used to update the table object that the iterator\n** passed as the second argument currently points to if the rbu_control\n** column of the data_xxx table entry is set to zMask.\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetSetlist(\n  sqlite3rbu *p,\n  RbuObjIter *pIter,\n  const char *zMask\n){\n  char *zList = 0;\n  if( p->rc==SQLITE_OK ){\n    int i;\n\n    if( (int)strlen(zMask)!=pIter->nTblCol ){\n      rbuBadControlError(p);\n    }else{\n      const char *zSep = \"\";\n      for(i=0; i<pIter->nTblCol; i++){\n        char c = zMask[pIter->aiSrcOrder[i]];\n        if( c=='x' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=?%d\", \n              zList, zSep, pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='d' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n        else if( c=='f' ){\n          zList = rbuMPrintf(p, \"%z%s\\\"%w\\\"=rbu_fossil_delta(\\\"%w\\\", ?%d)\", \n              zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1\n          );\n          zSep = \", \";\n        }\n      }\n    }\n  }\n  return zList;\n}\n\n/*\n** Return a nul-terminated string consisting of nByte comma separated\n** \"?\" expressions. For example, if nByte is 3, return a pointer to\n** a buffer containing the string \"?,?,?\".\n**\n** The memory for the returned string is obtained from sqlite3_malloc().\n** It is the responsibility of the caller to eventually free it using\n** sqlite3_free(). \n**\n** If an OOM error is encountered when allocating space for the new\n** string, an error code is left in the rbu handle passed as the first\n** argument and NULL is returned. Or, if an error has already occurred\n** when this function is called, NULL is returned immediately, without\n** attempting the allocation or modifying the stored error code.\n*/\nstatic char *rbuObjIterGetBindlist(sqlite3rbu *p, int nBind){\n  char *zRet = 0;\n  int nByte = nBind*2 + 1;\n\n  zRet = (char*)rbuMalloc(p, nByte);\n  if( zRet ){\n    int i;\n    for(i=0; i<nBind; i++){\n      zRet[i*2] = '?';\n      zRet[i*2+1] = (i+1==nBind) ? '\\0' : ',';\n    }\n  }\n  return zRet;\n}\n\n/*\n** The iterator currently points to a table (not index) of type \n** RBU_PK_WITHOUT_ROWID. This function creates the PRIMARY KEY \n** declaration for the corresponding imposter table. For example,\n** if the iterator points to a table created as:\n**\n**   CREATE TABLE t1(a, b, c, PRIMARY KEY(b, a DESC)) WITHOUT ROWID\n**\n** this function returns:\n**\n**   PRIMARY KEY(\"b\", \"a\" DESC)\n*/\nstatic char *rbuWithoutRowidPK(sqlite3rbu *p, RbuObjIter *pIter){\n  char *z = 0;\n  assert( pIter->zIdx==0 );\n  if( p->rc==SQLITE_OK ){\n    const char *zSep = \"PRIMARY KEY(\";\n    sqlite3_stmt *pXList = 0;     /* PRAGMA index_list = (pIter->zTbl) */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA index_xinfo = <pk-index> */\n   \n    p->rc = prepareFreeAndCollectError(p->dbMain, &pXList, &p->zErrmsg,\n        sqlite3_mprintf(\"PRAGMA main.index_list = %Q\", pIter->zTbl)\n    );\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXList) ){\n      const char *zOrig = (const char*)sqlite3_column_text(pXList,3);\n      if( zOrig && strcmp(zOrig, \"pk\")==0 ){\n        const char *zIdx = (const char*)sqlite3_column_text(pXList,1);\n        if( zIdx ){\n          p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n              sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n          );\n        }\n        break;\n      }\n    }\n    rbuFinalize(p, pXList);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      if( sqlite3_column_int(pXInfo, 5) ){\n        /* int iCid = sqlite3_column_int(pXInfo, 0); */\n        const char *zCol = (const char*)sqlite3_column_text(pXInfo, 2);\n        const char *zDesc = sqlite3_column_int(pXInfo, 3) ? \" DESC\" : \"\";\n        z = rbuMPrintf(p, \"%z%s\\\"%w\\\"%s\", z, zSep, zCol, zDesc);\n        zSep = \", \";\n      }\n    }\n    z = rbuMPrintf(p, \"%z)\", z);\n    rbuFinalize(p, pXInfo);\n  }\n  return z;\n}\n\n/*\n** This function creates the second imposter table used when writing to\n** a table b-tree where the table has an external primary key. If the\n** iterator passed as the second argument does not currently point to\n** a table (not index) with an external primary key, this function is a\n** no-op. \n**\n** Assuming the iterator does point to a table with an external PK, this\n** function creates a WITHOUT ROWID imposter table named \"rbu_imposter2\"\n** used to access that PK index. For example, if the target table is\n** declared as follows:\n**\n**   CREATE TABLE t1(a, b TEXT, c REAL, PRIMARY KEY(b, c));\n**\n** then the imposter table schema is:\n**\n**   CREATE TABLE rbu_imposter2(c1 TEXT, c2 REAL, id INTEGER) WITHOUT ROWID;\n**\n*/\nstatic void rbuCreateImposterTable2(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType==RBU_PK_EXTERNAL ){\n    int tnum = pIter->iPkTnum;    /* Root page of PK index */\n    sqlite3_stmt *pQuery = 0;     /* SELECT name ... WHERE rootpage = $tnum */\n    const char *zIdx = 0;         /* Name of PK index */\n    sqlite3_stmt *pXInfo = 0;     /* PRAGMA main.index_xinfo = $zIdx */\n    const char *zComma = \"\";\n    char *zCols = 0;              /* Used to build up list of table cols */\n    char *zPk = 0;                /* Used to build up table PK declaration */\n\n    /* Figure out the name of the primary key index for the current table.\n    ** This is needed for the argument to \"PRAGMA index_xinfo\". Set\n    ** zIdx to point to a nul-terminated string containing this name. */\n    p->rc = prepareAndCollectError(p->dbMain, &pQuery, &p->zErrmsg, \n        \"SELECT name FROM sqlite_master WHERE rootpage = ?\"\n    );\n    if( p->rc==SQLITE_OK ){\n      sqlite3_bind_int(pQuery, 1, tnum);\n      if( SQLITE_ROW==sqlite3_step(pQuery) ){\n        zIdx = (const char*)sqlite3_column_text(pQuery, 0);\n      }\n    }\n    if( zIdx ){\n      p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg,\n          sqlite3_mprintf(\"PRAGMA main.index_xinfo = %Q\", zIdx)\n      );\n    }\n    rbuFinalize(p, pQuery);\n\n    while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){\n      int bKey = sqlite3_column_int(pXInfo, 5);\n      if( bKey ){\n        int iCid = sqlite3_column_int(pXInfo, 1);\n        int bDesc = sqlite3_column_int(pXInfo, 3);\n        const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4);\n        zCols = rbuMPrintf(p, \"%z%sc%d %s COLLATE %s\", zCols, zComma, \n            iCid, pIter->azTblType[iCid], zCollate\n        );\n        zPk = rbuMPrintf(p, \"%z%sc%d%s\", zPk, zComma, iCid, bDesc?\" DESC\":\"\");\n        zComma = \", \";\n      }\n    }\n    zCols = rbuMPrintf(p, \"%z, id INTEGER\", zCols);\n    rbuFinalize(p, pXInfo);\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain,\n        \"CREATE TABLE rbu_imposter2(%z, PRIMARY KEY(%z)) WITHOUT ROWID\", \n        zCols, zPk\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** If an error has already occurred when this function is called, it \n** immediately returns zero (without doing any work). Or, if an error\n** occurs during the execution of this function, it sets the error code\n** in the sqlite3rbu object indicated by the first argument and returns\n** zero.\n**\n** The iterator passed as the second argument is guaranteed to point to\n** a table (not an index) when this function is called. This function\n** attempts to create any imposter table required to write to the main\n** table b-tree of the table before returning. Non-zero is returned if\n** an imposter table are created, or zero otherwise.\n**\n** An imposter table is required in all cases except RBU_PK_VTAB. Only\n** virtual tables are written to directly. The imposter table has the \n** same schema as the actual target table (less any UNIQUE constraints). \n** More precisely, the \"same schema\" means the same columns, types, \n** collation sequences. For tables that do not have an external PRIMARY\n** KEY, it also means the same PRIMARY KEY declaration.\n*/\nstatic void rbuCreateImposterTable(sqlite3rbu *p, RbuObjIter *pIter){\n  if( p->rc==SQLITE_OK && pIter->eType!=RBU_PK_VTAB ){\n    int tnum = pIter->iTnum;\n    const char *zComma = \"\";\n    char *zSql = 0;\n    int iCol;\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n\n    for(iCol=0; p->rc==SQLITE_OK && iCol<pIter->nTblCol; iCol++){\n      const char *zPk = \"\";\n      const char *zCol = pIter->azTblCol[iCol];\n      const char *zColl = 0;\n\n      p->rc = sqlite3_table_column_metadata(\n          p->dbMain, \"main\", pIter->zTbl, zCol, 0, &zColl, 0, 0, 0\n      );\n\n      if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){\n        /* If the target table column is an \"INTEGER PRIMARY KEY\", add\n        ** \"PRIMARY KEY\" to the imposter table column declaration. */\n        zPk = \"PRIMARY KEY \";\n      }\n      zSql = rbuMPrintf(p, \"%z%s\\\"%w\\\" %s %sCOLLATE %s%s\", \n          zSql, zComma, zCol, pIter->azTblType[iCol], zPk, zColl,\n          (pIter->abNotNull[iCol] ? \" NOT NULL\" : \"\")\n      );\n      zComma = \", \";\n    }\n\n    if( pIter->eType==RBU_PK_WITHOUT_ROWID ){\n      char *zPk = rbuWithoutRowidPK(p, pIter);\n      if( zPk ){\n        zSql = rbuMPrintf(p, \"%z, %z\", zSql, zPk);\n      }\n    }\n\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1, tnum);\n    rbuMPrintfExec(p, p->dbMain, \"CREATE TABLE \\\"rbu_imp_%w\\\"(%z)%s\", \n        pIter->zTbl, zSql, \n        (pIter->eType==RBU_PK_WITHOUT_ROWID ? \" WITHOUT ROWID\" : \"\")\n    );\n    sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n  }\n}\n\n/*\n** Prepare a statement used to insert rows into the \"rbu_tmp_xxx\" table.\n** Specifically a statement of the form:\n**\n**     INSERT INTO rbu_tmp_xxx VALUES(?, ?, ? ...);\n**\n** The number of bound variables is equal to the number of columns in\n** the target table, plus one (for the rbu_control column), plus one more \n** (for the rbu_rowid column) if the target table is an implicit IPK or \n** virtual table.\n*/\nstatic void rbuObjIterPrepareTmpInsert(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  const char *zCollist,\n  const char *zRbuRowid\n){\n  int bRbuRowid = (pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE);\n  char *zBind = rbuObjIterGetBindlist(p, pIter->nTblCol + 1 + bRbuRowid);\n  if( zBind ){\n    assert( pIter->pTmpInsert==0 );\n    p->rc = prepareFreeAndCollectError(\n        p->dbRbu, &pIter->pTmpInsert, &p->zErrmsg, sqlite3_mprintf(\n          \"INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)\", \n          p->zStateDb, pIter->zDataTbl, zCollist, zRbuRowid, zBind\n    ));\n  }\n}\n\nstatic void rbuTmpInsertFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = sqlite3_user_data(pCtx);\n  int rc = SQLITE_OK;\n  int i;\n\n  assert( sqlite3_value_int(apVal[0])!=0\n      || p->objiter.eType==RBU_PK_EXTERNAL \n      || p->objiter.eType==RBU_PK_NONE \n  );\n  if( sqlite3_value_int(apVal[0])!=0 ){\n    p->nPhaseOneStep += p->objiter.nIndex;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nVal; i++){\n    rc = sqlite3_bind_value(p->objiter.pTmpInsert, i+1, apVal[i]);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_step(p->objiter.pTmpInsert);\n    rc = sqlite3_reset(p->objiter.pTmpInsert);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\n/*\n** Ensure that the SQLite statement handles required to update the \n** target database object currently indicated by the iterator passed \n** as the second argument are available.\n*/\nstatic int rbuObjIterPrepareAll(\n  sqlite3rbu *p, \n  RbuObjIter *pIter,\n  int nOffset                     /* Add \"LIMIT -1 OFFSET $nOffset\" to SELECT */\n){\n  assert( pIter->bCleanup==0 );\n  if( pIter->pSelect==0 && rbuObjIterCacheTableInfo(p, pIter)==SQLITE_OK ){\n    const int tnum = pIter->iTnum;\n    char *zCollist = 0;           /* List of indexed columns */\n    char **pz = &p->zErrmsg;\n    const char *zIdx = pIter->zIdx;\n    char *zLimit = 0;\n\n    if( nOffset ){\n      zLimit = sqlite3_mprintf(\" LIMIT -1 OFFSET %d\", nOffset);\n      if( !zLimit ) p->rc = SQLITE_NOMEM;\n    }\n\n    if( zIdx ){\n      const char *zTbl = pIter->zTbl;\n      char *zImposterCols = 0;    /* Columns for imposter table */\n      char *zImposterPK = 0;      /* Primary key declaration for imposter */\n      char *zWhere = 0;           /* WHERE clause on PK columns */\n      char *zBind = 0;\n      int nBind = 0;\n\n      assert( pIter->eType!=RBU_PK_VTAB );\n      zCollist = rbuObjIterGetIndexCols(\n          p, pIter, &zImposterCols, &zImposterPK, &zWhere, &nBind\n      );\n      zBind = rbuObjIterGetBindlist(p, nBind);\n\n      /* Create the imposter table used to write to this index. */\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 1);\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 1,tnum);\n      rbuMPrintfExec(p, p->dbMain,\n          \"CREATE TABLE \\\"rbu_imp_%w\\\"( %s, PRIMARY KEY( %s ) ) WITHOUT ROWID\",\n          zTbl, zImposterCols, zImposterPK\n      );\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->dbMain, \"main\", 0, 0);\n\n      /* Create the statement to insert index entries */\n      pIter->nCol = nBind;\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pInsert, &p->zErrmsg,\n          sqlite3_mprintf(\"INSERT INTO \\\"rbu_imp_%w\\\" VALUES(%s)\", zTbl, zBind)\n        );\n      }\n\n      /* And to delete index entries */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(\n            p->dbMain, &pIter->pDelete, &p->zErrmsg,\n          sqlite3_mprintf(\"DELETE FROM \\\"rbu_imp_%w\\\" WHERE %s\", zTbl, zWhere)\n        );\n      }\n\n      /* Create the SELECT statement to read keys in sorted order */\n      if( p->rc==SQLITE_OK ){\n        char *zSql;\n        if( rbuIsVacuum(p) ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, 0 AS rbu_control FROM '%q' ORDER BY %s%s\",\n              zCollist, \n              pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl,\n              zCollist, zLimit\n          );\n        }else{\n          zSql = sqlite3_mprintf(\n              \"SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' \"\n              \"UNION ALL \"\n              \"SELECT %s, rbu_control FROM '%q' \"\n              \"WHERE typeof(rbu_control)='integer' AND rbu_control!=1 \"\n              \"ORDER BY %s%s\",\n              zCollist, p->zStateDb, pIter->zDataTbl, \n              zCollist, pIter->zDataTbl, \n              zCollist, zLimit\n          );\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql);\n      }\n\n      sqlite3_free(zImposterCols);\n      sqlite3_free(zImposterPK);\n      sqlite3_free(zWhere);\n      sqlite3_free(zBind);\n    }else{\n      int bRbuRowid = (pIter->eType==RBU_PK_VTAB)\n                    ||(pIter->eType==RBU_PK_NONE)\n                    ||(pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p));\n      const char *zTbl = pIter->zTbl;       /* Table this step applies to */\n      const char *zWrite;                   /* Imposter table name */\n\n      char *zBindings = rbuObjIterGetBindlist(p, pIter->nTblCol + bRbuRowid);\n      char *zWhere = rbuObjIterGetWhere(p, pIter);\n      char *zOldlist = rbuObjIterGetOldlist(p, pIter, \"old\");\n      char *zNewlist = rbuObjIterGetOldlist(p, pIter, \"new\");\n\n      zCollist = rbuObjIterGetCollist(p, pIter);\n      pIter->nCol = pIter->nTblCol;\n\n      /* Create the imposter table or tables (if required). */\n      rbuCreateImposterTable(p, pIter);\n      rbuCreateImposterTable2(p, pIter);\n      zWrite = (pIter->eType==RBU_PK_VTAB ? \"\" : \"rbu_imp_\");\n\n      /* Create the INSERT statement to write to the target PK b-tree */\n      if( p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pInsert, pz,\n            sqlite3_mprintf(\n              \"INSERT INTO \\\"%s%w\\\"(%s%s) VALUES(%s)\", \n              zWrite, zTbl, zCollist, (bRbuRowid ? \", _rowid_\" : \"\"), zBindings\n            )\n        );\n      }\n\n      /* Create the DELETE statement to write to the target PK b-tree.\n      ** Because it only performs INSERT operations, this is not required for\n      ** an rbu vacuum handle.  */\n      if( rbuIsVacuum(p)==0 && p->rc==SQLITE_OK ){\n        p->rc = prepareFreeAndCollectError(p->dbMain, &pIter->pDelete, pz,\n            sqlite3_mprintf(\n              \"DELETE FROM \\\"%s%w\\\" WHERE %s\", zWrite, zTbl, zWhere\n            )\n        );\n      }\n\n      if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n        const char *zRbuRowid = \"\";\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          zRbuRowid = \", rbu_rowid\";\n        }\n\n        /* Create the rbu_tmp_xxx table and the triggers to populate it. */\n        rbuMPrintfExec(p, p->dbRbu,\n            \"CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS \"\n            \"SELECT *%s FROM '%q' WHERE 0;\"\n            , p->zStateDb, pIter->zDataTbl\n            , (pIter->eType==RBU_PK_EXTERNAL ? \", 0 AS rbu_rowid\" : \"\")\n            , pIter->zDataTbl\n        );\n\n        rbuMPrintfExec(p, p->dbMain,\n            \"CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update1_tr BEFORE UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(3, %s);\"\n            \"END;\"\n\n            \"CREATE TEMP TRIGGER rbu_update2_tr AFTER UPDATE ON \\\"%s%w\\\" \"\n            \"BEGIN \"\n            \"  SELECT rbu_tmp_insert(4, %s);\"\n            \"END;\",\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zOldlist,\n            zWrite, zTbl, zNewlist\n        );\n\n        if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){\n          rbuMPrintfExec(p, p->dbMain,\n              \"CREATE TEMP TRIGGER rbu_insert_tr AFTER INSERT ON \\\"%s%w\\\" \"\n              \"BEGIN \"\n              \"  SELECT rbu_tmp_insert(0, %s);\"\n              \"END;\",\n              zWrite, zTbl, zNewlist\n          );\n        }\n\n        rbuObjIterPrepareTmpInsert(p, pIter, zCollist, zRbuRowid);\n      }\n\n      /* Create the SELECT statement to read keys from data_xxx */\n      if( p->rc==SQLITE_OK ){\n        const char *zRbuRowid = \"\";\n        if( bRbuRowid ){\n          zRbuRowid = rbuIsVacuum(p) ? \",_rowid_ \" : \",rbu_rowid\";\n        }\n        p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz,\n            sqlite3_mprintf(\n              \"SELECT %s,%s rbu_control%s FROM '%q'%s\", \n              zCollist, \n              (rbuIsVacuum(p) ? \"0 AS \" : \"\"),\n              zRbuRowid,\n              pIter->zDataTbl, zLimit\n            )\n        );\n      }\n\n      sqlite3_free(zWhere);\n      sqlite3_free(zOldlist);\n      sqlite3_free(zNewlist);\n      sqlite3_free(zBindings);\n    }\n    sqlite3_free(zCollist);\n    sqlite3_free(zLimit);\n  }\n  \n  return p->rc;\n}\n\n/*\n** Set output variable *ppStmt to point to an UPDATE statement that may\n** be used to update the imposter table for the main table b-tree of the\n** table object that pIter currently points to, assuming that the \n** rbu_control column of the data_xyz table contains zMask.\n** \n** If the zMask string does not specify any columns to update, then this\n** is not an error. Output variable *ppStmt is set to NULL in this case.\n*/\nstatic int rbuGetUpdateStmt(\n  sqlite3rbu *p,                  /* RBU handle */\n  RbuObjIter *pIter,              /* Object iterator */\n  const char *zMask,              /* rbu_control value ('x.x.') */\n  sqlite3_stmt **ppStmt           /* OUT: UPDATE statement handle */\n){\n  RbuUpdateStmt **pp;\n  RbuUpdateStmt *pUp = 0;\n  int nUp = 0;\n\n  /* In case an error occurs */\n  *ppStmt = 0;\n\n  /* Search for an existing statement. If one is found, shift it to the front\n  ** of the LRU queue and return immediately. Otherwise, leave nUp pointing\n  ** to the number of statements currently in the cache and pUp to the\n  ** last object in the list.  */\n  for(pp=&pIter->pRbuUpdate; *pp; pp=&((*pp)->pNext)){\n    pUp = *pp;\n    if( strcmp(pUp->zMask, zMask)==0 ){\n      *pp = pUp->pNext;\n      pUp->pNext = pIter->pRbuUpdate;\n      pIter->pRbuUpdate = pUp;\n      *ppStmt = pUp->pUpdate; \n      return SQLITE_OK;\n    }\n    nUp++;\n  }\n  assert( pUp==0 || pUp->pNext==0 );\n\n  if( nUp>=SQLITE_RBU_UPDATE_CACHESIZE ){\n    for(pp=&pIter->pRbuUpdate; *pp!=pUp; pp=&((*pp)->pNext));\n    *pp = 0;\n    sqlite3_finalize(pUp->pUpdate);\n    pUp->pUpdate = 0;\n  }else{\n    pUp = (RbuUpdateStmt*)rbuMalloc(p, sizeof(RbuUpdateStmt)+pIter->nTblCol+1);\n  }\n\n  if( pUp ){\n    char *zWhere = rbuObjIterGetWhere(p, pIter);\n    char *zSet = rbuObjIterGetSetlist(p, pIter, zMask);\n    char *zUpdate = 0;\n\n    pUp->zMask = (char*)&pUp[1];\n    memcpy(pUp->zMask, zMask, pIter->nTblCol);\n    pUp->pNext = pIter->pRbuUpdate;\n    pIter->pRbuUpdate = pUp;\n\n    if( zSet ){\n      const char *zPrefix = \"\";\n\n      if( pIter->eType!=RBU_PK_VTAB ) zPrefix = \"rbu_imp_\";\n      zUpdate = sqlite3_mprintf(\"UPDATE \\\"%s%w\\\" SET %s WHERE %s\", \n          zPrefix, pIter->zTbl, zSet, zWhere\n      );\n      p->rc = prepareFreeAndCollectError(\n          p->dbMain, &pUp->pUpdate, &p->zErrmsg, zUpdate\n      );\n      *ppStmt = pUp->pUpdate;\n    }\n    sqlite3_free(zWhere);\n    sqlite3_free(zSet);\n  }\n\n  return p->rc;\n}\n\nstatic sqlite3 *rbuOpenDbhandle(\n  sqlite3rbu *p, \n  const char *zName, \n  int bUseVfs\n){\n  sqlite3 *db = 0;\n  if( p->rc==SQLITE_OK ){\n    const int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_URI;\n    p->rc = sqlite3_open_v2(zName, &db, flags, bUseVfs ? p->zVfsName : 0);\n    if( p->rc ){\n      p->zErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n      sqlite3_close(db);\n      db = 0;\n    }\n  }\n  return db;\n}\n\n/*\n** Free an RbuState object allocated by rbuLoadState().\n*/\nstatic void rbuFreeState(RbuState *p){\n  if( p ){\n    sqlite3_free(p->zTbl);\n    sqlite3_free(p->zIdx);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Allocate an RbuState object and load the contents of the rbu_state \n** table into it. Return a pointer to the new object. It is the \n** responsibility of the caller to eventually free the object using\n** sqlite3_free().\n**\n** If an error occurs, leave an error code and message in the rbu handle\n** and return NULL.\n*/\nstatic RbuState *rbuLoadState(sqlite3rbu *p){\n  RbuState *pRet = 0;\n  sqlite3_stmt *pStmt = 0;\n  int rc;\n  int rc2;\n\n  pRet = (RbuState*)rbuMalloc(p, sizeof(RbuState));\n  if( pRet==0 ) return 0;\n\n  rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, \n      sqlite3_mprintf(\"SELECT k, v FROM %s.rbu_state\", p->zStateDb)\n  );\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    switch( sqlite3_column_int(pStmt, 0) ){\n      case RBU_STATE_STAGE:\n        pRet->eStage = sqlite3_column_int(pStmt, 1);\n        if( pRet->eStage!=RBU_STAGE_OAL\n         && pRet->eStage!=RBU_STAGE_MOVE\n         && pRet->eStage!=RBU_STAGE_CKPT\n        ){\n          p->rc = SQLITE_CORRUPT;\n        }\n        break;\n\n      case RBU_STATE_TBL:\n        pRet->zTbl = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_IDX:\n        pRet->zIdx = rbuStrndup((char*)sqlite3_column_text(pStmt, 1), &rc);\n        break;\n\n      case RBU_STATE_ROW:\n        pRet->nRow = sqlite3_column_int(pStmt, 1);\n        break;\n\n      case RBU_STATE_PROGRESS:\n        pRet->nProgress = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_CKPT:\n        pRet->iWalCksum = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_COOKIE:\n        pRet->iCookie = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_OALSZ:\n        pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1);\n        break;\n\n      case RBU_STATE_PHASEONESTEP:\n        pRet->nPhaseOneStep = sqlite3_column_int64(pStmt, 1);\n        break;\n\n      default:\n        rc = SQLITE_CORRUPT;\n        break;\n    }\n  }\n  rc2 = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) rc = rc2;\n\n  p->rc = rc;\n  return pRet;\n}\n\n\n/*\n** Open the database handle and attach the RBU database as \"rbu\". If an\n** error occurs, leave an error code and message in the RBU handle.\n*/\nstatic void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){\n  assert( p->rc || (p->dbMain==0 && p->dbRbu==0) );\n  assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 );\n\n  /* Open the RBU database */\n  p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1);\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( p->zState==0 ){\n      const char *zFile = sqlite3_db_filename(p->dbRbu, \"main\");\n      p->zState = rbuMPrintf(p, \"file://%s-vacuum?modeof=%s\", zFile, zFile);\n    }\n  }\n\n  /* If using separate RBU and state databases, attach the state database to\n  ** the RBU db handle now.  */\n  if( p->zState ){\n    rbuMPrintfExec(p, p->dbRbu, \"ATTACH %Q AS stat\", p->zState);\n    memcpy(p->zStateDb, \"stat\", 4);\n  }else{\n    memcpy(p->zStateDb, \"main\", 4);\n  }\n\n#if 0\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, 0);\n  }\n#endif\n\n  /* If it has not already been created, create the rbu_state table */\n  rbuMPrintfExec(p, p->dbRbu, RBU_CREATE_STATE, p->zStateDb);\n\n#if 0\n  if( rbuIsVacuum(p) ){\n    if( p->rc==SQLITE_OK ){\n      int rc2;\n      int bOk = 0;\n      sqlite3_stmt *pCnt = 0;\n      p->rc = prepareAndCollectError(p->dbRbu, &pCnt, &p->zErrmsg,\n          \"SELECT count(*) FROM stat.sqlite_master\"\n      );\n      if( p->rc==SQLITE_OK \n       && sqlite3_step(pCnt)==SQLITE_ROW\n       && 1==sqlite3_column_int(pCnt, 0)\n      ){\n        bOk = 1;\n      }\n      rc2 = sqlite3_finalize(pCnt);\n      if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n      if( p->rc==SQLITE_OK && bOk==0 ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"invalid state database\");\n      }\n    \n      if( p->rc==SQLITE_OK ){\n        p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n      }\n    }\n  }\n#endif\n\n  if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){\n    int bOpen = 0;\n    int rc;\n    p->nRbu = 0;\n    p->pRbuFd = 0;\n    rc = sqlite3_file_control(p->dbRbu, \"main\", SQLITE_FCNTL_RBUCNT, (void*)p);\n    if( rc!=SQLITE_NOTFOUND ) p->rc = rc;\n    if( p->eStage>=RBU_STAGE_MOVE ){\n      bOpen = 1;\n    }else{\n      RbuState *pState = rbuLoadState(p);\n      if( pState ){\n        bOpen = (pState->eStage>=RBU_STAGE_MOVE);\n        rbuFreeState(pState);\n      }\n    }\n    if( bOpen ) p->dbMain = rbuOpenDbhandle(p, p->zRbu, p->nRbu<=1);\n  }\n\n  p->eStage = 0;\n  if( p->rc==SQLITE_OK && p->dbMain==0 ){\n    if( !rbuIsVacuum(p) ){\n      p->dbMain = rbuOpenDbhandle(p, p->zTarget, 1);\n    }else if( p->pRbuFd->pWalFd ){\n      if( pbRetry ){\n        p->pRbuFd->bNolock = 0;\n        sqlite3_close(p->dbRbu);\n        sqlite3_close(p->dbMain);\n        p->dbMain = 0;\n        p->dbRbu = 0;\n        *pbRetry = 1;\n        return;\n      }\n      p->rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"cannot vacuum wal mode database\");\n    }else{\n      char *zTarget;\n      char *zExtra = 0;\n      if( strlen(p->zRbu)>=5 && 0==memcmp(\"file:\", p->zRbu, 5) ){\n        zExtra = &p->zRbu[5];\n        while( *zExtra ){\n          if( *zExtra++=='?' ) break;\n        }\n        if( *zExtra=='\\0' ) zExtra = 0;\n      }\n\n      zTarget = sqlite3_mprintf(\"file:%s-vacuum?rbu_memory=1%s%s\", \n          sqlite3_db_filename(p->dbRbu, \"main\"),\n          (zExtra==0 ? \"\" : \"&\"), (zExtra==0 ? \"\" : zExtra)\n      );\n\n      if( zTarget==0 ){\n        p->rc = SQLITE_NOMEM;\n        return;\n      }\n      p->dbMain = rbuOpenDbhandle(p, zTarget, p->nRbu<=1);\n      sqlite3_free(zTarget);\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_tmp_insert\", -1, SQLITE_UTF8, (void*)p, rbuTmpInsertFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbMain, \n        \"rbu_fossil_delta\", 2, SQLITE_UTF8, 0, rbuFossilDeltaFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_target_name\", -1, SQLITE_UTF8, (void*)p, rbuTargetNameFunc, 0, 0\n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n  rbuMPrintfExec(p, p->dbMain, \"SELECT * FROM sqlite_master\");\n\n  /* Mark the database file just opened as an RBU target database. If \n  ** this call returns SQLITE_NOTFOUND, then the RBU vfs is not in use.\n  ** This is an error.  */\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_file_control(p->dbMain, \"main\", SQLITE_FCNTL_RBU, (void*)p);\n  }\n\n  if( p->rc==SQLITE_NOTFOUND ){\n    p->rc = SQLITE_ERROR;\n    p->zErrmsg = sqlite3_mprintf(\"rbu vfs not found\");\n  }\n}\n\n/*\n** This routine is a copy of the sqlite3FileSuffix3() routine from the core.\n** It is a no-op unless SQLITE_ENABLE_8_3_NAMES is defined.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nstatic void rbuFileSuffix3(const char *zBase, char *z){\n#ifdef SQLITE_ENABLE_8_3_NAMES\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBase, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = (int)strlen(z)&0xffffff;\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n#endif\n}\n\n/*\n** Return the current wal-index header checksum for the target database \n** as a 64-bit integer.\n**\n** The checksum is store in the first page of xShmMap memory as an 8-byte \n** blob starting at byte offset 40.\n*/\nstatic i64 rbuShmChecksum(sqlite3rbu *p){\n  i64 iRet = 0;\n  if( p->rc==SQLITE_OK ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    u32 volatile *ptr;\n    p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, (void volatile**)&ptr);\n    if( p->rc==SQLITE_OK ){\n      iRet = ((i64)ptr[10] << 32) + ptr[11];\n    }\n  }\n  return iRet;\n}\n\n/*\n** This function is called as part of initializing or reinitializing an\n** incremental checkpoint. \n**\n** It populates the sqlite3rbu.aFrame[] array with the set of \n** (wal frame -> db page) copy operations required to checkpoint the \n** current wal file, and obtains the set of shm locks required to safely \n** perform the copy operations directly on the file-system.\n**\n** If argument pState is not NULL, then the incremental checkpoint is\n** being resumed. In this case, if the checksum of the wal-index-header\n** following recovery is not the same as the checksum saved in the RbuState\n** object, then the rbu handle is set to DONE state. This occurs if some\n** other client appends a transaction to the wal file in the middle of\n** an incremental checkpoint.\n*/\nstatic void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){\n\n  /* If pState is NULL, then the wal file may not have been opened and\n  ** recovered. Running a read-statement here to ensure that doing so\n  ** does not interfere with the \"capture\" process below.  */\n  if( pState==0 ){\n    p->eStage = 0;\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3_exec(p->dbMain, \"SELECT * FROM sqlite_master\", 0, 0, 0);\n    }\n  }\n\n  /* Assuming no error has occurred, run a \"restart\" checkpoint with the\n  ** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following\n  ** special behaviour in the rbu VFS:\n  **\n  **   * If the exclusive shm WRITER or READ0 lock cannot be obtained,\n  **     the checkpoint fails with SQLITE_BUSY (normally SQLite would\n  **     proceed with running a passive checkpoint instead of failing).\n  **\n  **   * Attempts to read from the *-wal file or write to the database file\n  **     do not perform any IO. Instead, the frame/page combinations that\n  **     would be read/written are recorded in the sqlite3rbu.aFrame[]\n  **     array.\n  **\n  **   * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER, \n  **     READ0 and CHECKPOINT locks taken as part of the checkpoint are\n  **     no-ops. These locks will not be released until the connection\n  **     is closed.\n  **\n  **   * Attempting to xSync() the database file causes an SQLITE_INTERNAL \n  **     error.\n  **\n  ** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the\n  ** checkpoint below fails with SQLITE_INTERNAL, and leaves the aFrame[]\n  ** array populated with a set of (frame -> page) mappings. Because the \n  ** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy \n  ** data from the wal file into the database file according to the \n  ** contents of aFrame[].\n  */\n  if( p->rc==SQLITE_OK ){\n    int rc2;\n    p->eStage = RBU_STAGE_CAPTURE;\n    rc2 = sqlite3_exec(p->dbMain, \"PRAGMA main.wal_checkpoint=restart\", 0, 0,0);\n    if( rc2!=SQLITE_INTERNAL ) p->rc = rc2;\n  }\n\n  if( p->rc==SQLITE_OK && p->nFrame>0 ){\n    p->eStage = RBU_STAGE_CKPT;\n    p->nStep = (pState ? pState->nRow : 0);\n    p->aBuf = rbuMalloc(p, p->pgsz);\n    p->iWalCksum = rbuShmChecksum(p);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){\n      p->rc = SQLITE_DONE;\n      p->eStage = RBU_STAGE_DONE;\n    }else{\n      int nSectorSize;\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n      assert( p->nPagePerSector==0 );\n      nSectorSize = pDb->pMethods->xSectorSize(pDb);\n      if( nSectorSize>p->pgsz ){\n        p->nPagePerSector = nSectorSize / p->pgsz;\n      }else{\n        p->nPagePerSector = 1;\n      }\n\n      /* Call xSync() on the wal file. This causes SQLite to sync the \n      ** directory in which the target database and the wal file reside, in \n      ** case it has not been synced since the rename() call in \n      ** rbuMoveOalFile(). */\n      p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);\n    }\n  }\n}\n\n/*\n** Called when iAmt bytes are read from offset iOff of the wal file while\n** the rbu object is in capture mode. Record the frame number of the frame\n** being read in the aFrame[] array.\n*/\nstatic int rbuCaptureWalRead(sqlite3rbu *pRbu, i64 iOff, int iAmt){\n  const u32 mReq = (1<<WAL_LOCK_WRITE)|(1<<WAL_LOCK_CKPT)|(1<<WAL_LOCK_READ0);\n  u32 iFrame;\n\n  if( pRbu->mLock!=mReq ){\n    pRbu->rc = SQLITE_BUSY;\n    return SQLITE_INTERNAL;\n  }\n\n  pRbu->pgsz = iAmt;\n  if( pRbu->nFrame==pRbu->nFrameAlloc ){\n    int nNew = (pRbu->nFrameAlloc ? pRbu->nFrameAlloc : 64) * 2;\n    RbuFrame *aNew;\n    aNew = (RbuFrame*)sqlite3_realloc64(pRbu->aFrame, nNew * sizeof(RbuFrame));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    pRbu->aFrame = aNew;\n    pRbu->nFrameAlloc = nNew;\n  }\n\n  iFrame = (u32)((iOff-32) / (i64)(iAmt+24)) + 1;\n  if( pRbu->iMaxFrame<iFrame ) pRbu->iMaxFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iWalFrame = iFrame;\n  pRbu->aFrame[pRbu->nFrame].iDbPage = 0;\n  pRbu->nFrame++;\n  return SQLITE_OK;\n}\n\n/*\n** Called when a page of data is written to offset iOff of the database\n** file while the rbu handle is in capture mode. Record the page number \n** of the page being written in the aFrame[] array.\n*/\nstatic int rbuCaptureDbWrite(sqlite3rbu *pRbu, i64 iOff){\n  pRbu->aFrame[pRbu->nFrame-1].iDbPage = (u32)(iOff / pRbu->pgsz) + 1;\n  return SQLITE_OK;\n}\n\n/*\n** This is called as part of an incremental checkpoint operation. Copy\n** a single frame of data from the wal file into the database file, as\n** indicated by the RbuFrame object.\n*/\nstatic void rbuCheckpointFrame(sqlite3rbu *p, RbuFrame *pFrame){\n  sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;\n  sqlite3_file *pDb = p->pTargetFd->pReal;\n  i64 iOff;\n\n  assert( p->rc==SQLITE_OK );\n  iOff = (i64)(pFrame->iWalFrame-1) * (p->pgsz + 24) + 32 + 24;\n  p->rc = pWal->pMethods->xRead(pWal, p->aBuf, p->pgsz, iOff);\n  if( p->rc ) return;\n\n  iOff = (i64)(pFrame->iDbPage-1) * p->pgsz;\n  p->rc = pDb->pMethods->xWrite(pDb, p->aBuf, p->pgsz, iOff);\n}\n\n\n/*\n** Take an EXCLUSIVE lock on the database file.\n*/\nstatic void rbuLockDatabase(sqlite3rbu *p){\n  sqlite3_file *pReal = p->pTargetFd->pReal;\n  assert( p->rc==SQLITE_OK );\n  p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED);\n  if( p->rc==SQLITE_OK ){\n    p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE);\n  }\n}\n\n#if defined(_WIN32_WCE)\nstatic LPWSTR rbuWinUtf8ToUnicode(const char *zFilename){\n  int nChar;\n  LPWSTR zWideFilename;\n\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideFilename = sqlite3_malloc64( nChar*sizeof(zWideFilename[0]) );\n  if( zWideFilename==0 ){\n    return 0;\n  }\n  memset(zWideFilename, 0, nChar*sizeof(zWideFilename[0]));\n  nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideFilename);\n    zWideFilename = 0;\n  }\n  return zWideFilename;\n}\n#endif\n\n/*\n** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock\n** on the database file. This proc moves the *-oal file to the *-wal path,\n** then reopens the database file (this time in vanilla, non-oal, WAL mode).\n** If an error occurs, leave an error code and error message in the rbu \n** handle.\n*/\nstatic void rbuMoveOalFile(sqlite3rbu *p){\n  const char *zBase = sqlite3_db_filename(p->dbMain, \"main\");\n  const char *zMove = zBase;\n  char *zOal;\n  char *zWal;\n\n  if( rbuIsVacuum(p) ){\n    zMove = sqlite3_db_filename(p->dbRbu, \"main\");\n  }\n  zOal = sqlite3_mprintf(\"%s-oal\", zMove);\n  zWal = sqlite3_mprintf(\"%s-wal\", zMove);\n\n  assert( p->eStage==RBU_STAGE_MOVE );\n  assert( p->rc==SQLITE_OK && p->zErrmsg==0 );\n  if( zWal==0 || zOal==0 ){\n    p->rc = SQLITE_NOMEM;\n  }else{\n    /* Move the *-oal file to *-wal. At this point connection p->db is\n    ** holding a SHARED lock on the target database file (because it is\n    ** in WAL mode). So no other connection may be writing the db. \n    **\n    ** In order to ensure that there are no database readers, an EXCLUSIVE\n    ** lock is obtained here before the *-oal is moved to *-wal.\n    */\n    rbuLockDatabase(p);\n    if( p->rc==SQLITE_OK ){\n      rbuFileSuffix3(zBase, zWal);\n      rbuFileSuffix3(zBase, zOal);\n\n      /* Re-open the databases. */\n      rbuObjIterFinalize(&p->objiter);\n      sqlite3_close(p->dbRbu);\n      sqlite3_close(p->dbMain);\n      p->dbMain = 0;\n      p->dbRbu = 0;\n\n#if defined(_WIN32_WCE)\n      {\n        LPWSTR zWideOal;\n        LPWSTR zWideWal;\n\n        zWideOal = rbuWinUtf8ToUnicode(zOal);\n        if( zWideOal ){\n          zWideWal = rbuWinUtf8ToUnicode(zWal);\n          if( zWideWal ){\n            if( MoveFileW(zWideOal, zWideWal) ){\n              p->rc = SQLITE_OK;\n            }else{\n              p->rc = SQLITE_IOERR;\n            }\n            sqlite3_free(zWideWal);\n          }else{\n            p->rc = SQLITE_IOERR_NOMEM;\n          }\n          sqlite3_free(zWideOal);\n        }else{\n          p->rc = SQLITE_IOERR_NOMEM;\n        }\n      }\n#else\n      p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;\n#endif\n\n      if( p->rc==SQLITE_OK ){\n        rbuOpenDatabase(p, 0);\n        rbuSetupCheckpoint(p, 0);\n      }\n    }\n  }\n\n  sqlite3_free(zWal);\n  sqlite3_free(zOal);\n}\n\n/*\n** The SELECT statement iterating through the keys for the current object\n** (p->objiter.pSelect) currently points to a valid row. This function\n** determines the type of operation requested by this row and returns\n** one of the following values to indicate the result:\n**\n**     * RBU_INSERT\n**     * RBU_DELETE\n**     * RBU_IDX_DELETE\n**     * RBU_UPDATE\n**\n** If RBU_UPDATE is returned, then output variable *pzMask is set to\n** point to the text value indicating the columns to update.\n**\n** If the rbu_control field contains an invalid value, an error code and\n** message are left in the RBU handle and zero returned.\n*/\nstatic int rbuStepType(sqlite3rbu *p, const char **pzMask){\n  int iCol = p->objiter.nCol;     /* Index of rbu_control column */\n  int res = 0;                    /* Return value */\n\n  switch( sqlite3_column_type(p->objiter.pSelect, iCol) ){\n    case SQLITE_INTEGER: {\n      int iVal = sqlite3_column_int(p->objiter.pSelect, iCol);\n      switch( iVal ){\n        case 0: res = RBU_INSERT;     break;\n        case 1: res = RBU_DELETE;     break;\n        case 2: res = RBU_REPLACE;    break;\n        case 3: res = RBU_IDX_DELETE; break;\n        case 4: res = RBU_IDX_INSERT; break;\n      }\n      break;\n    }\n\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_column_text(p->objiter.pSelect, iCol);\n      if( z==0 ){\n        p->rc = SQLITE_NOMEM;\n      }else{\n        *pzMask = (const char*)z;\n      }\n      res = RBU_UPDATE;\n\n      break;\n    }\n\n    default:\n      break;\n  }\n\n  if( res==0 ){\n    rbuBadControlError(p);\n  }\n  return res;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Assert that column iCol of statement pStmt is named zName.\n*/\nstatic void assertColumnName(sqlite3_stmt *pStmt, int iCol, const char *zName){\n  const char *zCol = sqlite3_column_name(pStmt, iCol);\n  assert( 0==sqlite3_stricmp(zName, zCol) );\n}\n#else\n# define assertColumnName(x,y,z)\n#endif\n\n/*\n** Argument eType must be one of RBU_INSERT, RBU_DELETE, RBU_IDX_INSERT or\n** RBU_IDX_DELETE. This function performs the work of a single\n** sqlite3rbu_step() call for the type of operation specified by eType.\n*/\nstatic void rbuStepOneOp(sqlite3rbu *p, int eType){\n  RbuObjIter *pIter = &p->objiter;\n  sqlite3_value *pVal;\n  sqlite3_stmt *pWriter;\n  int i;\n\n  assert( p->rc==SQLITE_OK );\n  assert( eType!=RBU_DELETE || pIter->zIdx==0 );\n  assert( eType==RBU_DELETE || eType==RBU_IDX_DELETE\n       || eType==RBU_INSERT || eType==RBU_IDX_INSERT\n  );\n\n  /* If this is a delete, decrement nPhaseOneStep by nIndex. If the DELETE\n  ** statement below does actually delete a row, nPhaseOneStep will be\n  ** incremented by the same amount when SQL function rbu_tmp_insert()\n  ** is invoked by the trigger.  */\n  if( eType==RBU_DELETE ){\n    p->nPhaseOneStep -= p->objiter.nIndex;\n  }\n\n  if( eType==RBU_IDX_DELETE || eType==RBU_DELETE ){\n    pWriter = pIter->pDelete;\n  }else{\n    pWriter = pIter->pInsert;\n  }\n\n  for(i=0; i<pIter->nCol; i++){\n    /* If this is an INSERT into a table b-tree and the table has an\n    ** explicit INTEGER PRIMARY KEY, check that this is not an attempt\n    ** to write a NULL into the IPK column. That is not permitted.  */\n    if( eType==RBU_INSERT \n     && pIter->zIdx==0 && pIter->eType==RBU_PK_IPK && pIter->abTblPk[i] \n     && sqlite3_column_type(pIter->pSelect, i)==SQLITE_NULL\n    ){\n      p->rc = SQLITE_MISMATCH;\n      p->zErrmsg = sqlite3_mprintf(\"datatype mismatch\");\n      return;\n    }\n\n    if( eType==RBU_DELETE && pIter->abTblPk[i]==0 ){\n      continue;\n    }\n\n    pVal = sqlite3_column_value(pIter->pSelect, i);\n    p->rc = sqlite3_bind_value(pWriter, i+1, pVal);\n    if( p->rc ) return;\n  }\n  if( pIter->zIdx==0 ){\n    if( pIter->eType==RBU_PK_VTAB \n     || pIter->eType==RBU_PK_NONE \n     || (pIter->eType==RBU_PK_EXTERNAL && rbuIsVacuum(p)) \n    ){\n      /* For a virtual table, or a table with no primary key, the \n      ** SELECT statement is:\n      **\n      **   SELECT <cols>, rbu_control, rbu_rowid FROM ....\n      **\n      ** Hence column_value(pIter->nCol+1).\n      */\n      assertColumnName(pIter->pSelect, pIter->nCol+1, \n          rbuIsVacuum(p) ? \"rowid\" : \"rbu_rowid\"\n      );\n      pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n      p->rc = sqlite3_bind_value(pWriter, pIter->nCol+1, pVal);\n    }\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_step(pWriter);\n    p->rc = resetAndCollectError(pWriter, &p->zErrmsg);\n  }\n}\n\n/*\n** This function does the work for an sqlite3rbu_step() call.\n**\n** The object-iterator (p->objiter) currently points to a valid object,\n** and the input cursor (p->objiter.pSelect) currently points to a valid\n** input row. Perform whatever processing is required and return.\n**\n** If no  error occurs, SQLITE_OK is returned. Otherwise, an error code\n** and message is left in the RBU handle and a copy of the error code\n** returned.\n*/\nstatic int rbuStep(sqlite3rbu *p){\n  RbuObjIter *pIter = &p->objiter;\n  const char *zMask = 0;\n  int eType = rbuStepType(p, &zMask);\n\n  if( eType ){\n    assert( eType==RBU_INSERT     || eType==RBU_DELETE\n         || eType==RBU_REPLACE    || eType==RBU_IDX_DELETE\n         || eType==RBU_IDX_INSERT || eType==RBU_UPDATE\n    );\n    assert( eType!=RBU_UPDATE || pIter->zIdx==0 );\n\n    if( pIter->zIdx==0 && (eType==RBU_IDX_DELETE || eType==RBU_IDX_INSERT) ){\n      rbuBadControlError(p);\n    }\n    else if( eType==RBU_REPLACE ){\n      if( pIter->zIdx==0 ){\n        p->nPhaseOneStep += p->objiter.nIndex;\n        rbuStepOneOp(p, RBU_DELETE);\n      }\n      if( p->rc==SQLITE_OK ) rbuStepOneOp(p, RBU_INSERT);\n    }\n    else if( eType!=RBU_UPDATE ){\n      rbuStepOneOp(p, eType);\n    }\n    else{\n      sqlite3_value *pVal;\n      sqlite3_stmt *pUpdate = 0;\n      assert( eType==RBU_UPDATE );\n      p->nPhaseOneStep -= p->objiter.nIndex;\n      rbuGetUpdateStmt(p, pIter, zMask, &pUpdate);\n      if( pUpdate ){\n        int i;\n        for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){\n          char c = zMask[pIter->aiSrcOrder[i]];\n          pVal = sqlite3_column_value(pIter->pSelect, i);\n          if( pIter->abTblPk[i] || c!='.' ){\n            p->rc = sqlite3_bind_value(pUpdate, i+1, pVal);\n          }\n        }\n        if( p->rc==SQLITE_OK \n         && (pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE) \n        ){\n          /* Bind the rbu_rowid value to column _rowid_ */\n          assertColumnName(pIter->pSelect, pIter->nCol+1, \"rbu_rowid\");\n          pVal = sqlite3_column_value(pIter->pSelect, pIter->nCol+1);\n          p->rc = sqlite3_bind_value(pUpdate, pIter->nCol+1, pVal);\n        }\n        if( p->rc==SQLITE_OK ){\n          sqlite3_step(pUpdate);\n          p->rc = resetAndCollectError(pUpdate, &p->zErrmsg);\n        }\n      }\n    }\n  }\n  return p->rc;\n}\n\n/*\n** Increment the schema cookie of the main database opened by p->dbMain.\n**\n** Or, if this is an RBU vacuum, set the schema cookie of the main db\n** opened by p->dbMain to one more than the schema cookie of the main\n** db opened by p->dbRbu.\n*/\nstatic void rbuIncrSchemaCookie(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3 *dbread = (rbuIsVacuum(p) ? p->dbRbu : p->dbMain);\n    int iCookie = 1000000;\n    sqlite3_stmt *pStmt;\n\n    p->rc = prepareAndCollectError(dbread, &pStmt, &p->zErrmsg, \n        \"PRAGMA schema_version\"\n    );\n    if( p->rc==SQLITE_OK ){\n      /* Coverage: it may be that this sqlite3_step() cannot fail. There\n      ** is already a transaction open, so the prepared statement cannot\n      ** throw an SQLITE_SCHEMA exception. The only database page the\n      ** statement reads is page 1, which is guaranteed to be in the cache.\n      ** And no memory allocations are required.  */\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        iCookie = sqlite3_column_int(pStmt, 0);\n      }\n      rbuFinalize(p, pStmt);\n    }\n    if( p->rc==SQLITE_OK ){\n      rbuMPrintfExec(p, p->dbMain, \"PRAGMA schema_version = %d\", iCookie+1);\n    }\n  }\n}\n\n/*\n** Update the contents of the rbu_state table within the rbu database. The\n** value stored in the RBU_STATE_STAGE column is eStage. All other values\n** are determined by inspecting the rbu handle passed as the first argument.\n*/\nstatic void rbuSaveState(sqlite3rbu *p, int eStage){\n  if( p->rc==SQLITE_OK || p->rc==SQLITE_DONE ){\n    sqlite3_stmt *pInsert = 0;\n    rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n    int rc;\n\n    assert( p->zErrmsg==0 );\n    rc = prepareFreeAndCollectError(p->dbRbu, &pInsert, &p->zErrmsg, \n        sqlite3_mprintf(\n          \"INSERT OR REPLACE INTO %s.rbu_state(k, v) VALUES \"\n          \"(%d, %d), \"\n          \"(%d, %Q), \"\n          \"(%d, %Q), \"\n          \"(%d, %d), \"\n          \"(%d, %d), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld), \"\n          \"(%d, %lld) \",\n          p->zStateDb,\n          RBU_STATE_STAGE, eStage,\n          RBU_STATE_TBL, p->objiter.zTbl, \n          RBU_STATE_IDX, p->objiter.zIdx, \n          RBU_STATE_ROW, p->nStep, \n          RBU_STATE_PROGRESS, p->nProgress,\n          RBU_STATE_CKPT, p->iWalCksum,\n          RBU_STATE_COOKIE, (i64)pFd->iCookie,\n          RBU_STATE_OALSZ, p->iOalSz,\n          RBU_STATE_PHASEONESTEP, p->nPhaseOneStep\n      )\n    );\n    assert( pInsert==0 || rc==SQLITE_OK );\n\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_finalize(pInsert);\n    }\n    if( rc!=SQLITE_OK ) p->rc = rc;\n  }\n}\n\n\n/*\n** The second argument passed to this function is the name of a PRAGMA \n** setting - \"page_size\", \"auto_vacuum\", \"user_version\" or \"application_id\".\n** This function executes the following on sqlite3rbu.dbRbu:\n**\n**   \"PRAGMA main.$zPragma\"\n**\n** where $zPragma is the string passed as the second argument, then\n** on sqlite3rbu.dbMain:\n**\n**   \"PRAGMA main.$zPragma = $val\"\n**\n** where $val is the value returned by the first PRAGMA invocation.\n**\n** In short, it copies the value  of the specified PRAGMA setting from\n** dbRbu to dbMain.\n*/\nstatic void rbuCopyPragma(sqlite3rbu *p, const char *zPragma){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pPragma = 0;\n    p->rc = prepareFreeAndCollectError(p->dbRbu, &pPragma, &p->zErrmsg, \n        sqlite3_mprintf(\"PRAGMA main.%s\", zPragma)\n    );\n    if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPragma) ){\n      p->rc = rbuMPrintfExec(p, p->dbMain, \"PRAGMA main.%s = %d\",\n          zPragma, sqlite3_column_int(pPragma, 0)\n      );\n    }\n    rbuFinalize(p, pPragma);\n  }\n}\n\n/*\n** The RBU handle passed as the only argument has just been opened and \n** the state database is empty. If this RBU handle was opened for an\n** RBU vacuum operation, create the schema in the target db.\n*/\nstatic void rbuCreateTargetSchema(sqlite3rbu *p){\n  sqlite3_stmt *pSql = 0;\n  sqlite3_stmt *pInsert = 0;\n\n  assert( rbuIsVacuum(p) );\n  p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=1\", 0,0, &p->zErrmsg);\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n      \"SELECT sql FROM sqlite_master WHERE sql!='' AND rootpage!=0\"\n      \" AND name!='sqlite_sequence' \"\n      \" ORDER BY type DESC\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    const char *zSql = (const char*)sqlite3_column_text(pSql, 0);\n    p->rc = sqlite3_exec(p->dbMain, zSql, 0, 0, &p->zErrmsg);\n  }\n  rbuFinalize(p, pSql);\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbRbu, &pSql, &p->zErrmsg, \n        \"SELECT * FROM sqlite_master WHERE rootpage=0 OR rootpage IS NULL\" \n    );\n  }\n\n  if( p->rc==SQLITE_OK ){\n    p->rc = prepareAndCollectError(p->dbMain, &pInsert, &p->zErrmsg, \n        \"INSERT INTO sqlite_master VALUES(?,?,?,?,?)\"\n    );\n  }\n\n  while( p->rc==SQLITE_OK && sqlite3_step(pSql)==SQLITE_ROW ){\n    int i;\n    for(i=0; i<5; i++){\n      sqlite3_bind_value(pInsert, i+1, sqlite3_column_value(pSql, i));\n    }\n    sqlite3_step(pInsert);\n    p->rc = sqlite3_reset(pInsert);\n  }\n  if( p->rc==SQLITE_OK ){\n    p->rc = sqlite3_exec(p->dbMain, \"PRAGMA writable_schema=0\",0,0,&p->zErrmsg);\n  }\n\n  rbuFinalize(p, pSql);\n  rbuFinalize(p, pInsert);\n}\n\n/*\n** Step the RBU object.\n*/\nSQLITE_API int sqlite3rbu_step(sqlite3rbu *p){\n  if( p ){\n    switch( p->eStage ){\n      case RBU_STAGE_OAL: {\n        RbuObjIter *pIter = &p->objiter;\n\n        /* If this is an RBU vacuum operation and the state table was empty\n        ** when this handle was opened, create the target database schema. */\n        if( rbuIsVacuum(p) && p->nProgress==0 && p->rc==SQLITE_OK ){\n          rbuCreateTargetSchema(p);\n          rbuCopyPragma(p, \"user_version\");\n          rbuCopyPragma(p, \"application_id\");\n        }\n\n        while( p->rc==SQLITE_OK && pIter->zTbl ){\n\n          if( pIter->bCleanup ){\n            /* Clean up the rbu_tmp_xxx table for the previous table. It \n            ** cannot be dropped as there are currently active SQL statements.\n            ** But the contents can be deleted.  */\n            if( rbuIsVacuum(p)==0 && pIter->abIndexed ){\n              rbuMPrintfExec(p, p->dbRbu, \n                  \"DELETE FROM %s.'rbu_tmp_%q'\", p->zStateDb, pIter->zDataTbl\n              );\n            }\n          }else{\n            rbuObjIterPrepareAll(p, pIter, 0);\n\n            /* Advance to the next row to process. */\n            if( p->rc==SQLITE_OK ){\n              int rc = sqlite3_step(pIter->pSelect);\n              if( rc==SQLITE_ROW ){\n                p->nProgress++;\n                p->nStep++;\n                return rbuStep(p);\n              }\n              p->rc = sqlite3_reset(pIter->pSelect);\n              p->nStep = 0;\n            }\n          }\n\n          rbuObjIterNext(p, pIter);\n        }\n\n        if( p->rc==SQLITE_OK ){\n          assert( pIter->zTbl==0 );\n          rbuSaveState(p, RBU_STAGE_MOVE);\n          rbuIncrSchemaCookie(p);\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n          }\n          p->eStage = RBU_STAGE_MOVE;\n        }\n        break;\n      }\n\n      case RBU_STAGE_MOVE: {\n        if( p->rc==SQLITE_OK ){\n          rbuMoveOalFile(p);\n          p->nProgress++;\n        }\n        break;\n      }\n\n      case RBU_STAGE_CKPT: {\n        if( p->rc==SQLITE_OK ){\n          if( p->nStep>=p->nFrame ){\n            sqlite3_file *pDb = p->pTargetFd->pReal;\n  \n            /* Sync the db file */\n            p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  \n            /* Update nBackfill */\n            if( p->rc==SQLITE_OK ){\n              void volatile *ptr;\n              p->rc = pDb->pMethods->xShmMap(pDb, 0, 32*1024, 0, &ptr);\n              if( p->rc==SQLITE_OK ){\n                ((u32 volatile*)ptr)[24] = p->iMaxFrame;\n              }\n            }\n  \n            if( p->rc==SQLITE_OK ){\n              p->eStage = RBU_STAGE_DONE;\n              p->rc = SQLITE_DONE;\n            }\n          }else{\n            /* At one point the following block copied a single frame from the\n            ** wal file to the database file. So that one call to sqlite3rbu_step()\n            ** checkpointed a single frame. \n            **\n            ** However, if the sector-size is larger than the page-size, and the\n            ** application calls sqlite3rbu_savestate() or close() immediately\n            ** after this step, then rbu_step() again, then a power failure occurs,\n            ** then the database page written here may be damaged. Work around\n            ** this by checkpointing frames until the next page in the aFrame[]\n            ** lies on a different disk sector to the current one. */\n            u32 iSector;\n            do{\n              RbuFrame *pFrame = &p->aFrame[p->nStep];\n              iSector = (pFrame->iDbPage-1) / p->nPagePerSector;\n              rbuCheckpointFrame(p, pFrame);\n              p->nStep++;\n            }while( p->nStep<p->nFrame \n                 && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)\n                 && p->rc==SQLITE_OK\n            );\n          }\n          p->nProgress++;\n        }\n        break;\n      }\n\n      default:\n        break;\n    }\n    return p->rc;\n  }else{\n    return SQLITE_NOMEM;\n  }\n}\n\n/*\n** Compare strings z1 and z2, returning 0 if they are identical, or non-zero\n** otherwise. Either or both argument may be NULL. Two NULL values are\n** considered equal, and NULL is considered distinct from all other values.\n*/\nstatic int rbuStrCompare(const char *z1, const char *z2){\n  if( z1==0 && z2==0 ) return 0;\n  if( z1==0 || z2==0 ) return 1;\n  return (sqlite3_stricmp(z1, z2)!=0);\n}\n\n/*\n** This function is called as part of sqlite3rbu_open() when initializing\n** an rbu handle in OAL stage. If the rbu update has not started (i.e.\n** the rbu_state table was empty) it is a no-op. Otherwise, it arranges\n** things so that the next call to sqlite3rbu_step() continues on from\n** where the previous rbu handle left off.\n**\n** If an error occurs, an error code and error message are left in the\n** rbu handle passed as the first argument.\n*/\nstatic void rbuSetupOal(sqlite3rbu *p, RbuState *pState){\n  assert( p->rc==SQLITE_OK );\n  if( pState->zTbl ){\n    RbuObjIter *pIter = &p->objiter;\n    int rc = SQLITE_OK;\n\n    while( rc==SQLITE_OK && pIter->zTbl && (pIter->bCleanup \n       || rbuStrCompare(pIter->zIdx, pState->zIdx)\n       || rbuStrCompare(pIter->zTbl, pState->zTbl) \n    )){\n      rc = rbuObjIterNext(p, pIter);\n    }\n\n    if( rc==SQLITE_OK && !pIter->zTbl ){\n      rc = SQLITE_ERROR;\n      p->zErrmsg = sqlite3_mprintf(\"rbu_state mismatch error\");\n    }\n\n    if( rc==SQLITE_OK ){\n      p->nStep = pState->nRow;\n      rc = rbuObjIterPrepareAll(p, &p->objiter, p->nStep);\n    }\n\n    p->rc = rc;\n  }\n}\n\n/*\n** If there is a \"*-oal\" file in the file-system corresponding to the\n** target database in the file-system, delete it. If an error occurs,\n** leave an error code and error message in the rbu handle.\n*/\nstatic void rbuDeleteOalFile(sqlite3rbu *p){\n  char *zOal = rbuMPrintf(p, \"%s-oal\", p->zTarget);\n  if( zOal ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n    assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 );\n    pVfs->xDelete(pVfs, zOal, 0);\n    sqlite3_free(zOal);\n  }\n}\n\n/*\n** Allocate a private rbu VFS for the rbu handle passed as the only\n** argument. This VFS will be used unless the call to sqlite3rbu_open()\n** specified a URI with a vfs=? option in place of a target database\n** file name.\n*/\nstatic void rbuCreateVfs(sqlite3rbu *p){\n  int rnd;\n  char zRnd[64];\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3_randomness(sizeof(int), (void*)&rnd);\n  sqlite3_snprintf(sizeof(zRnd), zRnd, \"rbu_vfs_%d\", rnd);\n  p->rc = sqlite3rbu_create_vfs(zRnd, 0);\n  if( p->rc==SQLITE_OK ){\n    sqlite3_vfs *pVfs = sqlite3_vfs_find(zRnd);\n    assert( pVfs );\n    p->zVfsName = pVfs->zName;\n    ((rbu_vfs*)pVfs)->pRbu = p;\n  }\n}\n\n/*\n** Destroy the private VFS created for the rbu handle passed as the only\n** argument by an earlier call to rbuCreateVfs().\n*/\nstatic void rbuDeleteVfs(sqlite3rbu *p){\n  if( p->zVfsName ){\n    sqlite3rbu_destroy_vfs(p->zVfsName);\n    p->zVfsName = 0;\n  }\n}\n\n/*\n** This user-defined SQL function is invoked with a single argument - the\n** name of a table expected to appear in the target database. It returns\n** the number of auxilliary indexes on the table.\n*/\nstatic void rbuIndexCntFunc(\n  sqlite3_context *pCtx, \n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3rbu *p = (sqlite3rbu*)sqlite3_user_data(pCtx);\n  sqlite3_stmt *pStmt = 0;\n  char *zErrmsg = 0;\n  int rc;\n\n  assert( nVal==1 );\n  \n  rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg, \n      sqlite3_mprintf(\"SELECT count(*) FROM sqlite_master \"\n        \"WHERE type='index' AND tbl_name = %Q\", sqlite3_value_text(apVal[0]))\n  );\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error(pCtx, zErrmsg, -1);\n  }else{\n    int nIndex = 0;\n    if( SQLITE_ROW==sqlite3_step(pStmt) ){\n      nIndex = sqlite3_column_int(pStmt, 0);\n    }\n    rc = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_int(pCtx, nIndex);\n    }else{\n      sqlite3_result_error(pCtx, sqlite3_errmsg(p->dbMain), -1);\n    }\n  }\n\n  sqlite3_free(zErrmsg);\n}\n\n/*\n** If the RBU database contains the rbu_count table, use it to initialize\n** the sqlite3rbu.nPhaseOneStep variable. The schema of the rbu_count table\n** is assumed to contain the same columns as:\n**\n**   CREATE TABLE rbu_count(tbl TEXT PRIMARY KEY, cnt INTEGER) WITHOUT ROWID;\n**\n** There should be one row in the table for each data_xxx table in the\n** database. The 'tbl' column should contain the name of a data_xxx table,\n** and the cnt column the number of rows it contains.\n**\n** sqlite3rbu.nPhaseOneStep is initialized to the sum of (1 + nIndex) * cnt\n** for all rows in the rbu_count table, where nIndex is the number of \n** indexes on the corresponding target database table.\n*/\nstatic void rbuInitPhaseOneSteps(sqlite3rbu *p){\n  if( p->rc==SQLITE_OK ){\n    sqlite3_stmt *pStmt = 0;\n    int bExists = 0;                /* True if rbu_count exists */\n\n    p->nPhaseOneStep = -1;\n\n    p->rc = sqlite3_create_function(p->dbRbu, \n        \"rbu_index_cnt\", 1, SQLITE_UTF8, (void*)p, rbuIndexCntFunc, 0, 0\n    );\n  \n    /* Check for the rbu_count table. If it does not exist, or if an error\n    ** occurs, nPhaseOneStep will be left set to -1. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT 1 FROM sqlite_master WHERE tbl_name = 'rbu_count'\"\n      );\n    }\n    if( p->rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pStmt) ){\n        bExists = 1;\n      }\n      p->rc = sqlite3_finalize(pStmt);\n    }\n  \n    if( p->rc==SQLITE_OK && bExists ){\n      p->rc = prepareAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg,\n          \"SELECT sum(cnt * (1 + rbu_index_cnt(rbu_target_name(tbl))))\"\n          \"FROM rbu_count\"\n      );\n      if( p->rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          p->nPhaseOneStep = sqlite3_column_int64(pStmt, 0);\n        }\n        p->rc = sqlite3_finalize(pStmt);\n      }\n    }\n  }\n}\n\n\nstatic sqlite3rbu *openRbuHandle(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  sqlite3rbu *p;\n  size_t nTarget = zTarget ? strlen(zTarget) : 0;\n  size_t nRbu = strlen(zRbu);\n  size_t nByte = sizeof(sqlite3rbu) + nTarget+1 + nRbu+1;\n\n  p = (sqlite3rbu*)sqlite3_malloc64(nByte);\n  if( p ){\n    RbuState *pState = 0;\n\n    /* Create the custom VFS. */\n    memset(p, 0, sizeof(sqlite3rbu));\n    rbuCreateVfs(p);\n\n    /* Open the target, RBU and state databases */\n    if( p->rc==SQLITE_OK ){\n      char *pCsr = (char*)&p[1];\n      int bRetry = 0;\n      if( zTarget ){\n        p->zTarget = pCsr;\n        memcpy(p->zTarget, zTarget, nTarget+1);\n        pCsr += nTarget+1;\n      }\n      p->zRbu = pCsr;\n      memcpy(p->zRbu, zRbu, nRbu+1);\n      pCsr += nRbu+1;\n      if( zState ){\n        p->zState = rbuMPrintf(p, \"%s\", zState);\n      }\n\n      /* If the first attempt to open the database file fails and the bRetry\n      ** flag it set, this means that the db was not opened because it seemed\n      ** to be a wal-mode db. But, this may have happened due to an earlier\n      ** RBU vacuum operation leaving an old wal file in the directory.\n      ** If this is the case, it will have been checkpointed and deleted\n      ** when the handle was closed and a second attempt to open the \n      ** database may succeed.  */\n      rbuOpenDatabase(p, &bRetry);\n      if( bRetry ){\n        rbuOpenDatabase(p, 0);\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      pState = rbuLoadState(p);\n      assert( pState || p->rc!=SQLITE_OK );\n      if( p->rc==SQLITE_OK ){\n\n        if( pState->eStage==0 ){ \n          rbuDeleteOalFile(p);\n          rbuInitPhaseOneSteps(p);\n          p->eStage = RBU_STAGE_OAL;\n        }else{\n          p->eStage = pState->eStage;\n          p->nPhaseOneStep = pState->nPhaseOneStep;\n        }\n        p->nProgress = pState->nProgress;\n        p->iOalSz = pState->iOalSz;\n      }\n    }\n    assert( p->rc!=SQLITE_OK || p->eStage!=0 );\n\n    if( p->rc==SQLITE_OK && p->pTargetFd->pWalFd ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        p->rc = SQLITE_ERROR;\n        p->zErrmsg = sqlite3_mprintf(\"cannot update wal mode database\");\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        p->eStage = RBU_STAGE_CKPT;\n        p->nStep = 0;\n      }\n    }\n\n    if( p->rc==SQLITE_OK \n     && (p->eStage==RBU_STAGE_OAL || p->eStage==RBU_STAGE_MOVE)\n     && pState->eStage!=0\n    ){\n      rbu_file *pFd = (rbuIsVacuum(p) ? p->pRbuFd : p->pTargetFd);\n      if( pFd->iCookie!=pState->iCookie ){   \n        /* At this point (pTargetFd->iCookie) contains the value of the\n        ** change-counter cookie (the thing that gets incremented when a \n        ** transaction is committed in rollback mode) currently stored on \n        ** page 1 of the database file. */\n        p->rc = SQLITE_BUSY;\n        p->zErrmsg = sqlite3_mprintf(\"database modified during rbu %s\",\n            (rbuIsVacuum(p) ? \"vacuum\" : \"update\")\n        );\n      }\n    }\n\n    if( p->rc==SQLITE_OK ){\n      if( p->eStage==RBU_STAGE_OAL ){\n        sqlite3 *db = p->dbMain;\n        p->rc = sqlite3_exec(p->dbRbu, \"BEGIN\", 0, 0, &p->zErrmsg);\n\n        /* Point the object iterator at the first object */\n        if( p->rc==SQLITE_OK ){\n          p->rc = rbuObjIterFirst(p, &p->objiter);\n        }\n\n        /* If the RBU database contains no data_xxx tables, declare the RBU\n        ** update finished.  */\n        if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){\n          p->rc = SQLITE_DONE;\n          p->eStage = RBU_STAGE_DONE;\n        }else{\n          if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){\n            rbuCopyPragma(p, \"page_size\");\n            rbuCopyPragma(p, \"auto_vacuum\");\n          }\n\n          /* Open transactions both databases. The *-oal file is opened or\n          ** created at this point. */\n          if( p->rc==SQLITE_OK ){\n            p->rc = sqlite3_exec(db, \"BEGIN IMMEDIATE\", 0, 0, &p->zErrmsg);\n          }\n\n          /* Check if the main database is a zipvfs db. If it is, set the upper\n          ** level pager to use \"journal_mode=off\". This prevents it from \n          ** generating a large journal using a temp file.  */\n          if( p->rc==SQLITE_OK ){\n            int frc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_ZIPVFS, 0);\n            if( frc==SQLITE_OK ){\n              p->rc = sqlite3_exec(\n                db, \"PRAGMA journal_mode=off\",0,0,&p->zErrmsg);\n            }\n          }\n\n          if( p->rc==SQLITE_OK ){\n            rbuSetupOal(p, pState);\n          }\n        }\n      }else if( p->eStage==RBU_STAGE_MOVE ){\n        /* no-op */\n      }else if( p->eStage==RBU_STAGE_CKPT ){\n        rbuSetupCheckpoint(p, pState);\n      }else if( p->eStage==RBU_STAGE_DONE ){\n        p->rc = SQLITE_DONE;\n      }else{\n        p->rc = SQLITE_CORRUPT;\n      }\n    }\n\n    rbuFreeState(pState);\n  }\n\n  return p;\n}\n\n/*\n** Allocate and return an RBU handle with all fields zeroed except for the\n** error code, which is set to SQLITE_MISUSE.\n*/\nstatic sqlite3rbu *rbuMisuseError(void){\n  sqlite3rbu *pRet;\n  pRet = sqlite3_malloc64(sizeof(sqlite3rbu));\n  if( pRet ){\n    memset(pRet, 0, sizeof(sqlite3rbu));\n    pRet->rc = SQLITE_MISUSE;\n  }\n  return pRet;\n}\n\n/*\n** Open and return a new RBU handle. \n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_open(\n  const char *zTarget, \n  const char *zRbu,\n  const char *zState\n){\n  if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); }\n  /* TODO: Check that zTarget and zRbu are non-NULL */\n  return openRbuHandle(zTarget, zRbu, zState);\n}\n\n/*\n** Open a handle to begin or resume an RBU VACUUM operation.\n*/\nSQLITE_API sqlite3rbu *sqlite3rbu_vacuum(\n  const char *zTarget, \n  const char *zState\n){\n  if( zTarget==0 ){ return rbuMisuseError(); }\n  /* TODO: Check that both arguments are non-NULL */\n  return openRbuHandle(0, zTarget, zState);\n}\n\n/*\n** Return the database handle used by pRbu.\n*/\nSQLITE_API sqlite3 *sqlite3rbu_db(sqlite3rbu *pRbu, int bRbu){\n  sqlite3 *db = 0;\n  if( pRbu ){\n    db = (bRbu ? pRbu->dbRbu : pRbu->dbMain);\n  }\n  return db;\n}\n\n\n/*\n** If the error code currently stored in the RBU handle is SQLITE_CONSTRAINT,\n** then edit any error message string so as to remove all occurrences of\n** the pattern \"rbu_imp_[0-9]*\".\n*/\nstatic void rbuEditErrmsg(sqlite3rbu *p){\n  if( p->rc==SQLITE_CONSTRAINT && p->zErrmsg ){\n    unsigned int i;\n    size_t nErrmsg = strlen(p->zErrmsg);\n    for(i=0; i<(nErrmsg-8); i++){\n      if( memcmp(&p->zErrmsg[i], \"rbu_imp_\", 8)==0 ){\n        int nDel = 8;\n        while( p->zErrmsg[i+nDel]>='0' && p->zErrmsg[i+nDel]<='9' ) nDel++;\n        memmove(&p->zErrmsg[i], &p->zErrmsg[i+nDel], nErrmsg + 1 - i - nDel);\n        nErrmsg -= nDel;\n      }\n    }\n  }\n}\n\n/*\n** Close the RBU handle.\n*/\nSQLITE_API int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){\n  int rc;\n  if( p ){\n\n    /* Commit the transaction to the *-oal file. */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Sync the db file if currently doing an incremental checkpoint */\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n      sqlite3_file *pDb = p->pTargetFd->pReal;\n      p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n    }\n\n    rbuSaveState(p, p->eStage);\n\n    if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){\n      p->rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, &p->zErrmsg);\n    }\n\n    /* Close any open statement handles. */\n    rbuObjIterFinalize(&p->objiter);\n\n    /* If this is an RBU vacuum handle and the vacuum has either finished\n    ** successfully or encountered an error, delete the contents of the \n    ** state table. This causes the next call to sqlite3rbu_vacuum() \n    ** specifying the current target and state databases to start a new\n    ** vacuum from scratch.  */\n    if( rbuIsVacuum(p) && p->rc!=SQLITE_OK && p->dbRbu ){\n      int rc2 = sqlite3_exec(p->dbRbu, \"DELETE FROM stat.rbu_state\", 0, 0, 0);\n      if( p->rc==SQLITE_DONE && rc2!=SQLITE_OK ) p->rc = rc2;\n    }\n\n    /* Close the open database handle and VFS object. */\n    sqlite3_close(p->dbRbu);\n    sqlite3_close(p->dbMain);\n    assert( p->szTemp==0 );\n    rbuDeleteVfs(p);\n    sqlite3_free(p->aBuf);\n    sqlite3_free(p->aFrame);\n\n    rbuEditErrmsg(p);\n    rc = p->rc;\n    if( pzErrmsg ){\n      *pzErrmsg = p->zErrmsg;\n    }else{\n      sqlite3_free(p->zErrmsg);\n    }\n    sqlite3_free(p->zState);\n    sqlite3_free(p);\n  }else{\n    rc = SQLITE_NOMEM;\n    *pzErrmsg = 0;\n  }\n  return rc;\n}\n\n/*\n** Return the total number of key-value operations (inserts, deletes or \n** updates) that have been performed on the target database since the\n** current RBU update was started.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_progress(sqlite3rbu *pRbu){\n  return pRbu->nProgress;\n}\n\n/*\n** Return permyriadage progress indications for the two main stages of\n** an RBU update.\n*/\nSQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *p, int *pnOne, int *pnTwo){\n  const int MAX_PROGRESS = 10000;\n  switch( p->eStage ){\n    case RBU_STAGE_OAL:\n      if( p->nPhaseOneStep>0 ){\n        *pnOne = (int)(MAX_PROGRESS * (i64)p->nProgress/(i64)p->nPhaseOneStep);\n      }else{\n        *pnOne = -1;\n      }\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_MOVE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = 0;\n      break;\n\n    case RBU_STAGE_CKPT:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = (int)(MAX_PROGRESS * (i64)p->nStep / (i64)p->nFrame);\n      break;\n\n    case RBU_STAGE_DONE:\n      *pnOne = MAX_PROGRESS;\n      *pnTwo = MAX_PROGRESS;\n      break;\n\n    default:\n      assert( 0 );\n  }\n}\n\n/*\n** Return the current state of the RBU vacuum or update operation.\n*/\nSQLITE_API int sqlite3rbu_state(sqlite3rbu *p){\n  int aRes[] = {\n    0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE,\n    0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE\n  };\n\n  assert( RBU_STAGE_OAL==1 );\n  assert( RBU_STAGE_MOVE==2 );\n  assert( RBU_STAGE_CKPT==4 );\n  assert( RBU_STAGE_DONE==5 );\n  assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL );\n  assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE );\n  assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT );\n  assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE );\n\n  if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){\n    return SQLITE_RBU_STATE_ERROR;\n  }else{\n    assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE );\n    assert( p->eStage==RBU_STAGE_OAL\n         || p->eStage==RBU_STAGE_MOVE\n         || p->eStage==RBU_STAGE_CKPT\n         || p->eStage==RBU_STAGE_DONE\n    );\n    return aRes[p->eStage];\n  }\n}\n\nSQLITE_API int sqlite3rbu_savestate(sqlite3rbu *p){\n  int rc = p->rc;\n  if( rc==SQLITE_DONE ) return SQLITE_OK;\n\n  assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"COMMIT\", 0, 0, 0);\n  }\n\n  /* Sync the db file */\n  if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){\n    sqlite3_file *pDb = p->pTargetFd->pReal;\n    rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);\n  }\n\n  p->rc = rc;\n  rbuSaveState(p, p->eStage);\n  rc = p->rc;\n\n  if( p->eStage==RBU_STAGE_OAL ){\n    assert( rc!=SQLITE_DONE );\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, \"COMMIT\", 0, 0, 0);\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, \"BEGIN IMMEDIATE\", 0, 0, 0);\n    if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, \"BEGIN IMMEDIATE\", 0, 0,0);\n  }\n\n  p->rc = rc;\n  return rc;\n}\n\n/**************************************************************************\n** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour\n** of a standard VFS in the following ways:\n**\n** 1. Whenever the first page of a main database file is read or \n**    written, the value of the change-counter cookie is stored in\n**    rbu_file.iCookie. Similarly, the value of the \"write-version\"\n**    database header field is stored in rbu_file.iWriteVer. This ensures\n**    that the values are always trustworthy within an open transaction.\n**\n** 2. Whenever an SQLITE_OPEN_WAL file is opened, the (rbu_file.pWalFd)\n**    member variable of the associated database file descriptor is set\n**    to point to the new file. A mutex protected linked list of all main \n**    db fds opened using a particular RBU VFS is maintained at \n**    rbu_vfs.pMain to facilitate this.\n**\n** 3. Using a new file-control \"SQLITE_FCNTL_RBU\", a main db rbu_file \n**    object can be marked as the target database of an RBU update. This\n**    turns on the following extra special behaviour:\n**\n** 3a. If xAccess() is called to check if there exists a *-wal file \n**     associated with an RBU target database currently in RBU_STAGE_OAL\n**     stage (preparing the *-oal file), the following special handling\n**     applies:\n**\n**      * if the *-wal file does exist, return SQLITE_CANTOPEN. An RBU\n**        target database may not be in wal mode already.\n**\n**      * if the *-wal file does not exist, set the output parameter to\n**        non-zero (to tell SQLite that it does exist) anyway.\n**\n**     Then, when xOpen() is called to open the *-wal file associated with\n**     the RBU target in RBU_STAGE_OAL stage, instead of opening the *-wal\n**     file, the rbu vfs opens the corresponding *-oal file instead. \n**\n** 3b. The *-shm pages returned by xShmMap() for a target db file in\n**     RBU_STAGE_OAL mode are actually stored in heap memory. This is to\n**     avoid creating a *-shm file on disk. Additionally, xShmLock() calls\n**     are no-ops on target database files in RBU_STAGE_OAL mode. This is\n**     because assert() statements in some VFS implementations fail if \n**     xShmLock() is called before xShmMap().\n**\n** 3c. If an EXCLUSIVE lock is attempted on a target database file in any\n**     mode except RBU_STAGE_DONE (all work completed and checkpointed), it \n**     fails with an SQLITE_BUSY error. This is to stop RBU connections\n**     from automatically checkpointing a *-wal (or *-oal) file from within\n**     sqlite3_close().\n**\n** 3d. In RBU_STAGE_CAPTURE mode, all xRead() calls on the wal file, and\n**     all xWrite() calls on the target database file perform no IO. \n**     Instead the frame and page numbers that would be read and written\n**     are recorded. Additionally, successful attempts to obtain exclusive\n**     xShmLock() WRITER, CHECKPOINTER and READ0 locks on the target \n**     database file are recorded. xShmLock() calls to unlock the same\n**     locks are no-ops (so that once obtained, these locks are never\n**     relinquished). Finally, calls to xSync() on the target database\n**     file fail with SQLITE_INTERNAL errors.\n*/\n\nstatic void rbuUnlockShm(rbu_file *p){\n  assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n  if( p->pRbu ){\n    int (*xShmLock)(sqlite3_file*,int,int,int) = p->pReal->pMethods->xShmLock;\n    int i;\n    for(i=0; i<SQLITE_SHM_NLOCK;i++){\n      if( (1<<i) & p->pRbu->mLock ){\n        xShmLock(p->pReal, i, 1, SQLITE_SHM_UNLOCK|SQLITE_SHM_EXCLUSIVE);\n      }\n    }\n    p->pRbu->mLock = 0;\n  }\n}\n\n/*\n*/\nstatic int rbuUpdateTempSize(rbu_file *pFd, sqlite3_int64 nNew){\n  sqlite3rbu *pRbu = pFd->pRbu;\n  i64 nDiff = nNew - pFd->sz;\n  pRbu->szTemp += nDiff;\n  pFd->sz = nNew;\n  assert( pRbu->szTemp>=0 );\n  if( pRbu->szTempLimit && pRbu->szTemp>pRbu->szTempLimit ) return SQLITE_FULL;\n  return SQLITE_OK;\n}\n\n/*\n** Close an rbu file.\n*/\nstatic int rbuVfsClose(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc;\n  int i;\n\n  /* Free the contents of the apShm[] array. And the array itself. */\n  for(i=0; i<p->nShm; i++){\n    sqlite3_free(p->apShm[i]);\n  }\n  sqlite3_free(p->apShm);\n  p->apShm = 0;\n  sqlite3_free(p->zDel);\n\n  if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n    rbu_file **pp;\n    sqlite3_mutex_enter(p->pRbuVfs->mutex);\n    for(pp=&p->pRbuVfs->pMain; *pp!=p; pp=&((*pp)->pMainNext));\n    *pp = p->pMainNext;\n    sqlite3_mutex_leave(p->pRbuVfs->mutex);\n    rbuUnlockShm(p);\n    p->pReal->pMethods->xShmUnmap(p->pReal, 0);\n  }\n  else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    rbuUpdateTempSize(p, 0);\n  }\n\n  /* Close the underlying file handle */\n  rc = p->pReal->pMethods->xClose(p->pReal);\n  return rc;\n}\n\n\n/*\n** Read and return an unsigned 32-bit big-endian integer from the buffer \n** passed as the only argument.\n*/\nstatic u32 rbuGetU32(u8 *aBuf){\n  return ((u32)aBuf[0] << 24)\n       + ((u32)aBuf[1] << 16)\n       + ((u32)aBuf[2] <<  8)\n       + ((u32)aBuf[3]);\n}\n\n/*\n** Write an unsigned 32-bit value in big-endian format to the supplied\n** buffer.\n*/\nstatic void rbuPutU32(u8 *aBuf, u32 iVal){\n  aBuf[0] = (iVal >> 24) & 0xFF;\n  aBuf[1] = (iVal >> 16) & 0xFF;\n  aBuf[2] = (iVal >>  8) & 0xFF;\n  aBuf[3] = (iVal >>  0) & 0xFF;\n}\n\nstatic void rbuPutU16(u8 *aBuf, u16 iVal){\n  aBuf[0] = (iVal >>  8) & 0xFF;\n  aBuf[1] = (iVal >>  0) & 0xFF;\n}\n\n/*\n** Read data from an rbuVfs-file.\n*/\nstatic int rbuVfsRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_WAL );\n    rc = rbuCaptureWalRead(p->pRbu, iOfst, iAmt);\n  }else{\n    if( pRbu && pRbu->eStage==RBU_STAGE_OAL \n     && (p->openFlags & SQLITE_OPEN_WAL) \n     && iOfst>=pRbu->iOalSz \n    ){\n      rc = SQLITE_OK;\n      memset(zBuf, 0, iAmt);\n    }else{\n      rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n#if 1\n      /* If this is being called to read the first page of the target \n      ** database as part of an rbu vacuum operation, synthesize the \n      ** contents of the first page if it does not yet exist. Otherwise,\n      ** SQLite will not check for a *-wal file.  */\n      if( pRbu && rbuIsVacuum(pRbu) \n          && rc==SQLITE_IOERR_SHORT_READ && iOfst==0\n          && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n          && pRbu->rc==SQLITE_OK\n      ){\n        sqlite3_file *pFd = (sqlite3_file*)pRbu->pRbuFd;\n        rc = pFd->pMethods->xRead(pFd, zBuf, iAmt, iOfst);\n        if( rc==SQLITE_OK ){\n          u8 *aBuf = (u8*)zBuf;\n          u32 iRoot = rbuGetU32(&aBuf[52]) ? 1 : 0;\n          rbuPutU32(&aBuf[52], iRoot);      /* largest root page number */\n          rbuPutU32(&aBuf[36], 0);          /* number of free pages */\n          rbuPutU32(&aBuf[32], 0);          /* first page on free list trunk */\n          rbuPutU32(&aBuf[28], 1);          /* size of db file in pages */\n          rbuPutU32(&aBuf[24], pRbu->pRbuFd->iCookie+1);  /* Change counter */\n\n          if( iAmt>100 ){\n            memset(&aBuf[100], 0, iAmt-100);\n            rbuPutU16(&aBuf[105], iAmt & 0xFFFF);\n            aBuf[100] = 0x0D;\n          }\n        }\n      }\n#endif\n    }\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n       ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Write data to an rbuVfs-file.\n*/\nstatic int rbuVfsWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc;\n\n  if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){\n    assert( p->openFlags & SQLITE_OPEN_MAIN_DB );\n    rc = rbuCaptureDbWrite(p->pRbu, iOfst);\n  }else{\n    if( pRbu ){\n      if( pRbu->eStage==RBU_STAGE_OAL \n       && (p->openFlags & SQLITE_OPEN_WAL) \n       && iOfst>=pRbu->iOalSz\n      ){\n        pRbu->iOalSz = iAmt + iOfst;\n      }else if( p->openFlags & SQLITE_OPEN_DELETEONCLOSE ){\n        i64 szNew = iAmt+iOfst;\n        if( szNew>p->sz ){\n          rc = rbuUpdateTempSize(p, szNew);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n      }\n    }\n    rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);\n    if( rc==SQLITE_OK && iOfst==0 && (p->openFlags & SQLITE_OPEN_MAIN_DB) ){\n      /* These look like magic numbers. But they are stable, as they are part\n      ** of the definition of the SQLite file format, which may not change. */\n      u8 *pBuf = (u8*)zBuf;\n      p->iCookie = rbuGetU32(&pBuf[24]);\n      p->iWriteVer = pBuf[19];\n    }\n  }\n  return rc;\n}\n\n/*\n** Truncate an rbuVfs-file.\n*/\nstatic int rbuVfsTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  rbu_file *p = (rbu_file*)pFile;\n  if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){\n    int rc = rbuUpdateTempSize(p, size);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  return p->pReal->pMethods->xTruncate(p->pReal, size);\n}\n\n/*\n** Sync an rbuVfs-file.\n*/\nstatic int rbuVfsSync(sqlite3_file *pFile, int flags){\n  rbu_file *p = (rbu_file *)pFile;\n  if( p->pRbu && p->pRbu->eStage==RBU_STAGE_CAPTURE ){\n    if( p->openFlags & SQLITE_OPEN_MAIN_DB ){\n      return SQLITE_INTERNAL;\n    }\n    return SQLITE_OK;\n  }\n  return p->pReal->pMethods->xSync(p->pReal, flags);\n}\n\n/*\n** Return the current file-size of an rbuVfs-file.\n*/\nstatic int rbuVfsFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  rbu_file *p = (rbu_file *)pFile;\n  int rc;\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n\n  /* If this is an RBU vacuum operation and this is the target database,\n  ** pretend that it has at least one page. Otherwise, SQLite will not\n  ** check for the existance of a *-wal file. rbuVfsRead() contains \n  ** similar logic.  */\n  if( rc==SQLITE_OK && *pSize==0 \n   && p->pRbu && rbuIsVacuum(p->pRbu) \n   && (p->openFlags & SQLITE_OPEN_MAIN_DB)\n  ){\n    *pSize = 1024;\n  }\n  return rc;\n}\n\n/*\n** Lock an rbuVfs-file.\n*/\nstatic int rbuVfsLock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eLock==SQLITE_LOCK_EXCLUSIVE \n   && (p->bNolock || (pRbu && pRbu->eStage!=RBU_STAGE_DONE))\n  ){\n    /* Do not allow EXCLUSIVE locks. Preventing SQLite from taking this \n    ** prevents it from checkpointing the database from sqlite3_close(). */\n    rc = SQLITE_BUSY;\n  }else{\n    rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  }\n\n  return rc;\n}\n\n/*\n** Unlock an rbuVfs-file.\n*/\nstatic int rbuVfsUnlock(sqlite3_file *pFile, int eLock){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xUnlock(p->pReal, eLock);\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an rbuVfs-file.\n*/\nstatic int rbuVfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an rbuVfs-file.\n*/\nstatic int rbuVfsFileControl(sqlite3_file *pFile, int op, void *pArg){\n  rbu_file *p = (rbu_file *)pFile;\n  int (*xControl)(sqlite3_file*,int,void*) = p->pReal->pMethods->xFileControl;\n  int rc;\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB)\n       || p->openFlags & (SQLITE_OPEN_TRANSIENT_DB|SQLITE_OPEN_TEMP_JOURNAL)\n  );\n  if( op==SQLITE_FCNTL_RBU ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n\n    /* First try to find another RBU vfs lower down in the vfs stack. If\n    ** one is found, this vfs will operate in pass-through mode. The lower\n    ** level vfs will do the special RBU handling.  */\n    rc = xControl(p->pReal, op, pArg);\n\n    if( rc==SQLITE_NOTFOUND ){\n      /* Now search for a zipvfs instance lower down in the VFS stack. If\n      ** one is found, this is an error.  */\n      void *dummy = 0;\n      rc = xControl(p->pReal, SQLITE_FCNTL_ZIPVFS, &dummy);\n      if( rc==SQLITE_OK ){\n        rc = SQLITE_ERROR;\n        pRbu->zErrmsg = sqlite3_mprintf(\"rbu/zipvfs setup error\");\n      }else if( rc==SQLITE_NOTFOUND ){\n        pRbu->pTargetFd = p;\n        p->pRbu = pRbu;\n        if( p->pWalFd ) p->pWalFd->pRbu = pRbu;\n        rc = SQLITE_OK;\n      }\n    }\n    return rc;\n  }\n  else if( op==SQLITE_FCNTL_RBUCNT ){\n    sqlite3rbu *pRbu = (sqlite3rbu*)pArg;\n    pRbu->nRbu++;\n    pRbu->pRbuFd = p;\n    p->bNolock = 1;\n  }\n\n  rc = xControl(p->pReal, op, pArg);\n  if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){\n    rbu_vfs *pRbuVfs = p->pRbuVfs;\n    char *zIn = *(char**)pArg;\n    char *zOut = sqlite3_mprintf(\"rbu(%s)/%z\", pRbuVfs->base.zName, zIn);\n    *(char**)pArg = zOut;\n    if( zOut==0 ) rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an rbuVfs-file.\n*/\nstatic int rbuVfsSectorSize(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xSectorSize(p->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an rbuVfs-file.\n*/\nstatic int rbuVfsDeviceCharacteristics(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  return p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n}\n\n/*\n** Take or release a shared-memory lock.\n*/\nstatic int rbuVfsShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  rbu_file *p = (rbu_file*)pFile;\n  sqlite3rbu *pRbu = p->pRbu;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_AMALGAMATION\n    assert( WAL_CKPT_LOCK==1 );\n#endif\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( pRbu && (pRbu->eStage==RBU_STAGE_OAL || pRbu->eStage==RBU_STAGE_MOVE) ){\n    /* Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from\n    ** taking this lock also prevents any checkpoints from occurring. \n    ** todo: really, it's not clear why this might occur, as \n    ** wal_autocheckpoint ought to be turned off.  */\n    if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY;\n  }else{\n    int bCapture = 0;\n    if( n==1 && (flags & SQLITE_SHM_EXCLUSIVE)\n     && pRbu && pRbu->eStage==RBU_STAGE_CAPTURE\n     && (ofst==WAL_LOCK_WRITE || ofst==WAL_LOCK_CKPT || ofst==WAL_LOCK_READ0)\n    ){\n      bCapture = 1;\n    }\n\n    if( bCapture==0 || 0==(flags & SQLITE_SHM_UNLOCK) ){\n      rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);\n      if( bCapture && rc==SQLITE_OK ){\n        pRbu->mLock |= (1 << ofst);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Obtain a pointer to a mapping of a single 32KiB page of the *-shm file.\n*/\nstatic int rbuVfsShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  void volatile **pp\n){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  /* If not in RBU_STAGE_OAL, allow this call to pass through. Or, if this\n  ** rbu is in the RBU_STAGE_OAL state, use heap memory for *-shm space \n  ** instead of a file on disk.  */\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    if( iRegion<=p->nShm ){\n      int nByte = (iRegion+1) * sizeof(char*);\n      char **apNew = (char**)sqlite3_realloc64(p->apShm, nByte);\n      if( apNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(&apNew[p->nShm], 0, sizeof(char*) * (1 + iRegion - p->nShm));\n        p->apShm = apNew;\n        p->nShm = iRegion+1;\n      }\n    }\n\n    if( rc==SQLITE_OK && p->apShm[iRegion]==0 ){\n      char *pNew = (char*)sqlite3_malloc64(szRegion);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memset(pNew, 0, szRegion);\n        p->apShm[iRegion] = pNew;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      *pp = p->apShm[iRegion];\n    }else{\n      *pp = 0;\n    }\n  }else{\n    assert( p->apShm==0 );\n    rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n  }\n\n  return rc;\n}\n\n/*\n** Memory barrier.\n*/\nstatic void rbuVfsShmBarrier(sqlite3_file *pFile){\n  rbu_file *p = (rbu_file *)pFile;\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n}\n\n/*\n** The xShmUnmap method.\n*/\nstatic int rbuVfsShmUnmap(sqlite3_file *pFile, int delFlag){\n  rbu_file *p = (rbu_file*)pFile;\n  int rc = SQLITE_OK;\n  int eStage = (p->pRbu ? p->pRbu->eStage : 0);\n\n  assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) );\n  if( eStage==RBU_STAGE_OAL || eStage==RBU_STAGE_MOVE ){\n    /* no-op */\n  }else{\n    /* Release the checkpointer and writer locks */\n    rbuUnlockShm(p);\n    rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);\n  }\n  return rc;\n}\n\n/*\n** Given that zWal points to a buffer containing a wal file name passed to \n** either the xOpen() or xAccess() VFS method, return a pointer to the\n** file-handle opened by the same database connection on the corresponding\n** database file.\n*/\nstatic rbu_file *rbuFindMaindb(rbu_vfs *pRbuVfs, const char *zWal){\n  rbu_file *pDb;\n  sqlite3_mutex_enter(pRbuVfs->mutex);\n  for(pDb=pRbuVfs->pMain; pDb && pDb->zWal!=zWal; pDb=pDb->pMainNext){}\n  sqlite3_mutex_leave(pRbuVfs->mutex);\n  return pDb;\n}\n\n/* \n** A main database named zName has just been opened. The following \n** function returns a pointer to a buffer owned by SQLite that contains\n** the name of the *-wal file this db connection will use. SQLite\n** happens to pass a pointer to this buffer when using xAccess()\n** or xOpen() to operate on the *-wal file.  \n*/\nstatic const char *rbuMainToWal(const char *zName, int flags){\n  int n = (int)strlen(zName);\n  const char *z = &zName[n];\n  if( flags & SQLITE_OPEN_URI ){\n    int odd = 0;\n    while( 1 ){\n      if( z[0]==0 ){\n        odd = 1 - odd;\n        if( odd && z[1]==0 ) break;\n      }\n      z++;\n    }\n    z += 2;\n  }else{\n    while( *z==0 ) z++;\n  }\n  z += (n + 8 + 1);\n  return z;\n}\n\n/*\n** Open an rbu file handle.\n*/\nstatic int rbuVfsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  static sqlite3_io_methods rbuvfs_io_methods = {\n    2,                            /* iVersion */\n    rbuVfsClose,                  /* xClose */\n    rbuVfsRead,                   /* xRead */\n    rbuVfsWrite,                  /* xWrite */\n    rbuVfsTruncate,               /* xTruncate */\n    rbuVfsSync,                   /* xSync */\n    rbuVfsFileSize,               /* xFileSize */\n    rbuVfsLock,                   /* xLock */\n    rbuVfsUnlock,                 /* xUnlock */\n    rbuVfsCheckReservedLock,      /* xCheckReservedLock */\n    rbuVfsFileControl,            /* xFileControl */\n    rbuVfsSectorSize,             /* xSectorSize */\n    rbuVfsDeviceCharacteristics,  /* xDeviceCharacteristics */\n    rbuVfsShmMap,                 /* xShmMap */\n    rbuVfsShmLock,                /* xShmLock */\n    rbuVfsShmBarrier,             /* xShmBarrier */\n    rbuVfsShmUnmap,               /* xShmUnmap */\n    0, 0                          /* xFetch, xUnfetch */\n  };\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  rbu_file *pFd = (rbu_file *)pFile;\n  int rc = SQLITE_OK;\n  const char *zOpen = zName;\n  int oflags = flags;\n\n  memset(pFd, 0, sizeof(rbu_file));\n  pFd->pReal = (sqlite3_file*)&pFd[1];\n  pFd->pRbuVfs = pRbuVfs;\n  pFd->openFlags = flags;\n  if( zName ){\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      /* A main database has just been opened. The following block sets\n      ** (pFd->zWal) to point to a buffer owned by SQLite that contains\n      ** the name of the *-wal file this db connection will use. SQLite\n      ** happens to pass a pointer to this buffer when using xAccess()\n      ** or xOpen() to operate on the *-wal file.  */\n      pFd->zWal = rbuMainToWal(zName, flags);\n    }\n    else if( flags & SQLITE_OPEN_WAL ){\n      rbu_file *pDb = rbuFindMaindb(pRbuVfs, zName);\n      if( pDb ){\n        if( pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n          /* This call is to open a *-wal file. Intead, open the *-oal. This\n          ** code ensures that the string passed to xOpen() is terminated by a\n          ** pair of '\\0' bytes in case the VFS attempts to extract a URI \n          ** parameter from it.  */\n          const char *zBase = zName;\n          size_t nCopy;\n          char *zCopy;\n          if( rbuIsVacuum(pDb->pRbu) ){\n            zBase = sqlite3_db_filename(pDb->pRbu->dbRbu, \"main\");\n            zBase = rbuMainToWal(zBase, SQLITE_OPEN_URI);\n          }\n          nCopy = strlen(zBase);\n          zCopy = sqlite3_malloc64(nCopy+2);\n          if( zCopy ){\n            memcpy(zCopy, zBase, nCopy);\n            zCopy[nCopy-3] = 'o';\n            zCopy[nCopy] = '\\0';\n            zCopy[nCopy+1] = '\\0';\n            zOpen = (const char*)(pFd->zDel = zCopy);\n          }else{\n            rc = SQLITE_NOMEM;\n          }\n          pFd->pRbu = pDb->pRbu;\n        }\n        pDb->pWalFd = pFd;\n      }\n    }\n  }else{\n    pFd->pRbu = pRbuVfs->pRbu;\n  }\n\n  if( oflags & SQLITE_OPEN_MAIN_DB \n   && sqlite3_uri_boolean(zName, \"rbu_memory\", 0) \n  ){\n    assert( oflags & SQLITE_OPEN_MAIN_DB );\n    oflags =  SQLITE_OPEN_TEMP_DB | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n              SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n    zOpen = 0;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pRealVfs->xOpen(pRealVfs, zOpen, pFd->pReal, oflags, pOutFlags);\n  }\n  if( pFd->pReal->pMethods ){\n    /* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods\n    ** pointer and, if the file is a main database file, link it into the\n    ** mutex protected linked list of all such files.  */\n    pFile->pMethods = &rbuvfs_io_methods;\n    if( flags & SQLITE_OPEN_MAIN_DB ){\n      sqlite3_mutex_enter(pRbuVfs->mutex);\n      pFd->pMainNext = pRbuVfs->pMain;\n      pRbuVfs->pMain = pFd;\n      sqlite3_mutex_leave(pRbuVfs->mutex);\n    }\n  }else{\n    sqlite3_free(pFd->zDel);\n  }\n\n  return rc;\n}\n\n/*\n** Delete the file located at zPath.\n*/\nstatic int rbuVfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDelete(pRealVfs, zPath, dirSync);\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int rbuVfsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;\n  sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;\n  int rc;\n\n  rc = pRealVfs->xAccess(pRealVfs, zPath, flags, pResOut);\n\n  /* If this call is to check if a *-wal file associated with an RBU target\n  ** database connection exists, and the RBU update is in RBU_STAGE_OAL,\n  ** the following special handling is activated:\n  **\n  **   a) if the *-wal file does exist, return SQLITE_CANTOPEN. This\n  **      ensures that the RBU extension never tries to update a database\n  **      in wal mode, even if the first page of the database file has\n  **      been damaged. \n  **\n  **   b) if the *-wal file does not exist, claim that it does anyway,\n  **      causing SQLite to call xOpen() to open it. This call will also\n  **      be intercepted (see the rbuVfsOpen() function) and the *-oal\n  **      file opened instead.\n  */\n  if( rc==SQLITE_OK && flags==SQLITE_ACCESS_EXISTS ){\n    rbu_file *pDb = rbuFindMaindb(pRbuVfs, zPath);\n    if( pDb && pDb->pRbu && pDb->pRbu->eStage==RBU_STAGE_OAL ){\n      if( *pResOut ){\n        rc = SQLITE_CANTOPEN;\n      }else{\n        sqlite3_int64 sz = 0;\n        rc = rbuVfsFileSize(&pDb->base, &sz);\n        *pResOut = (sz>0);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int rbuVfsFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xFullPathname(pRealVfs, zPath, nOut, zOut);\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *rbuVfsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlOpen(pRealVfs, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void rbuVfsDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlError(pRealVfs, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*rbuVfsDlSym(\n  sqlite3_vfs *pVfs, \n  void *pArg, \n  const char *zSym\n))(void){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xDlSym(pRealVfs, pArg, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void rbuVfsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  pRealVfs->xDlClose(pRealVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int rbuVfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xRandomness(pRealVfs, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int rbuVfsSleep(sqlite3_vfs *pVfs, int nMicro){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xSleep(pRealVfs, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int rbuVfsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  sqlite3_vfs *pRealVfs = ((rbu_vfs*)pVfs)->pRealVfs;\n  return pRealVfs->xCurrentTime(pRealVfs, pTimeOut);\n}\n\n/*\n** No-op.\n*/\nstatic int rbuVfsGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return 0;\n}\n\n/*\n** Deregister and destroy an RBU vfs created by an earlier call to\n** sqlite3rbu_create_vfs().\n*/\nSQLITE_API void sqlite3rbu_destroy_vfs(const char *zName){\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(zName);\n  if( pVfs && pVfs->xOpen==rbuVfsOpen ){\n    sqlite3_mutex_free(((rbu_vfs*)pVfs)->mutex);\n    sqlite3_vfs_unregister(pVfs);\n    sqlite3_free(pVfs);\n  }\n}\n\n/*\n** Create an RBU VFS named zName that accesses the underlying file-system\n** via existing VFS zParent. The new object is registered as a non-default\n** VFS with SQLite before returning.\n*/\nSQLITE_API int sqlite3rbu_create_vfs(const char *zName, const char *zParent){\n\n  /* Template for VFS */\n  static sqlite3_vfs vfs_template = {\n    1,                            /* iVersion */\n    0,                            /* szOsFile */\n    0,                            /* mxPathname */\n    0,                            /* pNext */\n    0,                            /* zName */\n    0,                            /* pAppData */\n    rbuVfsOpen,                   /* xOpen */\n    rbuVfsDelete,                 /* xDelete */\n    rbuVfsAccess,                 /* xAccess */\n    rbuVfsFullPathname,           /* xFullPathname */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    rbuVfsDlOpen,                 /* xDlOpen */\n    rbuVfsDlError,                /* xDlError */\n    rbuVfsDlSym,                  /* xDlSym */\n    rbuVfsDlClose,                /* xDlClose */\n#else\n    0, 0, 0, 0,\n#endif\n\n    rbuVfsRandomness,             /* xRandomness */\n    rbuVfsSleep,                  /* xSleep */\n    rbuVfsCurrentTime,            /* xCurrentTime */\n    rbuVfsGetLastError,           /* xGetLastError */\n    0,                            /* xCurrentTimeInt64 (version 2) */\n    0, 0, 0                       /* Unimplemented version 3 methods */\n  };\n\n  rbu_vfs *pNew = 0;              /* Newly allocated VFS */\n  int rc = SQLITE_OK;\n  size_t nName;\n  size_t nByte;\n\n  nName = strlen(zName);\n  nByte = sizeof(rbu_vfs) + nName + 1;\n  pNew = (rbu_vfs*)sqlite3_malloc64(nByte);\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_vfs *pParent;           /* Parent VFS */\n    memset(pNew, 0, nByte);\n    pParent = sqlite3_vfs_find(zParent);\n    if( pParent==0 ){\n      rc = SQLITE_NOTFOUND;\n    }else{\n      char *zSpace;\n      memcpy(&pNew->base, &vfs_template, sizeof(sqlite3_vfs));\n      pNew->base.mxPathname = pParent->mxPathname;\n      pNew->base.szOsFile = sizeof(rbu_file) + pParent->szOsFile;\n      pNew->pRealVfs = pParent;\n      pNew->base.zName = (const char*)(zSpace = (char*)&pNew[1]);\n      memcpy(zSpace, zName, nName);\n\n      /* Allocate the mutex and register the new VFS (not as the default) */\n      pNew->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);\n      if( pNew->mutex==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        rc = sqlite3_vfs_register(&pNew->base, 0);\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_mutex_free(pNew->mutex);\n      sqlite3_free(pNew);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Configure the aggregate temp file size limit for this RBU handle.\n*/\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size_limit(sqlite3rbu *pRbu, sqlite3_int64 n){\n  if( n>=0 ){\n    pRbu->szTempLimit = n;\n  }\n  return pRbu->szTempLimit;\n}\n\nSQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){\n  return pRbu->szTemp;\n}\n\n\n/**************************************************************************/\n\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) */\n\n/************** End of sqlite3rbu.c ******************************************/\n/************** Begin file dbstat.c ******************************************/\n/*\n** 2010 July 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"dbstat\" virtual table.\n**\n** The dbstat virtual table is used to extract low-level formatting\n** information from an SQLite database in order to implement the\n** \"sqlite3_analyzer\" utility.  See the ../tool/spaceanal.tcl script\n** for an example implementation.\n**\n** Additional information is available on the \"dbstat.html\" page of the\n** official SQLite documentation.\n*/\n\n/* #include \"sqliteInt.h\"   ** Requires access to internal data structures ** */\n#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\n/*\n** Page paths:\n** \n**   The value of the 'path' column describes the path taken from the \n**   root-node of the b-tree structure to each page. The value of the \n**   root-node path is '/'.\n**\n**   The value of the path for the left-most child page of the root of\n**   a b-tree is '/000/'. (Btrees store content ordered from left to right\n**   so the pages to the left have smaller keys than the pages to the right.)\n**   The next to left-most child of the root page is\n**   '/001', and so on, each sibling page identified by a 3-digit hex \n**   value. The children of the 451st left-most sibling have paths such\n**   as '/1c2/000/, '/1c2/001/' etc.\n**\n**   Overflow pages are specified by appending a '+' character and a \n**   six-digit hexadecimal value to the path to the cell they are linked\n**   from. For example, the three overflow pages in a chain linked from \n**   the left-most cell of the 450th child of the root page are identified\n**   by the paths:\n**\n**      '/1c2/000+000000'         // First page in overflow chain\n**      '/1c2/000+000001'         // Second page in overflow chain\n**      '/1c2/000+000002'         // Third page in overflow chain\n**\n**   If the paths are sorted using the BINARY collation sequence, then\n**   the overflow pages associated with a cell will appear earlier in the\n**   sort-order than its child page:\n**\n**      '/1c2/000/'               // Left-most child of 451st child of root\n*/\n#define VTAB_SCHEMA                                                         \\\n  \"CREATE TABLE xx( \"                                                       \\\n  \"  name       TEXT,             /* Name of table or index */\"             \\\n  \"  path       TEXT,             /* Path to page from root */\"             \\\n  \"  pageno     INTEGER,          /* Page number */\"                        \\\n  \"  pagetype   TEXT,             /* 'internal', 'leaf' or 'overflow' */\"   \\\n  \"  ncell      INTEGER,          /* Cells on page (0 for overflow) */\"     \\\n  \"  payload    INTEGER,          /* Bytes of payload on this page */\"      \\\n  \"  unused     INTEGER,          /* Bytes of unused space on this page */\" \\\n  \"  mx_payload INTEGER,          /* Largest payload size of all cells */\"  \\\n  \"  pgoffset   INTEGER,          /* Offset of page in file */\"             \\\n  \"  pgsize     INTEGER,          /* Size of the page */\"                   \\\n  \"  schema     TEXT HIDDEN       /* Database schema being analyzed */\"     \\\n  \");\"\n\n\ntypedef struct StatTable StatTable;\ntypedef struct StatCursor StatCursor;\ntypedef struct StatPage StatPage;\ntypedef struct StatCell StatCell;\n\nstruct StatCell {\n  int nLocal;                     /* Bytes of local payload */\n  u32 iChildPg;                   /* Child node (or 0 if this is a leaf) */\n  int nOvfl;                      /* Entries in aOvfl[] */\n  u32 *aOvfl;                     /* Array of overflow page numbers */\n  int nLastOvfl;                  /* Bytes of payload on final overflow page */\n  int iOvfl;                      /* Iterates through aOvfl[] */\n};\n\nstruct StatPage {\n  u32 iPgno;\n  DbPage *pPg;\n  int iCell;\n\n  char *zPath;                    /* Path to this page */\n\n  /* Variables populated by statDecodePage(): */\n  u8 flags;                       /* Copy of flags byte */\n  int nCell;                      /* Number of cells on page */\n  int nUnused;                    /* Number of unused bytes on page */\n  StatCell *aCell;                /* Array of parsed cells */\n  u32 iRightChildPg;              /* Right-child page number (or 0) */\n  int nMxPayload;                 /* Largest payload of any cell on this page */\n};\n\nstruct StatCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Iterates through set of root pages */\n  int isEof;                      /* After pStmt has returned SQLITE_DONE */\n  int iDb;                        /* Schema used for this query */\n\n  StatPage aPage[32];\n  int iPage;                      /* Current entry in aPage[] */\n\n  /* Values to return. */\n  char *zName;                    /* Value of 'name' column */\n  char *zPath;                    /* Value of 'path' column */\n  u32 iPageno;                    /* Value of 'pageno' column */\n  char *zPagetype;                /* Value of 'pagetype' column */\n  int nCell;                      /* Value of 'ncell' column */\n  int nPayload;                   /* Value of 'payload' column */\n  int nUnused;                    /* Value of 'unused' column */\n  int nMxPayload;                 /* Value of 'mx_payload' column */\n  i64 iOffset;                    /* Value of 'pgOffset' column */\n  int szPage;                     /* Value of 'pgSize' column */\n};\n\nstruct StatTable {\n  sqlite3_vtab base;\n  sqlite3 *db;\n  int iDb;                        /* Index of database to analyze */\n};\n\n#ifndef get2byte\n# define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#endif\n\n/*\n** Connect to or create a statvfs virtual table.\n*/\nstatic int statConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  StatTable *pTab = 0;\n  int rc = SQLITE_OK;\n  int iDb;\n\n  if( argc>=4 ){\n    Token nm;\n    sqlite3TokenInit(&nm, (char*)argv[3]);\n    iDb = sqlite3FindDb(db, &nm);\n    if( iDb<0 ){\n      *pzErr = sqlite3_mprintf(\"no such database: %s\", argv[3]);\n      return SQLITE_ERROR;\n    }\n  }else{\n    iDb = 0;\n  }\n  rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);\n  if( rc==SQLITE_OK ){\n    pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(StatTable));\n    pTab->db = db;\n    pTab->iDb = iDb;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a statvfs virtual table.\n*/\nstatic int statDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** There is no \"best-index\". This virtual table always does a linear\n** scan.  However, a schema=? constraint should cause this table to\n** operate on a different database schema, so check for it.\n**\n** idxNum is normally 0, but will be 1 if a schema=? constraint exists.\n*/\nstatic int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n\n  pIdxInfo->estimatedCost = 1.0e6;  /* Initial cost estimate */\n\n  /* Look for a valid schema=? constraint.  If found, change the idxNum to\n  ** 1 and request the value of that constraint be sent to xFilter.  And\n  ** lower the cost estimate to encourage the constrained version to be\n  ** used.\n  */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    if( pIdxInfo->aConstraint[i].usable==0 ) continue;\n    if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue;\n    pIdxInfo->idxNum = 1;\n    pIdxInfo->estimatedCost = 1.0;\n    pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[i].omit = 1;\n    break;\n  }\n\n\n  /* Records are always returned in ascending order of (name, path). \n  ** If this will satisfy the client, set the orderByConsumed flag so that \n  ** SQLite does not do an external sort.\n  */\n  if( ( pIdxInfo->nOrderBy==1\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     ) ||\n      ( pIdxInfo->nOrderBy==2\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     && pIdxInfo->aOrderBy[1].iColumn==1\n     && pIdxInfo->aOrderBy[1].desc==0\n     )\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Open a new statvfs cursor.\n*/\nstatic int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  StatTable *pTab = (StatTable *)pVTab;\n  StatCursor *pCsr;\n\n  pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(StatCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->iDb = pTab->iDb;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\nstatic void statClearPage(StatPage *p){\n  int i;\n  if( p->aCell ){\n    for(i=0; i<p->nCell; i++){\n      sqlite3_free(p->aCell[i].aOvfl);\n    }\n    sqlite3_free(p->aCell);\n  }\n  sqlite3PagerUnref(p->pPg);\n  sqlite3_free(p->zPath);\n  memset(p, 0, sizeof(StatPage));\n}\n\nstatic void statResetCsr(StatCursor *pCsr){\n  int i;\n  sqlite3_reset(pCsr->pStmt);\n  for(i=0; i<ArraySize(pCsr->aPage); i++){\n    statClearPage(&pCsr->aPage[i]);\n  }\n  pCsr->iPage = 0;\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n  pCsr->isEof = 0;\n}\n\n/*\n** Close a statvfs cursor.\n*/\nstatic int statClose(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic void getLocalPayload(\n  int nUsable,                    /* Usable bytes per page */\n  u8 flags,                       /* Page flags */\n  int nTotal,                     /* Total record (payload) size */\n  int *pnLocal                    /* OUT: Bytes stored locally */\n){\n  int nLocal;\n  int nMinLocal;\n  int nMaxLocal;\n \n  if( flags==0x0D ){              /* Table leaf node */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = nUsable - 35;\n  }else{                          /* Index interior and leaf nodes */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = (nUsable - 12) * 64 / 255 - 23;\n  }\n\n  nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);\n  if( nLocal>nMaxLocal ) nLocal = nMinLocal;\n  *pnLocal = nLocal;\n}\n\nstatic int statDecodePage(Btree *pBt, StatPage *p){\n  int nUnused;\n  int iOff;\n  int nHdr;\n  int isLeaf;\n  int szPage;\n\n  u8 *aData = sqlite3PagerGetData(p->pPg);\n  u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];\n\n  p->flags = aHdr[0];\n  p->nCell = get2byte(&aHdr[3]);\n  p->nMxPayload = 0;\n\n  isLeaf = (p->flags==0x0A || p->flags==0x0D);\n  nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;\n\n  nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;\n  nUnused += (int)aHdr[7];\n  iOff = get2byte(&aHdr[1]);\n  while( iOff ){\n    nUnused += get2byte(&aData[iOff+2]);\n    iOff = get2byte(&aData[iOff]);\n  }\n  p->nUnused = nUnused;\n  p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);\n  szPage = sqlite3BtreeGetPageSize(pBt);\n\n  if( p->nCell ){\n    int i;                        /* Used to iterate through cells */\n    int nUsable;                  /* Usable bytes per page */\n\n    sqlite3BtreeEnter(pBt);\n    nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);\n    sqlite3BtreeLeave(pBt);\n    p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell));\n    if( p->aCell==0 ) return SQLITE_NOMEM_BKPT;\n    memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));\n\n    for(i=0; i<p->nCell; i++){\n      StatCell *pCell = &p->aCell[i];\n\n      iOff = get2byte(&aData[nHdr+i*2]);\n      if( !isLeaf ){\n        pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);\n        iOff += 4;\n      }\n      if( p->flags==0x05 ){\n        /* A table interior node. nPayload==0. */\n      }else{\n        u32 nPayload;             /* Bytes of payload total (local+overflow) */\n        int nLocal;               /* Bytes of payload stored locally */\n        iOff += getVarint32(&aData[iOff], nPayload);\n        if( p->flags==0x0D ){\n          u64 dummy;\n          iOff += sqlite3GetVarint(&aData[iOff], &dummy);\n        }\n        if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;\n        getLocalPayload(nUsable, p->flags, nPayload, &nLocal);\n        pCell->nLocal = nLocal;\n        assert( nLocal>=0 );\n        assert( nPayload>=(u32)nLocal );\n        assert( nLocal<=(nUsable-35) );\n        if( nPayload>(u32)nLocal ){\n          int j;\n          int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);\n          pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4);\n          pCell->nOvfl = nOvfl;\n          pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl);\n          if( pCell->aOvfl==0 ) return SQLITE_NOMEM_BKPT;\n          pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]);\n          for(j=1; j<nOvfl; j++){\n            int rc;\n            u32 iPrev = pCell->aOvfl[j-1];\n            DbPage *pPg = 0;\n            rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0);\n            if( rc!=SQLITE_OK ){\n              assert( pPg==0 );\n              return rc;\n            } \n            pCell->aOvfl[j] = sqlite3Get4byte(sqlite3PagerGetData(pPg));\n            sqlite3PagerUnref(pPg);\n          }\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on\n** the current value of pCsr->iPageno.\n*/\nstatic void statSizeAndOffset(StatCursor *pCsr){\n  StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;\n  Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n  sqlite3_file *fd;\n  sqlite3_int64 x[2];\n\n  /* The default page size and offset */\n  pCsr->szPage = sqlite3BtreeGetPageSize(pBt);\n  pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);\n\n  /* If connected to a ZIPVFS backend, override the page size and\n  ** offset with actual values obtained from ZIPVFS.\n  */\n  fd = sqlite3PagerFile(pPager);\n  x[0] = pCsr->iPageno;\n  if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){\n    pCsr->iOffset = x[0];\n    pCsr->szPage = (int)x[1];\n  }\n}\n\n/*\n** Move a statvfs cursor to the next entry in the file.\n*/\nstatic int statNext(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  int nPayload;\n  char *z;\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable *)pCursor->pVtab;\n  Btree *pBt = pTab->db->aDb[pCsr->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n\nstatNextRestart:\n  if( pCsr->aPage[0].pPg==0 ){\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      int nPage;\n      u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);\n      sqlite3PagerPagecount(pPager, &nPage);\n      if( nPage==0 ){\n        pCsr->isEof = 1;\n        return sqlite3_reset(pCsr->pStmt);\n      }\n      rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);\n      pCsr->aPage[0].iPgno = iRoot;\n      pCsr->aPage[0].iCell = 0;\n      pCsr->aPage[0].zPath = z = sqlite3_mprintf(\"/\");\n      pCsr->iPage = 0;\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n    }else{\n      pCsr->isEof = 1;\n      return sqlite3_reset(pCsr->pStmt);\n    }\n  }else{\n\n    /* Page p itself has already been visited. */\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n\n    while( p->iCell<p->nCell ){\n      StatCell *pCell = &p->aCell[p->iCell];\n      if( pCell->iOvfl<pCell->nOvfl ){\n        int nUsable;\n        sqlite3BtreeEnter(pBt);\n        nUsable = sqlite3BtreeGetPageSize(pBt) - \n                        sqlite3BtreeGetReserveNoMutex(pBt);\n        sqlite3BtreeLeave(pBt);\n        pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n        pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];\n        pCsr->zPagetype = \"overflow\";\n        pCsr->nCell = 0;\n        pCsr->nMxPayload = 0;\n        pCsr->zPath = z = sqlite3_mprintf(\n            \"%s%.3x+%.6x\", p->zPath, p->iCell, pCell->iOvfl\n        );\n        if( pCell->iOvfl<pCell->nOvfl-1 ){\n          pCsr->nUnused = 0;\n          pCsr->nPayload = nUsable - 4;\n        }else{\n          pCsr->nPayload = pCell->nLastOvfl;\n          pCsr->nUnused = nUsable - 4 - pCsr->nPayload;\n        }\n        pCell->iOvfl++;\n        statSizeAndOffset(pCsr);\n        return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n      }\n      if( p->iRightChildPg ) break;\n      p->iCell++;\n    }\n\n    if( !p->iRightChildPg || p->iCell>p->nCell ){\n      statClearPage(p);\n      if( pCsr->iPage==0 ) return statNext(pCursor);\n      pCsr->iPage--;\n      goto statNextRestart; /* Tail recursion */\n    }\n    pCsr->iPage++;\n    assert( p==&pCsr->aPage[pCsr->iPage-1] );\n\n    if( p->iCell==p->nCell ){\n      p[1].iPgno = p->iRightChildPg;\n    }else{\n      p[1].iPgno = p->aCell[p->iCell].iChildPg;\n    }\n    rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);\n    p[1].iCell = 0;\n    p[1].zPath = z = sqlite3_mprintf(\"%s%.3x/\", p->zPath, p->iCell);\n    p->iCell++;\n    if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n  /* Populate the StatCursor fields with the values to be returned\n  ** by the xColumn() and xRowid() methods.\n  */\n  if( rc==SQLITE_OK ){\n    int i;\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n    pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n    pCsr->iPageno = p->iPgno;\n\n    rc = statDecodePage(pBt, p);\n    if( rc==SQLITE_OK ){\n      statSizeAndOffset(pCsr);\n\n      switch( p->flags ){\n        case 0x05:             /* table internal */\n        case 0x02:             /* index internal */\n          pCsr->zPagetype = \"internal\";\n          break;\n        case 0x0D:             /* table leaf */\n        case 0x0A:             /* index leaf */\n          pCsr->zPagetype = \"leaf\";\n          break;\n        default:\n          pCsr->zPagetype = \"corrupted\";\n          break;\n      }\n      pCsr->nCell = p->nCell;\n      pCsr->nUnused = p->nUnused;\n      pCsr->nMxPayload = p->nMxPayload;\n      pCsr->zPath = z = sqlite3_mprintf(\"%s\", p->zPath);\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n      nPayload = 0;\n      for(i=0; i<p->nCell; i++){\n        nPayload += p->aCell[i].nLocal;\n      }\n      pCsr->nPayload = nPayload;\n    }\n  }\n\n  return rc;\n}\n\nstatic int statEof(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  return pCsr->isEof;\n}\n\nstatic int statFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable*)(pCursor->pVtab);\n  char *zSql;\n  int rc = SQLITE_OK;\n  char *zMaster;\n\n  if( idxNum==1 ){\n    const char *zDbase = (const char*)sqlite3_value_text(argv[0]);\n    pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);\n    if( pCsr->iDb<0 ){\n      sqlite3_free(pCursor->pVtab->zErrMsg);\n      pCursor->pVtab->zErrMsg = sqlite3_mprintf(\"no such schema: %s\", zDbase);\n      return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;\n    }\n  }else{\n    pCsr->iDb = pTab->iDb;\n  }\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  pCsr->pStmt = 0;\n  zMaster = pCsr->iDb==1 ? \"sqlite_temp_master\" : \"sqlite_master\";\n  zSql = sqlite3_mprintf(\n      \"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type\"\n      \"  UNION ALL  \"\n      \"SELECT name, rootpage, type\"\n      \"  FROM \\\"%w\\\".%s WHERE rootpage!=0\"\n      \"  ORDER BY name\", pTab->db->aDb[pCsr->iDb].zDbSName, zMaster);\n  if( zSql==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);\n    sqlite3_free(zSql);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = statNext(pCursor);\n  }\n  return rc;\n}\n\nstatic int statColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  switch( i ){\n    case 0:            /* name */\n      sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:            /* path */\n      sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);\n      break;\n    case 2:            /* pageno */\n      sqlite3_result_int64(ctx, pCsr->iPageno);\n      break;\n    case 3:            /* pagetype */\n      sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);\n      break;\n    case 4:            /* ncell */\n      sqlite3_result_int(ctx, pCsr->nCell);\n      break;\n    case 5:            /* payload */\n      sqlite3_result_int(ctx, pCsr->nPayload);\n      break;\n    case 6:            /* unused */\n      sqlite3_result_int(ctx, pCsr->nUnused);\n      break;\n    case 7:            /* mx_payload */\n      sqlite3_result_int(ctx, pCsr->nMxPayload);\n      break;\n    case 8:            /* pgoffset */\n      sqlite3_result_int64(ctx, pCsr->iOffset);\n      break;\n    case 9:            /* pgsize */\n      sqlite3_result_int(ctx, pCsr->szPage);\n      break;\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      int iDb = pCsr->iDb;\n      sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  *pRowid = pCsr->iPageno;\n  return SQLITE_OK;\n}\n\n/*\n** Invoke this routine to register the \"dbstat\" virtual table module\n*/\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){\n  static sqlite3_module dbstat_module = {\n    0,                            /* iVersion */\n    statConnect,                  /* xCreate */\n    statConnect,                  /* xConnect */\n    statBestIndex,                /* xBestIndex */\n    statDisconnect,               /* xDisconnect */\n    statDisconnect,               /* xDestroy */\n    statOpen,                     /* xOpen - open a cursor */\n    statClose,                    /* xClose - close a cursor */\n    statFilter,                   /* xFilter - configure scan constraints */\n    statNext,                     /* xNext - advance a cursor */\n    statEof,                      /* xEof - check for end of scan */\n    statColumn,                   /* xColumn - read data */\n    statRowid,                    /* xRowid - read data */\n    0,                            /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n  };\n  return sqlite3_create_module(db, \"dbstat\", &dbstat_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBSTAT_VTAB)\nSQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n\n/************** End of dbstat.c **********************************************/\n/************** Begin file dbpage.c ******************************************/\n/*\n** 2017-10-11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"sqlite_dbpage\" virtual table.\n**\n** The sqlite_dbpage virtual table is used to read or write whole raw\n** pages of the database file.  The pager interface is used so that \n** uncommitted changes and changes recorded in the WAL file are correctly\n** retrieved.\n**\n** Usage example:\n**\n**    SELECT data FROM sqlite_dbpage('aux1') WHERE pgno=123;\n**\n** This is an eponymous virtual table so it does not need to be created before\n** use.  The optional argument to the sqlite_dbpage() table name is the\n** schema for the database file that is to be read.  The default schema is\n** \"main\".\n**\n** The data field of sqlite_dbpage table can be updated.  The new\n** value must be a BLOB which is the correct page size, otherwise the\n** update fails.  Rows may not be deleted or inserted.\n*/\n\n/* #include \"sqliteInt.h\"   ** Requires access to internal data structures ** */\n#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\ntypedef struct DbpageTable DbpageTable;\ntypedef struct DbpageCursor DbpageCursor;\n\nstruct DbpageCursor {\n  sqlite3_vtab_cursor base;       /* Base class.  Must be first */\n  int pgno;                       /* Current page number */\n  int mxPgno;                     /* Last page to visit on this scan */\n};\n\nstruct DbpageTable {\n  sqlite3_vtab base;              /* Base class.  Must be first */\n  sqlite3 *db;                    /* The database */\n  Pager *pPager;                  /* Pager being read/written */\n  int iDb;                        /* Index of database to analyze */\n  int szPage;                     /* Size of each page in bytes */\n  int nPage;                      /* Number of pages in the file */\n};\n\n/*\n** Connect to or create a dbpagevfs virtual table.\n*/\nstatic int dbpageConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  DbpageTable *pTab = 0;\n  int rc = SQLITE_OK;\n  int iDb;\n\n  if( argc>=4 ){\n    Token nm;\n    sqlite3TokenInit(&nm, (char*)argv[3]);\n    iDb = sqlite3FindDb(db, &nm);\n    if( iDb<0 ){\n      *pzErr = sqlite3_mprintf(\"no such schema: %s\", argv[3]);\n      return SQLITE_ERROR;\n    }\n  }else{\n    iDb = 0;\n  }\n  rc = sqlite3_declare_vtab(db, \n          \"CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    Btree *pBt = db->aDb[iDb].pBt;\n    memset(pTab, 0, sizeof(DbpageTable));\n    pTab->db = db;\n    pTab->iDb = iDb;\n    pTab->pPager = pBt ? sqlite3BtreePager(pBt) : 0;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a dbpagevfs virtual table.\n*/\nstatic int dbpageDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** idxNum:\n**\n**     0     full table scan\n**     1     pgno=?1\n*/\nstatic int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n  pIdxInfo->estimatedCost = 1.0e6;  /* Initial cost estimate */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];\n    if( p->usable && p->iColumn<=0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      pIdxInfo->estimatedRows = 1;\n      pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n      pIdxInfo->estimatedCost = 1.0;\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      break;\n    }\n  }\n  if( pIdxInfo->nOrderBy>=1\n   && pIdxInfo->aOrderBy[0].iColumn<=0\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Open a new dbpagevfs cursor.\n*/\nstatic int dbpageOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  DbpageCursor *pCsr;\n\n  pCsr = (DbpageCursor *)sqlite3_malloc64(sizeof(DbpageCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(DbpageCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->pgno = -1;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a dbpagevfs cursor.\n*/\nstatic int dbpageClose(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Move a dbpagevfs cursor to the next entry in the file.\n*/\nstatic int dbpageNext(sqlite3_vtab_cursor *pCursor){\n  int rc = SQLITE_OK;\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  pCsr->pgno++;\n  return rc;\n}\n\nstatic int dbpageEof(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  return pCsr->pgno > pCsr->mxPgno;\n}\n\nstatic int dbpageFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;\n\n  pTab->szPage = sqlite3BtreeGetPageSize(pBt);\n  pTab->nPage = sqlite3BtreeLastPage(pBt);\n  if( idxNum==1 ){\n    pCsr->pgno = sqlite3_value_int(argv[0]);\n    if( pCsr->pgno<1 || pCsr->pgno>pTab->nPage ){\n      pCsr->pgno = 1;\n      pCsr->mxPgno = 0;\n    }else{\n      pCsr->mxPgno = pCsr->pgno;\n    }\n  }else{\n    pCsr->pgno = 1;\n    pCsr->mxPgno = pTab->nPage;\n  }\n  return rc;\n}\n\nstatic int dbpageColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  switch( i ){\n    case 0: {           /* pgno */\n      sqlite3_result_int(ctx, pCsr->pgno);\n      break;\n    }\n    case 1: {           /* data */\n      DbPage *pDbPage = 0;\n      rc = sqlite3PagerGet(pTab->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_result_blob(ctx, sqlite3PagerGetData(pDbPage), pTab->szPage,\n                            SQLITE_TRANSIENT);\n      }\n      sqlite3PagerUnref(pDbPage);\n      break;\n    }\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      sqlite3_result_text(ctx, db->aDb[pTab->iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  *pRowid = pCsr->pgno;\n  return SQLITE_OK;\n}\n\nstatic int dbpageUpdate(\n  sqlite3_vtab *pVtab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  DbpageTable *pTab = (DbpageTable *)pVtab;\n  int pgno;\n  DbPage *pDbPage = 0;\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n\n  if( argc==1 ){\n    zErr = \"cannot delete\";\n    goto update_fail;\n  }\n  pgno = sqlite3_value_int(argv[0]);\n  if( pgno<1 || pgno>pTab->nPage ){\n    zErr = \"bad page number\";\n    goto update_fail;\n  }\n  if( sqlite3_value_int(argv[1])!=pgno ){\n    zErr = \"cannot insert\";\n    goto update_fail;\n  }\n  if( sqlite3_value_type(argv[3])!=SQLITE_BLOB \n   || sqlite3_value_bytes(argv[3])!=pTab->szPage \n  ){\n    zErr = \"bad page value\";\n    goto update_fail;\n  }\n  rc = sqlite3PagerGet(pTab->pPager, pgno, (DbPage**)&pDbPage, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      memcpy(sqlite3PagerGetData(pDbPage),\n             sqlite3_value_blob(argv[3]),\n             pTab->szPage);\n    }\n  }\n  sqlite3PagerUnref(pDbPage);\n  return rc;\n\nupdate_fail:\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n  return SQLITE_ERROR;\n}\n\n/*\n** Invoke this routine to register the \"dbpage\" virtual table module\n*/\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){\n  static sqlite3_module dbpage_module = {\n    0,                            /* iVersion */\n    dbpageConnect,                /* xCreate */\n    dbpageConnect,                /* xConnect */\n    dbpageBestIndex,              /* xBestIndex */\n    dbpageDisconnect,             /* xDisconnect */\n    dbpageDisconnect,             /* xDestroy */\n    dbpageOpen,                   /* xOpen - open a cursor */\n    dbpageClose,                  /* xClose - close a cursor */\n    dbpageFilter,                 /* xFilter - configure scan constraints */\n    dbpageNext,                   /* xNext - advance a cursor */\n    dbpageEof,                    /* xEof - check for end of scan */\n    dbpageColumn,                 /* xColumn - read data */\n    dbpageRowid,                  /* xRowid - read data */\n    dbpageUpdate,                 /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n  };\n  return sqlite3_create_module(db, \"sqlite_dbpage\", &dbpage_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBPAGE_VTAB)\nSQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n\n/************** End of dbpage.c **********************************************/\n/************** Begin file sqlite3session.c **********************************/\n\n#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n/* #include \"sqlite3session.h\" */\n/* #include <assert.h> */\n/* #include <string.h> */\n\n#ifndef SQLITE_AMALGAMATION\n/* # include \"sqliteInt.h\" */\n/* # include \"vdbeInt.h\" */\n#endif\n\ntypedef struct SessionTable SessionTable;\ntypedef struct SessionChange SessionChange;\ntypedef struct SessionBuffer SessionBuffer;\ntypedef struct SessionInput SessionInput;\n\n/*\n** Minimum chunk size used by streaming versions of functions.\n*/\n#ifndef SESSIONS_STRM_CHUNK_SIZE\n# ifdef SQLITE_TEST\n#   define SESSIONS_STRM_CHUNK_SIZE 64\n# else\n#   define SESSIONS_STRM_CHUNK_SIZE 1024\n# endif\n#endif\n\ntypedef struct SessionHook SessionHook;\nstruct SessionHook {\n  void *pCtx;\n  int (*xOld)(void*,int,sqlite3_value**);\n  int (*xNew)(void*,int,sqlite3_value**);\n  int (*xCount)(void*);\n  int (*xDepth)(void*);\n};\n\n/*\n** Session handle structure.\n*/\nstruct sqlite3_session {\n  sqlite3 *db;                    /* Database handle session is attached to */\n  char *zDb;                      /* Name of database session is attached to */\n  int bEnable;                    /* True if currently recording */\n  int bIndirect;                  /* True if all changes are indirect */\n  int bAutoAttach;                /* True to auto-attach tables */\n  int rc;                         /* Non-zero if an error has occurred */\n  void *pFilterCtx;               /* First argument to pass to xTableFilter */\n  int (*xTableFilter)(void *pCtx, const char *zTab);\n  sqlite3_session *pNext;         /* Next session object on same db. */\n  SessionTable *pTable;           /* List of attached tables */\n  SessionHook hook;               /* APIs to grab new and old data with */\n};\n\n/*\n** Instances of this structure are used to build strings or binary records.\n*/\nstruct SessionBuffer {\n  u8 *aBuf;                       /* Pointer to changeset buffer */\n  int nBuf;                       /* Size of buffer aBuf */\n  int nAlloc;                     /* Size of allocation containing aBuf */\n};\n\n/*\n** An object of this type is used internally as an abstraction for \n** input data. Input data may be supplied either as a single large buffer\n** (e.g. sqlite3changeset_start()) or using a stream function (e.g.\n**  sqlite3changeset_start_strm()).\n*/\nstruct SessionInput {\n  int bNoDiscard;                 /* If true, discard no data */\n  int iCurrent;                   /* Offset in aData[] of current change */\n  int iNext;                      /* Offset in aData[] of next change */\n  u8 *aData;                      /* Pointer to buffer containing changeset */\n  int nData;                      /* Number of bytes in aData */\n\n  SessionBuffer buf;              /* Current read buffer */\n  int (*xInput)(void*, void*, int*);        /* Input stream call (or NULL) */\n  void *pIn;                                /* First argument to xInput */\n  int bEof;                       /* Set to true after xInput finished */\n};\n\n/*\n** Structure for changeset iterators.\n*/\nstruct sqlite3_changeset_iter {\n  SessionInput in;                /* Input buffer or stream */\n  SessionBuffer tblhdr;           /* Buffer to hold apValue/zTab/abPK/ */\n  int bPatchset;                  /* True if this is a patchset */\n  int rc;                         /* Iterator error code */\n  sqlite3_stmt *pConflict;        /* Points to conflicting row, if any */\n  char *zTab;                     /* Current table */\n  int nCol;                       /* Number of columns in zTab */\n  int op;                         /* Current operation */\n  int bIndirect;                  /* True if current change was indirect */\n  u8 *abPK;                       /* Primary key array */\n  sqlite3_value **apValue;        /* old.* and new.* values */\n};\n\n/*\n** Each session object maintains a set of the following structures, one\n** for each table the session object is monitoring. The structures are\n** stored in a linked list starting at sqlite3_session.pTable.\n**\n** The keys of the SessionTable.aChange[] hash table are all rows that have\n** been modified in any way since the session object was attached to the\n** table.\n**\n** The data associated with each hash-table entry is a structure containing\n** a subset of the initial values that the modified row contained at the\n** start of the session. Or no initial values if the row was inserted.\n*/\nstruct SessionTable {\n  SessionTable *pNext;\n  char *zName;                    /* Local name of table */\n  int nCol;                       /* Number of columns in table zName */\n  const char **azCol;             /* Column names */\n  u8 *abPK;                       /* Array of primary key flags */\n  int nEntry;                     /* Total number of entries in hash table */\n  int nChange;                    /* Size of apChange[] array */\n  SessionChange **apChange;       /* Hash table buckets */\n};\n\n/* \n** RECORD FORMAT:\n**\n** The following record format is similar to (but not compatible with) that \n** used in SQLite database files. This format is used as part of the \n** change-set binary format, and so must be architecture independent.\n**\n** Unlike the SQLite database record format, each field is self-contained -\n** there is no separation of header and data. Each field begins with a\n** single byte describing its type, as follows:\n**\n**       0x00: Undefined value.\n**       0x01: Integer value.\n**       0x02: Real value.\n**       0x03: Text value.\n**       0x04: Blob value.\n**       0x05: SQL NULL value.\n**\n** Note that the above match the definitions of SQLITE_INTEGER, SQLITE_TEXT\n** and so on in sqlite3.h. For undefined and NULL values, the field consists\n** only of the single type byte. For other types of values, the type byte\n** is followed by:\n**\n**   Text values:\n**     A varint containing the number of bytes in the value (encoded using\n**     UTF-8). Followed by a buffer containing the UTF-8 representation\n**     of the text value. There is no nul terminator.\n**\n**   Blob values:\n**     A varint containing the number of bytes in the value, followed by\n**     a buffer containing the value itself.\n**\n**   Integer values:\n**     An 8-byte big-endian integer value.\n**\n**   Real values:\n**     An 8-byte big-endian IEEE 754-2008 real value.\n**\n** Varint values are encoded in the same way as varints in the SQLite \n** record format.\n**\n** CHANGESET FORMAT:\n**\n** A changeset is a collection of DELETE, UPDATE and INSERT operations on\n** one or more tables. Operations on a single table are grouped together,\n** but may occur in any order (i.e. deletes, updates and inserts are all\n** mixed together).\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x54 (capital 'T')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   old.* record: (delete and update only)\n**   new.* record: (insert and update only)\n**\n** The \"old.*\" and \"new.*\" records, if present, are N field records in the\n** format described above under \"RECORD FORMAT\", where N is the number of\n** columns in the table. The i'th field of each record is associated with\n** the i'th column of the table, counting from left to right in the order\n** in which columns were declared in the CREATE TABLE statement.\n**\n** The new.* record that is part of each INSERT change contains the values\n** that make up the new row. Similarly, the old.* record that is part of each\n** DELETE change contains the values that made up the row that was deleted \n** from the database. In the changeset format, the records that are part\n** of INSERT or DELETE changes never contain any undefined (type byte 0x00)\n** fields.\n**\n** Within the old.* record associated with an UPDATE change, all fields\n** associated with table columns that are not PRIMARY KEY columns and are\n** not modified by the UPDATE change are set to \"undefined\". Other fields\n** are set to the values that made up the row before the UPDATE that the\n** change records took place. Within the new.* record, fields associated \n** with table columns modified by the UPDATE change contain the new \n** values. Fields associated with table columns that are not modified\n** are set to \"undefined\".\n**\n** PATCHSET FORMAT:\n**\n** A patchset is also a collection of changes. It is similar to a changeset,\n** but leaves undefined those fields that are not useful if no conflict\n** resolution is required when applying the changeset.\n**\n** Each group of changes begins with a table header:\n**\n**   1 byte: Constant 0x50 (capital 'P')\n**   Varint: Number of columns in the table.\n**   nCol bytes: 0x01 for PK columns, 0x00 otherwise.\n**   N bytes: Unqualified table name (encoded using UTF-8). Nul-terminated.\n**\n** Followed by one or more changes to the table.\n**\n**   1 byte: Either SQLITE_INSERT (0x12), UPDATE (0x17) or DELETE (0x09).\n**   1 byte: The \"indirect-change\" flag.\n**   single record: (PK fields for DELETE, PK and modified fields for UPDATE,\n**                   full record for INSERT).\n**\n** As in the changeset format, each field of the single record that is part\n** of a patchset change is associated with the correspondingly positioned\n** table column, counting from left to right within the CREATE TABLE \n** statement.\n**\n** For a DELETE change, all fields within the record except those associated\n** with PRIMARY KEY columns are set to \"undefined\". The PRIMARY KEY fields\n** contain the values identifying the row to delete.\n**\n** For an UPDATE change, all fields except those associated with PRIMARY KEY\n** columns and columns that are modified by the UPDATE are set to \"undefined\".\n** PRIMARY KEY fields contain the values identifying the table row to update,\n** and fields associated with modified columns contain the new column values.\n**\n** The records associated with INSERT changes are in the same format as for\n** changesets. It is not possible for a record associated with an INSERT\n** change to contain a field set to \"undefined\".\n*/\n\n/*\n** For each row modified during a session, there exists a single instance of\n** this structure stored in a SessionTable.aChange[] hash table.\n*/\nstruct SessionChange {\n  int op;                         /* One of UPDATE, DELETE, INSERT */\n  int bIndirect;                  /* True if this change is \"indirect\" */\n  int nRecord;                    /* Number of bytes in buffer aRecord[] */\n  u8 *aRecord;                    /* Buffer containing old.* record */\n  SessionChange *pNext;           /* For hash-table collisions */\n};\n\n/*\n** Write a varint with value iVal into the buffer at aBuf. Return the \n** number of bytes written.\n*/\nstatic int sessionVarintPut(u8 *aBuf, int iVal){\n  return putVarint32(aBuf, iVal);\n}\n\n/*\n** Return the number of bytes required to store value iVal as a varint.\n*/\nstatic int sessionVarintLen(int iVal){\n  return sqlite3VarintLen(iVal);\n}\n\n/*\n** Read a varint value from aBuf[] into *piVal. Return the number of \n** bytes read.\n*/\nstatic int sessionVarintGet(u8 *aBuf, int *piVal){\n  return getVarint32(aBuf, *piVal);\n}\n\n/* Load an unaligned and unsigned 32-bit integer */\n#define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Read a 64-bit big-endian integer value from buffer aRec[]. Return\n** the value read.\n*/\nstatic sqlite3_int64 sessionGetI64(u8 *aRec){\n  u64 x = SESSION_UINT32(aRec);\n  u32 y = SESSION_UINT32(aRec+4);\n  x = (x<<32) + y;\n  return (sqlite3_int64)x;\n}\n\n/*\n** Write a 64-bit big-endian integer value to the buffer aBuf[].\n*/\nstatic void sessionPutI64(u8 *aBuf, sqlite3_int64 i){\n  aBuf[0] = (i>>56) & 0xFF;\n  aBuf[1] = (i>>48) & 0xFF;\n  aBuf[2] = (i>>40) & 0xFF;\n  aBuf[3] = (i>>32) & 0xFF;\n  aBuf[4] = (i>>24) & 0xFF;\n  aBuf[5] = (i>>16) & 0xFF;\n  aBuf[6] = (i>> 8) & 0xFF;\n  aBuf[7] = (i>> 0) & 0xFF;\n}\n\n/*\n** This function is used to serialize the contents of value pValue (see\n** comment titled \"RECORD FORMAT\" above).\n**\n** If it is non-NULL, the serialized form of the value is written to \n** buffer aBuf. *pnWrite is set to the number of bytes written before\n** returning. Or, if aBuf is NULL, the only thing this function does is\n** set *pnWrite.\n**\n** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs\n** within a call to sqlite3_value_text() (may fail if the db is utf-16)) \n** SQLITE_NOMEM is returned.\n*/\nstatic int sessionSerializeValue(\n  u8 *aBuf,                       /* If non-NULL, write serialized value here */\n  sqlite3_value *pValue,          /* Value to serialize */\n  int *pnWrite                    /* IN/OUT: Increment by bytes written */\n){\n  int nByte;                      /* Size of serialized value in bytes */\n\n  if( pValue ){\n    int eType;                    /* Value type (SQLITE_NULL, TEXT etc.) */\n  \n    eType = sqlite3_value_type(pValue);\n    if( aBuf ) aBuf[0] = eType;\n  \n    switch( eType ){\n      case SQLITE_NULL: \n        nByte = 1;\n        break;\n  \n      case SQLITE_INTEGER: \n      case SQLITE_FLOAT:\n        if( aBuf ){\n          /* TODO: SQLite does something special to deal with mixed-endian\n          ** floating point values (e.g. ARM7). This code probably should\n          ** too.  */\n          u64 i;\n          if( eType==SQLITE_INTEGER ){\n            i = (u64)sqlite3_value_int64(pValue);\n          }else{\n            double r;\n            assert( sizeof(double)==8 && sizeof(u64)==8 );\n            r = sqlite3_value_double(pValue);\n            memcpy(&i, &r, 8);\n          }\n          sessionPutI64(&aBuf[1], i);\n        }\n        nByte = 9; \n        break;\n  \n      default: {\n        u8 *z;\n        int n;\n        int nVarint;\n  \n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        if( eType==SQLITE_TEXT ){\n          z = (u8 *)sqlite3_value_text(pValue);\n        }else{\n          z = (u8 *)sqlite3_value_blob(pValue);\n        }\n        n = sqlite3_value_bytes(pValue);\n        if( z==0 && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        nVarint = sessionVarintLen(n);\n  \n        if( aBuf ){\n          sessionVarintPut(&aBuf[1], n);\n          if( n ) memcpy(&aBuf[nVarint + 1], z, n);\n        }\n  \n        nByte = 1 + nVarint + n;\n        break;\n      }\n    }\n  }else{\n    nByte = 1;\n    if( aBuf ) aBuf[0] = '\\0';\n  }\n\n  if( pnWrite ) *pnWrite += nByte;\n  return SQLITE_OK;\n}\n\n\n/*\n** This macro is used to calculate hash key values for data structures. In\n** order to use this macro, the entire data structure must be represented\n** as a series of unsigned integers. In order to calculate a hash-key value\n** for a data structure represented as three such integers, the macro may\n** then be used as follows:\n**\n**    int hash_key_value;\n**    hash_key_value = HASH_APPEND(0, <value 1>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 2>);\n**    hash_key_value = HASH_APPEND(hash_key_value, <value 3>);\n**\n** In practice, the data structures this macro is used for are the primary\n** key values of modified rows.\n*/\n#define HASH_APPEND(hash, add) ((hash) << 3) ^ (hash) ^ (unsigned int)(add)\n\n/*\n** Append the hash of the 64-bit integer passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendI64(unsigned int h, i64 i){\n  h = HASH_APPEND(h, i & 0xFFFFFFFF);\n  return HASH_APPEND(h, (i>>32)&0xFFFFFFFF);\n}\n\n/*\n** Append the hash of the blob passed via the second and third arguments to \n** the hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendBlob(unsigned int h, int n, const u8 *z){\n  int i;\n  for(i=0; i<n; i++) h = HASH_APPEND(h, z[i]);\n  return h;\n}\n\n/*\n** Append the hash of the data type passed as the second argument to the\n** hash-key value passed as the first. Return the new hash-key value.\n*/\nstatic unsigned int sessionHashAppendType(unsigned int h, int eType){\n  return HASH_APPEND(h, eType);\n}\n\n/*\n** This function may only be called from within a pre-update callback.\n** It calculates a hash based on the primary key values of the old.* or \n** new.* row currently available and, assuming no error occurs, writes it to\n** *piHash before returning. If the primary key contains one or more NULL\n** values, *pbNullPK is set to true before returning.\n**\n** If an error occurs, an SQLite error code is returned and the final values\n** of *piHash asn *pbNullPK are undefined. Otherwise, SQLITE_OK is returned\n** and the output variables are set as described above.\n*/\nstatic int sessionPreupdateHash(\n  sqlite3_session *pSession,      /* Session object that owns pTab */\n  SessionTable *pTab,             /* Session table handle */\n  int bNew,                       /* True to hash the new.* PK */\n  int *piHash,                    /* OUT: Hash value */\n  int *pbNullPK                   /* OUT: True if there are NULL values in PK */\n){\n  unsigned int h = 0;             /* Hash value to return */\n  int i;                          /* Used to iterate through columns */\n\n  assert( *pbNullPK==0 );\n  assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );\n  for(i=0; i<pTab->nCol; i++){\n    if( pTab->abPK[i] ){\n      int rc;\n      int eType;\n      sqlite3_value *pVal;\n\n      if( bNew ){\n        rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);\n      }else{\n        rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);\n      }\n      if( rc!=SQLITE_OK ) return rc;\n\n      eType = sqlite3_value_type(pVal);\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal;\n        if( eType==SQLITE_INTEGER ){\n          iVal = sqlite3_value_int64(pVal);\n        }else{\n          double rVal = sqlite3_value_double(pVal);\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&iVal, &rVal, 8);\n        }\n        h = sessionHashAppendI64(h, iVal);\n      }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        const u8 *z;\n        int n;\n        if( eType==SQLITE_TEXT ){\n          z = (const u8 *)sqlite3_value_text(pVal);\n        }else{\n          z = (const u8 *)sqlite3_value_blob(pVal);\n        }\n        n = sqlite3_value_bytes(pVal);\n        if( !z && (eType!=SQLITE_BLOB || n>0) ) return SQLITE_NOMEM;\n        h = sessionHashAppendBlob(h, n, z);\n      }else{\n        assert( eType==SQLITE_NULL );\n        *pbNullPK = 1;\n      }\n    }\n  }\n\n  *piHash = (h % pTab->nChange);\n  return SQLITE_OK;\n}\n\n/*\n** The buffer that the argument points to contains a serialized SQL value.\n** Return the number of bytes of space occupied by the value (including\n** the type byte).\n*/\nstatic int sessionSerialLen(u8 *a){\n  int e = *a;\n  int n;\n  if( e==0 ) return 1;\n  if( e==SQLITE_NULL ) return 1;\n  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;\n  return sessionVarintGet(&a[1], &n) + 1 + n;\n}\n\n/*\n** Based on the primary key values stored in change aRecord, calculate a\n** hash key. Assume the has table has nBucket buckets. The hash keys\n** calculated by this function are compatible with those calculated by\n** sessionPreupdateHash().\n**\n** The bPkOnly argument is non-zero if the record at aRecord[] is from\n** a patchset DELETE. In this case the non-PK fields are omitted entirely.\n*/\nstatic unsigned int sessionChangeHash(\n  SessionTable *pTab,             /* Table handle */\n  int bPkOnly,                    /* Record consists of PK fields only */\n  u8 *aRecord,                    /* Change record */\n  int nBucket                     /* Assume this many buckets in hash table */\n){\n  unsigned int h = 0;             /* Value to return */\n  int i;                          /* Used to iterate through columns */\n  u8 *a = aRecord;                /* Used to iterate through change record */\n\n  for(i=0; i<pTab->nCol; i++){\n    int eType = *a;\n    int isPK = pTab->abPK[i];\n    if( bPkOnly && isPK==0 ) continue;\n\n    /* It is not possible for eType to be SQLITE_NULL here. The session \n    ** module does not record changes for rows with NULL values stored in\n    ** primary key columns. */\n    assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT \n         || eType==SQLITE_TEXT || eType==SQLITE_BLOB \n         || eType==SQLITE_NULL || eType==0 \n    );\n    assert( !isPK || (eType!=0 && eType!=SQLITE_NULL) );\n\n    if( isPK ){\n      a++;\n      h = sessionHashAppendType(h, eType);\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        h = sessionHashAppendI64(h, sessionGetI64(a));\n        a += 8;\n      }else{\n        int n; \n        a += sessionVarintGet(a, &n);\n        h = sessionHashAppendBlob(h, n, a);\n        a += n;\n      }\n    }else{\n      a += sessionSerialLen(a);\n    }\n  }\n  return (h % nBucket);\n}\n\n/*\n** Arguments aLeft and aRight are pointers to change records for table pTab.\n** This function returns true if the two records apply to the same row (i.e.\n** have the same values stored in the primary key columns), or false \n** otherwise.\n*/\nstatic int sessionChangeEqual(\n  SessionTable *pTab,             /* Table used for PK definition */\n  int bLeftPkOnly,                /* True if aLeft[] contains PK fields only */\n  u8 *aLeft,                      /* Change record */\n  int bRightPkOnly,               /* True if aRight[] contains PK fields only */\n  u8 *aRight                      /* Change record */\n){\n  u8 *a1 = aLeft;                 /* Cursor to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor to iterate through aRight */\n  int iCol;                       /* Used to iterate through table columns */\n\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( pTab->abPK[iCol] ){\n      int n1 = sessionSerialLen(a1);\n      int n2 = sessionSerialLen(a2);\n\n      if( pTab->abPK[iCol] && (n1!=n2 || memcmp(a1, a2, n1)) ){\n        return 0;\n      }\n      a1 += n1;\n      a2 += n2;\n    }else{\n      if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1);\n      if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2);\n    }\n  }\n\n  return 1;\n}\n\n/*\n** Arguments aLeft and aRight both point to buffers containing change\n** records with nCol columns. This function \"merges\" the two records into\n** a single records which is written to the buffer at *paOut. *paOut is\n** then set to point to one byte after the last byte written before \n** returning.\n**\n** The merging of records is done as follows: For each column, if the \n** aRight record contains a value for the column, copy the value from\n** their. Otherwise, if aLeft contains a value, copy it. If neither\n** record contains a value for a given column, then neither does the\n** output record.\n*/\nstatic void sessionMergeRecord(\n  u8 **paOut, \n  int nCol,\n  u8 *aLeft,\n  u8 *aRight\n){\n  u8 *a1 = aLeft;                 /* Cursor used to iterate through aLeft */\n  u8 *a2 = aRight;                /* Cursor used to iterate through aRight */\n  u8 *aOut = *paOut;              /* Output cursor */\n  int iCol;                       /* Used to iterate from 0 to nCol */\n\n  for(iCol=0; iCol<nCol; iCol++){\n    int n1 = sessionSerialLen(a1);\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      memcpy(aOut, a2, n2);\n      aOut += n2;\n    }else{\n      memcpy(aOut, a1, n1);\n      aOut += n1;\n    }\n    a1 += n1;\n    a2 += n2;\n  }\n\n  *paOut = aOut;\n}\n\n/*\n** This is a helper function used by sessionMergeUpdate().\n**\n** When this function is called, both *paOne and *paTwo point to a value \n** within a change record. Before it returns, both have been advanced so \n** as to point to the next value in the record.\n**\n** If, when this function is called, *paTwo points to a valid value (i.e.\n** *paTwo[0] is not 0x00 - the \"no value\" placeholder), a copy of the *paTwo\n** pointer is returned and *pnVal is set to the number of bytes in the \n** serialized value. Otherwise, a copy of *paOne is returned and *pnVal\n** set to the number of bytes in the value at *paOne. If *paOne points\n** to the \"no value\" placeholder, *pnVal is set to 1. In other words:\n**\n**   if( *paTwo is valid ) return *paTwo;\n**   return *paOne;\n**\n*/\nstatic u8 *sessionMergeValue(\n  u8 **paOne,                     /* IN/OUT: Left-hand buffer pointer */\n  u8 **paTwo,                     /* IN/OUT: Right-hand buffer pointer */\n  int *pnVal                      /* OUT: Bytes in returned value */\n){\n  u8 *a1 = *paOne;\n  u8 *a2 = *paTwo;\n  u8 *pRet = 0;\n  int n1;\n\n  assert( a1 );\n  if( a2 ){\n    int n2 = sessionSerialLen(a2);\n    if( *a2 ){\n      *pnVal = n2;\n      pRet = a2;\n    }\n    *paTwo = &a2[n2];\n  }\n\n  n1 = sessionSerialLen(a1);\n  if( pRet==0 ){\n    *pnVal = n1;\n    pRet = a1;\n  }\n  *paOne = &a1[n1];\n\n  return pRet;\n}\n\n/*\n** This function is used by changeset_concat() to merge two UPDATE changes\n** on the same row.\n*/\nstatic int sessionMergeUpdate(\n  u8 **paOut,                     /* IN/OUT: Pointer to output buffer */\n  SessionTable *pTab,             /* Table change pertains to */\n  int bPatchset,                  /* True if records are patchset records */\n  u8 *aOldRecord1,                /* old.* record for first change */\n  u8 *aOldRecord2,                /* old.* record for second change */\n  u8 *aNewRecord1,                /* new.* record for first change */\n  u8 *aNewRecord2                 /* new.* record for second change */\n){\n  u8 *aOld1 = aOldRecord1;\n  u8 *aOld2 = aOldRecord2;\n  u8 *aNew1 = aNewRecord1;\n  u8 *aNew2 = aNewRecord2;\n\n  u8 *aOut = *paOut;\n  int i;\n\n  if( bPatchset==0 ){\n    int bRequired = 0;\n\n    assert( aOldRecord1 && aNewRecord1 );\n\n    /* Write the old.* vector first. */\n    for(i=0; i<pTab->nCol; i++){\n      int nOld;\n      u8 *aOld;\n      int nNew;\n      u8 *aNew;\n\n      aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n      aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n      if( pTab->abPK[i] || nOld!=nNew || memcmp(aOld, aNew, nNew) ){\n        if( pTab->abPK[i]==0 ) bRequired = 1;\n        memcpy(aOut, aOld, nOld);\n        aOut += nOld;\n      }else{\n        *(aOut++) = '\\0';\n      }\n    }\n\n    if( !bRequired ) return 0;\n  }\n\n  /* Write the new.* vector */\n  aOld1 = aOldRecord1;\n  aOld2 = aOldRecord2;\n  aNew1 = aNewRecord1;\n  aNew2 = aNewRecord2;\n  for(i=0; i<pTab->nCol; i++){\n    int nOld;\n    u8 *aOld;\n    int nNew;\n    u8 *aNew;\n\n    aOld = sessionMergeValue(&aOld1, &aOld2, &nOld);\n    aNew = sessionMergeValue(&aNew1, &aNew2, &nNew);\n    if( bPatchset==0 \n     && (pTab->abPK[i] || (nOld==nNew && 0==memcmp(aOld, aNew, nNew))) \n    ){\n      *(aOut++) = '\\0';\n    }else{\n      memcpy(aOut, aNew, nNew);\n      aOut += nNew;\n    }\n  }\n\n  *paOut = aOut;\n  return 1;\n}\n\n/*\n** This function is only called from within a pre-update-hook callback.\n** It determines if the current pre-update-hook change affects the same row\n** as the change stored in argument pChange. If so, it returns true. Otherwise\n** if the pre-update-hook does not affect the same row as pChange, it returns\n** false.\n*/\nstatic int sessionPreupdateEqual(\n  sqlite3_session *pSession,      /* Session object that owns SessionTable */\n  SessionTable *pTab,             /* Table associated with change */\n  SessionChange *pChange,         /* Change to compare to */\n  int op                          /* Current pre-update operation */\n){\n  int iCol;                       /* Used to iterate through columns */\n  u8 *a = pChange->aRecord;       /* Cursor used to scan change record */\n\n  assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );\n  for(iCol=0; iCol<pTab->nCol; iCol++){\n    if( !pTab->abPK[iCol] ){\n      a += sessionSerialLen(a);\n    }else{\n      sqlite3_value *pVal;        /* Value returned by preupdate_new/old */\n      int rc;                     /* Error code from preupdate_new/old */\n      int eType = *a++;           /* Type of value from change record */\n\n      /* The following calls to preupdate_new() and preupdate_old() can not\n      ** fail. This is because they cache their return values, and by the\n      ** time control flows to here they have already been called once from\n      ** within sessionPreupdateHash(). The first two asserts below verify\n      ** this (that the method has already been called). */\n      if( op==SQLITE_INSERT ){\n        /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */\n        rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);\n      }else{\n        /* assert( db->pPreUpdate->pUnpacked ); */\n        rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);\n      }\n      assert( rc==SQLITE_OK );\n      if( sqlite3_value_type(pVal)!=eType ) return 0;\n\n      /* A SessionChange object never has a NULL value in a PK column */\n      assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT\n           || eType==SQLITE_BLOB    || eType==SQLITE_TEXT\n      );\n\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        i64 iVal = sessionGetI64(a);\n        a += 8;\n        if( eType==SQLITE_INTEGER ){\n          if( sqlite3_value_int64(pVal)!=iVal ) return 0;\n        }else{\n          double rVal;\n          assert( sizeof(iVal)==8 && sizeof(rVal)==8 );\n          memcpy(&rVal, &iVal, 8);\n          if( sqlite3_value_double(pVal)!=rVal ) return 0;\n        }\n      }else{\n        int n;\n        const u8 *z;\n        a += sessionVarintGet(a, &n);\n        if( sqlite3_value_bytes(pVal)!=n ) return 0;\n        if( eType==SQLITE_TEXT ){\n          z = sqlite3_value_text(pVal);\n        }else{\n          z = sqlite3_value_blob(pVal);\n        }\n        if( memcmp(a, z, n) ) return 0;\n        a += n;\n        break;\n      }\n    }\n  }\n\n  return 1;\n}\n\n/*\n** If required, grow the hash table used to store changes on table pTab \n** (part of the session pSession). If a fatal OOM error occurs, set the\n** session object to failed and return SQLITE_ERROR. Otherwise, return\n** SQLITE_OK.\n**\n** It is possible that a non-fatal OOM error occurs in this function. In\n** that case the hash-table does not grow, but SQLITE_OK is returned anyway.\n** Growing the hash table in this case is a performance optimization only,\n** it is not required for correct operation.\n*/\nstatic int sessionGrowHash(int bPatchset, SessionTable *pTab){\n  if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){\n    int i;\n    SessionChange **apNew;\n    int nNew = (pTab->nChange ? pTab->nChange : 128) * 2;\n\n    apNew = (SessionChange **)sqlite3_malloc(sizeof(SessionChange *) * nNew);\n    if( apNew==0 ){\n      if( pTab->nChange==0 ){\n        return SQLITE_ERROR;\n      }\n      return SQLITE_OK;\n    }\n    memset(apNew, 0, sizeof(SessionChange *) * nNew);\n\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNext;\n      for(p=pTab->apChange[i]; p; p=pNext){\n        int bPkOnly = (p->op==SQLITE_DELETE && bPatchset);\n        int iHash = sessionChangeHash(pTab, bPkOnly, p->aRecord, nNew);\n        pNext = p->pNext;\n        p->pNext = apNew[iHash];\n        apNew[iHash] = p;\n      }\n    }\n\n    sqlite3_free(pTab->apChange);\n    pTab->nChange = nNew;\n    pTab->apChange = apNew;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This function queries the database for the names of the columns of table\n** zThis, in schema zDb. It is expected that the table has nCol columns. If\n** not, SQLITE_SCHEMA is returned and none of the output variables are\n** populated.\n**\n** Otherwise, if they are not NULL, variable *pnCol is set to the number\n** of columns in the database table and variable *pzTab is set to point to a\n** nul-terminated copy of the table name. *pazCol (if not NULL) is set to\n** point to an array of pointers to column names. And *pabPK (again, if not\n** NULL) is set to point to an array of booleans - true if the corresponding\n** column is part of the primary key.\n**\n** For example, if the table is declared as:\n**\n**     CREATE TABLE tbl1(w, x, y, z, PRIMARY KEY(w, z));\n**\n** Then the four output variables are populated as follows:\n**\n**     *pnCol  = 4\n**     *pzTab  = \"tbl1\"\n**     *pazCol = {\"w\", \"x\", \"y\", \"z\"}\n**     *pabPK  = {1, 0, 0, 1}\n**\n** All returned buffers are part of the same single allocation, which must\n** be freed using sqlite3_free() by the caller. If pazCol was not NULL, then\n** pointer *pazCol should be freed to release all memory. Otherwise, pointer\n** *pabPK. It is illegal for both pazCol and pabPK to be NULL.\n*/\nstatic int sessionTableInfo(\n  sqlite3 *db,                    /* Database connection */\n  const char *zDb,                /* Name of attached database (e.g. \"main\") */\n  const char *zThis,              /* Table name */\n  int *pnCol,                     /* OUT: number of columns */\n  const char **pzTab,             /* OUT: Copy of zThis */\n  const char ***pazCol,           /* OUT: Array of column names for table */\n  u8 **pabPK                      /* OUT: Array of booleans - true for PK col */\n){\n  char *zPragma;\n  sqlite3_stmt *pStmt;\n  int rc;\n  int nByte;\n  int nDbCol = 0;\n  int nThis;\n  int i;\n  u8 *pAlloc = 0;\n  char **azCol = 0;\n  u8 *abPK = 0;\n\n  assert( pazCol && pabPK );\n\n  nThis = sqlite3Strlen30(zThis);\n  zPragma = sqlite3_mprintf(\"PRAGMA '%q'.table_info('%q')\", zDb, zThis);\n  if( !zPragma ) return SQLITE_NOMEM;\n\n  rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);\n  sqlite3_free(zPragma);\n  if( rc!=SQLITE_OK ) return rc;\n\n  nByte = nThis + 1;\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    nByte += sqlite3_column_bytes(pStmt, 1);\n    nDbCol++;\n  }\n  rc = sqlite3_reset(pStmt);\n\n  if( rc==SQLITE_OK ){\n    nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1);\n    pAlloc = sqlite3_malloc(nByte);\n    if( pAlloc==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    azCol = (char **)pAlloc;\n    pAlloc = (u8 *)&azCol[nDbCol];\n    abPK = (u8 *)pAlloc;\n    pAlloc = &abPK[nDbCol];\n    if( pzTab ){\n      memcpy(pAlloc, zThis, nThis+1);\n      *pzTab = (char *)pAlloc;\n      pAlloc += nThis+1;\n    }\n  \n    i = 0;\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      int nName = sqlite3_column_bytes(pStmt, 1);\n      const unsigned char *zName = sqlite3_column_text(pStmt, 1);\n      if( zName==0 ) break;\n      memcpy(pAlloc, zName, nName+1);\n      azCol[i] = (char *)pAlloc;\n      pAlloc += nName+1;\n      abPK[i] = sqlite3_column_int(pStmt, 5);\n      i++;\n    }\n    rc = sqlite3_reset(pStmt);\n  \n  }\n\n  /* If successful, populate the output variables. Otherwise, zero them and\n  ** free any allocation made. An error code will be returned in this case.\n  */\n  if( rc==SQLITE_OK ){\n    *pazCol = (const char **)azCol;\n    *pabPK = abPK;\n    *pnCol = nDbCol;\n  }else{\n    *pazCol = 0;\n    *pabPK = 0;\n    *pnCol = 0;\n    if( pzTab ) *pzTab = 0;\n    sqlite3_free(azCol);\n  }\n  sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** This function is only called from within a pre-update handler for a\n** write to table pTab, part of session pSession. If this is the first\n** write to this table, initalize the SessionTable.nCol, azCol[] and\n** abPK[] arrays accordingly.\n**\n** If an error occurs, an error code is stored in sqlite3_session.rc and\n** non-zero returned. Or, if no error occurs but the table has no primary\n** key, sqlite3_session.rc is left set to SQLITE_OK and non-zero returned to\n** indicate that updates on this table should be ignored. SessionTable.abPK \n** is set to NULL in this case.\n*/\nstatic int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){\n  if( pTab->nCol==0 ){\n    u8 *abPK;\n    assert( pTab->azCol==0 || pTab->abPK==0 );\n    pSession->rc = sessionTableInfo(pSession->db, pSession->zDb, \n        pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK\n    );\n    if( pSession->rc==SQLITE_OK ){\n      int i;\n      for(i=0; i<pTab->nCol; i++){\n        if( abPK[i] ){\n          pTab->abPK = abPK;\n          break;\n        }\n      }\n    }\n  }\n  return (pSession->rc || pTab->abPK==0);\n}\n\n/*\n** This function is only called from with a pre-update-hook reporting a \n** change on table pTab (attached to session pSession). The type of change\n** (UPDATE, INSERT, DELETE) is specified by the first argument.\n**\n** Unless one is already present or an error occurs, an entry is added\n** to the changed-rows hash table associated with table pTab.\n*/\nstatic void sessionPreupdateOneChange(\n  int op,                         /* One of SQLITE_UPDATE, INSERT, DELETE */\n  sqlite3_session *pSession,      /* Session object pTab is attached to */\n  SessionTable *pTab              /* Table that change applies to */\n){\n  int iHash; \n  int bNull = 0; \n  int rc = SQLITE_OK;\n\n  if( pSession->rc ) return;\n\n  /* Load table details if required */\n  if( sessionInitTable(pSession, pTab) ) return;\n\n  /* Check the number of columns in this xPreUpdate call matches the \n  ** number of columns in the table.  */\n  if( pTab->nCol!=pSession->hook.xCount(pSession->hook.pCtx) ){\n    pSession->rc = SQLITE_SCHEMA;\n    return;\n  }\n\n  /* Grow the hash table if required */\n  if( sessionGrowHash(0, pTab) ){\n    pSession->rc = SQLITE_NOMEM;\n    return;\n  }\n\n  /* Calculate the hash-key for this change. If the primary key of the row\n  ** includes a NULL value, exit early. Such changes are ignored by the\n  ** session module. */\n  rc = sessionPreupdateHash(pSession, pTab, op==SQLITE_INSERT, &iHash, &bNull);\n  if( rc!=SQLITE_OK ) goto error_out;\n\n  if( bNull==0 ){\n    /* Search the hash table for an existing record for this row. */\n    SessionChange *pC;\n    for(pC=pTab->apChange[iHash]; pC; pC=pC->pNext){\n      if( sessionPreupdateEqual(pSession, pTab, pC, op) ) break;\n    }\n\n    if( pC==0 ){\n      /* Create a new change object containing all the old values (if\n      ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK\n      ** values (if this is an INSERT). */\n      SessionChange *pChange; /* New change object */\n      int nByte;              /* Number of bytes to allocate */\n      int i;                  /* Used to iterate through columns */\n  \n      assert( rc==SQLITE_OK );\n      pTab->nEntry++;\n  \n      /* Figure out how large an allocation is required */\n      nByte = sizeof(SessionChange);\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          TESTONLY(int trc = ) pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }else if( pTab->abPK[i] ){\n          TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n          assert( trc==SQLITE_OK );\n        }\n\n        /* This may fail if SQLite value p contains a utf-16 string that must\n        ** be converted to utf-8 and an OOM error occurs while doing so. */\n        rc = sessionSerializeValue(0, p, &nByte);\n        if( rc!=SQLITE_OK ) goto error_out;\n      }\n  \n      /* Allocate the change object */\n      pChange = (SessionChange *)sqlite3_malloc(nByte);\n      if( !pChange ){\n        rc = SQLITE_NOMEM;\n        goto error_out;\n      }else{\n        memset(pChange, 0, sizeof(SessionChange));\n        pChange->aRecord = (u8 *)&pChange[1];\n      }\n  \n      /* Populate the change object. None of the preupdate_old(),\n      ** preupdate_new() or SerializeValue() calls below may fail as all\n      ** required values and encodings have already been cached in memory.\n      ** It is not possible for an OOM to occur in this block. */\n      nByte = 0;\n      for(i=0; i<pTab->nCol; i++){\n        sqlite3_value *p = 0;\n        if( op!=SQLITE_INSERT ){\n          pSession->hook.xOld(pSession->hook.pCtx, i, &p);\n        }else if( pTab->abPK[i] ){\n          pSession->hook.xNew(pSession->hook.pCtx, i, &p);\n        }\n        sessionSerializeValue(&pChange->aRecord[nByte], p, &nByte);\n      }\n\n      /* Add the change to the hash-table */\n      if( pSession->bIndirect || pSession->hook.xDepth(pSession->hook.pCtx) ){\n        pChange->bIndirect = 1;\n      }\n      pChange->nRecord = nByte;\n      pChange->op = op;\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n\n    }else if( pC->bIndirect ){\n      /* If the existing change is considered \"indirect\", but this current\n      ** change is \"direct\", mark the change object as direct. */\n      if( pSession->hook.xDepth(pSession->hook.pCtx)==0 \n       && pSession->bIndirect==0 \n      ){\n        pC->bIndirect = 0;\n      }\n    }\n  }\n\n  /* If an error has occurred, mark the session object as failed. */\n error_out:\n  if( rc!=SQLITE_OK ){\n    pSession->rc = rc;\n  }\n}\n\nstatic int sessionFindTable(\n  sqlite3_session *pSession, \n  const char *zName,\n  SessionTable **ppTab\n){\n  int rc = SQLITE_OK;\n  int nName = sqlite3Strlen30(zName);\n  SessionTable *pRet;\n\n  /* Search for an existing table */\n  for(pRet=pSession->pTable; pRet; pRet=pRet->pNext){\n    if( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) ) break;\n  }\n\n  if( pRet==0 && pSession->bAutoAttach ){\n    /* If there is a table-filter configured, invoke it. If it returns 0,\n    ** do not automatically add the new table. */\n    if( pSession->xTableFilter==0\n     || pSession->xTableFilter(pSession->pFilterCtx, zName) \n    ){\n      rc = sqlite3session_attach(pSession, zName);\n      if( rc==SQLITE_OK ){\n        for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);\n        assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );\n      }\n    }\n  }\n\n  assert( rc==SQLITE_OK || pRet==0 );\n  *ppTab = pRet;\n  return rc;\n}\n\n/*\n** The 'pre-update' hook registered by this module with SQLite databases.\n*/\nstatic void xPreUpdate(\n  void *pCtx,                     /* Copy of third arg to preupdate_hook() */\n  sqlite3 *db,                    /* Database handle */\n  int op,                         /* SQLITE_UPDATE, DELETE or INSERT */\n  char const *zDb,                /* Database name */\n  char const *zName,              /* Table name */\n  sqlite3_int64 iKey1,            /* Rowid of row about to be deleted/updated */\n  sqlite3_int64 iKey2             /* New rowid value (for a rowid UPDATE) */\n){\n  sqlite3_session *pSession;\n  int nDb = sqlite3Strlen30(zDb);\n\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(pSession=(sqlite3_session *)pCtx; pSession; pSession=pSession->pNext){\n    SessionTable *pTab;\n\n    /* If this session is attached to a different database (\"main\", \"temp\" \n    ** etc.), or if it is not currently enabled, there is nothing to do. Skip \n    ** to the next session object attached to this database. */\n    if( pSession->bEnable==0 ) continue;\n    if( pSession->rc ) continue;\n    if( sqlite3_strnicmp(zDb, pSession->zDb, nDb+1) ) continue;\n\n    pSession->rc = sessionFindTable(pSession, zName, &pTab);\n    if( pTab ){\n      assert( pSession->rc==SQLITE_OK );\n      sessionPreupdateOneChange(op, pSession, pTab);\n      if( op==SQLITE_UPDATE ){\n        sessionPreupdateOneChange(SQLITE_INSERT, pSession, pTab);\n      }\n    }\n  }\n}\n\n/*\n** The pre-update hook implementations.\n*/\nstatic int sessionPreupdateOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_old((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  return sqlite3_preupdate_new((sqlite3*)pCtx, iVal, ppVal);\n}\nstatic int sessionPreupdateCount(void *pCtx){\n  return sqlite3_preupdate_count((sqlite3*)pCtx);\n}\nstatic int sessionPreupdateDepth(void *pCtx){\n  return sqlite3_preupdate_depth((sqlite3*)pCtx);\n}\n\n/*\n** Install the pre-update hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionPreupdateHooks(\n  sqlite3_session *pSession\n){\n  pSession->hook.pCtx = (void*)pSession->db;\n  pSession->hook.xOld = sessionPreupdateOld;\n  pSession->hook.xNew = sessionPreupdateNew;\n  pSession->hook.xCount = sessionPreupdateCount;\n  pSession->hook.xDepth = sessionPreupdateDepth;\n}\n\ntypedef struct SessionDiffCtx SessionDiffCtx;\nstruct SessionDiffCtx {\n  sqlite3_stmt *pStmt;\n  int nOldOff;\n};\n\n/*\n** The diff hook implementations.\n*/\nstatic int sessionDiffOld(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal+p->nOldOff);\n  return SQLITE_OK;\n}\nstatic int sessionDiffNew(void *pCtx, int iVal, sqlite3_value **ppVal){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  *ppVal = sqlite3_column_value(p->pStmt, iVal);\n   return SQLITE_OK;\n}\nstatic int sessionDiffCount(void *pCtx){\n  SessionDiffCtx *p = (SessionDiffCtx*)pCtx;\n  return p->nOldOff ? p->nOldOff : sqlite3_column_count(p->pStmt);\n}\nstatic int sessionDiffDepth(void *pCtx){\n  return 0;\n}\n\n/*\n** Install the diff hooks on the session object passed as the only\n** argument.\n*/\nstatic void sessionDiffHooks(\n  sqlite3_session *pSession,\n  SessionDiffCtx *pDiffCtx\n){\n  pSession->hook.pCtx = (void*)pDiffCtx;\n  pSession->hook.xOld = sessionDiffOld;\n  pSession->hook.xNew = sessionDiffNew;\n  pSession->hook.xCount = sessionDiffCount;\n  pSession->hook.xDepth = sessionDiffDepth;\n}\n\nstatic char *sessionExprComparePK(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i] ){\n      zRet = sqlite3_mprintf(\"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"=\\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" AND \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *sessionExprCompareOther(\n  int nCol,\n  const char *zDb1, const char *zDb2, \n  const char *zTab,\n  const char **azCol, u8 *abPK\n){\n  int i;\n  const char *zSep = \"\";\n  char *zRet = 0;\n  int bHave = 0;\n\n  for(i=0; i<nCol; i++){\n    if( abPK[i]==0 ){\n      bHave = 1;\n      zRet = sqlite3_mprintf(\n          \"%z%s\\\"%w\\\".\\\"%w\\\".\\\"%w\\\" IS NOT \\\"%w\\\".\\\"%w\\\".\\\"%w\\\"\",\n          zRet, zSep, zDb1, zTab, azCol[i], zDb2, zTab, azCol[i]\n      );\n      zSep = \" OR \";\n      if( zRet==0 ) break;\n    }\n  }\n\n  if( bHave==0 ){\n    assert( zRet==0 );\n    zRet = sqlite3_mprintf(\"0\");\n  }\n\n  return zRet;\n}\n\nstatic char *sessionSelectFindNew(\n  int nCol,\n  const char *zDb1,      /* Pick rows in this db only */\n  const char *zDb2,      /* But not in this one */\n  const char *zTbl,      /* Table name */\n  const char *zExpr\n){\n  char *zRet = sqlite3_mprintf(\n      \"SELECT * FROM \\\"%w\\\".\\\"%w\\\" WHERE NOT EXISTS (\"\n      \"  SELECT 1 FROM \\\"%w\\\".\\\"%w\\\" WHERE %s\"\n      \")\",\n      zDb1, zTbl, zDb2, zTbl, zExpr\n  );\n  return zRet;\n}\n\nstatic int sessionDiffFindNew(\n  int op,\n  sqlite3_session *pSession,\n  SessionTable *pTab,\n  const char *zDb1,\n  const char *zDb2,\n  char *zExpr\n){\n  int rc = SQLITE_OK;\n  char *zStmt = sessionSelectFindNew(pTab->nCol, zDb1, zDb2, pTab->zName,zExpr);\n\n  if( zStmt==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pStmt;\n    rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n      pDiffCtx->pStmt = pStmt;\n      pDiffCtx->nOldOff = 0;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        sessionPreupdateOneChange(op, pSession, pTab);\n      }\n      rc = sqlite3_finalize(pStmt);\n    }\n    sqlite3_free(zStmt);\n  }\n\n  return rc;\n}\n\nstatic int sessionDiffFindModified(\n  sqlite3_session *pSession, \n  SessionTable *pTab, \n  const char *zFrom, \n  const char *zExpr\n){\n  int rc = SQLITE_OK;\n\n  char *zExpr2 = sessionExprCompareOther(pTab->nCol,\n      pSession->zDb, zFrom, pTab->zName, pTab->azCol, pTab->abPK\n  );\n  if( zExpr2==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    char *zStmt = sqlite3_mprintf(\n        \"SELECT * FROM \\\"%w\\\".\\\"%w\\\", \\\"%w\\\".\\\"%w\\\" WHERE %s AND (%z)\",\n        pSession->zDb, pTab->zName, zFrom, pTab->zName, zExpr, zExpr2\n    );\n    if( zStmt==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_stmt *pStmt;\n      rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);\n\n      if( rc==SQLITE_OK ){\n        SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;\n        pDiffCtx->pStmt = pStmt;\n        pDiffCtx->nOldOff = pTab->nCol;\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){\n          sessionPreupdateOneChange(SQLITE_UPDATE, pSession, pTab);\n        }\n        rc = sqlite3_finalize(pStmt);\n      }\n      sqlite3_free(zStmt);\n    }\n  }\n\n  return rc;\n}\n\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFrom,\n  const char *zTbl,\n  char **pzErrMsg\n){\n  const char *zDb = pSession->zDb;\n  int rc = pSession->rc;\n  SessionDiffCtx d;\n\n  memset(&d, 0, sizeof(d));\n  sessionDiffHooks(pSession, &d);\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( pzErrMsg ) *pzErrMsg = 0;\n  if( rc==SQLITE_OK ){\n    char *zExpr = 0;\n    sqlite3 *db = pSession->db;\n    SessionTable *pTo;            /* Table zTbl */\n\n    /* Locate and if necessary initialize the target table object */\n    rc = sessionFindTable(pSession, zTbl, &pTo);\n    if( pTo==0 ) goto diff_out;\n    if( sessionInitTable(pSession, pTo) ){\n      rc = pSession->rc;\n      goto diff_out;\n    }\n\n    /* Check the table schemas match */\n    if( rc==SQLITE_OK ){\n      int bHasPk = 0;\n      int bMismatch = 0;\n      int nCol;                   /* Columns in zFrom.zTbl */\n      u8 *abPK;\n      const char **azCol = 0;\n      rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK);\n      if( rc==SQLITE_OK ){\n        if( pTo->nCol!=nCol ){\n          bMismatch = 1;\n        }else{\n          int i;\n          for(i=0; i<nCol; i++){\n            if( pTo->abPK[i]!=abPK[i] ) bMismatch = 1;\n            if( sqlite3_stricmp(azCol[i], pTo->azCol[i]) ) bMismatch = 1;\n            if( abPK[i] ) bHasPk = 1;\n          }\n        }\n\n      }\n      sqlite3_free((char*)azCol);\n      if( bMismatch ){\n        *pzErrMsg = sqlite3_mprintf(\"table schemas do not match\");\n        rc = SQLITE_SCHEMA;\n      }\n      if( bHasPk==0 ){\n        /* Ignore tables with no primary keys */\n        goto diff_out;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      zExpr = sessionExprComparePK(pTo->nCol, \n          zDb, zFrom, pTo->zName, pTo->azCol, pTo->abPK\n      );\n    }\n\n    /* Find new rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_INSERT, pSession, pTo, zDb, zFrom, zExpr);\n    }\n\n    /* Find old rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindNew(SQLITE_DELETE, pSession, pTo, zFrom, zDb, zExpr);\n    }\n\n    /* Find modified rows */\n    if( rc==SQLITE_OK ){\n      rc = sessionDiffFindModified(pSession, pTo, zFrom, zExpr);\n    }\n\n    sqlite3_free(zExpr);\n  }\n\n diff_out:\n  sessionPreupdateHooks(pSession);\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Create a session object. This session object will record changes to\n** database zDb attached to connection db.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n){\n  sqlite3_session *pNew;          /* Newly allocated session object */\n  sqlite3_session *pOld;          /* Session object already attached to db */\n  int nDb = sqlite3Strlen30(zDb); /* Length of zDb in bytes */\n\n  /* Zero the output value in case an error occurs. */\n  *ppSession = 0;\n\n  /* Allocate and populate the new session object. */\n  pNew = (sqlite3_session *)sqlite3_malloc(sizeof(sqlite3_session) + nDb + 1);\n  if( !pNew ) return SQLITE_NOMEM;\n  memset(pNew, 0, sizeof(sqlite3_session));\n  pNew->db = db;\n  pNew->zDb = (char *)&pNew[1];\n  pNew->bEnable = 1;\n  memcpy(pNew->zDb, zDb, nDb+1);\n  sessionPreupdateHooks(pNew);\n\n  /* Add the new session object to the linked list of session objects \n  ** attached to database handle $db. Do this under the cover of the db\n  ** handle mutex.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pOld = (sqlite3_session*)sqlite3_preupdate_hook(db, xPreUpdate, (void*)pNew);\n  pNew->pNext = pOld;\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n\n  *ppSession = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of table objects passed as the first argument. The contents\n** of the changed-rows hash tables are also deleted.\n*/\nstatic void sessionDeleteTable(SessionTable *pList){\n  SessionTable *pNext;\n  SessionTable *pTab;\n\n  for(pTab=pList; pTab; pTab=pNext){\n    int i;\n    pNext = pTab->pNext;\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      SessionChange *pNextChange;\n      for(p=pTab->apChange[i]; p; p=pNextChange){\n        pNextChange = p->pNext;\n        sqlite3_free(p);\n      }\n    }\n    sqlite3_free((char*)pTab->azCol);  /* cast works around VC++ bug */\n    sqlite3_free(pTab->apChange);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** Delete a session object previously allocated using sqlite3session_create().\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession){\n  sqlite3 *db = pSession->db;\n  sqlite3_session *pHead;\n  sqlite3_session **pp;\n\n  /* Unlink the session from the linked list of sessions attached to the\n  ** database handle. Hold the db mutex while doing so.  */\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  pHead = (sqlite3_session*)sqlite3_preupdate_hook(db, 0, 0);\n  for(pp=&pHead; ALWAYS((*pp)!=0); pp=&((*pp)->pNext)){\n    if( (*pp)==pSession ){\n      *pp = (*pp)->pNext;\n      if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void*)pHead);\n      break;\n    }\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n\n  /* Delete all attached table objects. And the contents of their \n  ** associated hash-tables. */\n  sessionDeleteTable(pSession->pTable);\n\n  /* Free the session object itself. */\n  sqlite3_free(pSession);\n}\n\n/*\n** Set a table filter on a Session Object.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession, \n  int(*xFilter)(void*, const char*),\n  void *pCtx                      /* First argument passed to xFilter */\n){\n  pSession->bAutoAttach = 1;\n  pSession->pFilterCtx = pCtx;\n  pSession->xTableFilter = xFilter;\n}\n\n/*\n** Attach a table to a session. All subsequent changes made to the table\n** while the session object is enabled will be recorded.\n**\n** Only tables that have a PRIMARY KEY defined may be attached. It does\n** not matter if the PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias)\n** or not.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zName               /* Table name */\n){\n  int rc = SQLITE_OK;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n\n  if( !zName ){\n    pSession->bAutoAttach = 1;\n  }else{\n    SessionTable *pTab;           /* New table object (if required) */\n    int nName;                    /* Number of bytes in string zName */\n\n    /* First search for an existing entry. If one is found, this call is\n    ** a no-op. Return early. */\n    nName = sqlite3Strlen30(zName);\n    for(pTab=pSession->pTable; pTab; pTab=pTab->pNext){\n      if( 0==sqlite3_strnicmp(pTab->zName, zName, nName+1) ) break;\n    }\n\n    if( !pTab ){\n      /* Allocate new SessionTable object. */\n      pTab = (SessionTable *)sqlite3_malloc(sizeof(SessionTable) + nName + 1);\n      if( !pTab ){\n        rc = SQLITE_NOMEM;\n      }else{\n        /* Populate the new SessionTable object and link it into the list.\n        ** The new object must be linked onto the end of the list, not \n        ** simply added to the start of it in order to ensure that tables\n        ** appear in the correct order when a changeset or patchset is\n        ** eventually generated. */\n        SessionTable **ppTab;\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->zName = (char *)&pTab[1];\n        memcpy(pTab->zName, zName, nName+1);\n        for(ppTab=&pSession->pTable; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return rc;\n}\n\n/*\n** Ensure that there is room in the buffer to append nByte bytes of data.\n** If not, use sqlite3_realloc() to grow the buffer so that there is.\n**\n** If successful, return zero. Otherwise, if an OOM condition is encountered,\n** set *pRc to SQLITE_NOMEM and return non-zero.\n*/\nstatic int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){\n  if( *pRc==SQLITE_OK && p->nAlloc-p->nBuf<nByte ){\n    u8 *aNew;\n    int nNew = p->nAlloc ? p->nAlloc : 128;\n    do {\n      nNew = nNew*2;\n    }while( nNew<(p->nBuf+nByte) );\n\n    aNew = (u8 *)sqlite3_realloc(p->aBuf, nNew);\n    if( 0==aNew ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      p->aBuf = aNew;\n      p->nAlloc = nNew;\n    }\n  }\n  return (*pRc!=SQLITE_OK);\n}\n\n/*\n** Append the value passed as the second argument to the buffer passed\n** as the first.\n**\n** This function is a no-op if *pRc is non-zero when it is called.\n** Otherwise, if an error occurs, *pRc is set to an SQLite error code\n** before returning.\n*/\nstatic void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    int nByte = 0;\n    rc = sessionSerializeValue(0, pVal, &nByte);\n    sessionBufferGrow(p, nByte, &rc);\n    if( rc==SQLITE_OK ){\n      rc = sessionSerializeValue(&p->aBuf[p->nBuf], pVal, 0);\n      p->nBuf += nByte;\n    }else{\n      *pRc = rc;\n    }\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single byte to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendByte(SessionBuffer *p, u8 v, int *pRc){\n  if( 0==sessionBufferGrow(p, 1, pRc) ){\n    p->aBuf[p->nBuf++] = v;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a single varint to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendVarint(SessionBuffer *p, int v, int *pRc){\n  if( 0==sessionBufferGrow(p, 9, pRc) ){\n    p->nBuf += sessionVarintPut(&p->aBuf[p->nBuf], v);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a blob of data to the buffer. \n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendBlob(\n  SessionBuffer *p, \n  const u8 *aBlob, \n  int nBlob, \n  int *pRc\n){\n  if( nBlob>0 && 0==sessionBufferGrow(p, nBlob, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], aBlob, nBlob);\n    p->nBuf += nBlob;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append a string to the buffer. All bytes in the string\n** up to (but not including) the nul-terminator are written to the buffer.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendStr(\n  SessionBuffer *p, \n  const char *zStr, \n  int *pRc\n){\n  int nStr = sqlite3Strlen30(zStr);\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    memcpy(&p->aBuf[p->nBuf], zStr, nStr);\n    p->nBuf += nStr;\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string representation of integer iVal\n** to the buffer. No nul-terminator is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendInteger(\n  SessionBuffer *p,               /* Buffer to append to */\n  int iVal,                       /* Value to write the string rep. of */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  char aBuf[24];\n  sqlite3_snprintf(sizeof(aBuf)-1, aBuf, \"%d\", iVal);\n  sessionAppendStr(p, aBuf, pRc);\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is \n** called. Otherwise, append the string zStr enclosed in quotes (\") and\n** with any embedded quote characters escaped to the buffer. No \n** nul-terminator byte is written.\n**\n** If an OOM condition is encountered, set *pRc to SQLITE_NOMEM before\n** returning.\n*/\nstatic void sessionAppendIdent(\n  SessionBuffer *p,               /* Buffer to a append to */\n  const char *zStr,               /* String to quote, escape and append */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  int nStr = sqlite3Strlen30(zStr)*2 + 2 + 1;\n  if( 0==sessionBufferGrow(p, nStr, pRc) ){\n    char *zOut = (char *)&p->aBuf[p->nBuf];\n    const char *zIn = zStr;\n    *zOut++ = '\"';\n    while( *zIn ){\n      if( *zIn=='\"' ) *zOut++ = '\"';\n      *zOut++ = *(zIn++);\n    }\n    *zOut++ = '\"';\n    p->nBuf = (int)((u8 *)zOut - p->aBuf);\n  }\n}\n\n/*\n** This function is a no-op if *pRc is other than SQLITE_OK when it is\n** called. Otherwse, it appends the serialized version of the value stored\n** in column iCol of the row that SQL statement pStmt currently points\n** to to the buffer.\n*/\nstatic void sessionAppendCol(\n  SessionBuffer *p,               /* Buffer to append to */\n  sqlite3_stmt *pStmt,            /* Handle pointing to row containing value */\n  int iCol,                       /* Column to read value from */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  if( *pRc==SQLITE_OK ){\n    int eType = sqlite3_column_type(pStmt, iCol);\n    sessionAppendByte(p, (u8)eType, pRc);\n    if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      sqlite3_int64 i;\n      u8 aBuf[8];\n      if( eType==SQLITE_INTEGER ){\n        i = sqlite3_column_int64(pStmt, iCol);\n      }else{\n        double r = sqlite3_column_double(pStmt, iCol);\n        memcpy(&i, &r, 8);\n      }\n      sessionPutI64(aBuf, i);\n      sessionAppendBlob(p, aBuf, 8, pRc);\n    }\n    if( eType==SQLITE_BLOB || eType==SQLITE_TEXT ){\n      u8 *z;\n      int nByte;\n      if( eType==SQLITE_BLOB ){\n        z = (u8 *)sqlite3_column_blob(pStmt, iCol);\n      }else{\n        z = (u8 *)sqlite3_column_text(pStmt, iCol);\n      }\n      nByte = sqlite3_column_bytes(pStmt, iCol);\n      if( z || (eType==SQLITE_BLOB && nByte==0) ){\n        sessionAppendVarint(p, nByte, pRc);\n        sessionAppendBlob(p, z, nByte, pRc);\n      }else{\n        *pRc = SQLITE_NOMEM;\n      }\n    }\n  }\n}\n\n/*\n**\n** This function appends an update change to the buffer (see the comments \n** under \"CHANGESET FORMAT\" at the top of the file). An update change \n** consists of:\n**\n**   1 byte:  SQLITE_UPDATE (0x17)\n**   n bytes: old.* record (see RECORD FORMAT)\n**   m bytes: new.* record (see RECORD FORMAT)\n**\n** The SessionChange object passed as the third argument contains the\n** values that were stored in the row when the session began (the old.*\n** values). The statement handle passed as the second argument points\n** at the current version of the row (the new.* values).\n**\n** If all of the old.* values are equal to their corresponding new.* value\n** (i.e. nothing has changed), then no data at all is appended to the buffer.\n**\n** Otherwise, the old.* record contains all primary key values and the \n** original values of any fields that have been modified. The new.* record \n** contains the new values of only those fields that have been modified.\n*/ \nstatic int sessionAppendUpdate(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  sqlite3_stmt *pStmt,            /* Statement handle pointing at new row */\n  SessionChange *p,               /* Object containing old values */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf2 = {0,0,0}; /* Buffer to accumulate new.* record in */\n  int bNoop = 1;                /* Set to zero if any values are modified */\n  int nRewind = pBuf->nBuf;     /* Set to zero if any values are modified */\n  int i;                        /* Used to iterate through columns */\n  u8 *pCsr = p->aRecord;        /* Used to iterate through old.* values */\n\n  sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n  for(i=0; i<sqlite3_column_count(pStmt); i++){\n    int bChanged = 0;\n    int nAdvance;\n    int eType = *pCsr;\n    switch( eType ){\n      case SQLITE_NULL:\n        nAdvance = 1;\n        if( sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n          bChanged = 1;\n        }\n        break;\n\n      case SQLITE_FLOAT:\n      case SQLITE_INTEGER: {\n        nAdvance = 9;\n        if( eType==sqlite3_column_type(pStmt, i) ){\n          sqlite3_int64 iVal = sessionGetI64(&pCsr[1]);\n          if( eType==SQLITE_INTEGER ){\n            if( iVal==sqlite3_column_int64(pStmt, i) ) break;\n          }else{\n            double dVal;\n            memcpy(&dVal, &iVal, 8);\n            if( dVal==sqlite3_column_double(pStmt, i) ) break;\n          }\n        }\n        bChanged = 1;\n        break;\n      }\n\n      default: {\n        int n;\n        int nHdr = 1 + sessionVarintGet(&pCsr[1], &n);\n        assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );\n        nAdvance = nHdr + n;\n        if( eType==sqlite3_column_type(pStmt, i) \n         && n==sqlite3_column_bytes(pStmt, i) \n         && (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n))\n        ){\n          break;\n        }\n        bChanged = 1;\n      }\n    }\n\n    /* If at least one field has been modified, this is not a no-op. */\n    if( bChanged ) bNoop = 0;\n\n    /* Add a field to the old.* record. This is omitted if this modules is\n    ** currently generating a patchset. */\n    if( bPatchset==0 ){\n      if( bChanged || abPK[i] ){\n        sessionAppendBlob(pBuf, pCsr, nAdvance, &rc);\n      }else{\n        sessionAppendByte(pBuf, 0, &rc);\n      }\n    }\n\n    /* Add a field to the new.* record. Or the only record if currently\n    ** generating a patchset.  */\n    if( bChanged || (bPatchset && abPK[i]) ){\n      sessionAppendCol(&buf2, pStmt, i, &rc);\n    }else{\n      sessionAppendByte(&buf2, 0, &rc);\n    }\n\n    pCsr += nAdvance;\n  }\n\n  if( bNoop ){\n    pBuf->nBuf = nRewind;\n  }else{\n    sessionAppendBlob(pBuf, buf2.aBuf, buf2.nBuf, &rc);\n  }\n  sqlite3_free(buf2.aBuf);\n\n  return rc;\n}\n\n/*\n** Append a DELETE change to the buffer passed as the first argument. Use\n** the changeset format if argument bPatchset is zero, or the patchset\n** format otherwise.\n*/\nstatic int sessionAppendDelete(\n  SessionBuffer *pBuf,            /* Buffer to append to */\n  int bPatchset,                  /* True for \"patchset\", 0 for \"changeset\" */\n  SessionChange *p,               /* Object containing old values */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK                        /* Boolean array - true for PK columns */\n){\n  int rc = SQLITE_OK;\n\n  sessionAppendByte(pBuf, SQLITE_DELETE, &rc);\n  sessionAppendByte(pBuf, p->bIndirect, &rc);\n\n  if( bPatchset==0 ){\n    sessionAppendBlob(pBuf, p->aRecord, p->nRecord, &rc);\n  }else{\n    int i;\n    u8 *a = p->aRecord;\n    for(i=0; i<nCol; i++){\n      u8 *pStart = a;\n      int eType = *a++;\n\n      switch( eType ){\n        case 0:\n        case SQLITE_NULL:\n          assert( abPK[i]==0 );\n          break;\n\n        case SQLITE_FLOAT:\n        case SQLITE_INTEGER:\n          a += 8;\n          break;\n\n        default: {\n          int n;\n          a += sessionVarintGet(a, &n);\n          a += n;\n          break;\n        }\n      }\n      if( abPK[i] ){\n        sessionAppendBlob(pBuf, pStart, (int)(a-pStart), &rc);\n      }\n    }\n    assert( (a - p->aRecord)==p->nRecord );\n  }\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a SELECT statement to retrieve a row from table\n** zTab in database zDb based on its primary key. i.e.\n**\n**   SELECT * FROM zDb.zTab WHERE pk1 = ? AND pk2 = ? AND ...\n*/\nstatic int sessionSelectStmt(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Database name */\n  const char *zTab,               /* Table name */\n  int nCol,                       /* Number of columns in table */\n  const char **azCol,             /* Names of table columns */\n  u8 *abPK,                       /* PRIMARY KEY  array */\n  sqlite3_stmt **ppStmt           /* OUT: Prepared SELECT statement */\n){\n  int rc = SQLITE_OK;\n  int i;\n  const char *zSep = \"\";\n  SessionBuffer buf = {0, 0, 0};\n\n  sessionAppendStr(&buf, \"SELECT * FROM \", &rc);\n  sessionAppendIdent(&buf, zDb, &rc);\n  sessionAppendStr(&buf, \".\", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n  for(i=0; i<nCol; i++){\n    if( abPK[i] ){\n      sessionAppendStr(&buf, zSep, &rc);\n      sessionAppendIdent(&buf, azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i+1, &rc);\n      zSep = \" AND \";\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, ppStmt, 0);\n  }\n  sqlite3_free(buf.aBuf);\n  return rc;\n}\n\n/*\n** Bind the PRIMARY KEY values from the change passed in argument pChange\n** to the SELECT statement passed as the first argument. The SELECT statement\n** is as prepared by function sessionSelectStmt().\n**\n** Return SQLITE_OK if all PK values are successfully bound, or an SQLite\n** error code (e.g. SQLITE_NOMEM) otherwise.\n*/\nstatic int sessionSelectBind(\n  sqlite3_stmt *pSelect,          /* SELECT from sessionSelectStmt() */\n  int nCol,                       /* Number of columns in table */\n  u8 *abPK,                       /* PRIMARY KEY array */\n  SessionChange *pChange          /* Change structure */\n){\n  int i;\n  int rc = SQLITE_OK;\n  u8 *a = pChange->aRecord;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = *a++;\n\n    switch( eType ){\n      case 0:\n      case SQLITE_NULL:\n        assert( abPK[i]==0 );\n        break;\n\n      case SQLITE_INTEGER: {\n        if( abPK[i] ){\n          i64 iVal = sessionGetI64(a);\n          rc = sqlite3_bind_int64(pSelect, i+1, iVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_FLOAT: {\n        if( abPK[i] ){\n          double rVal;\n          i64 iVal = sessionGetI64(a);\n          memcpy(&rVal, &iVal, 8);\n          rc = sqlite3_bind_double(pSelect, i+1, rVal);\n        }\n        a += 8;\n        break;\n      }\n\n      case SQLITE_TEXT: {\n        int n;\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_text(pSelect, i+1, (char *)a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n\n      default: {\n        int n;\n        assert( eType==SQLITE_BLOB );\n        a += sessionVarintGet(a, &n);\n        if( abPK[i] ){\n          rc = sqlite3_bind_blob(pSelect, i+1, a, n, SQLITE_TRANSIENT);\n        }\n        a += n;\n        break;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is a no-op if *pRc is set to other than SQLITE_OK when it\n** is called. Otherwise, append a serialized table header (part of the binary \n** changeset format) to buffer *pBuf. If an error occurs, set *pRc to an\n** SQLite error code before returning.\n*/\nstatic void sessionAppendTableHdr(\n  SessionBuffer *pBuf,            /* Append header to this buffer */\n  int bPatchset,                  /* Use the patchset format if true */\n  SessionTable *pTab,             /* Table object to append header for */\n  int *pRc                        /* IN/OUT: Error code */\n){\n  /* Write a table header */\n  sessionAppendByte(pBuf, (bPatchset ? 'P' : 'T'), pRc);\n  sessionAppendVarint(pBuf, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, pTab->abPK, pTab->nCol, pRc);\n  sessionAppendBlob(pBuf, (u8 *)pTab->zName, (int)strlen(pTab->zName)+1, pRc);\n}\n\n/*\n** Generate either a changeset (if argument bPatchset is zero) or a patchset\n** (if it is non-zero) based on the current contents of the session object\n** passed as the first argument.\n**\n** If no error occurs, SQLITE_OK is returned and the new changeset/patchset\n** stored in output variables *pnChangeset and *ppChangeset. Or, if an error\n** occurs, an SQLite error code is returned and both output variables set \n** to 0.\n*/\nstatic int sessionGenerateChangeset(\n  sqlite3_session *pSession,      /* Session object */\n  int bPatchset,                  /* True for patchset, false for changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,                     /* First argument for xOutput */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  sqlite3 *db = pSession->db;     /* Source database handle */\n  SessionTable *pTab;             /* Used to iterate through attached tables */\n  SessionBuffer buf = {0,0,0};    /* Buffer in which to accumlate changeset */\n  int rc;                         /* Return code */\n\n  assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );\n\n  /* Zero the output variables in case an error occurs. If this session\n  ** object is already in the error state (sqlite3_session.rc != SQLITE_OK),\n  ** this call will be a no-op.  */\n  if( xOutput==0 ){\n    *pnChangeset = 0;\n    *ppChangeset = 0;\n  }\n\n  if( pSession->rc ) return pSession->rc;\n  rc = sqlite3_exec(pSession->db, \"SAVEPOINT changeset\", 0, 0, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n\n  for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    if( pTab->nEntry ){\n      const char *zName = pTab->zName;\n      int nCol;                   /* Number of columns in table */\n      u8 *abPK;                   /* Primary key array */\n      const char **azCol = 0;     /* Table columns */\n      int i;                      /* Used to iterate through hash buckets */\n      sqlite3_stmt *pSel = 0;     /* SELECT statement to query table pTab */\n      int nRewind = buf.nBuf;     /* Initial size of write buffer */\n      int nNoop;                  /* Size of buffer after writing tbl header */\n\n      /* Check the table schema is still Ok. */\n      rc = sessionTableInfo(db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK);\n      if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){\n        rc = SQLITE_SCHEMA;\n      }\n\n      /* Write a table header */\n      sessionAppendTableHdr(&buf, bPatchset, pTab, &rc);\n\n      /* Build and compile a statement to execute: */\n      if( rc==SQLITE_OK ){\n        rc = sessionSelectStmt(\n            db, pSession->zDb, zName, nCol, azCol, abPK, &pSel);\n      }\n\n      nNoop = buf.nBuf;\n      for(i=0; i<pTab->nChange && rc==SQLITE_OK; i++){\n        SessionChange *p;         /* Used to iterate through changes */\n\n        for(p=pTab->apChange[i]; rc==SQLITE_OK && p; p=p->pNext){\n          rc = sessionSelectBind(pSel, nCol, abPK, p);\n          if( rc!=SQLITE_OK ) continue;\n          if( sqlite3_step(pSel)==SQLITE_ROW ){\n            if( p->op==SQLITE_INSERT ){\n              int iCol;\n              sessionAppendByte(&buf, SQLITE_INSERT, &rc);\n              sessionAppendByte(&buf, p->bIndirect, &rc);\n              for(iCol=0; iCol<nCol; iCol++){\n                sessionAppendCol(&buf, pSel, iCol, &rc);\n              }\n            }else{\n              rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);\n            }\n          }else if( p->op!=SQLITE_INSERT ){\n            rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3_reset(pSel);\n          }\n\n          /* If the buffer is now larger than SESSIONS_STRM_CHUNK_SIZE, pass\n          ** its contents to the xOutput() callback. */\n          if( xOutput \n           && rc==SQLITE_OK \n           && buf.nBuf>nNoop \n           && buf.nBuf>SESSIONS_STRM_CHUNK_SIZE \n          ){\n            rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n            nNoop = -1;\n            buf.nBuf = 0;\n          }\n\n        }\n      }\n\n      sqlite3_finalize(pSel);\n      if( buf.nBuf==nNoop ){\n        buf.nBuf = nRewind;\n      }\n      sqlite3_free((char*)azCol);  /* cast works around VC++ bug */\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput==0 ){\n      *pnChangeset = buf.nBuf;\n      *ppChangeset = buf.aBuf;\n      buf.aBuf = 0;\n    }else if( buf.nBuf>0 ){\n      rc = xOutput(pOut, (void*)buf.aBuf, buf.nBuf);\n    }\n  }\n\n  sqlite3_free(buf.aBuf);\n  sqlite3_exec(db, \"RELEASE changeset\", 0, 0, 0);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Obtain a changeset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset, ppChangeset);\n}\n\n/*\n** Streaming version of sqlite3session_changeset().\n*/\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);\n}\n\n/*\n** Streaming version of sqlite3session_patchset().\n*/\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);\n}\n\n/*\n** Obtain a patchset object containing all changes recorded by the \n** session object passed as the first argument.\n**\n** It is the responsibility of the caller to eventually free the buffer \n** using sqlite3_free().\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppChangeset */\n  void **ppPatchset               /* OUT: Buffer containing changeset */\n){\n  return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bEnable>=0 ){\n    pSession->bEnable = bEnable;\n  }\n  ret = pSession->bEnable;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Enable or disable the session object passed as the first argument.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect){\n  int ret;\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  if( bIndirect>=0 ){\n    pSession->bIndirect = bIndirect;\n  }\n  ret = pSession->bIndirect;\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n  return ret;\n}\n\n/*\n** Return true if there have been no changes to monitored tables recorded\n** by the session object passed as the only argument.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession){\n  int ret = 0;\n  SessionTable *pTab;\n\n  sqlite3_mutex_enter(sqlite3_db_mutex(pSession->db));\n  for(pTab=pSession->pTable; pTab && ret==0; pTab=pTab->pNext){\n    ret = (pTab->nEntry>0);\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(pSession->db));\n\n  return (ret==0);\n}\n\n/*\n** Do the work for either sqlite3changeset_start() or start_strm().\n*/\nstatic int sessionChangesetStart(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset                /* Pointer to buffer containing changeset */\n){\n  sqlite3_changeset_iter *pRet;   /* Iterator to return */\n  int nByte;                      /* Number of bytes to allocate for iterator */\n\n  assert( xInput==0 || (pChangeset==0 && nChangeset==0) );\n\n  /* Zero the output variable in case an error occurs. */\n  *pp = 0;\n\n  /* Allocate and initialize the iterator structure. */\n  nByte = sizeof(sqlite3_changeset_iter);\n  pRet = (sqlite3_changeset_iter *)sqlite3_malloc(nByte);\n  if( !pRet ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(sqlite3_changeset_iter));\n  pRet->in.aData = (u8 *)pChangeset;\n  pRet->in.nData = nChangeset;\n  pRet->in.xInput = xInput;\n  pRet->in.pIn = pIn;\n  pRet->in.bEof = (xInput ? 0 : 1);\n\n  /* Populate the output variable and return success. */\n  *pp = pRet;\n  return SQLITE_OK;\n}\n\n/*\n** Create an iterator used to iterate through the contents of a changeset.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int nChangeset,                 /* Size of buffer pChangeset in bytes */\n  void *pChangeset                /* Pointer to buffer containing changeset */\n){\n  return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset);\n}\n\n/*\n** Streaming version of sqlite3changeset_start().\n*/\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,    /* OUT: Changeset iterator handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  return sessionChangesetStart(pp, xInput, pIn, 0, 0);\n}\n\n/*\n** If the SessionInput object passed as the only argument is a streaming\n** object and the buffer is full, discard some data to free up space.\n*/\nstatic void sessionDiscardData(SessionInput *pIn){\n  if( pIn->bEof && pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){\n    int nMove = pIn->buf.nBuf - pIn->iNext;\n    assert( nMove>=0 );\n    if( nMove>0 ){\n      memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove);\n    }\n    pIn->buf.nBuf -= pIn->iNext;\n    pIn->iNext = 0;\n    pIn->nData = pIn->buf.nBuf;\n  }\n}\n\n/*\n** Ensure that there are at least nByte bytes available in the buffer. Or,\n** if there are not nByte bytes remaining in the input, that all available\n** data is in the buffer.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int sessionInputBuffer(SessionInput *pIn, int nByte){\n  int rc = SQLITE_OK;\n  if( pIn->xInput ){\n    while( !pIn->bEof && (pIn->iNext+nByte)>=pIn->nData && rc==SQLITE_OK ){\n      int nNew = SESSIONS_STRM_CHUNK_SIZE;\n\n      if( pIn->bNoDiscard==0 ) sessionDiscardData(pIn);\n      if( SQLITE_OK==sessionBufferGrow(&pIn->buf, nNew, &rc) ){\n        rc = pIn->xInput(pIn->pIn, &pIn->buf.aBuf[pIn->buf.nBuf], &nNew);\n        if( nNew==0 ){\n          pIn->bEof = 1;\n        }else{\n          pIn->buf.nBuf += nNew;\n        }\n      }\n\n      pIn->aData = pIn->buf.aBuf;\n      pIn->nData = pIn->buf.nBuf;\n    }\n  }\n  return rc;\n}\n\n/*\n** When this function is called, *ppRec points to the start of a record\n** that contains nCol values. This function advances the pointer *ppRec\n** until it points to the byte immediately following that record.\n*/\nstatic void sessionSkipRecord(\n  u8 **ppRec,                     /* IN/OUT: Record pointer */\n  int nCol                        /* Number of values in record */\n){\n  u8 *aRec = *ppRec;\n  int i;\n  for(i=0; i<nCol; i++){\n    int eType = *aRec++;\n    if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n      int nByte;\n      aRec += sessionVarintGet((u8*)aRec, &nByte);\n      aRec += nByte;\n    }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n      aRec += 8;\n    }\n  }\n\n  *ppRec = aRec;\n}\n\n/*\n** This function sets the value of the sqlite3_value object passed as the\n** first argument to a copy of the string or blob held in the aData[] \n** buffer. SQLITE_OK is returned if successful, or SQLITE_NOMEM if an OOM\n** error occurs.\n*/\nstatic int sessionValueSetStr(\n  sqlite3_value *pVal,            /* Set the value of this object */\n  u8 *aData,                      /* Buffer containing string or blob data */\n  int nData,                      /* Size of buffer aData[] in bytes */\n  u8 enc                          /* String encoding (0 for blobs) */\n){\n  /* In theory this code could just pass SQLITE_TRANSIENT as the final\n  ** argument to sqlite3ValueSetStr() and have the copy created \n  ** automatically. But doing so makes it difficult to detect any OOM\n  ** error. Hence the code to create the copy externally. */\n  u8 *aCopy = sqlite3_malloc(nData+1);\n  if( aCopy==0 ) return SQLITE_NOMEM;\n  memcpy(aCopy, aData, nData);\n  sqlite3ValueSetStr(pVal, nData, (char*)aCopy, enc, sqlite3_free);\n  return SQLITE_OK;\n}\n\n/*\n** Deserialize a single record from a buffer in memory. See \"RECORD FORMAT\"\n** for details.\n**\n** When this function is called, *paChange points to the start of the record\n** to deserialize. Assuming no error occurs, *paChange is set to point to\n** one byte after the end of the same record before this function returns.\n** If the argument abPK is NULL, then the record contains nCol values. Or,\n** if abPK is other than NULL, then the record contains only the PK fields\n** (in other words, it is a patchset DELETE record).\n**\n** If successful, each element of the apOut[] array (allocated by the caller)\n** is set to point to an sqlite3_value object containing the value read\n** from the corresponding position in the record. If that value is not\n** included in the record (i.e. because the record is part of an UPDATE change\n** and the field was not modified), the corresponding element of apOut[] is\n** set to NULL.\n**\n** It is the responsibility of the caller to free all sqlite_value structures\n** using sqlite3_free().\n**\n** If an error occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n** The apOut[] array may have been partially populated in this case.\n*/\nstatic int sessionReadRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of values in record */\n  u8 *abPK,                       /* Array of primary key flags, or NULL */\n  sqlite3_value **apOut           /* Write values to this array */\n){\n  int i;                          /* Used to iterate through columns */\n  int rc = SQLITE_OK;\n\n  for(i=0; i<nCol && rc==SQLITE_OK; i++){\n    int eType = 0;                /* Type of value (SQLITE_NULL, TEXT etc.) */\n    if( abPK && abPK[i]==0 ) continue;\n    rc = sessionInputBuffer(pIn, 9);\n    if( rc==SQLITE_OK ){\n      eType = pIn->aData[pIn->iNext++];\n    }\n\n    assert( apOut[i]==0 );\n    if( eType ){\n      apOut[i] = sqlite3ValueNew(0);\n      if( !apOut[i] ) rc = SQLITE_NOMEM;\n    }\n\n    if( rc==SQLITE_OK ){\n      u8 *aVal = &pIn->aData[pIn->iNext];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int nByte;\n        pIn->iNext += sessionVarintGet(aVal, &nByte);\n        rc = sessionInputBuffer(pIn, nByte);\n        if( rc==SQLITE_OK ){\n          u8 enc = (eType==SQLITE_TEXT ? SQLITE_UTF8 : 0);\n          rc = sessionValueSetStr(apOut[i],&pIn->aData[pIn->iNext],nByte,enc);\n        }\n        pIn->iNext += nByte;\n      }\n      if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        sqlite3_int64 v = sessionGetI64(aVal);\n        if( eType==SQLITE_INTEGER ){\n          sqlite3VdbeMemSetInt64(apOut[i], v);\n        }else{\n          double d;\n          memcpy(&d, &v, 8);\n          sqlite3VdbeMemSetDouble(apOut[i], d);\n        }\n        pIn->iNext += 8;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function ensures that all of the above is present in the input \n** buffer (i.e. that it can be accessed without any calls to xInput()).\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code.\n** The input pointer is not moved.\n*/\nstatic int sessionChangesetBufferTblhdr(SessionInput *pIn, int *pnByte){\n  int rc = SQLITE_OK;\n  int nCol = 0;\n  int nRead = 0;\n\n  rc = sessionInputBuffer(pIn, 9);\n  if( rc==SQLITE_OK ){\n    nRead += sessionVarintGet(&pIn->aData[pIn->iNext + nRead], &nCol);\n    rc = sessionInputBuffer(pIn, nRead+nCol+100);\n    nRead += nCol;\n  }\n\n  while( rc==SQLITE_OK ){\n    while( (pIn->iNext + nRead)<pIn->nData && pIn->aData[pIn->iNext + nRead] ){\n      nRead++;\n    }\n    if( (pIn->iNext + nRead)<pIn->nData ) break;\n    rc = sessionInputBuffer(pIn, nRead + 100);\n  }\n  *pnByte = nRead+1;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the first byte of the first field\n** of a record consisting of nCol columns. This function ensures the entire\n** record is buffered. It does not move the input pointer.\n**\n** If successful, SQLITE_OK is returned and *pnByte is set to the size of\n** the record in bytes. Otherwise, an SQLite error code is returned. The\n** final value of *pnByte is undefined in this case.\n*/\nstatic int sessionChangesetBufferRecord(\n  SessionInput *pIn,              /* Input data */\n  int nCol,                       /* Number of columns in record */\n  int *pnByte                     /* OUT: Size of record in bytes */\n){\n  int rc = SQLITE_OK;\n  int nByte = 0;\n  int i;\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    int eType;\n    rc = sessionInputBuffer(pIn, nByte + 10);\n    if( rc==SQLITE_OK ){\n      eType = pIn->aData[pIn->iNext + nByte++];\n      if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){\n        int n;\n        nByte += sessionVarintGet(&pIn->aData[pIn->iNext+nByte], &n);\n        nByte += n;\n        rc = sessionInputBuffer(pIn, nByte);\n      }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){\n        nByte += 8;\n      }\n    }\n  }\n  *pnByte = nByte;\n  return rc;\n}\n\n/*\n** The input pointer currently points to the second byte of a table-header.\n** Specifically, to the following:\n**\n**   + number of columns in table (varint)\n**   + array of PK flags (1 byte per column),\n**   + table name (nul terminated).\n**\n** This function decodes the table-header and populates the p->nCol, \n** p->zTab and p->abPK[] variables accordingly. The p->apValue[] array is \n** also allocated or resized according to the new value of p->nCol. The\n** input pointer is left pointing to the byte following the table header.\n**\n** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code\n** is returned and the final values of the various fields enumerated above\n** are undefined.\n*/\nstatic int sessionChangesetReadTblhdr(sqlite3_changeset_iter *p){\n  int rc;\n  int nCopy;\n  assert( p->rc==SQLITE_OK );\n\n  rc = sessionChangesetBufferTblhdr(&p->in, &nCopy);\n  if( rc==SQLITE_OK ){\n    int nByte;\n    int nVarint;\n    nVarint = sessionVarintGet(&p->in.aData[p->in.iNext], &p->nCol);\n    nCopy -= nVarint;\n    p->in.iNext += nVarint;\n    nByte = p->nCol * sizeof(sqlite3_value*) * 2 + nCopy;\n    p->tblhdr.nBuf = 0;\n    sessionBufferGrow(&p->tblhdr, nByte, &rc);\n  }\n\n  if( rc==SQLITE_OK ){\n    int iPK = sizeof(sqlite3_value*)*p->nCol*2;\n    memset(p->tblhdr.aBuf, 0, iPK);\n    memcpy(&p->tblhdr.aBuf[iPK], &p->in.aData[p->in.iNext], nCopy);\n    p->in.iNext += nCopy;\n  }\n\n  p->apValue = (sqlite3_value**)p->tblhdr.aBuf;\n  p->abPK = (u8*)&p->apValue[p->nCol*2];\n  p->zTab = (char*)&p->abPK[p->nCol];\n  return (p->rc = rc);\n}\n\n/*\n** Advance the changeset iterator to the next change.\n**\n** If both paRec and pnRec are NULL, then this function works like the public\n** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the\n** sqlite3changeset_new() and old() APIs may be used to query for values.\n**\n** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change\n** record is written to *paRec before returning and the number of bytes in\n** the record to *pnRec.\n**\n** Either way, this function returns SQLITE_ROW if the iterator is \n** successfully advanced to the next change in the changeset, an SQLite \n** error code if an error occurs, or SQLITE_DONE if there are no further \n** changes in the changeset.\n*/\nstatic int sessionChangesetNext(\n  sqlite3_changeset_iter *p,      /* Changeset iterator */\n  u8 **paRec,                     /* If non-NULL, store record pointer here */\n  int *pnRec                      /* If non-NULL, store size of record here */\n){\n  int i;\n  u8 op;\n\n  assert( (paRec==0 && pnRec==0) || (paRec && pnRec) );\n\n  /* If the iterator is in the error-state, return immediately. */\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* Free the current contents of p->apValue[], if any. */\n  if( p->apValue ){\n    for(i=0; i<p->nCol*2; i++){\n      sqlite3ValueFree(p->apValue[i]);\n    }\n    memset(p->apValue, 0, sizeof(sqlite3_value*)*p->nCol*2);\n  }\n\n  /* Make sure the buffer contains at least 10 bytes of input data, or all\n  ** remaining data if there are less than 10 bytes available. This is\n  ** sufficient either for the 'T' or 'P' byte and the varint that follows\n  ** it, or for the two single byte values otherwise. */\n  p->rc = sessionInputBuffer(&p->in, 2);\n  if( p->rc!=SQLITE_OK ) return p->rc;\n\n  /* If the iterator is already at the end of the changeset, return DONE. */\n  if( p->in.iNext>=p->in.nData ){\n    return SQLITE_DONE;\n  }\n\n  sessionDiscardData(&p->in);\n  p->in.iCurrent = p->in.iNext;\n\n  op = p->in.aData[p->in.iNext++];\n  while( op=='T' || op=='P' ){\n    p->bPatchset = (op=='P');\n    if( sessionChangesetReadTblhdr(p) ) return p->rc;\n    if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc;\n    p->in.iCurrent = p->in.iNext;\n    if( p->in.iNext>=p->in.nData ) return SQLITE_DONE;\n    op = p->in.aData[p->in.iNext++];\n  }\n\n  p->op = op;\n  p->bIndirect = p->in.aData[p->in.iNext++];\n  if( p->op!=SQLITE_UPDATE && p->op!=SQLITE_DELETE && p->op!=SQLITE_INSERT ){\n    return (p->rc = SQLITE_CORRUPT_BKPT);\n  }\n\n  if( paRec ){ \n    int nVal;                     /* Number of values to buffer */\n    if( p->bPatchset==0 && op==SQLITE_UPDATE ){\n      nVal = p->nCol * 2;\n    }else if( p->bPatchset && op==SQLITE_DELETE ){\n      nVal = 0;\n      for(i=0; i<p->nCol; i++) if( p->abPK[i] ) nVal++;\n    }else{\n      nVal = p->nCol;\n    }\n    p->rc = sessionChangesetBufferRecord(&p->in, nVal, pnRec);\n    if( p->rc!=SQLITE_OK ) return p->rc;\n    *paRec = &p->in.aData[p->in.iNext];\n    p->in.iNext += *pnRec;\n  }else{\n\n    /* If this is an UPDATE or DELETE, read the old.* record. */\n    if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){\n      u8 *abPK = p->bPatchset ? p->abPK : 0;\n      p->rc = sessionReadRecord(&p->in, p->nCol, abPK, p->apValue);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    /* If this is an INSERT or UPDATE, read the new.* record. */\n    if( p->op!=SQLITE_DELETE ){\n      p->rc = sessionReadRecord(&p->in, p->nCol, 0, &p->apValue[p->nCol]);\n      if( p->rc!=SQLITE_OK ) return p->rc;\n    }\n\n    if( p->bPatchset && p->op==SQLITE_UPDATE ){\n      /* If this is an UPDATE that is part of a patchset, then all PK and\n      ** modified fields are present in the new.* record. The old.* record\n      ** is currently completely empty. This block shifts the PK fields from\n      ** new.* to old.*, to accommodate the code that reads these arrays.  */\n      for(i=0; i<p->nCol; i++){\n        assert( p->apValue[i]==0 );\n        assert( p->abPK[i]==0 || p->apValue[i+p->nCol] );\n        if( p->abPK[i] ){\n          p->apValue[i] = p->apValue[i+p->nCol];\n          p->apValue[i+p->nCol] = 0;\n        }\n      }\n    }\n  }\n\n  return SQLITE_ROW;\n}\n\n/*\n** Advance an iterator created by sqlite3changeset_start() to the next\n** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE\n** or SQLITE_CORRUPT.\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){\n  return sessionChangesetNext(p, 0, 0);\n}\n\n/*\n** The following function extracts information on the current change\n** from a changeset iterator. It may only be called after changeset_next()\n** has returned SQLITE_ROW.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator handle */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True if change is indirect */\n){\n  *pOp = pIter->op;\n  *pnCol = pIter->nCol;\n  *pzTab = pIter->zTab;\n  if( pbIndirect ) *pbIndirect = pIter->bIndirect;\n  return SQLITE_OK;\n}\n\n/*\n** Return information regarding the PRIMARY KEY and number of columns in\n** the database table affected by the change that pIter currently points\n** to. This function may only be called after changeset_next() returns\n** SQLITE_ROW.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n){\n  *pabPK = pIter->abPK;\n  if( pnCol ) *pnCol = pIter->nCol;\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_DELETE change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the old.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified and is not a PK column), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of old.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_DELETE ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[iVal];\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called while the iterator is pointing to an\n** SQLITE_UPDATE or SQLITE_INSERT change (see sqlite3changeset_op()).\n** Otherwise, SQLITE_MISUSE is returned.\n**\n** It sets *ppValue to point to an sqlite3_value structure containing the\n** iVal'th value in the new.* record. Or, if that particular value is not\n** included in the record (because the change is an UPDATE and the field\n** was not modified), set *ppValue to NULL.\n**\n** If value iVal is out-of-range, SQLITE_RANGE is returned and *ppValue is\n** not modified. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of new.* value to retrieve */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n){\n  if( pIter->op!=SQLITE_UPDATE && pIter->op!=SQLITE_INSERT ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = pIter->apValue[pIter->nCol+iVal];\n  return SQLITE_OK;\n}\n\n/*\n** The following two macros are used internally. They are similar to the\n** sqlite3changeset_new() and sqlite3changeset_old() functions, except that\n** they omit all error checking and return a pointer to the requested value.\n*/\n#define sessionChangesetNew(pIter, iVal) (pIter)->apValue[(pIter)->nCol+(iVal)]\n#define sessionChangesetOld(pIter, iVal) (pIter)->apValue[(iVal)]\n\n/*\n** This function may only be called with a changeset iterator that has been\n** passed to an SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT \n** conflict-handler function. Otherwise, SQLITE_MISUSE is returned.\n**\n** If successful, *ppValue is set to point to an sqlite3_value structure\n** containing the iVal'th value of the conflicting record.\n**\n** If value iVal is out-of-range or some other error occurs, an SQLite error\n** code is returned. Otherwise, SQLITE_OK.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Index of conflict record value to fetch */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n){\n  if( !pIter->pConflict ){\n    return SQLITE_MISUSE;\n  }\n  if( iVal<0 || iVal>=pIter->nCol ){\n    return SQLITE_RANGE;\n  }\n  *ppValue = sqlite3_column_value(pIter->pConflict, iVal);\n  return SQLITE_OK;\n}\n\n/*\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n){\n  if( pIter->pConflict || pIter->apValue ){\n    return SQLITE_MISUSE;\n  }\n  *pnOut = pIter->nCol;\n  return SQLITE_OK;\n}\n\n\n/*\n** Finalize an iterator allocated with sqlite3changeset_start().\n**\n** This function may not be called on iterators passed to a conflict handler\n** callback by changeset_apply().\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;                        /* Used to iterate through p->apValue[] */\n    rc = p->rc;\n    if( p->apValue ){\n      for(i=0; i<p->nCol*2; i++) sqlite3ValueFree(p->apValue[i]);\n    }\n    sqlite3_free(p->tblhdr.aBuf);\n    sqlite3_free(p->in.buf.aBuf);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\nstatic int sessionChangesetInvert(\n  SessionInput *pInput,           /* Input changeset */\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  int rc = SQLITE_OK;             /* Return value */\n  SessionBuffer sOut;             /* Output buffer */\n  int nCol = 0;                   /* Number of cols in current table */\n  u8 *abPK = 0;                   /* PK array for current table */\n  sqlite3_value **apVal = 0;      /* Space for values for UPDATE inversion */\n  SessionBuffer sPK = {0, 0, 0};  /* PK array for current table */\n\n  /* Initialize the output buffer */\n  memset(&sOut, 0, sizeof(SessionBuffer));\n\n  /* Zero the output variables in case an error occurs. */\n  if( ppInverted ){\n    *ppInverted = 0;\n    *pnInverted = 0;\n  }\n\n  while( 1 ){\n    u8 eType;\n\n    /* Test for EOF. */\n    if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;\n    if( pInput->iNext>=pInput->nData ) break;\n    eType = pInput->aData[pInput->iNext];\n\n    switch( eType ){\n      case 'T': {\n        /* A 'table' record consists of:\n        **\n        **   * A constant 'T' character,\n        **   * Number of columns in said table (a varint),\n        **   * An array of nCol bytes (sPK),\n        **   * A nul-terminated table name.\n        */\n        int nByte;\n        int nVar;\n        pInput->iNext++;\n        if( (rc = sessionChangesetBufferTblhdr(pInput, &nByte)) ){\n          goto finished_invert;\n        }\n        nVar = sessionVarintGet(&pInput->aData[pInput->iNext], &nCol);\n        sPK.nBuf = 0;\n        sessionAppendBlob(&sPK, &pInput->aData[pInput->iNext+nVar], nCol, &rc);\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        if( rc ) goto finished_invert;\n\n        pInput->iNext += nByte;\n        sqlite3_free(apVal);\n        apVal = 0;\n        abPK = sPK.aBuf;\n        break;\n      }\n\n      case SQLITE_INSERT:\n      case SQLITE_DELETE: {\n        int nByte;\n        int bIndirect = pInput->aData[pInput->iNext+1];\n        int eType2 = (eType==SQLITE_DELETE ? SQLITE_INSERT : SQLITE_DELETE);\n        pInput->iNext += 2;\n        assert( rc==SQLITE_OK );\n        rc = sessionChangesetBufferRecord(pInput, nCol, &nByte);\n        sessionAppendByte(&sOut, eType2, &rc);\n        sessionAppendByte(&sOut, bIndirect, &rc);\n        sessionAppendBlob(&sOut, &pInput->aData[pInput->iNext], nByte, &rc);\n        pInput->iNext += nByte;\n        if( rc ) goto finished_invert;\n        break;\n      }\n\n      case SQLITE_UPDATE: {\n        int iCol;\n\n        if( 0==apVal ){\n          apVal = (sqlite3_value **)sqlite3_malloc(sizeof(apVal[0])*nCol*2);\n          if( 0==apVal ){\n            rc = SQLITE_NOMEM;\n            goto finished_invert;\n          }\n          memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        }\n\n        /* Write the header for the new UPDATE change. Same as the original. */\n        sessionAppendByte(&sOut, eType, &rc);\n        sessionAppendByte(&sOut, pInput->aData[pInput->iNext+1], &rc);\n\n        /* Read the old.* and new.* records for the update change. */\n        pInput->iNext += 2;\n        rc = sessionReadRecord(pInput, nCol, 0, &apVal[0]);\n        if( rc==SQLITE_OK ){\n          rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol]);\n        }\n\n        /* Write the new old.* record. Consists of the PK columns from the\n        ** original old.* record, and the other values from the original\n        ** new.* record. */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = apVal[iCol + (abPK[iCol] ? 0 : nCol)];\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        /* Write the new new.* record. Consists of a copy of all values\n        ** from the original old.* record, except for the PK columns, which\n        ** are set to \"undefined\". */\n        for(iCol=0; iCol<nCol; iCol++){\n          sqlite3_value *pVal = (abPK[iCol] ? 0 : apVal[iCol]);\n          sessionAppendValue(&sOut, pVal, &rc);\n        }\n\n        for(iCol=0; iCol<nCol*2; iCol++){\n          sqlite3ValueFree(apVal[iCol]);\n        }\n        memset(apVal, 0, sizeof(apVal[0])*nCol*2);\n        if( rc!=SQLITE_OK ){\n          goto finished_invert;\n        }\n\n        break;\n      }\n\n      default:\n        rc = SQLITE_CORRUPT_BKPT;\n        goto finished_invert;\n    }\n\n    assert( rc==SQLITE_OK );\n    if( xOutput && sOut.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){\n      rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n      sOut.nBuf = 0;\n      if( rc!=SQLITE_OK ) goto finished_invert;\n    }\n  }\n\n  assert( rc==SQLITE_OK );\n  if( pnInverted ){\n    *pnInverted = sOut.nBuf;\n    *ppInverted = sOut.aBuf;\n    sOut.aBuf = 0;\n  }else if( sOut.nBuf>0 ){\n    rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);\n  }\n\n finished_invert:\n  sqlite3_free(sOut.aBuf);\n  sqlite3_free(apVal);\n  sqlite3_free(sPK.aBuf);\n  return rc;\n}\n\n\n/*\n** Invert a changeset object.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nChangeset,                 /* Number of bytes in input */\n  const void *pChangeset,         /* Input changeset */\n  int *pnInverted,                /* OUT: Number of bytes in output changeset */\n  void **ppInverted               /* OUT: Inverse of pChangeset */\n){\n  SessionInput sInput;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.nData = nChangeset;\n  sInput.aData = (u8*)pChangeset;\n\n  return sessionChangesetInvert(&sInput, 0, 0, pnInverted, ppInverted);\n}\n\n/*\n** Streaming version of sqlite3changeset_invert().\n*/\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  SessionInput sInput;\n  int rc;\n\n  /* Set up the input stream */\n  memset(&sInput, 0, sizeof(SessionInput));\n  sInput.xInput = xInput;\n  sInput.pIn = pIn;\n\n  rc = sessionChangesetInvert(&sInput, xOutput, pOut, 0, 0);\n  sqlite3_free(sInput.buf.aBuf);\n  return rc;\n}\n\ntypedef struct SessionApplyCtx SessionApplyCtx;\nstruct SessionApplyCtx {\n  sqlite3 *db;\n  sqlite3_stmt *pDelete;          /* DELETE statement */\n  sqlite3_stmt *pUpdate;          /* UPDATE statement */\n  sqlite3_stmt *pInsert;          /* INSERT statement */\n  sqlite3_stmt *pSelect;          /* SELECT statement */\n  int nCol;                       /* Size of azCol[] and abPK[] arrays */\n  const char **azCol;             /* Array of column names */\n  u8 *abPK;                       /* Boolean array - true if column is in PK */\n\n  int bDeferConstraints;          /* True to defer constraints */\n  SessionBuffer constraints;      /* Deferred constraints are stored here */\n};\n\n/*\n** Formulate a statement to DELETE a row from database db. Assuming a table\n** structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The DELETE statement looks like this:\n**\n**     DELETE FROM x WHERE a = :1 AND c = :3 AND (:5 OR b IS :2 AND d IS :4)\n**\n** Variable :5 (nCol+1) is a boolean. It should be set to 0 if we require\n** matching b and d values, or 1 otherwise. The second case comes up if the\n** conflict handler is invoked with NOTFOUND and returns CHANGESET_REPLACE.\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pDelete is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionDeleteRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int i;\n  const char *zSep = \"\";\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  int nPk = 0;\n\n  sessionAppendStr(&buf, \"DELETE FROM \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      nPk++;\n      sessionAppendStr(&buf, zSep, &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i+1, &rc);\n      zSep = \" AND \";\n    }\n  }\n\n  if( nPk<p->nCol ){\n    sessionAppendStr(&buf, \" AND (?\", &rc);\n    sessionAppendInteger(&buf, p->nCol+1, &rc);\n    sessionAppendStr(&buf, \" OR \", &rc);\n\n    zSep = \"\";\n    for(i=0; i<p->nCol; i++){\n      if( !p->abPK[i] ){\n        sessionAppendStr(&buf, zSep, &rc);\n        sessionAppendIdent(&buf, p->azCol[i], &rc);\n        sessionAppendStr(&buf, \" IS ?\", &rc);\n        sessionAppendInteger(&buf, i+1, &rc);\n        zSep = \"AND \";\n      }\n    }\n    sessionAppendStr(&buf, \")\", &rc);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pDelete, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Formulate and prepare a statement to UPDATE a row from database db. \n** Assuming a table structure like this:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The UPDATE statement looks like this:\n**\n**     UPDATE x SET\n**     a = CASE WHEN ?2  THEN ?3  ELSE a END,\n**     b = CASE WHEN ?5  THEN ?6  ELSE b END,\n**     c = CASE WHEN ?8  THEN ?9  ELSE c END,\n**     d = CASE WHEN ?11 THEN ?12 ELSE d END\n**     WHERE a = ?1 AND c = ?7 AND (?13 OR \n**       (?5==0 OR b IS ?4) AND (?11==0 OR d IS ?10) AND\n**     )\n**\n** For each column in the table, there are three variables to bind:\n**\n**     ?(i*3+1)    The old.* value of the column, if any.\n**     ?(i*3+2)    A boolean flag indicating that the value is being modified.\n**     ?(i*3+3)    The new.* value of the column, if any.\n**\n** Also, a boolean flag that, if set to true, causes the statement to update\n** a row even if the non-PK values do not match. This is required if the\n** conflict-handler is invoked with CHANGESET_DATA and returns\n** CHANGESET_REPLACE. This is variable \"?(nCol*3+1)\".\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pUpdate is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionUpdateRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  const char *zSep = \"\";\n  SessionBuffer buf = {0, 0, 0};\n\n  /* Append \"UPDATE tbl SET \" */\n  sessionAppendStr(&buf, \"UPDATE \", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \" SET \", &rc);\n\n  /* Append the assignments */\n  for(i=0; i<p->nCol; i++){\n    sessionAppendStr(&buf, zSep, &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" = CASE WHEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+2, &rc);\n    sessionAppendStr(&buf, \" THEN ?\", &rc);\n    sessionAppendInteger(&buf, i*3+3, &rc);\n    sessionAppendStr(&buf, \" ELSE \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n    sessionAppendStr(&buf, \" END\", &rc);\n    zSep = \", \";\n  }\n\n  /* Append the PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" WHERE \", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( p->abPK[i] ){\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" = ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \" AND \", &rc);\n    }\n  }\n\n  /* Append the non-PK part of the WHERE clause */\n  sessionAppendStr(&buf, \" (?\", &rc);\n  sessionAppendInteger(&buf, p->nCol*3+1, &rc);\n  sessionAppendStr(&buf, \" OR 1\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( !p->abPK[i] ){\n      sessionAppendStr(&buf, \" AND (?\", &rc);\n      sessionAppendInteger(&buf, i*3+2, &rc);\n      sessionAppendStr(&buf, \"=0 OR \", &rc);\n      sessionAppendIdent(&buf, p->azCol[i], &rc);\n      sessionAppendStr(&buf, \" IS ?\", &rc);\n      sessionAppendInteger(&buf, i*3+1, &rc);\n      sessionAppendStr(&buf, \")\", &rc);\n    }\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pUpdate, 0);\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Formulate and prepare an SQL statement to query table zTab by primary\n** key. Assuming the following table structure:\n**\n**     CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c));\n**\n** The SELECT statement looks like this:\n**\n**     SELECT * FROM x WHERE a = ?1 AND c = ?3\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pSelect is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionSelectRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  return sessionSelectStmt(\n      db, \"main\", zTab, p->nCol, p->azCol, p->abPK, &p->pSelect);\n}\n\n/*\n** Formulate and prepare an INSERT statement to add a record to table zTab.\n** For example:\n**\n**     INSERT INTO main.\"zTab\" VALUES(?1, ?2, ?3 ...);\n**\n** If successful, SQLITE_OK is returned and SessionApplyCtx.pInsert is left\n** pointing to the prepared version of the SQL statement.\n*/\nstatic int sessionInsertRow(\n  sqlite3 *db,                    /* Database handle */\n  const char *zTab,               /* Table name */\n  SessionApplyCtx *p              /* Session changeset-apply context */\n){\n  int rc = SQLITE_OK;\n  int i;\n  SessionBuffer buf = {0, 0, 0};\n\n  sessionAppendStr(&buf, \"INSERT INTO main.\", &rc);\n  sessionAppendIdent(&buf, zTab, &rc);\n  sessionAppendStr(&buf, \"(\", &rc);\n  for(i=0; i<p->nCol; i++){\n    if( i!=0 ) sessionAppendStr(&buf, \", \", &rc);\n    sessionAppendIdent(&buf, p->azCol[i], &rc);\n  }\n\n  sessionAppendStr(&buf, \") VALUES(?\", &rc);\n  for(i=1; i<p->nCol; i++){\n    sessionAppendStr(&buf, \", ?\", &rc);\n  }\n  sessionAppendStr(&buf, \")\", &rc);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pInsert, 0);\n  }\n  sqlite3_free(buf.aBuf);\n  return rc;\n}\n\n/*\n** A wrapper around sqlite3_bind_value() that detects an extra problem. \n** See comments in the body of this function for details.\n*/\nstatic int sessionBindValue(\n  sqlite3_stmt *pStmt,            /* Statement to bind value to */\n  int i,                          /* Parameter number to bind to */\n  sqlite3_value *pVal             /* Value to bind */\n){\n  int eType = sqlite3_value_type(pVal);\n  /* COVERAGE: The (pVal->z==0) branch is never true using current versions\n  ** of SQLite. If a malloc fails in an sqlite3_value_xxx() function, either\n  ** the (pVal->z) variable remains as it was or the type of the value is\n  ** set to SQLITE_NULL.  */\n  if( (eType==SQLITE_TEXT || eType==SQLITE_BLOB) && pVal->z==0 ){\n    /* This condition occurs when an earlier OOM in a call to\n    ** sqlite3_value_text() or sqlite3_value_blob() (perhaps from within\n    ** a conflict-handler) has zeroed the pVal->z pointer. Return NOMEM. */\n    return SQLITE_NOMEM;\n  }\n  return sqlite3_bind_value(pStmt, i, pVal);\n}\n\n/*\n** Iterator pIter must point to an SQLITE_INSERT entry. This function \n** transfers new.* values from the current iterator entry to statement\n** pStmt. The table being inserted into has nCol columns.\n**\n** New.* value $i from the iterator is bound to variable ($i+1) of \n** statement pStmt. If parameter abPK is NULL, all values from 0 to (nCol-1)\n** are transfered to the statement. Otherwise, if abPK is not NULL, it points\n** to an array nCol elements in size. In this case only those values for \n** which abPK[$i] is true are read from the iterator and bound to the \n** statement.\n**\n** An SQLite error code is returned if an error occurs. Otherwise, SQLITE_OK.\n*/\nstatic int sessionBindRow(\n  sqlite3_changeset_iter *pIter,  /* Iterator to read values from */\n  int(*xValue)(sqlite3_changeset_iter *, int, sqlite3_value **),\n  int nCol,                       /* Number of columns */\n  u8 *abPK,                       /* If not NULL, bind only if true */\n  sqlite3_stmt *pStmt             /* Bind values to this statement */\n){\n  int i;\n  int rc = SQLITE_OK;\n\n  /* Neither sqlite3changeset_old or sqlite3changeset_new can fail if the\n  ** argument iterator points to a suitable entry. Make sure that xValue \n  ** is one of these to guarantee that it is safe to ignore the return \n  ** in the code below. */\n  assert( xValue==sqlite3changeset_old || xValue==sqlite3changeset_new );\n\n  for(i=0; rc==SQLITE_OK && i<nCol; i++){\n    if( !abPK || abPK[i] ){\n      sqlite3_value *pVal;\n      (void)xValue(pIter, i, &pVal);\n      rc = sessionBindValue(pStmt, i+1, pVal);\n    }\n  }\n  return rc;\n}\n\n/*\n** SQL statement pSelect is as generated by the sessionSelectRow() function.\n** This function binds the primary key values from the change that changeset\n** iterator pIter points to to the SELECT and attempts to seek to the table\n** entry. If a row is found, the SELECT statement left pointing at the row \n** and SQLITE_ROW is returned. Otherwise, if no row is found and no error\n** has occured, the statement is reset and SQLITE_OK is returned. If an\n** error occurs, the statement is reset and an SQLite error code is returned.\n**\n** If this function returns SQLITE_ROW, the caller must eventually reset() \n** statement pSelect. If any other value is returned, the statement does\n** not require a reset().\n**\n** If the iterator currently points to an INSERT record, bind values from the\n** new.* record to the SELECT statement. Or, if it points to a DELETE or\n** UPDATE, bind values from the old.* record. \n*/\nstatic int sessionSeekToRow(\n  sqlite3 *db,                    /* Database handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  u8 *abPK,                       /* Primary key flags array */\n  sqlite3_stmt *pSelect           /* SELECT statement from sessionSelectRow() */\n){\n  int rc;                         /* Return code */\n  int nCol;                       /* Number of columns in table */\n  int op;                         /* Changset operation (SQLITE_UPDATE etc.) */\n  const char *zDummy;             /* Unused */\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n  rc = sessionBindRow(pIter, \n      op==SQLITE_INSERT ? sqlite3changeset_new : sqlite3changeset_old,\n      nCol, abPK, pSelect\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_step(pSelect);\n    if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect);\n  }\n\n  return rc;\n}\n\n/*\n** Invoke the conflict handler for the change that the changeset iterator\n** currently points to.\n**\n** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT.\n** If argument pbReplace is NULL, then the type of conflict handler invoked\n** depends solely on eType, as follows:\n**\n**    eType value                 Value passed to xConflict\n**    -------------------------------------------------\n**    CHANGESET_DATA              CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT          CHANGESET_CONSTRAINT\n**\n** Or, if pbReplace is not NULL, then an attempt is made to find an existing\n** record with the same primary key as the record about to be deleted, updated\n** or inserted. If such a record can be found, it is available to the conflict\n** handler as the \"conflicting\" record. In this case the type of conflict\n** handler invoked is as follows:\n**\n**    eType value         PK Record found?   Value passed to xConflict\n**    ----------------------------------------------------------------\n**    CHANGESET_DATA      Yes                CHANGESET_DATA\n**    CHANGESET_DATA      No                 CHANGESET_NOTFOUND\n**    CHANGESET_CONFLICT  Yes                CHANGESET_CONFLICT\n**    CHANGESET_CONFLICT  No                 CHANGESET_CONSTRAINT\n**\n** If pbReplace is not NULL, and a record with a matching PK is found, and\n** the conflict handler function returns SQLITE_CHANGESET_REPLACE, *pbReplace\n** is set to non-zero before returning SQLITE_OK.\n**\n** If the conflict handler returns SQLITE_CHANGESET_ABORT, SQLITE_ABORT is\n** returned. Or, if the conflict handler returns an invalid value, \n** SQLITE_MISUSE. If the conflict handler returns SQLITE_CHANGESET_OMIT,\n** this function returns SQLITE_OK.\n*/\nstatic int sessionConflictHandler(\n  int eType,                      /* Either CHANGESET_DATA or CONFLICT */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter*),\n  void *pCtx,                     /* First argument for conflict handler */\n  int *pbReplace                  /* OUT: Set to true if PK row is found */\n){\n  int res = 0;                    /* Value returned by conflict handler */\n  int rc;\n  int nCol;\n  int op;\n  const char *zDummy;\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  assert( eType==SQLITE_CHANGESET_CONFLICT || eType==SQLITE_CHANGESET_DATA );\n  assert( SQLITE_CHANGESET_CONFLICT+1==SQLITE_CHANGESET_CONSTRAINT );\n  assert( SQLITE_CHANGESET_DATA+1==SQLITE_CHANGESET_NOTFOUND );\n\n  /* Bind the new.* PRIMARY KEY values to the SELECT statement. */\n  if( pbReplace ){\n    rc = sessionSeekToRow(p->db, pIter, p->abPK, p->pSelect);\n  }else{\n    rc = SQLITE_OK;\n  }\n\n  if( rc==SQLITE_ROW ){\n    /* There exists another row with the new.* primary key. */\n    pIter->pConflict = p->pSelect;\n    res = xConflict(pCtx, eType, pIter);\n    pIter->pConflict = 0;\n    rc = sqlite3_reset(p->pSelect);\n  }else if( rc==SQLITE_OK ){\n    if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){\n      /* Instead of invoking the conflict handler, append the change blob\n      ** to the SessionApplyCtx.constraints buffer. */\n      u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];\n      int nBlob = pIter->in.iNext - pIter->in.iCurrent;\n      sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);\n      res = SQLITE_CHANGESET_OMIT;\n    }else{\n      /* No other row with the new.* primary key. */\n      res = xConflict(pCtx, eType+1, pIter);\n      if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    switch( res ){\n      case SQLITE_CHANGESET_REPLACE:\n        assert( pbReplace );\n        *pbReplace = 1;\n        break;\n\n      case SQLITE_CHANGESET_OMIT:\n        break;\n\n      case SQLITE_CHANGESET_ABORT:\n        rc = SQLITE_ABORT;\n        break;\n\n      default:\n        rc = SQLITE_MISUSE;\n        break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** If argument pbRetry is NULL, then ignore any CHANGESET_DATA conflict. If\n** one is encountered, update or delete the row with the matching primary key\n** instead. Or, if pbRetry is not NULL and a CHANGESET_DATA conflict occurs,\n** invoke the conflict handler. If it returns CHANGESET_REPLACE, set *pbRetry\n** to true before returning. In this case the caller will invoke this function\n** again, this time with pbRetry set to NULL.\n**\n** If argument pbReplace is NULL and a CHANGESET_CONFLICT conflict is \n** encountered invoke the conflict handler with CHANGESET_CONSTRAINT instead.\n** Or, if pbReplace is not NULL, invoke it with CHANGESET_CONFLICT. If such\n** an invocation returns SQLITE_CHANGESET_REPLACE, set *pbReplace to true\n** before retrying. In this case the caller attempts to remove the conflicting\n** row before invoking this function again, this time with pbReplace set \n** to NULL.\n**\n** If any conflict handler returns SQLITE_CHANGESET_ABORT, this function\n** returns SQLITE_ABORT. Otherwise, if no error occurs, SQLITE_OK is \n** returned.\n*/\nstatic int sessionApplyOneOp(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  SessionApplyCtx *p,             /* changeset_apply() context */\n  int(*xConflict)(void *, int, sqlite3_changeset_iter *),\n  void *pCtx,                     /* First argument for the conflict handler */\n  int *pbReplace,                 /* OUT: True to remove PK row and retry */\n  int *pbRetry                    /* OUT: True to retry. */\n){\n  const char *zDummy;\n  int op;\n  int nCol;\n  int rc = SQLITE_OK;\n\n  assert( p->pDelete && p->pUpdate && p->pInsert && p->pSelect );\n  assert( p->azCol && p->abPK );\n  assert( !pbReplace || *pbReplace==0 );\n\n  sqlite3changeset_op(pIter, &zDummy, &nCol, &op, 0);\n\n  if( op==SQLITE_DELETE ){\n\n    /* Bind values to the DELETE statement. If conflict handling is required,\n    ** bind values for all columns and set bound variable (nCol+1) to true.\n    ** Or, if conflict handling is not required, bind just the PK column\n    ** values and, if it exists, set (nCol+1) to false. Conflict handling\n    ** is not required if:\n    **\n    **   * this is a patchset, or\n    **   * (pbRetry==0), or\n    **   * all columns of the table are PK columns (in this case there is\n    **     no (nCol+1) variable to bind to).\n    */\n    u8 *abPK = (pIter->bPatchset ? p->abPK : 0);\n    rc = sessionBindRow(pIter, sqlite3changeset_old, nCol, abPK, p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_bind_parameter_count(p->pDelete)>nCol ){\n      rc = sqlite3_bind_int(p->pDelete, nCol+1, (pbRetry==0 || abPK));\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    sqlite3_step(p->pDelete);\n    rc = sqlite3_reset(p->pDelete);\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else if( op==SQLITE_UPDATE ){\n    int i;\n\n    /* Bind values to the UPDATE statement. */\n    for(i=0; rc==SQLITE_OK && i<nCol; i++){\n      sqlite3_value *pOld = sessionChangesetOld(pIter, i);\n      sqlite3_value *pNew = sessionChangesetNew(pIter, i);\n\n      sqlite3_bind_int(p->pUpdate, i*3+2, !!pNew);\n      if( pOld ){\n        rc = sessionBindValue(p->pUpdate, i*3+1, pOld);\n      }\n      if( rc==SQLITE_OK && pNew ){\n        rc = sessionBindValue(p->pUpdate, i*3+3, pNew);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int(p->pUpdate, nCol*3+1, pbRetry==0 || pIter->bPatchset);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n\n    /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict,\n    ** the result will be SQLITE_OK with 0 rows modified. */\n    sqlite3_step(p->pUpdate);\n    rc = sqlite3_reset(p->pUpdate);\n\n    if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){\n      /* A NOTFOUND or DATA error. Search the table to see if it contains\n      ** a row with a matching primary key. If so, this is a DATA conflict.\n      ** Otherwise, if there is no primary key match, it is a NOTFOUND. */\n\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_DATA, p, pIter, xConflict, pCtx, pbRetry\n      );\n\n    }else if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      /* This is always a CONSTRAINT conflict. */\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, 0\n      );\n    }\n\n  }else{\n    assert( op==SQLITE_INSERT );\n    rc = sessionBindRow(pIter, sqlite3changeset_new, nCol, 0, p->pInsert);\n    if( rc!=SQLITE_OK ) return rc;\n\n    sqlite3_step(p->pInsert);\n    rc = sqlite3_reset(p->pInsert);\n    if( (rc&0xff)==SQLITE_CONSTRAINT ){\n      rc = sessionConflictHandler(\n          SQLITE_CHANGESET_CONFLICT, p, pIter, xConflict, pCtx, pbReplace\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Attempt to apply the change that the iterator passed as the first argument\n** currently points to to the database. If a conflict is encountered, invoke\n** the conflict handler callback.\n**\n** The difference between this function and sessionApplyOne() is that this\n** function handles the case where the conflict-handler is invoked and \n** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be\n** retried in some manner.\n*/\nstatic int sessionApplyOneWithRetry(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator to read change from */\n  SessionApplyCtx *pApply,        /* Apply context */\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int bReplace = 0;\n  int bRetry = 0;\n  int rc;\n\n  rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry);\n  assert( rc==SQLITE_OK || (bRetry==0 && bReplace==0) );\n\n  /* If the bRetry flag is set, the change has not been applied due to an\n  ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and\n  ** a row with the correct PK is present in the db, but one or more other\n  ** fields do not contain the expected values) and the conflict handler \n  ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,\n  ** but pass NULL as the final argument so that sessionApplyOneOp() ignores\n  ** the SQLITE_CHANGESET_DATA problem.  */\n  if( bRetry ){\n    assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE );\n    rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n  }\n\n  /* If the bReplace flag is set, the change is an INSERT that has not\n  ** been performed because the database already contains a row with the\n  ** specified primary key and the conflict handler returned\n  ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row\n  ** before reattempting the INSERT.  */\n  else if( bReplace ){\n    assert( pIter->op==SQLITE_INSERT );\n    rc = sqlite3_exec(db, \"SAVEPOINT replace_op\", 0, 0, 0);\n    if( rc==SQLITE_OK ){\n      rc = sessionBindRow(pIter, \n          sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete);\n      sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pApply->pDelete);\n      rc = sqlite3_reset(pApply->pDelete);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_exec(db, \"RELEASE replace_op\", 0, 0, 0);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Retry the changes accumulated in the pApply->constraints buffer.\n*/\nstatic int sessionRetryConstraints(\n  sqlite3 *db, \n  int bPatchset,\n  const char *zTab,\n  SessionApplyCtx *pApply,\n  int(*xConflict)(void*, int, sqlite3_changeset_iter*),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int rc = SQLITE_OK;\n\n  while( pApply->constraints.nBuf ){\n    sqlite3_changeset_iter *pIter2 = 0;\n    SessionBuffer cons = pApply->constraints;\n    memset(&pApply->constraints, 0, sizeof(SessionBuffer));\n\n    rc = sessionChangesetStart(&pIter2, 0, 0, cons.nBuf, cons.aBuf);\n    if( rc==SQLITE_OK ){\n      int nByte = 2*pApply->nCol*sizeof(sqlite3_value*);\n      int rc2;\n      pIter2->bPatchset = bPatchset;\n      pIter2->zTab = (char*)zTab;\n      pIter2->nCol = pApply->nCol;\n      pIter2->abPK = pApply->abPK;\n      sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);\n      pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;\n      if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);\n\n      while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){\n        rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);\n      }\n\n      rc2 = sqlite3changeset_finalize(pIter2);\n      if( rc==SQLITE_OK ) rc = rc2;\n    }\n    assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );\n\n    sqlite3_free(cons.aBuf);\n    if( rc!=SQLITE_OK ) break;\n    if( pApply->constraints.nBuf>=cons.nBuf ){\n      /* No progress was made on the last round. */\n      pApply->bDeferConstraints = 0;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Argument pIter is a changeset iterator that has been initialized, but\n** not yet passed to sqlite3changeset_next(). This function applies the \n** changeset to the main database attached to handle \"db\". The supplied\n** conflict handler callback is invoked to resolve any conflicts encountered\n** while applying the change.\n*/\nstatic int sessionChangesetApply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  sqlite3_changeset_iter *pIter,  /* Changeset to apply */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  int schemaMismatch = 0;\n  int rc;                         /* Return code */\n  const char *zTab = 0;           /* Name of current table */\n  int nTab = 0;                   /* Result of sqlite3Strlen30(zTab) */\n  SessionApplyCtx sApply;         /* changeset_apply() context object */\n  int bPatchset;\n\n  assert( xConflict!=0 );\n\n  pIter->in.bNoDiscard = 1;\n  memset(&sApply, 0, sizeof(sApply));\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  rc = sqlite3_exec(db, \"SAVEPOINT changeset_apply\", 0, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 1\", 0, 0, 0);\n  }\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){\n    int nCol;\n    int op;\n    const char *zNew;\n    \n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, 0);\n\n    if( zTab==0 || sqlite3_strnicmp(zNew, zTab, nTab+1) ){\n      u8 *abPK;\n\n      rc = sessionRetryConstraints(\n          db, pIter->bPatchset, zTab, &sApply, xConflict, pCtx\n      );\n      if( rc!=SQLITE_OK ) break;\n\n      sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n      sqlite3_finalize(sApply.pDelete);\n      sqlite3_finalize(sApply.pUpdate); \n      sqlite3_finalize(sApply.pInsert);\n      sqlite3_finalize(sApply.pSelect);\n      memset(&sApply, 0, sizeof(sApply));\n      sApply.db = db;\n      sApply.bDeferConstraints = 1;\n\n      /* If an xFilter() callback was specified, invoke it now. If the \n      ** xFilter callback returns zero, skip this table. If it returns\n      ** non-zero, proceed. */\n      schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew)));\n      if( schemaMismatch ){\n        zTab = sqlite3_mprintf(\"%s\", zNew);\n        if( zTab==0 ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        nTab = (int)strlen(zTab);\n        sApply.azCol = (const char **)zTab;\n      }else{\n        int nMinCol = 0;\n        int i;\n\n        sqlite3changeset_pk(pIter, &abPK, 0);\n        rc = sessionTableInfo(\n            db, \"main\", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK\n        );\n        if( rc!=SQLITE_OK ) break;\n        for(i=0; i<sApply.nCol; i++){\n          if( sApply.abPK[i] ) nMinCol = i+1;\n        }\n  \n        if( sApply.nCol==0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): no such table: %s\", zTab\n          );\n        }\n        else if( sApply.nCol<nCol ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \n              \"sqlite3changeset_apply(): table %s has %d columns, \"\n              \"expected %d or more\", \n              zTab, sApply.nCol, nCol\n          );\n        }\n        else if( nCol<nMinCol || memcmp(sApply.abPK, abPK, nCol)!=0 ){\n          schemaMismatch = 1;\n          sqlite3_log(SQLITE_SCHEMA, \"sqlite3changeset_apply(): \"\n              \"primary key mismatch for table %s\", zTab\n          );\n        }\n        else{\n          sApply.nCol = nCol;\n          if((rc = sessionSelectRow(db, zTab, &sApply))\n          || (rc = sessionUpdateRow(db, zTab, &sApply))\n          || (rc = sessionDeleteRow(db, zTab, &sApply))\n          || (rc = sessionInsertRow(db, zTab, &sApply))\n          ){\n            break;\n          }\n        }\n        nTab = sqlite3Strlen30(zTab);\n      }\n    }\n\n    /* If there is a schema mismatch on the current table, proceed to the\n    ** next change. A log message has already been issued. */\n    if( schemaMismatch ) continue;\n\n    rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);\n  }\n\n  bPatchset = pIter->bPatchset;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changeset_finalize(pIter);\n  }else{\n    sqlite3changeset_finalize(pIter);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sessionRetryConstraints(db, bPatchset, zTab, &sApply, xConflict, pCtx);\n  }\n\n  if( rc==SQLITE_OK ){\n    int nFk, notUsed;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_DEFERRED_FKS, &nFk, &notUsed, 0);\n    if( nFk!=0 ){\n      int res = SQLITE_CHANGESET_ABORT;\n      sqlite3_changeset_iter sIter;\n      memset(&sIter, 0, sizeof(sIter));\n      sIter.nCol = nFk;\n      res = xConflict(pCtx, SQLITE_CHANGESET_FOREIGN_KEY, &sIter);\n      if( res!=SQLITE_CHANGESET_OMIT ){\n        rc = SQLITE_CONSTRAINT;\n      }\n    }\n  }\n  sqlite3_exec(db, \"PRAGMA defer_foreign_keys = 0\", 0, 0, 0);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n  }else{\n    sqlite3_exec(db, \"ROLLBACK TO changeset_apply\", 0, 0, 0);\n    sqlite3_exec(db, \"RELEASE changeset_apply\", 0, 0, 0);\n  }\n\n  sqlite3_finalize(sApply.pInsert);\n  sqlite3_finalize(sApply.pDelete);\n  sqlite3_finalize(sApply.pUpdate);\n  sqlite3_finalize(sApply.pSelect);\n  sqlite3_free((char*)sApply.azCol);  /* cast works around VC++ bug */\n  sqlite3_free((char*)sApply.constraints.aBuf);\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return rc;\n}\n\n/*\n** Apply the changeset passed via pChangeset/nChangeset to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of fifth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);\n  }\n  return rc;\n}\n\n/*\n** Apply the changeset passed via xInput/pIn to the main database\n** attached to handle \"db\". Invoke the supplied conflict handler callback\n** to resolve any conflicts encountered while applying the change.\n*/\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator to skip through changeset */  \n  int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetApply(db, pIter, xFilter, xConflict, pCtx);\n  }\n  return rc;\n}\n\n/*\n** sqlite3_changegroup handle.\n*/\nstruct sqlite3_changegroup {\n  int rc;                         /* Error code */\n  int bPatch;                     /* True to accumulate patchsets */\n  SessionTable *pList;            /* List of tables in current patch */\n};\n\n/*\n** This function is called to merge two changes to the same row together as\n** part of an sqlite3changeset_concat() operation. A new change object is\n** allocated and a pointer to it stored in *ppNew.\n*/\nstatic int sessionChangeMerge(\n  SessionTable *pTab,             /* Table structure */\n  int bPatchset,                  /* True for patchsets */\n  SessionChange *pExist,          /* Existing change */\n  int op2,                        /* Second change operation */\n  int bIndirect,                  /* True if second change is indirect */\n  u8 *aRec,                       /* Second change record */\n  int nRec,                       /* Number of bytes in aRec */\n  SessionChange **ppNew           /* OUT: Merged change */\n){\n  SessionChange *pNew = 0;\n\n  if( !pExist ){\n    pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);\n    if( !pNew ){\n      return SQLITE_NOMEM;\n    }\n    memset(pNew, 0, sizeof(SessionChange));\n    pNew->op = op2;\n    pNew->bIndirect = bIndirect;\n    pNew->nRecord = nRec;\n    pNew->aRecord = (u8*)&pNew[1];\n    memcpy(pNew->aRecord, aRec, nRec);\n  }else{\n    int op1 = pExist->op;\n\n    /* \n    **   op1=INSERT, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=INSERT, op2=UPDATE      ->      INSERT.\n    **   op1=INSERT, op2=DELETE      ->      (none)\n    **\n    **   op1=UPDATE, op2=INSERT      ->      Unsupported. Discard op2.\n    **   op1=UPDATE, op2=UPDATE      ->      UPDATE.\n    **   op1=UPDATE, op2=DELETE      ->      DELETE.\n    **\n    **   op1=DELETE, op2=INSERT      ->      UPDATE.\n    **   op1=DELETE, op2=UPDATE      ->      Unsupported. Discard op2.\n    **   op1=DELETE, op2=DELETE      ->      Unsupported. Discard op2.\n    */   \n    if( (op1==SQLITE_INSERT && op2==SQLITE_INSERT)\n     || (op1==SQLITE_UPDATE && op2==SQLITE_INSERT)\n     || (op1==SQLITE_DELETE && op2==SQLITE_UPDATE)\n     || (op1==SQLITE_DELETE && op2==SQLITE_DELETE)\n    ){\n      pNew = pExist;\n    }else if( op1==SQLITE_INSERT && op2==SQLITE_DELETE ){\n      sqlite3_free(pExist);\n      assert( pNew==0 );\n    }else{\n      u8 *aExist = pExist->aRecord;\n      int nByte;\n      u8 *aCsr;\n\n      /* Allocate a new SessionChange object. Ensure that the aRecord[]\n      ** buffer of the new object is large enough to hold any record that\n      ** may be generated by combining the input records.  */\n      nByte = sizeof(SessionChange) + pExist->nRecord + nRec;\n      pNew = (SessionChange *)sqlite3_malloc(nByte);\n      if( !pNew ){\n        sqlite3_free(pExist);\n        return SQLITE_NOMEM;\n      }\n      memset(pNew, 0, sizeof(SessionChange));\n      pNew->bIndirect = (bIndirect && pExist->bIndirect);\n      aCsr = pNew->aRecord = (u8 *)&pNew[1];\n\n      if( op1==SQLITE_INSERT ){             /* INSERT + UPDATE */\n        u8 *a1 = aRec;\n        assert( op2==SQLITE_UPDATE );\n        pNew->op = SQLITE_INSERT;\n        if( bPatchset==0 ) sessionSkipRecord(&a1, pTab->nCol);\n        sessionMergeRecord(&aCsr, pTab->nCol, aExist, a1);\n      }else if( op1==SQLITE_DELETE ){       /* DELETE + INSERT */\n        assert( op2==SQLITE_INSERT );\n        pNew->op = SQLITE_UPDATE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){\n            sqlite3_free(pNew);\n            pNew = 0;\n          }\n        }\n      }else if( op2==SQLITE_UPDATE ){       /* UPDATE + UPDATE */\n        u8 *a1 = aExist;\n        u8 *a2 = aRec;\n        assert( op1==SQLITE_UPDATE );\n        if( bPatchset==0 ){\n          sessionSkipRecord(&a1, pTab->nCol);\n          sessionSkipRecord(&a2, pTab->nCol);\n        }\n        pNew->op = SQLITE_UPDATE;\n        if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aRec, aExist,a1,a2) ){\n          sqlite3_free(pNew);\n          pNew = 0;\n        }\n      }else{                                /* UPDATE + DELETE */\n        assert( op1==SQLITE_UPDATE && op2==SQLITE_DELETE );\n        pNew->op = SQLITE_DELETE;\n        if( bPatchset ){\n          memcpy(aCsr, aRec, nRec);\n          aCsr += nRec;\n        }else{\n          sessionMergeRecord(&aCsr, pTab->nCol, aRec, aExist);\n        }\n      }\n\n      if( pNew ){\n        pNew->nRecord = (int)(aCsr - pNew->aRecord);\n      }\n      sqlite3_free(pExist);\n    }\n  }\n\n  *ppNew = pNew;\n  return SQLITE_OK;\n}\n\n/*\n** Add all changes in the changeset traversed by the iterator passed as\n** the first argument to the changegroup hash tables.\n*/\nstatic int sessionChangesetToHash(\n  sqlite3_changeset_iter *pIter,   /* Iterator to read from */\n  sqlite3_changegroup *pGrp        /* Changegroup object to add changeset to */\n){\n  u8 *aRec;\n  int nRec;\n  int rc = SQLITE_OK;\n  SessionTable *pTab = 0;\n\n\n  while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec) ){\n    const char *zNew;\n    int nCol;\n    int op;\n    int iHash;\n    int bIndirect;\n    SessionChange *pChange;\n    SessionChange *pExist = 0;\n    SessionChange **pp;\n\n    if( pGrp->pList==0 ){\n      pGrp->bPatch = pIter->bPatchset;\n    }else if( pIter->bPatchset!=pGrp->bPatch ){\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    sqlite3changeset_op(pIter, &zNew, &nCol, &op, &bIndirect);\n    if( !pTab || sqlite3_stricmp(zNew, pTab->zName) ){\n      /* Search the list for a matching table */\n      int nNew = (int)strlen(zNew);\n      u8 *abPK;\n\n      sqlite3changeset_pk(pIter, &abPK, 0);\n      for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){\n        if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break;\n      }\n      if( !pTab ){\n        SessionTable **ppTab;\n\n        pTab = sqlite3_malloc(sizeof(SessionTable) + nCol + nNew+1);\n        if( !pTab ){\n          rc = SQLITE_NOMEM;\n          break;\n        }\n        memset(pTab, 0, sizeof(SessionTable));\n        pTab->nCol = nCol;\n        pTab->abPK = (u8*)&pTab[1];\n        memcpy(pTab->abPK, abPK, nCol);\n        pTab->zName = (char*)&pTab->abPK[nCol];\n        memcpy(pTab->zName, zNew, nNew+1);\n\n        /* The new object must be linked on to the end of the list, not\n        ** simply added to the start of it. This is to ensure that the\n        ** tables within the output of sqlite3changegroup_output() are in \n        ** the right order.  */\n        for(ppTab=&pGrp->pList; *ppTab; ppTab=&(*ppTab)->pNext);\n        *ppTab = pTab;\n      }else if( pTab->nCol!=nCol || memcmp(pTab->abPK, abPK, nCol) ){\n        rc = SQLITE_SCHEMA;\n        break;\n      }\n    }\n\n    if( sessionGrowHash(pIter->bPatchset, pTab) ){\n      rc = SQLITE_NOMEM;\n      break;\n    }\n    iHash = sessionChangeHash(\n        pTab, (pIter->bPatchset && op==SQLITE_DELETE), aRec, pTab->nChange\n    );\n\n    /* Search for existing entry. If found, remove it from the hash table. \n    ** Code below may link it back in.\n    */\n    for(pp=&pTab->apChange[iHash]; *pp; pp=&(*pp)->pNext){\n      int bPkOnly1 = 0;\n      int bPkOnly2 = 0;\n      if( pIter->bPatchset ){\n        bPkOnly1 = (*pp)->op==SQLITE_DELETE;\n        bPkOnly2 = op==SQLITE_DELETE;\n      }\n      if( sessionChangeEqual(pTab, bPkOnly1, (*pp)->aRecord, bPkOnly2, aRec) ){\n        pExist = *pp;\n        *pp = (*pp)->pNext;\n        pTab->nEntry--;\n        break;\n      }\n    }\n\n    rc = sessionChangeMerge(pTab, \n        pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange\n    );\n    if( rc ) break;\n    if( pChange ){\n      pChange->pNext = pTab->apChange[iHash];\n      pTab->apChange[iHash] = pChange;\n      pTab->nEntry++;\n    }\n  }\n\n  if( rc==SQLITE_OK ) rc = pIter->rc;\n  return rc;\n}\n\n/*\n** Serialize a changeset (or patchset) based on all changesets (or patchsets)\n** added to the changegroup object passed as the first argument.\n**\n** If xOutput is not NULL, then the changeset/patchset is returned to the\n** user via one or more calls to xOutput, as with the other streaming\n** interfaces. \n**\n** Or, if xOutput is NULL, then (*ppOut) is populated with a pointer to a\n** buffer containing the output changeset before this function returns. In\n** this case (*pnOut) is set to the size of the output buffer in bytes. It\n** is the responsibility of the caller to free the output buffer using\n** sqlite3_free() when it is no longer required.\n**\n** If successful, SQLITE_OK is returned. Or, if an error occurs, an SQLite\n** error code. If an error occurs and xOutput is NULL, (*ppOut) and (*pnOut)\n** are both set to 0 before returning.\n*/\nstatic int sessionChangegroupOutput(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut,\n  int *pnOut,\n  void **ppOut\n){\n  int rc = SQLITE_OK;\n  SessionBuffer buf = {0, 0, 0};\n  SessionTable *pTab;\n  assert( xOutput==0 || (ppOut==0 && pnOut==0) );\n\n  /* Create the serialized output changeset based on the contents of the\n  ** hash tables attached to the SessionTable objects in list p->pList. \n  */\n  for(pTab=pGrp->pList; rc==SQLITE_OK && pTab; pTab=pTab->pNext){\n    int i;\n    if( pTab->nEntry==0 ) continue;\n\n    sessionAppendTableHdr(&buf, pGrp->bPatch, pTab, &rc);\n    for(i=0; i<pTab->nChange; i++){\n      SessionChange *p;\n      for(p=pTab->apChange[i]; p; p=p->pNext){\n        sessionAppendByte(&buf, p->op, &rc);\n        sessionAppendByte(&buf, p->bIndirect, &rc);\n        sessionAppendBlob(&buf, p->aRecord, p->nRecord, &rc);\n      }\n    }\n\n    if( rc==SQLITE_OK && xOutput && buf.nBuf>=SESSIONS_STRM_CHUNK_SIZE ){\n      rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n      buf.nBuf = 0;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    if( xOutput ){\n      if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);\n    }else{\n      *ppOut = buf.aBuf;\n      *pnOut = buf.nBuf;\n      buf.aBuf = 0;\n    }\n  }\n  sqlite3_free(buf.aBuf);\n\n  return rc;\n}\n\n/*\n** Allocate a new, empty, sqlite3_changegroup.\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp){\n  int rc = SQLITE_OK;             /* Return code */\n  sqlite3_changegroup *p;         /* New object */\n  p = (sqlite3_changegroup*)sqlite3_malloc(sizeof(sqlite3_changegroup));\n  if( p==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    memset(p, 0, sizeof(sqlite3_changegroup));\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Add the changeset currently stored in buffer pData, size nData bytes,\n** to changeset-group p.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start(&pIter, nData, pData);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Obtain a buffer containing a changeset representing the concatenation\n** of all changesets added to the group so far.\n*/\nSQLITE_API int sqlite3changegroup_output(\n    sqlite3_changegroup *pGrp,\n    int *pnData,\n    void **ppData\n){\n  return sessionChangegroupOutput(pGrp, 0, 0, pnData, ppData);\n}\n\n/*\n** Streaming versions of changegroup_add().\n*/\nSQLITE_API int sqlite3changegroup_add_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n){\n  sqlite3_changeset_iter *pIter;  /* Iterator opened on pData/nData */\n  int rc;                         /* Return code */\n\n  rc = sqlite3changeset_start_strm(&pIter, xInput, pIn);\n  if( rc==SQLITE_OK ){\n    rc = sessionChangesetToHash(pIter, pGrp);\n  }\n  sqlite3changeset_finalize(pIter);\n  return rc;\n}\n\n/*\n** Streaming versions of changegroup_output().\n*/\nSQLITE_API int sqlite3changegroup_output_strm(\n  sqlite3_changegroup *pGrp,\n  int (*xOutput)(void *pOut, const void *pData, int nData), \n  void *pOut\n){\n  return sessionChangegroupOutput(pGrp, xOutput, pOut, 0, 0);\n}\n\n/*\n** Delete a changegroup object.\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){\n  if( pGrp ){\n    sessionDeleteTable(pGrp->pList);\n    sqlite3_free(pGrp);\n  }\n}\n\n/* \n** Combine two changesets together.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nLeft,                      /* Number of bytes in lhs input */\n  void *pLeft,                    /* Lhs input changeset */\n  int nRight                      /* Number of bytes in rhs input */,\n  void *pRight,                   /* Rhs input changeset */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: changeset (left <concat> right) */\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nLeft, pLeft);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add(pGrp, nRight, pRight);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n/*\n** Streaming version of sqlite3changeset_concat().\n*/\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n){\n  sqlite3_changegroup *pGrp;\n  int rc;\n\n  rc = sqlite3changegroup_new(&pGrp);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputA, pInA);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_add_strm(pGrp, xInputB, pInB);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut);\n  }\n  sqlite3changegroup_delete(pGrp);\n\n  return rc;\n}\n\n#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */\n\n/************** End of sqlite3session.c **************************************/\n/************** Begin file json1.c *******************************************/\n/*\n** 2015-08-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This SQLite extension implements JSON functions.  The interface is\n** modeled after MySQL JSON functions:\n**\n**     https://dev.mysql.com/doc/refman/5.7/en/json.html\n**\n** For the time being, all JSON is stored as pure text.  (We might add\n** a JSONB type in the future which stores a binary encoding of JSON in\n** a BLOB, but there is no support for JSONB in the current implementation.\n** This implementation parses JSON text at 250 MB/s, so it is hard to see\n** how JSONB might improve on that.)\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)\n#if !defined(SQLITEINT_H)\n/* #include \"sqlite3ext.h\" */\n#endif\nSQLITE_EXTENSION_INIT1\n/* #include <assert.h> */\n/* #include <string.h> */\n/* #include <stdlib.h> */\n/* #include <stdarg.h> */\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef LARGEST_INT64\n# define LARGEST_INT64  (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)\n#endif\n\n/*\n** Versions of isspace(), isalnum() and isdigit() to which it is safe\n** to pass signed char values.\n*/\n#ifdef sqlite3Isdigit\n   /* Use the SQLite core versions if this routine is part of the\n   ** SQLite amalgamation */\n#  define safe_isdigit(x)  sqlite3Isdigit(x)\n#  define safe_isalnum(x)  sqlite3Isalnum(x)\n#  define safe_isxdigit(x) sqlite3Isxdigit(x)\n#else\n   /* Use the standard library for separate compilation */\n#include <ctype.h>  /* amalgamator: keep */\n#  define safe_isdigit(x)  isdigit((unsigned char)(x))\n#  define safe_isalnum(x)  isalnum((unsigned char)(x))\n#  define safe_isxdigit(x) isxdigit((unsigned char)(x))\n#endif\n\n/*\n** Growing our own isspace() routine this way is twice as fast as\n** the library isspace() function, resulting in a 7% overall performance\n** increase for the parser.  (Ubuntu14.10 gcc 4.8.4 x64 with -Os).\n*/\nstatic const char jsonIsSpace[] = {\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 1, 1, 0, 0, 1, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  1, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,     0, 0, 0, 0, 0, 0, 0, 0,\n};\n#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])\n\n#ifndef SQLITE_AMALGAMATION\n  /* Unsigned integer types.  These are already defined in the sqliteInt.h,\n  ** but the definitions need to be repeated for separate compilation. */\n  typedef sqlite3_uint64 u64;\n  typedef unsigned int u32;\n  typedef unsigned short int u16;\n  typedef unsigned char u8;\n#endif\n\n/* Objects */\ntypedef struct JsonString JsonString;\ntypedef struct JsonNode JsonNode;\ntypedef struct JsonParse JsonParse;\n\n/* An instance of this object represents a JSON string\n** under construction.  Really, this is a generic string accumulator\n** that can be and is used to create strings other than JSON.\n*/\nstruct JsonString {\n  sqlite3_context *pCtx;   /* Function context - put error messages here */\n  char *zBuf;              /* Append JSON content here */\n  u64 nAlloc;              /* Bytes of storage available in zBuf[] */\n  u64 nUsed;               /* Bytes of zBuf[] currently used */\n  u8 bStatic;              /* True if zBuf is static space */\n  u8 bErr;                 /* True if an error has been encountered */\n  char zSpace[100];        /* Initial static space */\n};\n\n/* JSON type values\n*/\n#define JSON_NULL     0\n#define JSON_TRUE     1\n#define JSON_FALSE    2\n#define JSON_INT      3\n#define JSON_REAL     4\n#define JSON_STRING   5\n#define JSON_ARRAY    6\n#define JSON_OBJECT   7\n\n/* The \"subtype\" set for JSON values */\n#define JSON_SUBTYPE  74    /* Ascii for \"J\" */\n\n/*\n** Names of the various JSON types:\n*/\nstatic const char * const jsonType[] = {\n  \"null\", \"true\", \"false\", \"integer\", \"real\", \"text\", \"array\", \"object\"\n};\n\n/* Bit values for the JsonNode.jnFlag field\n*/\n#define JNODE_RAW     0x01         /* Content is raw, not JSON encoded */\n#define JNODE_ESCAPE  0x02         /* Content is text with \\ escapes */\n#define JNODE_REMOVE  0x04         /* Do not output */\n#define JNODE_REPLACE 0x08         /* Replace with JsonNode.u.iReplace */\n#define JNODE_PATCH   0x10         /* Patch with JsonNode.u.pPatch */\n#define JNODE_APPEND  0x20         /* More ARRAY/OBJECT entries at u.iAppend */\n#define JNODE_LABEL   0x40         /* Is a label of an object */\n\n\n/* A single node of parsed JSON\n*/\nstruct JsonNode {\n  u8 eType;              /* One of the JSON_ type values */\n  u8 jnFlags;            /* JNODE flags */\n  u32 n;                 /* Bytes of content, or number of sub-nodes */\n  union {\n    const char *zJContent; /* Content for INT, REAL, and STRING */\n    u32 iAppend;           /* More terms for ARRAY and OBJECT */\n    u32 iKey;              /* Key for ARRAY objects in json_tree() */\n    u32 iReplace;          /* Replacement content for JNODE_REPLACE */\n    JsonNode *pPatch;      /* Node chain of patch for JNODE_PATCH */\n  } u;\n};\n\n/* A completely parsed JSON string\n*/\nstruct JsonParse {\n  u32 nNode;         /* Number of slots of aNode[] used */\n  u32 nAlloc;        /* Number of slots of aNode[] allocated */\n  JsonNode *aNode;   /* Array of nodes containing the parse */\n  const char *zJson; /* Original JSON string */\n  u32 *aUp;          /* Index of parent of each node */\n  u8 oom;            /* Set to true if out of memory */\n  u8 nErr;           /* Number of errors seen */\n  u16 iDepth;        /* Nesting depth */\n  int nJson;         /* Length of the zJson string in bytes */\n};\n\n/*\n** Maximum nesting depth of JSON for this implementation.\n**\n** This limit is needed to avoid a stack overflow in the recursive\n** descent parser.  A depth of 2000 is far deeper than any sane JSON\n** should go.\n*/\n#define JSON_MAX_DEPTH  2000\n\n/**************************************************************************\n** Utility routines for dealing with JsonString objects\n**************************************************************************/\n\n/* Set the JsonString object to an empty string\n*/\nstatic void jsonZero(JsonString *p){\n  p->zBuf = p->zSpace;\n  p->nAlloc = sizeof(p->zSpace);\n  p->nUsed = 0;\n  p->bStatic = 1;\n}\n\n/* Initialize the JsonString object\n*/\nstatic void jsonInit(JsonString *p, sqlite3_context *pCtx){\n  p->pCtx = pCtx;\n  p->bErr = 0;\n  jsonZero(p);\n}\n\n\n/* Free all allocated memory and reset the JsonString object back to its\n** initial state.\n*/\nstatic void jsonReset(JsonString *p){\n  if( !p->bStatic ) sqlite3_free(p->zBuf);\n  jsonZero(p);\n}\n\n\n/* Report an out-of-memory (OOM) condition \n*/\nstatic void jsonOom(JsonString *p){\n  p->bErr = 1;\n  sqlite3_result_error_nomem(p->pCtx);\n  jsonReset(p);\n}\n\n/* Enlarge pJson->zBuf so that it can hold at least N more bytes.\n** Return zero on success.  Return non-zero on an OOM error\n*/\nstatic int jsonGrow(JsonString *p, u32 N){\n  u64 nTotal = N<p->nAlloc ? p->nAlloc*2 : p->nAlloc+N+10;\n  char *zNew;\n  if( p->bStatic ){\n    if( p->bErr ) return 1;\n    zNew = sqlite3_malloc64(nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    memcpy(zNew, p->zBuf, (size_t)p->nUsed);\n    p->zBuf = zNew;\n    p->bStatic = 0;\n  }else{\n    zNew = sqlite3_realloc64(p->zBuf, nTotal);\n    if( zNew==0 ){\n      jsonOom(p);\n      return SQLITE_NOMEM;\n    }\n    p->zBuf = zNew;\n  }\n  p->nAlloc = nTotal;\n  return SQLITE_OK;\n}\n\n/* Append N bytes from zIn onto the end of the JsonString string.\n*/\nstatic void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){\n  if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;\n  memcpy(p->zBuf+p->nUsed, zIn, N);\n  p->nUsed += N;\n}\n\n/* Append formatted text (not to exceed N bytes) to the JsonString.\n*/\nstatic void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){\n  va_list ap;\n  if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return;\n  va_start(ap, zFormat);\n  sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap);\n  va_end(ap);\n  p->nUsed += (int)strlen(p->zBuf+p->nUsed);\n}\n\n/* Append a single character\n*/\nstatic void jsonAppendChar(JsonString *p, char c){\n  if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return;\n  p->zBuf[p->nUsed++] = c;\n}\n\n/* Append a comma separator to the output buffer, if the previous\n** character is not '[' or '{'.\n*/\nstatic void jsonAppendSeparator(JsonString *p){\n  char c;\n  if( p->nUsed==0 ) return;\n  c = p->zBuf[p->nUsed-1];\n  if( c!='[' && c!='{' ) jsonAppendChar(p, ',');\n}\n\n/* Append the N-byte string in zIn to the end of the JsonString string\n** under construction.  Enclose the string in \"...\" and escape\n** any double-quotes or backslash characters contained within the\n** string.\n*/\nstatic void jsonAppendString(JsonString *p, const char *zIn, u32 N){\n  u32 i;\n  if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return;\n  p->zBuf[p->nUsed++] = '\"';\n  for(i=0; i<N; i++){\n    unsigned char c = ((unsigned const char*)zIn)[i];\n    if( c=='\"' || c=='\\\\' ){\n      json_simple_escape:\n      if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n    }else if( c<=0x1f ){\n      static const char aSpecial[] = {\n         0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0,\n         0, 0, 0, 0, 0, 0, 0, 0,   0,   0,   0, 0,   0,   0, 0, 0\n      };\n      assert( sizeof(aSpecial)==32 );\n      assert( aSpecial['\\b']=='b' );\n      assert( aSpecial['\\f']=='f' );\n      assert( aSpecial['\\n']=='n' );\n      assert( aSpecial['\\r']=='r' );\n      assert( aSpecial['\\t']=='t' );\n      if( aSpecial[c] ){\n        c = aSpecial[c];\n        goto json_simple_escape;\n      }\n      if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return;\n      p->zBuf[p->nUsed++] = '\\\\';\n      p->zBuf[p->nUsed++] = 'u';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0';\n      p->zBuf[p->nUsed++] = '0' + (c>>4);\n      c = \"0123456789abcdef\"[c&0xf];\n    }\n    p->zBuf[p->nUsed++] = c;\n  }\n  p->zBuf[p->nUsed++] = '\"';\n  assert( p->nUsed<p->nAlloc );\n}\n\n/*\n** Append a function parameter value to the JSON string under \n** construction.\n*/\nstatic void jsonAppendValue(\n  JsonString *p,                 /* Append to this JSON string */\n  sqlite3_value *pValue          /* Value to append */\n){\n  switch( sqlite3_value_type(pValue) ){\n    case SQLITE_NULL: {\n      jsonAppendRaw(p, \"null\", 4);\n      break;\n    }\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      jsonAppendRaw(p, z, n);\n      break;\n    }\n    case SQLITE_TEXT: {\n      const char *z = (const char*)sqlite3_value_text(pValue);\n      u32 n = (u32)sqlite3_value_bytes(pValue);\n      if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){\n        jsonAppendRaw(p, z, n);\n      }else{\n        jsonAppendString(p, z, n);\n      }\n      break;\n    }\n    default: {\n      if( p->bErr==0 ){\n        sqlite3_result_error(p->pCtx, \"JSON cannot hold BLOB values\", -1);\n        p->bErr = 2;\n        jsonReset(p);\n      }\n      break;\n    }\n  }\n}\n\n\n/* Make the JSON in p the result of the SQL function.\n*/\nstatic void jsonResult(JsonString *p){\n  if( p->bErr==0 ){\n    sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, \n                          p->bStatic ? SQLITE_TRANSIENT : sqlite3_free,\n                          SQLITE_UTF8);\n    jsonZero(p);\n  }\n  assert( p->bStatic );\n}\n\n/**************************************************************************\n** Utility routines for dealing with JsonNode and JsonParse objects\n**************************************************************************/\n\n/*\n** Return the number of consecutive JsonNode slots need to represent\n** the parsed JSON at pNode.  The minimum answer is 1.  For ARRAY and\n** OBJECT types, the number might be larger.\n**\n** Appended elements are not counted.  The value returned is the number\n** by which the JsonNode counter should increment in order to go to the\n** next peer value.\n*/\nstatic u32 jsonNodeSize(JsonNode *pNode){\n  return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1;\n}\n\n/*\n** Reclaim all memory allocated by a JsonParse object.  But do not\n** delete the JsonParse object itself.\n*/\nstatic void jsonParseReset(JsonParse *pParse){\n  sqlite3_free(pParse->aNode);\n  pParse->aNode = 0;\n  pParse->nNode = 0;\n  pParse->nAlloc = 0;\n  sqlite3_free(pParse->aUp);\n  pParse->aUp = 0;\n}\n\n/*\n** Free a JsonParse object that was obtained from sqlite3_malloc().\n*/\nstatic void jsonParseFree(JsonParse *pParse){\n  jsonParseReset(pParse);\n  sqlite3_free(pParse);\n}\n\n/*\n** Convert the JsonNode pNode into a pure JSON string and\n** append to pOut.  Subsubstructure is also included.  Return\n** the number of JsonNode objects that are encoded.\n*/\nstatic void jsonRenderNode(\n  JsonNode *pNode,               /* The node to render */\n  JsonString *pOut,              /* Write JSON here */\n  sqlite3_value **aReplace       /* Replacement values */\n){\n  if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){\n    if( pNode->jnFlags & JNODE_REPLACE ){\n      jsonAppendValue(pOut, aReplace[pNode->u.iReplace]);\n      return;\n    }\n    pNode = pNode->u.pPatch;\n  }\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      jsonAppendRaw(pOut, \"null\", 4);\n      break;\n    }\n    case JSON_TRUE: {\n      jsonAppendRaw(pOut, \"true\", 4);\n      break;\n    }\n    case JSON_FALSE: {\n      jsonAppendRaw(pOut, \"false\", 5);\n      break;\n    }\n    case JSON_STRING: {\n      if( pNode->jnFlags & JNODE_RAW ){\n        jsonAppendString(pOut, pNode->u.zJContent, pNode->n);\n        break;\n      }\n      /* Fall through into the next case */\n    }\n    case JSON_REAL:\n    case JSON_INT: {\n      jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n);\n      break;\n    }\n    case JSON_ARRAY: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '[');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n          }\n          j += jsonNodeSize(&pNode[j]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, ']');\n      break;\n    }\n    case JSON_OBJECT: {\n      u32 j = 1;\n      jsonAppendChar(pOut, '{');\n      for(;;){\n        while( j<=pNode->n ){\n          if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){\n            jsonAppendSeparator(pOut);\n            jsonRenderNode(&pNode[j], pOut, aReplace);\n            jsonAppendChar(pOut, ':');\n            jsonRenderNode(&pNode[j+1], pOut, aReplace);\n          }\n          j += 1 + jsonNodeSize(&pNode[j+1]);\n        }\n        if( (pNode->jnFlags & JNODE_APPEND)==0 ) break;\n        pNode = &pNode[pNode->u.iAppend];\n        j = 1;\n      }\n      jsonAppendChar(pOut, '}');\n      break;\n    }\n  }\n}\n\n/*\n** Return a JsonNode and all its descendents as a JSON string.\n*/\nstatic void jsonReturnJson(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  JsonString s;\n  jsonInit(&s, pCtx);\n  jsonRenderNode(pNode, &s, aReplace);\n  jsonResult(&s);\n  sqlite3_result_subtype(pCtx, JSON_SUBTYPE);\n}\n\n/*\n** Make the JsonNode the return value of the function.\n*/\nstatic void jsonReturn(\n  JsonNode *pNode,            /* Node to return */\n  sqlite3_context *pCtx,      /* Return value for this function */\n  sqlite3_value **aReplace    /* Array of replacement values */\n){\n  switch( pNode->eType ){\n    default: {\n      assert( pNode->eType==JSON_NULL );\n      sqlite3_result_null(pCtx);\n      break;\n    }\n    case JSON_TRUE: {\n      sqlite3_result_int(pCtx, 1);\n      break;\n    }\n    case JSON_FALSE: {\n      sqlite3_result_int(pCtx, 0);\n      break;\n    }\n    case JSON_INT: {\n      sqlite3_int64 i = 0;\n      const char *z = pNode->u.zJContent;\n      if( z[0]=='-' ){ z++; }\n      while( z[0]>='0' && z[0]<='9' ){\n        unsigned v = *(z++) - '0';\n        if( i>=LARGEST_INT64/10 ){\n          if( i>LARGEST_INT64/10 ) goto int_as_real;\n          if( z[0]>='0' && z[0]<='9' ) goto int_as_real;\n          if( v==9 ) goto int_as_real;\n          if( v==8 ){\n            if( pNode->u.zJContent[0]=='-' ){\n              sqlite3_result_int64(pCtx, SMALLEST_INT64);\n              goto int_done;\n            }else{\n              goto int_as_real;\n            }\n          }\n        }\n        i = i*10 + v;\n      }\n      if( pNode->u.zJContent[0]=='-' ){ i = -i; }\n      sqlite3_result_int64(pCtx, i);\n      int_done:\n      break;\n      int_as_real: /* fall through to real */;\n    }\n    case JSON_REAL: {\n      double r;\n#ifdef SQLITE_AMALGAMATION\n      const char *z = pNode->u.zJContent;\n      sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8);\n#else\n      r = strtod(pNode->u.zJContent, 0);\n#endif\n      sqlite3_result_double(pCtx, r);\n      break;\n    }\n    case JSON_STRING: {\n#if 0 /* Never happens because JNODE_RAW is only set by json_set(),\n      ** json_insert() and json_replace() and those routines do not\n      ** call jsonReturn() */\n      if( pNode->jnFlags & JNODE_RAW ){\n        sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n,\n                            SQLITE_TRANSIENT);\n      }else \n#endif\n      assert( (pNode->jnFlags & JNODE_RAW)==0 );\n      if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){\n        /* JSON formatted without any backslash-escapes */\n        sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2,\n                            SQLITE_TRANSIENT);\n      }else{\n        /* Translate JSON formatted string into raw text */\n        u32 i;\n        u32 n = pNode->n;\n        const char *z = pNode->u.zJContent;\n        char *zOut;\n        u32 j;\n        zOut = sqlite3_malloc( n+1 );\n        if( zOut==0 ){\n          sqlite3_result_error_nomem(pCtx);\n          break;\n        }\n        for(i=1, j=0; i<n-1; i++){\n          char c = z[i];\n          if( c!='\\\\' ){\n            zOut[j++] = c;\n          }else{\n            c = z[++i];\n            if( c=='u' ){\n              u32 v = 0, k;\n              for(k=0; k<4; i++, k++){\n                assert( i<n-2 );\n                c = z[i+1];\n                assert( safe_isxdigit(c) );\n                if( c<='9' ) v = v*16 + c - '0';\n                else if( c<='F' ) v = v*16 + c - 'A' + 10;\n                else v = v*16 + c - 'a' + 10;\n              }\n              if( v==0 ) break;\n              if( v<=0x7f ){\n                zOut[j++] = (char)v;\n              }else if( v<=0x7ff ){\n                zOut[j++] = (char)(0xc0 | (v>>6));\n                zOut[j++] = 0x80 | (v&0x3f);\n              }else{\n                zOut[j++] = (char)(0xe0 | (v>>12));\n                zOut[j++] = 0x80 | ((v>>6)&0x3f);\n                zOut[j++] = 0x80 | (v&0x3f);\n              }\n            }else{\n              if( c=='b' ){\n                c = '\\b';\n              }else if( c=='f' ){\n                c = '\\f';\n              }else if( c=='n' ){\n                c = '\\n';\n              }else if( c=='r' ){\n                c = '\\r';\n              }else if( c=='t' ){\n                c = '\\t';\n              }\n              zOut[j++] = c;\n            }\n          }\n        }\n        zOut[j] = 0;\n        sqlite3_result_text(pCtx, zOut, j, sqlite3_free);\n      }\n      break;\n    }\n    case JSON_ARRAY:\n    case JSON_OBJECT: {\n      jsonReturnJson(pNode, pCtx, aReplace);\n      break;\n    }\n  }\n}\n\n/* Forward reference */\nstatic int jsonParseAddNode(JsonParse*,u32,u32,const char*);\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define JSON_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define JSON_NOINLINE  __declspec(noinline)\n#else\n#  define JSON_NOINLINE\n#endif\n\n\nstatic JSON_NOINLINE int jsonParseAddNodeExpand(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  u32 nNew;\n  JsonNode *pNew;\n  assert( pParse->nNode>=pParse->nAlloc );\n  if( pParse->oom ) return -1;\n  nNew = pParse->nAlloc*2 + 10;\n  pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);\n  if( pNew==0 ){\n    pParse->oom = 1;\n    return -1;\n  }\n  pParse->nAlloc = nNew;\n  pParse->aNode = pNew;\n  assert( pParse->nNode<pParse->nAlloc );\n  return jsonParseAddNode(pParse, eType, n, zContent);\n}\n\n/*\n** Create a new JsonNode instance based on the arguments and append that\n** instance to the JsonParse.  Return the index in pParse->aNode[] of the\n** new node, or -1 if a memory allocation fails.\n*/\nstatic int jsonParseAddNode(\n  JsonParse *pParse,        /* Append the node to this object */\n  u32 eType,                /* Node type */\n  u32 n,                    /* Content size or sub-node count */\n  const char *zContent      /* Content */\n){\n  JsonNode *p;\n  if( pParse->nNode>=pParse->nAlloc ){\n    return jsonParseAddNodeExpand(pParse, eType, n, zContent);\n  }\n  p = &pParse->aNode[pParse->nNode];\n  p->eType = (u8)eType;\n  p->jnFlags = 0;\n  p->n = n;\n  p->u.zJContent = zContent;\n  return pParse->nNode++;\n}\n\n/*\n** Return true if z[] begins with 4 (or more) hexadecimal digits\n*/\nstatic int jsonIs4Hex(const char *z){\n  int i;\n  for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;\n  return 1;\n}\n\n/*\n** Parse a single JSON value which begins at pParse->zJson[i].  Return the\n** index of the first character past the end of the value parsed.\n**\n** Return negative for a syntax error.  Special cases:  return -2 if the\n** first non-whitespace character is '}' and return -3 if the first\n** non-whitespace character is ']'.\n*/\nstatic int jsonParseValue(JsonParse *pParse, u32 i){\n  char c;\n  u32 j;\n  int iThis;\n  int x;\n  JsonNode *pNode;\n  const char *z = pParse->zJson;\n  while( safe_isspace(z[i]) ){ i++; }\n  if( (c = z[i])=='{' ){\n    /* Parse object */\n    iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      if( x<0 ){\n        pParse->iDepth--;\n        if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      if( pParse->oom ) return -1;\n      pNode = &pParse->aNode[pParse->nNode-1];\n      if( pNode->eType!=JSON_STRING ) return -1;\n      pNode->jnFlags |= JNODE_LABEL;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      if( z[j]!=':' ) return -1;\n      j++;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ) return -1;\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!='}' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='[' ){\n    /* Parse array */\n    iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n    if( iThis<0 ) return -1;\n    for(j=i+1;;j++){\n      while( safe_isspace(z[j]) ){ j++; }\n      if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;\n      x = jsonParseValue(pParse, j);\n      pParse->iDepth--;\n      if( x<0 ){\n        if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1;\n        return -1;\n      }\n      j = x;\n      while( safe_isspace(z[j]) ){ j++; }\n      c = z[j];\n      if( c==',' ) continue;\n      if( c!=']' ) return -1;\n      break;\n    }\n    pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1;\n    return j+1;\n  }else if( c=='\"' ){\n    /* Parse string */\n    u8 jnFlags = 0;\n    j = i+1;\n    for(;;){\n      c = z[j];\n      if( (c & ~0x1f)==0 ){\n        /* Control characters are not allowed in strings */\n        return -1;\n      }\n      if( c=='\\\\' ){\n        c = z[++j];\n        if( c=='\"' || c=='\\\\' || c=='/' || c=='b' || c=='f'\n           || c=='n' || c=='r' || c=='t'\n           || (c=='u' && jsonIs4Hex(z+j+1)) ){\n          jnFlags = JNODE_ESCAPE;\n        }else{\n          return -1;\n        }\n      }else if( c=='\"' ){\n        break;\n      }\n      j++;\n    }\n    jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]);\n    if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags;\n    return j+1;\n  }else if( c=='n'\n         && strncmp(z+i,\"null\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return i+4;\n  }else if( c=='t'\n         && strncmp(z+i,\"true\",4)==0\n         && !safe_isalnum(z[i+4]) ){\n    jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n    return i+4;\n  }else if( c=='f'\n         && strncmp(z+i,\"false\",5)==0\n         && !safe_isalnum(z[i+5]) ){\n    jsonParseAddNode(pParse, JSON_FALSE, 0, 0);\n    return i+5;\n  }else if( c=='-' || (c>='0' && c<='9') ){\n    /* Parse number */\n    u8 seenDP = 0;\n    u8 seenE = 0;\n    assert( '-' < '0' );\n    if( c<='0' ){\n      j = c=='-' ? i+1 : i;\n      if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1;\n    }\n    j = i+1;\n    for(;; j++){\n      c = z[j];\n      if( c>='0' && c<='9' ) continue;\n      if( c=='.' ){\n        if( z[j-1]=='-' ) return -1;\n        if( seenDP ) return -1;\n        seenDP = 1;\n        continue;\n      }\n      if( c=='e' || c=='E' ){\n        if( z[j-1]<'0' ) return -1;\n        if( seenE ) return -1;\n        seenDP = seenE = 1;\n        c = z[j+1];\n        if( c=='+' || c=='-' ){\n          j++;\n          c = z[j+1];\n        }\n        if( c<'0' || c>'9' ) return -1;\n        continue;\n      }\n      break;\n    }\n    if( z[j-1]<'0' ) return -1;\n    jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT,\n                        j - i, &z[i]);\n    return j;\n  }else if( c=='}' ){\n    return -2;  /* End of {...} */\n  }else if( c==']' ){\n    return -3;  /* End of [...] */\n  }else if( c==0 ){\n    return 0;   /* End of file */\n  }else{\n    return -1;  /* Syntax error */\n  }\n}\n\n/*\n** Parse a complete JSON string.  Return 0 on success or non-zero if there\n** are any errors.  If an error occurs, free all memory associated with\n** pParse.\n**\n** pParse is uninitialized when this routine is called.\n*/\nstatic int jsonParse(\n  JsonParse *pParse,           /* Initialize and fill this JsonParse object */\n  sqlite3_context *pCtx,       /* Report errors here */\n  const char *zJson            /* Input JSON text to be parsed */\n){\n  int i;\n  memset(pParse, 0, sizeof(*pParse));\n  if( zJson==0 ) return 1;\n  pParse->zJson = zJson;\n  i = jsonParseValue(pParse, 0);\n  if( pParse->oom ) i = -1;\n  if( i>0 ){\n    assert( pParse->iDepth==0 );\n    while( safe_isspace(zJson[i]) ) i++;\n    if( zJson[i] ) i = -1;\n  }\n  if( i<=0 ){\n    if( pCtx!=0 ){\n      if( pParse->oom ){\n        sqlite3_result_error_nomem(pCtx);\n      }else{\n        sqlite3_result_error(pCtx, \"malformed JSON\", -1);\n      }\n    }\n    jsonParseReset(pParse);\n    return 1;\n  }\n  return 0;\n}\n\n/* Mark node i of pParse as being a child of iParent.  Call recursively\n** to fill in all the descendants of node i.\n*/\nstatic void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){\n  JsonNode *pNode = &pParse->aNode[i];\n  u32 j;\n  pParse->aUp[i] = iParent;\n  switch( pNode->eType ){\n    case JSON_ARRAY: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){\n        jsonParseFillInParentage(pParse, i+j, i);\n      }\n      break;\n    }\n    case JSON_OBJECT: {\n      for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){\n        pParse->aUp[i+j] = i;\n        jsonParseFillInParentage(pParse, i+j+1, i);\n      }\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n}\n\n/*\n** Compute the parentage of all nodes in a completed parse.\n*/\nstatic int jsonParseFindParents(JsonParse *pParse){\n  u32 *aUp;\n  assert( pParse->aUp==0 );\n  aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );\n  if( aUp==0 ){\n    pParse->oom = 1;\n    return SQLITE_NOMEM;\n  }\n  jsonParseFillInParentage(pParse, 0, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Magic number used for the JSON parse cache in sqlite3_get_auxdata()\n*/\n#define JSON_CACHE_ID  (-429938)\n\n/*\n** Obtain a complete parse of the JSON found in the first argument\n** of the argv array.  Use the sqlite3_get_auxdata() cache for this\n** parse if it is available.  If the cache is not available or if it\n** is no longer valid, parse the JSON again and return the new parse,\n** and also register the new parse so that it will be available for\n** future sqlite3_get_auxdata() calls.\n*/\nstatic JsonParse *jsonParseCached(\n  sqlite3_context *pCtx,\n  sqlite3_value **argv\n){\n  const char *zJson = (const char*)sqlite3_value_text(argv[0]);\n  int nJson = sqlite3_value_bytes(argv[0]);\n  JsonParse *p;\n  if( zJson==0 ) return 0;\n  p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);\n  if( p && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){\n    p->nErr = 0;\n    return p; /* The cached entry matches, so return it */\n  }\n  p = sqlite3_malloc( sizeof(*p) + nJson + 1 );\n  if( p==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return 0;\n  }\n  memset(p, 0, sizeof(*p));\n  p->zJson = (char*)&p[1];\n  memcpy((char*)p->zJson, zJson, nJson+1);\n  if( jsonParse(p, pCtx, p->zJson) ){\n    sqlite3_free(p);\n    return 0;\n  }\n  p->nJson = nJson;\n  sqlite3_set_auxdata(pCtx, JSON_CACHE_ID, p, (void(*)(void*))jsonParseFree);\n  return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID);\n}\n\n/*\n** Compare the OBJECT label at pNode against zKey,nKey.  Return true on\n** a match.\n*/\nstatic int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){\n  if( pNode->jnFlags & JNODE_RAW ){\n    if( pNode->n!=nKey ) return 0;\n    return strncmp(pNode->u.zJContent, zKey, nKey)==0;\n  }else{\n    if( pNode->n!=nKey+2 ) return 0;\n    return strncmp(pNode->u.zJContent+1, zKey, nKey)==0;\n  }\n}\n\n/* forward declaration */\nstatic JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**);\n\n/*\n** Search along zPath to find the node specified.  Return a pointer\n** to that node, or NULL if zPath is malformed or if there is no such\n** node.\n**\n** If pApnd!=0, then try to append new nodes to complete zPath if it is\n** possible to do so and if no existing node corresponds to zPath.  If\n** new nodes are appended *pApnd is set to 1.\n*/\nstatic JsonNode *jsonLookupStep(\n  JsonParse *pParse,      /* The JSON to search */\n  u32 iRoot,              /* Begin the search at this node */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  const char **pzErr      /* Make *pzErr point to any syntax error in zPath */\n){\n  u32 i, j, nKey;\n  const char *zKey;\n  JsonNode *pRoot = &pParse->aNode[iRoot];\n  if( zPath[0]==0 ) return pRoot;\n  if( zPath[0]=='.' ){\n    if( pRoot->eType!=JSON_OBJECT ) return 0;\n    zPath++;\n    if( zPath[0]=='\"' ){\n      zKey = zPath + 1;\n      for(i=1; zPath[i] && zPath[i]!='\"'; i++){}\n      nKey = i-1;\n      if( zPath[i] ){\n        i++;\n      }else{\n        *pzErr = zPath;\n        return 0;\n      }\n    }else{\n      zKey = zPath;\n      for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}\n      nKey = i;\n    }\n    if( nKey==0 ){\n      *pzErr = zPath;\n      return 0;\n    }\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n ){\n        if( jsonLabelCompare(pRoot+j, zKey, nKey) ){\n          return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr);\n        }\n        j++;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( pApnd ){\n      u32 iStart, iLabel;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      iLabel = jsonParseAddNode(pParse, JSON_STRING, i, zPath);\n      zPath += i;\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n        pParse->aNode[iLabel].jnFlags |= JNODE_RAW;\n      }\n      return pNode;\n    }\n  }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){\n    if( pRoot->eType!=JSON_ARRAY ) return 0;\n    i = 0;\n    j = 1;\n    while( safe_isdigit(zPath[j]) ){\n      i = i*10 + zPath[j] - '0';\n      j++;\n    }\n    if( zPath[j]!=']' ){\n      *pzErr = zPath;\n      return 0;\n    }\n    zPath += j + 1;\n    j = 1;\n    for(;;){\n      while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){\n        if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--;\n        j += jsonNodeSize(&pRoot[j]);\n      }\n      if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break;\n      iRoot += pRoot->u.iAppend;\n      pRoot = &pParse->aNode[iRoot];\n      j = 1;\n    }\n    if( j<=pRoot->n ){\n      return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr);\n    }\n    if( i==0 && pApnd ){\n      u32 iStart;\n      JsonNode *pNode;\n      iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0);\n      pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr);\n      if( pParse->oom ) return 0;\n      if( pNode ){\n        pRoot = &pParse->aNode[iRoot];\n        pRoot->u.iAppend = iStart - iRoot;\n        pRoot->jnFlags |= JNODE_APPEND;\n      }\n      return pNode;\n    }\n  }else{\n    *pzErr = zPath;\n  }\n  return 0;\n}\n\n/*\n** Append content to pParse that will complete zPath.  Return a pointer\n** to the inserted node, or return NULL if the append fails.\n*/\nstatic JsonNode *jsonLookupAppend(\n  JsonParse *pParse,     /* Append content to the JSON parse */\n  const char *zPath,     /* Description of content to append */\n  int *pApnd,            /* Set this flag to 1 */\n  const char **pzErr     /* Make this point to any syntax error */\n){\n  *pApnd = 1;\n  if( zPath[0]==0 ){\n    jsonParseAddNode(pParse, JSON_NULL, 0, 0);\n    return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1];\n  }\n  if( zPath[0]=='.' ){\n    jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);\n  }else if( strncmp(zPath,\"[0]\",3)==0 ){\n    jsonParseAddNode(pParse, JSON_ARRAY, 0, 0);\n  }else{\n    return 0;\n  }\n  if( pParse->oom ) return 0;\n  return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr);\n}\n\n/*\n** Return the text of a syntax error message on a JSON path.  Space is\n** obtained from sqlite3_malloc().\n*/\nstatic char *jsonPathSyntaxError(const char *zErr){\n  return sqlite3_mprintf(\"JSON path error near '%q'\", zErr);\n}\n\n/*\n** Do a node lookup using zPath.  Return a pointer to the node on success.\n** Return NULL if not found or if there is an error.\n**\n** On an error, write an error message into pCtx and increment the\n** pParse->nErr counter.\n**\n** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if\n** nodes are appended.\n*/\nstatic JsonNode *jsonLookup(\n  JsonParse *pParse,      /* The JSON to search */\n  const char *zPath,      /* The path to search */\n  int *pApnd,             /* Append nodes to complete path if not NULL */\n  sqlite3_context *pCtx   /* Report errors here, if not NULL */\n){\n  const char *zErr = 0;\n  JsonNode *pNode = 0;\n  char *zMsg;\n\n  if( zPath==0 ) return 0;\n  if( zPath[0]!='$' ){\n    zErr = zPath;\n    goto lookup_err;\n  }\n  zPath++;\n  pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr);\n  if( zErr==0 ) return pNode;\n\nlookup_err:\n  pParse->nErr++;\n  assert( zErr!=0 && pCtx!=0 );\n  zMsg = jsonPathSyntaxError(zErr);\n  if( zMsg ){\n    sqlite3_result_error(pCtx, zMsg, -1);\n    sqlite3_free(zMsg);\n  }else{\n    sqlite3_result_error_nomem(pCtx);\n  }\n  return 0;\n}\n\n\n/*\n** Report the wrong number of arguments for json_insert(), json_replace()\n** or json_set().\n*/\nstatic void jsonWrongNumArgs(\n  sqlite3_context *pCtx,\n  const char *zFuncName\n){\n  char *zMsg = sqlite3_mprintf(\"json_%s() needs an odd number of arguments\",\n                               zFuncName);\n  sqlite3_result_error(pCtx, zMsg, -1);\n  sqlite3_free(zMsg);     \n}\n\n/*\n** Mark all NULL entries in the Object passed in as JNODE_REMOVE.\n*/\nstatic void jsonRemoveAllNulls(JsonNode *pNode){\n  int i, n;\n  assert( pNode->eType==JSON_OBJECT );\n  n = pNode->n;\n  for(i=2; i<=n; i += jsonNodeSize(&pNode[i])+1){\n    switch( pNode[i].eType ){\n      case JSON_NULL:\n        pNode[i].jnFlags |= JNODE_REMOVE;\n        break;\n      case JSON_OBJECT:\n        jsonRemoveAllNulls(&pNode[i]);\n        break;\n    }\n  }\n}\n\n\n/****************************************************************************\n** SQL functions used for testing and debugging\n****************************************************************************/\n\n#ifdef SQLITE_DEBUG\n/*\n** The json_parse(JSON) function returns a string which describes\n** a parse of the JSON provided.  Or it returns NULL if JSON is not\n** well-formed.\n*/\nstatic void jsonParseFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString s;       /* Output string - not real JSON */\n  JsonParse x;        /* The parse */\n  u32 i;\n\n  assert( argc==1 );\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  jsonParseFindParents(&x);\n  jsonInit(&s, ctx);\n  for(i=0; i<x.nNode; i++){\n    const char *zType;\n    if( x.aNode[i].jnFlags & JNODE_LABEL ){\n      assert( x.aNode[i].eType==JSON_STRING );\n      zType = \"label\";\n    }else{\n      zType = jsonType[x.aNode[i].eType];\n    }\n    jsonPrintf(100, &s,\"node %3u: %7s n=%-4d up=%-4d\",\n               i, zType, x.aNode[i].n, x.aUp[i]);\n    if( x.aNode[i].u.zJContent!=0 ){\n      jsonAppendRaw(&s, \" \", 1);\n      jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n);\n    }\n    jsonAppendRaw(&s, \"\\n\", 1);\n  }\n  jsonParseReset(&x);\n  jsonResult(&s);\n}\n\n/*\n** The json_test1(JSON) function return true (1) if the input is JSON\n** text generated by another json function.  It returns (0) if the input\n** is not known to be JSON.\n*/\nstatic void jsonTest1Func(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAM(argc);\n  sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);\n}\n#endif /* SQLITE_DEBUG */\n\n/****************************************************************************\n** Scalar SQL function implementations\n****************************************************************************/\n\n/*\n** Implementation of the json_QUOTE(VALUE) function.  Return a JSON value\n** corresponding to the SQL value input.  Mostly this means putting \n** double-quotes around strings and returning the unquoted string \"null\"\n** when given a NULL input.\n*/\nstatic void jsonQuoteFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString jx;\n  UNUSED_PARAM(argc);\n\n  jsonInit(&jx, ctx);\n  jsonAppendValue(&jx, argv[0]);\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n/*\n** Implementation of the json_array(VALUE,...) function.  Return a JSON\n** array that contains all values given in arguments.  Or if any argument\n** is a BLOB, throw an error.\n*/\nstatic void jsonArrayFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=0; i<argc; i++){\n    jsonAppendSeparator(&jx);\n    jsonAppendValue(&jx, argv[i]);\n  }\n  jsonAppendChar(&jx, ']');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_array_length(JSON)\n** json_array_length(JSON, PATH)\n**\n** Return the number of elements in the top-level JSON array.  \n** Return 0 if the input is not a well-formed JSON array.\n*/\nstatic void jsonArrayLengthFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  sqlite3_int64 n = 0;\n  u32 i;\n  JsonNode *pNode;\n\n  p = jsonParseCached(ctx, argv);\n  if( p==0 ) return;\n  assert( p->nNode );\n  if( argc==2 ){\n    const char *zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n  }else{\n    pNode = p->aNode;\n  }\n  if( pNode==0 ){\n    return;\n  }\n  if( pNode->eType==JSON_ARRAY ){\n    assert( (pNode->jnFlags & JNODE_APPEND)==0 );\n    for(i=1; i<=pNode->n; n++){\n      i += jsonNodeSize(&pNode[i]);\n    }\n  }\n  sqlite3_result_int64(ctx, n);\n}\n\n/*\n** json_extract(JSON, PATH, ...)\n**\n** Return the element described by PATH.  Return NULL if there is no\n** PATH element.  If there are multiple PATHs, then return a JSON array\n** with the result from each path.  Throw an error if the JSON or any PATH\n** is malformed.\n*/\nstatic void jsonExtractFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse *p;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  JsonString jx;\n  int i;\n\n  if( argc<2 ) return;\n  p = jsonParseCached(ctx, argv);\n  if( p==0 ) return;\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '[');\n  for(i=1; i<argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(p, zPath, 0, ctx);\n    if( p->nErr ) break;\n    if( argc>2 ){\n      jsonAppendSeparator(&jx);\n      if( pNode ){\n        jsonRenderNode(pNode, &jx, 0);\n      }else{\n        jsonAppendRaw(&jx, \"null\", 4);\n      }\n    }else if( pNode ){\n      jsonReturn(pNode, ctx, 0);\n    }\n  }\n  if( argc>2 && i==argc ){\n    jsonAppendChar(&jx, ']');\n    jsonResult(&jx);\n    sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n  }\n  jsonReset(&jx);\n}\n\n/* This is the RFC 7396 MergePatch algorithm.\n*/\nstatic JsonNode *jsonMergePatch(\n  JsonParse *pParse,   /* The JSON parser that contains the TARGET */\n  u32 iTarget,         /* Node of the TARGET in pParse */\n  JsonNode *pPatch     /* The PATCH */\n){\n  u32 i, j;\n  u32 iRoot;\n  JsonNode *pTarget;\n  if( pPatch->eType!=JSON_OBJECT ){\n    return pPatch;\n  }\n  assert( iTarget>=0 && iTarget<pParse->nNode );\n  pTarget = &pParse->aNode[iTarget];\n  assert( (pPatch->jnFlags & JNODE_APPEND)==0 );\n  if( pTarget->eType!=JSON_OBJECT ){\n    jsonRemoveAllNulls(pPatch);\n    return pPatch;\n  }\n  iRoot = iTarget;\n  for(i=1; i<pPatch->n; i += jsonNodeSize(&pPatch[i+1])+1){\n    u32 nKey;\n    const char *zKey;\n    assert( pPatch[i].eType==JSON_STRING );\n    assert( pPatch[i].jnFlags & JNODE_LABEL );\n    nKey = pPatch[i].n;\n    zKey = pPatch[i].u.zJContent;\n    assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n    for(j=1; j<pTarget->n; j += jsonNodeSize(&pTarget[j+1])+1 ){\n      assert( pTarget[j].eType==JSON_STRING );\n      assert( pTarget[j].jnFlags & JNODE_LABEL );\n      assert( (pPatch[i].jnFlags & JNODE_RAW)==0 );\n      if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){\n        if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break;\n        if( pPatch[i+1].eType==JSON_NULL ){\n          pTarget[j+1].jnFlags |= JNODE_REMOVE;\n        }else{\n          JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]);\n          if( pNew==0 ) return 0;\n          pTarget = &pParse->aNode[iTarget];\n          if( pNew!=&pTarget[j+1] ){\n            pTarget[j+1].u.pPatch = pNew;\n            pTarget[j+1].jnFlags |= JNODE_PATCH;\n          }\n        }\n        break;\n      }\n    }\n    if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){\n      int iStart, iPatch;\n      iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0);\n      jsonParseAddNode(pParse, JSON_STRING, nKey, zKey);\n      iPatch = jsonParseAddNode(pParse, JSON_TRUE, 0, 0);\n      if( pParse->oom ) return 0;\n      jsonRemoveAllNulls(pPatch);\n      pTarget = &pParse->aNode[iTarget];\n      pParse->aNode[iRoot].jnFlags |= JNODE_APPEND;\n      pParse->aNode[iRoot].u.iAppend = iStart - iRoot;\n      iRoot = iStart;\n      pParse->aNode[iPatch].jnFlags |= JNODE_PATCH;\n      pParse->aNode[iPatch].u.pPatch = &pPatch[i+1];\n    }\n  }\n  return pTarget;\n}\n\n/*\n** Implementation of the json_mergepatch(JSON1,JSON2) function.  Return a JSON\n** object that is the result of running the RFC 7396 MergePatch() algorithm\n** on the two arguments.\n*/\nstatic void jsonPatchFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;     /* The JSON that is being patched */\n  JsonParse y;     /* The patch */\n  JsonNode *pResult;   /* The result of the merge */\n\n  UNUSED_PARAM(argc);\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){\n    jsonParseReset(&x);\n    return;\n  }\n  pResult = jsonMergePatch(&x, 0, y.aNode);\n  assert( pResult!=0 || x.oom );\n  if( pResult ){\n    jsonReturnJson(pResult, ctx, 0);\n  }else{\n    sqlite3_result_error_nomem(ctx);\n  }\n  jsonParseReset(&x);\n  jsonParseReset(&y);\n}\n\n\n/*\n** Implementation of the json_object(NAME,VALUE,...) function.  Return a JSON\n** object that contains all name/value given in arguments.  Or if any name\n** is not a string or if any value is a BLOB, throw an error.\n*/\nstatic void jsonObjectFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  JsonString jx;\n  const char *z;\n  u32 n;\n\n  if( argc&1 ){\n    sqlite3_result_error(ctx, \"json_object() requires an even number \"\n                                  \"of arguments\", -1);\n    return;\n  }\n  jsonInit(&jx, ctx);\n  jsonAppendChar(&jx, '{');\n  for(i=0; i<argc; i+=2){\n    if( sqlite3_value_type(argv[i])!=SQLITE_TEXT ){\n      sqlite3_result_error(ctx, \"json_object() labels must be TEXT\", -1);\n      jsonReset(&jx);\n      return;\n    }\n    jsonAppendSeparator(&jx);\n    z = (const char*)sqlite3_value_text(argv[i]);\n    n = (u32)sqlite3_value_bytes(argv[i]);\n    jsonAppendString(&jx, z, n);\n    jsonAppendChar(&jx, ':');\n    jsonAppendValue(&jx, argv[i+1]);\n  }\n  jsonAppendChar(&jx, '}');\n  jsonResult(&jx);\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n/*\n** json_remove(JSON, PATH, ...)\n**\n** Remove the named elements from JSON and return the result.  malformed\n** JSON or PATH arguments result in an error.\n*/\nstatic void jsonRemoveFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i++){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    if( zPath==0 ) goto remove_done;\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto remove_done;\n    if( pNode ) pNode->jnFlags |= JNODE_REMOVE;\n  }\n  if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){\n    jsonReturnJson(x.aNode, ctx, 0);\n  }\nremove_done:\n  jsonParseReset(&x);\n}\n\n/*\n** json_replace(JSON, PATH, VALUE, ...)\n**\n** Replace the value at PATH with VALUE.  If PATH does not already exist,\n** this routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonReplaceFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, \"replace\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n    if( x.nErr ) goto replace_err;\n    if( pNode ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\nreplace_err:\n  jsonParseReset(&x);\n}\n\n/*\n** json_set(JSON, PATH, VALUE, ...)\n**\n** Set the value at PATH to VALUE.  Create the PATH if it does not already\n** exist.  Overwrite existing values that do exist.\n** If JSON or PATH is malformed, throw an error.\n**\n** json_insert(JSON, PATH, VALUE, ...)\n**\n** Create PATH and initialize it to VALUE.  If PATH already exists, this\n** routine is a no-op.  If JSON or PATH is malformed, throw an error.\n*/\nstatic void jsonSetFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  JsonNode *pNode;\n  const char *zPath;\n  u32 i;\n  int bApnd;\n  int bIsSet = *(int*)sqlite3_user_data(ctx);\n\n  if( argc<1 ) return;\n  if( (argc&1)==0 ) {\n    jsonWrongNumArgs(ctx, bIsSet ? \"set\" : \"insert\");\n    return;\n  }\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  for(i=1; i<(u32)argc; i+=2){\n    zPath = (const char*)sqlite3_value_text(argv[i]);\n    bApnd = 0;\n    pNode = jsonLookup(&x, zPath, &bApnd, ctx);\n    if( x.oom ){\n      sqlite3_result_error_nomem(ctx);\n      goto jsonSetDone;\n    }else if( x.nErr ){\n      goto jsonSetDone;\n    }else if( pNode && (bApnd || bIsSet) ){\n      pNode->jnFlags |= (u8)JNODE_REPLACE;\n      pNode->u.iReplace = i + 1;\n    }\n  }\n  if( x.aNode[0].jnFlags & JNODE_REPLACE ){\n    sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]);\n  }else{\n    jsonReturnJson(x.aNode, ctx, argv);\n  }\njsonSetDone:\n  jsonParseReset(&x);\n}\n\n/*\n** json_type(JSON)\n** json_type(JSON, PATH)\n**\n** Return the top-level \"type\" of a JSON string.  Throw an error if\n** either the JSON or PATH inputs are not well-formed.\n*/\nstatic void jsonTypeFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  const char *zPath;\n  JsonNode *pNode;\n\n  if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;\n  assert( x.nNode );\n  if( argc==2 ){\n    zPath = (const char*)sqlite3_value_text(argv[1]);\n    pNode = jsonLookup(&x, zPath, 0, ctx);\n  }else{\n    pNode = x.aNode;\n  }\n  if( pNode ){\n    sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC);\n  }\n  jsonParseReset(&x);\n}\n\n/*\n** json_valid(JSON)\n**\n** Return 1 if JSON is a well-formed JSON string according to RFC-7159.\n** Return 0 otherwise.\n*/\nstatic void jsonValidFunc(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonParse x;          /* The parse */\n  int rc = 0;\n\n  UNUSED_PARAM(argc);\n  if( jsonParse(&x, 0, (const char*)sqlite3_value_text(argv[0]))==0 ){\n    rc = 1;\n  }\n  jsonParseReset(&x);\n  sqlite3_result_int(ctx, rc);\n}\n\n\n/****************************************************************************\n** Aggregate SQL function implementations\n****************************************************************************/\n/*\n** json_group_array(VALUE)\n**\n** Return a JSON array composed of all values in the aggregate.\n*/\nstatic void jsonArrayStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '[');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    jsonAppendValue(pStr, argv[0]);\n  }\n}\nstatic void jsonArrayFinal(sqlite3_context *ctx){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    pStr->pCtx = ctx;\n    jsonAppendChar(pStr, ']');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"[]\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n/*\n** json_group_obj(NAME,VALUE)\n**\n** Return a JSON object composed of all names and values in the aggregate.\n*/\nstatic void jsonObjectStep(\n  sqlite3_context *ctx,\n  int argc,\n  sqlite3_value **argv\n){\n  JsonString *pStr;\n  const char *z;\n  u32 n;\n  UNUSED_PARAM(argc);\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));\n  if( pStr ){\n    if( pStr->zBuf==0 ){\n      jsonInit(pStr, ctx);\n      jsonAppendChar(pStr, '{');\n    }else{\n      jsonAppendChar(pStr, ',');\n      pStr->pCtx = ctx;\n    }\n    z = (const char*)sqlite3_value_text(argv[0]);\n    n = (u32)sqlite3_value_bytes(argv[0]);\n    jsonAppendString(pStr, z, n);\n    jsonAppendChar(pStr, ':');\n    jsonAppendValue(pStr, argv[1]);\n  }\n}\nstatic void jsonObjectFinal(sqlite3_context *ctx){\n  JsonString *pStr;\n  pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);\n  if( pStr ){\n    jsonAppendChar(pStr, '}');\n    if( pStr->bErr ){\n      if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx);\n      assert( pStr->bStatic );\n    }else{\n      sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,\n                          pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);\n      pStr->bStatic = 1;\n    }\n  }else{\n    sqlite3_result_text(ctx, \"{}\", 2, SQLITE_STATIC);\n  }\n  sqlite3_result_subtype(ctx, JSON_SUBTYPE);\n}\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/****************************************************************************\n** The json_each virtual table\n****************************************************************************/\ntypedef struct JsonEachCursor JsonEachCursor;\nstruct JsonEachCursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  u32 iRowid;                /* The rowid */\n  u32 iBegin;                /* The first node of the scan */\n  u32 i;                     /* Index in sParse.aNode[] of current row */\n  u32 iEnd;                  /* EOF when i equals or exceeds this value */\n  u8 eType;                  /* Type of top-level element */\n  u8 bRecursive;             /* True for json_tree().  False for json_each() */\n  char *zJson;               /* Input JSON */\n  char *zRoot;               /* Path by which to filter zJson */\n  JsonParse sParse;          /* Parse of the input JSON */\n};\n\n/* Constructor for the json_each virtual table */\nstatic int jsonEachConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define JEACH_KEY     0\n#define JEACH_VALUE   1\n#define JEACH_TYPE    2\n#define JEACH_ATOM    3\n#define JEACH_ID      4\n#define JEACH_PARENT  5\n#define JEACH_FULLKEY 6\n#define JEACH_PATH    7\n#define JEACH_JSON    8\n#define JEACH_ROOT    9\n\n  UNUSED_PARAM(pzErr);\n  UNUSED_PARAM(argv);\n  UNUSED_PARAM(argc);\n  UNUSED_PARAM(pAux);\n  rc = sqlite3_declare_vtab(db, \n     \"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,\"\n                    \"json HIDDEN,root HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) );\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n  }\n  return rc;\n}\n\n/* destructor for json_each virtual table */\nstatic int jsonEachDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_each(). */\nstatic int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  JsonEachCursor *pCur;\n\n  UNUSED_PARAM(p);\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/* constructor for a JsonEachCursor object for json_tree(). */\nstatic int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  int rc = jsonEachOpenEach(p, ppCursor);\n  if( rc==SQLITE_OK ){\n    JsonEachCursor *pCur = (JsonEachCursor*)*ppCursor;\n    pCur->bRecursive = 1;\n  }\n  return rc;\n}\n\n/* Reset a JsonEachCursor back to its original state.  Free any memory\n** held. */\nstatic void jsonEachCursorReset(JsonEachCursor *p){\n  sqlite3_free(p->zJson);\n  sqlite3_free(p->zRoot);\n  jsonParseReset(&p->sParse);\n  p->iRowid = 0;\n  p->i = 0;\n  p->iEnd = 0;\n  p->eType = 0;\n  p->zJson = 0;\n  p->zRoot = 0;\n}\n\n/* Destructor for a jsonEachCursor object */\nstatic int jsonEachClose(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  jsonEachCursorReset(p);\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n/* Return TRUE if the jsonEachCursor object has been advanced off the end\n** of the JSON object */\nstatic int jsonEachEof(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  return p->i >= p->iEnd;\n}\n\n/* Advance the cursor to the next element for json_tree() */\nstatic int jsonEachNext(sqlite3_vtab_cursor *cur){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  if( p->bRecursive ){\n    if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++;\n    p->i++;\n    p->iRowid++;\n    if( p->i<p->iEnd ){\n      u32 iUp = p->sParse.aUp[p->i];\n      JsonNode *pUp = &p->sParse.aNode[iUp];\n      p->eType = pUp->eType;\n      if( pUp->eType==JSON_ARRAY ){\n        if( iUp==p->i-1 ){\n          pUp->u.iKey = 0;\n        }else{\n          pUp->u.iKey++;\n        }\n      }\n    }\n  }else{\n    switch( p->eType ){\n      case JSON_ARRAY: {\n        p->i += jsonNodeSize(&p->sParse.aNode[p->i]);\n        p->iRowid++;\n        break;\n      }\n      case JSON_OBJECT: {\n        p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]);\n        p->iRowid++;\n        break;\n      }\n      default: {\n        p->i = p->iEnd;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Append the name of the path for element i to pStr\n*/\nstatic void jsonEachComputePath(\n  JsonEachCursor *p,       /* The cursor */\n  JsonString *pStr,        /* Write the path here */\n  u32 i                    /* Path to this element */\n){\n  JsonNode *pNode, *pUp;\n  u32 iUp;\n  if( i==0 ){\n    jsonAppendChar(pStr, '$');\n    return;\n  }\n  iUp = p->sParse.aUp[i];\n  jsonEachComputePath(p, pStr, iUp);\n  pNode = &p->sParse.aNode[i];\n  pUp = &p->sParse.aNode[iUp];\n  if( pUp->eType==JSON_ARRAY ){\n    jsonPrintf(30, pStr, \"[%d]\", pUp->u.iKey);\n  }else{\n    assert( pUp->eType==JSON_OBJECT );\n    if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--;\n    assert( pNode->eType==JSON_STRING );\n    assert( pNode->jnFlags & JNODE_LABEL );\n    jsonPrintf(pNode->n+1, pStr, \".%.*s\", pNode->n-2, pNode->u.zJContent+1);\n  }\n}\n\n/* Return the value of a column */\nstatic int jsonEachColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  JsonNode *pThis = &p->sParse.aNode[p->i];\n  switch( i ){\n    case JEACH_KEY: {\n      if( p->i==0 ) break;\n      if( p->eType==JSON_OBJECT ){\n        jsonReturn(pThis, ctx, 0);\n      }else if( p->eType==JSON_ARRAY ){\n        u32 iKey;\n        if( p->bRecursive ){\n          if( p->iRowid==0 ) break;\n          iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey;\n        }else{\n          iKey = p->iRowid;\n        }\n        sqlite3_result_int64(ctx, (sqlite3_int64)iKey);\n      }\n      break;\n    }\n    case JEACH_VALUE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_TYPE: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_ATOM: {\n      if( pThis->jnFlags & JNODE_LABEL ) pThis++;\n      if( pThis->eType>=JSON_ARRAY ) break;\n      jsonReturn(pThis, ctx, 0);\n      break;\n    }\n    case JEACH_ID: {\n      sqlite3_result_int64(ctx, \n         (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0));\n      break;\n    }\n    case JEACH_PARENT: {\n      if( p->i>p->iBegin && p->bRecursive ){\n        sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]);\n      }\n      break;\n    }\n    case JEACH_FULLKEY: {\n      JsonString x;\n      jsonInit(&x, ctx);\n      if( p->bRecursive ){\n        jsonEachComputePath(p, &x, p->i);\n      }else{\n        if( p->zRoot ){\n          jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot));\n        }else{\n          jsonAppendChar(&x, '$');\n        }\n        if( p->eType==JSON_ARRAY ){\n          jsonPrintf(30, &x, \"[%d]\", p->iRowid);\n        }else{\n          jsonPrintf(pThis->n, &x, \".%.*s\", pThis->n-2, pThis->u.zJContent+1);\n        }\n      }\n      jsonResult(&x);\n      break;\n    }\n    case JEACH_PATH: {\n      if( p->bRecursive ){\n        JsonString x;\n        jsonInit(&x, ctx);\n        jsonEachComputePath(p, &x, p->sParse.aUp[p->i]);\n        jsonResult(&x);\n        break;\n      }\n      /* For json_each() path and root are the same so fall through\n      ** into the root case */\n    }\n    default: {\n      const char *zRoot = p->zRoot;\n      if( zRoot==0 ) zRoot = \"$\";\n      sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC);\n      break;\n    }\n    case JEACH_JSON: {\n      assert( i==JEACH_JSON );\n      sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Return the current rowid value */\nstatic int jsonEachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  *pRowid = p->iRowid;\n  return SQLITE_OK;\n}\n\n/* The query strategy is to look for an equality constraint on the json\n** column.  Without such a constraint, the table cannot operate.  idxNum is\n** 1 if the constraint is found, 3 if the constraint and zRoot are found,\n** and 0 otherwise.\n*/\nstatic int jsonEachBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  int i;\n  int jsonIdx = -1;\n  int rootIdx = -1;\n  const struct sqlite3_index_constraint *pConstraint;\n\n  UNUSED_PARAM(tab);\n  pConstraint = pIdxInfo->aConstraint;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    switch( pConstraint->iColumn ){\n      case JEACH_JSON:   jsonIdx = i;    break;\n      case JEACH_ROOT:   rootIdx = i;    break;\n      default:           /* no-op */     break;\n    }\n  }\n  if( jsonIdx<0 ){\n    pIdxInfo->idxNum = 0;\n    pIdxInfo->estimatedCost = 1e99;\n  }else{\n    pIdxInfo->estimatedCost = 1.0;\n    pIdxInfo->aConstraintUsage[jsonIdx].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[jsonIdx].omit = 1;\n    if( rootIdx<0 ){\n      pIdxInfo->idxNum = 1;\n    }else{\n      pIdxInfo->aConstraintUsage[rootIdx].argvIndex = 2;\n      pIdxInfo->aConstraintUsage[rootIdx].omit = 1;\n      pIdxInfo->idxNum = 3;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* Start a search on a new JSON string */\nstatic int jsonEachFilter(\n  sqlite3_vtab_cursor *cur,\n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  JsonEachCursor *p = (JsonEachCursor*)cur;\n  const char *z;\n  const char *zRoot = 0;\n  sqlite3_int64 n;\n\n  UNUSED_PARAM(idxStr);\n  UNUSED_PARAM(argc);\n  jsonEachCursorReset(p);\n  if( idxNum==0 ) return SQLITE_OK;\n  z = (const char*)sqlite3_value_text(argv[0]);\n  if( z==0 ) return SQLITE_OK;\n  n = sqlite3_value_bytes(argv[0]);\n  p->zJson = sqlite3_malloc64( n+1 );\n  if( p->zJson==0 ) return SQLITE_NOMEM;\n  memcpy(p->zJson, z, (size_t)n+1);\n  if( jsonParse(&p->sParse, 0, p->zJson) ){\n    int rc = SQLITE_NOMEM;\n    if( p->sParse.oom==0 ){\n      sqlite3_free(cur->pVtab->zErrMsg);\n      cur->pVtab->zErrMsg = sqlite3_mprintf(\"malformed JSON\");\n      if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR;\n    }\n    jsonEachCursorReset(p);\n    return rc;\n  }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){\n    jsonEachCursorReset(p);\n    return SQLITE_NOMEM;\n  }else{\n    JsonNode *pNode = 0;\n    if( idxNum==3 ){\n      const char *zErr = 0;\n      zRoot = (const char*)sqlite3_value_text(argv[1]);\n      if( zRoot==0 ) return SQLITE_OK;\n      n = sqlite3_value_bytes(argv[1]);\n      p->zRoot = sqlite3_malloc64( n+1 );\n      if( p->zRoot==0 ) return SQLITE_NOMEM;\n      memcpy(p->zRoot, zRoot, (size_t)n+1);\n      if( zRoot[0]!='$' ){\n        zErr = zRoot;\n      }else{\n        pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr);\n      }\n      if( zErr ){\n        sqlite3_free(cur->pVtab->zErrMsg);\n        cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr);\n        jsonEachCursorReset(p);\n        return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;\n      }else if( pNode==0 ){\n        return SQLITE_OK;\n      }\n    }else{\n      pNode = p->sParse.aNode;\n    }\n    p->iBegin = p->i = (int)(pNode - p->sParse.aNode);\n    p->eType = pNode->eType;\n    if( p->eType>=JSON_ARRAY ){\n      pNode->u.iKey = 0;\n      p->iEnd = p->i + pNode->n + 1;\n      if( p->bRecursive ){\n        p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType;\n        if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){\n          p->i--;\n        }\n      }else{\n        p->i++;\n      }\n    }else{\n      p->iEnd = p->i+1;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/* The methods of the json_each virtual table */\nstatic sqlite3_module jsonEachModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenEach,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n\n/* The methods of the json_tree virtual table. */\nstatic sqlite3_module jsonTreeModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  jsonEachConnect,           /* xConnect */\n  jsonEachBestIndex,         /* xBestIndex */\n  jsonEachDisconnect,        /* xDisconnect */\n  0,                         /* xDestroy */\n  jsonEachOpenTree,          /* xOpen - open a cursor */\n  jsonEachClose,             /* xClose - close a cursor */\n  jsonEachFilter,            /* xFilter - configure scan constraints */\n  jsonEachNext,              /* xNext - advance a cursor */\n  jsonEachEof,               /* xEof - check for end of scan */\n  jsonEachColumn,            /* xColumn - read data */\n  jsonEachRowid,             /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0                          /* xRollbackTo */\n};\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/****************************************************************************\n** The following routines are the only publically visible identifiers in this\n** file.  Call the following routines in order to register the various SQL\n** functions and the virtual table implemented by this file.\n****************************************************************************/\n\nSQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){\n  int rc = SQLITE_OK;\n  unsigned int i;\n  static const struct {\n     const char *zName;\n     int nArg;\n     int flag;\n     void (*xFunc)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"json\",                 1, 0,   jsonRemoveFunc        },\n    { \"json_array\",          -1, 0,   jsonArrayFunc         },\n    { \"json_array_length\",    1, 0,   jsonArrayLengthFunc   },\n    { \"json_array_length\",    2, 0,   jsonArrayLengthFunc   },\n    { \"json_extract\",        -1, 0,   jsonExtractFunc       },\n    { \"json_insert\",         -1, 0,   jsonSetFunc           },\n    { \"json_object\",         -1, 0,   jsonObjectFunc        },\n    { \"json_patch\",           2, 0,   jsonPatchFunc         },\n    { \"json_quote\",           1, 0,   jsonQuoteFunc         },\n    { \"json_remove\",         -1, 0,   jsonRemoveFunc        },\n    { \"json_replace\",        -1, 0,   jsonReplaceFunc       },\n    { \"json_set\",            -1, 1,   jsonSetFunc           },\n    { \"json_type\",            1, 0,   jsonTypeFunc          },\n    { \"json_type\",            2, 0,   jsonTypeFunc          },\n    { \"json_valid\",           1, 0,   jsonValidFunc         },\n\n#if SQLITE_DEBUG\n    /* DEBUG and TESTING functions */\n    { \"json_parse\",           1, 0,   jsonParseFunc         },\n    { \"json_test1\",           1, 0,   jsonTest1Func         },\n#endif\n  };\n  static const struct {\n     const char *zName;\n     int nArg;\n     void (*xStep)(sqlite3_context*,int,sqlite3_value**);\n     void (*xFinal)(sqlite3_context*);\n  } aAgg[] = {\n    { \"json_group_array\",     1,   jsonArrayStep,   jsonArrayFinal  },\n    { \"json_group_object\",    2,   jsonObjectStep,  jsonObjectFinal },\n  };\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static const struct {\n     const char *zName;\n     sqlite3_module *pModule;\n  } aMod[] = {\n    { \"json_each\",            &jsonEachModule               },\n    { \"json_tree\",            &jsonTreeModule               },\n  };\n#endif\n  for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, \n                                 (void*)&aFunc[i].flag,\n                                 aFunc[i].xFunc, 0, 0);\n  }\n  for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,\n                                 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,\n                                 0, aAgg[i].xStep, aAgg[i].xFinal);\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){\n    rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);\n  }\n#endif\n  return rc;\n}\n\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_json_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return sqlite3Json1Init(db);\n}\n#endif\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */\n\n/************** End of json1.c ***********************************************/\n/************** Begin file fts5.c ********************************************/\n\n\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) \n\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) \n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n/* #include \"sqlite3.h\" */\n\n#if 0\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. The exception is if the table was created\n**   with the offsets=0 option specified. In this case *piOff is always\n**   set to -1.\n**\n**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) \n**   if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            In this case, when tokenizing query text, the tokenizer may \n**            provide multiple synonyms for a single term within the document.\n**            FTS5 then queries the index for each synonym individually. For\n**            example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entires in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is subsituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#if 0\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n#ifndef _FTS5INT_H\n#define _FTS5INT_H\n\n/* #include \"fts5.h\" */\n/* #include \"sqlite3ext.h\" */\nSQLITE_EXTENSION_INIT1\n\n/* #include <string.h> */\n/* #include <assert.h> */\n\n#ifndef SQLITE_AMALGAMATION\n\ntypedef unsigned char  u8;\ntypedef unsigned int   u32;\ntypedef unsigned short u16;\ntypedef short i16;\ntypedef sqlite3_int64 i64;\ntypedef sqlite3_uint64 u64;\n\n#ifndef ArraySize\n# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))\n#endif\n\n#define testcase(x)\n#define ALWAYS(x) 1\n#define NEVER(x) 0\n\n#define MIN(x,y) (((x) < (y)) ? (x) : (y))\n#define MAX(x,y) (((x) > (y)) ? (x) : (y))\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n*/\n# define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n# define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n#endif\n\n/* Truncate very long tokens to this many bytes. Hard limit is \n** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset\n** field that occurs at the start of each leaf page (see fts5_index.c). */\n#define FTS5_MAX_TOKEN_SIZE 32768\n\n/*\n** Maximum number of prefix indexes on single FTS5 table. This must be\n** less than 32. If it is set to anything large than that, an #error\n** directive in fts5_index.c will cause the build to fail.\n*/\n#define FTS5_MAX_PREFIX_INDEXES 31\n\n#define FTS5_DEFAULT_NEARDIST 10\n#define FTS5_DEFAULT_RANK     \"bm25\"\n\n/* Name of rank and rowid columns */\n#define FTS5_RANK_NAME \"rank\"\n#define FTS5_ROWID_NAME \"rowid\"\n\n#ifdef SQLITE_DEBUG\n# define FTS5_CORRUPT sqlite3Fts5Corrupt()\nstatic int sqlite3Fts5Corrupt(void);\n#else\n# define FTS5_CORRUPT SQLITE_CORRUPT_VTAB\n#endif\n\n/*\n** The assert_nc() macro is similar to the assert() macro, except that it\n** is used for assert() conditions that are true only if it can be \n** guranteed that the database is not corrupt.\n*/\n#ifdef SQLITE_DEBUG\nSQLITE_API extern int sqlite3_fts5_may_be_corrupt;\n# define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x))\n#else\n# define assert_nc(x) assert(x)\n#endif\n\n/* Mark a function parameter as unused, to suppress nuisance compiler\n** warnings. */\n#ifndef UNUSED_PARAM\n# define UNUSED_PARAM(X)  (void)(X)\n#endif\n\n#ifndef UNUSED_PARAM2\n# define UNUSED_PARAM2(X, Y)  (void)(X), (void)(Y)\n#endif\n\ntypedef struct Fts5Global Fts5Global;\ntypedef struct Fts5Colset Fts5Colset;\n\n/* If a NEAR() clump or phrase may only match a specific set of columns, \n** then an object of the following type is used to record the set of columns.\n** Each entry in the aiCol[] array is a column that may be matched.\n**\n** This object is used by fts5_expr.c and fts5_index.c.\n*/\nstruct Fts5Colset {\n  int nCol;\n  int aiCol[1];\n};\n\n\n\n/**************************************************************************\n** Interface to code in fts5_config.c. fts5_config.c contains contains code\n** to parse the arguments passed to the CREATE VIRTUAL TABLE statement.\n*/\n\ntypedef struct Fts5Config Fts5Config;\n\n/*\n** An instance of the following structure encodes all information that can\n** be gleaned from the CREATE VIRTUAL TABLE statement.\n**\n** And all information loaded from the %_config table.\n**\n** nAutomerge:\n**   The minimum number of segments that an auto-merge operation should\n**   attempt to merge together. A value of 1 sets the object to use the \n**   compile time default. Zero disables auto-merge altogether.\n**\n** zContent:\n**\n** zContentRowid:\n**   The value of the content_rowid= option, if one was specified. Or \n**   the string \"rowid\" otherwise. This text is not quoted - if it is\n**   used as part of an SQL statement it needs to be quoted appropriately.\n**\n** zContentExprlist:\n**\n** pzErrmsg:\n**   This exists in order to allow the fts5_index.c module to return a \n**   decent error message if it encounters a file-format version it does\n**   not understand.\n**\n** bColumnsize:\n**   True if the %_docsize table is created.\n**\n** bPrefixIndex:\n**   This is only used for debugging. If set to false, any prefix indexes\n**   are ignored. This value is configured using:\n**\n**       INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex);\n**\n*/\nstruct Fts5Config {\n  sqlite3 *db;                    /* Database handle */\n  char *zDb;                      /* Database holding FTS index (e.g. \"main\") */\n  char *zName;                    /* Name of FTS index */\n  int nCol;                       /* Number of columns */\n  char **azCol;                   /* Column names */\n  u8 *abUnindexed;                /* True for unindexed columns */\n  int nPrefix;                    /* Number of prefix indexes */\n  int *aPrefix;                   /* Sizes in bytes of nPrefix prefix indexes */\n  int eContent;                   /* An FTS5_CONTENT value */\n  char *zContent;                 /* content table */ \n  char *zContentRowid;            /* \"content_rowid=\" option value */ \n  int bColumnsize;                /* \"columnsize=\" option value (dflt==1) */\n  int eDetail;                    /* FTS5_DETAIL_XXX value */\n  char *zContentExprlist;\n  Fts5Tokenizer *pTok;\n  fts5_tokenizer *pTokApi;\n\n  /* Values loaded from the %_config table */\n  int iCookie;                    /* Incremented when %_config is modified */\n  int pgsz;                       /* Approximate page size used in %_data */\n  int nAutomerge;                 /* 'automerge' setting */\n  int nCrisisMerge;               /* Maximum allowed segments per level */\n  int nUsermerge;                 /* 'usermerge' setting */\n  int nHashSize;                  /* Bytes of memory for in-memory hash */\n  char *zRank;                    /* Name of rank function */\n  char *zRankArgs;                /* Arguments to rank function */\n\n  /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */\n  char **pzErrmsg;\n\n#ifdef SQLITE_DEBUG\n  int bPrefixIndex;               /* True to use prefix-indexes */\n#endif\n};\n\n/* Current expected value of %_config table 'version' field */\n#define FTS5_CURRENT_VERSION 4\n\n#define FTS5_CONTENT_NORMAL   0\n#define FTS5_CONTENT_NONE     1\n#define FTS5_CONTENT_EXTERNAL 2\n\n#define FTS5_DETAIL_FULL    0\n#define FTS5_DETAIL_NONE    1\n#define FTS5_DETAIL_COLUMNS 2\n\n\n\nstatic int sqlite3Fts5ConfigParse(\n    Fts5Global*, sqlite3*, int, const char **, Fts5Config**, char**\n);\nstatic void sqlite3Fts5ConfigFree(Fts5Config*);\n\nstatic int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig);\n\nstatic int sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n);\n\nstatic void sqlite3Fts5Dequote(char *z);\n\n/* Load the contents of the %_config table */\nstatic int sqlite3Fts5ConfigLoad(Fts5Config*, int);\n\n/* Set the value of a single config attribute */\nstatic int sqlite3Fts5ConfigSetValue(Fts5Config*, const char*, sqlite3_value*, int*);\n\nstatic int sqlite3Fts5ConfigParseRank(const char*, char**, char**);\n\n/*\n** End of interface to code in fts5_config.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_buffer.c.\n*/\n\n/*\n** Buffer object for the incremental building of string data.\n*/\ntypedef struct Fts5Buffer Fts5Buffer;\nstruct Fts5Buffer {\n  u8 *p;\n  int n;\n  int nSpace;\n};\n\nstatic int sqlite3Fts5BufferSize(int*, Fts5Buffer*, u32);\nstatic void sqlite3Fts5BufferAppendVarint(int*, Fts5Buffer*, i64);\nstatic void sqlite3Fts5BufferAppendBlob(int*, Fts5Buffer*, u32, const u8*);\nstatic void sqlite3Fts5BufferAppendString(int *, Fts5Buffer*, const char*);\nstatic void sqlite3Fts5BufferFree(Fts5Buffer*);\nstatic void sqlite3Fts5BufferZero(Fts5Buffer*);\nstatic void sqlite3Fts5BufferSet(int*, Fts5Buffer*, int, const u8*);\nstatic void sqlite3Fts5BufferAppendPrintf(int *, Fts5Buffer*, char *zFmt, ...);\n\nstatic char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...);\n\n#define fts5BufferZero(x)             sqlite3Fts5BufferZero(x)\n#define fts5BufferAppendVarint(a,b,c) sqlite3Fts5BufferAppendVarint(a,b,c)\n#define fts5BufferFree(a)             sqlite3Fts5BufferFree(a)\n#define fts5BufferAppendBlob(a,b,c,d) sqlite3Fts5BufferAppendBlob(a,b,c,d)\n#define fts5BufferSet(a,b,c,d)        sqlite3Fts5BufferSet(a,b,c,d)\n\n#define fts5BufferGrow(pRc,pBuf,nn) ( \\\n  (u32)((pBuf)->n) + (u32)(nn) <= (u32)((pBuf)->nSpace) ? 0 : \\\n    sqlite3Fts5BufferSize((pRc),(pBuf),(nn)+(pBuf)->n) \\\n)\n\n/* Write and decode big-endian 32-bit integer values */\nstatic void sqlite3Fts5Put32(u8*, int);\nstatic int sqlite3Fts5Get32(const u8*);\n\n#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)\n#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)\n\ntypedef struct Fts5PoslistReader Fts5PoslistReader;\nstruct Fts5PoslistReader {\n  /* Variables used only by sqlite3Fts5PoslistIterXXX() functions. */\n  const u8 *a;                    /* Position list to iterate through */\n  int n;                          /* Size of buffer at a[] in bytes */\n  int i;                          /* Current offset in a[] */\n\n  u8 bFlag;                       /* For client use (any custom purpose) */\n\n  /* Output variables */\n  u8 bEof;                        /* Set to true at EOF */\n  i64 iPos;                       /* (iCol<<32) + iPos */\n};\nstatic int sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n);\nstatic int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader*);\n\ntypedef struct Fts5PoslistWriter Fts5PoslistWriter;\nstruct Fts5PoslistWriter {\n  i64 iPrev;\n};\nstatic int sqlite3Fts5PoslistWriterAppend(Fts5Buffer*, Fts5PoslistWriter*, i64);\nstatic void sqlite3Fts5PoslistSafeAppend(Fts5Buffer*, i64*, i64);\n\nstatic int sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n);\n\n/* Malloc utility */\nstatic void *sqlite3Fts5MallocZero(int *pRc, int nByte);\nstatic char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);\n\n/* Character set tests (like isspace(), isalpha() etc.) */\nstatic int sqlite3Fts5IsBareword(char t);\n\n\n/* Bucket of terms object used by the integrity-check in offsets=0 mode. */\ntypedef struct Fts5Termset Fts5Termset;\nstatic int sqlite3Fts5TermsetNew(Fts5Termset**);\nstatic int sqlite3Fts5TermsetAdd(Fts5Termset*, int, const char*, int, int *pbPresent);\nstatic void sqlite3Fts5TermsetFree(Fts5Termset*);\n\n/*\n** End of interface to code in fts5_buffer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_index.c. fts5_index.c contains contains code\n** to access the data stored in the %_data table.\n*/\n\ntypedef struct Fts5Index Fts5Index;\ntypedef struct Fts5IndexIter Fts5IndexIter;\n\nstruct Fts5IndexIter {\n  i64 iRowid;\n  const u8 *pData;\n  int nData;\n  u8 bEof;\n};\n\n#define sqlite3Fts5IterEof(x) ((x)->bEof)\n\n/*\n** Values used as part of the flags argument passed to IndexQuery().\n*/\n#define FTS5INDEX_QUERY_PREFIX     0x0001   /* Prefix query */\n#define FTS5INDEX_QUERY_DESC       0x0002   /* Docs in descending rowid order */\n#define FTS5INDEX_QUERY_TEST_NOIDX 0x0004   /* Do not use prefix index */\n#define FTS5INDEX_QUERY_SCAN       0x0008   /* Scan query (fts5vocab) */\n\n/* The following are used internally by the fts5_index.c module. They are\n** defined here only to make it easier to avoid clashes with the flags\n** above. */\n#define FTS5INDEX_QUERY_SKIPEMPTY  0x0010\n#define FTS5INDEX_QUERY_NOOUTPUT   0x0020\n\n/*\n** Create/destroy an Fts5Index object.\n*/\nstatic int sqlite3Fts5IndexOpen(Fts5Config *pConfig, int bCreate, Fts5Index**, char**);\nstatic int sqlite3Fts5IndexClose(Fts5Index *p);\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nstatic u64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n);\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nstatic int sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n);\n\n/*\n** Open a new iterator to iterate though all rowids that match the \n** specified token or token prefix.\n*/\nstatic int sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n);\n\n/*\n** The various operations on open token or token prefix iterators opened\n** using sqlite3Fts5IndexQuery().\n*/\nstatic int sqlite3Fts5IterNext(Fts5IndexIter*);\nstatic int sqlite3Fts5IterNextFrom(Fts5IndexIter*, i64 iMatch);\n\n/*\n** Close an iterator opened by sqlite3Fts5IndexQuery().\n*/\nstatic void sqlite3Fts5IterClose(Fts5IndexIter*);\n\n/*\n** This interface is used by the fts5vocab module.\n*/\nstatic const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);\nstatic int sqlite3Fts5IterNextScan(Fts5IndexIter*);\n\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nstatic int sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Indicate that subsequent calls to sqlite3Fts5IndexWrite() pertain to\n** document iDocid.\n*/\nstatic int sqlite3Fts5IndexBeginWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int bDelete,                    /* True if current operation is a delete */\n  i64 iDocid                      /* Docid to add or remove data from */\n);\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n** Also close any open blob handles.\n*/\nstatic int sqlite3Fts5IndexSync(Fts5Index *p);\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nstatic int sqlite3Fts5IndexRollback(Fts5Index *p);\n\n/*\n** Get or set the \"averages\" values.\n*/\nstatic int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize);\nstatic int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);\n\n/*\n** Functions called by the storage module as part of integrity-check.\n*/\nstatic int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);\n\n/* \n** Called during virtual module initialization to register UDF \n** fts5_decode() with SQLite \n*/\nstatic int sqlite3Fts5IndexInit(sqlite3*);\n\nstatic int sqlite3Fts5IndexSetCookie(Fts5Index*, int);\n\n/*\n** Return the total number of entries read from the %_data table by \n** this connection since it was created.\n*/\nstatic int sqlite3Fts5IndexReads(Fts5Index *p);\n\nstatic int sqlite3Fts5IndexReinit(Fts5Index *p);\nstatic int sqlite3Fts5IndexOptimize(Fts5Index *p);\nstatic int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge);\nstatic int sqlite3Fts5IndexReset(Fts5Index *p);\n\nstatic int sqlite3Fts5IndexLoadConfig(Fts5Index *p);\n\n/*\n** End of interface to code in fts5_index.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_varint.c. \n*/\nstatic int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v);\nstatic int sqlite3Fts5GetVarintLen(u32 iVal);\nstatic u8 sqlite3Fts5GetVarint(const unsigned char*, u64*);\nstatic int sqlite3Fts5PutVarint(unsigned char *p, u64 v);\n\n#define fts5GetVarint32(a,b) sqlite3Fts5GetVarint32(a,(u32*)&b)\n#define fts5GetVarint    sqlite3Fts5GetVarint\n\n#define fts5FastGetVarint32(a, iOff, nVal) {      \\\n  nVal = (a)[iOff++];                             \\\n  if( nVal & 0x80 ){                              \\\n    iOff--;                                       \\\n    iOff += fts5GetVarint32(&(a)[iOff], nVal);    \\\n  }                                               \\\n}\n\n\n/*\n** End of interface to code in fts5_varint.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5.c. \n*/\n\nstatic int sqlite3Fts5GetTokenizer(\n  Fts5Global*, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer**,\n  fts5_tokenizer**,\n  char **pzErr\n);\n\nstatic Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);\n\n/*\n** End of interface to code in fts5.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_hash.c. \n*/\ntypedef struct Fts5Hash Fts5Hash;\n\n/*\n** Create a hash table, free a hash table.\n*/\nstatic int sqlite3Fts5HashNew(Fts5Config*, Fts5Hash**, int *pnSize);\nstatic void sqlite3Fts5HashFree(Fts5Hash*);\n\nstatic int sqlite3Fts5HashWrite(\n  Fts5Hash*,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n);\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nstatic void sqlite3Fts5HashClear(Fts5Hash*);\n\nstatic int sqlite3Fts5HashQuery(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n);\n\nstatic int sqlite3Fts5HashScanInit(\n  Fts5Hash*,                      /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n);\nstatic void sqlite3Fts5HashScanNext(Fts5Hash*);\nstatic int sqlite3Fts5HashScanEof(Fts5Hash*);\nstatic void sqlite3Fts5HashScanEntry(Fts5Hash *,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n);\n\n\n/*\n** End of interface to code in fts5_hash.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_storage.c. fts5_storage.c contains contains \n** code to access the data stored in the %_content and %_docsize tables.\n*/\n\n#define FTS5_STMT_SCAN_ASC  0     /* SELECT rowid, * FROM ... ORDER BY 1 ASC */\n#define FTS5_STMT_SCAN_DESC 1     /* SELECT rowid, * FROM ... ORDER BY 1 DESC */\n#define FTS5_STMT_LOOKUP    2     /* SELECT rowid, * FROM ... WHERE rowid=? */\n\ntypedef struct Fts5Storage Fts5Storage;\n\nstatic int sqlite3Fts5StorageOpen(Fts5Config*, Fts5Index*, int, Fts5Storage**, char**);\nstatic int sqlite3Fts5StorageClose(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRename(Fts5Storage*, const char *zName);\n\nstatic int sqlite3Fts5DropAll(Fts5Config*);\nstatic int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **);\n\nstatic int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);\nstatic int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);\nstatic int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);\n\nstatic int sqlite3Fts5StorageIntegrity(Fts5Storage *p);\n\nstatic int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);\nstatic void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);\n\nstatic int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);\nstatic int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg);\nstatic int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow);\n\nstatic int sqlite3Fts5StorageSync(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRollback(Fts5Storage *p);\n\nstatic int sqlite3Fts5StorageConfigValue(\n    Fts5Storage *p, const char*, sqlite3_value*, int\n);\n\nstatic int sqlite3Fts5StorageDeleteAll(Fts5Storage *p);\nstatic int sqlite3Fts5StorageRebuild(Fts5Storage *p);\nstatic int sqlite3Fts5StorageOptimize(Fts5Storage *p);\nstatic int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge);\nstatic int sqlite3Fts5StorageReset(Fts5Storage *p);\n\n/*\n** End of interface to code in fts5_storage.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to code in fts5_expr.c. \n*/\ntypedef struct Fts5Expr Fts5Expr;\ntypedef struct Fts5ExprNode Fts5ExprNode;\ntypedef struct Fts5Parse Fts5Parse;\ntypedef struct Fts5Token Fts5Token;\ntypedef struct Fts5ExprPhrase Fts5ExprPhrase;\ntypedef struct Fts5ExprNearset Fts5ExprNearset;\n\nstruct Fts5Token {\n  const char *p;                  /* Token text (not NULL terminated) */\n  int n;                          /* Size of buffer p in bytes */\n};\n\n/* Parse a MATCH expression. */\nstatic int sqlite3Fts5ExprNew(\n  Fts5Config *pConfig, \n  int iCol,                       /* Column on LHS of MATCH operator */\n  const char *zExpr,\n  Fts5Expr **ppNew, \n  char **pzErr\n);\n\n/*\n** for(rc = sqlite3Fts5ExprFirst(pExpr, pIdx, bDesc);\n**     rc==SQLITE_OK && 0==sqlite3Fts5ExprEof(pExpr);\n**     rc = sqlite3Fts5ExprNext(pExpr)\n** ){\n**   // The document with rowid iRowid matches the expression!\n**   i64 iRowid = sqlite3Fts5ExprRowid(pExpr);\n** }\n*/\nstatic int sqlite3Fts5ExprFirst(Fts5Expr*, Fts5Index *pIdx, i64 iMin, int bDesc);\nstatic int sqlite3Fts5ExprNext(Fts5Expr*, i64 iMax);\nstatic int sqlite3Fts5ExprEof(Fts5Expr*);\nstatic i64 sqlite3Fts5ExprRowid(Fts5Expr*);\n\nstatic void sqlite3Fts5ExprFree(Fts5Expr*);\n\n/* Called during startup to register a UDF with SQLite */\nstatic int sqlite3Fts5ExprInit(Fts5Global*, sqlite3*);\n\nstatic int sqlite3Fts5ExprPhraseCount(Fts5Expr*);\nstatic int sqlite3Fts5ExprPhraseSize(Fts5Expr*, int iPhrase);\nstatic int sqlite3Fts5ExprPoslist(Fts5Expr*, int, const u8 **);\n\ntypedef struct Fts5PoslistPopulator Fts5PoslistPopulator;\nstatic Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int);\nstatic int sqlite3Fts5ExprPopulatePoslists(\n    Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int\n);\nstatic void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64);\n\nstatic int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**);\n\nstatic int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *);\n\n/*******************************************\n** The fts5_expr.c API above this point is used by the other hand-written\n** C code in this module. The interfaces below this point are called by\n** the parser code in fts5parse.y.  */\n\nstatic void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...);\n\nstatic Fts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,\n  int eType,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight,\n  Fts5ExprNearset *pNear\n);\n\nstatic Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,\n  Fts5ExprNode *pLeft,\n  Fts5ExprNode *pRight\n);\n\nstatic Fts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse, \n  Fts5ExprPhrase *pPhrase, \n  Fts5Token *pToken,\n  int bPrefix\n);\n\nstatic Fts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse*, \n  Fts5ExprNearset*,\n  Fts5ExprPhrase* \n);\n\nstatic Fts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse*, \n  Fts5Colset*, \n  Fts5Token *\n);\n\nstatic void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*);\nstatic void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*);\nstatic void sqlite3Fts5ParseNodeFree(Fts5ExprNode*);\n\nstatic void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*);\nstatic void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNode*, Fts5Colset*);\nstatic Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*);\nstatic void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p);\nstatic void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*);\n\n/*\n** End of interface to code in fts5_expr.c.\n**************************************************************************/\n\n\n\n/**************************************************************************\n** Interface to code in fts5_aux.c. \n*/\n\nstatic int sqlite3Fts5AuxInit(fts5_api*);\n/*\n** End of interface to code in fts5_aux.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_tokenizer.c. \n*/\n\nstatic int sqlite3Fts5TokenizerInit(fts5_api*);\n/*\n** End of interface to code in fts5_tokenizer.c.\n**************************************************************************/\n\n/**************************************************************************\n** Interface to code in fts5_vocab.c. \n*/\n\nstatic int sqlite3Fts5VocabInit(Fts5Global*, sqlite3*);\n\n/*\n** End of interface to code in fts5_vocab.c.\n**************************************************************************/\n\n\n/**************************************************************************\n** Interface to automatically generated code in fts5_unicode2.c. \n*/\nstatic int sqlite3Fts5UnicodeIsalnum(int c);\nstatic int sqlite3Fts5UnicodeIsdiacritic(int c);\nstatic int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);\n/*\n** End of interface to code in fts5_unicode2.c.\n**************************************************************************/\n\n#endif\n\n#define FTS5_OR                               1\n#define FTS5_AND                              2\n#define FTS5_NOT                              3\n#define FTS5_TERM                             4\n#define FTS5_COLON                            5\n#define FTS5_MINUS                            6\n#define FTS5_LCP                              7\n#define FTS5_RCP                              8\n#define FTS5_STRING                           9\n#define FTS5_LP                              10\n#define FTS5_RP                              11\n#define FTS5_COMMA                           12\n#define FTS5_PLUS                            13\n#define FTS5_STAR                            14\n\n/*\n** 2000-05-29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Driver template for the LEMON parser generator.\n**\n** The \"lemon\" program processes an LALR(1) input grammar file, then uses\n** this template to construct a parser.  The \"lemon\" program inserts text\n** at each \"%%\" line.  Also, any \"P-a-r-s-e\" identifer prefix (without the\n** interstitial \"-\" characters) contained in this template is changed into\n** the value of the %name directive from the grammar.  Otherwise, the content\n** of this template is copied straight through into the generate parser\n** source file.\n**\n** The following is the concatenation of all %include directives from the\n** input grammar file:\n*/\n/* #include <stdio.h> */\n/************ Begin %include sections from the grammar ************************/\n\n/* #include \"fts5Int.h\" */\n/* #include \"fts5parse.h\" */\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define fts5YYNOERRORRECOVERY 1\n\n/*\n** Make fts5yytestcase() the same as testcase()\n*/\n#define fts5yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define fts5YYPARSEFREENOTNULL 1\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define fts5YYMALLOCARGTYPE  u64\n\n/**************** End of %include directives **********************************/\n/* These constants specify the various numeric values for terminal symbols\n** in a format understandable to \"makeheaders\".  This section is blank unless\n** \"lemon\" is run with the \"-m\" command-line option.\n***************** Begin makeheaders token definitions *************************/\n/**************** End makeheaders token definitions ***************************/\n\n/* The next sections is a series of control #defines.\n** various aspects of the generated parser.\n**    fts5YYCODETYPE         is the data type used to store the integer codes\n**                       that represent terminal and non-terminal symbols.\n**                       \"unsigned char\" is used if there are fewer than\n**                       256 symbols.  Larger types otherwise.\n**    fts5YYNOCODE           is a number of type fts5YYCODETYPE that is not used for\n**                       any terminal or nonterminal symbol.\n**    fts5YYFALLBACK         If defined, this indicates that one or more tokens\n**                       (also known as: \"terminal symbols\") have fall-back\n**                       values which should be used if the original symbol\n**                       would not parse.  This permits keywords to sometimes\n**                       be used as identifiers, for example.\n**    fts5YYACTIONTYPE       is the data type used for \"action codes\" - numbers\n**                       that indicate what to do in response to the next\n**                       token.\n**    sqlite3Fts5ParserFTS5TOKENTYPE     is the data type used for minor type for terminal\n**                       symbols.  Background: A \"minor type\" is a semantic\n**                       value associated with a terminal or non-terminal\n**                       symbols.  For example, for an \"ID\" terminal symbol,\n**                       the minor type might be the name of the identifier.\n**                       Each non-terminal can have a different minor type.\n**                       Terminal symbols all have the same minor type, though.\n**                       This macros defines the minor type for terminal \n**                       symbols.\n**    fts5YYMINORTYPE        is the data type used for all minor types.\n**                       This is typically a union of many types, one of\n**                       which is sqlite3Fts5ParserFTS5TOKENTYPE.  The entry in the union\n**                       for terminal symbols is called \"fts5yy0\".\n**    fts5YYSTACKDEPTH       is the maximum depth of the parser's stack.  If\n**                       zero the stack is dynamically sized using realloc()\n**    sqlite3Fts5ParserARG_SDECL     A static variable declaration for the %extra_argument\n**    sqlite3Fts5ParserARG_PDECL     A parameter declaration for the %extra_argument\n**    sqlite3Fts5ParserARG_STORE     Code to store %extra_argument into fts5yypParser\n**    sqlite3Fts5ParserARG_FETCH     Code to extract %extra_argument from fts5yypParser\n**    fts5YYERRORSYMBOL      is the code number of the error symbol.  If not\n**                       defined, then do no error processing.\n**    fts5YYNSTATE           the combined number of states.\n**    fts5YYNRULE            the number of rules in the grammar\n**    fts5YY_MAX_SHIFT       Maximum value for shift actions\n**    fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions\n**    fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions\n**    fts5YY_MIN_REDUCE      Minimum value for reduce actions\n**    fts5YY_MAX_REDUCE      Maximum value for reduce actions\n**    fts5YY_ERROR_ACTION    The fts5yy_action[] code for syntax error\n**    fts5YY_ACCEPT_ACTION   The fts5yy_action[] code for accept\n**    fts5YY_NO_ACTION       The fts5yy_action[] code for no-op\n*/\n#ifndef INTERFACE\n# define INTERFACE 1\n#endif\n/************* Begin control #defines *****************************************/\n#define fts5YYCODETYPE unsigned char\n#define fts5YYNOCODE 28\n#define fts5YYACTIONTYPE unsigned char\n#define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token\ntypedef union {\n  int fts5yyinit;\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0;\n  int fts5yy4;\n  Fts5Colset* fts5yy11;\n  Fts5ExprNode* fts5yy24;\n  Fts5ExprNearset* fts5yy46;\n  Fts5ExprPhrase* fts5yy53;\n} fts5YYMINORTYPE;\n#ifndef fts5YYSTACKDEPTH\n#define fts5YYSTACKDEPTH 100\n#endif\n#define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse;\n#define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse\n#define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse\n#define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse\n#define fts5YYNSTATE             33\n#define fts5YYNRULE              27\n#define fts5YY_MAX_SHIFT         32\n#define fts5YY_MIN_SHIFTREDUCE   50\n#define fts5YY_MAX_SHIFTREDUCE   76\n#define fts5YY_MIN_REDUCE        77\n#define fts5YY_MAX_REDUCE        103\n#define fts5YY_ERROR_ACTION      104\n#define fts5YY_ACCEPT_ACTION     105\n#define fts5YY_NO_ACTION         106\n/************* End control #defines *******************************************/\n\n/* Define the fts5yytestcase() macro to be a no-op if is not already defined\n** otherwise.\n**\n** Applications can choose to define fts5yytestcase() in the %include section\n** to a macro that can assist in verifying code coverage.  For production\n** code the fts5yytestcase() macro should be turned off.  But it is useful\n** for testing.\n*/\n#ifndef fts5yytestcase\n# define fts5yytestcase(X)\n#endif\n\n\n/* Next are the tables used to determine what action to take based on the\n** current state and lookahead token.  These tables are used to implement\n** functions that take a state number and lookahead value and return an\n** action integer.  \n**\n** Suppose the action integer is N.  Then the action is determined as\n** follows\n**\n**   0 <= N <= fts5YY_MAX_SHIFT             Shift N.  That is, push the lookahead\n**                                      token onto the stack and goto state N.\n**\n**   N between fts5YY_MIN_SHIFTREDUCE       Shift to an arbitrary state then\n**     and fts5YY_MAX_SHIFTREDUCE           reduce by rule N-fts5YY_MIN_SHIFTREDUCE.\n**\n**   N between fts5YY_MIN_REDUCE            Reduce by rule N-fts5YY_MIN_REDUCE\n**     and fts5YY_MAX_REDUCE\n**\n**   N == fts5YY_ERROR_ACTION               A syntax error has occurred.\n**\n**   N == fts5YY_ACCEPT_ACTION              The parser accepts its input.\n**\n**   N == fts5YY_NO_ACTION                  No such action.  Denotes unused\n**                                      slots in the fts5yy_action[] table.\n**\n** The action table is constructed as a single large table named fts5yy_action[].\n** Given state S and lookahead X, the action is computed as either:\n**\n**    (A)   N = fts5yy_action[ fts5yy_shift_ofst[S] + X ]\n**    (B)   N = fts5yy_default[S]\n**\n** The (A) formula is preferred.  The B formula is used instead if:\n**    (1)  The fts5yy_shift_ofst[S]+X value is out of range, or\n**    (2)  fts5yy_lookahead[fts5yy_shift_ofst[S]+X] is not equal to X, or\n**    (3)  fts5yy_shift_ofst[S] equal fts5YY_SHIFT_USE_DFLT.\n** (Implementation note: fts5YY_SHIFT_USE_DFLT is chosen so that\n** fts5YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.\n** Hence only tests (1) and (2) need to be evaluated.)\n**\n** The formulas above are for computing the action when the lookahead is\n** a terminal symbol.  If the lookahead is a non-terminal (as occurs after\n** a reduce action) then the fts5yy_reduce_ofst[] array is used in place of\n** the fts5yy_shift_ofst[] array and fts5YY_REDUCE_USE_DFLT is used in place of\n** fts5YY_SHIFT_USE_DFLT.\n**\n** The following are the tables generated in this section:\n**\n**  fts5yy_action[]        A single table containing all actions.\n**  fts5yy_lookahead[]     A table containing the lookahead for each entry in\n**                     fts5yy_action.  Used to detect hash collisions.\n**  fts5yy_shift_ofst[]    For each state, the offset into fts5yy_action for\n**                     shifting terminals.\n**  fts5yy_reduce_ofst[]   For each state, the offset into fts5yy_action for\n**                     shifting non-terminals after a reduce.\n**  fts5yy_default[]       Default action for each state.\n**\n*********** Begin parsing tables **********************************************/\n#define fts5YY_ACTTAB_COUNT (98)\nstatic const fts5YYACTIONTYPE fts5yy_action[] = {\n /*     0 */   105,   19,   90,    6,   26,   93,   92,   24,   24,   17,\n /*    10 */    90,    6,   26,   16,   92,   54,   24,   18,   90,    6,\n /*    20 */    26,   10,   92,   12,   24,   75,   86,   90,    6,   26,\n /*    30 */    13,   92,   75,   24,   20,   90,    6,   26,  101,   92,\n /*    40 */    56,   24,   27,   90,    6,   26,  100,   92,   21,   24,\n /*    50 */    23,   15,   30,   11,    1,   91,   22,   25,    9,   92,\n /*    60 */     7,   24,    3,    4,    5,    3,    4,    5,    3,   77,\n /*    70 */     4,    5,    3,   61,   23,   15,   60,   11,   80,   12,\n /*    80 */     2,   13,   68,   10,   29,   52,   55,   75,   31,   32,\n /*    90 */     8,   28,    5,    3,   51,   55,   72,   14,\n};\nstatic const fts5YYCODETYPE fts5yy_lookahead[] = {\n /*     0 */    16,   17,   18,   19,   20,   22,   22,   24,   24,   17,\n /*    10 */    18,   19,   20,    7,   22,    9,   24,   17,   18,   19,\n /*    20 */    20,   10,   22,    9,   24,   14,   17,   18,   19,   20,\n /*    30 */     9,   22,   14,   24,   17,   18,   19,   20,   26,   22,\n /*    40 */     9,   24,   17,   18,   19,   20,   26,   22,   21,   24,\n /*    50 */     6,    7,   13,    9,   10,   18,   21,   20,    5,   22,\n /*    60 */     5,   24,    3,    1,    2,    3,    1,    2,    3,    0,\n /*    70 */     1,    2,    3,   11,    6,    7,   11,    9,    5,    9,\n /*    80 */    10,    9,   11,   10,   12,    8,    9,   14,   24,   25,\n /*    90 */    23,   24,    2,    3,    8,    9,    9,    9,\n};\n#define fts5YY_SHIFT_USE_DFLT (98)\n#define fts5YY_SHIFT_COUNT    (32)\n#define fts5YY_SHIFT_MIN      (0)\n#define fts5YY_SHIFT_MAX      (90)\nstatic const unsigned char fts5yy_shift_ofst[] = {\n /*     0 */    44,   44,   44,   44,   44,   44,   68,   70,   72,   14,\n /*    10 */    21,   73,   11,   18,   18,   31,   31,   62,   65,   69,\n /*    20 */    90,   77,   86,    6,   39,   53,   55,   59,   39,   87,\n /*    30 */    88,   39,   71,\n};\n#define fts5YY_REDUCE_USE_DFLT (-18)\n#define fts5YY_REDUCE_COUNT (16)\n#define fts5YY_REDUCE_MIN   (-17)\n#define fts5YY_REDUCE_MAX   (67)\nstatic const signed char fts5yy_reduce_ofst[] = {\n /*     0 */   -16,   -8,    0,    9,   17,   25,   37,  -17,   64,  -17,\n /*    10 */    67,   12,   12,   12,   20,   27,   35,\n};\nstatic const fts5YYACTIONTYPE fts5yy_default[] = {\n /*     0 */   104,  104,  104,  104,  104,  104,   89,  104,   98,  104,\n /*    10 */   104,  103,  103,  103,  103,  104,  104,  104,  104,  104,\n /*    20 */    85,  104,  104,  104,   94,  104,  104,   84,   96,  104,\n /*    30 */   104,   97,  104,\n};\n/********** End of lemon-generated parsing tables *****************************/\n\n/* The next table maps tokens (terminal symbols) into fallback tokens.  \n** If a construct like the following:\n** \n**      %fallback ID X Y Z.\n**\n** appears in the grammar, then ID becomes a fallback token for X, Y,\n** and Z.  Whenever one of the tokens X, Y, or Z is input to the parser\n** but it does not parse, the type of the token is changed to ID and\n** the parse is retried before an error is thrown.\n**\n** This feature can be used, for example, to cause some keywords in a language\n** to revert to identifiers if they keyword does not apply in the context where\n** it appears.\n*/\n#ifdef fts5YYFALLBACK\nstatic const fts5YYCODETYPE fts5yyFallback[] = {\n};\n#endif /* fts5YYFALLBACK */\n\n/* The following structure represents a single element of the\n** parser's stack.  Information stored includes:\n**\n**   +  The state number for the parser at this level of the stack.\n**\n**   +  The value of the token stored at this level of the stack.\n**      (In other words, the \"major\" token.)\n**\n**   +  The semantic value stored at this level of the stack.  This is\n**      the information used by the action routines in the grammar.\n**      It is sometimes called the \"minor\" token.\n**\n** After the \"shift\" half of a SHIFTREDUCE action, the stateno field\n** actually contains the reduce action for the second half of the\n** SHIFTREDUCE.\n*/\nstruct fts5yyStackEntry {\n  fts5YYACTIONTYPE stateno;  /* The state-number, or reduce action in SHIFTREDUCE */\n  fts5YYCODETYPE major;      /* The major token value.  This is the code\n                         ** number for the token at this stack level */\n  fts5YYMINORTYPE minor;     /* The user-supplied minor token value.  This\n                         ** is the value of the token  */\n};\ntypedef struct fts5yyStackEntry fts5yyStackEntry;\n\n/* The state of the parser is completely contained in an instance of\n** the following structure */\nstruct fts5yyParser {\n  fts5yyStackEntry *fts5yytos;          /* Pointer to top element of the stack */\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  int fts5yyhwm;                    /* High-water mark of the stack */\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  int fts5yyerrcnt;                 /* Shifts left before out of the error */\n#endif\n  sqlite3Fts5ParserARG_SDECL                /* A place to hold %extra_argument */\n#if fts5YYSTACKDEPTH<=0\n  int fts5yystksz;                  /* Current side of the stack */\n  fts5yyStackEntry *fts5yystack;        /* The parser's stack */\n  fts5yyStackEntry fts5yystk0;          /* First stack entry */\n#else\n  fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH];  /* The parser's stack */\n  fts5yyStackEntry *fts5yystackEnd;            /* Last entry in the stack */\n#endif\n};\ntypedef struct fts5yyParser fts5yyParser;\n\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic FILE *fts5yyTraceFILE = 0;\nstatic char *fts5yyTracePrompt = 0;\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* \n** Turn parser tracing on by giving a stream to which to write the trace\n** and a prompt to preface each trace message.  Tracing is turned off\n** by making either argument NULL \n**\n** Inputs:\n** <ul>\n** <li> A FILE* to which trace output should be written.\n**      If NULL, then tracing is turned off.\n** <li> A prefix string written at the beginning of every\n**      line of trace output.  If NULL, then tracing is\n**      turned off.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nstatic void sqlite3Fts5ParserTrace(FILE *TraceFILE, char *zTracePrompt){\n  fts5yyTraceFILE = TraceFILE;\n  fts5yyTracePrompt = zTracePrompt;\n  if( fts5yyTraceFILE==0 ) fts5yyTracePrompt = 0;\n  else if( fts5yyTracePrompt==0 ) fts5yyTraceFILE = 0;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing shifts, the names of all terminals and nonterminals\n** are required.  The following table supplies these names */\nstatic const char *const fts5yyTokenName[] = { \n  \"$\",             \"OR\",            \"AND\",           \"NOT\",         \n  \"TERM\",          \"COLON\",         \"MINUS\",         \"LCP\",         \n  \"RCP\",           \"STRING\",        \"LP\",            \"RP\",          \n  \"COMMA\",         \"PLUS\",          \"STAR\",          \"error\",       \n  \"input\",         \"expr\",          \"cnearset\",      \"exprlist\",    \n  \"colset\",        \"colsetlist\",    \"nearset\",       \"nearphrases\", \n  \"phrase\",        \"neardist_opt\",  \"star_opt\",    \n};\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/* For tracing reduce actions, the names of all rules are required.\n*/\nstatic const char *const fts5yyRuleName[] = {\n /*   0 */ \"input ::= expr\",\n /*   1 */ \"colset ::= MINUS LCP colsetlist RCP\",\n /*   2 */ \"colset ::= LCP colsetlist RCP\",\n /*   3 */ \"colset ::= STRING\",\n /*   4 */ \"colset ::= MINUS STRING\",\n /*   5 */ \"colsetlist ::= colsetlist STRING\",\n /*   6 */ \"colsetlist ::= STRING\",\n /*   7 */ \"expr ::= expr AND expr\",\n /*   8 */ \"expr ::= expr OR expr\",\n /*   9 */ \"expr ::= expr NOT expr\",\n /*  10 */ \"expr ::= colset COLON LP expr RP\",\n /*  11 */ \"expr ::= LP expr RP\",\n /*  12 */ \"expr ::= exprlist\",\n /*  13 */ \"exprlist ::= cnearset\",\n /*  14 */ \"exprlist ::= exprlist cnearset\",\n /*  15 */ \"cnearset ::= nearset\",\n /*  16 */ \"cnearset ::= colset COLON nearset\",\n /*  17 */ \"nearset ::= phrase\",\n /*  18 */ \"nearset ::= STRING LP nearphrases neardist_opt RP\",\n /*  19 */ \"nearphrases ::= phrase\",\n /*  20 */ \"nearphrases ::= nearphrases phrase\",\n /*  21 */ \"neardist_opt ::=\",\n /*  22 */ \"neardist_opt ::= COMMA STRING\",\n /*  23 */ \"phrase ::= phrase PLUS STRING star_opt\",\n /*  24 */ \"phrase ::= STRING star_opt\",\n /*  25 */ \"star_opt ::= STAR\",\n /*  26 */ \"star_opt ::=\",\n};\n#endif /* NDEBUG */\n\n\n#if fts5YYSTACKDEPTH<=0\n/*\n** Try to increase the size of the parser stack.  Return the number\n** of errors.  Return 0 on success.\n*/\nstatic int fts5yyGrowStack(fts5yyParser *p){\n  int newSize;\n  int idx;\n  fts5yyStackEntry *pNew;\n\n  newSize = p->fts5yystksz*2 + 100;\n  idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0;\n  if( p->fts5yystack==&p->fts5yystk0 ){\n    pNew = malloc(newSize*sizeof(pNew[0]));\n    if( pNew ) pNew[0] = p->fts5yystk0;\n  }else{\n    pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0]));\n  }\n  if( pNew ){\n    p->fts5yystack = pNew;\n    p->fts5yytos = &p->fts5yystack[idx];\n#ifndef NDEBUG\n    if( fts5yyTraceFILE ){\n      fprintf(fts5yyTraceFILE,\"%sStack grows from %d to %d entries.\\n\",\n              fts5yyTracePrompt, p->fts5yystksz, newSize);\n    }\n#endif\n    p->fts5yystksz = newSize;\n  }\n  return pNew==0; \n}\n#endif\n\n/* Datatype of the argument to the memory allocated passed as the\n** second argument to sqlite3Fts5ParserAlloc() below.  This can be changed by\n** putting an appropriate #define in the %include section of the input\n** grammar.\n*/\n#ifndef fts5YYMALLOCARGTYPE\n# define fts5YYMALLOCARGTYPE size_t\n#endif\n\n/* Initialize a new parser that has already been allocated.\n*/\nstatic void sqlite3Fts5ParserInit(void *fts5yypParser){\n  fts5yyParser *pParser = (fts5yyParser*)fts5yypParser;\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  pParser->fts5yyhwm = 0;\n#endif\n#if fts5YYSTACKDEPTH<=0\n  pParser->fts5yytos = NULL;\n  pParser->fts5yystack = NULL;\n  pParser->fts5yystksz = 0;\n  if( fts5yyGrowStack(pParser) ){\n    pParser->fts5yystack = &pParser->fts5yystk0;\n    pParser->fts5yystksz = 1;\n  }\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  pParser->fts5yyerrcnt = -1;\n#endif\n  pParser->fts5yytos = pParser->fts5yystack;\n  pParser->fts5yystack[0].stateno = 0;\n  pParser->fts5yystack[0].major = 0;\n#if fts5YYSTACKDEPTH>0\n  pParser->fts5yystackEnd = &pParser->fts5yystack[fts5YYSTACKDEPTH-1];\n#endif\n}\n\n#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK\n/* \n** This function allocates a new parser.\n** The only argument is a pointer to a function which works like\n** malloc.\n**\n** Inputs:\n** A pointer to the function used to allocate memory.\n**\n** Outputs:\n** A pointer to a parser.  This pointer is used in subsequent calls\n** to sqlite3Fts5Parser and sqlite3Fts5ParserFree.\n*/\nstatic void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){\n  fts5yyParser *pParser;\n  pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) );\n  if( pParser ) sqlite3Fts5ParserInit(pParser);\n  return pParser;\n}\n#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */\n\n\n/* The following function deletes the \"minor type\" or semantic value\n** associated with a symbol.  The symbol can be either a terminal\n** or nonterminal. \"fts5yymajor\" is the symbol code, and \"fts5yypminor\" is\n** a pointer to the value to be deleted.  The code used to do the \n** deletions is derived from the %destructor and/or %token_destructor\n** directives of the input grammar.\n*/\nstatic void fts5yy_destructor(\n  fts5yyParser *fts5yypParser,    /* The parser */\n  fts5YYCODETYPE fts5yymajor,     /* Type code for object to destroy */\n  fts5YYMINORTYPE *fts5yypminor   /* The object to be destroyed */\n){\n  sqlite3Fts5ParserARG_FETCH;\n  switch( fts5yymajor ){\n    /* Here is inserted the actions which take place when a\n    ** terminal or non-terminal is destroyed.  This can happen\n    ** when the symbol is popped from the stack during a\n    ** reduce or during error processing or when a parser is \n    ** being destroyed before it is finished parsing.\n    **\n    ** Note: during a reduce, the only symbols destroyed are those\n    ** which appear on the RHS of the rule, but which are *not* used\n    ** inside the C code.\n    */\n/********* Begin destructor definitions ***************************************/\n    case 16: /* input */\n{\n (void)pParse; \n}\n      break;\n    case 17: /* expr */\n    case 18: /* cnearset */\n    case 19: /* exprlist */\n{\n sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); \n}\n      break;\n    case 20: /* colset */\n    case 21: /* colsetlist */\n{\n sqlite3_free((fts5yypminor->fts5yy11)); \n}\n      break;\n    case 22: /* nearset */\n    case 23: /* nearphrases */\n{\n sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); \n}\n      break;\n    case 24: /* phrase */\n{\n sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); \n}\n      break;\n/********* End destructor definitions *****************************************/\n    default:  break;   /* If no destructor action specified: do nothing */\n  }\n}\n\n/*\n** Pop the parser's stack once.\n**\n** If there is a destructor routine associated with the token which\n** is popped from the stack, then call it.\n*/\nstatic void fts5yy_pop_parser_stack(fts5yyParser *pParser){\n  fts5yyStackEntry *fts5yytos;\n  assert( pParser->fts5yytos!=0 );\n  assert( pParser->fts5yytos > pParser->fts5yystack );\n  fts5yytos = pParser->fts5yytos--;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sPopping %s\\n\",\n      fts5yyTracePrompt,\n      fts5yyTokenName[fts5yytos->major]);\n  }\n#endif\n  fts5yy_destructor(pParser, fts5yytos->major, &fts5yytos->minor);\n}\n\n/*\n** Clear all secondary memory allocations from the parser\n*/\nstatic void sqlite3Fts5ParserFinalize(void *p){\n  fts5yyParser *pParser = (fts5yyParser*)p;\n  while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser);\n#if fts5YYSTACKDEPTH<=0\n  if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack);\n#endif\n}\n\n#ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK\n/* \n** Deallocate and destroy a parser.  Destructors are called for\n** all stack elements before shutting the parser down.\n**\n** If the fts5YYPARSEFREENEVERNULL macro exists (for example because it\n** is defined in a %include section of the input grammar) then it is\n** assumed that the input pointer is never NULL.\n*/\nstatic void sqlite3Fts5ParserFree(\n  void *p,                    /* The parser to be deleted */\n  void (*freeProc)(void*)     /* Function used to reclaim memory */\n){\n#ifndef fts5YYPARSEFREENEVERNULL\n  if( p==0 ) return;\n#endif\n  sqlite3Fts5ParserFinalize(p);\n  (*freeProc)(p);\n}\n#endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */\n\n/*\n** Return the peak depth of the stack for a parser.\n*/\n#ifdef fts5YYTRACKMAXSTACKDEPTH\nstatic int sqlite3Fts5ParserStackPeak(void *p){\n  fts5yyParser *pParser = (fts5yyParser*)p;\n  return pParser->fts5yyhwm;\n}\n#endif\n\n/*\n** Find the appropriate action for a parser given the terminal\n** look-ahead token iLookAhead.\n*/\nstatic unsigned int fts5yy_find_shift_action(\n  fts5yyParser *pParser,        /* The parser */\n  fts5YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n  int stateno = pParser->fts5yytos->stateno;\n \n  if( stateno>=fts5YY_MIN_REDUCE ) return stateno;\n  assert( stateno <= fts5YY_SHIFT_COUNT );\n  do{\n    i = fts5yy_shift_ofst[stateno];\n    assert( iLookAhead!=fts5YYNOCODE );\n    i += iLookAhead;\n    if( i<0 || i>=fts5YY_ACTTAB_COUNT || fts5yy_lookahead[i]!=iLookAhead ){\n#ifdef fts5YYFALLBACK\n      fts5YYCODETYPE iFallback;            /* Fallback token */\n      if( iLookAhead<sizeof(fts5yyFallback)/sizeof(fts5yyFallback[0])\n             && (iFallback = fts5yyFallback[iLookAhead])!=0 ){\n#ifndef NDEBUG\n        if( fts5yyTraceFILE ){\n          fprintf(fts5yyTraceFILE, \"%sFALLBACK %s => %s\\n\",\n             fts5yyTracePrompt, fts5yyTokenName[iLookAhead], fts5yyTokenName[iFallback]);\n        }\n#endif\n        assert( fts5yyFallback[iFallback]==0 ); /* Fallback loop must terminate */\n        iLookAhead = iFallback;\n        continue;\n      }\n#endif\n#ifdef fts5YYWILDCARD\n      {\n        int j = i - iLookAhead + fts5YYWILDCARD;\n        if( \n#if fts5YY_SHIFT_MIN+fts5YYWILDCARD<0\n          j>=0 &&\n#endif\n#if fts5YY_SHIFT_MAX+fts5YYWILDCARD>=fts5YY_ACTTAB_COUNT\n          j<fts5YY_ACTTAB_COUNT &&\n#endif\n          fts5yy_lookahead[j]==fts5YYWILDCARD && iLookAhead>0\n        ){\n#ifndef NDEBUG\n          if( fts5yyTraceFILE ){\n            fprintf(fts5yyTraceFILE, \"%sWILDCARD %s => %s\\n\",\n               fts5yyTracePrompt, fts5yyTokenName[iLookAhead],\n               fts5yyTokenName[fts5YYWILDCARD]);\n          }\n#endif /* NDEBUG */\n          return fts5yy_action[j];\n        }\n      }\n#endif /* fts5YYWILDCARD */\n      return fts5yy_default[stateno];\n    }else{\n      return fts5yy_action[i];\n    }\n  }while(1);\n}\n\n/*\n** Find the appropriate action for a parser given the non-terminal\n** look-ahead token iLookAhead.\n*/\nstatic int fts5yy_find_reduce_action(\n  int stateno,              /* Current state number */\n  fts5YYCODETYPE iLookAhead     /* The look-ahead token */\n){\n  int i;\n#ifdef fts5YYERRORSYMBOL\n  if( stateno>fts5YY_REDUCE_COUNT ){\n    return fts5yy_default[stateno];\n  }\n#else\n  assert( stateno<=fts5YY_REDUCE_COUNT );\n#endif\n  i = fts5yy_reduce_ofst[stateno];\n  assert( i!=fts5YY_REDUCE_USE_DFLT );\n  assert( iLookAhead!=fts5YYNOCODE );\n  i += iLookAhead;\n#ifdef fts5YYERRORSYMBOL\n  if( i<0 || i>=fts5YY_ACTTAB_COUNT || fts5yy_lookahead[i]!=iLookAhead ){\n    return fts5yy_default[stateno];\n  }\n#else\n  assert( i>=0 && i<fts5YY_ACTTAB_COUNT );\n  assert( fts5yy_lookahead[i]==iLookAhead );\n#endif\n  return fts5yy_action[i];\n}\n\n/*\n** The following routine is called if the stack overflows.\n*/\nstatic void fts5yyStackOverflow(fts5yyParser *fts5yypParser){\n   sqlite3Fts5ParserARG_FETCH;\n#ifndef NDEBUG\n   if( fts5yyTraceFILE ){\n     fprintf(fts5yyTraceFILE,\"%sStack Overflow!\\n\",fts5yyTracePrompt);\n   }\n#endif\n   while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);\n   /* Here code is inserted which will execute if the parser\n   ** stack every overflows */\n/******** Begin %stack_overflow code ******************************************/\n\n  sqlite3Fts5ParseError(pParse, \"fts5: parser stack overflow\");\n/******** End %stack_overflow code ********************************************/\n   sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument var */\n}\n\n/*\n** Print tracing information for a SHIFT action\n*/\n#ifndef NDEBUG\nstatic void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){\n  if( fts5yyTraceFILE ){\n    if( fts5yyNewState<fts5YYNSTATE ){\n      fprintf(fts5yyTraceFILE,\"%sShift '%s', go to state %d\\n\",\n         fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major],\n         fts5yyNewState);\n    }else{\n      fprintf(fts5yyTraceFILE,\"%sShift '%s'\\n\",\n         fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]);\n    }\n  }\n}\n#else\n# define fts5yyTraceShift(X,Y)\n#endif\n\n/*\n** Perform a shift action.\n*/\nstatic void fts5yy_shift(\n  fts5yyParser *fts5yypParser,          /* The parser to be shifted */\n  int fts5yyNewState,               /* The new state to shift in */\n  int fts5yyMajor,                  /* The major token to shift in */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor        /* The minor token to shift in */\n){\n  fts5yyStackEntry *fts5yytos;\n  fts5yypParser->fts5yytos++;\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n  if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){\n    fts5yypParser->fts5yyhwm++;\n    assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) );\n  }\n#endif\n#if fts5YYSTACKDEPTH>0 \n  if( fts5yypParser->fts5yytos>fts5yypParser->fts5yystackEnd ){\n    fts5yypParser->fts5yytos--;\n    fts5yyStackOverflow(fts5yypParser);\n    return;\n  }\n#else\n  if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){\n    if( fts5yyGrowStack(fts5yypParser) ){\n      fts5yypParser->fts5yytos--;\n      fts5yyStackOverflow(fts5yypParser);\n      return;\n    }\n  }\n#endif\n  if( fts5yyNewState > fts5YY_MAX_SHIFT ){\n    fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE;\n  }\n  fts5yytos = fts5yypParser->fts5yytos;\n  fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState;\n  fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor;\n  fts5yytos->minor.fts5yy0 = fts5yyMinor;\n  fts5yyTraceShift(fts5yypParser, fts5yyNewState);\n}\n\n/* The following table contains information about every rule that\n** is used during the reduce.\n*/\nstatic const struct {\n  fts5YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */\n  signed char nrhs;     /* Negative of the number of RHS symbols in the rule */\n} fts5yyRuleInfo[] = {\n  { 16, -1 },\n  { 20, -4 },\n  { 20, -3 },\n  { 20, -1 },\n  { 20, -2 },\n  { 21, -2 },\n  { 21, -1 },\n  { 17, -3 },\n  { 17, -3 },\n  { 17, -3 },\n  { 17, -5 },\n  { 17, -3 },\n  { 17, -1 },\n  { 19, -1 },\n  { 19, -2 },\n  { 18, -1 },\n  { 18, -3 },\n  { 22, -1 },\n  { 22, -5 },\n  { 23, -1 },\n  { 23, -2 },\n  { 25, 0 },\n  { 25, -2 },\n  { 24, -4 },\n  { 24, -2 },\n  { 26, -1 },\n  { 26, 0 },\n};\n\nstatic void fts5yy_accept(fts5yyParser*);  /* Forward Declaration */\n\n/*\n** Perform a reduce action and the shift that must immediately\n** follow the reduce.\n*/\nstatic void fts5yy_reduce(\n  fts5yyParser *fts5yypParser,         /* The parser */\n  unsigned int fts5yyruleno        /* Number of the rule by which to reduce */\n){\n  int fts5yygoto;                     /* The next state */\n  int fts5yyact;                      /* The next action */\n  fts5yyStackEntry *fts5yymsp;            /* The top of the parser's stack */\n  int fts5yysize;                     /* Amount to pop the stack */\n  sqlite3Fts5ParserARG_FETCH;\n  fts5yymsp = fts5yypParser->fts5yytos;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){\n    fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;\n    fprintf(fts5yyTraceFILE, \"%sReduce [%s], go to state %d.\\n\", fts5yyTracePrompt,\n      fts5yyRuleName[fts5yyruleno], fts5yymsp[fts5yysize].stateno);\n  }\n#endif /* NDEBUG */\n\n  /* Check that the stack is large enough to grow by a single entry\n  ** if the RHS of the rule is empty.  This ensures that there is room\n  ** enough on the stack to push the LHS value */\n  if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){\n#ifdef fts5YYTRACKMAXSTACKDEPTH\n    if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){\n      fts5yypParser->fts5yyhwm++;\n      assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack));\n    }\n#endif\n#if fts5YYSTACKDEPTH>0 \n    if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){\n      fts5yyStackOverflow(fts5yypParser);\n      return;\n    }\n#else\n    if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){\n      if( fts5yyGrowStack(fts5yypParser) ){\n        fts5yyStackOverflow(fts5yypParser);\n        return;\n      }\n      fts5yymsp = fts5yypParser->fts5yytos;\n    }\n#endif\n  }\n\n  switch( fts5yyruleno ){\n  /* Beginning here are the reduction cases.  A typical example\n  ** follows:\n  **   case 0:\n  **  #line <lineno> <grammarfile>\n  **     { ... }           // User supplied code\n  **  #line <lineno> <thisfile>\n  **     break;\n  */\n/********** Begin reduce actions **********************************************/\n        fts5YYMINORTYPE fts5yylhsminor;\n      case 0: /* input ::= expr */\n{ sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); }\n        break;\n      case 1: /* colset ::= MINUS LCP colsetlist RCP */\n{ \n    fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);\n}\n        break;\n      case 2: /* colset ::= LCP colsetlist RCP */\n{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; }\n        break;\n      case 3: /* colset ::= STRING */\n{\n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);\n}\n  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 4: /* colset ::= MINUS STRING */\n{\n  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0);\n  fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11);\n}\n        break;\n      case 5: /* colsetlist ::= colsetlist STRING */\n{ \n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); }\n  fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 6: /* colsetlist ::= STRING */\n{ \n  fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); \n}\n  fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11;\n        break;\n      case 7: /* expr ::= expr AND expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 8: /* expr ::= expr OR expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 9: /* expr ::= expr NOT expr */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 10: /* expr ::= colset COLON LP expr RP */\n{\n  sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11);\n  fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;\n}\n  fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 11: /* expr ::= LP expr RP */\n{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;}\n        break;\n      case 12: /* expr ::= exprlist */\n      case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13);\n{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;}\n  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 14: /* exprlist ::= exprlist cnearset */\n{\n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24);\n}\n  fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 15: /* cnearset ::= nearset */\n{ \n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); \n}\n  fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 16: /* cnearset ::= colset COLON nearset */\n{ \n  fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); \n  sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11);\n}\n  fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24;\n        break;\n      case 17: /* nearset ::= phrase */\n{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); }\n  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 18: /* nearset ::= STRING LP nearphrases neardist_opt RP */\n{\n  sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0);\n  sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0);\n  fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46;\n}\n  fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 19: /* nearphrases ::= phrase */\n{ \n  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); \n}\n  fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 20: /* nearphrases ::= nearphrases phrase */\n{\n  fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53);\n}\n  fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46;\n        break;\n      case 21: /* neardist_opt ::= */\n{ fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; }\n        break;\n      case 22: /* neardist_opt ::= COMMA STRING */\n{ fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; }\n        break;\n      case 23: /* phrase ::= phrase PLUS STRING star_opt */\n{ \n  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);\n}\n  fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53;\n        break;\n      case 24: /* phrase ::= STRING star_opt */\n{ \n  fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4);\n}\n  fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53;\n        break;\n      case 25: /* star_opt ::= STAR */\n{ fts5yymsp[0].minor.fts5yy4 = 1; }\n        break;\n      case 26: /* star_opt ::= */\n{ fts5yymsp[1].minor.fts5yy4 = 0; }\n        break;\n      default:\n        break;\n/********** End reduce actions ************************************************/\n  };\n  assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );\n  fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;\n  fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;\n  fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);\n\n  /* There are no SHIFTREDUCE actions on nonterminals because the table\n  ** generator has simplified them to pure REDUCE actions. */\n  assert( !(fts5yyact>fts5YY_MAX_SHIFT && fts5yyact<=fts5YY_MAX_SHIFTREDUCE) );\n\n  /* It is not possible for a REDUCE to be followed by an error */\n  assert( fts5yyact!=fts5YY_ERROR_ACTION );\n\n  if( fts5yyact==fts5YY_ACCEPT_ACTION ){\n    fts5yypParser->fts5yytos += fts5yysize;\n    fts5yy_accept(fts5yypParser);\n  }else{\n    fts5yymsp += fts5yysize+1;\n    fts5yypParser->fts5yytos = fts5yymsp;\n    fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact;\n    fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto;\n    fts5yyTraceShift(fts5yypParser, fts5yyact);\n  }\n}\n\n/*\n** The following code executes when the parse fails\n*/\n#ifndef fts5YYNOERRORRECOVERY\nstatic void fts5yy_parse_failed(\n  fts5yyParser *fts5yypParser           /* The parser */\n){\n  sqlite3Fts5ParserARG_FETCH;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sFail!\\n\",fts5yyTracePrompt);\n  }\n#endif\n  while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser);\n  /* Here code is inserted which will be executed whenever the\n  ** parser fails */\n/************ Begin %parse_failure code ***************************************/\n/************ End %parse_failure code *****************************************/\n  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n#endif /* fts5YYNOERRORRECOVERY */\n\n/*\n** The following code executes when a syntax error first occurs.\n*/\nstatic void fts5yy_syntax_error(\n  fts5yyParser *fts5yypParser,           /* The parser */\n  int fts5yymajor,                   /* The major type of the error token */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor         /* The minor type of the error token */\n){\n  sqlite3Fts5ParserARG_FETCH;\n#define FTS5TOKEN fts5yyminor\n/************ Begin %syntax_error code ****************************************/\n\n  UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */\n  sqlite3Fts5ParseError(\n    pParse, \"fts5: syntax error near \\\"%.*s\\\"\",FTS5TOKEN.n,FTS5TOKEN.p\n  );\n/************ End %syntax_error code ******************************************/\n  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/*\n** The following is executed when the parser accepts\n*/\nstatic void fts5yy_accept(\n  fts5yyParser *fts5yypParser           /* The parser */\n){\n  sqlite3Fts5ParserARG_FETCH;\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sAccept!\\n\",fts5yyTracePrompt);\n  }\n#endif\n#ifndef fts5YYNOERRORRECOVERY\n  fts5yypParser->fts5yyerrcnt = -1;\n#endif\n  assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack );\n  /* Here code is inserted which will be executed whenever the\n  ** parser accepts */\n/*********** Begin %parse_accept code *****************************************/\n/*********** End %parse_accept code *******************************************/\n  sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */\n}\n\n/* The main parser program.\n** The first argument is a pointer to a structure obtained from\n** \"sqlite3Fts5ParserAlloc\" which describes the current state of the parser.\n** The second argument is the major token number.  The third is\n** the minor token.  The fourth optional argument is whatever the\n** user wants (and specified in the grammar) and is available for\n** use by the action routines.\n**\n** Inputs:\n** <ul>\n** <li> A pointer to the parser (an opaque structure.)\n** <li> The major token number.\n** <li> The minor token number.\n** <li> An option argument of a grammar-specified type.\n** </ul>\n**\n** Outputs:\n** None.\n*/\nstatic void sqlite3Fts5Parser(\n  void *fts5yyp,                   /* The parser */\n  int fts5yymajor,                 /* The major token code number */\n  sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor       /* The value for the token */\n  sqlite3Fts5ParserARG_PDECL               /* Optional %extra_argument parameter */\n){\n  fts5YYMINORTYPE fts5yyminorunion;\n  unsigned int fts5yyact;   /* The parser action. */\n#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)\n  int fts5yyendofinput;     /* True if we are at the end of input */\n#endif\n#ifdef fts5YYERRORSYMBOL\n  int fts5yyerrorhit = 0;   /* True if fts5yymajor has invoked an error */\n#endif\n  fts5yyParser *fts5yypParser;  /* The parser */\n\n  fts5yypParser = (fts5yyParser*)fts5yyp;\n  assert( fts5yypParser->fts5yytos!=0 );\n#if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY)\n  fts5yyendofinput = (fts5yymajor==0);\n#endif\n  sqlite3Fts5ParserARG_STORE;\n\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fprintf(fts5yyTraceFILE,\"%sInput '%s'\\n\",fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);\n  }\n#endif\n\n  do{\n    fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor);\n    if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){\n      fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor);\n#ifndef fts5YYNOERRORRECOVERY\n      fts5yypParser->fts5yyerrcnt--;\n#endif\n      fts5yymajor = fts5YYNOCODE;\n    }else if( fts5yyact <= fts5YY_MAX_REDUCE ){\n      fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE);\n    }else{\n      assert( fts5yyact == fts5YY_ERROR_ACTION );\n      fts5yyminorunion.fts5yy0 = fts5yyminor;\n#ifdef fts5YYERRORSYMBOL\n      int fts5yymx;\n#endif\n#ifndef NDEBUG\n      if( fts5yyTraceFILE ){\n        fprintf(fts5yyTraceFILE,\"%sSyntax Error!\\n\",fts5yyTracePrompt);\n      }\n#endif\n#ifdef fts5YYERRORSYMBOL\n      /* A syntax error has occurred.\n      ** The response to an error depends upon whether or not the\n      ** grammar defines an error token \"ERROR\".  \n      **\n      ** This is what we do if the grammar does define ERROR:\n      **\n      **  * Call the %syntax_error function.\n      **\n      **  * Begin popping the stack until we enter a state where\n      **    it is legal to shift the error symbol, then shift\n      **    the error symbol.\n      **\n      **  * Set the error count to three.\n      **\n      **  * Begin accepting and shifting new tokens.  No new error\n      **    processing will occur until three tokens have been\n      **    shifted successfully.\n      **\n      */\n      if( fts5yypParser->fts5yyerrcnt<0 ){\n        fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor);\n      }\n      fts5yymx = fts5yypParser->fts5yytos->major;\n      if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){\n#ifndef NDEBUG\n        if( fts5yyTraceFILE ){\n          fprintf(fts5yyTraceFILE,\"%sDiscard input token %s\\n\",\n             fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]);\n        }\n#endif\n        fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion);\n        fts5yymajor = fts5YYNOCODE;\n      }else{\n        while( fts5yypParser->fts5yytos >= fts5yypParser->fts5yystack\n            && fts5yymx != fts5YYERRORSYMBOL\n            && (fts5yyact = fts5yy_find_reduce_action(\n                        fts5yypParser->fts5yytos->stateno,\n                        fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE\n        ){\n          fts5yy_pop_parser_stack(fts5yypParser);\n        }\n        if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){\n          fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n          fts5yy_parse_failed(fts5yypParser);\n#ifndef fts5YYNOERRORRECOVERY\n          fts5yypParser->fts5yyerrcnt = -1;\n#endif\n          fts5yymajor = fts5YYNOCODE;\n        }else if( fts5yymx!=fts5YYERRORSYMBOL ){\n          fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor);\n        }\n      }\n      fts5yypParser->fts5yyerrcnt = 3;\n      fts5yyerrorhit = 1;\n#elif defined(fts5YYNOERRORRECOVERY)\n      /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to\n      ** do any kind of error recovery.  Instead, simply invoke the syntax\n      ** error routine and continue going as if nothing had happened.\n      **\n      ** Applications can set this macro (for example inside %include) if\n      ** they intend to abandon the parse upon the first syntax error seen.\n      */\n      fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);\n      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n      fts5yymajor = fts5YYNOCODE;\n      \n#else  /* fts5YYERRORSYMBOL is not defined */\n      /* This is what we do if the grammar does not define ERROR:\n      **\n      **  * Report an error message, and throw away the input token.\n      **\n      **  * If the input token is $, then fail the parse.\n      **\n      ** As before, subsequent error messages are suppressed until\n      ** three input tokens have been successfully shifted.\n      */\n      if( fts5yypParser->fts5yyerrcnt<=0 ){\n        fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor);\n      }\n      fts5yypParser->fts5yyerrcnt = 3;\n      fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion);\n      if( fts5yyendofinput ){\n        fts5yy_parse_failed(fts5yypParser);\n#ifndef fts5YYNOERRORRECOVERY\n        fts5yypParser->fts5yyerrcnt = -1;\n#endif\n      }\n      fts5yymajor = fts5YYNOCODE;\n#endif\n    }\n  }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack );\n#ifndef NDEBUG\n  if( fts5yyTraceFILE ){\n    fts5yyStackEntry *i;\n    char cDiv = '[';\n    fprintf(fts5yyTraceFILE,\"%sReturn. Stack=\",fts5yyTracePrompt);\n    for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){\n      fprintf(fts5yyTraceFILE,\"%c%s\", cDiv, fts5yyTokenName[i->major]);\n      cDiv = ' ';\n    }\n    fprintf(fts5yyTraceFILE,\"]\\n\");\n  }\n#endif\n  return;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n/* #include \"fts5Int.h\" */\n#include <math.h>                 /* amalgamator: keep */\n\n/*\n** Object used to iterate through all \"coalesced phrase instances\" in \n** a single column of the current row. If the phrase instances in the\n** column being considered do not overlap, this object simply iterates\n** through them. Or, if they do overlap (share one or more tokens in\n** common), each set of overlapping instances is treated as a single\n** match. See documentation for the highlight() auxiliary function for\n** details.\n**\n** Usage is:\n**\n**   for(rc = fts5CInstIterNext(pApi, pFts, iCol, &iter);\n**      (rc==SQLITE_OK && 0==fts5CInstIterEof(&iter);\n**      rc = fts5CInstIterNext(&iter)\n**   ){\n**     printf(\"instance starts at %d, ends at %d\\n\", iter.iStart, iter.iEnd);\n**   }\n**\n*/\ntypedef struct CInstIter CInstIter;\nstruct CInstIter {\n  const Fts5ExtensionApi *pApi;   /* API offered by current FTS version */\n  Fts5Context *pFts;              /* First arg to pass to pApi functions */\n  int iCol;                       /* Column to search */\n  int iInst;                      /* Next phrase instance index */\n  int nInst;                      /* Total number of phrase instances */\n\n  /* Output variables */\n  int iStart;                     /* First token in coalesced phrase instance */\n  int iEnd;                       /* Last token in coalesced phrase instance */\n};\n\n/*\n** Advance the iterator to the next coalesced phrase instance. Return\n** an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n*/\nstatic int fts5CInstIterNext(CInstIter *pIter){\n  int rc = SQLITE_OK;\n  pIter->iStart = -1;\n  pIter->iEnd = -1;\n\n  while( rc==SQLITE_OK && pIter->iInst<pIter->nInst ){\n    int ip; int ic; int io;\n    rc = pIter->pApi->xInst(pIter->pFts, pIter->iInst, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      if( ic==pIter->iCol ){\n        int iEnd = io - 1 + pIter->pApi->xPhraseSize(pIter->pFts, ip);\n        if( pIter->iStart<0 ){\n          pIter->iStart = io;\n          pIter->iEnd = iEnd;\n        }else if( io<=pIter->iEnd ){\n          if( iEnd>pIter->iEnd ) pIter->iEnd = iEnd;\n        }else{\n          break;\n        }\n      }\n      pIter->iInst++;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Initialize the iterator object indicated by the final parameter to \n** iterate through coalesced phrase instances in column iCol.\n*/\nstatic int fts5CInstIterInit(\n  const Fts5ExtensionApi *pApi,\n  Fts5Context *pFts,\n  int iCol,\n  CInstIter *pIter\n){\n  int rc;\n\n  memset(pIter, 0, sizeof(CInstIter));\n  pIter->pApi = pApi;\n  pIter->pFts = pFts;\n  pIter->iCol = iCol;\n  rc = pApi->xInstCount(pFts, &pIter->nInst);\n\n  if( rc==SQLITE_OK ){\n    rc = fts5CInstIterNext(pIter);\n  }\n\n  return rc;\n}\n\n\n\n/*************************************************************************\n** Start of highlight() implementation.\n*/\ntypedef struct HighlightContext HighlightContext;\nstruct HighlightContext {\n  CInstIter iter;                 /* Coalesced Instance Iterator */\n  int iPos;                       /* Current token offset in zIn[] */\n  int iRangeStart;                /* First token to include */\n  int iRangeEnd;                  /* If non-zero, last token to include */\n  const char *zOpen;              /* Opening highlight */\n  const char *zClose;             /* Closing highlight */\n  const char *zIn;                /* Input text */\n  int nIn;                        /* Size of input text in bytes */\n  int iOff;                       /* Current offset within zIn[] */\n  char *zOut;                     /* Output value */\n};\n\n/*\n** Append text to the HighlightContext output string - p->zOut. Argument\n** z points to a buffer containing n bytes of text to append. If n is \n** negative, everything up until the first '\\0' is appended to the output.\n**\n** If *pRc is set to any value other than SQLITE_OK when this function is \n** called, it is a no-op. If an error (i.e. an OOM condition) is encountered, \n** *pRc is set to an error code before returning. \n*/\nstatic void fts5HighlightAppend(\n  int *pRc, \n  HighlightContext *p, \n  const char *z, int n\n){\n  if( *pRc==SQLITE_OK ){\n    if( n<0 ) n = (int)strlen(z);\n    p->zOut = sqlite3_mprintf(\"%z%.*s\", p->zOut, n, z);\n    if( p->zOut==0 ) *pRc = SQLITE_NOMEM;\n  }\n}\n\n/*\n** Tokenizer callback used by implementation of highlight() function.\n*/\nstatic int fts5HighlightCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  HighlightContext *p = (HighlightContext*)pContext;\n  int rc = SQLITE_OK;\n  int iPos;\n\n  UNUSED_PARAM2(pToken, nToken);\n\n  if( tflags & FTS5_TOKEN_COLOCATED ) return SQLITE_OK;\n  iPos = p->iPos++;\n\n  if( p->iRangeEnd>0 ){\n    if( iPos<p->iRangeStart || iPos>p->iRangeEnd ) return SQLITE_OK;\n    if( p->iRangeStart && iPos==p->iRangeStart ) p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iStart ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iStartOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    p->iOff = iStartOff;\n  }\n\n  if( iPos==p->iter.iEnd ){\n    if( p->iRangeEnd && p->iter.iStart<p->iRangeStart ){\n      fts5HighlightAppend(&rc, p, p->zOpen, -1);\n    }\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    fts5HighlightAppend(&rc, p, p->zClose, -1);\n    p->iOff = iEndOff;\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&p->iter);\n    }\n  }\n\n  if( p->iRangeEnd>0 && iPos==p->iRangeEnd ){\n    fts5HighlightAppend(&rc, p, &p->zIn[p->iOff], iEndOff - p->iOff);\n    p->iOff = iEndOff;\n    if( iPos>=p->iter.iStart && iPos<p->iter.iEnd ){\n      fts5HighlightAppend(&rc, p, p->zClose, -1);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of highlight() function.\n*/\nstatic void fts5HighlightFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc;\n  int iCol;\n\n  if( nVal!=3 ){\n    const char *zErr = \"wrong number of arguments to function highlight()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  iCol = sqlite3_value_int(apVal[0]);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);\n  ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);\n  rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn);\n\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iCol, &ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n\n    if( rc==SQLITE_OK ){\n      sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n    }\n    sqlite3_free(ctx.zOut);\n  }\n  if( rc!=SQLITE_OK ){\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n/*\n** End of highlight() implementation.\n**************************************************************************/\n\n/*\n** Context object passed to the fts5SentenceFinderCb() function.\n*/\ntypedef struct Fts5SFinder Fts5SFinder;\nstruct Fts5SFinder {\n  int iPos;                       /* Current token position */\n  int nFirstAlloc;                /* Allocated size of aFirst[] */\n  int nFirst;                     /* Number of entries in aFirst[] */\n  int *aFirst;                    /* Array of first token in each sentence */\n  const char *zDoc;               /* Document being tokenized */\n};\n\n/*\n** Add an entry to the Fts5SFinder.aFirst[] array. Grow the array if\n** necessary. Return SQLITE_OK if successful, or SQLITE_NOMEM if an\n** error occurs.\n*/\nstatic int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){\n  if( p->nFirstAlloc==p->nFirst ){\n    int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;\n    int *aNew;\n\n    aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));\n    if( aNew==0 ) return SQLITE_NOMEM;\n    p->aFirst = aNew;\n    p->nFirstAlloc = nNew;\n  }\n  p->aFirst[p->nFirst++] = iAdd;\n  return SQLITE_OK;\n}\n\n/*\n** This function is an xTokenize() callback used by the auxiliary snippet()\n** function. Its job is to identify tokens that are the first in a sentence.\n** For each such token, an entry is added to the SFinder.aFirst[] array.\n*/\nstatic int fts5SentenceFinderCb(\n  void *pContext,                 /* Pointer to HighlightContext object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iStartOff,                  /* Start offset of token */\n  int iEndOff                     /* End offset of token */\n){\n  int rc = SQLITE_OK;\n\n  UNUSED_PARAM2(pToken, nToken);\n  UNUSED_PARAM(iEndOff);\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    Fts5SFinder *p = (Fts5SFinder*)pContext;\n    if( p->iPos>0 ){\n      int i;\n      char c = 0;\n      for(i=iStartOff-1; i>=0; i--){\n        c = p->zDoc[i];\n        if( c!=' ' && c!='\\t' && c!='\\n' && c!='\\r' ) break;\n      }\n      if( i!=iStartOff-1 && (c=='.' || c==':') ){\n        rc = fts5SentenceFinderAdd(p, p->iPos);\n      }\n    }else{\n      rc = fts5SentenceFinderAdd(p, 0);\n    }\n    p->iPos++;\n  }\n  return rc;\n}\n\nstatic int fts5SnippetScore(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  int nDocsize,                   /* Size of column in tokens */\n  unsigned char *aSeen,           /* Array with one element per query phrase */\n  int iCol,                       /* Column to score */\n  int iPos,                       /* Starting offset to score */\n  int nToken,                     /* Max tokens per snippet */\n  int *pnScore,                   /* OUT: Score */\n  int *piPos                      /* OUT: Adjusted offset */\n){\n  int rc;\n  int i;\n  int ip = 0;\n  int ic = 0;\n  int iOff = 0;\n  int iFirst = -1;\n  int nInst;\n  int nScore = 0;\n  int iLast = 0;\n\n  rc = pApi->xInstCount(pFts, &nInst);\n  for(i=0; i<nInst && rc==SQLITE_OK; i++){\n    rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);\n    if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){\n      nScore += (aSeen[ip] ? 1 : 1000);\n      aSeen[ip] = 1;\n      if( iFirst<0 ) iFirst = iOff;\n      iLast = iOff + pApi->xPhraseSize(pFts, ip);\n    }\n  }\n\n  *pnScore = nScore;\n  if( piPos ){\n    int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;\n    if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;\n    if( iAdj<0 ) iAdj = 0;\n    *piPos = iAdj;\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of snippet() function.\n*/\nstatic void fts5SnippetFunction(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  HighlightContext ctx;\n  int rc = SQLITE_OK;             /* Return code */\n  int iCol;                       /* 1st argument to snippet() */\n  const char *zEllips;            /* 4th argument to snippet() */\n  int nToken;                     /* 5th argument to snippet() */\n  int nInst = 0;                  /* Number of instance matches this row */\n  int i;                          /* Used to iterate through instances */\n  int nPhrase;                    /* Number of phrases in query */\n  unsigned char *aSeen;           /* Array of \"seen instance\" flags */\n  int iBestCol;                   /* Column containing best snippet */\n  int iBestStart = 0;             /* First token of best snippet */\n  int nBestScore = 0;             /* Score of best snippet */\n  int nColSize = 0;               /* Total size of iBestCol in tokens */\n  Fts5SFinder sFinder;            /* Used to find the beginnings of sentences */\n  int nCol;\n\n  if( nVal!=5 ){\n    const char *zErr = \"wrong number of arguments to function snippet()\";\n    sqlite3_result_error(pCtx, zErr, -1);\n    return;\n  }\n\n  nCol = pApi->xColumnCount(pFts);\n  memset(&ctx, 0, sizeof(HighlightContext));\n  iCol = sqlite3_value_int(apVal[0]);\n  ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);\n  ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);\n  zEllips = (const char*)sqlite3_value_text(apVal[3]);\n  nToken = sqlite3_value_int(apVal[4]);\n\n  iBestCol = (iCol>=0 ? iCol : 0);\n  nPhrase = pApi->xPhraseCount(pFts);\n  aSeen = sqlite3_malloc(nPhrase);\n  if( aSeen==0 ){\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n\n  memset(&sFinder, 0, sizeof(Fts5SFinder));\n  for(i=0; i<nCol; i++){\n    if( iCol<0 || iCol==i ){\n      int nDoc;\n      int nDocsize;\n      int ii;\n      sFinder.iPos = 0;\n      sFinder.nFirst = 0;\n      rc = pApi->xColumnText(pFts, i, &sFinder.zDoc, &nDoc);\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xTokenize(pFts, \n          sFinder.zDoc, nDoc, (void*)&sFinder,fts5SentenceFinderCb\n      );\n      if( rc!=SQLITE_OK ) break;\n      rc = pApi->xColumnSize(pFts, i, &nDocsize);\n      if( rc!=SQLITE_OK ) break;\n\n      for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){\n        int ip, ic, io;\n        int iAdj;\n        int nScore;\n        int jj;\n\n        rc = pApi->xInst(pFts, ii, &ip, &ic, &io);\n        if( ic!=i || rc!=SQLITE_OK ) continue;\n        memset(aSeen, 0, nPhrase);\n        rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,\n            io, nToken, &nScore, &iAdj\n        );\n        if( rc==SQLITE_OK && nScore>nBestScore ){\n          nBestScore = nScore;\n          iBestCol = i;\n          iBestStart = iAdj;\n          nColSize = nDocsize;\n        }\n\n        if( rc==SQLITE_OK && sFinder.nFirst && nDocsize>nToken ){\n          for(jj=0; jj<(sFinder.nFirst-1); jj++){\n            if( sFinder.aFirst[jj+1]>io ) break;\n          }\n\n          if( sFinder.aFirst[jj]<io ){\n            memset(aSeen, 0, nPhrase);\n            rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i, \n              sFinder.aFirst[jj], nToken, &nScore, 0\n            );\n\n            nScore += (sFinder.aFirst[jj]==0 ? 120 : 100);\n            if( rc==SQLITE_OK && nScore>nBestScore ){\n              nBestScore = nScore;\n              iBestCol = i;\n              iBestStart = sFinder.aFirst[jj];\n              nColSize = nDocsize;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn);\n  }\n  if( rc==SQLITE_OK && nColSize==0 ){\n    rc = pApi->xColumnSize(pFts, iBestCol, &nColSize);\n  }\n  if( ctx.zIn ){\n    if( rc==SQLITE_OK ){\n      rc = fts5CInstIterInit(pApi, pFts, iBestCol, &ctx.iter);\n    }\n\n    ctx.iRangeStart = iBestStart;\n    ctx.iRangeEnd = iBestStart + nToken - 1;\n\n    if( iBestStart>0 ){\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n\n    /* Advance iterator ctx.iter so that it points to the first coalesced\n    ** phrase instance at or following position iBestStart. */\n    while( ctx.iter.iStart>=0 && ctx.iter.iStart<iBestStart && rc==SQLITE_OK ){\n      rc = fts5CInstIterNext(&ctx.iter);\n    }\n\n    if( rc==SQLITE_OK ){\n      rc = pApi->xTokenize(pFts, ctx.zIn, ctx.nIn, (void*)&ctx,fts5HighlightCb);\n    }\n    if( ctx.iRangeEnd>=(nColSize-1) ){\n      fts5HighlightAppend(&rc, &ctx, &ctx.zIn[ctx.iOff], ctx.nIn - ctx.iOff);\n    }else{\n      fts5HighlightAppend(&rc, &ctx, zEllips, -1);\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)ctx.zOut, -1, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  sqlite3_free(ctx.zOut);\n  sqlite3_free(aSeen);\n  sqlite3_free(sFinder.aFirst);\n}\n\n/************************************************************************/\n\n/*\n** The first time the bm25() function is called for a query, an instance\n** of the following structure is allocated and populated.\n*/\ntypedef struct Fts5Bm25Data Fts5Bm25Data;\nstruct Fts5Bm25Data {\n  int nPhrase;                    /* Number of phrases in query */\n  double avgdl;                   /* Average number of tokens in each row */\n  double *aIDF;                   /* IDF for each phrase */\n  double *aFreq;                  /* Array used to calculate phrase freq. */\n};\n\n/*\n** Callback used by fts5Bm25GetData() to count the number of rows in the\n** table matched by each individual phrase within the query.\n*/\nstatic int fts5CountCb(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  void *pUserData                 /* Pointer to sqlite3_int64 variable */\n){\n  sqlite3_int64 *pn = (sqlite3_int64*)pUserData;\n  UNUSED_PARAM2(pApi, pFts);\n  (*pn)++;\n  return SQLITE_OK;\n}\n\n/*\n** Set *ppData to point to the Fts5Bm25Data object for the current query. \n** If the object has not already been allocated, allocate and populate it\n** now.\n*/\nstatic int fts5Bm25GetData(\n  const Fts5ExtensionApi *pApi, \n  Fts5Context *pFts,\n  Fts5Bm25Data **ppData           /* OUT: bm25-data object for this query */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Bm25Data *p;                /* Object to return */\n\n  p = pApi->xGetAuxdata(pFts, 0);\n  if( p==0 ){\n    int nPhrase;                  /* Number of phrases in query */\n    sqlite3_int64 nRow = 0;       /* Number of rows in table */\n    sqlite3_int64 nToken = 0;     /* Number of tokens in table */\n    int nByte;                    /* Bytes of space to allocate */\n    int i;\n\n    /* Allocate the Fts5Bm25Data object */\n    nPhrase = pApi->xPhraseCount(pFts);\n    nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);\n    p = (Fts5Bm25Data*)sqlite3_malloc(nByte);\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(p, 0, nByte);\n      p->nPhrase = nPhrase;\n      p->aIDF = (double*)&p[1];\n      p->aFreq = &p->aIDF[nPhrase];\n    }\n\n    /* Calculate the average document length for this FTS5 table */\n    if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);\n    if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);\n    if( rc==SQLITE_OK ) p->avgdl = (double)nToken  / (double)nRow;\n\n    /* Calculate an IDF for each phrase in the query */\n    for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n      sqlite3_int64 nHit = 0;\n      rc = pApi->xQueryPhrase(pFts, i, (void*)&nHit, fts5CountCb);\n      if( rc==SQLITE_OK ){\n        /* Calculate the IDF (Inverse Document Frequency) for phrase i.\n        ** This is done using the standard BM25 formula as found on wikipedia:\n        **\n        **   IDF = log( (N - nHit + 0.5) / (nHit + 0.5) )\n        **\n        ** where \"N\" is the total number of documents in the set and nHit\n        ** is the number that contain at least one instance of the phrase\n        ** under consideration.\n        **\n        ** The problem with this is that if (N < 2*nHit), the IDF is \n        ** negative. Which is undesirable. So the mimimum allowable IDF is\n        ** (1e-6) - roughly the same as a term that appears in just over\n        ** half of set of 5,000,000 documents.  */\n        double idf = log( (nRow - nHit + 0.5) / (nHit + 0.5) );\n        if( idf<=0.0 ) idf = 1e-6;\n        p->aIDF[i] = idf;\n      }\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(p);\n    }else{\n      rc = pApi->xSetAuxdata(pFts, p, sqlite3_free);\n    }\n    if( rc!=SQLITE_OK ) p = 0;\n  }\n  *ppData = p;\n  return rc;\n}\n\n/*\n** Implementation of bm25() function.\n*/\nstatic void fts5Bm25Function(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n){\n  const double k1 = 1.2;          /* Constant \"k1\" from BM25 formula */\n  const double b = 0.75;          /* Constant \"b\" from BM25 formula */\n  int rc = SQLITE_OK;             /* Error code */\n  double score = 0.0;             /* SQL function return value */\n  Fts5Bm25Data *pData;            /* Values allocated/calculated once only */\n  int i;                          /* Iterator variable */\n  int nInst = 0;                  /* Value returned by xInstCount() */\n  double D = 0.0;                 /* Total number of tokens in row */\n  double *aFreq = 0;              /* Array of phrase freq. for current row */\n\n  /* Calculate the phrase frequency (symbol \"f(qi,D)\" in the documentation)\n  ** for each phrase in the query for the current row. */\n  rc = fts5Bm25GetData(pApi, pFts, &pData);\n  if( rc==SQLITE_OK ){\n    aFreq = pData->aFreq;\n    memset(aFreq, 0, sizeof(double) * pData->nPhrase);\n    rc = pApi->xInstCount(pFts, &nInst);\n  }\n  for(i=0; rc==SQLITE_OK && i<nInst; i++){\n    int ip; int ic; int io;\n    rc = pApi->xInst(pFts, i, &ip, &ic, &io);\n    if( rc==SQLITE_OK ){\n      double w = (nVal > ic) ? sqlite3_value_double(apVal[ic]) : 1.0;\n      aFreq[ip] += w;\n    }\n  }\n\n  /* Figure out the total size of the current row in tokens. */\n  if( rc==SQLITE_OK ){\n    int nTok;\n    rc = pApi->xColumnSize(pFts, -1, &nTok);\n    D = (double)nTok;\n  }\n\n  /* Determine the BM25 score for the current row. */\n  for(i=0; rc==SQLITE_OK && i<pData->nPhrase; i++){\n    score += pData->aIDF[i] * (\n      ( aFreq[i] * (k1 + 1.0) ) / \n      ( aFreq[i] + k1 * (1 - b + b * D / pData->avgdl) )\n    );\n  }\n  \n  /* If no error has occurred, return the calculated score. Otherwise,\n  ** throw an SQL exception.  */\n  if( rc==SQLITE_OK ){\n    sqlite3_result_double(pCtx, -1.0 * score);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\nstatic int sqlite3Fts5AuxInit(fts5_api *pApi){\n  struct Builtin {\n    const char *zFunc;            /* Function name (nul-terminated) */\n    void *pUserData;              /* User-data pointer */\n    fts5_extension_function xFunc;/* Callback function */\n    void (*xDestroy)(void*);      /* Destructor function */\n  } aBuiltin [] = {\n    { \"snippet\",   0, fts5SnippetFunction, 0 },\n    { \"highlight\", 0, fts5HighlightFunction, 0 },\n    { \"bm25\",      0, fts5Bm25Function,    0 },\n  };\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateFunction(pApi,\n        aBuiltin[i].zFunc,\n        aBuiltin[i].pUserData,\n        aBuiltin[i].xFunc,\n        aBuiltin[i].xDestroy\n    );\n  }\n\n  return rc;\n}\n\n\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\nstatic int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){\n  if( (u32)pBuf->nSpace<nByte ){\n    u32 nNew = pBuf->nSpace ? pBuf->nSpace : 64;\n    u8 *pNew;\n    while( nNew<nByte ){\n      nNew = nNew * 2;\n    }\n    pNew = sqlite3_realloc(pBuf->p, nNew);\n    if( pNew==0 ){\n      *pRc = SQLITE_NOMEM;\n      return 1;\n    }else{\n      pBuf->nSpace = nNew;\n      pBuf->p = pNew;\n    }\n  }\n  return 0;\n}\n\n\n/*\n** Encode value iVal as an SQLite varint and append it to the buffer object\n** pBuf. If an OOM error occurs, set the error code in p.\n*/\nstatic void sqlite3Fts5BufferAppendVarint(int *pRc, Fts5Buffer *pBuf, i64 iVal){\n  if( fts5BufferGrow(pRc, pBuf, 9) ) return;\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iVal);\n}\n\nstatic void sqlite3Fts5Put32(u8 *aBuf, int iVal){\n  aBuf[0] = (iVal>>24) & 0x00FF;\n  aBuf[1] = (iVal>>16) & 0x00FF;\n  aBuf[2] = (iVal>> 8) & 0x00FF;\n  aBuf[3] = (iVal>> 0) & 0x00FF;\n}\n\nstatic int sqlite3Fts5Get32(const u8 *aBuf){\n  return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3];\n}\n\n/*\n** Append buffer nData/pData to buffer pBuf. If an OOM error occurs, set \n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic void sqlite3Fts5BufferAppendBlob(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  u32 nData, \n  const u8 *pData\n){\n  assert_nc( *pRc || nData>=0 );\n  if( nData ){\n    if( fts5BufferGrow(pRc, pBuf, nData) ) return;\n    memcpy(&pBuf->p[pBuf->n], pData, nData);\n    pBuf->n += nData;\n  }\n}\n\n/*\n** Append the nul-terminated string zStr to the buffer pBuf. This function\n** ensures that the byte following the buffer data is set to 0x00, even \n** though this byte is not included in the pBuf->n count.\n*/\nstatic void sqlite3Fts5BufferAppendString(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  const char *zStr\n){\n  int nStr = (int)strlen(zStr);\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nStr+1, (const u8*)zStr);\n  pBuf->n--;\n}\n\n/*\n** Argument zFmt is a printf() style format string. This function performs\n** the printf() style processing, then appends the results to buffer pBuf.\n**\n** Like sqlite3Fts5BufferAppendString(), this function ensures that the byte \n** following the buffer data is set to 0x00, even though this byte is not\n** included in the pBuf->n count.\n*/ \nstatic void sqlite3Fts5BufferAppendPrintf(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  char *zFmt, ...\n){\n  if( *pRc==SQLITE_OK ){\n    char *zTmp;\n    va_list ap;\n    va_start(ap, zFmt);\n    zTmp = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n\n    if( zTmp==0 ){\n      *pRc = SQLITE_NOMEM;\n    }else{\n      sqlite3Fts5BufferAppendString(pRc, pBuf, zTmp);\n      sqlite3_free(zTmp);\n    }\n  }\n}\n\nstatic char *sqlite3Fts5Mprintf(int *pRc, const char *zFmt, ...){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    va_list ap;\n    va_start(ap, zFmt);\n    zRet = sqlite3_vmprintf(zFmt, ap);\n    va_end(ap);\n    if( zRet==0 ){\n      *pRc = SQLITE_NOMEM; \n    }\n  }\n  return zRet;\n}\n \n\n/*\n** Free any buffer allocated by pBuf. Zero the structure before returning.\n*/\nstatic void sqlite3Fts5BufferFree(Fts5Buffer *pBuf){\n  sqlite3_free(pBuf->p);\n  memset(pBuf, 0, sizeof(Fts5Buffer));\n}\n\n/*\n** Zero the contents of the buffer object. But do not free the associated \n** memory allocation.\n*/\nstatic void sqlite3Fts5BufferZero(Fts5Buffer *pBuf){\n  pBuf->n = 0;\n}\n\n/*\n** Set the buffer to contain nData/pData. If an OOM error occurs, leave an\n** the error code in p. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic void sqlite3Fts5BufferSet(\n  int *pRc,\n  Fts5Buffer *pBuf, \n  int nData, \n  const u8 *pData\n){\n  pBuf->n = 0;\n  sqlite3Fts5BufferAppendBlob(pRc, pBuf, nData, pData);\n}\n\nstatic int sqlite3Fts5PoslistNext64(\n  const u8 *a, int n,             /* Buffer containing poslist */\n  int *pi,                        /* IN/OUT: Offset within a[] */\n  i64 *piOff                      /* IN/OUT: Current offset */\n){\n  int i = *pi;\n  if( i>=n ){\n    /* EOF */\n    *piOff = -1;\n    return 1;  \n  }else{\n    i64 iOff = *piOff;\n    int iVal;\n    fts5FastGetVarint32(a, i, iVal);\n    if( iVal==1 ){\n      fts5FastGetVarint32(a, i, iVal);\n      iOff = ((i64)iVal) << 32;\n      fts5FastGetVarint32(a, i, iVal);\n    }\n    *piOff = iOff + (iVal-2);\n    *pi = i;\n    return 0;\n  }\n}\n\n\n/*\n** Advance the iterator object passed as the only argument. Return true\n** if the iterator reaches EOF, or false otherwise.\n*/\nstatic int sqlite3Fts5PoslistReaderNext(Fts5PoslistReader *pIter){\n  if( sqlite3Fts5PoslistNext64(pIter->a, pIter->n, &pIter->i, &pIter->iPos) ){\n    pIter->bEof = 1;\n  }\n  return pIter->bEof;\n}\n\nstatic int sqlite3Fts5PoslistReaderInit(\n  const u8 *a, int n,             /* Poslist buffer to iterate through */\n  Fts5PoslistReader *pIter        /* Iterator object to initialize */\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->a = a;\n  pIter->n = n;\n  sqlite3Fts5PoslistReaderNext(pIter);\n  return pIter->bEof;\n}\n\n/*\n** Append position iPos to the position list being accumulated in buffer\n** pBuf, which must be already be large enough to hold the new data.\n** The previous position written to this list is *piPrev. *piPrev is set\n** to iPos before returning.\n*/\nstatic void sqlite3Fts5PoslistSafeAppend(\n  Fts5Buffer *pBuf, \n  i64 *piPrev, \n  i64 iPos\n){\n  static const i64 colmask = ((i64)(0x7FFFFFFF)) << 32;\n  if( (iPos & colmask) != (*piPrev & colmask) ){\n    pBuf->p[pBuf->n++] = 1;\n    pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos>>32));\n    *piPrev = (iPos & colmask);\n  }\n  pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], (iPos-*piPrev)+2);\n  *piPrev = iPos;\n}\n\nstatic int sqlite3Fts5PoslistWriterAppend(\n  Fts5Buffer *pBuf, \n  Fts5PoslistWriter *pWriter,\n  i64 iPos\n){\n  int rc = 0;   /* Initialized only to suppress erroneous warning from Clang */\n  if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc;\n  sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos);\n  return SQLITE_OK;\n}\n\nstatic void *sqlite3Fts5MallocZero(int *pRc, int nByte){\n  void *pRet = 0;\n  if( *pRc==SQLITE_OK ){\n    pRet = sqlite3_malloc(nByte);\n    if( pRet==0 ){\n      if( nByte>0 ) *pRc = SQLITE_NOMEM;\n    }else{\n      memset(pRet, 0, nByte);\n    }\n  }\n  return pRet;\n}\n\n/*\n** Return a nul-terminated copy of the string indicated by pIn. If nIn\n** is non-negative, then it is the length of the string in bytes. Otherwise,\n** the length of the string is determined using strlen().\n**\n** It is the responsibility of the caller to eventually free the returned\n** buffer using sqlite3_free(). If an OOM error occurs, NULL is returned. \n*/\nstatic char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn){\n  char *zRet = 0;\n  if( *pRc==SQLITE_OK ){\n    if( nIn<0 ){\n      nIn = (int)strlen(pIn);\n    }\n    zRet = (char*)sqlite3_malloc(nIn+1);\n    if( zRet ){\n      memcpy(zRet, pIn, nIn);\n      zRet[nIn] = '\\0';\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n  return zRet;\n}\n\n\n/*\n** Return true if character 't' may be part of an FTS5 bareword, or false\n** otherwise. Characters that may be part of barewords:\n**\n**   * All non-ASCII characters,\n**   * The 52 upper and lower case ASCII characters, and\n**   * The 10 integer ASCII characters.\n**   * The underscore character \"_\" (0x5F).\n**   * The unicode \"subsitute\" character (0x1A).\n*/\nstatic int sqlite3Fts5IsBareword(char t){\n  u8 aBareword[128] = {\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00 .. 0x0F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 1, 0, 0, 0, 0, 0,   /* 0x10 .. 0x1F */\n    0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20 .. 0x2F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30 .. 0x3F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40 .. 0x4F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 1,   /* 0x50 .. 0x5F */\n    0, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60 .. 0x6F */\n    1, 1, 1, 1, 1, 1, 1, 1,    1, 1, 1, 0, 0, 0, 0, 0    /* 0x70 .. 0x7F */\n  };\n\n  return (t & 0x80) || aBareword[(int)t];\n}\n\n\n/*************************************************************************\n*/\ntypedef struct Fts5TermsetEntry Fts5TermsetEntry;\nstruct Fts5TermsetEntry {\n  char *pTerm;\n  int nTerm;\n  int iIdx;                       /* Index (main or aPrefix[] entry) */\n  Fts5TermsetEntry *pNext;\n};\n\nstruct Fts5Termset {\n  Fts5TermsetEntry *apHash[512];\n};\n\nstatic int sqlite3Fts5TermsetNew(Fts5Termset **pp){\n  int rc = SQLITE_OK;\n  *pp = sqlite3Fts5MallocZero(&rc, sizeof(Fts5Termset));\n  return rc;\n}\n\nstatic int sqlite3Fts5TermsetAdd(\n  Fts5Termset *p, \n  int iIdx,\n  const char *pTerm, int nTerm, \n  int *pbPresent\n){\n  int rc = SQLITE_OK;\n  *pbPresent = 0;\n  if( p ){\n    int i;\n    u32 hash = 13;\n    Fts5TermsetEntry *pEntry;\n\n    /* Calculate a hash value for this term. This is the same hash checksum\n    ** used by the fts5_hash.c module. This is not important for correct\n    ** operation of the module, but is necessary to ensure that some tests\n    ** designed to produce hash table collisions really do work.  */\n    for(i=nTerm-1; i>=0; i--){\n      hash = (hash << 3) ^ hash ^ pTerm[i];\n    }\n    hash = (hash << 3) ^ hash ^ iIdx;\n    hash = hash % ArraySize(p->apHash);\n\n    for(pEntry=p->apHash[hash]; pEntry; pEntry=pEntry->pNext){\n      if( pEntry->iIdx==iIdx \n          && pEntry->nTerm==nTerm \n          && memcmp(pEntry->pTerm, pTerm, nTerm)==0 \n      ){\n        *pbPresent = 1;\n        break;\n      }\n    }\n\n    if( pEntry==0 ){\n      pEntry = sqlite3Fts5MallocZero(&rc, sizeof(Fts5TermsetEntry) + nTerm);\n      if( pEntry ){\n        pEntry->pTerm = (char*)&pEntry[1];\n        pEntry->nTerm = nTerm;\n        pEntry->iIdx = iIdx;\n        memcpy(pEntry->pTerm, pTerm, nTerm);\n        pEntry->pNext = p->apHash[hash];\n        p->apHash[hash] = pEntry;\n      }\n    }\n  }\n\n  return rc;\n}\n\nstatic void sqlite3Fts5TermsetFree(Fts5Termset *p){\n  if( p ){\n    u32 i;\n    for(i=0; i<ArraySize(p->apHash); i++){\n      Fts5TermsetEntry *pEntry = p->apHash[i];\n      while( pEntry ){\n        Fts5TermsetEntry *pDel = pEntry;\n        pEntry = pEntry->pNext;\n        sqlite3_free(pDel);\n      }\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n#define FTS5_DEFAULT_PAGE_SIZE   4050\n#define FTS5_DEFAULT_AUTOMERGE      4\n#define FTS5_DEFAULT_USERMERGE      4\n#define FTS5_DEFAULT_CRISISMERGE   16\n#define FTS5_DEFAULT_HASHSIZE    (1024*1024)\n\n/* Maximum allowed page size */\n#define FTS5_MAX_PAGE_SIZE (128*1024)\n\nstatic int fts5_iswhitespace(char x){\n  return (x==' ');\n}\n\nstatic int fts5_isopenquote(char x){\n  return (x=='\"' || x=='\\'' || x=='[' || x=='`');\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a white-space character.\n*/\nstatic const char *fts5ConfigSkipWhitespace(const char *pIn){\n  const char *p = pIn;\n  if( p ){\n    while( fts5_iswhitespace(*p) ){ p++; }\n  }\n  return p;\n}\n\n/*\n** Argument pIn points to a character that is part of a nul-terminated \n** string. Return a pointer to the first character following *pIn in \n** the string that is not a \"bareword\" character.\n*/\nstatic const char *fts5ConfigSkipBareword(const char *pIn){\n  const char *p = pIn;\n  while ( sqlite3Fts5IsBareword(*p) ) p++;\n  if( p==pIn ) p = 0;\n  return p;\n}\n\nstatic int fts5_isdigit(char a){\n  return (a>='0' && a<='9');\n}\n\n\n\nstatic const char *fts5ConfigSkipLiteral(const char *pIn){\n  const char *p = pIn;\n  switch( *p ){\n    case 'n': case 'N':\n      if( sqlite3_strnicmp(\"null\", p, 4)==0 ){\n        p = &p[4];\n      }else{\n        p = 0;\n      }\n      break;\n\n    case 'x': case 'X':\n      p++;\n      if( *p=='\\'' ){\n        p++;\n        while( (*p>='a' && *p<='f') \n            || (*p>='A' && *p<='F') \n            || (*p>='0' && *p<='9') \n            ){\n          p++;\n        }\n        if( *p=='\\'' && 0==((p-pIn)%2) ){\n          p++;\n        }else{\n          p = 0;\n        }\n      }else{\n        p = 0;\n      }\n      break;\n\n    case '\\'':\n      p++;\n      while( p ){\n        if( *p=='\\'' ){\n          p++;\n          if( *p!='\\'' ) break;\n        }\n        p++;\n        if( *p==0 ) p = 0;\n      }\n      break;\n\n    default:\n      /* maybe a number */\n      if( *p=='+' || *p=='-' ) p++;\n      while( fts5_isdigit(*p) ) p++;\n\n      /* At this point, if the literal was an integer, the parse is \n      ** finished. Or, if it is a floating point value, it may continue\n      ** with either a decimal point or an 'E' character. */\n      if( *p=='.' && fts5_isdigit(p[1]) ){\n        p += 2;\n        while( fts5_isdigit(*p) ) p++;\n      }\n      if( p==pIn ) p = 0;\n\n      break;\n  }\n\n  return p;\n}\n\n/*\n** The first character of the string pointed to by argument z is guaranteed\n** to be an open-quote character (see function fts5_isopenquote()).\n**\n** This function searches for the corresponding close-quote character within\n** the string and, if found, dequotes the string in place and adds a new\n** nul-terminator byte.\n**\n** If the close-quote is found, the value returned is the byte offset of\n** the character immediately following it. Or, if the close-quote is not \n** found, -1 is returned. If -1 is returned, the buffer is left in an \n** undefined state.\n*/\nstatic int fts5Dequote(char *z){\n  char q;\n  int iIn = 1;\n  int iOut = 0;\n  q = z[0];\n\n  /* Set stack variable q to the close-quote character */\n  assert( q=='[' || q=='\\'' || q=='\"' || q=='`' );\n  if( q=='[' ) q = ']';  \n\n  while( ALWAYS(z[iIn]) ){\n    if( z[iIn]==q ){\n      if( z[iIn+1]!=q ){\n        /* Character iIn was the close quote. */\n        iIn++;\n        break;\n      }else{\n        /* Character iIn and iIn+1 form an escaped quote character. Skip\n        ** the input cursor past both and copy a single quote character \n        ** to the output buffer. */\n        iIn += 2;\n        z[iOut++] = q;\n      }\n    }else{\n      z[iOut++] = z[iIn++];\n    }\n  }\n\n  z[iOut] = '\\0';\n  return iIn;\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic void sqlite3Fts5Dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n\n  assert( 0==fts5_iswhitespace(z[0]) );\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    fts5Dequote(z);\n  }\n}\n\n\nstruct Fts5Enum {\n  const char *zName;\n  int eVal;\n};\ntypedef struct Fts5Enum Fts5Enum;\n\nstatic int fts5ConfigSetEnum(\n  const Fts5Enum *aEnum, \n  const char *zEnum, \n  int *peVal\n){\n  int nEnum = (int)strlen(zEnum);\n  int i;\n  int iVal = -1;\n\n  for(i=0; aEnum[i].zName; i++){\n    if( sqlite3_strnicmp(aEnum[i].zName, zEnum, nEnum)==0 ){\n      if( iVal>=0 ) return SQLITE_ERROR;\n      iVal = aEnum[i].eVal;\n    }\n  }\n\n  *peVal = iVal;\n  return iVal<0 ? SQLITE_ERROR : SQLITE_OK;\n}\n\n/*\n** Parse a \"special\" CREATE VIRTUAL TABLE directive and update\n** configuration object pConfig as appropriate.\n**\n** If successful, object pConfig is updated and SQLITE_OK returned. If\n** an error occurs, an SQLite error code is returned and an error message\n** may be left in *pzErr. It is the responsibility of the caller to\n** eventually free any such error message using sqlite3_free().\n*/\nstatic int fts5ConfigParseSpecial(\n  Fts5Global *pGlobal,\n  Fts5Config *pConfig,            /* Configuration object to update */\n  const char *zCmd,               /* Special command to parse */\n  const char *zArg,               /* Argument to parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  int nCmd = (int)strlen(zCmd);\n  if( sqlite3_strnicmp(\"prefix\", zCmd, nCmd)==0 ){\n    const int nByte = sizeof(int) * FTS5_MAX_PREFIX_INDEXES;\n    const char *p;\n    int bFirst = 1;\n    if( pConfig->aPrefix==0 ){\n      pConfig->aPrefix = sqlite3Fts5MallocZero(&rc, nByte);\n      if( rc ) return rc;\n    }\n\n    p = zArg;\n    while( 1 ){\n      int nPre = 0;\n\n      while( p[0]==' ' ) p++;\n      if( bFirst==0 && p[0]==',' ){\n        p++;\n        while( p[0]==' ' ) p++;\n      }else if( p[0]=='\\0' ){\n        break;\n      }\n      if( p[0]<'0' || p[0]>'9' ){\n        *pzErr = sqlite3_mprintf(\"malformed prefix=... directive\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      if( pConfig->nPrefix==FTS5_MAX_PREFIX_INDEXES ){\n        *pzErr = sqlite3_mprintf(\n            \"too many prefix indexes (max %d)\", FTS5_MAX_PREFIX_INDEXES\n        );\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      while( p[0]>='0' && p[0]<='9' && nPre<1000 ){\n        nPre = nPre*10 + (p[0] - '0');\n        p++;\n      }\n\n      if( nPre<=0 || nPre>=1000 ){\n        *pzErr = sqlite3_mprintf(\"prefix length out of range (max 999)\");\n        rc = SQLITE_ERROR;\n        break;\n      }\n\n      pConfig->aPrefix[pConfig->nPrefix] = nPre;\n      pConfig->nPrefix++;\n      bFirst = 0;\n    }\n    assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES );\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"tokenize\", zCmd, nCmd)==0 ){\n    const char *p = (const char*)zArg;\n    int nArg = (int)strlen(zArg) + 1;\n    char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);\n    char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);\n    char *pSpace = pDel;\n\n    if( azArg && pSpace ){\n      if( pConfig->pTok ){\n        *pzErr = sqlite3_mprintf(\"multiple tokenize=... directives\");\n        rc = SQLITE_ERROR;\n      }else{\n        for(nArg=0; p && *p; nArg++){\n          const char *p2 = fts5ConfigSkipWhitespace(p);\n          if( *p2=='\\'' ){\n            p = fts5ConfigSkipLiteral(p2);\n          }else{\n            p = fts5ConfigSkipBareword(p2);\n          }\n          if( p ){\n            memcpy(pSpace, p2, p-p2);\n            azArg[nArg] = pSpace;\n            sqlite3Fts5Dequote(pSpace);\n            pSpace += (p - p2) + 1;\n            p = fts5ConfigSkipWhitespace(p);\n          }\n        }\n        if( p==0 ){\n          *pzErr = sqlite3_mprintf(\"parse error in tokenize directive\");\n          rc = SQLITE_ERROR;\n        }else{\n          rc = sqlite3Fts5GetTokenizer(pGlobal, \n              (const char**)azArg, nArg, &pConfig->pTok, &pConfig->pTokApi,\n              pzErr\n          );\n        }\n      }\n    }\n\n    sqlite3_free(azArg);\n    sqlite3_free(pDel);\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content\", zCmd, nCmd)==0 ){\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n      *pzErr = sqlite3_mprintf(\"multiple content=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      if( zArg[0] ){\n        pConfig->eContent = FTS5_CONTENT_EXTERNAL;\n        pConfig->zContent = sqlite3Fts5Mprintf(&rc, \"%Q.%Q\", pConfig->zDb,zArg);\n      }else{\n        pConfig->eContent = FTS5_CONTENT_NONE;\n      }\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"content_rowid\", zCmd, nCmd)==0 ){\n    if( pConfig->zContentRowid ){\n      *pzErr = sqlite3_mprintf(\"multiple content_rowid=... directives\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->zContentRowid = sqlite3Fts5Strndup(&rc, zArg, -1);\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"columnsize\", zCmd, nCmd)==0 ){\n    if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1]!='\\0' ){\n      *pzErr = sqlite3_mprintf(\"malformed columnsize=... directive\");\n      rc = SQLITE_ERROR;\n    }else{\n      pConfig->bColumnsize = (zArg[0]=='1');\n    }\n    return rc;\n  }\n\n  if( sqlite3_strnicmp(\"detail\", zCmd, nCmd)==0 ){\n    const Fts5Enum aDetail[] = {\n      { \"none\", FTS5_DETAIL_NONE },\n      { \"full\", FTS5_DETAIL_FULL },\n      { \"columns\", FTS5_DETAIL_COLUMNS },\n      { 0, 0 }\n    };\n\n    if( (rc = fts5ConfigSetEnum(aDetail, zArg, &pConfig->eDetail)) ){\n      *pzErr = sqlite3_mprintf(\"malformed detail=... directive\");\n    }\n    return rc;\n  }\n\n  *pzErr = sqlite3_mprintf(\"unrecognized option: \\\"%.*s\\\"\", nCmd, zCmd);\n  return SQLITE_ERROR;\n}\n\n/*\n** Allocate an instance of the default tokenizer (\"simple\") at \n** Fts5Config.pTokenizer. Return SQLITE_OK if successful, or an SQLite error\n** code if an error occurs.\n*/\nstatic int fts5ConfigDefaultTokenizer(Fts5Global *pGlobal, Fts5Config *pConfig){\n  assert( pConfig->pTok==0 && pConfig->pTokApi==0 );\n  return sqlite3Fts5GetTokenizer(\n      pGlobal, 0, 0, &pConfig->pTok, &pConfig->pTokApi, 0\n  );\n}\n\n/*\n** Gobble up the first bareword or quoted word from the input buffer zIn.\n** Return a pointer to the character immediately following the last in\n** the gobbled word if successful, or a NULL pointer otherwise (failed\n** to find close-quote character).\n**\n** Before returning, set pzOut to point to a new buffer containing a\n** nul-terminated, dequoted copy of the gobbled word. If the word was\n** quoted, *pbQuoted is also set to 1 before returning.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is\n** a no-op (NULL is returned). Otherwise, if an OOM occurs within this\n** function, *pRc is set to SQLITE_NOMEM before returning. *pRc is *not*\n** set if a parse error (failed to find close quote) occurs.\n*/\nstatic const char *fts5ConfigGobbleWord(\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zIn,                /* Buffer to gobble string/bareword from */\n  char **pzOut,                   /* OUT: malloc'd buffer containing str/bw */\n  int *pbQuoted                   /* OUT: Set to true if dequoting required */\n){\n  const char *zRet = 0;\n\n  int nIn = (int)strlen(zIn);\n  char *zOut = sqlite3_malloc(nIn+1);\n\n  assert( *pRc==SQLITE_OK );\n  *pbQuoted = 0;\n  *pzOut = 0;\n\n  if( zOut==0 ){\n    *pRc = SQLITE_NOMEM;\n  }else{\n    memcpy(zOut, zIn, nIn+1);\n    if( fts5_isopenquote(zOut[0]) ){\n      int ii = fts5Dequote(zOut);\n      zRet = &zIn[ii];\n      *pbQuoted = 1;\n    }else{\n      zRet = fts5ConfigSkipBareword(zIn);\n      if( zRet ){\n        zOut[zRet-zIn] = '\\0';\n      }\n    }\n  }\n\n  if( zRet==0 ){\n    sqlite3_free(zOut);\n  }else{\n    *pzOut = zOut;\n  }\n\n  return zRet;\n}\n\nstatic int fts5ConfigParseColumn(\n  Fts5Config *p, \n  char *zCol, \n  char *zArg, \n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  if( 0==sqlite3_stricmp(zCol, FTS5_RANK_NAME) \n   || 0==sqlite3_stricmp(zCol, FTS5_ROWID_NAME) \n  ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 column name: %s\", zCol);\n    rc = SQLITE_ERROR;\n  }else if( zArg ){\n    if( 0==sqlite3_stricmp(zArg, \"unindexed\") ){\n      p->abUnindexed[p->nCol] = 1;\n    }else{\n      *pzErr = sqlite3_mprintf(\"unrecognized column option: %s\", zArg);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  p->azCol[p->nCol++] = zCol;\n  return rc;\n}\n\n/*\n** Populate the Fts5Config.zContentExprlist string.\n*/\nstatic int fts5ConfigMakeExprlist(Fts5Config *p){\n  int i;\n  int rc = SQLITE_OK;\n  Fts5Buffer buf = {0, 0, 0};\n\n  sqlite3Fts5BufferAppendPrintf(&rc, &buf, \"T.%Q\", p->zContentRowid);\n  if( p->eContent!=FTS5_CONTENT_NONE ){\n    for(i=0; i<p->nCol; i++){\n      if( p->eContent==FTS5_CONTENT_EXTERNAL ){\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.%Q\", p->azCol[i]);\n      }else{\n        sqlite3Fts5BufferAppendPrintf(&rc, &buf, \", T.c%d\", i);\n      }\n    }\n  }\n\n  assert( p->zContentExprlist==0 );\n  p->zContentExprlist = (char*)buf.p;\n  return rc;\n}\n\n/*\n** Arguments nArg/azArg contain the string arguments passed to the xCreate\n** or xConnect method of the virtual table. This function attempts to \n** allocate an instance of Fts5Config containing the results of parsing\n** those arguments.\n**\n** If successful, SQLITE_OK is returned and *ppOut is set to point to the\n** new Fts5Config object. If an error occurs, an SQLite error code is \n** returned, *ppOut is set to NULL and an error message may be left in\n** *pzErr. It is the responsibility of the caller to eventually free any \n** such error message using sqlite3_free().\n*/\nstatic int sqlite3Fts5ConfigParse(\n  Fts5Global *pGlobal,\n  sqlite3 *db,\n  int nArg,                       /* Number of arguments */\n  const char **azArg,             /* Array of nArg CREATE VIRTUAL TABLE args */\n  Fts5Config **ppOut,             /* OUT: Results of parse */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pRet;               /* New object to return */\n  int i;\n  int nByte;\n\n  *ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));\n  if( pRet==0 ) return SQLITE_NOMEM;\n  memset(pRet, 0, sizeof(Fts5Config));\n  pRet->db = db;\n  pRet->iCookie = -1;\n\n  nByte = nArg * (sizeof(char*) + sizeof(u8));\n  pRet->azCol = (char**)sqlite3Fts5MallocZero(&rc, nByte);\n  pRet->abUnindexed = (u8*)&pRet->azCol[nArg];\n  pRet->zDb = sqlite3Fts5Strndup(&rc, azArg[1], -1);\n  pRet->zName = sqlite3Fts5Strndup(&rc, azArg[2], -1);\n  pRet->bColumnsize = 1;\n  pRet->eDetail = FTS5_DETAIL_FULL;\n#ifdef SQLITE_DEBUG\n  pRet->bPrefixIndex = 1;\n#endif\n  if( rc==SQLITE_OK && sqlite3_stricmp(pRet->zName, FTS5_RANK_NAME)==0 ){\n    *pzErr = sqlite3_mprintf(\"reserved fts5 table name: %s\", pRet->zName);\n    rc = SQLITE_ERROR;\n  }\n\n  for(i=3; rc==SQLITE_OK && i<nArg; i++){\n    const char *zOrig = azArg[i];\n    const char *z;\n    char *zOne = 0;\n    char *zTwo = 0;\n    int bOption = 0;\n    int bMustBeCol = 0;\n\n    z = fts5ConfigGobbleWord(&rc, zOrig, &zOne, &bMustBeCol);\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && *z=='=' ){\n      bOption = 1;\n      z++;\n      if( bMustBeCol ) z = 0;\n    }\n    z = fts5ConfigSkipWhitespace(z);\n    if( z && z[0] ){\n      int bDummy;\n      z = fts5ConfigGobbleWord(&rc, z, &zTwo, &bDummy);\n      if( z && z[0] ) z = 0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( z==0 ){\n        *pzErr = sqlite3_mprintf(\"parse error in \\\"%s\\\"\", zOrig);\n        rc = SQLITE_ERROR;\n      }else{\n        if( bOption ){\n          rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:\"\", pzErr);\n        }else{\n          rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);\n          zOne = 0;\n        }\n      }\n    }\n\n    sqlite3_free(zOne);\n    sqlite3_free(zTwo);\n  }\n\n  /* If a tokenizer= option was successfully parsed, the tokenizer has\n  ** already been allocated. Otherwise, allocate an instance of the default\n  ** tokenizer (unicode61) now.  */\n  if( rc==SQLITE_OK && pRet->pTok==0 ){\n    rc = fts5ConfigDefaultTokenizer(pGlobal, pRet);\n  }\n\n  /* If no zContent option was specified, fill in the default values. */\n  if( rc==SQLITE_OK && pRet->zContent==0 ){\n    const char *zTail = 0;\n    assert( pRet->eContent==FTS5_CONTENT_NORMAL \n         || pRet->eContent==FTS5_CONTENT_NONE \n    );\n    if( pRet->eContent==FTS5_CONTENT_NORMAL ){\n      zTail = \"content\";\n    }else if( pRet->bColumnsize ){\n      zTail = \"docsize\";\n    }\n\n    if( zTail ){\n      pRet->zContent = sqlite3Fts5Mprintf(\n          &rc, \"%Q.'%q_%s'\", pRet->zDb, pRet->zName, zTail\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK && pRet->zContentRowid==0 ){\n    pRet->zContentRowid = sqlite3Fts5Strndup(&rc, \"rowid\", -1);\n  }\n\n  /* Formulate the zContentExprlist text */\n  if( rc==SQLITE_OK ){\n    rc = fts5ConfigMakeExprlist(pRet);\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3Fts5ConfigFree(pRet);\n    *ppOut = 0;\n  }\n  return rc;\n}\n\n/*\n** Free the configuration object passed as the only argument.\n*/\nstatic void sqlite3Fts5ConfigFree(Fts5Config *pConfig){\n  if( pConfig ){\n    int i;\n    if( pConfig->pTok ){\n      pConfig->pTokApi->xDelete(pConfig->pTok);\n    }\n    sqlite3_free(pConfig->zDb);\n    sqlite3_free(pConfig->zName);\n    for(i=0; i<pConfig->nCol; i++){\n      sqlite3_free(pConfig->azCol[i]);\n    }\n    sqlite3_free(pConfig->azCol);\n    sqlite3_free(pConfig->aPrefix);\n    sqlite3_free(pConfig->zRank);\n    sqlite3_free(pConfig->zRankArgs);\n    sqlite3_free(pConfig->zContent);\n    sqlite3_free(pConfig->zContentRowid);\n    sqlite3_free(pConfig->zContentExprlist);\n    sqlite3_free(pConfig);\n  }\n}\n\n/*\n** Call sqlite3_declare_vtab() based on the contents of the configuration\n** object passed as the only argument. Return SQLITE_OK if successful, or\n** an SQLite error code if an error occurs.\n*/\nstatic int sqlite3Fts5ConfigDeclareVtab(Fts5Config *pConfig){\n  int i;\n  int rc = SQLITE_OK;\n  char *zSql;\n\n  zSql = sqlite3Fts5Mprintf(&rc, \"CREATE TABLE x(\");\n  for(i=0; zSql && i<pConfig->nCol; i++){\n    const char *zSep = (i==0?\"\":\", \");\n    zSql = sqlite3Fts5Mprintf(&rc, \"%z%s%Q\", zSql, zSep, pConfig->azCol[i]);\n  }\n  zSql = sqlite3Fts5Mprintf(&rc, \"%z, %Q HIDDEN, %s HIDDEN)\", \n      zSql, pConfig->zName, FTS5_RANK_NAME\n  );\n\n  assert( zSql || rc==SQLITE_NOMEM );\n  if( zSql ){\n    rc = sqlite3_declare_vtab(pConfig->db, zSql);\n    sqlite3_free(zSql);\n  }\n  \n  return rc;\n}\n\n/*\n** Tokenize the text passed via the second and third arguments.\n**\n** The callback is invoked once for each token in the input text. The\n** arguments passed to it are, in order:\n**\n**     void *pCtx          // Copy of 4th argument to sqlite3Fts5Tokenize()\n**     const char *pToken  // Pointer to buffer containing token\n**     int nToken          // Size of token in bytes\n**     int iStart          // Byte offset of start of token within input text\n**     int iEnd            // Byte offset of end of token within input text\n**     int iPos            // Position of token in input (first token is 0)\n**\n** If the callback returns a non-zero value the tokenization is abandoned\n** and no further callbacks are issued. \n**\n** This function returns SQLITE_OK if successful or an SQLite error code\n** if an error occurs. If the tokenization was abandoned early because\n** the callback returned SQLITE_DONE, this is not an error and this function\n** still returns SQLITE_OK. Or, if the tokenization was abandoned early\n** because the callback returned another non-zero value, it is assumed\n** to be an SQLite error code and returned to the caller.\n*/\nstatic int sqlite3Fts5Tokenize(\n  Fts5Config *pConfig,            /* FTS5 Configuration object */\n  int flags,                      /* FTS5_TOKENIZE_* flags */\n  const char *pText, int nText,   /* Text to tokenize */\n  void *pCtx,                     /* Context passed to xToken() */\n  int (*xToken)(void*, int, const char*, int, int, int)    /* Callback */\n){\n  if( pText==0 ) return SQLITE_OK;\n  return pConfig->pTokApi->xTokenize(\n      pConfig->pTok, pCtx, flags, pText, nText, xToken\n  );\n}\n\n/*\n** Argument pIn points to the first character in what is expected to be\n** a comma-separated list of SQL literals followed by a ')' character.\n** If it actually is this, return a pointer to the ')'. Otherwise, return\n** NULL to indicate a parse error.\n*/\nstatic const char *fts5ConfigSkipArgs(const char *pIn){\n  const char *p = pIn;\n  \n  while( 1 ){\n    p = fts5ConfigSkipWhitespace(p);\n    p = fts5ConfigSkipLiteral(p);\n    p = fts5ConfigSkipWhitespace(p);\n    if( p==0 || *p==')' ) break;\n    if( *p!=',' ){\n      p = 0;\n      break;\n    }\n    p++;\n  }\n\n  return p;\n}\n\n/*\n** Parameter zIn contains a rank() function specification. The format of \n** this is:\n**\n**   + Bareword (function name)\n**   + Open parenthesis - \"(\"\n**   + Zero or more SQL literals in a comma separated list\n**   + Close parenthesis - \")\"\n*/\nstatic int sqlite3Fts5ConfigParseRank(\n  const char *zIn,                /* Input string */\n  char **pzRank,                  /* OUT: Rank function name */\n  char **pzRankArgs               /* OUT: Rank function arguments */\n){\n  const char *p = zIn;\n  const char *pRank;\n  char *zRank = 0;\n  char *zRankArgs = 0;\n  int rc = SQLITE_OK;\n\n  *pzRank = 0;\n  *pzRankArgs = 0;\n\n  if( p==0 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = fts5ConfigSkipWhitespace(p);\n    pRank = p;\n    p = fts5ConfigSkipBareword(p);\n\n    if( p ){\n      zRank = sqlite3Fts5MallocZero(&rc, 1 + p - pRank);\n      if( zRank ) memcpy(zRank, pRank, p-pRank);\n    }else{\n      rc = SQLITE_ERROR;\n    }\n\n    if( rc==SQLITE_OK ){\n      p = fts5ConfigSkipWhitespace(p);\n      if( *p!='(' ) rc = SQLITE_ERROR;\n      p++;\n    }\n    if( rc==SQLITE_OK ){\n      const char *pArgs; \n      p = fts5ConfigSkipWhitespace(p);\n      pArgs = p;\n      if( *p!=')' ){\n        p = fts5ConfigSkipArgs(p);\n        if( p==0 ){\n          rc = SQLITE_ERROR;\n        }else{\n          zRankArgs = sqlite3Fts5MallocZero(&rc, 1 + p - pArgs);\n          if( zRankArgs ) memcpy(zRankArgs, pArgs, p-pArgs);\n        }\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zRank);\n    assert( zRankArgs==0 );\n  }else{\n    *pzRank = zRank;\n    *pzRankArgs = zRankArgs;\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5ConfigSetValue(\n  Fts5Config *pConfig, \n  const char *zKey, \n  sqlite3_value *pVal,\n  int *pbBadkey\n){\n  int rc = SQLITE_OK;\n\n  if( 0==sqlite3_stricmp(zKey, \"pgsz\") ){\n    int pgsz = 0;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      pgsz = sqlite3_value_int(pVal);\n    }\n    if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->pgsz = pgsz;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"hashsize\") ){\n    int nHashSize = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nHashSize = sqlite3_value_int(pVal);\n    }\n    if( nHashSize<=0 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nHashSize = nHashSize;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"automerge\") ){\n    int nAutomerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nAutomerge = sqlite3_value_int(pVal);\n    }\n    if( nAutomerge<0 || nAutomerge>64 ){\n      *pbBadkey = 1;\n    }else{\n      if( nAutomerge==1 ) nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n      pConfig->nAutomerge = nAutomerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"usermerge\") ){\n    int nUsermerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nUsermerge = sqlite3_value_int(pVal);\n    }\n    if( nUsermerge<2 || nUsermerge>16 ){\n      *pbBadkey = 1;\n    }else{\n      pConfig->nUsermerge = nUsermerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"crisismerge\") ){\n    int nCrisisMerge = -1;\n    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){\n      nCrisisMerge = sqlite3_value_int(pVal);\n    }\n    if( nCrisisMerge<0 ){\n      *pbBadkey = 1;\n    }else{\n      if( nCrisisMerge<=1 ) nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n      pConfig->nCrisisMerge = nCrisisMerge;\n    }\n  }\n\n  else if( 0==sqlite3_stricmp(zKey, \"rank\") ){\n    const char *zIn = (const char*)sqlite3_value_text(pVal);\n    char *zRank;\n    char *zRankArgs;\n    rc = sqlite3Fts5ConfigParseRank(zIn, &zRank, &zRankArgs);\n    if( rc==SQLITE_OK ){\n      sqlite3_free(pConfig->zRank);\n      sqlite3_free(pConfig->zRankArgs);\n      pConfig->zRank = zRank;\n      pConfig->zRankArgs = zRankArgs;\n    }else if( rc==SQLITE_ERROR ){\n      rc = SQLITE_OK;\n      *pbBadkey = 1;\n    }\n  }else{\n    *pbBadkey = 1;\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the %_config table into memory.\n*/\nstatic int sqlite3Fts5ConfigLoad(Fts5Config *pConfig, int iCookie){\n  const char *zSelect = \"SELECT k, v FROM %Q.'%q_config'\";\n  char *zSql;\n  sqlite3_stmt *p = 0;\n  int rc = SQLITE_OK;\n  int iVersion = 0;\n\n  /* Set default values */\n  pConfig->pgsz = FTS5_DEFAULT_PAGE_SIZE;\n  pConfig->nAutomerge = FTS5_DEFAULT_AUTOMERGE;\n  pConfig->nUsermerge = FTS5_DEFAULT_USERMERGE;\n  pConfig->nCrisisMerge = FTS5_DEFAULT_CRISISMERGE;\n  pConfig->nHashSize = FTS5_DEFAULT_HASHSIZE;\n\n  zSql = sqlite3Fts5Mprintf(&rc, zSelect, pConfig->zDb, pConfig->zName);\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &p, 0);\n    sqlite3_free(zSql);\n  }\n\n  assert( rc==SQLITE_OK || p==0 );\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==sqlite3_step(p) ){\n      const char *zK = (const char*)sqlite3_column_text(p, 0);\n      sqlite3_value *pVal = sqlite3_column_value(p, 1);\n      if( 0==sqlite3_stricmp(zK, \"version\") ){\n        iVersion = sqlite3_value_int(pVal);\n      }else{\n        int bDummy = 0;\n        sqlite3Fts5ConfigSetValue(pConfig, zK, pVal, &bDummy);\n      }\n    }\n    rc = sqlite3_finalize(p);\n  }\n  \n  if( rc==SQLITE_OK && iVersion!=FTS5_CURRENT_VERSION ){\n    rc = SQLITE_ERROR;\n    if( pConfig->pzErrmsg ){\n      assert( 0==*pConfig->pzErrmsg );\n      *pConfig->pzErrmsg = sqlite3_mprintf(\n          \"invalid fts5 file format (found %d, expected %d) - run 'rebuild'\",\n          iVersion, FTS5_CURRENT_VERSION\n      );\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pConfig->iCookie = iCookie;\n  }\n  return rc;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n/* #include \"fts5parse.h\" */\n\n/*\n** All token types in the generated fts5parse.h file are greater than 0.\n*/\n#define FTS5_EOF 0\n\n#define FTS5_LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n\ntypedef struct Fts5ExprTerm Fts5ExprTerm;\n\n/*\n** Functions generated by lemon from fts5parse.y.\n*/\nstatic void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(u64));\nstatic void sqlite3Fts5ParserFree(void*, void (*freeProc)(void*));\nstatic void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);\n#ifndef NDEBUG\n/* #include <stdio.h> */\nstatic void sqlite3Fts5ParserTrace(FILE*, char*);\n#endif\n\n\nstruct Fts5Expr {\n  Fts5Index *pIndex;\n  Fts5Config *pConfig;\n  Fts5ExprNode *pRoot;\n  int bDesc;                      /* Iterate in descending rowid order */\n  int nPhrase;                    /* Number of phrases in expression */\n  Fts5ExprPhrase **apExprPhrase;  /* Pointers to phrase objects */\n};\n\n/*\n** eType:\n**   Expression node type. Always one of:\n**\n**       FTS5_AND                 (nChild, apChild valid)\n**       FTS5_OR                  (nChild, apChild valid)\n**       FTS5_NOT                 (nChild, apChild valid)\n**       FTS5_STRING              (pNear valid)\n**       FTS5_TERM                (pNear valid)\n*/\nstruct Fts5ExprNode {\n  int eType;                      /* Node type */\n  int bEof;                       /* True at EOF */\n  int bNomatch;                   /* True if entry is not a match */\n\n  /* Next method for this node. */\n  int (*xNext)(Fts5Expr*, Fts5ExprNode*, int, i64);\n\n  i64 iRowid;                     /* Current rowid */\n  Fts5ExprNearset *pNear;         /* For FTS5_STRING - cluster of phrases */\n\n  /* Child nodes. For a NOT node, this array always contains 2 entries. For \n  ** AND or OR nodes, it contains 2 or more entries.  */\n  int nChild;                     /* Number of child nodes */\n  Fts5ExprNode *apChild[1];       /* Array of child nodes */\n};\n\n#define Fts5NodeIsString(p) ((p)->eType==FTS5_TERM || (p)->eType==FTS5_STRING)\n\n/*\n** Invoke the xNext method of an Fts5ExprNode object. This macro should be\n** used as if it has the same signature as the xNext() methods themselves.\n*/\n#define fts5ExprNodeNext(a,b,c,d) (b)->xNext((a), (b), (c), (d))\n\n/*\n** An instance of the following structure represents a single search term\n** or term prefix.\n*/\nstruct Fts5ExprTerm {\n  int bPrefix;                    /* True for a prefix term */\n  char *zTerm;                    /* nul-terminated term */\n  Fts5IndexIter *pIter;           /* Iterator for this term */\n  Fts5ExprTerm *pSynonym;         /* Pointer to first in list of synonyms */\n};\n\n/*\n** A phrase. One or more terms that must appear in a contiguous sequence\n** within a document for it to match.\n*/\nstruct Fts5ExprPhrase {\n  Fts5ExprNode *pNode;            /* FTS5_STRING node this phrase is part of */\n  Fts5Buffer poslist;             /* Current position list */\n  int nTerm;                      /* Number of entries in aTerm[] */\n  Fts5ExprTerm aTerm[1];          /* Terms that make up this phrase */\n};\n\n/*\n** One or more phrases that must appear within a certain token distance of\n** each other within each matching document.\n*/\nstruct Fts5ExprNearset {\n  int nNear;                      /* NEAR parameter */\n  Fts5Colset *pColset;            /* Columns to search (NULL -> all columns) */\n  int nPhrase;                    /* Number of entries in aPhrase[] array */\n  Fts5ExprPhrase *apPhrase[1];    /* Array of phrase pointers */\n};\n\n\n/*\n** Parse context.\n*/\nstruct Fts5Parse {\n  Fts5Config *pConfig;\n  char *zErr;\n  int rc;\n  int nPhrase;                    /* Size of apPhrase array */\n  Fts5ExprPhrase **apPhrase;      /* Array of all phrases */\n  Fts5ExprNode *pExpr;            /* Result of a successful parse */\n};\n\nstatic void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){\n  va_list ap;\n  va_start(ap, zFmt);\n  if( pParse->rc==SQLITE_OK ){\n    pParse->zErr = sqlite3_vmprintf(zFmt, ap);\n    pParse->rc = SQLITE_ERROR;\n  }\n  va_end(ap);\n}\n\nstatic int fts5ExprIsspace(char t){\n  return t==' ' || t=='\\t' || t=='\\n' || t=='\\r';\n}\n\n/*\n** Read the first token from the nul-terminated string at *pz.\n*/\nstatic int fts5ExprGetToken(\n  Fts5Parse *pParse, \n  const char **pz,                /* IN/OUT: Pointer into buffer */\n  Fts5Token *pToken\n){\n  const char *z = *pz;\n  int tok;\n\n  /* Skip past any whitespace */\n  while( fts5ExprIsspace(*z) ) z++;\n\n  pToken->p = z;\n  pToken->n = 1;\n  switch( *z ){\n    case '(':  tok = FTS5_LP;    break;\n    case ')':  tok = FTS5_RP;    break;\n    case '{':  tok = FTS5_LCP;   break;\n    case '}':  tok = FTS5_RCP;   break;\n    case ':':  tok = FTS5_COLON; break;\n    case ',':  tok = FTS5_COMMA; break;\n    case '+':  tok = FTS5_PLUS;  break;\n    case '*':  tok = FTS5_STAR;  break;\n    case '-':  tok = FTS5_MINUS; break;\n    case '\\0': tok = FTS5_EOF;   break;\n\n    case '\"': {\n      const char *z2;\n      tok = FTS5_STRING;\n\n      for(z2=&z[1]; 1; z2++){\n        if( z2[0]=='\"' ){\n          z2++;\n          if( z2[0]!='\"' ) break;\n        }\n        if( z2[0]=='\\0' ){\n          sqlite3Fts5ParseError(pParse, \"unterminated string\");\n          return FTS5_EOF;\n        }\n      }\n      pToken->n = (z2 - z);\n      break;\n    }\n\n    default: {\n      const char *z2;\n      if( sqlite3Fts5IsBareword(z[0])==0 ){\n        sqlite3Fts5ParseError(pParse, \"fts5: syntax error near \\\"%.1s\\\"\", z);\n        return FTS5_EOF;\n      }\n      tok = FTS5_STRING;\n      for(z2=&z[1]; sqlite3Fts5IsBareword(*z2); z2++);\n      pToken->n = (z2 - z);\n      if( pToken->n==2 && memcmp(pToken->p, \"OR\", 2)==0 )  tok = FTS5_OR;\n      if( pToken->n==3 && memcmp(pToken->p, \"NOT\", 3)==0 ) tok = FTS5_NOT;\n      if( pToken->n==3 && memcmp(pToken->p, \"AND\", 3)==0 ) tok = FTS5_AND;\n      break;\n    }\n  }\n\n  *pz = &pToken->p[pToken->n];\n  return tok;\n}\n\nstatic void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); }\nstatic void fts5ParseFree(void *p){ sqlite3_free(p); }\n\nstatic int sqlite3Fts5ExprNew(\n  Fts5Config *pConfig,            /* FTS5 Configuration */\n  int iCol,\n  const char *zExpr,              /* Expression text */\n  Fts5Expr **ppNew, \n  char **pzErr\n){\n  Fts5Parse sParse;\n  Fts5Token token;\n  const char *z = zExpr;\n  int t;                          /* Next token type */\n  void *pEngine;\n  Fts5Expr *pNew;\n\n  *ppNew = 0;\n  *pzErr = 0;\n  memset(&sParse, 0, sizeof(sParse));\n  pEngine = sqlite3Fts5ParserAlloc(fts5ParseAlloc);\n  if( pEngine==0 ){ return SQLITE_NOMEM; }\n  sParse.pConfig = pConfig;\n\n  do {\n    t = fts5ExprGetToken(&sParse, &z, &token);\n    sqlite3Fts5Parser(pEngine, t, token, &sParse);\n  }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF );\n  sqlite3Fts5ParserFree(pEngine, fts5ParseFree);\n\n  /* If the LHS of the MATCH expression was a user column, apply the\n  ** implicit column-filter.  */\n  if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){\n    int n = sizeof(Fts5Colset);\n    Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n);\n    if( pColset ){\n      pColset->nCol = 1;\n      pColset->aiCol[0] = iCol;\n      sqlite3Fts5ParseSetColset(&sParse, sParse.pExpr, pColset);\n    }\n  }\n\n  assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 );\n  if( sParse.rc==SQLITE_OK ){\n    *ppNew = pNew = sqlite3_malloc(sizeof(Fts5Expr));\n    if( pNew==0 ){\n      sParse.rc = SQLITE_NOMEM;\n      sqlite3Fts5ParseNodeFree(sParse.pExpr);\n    }else{\n      if( !sParse.pExpr ){\n        const int nByte = sizeof(Fts5ExprNode);\n        pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&sParse.rc, nByte);\n        if( pNew->pRoot ){\n          pNew->pRoot->bEof = 1;\n        }\n      }else{\n        pNew->pRoot = sParse.pExpr;\n      }\n      pNew->pIndex = 0;\n      pNew->pConfig = pConfig;\n      pNew->apExprPhrase = sParse.apPhrase;\n      pNew->nPhrase = sParse.nPhrase;\n      sParse.apPhrase = 0;\n    }\n  }else{\n    sqlite3Fts5ParseNodeFree(sParse.pExpr);\n  }\n\n  sqlite3_free(sParse.apPhrase);\n  *pzErr = sParse.zErr;\n  return sParse.rc;\n}\n\n/*\n** Free the expression node object passed as the only argument.\n*/\nstatic void sqlite3Fts5ParseNodeFree(Fts5ExprNode *p){\n  if( p ){\n    int i;\n    for(i=0; i<p->nChild; i++){\n      sqlite3Fts5ParseNodeFree(p->apChild[i]);\n    }\n    sqlite3Fts5ParseNearsetFree(p->pNear);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Free the expression object passed as the only argument.\n*/\nstatic void sqlite3Fts5ExprFree(Fts5Expr *p){\n  if( p ){\n    sqlite3Fts5ParseNodeFree(p->pRoot);\n    sqlite3_free(p->apExprPhrase);\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Argument pTerm must be a synonym iterator. Return the current rowid\n** that it points to.\n*/\nstatic i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){\n  i64 iRet = 0;\n  int bRetValid = 0;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  assert( bDesc==0 || bDesc==1 );\n  for(p=pTerm; p; p=p->pSynonym){\n    if( 0==sqlite3Fts5IterEof(p->pIter) ){\n      i64 iRowid = p->pIter->iRowid;\n      if( bRetValid==0 || (bDesc!=(iRowid<iRet)) ){\n        iRet = iRowid;\n        bRetValid = 1;\n      }\n    }\n  }\n\n  if( pbEof && bRetValid==0 ) *pbEof = 1;\n  return iRet;\n}\n\n/*\n** Argument pTerm must be a synonym iterator.\n*/\nstatic int fts5ExprSynonymList(\n  Fts5ExprTerm *pTerm, \n  i64 iRowid,\n  Fts5Buffer *pBuf,               /* Use this buffer for space if required */\n  u8 **pa, int *pn\n){\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int nIter = 0;\n  int nAlloc = 4;\n  int rc = SQLITE_OK;\n  Fts5ExprTerm *p;\n\n  assert( pTerm->pSynonym );\n  for(p=pTerm; p; p=p->pSynonym){\n    Fts5IndexIter *pIter = p->pIter;\n    if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){\n      if( pIter->nData==0 ) continue;\n      if( nIter==nAlloc ){\n        int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;\n        Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte);\n        if( aNew==0 ){\n          rc = SQLITE_NOMEM;\n          goto synonym_poslist_out;\n        }\n        memcpy(aNew, aIter, sizeof(Fts5PoslistReader) * nIter);\n        nAlloc = nAlloc*2;\n        if( aIter!=aStatic ) sqlite3_free(aIter);\n        aIter = aNew;\n      }\n      sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &aIter[nIter]);\n      assert( aIter[nIter].bEof==0 );\n      nIter++;\n    }\n  }\n\n  if( nIter==1 ){\n    *pa = (u8*)aIter[0].a;\n    *pn = aIter[0].n;\n  }else{\n    Fts5PoslistWriter writer = {0};\n    i64 iPrev = -1;\n    fts5BufferZero(pBuf);\n    while( 1 ){\n      int i;\n      i64 iMin = FTS5_LARGEST_INT64;\n      for(i=0; i<nIter; i++){\n        if( aIter[i].bEof==0 ){\n          if( aIter[i].iPos==iPrev ){\n            if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) continue;\n          }\n          if( aIter[i].iPos<iMin ){\n            iMin = aIter[i].iPos;\n          }\n        }\n      }\n      if( iMin==FTS5_LARGEST_INT64 || rc!=SQLITE_OK ) break;\n      rc = sqlite3Fts5PoslistWriterAppend(pBuf, &writer, iMin);\n      iPrev = iMin;\n    }\n    if( rc==SQLITE_OK ){\n      *pa = pBuf->p;\n      *pn = pBuf->n;\n    }\n  }\n\n synonym_poslist_out:\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\n\n/*\n** All individual term iterators in pPhrase are guaranteed to be valid and\n** pointing to the same rowid when this function is called. This function \n** checks if the current rowid really is a match, and if so populates\n** the pPhrase->poslist buffer accordingly. Output parameter *pbMatch\n** is set to true if this is really a match, or false otherwise.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if the current rowid is \n** not a match.\n*/\nstatic int fts5ExprPhraseIsMatch(\n  Fts5ExprNode *pNode,            /* Node pPhrase belongs to */\n  Fts5ExprPhrase *pPhrase,        /* Phrase object to initialize */\n  int *pbMatch                    /* OUT: Set to true if really a match */\n){\n  Fts5PoslistWriter writer = {0};\n  Fts5PoslistReader aStatic[4];\n  Fts5PoslistReader *aIter = aStatic;\n  int i;\n  int rc = SQLITE_OK;\n  \n  fts5BufferZero(&pPhrase->poslist);\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pPhrase->nTerm>ArraySize(aStatic) ){\n    int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;\n    aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte);\n    if( !aIter ) return SQLITE_NOMEM;\n  }\n  memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);\n\n  /* Initialize a term iterator for each term in the phrase */\n  for(i=0; i<pPhrase->nTerm; i++){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n    int n = 0;\n    int bFlag = 0;\n    u8 *a = 0;\n    if( pTerm->pSynonym ){\n      Fts5Buffer buf = {0, 0, 0};\n      rc = fts5ExprSynonymList(pTerm, pNode->iRowid, &buf, &a, &n);\n      if( rc ){\n        sqlite3_free(a);\n        goto ismatch_out;\n      }\n      if( a==buf.p ) bFlag = 1;\n    }else{\n      a = (u8*)pTerm->pIter->pData;\n      n = pTerm->pIter->nData;\n    }\n    sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n    aIter[i].bFlag = (u8)bFlag;\n    if( aIter[i].bEof ) goto ismatch_out;\n  }\n\n  while( 1 ){\n    int bMatch;\n    i64 iPos = aIter[0].iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pPhrase->nTerm; i++){\n        Fts5PoslistReader *pPos = &aIter[i];\n        i64 iAdj = iPos + i;\n        if( pPos->iPos!=iAdj ){\n          bMatch = 0;\n          while( pPos->iPos<iAdj ){\n            if( sqlite3Fts5PoslistReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iAdj ) iPos = pPos->iPos-i;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Append position iPos to the output */\n    rc = sqlite3Fts5PoslistWriterAppend(&pPhrase->poslist, &writer, iPos);\n    if( rc!=SQLITE_OK ) goto ismatch_out;\n\n    for(i=0; i<pPhrase->nTerm; i++){\n      if( sqlite3Fts5PoslistReaderNext(&aIter[i]) ) goto ismatch_out;\n    }\n  }\n\n ismatch_out:\n  *pbMatch = (pPhrase->poslist.n>0);\n  for(i=0; i<pPhrase->nTerm; i++){\n    if( aIter[i].bFlag ) sqlite3_free((u8*)aIter[i].a);\n  }\n  if( aIter!=aStatic ) sqlite3_free(aIter);\n  return rc;\n}\n\ntypedef struct Fts5LookaheadReader Fts5LookaheadReader;\nstruct Fts5LookaheadReader {\n  const u8 *a;                    /* Buffer containing position list */\n  int n;                          /* Size of buffer a[] in bytes */\n  int i;                          /* Current offset in position list */\n  i64 iPos;                       /* Current position */\n  i64 iLookahead;                 /* Next position */\n};\n\n#define FTS5_LOOKAHEAD_EOF (((i64)1) << 62)\n\nstatic int fts5LookaheadReaderNext(Fts5LookaheadReader *p){\n  p->iPos = p->iLookahead;\n  if( sqlite3Fts5PoslistNext64(p->a, p->n, &p->i, &p->iLookahead) ){\n    p->iLookahead = FTS5_LOOKAHEAD_EOF;\n  }\n  return (p->iPos==FTS5_LOOKAHEAD_EOF);\n}\n\nstatic int fts5LookaheadReaderInit(\n  const u8 *a, int n,             /* Buffer to read position list from */\n  Fts5LookaheadReader *p          /* Iterator object to initialize */\n){\n  memset(p, 0, sizeof(Fts5LookaheadReader));\n  p->a = a;\n  p->n = n;\n  fts5LookaheadReaderNext(p);\n  return fts5LookaheadReaderNext(p);\n}\n\ntypedef struct Fts5NearTrimmer Fts5NearTrimmer;\nstruct Fts5NearTrimmer {\n  Fts5LookaheadReader reader;     /* Input iterator */\n  Fts5PoslistWriter writer;       /* Writer context */\n  Fts5Buffer *pOut;               /* Output poslist */\n};\n\n/*\n** The near-set object passed as the first argument contains more than\n** one phrase. All phrases currently point to the same row. The\n** Fts5ExprPhrase.poslist buffers are populated accordingly. This function\n** tests if the current row contains instances of each phrase sufficiently\n** close together to meet the NEAR constraint. Non-zero is returned if it\n** does, or zero otherwise.\n**\n** If in/out parameter (*pRc) is set to other than SQLITE_OK when this\n** function is called, it is a no-op. Or, if an error (e.g. SQLITE_NOMEM)\n** occurs within this function (*pRc) is set accordingly before returning.\n** The return value is undefined in both these cases.\n** \n** If no error occurs and non-zero (a match) is returned, the position-list\n** of each phrase object is edited to contain only those entries that\n** meet the constraint before returning.\n*/\nstatic int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){\n  Fts5NearTrimmer aStatic[4];\n  Fts5NearTrimmer *a = aStatic;\n  Fts5ExprPhrase **apPhrase = pNear->apPhrase;\n\n  int i;\n  int rc = *pRc;\n  int bMatch;\n\n  assert( pNear->nPhrase>1 );\n\n  /* If the aStatic[] array is not large enough, allocate a large array\n  ** using sqlite3_malloc(). This approach could be improved upon. */\n  if( pNear->nPhrase>ArraySize(aStatic) ){\n    int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;\n    a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);\n  }else{\n    memset(aStatic, 0, sizeof(aStatic));\n  }\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return 0;\n  }\n\n  /* Initialize a lookahead iterator for each phrase. After passing the\n  ** buffer and buffer size to the lookaside-reader init function, zero\n  ** the phrase poslist buffer. The new poslist for the phrase (containing\n  ** the same entries as the original with some entries removed on account \n  ** of the NEAR constraint) is written over the original even as it is\n  ** being read. This is safe as the entries for the new poslist are a\n  ** subset of the old, so it is not possible for data yet to be read to\n  ** be overwritten.  */\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5Buffer *pPoslist = &apPhrase[i]->poslist;\n    fts5LookaheadReaderInit(pPoslist->p, pPoslist->n, &a[i].reader);\n    pPoslist->n = 0;\n    a[i].pOut = pPoslist;\n  }\n\n  while( 1 ){\n    int iAdv;\n    i64 iMin;\n    i64 iMax;\n\n    /* This block advances the phrase iterators until they point to a set of\n    ** entries that together comprise a match.  */\n    iMax = a[0].reader.iPos;\n    do {\n      bMatch = 1;\n      for(i=0; i<pNear->nPhrase; i++){\n        Fts5LookaheadReader *pPos = &a[i].reader;\n        iMin = iMax - pNear->apPhrase[i]->nTerm - pNear->nNear;\n        if( pPos->iPos<iMin || pPos->iPos>iMax ){\n          bMatch = 0;\n          while( pPos->iPos<iMin ){\n            if( fts5LookaheadReaderNext(pPos) ) goto ismatch_out;\n          }\n          if( pPos->iPos>iMax ) iMax = pPos->iPos;\n        }\n      }\n    }while( bMatch==0 );\n\n    /* Add an entry to each output position list */\n    for(i=0; i<pNear->nPhrase; i++){\n      i64 iPos = a[i].reader.iPos;\n      Fts5PoslistWriter *pWriter = &a[i].writer;\n      if( a[i].pOut->n==0 || iPos!=pWriter->iPrev ){\n        sqlite3Fts5PoslistWriterAppend(a[i].pOut, pWriter, iPos);\n      }\n    }\n\n    iAdv = 0;\n    iMin = a[0].reader.iLookahead;\n    for(i=0; i<pNear->nPhrase; i++){\n      if( a[i].reader.iLookahead < iMin ){\n        iMin = a[i].reader.iLookahead;\n        iAdv = i;\n      }\n    }\n    if( fts5LookaheadReaderNext(&a[iAdv].reader) ) goto ismatch_out;\n  }\n\n  ismatch_out: {\n    int bRet = a[0].pOut->n>0;\n    *pRc = rc;\n    if( a!=aStatic ) sqlite3_free(a);\n    return bRet;\n  }\n}\n\n/*\n** Advance iterator pIter until it points to a value equal to or laster\n** than the initial value of *piLast. If this means the iterator points\n** to a value laster than *piLast, update *piLast to the new lastest value.\n**\n** If the iterator reaches EOF, set *pbEof to true before returning. If\n** an error occurs, set *pRc to an error code. If either *pbEof or *pRc\n** are set, return a non-zero value. Otherwise, return zero.\n*/\nstatic int fts5ExprAdvanceto(\n  Fts5IndexIter *pIter,           /* Iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc,                       /* OUT: Error code */\n  int *pbEof                      /* OUT: Set to true if EOF */\n){\n  i64 iLast = *piLast;\n  i64 iRowid;\n\n  iRowid = pIter->iRowid;\n  if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n    int rc = sqlite3Fts5IterNextFrom(pIter, iLast);\n    if( rc || sqlite3Fts5IterEof(pIter) ){\n      *pRc = rc;\n      *pbEof = 1;\n      return 1;\n    }\n    iRowid = pIter->iRowid;\n    assert( (bDesc==0 && iRowid>=iLast) || (bDesc==1 && iRowid<=iLast) );\n  }\n  *piLast = iRowid;\n\n  return 0;\n}\n\nstatic int fts5ExprSynonymAdvanceto(\n  Fts5ExprTerm *pTerm,            /* Term iterator to advance */\n  int bDesc,                      /* True if iterator is \"rowid DESC\" */\n  i64 *piLast,                    /* IN/OUT: Lastest rowid seen so far */\n  int *pRc                        /* OUT: Error code */\n){\n  int rc = SQLITE_OK;\n  i64 iLast = *piLast;\n  Fts5ExprTerm *p;\n  int bEof = 0;\n\n  for(p=pTerm; rc==SQLITE_OK && p; p=p->pSynonym){\n    if( sqlite3Fts5IterEof(p->pIter)==0 ){\n      i64 iRowid = p->pIter->iRowid;\n      if( (bDesc==0 && iLast>iRowid) || (bDesc && iLast<iRowid) ){\n        rc = sqlite3Fts5IterNextFrom(p->pIter, iLast);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    bEof = 1;\n  }else{\n    *piLast = fts5ExprSynonymRowid(pTerm, bDesc, &bEof);\n  }\n  return bEof;\n}\n\n\nstatic int fts5ExprNearTest(\n  int *pRc,\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_STRING) */\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int rc = *pRc;\n\n  if( pExpr->pConfig->eDetail!=FTS5_DETAIL_FULL ){\n    Fts5ExprTerm *pTerm;\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];\n    pPhrase->poslist.n = 0;\n    for(pTerm=&pPhrase->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      Fts5IndexIter *pIter = pTerm->pIter;\n      if( sqlite3Fts5IterEof(pIter)==0 ){\n        if( pIter->iRowid==pNode->iRowid && pIter->nData>0 ){\n          pPhrase->poslist.n = 1;\n        }\n      }\n    }\n    return pPhrase->poslist.n;\n  }else{\n    int i;\n\n    /* Check that each phrase in the nearset matches the current row.\n    ** Populate the pPhrase->poslist buffers at the same time. If any\n    ** phrase is not a match, break out of the loop early.  */\n    for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( pPhrase->nTerm>1 || pPhrase->aTerm[0].pSynonym || pNear->pColset ){\n        int bMatch = 0;\n        rc = fts5ExprPhraseIsMatch(pNode, pPhrase, &bMatch);\n        if( bMatch==0 ) break;\n      }else{\n        Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n        fts5BufferSet(&rc, &pPhrase->poslist, pIter->nData, pIter->pData);\n      }\n    }\n\n    *pRc = rc;\n    if( i==pNear->nPhrase && (i==1 || fts5ExprNearIsMatch(pRc, pNear)) ){\n      return 1;\n    }\n    return 0;\n  }\n}\n\n\n/*\n** Initialize all term iterators in the pNear object. If any term is found\n** to match no documents at all, return immediately without initializing any\n** further iterators.\n**\n** If an error occurs, return an SQLite error code. Otherwise, return\n** SQLITE_OK. It is not considered an error if some term matches zero\n** documents.\n*/\nstatic int fts5ExprNearInitAll(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  int i;\n\n  assert( pNode->bNomatch==0 );\n  for(i=0; i<pNear->nPhrase; i++){\n    Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n    if( pPhrase->nTerm==0 ){\n      pNode->bEof = 1;\n      return SQLITE_OK;\n    }else{\n      int j;\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        Fts5ExprTerm *p;\n        int bHit = 0;\n\n        for(p=pTerm; p; p=p->pSynonym){\n          int rc;\n          if( p->pIter ){\n            sqlite3Fts5IterClose(p->pIter);\n            p->pIter = 0;\n          }\n          rc = sqlite3Fts5IndexQuery(\n              pExpr->pIndex, p->zTerm, (int)strlen(p->zTerm),\n              (pTerm->bPrefix ? FTS5INDEX_QUERY_PREFIX : 0) |\n              (pExpr->bDesc ? FTS5INDEX_QUERY_DESC : 0),\n              pNear->pColset,\n              &p->pIter\n          );\n          assert( (rc==SQLITE_OK)==(p->pIter!=0) );\n          if( rc!=SQLITE_OK ) return rc;\n          if( 0==sqlite3Fts5IterEof(p->pIter) ){\n            bHit = 1;\n          }\n        }\n\n        if( bHit==0 ){\n          pNode->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n    }\n  }\n\n  pNode->bEof = 0;\n  return SQLITE_OK;\n}\n\n/*\n** If pExpr is an ASC iterator, this function returns a value with the\n** same sign as:\n**\n**   (iLhs - iRhs)\n**\n** Otherwise, if this is a DESC iterator, the opposite is returned:\n**\n**   (iRhs - iLhs)\n*/\nstatic int fts5RowidCmp(\n  Fts5Expr *pExpr,\n  i64 iLhs,\n  i64 iRhs\n){\n  assert( pExpr->bDesc==0 || pExpr->bDesc==1 );\n  if( pExpr->bDesc==0 ){\n    if( iLhs<iRhs ) return -1;\n    return (iLhs > iRhs);\n  }else{\n    if( iLhs>iRhs ) return -1;\n    return (iLhs < iRhs);\n  }\n}\n\nstatic void fts5ExprSetEof(Fts5ExprNode *pNode){\n  int i;\n  pNode->bEof = 1;\n  pNode->bNomatch = 0;\n  for(i=0; i<pNode->nChild; i++){\n    fts5ExprSetEof(pNode->apChild[i]);\n  }\n}\n\nstatic void fts5ExprNodeZeroPoslist(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pNode->pNear;\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      pPhrase->poslist.n = 0;\n    }\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprNodeZeroPoslist(pNode->apChild[i]);\n    }\n  }\n}\n\n\n\n/*\n** Compare the values currently indicated by the two nodes as follows:\n**\n**    res = (*p1) - (*p2)\n**\n** Nodes that point to values that come later in the iteration order are\n** considered to be larger. Nodes at EOF are the largest of all.\n**\n** This means that if the iteration order is ASC, then numerically larger\n** rowids are considered larger. Or if it is the default DESC, numerically\n** smaller rowids are larger.\n*/\nstatic int fts5NodeCompare(\n  Fts5Expr *pExpr,\n  Fts5ExprNode *p1, \n  Fts5ExprNode *p2\n){\n  if( p2->bEof ) return -1;\n  if( p1->bEof ) return +1;\n  return fts5RowidCmp(pExpr, p1->iRowid, p2->iRowid);\n}\n\n/*\n** All individual term iterators in pNear are guaranteed to be valid when\n** this function is called. This function checks if all term iterators\n** point to the same rowid, and if not, advances them until they do.\n** If an EOF is reached before this happens, *pbEof is set to true before\n** returning.\n**\n** SQLITE_OK is returned if an error occurs, or an SQLite error code \n** otherwise. It is not considered an error code if an iterator reaches\n** EOF.\n*/\nstatic int fts5ExprNodeTest_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode\n){\n  Fts5ExprNearset *pNear = pNode->pNear;\n  Fts5ExprPhrase *pLeft = pNear->apPhrase[0];\n  int rc = SQLITE_OK;\n  i64 iLast;                      /* Lastest rowid any iterator points to */\n  int i, j;                       /* Phrase and token index, respectively */\n  int bMatch;                     /* True if all terms are at the same rowid */\n  const int bDesc = pExpr->bDesc;\n\n  /* Check that this node should not be FTS5_TERM */\n  assert( pNear->nPhrase>1 \n       || pNear->apPhrase[0]->nTerm>1 \n       || pNear->apPhrase[0]->aTerm[0].pSynonym\n  );\n\n  /* Initialize iLast, the \"lastest\" rowid any iterator points to. If the\n  ** iterator skips through rowids in the default ascending order, this means\n  ** the maximum rowid. Or, if the iterator is \"ORDER BY rowid DESC\", then it\n  ** means the minimum rowid.  */\n  if( pLeft->aTerm[0].pSynonym ){\n    iLast = fts5ExprSynonymRowid(&pLeft->aTerm[0], bDesc, 0);\n  }else{\n    iLast = pLeft->aTerm[0].pIter->iRowid;\n  }\n\n  do {\n    bMatch = 1;\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      for(j=0; j<pPhrase->nTerm; j++){\n        Fts5ExprTerm *pTerm = &pPhrase->aTerm[j];\n        if( pTerm->pSynonym ){\n          i64 iRowid = fts5ExprSynonymRowid(pTerm, bDesc, 0);\n          if( iRowid==iLast ) continue;\n          bMatch = 0;\n          if( fts5ExprSynonymAdvanceto(pTerm, bDesc, &iLast, &rc) ){\n            pNode->bNomatch = 0;\n            pNode->bEof = 1;\n            return rc;\n          }\n        }else{\n          Fts5IndexIter *pIter = pPhrase->aTerm[j].pIter;\n          if( pIter->iRowid==iLast || pIter->bEof ) continue;\n          bMatch = 0;\n          if( fts5ExprAdvanceto(pIter, bDesc, &iLast, &rc, &pNode->bEof) ){\n            return rc;\n          }\n        }\n      }\n    }\n  }while( bMatch==0 );\n\n  pNode->iRowid = iLast;\n  pNode->bNomatch = ((0==fts5ExprNearTest(&rc, pExpr, pNode)) && rc==SQLITE_OK);\n  assert( pNode->bEof==0 || pNode->bNomatch==0 );\n\n  return rc;\n}\n\n/*\n** Advance the first term iterator in the first phrase of pNear. Set output\n** variable *pbEof to true if it reaches EOF or if an error occurs.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5ExprNodeNext_STRING(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode,            /* FTS5_STRING or FTS5_TERM node */\n  int bFromValid,\n  i64 iFrom \n){\n  Fts5ExprTerm *pTerm = &pNode->pNear->apPhrase[0]->aTerm[0];\n  int rc = SQLITE_OK;\n\n  pNode->bNomatch = 0;\n  if( pTerm->pSynonym ){\n    int bEof = 1;\n    Fts5ExprTerm *p;\n\n    /* Find the firstest rowid any synonym points to. */\n    i64 iRowid = fts5ExprSynonymRowid(pTerm, pExpr->bDesc, 0);\n\n    /* Advance each iterator that currently points to iRowid. Or, if iFrom\n    ** is valid - each iterator that points to a rowid before iFrom.  */\n    for(p=pTerm; p; p=p->pSynonym){\n      if( sqlite3Fts5IterEof(p->pIter)==0 ){\n        i64 ii = p->pIter->iRowid;\n        if( ii==iRowid \n         || (bFromValid && ii!=iFrom && (ii>iFrom)==pExpr->bDesc) \n        ){\n          if( bFromValid ){\n            rc = sqlite3Fts5IterNextFrom(p->pIter, iFrom);\n          }else{\n            rc = sqlite3Fts5IterNext(p->pIter);\n          }\n          if( rc!=SQLITE_OK ) break;\n          if( sqlite3Fts5IterEof(p->pIter)==0 ){\n            bEof = 0;\n          }\n        }else{\n          bEof = 0;\n        }\n      }\n    }\n\n    /* Set the EOF flag if either all synonym iterators are at EOF or an\n    ** error has occurred.  */\n    pNode->bEof = (rc || bEof);\n  }else{\n    Fts5IndexIter *pIter = pTerm->pIter;\n\n    assert( Fts5NodeIsString(pNode) );\n    if( bFromValid ){\n      rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n    }else{\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n\n    pNode->bEof = (rc || sqlite3Fts5IterEof(pIter));\n  }\n\n  if( pNode->bEof==0 ){\n    assert( rc==SQLITE_OK );\n    rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ExprNodeTest_TERM(\n  Fts5Expr *pExpr,                /* Expression that pNear is a part of */\n  Fts5ExprNode *pNode             /* The \"NEAR\" node (FTS5_TERM) */\n){\n  /* As this \"NEAR\" object is actually a single phrase that consists \n  ** of a single term only, grab pointers into the poslist managed by the\n  ** fts5_index.c iterator object. This is much faster than synthesizing \n  ** a new poslist the way we have to for more complicated phrase or NEAR\n  ** expressions.  */\n  Fts5ExprPhrase *pPhrase = pNode->pNear->apPhrase[0];\n  Fts5IndexIter *pIter = pPhrase->aTerm[0].pIter;\n\n  assert( pNode->eType==FTS5_TERM );\n  assert( pNode->pNear->nPhrase==1 && pPhrase->nTerm==1 );\n  assert( pPhrase->aTerm[0].pSynonym==0 );\n\n  pPhrase->poslist.n = pIter->nData;\n  if( pExpr->pConfig->eDetail==FTS5_DETAIL_FULL ){\n    pPhrase->poslist.p = (u8*)pIter->pData;\n  }\n  pNode->iRowid = pIter->iRowid;\n  pNode->bNomatch = (pPhrase->poslist.n==0);\n  return SQLITE_OK;\n}\n\n/*\n** xNext() method for a node of type FTS5_TERM.\n*/\nstatic int fts5ExprNodeNext_TERM(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc;\n  Fts5IndexIter *pIter = pNode->pNear->apPhrase[0]->aTerm[0].pIter;\n\n  assert( pNode->bEof==0 );\n  if( bFromValid ){\n    rc = sqlite3Fts5IterNextFrom(pIter, iFrom);\n  }else{\n    rc = sqlite3Fts5IterNext(pIter);\n  }\n  if( rc==SQLITE_OK && sqlite3Fts5IterEof(pIter)==0 ){\n    rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n  }else{\n    pNode->bEof = 1;\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic void fts5ExprNodeTest_OR(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  Fts5ExprNode *pNext = pNode->apChild[0];\n  int i;\n\n  for(i=1; i<pNode->nChild; i++){\n    Fts5ExprNode *pChild = pNode->apChild[i];\n    int cmp = fts5NodeCompare(pExpr, pNext, pChild);\n    if( cmp>0 || (cmp==0 && pChild->bNomatch==0) ){\n      pNext = pChild;\n    }\n  }\n  pNode->iRowid = pNext->iRowid;\n  pNode->bEof = pNext->bEof;\n  pNode->bNomatch = pNext->bNomatch;\n}\n\nstatic int fts5ExprNodeNext_OR(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int i;\n  i64 iLast = pNode->iRowid;\n\n  for(i=0; i<pNode->nChild; i++){\n    Fts5ExprNode *p1 = pNode->apChild[i];\n    assert( p1->bEof || fts5RowidCmp(pExpr, p1->iRowid, iLast)>=0 );\n    if( p1->bEof==0 ){\n      if( (p1->iRowid==iLast) \n       || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)\n      ){\n        int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);\n        if( rc!=SQLITE_OK ){\n          pNode->bNomatch = 0;\n          return rc;\n        }\n      }\n    }\n  }\n\n  fts5ExprNodeTest_OR(pExpr, pNode);\n  return SQLITE_OK;\n}\n\n/*\n** Argument pNode is an FTS5_AND node.\n*/\nstatic int fts5ExprNodeTest_AND(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pAnd              /* FTS5_AND node to advance */\n){\n  int iChild;\n  i64 iLast = pAnd->iRowid;\n  int rc = SQLITE_OK;\n  int bMatch;\n\n  assert( pAnd->bEof==0 );\n  do {\n    pAnd->bNomatch = 0;\n    bMatch = 1;\n    for(iChild=0; iChild<pAnd->nChild; iChild++){\n      Fts5ExprNode *pChild = pAnd->apChild[iChild];\n      int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);\n      if( cmp>0 ){\n        /* Advance pChild until it points to iLast or laster */\n        rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);\n        if( rc!=SQLITE_OK ){\n          pAnd->bNomatch = 0;\n          return rc;\n        }\n      }\n\n      /* If the child node is now at EOF, so is the parent AND node. Otherwise,\n      ** the child node is guaranteed to have advanced at least as far as\n      ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the\n      ** new lastest rowid seen so far.  */\n      assert( pChild->bEof || fts5RowidCmp(pExpr, iLast, pChild->iRowid)<=0 );\n      if( pChild->bEof ){\n        fts5ExprSetEof(pAnd);\n        bMatch = 1;\n        break;\n      }else if( iLast!=pChild->iRowid ){\n        bMatch = 0;\n        iLast = pChild->iRowid;\n      }\n\n      if( pChild->bNomatch ){\n        pAnd->bNomatch = 1;\n      }\n    }\n  }while( bMatch==0 );\n\n  if( pAnd->bNomatch && pAnd!=pExpr->pRoot ){\n    fts5ExprNodeZeroPoslist(pAnd);\n  }\n  pAnd->iRowid = iLast;\n  return SQLITE_OK;\n}\n\nstatic int fts5ExprNodeNext_AND(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_AND(pExpr, pNode);\n  }else{\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeTest_NOT(\n  Fts5Expr *pExpr,                /* Expression pPhrase belongs to */\n  Fts5ExprNode *pNode             /* FTS5_NOT node to advance */\n){\n  int rc = SQLITE_OK;\n  Fts5ExprNode *p1 = pNode->apChild[0];\n  Fts5ExprNode *p2 = pNode->apChild[1];\n  assert( pNode->nChild==2 );\n\n  while( rc==SQLITE_OK && p1->bEof==0 ){\n    int cmp = fts5NodeCompare(pExpr, p1, p2);\n    if( cmp>0 ){\n      rc = fts5ExprNodeNext(pExpr, p2, 1, p1->iRowid);\n      cmp = fts5NodeCompare(pExpr, p1, p2);\n    }\n    assert( rc!=SQLITE_OK || cmp<=0 );\n    if( cmp || p2->bNomatch ) break;\n    rc = fts5ExprNodeNext(pExpr, p1, 0, 0);\n  }\n  pNode->bEof = p1->bEof;\n  pNode->bNomatch = p1->bNomatch;\n  pNode->iRowid = p1->iRowid;\n  if( p1->bEof ){\n    fts5ExprNodeZeroPoslist(p2);\n  }\n  return rc;\n}\n\nstatic int fts5ExprNodeNext_NOT(\n  Fts5Expr *pExpr, \n  Fts5ExprNode *pNode,\n  int bFromValid,\n  i64 iFrom\n){\n  int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n  }\n  if( rc!=SQLITE_OK ){\n    pNode->bNomatch = 0;\n  }\n  return rc;\n}\n\n/*\n** If pNode currently points to a match, this function returns SQLITE_OK\n** without modifying it. Otherwise, pNode is advanced until it does point\n** to a match or EOF is reached.\n*/\nstatic int fts5ExprNodeTest(\n  Fts5Expr *pExpr,                /* Expression of which pNode is a part */\n  Fts5ExprNode *pNode             /* Expression node to test */\n){\n  int rc = SQLITE_OK;\n  if( pNode->bEof==0 ){\n    switch( pNode->eType ){\n\n      case FTS5_STRING: {\n        rc = fts5ExprNodeTest_STRING(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_TERM: {\n        rc = fts5ExprNodeTest_TERM(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_AND: {\n        rc = fts5ExprNodeTest_AND(pExpr, pNode);\n        break;\n      }\n\n      case FTS5_OR: {\n        fts5ExprNodeTest_OR(pExpr, pNode);\n        break;\n      }\n\n      default: assert( pNode->eType==FTS5_NOT ); {\n        rc = fts5ExprNodeTest_NOT(pExpr, pNode);\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n \n/*\n** Set node pNode, which is part of expression pExpr, to point to the first\n** match. If there are no matches, set the Node.bEof flag to indicate EOF.\n**\n** Return an SQLite error code if an error occurs, or SQLITE_OK otherwise.\n** It is not an error if there are no matches.\n*/\nstatic int fts5ExprNodeFirst(Fts5Expr *pExpr, Fts5ExprNode *pNode){\n  int rc = SQLITE_OK;\n  pNode->bEof = 0;\n  pNode->bNomatch = 0;\n\n  if( Fts5NodeIsString(pNode) ){\n    /* Initialize all term iterators in the NEAR object. */\n    rc = fts5ExprNearInitAll(pExpr, pNode);\n  }else if( pNode->xNext==0 ){\n    pNode->bEof = 1;\n  }else{\n    int i;\n    int nEof = 0;\n    for(i=0; i<pNode->nChild && rc==SQLITE_OK; i++){\n      Fts5ExprNode *pChild = pNode->apChild[i];\n      rc = fts5ExprNodeFirst(pExpr, pNode->apChild[i]);\n      assert( pChild->bEof==0 || pChild->bEof==1 );\n      nEof += pChild->bEof;\n    }\n    pNode->iRowid = pNode->apChild[0]->iRowid;\n\n    switch( pNode->eType ){\n      case FTS5_AND:\n        if( nEof>0 ) fts5ExprSetEof(pNode);\n        break;\n\n      case FTS5_OR:\n        if( pNode->nChild==nEof ) fts5ExprSetEof(pNode);\n        break;\n\n      default:\n        assert( pNode->eType==FTS5_NOT );\n        pNode->bEof = pNode->apChild[0]->bEof;\n        break;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5ExprNodeTest(pExpr, pNode);\n  }\n  return rc;\n}\n\n\n/*\n** Begin iterating through the set of documents in index pIdx matched by\n** the MATCH expression passed as the first argument. If the \"bDesc\" \n** parameter is passed a non-zero value, iteration is in descending rowid \n** order. Or, if it is zero, in ascending order.\n**\n** If iterating in ascending rowid order (bDesc==0), the first document\n** visited is that with the smallest rowid that is larger than or equal\n** to parameter iFirst. Or, if iterating in ascending order (bDesc==1),\n** then the first document visited must have a rowid smaller than or\n** equal to iFirst.\n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nstatic int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bDesc){\n  Fts5ExprNode *pRoot = p->pRoot;\n  int rc;                         /* Return code */\n\n  p->pIndex = pIdx;\n  p->bDesc = bDesc;\n  rc = fts5ExprNodeFirst(p, pRoot);\n\n  /* If not at EOF but the current rowid occurs earlier than iFirst in\n  ** the iteration order, move to document iFirst or later. */\n  if( rc==SQLITE_OK \n   && 0==pRoot->bEof \n   && fts5RowidCmp(p, pRoot->iRowid, iFirst)<0 \n  ){\n    rc = fts5ExprNodeNext(p, pRoot, 1, iFirst);\n  }\n\n  /* If the iterator is not at a real match, skip forward until it is. */\n  while( pRoot->bNomatch ){\n    assert( pRoot->bEof==0 && rc==SQLITE_OK );\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n  }\n  return rc;\n}\n\n/*\n** Move to the next document \n**\n** Return SQLITE_OK if successful, or an SQLite error code otherwise. It\n** is not considered an error if the query does not match any documents.\n*/\nstatic int sqlite3Fts5ExprNext(Fts5Expr *p, i64 iLast){\n  int rc;\n  Fts5ExprNode *pRoot = p->pRoot;\n  assert( pRoot->bEof==0 && pRoot->bNomatch==0 );\n  do {\n    rc = fts5ExprNodeNext(p, pRoot, 0, 0);\n    assert( pRoot->bNomatch==0 || (rc==SQLITE_OK && pRoot->bEof==0) );\n  }while( pRoot->bNomatch );\n  if( fts5RowidCmp(p, pRoot->iRowid, iLast)>0 ){\n    pRoot->bEof = 1;\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5ExprEof(Fts5Expr *p){\n  return p->pRoot->bEof;\n}\n\nstatic i64 sqlite3Fts5ExprRowid(Fts5Expr *p){\n  return p->pRoot->iRowid;\n}\n\nstatic int fts5ParseStringFromToken(Fts5Token *pToken, char **pz){\n  int rc = SQLITE_OK;\n  *pz = sqlite3Fts5Strndup(&rc, pToken->p, pToken->n);\n  return rc;\n}\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nstatic void fts5ExprPhraseFree(Fts5ExprPhrase *pPhrase){\n  if( pPhrase ){\n    int i;\n    for(i=0; i<pPhrase->nTerm; i++){\n      Fts5ExprTerm *pSyn;\n      Fts5ExprTerm *pNext;\n      Fts5ExprTerm *pTerm = &pPhrase->aTerm[i];\n      sqlite3_free(pTerm->zTerm);\n      sqlite3Fts5IterClose(pTerm->pIter);\n      for(pSyn=pTerm->pSynonym; pSyn; pSyn=pNext){\n        pNext = pSyn->pSynonym;\n        sqlite3Fts5IterClose(pSyn->pIter);\n        fts5BufferFree((Fts5Buffer*)&pSyn[1]);\n        sqlite3_free(pSyn);\n      }\n    }\n    if( pPhrase->poslist.nSpace>0 ) fts5BufferFree(&pPhrase->poslist);\n    sqlite3_free(pPhrase);\n  }\n}\n\n/*\n** If argument pNear is NULL, then a new Fts5ExprNearset object is allocated\n** and populated with pPhrase. Or, if pNear is not NULL, phrase pPhrase is\n** appended to it and the results returned.\n**\n** If an OOM error occurs, both the pNear and pPhrase objects are freed and\n** NULL returned.\n*/\nstatic Fts5ExprNearset *sqlite3Fts5ParseNearset(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNearset *pNear,         /* Existing nearset, or NULL */\n  Fts5ExprPhrase *pPhrase         /* Recently parsed phrase */\n){\n  const int SZALLOC = 8;\n  Fts5ExprNearset *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    if( pPhrase==0 ){\n      return pNear;\n    }\n    if( pNear==0 ){\n      int nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);\n      pRet = sqlite3_malloc(nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }else{\n        memset(pRet, 0, nByte);\n      }\n    }else if( (pNear->nPhrase % SZALLOC)==0 ){\n      int nNew = pNear->nPhrase + SZALLOC;\n      int nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);\n\n      pRet = (Fts5ExprNearset*)sqlite3_realloc(pNear, nByte);\n      if( pRet==0 ){\n        pParse->rc = SQLITE_NOMEM;\n      }\n    }else{\n      pRet = pNear;\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNearsetFree(pNear);\n    sqlite3Fts5ParsePhraseFree(pPhrase);\n  }else{\n    if( pRet->nPhrase>0 ){\n      Fts5ExprPhrase *pLast = pRet->apPhrase[pRet->nPhrase-1];\n      assert( pLast==pParse->apPhrase[pParse->nPhrase-2] );\n      if( pPhrase->nTerm==0 ){\n        fts5ExprPhraseFree(pPhrase);\n        pRet->nPhrase--;\n        pParse->nPhrase--;\n        pPhrase = pLast;\n      }else if( pLast->nTerm==0 ){\n        fts5ExprPhraseFree(pLast);\n        pParse->apPhrase[pParse->nPhrase-2] = pPhrase;\n        pParse->nPhrase--;\n        pRet->nPhrase--;\n      }\n    }\n    pRet->apPhrase[pRet->nPhrase++] = pPhrase;\n  }\n  return pRet;\n}\n\ntypedef struct TokenCtx TokenCtx;\nstruct TokenCtx {\n  Fts5ExprPhrase *pPhrase;\n  int rc;\n};\n\n/*\n** Callback for tokenizing terms used by ParseTerm().\n*/\nstatic int fts5ParseTokenize(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,                     /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int rc = SQLITE_OK;\n  const int SZALLOC = 8;\n  TokenCtx *pCtx = (TokenCtx*)pContext;\n  Fts5ExprPhrase *pPhrase = pCtx->pPhrase;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  /* If an error has already occurred, this is a no-op */\n  if( pCtx->rc!=SQLITE_OK ) return pCtx->rc;\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){\n    Fts5ExprTerm *pSyn;\n    int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;\n    pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte);\n    if( pSyn==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pSyn, 0, nByte);\n      pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);\n      memcpy(pSyn->zTerm, pToken, nToken);\n      pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;\n      pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;\n    }\n  }else{\n    Fts5ExprTerm *pTerm;\n    if( pPhrase==0 || (pPhrase->nTerm % SZALLOC)==0 ){\n      Fts5ExprPhrase *pNew;\n      int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);\n\n      pNew = (Fts5ExprPhrase*)sqlite3_realloc(pPhrase, \n          sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew\n      );\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        if( pPhrase==0 ) memset(pNew, 0, sizeof(Fts5ExprPhrase));\n        pCtx->pPhrase = pPhrase = pNew;\n        pNew->nTerm = nNew - SZALLOC;\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      pTerm = &pPhrase->aTerm[pPhrase->nTerm++];\n      memset(pTerm, 0, sizeof(Fts5ExprTerm));\n      pTerm->zTerm = sqlite3Fts5Strndup(&rc, pToken, nToken);\n    }\n  }\n\n  pCtx->rc = rc;\n  return rc;\n}\n\n\n/*\n** Free the phrase object passed as the only argument.\n*/\nstatic void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase *pPhrase){\n  fts5ExprPhraseFree(pPhrase);\n}\n\n/*\n** Free the phrase object passed as the second argument.\n*/\nstatic void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset *pNear){\n  if( pNear ){\n    int i;\n    for(i=0; i<pNear->nPhrase; i++){\n      fts5ExprPhraseFree(pNear->apPhrase[i]);\n    }\n    sqlite3_free(pNear->pColset);\n    sqlite3_free(pNear);\n  }\n}\n\nstatic void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p){\n  assert( pParse->pExpr==0 );\n  pParse->pExpr = p;\n}\n\n/*\n** This function is called by the parser to process a string token. The\n** string may or may not be quoted. In any case it is tokenized and a\n** phrase object consisting of all tokens returned.\n*/\nstatic Fts5ExprPhrase *sqlite3Fts5ParseTerm(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprPhrase *pAppend,        /* Phrase to append to */\n  Fts5Token *pToken,              /* String to tokenize */\n  int bPrefix                     /* True if there is a trailing \"*\" */\n){\n  Fts5Config *pConfig = pParse->pConfig;\n  TokenCtx sCtx;                  /* Context object passed to callback */\n  int rc;                         /* Tokenize return code */\n  char *z = 0;\n\n  memset(&sCtx, 0, sizeof(TokenCtx));\n  sCtx.pPhrase = pAppend;\n\n  rc = fts5ParseStringFromToken(pToken, &z);\n  if( rc==SQLITE_OK ){\n    int flags = FTS5_TOKENIZE_QUERY | (bPrefix ? FTS5_TOKENIZE_PREFIX : 0);\n    int n;\n    sqlite3Fts5Dequote(z);\n    n = (int)strlen(z);\n    rc = sqlite3Fts5Tokenize(pConfig, flags, z, n, &sCtx, fts5ParseTokenize);\n  }\n  sqlite3_free(z);\n  if( rc || (rc = sCtx.rc) ){\n    pParse->rc = rc;\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    sCtx.pPhrase = 0;\n  }else{\n\n    if( pAppend==0 ){\n      if( (pParse->nPhrase % 8)==0 ){\n        int nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);\n        Fts5ExprPhrase **apNew;\n        apNew = (Fts5ExprPhrase**)sqlite3_realloc(pParse->apPhrase, nByte);\n        if( apNew==0 ){\n          pParse->rc = SQLITE_NOMEM;\n          fts5ExprPhraseFree(sCtx.pPhrase);\n          return 0;\n        }\n        pParse->apPhrase = apNew;\n      }\n      pParse->nPhrase++;\n    }\n\n    if( sCtx.pPhrase==0 ){\n      /* This happens when parsing a token or quoted phrase that contains\n      ** no token characters at all. (e.g ... MATCH '\"\"'). */\n      sCtx.pPhrase = sqlite3Fts5MallocZero(&pParse->rc, sizeof(Fts5ExprPhrase));\n    }else if( sCtx.pPhrase->nTerm ){\n      sCtx.pPhrase->aTerm[sCtx.pPhrase->nTerm-1].bPrefix = bPrefix;\n    }\n    pParse->apPhrase[pParse->nPhrase-1] = sCtx.pPhrase;\n  }\n\n  return sCtx.pPhrase;\n}\n\n/*\n** Create a new FTS5 expression by cloning phrase iPhrase of the\n** expression passed as the second argument.\n*/\nstatic int sqlite3Fts5ExprClonePhrase(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  Fts5Expr **ppNew\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5ExprPhrase *pOrig;          /* The phrase extracted from pExpr */\n  Fts5Expr *pNew = 0;             /* Expression to return via *ppNew */\n  TokenCtx sCtx = {0,0};          /* Context object for fts5ParseTokenize */\n\n  pOrig = pExpr->apExprPhrase[iPhrase];\n  pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr));\n  if( rc==SQLITE_OK ){\n    pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot = (Fts5ExprNode*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNode));\n  }\n  if( rc==SQLITE_OK ){\n    pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, \n        sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*));\n  }\n  if( rc==SQLITE_OK ){\n    Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;\n    if( pColsetOrig ){\n      int nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);\n      Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);\n      if( pColset ){ \n        memcpy(pColset, pColsetOrig, nByte);\n      }\n      pNew->pRoot->pNear->pColset = pColset;\n    }\n  }\n\n  if( pOrig->nTerm ){\n    int i;                          /* Used to iterate through phrase terms */\n    for(i=0; rc==SQLITE_OK && i<pOrig->nTerm; i++){\n      int tflags = 0;\n      Fts5ExprTerm *p;\n      for(p=&pOrig->aTerm[i]; p && rc==SQLITE_OK; p=p->pSynonym){\n        const char *zTerm = p->zTerm;\n        rc = fts5ParseTokenize((void*)&sCtx, tflags, zTerm, (int)strlen(zTerm),\n            0, 0);\n        tflags = FTS5_TOKEN_COLOCATED;\n      }\n      if( rc==SQLITE_OK ){\n        sCtx.pPhrase->aTerm[i].bPrefix = pOrig->aTerm[i].bPrefix;\n      }\n    }\n  }else{\n    /* This happens when parsing a token or quoted phrase that contains\n    ** no token characters at all. (e.g ... MATCH '\"\"'). */\n    sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));\n  }\n\n  if( rc==SQLITE_OK ){\n    /* All the allocations succeeded. Put the expression object together. */\n    pNew->pIndex = pExpr->pIndex;\n    pNew->pConfig = pExpr->pConfig;\n    pNew->nPhrase = 1;\n    pNew->apExprPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->apPhrase[0] = sCtx.pPhrase;\n    pNew->pRoot->pNear->nPhrase = 1;\n    sCtx.pPhrase->pNode = pNew->pRoot;\n\n    if( pOrig->nTerm==1 && pOrig->aTerm[0].pSynonym==0 ){\n      pNew->pRoot->eType = FTS5_TERM;\n      pNew->pRoot->xNext = fts5ExprNodeNext_TERM;\n    }else{\n      pNew->pRoot->eType = FTS5_STRING;\n      pNew->pRoot->xNext = fts5ExprNodeNext_STRING;\n    }\n  }else{\n    sqlite3Fts5ExprFree(pNew);\n    fts5ExprPhraseFree(sCtx.pPhrase);\n    pNew = 0;\n  }\n\n  *ppNew = pNew;\n  return rc;\n}\n\n\n/*\n** Token pTok has appeared in a MATCH expression where the NEAR operator\n** is expected. If token pTok does not contain \"NEAR\", store an error\n** in the pParse object.\n*/\nstatic void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token *pTok){\n  if( pTok->n!=4 || memcmp(\"NEAR\", pTok->p, 4) ){\n    sqlite3Fts5ParseError(\n        pParse, \"fts5: syntax error near \\\"%.*s\\\"\", pTok->n, pTok->p\n    );\n  }\n}\n\nstatic void sqlite3Fts5ParseSetDistance(\n  Fts5Parse *pParse, \n  Fts5ExprNearset *pNear,\n  Fts5Token *p\n){\n  if( pNear ){\n    int nNear = 0;\n    int i;\n    if( p->n ){\n      for(i=0; i<p->n; i++){\n        char c = (char)p->p[i];\n        if( c<'0' || c>'9' ){\n          sqlite3Fts5ParseError(\n              pParse, \"expected integer, got \\\"%.*s\\\"\", p->n, p->p\n              );\n          return;\n        }\n        nNear = nNear * 10 + (p->p[i] - '0');\n      }\n    }else{\n      nNear = FTS5_DEFAULT_NEARDIST;\n    }\n    pNear->nNear = nNear;\n  }\n}\n\n/*\n** The second argument passed to this function may be NULL, or it may be\n** an existing Fts5Colset object. This function returns a pointer to\n** a new colset object containing the contents of (p) with new value column\n** number iCol appended. \n**\n** If an OOM error occurs, store an error code in pParse and return NULL.\n** The old colset object (if any) is not freed in this case.\n*/\nstatic Fts5Colset *fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *p,                  /* Existing colset object */\n  int iCol                        /* New column to add to colset object */\n){\n  int nCol = p ? p->nCol : 0;     /* Num. columns already in colset object */\n  Fts5Colset *pNew;               /* New colset object to return */\n\n  assert( pParse->rc==SQLITE_OK );\n  assert( iCol>=0 && iCol<pParse->pConfig->nCol );\n\n  pNew = sqlite3_realloc(p, sizeof(Fts5Colset) + sizeof(int)*nCol);\n  if( pNew==0 ){\n    pParse->rc = SQLITE_NOMEM;\n  }else{\n    int *aiCol = pNew->aiCol;\n    int i, j;\n    for(i=0; i<nCol; i++){\n      if( aiCol[i]==iCol ) return pNew;\n      if( aiCol[i]>iCol ) break;\n    }\n    for(j=nCol; j>i; j--){\n      aiCol[j] = aiCol[j-1];\n    }\n    aiCol[i] = iCol;\n    pNew->nCol = nCol+1;\n\n#ifndef NDEBUG\n    /* Check that the array is in order and contains no duplicate entries. */\n    for(i=1; i<pNew->nCol; i++) assert( pNew->aiCol[i]>pNew->aiCol[i-1] );\n#endif\n  }\n\n  return pNew;\n}\n\n/*\n** Allocate and return an Fts5Colset object specifying the inverse of\n** the colset passed as the second argument. Free the colset passed\n** as the second argument before returning.\n*/\nstatic Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse *pParse, Fts5Colset *p){\n  Fts5Colset *pRet;\n  int nCol = pParse->pConfig->nCol;\n\n  pRet = (Fts5Colset*)sqlite3Fts5MallocZero(&pParse->rc, \n      sizeof(Fts5Colset) + sizeof(int)*nCol\n  );\n  if( pRet ){\n    int i;\n    int iOld = 0;\n    for(i=0; i<nCol; i++){\n      if( iOld>=p->nCol || p->aiCol[iOld]!=i ){\n        pRet->aiCol[pRet->nCol++] = i;\n      }else{\n        iOld++;\n      }\n    }\n  }\n\n  sqlite3_free(p);\n  return pRet;\n}\n\nstatic Fts5Colset *sqlite3Fts5ParseColset(\n  Fts5Parse *pParse,              /* Store SQLITE_NOMEM here if required */\n  Fts5Colset *pColset,            /* Existing colset object */\n  Fts5Token *p\n){\n  Fts5Colset *pRet = 0;\n  int iCol;\n  char *z;                        /* Dequoted copy of token p */\n\n  z = sqlite3Fts5Strndup(&pParse->rc, p->p, p->n);\n  if( pParse->rc==SQLITE_OK ){\n    Fts5Config *pConfig = pParse->pConfig;\n    sqlite3Fts5Dequote(z);\n    for(iCol=0; iCol<pConfig->nCol; iCol++){\n      if( 0==sqlite3_stricmp(pConfig->azCol[iCol], z) ) break;\n    }\n    if( iCol==pConfig->nCol ){\n      sqlite3Fts5ParseError(pParse, \"no such column: %s\", z);\n    }else{\n      pRet = fts5ParseColset(pParse, pColset, iCol);\n    }\n    sqlite3_free(z);\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3_free(pColset);\n  }\n\n  return pRet;\n}\n\n/*\n** If argument pOrig is NULL, or if (*pRc) is set to anything other than\n** SQLITE_OK when this function is called, NULL is returned. \n**\n** Otherwise, a copy of (*pOrig) is made into memory obtained from\n** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation\n** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned.\n*/\nstatic Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){\n  Fts5Colset *pRet;\n  if( pOrig ){\n    int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);\n    pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);\n    if( pRet ){ \n      memcpy(pRet, pOrig, nByte);\n    }\n  }else{\n    pRet = 0;\n  }\n  return pRet;\n}\n\n/*\n** Remove from colset pColset any columns that are not also in colset pMerge.\n*/\nstatic void fts5MergeColset(Fts5Colset *pColset, Fts5Colset *pMerge){\n  int iIn = 0;          /* Next input in pColset */\n  int iMerge = 0;       /* Next input in pMerge */\n  int iOut = 0;         /* Next output slot in pColset */\n\n  while( iIn<pColset->nCol && iMerge<pMerge->nCol ){\n    int iDiff = pColset->aiCol[iIn] - pMerge->aiCol[iMerge];\n    if( iDiff==0 ){\n      pColset->aiCol[iOut++] = pMerge->aiCol[iMerge];\n      iMerge++;\n      iIn++;\n    }else if( iDiff>0 ){\n      iMerge++;\n    }else{\n      iIn++;\n    }\n  }\n  pColset->nCol = iOut;\n}\n\n/*\n** Recursively apply colset pColset to expression node pNode and all of\n** its decendents. If (*ppFree) is not NULL, it contains a spare copy\n** of pColset. This function may use the spare copy and set (*ppFree) to\n** zero, or it may create copies of pColset using fts5CloneColset().\n*/\nstatic void fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pNode, \n  Fts5Colset *pColset,\n  Fts5Colset **ppFree\n){\n  if( pParse->rc==SQLITE_OK ){\n    assert( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING \n         || pNode->eType==FTS5_AND  || pNode->eType==FTS5_OR\n         || pNode->eType==FTS5_NOT  || pNode->eType==FTS5_EOF\n    );\n    if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->pColset ){\n        fts5MergeColset(pNear->pColset, pColset);\n        if( pNear->pColset->nCol==0 ){\n          pNode->eType = FTS5_EOF;\n          pNode->xNext = 0;\n        }\n      }else if( *ppFree ){\n        pNear->pColset = pColset;\n        *ppFree = 0;\n      }else{\n        pNear->pColset = fts5CloneColset(&pParse->rc, pColset);\n      }\n    }else{\n      int i;\n      assert( pNode->eType!=FTS5_EOF || pNode->nChild==0 );\n      for(i=0; i<pNode->nChild; i++){\n        fts5ParseSetColset(pParse, pNode->apChild[i], pColset, ppFree);\n      }\n    }\n  }\n}\n\n/*\n** Apply colset pColset to expression node pExpr and all of its descendents.\n*/\nstatic void sqlite3Fts5ParseSetColset(\n  Fts5Parse *pParse, \n  Fts5ExprNode *pExpr, \n  Fts5Colset *pColset \n){\n  Fts5Colset *pFree = pColset;\n  if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pParse->rc = SQLITE_ERROR;\n    pParse->zErr = sqlite3_mprintf(\n      \"fts5: column queries are not supported (detail=none)\"\n    );\n  }else{\n    fts5ParseSetColset(pParse, pExpr, pColset, &pFree);\n  }\n  sqlite3_free(pFree);\n}\n\nstatic void fts5ExprAssignXNext(Fts5ExprNode *pNode){\n  switch( pNode->eType ){\n    case FTS5_STRING: {\n      Fts5ExprNearset *pNear = pNode->pNear;\n      if( pNear->nPhrase==1 && pNear->apPhrase[0]->nTerm==1 \n       && pNear->apPhrase[0]->aTerm[0].pSynonym==0\n      ){\n        pNode->eType = FTS5_TERM;\n        pNode->xNext = fts5ExprNodeNext_TERM;\n      }else{\n        pNode->xNext = fts5ExprNodeNext_STRING;\n      }\n      break;\n    };\n\n    case FTS5_OR: {\n      pNode->xNext = fts5ExprNodeNext_OR;\n      break;\n    };\n\n    case FTS5_AND: {\n      pNode->xNext = fts5ExprNodeNext_AND;\n      break;\n    };\n\n    default: assert( pNode->eType==FTS5_NOT ); {\n      pNode->xNext = fts5ExprNodeNext_NOT;\n      break;\n    };\n  }\n}\n\nstatic void fts5ExprAddChildren(Fts5ExprNode *p, Fts5ExprNode *pSub){\n  if( p->eType!=FTS5_NOT && pSub->eType==p->eType ){\n    int nByte = sizeof(Fts5ExprNode*) * pSub->nChild;\n    memcpy(&p->apChild[p->nChild], pSub->apChild, nByte);\n    p->nChild += pSub->nChild;\n    sqlite3_free(pSub);\n  }else{\n    p->apChild[p->nChild++] = pSub;\n  }\n}\n\n/*\n** Allocate and return a new expression object. If anything goes wrong (i.e.\n** OOM error), leave an error code in pParse and return NULL.\n*/\nstatic Fts5ExprNode *sqlite3Fts5ParseNode(\n  Fts5Parse *pParse,              /* Parse context */\n  int eType,                      /* FTS5_STRING, AND, OR or NOT */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight,           /* Right hand child expression */\n  Fts5ExprNearset *pNear          /* For STRING expressions, the near cluster */\n){\n  Fts5ExprNode *pRet = 0;\n\n  if( pParse->rc==SQLITE_OK ){\n    int nChild = 0;               /* Number of children of returned node */\n    int nByte;                    /* Bytes of space to allocate for this node */\n \n    assert( (eType!=FTS5_STRING && !pNear)\n         || (eType==FTS5_STRING && !pLeft && !pRight)\n    );\n    if( eType==FTS5_STRING && pNear==0 ) return 0;\n    if( eType!=FTS5_STRING && pLeft==0 ) return pRight;\n    if( eType!=FTS5_STRING && pRight==0 ) return pLeft;\n\n    if( eType==FTS5_NOT ){\n      nChild = 2;\n    }else if( eType==FTS5_AND || eType==FTS5_OR ){\n      nChild = 2;\n      if( pLeft->eType==eType ) nChild += pLeft->nChild-1;\n      if( pRight->eType==eType ) nChild += pRight->nChild-1;\n    }\n\n    nByte = sizeof(Fts5ExprNode) + sizeof(Fts5ExprNode*)*(nChild-1);\n    pRet = (Fts5ExprNode*)sqlite3Fts5MallocZero(&pParse->rc, nByte);\n\n    if( pRet ){\n      pRet->eType = eType;\n      pRet->pNear = pNear;\n      fts5ExprAssignXNext(pRet);\n      if( eType==FTS5_STRING ){\n        int iPhrase;\n        for(iPhrase=0; iPhrase<pNear->nPhrase; iPhrase++){\n          pNear->apPhrase[iPhrase]->pNode = pRet;\n          if( pNear->apPhrase[iPhrase]->nTerm==0 ){\n            pRet->xNext = 0;\n            pRet->eType = FTS5_EOF;\n          }\n        }\n\n        if( pParse->pConfig->eDetail!=FTS5_DETAIL_FULL \n         && (pNear->nPhrase!=1 || pNear->apPhrase[0]->nTerm>1)\n        ){\n          assert( pParse->rc==SQLITE_OK );\n          pParse->rc = SQLITE_ERROR;\n          assert( pParse->zErr==0 );\n          pParse->zErr = sqlite3_mprintf(\n              \"fts5: %s queries are not supported (detail!=full)\", \n              pNear->nPhrase==1 ? \"phrase\": \"NEAR\"\n          );\n          sqlite3_free(pRet);\n          pRet = 0;\n        }\n\n      }else{\n        fts5ExprAddChildren(pRet, pLeft);\n        fts5ExprAddChildren(pRet, pRight);\n      }\n    }\n  }\n\n  if( pRet==0 ){\n    assert( pParse->rc!=SQLITE_OK );\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n    sqlite3Fts5ParseNearsetFree(pNear);\n  }\n  return pRet;\n}\n\nstatic Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(\n  Fts5Parse *pParse,              /* Parse context */\n  Fts5ExprNode *pLeft,            /* Left hand child expression */\n  Fts5ExprNode *pRight            /* Right hand child expression */\n){\n  Fts5ExprNode *pRet = 0;\n  Fts5ExprNode *pPrev;\n\n  if( pParse->rc ){\n    sqlite3Fts5ParseNodeFree(pLeft);\n    sqlite3Fts5ParseNodeFree(pRight);\n  }else{\n\n    assert( pLeft->eType==FTS5_STRING \n        || pLeft->eType==FTS5_TERM\n        || pLeft->eType==FTS5_EOF\n        || pLeft->eType==FTS5_AND\n    );\n    assert( pRight->eType==FTS5_STRING \n        || pRight->eType==FTS5_TERM \n        || pRight->eType==FTS5_EOF \n    );\n\n    if( pLeft->eType==FTS5_AND ){\n      pPrev = pLeft->apChild[pLeft->nChild-1];\n    }else{\n      pPrev = pLeft;\n    }\n    assert( pPrev->eType==FTS5_STRING \n        || pPrev->eType==FTS5_TERM \n        || pPrev->eType==FTS5_EOF \n        );\n\n    if( pRight->eType==FTS5_EOF ){\n      assert( pParse->apPhrase[pParse->nPhrase-1]==pRight->pNear->apPhrase[0] );\n      sqlite3Fts5ParseNodeFree(pRight);\n      pRet = pLeft;\n      pParse->nPhrase--;\n    }\n    else if( pPrev->eType==FTS5_EOF ){\n      Fts5ExprPhrase **ap;\n\n      if( pPrev==pLeft ){\n        pRet = pRight;\n      }else{\n        pLeft->apChild[pLeft->nChild-1] = pRight;\n        pRet = pLeft;\n      }\n\n      ap = &pParse->apPhrase[pParse->nPhrase-1-pRight->pNear->nPhrase];\n      assert( ap[0]==pPrev->pNear->apPhrase[0] );\n      memmove(ap, &ap[1], sizeof(Fts5ExprPhrase*)*pRight->pNear->nPhrase);\n      pParse->nPhrase--;\n\n      sqlite3Fts5ParseNodeFree(pPrev);\n    }\n    else{\n      pRet = sqlite3Fts5ParseNode(pParse, FTS5_AND, pLeft, pRight, 0);\n    }\n  }\n\n  return pRet;\n}\n\nstatic char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){\n  int nByte = 0;\n  Fts5ExprTerm *p;\n  char *zQuoted;\n\n  /* Determine the maximum amount of space required. */\n  for(p=pTerm; p; p=p->pSynonym){\n    nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;\n  }\n  zQuoted = sqlite3_malloc(nByte);\n\n  if( zQuoted ){\n    int i = 0;\n    for(p=pTerm; p; p=p->pSynonym){\n      char *zIn = p->zTerm;\n      zQuoted[i++] = '\"';\n      while( *zIn ){\n        if( *zIn=='\"' ) zQuoted[i++] = '\"';\n        zQuoted[i++] = *zIn++;\n      }\n      zQuoted[i++] = '\"';\n      if( p->pSynonym ) zQuoted[i++] = '|';\n    }\n    if( pTerm->bPrefix ){\n      zQuoted[i++] = ' ';\n      zQuoted[i++] = '*';\n    }\n    zQuoted[i++] = '\\0';\n  }\n  return zQuoted;\n}\n\nstatic char *fts5PrintfAppend(char *zApp, const char *zFmt, ...){\n  char *zNew;\n  va_list ap;\n  va_start(ap, zFmt);\n  zNew = sqlite3_vmprintf(zFmt, ap);\n  va_end(ap);\n  if( zApp && zNew ){\n    char *zNew2 = sqlite3_mprintf(\"%s%s\", zApp, zNew);\n    sqlite3_free(zNew);\n    zNew = zNew2;\n  }\n  sqlite3_free(zApp);\n  return zNew;\n}\n\n/*\n** Compose a tcl-readable representation of expression pExpr. Return a \n** pointer to a buffer containing that representation. It is the \n** responsibility of the caller to at some point free the buffer using \n** sqlite3_free().\n*/\nstatic char *fts5ExprPrintTcl(\n  Fts5Config *pConfig, \n  const char *zNearsetCmd,\n  Fts5ExprNode *pExpr\n){\n  char *zRet = 0;\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    zRet = fts5PrintfAppend(zRet, \"%s \", zNearsetCmd);\n    if( zRet==0 ) return 0;\n    if( pNear->pColset ){\n      int *aiCol = pNear->pColset->aiCol;\n      int nCol = pNear->pColset->nCol;\n      if( nCol==1 ){\n        zRet = fts5PrintfAppend(zRet, \"-col %d \", aiCol[0]);\n      }else{\n        zRet = fts5PrintfAppend(zRet, \"-col {%d\", aiCol[0]);\n        for(i=1; i<pNear->pColset->nCol; i++){\n          zRet = fts5PrintfAppend(zRet, \" %d\", aiCol[i]);\n        }\n        zRet = fts5PrintfAppend(zRet, \"} \");\n      }\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"-near %d \", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n    zRet = fts5PrintfAppend(zRet, \"--\");\n    if( zRet==0 ) return 0;\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n\n      zRet = fts5PrintfAppend(zRet, \" {\");\n      for(iTerm=0; zRet && iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = pPhrase->aTerm[iTerm].zTerm;\n        zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" \", zTerm);\n        if( pPhrase->aTerm[iTerm].bPrefix ){\n          zRet = fts5PrintfAppend(zRet, \"*\");\n        }\n      }\n\n      if( zRet ) zRet = fts5PrintfAppend(zRet, \"}\");\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \"AND\"; break;\n      case FTS5_NOT: zOp = \"NOT\"; break;\n      default: \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \"OR\"; \n        break;\n    }\n\n    zRet = sqlite3_mprintf(\"%s\", zOp);\n    for(i=0; zRet && i<pExpr->nChild; i++){\n      char *z = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->apChild[i]);\n      if( !z ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        zRet = fts5PrintfAppend(zRet, \" [%z]\", z);\n      }\n    }\n  }\n\n  return zRet;\n}\n\nstatic char *fts5ExprPrint(Fts5Config *pConfig, Fts5ExprNode *pExpr){\n  char *zRet = 0;\n  if( pExpr->eType==0 ){\n    return sqlite3_mprintf(\"\\\"\\\"\");\n  }else\n  if( pExpr->eType==FTS5_STRING || pExpr->eType==FTS5_TERM ){\n    Fts5ExprNearset *pNear = pExpr->pNear;\n    int i; \n    int iTerm;\n\n    if( pNear->pColset ){\n      int iCol = pNear->pColset->aiCol[0];\n      zRet = fts5PrintfAppend(zRet, \"%s : \", pConfig->azCol[iCol]);\n      if( zRet==0 ) return 0;\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \"NEAR(\");\n      if( zRet==0 ) return 0;\n    }\n\n    for(i=0; i<pNear->nPhrase; i++){\n      Fts5ExprPhrase *pPhrase = pNear->apPhrase[i];\n      if( i!=0 ){\n        zRet = fts5PrintfAppend(zRet, \" \");\n        if( zRet==0 ) return 0;\n      }\n      for(iTerm=0; iTerm<pPhrase->nTerm; iTerm++){\n        char *zTerm = fts5ExprTermPrint(&pPhrase->aTerm[iTerm]);\n        if( zTerm ){\n          zRet = fts5PrintfAppend(zRet, \"%s%s\", iTerm==0?\"\":\" + \", zTerm);\n          sqlite3_free(zTerm);\n        }\n        if( zTerm==0 || zRet==0 ){\n          sqlite3_free(zRet);\n          return 0;\n        }\n      }\n    }\n\n    if( pNear->nPhrase>1 ){\n      zRet = fts5PrintfAppend(zRet, \", %d)\", pNear->nNear);\n      if( zRet==0 ) return 0;\n    }\n\n  }else{\n    char const *zOp = 0;\n    int i;\n\n    switch( pExpr->eType ){\n      case FTS5_AND: zOp = \" AND \"; break;\n      case FTS5_NOT: zOp = \" NOT \"; break;\n      default:  \n        assert( pExpr->eType==FTS5_OR );\n        zOp = \" OR \"; \n        break;\n    }\n\n    for(i=0; i<pExpr->nChild; i++){\n      char *z = fts5ExprPrint(pConfig, pExpr->apChild[i]);\n      if( z==0 ){\n        sqlite3_free(zRet);\n        zRet = 0;\n      }else{\n        int e = pExpr->apChild[i]->eType;\n        int b = (e!=FTS5_STRING && e!=FTS5_TERM && e!=FTS5_EOF);\n        zRet = fts5PrintfAppend(zRet, \"%s%s%z%s\", \n            (i==0 ? \"\" : zOp),\n            (b?\"(\":\"\"), z, (b?\")\":\"\")\n        );\n      }\n      if( zRet==0 ) break;\n    }\n  }\n\n  return zRet;\n}\n\n/*\n** The implementation of user-defined scalar functions fts5_expr() (bTcl==0)\n** and fts5_expr_tcl() (bTcl!=0).\n*/\nstatic void fts5ExprFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal,          /* Function arguments */\n  int bTcl\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zExpr = 0;\n  char *zErr = 0;\n  Fts5Expr *pExpr = 0;\n  int rc;\n  int i;\n\n  const char **azConfig;          /* Array of arguments for Fts5Config */\n  const char *zNearsetCmd = \"nearset\";\n  int nConfig;                    /* Size of azConfig[] */\n  Fts5Config *pConfig = 0;\n  int iArg = 1;\n\n  if( nArg<1 ){\n    zErr = sqlite3_mprintf(\"wrong number of arguments to function %s\",\n        bTcl ? \"fts5_expr_tcl\" : \"fts5_expr\"\n    );\n    sqlite3_result_error(pCtx, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n\n  if( bTcl && nArg>1 ){\n    zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]);\n    iArg = 2;\n  }\n\n  nConfig = 3 + (nArg-iArg);\n  azConfig = (const char**)sqlite3_malloc(sizeof(char*) * nConfig);\n  if( azConfig==0 ){\n    sqlite3_result_error_nomem(pCtx);\n    return;\n  }\n  azConfig[0] = 0;\n  azConfig[1] = \"main\";\n  azConfig[2] = \"tbl\";\n  for(i=3; iArg<nArg; iArg++){\n    azConfig[i++] = (const char*)sqlite3_value_text(apVal[iArg]);\n  }\n\n  zExpr = (const char*)sqlite3_value_text(apVal[0]);\n\n  rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr);\n  }\n  if( rc==SQLITE_OK ){\n    char *zText;\n    if( pExpr->pRoot->xNext==0 ){\n      zText = sqlite3_mprintf(\"\");\n    }else if( bTcl ){\n      zText = fts5ExprPrintTcl(pConfig, zNearsetCmd, pExpr->pRoot);\n    }else{\n      zText = fts5ExprPrint(pConfig, pExpr->pRoot);\n    }\n    if( zText==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      sqlite3_result_text(pCtx, zText, -1, SQLITE_TRANSIENT);\n      sqlite3_free(zText);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    if( zErr ){\n      sqlite3_result_error(pCtx, zErr, -1);\n      sqlite3_free(zErr);\n    }else{\n      sqlite3_result_error_code(pCtx, rc);\n    }\n  }\n  sqlite3_free((void *)azConfig);\n  sqlite3Fts5ConfigFree(pConfig);\n  sqlite3Fts5ExprFree(pExpr);\n}\n\nstatic void fts5ExprFunctionHr(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 0);\n}\nstatic void fts5ExprFunctionTcl(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  fts5ExprFunction(pCtx, nArg, apVal, 1);\n}\n\n/*\n** The implementation of an SQLite user-defined-function that accepts a\n** single integer as an argument. If the integer is an alpha-numeric \n** unicode code point, 1 is returned. Otherwise 0.\n*/\nstatic void fts5ExprIsAlnum(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  int iCode;\n  if( nArg!=1 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_isalnum\", -1\n    );\n    return;\n  }\n  iCode = sqlite3_value_int(apVal[0]);\n  sqlite3_result_int(pCtx, sqlite3Fts5UnicodeIsalnum(iCode));\n}\n\nstatic void fts5ExprFold(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  if( nArg!=1 && nArg!=2 ){\n    sqlite3_result_error(pCtx, \n        \"wrong number of arguments to function fts5_fold\", -1\n    );\n  }else{\n    int iCode;\n    int bRemoveDiacritics = 0;\n    iCode = sqlite3_value_int(apVal[0]);\n    if( nArg==2 ) bRemoveDiacritics = sqlite3_value_int(apVal[1]);\n    sqlite3_result_int(pCtx, sqlite3Fts5UnicodeFold(iCode, bRemoveDiacritics));\n  }\n}\n\n/*\n** This is called during initialization to register the fts5_expr() scalar\n** UDF with the SQLite handle passed as the only argument.\n*/\nstatic int sqlite3Fts5ExprInit(Fts5Global *pGlobal, sqlite3 *db){\n  struct Fts5ExprFunc {\n    const char *z;\n    void (*x)(sqlite3_context*,int,sqlite3_value**);\n  } aFunc[] = {\n    { \"fts5_expr\",     fts5ExprFunctionHr },\n    { \"fts5_expr_tcl\", fts5ExprFunctionTcl },\n    { \"fts5_isalnum\",  fts5ExprIsAlnum },\n    { \"fts5_fold\",     fts5ExprFold },\n  };\n  int i;\n  int rc = SQLITE_OK;\n  void *pCtx = (void*)pGlobal;\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aFunc); i++){\n    struct Fts5ExprFunc *p = &aFunc[i];\n    rc = sqlite3_create_function(db, p->z, -1, SQLITE_UTF8, pCtx, p->x, 0, 0);\n  }\n\n  /* Avoid a warning indicating that sqlite3Fts5ParserTrace() is unused */\n#ifndef NDEBUG\n  (void)sqlite3Fts5ParserTrace;\n#endif\n\n  return rc;\n}\n\n/*\n** Return the number of phrases in expression pExpr.\n*/\nstatic int sqlite3Fts5ExprPhraseCount(Fts5Expr *pExpr){\n  return (pExpr ? pExpr->nPhrase : 0);\n}\n\n/*\n** Return the number of terms in the iPhrase'th phrase in pExpr.\n*/\nstatic int sqlite3Fts5ExprPhraseSize(Fts5Expr *pExpr, int iPhrase){\n  if( iPhrase<0 || iPhrase>=pExpr->nPhrase ) return 0;\n  return pExpr->apExprPhrase[iPhrase]->nTerm;\n}\n\n/*\n** This function is used to access the current position list for phrase\n** iPhrase.\n*/\nstatic int sqlite3Fts5ExprPoslist(Fts5Expr *pExpr, int iPhrase, const u8 **pa){\n  int nRet;\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  if( pNode->bEof==0 && pNode->iRowid==pExpr->pRoot->iRowid ){\n    *pa = pPhrase->poslist.p;\n    nRet = pPhrase->poslist.n;\n  }else{\n    *pa = 0;\n    nRet = 0;\n  }\n  return nRet;\n}\n\nstruct Fts5PoslistPopulator {\n  Fts5PoslistWriter writer;\n  int bOk;                        /* True if ok to populate */\n  int bMiss;\n};\n\nstatic Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){\n  Fts5PoslistPopulator *pRet;\n  pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n  if( pRet ){\n    int i;\n    memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);\n    for(i=0; i<pExpr->nPhrase; i++){\n      Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist;\n      Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n      assert( pExpr->apExprPhrase[i]->nTerm==1 );\n      if( bLive && \n          (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof)\n      ){\n        pRet[i].bMiss = 1;\n      }else{\n        pBuf->n = 0;\n      }\n    }\n  }\n  return pRet;\n}\n\nstruct Fts5ExprCtx {\n  Fts5Expr *pExpr;\n  Fts5PoslistPopulator *aPopulator;\n  i64 iOff;\n};\ntypedef struct Fts5ExprCtx Fts5ExprCtx;\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5ExprColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic int fts5ExprPopulatePoslistsCb(\n  void *pCtx,                /* Copy of 2nd argument to xTokenize() */\n  int tflags,                /* Mask of FTS5_TOKEN_* flags */\n  const char *pToken,        /* Pointer to buffer containing token */\n  int nToken,                /* Size of token in bytes */\n  int iUnused1,              /* Byte offset of token within input text */\n  int iUnused2               /* Byte offset of end of token within input text */\n){\n  Fts5ExprCtx *p = (Fts5ExprCtx*)pCtx;\n  Fts5Expr *pExpr = p->pExpr;\n  int i;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++;\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprTerm *pTerm;\n    if( p->aPopulator[i].bOk==0 ) continue;\n    for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){\n      int nTerm = (int)strlen(pTerm->zTerm);\n      if( (nTerm==nToken || (nTerm<nToken && pTerm->bPrefix))\n       && memcmp(pTerm->zTerm, pToken, nTerm)==0\n      ){\n        int rc = sqlite3Fts5PoslistWriterAppend(\n            &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff\n        );\n        if( rc ) return rc;\n        break;\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5ExprPopulatePoslists(\n  Fts5Config *pConfig,\n  Fts5Expr *pExpr, \n  Fts5PoslistPopulator *aPopulator,\n  int iCol, \n  const char *z, int n\n){\n  int i;\n  Fts5ExprCtx sCtx;\n  sCtx.pExpr = pExpr;\n  sCtx.aPopulator = aPopulator;\n  sCtx.iOff = (((i64)iCol) << 32) - 1;\n\n  for(i=0; i<pExpr->nPhrase; i++){\n    Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode;\n    Fts5Colset *pColset = pNode->pNear->pColset;\n    if( (pColset && 0==fts5ExprColsetTest(pColset, iCol)) \n     || aPopulator[i].bMiss\n    ){\n      aPopulator[i].bOk = 0;\n    }else{\n      aPopulator[i].bOk = 1;\n    }\n  }\n\n  return sqlite3Fts5Tokenize(pConfig, \n      FTS5_TOKENIZE_DOCUMENT, z, n, (void*)&sCtx, fts5ExprPopulatePoslistsCb\n  );\n}\n\nstatic void fts5ExprClearPoslists(Fts5ExprNode *pNode){\n  if( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING ){\n    pNode->pNear->apPhrase[0]->poslist.n = 0;\n  }else{\n    int i;\n    for(i=0; i<pNode->nChild; i++){\n      fts5ExprClearPoslists(pNode->apChild[i]);\n    }\n  }\n}\n\nstatic int fts5ExprCheckPoslists(Fts5ExprNode *pNode, i64 iRowid){\n  pNode->iRowid = iRowid;\n  pNode->bEof = 0;\n  switch( pNode->eType ){\n    case FTS5_TERM:\n    case FTS5_STRING:\n      return (pNode->pNear->apPhrase[0]->poslist.n>0);\n\n    case FTS5_AND: {\n      int i;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid)==0 ){\n          fts5ExprClearPoslists(pNode);\n          return 0;\n        }\n      }\n      break;\n    }\n\n    case FTS5_OR: {\n      int i;\n      int bRet = 0;\n      for(i=0; i<pNode->nChild; i++){\n        if( fts5ExprCheckPoslists(pNode->apChild[i], iRowid) ){\n          bRet = 1;\n        }\n      }\n      return bRet;\n    }\n\n    default: {\n      assert( pNode->eType==FTS5_NOT );\n      if( 0==fts5ExprCheckPoslists(pNode->apChild[0], iRowid)\n          || 0!=fts5ExprCheckPoslists(pNode->apChild[1], iRowid)\n        ){\n        fts5ExprClearPoslists(pNode);\n        return 0;\n      }\n      break;\n    }\n  }\n  return 1;\n}\n\nstatic void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){\n  fts5ExprCheckPoslists(pExpr->pRoot, iRowid);\n}\n\n/*\n** This function is only called for detail=columns tables. \n*/\nstatic int sqlite3Fts5ExprPhraseCollist(\n  Fts5Expr *pExpr, \n  int iPhrase, \n  const u8 **ppCollist, \n  int *pnCollist\n){\n  Fts5ExprPhrase *pPhrase = pExpr->apExprPhrase[iPhrase];\n  Fts5ExprNode *pNode = pPhrase->pNode;\n  int rc = SQLITE_OK;\n\n  assert( iPhrase>=0 && iPhrase<pExpr->nPhrase );\n  assert( pExpr->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n\n  if( pNode->bEof==0 \n   && pNode->iRowid==pExpr->pRoot->iRowid \n   && pPhrase->poslist.n>0\n  ){\n    Fts5ExprTerm *pTerm = &pPhrase->aTerm[0];\n    if( pTerm->pSynonym ){\n      Fts5Buffer *pBuf = (Fts5Buffer*)&pTerm->pSynonym[1];\n      rc = fts5ExprSynonymList(\n          pTerm, pNode->iRowid, pBuf, (u8**)ppCollist, pnCollist\n      );\n    }else{\n      *ppCollist = pPhrase->aTerm[0].pIter->pData;\n      *pnCollist = pPhrase->aTerm[0].pIter->nData;\n    }\n  }else{\n    *ppCollist = 0;\n    *pnCollist = 0;\n  }\n\n  return rc;\n}\n\n\n/*\n** 2014 August 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\ntypedef struct Fts5HashEntry Fts5HashEntry;\n\n/*\n** This file contains the implementation of an in-memory hash table used\n** to accumuluate \"term -> doclist\" content before it is flused to a level-0\n** segment.\n*/\n\n\nstruct Fts5Hash {\n  int eDetail;                    /* Copy of Fts5Config.eDetail */\n  int *pnByte;                    /* Pointer to bytes counter */\n  int nEntry;                     /* Number of entries currently in hash */\n  int nSlot;                      /* Size of aSlot[] array */\n  Fts5HashEntry *pScan;           /* Current ordered scan item */\n  Fts5HashEntry **aSlot;          /* Array of hash slots */\n};\n\n/*\n** Each entry in the hash table is represented by an object of the \n** following type. Each object, its key (a nul-terminated string) and \n** its current data are stored in a single memory allocation. The \n** key immediately follows the object in memory. The position list\n** data immediately follows the key data in memory.\n**\n** The data that follows the key is in a similar, but not identical format\n** to the doclist data stored in the database. It is:\n**\n**   * Rowid, as a varint\n**   * Position list, without 0x00 terminator.\n**   * Size of previous position list and rowid, as a 4 byte\n**     big-endian integer.\n**\n** iRowidOff:\n**   Offset of last rowid written to data area. Relative to first byte of\n**   structure.\n**\n** nData:\n**   Bytes of data written since iRowidOff.\n*/\nstruct Fts5HashEntry {\n  Fts5HashEntry *pHashNext;       /* Next hash entry with same hash-key */\n  Fts5HashEntry *pScanNext;       /* Next entry in sorted order */\n  \n  int nAlloc;                     /* Total size of allocation */\n  int iSzPoslist;                 /* Offset of space for 4-byte poslist size */\n  int nData;                      /* Total bytes of data (incl. structure) */\n  int nKey;                       /* Length of key in bytes */\n  u8 bDel;                        /* Set delete-flag @ iSzPoslist */\n  u8 bContent;                    /* Set content-flag (detail=none mode) */\n  i16 iCol;                       /* Column of last value written */\n  int iPos;                       /* Position of last value written */\n  i64 iRowid;                     /* Rowid of last value written */\n};\n\n/*\n** Eqivalent to:\n**\n**   char *fts5EntryKey(Fts5HashEntry *pEntry){ return zKey; }\n*/\n#define fts5EntryKey(p) ( ((char *)(&(p)[1])) )\n\n\n/*\n** Allocate a new hash table.\n*/\nstatic int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){\n  int rc = SQLITE_OK;\n  Fts5Hash *pNew;\n\n  *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash));\n  if( pNew==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    int nByte;\n    memset(pNew, 0, sizeof(Fts5Hash));\n    pNew->pnByte = pnByte;\n    pNew->eDetail = pConfig->eDetail;\n\n    pNew->nSlot = 1024;\n    nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;\n    pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc(nByte);\n    if( pNew->aSlot==0 ){\n      sqlite3_free(pNew);\n      *ppNew = 0;\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pNew->aSlot, 0, nByte);\n    }\n  }\n  return rc;\n}\n\n/*\n** Free a hash table object.\n*/\nstatic void sqlite3Fts5HashFree(Fts5Hash *pHash){\n  if( pHash ){\n    sqlite3Fts5HashClear(pHash);\n    sqlite3_free(pHash->aSlot);\n    sqlite3_free(pHash);\n  }\n}\n\n/*\n** Empty (but do not delete) a hash table.\n*/\nstatic void sqlite3Fts5HashClear(Fts5Hash *pHash){\n  int i;\n  for(i=0; i<pHash->nSlot; i++){\n    Fts5HashEntry *pNext;\n    Fts5HashEntry *pSlot;\n    for(pSlot=pHash->aSlot[i]; pSlot; pSlot=pNext){\n      pNext = pSlot->pHashNext;\n      sqlite3_free(pSlot);\n    }\n  }\n  memset(pHash->aSlot, 0, pHash->nSlot * sizeof(Fts5HashEntry*));\n  pHash->nEntry = 0;\n}\n\nstatic unsigned int fts5HashKey(int nSlot, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  return (h % nSlot);\n}\n\nstatic unsigned int fts5HashKey2(int nSlot, u8 b, const u8 *p, int n){\n  int i;\n  unsigned int h = 13;\n  for(i=n-1; i>=0; i--){\n    h = (h << 3) ^ h ^ p[i];\n  }\n  h = (h << 3) ^ h ^ b;\n  return (h % nSlot);\n}\n\n/*\n** Resize the hash table by doubling the number of slots.\n*/\nstatic int fts5HashResize(Fts5Hash *pHash){\n  int nNew = pHash->nSlot*2;\n  int i;\n  Fts5HashEntry **apNew;\n  Fts5HashEntry **apOld = pHash->aSlot;\n\n  apNew = (Fts5HashEntry**)sqlite3_malloc(nNew*sizeof(Fts5HashEntry*));\n  if( !apNew ) return SQLITE_NOMEM;\n  memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));\n\n  for(i=0; i<pHash->nSlot; i++){\n    while( apOld[i] ){\n      unsigned int iHash;\n      Fts5HashEntry *p = apOld[i];\n      apOld[i] = p->pHashNext;\n      iHash = fts5HashKey(nNew, (u8*)fts5EntryKey(p),\n                          (int)strlen(fts5EntryKey(p)));\n      p->pHashNext = apNew[iHash];\n      apNew[iHash] = p;\n    }\n  }\n\n  sqlite3_free(apOld);\n  pHash->nSlot = nNew;\n  pHash->aSlot = apNew;\n  return SQLITE_OK;\n}\n\nstatic void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){\n  if( p->iSzPoslist ){\n    u8 *pPtr = (u8*)p;\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      assert( p->nData==p->iSzPoslist );\n      if( p->bDel ){\n        pPtr[p->nData++] = 0x00;\n        if( p->bContent ){\n          pPtr[p->nData++] = 0x00;\n        }\n      }\n    }else{\n      int nSz = (p->nData - p->iSzPoslist - 1);       /* Size in bytes */\n      int nPos = nSz*2 + p->bDel;                     /* Value of nPos field */\n\n      assert( p->bDel==0 || p->bDel==1 );\n      if( nPos<=127 ){\n        pPtr[p->iSzPoslist] = (u8)nPos;\n      }else{\n        int nByte = sqlite3Fts5GetVarintLen((u32)nPos);\n        memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);\n        sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);\n        p->nData += (nByte-1);\n      }\n    }\n\n    p->iSzPoslist = 0;\n    p->bDel = 0;\n    p->bContent = 0;\n  }\n}\n\n/*\n** Add an entry to the in-memory hash table. The key is the concatenation\n** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).\n**\n**     (bByte || pToken) -> (iRowid,iCol,iPos)\n**\n** Or, if iCol is negative, then the value is a delete marker.\n*/\nstatic int sqlite3Fts5HashWrite(\n  Fts5Hash *pHash,\n  i64 iRowid,                     /* Rowid for this entry */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  char bByte,                     /* First byte of token */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  unsigned int iHash;\n  Fts5HashEntry *p;\n  u8 *pPtr;\n  int nIncr = 0;                  /* Amount to increment (*pHash->pnByte) by */\n  int bNew;                       /* If non-delete entry should be written */\n  \n  bNew = (pHash->eDetail==FTS5_DETAIL_FULL);\n\n  /* Attempt to locate an existing hash entry */\n  iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    char *zKey = fts5EntryKey(p);\n    if( zKey[0]==bByte \n     && p->nKey==nToken\n     && memcmp(&zKey[1], pToken, nToken)==0 \n    ){\n      break;\n    }\n  }\n\n  /* If an existing hash entry cannot be found, create a new one. */\n  if( p==0 ){\n    /* Figure out how much space to allocate */\n    char *zKey;\n    int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;\n    if( nByte<128 ) nByte = 128;\n\n    /* Grow the Fts5Hash.aSlot[] array if necessary. */\n    if( (pHash->nEntry*2)>=pHash->nSlot ){\n      int rc = fts5HashResize(pHash);\n      if( rc!=SQLITE_OK ) return rc;\n      iHash = fts5HashKey2(pHash->nSlot, (u8)bByte, (const u8*)pToken, nToken);\n    }\n\n    /* Allocate new Fts5HashEntry and add it to the hash table. */\n    p = (Fts5HashEntry*)sqlite3_malloc(nByte);\n    if( !p ) return SQLITE_NOMEM;\n    memset(p, 0, sizeof(Fts5HashEntry));\n    p->nAlloc = nByte;\n    zKey = fts5EntryKey(p);\n    zKey[0] = bByte;\n    memcpy(&zKey[1], pToken, nToken);\n    assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );\n    p->nKey = nToken;\n    zKey[nToken+1] = '\\0';\n    p->nData = nToken+1 + 1 + sizeof(Fts5HashEntry);\n    p->pHashNext = pHash->aSlot[iHash];\n    pHash->aSlot[iHash] = p;\n    pHash->nEntry++;\n\n    /* Add the first rowid field to the hash-entry */\n    p->nData += sqlite3Fts5PutVarint(&((u8*)p)[p->nData], iRowid);\n    p->iRowid = iRowid;\n\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n    }\n\n    nIncr += p->nData;\n  }else{\n\n    /* Appending to an existing hash-entry. Check that there is enough \n    ** space to append the largest possible new entry. Worst case scenario \n    ** is:\n    **\n    **     + 9 bytes for a new rowid,\n    **     + 4 byte reserved for the \"poslist size\" varint.\n    **     + 1 byte for a \"new column\" byte,\n    **     + 3 bytes for a new column number (16-bit max) as a varint,\n    **     + 5 bytes for the new position offset (32-bit max).\n    */\n    if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){\n      int nNew = p->nAlloc * 2;\n      Fts5HashEntry *pNew;\n      Fts5HashEntry **pp;\n      pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew);\n      if( pNew==0 ) return SQLITE_NOMEM;\n      pNew->nAlloc = nNew;\n      for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);\n      *pp = pNew;\n      p = pNew;\n    }\n    nIncr -= p->nData;\n  }\n  assert( (p->nAlloc - p->nData) >= (9 + 4 + 1 + 3 + 5) );\n\n  pPtr = (u8*)p;\n\n  /* If this is a new rowid, append the 4-byte size field for the previous\n  ** entry, and the new rowid for this entry.  */\n  if( iRowid!=p->iRowid ){\n    fts5HashAddPoslistSize(pHash, p);\n    p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);\n    p->iRowid = iRowid;\n    bNew = 1;\n    p->iSzPoslist = p->nData;\n    if( pHash->eDetail!=FTS5_DETAIL_NONE ){\n      p->nData += 1;\n      p->iCol = (pHash->eDetail==FTS5_DETAIL_FULL ? 0 : -1);\n      p->iPos = 0;\n    }\n  }\n\n  if( iCol>=0 ){\n    if( pHash->eDetail==FTS5_DETAIL_NONE ){\n      p->bContent = 1;\n    }else{\n      /* Append a new column value, if necessary */\n      assert( iCol>=p->iCol );\n      if( iCol!=p->iCol ){\n        if( pHash->eDetail==FTS5_DETAIL_FULL ){\n          pPtr[p->nData++] = 0x01;\n          p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iCol);\n          p->iCol = (i16)iCol;\n          p->iPos = 0;\n        }else{\n          bNew = 1;\n          p->iCol = (i16)(iPos = iCol);\n        }\n      }\n\n      /* Append the new position offset, if necessary */\n      if( bNew ){\n        p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iPos - p->iPos + 2);\n        p->iPos = iPos;\n      }\n    }\n  }else{\n    /* This is a delete. Set the delete flag. */\n    p->bDel = 1;\n  }\n\n  nIncr += p->nData;\n  *pHash->pnByte += nIncr;\n  return SQLITE_OK;\n}\n\n\n/*\n** Arguments pLeft and pRight point to linked-lists of hash-entry objects,\n** each sorted in key order. This function merges the two lists into a\n** single list and returns a pointer to its first element.\n*/\nstatic Fts5HashEntry *fts5HashEntryMerge(\n  Fts5HashEntry *pLeft,\n  Fts5HashEntry *pRight\n){\n  Fts5HashEntry *p1 = pLeft;\n  Fts5HashEntry *p2 = pRight;\n  Fts5HashEntry *pRet = 0;\n  Fts5HashEntry **ppOut = &pRet;\n\n  while( p1 || p2 ){\n    if( p1==0 ){\n      *ppOut = p2;\n      p2 = 0;\n    }else if( p2==0 ){\n      *ppOut = p1;\n      p1 = 0;\n    }else{\n      int i = 0;\n      char *zKey1 = fts5EntryKey(p1);\n      char *zKey2 = fts5EntryKey(p2);\n      while( zKey1[i]==zKey2[i] ) i++;\n\n      if( ((u8)zKey1[i])>((u8)zKey2[i]) ){\n        /* p2 is smaller */\n        *ppOut = p2;\n        ppOut = &p2->pScanNext;\n        p2 = p2->pScanNext;\n      }else{\n        /* p1 is smaller */\n        *ppOut = p1;\n        ppOut = &p1->pScanNext;\n        p1 = p1->pScanNext;\n      }\n      *ppOut = 0;\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Extract all tokens from hash table iHash and link them into a list\n** in sorted order. The hash table is cleared before returning. It is\n** the responsibility of the caller to free the elements of the returned\n** list.\n*/\nstatic int fts5HashEntrySort(\n  Fts5Hash *pHash, \n  const char *pTerm, int nTerm,   /* Query prefix, if any */\n  Fts5HashEntry **ppSorted\n){\n  const int nMergeSlot = 32;\n  Fts5HashEntry **ap;\n  Fts5HashEntry *pList;\n  int iSlot;\n  int i;\n\n  *ppSorted = 0;\n  ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);\n  if( !ap ) return SQLITE_NOMEM;\n  memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);\n\n  for(iSlot=0; iSlot<pHash->nSlot; iSlot++){\n    Fts5HashEntry *pIter;\n    for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){\n      if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){\n        Fts5HashEntry *pEntry = pIter;\n        pEntry->pScanNext = 0;\n        for(i=0; ap[i]; i++){\n          pEntry = fts5HashEntryMerge(pEntry, ap[i]);\n          ap[i] = 0;\n        }\n        ap[i] = pEntry;\n      }\n    }\n  }\n\n  pList = 0;\n  for(i=0; i<nMergeSlot; i++){\n    pList = fts5HashEntryMerge(pList, ap[i]);\n  }\n\n  pHash->nEntry = 0;\n  sqlite3_free(ap);\n  *ppSorted = pList;\n  return SQLITE_OK;\n}\n\n/*\n** Query the hash table for a doclist associated with term pTerm/nTerm.\n*/\nstatic int sqlite3Fts5HashQuery(\n  Fts5Hash *pHash,                /* Hash table to query */\n  const char *pTerm, int nTerm,   /* Query term */\n  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */\n  int *pnDoclist                  /* OUT: Size of doclist in bytes */\n){\n  unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);\n  char *zKey = 0;\n  Fts5HashEntry *p;\n\n  for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){\n    zKey = fts5EntryKey(p);\n    if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;\n  }\n\n  if( p ){\n    fts5HashAddPoslistSize(pHash, p);\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5HashScanInit(\n  Fts5Hash *p,                    /* Hash table to query */\n  const char *pTerm, int nTerm    /* Query prefix */\n){\n  return fts5HashEntrySort(p, pTerm, nTerm, &p->pScan);\n}\n\nstatic void sqlite3Fts5HashScanNext(Fts5Hash *p){\n  assert( !sqlite3Fts5HashScanEof(p) );\n  p->pScan = p->pScan->pScanNext;\n}\n\nstatic int sqlite3Fts5HashScanEof(Fts5Hash *p){\n  return (p->pScan==0);\n}\n\nstatic void sqlite3Fts5HashScanEntry(\n  Fts5Hash *pHash,\n  const char **pzTerm,            /* OUT: term (nul-terminated) */\n  const u8 **ppDoclist,           /* OUT: pointer to doclist */\n  int *pnDoclist                  /* OUT: size of doclist in bytes */\n){\n  Fts5HashEntry *p;\n  if( (p = pHash->pScan) ){\n    char *zKey = fts5EntryKey(p);\n    int nTerm = (int)strlen(zKey);\n    fts5HashAddPoslistSize(pHash, p);\n    *pzTerm = zKey;\n    *ppDoclist = (const u8*)&zKey[nTerm+1];\n    *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);\n  }else{\n    *pzTerm = 0;\n    *ppDoclist = 0;\n    *pnDoclist = 0;\n  }\n}\n\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Low level access to the FTS index stored in the database file. The \n** routines in this file file implement all read and write access to the\n** %_data table. Other parts of the system access this functionality via\n** the interface defined in fts5Int.h.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** Overview:\n**\n** The %_data table contains all the FTS indexes for an FTS5 virtual table.\n** As well as the main term index, there may be up to 31 prefix indexes.\n** The format is similar to FTS3/4, except that:\n**\n**   * all segment b-tree leaf data is stored in fixed size page records \n**     (e.g. 1000 bytes). A single doclist may span multiple pages. Care is \n**     taken to ensure it is possible to iterate in either direction through \n**     the entries in a doclist, or to seek to a specific entry within a \n**     doclist, without loading it into memory.\n**\n**   * large doclists that span many pages have associated \"doclist index\"\n**     records that contain a copy of the first rowid on each page spanned by\n**     the doclist. This is used to speed up seek operations, and merges of\n**     large doclists with very small doclists.\n**\n**   * extra fields in the \"structure record\" record the state of ongoing\n**     incremental merge operations.\n**\n*/\n\n\n#define FTS5_OPT_WORK_UNIT  1000  /* Number of leaf pages per optimize step */\n#define FTS5_WORK_UNIT      64    /* Number of leaf pages in unit of work */\n\n#define FTS5_MIN_DLIDX_SIZE 4     /* Add dlidx if this many empty pages */\n\n#define FTS5_MAIN_PREFIX '0'\n\n#if FTS5_MAX_PREFIX_INDEXES > 31\n# error \"FTS5_MAX_PREFIX_INDEXES is too large\"\n#endif\n\n/*\n** Details:\n**\n** The %_data table managed by this module,\n**\n**     CREATE TABLE %_data(id INTEGER PRIMARY KEY, block BLOB);\n**\n** , contains the following 5 types of records. See the comments surrounding\n** the FTS5_*_ROWID macros below for a description of how %_data rowids are \n** assigned to each fo them.\n**\n** 1. Structure Records:\n**\n**   The set of segments that make up an index - the index structure - are\n**   recorded in a single record within the %_data table. The record consists\n**   of a single 32-bit configuration cookie value followed by a list of \n**   SQLite varints. If the FTS table features more than one index (because\n**   there are one or more prefix indexes), it is guaranteed that all share\n**   the same cookie value.\n**\n**   Immediately following the configuration cookie, the record begins with\n**   three varints:\n**\n**     + number of levels,\n**     + total number of segments on all levels,\n**     + value of write counter.\n**\n**   Then, for each level from 0 to nMax:\n**\n**     + number of input segments in ongoing merge.\n**     + total number of segments in level.\n**     + for each segment from oldest to newest:\n**         + segment id (always > 0)\n**         + first leaf page number (often 1, always greater than 0)\n**         + final leaf page number\n**\n** 2. The Averages Record:\n**\n**   A single record within the %_data table. The data is a list of varints.\n**   The first value is the number of rows in the index. Then, for each column\n**   from left to right, the total number of tokens in the column for all\n**   rows of the table.\n**\n** 3. Segment leaves:\n**\n**   TERM/DOCLIST FORMAT:\n**\n**     Most of each segment leaf is taken up by term/doclist data. The \n**     general format of term/doclist, starting with the first term\n**     on the leaf page, is:\n**\n**         varint : size of first term\n**         blob:    first term data\n**         doclist: first doclist\n**         zero-or-more {\n**           varint:  number of bytes in common with previous term\n**           varint:  number of bytes of new term data (nNew)\n**           blob:    nNew bytes of new term data\n**           doclist: next doclist\n**         }\n**\n**     doclist format:\n**\n**         varint:  first rowid\n**         poslist: first poslist\n**         zero-or-more {\n**           varint:  rowid delta (always > 0)\n**           poslist: next poslist\n**         }\n**\n**     poslist format:\n**\n**         varint: size of poslist in bytes multiplied by 2, not including\n**                 this field. Plus 1 if this entry carries the \"delete\" flag.\n**         collist: collist for column 0\n**         zero-or-more {\n**           0x01 byte\n**           varint: column number (I)\n**           collist: collist for column I\n**         }\n**\n**     collist format:\n**\n**         varint: first offset + 2\n**         zero-or-more {\n**           varint: offset delta + 2\n**         }\n**\n**   PAGE FORMAT\n**\n**     Each leaf page begins with a 4-byte header containing 2 16-bit \n**     unsigned integer fields in big-endian format. They are:\n**\n**       * The byte offset of the first rowid on the page, if it exists\n**         and occurs before the first term (otherwise 0).\n**\n**       * The byte offset of the start of the page footer. If the page\n**         footer is 0 bytes in size, then this field is the same as the\n**         size of the leaf page in bytes.\n**\n**     The page footer consists of a single varint for each term located\n**     on the page. Each varint is the byte offset of the current term\n**     within the page, delta-compressed against the previous value. In\n**     other words, the first varint in the footer is the byte offset of\n**     the first term, the second is the byte offset of the second less that\n**     of the first, and so on.\n**\n**     The term/doclist format described above is accurate if the entire\n**     term/doclist data fits on a single leaf page. If this is not the case,\n**     the format is changed in two ways:\n**\n**       + if the first rowid on a page occurs before the first term, it\n**         is stored as a literal value:\n**\n**             varint:  first rowid\n**\n**       + the first term on each page is stored in the same way as the\n**         very first term of the segment:\n**\n**             varint : size of first term\n**             blob:    first term data\n**\n** 5. Segment doclist indexes:\n**\n**   Doclist indexes are themselves b-trees, however they usually consist of\n**   a single leaf record only. The format of each doclist index leaf page \n**   is:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear if leaf is also the root page, otherwise set.\n**\n**     * Page number of fts index leaf page. As a varint.\n**\n**     * First rowid on page indicated by previous field. As a varint.\n**\n**     * A list of varints, one for each subsequent termless page. A \n**       positive delta if the termless page contains at least one rowid, \n**       or an 0x00 byte otherwise.\n**\n**   Internal doclist index nodes are:\n**\n**     * Flags byte. Bits are:\n**         0x01: Clear for root page, otherwise set.\n**\n**     * Page number of first child page. As a varint.\n**\n**     * Copy of first rowid on page indicated by previous field. As a varint.\n**\n**     * A list of delta-encoded varints - the first rowid on each subsequent\n**       child page. \n**\n*/\n\n/*\n** Rowids for the averages and structure records in the %_data table.\n*/\n#define FTS5_AVERAGES_ROWID     1    /* Rowid used for the averages record */\n#define FTS5_STRUCTURE_ROWID   10    /* The structure record */\n\n/*\n** Macros determining the rowids used by segment leaves and dlidx leaves\n** and nodes. All nodes and leaves are stored in the %_data table with large\n** positive rowids.\n**\n** Each segment has a unique non-zero 16-bit id.\n**\n** The rowid for each segment leaf is found by passing the segment id and \n** the leaf page number to the FTS5_SEGMENT_ROWID macro. Leaves are numbered\n** sequentially starting from 1.\n*/\n#define FTS5_DATA_ID_B     16     /* Max seg id number 65535 */\n#define FTS5_DATA_DLI_B     1     /* Doclist-index flag (1 bit) */\n#define FTS5_DATA_HEIGHT_B  5     /* Max dlidx tree height of 32 */\n#define FTS5_DATA_PAGE_B   31     /* Max page number of 2147483648 */\n\n#define fts5_dri(segid, dlidx, height, pgno) (                                 \\\n ((i64)(segid)  << (FTS5_DATA_PAGE_B+FTS5_DATA_HEIGHT_B+FTS5_DATA_DLI_B)) +    \\\n ((i64)(dlidx)  << (FTS5_DATA_PAGE_B + FTS5_DATA_HEIGHT_B)) +                  \\\n ((i64)(height) << (FTS5_DATA_PAGE_B)) +                                       \\\n ((i64)(pgno))                                                                 \\\n)\n\n#define FTS5_SEGMENT_ROWID(segid, pgno)       fts5_dri(segid, 0, 0, pgno)\n#define FTS5_DLIDX_ROWID(segid, height, pgno) fts5_dri(segid, 1, height, pgno)\n\n/*\n** Maximum segments permitted in a single index \n*/\n#define FTS5_MAX_SEGMENT 2000\n\n#ifdef SQLITE_DEBUG\nstatic int sqlite3Fts5Corrupt() { return SQLITE_CORRUPT_VTAB; }\n#endif\n\n\n/*\n** Each time a blob is read from the %_data table, it is padded with this\n** many zero bytes. This makes it easier to decode the various record formats\n** without overreading if the records are corrupt.\n*/\n#define FTS5_DATA_ZERO_PADDING 8\n#define FTS5_DATA_PADDING 20\n\ntypedef struct Fts5Data Fts5Data;\ntypedef struct Fts5DlidxIter Fts5DlidxIter;\ntypedef struct Fts5DlidxLvl Fts5DlidxLvl;\ntypedef struct Fts5DlidxWriter Fts5DlidxWriter;\ntypedef struct Fts5Iter Fts5Iter;\ntypedef struct Fts5PageWriter Fts5PageWriter;\ntypedef struct Fts5SegIter Fts5SegIter;\ntypedef struct Fts5DoclistIter Fts5DoclistIter;\ntypedef struct Fts5SegWriter Fts5SegWriter;\ntypedef struct Fts5Structure Fts5Structure;\ntypedef struct Fts5StructureLevel Fts5StructureLevel;\ntypedef struct Fts5StructureSegment Fts5StructureSegment;\n\nstruct Fts5Data {\n  u8 *p;                          /* Pointer to buffer containing record */\n  int nn;                         /* Size of record in bytes */\n  int szLeaf;                     /* Size of leaf without page-index */\n};\n\n/*\n** One object per %_data table.\n*/\nstruct Fts5Index {\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  char *zDataTbl;                 /* Name of %_data table */\n  int nWorkUnit;                  /* Leaf pages in a \"unit\" of work */\n\n  /*\n  ** Variables related to the accumulation of tokens and doclists within the\n  ** in-memory hash tables before they are flushed to disk.\n  */\n  Fts5Hash *pHash;                /* Hash table for in-memory data */\n  int nPendingData;               /* Current bytes of pending data */\n  i64 iWriteRowid;                /* Rowid for current doc being written */\n  int bDelete;                    /* Current write is a delete */\n\n  /* Error state. */\n  int rc;                         /* Current error code */\n\n  /* State used by the fts5DataXXX() functions. */\n  sqlite3_blob *pReader;          /* RO incr-blob open on %_data table */\n  sqlite3_stmt *pWriter;          /* \"INSERT ... %_data VALUES(?,?)\" */\n  sqlite3_stmt *pDeleter;         /* \"DELETE FROM %_data ... id>=? AND id<=?\" */\n  sqlite3_stmt *pIdxWriter;       /* \"INSERT ... %_idx VALUES(?,?,?,?)\" */\n  sqlite3_stmt *pIdxDeleter;      /* \"DELETE FROM %_idx WHERE segid=? */\n  sqlite3_stmt *pIdxSelect;\n  int nRead;                      /* Total number of blocks read */\n\n  sqlite3_stmt *pDataVersion;\n  i64 iStructVersion;             /* data_version when pStruct read */\n  Fts5Structure *pStruct;         /* Current db structure (or NULL) */\n};\n\nstruct Fts5DoclistIter {\n  u8 *aEof;                       /* Pointer to 1 byte past end of doclist */\n\n  /* Output variables. aPoslist==0 at EOF */\n  i64 iRowid;\n  u8 *aPoslist;\n  int nPoslist;\n  int nSize;\n};\n\n/*\n** The contents of the \"structure\" record for each index are represented\n** using an Fts5Structure record in memory. Which uses instances of the \n** other Fts5StructureXXX types as components.\n*/\nstruct Fts5StructureSegment {\n  int iSegid;                     /* Segment id */\n  int pgnoFirst;                  /* First leaf page number in segment */\n  int pgnoLast;                   /* Last leaf page number in segment */\n};\nstruct Fts5StructureLevel {\n  int nMerge;                     /* Number of segments in incr-merge */\n  int nSeg;                       /* Total number of segments on level */\n  Fts5StructureSegment *aSeg;     /* Array of segments. aSeg[0] is oldest. */\n};\nstruct Fts5Structure {\n  int nRef;                       /* Object reference count */\n  u64 nWriteCounter;              /* Total leaves written to level 0 */\n  int nSegment;                   /* Total segments in this structure */\n  int nLevel;                     /* Number of levels in this index */\n  Fts5StructureLevel aLevel[1];   /* Array of nLevel level objects */\n};\n\n/*\n** An object of type Fts5SegWriter is used to write to segments.\n*/\nstruct Fts5PageWriter {\n  int pgno;                       /* Page number for this page */\n  int iPrevPgidx;                 /* Previous value written into pgidx */\n  Fts5Buffer buf;                 /* Buffer containing leaf data */\n  Fts5Buffer pgidx;               /* Buffer containing page-index */\n  Fts5Buffer term;                /* Buffer containing previous term on page */\n};\nstruct Fts5DlidxWriter {\n  int pgno;                       /* Page number for this page */\n  int bPrevValid;                 /* True if iPrev is valid */\n  i64 iPrev;                      /* Previous rowid value written to page */\n  Fts5Buffer buf;                 /* Buffer containing page data */\n};\nstruct Fts5SegWriter {\n  int iSegid;                     /* Segid to write to */\n  Fts5PageWriter writer;          /* PageWriter object */\n  i64 iPrevRowid;                 /* Previous rowid written to current leaf */\n  u8 bFirstRowidInDoclist;        /* True if next rowid is first in doclist */\n  u8 bFirstRowidInPage;           /* True if next rowid is first in page */\n  /* TODO1: Can use (writer.pgidx.n==0) instead of bFirstTermInPage */\n  u8 bFirstTermInPage;            /* True if next term will be first in leaf */\n  int nLeafWritten;               /* Number of leaf pages written */\n  int nEmpty;                     /* Number of contiguous term-less nodes */\n\n  int nDlidx;                     /* Allocated size of aDlidx[] array */\n  Fts5DlidxWriter *aDlidx;        /* Array of Fts5DlidxWriter objects */\n\n  /* Values to insert into the %_idx table */\n  Fts5Buffer btterm;              /* Next term to insert into %_idx table */\n  int iBtPage;                    /* Page number corresponding to btterm */\n};\n\ntypedef struct Fts5CResult Fts5CResult;\nstruct Fts5CResult {\n  u16 iFirst;                     /* aSeg[] index of firstest iterator */\n  u8 bTermEq;                     /* True if the terms are equal */\n};\n\n/*\n** Object for iterating through a single segment, visiting each term/rowid\n** pair in the segment.\n**\n** pSeg:\n**   The segment to iterate through.\n**\n** iLeafPgno:\n**   Current leaf page number within segment.\n**\n** iLeafOffset:\n**   Byte offset within the current leaf that is the first byte of the \n**   position list data (one byte passed the position-list size field).\n**   rowid field of the current entry. Usually this is the size field of the\n**   position list data. The exception is if the rowid for the current entry \n**   is the last thing on the leaf page.\n**\n** pLeaf:\n**   Buffer containing current leaf page data. Set to NULL at EOF.\n**\n** iTermLeafPgno, iTermLeafOffset:\n**   Leaf page number containing the last term read from the segment. And\n**   the offset immediately following the term data.\n**\n** flags:\n**   Mask of FTS5_SEGITER_XXX values. Interpreted as follows:\n**\n**   FTS5_SEGITER_ONETERM:\n**     If set, set the iterator to point to EOF after the current doclist \n**     has been exhausted. Do not proceed to the next term in the segment.\n**\n**   FTS5_SEGITER_REVERSE:\n**     This flag is only ever set if FTS5_SEGITER_ONETERM is also set. If\n**     it is set, iterate through rowid in descending order instead of the\n**     default ascending order.\n**\n** iRowidOffset/nRowidOffset/aRowidOffset:\n**     These are used if the FTS5_SEGITER_REVERSE flag is set.\n**\n**     For each rowid on the page corresponding to the current term, the\n**     corresponding aRowidOffset[] entry is set to the byte offset of the\n**     start of the \"position-list-size\" field within the page.\n**\n** iTermIdx:\n**     Index of current term on iTermLeafPgno.\n*/\nstruct Fts5SegIter {\n  Fts5StructureSegment *pSeg;     /* Segment to iterate through */\n  int flags;                      /* Mask of configuration flags */\n  int iLeafPgno;                  /* Current leaf page number */\n  Fts5Data *pLeaf;                /* Current leaf data */\n  Fts5Data *pNextLeaf;            /* Leaf page (iLeafPgno+1) */\n  int iLeafOffset;                /* Byte offset within current leaf */\n\n  /* Next method */\n  void (*xNext)(Fts5Index*, Fts5SegIter*, int*);\n\n  /* The page and offset from which the current term was read. The offset \n  ** is the offset of the first rowid in the current doclist.  */\n  int iTermLeafPgno;\n  int iTermLeafOffset;\n\n  int iPgidxOff;                  /* Next offset in pgidx */\n  int iEndofDoclist;\n\n  /* The following are only used if the FTS5_SEGITER_REVERSE flag is set. */\n  int iRowidOffset;               /* Current entry in aRowidOffset[] */\n  int nRowidOffset;               /* Allocated size of aRowidOffset[] array */\n  int *aRowidOffset;              /* Array of offset to rowid fields */\n\n  Fts5DlidxIter *pDlidx;          /* If there is a doclist-index */\n\n  /* Variables populated based on current entry. */\n  Fts5Buffer term;                /* Current term */\n  i64 iRowid;                     /* Current rowid */\n  int nPos;                       /* Number of bytes in current position list */\n  u8 bDel;                        /* True if the delete flag is set */\n};\n\n/*\n** Argument is a pointer to an Fts5Data structure that contains a \n** leaf page.\n*/\n#define ASSERT_SZLEAF_OK(x) assert( \\\n    (x)->szLeaf==(x)->nn || (x)->szLeaf==fts5GetU16(&(x)->p[2]) \\\n)\n\n#define FTS5_SEGITER_ONETERM 0x01\n#define FTS5_SEGITER_REVERSE 0x02\n\n/* \n** Argument is a pointer to an Fts5Data structure that contains a leaf\n** page. This macro evaluates to true if the leaf contains no terms, or\n** false if it contains at least one term.\n*/\n#define fts5LeafIsTermless(x) ((x)->szLeaf >= (x)->nn)\n\n#define fts5LeafTermOff(x, i) (fts5GetU16(&(x)->p[(x)->szLeaf + (i)*2]))\n\n#define fts5LeafFirstRowidOff(x) (fts5GetU16((x)->p))\n\n/*\n** Object for iterating through the merged results of one or more segments,\n** visiting each term/rowid pair in the merged data.\n**\n** nSeg is always a power of two greater than or equal to the number of\n** segments that this object is merging data from. Both the aSeg[] and\n** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded\n** with zeroed objects - these are handled as if they were iterators opened\n** on empty segments.\n**\n** The results of comparing segments aSeg[N] and aSeg[N+1], where N is an\n** even number, is stored in aFirst[(nSeg+N)/2]. The \"result\" of the \n** comparison in this context is the index of the iterator that currently\n** points to the smaller term/rowid combination. Iterators at EOF are\n** considered to be greater than all other iterators.\n**\n** aFirst[1] contains the index in aSeg[] of the iterator that points to\n** the smallest key overall. aFirst[0] is unused. \n**\n** poslist:\n**   Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered.\n**   There is no way to tell if this is populated or not.\n*/\nstruct Fts5Iter {\n  Fts5IndexIter base;             /* Base class containing output vars */\n\n  Fts5Index *pIndex;              /* Index that owns this iterator */\n  Fts5Structure *pStruct;         /* Database structure for this iterator */\n  Fts5Buffer poslist;             /* Buffer containing current poslist */\n  Fts5Colset *pColset;            /* Restrict matches to these columns */\n\n  /* Invoked to set output variables. */\n  void (*xSetOutputs)(Fts5Iter*, Fts5SegIter*);\n\n  int nSeg;                       /* Size of aSeg[] array */\n  int bRev;                       /* True to iterate in reverse order */\n  u8 bSkipEmpty;                  /* True to skip deleted entries */\n\n  i64 iSwitchRowid;               /* Firstest rowid of other than aFirst[1] */\n  Fts5CResult *aFirst;            /* Current merge state (see above) */\n  Fts5SegIter aSeg[1];            /* Array of segment iterators */\n};\n\n\n/*\n** An instance of the following type is used to iterate through the contents\n** of a doclist-index record.\n**\n** pData:\n**   Record containing the doclist-index data.\n**\n** bEof:\n**   Set to true once iterator has reached EOF.\n**\n** iOff:\n**   Set to the current offset within record pData.\n*/\nstruct Fts5DlidxLvl {\n  Fts5Data *pData;              /* Data for current page of this level */\n  int iOff;                     /* Current offset into pData */\n  int bEof;                     /* At EOF already */\n  int iFirstOff;                /* Used by reverse iterators */\n\n  /* Output variables */\n  int iLeafPgno;                /* Page number of current leaf page */\n  i64 iRowid;                   /* First rowid on leaf iLeafPgno */\n};\nstruct Fts5DlidxIter {\n  int nLvl;\n  int iSegid;\n  Fts5DlidxLvl aLvl[1];\n};\n\nstatic void fts5PutU16(u8 *aOut, u16 iVal){\n  aOut[0] = (iVal>>8);\n  aOut[1] = (iVal&0xFF);\n}\n\nstatic u16 fts5GetU16(const u8 *aIn){\n  return ((u16)aIn[0] << 8) + aIn[1];\n} \n\n/*\n** Allocate and return a buffer at least nByte bytes in size.\n**\n** If an OOM error is encountered, return NULL and set the error code in\n** the Fts5Index handle passed as the first argument.\n*/\nstatic void *fts5IdxMalloc(Fts5Index *p, int nByte){\n  return sqlite3Fts5MallocZero(&p->rc, nByte);\n}\n\n/*\n** Compare the contents of the pLeft buffer with the pRight/nRight blob.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5BufferCompareBlob(\n  Fts5Buffer *pLeft,              /* Left hand side of comparison */\n  const u8 *pRight, int nRight    /* Right hand side of comparison */\n){\n  int nCmp = MIN(pLeft->n, nRight);\n  int res = memcmp(pLeft->p, pRight, nCmp);\n  return (res==0 ? (pLeft->n - nRight) : res);\n}\n#endif\n\n/*\n** Compare the contents of the two buffers using memcmp(). If one buffer\n** is a prefix of the other, it is considered the lesser.\n**\n** Return -ve if pLeft is smaller than pRight, 0 if they are equal or\n** +ve if pRight is smaller than pLeft. In other words:\n**\n**     res = *pLeft - *pRight\n*/\nstatic int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){\n  int nCmp = MIN(pLeft->n, pRight->n);\n  int res = memcmp(pLeft->p, pRight->p, nCmp);\n  return (res==0 ? (pLeft->n - pRight->n) : res);\n}\n\nstatic int fts5LeafFirstTermOff(Fts5Data *pLeaf){\n  int ret;\n  fts5GetVarint32(&pLeaf->p[pLeaf->szLeaf], ret);\n  return ret;\n}\n\n/*\n** Close the read-only blob handle, if it is open.\n*/\nstatic void fts5CloseReader(Fts5Index *p){\n  if( p->pReader ){\n    sqlite3_blob *pReader = p->pReader;\n    p->pReader = 0;\n    sqlite3_blob_close(pReader);\n  }\n}\n\n/*\n** Retrieve a record from the %_data table.\n**\n** If an error occurs, NULL is returned and an error left in the \n** Fts5Index object.\n*/\nstatic Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = 0;\n  if( p->rc==SQLITE_OK ){\n    int rc = SQLITE_OK;\n\n    if( p->pReader ){\n      /* This call may return SQLITE_ABORT if there has been a savepoint\n      ** rollback since it was last used. In this case a new blob handle\n      ** is required.  */\n      sqlite3_blob *pBlob = p->pReader;\n      p->pReader = 0;\n      rc = sqlite3_blob_reopen(pBlob, iRowid);\n      assert( p->pReader==0 );\n      p->pReader = pBlob;\n      if( rc!=SQLITE_OK ){\n        fts5CloseReader(p);\n      }\n      if( rc==SQLITE_ABORT ) rc = SQLITE_OK;\n    }\n\n    /* If the blob handle is not open at this point, open it and seek \n    ** to the requested entry.  */\n    if( p->pReader==0 && rc==SQLITE_OK ){\n      Fts5Config *pConfig = p->pConfig;\n      rc = sqlite3_blob_open(pConfig->db, \n          pConfig->zDb, p->zDataTbl, \"block\", iRowid, 0, &p->pReader\n      );\n    }\n\n    /* If either of the sqlite3_blob_open() or sqlite3_blob_reopen() calls\n    ** above returned SQLITE_ERROR, return SQLITE_CORRUPT_VTAB instead.\n    ** All the reasons those functions might return SQLITE_ERROR - missing\n    ** table, missing row, non-blob/text in block column - indicate \n    ** backing store corruption.  */\n    if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT;\n\n    if( rc==SQLITE_OK ){\n      u8 *aOut = 0;               /* Read blob data into this buffer */\n      int nByte = sqlite3_blob_bytes(p->pReader);\n      int nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;\n      pRet = (Fts5Data*)sqlite3_malloc(nAlloc);\n      if( pRet ){\n        pRet->nn = nByte;\n        aOut = pRet->p = (u8*)&pRet[1];\n      }else{\n        rc = SQLITE_NOMEM;\n      }\n\n      if( rc==SQLITE_OK ){\n        rc = sqlite3_blob_read(p->pReader, aOut, nByte, 0);\n      }\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pRet);\n        pRet = 0;\n      }else{\n        /* TODO1: Fix this */\n        pRet->szLeaf = fts5GetU16(&pRet->p[2]);\n      }\n    }\n    p->rc = rc;\n    p->nRead++;\n  }\n\n  assert( (pRet==0)==(p->rc!=SQLITE_OK) );\n  return pRet;\n}\n\n/*\n** Release a reference to data record returned by an earlier call to\n** fts5DataRead().\n*/\nstatic void fts5DataRelease(Fts5Data *pData){\n  sqlite3_free(pData);\n}\n\nstatic Fts5Data *fts5LeafRead(Fts5Index *p, i64 iRowid){\n  Fts5Data *pRet = fts5DataRead(p, iRowid);\n  if( pRet ){\n    if( pRet->szLeaf>pRet->nn ){\n      p->rc = FTS5_CORRUPT;\n      fts5DataRelease(pRet);\n      pRet = 0;\n    }\n  }\n  return pRet;\n}\n\nstatic int fts5IndexPrepareStmt(\n  Fts5Index *p,\n  sqlite3_stmt **ppStmt,\n  char *zSql\n){\n  if( p->rc==SQLITE_OK ){\n    if( zSql ){\n      p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,\n                                 SQLITE_PREPARE_PERSISTENT, ppStmt, 0);\n    }else{\n      p->rc = SQLITE_NOMEM;\n    }\n  }\n  sqlite3_free(zSql);\n  return p->rc;\n}\n\n\n/*\n** INSERT OR REPLACE a record into the %_data table.\n*/\nstatic void fts5DataWrite(Fts5Index *p, i64 iRowid, const u8 *pData, int nData){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pWriter, sqlite3_mprintf(\n          \"REPLACE INTO '%q'.'%q_data'(id, block) VALUES(?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n    if( p->rc ) return;\n  }\n\n  sqlite3_bind_int64(p->pWriter, 1, iRowid);\n  sqlite3_bind_blob(p->pWriter, 2, pData, nData, SQLITE_STATIC);\n  sqlite3_step(p->pWriter);\n  p->rc = sqlite3_reset(p->pWriter);\n}\n\n/*\n** Execute the following SQL:\n**\n**     DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast\n*/\nstatic void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){\n  if( p->rc!=SQLITE_OK ) return;\n\n  if( p->pDeleter==0 ){\n    int rc;\n    Fts5Config *pConfig = p->pConfig;\n    char *zSql = sqlite3_mprintf(\n        \"DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?\", \n          pConfig->zDb, pConfig->zName\n    );\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);\n      sqlite3_free(zSql);\n    }\n    if( rc!=SQLITE_OK ){\n      p->rc = rc;\n      return;\n    }\n  }\n\n  sqlite3_bind_int64(p->pDeleter, 1, iFirst);\n  sqlite3_bind_int64(p->pDeleter, 2, iLast);\n  sqlite3_step(p->pDeleter);\n  p->rc = sqlite3_reset(p->pDeleter);\n}\n\n/*\n** Remove all records associated with segment iSegid.\n*/\nstatic void fts5DataRemoveSegment(Fts5Index *p, int iSegid){\n  i64 iFirst = FTS5_SEGMENT_ROWID(iSegid, 0);\n  i64 iLast = FTS5_SEGMENT_ROWID(iSegid+1, 0)-1;\n  fts5DataDelete(p, iFirst, iLast);\n  if( p->pIdxDeleter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxDeleter, sqlite3_mprintf(\n          \"DELETE FROM '%q'.'%q_idx' WHERE segid=?\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  if( p->rc==SQLITE_OK ){\n    sqlite3_bind_int(p->pIdxDeleter, 1, iSegid);\n    sqlite3_step(p->pIdxDeleter);\n    p->rc = sqlite3_reset(p->pIdxDeleter);\n  }\n}\n\n/*\n** Release a reference to an Fts5Structure object returned by an earlier \n** call to fts5StructureRead() or fts5StructureDecode().\n*/\nstatic void fts5StructureRelease(Fts5Structure *pStruct){\n  if( pStruct && 0>=(--pStruct->nRef) ){\n    int i;\n    assert( pStruct->nRef==0 );\n    for(i=0; i<pStruct->nLevel; i++){\n      sqlite3_free(pStruct->aLevel[i].aSeg);\n    }\n    sqlite3_free(pStruct);\n  }\n}\n\nstatic void fts5StructureRef(Fts5Structure *pStruct){\n  pStruct->nRef++;\n}\n\n/*\n** Deserialize and return the structure record currently stored in serialized\n** form within buffer pData/nData.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated by one slot. This allows the structure contents\n** to be more easily edited.\n**\n** If an error occurs, *ppOut is set to NULL and an SQLite error code\n** returned. Otherwise, *ppOut is set to point to the new object and\n** SQLITE_OK returned.\n*/\nstatic int fts5StructureDecode(\n  const u8 *pData,                /* Buffer containing serialized structure */\n  int nData,                      /* Size of buffer pData in bytes */\n  int *piCookie,                  /* Configuration cookie value */\n  Fts5Structure **ppOut           /* OUT: Deserialized object */\n){\n  int rc = SQLITE_OK;\n  int i = 0;\n  int iLvl;\n  int nLevel = 0;\n  int nSegment = 0;\n  int nByte;                      /* Bytes of space to allocate at pRet */\n  Fts5Structure *pRet = 0;        /* Structure object to return */\n\n  /* Grab the cookie value */\n  if( piCookie ) *piCookie = sqlite3Fts5Get32(pData);\n  i = 4;\n\n  /* Read the total number of levels and segments from the start of the\n  ** structure record.  */\n  i += fts5GetVarint32(&pData[i], nLevel);\n  i += fts5GetVarint32(&pData[i], nSegment);\n  nByte = (\n      sizeof(Fts5Structure) +                    /* Main structure */\n      sizeof(Fts5StructureLevel) * (nLevel-1)    /* aLevel[] array */\n  );\n  pRet = (Fts5Structure*)sqlite3Fts5MallocZero(&rc, nByte);\n\n  if( pRet ){\n    pRet->nRef = 1;\n    pRet->nLevel = nLevel;\n    pRet->nSegment = nSegment;\n    i += sqlite3Fts5GetVarint(&pData[i], &pRet->nWriteCounter);\n\n    for(iLvl=0; rc==SQLITE_OK && iLvl<nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pRet->aLevel[iLvl];\n      int nTotal = 0;\n      int iSeg;\n\n      if( i>=nData ){\n        rc = FTS5_CORRUPT;\n      }else{\n        i += fts5GetVarint32(&pData[i], pLvl->nMerge);\n        i += fts5GetVarint32(&pData[i], nTotal);\n        assert( nTotal>=pLvl->nMerge );\n        pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc, \n            nTotal * sizeof(Fts5StructureSegment)\n        );\n      }\n\n      if( rc==SQLITE_OK ){\n        pLvl->nSeg = nTotal;\n        for(iSeg=0; iSeg<nTotal; iSeg++){\n          if( i>=nData ){\n            rc = FTS5_CORRUPT;\n            break;\n          }\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);\n          i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);\n        }\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  *ppOut = pRet;\n  return rc;\n}\n\n/*\n**\n*/\nstatic void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){\n  if( *pRc==SQLITE_OK ){\n    Fts5Structure *pStruct = *ppStruct;\n    int nLevel = pStruct->nLevel;\n    int nByte = (\n        sizeof(Fts5Structure) +                  /* Main structure */\n        sizeof(Fts5StructureLevel) * (nLevel+1)  /* aLevel[] array */\n    );\n\n    pStruct = sqlite3_realloc(pStruct, nByte);\n    if( pStruct ){\n      memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));\n      pStruct->nLevel++;\n      *ppStruct = pStruct;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\n/*\n** Extend level iLvl so that there is room for at least nExtra more\n** segments.\n*/\nstatic void fts5StructureExtendLevel(\n  int *pRc, \n  Fts5Structure *pStruct, \n  int iLvl, \n  int nExtra, \n  int bInsert\n){\n  if( *pRc==SQLITE_OK ){\n    Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n    Fts5StructureSegment *aNew;\n    int nByte;\n\n    nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);\n    aNew = sqlite3_realloc(pLvl->aSeg, nByte);\n    if( aNew ){\n      if( bInsert==0 ){\n        memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);\n      }else{\n        int nMove = pLvl->nSeg * sizeof(Fts5StructureSegment);\n        memmove(&aNew[nExtra], aNew, nMove);\n        memset(aNew, 0, sizeof(Fts5StructureSegment) * nExtra);\n      }\n      pLvl->aSeg = aNew;\n    }else{\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n}\n\nstatic Fts5Structure *fts5StructureReadUncached(Fts5Index *p){\n  Fts5Structure *pRet = 0;\n  Fts5Config *pConfig = p->pConfig;\n  int iCookie;                    /* Configuration cookie */\n  Fts5Data *pData;\n\n  pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);\n  if( p->rc==SQLITE_OK ){\n    /* TODO: Do we need this if the leaf-index is appended? Probably... */\n    memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);\n    p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);\n    if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){\n      p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);\n    }\n    fts5DataRelease(pData);\n    if( p->rc!=SQLITE_OK ){\n      fts5StructureRelease(pRet);\n      pRet = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic i64 fts5IndexDataVersion(Fts5Index *p){\n  i64 iVersion = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( p->pDataVersion==0 ){\n      p->rc = fts5IndexPrepareStmt(p, &p->pDataVersion, \n          sqlite3_mprintf(\"PRAGMA %Q.data_version\", p->pConfig->zDb)\n          );\n      if( p->rc ) return 0;\n    }\n\n    if( SQLITE_ROW==sqlite3_step(p->pDataVersion) ){\n      iVersion = sqlite3_column_int64(p->pDataVersion, 0);\n    }\n    p->rc = sqlite3_reset(p->pDataVersion);\n  }\n\n  return iVersion;\n}\n\n/*\n** Read, deserialize and return the structure record.\n**\n** The Fts5Structure.aLevel[] and each Fts5StructureLevel.aSeg[] array\n** are over-allocated as described for function fts5StructureDecode() \n** above.\n**\n** If an error occurs, NULL is returned and an error code left in the\n** Fts5Index handle. If an error has already occurred when this function\n** is called, it is a no-op.\n*/\nstatic Fts5Structure *fts5StructureRead(Fts5Index *p){\n\n  if( p->pStruct==0 ){\n    p->iStructVersion = fts5IndexDataVersion(p);\n    if( p->rc==SQLITE_OK ){\n      p->pStruct = fts5StructureReadUncached(p);\n    }\n  }\n\n#if 0\n  else{\n    Fts5Structure *pTest = fts5StructureReadUncached(p);\n    if( pTest ){\n      int i, j;\n      assert_nc( p->pStruct->nSegment==pTest->nSegment );\n      assert_nc( p->pStruct->nLevel==pTest->nLevel );\n      for(i=0; i<pTest->nLevel; i++){\n        assert_nc( p->pStruct->aLevel[i].nMerge==pTest->aLevel[i].nMerge );\n        assert_nc( p->pStruct->aLevel[i].nSeg==pTest->aLevel[i].nSeg );\n        for(j=0; j<pTest->aLevel[i].nSeg; j++){\n          Fts5StructureSegment *p1 = &pTest->aLevel[i].aSeg[j];\n          Fts5StructureSegment *p2 = &p->pStruct->aLevel[i].aSeg[j];\n          assert_nc( p1->iSegid==p2->iSegid );\n          assert_nc( p1->pgnoFirst==p2->pgnoFirst );\n          assert_nc( p1->pgnoLast==p2->pgnoLast );\n        }\n      }\n      fts5StructureRelease(pTest);\n    }\n  }\n#endif\n\n  if( p->rc!=SQLITE_OK ) return 0;\n  assert( p->iStructVersion!=0 );\n  assert( p->pStruct!=0 );\n  fts5StructureRef(p->pStruct);\n  return p->pStruct;\n}\n\nstatic void fts5StructureInvalidate(Fts5Index *p){\n  if( p->pStruct ){\n    fts5StructureRelease(p->pStruct);\n    p->pStruct = 0;\n  }\n}\n\n/*\n** Return the total number of segments in index structure pStruct. This\n** function is only ever used as part of assert() conditions.\n*/\n#ifdef SQLITE_DEBUG\nstatic int fts5StructureCountSegments(Fts5Structure *pStruct){\n  int nSegment = 0;               /* Total number of segments */\n  if( pStruct ){\n    int iLvl;                     /* Used to iterate through levels */\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      nSegment += pStruct->aLevel[iLvl].nSeg;\n    }\n  }\n\n  return nSegment;\n}\n#endif\n\n#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) {     \\\n  assert( (pBuf)->nSpace>=((pBuf)->n+nBlob) );             \\\n  memcpy(&(pBuf)->p[(pBuf)->n], pBlob, nBlob);             \\\n  (pBuf)->n += nBlob;                                      \\\n}\n\n#define fts5BufferSafeAppendVarint(pBuf, iVal) {                \\\n  (pBuf)->n += sqlite3Fts5PutVarint(&(pBuf)->p[(pBuf)->n], (iVal));  \\\n  assert( (pBuf)->nSpace>=(pBuf)->n );                          \\\n}\n\n\n/*\n** Serialize and store the \"structure\" record.\n**\n** If an error occurs, leave an error code in the Fts5Index object. If an\n** error has already occurred, this function is a no-op.\n*/\nstatic void fts5StructureWrite(Fts5Index *p, Fts5Structure *pStruct){\n  if( p->rc==SQLITE_OK ){\n    Fts5Buffer buf;               /* Buffer to serialize record into */\n    int iLvl;                     /* Used to iterate through levels */\n    int iCookie;                  /* Cookie value to store */\n\n    assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n    memset(&buf, 0, sizeof(Fts5Buffer));\n\n    /* Append the current configuration cookie */\n    iCookie = p->pConfig->iCookie;\n    if( iCookie<0 ) iCookie = 0;\n\n    if( 0==sqlite3Fts5BufferSize(&p->rc, &buf, 4+9+9+9) ){\n      sqlite3Fts5Put32(buf.p, iCookie);\n      buf.n = 4;\n      fts5BufferSafeAppendVarint(&buf, pStruct->nLevel);\n      fts5BufferSafeAppendVarint(&buf, pStruct->nSegment);\n      fts5BufferSafeAppendVarint(&buf, (i64)pStruct->nWriteCounter);\n    }\n\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      int iSeg;                     /* Used to iterate through segments */\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nMerge);\n      fts5BufferAppendVarint(&p->rc, &buf, pLvl->nSeg);\n      assert( pLvl->nMerge<=pLvl->nSeg );\n\n      for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].iSegid);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoFirst);\n        fts5BufferAppendVarint(&p->rc, &buf, pLvl->aSeg[iSeg].pgnoLast);\n      }\n    }\n\n    fts5DataWrite(p, FTS5_STRUCTURE_ROWID, buf.p, buf.n);\n    fts5BufferFree(&buf);\n  }\n}\n\n#if 0\nstatic void fts5DebugStructure(int*,Fts5Buffer*,Fts5Structure*);\nstatic void fts5PrintStructure(const char *zCaption, Fts5Structure *pStruct){\n  int rc = SQLITE_OK;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(buf));\n  fts5DebugStructure(&rc, &buf, pStruct);\n  fprintf(stdout, \"%s: %s\\n\", zCaption, buf.p);\n  fflush(stdout);\n  fts5BufferFree(&buf);\n}\n#else\n# define fts5PrintStructure(x,y)\n#endif\n\nstatic int fts5SegmentSize(Fts5StructureSegment *pSeg){\n  return 1 + pSeg->pgnoLast - pSeg->pgnoFirst;\n}\n\n/*\n** Return a copy of index structure pStruct. Except, promote as many \n** segments as possible to level iPromote. If an OOM occurs, NULL is \n** returned.\n*/\nstatic void fts5StructurePromoteTo(\n  Fts5Index *p,\n  int iPromote,\n  int szPromote,\n  Fts5Structure *pStruct\n){\n  int il, is;\n  Fts5StructureLevel *pOut = &pStruct->aLevel[iPromote];\n\n  if( pOut->nMerge==0 ){\n    for(il=iPromote+1; il<pStruct->nLevel; il++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[il];\n      if( pLvl->nMerge ) return;\n      for(is=pLvl->nSeg-1; is>=0; is--){\n        int sz = fts5SegmentSize(&pLvl->aSeg[is]);\n        if( sz>szPromote ) return;\n        fts5StructureExtendLevel(&p->rc, pStruct, iPromote, 1, 1);\n        if( p->rc ) return;\n        memcpy(pOut->aSeg, &pLvl->aSeg[is], sizeof(Fts5StructureSegment));\n        pOut->nSeg++;\n        pLvl->nSeg--;\n      }\n    }\n  }\n}\n\n/*\n** A new segment has just been written to level iLvl of index structure\n** pStruct. This function determines if any segments should be promoted\n** as a result. Segments are promoted in two scenarios:\n**\n**   a) If the segment just written is smaller than one or more segments\n**      within the previous populated level, it is promoted to the previous\n**      populated level.\n**\n**   b) If the segment just written is larger than the newest segment on\n**      the next populated level, then that segment, and any other adjacent\n**      segments that are also smaller than the one just written, are \n**      promoted. \n**\n** If one or more segments are promoted, the structure object is updated\n** to reflect this.\n*/\nstatic void fts5StructurePromote(\n  Fts5Index *p,                   /* FTS5 backend object */\n  int iLvl,                       /* Index level just updated */\n  Fts5Structure *pStruct          /* Index structure */\n){\n  if( p->rc==SQLITE_OK ){\n    int iTst;\n    int iPromote = -1;\n    int szPromote = 0;            /* Promote anything this size or smaller */\n    Fts5StructureSegment *pSeg;   /* Segment just written */\n    int szSeg;                    /* Size of segment just written */\n    int nSeg = pStruct->aLevel[iLvl].nSeg;\n\n    if( nSeg==0 ) return;\n    pSeg = &pStruct->aLevel[iLvl].aSeg[pStruct->aLevel[iLvl].nSeg-1];\n    szSeg = (1 + pSeg->pgnoLast - pSeg->pgnoFirst);\n\n    /* Check for condition (a) */\n    for(iTst=iLvl-1; iTst>=0 && pStruct->aLevel[iTst].nSeg==0; iTst--);\n    if( iTst>=0 ){\n      int i;\n      int szMax = 0;\n      Fts5StructureLevel *pTst = &pStruct->aLevel[iTst];\n      assert( pTst->nMerge==0 );\n      for(i=0; i<pTst->nSeg; i++){\n        int sz = pTst->aSeg[i].pgnoLast - pTst->aSeg[i].pgnoFirst + 1;\n        if( sz>szMax ) szMax = sz;\n      }\n      if( szMax>=szSeg ){\n        /* Condition (a) is true. Promote the newest segment on level \n        ** iLvl to level iTst.  */\n        iPromote = iTst;\n        szPromote = szMax;\n      }\n    }\n\n    /* If condition (a) is not met, assume (b) is true. StructurePromoteTo()\n    ** is a no-op if it is not.  */\n    if( iPromote<0 ){\n      iPromote = iLvl;\n      szPromote = szSeg;\n    }\n    fts5StructurePromoteTo(p, iPromote, szPromote, pStruct);\n  }\n}\n\n\n/*\n** Advance the iterator passed as the only argument. If the end of the \n** doclist-index page is reached, return non-zero.\n*/\nstatic int fts5DlidxLvlNext(Fts5DlidxLvl *pLvl){\n  Fts5Data *pData = pLvl->pData;\n\n  if( pLvl->iOff==0 ){\n    assert( pLvl->bEof==0 );\n    pLvl->iOff = 1;\n    pLvl->iOff += fts5GetVarint32(&pData->p[1], pLvl->iLeafPgno);\n    pLvl->iOff += fts5GetVarint(&pData->p[pLvl->iOff], (u64*)&pLvl->iRowid);\n    pLvl->iFirstOff = pLvl->iOff;\n  }else{\n    int iOff;\n    for(iOff=pLvl->iOff; iOff<pData->nn; iOff++){\n      if( pData->p[iOff] ) break; \n    }\n\n    if( iOff<pData->nn ){\n      i64 iVal;\n      pLvl->iLeafPgno += (iOff - pLvl->iOff) + 1;\n      iOff += fts5GetVarint(&pData->p[iOff], (u64*)&iVal);\n      pLvl->iRowid += iVal;\n      pLvl->iOff = iOff;\n    }else{\n      pLvl->bEof = 1;\n    }\n  }\n\n  return pLvl->bEof;\n}\n\n/*\n** Advance the iterator passed as the only argument.\n*/\nstatic int fts5DlidxIterNextR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlNext(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterNextR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ) fts5DlidxLvlNext(pLvl);\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterNext(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterNextR(p, pIter, 0);\n}\n\n/*\n** The iterator passed as the first argument has the following fields set\n** as follows. This function sets up the rest of the iterator so that it\n** points to the first rowid in the doclist-index.\n**\n**   pData:\n**     pointer to doclist-index record, \n**\n** When this function is called pIter->iLeafPgno is the page number the\n** doclist is associated with (the one featuring the term).\n*/\nstatic int fts5DlidxIterFirst(Fts5DlidxIter *pIter){\n  int i;\n  for(i=0; i<pIter->nLvl; i++){\n    fts5DlidxLvlNext(&pIter->aLvl[i]);\n  }\n  return pIter->aLvl[0].bEof;\n}\n\n\nstatic int fts5DlidxIterEof(Fts5Index *p, Fts5DlidxIter *pIter){\n  return p->rc!=SQLITE_OK || pIter->aLvl[0].bEof;\n}\n\nstatic void fts5DlidxIterLast(Fts5Index *p, Fts5DlidxIter *pIter){\n  int i;\n\n  /* Advance each level to the last entry on the last page */\n  for(i=pIter->nLvl-1; p->rc==SQLITE_OK && i>=0; i--){\n    Fts5DlidxLvl *pLvl = &pIter->aLvl[i];\n    while( fts5DlidxLvlNext(pLvl)==0 );\n    pLvl->bEof = 0;\n\n    if( i>0 ){\n      Fts5DlidxLvl *pChild = &pLvl[-1];\n      fts5DataRelease(pChild->pData);\n      memset(pChild, 0, sizeof(Fts5DlidxLvl));\n      pChild->pData = fts5DataRead(p, \n          FTS5_DLIDX_ROWID(pIter->iSegid, i-1, pLvl->iLeafPgno)\n      );\n    }\n  }\n}\n\n/*\n** Move the iterator passed as the only argument to the previous entry.\n*/\nstatic int fts5DlidxLvlPrev(Fts5DlidxLvl *pLvl){\n  int iOff = pLvl->iOff;\n\n  assert( pLvl->bEof==0 );\n  if( iOff<=pLvl->iFirstOff ){\n    pLvl->bEof = 1;\n  }else{\n    u8 *a = pLvl->pData->p;\n    i64 iVal;\n    int iLimit;\n    int ii;\n    int nZero = 0;\n\n    /* Currently iOff points to the first byte of a varint. This block \n    ** decrements iOff until it points to the first byte of the previous \n    ** varint. Taking care not to read any memory locations that occur\n    ** before the buffer in memory.  */\n    iLimit = (iOff>9 ? iOff-9 : 0);\n    for(iOff--; iOff>iLimit; iOff--){\n      if( (a[iOff-1] & 0x80)==0 ) break;\n    }\n\n    fts5GetVarint(&a[iOff], (u64*)&iVal);\n    pLvl->iRowid -= iVal;\n    pLvl->iLeafPgno--;\n\n    /* Skip backwards past any 0x00 varints. */\n    for(ii=iOff-1; ii>=pLvl->iFirstOff && a[ii]==0x00; ii--){\n      nZero++;\n    }\n    if( ii>=pLvl->iFirstOff && (a[ii] & 0x80) ){\n      /* The byte immediately before the last 0x00 byte has the 0x80 bit\n      ** set. So the last 0x00 is only a varint 0 if there are 8 more 0x80\n      ** bytes before a[ii]. */\n      int bZero = 0;              /* True if last 0x00 counts */\n      if( (ii-8)>=pLvl->iFirstOff ){\n        int j;\n        for(j=1; j<=8 && (a[ii-j] & 0x80); j++);\n        bZero = (j>8);\n      }\n      if( bZero==0 ) nZero--;\n    }\n    pLvl->iLeafPgno -= nZero;\n    pLvl->iOff = iOff - nZero;\n  }\n\n  return pLvl->bEof;\n}\n\nstatic int fts5DlidxIterPrevR(Fts5Index *p, Fts5DlidxIter *pIter, int iLvl){\n  Fts5DlidxLvl *pLvl = &pIter->aLvl[iLvl];\n\n  assert( iLvl<pIter->nLvl );\n  if( fts5DlidxLvlPrev(pLvl) ){\n    if( (iLvl+1) < pIter->nLvl ){\n      fts5DlidxIterPrevR(p, pIter, iLvl+1);\n      if( pLvl[1].bEof==0 ){\n        fts5DataRelease(pLvl->pData);\n        memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n        pLvl->pData = fts5DataRead(p, \n            FTS5_DLIDX_ROWID(pIter->iSegid, iLvl, pLvl[1].iLeafPgno)\n        );\n        if( pLvl->pData ){\n          while( fts5DlidxLvlNext(pLvl)==0 );\n          pLvl->bEof = 0;\n        }\n      }\n    }\n  }\n\n  return pIter->aLvl[0].bEof;\n}\nstatic int fts5DlidxIterPrev(Fts5Index *p, Fts5DlidxIter *pIter){\n  return fts5DlidxIterPrevR(p, pIter, 0);\n}\n\n/*\n** Free a doclist-index iterator object allocated by fts5DlidxIterInit().\n*/\nstatic void fts5DlidxIterFree(Fts5DlidxIter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nLvl; i++){\n      fts5DataRelease(pIter->aLvl[i].pData);\n    }\n    sqlite3_free(pIter);\n  }\n}\n\nstatic Fts5DlidxIter *fts5DlidxIterInit(\n  Fts5Index *p,                   /* Fts5 Backend to iterate within */\n  int bRev,                       /* True for ORDER BY ASC */\n  int iSegid,                     /* Segment id */\n  int iLeafPg                     /* Leaf page number to load dlidx for */\n){\n  Fts5DlidxIter *pIter = 0;\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);\n    Fts5DlidxIter *pNew;\n\n    pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);\n    if( pNew==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      i64 iRowid = FTS5_DLIDX_ROWID(iSegid, i, iLeafPg);\n      Fts5DlidxLvl *pLvl = &pNew->aLvl[i];\n      pIter = pNew;\n      memset(pLvl, 0, sizeof(Fts5DlidxLvl));\n      pLvl->pData = fts5DataRead(p, iRowid);\n      if( pLvl->pData && (pLvl->pData->p[0] & 0x0001)==0 ){\n        bDone = 1;\n      }\n      pIter->nLvl = i+1;\n    }\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iSegid = iSegid;\n    if( bRev==0 ){\n      fts5DlidxIterFirst(pIter);\n    }else{\n      fts5DlidxIterLast(p, pIter);\n    }\n  }\n\n  if( p->rc!=SQLITE_OK ){\n    fts5DlidxIterFree(pIter);\n    pIter = 0;\n  }\n\n  return pIter;\n}\n\nstatic i64 fts5DlidxIterRowid(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iRowid;\n}\nstatic int fts5DlidxIterPgno(Fts5DlidxIter *pIter){\n  return pIter->aLvl[0].iLeafPgno;\n}\n\n/*\n** Load the next leaf page into the segment iterator.\n*/\nstatic void fts5SegIterNextPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter              /* Iterator to advance to next page */\n){\n  Fts5Data *pLeaf;\n  Fts5StructureSegment *pSeg = pIter->pSeg;\n  fts5DataRelease(pIter->pLeaf);\n  pIter->iLeafPgno++;\n  if( pIter->pNextLeaf ){\n    pIter->pLeaf = pIter->pNextLeaf;\n    pIter->pNextLeaf = 0;\n  }else if( pIter->iLeafPgno<=pSeg->pgnoLast ){\n    pIter->pLeaf = fts5LeafRead(p, \n        FTS5_SEGMENT_ROWID(pSeg->iSegid, pIter->iLeafPgno)\n    );\n  }else{\n    pIter->pLeaf = 0;\n  }\n  pLeaf = pIter->pLeaf;\n\n  if( pLeaf ){\n    pIter->iPgidxOff = pLeaf->szLeaf;\n    if( fts5LeafIsTermless(pLeaf) ){\n      pIter->iEndofDoclist = pLeaf->nn+1;\n    }else{\n      pIter->iPgidxOff += fts5GetVarint32(&pLeaf->p[pIter->iPgidxOff],\n          pIter->iEndofDoclist\n      );\n    }\n  }\n}\n\n/*\n** Argument p points to a buffer containing a varint to be interpreted as a\n** position list size field. Read the varint and return the number of bytes\n** read. Before returning, set *pnSz to the number of bytes in the position\n** list, and *pbDel to true if the delete flag is set, or false otherwise.\n*/\nstatic int fts5GetPoslistSize(const u8 *p, int *pnSz, int *pbDel){\n  int nSz;\n  int n = 0;\n  fts5FastGetVarint32(p, n, nSz);\n  assert_nc( nSz>=0 );\n  *pnSz = nSz/2;\n  *pbDel = nSz & 0x0001;\n  return n;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of a\n** position-list size field. Read the value of the field and store it\n** in the following variables:\n**\n**   Fts5SegIter.nPos\n**   Fts5SegIter.bDel\n**\n** Leave Fts5SegIter.iLeafOffset pointing to the first byte of the \n** position list content (if any).\n*/\nstatic void fts5SegIterLoadNPos(Fts5Index *p, Fts5SegIter *pIter){\n  if( p->rc==SQLITE_OK ){\n    int iOff = pIter->iLeafOffset;  /* Offset to read at */\n    ASSERT_SZLEAF_OK(pIter->pLeaf);\n    if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n      int iEod = MIN(pIter->iEndofDoclist, pIter->pLeaf->szLeaf);\n      pIter->bDel = 0;\n      pIter->nPos = 1;\n      if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n        pIter->bDel = 1;\n        iOff++;\n        if( iOff<iEod && pIter->pLeaf->p[iOff]==0 ){\n          pIter->nPos = 1;\n          iOff++;\n        }else{\n          pIter->nPos = 0;\n        }\n      }\n    }else{\n      int nSz;\n      fts5FastGetVarint32(pIter->pLeaf->p, iOff, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n    pIter->iLeafOffset = iOff;\n  }\n}\n\nstatic void fts5SegIterLoadRowid(Fts5Index *p, Fts5SegIter *pIter){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  if( iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( pIter->pLeaf==0 ){\n      if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT;\n      return;\n    }\n    iOff = 4;\n    a = pIter->pLeaf->p;\n  }\n  iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n  pIter->iLeafOffset = iOff;\n}\n\n/*\n** Fts5SegIter.iLeafOffset currently points to the first byte of the \n** \"nSuffix\" field of a term. Function parameter nKeep contains the value\n** of the \"nPrefix\" field (if there was one - it is passed 0 if this is\n** the first term in the segment).\n**\n** This function populates:\n**\n**   Fts5SegIter.term\n**   Fts5SegIter.rowid\n**\n** accordingly and leaves (Fts5SegIter.iLeafOffset) set to the content of\n** the first position list. The position list belonging to document \n** (Fts5SegIter.iRowid).\n*/\nstatic void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){\n  u8 *a = pIter->pLeaf->p;        /* Buffer to read data from */\n  int iOff = pIter->iLeafOffset;  /* Offset to read at */\n  int nNew;                       /* Bytes of new data */\n\n  iOff += fts5GetVarint32(&a[iOff], nNew);\n  if( iOff+nNew>pIter->pLeaf->nn ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n  pIter->term.n = nKeep;\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n  iOff += nNew;\n  pIter->iTermLeafOffset = iOff;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n  pIter->iLeafOffset = iOff;\n\n  if( pIter->iPgidxOff>=pIter->pLeaf->nn ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    pIter->iPgidxOff += fts5GetVarint32(&a[pIter->iPgidxOff], nExtra);\n    pIter->iEndofDoclist += nExtra;\n  }\n\n  fts5SegIterLoadRowid(p, pIter);\n}\n\nstatic void fts5SegIterNext(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_Reverse(Fts5Index*, Fts5SegIter*, int*);\nstatic void fts5SegIterNext_None(Fts5Index*, Fts5SegIter*, int*);\n\nstatic void fts5SegIterSetNext(Fts5Index *p, Fts5SegIter *pIter){\n  if( pIter->flags & FTS5_SEGITER_REVERSE ){\n    pIter->xNext = fts5SegIterNext_Reverse;\n  }else if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    pIter->xNext = fts5SegIterNext_None;\n  }else{\n    pIter->xNext = fts5SegIterNext;\n  }\n}\n\n/*\n** Initialize the iterator object pIter to iterate through the entries in\n** segment pSeg. The iterator is left pointing to the first entry when \n** this function returns.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterInit(\n  Fts5Index *p,                   /* FTS index object */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  if( pSeg->pgnoFirst==0 ){\n    /* This happens if the segment is being used as an input to an incremental\n    ** merge and all data has already been \"trimmed\". See function\n    ** fts5TrimSegments() for details. In this case leave the iterator empty.\n    ** The caller will see the (pIter->pLeaf==0) and assume the iterator is\n    ** at EOF already. */\n    assert( pIter->pLeaf==0 );\n    return;\n  }\n\n  if( p->rc==SQLITE_OK ){\n    memset(pIter, 0, sizeof(*pIter));\n    fts5SegIterSetNext(p, pIter);\n    pIter->pSeg = pSeg;\n    pIter->iLeafPgno = pSeg->pgnoFirst-1;\n    fts5SegIterNextPage(p, pIter);\n  }\n\n  if( p->rc==SQLITE_OK ){\n    pIter->iLeafOffset = 4;\n    assert_nc( pIter->pLeaf->nn>4 );\n    assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );\n    pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;\n    fts5SegIterLoadTerm(p, pIter, 0);\n    fts5SegIterLoadNPos(p, pIter);\n  }\n}\n\n/*\n** This function is only ever called on iterators created by calls to\n** Fts5IndexQuery() with the FTS5INDEX_QUERY_DESC flag set.\n**\n** The iterator is in an unusual state when this function is called: the\n** Fts5SegIter.iLeafOffset variable is set to the offset of the start of\n** the position-list size field for the first relevant rowid on the page.\n** Fts5SegIter.rowid is set, but nPos and bDel are not.\n**\n** This function advances the iterator so that it points to the last \n** relevant rowid on the page and, if necessary, initializes the \n** aRowidOffset[] and iRowidOffset variables. At this point the iterator\n** is in its regular state - Fts5SegIter.iLeafOffset points to the first\n** byte of the position list content associated with said rowid.\n*/\nstatic void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){\n  int eDetail = p->pConfig->eDetail;\n  int n = pIter->pLeaf->szLeaf;\n  int i = pIter->iLeafOffset;\n  u8 *a = pIter->pLeaf->p;\n  int iRowidOffset = 0;\n\n  if( n>pIter->iEndofDoclist ){\n    n = pIter->iEndofDoclist;\n  }\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  while( 1 ){\n    i64 iDelta = 0;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      /* todo */\n      if( i<n && a[i]==0 ){\n        i++;\n        if( i<n && a[i]==0 ) i++;\n      }\n    }else{\n      int nPos;\n      int bDummy;\n      i += fts5GetPoslistSize(&a[i], &nPos, &bDummy);\n      i += nPos;\n    }\n    if( i>=n ) break;\n    i += fts5GetVarint(&a[i], (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* If necessary, grow the pIter->aRowidOffset[] array. */\n    if( iRowidOffset>=pIter->nRowidOffset ){\n      int nNew = pIter->nRowidOffset + 8;\n      int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));\n      if( aNew==0 ){\n        p->rc = SQLITE_NOMEM;\n        break;\n      }\n      pIter->aRowidOffset = aNew;\n      pIter->nRowidOffset = nNew;\n    }\n\n    pIter->aRowidOffset[iRowidOffset++] = pIter->iLeafOffset;\n    pIter->iLeafOffset = i;\n  }\n  pIter->iRowidOffset = iRowidOffset;\n  fts5SegIterLoadNPos(p, pIter);\n}\n\n/*\n**\n*/\nstatic void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n  while( p->rc==SQLITE_OK && pIter->iLeafPgno>pIter->iTermLeafPgno ){\n    Fts5Data *pNew;\n    pIter->iLeafPgno--;\n    pNew = fts5DataRead(p, FTS5_SEGMENT_ROWID(\n          pIter->pSeg->iSegid, pIter->iLeafPgno\n    ));\n    if( pNew ){\n      /* iTermLeafOffset may be equal to szLeaf if the term is the last\n      ** thing on the page - i.e. the first rowid is on the following page.\n      ** In this case leave pIter->pLeaf==0, this iterator is at EOF. */\n      if( pIter->iLeafPgno==pIter->iTermLeafPgno ){\n        assert( pIter->pLeaf==0 );\n        if( pIter->iTermLeafOffset<pNew->szLeaf ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = pIter->iTermLeafOffset;\n        }\n      }else{\n        int iRowidOff;\n        iRowidOff = fts5LeafFirstRowidOff(pNew);\n        if( iRowidOff ){\n          pIter->pLeaf = pNew;\n          pIter->iLeafOffset = iRowidOff;\n        }\n      }\n\n      if( pIter->pLeaf ){\n        u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset];\n        pIter->iLeafOffset += fts5GetVarint(a, (u64*)&pIter->iRowid);\n        break;\n      }else{\n        fts5DataRelease(pNew);\n      }\n    }\n  }\n\n  if( pIter->pLeaf ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n    fts5SegIterReverseInitPage(p, pIter);\n  }\n}\n\n/*\n** Return true if the iterator passed as the second argument currently\n** points to a delete marker. A delete marker is an entry with a 0 byte\n** position-list.\n*/\nstatic int fts5MultiIterIsEmpty(Fts5Index *p, Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n  return (p->rc==SQLITE_OK && pSeg->pLeaf && pSeg->nPos==0);\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used by reverse iterators.\n*/\nstatic void fts5SegIterNext_Reverse(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbUnused                   /* Unused */\n){\n  assert( pIter->flags & FTS5_SEGITER_REVERSE );\n  assert( pIter->pNextLeaf==0 );\n  UNUSED_PARAM(pbUnused);\n\n  if( pIter->iRowidOffset>0 ){\n    u8 *a = pIter->pLeaf->p;\n    int iOff;\n    i64 iDelta;\n\n    pIter->iRowidOffset--;\n    pIter->iLeafOffset = pIter->aRowidOffset[pIter->iRowidOffset];\n    fts5SegIterLoadNPos(p, pIter);\n    iOff = pIter->iLeafOffset;\n    if( p->pConfig->eDetail!=FTS5_DETAIL_NONE ){\n      iOff += pIter->nPos;\n    }\n    fts5GetVarint(&a[iOff], (u64*)&iDelta);\n    pIter->iRowid -= iDelta;\n  }else{\n    fts5SegIterReverseNewPage(p, pIter);\n  }\n}\n\n/*\n** Advance iterator pIter to the next entry.\n**\n** This version of fts5SegIterNext() is only used if detail=none and the\n** iterator is not a reverse direction iterator.\n*/\nstatic void fts5SegIterNext_None(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  int iOff;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (pIter->flags & FTS5_SEGITER_REVERSE)==0 );\n  assert( p->pConfig->eDetail==FTS5_DETAIL_NONE );\n\n  ASSERT_SZLEAF_OK(pIter->pLeaf);\n  iOff = pIter->iLeafOffset;\n\n  /* Next entry is on the next page */\n  if( pIter->pSeg && iOff>=pIter->pLeaf->szLeaf ){\n    fts5SegIterNextPage(p, pIter);\n    if( p->rc || pIter->pLeaf==0 ) return;\n    pIter->iRowid = 0;\n    iOff = 4;\n  }\n\n  if( iOff<pIter->iEndofDoclist ){\n    /* Next entry is on the current page */\n    i64 iDelta;\n    iOff += sqlite3Fts5GetVarint(&pIter->pLeaf->p[iOff], (u64*)&iDelta);\n    pIter->iLeafOffset = iOff;\n    pIter->iRowid += iDelta;\n  }else if( (pIter->flags & FTS5_SEGITER_ONETERM)==0 ){\n    if( pIter->pSeg ){\n      int nKeep = 0;\n      if( iOff!=fts5LeafFirstTermOff(pIter->pLeaf) ){\n        iOff += fts5GetVarint32(&pIter->pLeaf->p[iOff], nKeep);\n      }\n      pIter->iLeafOffset = iOff;\n      fts5SegIterLoadTerm(p, pIter, nKeep);\n    }else{\n      const u8 *pList = 0;\n      const char *zTerm = 0;\n      int nList;\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n      if( pList==0 ) goto next_none_eof;\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList;\n      sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n    }\n\n    if( pbNewTerm ) *pbNewTerm = 1;\n  }else{\n    goto next_none_eof;\n  }\n\n  fts5SegIterLoadNPos(p, pIter);\n\n  return;\n next_none_eof:\n  fts5DataRelease(pIter->pLeaf);\n  pIter->pLeaf = 0;\n}\n\n\n/*\n** Advance iterator pIter to the next entry. \n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. It \n** is not considered an error if the iterator reaches EOF. If an error has \n** already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterNext(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int *pbNewTerm                  /* OUT: Set for new term */\n){\n  Fts5Data *pLeaf = pIter->pLeaf;\n  int iOff;\n  int bNewTerm = 0;\n  int nKeep = 0;\n  u8 *a;\n  int n;\n\n  assert( pbNewTerm==0 || *pbNewTerm==0 );\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  /* Search for the end of the position list within the current page. */\n  a = pLeaf->p;\n  n = pLeaf->szLeaf;\n\n  ASSERT_SZLEAF_OK(pLeaf);\n  iOff = pIter->iLeafOffset + pIter->nPos;\n\n  if( iOff<n ){\n    /* The next entry is on the current page. */\n    assert_nc( iOff<=pIter->iEndofDoclist );\n    if( iOff>=pIter->iEndofDoclist ){\n      bNewTerm = 1;\n      if( iOff!=fts5LeafFirstTermOff(pLeaf) ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }else{\n      u64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], &iDelta);\n      pIter->iRowid += iDelta;\n      assert_nc( iDelta>0 );\n    }\n    pIter->iLeafOffset = iOff;\n\n  }else if( pIter->pSeg==0 ){\n    const u8 *pList = 0;\n    const char *zTerm = 0;\n    int nList = 0;\n    assert( (pIter->flags & FTS5_SEGITER_ONETERM) || pbNewTerm );\n    if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){\n      sqlite3Fts5HashScanNext(p->pHash);\n      sqlite3Fts5HashScanEntry(p->pHash, &zTerm, &pList, &nList);\n    }\n    if( pList==0 ){\n      fts5DataRelease(pIter->pLeaf);\n      pIter->pLeaf = 0;\n    }else{\n      pIter->pLeaf->p = (u8*)pList;\n      pIter->pLeaf->nn = nList;\n      pIter->pLeaf->szLeaf = nList;\n      pIter->iEndofDoclist = nList+1;\n      sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),\n          (u8*)zTerm);\n      pIter->iLeafOffset = fts5GetVarint(pList, (u64*)&pIter->iRowid);\n      *pbNewTerm = 1;\n    }\n  }else{\n    iOff = 0;\n    /* Next entry is not on the current page */\n    while( iOff==0 ){\n      fts5SegIterNextPage(p, pIter);\n      pLeaf = pIter->pLeaf;\n      if( pLeaf==0 ) break;\n      ASSERT_SZLEAF_OK(pLeaf);\n      if( (iOff = fts5LeafFirstRowidOff(pLeaf)) && iOff<pLeaf->szLeaf ){\n        iOff += sqlite3Fts5GetVarint(&pLeaf->p[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n\n        if( pLeaf->nn>pLeaf->szLeaf ){\n          pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n              &pLeaf->p[pLeaf->szLeaf], pIter->iEndofDoclist\n          );\n        }\n      }\n      else if( pLeaf->nn>pLeaf->szLeaf ){\n        pIter->iPgidxOff = pLeaf->szLeaf + fts5GetVarint32(\n            &pLeaf->p[pLeaf->szLeaf], iOff\n        );\n        pIter->iLeafOffset = iOff;\n        pIter->iEndofDoclist = iOff;\n        bNewTerm = 1;\n      }\n      assert_nc( iOff<pLeaf->szLeaf );\n      if( iOff>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n        return;\n      }\n    }\n  }\n\n  /* Check if the iterator is now at EOF. If so, return early. */\n  if( pIter->pLeaf ){\n    if( bNewTerm ){\n      if( pIter->flags & FTS5_SEGITER_ONETERM ){\n        fts5DataRelease(pIter->pLeaf);\n        pIter->pLeaf = 0;\n      }else{\n        fts5SegIterLoadTerm(p, pIter, nKeep);\n        fts5SegIterLoadNPos(p, pIter);\n        if( pbNewTerm ) *pbNewTerm = 1;\n      }\n    }else{\n      /* The following could be done by calling fts5SegIterLoadNPos(). But\n      ** this block is particularly performance critical, so equivalent\n      ** code is inlined. \n      **\n      ** Later: Switched back to fts5SegIterLoadNPos() because it supports\n      ** detail=none mode. Not ideal.\n      */\n      int nSz;\n      assert( p->rc==SQLITE_OK );\n      assert( pIter->iLeafOffset<=pIter->pLeaf->nn );\n      fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz);\n      pIter->bDel = (nSz & 0x0001);\n      pIter->nPos = nSz>>1;\n      assert_nc( pIter->nPos>=0 );\n    }\n  }\n}\n\n#define SWAPVAL(T, a, b) { T tmp; tmp=a; a=b; b=tmp; }\n\n#define fts5IndexSkipVarint(a, iOff) {            \\\n  int iEnd = iOff+9;                              \\\n  while( (a[iOff++] & 0x80) && iOff<iEnd );       \\\n}\n\n/*\n** Iterator pIter currently points to the first rowid in a doclist. This\n** function sets the iterator up so that iterates in reverse order through\n** the doclist.\n*/\nstatic void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  Fts5Data *pLast = 0;\n  int pgnoLast = 0;\n\n  if( pDlidx ){\n    int iSegid = pIter->pSeg->iSegid;\n    pgnoLast = fts5DlidxIterPgno(pDlidx);\n    pLast = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast));\n  }else{\n    Fts5Data *pLeaf = pIter->pLeaf;         /* Current leaf data */\n\n    /* Currently, Fts5SegIter.iLeafOffset points to the first byte of\n    ** position-list content for the current rowid. Back it up so that it\n    ** points to the start of the position-list size field. */\n    int iPoslist;\n    if( pIter->iTermLeafPgno==pIter->iLeafPgno ){\n      iPoslist = pIter->iTermLeafOffset;\n    }else{\n      iPoslist = 4;\n    }\n    fts5IndexSkipVarint(pLeaf->p, iPoslist);\n    pIter->iLeafOffset = iPoslist;\n\n    /* If this condition is true then the largest rowid for the current\n    ** term may not be stored on the current page. So search forward to\n    ** see where said rowid really is.  */\n    if( pIter->iEndofDoclist>=pLeaf->szLeaf ){\n      int pgno;\n      Fts5StructureSegment *pSeg = pIter->pSeg;\n\n      /* The last rowid in the doclist may not be on the current page. Search\n      ** forward to find the page containing the last rowid.  */\n      for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){\n        i64 iAbs = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno);\n        Fts5Data *pNew = fts5DataRead(p, iAbs);\n        if( pNew ){\n          int iRowid, bTermless;\n          iRowid = fts5LeafFirstRowidOff(pNew);\n          bTermless = fts5LeafIsTermless(pNew);\n          if( iRowid ){\n            SWAPVAL(Fts5Data*, pNew, pLast);\n            pgnoLast = pgno;\n          }\n          fts5DataRelease(pNew);\n          if( bTermless==0 ) break;\n        }\n      }\n    }\n  }\n\n  /* If pLast is NULL at this point, then the last rowid for this doclist\n  ** lies on the page currently indicated by the iterator. In this case \n  ** pIter->iLeafOffset is already set to point to the position-list size\n  ** field associated with the first relevant rowid on the page.\n  **\n  ** Or, if pLast is non-NULL, then it is the page that contains the last\n  ** rowid. In this case configure the iterator so that it points to the\n  ** first rowid on this page.\n  */\n  if( pLast ){\n    int iOff;\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = pLast;\n    pIter->iLeafPgno = pgnoLast;\n    iOff = fts5LeafFirstRowidOff(pLast);\n    iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid);\n    pIter->iLeafOffset = iOff;\n\n    if( fts5LeafIsTermless(pLast) ){\n      pIter->iEndofDoclist = pLast->nn+1;\n    }else{\n      pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast);\n    }\n\n  }\n\n  fts5SegIterReverseInitPage(p, pIter);\n}\n\n/*\n** Iterator pIter currently points to the first rowid of a doclist.\n** There is a doclist-index associated with the final term on the current \n** page. If the current term is the last term on the page, load the \n** doclist-index from disk and initialize an iterator at (pIter->pDlidx).\n*/\nstatic void fts5SegIterLoadDlidx(Fts5Index *p, Fts5SegIter *pIter){\n  int iSeg = pIter->pSeg->iSegid;\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx==0 );\n\n  /* Check if the current doclist ends on this page. If it does, return\n  ** early without loading the doclist-index (as it belongs to a different\n  ** term. */\n  if( pIter->iTermLeafPgno==pIter->iLeafPgno \n   && pIter->iEndofDoclist<pLeaf->szLeaf \n  ){\n    return;\n  }\n\n  pIter->pDlidx = fts5DlidxIterInit(p, bRev, iSeg, pIter->iTermLeafPgno);\n}\n\n/*\n** The iterator object passed as the second argument currently contains\n** no valid values except for the Fts5SegIter.pLeaf member variable. This\n** function searches the leaf page for a term matching (pTerm/nTerm).\n**\n** If the specified term is found on the page, then the iterator is left\n** pointing to it. If argument bGe is zero and the term is not found,\n** the iterator is left pointing at EOF.\n**\n** If bGe is non-zero and the specified term is not found, then the\n** iterator is left pointing to the smallest term in the segment that\n** is larger than the specified term, even if this term is not on the\n** current page.\n*/\nstatic void fts5LeafSeek(\n  Fts5Index *p,                   /* Leave any error code here */\n  int bGe,                        /* True for a >= search */\n  Fts5SegIter *pIter,             /* Iterator to seek */\n  const u8 *pTerm, int nTerm      /* Term to search for */\n){\n  int iOff;\n  const u8 *a = pIter->pLeaf->p;\n  int szLeaf = pIter->pLeaf->szLeaf;\n  int n = pIter->pLeaf->nn;\n\n  int nMatch = 0;\n  int nKeep = 0;\n  int nNew = 0;\n  int iTermOff;\n  int iPgidx;                     /* Current offset in pgidx */\n  int bEndOfPage = 0;\n\n  assert( p->rc==SQLITE_OK );\n\n  iPgidx = szLeaf;\n  iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff);\n  iOff = iTermOff;\n  if( iOff>n ){\n    p->rc = FTS5_CORRUPT;\n    return;\n  }\n\n  while( 1 ){\n\n    /* Figure out how many new bytes are in this term */\n    fts5FastGetVarint32(a, iOff, nNew);\n    if( nKeep<nMatch ){\n      goto search_failed;\n    }\n\n    assert( nKeep>=nMatch );\n    if( nKeep==nMatch ){\n      int nCmp;\n      int i;\n      nCmp = MIN(nNew, nTerm-nMatch);\n      for(i=0; i<nCmp; i++){\n        if( a[iOff+i]!=pTerm[nMatch+i] ) break;\n      }\n      nMatch += i;\n\n      if( nTerm==nMatch ){\n        if( i==nNew ){\n          goto search_success;\n        }else{\n          goto search_failed;\n        }\n      }else if( i<nNew && a[iOff+i]>pTerm[nMatch] ){\n        goto search_failed;\n      }\n    }\n\n    if( iPgidx>=n ){\n      bEndOfPage = 1;\n      break;\n    }\n\n    iPgidx += fts5GetVarint32(&a[iPgidx], nKeep);\n    iTermOff += nKeep;\n    iOff = iTermOff;\n\n    if( iOff>=n ){\n      p->rc = FTS5_CORRUPT;\n      return;\n    }\n\n    /* Read the nKeep field of the next term. */\n    fts5FastGetVarint32(a, iOff, nKeep);\n  }\n\n search_failed:\n  if( bGe==0 ){\n    fts5DataRelease(pIter->pLeaf);\n    pIter->pLeaf = 0;\n    return;\n  }else if( bEndOfPage ){\n    do {\n      fts5SegIterNextPage(p, pIter);\n      if( pIter->pLeaf==0 ) return;\n      a = pIter->pLeaf->p;\n      if( fts5LeafIsTermless(pIter->pLeaf)==0 ){\n        iPgidx = pIter->pLeaf->szLeaf;\n        iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);\n        if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){\n          p->rc = FTS5_CORRUPT;\n        }else{\n          nKeep = 0;\n          iTermOff = iOff;\n          n = pIter->pLeaf->nn;\n          iOff += fts5GetVarint32(&a[iOff], nNew);\n          break;\n        }\n      }\n    }while( 1 );\n  }\n\n search_success:\n\n  pIter->iLeafOffset = iOff + nNew;\n  pIter->iTermLeafOffset = pIter->iLeafOffset;\n  pIter->iTermLeafPgno = pIter->iLeafPgno;\n\n  fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);\n  fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);\n\n  if( iPgidx>=n ){\n    pIter->iEndofDoclist = pIter->pLeaf->nn+1;\n  }else{\n    int nExtra;\n    iPgidx += fts5GetVarint32(&a[iPgidx], nExtra);\n    pIter->iEndofDoclist = iTermOff + nExtra;\n  }\n  pIter->iPgidxOff = iPgidx;\n\n  fts5SegIterLoadRowid(p, pIter);\n  fts5SegIterLoadNPos(p, pIter);\n}\n\nstatic sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){\n  if( p->pIdxSelect==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf(\n          \"SELECT pgno FROM '%q'.'%q_idx' WHERE \"\n          \"segid=? AND term<=? ORDER BY term DESC LIMIT 1\",\n          pConfig->zDb, pConfig->zName\n    ));\n  }\n  return p->pIdxSelect;\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within segment\n** pSeg. If there is no such term in the index, the iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterSeekInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5StructureSegment *pSeg,     /* Description of segment */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  int iPg = 1;\n  int bGe = (flags & FTS5INDEX_QUERY_SCAN);\n  int bDlidx = 0;                 /* True if there is a doclist-index */\n  sqlite3_stmt *pIdxSelect = 0;\n\n  assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 );\n  assert( pTerm && nTerm );\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->pSeg = pSeg;\n\n  /* This block sets stack variable iPg to the leaf page number that may\n  ** contain term (pTerm/nTerm), if it is present in the segment. */\n  pIdxSelect = fts5IdxSelectStmt(p);\n  if( p->rc ) return;\n  sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid);\n  sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC);\n  if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){\n    i64 val = sqlite3_column_int(pIdxSelect, 0);\n    iPg = (int)(val>>1);\n    bDlidx = (val & 0x0001);\n  }\n  p->rc = sqlite3_reset(pIdxSelect);\n\n  if( iPg<pSeg->pgnoFirst ){\n    iPg = pSeg->pgnoFirst;\n    bDlidx = 0;\n  }\n\n  pIter->iLeafPgno = iPg - 1;\n  fts5SegIterNextPage(p, pIter);\n\n  if( pIter->pLeaf ){\n    fts5LeafSeek(p, bGe, pIter, pTerm, nTerm);\n  }\n\n  if( p->rc==SQLITE_OK && bGe==0 ){\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    if( pIter->pLeaf ){\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n      }\n      if( bDlidx ){\n        fts5SegIterLoadDlidx(p, pIter);\n      }\n      if( flags & FTS5INDEX_QUERY_DESC ){\n        fts5SegIterReverse(p, pIter);\n      }\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n\n  /* Either:\n  **\n  **   1) an error has occurred, or\n  **   2) the iterator points to EOF, or\n  **   3) the iterator points to an entry with term (pTerm/nTerm), or\n  **   4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points\n  **      to an entry with a term greater than or equal to (pTerm/nTerm).\n  */\n  assert( p->rc!=SQLITE_OK                                          /* 1 */\n   || pIter->pLeaf==0                                               /* 2 */\n   || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0          /* 3 */\n   || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0)  /* 4 */\n  );\n}\n\n/*\n** Initialize the object pIter to point to term pTerm/nTerm within the\n** in-memory hash table. If there is no such term in the hash-table, the \n** iterator is set to EOF.\n**\n** If an error occurs, Fts5Index.rc is set to an appropriate error code. If \n** an error has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5SegIterHashInit(\n  Fts5Index *p,                   /* FTS5 backend */\n  const u8 *pTerm, int nTerm,     /* Term to seek to */\n  int flags,                      /* Mask of FTS5INDEX_XXX flags */\n  Fts5SegIter *pIter              /* Object to populate */\n){\n  const u8 *pList = 0;\n  int nList = 0;\n  const u8 *z = 0;\n  int n = 0;\n\n  assert( p->pHash );\n  assert( p->rc==SQLITE_OK );\n\n  if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){\n    p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);\n    sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);\n    n = (z ? (int)strlen((const char*)z) : 0);\n  }else{\n    pIter->flags |= FTS5_SEGITER_ONETERM;\n    sqlite3Fts5HashQuery(p->pHash, (const char*)pTerm, nTerm, &pList, &nList);\n    z = pTerm;\n    n = nTerm;\n  }\n\n  if( pList ){\n    Fts5Data *pLeaf;\n    sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);\n    pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));\n    if( pLeaf==0 ) return;\n    pLeaf->p = (u8*)pList;\n    pLeaf->nn = pLeaf->szLeaf = nList;\n    pIter->pLeaf = pLeaf;\n    pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);\n    pIter->iEndofDoclist = pLeaf->nn;\n\n    if( flags & FTS5INDEX_QUERY_DESC ){\n      pIter->flags |= FTS5_SEGITER_REVERSE;\n      fts5SegIterReverseInitPage(p, pIter);\n    }else{\n      fts5SegIterLoadNPos(p, pIter);\n    }\n  }\n\n  fts5SegIterSetNext(p, pIter);\n}\n\n/*\n** Zero the iterator passed as the only argument.\n*/\nstatic void fts5SegIterClear(Fts5SegIter *pIter){\n  fts5BufferFree(&pIter->term);\n  fts5DataRelease(pIter->pLeaf);\n  fts5DataRelease(pIter->pNextLeaf);\n  fts5DlidxIterFree(pIter->pDlidx);\n  sqlite3_free(pIter->aRowidOffset);\n  memset(pIter, 0, sizeof(Fts5SegIter));\n}\n\n#ifdef SQLITE_DEBUG\n\n/*\n** This function is used as part of the big assert() procedure implemented by\n** fts5AssertMultiIterSetup(). It ensures that the result currently stored\n** in *pRes is the correct result of comparing the current positions of the\n** two iterators.\n*/\nstatic void fts5AssertComparisonResult(\n  Fts5Iter *pIter, \n  Fts5SegIter *p1,\n  Fts5SegIter *p2,\n  Fts5CResult *pRes\n){\n  int i1 = p1 - pIter->aSeg;\n  int i2 = p2 - pIter->aSeg;\n\n  if( p1->pLeaf || p2->pLeaf ){\n    if( p1->pLeaf==0 ){\n      assert( pRes->iFirst==i2 );\n    }else if( p2->pLeaf==0 ){\n      assert( pRes->iFirst==i1 );\n    }else{\n      int nMin = MIN(p1->term.n, p2->term.n);\n      int res = memcmp(p1->term.p, p2->term.p, nMin);\n      if( res==0 ) res = p1->term.n - p2->term.n;\n\n      if( res==0 ){\n        assert( pRes->bTermEq==1 );\n        assert( p1->iRowid!=p2->iRowid );\n        res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : 1;\n      }else{\n        assert( pRes->bTermEq==0 );\n      }\n\n      if( res<0 ){\n        assert( pRes->iFirst==i1 );\n      }else{\n        assert( pRes->iFirst==i2 );\n      }\n    }\n  }\n}\n\n/*\n** This function is a no-op unless SQLITE_DEBUG is defined when this module\n** is compiled. In that case, this function is essentially an assert() \n** statement used to verify that the contents of the pIter->aFirst[] array\n** are correct.\n*/\nstatic void fts5AssertMultiIterSetup(Fts5Index *p, Fts5Iter *pIter){\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pFirst = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int i;\n\n    assert( (pFirst->pLeaf==0)==pIter->base.bEof );\n\n    /* Check that pIter->iSwitchRowid is set correctly. */\n    for(i=0; i<pIter->nSeg; i++){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      assert( p1==pFirst \n           || p1->pLeaf==0 \n           || fts5BufferCompare(&pFirst->term, &p1->term) \n           || p1->iRowid==pIter->iSwitchRowid\n           || (p1->iRowid<pIter->iSwitchRowid)==pIter->bRev\n      );\n    }\n\n    for(i=0; i<pIter->nSeg; i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[i];\n      Fts5SegIter *p2 = &pIter->aSeg[i+1];\n      Fts5CResult *pRes = &pIter->aFirst[(pIter->nSeg + i) / 2];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n\n    for(i=1; i<(pIter->nSeg / 2); i+=2){\n      Fts5SegIter *p1 = &pIter->aSeg[ pIter->aFirst[i*2].iFirst ];\n      Fts5SegIter *p2 = &pIter->aSeg[ pIter->aFirst[i*2+1].iFirst ];\n      Fts5CResult *pRes = &pIter->aFirst[i];\n      fts5AssertComparisonResult(pIter, p1, p2, pRes);\n    }\n  }\n}\n#else\n# define fts5AssertMultiIterSetup(x,y)\n#endif\n\n/*\n** Do the comparison necessary to populate pIter->aFirst[iOut].\n**\n** If the returned value is non-zero, then it is the index of an entry\n** in the pIter->aSeg[] array that is (a) not at EOF, and (b) pointing\n** to a key that is a duplicate of another, higher priority, \n** segment-iterator in the pSeg->aSeg[] array.\n*/\nstatic int fts5MultiIterDoCompare(Fts5Iter *pIter, int iOut){\n  int i1;                         /* Index of left-hand Fts5SegIter */\n  int i2;                         /* Index of right-hand Fts5SegIter */\n  int iRes;\n  Fts5SegIter *p1;                /* Left-hand Fts5SegIter */\n  Fts5SegIter *p2;                /* Right-hand Fts5SegIter */\n  Fts5CResult *pRes = &pIter->aFirst[iOut];\n\n  assert( iOut<pIter->nSeg && iOut>0 );\n  assert( pIter->bRev==0 || pIter->bRev==1 );\n\n  if( iOut>=(pIter->nSeg/2) ){\n    i1 = (iOut - pIter->nSeg/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pIter->aFirst[iOut*2].iFirst;\n    i2 = pIter->aFirst[iOut*2+1].iFirst;\n  }\n  p1 = &pIter->aSeg[i1];\n  p2 = &pIter->aSeg[i2];\n\n  pRes->bTermEq = 0;\n  if( p1->pLeaf==0 ){           /* If p1 is at EOF */\n    iRes = i2;\n  }else if( p2->pLeaf==0 ){     /* If p2 is at EOF */\n    iRes = i1;\n  }else{\n    int res = fts5BufferCompare(&p1->term, &p2->term);\n    if( res==0 ){\n      assert( i2>i1 );\n      assert( i2!=0 );\n      pRes->bTermEq = 1;\n      if( p1->iRowid==p2->iRowid ){\n        p1->bDel = p2->bDel;\n        return i2;\n      }\n      res = ((p1->iRowid > p2->iRowid)==pIter->bRev) ? -1 : +1;\n    }\n    assert( res!=0 );\n    if( res<0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pRes->iFirst = (u16)iRes;\n  return 0;\n}\n\n/*\n** Move the seg-iter so that it points to the first rowid on page iLeafPgno.\n** It is an error if leaf iLeafPgno does not exist or contains no rowids.\n*/\nstatic void fts5SegIterGotoPage(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  int iLeafPgno\n){\n  assert( iLeafPgno>pIter->iLeafPgno );\n\n  if( iLeafPgno>pIter->pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }else{\n    fts5DataRelease(pIter->pNextLeaf);\n    pIter->pNextLeaf = 0;\n    pIter->iLeafPgno = iLeafPgno-1;\n    fts5SegIterNextPage(p, pIter);\n    assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno );\n\n    if( p->rc==SQLITE_OK ){\n      int iOff;\n      u8 *a = pIter->pLeaf->p;\n      int n = pIter->pLeaf->szLeaf;\n\n      iOff = fts5LeafFirstRowidOff(pIter->pLeaf);\n      if( iOff<4 || iOff>=n ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint(&a[iOff], (u64*)&pIter->iRowid);\n        pIter->iLeafOffset = iOff;\n        fts5SegIterLoadNPos(p, pIter);\n      }\n    }\n  }\n}\n\n/*\n** Advance the iterator passed as the second argument until it is at or \n** past rowid iFrom. Regardless of the value of iFrom, the iterator is\n** always advanced at least once.\n*/\nstatic void fts5SegIterNextFrom(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegIter *pIter,             /* Iterator to advance */\n  i64 iMatch                      /* Advance iterator at least this far */\n){\n  int bRev = (pIter->flags & FTS5_SEGITER_REVERSE);\n  Fts5DlidxIter *pDlidx = pIter->pDlidx;\n  int iLeafPgno = pIter->iLeafPgno;\n  int bMove = 1;\n\n  assert( pIter->flags & FTS5_SEGITER_ONETERM );\n  assert( pIter->pDlidx );\n  assert( pIter->pLeaf );\n\n  if( bRev==0 ){\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch>fts5DlidxIterRowid(pDlidx) ){\n      iLeafPgno = fts5DlidxIterPgno(pDlidx);\n      fts5DlidxIterNext(p, pDlidx);\n    }\n    assert_nc( iLeafPgno>=pIter->iLeafPgno || p->rc );\n    if( iLeafPgno>pIter->iLeafPgno ){\n      fts5SegIterGotoPage(p, pIter, iLeafPgno);\n      bMove = 0;\n    }\n  }else{\n    assert( pIter->pNextLeaf==0 );\n    assert( iMatch<pIter->iRowid );\n    while( !fts5DlidxIterEof(p, pDlidx) && iMatch<fts5DlidxIterRowid(pDlidx) ){\n      fts5DlidxIterPrev(p, pDlidx);\n    }\n    iLeafPgno = fts5DlidxIterPgno(pDlidx);\n\n    assert( fts5DlidxIterEof(p, pDlidx) || iLeafPgno<=pIter->iLeafPgno );\n\n    if( iLeafPgno<pIter->iLeafPgno ){\n      pIter->iLeafPgno = iLeafPgno+1;\n      fts5SegIterReverseNewPage(p, pIter);\n      bMove = 0;\n    }\n  }\n\n  do{\n    if( bMove && p->rc==SQLITE_OK ) pIter->xNext(p, pIter, 0);\n    if( pIter->pLeaf==0 ) break;\n    if( bRev==0 && pIter->iRowid>=iMatch ) break;\n    if( bRev!=0 && pIter->iRowid<=iMatch ) break;\n    bMove = 1;\n  }while( p->rc==SQLITE_OK );\n}\n\n\n/*\n** Free the iterator object passed as the second argument.\n*/\nstatic void fts5MultiIterFree(Fts5Iter *pIter){\n  if( pIter ){\n    int i;\n    for(i=0; i<pIter->nSeg; i++){\n      fts5SegIterClear(&pIter->aSeg[i]);\n    }\n    fts5StructureRelease(pIter->pStruct);\n    fts5BufferFree(&pIter->poslist);\n    sqlite3_free(pIter);\n  }\n}\n\nstatic void fts5MultiIterAdvanced(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  int iMinset                     /* Minimum entry in aFirst[] to set */\n){\n  int i;\n  for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){\n    int iEq;\n    if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){\n      Fts5SegIter *pSeg = &pIter->aSeg[iEq];\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, 0);\n      i = pIter->nSeg + iEq;\n    }\n  }\n}\n\n/*\n** Sub-iterator iChanged of iterator pIter has just been advanced. It still\n** points to the same term though - just a different rowid. This function\n** attempts to update the contents of the pIter->aFirst[] accordingly.\n** If it does so successfully, 0 is returned. Otherwise 1.\n**\n** If non-zero is returned, the caller should call fts5MultiIterAdvanced()\n** on the iterator instead. That function does the same as this one, except\n** that it deals with more complicated cases as well.\n*/ \nstatic int fts5MultiIterAdvanceRowid(\n  Fts5Iter *pIter,                /* Iterator to update aFirst[] array for */\n  int iChanged,                   /* Index of sub-iterator just advanced */\n  Fts5SegIter **ppFirst\n){\n  Fts5SegIter *pNew = &pIter->aSeg[iChanged];\n\n  if( pNew->iRowid==pIter->iSwitchRowid\n   || (pNew->iRowid<pIter->iSwitchRowid)==pIter->bRev\n  ){\n    int i;\n    Fts5SegIter *pOther = &pIter->aSeg[iChanged ^ 0x0001];\n    pIter->iSwitchRowid = pIter->bRev ? SMALLEST_INT64 : LARGEST_INT64;\n    for(i=(pIter->nSeg+iChanged)/2; 1; i=i/2){\n      Fts5CResult *pRes = &pIter->aFirst[i];\n\n      assert( pNew->pLeaf );\n      assert( pRes->bTermEq==0 || pOther->pLeaf );\n\n      if( pRes->bTermEq ){\n        if( pNew->iRowid==pOther->iRowid ){\n          return 1;\n        }else if( (pOther->iRowid>pNew->iRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n          pNew = pOther;\n        }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){\n          pIter->iSwitchRowid = pOther->iRowid;\n        }\n      }\n      pRes->iFirst = (u16)(pNew - pIter->aSeg);\n      if( i==1 ) break;\n\n      pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];\n    }\n  }\n\n  *ppFirst = pNew;\n  return 0;\n}\n\n/*\n** Set the pIter->bEof variable based on the state of the sub-iterators.\n*/\nstatic void fts5MultiIterSetEof(Fts5Iter *pIter){\n  Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  pIter->base.bEof = pSeg->pLeaf==0;\n  pIter->iSwitchRowid = pSeg->iRowid;\n}\n\n/*\n** Move the iterator to the next entry. \n**\n** If an error occurs, an error code is left in Fts5Index.rc. It is not \n** considered an error if the iterator reaches EOF, or if it is already at \n** EOF when this function is called.\n*/\nstatic void fts5MultiIterNext(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int bFrom,                      /* True if argument iFrom is valid */\n  i64 iFrom                       /* Advance at least as far as this */\n){\n  int bUseFrom = bFrom;\n  assert( pIter->base.bEof==0 );\n  while( p->rc==SQLITE_OK ){\n    int iFirst = pIter->aFirst[1].iFirst;\n    int bNewTerm = 0;\n    Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n    assert( p->rc==SQLITE_OK );\n    if( bUseFrom && pSeg->pDlidx ){\n      fts5SegIterNextFrom(p, pSeg, iFrom);\n    }else{\n      pSeg->xNext(p, pSeg, &bNewTerm);\n    }\n\n    if( pSeg->pLeaf==0 || bNewTerm \n     || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n    ){\n      fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n      fts5MultiIterSetEof(pIter);\n      pSeg = &pIter->aSeg[pIter->aFirst[1].iFirst];\n      if( pSeg->pLeaf==0 ) return;\n    }\n\n    fts5AssertMultiIterSetup(p, pIter);\n    assert( pSeg==&pIter->aSeg[pIter->aFirst[1].iFirst] && pSeg->pLeaf );\n    if( pIter->bSkipEmpty==0 || pSeg->nPos ){\n      pIter->xSetOutputs(pIter, pSeg);\n      return;\n    }\n    bUseFrom = 0;\n  }\n}\n\nstatic void fts5MultiIterNext2(\n  Fts5Index *p, \n  Fts5Iter *pIter,\n  int *pbNewTerm                  /* OUT: True if *might* be new term */\n){\n  assert( pIter->bSkipEmpty );\n  if( p->rc==SQLITE_OK ){\n    *pbNewTerm = 0;\n    do{\n      int iFirst = pIter->aFirst[1].iFirst;\n      Fts5SegIter *pSeg = &pIter->aSeg[iFirst];\n      int bNewTerm = 0;\n\n      assert( p->rc==SQLITE_OK );\n      pSeg->xNext(p, pSeg, &bNewTerm);\n      if( pSeg->pLeaf==0 || bNewTerm \n       || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg)\n      ){\n        fts5MultiIterAdvanced(p, pIter, iFirst, 1);\n        fts5MultiIterSetEof(pIter);\n        *pbNewTerm = 1;\n      }\n      fts5AssertMultiIterSetup(p, pIter);\n\n    }while( fts5MultiIterIsEmpty(p, pIter) );\n  }\n}\n\nstatic void fts5IterSetOutputs_Noop(Fts5Iter *pUnused1, Fts5SegIter *pUnused2){\n  UNUSED_PARAM2(pUnused1, pUnused2);\n}\n\nstatic Fts5Iter *fts5MultiIterAlloc(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  int nSeg\n){\n  Fts5Iter *pNew;\n  int nSlot;                      /* Power of two >= nSeg */\n\n  for(nSlot=2; nSlot<nSeg; nSlot=nSlot*2);\n  pNew = fts5IdxMalloc(p, \n      sizeof(Fts5Iter) +                  /* pNew */\n      sizeof(Fts5SegIter) * (nSlot-1) +   /* pNew->aSeg[] */\n      sizeof(Fts5CResult) * nSlot         /* pNew->aFirst[] */\n  );\n  if( pNew ){\n    pNew->nSeg = nSlot;\n    pNew->aFirst = (Fts5CResult*)&pNew->aSeg[nSlot];\n    pNew->pIndex = p;\n    pNew->xSetOutputs = fts5IterSetOutputs_Noop;\n  }\n  return pNew;\n}\n\nstatic void fts5PoslistCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    fts5BufferSafeAppendBlob((Fts5Buffer*)pContext, pChunk, nChunk);\n  }\n}\n\ntypedef struct PoslistCallbackCtx PoslistCallbackCtx;\nstruct PoslistCallbackCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int eState;                     /* See above */\n};\n\ntypedef struct PoslistOffsetsCtx PoslistOffsetsCtx;\nstruct PoslistOffsetsCtx {\n  Fts5Buffer *pBuf;               /* Append to this buffer */\n  Fts5Colset *pColset;            /* Restrict matches to this column */\n  int iRead;\n  int iWrite;\n};\n\n/*\n** TODO: Make this more efficient!\n*/\nstatic int fts5IndexColsetTest(Fts5Colset *pColset, int iCol){\n  int i;\n  for(i=0; i<pColset->nCol; i++){\n    if( pColset->aiCol[i]==iCol ) return 1;\n  }\n  return 0;\n}\n\nstatic void fts5PoslistOffsetsCallback(\n  Fts5Index *pUnused, \n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistOffsetsCtx *pCtx = (PoslistOffsetsCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    int i = 0;\n    while( i<nChunk ){\n      int iVal;\n      i += fts5GetVarint32(&pChunk[i], iVal);\n      iVal += pCtx->iRead - 2;\n      pCtx->iRead = iVal;\n      if( fts5IndexColsetTest(pCtx->pColset, iVal) ){\n        fts5BufferSafeAppendVarint(pCtx->pBuf, iVal + 2 - pCtx->iWrite);\n        pCtx->iWrite = iVal;\n      }\n    }\n  }\n}\n\nstatic void fts5PoslistFilterCallback(\n  Fts5Index *pUnused,\n  void *pContext, \n  const u8 *pChunk, int nChunk\n){\n  PoslistCallbackCtx *pCtx = (PoslistCallbackCtx*)pContext;\n  UNUSED_PARAM(pUnused);\n  assert_nc( nChunk>=0 );\n  if( nChunk>0 ){\n    /* Search through to find the first varint with value 1. This is the\n    ** start of the next columns hits. */\n    int i = 0;\n    int iStart = 0;\n\n    if( pCtx->eState==2 ){\n      int iCol;\n      fts5FastGetVarint32(pChunk, i, iCol);\n      if( fts5IndexColsetTest(pCtx->pColset, iCol) ){\n        pCtx->eState = 1;\n        fts5BufferSafeAppendVarint(pCtx->pBuf, 1);\n      }else{\n        pCtx->eState = 0;\n      }\n    }\n\n    do {\n      while( i<nChunk && pChunk[i]!=0x01 ){\n        while( pChunk[i] & 0x80 ) i++;\n        i++;\n      }\n      if( pCtx->eState ){\n        fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n      }\n      if( i<nChunk ){\n        int iCol;\n        iStart = i;\n        i++;\n        if( i>=nChunk ){\n          pCtx->eState = 2;\n        }else{\n          fts5FastGetVarint32(pChunk, i, iCol);\n          pCtx->eState = fts5IndexColsetTest(pCtx->pColset, iCol);\n          if( pCtx->eState ){\n            fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);\n            iStart = i;\n          }\n        }\n      }\n    }while( i<nChunk );\n  }\n}\n\nstatic void fts5ChunkIterate(\n  Fts5Index *p,                   /* Index object */\n  Fts5SegIter *pSeg,              /* Poslist of this iterator */\n  void *pCtx,                     /* Context pointer for xChunk callback */\n  void (*xChunk)(Fts5Index*, void*, const u8*, int)\n){\n  int nRem = pSeg->nPos;          /* Number of bytes still to come */\n  Fts5Data *pData = 0;\n  u8 *pChunk = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  int nChunk = MIN(nRem, pSeg->pLeaf->szLeaf - pSeg->iLeafOffset);\n  int pgno = pSeg->iLeafPgno;\n  int pgnoSave = 0;\n\n  /* This function does notmwork with detail=none databases. */\n  assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE );\n\n  if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){\n    pgnoSave = pgno+1;\n  }\n\n  while( 1 ){\n    xChunk(p, pCtx, pChunk, nChunk);\n    nRem -= nChunk;\n    fts5DataRelease(pData);\n    if( nRem<=0 ){\n      break;\n    }else{\n      pgno++;\n      pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno));\n      if( pData==0 ) break;\n      pChunk = &pData->p[4];\n      nChunk = MIN(nRem, pData->szLeaf - 4);\n      if( pgno==pgnoSave ){\n        assert( pSeg->pNextLeaf==0 );\n        pSeg->pNextLeaf = pData;\n        pData = 0;\n      }\n    }\n  }\n}\n\n/*\n** Iterator pIter currently points to a valid entry (not EOF). This\n** function appends the position list data for the current entry to\n** buffer pBuf. It does not make a copy of the position-list size\n** field.\n*/\nstatic void fts5SegiterPoslist(\n  Fts5Index *p,\n  Fts5SegIter *pSeg,\n  Fts5Colset *pColset,\n  Fts5Buffer *pBuf\n){\n  if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos) ){\n    if( pColset==0 ){\n      fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);\n    }else{\n      if( p->pConfig->eDetail==FTS5_DETAIL_FULL ){\n        PoslistCallbackCtx sCtx;\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        sCtx.eState = fts5IndexColsetTest(pColset, 0);\n        assert( sCtx.eState==0 || sCtx.eState==1 );\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistFilterCallback);\n      }else{\n        PoslistOffsetsCtx sCtx;\n        memset(&sCtx, 0, sizeof(sCtx));\n        sCtx.pBuf = pBuf;\n        sCtx.pColset = pColset;\n        fts5ChunkIterate(p, pSeg, (void*)&sCtx, fts5PoslistOffsetsCallback);\n      }\n    }\n  }\n}\n\n/*\n** IN/OUT parameter (*pa) points to a position list n bytes in size. If\n** the position list contains entries for column iCol, then (*pa) is set\n** to point to the sub-position-list for that column and the number of\n** bytes in it returned. Or, if the argument position list does not\n** contain any entries for column iCol, return 0.\n*/\nstatic int fts5IndexExtractCol(\n  const u8 **pa,                  /* IN/OUT: Pointer to poslist */\n  int n,                          /* IN: Size of poslist in bytes */\n  int iCol                        /* Column to extract from poslist */\n){\n  int iCurrent = 0;               /* Anything before the first 0x01 is col 0 */\n  const u8 *p = *pa;\n  const u8 *pEnd = &p[n];         /* One byte past end of position list */\n\n  while( iCol>iCurrent ){\n    /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n    ** not part of a varint. Note that it is not possible for a negative\n    ** or extremely large varint to occur within an uncorrupted position \n    ** list. So the last byte of each varint may be assumed to have a clear\n    ** 0x80 bit.  */\n    while( *p!=0x01 ){\n      while( *p++ & 0x80 );\n      if( p>=pEnd ) return 0;\n    }\n    *pa = p++;\n    iCurrent = *p++;\n    if( iCurrent & 0x80 ){\n      p--;\n      p += fts5GetVarint32(p, iCurrent);\n    }\n  }\n  if( iCol!=iCurrent ) return 0;\n\n  /* Advance pointer p until it points to pEnd or an 0x01 byte that is\n  ** not part of a varint */\n  while( p<pEnd && *p!=0x01 ){\n    while( *p++ & 0x80 );\n  }\n\n  return p - (*pa);\n}\n\nstatic void fts5IndexExtractColset(\n  int *pRc,\n  Fts5Colset *pColset,            /* Colset to filter on */\n  const u8 *pPos, int nPos,       /* Position list */\n  Fts5Buffer *pBuf                /* Output buffer */\n){\n  if( *pRc==SQLITE_OK ){\n    int i;\n    fts5BufferZero(pBuf);\n    for(i=0; i<pColset->nCol; i++){\n      const u8 *pSub = pPos;\n      int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]);\n      if( nSub ){\n        fts5BufferAppendBlob(pRc, pBuf, nSub, pSub);\n      }\n    }\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=none tables.\n*/\nstatic void fts5IterSetOutputs_None(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_NONE );\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n}\n\n/*\n** xSetOutputs callback used by detail=full and detail=col tables when no\n** column filters are specified.\n*/\nstatic void fts5IterSetOutputs_Nocolset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.nData = pSeg->nPos;\n\n  assert( pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_NONE );\n  assert( pIter->pColset==0 );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    pIter->base.pData = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, 0, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used when the Fts5Colset object has nCol==0 (match\n** against no columns at all).\n*/\nstatic void fts5IterSetOutputs_ZeroColset(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  UNUSED_PARAM(pSeg);\n  pIter->base.nData = 0;\n}\n\n/*\n** xSetOutputs callback used by detail=col when there is a column filter\n** and there are 100 or more columns. Also called as a fallback from\n** fts5IterSetOutputs_Col100 if the column-list spans more than one page.\n*/\nstatic void fts5IterSetOutputs_Col(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  fts5BufferZero(&pIter->poslist);\n  fts5SegiterPoslist(pIter->pIndex, pSeg, pIter->pColset, &pIter->poslist);\n  pIter->base.iRowid = pSeg->iRowid;\n  pIter->base.pData = pIter->poslist.p;\n  pIter->base.nData = pIter->poslist.n;\n}\n\n/*\n** xSetOutputs callback used when: \n**\n**   * detail=col,\n**   * there is a column filter, and\n**   * the table contains 100 or fewer columns. \n**\n** The last point is to ensure all column numbers are stored as \n** single-byte varints.\n*/\nstatic void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n  assert( pIter->pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){\n    fts5IterSetOutputs_Col(pIter, pSeg);\n  }else{\n    u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];\n    u8 *pEnd = (u8*)&a[pSeg->nPos]; \n    int iPrev = 0;\n    int *aiCol = pIter->pColset->aiCol;\n    int *aiColEnd = &aiCol[pIter->pColset->nCol];\n\n    u8 *aOut = pIter->poslist.p;\n    int iPrevOut = 0;\n\n    pIter->base.iRowid = pSeg->iRowid;\n\n    while( a<pEnd ){\n      iPrev += (int)a++[0] - 2;\n      while( *aiCol<iPrev ){\n        aiCol++;\n        if( aiCol==aiColEnd ) goto setoutputs_col_out;\n      }\n      if( *aiCol==iPrev ){\n        *aOut++ = (u8)((iPrev - iPrevOut) + 2);\n        iPrevOut = iPrev;\n      }\n    }\n\nsetoutputs_col_out:\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = aOut - pIter->poslist.p;\n  }\n}\n\n/*\n** xSetOutputs callback used by detail=full when there is a column filter.\n*/\nstatic void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){\n  Fts5Colset *pColset = pIter->pColset;\n  pIter->base.iRowid = pSeg->iRowid;\n\n  assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_FULL );\n  assert( pColset );\n\n  if( pSeg->iLeafOffset+pSeg->nPos<=pSeg->pLeaf->szLeaf ){\n    /* All data is stored on the current page. Populate the output \n    ** variables to point into the body of the page object. */\n    const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset];\n    if( pColset->nCol==1 ){\n      pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]);\n      pIter->base.pData = a;\n    }else{\n      int *pRc = &pIter->pIndex->rc;\n      fts5BufferZero(&pIter->poslist);\n      fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist);\n      pIter->base.pData = pIter->poslist.p;\n      pIter->base.nData = pIter->poslist.n;\n    }\n  }else{\n    /* The data is distributed over two or more pages. Copy it into the\n    ** Fts5Iter.poslist buffer and then set the output pointer to point\n    ** to this buffer.  */\n    fts5BufferZero(&pIter->poslist);\n    fts5SegiterPoslist(pIter->pIndex, pSeg, pColset, &pIter->poslist);\n    pIter->base.pData = pIter->poslist.p;\n    pIter->base.nData = pIter->poslist.n;\n  }\n}\n\nstatic void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){\n  if( *pRc==SQLITE_OK ){\n    Fts5Config *pConfig = pIter->pIndex->pConfig;\n    if( pConfig->eDetail==FTS5_DETAIL_NONE ){\n      pIter->xSetOutputs = fts5IterSetOutputs_None;\n    }\n\n    else if( pIter->pColset==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Nocolset;\n    }\n\n    else if( pIter->pColset->nCol==0 ){\n      pIter->xSetOutputs = fts5IterSetOutputs_ZeroColset;\n    }\n\n    else if( pConfig->eDetail==FTS5_DETAIL_FULL ){\n      pIter->xSetOutputs = fts5IterSetOutputs_Full;\n    }\n\n    else{\n      assert( pConfig->eDetail==FTS5_DETAIL_COLUMNS );\n      if( pConfig->nCol<=100 ){\n        pIter->xSetOutputs = fts5IterSetOutputs_Col100;\n        sqlite3Fts5BufferSize(pRc, &pIter->poslist, pConfig->nCol);\n      }else{\n        pIter->xSetOutputs = fts5IterSetOutputs_Col;\n      }\n    }\n  }\n}\n\n\n/*\n** Allocate a new Fts5Iter object.\n**\n** The new object will be used to iterate through data in structure pStruct.\n** If iLevel is -ve, then all data in all segments is merged. Or, if iLevel\n** is zero or greater, data from the first nSegment segments on level iLevel\n** is merged.\n**\n** The iterator initially points to the first term/rowid entry in the \n** iterated data.\n*/\nstatic void fts5MultiIterNew(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Structure *pStruct,         /* Structure of specific index */\n  int flags,                      /* FTS5INDEX_QUERY_XXX flags */\n  Fts5Colset *pColset,            /* Colset to filter on (or NULL) */\n  const u8 *pTerm, int nTerm,     /* Term to seek to (or NULL/0) */\n  int iLevel,                     /* Level to iterate (-1 for all) */\n  int nSegment,                   /* Number of segments to merge (iLevel>=0) */\n  Fts5Iter **ppOut                /* New object */\n){\n  int nSeg = 0;                   /* Number of segment-iters in use */\n  int iIter = 0;                  /* */\n  int iSeg;                       /* Used to iterate through segments */\n  Fts5StructureLevel *pLvl;\n  Fts5Iter *pNew;\n\n  assert( (pTerm==0 && nTerm==0) || iLevel<0 );\n\n  /* Allocate space for the new multi-seg-iterator. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      assert( pStruct->nSegment==fts5StructureCountSegments(pStruct) );\n      nSeg = pStruct->nSegment;\n      nSeg += (p->pHash ? 1 : 0);\n    }else{\n      nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment);\n    }\n  }\n  *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);\n  if( pNew==0 ) return;\n  pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));\n  pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));\n  pNew->pStruct = pStruct;\n  pNew->pColset = pColset;\n  fts5StructureRef(pStruct);\n  if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){\n    fts5IterSetOutputCb(&p->rc, pNew);\n  }\n\n  /* Initialize each of the component segment iterators. */\n  if( p->rc==SQLITE_OK ){\n    if( iLevel<0 ){\n      Fts5StructureLevel *pEnd = &pStruct->aLevel[pStruct->nLevel];\n      if( p->pHash ){\n        /* Add a segment iterator for the current contents of the hash table. */\n        Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n        fts5SegIterHashInit(p, pTerm, nTerm, flags, pIter);\n      }\n      for(pLvl=&pStruct->aLevel[0]; pLvl<pEnd; pLvl++){\n        for(iSeg=pLvl->nSeg-1; iSeg>=0; iSeg--){\n          Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n          Fts5SegIter *pIter = &pNew->aSeg[iIter++];\n          if( pTerm==0 ){\n            fts5SegIterInit(p, pSeg, pIter);\n          }else{\n            fts5SegIterSeekInit(p, pTerm, nTerm, flags, pSeg, pIter);\n          }\n        }\n      }\n    }else{\n      pLvl = &pStruct->aLevel[iLevel];\n      for(iSeg=nSeg-1; iSeg>=0; iSeg--){\n        fts5SegIterInit(p, &pLvl->aSeg[iSeg], &pNew->aSeg[iIter++]);\n      }\n    }\n    assert( iIter==nSeg );\n  }\n\n  /* If the above was successful, each component iterators now points \n  ** to the first entry in its segment. In this case initialize the \n  ** aFirst[] array. Or, if an error has occurred, free the iterator\n  ** object and set the output variable to NULL.  */\n  if( p->rc==SQLITE_OK ){\n    for(iIter=pNew->nSeg-1; iIter>0; iIter--){\n      int iEq;\n      if( (iEq = fts5MultiIterDoCompare(pNew, iIter)) ){\n        Fts5SegIter *pSeg = &pNew->aSeg[iEq];\n        if( p->rc==SQLITE_OK ) pSeg->xNext(p, pSeg, 0);\n        fts5MultiIterAdvanced(p, pNew, iEq, iIter);\n      }\n    }\n    fts5MultiIterSetEof(pNew);\n    fts5AssertMultiIterSetup(p, pNew);\n\n    if( pNew->bSkipEmpty && fts5MultiIterIsEmpty(p, pNew) ){\n      fts5MultiIterNext(p, pNew, 0, 0);\n    }else if( pNew->base.bEof==0 ){\n      Fts5SegIter *pSeg = &pNew->aSeg[pNew->aFirst[1].iFirst];\n      pNew->xSetOutputs(pNew, pSeg);\n    }\n\n  }else{\n    fts5MultiIterFree(pNew);\n    *ppOut = 0;\n  }\n}\n\n/*\n** Create an Fts5Iter that iterates through the doclist provided\n** as the second argument.\n*/\nstatic void fts5MultiIterNew2(\n  Fts5Index *p,                   /* FTS5 backend to iterate within */\n  Fts5Data *pData,                /* Doclist to iterate through */\n  int bDesc,                      /* True for descending rowid order */\n  Fts5Iter **ppOut                /* New object */\n){\n  Fts5Iter *pNew;\n  pNew = fts5MultiIterAlloc(p, 2);\n  if( pNew ){\n    Fts5SegIter *pIter = &pNew->aSeg[1];\n\n    pIter->flags = FTS5_SEGITER_ONETERM;\n    if( pData->szLeaf>0 ){\n      pIter->pLeaf = pData;\n      pIter->iLeafOffset = fts5GetVarint(pData->p, (u64*)&pIter->iRowid);\n      pIter->iEndofDoclist = pData->nn;\n      pNew->aFirst[1].iFirst = 1;\n      if( bDesc ){\n        pNew->bRev = 1;\n        pIter->flags |= FTS5_SEGITER_REVERSE;\n        fts5SegIterReverseInitPage(p, pIter);\n      }else{\n        fts5SegIterLoadNPos(p, pIter);\n      }\n      pData = 0;\n    }else{\n      pNew->base.bEof = 1;\n    }\n    fts5SegIterSetNext(p, pIter);\n\n    *ppOut = pNew;\n  }\n\n  fts5DataRelease(pData);\n}\n\n/*\n** Return true if the iterator is at EOF or if an error has occurred. \n** False otherwise.\n*/\nstatic int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){\n  assert( p->rc \n      || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof \n  );\n  return (p->rc || pIter->base.bEof);\n}\n\n/*\n** Return the rowid of the entry that the iterator currently points\n** to. If the iterator points to EOF when this function is called the\n** results are undefined.\n*/\nstatic i64 fts5MultiIterRowid(Fts5Iter *pIter){\n  assert( pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf );\n  return pIter->aSeg[ pIter->aFirst[1].iFirst ].iRowid;\n}\n\n/*\n** Move the iterator to the next entry at or following iMatch.\n*/\nstatic void fts5MultiIterNextFrom(\n  Fts5Index *p, \n  Fts5Iter *pIter, \n  i64 iMatch\n){\n  while( 1 ){\n    i64 iRowid;\n    fts5MultiIterNext(p, pIter, 1, iMatch);\n    if( fts5MultiIterEof(p, pIter) ) break;\n    iRowid = fts5MultiIterRowid(pIter);\n    if( pIter->bRev==0 && iRowid>=iMatch ) break;\n    if( pIter->bRev!=0 && iRowid<=iMatch ) break;\n  }\n}\n\n/*\n** Return a pointer to a buffer containing the term associated with the \n** entry that the iterator currently points to.\n*/\nstatic const u8 *fts5MultiIterTerm(Fts5Iter *pIter, int *pn){\n  Fts5SegIter *p = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n  *pn = p->term.n;\n  return p->term.p;\n}\n\n/*\n** Allocate a new segment-id for the structure pStruct. The new segment\n** id must be between 1 and 65335 inclusive, and must not be used by \n** any currently existing segment. If a free segment id cannot be found,\n** SQLITE_FULL is returned.\n**\n** If an error has already occurred, this function is a no-op. 0 is \n** returned in this case.\n*/\nstatic int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){\n  int iSegid = 0;\n\n  if( p->rc==SQLITE_OK ){\n    if( pStruct->nSegment>=FTS5_MAX_SEGMENT ){\n      p->rc = SQLITE_FULL;\n    }else{\n      /* FTS5_MAX_SEGMENT is currently defined as 2000. So the following\n      ** array is 63 elements, or 252 bytes, in size.  */\n      u32 aUsed[(FTS5_MAX_SEGMENT+31) / 32];\n      int iLvl, iSeg;\n      int i;\n      u32 mask;\n      memset(aUsed, 0, sizeof(aUsed));\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;\n          if( iId<=FTS5_MAX_SEGMENT ){\n            aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);\n          }\n        }\n      }\n\n      for(i=0; aUsed[i]==0xFFFFFFFF; i++);\n      mask = aUsed[i];\n      for(iSegid=0; mask & (1 << iSegid); iSegid++);\n      iSegid += 1 + i*32;\n\n#ifdef SQLITE_DEBUG\n      for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );\n        }\n      }\n      assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );\n\n      {\n        sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);\n        if( p->rc==SQLITE_OK ){\n          u8 aBlob[2] = {0xff, 0xff};\n          sqlite3_bind_int(pIdxSelect, 1, iSegid);\n          sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);\n          assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );\n          p->rc = sqlite3_reset(pIdxSelect);\n        }\n      }\n#endif\n    }\n  }\n\n  return iSegid;\n}\n\n/*\n** Discard all data currently cached in the hash-tables.\n*/\nstatic void fts5IndexDiscardData(Fts5Index *p){\n  assert( p->pHash || p->nPendingData==0 );\n  if( p->pHash ){\n    sqlite3Fts5HashClear(p->pHash);\n    p->nPendingData = 0;\n  }\n}\n\n/*\n** Return the size of the prefix, in bytes, that buffer \n** (pNew/<length-unknown>) shares with buffer (pOld/nOld).\n**\n** Buffer (pNew/<length-unknown>) is guaranteed to be greater \n** than buffer (pOld/nOld).\n*/\nstatic int fts5PrefixCompress(int nOld, const u8 *pOld, const u8 *pNew){\n  int i;\n  for(i=0; i<nOld; i++){\n    if( pOld[i]!=pNew[i] ) break;\n  }\n  return i;\n}\n\nstatic void fts5WriteDlidxClear(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int bFlush                      /* If true, write dlidx to disk */\n){\n  int i;\n  assert( bFlush==0 || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n>0) );\n  for(i=0; i<pWriter->nDlidx; i++){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n    if( pDlidx->buf.n==0 ) break;\n    if( bFlush ){\n      assert( pDlidx->pgno!=0 );\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n    }\n    sqlite3Fts5BufferZero(&pDlidx->buf);\n    pDlidx->bPrevValid = 0;\n  }\n}\n\n/*\n** Grow the pWriter->aDlidx[] array to at least nLvl elements in size.\n** Any new array elements are zeroed before returning.\n*/\nstatic int fts5WriteDlidxGrow(\n  Fts5Index *p,\n  Fts5SegWriter *pWriter,\n  int nLvl\n){\n  if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){\n    Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(\n        pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl\n    );\n    if( aDlidx==0 ){\n      p->rc = SQLITE_NOMEM;\n    }else{\n      int nByte = sizeof(Fts5DlidxWriter) * (nLvl - pWriter->nDlidx);\n      memset(&aDlidx[pWriter->nDlidx], 0, nByte);\n      pWriter->aDlidx = aDlidx;\n      pWriter->nDlidx = nLvl;\n    }\n  }\n  return p->rc;\n}\n\n/*\n** If the current doclist-index accumulating in pWriter->aDlidx[] is large\n** enough, flush it to disk and return 1. Otherwise discard it and return\n** zero.\n*/\nstatic int fts5WriteFlushDlidx(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag = 0;\n\n  /* If there were FTS5_MIN_DLIDX_SIZE or more empty leaf pages written\n  ** to the database, also write the doclist-index to disk.  */\n  if( pWriter->aDlidx[0].buf.n>0 && pWriter->nEmpty>=FTS5_MIN_DLIDX_SIZE ){\n    bFlag = 1;\n  }\n  fts5WriteDlidxClear(p, pWriter, bFlag);\n  pWriter->nEmpty = 0;\n  return bFlag;\n}\n\n/*\n** This function is called whenever processing of the doclist for the \n** last term on leaf page (pWriter->iBtPage) is completed. \n**\n** The doclist-index for that term is currently stored in-memory within the\n** Fts5SegWriter.aDlidx[] array. If it is large enough, this function\n** writes it out to disk. Or, if it is too small to bother with, discards\n** it.\n**\n** Fts5SegWriter.btterm currently contains the first term on page iBtPage.\n*/\nstatic void fts5WriteFlushBtree(Fts5Index *p, Fts5SegWriter *pWriter){\n  int bFlag;\n\n  assert( pWriter->iBtPage || pWriter->nEmpty==0 );\n  if( pWriter->iBtPage==0 ) return;\n  bFlag = fts5WriteFlushDlidx(p, pWriter);\n\n  if( p->rc==SQLITE_OK ){\n    const char *z = (pWriter->btterm.n>0?(const char*)pWriter->btterm.p:\"\");\n    /* The following was already done in fts5WriteInit(): */\n    /* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */\n    sqlite3_bind_blob(p->pIdxWriter, 2, z, pWriter->btterm.n, SQLITE_STATIC);\n    sqlite3_bind_int64(p->pIdxWriter, 3, bFlag + ((i64)pWriter->iBtPage<<1));\n    sqlite3_step(p->pIdxWriter);\n    p->rc = sqlite3_reset(p->pIdxWriter);\n  }\n  pWriter->iBtPage = 0;\n}\n\n/*\n** This is called once for each leaf page except the first that contains\n** at least one term. Argument (nTerm/pTerm) is the split-key - a term that\n** is larger than all terms written to earlier leaves, and equal to or\n** smaller than the first term on the new leaf.\n**\n** If an error occurs, an error code is left in Fts5Index.rc. If an error\n** has already occurred when this function is called, it is a no-op.\n*/\nstatic void fts5WriteBtreeTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter,         /* Writer object */\n  int nTerm, const u8 *pTerm      /* First term on new page */\n){\n  fts5WriteFlushBtree(p, pWriter);\n  fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);\n  pWriter->iBtPage = pWriter->writer.pgno;\n}\n\n/*\n** This function is called when flushing a leaf page that contains no\n** terms at all to disk.\n*/\nstatic void fts5WriteBtreeNoTerm(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5SegWriter *pWriter          /* Writer object */\n){\n  /* If there were no rowids on the leaf page either and the doclist-index\n  ** has already been started, append an 0x00 byte to it.  */\n  if( pWriter->bFirstRowidInPage && pWriter->aDlidx[0].buf.n>0 ){\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[0];\n    assert( pDlidx->bPrevValid );\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, 0);\n  }\n\n  /* Increment the \"number of sequential leaves without a term\" counter. */\n  pWriter->nEmpty++;\n}\n\nstatic i64 fts5DlidxExtractFirstRowid(Fts5Buffer *pBuf){\n  i64 iRowid;\n  int iOff;\n\n  iOff = 1 + fts5GetVarint(&pBuf->p[1], (u64*)&iRowid);\n  fts5GetVarint(&pBuf->p[iOff], (u64*)&iRowid);\n  return iRowid;\n}\n\n/*\n** Rowid iRowid has just been appended to the current leaf page. It is the\n** first on the page. This function appends an appropriate entry to the current\n** doclist-index.\n*/\nstatic void fts5WriteDlidxAppend(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  i64 iRowid\n){\n  int i;\n  int bDone = 0;\n\n  for(i=0; p->rc==SQLITE_OK && bDone==0; i++){\n    i64 iVal;\n    Fts5DlidxWriter *pDlidx = &pWriter->aDlidx[i];\n\n    if( pDlidx->buf.n>=p->pConfig->pgsz ){\n      /* The current doclist-index page is full. Write it to disk and push\n      ** a copy of iRowid (which will become the first rowid on the next\n      ** doclist-index leaf page) up into the next level of the b-tree \n      ** hierarchy. If the node being flushed is currently the root node,\n      ** also push its first rowid upwards. */\n      pDlidx->buf.p[0] = 0x01;    /* Not the root node */\n      fts5DataWrite(p, \n          FTS5_DLIDX_ROWID(pWriter->iSegid, i, pDlidx->pgno),\n          pDlidx->buf.p, pDlidx->buf.n\n      );\n      fts5WriteDlidxGrow(p, pWriter, i+2);\n      pDlidx = &pWriter->aDlidx[i];\n      if( p->rc==SQLITE_OK && pDlidx[1].buf.n==0 ){\n        i64 iFirst = fts5DlidxExtractFirstRowid(&pDlidx->buf);\n\n        /* This was the root node. Push its first rowid up to the new root. */\n        pDlidx[1].pgno = pDlidx->pgno;\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, 0);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, pDlidx->pgno);\n        sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx[1].buf, iFirst);\n        pDlidx[1].bPrevValid = 1;\n        pDlidx[1].iPrev = iFirst;\n      }\n\n      sqlite3Fts5BufferZero(&pDlidx->buf);\n      pDlidx->bPrevValid = 0;\n      pDlidx->pgno++;\n    }else{\n      bDone = 1;\n    }\n\n    if( pDlidx->bPrevValid ){\n      iVal = iRowid - pDlidx->iPrev;\n    }else{\n      i64 iPgno = (i==0 ? pWriter->writer.pgno : pDlidx[-1].pgno);\n      assert( pDlidx->buf.n==0 );\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, !bDone);\n      sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iPgno);\n      iVal = iRowid;\n    }\n\n    sqlite3Fts5BufferAppendVarint(&p->rc, &pDlidx->buf, iVal);\n    pDlidx->bPrevValid = 1;\n    pDlidx->iPrev = iRowid;\n  }\n}\n\nstatic void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){\n  static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 };\n  Fts5PageWriter *pPage = &pWriter->writer;\n  i64 iRowid;\n\n  assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );\n\n  /* Set the szLeaf header field. */\n  assert( 0==fts5GetU16(&pPage->buf.p[2]) );\n  fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n);\n\n  if( pWriter->bFirstTermInPage ){\n    /* No term was written to this page. */\n    assert( pPage->pgidx.n==0 );\n    fts5WriteBtreeNoTerm(p, pWriter);\n  }else{\n    /* Append the pgidx to the page buffer. Set the szLeaf header field. */\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, pPage->pgidx.n, pPage->pgidx.p);\n  }\n\n  /* Write the page out to disk */\n  iRowid = FTS5_SEGMENT_ROWID(pWriter->iSegid, pPage->pgno);\n  fts5DataWrite(p, iRowid, pPage->buf.p, pPage->buf.n);\n\n  /* Initialize the next page. */\n  fts5BufferZero(&pPage->buf);\n  fts5BufferZero(&pPage->pgidx);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, 4, zero);\n  pPage->iPrevPgidx = 0;\n  pPage->pgno++;\n\n  /* Increase the leaves written counter */\n  pWriter->nLeafWritten++;\n\n  /* The new leaf holds no terms or rowids */\n  pWriter->bFirstTermInPage = 1;\n  pWriter->bFirstRowidInPage = 1;\n}\n\n/*\n** Append term pTerm/nTerm to the segment being written by the writer passed\n** as the second argument.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5WriteAppendTerm(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  int nTerm, const u8 *pTerm \n){\n  int nPrefix;                    /* Bytes of prefix compression for term */\n  Fts5PageWriter *pPage = &pWriter->writer;\n  Fts5Buffer *pPgidx = &pWriter->writer.pgidx;\n\n  assert( p->rc==SQLITE_OK );\n  assert( pPage->buf.n>=4 );\n  assert( pPage->buf.n>4 || pWriter->bFirstTermInPage );\n\n  /* If the current leaf page is full, flush it to disk. */\n  if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){\n    if( pPage->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n    fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);\n  }\n  \n  /* TODO1: Updating pgidx here. */\n  pPgidx->n += sqlite3Fts5PutVarint(\n      &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx\n  );\n  pPage->iPrevPgidx = pPage->buf.n;\n#if 0\n  fts5PutU16(&pPgidx->p[pPgidx->n], pPage->buf.n);\n  pPgidx->n += 2;\n#endif\n\n  if( pWriter->bFirstTermInPage ){\n    nPrefix = 0;\n    if( pPage->pgno!=1 ){\n      /* This is the first term on a leaf that is not the leftmost leaf in\n      ** the segment b-tree. In this case it is necessary to add a term to\n      ** the b-tree hierarchy that is (a) larger than the largest term \n      ** already written to the segment and (b) smaller than or equal to\n      ** this term. In other words, a prefix of (pTerm/nTerm) that is one\n      ** byte longer than the longest prefix (pTerm/nTerm) shares with the\n      ** previous term. \n      **\n      ** Usually, the previous term is available in pPage->term. The exception\n      ** is if this is the first term written in an incremental-merge step.\n      ** In this case the previous term is not available, so just write a\n      ** copy of (pTerm/nTerm) into the parent node. This is slightly\n      ** inefficient, but still correct.  */\n      int n = nTerm;\n      if( pPage->term.n ){\n        n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);\n      }\n      fts5WriteBtreeTerm(p, pWriter, n, pTerm);\n      pPage = &pWriter->writer;\n    }\n  }else{\n    nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);\n    fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);\n  }\n\n  /* Append the number of bytes of new data, then the term data itself\n  ** to the page. */\n  fts5BufferAppendVarint(&p->rc, &pPage->buf, nTerm - nPrefix);\n  fts5BufferAppendBlob(&p->rc, &pPage->buf, nTerm - nPrefix, &pTerm[nPrefix]);\n\n  /* Update the Fts5PageWriter.term field. */\n  fts5BufferSet(&p->rc, &pPage->term, nTerm, pTerm);\n  pWriter->bFirstTermInPage = 0;\n\n  pWriter->bFirstRowidInPage = 0;\n  pWriter->bFirstRowidInDoclist = 1;\n\n  assert( p->rc || (pWriter->nDlidx>0 && pWriter->aDlidx[0].buf.n==0) );\n  pWriter->aDlidx[0].pgno = pPage->pgno;\n}\n\n/*\n** Append a rowid and position-list size field to the writers output. \n*/\nstatic void fts5WriteAppendRowid(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,\n  i64 iRowid\n){\n  if( p->rc==SQLITE_OK ){\n    Fts5PageWriter *pPage = &pWriter->writer;\n\n    if( (pPage->buf.n + pPage->pgidx.n)>=p->pConfig->pgsz ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n\n    /* If this is to be the first rowid written to the page, set the \n    ** rowid-pointer in the page-header. Also append a value to the dlidx\n    ** buffer, in case a doclist-index is required.  */\n    if( pWriter->bFirstRowidInPage ){\n      fts5PutU16(pPage->buf.p, (u16)pPage->buf.n);\n      fts5WriteDlidxAppend(p, pWriter, iRowid);\n    }\n\n    /* Write the rowid. */\n    if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);\n    }else{\n      assert( p->rc || iRowid>pWriter->iPrevRowid );\n      fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);\n    }\n    pWriter->iPrevRowid = iRowid;\n    pWriter->bFirstRowidInDoclist = 0;\n    pWriter->bFirstRowidInPage = 0;\n  }\n}\n\nstatic void fts5WriteAppendPoslistData(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  const u8 *aData, \n  int nData\n){\n  Fts5PageWriter *pPage = &pWriter->writer;\n  const u8 *a = aData;\n  int n = nData;\n  \n  assert( p->pConfig->pgsz>0 );\n  while( p->rc==SQLITE_OK \n     && (pPage->buf.n + pPage->pgidx.n + n)>=p->pConfig->pgsz \n  ){\n    int nReq = p->pConfig->pgsz - pPage->buf.n - pPage->pgidx.n;\n    int nCopy = 0;\n    while( nCopy<nReq ){\n      i64 dummy;\n      nCopy += fts5GetVarint(&a[nCopy], (u64*)&dummy);\n    }\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, nCopy, a);\n    a += nCopy;\n    n -= nCopy;\n    fts5WriteFlushLeaf(p, pWriter);\n  }\n  if( n>0 ){\n    fts5BufferAppendBlob(&p->rc, &pPage->buf, n, a);\n  }\n}\n\n/*\n** Flush any data cached by the writer object to the database. Free any\n** allocations associated with the writer.\n*/\nstatic void fts5WriteFinish(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter,         /* Writer object */\n  int *pnLeaf                     /* OUT: Number of leaf pages in b-tree */\n){\n  int i;\n  Fts5PageWriter *pLeaf = &pWriter->writer;\n  if( p->rc==SQLITE_OK ){\n    assert( pLeaf->pgno>=1 );\n    if( pLeaf->buf.n>4 ){\n      fts5WriteFlushLeaf(p, pWriter);\n    }\n    *pnLeaf = pLeaf->pgno-1;\n    if( pLeaf->pgno>1 ){\n      fts5WriteFlushBtree(p, pWriter);\n    }\n  }\n  fts5BufferFree(&pLeaf->term);\n  fts5BufferFree(&pLeaf->buf);\n  fts5BufferFree(&pLeaf->pgidx);\n  fts5BufferFree(&pWriter->btterm);\n\n  for(i=0; i<pWriter->nDlidx; i++){\n    sqlite3Fts5BufferFree(&pWriter->aDlidx[i].buf);\n  }\n  sqlite3_free(pWriter->aDlidx);\n}\n\nstatic void fts5WriteInit(\n  Fts5Index *p, \n  Fts5SegWriter *pWriter, \n  int iSegid\n){\n  const int nBuffer = p->pConfig->pgsz + FTS5_DATA_PADDING;\n\n  memset(pWriter, 0, sizeof(Fts5SegWriter));\n  pWriter->iSegid = iSegid;\n\n  fts5WriteDlidxGrow(p, pWriter, 1);\n  pWriter->writer.pgno = 1;\n  pWriter->bFirstTermInPage = 1;\n  pWriter->iBtPage = 1;\n\n  assert( pWriter->writer.buf.n==0 );\n  assert( pWriter->writer.pgidx.n==0 );\n\n  /* Grow the two buffers to pgsz + padding bytes in size. */\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.pgidx, nBuffer);\n  sqlite3Fts5BufferSize(&p->rc, &pWriter->writer.buf, nBuffer);\n\n  if( p->pIdxWriter==0 ){\n    Fts5Config *pConfig = p->pConfig;\n    fts5IndexPrepareStmt(p, &p->pIdxWriter, sqlite3_mprintf(\n          \"INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)\", \n          pConfig->zDb, pConfig->zName\n    ));\n  }\n\n  if( p->rc==SQLITE_OK ){\n    /* Initialize the 4-byte leaf-page header to 0x00. */\n    memset(pWriter->writer.buf.p, 0, 4);\n    pWriter->writer.buf.n = 4;\n\n    /* Bind the current output segment id to the index-writer. This is an\n    ** optimization over binding the same value over and over as rows are\n    ** inserted into %_idx by the current writer.  */\n    sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid);\n  }\n}\n\n/*\n** Iterator pIter was used to iterate through the input segments of on an\n** incremental merge operation. This function is called if the incremental\n** merge step has finished but the input has not been completely exhausted.\n*/\nstatic void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){\n  int i;\n  Fts5Buffer buf;\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  for(i=0; i<pIter->nSeg; i++){\n    Fts5SegIter *pSeg = &pIter->aSeg[i];\n    if( pSeg->pSeg==0 ){\n      /* no-op */\n    }else if( pSeg->pLeaf==0 ){\n      /* All keys from this input segment have been transfered to the output.\n      ** Set both the first and last page-numbers to 0 to indicate that the\n      ** segment is now empty. */\n      pSeg->pSeg->pgnoLast = 0;\n      pSeg->pSeg->pgnoFirst = 0;\n    }else{\n      int iOff = pSeg->iTermLeafOffset;     /* Offset on new first leaf page */\n      i64 iLeafRowid;\n      Fts5Data *pData;\n      int iId = pSeg->pSeg->iSegid;\n      u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};\n\n      iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);\n      pData = fts5DataRead(p, iLeafRowid);\n      if( pData ){\n        fts5BufferZero(&buf);\n        fts5BufferGrow(&p->rc, &buf, pData->nn);\n        fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);\n        fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);\n        fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);\n        fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);\n        if( p->rc==SQLITE_OK ){\n          /* Set the szLeaf field */\n          fts5PutU16(&buf.p[2], (u16)buf.n);\n        }\n\n        /* Set up the new page-index array */\n        fts5BufferAppendVarint(&p->rc, &buf, 4);\n        if( pSeg->iLeafPgno==pSeg->iTermLeafPgno \n         && pSeg->iEndofDoclist<pData->szLeaf \n        ){\n          int nDiff = pData->szLeaf - pSeg->iEndofDoclist;\n          fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);\n          fts5BufferAppendBlob(&p->rc, &buf, \n              pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]\n          );\n        }\n\n        fts5DataRelease(pData);\n        pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;\n        fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);\n        fts5DataWrite(p, iLeafRowid, buf.p, buf.n);\n      }\n    }\n  }\n  fts5BufferFree(&buf);\n}\n\nstatic void fts5MergeChunkCallback(\n  Fts5Index *p, \n  void *pCtx, \n  const u8 *pChunk, int nChunk\n){\n  Fts5SegWriter *pWriter = (Fts5SegWriter*)pCtx;\n  fts5WriteAppendPoslistData(p, pWriter, pChunk, nChunk);\n}\n\n/*\n**\n*/\nstatic void fts5IndexMergeLevel(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Stucture of index */\n  int iLvl,                       /* Level to read input from */\n  int *pnRem                      /* Write up to this many output leaves */\n){\n  Fts5Structure *pStruct = *ppStruct;\n  Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n  Fts5StructureLevel *pLvlOut;\n  Fts5Iter *pIter = 0;       /* Iterator to read input data */\n  int nRem = pnRem ? *pnRem : 0;  /* Output leaf pages left to write */\n  int nInput;                     /* Number of input segments */\n  Fts5SegWriter writer;           /* Writer object */\n  Fts5StructureSegment *pSeg;     /* Output segment */\n  Fts5Buffer term;\n  int bOldest;                    /* True if the output segment is the oldest */\n  int eDetail = p->pConfig->eDetail;\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  int bTermWritten = 0;           /* True if current term already output */\n\n  assert( iLvl<pStruct->nLevel );\n  assert( pLvl->nMerge<=pLvl->nSeg );\n\n  memset(&writer, 0, sizeof(Fts5SegWriter));\n  memset(&term, 0, sizeof(Fts5Buffer));\n  if( pLvl->nMerge ){\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n    assert( pLvlOut->nSeg>0 );\n    nInput = pLvl->nMerge;\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg-1];\n\n    fts5WriteInit(p, &writer, pSeg->iSegid);\n    writer.writer.pgno = pSeg->pgnoLast+1;\n    writer.iBtPage = 0;\n  }else{\n    int iSegid = fts5AllocateSegid(p, pStruct);\n\n    /* Extend the Fts5Structure object as required to ensure the output\n    ** segment exists. */\n    if( iLvl==pStruct->nLevel-1 ){\n      fts5StructureAddLevel(&p->rc, ppStruct);\n      pStruct = *ppStruct;\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, iLvl+1, 1, 0);\n    if( p->rc ) return;\n    pLvl = &pStruct->aLevel[iLvl];\n    pLvlOut = &pStruct->aLevel[iLvl+1];\n\n    fts5WriteInit(p, &writer, iSegid);\n\n    /* Add the new segment to the output level */\n    pSeg = &pLvlOut->aSeg[pLvlOut->nSeg];\n    pLvlOut->nSeg++;\n    pSeg->pgnoFirst = 1;\n    pSeg->iSegid = iSegid;\n    pStruct->nSegment++;\n\n    /* Read input from all segments in the input level */\n    nInput = pLvl->nSeg;\n  }\n  bOldest = (pLvlOut->nSeg==1 && pStruct->nLevel==iLvl+2);\n\n  assert( iLvl>=0 );\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, iLvl, nInput, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    int nPos;                     /* position-list size field value */\n    int nTerm;\n    const u8 *pTerm;\n\n    pTerm = fts5MultiIterTerm(pIter, &nTerm);\n    if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){\n      if( pnRem && writer.nLeafWritten>nRem ){\n        break;\n      }\n      fts5BufferSet(&p->rc, &term, nTerm, pTerm);\n      bTermWritten =0;\n    }\n\n    /* Check for key annihilation. */\n    if( pSegIter->nPos==0 && (bOldest || pSegIter->bDel==0) ) continue;\n\n    if( p->rc==SQLITE_OK && bTermWritten==0 ){\n      /* This is a new term. Append a term to the output segment. */\n      fts5WriteAppendTerm(p, &writer, nTerm, pTerm);\n      bTermWritten = 1;\n    }\n\n    /* Append the rowid to the output */\n    /* WRITEPOSLISTSIZE */\n    fts5WriteAppendRowid(p, &writer, fts5MultiIterRowid(pIter));\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( pSegIter->bDel ){\n        fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        if( pSegIter->nPos>0 ){\n          fts5BufferAppendVarint(&p->rc, &writer.writer.buf, 0);\n        }\n      }\n    }else{\n      /* Append the position-list data to the output */\n      nPos = pSegIter->nPos*2 + pSegIter->bDel;\n      fts5BufferAppendVarint(&p->rc, &writer.writer.buf, nPos);\n      fts5ChunkIterate(p, pSegIter, (void*)&writer, fts5MergeChunkCallback);\n    }\n  }\n\n  /* Flush the last leaf page to disk. Set the output segment b-tree height\n  ** and last leaf page number at the same time.  */\n  fts5WriteFinish(p, &writer, &pSeg->pgnoLast);\n\n  if( fts5MultiIterEof(p, pIter) ){\n    int i;\n\n    /* Remove the redundant segments from the %_data table */\n    for(i=0; i<nInput; i++){\n      fts5DataRemoveSegment(p, pLvl->aSeg[i].iSegid);\n    }\n\n    /* Remove the redundant segments from the input level */\n    if( pLvl->nSeg!=nInput ){\n      int nMove = (pLvl->nSeg - nInput) * sizeof(Fts5StructureSegment);\n      memmove(pLvl->aSeg, &pLvl->aSeg[nInput], nMove);\n    }\n    pStruct->nSegment -= nInput;\n    pLvl->nSeg -= nInput;\n    pLvl->nMerge = 0;\n    if( pSeg->pgnoLast==0 ){\n      pLvlOut->nSeg--;\n      pStruct->nSegment--;\n    }\n  }else{\n    assert( pSeg->pgnoLast>0 );\n    fts5TrimSegments(p, pIter);\n    pLvl->nMerge = nInput;\n  }\n\n  fts5MultiIterFree(pIter);\n  fts5BufferFree(&term);\n  if( pnRem ) *pnRem -= writer.nLeafWritten;\n}\n\n/*\n** Do up to nPg pages of automerge work on the index.\n**\n** Return true if any changes were actually made, or false otherwise.\n*/\nstatic int fts5IndexMerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nPg,                        /* Pages of work to do */\n  int nMin                        /* Minimum number of segments to merge */\n){\n  int nRem = nPg;\n  int bRet = 0;\n  Fts5Structure *pStruct = *ppStruct;\n  while( nRem>0 && p->rc==SQLITE_OK ){\n    int iLvl;                   /* To iterate through levels */\n    int iBestLvl = 0;           /* Level offering the most input segments */\n    int nBest = 0;              /* Number of input segments on best level */\n\n    /* Set iBestLvl to the level to read input segments from. */\n    assert( pStruct->nLevel>0 );\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];\n      if( pLvl->nMerge ){\n        if( pLvl->nMerge>nBest ){\n          iBestLvl = iLvl;\n          nBest = pLvl->nMerge;\n        }\n        break;\n      }\n      if( pLvl->nSeg>nBest ){\n        nBest = pLvl->nSeg;\n        iBestLvl = iLvl;\n      }\n    }\n\n    /* If nBest is still 0, then the index must be empty. */\n#ifdef SQLITE_DEBUG\n    for(iLvl=0; nBest==0 && iLvl<pStruct->nLevel; iLvl++){\n      assert( pStruct->aLevel[iLvl].nSeg==0 );\n    }\n#endif\n\n    if( nBest<nMin && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      break;\n    }\n    bRet = 1;\n    fts5IndexMergeLevel(p, &pStruct, iBestLvl, &nRem);\n    if( p->rc==SQLITE_OK && pStruct->aLevel[iBestLvl].nMerge==0 ){\n      fts5StructurePromote(p, iBestLvl+1, pStruct);\n    }\n  }\n  *ppStruct = pStruct;\n  return bRet;\n}\n\n/*\n** A total of nLeaf leaf pages of data has just been flushed to a level-0\n** segment. This function updates the write-counter accordingly and, if\n** necessary, performs incremental merge work.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5IndexAutomerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct,       /* IN/OUT: Current structure of index */\n  int nLeaf                       /* Number of output leaves just written */\n){\n  if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){\n    Fts5Structure *pStruct = *ppStruct;\n    u64 nWrite;                   /* Initial value of write-counter */\n    int nWork;                    /* Number of work-quanta to perform */\n    int nRem;                     /* Number of leaf pages left to write */\n\n    /* Update the write-counter. While doing so, set nWork. */\n    nWrite = pStruct->nWriteCounter;\n    nWork = (int)(((nWrite + nLeaf) / p->nWorkUnit) - (nWrite / p->nWorkUnit));\n    pStruct->nWriteCounter += nLeaf;\n    nRem = (int)(p->nWorkUnit * nWork * pStruct->nLevel);\n\n    fts5IndexMerge(p, ppStruct, nRem, p->pConfig->nAutomerge);\n  }\n}\n\nstatic void fts5IndexCrisismerge(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Structure **ppStruct        /* IN/OUT: Current structure of index */\n){\n  const int nCrisis = p->pConfig->nCrisisMerge;\n  Fts5Structure *pStruct = *ppStruct;\n  int iLvl = 0;\n\n  assert( p->rc!=SQLITE_OK || pStruct->nLevel>0 );\n  while( p->rc==SQLITE_OK && pStruct->aLevel[iLvl].nSeg>=nCrisis ){\n    fts5IndexMergeLevel(p, &pStruct, iLvl, 0);\n    assert( p->rc!=SQLITE_OK || pStruct->nLevel>(iLvl+1) );\n    fts5StructurePromote(p, iLvl+1, pStruct);\n    iLvl++;\n  }\n  *ppStruct = pStruct;\n}\n\nstatic int fts5IndexReturn(Fts5Index *p){\n  int rc = p->rc;\n  p->rc = SQLITE_OK;\n  return rc;\n}\n\ntypedef struct Fts5FlushCtx Fts5FlushCtx;\nstruct Fts5FlushCtx {\n  Fts5Index *pIdx;\n  Fts5SegWriter writer; \n};\n\n/*\n** Buffer aBuf[] contains a list of varints, all small enough to fit\n** in a 32-bit integer. Return the size of the largest prefix of this \n** list nMax bytes or less in size.\n*/\nstatic int fts5PoslistPrefix(const u8 *aBuf, int nMax){\n  int ret;\n  u32 dummy;\n  ret = fts5GetVarint32(aBuf, dummy);\n  if( ret<nMax ){\n    while( 1 ){\n      int i = fts5GetVarint32(&aBuf[ret], dummy);\n      if( (ret + i) > nMax ) break;\n      ret += i;\n    }\n  }\n  return ret;\n}\n\n/*\n** Flush the contents of in-memory hash table iHash to a new level-0 \n** segment on disk. Also update the corresponding structure record.\n**\n** If an error occurs, set the Fts5Index.rc error code. If an error has \n** already occurred, this function is a no-op.\n*/\nstatic void fts5FlushOneHash(Fts5Index *p){\n  Fts5Hash *pHash = p->pHash;\n  Fts5Structure *pStruct;\n  int iSegid;\n  int pgnoLast = 0;                 /* Last leaf page number in segment */\n\n  /* Obtain a reference to the index structure and allocate a new segment-id\n  ** for the new level-0 segment.  */\n  pStruct = fts5StructureRead(p);\n  iSegid = fts5AllocateSegid(p, pStruct);\n  fts5StructureInvalidate(p);\n\n  if( iSegid ){\n    const int pgsz = p->pConfig->pgsz;\n    int eDetail = p->pConfig->eDetail;\n    Fts5StructureSegment *pSeg;   /* New segment within pStruct */\n    Fts5Buffer *pBuf;             /* Buffer in which to assemble leaf page */\n    Fts5Buffer *pPgidx;           /* Buffer in which to assemble pgidx */\n\n    Fts5SegWriter writer;\n    fts5WriteInit(p, &writer, iSegid);\n\n    pBuf = &writer.writer.buf;\n    pPgidx = &writer.writer.pgidx;\n\n    /* fts5WriteInit() should have initialized the buffers to (most likely)\n    ** the maximum space required. */\n    assert( p->rc || pBuf->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n    assert( p->rc || pPgidx->nSpace>=(pgsz + FTS5_DATA_PADDING) );\n\n    /* Begin scanning through hash table entries. This loop runs once for each\n    ** term/doclist currently stored within the hash table. */\n    if( p->rc==SQLITE_OK ){\n      p->rc = sqlite3Fts5HashScanInit(pHash, 0, 0);\n    }\n    while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){\n      const char *zTerm;          /* Buffer containing term */\n      const u8 *pDoclist;         /* Pointer to doclist for this term */\n      int nDoclist;               /* Size of doclist in bytes */\n\n      /* Write the term for this entry to disk. */\n      sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);\n      fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);\n\n      assert( writer.bFirstRowidInPage==0 );\n      if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){\n        /* The entire doclist will fit on the current leaf. */\n        fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist);\n      }else{\n        i64 iRowid = 0;\n        i64 iDelta = 0;\n        int iOff = 0;\n\n        /* The entire doclist will not fit on this leaf. The following \n        ** loop iterates through the poslists that make up the current \n        ** doclist.  */\n        while( p->rc==SQLITE_OK && iOff<nDoclist ){\n          iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);\n          iRowid += iDelta;\n          \n          if( writer.bFirstRowidInPage ){\n            fts5PutU16(&pBuf->p[0], (u16)pBuf->n);   /* first rowid on page */\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);\n            writer.bFirstRowidInPage = 0;\n            fts5WriteDlidxAppend(p, &writer, iRowid);\n          }else{\n            pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);\n          }\n          assert( pBuf->n<=pBuf->nSpace );\n\n          if( eDetail==FTS5_DETAIL_NONE ){\n            if( iOff<nDoclist && pDoclist[iOff]==0 ){\n              pBuf->p[pBuf->n++] = 0;\n              iOff++;\n              if( iOff<nDoclist && pDoclist[iOff]==0 ){\n                pBuf->p[pBuf->n++] = 0;\n                iOff++;\n              }\n            }\n            if( (pBuf->n + pPgidx->n)>=pgsz ){\n              fts5WriteFlushLeaf(p, &writer);\n            }\n          }else{\n            int bDummy;\n            int nPos;\n            int nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);\n            nCopy += nPos;\n            if( (pBuf->n + pPgidx->n + nCopy) <= pgsz ){\n              /* The entire poslist will fit on the current leaf. So copy\n              ** it in one go. */\n              fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy);\n            }else{\n              /* The entire poslist will not fit on this leaf. So it needs\n              ** to be broken into sections. The only qualification being\n              ** that each varint must be stored contiguously.  */\n              const u8 *pPoslist = &pDoclist[iOff];\n              int iPos = 0;\n              while( p->rc==SQLITE_OK ){\n                int nSpace = pgsz - pBuf->n - pPgidx->n;\n                int n = 0;\n                if( (nCopy - iPos)<=nSpace ){\n                  n = nCopy - iPos;\n                }else{\n                  n = fts5PoslistPrefix(&pPoslist[iPos], nSpace);\n                }\n                assert( n>0 );\n                fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n);\n                iPos += n;\n                if( (pBuf->n + pPgidx->n)>=pgsz ){\n                  fts5WriteFlushLeaf(p, &writer);\n                }\n                if( iPos>=nCopy ) break;\n              }\n            }\n            iOff += nCopy;\n          }\n        }\n      }\n\n      /* TODO2: Doclist terminator written here. */\n      /* pBuf->p[pBuf->n++] = '\\0'; */\n      assert( pBuf->n<=pBuf->nSpace );\n      sqlite3Fts5HashScanNext(pHash);\n    }\n    sqlite3Fts5HashClear(pHash);\n    fts5WriteFinish(p, &writer, &pgnoLast);\n\n    /* Update the Fts5Structure. It is written back to the database by the\n    ** fts5StructureRelease() call below.  */\n    if( pStruct->nLevel==0 ){\n      fts5StructureAddLevel(&p->rc, &pStruct);\n    }\n    fts5StructureExtendLevel(&p->rc, pStruct, 0, 1, 0);\n    if( p->rc==SQLITE_OK ){\n      pSeg = &pStruct->aLevel[0].aSeg[ pStruct->aLevel[0].nSeg++ ];\n      pSeg->iSegid = iSegid;\n      pSeg->pgnoFirst = 1;\n      pSeg->pgnoLast = pgnoLast;\n      pStruct->nSegment++;\n    }\n    fts5StructurePromote(p, 0, pStruct);\n  }\n\n  fts5IndexAutomerge(p, &pStruct, pgnoLast);\n  fts5IndexCrisismerge(p, &pStruct);\n  fts5StructureWrite(p, pStruct);\n  fts5StructureRelease(pStruct);\n}\n\n/*\n** Flush any data stored in the in-memory hash tables to the database.\n*/\nstatic void fts5IndexFlush(Fts5Index *p){\n  /* Unless it is empty, flush the hash table to disk */\n  if( p->nPendingData ){\n    assert( p->pHash );\n    p->nPendingData = 0;\n    fts5FlushOneHash(p);\n  }\n}\n\nstatic Fts5Structure *fts5IndexOptimizeStruct(\n  Fts5Index *p, \n  Fts5Structure *pStruct\n){\n  Fts5Structure *pNew = 0;\n  int nByte = sizeof(Fts5Structure);\n  int nSeg = pStruct->nSegment;\n  int i;\n\n  /* Figure out if this structure requires optimization. A structure does\n  ** not require optimization if either:\n  **\n  **  + it consists of fewer than two segments, or \n  **  + all segments are on the same level, or\n  **  + all segments except one are currently inputs to a merge operation.\n  **\n  ** In the first case, return NULL. In the second, increment the ref-count\n  ** on *pStruct and return a copy of the pointer to it.\n  */\n  if( nSeg<2 ) return 0;\n  for(i=0; i<pStruct->nLevel; i++){\n    int nThis = pStruct->aLevel[i].nSeg;\n    if( nThis==nSeg || (nThis==nSeg-1 && pStruct->aLevel[i].nMerge==nThis) ){\n      fts5StructureRef(pStruct);\n      return pStruct;\n    }\n    assert( pStruct->aLevel[i].nMerge<=nThis );\n  }\n\n  nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel);\n  pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);\n\n  if( pNew ){\n    Fts5StructureLevel *pLvl;\n    nByte = nSeg * sizeof(Fts5StructureSegment);\n    pNew->nLevel = pStruct->nLevel+1;\n    pNew->nRef = 1;\n    pNew->nWriteCounter = pStruct->nWriteCounter;\n    pLvl = &pNew->aLevel[pStruct->nLevel];\n    pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&p->rc, nByte);\n    if( pLvl->aSeg ){\n      int iLvl, iSeg;\n      int iSegOut = 0;\n      /* Iterate through all segments, from oldest to newest. Add them to\n      ** the new Fts5Level object so that pLvl->aSeg[0] is the oldest\n      ** segment in the data structure.  */\n      for(iLvl=pStruct->nLevel-1; iLvl>=0; iLvl--){\n        for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n          pLvl->aSeg[iSegOut] = pStruct->aLevel[iLvl].aSeg[iSeg];\n          iSegOut++;\n        }\n      }\n      pNew->nSegment = pLvl->nSeg = nSeg;\n    }else{\n      sqlite3_free(pNew);\n      pNew = 0;\n    }\n  }\n\n  return pNew;\n}\n\nstatic int sqlite3Fts5IndexOptimize(Fts5Index *p){\n  Fts5Structure *pStruct;\n  Fts5Structure *pNew = 0;\n\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  pStruct = fts5StructureRead(p);\n  fts5StructureInvalidate(p);\n\n  if( pStruct ){\n    pNew = fts5IndexOptimizeStruct(p, pStruct);\n  }\n  fts5StructureRelease(pStruct);\n\n  assert( pNew==0 || pNew->nSegment>0 );\n  if( pNew ){\n    int iLvl;\n    for(iLvl=0; pNew->aLevel[iLvl].nSeg==0; iLvl++){}\n    while( p->rc==SQLITE_OK && pNew->aLevel[iLvl].nSeg>0 ){\n      int nRem = FTS5_OPT_WORK_UNIT;\n      fts5IndexMergeLevel(p, &pNew, iLvl, &nRem);\n    }\n\n    fts5StructureWrite(p, pNew);\n    fts5StructureRelease(pNew);\n  }\n\n  return fts5IndexReturn(p); \n}\n\n/*\n** This is called to implement the special \"VALUES('merge', $nMerge)\"\n** INSERT command.\n*/\nstatic int sqlite3Fts5IndexMerge(Fts5Index *p, int nMerge){\n  Fts5Structure *pStruct = fts5StructureRead(p);\n  if( pStruct ){\n    int nMin = p->pConfig->nUsermerge;\n    fts5StructureInvalidate(p);\n    if( nMerge<0 ){\n      Fts5Structure *pNew = fts5IndexOptimizeStruct(p, pStruct);\n      fts5StructureRelease(pStruct);\n      pStruct = pNew;\n      nMin = 2;\n      nMerge = nMerge*-1;\n    }\n    if( pStruct && pStruct->nLevel ){\n      if( fts5IndexMerge(p, &pStruct, nMerge, nMin) ){\n        fts5StructureWrite(p, pStruct);\n      }\n    }\n    fts5StructureRelease(pStruct);\n  }\n  return fts5IndexReturn(p);\n}\n\nstatic void fts5AppendRowid(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pUnused,\n  Fts5Buffer *pBuf\n){\n  UNUSED_PARAM(pUnused);\n  fts5BufferAppendVarint(&p->rc, pBuf, iDelta);\n}\n\nstatic void fts5AppendPoslist(\n  Fts5Index *p,\n  i64 iDelta,\n  Fts5Iter *pMulti,\n  Fts5Buffer *pBuf\n){\n  int nData = pMulti->base.nData;\n  assert( nData>0 );\n  if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){\n    fts5BufferSafeAppendVarint(pBuf, iDelta);\n    fts5BufferSafeAppendVarint(pBuf, nData*2);\n    fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);\n  }\n}\n\n\nstatic void fts5DoclistIterNext(Fts5DoclistIter *pIter){\n  u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist;\n\n  assert( pIter->aPoslist );\n  if( p>=pIter->aEof ){\n    pIter->aPoslist = 0;\n  }else{\n    i64 iDelta;\n\n    p += fts5GetVarint(p, (u64*)&iDelta);\n    pIter->iRowid += iDelta;\n\n    /* Read position list size */\n    if( p[0] & 0x80 ){\n      int nPos;\n      pIter->nSize = fts5GetVarint32(p, nPos);\n      pIter->nPoslist = (nPos>>1);\n    }else{\n      pIter->nPoslist = ((int)(p[0])) >> 1;\n      pIter->nSize = 1;\n    }\n\n    pIter->aPoslist = p;\n  }\n}\n\nstatic void fts5DoclistIterInit(\n  Fts5Buffer *pBuf, \n  Fts5DoclistIter *pIter\n){\n  memset(pIter, 0, sizeof(*pIter));\n  pIter->aPoslist = pBuf->p;\n  pIter->aEof = &pBuf->p[pBuf->n];\n  fts5DoclistIterNext(pIter);\n}\n\n#if 0\n/*\n** Append a doclist to buffer pBuf.\n**\n** This function assumes that space within the buffer has already been\n** allocated.\n*/\nstatic void fts5MergeAppendDocid(\n  Fts5Buffer *pBuf,               /* Buffer to write to */\n  i64 *piLastRowid,               /* IN/OUT: Previous rowid written (if any) */\n  i64 iRowid                      /* Rowid to append */\n){\n  assert( pBuf->n!=0 || (*piLastRowid)==0 );\n  fts5BufferSafeAppendVarint(pBuf, iRowid - *piLastRowid);\n  *piLastRowid = iRowid;\n}\n#endif\n\n#define fts5MergeAppendDocid(pBuf, iLastRowid, iRowid) {       \\\n  assert( (pBuf)->n!=0 || (iLastRowid)==0 );                   \\\n  fts5BufferSafeAppendVarint((pBuf), (iRowid) - (iLastRowid)); \\\n  (iLastRowid) = (iRowid);                                     \\\n}\n\n/*\n** Swap the contents of buffer *p1 with that of *p2.\n*/\nstatic void fts5BufferSwap(Fts5Buffer *p1, Fts5Buffer *p2){\n  Fts5Buffer tmp = *p1;\n  *p1 = *p2;\n  *p2 = tmp;\n}\n\nstatic void fts5NextRowid(Fts5Buffer *pBuf, int *piOff, i64 *piRowid){\n  int i = *piOff;\n  if( i>=pBuf->n ){\n    *piOff = -1;\n  }else{\n    u64 iVal;\n    *piOff = i + sqlite3Fts5GetVarint(&pBuf->p[i], &iVal);\n    *piRowid += iVal;\n  }\n}\n\n/*\n** This is the equivalent of fts5MergePrefixLists() for detail=none mode.\n** In this case the buffers consist of a delta-encoded list of rowids only.\n*/\nstatic void fts5MergeRowidLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  int i1 = 0;\n  int i2 = 0;\n  i64 iRowid1 = 0;\n  i64 iRowid2 = 0;\n  i64 iOut = 0;\n\n  Fts5Buffer out;\n  memset(&out, 0, sizeof(out));\n  sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n);\n  if( p->rc ) return;\n\n  fts5NextRowid(p1, &i1, &iRowid1);\n  fts5NextRowid(p2, &i2, &iRowid2);\n  while( i1>=0 || i2>=0 ){\n    if( i1>=0 && (i2<0 || iRowid1<iRowid2) ){\n      assert( iOut==0 || iRowid1>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid1 - iOut);\n      iOut = iRowid1;\n      fts5NextRowid(p1, &i1, &iRowid1);\n    }else{\n      assert( iOut==0 || iRowid2>iOut );\n      fts5BufferSafeAppendVarint(&out, iRowid2 - iOut);\n      iOut = iRowid2;\n      if( i1>=0 && iRowid1==iRowid2 ){\n        fts5NextRowid(p1, &i1, &iRowid1);\n      }\n      fts5NextRowid(p2, &i2, &iRowid2);\n    }\n  }\n\n  fts5BufferSwap(&out, p1);\n  fts5BufferFree(&out);\n}\n\n/*\n** Buffers p1 and p2 contain doclists. This function merges the content\n** of the two doclists together and sets buffer p1 to the result before\n** returning.\n**\n** If an error occurs, an error code is left in p->rc. If an error has\n** already occurred, this function is a no-op.\n*/\nstatic void fts5MergePrefixLists(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5Buffer *p1,                 /* First list to merge */\n  Fts5Buffer *p2                  /* Second list to merge */\n){\n  if( p2->n ){\n    i64 iLastRowid = 0;\n    Fts5DoclistIter i1;\n    Fts5DoclistIter i2;\n    Fts5Buffer out = {0, 0, 0};\n    Fts5Buffer tmp = {0, 0, 0};\n\n    if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n) ) return;\n    fts5DoclistIterInit(p1, &i1);\n    fts5DoclistIterInit(p2, &i2);\n\n    while( 1 ){\n      if( i1.iRowid<i2.iRowid ){\n        /* Copy entry from i1 */\n        fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n        fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.nPoslist+i1.nSize);\n        fts5DoclistIterNext(&i1);\n        if( i1.aPoslist==0 ) break;\n      }\n      else if( i2.iRowid!=i1.iRowid ){\n        /* Copy entry from i2 */\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.nPoslist+i2.nSize);\n        fts5DoclistIterNext(&i2);\n        if( i2.aPoslist==0 ) break;\n      }\n      else{\n        /* Merge the two position lists. */ \n        i64 iPos1 = 0;\n        i64 iPos2 = 0;\n        int iOff1 = 0;\n        int iOff2 = 0;\n        u8 *a1 = &i1.aPoslist[i1.nSize];\n        u8 *a2 = &i2.aPoslist[i2.nSize];\n\n        i64 iPrev = 0;\n        Fts5PoslistWriter writer;\n        memset(&writer, 0, sizeof(writer));\n\n        fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n        fts5BufferZero(&tmp);\n        sqlite3Fts5BufferSize(&p->rc, &tmp, i1.nPoslist + i2.nPoslist);\n        if( p->rc ) break;\n\n        sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        assert( iPos1>=0 && iPos2>=0 );\n\n        if( iPos1<iPos2 ){\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n        }else{\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n        }\n\n        if( iPos1>=0 && iPos2>=0 ){\n          while( 1 ){\n            if( iPos1<iPos2 ){\n              if( iPos1!=iPrev ){\n                sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n              }\n              sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);\n              if( iPos1<0 ) break;\n            }else{\n              assert( iPos2!=iPrev );\n              sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n              sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);\n              if( iPos2<0 ) break;\n            }\n          }\n        }\n\n        if( iPos1>=0 ){\n          if( iPos1!=iPrev ){\n            sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);\n          }\n          fts5BufferSafeAppendBlob(&tmp, &a1[iOff1], i1.nPoslist-iOff1);\n        }else{\n          assert( iPos2>=0 && iPos2!=iPrev );\n          sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);\n          fts5BufferSafeAppendBlob(&tmp, &a2[iOff2], i2.nPoslist-iOff2);\n        }\n\n        /* WRITEPOSLISTSIZE */\n        fts5BufferSafeAppendVarint(&out, tmp.n * 2);\n        fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);\n        fts5DoclistIterNext(&i1);\n        fts5DoclistIterNext(&i2);\n        if( i1.aPoslist==0 || i2.aPoslist==0 ) break;\n      }\n    }\n\n    if( i1.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid);\n      fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.aEof - i1.aPoslist);\n    }\n    else if( i2.aPoslist ){\n      fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);\n      fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);\n    }\n\n    fts5BufferSet(&p->rc, p1, out.n, out.p);\n    fts5BufferFree(&tmp);\n    fts5BufferFree(&out);\n  }\n}\n\nstatic void fts5SetupPrefixIter(\n  Fts5Index *p,                   /* Index to read from */\n  int bDesc,                      /* True for \"ORDER BY rowid DESC\" */\n  const u8 *pToken,               /* Buffer containing prefix to match */\n  int nToken,                     /* Size of buffer pToken in bytes */\n  Fts5Colset *pColset,            /* Restrict matches to these columns */\n  Fts5Iter **ppIter          /* OUT: New iterator */\n){\n  Fts5Structure *pStruct;\n  Fts5Buffer *aBuf;\n  const int nBuf = 32;\n\n  void (*xMerge)(Fts5Index*, Fts5Buffer*, Fts5Buffer*);\n  void (*xAppend)(Fts5Index*, i64, Fts5Iter*, Fts5Buffer*);\n  if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){\n    xMerge = fts5MergeRowidLists;\n    xAppend = fts5AppendRowid;\n  }else{\n    xMerge = fts5MergePrefixLists;\n    xAppend = fts5AppendPoslist;\n  }\n\n  aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf);\n  pStruct = fts5StructureRead(p);\n\n  if( aBuf && pStruct ){\n    const int flags = FTS5INDEX_QUERY_SCAN \n                    | FTS5INDEX_QUERY_SKIPEMPTY \n                    | FTS5INDEX_QUERY_NOOUTPUT;\n    int i;\n    i64 iLastRowid = 0;\n    Fts5Iter *p1 = 0;     /* Iterator used to gather data from index */\n    Fts5Data *pData;\n    Fts5Buffer doclist;\n    int bNewTerm = 1;\n\n    memset(&doclist, 0, sizeof(doclist));\n    fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1);\n    fts5IterSetOutputCb(&p->rc, p1);\n    for( /* no-op */ ;\n        fts5MultiIterEof(p, p1)==0;\n        fts5MultiIterNext2(p, p1, &bNewTerm)\n    ){\n      Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];\n      int nTerm = pSeg->term.n;\n      const u8 *pTerm = pSeg->term.p;\n      p1->xSetOutputs(p1, pSeg);\n\n      assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 );\n      if( bNewTerm ){\n        if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break;\n      }\n\n      if( p1->base.nData==0 ) continue;\n\n      if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){\n        for(i=0; p->rc==SQLITE_OK && doclist.n; i++){\n          assert( i<nBuf );\n          if( aBuf[i].n==0 ){\n            fts5BufferSwap(&doclist, &aBuf[i]);\n            fts5BufferZero(&doclist);\n          }else{\n            xMerge(p, &doclist, &aBuf[i]);\n            fts5BufferZero(&aBuf[i]);\n          }\n        }\n        iLastRowid = 0;\n      }\n\n      xAppend(p, p1->base.iRowid-iLastRowid, p1, &doclist);\n      iLastRowid = p1->base.iRowid;\n    }\n\n    for(i=0; i<nBuf; i++){\n      if( p->rc==SQLITE_OK ){\n        xMerge(p, &doclist, &aBuf[i]);\n      }\n      fts5BufferFree(&aBuf[i]);\n    }\n    fts5MultiIterFree(p1);\n\n    pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);\n    if( pData ){\n      pData->p = (u8*)&pData[1];\n      pData->nn = pData->szLeaf = doclist.n;\n      if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);\n      fts5MultiIterNew2(p, pData, bDesc, ppIter);\n    }\n    fts5BufferFree(&doclist);\n  }\n\n  fts5StructureRelease(pStruct);\n  sqlite3_free(aBuf);\n}\n\n\n/*\n** Indicate that all subsequent calls to sqlite3Fts5IndexWrite() pertain\n** to the document with rowid iRowid.\n*/\nstatic int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){\n  assert( p->rc==SQLITE_OK );\n\n  /* Allocate the hash table if it has not already been allocated */\n  if( p->pHash==0 ){\n    p->rc = sqlite3Fts5HashNew(p->pConfig, &p->pHash, &p->nPendingData);\n  }\n\n  /* Flush the hash table to disk if required */\n  if( iRowid<p->iWriteRowid \n   || (iRowid==p->iWriteRowid && p->bDelete==0)\n   || (p->nPendingData > p->pConfig->nHashSize) \n  ){\n    fts5IndexFlush(p);\n  }\n\n  p->iWriteRowid = iRowid;\n  p->bDelete = bDelete;\n  return fts5IndexReturn(p);\n}\n\n/*\n** Commit data to disk.\n*/\nstatic int sqlite3Fts5IndexSync(Fts5Index *p){\n  assert( p->rc==SQLITE_OK );\n  fts5IndexFlush(p);\n  fts5CloseReader(p);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Discard any data stored in the in-memory hash tables. Do not write it\n** to the database. Additionally, assume that the contents of the %_data\n** table may have changed on disk. So any in-memory caches of %_data \n** records must be invalidated.\n*/\nstatic int sqlite3Fts5IndexRollback(Fts5Index *p){\n  fts5CloseReader(p);\n  fts5IndexDiscardData(p);\n  fts5StructureInvalidate(p);\n  /* assert( p->rc==SQLITE_OK ); */\n  return SQLITE_OK;\n}\n\n/*\n** The %_data table is completely empty when this function is called. This\n** function populates it with the initial structure objects for each index,\n** and the initial version of the \"averages\" record (a zero-byte blob).\n*/\nstatic int sqlite3Fts5IndexReinit(Fts5Index *p){\n  Fts5Structure s;\n  fts5StructureInvalidate(p);\n  memset(&s, 0, sizeof(Fts5Structure));\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, (const u8*)\"\", 0);\n  fts5StructureWrite(p, &s);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying %_data table.\n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nstatic int sqlite3Fts5IndexOpen(\n  Fts5Config *pConfig, \n  int bCreate, \n  Fts5Index **pp,\n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  Fts5Index *p;                   /* New object */\n\n  *pp = p = (Fts5Index*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Index));\n  if( rc==SQLITE_OK ){\n    p->pConfig = pConfig;\n    p->nWorkUnit = FTS5_WORK_UNIT;\n    p->zDataTbl = sqlite3Fts5Mprintf(&rc, \"%s_data\", pConfig->zName);\n    if( p->zDataTbl && bCreate ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"data\", \"id INTEGER PRIMARY KEY, block BLOB\", 0, pzErr\n      );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5CreateTable(pConfig, \"idx\", \n            \"segid, term, pgno, PRIMARY KEY(segid, term)\", \n            1, pzErr\n        );\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3Fts5IndexReinit(p);\n      }\n    }\n  }\n\n  assert( rc!=SQLITE_OK || p->rc==SQLITE_OK );\n  if( rc ){\n    sqlite3Fts5IndexClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5IndexOpen().\n*/\nstatic int sqlite3Fts5IndexClose(Fts5Index *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( p->pReader==0 );\n    fts5StructureInvalidate(p);\n    sqlite3_finalize(p->pWriter);\n    sqlite3_finalize(p->pDeleter);\n    sqlite3_finalize(p->pIdxWriter);\n    sqlite3_finalize(p->pIdxDeleter);\n    sqlite3_finalize(p->pIdxSelect);\n    sqlite3_finalize(p->pDataVersion);\n    sqlite3Fts5HashFree(p->pHash);\n    sqlite3_free(p->zDataTbl);\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\n/*\n** Argument p points to a buffer containing utf-8 text that is n bytes in \n** size. Return the number of bytes in the nChar character prefix of the\n** buffer, or 0 if there are less than nChar characters in total.\n*/\nstatic int sqlite3Fts5IndexCharlenToBytelen(\n  const char *p, \n  int nByte, \n  int nChar\n){\n  int n = 0;\n  int i;\n  for(i=0; i<nChar; i++){\n    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */\n    if( (unsigned char)p[n++]>=0xc0 ){\n      while( (p[n] & 0xc0)==0x80 ) n++;\n    }\n  }\n  return n;\n}\n\n/*\n** pIn is a UTF-8 encoded string, nIn bytes in size. Return the number of\n** unicode characters in the string.\n*/\nstatic int fts5IndexCharlen(const char *pIn, int nIn){\n  int nChar = 0;            \n  int i = 0;\n  while( i<nIn ){\n    if( (unsigned char)pIn[i++]>=0xc0 ){\n      while( i<nIn && (pIn[i] & 0xc0)==0x80 ) i++;\n    }\n    nChar++;\n  }\n  return nChar;\n}\n\n/*\n** Insert or remove data to or from the index. Each time a document is \n** added to or removed from the index, this function is called one or more\n** times.\n**\n** For an insert, it must be called once for each token in the new document.\n** If the operation is a delete, it must be called (at least) once for each\n** unique token in the document with an iCol value less than zero. The iPos\n** argument is ignored for a delete.\n*/\nstatic int sqlite3Fts5IndexWrite(\n  Fts5Index *p,                   /* Index to write to */\n  int iCol,                       /* Column token appears in (-ve -> delete) */\n  int iPos,                       /* Position of token within column */\n  const char *pToken, int nToken  /* Token to add or remove to or from index */\n){\n  int i;                          /* Used to iterate through indexes */\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = p->pConfig;\n\n  assert( p->rc==SQLITE_OK );\n  assert( (iCol<0)==p->bDelete );\n\n  /* Add the entry to the main terms index. */\n  rc = sqlite3Fts5HashWrite(\n      p->pHash, p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX, pToken, nToken\n  );\n\n  for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){\n    const int nChar = pConfig->aPrefix[i];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5HashWrite(p->pHash, \n          p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken,\n          nByte\n      );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Open a new iterator to iterate though all rowid that match the \n** specified token or token prefix.\n*/\nstatic int sqlite3Fts5IndexQuery(\n  Fts5Index *p,                   /* FTS index to query */\n  const char *pToken, int nToken, /* Token (or prefix) to query for */\n  int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */\n  Fts5Colset *pColset,            /* Match these columns only */\n  Fts5IndexIter **ppIter          /* OUT: New iterator object */\n){\n  Fts5Config *pConfig = p->pConfig;\n  Fts5Iter *pRet = 0;\n  Fts5Buffer buf = {0, 0, 0};\n\n  /* If the QUERY_SCAN flag is set, all other flags must be clear. */\n  assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN );\n\n  if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){\n    int iIdx = 0;                 /* Index to search */\n    if( nToken ) memcpy(&buf.p[1], pToken, nToken);\n\n    /* Figure out which index to search and set iIdx accordingly. If this\n    ** is a prefix query for which there is no prefix index, set iIdx to\n    ** greater than pConfig->nPrefix to indicate that the query will be\n    ** satisfied by scanning multiple terms in the main index.\n    **\n    ** If the QUERY_TEST_NOIDX flag was specified, then this must be a\n    ** prefix-query. Instead of using a prefix-index (if one exists), \n    ** evaluate the prefix query using the main FTS index. This is used\n    ** for internal sanity checking by the integrity-check in debug \n    ** mode only.  */\n#ifdef SQLITE_DEBUG\n    if( pConfig->bPrefixIndex==0 || (flags & FTS5INDEX_QUERY_TEST_NOIDX) ){\n      assert( flags & FTS5INDEX_QUERY_PREFIX );\n      iIdx = 1+pConfig->nPrefix;\n    }else\n#endif\n    if( flags & FTS5INDEX_QUERY_PREFIX ){\n      int nChar = fts5IndexCharlen(pToken, nToken);\n      for(iIdx=1; iIdx<=pConfig->nPrefix; iIdx++){\n        if( pConfig->aPrefix[iIdx-1]==nChar ) break;\n      }\n    }\n\n    if( iIdx<=pConfig->nPrefix ){\n      /* Straight index lookup */\n      Fts5Structure *pStruct = fts5StructureRead(p);\n      buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx);\n      if( pStruct ){\n        fts5MultiIterNew(p, pStruct, flags | FTS5INDEX_QUERY_SKIPEMPTY, \n            pColset, buf.p, nToken+1, -1, 0, &pRet\n        );\n        fts5StructureRelease(pStruct);\n      }\n    }else{\n      /* Scan multiple terms in the main index */\n      int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;\n      buf.p[0] = FTS5_MAIN_PREFIX;\n      fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet);\n      assert( p->rc!=SQLITE_OK || pRet->pColset==0 );\n      fts5IterSetOutputCb(&p->rc, pRet);\n      if( p->rc==SQLITE_OK ){\n        Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst];\n        if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg);\n      }\n    }\n\n    if( p->rc ){\n      sqlite3Fts5IterClose((Fts5IndexIter*)pRet);\n      pRet = 0;\n      fts5CloseReader(p);\n    }\n\n    *ppIter = &pRet->base;\n    sqlite3Fts5BufferFree(&buf);\n  }\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return true if the iterator passed as the only argument is at EOF.\n*/\n/*\n** Move to the next matching rowid. \n*/\nstatic int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  assert( pIter->pIndex->rc==SQLITE_OK );\n  fts5MultiIterNext(pIter->pIndex, pIter, 0, 0);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching term/rowid. Used by the fts5vocab module.\n*/\nstatic int sqlite3Fts5IterNextScan(Fts5IndexIter *pIndexIter){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  Fts5Index *p = pIter->pIndex;\n\n  assert( pIter->pIndex->rc==SQLITE_OK );\n\n  fts5MultiIterNext(p, pIter, 0, 0);\n  if( p->rc==SQLITE_OK ){\n    Fts5SegIter *pSeg = &pIter->aSeg[ pIter->aFirst[1].iFirst ];\n    if( pSeg->pLeaf && pSeg->term.p[0]!=FTS5_MAIN_PREFIX ){\n      fts5DataRelease(pSeg->pLeaf);\n      pSeg->pLeaf = 0;\n      pIter->base.bEof = 1;\n    }\n  }\n\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Move to the next matching rowid that occurs at or after iMatch. The\n** definition of \"at or after\" depends on whether this iterator iterates\n** in ascending or descending rowid order.\n*/\nstatic int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){\n  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n  fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch);\n  return fts5IndexReturn(pIter->pIndex);\n}\n\n/*\n** Return the current term.\n*/\nstatic const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){\n  int n;\n  const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n);\n  *pn = n-1;\n  return &z[1];\n}\n\n/*\n** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().\n*/\nstatic void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){\n  if( pIndexIter ){\n    Fts5Iter *pIter = (Fts5Iter*)pIndexIter;\n    Fts5Index *pIndex = pIter->pIndex;\n    fts5MultiIterFree(pIter);\n    fts5CloseReader(pIndex);\n  }\n}\n\n/*\n** Read and decode the \"averages\" record from the database. \n**\n** Parameter anSize must point to an array of size nCol, where nCol is\n** the number of user defined columns in the FTS table.\n*/\nstatic int sqlite3Fts5IndexGetAverages(Fts5Index *p, i64 *pnRow, i64 *anSize){\n  int nCol = p->pConfig->nCol;\n  Fts5Data *pData;\n\n  *pnRow = 0;\n  memset(anSize, 0, sizeof(i64) * nCol);\n  pData = fts5DataRead(p, FTS5_AVERAGES_ROWID);\n  if( p->rc==SQLITE_OK && pData->nn ){\n    int i = 0;\n    int iCol;\n    i += fts5GetVarint(&pData->p[i], (u64*)pnRow);\n    for(iCol=0; i<pData->nn && iCol<nCol; iCol++){\n      i += fts5GetVarint(&pData->p[i], (u64*)&anSize[iCol]);\n    }\n  }\n\n  fts5DataRelease(pData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Replace the current \"averages\" record with the contents of the buffer \n** supplied as the second argument.\n*/\nstatic int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8 *pData, int nData){\n  assert( p->rc==SQLITE_OK );\n  fts5DataWrite(p, FTS5_AVERAGES_ROWID, pData, nData);\n  return fts5IndexReturn(p);\n}\n\n/*\n** Return the total number of blocks this module has read from the %_data\n** table since it was created.\n*/\nstatic int sqlite3Fts5IndexReads(Fts5Index *p){\n  return p->nRead;\n}\n\n/*\n** Set the 32-bit cookie value stored at the start of all structure \n** records to the value passed as the second argument.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int sqlite3Fts5IndexSetCookie(Fts5Index *p, int iNew){\n  int rc;                              /* Return code */\n  Fts5Config *pConfig = p->pConfig;    /* Configuration object */\n  u8 aCookie[4];                       /* Binary representation of iNew */\n  sqlite3_blob *pBlob = 0;\n\n  assert( p->rc==SQLITE_OK );\n  sqlite3Fts5Put32(aCookie, iNew);\n\n  rc = sqlite3_blob_open(pConfig->db, pConfig->zDb, p->zDataTbl, \n      \"block\", FTS5_STRUCTURE_ROWID, 1, &pBlob\n  );\n  if( rc==SQLITE_OK ){\n    sqlite3_blob_write(pBlob, aCookie, 4, 0);\n    rc = sqlite3_blob_close(pBlob);\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5IndexLoadConfig(Fts5Index *p){\n  Fts5Structure *pStruct;\n  pStruct = fts5StructureRead(p);\n  fts5StructureRelease(pStruct);\n  return fts5IndexReturn(p);\n}\n\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the integrity-check \n** functionality.\n*/\n\n/*\n** Return a simple checksum value based on the arguments.\n*/\nstatic u64 sqlite3Fts5IndexEntryCksum(\n  i64 iRowid, \n  int iCol, \n  int iPos, \n  int iIdx,\n  const char *pTerm,\n  int nTerm\n){\n  int i;\n  u64 ret = iRowid;\n  ret += (ret<<3) + iCol;\n  ret += (ret<<3) + iPos;\n  if( iIdx>=0 ) ret += (ret<<3) + (FTS5_MAIN_PREFIX + iIdx);\n  for(i=0; i<nTerm; i++) ret += (ret<<3) + pTerm[i];\n  return ret;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function is purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n**\n** Instead, it tests that the same set of pgno/rowid combinations are \n** visited regardless of whether the doclist-index identified by parameters\n** iSegid/iLeaf is iterated in forwards or reverse order.\n*/\nstatic void fts5TestDlidxReverse(\n  Fts5Index *p, \n  int iSegid,                     /* Segment id to load from */\n  int iLeaf                       /* Load doclist-index for this leaf */\n){\n  Fts5DlidxIter *pDlidx = 0;\n  u64 cksum1 = 13;\n  u64 cksum2 = 13;\n\n  for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterNext(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( pgno>iLeaf );\n    cksum1 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  for(pDlidx=fts5DlidxIterInit(p, 1, iSegid, iLeaf);\n      fts5DlidxIterEof(p, pDlidx)==0;\n      fts5DlidxIterPrev(p, pDlidx)\n  ){\n    i64 iRowid = fts5DlidxIterRowid(pDlidx);\n    int pgno = fts5DlidxIterPgno(pDlidx);\n    assert( fts5DlidxIterPgno(pDlidx)>iLeaf );\n    cksum2 += iRowid + ((i64)pgno<<32);\n  }\n  fts5DlidxIterFree(pDlidx);\n  pDlidx = 0;\n\n  if( p->rc==SQLITE_OK && cksum1!=cksum2 ) p->rc = FTS5_CORRUPT;\n}\n\nstatic int fts5QueryCksum(\n  Fts5Index *p,                   /* Fts5 index object */\n  int iIdx,\n  const char *z,                  /* Index key to query for */\n  int n,                          /* Size of index key in bytes */\n  int flags,                      /* Flags for Fts5IndexQuery */\n  u64 *pCksum                     /* IN/OUT: Checksum value */\n){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum = *pCksum;\n  Fts5IndexIter *pIter = 0;\n  int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter);\n\n  while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){\n    i64 rowid = pIter->iRowid;\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      cksum ^= sqlite3Fts5IndexEntryCksum(rowid, 0, 0, iIdx, z, n);\n    }else{\n      Fts5PoslistReader sReader;\n      for(sqlite3Fts5PoslistReaderInit(pIter->pData, pIter->nData, &sReader);\n          sReader.bEof==0;\n          sqlite3Fts5PoslistReaderNext(&sReader)\n      ){\n        int iCol = FTS5_POS2COLUMN(sReader.iPos);\n        int iOff = FTS5_POS2OFFSET(sReader.iPos);\n        cksum ^= sqlite3Fts5IndexEntryCksum(rowid, iCol, iOff, iIdx, z, n);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5IterNext(pIter);\n    }\n  }\n  sqlite3Fts5IterClose(pIter);\n\n  *pCksum = cksum;\n  return rc;\n}\n\n\n/*\n** This function is also purely an internal test. It does not contribute to \n** FTS functionality, or even the integrity-check, in any way.\n*/\nstatic void fts5TestTerm(\n  Fts5Index *p, \n  Fts5Buffer *pPrev,              /* Previous term */\n  const char *z, int n,           /* Possibly new term to test */\n  u64 expected,\n  u64 *pCksum\n){\n  int rc = p->rc;\n  if( pPrev->n==0 ){\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n  }else\n  if( rc==SQLITE_OK && (pPrev->n!=n || memcmp(pPrev->p, z, n)) ){\n    u64 cksum3 = *pCksum;\n    const char *zTerm = (const char*)&pPrev->p[1];  /* term sans prefix-byte */\n    int nTerm = pPrev->n-1;            /* Size of zTerm in bytes */\n    int iIdx = (pPrev->p[0] - FTS5_MAIN_PREFIX);\n    int flags = (iIdx==0 ? 0 : FTS5INDEX_QUERY_PREFIX);\n    u64 ck1 = 0;\n    u64 ck2 = 0;\n\n    /* Check that the results returned for ASC and DESC queries are\n    ** the same. If not, call this corruption.  */\n    rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, flags, &ck1);\n    if( rc==SQLITE_OK ){\n      int f = flags|FTS5INDEX_QUERY_DESC;\n      rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n    }\n    if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n\n    /* If this is a prefix query, check that the results returned if the\n    ** the index is disabled are the same. In both ASC and DESC order. \n    **\n    ** This check may only be performed if the hash table is empty. This\n    ** is because the hash table only supports a single scan query at\n    ** a time, and the multi-iter loop from which this function is called\n    ** is already performing such a scan. */\n    if( p->nPendingData==0 ){\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n      if( iIdx>0 && rc==SQLITE_OK ){\n        int f = flags|FTS5INDEX_QUERY_TEST_NOIDX|FTS5INDEX_QUERY_DESC;\n        ck2 = 0;\n        rc = fts5QueryCksum(p, iIdx, zTerm, nTerm, f, &ck2);\n        if( rc==SQLITE_OK && ck1!=ck2 ) rc = FTS5_CORRUPT;\n      }\n    }\n\n    cksum3 ^= ck1;\n    fts5BufferSet(&rc, pPrev, n, (const u8*)z);\n\n    if( rc==SQLITE_OK && cksum3!=expected ){\n      rc = FTS5_CORRUPT;\n    }\n    *pCksum = cksum3;\n  }\n  p->rc = rc;\n}\n \n#else\n# define fts5TestDlidxReverse(x,y,z)\n# define fts5TestTerm(u,v,w,x,y,z)\n#endif\n\n/*\n** Check that:\n**\n**   1) All leaves of pSeg between iFirst and iLast (inclusive) exist and\n**      contain zero terms.\n**   2) All leaves of pSeg between iNoRowid and iLast (inclusive) exist and\n**      contain zero rowids.\n*/\nstatic void fts5IndexIntegrityCheckEmpty(\n  Fts5Index *p,\n  Fts5StructureSegment *pSeg,     /* Segment to check internal consistency */\n  int iFirst,\n  int iNoRowid,\n  int iLast\n){\n  int i;\n\n  /* Now check that the iter.nEmpty leaves following the current leaf\n  ** (a) exist and (b) contain no terms. */\n  for(i=iFirst; p->rc==SQLITE_OK && i<=iLast; i++){\n    Fts5Data *pLeaf = fts5DataRead(p, FTS5_SEGMENT_ROWID(pSeg->iSegid, i));\n    if( pLeaf ){\n      if( !fts5LeafIsTermless(pLeaf) ) p->rc = FTS5_CORRUPT;\n      if( i>=iNoRowid && 0!=fts5LeafFirstRowidOff(pLeaf) ) p->rc = FTS5_CORRUPT;\n    }\n    fts5DataRelease(pLeaf);\n  }\n}\n\nstatic void fts5IntegrityCheckPgidx(Fts5Index *p, Fts5Data *pLeaf){\n  int iTermOff = 0;\n  int ii;\n\n  Fts5Buffer buf1 = {0,0,0};\n  Fts5Buffer buf2 = {0,0,0};\n\n  ii = pLeaf->szLeaf;\n  while( ii<pLeaf->nn && p->rc==SQLITE_OK ){\n    int res;\n    int iOff;\n    int nIncr;\n\n    ii += fts5GetVarint32(&pLeaf->p[ii], nIncr);\n    iTermOff += nIncr;\n    iOff = iTermOff;\n\n    if( iOff>=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else if( iTermOff==nIncr ){\n      int nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        fts5BufferSet(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n    }else{\n      int nKeep, nByte;\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nKeep);\n      iOff += fts5GetVarint32(&pLeaf->p[iOff], nByte);\n      if( nKeep>buf1.n || (iOff+nByte)>pLeaf->szLeaf ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        buf1.n = nKeep;\n        fts5BufferAppendBlob(&p->rc, &buf1, nByte, &pLeaf->p[iOff]);\n      }\n\n      if( p->rc==SQLITE_OK ){\n        res = fts5BufferCompare(&buf1, &buf2);\n        if( res<=0 ) p->rc = FTS5_CORRUPT;\n      }\n    }\n    fts5BufferSet(&p->rc, &buf2, buf1.n, buf1.p);\n  }\n\n  fts5BufferFree(&buf1);\n  fts5BufferFree(&buf2);\n}\n\nstatic void fts5IndexIntegrityCheckSegment(\n  Fts5Index *p,                   /* FTS5 backend object */\n  Fts5StructureSegment *pSeg      /* Segment to check internal consistency */\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pStmt = 0;\n  int rc2;\n  int iIdxPrevLeaf = pSeg->pgnoFirst-1;\n  int iDlidxPrevLeaf = pSeg->pgnoLast;\n\n  if( pSeg->pgnoFirst==0 ) return;\n\n  fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(\n      \"SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d\",\n      pConfig->zDb, pConfig->zName, pSeg->iSegid\n  ));\n\n  /* Iterate through the b-tree hierarchy.  */\n  while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){\n    i64 iRow;                     /* Rowid for this leaf */\n    Fts5Data *pLeaf;              /* Data for this leaf */\n\n    int nIdxTerm = sqlite3_column_bytes(pStmt, 1);\n    const char *zIdxTerm = (const char*)sqlite3_column_text(pStmt, 1);\n    int iIdxLeaf = sqlite3_column_int(pStmt, 2);\n    int bIdxDlidx = sqlite3_column_int(pStmt, 3);\n\n    /* If the leaf in question has already been trimmed from the segment, \n    ** ignore this b-tree entry. Otherwise, load it into memory. */\n    if( iIdxLeaf<pSeg->pgnoFirst ) continue;\n    iRow = FTS5_SEGMENT_ROWID(pSeg->iSegid, iIdxLeaf);\n    pLeaf = fts5LeafRead(p, iRow);\n    if( pLeaf==0 ) break;\n\n    /* Check that the leaf contains at least one term, and that it is equal\n    ** to or larger than the split-key in zIdxTerm.  Also check that if there\n    ** is also a rowid pointer within the leaf page header, it points to a\n    ** location before the term.  */\n    if( pLeaf->nn<=pLeaf->szLeaf ){\n      p->rc = FTS5_CORRUPT;\n    }else{\n      int iOff;                   /* Offset of first term on leaf */\n      int iRowidOff;              /* Offset of first rowid on leaf */\n      int nTerm;                  /* Size of term on leaf in bytes */\n      int res;                    /* Comparison of term and split-key */\n\n      iOff = fts5LeafFirstTermOff(pLeaf);\n      iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n      if( iRowidOff>=iOff ){\n        p->rc = FTS5_CORRUPT;\n      }else{\n        iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);\n        res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));\n        if( res==0 ) res = nTerm - nIdxTerm;\n        if( res<0 ) p->rc = FTS5_CORRUPT;\n      }\n\n      fts5IntegrityCheckPgidx(p, pLeaf);\n    }\n    fts5DataRelease(pLeaf);\n    if( p->rc ) break;\n\n    /* Now check that the iter.nEmpty leaves following the current leaf\n    ** (a) exist and (b) contain no terms. */\n    fts5IndexIntegrityCheckEmpty(\n        p, pSeg, iIdxPrevLeaf+1, iDlidxPrevLeaf+1, iIdxLeaf-1\n    );\n    if( p->rc ) break;\n\n    /* If there is a doclist-index, check that it looks right. */\n    if( bIdxDlidx ){\n      Fts5DlidxIter *pDlidx = 0;  /* For iterating through doclist index */\n      int iPrevLeaf = iIdxLeaf;\n      int iSegid = pSeg->iSegid;\n      int iPg = 0;\n      i64 iKey;\n\n      for(pDlidx=fts5DlidxIterInit(p, 0, iSegid, iIdxLeaf);\n          fts5DlidxIterEof(p, pDlidx)==0;\n          fts5DlidxIterNext(p, pDlidx)\n      ){\n\n        /* Check any rowid-less pages that occur before the current leaf. */\n        for(iPg=iPrevLeaf+1; iPg<fts5DlidxIterPgno(pDlidx); iPg++){\n          iKey = FTS5_SEGMENT_ROWID(iSegid, iPg);\n          pLeaf = fts5DataRead(p, iKey);\n          if( pLeaf ){\n            if( fts5LeafFirstRowidOff(pLeaf)!=0 ) p->rc = FTS5_CORRUPT;\n            fts5DataRelease(pLeaf);\n          }\n        }\n        iPrevLeaf = fts5DlidxIterPgno(pDlidx);\n\n        /* Check that the leaf page indicated by the iterator really does\n        ** contain the rowid suggested by the same. */\n        iKey = FTS5_SEGMENT_ROWID(iSegid, iPrevLeaf);\n        pLeaf = fts5DataRead(p, iKey);\n        if( pLeaf ){\n          i64 iRowid;\n          int iRowidOff = fts5LeafFirstRowidOff(pLeaf);\n          ASSERT_SZLEAF_OK(pLeaf);\n          if( iRowidOff>=pLeaf->szLeaf ){\n            p->rc = FTS5_CORRUPT;\n          }else{\n            fts5GetVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);\n            if( iRowid!=fts5DlidxIterRowid(pDlidx) ) p->rc = FTS5_CORRUPT;\n          }\n          fts5DataRelease(pLeaf);\n        }\n      }\n\n      iDlidxPrevLeaf = iPg;\n      fts5DlidxIterFree(pDlidx);\n      fts5TestDlidxReverse(p, iSegid, iIdxLeaf);\n    }else{\n      iDlidxPrevLeaf = pSeg->pgnoLast;\n      /* TODO: Check there is no doclist index */\n    }\n\n    iIdxPrevLeaf = iIdxLeaf;\n  }\n\n  rc2 = sqlite3_finalize(pStmt);\n  if( p->rc==SQLITE_OK ) p->rc = rc2;\n\n  /* Page iter.iLeaf must now be the rightmost leaf-page in the segment */\n#if 0\n  if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){\n    p->rc = FTS5_CORRUPT;\n  }\n#endif\n}\n\n\n/*\n** Run internal checks to ensure that the FTS index (a) is internally \n** consistent and (b) contains entries for which the XOR of the checksums\n** as calculated by sqlite3Fts5IndexEntryCksum() is cksum.\n**\n** Return SQLITE_CORRUPT if any of the internal checks fail, or if the\n** checksum does not match. Return SQLITE_OK if all checks pass without\n** error, or some other SQLite error code if another error (e.g. OOM)\n** occurs.\n*/\nstatic int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){\n  int eDetail = p->pConfig->eDetail;\n  u64 cksum2 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer poslist = {0,0,0};   /* Buffer used to hold a poslist */\n  Fts5Iter *pIter;                /* Used to iterate through entire index */\n  Fts5Structure *pStruct;         /* Index structure */\n\n#ifdef SQLITE_DEBUG\n  /* Used by extra internal tests only run if NDEBUG is not defined */\n  u64 cksum3 = 0;                 /* Checksum based on contents of indexes */\n  Fts5Buffer term = {0,0,0};      /* Buffer used to hold most recent term */\n#endif\n  const int flags = FTS5INDEX_QUERY_NOOUTPUT;\n  \n  /* Load the FTS index structure */\n  pStruct = fts5StructureRead(p);\n\n  /* Check that the internal nodes of each segment match the leaves */\n  if( pStruct ){\n    int iLvl, iSeg;\n    for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){\n      for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){\n        Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];\n        fts5IndexIntegrityCheckSegment(p, pSeg);\n      }\n    }\n  }\n\n  /* The cksum argument passed to this function is a checksum calculated\n  ** based on all expected entries in the FTS index (including prefix index\n  ** entries). This block checks that a checksum calculated based on the\n  ** actual contents of FTS index is identical.\n  **\n  ** Two versions of the same checksum are calculated. The first (stack\n  ** variable cksum2) based on entries extracted from the full-text index\n  ** while doing a linear scan of each individual index in turn. \n  **\n  ** As each term visited by the linear scans, a separate query for the\n  ** same term is performed. cksum3 is calculated based on the entries\n  ** extracted by these queries.\n  */\n  for(fts5MultiIterNew(p, pStruct, flags, 0, 0, 0, -1, 0, &pIter);\n      fts5MultiIterEof(p, pIter)==0;\n      fts5MultiIterNext(p, pIter, 0, 0)\n  ){\n    int n;                      /* Size of term in bytes */\n    i64 iPos = 0;               /* Position read from poslist */\n    int iOff = 0;               /* Offset within poslist */\n    i64 iRowid = fts5MultiIterRowid(pIter);\n    char *z = (char*)fts5MultiIterTerm(pIter, &n);\n\n    /* If this is a new term, query for it. Update cksum3 with the results. */\n    fts5TestTerm(p, &term, z, n, cksum2, &cksum3);\n\n    if( eDetail==FTS5_DETAIL_NONE ){\n      if( 0==fts5MultiIterIsEmpty(p, pIter) ){\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, 0, 0, -1, z, n);\n      }\n    }else{\n      poslist.n = 0;\n      fts5SegiterPoslist(p, &pIter->aSeg[pIter->aFirst[1].iFirst], 0, &poslist);\n      while( 0==sqlite3Fts5PoslistNext64(poslist.p, poslist.n, &iOff, &iPos) ){\n        int iCol = FTS5_POS2COLUMN(iPos);\n        int iTokOff = FTS5_POS2OFFSET(iPos);\n        cksum2 ^= sqlite3Fts5IndexEntryCksum(iRowid, iCol, iTokOff, -1, z, n);\n      }\n    }\n  }\n  fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);\n\n  fts5MultiIterFree(pIter);\n  if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;\n\n  fts5StructureRelease(pStruct);\n#ifdef SQLITE_DEBUG\n  fts5BufferFree(&term);\n#endif\n  fts5BufferFree(&poslist);\n  return fts5IndexReturn(p);\n}\n\n/*************************************************************************\n**************************************************************************\n** Below this point is the implementation of the fts5_decode() scalar\n** function only.\n*/\n\n/*\n** Decode a segment-data rowid from the %_data table. This function is\n** the opposite of macro FTS5_SEGMENT_ROWID().\n*/\nstatic void fts5DecodeRowid(\n  i64 iRowid,                     /* Rowid from %_data table */\n  int *piSegid,                   /* OUT: Segment id */\n  int *pbDlidx,                   /* OUT: Dlidx flag */\n  int *piHeight,                  /* OUT: Height */\n  int *piPgno                     /* OUT: Page number */\n){\n  *piPgno = (int)(iRowid & (((i64)1 << FTS5_DATA_PAGE_B) - 1));\n  iRowid >>= FTS5_DATA_PAGE_B;\n\n  *piHeight = (int)(iRowid & (((i64)1 << FTS5_DATA_HEIGHT_B) - 1));\n  iRowid >>= FTS5_DATA_HEIGHT_B;\n\n  *pbDlidx = (int)(iRowid & 0x0001);\n  iRowid >>= FTS5_DATA_DLI_B;\n\n  *piSegid = (int)(iRowid & (((i64)1 << FTS5_DATA_ID_B) - 1));\n}\n\nstatic void fts5DebugRowid(int *pRc, Fts5Buffer *pBuf, i64 iKey){\n  int iSegid, iHeight, iPgno, bDlidx;       /* Rowid compenents */\n  fts5DecodeRowid(iKey, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  if( iSegid==0 ){\n    if( iKey==FTS5_AVERAGES_ROWID ){\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{averages} \");\n    }else{\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{structure}\");\n    }\n  }\n  else{\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"{%ssegid=%d h=%d pgno=%d}\",\n        bDlidx ? \"dlidx \" : \"\", iSegid, iHeight, iPgno\n    );\n  }\n}\n\nstatic void fts5DebugStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  Fts5Structure *p\n){\n  int iLvl, iSeg;                 /* Iterate through levels, segments */\n\n  for(iLvl=0; iLvl<p->nLevel; iLvl++){\n    Fts5StructureLevel *pLvl = &p->aLevel[iLvl];\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \n        \" {lvl=%d nMerge=%d nSeg=%d\", iLvl, pLvl->nMerge, pLvl->nSeg\n    );\n    for(iSeg=0; iSeg<pLvl->nSeg; iSeg++){\n      Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" {id=%d leaves=%d..%d}\", \n          pSeg->iSegid, pSeg->pgnoFirst, pSeg->pgnoLast\n      );\n    }\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"}\");\n  }\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain a serialized Fts5Structure object. This\n** function appends a human-readable representation of the same object\n** to the buffer passed as the second argument. \n*/\nstatic void fts5DecodeStructure(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int rc;                         /* Return code */\n  Fts5Structure *p = 0;           /* Decoded structure object */\n\n  rc = fts5StructureDecode(pBlob, nBlob, 0, &p);\n  if( rc!=SQLITE_OK ){\n    *pRc = rc;\n    return;\n  }\n\n  fts5DebugStructure(pRc, pBuf, p);\n  fts5StructureRelease(p);\n}\n\n/*\n** This is part of the fts5_decode() debugging aid.\n**\n** Arguments pBlob/nBlob contain an \"averages\" record. This function \n** appends a human-readable representation of record to the buffer passed \n** as the second argument. \n*/\nstatic void fts5DecodeAverages(\n  int *pRc,                       /* IN/OUT: error code */\n  Fts5Buffer *pBuf,\n  const u8 *pBlob, int nBlob\n){\n  int i = 0;\n  const char *zSpace = \"\";\n\n  while( i<nBlob ){\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pBlob[i], &iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \"%s%d\", zSpace, (int)iVal);\n    zSpace = \" \";\n  }\n}\n\n/*\n** Buffer (a/n) is assumed to contain a list of serialized varints. Read\n** each varint and append its string representation to buffer pBuf. Return\n** after either the input buffer is exhausted or a 0 value is read.\n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodePoslist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  int iOff = 0;\n  while( iOff<n ){\n    int iVal;\n    iOff += fts5GetVarint32(&a[iOff], iVal);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %d\", iVal);\n  }\n  return iOff;\n}\n\n/*\n** The start of buffer (a/n) contains the start of a doclist. The doclist\n** may or may not finish within the buffer. This function appends a text\n** representation of the part of the doclist that is present to buffer\n** pBuf. \n**\n** The return value is the number of bytes read from the input buffer.\n*/\nstatic int fts5DecodeDoclist(int *pRc, Fts5Buffer *pBuf, const u8 *a, int n){\n  i64 iDocid = 0;\n  int iOff = 0;\n\n  if( n>0 ){\n    iOff = sqlite3Fts5GetVarint(a, (u64*)&iDocid);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n  }\n  while( iOff<n ){\n    int nPos;\n    int bDel;\n    iOff += fts5GetPoslistSize(&a[iOff], &nPos, &bDel);\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" nPos=%d%s\", nPos, bDel?\"*\":\"\");\n    iOff += fts5DecodePoslist(pRc, pBuf, &a[iOff], MIN(n-iOff, nPos));\n    if( iOff<n ){\n      i64 iDelta;\n      iOff += sqlite3Fts5GetVarint(&a[iOff], (u64*)&iDelta);\n      iDocid += iDelta;\n      sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" id=%lld\", iDocid);\n    }\n  }\n\n  return iOff;\n}\n\n/*\n** This function is part of the fts5_decode() debugging function. It is \n** only ever used with detail=none tables.\n**\n** Buffer (pData/nData) contains a doclist in the format used by detail=none\n** tables. This function appends a human-readable version of that list to\n** buffer pBuf.\n**\n** If *pRc is other than SQLITE_OK when this function is called, it is a\n** no-op. If an OOM or other error occurs within this function, *pRc is\n** set to an SQLite error code before returning. The final state of buffer\n** pBuf is undefined in this case.\n*/\nstatic void fts5DecodeRowidList(\n  int *pRc,                       /* IN/OUT: Error code */\n  Fts5Buffer *pBuf,               /* Buffer to append text to */\n  const u8 *pData, int nData      /* Data to decode list-of-rowids from */\n){\n  int i = 0;\n  i64 iRowid = 0;\n\n  while( i<nData ){\n    const char *zApp = \"\";\n    u64 iVal;\n    i += sqlite3Fts5GetVarint(&pData[i], &iVal);\n    iRowid += iVal;\n\n    if( i<nData && pData[i]==0x00 ){\n      i++;\n      if( i<nData && pData[i]==0x00 ){\n        i++;\n        zApp = \"+\";\n      }else{\n        zApp = \"*\";\n      }\n    }\n\n    sqlite3Fts5BufferAppendPrintf(pRc, pBuf, \" %lld%s\", iRowid, zApp);\n  }\n}\n\n/*\n** The implementation of user-defined scalar function fts5_decode().\n*/\nstatic void fts5DecodeFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  i64 iRowid;                     /* Rowid for record being decoded */\n  int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */\n  const u8 *aBlob; int n;         /* Record to decode */\n  u8 *a = 0;\n  Fts5Buffer s;                   /* Build up text to return here */\n  int rc = SQLITE_OK;             /* Return code */\n  int nSpace = 0;\n  int eDetailNone = (sqlite3_user_data(pCtx)!=0);\n\n  assert( nArg==2 );\n  UNUSED_PARAM(nArg);\n  memset(&s, 0, sizeof(Fts5Buffer));\n  iRowid = sqlite3_value_int64(apVal[0]);\n\n  /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]\n  ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents\n  ** buffer overreads even if the record is corrupt.  */\n  n = sqlite3_value_bytes(apVal[1]);\n  aBlob = sqlite3_value_blob(apVal[1]);\n  nSpace = n + FTS5_DATA_ZERO_PADDING;\n  a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);\n  if( a==0 ) goto decode_out;\n  memcpy(a, aBlob, n);\n\n\n  fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);\n\n  fts5DebugRowid(&rc, &s, iRowid);\n  if( bDlidx ){\n    Fts5Data dlidx;\n    Fts5DlidxLvl lvl;\n\n    dlidx.p = a;\n    dlidx.nn = n;\n\n    memset(&lvl, 0, sizeof(Fts5DlidxLvl));\n    lvl.pData = &dlidx;\n    lvl.iLeafPgno = iPgno;\n\n    for(fts5DlidxLvlNext(&lvl); lvl.bEof==0; fts5DlidxLvlNext(&lvl)){\n      sqlite3Fts5BufferAppendPrintf(&rc, &s, \n          \" %d(%lld)\", lvl.iLeafPgno, lvl.iRowid\n      );\n    }\n  }else if( iSegid==0 ){\n    if( iRowid==FTS5_AVERAGES_ROWID ){\n      fts5DecodeAverages(&rc, &s, a, n);\n    }else{\n      fts5DecodeStructure(&rc, &s, a, n);\n    }\n  }else if( eDetailNone ){\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;\n    int iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n    int iTermOff;\n    int nKeep = 0;\n    int iOff;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    /* Decode any entries that occur before the first term. */\n    if( szLeaf<n ){\n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], iTermOff);\n    }else{\n      iTermOff = szLeaf;\n    }\n    fts5DecodeRowidList(&rc, &s, &a[4], iTermOff-4);\n\n    iOff = iTermOff;\n    while( iOff<szLeaf ){\n      int nAppend;\n\n      /* Read the term data for the next term*/\n      iOff += fts5GetVarint32(&a[iOff], nAppend);\n      term.n = nKeep;\n      fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]);\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += nAppend;\n\n      /* Figure out where the doclist for this term ends */\n      if( iPgidxOff<n ){\n        int nIncr;\n        iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nIncr);\n        iTermOff += nIncr;\n      }else{\n        iTermOff = szLeaf;\n      }\n\n      fts5DecodeRowidList(&rc, &s, &a[iOff], iTermOff-iOff);\n      iOff = iTermOff;\n      if( iOff<szLeaf ){\n        iOff += fts5GetVarint32(&a[iOff], nKeep);\n      }\n    }\n\n    fts5BufferFree(&term);\n  }else{\n    Fts5Buffer term;              /* Current term read from page */\n    int szLeaf;                   /* Offset of pgidx in a[] */\n    int iPgidxOff;\n    int iPgidxPrev = 0;           /* Previous value read from pgidx */\n    int iTermOff = 0;\n    int iRowidOff = 0;\n    int iOff;\n    int nDoclist;\n\n    memset(&term, 0, sizeof(Fts5Buffer));\n\n    if( n<4 ){\n      sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)\"corrupt\");\n      goto decode_out;\n    }else{\n      iRowidOff = fts5GetU16(&a[0]);\n      iPgidxOff = szLeaf = fts5GetU16(&a[2]);\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], iTermOff);\n      }\n    }\n\n    /* Decode the position list tail at the start of the page */\n    if( iRowidOff!=0 ){\n      iOff = iRowidOff;\n    }else if( iTermOff!=0 ){\n      iOff = iTermOff;\n    }else{\n      iOff = szLeaf;\n    }\n    fts5DecodePoslist(&rc, &s, &a[4], iOff-4);\n\n    /* Decode any more doclist data that appears on the page before the\n    ** first term. */\n    nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;\n    fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);\n\n    while( iPgidxOff<n ){\n      int bFirst = (iPgidxOff==szLeaf);     /* True for first term on page */\n      int nByte;                            /* Bytes of data */\n      int iEnd;\n      \n      iPgidxOff += fts5GetVarint32(&a[iPgidxOff], nByte);\n      iPgidxPrev += nByte;\n      iOff = iPgidxPrev;\n\n      if( iPgidxOff<n ){\n        fts5GetVarint32(&a[iPgidxOff], nByte);\n        iEnd = iPgidxPrev + nByte;\n      }else{\n        iEnd = szLeaf;\n      }\n\n      if( bFirst==0 ){\n        iOff += fts5GetVarint32(&a[iOff], nByte);\n        term.n = nByte;\n      }\n      iOff += fts5GetVarint32(&a[iOff], nByte);\n      fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);\n      iOff += nByte;\n\n      sqlite3Fts5BufferAppendPrintf(\n          &rc, &s, \" term=%.*s\", term.n, (const char*)term.p\n      );\n      iOff += fts5DecodeDoclist(&rc, &s, &a[iOff], iEnd-iOff);\n    }\n\n    fts5BufferFree(&term);\n  }\n  \n decode_out:\n  sqlite3_free(a);\n  if( rc==SQLITE_OK ){\n    sqlite3_result_text(pCtx, (const char*)s.p, s.n, SQLITE_TRANSIENT);\n  }else{\n    sqlite3_result_error_code(pCtx, rc);\n  }\n  fts5BufferFree(&s);\n}\n\n/*\n** The implementation of user-defined scalar function fts5_rowid().\n*/\nstatic void fts5RowidFunction(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args (always 2) */\n  sqlite3_value **apVal           /* Function arguments */\n){\n  const char *zArg;\n  if( nArg==0 ){\n    sqlite3_result_error(pCtx, \"should be: fts5_rowid(subject, ....)\", -1);\n  }else{\n    zArg = (const char*)sqlite3_value_text(apVal[0]);\n    if( 0==sqlite3_stricmp(zArg, \"segment\") ){\n      i64 iRowid;\n      int segid, pgno;\n      if( nArg!=3 ){\n        sqlite3_result_error(pCtx, \n            \"should be: fts5_rowid('segment', segid, pgno))\", -1\n        );\n      }else{\n        segid = sqlite3_value_int(apVal[1]);\n        pgno = sqlite3_value_int(apVal[2]);\n        iRowid = FTS5_SEGMENT_ROWID(segid, pgno);\n        sqlite3_result_int64(pCtx, iRowid);\n      }\n    }else{\n      sqlite3_result_error(pCtx, \n        \"first arg to fts5_rowid() must be 'segment'\" , -1\n      );\n    }\n  }\n}\n\n/*\n** This is called as part of registering the FTS5 module with database\n** connection db. It registers several user-defined scalar functions useful\n** with FTS5.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, some other\n** SQLite error code is returned instead.\n*/\nstatic int sqlite3Fts5IndexInit(sqlite3 *db){\n  int rc = sqlite3_create_function(\n      db, \"fts5_decode\", 2, SQLITE_UTF8, 0, fts5DecodeFunction, 0, 0\n  );\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_decode_none\", 2, \n        SQLITE_UTF8, (void*)db, fts5DecodeFunction, 0, 0\n    );\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(\n        db, \"fts5_rowid\", -1, SQLITE_UTF8, 0, fts5RowidFunction, 0, 0\n    );\n  }\n  return rc;\n}\n\n\nstatic int sqlite3Fts5IndexReset(Fts5Index *p){\n  assert( p->pStruct==0 || p->iStructVersion!=0 );\n  if( fts5IndexDataVersion(p)!=p->iStructVersion ){\n    fts5StructureInvalidate(p);\n  }\n  return fts5IndexReturn(p);\n}\n\n/*\n** 2014 Jun 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite module implementing full-text search.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** This variable is set to false when running tests for which the on disk\n** structures should not be corrupt. Otherwise, true. If it is false, extra\n** assert() conditions in the fts5 code are activated - conditions that are\n** only true if it is guaranteed that the fts5 database is not corrupt.\n*/\nSQLITE_API int sqlite3_fts5_may_be_corrupt = 1;\n\n\ntypedef struct Fts5Auxdata Fts5Auxdata;\ntypedef struct Fts5Auxiliary Fts5Auxiliary;\ntypedef struct Fts5Cursor Fts5Cursor;\ntypedef struct Fts5Sorter Fts5Sorter;\ntypedef struct Fts5Table Fts5Table;\ntypedef struct Fts5TokenizerModule Fts5TokenizerModule;\n\n/*\n** NOTES ON TRANSACTIONS: \n**\n** SQLite invokes the following virtual table methods as transactions are \n** opened and closed by the user:\n**\n**     xBegin():    Start of a new transaction.\n**     xSync():     Initial part of two-phase commit.\n**     xCommit():   Final part of two-phase commit.\n**     xRollback(): Rollback the transaction.\n**\n** Anything that is required as part of a commit that may fail is performed\n** in the xSync() callback. Current versions of SQLite ignore any errors \n** returned by xCommit().\n**\n** And as sub-transactions are opened/closed:\n**\n**     xSavepoint(int S):  Open savepoint S.\n**     xRelease(int S):    Commit and close savepoint S.\n**     xRollbackTo(int S): Rollback to start of savepoint S.\n**\n** During a write-transaction the fts5_index.c module may cache some data \n** in-memory. It is flushed to disk whenever xSync(), xRelease() or\n** xSavepoint() is called. And discarded whenever xRollback() or xRollbackTo() \n** is called.\n**\n** Additionally, if SQLITE_DEBUG is defined, an instance of the following\n** structure is used to record the current transaction state. This information\n** is not required, but it is used in the assert() statements executed by\n** function fts5CheckTransactionState() (see below).\n*/\nstruct Fts5TransactionState {\n  int eState;                     /* 0==closed, 1==open, 2==synced */\n  int iSavepoint;                 /* Number of open savepoints (0 -> none) */\n};\n\n/*\n** A single object of this type is allocated when the FTS5 module is \n** registered with a database handle. It is used to store pointers to\n** all registered FTS5 extensions - tokenizers and auxiliary functions.\n*/\nstruct Fts5Global {\n  fts5_api api;                   /* User visible part of object (see fts5.h) */\n  sqlite3 *db;                    /* Associated database connection */ \n  i64 iNextId;                    /* Used to allocate unique cursor ids */\n  Fts5Auxiliary *pAux;            /* First in list of all aux. functions */\n  Fts5TokenizerModule *pTok;      /* First in list of all tokenizer modules */\n  Fts5TokenizerModule *pDfltTok;  /* Default tokenizer module */\n  Fts5Cursor *pCsr;               /* First in list of all open cursors */\n};\n\n/*\n** Each auxiliary function registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pAux list.\n*/\nstruct Fts5Auxiliary {\n  Fts5Global *pGlobal;            /* Global context for this function */\n  char *zFunc;                    /* Function name (nul-terminated) */\n  void *pUserData;                /* User-data pointer */\n  fts5_extension_function xFunc;  /* Callback function */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5Auxiliary *pNext;           /* Next registered auxiliary function */\n};\n\n/*\n** Each tokenizer module registered with the FTS5 module is represented\n** by an object of the following type. All such objects are stored as part\n** of the Fts5Global.pTok list.\n*/\nstruct Fts5TokenizerModule {\n  char *zName;                    /* Name of tokenizer */\n  void *pUserData;                /* User pointer passed to xCreate() */\n  fts5_tokenizer x;               /* Tokenizer functions */\n  void (*xDestroy)(void*);        /* Destructor function */\n  Fts5TokenizerModule *pNext;     /* Next registered tokenizer module */\n};\n\n/*\n** Virtual-table object.\n*/\nstruct Fts5Table {\n  sqlite3_vtab base;              /* Base class used by SQLite core */\n  Fts5Config *pConfig;            /* Virtual table configuration */\n  Fts5Index *pIndex;              /* Full-text index */\n  Fts5Storage *pStorage;          /* Document store */\n  Fts5Global *pGlobal;            /* Global (connection wide) data */\n  Fts5Cursor *pSortCsr;           /* Sort data from this cursor */\n#ifdef SQLITE_DEBUG\n  struct Fts5TransactionState ts;\n#endif\n};\n\nstruct Fts5MatchPhrase {\n  Fts5Buffer *pPoslist;           /* Pointer to current poslist */\n  int nTerm;                      /* Size of phrase in terms */\n};\n\n/*\n** pStmt:\n**   SELECT rowid, <fts> FROM <fts> ORDER BY +rank;\n**\n** aIdx[]:\n**   There is one entry in the aIdx[] array for each phrase in the query,\n**   the value of which is the offset within aPoslist[] following the last \n**   byte of the position list for the corresponding phrase.\n*/\nstruct Fts5Sorter {\n  sqlite3_stmt *pStmt;\n  i64 iRowid;                     /* Current rowid */\n  const u8 *aPoslist;             /* Position lists for current row */\n  int nIdx;                       /* Number of entries in aIdx[] */\n  int aIdx[1];                    /* Offsets into aPoslist for current row */\n};\n\n\n/*\n** Virtual-table cursor object.\n**\n** iSpecial:\n**   If this is a 'special' query (refer to function fts5SpecialMatch()), \n**   then this variable contains the result of the query. \n**\n** iFirstRowid, iLastRowid:\n**   These variables are only used for FTS5_PLAN_MATCH cursors. Assuming the\n**   cursor iterates in ascending order of rowids, iFirstRowid is the lower\n**   limit of rowids to return, and iLastRowid the upper. In other words, the\n**   WHERE clause in the user's query might have been:\n**\n**       <tbl> MATCH <expr> AND rowid BETWEEN $iFirstRowid AND $iLastRowid\n**\n**   If the cursor iterates in descending order of rowid, iFirstRowid\n**   is the upper limit (i.e. the \"first\" rowid visited) and iLastRowid\n**   the lower.\n*/\nstruct Fts5Cursor {\n  sqlite3_vtab_cursor base;       /* Base class used by SQLite core */\n  Fts5Cursor *pNext;              /* Next cursor in Fts5Cursor.pCsr list */\n  int *aColumnSize;               /* Values for xColumnSize() */\n  i64 iCsrId;                     /* Cursor id */\n\n  /* Zero from this point onwards on cursor reset */\n  int ePlan;                      /* FTS5_PLAN_XXX value */\n  int bDesc;                      /* True for \"ORDER BY rowid DESC\" queries */\n  i64 iFirstRowid;                /* Return no rowids earlier than this */\n  i64 iLastRowid;                 /* Return no rowids later than this */\n  sqlite3_stmt *pStmt;            /* Statement used to read %_content */\n  Fts5Expr *pExpr;                /* Expression for MATCH queries */\n  Fts5Sorter *pSorter;            /* Sorter for \"ORDER BY rank\" queries */\n  int csrflags;                   /* Mask of cursor flags (see below) */\n  i64 iSpecial;                   /* Result of special query */\n\n  /* \"rank\" function. Populated on demand from vtab.xColumn(). */\n  char *zRank;                    /* Custom rank function */\n  char *zRankArgs;                /* Custom rank function args */\n  Fts5Auxiliary *pRank;           /* Rank callback (or NULL) */\n  int nRankArg;                   /* Number of trailing arguments for rank() */\n  sqlite3_value **apRankArg;      /* Array of trailing arguments */\n  sqlite3_stmt *pRankArgStmt;     /* Origin of objects in apRankArg[] */\n\n  /* Auxiliary data storage */\n  Fts5Auxiliary *pAux;            /* Currently executing extension function */\n  Fts5Auxdata *pAuxdata;          /* First in linked list of saved aux-data */\n\n  /* Cache used by auxiliary functions xInst() and xInstCount() */\n  Fts5PoslistReader *aInstIter;   /* One for each phrase */\n  int nInstAlloc;                 /* Size of aInst[] array (entries / 3) */\n  int nInstCount;                 /* Number of phrase instances */\n  int *aInst;                     /* 3 integers per phrase instance */\n};\n\n/*\n** Bits that make up the \"idxNum\" parameter passed indirectly by \n** xBestIndex() to xFilter().\n*/\n#define FTS5_BI_MATCH        0x0001         /* <tbl> MATCH ? */\n#define FTS5_BI_RANK         0x0002         /* rank MATCH ? */\n#define FTS5_BI_ROWID_EQ     0x0004         /* rowid == ? */\n#define FTS5_BI_ROWID_LE     0x0008         /* rowid <= ? */\n#define FTS5_BI_ROWID_GE     0x0010         /* rowid >= ? */\n\n#define FTS5_BI_ORDER_RANK   0x0020\n#define FTS5_BI_ORDER_ROWID  0x0040\n#define FTS5_BI_ORDER_DESC   0x0080\n\n/*\n** Values for Fts5Cursor.csrflags\n*/\n#define FTS5CSR_EOF               0x01\n#define FTS5CSR_REQUIRE_CONTENT   0x02\n#define FTS5CSR_REQUIRE_DOCSIZE   0x04\n#define FTS5CSR_REQUIRE_INST      0x08\n#define FTS5CSR_FREE_ZRANK        0x10\n#define FTS5CSR_REQUIRE_RESEEK    0x20\n#define FTS5CSR_REQUIRE_POSLIST   0x40\n\n#define BitFlagAllTest(x,y) (((x) & (y))==(y))\n#define BitFlagTest(x,y)    (((x) & (y))!=0)\n\n\n/*\n** Macros to Set(), Clear() and Test() cursor flags.\n*/\n#define CsrFlagSet(pCsr, flag)   ((pCsr)->csrflags |= (flag))\n#define CsrFlagClear(pCsr, flag) ((pCsr)->csrflags &= ~(flag))\n#define CsrFlagTest(pCsr, flag)  ((pCsr)->csrflags & (flag))\n\nstruct Fts5Auxdata {\n  Fts5Auxiliary *pAux;            /* Extension to which this belongs */\n  void *pPtr;                     /* Pointer value */\n  void(*xDelete)(void*);          /* Destructor */\n  Fts5Auxdata *pNext;             /* Next object in linked list */\n};\n\n#ifdef SQLITE_DEBUG\n#define FTS5_BEGIN      1\n#define FTS5_SYNC       2\n#define FTS5_COMMIT     3\n#define FTS5_ROLLBACK   4\n#define FTS5_SAVEPOINT  5\n#define FTS5_RELEASE    6\n#define FTS5_ROLLBACKTO 7\nstatic void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){\n  switch( op ){\n    case FTS5_BEGIN:\n      assert( p->ts.eState==0 );\n      p->ts.eState = 1;\n      p->ts.iSavepoint = -1;\n      break;\n\n    case FTS5_SYNC:\n      assert( p->ts.eState==1 );\n      p->ts.eState = 2;\n      break;\n\n    case FTS5_COMMIT:\n      assert( p->ts.eState==2 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_ROLLBACK:\n      assert( p->ts.eState==1 || p->ts.eState==2 || p->ts.eState==0 );\n      p->ts.eState = 0;\n      break;\n\n    case FTS5_SAVEPOINT:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint>p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n      \n    case FTS5_RELEASE:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint-1;\n      break;\n\n    case FTS5_ROLLBACKTO:\n      assert( p->ts.eState==1 );\n      assert( iSavepoint>=0 );\n      assert( iSavepoint<=p->ts.iSavepoint );\n      p->ts.iSavepoint = iSavepoint;\n      break;\n  }\n}\n#else\n# define fts5CheckTransactionState(x,y,z)\n#endif\n\n/*\n** Return true if pTab is a contentless table.\n*/\nstatic int fts5IsContentless(Fts5Table *pTab){\n  return pTab->pConfig->eContent==FTS5_CONTENT_NONE;\n}\n\n/*\n** Delete a virtual table handle allocated by fts5InitVtab(). \n*/\nstatic void fts5FreeVtab(Fts5Table *pTab){\n  if( pTab ){\n    sqlite3Fts5IndexClose(pTab->pIndex);\n    sqlite3Fts5StorageClose(pTab->pStorage);\n    sqlite3Fts5ConfigFree(pTab->pConfig);\n    sqlite3_free(pTab);\n  }\n}\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5DisconnectMethod(sqlite3_vtab *pVtab){\n  fts5FreeVtab((Fts5Table*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5DestroyMethod(sqlite3_vtab *pVtab){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  int rc = sqlite3Fts5DropAll(pTab->pConfig);\n  if( rc==SQLITE_OK ){\n    fts5FreeVtab((Fts5Table*)pVtab);\n  }\n  return rc;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> \"column name\" and other module argument fields.\n*/\nstatic int fts5InitVtab(\n  int bCreate,                    /* True for xCreate, false for xConnect */\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Hash table containing tokenizers */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pAux;\n  const char **azConfig = (const char**)argv;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5Config *pConfig = 0;        /* Results of parsing argc/argv */\n  Fts5Table *pTab = 0;            /* New virtual table object */\n\n  /* Allocate the new vtab object and parse the configuration */\n  pTab = (Fts5Table*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Table));\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);\n    assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );\n  }\n  if( rc==SQLITE_OK ){\n    pTab->pConfig = pConfig;\n    pTab->pGlobal = pGlobal;\n  }\n\n  /* Open the index sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->pIndex, pzErr);\n  }\n\n  /* Open the storage sub-system */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageOpen(\n        pConfig, pTab->pIndex, bCreate, &pTab->pStorage, pzErr\n    );\n  }\n\n  /* Call sqlite3_declare_vtab() */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5ConfigDeclareVtab(pConfig);\n  }\n\n  /* Load the initial configuration */\n  if( rc==SQLITE_OK ){\n    assert( pConfig->pzErrmsg==0 );\n    pConfig->pzErrmsg = pzErr;\n    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);\n    sqlite3Fts5IndexRollback(pTab->pIndex);\n    pConfig->pzErrmsg = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5FreeVtab(pTab);\n    pTab = 0;\n  }else if( bCreate ){\n    fts5CheckTransactionState(pTab, FTS5_BEGIN, 0);\n  }\n  *ppVTab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5InitVtab().\n*/\nstatic int fts5ConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(0, db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5CreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5InitVtab(1, db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/*\n** The different query plans.\n*/\n#define FTS5_PLAN_MATCH          1       /* (<tbl> MATCH ?) */\n#define FTS5_PLAN_SOURCE         2       /* A source cursor for SORTED_MATCH */\n#define FTS5_PLAN_SPECIAL        3       /* An internal query */\n#define FTS5_PLAN_SORTED_MATCH   4       /* (<tbl> MATCH ? ORDER BY rank) */\n#define FTS5_PLAN_SCAN           5       /* No usable constraint */\n#define FTS5_PLAN_ROWID          6       /* (rowid = ?) */\n\n/*\n** Set the SQLITE_INDEX_SCAN_UNIQUE flag in pIdxInfo->flags. Unless this\n** extension is currently being used by a version of SQLite too old to\n** support index-info flags. In that case this function is a no-op.\n*/\nstatic void fts5SetUniqueFlag(sqlite3_index_info *pIdxInfo){\n#if SQLITE_VERSION_NUMBER>=3008012\n#ifndef SQLITE_CORE\n  if( sqlite3_libversion_number()>=3008012 )\n#endif\n  {\n    pIdxInfo->idxFlags |= SQLITE_INDEX_SCAN_UNIQUE;\n  }\n#endif\n}\n\n/*\n** Implementation of the xBestIndex method for FTS5 tables. Within the \n** WHERE constraint, it searches for the following:\n**\n**   1. A MATCH constraint against the special column.\n**   2. A MATCH constraint against the \"rank\" column.\n**   3. An == constraint against the rowid column.\n**   4. A < or <= constraint against the rowid column.\n**   5. A > or >= constraint against the rowid column.\n**\n** Within the ORDER BY, either:\n**\n**   5. ORDER BY rank [ASC|DESC]\n**   6. ORDER BY rowid [ASC|DESC]\n**\n** Costs are assigned as follows:\n**\n**  a) If an unusable MATCH operator is present in the WHERE clause, the\n**     cost is unconditionally set to 1e50 (a really big number).\n**\n**  a) If a MATCH operator is present, the cost depends on the other\n**     constraints also present. As follows:\n**\n**       * No other constraints:         cost=1000.0\n**       * One rowid range constraint:   cost=750.0\n**       * Both rowid range constraints: cost=500.0\n**       * An == rowid constraint:       cost=100.0\n**\n**  b) Otherwise, if there is no MATCH:\n**\n**       * No other constraints:         cost=1000000.0\n**       * One rowid range constraint:   cost=750000.0\n**       * Both rowid range constraints: cost=250000.0\n**       * An == rowid constraint:       cost=10.0\n**\n** Costs are not modified by the ORDER BY clause.\n*/\nstatic int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){\n  Fts5Table *pTab = (Fts5Table*)pVTab;\n  Fts5Config *pConfig = pTab->pConfig;\n  const int nCol = pConfig->nCol;\n  int idxFlags = 0;               /* Parameter passed through to xFilter() */\n  int bHasMatch;\n  int iNext;\n  int i;\n\n  struct Constraint {\n    int op;                       /* Mask against sqlite3_index_constraint.op */\n    int fts5op;                   /* FTS5 mask for idxFlags */\n    int iCol;                     /* 0==rowid, 1==tbl, 2==rank */\n    int omit;                     /* True to omit this if found */\n    int iConsIndex;               /* Index in pInfo->aConstraint[] */\n  } aConstraint[] = {\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_MATCH,    1, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_MATCH|SQLITE_INDEX_CONSTRAINT_EQ, \n                                    FTS5_BI_RANK,     2, 1, -1},\n    {SQLITE_INDEX_CONSTRAINT_EQ,    FTS5_BI_ROWID_EQ, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_LT|SQLITE_INDEX_CONSTRAINT_LE, \n                                    FTS5_BI_ROWID_LE, 0, 0, -1},\n    {SQLITE_INDEX_CONSTRAINT_GT|SQLITE_INDEX_CONSTRAINT_GE, \n                                    FTS5_BI_ROWID_GE, 0, 0, -1},\n  };\n\n  int aColMap[3];\n  aColMap[0] = -1;\n  aColMap[1] = nCol;\n  aColMap[2] = nCol+1;\n\n  /* Set idxFlags flags for all WHERE clause terms that will be used. */\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    int iCol = p->iColumn;\n\n    if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol)\n     || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol)\n    ){\n      /* A MATCH operator or equivalent */\n      if( p->usable ){\n        idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16);\n        aConstraint[0].iConsIndex = i;\n      }else{\n        /* As there exists an unusable MATCH constraint this is an \n        ** unusable plan. Set a prohibitively high cost. */\n        pInfo->estimatedCost = 1e50;\n        return SQLITE_OK;\n      }\n    }else{\n      int j;\n      for(j=1; j<ArraySize(aConstraint); j++){\n        struct Constraint *pC = &aConstraint[j];\n        if( iCol==aColMap[pC->iCol] && p->op & pC->op && p->usable ){\n          pC->iConsIndex = i;\n          idxFlags |= pC->fts5op;\n        }\n      }\n    }\n  }\n\n  /* Set idxFlags flags for the ORDER BY clause */\n  if( pInfo->nOrderBy==1 ){\n    int iSort = pInfo->aOrderBy[0].iColumn;\n    if( iSort==(pConfig->nCol+1) && BitFlagTest(idxFlags, FTS5_BI_MATCH) ){\n      idxFlags |= FTS5_BI_ORDER_RANK;\n    }else if( iSort==-1 ){\n      idxFlags |= FTS5_BI_ORDER_ROWID;\n    }\n    if( BitFlagTest(idxFlags, FTS5_BI_ORDER_RANK|FTS5_BI_ORDER_ROWID) ){\n      pInfo->orderByConsumed = 1;\n      if( pInfo->aOrderBy[0].desc ){\n        idxFlags |= FTS5_BI_ORDER_DESC;\n      }\n    }\n  }\n\n  /* Calculate the estimated cost based on the flags set in idxFlags. */\n  bHasMatch = BitFlagTest(idxFlags, FTS5_BI_MATCH);\n  if( BitFlagTest(idxFlags, FTS5_BI_ROWID_EQ) ){\n    pInfo->estimatedCost = bHasMatch ? 100.0 : 10.0;\n    if( bHasMatch==0 ) fts5SetUniqueFlag(pInfo);\n  }else if( BitFlagAllTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 500.0 : 250000.0;\n  }else if( BitFlagTest(idxFlags, FTS5_BI_ROWID_LE|FTS5_BI_ROWID_GE) ){\n    pInfo->estimatedCost = bHasMatch ? 750.0 : 750000.0;\n  }else{\n    pInfo->estimatedCost = bHasMatch ? 1000.0 : 1000000.0;\n  }\n\n  /* Assign argvIndex values to each constraint in use. */\n  iNext = 1;\n  for(i=0; i<ArraySize(aConstraint); i++){\n    struct Constraint *pC = &aConstraint[i];\n    if( pC->iConsIndex>=0 ){\n      pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;\n      pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit;\n    }\n  }\n\n  pInfo->idxNum = idxFlags;\n  return SQLITE_OK;\n}\n\nstatic int fts5NewTransaction(Fts5Table *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;\n  }\n  return sqlite3Fts5StorageReset(pTab->pStorage);\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){\n  Fts5Table *pTab = (Fts5Table*)pVTab;\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = 0;           /* New cursor object */\n  int nByte;                      /* Bytes of space to allocate */\n  int rc;                         /* Return code */\n\n  rc = fts5NewTransaction(pTab);\n  if( rc==SQLITE_OK ){\n    nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);\n    pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);\n    if( pCsr ){\n      Fts5Global *pGlobal = pTab->pGlobal;\n      memset(pCsr, 0, nByte);\n      pCsr->aColumnSize = (int*)&pCsr[1];\n      pCsr->pNext = pGlobal->pCsr;\n      pGlobal->pCsr = pCsr;\n      pCsr->iCsrId = ++pGlobal->iNextId;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic int fts5StmtType(Fts5Cursor *pCsr){\n  if( pCsr->ePlan==FTS5_PLAN_SCAN ){\n    return (pCsr->bDesc) ? FTS5_STMT_SCAN_DESC : FTS5_STMT_SCAN_ASC;\n  }\n  return FTS5_STMT_LOOKUP;\n}\n\n/*\n** This function is called after the cursor passed as the only argument\n** is moved to point at a different row. It clears all cached data \n** specific to the previous row stored by the cursor object.\n*/\nstatic void fts5CsrNewrow(Fts5Cursor *pCsr){\n  CsrFlagSet(pCsr, \n      FTS5CSR_REQUIRE_CONTENT \n    | FTS5CSR_REQUIRE_DOCSIZE \n    | FTS5CSR_REQUIRE_INST \n    | FTS5CSR_REQUIRE_POSLIST \n  );\n}\n\nstatic void fts5FreeCursorComponents(Fts5Cursor *pCsr){\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Auxdata *pData;\n  Fts5Auxdata *pNext;\n\n  sqlite3_free(pCsr->aInstIter);\n  sqlite3_free(pCsr->aInst);\n  if( pCsr->pStmt ){\n    int eStmt = fts5StmtType(pCsr);\n    sqlite3Fts5StorageStmtRelease(pTab->pStorage, eStmt, pCsr->pStmt);\n  }\n  if( pCsr->pSorter ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n  }\n\n  if( pCsr->ePlan!=FTS5_PLAN_SOURCE ){\n    sqlite3Fts5ExprFree(pCsr->pExpr);\n  }\n\n  for(pData=pCsr->pAuxdata; pData; pData=pNext){\n    pNext = pData->pNext;\n    if( pData->xDelete ) pData->xDelete(pData->pPtr);\n    sqlite3_free(pData);\n  }\n\n  sqlite3_finalize(pCsr->pRankArgStmt);\n  sqlite3_free(pCsr->apRankArg);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_FREE_ZRANK) ){\n    sqlite3_free(pCsr->zRank);\n    sqlite3_free(pCsr->zRankArgs);\n  }\n\n  memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan - (u8*)pCsr));\n}\n\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){\n  if( pCursor ){\n    Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n    Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n    Fts5Cursor **pp;\n\n    fts5FreeCursorComponents(pCsr);\n    /* Remove the cursor from the Fts5Global.pCsr list */\n    for(pp=&pTab->pGlobal->pCsr; (*pp)!=pCsr; pp=&(*pp)->pNext);\n    *pp = pCsr->pNext;\n\n    sqlite3_free(pCsr);\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5SorterNext(Fts5Cursor *pCsr){\n  Fts5Sorter *pSorter = pCsr->pSorter;\n  int rc;\n\n  rc = sqlite3_step(pSorter->pStmt);\n  if( rc==SQLITE_DONE ){\n    rc = SQLITE_OK;\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }else if( rc==SQLITE_ROW ){\n    const u8 *a;\n    const u8 *aBlob;\n    int nBlob;\n    int i;\n    int iOff = 0;\n    rc = SQLITE_OK;\n\n    pSorter->iRowid = sqlite3_column_int64(pSorter->pStmt, 0);\n    nBlob = sqlite3_column_bytes(pSorter->pStmt, 1);\n    aBlob = a = sqlite3_column_blob(pSorter->pStmt, 1);\n\n    /* nBlob==0 in detail=none mode. */\n    if( nBlob>0 ){\n      for(i=0; i<(pSorter->nIdx-1); i++){\n        int iVal;\n        a += fts5GetVarint32(a, iVal);\n        iOff += iVal;\n        pSorter->aIdx[i] = iOff;\n      }\n      pSorter->aIdx[i] = &aBlob[nBlob] - a;\n      pSorter->aPoslist = a;\n    }\n\n    fts5CsrNewrow(pCsr);\n  }\n\n  return rc;\n}\n\n\n/*\n** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors \n** open on table pTab.\n*/\nstatic void fts5TripCursors(Fts5Table *pTab){\n  Fts5Cursor *pCsr;\n  for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->ePlan==FTS5_PLAN_MATCH\n     && pCsr->base.pVtab==(sqlite3_vtab*)pTab \n    ){\n      CsrFlagSet(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    }\n  }\n}\n\n/*\n** If the REQUIRE_RESEEK flag is set on the cursor passed as the first\n** argument, close and reopen all Fts5IndexIter iterators that the cursor \n** is using. Then attempt to move the cursor to a rowid equal to or laster\n** (in the cursors sort order - ASC or DESC) than the current rowid. \n**\n** If the new rowid is not equal to the old, set output parameter *pbSkip\n** to 1 before returning. Otherwise, leave it unchanged.\n**\n** Return SQLITE_OK if successful or if no reseek was required, or an \n** error code if an error occurred.\n*/\nstatic int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){\n  int rc = SQLITE_OK;\n  assert( *pbSkip==0 );\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){\n    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n    int bDesc = pCsr->bDesc;\n    i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);\n\n    rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);\n    if( rc==SQLITE_OK &&  iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){\n      *pbSkip = 1;\n    }\n\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_RESEEK);\n    fts5CsrNewrow(pCsr);\n    if( sqlite3Fts5ExprEof(pCsr->pExpr) ){\n      CsrFlagSet(pCsr, FTS5CSR_EOF);\n      *pbSkip = 1;\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Advance the cursor to the next row in the table that matches the \n** search criteria.\n**\n** Return SQLITE_OK if nothing goes wrong.  SQLITE_OK is returned\n** even if we reach end-of-file.  The fts5EofMethod() will be called\n** subsequently to determine whether or not an EOF was hit.\n*/\nstatic int fts5NextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc;\n\n  assert( (pCsr->ePlan<3)==\n          (pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE) \n  );\n  assert( !CsrFlagTest(pCsr, FTS5CSR_EOF) );\n\n  if( pCsr->ePlan<3 ){\n    int bSkip = 0;\n    if( (rc = fts5CursorReseek(pCsr, &bSkip)) || bSkip ) return rc;\n    rc = sqlite3Fts5ExprNext(pCsr->pExpr, pCsr->iLastRowid);\n    CsrFlagSet(pCsr, sqlite3Fts5ExprEof(pCsr->pExpr));\n    fts5CsrNewrow(pCsr);\n  }else{\n    switch( pCsr->ePlan ){\n      case FTS5_PLAN_SPECIAL: {\n        CsrFlagSet(pCsr, FTS5CSR_EOF);\n        rc = SQLITE_OK;\n        break;\n      }\n  \n      case FTS5_PLAN_SORTED_MATCH: {\n        rc = fts5SorterNext(pCsr);\n        break;\n      }\n  \n      default:\n        rc = sqlite3_step(pCsr->pStmt);\n        if( rc!=SQLITE_ROW ){\n          CsrFlagSet(pCsr, FTS5CSR_EOF);\n          rc = sqlite3_reset(pCsr->pStmt);\n        }else{\n          rc = SQLITE_OK;\n        }\n        break;\n    }\n  }\n  \n  return rc;\n}\n\n\nstatic int fts5PrepareStatement(\n  sqlite3_stmt **ppStmt,\n  Fts5Config *pConfig, \n  const char *zFmt,\n  ...\n){\n  sqlite3_stmt *pRet = 0;\n  int rc;\n  char *zSql;\n  va_list ap;\n\n  va_start(ap, zFmt);\n  zSql = sqlite3_vmprintf(zFmt, ap);\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM; \n  }else{\n    rc = sqlite3_prepare_v3(pConfig->db, zSql, -1, \n                            SQLITE_PREPARE_PERSISTENT, &pRet, 0);\n    if( rc!=SQLITE_OK ){\n      *pConfig->pzErrmsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pConfig->db));\n    }\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  *ppStmt = pRet;\n  return rc;\n} \n\nstatic int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Sorter *pSorter;\n  int nPhrase;\n  int nByte;\n  int rc;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n  \n  nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);\n  pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);\n  if( pSorter==0 ) return SQLITE_NOMEM;\n  memset(pSorter, 0, nByte);\n  pSorter->nIdx = nPhrase;\n\n  /* TODO: It would be better to have some system for reusing statement\n  ** handles here, rather than preparing a new one for each query. But that\n  ** is not possible as SQLite reference counts the virtual table objects.\n  ** And since the statement required here reads from this very virtual \n  ** table, saving it creates a circular reference.\n  **\n  ** If SQLite a built-in statement cache, this wouldn't be a problem. */\n  rc = fts5PrepareStatement(&pSorter->pStmt, pConfig,\n      \"SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s\",\n      pConfig->zDb, pConfig->zName, zRank, pConfig->zName,\n      (zRankArgs ? \", \" : \"\"),\n      (zRankArgs ? zRankArgs : \"\"),\n      bDesc ? \"DESC\" : \"ASC\"\n  );\n\n  pCsr->pSorter = pSorter;\n  if( rc==SQLITE_OK ){\n    assert( pTab->pSortCsr==0 );\n    pTab->pSortCsr = pCsr;\n    rc = fts5SorterNext(pCsr);\n    pTab->pSortCsr = 0;\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_finalize(pSorter->pStmt);\n    sqlite3_free(pSorter);\n    pCsr->pSorter = 0;\n  }\n\n  return rc;\n}\n\nstatic int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){\n  int rc;\n  Fts5Expr *pExpr = pCsr->pExpr;\n  rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);\n  if( sqlite3Fts5ExprEof(pExpr) ){\n    CsrFlagSet(pCsr, FTS5CSR_EOF);\n  }\n  fts5CsrNewrow(pCsr);\n  return rc;\n}\n\n/*\n** Process a \"special\" query. A special query is identified as one with a\n** MATCH expression that begins with a '*' character. The remainder of\n** the text passed to the MATCH operator are used as  the special query\n** parameters.\n*/\nstatic int fts5SpecialMatch(\n  Fts5Table *pTab, \n  Fts5Cursor *pCsr, \n  const char *zQuery\n){\n  int rc = SQLITE_OK;             /* Return code */\n  const char *z = zQuery;         /* Special query text */\n  int n;                          /* Number of bytes in text at z */\n\n  while( z[0]==' ' ) z++;\n  for(n=0; z[n] && z[n]!=' '; n++);\n\n  assert( pTab->base.zErrMsg==0 );\n  pCsr->ePlan = FTS5_PLAN_SPECIAL;\n\n  if( 0==sqlite3_strnicmp(\"reads\", z, n) ){\n    pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->pIndex);\n  }\n  else if( 0==sqlite3_strnicmp(\"id\", z, n) ){\n    pCsr->iSpecial = pCsr->iCsrId;\n  }\n  else{\n    /* An unrecognized directive. Return an error message. */\n    pTab->base.zErrMsg = sqlite3_mprintf(\"unknown special query: %.*s\", n, z);\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\n/*\n** Search for an auxiliary function named zName that can be used with table\n** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary\n** structure. Otherwise, if no such function exists, return NULL.\n*/\nstatic Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){\n  Fts5Auxiliary *pAux;\n\n  for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){\n    if( sqlite3_stricmp(zName, pAux->zFunc)==0 ) return pAux;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n\nstatic int fts5FindRankFunction(Fts5Cursor *pCsr){\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n  Fts5Auxiliary *pAux = 0;\n  const char *zRank = pCsr->zRank;\n  const char *zRankArgs = pCsr->zRankArgs;\n\n  if( zRankArgs ){\n    char *zSql = sqlite3Fts5Mprintf(&rc, \"SELECT %s\", zRankArgs);\n    if( zSql ){\n      sqlite3_stmt *pStmt = 0;\n      rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &pStmt, 0);\n      sqlite3_free(zSql);\n      assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );\n      if( rc==SQLITE_OK ){\n        if( SQLITE_ROW==sqlite3_step(pStmt) ){\n          int nByte;\n          pCsr->nRankArg = sqlite3_column_count(pStmt);\n          nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;\n          pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);\n          if( rc==SQLITE_OK ){\n            int i;\n            for(i=0; i<pCsr->nRankArg; i++){\n              pCsr->apRankArg[i] = sqlite3_column_value(pStmt, i);\n            }\n          }\n          pCsr->pRankArgStmt = pStmt;\n        }else{\n          rc = sqlite3_finalize(pStmt);\n          assert( rc!=SQLITE_OK );\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    pAux = fts5FindAuxiliary(pTab, zRank);\n    if( pAux==0 ){\n      assert( pTab->base.zErrMsg==0 );\n      pTab->base.zErrMsg = sqlite3_mprintf(\"no such function: %s\", zRank);\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  pCsr->pRank = pAux;\n  return rc;\n}\n\n\nstatic int fts5CursorParseRank(\n  Fts5Config *pConfig,\n  Fts5Cursor *pCsr, \n  sqlite3_value *pRank\n){\n  int rc = SQLITE_OK;\n  if( pRank ){\n    const char *z = (const char*)sqlite3_value_text(pRank);\n    char *zRank = 0;\n    char *zRankArgs = 0;\n\n    if( z==0 ){\n      if( sqlite3_value_type(pRank)==SQLITE_NULL ) rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5ConfigParseRank(z, &zRank, &zRankArgs);\n    }\n    if( rc==SQLITE_OK ){\n      pCsr->zRank = zRank;\n      pCsr->zRankArgs = zRankArgs;\n      CsrFlagSet(pCsr, FTS5CSR_FREE_ZRANK);\n    }else if( rc==SQLITE_ERROR ){\n      pCsr->base.pVtab->zErrMsg = sqlite3_mprintf(\n          \"parse error in rank function: %s\", z\n      );\n    }\n  }else{\n    if( pConfig->zRank ){\n      pCsr->zRank = (char*)pConfig->zRank;\n      pCsr->zRankArgs = (char*)pConfig->zRankArgs;\n    }else{\n      pCsr->zRank = (char*)FTS5_DEFAULT_RANK;\n      pCsr->zRankArgs = 0;\n    }\n  }\n  return rc;\n}\n\nstatic i64 fts5GetRowidLimit(sqlite3_value *pVal, i64 iDefault){\n  if( pVal ){\n    int eType = sqlite3_value_numeric_type(pVal);\n    if( eType==SQLITE_INTEGER ){\n      return sqlite3_value_int64(pVal);\n    }\n  }\n  return iDefault;\n}\n\n/*\n** This is the xFilter interface for the virtual table.  See\n** the virtual table xFilter method documentation for additional\n** information.\n** \n** There are three possible query strategies:\n**\n**   1. Full-text search using a MATCH operator.\n**   2. A by-rowid lookup.\n**   3. A full-table scan.\n*/\nstatic int fts5FilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nVal,                       /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;             /* Error code */\n  int iVal = 0;                   /* Counter for apVal[] */\n  int bDesc;                      /* True if ORDER BY [rank|rowid] DESC */\n  int bOrderByRank;               /* True if ORDER BY rank */\n  sqlite3_value *pMatch = 0;      /* <tbl> MATCH ? expression (or NULL) */\n  sqlite3_value *pRank = 0;       /* rank MATCH ? expression (or NULL) */\n  sqlite3_value *pRowidEq = 0;    /* rowid = ? expression (or NULL) */\n  sqlite3_value *pRowidLe = 0;    /* rowid <= ? expression (or NULL) */\n  sqlite3_value *pRowidGe = 0;    /* rowid >= ? expression (or NULL) */\n  int iCol;                       /* Column on LHS of MATCH operator */\n  char **pzErrmsg = pConfig->pzErrmsg;\n\n  UNUSED_PARAM(zUnused);\n  UNUSED_PARAM(nVal);\n\n  if( pCsr->ePlan ){\n    fts5FreeCursorComponents(pCsr);\n    memset(&pCsr->ePlan, 0, sizeof(Fts5Cursor) - ((u8*)&pCsr->ePlan-(u8*)pCsr));\n  }\n\n  assert( pCsr->pStmt==0 );\n  assert( pCsr->pExpr==0 );\n  assert( pCsr->csrflags==0 );\n  assert( pCsr->pRank==0 );\n  assert( pCsr->zRank==0 );\n  assert( pCsr->zRankArgs==0 );\n\n  assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );\n  pConfig->pzErrmsg = &pTab->base.zErrMsg;\n\n  /* Decode the arguments passed through to this function.\n  **\n  ** Note: The following set of if(...) statements must be in the same\n  ** order as the corresponding entries in the struct at the top of\n  ** fts5BestIndexMethod().  */\n  if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_RANK) ) pRank = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_EQ) ) pRowidEq = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_LE) ) pRowidLe = apVal[iVal++];\n  if( BitFlagTest(idxNum, FTS5_BI_ROWID_GE) ) pRowidGe = apVal[iVal++];\n  iCol = (idxNum>>16);\n  assert( iCol>=0 && iCol<=pConfig->nCol );\n  assert( iVal==nVal );\n  bOrderByRank = ((idxNum & FTS5_BI_ORDER_RANK) ? 1 : 0);\n  pCsr->bDesc = bDesc = ((idxNum & FTS5_BI_ORDER_DESC) ? 1 : 0);\n\n  /* Set the cursor upper and lower rowid limits. Only some strategies \n  ** actually use them. This is ok, as the xBestIndex() method leaves the\n  ** sqlite3_index_constraint.omit flag clear for range constraints\n  ** on the rowid field.  */\n  if( pRowidEq ){\n    pRowidLe = pRowidGe = pRowidEq;\n  }\n  if( bDesc ){\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }else{\n    pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64);\n    pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);\n  }\n\n  if( pTab->pSortCsr ){\n    /* If pSortCsr is non-NULL, then this call is being made as part of \n    ** processing for a \"... MATCH <expr> ORDER BY rank\" query (ePlan is\n    ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will\n    ** return results to the user for this query. The current cursor \n    ** (pCursor) is used to execute the query issued by function \n    ** fts5CursorFirstSorted() above.  */\n    assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );\n    assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );\n    assert( pCsr->iLastRowid==LARGEST_INT64 );\n    assert( pCsr->iFirstRowid==SMALLEST_INT64 );\n    pCsr->ePlan = FTS5_PLAN_SOURCE;\n    pCsr->pExpr = pTab->pSortCsr->pExpr;\n    rc = fts5CursorFirst(pTab, pCsr, bDesc);\n  }else if( pMatch ){\n    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);\n    if( zExpr==0 ) zExpr = \"\";\n\n    rc = fts5CursorParseRank(pConfig, pCsr, pRank);\n    if( rc==SQLITE_OK ){\n      if( zExpr[0]=='*' ){\n        /* The user has issued a query of the form \"MATCH '*...'\". This\n        ** indicates that the MATCH expression is not a full text query,\n        ** but a request for an internal parameter.  */\n        rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);\n      }else{\n        char **pzErr = &pTab->base.zErrMsg;\n        rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);\n        if( rc==SQLITE_OK ){\n          if( bOrderByRank ){\n            pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;\n            rc = fts5CursorFirstSorted(pTab, pCsr, bDesc);\n          }else{\n            pCsr->ePlan = FTS5_PLAN_MATCH;\n            rc = fts5CursorFirst(pTab, pCsr, bDesc);\n          }\n        }\n      }\n    }\n  }else if( pConfig->zContent==0 ){\n    *pConfig->pzErrmsg = sqlite3_mprintf(\n        \"%s: table does not support scanning\", pConfig->zName\n    );\n    rc = SQLITE_ERROR;\n  }else{\n    /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup\n    ** by rowid (ePlan==FTS5_PLAN_ROWID).  */\n    pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->base.zErrMsg\n    );\n    if( rc==SQLITE_OK ){\n      if( pCsr->ePlan==FTS5_PLAN_ROWID ){\n        sqlite3_bind_value(pCsr->pStmt, 1, apVal[0]);\n      }else{\n        sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid);\n        sqlite3_bind_int64(pCsr->pStmt, 2, pCsr->iLastRowid);\n      }\n      rc = fts5NextMethod(pCursor);\n    }\n  }\n\n  pConfig->pzErrmsg = pzErrmsg;\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5EofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  return (CsrFlagTest(pCsr, FTS5CSR_EOF) ? 1 : 0);\n}\n\n/*\n** Return the rowid that the cursor currently points to.\n*/\nstatic i64 fts5CursorRowid(Fts5Cursor *pCsr){\n  assert( pCsr->ePlan==FTS5_PLAN_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH \n       || pCsr->ePlan==FTS5_PLAN_SOURCE \n  );\n  if( pCsr->pSorter ){\n    return pCsr->pSorter->iRowid;\n  }else{\n    return sqlite3Fts5ExprRowid(pCsr->pExpr);\n  }\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. fts5\n** exposes %_content.rowid as the rowid for the virtual table. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int ePlan = pCsr->ePlan;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n  switch( ePlan ){\n    case FTS5_PLAN_SPECIAL:\n      *pRowid = 0;\n      break;\n\n    case FTS5_PLAN_SOURCE:\n    case FTS5_PLAN_MATCH:\n    case FTS5_PLAN_SORTED_MATCH:\n      *pRowid = fts5CursorRowid(pCsr);\n      break;\n\n    default:\n      *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** If the cursor requires seeking (bSeekRequired flag is set), seek it.\n** Return SQLITE_OK if no error occurs, or an SQLite error code otherwise.\n**\n** If argument bErrormsg is true and an error occurs, an error message may\n** be left in sqlite3_vtab.zErrMsg.\n*/\nstatic int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){\n  int rc = SQLITE_OK;\n\n  /* If the cursor does not yet have a statement handle, obtain one now. */ \n  if( pCsr->pStmt==0 ){\n    Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n    int eStmt = fts5StmtType(pCsr);\n    rc = sqlite3Fts5StorageStmt(\n        pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->base.zErrMsg:0)\n    );\n    assert( rc!=SQLITE_OK || pTab->base.zErrMsg==0 );\n    assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );\n  }\n\n  if( rc==SQLITE_OK && CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) ){\n    assert( pCsr->pExpr );\n    sqlite3_reset(pCsr->pStmt);\n    sqlite3_bind_int64(pCsr->pStmt, 1, fts5CursorRowid(pCsr));\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      rc = SQLITE_OK;\n      CsrFlagClear(pCsr, FTS5CSR_REQUIRE_CONTENT);\n    }else{\n      rc = sqlite3_reset(pCsr->pStmt);\n      if( rc==SQLITE_OK ){\n        rc = FTS5_CORRUPT;\n      }\n    }\n  }\n  return rc;\n}\n\nstatic void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){\n  va_list ap;                     /* ... printf arguments */\n  va_start(ap, zFormat);\n  assert( p->base.zErrMsg==0 );\n  p->base.zErrMsg = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** This function is called to handle an FTS INSERT command. In other words,\n** an INSERT statement of the form:\n**\n**     INSERT INTO fts(fts) VALUES($pCmd)\n**     INSERT INTO fts(fts, rank) VALUES($pCmd, $pVal)\n**\n** Argument pVal is the value assigned to column \"fts\" by the INSERT \n** statement. This function returns SQLITE_OK if successful, or an SQLite\n** error code if an error occurs.\n**\n** The commands implemented by this function are documented in the \"Special\n** INSERT Directives\" section of the documentation. It should be updated if\n** more commands are added to this function.\n*/\nstatic int fts5SpecialInsert(\n  Fts5Table *pTab,                /* Fts5 table object */\n  const char *zCmd,               /* Text inserted into table-name column */\n  sqlite3_value *pVal             /* Value inserted into rank column */\n){\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n  int bError = 0;\n\n  if( 0==sqlite3_stricmp(\"delete-all\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      fts5SetVtabError(pTab, \n          \"'delete-all' may only be used with a \"\n          \"contentless or external content fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageDeleteAll(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"rebuild\", zCmd) ){\n    if( pConfig->eContent==FTS5_CONTENT_NONE ){\n      fts5SetVtabError(pTab, \n          \"'rebuild' may not be used with a contentless fts5 table\"\n      );\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3Fts5StorageRebuild(pTab->pStorage);\n    }\n  }else if( 0==sqlite3_stricmp(\"optimize\", zCmd) ){\n    rc = sqlite3Fts5StorageOptimize(pTab->pStorage);\n  }else if( 0==sqlite3_stricmp(\"merge\", zCmd) ){\n    int nMerge = sqlite3_value_int(pVal);\n    rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);\n  }else if( 0==sqlite3_stricmp(\"integrity-check\", zCmd) ){\n    rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);\n#ifdef SQLITE_DEBUG\n  }else if( 0==sqlite3_stricmp(\"prefix-index\", zCmd) ){\n    pConfig->bPrefixIndex = sqlite3_value_int(pVal);\n#endif\n  }else{\n    rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5ConfigSetValue(pTab->pConfig, zCmd, pVal, &bError);\n    }\n    if( rc==SQLITE_OK ){\n      if( bError ){\n        rc = SQLITE_ERROR;\n      }else{\n        rc = sqlite3Fts5StorageConfigValue(pTab->pStorage, zCmd, pVal, 0);\n      }\n    }\n  }\n  return rc;\n}\n\nstatic int fts5SpecialDelete(\n  Fts5Table *pTab, \n  sqlite3_value **apVal\n){\n  int rc = SQLITE_OK;\n  int eType1 = sqlite3_value_type(apVal[1]);\n  if( eType1==SQLITE_INTEGER ){\n    sqlite3_int64 iDel = sqlite3_value_int64(apVal[1]);\n    rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, &apVal[2]);\n  }\n  return rc;\n}\n\nstatic void fts5StorageInsert(\n  int *pRc, \n  Fts5Table *pTab, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  int rc = *pRc;\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, piRowid);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *piRowid);\n  }\n  *pRc = rc;\n}\n\n/* \n** This function is the implementation of the xUpdate callback used by \n** FTS3 virtual tables. It is invoked by SQLite each time a row is to be\n** inserted, updated or deleted.\n**\n** A delete specifies a single argument - the rowid of the row to remove.\n** \n** Update and insert operations pass:\n**\n**   1. The \"old\" rowid, or NULL.\n**   2. The \"new\" rowid.\n**   3. Values for each of the nCol matchable columns.\n**   4. Values for the two hidden columns (<tablename> and \"rank\").\n*/\nstatic int fts5UpdateMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nArg,                       /* Size of argument array */\n  sqlite3_value **apVal,          /* Array of arguments */\n  sqlite_int64 *pRowid            /* OUT: The affected (or effected) rowid */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  Fts5Config *pConfig = pTab->pConfig;\n  int eType0;                     /* value_type() of apVal[0] */\n  int rc = SQLITE_OK;             /* Return code */\n\n  /* A transaction must be open when this is called. */\n  assert( pTab->ts.eState==1 );\n\n  assert( pVtab->zErrMsg==0 );\n  assert( nArg==1 || nArg==(2+pConfig->nCol+2) );\n  assert( nArg==1 \n      || sqlite3_value_type(apVal[1])==SQLITE_INTEGER \n      || sqlite3_value_type(apVal[1])==SQLITE_NULL \n  );\n  assert( pTab->pConfig->pzErrmsg==0 );\n  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;\n\n  /* Put any active cursors into REQUIRE_SEEK state. */\n  fts5TripCursors(pTab);\n\n  eType0 = sqlite3_value_type(apVal[0]);\n  if( eType0==SQLITE_NULL \n   && sqlite3_value_type(apVal[2+pConfig->nCol])!=SQLITE_NULL \n  ){\n    /* A \"special\" INSERT op. These are handled separately. */\n    const char *z = (const char*)sqlite3_value_text(apVal[2+pConfig->nCol]);\n    if( pConfig->eContent!=FTS5_CONTENT_NORMAL \n      && 0==sqlite3_stricmp(\"delete\", z) \n    ){\n      rc = fts5SpecialDelete(pTab, apVal);\n    }else{\n      rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);\n    }\n  }else{\n    /* A regular INSERT, UPDATE or DELETE statement. The trick here is that\n    ** any conflict on the rowid value must be detected before any \n    ** modifications are made to the database file. There are 4 cases:\n    **\n    **   1) DELETE\n    **   2) UPDATE (rowid not modified)\n    **   3) UPDATE (rowid modified)\n    **   4) INSERT\n    **\n    ** Cases 3 and 4 may violate the rowid constraint.\n    */\n    int eConflict = SQLITE_ABORT;\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      eConflict = sqlite3_vtab_on_conflict(pConfig->db);\n    }\n\n    assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL );\n    assert( nArg!=1 || eType0==SQLITE_INTEGER );\n\n    /* Filter out attempts to run UPDATE or DELETE on contentless tables.\n    ** This is not suported.  */\n    if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){\n      pTab->base.zErrMsg = sqlite3_mprintf(\n          \"cannot %s contentless fts5 table: %s\", \n          (nArg>1 ? \"UPDATE\" : \"DELETE from\"), pConfig->zName\n      );\n      rc = SQLITE_ERROR;\n    }\n\n    /* DELETE */\n    else if( nArg==1 ){\n      i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */\n      rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);\n    }\n\n    /* INSERT */\n    else if( eType0!=SQLITE_INTEGER ){     \n      /* If this is a REPLACE, first remove the current entry (if any) */\n      if( eConflict==SQLITE_REPLACE \n       && sqlite3_value_type(apVal[1])==SQLITE_INTEGER \n      ){\n        i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */\n        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n      }\n      fts5StorageInsert(&rc, pTab, apVal, pRowid);\n    }\n\n    /* UPDATE */\n    else{\n      i64 iOld = sqlite3_value_int64(apVal[0]);  /* Old rowid */\n      i64 iNew = sqlite3_value_int64(apVal[1]);  /* New rowid */\n      if( iOld!=iNew ){\n        if( eConflict==SQLITE_REPLACE ){\n          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);\n          }\n          fts5StorageInsert(&rc, pTab, apVal, pRowid);\n        }else{\n          rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);\n          }\n        }\n      }else{\n        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);\n        fts5StorageInsert(&rc, pTab, apVal, pRowid);\n      }\n    }\n  }\n\n  pTab->pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xSync() method. \n*/\nstatic int fts5SyncMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_SYNC, 0);\n  pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;\n  fts5TripCursors(pTab);\n  rc = sqlite3Fts5StorageSync(pTab->pStorage);\n  pTab->pConfig->pzErrmsg = 0;\n  return rc;\n}\n\n/*\n** Implementation of xBegin() method. \n*/\nstatic int fts5BeginMethod(sqlite3_vtab *pVtab){\n  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);\n  fts5NewTransaction((Fts5Table*)pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xCommit() method. This is a no-op. The contents of\n** the pending-terms hash-table have already been flushed into the database\n** by fts5SyncMethod().\n*/\nstatic int fts5CommitMethod(sqlite3_vtab *pVtab){\n  UNUSED_PARAM(pVtab);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xRollback(). Discard the contents of the pending-terms\n** hash-table. Any changes made to the database are reverted by SQLite.\n*/\nstatic int fts5RollbackMethod(sqlite3_vtab *pVtab){\n  int rc;\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);\n  rc = sqlite3Fts5StorageRollback(pTab->pStorage);\n  return rc;\n}\n\nstatic int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);\n\nstatic void *fts5ApiUserData(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return pCsr->pAux->pUserData;\n}\n\nstatic int fts5ApiColumnCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return ((Fts5Table*)(pCsr->base.pVtab))->pConfig->nCol;\n}\n\nstatic int fts5ApiColumnTotalSize(\n  Fts5Context *pCtx, \n  int iCol, \n  sqlite3_int64 *pnToken\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);\n}\n\nstatic int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);\n}\n\nstatic int fts5ApiTokenize(\n  Fts5Context *pCtx, \n  const char *pText, int nText, \n  void *pUserData,\n  int (*xToken)(void*, int, const char*, int, int, int)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  return sqlite3Fts5Tokenize(\n      pTab->pConfig, FTS5_TOKENIZE_AUX, pText, nText, pUserData, xToken\n  );\n}\n\nstatic int fts5ApiPhraseCount(Fts5Context *pCtx){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n}\n\nstatic int fts5ApiPhraseSize(Fts5Context *pCtx, int iPhrase){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  return sqlite3Fts5ExprPhraseSize(pCsr->pExpr, iPhrase);\n}\n\nstatic int fts5ApiColumnText(\n  Fts5Context *pCtx, \n  int iCol, \n  const char **pz, \n  int *pn\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){\n    *pz = 0;\n    *pn = 0;\n  }else{\n    rc = fts5SeekCursor(pCsr, 0);\n    if( rc==SQLITE_OK ){\n      *pz = (const char*)sqlite3_column_text(pCsr->pStmt, iCol+1);\n      *pn = sqlite3_column_bytes(pCsr->pStmt, iCol+1);\n    }\n  }\n  return rc;\n}\n\nstatic int fts5CsrPoslist(\n  Fts5Cursor *pCsr, \n  int iPhrase, \n  const u8 **pa,\n  int *pn\n){\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n  int rc = SQLITE_OK;\n  int bLive = (pCsr->pSorter==0);\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_POSLIST) ){\n\n    if( pConfig->eDetail!=FTS5_DETAIL_FULL ){\n      Fts5PoslistPopulator *aPopulator;\n      int i;\n      aPopulator = sqlite3Fts5ExprClearPoslists(pCsr->pExpr, bLive);\n      if( aPopulator==0 ) rc = SQLITE_NOMEM;\n      for(i=0; i<pConfig->nCol && rc==SQLITE_OK; i++){\n        int n; const char *z;\n        rc = fts5ApiColumnText((Fts5Context*)pCsr, i, &z, &n);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5ExprPopulatePoslists(\n              pConfig, pCsr->pExpr, aPopulator, i, z, n\n          );\n        }\n      }\n      sqlite3_free(aPopulator);\n\n      if( pCsr->pSorter ){\n        sqlite3Fts5ExprCheckPoslists(pCsr->pExpr, pCsr->pSorter->iRowid);\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_POSLIST);\n  }\n\n  if( pCsr->pSorter && pConfig->eDetail==FTS5_DETAIL_FULL ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n    *pn = pSorter->aIdx[iPhrase] - i1;\n    *pa = &pSorter->aPoslist[i1];\n  }else{\n    *pn = sqlite3Fts5ExprPoslist(pCsr->pExpr, iPhrase, pa);\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the Fts5Cursor.nInstCount and aInst[] variables are populated\n** correctly for the current view. Return SQLITE_OK if successful, or an\n** SQLite error code otherwise.\n*/\nstatic int fts5CacheInstArray(Fts5Cursor *pCsr){\n  int rc = SQLITE_OK;\n  Fts5PoslistReader *aIter;       /* One iterator for each phrase */\n  int nIter;                      /* Number of iterators/phrases */\n  \n  nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  if( pCsr->aInstIter==0 ){\n    int nByte = sizeof(Fts5PoslistReader) * nIter;\n    pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n  aIter = pCsr->aInstIter;\n\n  if( aIter ){\n    int nInst = 0;                /* Number instances seen so far */\n    int i;\n\n    /* Initialize all iterators */\n    for(i=0; i<nIter && rc==SQLITE_OK; i++){\n      const u8 *a;\n      int n; \n      rc = fts5CsrPoslist(pCsr, i, &a, &n);\n      if( rc==SQLITE_OK ){\n        sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      while( 1 ){\n        int *aInst;\n        int iBest = -1;\n        for(i=0; i<nIter; i++){\n          if( (aIter[i].bEof==0) \n              && (iBest<0 || aIter[i].iPos<aIter[iBest].iPos) \n            ){\n            iBest = i;\n          }\n        }\n        if( iBest<0 ) break;\n\n        nInst++;\n        if( nInst>=pCsr->nInstAlloc ){\n          pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;\n          aInst = (int*)sqlite3_realloc(\n              pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3\n              );\n          if( aInst ){\n            pCsr->aInst = aInst;\n          }else{\n            rc = SQLITE_NOMEM;\n            break;\n          }\n        }\n\n        aInst = &pCsr->aInst[3 * (nInst-1)];\n        aInst[0] = iBest;\n        aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);\n        aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);\n        sqlite3Fts5PoslistReaderNext(&aIter[iBest]);\n      }\n    }\n\n    pCsr->nInstCount = nInst;\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_INST);\n  }\n  return rc;\n}\n\nstatic int fts5ApiInstCount(Fts5Context *pCtx, int *pnInst){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) ){\n    *pnInst = pCsr->nInstCount;\n  }\n  return rc;\n}\n\nstatic int fts5ApiInst(\n  Fts5Context *pCtx, \n  int iIdx, \n  int *piPhrase, \n  int *piCol, \n  int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int rc = SQLITE_OK;\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_INST)==0 \n   || SQLITE_OK==(rc = fts5CacheInstArray(pCsr)) \n  ){\n    if( iIdx<0 || iIdx>=pCsr->nInstCount ){\n      rc = SQLITE_RANGE;\n#if 0\n    }else if( fts5IsOffsetless((Fts5Table*)pCsr->base.pVtab) ){\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 2];\n      *piOff = -1;\n#endif\n    }else{\n      *piPhrase = pCsr->aInst[iIdx*3];\n      *piCol = pCsr->aInst[iIdx*3 + 1];\n      *piOff = pCsr->aInst[iIdx*3 + 2];\n    }\n  }\n  return rc;\n}\n\nstatic sqlite3_int64 fts5ApiRowid(Fts5Context *pCtx){\n  return fts5CursorRowid((Fts5Cursor*)pCtx);\n}\n\nstatic int fts5ColumnSizeCb(\n  void *pContext,                 /* Pointer to int */\n  int tflags,\n  const char *pUnused,            /* Buffer containing token */\n  int nUnused,                    /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  int *pCnt = (int*)pContext;\n  UNUSED_PARAM2(pUnused, nUnused);\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 ){\n    (*pCnt)++;\n  }\n  return SQLITE_OK;\n}\n\nstatic int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  int rc = SQLITE_OK;\n\n  if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){\n    if( pConfig->bColumnsize ){\n      i64 iRowid = fts5CursorRowid(pCsr);\n      rc = sqlite3Fts5StorageDocsize(pTab->pStorage, iRowid, pCsr->aColumnSize);\n    }else if( pConfig->zContent==0 ){\n      int i;\n      for(i=0; i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          pCsr->aColumnSize[i] = -1;\n        }\n      }\n    }else{\n      int i;\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i]==0 ){\n          const char *z; int n;\n          void *p = (void*)(&pCsr->aColumnSize[i]);\n          pCsr->aColumnSize[i] = 0;\n          rc = fts5ApiColumnText(pCtx, i, &z, &n);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3Fts5Tokenize(\n                pConfig, FTS5_TOKENIZE_AUX, z, n, p, fts5ColumnSizeCb\n            );\n          }\n        }\n      }\n    }\n    CsrFlagClear(pCsr, FTS5CSR_REQUIRE_DOCSIZE);\n  }\n  if( iCol<0 ){\n    int i;\n    *pnToken = 0;\n    for(i=0; i<pConfig->nCol; i++){\n      *pnToken += pCsr->aColumnSize[i];\n    }\n  }else if( iCol<pConfig->nCol ){\n    *pnToken = pCsr->aColumnSize[iCol];\n  }else{\n    *pnToken = 0;\n    rc = SQLITE_RANGE;\n  }\n  return rc;\n}\n\n/*\n** Implementation of the xSetAuxdata() method.\n*/\nstatic int fts5ApiSetAuxdata(\n  Fts5Context *pCtx,              /* Fts5 context */\n  void *pPtr,                     /* Pointer to save as auxdata */\n  void(*xDelete)(void*)           /* Destructor for pPtr (or NULL) */\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n\n  /* Search through the cursors list of Fts5Auxdata objects for one that\n  ** corresponds to the currently executing auxiliary function.  */\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    if( pData->xDelete ){\n      pData->xDelete(pData->pPtr);\n    }\n  }else{\n    int rc = SQLITE_OK;\n    pData = (Fts5Auxdata*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Auxdata));\n    if( pData==0 ){\n      if( xDelete ) xDelete(pPtr);\n      return rc;\n    }\n    pData->pAux = pCsr->pAux;\n    pData->pNext = pCsr->pAuxdata;\n    pCsr->pAuxdata = pData;\n  }\n\n  pData->xDelete = xDelete;\n  pData->pPtr = pPtr;\n  return SQLITE_OK;\n}\n\nstatic void *fts5ApiGetAuxdata(Fts5Context *pCtx, int bClear){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Auxdata *pData;\n  void *pRet = 0;\n\n  for(pData=pCsr->pAuxdata; pData; pData=pData->pNext){\n    if( pData->pAux==pCsr->pAux ) break;\n  }\n\n  if( pData ){\n    pRet = pData->pPtr;\n    if( bClear ){\n      pData->pPtr = 0;\n      pData->xDelete = 0;\n    }\n  }\n\n  return pRet;\n}\n\nstatic void fts5ApiPhraseNext(\n  Fts5Context *pUnused, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  UNUSED_PARAM(pUnused);\n  if( pIter->a>=pIter->b ){\n    *piCol = -1;\n    *piOff = -1;\n  }else{\n    int iVal;\n    pIter->a += fts5GetVarint32(pIter->a, iVal);\n    if( iVal==1 ){\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n      *piCol = iVal;\n      *piOff = 0;\n      pIter->a += fts5GetVarint32(pIter->a, iVal);\n    }\n    *piOff += (iVal-2);\n  }\n}\n\nstatic int fts5ApiPhraseFirst(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol, int *piOff\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  int n;\n  int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n  if( rc==SQLITE_OK ){\n    pIter->b = &pIter->a[n];\n    *piCol = 0;\n    *piOff = 0;\n    fts5ApiPhraseNext(pCtx, pIter, piCol, piOff);\n  }\n  return rc;\n}\n\nstatic void fts5ApiPhraseNextColumn(\n  Fts5Context *pCtx, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    if( pIter->a>=pIter->b ){\n      *piCol = -1;\n    }else{\n      int iIncr;\n      pIter->a += fts5GetVarint32(&pIter->a[0], iIncr);\n      *piCol += (iIncr-2);\n    }\n  }else{\n    while( 1 ){\n      int dummy;\n      if( pIter->a>=pIter->b ){\n        *piCol = -1;\n        return;\n      }\n      if( pIter->a[0]==0x01 ) break;\n      pIter->a += fts5GetVarint32(pIter->a, dummy);\n    }\n    pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n  }\n}\n\nstatic int fts5ApiPhraseFirstColumn(\n  Fts5Context *pCtx, \n  int iPhrase, \n  Fts5PhraseIter *pIter, \n  int *piCol\n){\n  int rc = SQLITE_OK;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Config *pConfig = ((Fts5Table*)(pCsr->base.pVtab))->pConfig;\n\n  if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n    Fts5Sorter *pSorter = pCsr->pSorter;\n    int n;\n    if( pSorter ){\n      int i1 = (iPhrase==0 ? 0 : pSorter->aIdx[iPhrase-1]);\n      n = pSorter->aIdx[iPhrase] - i1;\n      pIter->a = &pSorter->aPoslist[i1];\n    }else{\n      rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n);\n    }\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      *piCol = 0;\n      fts5ApiPhraseNextColumn(pCtx, pIter, piCol);\n    }\n  }else{\n    int n;\n    rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n);\n    if( rc==SQLITE_OK ){\n      pIter->b = &pIter->a[n];\n      if( n<=0 ){\n        *piCol = -1;\n      }else if( pIter->a[0]==0x01 ){\n        pIter->a += 1 + fts5GetVarint32(&pIter->a[1], *piCol);\n      }else{\n        *piCol = 0;\n      }\n    }\n  }\n\n  return rc;\n}\n\n\nstatic int fts5ApiQueryPhrase(Fts5Context*, int, void*, \n    int(*)(const Fts5ExtensionApi*, Fts5Context*, void*)\n);\n\nstatic const Fts5ExtensionApi sFts5Api = {\n  2,                            /* iVersion */\n  fts5ApiUserData,\n  fts5ApiColumnCount,\n  fts5ApiRowCount,\n  fts5ApiColumnTotalSize,\n  fts5ApiTokenize,\n  fts5ApiPhraseCount,\n  fts5ApiPhraseSize,\n  fts5ApiInstCount,\n  fts5ApiInst,\n  fts5ApiRowid,\n  fts5ApiColumnText,\n  fts5ApiColumnSize,\n  fts5ApiQueryPhrase,\n  fts5ApiSetAuxdata,\n  fts5ApiGetAuxdata,\n  fts5ApiPhraseFirst,\n  fts5ApiPhraseNext,\n  fts5ApiPhraseFirstColumn,\n  fts5ApiPhraseNextColumn,\n};\n\n/*\n** Implementation of API function xQueryPhrase().\n*/\nstatic int fts5ApiQueryPhrase(\n  Fts5Context *pCtx, \n  int iPhrase, \n  void *pUserData,\n  int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)\n){\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;\n  Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);\n  int rc;\n  Fts5Cursor *pNew = 0;\n\n  rc = fts5OpenMethod(pCsr->base.pVtab, (sqlite3_vtab_cursor**)&pNew);\n  if( rc==SQLITE_OK ){\n    pNew->ePlan = FTS5_PLAN_MATCH;\n    pNew->iFirstRowid = SMALLEST_INT64;\n    pNew->iLastRowid = LARGEST_INT64;\n    pNew->base.pVtab = (sqlite3_vtab*)pTab;\n    rc = sqlite3Fts5ExprClonePhrase(pCsr->pExpr, iPhrase, &pNew->pExpr);\n  }\n\n  if( rc==SQLITE_OK ){\n    for(rc = fts5CursorFirst(pTab, pNew, 0);\n        rc==SQLITE_OK && CsrFlagTest(pNew, FTS5CSR_EOF)==0;\n        rc = fts5NextMethod((sqlite3_vtab_cursor*)pNew)\n    ){\n      rc = xCallback(&sFts5Api, (Fts5Context*)pNew, pUserData);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n        break;\n      }\n    }\n  }\n\n  fts5CloseMethod((sqlite3_vtab_cursor*)pNew);\n  return rc;\n}\n\nstatic void fts5ApiInvoke(\n  Fts5Auxiliary *pAux,\n  Fts5Cursor *pCsr,\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  assert( pCsr->pAux==0 );\n  pCsr->pAux = pAux;\n  pAux->xFunc(&sFts5Api, (Fts5Context*)pCsr, context, argc, argv);\n  pCsr->pAux = 0;\n}\n\nstatic Fts5Cursor *fts5CursorFromCsrid(Fts5Global *pGlobal, i64 iCsrId){\n  Fts5Cursor *pCsr;\n  for(pCsr=pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){\n    if( pCsr->iCsrId==iCsrId ) break;\n  }\n  return pCsr;\n}\n\nstatic void fts5ApiCallback(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n\n  Fts5Auxiliary *pAux;\n  Fts5Cursor *pCsr;\n  i64 iCsrId;\n\n  assert( argc>=1 );\n  pAux = (Fts5Auxiliary*)sqlite3_user_data(context);\n  iCsrId = sqlite3_value_int64(argv[0]);\n\n  pCsr = fts5CursorFromCsrid(pAux->pGlobal, iCsrId);\n  if( pCsr==0 ){\n    char *zErr = sqlite3_mprintf(\"no such cursor: %lld\", iCsrId);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n  }else{\n    fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]);\n  }\n}\n\n\n/*\n** Given cursor id iId, return a pointer to the corresponding Fts5Index \n** object. Or NULL If the cursor id does not exist.\n**\n** If successful, set *ppConfig to point to the associated config object \n** before returning.\n*/\nstatic Fts5Index *sqlite3Fts5IndexFromCsrid(\n  Fts5Global *pGlobal,            /* FTS5 global context for db handle */\n  i64 iCsrId,                     /* Id of cursor to find */\n  Fts5Config **ppConfig           /* OUT: Configuration object */\n){\n  Fts5Cursor *pCsr;\n  Fts5Table *pTab;\n\n  pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);\n  pTab = (Fts5Table*)pCsr->base.pVtab;\n  *ppConfig = pTab->pConfig;\n\n  return pTab->pIndex;\n}\n\n/*\n** Return a \"position-list blob\" corresponding to the current position of\n** cursor pCsr via sqlite3_result_blob(). A position-list blob contains\n** the current position-list for each phrase in the query associated with\n** cursor pCsr.\n**\n** A position-list blob begins with (nPhrase-1) varints, where nPhrase is\n** the number of phrases in the query. Following the varints are the\n** concatenated position lists for each phrase, in order.\n**\n** The first varint (if it exists) contains the size of the position list\n** for phrase 0. The second (same disclaimer) contains the size of position\n** list 1. And so on. There is no size field for the final position list,\n** as it can be derived from the total size of the blob.\n*/\nstatic int fts5PoslistBlob(sqlite3_context *pCtx, Fts5Cursor *pCsr){\n  int i;\n  int rc = SQLITE_OK;\n  int nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);\n  Fts5Buffer val;\n\n  memset(&val, 0, sizeof(Fts5Buffer));\n  switch( ((Fts5Table*)(pCsr->base.pVtab))->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n\n      /* Append the varints */\n      for(i=0; i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &dummy);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        nPoslist = sqlite3Fts5ExprPoslist(pCsr->pExpr, i, &pPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n\n      /* Append the varints */\n      for(i=0; rc==SQLITE_OK && i<(nPhrase-1); i++){\n        const u8 *dummy;\n        int nByte;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &dummy, &nByte);\n        sqlite3Fts5BufferAppendVarint(&rc, &val, nByte);\n      }\n\n      /* Append the position lists */\n      for(i=0; rc==SQLITE_OK && i<nPhrase; i++){\n        const u8 *pPoslist;\n        int nPoslist;\n        rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, i, &pPoslist, &nPoslist);\n        sqlite3Fts5BufferAppendBlob(&rc, &val, nPoslist, pPoslist);\n      }\n      break;\n\n    default:\n      break;\n  }\n\n  sqlite3_result_blob(pCtx, val.p, val.n, sqlite3_free);\n  return rc;\n}\n\n/* \n** This is the xColumn method, called by SQLite to request a value from\n** the row that the supplied cursor currently points to.\n*/\nstatic int fts5ColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);\n  Fts5Config *pConfig = pTab->pConfig;\n  Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;\n  int rc = SQLITE_OK;\n  \n  assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );\n\n  if( pCsr->ePlan==FTS5_PLAN_SPECIAL ){\n    if( iCol==pConfig->nCol ){\n      sqlite3_result_int64(pCtx, pCsr->iSpecial);\n    }\n  }else\n\n  if( iCol==pConfig->nCol ){\n    /* User is requesting the value of the special column with the same name\n    ** as the table. Return the cursor integer id number. This value is only\n    ** useful in that it may be passed as the first argument to an FTS5\n    ** auxiliary function.  */\n    sqlite3_result_int64(pCtx, pCsr->iCsrId);\n  }else if( iCol==pConfig->nCol+1 ){\n\n    /* The value of the \"rank\" column. */\n    if( pCsr->ePlan==FTS5_PLAN_SOURCE ){\n      fts5PoslistBlob(pCtx, pCsr);\n    }else if( \n        pCsr->ePlan==FTS5_PLAN_MATCH\n     || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH\n    ){\n      if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){\n        fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg);\n      }\n    }\n  }else if( !fts5IsContentless(pTab) ){\n    rc = fts5SeekCursor(pCsr, 1);\n    if( rc==SQLITE_OK ){\n      sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1));\n    }\n  }\n  return rc;\n}\n\n\n/*\n** This routine implements the xFindFunction method for the FTS3\n** virtual table.\n*/\nstatic int fts5FindFunctionMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  int nUnused,                    /* Number of SQL function arguments */\n  const char *zName,              /* Name of SQL function */\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */\n  void **ppArg                    /* OUT: User data for *pxFunc */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  Fts5Auxiliary *pAux;\n\n  UNUSED_PARAM(nUnused);\n  pAux = fts5FindAuxiliary(pTab, zName);\n  if( pAux ){\n    *pxFunc = fts5ApiCallback;\n    *ppArg = (void*)pAux;\n    return 1;\n  }\n\n  /* No function of the specified name was found. Return 0. */\n  return 0;\n}\n\n/*\n** Implementation of FTS5 xRename method. Rename an fts5 table.\n*/\nstatic int fts5RenameMethod(\n  sqlite3_vtab *pVtab,            /* Virtual table handle */\n  const char *zName               /* New name of table */\n){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  return sqlite3Fts5StorageRename(pTab->pStorage, zName);\n}\n\n/*\n** The xSavepoint() method.\n**\n** Flush the contents of the pending-terms table to disk.\n*/\nstatic int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageSync(pTab->pStorage);\n}\n\n/*\n** The xRelease() method.\n**\n** This is a no-op.\n*/\nstatic int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageSync(pTab->pStorage);\n}\n\n/*\n** The xRollbackTo() method.\n**\n** Discard the contents of the pending terms table.\n*/\nstatic int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){\n  Fts5Table *pTab = (Fts5Table*)pVtab;\n  UNUSED_PARAM(iSavepoint);  /* Call below is a no-op for NDEBUG builds */\n  fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);\n  fts5TripCursors(pTab);\n  return sqlite3Fts5StorageRollback(pTab->pStorage);\n}\n\n/*\n** Register a new auxiliary function with global context pGlobal.\n*/\nstatic int fts5CreateAux(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_extension_function xFunc,  /* Aux. function implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  int rc = sqlite3_overload_function(pGlobal->db, zName, -1);\n  if( rc==SQLITE_OK ){\n    Fts5Auxiliary *pAux;\n    int nName;                      /* Size of zName in bytes, including \\0 */\n    int nByte;                      /* Bytes of space to allocate */\n\n    nName = (int)strlen(zName) + 1;\n    nByte = sizeof(Fts5Auxiliary) + nName;\n    pAux = (Fts5Auxiliary*)sqlite3_malloc(nByte);\n    if( pAux ){\n      memset(pAux, 0, nByte);\n      pAux->zFunc = (char*)&pAux[1];\n      memcpy(pAux->zFunc, zName, nName);\n      pAux->pGlobal = pGlobal;\n      pAux->pUserData = pUserData;\n      pAux->xFunc = xFunc;\n      pAux->xDestroy = xDestroy;\n      pAux->pNext = pGlobal->pAux;\n      pGlobal->pAux = pAux;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Register a new tokenizer. This is the implementation of the \n** fts5_api.xCreateTokenizer() method.\n*/\nstatic int fts5CreateTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void *pUserData,                /* User data for aux. function */\n  fts5_tokenizer *pTokenizer,     /* Tokenizer implementation */\n  void(*xDestroy)(void*)          /* Destructor for pUserData */\n){\n  Fts5Global *pGlobal = (Fts5Global*)pApi;\n  Fts5TokenizerModule *pNew;\n  int nName;                      /* Size of zName and its \\0 terminator */\n  int nByte;                      /* Bytes of space to allocate */\n  int rc = SQLITE_OK;\n\n  nName = (int)strlen(zName) + 1;\n  nByte = sizeof(Fts5TokenizerModule) + nName;\n  pNew = (Fts5TokenizerModule*)sqlite3_malloc(nByte);\n  if( pNew ){\n    memset(pNew, 0, nByte);\n    pNew->zName = (char*)&pNew[1];\n    memcpy(pNew->zName, zName, nName);\n    pNew->pUserData = pUserData;\n    pNew->x = *pTokenizer;\n    pNew->xDestroy = xDestroy;\n    pNew->pNext = pGlobal->pTok;\n    pGlobal->pTok = pNew;\n    if( pNew->pNext==0 ){\n      pGlobal->pDfltTok = pNew;\n    }\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n\n  return rc;\n}\n\nstatic Fts5TokenizerModule *fts5LocateTokenizer(\n  Fts5Global *pGlobal, \n  const char *zName\n){\n  Fts5TokenizerModule *pMod = 0;\n\n  if( zName==0 ){\n    pMod = pGlobal->pDfltTok;\n  }else{\n    for(pMod=pGlobal->pTok; pMod; pMod=pMod->pNext){\n      if( sqlite3_stricmp(zName, pMod->zName)==0 ) break;\n    }\n  }\n\n  return pMod;\n}\n\n/*\n** Find a tokenizer. This is the implementation of the \n** fts5_api.xFindTokenizer() method.\n*/\nstatic int fts5FindTokenizer(\n  fts5_api *pApi,                 /* Global context (one per db handle) */\n  const char *zName,              /* Name of new function */\n  void **ppUserData,\n  fts5_tokenizer *pTokenizer      /* Populate this object */\n){\n  int rc = SQLITE_OK;\n  Fts5TokenizerModule *pMod;\n\n  pMod = fts5LocateTokenizer((Fts5Global*)pApi, zName);\n  if( pMod ){\n    *pTokenizer = pMod->x;\n    *ppUserData = pMod->pUserData;\n  }else{\n    memset(pTokenizer, 0, sizeof(fts5_tokenizer));\n    rc = SQLITE_ERROR;\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5GetTokenizer(\n  Fts5Global *pGlobal, \n  const char **azArg,\n  int nArg,\n  Fts5Tokenizer **ppTok,\n  fts5_tokenizer **ppTokApi,\n  char **pzErr\n){\n  Fts5TokenizerModule *pMod;\n  int rc = SQLITE_OK;\n\n  pMod = fts5LocateTokenizer(pGlobal, nArg==0 ? 0 : azArg[0]);\n  if( pMod==0 ){\n    assert( nArg>0 );\n    rc = SQLITE_ERROR;\n    *pzErr = sqlite3_mprintf(\"no such tokenizer: %s\", azArg[0]);\n  }else{\n    rc = pMod->x.xCreate(pMod->pUserData, &azArg[1], (nArg?nArg-1:0), ppTok);\n    *ppTokApi = &pMod->x;\n    if( rc!=SQLITE_OK && pzErr ){\n      *pzErr = sqlite3_mprintf(\"error in tokenizer constructor\");\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    *ppTokApi = 0;\n    *ppTok = 0;\n  }\n\n  return rc;\n}\n\nstatic void fts5ModuleDestroy(void *pCtx){\n  Fts5TokenizerModule *pTok, *pNextTok;\n  Fts5Auxiliary *pAux, *pNextAux;\n  Fts5Global *pGlobal = (Fts5Global*)pCtx;\n\n  for(pAux=pGlobal->pAux; pAux; pAux=pNextAux){\n    pNextAux = pAux->pNext;\n    if( pAux->xDestroy ) pAux->xDestroy(pAux->pUserData);\n    sqlite3_free(pAux);\n  }\n\n  for(pTok=pGlobal->pTok; pTok; pTok=pNextTok){\n    pNextTok = pTok->pNext;\n    if( pTok->xDestroy ) pTok->xDestroy(pTok->pUserData);\n    sqlite3_free(pTok);\n  }\n\n  sqlite3_free(pGlobal);\n}\n\nstatic void fts5Fts5Func(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apArg           /* Function arguments */\n){\n  Fts5Global *pGlobal = (Fts5Global*)sqlite3_user_data(pCtx);\n  fts5_api **ppApi;\n  UNUSED_PARAM(nArg);\n  assert( nArg==1 );\n  ppApi = (fts5_api**)sqlite3_value_pointer(apArg[0], \"fts5_api_ptr\");\n  if( ppApi ) *ppApi = &pGlobal->api;\n}\n\n/*\n** Implementation of fts5_source_id() function.\n*/\nstatic void fts5SourceIdFunc(\n  sqlite3_context *pCtx,          /* Function call context */\n  int nArg,                       /* Number of args */\n  sqlite3_value **apUnused        /* Function arguments */\n){\n  assert( nArg==0 );\n  UNUSED_PARAM2(nArg, apUnused);\n  sqlite3_result_text(pCtx, \"fts5: 2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de48827\", -1, SQLITE_TRANSIENT);\n}\n\nstatic int fts5Init(sqlite3 *db){\n  static const sqlite3_module fts5Mod = {\n    /* iVersion      */ 2,\n    /* xCreate       */ fts5CreateMethod,\n    /* xConnect      */ fts5ConnectMethod,\n    /* xBestIndex    */ fts5BestIndexMethod,\n    /* xDisconnect   */ fts5DisconnectMethod,\n    /* xDestroy      */ fts5DestroyMethod,\n    /* xOpen         */ fts5OpenMethod,\n    /* xClose        */ fts5CloseMethod,\n    /* xFilter       */ fts5FilterMethod,\n    /* xNext         */ fts5NextMethod,\n    /* xEof          */ fts5EofMethod,\n    /* xColumn       */ fts5ColumnMethod,\n    /* xRowid        */ fts5RowidMethod,\n    /* xUpdate       */ fts5UpdateMethod,\n    /* xBegin        */ fts5BeginMethod,\n    /* xSync         */ fts5SyncMethod,\n    /* xCommit       */ fts5CommitMethod,\n    /* xRollback     */ fts5RollbackMethod,\n    /* xFindFunction */ fts5FindFunctionMethod,\n    /* xRename       */ fts5RenameMethod,\n    /* xSavepoint    */ fts5SavepointMethod,\n    /* xRelease      */ fts5ReleaseMethod,\n    /* xRollbackTo   */ fts5RollbackToMethod,\n  };\n\n  int rc;\n  Fts5Global *pGlobal = 0;\n\n  pGlobal = (Fts5Global*)sqlite3_malloc(sizeof(Fts5Global));\n  if( pGlobal==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    void *p = (void*)pGlobal;\n    memset(pGlobal, 0, sizeof(Fts5Global));\n    pGlobal->db = db;\n    pGlobal->api.iVersion = 2;\n    pGlobal->api.xCreateFunction = fts5CreateAux;\n    pGlobal->api.xCreateTokenizer = fts5CreateTokenizer;\n    pGlobal->api.xFindTokenizer = fts5FindTokenizer;\n    rc = sqlite3_create_module_v2(db, \"fts5\", &fts5Mod, p, fts5ModuleDestroy);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5IndexInit(db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5ExprInit(pGlobal, db);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5AuxInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5TokenizerInit(&pGlobal->api);\n    if( rc==SQLITE_OK ) rc = sqlite3Fts5VocabInit(pGlobal, db);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5\", 1, SQLITE_UTF8, p, fts5Fts5Func, 0, 0\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_create_function(\n          db, \"fts5_source_id\", 0, SQLITE_UTF8, p, fts5SourceIdFunc, 0, 0\n      );\n    }\n  }\n\n  /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file\n  ** fts5_test_mi.c is compiled and linked into the executable. And call\n  ** its entry point to enable the matchinfo() demo.  */\n#ifdef SQLITE_FTS5_ENABLE_TEST_MI\n  if( rc==SQLITE_OK ){\n    extern int sqlite3Fts5TestRegisterMatchinfo(sqlite3*);\n    rc = sqlite3Fts5TestRegisterMatchinfo(db);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** The following functions are used to register the module with SQLite. If\n** this module is being built as part of the SQLite core (SQLITE_CORE is\n** defined), then sqlite3_open() will call sqlite3Fts5Init() directly.\n**\n** Or, if this module is being built as a loadable extension, \n** sqlite3Fts5Init() is omitted and the two standard entry points\n** sqlite3_fts_init() and sqlite3_fts5_init() defined instead.\n*/\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_fts5_init(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  (void)pzErrMsg;  /* Unused parameter */\n  return fts5Init(db);\n}\n#else\nSQLITE_PRIVATE int sqlite3Fts5Init(sqlite3 *db){\n  return fts5Init(db);\n}\n#endif\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n*/\n\n\n\n/* #include \"fts5Int.h\" */\n\nstruct Fts5Storage {\n  Fts5Config *pConfig;\n  Fts5Index *pIndex;\n  int bTotalsValid;               /* True if nTotalRow/aTotalSize[] are valid */\n  i64 nTotalRow;                  /* Total number of rows in FTS table */\n  i64 *aTotalSize;                /* Total sizes of each column */ \n  sqlite3_stmt *aStmt[11];\n};\n\n\n#if FTS5_STMT_SCAN_ASC!=0 \n# error \"FTS5_STMT_SCAN_ASC mismatch\" \n#endif\n#if FTS5_STMT_SCAN_DESC!=1 \n# error \"FTS5_STMT_SCAN_DESC mismatch\" \n#endif\n#if FTS5_STMT_LOOKUP!=2\n# error \"FTS5_STMT_LOOKUP mismatch\" \n#endif\n\n#define FTS5_STMT_INSERT_CONTENT  3\n#define FTS5_STMT_REPLACE_CONTENT 4\n#define FTS5_STMT_DELETE_CONTENT  5\n#define FTS5_STMT_REPLACE_DOCSIZE  6\n#define FTS5_STMT_DELETE_DOCSIZE  7\n#define FTS5_STMT_LOOKUP_DOCSIZE  8\n#define FTS5_STMT_REPLACE_CONFIG 9\n#define FTS5_STMT_SCAN 10\n\n/*\n** Prepare the two insert statements - Fts5Storage.pInsertContent and\n** Fts5Storage.pInsertDocsize - if they have not already been prepared.\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageGetStmt(\n  Fts5Storage *p,                 /* Storage handle */\n  int eStmt,                      /* FTS5_STMT_XXX constant */\n  sqlite3_stmt **ppStmt,          /* OUT: Prepared statement handle */\n  char **pzErrMsg                 /* OUT: Error message (if any) */\n){\n  int rc = SQLITE_OK;\n\n  /* If there is no %_docsize table, there should be no requests for \n  ** statements to operate on it.  */\n  assert( p->pConfig->bColumnsize || (\n        eStmt!=FTS5_STMT_REPLACE_DOCSIZE \n     && eStmt!=FTS5_STMT_DELETE_DOCSIZE \n     && eStmt!=FTS5_STMT_LOOKUP_DOCSIZE \n  ));\n\n  assert( eStmt>=0 && eStmt<ArraySize(p->aStmt) );\n  if( p->aStmt[eStmt]==0 ){\n    const char *azStmt[] = {\n      \"SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC\",\n      \"SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC\",\n      \"SELECT %s FROM %s T WHERE T.%Q=?\",               /* LOOKUP  */\n\n      \"INSERT INTO %Q.'%q_content' VALUES(%s)\",         /* INSERT_CONTENT  */\n      \"REPLACE INTO %Q.'%q_content' VALUES(%s)\",        /* REPLACE_CONTENT */\n      \"DELETE FROM %Q.'%q_content' WHERE id=?\",         /* DELETE_CONTENT  */\n      \"REPLACE INTO %Q.'%q_docsize' VALUES(?,?)\",       /* REPLACE_DOCSIZE  */\n      \"DELETE FROM %Q.'%q_docsize' WHERE id=?\",         /* DELETE_DOCSIZE  */\n\n      \"SELECT sz FROM %Q.'%q_docsize' WHERE id=?\",      /* LOOKUP_DOCSIZE  */\n\n      \"REPLACE INTO %Q.'%q_config' VALUES(?,?)\",        /* REPLACE_CONFIG */\n      \"SELECT %s FROM %s AS T\",                         /* SCAN */\n    };\n    Fts5Config *pC = p->pConfig;\n    char *zSql = 0;\n\n    switch( eStmt ){\n      case FTS5_STMT_SCAN:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent\n        );\n        break;\n\n      case FTS5_STMT_SCAN_ASC:\n      case FTS5_STMT_SCAN_DESC:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zContentExprlist, \n            pC->zContent, pC->zContentRowid, pC->zContentRowid,\n            pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_LOOKUP:\n        zSql = sqlite3_mprintf(azStmt[eStmt], \n            pC->zContentExprlist, pC->zContent, pC->zContentRowid\n        );\n        break;\n\n      case FTS5_STMT_INSERT_CONTENT: \n      case FTS5_STMT_REPLACE_CONTENT: {\n        int nCol = pC->nCol + 1;\n        char *zBind;\n        int i;\n\n        zBind = sqlite3_malloc(1 + nCol*2);\n        if( zBind ){\n          for(i=0; i<nCol; i++){\n            zBind[i*2] = '?';\n            zBind[i*2 + 1] = ',';\n          }\n          zBind[i*2-1] = '\\0';\n          zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName, zBind);\n          sqlite3_free(zBind);\n        }\n        break;\n      }\n\n      default:\n        zSql = sqlite3_mprintf(azStmt[eStmt], pC->zDb, pC->zName);\n        break;\n    }\n\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_prepare_v3(pC->db, zSql, -1,\n                              SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);\n      sqlite3_free(zSql);\n      if( rc!=SQLITE_OK && pzErrMsg ){\n        *pzErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pC->db));\n      }\n    }\n  }\n\n  *ppStmt = p->aStmt[eStmt];\n  sqlite3_reset(*ppStmt);\n  return rc;\n}\n\n\nstatic int fts5ExecPrintf(\n  sqlite3 *db,\n  char **pzErr,\n  const char *zFormat,\n  ...\n){\n  int rc;\n  va_list ap;                     /* ... printf arguments */\n  char *zSql;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    rc = sqlite3_exec(db, zSql, 0, 0, pzErr);\n    sqlite3_free(zSql);\n  }\n\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error\n** code otherwise.\n*/\nstatic int sqlite3Fts5DropAll(Fts5Config *pConfig){\n  int rc = fts5ExecPrintf(pConfig->db, 0, \n      \"DROP TABLE IF EXISTS %Q.'%q_data';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_idx';\"\n      \"DROP TABLE IF EXISTS %Q.'%q_config';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    rc = fts5ExecPrintf(pConfig->db, 0, \n        \"DROP TABLE IF EXISTS %Q.'%q_content';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n  return rc;\n}\n\nstatic void fts5StorageRenameOne(\n  Fts5Config *pConfig,            /* Current FTS5 configuration */\n  int *pRc,                       /* IN/OUT: Error code */\n  const char *zTail,              /* Tail of table name e.g. \"data\", \"config\" */\n  const char *zName               /* New name of FTS5 table */\n){\n  if( *pRc==SQLITE_OK ){\n    *pRc = fts5ExecPrintf(pConfig->db, 0, \n        \"ALTER TABLE %Q.'%q_%s' RENAME TO '%q_%s';\",\n        pConfig->zDb, pConfig->zName, zTail, zName, zTail\n    );\n  }\n}\n\nstatic int sqlite3Fts5StorageRename(Fts5Storage *pStorage, const char *zName){\n  Fts5Config *pConfig = pStorage->pConfig;\n  int rc = sqlite3Fts5StorageSync(pStorage);\n\n  fts5StorageRenameOne(pConfig, &rc, \"data\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"idx\", zName);\n  fts5StorageRenameOne(pConfig, &rc, \"config\", zName);\n  if( pConfig->bColumnsize ){\n    fts5StorageRenameOne(pConfig, &rc, \"docsize\", zName);\n  }\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    fts5StorageRenameOne(pConfig, &rc, \"content\", zName);\n  }\n  return rc;\n}\n\n/*\n** Create the shadow table named zPost, with definition zDefn. Return\n** SQLITE_OK if successful, or an SQLite error code otherwise.\n*/\nstatic int sqlite3Fts5CreateTable(\n  Fts5Config *pConfig,            /* FTS5 configuration */\n  const char *zPost,              /* Shadow table to create (e.g. \"content\") */\n  const char *zDefn,              /* Columns etc. for shadow table */\n  int bWithout,                   /* True for without rowid */\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc;\n  char *zErr = 0;\n\n  rc = fts5ExecPrintf(pConfig->db, &zErr, \"CREATE TABLE %Q.'%q_%q'(%s)%s\",\n      pConfig->zDb, pConfig->zName, zPost, zDefn, \n#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID\n      bWithout?\" WITHOUT ROWID\":\n#endif\n      \"\"\n  );\n  if( zErr ){\n    *pzErr = sqlite3_mprintf(\n        \"fts5: error creating shadow table %q_%s: %s\", \n        pConfig->zName, zPost, zErr\n    );\n    sqlite3_free(zErr);\n  }\n\n  return rc;\n}\n\n/*\n** Open a new Fts5Index handle. If the bCreate argument is true, create\n** and initialize the underlying tables \n**\n** If successful, set *pp to point to the new object and return SQLITE_OK.\n** Otherwise, set *pp to NULL and return an SQLite error code.\n*/\nstatic int sqlite3Fts5StorageOpen(\n  Fts5Config *pConfig, \n  Fts5Index *pIndex, \n  int bCreate, \n  Fts5Storage **pp,\n  char **pzErr                    /* OUT: Error message */\n){\n  int rc = SQLITE_OK;\n  Fts5Storage *p;                 /* New object */\n  int nByte;                      /* Bytes of space to allocate */\n\n  nByte = sizeof(Fts5Storage)               /* Fts5Storage object */\n        + pConfig->nCol * sizeof(i64);      /* Fts5Storage.aTotalSize[] */\n  *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);\n  if( !p ) return SQLITE_NOMEM;\n\n  memset(p, 0, nByte);\n  p->aTotalSize = (i64*)&p[1];\n  p->pConfig = pConfig;\n  p->pIndex = pIndex;\n\n  if( bCreate ){\n    if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n      int nDefn = 32 + pConfig->nCol*10;\n      char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);\n      if( zDefn==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        int i;\n        int iOff;\n        sqlite3_snprintf(nDefn, zDefn, \"id INTEGER PRIMARY KEY\");\n        iOff = (int)strlen(zDefn);\n        for(i=0; i<pConfig->nCol; i++){\n          sqlite3_snprintf(nDefn-iOff, &zDefn[iOff], \", c%d\", i);\n          iOff += (int)strlen(&zDefn[iOff]);\n        }\n        rc = sqlite3Fts5CreateTable(pConfig, \"content\", zDefn, 0, pzErr);\n      }\n      sqlite3_free(zDefn);\n    }\n\n    if( rc==SQLITE_OK && pConfig->bColumnsize ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"docsize\", \"id INTEGER PRIMARY KEY, sz BLOB\", 0, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5CreateTable(\n          pConfig, \"config\", \"k PRIMARY KEY, v\", 1, pzErr\n      );\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n    }\n  }\n\n  if( rc ){\n    sqlite3Fts5StorageClose(p);\n    *pp = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a handle opened by an earlier call to sqlite3Fts5StorageOpen().\n*/\nstatic int sqlite3Fts5StorageClose(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    int i;\n\n    /* Finalize all SQL statements */\n    for(i=0; i<ArraySize(p->aStmt); i++){\n      sqlite3_finalize(p->aStmt[i]);\n    }\n\n    sqlite3_free(p);\n  }\n  return rc;\n}\n\ntypedef struct Fts5InsertCtx Fts5InsertCtx;\nstruct Fts5InsertCtx {\n  Fts5Storage *pStorage;\n  int iCol;\n  int szCol;                      /* Size of column value in tokens */\n};\n\n/*\n** Tokenization callback used when inserting tokens into the FTS index.\n*/\nstatic int fts5StorageInsertCallback(\n  void *pContext,                 /* Pointer to Fts5InsertCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext;\n  Fts5Index *pIdx = pCtx->pStorage->pIndex;\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n  return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken);\n}\n\n/*\n** If a row with rowid iDel is present in the %_content table, add the\n** delete-markers to the FTS index necessary to delete it. Do not actually\n** remove the %_content row at this time though.\n*/\nstatic int fts5StorageDeleteFromIndex(\n  Fts5Storage *p, \n  i64 iDel, \n  sqlite3_value **apVal\n){\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pSeek = 0;        /* SELECT to read row iDel from %_data */\n  int rc;                         /* Return code */\n  int rc2;                        /* sqlite3_reset() return code */\n  int iCol;\n  Fts5InsertCtx ctx;\n\n  if( apVal==0 ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP, &pSeek, 0);\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3_bind_int64(pSeek, 1, iDel);\n    if( sqlite3_step(pSeek)!=SQLITE_ROW ){\n      return sqlite3_reset(pSeek);\n    }\n  }\n\n  ctx.pStorage = p;\n  ctx.iCol = -1;\n  rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 1, iDel);\n  for(iCol=1; rc==SQLITE_OK && iCol<=pConfig->nCol; iCol++){\n    if( pConfig->abUnindexed[iCol-1]==0 ){\n      const char *zText;\n      int nText;\n      if( pSeek ){\n        zText = (const char*)sqlite3_column_text(pSeek, iCol);\n        nText = sqlite3_column_bytes(pSeek, iCol);\n      }else{\n        zText = (const char*)sqlite3_value_text(apVal[iCol-1]);\n        nText = sqlite3_value_bytes(apVal[iCol-1]);\n      }\n      ctx.szCol = 0;\n      rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, \n          zText, nText, (void*)&ctx, fts5StorageInsertCallback\n      );\n      p->aTotalSize[iCol-1] -= (i64)ctx.szCol;\n    }\n  }\n  p->nTotalRow--;\n\n  rc2 = sqlite3_reset(pSeek);\n  if( rc==SQLITE_OK ) rc = rc2;\n  return rc;\n}\n\n\n/*\n** Insert a record into the %_docsize table. Specifically, do:\n**\n**   INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf);\n**\n** If there is no %_docsize table (as happens if the columnsize=0 option\n** is specified when the FTS5 table is created), this function is a no-op.\n*/\nstatic int fts5StorageInsertDocsize(\n  Fts5Storage *p,                 /* Storage module to write to */\n  i64 iRowid,                     /* id value */\n  Fts5Buffer *pBuf                /* sz value */\n){\n  int rc = SQLITE_OK;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pReplace, 1, iRowid);\n      sqlite3_bind_blob(pReplace, 2, pBuf->p, pBuf->n, SQLITE_STATIC);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n    }\n  }\n  return rc;\n}\n\n/*\n** Load the contents of the \"averages\" record from disk into the \n** p->nTotalRow and p->aTotalSize[] variables. If successful, and if\n** argument bCache is true, set the p->bTotalsValid flag to indicate\n** that the contents of aTotalSize[] and nTotalRow are valid until\n** further notice.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageLoadTotals(Fts5Storage *p, int bCache){\n  int rc = SQLITE_OK;\n  if( p->bTotalsValid==0 ){\n    rc = sqlite3Fts5IndexGetAverages(p->pIndex, &p->nTotalRow, p->aTotalSize);\n    p->bTotalsValid = bCache;\n  }\n  return rc;\n}\n\n/*\n** Store the current contents of the p->nTotalRow and p->aTotalSize[] \n** variables in the \"averages\" record on disk.\n**\n** Return SQLITE_OK if successful, or an SQLite error code if an error\n** occurs.\n*/\nstatic int fts5StorageSaveTotals(Fts5Storage *p){\n  int nCol = p->pConfig->nCol;\n  int i;\n  Fts5Buffer buf;\n  int rc = SQLITE_OK;\n  memset(&buf, 0, sizeof(buf));\n\n  sqlite3Fts5BufferAppendVarint(&rc, &buf, p->nTotalRow);\n  for(i=0; i<nCol; i++){\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, p->aTotalSize[i]);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\n/*\n** Remove a row from the FTS table.\n*/\nstatic int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel, sqlite3_value **apVal){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n  sqlite3_stmt *pDel = 0;\n\n  assert( pConfig->eContent!=FTS5_CONTENT_NORMAL || apVal==0 );\n  rc = fts5StorageLoadTotals(p, 1);\n\n  /* Delete the index records */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageDeleteFromIndex(p, iDel, apVal);\n  }\n\n  /* Delete the %_docsize record */\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  /* Delete the %_content record */\n  if( pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel, 0);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_int64(pDel, 1, iDel);\n      sqlite3_step(pDel);\n      rc = sqlite3_reset(pDel);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Delete all entries in the FTS5 index.\n*/\nstatic int sqlite3Fts5StorageDeleteAll(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;\n\n  /* Delete the contents of the %_data and %_docsize tables. */\n  rc = fts5ExecPrintf(pConfig->db, 0,\n      \"DELETE FROM %Q.'%q_data';\" \n      \"DELETE FROM %Q.'%q_idx';\",\n      pConfig->zDb, pConfig->zName,\n      pConfig->zDb, pConfig->zName\n  );\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    rc = fts5ExecPrintf(pConfig->db, 0,\n        \"DELETE FROM %Q.'%q_docsize';\",\n        pConfig->zDb, pConfig->zName\n    );\n  }\n\n  /* Reinitialize the %_data table. This call creates the initial structure\n  ** and averages records.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexReinit(p->pIndex);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5StorageConfigValue(p, \"version\", 0, FTS5_CURRENT_VERSION);\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRebuild(Fts5Storage *p){\n  Fts5Buffer buf = {0,0,0};\n  Fts5Config *pConfig = p->pConfig;\n  sqlite3_stmt *pScan = 0;\n  Fts5InsertCtx ctx;\n  int rc;\n\n  memset(&ctx, 0, sizeof(Fts5InsertCtx));\n  ctx.pStorage = p;\n  rc = sqlite3Fts5StorageDeleteAll(p);\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageLoadTotals(p, 1);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  }\n\n  while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pScan) ){\n    i64 iRowid = sqlite3_column_int64(pScan, 0);\n\n    sqlite3Fts5BufferZero(&buf);\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n    for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n      ctx.szCol = 0;\n      if( pConfig->abUnindexed[ctx.iCol]==0 ){\n        rc = sqlite3Fts5Tokenize(pConfig, \n            FTS5_TOKENIZE_DOCUMENT,\n            (const char*)sqlite3_column_text(pScan, ctx.iCol+1),\n            sqlite3_column_bytes(pScan, ctx.iCol+1),\n            (void*)&ctx,\n            fts5StorageInsertCallback\n        );\n      }\n      sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n      p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n    }\n    p->nTotalRow++;\n\n    if( rc==SQLITE_OK ){\n      rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n    }\n  }\n  sqlite3_free(buf.p);\n\n  /* Write the averages record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageSaveTotals(p);\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageOptimize(Fts5Storage *p){\n  return sqlite3Fts5IndexOptimize(p->pIndex);\n}\n\nstatic int sqlite3Fts5StorageMerge(Fts5Storage *p, int nMerge){\n  return sqlite3Fts5IndexMerge(p->pIndex, nMerge);\n}\n\nstatic int sqlite3Fts5StorageReset(Fts5Storage *p){\n  return sqlite3Fts5IndexReset(p->pIndex);\n}\n\n/*\n** Allocate a new rowid. This is used for \"external content\" tables when\n** a NULL value is inserted into the rowid column. The new rowid is allocated\n** by inserting a dummy row into the %_docsize table. The dummy will be\n** overwritten later.\n**\n** If the %_docsize table does not exist, SQLITE_MISMATCH is returned. In\n** this case the user is required to provide a rowid explicitly.\n*/\nstatic int fts5StorageNewRowid(Fts5Storage *p, i64 *piRowid){\n  int rc = SQLITE_MISMATCH;\n  if( p->pConfig->bColumnsize ){\n    sqlite3_stmt *pReplace = 0;\n    rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_DOCSIZE, &pReplace, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_null(pReplace, 1);\n      sqlite3_bind_null(pReplace, 2);\n      sqlite3_step(pReplace);\n      rc = sqlite3_reset(pReplace);\n    }\n    if( rc==SQLITE_OK ){\n      *piRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n    }\n  }\n  return rc;\n}\n\n/*\n** Insert a new row into the FTS content table.\n*/\nstatic int sqlite3Fts5StorageContentInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 *piRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;\n\n  /* Insert the new row into the %_content table. */\n  if( pConfig->eContent!=FTS5_CONTENT_NORMAL ){\n    if( sqlite3_value_type(apVal[1])==SQLITE_INTEGER ){\n      *piRowid = sqlite3_value_int64(apVal[1]);\n    }else{\n      rc = fts5StorageNewRowid(p, piRowid);\n    }\n  }else{\n    sqlite3_stmt *pInsert = 0;    /* Statement to write %_content table */\n    int i;                        /* Counter variable */\n    rc = fts5StorageGetStmt(p, FTS5_STMT_INSERT_CONTENT, &pInsert, 0);\n    for(i=1; rc==SQLITE_OK && i<=pConfig->nCol+1; i++){\n      rc = sqlite3_bind_value(pInsert, i, apVal[i]);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pInsert);\n      rc = sqlite3_reset(pInsert);\n    }\n    *piRowid = sqlite3_last_insert_rowid(pConfig->db);\n  }\n\n  return rc;\n}\n\n/*\n** Insert new entries into the FTS index and %_docsize table.\n*/\nstatic int sqlite3Fts5StorageIndexInsert(\n  Fts5Storage *p, \n  sqlite3_value **apVal, \n  i64 iRowid\n){\n  Fts5Config *pConfig = p->pConfig;\n  int rc = SQLITE_OK;             /* Return code */\n  Fts5InsertCtx ctx;              /* Tokenization callback context object */\n  Fts5Buffer buf;                 /* Buffer used to build up %_docsize blob */\n\n  memset(&buf, 0, sizeof(Fts5Buffer));\n  ctx.pStorage = p;\n  rc = fts5StorageLoadTotals(p, 1);\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexBeginWrite(p->pIndex, 0, iRowid);\n  }\n  for(ctx.iCol=0; rc==SQLITE_OK && ctx.iCol<pConfig->nCol; ctx.iCol++){\n    ctx.szCol = 0;\n    if( pConfig->abUnindexed[ctx.iCol]==0 ){\n      rc = sqlite3Fts5Tokenize(pConfig, \n          FTS5_TOKENIZE_DOCUMENT,\n          (const char*)sqlite3_value_text(apVal[ctx.iCol+2]),\n          sqlite3_value_bytes(apVal[ctx.iCol+2]),\n          (void*)&ctx,\n          fts5StorageInsertCallback\n      );\n    }\n    sqlite3Fts5BufferAppendVarint(&rc, &buf, ctx.szCol);\n    p->aTotalSize[ctx.iCol] += (i64)ctx.szCol;\n  }\n  p->nTotalRow++;\n\n  /* Write the %_docsize record */\n  if( rc==SQLITE_OK ){\n    rc = fts5StorageInsertDocsize(p, iRowid, &buf);\n  }\n  sqlite3_free(buf.p);\n\n  return rc;\n}\n\nstatic int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){\n  Fts5Config *pConfig = p->pConfig;\n  char *zSql;\n  int rc;\n\n  zSql = sqlite3_mprintf(\"SELECT count(*) FROM %Q.'%q_%s'\", \n      pConfig->zDb, pConfig->zName, zSuffix\n  );\n  if( zSql==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    sqlite3_stmt *pCnt = 0;\n    rc = sqlite3_prepare_v2(pConfig->db, zSql, -1, &pCnt, 0);\n    if( rc==SQLITE_OK ){\n      if( SQLITE_ROW==sqlite3_step(pCnt) ){\n        *pnRow = sqlite3_column_int64(pCnt, 0);\n      }\n      rc = sqlite3_finalize(pCnt);\n    }\n  }\n\n  sqlite3_free(zSql);\n  return rc;\n}\n\n/*\n** Context object used by sqlite3Fts5StorageIntegrity().\n*/\ntypedef struct Fts5IntegrityCtx Fts5IntegrityCtx;\nstruct Fts5IntegrityCtx {\n  i64 iRowid;\n  int iCol;\n  int szCol;\n  u64 cksum;\n  Fts5Termset *pTermset;\n  Fts5Config *pConfig;\n};\n\n\n/*\n** Tokenization callback used by integrity check.\n*/\nstatic int fts5StorageIntegrityCallback(\n  void *pContext,                 /* Pointer to Fts5IntegrityCtx object */\n  int tflags,\n  const char *pToken,             /* Buffer containing token */\n  int nToken,                     /* Size of token in bytes */\n  int iUnused1,                   /* Start offset of token */\n  int iUnused2                    /* End offset of token */\n){\n  Fts5IntegrityCtx *pCtx = (Fts5IntegrityCtx*)pContext;\n  Fts5Termset *pTermset = pCtx->pTermset;\n  int bPresent;\n  int ii;\n  int rc = SQLITE_OK;\n  int iPos;\n  int iCol;\n\n  UNUSED_PARAM2(iUnused1, iUnused2);\n  if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE;\n\n  if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){\n    pCtx->szCol++;\n  }\n\n  switch( pCtx->pConfig->eDetail ){\n    case FTS5_DETAIL_FULL:\n      iPos = pCtx->szCol-1;\n      iCol = pCtx->iCol;\n      break;\n\n    case FTS5_DETAIL_COLUMNS:\n      iPos = pCtx->iCol;\n      iCol = 0;\n      break;\n\n    default:\n      assert( pCtx->pConfig->eDetail==FTS5_DETAIL_NONE );\n      iPos = 0;\n      iCol = 0;\n      break;\n  }\n\n  rc = sqlite3Fts5TermsetAdd(pTermset, 0, pToken, nToken, &bPresent);\n  if( rc==SQLITE_OK && bPresent==0 ){\n    pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n        pCtx->iRowid, iCol, iPos, 0, pToken, nToken\n    );\n  }\n\n  for(ii=0; rc==SQLITE_OK && ii<pCtx->pConfig->nPrefix; ii++){\n    const int nChar = pCtx->pConfig->aPrefix[ii];\n    int nByte = sqlite3Fts5IndexCharlenToBytelen(pToken, nToken, nChar);\n    if( nByte ){\n      rc = sqlite3Fts5TermsetAdd(pTermset, ii+1, pToken, nByte, &bPresent);\n      if( bPresent==0 ){\n        pCtx->cksum ^= sqlite3Fts5IndexEntryCksum(\n            pCtx->iRowid, iCol, iPos, ii+1, pToken, nByte\n        );\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Check that the contents of the FTS index match that of the %_content\n** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return\n** some other SQLite error code if an error occurs while attempting to\n** determine this.\n*/\nstatic int sqlite3Fts5StorageIntegrity(Fts5Storage *p){\n  Fts5Config *pConfig = p->pConfig;\n  int rc;                         /* Return code */\n  int *aColSize;                  /* Array of size pConfig->nCol */\n  i64 *aTotalSize;                /* Array of size pConfig->nCol */\n  Fts5IntegrityCtx ctx;\n  sqlite3_stmt *pScan;\n\n  memset(&ctx, 0, sizeof(Fts5IntegrityCtx));\n  ctx.pConfig = p->pConfig;\n  aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));\n  if( !aTotalSize ) return SQLITE_NOMEM;\n  aColSize = (int*)&aTotalSize[pConfig->nCol];\n  memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);\n\n  /* Generate the expected index checksum based on the contents of the\n  ** %_content table. This block stores the checksum in ctx.cksum. */\n  rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);\n  if( rc==SQLITE_OK ){\n    int rc2;\n    while( SQLITE_ROW==sqlite3_step(pScan) ){\n      int i;\n      ctx.iRowid = sqlite3_column_int64(pScan, 0);\n      ctx.szCol = 0;\n      if( pConfig->bColumnsize ){\n        rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);\n      }\n      if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){\n        rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n      }\n      for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n        if( pConfig->abUnindexed[i] ) continue;\n        ctx.iCol = i;\n        ctx.szCol = 0;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          rc = sqlite3Fts5TermsetNew(&ctx.pTermset);\n        }\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5Tokenize(pConfig, \n              FTS5_TOKENIZE_DOCUMENT,\n              (const char*)sqlite3_column_text(pScan, i+1),\n              sqlite3_column_bytes(pScan, i+1),\n              (void*)&ctx,\n              fts5StorageIntegrityCallback\n          );\n        }\n        if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){\n          rc = FTS5_CORRUPT;\n        }\n        aTotalSize[i] += ctx.szCol;\n        if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){\n          sqlite3Fts5TermsetFree(ctx.pTermset);\n          ctx.pTermset = 0;\n        }\n      }\n      sqlite3Fts5TermsetFree(ctx.pTermset);\n      ctx.pTermset = 0;\n\n      if( rc!=SQLITE_OK ) break;\n    }\n    rc2 = sqlite3_reset(pScan);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n\n  /* Test that the \"totals\" (sometimes called \"averages\") record looks Ok */\n  if( rc==SQLITE_OK ){\n    int i;\n    rc = fts5StorageLoadTotals(p, 0);\n    for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){\n      if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;\n    }\n  }\n\n  /* Check that the %_docsize and %_content tables contain the expected\n  ** number of rows.  */\n  if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"content\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n  if( rc==SQLITE_OK && pConfig->bColumnsize ){\n    i64 nRow = 0;\n    rc = fts5StorageCount(p, \"docsize\", &nRow);\n    if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;\n  }\n\n  /* Pass the expected checksum down to the FTS index module. It will\n  ** verify, amongst other things, that it matches the checksum generated by\n  ** inspecting the index itself.  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);\n  }\n\n  sqlite3_free(aTotalSize);\n  return rc;\n}\n\n/*\n** Obtain an SQLite statement handle that may be used to read data from the\n** %_content table.\n*/\nstatic int sqlite3Fts5StorageStmt(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt **pp, \n  char **pzErrMsg\n){\n  int rc;\n  assert( eStmt==FTS5_STMT_SCAN_ASC \n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  rc = fts5StorageGetStmt(p, eStmt, pp, pzErrMsg);\n  if( rc==SQLITE_OK ){\n    assert( p->aStmt[eStmt]==*pp );\n    p->aStmt[eStmt] = 0;\n  }\n  return rc;\n}\n\n/*\n** Release an SQLite statement handle obtained via an earlier call to\n** sqlite3Fts5StorageStmt(). The eStmt parameter passed to this function\n** must match that passed to the sqlite3Fts5StorageStmt() call.\n*/\nstatic void sqlite3Fts5StorageStmtRelease(\n  Fts5Storage *p, \n  int eStmt, \n  sqlite3_stmt *pStmt\n){\n  assert( eStmt==FTS5_STMT_SCAN_ASC\n       || eStmt==FTS5_STMT_SCAN_DESC\n       || eStmt==FTS5_STMT_LOOKUP\n  );\n  if( p->aStmt[eStmt]==0 ){\n    sqlite3_reset(pStmt);\n    p->aStmt[eStmt] = pStmt;\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n}\n\nstatic int fts5StorageDecodeSizeArray(\n  int *aCol, int nCol,            /* Array to populate */\n  const u8 *aBlob, int nBlob      /* Record to read varints from */\n){\n  int i;\n  int iOff = 0;\n  for(i=0; i<nCol; i++){\n    if( iOff>=nBlob ) return 1;\n    iOff += fts5GetVarint32(&aBlob[iOff], aCol[i]);\n  }\n  return (iOff!=nBlob);\n}\n\n/*\n** Argument aCol points to an array of integers containing one entry for\n** each table column. This function reads the %_docsize record for the\n** specified rowid and populates aCol[] with the results.\n**\n** An SQLite error code is returned if an error occurs, or SQLITE_OK\n** otherwise.\n*/\nstatic int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){\n  int nCol = p->pConfig->nCol;    /* Number of user columns in table */\n  sqlite3_stmt *pLookup = 0;      /* Statement to query %_docsize */\n  int rc;                         /* Return Code */\n\n  assert( p->pConfig->bColumnsize );\n  rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);\n  if( rc==SQLITE_OK ){\n    int bCorrupt = 1;\n    sqlite3_bind_int64(pLookup, 1, iRowid);\n    if( SQLITE_ROW==sqlite3_step(pLookup) ){\n      const u8 *aBlob = sqlite3_column_blob(pLookup, 0);\n      int nBlob = sqlite3_column_bytes(pLookup, 0);\n      if( 0==fts5StorageDecodeSizeArray(aCol, nCol, aBlob, nBlob) ){\n        bCorrupt = 0;\n      }\n    }\n    rc = sqlite3_reset(pLookup);\n    if( bCorrupt && rc==SQLITE_OK ){\n      rc = FTS5_CORRUPT;\n    }\n  }\n\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnToken){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    *pnToken = 0;\n    if( iCol<0 ){\n      int i;\n      for(i=0; i<p->pConfig->nCol; i++){\n        *pnToken += p->aTotalSize[i];\n      }\n    }else if( iCol<p->pConfig->nCol ){\n      *pnToken = p->aTotalSize[iCol];\n    }else{\n      rc = SQLITE_RANGE;\n    }\n  }\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){\n  int rc = fts5StorageLoadTotals(p, 0);\n  if( rc==SQLITE_OK ){\n    *pnRow = p->nTotalRow;\n  }\n  return rc;\n}\n\n/*\n** Flush any data currently held in-memory to disk.\n*/\nstatic int sqlite3Fts5StorageSync(Fts5Storage *p){\n  int rc = SQLITE_OK;\n  i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);\n  if( p->bTotalsValid ){\n    rc = fts5StorageSaveTotals(p);\n    p->bTotalsValid = 0;\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexSync(p->pIndex);\n  }\n  sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid);\n  return rc;\n}\n\nstatic int sqlite3Fts5StorageRollback(Fts5Storage *p){\n  p->bTotalsValid = 0;\n  return sqlite3Fts5IndexRollback(p->pIndex);\n}\n\nstatic int sqlite3Fts5StorageConfigValue(\n  Fts5Storage *p, \n  const char *z,\n  sqlite3_value *pVal,\n  int iVal\n){\n  sqlite3_stmt *pReplace = 0;\n  int rc = fts5StorageGetStmt(p, FTS5_STMT_REPLACE_CONFIG, &pReplace, 0);\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_text(pReplace, 1, z, -1, SQLITE_STATIC);\n    if( pVal ){\n      sqlite3_bind_value(pReplace, 2, pVal);\n    }else{\n      sqlite3_bind_int(pReplace, 2, iVal);\n    }\n    sqlite3_step(pReplace);\n    rc = sqlite3_reset(pReplace);\n  }\n  if( rc==SQLITE_OK && pVal ){\n    int iNew = p->pConfig->iCookie + 1;\n    rc = sqlite3Fts5IndexSetCookie(p->pIndex, iNew);\n    if( rc==SQLITE_OK ){\n      p->pConfig->iCookie = iNew;\n    }\n  }\n  return rc;\n}\n\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/**************************************************************************\n** Start of ascii tokenizer implementation.\n*/\n\n/*\n** For tokenizers with no \"unicode\" modifier, the set of token characters\n** is the same as the set of ASCII range alphanumeric characters. \n*/\nstatic unsigned char aAsciiTokenChar[128] = {\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x00..0x0F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x10..0x1F */\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,   /* 0x20..0x2F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 0, 0, 0, 0, 0, 0,   /* 0x30..0x3F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x40..0x4F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x50..0x5F */\n  0, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   /* 0x60..0x6F */\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 0, 0, 0, 0, 0,   /* 0x70..0x7F */\n};\n\ntypedef struct AsciiTokenizer AsciiTokenizer;\nstruct AsciiTokenizer {\n  unsigned char aTokenChar[128];\n};\n\nstatic void fts5AsciiAddExceptions(\n  AsciiTokenizer *p, \n  const char *zArg, \n  int bTokenChars\n){\n  int i;\n  for(i=0; zArg[i]; i++){\n    if( (zArg[i] & 0x80)==0 ){\n      p->aTokenChar[(int)zArg[i]] = (unsigned char)bTokenChars;\n    }\n  }\n}\n\n/*\n** Delete a \"ascii\" tokenizer.\n*/\nstatic void fts5AsciiDelete(Fts5Tokenizer *p){\n  sqlite3_free(p);\n}\n\n/*\n** Create an \"ascii\" tokenizer.\n*/\nstatic int fts5AsciiCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;\n  AsciiTokenizer *p = 0;\n  UNUSED_PARAM(pUnused);\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = sqlite3_malloc(sizeof(AsciiTokenizer));\n    if( p==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      int i;\n      memset(p, 0, sizeof(AsciiTokenizer));\n      memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          fts5AsciiAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          fts5AsciiAddExceptions(p, zArg, 0);\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n      if( rc!=SQLITE_OK ){\n        fts5AsciiDelete((Fts5Tokenizer*)p);\n        p = 0;\n      }\n    }\n  }\n\n  *ppOut = (Fts5Tokenizer*)p;\n  return rc;\n}\n\n\nstatic void asciiFold(char *aOut, const char *aIn, int nByte){\n  int i;\n  for(i=0; i<nByte; i++){\n    char c = aIn[i];\n    if( c>='A' && c<='Z' ) c += 32;\n    aOut[i] = c;\n  }\n}\n\n/*\n** Tokenize some text using the ascii tokenizer.\n*/\nstatic int fts5AsciiTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  AsciiTokenizer *p = (AsciiTokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  int ie;\n  int is = 0;\n\n  char aFold[64];\n  int nFold = sizeof(aFold);\n  char *pFold = aFold;\n  unsigned char *a = p->aTokenChar;\n\n  UNUSED_PARAM(iUnused);\n\n  while( is<nText && rc==SQLITE_OK ){\n    int nByte;\n\n    /* Skip any leading divider characters. */\n    while( is<nText && ((pText[is]&0x80)==0 && a[(int)pText[is]]==0) ){\n      is++;\n    }\n    if( is==nText ) break;\n\n    /* Count the token characters */\n    ie = is+1;\n    while( ie<nText && ((pText[ie]&0x80) || a[(int)pText[ie]] ) ){\n      ie++;\n    }\n\n    /* Fold to lower case */\n    nByte = ie-is;\n    if( nByte>nFold ){\n      if( pFold!=aFold ) sqlite3_free(pFold);\n      pFold = sqlite3_malloc(nByte*2);\n      if( pFold==0 ){\n        rc = SQLITE_NOMEM;\n        break;\n      }\n      nFold = nByte*2;\n    }\n    asciiFold(pFold, &pText[is], nByte);\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, pFold, nByte, is, ie);\n    is = ie+1;\n  }\n  \n  if( pFold!=aFold ) sqlite3_free(pFold);\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of unicode61 tokenizer implementation.\n*/\n\n\n/*\n** The following two macros - READ_UTF8 and WRITE_UTF8 - have been copied\n** from the sqlite3 source file utf.c. If this file is compiled as part\n** of the amalgamation, they are not required.\n*/\n#ifndef SQLITE_AMALGAMATION\n\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (unsigned char)(c&0xFF);                 \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (unsigned char)((c>>6)&0x1F);     \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (unsigned char)((c>>12)&0x0F);    \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (unsigned char)((c>>18) & 0x07);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>12) & 0x3F);  \\\n    *zOut++ = 0x80 + (unsigned char)((c>>6) & 0x3F);   \\\n    *zOut++ = 0x80 + (unsigned char)(c & 0x3F);        \\\n  }                                                    \\\n}\n\n#endif /* ifndef SQLITE_AMALGAMATION */\n\ntypedef struct Unicode61Tokenizer Unicode61Tokenizer;\nstruct Unicode61Tokenizer {\n  unsigned char aTokenChar[128];  /* ASCII range token characters */\n  char *aFold;                    /* Buffer to fold text into */\n  int nFold;                      /* Size of aFold[] in bytes */\n  int bRemoveDiacritic;           /* True if remove_diacritics=1 is set */\n  int nException;\n  int *aiException;\n};\n\nstatic int fts5UnicodeAddExceptions(\n  Unicode61Tokenizer *p,          /* Tokenizer object */\n  const char *z,                  /* Characters to treat as exceptions */\n  int bTokenChars                 /* 1 for 'tokenchars', 0 for 'separators' */\n){\n  int rc = SQLITE_OK;\n  int n = (int)strlen(z);\n  int *aNew;\n\n  if( n>0 ){\n    aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));\n    if( aNew ){\n      int nNew = p->nException;\n      const unsigned char *zCsr = (const unsigned char*)z;\n      const unsigned char *zTerm = (const unsigned char*)&z[n];\n      while( zCsr<zTerm ){\n        int iCode;\n        int bToken;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( iCode<128 ){\n          p->aTokenChar[iCode] = (unsigned char)bTokenChars;\n        }else{\n          bToken = sqlite3Fts5UnicodeIsalnum(iCode);\n          assert( (bToken==0 || bToken==1) ); \n          assert( (bTokenChars==0 || bTokenChars==1) );\n          if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){\n            int i;\n            for(i=0; i<nNew; i++){\n              if( aNew[i]>iCode ) break;\n            }\n            memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));\n            aNew[i] = iCode;\n            nNew++;\n          }\n        }\n      }\n      p->aiException = aNew;\n      p->nException = nNew;\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Return true if the p->aiException[] array contains the value iCode.\n*/\nstatic int fts5UnicodeIsException(Unicode61Tokenizer *p, int iCode){\n  if( p->nException>0 ){\n    int *a = p->aiException;\n    int iLo = 0;\n    int iHi = p->nException-1;\n\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( iCode==a[iTest] ){\n        return 1;\n      }else if( iCode>a[iTest] ){\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n  }\n\n  return 0;\n}\n\n/*\n** Delete a \"unicode61\" tokenizer.\n*/\nstatic void fts5UnicodeDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTok;\n    sqlite3_free(p->aiException);\n    sqlite3_free(p->aFold);\n    sqlite3_free(p);\n  }\n  return;\n}\n\n/*\n** Create a \"unicode61\" tokenizer.\n*/\nstatic int fts5UnicodeCreate(\n  void *pUnused, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  int rc = SQLITE_OK;             /* Return code */\n  Unicode61Tokenizer *p = 0;      /* New tokenizer object */ \n\n  UNUSED_PARAM(pUnused);\n\n  if( nArg%2 ){\n    rc = SQLITE_ERROR;\n  }else{\n    p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer));\n    if( p ){\n      int i;\n      memset(p, 0, sizeof(Unicode61Tokenizer));\n      memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));\n      p->bRemoveDiacritic = 1;\n      p->nFold = 64;\n      p->aFold = sqlite3_malloc(p->nFold * sizeof(char));\n      if( p->aFold==0 ){\n        rc = SQLITE_NOMEM;\n      }\n      for(i=0; rc==SQLITE_OK && i<nArg; i+=2){\n        const char *zArg = azArg[i+1];\n        if( 0==sqlite3_stricmp(azArg[i], \"remove_diacritics\") ){\n          if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){\n            rc = SQLITE_ERROR;\n          }\n          p->bRemoveDiacritic = (zArg[0]=='1');\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"tokenchars\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 1);\n        }else\n        if( 0==sqlite3_stricmp(azArg[i], \"separators\") ){\n          rc = fts5UnicodeAddExceptions(p, zArg, 0);\n        }else{\n          rc = SQLITE_ERROR;\n        }\n      }\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      fts5UnicodeDelete((Fts5Tokenizer*)p);\n      p = 0;\n    }\n    *ppOut = (Fts5Tokenizer*)p;\n  }\n  return rc;\n}\n\n/*\n** Return true if, for the purposes of tokenizing with the tokenizer\n** passed as the first argument, codepoint iCode is considered a token \n** character (not a separator).\n*/\nstatic int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){\n  assert( (sqlite3Fts5UnicodeIsalnum(iCode) & 0xFFFFFFFE)==0 );\n  return sqlite3Fts5UnicodeIsalnum(iCode) ^ fts5UnicodeIsException(p, iCode);\n}\n\nstatic int fts5UnicodeTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int iUnused,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  Unicode61Tokenizer *p = (Unicode61Tokenizer*)pTokenizer;\n  int rc = SQLITE_OK;\n  unsigned char *a = p->aTokenChar;\n\n  unsigned char *zTerm = (unsigned char*)&pText[nText];\n  unsigned char *zCsr = (unsigned char *)pText;\n\n  /* Output buffer */\n  char *aFold = p->aFold;\n  int nFold = p->nFold;\n  const char *pEnd = &aFold[nFold-6];\n\n  UNUSED_PARAM(iUnused);\n\n  /* Each iteration of this loop gobbles up a contiguous run of separators,\n  ** then the next token.  */\n  while( rc==SQLITE_OK ){\n    int iCode;                    /* non-ASCII codepoint read from input */\n    char *zOut = aFold;\n    int is;\n    int ie;\n\n    /* Skip any separator characters. */\n    while( 1 ){\n      if( zCsr>=zTerm ) goto tokenize_done;\n      if( *zCsr & 0x80 ) {\n        /* A character outside of the ascii range. Skip past it if it is\n        ** a separator character. Or break out of the loop if it is not. */\n        is = zCsr - (unsigned char*)pText;\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p, iCode) ){\n          goto non_ascii_tokenchar;\n        }\n      }else{\n        if( a[*zCsr] ){\n          is = zCsr - (unsigned char*)pText;\n          goto ascii_tokenchar;\n        }\n        zCsr++;\n      }\n    }\n\n    /* Run through the tokenchars. Fold them into the output buffer along\n    ** the way.  */\n    while( zCsr<zTerm ){\n\n      /* Grow the output buffer so that there is sufficient space to fit the\n      ** largest possible utf-8 character.  */\n      if( zOut>pEnd ){\n        aFold = sqlite3_malloc(nFold*2);\n        if( aFold==0 ){\n          rc = SQLITE_NOMEM;\n          goto tokenize_done;\n        }\n        zOut = &aFold[zOut - p->aFold];\n        memcpy(aFold, p->aFold, nFold);\n        sqlite3_free(p->aFold);\n        p->aFold = aFold;\n        p->nFold = nFold = nFold*2;\n        pEnd = &aFold[nFold-6];\n      }\n\n      if( *zCsr & 0x80 ){\n        /* An non-ascii-range character. Fold it into the output buffer if\n        ** it is a token character, or break out of the loop if it is not. */\n        READ_UTF8(zCsr, zTerm, iCode);\n        if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){\n non_ascii_tokenchar:\n          iCode = sqlite3Fts5UnicodeFold(iCode, p->bRemoveDiacritic);\n          if( iCode ) WRITE_UTF8(zOut, iCode);\n        }else{\n          break;\n        }\n      }else if( a[*zCsr]==0 ){\n        /* An ascii-range separator character. End of token. */\n        break; \n      }else{\n ascii_tokenchar:\n        if( *zCsr>='A' && *zCsr<='Z' ){\n          *zOut++ = *zCsr + 32;\n        }else{\n          *zOut++ = *zCsr;\n        }\n        zCsr++;\n      }\n      ie = zCsr - (unsigned char*)pText;\n    }\n\n    /* Invoke the token callback */\n    rc = xToken(pCtx, 0, aFold, zOut-aFold, is, ie); \n  }\n  \n tokenize_done:\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  return rc;\n}\n\n/**************************************************************************\n** Start of porter stemmer implementation.\n*/\n\n/* Any tokens larger than this (in bytes) are passed through without\n** stemming. */\n#define FTS5_PORTER_MAX_TOKEN 64\n\ntypedef struct PorterTokenizer PorterTokenizer;\nstruct PorterTokenizer {\n  fts5_tokenizer tokenizer;       /* Parent tokenizer module */\n  Fts5Tokenizer *pTokenizer;      /* Parent tokenizer instance */\n  char aBuf[FTS5_PORTER_MAX_TOKEN + 64];\n};\n\n/*\n** Delete a \"porter\" tokenizer.\n*/\nstatic void fts5PorterDelete(Fts5Tokenizer *pTok){\n  if( pTok ){\n    PorterTokenizer *p = (PorterTokenizer*)pTok;\n    if( p->pTokenizer ){\n      p->tokenizer.xDelete(p->pTokenizer);\n    }\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Create a \"porter\" tokenizer.\n*/\nstatic int fts5PorterCreate(\n  void *pCtx, \n  const char **azArg, int nArg,\n  Fts5Tokenizer **ppOut\n){\n  fts5_api *pApi = (fts5_api*)pCtx;\n  int rc = SQLITE_OK;\n  PorterTokenizer *pRet;\n  void *pUserdata = 0;\n  const char *zBase = \"unicode61\";\n\n  if( nArg>0 ){\n    zBase = azArg[0];\n  }\n\n  pRet = (PorterTokenizer*)sqlite3_malloc(sizeof(PorterTokenizer));\n  if( pRet ){\n    memset(pRet, 0, sizeof(PorterTokenizer));\n    rc = pApi->xFindTokenizer(pApi, zBase, &pUserdata, &pRet->tokenizer);\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n  if( rc==SQLITE_OK ){\n    int nArg2 = (nArg>0 ? nArg-1 : 0);\n    const char **azArg2 = (nArg2 ? &azArg[1] : 0);\n    rc = pRet->tokenizer.xCreate(pUserdata, azArg2, nArg2, &pRet->pTokenizer);\n  }\n\n  if( rc!=SQLITE_OK ){\n    fts5PorterDelete((Fts5Tokenizer*)pRet);\n    pRet = 0;\n  }\n  *ppOut = (Fts5Tokenizer*)pRet;\n  return rc;\n}\n\ntypedef struct PorterContext PorterContext;\nstruct PorterContext {\n  void *pCtx;\n  int (*xToken)(void*, int, const char*, int, int, int);\n  char *aBuf;\n};\n\ntypedef struct PorterRule PorterRule;\nstruct PorterRule {\n  const char *zSuffix;\n  int nSuffix;\n  int (*xCond)(char *zStem, int nStem);\n  const char *zOutput;\n  int nOutput;\n};\n\n#if 0\nstatic int fts5PorterApply(char *aBuf, int *pnBuf, PorterRule *aRule){\n  int ret = -1;\n  int nBuf = *pnBuf;\n  PorterRule *p;\n\n  for(p=aRule; p->zSuffix; p++){\n    assert( strlen(p->zSuffix)==p->nSuffix );\n    assert( strlen(p->zOutput)==p->nOutput );\n    if( nBuf<p->nSuffix ) continue;\n    if( 0==memcmp(&aBuf[nBuf - p->nSuffix], p->zSuffix, p->nSuffix) ) break;\n  }\n\n  if( p->zSuffix ){\n    int nStem = nBuf - p->nSuffix;\n    if( p->xCond==0 || p->xCond(aBuf, nStem) ){\n      memcpy(&aBuf[nStem], p->zOutput, p->nOutput);\n      *pnBuf = nStem + p->nOutput;\n      ret = p - aRule;\n    }\n  }\n\n  return ret;\n}\n#endif\n\nstatic int fts5PorterIsVowel(char c, int bYIsVowel){\n  return (\n      c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || (bYIsVowel && c=='y')\n  );\n}\n\nstatic int fts5PorterGobbleVC(char *zStem, int nStem, int bPrevCons){\n  int i;\n  int bCons = bPrevCons;\n\n  /* Scan for a vowel */\n  for(i=0; i<nStem; i++){\n    if( 0==(bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) break;\n  }\n\n  /* Scan for a consonent */\n  for(i++; i<nStem; i++){\n    if( (bCons = !fts5PorterIsVowel(zStem[i], bCons)) ) return i+1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m > 0) */\nstatic int fts5Porter_MGt0(char *zStem, int nStem){\n  return !!fts5PorterGobbleVC(zStem, nStem, 0);\n}\n\n/* porter rule condition: (m > 1) */\nstatic int fts5Porter_MGt1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (m = 1) */\nstatic int fts5Porter_MEq1(char *zStem, int nStem){\n  int n;\n  n = fts5PorterGobbleVC(zStem, nStem, 0);\n  if( n && 0==fts5PorterGobbleVC(&zStem[n], nStem-n, 1) ){\n    return 1;\n  }\n  return 0;\n}\n\n/* porter rule condition: (*o) */\nstatic int fts5Porter_Ostar(char *zStem, int nStem){\n  if( zStem[nStem-1]=='w' || zStem[nStem-1]=='x' || zStem[nStem-1]=='y' ){\n    return 0;\n  }else{\n    int i;\n    int mask = 0;\n    int bCons = 0;\n    for(i=0; i<nStem; i++){\n      bCons = !fts5PorterIsVowel(zStem[i], bCons);\n      assert( bCons==0 || bCons==1 );\n      mask = (mask << 1) + bCons;\n    }\n    return ((mask & 0x0007)==0x0005);\n  }\n}\n\n/* porter rule condition: (m > 1 and (*S or *T)) */\nstatic int fts5Porter_MGt1_and_S_or_T(char *zStem, int nStem){\n  assert( nStem>0 );\n  return (zStem[nStem-1]=='s' || zStem[nStem-1]=='t') \n      && fts5Porter_MGt1(zStem, nStem);\n}\n\n/* porter rule condition: (*v*) */\nstatic int fts5Porter_Vowel(char *zStem, int nStem){\n  int i;\n  for(i=0; i<nStem; i++){\n    if( fts5PorterIsVowel(zStem[i], i>0) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n\n/**************************************************************************\n***************************************************************************\n** GENERATED CODE STARTS HERE (mkportersteps.tcl)\n*/\n\nstatic int fts5PorterStep4(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"al\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"ance\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ence\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>2 && 0==memcmp(\"er\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"ic\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>4 && 0==memcmp(\"able\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ible\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ant\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ement\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ment\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"ent\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>3 && 0==memcmp(\"ion\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1_and_S_or_T(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ou\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>3 && 0==memcmp(\"ism\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>3 && 0==memcmp(\"ate\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"iti\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ous\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>3 && 0==memcmp(\"ive\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>3 && 0==memcmp(\"ize\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt1(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>2 && 0==memcmp(\"at\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ate\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'b': \n      if( nBuf>2 && 0==memcmp(\"bl\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ble\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n    case 'i': \n      if( nBuf>2 && 0==memcmp(\"iz\", &aBuf[nBuf-2], 2) ){\n        memcpy(&aBuf[nBuf-2], \"ize\", 3);\n        *pnBuf = nBuf - 2 + 3;\n        ret = 1;\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep2(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>7 && 0==memcmp(\"ational\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ate\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"tional\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"tion\", 4);\n          *pnBuf = nBuf - 6 + 4;\n        }\n      }\n      break;\n  \n    case 'c': \n      if( nBuf>4 && 0==memcmp(\"enci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ence\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"anci\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ance\", 4);\n          *pnBuf = nBuf - 4 + 4;\n        }\n      }\n      break;\n  \n    case 'e': \n      if( nBuf>4 && 0==memcmp(\"izer\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ize\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'g': \n      if( nBuf>4 && 0==memcmp(\"logi\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"log\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 'l': \n      if( nBuf>3 && 0==memcmp(\"bli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ble\", 3);\n          *pnBuf = nBuf - 3 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"alli\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"al\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"entli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ent\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>3 && 0==memcmp(\"eli\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"e\", 1);\n          *pnBuf = nBuf - 3 + 1;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ousli\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ous\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }\n      break;\n  \n    case 'o': \n      if( nBuf>7 && 0==memcmp(\"ization\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ize\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"ation\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ate\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>4 && 0==memcmp(\"ator\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ate\", 3);\n          *pnBuf = nBuf - 4 + 3;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>5 && 0==memcmp(\"alism\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"iveness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ive\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"fulness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ful\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }else if( nBuf>7 && 0==memcmp(\"ousness\", &aBuf[nBuf-7], 7) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-7) ){\n          memcpy(&aBuf[nBuf-7], \"ous\", 3);\n          *pnBuf = nBuf - 7 + 3;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"aliti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iviti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ive\", 3);\n          *pnBuf = nBuf - 5 + 3;\n        }\n      }else if( nBuf>6 && 0==memcmp(\"biliti\", &aBuf[nBuf-6], 6) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-6) ){\n          memcpy(&aBuf[nBuf-6], \"ble\", 3);\n          *pnBuf = nBuf - 6 + 3;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep3(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'a': \n      if( nBuf>4 && 0==memcmp(\"ical\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          memcpy(&aBuf[nBuf-4], \"ic\", 2);\n          *pnBuf = nBuf - 4 + 2;\n        }\n      }\n      break;\n  \n    case 's': \n      if( nBuf>4 && 0==memcmp(\"ness\", &aBuf[nBuf-4], 4) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-4) ){\n          *pnBuf = nBuf - 4;\n        }\n      }\n      break;\n  \n    case 't': \n      if( nBuf>5 && 0==memcmp(\"icate\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }else if( nBuf>5 && 0==memcmp(\"iciti\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"ic\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n    case 'u': \n      if( nBuf>3 && 0==memcmp(\"ful\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n        }\n      }\n      break;\n  \n    case 'v': \n      if( nBuf>5 && 0==memcmp(\"ative\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          *pnBuf = nBuf - 5;\n        }\n      }\n      break;\n  \n    case 'z': \n      if( nBuf>5 && 0==memcmp(\"alize\", &aBuf[nBuf-5], 5) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-5) ){\n          memcpy(&aBuf[nBuf-5], \"al\", 2);\n          *pnBuf = nBuf - 5 + 2;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n\nstatic int fts5PorterStep1B(char *aBuf, int *pnBuf){\n  int ret = 0;\n  int nBuf = *pnBuf;\n  switch( aBuf[nBuf-2] ){\n    \n    case 'e': \n      if( nBuf>3 && 0==memcmp(\"eed\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_MGt0(aBuf, nBuf-3) ){\n          memcpy(&aBuf[nBuf-3], \"ee\", 2);\n          *pnBuf = nBuf - 3 + 2;\n        }\n      }else if( nBuf>2 && 0==memcmp(\"ed\", &aBuf[nBuf-2], 2) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-2) ){\n          *pnBuf = nBuf - 2;\n          ret = 1;\n        }\n      }\n      break;\n  \n    case 'n': \n      if( nBuf>3 && 0==memcmp(\"ing\", &aBuf[nBuf-3], 3) ){\n        if( fts5Porter_Vowel(aBuf, nBuf-3) ){\n          *pnBuf = nBuf - 3;\n          ret = 1;\n        }\n      }\n      break;\n  \n  }\n  return ret;\n}\n  \n/* \n** GENERATED CODE ENDS HERE (mkportersteps.tcl)\n***************************************************************************\n**************************************************************************/\n\nstatic void fts5PorterStep1A(char *aBuf, int *pnBuf){\n  int nBuf = *pnBuf;\n  if( aBuf[nBuf-1]=='s' ){\n    if( aBuf[nBuf-2]=='e' ){\n      if( (nBuf>4 && aBuf[nBuf-4]=='s' && aBuf[nBuf-3]=='s') \n       || (nBuf>3 && aBuf[nBuf-3]=='i' )\n      ){\n        *pnBuf = nBuf-2;\n      }else{\n        *pnBuf = nBuf-1;\n      }\n    }\n    else if( aBuf[nBuf-2]!='s' ){\n      *pnBuf = nBuf-1;\n    }\n  }\n}\n\nstatic int fts5PorterCb(\n  void *pCtx, \n  int tflags,\n  const char *pToken, \n  int nToken, \n  int iStart, \n  int iEnd\n){\n  PorterContext *p = (PorterContext*)pCtx;\n\n  char *aBuf;\n  int nBuf;\n\n  if( nToken>FTS5_PORTER_MAX_TOKEN || nToken<3 ) goto pass_through;\n  aBuf = p->aBuf;\n  nBuf = nToken;\n  memcpy(aBuf, pToken, nBuf);\n\n  /* Step 1. */\n  fts5PorterStep1A(aBuf, &nBuf);\n  if( fts5PorterStep1B(aBuf, &nBuf) ){\n    if( fts5PorterStep1B2(aBuf, &nBuf)==0 ){\n      char c = aBuf[nBuf-1];\n      if( fts5PorterIsVowel(c, 0)==0 \n       && c!='l' && c!='s' && c!='z' && c==aBuf[nBuf-2] \n      ){\n        nBuf--;\n      }else if( fts5Porter_MEq1(aBuf, nBuf) && fts5Porter_Ostar(aBuf, nBuf) ){\n        aBuf[nBuf++] = 'e';\n      }\n    }\n  }\n\n  /* Step 1C. */\n  if( aBuf[nBuf-1]=='y' && fts5Porter_Vowel(aBuf, nBuf-1) ){\n    aBuf[nBuf-1] = 'i';\n  }\n\n  /* Steps 2 through 4. */\n  fts5PorterStep2(aBuf, &nBuf);\n  fts5PorterStep3(aBuf, &nBuf);\n  fts5PorterStep4(aBuf, &nBuf);\n\n  /* Step 5a. */\n  assert( nBuf>0 );\n  if( aBuf[nBuf-1]=='e' ){\n    if( fts5Porter_MGt1(aBuf, nBuf-1) \n     || (fts5Porter_MEq1(aBuf, nBuf-1) && !fts5Porter_Ostar(aBuf, nBuf-1))\n    ){\n      nBuf--;\n    }\n  }\n\n  /* Step 5b. */\n  if( nBuf>1 && aBuf[nBuf-1]=='l' \n   && aBuf[nBuf-2]=='l' && fts5Porter_MGt1(aBuf, nBuf-1) \n  ){\n    nBuf--;\n  }\n\n  return p->xToken(p->pCtx, tflags, aBuf, nBuf, iStart, iEnd);\n\n pass_through:\n  return p->xToken(p->pCtx, tflags, pToken, nToken, iStart, iEnd);\n}\n\n/*\n** Tokenize using the porter tokenizer.\n*/\nstatic int fts5PorterTokenize(\n  Fts5Tokenizer *pTokenizer,\n  void *pCtx,\n  int flags,\n  const char *pText, int nText,\n  int (*xToken)(void*, int, const char*, int nToken, int iStart, int iEnd)\n){\n  PorterTokenizer *p = (PorterTokenizer*)pTokenizer;\n  PorterContext sCtx;\n  sCtx.xToken = xToken;\n  sCtx.pCtx = pCtx;\n  sCtx.aBuf = p->aBuf;\n  return p->tokenizer.xTokenize(\n      p->pTokenizer, (void*)&sCtx, flags, pText, nText, fts5PorterCb\n  );\n}\n\n/*\n** Register all built-in tokenizers with FTS5.\n*/\nstatic int sqlite3Fts5TokenizerInit(fts5_api *pApi){\n  struct BuiltinTokenizer {\n    const char *zName;\n    fts5_tokenizer x;\n  } aBuiltin[] = {\n    { \"unicode61\", {fts5UnicodeCreate, fts5UnicodeDelete, fts5UnicodeTokenize}},\n    { \"ascii\",     {fts5AsciiCreate, fts5AsciiDelete, fts5AsciiTokenize }},\n    { \"porter\",    {fts5PorterCreate, fts5PorterDelete, fts5PorterTokenize }},\n  };\n  \n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* To iterate through builtin functions */\n\n  for(i=0; rc==SQLITE_OK && i<ArraySize(aBuiltin); i++){\n    rc = pApi->xCreateTokenizer(pApi,\n        aBuiltin[i].zName,\n        (void*)pApi,\n        &aBuiltin[i].x,\n        0\n    );\n  }\n\n  return rc;\n}\n\n\n\n/*\n** 2012 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n*/\n\n/*\n** DO NOT EDIT THIS MACHINE GENERATED FILE.\n*/\n\n\n/* #include <assert.h> */\n\n/*\n** Return true if the argument corresponds to a unicode codepoint\n** classified as either a letter or a number. Otherwise false.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nstatic int sqlite3Fts5UnicodeIsalnum(int c){\n  /* Each unsigned integer in the following array corresponds to a contiguous\n  ** range of unicode codepoints that are not either letters or numbers (i.e.\n  ** codepoints for which this function should return 0).\n  **\n  ** The most significant 22 bits in each 32-bit value contain the first \n  ** codepoint in the range. The least significant 10 bits are used to store\n  ** the size of the range (always at least 1). In other words, the value \n  ** ((C<<22) + N) represents a range of N codepoints starting with codepoint \n  ** C. It is not possible to represent a range larger than 1023 codepoints \n  ** using this format.\n  */\n  static const unsigned int aEntry[] = {\n    0x00000030, 0x0000E807, 0x00016C06, 0x0001EC2F, 0x0002AC07,\n    0x0002D001, 0x0002D803, 0x0002EC01, 0x0002FC01, 0x00035C01,\n    0x0003DC01, 0x000B0804, 0x000B480E, 0x000B9407, 0x000BB401,\n    0x000BBC81, 0x000DD401, 0x000DF801, 0x000E1002, 0x000E1C01,\n    0x000FD801, 0x00120808, 0x00156806, 0x00162402, 0x00163C01,\n    0x00164437, 0x0017CC02, 0x00180005, 0x00181816, 0x00187802,\n    0x00192C15, 0x0019A804, 0x0019C001, 0x001B5001, 0x001B580F,\n    0x001B9C07, 0x001BF402, 0x001C000E, 0x001C3C01, 0x001C4401,\n    0x001CC01B, 0x001E980B, 0x001FAC09, 0x001FD804, 0x00205804,\n    0x00206C09, 0x00209403, 0x0020A405, 0x0020C00F, 0x00216403,\n    0x00217801, 0x0023901B, 0x00240004, 0x0024E803, 0x0024F812,\n    0x00254407, 0x00258804, 0x0025C001, 0x00260403, 0x0026F001,\n    0x0026F807, 0x00271C02, 0x00272C03, 0x00275C01, 0x00278802,\n    0x0027C802, 0x0027E802, 0x00280403, 0x0028F001, 0x0028F805,\n    0x00291C02, 0x00292C03, 0x00294401, 0x0029C002, 0x0029D401,\n    0x002A0403, 0x002AF001, 0x002AF808, 0x002B1C03, 0x002B2C03,\n    0x002B8802, 0x002BC002, 0x002C0403, 0x002CF001, 0x002CF807,\n    0x002D1C02, 0x002D2C03, 0x002D5802, 0x002D8802, 0x002DC001,\n    0x002E0801, 0x002EF805, 0x002F1803, 0x002F2804, 0x002F5C01,\n    0x002FCC08, 0x00300403, 0x0030F807, 0x00311803, 0x00312804,\n    0x00315402, 0x00318802, 0x0031FC01, 0x00320802, 0x0032F001,\n    0x0032F807, 0x00331803, 0x00332804, 0x00335402, 0x00338802,\n    0x00340802, 0x0034F807, 0x00351803, 0x00352804, 0x00355C01,\n    0x00358802, 0x0035E401, 0x00360802, 0x00372801, 0x00373C06,\n    0x00375801, 0x00376008, 0x0037C803, 0x0038C401, 0x0038D007,\n    0x0038FC01, 0x00391C09, 0x00396802, 0x003AC401, 0x003AD006,\n    0x003AEC02, 0x003B2006, 0x003C041F, 0x003CD00C, 0x003DC417,\n    0x003E340B, 0x003E6424, 0x003EF80F, 0x003F380D, 0x0040AC14,\n    0x00412806, 0x00415804, 0x00417803, 0x00418803, 0x00419C07,\n    0x0041C404, 0x0042080C, 0x00423C01, 0x00426806, 0x0043EC01,\n    0x004D740C, 0x004E400A, 0x00500001, 0x0059B402, 0x005A0001,\n    0x005A6C02, 0x005BAC03, 0x005C4803, 0x005CC805, 0x005D4802,\n    0x005DC802, 0x005ED023, 0x005F6004, 0x005F7401, 0x0060000F,\n    0x0062A401, 0x0064800C, 0x0064C00C, 0x00650001, 0x00651002,\n    0x0066C011, 0x00672002, 0x00677822, 0x00685C05, 0x00687802,\n    0x0069540A, 0x0069801D, 0x0069FC01, 0x006A8007, 0x006AA006,\n    0x006C0005, 0x006CD011, 0x006D6823, 0x006E0003, 0x006E840D,\n    0x006F980E, 0x006FF004, 0x00709014, 0x0070EC05, 0x0071F802,\n    0x00730008, 0x00734019, 0x0073B401, 0x0073C803, 0x00770027,\n    0x0077F004, 0x007EF401, 0x007EFC03, 0x007F3403, 0x007F7403,\n    0x007FB403, 0x007FF402, 0x00800065, 0x0081A806, 0x0081E805,\n    0x00822805, 0x0082801A, 0x00834021, 0x00840002, 0x00840C04,\n    0x00842002, 0x00845001, 0x00845803, 0x00847806, 0x00849401,\n    0x00849C01, 0x0084A401, 0x0084B801, 0x0084E802, 0x00850005,\n    0x00852804, 0x00853C01, 0x00864264, 0x00900027, 0x0091000B,\n    0x0092704E, 0x00940200, 0x009C0475, 0x009E53B9, 0x00AD400A,\n    0x00B39406, 0x00B3BC03, 0x00B3E404, 0x00B3F802, 0x00B5C001,\n    0x00B5FC01, 0x00B7804F, 0x00B8C00C, 0x00BA001A, 0x00BA6C59,\n    0x00BC00D6, 0x00BFC00C, 0x00C00005, 0x00C02019, 0x00C0A807,\n    0x00C0D802, 0x00C0F403, 0x00C26404, 0x00C28001, 0x00C3EC01,\n    0x00C64002, 0x00C6580A, 0x00C70024, 0x00C8001F, 0x00C8A81E,\n    0x00C94001, 0x00C98020, 0x00CA2827, 0x00CB003F, 0x00CC0100,\n    0x01370040, 0x02924037, 0x0293F802, 0x02983403, 0x0299BC10,\n    0x029A7C01, 0x029BC008, 0x029C0017, 0x029C8002, 0x029E2402,\n    0x02A00801, 0x02A01801, 0x02A02C01, 0x02A08C09, 0x02A0D804,\n    0x02A1D004, 0x02A20002, 0x02A2D011, 0x02A33802, 0x02A38012,\n    0x02A3E003, 0x02A4980A, 0x02A51C0D, 0x02A57C01, 0x02A60004,\n    0x02A6CC1B, 0x02A77802, 0x02A8A40E, 0x02A90C01, 0x02A93002,\n    0x02A97004, 0x02A9DC03, 0x02A9EC01, 0x02AAC001, 0x02AAC803,\n    0x02AADC02, 0x02AAF802, 0x02AB0401, 0x02AB7802, 0x02ABAC07,\n    0x02ABD402, 0x02AF8C0B, 0x03600001, 0x036DFC02, 0x036FFC02,\n    0x037FFC01, 0x03EC7801, 0x03ECA401, 0x03EEC810, 0x03F4F802,\n    0x03F7F002, 0x03F8001A, 0x03F88007, 0x03F8C023, 0x03F95013,\n    0x03F9A004, 0x03FBFC01, 0x03FC040F, 0x03FC6807, 0x03FCEC06,\n    0x03FD6C0B, 0x03FF8007, 0x03FFA007, 0x03FFE405, 0x04040003,\n    0x0404DC09, 0x0405E411, 0x0406400C, 0x0407402E, 0x040E7C01,\n    0x040F4001, 0x04215C01, 0x04247C01, 0x0424FC01, 0x04280403,\n    0x04281402, 0x04283004, 0x0428E003, 0x0428FC01, 0x04294009,\n    0x0429FC01, 0x042CE407, 0x04400003, 0x0440E016, 0x04420003,\n    0x0442C012, 0x04440003, 0x04449C0E, 0x04450004, 0x04460003,\n    0x0446CC0E, 0x04471404, 0x045AAC0D, 0x0491C004, 0x05BD442E,\n    0x05BE3C04, 0x074000F6, 0x07440027, 0x0744A4B5, 0x07480046,\n    0x074C0057, 0x075B0401, 0x075B6C01, 0x075BEC01, 0x075C5401,\n    0x075CD401, 0x075D3C01, 0x075DBC01, 0x075E2401, 0x075EA401,\n    0x075F0C01, 0x07BBC002, 0x07C0002C, 0x07C0C064, 0x07C2800F,\n    0x07C2C40E, 0x07C3040F, 0x07C3440F, 0x07C4401F, 0x07C4C03C,\n    0x07C5C02B, 0x07C7981D, 0x07C8402B, 0x07C90009, 0x07C94002,\n    0x07CC0021, 0x07CCC006, 0x07CCDC46, 0x07CE0014, 0x07CE8025,\n    0x07CF1805, 0x07CF8011, 0x07D0003F, 0x07D10001, 0x07D108B6,\n    0x07D3E404, 0x07D4003E, 0x07D50004, 0x07D54018, 0x07D7EC46,\n    0x07D9140B, 0x07DA0046, 0x07DC0074, 0x38000401, 0x38008060,\n    0x380400F0,\n  };\n  static const unsigned int aAscii[4] = {\n    0xFFFFFFFF, 0xFC00FFFF, 0xF8000001, 0xF8000001,\n  };\n\n  if( (unsigned int)c<128 ){\n    return ( (aAscii[c >> 5] & (1 << (c & 0x001F)))==0 );\n  }else if( (unsigned int)c<(1<<22) ){\n    unsigned int key = (((unsigned int)c)<<10) | 0x000003FF;\n    int iRes = 0;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      if( key >= aEntry[iTest] ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n    assert( aEntry[0]<key );\n    assert( key>=aEntry[iRes] );\n    return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF)));\n  }\n  return 1;\n}\n\n\n/*\n** If the argument is a codepoint corresponding to a lowercase letter\n** in the ASCII range with a diacritic added, return the codepoint\n** of the ASCII letter only. For example, if passed 235 - \"LATIN\n** SMALL LETTER E WITH DIAERESIS\" - return 65 (\"LATIN SMALL LETTER\n** E\"). The resuls of passing a codepoint that corresponds to an\n** uppercase letter are undefined.\n*/\nstatic int fts5_remove_diacritic(int c){\n  unsigned short aDia[] = {\n        0,  1797,  1848,  1859,  1891,  1928,  1940,  1995, \n     2024,  2040,  2060,  2110,  2168,  2206,  2264,  2286, \n     2344,  2383,  2472,  2488,  2516,  2596,  2668,  2732, \n     2782,  2842,  2894,  2954,  2984,  3000,  3028,  3336, \n     3456,  3696,  3712,  3728,  3744,  3896,  3912,  3928, \n     3968,  4008,  4040,  4106,  4138,  4170,  4202,  4234, \n     4266,  4296,  4312,  4344,  4408,  4424,  4472,  4504, \n     6148,  6198,  6264,  6280,  6360,  6429,  6505,  6529, \n    61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726, \n    61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122, \n    62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536, \n    62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730, \n    62924, 63050, 63082, 63274, 63390, \n  };\n  char aChar[] = {\n    '\\0', 'a',  'c',  'e',  'i',  'n',  'o',  'u',  'y',  'y',  'a',  'c',  \n    'd',  'e',  'e',  'g',  'h',  'i',  'j',  'k',  'l',  'n',  'o',  'r',  \n    's',  't',  'u',  'u',  'w',  'y',  'z',  'o',  'u',  'a',  'i',  'o',  \n    'u',  'g',  'k',  'o',  'j',  'g',  'n',  'a',  'e',  'i',  'o',  'r',  \n    'u',  's',  't',  'h',  'a',  'e',  'o',  'y',  '\\0', '\\0', '\\0', '\\0', \n    '\\0', '\\0', '\\0', '\\0', 'a',  'b',  'd',  'd',  'e',  'f',  'g',  'h',  \n    'h',  'i',  'k',  'l',  'l',  'm',  'n',  'p',  'r',  'r',  's',  't',  \n    'u',  'v',  'w',  'w',  'x',  'y',  'z',  'h',  't',  'w',  'y',  'a',  \n    'e',  'i',  'o',  'u',  'y',  \n  };\n\n  unsigned int key = (((unsigned int)c)<<3) | 0x00000007;\n  int iRes = 0;\n  int iHi = sizeof(aDia)/sizeof(aDia[0]) - 1;\n  int iLo = 0;\n  while( iHi>=iLo ){\n    int iTest = (iHi + iLo) / 2;\n    if( key >= aDia[iTest] ){\n      iRes = iTest;\n      iLo = iTest+1;\n    }else{\n      iHi = iTest-1;\n    }\n  }\n  assert( key>=aDia[iRes] );\n  return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);\n}\n\n\n/*\n** Return true if the argument interpreted as a unicode codepoint\n** is a diacritical modifier character.\n*/\nstatic int sqlite3Fts5UnicodeIsdiacritic(int c){\n  unsigned int mask0 = 0x08029FDF;\n  unsigned int mask1 = 0x000361F8;\n  if( c<768 || c>817 ) return 0;\n  return (c < 768+32) ?\n      (mask0 & (1 << (c-768))) :\n      (mask1 & (1 << (c-768-32)));\n}\n\n\n/*\n** Interpret the argument as a unicode codepoint. If the codepoint\n** is an upper case character that has a lower case equivalent,\n** return the codepoint corresponding to the lower case version.\n** Otherwise, return a copy of the argument.\n**\n** The results are undefined if the value passed to this function\n** is less than zero.\n*/\nstatic int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){\n  /* Each entry in the following array defines a rule for folding a range\n  ** of codepoints to lower case. The rule applies to a range of nRange\n  ** codepoints starting at codepoint iCode.\n  **\n  ** If the least significant bit in flags is clear, then the rule applies\n  ** to all nRange codepoints (i.e. all nRange codepoints are upper case and\n  ** need to be folded). Or, if it is set, then the rule only applies to\n  ** every second codepoint in the range, starting with codepoint C.\n  **\n  ** The 7 most significant bits in flags are an index into the aiOff[]\n  ** array. If a specific codepoint C does require folding, then its lower\n  ** case equivalent is ((C + aiOff[flags>>1]) & 0xFFFF).\n  **\n  ** The contents of this array are generated by parsing the CaseFolding.txt\n  ** file distributed as part of the \"Unicode Character Database\". See\n  ** http://www.unicode.org for details.\n  */\n  static const struct TableEntry {\n    unsigned short iCode;\n    unsigned char flags;\n    unsigned char nRange;\n  } aEntry[] = {\n    {65, 14, 26},          {181, 64, 1},          {192, 14, 23},\n    {216, 14, 7},          {256, 1, 48},          {306, 1, 6},\n    {313, 1, 16},          {330, 1, 46},          {376, 116, 1},\n    {377, 1, 6},           {383, 104, 1},         {385, 50, 1},\n    {386, 1, 4},           {390, 44, 1},          {391, 0, 1},\n    {393, 42, 2},          {395, 0, 1},           {398, 32, 1},\n    {399, 38, 1},          {400, 40, 1},          {401, 0, 1},\n    {403, 42, 1},          {404, 46, 1},          {406, 52, 1},\n    {407, 48, 1},          {408, 0, 1},           {412, 52, 1},\n    {413, 54, 1},          {415, 56, 1},          {416, 1, 6},\n    {422, 60, 1},          {423, 0, 1},           {425, 60, 1},\n    {428, 0, 1},           {430, 60, 1},          {431, 0, 1},\n    {433, 58, 2},          {435, 1, 4},           {439, 62, 1},\n    {440, 0, 1},           {444, 0, 1},           {452, 2, 1},\n    {453, 0, 1},           {455, 2, 1},           {456, 0, 1},\n    {458, 2, 1},           {459, 1, 18},          {478, 1, 18},\n    {497, 2, 1},           {498, 1, 4},           {502, 122, 1},\n    {503, 134, 1},         {504, 1, 40},          {544, 110, 1},\n    {546, 1, 18},          {570, 70, 1},          {571, 0, 1},\n    {573, 108, 1},         {574, 68, 1},          {577, 0, 1},\n    {579, 106, 1},         {580, 28, 1},          {581, 30, 1},\n    {582, 1, 10},          {837, 36, 1},          {880, 1, 4},\n    {886, 0, 1},           {902, 18, 1},          {904, 16, 3},\n    {908, 26, 1},          {910, 24, 2},          {913, 14, 17},\n    {931, 14, 9},          {962, 0, 1},           {975, 4, 1},\n    {976, 140, 1},         {977, 142, 1},         {981, 146, 1},\n    {982, 144, 1},         {984, 1, 24},          {1008, 136, 1},\n    {1009, 138, 1},        {1012, 130, 1},        {1013, 128, 1},\n    {1015, 0, 1},          {1017, 152, 1},        {1018, 0, 1},\n    {1021, 110, 3},        {1024, 34, 16},        {1040, 14, 32},\n    {1120, 1, 34},         {1162, 1, 54},         {1216, 6, 1},\n    {1217, 1, 14},         {1232, 1, 88},         {1329, 22, 38},\n    {4256, 66, 38},        {4295, 66, 1},         {4301, 66, 1},\n    {7680, 1, 150},        {7835, 132, 1},        {7838, 96, 1},\n    {7840, 1, 96},         {7944, 150, 8},        {7960, 150, 6},\n    {7976, 150, 8},        {7992, 150, 8},        {8008, 150, 6},\n    {8025, 151, 8},        {8040, 150, 8},        {8072, 150, 8},\n    {8088, 150, 8},        {8104, 150, 8},        {8120, 150, 2},\n    {8122, 126, 2},        {8124, 148, 1},        {8126, 100, 1},\n    {8136, 124, 4},        {8140, 148, 1},        {8152, 150, 2},\n    {8154, 120, 2},        {8168, 150, 2},        {8170, 118, 2},\n    {8172, 152, 1},        {8184, 112, 2},        {8186, 114, 2},\n    {8188, 148, 1},        {8486, 98, 1},         {8490, 92, 1},\n    {8491, 94, 1},         {8498, 12, 1},         {8544, 8, 16},\n    {8579, 0, 1},          {9398, 10, 26},        {11264, 22, 47},\n    {11360, 0, 1},         {11362, 88, 1},        {11363, 102, 1},\n    {11364, 90, 1},        {11367, 1, 6},         {11373, 84, 1},\n    {11374, 86, 1},        {11375, 80, 1},        {11376, 82, 1},\n    {11378, 0, 1},         {11381, 0, 1},         {11390, 78, 2},\n    {11392, 1, 100},       {11499, 1, 4},         {11506, 0, 1},\n    {42560, 1, 46},        {42624, 1, 24},        {42786, 1, 14},\n    {42802, 1, 62},        {42873, 1, 4},         {42877, 76, 1},\n    {42878, 1, 10},        {42891, 0, 1},         {42893, 74, 1},\n    {42896, 1, 4},         {42912, 1, 10},        {42922, 72, 1},\n    {65313, 14, 26},       \n  };\n  static const unsigned short aiOff[] = {\n   1,     2,     8,     15,    16,    26,    28,    32,    \n   37,    38,    40,    48,    63,    64,    69,    71,    \n   79,    80,    116,   202,   203,   205,   206,   207,   \n   209,   210,   211,   213,   214,   217,   218,   219,   \n   775,   7264,  10792, 10795, 23228, 23256, 30204, 54721, \n   54753, 54754, 54756, 54787, 54793, 54809, 57153, 57274, \n   57921, 58019, 58363, 61722, 65268, 65341, 65373, 65406, \n   65408, 65410, 65415, 65424, 65436, 65439, 65450, 65462, \n   65472, 65476, 65478, 65480, 65482, 65488, 65506, 65511, \n   65514, 65521, 65527, 65528, 65529, \n  };\n\n  int ret = c;\n\n  assert( sizeof(unsigned short)==2 && sizeof(unsigned char)==1 );\n\n  if( c<128 ){\n    if( c>='A' && c<='Z' ) ret = c + ('a' - 'A');\n  }else if( c<65536 ){\n    const struct TableEntry *p;\n    int iHi = sizeof(aEntry)/sizeof(aEntry[0]) - 1;\n    int iLo = 0;\n    int iRes = -1;\n\n    assert( c>aEntry[0].iCode );\n    while( iHi>=iLo ){\n      int iTest = (iHi + iLo) / 2;\n      int cmp = (c - aEntry[iTest].iCode);\n      if( cmp>=0 ){\n        iRes = iTest;\n        iLo = iTest+1;\n      }else{\n        iHi = iTest-1;\n      }\n    }\n\n    assert( iRes>=0 && c>=aEntry[iRes].iCode );\n    p = &aEntry[iRes];\n    if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){\n      ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF;\n      assert( ret>0 );\n    }\n\n    if( bRemoveDiacritic ) ret = fts5_remove_diacritic(ret);\n  }\n  \n  else if( c>=66560 && c<66600 ){\n    ret = c + 40;\n  }\n\n  return ret;\n}\n\n/*\n** 2015 May 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Routines for varint serialization and deserialization.\n*/\n\n\n/* #include \"fts5Int.h\" */\n\n/*\n** This is a copy of the sqlite3GetVarint32() routine from the SQLite core.\n** Except, this version does handle the single byte case that the core\n** version depends on being handled before its function is called.\n*/\nstatic int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case. Overwhelmingly the most common. */\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n  {\n    u64 v64;\n    u8 n;\n    p -= 2;\n    n = sqlite3Fts5GetVarint(p, &v64);\n    *v = (u32)v64;\n    assert( n>3 && n<=9 );\n    return n;\n  }\n}\n\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nstatic u8 sqlite3Fts5GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above in calc'ing s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n#ifdef SQLITE_NOINLINE\n# define FTS5_NOINLINE SQLITE_NOINLINE\n#else\n# define FTS5_NOINLINE\n#endif\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int FTS5_NOINLINE fts5PutVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\n\nstatic int sqlite3Fts5PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return fts5PutVarint64(p,v);\n}\n\n\nstatic int sqlite3Fts5GetVarintLen(u32 iVal){\n#if 0\n  if( iVal<(1 << 7 ) ) return 1;\n#endif\n  assert( iVal>=(1 << 7) );\n  if( iVal<(1 << 14) ) return 2;\n  if( iVal<(1 << 21) ) return 3;\n  if( iVal<(1 << 28) ) return 4;\n  return 5;\n}\n\n\n/*\n** 2015 May 08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This is an SQLite virtual table module implementing direct access to an\n** existing FTS5 index. The module may create several different types of \n** tables:\n**\n** col:\n**     CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));\n**\n**   One row for each term/column combination. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term within column $col. Field $cnt is set to the total number of \n**   instances of term $term in column $col (in any row of the fts5 table). \n**\n** row:\n**     CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));\n**\n**   One row for each term in the database. The value of $doc is set to\n**   the number of fts5 rows that contain at least one instance of term\n**   $term. Field $cnt is set to the total number of instances of term \n**   $term in the database.\n**\n** instance:\n**     CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));\n**\n**   One row for each term instance in the database. \n*/\n\n\n/* #include \"fts5Int.h\" */\n\n\ntypedef struct Fts5VocabTable Fts5VocabTable;\ntypedef struct Fts5VocabCursor Fts5VocabCursor;\n\nstruct Fts5VocabTable {\n  sqlite3_vtab base;\n  char *zFts5Tbl;                 /* Name of fts5 table */\n  char *zFts5Db;                  /* Db containing fts5 table */\n  sqlite3 *db;                    /* Database handle */\n  Fts5Global *pGlobal;            /* FTS5 global object for this database */\n  int eType;                      /* FTS5_VOCAB_COL, ROW or INSTANCE */\n};\n\nstruct Fts5VocabCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Statement holding lock on pIndex */\n  Fts5Index *pIndex;              /* Associated FTS5 index */\n\n  int bEof;                       /* True if this cursor is at EOF */\n  Fts5IndexIter *pIter;           /* Term/rowid iterator object */\n\n  int nLeTerm;                    /* Size of zLeTerm in bytes */\n  char *zLeTerm;                  /* (term <= $zLeTerm) paramater, or NULL */\n\n  /* These are used by 'col' tables only */\n  Fts5Config *pConfig;            /* Fts5 table configuration */\n  int iCol;\n  i64 *aCnt;\n  i64 *aDoc;\n\n  /* Output values used by all tables. */\n  i64 rowid;                      /* This table's current rowid value */\n  Fts5Buffer term;                /* Current value of 'term' column */\n\n  /* Output values Used by 'instance' tables only */\n  i64 iInstPos;\n  int iInstOff;\n};\n\n#define FTS5_VOCAB_COL      0\n#define FTS5_VOCAB_ROW      1\n#define FTS5_VOCAB_INSTANCE 2\n\n#define FTS5_VOCAB_COL_SCHEMA  \"term, col, doc, cnt\"\n#define FTS5_VOCAB_ROW_SCHEMA  \"term, doc, cnt\"\n#define FTS5_VOCAB_INST_SCHEMA \"term, doc, col, offset\"\n\n/*\n** Bits for the mask used as the idxNum value by xBestIndex/xFilter.\n*/\n#define FTS5_VOCAB_TERM_EQ 0x01\n#define FTS5_VOCAB_TERM_GE 0x02\n#define FTS5_VOCAB_TERM_LE 0x04\n\n\n/*\n** Translate a string containing an fts5vocab table type to an \n** FTS5_VOCAB_XXX constant. If successful, set *peType to the output\n** value and return SQLITE_OK. Otherwise, set *pzErr to an error message\n** and return SQLITE_ERROR.\n*/\nstatic int fts5VocabTableType(const char *zType, char **pzErr, int *peType){\n  int rc = SQLITE_OK;\n  char *zCopy = sqlite3Fts5Strndup(&rc, zType, -1);\n  if( rc==SQLITE_OK ){\n    sqlite3Fts5Dequote(zCopy);\n    if( sqlite3_stricmp(zCopy, \"col\")==0 ){\n      *peType = FTS5_VOCAB_COL;\n    }else\n\n    if( sqlite3_stricmp(zCopy, \"row\")==0 ){\n      *peType = FTS5_VOCAB_ROW;\n    }else\n    if( sqlite3_stricmp(zCopy, \"instance\")==0 ){\n      *peType = FTS5_VOCAB_INSTANCE;\n    }else\n    {\n      *pzErr = sqlite3_mprintf(\"fts5vocab: unknown table type: %Q\", zCopy);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3_free(zCopy);\n  }\n\n  return rc;\n}\n\n\n/*\n** The xDisconnect() virtual table method.\n*/\nstatic int fts5VocabDisconnectMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** The xDestroy() virtual table method.\n*/\nstatic int fts5VocabDestroyMethod(sqlite3_vtab *pVtab){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the FTS3 virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fts5vocab\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**\n** then:\n**\n**   argv[3]   -> name of fts5 table\n**   argv[4]   -> type of fts5vocab table\n**\n** or, for tables in the TEMP schema only.\n**\n**   argv[3]   -> name of fts5 tables database\n**   argv[4]   -> name of fts5 table\n**   argv[5]   -> type of fts5vocab table\n*/\nstatic int fts5VocabInitVtab(\n  sqlite3 *db,                    /* The SQLite database connection */\n  void *pAux,                     /* Pointer to Fts5Global object */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVTab,          /* Write the resulting vtab structure here */\n  char **pzErr                    /* Write any error message here */\n){\n  const char *azSchema[] = { \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_COL_SCHEMA  \")\", \n    \"CREATE TABlE vocab(\" FTS5_VOCAB_ROW_SCHEMA  \")\",\n    \"CREATE TABlE vocab(\" FTS5_VOCAB_INST_SCHEMA \")\"\n  };\n\n  Fts5VocabTable *pRet = 0;\n  int rc = SQLITE_OK;             /* Return code */\n  int bDb;\n\n  bDb = (argc==6 && strlen(argv[1])==4 && memcmp(\"temp\", argv[1], 4)==0);\n\n  if( argc!=5 && bDb==0 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of vtable arguments\");\n    rc = SQLITE_ERROR;\n  }else{\n    int nByte;                      /* Bytes of space to allocate */\n    const char *zDb = bDb ? argv[3] : argv[1];\n    const char *zTab = bDb ? argv[4] : argv[3];\n    const char *zType = bDb ? argv[5] : argv[4];\n    int nDb = (int)strlen(zDb)+1; \n    int nTab = (int)strlen(zTab)+1;\n    int eType = 0;\n    \n    rc = fts5VocabTableType(zType, pzErr, &eType);\n    if( rc==SQLITE_OK ){\n      assert( eType>=0 && eType<ArraySize(azSchema) );\n      rc = sqlite3_declare_vtab(db, azSchema[eType]);\n    }\n\n    nByte = sizeof(Fts5VocabTable) + nDb + nTab;\n    pRet = sqlite3Fts5MallocZero(&rc, nByte);\n    if( pRet ){\n      pRet->pGlobal = (Fts5Global*)pAux;\n      pRet->eType = eType;\n      pRet->db = db;\n      pRet->zFts5Tbl = (char*)&pRet[1];\n      pRet->zFts5Db = &pRet->zFts5Tbl[nTab];\n      memcpy(pRet->zFts5Tbl, zTab, nTab);\n      memcpy(pRet->zFts5Db, zDb, nDb);\n      sqlite3Fts5Dequote(pRet->zFts5Tbl);\n      sqlite3Fts5Dequote(pRet->zFts5Db);\n    }\n  }\n\n  *ppVTab = (sqlite3_vtab*)pRet;\n  return rc;\n}\n\n\n/*\n** The xConnect() and xCreate() methods for the virtual table. All the\n** work is done in function fts5VocabInitVtab().\n*/\nstatic int fts5VocabConnectMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\nstatic int fts5VocabCreateMethod(\n  sqlite3 *db,                    /* Database connection */\n  void *pAux,                     /* Pointer to tokenizer hash table */\n  int argc,                       /* Number of elements in argv array */\n  const char * const *argv,       /* xCreate/xConnect argument array */\n  sqlite3_vtab **ppVtab,          /* OUT: New sqlite3_vtab object */\n  char **pzErr                    /* OUT: sqlite3_malloc'd error message */\n){\n  return fts5VocabInitVtab(db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/* \n** Implementation of the xBestIndex method.\n**\n** Only constraints of the form:\n**\n**     term <= ?\n**     term == ?\n**     term >= ?\n**\n** are interpreted. Less-than and less-than-or-equal are treated \n** identically, as are greater-than and greater-than-or-equal.\n*/\nstatic int fts5VocabBestIndexMethod(\n  sqlite3_vtab *pUnused,\n  sqlite3_index_info *pInfo\n){\n  int i;\n  int iTermEq = -1;\n  int iTermGe = -1;\n  int iTermLe = -1;\n  int idxNum = 0;\n  int nArg = 0;\n\n  UNUSED_PARAM(pUnused);\n\n  for(i=0; i<pInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pInfo->aConstraint[i];\n    if( p->usable==0 ) continue;\n    if( p->iColumn==0 ){          /* term column */\n      if( p->op==SQLITE_INDEX_CONSTRAINT_EQ ) iTermEq = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LE ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_LT ) iTermLe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GE ) iTermGe = i;\n      if( p->op==SQLITE_INDEX_CONSTRAINT_GT ) iTermGe = i;\n    }\n  }\n\n  if( iTermEq>=0 ){\n    idxNum |= FTS5_VOCAB_TERM_EQ;\n    pInfo->aConstraintUsage[iTermEq].argvIndex = ++nArg;\n    pInfo->estimatedCost = 100;\n  }else{\n    pInfo->estimatedCost = 1000000;\n    if( iTermGe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_GE;\n      pInfo->aConstraintUsage[iTermGe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n    if( iTermLe>=0 ){\n      idxNum |= FTS5_VOCAB_TERM_LE;\n      pInfo->aConstraintUsage[iTermLe].argvIndex = ++nArg;\n      pInfo->estimatedCost = pInfo->estimatedCost / 2;\n    }\n  }\n\n  /* This virtual table always delivers results in ascending order of\n  ** the \"term\" column (column 0). So if the user has requested this\n  ** specifically - \"ORDER BY term\" or \"ORDER BY term ASC\" - set the\n  ** sqlite3_index_info.orderByConsumed flag to tell the core the results\n  ** are already in sorted order.  */\n  if( pInfo->nOrderBy==1 \n   && pInfo->aOrderBy[0].iColumn==0 \n   && pInfo->aOrderBy[0].desc==0\n  ){\n    pInfo->orderByConsumed = 1;\n  }\n\n  pInfo->idxNum = idxNum;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of xOpen method.\n*/\nstatic int fts5VocabOpenMethod(\n  sqlite3_vtab *pVTab, \n  sqlite3_vtab_cursor **ppCsr\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;\n  Fts5Index *pIndex = 0;\n  Fts5Config *pConfig = 0;\n  Fts5VocabCursor *pCsr = 0;\n  int rc = SQLITE_OK;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql = 0;\n\n  zSql = sqlite3Fts5Mprintf(&rc,\n      \"SELECT t.%Q FROM %Q.%Q AS t WHERE t.%Q MATCH '*id'\",\n      pTab->zFts5Tbl, pTab->zFts5Db, pTab->zFts5Tbl, pTab->zFts5Tbl\n  );\n  if( zSql ){\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pStmt, 0);\n  }\n  sqlite3_free(zSql);\n  assert( rc==SQLITE_OK || pStmt==0 );\n  if( rc==SQLITE_ERROR ) rc = SQLITE_OK;\n\n  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    i64 iId = sqlite3_column_int64(pStmt, 0);\n    pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig);\n  }\n\n  if( rc==SQLITE_OK && pIndex==0 ){\n    rc = sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( rc==SQLITE_OK ){\n      pVTab->zErrMsg = sqlite3_mprintf(\n          \"no such fts5 table: %s.%s\", pTab->zFts5Db, pTab->zFts5Tbl\n      );\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor);\n    pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);\n  }\n\n  if( pCsr ){\n    pCsr->pIndex = pIndex;\n    pCsr->pStmt = pStmt;\n    pCsr->pConfig = pConfig;\n    pCsr->aCnt = (i64*)&pCsr[1];\n    pCsr->aDoc = &pCsr->aCnt[pConfig->nCol];\n  }else{\n    sqlite3_finalize(pStmt);\n  }\n\n  *ppCsr = (sqlite3_vtab_cursor*)pCsr;\n  return rc;\n}\n\nstatic void fts5VocabResetCursor(Fts5VocabCursor *pCsr){\n  pCsr->rowid = 0;\n  sqlite3Fts5IterClose(pCsr->pIter);\n  pCsr->pIter = 0;\n  sqlite3_free(pCsr->zLeTerm);\n  pCsr->nLeTerm = -1;\n  pCsr->zLeTerm = 0;\n}\n\n/*\n** Close the cursor.  For additional information see the documentation\n** on the xClose method of the virtual table interface.\n*/\nstatic int fts5VocabCloseMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  fts5VocabResetCursor(pCsr);\n  sqlite3Fts5BufferFree(&pCsr->term);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic int fts5VocabInstanceNewTerm(Fts5VocabCursor *pCsr){\n  int rc = SQLITE_OK;\n  \n  if( sqlite3Fts5IterEof(pCsr->pIter) ){\n    pCsr->bEof = 1;\n  }else{\n    const char *zTerm;\n    int nTerm;\n    zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n    if( pCsr->nLeTerm>=0 ){\n      int nCmp = MIN(nTerm, pCsr->nLeTerm);\n      int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n      if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n        pCsr->bEof = 1;\n      }\n    }\n\n    sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n  }\n  return rc;\n}\n\nstatic int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){\n  int eDetail = pCsr->pConfig->eDetail;\n  int rc = SQLITE_OK;\n  Fts5IndexIter *pIter = pCsr->pIter;\n  i64 *pp = &pCsr->iInstPos;\n  int *po = &pCsr->iInstOff;\n  \n  while( eDetail==FTS5_DETAIL_NONE\n      || sqlite3Fts5PoslistNext64(pIter->pData, pIter->nData, po, pp) \n  ){\n    pCsr->iInstPos = 0;\n    pCsr->iInstOff = 0;\n\n    rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n    if( rc==SQLITE_OK ){\n      rc = fts5VocabInstanceNewTerm(pCsr);\n      if( eDetail==FTS5_DETAIL_NONE ) break;\n    }\n    if( rc ){\n      pCsr->bEof = 1;\n      break;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance the cursor to the next row in the table.\n*/\nstatic int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  int nCol = pCsr->pConfig->nCol;\n\n  pCsr->rowid++;\n\n  if( pTab->eType==FTS5_VOCAB_INSTANCE ){\n    return fts5VocabInstanceNext(pCsr);\n  }\n\n  if( pTab->eType==FTS5_VOCAB_COL ){\n    for(pCsr->iCol++; pCsr->iCol<nCol; pCsr->iCol++){\n      if( pCsr->aDoc[pCsr->iCol] ) break;\n    }\n  }\n\n  if( pTab->eType!=FTS5_VOCAB_COL || pCsr->iCol>=nCol ){\n    if( sqlite3Fts5IterEof(pCsr->pIter) ){\n      pCsr->bEof = 1;\n    }else{\n      const char *zTerm;\n      int nTerm;\n\n      zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n      if( pCsr->nLeTerm>=0 ){\n        int nCmp = MIN(nTerm, pCsr->nLeTerm);\n        int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);\n        if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){\n          pCsr->bEof = 1;\n          return SQLITE_OK;\n        }\n      }\n\n      sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);\n      memset(pCsr->aCnt, 0, nCol * sizeof(i64));\n      memset(pCsr->aDoc, 0, nCol * sizeof(i64));\n      pCsr->iCol = 0;\n\n      assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );\n      while( rc==SQLITE_OK ){\n        int eDetail = pCsr->pConfig->eDetail;\n        const u8 *pPos; int nPos;   /* Position list */\n        i64 iPos = 0;               /* 64-bit position read from poslist */\n        int iOff = 0;               /* Current offset within position list */\n\n        pPos = pCsr->pIter->pData;\n        nPos = pCsr->pIter->nData;\n\n        switch( pTab->eType ){\n          case FTS5_VOCAB_ROW:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                pCsr->aCnt[0]++;\n              }\n            }\n            pCsr->aDoc[0]++;\n            break;\n\n          case FTS5_VOCAB_COL:\n            if( eDetail==FTS5_DETAIL_FULL ){\n              int iCol = -1;\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){\n                int ii = FTS5_POS2COLUMN(iPos);\n                pCsr->aCnt[ii]++;\n                if( iCol!=ii ){\n                  if( ii>=nCol ){\n                    rc = FTS5_CORRUPT;\n                    break;\n                  }\n                  pCsr->aDoc[ii]++;\n                  iCol = ii;\n                }\n              }\n            }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n              while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){\n                assert_nc( iPos>=0 && iPos<nCol );\n                if( iPos>=nCol ){\n                  rc = FTS5_CORRUPT;\n                  break;\n                }\n                pCsr->aDoc[iPos]++;\n              }\n            }else{\n              assert( eDetail==FTS5_DETAIL_NONE );\n              pCsr->aDoc[0]++;\n            }\n            break;\n\n          default:\n            assert( pTab->eType==FTS5_VOCAB_INSTANCE );\n            break;\n        }\n\n        if( rc==SQLITE_OK ){\n          rc = sqlite3Fts5IterNextScan(pCsr->pIter);\n        }\n        if( pTab->eType==FTS5_VOCAB_INSTANCE ) break;\n\n        if( rc==SQLITE_OK ){\n          zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);\n          if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){\n            break;\n          }\n          if( sqlite3Fts5IterEof(pCsr->pIter) ) break;\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){\n    while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;\n    assert( pCsr->iCol<pCsr->pConfig->nCol );\n  }\n  return rc;\n}\n\n/*\n** This is the xFilter implementation for the virtual table.\n*/\nstatic int fts5VocabFilterMethod(\n  sqlite3_vtab_cursor *pCursor,   /* The cursor used for this query */\n  int idxNum,                     /* Strategy index */\n  const char *zUnused,            /* Unused */\n  int nUnused,                    /* Number of elements in apVal */\n  sqlite3_value **apVal           /* Arguments for the indexing scheme */\n){\n  Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eType = pTab->eType;\n  int rc = SQLITE_OK;\n\n  int iVal = 0;\n  int f = FTS5INDEX_QUERY_SCAN;\n  const char *zTerm = 0;\n  int nTerm = 0;\n\n  sqlite3_value *pEq = 0;\n  sqlite3_value *pGe = 0;\n  sqlite3_value *pLe = 0;\n\n  UNUSED_PARAM2(zUnused, nUnused);\n\n  fts5VocabResetCursor(pCsr);\n  if( idxNum & FTS5_VOCAB_TERM_EQ ) pEq = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_GE ) pGe = apVal[iVal++];\n  if( idxNum & FTS5_VOCAB_TERM_LE ) pLe = apVal[iVal++];\n\n  if( pEq ){\n    zTerm = (const char *)sqlite3_value_text(pEq);\n    nTerm = sqlite3_value_bytes(pEq);\n    f = 0;\n  }else{\n    if( pGe ){\n      zTerm = (const char *)sqlite3_value_text(pGe);\n      nTerm = sqlite3_value_bytes(pGe);\n    }\n    if( pLe ){\n      const char *zCopy = (const char *)sqlite3_value_text(pLe);\n      pCsr->nLeTerm = sqlite3_value_bytes(pLe);\n      pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);\n      if( pCsr->zLeTerm==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1);\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);\n  }\n  if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){\n    rc = fts5VocabInstanceNewTerm(pCsr);\n  }\n  if( rc==SQLITE_OK \n   && !pCsr->bEof \n   && (eType!=FTS5_VOCAB_INSTANCE || pCsr->pConfig->eDetail!=FTS5_DETAIL_NONE)\n  ){\n    rc = fts5VocabNextMethod(pCursor);\n  }\n\n  return rc;\n}\n\n/* \n** This is the xEof method of the virtual table. SQLite calls this \n** routine to find out if it has reached the end of a result set.\n*/\nstatic int fts5VocabEofMethod(sqlite3_vtab_cursor *pCursor){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  return pCsr->bEof;\n}\n\nstatic int fts5VocabColumnMethod(\n  sqlite3_vtab_cursor *pCursor,   /* Cursor to retrieve value from */\n  sqlite3_context *pCtx,          /* Context for sqlite3_result_xxx() calls */\n  int iCol                        /* Index of column to read value from */\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  int eDetail = pCsr->pConfig->eDetail;\n  int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;\n  i64 iVal = 0;\n\n  if( iCol==0 ){\n    sqlite3_result_text(\n        pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT\n    );\n  }else if( eType==FTS5_VOCAB_COL ){\n    assert( iCol==1 || iCol==2 || iCol==3 );\n    if( iCol==1 ){\n      if( eDetail!=FTS5_DETAIL_NONE ){\n        const char *z = pCsr->pConfig->azCol[pCsr->iCol];\n        sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n      }\n    }else if( iCol==2 ){\n      iVal = pCsr->aDoc[pCsr->iCol];\n    }else{\n      iVal = pCsr->aCnt[pCsr->iCol];\n    }\n  }else if( eType==FTS5_VOCAB_ROW ){\n    assert( iCol==1 || iCol==2 );\n    if( iCol==1 ){\n      iVal = pCsr->aDoc[0];\n    }else{\n      iVal = pCsr->aCnt[0];\n    }\n  }else{\n    assert( eType==FTS5_VOCAB_INSTANCE );\n    switch( iCol ){\n      case 1:\n        sqlite3_result_int64(pCtx, pCsr->pIter->iRowid);\n        break;\n      case 2: {\n        int ii = -1;\n        if( eDetail==FTS5_DETAIL_FULL ){\n          ii = FTS5_POS2COLUMN(pCsr->iInstPos);\n        }else if( eDetail==FTS5_DETAIL_COLUMNS ){\n          ii = (int)pCsr->iInstPos;\n        }\n        if( ii>=0 && ii<pCsr->pConfig->nCol ){\n          const char *z = pCsr->pConfig->azCol[ii];\n          sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);\n        }\n        break;\n      }\n      default: {\n        assert( iCol==3 );\n        if( eDetail==FTS5_DETAIL_FULL ){\n          int ii = FTS5_POS2OFFSET(pCsr->iInstPos);\n          sqlite3_result_int(pCtx, ii);\n        }\n        break;\n      }\n    }\n  }\n\n  if( iVal>0 ) sqlite3_result_int64(pCtx, iVal);\n  return SQLITE_OK;\n}\n\n/* \n** This is the xRowid method. The SQLite core calls this routine to\n** retrieve the rowid for the current row of the result set. The\n** rowid should be written to *pRowid.\n*/\nstatic int fts5VocabRowidMethod(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite_int64 *pRowid\n){\n  Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;\n  *pRowid = pCsr->rowid;\n  return SQLITE_OK;\n}\n\nstatic int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){\n  static const sqlite3_module fts5Vocab = {\n    /* iVersion      */ 2,\n    /* xCreate       */ fts5VocabCreateMethod,\n    /* xConnect      */ fts5VocabConnectMethod,\n    /* xBestIndex    */ fts5VocabBestIndexMethod,\n    /* xDisconnect   */ fts5VocabDisconnectMethod,\n    /* xDestroy      */ fts5VocabDestroyMethod,\n    /* xOpen         */ fts5VocabOpenMethod,\n    /* xClose        */ fts5VocabCloseMethod,\n    /* xFilter       */ fts5VocabFilterMethod,\n    /* xNext         */ fts5VocabNextMethod,\n    /* xEof          */ fts5VocabEofMethod,\n    /* xColumn       */ fts5VocabColumnMethod,\n    /* xRowid        */ fts5VocabRowidMethod,\n    /* xUpdate       */ 0,\n    /* xBegin        */ 0,\n    /* xSync         */ 0,\n    /* xCommit       */ 0,\n    /* xRollback     */ 0,\n    /* xFindFunction */ 0,\n    /* xRename       */ 0,\n    /* xSavepoint    */ 0,\n    /* xRelease      */ 0,\n    /* xRollbackTo   */ 0,\n  };\n  void *p = (void*)pGlobal;\n\n  return sqlite3_create_module_v2(db, \"fts5vocab\", &fts5Vocab, p, 0);\n}\n\n\n\n\n    \n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */\n\n/************** End of fts5.c ************************************************/\n/************** Begin file stmt.c ********************************************/\n/*\n** 2017-05-31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file demonstrates an eponymous virtual table that returns information\n** about all prepared statements for the database connection.\n**\n** Usage example:\n**\n**     .load ./stmt\n**     .mode line\n**     .header on\n**     SELECT * FROM stmt;\n*/\n#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB)\n#if !defined(SQLITEINT_H)\n/* #include \"sqlite3ext.h\" */\n#endif\nSQLITE_EXTENSION_INIT1\n/* #include <assert.h> */\n/* #include <string.h> */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/* stmt_vtab is a subclass of sqlite3_vtab which will\n** serve as the underlying representation of a stmt virtual table\n*/\ntypedef struct stmt_vtab stmt_vtab;\nstruct stmt_vtab {\n  sqlite3_vtab base;  /* Base class - must be first */\n  sqlite3 *db;        /* Database connection for this stmt vtab */\n};\n\n/* stmt_cursor is a subclass of sqlite3_vtab_cursor which will\n** serve as the underlying representation of a cursor that scans\n** over rows of the result\n*/\ntypedef struct stmt_cursor stmt_cursor;\nstruct stmt_cursor {\n  sqlite3_vtab_cursor base;  /* Base class - must be first */\n  sqlite3 *db;               /* Database connection for this cursor */\n  sqlite3_stmt *pStmt;       /* Statement cursor is currently pointing at */\n  sqlite3_int64 iRowid;      /* The rowid */\n};\n\n/*\n** The stmtConnect() method is invoked to create a new\n** stmt_vtab that describes the stmt virtual table.\n**\n** Think of this routine as the constructor for stmt_vtab objects.\n**\n** All this routine needs to do is:\n**\n**    (1) Allocate the stmt_vtab object and initialize all fields.\n**\n**    (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the\n**        result set of queries against stmt will look like.\n*/\nstatic int stmtConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  stmt_vtab *pNew;\n  int rc;\n\n/* Column numbers */\n#define STMT_COLUMN_SQL     0   /* SQL for the statement */\n#define STMT_COLUMN_NCOL    1   /* Number of result columns */\n#define STMT_COLUMN_RO      2   /* True if read-only */\n#define STMT_COLUMN_BUSY    3   /* True if currently busy */\n#define STMT_COLUMN_NSCAN   4   /* SQLITE_STMTSTATUS_FULLSCAN_STEP */\n#define STMT_COLUMN_NSORT   5   /* SQLITE_STMTSTATUS_SORT */\n#define STMT_COLUMN_NAIDX   6   /* SQLITE_STMTSTATUS_AUTOINDEX */\n#define STMT_COLUMN_NSTEP   7   /* SQLITE_STMTSTATUS_VM_STEP */\n#define STMT_COLUMN_REPREP  8   /* SQLITE_STMTSTATUS_REPREPARE */\n#define STMT_COLUMN_RUN     9   /* SQLITE_STMTSTATUS_RUN */\n#define STMT_COLUMN_MEM    10   /* SQLITE_STMTSTATUS_MEMUSED */\n\n\n  rc = sqlite3_declare_vtab(db,\n     \"CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,\"\n                    \"reprep,run,mem)\");\n  if( rc==SQLITE_OK ){\n    pNew = sqlite3_malloc( sizeof(*pNew) );\n    *ppVtab = (sqlite3_vtab*)pNew;\n    if( pNew==0 ) return SQLITE_NOMEM;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->db = db;\n  }\n  return rc;\n}\n\n/*\n** This method is the destructor for stmt_cursor objects.\n*/\nstatic int stmtDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** Constructor for a new stmt_cursor object.\n*/\nstatic int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){\n  stmt_cursor *pCur;\n  pCur = sqlite3_malloc( sizeof(*pCur) );\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(*pCur));\n  pCur->db = ((stmt_vtab*)p)->db;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Destructor for a stmt_cursor.\n*/\nstatic int stmtClose(sqlite3_vtab_cursor *cur){\n  sqlite3_free(cur);\n  return SQLITE_OK;\n}\n\n\n/*\n** Advance a stmt_cursor to its next row of output.\n*/\nstatic int stmtNext(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  pCur->iRowid++;\n  pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);\n  return SQLITE_OK;\n}\n\n/*\n** Return values of columns for the row at which the stmt_cursor\n** is currently pointing.\n*/\nstatic int stmtColumn(\n  sqlite3_vtab_cursor *cur,   /* The cursor */\n  sqlite3_context *ctx,       /* First argument to sqlite3_result_...() */\n  int i                       /* Which column to return */\n){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  switch( i ){\n    case STMT_COLUMN_SQL: {\n      sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case STMT_COLUMN_NCOL: {\n      sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_RO: {\n      sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_BUSY: {\n      sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));\n      break;\n    }\n    case STMT_COLUMN_MEM: {\n      i = SQLITE_STMTSTATUS_MEMUSED + \n            STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;\n      /* Fall thru */\n    }\n    case STMT_COLUMN_NSCAN:\n    case STMT_COLUMN_NSORT:\n    case STMT_COLUMN_NAIDX:\n    case STMT_COLUMN_NSTEP:\n    case STMT_COLUMN_REPREP:\n    case STMT_COLUMN_RUN: {\n      sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,\n                      i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the rowid for the current row.  In this implementation, the\n** rowid is the same as the output value.\n*/\nstatic int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  *pRowid = pCur->iRowid;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the cursor has been moved off of the last\n** row of output.\n*/\nstatic int stmtEof(sqlite3_vtab_cursor *cur){\n  stmt_cursor *pCur = (stmt_cursor*)cur;\n  return pCur->pStmt==0;\n}\n\n/*\n** This method is called to \"rewind\" the stmt_cursor object back\n** to the first row of output.  This method is always called at least\n** once prior to any call to stmtColumn() or stmtRowid() or \n** stmtEof().\n*/\nstatic int stmtFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;\n  pCur->pStmt = 0;\n  pCur->iRowid = 0;\n  return stmtNext(pVtabCursor);\n}\n\n/*\n** SQLite will invoke this method one or more times while planning a query\n** that uses the stmt virtual table.  This routine needs to create\n** a query plan for each invocation and compute an estimated cost for that\n** plan.\n*/\nstatic int stmtBestIndex(\n  sqlite3_vtab *tab,\n  sqlite3_index_info *pIdxInfo\n){\n  pIdxInfo->estimatedCost = (double)500;\n  pIdxInfo->estimatedRows = 500;\n  return SQLITE_OK;\n}\n\n/*\n** This following structure defines all the methods for the \n** stmt virtual table.\n*/\nstatic sqlite3_module stmtModule = {\n  0,                         /* iVersion */\n  0,                         /* xCreate */\n  stmtConnect,               /* xConnect */\n  stmtBestIndex,             /* xBestIndex */\n  stmtDisconnect,            /* xDisconnect */\n  0,                         /* xDestroy */\n  stmtOpen,                  /* xOpen - open a cursor */\n  stmtClose,                 /* xClose - close a cursor */\n  stmtFilter,                /* xFilter - configure scan constraints */\n  stmtNext,                  /* xNext - advance a cursor */\n  stmtEof,                   /* xEof - check for end of scan */\n  stmtColumn,                /* xColumn - read data */\n  stmtRowid,                 /* xRowid - read data */\n  0,                         /* xUpdate */\n  0,                         /* xBegin */\n  0,                         /* xSync */\n  0,                         /* xCommit */\n  0,                         /* xRollback */\n  0,                         /* xFindMethod */\n  0,                         /* xRename */\n  0,                         /* xSavepoint */\n  0,                         /* xRelease */\n  0,                         /* xRollbackTo */\n};\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\nSQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_create_module(db, \"sqlite_stmt\", &stmtModule, 0);\n#endif\n  return rc;\n}\n\n#ifndef SQLITE_CORE\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nSQLITE_API int sqlite3_stmt_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc = SQLITE_OK;\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3StmtVtabInit(db);\n#endif\n  return rc;\n}\n#endif /* SQLITE_CORE */\n#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */\n\n/************** End of stmt.c ************************************************/\n#if __LINE__!=205346\n#undef SQLITE_SOURCE_ID\n#define SQLITE_SOURCE_ID      \"2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de4alt2\"\n#endif\n/* Return the source-id for this library */\nSQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }\n/************************** End of sqlite3.c ******************************/\n"
  },
  {
    "path": "v2/testdata/_sqlite/sqlite-amalgamation-3210000/sqlite3.h",
    "content": "/*\n** 2001-09-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are supposed to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef SQLITE3_H\n#define SQLITE3_H\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** Provide the ability to override linkage features of the interface.\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n#ifndef SQLITE_CDECL\n# define SQLITE_CDECL\n#endif\n#ifndef SQLITE_APICALL\n# define SQLITE_APICALL\n#endif\n#ifndef SQLITE_STDCALL\n# define SQLITE_STDCALL SQLITE_APICALL\n#endif\n#ifndef SQLITE_CALLBACK\n# define SQLITE_CALLBACK\n#endif\n#ifndef SQLITE_SYSAPI\n# define SQLITE_SYSAPI\n#endif\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are supported for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since [version 3.6.18] ([dateof:3.6.18]), \n** SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and a SHA1\n** or SHA3-256 hash of the entire source tree.  If the source code has\n** been edited in any way since it was last checked in, then the last\n** four hexadecimal digits of the hash may be modified.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"3.21.0\"\n#define SQLITE_VERSION_NUMBER 3021000\n#define SQLITE_SOURCE_ID      \"2017-10-24 18:55:49 1a584e499906b5c87ec7d43d4abce641fdf017c42125b083109bc77c4de48827\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus ensure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built\n** using an edited copy of [the amalgamation], then the last four characters\n** of the hash might be different from [SQLITE_SOURCE_ID].)^\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_API SQLITE_EXTERN const char sqlite3_version[];\nSQLITE_API const char *sqlite3_libversion(void);\nSQLITE_API const char *sqlite3_sourceid(void);\nSQLITE_API int sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nSQLITE_API int sqlite3_compileoption_used(const char *zOptName);\nSQLITE_API const char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nSQLITE_API int sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n# ifdef SQLITE_UINT64_TYPE\n    typedef SQLITE_UINT64_TYPE sqlite_uint64;\n# else  \n    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n# endif\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n** DESTRUCTOR: sqlite3\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and/or unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nSQLITE_API int sqlite3_close(sqlite3*);\nSQLITE_API int sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n** METHOD: sqlite3\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must ensure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close the [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nSQLITE_API int sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: {result code definitions}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [extended result code definitions]\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* Generic error */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Internal use only */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Not used */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended result code definitions}\n**\n** In its default configuration, SQLite API routines return one of 30 integer\n** [result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]\n** and later) include\n** support for additional result codes that provide more detailed information\n** about errors. These [extended result codes] are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.  Or, the extended code for\n** the most recent error can be obtained using\n** [sqlite3_extended_errcode()].\n*/\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))\n#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))\n#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))\n#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))\n#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))\n#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))\n#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))\n#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))\n#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n** flag indicates that a file cannot be deleted when open.  The\n** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on\n** read-only media and cannot be changed even by processes with\n** elevated privileges.\n**\n** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying\n** filesystem supports doing multiple write operations atomically when those\n** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and\n** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n#define SQLITE_IOCAP_IMMUTABLE              0x00002000\n#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [file control opcodes | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]\n** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]\n** <li> [SQLITE_IOCAP_IMMUTABLE]\n** <li> [SQLITE_IOCAP_BATCH_ATOMIC]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n** KEYWORDS: {file control opcodes} {file control opcode}\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** <ul>\n** <li>[[SQLITE_FCNTL_LOCKSTATE]]\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and is only available when the SQLITE_TEST\n** compile-time option is used.\n**\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].\n**\n** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]\n** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with the journal file (either\n** the [rollback journal] or the [write-ahead log]) for a particular database\n** connection.  See also [SQLITE_FCNTL_FILE_POINTER].\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** No longer in use.\n**\n** <li>[[SQLITE_FCNTL_SYNC]]\n** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and\n** sent to the VFS immediately before the xSync method is invoked on a\n** database file descriptor. Or, if the xSync method is not invoked \n** because the user has configured SQLite with \n** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place \n** of the xSync method. In most cases, the pointer argument passed with\n** this file-control is NULL. However, if the database file is being synced\n** as part of a multi-database commit, the argument points to a nul-terminated\n** string containing the transactions master-journal file name. VFSes that \n** do not need this signal should silently ignore this opcode. Applications \n** should not call [sqlite3_file_control()] with this opcode as doing so may \n** disrupt the operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]\n** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite\n** and sent to the VFS after a transaction has been committed immediately\n** but before the database is unlocked. VFSes that do not need this signal\n** should silently ignore this opcode. Applications should not call\n** [sqlite3_file_control()] with this opcode as doing so may disrupt the \n** operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer is the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log and shared memory files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_VFS_POINTER]]\n** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level\n** [VFSes] currently in use.  ^(The argument X in\n** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be\n** of type \"[sqlite3_vfs] **\".  This opcodes will set *X\n** to a pointer to the top-level VFS.)^\n** ^When there are multiple VFS shims in the stack, this opcode finds the\n** upper-most shim only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement if result string is NULL, or that returns a copy\n** of the result string if the string is non-NULL.\n** ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** <li>[[SQLITE_FCNTL_TRACE]]\n** The [SQLITE_FCNTL_TRACE] file control provides advisory information\n** to the VFS about what the higher layers of the SQLite stack are doing.\n** This file control is used by some VFS activity tracing [shims].\n** The argument is a zero-terminated string.  Higher layers in the\n** SQLite stack may generate instances of this file control if\n** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.\n**\n** <li>[[SQLITE_FCNTL_HAS_MOVED]]\n** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a\n** pointer to an integer and it writes a boolean into that integer depending\n** on whether or not the file has been renamed, moved, or deleted since it\n** was first opened.\n**\n** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the\n** underlying native file handle associated with a file handle.  This file\n** control interprets its argument as a pointer to a native file handle and\n** writes the resulting value there.\n**\n** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to swap the file handle with the one\n** pointed to by the pArg argument.  This capability is used during testing\n** and only needs to be supported when SQLITE_TEST is defined.\n**\n** <li>[[SQLITE_FCNTL_WAL_BLOCK]]\n** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might\n** be advantageous to block on the next WAL lock if the lock is not immediately\n** available.  The WAL subsystem issues this signal during rare\n** circumstances in order to fix a problem with priority inversion.\n** Applications should <em>not</em> use this file-control.\n**\n** <li>[[SQLITE_FCNTL_ZIPVFS]]\n** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other\n** VFS should return SQLITE_NOTFOUND for this opcode.\n**\n** <li>[[SQLITE_FCNTL_RBU]]\n** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by\n** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for\n** this opcode.  \n**\n** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]\n** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then\n** the file descriptor is placed in \"batch write mode\", which\n** means all subsequent write operations will be deferred and done\n** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems\n** that do not support batch atomic writes will return SQLITE_NOTFOUND.\n** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to\n** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or\n** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make\n** no VFS interface calls on the same [sqlite3_file] file descriptor\n** except for calls to the xWrite method and the xFileControl method\n** with [SQLITE_FCNTL_SIZE_HINT].\n**\n** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.\n** This file control returns [SQLITE_OK] if and only if the writes were\n** all performed successfully and have been committed to persistent storage.\n** ^Regardless of whether or not it is successful, this file control takes\n** the file descriptor out of batch write mode so that all subsequent\n** write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.\n** ^This file control takes the file descriptor out of batch write mode\n** so that all subsequent write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2\n#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3\n#define SQLITE_FCNTL_LAST_ERRNO              4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n#define SQLITE_FCNTL_TRACE                  19\n#define SQLITE_FCNTL_HAS_MOVED              20\n#define SQLITE_FCNTL_SYNC                   21\n#define SQLITE_FCNTL_COMMIT_PHASETWO        22\n#define SQLITE_FCNTL_WIN32_SET_HANDLE       23\n#define SQLITE_FCNTL_WAL_BLOCK              24\n#define SQLITE_FCNTL_ZIPVFS                 25\n#define SQLITE_FCNTL_RBU                    26\n#define SQLITE_FCNTL_VFS_POINTER            27\n#define SQLITE_FCNTL_JOURNAL_POINTER        28\n#define SQLITE_FCNTL_WIN32_GET_HANDLE       29\n#define SQLITE_FCNTL_PDB                    30\n#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31\n#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32\n#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33\n\n/* deprecated names */\n#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE\n#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE\n#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO\n\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: Loadable Extension Thunk\n**\n** A pointer to the opaque sqlite3_api_routines structure is passed as\n** the third parameter to entry points of [loadable extensions].  This\n** structure must be typedefed in order to work around compiler warnings\n** on some platforms.\n*/\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The value of the iVersion field is initially 1 but may be larger in\n** future versions of SQLite.  Additional fields may be appended to this\n** object when the iVersion value is increased.  Note that the structure\n** of the sqlite3_vfs object changes in the transaction between\n** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not\n** modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in future versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given on the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nSQLITE_API int sqlite3_initialize(void);\nSQLITE_API int sqlite3_shutdown(void);\nSQLITE_API int sqlite3_os_init(void);\nSQLITE_API int sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** <b>The sqlite3_config() interface is not threadsafe. The application\n** must ensure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.</b>\n**\n** The sqlite3_config() interface\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nSQLITE_API int sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n** METHOD: sqlite3\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nSQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is \n** a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>\n** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of\n** type int, interpreted as a boolean, which if true provides a hint to\n** SQLite that it should avoid large memory allocations if possible.\n** SQLite will run faster if it is free to make large memory allocations,\n** but some application might prefer to run slower in exchange for\n** guarantees about memory fragmentation that are possible if large\n** allocations are avoided.  This hint is normally off.\n** </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,\n** interpreted as a boolean, which enables or disables the collection of\n** memory allocation statistics. ^(When memory allocation statistics are\n** disabled, the following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status64()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.\n** </dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool\n** that SQLite can use for the database page cache with the default page\n** cache implementation.  \n** This configuration option is a no-op if an application-define page\n** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].\n** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to\n** 8-byte aligned memory (pMem), the size of each page cache line (sz),\n** and the number of cache lines (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 65536) plus some extra bytes for each\n** page header.  ^The number of extra bytes needed by the page header\n** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].\n** ^It is harmless, apart from the wasted memory,\n** for the sz parameter to be larger than necessary.  The pMem\n** argument must be either a NULL pointer or a pointer to an 8-byte\n** aligned block of memory of at least sz*N bytes, otherwise\n** subsequent behavior is undefined.\n** ^When pMem is not NULL, SQLite will strive to use the memory provided\n** to satisfy page cache needs, falling back to [sqlite3_malloc()] if\n** a page cache line is larger than sz bytes or if all of the pMem buffer\n** is exhausted.\n** ^If pMem is NULL and N is non-zero, then each database connection\n** does an initial bulk allocation for page cache memory\n** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or\n** of -1024*N bytes if N is negative, . ^If additional\n** page cache memory is needed beyond what is provided by the initial\n** allocation, then SQLite goes to [sqlite3_malloc()] separately for each\n** additional cache line. </dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer \n** that SQLite will use for all of its dynamic memory allocation needs\n** beyond those provided for by [SQLITE_CONFIG_PAGECACHE].\n** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled\n** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns\n** [SQLITE_ERROR] if invoked otherwise.\n** ^There are three arguments to SQLITE_CONFIG_HEAP:\n** An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a\n** pointer to an instance of the [sqlite3_mutex_methods] structure.\n** The argument specifies alternative low-level mutex routines to be used\n** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of\n** the content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine\n** the default size of lookaside memory on each [database connection].\n** The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE\n** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** option to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is \n** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies\n** the interface to a custom page cache implementation.)^\n** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which\n** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of\n** the current page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.\n** If non-zero, then URI handling is globally enabled. If the parameter is zero,\n** then URI handling is globally disabled.)^ ^If URI handling is globally\n** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],\n** [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. ^If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. ^(By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.)^\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer\n** argument which is interpreted as a boolean in order to enable or disable\n** the use of covering indices for full table scans in the query optimizer.\n** ^The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** ^The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size\n** will be silently truncated if necessary so that it does not exceed the\n** compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^\n** ^If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n**\n** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]\n** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE\n** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is\n** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro\n** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value\n** that specifies the maximum size of the created heap.\n**\n** [[SQLITE_CONFIG_PCACHE_HDRSZ]]\n** <dt>SQLITE_CONFIG_PCACHE_HDRSZ\n** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which\n** is a pointer to an integer and writes into that integer the number of extra\n** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].\n** The amount of extra space required can change depending on the compiler,\n** target platform, and SQLite version.\n**\n** [[SQLITE_CONFIG_PMASZ]]\n** <dt>SQLITE_CONFIG_PMASZ\n** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which\n** is an unsigned integer and sets the \"Minimum PMA Size\" for the multithreaded\n** sorter to that integer.  The default minimum PMA Size is set by the\n** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched\n** to help with sort operations when multithreaded sorting\n** is enabled (using the [PRAGMA threads] command) and the amount of content\n** to be sorted exceeds the page size times the minimum of the\n** [PRAGMA cache_size] setting and this value.\n**\n** [[SQLITE_CONFIG_STMTJRNL_SPILL]]\n** <dt>SQLITE_CONFIG_STMTJRNL_SPILL\n** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which\n** becomes the [statement journal] spill-to-disk threshold.  \n** [Statement journals] are held in memory until their size (in bytes)\n** exceeds this threshold, at which point they are written to disk.\n** Or if the threshold is -1, statement journals are always held\n** exclusively in memory.\n** Since many statement journals never become large, setting the spill\n** threshold to a value such as 64KiB can greatly reduce the amount of\n** I/O required to support statement rollback.\n** The default value for this setting is controlled by the\n** [SQLITE_STMTJRNL_SPILL] compile-time option.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* No longer used */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */\n#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */\n#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */\n#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */\n#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>\n** <dd> ^This option is used to enable or disable the two-argument\n** version of the [fts3_tokenizer()] function which is part of the\n** [FTS3] full-text search engine extension.\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable fts3_tokenizer() or\n** positive to enable fts3_tokenizer() or negative to leave the setting\n** unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the new setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>\n** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]\n** interface independently of the [load_extension()] SQL function.\n** The [sqlite3_enable_load_extension()] API enables or disables both the\n** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].\n** There should be two additional arguments.\n** When the first argument to this interface is 1, then only the C-API is\n** enabled and the SQL function remains disabled.  If the first argument to\n** this interface is 0, then both the C-API and the SQL function are disabled.\n** If the first argument is -1, then no changes are made to state of either the\n** C-API or the SQL function.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface\n** is disabled or enabled following this call.  The second parameter may\n** be a NULL pointer, in which case the new setting is not reported back.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>\n** <dd> ^This option is used to change the name of the \"main\" database\n** schema.  ^The sole argument is a pointer to a constant UTF8 string\n** which will become the new schema name in place of \"main\".  ^SQLite\n** does not make a copy of the new main schema name string, so the application\n** must ensure that the argument passed into this DBCONFIG option is unchanged\n** until after the database connection closes.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>\n** <dd> Usually, when a database in wal mode is closed or detached from a \n** database handle, SQLite checks if this will mean that there are now no \n** connections at all to the database. If so, it performs a checkpoint \n** operation before closing the connection. This option may be used to\n** override this behaviour. The first parameter passed to this operation\n** is an integer - non-zero to disable checkpoints-on-close, or zero (the\n** default) to enable them. The second parameter is a pointer to an integer\n** into which is written 0 or 1 to indicate whether checkpoints-on-close\n** have been disabled - 0 if they are not disabled, 1 if they are.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>\n** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates\n** the [query planner stability guarantee] (QPSG).  When the QPSG is active,\n** a single SQL query statement will always use the same algorithm regardless\n** of values of [bound parameters].)^ The QPSG disables some query optimizations\n** that look at the values of bound parameters, which can make some queries\n** slower.  But the QPSG has the advantage of more predictable behavior.  With\n** the QPSG active, SQLite will always use the same query plan in the field as\n** was used during testing in the lab.\n** </dd>\n**\n** </dl>\n*/\n#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */\n#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */\n#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */\n\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n** METHOD: sqlite3\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nSQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n** METHOD: sqlite3\n**\n** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)\n** has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of\n** the most recent successful [INSERT] into a rowid table or [virtual table]\n** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not\n** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred \n** on the database connection D, then sqlite3_last_insert_rowid(D) returns \n** zero.\n**\n** As well as being set automatically as rows are inserted into database\n** tables, the value returned by this function may be set explicitly by\n** [sqlite3_set_last_insert_rowid()]\n**\n** Some virtual table implementations may INSERT rows into rowid tables as\n** part of committing a transaction (e.g. to flush data accumulated in memory\n** to disk). In this case subsequent calls to this function return the rowid\n** associated with these internal INSERT operations, which leads to \n** unintuitive results. Virtual table implementations that do write to rowid\n** tables in this way can avoid this problem by restoring the original \n** rowid value using [sqlite3_set_last_insert_rowid()] before returning \n** control to the user.\n**\n** ^(If an [INSERT] occurs within a trigger then this routine will \n** return the [rowid] of the inserted row as long as the trigger is \n** running. Once the trigger program ends, the value returned \n** by this routine reverts to what it was before the trigger was fired.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nSQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Set the Last Insert Rowid value.\n** METHOD: sqlite3\n**\n** The sqlite3_set_last_insert_rowid(D, R) method allows the application to\n** set the value returned by calling sqlite3_last_insert_rowid(D) to R \n** without inserting a row into the database.\n*/\nSQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the number of rows modified, inserted or\n** deleted by the most recently completed INSERT, UPDATE or DELETE\n** statement on the database connection specified by the only parameter.\n** ^Executing any other type of SQL statement does not modify the value\n** returned by this function.\n**\n** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are\n** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], \n** [foreign key actions] or [REPLACE] constraint resolution are not counted.\n** \n** Changes to a view that are intercepted by \n** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value \n** returned by sqlite3_changes() immediately after an INSERT, UPDATE or \n** DELETE statement run on a view is always zero. Only changes made to real \n** tables are counted.\n**\n** Things are more complicated if the sqlite3_changes() function is\n** executed while a trigger program is running. This may happen if the\n** program uses the [changes() SQL function], or if some other callback\n** function invokes sqlite3_changes() directly. Essentially:\n** \n** <ul>\n**   <li> ^(Before entering a trigger program the value returned by\n**        sqlite3_changes() function is saved. After the trigger program \n**        has finished, the original value is restored.)^\n** \n**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE \n**        statement sets the value returned by sqlite3_changes() \n**        upon completion as normal. Of course, this value will not include \n**        any changes performed by sub-triggers, as the sqlite3_changes() \n**        value will be saved and restored after each sub-trigger has run.)^\n** </ul>\n** \n** ^This means that if the changes() SQL function (or similar) is used\n** by the first INSERT, UPDATE or DELETE statement within a trigger, it \n** returns the value as set when the calling statement began executing.\n** ^If it is used by the second or subsequent such statement within a trigger \n** program, the value returned reflects the number of rows modified by the \n** previous INSERT, UPDATE or DELETE statement within the same trigger.\n**\n** See also the [sqlite3_total_changes()] interface, the\n** [count_changes pragma], and the [changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the total number of rows inserted, modified or\n** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed\n** since the database connection was opened, including those executed as\n** part of trigger programs. ^Executing any other type of SQL statement\n** does not affect the value returned by sqlite3_total_changes().\n** \n** ^Changes made as part of [foreign key actions] are included in the\n** count, but those made as part of REPLACE constraint resolution are\n** not. ^Changes to a view that are intercepted by INSTEAD OF triggers \n** are not counted.\n** \n** See also the [sqlite3_changes()] interface, the\n** [count_changes pragma], and the [total_changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n*/\nSQLITE_API int sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n** METHOD: sqlite3\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n*/\nSQLITE_API void sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nSQLITE_API int sqlite3_complete(const char *sql);\nSQLITE_API int sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n** KEYWORDS: {busy-handler callback} {busy handler}\n** METHOD: sqlite3\n**\n** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X\n** that might be invoked with argument P whenever\n** an attempt is made to access a database table associated with\n** [database connection] D when another thread\n** or process has the table locked.\n** The sqlite3_busy_handler() interface is used to implement\n** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked previously for the same locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] is returned\n** to the application.\n** ^If the callback returns non-zero, then another attempt\n** is made to access the database and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** to the application instead of invoking the \n** busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** or evaluating [PRAGMA busy_timeout=N] will change the\n** busy handler and thus clear any previously set busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  In other words,\n** the busy handler is not reentrant.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nSQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n** METHOD: sqlite3\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] at any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n**\n** See also:  [PRAGMA busy_timeout]\n*/\nSQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n** METHOD: sqlite3\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nSQLITE_API int sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nSQLITE_API void sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n** These routines understand most of the common K&R formatting options,\n** plus some additional non-standard formats, detailed below.\n** Note that some of the more obscure formatting options from recent\n** C-library standards are omitted from this implementation.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** These routines all implement some additional formatting\n** options that are useful for constructing SQL statements.\n** All of the usual printf() formatting options apply.  In addition, there\n** is are \"%q\", \"%Q\", \"%w\" and \"%z\" options.\n**\n** ^(The %q option works like %s in that it substitutes a nul-terminated\n** string from the argument list.  But %q also doubles every '\\'' character.\n** %q is designed for use inside a string literal.)^  By doubling each '\\''\n** character it escapes that character and allows it to be inserted into\n** the string.\n**\n** For example, assume the string variable zText contains text as follows:\n**\n** <blockquote><pre>\n**  char *zText = \"It's a happy day!\";\n** </pre></blockquote>\n**\n** One can use this text in an SQL statement as follows:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES('%q')\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** Because the %q format string is used, the '\\'' character in zText\n** is escaped and the SQL generated is as follows:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It''s a happy day!')\n** </pre></blockquote>\n**\n** This is correct.  Had we used %s instead of %q, the generated SQL\n** would have looked like this:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It's a happy day!');\n** </pre></blockquote>\n**\n** This second example is an SQL syntax error.  As a general rule you should\n** always use %q instead of %s when inserting text into a string literal.\n**\n** ^(The %Q option works like %q except it also adds single quotes around\n** the outside of the total string.  Additionally, if the parameter in the\n** argument list is a NULL pointer, %Q substitutes the text \"NULL\" (without\n** single quotes).)^  So, for example, one could say:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES(%Q)\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** The code above will render a correct SQL statement in the zSQL\n** variable even if the zText variable is a NULL pointer.\n**\n** ^(The \"%w\" formatting option is like \"%q\" except that it expects to\n** be contained within double-quotes instead of single quotes, and it\n** escapes the double-quote character instead of the single-quote\n** character.)^  The \"%w\" formatting option is intended for safely inserting\n** table and column names into a constructed SQL statement.\n**\n** ^(The \"%z\" formatting option works like \"%s\" but with the\n** addition that after the string has been read and copied into\n** the result, [sqlite3_free()] is called on the input string.)^\n*/\nSQLITE_API char *sqlite3_mprintf(const char*,...);\nSQLITE_API char *sqlite3_vmprintf(const char*, va_list);\nSQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);\nSQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^The sqlite3_malloc64(N) routine works just like\n** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead\n** of a signed 32-bit integer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^The sqlite3_realloc(X,N) interface attempts to resize a\n** prior memory allocation X to be at least N bytes.\n** ^If the X parameter to sqlite3_realloc(X,N)\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N).\n** ^If the N parameter to sqlite3_realloc(X,N) is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(X).\n** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if insufficient memory is available.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc(X,N) and the prior allocation is freed.\n** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the\n** prior allocation is not freed.\n**\n** ^The sqlite3_realloc64(X,N) interfaces works the same as\n** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead\n** of a 32-bit signed integer.\n**\n** ^If X is a memory allocation previously obtained from sqlite3_malloc(),\n** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then\n** sqlite3_msize(X) returns the size of that memory allocation in bytes.\n** ^The value returned by sqlite3_msize(X) might be larger than the number\n** of bytes requested when X was allocated.  ^If X is a NULL pointer then\n** sqlite3_msize(X) returns zero.  If X points to something that is not\n** the beginning of memory allocation, or if it points to a formerly\n** valid memory allocation that has now been freed, then the behavior\n** of sqlite3_msize(X) is undefined and possibly harmful.\n**\n** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),\n** sqlite3_malloc64(), and sqlite3_realloc64()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nSQLITE_API void *sqlite3_malloc(int);\nSQLITE_API void *sqlite3_malloc64(sqlite3_uint64);\nSQLITE_API void *sqlite3_realloc(void*, int);\nSQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);\nSQLITE_API void sqlite3_free(void*);\nSQLITE_API sqlite3_uint64 sqlite3_msize(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nSQLITE_API sqlite3_int64 sqlite3_memory_used(void);\nSQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n** ^The P parameter can be a NULL pointer.\n**\n** ^If this routine has not been previously called or if the previous\n** call had N less than one or a NULL pointer for P, then the PRNG is\n** seeded using randomness obtained from the xRandomness method of\n** the default [sqlite3_vfs] object.\n** ^If the previous call to this routine had an N of 1 or more and a\n** non-NULL P then the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nSQLITE_API void sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n** METHOD: sqlite3\n** KEYWORDS: {authorizer callback}\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],\n** and [sqlite3_prepare16_v3()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are either NULL pointers or zero-terminated strings\n** that contain additional details about the action to be authorized.\n** Applications must always be prepared to encounter a NULL pointer in any\n** of the third through the sixth parameters of the authorization callback.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^When a table is referenced by a [SELECT] but no column values are\n** extracted from that table (for example in a query like\n** \"SELECT count(*) FROM tab\") then the [SQLITE_READ] authorizer callback\n** is invoked once for that table with a column name that is an empty string.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nSQLITE_API int sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]\n** returned from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n#define SQLITE_RECURSIVE            33   /* NULL            NULL            */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n** METHOD: sqlite3\n**\n** These routines are deprecated. Use the [sqlite3_trace_v2()] interface\n** instead of the routines described here.\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  The\n** sqlite3_profile() function is considered experimental and is\n** subject to change in future versions of SQLite.\n*/\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,\n   void(*xTrace)(void*,const char*), void*);\nSQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: SQL Trace Event Codes\n** KEYWORDS: SQLITE_TRACE\n**\n** These constants identify classes of events that can be monitored\n** using the [sqlite3_trace_v2()] tracing logic.  The third argument\n** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of\n** the following constants.  ^The first argument to the trace callback\n** is one of the following constants.\n**\n** New tracing constants may be added in future releases.\n**\n** ^A trace callback has four arguments: xCallback(T,C,P,X).\n** ^The T argument is one of the integer type codes above.\n** ^The C argument is a copy of the context pointer passed in as the\n** fourth argument to [sqlite3_trace_v2()].\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** <dl>\n** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>\n** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement\n** first begins running and possibly at other times during the\n** execution of the prepared statement, such as at the start of each\n** trigger subprogram. ^The P argument is a pointer to the\n** [prepared statement]. ^The X argument is a pointer to a string which\n** is the unexpanded SQL text of the prepared statement or an SQL comment \n** that indicates the invocation of a trigger.  ^The callback can compute\n** the same text that would have been returned by the legacy [sqlite3_trace()]\n** interface by using the X argument when X begins with \"--\" and invoking\n** [sqlite3_expanded_sql(P)] otherwise.\n**\n** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>\n** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same\n** information as is provided by the [sqlite3_profile()] callback.\n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument points to a 64-bit integer which is the estimated of\n** the number of nanosecond that the prepared statement took to run.\n** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.\n**\n** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>\n** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared\n** statement generates a single row of result.  \n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument is unused.\n**\n** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>\n** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database\n** connection closes.\n** ^The P argument is a pointer to the [database connection] object\n** and the X argument is unused.\n** </dl>\n*/\n#define SQLITE_TRACE_STMT       0x01\n#define SQLITE_TRACE_PROFILE    0x02\n#define SQLITE_TRACE_ROW        0x04\n#define SQLITE_TRACE_CLOSE      0x08\n\n/*\n** CAPI3REF: SQL Trace Hook\n** METHOD: sqlite3\n**\n** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback\n** function X against [database connection] D, using property mask M\n** and context pointer P.  ^If the X callback is\n** NULL or if the M mask is zero, then tracing is disabled.  The\n** M argument should be the bitwise OR-ed combination of\n** zero or more [SQLITE_TRACE] constants.\n**\n** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides \n** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().\n**\n** ^The X callback is invoked whenever any of the events identified by \n** mask M occur.  ^The integer return value from the callback is currently\n** ignored, though this may change in future releases.  Callback\n** implementations should return zero to ensure future compatibility.\n**\n** ^A trace callback is invoked with four arguments: callback(T,C,P,X).\n** ^The T argument is one of the [SQLITE_TRACE]\n** constants to indicate why the callback was invoked.\n** ^The C argument is a copy of the context pointer.\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** The sqlite3_trace_v2() interface is intended to replace the legacy\n** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which\n** are deprecated.\n*/\nSQLITE_API int sqlite3_trace_v2(\n  sqlite3*,\n  unsigned uMask,\n  int(*xCallback)(unsigned,void*,void*,void*),\n  void *pCtx\n);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the approximate number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.  ^If N is less than one then the progress\n** handler is disabled.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nSQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n** CONSTRUCTOR: sqlite3\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding will be UTF-8 for databases created using\n** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases\n** created using sqlite3_open16() will be UTF-16 in the native byte order.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the third argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^(On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").)^\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite and its built-in [VFSes] interpret the\n** following query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n**\n**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the\n**     [powersafe overwrite] property does or does not apply to the\n**     storage media on which the database file resides.\n**\n**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter\n**     which if set disables file locking in rollback journal modes.  This\n**     is useful for accessing a database on a filesystem that does not\n**     support locking.  Caution:  Database corruption might result if two\n**     or more processes write to the same database and any one of those\n**     processes uses nolock=1.\n**\n**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query\n**     parameter that indicates that the database file is stored on\n**     read-only media.  ^When immutable is set, SQLite assumes that the\n**     database file cannot be changed, even by a process with higher\n**     privilege, and so the database is opened read-only and all locking\n**     and change detection is disabled.  Caution: Setting the immutable\n**     property on a database file that does in fact change can result\n**     in incorrect query results and/or [SQLITE_CORRUPT] errors.\n**     See also: [SQLITE_IOCAP_IMMUTABLE].\n**       \n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-dotfile\"\n**          that uses dot-files in place of posix advisory locking.\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nSQLITE_API int sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nSQLITE_API int sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n*/\nSQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nSQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nSQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n** METHOD: sqlite3\n**\n** ^If the most recent sqlite3_* API call associated with \n** [database connection] D failed, then the sqlite3_errcode(D) interface\n** returns the numeric [result code] or [extended result code] for that\n** API call.\n** If the most recent API call was successful,\n** then the return value from sqlite3_errcode() is undefined.\n** ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nSQLITE_API int sqlite3_errcode(sqlite3 *db);\nSQLITE_API int sqlite3_extended_errcode(sqlite3 *db);\nSQLITE_API const char *sqlite3_errmsg(sqlite3*);\nSQLITE_API const void *sqlite3_errmsg16(sqlite3*);\nSQLITE_API const char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: Prepared Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement that\n** has been compiled into binary form and is ready to be evaluated.\n**\n** Think of each SQL statement as a separate computer program.  The\n** original SQL text is source code.  A prepared statement object \n** is the compiled object code.  All SQL must be converted into a\n** prepared statement before it can be run.\n**\n** The life-cycle of a prepared statement object usually goes like this:\n**\n** <ol>\n** <li> Create the prepared statement object using [sqlite3_prepare_v2()].\n** <li> Bind values to [parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the prepared statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n** METHOD: sqlite3\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nSQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or\n** the equivalent tries to allocate space for more than this many opcodes\n** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n**\n** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>\n** <dd>The maximum number of auxiliary worker threads that a single\n** [prepared statement] may start.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n#define SQLITE_LIMIT_WORKER_THREADS           11\n\n/*\n** CAPI3REF: Prepare Flags\n**\n** These constants define various flags that can be passed into\n** \"prepFlags\" parameter of the [sqlite3_prepare_v3()] and\n** [sqlite3_prepare16_v3()] interfaces.\n**\n** New flags may be added in future releases of SQLite.\n**\n** <dl>\n** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>\n** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner\n** that the prepared statement will be retained for a long time and\n** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]\n** and [sqlite3_prepare16_v3()] assume that the prepared statement will \n** be used just once or at most a few times and then destroyed using\n** [sqlite3_finalize()] relatively soon. The current implementation acts\n** on this hint by avoiding the use of [lookaside memory] so as not to\n** deplete the limited store of lookaside memory. Future versions of\n** SQLite may act on this hint differently.\n** </dl>\n*/\n#define SQLITE_PREPARE_PERSISTENT              0x01\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_stmt\n**\n** To execute an SQL statement, it must first be compiled into a byte-code\n** program using one of these routines.  Or, in other words, these routines\n** are constructors for the [prepared statement] object.\n**\n** The preferred routine to use is [sqlite3_prepare_v2()].  The\n** [sqlite3_prepare()] interface is legacy and should be avoided.\n** [sqlite3_prepare_v3()] has an extra \"prepFlags\" option that is used\n** for special purposes.\n**\n** The use of the UTF-8 interfaces is preferred, as SQLite currently\n** does all parsing using UTF-8.  The UTF-16 interfaces are provided\n** as a convenience.  The UTF-16 interfaces work by converting the\n** input text into UTF-8, then invoking the corresponding UTF-8 interface.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare(), sqlite3_prepare_v2(),\n** and sqlite3_prepare_v3()\n** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() use UTF-16.\n**\n** ^If the nByte argument is negative, then zSql is read up to the\n** first zero terminator. ^If nByte is positive, then it is the\n** number of bytes read from zSql.  ^If nByte is zero, then no prepared\n** statement is generated.\n** If the caller knows that the supplied string is nul-terminated, then\n** there is a small performance advantage to passing an nByte parameter that\n** is the number of bytes in the input string <i>including</i>\n** the nul-terminator.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.\n** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())\n** are retained for backwards compatibility, but their use is discouraged.\n** ^In the \"vX\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** </li>\n**\n** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having\n** the extra prepFlags parameter, which is a bit array consisting of zero or\n** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The\n** sqlite3_prepare_v2() interface works exactly the same as\n** sqlite3_prepare_v3() with a zero prepFlags parameter.\n** </ol>\n*/\nSQLITE_API int sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare_v3(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nSQLITE_API int sqlite3_prepare16_v3(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8\n** SQL text used to create [prepared statement] P if P was\n** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8\n** string containing the SQL text of prepared statement P with\n** [bound parameters] expanded.\n**\n** ^(For example, if a prepared statement is created using the SQL\n** text \"SELECT $abc,:xyz\" and if parameter $abc is bound to integer 2345\n** and parameter :xyz is unbound, then sqlite3_sql() will return\n** the original string, \"SELECT $abc,:xyz\" but sqlite3_expanded_sql()\n** will return \"SELECT 2345,NULL\".)^\n**\n** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory\n** is available to hold the result, or if the result would exceed the\n** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].\n**\n** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of\n** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time\n** option causes sqlite3_expanded_sql() to always return NULL.\n**\n** ^The string returned by sqlite3_sql(P) is managed by SQLite and is\n** automatically freed when the prepared statement is finalized.\n** ^The string returned by sqlite3_expanded_sql(P), on the other hand,\n** is obtained from [sqlite3_malloc()] and must be free by the application\n** by passing it to [sqlite3_free()].\n*/\nSQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);\nSQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since\n** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and\n** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so\n** sqlite3_stmt_readonly() returns false for those commands.\n*/\nSQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has neither run to completion (returned\n** [SQLITE_DONE] from [sqlite3_step(S)]) nor\n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nSQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.  The\n** [sqlite3_value_dup()] interface can be used to construct a new \n** protected sqlite3_value from an unprotected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used as arguments\n** to [sqlite3_result_value()], [sqlite3_bind_value()], and\n** [sqlite3_value_dup()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct sqlite3_value sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n** METHOD: sqlite3_stmt\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() or sqlite3_bind_text64() then\n** that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to the BLOB and string binding interfaces\n** is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to bind API fails.\n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sixth argument to sqlite3_bind_text64() must be one of\n** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]\n** to specify the encoding of the text in the third parameter.  If\n** the sixth argument to sqlite3_bind_text64() is not one of the\n** allowed values shown above, or if the text encoding is different\n** from the encoding specified by the sixth parameter, then the behavior\n** is undefined.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in\n** [prepared statement] S to have an SQL value of NULL, but to also be\n** associated with the pointer P of type T.  ^D is either a NULL pointer or\n** a pointer to a destructor function for P. ^SQLite will invoke the\n** destructor D with a single argument of P when it is finished using\n** P.  The T parameter should be a static string, preferably a string\n** literal. The sqlite3_bind_pointer() routine is part of the\n** [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB\n** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or\n** [SQLITE_MAX_LENGTH].\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nSQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,\n                        void(*)(void*));\nSQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);\nSQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);\nSQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nSQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);\nSQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));\nSQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nSQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,\n                         void(*)(void*), unsigned char encoding);\nSQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nSQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));\nSQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\nSQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n** METHOD: sqlite3_stmt\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nSQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n** METHOD: sqlite3_stmt\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or\n** [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_name()].\n*/\nSQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nSQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^If this routine returns 0, that means the \n** [prepared statement] returns no data (for example an [UPDATE]).\n** ^However, just because this routine returns a positive number does not\n** mean that one or more rows of data will be returned.  ^A SELECT statement\n** will always have a positive sqlite3_column_count() but depending on the\n** WHERE clause constraints and the table content, it might return no rows.\n**\n** See also: [sqlite3_data_count()]\n*/\nSQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nSQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);\nSQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nSQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nSQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nSQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);\nSQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n** METHOD: sqlite3_stmt\n**\n** After a [prepared statement] has been prepared using any of\n** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],\n** or [sqlite3_prepare16_v3()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"vX\" interfaces\n** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],\n** [sqlite3_prepare16_v2()] or the older legacy\n** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"vX\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],\n** sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]\n** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"vX\" interfaces is recommended.\n*/\nSQLITE_API int sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nSQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n** METHOD: sqlite3_stmt\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result\n** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result\n** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result\n** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result\n** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result\n** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result\n** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an \n** [sqlite3_value|unprotected sqlite3_value] object.\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT result in bytes\n** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default\n** datatype of the result\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)\n** each return the value of a result column in a specific data format.  If\n** the result column is not initially in the requested format (for example,\n** if the query returns an integer but the sqlite3_column_text() interface\n** is used to extract the value) then an automatic type conversion is performed.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].\n** The return value of sqlite3_column_type() can be used to decide which\n** of the first six interface should be used to extract the column value.\n** The value returned by sqlite3_column_type() is only meaningful if no\n** automatic type conversions have occurred for the value in question.  \n** After a type conversion, the result of calling sqlite3_column_type()\n** is undefined, though harmless.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()\n** or sqlite3_column_bytes16() interfaces can be used to determine the size\n** of that BLOB or string.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  In a multithreaded environment,\n** an unprotected sqlite3_value object may only be used safely with\n** [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], the behavior is not threadsafe.\n** Hence, the sqlite3_column_value() interface\n** is normally only useful within the implementation of \n** [application-defined SQL functions] or [virtual tables], not within\n** top-level application code.\n**\n** The these routines may attempt to convert the datatype of the result.\n** ^For example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB\n** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do not pass the pointers returned\n** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** ^(If a memory allocation error occurs during the evaluation of any\n** of these routines, a default value is returned.  The default value\n** is either the integer 0, the floating point number 0.0, or a NULL\n** pointer.  Subsequent calls to [sqlite3_errcode()] will return\n** [SQLITE_NOMEM].)^\n*/\nSQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\nSQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nSQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nSQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nSQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nSQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n** DESTRUCTOR: sqlite3_stmt\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nSQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n** METHOD: sqlite3_stmt\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nSQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n** METHOD: sqlite3\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates.  The only differences between\n** these routines are the text encoding expected for\n** the second parameter (the name of the function being created)\n** and the presence or absence of a destructor callback for\n** the application data pointer.\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  The application should set this parameter to\n** [SQLITE_UTF16LE] if the function implementation invokes \n** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the\n** implementation invokes [sqlite3_value_text16be()] on an input, or\n** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]\n** otherwise.  ^The same SQL function may be registered multiple times using\n** different preferred text encodings, with different implementations for\n** each encoding.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n**\n** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]\n** to signal that the function will always return the same result given\n** the same inputs within a single SQL statement.  Most SQL functions are\n** deterministic.  The built-in [random()] SQL function is an example of a\n** function that is not deterministic.  The SQLite query planner is able to\n** perform additional optimizations on deterministic functions, so use\n** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,\n** then it is destructor for the application data pointer. \n** The destructor is invoked when the function is deleted, either by being\n** overloaded or when the database connection closes.)^\n** ^The destructor is also invoked if the call to\n** sqlite3_create_function_v2() fails.\n** ^When the destructor callback of the tenth parameter is invoked, it\n** is passed a single argument which is a copy of the application data \n** pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nSQLITE_API int sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nSQLITE_API int sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */\n#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */\n#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* Deprecated */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Function Flags\n**\n** These constants may be ORed together with the \n** [SQLITE_UTF8 | preferred text encoding] as the fourth argument\n** to [sqlite3_create_function()], [sqlite3_create_function16()], or\n** [sqlite3_create_function_v2()].\n*/\n#define SQLITE_DETERMINISTIC    0x800\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To encourage programmers to avoid\n** these functions, we will not explain what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Values\n** METHOD: sqlite3_value\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value\n** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value\n** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value\n** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value\n** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value\n** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value\n** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in\n** the native byteorder\n** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value\n** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT in bytes\n** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default\n** datatype of the value\n** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** These routines extract type, size, and content information from\n** [protected sqlite3_value] objects.  Protected sqlite3_value objects\n** are used to pass parameter information into implementation of\n** [application-defined SQL functions] and [virtual tables].\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** is not threadsafe.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^If [sqlite3_value] object V was initialized \n** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]\n** and if X and Y are strings that compare equal according to strcmp(X,Y),\n** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,\n** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() \n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^(The sqlite3_value_type(V) interface returns the\n** [SQLITE_INTEGER | datatype code] for the initial datatype of the\n** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^\n** Other interfaces might change the datatype for an sqlite3_value object.\n** For example, if the datatype is initially SQLITE_INTEGER and\n** sqlite3_value_text(V) is called to extract a text value for that\n** integer, then subsequent calls to sqlite3_value_type(V) might return\n** SQLITE_TEXT.  Whether or not a persistent internal datatype conversion\n** occurs is undefined and may change from one release of SQLite to the next.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n*/\nSQLITE_API const void *sqlite3_value_blob(sqlite3_value*);\nSQLITE_API double sqlite3_value_double(sqlite3_value*);\nSQLITE_API int sqlite3_value_int(sqlite3_value*);\nSQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nSQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);\nSQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);\nSQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes(sqlite3_value*);\nSQLITE_API int sqlite3_value_bytes16(sqlite3_value*);\nSQLITE_API int sqlite3_value_type(sqlite3_value*);\nSQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);\n\n/*\n** CAPI3REF: Finding The Subtype Of SQL Values\n** METHOD: sqlite3_value\n**\n** The sqlite3_value_subtype(V) function returns the subtype for\n** an [application-defined SQL function] argument V.  The subtype\n** information can be used to pass a limited amount of context from\n** one SQL function to another.  Use the [sqlite3_result_subtype()]\n** routine to set the subtype for the return value of an SQL function.\n*/\nSQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);\n\n/*\n** CAPI3REF: Copy And Free SQL Values\n** METHOD: sqlite3_value\n**\n** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]\n** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned\n** is a [protected sqlite3_value] object even if the input is not.\n** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a\n** memory allocation fails.\n**\n** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object\n** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer\n** then sqlite3_value_free(V) is a harmless no-op.\n*/\nSQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value*);\nSQLITE_API void sqlite3_value_free(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n** METHOD: sqlite3_context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nSQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nSQLITE_API void *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nSQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n** METHOD: sqlite3_context\n**\n** These functions may be used by (non-aggregate) SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved.  An example\n** of where this might be useful is in a regular-expression matching\n** function. The compiled version of the regular expression can be stored as\n** metadata associated with the pattern string.  \n** Then as long as the pattern string remains the same,\n** the compiled regular expression can be reused on multiple\n** invocations of the same function.\n**\n** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument\n** value to the application-defined function.  ^N is zero for the left-most\n** function argument.  ^If there is no metadata\n** associated with the function argument, the sqlite3_get_auxdata(C,N) interface\n** returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th\n** argument of the application-defined function.  ^Subsequent\n** calls to sqlite3_get_auxdata(C,N) return P from the most recent\n** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or\n** NULL if the metadata has been discarded.\n** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,\n** SQLite will invoke the destructor function X with parameter P exactly\n** once, when the metadata is discarded.\n** SQLite is free to discard the metadata at any time, including: <ul>\n** <li> ^(when the corresponding function parameter changes)^, or\n** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the\n**      SQL statement)^, or\n** <li> ^(when sqlite3_set_auxdata() is invoked again on the same\n**       parameter)^, or\n** <li> ^(during the original sqlite3_set_auxdata() call when a memory \n**      allocation error occurs.)^ </ul>\n**\n** Note the last bullet in particular.  The destructor X in \n** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the\n** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()\n** should be called near the end of the function implementation and the\n** function implementation should not make any use of P after\n** sqlite3_set_auxdata() has been called.\n**\n** ^(In practice, metadata is preserved between function calls for\n** function parameters that are compile-time constants, including literal\n** values and [parameters] and expressions composed from the same.)^\n**\n** The value of the N parameter to these interfaces should be non-negative.\n** Future enhancements may make use of negative N values to define new\n** kinds of function caching behavior.\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nSQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);\nSQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n** METHOD: sqlite3_context\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)\n** interfaces set the result of the application-defined function to be\n** a BLOB containing all zero bytes and N bytes in size.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^The sqlite3_result_text64() interface sets the return value of an\n** application-defined function to be a text string in an encoding\n** specified by the fifth (and last) parameter, which must be one\n** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy of the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an\n** SQL NULL value, just like [sqlite3_result_null(C)], except that it\n** also associates the host-language pointer P or type T with that \n** NULL value such that the pointer can be retrieved within an\n** [application-defined SQL function] using [sqlite3_value_pointer()].\n** ^If the D parameter is not NULL, then it is a pointer to a destructor\n** for the P parameter.  ^SQLite invokes D with P as its only argument\n** when SQLite is finished with P.  The T parameter should be a static\n** string and preferably a string literal. The sqlite3_result_pointer()\n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nSQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,\n                           sqlite3_uint64,void(*)(void*));\nSQLITE_API void sqlite3_result_double(sqlite3_context*, double);\nSQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);\nSQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);\nSQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);\nSQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int(sqlite3_context*, int);\nSQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nSQLITE_API void sqlite3_result_null(sqlite3_context*);\nSQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,\n                           void(*)(void*), unsigned char encoding);\nSQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nSQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nSQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nSQLITE_API void sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));\nSQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);\nSQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);\n\n\n/*\n** CAPI3REF: Setting The Subtype Of An SQL Function\n** METHOD: sqlite3_context\n**\n** The sqlite3_result_subtype(C,T) function causes the subtype of\n** the result from the [application-defined SQL function] with \n** [sqlite3_context] C to be the value T.  Only the lower 8 bits \n** of the subtype T are preserved in current versions of SQLite;\n** higher order bits are discarded.\n** The number of subtype bytes preserved by SQLite might increase\n** in future releases of SQLite.\n*/\nSQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n** METHOD: sqlite3\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nSQLITE_API int sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nSQLITE_API int sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nSQLITE_API int sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n** METHOD: sqlite3\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nSQLITE_API int sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nSQLITE_API int sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\nSQLITE_API int sqlite3_key_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nSQLITE_API int sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\nSQLITE_API int sqlite3_rekey_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nSQLITE_API void sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nSQLITE_API void sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nSQLITE_API int sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** Applications are strongly discouraged from using this global variable.\n** It is required to set a temporary folder on Windows Runtime (WinRT).\n** But for all other platforms, it is highly recommended that applications\n** neither read nor write this variable.  This global variable is a relic\n** that exists for backwards compatibility of legacy applications and should\n** be avoided in new projects.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n** Except when requested by the [temp_store_directory pragma], SQLite\n** does not free the memory that sqlite3_temp_directory points to.  If\n** the application wants that memory to be freed, it must do\n** so itself, taking care to only do so after all [database connection]\n** objects have been destroyed.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n** METHOD: sqlite3\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nSQLITE_API int sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nSQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nSQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nSQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nSQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nSQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nSQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted in\n** a [rowid table].\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted in a rowid table.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.\n**\n** ^In the current implementation, the update hook\n** is not invoked when conflicting rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],\n** and [sqlite3_preupdate_hook()] interfaces.\n*/\nSQLITE_API void *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). \n** In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0\n** and will always return SQLITE_MISUSE. On those systems, \n** shared cache mode should be enabled per-database connection via \n** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nSQLITE_API int sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nSQLITE_API int sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is in effect even\n** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nSQLITE_API int sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), \n** the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nSQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n** METHOD: sqlite3\n**\n** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns\n** information about column C of table T in database D\n** on [database connection] X.)^  ^The sqlite3_table_column_metadata()\n** interface returns SQLITE_OK and fills in the non-NULL pointers in\n** the final five arguments with appropriate values if the specified\n** column exists.  ^The sqlite3_table_column_metadata() interface returns\n** SQLITE_ERROR and if the specified column does not exist.\n** ^If the column-name parameter to sqlite3_table_column_metadata() is a\n** NULL pointer, then this routine simply checks for the existence of the\n** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it\n** does not.  If the table name parameter T in a call to\n** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is\n** undefined behavior.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^(The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL.)^ ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and the table \n** is not a [WITHOUT ROWID] table and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** [INTEGER PRIMARY KEY] column, then the outputs\n** for the [rowid] are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^This function causes all database schemas to be read from disk and\n** parsed, if that has not already been done, and returns an error if\n** any errors are encountered while loading the schema.\n*/\nSQLITE_API int sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n** METHOD: sqlite3\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] or\n** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)\n** prior to calling this API,\n** otherwise an error will be returned.\n**\n** <b>Security warning:</b> It is recommended that the \n** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this\n** interface.  The use of the [sqlite3_enable_load_extension()] interface\n** should be avoided.  This will keep the SQL function [load_extension()]\n** disabled and prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n**\n** See also the [load_extension() SQL function].\n*/\nSQLITE_API int sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n** METHOD: sqlite3\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n**\n** ^This interface enables or disables both the C-API\n** [sqlite3_load_extension()] and the SQL function [load_extension()].\n** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)\n** to enable or disable only the C-API.)^\n**\n** <b>Security warning:</b> It is recommended that extension loading\n** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method\n** rather than this interface, so the [load_extension()] SQL function\n** remains disabled. This will prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n*/\nSQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects an integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()]\n** and [sqlite3_cancel_auto_extension()]\n*/\nSQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Cancel Automatic Extension Loading\n**\n** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the\n** initialization routine X that was registered using a prior call to\n** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]\n** routine returns 1 if initialization routine X was successfully \n** unregistered and it returns 0 if X was not on the list of initialization\n** routines.\n*/\nSQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nSQLITE_API void sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The colUsed field indicates which columns of the virtual table may be\n** required by the current scan. Virtual table columns are numbered from\n** zero in the order in which they appear within the CREATE TABLE statement\n** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),\n** the corresponding bit is set within the colUsed mask if the column may be\n** required by SQLite. If the table has at least 64 columns and any column\n** to the right of the first 63 is required, then bit 63 of colUsed is also\n** set. In other words, column iCol may be required if the expression\n** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to \n** non-zero.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of a particular\n** strategy. A cost of N indicates that the cost of the strategy is similar\n** to a linear scan of an SQLite table with N rows. A cost of log(N) \n** indicates that the expense of the operation is similar to that of a\n** binary search on a unique indexed field of an SQLite table with N rows.\n**\n** ^The estimatedRows value is an estimate of the number of rows that\n** will be returned by the strategy.\n**\n** The xBestIndex method may optionally populate the idxFlags field with a \n** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -\n** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite\n** assumes that the strategy may visit at most one row. \n**\n** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then\n** SQLite also assumes that if a call to the xUpdate() method is made as\n** part of the same statement to delete or update a virtual table row and the\n** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback\n** any database changes. In other words, if the xUpdate() returns\n** SQLITE_CONSTRAINT, the database contents must be exactly as they were\n** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not\n** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by\n** the xUpdate method are automatically rolled back by SQLite.\n**\n** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info\n** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). \n** If a virtual table extension is\n** used with an SQLite version earlier than 3.8.2, the results of attempting \n** to read or write the estimatedRows field are undefined (but are likely \n** to included crashing the application). The estimatedRows field should\n** therefore only be used if [sqlite3_libversion_number()] returns a\n** value greater than or equal to 3008002. Similarly, the idxFlags field\n** was added for [version 3.9.0] ([dateof:3.9.0]). \n** It may therefore only be used if\n** sqlite3_libversion_number() returns a value greater than or equal to\n** 3009000.\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column constrained.  -1 for ROWID */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;           /* Estimated cost of using this index */\n  /* Fields below are only available in SQLite 3.8.2 and later */\n  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */\n  /* Fields below are only available in SQLite 3.9.0 and later */\n  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */\n  /* Fields below are only available in SQLite 3.10.0 and later */\n  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */\n};\n\n/*\n** CAPI3REF: Virtual Table Scan Flags\n*/\n#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ         2\n#define SQLITE_INDEX_CONSTRAINT_GT         4\n#define SQLITE_INDEX_CONSTRAINT_LE         8\n#define SQLITE_INDEX_CONSTRAINT_LT        16\n#define SQLITE_INDEX_CONSTRAINT_GE        32\n#define SQLITE_INDEX_CONSTRAINT_MATCH     64\n#define SQLITE_INDEX_CONSTRAINT_LIKE      65\n#define SQLITE_INDEX_CONSTRAINT_GLOB      66\n#define SQLITE_INDEX_CONSTRAINT_REGEXP    67\n#define SQLITE_INDEX_CONSTRAINT_NE        68\n#define SQLITE_INDEX_CONSTRAINT_ISNOT     69\n#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70\n#define SQLITE_INDEX_CONSTRAINT_ISNULL    71\n#define SQLITE_INDEX_CONSTRAINT_IS        72\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n** METHOD: sqlite3\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nSQLITE_API int sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nSQLITE_API int sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* Number of open cursors */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nSQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n** METHOD: sqlite3\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nSQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_blob\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^(Parameter zDb is not the filename that contains the database, but \n** rather the symbolic name of the database. For attached databases, this is\n** the name that appears after the AS keyword in the [ATTACH] statement.\n** For the main database file, the database name is \"main\". For TEMP\n** tables, the database name is \"temp\".)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If the flags parameter is zero, the BLOB is opened for\n** read-only access.\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored\n** in *ppBlob. Otherwise an [error code] is returned and, unless the error\n** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided\n** the API is not misused, it is always safe to call [sqlite3_blob_close()] \n** on *ppBlob after this function it returns.\n**\n** This function fails with SQLITE_ERROR if any of the following are true:\n** <ul>\n**   <li> ^(Database zDb does not exist)^, \n**   <li> ^(Table zTable does not exist within database zDb)^, \n**   <li> ^(Table zTable is a WITHOUT ROWID table)^, \n**   <li> ^(Column zColumn does not exist)^,\n**   <li> ^(Row iRow is not present in the table)^,\n**   <li> ^(The specified column of row iRow contains a value that is not\n**         a TEXT or BLOB value)^,\n**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE \n**         constraint and the blob is being opened for read/write access)^,\n**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, \n**         column zColumn is part of a [child key] definition and the blob is\n**         being opened for read/write access)^.\n** </ul>\n**\n** ^Unless it returns SQLITE_MISUSE, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** A BLOB referenced by sqlite3_blob_open() may be read using the\n** [sqlite3_blob_read()] interface and modified by using\n** [sqlite3_blob_write()].  The [BLOB handle] can be moved to a\n** different row of the same table using the [sqlite3_blob_reopen()]\n** interface.  However, the column, table, or database of a [BLOB handle]\n** cannot be changed after the [BLOB handle] is opened.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function may be used to create a \n** zero-filled blob to read or write using the incremental-blob interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n**\n** See also: [sqlite3_blob_close()],\n** [sqlite3_blob_reopen()], [sqlite3_blob_read()],\n** [sqlite3_blob_bytes()], [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n** METHOD: sqlite3_blob\n**\n** ^This function is used to move an existing [BLOB handle] so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing [BLOB handle] to a new row is\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nSQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n** DESTRUCTOR: sqlite3_blob\n**\n** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed\n** unconditionally.  Even if this routine returns an error code, the \n** handle is still closed.)^\n**\n** ^If the blob handle being closed was opened for read-write access, and if\n** the database is in auto-commit mode and there are no other open read-write\n** blob handles or active write statements, the current transaction is\n** committed. ^If an error occurs while committing the transaction, an error\n** code is returned and the transaction rolled back.\n**\n** Calling this function with an argument that is not a NULL pointer or an\n** open blob handle results in undefined behaviour. ^Calling this routine \n** with a null pointer (such as would be returned by a failed call to \n** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function\n** is passed a valid open blob handle, the values returned by the \n** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.\n*/\nSQLITE_API int sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n** METHOD: sqlite3_blob\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nSQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nSQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.)^\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n** ^Unless SQLITE_MISUSE is returned, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written. The size of the \n** BLOB (and hence the maximum value of N+iOffset) can be determined \n** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less \n** than zero [SQLITE_ERROR] is returned and no data is written.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nSQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nSQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nSQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nSQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>\n**\n** The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()\n** routine returns NULL if it is unable to allocate the requested\n** mutex.  The argument to sqlite3_mutex_alloc() must one of these\n** integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Nine static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^For the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  Attempting to deallocate a static\n** mutex results in undefined behavior.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases, the\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  If the same thread tries to enter any mutex other\n** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY. The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable \n** behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nSQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);\nSQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);\nSQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the application has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the application\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nSQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);\nSQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_randomness() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */\n#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */\n#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */\n#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nSQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n** METHOD: sqlite3\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  ^The SQLITE_FCNTL_FILE_POINTER\n** case is a short-circuit path which does not actually invoke the\n** underlying sqlite3_io_methods.xFileControl method.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [SQLITE_FCNTL_LOCKSTATE]\n*/\nSQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nSQLITE_API int sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */\n#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19\n#define SQLITE_TESTCTRL_NEVER_CORRUPT           20\n#define SQLITE_TESTCTRL_VDBE_COVERAGE           21\n#define SQLITE_TESTCTRL_BYTEORDER               22\n#define SQLITE_TESTCTRL_ISINIT                  23\n#define SQLITE_TESTCTRL_SORTER_MMAP             24\n#define SQLITE_TESTCTRL_IMPOSTER                25\n#define SQLITE_TESTCTRL_LAST                    25\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^These interfaces are used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() and sqlite3_status64() routines return\n** SQLITE_OK on success and a non-zero [error code] on failure.\n**\n** If either the current value or the highwater mark is too large to\n** be represented by a 32-bit integer, then the values returned by\n** sqlite3_status() are undefined.\n**\n** See also: [sqlite3_db_status()]\n*/\nSQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\nSQLITE_API int sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>The *pHighwater parameter records the deepest parser stack. \n** The *pCurrent value is undefined.  The *pHighwater value is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3  /* NOT USED */\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n** METHOD: sqlite3\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nSQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] \n** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>\n** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a\n** pager cache is shared between two or more connections the bytes of heap\n** memory used by that pager cache is divided evenly between the attached\n** connections.)^  In other words, if none of the pager caches associated\n** with the database connection are shared, this request returns the same\n** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are\n** shared, the value returned by this call will be smaller than that returned\n** by DBSTATUS_CACHE_USED. ^The highwater mark associated with\n** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>\n** <dd>This parameter returns zero for the current value if and only if\n** all foreign key constraints (deferred or immediate) have been\n** resolved.)^  ^The highwater mark is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_DEFERRED_FKS        10\n#define SQLITE_DBSTATUS_CACHE_USED_SHARED   11\n#define SQLITE_DBSTATUS_MAX                 11   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n** METHOD: sqlite3_stmt\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nSQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n**\n** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>\n** <dd>^This is the number of virtual machine operations executed\n** by the prepared statement if that number is less than or equal\n** to 2147483647.  The number of virtual machine operations can be \n** used as a proxy for the total work done by the prepared statement.\n** If the number of virtual machine operations exceeds 2147483647\n** then the value returned by this statement status code is undefined.\n**\n** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>\n** <dd>^This is the number of times that the prepare statement has been\n** automatically regenerated due to schema changes or change to \n** [bound parameters] that might affect the query plan.\n**\n** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>\n** <dd>^This is the number of times that the prepared statement has\n** been run.  A single \"run\" for the purposes of this counter is one\n** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].\n** The counter is incremented on the first [sqlite3_step()] call of each\n** cycle.\n**\n** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>\n** <dd>^This is the approximate number of bytes of heap memory\n** used to store the prepared statement.  ^This value is not actually\n** a counter, and so the resetFlg parameter to sqlite3_stmt_status()\n** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.\n** </dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n#define SQLITE_STMTSTATUS_VM_STEP           4\n#define SQLITE_STMTSTATUS_REPREPARE         5\n#define SQLITE_STMTSTATUS_RUN               6\n#define SQLITE_STMTSTATUS_MEMUSED           99\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^A call to sqlite3_backup_init() will fail, returning NULL, if \n** there is already a read or read-write transaction open on the \n** destination database.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^The sqlite3_backup_remaining() routine returns the number of pages still\n** to be backed up at the conclusion of the most recent sqlite3_backup_step().\n** ^The sqlite3_backup_pagecount() routine returns the total number of pages\n** in the source database at the conclusion of the most recent\n** sqlite3_backup_step().\n** ^(The values returned by these functions are only updated by\n** sqlite3_backup_step(). If the source database is modified in a way that\n** changes the size of the source database or the number of pages remaining,\n** those changes are not reflected in the output of sqlite3_backup_pagecount()\n** and sqlite3_backup_remaining() until after the next\n** sqlite3_backup_step().)^\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nSQLITE_API sqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nSQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);\nSQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);\nSQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n** METHOD: sqlite3\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nSQLITE_API int sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nSQLITE_API int sqlite3_stricmp(const char *, const char *);\nSQLITE_API int sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if\n** string X matches the [GLOB] pattern P.\n** ^The definition of [GLOB] pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function\n** is case sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strlike()].\n*/\nSQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: String LIKE Matching\n*\n** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if\n** string X matches the [LIKE] pattern P with escape character E.\n** ^The definition of [LIKE] pattern matching used in\n** [sqlite3_strlike(P,X,E)] is the same as for the \"X LIKE P ESCAPE E\"\n** operator in the SQL dialect understood by SQLite.  ^For \"X LIKE P\" without\n** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.\n** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case\n** insensitive - equivalent upper and lower case ASCII characters match\n** one another.\n**\n** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though\n** only ASCII characters are case folded.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strglob()].\n*/\nSQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nSQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** is invoked each time data is committed to a database in wal mode.\n**\n** ^(The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released)^, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nSQLITE_API void *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Checkpoints initiated by this mechanism are\n** [sqlite3_wal_checkpoint_v2|PASSIVE].\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nSQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to\n** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^\n**\n** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the \n** [write-ahead log] for database X on [database connection] D to be\n** transferred into the database file and for the write-ahead log to\n** be reset.  See the [checkpointing] documentation for addition\n** information.\n**\n** This interface used to be the only way to cause a checkpoint to\n** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]\n** interface was added.  This interface is retained for backwards\n** compatibility and as a convenience for applications that need to manually\n** start a callback but which do not need the full power (and corresponding\n** complication) of [sqlite3_wal_checkpoint_v2()].\n*/\nSQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint\n** operation on database X of [database connection] D in mode M.  Status\n** information is written back into integers pointed to by L and C.)^\n** ^(The M parameter must be a valid [checkpoint mode]:)^\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   ^Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish, then sync the database file if all frames \n**   in the log were checkpointed. ^The [busy-handler callback]\n**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  \n**   ^On the other hand, passive mode might leave the checkpoint unfinished\n**   if there are concurrent readers or writers.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   ^This mode blocks (it invokes the\n**   [sqlite3_busy_handler|busy-handler callback]) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. ^It then checkpoints all frames in the log file and syncs the\n**   database file. ^This mode blocks new database writers while it is pending,\n**   but new database readers are allowed to continue unimpeded.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition\n**   that after checkpointing the log file it blocks (calls the \n**   [busy-handler callback])\n**   until all readers are reading from the database file only. ^This ensures \n**   that the next writer will restart the log file from the beginning.\n**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new\n**   database writer attempts while it is pending, but does not impede readers.\n**\n** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the\n**   addition that it also truncates the log file to zero bytes just prior\n**   to a successful return.\n** </dl>\n**\n** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file or to -1 if the checkpoint could not run because\n** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not\n** NULL,then *pnCkpt is set to the total number of checkpointed frames in the\n** log file (including any that were already checkpointed before the function\n** was called) or to -1 if the checkpoint could not run due to an error or\n** because the database is not in WAL mode. ^Note that upon successful\n** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been\n** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n**\n** ^All calls obtain an exclusive \"checkpoint\" lock on the database file. ^If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the \n** exclusive \"writer\" lock on the database file. ^If the writer lock cannot be\n** obtained immediately, and a busy-handler is configured, it is invoked and\n** the writer lock retried until either the busy-handler returns 0 or the lock\n** is successfully obtained. ^The busy-handler is also invoked while waiting for\n** database readers as described above. ^If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. ^SQLITE_BUSY is returned in this case.\n**\n** ^If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases [attached] to \n** [database connection] db.  In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. ^If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned at the end. ^If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code is returned to the caller immediately. ^If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** ^If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n**\n** ^Unless it returns SQLITE_MISUSE,\n** the sqlite3_wal_checkpoint_v2() interface\n** sets the error information that is queried by\n** [sqlite3_errcode()] and [sqlite3_errmsg()].\n**\n** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface\n** from SQL.\n*/\nSQLITE_API int sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint Mode Values\n** KEYWORDS: {checkpoint mode}\n**\n** These constants define all valid values for the \"checkpoint mode\" passed\n** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.\n** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the\n** meaning of each of these checkpoint modes.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */\n#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */\n#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */\n#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nSQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nSQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Conflict resolution modes\n** KEYWORDS: {conflict resolution mode}\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status Opcodes\n** KEYWORDS: {scanstatus options}\n**\n** The following constants can be used for the T parameter to the\n** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a\n** different metric for sqlite3_stmt_scanstatus() to return.\n**\n** When the value returned to V is a string, space to hold that string is\n** managed by the prepared statement S and will be automatically freed when\n** S is finalized.\n**\n** <dl>\n** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be\n** set to the total number of times that the X-th loop has run.</dd>\n**\n** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set\n** to the total number of rows examined by all iterations of the X-th loop.</dd>\n**\n** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>\n** <dd>^The \"double\" variable pointed to by the T parameter will be set to the\n** query planner's estimate for the average number of rows output from each\n** iteration of the X-th loop.  If the query planner's estimates was accurate,\n** then this value will approximate the quotient NVISIT/NLOOP and the\n** product of this value for all prior loops with the same SELECTID will\n** be the NLOOP value for the current loop.\n**\n** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the name of the index or table\n** used for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]\n** description for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>\n** <dd>^The \"int\" variable pointed to by the T parameter will be set to the\n** \"select-id\" for the X-th loop.  The select-id identifies which query or\n** subquery the loop is part of.  The main query has a select-id of zero.\n** The select-id is the same value as is output in the first column\n** of an [EXPLAIN QUERY PLAN] query.\n** </dl>\n*/\n#define SQLITE_SCANSTAT_NLOOP    0\n#define SQLITE_SCANSTAT_NVISIT   1\n#define SQLITE_SCANSTAT_EST      2\n#define SQLITE_SCANSTAT_NAME     3\n#define SQLITE_SCANSTAT_EXPLAIN  4\n#define SQLITE_SCANSTAT_SELECTID 5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status\n** METHOD: sqlite3_stmt\n**\n** This interface returns information about the predicted and measured\n** performance for pStmt.  Advanced applications can use this\n** interface to compare the predicted and the measured performance and\n** issue warnings and/or rerun [ANALYZE] if discrepancies are found.\n**\n** Since this interface is expected to be rarely used, it is only\n** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]\n** compile-time option.\n**\n** The \"iScanStatusOp\" parameter determines which status information to return.\n** The \"iScanStatusOp\" must be one of the [scanstatus options] or the behavior\n** of this interface is undefined.\n** ^The requested measurement is written into a variable pointed to by\n** the \"pOut\" parameter.\n** Parameter \"idx\" identifies the specific loop to retrieve statistics for.\n** Loops are numbered starting from zero. ^If idx is out of range - less than\n** zero or greater than or equal to the total number of loops used to implement\n** the statement - a non-zero value is returned and the variable that pOut\n** points to is unchanged.\n**\n** ^Statistics might not be available for all loops in all statements. ^In cases\n** where there exist loops with no available statistics, this function behaves\n** as if the loop did not exist - it returns non-zero and leave the variable\n** that pOut points to unchanged.\n**\n** See also: [sqlite3_stmt_scanstatus_reset()]\n*/\nSQLITE_API int sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */\n  int idx,                  /* Index of loop to report on */\n  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */\n  void *pOut                /* Result written here */\n);     \n\n/*\n** CAPI3REF: Zero Scan-Status Counters\n** METHOD: sqlite3_stmt\n**\n** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.\n**\n** This API is only available if the library is built with pre-processor\n** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.\n*/\nSQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Flush caches to disk mid-transaction\n**\n** ^If a write-transaction is open on [database connection] D when the\n** [sqlite3_db_cacheflush(D)] interface invoked, any dirty\n** pages in the pager-cache that are not currently in use are written out \n** to disk. A dirty page may be in use if a database cursor created by an\n** active SQL statement is reading from it, or if it is page 1 of a database\n** file (page 1 is always \"in use\").  ^The [sqlite3_db_cacheflush(D)]\n** interface flushes caches for all schemas - \"main\", \"temp\", and\n** any [attached] databases.\n**\n** ^If this function needs to obtain extra database locks before dirty pages \n** can be flushed to disk, it does so. ^If those locks cannot be obtained \n** immediately and there is a busy-handler callback configured, it is invoked\n** in the usual manner. ^If the required lock still cannot be obtained, then\n** the database is skipped and an attempt made to flush any dirty pages\n** belonging to the next (if any) database. ^If any databases are skipped\n** because locks cannot be obtained, but no other error occurs, this\n** function returns SQLITE_BUSY.\n**\n** ^If any other error occurs while flushing dirty pages to disk (for\n** example an IO error or out-of-memory condition), then processing is\n** abandoned and an SQLite [error code] is returned to the caller immediately.\n**\n** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.\n**\n** ^This function does not set the database handle error code or message\n** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.\n*/\nSQLITE_API int sqlite3_db_cacheflush(sqlite3*);\n\n/*\n** CAPI3REF: The pre-update hook.\n**\n** ^These interfaces are only available if SQLite is compiled using the\n** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.\n**\n** ^The [sqlite3_preupdate_hook()] interface registers a callback function\n** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation\n** on a database table.\n** ^At most one preupdate hook may be registered at a time on a single\n** [database connection]; each call to [sqlite3_preupdate_hook()] overrides\n** the previous setting.\n** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]\n** with a NULL pointer as the second parameter.\n** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as\n** the first parameter to callbacks.\n**\n** ^The preupdate hook only fires for changes to real database tables; the\n** preupdate hook is not invoked for changes to [virtual tables] or to\n** system tables like sqlite_master or sqlite_stat1.\n**\n** ^The second parameter to the preupdate callback is a pointer to\n** the [database connection] that registered the preupdate hook.\n** ^The third parameter to the preupdate callback is one of the constants\n** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the\n** kind of update operation that is about to occur.\n** ^(The fourth parameter to the preupdate callback is the name of the\n** database within the database connection that is being modified.  This\n** will be \"main\" for the main database or \"temp\" for TEMP tables or \n** the name given after the AS keyword in the [ATTACH] statement for attached\n** databases.)^\n** ^The fifth parameter to the preupdate callback is the name of the\n** table that is being modified.\n**\n** For an UPDATE or DELETE operation on a [rowid table], the sixth\n** parameter passed to the preupdate callback is the initial [rowid] of the \n** row being modified or deleted. For an INSERT operation on a rowid table,\n** or any operation on a WITHOUT ROWID table, the value of the sixth \n** parameter is undefined. For an INSERT or UPDATE on a rowid table the\n** seventh parameter is the final rowid value of the row being inserted\n** or updated. The value of the seventh parameter passed to the callback\n** function is not defined for operations on WITHOUT ROWID tables, or for\n** INSERT operations on rowid tables.\n**\n** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],\n** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces\n** provide additional information about a preupdate event. These routines\n** may only be called from within a preupdate callback.  Invoking any of\n** these routines from outside of a preupdate callback or with a\n** [database connection] pointer that is different from the one supplied\n** to the preupdate callback results in undefined and probably undesirable\n** behavior.\n**\n** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns\n** in the row that is being inserted, updated, or deleted.\n**\n** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row before it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE\n** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row after it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE\n** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate\n** callback was invoked as a result of a direct insert, update, or delete\n** operation; or 1 for inserts, updates, or deletes invoked by top-level \n** triggers; or 2 for changes resulting from triggers called by top-level\n** triggers; and so forth.\n**\n** See also:  [sqlite3_update_hook()]\n*/\n#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)\nSQLITE_API void *sqlite3_preupdate_hook(\n  sqlite3 *db,\n  void(*xPreUpdate)(\n    void *pCtx,                   /* Copy of third arg to preupdate_hook() */\n    sqlite3 *db,                  /* Database handle */\n    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */\n    char const *zDb,              /* Database name */\n    char const *zName,            /* Table name */\n    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */\n    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */\n  ),\n  void*\n);\nSQLITE_API int sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);\nSQLITE_API int sqlite3_preupdate_count(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_depth(sqlite3 *);\nSQLITE_API int sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);\n#endif\n\n/*\n** CAPI3REF: Low-level system error code\n**\n** ^Attempt to return the underlying operating system error code or error\n** number that caused the most recent I/O error or failure to open a file.\n** The return value is OS-dependent.  For example, on unix systems, after\n** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be\n** called to get back the underlying \"errno\" that caused the problem, such\n** as ENOSPC, EAUTH, EISDIR, and so forth.  \n*/\nSQLITE_API int sqlite3_system_errno(sqlite3*);\n\n/*\n** CAPI3REF: Database Snapshot\n** KEYWORDS: {snapshot} {sqlite3_snapshot}\n** EXPERIMENTAL\n**\n** An instance of the snapshot object records the state of a [WAL mode]\n** database for some specific point in history.\n**\n** In [WAL mode], multiple [database connections] that are open on the\n** same database file can each be reading a different historical version\n** of the database file.  When a [database connection] begins a read\n** transaction, that connection sees an unchanging copy of the database\n** as it existed for the point in time when the transaction first started.\n** Subsequent changes to the database from other connections are not seen\n** by the reader until a new read transaction is started.\n**\n** The sqlite3_snapshot object records state information about an historical\n** version of the database file so that it is possible to later open a new read\n** transaction that sees that historical version of the database rather than\n** the most recent version.\n**\n** The constructor for this object is [sqlite3_snapshot_get()].  The\n** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer\n** to an historical snapshot (if possible).  The destructor for \n** sqlite3_snapshot objects is [sqlite3_snapshot_free()].\n*/\ntypedef struct sqlite3_snapshot {\n  unsigned char hidden[48];\n} sqlite3_snapshot;\n\n/*\n** CAPI3REF: Record A Database Snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a\n** new [sqlite3_snapshot] object that records the current state of\n** schema S in database connection D.  ^On success, the\n** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly\n** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.\n** If there is not already a read-transaction open on schema S when\n** this function is called, one is opened automatically. \n**\n** The following must be true for this function to succeed. If any of\n** the following statements are false when sqlite3_snapshot_get() is\n** called, SQLITE_ERROR is returned. The final value of *P is undefined\n** in this case. \n**\n** <ul>\n**   <li> The database handle must be in [autocommit mode].\n**\n**   <li> Schema S of [database connection] D must be a [WAL mode] database.\n**\n**   <li> There must not be a write transaction open on schema S of database\n**        connection D.\n**\n**   <li> One or more transactions must have been written to the current wal\n**        file since it was created on disk (by any connection). This means\n**        that a snapshot cannot be taken on a wal mode database with no wal \n**        file immediately after it is first opened. At least one transaction\n**        must be written to it first.\n** </ul>\n**\n** This function may also return SQLITE_NOMEM.  If it is called with the\n** database handle in autocommit mode but fails for some other reason, \n** whether or not a read transaction is opened on schema S is undefined.\n**\n** The [sqlite3_snapshot] object returned from a successful call to\n** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]\n** to avoid a memory leak.\n**\n** The [sqlite3_snapshot_get()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot **ppSnapshot\n);\n\n/*\n** CAPI3REF: Start a read transaction on an historical snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a\n** read transaction for schema S of\n** [database connection] D such that the read transaction\n** refers to historical [snapshot] P, rather than the most\n** recent change to the database.\n** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success\n** or an appropriate [error code] if it fails.\n**\n** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be\n** the first operation following the [BEGIN] that takes the schema S\n** out of [autocommit mode].\n** ^In other words, schema S must not currently be in\n** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the\n** database connection D must be out of [autocommit mode].\n** ^A [snapshot] will fail to open if it has been overwritten by a\n** [checkpoint].\n** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the\n** database connection D does not know that the database file for\n** schema S is in [WAL mode].  A database connection might not know\n** that the database file is in [WAL mode] if there has been no prior\n** I/O on that database connection, or if the database entered [WAL mode] \n** after the most recent I/O on the database connection.)^\n** (Hint: Run \"[PRAGMA application_id]\" against a newly opened\n** database connection in order to make it ready to use snapshots.)\n**\n** The [sqlite3_snapshot_open()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot *pSnapshot\n);\n\n/*\n** CAPI3REF: Destroy a snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.\n** The application must eventually free every [sqlite3_snapshot] object\n** using this routine to avoid a memory leak.\n**\n** The [sqlite3_snapshot_free()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);\n\n/*\n** CAPI3REF: Compare the ages of two snapshot handles.\n** EXPERIMENTAL\n**\n** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages\n** of two valid snapshot handles. \n**\n** If the two snapshot handles are not associated with the same database \n** file, the result of the comparison is undefined. \n**\n** Additionally, the result of the comparison is only valid if both of the\n** snapshot handles were obtained by calling sqlite3_snapshot_get() since the\n** last time the wal file was deleted. The wal file is deleted when the\n** database is changed back to rollback mode or when the number of database\n** clients drops to zero. If either snapshot handle was obtained before the \n** wal file was last deleted, the value returned by this function \n** is undefined.\n**\n** Otherwise, this API returns a negative value if P1 refers to an older\n** snapshot than P2, zero if the two handles refer to the same database\n** snapshot, and a positive value if P1 is a newer snapshot than P2.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(\n  sqlite3_snapshot *p1,\n  sqlite3_snapshot *p2\n);\n\n/*\n** CAPI3REF: Recover snapshots from a wal file\n** EXPERIMENTAL\n**\n** If all connections disconnect from a database file but do not perform\n** a checkpoint, the existing wal file is opened along with the database\n** file the next time the database is opened. At this point it is only\n** possible to successfully call sqlite3_snapshot_open() to open the most\n** recent snapshot of the database (the one at the head of the wal file),\n** even though the wal file may contain other valid snapshots for which\n** clients have sqlite3_snapshot handles.\n**\n** This function attempts to scan the wal file associated with database zDb\n** of database handle db and make all valid snapshots available to\n** sqlite3_snapshot_open(). It is an error if there is already a read\n** transaction open on the database, or if the database is not a wal mode\n** database.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE3_H */\n\n/******** Begin file sqlite3rtree.h *********/\n/*\n** 2010 August 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n*/\n\n#ifndef _SQLITE3RTREE_H_\n#define _SQLITE3RTREE_H_\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;\ntypedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;\n\n/* The double-precision datatype used by RTree depends on the\n** SQLITE_RTREE_INT_ONLY compile-time option.\n*/\n#ifdef SQLITE_RTREE_INT_ONLY\n  typedef sqlite3_int64 sqlite3_rtree_dbl;\n#else\n  typedef double sqlite3_rtree_dbl;\n#endif\n\n/*\n** Register a geometry callback named zGeom that can be used as part of an\n** R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_geometry_callback(\n  sqlite3 *db,\n  const char *zGeom,\n  int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),\n  void *pContext\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the first\n** argument to callbacks registered using rtree_geometry_callback().\n*/\nstruct sqlite3_rtree_geometry {\n  void *pContext;                 /* Copy of pContext passed to s_r_g_c() */\n  int nParam;                     /* Size of array aParam[] */\n  sqlite3_rtree_dbl *aParam;      /* Parameters passed to SQL geom function */\n  void *pUser;                    /* Callback implementation user data */\n  void (*xDelUser)(void *);       /* Called by SQLite to clean up pUser */\n};\n\n/*\n** Register a 2nd-generation geometry callback named zScore that can be \n** used as part of an R-Tree geometry query as follows:\n**\n**   SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)\n*/\nSQLITE_API int sqlite3_rtree_query_callback(\n  sqlite3 *db,\n  const char *zQueryFunc,\n  int (*xQueryFunc)(sqlite3_rtree_query_info*),\n  void *pContext,\n  void (*xDestructor)(void*)\n);\n\n\n/*\n** A pointer to a structure of the following type is passed as the \n** argument to scored geometry callback registered using\n** sqlite3_rtree_query_callback().\n**\n** Note that the first 5 fields of this structure are identical to\n** sqlite3_rtree_geometry.  This structure is a subclass of\n** sqlite3_rtree_geometry.\n*/\nstruct sqlite3_rtree_query_info {\n  void *pContext;                   /* pContext from when function registered */\n  int nParam;                       /* Number of function parameters */\n  sqlite3_rtree_dbl *aParam;        /* value of function parameters */\n  void *pUser;                      /* callback can use this, if desired */\n  void (*xDelUser)(void*);          /* function to free pUser */\n  sqlite3_rtree_dbl *aCoord;        /* Coordinates of node or entry to check */\n  unsigned int *anQueue;            /* Number of pending entries in the queue */\n  int nCoord;                       /* Number of coordinates */\n  int iLevel;                       /* Level of current node or entry */\n  int mxLevel;                      /* The largest iLevel value in the tree */\n  sqlite3_int64 iRowid;             /* Rowid for current entry */\n  sqlite3_rtree_dbl rParentScore;   /* Score of parent node */\n  int eParentWithin;                /* Visibility of parent node */\n  int eWithin;                      /* OUT: Visiblity */\n  sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */\n  /* The following fields are only available in 3.8.11 and later */\n  sqlite3_value **apSqlParam;       /* Original SQL values of parameters */\n};\n\n/*\n** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.\n*/\n#define NOT_WITHIN       0   /* Object completely outside of query region */\n#define PARTLY_WITHIN    1   /* Object partially overlaps query region */\n#define FULLY_WITHIN     2   /* Object fully contained within query region */\n\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif  /* ifndef _SQLITE3RTREE_H_ */\n\n/******** End of sqlite3rtree.h *********/\n/******** Begin file sqlite3session.h *********/\n\n#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)\n#define __SQLITESESSION_H_ 1\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** CAPI3REF: Session Object Handle\n*/\ntypedef struct sqlite3_session sqlite3_session;\n\n/*\n** CAPI3REF: Changeset Iterator Handle\n*/\ntypedef struct sqlite3_changeset_iter sqlite3_changeset_iter;\n\n/*\n** CAPI3REF: Create A New Session Object\n**\n** Create a new session object attached to database handle db. If successful,\n** a pointer to the new object is written to *ppSession and SQLITE_OK is\n** returned. If an error occurs, *ppSession is set to NULL and an SQLite\n** error code (e.g. SQLITE_NOMEM) is returned.\n**\n** It is possible to create multiple session objects attached to a single\n** database handle.\n**\n** Session objects created using this function should be deleted using the\n** [sqlite3session_delete()] function before the database handle that they\n** are attached to is itself closed. If the database handle is closed before\n** the session object is deleted, then the results of calling any session\n** module function, including [sqlite3session_delete()] on the session object\n** are undefined.\n**\n** Because the session module uses the [sqlite3_preupdate_hook()] API, it\n** is not possible for an application to register a pre-update hook on a\n** database handle that has one or more session objects attached. Nor is\n** it possible to create a session object attached to a database handle for\n** which a pre-update hook is already defined. The results of attempting \n** either of these things are undefined.\n**\n** The session object will be used to create changesets for tables in\n** database zDb, where zDb is either \"main\", or \"temp\", or the name of an\n** attached database. It is not an error if database zDb is not attached\n** to the database when the session object is created.\n*/\nSQLITE_API int sqlite3session_create(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of db (e.g. \"main\") */\n  sqlite3_session **ppSession     /* OUT: New session object */\n);\n\n/*\n** CAPI3REF: Delete A Session Object\n**\n** Delete a session object previously allocated using \n** [sqlite3session_create()]. Once a session object has been deleted, the\n** results of attempting to use pSession with any other session module\n** function are undefined.\n**\n** Session objects must be deleted before the database handle to which they\n** are attached is closed. Refer to the documentation for \n** [sqlite3session_create()] for details.\n*/\nSQLITE_API void sqlite3session_delete(sqlite3_session *pSession);\n\n\n/*\n** CAPI3REF: Enable Or Disable A Session Object\n**\n** Enable or disable the recording of changes by a session object. When\n** enabled, a session object records changes made to the database. When\n** disabled - it does not. A newly created session object is enabled.\n** Refer to the documentation for [sqlite3session_changeset()] for further\n** details regarding how enabling and disabling a session object affects\n** the eventual changesets.\n**\n** Passing zero to this function disables the session. Passing a value\n** greater than zero enables it. Passing a value less than zero is a \n** no-op, and may be used to query the current state of the session.\n**\n** The return value indicates the final state of the session object: 0 if \n** the session is disabled, or 1 if it is enabled.\n*/\nSQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable);\n\n/*\n** CAPI3REF: Set Or Clear the Indirect Change Flag\n**\n** Each change recorded by a session object is marked as either direct or\n** indirect. A change is marked as indirect if either:\n**\n** <ul>\n**   <li> The session object \"indirect\" flag is set when the change is\n**        made, or\n**   <li> The change is made by an SQL trigger or foreign key action \n**        instead of directly as a result of a users SQL statement.\n** </ul>\n**\n** If a single row is affected by more than one operation within a session,\n** then the change is considered indirect if all operations meet the criteria\n** for an indirect change above, or direct otherwise.\n**\n** This function is used to set, clear or query the session object indirect\n** flag.  If the second argument passed to this function is zero, then the\n** indirect flag is cleared. If it is greater than zero, the indirect flag\n** is set. Passing a value less than zero does not modify the current value\n** of the indirect flag, and may be used to query the current state of the \n** indirect flag for the specified session object.\n**\n** The return value indicates the final state of the indirect flag: 0 if \n** it is clear, or 1 if it is set.\n*/\nSQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);\n\n/*\n** CAPI3REF: Attach A Table To A Session Object\n**\n** If argument zTab is not NULL, then it is the name of a table to attach\n** to the session object passed as the first argument. All subsequent changes \n** made to the table while the session object is enabled will be recorded. See \n** documentation for [sqlite3session_changeset()] for further details.\n**\n** Or, if argument zTab is NULL, then changes are recorded for all tables\n** in the database. If additional tables are added to the database (by \n** executing \"CREATE TABLE\" statements) after this call is made, changes for \n** the new tables are also recorded.\n**\n** Changes can only be recorded for tables that have a PRIMARY KEY explicitly\n** defined as part of their CREATE TABLE statement. It does not matter if the \n** PRIMARY KEY is an \"INTEGER PRIMARY KEY\" (rowid alias) or not. The PRIMARY\n** KEY may consist of a single column, or may be a composite key.\n** \n** It is not an error if the named table does not exist in the database. Nor\n** is it an error if the named table does not have a PRIMARY KEY. However,\n** no changes will be recorded in either of these scenarios.\n**\n** Changes are not recorded for individual rows that have NULL values stored\n** in one or more of their PRIMARY KEY columns.\n**\n** SQLITE_OK is returned if the call completes without error. Or, if an error \n** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.\n*/\nSQLITE_API int sqlite3session_attach(\n  sqlite3_session *pSession,      /* Session object */\n  const char *zTab                /* Table name */\n);\n\n/*\n** CAPI3REF: Set a table filter on a Session Object.\n**\n** The second argument (xFilter) is the \"filter callback\". For changes to rows \n** in tables that are not attached to the Session object, the filter is called\n** to determine whether changes to the table's rows should be tracked or not. \n** If xFilter returns 0, changes is not tracked. Note that once a table is \n** attached, xFilter will not be called again.\n*/\nSQLITE_API void sqlite3session_table_filter(\n  sqlite3_session *pSession,      /* Session object */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of third arg to _filter_table() */\n    const char *zTab              /* Table name */\n  ),\n  void *pCtx                      /* First argument passed to xFilter */\n);\n\n/*\n** CAPI3REF: Generate A Changeset From A Session Object\n**\n** Obtain a changeset containing changes to the tables attached to the \n** session object passed as the first argument. If successful, \n** set *ppChangeset to point to a buffer containing the changeset \n** and *pnChangeset to the size of the changeset in bytes before returning\n** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to\n** zero and return an SQLite error code.\n**\n** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,\n** each representing a change to a single row of an attached table. An INSERT\n** change contains the values of each field of a new database row. A DELETE\n** contains the original values of each field of a deleted database row. An\n** UPDATE change contains the original values of each field of an updated\n** database row along with the updated values for each updated non-primary-key\n** column. It is not possible for an UPDATE change to represent a change that\n** modifies the values of primary key columns. If such a change is made, it\n** is represented in a changeset as a DELETE followed by an INSERT.\n**\n** Changes are not recorded for rows that have NULL values stored in one or \n** more of their PRIMARY KEY columns. If such a row is inserted or deleted,\n** no corresponding change is present in the changesets returned by this\n** function. If an existing row with one or more NULL values stored in\n** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,\n** only an INSERT is appears in the changeset. Similarly, if an existing row\n** with non-NULL PRIMARY KEY values is updated so that one or more of its\n** PRIMARY KEY columns are set to NULL, the resulting changeset contains a\n** DELETE change only.\n**\n** The contents of a changeset may be traversed using an iterator created\n** using the [sqlite3changeset_start()] API. A changeset may be applied to\n** a database with a compatible schema using the [sqlite3changeset_apply()]\n** API.\n**\n** Within a changeset generated by this function, all changes related to a\n** single table are grouped together. In other words, when iterating through\n** a changeset or when applying a changeset to a database, all changes related\n** to a single table are processed before moving on to the next table. Tables\n** are sorted in the same order in which they were attached (or auto-attached)\n** to the sqlite3_session object. The order in which the changes related to\n** a single table are stored is undefined.\n**\n** Following a successful call to this function, it is the responsibility of\n** the caller to eventually free the buffer that *ppChangeset points to using\n** [sqlite3_free()].\n**\n** <h3>Changeset Generation</h3>\n**\n** Once a table has been attached to a session object, the session object\n** records the primary key values of all new rows inserted into the table.\n** It also records the original primary key and other column values of any\n** deleted or updated rows. For each unique primary key value, data is only\n** recorded once - the first time a row with said primary key is inserted,\n** updated or deleted in the lifetime of the session.\n**\n** There is one exception to the previous paragraph: when a row is inserted,\n** updated or deleted, if one or more of its primary key columns contain a\n** NULL value, no record of the change is made.\n**\n** The session object therefore accumulates two types of records - those\n** that consist of primary key values only (created when the user inserts\n** a new record) and those that consist of the primary key values and the\n** original values of other table columns (created when the users deletes\n** or updates a record).\n**\n** When this function is called, the requested changeset is created using\n** both the accumulated records and the current contents of the database\n** file. Specifically:\n**\n** <ul>\n**   <li> For each record generated by an insert, the database is queried\n**        for a row with a matching primary key. If one is found, an INSERT\n**        change is added to the changeset. If no such row is found, no change \n**        is added to the changeset.\n**\n**   <li> For each record generated by an update or delete, the database is \n**        queried for a row with a matching primary key. If such a row is\n**        found and one or more of the non-primary key fields have been\n**        modified from their original values, an UPDATE change is added to \n**        the changeset. Or, if no such row is found in the table, a DELETE \n**        change is added to the changeset. If there is a row with a matching\n**        primary key in the database, but all fields contain their original\n**        values, no change is added to the changeset.\n** </ul>\n**\n** This means, amongst other things, that if a row is inserted and then later\n** deleted while a session object is active, neither the insert nor the delete\n** will be present in the changeset. Or if a row is deleted and then later a \n** row with the same primary key values inserted while a session object is\n** active, the resulting changeset will contain an UPDATE change instead of\n** a DELETE and an INSERT.\n**\n** When a session object is disabled (see the [sqlite3session_enable()] API),\n** it does not accumulate records when rows are inserted, updated or deleted.\n** This may appear to have some counter-intuitive effects if a single row\n** is written to more than once during a session. For example, if a row\n** is inserted while a session object is enabled, then later deleted while \n** the same session object is disabled, no INSERT record will appear in the\n** changeset, even though the delete took place while the session was disabled.\n** Or, if one field of a row is updated while a session is disabled, and \n** another field of the same row is updated while the session is enabled, the\n** resulting changeset will contain an UPDATE change that updates both fields.\n*/\nSQLITE_API int sqlite3session_changeset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnChangeset,               /* OUT: Size of buffer at *ppChangeset */\n  void **ppChangeset              /* OUT: Buffer containing changeset */\n);\n\n/*\n** CAPI3REF: Load The Difference Between Tables Into A Session \n**\n** If it is not already attached to the session object passed as the first\n** argument, this function attaches table zTbl in the same manner as the\n** [sqlite3session_attach()] function. If zTbl does not exist, or if it\n** does not have a primary key, this function is a no-op (but does not return\n** an error).\n**\n** Argument zFromDb must be the name of a database (\"main\", \"temp\" etc.)\n** attached to the same database handle as the session object that contains \n** a table compatible with the table attached to the session by this function.\n** A table is considered compatible if it:\n**\n** <ul>\n**   <li> Has the same name,\n**   <li> Has the same set of columns declared in the same order, and\n**   <li> Has the same PRIMARY KEY definition.\n** </ul>\n**\n** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables\n** are compatible but do not have any PRIMARY KEY columns, it is not an error\n** but no changes are added to the session object. As with other session\n** APIs, tables without PRIMARY KEYs are simply ignored.\n**\n** This function adds a set of changes to the session object that could be\n** used to update the table in database zFrom (call this the \"from-table\") \n** so that its content is the same as the table attached to the session \n** object (call this the \"to-table\"). Specifically:\n**\n** <ul>\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, an INSERT record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in the to-table but not in \n**     the from-table, a DELETE record is added to the session object.\n**\n**   <li> For each row (primary key) that exists in both tables, but features \n**     different non-PK values in each, an UPDATE record is added to the\n**     session.  \n** </ul>\n**\n** To clarify, if this function is called and then a changeset constructed\n** using [sqlite3session_changeset()], then after applying that changeset to \n** database zFrom the contents of the two compatible tables would be \n** identical.\n**\n** It an error if database zFrom does not exist or does not contain the\n** required compatible table.\n**\n** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite\n** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to free this buffer using\n** sqlite3_free().\n*/\nSQLITE_API int sqlite3session_diff(\n  sqlite3_session *pSession,\n  const char *zFromDb,\n  const char *zTbl,\n  char **pzErrMsg\n);\n\n\n/*\n** CAPI3REF: Generate A Patchset From A Session Object\n**\n** The differences between a patchset and a changeset are that:\n**\n** <ul>\n**   <li> DELETE records consist of the primary key fields only. The \n**        original values of other fields are omitted.\n**   <li> The original values of any modified fields are omitted from \n**        UPDATE records.\n** </ul>\n**\n** A patchset blob may be used with up to date versions of all \n** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(), \n** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,\n** attempting to use a patchset blob with old versions of the\n** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error. \n**\n** Because the non-primary key \"old.*\" fields are omitted, no \n** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset\n** is passed to the sqlite3changeset_apply() API. Other conflict types work\n** in the same way as for changesets.\n**\n** Changes within a patchset are ordered in the same way as for changesets\n** generated by the sqlite3session_changeset() function (i.e. all changes for\n** a single table are grouped together, tables appear in the order in which\n** they were attached to the session object).\n*/\nSQLITE_API int sqlite3session_patchset(\n  sqlite3_session *pSession,      /* Session object */\n  int *pnPatchset,                /* OUT: Size of buffer at *ppPatchset */\n  void **ppPatchset               /* OUT: Buffer containing patchset */\n);\n\n/*\n** CAPI3REF: Test if a changeset has recorded any changes.\n**\n** Return non-zero if no changes to attached tables have been recorded by \n** the session object passed as the first argument. Otherwise, if one or \n** more changes have been recorded, return zero.\n**\n** Even if this function returns zero, it is possible that calling\n** [sqlite3session_changeset()] on the session handle may still return a\n** changeset that contains no changes. This can happen when a row in \n** an attached table is modified and then later on the original values \n** are restored. However, if this function returns non-zero, then it is\n** guaranteed that a call to sqlite3session_changeset() will return a \n** changeset containing zero changes.\n*/\nSQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);\n\n/*\n** CAPI3REF: Create An Iterator To Traverse A Changeset \n**\n** Create an iterator used to iterate through the contents of a changeset.\n** If successful, *pp is set to point to the iterator handle and SQLITE_OK\n** is returned. Otherwise, if an error occurs, *pp is set to zero and an\n** SQLite error code is returned.\n**\n** The following functions can be used to advance and query a changeset \n** iterator created by this function:\n**\n** <ul>\n**   <li> [sqlite3changeset_next()]\n**   <li> [sqlite3changeset_op()]\n**   <li> [sqlite3changeset_new()]\n**   <li> [sqlite3changeset_old()]\n** </ul>\n**\n** It is the responsibility of the caller to eventually destroy the iterator\n** by passing it to [sqlite3changeset_finalize()]. The buffer containing the\n** changeset (pChangeset) must remain valid until after the iterator is\n** destroyed.\n**\n** Assuming the changeset blob was created by one of the\n** [sqlite3session_changeset()], [sqlite3changeset_concat()] or\n** [sqlite3changeset_invert()] functions, all changes within the changeset \n** that apply to a single table are grouped together. This means that when \n** an application iterates through a changeset using an iterator created by \n** this function, all changes that relate to a single table are visited \n** consecutively. There is no chance that the iterator will visit a change \n** the applies to table X, then one for table Y, and then later on visit \n** another change for table X.\n*/\nSQLITE_API int sqlite3changeset_start(\n  sqlite3_changeset_iter **pp,    /* OUT: New changeset iterator handle */\n  int nChangeset,                 /* Size of changeset blob in bytes */\n  void *pChangeset                /* Pointer to blob containing changeset */\n);\n\n\n/*\n** CAPI3REF: Advance A Changeset Iterator\n**\n** This function may only be used with iterators created by function\n** [sqlite3changeset_start()]. If it is called on an iterator passed to\n** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE\n** is returned and the call has no effect.\n**\n** Immediately after an iterator is created by sqlite3changeset_start(), it\n** does not point to any change in the changeset. Assuming the changeset\n** is not empty, the first call to this function advances the iterator to\n** point to the first change in the changeset. Each subsequent call advances\n** the iterator to point to the next change in the changeset (if any). If\n** no error occurs and the iterator points to a valid change after a call\n** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned. \n** Otherwise, if all changes in the changeset have already been visited,\n** SQLITE_DONE is returned.\n**\n** If an error occurs, an SQLite error code is returned. Possible error \n** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or \n** SQLITE_NOMEM.\n*/\nSQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Obtain The Current Operation From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this\n** is not the case, this function returns [SQLITE_MISUSE].\n**\n** If argument pzTab is not NULL, then *pzTab is set to point to a\n** nul-terminated utf-8 encoded string containing the name of the table\n** affected by the current change. The buffer remains valid until either\n** sqlite3changeset_next() is called on the iterator or until the \n** conflict-handler function returns. If pnCol is not NULL, then *pnCol is \n** set to the number of columns in the table affected by the change. If\n** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change\n** is an indirect change, or false (0) otherwise. See the documentation for\n** [sqlite3session_indirect()] for a description of direct and indirect\n** changes. Finally, if pOp is not NULL, then *pOp is set to one of \n** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the \n** type of change that the iterator currently points to.\n**\n** If no error occurs, SQLITE_OK is returned. If an error does occur, an\n** SQLite error code is returned. The values of the output variables may not\n** be trusted in this case.\n*/\nSQLITE_API int sqlite3changeset_op(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  const char **pzTab,             /* OUT: Pointer to table name */\n  int *pnCol,                     /* OUT: Number of columns in table */\n  int *pOp,                       /* OUT: SQLITE_INSERT, DELETE or UPDATE */\n  int *pbIndirect                 /* OUT: True for an 'indirect' change */\n);\n\n/*\n** CAPI3REF: Obtain The Primary Key Definition Of A Table\n**\n** For each modified table, a changeset includes the following:\n**\n** <ul>\n**   <li> The number of columns in the table, and\n**   <li> Which of those columns make up the tables PRIMARY KEY.\n** </ul>\n**\n** This function is used to find which columns comprise the PRIMARY KEY of\n** the table modified by the change that iterator pIter currently points to.\n** If successful, *pabPK is set to point to an array of nCol entries, where\n** nCol is the number of columns in the table. Elements of *pabPK are set to\n** 0x01 if the corresponding column is part of the tables primary key, or\n** 0x00 if it is not.\n**\n** If argument pnCol is not NULL, then *pnCol is set to the number of columns\n** in the table.\n**\n** If this function is called when the iterator does not point to a valid\n** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,\n** SQLITE_OK is returned and the output variables populated as described\n** above.\n*/\nSQLITE_API int sqlite3changeset_pk(\n  sqlite3_changeset_iter *pIter,  /* Iterator object */\n  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */\n  int *pnCol                      /* OUT: Number of entries in output array */\n);\n\n/*\n** CAPI3REF: Obtain old.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** original row values stored as part of the UPDATE or DELETE change and\n** returns SQLITE_OK. The name of the function comes from the fact that this \n** is similar to the \"old.*\" columns available to update or delete triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_old(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Old value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain new.* Values From A Changeset Iterator\n**\n** The pIter argument passed to this function may either be an iterator\n** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator\n** created by [sqlite3changeset_start()]. In the latter case, the most recent\n** call to [sqlite3changeset_next()] must have returned SQLITE_ROW. \n** Furthermore, it may only be called if the type of change that the iterator\n** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,\n** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the vector of \n** new row values stored as part of the UPDATE or INSERT change and\n** returns SQLITE_OK. If the change is an UPDATE and does not include\n** a new value for the requested column, *ppValue is set to NULL and \n** SQLITE_OK returned. The name of the function comes from the fact that \n** this is similar to the \"new.*\" columns available to update or delete \n** triggers.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_new(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: New value (or NULL pointer) */\n);\n\n/*\n** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator\n**\n** This function should only be used with iterator objects passed to a\n** conflict-handler callback by [sqlite3changeset_apply()] with either\n** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function\n** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue\n** is set to NULL.\n**\n** Argument iVal must be greater than or equal to 0, and less than the number\n** of columns in the table affected by the current change. Otherwise,\n** [SQLITE_RANGE] is returned and *ppValue is set to NULL.\n**\n** If successful, this function sets *ppValue to point to a protected\n** sqlite3_value object containing the iVal'th value from the \n** \"conflicting row\" associated with the current conflict-handler callback\n** and returns SQLITE_OK.\n**\n** If some other error occurs (e.g. an OOM condition), an SQLite error code\n** is returned and *ppValue is set to NULL.\n*/\nSQLITE_API int sqlite3changeset_conflict(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int iVal,                       /* Column number */\n  sqlite3_value **ppValue         /* OUT: Value from conflicting row */\n);\n\n/*\n** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations\n**\n** This function may only be called with an iterator passed to an\n** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case\n** it sets the output variable to the total number of known foreign key\n** violations in the destination database and returns SQLITE_OK.\n**\n** In all other cases this function returns SQLITE_MISUSE.\n*/\nSQLITE_API int sqlite3changeset_fk_conflicts(\n  sqlite3_changeset_iter *pIter,  /* Changeset iterator */\n  int *pnOut                      /* OUT: Number of FK violations */\n);\n\n\n/*\n** CAPI3REF: Finalize A Changeset Iterator\n**\n** This function is used to finalize an iterator allocated with\n** [sqlite3changeset_start()].\n**\n** This function should only be called on iterators created using the\n** [sqlite3changeset_start()] function. If an application calls this\n** function with an iterator passed to a conflict-handler by\n** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the\n** call has no effect.\n**\n** If an error was encountered within a call to an sqlite3changeset_xxx()\n** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an \n** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding\n** to that error is returned by this function. Otherwise, SQLITE_OK is\n** returned. This is to allow the following pattern (pseudo-code):\n**\n**   sqlite3changeset_start();\n**   while( SQLITE_ROW==sqlite3changeset_next() ){\n**     // Do something with change.\n**   }\n**   rc = sqlite3changeset_finalize();\n**   if( rc!=SQLITE_OK ){\n**     // An error has occurred \n**   }\n*/\nSQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);\n\n/*\n** CAPI3REF: Invert A Changeset\n**\n** This function is used to \"invert\" a changeset object. Applying an inverted\n** changeset to a database reverses the effects of applying the uninverted\n** changeset. Specifically:\n**\n** <ul>\n**   <li> Each DELETE change is changed to an INSERT, and\n**   <li> Each INSERT change is changed to a DELETE, and\n**   <li> For each UPDATE change, the old.* and new.* values are exchanged.\n** </ul>\n**\n** This function does not change the order in which changes appear within\n** the changeset. It merely reverses the sense of each individual change.\n**\n** If successful, a pointer to a buffer containing the inverted changeset\n** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and\n** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are\n** zeroed and an SQLite error code returned.\n**\n** It is the responsibility of the caller to eventually call sqlite3_free()\n** on the *ppOut pointer to free the buffer allocation following a successful \n** call to this function.\n**\n** WARNING/TODO: This function currently assumes that the input is a valid\n** changeset. If it is not, the results are undefined.\n*/\nSQLITE_API int sqlite3changeset_invert(\n  int nIn, const void *pIn,       /* Input changeset */\n  int *pnOut, void **ppOut        /* OUT: Inverse of input */\n);\n\n/*\n** CAPI3REF: Concatenate Two Changeset Objects\n**\n** This function is used to concatenate two changesets, A and B, into a \n** single changeset. The result is a changeset equivalent to applying\n** changeset A followed by changeset B. \n**\n** This function combines the two input changesets using an \n** sqlite3_changegroup object. Calling it produces similar results as the\n** following code fragment:\n**\n**   sqlite3_changegroup *pGrp;\n**   rc = sqlite3_changegroup_new(&pGrp);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);\n**   if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);\n**   if( rc==SQLITE_OK ){\n**     rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);\n**   }else{\n**     *ppOut = 0;\n**     *pnOut = 0;\n**   }\n**\n** Refer to the sqlite3_changegroup documentation below for details.\n*/\nSQLITE_API int sqlite3changeset_concat(\n  int nA,                         /* Number of bytes in buffer pA */\n  void *pA,                       /* Pointer to buffer containing changeset A */\n  int nB,                         /* Number of bytes in buffer pB */\n  void *pB,                       /* Pointer to buffer containing changeset B */\n  int *pnOut,                     /* OUT: Number of bytes in output changeset */\n  void **ppOut                    /* OUT: Buffer containing output changeset */\n);\n\n\n/*\n** CAPI3REF: Changegroup Handle\n*/\ntypedef struct sqlite3_changegroup sqlite3_changegroup;\n\n/*\n** CAPI3REF: Create A New Changegroup Object\n**\n** An sqlite3_changegroup object is used to combine two or more changesets\n** (or patchsets) into a single changeset (or patchset). A single changegroup\n** object may combine changesets or patchsets, but not both. The output is\n** always in the same format as the input.\n**\n** If successful, this function returns SQLITE_OK and populates (*pp) with\n** a pointer to a new sqlite3_changegroup object before returning. The caller\n** should eventually free the returned object using a call to \n** sqlite3changegroup_delete(). If an error occurs, an SQLite error code\n** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.\n**\n** The usual usage pattern for an sqlite3_changegroup object is as follows:\n**\n** <ul>\n**   <li> It is created using a call to sqlite3changegroup_new().\n**\n**   <li> Zero or more changesets (or patchsets) are added to the object\n**        by calling sqlite3changegroup_add().\n**\n**   <li> The result of combining all input changesets together is obtained \n**        by the application via a call to sqlite3changegroup_output().\n**\n**   <li> The object is deleted using a call to sqlite3changegroup_delete().\n** </ul>\n**\n** Any number of calls to add() and output() may be made between the calls to\n** new() and delete(), and in any order.\n**\n** As well as the regular sqlite3changegroup_add() and \n** sqlite3changegroup_output() functions, also available are the streaming\n** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().\n*/\nSQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);\n\n/*\n** CAPI3REF: Add A Changeset To A Changegroup\n**\n** Add all changes within the changeset (or patchset) in buffer pData (size\n** nData bytes) to the changegroup. \n**\n** If the buffer contains a patchset, then all prior calls to this function\n** on the same changegroup object must also have specified patchsets. Or, if\n** the buffer contains a changeset, so must have the earlier calls to this\n** function. Otherwise, SQLITE_ERROR is returned and no changes are added\n** to the changegroup.\n**\n** Rows within the changeset and changegroup are identified by the values in\n** their PRIMARY KEY columns. A change in the changeset is considered to\n** apply to the same row as a change already present in the changegroup if\n** the two rows have the same primary key.\n**\n** Changes to rows that do not already appear in the changegroup are\n** simply copied into it. Or, if both the new changeset and the changegroup\n** contain changes that apply to a single row, the final contents of the\n** changegroup depends on the type of each change, as follows:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th style=\"white-space:pre\">Existing Change  </th>\n**       <th style=\"white-space:pre\">New Change       </th>\n**       <th>Output Change\n**   <tr><td>INSERT <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>INSERT <td>UPDATE <td>\n**       The INSERT change remains in the changegroup. The values in the \n**       INSERT change are modified as if the row was inserted by the\n**       existing change and then updated according to the new change.\n**   <tr><td>INSERT <td>DELETE <td>\n**       The existing INSERT is removed from the changegroup. The DELETE is\n**       not added.\n**   <tr><td>UPDATE <td>INSERT <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>UPDATE <td>UPDATE <td>\n**       The existing UPDATE remains within the changegroup. It is amended \n**       so that the accompanying values are as if the row was updated once \n**       by the existing change and then again by the new change.\n**   <tr><td>UPDATE <td>DELETE <td>\n**       The existing UPDATE is replaced by the new DELETE within the\n**       changegroup.\n**   <tr><td>DELETE <td>INSERT <td>\n**       If one or more of the column values in the row inserted by the\n**       new change differ from those in the row deleted by the existing \n**       change, the existing DELETE is replaced by an UPDATE within the\n**       changegroup. Otherwise, if the inserted row is exactly the same \n**       as the deleted row, the existing DELETE is simply discarded.\n**   <tr><td>DELETE <td>UPDATE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n**   <tr><td>DELETE <td>DELETE <td>\n**       The new change is ignored. This case does not occur if the new\n**       changeset was recorded immediately after the changesets already\n**       added to the changegroup.\n** </table>\n**\n** If the new changeset contains changes to a table that is already present\n** in the changegroup, then the number of columns and the position of the\n** primary key columns for the table must be consistent. If this is not the\n** case, this function fails with SQLITE_SCHEMA. If the input changeset\n** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is\n** returned. Or, if an out-of-memory condition occurs during processing, this\n** function returns SQLITE_NOMEM. In all cases, if an error occurs the\n** final contents of the changegroup is undefined.\n**\n** If no error occurs, SQLITE_OK is returned.\n*/\nSQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);\n\n/*\n** CAPI3REF: Obtain A Composite Changeset From A Changegroup\n**\n** Obtain a buffer containing a changeset (or patchset) representing the\n** current contents of the changegroup. If the inputs to the changegroup\n** were themselves changesets, the output is a changeset. Or, if the\n** inputs were patchsets, the output is also a patchset.\n**\n** As with the output of the sqlite3session_changeset() and\n** sqlite3session_patchset() functions, all changes related to a single\n** table are grouped together in the output of this function. Tables appear\n** in the same order as for the very first changeset added to the changegroup.\n** If the second or subsequent changesets added to the changegroup contain\n** changes for tables that do not appear in the first changeset, they are\n** appended onto the end of the output changeset, again in the order in\n** which they are first encountered.\n**\n** If an error occurs, an SQLite error code is returned and the output\n** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK\n** is returned and the output variables are set to the size of and a \n** pointer to the output buffer, respectively. In this case it is the\n** responsibility of the caller to eventually free the buffer using a\n** call to sqlite3_free().\n*/\nSQLITE_API int sqlite3changegroup_output(\n  sqlite3_changegroup*,\n  int *pnData,                    /* OUT: Size of output buffer in bytes */\n  void **ppData                   /* OUT: Pointer to output buffer */\n);\n\n/*\n** CAPI3REF: Delete A Changegroup Object\n*/\nSQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*);\n\n/*\n** CAPI3REF: Apply A Changeset To A Database\n**\n** Apply a changeset to a database. This function attempts to update the\n** \"main\" database attached to handle db with the changes found in the\n** changeset passed via the second and third arguments.\n**\n** The fourth argument (xFilter) passed to this function is the \"filter\n** callback\". If it is not NULL, then for each table affected by at least one\n** change in the changeset, the filter callback is invoked with\n** the table name as the second argument, and a copy of the context pointer\n** passed as the sixth argument to this function as the first. If the \"filter\n** callback\" returns zero, then no attempt is made to apply any changes to \n** the table. Otherwise, if the return value is non-zero or the xFilter\n** argument to this function is NULL, all changes related to the table are\n** attempted.\n**\n** For each table that is not excluded by the filter callback, this function \n** tests that the target database contains a compatible table. A table is \n** considered compatible if all of the following are true:\n**\n** <ul>\n**   <li> The table has the same name as the name recorded in the \n**        changeset, and\n**   <li> The table has at least as many columns as recorded in the \n**        changeset, and\n**   <li> The table has primary key columns in the same position as \n**        recorded in the changeset.\n** </ul>\n**\n** If there is no compatible table, it is not an error, but none of the\n** changes associated with the table are applied. A warning message is issued\n** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most\n** one such warning is issued for each table in the changeset.\n**\n** For each change for which there is a compatible table, an attempt is made \n** to modify the table contents according to the UPDATE, INSERT or DELETE \n** change. If a change cannot be applied cleanly, the conflict handler \n** function passed as the fifth argument to sqlite3changeset_apply() may be \n** invoked. A description of exactly when the conflict handler is invoked for \n** each type of change is below.\n**\n** Unlike the xFilter argument, xConflict may not be passed NULL. The results\n** of passing anything other than a valid function pointer as the xConflict\n** argument are undefined.\n**\n** Each time the conflict handler function is invoked, it must return one\n** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or \n** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned\n** if the second argument passed to the conflict handler is either\n** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler\n** returns an illegal value, any changes already made are rolled back and\n** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different \n** actions are taken by sqlite3changeset_apply() depending on the value\n** returned by each invocation of the conflict-handler function. Refer to\n** the documentation for the three \n** [SQLITE_CHANGESET_OMIT|available return values] for details.\n**\n** <dl>\n** <dt>DELETE Changes<dd>\n**   For each DELETE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all non-primary key columns also match the values stored in \n**   the changeset the row is deleted from the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the non-primary key fields contains a value different from the original\n**   row value stored in the changeset, the conflict-handler function is\n**   invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the\n**   database table has more columns than are recorded in the changeset,\n**   only the values of those non-primary key fields are compared against\n**   the current database contents - any trailing database table columns\n**   are ignored.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT\n**   (which can only happen if a foreign key constraint is violated), the\n**   conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]\n**   passed as the second argument. This includes the case where the DELETE\n**   operation is attempted because an earlier call to the conflict handler\n**   function returned [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>INSERT Changes<dd>\n**   For each INSERT change, an attempt is made to insert the new row into\n**   the database. If the changeset row contains fewer fields than the\n**   database table, the trailing fields are populated with their default\n**   values.\n**\n**   If the attempt to insert the row fails because the database already \n**   contains a row with the same primary key values, the conflict handler\n**   function is invoked with the second argument set to \n**   [SQLITE_CHANGESET_CONFLICT].\n**\n**   If the attempt to insert the row fails because of some other constraint\n**   violation (e.g. NOT NULL or UNIQUE), the conflict handler function is \n**   invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].\n**   This includes the case where the INSERT operation is re-attempted because \n**   an earlier call to the conflict handler function returned \n**   [SQLITE_CHANGESET_REPLACE].\n**\n** <dt>UPDATE Changes<dd>\n**   For each UPDATE change, this function checks if the target database \n**   contains a row with the same primary key value (or values) as the \n**   original row values stored in the changeset. If it does, and the values \n**   stored in all modified non-primary key columns also match the values\n**   stored in the changeset the row is updated within the target database.\n**\n**   If a row with matching primary key values is found, but one or more of\n**   the modified non-primary key fields contains a value different from an\n**   original row value stored in the changeset, the conflict-handler function\n**   is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since\n**   UPDATE changes only contain values for non-primary key fields that are\n**   to be modified, only those fields need to match the original values to\n**   avoid the SQLITE_CHANGESET_DATA conflict-handler callback.\n**\n**   If no row with matching primary key values is found in the database,\n**   the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]\n**   passed as the second argument.\n**\n**   If the UPDATE operation is attempted, but SQLite returns \n**   SQLITE_CONSTRAINT, the conflict-handler function is invoked with \n**   [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.\n**   This includes the case where the UPDATE operation is attempted after \n**   an earlier call to the conflict handler function returned\n**   [SQLITE_CHANGESET_REPLACE].  \n** </dl>\n**\n** It is safe to execute SQL statements, including those that write to the\n** table that the callback related to, from within the xConflict callback.\n** This can be used to further customize the applications conflict\n** resolution strategy.\n**\n** All changes made by this function are enclosed in a savepoint transaction.\n** If any other error (aside from a constraint failure when attempting to\n** write to the target database) occurs, then the savepoint transaction is\n** rolled back, restoring the target database to its original state, and an \n** SQLite error code returned.\n*/\nSQLITE_API int sqlite3changeset_apply(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int nChangeset,                 /* Size of changeset in bytes */\n  void *pChangeset,               /* Changeset blob */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\n\n/* \n** CAPI3REF: Constants Passed To The Conflict Handler\n**\n** Values that may be passed as the second argument to a conflict-handler.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_DATA<dd>\n**   The conflict handler is invoked with CHANGESET_DATA as the second argument\n**   when processing a DELETE or UPDATE change if a row with the required\n**   PRIMARY KEY fields is present in the database, but one or more other \n**   (non primary-key) fields modified by the update do not contain the \n**   expected \"before\" values.\n** \n**   The conflicting row, in this case, is the database row with the matching\n**   primary key.\n** \n** <dt>SQLITE_CHANGESET_NOTFOUND<dd>\n**   The conflict handler is invoked with CHANGESET_NOTFOUND as the second\n**   argument when processing a DELETE or UPDATE change if a row with the\n**   required PRIMARY KEY fields is not present in the database.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n** \n** <dt>SQLITE_CHANGESET_CONFLICT<dd>\n**   CHANGESET_CONFLICT is passed as the second argument to the conflict\n**   handler while processing an INSERT change if the operation would result \n**   in duplicate primary key values.\n** \n**   The conflicting row in this case is the database row with the matching\n**   primary key.\n**\n** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>\n**   If foreign key handling is enabled, and applying a changeset leaves the\n**   database in a state containing foreign key violations, the conflict \n**   handler is invoked with CHANGESET_FOREIGN_KEY as the second argument\n**   exactly once before the changeset is committed. If the conflict handler\n**   returns CHANGESET_OMIT, the changes, including those that caused the\n**   foreign key constraint violation, are committed. Or, if it returns\n**   CHANGESET_ABORT, the changeset is rolled back.\n**\n**   No current or conflicting row information is provided. The only function\n**   it is possible to call on the supplied sqlite3_changeset_iter handle\n**   is sqlite3changeset_fk_conflicts().\n** \n** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>\n**   If any other constraint violation occurs while applying a change (i.e. \n**   a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is \n**   invoked with CHANGESET_CONSTRAINT as the second argument.\n** \n**   There is no conflicting row in this case. The results of invoking the\n**   sqlite3changeset_conflict() API are undefined.\n**\n** </dl>\n*/\n#define SQLITE_CHANGESET_DATA        1\n#define SQLITE_CHANGESET_NOTFOUND    2\n#define SQLITE_CHANGESET_CONFLICT    3\n#define SQLITE_CHANGESET_CONSTRAINT  4\n#define SQLITE_CHANGESET_FOREIGN_KEY 5\n\n/* \n** CAPI3REF: Constants Returned By The Conflict Handler\n**\n** A conflict handler callback must return one of the following three values.\n**\n** <dl>\n** <dt>SQLITE_CHANGESET_OMIT<dd>\n**   If a conflict handler returns this value no special action is taken. The\n**   change that caused the conflict is not applied. The session module \n**   continues to the next change in the changeset.\n**\n** <dt>SQLITE_CHANGESET_REPLACE<dd>\n**   This value may only be returned if the second argument to the conflict\n**   handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this\n**   is not the case, any changes applied so far are rolled back and the \n**   call to sqlite3changeset_apply() returns SQLITE_MISUSE.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict\n**   handler, then the conflicting row is either updated or deleted, depending\n**   on the type of change.\n**\n**   If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict\n**   handler, then the conflicting row is removed from the database and a\n**   second attempt to apply the change is made. If this second attempt fails,\n**   the original row is restored to the database before continuing.\n**\n** <dt>SQLITE_CHANGESET_ABORT<dd>\n**   If this value is returned, any changes applied so far are rolled back \n**   and the call to sqlite3changeset_apply() returns SQLITE_ABORT.\n** </dl>\n*/\n#define SQLITE_CHANGESET_OMIT       0\n#define SQLITE_CHANGESET_REPLACE    1\n#define SQLITE_CHANGESET_ABORT      2\n\n/*\n** CAPI3REF: Streaming Versions of API functions.\n**\n** The six streaming API xxx_strm() functions serve similar purposes to the \n** corresponding non-streaming API functions:\n**\n** <table border=1 style=\"margin-left:8ex;margin-right:8ex\">\n**   <tr><th>Streaming function<th>Non-streaming equivalent</th>\n**   <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] \n**   <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] \n**   <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] \n**   <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] \n**   <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] \n**   <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] \n** </table>\n**\n** Non-streaming functions that accept changesets (or patchsets) as input\n** require that the entire changeset be stored in a single buffer in memory. \n** Similarly, those that return a changeset or patchset do so by returning \n** a pointer to a single large buffer allocated using sqlite3_malloc(). \n** Normally this is convenient. However, if an application running in a \n** low-memory environment is required to handle very large changesets, the\n** large contiguous memory allocations required can become onerous.\n**\n** In order to avoid this problem, instead of a single large buffer, input\n** is passed to a streaming API functions by way of a callback function that\n** the sessions module invokes to incrementally request input data as it is\n** required. In all cases, a pair of API function parameters such as\n**\n**  <pre>\n**  &nbsp;     int nChangeset,\n**  &nbsp;     void *pChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xInput)(void *pIn, void *pData, int *pnData),\n**  &nbsp;     void *pIn,\n**  </pre>\n**\n** Each time the xInput callback is invoked by the sessions module, the first\n** argument passed is a copy of the supplied pIn context pointer. The second \n** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no \n** error occurs the xInput method should copy up to (*pnData) bytes of data \n** into the buffer and set (*pnData) to the actual number of bytes copied \n** before returning SQLITE_OK. If the input is completely exhausted, (*pnData) \n** should be set to zero to indicate this. Or, if an error occurs, an SQLite \n** error code should be returned. In all cases, if an xInput callback returns\n** an error, all processing is abandoned and the streaming API function\n** returns a copy of the error code to the caller.\n**\n** In the case of sqlite3changeset_start_strm(), the xInput callback may be\n** invoked by the sessions module at any point during the lifetime of the\n** iterator. If such an xInput callback returns an error, the iterator enters\n** an error state, whereby all subsequent calls to iterator functions \n** immediately fail with the same error code as returned by xInput.\n**\n** Similarly, streaming API functions that return changesets (or patchsets)\n** return them in chunks by way of a callback function instead of via a\n** pointer to a single large buffer. In this case, a pair of parameters such\n** as:\n**\n**  <pre>\n**  &nbsp;     int *pnChangeset,\n**  &nbsp;     void **ppChangeset,\n**  </pre>\n**\n** Is replaced by:\n**\n**  <pre>\n**  &nbsp;     int (*xOutput)(void *pOut, const void *pData, int nData),\n**  &nbsp;     void *pOut\n**  </pre>\n**\n** The xOutput callback is invoked zero or more times to return data to\n** the application. The first parameter passed to each call is a copy of the\n** pOut pointer supplied by the application. The second parameter, pData,\n** points to a buffer nData bytes in size containing the chunk of output\n** data being returned. If the xOutput callback successfully processes the\n** supplied data, it should return SQLITE_OK to indicate success. Otherwise,\n** it should return some other SQLite error code. In this case processing\n** is immediately abandoned and the streaming API function returns a copy\n** of the xOutput error code to the application.\n**\n** The sessions module never invokes an xOutput callback with the third \n** parameter set to a value less than or equal to zero. Other than this,\n** no guarantees are made as to the size of the chunks of data returned.\n*/\nSQLITE_API int sqlite3changeset_apply_strm(\n  sqlite3 *db,                    /* Apply change to \"main\" db of this handle */\n  int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */\n  void *pIn,                                          /* First arg for xInput */\n  int(*xFilter)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    const char *zTab              /* Table name */\n  ),\n  int(*xConflict)(\n    void *pCtx,                   /* Copy of sixth arg to _apply() */\n    int eConflict,                /* DATA, MISSING, CONFLICT, CONSTRAINT */\n    sqlite3_changeset_iter *p     /* Handle describing change and conflict */\n  ),\n  void *pCtx                      /* First argument passed to xConflict */\n);\nSQLITE_API int sqlite3changeset_concat_strm(\n  int (*xInputA)(void *pIn, void *pData, int *pnData),\n  void *pInA,\n  int (*xInputB)(void *pIn, void *pData, int *pnData),\n  void *pInB,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_invert_strm(\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changeset_start_strm(\n  sqlite3_changeset_iter **pp,\n  int (*xInput)(void *pIn, void *pData, int *pnData),\n  void *pIn\n);\nSQLITE_API int sqlite3session_changeset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3session_patchset_strm(\n  sqlite3_session *pSession,\n  int (*xOutput)(void *pOut, const void *pData, int nData),\n  void *pOut\n);\nSQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, \n    int (*xInput)(void *pIn, void *pData, int *pnData),\n    void *pIn\n);\nSQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*,\n    int (*xOutput)(void *pOut, const void *pData, int nData), \n    void *pOut\n);\n\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\n}\n#endif\n\n#endif  /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */\n\n/******** End of sqlite3session.h *********/\n/******** Begin file fts5.h *********/\n/*\n** 2014 May 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** Interfaces to extend FTS5. Using the interfaces defined in this file, \n** FTS5 may be extended with:\n**\n**     * custom tokenizers, and\n**     * custom auxiliary functions.\n*/\n\n\n#ifndef _FTS5_H\n#define _FTS5_H\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*************************************************************************\n** CUSTOM AUXILIARY FUNCTIONS\n**\n** Virtual table implementations may overload SQL functions by implementing\n** the sqlite3_module.xFindFunction() method.\n*/\n\ntypedef struct Fts5ExtensionApi Fts5ExtensionApi;\ntypedef struct Fts5Context Fts5Context;\ntypedef struct Fts5PhraseIter Fts5PhraseIter;\n\ntypedef void (*fts5_extension_function)(\n  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */\n  Fts5Context *pFts,              /* First arg to pass to pApi functions */\n  sqlite3_context *pCtx,          /* Context for returning result/error */\n  int nVal,                       /* Number of values in apVal[] array */\n  sqlite3_value **apVal           /* Array of trailing arguments */\n);\n\nstruct Fts5PhraseIter {\n  const unsigned char *a;\n  const unsigned char *b;\n};\n\n/*\n** EXTENSION API FUNCTIONS\n**\n** xUserData(pFts):\n**   Return a copy of the context pointer the extension function was \n**   registered with.\n**\n** xColumnTotalSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the FTS5 table. Or, if iCol is\n**   non-negative but less than the number of columns in the table, return\n**   the total number of tokens in column iCol, considering all rows in \n**   the FTS5 table.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n** xColumnCount(pFts):\n**   Return the number of columns in the table.\n**\n** xColumnSize(pFts, iCol, pnToken):\n**   If parameter iCol is less than zero, set output variable *pnToken\n**   to the total number of tokens in the current row. Or, if iCol is\n**   non-negative but less than the number of columns in the table, set\n**   *pnToken to the number of tokens in column iCol of the current row.\n**\n**   If parameter iCol is greater than or equal to the number of columns\n**   in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g.\n**   an OOM condition or IO error), an appropriate SQLite error code is \n**   returned.\n**\n**   This function may be quite inefficient if used with an FTS5 table\n**   created with the \"columnsize=0\" option.\n**\n** xColumnText:\n**   This function attempts to retrieve the text of column iCol of the\n**   current document. If successful, (*pz) is set to point to a buffer\n**   containing the text in utf-8 encoding, (*pn) is set to the size in bytes\n**   (not characters) of the buffer and SQLITE_OK is returned. Otherwise,\n**   if an error occurs, an SQLite error code is returned and the final values\n**   of (*pz) and (*pn) are undefined.\n**\n** xPhraseCount:\n**   Returns the number of phrases in the current query expression.\n**\n** xPhraseSize:\n**   Returns the number of tokens in phrase iPhrase of the query. Phrases\n**   are numbered starting from zero.\n**\n** xInstCount:\n**   Set *pnInst to the total number of occurrences of all phrases within\n**   the query within the current row. Return SQLITE_OK if successful, or\n**   an error code (i.e. SQLITE_NOMEM) if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always returns 0.\n**\n** xInst:\n**   Query for the details of phrase match iIdx within the current row.\n**   Phrase matches are numbered starting from zero, so the iIdx argument\n**   should be greater than or equal to zero and smaller than the value\n**   output by xInstCount().\n**\n**   Usually, output parameter *piPhrase is set to the phrase number, *piCol\n**   to the column in which it occurs and *piOff the token offset of the\n**   first token of the phrase. The exception is if the table was created\n**   with the offsets=0 option specified. In this case *piOff is always\n**   set to -1.\n**\n**   Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM) \n**   if an error occurs.\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. \n**\n** xRowid:\n**   Returns the rowid of the current row.\n**\n** xTokenize:\n**   Tokenize text using the tokenizer belonging to the FTS5 table.\n**\n** xQueryPhrase(pFts5, iPhrase, pUserData, xCallback):\n**   This API function is used to query the FTS table for phrase iPhrase\n**   of the current query. Specifically, a query equivalent to:\n**\n**       ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid\n**\n**   with $p set to a phrase equivalent to the phrase iPhrase of the\n**   current query is executed. Any column filter that applies to\n**   phrase iPhrase of the current query is included in $p. For each \n**   row visited, the callback function passed as the fourth argument \n**   is invoked. The context and API objects passed to the callback \n**   function may be used to access the properties of each matched row.\n**   Invoking Api.xUserData() returns a copy of the pointer passed as \n**   the third argument to pUserData.\n**\n**   If the callback function returns any value other than SQLITE_OK, the\n**   query is abandoned and the xQueryPhrase function returns immediately.\n**   If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.\n**   Otherwise, the error code is propagated upwards.\n**\n**   If the query runs to completion without incident, SQLITE_OK is returned.\n**   Or, if some error occurs before the query completes or is aborted by\n**   the callback, an SQLite error code is returned.\n**\n**\n** xSetAuxdata(pFts5, pAux, xDelete)\n**\n**   Save the pointer passed as the second argument as the extension functions \n**   \"auxiliary data\". The pointer may then be retrieved by the current or any\n**   future invocation of the same fts5 extension function made as part of\n**   of the same MATCH query using the xGetAuxdata() API.\n**\n**   Each extension function is allocated a single auxiliary data slot for\n**   each FTS query (MATCH expression). If the extension function is invoked \n**   more than once for a single FTS query, then all invocations share a \n**   single auxiliary data context.\n**\n**   If there is already an auxiliary data pointer when this function is\n**   invoked, then it is replaced by the new pointer. If an xDelete callback\n**   was specified along with the original pointer, it is invoked at this\n**   point.\n**\n**   The xDelete callback, if one is specified, is also invoked on the\n**   auxiliary data pointer after the FTS5 query has finished.\n**\n**   If an error (e.g. an OOM condition) occurs within this function, an\n**   the auxiliary data is set to NULL and an error code returned. If the\n**   xDelete parameter was not NULL, it is invoked on the auxiliary data\n**   pointer before returning.\n**\n**\n** xGetAuxdata(pFts5, bClear)\n**\n**   Returns the current auxiliary data pointer for the fts5 extension \n**   function. See the xSetAuxdata() method for details.\n**\n**   If the bClear argument is non-zero, then the auxiliary data is cleared\n**   (set to NULL) before this function returns. In this case the xDelete,\n**   if any, is not invoked.\n**\n**\n** xRowCount(pFts5, pnRow)\n**\n**   This function is used to retrieve the total number of rows in the table.\n**   In other words, the same value that would be returned by:\n**\n**        SELECT count(*) FROM ftstable;\n**\n** xPhraseFirst()\n**   This function is used, along with type Fts5PhraseIter and the xPhraseNext\n**   method, to iterate through all instances of a single query phrase within\n**   the current row. This is the same information as is accessible via the\n**   xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient\n**   to use, this API may be faster under some circumstances. To iterate \n**   through instances of phrase iPhrase, use the following code:\n**\n**       Fts5PhraseIter iter;\n**       int iCol, iOff;\n**       for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff);\n**           iCol>=0;\n**           pApi->xPhraseNext(pFts, &iter, &iCol, &iOff)\n**       ){\n**         // An instance of phrase iPhrase at offset iOff of column iCol\n**       }\n**\n**   The Fts5PhraseIter structure is defined above. Applications should not\n**   modify this structure directly - it should only be used as shown above\n**   with the xPhraseFirst() and xPhraseNext() API methods (and by\n**   xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below).\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" or \"detail=column\" option. If the FTS5 table is created \n**   with either \"detail=none\" or \"detail=column\" and \"content=\" option \n**   (i.e. if it is a contentless table), then this API always iterates\n**   through an empty set (all calls to xPhraseFirst() set iCol to -1).\n**\n** xPhraseNext()\n**   See xPhraseFirst above.\n**\n** xPhraseFirstColumn()\n**   This function and xPhraseNextColumn() are similar to the xPhraseFirst()\n**   and xPhraseNext() APIs described above. The difference is that instead\n**   of iterating through all instances of a phrase in the current row, these\n**   APIs are used to iterate through the set of columns in the current row\n**   that contain one or more instances of a specified phrase. For example:\n**\n**       Fts5PhraseIter iter;\n**       int iCol;\n**       for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol);\n**           iCol>=0;\n**           pApi->xPhraseNextColumn(pFts, &iter, &iCol)\n**       ){\n**         // Column iCol contains at least one instance of phrase iPhrase\n**       }\n**\n**   This API can be quite slow if used with an FTS5 table created with the\n**   \"detail=none\" option. If the FTS5 table is created with either \n**   \"detail=none\" \"content=\" option (i.e. if it is a contentless table), \n**   then this API always iterates through an empty set (all calls to \n**   xPhraseFirstColumn() set iCol to -1).\n**\n**   The information accessed using this API and its companion\n**   xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext\n**   (or xInst/xInstCount). The chief advantage of this API is that it is\n**   significantly more efficient than those alternatives when used with\n**   \"detail=column\" tables.  \n**\n** xPhraseNextColumn()\n**   See xPhraseFirstColumn above.\n*/\nstruct Fts5ExtensionApi {\n  int iVersion;                   /* Currently always set to 3 */\n\n  void *(*xUserData)(Fts5Context*);\n\n  int (*xColumnCount)(Fts5Context*);\n  int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);\n  int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);\n\n  int (*xTokenize)(Fts5Context*, \n    const char *pText, int nText, /* Text to tokenize */\n    void *pCtx,                   /* Context passed to xToken() */\n    int (*xToken)(void*, int, const char*, int, int, int)       /* Callback */\n  );\n\n  int (*xPhraseCount)(Fts5Context*);\n  int (*xPhraseSize)(Fts5Context*, int iPhrase);\n\n  int (*xInstCount)(Fts5Context*, int *pnInst);\n  int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);\n\n  sqlite3_int64 (*xRowid)(Fts5Context*);\n  int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn);\n  int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);\n\n  int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData,\n    int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)\n  );\n  int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*));\n  void *(*xGetAuxdata)(Fts5Context*, int bClear);\n\n  int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);\n  void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);\n\n  int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);\n  void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);\n};\n\n/* \n** CUSTOM AUXILIARY FUNCTIONS\n*************************************************************************/\n\n/*************************************************************************\n** CUSTOM TOKENIZERS\n**\n** Applications may also register custom tokenizer types. A tokenizer \n** is registered by providing fts5 with a populated instance of the \n** following structure. All structure methods must be defined, setting\n** any member of the fts5_tokenizer struct to NULL leads to undefined\n** behaviour. The structure methods are expected to function as follows:\n**\n** xCreate:\n**   This function is used to allocate and initialize a tokenizer instance.\n**   A tokenizer instance is required to actually tokenize text.\n**\n**   The first argument passed to this function is a copy of the (void*)\n**   pointer provided by the application when the fts5_tokenizer object\n**   was registered with FTS5 (the third argument to xCreateTokenizer()). \n**   The second and third arguments are an array of nul-terminated strings\n**   containing the tokenizer arguments, if any, specified following the\n**   tokenizer name as part of the CREATE VIRTUAL TABLE statement used\n**   to create the FTS5 table.\n**\n**   The final argument is an output variable. If successful, (*ppOut) \n**   should be set to point to the new tokenizer handle and SQLITE_OK\n**   returned. If an error occurs, some value other than SQLITE_OK should\n**   be returned. In this case, fts5 assumes that the final value of *ppOut \n**   is undefined.\n**\n** xDelete:\n**   This function is invoked to delete a tokenizer handle previously\n**   allocated using xCreate(). Fts5 guarantees that this function will\n**   be invoked exactly once for each successful call to xCreate().\n**\n** xTokenize:\n**   This function is expected to tokenize the nText byte string indicated \n**   by argument pText. pText may or may not be nul-terminated. The first\n**   argument passed to this function is a pointer to an Fts5Tokenizer object\n**   returned by an earlier call to xCreate().\n**\n**   The second argument indicates the reason that FTS5 is requesting\n**   tokenization of the supplied text. This is always one of the following\n**   four values:\n**\n**   <ul><li> <b>FTS5_TOKENIZE_DOCUMENT</b> - A document is being inserted into\n**            or removed from the FTS table. The tokenizer is being invoked to\n**            determine the set of tokens to add to (or delete from) the\n**            FTS index.\n**\n**       <li> <b>FTS5_TOKENIZE_QUERY</b> - A MATCH query is being executed \n**            against the FTS index. The tokenizer is being called to tokenize \n**            a bareword or quoted string specified as part of the query.\n**\n**       <li> <b>(FTS5_TOKENIZE_QUERY | FTS5_TOKENIZE_PREFIX)</b> - Same as\n**            FTS5_TOKENIZE_QUERY, except that the bareword or quoted string is\n**            followed by a \"*\" character, indicating that the last token\n**            returned by the tokenizer will be treated as a token prefix.\n**\n**       <li> <b>FTS5_TOKENIZE_AUX</b> - The tokenizer is being invoked to \n**            satisfy an fts5_api.xTokenize() request made by an auxiliary\n**            function. Or an fts5_api.xColumnSize() request made by the same\n**            on a columnsize=0 database.  \n**   </ul>\n**\n**   For each token in the input string, the supplied callback xToken() must\n**   be invoked. The first argument to it should be a copy of the pointer\n**   passed as the second argument to xTokenize(). The third and fourth\n**   arguments are a pointer to a buffer containing the token text, and the\n**   size of the token in bytes. The 4th and 5th arguments are the byte offsets\n**   of the first byte of and first byte immediately following the text from\n**   which the token is derived within the input.\n**\n**   The second argument passed to the xToken() callback (\"tflags\") should\n**   normally be set to 0. The exception is if the tokenizer supports \n**   synonyms. In this case see the discussion below for details.\n**\n**   FTS5 assumes the xToken() callback is invoked for each token in the \n**   order that they occur within the input text.\n**\n**   If an xToken() callback returns any value other than SQLITE_OK, then\n**   the tokenization should be abandoned and the xTokenize() method should\n**   immediately return a copy of the xToken() return value. Or, if the\n**   input buffer is exhausted, xTokenize() should return SQLITE_OK. Finally,\n**   if an error occurs with the xTokenize() implementation itself, it\n**   may abandon the tokenization and return any error code other than\n**   SQLITE_OK or SQLITE_DONE.\n**\n** SYNONYM SUPPORT\n**\n**   Custom tokenizers may also support synonyms. Consider a case in which a\n**   user wishes to query for a phrase such as \"first place\". Using the \n**   built-in tokenizers, the FTS5 query 'first + place' will match instances\n**   of \"first place\" within the document set, but not alternative forms\n**   such as \"1st place\". In some applications, it would be better to match\n**   all instances of \"first place\" or \"1st place\" regardless of which form\n**   the user specified in the MATCH query text.\n**\n**   There are several ways to approach this in FTS5:\n**\n**   <ol><li> By mapping all synonyms to a single token. In this case, the \n**            In the above example, this means that the tokenizer returns the\n**            same token for inputs \"first\" and \"1st\". Say that token is in\n**            fact \"first\", so that when the user inserts the document \"I won\n**            1st place\" entries are added to the index for tokens \"i\", \"won\",\n**            \"first\" and \"place\". If the user then queries for '1st + place',\n**            the tokenizer substitutes \"first\" for \"1st\" and the query works\n**            as expected.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            In this case, when tokenizing query text, the tokenizer may \n**            provide multiple synonyms for a single term within the document.\n**            FTS5 then queries the index for each synonym individually. For\n**            example, faced with the query:\n**\n**   <codeblock>\n**     ... MATCH 'first place'</codeblock>\n**\n**            the tokenizer offers both \"1st\" and \"first\" as synonyms for the\n**            first token in the MATCH query and FTS5 effectively runs a query \n**            similar to:\n**\n**   <codeblock>\n**     ... MATCH '(first OR 1st) place'</codeblock>\n**\n**            except that, for the purposes of auxiliary functions, the query\n**            still appears to contain just two phrases - \"(first OR 1st)\" \n**            being treated as a single phrase.\n**\n**       <li> By adding multiple synonyms for a single term to the FTS index.\n**            Using this method, when tokenizing document text, the tokenizer\n**            provides multiple synonyms for each token. So that when a \n**            document such as \"I won first place\" is tokenized, entries are\n**            added to the FTS index for \"i\", \"won\", \"first\", \"1st\" and\n**            \"place\".\n**\n**            This way, even if the tokenizer does not provide synonyms\n**            when tokenizing query text (it should not - to do would be\n**            inefficient), it doesn't matter if the user queries for \n**            'first + place' or '1st + place', as there are entires in the\n**            FTS index corresponding to both forms of the first token.\n**   </ol>\n**\n**   Whether it is parsing document or query text, any call to xToken that\n**   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit\n**   is considered to supply a synonym for the previous token. For example,\n**   when parsing the document \"I won first place\", a tokenizer that supports\n**   synonyms would call xToken() 5 times, as follows:\n**\n**   <codeblock>\n**       xToken(pCtx, 0, \"i\",                      1,  0,  1);\n**       xToken(pCtx, 0, \"won\",                    3,  2,  5);\n**       xToken(pCtx, 0, \"first\",                  5,  6, 11);\n**       xToken(pCtx, FTS5_TOKEN_COLOCATED, \"1st\", 3,  6, 11);\n**       xToken(pCtx, 0, \"place\",                  5, 12, 17);\n**</codeblock>\n**\n**   It is an error to specify the FTS5_TOKEN_COLOCATED flag the first time\n**   xToken() is called. Multiple synonyms may be specified for a single token\n**   by making multiple calls to xToken(FTS5_TOKEN_COLOCATED) in sequence. \n**   There is no limit to the number of synonyms that may be provided for a\n**   single token.\n**\n**   In many cases, method (1) above is the best approach. It does not add \n**   extra data to the FTS index or require FTS5 to query for multiple terms,\n**   so it is efficient in terms of disk space and query speed. However, it\n**   does not support prefix queries very well. If, as suggested above, the\n**   token \"first\" is subsituted for \"1st\" by the tokenizer, then the query:\n**\n**   <codeblock>\n**     ... MATCH '1s*'</codeblock>\n**\n**   will not match documents that contain the token \"1st\" (as the tokenizer\n**   will probably not map \"1s\" to any prefix of \"first\").\n**\n**   For full prefix support, method (3) may be preferred. In this case, \n**   because the index contains entries for both \"first\" and \"1st\", prefix\n**   queries such as 'fi*' or '1s*' will match correctly. However, because\n**   extra entries are added to the FTS index, this method uses more space\n**   within the database.\n**\n**   Method (2) offers a midpoint between (1) and (3). Using this method,\n**   a query such as '1s*' will match documents that contain the literal \n**   token \"1st\", but not \"first\" (assuming the tokenizer is not able to\n**   provide synonyms for prefixes). However, a non-prefix query like '1st'\n**   will match against \"1st\" and \"first\". This method does not require\n**   extra disk space, as no extra entries are added to the FTS index. \n**   On the other hand, it may require more CPU cycles to run MATCH queries,\n**   as separate queries of the FTS index are required for each synonym.\n**\n**   When using methods (2) or (3), it is important that the tokenizer only\n**   provide synonyms when tokenizing document text (method (2)) or query\n**   text (method (3)), not both. Doing so will not cause any errors, but is\n**   inefficient.\n*/\ntypedef struct Fts5Tokenizer Fts5Tokenizer;\ntypedef struct fts5_tokenizer fts5_tokenizer;\nstruct fts5_tokenizer {\n  int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);\n  void (*xDelete)(Fts5Tokenizer*);\n  int (*xTokenize)(Fts5Tokenizer*, \n      void *pCtx,\n      int flags,            /* Mask of FTS5_TOKENIZE_* flags */\n      const char *pText, int nText, \n      int (*xToken)(\n        void *pCtx,         /* Copy of 2nd argument to xTokenize() */\n        int tflags,         /* Mask of FTS5_TOKEN_* flags */\n        const char *pToken, /* Pointer to buffer containing token */\n        int nToken,         /* Size of token in bytes */\n        int iStart,         /* Byte offset of token within input text */\n        int iEnd            /* Byte offset of end of token within input text */\n      )\n  );\n};\n\n/* Flags that may be passed as the third argument to xTokenize() */\n#define FTS5_TOKENIZE_QUERY     0x0001\n#define FTS5_TOKENIZE_PREFIX    0x0002\n#define FTS5_TOKENIZE_DOCUMENT  0x0004\n#define FTS5_TOKENIZE_AUX       0x0008\n\n/* Flags that may be passed by the tokenizer implementation back to FTS5\n** as the third argument to the supplied xToken callback. */\n#define FTS5_TOKEN_COLOCATED    0x0001      /* Same position as prev. token */\n\n/*\n** END OF CUSTOM TOKENIZERS\n*************************************************************************/\n\n/*************************************************************************\n** FTS5 EXTENSION REGISTRATION API\n*/\ntypedef struct fts5_api fts5_api;\nstruct fts5_api {\n  int iVersion;                   /* Currently always set to 2 */\n\n  /* Create a new tokenizer */\n  int (*xCreateTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_tokenizer *pTokenizer,\n    void (*xDestroy)(void*)\n  );\n\n  /* Find an existing tokenizer */\n  int (*xFindTokenizer)(\n    fts5_api *pApi,\n    const char *zName,\n    void **ppContext,\n    fts5_tokenizer *pTokenizer\n  );\n\n  /* Create a new auxiliary function */\n  int (*xCreateFunction)(\n    fts5_api *pApi,\n    const char *zName,\n    void *pContext,\n    fts5_extension_function xFunction,\n    void (*xDestroy)(void*)\n  );\n};\n\n/*\n** END OF REGISTRATION API\n*************************************************************************/\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n\n#endif /* _FTS5_H */\n\n/******** End of fts5.h *********/\n"
  },
  {
    "path": "v2/testdata/_sqlite/sqlite-amalgamation-3210000/sqlite3ext.h",
    "content": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef SQLITE3EXT_H\n#define SQLITE3EXT_H\n#include \"sqlite3.h\"\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each other's shared\n** libraries!\n*/\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n  int  (*global_recover)(void);\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*xsnprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*xvsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n  /* Version 3.8.7 and later */\n  int (*auto_extension)(void(*)(void));\n  int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,\n                     void(*)(void*));\n  int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,\n                      void(*)(void*),unsigned char);\n  int (*cancel_auto_extension)(void(*)(void));\n  int (*load_extension)(sqlite3*,const char*,const char*,char**);\n  void *(*malloc64)(sqlite3_uint64);\n  sqlite3_uint64 (*msize)(void*);\n  void *(*realloc64)(void*,sqlite3_uint64);\n  void (*reset_auto_extension)(void);\n  void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,\n                        void(*)(void*));\n  void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,\n                         void(*)(void*), unsigned char);\n  int (*strglob)(const char*,const char*);\n  /* Version 3.8.11 and later */\n  sqlite3_value *(*value_dup)(const sqlite3_value*);\n  void (*value_free)(sqlite3_value*);\n  int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);\n  int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);\n  /* Version 3.9.0 and later */\n  unsigned int (*value_subtype)(sqlite3_value*);\n  void (*result_subtype)(sqlite3_context*,unsigned int);\n  /* Version 3.10.0 and later */\n  int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);\n  int (*strlike)(const char*,const char*,unsigned int);\n  int (*db_cacheflush)(sqlite3*);\n  /* Version 3.12.0 and later */\n  int (*system_errno)(sqlite3*);\n  /* Version 3.14.0 and later */\n  int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);\n  char *(*expanded_sql)(sqlite3_stmt*);\n  /* Version 3.18.0 and later */\n  void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);\n  /* Version 3.20.0 and later */\n  int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,\n                    sqlite3_stmt**,const char**);\n  int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,\n                      sqlite3_stmt**,const void**);\n  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));\n  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));\n  void *(*value_pointer)(sqlite3_value*,const char*);\n};\n\n/*\n** This is the function signature used for all extension entry points.  It\n** is also defined in the file \"loadext.c\".\n*/\ntypedef int (*sqlite3_loadext_entry)(\n  sqlite3 *db,                       /* Handle to the database. */\n  char **pzErrMsg,                   /* Used to set error string on failure. */\n  const sqlite3_api_routines *pThunk /* Extension API function pointers. */\n);\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected through the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->xsnprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_vsnprintf              sqlite3_api->xvsnprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->xvsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n/* Version 3.8.7 and later */\n#define sqlite3_auto_extension         sqlite3_api->auto_extension\n#define sqlite3_bind_blob64            sqlite3_api->bind_blob64\n#define sqlite3_bind_text64            sqlite3_api->bind_text64\n#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension\n#define sqlite3_load_extension         sqlite3_api->load_extension\n#define sqlite3_malloc64               sqlite3_api->malloc64\n#define sqlite3_msize                  sqlite3_api->msize\n#define sqlite3_realloc64              sqlite3_api->realloc64\n#define sqlite3_reset_auto_extension   sqlite3_api->reset_auto_extension\n#define sqlite3_result_blob64          sqlite3_api->result_blob64\n#define sqlite3_result_text64          sqlite3_api->result_text64\n#define sqlite3_strglob                sqlite3_api->strglob\n/* Version 3.8.11 and later */\n#define sqlite3_value_dup              sqlite3_api->value_dup\n#define sqlite3_value_free             sqlite3_api->value_free\n#define sqlite3_result_zeroblob64      sqlite3_api->result_zeroblob64\n#define sqlite3_bind_zeroblob64        sqlite3_api->bind_zeroblob64\n/* Version 3.9.0 and later */\n#define sqlite3_value_subtype          sqlite3_api->value_subtype\n#define sqlite3_result_subtype         sqlite3_api->result_subtype\n/* Version 3.10.0 and later */\n#define sqlite3_status64               sqlite3_api->status64\n#define sqlite3_strlike                sqlite3_api->strlike\n#define sqlite3_db_cacheflush          sqlite3_api->db_cacheflush\n/* Version 3.12.0 and later */\n#define sqlite3_system_errno           sqlite3_api->system_errno\n/* Version 3.14.0 and later */\n#define sqlite3_trace_v2               sqlite3_api->trace_v2\n#define sqlite3_expanded_sql           sqlite3_api->expanded_sql\n/* Version 3.18.0 and later */\n#define sqlite3_set_last_insert_rowid  sqlite3_api->set_last_insert_rowid\n/* Version 3.20.0 and later */\n#define sqlite3_prepare_v3             sqlite3_api->prepare_v3\n#define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3\n#define sqlite3_bind_pointer           sqlite3_api->bind_pointer\n#define sqlite3_result_pointer         sqlite3_api->result_pointer\n#define sqlite3_value_pointer          sqlite3_api->value_pointer\n#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n# define SQLITE_EXTENSION_INIT3     \\\n    extern const sqlite3_api_routines *sqlite3_api;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n# define SQLITE_EXTENSION_INIT3     /*no-op*/\n#endif\n\n#endif /* SQLITE3EXT_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/alter.c",
    "content": "/*\n** 2005 February 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that used to generate VDBE code\n** that implements the ALTER TABLE command.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** The code in this file only exists if we are not omitting the\n** ALTER TABLE logic from the build.\n*/\n#ifndef SQLITE_OMIT_ALTERTABLE\n\n\n/*\n** This function is used by SQL generated to implement the \n** ALTER TABLE command. The first argument is the text of a CREATE TABLE or\n** CREATE INDEX command. The second is a table name. The table name in \n** the CREATE TABLE or CREATE INDEX statement is replaced with the third\n** argument and the result returned. Examples:\n**\n** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')\n**     -> 'CREATE TABLE def(a, b, c)'\n**\n** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')\n**     -> 'CREATE INDEX i ON def(a, b, c)'\n*/\nstatic void renameTableFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TABLE \n  ** statement is that the table name is the first non-space token that\n  ** is immediately followed by a TK_LP or TK_USING token.\n  */\n  if( zSql ){\n    do {\n      if( !*zCsr ){\n        /* Ran out of input before finding an opening bracket. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      } while( token==TK_SPACE );\n      assert( len>0 );\n    } while( token!=TK_LP && token!=TK_USING );\n\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", (int)(((u8*)tname.z) - zSql),\n       zSql, zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** This C function implements an SQL user function that is used by SQL code\n** generated by the ALTER TABLE ... RENAME command to modify the definition\n** of any foreign key constraints that use the table being renamed as the \n** parent table. It is passed three arguments:\n**\n**   1) The complete text of the CREATE TABLE statement being modified,\n**   2) The old name of the table being renamed, and\n**   3) The new name of the table being renamed.\n**\n** It returns the new CREATE TABLE statement. For example:\n**\n**   sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')\n**       -> 'CREATE TABLE t1(a REFERENCES t3)'\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic void renameParentFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zOutput = 0;\n  char *zResult;\n  unsigned char const *zInput = sqlite3_value_text(argv[0]);\n  unsigned char const *zOld = sqlite3_value_text(argv[1]);\n  unsigned char const *zNew = sqlite3_value_text(argv[2]);\n\n  unsigned const char *z;         /* Pointer to token */\n  int n;                          /* Length of token z */\n  int token;                      /* Type of token */\n\n  UNUSED_PARAMETER(NotUsed);\n  if( zInput==0 || zOld==0 ) return;\n  for(z=zInput; *z; z=z+n){\n    n = sqlite3GetToken(z, &token);\n    if( token==TK_REFERENCES ){\n      char *zParent;\n      do {\n        z += n;\n        n = sqlite3GetToken(z, &token);\n      }while( token==TK_SPACE );\n\n      if( token==TK_ILLEGAL ) break;\n      zParent = sqlite3DbStrNDup(db, (const char *)z, n);\n      if( zParent==0 ) break;\n      sqlite3Dequote(zParent);\n      if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){\n        char *zOut = sqlite3MPrintf(db, \"%s%.*s\\\"%w\\\"\", \n            (zOutput?zOutput:\"\"), (int)(z-zInput), zInput, (const char *)zNew\n        );\n        sqlite3DbFree(db, zOutput);\n        zOutput = zOut;\n        zInput = &z[n];\n      }\n      sqlite3DbFree(db, zParent);\n    }\n  }\n\n  zResult = sqlite3MPrintf(db, \"%s%s\", (zOutput?zOutput:\"\"), zInput), \n  sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);\n  sqlite3DbFree(db, zOutput);\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n/* This function is used by SQL generated to implement the\n** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER \n** statement. The second is a table name. The table name in the CREATE \n** TRIGGER statement is replaced with the third argument and the result \n** returned. This is analagous to renameTableFunc() above, except for CREATE\n** TRIGGER, not CREATE INDEX and CREATE TABLE.\n*/\nstatic void renameTriggerFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  unsigned char const *zSql = sqlite3_value_text(argv[0]);\n  unsigned char const *zTableName = sqlite3_value_text(argv[1]);\n\n  int token;\n  Token tname;\n  int dist = 3;\n  unsigned char const *zCsr = zSql;\n  int len = 0;\n  char *zRet;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* The principle used to locate the table name in the CREATE TRIGGER \n  ** statement is that the table name is the first token that is immediately\n  ** preceded by either TK_ON or TK_DOT and immediately followed by one\n  ** of TK_WHEN, TK_BEGIN or TK_FOR.\n  */\n  if( zSql ){\n    do {\n\n      if( !*zCsr ){\n        /* Ran out of input before finding the table name. Return NULL. */\n        return;\n      }\n\n      /* Store the token that zCsr points to in tname. */\n      tname.z = (char*)zCsr;\n      tname.n = len;\n\n      /* Advance zCsr to the next token. Store that token type in 'token',\n      ** and its length in 'len' (to be used next iteration of this loop).\n      */\n      do {\n        zCsr += len;\n        len = sqlite3GetToken(zCsr, &token);\n      }while( token==TK_SPACE );\n      assert( len>0 );\n\n      /* Variable 'dist' stores the number of tokens read since the most\n      ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN \n      ** token is read and 'dist' equals 2, the condition stated above\n      ** to be met.\n      **\n      ** Note that ON cannot be a database, table or column name, so\n      ** there is no need to worry about syntax like \n      ** \"CREATE TRIGGER ... ON ON.ON BEGIN ...\" etc.\n      */\n      dist++;\n      if( token==TK_DOT || token==TK_ON ){\n        dist = 0;\n      }\n    } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );\n\n    /* Variable tname now contains the token that is the old table-name\n    ** in the CREATE TRIGGER statement.\n    */\n    zRet = sqlite3MPrintf(db, \"%.*s\\\"%w\\\"%s\", (int)(((u8*)tname.z) - zSql),\n       zSql, zTableName, tname.z+tname.n);\n    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);\n  }\n}\n#endif   /* !SQLITE_OMIT_TRIGGER */\n\n/*\n** Register built-in functions used to help implement ALTER TABLE\n*/\nvoid sqlite3AlterFunctions(void){\n  static FuncDef aAlterTableFuncs[] = {\n    FUNCTION(sqlite_rename_table,   2, 0, 0, renameTableFunc),\n#ifndef SQLITE_OMIT_TRIGGER\n    FUNCTION(sqlite_rename_trigger, 2, 0, 0, renameTriggerFunc),\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    FUNCTION(sqlite_rename_parent,  3, 0, 0, renameParentFunc),\n#endif\n  };\n  sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));\n}\n\n/*\n** This function is used to create the text of expressions of the form:\n**\n**   name=<constant1> OR name=<constant2> OR ...\n**\n** If argument zWhere is NULL, then a pointer string containing the text \n** \"name=<constant>\" is returned, where <constant> is the quoted version\n** of the string passed as argument zConstant. The returned buffer is\n** allocated using sqlite3DbMalloc(). It is the responsibility of the\n** caller to ensure that it is eventually freed.\n**\n** If argument zWhere is not NULL, then the string returned is \n** \"<where> OR name=<constant>\", where <where> is the contents of zWhere.\n** In this case zWhere is passed to sqlite3DbFree() before returning.\n** \n*/\nstatic char *whereOrName(sqlite3 *db, char *zWhere, char *zConstant){\n  char *zNew;\n  if( !zWhere ){\n    zNew = sqlite3MPrintf(db, \"name=%Q\", zConstant);\n  }else{\n    zNew = sqlite3MPrintf(db, \"%s OR name=%Q\", zWhere, zConstant);\n    sqlite3DbFree(db, zWhere);\n  }\n  return zNew;\n}\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** tables that have foreign key constraints that refer to table pTab (i.e.\n** constraints for which pTab is the parent table) from the sqlite_master\n** table.\n*/\nstatic char *whereForeignKeys(Parse *pParse, Table *pTab){\n  FKey *p;\n  char *zWhere = 0;\n  for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n    zWhere = whereOrName(pParse->db, zWhere, p->pFrom->zName);\n  }\n  return zWhere;\n}\n#endif\n\n/*\n** Generate the text of a WHERE expression which can be used to select all\n** temporary triggers on table pTab from the sqlite_temp_master table. If\n** table pTab has no temporary triggers, or is itself stored in the \n** temporary database, NULL is returned.\n*/\nstatic char *whereTempTriggers(Parse *pParse, Table *pTab){\n  Trigger *pTrig;\n  char *zWhere = 0;\n  const Schema *pTempSchema = pParse->db->aDb[1].pSchema; /* Temp db schema */\n\n  /* If the table is not located in the temp-db (in which case NULL is \n  ** returned, loop through the tables list of triggers. For each trigger\n  ** that is not part of the temp-db schema, add a clause to the WHERE \n  ** expression being built up in zWhere.\n  */\n  if( pTab->pSchema!=pTempSchema ){\n    sqlite3 *db = pParse->db;\n    for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n      if( pTrig->pSchema==pTempSchema ){\n        zWhere = whereOrName(db, zWhere, pTrig->zName);\n      }\n    }\n  }\n  if( zWhere ){\n    char *zNew = sqlite3MPrintf(pParse->db, \"type='trigger' AND (%s)\", zWhere);\n    sqlite3DbFree(pParse->db, zWhere);\n    zWhere = zNew;\n  }\n  return zWhere;\n}\n\n/*\n** Generate code to drop and reload the internal representation of table\n** pTab from the database, including triggers and temporary triggers.\n** Argument zName is the name of the table in the database schema at\n** the time the generated code is executed. This can be different from\n** pTab->zName if this function is being called to code part of an \n** \"ALTER TABLE RENAME TO\" statement.\n*/\nstatic void reloadTableSchema(Parse *pParse, Table *pTab, const char *zName){\n  Vdbe *v;\n  char *zWhere;\n  int iDb;                   /* Index of database containing pTab */\n#ifndef SQLITE_OMIT_TRIGGER\n  Trigger *pTrig;\n#endif\n\n  v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  assert( iDb>=0 );\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Drop any table triggers from the internal schema. */\n  for(pTrig=sqlite3TriggerList(pParse, pTab); pTrig; pTrig=pTrig->pNext){\n    int iTrigDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n    assert( iTrigDb==iDb || iTrigDb==1 );\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iTrigDb, 0, 0, pTrig->zName, 0);\n  }\n#endif\n\n  /* Drop the table and index from the internal schema.  */\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n\n  /* Reload the table, index and permanent trigger schemas. */\n  zWhere = sqlite3MPrintf(pParse->db, \"tbl_name=%Q\", zName);\n  if( !zWhere ) return;\n  sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* Now, if the table is not stored in the temp database, reload any temp \n  ** triggers. Don't use IN(...) in case SQLITE_OMIT_SUBQUERY is defined. \n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3VdbeAddParseSchemaOp(v, 1, zWhere);\n  }\n#endif\n}\n\n/*\n** Parameter zName is the name of a table that is about to be altered\n** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).\n** If the table is a system table, this function leaves an error message\n** in pParse->zErr (system tables may not be altered) and returns non-zero.\n**\n** Or, if zName is not a system table, zero is returned.\n*/\nstatic int isSystemTable(Parse *pParse, const char *zName){\n  if( 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be altered\", zName);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Generate code to implement the \"ALTER TABLE xxx RENAME TO yyy\" \n** command. \n*/\nvoid sqlite3AlterRenameTable(\n  Parse *pParse,            /* Parser context. */\n  SrcList *pSrc,            /* The table to rename. */\n  Token *pName              /* The new table name. */\n){\n  int iDb;                  /* Database that contains the table */\n  char *zDb;                /* Name of database iDb */\n  Table *pTab;              /* Table being renamed */\n  char *zName = 0;          /* NULL-terminated version of pName */ \n  sqlite3 *db = pParse->db; /* Database connection */\n  int nTabName;             /* Number of UTF-8 characters in zTabName */\n  const char *zTabName;     /* Original name of the table */\n  Vdbe *v;\n#ifndef SQLITE_OMIT_TRIGGER\n  char *zWhere = 0;         /* Where clause to locate temp triggers */\n#endif\n  VTable *pVTab = 0;        /* Non-zero if this is a v-tab with an xRename() */\n  u32 savedDbFlags;         /* Saved value of db->mDbFlags */\n\n  savedDbFlags = db->mDbFlags;  \n  if( NEVER(db->mallocFailed) ) goto exit_rename_table;\n  assert( pSrc->nSrc==1 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_rename_table;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  db->mDbFlags |= DBFLAG_PreferBuiltin;\n\n  /* Get a NULL terminated version of the new table name. */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName ) goto exit_rename_table;\n\n  /* Check that a table or index named 'zName' does not already exist\n  ** in database iDb. If so, this is an error.\n  */\n  if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){\n    sqlite3ErrorMsg(pParse, \n        \"there is already another table or index with this name: %s\", zName);\n    goto exit_rename_table;\n  }\n\n  /* Make sure it is not a system table being altered, or a reserved name\n  ** that the table is being renamed to.\n  */\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_rename_table;\n  }\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto\n    exit_rename_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"view %s may not be altered\", pTab->zName);\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    goto exit_rename_table;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_rename_table;\n  }\n  if( IsVirtual(pTab) ){\n    pVTab = sqlite3GetVTable(db, pTab);\n    if( pVTab->pVtab->pModule->xRename==0 ){\n      pVTab = 0;\n    }\n  }\n#endif\n\n  /* Begin a transaction for database iDb. \n  ** Then modify the schema cookie (since the ALTER TABLE modifies the\n  ** schema). Open a statement transaction if the table is a virtual\n  ** table.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto exit_rename_table;\n  }\n  sqlite3BeginWriteOperation(pParse, pVTab!=0, iDb);\n  sqlite3ChangeCookie(pParse, iDb);\n\n  /* If this is a virtual table, invoke the xRename() function if\n  ** one is defined. The xRename() callback will modify the names\n  ** of any resources used by the v-table implementation (including other\n  ** SQLite tables) that are identified by the name of the virtual table.\n  */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( pVTab ){\n    int i = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, i, zName);\n    sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB);\n    sqlite3MayAbort(pParse);\n  }\n#endif\n\n  /* figure out how many UTF-8 characters are in zName */\n  zTabName = pTab->zName;\n  nTabName = sqlite3Utf8CharLen(zTabName, -1);\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    /* If foreign-key support is enabled, rewrite the CREATE TABLE \n    ** statements corresponding to all child tables of foreign key constraints\n    ** for which the renamed table is the parent table.  */\n    if( (zWhere=whereForeignKeys(pParse, pTab))!=0 ){\n      sqlite3NestedParse(pParse, \n          \"UPDATE \\\"%w\\\".%s SET \"\n              \"sql = sqlite_rename_parent(sql, %Q, %Q) \"\n              \"WHERE %s;\", zDb, MASTER_NAME, zTabName, zName, zWhere);\n      sqlite3DbFree(db, zWhere);\n    }\n  }\n#endif\n\n  /* Modify the sqlite_master table to use the new table name. */\n  sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s SET \"\n#ifdef SQLITE_OMIT_TRIGGER\n          \"sql = sqlite_rename_table(sql, %Q), \"\n#else\n          \"sql = CASE \"\n            \"WHEN type = 'trigger' THEN sqlite_rename_trigger(sql, %Q)\"\n            \"ELSE sqlite_rename_table(sql, %Q) END, \"\n#endif\n          \"tbl_name = %Q, \"\n          \"name = CASE \"\n            \"WHEN type='table' THEN %Q \"\n            \"WHEN name LIKE 'sqlite_autoindex%%' AND type='index' THEN \"\n             \"'sqlite_autoindex_' || %Q || substr(name,%d+18) \"\n            \"ELSE name END \"\n      \"WHERE tbl_name=%Q COLLATE nocase AND \"\n          \"(type='table' OR type='index' OR type='trigger');\", \n      zDb, MASTER_NAME, zName, zName, zName, \n#ifndef SQLITE_OMIT_TRIGGER\n      zName,\n#endif\n      zName, nTabName, zTabName\n  );\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* If the sqlite_sequence table exists in this database, then update \n  ** it with the new table name.\n  */\n  if( sqlite3FindTable(db, \"sqlite_sequence\", zDb) ){\n    sqlite3NestedParse(pParse,\n        \"UPDATE \\\"%w\\\".sqlite_sequence set name = %Q WHERE name = %Q\",\n        zDb, zName, pTab->zName);\n  }\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* If there are TEMP triggers on this table, modify the sqlite_temp_master\n  ** table. Don't do this if the table being ALTERed is itself located in\n  ** the temp database.\n  */\n  if( (zWhere=whereTempTriggers(pParse, pTab))!=0 ){\n    sqlite3NestedParse(pParse, \n        \"UPDATE sqlite_temp_master SET \"\n            \"sql = sqlite_rename_trigger(sql, %Q), \"\n            \"tbl_name = %Q \"\n            \"WHERE %s;\", zName, zName, zWhere);\n    sqlite3DbFree(db, zWhere);\n  }\n#endif\n\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  if( db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Table *pFrom = p->pFrom;\n      if( pFrom!=pTab ){\n        reloadTableSchema(pParse, p->pFrom, pFrom->zName);\n      }\n    }\n  }\n#endif\n\n  /* Drop and reload the internal table schema. */\n  reloadTableSchema(pParse, pTab, zName);\n\nexit_rename_table:\n  sqlite3SrcListDelete(db, pSrc);\n  sqlite3DbFree(db, zName);\n  db->mDbFlags = savedDbFlags;\n}\n\n/*\n** This function is called after an \"ALTER TABLE ... ADD\" statement\n** has been parsed. Argument pColDef contains the text of the new\n** column definition.\n**\n** The Table structure pParse->pNewTable was extended to include\n** the new column during parsing.\n*/\nvoid sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){\n  Table *pNew;              /* Copy of pParse->pNewTable */\n  Table *pTab;              /* Table being altered */\n  int iDb;                  /* Database number */\n  const char *zDb;          /* Database name */\n  const char *zTab;         /* Table name */\n  char *zCol;               /* Null-terminated column definition */\n  Column *pCol;             /* The new column */\n  Expr *pDflt;              /* Default value for the new column */\n  sqlite3 *db;              /* The database connection; */\n  Vdbe *v = pParse->pVdbe;  /* The prepared statement under construction */\n  int r1;                   /* Temporary registers */\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ) return;\n  assert( v!=0 );\n  pNew = pParse->pNewTable;\n  assert( pNew );\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pNew->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n  zTab = &pNew->zName[16];  /* Skip the \"sqlite_altertab_\" prefix on the name */\n  pCol = &pNew->aCol[pNew->nCol-1];\n  pDflt = pCol->pDflt;\n  pTab = sqlite3FindTable(db, zTab, zDb);\n  assert( pTab );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Invoke the authorization callback. */\n  if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){\n    return;\n  }\n#endif\n\n  /* If the default value for the new column was specified with a \n  ** literal NULL, then set pDflt to 0. This simplifies checking\n  ** for an SQL NULL default below.\n  */\n  assert( pDflt==0 || pDflt->op==TK_SPAN );\n  if( pDflt && pDflt->pLeft->op==TK_NULL ){\n    pDflt = 0;\n  }\n\n  /* Check that the new column is not specified as PRIMARY KEY or UNIQUE.\n  ** If there is a NOT NULL constraint, then the default value for the\n  ** column must not be NULL.\n  */\n  if( pCol->colFlags & COLFLAG_PRIMKEY ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a PRIMARY KEY column\");\n    return;\n  }\n  if( pNew->pIndex ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a UNIQUE column\");\n    return;\n  }\n  if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a REFERENCES column with non-NULL default value\");\n    return;\n  }\n  if( pCol->notNull && !pDflt ){\n    sqlite3ErrorMsg(pParse, \n        \"Cannot add a NOT NULL column with default value NULL\");\n    return;\n  }\n\n  /* Ensure the default expression is something that sqlite3ValueFromExpr()\n  ** can handle (i.e. not CURRENT_TIME etc.)\n  */\n  if( pDflt ){\n    sqlite3_value *pVal = 0;\n    int rc;\n    rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_BLOB, &pVal);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc!=SQLITE_OK ){\n      assert( db->mallocFailed == 1 );\n      return;\n    }\n    if( !pVal ){\n      sqlite3ErrorMsg(pParse, \"Cannot add a column with non-constant default\");\n      return;\n    }\n    sqlite3ValueFree(pVal);\n  }\n\n  /* Modify the CREATE TABLE statement. */\n  zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);\n  if( zCol ){\n    char *zEnd = &zCol[pColDef->n-1];\n    u32 savedDbFlags = db->mDbFlags;\n    while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){\n      *zEnd-- = '\\0';\n    }\n    db->mDbFlags |= DBFLAG_PreferBuiltin;\n    sqlite3NestedParse(pParse, \n        \"UPDATE \\\"%w\\\".%s SET \"\n          \"sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) \"\n        \"WHERE type = 'table' AND name = %Q\", \n      zDb, MASTER_NAME, pNew->addColOffset, zCol, pNew->addColOffset+1,\n      zTab\n    );\n    sqlite3DbFree(db, zCol);\n    db->mDbFlags = savedDbFlags;\n  }\n\n  /* Make sure the schema version is at least 3.  But do not upgrade\n  ** from less than 3 to 4, as that will corrupt any preexisting DESC\n  ** index.\n  */\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);\n  sqlite3VdbeUsesBtree(v, iDb);\n  sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);\n  sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);\n  sqlite3ReleaseTempReg(pParse, r1);\n\n  /* Reload the schema of the modified table. */\n  reloadTableSchema(pParse, pTab, pTab->zName);\n}\n\n/*\n** This function is called by the parser after the table-name in\n** an \"ALTER TABLE <table-name> ADD\" statement is parsed. Argument \n** pSrc is the full-name of the table being altered.\n**\n** This routine makes a (partial) copy of the Table structure\n** for the table being altered and sets Parse.pNewTable to point\n** to it. Routines called by the parser as the column definition\n** is parsed (i.e. sqlite3AddColumn()) add the new Column data to \n** the copy. The copy of the Table structure is deleted by tokenize.c \n** after parsing is finished.\n**\n** Routine sqlite3AlterFinishAddColumn() will be called to complete\n** coding the \"ALTER TABLE ... ADD\" statement.\n*/\nvoid sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){\n  Table *pNew;\n  Table *pTab;\n  Vdbe *v;\n  int iDb;\n  int i;\n  int nAlloc;\n  sqlite3 *db = pParse->db;\n\n  /* Look up the table being altered. */\n  assert( pParse->pNewTable==0 );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  if( db->mallocFailed ) goto exit_begin_add_column;\n  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);\n  if( !pTab ) goto exit_begin_add_column;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be altered\");\n    goto exit_begin_add_column;\n  }\n#endif\n\n  /* Make sure this is not an attempt to ALTER a view. */\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"Cannot add a column to a view\");\n    goto exit_begin_add_column;\n  }\n  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){\n    goto exit_begin_add_column;\n  }\n\n  assert( pTab->addColOffset>0 );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n\n  /* Put a copy of the Table struct in Parse.pNewTable for the\n  ** sqlite3AddColumn() function and friends to modify.  But modify\n  ** the name by adding an \"sqlite_altertab_\" prefix.  By adding this\n  ** prefix, we insure that the name will not collide with an existing\n  ** table because user table are not allowed to have the \"sqlite_\"\n  ** prefix on their name.\n  */\n  pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));\n  if( !pNew ) goto exit_begin_add_column;\n  pParse->pNewTable = pNew;\n  pNew->nTabRef = 1;\n  pNew->nCol = pTab->nCol;\n  assert( pNew->nCol>0 );\n  nAlloc = (((pNew->nCol-1)/8)*8)+8;\n  assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );\n  pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);\n  pNew->zName = sqlite3MPrintf(db, \"sqlite_altertab_%s\", pTab->zName);\n  if( !pNew->aCol || !pNew->zName ){\n    assert( db->mallocFailed );\n    goto exit_begin_add_column;\n  }\n  memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol);\n  for(i=0; i<pNew->nCol; i++){\n    Column *pCol = &pNew->aCol[i];\n    pCol->zName = sqlite3DbStrDup(db, pCol->zName);\n    pCol->zColl = 0;\n    pCol->pDflt = 0;\n  }\n  pNew->pSchema = db->aDb[iDb].pSchema;\n  pNew->addColOffset = pTab->addColOffset;\n  pNew->nTabRef = 1;\n\n  /* Begin a transaction and increment the schema cookie.  */\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) goto exit_begin_add_column;\n  sqlite3ChangeCookie(pParse, iDb);\n\nexit_begin_add_column:\n  sqlite3SrcListDelete(db, pSrc);\n  return;\n}\n#endif  /* SQLITE_ALTER_TABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/analyze.c",
    "content": "/*\n** 2005-07-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code associated with the ANALYZE command.\n**\n** The ANALYZE command gather statistics about the content of tables\n** and indices.  These statistics are made available to the query planner\n** to help it make better decisions about how to perform queries.\n**\n** The following system tables are or have been supported:\n**\n**    CREATE TABLE sqlite_stat1(tbl, idx, stat);\n**    CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);\n**    CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);\n**    CREATE TABLE sqlite_stat4(tbl, idx, nEq, nLt, nDLt, sample);\n**\n** Additional tables might be added in future releases of SQLite.\n** The sqlite_stat2 table is not created or used unless the SQLite version\n** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled\n** with SQLITE_ENABLE_STAT2.  The sqlite_stat2 table is deprecated.\n** The sqlite_stat2 table is superseded by sqlite_stat3, which is only\n** created and used by SQLite versions 3.7.9 and later and with\n** SQLITE_ENABLE_STAT3 defined.  The functionality of sqlite_stat3\n** is a superset of sqlite_stat2.  The sqlite_stat4 is an enhanced\n** version of sqlite_stat3 and is only available when compiled with\n** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later.  It is\n** not possible to enable both STAT3 and STAT4 at the same time.  If they\n** are both enabled, then STAT4 takes precedence.\n**\n** For most applications, sqlite_stat1 provides all the statistics required\n** for the query planner to make good choices.\n**\n** Format of sqlite_stat1:\n**\n** There is normally one row per index, with the index identified by the\n** name in the idx column.  The tbl column is the name of the table to\n** which the index belongs.  In each such row, the stat column will be\n** a string consisting of a list of integers.  The first integer in this\n** list is the number of rows in the index.  (This is the same as the\n** number of rows in the table, except for partial indices.)  The second\n** integer is the average number of rows in the index that have the same\n** value in the first column of the index.  The third integer is the average\n** number of rows in the index that have the same value for the first two\n** columns.  The N-th integer (for N>1) is the average number of rows in \n** the index which have the same value for the first N-1 columns.  For\n** a K-column index, there will be K+1 integers in the stat column.  If\n** the index is unique, then the last integer will be 1.\n**\n** The list of integers in the stat column can optionally be followed\n** by the keyword \"unordered\".  The \"unordered\" keyword, if it is present,\n** must be separated from the last integer by a single space.  If the\n** \"unordered\" keyword is present, then the query planner assumes that\n** the index is unordered and will not use the index for a range query.\n** \n** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat\n** column contains a single integer which is the (estimated) number of\n** rows in the table identified by sqlite_stat1.tbl.\n**\n** Format of sqlite_stat2:\n**\n** The sqlite_stat2 is only created and is only used if SQLite is compiled\n** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between\n** 3.6.18 and 3.7.8.  The \"stat2\" table contains additional information\n** about the distribution of keys within an index.  The index is identified by\n** the \"idx\" column and the \"tbl\" column is the name of the table to which\n** the index belongs.  There are usually 10 rows in the sqlite_stat2\n** table for each index.\n**\n** The sqlite_stat2 entries for an index that have sampleno between 0 and 9\n** inclusive are samples of the left-most key value in the index taken at\n** evenly spaced points along the index.  Let the number of samples be S\n** (10 in the standard build) and let C be the number of rows in the index.\n** Then the sampled rows are given by:\n**\n**     rownumber = (i*C*2 + C)/(S*2)\n**\n** For i between 0 and S-1.  Conceptually, the index space is divided into\n** S uniform buckets and the samples are the middle row from each bucket.\n**\n** The format for sqlite_stat2 is recorded here for legacy reference.  This\n** version of SQLite does not support sqlite_stat2.  It neither reads nor\n** writes the sqlite_stat2 table.  This version of SQLite only supports\n** sqlite_stat3.\n**\n** Format for sqlite_stat3:\n**\n** The sqlite_stat3 format is a subset of sqlite_stat4.  Hence, the\n** sqlite_stat4 format will be described first.  Further information\n** about sqlite_stat3 follows the sqlite_stat4 description.\n**\n** Format for sqlite_stat4:\n**\n** As with sqlite_stat2, the sqlite_stat4 table contains histogram data\n** to aid the query planner in choosing good indices based on the values\n** that indexed columns are compared against in the WHERE clauses of\n** queries.\n**\n** The sqlite_stat4 table contains multiple entries for each index.\n** The idx column names the index and the tbl column is the table of the\n** index.  If the idx and tbl columns are the same, then the sample is\n** of the INTEGER PRIMARY KEY.  The sample column is a blob which is the\n** binary encoding of a key from the index.  The nEq column is a\n** list of integers.  The first integer is the approximate number\n** of entries in the index whose left-most column exactly matches\n** the left-most column of the sample.  The second integer in nEq\n** is the approximate number of entries in the index where the\n** first two columns match the first two columns of the sample.\n** And so forth.  nLt is another list of integers that show the approximate\n** number of entries that are strictly less than the sample.  The first\n** integer in nLt contains the number of entries in the index where the\n** left-most column is less than the left-most column of the sample.\n** The K-th integer in the nLt entry is the number of index entries \n** where the first K columns are less than the first K columns of the\n** sample.  The nDLt column is like nLt except that it contains the \n** number of distinct entries in the index that are less than the\n** sample.\n**\n** There can be an arbitrary number of sqlite_stat4 entries per index.\n** The ANALYZE command will typically generate sqlite_stat4 tables\n** that contain between 10 and 40 samples which are distributed across\n** the key space, though not uniformly, and which include samples with\n** large nEq values.\n**\n** Format for sqlite_stat3 redux:\n**\n** The sqlite_stat3 table is like sqlite_stat4 except that it only\n** looks at the left-most column of the index.  The sqlite_stat3.sample\n** column contains the actual value of the left-most column instead\n** of a blob encoding of the complete index key as is found in\n** sqlite_stat4.sample.  The nEq, nLt, and nDLt entries of sqlite_stat3\n** all contain just a single integer which is the same as the first\n** integer in the equivalent columns in sqlite_stat4.\n*/\n#ifndef SQLITE_OMIT_ANALYZE\n#include \"sqliteInt.h\"\n\n#if defined(SQLITE_ENABLE_STAT4)\n# define IsStat4     1\n# define IsStat3     0\n#elif defined(SQLITE_ENABLE_STAT3)\n# define IsStat4     0\n# define IsStat3     1\n#else\n# define IsStat4     0\n# define IsStat3     0\n# undef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 1\n#endif\n#define IsStat34    (IsStat3+IsStat4)  /* 1 for STAT3 or STAT4. 0 otherwise */\n\n/*\n** This routine generates code that opens the sqlite_statN tables.\n** The sqlite_stat1 table is always relevant.  sqlite_stat2 is now\n** obsolete.  sqlite_stat3 and sqlite_stat4 are only opened when\n** appropriate compile-time options are provided.\n**\n** If the sqlite_statN tables do not previously exist, it is created.\n**\n** Argument zWhere may be a pointer to a buffer containing a table name,\n** or it may be a NULL pointer. If it is not NULL, then all entries in\n** the sqlite_statN tables associated with the named table are deleted.\n** If zWhere==0, then code is generated to delete all stat table entries.\n*/\nstatic void openStatTable(\n  Parse *pParse,          /* Parsing context */\n  int iDb,                /* The database we are looking in */\n  int iStatCur,           /* Open the sqlite_stat1 table on this cursor */\n  const char *zWhere,     /* Delete entries for this table or index */\n  const char *zWhereType  /* Either \"tbl\" or \"idx\" */\n){\n  static const struct {\n    const char *zName;\n    const char *zCols;\n  } aTable[] = {\n    { \"sqlite_stat1\", \"tbl,idx,stat\" },\n#if defined(SQLITE_ENABLE_STAT4)\n    { \"sqlite_stat4\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat3\", 0 },\n#elif defined(SQLITE_ENABLE_STAT3)\n    { \"sqlite_stat3\", \"tbl,idx,neq,nlt,ndlt,sample\" },\n    { \"sqlite_stat4\", 0 },\n#else\n    { \"sqlite_stat3\", 0 },\n    { \"sqlite_stat4\", 0 },\n#endif\n  };\n  int i;\n  sqlite3 *db = pParse->db;\n  Db *pDb;\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int aRoot[ArraySize(aTable)];\n  u8 aCreateTbl[ArraySize(aTable)];\n\n  if( v==0 ) return;\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3VdbeDb(v)==db );\n  pDb = &db->aDb[iDb];\n\n  /* Create new statistic tables if they do not exist, or clear them\n  ** if they do already exist.\n  */\n  for(i=0; i<ArraySize(aTable); i++){\n    const char *zTab = aTable[i].zName;\n    Table *pStat;\n    if( (pStat = sqlite3FindTable(db, zTab, pDb->zDbSName))==0 ){\n      if( aTable[i].zCols ){\n        /* The sqlite_statN table does not exist. Create it. Note that a \n        ** side-effect of the CREATE TABLE statement is to leave the rootpage \n        ** of the new table in register pParse->regRoot. This is important \n        ** because the OpenWrite opcode below will be needing it. */\n        sqlite3NestedParse(pParse,\n            \"CREATE TABLE %Q.%s(%s)\", pDb->zDbSName, zTab, aTable[i].zCols\n        );\n        aRoot[i] = pParse->regRoot;\n        aCreateTbl[i] = OPFLAG_P2ISREG;\n      }\n    }else{\n      /* The table already exists. If zWhere is not NULL, delete all entries \n      ** associated with the table zWhere. If zWhere is NULL, delete the\n      ** entire contents of the table. */\n      aRoot[i] = pStat->tnum;\n      aCreateTbl[i] = 0;\n      sqlite3TableLock(pParse, iDb, aRoot[i], 1, zTab);\n      if( zWhere ){\n        sqlite3NestedParse(pParse,\n           \"DELETE FROM %Q.%s WHERE %s=%Q\",\n           pDb->zDbSName, zTab, zWhereType, zWhere\n        );\n      }else{\n        /* The sqlite_stat[134] table already exists.  Delete all rows. */\n        sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb);\n      }\n    }\n  }\n\n  /* Open the sqlite_stat[134] tables for writing. */\n  for(i=0; aTable[i].zCols; i++){\n    assert( i<ArraySize(aTable) );\n    sqlite3VdbeAddOp4Int(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb, 3);\n    sqlite3VdbeChangeP5(v, aCreateTbl[i]);\n    VdbeComment((v, aTable[i].zName));\n  }\n}\n\n/*\n** Recommended number of samples for sqlite_stat4\n*/\n#ifndef SQLITE_STAT4_SAMPLES\n# define SQLITE_STAT4_SAMPLES 24\n#endif\n\n/*\n** Three SQL functions - stat_init(), stat_push(), and stat_get() -\n** share an instance of the following structure to hold their state\n** information.\n*/\ntypedef struct Stat4Accum Stat4Accum;\ntypedef struct Stat4Sample Stat4Sample;\nstruct Stat4Sample {\n  tRowcnt *anEq;                  /* sqlite_stat4.nEq */\n  tRowcnt *anDLt;                 /* sqlite_stat4.nDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  tRowcnt *anLt;                  /* sqlite_stat4.nLt */\n  union {\n    i64 iRowid;                     /* Rowid in main table of the key */\n    u8 *aRowid;                     /* Key for WITHOUT ROWID tables */\n  } u;\n  u32 nRowid;                     /* Sizeof aRowid[] */\n  u8 isPSample;                   /* True if a periodic sample */\n  int iCol;                       /* If !isPSample, the reason for inclusion */\n  u32 iHash;                      /* Tiebreaker hash */\n#endif\n};                                                    \nstruct Stat4Accum {\n  tRowcnt nRow;             /* Number of rows in the entire table */\n  tRowcnt nPSample;         /* How often to do a periodic sample */\n  int nCol;                 /* Number of columns in index + pk/rowid */\n  int nKeyCol;              /* Number of index columns w/o the pk/rowid */\n  int mxSample;             /* Maximum number of samples to accumulate */\n  Stat4Sample current;      /* Current row as a Stat4Sample */\n  u32 iPrn;                 /* Pseudo-random number used for sampling */\n  Stat4Sample *aBest;       /* Array of nCol best samples */\n  int iMin;                 /* Index in a[] of entry with minimum score */\n  int nSample;              /* Current number of samples */\n  int nMaxEqZero;           /* Max leading 0 in anEq[] for any a[] entry */\n  int iGet;                 /* Index of current sample accessed by stat_get() */\n  Stat4Sample *a;           /* Array of mxSample Stat4Sample objects */\n  sqlite3 *db;              /* Database connection, for malloc() */\n};\n\n/* Reclaim memory used by a Stat4Sample\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleClear(sqlite3 *db, Stat4Sample *p){\n  assert( db!=0 );\n  if( p->nRowid ){\n    sqlite3DbFree(db, p->u.aRowid);\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the BLOB value of a ROWID\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->u.aRowid = sqlite3DbMallocRawNN(db, n);\n  if( p->u.aRowid ){\n    p->nRowid = n;\n    memcpy(p->u.aRowid, pData, n);\n  }else{\n    p->nRowid = 0;\n  }\n}\n#endif\n\n/* Initialize the INTEGER value of a ROWID.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){\n  assert( db!=0 );\n  if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid);\n  p->nRowid = 0;\n  p->u.iRowid = iRowid;\n}\n#endif\n\n\n/*\n** Copy the contents of object (*pFrom) into (*pTo).\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){\n  pTo->isPSample = pFrom->isPSample;\n  pTo->iCol = pFrom->iCol;\n  pTo->iHash = pFrom->iHash;\n  memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol);\n  memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol);\n  if( pFrom->nRowid ){\n    sampleSetRowid(p->db, pTo, pFrom->nRowid, pFrom->u.aRowid);\n  }else{\n    sampleSetRowidInt64(p->db, pTo, pFrom->u.iRowid);\n  }\n}\n#endif\n\n/*\n** Reclaim all memory of a Stat4Accum structure.\n*/\nstatic void stat4Destructor(void *pOld){\n  Stat4Accum *p = (Stat4Accum*)pOld;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int i;\n  for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i);\n  for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);\n  sampleClear(p->db, &p->current);\n#endif\n  sqlite3DbFree(p->db, p);\n}\n\n/*\n** Implementation of the stat_init(N,K,C) SQL function. The three parameters\n** are:\n**     N:    The number of columns in the index including the rowid/pk (note 1)\n**     K:    The number of columns in the index excluding the rowid/pk.\n**     C:    The number of rows in the index (note 2)\n**\n** Note 1:  In the special case of the covering index that implements a\n** WITHOUT ROWID table, N is the number of PRIMARY KEY columns, not the\n** total number of columns in the table.\n**\n** Note 2:  C is only used for STAT3 and STAT4.\n**\n** For indexes on ordinary rowid tables, N==K+1.  But for indexes on\n** WITHOUT ROWID tables, N=K+P where P is the number of columns in the\n** PRIMARY KEY of the table.  The covering index that implements the\n** original WITHOUT ROWID table as N==K as a special case.\n**\n** This routine allocates the Stat4Accum object in heap memory. The return \n** value is a pointer to the Stat4Accum object.  The datatype of the\n** return value is BLOB, but it is really just a pointer to the Stat4Accum\n** object.\n*/\nstatic void statInit(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p;\n  int nCol;                       /* Number of columns in index being sampled */\n  int nKeyCol;                    /* Number of key columns */\n  int nColUp;                     /* nCol rounded up for alignment */\n  int n;                          /* Bytes of space to allocate */\n  sqlite3 *db;                    /* Database connection */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int mxSample = SQLITE_STAT4_SAMPLES;\n#endif\n\n  /* Decode the three function arguments */\n  UNUSED_PARAMETER(argc);\n  nCol = sqlite3_value_int(argv[0]);\n  assert( nCol>0 );\n  nColUp = sizeof(tRowcnt)<8 ? (nCol+1)&~1 : nCol;\n  nKeyCol = sqlite3_value_int(argv[1]);\n  assert( nKeyCol<=nCol );\n  assert( nKeyCol>0 );\n\n  /* Allocate the space required for the Stat4Accum object */\n  n = sizeof(*p) \n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anEq */\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anDLt */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anLt */\n    + sizeof(Stat4Sample)*(nCol+mxSample)     /* Stat4Accum.aBest[], a[] */\n    + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample)\n#endif\n  ;\n  db = sqlite3_context_db_handle(context);\n  p = sqlite3DbMallocZero(db, n);\n  if( p==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n\n  p->db = db;\n  p->nRow = 0;\n  p->nCol = nCol;\n  p->nKeyCol = nKeyCol;\n  p->current.anDLt = (tRowcnt*)&p[1];\n  p->current.anEq = &p->current.anDLt[nColUp];\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  {\n    u8 *pSpace;                     /* Allocated space not yet assigned */\n    int i;                          /* Used to iterate through p->aSample[] */\n\n    p->iGet = -1;\n    p->mxSample = mxSample;\n    p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1);\n    p->current.anLt = &p->current.anEq[nColUp];\n    p->iPrn = 0x689e962d*(u32)nCol ^ 0xd0944565*(u32)sqlite3_value_int(argv[2]);\n  \n    /* Set up the Stat4Accum.a[] and aBest[] arrays */\n    p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];\n    p->aBest = &p->a[mxSample];\n    pSpace = (u8*)(&p->a[mxSample+nCol]);\n    for(i=0; i<(mxSample+nCol); i++){\n      p->a[i].anEq = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n      p->a[i].anDLt = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);\n    }\n    assert( (pSpace - (u8*)p)==n );\n  \n    for(i=0; i<nCol; i++){\n      p->aBest[i].iCol = i;\n    }\n  }\n#endif\n\n  /* Return a pointer to the allocated object to the caller.  Note that\n  ** only the pointer (the 2nd parameter) matters.  The size of the object\n  ** (given by the 3rd parameter) is never used and can be any positive\n  ** value. */\n  sqlite3_result_blob(context, p, sizeof(*p), stat4Destructor);\n}\nstatic const FuncDef statInitFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statInit,        /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_init\",     /* zName */\n  {0}\n};\n\n#ifdef SQLITE_ENABLE_STAT4\n/*\n** pNew and pOld are both candidate non-periodic samples selected for \n** the same column (pNew->iCol==pOld->iCol). Ignoring this column and \n** considering only any trailing columns and the sample hash value, this\n** function returns true if sample pNew is to be preferred over pOld.\n** In other words, if we assume that the cardinalities of the selected\n** column for pNew and pOld are equal, is pNew to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid. \n*/\nstatic int sampleIsBetterPost(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  int nCol = pAccum->nCol;\n  int i;\n  assert( pNew->iCol==pOld->iCol );\n  for(i=pNew->iCol+1; i<nCol; i++){\n    if( pNew->anEq[i]>pOld->anEq[i] ) return 1;\n    if( pNew->anEq[i]<pOld->anEq[i] ) return 0;\n  }\n  if( pNew->iHash>pOld->iHash ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return true if pNew is to be preferred over pOld.\n**\n** This function assumes that for each argument sample, the contents of\n** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid. \n*/\nstatic int sampleIsBetter(\n  Stat4Accum *pAccum, \n  Stat4Sample *pNew, \n  Stat4Sample *pOld\n){\n  tRowcnt nEqNew = pNew->anEq[pNew->iCol];\n  tRowcnt nEqOld = pOld->anEq[pOld->iCol];\n\n  assert( pOld->isPSample==0 && pNew->isPSample==0 );\n  assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );\n\n  if( (nEqNew>nEqOld) ) return 1;\n#ifdef SQLITE_ENABLE_STAT4\n  if( nEqNew==nEqOld ){\n    if( pNew->iCol<pOld->iCol ) return 1;\n    return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));\n  }\n  return 0;\n#else\n  return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);\n#endif\n}\n\n/*\n** Copy the contents of sample *pNew into the p->a[] array. If necessary,\n** remove the least desirable sample from p->a[] to make room.\n*/\nstatic void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){\n  Stat4Sample *pSample = 0;\n  int i;\n\n  assert( IsStat4 || nEqZero==0 );\n\n#ifdef SQLITE_ENABLE_STAT4\n  /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0\n  ** values in the anEq[] array of any sample in Stat4Accum.a[]. In\n  ** other words, if nMaxEqZero is n, then it is guaranteed that there\n  ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */\n  if( nEqZero>p->nMaxEqZero ){\n    p->nMaxEqZero = nEqZero;\n  }\n  if( pNew->isPSample==0 ){\n    Stat4Sample *pUpgrade = 0;\n    assert( pNew->anEq[pNew->iCol]>0 );\n\n    /* This sample is being added because the prefix that ends in column \n    ** iCol occurs many times in the table. However, if we have already\n    ** added a sample that shares this prefix, there is no need to add\n    ** this one. Instead, upgrade the priority of the highest priority\n    ** existing sample that shares this prefix.  */\n    for(i=p->nSample-1; i>=0; i--){\n      Stat4Sample *pOld = &p->a[i];\n      if( pOld->anEq[pNew->iCol]==0 ){\n        if( pOld->isPSample ) return;\n        assert( pOld->iCol>pNew->iCol );\n        assert( sampleIsBetter(p, pNew, pOld) );\n        if( pUpgrade==0 || sampleIsBetter(p, pOld, pUpgrade) ){\n          pUpgrade = pOld;\n        }\n      }\n    }\n    if( pUpgrade ){\n      pUpgrade->iCol = pNew->iCol;\n      pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];\n      goto find_new_min;\n    }\n  }\n#endif\n\n  /* If necessary, remove sample iMin to make room for the new sample. */\n  if( p->nSample>=p->mxSample ){\n    Stat4Sample *pMin = &p->a[p->iMin];\n    tRowcnt *anEq = pMin->anEq;\n    tRowcnt *anLt = pMin->anLt;\n    tRowcnt *anDLt = pMin->anDLt;\n    sampleClear(p->db, pMin);\n    memmove(pMin, &pMin[1], sizeof(p->a[0])*(p->nSample-p->iMin-1));\n    pSample = &p->a[p->nSample-1];\n    pSample->nRowid = 0;\n    pSample->anEq = anEq;\n    pSample->anDLt = anDLt;\n    pSample->anLt = anLt;\n    p->nSample = p->mxSample-1;\n  }\n\n  /* The \"rows less-than\" for the rowid column must be greater than that\n  ** for the last sample in the p->a[] array. Otherwise, the samples would\n  ** be out of order. */\n#ifdef SQLITE_ENABLE_STAT4\n  assert( p->nSample==0 \n       || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );\n#endif\n\n  /* Insert the new sample */\n  pSample = &p->a[p->nSample];\n  sampleCopy(p, pSample, pNew);\n  p->nSample++;\n\n  /* Zero the first nEqZero entries in the anEq[] array. */\n  memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);\n\n#ifdef SQLITE_ENABLE_STAT4\n find_new_min:\n#endif\n  if( p->nSample>=p->mxSample ){\n    int iMin = -1;\n    for(i=0; i<p->mxSample; i++){\n      if( p->a[i].isPSample ) continue;\n      if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){\n        iMin = i;\n      }\n    }\n    assert( iMin>=0 );\n    p->iMin = iMin;\n  }\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Field iChng of the index being scanned has changed. So at this point\n** p->current contains a sample that reflects the previous row of the\n** index. The value of anEq[iChng] and subsequent anEq[] elements are\n** correct at this point.\n*/\nstatic void samplePushPrevious(Stat4Accum *p, int iChng){\n#ifdef SQLITE_ENABLE_STAT4\n  int i;\n\n  /* Check if any samples from the aBest[] array should be pushed\n  ** into IndexSample.a[] at this point.  */\n  for(i=(p->nCol-2); i>=iChng; i--){\n    Stat4Sample *pBest = &p->aBest[i];\n    pBest->anEq[i] = p->current.anEq[i];\n    if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){\n      sampleInsert(p, pBest, i);\n    }\n  }\n\n  /* Check that no sample contains an anEq[] entry with an index of\n  ** p->nMaxEqZero or greater set to zero. */\n  for(i=p->nSample-1; i>=0; i--){\n    int j;\n    for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );\n  }\n\n  /* Update the anEq[] fields of any samples already collected. */\n  if( iChng<p->nMaxEqZero ){\n    for(i=p->nSample-1; i>=0; i--){\n      int j;\n      for(j=iChng; j<p->nCol; j++){\n        if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];\n      }\n    }\n    p->nMaxEqZero = iChng;\n  }\n#endif\n\n#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)\n  if( iChng==0 ){\n    tRowcnt nLt = p->current.anLt[0];\n    tRowcnt nEq = p->current.anEq[0];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+nEq)/p->nPSample ){\n      p->current.isPSample = 1;\n      sampleInsert(p, &p->current, 0);\n      p->current.isPSample = 0;\n    }else \n\n    /* Or if it is a non-periodic sample. Add it in this case too. */\n    if( p->nSample<p->mxSample \n     || sampleIsBetter(p, &p->current, &p->a[p->iMin]) \n    ){\n      sampleInsert(p, &p->current, 0);\n    }\n  }\n#endif\n\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  UNUSED_PARAMETER( p );\n  UNUSED_PARAMETER( iChng );\n#endif\n}\n\n/*\n** Implementation of the stat_push SQL function:  stat_push(P,C,R)\n** Arguments:\n**\n**    P     Pointer to the Stat4Accum object created by stat_init()\n**    C     Index of left-most column to differ from previous row\n**    R     Rowid for the current row.  Might be a key record for\n**          WITHOUT ROWID tables.\n**\n** This SQL function always returns NULL.  It's purpose it to accumulate\n** statistical data and/or samples in the Stat4Accum object about the\n** index being analyzed.  The stat_get() SQL function will later be used to\n** extract relevant information for constructing the sqlite_statN tables.\n**\n** The R parameter is only used for STAT3 and STAT4\n*/\nstatic void statPush(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n\n  /* The three function arguments */\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n  int iChng = sqlite3_value_int(argv[1]);\n\n  UNUSED_PARAMETER( argc );\n  UNUSED_PARAMETER( context );\n  assert( p->nCol>0 );\n  assert( iChng<p->nCol );\n\n  if( p->nRow==0 ){\n    /* This is the first call to this function. Do initialization. */\n    for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;\n  }else{\n    /* Second and subsequent calls get processed here */\n    samplePushPrevious(p, iChng);\n\n    /* Update anDLt[], anLt[] and anEq[] to reflect the values that apply\n    ** to the current row of the index. */\n    for(i=0; i<iChng; i++){\n      p->current.anEq[i]++;\n    }\n    for(i=iChng; i<p->nCol; i++){\n      p->current.anDLt[i]++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n      p->current.anLt[i] += p->current.anEq[i];\n#endif\n      p->current.anEq[i] = 1;\n    }\n  }\n  p->nRow++;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){\n    sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2]));\n  }else{\n    sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]),\n                                       sqlite3_value_blob(argv[2]));\n  }\n  p->current.iHash = p->iPrn = p->iPrn*1103515245 + 12345;\n#endif\n\n#ifdef SQLITE_ENABLE_STAT4\n  {\n    tRowcnt nLt = p->current.anLt[p->nCol-1];\n\n    /* Check if this is to be a periodic sample. If so, add it. */\n    if( (nLt/p->nPSample)!=(nLt+1)/p->nPSample ){\n      p->current.isPSample = 1;\n      p->current.iCol = 0;\n      sampleInsert(p, &p->current, p->nCol-1);\n      p->current.isPSample = 0;\n    }\n\n    /* Update the aBest[] array. */\n    for(i=0; i<(p->nCol-1); i++){\n      p->current.iCol = i;\n      if( i>=iChng || sampleIsBetterPost(p, &p->current, &p->aBest[i]) ){\n        sampleCopy(p, &p->aBest[i], &p->current);\n      }\n    }\n  }\n#endif\n}\nstatic const FuncDef statPushFuncdef = {\n  2+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statPush,        /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_push\",     /* zName */\n  {0}\n};\n\n#define STAT_GET_STAT1 0          /* \"stat\" column of stat1 table */\n#define STAT_GET_ROWID 1          /* \"rowid\" column of stat[34] entry */\n#define STAT_GET_NEQ   2          /* \"neq\" column of stat[34] entry */\n#define STAT_GET_NLT   3          /* \"nlt\" column of stat[34] entry */\n#define STAT_GET_NDLT  4          /* \"ndlt\" column of stat[34] entry */\n\n/*\n** Implementation of the stat_get(P,J) SQL function.  This routine is\n** used to query statistical information that has been gathered into\n** the Stat4Accum object by prior calls to stat_push().  The P parameter\n** has type BLOB but it is really just a pointer to the Stat4Accum object.\n** The content to returned is determined by the parameter J\n** which is one of the STAT_GET_xxxx values defined above.\n**\n** The stat_get(P,J) function is not available to generic SQL.  It is\n** inserted as part of a manually constructed bytecode program.  (See\n** the callStatGet() routine below.)  It is guaranteed that the P\n** parameter will always be a poiner to a Stat4Accum object, never a\n** NULL.\n**\n** If neither STAT3 nor STAT4 are enabled, then J is always\n** STAT_GET_STAT1 and is hence omitted and this routine becomes\n** a one-parameter function, stat_get(P), that always returns the\n** stat1 table entry information.\n*/\nstatic void statGet(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* STAT3 and STAT4 have a parameter on this routine. */\n  int eCall = sqlite3_value_int(argv[1]);\n  assert( argc==2 );\n  assert( eCall==STAT_GET_STAT1 || eCall==STAT_GET_NEQ \n       || eCall==STAT_GET_ROWID || eCall==STAT_GET_NLT\n       || eCall==STAT_GET_NDLT \n  );\n  if( eCall==STAT_GET_STAT1 )\n#else\n  assert( argc==1 );\n#endif\n  {\n    /* Return the value to store in the \"stat\" column of the sqlite_stat1\n    ** table for this index.\n    **\n    ** The value is a string composed of a list of integers describing \n    ** the index. The first integer in the list is the total number of \n    ** entries in the index. There is one additional integer in the list \n    ** for each indexed column. This additional integer is an estimate of\n    ** the number of rows matched by a stabbing query on the index using\n    ** a key with the corresponding number of fields. In other words,\n    ** if the index is on columns (a,b) and the sqlite_stat1 value is \n    ** \"100 10 2\", then SQLite estimates that:\n    **\n    **   * the index contains 100 rows,\n    **   * \"WHERE a=?\" matches 10 rows, and\n    **   * \"WHERE a=? AND b=?\" matches 2 rows.\n    **\n    ** If D is the count of distinct values and K is the total number of \n    ** rows, then each estimate is computed as:\n    **\n    **        I = (K+D-1)/D\n    */\n    char *z;\n    int i;\n\n    char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 );\n    if( zRet==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n\n    sqlite3_snprintf(24, zRet, \"%llu\", (u64)p->nRow);\n    z = zRet + sqlite3Strlen30(zRet);\n    for(i=0; i<p->nKeyCol; i++){\n      u64 nDistinct = p->current.anDLt[i] + 1;\n      u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;\n      sqlite3_snprintf(24, z, \" %llu\", iVal);\n      z += sqlite3Strlen30(z);\n      assert( p->current.anEq[i] );\n    }\n    assert( z[0]=='\\0' && z>zRet );\n\n    sqlite3_result_text(context, zRet, -1, sqlite3_free);\n  }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( eCall==STAT_GET_ROWID ){\n    if( p->iGet<0 ){\n      samplePushPrevious(p, 0);\n      p->iGet = 0;\n    }\n    if( p->iGet<p->nSample ){\n      Stat4Sample *pS = p->a + p->iGet;\n      if( pS->nRowid==0 ){\n        sqlite3_result_int64(context, pS->u.iRowid);\n      }else{\n        sqlite3_result_blob(context, pS->u.aRowid, pS->nRowid,\n                            SQLITE_TRANSIENT);\n      }\n    }\n  }else{\n    tRowcnt *aCnt = 0;\n\n    assert( p->iGet<p->nSample );\n    switch( eCall ){\n      case STAT_GET_NEQ:  aCnt = p->a[p->iGet].anEq; break;\n      case STAT_GET_NLT:  aCnt = p->a[p->iGet].anLt; break;\n      default: {\n        aCnt = p->a[p->iGet].anDLt; \n        p->iGet++;\n        break;\n      }\n    }\n\n    if( IsStat3 ){\n      sqlite3_result_int64(context, (i64)aCnt[0]);\n    }else{\n      char *zRet = sqlite3MallocZero(p->nCol * 25);\n      if( zRet==0 ){\n        sqlite3_result_error_nomem(context);\n      }else{\n        int i;\n        char *z = zRet;\n        for(i=0; i<p->nCol; i++){\n          sqlite3_snprintf(24, z, \"%llu \", (u64)aCnt[i]);\n          z += sqlite3Strlen30(z);\n        }\n        assert( z[0]=='\\0' && z>zRet );\n        z[-1] = '\\0';\n        sqlite3_result_text(context, zRet, -1, sqlite3_free);\n      }\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( argc );\n#endif\n}\nstatic const FuncDef statGetFuncdef = {\n  1+IsStat34,      /* nArg */\n  SQLITE_UTF8,     /* funcFlags */\n  0,               /* pUserData */\n  0,               /* pNext */\n  statGet,         /* xSFunc */\n  0,               /* xFinalize */\n  \"stat_get\",      /* zName */\n  {0}\n};\n\nstatic void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){\n  assert( regOut!=regStat4 && regOut!=regStat4+1 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);\n#elif SQLITE_DEBUG\n  assert( iParam==STAT_GET_STAT1 );\n#else\n  UNUSED_PARAMETER( iParam );\n#endif\n  sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4, regOut,\n                    (char*)&statGetFuncdef, P4_FUNCDEF);\n  sqlite3VdbeChangeP5(v, 1 + IsStat34);\n}\n\n/*\n** Generate code to do an analysis of all indices associated with\n** a single table.\n*/\nstatic void analyzeOneTable(\n  Parse *pParse,   /* Parser context */\n  Table *pTab,     /* Table whose indices are to be analyzed */\n  Index *pOnlyIdx, /* If not NULL, only analyze this one index */\n  int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */\n  int iMem,        /* Available memory locations begin here */\n  int iTab         /* Next available cursor */\n){\n  sqlite3 *db = pParse->db;    /* Database handle */\n  Index *pIdx;                 /* An index to being analyzed */\n  int iIdxCur;                 /* Cursor open on index being analyzed */\n  int iTabCur;                 /* Table cursor */\n  Vdbe *v;                     /* The virtual machine being built up */\n  int i;                       /* Loop counter */\n  int jZeroRows = -1;          /* Jump from here if number of rows is zero */\n  int iDb;                     /* Index of database containing pTab */\n  u8 needTableCnt = 1;         /* True to count the table */\n  int regNewRowid = iMem++;    /* Rowid for the inserted record */\n  int regStat4 = iMem++;       /* Register to hold Stat4Accum object */\n  int regChng = iMem++;        /* Index of changed index field */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int regRowid = iMem++;       /* Rowid argument passed to stat_push() */\n#endif\n  int regTemp = iMem++;        /* Temporary use register */\n  int regTabname = iMem++;     /* Register containing table name */\n  int regIdxname = iMem++;     /* Register containing index name */\n  int regStat1 = iMem++;       /* Value for the stat column of sqlite_stat1 */\n  int regPrev = iMem;          /* MUST BE LAST (see below) */\n\n  pParse->nMem = MAX(pParse->nMem, iMem);\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 || NEVER(pTab==0) ){\n    return;\n  }\n  if( pTab->tnum==0 ){\n    /* Do not gather statistics on views or virtual tables */\n    return;\n  }\n  if( sqlite3_strlike(\"sqlite_%\", pTab->zName, 0)==0 ){\n    /* Do not gather statistics on system tables */\n    return;\n  }\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n  /* Establish a read-lock on the table at the shared-cache level. \n  ** Open a read-only cursor on the table. Also allocate a cursor number\n  ** to use for scanning indexes (iIdxCur). No index cursor is opened at\n  ** this time though.  */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n  iTabCur = iTab++;\n  iIdxCur = iTab++;\n  pParse->nTab = MAX(pParse->nTab, iTab);\n  sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n  sqlite3VdbeLoadString(v, regTabname, pTab->zName);\n\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int nCol;                     /* Number of columns in pIdx. \"N\" */\n    int addrRewind;               /* Address of \"OP_Rewind iIdxCur\" */\n    int addrNextRow;              /* Address of \"next_row:\" */\n    const char *zIdxName;         /* Name of the index */\n    int nColTest;                 /* Number of columns to test for changes */\n\n    if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;\n    if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;\n    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){\n      nCol = pIdx->nKeyCol;\n      zIdxName = pTab->zName;\n      nColTest = nCol - 1;\n    }else{\n      nCol = pIdx->nColumn;\n      zIdxName = pIdx->zName;\n      nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1;\n    }\n\n    /* Populate the register containing the index name. */\n    sqlite3VdbeLoadString(v, regIdxname, zIdxName);\n    VdbeComment((v, \"Analysis for %s.%s\", pTab->zName, zIdxName));\n\n    /*\n    ** Pseudo-code for loop that calls stat_push():\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto chng_addr_0;\n    **\n    **  next_row:\n    **   regChng = 0\n    **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n    **   regChng = 1\n    **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n    **   ...\n    **   regChng = N\n    **   goto chng_addr_N\n    **\n    **  chng_addr_0:\n    **   regPrev(0) = idx(0)\n    **  chng_addr_1:\n    **   regPrev(1) = idx(1)\n    **  ...\n    **\n    **  endDistinctTest:\n    **   regRowid = idx(rowid)\n    **   stat_push(P, regChng, regRowid)\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    **\n    **  end_of_scan:\n    */\n\n    /* Make sure there are enough memory cells allocated to accommodate \n    ** the regPrev array and a trailing rowid (the rowid slot is required\n    ** when building a record to insert into the sample column of \n    ** the sqlite_stat4 table.  */\n    pParse->nMem = MAX(pParse->nMem, regPrev+nColTest);\n\n    /* Open a read-only cursor on the index being analyzed. */\n    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n    VdbeComment((v, \"%s\", pIdx->zName));\n\n    /* Invoke the stat_init() function. The arguments are:\n    ** \n    **    (1) the number of columns in the index including the rowid\n    **        (or for a WITHOUT ROWID table, the number of PK columns),\n    **    (2) the number of columns in the key without the rowid/pk\n    **    (3) the number of rows in the index,\n    **\n    **\n    ** The third argument is only used for STAT3 and STAT4\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);\n#endif\n    sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);\n    sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regStat4+1, regStat4,\n                     (char*)&statInitFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n\n    /* Implementation of the following:\n    **\n    **   Rewind csr\n    **   if eof(csr) goto end_of_scan;\n    **   regChng = 0\n    **   goto next_push_0;\n    **\n    */\n    addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng);\n    addrNextRow = sqlite3VdbeCurrentAddr(v);\n\n    if( nColTest>0 ){\n      int endDistinctTest = sqlite3VdbeMakeLabel(v);\n      int *aGotoChng;               /* Array of jump instruction addresses */\n      aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);\n      if( aGotoChng==0 ) continue;\n\n      /*\n      **  next_row:\n      **   regChng = 0\n      **   if( idx(0) != regPrev(0) ) goto chng_addr_0\n      **   regChng = 1\n      **   if( idx(1) != regPrev(1) ) goto chng_addr_1\n      **   ...\n      **   regChng = N\n      **   goto endDistinctTest\n      */\n      sqlite3VdbeAddOp0(v, OP_Goto);\n      addrNextRow = sqlite3VdbeCurrentAddr(v);\n      if( nColTest==1 && pIdx->nKeyCol==1 && IsUniqueIndex(pIdx) ){\n        /* For a single-column UNIQUE index, once we have found a non-NULL\n        ** row, we know that all the rest will be distinct, so skip \n        ** subsequent distinctness tests. */\n        sqlite3VdbeAddOp2(v, OP_NotNull, regPrev, endDistinctTest);\n        VdbeCoverage(v);\n      }\n      for(i=0; i<nColTest; i++){\n        char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]);\n        sqlite3VdbeAddOp2(v, OP_Integer, i, regChng);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regTemp);\n        aGotoChng[i] = \n        sqlite3VdbeAddOp4(v, OP_Ne, regTemp, 0, regPrev+i, pColl, P4_COLLSEQ);\n        sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp2(v, OP_Integer, nColTest, regChng);\n      sqlite3VdbeGoto(v, endDistinctTest);\n  \n  \n      /*\n      **  chng_addr_0:\n      **   regPrev(0) = idx(0)\n      **  chng_addr_1:\n      **   regPrev(1) = idx(1)\n      **  ...\n      */\n      sqlite3VdbeJumpHere(v, addrNextRow-1);\n      for(i=0; i<nColTest; i++){\n        sqlite3VdbeJumpHere(v, aGotoChng[i]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regPrev+i);\n      }\n      sqlite3VdbeResolveLabel(v, endDistinctTest);\n      sqlite3DbFree(db, aGotoChng);\n    }\n  \n    /*\n    **  chng_addr_N:\n    **   regRowid = idx(rowid)            // STAT34 only\n    **   stat_push(P, regChng, regRowid)  // 3rd parameter STAT34 only\n    **   Next csr\n    **   if !eof(csr) goto next_row;\n    */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    assert( regRowid==(regStat4+2) );\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid);\n    }else{\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      int j, k, regKey;\n      regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        assert( k>=0 && k<pIdx->nColumn );\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j);\n        VdbeComment((v, \"%s\", pTab->aCol[pPk->aiColumn[j]].zName));\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid);\n      sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol);\n    }\n#endif\n    assert( regChng==(regStat4+1) );\n    sqlite3VdbeAddOp4(v, OP_Function0, 1, regStat4, regTemp,\n                     (char*)&statPushFuncdef, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, 2+IsStat34);\n    sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, addrNextRow); VdbeCoverage(v);\n\n    /* Add the entry to the stat1 table. */\n    callStatGet(v, regStat4, STAT_GET_STAT1, regStat1);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n\n    /* Add the entries to the stat3 or stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    {\n      int regEq = regStat1;\n      int regLt = regStat1+1;\n      int regDLt = regStat1+2;\n      int regSample = regStat1+3;\n      int regCol = regStat1+4;\n      int regSampleRowid = regCol + nCol;\n      int addrNext;\n      int addrIsNull;\n      u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n\n      pParse->nMem = MAX(pParse->nMem, regCol+nCol);\n\n      addrNext = sqlite3VdbeCurrentAddr(v);\n      callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);\n      addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);\n      VdbeCoverage(v);\n      callStatGet(v, regStat4, STAT_GET_NEQ, regEq);\n      callStatGet(v, regStat4, STAT_GET_NLT, regLt);\n      callStatGet(v, regStat4, STAT_GET_NDLT, regDLt);\n      sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0);\n      /* We know that the regSampleRowid row exists because it was read by\n      ** the previous loop.  Thus the not-found jump of seekOp will never\n      ** be taken */\n      VdbeCoverageNeverTaken(v);\n#ifdef SQLITE_ENABLE_STAT3\n      sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample);\n#else\n      for(i=0; i<nCol; i++){\n        sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);\n#endif\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);\n      sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */\n      sqlite3VdbeJumpHere(v, addrIsNull);\n    }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n    /* End of analysis */\n    sqlite3VdbeJumpHere(v, addrRewind);\n  }\n\n\n  /* Create a single sqlite_stat1 entry containing NULL as the index\n  ** name and the row count as the content.\n  */\n  if( pOnlyIdx==0 && needTableCnt ){\n    VdbeComment((v, \"%s\", pTab->zName));\n    sqlite3VdbeAddOp2(v, OP_Count, iTabCur, regStat1);\n    jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname);\n    assert( \"BBB\"[0]==SQLITE_AFF_TEXT );\n    sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regTemp, \"BBB\", 0);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regTemp, regNewRowid);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeJumpHere(v, jZeroRows);\n  }\n}\n\n\n/*\n** Generate code that will cause the most recent index analysis to\n** be loaded into internal hash tables where is can be used.\n*/\nstatic void loadAnalysis(Parse *pParse, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp1(v, OP_LoadAnalysis, iDb);\n  }\n}\n\n/*\n** Generate code that will do an analysis of an entire database\n*/\nstatic void analyzeDatabase(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Schema *pSchema = db->aDb[iDb].pSchema;    /* Schema of database iDb */\n  HashElem *k;\n  int iStatCur;\n  int iMem;\n  int iTab;\n\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  openStatTable(pParse, iDb, iStatCur, 0, 0);\n  iMem = pParse->nMem+1;\n  iTab = pParse->nTab;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n    Table *pTab = (Table*)sqliteHashData(k);\n    analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab);\n  }\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code that will do an analysis of a single table in\n** a database.  If pOnlyIdx is not NULL then it is a single index\n** in pTab that should be analyzed.\n*/\nstatic void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){\n  int iDb;\n  int iStatCur;\n\n  assert( pTab!=0 );\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  sqlite3BeginWriteOperation(pParse, 0, iDb);\n  iStatCur = pParse->nTab;\n  pParse->nTab += 3;\n  if( pOnlyIdx ){\n    openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, \"idx\");\n  }else{\n    openStatTable(pParse, iDb, iStatCur, pTab->zName, \"tbl\");\n  }\n  analyzeOneTable(pParse, pTab, pOnlyIdx, iStatCur,pParse->nMem+1,pParse->nTab);\n  loadAnalysis(pParse, iDb);\n}\n\n/*\n** Generate code for the ANALYZE command.  The parser calls this routine\n** when it recognizes an ANALYZE command.\n**\n**        ANALYZE                            -- 1\n**        ANALYZE  <database>                -- 2\n**        ANALYZE  ?<database>.?<tablename>  -- 3\n**\n** Form 1 causes all indices in all attached databases to be analyzed.\n** Form 2 analyzes all indices the single database named.\n** Form 3 analyzes all indices associated with the named table.\n*/\nvoid sqlite3Analyze(Parse *pParse, Token *pName1, Token *pName2){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int i;\n  char *z, *zDb;\n  Table *pTab;\n  Index *pIdx;\n  Token *pTableName;\n  Vdbe *v;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  assert( pName2!=0 || pName1==0 );\n  if( pName1==0 ){\n    /* Form 1:  Analyze everything */\n    for(i=0; i<db->nDb; i++){\n      if( i==1 ) continue;  /* Do not analyze the TEMP database */\n      analyzeDatabase(pParse, i);\n    }\n  }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){\n    /* Analyze the schema named as the argument */\n    analyzeDatabase(pParse, iDb);\n  }else{\n    /* Form 3: Analyze the table or index named as an argument */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);\n    if( iDb>=0 ){\n      zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;\n      z = sqlite3NameFromToken(db, pTableName);\n      if( z ){\n        if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){\n          analyzeTable(pParse, pIdx->pTable, pIdx);\n        }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){\n          analyzeTable(pParse, pTab, 0);\n        }\n        sqlite3DbFree(db, z);\n      }\n    }\n  }\n  if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3VdbeAddOp0(v, OP_Expire);\n  }\n}\n\n/*\n** Used to pass information from the analyzer reader through to the\n** callback routine.\n*/\ntypedef struct analysisInfo analysisInfo;\nstruct analysisInfo {\n  sqlite3 *db;\n  const char *zDatabase;\n};\n\n/*\n** The first argument points to a nul-terminated string containing a\n** list of space separated integers. Read the first nOut of these into\n** the array aOut[].\n*/\nstatic void decodeIntArray(\n  char *zIntArray,       /* String containing int array to decode */\n  int nOut,              /* Number of slots in aOut[] */\n  tRowcnt *aOut,         /* Store integers here */\n  LogEst *aLog,          /* Or, if aOut==0, here */\n  Index *pIndex          /* Handle extra flags for this index, if not NULL */\n){\n  char *z = zIntArray;\n  int c;\n  int i;\n  tRowcnt v;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( z==0 ) z = \"\";\n#else\n  assert( z!=0 );\n#endif\n  for(i=0; *z && i<nOut; i++){\n    v = 0;\n    while( (c=z[0])>='0' && c<='9' ){\n      v = v*10 + c - '0';\n      z++;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    if( aOut ) aOut[i] = v;\n    if( aLog ) aLog[i] = sqlite3LogEst(v);\n#else\n    assert( aOut==0 );\n    UNUSED_PARAMETER(aOut);\n    assert( aLog!=0 );\n    aLog[i] = sqlite3LogEst(v);\n#endif\n    if( *z==' ' ) z++;\n  }\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  assert( pIndex!=0 ); {\n#else\n  if( pIndex ){\n#endif\n    pIndex->bUnordered = 0;\n    pIndex->noSkipScan = 0;\n    while( z[0] ){\n      if( sqlite3_strglob(\"unordered*\", z)==0 ){\n        pIndex->bUnordered = 1;\n      }else if( sqlite3_strglob(\"sz=[0-9]*\", z)==0 ){\n        pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));\n      }else if( sqlite3_strglob(\"noskipscan*\", z)==0 ){\n        pIndex->noSkipScan = 1;\n      }\n#ifdef SQLITE_ENABLE_COSTMULT\n      else if( sqlite3_strglob(\"costmult=[0-9]*\",z)==0 ){\n        pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));\n      }\n#endif\n      while( z[0]!=0 && z[0]!=' ' ) z++;\n      while( z[0]==' ' ) z++;\n    }\n  }\n}\n\n/*\n** This callback is invoked once for each index when reading the\n** sqlite_stat1 table.  \n**\n**     argv[0] = name of the table\n**     argv[1] = name of the index (might be NULL)\n**     argv[2] = results of analysis - on integer for each column\n**\n** Entries for which argv[1]==NULL simply record the number of rows in\n** the table.\n*/\nstatic int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){\n  analysisInfo *pInfo = (analysisInfo*)pData;\n  Index *pIndex;\n  Table *pTable;\n  const char *z;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n\n  if( argv==0 || argv[0]==0 || argv[2]==0 ){\n    return 0;\n  }\n  pTable = sqlite3FindTable(pInfo->db, argv[0], pInfo->zDatabase);\n  if( pTable==0 ){\n    return 0;\n  }\n  if( argv[1]==0 ){\n    pIndex = 0;\n  }else if( sqlite3_stricmp(argv[0],argv[1])==0 ){\n    pIndex = sqlite3PrimaryKeyIndex(pTable);\n  }else{\n    pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);\n  }\n  z = argv[2];\n\n  if( pIndex ){\n    tRowcnt *aiRowEst = 0;\n    int nCol = pIndex->nKeyCol+1;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    /* Index.aiRowEst may already be set here if there are duplicate \n    ** sqlite_stat1 entries for this index. In that case just clobber\n    ** the old data with the new instead of allocating a new array.  */\n    if( pIndex->aiRowEst==0 ){\n      pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);\n      if( pIndex->aiRowEst==0 ) sqlite3OomFault(pInfo->db);\n    }\n    aiRowEst = pIndex->aiRowEst;\n#endif\n    pIndex->bUnordered = 0;\n    decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);\n    pIndex->hasStat1 = 1;\n    if( pIndex->pPartIdxWhere==0 ){\n      pTable->nRowLogEst = pIndex->aiRowLogEst[0];\n      pTable->tabFlags |= TF_HasStat1;\n    }\n  }else{\n    Index fakeIdx;\n    fakeIdx.szIdxRow = pTable->szTabRow;\n#ifdef SQLITE_ENABLE_COSTMULT\n    fakeIdx.pTable = pTable;\n#endif\n    decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);\n    pTable->szTabRow = fakeIdx.szIdxRow;\n    pTable->tabFlags |= TF_HasStat1;\n  }\n\n  return 0;\n}\n\n/*\n** If the Index.aSample variable is not NULL, delete the aSample[] array\n** and its contents.\n*/\nvoid sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pIdx->aSample ){\n    int j;\n    for(j=0; j<pIdx->nSample; j++){\n      IndexSample *p = &pIdx->aSample[j];\n      sqlite3DbFree(db, p->p);\n    }\n    sqlite3DbFree(db, pIdx->aSample);\n  }\n  if( db && db->pnBytesFreed==0 ){\n    pIdx->nSample = 0;\n    pIdx->aSample = 0;\n  }\n#else\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pIdx);\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Populate the pIdx->aAvgEq[] array based on the samples currently\n** stored in pIdx->aSample[]. \n*/\nstatic void initAvgEq(Index *pIdx){\n  if( pIdx ){\n    IndexSample *aSample = pIdx->aSample;\n    IndexSample *pFinal = &aSample[pIdx->nSample-1];\n    int iCol;\n    int nCol = 1;\n    if( pIdx->nSampleCol>1 ){\n      /* If this is stat4 data, then calculate aAvgEq[] values for all\n      ** sample columns except the last. The last is always set to 1, as\n      ** once the trailing PK fields are considered all index keys are\n      ** unique.  */\n      nCol = pIdx->nSampleCol-1;\n      pIdx->aAvgEq[nCol] = 1;\n    }\n    for(iCol=0; iCol<nCol; iCol++){\n      int nSample = pIdx->nSample;\n      int i;                    /* Used to iterate through samples */\n      tRowcnt sumEq = 0;        /* Sum of the nEq values */\n      tRowcnt avgEq = 0;\n      tRowcnt nRow;             /* Number of rows in index */\n      i64 nSum100 = 0;          /* Number of terms contributing to sumEq */\n      i64 nDist100;             /* Number of distinct values in index */\n\n      if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){\n        nRow = pFinal->anLt[iCol];\n        nDist100 = (i64)100 * pFinal->anDLt[iCol];\n        nSample--;\n      }else{\n        nRow = pIdx->aiRowEst[0];\n        nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];\n      }\n      pIdx->nRowEst0 = nRow;\n\n      /* Set nSum to the number of distinct (iCol+1) field prefixes that\n      ** occur in the stat4 table for this index. Set sumEq to the sum of \n      ** the nEq values for column iCol for the same set (adding the value \n      ** only once where there exist duplicate prefixes).  */\n      for(i=0; i<nSample; i++){\n        if( i==(pIdx->nSample-1)\n         || aSample[i].anDLt[iCol]!=aSample[i+1].anDLt[iCol] \n        ){\n          sumEq += aSample[i].anEq[iCol];\n          nSum100 += 100;\n        }\n      }\n\n      if( nDist100>nSum100 && sumEq<nRow ){\n        avgEq = ((i64)100 * (nRow - sumEq))/(nDist100 - nSum100);\n      }\n      if( avgEq==0 ) avgEq = 1;\n      pIdx->aAvgEq[iCol] = avgEq;\n    }\n  }\n}\n\n/*\n** Look up an index by name.  Or, if the name of a WITHOUT ROWID table\n** is supplied instead, find the PRIMARY KEY index for that table.\n*/\nstatic Index *findIndexOrPrimaryKey(\n  sqlite3 *db,\n  const char *zName,\n  const char *zDb\n){\n  Index *pIdx = sqlite3FindIndex(db, zName, zDb);\n  if( pIdx==0 ){\n    Table *pTab = sqlite3FindTable(db, zName, zDb);\n    if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);\n  }\n  return pIdx;\n}\n\n/*\n** Load the content from either the sqlite_stat4 or sqlite_stat3 table \n** into the relevant Index.aSample[] arrays.\n**\n** Arguments zSql1 and zSql2 must point to SQL statements that return\n** data equivalent to the following (statements are different for stat3,\n** see the caller of this function for details):\n**\n**    zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\n**    zSql2: SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\n**\n** where %Q is replaced with the database name before the SQL is executed.\n*/\nstatic int loadStatTbl(\n  sqlite3 *db,                  /* Database handle */\n  int bStat3,                   /* Assume single column records only */\n  const char *zSql1,            /* SQL statement 1 (see above) */\n  const char *zSql2,            /* SQL statement 2 (see above) */\n  const char *zDb               /* Database name (e.g. \"main\") */\n){\n  int rc;                       /* Result codes from subroutines */\n  sqlite3_stmt *pStmt = 0;      /* An SQL statement being run */\n  char *zSql;                   /* Text of the SQL statement */\n  Index *pPrevIdx = 0;          /* Previous index in the loop */\n  IndexSample *pSample;         /* A slot in pIdx->aSample[] */\n\n  assert( db->lookaside.bDisable );\n  zSql = sqlite3MPrintf(db, zSql1, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int nIdxCol = 1;              /* Number of columns in stat4 records */\n\n    char *zIndex;   /* Index name */\n    Index *pIdx;    /* Pointer to the index object */\n    int nSample;    /* Number of samples */\n    int nByte;      /* Bytes of space required */\n    int i;          /* Bytes of space required */\n    tRowcnt *pSpace;\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    nSample = sqlite3_column_int(pStmt, 1);\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    assert( pIdx==0 || bStat3 || pIdx->nSample==0 );\n    /* Index.nSample is non-zero at this point if data has already been\n    ** loaded from the stat4 table. In this case ignore stat3 data.  */\n    if( pIdx==0 || pIdx->nSample ) continue;\n    if( bStat3==0 ){\n      assert( !HasRowid(pIdx->pTable) || pIdx->nColumn==pIdx->nKeyCol+1 );\n      if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){\n        nIdxCol = pIdx->nKeyCol;\n      }else{\n        nIdxCol = pIdx->nColumn;\n      }\n    }\n    pIdx->nSampleCol = nIdxCol;\n    nByte = sizeof(IndexSample) * nSample;\n    nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample;\n    nByte += nIdxCol * sizeof(tRowcnt);     /* Space for Index.aAvgEq[] */\n\n    pIdx->aSample = sqlite3DbMallocZero(db, nByte);\n    if( pIdx->aSample==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pSpace = (tRowcnt*)&pIdx->aSample[nSample];\n    pIdx->aAvgEq = pSpace; pSpace += nIdxCol;\n    for(i=0; i<nSample; i++){\n      pIdx->aSample[i].anEq = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anLt = pSpace; pSpace += nIdxCol;\n      pIdx->aSample[i].anDLt = pSpace; pSpace += nIdxCol;\n    }\n    assert( ((u8*)pSpace)-nByte==(u8*)(pIdx->aSample) );\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc ) return rc;\n\n  zSql = sqlite3MPrintf(db, zSql2, zDb);\n  if( !zSql ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3DbFree(db, zSql);\n  if( rc ) return rc;\n\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    char *zIndex;                 /* Index name */\n    Index *pIdx;                  /* Pointer to the index object */\n    int nCol = 1;                 /* Number of columns in index */\n\n    zIndex = (char *)sqlite3_column_text(pStmt, 0);\n    if( zIndex==0 ) continue;\n    pIdx = findIndexOrPrimaryKey(db, zIndex, zDb);\n    if( pIdx==0 ) continue;\n    /* This next condition is true if data has already been loaded from \n    ** the sqlite_stat4 table. In this case ignore stat3 data.  */\n    nCol = pIdx->nSampleCol;\n    if( bStat3 && nCol>1 ) continue;\n    if( pIdx!=pPrevIdx ){\n      initAvgEq(pPrevIdx);\n      pPrevIdx = pIdx;\n    }\n    pSample = &pIdx->aSample[pIdx->nSample];\n    decodeIntArray((char*)sqlite3_column_text(pStmt,1),nCol,pSample->anEq,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,2),nCol,pSample->anLt,0,0);\n    decodeIntArray((char*)sqlite3_column_text(pStmt,3),nCol,pSample->anDLt,0,0);\n\n    /* Take a copy of the sample. Add two 0x00 bytes the end of the buffer.\n    ** This is in case the sample record is corrupted. In that case, the\n    ** sqlite3VdbeRecordCompare() may read up to two varints past the\n    ** end of the allocated buffer before it realizes it is dealing with\n    ** a corrupt record. Adding the two 0x00 bytes prevents this from causing\n    ** a buffer overread.  */\n    pSample->n = sqlite3_column_bytes(pStmt, 4);\n    pSample->p = sqlite3DbMallocZero(db, pSample->n + 2);\n    if( pSample->p==0 ){\n      sqlite3_finalize(pStmt);\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pSample->n ){\n      memcpy(pSample->p, sqlite3_column_blob(pStmt, 4), pSample->n);\n    }\n    pIdx->nSample++;\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc==SQLITE_OK ) initAvgEq(pPrevIdx);\n  return rc;\n}\n\n/*\n** Load content from the sqlite_stat4 and sqlite_stat3 tables into \n** the Index.aSample[] arrays of all indices.\n*/\nstatic int loadStat4(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_OK;             /* Result codes from subroutines */\n\n  assert( db->lookaside.bDisable );\n  if( sqlite3FindTable(db, \"sqlite_stat4\", zDb) ){\n    rc = loadStatTbl(db, 0,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4\",\n      zDb\n    );\n  }\n\n  if( rc==SQLITE_OK && sqlite3FindTable(db, \"sqlite_stat3\", zDb) ){\n    rc = loadStatTbl(db, 1,\n      \"SELECT idx,count(*) FROM %Q.sqlite_stat3 GROUP BY idx\", \n      \"SELECT idx,neq,nlt,ndlt,sqlite_record(sample) FROM %Q.sqlite_stat3\",\n      zDb\n    );\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** Load the content of the sqlite_stat1 and sqlite_stat3/4 tables. The\n** contents of sqlite_stat1 are used to populate the Index.aiRowEst[]\n** arrays. The contents of sqlite_stat3/4 are used to populate the\n** Index.aSample[] arrays.\n**\n** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR\n** is returned. In this case, even if SQLITE_ENABLE_STAT3/4 was defined \n** during compilation and the sqlite_stat3/4 table is present, no data is \n** read from it.\n**\n** If SQLITE_ENABLE_STAT3/4 was defined during compilation and the \n** sqlite_stat4 table is not present in the database, SQLITE_ERROR is\n** returned. However, in this case, data is read from the sqlite_stat1\n** table (if it is present) before returning.\n**\n** If an OOM error occurs, this function always sets db->mallocFailed.\n** This means if the caller does not care about other errors, the return\n** code may be ignored.\n*/\nint sqlite3AnalysisLoad(sqlite3 *db, int iDb){\n  analysisInfo sInfo;\n  HashElem *i;\n  char *zSql;\n  int rc = SQLITE_OK;\n  Schema *pSchema = db->aDb[iDb].pSchema;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n\n  /* Clear any prior statistics */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    pTab->tabFlags &= ~TF_HasStat1;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    pIdx->hasStat1 = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3DeleteIndexSamples(db, pIdx);\n    pIdx->aSample = 0;\n#endif\n  }\n\n  /* Load new statistics out of the sqlite_stat1 table */\n  sInfo.db = db;\n  sInfo.zDatabase = db->aDb[iDb].zDbSName;\n  if( sqlite3FindTable(db, \"sqlite_stat1\", sInfo.zDatabase)!=0 ){\n    zSql = sqlite3MPrintf(db, \n        \"SELECT tbl,idx,stat FROM %Q.sqlite_stat1\", sInfo.zDatabase);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);\n      sqlite3DbFree(db, zSql);\n    }\n  }\n\n  /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);\n  }\n\n  /* Load the statistics from the sqlite_stat4 table. */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){\n    db->lookaside.bDisable++;\n    rc = loadStat4(db, sInfo.zDatabase);\n    db->lookaside.bDisable--;\n  }\n  for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){\n    Index *pIdx = sqliteHashData(i);\n    sqlite3_free(pIdx->aiRowEst);\n    pIdx->aiRowEst = 0;\n  }\n#endif\n\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return rc;\n}\n\n\n#endif /* SQLITE_OMIT_ANALYZE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/attach.c",
    "content": "/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the ATTACH and DETACH commands.\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_ATTACH\n/*\n** Resolve an expression that was part of an ATTACH or DETACH statement. This\n** is slightly different from resolving a normal SQL expression, because simple\n** identifiers are treated as strings, not possible column names or aliases.\n**\n** i.e. if the parser sees:\n**\n**     ATTACH DATABASE abc AS def\n**\n** it treats the two expressions as literal strings 'abc' and 'def' instead of\n** looking for columns of the same name.\n**\n** This only applies to the root node of pExpr, so the statement:\n**\n**     ATTACH DATABASE abc||def AS 'db2'\n**\n** will fail because neither abc or def can be resolved.\n*/\nstatic int resolveAttachExpr(NameContext *pName, Expr *pExpr)\n{\n  int rc = SQLITE_OK;\n  if( pExpr ){\n    if( pExpr->op!=TK_ID ){\n      rc = sqlite3ResolveExprNames(pName, pExpr);\n    }else{\n      pExpr->op = TK_STRING;\n    }\n  }\n  return rc;\n}\n\n/*\n** An SQL user-function registered to do the work of an ATTACH statement. The\n** three arguments to the function come directly from an attach statement:\n**\n**     ATTACH DATABASE x AS y KEY z\n**\n**     SELECT sqlite_attach(x, y, z)\n**\n** If the optional \"KEY z\" syntax is omitted, an SQL NULL is passed as the\n** third argument.\n*/\nstatic void attachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  int i;\n  int rc = 0;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  const char *zName;\n  const char *zFile;\n  char *zPath = 0;\n  char *zErr = 0;\n  unsigned int flags;\n  Db *aNew;                 /* New array of Db pointers */\n  Db *pNew;                 /* Db object for the newly attached database */\n  char *zErrDyn = 0;\n  sqlite3_vfs *pVfs;\n\n  UNUSED_PARAMETER(NotUsed);\n\n  zFile = (const char *)sqlite3_value_text(argv[0]);\n  zName = (const char *)sqlite3_value_text(argv[1]);\n  if( zFile==0 ) zFile = \"\";\n  if( zName==0 ) zName = \"\";\n\n  /* Check for the following errors:\n  **\n  **     * Too many attached databases,\n  **     * Transaction currently open\n  **     * Specified database name already being used.\n  */\n  if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){\n    zErrDyn = sqlite3MPrintf(db, \"too many attached databases - max %d\", \n      db->aLimit[SQLITE_LIMIT_ATTACHED]\n    );\n    goto attach_error;\n  }\n  for(i=0; i<db->nDb; i++){\n    char *z = db->aDb[i].zDbSName;\n    assert( z && zName );\n    if( sqlite3StrICmp(z, zName)==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"database %s is already in use\", zName);\n      goto attach_error;\n    }\n  }\n\n  /* Allocate the new entry in the db->aDb[] array and initialize the schema\n  ** hash tables.\n  */\n  if( db->aDb==db->aDbStatic ){\n    aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );\n    if( aNew==0 ) return;\n    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);\n  }else{\n    aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );\n    if( aNew==0 ) return;\n  }\n  db->aDb = aNew;\n  pNew = &db->aDb[db->nDb];\n  memset(pNew, 0, sizeof(*pNew));\n\n  /* Open the database file. If the btree is successfully opened, use\n  ** it to obtain the database schema. At this point the schema may\n  ** or may not be initialized.\n  */\n  flags = db->openFlags;\n  rc = sqlite3ParseUri(db->pVfs->zName, zFile, &flags, &pVfs, &zPath, &zErr);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n    sqlite3_result_error(context, zErr, -1);\n    sqlite3_free(zErr);\n    return;\n  }\n  assert( pVfs );\n  flags |= SQLITE_OPEN_MAIN_DB;\n  rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);\n  sqlite3_free( zPath );\n  db->nDb++;\n  db->skipBtreeMutex = 0;\n  if( rc==SQLITE_CONSTRAINT ){\n    rc = SQLITE_ERROR;\n    zErrDyn = sqlite3MPrintf(db, \"database is already attached\");\n  }else if( rc==SQLITE_OK ){\n    Pager *pPager;\n    pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);\n    if( !pNew->pSchema ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else if( pNew->pSchema->file_format && pNew->pSchema->enc!=ENC(db) ){\n      zErrDyn = sqlite3MPrintf(db, \n        \"attached databases must use the same text encoding as main database\");\n      rc = SQLITE_ERROR;\n    }\n    sqlite3BtreeEnter(pNew->pBt);\n    pPager = sqlite3BtreePager(pNew->pBt);\n    sqlite3PagerLockingMode(pPager, db->dfltLockMode);\n    sqlite3BtreeSecureDelete(pNew->pBt,\n                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n    sqlite3BtreeSetPagerFlags(pNew->pBt,\n                      PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));\n#endif\n    sqlite3BtreeLeave(pNew->pBt);\n  }\n  pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  pNew->zDbSName = sqlite3DbStrDup(db, zName);\n  if( rc==SQLITE_OK && pNew->zDbSName==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n#ifdef SQLITE_HAS_CODEC\n  if( rc==SQLITE_OK ){\n    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    int t = sqlite3_value_type(argv[2]);\n    switch( t ){\n      case SQLITE_INTEGER:\n      case SQLITE_FLOAT:\n        zErrDyn = sqlite3DbStrDup(db, \"Invalid key value\");\n        rc = SQLITE_ERROR;\n        break;\n        \n      case SQLITE_TEXT:\n      case SQLITE_BLOB:\n        nKey = sqlite3_value_bytes(argv[2]);\n        zKey = (char *)sqlite3_value_blob(argv[2]);\n        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        break;\n\n      case SQLITE_NULL:\n        /* No key specified.  Use the key from the main database */\n        sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);\n        if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){\n          rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);\n        }\n        break;\n    }\n  }\n#endif\n\n  /* If the file was opened successfully, read the schema for the new database.\n  ** If this fails, or if opening the file failed, then close the file and \n  ** remove the entry from the db->aDb[] array. i.e. put everything back the way\n  ** we found it.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3BtreeEnterAll(db);\n    rc = sqlite3Init(db, &zErrDyn);\n    sqlite3BtreeLeaveAll(db);\n  }\n#ifdef SQLITE_USER_AUTHENTICATION\n  if( rc==SQLITE_OK ){\n    u8 newAuth = 0;\n    rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);\n    if( newAuth<db->auth.authLevel ){\n      rc = SQLITE_AUTH_USER;\n    }\n  }\n#endif\n  if( rc ){\n    int iDb = db->nDb - 1;\n    assert( iDb>=2 );\n    if( db->aDb[iDb].pBt ){\n      sqlite3BtreeClose(db->aDb[iDb].pBt);\n      db->aDb[iDb].pBt = 0;\n      db->aDb[iDb].pSchema = 0;\n    }\n    sqlite3ResetAllSchemasOfConnection(db);\n    db->nDb = iDb;\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      sqlite3OomFault(db);\n      sqlite3DbFree(db, zErrDyn);\n      zErrDyn = sqlite3MPrintf(db, \"out of memory\");\n    }else if( zErrDyn==0 ){\n      zErrDyn = sqlite3MPrintf(db, \"unable to open database: %s\", zFile);\n    }\n    goto attach_error;\n  }\n  \n  return;\n\nattach_error:\n  /* Return an error if we get here */\n  if( zErrDyn ){\n    sqlite3_result_error(context, zErrDyn, -1);\n    sqlite3DbFree(db, zErrDyn);\n  }\n  if( rc ) sqlite3_result_error_code(context, rc);\n}\n\n/*\n** An SQL user-function registered to do the work of an DETACH statement. The\n** three arguments to the function come directly from a detach statement:\n**\n**     DETACH DATABASE x\n**\n**     SELECT sqlite_detach(x)\n*/\nstatic void detachFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  const char *zName = (const char *)sqlite3_value_text(argv[0]);\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int i;\n  Db *pDb = 0;\n  char zErr[128];\n\n  UNUSED_PARAMETER(NotUsed);\n\n  if( zName==0 ) zName = \"\";\n  for(i=0; i<db->nDb; i++){\n    pDb = &db->aDb[i];\n    if( pDb->pBt==0 ) continue;\n    if( sqlite3StrICmp(pDb->zDbSName, zName)==0 ) break;\n  }\n\n  if( i>=db->nDb ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"no such database: %s\", zName);\n    goto detach_error;\n  }\n  if( i<2 ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"cannot detach database %s\", zName);\n    goto detach_error;\n  }\n  if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){\n    sqlite3_snprintf(sizeof(zErr),zErr, \"database %s is locked\", zName);\n    goto detach_error;\n  }\n\n  sqlite3BtreeClose(pDb->pBt);\n  pDb->pBt = 0;\n  pDb->pSchema = 0;\n  sqlite3CollapseDatabaseArray(db);\n  return;\n\ndetach_error:\n  sqlite3_result_error(context, zErr, -1);\n}\n\n/*\n** This procedure generates VDBE code for a single invocation of either the\n** sqlite_detach() or sqlite_attach() SQL user functions.\n*/\nstatic void codeAttach(\n  Parse *pParse,       /* The parser context */\n  int type,            /* Either SQLITE_ATTACH or SQLITE_DETACH */\n  FuncDef const *pFunc,/* FuncDef wrapper for detachFunc() or attachFunc() */\n  Expr *pAuthArg,      /* Expression to pass to authorization callback */\n  Expr *pFilename,     /* Name of database file */\n  Expr *pDbname,       /* Name of the database to use internally */\n  Expr *pKey           /* Database key for encryption extension */\n){\n  int rc;\n  NameContext sName;\n  Vdbe *v;\n  sqlite3* db = pParse->db;\n  int regArgs;\n\n  if( pParse->nErr ) goto attach_end;\n  memset(&sName, 0, sizeof(NameContext));\n  sName.pParse = pParse;\n\n  if( \n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||\n      SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))\n  ){\n    goto attach_end;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( pAuthArg ){\n    char *zAuthArg;\n    if( pAuthArg->op==TK_STRING ){\n      zAuthArg = pAuthArg->u.zToken;\n    }else{\n      zAuthArg = 0;\n    }\n    rc = sqlite3AuthCheck(pParse, type, zAuthArg, 0, 0);\n    if(rc!=SQLITE_OK ){\n      goto attach_end;\n    }\n  }\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n\n  v = sqlite3GetVdbe(pParse);\n  regArgs = sqlite3GetTempRange(pParse, 4);\n  sqlite3ExprCode(pParse, pFilename, regArgs);\n  sqlite3ExprCode(pParse, pDbname, regArgs+1);\n  sqlite3ExprCode(pParse, pKey, regArgs+2);\n\n  assert( v || db->mallocFailed );\n  if( v ){\n    sqlite3VdbeAddOp4(v, OP_Function0, 0, regArgs+3-pFunc->nArg, regArgs+3,\n                      (char *)pFunc, P4_FUNCDEF);\n    assert( pFunc->nArg==-1 || (pFunc->nArg&0xff)==pFunc->nArg );\n    sqlite3VdbeChangeP5(v, (u8)(pFunc->nArg));\n \n    /* Code an OP_Expire. For an ATTACH statement, set P1 to true (expire this\n    ** statement only). For DETACH, set it to false (expire all existing\n    ** statements).\n    */\n    sqlite3VdbeAddOp1(v, OP_Expire, (type==SQLITE_ATTACH));\n  }\n  \nattach_end:\n  sqlite3ExprDelete(db, pFilename);\n  sqlite3ExprDelete(db, pDbname);\n  sqlite3ExprDelete(db, pKey);\n}\n\n/*\n** Called by the parser to compile a DETACH statement.\n**\n**     DETACH pDbname\n*/\nvoid sqlite3Detach(Parse *pParse, Expr *pDbname){\n  static const FuncDef detach_func = {\n    1,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    detachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    \"sqlite_detach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_DETACH, &detach_func, pDbname, 0, 0, pDbname);\n}\n\n/*\n** Called by the parser to compile an ATTACH statement.\n**\n**     ATTACH p AS pDbname KEY pKey\n*/\nvoid sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){\n  static const FuncDef attach_func = {\n    3,                /* nArg */\n    SQLITE_UTF8,      /* funcFlags */\n    0,                /* pUserData */\n    0,                /* pNext */\n    attachFunc,       /* xSFunc */\n    0,                /* xFinalize */\n    \"sqlite_attach\",  /* zName */\n    {0}\n  };\n  codeAttach(pParse, SQLITE_ATTACH, &attach_func, p, p, pDbname, pKey);\n}\n#endif /* SQLITE_OMIT_ATTACH */\n\n/*\n** Initialize a DbFixer structure.  This routine must be called prior\n** to passing the structure to one of the sqliteFixAAAA() routines below.\n*/\nvoid sqlite3FixInit(\n  DbFixer *pFix,      /* The fixer to be initialized */\n  Parse *pParse,      /* Error messages will be written here */\n  int iDb,            /* This is the database that must be used */\n  const char *zType,  /* \"view\", \"trigger\", or \"index\" */\n  const Token *pName  /* Name of the view, trigger, or index */\n){\n  sqlite3 *db;\n\n  db = pParse->db;\n  assert( db->nDb>iDb );\n  pFix->pParse = pParse;\n  pFix->zDb = db->aDb[iDb].zDbSName;\n  pFix->pSchema = db->aDb[iDb].pSchema;\n  pFix->zType = zType;\n  pFix->pName = pName;\n  pFix->bVarOnly = (iDb==1);\n}\n\n/*\n** The following set of routines walk through the parse tree and assign\n** a specific database to all table references where the database name\n** was left unspecified in the original SQL statement.  The pFix structure\n** must have been initialized by a prior call to sqlite3FixInit().\n**\n** These routines are used to make sure that an index, trigger, or\n** view in one database does not refer to objects in a different database.\n** (Exception: indices, triggers, and views in the TEMP database are\n** allowed to refer to anything.)  If a reference is explicitly made\n** to an object in a different database, an error message is added to\n** pParse->zErrMsg and these routines return non-zero.  If everything\n** checks out, these routines return 0.\n*/\nint sqlite3FixSrcList(\n  DbFixer *pFix,       /* Context of the fixation */\n  SrcList *pList       /* The Source list to check and modify */\n){\n  int i;\n  const char *zDb;\n  struct SrcList_item *pItem;\n\n  if( NEVER(pList==0) ) return 0;\n  zDb = pFix->zDb;\n  for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n    if( pFix->bVarOnly==0 ){\n      if( pItem->zDatabase && sqlite3StrICmp(pItem->zDatabase, zDb) ){\n        sqlite3ErrorMsg(pFix->pParse,\n            \"%s %T cannot reference objects in database %s\",\n            pFix->zType, pFix->pName, pItem->zDatabase);\n        return 1;\n      }\n      sqlite3DbFree(pFix->pParse->db, pItem->zDatabase);\n      pItem->zDatabase = 0;\n      pItem->pSchema = pFix->pSchema;\n    }\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\n    if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;\n    if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;\n#endif\n  }\n  return 0;\n}\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)\nint sqlite3FixSelect(\n  DbFixer *pFix,       /* Context of the fixation */\n  Select *pSelect      /* The SELECT statement to be fixed to one database */\n){\n  while( pSelect ){\n    if( sqlite3FixExprList(pFix, pSelect->pEList) ){\n      return 1;\n    }\n    if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pHaving) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pLimit) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pSelect->pOffset) ){\n      return 1;\n    }\n    pSelect = pSelect->pPrior;\n  }\n  return 0;\n}\nint sqlite3FixExpr(\n  DbFixer *pFix,     /* Context of the fixation */\n  Expr *pExpr        /* The expression to be fixed to one database */\n){\n  while( pExpr ){\n    if( pExpr->op==TK_VARIABLE ){\n      if( pFix->pParse->db->init.busy ){\n        pExpr->op = TK_NULL;\n      }else{\n        sqlite3ErrorMsg(pFix->pParse, \"%s cannot use variables\", pFix->zType);\n        return 1;\n      }\n    }\n    if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1;\n    }else{\n      if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1;\n    }\n    if( sqlite3FixExpr(pFix, pExpr->pRight) ){\n      return 1;\n    }\n    pExpr = pExpr->pLeft;\n  }\n  return 0;\n}\nint sqlite3FixExprList(\n  DbFixer *pFix,     /* Context of the fixation */\n  ExprList *pList    /* The expression to be fixed to one database */\n){\n  int i;\n  struct ExprList_item *pItem;\n  if( pList==0 ) return 0;\n  for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){\n    if( sqlite3FixExpr(pFix, pItem->pExpr) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\nint sqlite3FixTriggerStep(\n  DbFixer *pFix,     /* Context of the fixation */\n  TriggerStep *pStep /* The trigger step be fixed to one database */\n){\n  while( pStep ){\n    if( sqlite3FixSelect(pFix, pStep->pSelect) ){\n      return 1;\n    }\n    if( sqlite3FixExpr(pFix, pStep->pWhere) ){\n      return 1;\n    }\n    if( sqlite3FixExprList(pFix, pStep->pExprList) ){\n      return 1;\n    }\n    pStep = pStep->pNext;\n  }\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/auth.c",
    "content": "/*\n** 2003 January 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the sqlite3_set_authorizer()\n** API.  This facility is an optional feature of the library.  Embedded\n** systems that do not need this facility may omit it by recompiling\n** the library with -DSQLITE_OMIT_AUTHORIZATION=1\n*/\n#include \"sqliteInt.h\"\n\n/*\n** All of the code in this file may be omitted by defining a single\n** macro.\n*/\n#ifndef SQLITE_OMIT_AUTHORIZATION\n\n/*\n** Set or clear the access authorization function.\n**\n** The access authorization function is be called during the compilation\n** phase to verify that the user has read and/or write access permission on\n** various fields of the database.  The first argument to the auth function\n** is a copy of the 3rd argument to this routine.  The second argument\n** to the auth function is one of these constants:\n**\n**       SQLITE_CREATE_INDEX\n**       SQLITE_CREATE_TABLE\n**       SQLITE_CREATE_TEMP_INDEX\n**       SQLITE_CREATE_TEMP_TABLE\n**       SQLITE_CREATE_TEMP_TRIGGER\n**       SQLITE_CREATE_TEMP_VIEW\n**       SQLITE_CREATE_TRIGGER\n**       SQLITE_CREATE_VIEW\n**       SQLITE_DELETE\n**       SQLITE_DROP_INDEX\n**       SQLITE_DROP_TABLE\n**       SQLITE_DROP_TEMP_INDEX\n**       SQLITE_DROP_TEMP_TABLE\n**       SQLITE_DROP_TEMP_TRIGGER\n**       SQLITE_DROP_TEMP_VIEW\n**       SQLITE_DROP_TRIGGER\n**       SQLITE_DROP_VIEW\n**       SQLITE_INSERT\n**       SQLITE_PRAGMA\n**       SQLITE_READ\n**       SQLITE_SELECT\n**       SQLITE_TRANSACTION\n**       SQLITE_UPDATE\n**\n** The third and fourth arguments to the auth function are the name of\n** the table and the column that are being accessed.  The auth function\n** should return either SQLITE_OK, SQLITE_DENY, or SQLITE_IGNORE.  If\n** SQLITE_OK is returned, it means that access is allowed.  SQLITE_DENY\n** means that the SQL statement will never-run - the sqlite3_exec() call\n** will return with an error.  SQLITE_IGNORE means that the SQL statement\n** should run but attempts to read the specified column will return NULL\n** and attempts to write the column will be ignored.\n**\n** Setting the auth function to NULL disables this hook.  The default\n** setting of the auth function is NULL.\n*/\nint sqlite3_set_authorizer(\n  sqlite3 *db,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xAuth = (sqlite3_xauth)xAuth;\n  db->pAuthArg = pArg;\n  sqlite3ExpirePreparedStatements(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Write an error message into pParse->zErrMsg that explains that the\n** user-supplied authorization function returned an illegal value.\n*/\nstatic void sqliteAuthBadReturnCode(Parse *pParse){\n  sqlite3ErrorMsg(pParse, \"authorizer malfunction\");\n  pParse->rc = SQLITE_ERROR;\n}\n\n/*\n** Invoke the authorization callback for permission to read column zCol from\n** table zTab in database zDb. This function assumes that an authorization\n** callback has been registered (i.e. that sqlite3.xAuth is not NULL).\n**\n** If SQLITE_IGNORE is returned and pExpr is not NULL, then pExpr is changed\n** to an SQL NULL expression. Otherwise, if pExpr is NULL, then SQLITE_IGNORE\n** is treated as SQLITE_DENY. In this case an error is left in pParse.\n*/\nint sqlite3AuthReadCol(\n  Parse *pParse,                  /* The parser context */\n  const char *zTab,               /* Table name */\n  const char *zCol,               /* Column name */\n  int iDb                         /* Index of containing database. */\n){\n  sqlite3 *db = pParse->db;          /* Database handle */\n  char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */\n  int rc;                            /* Auth callback return code */\n\n  if( db->init.busy ) return SQLITE_OK;\n  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    char *z = sqlite3_mprintf(\"%s.%s\", zTab, zCol);\n    if( db->nDb>2 || iDb!=0 ) z = sqlite3_mprintf(\"%s.%z\", zDb, z);\n    sqlite3ErrorMsg(pParse, \"access to %z is prohibited\", z);\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_IGNORE && rc!=SQLITE_OK ){\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** The pExpr should be a TK_COLUMN expression.  The table referred to\n** is in pTabList or else it is the NEW or OLD table of a trigger.  \n** Check to see if it is OK to read this particular column.\n**\n** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN \n** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,\n** then generate an error.\n*/\nvoid sqlite3AuthRead(\n  Parse *pParse,        /* The parser context */\n  Expr *pExpr,          /* The expression to check authorization on */\n  Schema *pSchema,      /* The schema of the expression */\n  SrcList *pTabList     /* All table that pExpr might refer to */\n){\n  sqlite3 *db = pParse->db;\n  Table *pTab = 0;      /* The table being read */\n  const char *zCol;     /* Name of the column of the table */\n  int iSrc;             /* Index in pTabList->a[] of table being read */\n  int iDb;              /* The index of the database the expression refers to */\n  int iCol;             /* Index of column in table */\n\n  if( db->xAuth==0 ) return;\n  iDb = sqlite3SchemaToIndex(pParse->db, pSchema);\n  if( iDb<0 ){\n    /* An attempt to read a column out of a subquery or other\n    ** temporary table. */\n    return;\n  }\n\n  assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER );\n  if( pExpr->op==TK_TRIGGER ){\n    pTab = pParse->pTriggerTab;\n  }else{\n    assert( pTabList );\n    for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){\n      if( pExpr->iTable==pTabList->a[iSrc].iCursor ){\n        pTab = pTabList->a[iSrc].pTab;\n        break;\n      }\n    }\n  }\n  iCol = pExpr->iColumn;\n  if( NEVER(pTab==0) ) return;\n\n  if( iCol>=0 ){\n    assert( iCol<pTab->nCol );\n    zCol = pTab->aCol[iCol].zName;\n  }else if( pTab->iPKey>=0 ){\n    assert( pTab->iPKey<pTab->nCol );\n    zCol = pTab->aCol[pTab->iPKey].zName;\n  }else{\n    zCol = \"ROWID\";\n  }\n  assert( iDb>=0 && iDb<db->nDb );\n  if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){\n    pExpr->op = TK_NULL;\n  }\n}\n\n/*\n** Do an authorization check using the code and arguments given.  Return\n** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY\n** is returned, then the error count and error message in pParse are\n** modified appropriately.\n*/\nint sqlite3AuthCheck(\n  Parse *pParse,\n  int code,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3\n){\n  sqlite3 *db = pParse->db;\n  int rc;\n\n  /* Don't do any authorization checks if the database is initialising\n  ** or if the parser is being invoked from within sqlite3_declare_vtab.\n  */\n  if( db->init.busy || IN_DECLARE_VTAB ){\n    return SQLITE_OK;\n  }\n\n  if( db->xAuth==0 ){\n    return SQLITE_OK;\n  }\n\n  /* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the\n  ** callback are either NULL pointers or zero-terminated strings that\n  ** contain additional details about the action to be authorized.\n  **\n  ** The following testcase() macros show that any of the 3rd through 6th\n  ** parameters can be either NULL or a string. */\n  testcase( zArg1==0 );\n  testcase( zArg2==0 );\n  testcase( zArg3==0 );\n  testcase( pParse->zAuthContext==0 );\n\n  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext\n#ifdef SQLITE_USER_AUTHENTICATION\n                 ,db->auth.zAuthUser\n#endif\n                );\n  if( rc==SQLITE_DENY ){\n    sqlite3ErrorMsg(pParse, \"not authorized\");\n    pParse->rc = SQLITE_AUTH;\n  }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){\n    rc = SQLITE_DENY;\n    sqliteAuthBadReturnCode(pParse);\n  }\n  return rc;\n}\n\n/*\n** Push an authorization context.  After this routine is called, the\n** zArg3 argument to authorization callbacks will be zContext until\n** popped.  Or if pParse==0, this routine is a no-op.\n*/\nvoid sqlite3AuthContextPush(\n  Parse *pParse,\n  AuthContext *pContext, \n  const char *zContext\n){\n  assert( pParse );\n  pContext->pParse = pParse;\n  pContext->zAuthContext = pParse->zAuthContext;\n  pParse->zAuthContext = zContext;\n}\n\n/*\n** Pop an authorization context that was previously pushed\n** by sqlite3AuthContextPush\n*/\nvoid sqlite3AuthContextPop(AuthContext *pContext){\n  if( pContext->pParse ){\n    pContext->pParse->zAuthContext = pContext->zAuthContext;\n    pContext->pParse = 0;\n  }\n}\n\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/backup.c",
    "content": "/*\n** 2009 January 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_backup_XXX() \n** API functions and the related features.\n*/\n#include \"sqliteInt.h\"\n#include \"btreeInt.h\"\n\n/*\n** Structure allocated for each backup operation.\n*/\nstruct sqlite3_backup {\n  sqlite3* pDestDb;        /* Destination database handle */\n  Btree *pDest;            /* Destination b-tree file */\n  u32 iDestSchema;         /* Original schema cookie in destination */\n  int bDestLocked;         /* True once a write-transaction is open on pDest */\n\n  Pgno iNext;              /* Page number of the next source page to copy */\n  sqlite3* pSrcDb;         /* Source database handle */\n  Btree *pSrc;             /* Source b-tree file */\n\n  int rc;                  /* Backup process error code */\n\n  /* These two variables are set by every call to backup_step(). They are\n  ** read by calls to backup_remaining() and backup_pagecount().\n  */\n  Pgno nRemaining;         /* Number of pages left to copy */\n  Pgno nPagecount;         /* Total number of pages to copy */\n\n  int isAttached;          /* True once backup has been registered with pager */\n  sqlite3_backup *pNext;   /* Next backup associated with source pager */\n};\n\n/*\n** THREAD SAFETY NOTES:\n**\n**   Once it has been created using backup_init(), a single sqlite3_backup\n**   structure may be accessed via two groups of thread-safe entry points:\n**\n**     * Via the sqlite3_backup_XXX() API function backup_step() and \n**       backup_finish(). Both these functions obtain the source database\n**       handle mutex and the mutex associated with the source BtShared \n**       structure, in that order.\n**\n**     * Via the BackupUpdate() and BackupRestart() functions, which are\n**       invoked by the pager layer to report various state changes in\n**       the page cache associated with the source database. The mutex\n**       associated with the source database BtShared structure will always \n**       be held when either of these functions are invoked.\n**\n**   The other sqlite3_backup_XXX() API functions, backup_remaining() and\n**   backup_pagecount() are not thread-safe functions. If they are called\n**   while some other thread is calling backup_step() or backup_finish(),\n**   the values returned may be invalid. There is no way for a call to\n**   BackupUpdate() or BackupRestart() to interfere with backup_remaining()\n**   or backup_pagecount().\n**\n**   Depending on the SQLite configuration, the database handles and/or\n**   the Btree objects may have their own mutexes that require locking.\n**   Non-sharable Btrees (in-memory databases for example), do not have\n**   associated mutexes.\n*/\n\n/*\n** Return a pointer corresponding to database zDb (i.e. \"main\", \"temp\")\n** in connection handle pDb. If such a database cannot be found, return\n** a NULL pointer and write an error message to pErrorDb.\n**\n** If the \"temp\" database is requested, it may need to be opened by this \n** function. If an error occurs while doing so, return 0 and write an \n** error message to pErrorDb.\n*/\nstatic Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){\n  int i = sqlite3FindDbName(pDb, zDb);\n\n  if( i==1 ){\n    Parse sParse;\n    int rc = 0;\n    memset(&sParse, 0, sizeof(sParse));\n    sParse.db = pDb;\n    if( sqlite3OpenTempDatabase(&sParse) ){\n      sqlite3ErrorWithMsg(pErrorDb, sParse.rc, \"%s\", sParse.zErrMsg);\n      rc = SQLITE_ERROR;\n    }\n    sqlite3DbFree(pErrorDb, sParse.zErrMsg);\n    sqlite3ParserReset(&sParse);\n    if( rc ){\n      return 0;\n    }\n  }\n\n  if( i<0 ){\n    sqlite3ErrorWithMsg(pErrorDb, SQLITE_ERROR, \"unknown database %s\", zDb);\n    return 0;\n  }\n\n  return pDb->aDb[i].pBt;\n}\n\n/*\n** Attempt to set the page size of the destination to match the page size\n** of the source.\n*/\nstatic int setDestPgsz(sqlite3_backup *p){\n  int rc;\n  rc = sqlite3BtreeSetPageSize(p->pDest,sqlite3BtreeGetPageSize(p->pSrc),-1,0);\n  return rc;\n}\n\n/*\n** Check that there is no open read-transaction on the b-tree passed as the\n** second argument. If there is not, return SQLITE_OK. Otherwise, if there\n** is an open read-transaction, return SQLITE_ERROR and leave an error \n** message in database handle db.\n*/\nstatic int checkReadTransaction(sqlite3 *db, Btree *p){\n  if( sqlite3BtreeIsInReadTrans(p) ){\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"destination database is in use\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create an sqlite3_backup process to copy the contents of zSrcDb from\n** connection handle pSrcDb to zDestDb in pDestDb. If successful, return\n** a pointer to the new sqlite3_backup object.\n**\n** If an error occurs, NULL is returned and an error code and error message\n** stored in database handle pDestDb.\n*/\nsqlite3_backup *sqlite3_backup_init(\n  sqlite3* pDestDb,                     /* Database to write to */\n  const char *zDestDb,                  /* Name of database within pDestDb */\n  sqlite3* pSrcDb,                      /* Database connection to read from */\n  const char *zSrcDb                    /* Name of database within pSrcDb */\n){\n  sqlite3_backup *p;                    /* Value to return */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pSrcDb)||!sqlite3SafetyCheckOk(pDestDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  /* Lock the source database handle. The destination database\n  ** handle is not locked in this routine, but it is locked in\n  ** sqlite3_backup_step(). The user is required to ensure that no\n  ** other thread accesses the destination handle for the duration\n  ** of the backup operation.  Any attempt to use the destination\n  ** database connection while a backup is in progress may cause\n  ** a malfunction or a deadlock.\n  */\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3_mutex_enter(pDestDb->mutex);\n\n  if( pSrcDb==pDestDb ){\n    sqlite3ErrorWithMsg(\n        pDestDb, SQLITE_ERROR, \"source and destination must be distinct\"\n    );\n    p = 0;\n  }else {\n    /* Allocate space for a new sqlite3_backup object...\n    ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup));\n    if( !p ){\n      sqlite3Error(pDestDb, SQLITE_NOMEM_BKPT);\n    }\n  }\n\n  /* If the allocation succeeded, populate the new object. */\n  if( p ){\n    p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb);\n    p->pDest = findBtree(pDestDb, pDestDb, zDestDb);\n    p->pDestDb = pDestDb;\n    p->pSrcDb = pSrcDb;\n    p->iNext = 1;\n    p->isAttached = 0;\n\n    if( 0==p->pSrc || 0==p->pDest \n     || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK \n     ){\n      /* One (or both) of the named databases did not exist or an OOM\n      ** error was hit. Or there is a transaction open on the destination\n      ** database. The error has already been written into the pDestDb \n      ** handle. All that is left to do here is free the sqlite3_backup \n      ** structure.  */\n      sqlite3_free(p);\n      p = 0;\n    }\n  }\n  if( p ){\n    p->pSrc->nBackup++;\n  }\n\n  sqlite3_mutex_leave(pDestDb->mutex);\n  sqlite3_mutex_leave(pSrcDb->mutex);\n  return p;\n}\n\n/*\n** Argument rc is an SQLite error code. Return true if this error is \n** considered fatal if encountered during a backup operation. All errors\n** are considered fatal except for SQLITE_BUSY and SQLITE_LOCKED.\n*/\nstatic int isFatalError(int rc){\n  return (rc!=SQLITE_OK && rc!=SQLITE_BUSY && ALWAYS(rc!=SQLITE_LOCKED));\n}\n\n/*\n** Parameter zSrcData points to a buffer containing the data for \n** page iSrcPg from the source database. Copy this data into the \n** destination database.\n*/\nstatic int backupOnePage(\n  sqlite3_backup *p,              /* Backup handle */\n  Pgno iSrcPg,                    /* Source database page to backup */\n  const u8 *zSrcData,             /* Source database page data */\n  int bUpdate                     /* True for an update, false otherwise */\n){\n  Pager * const pDestPager = sqlite3BtreePager(p->pDest);\n  const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);\n  int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);\n  const int nCopy = MIN(nSrcPgsz, nDestPgsz);\n  const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;\n#ifdef SQLITE_HAS_CODEC\n  /* Use BtreeGetReserveNoMutex() for the source b-tree, as although it is\n  ** guaranteed that the shared-mutex is held by this thread, handle\n  ** p->pSrc may not actually be the owner.  */\n  int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);\n  int nDestReserve = sqlite3BtreeGetOptimalReserve(p->pDest);\n#endif\n  int rc = SQLITE_OK;\n  i64 iOff;\n\n  assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );\n  assert( p->bDestLocked );\n  assert( !isFatalError(p->rc) );\n  assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );\n  assert( zSrcData );\n\n  /* Catch the case where the destination is an in-memory database and the\n  ** page sizes of the source and destination differ. \n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){\n    rc = SQLITE_READONLY;\n  }\n\n#ifdef SQLITE_HAS_CODEC\n  /* Backup is not possible if the page size of the destination is changing\n  ** and a codec is in use.\n  */\n  if( nSrcPgsz!=nDestPgsz && sqlite3PagerGetCodec(pDestPager)!=0 ){\n    rc = SQLITE_READONLY;\n  }\n\n  /* Backup is not possible if the number of bytes of reserve space differ\n  ** between source and destination.  If there is a difference, try to\n  ** fix the destination to agree with the source.  If that is not possible,\n  ** then the backup cannot proceed.\n  */\n  if( nSrcReserve!=nDestReserve ){\n    u32 newPgsz = nSrcPgsz;\n    rc = sqlite3PagerSetPagesize(pDestPager, &newPgsz, nSrcReserve);\n    if( rc==SQLITE_OK && newPgsz!=nSrcPgsz ) rc = SQLITE_READONLY;\n  }\n#endif\n\n  /* This loop runs once for each destination page spanned by the source \n  ** page. For each iteration, variable iOff is set to the byte offset\n  ** of the destination page.\n  */\n  for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){\n    DbPage *pDestPg = 0;\n    Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;\n    if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;\n    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))\n     && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))\n    ){\n      const u8 *zIn = &zSrcData[iOff%nSrcPgsz];\n      u8 *zDestData = sqlite3PagerGetData(pDestPg);\n      u8 *zOut = &zDestData[iOff%nDestPgsz];\n\n      /* Copy the data from the source page into the destination page.\n      ** Then clear the Btree layer MemPage.isInit flag. Both this module\n      ** and the pager code use this trick (clearing the first byte\n      ** of the page 'extra' space to invalidate the Btree layers\n      ** cached parse of the page). MemPage.isInit is marked \n      ** \"MUST BE FIRST\" for this purpose.\n      */\n      memcpy(zOut, zIn, nCopy);\n      ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;\n      if( iOff==0 && bUpdate==0 ){\n        sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));\n      }\n    }\n    sqlite3PagerUnref(pDestPg);\n  }\n\n  return rc;\n}\n\n/*\n** If pFile is currently larger than iSize bytes, then truncate it to\n** exactly iSize bytes. If pFile is not larger than iSize bytes, then\n** this function is a no-op.\n**\n** Return SQLITE_OK if everything is successful, or an SQLite error \n** code if an error occurs.\n*/\nstatic int backupTruncateFile(sqlite3_file *pFile, i64 iSize){\n  i64 iCurrent;\n  int rc = sqlite3OsFileSize(pFile, &iCurrent);\n  if( rc==SQLITE_OK && iCurrent>iSize ){\n    rc = sqlite3OsTruncate(pFile, iSize);\n  }\n  return rc;\n}\n\n/*\n** Register this backup object with the associated source pager for\n** callbacks when pages are changed or the cache invalidated.\n*/\nstatic void attachBackupObject(sqlite3_backup *p){\n  sqlite3_backup **pp;\n  assert( sqlite3BtreeHoldsMutex(p->pSrc) );\n  pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n  p->pNext = *pp;\n  *pp = p;\n  p->isAttached = 1;\n}\n\n/*\n** Copy nPage pages from the source b-tree to the destination.\n*/\nint sqlite3_backup_step(sqlite3_backup *p, int nPage){\n  int rc;\n  int destMode;       /* Destination journal mode */\n  int pgszSrc = 0;    /* Source page size */\n  int pgszDest = 0;   /* Destination page size */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(p->pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  rc = p->rc;\n  if( !isFatalError(rc) ){\n    Pager * const pSrcPager = sqlite3BtreePager(p->pSrc);     /* Source pager */\n    Pager * const pDestPager = sqlite3BtreePager(p->pDest);   /* Dest pager */\n    int ii;                            /* Iterator variable */\n    int nSrcPage = -1;                 /* Size of source db in pages */\n    int bCloseTrans = 0;               /* True if src db requires unlocking */\n\n    /* If the source pager is currently in a write-transaction, return\n    ** SQLITE_BUSY immediately.\n    */\n    if( p->pDestDb && p->pSrc->pBt->inTransaction==TRANS_WRITE ){\n      rc = SQLITE_BUSY;\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* If there is no open read-transaction on the source database, open\n    ** one now. If a transaction is opened here, then it will be closed\n    ** before this function exits.\n    */\n    if( rc==SQLITE_OK && 0==sqlite3BtreeIsInReadTrans(p->pSrc) ){\n      rc = sqlite3BtreeBeginTrans(p->pSrc, 0);\n      bCloseTrans = 1;\n    }\n\n    /* If the destination database has not yet been locked (i.e. if this\n    ** is the first call to backup_step() for the current backup operation),\n    ** try to set its page size to the same as the source database. This\n    ** is especially important on ZipVFS systems, as in that case it is\n    ** not possible to create a database file that uses one page size by\n    ** writing to it with another.  */\n    if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){\n      rc = SQLITE_NOMEM;\n    }\n\n    /* Lock the destination database, if it is not locked already. */\n    if( SQLITE_OK==rc && p->bDestLocked==0\n     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2)) \n    ){\n      p->bDestLocked = 1;\n      sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);\n    }\n\n    /* Do not allow backup if the destination database is in WAL mode\n    ** and the page sizes are different between source and destination */\n    pgszSrc = sqlite3BtreeGetPageSize(p->pSrc);\n    pgszDest = sqlite3BtreeGetPageSize(p->pDest);\n    destMode = sqlite3PagerGetJournalMode(sqlite3BtreePager(p->pDest));\n    if( SQLITE_OK==rc && destMode==PAGER_JOURNALMODE_WAL && pgszSrc!=pgszDest ){\n      rc = SQLITE_READONLY;\n    }\n  \n    /* Now that there is a read-lock on the source database, query the\n    ** source pager for the number of pages in the database.\n    */\n    nSrcPage = (int)sqlite3BtreeLastPage(p->pSrc);\n    assert( nSrcPage>=0 );\n    for(ii=0; (nPage<0 || ii<nPage) && p->iNext<=(Pgno)nSrcPage && !rc; ii++){\n      const Pgno iSrcPg = p->iNext;                 /* Source page number */\n      if( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) ){\n        DbPage *pSrcPg;                             /* Source page object */\n        rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg,PAGER_GET_READONLY);\n        if( rc==SQLITE_OK ){\n          rc = backupOnePage(p, iSrcPg, sqlite3PagerGetData(pSrcPg), 0);\n          sqlite3PagerUnref(pSrcPg);\n        }\n      }\n      p->iNext++;\n    }\n    if( rc==SQLITE_OK ){\n      p->nPagecount = nSrcPage;\n      p->nRemaining = nSrcPage+1-p->iNext;\n      if( p->iNext>(Pgno)nSrcPage ){\n        rc = SQLITE_DONE;\n      }else if( !p->isAttached ){\n        attachBackupObject(p);\n      }\n    }\n  \n    /* Update the schema version field in the destination database. This\n    ** is to make sure that the schema-version really does change in\n    ** the case where the source and destination databases have the\n    ** same schema version.\n    */\n    if( rc==SQLITE_DONE ){\n      if( nSrcPage==0 ){\n        rc = sqlite3BtreeNewDb(p->pDest);\n        nSrcPage = 1;\n      }\n      if( rc==SQLITE_OK || rc==SQLITE_DONE ){\n        rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);\n      }\n      if( rc==SQLITE_OK ){\n        if( p->pDestDb ){\n          sqlite3ResetAllSchemasOfConnection(p->pDestDb);\n        }\n        if( destMode==PAGER_JOURNALMODE_WAL ){\n          rc = sqlite3BtreeSetVersion(p->pDest, 2);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        int nDestTruncate;\n        /* Set nDestTruncate to the final number of pages in the destination\n        ** database. The complication here is that the destination page\n        ** size may be different to the source page size. \n        **\n        ** If the source page size is smaller than the destination page size, \n        ** round up. In this case the call to sqlite3OsTruncate() below will\n        ** fix the size of the file. However it is important to call\n        ** sqlite3PagerTruncateImage() here so that any pages in the \n        ** destination file that lie beyond the nDestTruncate page mark are\n        ** journalled by PagerCommitPhaseOne() before they are destroyed\n        ** by the file truncation.\n        */\n        assert( pgszSrc==sqlite3BtreeGetPageSize(p->pSrc) );\n        assert( pgszDest==sqlite3BtreeGetPageSize(p->pDest) );\n        if( pgszSrc<pgszDest ){\n          int ratio = pgszDest/pgszSrc;\n          nDestTruncate = (nSrcPage+ratio-1)/ratio;\n          if( nDestTruncate==(int)PENDING_BYTE_PAGE(p->pDest->pBt) ){\n            nDestTruncate--;\n          }\n        }else{\n          nDestTruncate = nSrcPage * (pgszSrc/pgszDest);\n        }\n        assert( nDestTruncate>0 );\n\n        if( pgszSrc<pgszDest ){\n          /* If the source page-size is smaller than the destination page-size,\n          ** two extra things may need to happen:\n          **\n          **   * The destination may need to be truncated, and\n          **\n          **   * Data stored on the pages immediately following the \n          **     pending-byte page in the source database may need to be\n          **     copied into the destination database.\n          */\n          const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;\n          sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);\n          Pgno iPg;\n          int nDstPage;\n          i64 iOff;\n          i64 iEnd;\n\n          assert( pFile );\n          assert( nDestTruncate==0 \n              || (i64)nDestTruncate*(i64)pgszDest >= iSize || (\n                nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)\n             && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest\n          ));\n\n          /* This block ensures that all data required to recreate the original\n          ** database has been stored in the journal for pDestPager and the\n          ** journal synced to disk. So at this point we may safely modify\n          ** the database file in any way, knowing that if a power failure\n          ** occurs, the original database will be reconstructed from the \n          ** journal file.  */\n          sqlite3PagerPagecount(pDestPager, &nDstPage);\n          for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){\n            if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){\n              DbPage *pPg;\n              rc = sqlite3PagerGet(pDestPager, iPg, &pPg, 0);\n              if( rc==SQLITE_OK ){\n                rc = sqlite3PagerWrite(pPg);\n                sqlite3PagerUnref(pPg);\n              }\n            }\n          }\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);\n          }\n\n          /* Write the extra pages and truncate the database file as required */\n          iEnd = MIN(PENDING_BYTE + pgszDest, iSize);\n          for(\n            iOff=PENDING_BYTE+pgszSrc; \n            rc==SQLITE_OK && iOff<iEnd; \n            iOff+=pgszSrc\n          ){\n            PgHdr *pSrcPg = 0;\n            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);\n            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg, 0);\n            if( rc==SQLITE_OK ){\n              u8 *zData = sqlite3PagerGetData(pSrcPg);\n              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);\n            }\n            sqlite3PagerUnref(pSrcPg);\n          }\n          if( rc==SQLITE_OK ){\n            rc = backupTruncateFile(pFile, iSize);\n          }\n\n          /* Sync the database file to disk. */\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerSync(pDestPager, 0);\n          }\n        }else{\n          sqlite3PagerTruncateImage(pDestPager, nDestTruncate);\n          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);\n        }\n    \n        /* Finish committing the transaction to the destination database. */\n        if( SQLITE_OK==rc\n         && SQLITE_OK==(rc = sqlite3BtreeCommitPhaseTwo(p->pDest, 0))\n        ){\n          rc = SQLITE_DONE;\n        }\n      }\n    }\n  \n    /* If bCloseTrans is true, then this function opened a read transaction\n    ** on the source database. Close the read transaction here. There is\n    ** no need to check the return values of the btree methods here, as\n    ** \"committing\" a read-only transaction cannot fail.\n    */\n    if( bCloseTrans ){\n      TESTONLY( int rc2 );\n      TESTONLY( rc2  = ) sqlite3BtreeCommitPhaseOne(p->pSrc, 0);\n      TESTONLY( rc2 |= ) sqlite3BtreeCommitPhaseTwo(p->pSrc, 0);\n      assert( rc2==SQLITE_OK );\n    }\n  \n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    p->rc = rc;\n  }\n  if( p->pDestDb ){\n    sqlite3_mutex_leave(p->pDestDb->mutex);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  sqlite3_mutex_leave(p->pSrcDb->mutex);\n  return rc;\n}\n\n/*\n** Release all resources associated with an sqlite3_backup* handle.\n*/\nint sqlite3_backup_finish(sqlite3_backup *p){\n  sqlite3_backup **pp;                 /* Ptr to head of pagers backup list */\n  sqlite3 *pSrcDb;                     /* Source database connection */\n  int rc;                              /* Value to return */\n\n  /* Enter the mutexes */\n  if( p==0 ) return SQLITE_OK;\n  pSrcDb = p->pSrcDb;\n  sqlite3_mutex_enter(pSrcDb->mutex);\n  sqlite3BtreeEnter(p->pSrc);\n  if( p->pDestDb ){\n    sqlite3_mutex_enter(p->pDestDb->mutex);\n  }\n\n  /* Detach this backup from the source pager. */\n  if( p->pDestDb ){\n    p->pSrc->nBackup--;\n  }\n  if( p->isAttached ){\n    pp = sqlite3PagerBackupPtr(sqlite3BtreePager(p->pSrc));\n    while( *pp!=p ){\n      pp = &(*pp)->pNext;\n    }\n    *pp = p->pNext;\n  }\n\n  /* If a transaction is still open on the Btree, roll it back. */\n  sqlite3BtreeRollback(p->pDest, SQLITE_OK, 0);\n\n  /* Set the error code of the destination database handle. */\n  rc = (p->rc==SQLITE_DONE) ? SQLITE_OK : p->rc;\n  if( p->pDestDb ){\n    sqlite3Error(p->pDestDb, rc);\n\n    /* Exit the mutexes and free the backup context structure. */\n    sqlite3LeaveMutexAndCloseZombie(p->pDestDb);\n  }\n  sqlite3BtreeLeave(p->pSrc);\n  if( p->pDestDb ){\n    /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a\n    ** call to sqlite3_backup_init() and is destroyed by a call to\n    ** sqlite3_backup_finish(). */\n    sqlite3_free(p);\n  }\n  sqlite3LeaveMutexAndCloseZombie(pSrcDb);\n  return rc;\n}\n\n/*\n** Return the number of pages still to be backed up as of the most recent\n** call to sqlite3_backup_step().\n*/\nint sqlite3_backup_remaining(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nRemaining;\n}\n\n/*\n** Return the total number of pages in the source database as of the most \n** recent call to sqlite3_backup_step().\n*/\nint sqlite3_backup_pagecount(sqlite3_backup *p){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( p==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return p->nPagecount;\n}\n\n/*\n** This function is called after the contents of page iPage of the\n** source database have been modified. If page iPage has already been \n** copied into the destination database, then the data written to the\n** destination is now invalidated. The destination copy of iPage needs\n** to be updated with the new data before the backup operation is\n** complete.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nstatic SQLITE_NOINLINE void backupUpdate(\n  sqlite3_backup *p,\n  Pgno iPage,\n  const u8 *aData\n){\n  assert( p!=0 );\n  do{\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    if( !isFatalError(p->rc) && iPage<p->iNext ){\n      /* The backup process p has already copied page iPage. But now it\n      ** has been modified by a transaction on the source pager. Copy\n      ** the new data into the backup.\n      */\n      int rc;\n      assert( p->pDestDb );\n      sqlite3_mutex_enter(p->pDestDb->mutex);\n      rc = backupOnePage(p, iPage, aData, 1);\n      sqlite3_mutex_leave(p->pDestDb->mutex);\n      assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );\n      if( rc!=SQLITE_OK ){\n        p->rc = rc;\n      }\n    }\n  }while( (p = p->pNext)!=0 );\n}\nvoid sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){\n  if( pBackup ) backupUpdate(pBackup, iPage, aData);\n}\n\n/*\n** Restart the backup process. This is called when the pager layer\n** detects that the database has been modified by an external database\n** connection. In this case there is no way of knowing which of the\n** pages that have been copied into the destination database are still \n** valid and which are not, so the entire process needs to be restarted.\n**\n** It is assumed that the mutex associated with the BtShared object\n** corresponding to the source database is held when this function is\n** called.\n*/\nvoid sqlite3BackupRestart(sqlite3_backup *pBackup){\n  sqlite3_backup *p;                   /* Iterator variable */\n  for(p=pBackup; p; p=p->pNext){\n    assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );\n    p->iNext = 1;\n  }\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Copy the complete content of pBtFrom into pBtTo.  A transaction\n** must be active for both files.\n**\n** The size of file pTo may be reduced by this operation. If anything \n** goes wrong, the transaction on pTo is rolled back. If successful, the \n** transaction is committed before returning.\n*/\nint sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){\n  int rc;\n  sqlite3_file *pFd;              /* File descriptor for database pTo */\n  sqlite3_backup b;\n  sqlite3BtreeEnter(pTo);\n  sqlite3BtreeEnter(pFrom);\n\n  assert( sqlite3BtreeIsInTrans(pTo) );\n  pFd = sqlite3PagerFile(sqlite3BtreePager(pTo));\n  if( pFd->pMethods ){\n    i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom);\n    rc = sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n    if( rc ) goto copy_finished;\n  }\n\n  /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set\n  ** to 0. This is used by the implementations of sqlite3_backup_step()\n  ** and sqlite3_backup_finish() to detect that they are being called\n  ** from this function, not directly by the user.\n  */\n  memset(&b, 0, sizeof(b));\n  b.pSrcDb = pFrom->db;\n  b.pSrc = pFrom;\n  b.pDest = pTo;\n  b.iNext = 1;\n\n#ifdef SQLITE_HAS_CODEC\n  sqlite3PagerAlignReserve(sqlite3BtreePager(pTo), sqlite3BtreePager(pFrom));\n#endif\n\n  /* 0x7FFFFFFF is the hard limit for the number of pages in a database\n  ** file. By passing this as the number of pages to copy to\n  ** sqlite3_backup_step(), we can guarantee that the copy finishes \n  ** within a single call (unless an error occurs). The assert() statement\n  ** checks this assumption - (p->rc) should be set to either SQLITE_DONE \n  ** or an error code.  */\n  sqlite3_backup_step(&b, 0x7FFFFFFF);\n  assert( b.rc!=SQLITE_OK );\n\n  rc = sqlite3_backup_finish(&b);\n  if( rc==SQLITE_OK ){\n    pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED;\n  }else{\n    sqlite3PagerClearCache(sqlite3BtreePager(b.pDest));\n  }\n\n  assert( sqlite3BtreeIsInTrans(pTo)==0 );\ncopy_finished:\n  sqlite3BtreeLeave(pFrom);\n  sqlite3BtreeLeave(pTo);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VACUUM */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/bitvec.c",
    "content": "/*\n** 2008 February 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an object that represents a fixed-length\n** bitmap.  Bits are numbered starting with 1.\n**\n** A bitmap is used to record which pages of a database file have been\n** journalled during a transaction, or which pages have the \"dont-write\"\n** property.  Usually only a few pages are meet either condition.\n** So the bitmap is usually sparse and has low cardinality.\n** But sometimes (for example when during a DROP of a large table) most\n** or all of the pages in a database can get journalled.  In those cases, \n** the bitmap becomes dense with high cardinality.  The algorithm needs \n** to handle both cases well.\n**\n** The size of the bitmap is fixed when the object is created.\n**\n** All bits are clear when the bitmap is created.  Individual bits\n** may be set or cleared one at a time.\n**\n** Test operations are about 100 times more common that set operations.\n** Clear operations are exceedingly rare.  There are usually between\n** 5 and 500 set operations per Bitvec object, though the number of sets can\n** sometimes grow into tens of thousands or larger.  The size of the\n** Bitvec object is the number of pages in the database file at the\n** start of a transaction, and is thus usually less than a few thousand,\n** but can be as large as 2 billion for a really big database.\n*/\n#include \"sqliteInt.h\"\n\n/* Size of the Bitvec structure in bytes. */\n#define BITVEC_SZ        512\n\n/* Round the union size down to the nearest pointer boundary, since that's how \n** it will be aligned within the Bitvec struct. */\n#define BITVEC_USIZE \\\n    (((BITVEC_SZ-(3*sizeof(u32)))/sizeof(Bitvec*))*sizeof(Bitvec*))\n\n/* Type of the array \"element\" for the bitmap representation. \n** Should be a power of 2, and ideally, evenly divide into BITVEC_USIZE. \n** Setting this to the \"natural word\" size of your CPU may improve\n** performance. */\n#define BITVEC_TELEM     u8\n/* Size, in bits, of the bitmap element. */\n#define BITVEC_SZELEM    8\n/* Number of elements in a bitmap array. */\n#define BITVEC_NELEM     (BITVEC_USIZE/sizeof(BITVEC_TELEM))\n/* Number of bits in the bitmap array. */\n#define BITVEC_NBIT      (BITVEC_NELEM*BITVEC_SZELEM)\n\n/* Number of u32 values in hash table. */\n#define BITVEC_NINT      (BITVEC_USIZE/sizeof(u32))\n/* Maximum number of entries in hash table before \n** sub-dividing and re-hashing. */\n#define BITVEC_MXHASH    (BITVEC_NINT/2)\n/* Hashing function for the aHash representation.\n** Empirical testing showed that the *37 multiplier \n** (an arbitrary prime)in the hash function provided \n** no fewer collisions than the no-op *1. */\n#define BITVEC_HASH(X)   (((X)*1)%BITVEC_NINT)\n\n#define BITVEC_NPTR      (BITVEC_USIZE/sizeof(Bitvec *))\n\n\n/*\n** A bitmap is an instance of the following structure.\n**\n** This bitmap records the existence of zero or more bits\n** with values between 1 and iSize, inclusive.\n**\n** There are three possible representations of the bitmap.\n** If iSize<=BITVEC_NBIT, then Bitvec.u.aBitmap[] is a straight\n** bitmap.  The least significant bit is bit 1.\n**\n** If iSize>BITVEC_NBIT and iDivisor==0 then Bitvec.u.aHash[] is\n** a hash table that will hold up to BITVEC_MXHASH distinct values.\n**\n** Otherwise, the value i is redirected into one of BITVEC_NPTR\n** sub-bitmaps pointed to by Bitvec.u.apSub[].  Each subbitmap\n** handles up to iDivisor separate values of i.  apSub[0] holds\n** values between 1 and iDivisor.  apSub[1] holds values between\n** iDivisor+1 and 2*iDivisor.  apSub[N] holds values between\n** N*iDivisor+1 and (N+1)*iDivisor.  Each subbitmap is normalized\n** to hold deal with values between 1 and iDivisor.\n*/\nstruct Bitvec {\n  u32 iSize;      /* Maximum bit index.  Max iSize is 4,294,967,296. */\n  u32 nSet;       /* Number of bits that are set - only valid for aHash\n                  ** element.  Max is BITVEC_NINT.  For BITVEC_SZ of 512,\n                  ** this would be 125. */\n  u32 iDivisor;   /* Number of bits handled by each apSub[] entry. */\n                  /* Should >=0 for apSub element. */\n                  /* Max iDivisor is max(u32) / BITVEC_NPTR + 1.  */\n                  /* For a BITVEC_SZ of 512, this would be 34,359,739. */\n  union {\n    BITVEC_TELEM aBitmap[BITVEC_NELEM];    /* Bitmap representation */\n    u32 aHash[BITVEC_NINT];      /* Hash table representation */\n    Bitvec *apSub[BITVEC_NPTR];  /* Recursive representation */\n  } u;\n};\n\n/*\n** Create a new bitmap object able to handle bits between 0 and iSize,\n** inclusive.  Return a pointer to the new object.  Return NULL if \n** malloc fails.\n*/\nBitvec *sqlite3BitvecCreate(u32 iSize){\n  Bitvec *p;\n  assert( sizeof(*p)==BITVEC_SZ );\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p ){\n    p->iSize = iSize;\n  }\n  return p;\n}\n\n/*\n** Check to see if the i-th bit is set.  Return true or false.\n** If p is NULL (if the bitmap has not been created) or if\n** i is out of range, then return false.\n*/\nint sqlite3BitvecTestNotNull(Bitvec *p, u32 i){\n  assert( p!=0 );\n  i--;\n  if( i>=p->iSize ) return 0;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return 0;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    return (p->u.aBitmap[i/BITVEC_SZELEM] & (1<<(i&(BITVEC_SZELEM-1))))!=0;\n  } else{\n    u32 h = BITVEC_HASH(i++);\n    while( p->u.aHash[h] ){\n      if( p->u.aHash[h]==i ) return 1;\n      h = (h+1) % BITVEC_NINT;\n    }\n    return 0;\n  }\n}\nint sqlite3BitvecTest(Bitvec *p, u32 i){\n  return p!=0 && sqlite3BitvecTestNotNull(p,i);\n}\n\n/*\n** Set the i-th bit.  Return 0 on success and an error code if\n** anything goes wrong.\n**\n** This routine might cause sub-bitmaps to be allocated.  Failing\n** to get the memory needed to hold the sub-bitmap is the only\n** that can go wrong with an insert, assuming p and i are valid.\n**\n** The calling function must ensure that p is a valid Bitvec object\n** and that the value for \"i\" is within range of the Bitvec object.\n** Otherwise the behavior is undefined.\n*/\nint sqlite3BitvecSet(Bitvec *p, u32 i){\n  u32 h;\n  if( p==0 ) return SQLITE_OK;\n  assert( i>0 );\n  assert( i<=p->iSize );\n  i--;\n  while((p->iSize > BITVEC_NBIT) && p->iDivisor) {\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    if( p->u.apSub[bin]==0 ){\n      p->u.apSub[bin] = sqlite3BitvecCreate( p->iDivisor );\n      if( p->u.apSub[bin]==0 ) return SQLITE_NOMEM_BKPT;\n    }\n    p = p->u.apSub[bin];\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] |= 1 << (i&(BITVEC_SZELEM-1));\n    return SQLITE_OK;\n  }\n  h = BITVEC_HASH(i++);\n  /* if there wasn't a hash collision, and this doesn't */\n  /* completely fill the hash, then just add it without */\n  /* worring about sub-dividing and re-hashing. */\n  if( !p->u.aHash[h] ){\n    if (p->nSet<(BITVEC_NINT-1)) {\n      goto bitvec_set_end;\n    } else {\n      goto bitvec_set_rehash;\n    }\n  }\n  /* there was a collision, check to see if it's already */\n  /* in hash, if not, try to find a spot for it */\n  do {\n    if( p->u.aHash[h]==i ) return SQLITE_OK;\n    h++;\n    if( h>=BITVEC_NINT ) h = 0;\n  } while( p->u.aHash[h] );\n  /* we didn't find it in the hash.  h points to the first */\n  /* available free spot. check to see if this is going to */\n  /* make our hash too \"full\".  */\nbitvec_set_rehash:\n  if( p->nSet>=BITVEC_MXHASH ){\n    unsigned int j;\n    int rc;\n    u32 *aiValues = sqlite3StackAllocRaw(0, sizeof(p->u.aHash));\n    if( aiValues==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }else{\n      memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n      memset(p->u.apSub, 0, sizeof(p->u.apSub));\n      p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR;\n      rc = sqlite3BitvecSet(p, i);\n      for(j=0; j<BITVEC_NINT; j++){\n        if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]);\n      }\n      sqlite3StackFree(0, aiValues);\n      return rc;\n    }\n  }\nbitvec_set_end:\n  p->nSet++;\n  p->u.aHash[h] = i;\n  return SQLITE_OK;\n}\n\n/*\n** Clear the i-th bit.\n**\n** pBuf must be a pointer to at least BITVEC_SZ bytes of temporary storage\n** that BitvecClear can use to rebuilt its hash table.\n*/\nvoid sqlite3BitvecClear(Bitvec *p, u32 i, void *pBuf){\n  if( p==0 ) return;\n  assert( i>0 );\n  i--;\n  while( p->iDivisor ){\n    u32 bin = i/p->iDivisor;\n    i = i%p->iDivisor;\n    p = p->u.apSub[bin];\n    if (!p) {\n      return;\n    }\n  }\n  if( p->iSize<=BITVEC_NBIT ){\n    p->u.aBitmap[i/BITVEC_SZELEM] &= ~(1 << (i&(BITVEC_SZELEM-1)));\n  }else{\n    unsigned int j;\n    u32 *aiValues = pBuf;\n    memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash));\n    memset(p->u.aHash, 0, sizeof(p->u.aHash));\n    p->nSet = 0;\n    for(j=0; j<BITVEC_NINT; j++){\n      if( aiValues[j] && aiValues[j]!=(i+1) ){\n        u32 h = BITVEC_HASH(aiValues[j]-1);\n        p->nSet++;\n        while( p->u.aHash[h] ){\n          h++;\n          if( h>=BITVEC_NINT ) h = 0;\n        }\n        p->u.aHash[h] = aiValues[j];\n      }\n    }\n  }\n}\n\n/*\n** Destroy a bitmap object.  Reclaim all memory used.\n*/\nvoid sqlite3BitvecDestroy(Bitvec *p){\n  if( p==0 ) return;\n  if( p->iDivisor ){\n    unsigned int i;\n    for(i=0; i<BITVEC_NPTR; i++){\n      sqlite3BitvecDestroy(p->u.apSub[i]);\n    }\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Return the value of the iSize parameter specified when Bitvec *p\n** was created.\n*/\nu32 sqlite3BitvecSize(Bitvec *p){\n  return p->iSize;\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** Let V[] be an array of unsigned characters sufficient to hold\n** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.\n** Then the following macros can be used to set, clear, or test\n** individual bits within V.\n*/\n#define SETBIT(V,I)      V[I>>3] |= (1<<(I&7))\n#define CLEARBIT(V,I)    V[I>>3] &= ~(1<<(I&7))\n#define TESTBIT(V,I)     (V[I>>3]&(1<<(I&7)))!=0\n\n/*\n** This routine runs an extensive test of the Bitvec code.\n**\n** The input is an array of integers that acts as a program\n** to test the Bitvec.  The integers are opcodes followed\n** by 0, 1, or 3 operands, depending on the opcode.  Another\n** opcode follows immediately after the last operand.\n**\n** There are 6 opcodes numbered from 0 through 5.  0 is the\n** \"halt\" opcode and causes the test to end.\n**\n**    0          Halt and return the number of errors\n**    1 N S X    Set N bits beginning with S and incrementing by X\n**    2 N S X    Clear N bits beginning with S and incrementing by X\n**    3 N        Set N randomly chosen bits\n**    4 N        Clear N randomly chosen bits\n**    5 N S X    Set N bits from S increment X in array only, not in bitvec\n**\n** The opcodes 1 through 4 perform set and clear operations are performed\n** on both a Bitvec object and on a linear array of bits obtained from malloc.\n** Opcode 5 works on the linear array only, not on the Bitvec.\n** Opcode 5 is used to deliberately induce a fault in order to\n** confirm that error detection works.\n**\n** At the conclusion of the test the linear array is compared\n** against the Bitvec object.  If there are any differences,\n** an error is returned.  If they are the same, zero is returned.\n**\n** If a memory allocation error occurs, return -1.\n*/\nint sqlite3BitvecBuiltinTest(int sz, int *aOp){\n  Bitvec *pBitvec = 0;\n  unsigned char *pV = 0;\n  int rc = -1;\n  int i, nx, pc, op;\n  void *pTmpSpace;\n\n  /* Allocate the Bitvec to be tested and a linear array of\n  ** bits to act as the reference */\n  pBitvec = sqlite3BitvecCreate( sz );\n  pV = sqlite3MallocZero( (sz+7)/8 + 1 );\n  pTmpSpace = sqlite3_malloc64(BITVEC_SZ);\n  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;\n\n  /* NULL pBitvec tests */\n  sqlite3BitvecSet(0, 1);\n  sqlite3BitvecClear(0, 1, pTmpSpace);\n\n  /* Run the program */\n  pc = 0;\n  while( (op = aOp[pc])!=0 ){\n    switch( op ){\n      case 1:\n      case 2:\n      case 5: {\n        nx = 4;\n        i = aOp[pc+2] - 1;\n        aOp[pc+2] += aOp[pc+3];\n        break;\n      }\n      case 3:\n      case 4: \n      default: {\n        nx = 2;\n        sqlite3_randomness(sizeof(i), &i);\n        break;\n      }\n    }\n    if( (--aOp[pc+1]) > 0 ) nx = 0;\n    pc += nx;\n    i = (i & 0x7fffffff)%sz;\n    if( (op & 1)!=0 ){\n      SETBIT(pV, (i+1));\n      if( op!=5 ){\n        if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;\n      }\n    }else{\n      CLEARBIT(pV, (i+1));\n      sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);\n    }\n  }\n\n  /* Test to make sure the linear array exactly matches the\n  ** Bitvec object.  Start with the assumption that they do\n  ** match (rc==0).  Change rc to non-zero if a discrepancy\n  ** is found.\n  */\n  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)\n          + sqlite3BitvecTest(pBitvec, 0)\n          + (sqlite3BitvecSize(pBitvec) - sz);\n  for(i=1; i<=sz; i++){\n    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){\n      rc = i;\n      break;\n    }\n  }\n\n  /* Free allocated structure */\nbitvec_end:\n  sqlite3_free(pTmpSpace);\n  sqlite3_free(pV);\n  sqlite3BitvecDestroy(pBitvec);\n  return rc;\n}\n#endif /* SQLITE_UNTESTABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/btmutex.c",
    "content": "/*\n** 2007 August 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement mutexes on Btree objects.\n** This code really belongs in btree.c.  But btree.c is getting too\n** big and we want to break it down some.  This packaged seemed like\n** a good breakout.\n*/\n#include \"btreeInt.h\"\n#ifndef SQLITE_OMIT_SHARED_CACHE\n#if SQLITE_THREADSAFE\n\n/*\n** Obtain the BtShared mutex associated with B-Tree handle p. Also,\n** set BtShared.db to the database handle associated with p and the\n** p->locked boolean to true.\n*/\nstatic void lockBtreeMutex(Btree *p){\n  assert( p->locked==0 );\n  assert( sqlite3_mutex_notheld(p->pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  sqlite3_mutex_enter(p->pBt->mutex);\n  p->pBt->db = p->db;\n  p->locked = 1;\n}\n\n/*\n** Release the BtShared mutex associated with B-Tree handle p and\n** clear the p->locked boolean.\n*/\nstatic void SQLITE_NOINLINE unlockBtreeMutex(Btree *p){\n  BtShared *pBt = p->pBt;\n  assert( p->locked==1 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  assert( p->db==pBt->db );\n\n  sqlite3_mutex_leave(pBt->mutex);\n  p->locked = 0;\n}\n\n/* Forward reference */\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p);\n\n/*\n** Enter a mutex on the given BTree object.\n**\n** If the object is not sharable, then no mutex is ever required\n** and this routine is a no-op.  The underlying mutex is non-recursive.\n** But we keep a reference count in Btree.wantToLock so the behavior\n** of this interface is recursive.\n**\n** To avoid deadlocks, multiple Btrees are locked in the same order\n** by all database connections.  The p->pNext is a list of other\n** Btrees belonging to the same database connection as the p Btree\n** which need to be locked after p.  If we cannot get a lock on\n** p, then first unlock all of the others on p->pNext, then wait\n** for the lock to become available on p, then relock all of the\n** subsequent Btrees that desire a lock.\n*/\nvoid sqlite3BtreeEnter(Btree *p){\n  /* Some basic sanity checking on the Btree.  The list of Btrees\n  ** connected by pNext and pPrev should be in sorted order by\n  ** Btree.pBt value. All elements of the list should belong to\n  ** the same connection. Only shared Btrees are on the list. */\n  assert( p->pNext==0 || p->pNext->pBt>p->pBt );\n  assert( p->pPrev==0 || p->pPrev->pBt<p->pBt );\n  assert( p->pNext==0 || p->pNext->db==p->db );\n  assert( p->pPrev==0 || p->pPrev->db==p->db );\n  assert( p->sharable || (p->pNext==0 && p->pPrev==0) );\n\n  /* Check for locking consistency */\n  assert( !p->locked || p->wantToLock>0 );\n  assert( p->sharable || p->wantToLock==0 );\n\n  /* We should already hold a lock on the database connection */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n\n  /* Unless the database is sharable and unlocked, then BtShared.db\n  ** should already be set correctly. */\n  assert( (p->locked==0 && p->sharable) || p->pBt->db==p->db );\n\n  if( !p->sharable ) return;\n  p->wantToLock++;\n  if( p->locked ) return;\n  btreeLockCarefully(p);\n}\n\n/* This is a helper function for sqlite3BtreeLock(). By moving\n** complex, but seldom used logic, out of sqlite3BtreeLock() and\n** into this routine, we avoid unnecessary stack pointer changes\n** and thus help the sqlite3BtreeLock() routine to run much faster\n** in the common case.\n*/\nstatic void SQLITE_NOINLINE btreeLockCarefully(Btree *p){\n  Btree *pLater;\n\n  /* In most cases, we should be able to acquire the lock we\n  ** want without having to go through the ascending lock\n  ** procedure that follows.  Just be sure not to block.\n  */\n  if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){\n    p->pBt->db = p->db;\n    p->locked = 1;\n    return;\n  }\n\n  /* To avoid deadlock, first release all locks with a larger\n  ** BtShared address.  Then acquire our lock.  Then reacquire\n  ** the other BtShared locks that we used to hold in ascending\n  ** order.\n  */\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    assert( pLater->sharable );\n    assert( pLater->pNext==0 || pLater->pNext->pBt>pLater->pBt );\n    assert( !pLater->locked || pLater->wantToLock>0 );\n    if( pLater->locked ){\n      unlockBtreeMutex(pLater);\n    }\n  }\n  lockBtreeMutex(p);\n  for(pLater=p->pNext; pLater; pLater=pLater->pNext){\n    if( pLater->wantToLock ){\n      lockBtreeMutex(pLater);\n    }\n  }\n}\n\n\n/*\n** Exit the recursive mutex on a Btree.\n*/\nvoid sqlite3BtreeLeave(Btree *p){\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  if( p->sharable ){\n    assert( p->wantToLock>0 );\n    p->wantToLock--;\n    if( p->wantToLock==0 ){\n      unlockBtreeMutex(p);\n    }\n  }\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the BtShared mutex is held on the btree, or if the\n** B-Tree is not marked as sharable.\n**\n** This routine is used only from within assert() statements.\n*/\nint sqlite3BtreeHoldsMutex(Btree *p){\n  assert( p->sharable==0 || p->locked==0 || p->wantToLock>0 );\n  assert( p->sharable==0 || p->locked==0 || p->db==p->pBt->db );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->pBt->mutex) );\n  assert( p->sharable==0 || p->locked==0 || sqlite3_mutex_held(p->db->mutex) );\n\n  return (p->sharable==0 || p->locked);\n}\n#endif\n\n\n/*\n** Enter the mutex on every Btree associated with a database\n** connection.  This is needed (for example) prior to parsing\n** a statement since we will be comparing table and column names\n** against all schemas and we do not want those schemas being\n** reset out from under us.\n**\n** There is a corresponding leave-all procedures.\n**\n** Enter the mutexes in accending order by BtShared pointer address\n** to avoid the possibility of deadlock when two threads with\n** two or more btrees in common both try to lock all their btrees\n** at the same instant.\n*/\nstatic void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){\n  int i;\n  int skipOk = 1;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p && p->sharable ){\n      sqlite3BtreeEnter(p);\n      skipOk = 0;\n    }\n  }\n  db->skipBtreeMutex = skipOk;\n}\nvoid sqlite3BtreeEnterAll(sqlite3 *db){\n  if( db->skipBtreeMutex==0 ) btreeEnterAll(db);\n}\nstatic void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){\n  int i;\n  Btree *p;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nDb; i++){\n    p = db->aDb[i].pBt;\n    if( p ) sqlite3BtreeLeave(p);\n  }\n}\nvoid sqlite3BtreeLeaveAll(sqlite3 *db){\n  if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);\n}\n\n#ifndef NDEBUG\n/*\n** Return true if the current thread holds the database connection\n** mutex and all required BtShared mutexes.\n**\n** This routine is used inside assert() statements only.\n*/\nint sqlite3BtreeHoldsAllMutexes(sqlite3 *db){\n  int i;\n  if( !sqlite3_mutex_held(db->mutex) ){\n    return 0;\n  }\n  for(i=0; i<db->nDb; i++){\n    Btree *p;\n    p = db->aDb[i].pBt;\n    if( p && p->sharable &&\n         (p->wantToLock==0 || !sqlite3_mutex_held(p->pBt->mutex)) ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* NDEBUG */\n\n#ifndef NDEBUG\n/*\n** Return true if the correct mutexes are held for accessing the\n** db->aDb[iDb].pSchema structure.  The mutexes required for schema\n** access are:\n**\n**   (1) The mutex on db\n**   (2) if iDb!=1, then the mutex on db->aDb[iDb].pBt.\n**\n** If pSchema is not NULL, then iDb is computed from pSchema and\n** db using sqlite3SchemaToIndex().\n*/\nint sqlite3SchemaMutexHeld(sqlite3 *db, int iDb, Schema *pSchema){\n  Btree *p;\n  assert( db!=0 );\n  if( pSchema ) iDb = sqlite3SchemaToIndex(db, pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  if( !sqlite3_mutex_held(db->mutex) ) return 0;\n  if( iDb==1 ) return 1;\n  p = db->aDb[iDb].pBt;\n  assert( p!=0 );\n  return p->sharable==0 || p->locked==1;\n}\n#endif /* NDEBUG */\n\n#else /* SQLITE_THREADSAFE>0 above.  SQLITE_THREADSAFE==0 below */\n/*\n** The following are special cases for mutex enter routines for use\n** in single threaded applications that use shared cache.  Except for\n** these two routines, all mutex operations are no-ops in that case and\n** are null #defines in btree.h.\n**\n** If shared cache is disabled, then all btree mutex routines, including\n** the ones below, are no-ops and are null #defines in btree.h.\n*/\n\nvoid sqlite3BtreeEnter(Btree *p){\n  p->pBt->db = p->db;\n}\nvoid sqlite3BtreeEnterAll(sqlite3 *db){\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      p->pBt->db = p->db;\n    }\n  }\n}\n#endif /* if SQLITE_THREADSAFE */\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Enter a mutex on a Btree given a cursor owned by that Btree. \n**\n** These entry points are used by incremental I/O only. Enter() is required \n** any time OMIT_SHARED_CACHE is not defined, regardless of whether or not \n** the build is threadsafe. Leave() is only required by threadsafe builds.\n*/\nvoid sqlite3BtreeEnterCursor(BtCursor *pCur){\n  sqlite3BtreeEnter(pCur->pBtree);\n}\n# if SQLITE_THREADSAFE\nvoid sqlite3BtreeLeaveCursor(BtCursor *pCur){\n  sqlite3BtreeLeave(pCur->pBtree);\n}\n# endif\n#endif /* ifndef SQLITE_OMIT_INCRBLOB */\n\n#endif /* ifndef SQLITE_OMIT_SHARED_CACHE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/btree.c",
    "content": "/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** See the header comment on \"btreeInt.h\" for additional information.\n** Including a description of file format and an overview of operation.\n*/\n#include \"btreeInt.h\"\n\n/*\n** The header string that appears at the beginning of every\n** SQLite database.\n*/\nstatic const char zMagicHeader[] = SQLITE_FILE_HEADER;\n\n/*\n** Set this global variable to 1 to enable tracing using the TRACE\n** macro.\n*/\n#if 0\nint sqlite3BtreeTrace=1;  /* True to enable tracing */\n# define TRACE(X)  if(sqlite3BtreeTrace){printf X;fflush(stdout);}\n#else\n# define TRACE(X)\n#endif\n\n/*\n** Extract a 2-byte big-endian integer from an array of unsigned bytes.\n** But if the value is zero, make it 65536.\n**\n** This routine is used to extract the \"offset to cell content area\" value\n** from the header of a btree page.  If the page size is 65536 and the page\n** is empty, the offset should be 65536, but the 2-byte value stores zero.\n** This routine makes the necessary adjustment to 65536.\n*/\n#define get2byteNotZero(X)  (((((int)get2byte(X))-1)&0xffff)+1)\n\n/*\n** Values passed as the 5th argument to allocateBtreePage()\n*/\n#define BTALLOC_ANY   0           /* Allocate any page */\n#define BTALLOC_EXACT 1           /* Allocate exact page if possible */\n#define BTALLOC_LE    2           /* Allocate any page <= the parameter */\n\n/*\n** Macro IfNotOmitAV(x) returns (x) if SQLITE_OMIT_AUTOVACUUM is not \n** defined, or 0 if it is. For example:\n**\n**   bIncrVacuum = IfNotOmitAV(pBtShared->incrVacuum);\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define IfNotOmitAV(expr) (expr)\n#else\n#define IfNotOmitAV(expr) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** A list of BtShared objects that are eligible for participation\n** in shared cache.  This variable has file scope during normal builds,\n** but the test harness needs to access it so we make it global for \n** test builds.\n**\n** Access to this variable is protected by SQLITE_MUTEX_STATIC_MASTER.\n*/\n#ifdef SQLITE_TEST\nBtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#else\nstatic BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;\n#endif\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Enable or disable the shared pager and schema features.\n**\n** This routine has no effect on existing database connections.\n** The shared cache setting effects only future calls to\n** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().\n*/\nint sqlite3_enable_shared_cache(int enable){\n  sqlite3GlobalConfig.sharedCacheEnabled = enable;\n  return SQLITE_OK;\n}\n#endif\n\n\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n  /*\n  ** The functions querySharedCacheTableLock(), setSharedCacheTableLock(),\n  ** and clearAllSharedCacheTableLocks()\n  ** manipulate entries in the BtShared.pLock linked list used to store\n  ** shared-cache table level locks. If the library is compiled with the\n  ** shared-cache feature disabled, then there is only ever one user\n  ** of each BtShared structure and so this locking is not necessary. \n  ** So define the lock related functions as no-ops.\n  */\n  #define querySharedCacheTableLock(a,b,c) SQLITE_OK\n  #define setSharedCacheTableLock(a,b,c) SQLITE_OK\n  #define clearAllSharedCacheTableLocks(a)\n  #define downgradeAllSharedCacheTableLocks(a)\n  #define hasSharedCacheTableLock(a,b,c,d) 1\n  #define hasReadConflicts(a, b) 0\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function is only used as part of an assert() statement. ***\n**\n** Check to see if pBtree holds the required locks to read or write to the \n** table with root page iRoot.   Return 1 if it does and 0 if not.\n**\n** For example, when writing to a table with root-page iRoot via \n** Btree connection pBtree:\n**\n**    assert( hasSharedCacheTableLock(pBtree, iRoot, 0, WRITE_LOCK) );\n**\n** When writing to an index that resides in a sharable database, the \n** caller should have first obtained a lock specifying the root page of\n** the corresponding table. This makes things a bit more complicated,\n** as this module treats each table as a separate structure. To determine\n** the table corresponding to the index being written, this\n** function has to search through the database schema.\n**\n** Instead of a lock on the table/index rooted at page iRoot, the caller may\n** hold a write-lock on the schema table (root page 1). This is also\n** acceptable.\n*/\nstatic int hasSharedCacheTableLock(\n  Btree *pBtree,         /* Handle that must hold lock */\n  Pgno iRoot,            /* Root page of b-tree */\n  int isIndex,           /* True if iRoot is the root of an index b-tree */\n  int eLockType          /* Required lock type (READ_LOCK or WRITE_LOCK) */\n){\n  Schema *pSchema = (Schema *)pBtree->pBt->pSchema;\n  Pgno iTab = 0;\n  BtLock *pLock;\n\n  /* If this database is not shareable, or if the client is reading\n  ** and has the read-uncommitted flag set, then no lock is required. \n  ** Return true immediately.\n  */\n  if( (pBtree->sharable==0)\n   || (eLockType==READ_LOCK && (pBtree->db->flags & SQLITE_ReadUncommit))\n  ){\n    return 1;\n  }\n\n  /* If the client is reading  or writing an index and the schema is\n  ** not loaded, then it is too difficult to actually check to see if\n  ** the correct locks are held.  So do not bother - just return true.\n  ** This case does not come up very often anyhow.\n  */\n  if( isIndex && (!pSchema || (pSchema->schemaFlags&DB_SchemaLoaded)==0) ){\n    return 1;\n  }\n\n  /* Figure out the root-page that the lock should be held on. For table\n  ** b-trees, this is just the root page of the b-tree being read or\n  ** written. For index b-trees, it is the root page of the associated\n  ** table.  */\n  if( isIndex ){\n    HashElem *p;\n    for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){\n      Index *pIdx = (Index *)sqliteHashData(p);\n      if( pIdx->tnum==(int)iRoot ){\n        if( iTab ){\n          /* Two or more indexes share the same root page.  There must\n          ** be imposter tables.  So just return true.  The assert is not\n          ** useful in that case. */\n          return 1;\n        }\n        iTab = pIdx->pTable->tnum;\n      }\n    }\n  }else{\n    iTab = iRoot;\n  }\n\n  /* Search for the required lock. Either a write-lock on root-page iTab, a \n  ** write-lock on the schema table, or (if the client is reading) a\n  ** read-lock on iTab will suffice. Return 1 if any of these are found.  */\n  for(pLock=pBtree->pBt->pLock; pLock; pLock=pLock->pNext){\n    if( pLock->pBtree==pBtree \n     && (pLock->iTable==iTab || (pLock->eLock==WRITE_LOCK && pLock->iTable==1))\n     && pLock->eLock>=eLockType \n    ){\n      return 1;\n    }\n  }\n\n  /* Failed to find the required lock. */\n  return 0;\n}\n#endif /* SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n**** This function may be used as part of assert() statements only. ****\n**\n** Return true if it would be illegal for pBtree to write into the\n** table or index rooted at iRoot because other shared connections are\n** simultaneously reading that same table or index.\n**\n** It is illegal for pBtree to write if some other Btree object that\n** shares the same BtShared object is currently reading or writing\n** the iRoot table.  Except, if the other Btree object has the\n** read-uncommitted flag set, then it is OK for the other object to\n** have a read cursor.\n**\n** For example, before writing to any part of the table or index\n** rooted at page iRoot, one should call:\n**\n**    assert( !hasReadConflicts(pBtree, iRoot) );\n*/\nstatic int hasReadConflicts(Btree *pBtree, Pgno iRoot){\n  BtCursor *p;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( p->pgnoRoot==iRoot \n     && p->pBtree!=pBtree\n     && 0==(p->pBtree->db->flags & SQLITE_ReadUncommit)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif    /* #ifdef SQLITE_DEBUG */\n\n/*\n** Query to see if Btree handle p may obtain a lock of type eLock \n** (READ_LOCK or WRITE_LOCK) on the table with root-page iTab. Return\n** SQLITE_OK if the lock may be obtained (by calling\n** setSharedCacheTableLock()), or SQLITE_LOCKED if not.\n*/\nstatic int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n  assert( !(p->db->flags&SQLITE_ReadUncommit)||eLock==WRITE_LOCK||iTab==1 );\n  \n  /* If requesting a write-lock, then the Btree must have an open write\n  ** transaction on this file. And, obviously, for this to be so there \n  ** must be an open write transaction on the file itself.\n  */\n  assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );\n  assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );\n  \n  /* This routine is a no-op if the shared-cache is not enabled */\n  if( !p->sharable ){\n    return SQLITE_OK;\n  }\n\n  /* If some other connection is holding an exclusive lock, the\n  ** requested lock may not be obtained.\n  */\n  if( pBt->pWriter!=p && (pBt->btsFlags & BTS_EXCLUSIVE)!=0 ){\n    sqlite3ConnectionBlocked(p->db, pBt->pWriter->db);\n    return SQLITE_LOCKED_SHAREDCACHE;\n  }\n\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    /* The condition (pIter->eLock!=eLock) in the following if(...) \n    ** statement is a simplification of:\n    **\n    **   (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)\n    **\n    ** since we know that if eLock==WRITE_LOCK, then no other connection\n    ** may hold a WRITE_LOCK on any table in this file (since there can\n    ** only be a single writer).\n    */\n    assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );\n    assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);\n    if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){\n      sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);\n      if( eLock==WRITE_LOCK ){\n        assert( p==pBt->pWriter );\n        pBt->btsFlags |= BTS_PENDING;\n      }\n      return SQLITE_LOCKED_SHAREDCACHE;\n    }\n  }\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Add a lock on the table with root-page iTable to the shared-btree used\n** by Btree handle p. Parameter eLock must be either READ_LOCK or \n** WRITE_LOCK.\n**\n** This function assumes the following:\n**\n**   (a) The specified Btree object p is connected to a sharable\n**       database (one with the BtShared.sharable flag set), and\n**\n**   (b) No other Btree objects hold a lock that conflicts\n**       with the requested lock (i.e. querySharedCacheTableLock() has\n**       already been called and returned SQLITE_OK).\n**\n** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM \n** is returned if a malloc attempt fails.\n*/\nstatic int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){\n  BtShared *pBt = p->pBt;\n  BtLock *pLock = 0;\n  BtLock *pIter;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( eLock==READ_LOCK || eLock==WRITE_LOCK );\n  assert( p->db!=0 );\n\n  /* A connection with the read-uncommitted flag set will never try to\n  ** obtain a read-lock using this function. The only read-lock obtained\n  ** by a connection in read-uncommitted mode is on the sqlite_master \n  ** table, and that lock is obtained in BtreeBeginTrans().  */\n  assert( 0==(p->db->flags&SQLITE_ReadUncommit) || eLock==WRITE_LOCK );\n\n  /* This function should only be called on a sharable b-tree after it \n  ** has been determined that no other b-tree holds a conflicting lock.  */\n  assert( p->sharable );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );\n\n  /* First search the list for an existing lock on this table. */\n  for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n    if( pIter->iTable==iTable && pIter->pBtree==p ){\n      pLock = pIter;\n      break;\n    }\n  }\n\n  /* If the above search did not find a BtLock struct associating Btree p\n  ** with table iTable, allocate one and link it into the list.\n  */\n  if( !pLock ){\n    pLock = (BtLock *)sqlite3MallocZero(sizeof(BtLock));\n    if( !pLock ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pLock->iTable = iTable;\n    pLock->pBtree = p;\n    pLock->pNext = pBt->pLock;\n    pBt->pLock = pLock;\n  }\n\n  /* Set the BtLock.eLock variable to the maximum of the current lock\n  ** and the requested lock. This means if a write-lock was already held\n  ** and a read-lock requested, we don't incorrectly downgrade the lock.\n  */\n  assert( WRITE_LOCK>READ_LOCK );\n  if( eLock>pLock->eLock ){\n    pLock->eLock = eLock;\n  }\n\n  return SQLITE_OK;\n}\n#endif /* !SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Release all the table locks (locks obtained via calls to\n** the setSharedCacheTableLock() procedure) held by Btree object p.\n**\n** This function assumes that Btree p has an open read or write \n** transaction. If it does not, then the BTS_PENDING flag\n** may be incorrectly cleared.\n*/\nstatic void clearAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtLock **ppIter = &pBt->pLock;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->sharable || 0==*ppIter );\n  assert( p->inTrans>0 );\n\n  while( *ppIter ){\n    BtLock *pLock = *ppIter;\n    assert( (pBt->btsFlags & BTS_EXCLUSIVE)==0 || pBt->pWriter==pLock->pBtree );\n    assert( pLock->pBtree->inTrans>=pLock->eLock );\n    if( pLock->pBtree==p ){\n      *ppIter = pLock->pNext;\n      assert( pLock->iTable!=1 || pLock==&p->lock );\n      if( pLock->iTable!=1 ){\n        sqlite3_free(pLock);\n      }\n    }else{\n      ppIter = &pLock->pNext;\n    }\n  }\n\n  assert( (pBt->btsFlags & BTS_PENDING)==0 || pBt->pWriter );\n  if( pBt->pWriter==p ){\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n  }else if( pBt->nTransaction==2 ){\n    /* This function is called when Btree p is concluding its \n    ** transaction. If there currently exists a writer, and p is not\n    ** that writer, then the number of locks held by connections other\n    ** than the writer must be about to drop to zero. In this case\n    ** set the BTS_PENDING flag to 0.\n    **\n    ** If there is not currently a writer, then BTS_PENDING must\n    ** be zero already. So this next line is harmless in that case.\n    */\n    pBt->btsFlags &= ~BTS_PENDING;\n  }\n}\n\n/*\n** This function changes all write-locks held by Btree p into read-locks.\n*/\nstatic void downgradeAllSharedCacheTableLocks(Btree *p){\n  BtShared *pBt = p->pBt;\n  if( pBt->pWriter==p ){\n    BtLock *pLock;\n    pBt->pWriter = 0;\n    pBt->btsFlags &= ~(BTS_EXCLUSIVE|BTS_PENDING);\n    for(pLock=pBt->pLock; pLock; pLock=pLock->pNext){\n      assert( pLock->eLock==READ_LOCK || pLock->pBtree==p );\n      pLock->eLock = READ_LOCK;\n    }\n  }\n}\n\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\nstatic void releasePage(MemPage *pPage);         /* Forward reference */\nstatic void releasePageOne(MemPage *pPage);      /* Forward reference */\nstatic void releasePageNotNull(MemPage *pPage);  /* Forward reference */\n\n/*\n***** This routine is used inside of assert() only ****\n**\n** Verify that the cursor holds the mutex on its BtShared\n*/\n#ifdef SQLITE_DEBUG\nstatic int cursorHoldsMutex(BtCursor *p){\n  return sqlite3_mutex_held(p->pBt->mutex);\n}\n\n/* Verify that the cursor and the BtShared agree about what is the current\n** database connetion. This is important in shared-cache mode. If the database \n** connection pointers get out-of-sync, it is possible for routines like\n** btreeInitPage() to reference an stale connection pointer that references a\n** a connection that has already closed.  This routine is used inside assert()\n** statements only and for the purpose of double-checking that the btree code\n** does keep the database connection pointers up-to-date.\n*/\nstatic int cursorOwnsBtShared(BtCursor *p){\n  assert( cursorHoldsMutex(p) );\n  return (p->pBtree->db==p->pBt->db);\n}\n#endif\n\n/*\n** Invalidate the overflow cache of the cursor passed as the first argument.\n** on the shared btree structure pBt.\n*/\n#define invalidateOverflowCache(pCur) (pCur->curFlags &= ~BTCF_ValidOvfl)\n\n/*\n** Invalidate the overflow page-list cache for all cursors opened\n** on the shared btree structure pBt.\n*/\nstatic void invalidateAllOverflowCache(BtShared *pBt){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    invalidateOverflowCache(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** This function is called before modifying the contents of a table\n** to invalidate any incrblob cursors that are open on the\n** row or one of the rows being modified.\n**\n** If argument isClearTable is true, then the entire contents of the\n** table is about to be deleted. In this case invalidate all incrblob\n** cursors open on any row within the table with root-page pgnoRoot.\n**\n** Otherwise, if argument isClearTable is false, then the row with\n** rowid iRow is being replaced or deleted. In this case invalidate\n** only those incrblob cursors open on that specific row.\n*/\nstatic void invalidateIncrblobCursors(\n  Btree *pBtree,          /* The database file to check */\n  Pgno pgnoRoot,          /* The table that might be changing */\n  i64 iRow,               /* The rowid that might be changing */\n  int isClearTable        /* True if all rows are being deleted */\n){\n  BtCursor *p;\n  if( pBtree->hasIncrblobCur==0 ) return;\n  assert( sqlite3BtreeHoldsMutex(pBtree) );\n  pBtree->hasIncrblobCur = 0;\n  for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n    if( (p->curFlags & BTCF_Incrblob)!=0 ){\n      pBtree->hasIncrblobCur = 1;\n      if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){\n        p->eState = CURSOR_INVALID;\n      }\n    }\n  }\n}\n\n#else\n  /* Stub function when INCRBLOB is omitted */\n  #define invalidateIncrblobCursors(w,x,y,z)\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Set bit pgno of the BtShared.pHasContent bitvec. This is called \n** when a page that previously contained data becomes a free-list leaf \n** page.\n**\n** The BtShared.pHasContent bitvec exists to work around an obscure\n** bug caused by the interaction of two useful IO optimizations surrounding\n** free-list leaf pages:\n**\n**   1) When all data is deleted from a page and the page becomes\n**      a free-list leaf page, the page is not written to the database\n**      (as free-list leaf pages contain no meaningful data). Sometimes\n**      such a page is not even journalled (as it will not be modified,\n**      why bother journalling it?).\n**\n**   2) When a free-list leaf page is reused, its content is not read\n**      from the database or written to the journal file (why should it\n**      be, if it is not at all meaningful?).\n**\n** By themselves, these optimizations work fine and provide a handy\n** performance boost to bulk delete or insert operations. However, if\n** a page is moved to the free-list and then reused within the same\n** transaction, a problem comes up. If the page is not journalled when\n** it is moved to the free-list and it is also not journalled when it\n** is extracted from the free-list and reused, then the original data\n** may be lost. In the event of a rollback, it may not be possible\n** to restore the database to its original configuration.\n**\n** The solution is the BtShared.pHasContent bitvec. Whenever a page is \n** moved to become a free-list leaf page, the corresponding bit is\n** set in the bitvec. Whenever a leaf page is extracted from the free-list,\n** optimization 2 above is omitted if the corresponding bit is already\n** set in BtShared.pHasContent. The contents of the bitvec are cleared\n** at the end of every transaction.\n*/\nstatic int btreeSetHasContent(BtShared *pBt, Pgno pgno){\n  int rc = SQLITE_OK;\n  if( !pBt->pHasContent ){\n    assert( pgno<=pBt->nPage );\n    pBt->pHasContent = sqlite3BitvecCreate(pBt->nPage);\n    if( !pBt->pHasContent ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){\n    rc = sqlite3BitvecSet(pBt->pHasContent, pgno);\n  }\n  return rc;\n}\n\n/*\n** Query the BtShared.pHasContent vector.\n**\n** This function is called when a free-list leaf page is removed from the\n** free-list for reuse. It returns false if it is safe to retrieve the\n** page from the pager layer with the 'no-content' flag set. True otherwise.\n*/\nstatic int btreeGetHasContent(BtShared *pBt, Pgno pgno){\n  Bitvec *p = pBt->pHasContent;\n  return (p && (pgno>sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno)));\n}\n\n/*\n** Clear (destroy) the BtShared.pHasContent bitvec. This should be\n** invoked at the conclusion of each write-transaction.\n*/\nstatic void btreeClearHasContent(BtShared *pBt){\n  sqlite3BitvecDestroy(pBt->pHasContent);\n  pBt->pHasContent = 0;\n}\n\n/*\n** Release all of the apPage[] pages for a cursor.\n*/\nstatic void btreeReleaseAllCursorPages(BtCursor *pCur){\n  int i;\n  if( pCur->iPage>=0 ){\n    for(i=0; i<pCur->iPage; i++){\n      releasePageNotNull(pCur->apPage[i]);\n    }\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage = -1;\n  }\n}\n\n/*\n** The cursor passed as the only argument must point to a valid entry\n** when this function is called (i.e. have eState==CURSOR_VALID). This\n** function saves the current cursor key in variables pCur->nKey and\n** pCur->pKey. SQLITE_OK is returned if successful or an SQLite error \n** code otherwise.\n**\n** If the cursor is open on an intkey table, then the integer key\n** (the rowid) is stored in pCur->nKey and pCur->pKey is left set to\n** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is \n** set to point to a malloced buffer pCur->nKey bytes in size containing \n** the key.\n*/\nstatic int saveCursorKey(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  assert( CURSOR_VALID==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->curIntKey ){\n    /* Only the rowid is required for a table btree */\n    pCur->nKey = sqlite3BtreeIntegerKey(pCur);\n  }else{\n    /* For an index btree, save the complete key content */\n    void *pKey;\n    pCur->nKey = sqlite3BtreePayloadSize(pCur);\n    pKey = sqlite3Malloc( pCur->nKey );\n    if( pKey ){\n      rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);\n      if( rc==SQLITE_OK ){\n        pCur->pKey = pKey;\n      }else{\n        sqlite3_free(pKey);\n      }\n    }else{\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  assert( !pCur->curIntKey || !pCur->pKey );\n  return rc;\n}\n\n/*\n** Save the current cursor position in the variables BtCursor.nKey \n** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.\n**\n** The caller must ensure that the cursor is valid (has eState==CURSOR_VALID)\n** prior to calling this routine.  \n*/\nstatic int saveCursorPosition(BtCursor *pCur){\n  int rc;\n\n  assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );\n  assert( 0==pCur->pKey );\n  assert( cursorHoldsMutex(pCur) );\n\n  if( pCur->eState==CURSOR_SKIPNEXT ){\n    pCur->eState = CURSOR_VALID;\n  }else{\n    pCur->skipNext = 0;\n  }\n\n  rc = saveCursorKey(pCur);\n  if( rc==SQLITE_OK ){\n    btreeReleaseAllCursorPages(pCur);\n    pCur->eState = CURSOR_REQUIRESEEK;\n  }\n\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl|BTCF_AtLast);\n  return rc;\n}\n\n/* Forward reference */\nstatic int SQLITE_NOINLINE saveCursorsOnList(BtCursor*,Pgno,BtCursor*);\n\n/*\n** Save the positions of all cursors (except pExcept) that are open on\n** the table with root-page iRoot.  \"Saving the cursor position\" means that\n** the location in the btree is remembered in such a way that it can be\n** moved back to the same spot after the btree has been modified.  This\n** routine is called just before cursor pExcept is used to modify the\n** table, for example in BtreeDelete() or BtreeInsert().\n**\n** If there are two or more cursors on the same btree, then all such \n** cursors should have their BTCF_Multiple flag set.  The btreeCursor()\n** routine enforces that rule.  This routine only needs to be called in\n** the uncommon case when pExpect has the BTCF_Multiple flag set.\n**\n** If pExpect!=NULL and if no other cursors are found on the same root-page,\n** then the BTCF_Multiple flag on pExpect is cleared, to avoid another\n** pointless call to this routine.\n**\n** Implementation note:  This routine merely checks to see if any cursors\n** need to be saved.  It calls out to saveCursorsOnList() in the (unusual)\n** event that cursors are in need to being saved.\n*/\nstatic int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){\n  BtCursor *p;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pExcept==0 || pExcept->pBt==pBt );\n  for(p=pBt->pCursor; p; p=p->pNext){\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ) break;\n  }\n  if( p ) return saveCursorsOnList(p, iRoot, pExcept);\n  if( pExcept ) pExcept->curFlags &= ~BTCF_Multiple;\n  return SQLITE_OK;\n}\n\n/* This helper routine to saveAllCursors does the actual work of saving\n** the cursors if and when a cursor is found that actually requires saving.\n** The common case is that no cursors need to be saved, so this routine is\n** broken out from its caller to avoid unnecessary stack pointer movement.\n*/\nstatic int SQLITE_NOINLINE saveCursorsOnList(\n  BtCursor *p,         /* The first cursor that needs saving */\n  Pgno iRoot,          /* Only save cursor with this iRoot. Save all if zero */\n  BtCursor *pExcept    /* Do not save this cursor */\n){\n  do{\n    if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){\n      if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n        int rc = saveCursorPosition(p);\n        if( SQLITE_OK!=rc ){\n          return rc;\n        }\n      }else{\n        testcase( p->iPage>=0 );\n        btreeReleaseAllCursorPages(p);\n      }\n    }\n    p = p->pNext;\n  }while( p );\n  return SQLITE_OK;\n}\n\n/*\n** Clear the current cursor position.\n*/\nvoid sqlite3BtreeClearCursor(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  sqlite3_free(pCur->pKey);\n  pCur->pKey = 0;\n  pCur->eState = CURSOR_INVALID;\n}\n\n/*\n** In this version of BtreeMoveto, pKey is a packed index record\n** such as is generated by the OP_MakeRecord opcode.  Unpack the\n** record and then call BtreeMovetoUnpacked() to do the work.\n*/\nstatic int btreeMoveto(\n  BtCursor *pCur,     /* Cursor open on the btree to be searched */\n  const void *pKey,   /* Packed key if the btree is an index */\n  i64 nKey,           /* Integer key for tables.  Size of pKey for indices */\n  int bias,           /* Bias search to the high end */\n  int *pRes           /* Write search results here */\n){\n  int rc;                    /* Status code */\n  UnpackedRecord *pIdxKey;   /* Unpacked index key */\n\n  if( pKey ){\n    assert( nKey==(i64)(int)nKey );\n    pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);\n    if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);\n    if( pIdxKey->nField==0 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto moveto_done;\n    }\n  }else{\n    pIdxKey = 0;\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);\nmoveto_done:\n  if( pIdxKey ){\n    sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);\n  }\n  return rc;\n}\n\n/*\n** Restore the cursor to the position it was in (or as close to as possible)\n** when saveCursorPosition() was called. Note that this call deletes the \n** saved position info stored by saveCursorPosition(), so there can be\n** at most one effective restoreCursorPosition() call after each \n** saveCursorPosition().\n*/\nstatic int btreeRestoreCursorPosition(BtCursor *pCur){\n  int rc;\n  int skipNext;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState>=CURSOR_REQUIRESEEK );\n  if( pCur->eState==CURSOR_FAULT ){\n    return pCur->skipNext;\n  }\n  pCur->eState = CURSOR_INVALID;\n  rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);\n  if( rc==SQLITE_OK ){\n    sqlite3_free(pCur->pKey);\n    pCur->pKey = 0;\n    assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );\n    pCur->skipNext |= skipNext;\n    if( pCur->skipNext && pCur->eState==CURSOR_VALID ){\n      pCur->eState = CURSOR_SKIPNEXT;\n    }\n  }\n  return rc;\n}\n\n#define restoreCursorPosition(p) \\\n  (p->eState>=CURSOR_REQUIRESEEK ? \\\n         btreeRestoreCursorPosition(p) : \\\n         SQLITE_OK)\n\n/*\n** Determine whether or not a cursor has moved from the position where\n** it was last placed, or has been invalidated for any other reason.\n** Cursors can move when the row they are pointing at is deleted out\n** from under them, for example.  Cursor might also move if a btree\n** is rebalanced.\n**\n** Calling this routine with a NULL cursor pointer returns false.\n**\n** Use the separate sqlite3BtreeCursorRestore() routine to restore a cursor\n** back to where it ought to be if this routine returns true.\n*/\nint sqlite3BtreeCursorHasMoved(BtCursor *pCur){\n  return pCur->eState!=CURSOR_VALID;\n}\n\n/*\n** Return a pointer to a fake BtCursor object that will always answer\n** false to the sqlite3BtreeCursorHasMoved() routine above.  The fake\n** cursor returned must not be used with any other Btree interface.\n*/\nBtCursor *sqlite3BtreeFakeValidCursor(void){\n  static u8 fakeCursor = CURSOR_VALID;\n  assert( offsetof(BtCursor, eState)==0 );\n  return (BtCursor*)&fakeCursor;\n}\n\n/*\n** This routine restores a cursor back to its original position after it\n** has been moved by some outside activity (such as a btree rebalance or\n** a row having been deleted out from under the cursor).  \n**\n** On success, the *pDifferentRow parameter is false if the cursor is left\n** pointing at exactly the same row.  *pDifferntRow is the row the cursor\n** was pointing to has been deleted, forcing the cursor to point to some\n** nearby row.\n**\n** This routine should only be called for a cursor that just returned\n** TRUE from sqlite3BtreeCursorHasMoved().\n*/\nint sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){\n  int rc;\n\n  assert( pCur!=0 );\n  assert( pCur->eState!=CURSOR_VALID );\n  rc = restoreCursorPosition(pCur);\n  if( rc ){\n    *pDifferentRow = 1;\n    return rc;\n  }\n  if( pCur->eState!=CURSOR_VALID ){\n    *pDifferentRow = 1;\n  }else{\n    assert( pCur->skipNext==0 );\n    *pDifferentRow = 0;\n  }\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Provide hints to the cursor.  The particular hint given (and the type\n** and number of the varargs parameters) is determined by the eHintType\n** parameter.  See the definitions of the BTREE_HINT_* macros for details.\n*/\nvoid sqlite3BtreeCursorHint(BtCursor *pCur, int eHintType, ...){\n  /* Used only by system that substitute their own storage engine */\n}\n#endif\n\n/*\n** Provide flag hints to the cursor.\n*/\nvoid sqlite3BtreeCursorHintFlags(BtCursor *pCur, unsigned x){\n  assert( x==BTREE_SEEK_EQ || x==BTREE_BULKLOAD || x==0 );\n  pCur->hints = x;\n}\n\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Given a page number of a regular database page, return the page\n** number for the pointer-map page that contains the entry for the\n** input page number.\n**\n** Return 0 (not a valid page) for pgno==1 since there is\n** no pointer map associated with page 1.  The integrity_check logic\n** requires that ptrmapPageno(*,1)!=1.\n*/\nstatic Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){\n  int nPagesPerMapPage;\n  Pgno iPtrMap, ret;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno<2 ) return 0;\n  nPagesPerMapPage = (pBt->usableSize/5)+1;\n  iPtrMap = (pgno-2)/nPagesPerMapPage;\n  ret = (iPtrMap*nPagesPerMapPage) + 2; \n  if( ret==PENDING_BYTE_PAGE(pBt) ){\n    ret++;\n  }\n  return ret;\n}\n\n/*\n** Write an entry into the pointer map.\n**\n** This routine updates the pointer map entry for page number 'key'\n** so that it maps to type 'eType' and parent page number 'pgno'.\n**\n** If *pRC is initially non-zero (non-SQLITE_OK) then this routine is\n** a no-op.  If an error occurs, the appropriate error code is written\n** into *pRC.\n*/\nstatic void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){\n  DbPage *pDbPage;  /* The pointer map page */\n  u8 *pPtrmap;      /* The pointer map data */\n  Pgno iPtrmap;     /* The pointer map page number */\n  int offset;       /* Offset in pointer map page */\n  int rc;           /* Return code from subfunctions */\n\n  if( *pRC ) return;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  /* The master-journal page number must never be used as a pointer map page */\n  assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );\n\n  assert( pBt->autoVacuum );\n  if( key==0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=SQLITE_OK ){\n    *pRC = rc;\n    return;\n  }\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    goto ptrmap_exit;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=parent ){\n    TRACE((\"PTRMAP_UPDATE: %d->(%d,%d)\\n\", key, eType, parent));\n    *pRC= rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      pPtrmap[offset] = eType;\n      put4byte(&pPtrmap[offset+1], parent);\n    }\n  }\n\nptrmap_exit:\n  sqlite3PagerUnref(pDbPage);\n}\n\n/*\n** Read an entry from the pointer map.\n**\n** This routine retrieves the pointer map entry for page 'key', writing\n** the type and parent page number to *pEType and *pPgno respectively.\n** An error code is returned if something goes wrong, otherwise SQLITE_OK.\n*/\nstatic int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){\n  DbPage *pDbPage;   /* The pointer map page */\n  int iPtrmap;       /* Pointer map page index */\n  u8 *pPtrmap;       /* Pointer map page data */\n  int offset;        /* Offset of entry in pointer map */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  iPtrmap = PTRMAP_PAGENO(pBt, key);\n  rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0);\n  if( rc!=0 ){\n    return rc;\n  }\n  pPtrmap = (u8 *)sqlite3PagerGetData(pDbPage);\n\n  offset = PTRMAP_PTROFFSET(iPtrmap, key);\n  if( offset<0 ){\n    sqlite3PagerUnref(pDbPage);\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( offset <= (int)pBt->usableSize-5 );\n  assert( pEType!=0 );\n  *pEType = pPtrmap[offset];\n  if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);\n\n  sqlite3PagerUnref(pDbPage);\n  if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap);\n  return SQLITE_OK;\n}\n\n#else /* if defined SQLITE_OMIT_AUTOVACUUM */\n  #define ptrmapPut(w,x,y,z,rc)\n  #define ptrmapGet(w,x,y,z) SQLITE_OK\n  #define ptrmapPutOvflPtr(x, y, rc)\n#endif\n\n/*\n** Given a btree page and a cell index (0 means the first cell on\n** the page, 1 means the second cell, and so forth) return a pointer\n** to the cell content.\n**\n** findCellPastPtr() does the same except it skips past the initial\n** 4-byte child pointer found on interior pages, if there is one.\n**\n** This routine works only for pages that do not contain overflow cells.\n*/\n#define findCell(P,I) \\\n  ((P)->aData + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n#define findCellPastPtr(P,I) \\\n  ((P)->aDataOfst + ((P)->maskPage & get2byteAligned(&(P)->aCellIdx[2*(I)])))\n\n\n/*\n** This is common tail processing for btreeParseCellPtr() and\n** btreeParseCellPtrIndex() for the case when the cell does not fit entirely\n** on a single B-tree page.  Make necessary adjustments to the CellInfo\n** structure.\n*/\nstatic SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  /* If the payload will not fit completely on the local page, we have\n  ** to decide how much to store locally and how much to spill onto\n  ** overflow pages.  The strategy is to minimize the amount of unused\n  ** space on overflow pages while keeping the amount of local storage\n  ** in between minLocal and maxLocal.\n  **\n  ** Warning:  changing the way overflow payload is distributed in any\n  ** way will result in an incompatible file format.\n  */\n  int minLocal;  /* Minimum amount of payload held locally */\n  int maxLocal;  /* Maximum amount of payload held locally */\n  int surplus;   /* Overflow payload available for local storage */\n\n  minLocal = pPage->minLocal;\n  maxLocal = pPage->maxLocal;\n  surplus = minLocal + (pInfo->nPayload - minLocal)%(pPage->pBt->usableSize-4);\n  testcase( surplus==maxLocal );\n  testcase( surplus==maxLocal+1 );\n  if( surplus <= maxLocal ){\n    pInfo->nLocal = (u16)surplus;\n  }else{\n    pInfo->nLocal = (u16)minLocal;\n  }\n  pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4;\n}\n\n/*\n** The following routines are implementations of the MemPage.xParseCell()\n** method.\n**\n** Parse a cell content block and fill in the CellInfo structure.\n**\n** btreeParseCellPtr()        =>   table btree leaf nodes\n** btreeParseCellNoPayload()  =>   table btree internal nodes\n** btreeParseCellPtrIndex()   =>   index btree nodes\n**\n** There is also a wrapper function btreeParseCell() that works for\n** all MemPage types and that references the cell by index rather than\n** by pointer.\n*/\nstatic void btreeParseCellPtrNoPayload(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 );\n  assert( pPage->childPtrSize==4 );\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER(pPage);\n#endif\n  pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);\n  pInfo->nPayload = 0;\n  pInfo->nLocal = 0;\n  pInfo->pPayload = 0;\n  return;\n}\nstatic void btreeParseCellPtr(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n  u64 iKey;               /* Extracted Key value */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf );\n  assert( pPage->childPtrSize==0 );\n  pIter = pCell;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint32(pIter, nPayload);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( (*pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n\n  /* The next block of code is equivalent to:\n  **\n  **     pIter += getVarint(pIter, (u64*)&pInfo->nKey);\n  **\n  ** The code is inlined to avoid a function call.\n  */\n  iKey = *pIter;\n  if( iKey>=0x80 ){\n    u8 *pEnd = &pIter[7];\n    iKey &= 0x7f;\n    while(1){\n      iKey = (iKey<<7) | (*++pIter & 0x7f);\n      if( (*pIter)<0x80 ) break;\n      if( pIter>=pEnd ){\n        iKey = (iKey<<8) | *++pIter;\n        break;\n      }\n    }\n  }\n  pIter++;\n\n  pInfo->nKey = *(i64*)&iKey;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCellPtrIndex(\n  MemPage *pPage,         /* Page containing the cell */\n  u8 *pCell,              /* Pointer to the cell text. */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  u8 *pIter;              /* For scanning through pCell */\n  u32 nPayload;           /* Number of bytes of cell payload */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->leaf==0 || pPage->leaf==1 );\n  assert( pPage->intKeyLeaf==0 );\n  pIter = pCell + pPage->childPtrSize;\n  nPayload = *pIter;\n  if( nPayload>=0x80 ){\n    u8 *pEnd = &pIter[8];\n    nPayload &= 0x7f;\n    do{\n      nPayload = (nPayload<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  pInfo->nKey = nPayload;\n  pInfo->nPayload = nPayload;\n  pInfo->pPayload = pIter;\n  testcase( nPayload==pPage->maxLocal );\n  testcase( nPayload==pPage->maxLocal+1 );\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the (easy) common case where the entire payload fits\n    ** on the local page.  No overflow is required.\n    */\n    pInfo->nSize = nPayload + (u16)(pIter - pCell);\n    if( pInfo->nSize<4 ) pInfo->nSize = 4;\n    pInfo->nLocal = (u16)nPayload;\n  }else{\n    btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);\n  }\n}\nstatic void btreeParseCell(\n  MemPage *pPage,         /* Page containing the cell */\n  int iCell,              /* The cell index.  First cell is 0 */\n  CellInfo *pInfo         /* Fill in this structure */\n){\n  pPage->xParseCell(pPage, findCell(pPage, iCell), pInfo);\n}\n\n/*\n** The following routines are implementations of the MemPage.xCellSize\n** method.\n**\n** Compute the total number of bytes that a Cell needs in the cell\n** data area of the btree-page.  The return number includes the cell\n** data header and the local payload, but not any overflow page or\n** the space used by the cell pointer.\n**\n** cellSizePtrNoPayload()    =>   table internal nodes\n** cellSizePtr()             =>   all index nodes & table leaf nodes\n*/\nstatic u16 cellSizePtr(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + pPage->childPtrSize; /* For looping over bytes of pCell */\n  u8 *pEnd;                                /* End mark for a varint */\n  u32 nSize;                               /* Size value to return */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#endif\n\n  nSize = *pIter;\n  if( nSize>=0x80 ){\n    pEnd = &pIter[8];\n    nSize &= 0x7f;\n    do{\n      nSize = (nSize<<7) | (*++pIter & 0x7f);\n    }while( *(pIter)>=0x80 && pIter<pEnd );\n  }\n  pIter++;\n  if( pPage->intKey ){\n    /* pIter now points at the 64-bit integer key value, a variable length \n    ** integer. The following block moves pIter to point at the first byte\n    ** past the end of the key value. */\n    pEnd = &pIter[9];\n    while( (*pIter++)&0x80 && pIter<pEnd );\n  }\n  testcase( nSize==pPage->maxLocal );\n  testcase( nSize==pPage->maxLocal+1 );\n  if( nSize<=pPage->maxLocal ){\n    nSize += (u32)(pIter - pCell);\n    if( nSize<4 ) nSize = 4;\n  }else{\n    int minLocal = pPage->minLocal;\n    nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);\n    testcase( nSize==pPage->maxLocal );\n    testcase( nSize==pPage->maxLocal+1 );\n    if( nSize>pPage->maxLocal ){\n      nSize = minLocal;\n    }\n    nSize += 4 + (u16)(pIter - pCell);\n  }\n  assert( nSize==debuginfo.nSize || CORRUPT_DB );\n  return (u16)nSize;\n}\nstatic u16 cellSizePtrNoPayload(MemPage *pPage, u8 *pCell){\n  u8 *pIter = pCell + 4; /* For looping over bytes of pCell */\n  u8 *pEnd;              /* End mark for a varint */\n\n#ifdef SQLITE_DEBUG\n  /* The value returned by this function should always be the same as\n  ** the (CellInfo.nSize) value found by doing a full parse of the\n  ** cell. If SQLITE_DEBUG is defined, an assert() at the bottom of\n  ** this function verifies that this invariant is not violated. */\n  CellInfo debuginfo;\n  pPage->xParseCell(pPage, pCell, &debuginfo);\n#else\n  UNUSED_PARAMETER(pPage);\n#endif\n\n  assert( pPage->childPtrSize==4 );\n  pEnd = pIter + 9;\n  while( (*pIter++)&0x80 && pIter<pEnd );\n  assert( debuginfo.nSize==(u16)(pIter - pCell) || CORRUPT_DB );\n  return (u16)(pIter - pCell);\n}\n\n\n#ifdef SQLITE_DEBUG\n/* This variation on cellSizePtr() is used inside of assert() statements\n** only. */\nstatic u16 cellSize(MemPage *pPage, int iCell){\n  return pPage->xCellSize(pPage, findCell(pPage, iCell));\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** If the cell pCell, part of page pPage contains a pointer\n** to an overflow page, insert an entry into the pointer-map\n** for the overflow page.\n*/\nstatic void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){\n  CellInfo info;\n  if( *pRC ) return;\n  assert( pCell!=0 );\n  pPage->xParseCell(pPage, pCell, &info);\n  if( info.nLocal<info.nPayload ){\n    Pgno ovfl = get4byte(&pCell[info.nSize-4]);\n    ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);\n  }\n}\n#endif\n\n\n/*\n** Defragment the page given. This routine reorganizes cells within the\n** page so that there are no free-blocks on the free-block list.\n**\n** Parameter nMaxFrag is the maximum amount of fragmented space that may be\n** present in the page after this routine returns.\n**\n** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a\n** b-tree page so that there are no freeblocks or fragment bytes, all\n** unused bytes are contained in the unallocated space region, and all\n** cells are packed tightly at the end of the page.\n*/\nstatic int defragmentPage(MemPage *pPage, int nMaxFrag){\n  int i;                     /* Loop counter */\n  int pc;                    /* Address of the i-th cell */\n  int hdr;                   /* Offset to the page header */\n  int size;                  /* Size of a cell */\n  int usableSize;            /* Number of usable bytes on a page */\n  int cellOffset;            /* Offset to the cell pointer array */\n  int cbrk;                  /* Offset to the cell content area */\n  int nCell;                 /* Number of cells on the page */\n  unsigned char *data;       /* The page data */\n  unsigned char *temp;       /* Temp area for cell content */\n  unsigned char *src;        /* Source of content */\n  int iCellFirst;            /* First allowable cell index */\n  int iCellLast;             /* Last possible cell index */\n\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );\n  assert( pPage->nOverflow==0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  temp = 0;\n  src = data = pPage->aData;\n  hdr = pPage->hdrOffset;\n  cellOffset = pPage->cellOffset;\n  nCell = pPage->nCell;\n  assert( nCell==get2byte(&data[hdr+3]) );\n  iCellFirst = cellOffset + 2*nCell;\n  usableSize = pPage->pBt->usableSize;\n\n  /* This block handles pages with two or fewer free blocks and nMaxFrag\n  ** or fewer fragmented bytes. In this case it is faster to move the\n  ** two (or one) blocks of cells using memmove() and add the required\n  ** offsets to each pointer in the cell-pointer array than it is to \n  ** reconstruct the entire page.  */\n  if( (int)data[hdr+7]<=nMaxFrag ){\n    int iFree = get2byte(&data[hdr+1]);\n    if( iFree ){\n      int iFree2 = get2byte(&data[iFree]);\n\n      /* pageFindSlot() has already verified that free blocks are sorted\n      ** in order of offset within the page, and that no block extends\n      ** past the end of the page. Provided the two free slots do not \n      ** overlap, this guarantees that the memmove() calls below will not\n      ** overwrite the usableSize byte buffer, even if the database page\n      ** is corrupt.  */\n      assert( iFree2==0 || iFree2>iFree );\n      assert( iFree+get2byte(&data[iFree+2]) <= usableSize );\n      assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );\n\n      if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){\n        u8 *pEnd = &data[cellOffset + nCell*2];\n        u8 *pAddr;\n        int sz2 = 0;\n        int sz = get2byte(&data[iFree+2]);\n        int top = get2byte(&data[hdr+5]);\n        if( top>=iFree ){\n          return SQLITE_CORRUPT_PGNO(pPage->pgno);\n        }\n        if( iFree2 ){\n          assert( iFree+sz<=iFree2 ); /* Verified by pageFindSlot() */\n          sz2 = get2byte(&data[iFree2+2]);\n          assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );\n          memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));\n          sz += sz2;\n        }\n        cbrk = top+sz;\n        assert( cbrk+(iFree-top) <= usableSize );\n        memmove(&data[cbrk], &data[top], iFree-top);\n        for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){\n          pc = get2byte(pAddr);\n          if( pc<iFree ){ put2byte(pAddr, pc+sz); }\n          else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); }\n        }\n        goto defragment_out;\n      }\n    }\n  }\n\n  cbrk = usableSize;\n  iCellLast = usableSize - 4;\n  for(i=0; i<nCell; i++){\n    u8 *pAddr;     /* The i-th cell pointer */\n    pAddr = &data[cellOffset + i*2];\n    pc = get2byte(pAddr);\n    testcase( pc==iCellFirst );\n    testcase( pc==iCellLast );\n    /* These conditions have already been verified in btreeInitPage()\n    ** if PRAGMA cell_size_check=ON.\n    */\n    if( pc<iCellFirst || pc>iCellLast ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( pc>=iCellFirst && pc<=iCellLast );\n    size = pPage->xCellSize(pPage, &src[pc]);\n    cbrk -= size;\n    if( cbrk<iCellFirst || pc+size>usableSize ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( cbrk+size<=usableSize && cbrk>=iCellFirst );\n    testcase( cbrk+size==usableSize );\n    testcase( pc+size==usableSize );\n    put2byte(pAddr, cbrk);\n    if( temp==0 ){\n      int x;\n      if( cbrk==pc ) continue;\n      temp = sqlite3PagerTempSpace(pPage->pBt->pPager);\n      x = get2byte(&data[hdr+5]);\n      memcpy(&temp[x], &data[x], (cbrk+size) - x);\n      src = temp;\n    }\n    memcpy(&data[cbrk], &src[pc], size);\n  }\n  data[hdr+7] = 0;\n\n defragment_out:\n  if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  assert( cbrk>=iCellFirst );\n  put2byte(&data[hdr+5], cbrk);\n  data[hdr+1] = 0;\n  data[hdr+2] = 0;\n  memset(&data[iCellFirst], 0, cbrk-iCellFirst);\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  return SQLITE_OK;\n}\n\n/*\n** Search the free-list on page pPg for space to store a cell nByte bytes in\n** size. If one can be found, return a pointer to the space and remove it\n** from the free-list.\n**\n** If no suitable space can be found on the free-list, return NULL.\n**\n** This function may detect corruption within pPg.  If corruption is\n** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned.\n**\n** Slots on the free list that are between 1 and 3 bytes larger than nByte\n** will be ignored if adding the extra space to the fragmentation count\n** causes the fragmentation count to exceed 60.\n*/\nstatic u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc){\n  const int hdr = pPg->hdrOffset;\n  u8 * const aData = pPg->aData;\n  int iAddr = hdr + 1;\n  int pc = get2byte(&aData[iAddr]);\n  int x;\n  int usableSize = pPg->pBt->usableSize;\n  int size;            /* Size of the free slot */\n\n  assert( pc>0 );\n  while( pc<=usableSize-4 ){\n    /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each\n    ** freeblock form a big-endian integer which is the size of the freeblock\n    ** in bytes, including the 4-byte header. */\n    size = get2byte(&aData[pc+2]);\n    if( (x = size - nByte)>=0 ){\n      testcase( x==4 );\n      testcase( x==3 );\n      if( size+pc > usableSize ){\n        *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);\n        return 0;\n      }else if( x<4 ){\n        /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total\n        ** number of bytes in fragments may not exceed 60. */\n        if( aData[hdr+7]>57 ) return 0;\n\n        /* Remove the slot from the free-list. Update the number of\n        ** fragmented bytes within the page. */\n        memcpy(&aData[iAddr], &aData[pc], 2);\n        aData[hdr+7] += (u8)x;\n      }else{\n        /* The slot remains on the free-list. Reduce its size to account\n         ** for the portion used by the new allocation. */\n        put2byte(&aData[pc+2], x);\n      }\n      return &aData[pc + x];\n    }\n    iAddr = pc;\n    pc = get2byte(&aData[pc]);\n    if( pc<iAddr+size ) break;\n  }\n  if( pc ){\n    *pRc = SQLITE_CORRUPT_PGNO(pPg->pgno);\n  }\n\n  return 0;\n}\n\n/*\n** Allocate nByte bytes of space from within the B-Tree page passed\n** as the first argument. Write into *pIdx the index into pPage->aData[]\n** of the first byte of allocated space. Return either SQLITE_OK or\n** an error code (usually SQLITE_CORRUPT).\n**\n** The caller guarantees that there is sufficient space to make the\n** allocation.  This routine might need to defragment in order to bring\n** all the space together, however.  This routine will avoid using\n** the first two bytes past the cell pointer area since presumably this\n** allocation is being made in order to insert a new cell, so we will\n** also end up needing a new cell pointer.\n*/\nstatic int allocateSpace(MemPage *pPage, int nByte, int *pIdx){\n  const int hdr = pPage->hdrOffset;    /* Local cache of pPage->hdrOffset */\n  u8 * const data = pPage->aData;      /* Local cache of pPage->aData */\n  int top;                             /* First byte of cell content area */\n  int rc = SQLITE_OK;                  /* Integer return code */\n  int gap;        /* First byte of gap between cell pointers and cell content */\n  \n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( pPage->pBt );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( nByte>=0 );  /* Minimum cell size is 4 */\n  assert( pPage->nFree>=nByte );\n  assert( pPage->nOverflow==0 );\n  assert( nByte < (int)(pPage->pBt->usableSize-8) );\n\n  assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );\n  gap = pPage->cellOffset + 2*pPage->nCell;\n  assert( gap<=65536 );\n  /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size\n  ** and the reserved space is zero (the usual value for reserved space)\n  ** then the cell content offset of an empty page wants to be 65536.\n  ** However, that integer is too large to be stored in a 2-byte unsigned\n  ** integer, so a value of 0 is used in its place. */\n  top = get2byte(&data[hdr+5]);\n  assert( top<=(int)pPage->pBt->usableSize ); /* Prevent by getAndInitPage() */\n  if( gap>top ){\n    if( top==0 && pPage->pBt->usableSize==65536 ){\n      top = 65536;\n    }else{\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n  }\n\n  /* If there is enough space between gap and top for one more cell pointer\n  ** array entry offset, and if the freelist is not empty, then search the\n  ** freelist looking for a free slot big enough to satisfy the request.\n  */\n  testcase( gap+2==top );\n  testcase( gap+1==top );\n  testcase( gap==top );\n  if( (data[hdr+2] || data[hdr+1]) && gap+2<=top ){\n    u8 *pSpace = pageFindSlot(pPage, nByte, &rc);\n    if( pSpace ){\n      assert( pSpace>=data && (pSpace - data)<65536 );\n      *pIdx = (int)(pSpace - data);\n      return SQLITE_OK;\n    }else if( rc ){\n      return rc;\n    }\n  }\n\n  /* The request could not be fulfilled using a freelist slot.  Check\n  ** to see if defragmentation is necessary.\n  */\n  testcase( gap+2+nByte==top );\n  if( gap+2+nByte>top ){\n    assert( pPage->nCell>0 || CORRUPT_DB );\n    rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));\n    if( rc ) return rc;\n    top = get2byteNotZero(&data[hdr+5]);\n    assert( gap+2+nByte<=top );\n  }\n\n\n  /* Allocate memory from the gap in between the cell pointer array\n  ** and the cell content area.  The btreeInitPage() call has already\n  ** validated the freelist.  Given that the freelist is valid, there\n  ** is no way that the allocation can extend off the end of the page.\n  ** The assert() below verifies the previous sentence.\n  */\n  top -= nByte;\n  put2byte(&data[hdr+5], top);\n  assert( top+nByte <= (int)pPage->pBt->usableSize );\n  *pIdx = top;\n  return SQLITE_OK;\n}\n\n/*\n** Return a section of the pPage->aData to the freelist.\n** The first byte of the new free block is pPage->aData[iStart]\n** and the size of the block is iSize bytes.\n**\n** Adjacent freeblocks are coalesced.\n**\n** Note that even though the freeblock list was checked by btreeInitPage(),\n** that routine will not detect overlap between cells or freeblocks.  Nor\n** does it detect cells or freeblocks that encrouch into the reserved bytes\n** at the end of the page.  So do additional corruption checks inside this\n** routine and return SQLITE_CORRUPT if any problems are found.\n*/\nstatic int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){\n  u16 iPtr;                             /* Address of ptr to next freeblock */\n  u16 iFreeBlk;                         /* Address of the next freeblock */\n  u8 hdr;                               /* Page header size.  0 or 100 */\n  u8 nFrag = 0;                         /* Reduction in fragmentation */\n  u16 iOrigSize = iSize;                /* Original value of iSize */\n  u16 x;                                /* Offset to cell content area */\n  u32 iEnd = iStart + iSize;            /* First byte past the iStart buffer */\n  unsigned char *data = pPage->aData;   /* Page content */\n\n  assert( pPage->pBt!=0 );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize );\n  assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( iSize>=4 );   /* Minimum cell size is 4 */\n  assert( iStart<=pPage->pBt->usableSize-4 );\n\n  /* The list of freeblocks must be in ascending order.  Find the \n  ** spot on the list where iStart should be inserted.\n  */\n  hdr = pPage->hdrOffset;\n  iPtr = hdr + 1;\n  if( data[iPtr+1]==0 && data[iPtr]==0 ){\n    iFreeBlk = 0;  /* Shortcut for the case when the freelist is empty */\n  }else{\n    while( (iFreeBlk = get2byte(&data[iPtr]))<iStart ){\n      if( iFreeBlk<iPtr+4 ){\n        if( iFreeBlk==0 ) break;\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      iPtr = iFreeBlk;\n    }\n    if( iFreeBlk>pPage->pBt->usableSize-4 ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    assert( iFreeBlk>iPtr || iFreeBlk==0 );\n  \n    /* At this point:\n    **    iFreeBlk:   First freeblock after iStart, or zero if none\n    **    iPtr:       The address of a pointer to iFreeBlk\n    **\n    ** Check to see if iFreeBlk should be coalesced onto the end of iStart.\n    */\n    if( iFreeBlk && iEnd+3>=iFreeBlk ){\n      nFrag = iFreeBlk - iEnd;\n      if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);\n      if( iEnd > pPage->pBt->usableSize ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      iSize = iEnd - iStart;\n      iFreeBlk = get2byte(&data[iFreeBlk]);\n    }\n  \n    /* If iPtr is another freeblock (that is, if iPtr is not the freelist\n    ** pointer in the page header) then check to see if iStart should be\n    ** coalesced onto the end of iPtr.\n    */\n    if( iPtr>hdr+1 ){\n      int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);\n      if( iPtrEnd+3>=iStart ){\n        if( iPtrEnd>iStart ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n        nFrag += iStart - iPtrEnd;\n        iSize = iEnd - iPtr;\n        iStart = iPtr;\n      }\n    }\n    if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    data[hdr+7] -= nFrag;\n  }\n  x = get2byte(&data[hdr+5]);\n  if( iStart<=x ){\n    /* The new freeblock is at the beginning of the cell content area,\n    ** so just extend the cell content area rather than create another\n    ** freelist entry */\n    if( iStart<x || iPtr!=hdr+1 ) return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    put2byte(&data[hdr+1], iFreeBlk);\n    put2byte(&data[hdr+5], iEnd);\n  }else{\n    /* Insert the new freeblock into the freelist */\n    put2byte(&data[iPtr], iStart);\n  }\n  if( pPage->pBt->btsFlags & BTS_FAST_SECURE ){\n    /* Overwrite deleted information with zeros when the secure_delete\n    ** option is enabled */\n    memset(&data[iStart], 0, iSize);\n  }\n  put2byte(&data[iStart], iFreeBlk);\n  put2byte(&data[iStart+2], iSize);\n  pPage->nFree += iOrigSize;\n  return SQLITE_OK;\n}\n\n/*\n** Decode the flags byte (the first byte of the header) for a page\n** and initialize fields of the MemPage structure accordingly.\n**\n** Only the following combinations are supported.  Anything different\n** indicates a corrupt database files:\n**\n**         PTF_ZERODATA\n**         PTF_ZERODATA | PTF_LEAF\n**         PTF_LEAFDATA | PTF_INTKEY\n**         PTF_LEAFDATA | PTF_INTKEY | PTF_LEAF\n*/\nstatic int decodeFlags(MemPage *pPage, int flagByte){\n  BtShared *pBt;     /* A copy of pPage->pBt */\n\n  assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->leaf = (u8)(flagByte>>3);  assert( PTF_LEAF == 1<<3 );\n  flagByte &= ~PTF_LEAF;\n  pPage->childPtrSize = 4-4*pPage->leaf;\n  pPage->xCellSize = cellSizePtr;\n  pBt = pPage->pBt;\n  if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){\n    /* EVIDENCE-OF: R-07291-35328 A value of 5 (0x05) means the page is an\n    ** interior table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );\n    /* EVIDENCE-OF: R-26900-09176 A value of 13 (0x0d) means the page is a\n    ** leaf table b-tree page. */\n    assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );\n    pPage->intKey = 1;\n    if( pPage->leaf ){\n      pPage->intKeyLeaf = 1;\n      pPage->xParseCell = btreeParseCellPtr;\n    }else{\n      pPage->intKeyLeaf = 0;\n      pPage->xCellSize = cellSizePtrNoPayload;\n      pPage->xParseCell = btreeParseCellPtrNoPayload;\n    }\n    pPage->maxLocal = pBt->maxLeaf;\n    pPage->minLocal = pBt->minLeaf;\n  }else if( flagByte==PTF_ZERODATA ){\n    /* EVIDENCE-OF: R-43316-37308 A value of 2 (0x02) means the page is an\n    ** interior index b-tree page. */\n    assert( (PTF_ZERODATA)==2 );\n    /* EVIDENCE-OF: R-59615-42828 A value of 10 (0x0a) means the page is a\n    ** leaf index b-tree page. */\n    assert( (PTF_ZERODATA|PTF_LEAF)==10 );\n    pPage->intKey = 0;\n    pPage->intKeyLeaf = 0;\n    pPage->xParseCell = btreeParseCellPtrIndex;\n    pPage->maxLocal = pBt->maxLocal;\n    pPage->minLocal = pBt->minLocal;\n  }else{\n    /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is\n    ** an error. */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  pPage->max1bytePayload = pBt->max1bytePayload;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the auxiliary information for a disk block.\n**\n** Return SQLITE_OK on success.  If we see that the page does\n** not contain a well-formed database page, then return \n** SQLITE_CORRUPT.  Note that a return of SQLITE_OK does not\n** guarantee that the page is well-formed.  It only shows that\n** we failed to detect any corruption.\n*/\nstatic int btreeInitPage(MemPage *pPage){\n  int pc;            /* Address of a freeblock within pPage->aData[] */\n  u8 hdr;            /* Offset to beginning of page header */\n  u8 *data;          /* Equal to pPage->aData */\n  BtShared *pBt;        /* The main btree structure */\n  int usableSize;    /* Amount of usable space on each page */\n  u16 cellOffset;    /* Offset from start of page to first cell pointer */\n  int nFree;         /* Number of unused bytes on the page */\n  int top;           /* First byte of the cell content area */\n  int iCellFirst;    /* First allowable cell or freeblock offset */\n  int iCellLast;     /* Last possible cell or freeblock offset */\n\n  assert( pPage->pBt!=0 );\n  assert( pPage->pBt->db!=0 );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );\n  assert( pPage == sqlite3PagerGetExtra(pPage->pDbPage) );\n  assert( pPage->aData == sqlite3PagerGetData(pPage->pDbPage) );\n  assert( pPage->isInit==0 );\n\n  pBt = pPage->pBt;\n  hdr = pPage->hdrOffset;\n  data = pPage->aData;\n  /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating\n  ** the b-tree page type. */\n  if( decodeFlags(pPage, data[hdr]) ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nOverflow = 0;\n  usableSize = pBt->usableSize;\n  pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;\n  pPage->aDataEnd = &data[usableSize];\n  pPage->aCellIdx = &data[cellOffset];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates\n  ** the start of the cell content area. A zero value for this integer is\n  ** interpreted as 65536. */\n  top = get2byteNotZero(&data[hdr+5]);\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  pPage->nCell = get2byte(&data[hdr+3]);\n  if( pPage->nCell>MX_CELL(pBt) ){\n    /* To many cells for a single page.  The page must be corrupt */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  testcase( pPage->nCell==MX_CELL(pBt) );\n  /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only\n  ** possible for a root page of a table that contains no rows) then the\n  ** offset to the cell content area will equal the page size minus the\n  ** bytes of reserved space. */\n  assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );\n\n  /* A malformed database page might cause us to read past the end\n  ** of page when parsing a cell.  \n  **\n  ** The following block of code checks early to see if a cell extends\n  ** past the end of a page boundary and causes SQLITE_CORRUPT to be \n  ** returned if it does.\n  */\n  iCellFirst = cellOffset + 2*pPage->nCell;\n  iCellLast = usableSize - 4;\n  if( pBt->db->flags & SQLITE_CellSizeCk ){\n    int i;            /* Index into the cell pointer array */\n    int sz;           /* Size of a cell */\n\n    if( !pPage->leaf ) iCellLast--;\n    for(i=0; i<pPage->nCell; i++){\n      pc = get2byteAligned(&data[cellOffset+i*2]);\n      testcase( pc==iCellFirst );\n      testcase( pc==iCellLast );\n      if( pc<iCellFirst || pc>iCellLast ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      sz = pPage->xCellSize(pPage, &data[pc]);\n      testcase( pc+sz==usableSize );\n      if( pc+sz>usableSize ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n    }\n    if( !pPage->leaf ) iCellLast++;\n  }  \n\n  /* Compute the total free space on the page\n  ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the\n  ** start of the first freeblock on the page, or is zero if there are no\n  ** freeblocks. */\n  pc = get2byte(&data[hdr+1]);\n  nFree = data[hdr+7] + top;  /* Init nFree to non-freeblock free space */\n  if( pc>0 ){\n    u32 next, size;\n    if( pc<iCellFirst ){\n      /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will\n      ** always be at least one cell before the first freeblock.\n      */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno); \n    }\n    while( 1 ){\n      if( pc>iCellLast ){\n        /* Freeblock off the end of the page */\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      next = get2byte(&data[pc]);\n      size = get2byte(&data[pc+2]);\n      nFree = nFree + size;\n      if( next<=pc+size+3 ) break;\n      pc = next;\n    }\n    if( next>0 ){\n      /* Freeblock not in ascending order */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    if( pc+size>(unsigned int)usableSize ){\n      /* Last freeblock extends past page end */\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n  }\n\n  /* At this point, nFree contains the sum of the offset to the start\n  ** of the cell-content area plus the number of free bytes within\n  ** the cell-content area. If this is greater than the usable-size\n  ** of the page, then the page must be corrupted. This check also\n  ** serves to verify that the offset to the start of the cell-content\n  ** area, according to the page header, lies within the page.\n  */\n  if( nFree>usableSize ){\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  pPage->nFree = (u16)(nFree - iCellFirst);\n  pPage->isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Set up a raw page so that it looks like a database page holding\n** no entries.\n*/\nstatic void zeroPage(MemPage *pPage, int flags){\n  unsigned char *data = pPage->aData;\n  BtShared *pBt = pPage->pBt;\n  u8 hdr = pPage->hdrOffset;\n  u16 first;\n\n  assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage) == data );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->btsFlags & BTS_FAST_SECURE ){\n    memset(&data[hdr], 0, pBt->usableSize - hdr);\n  }\n  data[hdr] = (char)flags;\n  first = hdr + ((flags&PTF_LEAF)==0 ? 12 : 8);\n  memset(&data[hdr+1], 0, 4);\n  data[hdr+7] = 0;\n  put2byte(&data[hdr+5], pBt->usableSize);\n  pPage->nFree = (u16)(pBt->usableSize - first);\n  decodeFlags(pPage, flags);\n  pPage->cellOffset = first;\n  pPage->aDataEnd = &data[pBt->usableSize];\n  pPage->aCellIdx = &data[first];\n  pPage->aDataOfst = &data[pPage->childPtrSize];\n  pPage->nOverflow = 0;\n  assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );\n  pPage->maskPage = (u16)(pBt->pageSize - 1);\n  pPage->nCell = 0;\n  pPage->isInit = 1;\n}\n\n\n/*\n** Convert a DbPage obtained from the pager into a MemPage used by\n** the btree layer.\n*/\nstatic MemPage *btreePageFromDbPage(DbPage *pDbPage, Pgno pgno, BtShared *pBt){\n  MemPage *pPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( pgno!=pPage->pgno ){\n    pPage->aData = sqlite3PagerGetData(pDbPage);\n    pPage->pDbPage = pDbPage;\n    pPage->pBt = pBt;\n    pPage->pgno = pgno;\n    pPage->hdrOffset = pgno==1 ? 100 : 0;\n  }\n  assert( pPage->aData==sqlite3PagerGetData(pDbPage) );\n  return pPage; \n}\n\n/*\n** Get a page from the pager.  Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.  See also: btreeGetUnusedPage().\n**\n** If the PAGER_GET_NOCONTENT flag is set, it means that we do not care\n** about the content of the page at this time.  So do not go to the disk\n** to fetch the content.  Just fill in the content with zeros for now.\n** If in the future we call sqlite3PagerWrite() on this page, that\n** means we have started to be concerned about content and the disk\n** read should occur at that point.\n*/\nstatic int btreeGetPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc;\n  DbPage *pDbPage;\n\n  assert( flags==0 || flags==PAGER_GET_NOCONTENT || flags==PAGER_GET_READONLY );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, flags);\n  if( rc ) return rc;\n  *ppPage = btreePageFromDbPage(pDbPage, pgno, pBt);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a page from the pager cache. If the requested page is not\n** already in the pager cache return NULL. Initialize the MemPage.pBt and\n** MemPage.aData elements if needed.\n*/\nstatic MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);\n  if( pDbPage ){\n    return btreePageFromDbPage(pDbPage, pgno, pBt);\n  }\n  return 0;\n}\n\n/*\n** Return the size of the database file in pages. If there is any kind of\n** error, return ((unsigned int)-1).\n*/\nstatic Pgno btreePagecount(BtShared *pBt){\n  return pBt->nPage;\n}\nu32 sqlite3BtreeLastPage(Btree *p){\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( ((p->pBt->nPage)&0x80000000)==0 );\n  return btreePagecount(p->pBt);\n}\n\n/*\n** Get a page from the pager and initialize it.\n**\n** If pCur!=0 then the page is being fetched as part of a moveToChild()\n** call.  Do additional sanity checking on the page in this case.\n** And if the fetch fails, this routine must decrement pCur->iPage.\n**\n** The page is fetched as read-write unless pCur is not NULL and is\n** a read-only cursor.\n**\n** If an error occurs, then *ppPage is undefined. It\n** may remain unchanged, or it may be set to an invalid value.\n*/\nstatic int getAndInitPage(\n  BtShared *pBt,                  /* The database file */\n  Pgno pgno,                      /* Number of the page to get */\n  MemPage **ppPage,               /* Write the page pointer here */\n  BtCursor *pCur,                 /* Cursor to receive the page, or NULL */\n  int bReadOnly                   /* True for a read-only page */\n){\n  int rc;\n  DbPage *pDbPage;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pCur==0 || ppPage==&pCur->pPage );\n  assert( pCur==0 || bReadOnly==pCur->curPagerFlags );\n  assert( pCur==0 || pCur->iPage>0 );\n\n  if( pgno>btreePagecount(pBt) ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto getAndInitPage_error;\n  }\n  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly);\n  if( rc ){\n    goto getAndInitPage_error;\n  }\n  *ppPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);\n  if( (*ppPage)->isInit==0 ){\n    btreePageFromDbPage(pDbPage, pgno, pBt);\n    rc = btreeInitPage(*ppPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      goto getAndInitPage_error;\n    }\n  }\n  assert( (*ppPage)->pgno==pgno );\n  assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );\n\n  /* If obtaining a child page for a cursor, we must verify that the page is\n  ** compatible with the root page. */\n  if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){\n    rc = SQLITE_CORRUPT_PGNO(pgno);\n    releasePage(*ppPage);\n    goto getAndInitPage_error;\n  }\n  return SQLITE_OK;\n\ngetAndInitPage_error:\n  if( pCur ){\n    pCur->iPage--;\n    pCur->pPage = pCur->apPage[pCur->iPage];\n  }\n  testcase( pgno==0 );\n  assert( pgno!=0 || rc==SQLITE_CORRUPT );\n  return rc;\n}\n\n/*\n** Release a MemPage.  This should be called once for each prior\n** call to btreeGetPage.\n**\n** Page1 is a special case and must be released using releasePageOne().\n*/\nstatic void releasePageNotNull(MemPage *pPage){\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefNotNull(pPage->pDbPage);\n}\nstatic void releasePage(MemPage *pPage){\n  if( pPage ) releasePageNotNull(pPage);\n}\nstatic void releasePageOne(MemPage *pPage){\n  assert( pPage!=0 );\n  assert( pPage->aData );\n  assert( pPage->pBt );\n  assert( pPage->pDbPage!=0 );\n  assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );\n  assert( sqlite3PagerGetData(pPage->pDbPage)==pPage->aData );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  sqlite3PagerUnrefPageOne(pPage->pDbPage);\n}\n\n/*\n** Get an unused page.\n**\n** This works just like btreeGetPage() with the addition:\n**\n**   *  If the page is already in use for some other purpose, immediately\n**      release it and return an SQLITE_CURRUPT error.\n**   *  Make sure the isInit flag is clear\n*/\nstatic int btreeGetUnusedPage(\n  BtShared *pBt,       /* The btree */\n  Pgno pgno,           /* Number of the page to fetch */\n  MemPage **ppPage,    /* Return the page in this parameter */\n  int flags            /* PAGER_GET_NOCONTENT or PAGER_GET_READONLY */\n){\n  int rc = btreeGetPage(pBt, pgno, ppPage, flags);\n  if( rc==SQLITE_OK ){\n    if( sqlite3PagerPageRefcount((*ppPage)->pDbPage)>1 ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n      return SQLITE_CORRUPT_BKPT;\n    }\n    (*ppPage)->isInit = 0;\n  }else{\n    *ppPage = 0;\n  }\n  return rc;\n}\n\n\n/*\n** During a rollback, when the pager reloads information into the cache\n** so that the cache is restored to its original state at the start of\n** the transaction, for each page restored this routine is called.\n**\n** This routine needs to reset the extra data section at the end of the\n** page to agree with the restored data.\n*/\nstatic void pageReinit(DbPage *pData){\n  MemPage *pPage;\n  pPage = (MemPage *)sqlite3PagerGetExtra(pData);\n  assert( sqlite3PagerPageRefcount(pData)>0 );\n  if( pPage->isInit ){\n    assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n    pPage->isInit = 0;\n    if( sqlite3PagerPageRefcount(pData)>1 ){\n      /* pPage might not be a btree page;  it might be an overflow page\n      ** or ptrmap page or a free page.  In those cases, the following\n      ** call to btreeInitPage() will likely return SQLITE_CORRUPT.\n      ** But no harm is done by this.  And it is very important that\n      ** btreeInitPage() be called on every btree page so we make\n      ** the call for every page that comes in for re-initing. */\n      btreeInitPage(pPage);\n    }\n  }\n}\n\n/*\n** Invoke the busy handler for a btree.\n*/\nstatic int btreeInvokeBusyHandler(void *pArg){\n  BtShared *pBt = (BtShared*)pArg;\n  assert( pBt->db );\n  assert( sqlite3_mutex_held(pBt->db->mutex) );\n  return sqlite3InvokeBusyHandler(&pBt->db->busyHandler);\n}\n\n/*\n** Open a database file.\n** \n** zFilename is the name of the database file.  If zFilename is NULL\n** then an ephemeral database is created.  The ephemeral database might\n** be exclusively in memory, or it might use a disk-based memory cache.\n** Either way, the ephemeral database will be automatically deleted \n** when sqlite3BtreeClose() is called.\n**\n** If zFilename is \":memory:\" then an in-memory database is created\n** that is automatically destroyed when it is closed.\n**\n** The \"flags\" parameter is a bitmask that might contain bits like\n** BTREE_OMIT_JOURNAL and/or BTREE_MEMORY.\n**\n** If the database is already opened in the same database connection\n** and we are in shared cache mode, then the open will fail with an\n** SQLITE_CONSTRAINT error.  We cannot allow two or more BtShared\n** objects in the same database connection since doing so will lead\n** to problems with locking.\n*/\nint sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,      /* VFS to use for this b-tree */\n  const char *zFilename,  /* Name of the file containing the BTree database */\n  sqlite3 *db,            /* Associated database handle */\n  Btree **ppBtree,        /* Pointer to new Btree object written here */\n  int flags,              /* Options */\n  int vfsFlags            /* Flags passed through to sqlite3_vfs.xOpen() */\n){\n  BtShared *pBt = 0;             /* Shared part of btree structure */\n  Btree *p;                      /* Handle to return */\n  sqlite3_mutex *mutexOpen = 0;  /* Prevents a race condition. Ticket #3537 */\n  int rc = SQLITE_OK;            /* Result code from this function */\n  u8 nReserve;                   /* Byte of unused space on each page */\n  unsigned char zDbHeader[100];  /* Database header content */\n\n  /* True if opening an ephemeral, temporary database */\n  const int isTempDb = zFilename==0 || zFilename[0]==0;\n\n  /* Set the variable isMemdb to true for an in-memory database, or \n  ** false for a file-based database.\n  */\n#ifdef SQLITE_OMIT_MEMORYDB\n  const int isMemdb = 0;\n#else\n  const int isMemdb = (zFilename && strcmp(zFilename, \":memory:\")==0)\n                       || (isTempDb && sqlite3TempInMemory(db))\n                       || (vfsFlags & SQLITE_OPEN_MEMORY)!=0;\n#endif\n\n  assert( db!=0 );\n  assert( pVfs!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( (flags&0xff)==flags );   /* flags fit in 8 bits */\n\n  /* Only a BTREE_SINGLE database can be BTREE_UNORDERED */\n  assert( (flags & BTREE_UNORDERED)==0 || (flags & BTREE_SINGLE)!=0 );\n\n  /* A BTREE_SINGLE database is always a temporary and/or ephemeral */\n  assert( (flags & BTREE_SINGLE)==0 || isTempDb );\n\n  if( isMemdb ){\n    flags |= BTREE_MEMORY;\n  }\n  if( (vfsFlags & SQLITE_OPEN_MAIN_DB)!=0 && (isMemdb || isTempDb) ){\n    vfsFlags = (vfsFlags & ~SQLITE_OPEN_MAIN_DB) | SQLITE_OPEN_TEMP_DB;\n  }\n  p = sqlite3MallocZero(sizeof(Btree));\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  p->inTrans = TRANS_NONE;\n  p->db = db;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  p->lock.pBtree = p;\n  p->lock.iTable = 1;\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /*\n  ** If this Btree is a candidate for shared cache, try to find an\n  ** existing BtShared object that we can share with\n  */\n  if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){\n    if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){\n      int nFilename = sqlite3Strlen30(zFilename)+1;\n      int nFullPathname = pVfs->mxPathname+1;\n      char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n\n      p->sharable = 1;\n      if( !zFullPathname ){\n        sqlite3_free(p);\n        return SQLITE_NOMEM_BKPT;\n      }\n      if( isMemdb ){\n        memcpy(zFullPathname, zFilename, nFilename);\n      }else{\n        rc = sqlite3OsFullPathname(pVfs, zFilename,\n                                   nFullPathname, zFullPathname);\n        if( rc ){\n          sqlite3_free(zFullPathname);\n          sqlite3_free(p);\n          return rc;\n        }\n      }\n#if SQLITE_THREADSAFE\n      mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);\n      sqlite3_mutex_enter(mutexOpen);\n      mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n      sqlite3_mutex_enter(mutexShared);\n#endif\n      for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){\n        assert( pBt->nRef>0 );\n        if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager, 0))\n                 && sqlite3PagerVfs(pBt->pPager)==pVfs ){\n          int iDb;\n          for(iDb=db->nDb-1; iDb>=0; iDb--){\n            Btree *pExisting = db->aDb[iDb].pBt;\n            if( pExisting && pExisting->pBt==pBt ){\n              sqlite3_mutex_leave(mutexShared);\n              sqlite3_mutex_leave(mutexOpen);\n              sqlite3_free(zFullPathname);\n              sqlite3_free(p);\n              return SQLITE_CONSTRAINT;\n            }\n          }\n          p->pBt = pBt;\n          pBt->nRef++;\n          break;\n        }\n      }\n      sqlite3_mutex_leave(mutexShared);\n      sqlite3_free(zFullPathname);\n    }\n#ifdef SQLITE_DEBUG\n    else{\n      /* In debug mode, we mark all persistent databases as sharable\n      ** even when they are not.  This exercises the locking code and\n      ** gives more opportunity for asserts(sqlite3_mutex_held())\n      ** statements to find locking problems.\n      */\n      p->sharable = 1;\n    }\n#endif\n  }\n#endif\n  if( pBt==0 ){\n    /*\n    ** The following asserts make sure that structures used by the btree are\n    ** the right size.  This is to guard against size changes that result\n    ** when compiling on a different architecture.\n    */\n    assert( sizeof(i64)==8 );\n    assert( sizeof(u64)==8 );\n    assert( sizeof(u32)==4 );\n    assert( sizeof(u16)==2 );\n    assert( sizeof(Pgno)==4 );\n  \n    pBt = sqlite3MallocZero( sizeof(*pBt) );\n    if( pBt==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto btree_open_out;\n    }\n    rc = sqlite3PagerOpen(pVfs, &pBt->pPager, zFilename,\n                          sizeof(MemPage), flags, vfsFlags, pageReinit);\n    if( rc==SQLITE_OK ){\n      sqlite3PagerSetMmapLimit(pBt->pPager, db->szMmap);\n      rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader);\n    }\n    if( rc!=SQLITE_OK ){\n      goto btree_open_out;\n    }\n    pBt->openFlags = (u8)flags;\n    pBt->db = db;\n    sqlite3PagerSetBusyhandler(pBt->pPager, btreeInvokeBusyHandler, pBt);\n    p->pBt = pBt;\n  \n    pBt->pCursor = 0;\n    pBt->pPage1 = 0;\n    if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY;\n#if defined(SQLITE_SECURE_DELETE)\n    pBt->btsFlags |= BTS_SECURE_DELETE;\n#elif defined(SQLITE_FAST_SECURE_DELETE)\n    pBt->btsFlags |= BTS_OVERWRITE;\n#endif\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);\n    if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE\n         || ((pBt->pageSize-1)&pBt->pageSize)!=0 ){\n      pBt->pageSize = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the magic name \":memory:\" will create an in-memory database, then\n      ** leave the autoVacuum mode at 0 (do not auto-vacuum), even if\n      ** SQLITE_DEFAULT_AUTOVACUUM is true. On the other hand, if\n      ** SQLITE_OMIT_MEMORYDB has been defined, then \":memory:\" is just a\n      ** regular file-name. In this case the auto-vacuum applies as per normal.\n      */\n      if( zFilename && !isMemdb ){\n        pBt->autoVacuum = (SQLITE_DEFAULT_AUTOVACUUM ? 1 : 0);\n        pBt->incrVacuum = (SQLITE_DEFAULT_AUTOVACUUM==2 ? 1 : 0);\n      }\n#endif\n      nReserve = 0;\n    }else{\n      /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n      ** determined by the one-byte unsigned integer found at an offset of 20\n      ** into the database file header. */\n      nReserve = zDbHeader[20];\n      pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);\n      pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0);\n#endif\n    }\n    rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n    if( rc ) goto btree_open_out;\n    pBt->usableSize = pBt->pageSize - nReserve;\n    assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */\n   \n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n    /* Add the new BtShared object to the linked list sharable BtShareds.\n    */\n    pBt->nRef = 1;\n    if( p->sharable ){\n      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )\n      MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)\n      if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){\n        pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);\n        if( pBt->mutex==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto btree_open_out;\n        }\n      }\n      sqlite3_mutex_enter(mutexShared);\n      pBt->pNext = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt;\n      sqlite3_mutex_leave(mutexShared);\n    }\n#endif\n  }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)\n  /* If the new Btree uses a sharable pBtShared, then link the new\n  ** Btree into the list of all sharable Btrees for the same connection.\n  ** The list is kept in ascending order by pBt address.\n  */\n  if( p->sharable ){\n    int i;\n    Btree *pSib;\n    for(i=0; i<db->nDb; i++){\n      if( (pSib = db->aDb[i].pBt)!=0 && pSib->sharable ){\n        while( pSib->pPrev ){ pSib = pSib->pPrev; }\n        if( (uptr)p->pBt<(uptr)pSib->pBt ){\n          p->pNext = pSib;\n          p->pPrev = 0;\n          pSib->pPrev = p;\n        }else{\n          while( pSib->pNext && (uptr)pSib->pNext->pBt<(uptr)p->pBt ){\n            pSib = pSib->pNext;\n          }\n          p->pNext = pSib->pNext;\n          p->pPrev = pSib;\n          if( p->pNext ){\n            p->pNext->pPrev = p;\n          }\n          pSib->pNext = p;\n        }\n        break;\n      }\n    }\n  }\n#endif\n  *ppBtree = p;\n\nbtree_open_out:\n  if( rc!=SQLITE_OK ){\n    if( pBt && pBt->pPager ){\n      sqlite3PagerClose(pBt->pPager, 0);\n    }\n    sqlite3_free(pBt);\n    sqlite3_free(p);\n    *ppBtree = 0;\n  }else{\n    sqlite3_file *pFile;\n\n    /* If the B-Tree was successfully opened, set the pager-cache size to the\n    ** default value. Except, when opening on an existing shared pager-cache,\n    ** do not change the pager-cache size.\n    */\n    if( sqlite3BtreeSchema(p, 0, 0)==0 ){\n      sqlite3PagerSetCachesize(p->pBt->pPager, SQLITE_DEFAULT_CACHE_SIZE);\n    }\n\n    pFile = sqlite3PagerFile(pBt->pPager);\n    if( pFile->pMethods ){\n      sqlite3OsFileControlHint(pFile, SQLITE_FCNTL_PDB, (void*)&pBt->db);\n    }\n  }\n  if( mutexOpen ){\n    assert( sqlite3_mutex_held(mutexOpen) );\n    sqlite3_mutex_leave(mutexOpen);\n  }\n  assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 );\n  return rc;\n}\n\n/*\n** Decrement the BtShared.nRef counter.  When it reaches zero,\n** remove the BtShared structure from the sharing list.  Return\n** true if the BtShared.nRef counter reaches zero and return\n** false if it is still positive.\n*/\nstatic int removeFromSharingList(BtShared *pBt){\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )\n  BtShared *pList;\n  int removed = 0;\n\n  assert( sqlite3_mutex_notheld(pBt->mutex) );\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  pBt->nRef--;\n  if( pBt->nRef<=0 ){\n    if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){\n      GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;\n    }else{\n      pList = GLOBAL(BtShared*,sqlite3SharedCacheList);\n      while( ALWAYS(pList) && pList->pNext!=pBt ){\n        pList=pList->pNext;\n      }\n      if( ALWAYS(pList) ){\n        pList->pNext = pBt->pNext;\n      }\n    }\n    if( SQLITE_THREADSAFE ){\n      sqlite3_mutex_free(pBt->mutex);\n    }\n    removed = 1;\n  }\n  sqlite3_mutex_leave(pMaster);\n  return removed;\n#else\n  return 1;\n#endif\n}\n\n/*\n** Make sure pBt->pTmpSpace points to an allocation of \n** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child\n** pointer.\n*/\nstatic void allocateTempSpace(BtShared *pBt){\n  if( !pBt->pTmpSpace ){\n    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );\n\n    /* One of the uses of pBt->pTmpSpace is to format cells before\n    ** inserting them into a leaf page (function fillInCell()). If\n    ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes\n    ** by the various routines that manipulate binary cells. Which\n    ** can mean that fillInCell() only initializes the first 2 or 3\n    ** bytes of pTmpSpace, but that the first 4 bytes are copied from\n    ** it into a database page. This is not actually a problem, but it\n    ** does cause a valgrind error when the 1 or 2 bytes of unitialized \n    ** data is passed to system call write(). So to avoid this error,\n    ** zero the first 4 bytes of temp space here.\n    **\n    ** Also:  Provide four bytes of initialized space before the\n    ** beginning of pTmpSpace as an area available to prepend the\n    ** left-child pointer to the beginning of a cell.\n    */\n    if( pBt->pTmpSpace ){\n      memset(pBt->pTmpSpace, 0, 8);\n      pBt->pTmpSpace += 4;\n    }\n  }\n}\n\n/*\n** Free the pBt->pTmpSpace allocation\n*/\nstatic void freeTempSpace(BtShared *pBt){\n  if( pBt->pTmpSpace ){\n    pBt->pTmpSpace -= 4;\n    sqlite3PageFree(pBt->pTmpSpace);\n    pBt->pTmpSpace = 0;\n  }\n}\n\n/*\n** Close an open database and invalidate all cursors.\n*/\nint sqlite3BtreeClose(Btree *p){\n  BtShared *pBt = p->pBt;\n  BtCursor *pCur;\n\n  /* Close all cursors opened via this handle.  */\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  pCur = pBt->pCursor;\n  while( pCur ){\n    BtCursor *pTmp = pCur;\n    pCur = pCur->pNext;\n    if( pTmp->pBtree==p ){\n      sqlite3BtreeCloseCursor(pTmp);\n    }\n  }\n\n  /* Rollback any active transaction and free the handle structure.\n  ** The call to sqlite3BtreeRollback() drops any table-locks held by\n  ** this handle.\n  */\n  sqlite3BtreeRollback(p, SQLITE_OK, 0);\n  sqlite3BtreeLeave(p);\n\n  /* If there are still other outstanding references to the shared-btree\n  ** structure, return now. The remainder of this procedure cleans \n  ** up the shared-btree.\n  */\n  assert( p->wantToLock==0 && p->locked==0 );\n  if( !p->sharable || removeFromSharingList(pBt) ){\n    /* The pBt is no longer on the sharing list, so we can access\n    ** it without having to hold the mutex.\n    **\n    ** Clean out and delete the BtShared object.\n    */\n    assert( !pBt->pCursor );\n    sqlite3PagerClose(pBt->pPager, p->db);\n    if( pBt->xFreeSchema && pBt->pSchema ){\n      pBt->xFreeSchema(pBt->pSchema);\n    }\n    sqlite3DbFree(0, pBt->pSchema);\n    freeTempSpace(pBt);\n    sqlite3_free(pBt);\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  assert( p->wantToLock==0 );\n  assert( p->locked==0 );\n  if( p->pPrev ) p->pPrev->pNext = p->pNext;\n  if( p->pNext ) p->pNext->pPrev = p->pPrev;\n#endif\n\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"soft\" limit on the number of pages in the cache.\n** Unused and unmodified pages will be recycled when the number of\n** pages in the cache exceeds this soft limit.  But the size of the\n** cache is allowed to grow larger than this limit if it contains\n** dirty pages or pages still in active use.\n*/\nint sqlite3BtreeSetCacheSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetCachesize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Change the \"spill\" limit on the number of pages in the cache.\n** If the number of pages exceeds this limit during a write transaction,\n** the pager might attempt to \"spill\" pages to the journal early in\n** order to free up memory.\n**\n** The value returned is the current spill size.  If zero is passed\n** as an argument, no changes are made to the spill size setting, so\n** using mxPage of 0 is a way to query the current spill size.\n*/\nint sqlite3BtreeSetSpillSize(Btree *p, int mxPage){\n  BtShared *pBt = p->pBt;\n  int res;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  res = sqlite3PagerSetSpillsize(pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return res;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Change the limit on the amount of the database file that may be\n** memory mapped.\n*/\nint sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 szMmap){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetMmapLimit(pBt->pPager, szMmap);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** Change the way data is synced to disk in order to increase or decrease\n** how well the database resists damage due to OS crashes and power\n** failures.  Level 1 is the same as asynchronous (no syncs() occur and\n** there is a high probability of damage)  Level 2 is the default.  There\n** is a very low but non-zero probability of damage.  Level 3 reduces the\n** probability of damage to near zero but with a write performance reduction.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nint sqlite3BtreeSetPagerFlags(\n  Btree *p,              /* The btree to set the safety level on */\n  unsigned pgFlags       /* Various PAGER_* flags */\n){\n  BtShared *pBt = p->pBt;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  sqlite3PagerSetFlags(pBt->pPager, pgFlags);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Change the default pages size and the number of reserved bytes per page.\n** Or, if the page size has already been fixed, return SQLITE_READONLY \n** without changing anything.\n**\n** The page size must be a power of 2 between 512 and 65536.  If the page\n** size supplied does not meet this constraint then the page size is not\n** changed.\n**\n** Page sizes are constrained to be a power of two so that the region\n** of the database file used for locking (beginning at PENDING_BYTE,\n** the first byte past the 1GB boundary, 0x40000000) needs to occur\n** at the beginning of a page.\n**\n** If parameter nReserve is less than zero, then the number of reserved\n** bytes per page is left unchanged.\n**\n** If the iFix!=0 then the BTS_PAGESIZE_FIXED flag is set so that the page size\n** and autovacuum mode can no longer be changed.\n*/\nint sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, int iFix){\n  int rc = SQLITE_OK;\n  BtShared *pBt = p->pBt;\n  assert( nReserve>=-1 && nReserve<=255 );\n  sqlite3BtreeEnter(p);\n#if SQLITE_HAS_CODEC\n  if( nReserve>pBt->optimalReserve ) pBt->optimalReserve = (u8)nReserve;\n#endif\n  if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){\n    sqlite3BtreeLeave(p);\n    return SQLITE_READONLY;\n  }\n  if( nReserve<0 ){\n    nReserve = pBt->pageSize - pBt->usableSize;\n  }\n  assert( nReserve>=0 && nReserve<=255 );\n  if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&\n        ((pageSize-1)&pageSize)==0 ){\n    assert( (pageSize & 7)==0 );\n    assert( !pBt->pCursor );\n    pBt->pageSize = (u32)pageSize;\n    freeTempSpace(pBt);\n  }\n  rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);\n  pBt->usableSize = pBt->pageSize - (u16)nReserve;\n  if( iFix ) pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Return the currently defined page size\n*/\nint sqlite3BtreeGetPageSize(Btree *p){\n  return p->pBt->pageSize;\n}\n\n/*\n** This function is similar to sqlite3BtreeGetReserve(), except that it\n** may only be called if it is guaranteed that the b-tree mutex is already\n** held.\n**\n** This is useful in one special case in the backup API code where it is\n** known that the shared b-tree mutex is held, but the mutex on the \n** database handle that owns *p is not. In this case if sqlite3BtreeEnter()\n** were to be called, it might collide with some other operation on the\n** database handle that owns *p, causing undefined behavior.\n*/\nint sqlite3BtreeGetReserveNoMutex(Btree *p){\n  int n;\n  assert( sqlite3_mutex_held(p->pBt->mutex) );\n  n = p->pBt->pageSize - p->pBt->usableSize;\n  return n;\n}\n\n/*\n** Return the number of bytes of space at the end of every page that\n** are intentually left unused.  This is the \"reserved\" space that is\n** sometimes used by extensions.\n**\n** If SQLITE_HAS_MUTEX is defined then the number returned is the\n** greater of the current reserved space and the maximum requested\n** reserve space.\n*/\nint sqlite3BtreeGetOptimalReserve(Btree *p){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3BtreeGetReserveNoMutex(p);\n#ifdef SQLITE_HAS_CODEC\n  if( n<p->pBt->optimalReserve ) n = p->pBt->optimalReserve;\n#endif\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n\n/*\n** Set the maximum page count for a database if mxPage is positive.\n** No changes are made if mxPage is 0 or negative.\n** Regardless of the value of mxPage, return the maximum page count.\n*/\nint sqlite3BtreeMaxPageCount(Btree *p, int mxPage){\n  int n;\n  sqlite3BtreeEnter(p);\n  n = sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);\n  sqlite3BtreeLeave(p);\n  return n;\n}\n\n/*\n** Change the values for the BTS_SECURE_DELETE and BTS_OVERWRITE flags:\n**\n**    newFlag==0       Both BTS_SECURE_DELETE and BTS_OVERWRITE are cleared\n**    newFlag==1       BTS_SECURE_DELETE set and BTS_OVERWRITE is cleared\n**    newFlag==2       BTS_SECURE_DELETE cleared and BTS_OVERWRITE is set\n**    newFlag==(-1)    No changes\n**\n** This routine acts as a query if newFlag is less than zero\n**\n** With BTS_OVERWRITE set, deleted content is overwritten by zeros, but\n** freelist leaf pages are not written back to the database.  Thus in-page\n** deleted content is cleared, but freelist deleted content is not.\n**\n** With BTS_SECURE_DELETE, operation is like BTS_OVERWRITE with the addition\n** that freelist leaf pages are written back into the database, increasing\n** the amount of disk I/O.\n*/\nint sqlite3BtreeSecureDelete(Btree *p, int newFlag){\n  int b;\n  if( p==0 ) return 0;\n  sqlite3BtreeEnter(p);\n  assert( BTS_OVERWRITE==BTS_SECURE_DELETE*2 );\n  assert( BTS_FAST_SECURE==(BTS_OVERWRITE|BTS_SECURE_DELETE) );\n  if( newFlag>=0 ){\n    p->pBt->btsFlags &= ~BTS_FAST_SECURE;\n    p->pBt->btsFlags |= BTS_SECURE_DELETE*newFlag;\n  }\n  b = (p->pBt->btsFlags & BTS_FAST_SECURE)/BTS_SECURE_DELETE;\n  sqlite3BtreeLeave(p);\n  return b;\n}\n\n/*\n** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'\n** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it\n** is disabled. The default value for the auto-vacuum property is \n** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.\n*/\nint sqlite3BtreeSetAutoVacuum(Btree *p, int autoVacuum){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return SQLITE_READONLY;\n#else\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n  u8 av = (u8)autoVacuum;\n\n  sqlite3BtreeEnter(p);\n  if( (pBt->btsFlags & BTS_PAGESIZE_FIXED)!=0 && (av ?1:0)!=pBt->autoVacuum ){\n    rc = SQLITE_READONLY;\n  }else{\n    pBt->autoVacuum = av ?1:0;\n    pBt->incrVacuum = av==2 ?1:0;\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** Return the value of the 'auto-vacuum' property. If auto-vacuum is \n** enabled 1 is returned. Otherwise 0.\n*/\nint sqlite3BtreeGetAutoVacuum(Btree *p){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  return BTREE_AUTOVACUUM_NONE;\n#else\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = (\n    (!p->pBt->autoVacuum)?BTREE_AUTOVACUUM_NONE:\n    (!p->pBt->incrVacuum)?BTREE_AUTOVACUUM_FULL:\n    BTREE_AUTOVACUUM_INCR\n  );\n  sqlite3BtreeLeave(p);\n  return rc;\n#endif\n}\n\n/*\n** If the user has not set the safety-level for this database connection\n** using \"PRAGMA synchronous\", and if the safety-level is not already\n** set to the value passed to this function as the second parameter,\n** set it so.\n*/\n#if SQLITE_DEFAULT_SYNCHRONOUS!=SQLITE_DEFAULT_WAL_SYNCHRONOUS \\\n    && !defined(SQLITE_OMIT_WAL)\nstatic void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){\n  sqlite3 *db;\n  Db *pDb;\n  if( (db=pBt->db)!=0 && (pDb=db->aDb)!=0 ){\n    while( pDb->pBt==0 || pDb->pBt->pBt!=pBt ){ pDb++; }\n    if( pDb->bSyncSet==0 \n     && pDb->safety_level!=safety_level \n     && pDb!=&db->aDb[1] \n    ){\n      pDb->safety_level = safety_level;\n      sqlite3PagerSetFlags(pBt->pPager,\n          pDb->safety_level | (db->flags & PAGER_FLAGS_MASK));\n    }\n  }\n}\n#else\n# define setDefaultSyncFlag(pBt,safety_level)\n#endif\n\n/*\n** Get a reference to pPage1 of the database file.  This will\n** also acquire a readlock on that file.\n**\n** SQLITE_OK is returned on success.  If the file is not a\n** well-formed database file, then SQLITE_CORRUPT is returned.\n** SQLITE_BUSY is returned if the database is locked.  SQLITE_NOMEM\n** is returned if we run out of memory. \n*/\nstatic int lockBtree(BtShared *pBt){\n  int rc;              /* Result code from subfunctions */\n  MemPage *pPage1;     /* Page 1 of the database file */\n  int nPage;           /* Number of pages in the database */\n  int nPageFile = 0;   /* Number of pages in the database file */\n  int nPageHeader;     /* Number of pages in the database according to hdr */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pBt->pPage1==0 );\n  rc = sqlite3PagerSharedLock(pBt->pPager);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = btreeGetPage(pBt, 1, &pPage1, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Do some checking to help insure the file we opened really is\n  ** a valid database file. \n  */\n  nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);\n  sqlite3PagerPagecount(pBt->pPager, &nPageFile);\n  if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){\n    nPage = nPageFile;\n  }\n  if( nPage>0 ){\n    u32 pageSize;\n    u32 usableSize;\n    u8 *page1 = pPage1->aData;\n    rc = SQLITE_NOTADB;\n    /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins\n    ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d\n    ** 61 74 20 33 00. */\n    if( memcmp(page1, zMagicHeader, 16)!=0 ){\n      goto page1_init_failed;\n    }\n\n#ifdef SQLITE_OMIT_WAL\n    if( page1[18]>1 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>1 ){\n      goto page1_init_failed;\n    }\n#else\n    if( page1[18]>2 ){\n      pBt->btsFlags |= BTS_READ_ONLY;\n    }\n    if( page1[19]>2 ){\n      goto page1_init_failed;\n    }\n\n    /* If the write version is set to 2, this database should be accessed\n    ** in WAL mode. If the log is not already open, open it now. Then \n    ** return SQLITE_OK and return without populating BtShared.pPage1.\n    ** The caller detects this and calls this function again. This is\n    ** required as the version of page 1 currently in the page1 buffer\n    ** may not be the latest version - there may be a newer one in the log\n    ** file.\n    */\n    if( page1[19]==2 && (pBt->btsFlags & BTS_NO_WAL)==0 ){\n      int isOpen = 0;\n      rc = sqlite3PagerOpenWal(pBt->pPager, &isOpen);\n      if( rc!=SQLITE_OK ){\n        goto page1_init_failed;\n      }else{\n        setDefaultSyncFlag(pBt, SQLITE_DEFAULT_WAL_SYNCHRONOUS+1);\n        if( isOpen==0 ){\n          releasePageOne(pPage1);\n          return SQLITE_OK;\n        }\n      }\n      rc = SQLITE_NOTADB;\n    }else{\n      setDefaultSyncFlag(pBt, SQLITE_DEFAULT_SYNCHRONOUS+1);\n    }\n#endif\n\n    /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload\n    ** fractions and the leaf payload fraction values must be 64, 32, and 32.\n    **\n    ** The original design allowed these amounts to vary, but as of\n    ** version 3.6.0, we require them to be fixed.\n    */\n    if( memcmp(&page1[21], \"\\100\\040\\040\",3)!=0 ){\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-51873-39618 The page size for a database file is\n    ** determined by the 2-byte integer located at an offset of 16 bytes from\n    ** the beginning of the database file. */\n    pageSize = (page1[16]<<8) | (page1[17]<<16);\n    /* EVIDENCE-OF: R-25008-21688 The size of a page is a power of two\n    ** between 512 and 65536 inclusive. */\n    if( ((pageSize-1)&pageSize)!=0\n     || pageSize>SQLITE_MAX_PAGE_SIZE \n     || pageSize<=256 \n    ){\n      goto page1_init_failed;\n    }\n    assert( (pageSize & 7)==0 );\n    /* EVIDENCE-OF: R-59310-51205 The \"reserved space\" size in the 1-byte\n    ** integer at offset 20 is the number of bytes of space at the end of\n    ** each page to reserve for extensions. \n    **\n    ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is\n    ** determined by the one-byte unsigned integer found at an offset of 20\n    ** into the database file header. */\n    usableSize = pageSize - page1[20];\n    if( (u32)pageSize!=pBt->pageSize ){\n      /* After reading the first page of the database assuming a page size\n      ** of BtShared.pageSize, we have discovered that the page-size is\n      ** actually pageSize. Unlock the database, leave pBt->pPage1 at\n      ** zero and return SQLITE_OK. The caller will call this function\n      ** again with the correct page-size.\n      */\n      releasePageOne(pPage1);\n      pBt->usableSize = usableSize;\n      pBt->pageSize = pageSize;\n      freeTempSpace(pBt);\n      rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize,\n                                   pageSize-usableSize);\n      return rc;\n    }\n    if( (pBt->db->flags & SQLITE_WriteSchema)==0 && nPage>nPageFile ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto page1_init_failed;\n    }\n    /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to\n    ** be less than 480. In other words, if the page size is 512, then the\n    ** reserved space size cannot exceed 32. */\n    if( usableSize<480 ){\n      goto page1_init_failed;\n    }\n    pBt->pageSize = pageSize;\n    pBt->usableSize = usableSize;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0);\n    pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0);\n#endif\n  }\n\n  /* maxLocal is the maximum amount of payload to store locally for\n  ** a cell.  Make sure it is small enough so that at least minFanout\n  ** cells can will fit on one page.  We assume a 10-byte page header.\n  ** Besides the payload, the cell must store:\n  **     2-byte pointer to the cell\n  **     4-byte child pointer\n  **     9-byte nKey value\n  **     4-byte nData value\n  **     4-byte overflow page pointer\n  ** So a cell consists of a 2-byte pointer, a header which is as much as\n  ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow\n  ** page pointer.\n  */\n  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);\n  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);\n  pBt->maxLeaf = (u16)(pBt->usableSize - 35);\n  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);\n  if( pBt->maxLocal>127 ){\n    pBt->max1bytePayload = 127;\n  }else{\n    pBt->max1bytePayload = (u8)pBt->maxLocal;\n  }\n  assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );\n  pBt->pPage1 = pPage1;\n  pBt->nPage = nPage;\n  return SQLITE_OK;\n\npage1_init_failed:\n  releasePageOne(pPage1);\n  pBt->pPage1 = 0;\n  return rc;\n}\n\n#ifndef NDEBUG\n/*\n** Return the number of cursors open on pBt. This is for use\n** in assert() expressions, so it is only compiled if NDEBUG is not\n** defined.\n**\n** Only write cursors are counted if wrOnly is true.  If wrOnly is\n** false then all cursors are counted.\n**\n** For the purposes of this routine, a cursor is any cursor that\n** is capable of reading or writing to the database.  Cursors that\n** have been tripped into the CURSOR_FAULT state are not counted.\n*/\nstatic int countValidCursors(BtShared *pBt, int wrOnly){\n  BtCursor *pCur;\n  int r = 0;\n  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){\n    if( (wrOnly==0 || (pCur->curFlags & BTCF_WriteFlag)!=0)\n     && pCur->eState!=CURSOR_FAULT ) r++; \n  }\n  return r;\n}\n#endif\n\n/*\n** If there are no outstanding cursors and we are not in the middle\n** of a transaction but there is a read lock on the database, then\n** this routine unrefs the first page of the database file which \n** has the effect of releasing the read lock.\n**\n** If there is a transaction in progress, this routine is a no-op.\n*/\nstatic void unlockBtreeIfUnused(BtShared *pBt){\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( countValidCursors(pBt,0)==0 || pBt->inTransaction>TRANS_NONE );\n  if( pBt->inTransaction==TRANS_NONE && pBt->pPage1!=0 ){\n    MemPage *pPage1 = pBt->pPage1;\n    assert( pPage1->aData );\n    assert( sqlite3PagerRefcount(pBt->pPager)==1 );\n    pBt->pPage1 = 0;\n    releasePageOne(pPage1);\n  }\n}\n\n/*\n** If pBt points to an empty file then convert that empty file\n** into a new empty database by initializing the first page of\n** the database.\n*/\nstatic int newDatabase(BtShared *pBt){\n  MemPage *pP1;\n  unsigned char *data;\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pBt->nPage>0 ){\n    return SQLITE_OK;\n  }\n  pP1 = pBt->pPage1;\n  assert( pP1!=0 );\n  data = pP1->aData;\n  rc = sqlite3PagerWrite(pP1->pDbPage);\n  if( rc ) return rc;\n  memcpy(data, zMagicHeader, sizeof(zMagicHeader));\n  assert( sizeof(zMagicHeader)==16 );\n  data[16] = (u8)((pBt->pageSize>>8)&0xff);\n  data[17] = (u8)((pBt->pageSize>>16)&0xff);\n  data[18] = 1;\n  data[19] = 1;\n  assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);\n  data[20] = (u8)(pBt->pageSize - pBt->usableSize);\n  data[21] = 64;\n  data[22] = 32;\n  data[23] = 32;\n  memset(&data[24], 0, 100-24);\n  zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );\n  pBt->btsFlags |= BTS_PAGESIZE_FIXED;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 );\n  assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 );\n  put4byte(&data[36 + 4*4], pBt->autoVacuum);\n  put4byte(&data[36 + 7*4], pBt->incrVacuum);\n#endif\n  pBt->nPage = 1;\n  data[31] = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Initialize the first page of the database file (creating a database\n** consisting of a single page and no schema objects). Return SQLITE_OK\n** if successful, or an SQLite error code otherwise.\n*/\nint sqlite3BtreeNewDb(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  p->pBt->nPage = 0;\n  rc = newDatabase(p->pBt);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Attempt to start a new transaction. A write-transaction\n** is started if the second argument is nonzero, otherwise a read-\n** transaction.  If the second argument is 2 or more and exclusive\n** transaction is started, meaning that no other process is allowed\n** to access the database.  A preexisting transaction may not be\n** upgraded to exclusive by calling this routine a second time - the\n** exclusivity flag only works for a new transaction.\n**\n** A write-transaction must be started before attempting any \n** changes to the database.  None of the following routines \n** will work unless a transaction is started first:\n**\n**      sqlite3BtreeCreateTable()\n**      sqlite3BtreeCreateIndex()\n**      sqlite3BtreeClearTable()\n**      sqlite3BtreeDropTable()\n**      sqlite3BtreeInsert()\n**      sqlite3BtreeDelete()\n**      sqlite3BtreeUpdateMeta()\n**\n** If an initial attempt to acquire the lock fails because of lock contention\n** and the database was previously unlocked, then invoke the busy handler\n** if there is one.  But if there was previously a read-lock, do not\n** invoke the busy handler - just return SQLITE_BUSY.  SQLITE_BUSY is \n** returned when there is already a read-lock in order to avoid a deadlock.\n**\n** Suppose there are two processes A and B.  A has a read lock and B has\n** a reserved lock.  B tries to promote to exclusive but is blocked because\n** of A's read lock.  A tries to promote to reserved but is blocked by B.\n** One or the other of the two processes must give way or there can be\n** no progress.  By returning SQLITE_BUSY and not invoking the busy callback\n** when A already has a read lock, we encourage A to give up and let B\n** proceed.\n*/\nint sqlite3BtreeBeginTrans(Btree *p, int wrflag){\n  BtShared *pBt = p->pBt;\n  int rc = SQLITE_OK;\n\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the btree is already in a write-transaction, or it\n  ** is already in a read-transaction and a read-transaction\n  ** is requested, this is a no-op.\n  */\n  if( p->inTrans==TRANS_WRITE || (p->inTrans==TRANS_READ && !wrflag) ){\n    goto trans_begun;\n  }\n  assert( pBt->inTransaction==TRANS_WRITE || IfNotOmitAV(pBt->bDoTruncate)==0 );\n\n  /* Write transactions are not possible on a read-only database */\n  if( (pBt->btsFlags & BTS_READ_ONLY)!=0 && wrflag ){\n    rc = SQLITE_READONLY;\n    goto trans_begun;\n  }\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  {\n    sqlite3 *pBlock = 0;\n    /* If another database handle has already opened a write transaction \n    ** on this shared-btree structure and a second write transaction is\n    ** requested, return SQLITE_LOCKED.\n    */\n    if( (wrflag && pBt->inTransaction==TRANS_WRITE)\n     || (pBt->btsFlags & BTS_PENDING)!=0\n    ){\n      pBlock = pBt->pWriter->db;\n    }else if( wrflag>1 ){\n      BtLock *pIter;\n      for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){\n        if( pIter->pBtree!=p ){\n          pBlock = pIter->pBtree->db;\n          break;\n        }\n      }\n    }\n    if( pBlock ){\n      sqlite3ConnectionBlocked(p->db, pBlock);\n      rc = SQLITE_LOCKED_SHAREDCACHE;\n      goto trans_begun;\n    }\n  }\n#endif\n\n  /* Any read-only or read-write transaction implies a read-lock on \n  ** page 1. So if some other shared-cache client already has a write-lock \n  ** on page 1, the transaction cannot be opened. */\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  if( SQLITE_OK!=rc ) goto trans_begun;\n\n  pBt->btsFlags &= ~BTS_INITIALLY_EMPTY;\n  if( pBt->nPage==0 ) pBt->btsFlags |= BTS_INITIALLY_EMPTY;\n  do {\n    /* Call lockBtree() until either pBt->pPage1 is populated or\n    ** lockBtree() returns something other than SQLITE_OK. lockBtree()\n    ** may return SQLITE_OK but leave pBt->pPage1 set to 0 if after\n    ** reading page 1 it discovers that the page-size of the database \n    ** file is not pBt->pageSize. In this case lockBtree() will update\n    ** pBt->pageSize to the page-size of the file on disk.\n    */\n    while( pBt->pPage1==0 && SQLITE_OK==(rc = lockBtree(pBt)) );\n\n    if( rc==SQLITE_OK && wrflag ){\n      if( (pBt->btsFlags & BTS_READ_ONLY)!=0 ){\n        rc = SQLITE_READONLY;\n      }else{\n        rc = sqlite3PagerBegin(pBt->pPager,wrflag>1,sqlite3TempInMemory(p->db));\n        if( rc==SQLITE_OK ){\n          rc = newDatabase(pBt);\n        }\n      }\n    }\n  \n    if( rc!=SQLITE_OK ){\n      unlockBtreeIfUnused(pBt);\n    }\n  }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE &&\n          btreeInvokeBusyHandler(pBt) );\n\n  if( rc==SQLITE_OK ){\n    if( p->inTrans==TRANS_NONE ){\n      pBt->nTransaction++;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      if( p->sharable ){\n        assert( p->lock.pBtree==p && p->lock.iTable==1 );\n        p->lock.eLock = READ_LOCK;\n        p->lock.pNext = pBt->pLock;\n        pBt->pLock = &p->lock;\n      }\n#endif\n    }\n    p->inTrans = (wrflag?TRANS_WRITE:TRANS_READ);\n    if( p->inTrans>pBt->inTransaction ){\n      pBt->inTransaction = p->inTrans;\n    }\n    if( wrflag ){\n      MemPage *pPage1 = pBt->pPage1;\n#ifndef SQLITE_OMIT_SHARED_CACHE\n      assert( !pBt->pWriter );\n      pBt->pWriter = p;\n      pBt->btsFlags &= ~BTS_EXCLUSIVE;\n      if( wrflag>1 ) pBt->btsFlags |= BTS_EXCLUSIVE;\n#endif\n\n      /* If the db-size header field is incorrect (as it may be if an old\n      ** client has been writing the database file), update it now. Doing\n      ** this sooner rather than later means the database size can safely \n      ** re-read the database size from page 1 if a savepoint or transaction\n      ** rollback occurs within the transaction.\n      */\n      if( pBt->nPage!=get4byte(&pPage1->aData[28]) ){\n        rc = sqlite3PagerWrite(pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          put4byte(&pPage1->aData[28], pBt->nPage);\n        }\n      }\n    }\n  }\n\n\ntrans_begun:\n  if( rc==SQLITE_OK && wrflag ){\n    /* This call makes sure that the pager has the correct number of\n    ** open savepoints. If the second parameter is greater than 0 and\n    ** the sub-journal is not already open, then it will be opened here.\n    */\n    rc = sqlite3PagerOpenSavepoint(pBt->pPager, p->db->nSavepoint);\n  }\n\n  btreeIntegrity(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n\n/*\n** Set the pointer-map entries for all children of page pPage. Also, if\n** pPage contains cells that point to overflow pages, set the pointer\n** map entries for the overflow pages as well.\n*/\nstatic int setChildPtrmaps(MemPage *pPage){\n  int i;                             /* Counter variable */\n  int nCell;                         /* Number of cells in page pPage */\n  int rc;                            /* Return code */\n  BtShared *pBt = pPage->pBt;\n  Pgno pgno = pPage->pgno;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n  if( rc!=SQLITE_OK ) return rc;\n  nCell = pPage->nCell;\n\n  for(i=0; i<nCell; i++){\n    u8 *pCell = findCell(pPage, i);\n\n    ptrmapPutOvflPtr(pPage, pCell, &rc);\n\n    if( !pPage->leaf ){\n      Pgno childPgno = get4byte(pCell);\n      ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n    }\n  }\n\n  if( !pPage->leaf ){\n    Pgno childPgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    ptrmapPut(pBt, childPgno, PTRMAP_BTREE, pgno, &rc);\n  }\n\n  return rc;\n}\n\n/*\n** Somewhere on pPage is a pointer to page iFrom.  Modify this pointer so\n** that it points to iTo. Parameter eType describes the type of pointer to\n** be modified, as  follows:\n**\n** PTRMAP_BTREE:     pPage is a btree-page. The pointer points at a child \n**                   page of pPage.\n**\n** PTRMAP_OVERFLOW1: pPage is a btree-page. The pointer points at an overflow\n**                   page pointed to by one of the cells on pPage.\n**\n** PTRMAP_OVERFLOW2: pPage is an overflow-page. The pointer points at the next\n**                   overflow page in the list.\n*/\nstatic int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  if( eType==PTRMAP_OVERFLOW2 ){\n    /* The pointer is always the first 4 bytes of the page in this case.  */\n    if( get4byte(pPage->aData)!=iFrom ){\n      return SQLITE_CORRUPT_PGNO(pPage->pgno);\n    }\n    put4byte(pPage->aData, iTo);\n  }else{\n    int i;\n    int nCell;\n    int rc;\n\n    rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage);\n    if( rc ) return rc;\n    nCell = pPage->nCell;\n\n    for(i=0; i<nCell; i++){\n      u8 *pCell = findCell(pPage, i);\n      if( eType==PTRMAP_OVERFLOW1 ){\n        CellInfo info;\n        pPage->xParseCell(pPage, pCell, &info);\n        if( info.nLocal<info.nPayload ){\n          if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){\n            return SQLITE_CORRUPT_PGNO(pPage->pgno);\n          }\n          if( iFrom==get4byte(pCell+info.nSize-4) ){\n            put4byte(pCell+info.nSize-4, iTo);\n            break;\n          }\n        }\n      }else{\n        if( get4byte(pCell)==iFrom ){\n          put4byte(pCell, iTo);\n          break;\n        }\n      }\n    }\n  \n    if( i==nCell ){\n      if( eType!=PTRMAP_BTREE || \n          get4byte(&pPage->aData[pPage->hdrOffset+8])!=iFrom ){\n        return SQLITE_CORRUPT_PGNO(pPage->pgno);\n      }\n      put4byte(&pPage->aData[pPage->hdrOffset+8], iTo);\n    }\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Move the open database page pDbPage to location iFreePage in the \n** database. The pDbPage reference remains valid.\n**\n** The isCommit flag indicates that there is no need to remember that\n** the journal needs to be sync()ed before database page pDbPage->pgno \n** can be written to. The caller has already promised not to write to that\n** page.\n*/\nstatic int relocatePage(\n  BtShared *pBt,           /* Btree */\n  MemPage *pDbPage,        /* Open page to move */\n  u8 eType,                /* Pointer map 'type' entry for pDbPage */\n  Pgno iPtrPage,           /* Pointer map 'page-no' entry for pDbPage */\n  Pgno iFreePage,          /* The location to move pDbPage to */\n  int isCommit             /* isCommit flag passed to sqlite3PagerMovepage */\n){\n  MemPage *pPtrPage;   /* The page that contains a pointer to pDbPage */\n  Pgno iDbPage = pDbPage->pgno;\n  Pager *pPager = pBt->pPager;\n  int rc;\n\n  assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 || \n      eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( pDbPage->pBt==pBt );\n\n  /* Move page iDbPage from its current location to page number iFreePage */\n  TRACE((\"AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\\n\", \n      iDbPage, iFreePage, iPtrPage, eType));\n  rc = sqlite3PagerMovepage(pPager, pDbPage->pDbPage, iFreePage, isCommit);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  pDbPage->pgno = iFreePage;\n\n  /* If pDbPage was a btree-page, then it may have child pages and/or cells\n  ** that point to overflow pages. The pointer map entries for all these\n  ** pages need to be changed.\n  **\n  ** If pDbPage is an overflow page, then the first 4 bytes may store a\n  ** pointer to a subsequent overflow page. If this is the case, then\n  ** the pointer map needs to be updated for the subsequent overflow page.\n  */\n  if( eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE ){\n    rc = setChildPtrmaps(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }else{\n    Pgno nextOvfl = get4byte(pDbPage->aData);\n    if( nextOvfl!=0 ){\n      ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage, &rc);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  /* Fix the database pointer on page iPtrPage that pointed at iDbPage so\n  ** that it points at iFreePage. Also fix the pointer map entry for\n  ** iPtrPage.\n  */\n  if( eType!=PTRMAP_ROOTPAGE ){\n    rc = btreeGetPage(pBt, iPtrPage, &pPtrPage, 0);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    rc = sqlite3PagerWrite(pPtrPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(pPtrPage);\n      return rc;\n    }\n    rc = modifyPagePointer(pPtrPage, iDbPage, iFreePage, eType);\n    releasePage(pPtrPage);\n    if( rc==SQLITE_OK ){\n      ptrmapPut(pBt, iFreePage, eType, iPtrPage, &rc);\n    }\n  }\n  return rc;\n}\n\n/* Forward declaration required by incrVacuumStep(). */\nstatic int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);\n\n/*\n** Perform a single step of an incremental-vacuum. If successful, return\n** SQLITE_OK. If there is no work to do (and therefore no point in \n** calling this function again), return SQLITE_DONE. Or, if an error \n** occurs, return some other error code.\n**\n** More specifically, this function attempts to re-organize the database so \n** that the last page of the file currently in use is no longer in use.\n**\n** Parameter nFin is the number of pages that this database would contain\n** were this function called until it returns SQLITE_DONE.\n**\n** If the bCommit parameter is non-zero, this function assumes that the \n** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE \n** or an error. bCommit is passed true for an auto-vacuum-on-commit \n** operation, or false for an incremental vacuum.\n*/\nstatic int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){\n  Pgno nFreeList;           /* Number of pages still on the free-list */\n  int rc;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( iLastPg>nFin );\n\n  if( !PTRMAP_ISPAGE(pBt, iLastPg) && iLastPg!=PENDING_BYTE_PAGE(pBt) ){\n    u8 eType;\n    Pgno iPtrPage;\n\n    nFreeList = get4byte(&pBt->pPage1->aData[36]);\n    if( nFreeList==0 ){\n      return SQLITE_DONE;\n    }\n\n    rc = ptrmapGet(pBt, iLastPg, &eType, &iPtrPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( eType==PTRMAP_ROOTPAGE ){\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    if( eType==PTRMAP_FREEPAGE ){\n      if( bCommit==0 ){\n        /* Remove the page from the files free-list. This is not required\n        ** if bCommit is non-zero. In that case, the free-list will be\n        ** truncated to zero after this function returns, so it doesn't \n        ** matter if it still contains some garbage entries.\n        */\n        Pgno iFreePg;\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iLastPg, BTALLOC_EXACT);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        assert( iFreePg==iLastPg );\n        releasePage(pFreePg);\n      }\n    } else {\n      Pgno iFreePg;             /* Index of free page to move pLastPg to */\n      MemPage *pLastPg;\n      u8 eMode = BTALLOC_ANY;   /* Mode parameter for allocateBtreePage() */\n      Pgno iNear = 0;           /* nearby parameter for allocateBtreePage() */\n\n      rc = btreeGetPage(pBt, iLastPg, &pLastPg, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* If bCommit is zero, this loop runs exactly once and page pLastPg\n      ** is swapped with the first free page pulled off the free list.\n      **\n      ** On the other hand, if bCommit is greater than zero, then keep\n      ** looping until a free-page located within the first nFin pages\n      ** of the file is found.\n      */\n      if( bCommit==0 ){\n        eMode = BTALLOC_LE;\n        iNear = nFin;\n      }\n      do {\n        MemPage *pFreePg;\n        rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, iNear, eMode);\n        if( rc!=SQLITE_OK ){\n          releasePage(pLastPg);\n          return rc;\n        }\n        releasePage(pFreePg);\n      }while( bCommit && iFreePg>nFin );\n      assert( iFreePg<iLastPg );\n      \n      rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg, bCommit);\n      releasePage(pLastPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  if( bCommit==0 ){\n    do {\n      iLastPg--;\n    }while( iLastPg==PENDING_BYTE_PAGE(pBt) || PTRMAP_ISPAGE(pBt, iLastPg) );\n    pBt->bDoTruncate = 1;\n    pBt->nPage = iLastPg;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The database opened by the first argument is an auto-vacuum database\n** nOrig pages in size containing nFree free pages. Return the expected \n** size of the database in pages following an auto-vacuum operation.\n*/\nstatic Pgno finalDbSize(BtShared *pBt, Pgno nOrig, Pgno nFree){\n  int nEntry;                     /* Number of entries on one ptrmap page */\n  Pgno nPtrmap;                   /* Number of PtrMap pages to be freed */\n  Pgno nFin;                      /* Return value */\n\n  nEntry = pBt->usableSize/5;\n  nPtrmap = (nFree-nOrig+PTRMAP_PAGENO(pBt, nOrig)+nEntry)/nEntry;\n  nFin = nOrig - nFree - nPtrmap;\n  if( nOrig>PENDING_BYTE_PAGE(pBt) && nFin<PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n  while( PTRMAP_ISPAGE(pBt, nFin) || nFin==PENDING_BYTE_PAGE(pBt) ){\n    nFin--;\n  }\n\n  return nFin;\n}\n\n/*\n** A write-transaction must be opened before calling this function.\n** It performs a single unit of work towards an incremental vacuum.\n**\n** If the incremental vacuum is finished after this function has run,\n** SQLITE_DONE is returned. If it is not finished, but no error occurred,\n** SQLITE_OK is returned. Otherwise an SQLite error code. \n*/\nint sqlite3BtreeIncrVacuum(Btree *p){\n  int rc;\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( pBt->inTransaction==TRANS_WRITE && p->inTrans==TRANS_WRITE );\n  if( !pBt->autoVacuum ){\n    rc = SQLITE_DONE;\n  }else{\n    Pgno nOrig = btreePagecount(pBt);\n    Pgno nFree = get4byte(&pBt->pPage1->aData[36]);\n    Pgno nFin = finalDbSize(pBt, nOrig, nFree);\n\n    if( nOrig<nFin ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else if( nFree>0 ){\n      rc = saveAllCursors(pBt, 0, 0);\n      if( rc==SQLITE_OK ){\n        invalidateAllOverflowCache(pBt);\n        rc = incrVacuumStep(pBt, nFin, nOrig, 0);\n      }\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        put4byte(&pBt->pPage1->aData[28], pBt->nPage);\n      }\n    }else{\n      rc = SQLITE_DONE;\n    }\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine is called prior to sqlite3PagerCommit when a transaction\n** is committed for an auto-vacuum database.\n**\n** If SQLITE_OK is returned, then *pnTrunc is set to the number of pages\n** the database file should be truncated to during the commit process. \n** i.e. the database has been reorganized so that only the first *pnTrunc\n** pages are in use.\n*/\nstatic int autoVacuumCommit(BtShared *pBt){\n  int rc = SQLITE_OK;\n  Pager *pPager = pBt->pPager;\n  VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  invalidateAllOverflowCache(pBt);\n  assert(pBt->autoVacuum);\n  if( !pBt->incrVacuum ){\n    Pgno nFin;         /* Number of pages in database after autovacuuming */\n    Pgno nFree;        /* Number of pages on the freelist initially */\n    Pgno iFree;        /* The next page to be freed */\n    Pgno nOrig;        /* Database size before freeing */\n\n    nOrig = btreePagecount(pBt);\n    if( PTRMAP_ISPAGE(pBt, nOrig) || nOrig==PENDING_BYTE_PAGE(pBt) ){\n      /* It is not possible to create a database for which the final page\n      ** is either a pointer-map page or the pending-byte page. If one\n      ** is encountered, this indicates corruption.\n      */\n      return SQLITE_CORRUPT_BKPT;\n    }\n\n    nFree = get4byte(&pBt->pPage1->aData[36]);\n    nFin = finalDbSize(pBt, nOrig, nFree);\n    if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT;\n    if( nFin<nOrig ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){\n      rc = incrVacuumStep(pBt, nFin, iFree, 1);\n    }\n    if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){\n      rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n      put4byte(&pBt->pPage1->aData[32], 0);\n      put4byte(&pBt->pPage1->aData[36], 0);\n      put4byte(&pBt->pPage1->aData[28], nFin);\n      pBt->bDoTruncate = 1;\n      pBt->nPage = nFin;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3PagerRollback(pPager);\n    }\n  }\n\n  assert( nRef>=sqlite3PagerRefcount(pPager) );\n  return rc;\n}\n\n#else /* ifndef SQLITE_OMIT_AUTOVACUUM */\n# define setChildPtrmaps(x) SQLITE_OK\n#endif\n\n/*\n** This routine does the first phase of a two-phase commit.  This routine\n** causes a rollback journal to be created (if it does not already exist)\n** and populated with enough information so that if a power loss occurs\n** the database can be restored to its original state by playing back\n** the journal.  Then the contents of the journal are flushed out to\n** the disk.  After the journal is safely on oxide, the changes to the\n** database are written into the database file and flushed to oxide.\n** At the end of this call, the rollback journal still exists on the\n** disk and we are still holding all locks, so the transaction has not\n** committed.  See sqlite3BtreeCommitPhaseTwo() for the second phase of the\n** commit process.\n**\n** This call is a no-op if no write-transaction is currently active on pBt.\n**\n** Otherwise, sync the database file for the btree pBt. zMaster points to\n** the name of a master journal file that should be written into the\n** individual journal file, or is NULL, indicating no master journal file \n** (single database transaction).\n**\n** When this is called, the master journal should already have been\n** created, populated with this journal pointer and synced to disk.\n**\n** Once this is routine has returned, the only thing required to commit\n** the write-transaction for this database file is to delete the journal.\n*/\nint sqlite3BtreeCommitPhaseOne(Btree *p, const char *zMaster){\n  int rc = SQLITE_OK;\n  if( p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      rc = autoVacuumCommit(pBt);\n      if( rc!=SQLITE_OK ){\n        sqlite3BtreeLeave(p);\n        return rc;\n      }\n    }\n    if( pBt->bDoTruncate ){\n      sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage);\n    }\n#endif\n    rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zMaster, 0);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** This function is called from both BtreeCommitPhaseTwo() and BtreeRollback()\n** at the conclusion of a transaction.\n*/\nstatic void btreeEndTransaction(Btree *p){\n  BtShared *pBt = p->pBt;\n  sqlite3 *db = p->db;\n  assert( sqlite3BtreeHoldsMutex(p) );\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  pBt->bDoTruncate = 0;\n#endif\n  if( p->inTrans>TRANS_NONE && db->nVdbeRead>1 ){\n    /* If there are other active statements that belong to this database\n    ** handle, downgrade to a read-only transaction. The other statements\n    ** may still be reading from the database.  */\n    downgradeAllSharedCacheTableLocks(p);\n    p->inTrans = TRANS_READ;\n  }else{\n    /* If the handle had any kind of transaction open, decrement the \n    ** transaction count of the shared btree. If the transaction count \n    ** reaches 0, set the shared state to TRANS_NONE. The unlockBtreeIfUnused()\n    ** call below will unlock the pager.  */\n    if( p->inTrans!=TRANS_NONE ){\n      clearAllSharedCacheTableLocks(p);\n      pBt->nTransaction--;\n      if( 0==pBt->nTransaction ){\n        pBt->inTransaction = TRANS_NONE;\n      }\n    }\n\n    /* Set the current transaction state to TRANS_NONE and unlock the \n    ** pager if this call closed the only read or write transaction.  */\n    p->inTrans = TRANS_NONE;\n    unlockBtreeIfUnused(pBt);\n  }\n\n  btreeIntegrity(p);\n}\n\n/*\n** Commit the transaction currently in progress.\n**\n** This routine implements the second phase of a 2-phase commit.  The\n** sqlite3BtreeCommitPhaseOne() routine does the first phase and should\n** be invoked prior to calling this routine.  The sqlite3BtreeCommitPhaseOne()\n** routine did all the work of writing information out to disk and flushing the\n** contents so that they are written onto the disk platter.  All this\n** routine has to do is delete or truncate or zero the header in the\n** the rollback journal (which causes the transaction to commit) and\n** drop locks.\n**\n** Normally, if an error occurs while the pager layer is attempting to \n** finalize the underlying journal file, this function returns an error and\n** the upper layer will attempt a rollback. However, if the second argument\n** is non-zero then this b-tree transaction is part of a multi-file \n** transaction. In this case, the transaction has already been committed \n** (by deleting a master journal file) and the caller will ignore this \n** functions return code. So, even if an error occurs in the pager layer,\n** reset the b-tree objects internal state to indicate that the write\n** transaction has been closed. This is quite safe, as the pager will have\n** transitioned to the error state.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nint sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){\n\n  if( p->inTrans==TRANS_NONE ) return SQLITE_OK;\n  sqlite3BtreeEnter(p);\n  btreeIntegrity(p);\n\n  /* If the handle has a write-transaction open, commit the shared-btrees \n  ** transaction and set the shared state to TRANS_READ.\n  */\n  if( p->inTrans==TRANS_WRITE ){\n    int rc;\n    BtShared *pBt = p->pBt;\n    assert( pBt->inTransaction==TRANS_WRITE );\n    assert( pBt->nTransaction>0 );\n    rc = sqlite3PagerCommitPhaseTwo(pBt->pPager);\n    if( rc!=SQLITE_OK && bCleanup==0 ){\n      sqlite3BtreeLeave(p);\n      return rc;\n    }\n    p->iDataVersion--;  /* Compensate for pPager->iDataVersion++; */\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return SQLITE_OK;\n}\n\n/*\n** Do both phases of a commit.\n*/\nint sqlite3BtreeCommit(Btree *p){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = sqlite3BtreeCommitPhaseOne(p, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeCommitPhaseTwo(p, 0);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** This routine sets the state to CURSOR_FAULT and the error\n** code to errCode for every cursor on any BtShared that pBtree\n** references.  Or if the writeOnly flag is set to 1, then only\n** trip write cursors and leave read cursors unchanged.\n**\n** Every cursor is a candidate to be tripped, including cursors\n** that belong to other database connections that happen to be\n** sharing the cache with pBtree.\n**\n** This routine gets called when a rollback occurs. If the writeOnly\n** flag is true, then only write-cursors need be tripped - read-only\n** cursors save their current positions so that they may continue \n** following the rollback. Or, if writeOnly is false, all cursors are \n** tripped. In general, writeOnly is false if the transaction being\n** rolled back modified the database schema. In this case b-tree root\n** pages may be moved or deleted from the database altogether, making\n** it unsafe for read cursors to continue.\n**\n** If the writeOnly flag is true and an error is encountered while \n** saving the current position of a read-only cursor, all cursors, \n** including all read-cursors are tripped.\n**\n** SQLITE_OK is returned if successful, or if an error occurs while\n** saving a cursor position, an SQLite error code.\n*/\nint sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int writeOnly){\n  BtCursor *p;\n  int rc = SQLITE_OK;\n\n  assert( (writeOnly==0 || writeOnly==1) && BTCF_WriteFlag==1 );\n  if( pBtree ){\n    sqlite3BtreeEnter(pBtree);\n    for(p=pBtree->pBt->pCursor; p; p=p->pNext){\n      if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){\n        if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){\n          rc = saveCursorPosition(p);\n          if( rc!=SQLITE_OK ){\n            (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);\n            break;\n          }\n        }\n      }else{\n        sqlite3BtreeClearCursor(p);\n        p->eState = CURSOR_FAULT;\n        p->skipNext = errCode;\n      }\n      btreeReleaseAllCursorPages(p);\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  return rc;\n}\n\n/*\n** Rollback the transaction in progress.\n**\n** If tripCode is not SQLITE_OK then cursors will be invalidated (tripped).\n** Only write cursors are tripped if writeOnly is true but all cursors are\n** tripped if writeOnly is false.  Any attempt to use\n** a tripped cursor will result in an error.\n**\n** This will release the write lock on the database file.  If there\n** are no active cursors, it also releases the read lock.\n*/\nint sqlite3BtreeRollback(Btree *p, int tripCode, int writeOnly){\n  int rc;\n  BtShared *pBt = p->pBt;\n  MemPage *pPage1;\n\n  assert( writeOnly==1 || writeOnly==0 );\n  assert( tripCode==SQLITE_ABORT_ROLLBACK || tripCode==SQLITE_OK );\n  sqlite3BtreeEnter(p);\n  if( tripCode==SQLITE_OK ){\n    rc = tripCode = saveAllCursors(pBt, 0, 0);\n    if( rc ) writeOnly = 0;\n  }else{\n    rc = SQLITE_OK;\n  }\n  if( tripCode ){\n    int rc2 = sqlite3BtreeTripAllCursors(p, tripCode, writeOnly);\n    assert( rc==SQLITE_OK || (writeOnly==0 && rc2==SQLITE_OK) );\n    if( rc2!=SQLITE_OK ) rc = rc2;\n  }\n  btreeIntegrity(p);\n\n  if( p->inTrans==TRANS_WRITE ){\n    int rc2;\n\n    assert( TRANS_WRITE==pBt->inTransaction );\n    rc2 = sqlite3PagerRollback(pBt->pPager);\n    if( rc2!=SQLITE_OK ){\n      rc = rc2;\n    }\n\n    /* The rollback may have destroyed the pPage1->aData value.  So\n    ** call btreeGetPage() on page 1 again to make\n    ** sure pPage1->aData is set correctly. */\n    if( btreeGetPage(pBt, 1, &pPage1, 0)==SQLITE_OK ){\n      int nPage = get4byte(28+(u8*)pPage1->aData);\n      testcase( nPage==0 );\n      if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);\n      testcase( pBt->nPage!=nPage );\n      pBt->nPage = nPage;\n      releasePageOne(pPage1);\n    }\n    assert( countValidCursors(pBt, 1)==0 );\n    pBt->inTransaction = TRANS_READ;\n    btreeClearHasContent(pBt);\n  }\n\n  btreeEndTransaction(p);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Start a statement subtransaction. The subtransaction can be rolled\n** back independently of the main transaction. You must start a transaction \n** before starting a subtransaction. The subtransaction is ended automatically \n** if the main transaction commits or rolls back.\n**\n** Statement subtransactions are used around individual SQL statements\n** that are contained within a BEGIN...COMMIT block.  If a constraint\n** error occurs within the statement, the effect of that one statement\n** can be rolled back without having to rollback the entire transaction.\n**\n** A statement sub-transaction is implemented as an anonymous savepoint. The\n** value passed as the second parameter is the total number of savepoints,\n** including the new anonymous savepoint, open on the B-Tree. i.e. if there\n** are no active savepoints and no other statement-transactions open,\n** iStatement is 1. This anonymous savepoint can be released or rolled back\n** using the sqlite3BtreeSavepoint() function.\n*/\nint sqlite3BtreeBeginStmt(Btree *p, int iStatement){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( iStatement>0 );\n  assert( iStatement>p->db->nSavepoint );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  /* At the pager level, a statement transaction is a savepoint with\n  ** an index greater than all savepoints created explicitly using\n  ** SQL statements. It is illegal to open, release or rollback any\n  ** such savepoints while the statement transaction savepoint is active.\n  */\n  rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** The second argument to this function, op, is always SAVEPOINT_ROLLBACK\n** or SAVEPOINT_RELEASE. This function either releases or rolls back the\n** savepoint identified by parameter iSavepoint, depending on the value \n** of op.\n**\n** Normally, iSavepoint is greater than or equal to zero. However, if op is\n** SAVEPOINT_ROLLBACK, then iSavepoint may also be -1. In this case the \n** contents of the entire transaction are rolled back. This is different\n** from a normal transaction rollback, as no locks are released and the\n** transaction remains open.\n*/\nint sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n  if( p && p->inTrans==TRANS_WRITE ){\n    BtShared *pBt = p->pBt;\n    assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n    assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );\n    sqlite3BtreeEnter(p);\n    if( op==SAVEPOINT_ROLLBACK ){\n      rc = saveAllCursors(pBt, 0, 0);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){\n        pBt->nPage = 0;\n      }\n      rc = newDatabase(pBt);\n      pBt->nPage = get4byte(28 + pBt->pPage1->aData);\n\n      /* The database size was written into the offset 28 of the header\n      ** when the transaction started, so we know that the value at offset\n      ** 28 is nonzero. */\n      assert( pBt->nPage>0 );\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Create a new cursor for the BTree whose root is on the page\n** iTable. If a read-only cursor is requested, it is assumed that\n** the caller already has at least a read-only transaction open\n** on the database already. If a write-cursor is requested, then\n** the caller is assumed to have an open write transaction.\n**\n** If the BTREE_WRCSR bit of wrFlag is clear, then the cursor can only\n** be used for reading.  If the BTREE_WRCSR bit is set, then the cursor\n** can be used for reading or for writing if other conditions for writing\n** are also met.  These are the conditions that must be met in order\n** for writing to be allowed:\n**\n** 1:  The cursor must have been opened with wrFlag containing BTREE_WRCSR\n**\n** 2:  Other database connections that share the same pager cache\n**     but which are not in the READ_UNCOMMITTED state may not have\n**     cursors open with wrFlag==0 on the same table.  Otherwise\n**     the changes made by this write cursor would be visible to\n**     the read cursors in the other database connection.\n**\n** 3:  The database must be writable (not on read-only media)\n**\n** 4:  There must be an active transaction.\n**\n** The BTREE_FORDELETE bit of wrFlag may optionally be set if BTREE_WRCSR\n** is set.  If FORDELETE is set, that is a hint to the implementation that\n** this cursor will only be used to seek to and delete entries of an index\n** as part of a larger DELETE statement.  The FORDELETE hint is not used by\n** this implementation.  But in a hypothetical alternative storage engine \n** in which index entries are automatically deleted when corresponding table\n** rows are deleted, the FORDELETE flag is a hint that all SEEK and DELETE\n** operations on this cursor can be no-ops and all READ operations can \n** return a null row (2-bytes: 0x01 0x00).\n**\n** No checking is done to make sure that page iTable really is the\n** root page of a b-tree.  If it is not, then the cursor acquired\n** will not work correctly.\n**\n** It is assumed that the sqlite3BtreeCursorZero() has been called\n** on pCur to initialize the memory space prior to invoking this routine.\n*/\nstatic int btreeCursor(\n  Btree *p,                              /* The btree */\n  int iTable,                            /* Root page of table to open */\n  int wrFlag,                            /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,              /* First arg to comparison function */\n  BtCursor *pCur                         /* Space for new cursor */\n){\n  BtShared *pBt = p->pBt;                /* Shared b-tree handle */\n  BtCursor *pX;                          /* Looping over other all cursors */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( wrFlag==0 \n       || wrFlag==BTREE_WRCSR \n       || wrFlag==(BTREE_WRCSR|BTREE_FORDELETE) \n  );\n\n  /* The following assert statements verify that if this is a sharable \n  ** b-tree database, the connection is holding the required table locks, \n  ** and that no other connection has any open cursor that conflicts with \n  ** this lock.  */\n  assert( hasSharedCacheTableLock(p, iTable, pKeyInfo!=0, (wrFlag?2:1)) );\n  assert( wrFlag==0 || !hasReadConflicts(p, iTable) );\n\n  /* Assert that the caller has opened the required transaction. */\n  assert( p->inTrans>TRANS_NONE );\n  assert( wrFlag==0 || p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1 && pBt->pPage1->aData );\n  assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n  if( wrFlag ){\n    allocateTempSpace(pBt);\n    if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  if( iTable==1 && btreePagecount(pBt)==0 ){\n    assert( wrFlag==0 );\n    iTable = 0;\n  }\n\n  /* Now that no other errors can occur, finish filling in the BtCursor\n  ** variables and link the cursor into the BtShared list.  */\n  pCur->pgnoRoot = (Pgno)iTable;\n  pCur->iPage = -1;\n  pCur->pKeyInfo = pKeyInfo;\n  pCur->pBtree = p;\n  pCur->pBt = pBt;\n  pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;\n  pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;\n  /* If there are two or more cursors on the same btree, then all such\n  ** cursors *must* have the BTCF_Multiple flag set. */\n  for(pX=pBt->pCursor; pX; pX=pX->pNext){\n    if( pX->pgnoRoot==(Pgno)iTable ){\n      pX->curFlags |= BTCF_Multiple;\n      pCur->curFlags |= BTCF_Multiple;\n    }\n  }\n  pCur->pNext = pBt->pCursor;\n  pBt->pCursor = pCur;\n  pCur->eState = CURSOR_INVALID;\n  return SQLITE_OK;\n}\nint sqlite3BtreeCursor(\n  Btree *p,                                   /* The btree */\n  int iTable,                                 /* Root page of table to open */\n  int wrFlag,                                 /* 1 to write. 0 read-only */\n  struct KeyInfo *pKeyInfo,                   /* First arg to xCompare() */\n  BtCursor *pCur                              /* Write new cursor here */\n){\n  int rc;\n  if( iTable<1 ){\n    rc = SQLITE_CORRUPT_BKPT;\n  }else{\n    sqlite3BtreeEnter(p);\n    rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur);\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n\n/*\n** Return the size of a BtCursor object in bytes.\n**\n** This interfaces is needed so that users of cursors can preallocate\n** sufficient storage to hold a cursor.  The BtCursor object is opaque\n** to users so they cannot do the sizeof() themselves - they must call\n** this routine.\n*/\nint sqlite3BtreeCursorSize(void){\n  return ROUND8(sizeof(BtCursor));\n}\n\n/*\n** Initialize memory that will be converted into a BtCursor object.\n**\n** The simple approach here would be to memset() the entire object\n** to zero.  But it turns out that the apPage[] and aiIdx[] arrays\n** do not need to be zeroed and they are large, so we can save a lot\n** of run-time by skipping the initialization of those elements.\n*/\nvoid sqlite3BtreeCursorZero(BtCursor *p){\n  memset(p, 0, offsetof(BtCursor, iPage));\n}\n\n/*\n** Close a cursor.  The read lock on the database file is released\n** when the last cursor is closed.\n*/\nint sqlite3BtreeCloseCursor(BtCursor *pCur){\n  Btree *pBtree = pCur->pBtree;\n  if( pBtree ){\n    BtShared *pBt = pCur->pBt;\n    sqlite3BtreeEnter(pBtree);\n    assert( pBt->pCursor!=0 );\n    if( pBt->pCursor==pCur ){\n      pBt->pCursor = pCur->pNext;\n    }else{\n      BtCursor *pPrev = pBt->pCursor;\n      do{\n        if( pPrev->pNext==pCur ){\n          pPrev->pNext = pCur->pNext;\n          break;\n        }\n        pPrev = pPrev->pNext;\n      }while( ALWAYS(pPrev) );\n    }\n    btreeReleaseAllCursorPages(pCur);\n    unlockBtreeIfUnused(pBt);\n    sqlite3_free(pCur->aOverflow);\n    sqlite3_free(pCur->pKey);\n    sqlite3BtreeLeave(pBtree);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the BtCursor* given in the argument has a valid\n** BtCursor.info structure.  If it is not already valid, call\n** btreeParseCell() to fill it in.\n**\n** BtCursor.info is a cache of the information in the current cell.\n** Using this cache reduces the number of calls to btreeParseCell().\n*/\n#ifndef NDEBUG\n  static void assertCellInfo(BtCursor *pCur){\n    CellInfo info;\n    memset(&info, 0, sizeof(info));\n    btreeParseCell(pCur->pPage, pCur->ix, &info);\n    assert( CORRUPT_DB || memcmp(&info, &pCur->info, sizeof(info))==0 );\n  }\n#else\n  #define assertCellInfo(x)\n#endif\nstatic SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){\n  if( pCur->info.nSize==0 ){\n    pCur->curFlags |= BTCF_ValidNKey;\n    btreeParseCell(pCur->pPage,pCur->ix,&pCur->info);\n  }else{\n    assertCellInfo(pCur);\n  }\n}\n\n#ifndef NDEBUG  /* The next routine used only within assert() statements */\n/*\n** Return true if the given BtCursor is valid.  A valid cursor is one\n** that is currently pointing to a row in a (non-empty) table.\n** This is a verification routine is used only within assert() statements.\n*/\nint sqlite3BtreeCursorIsValid(BtCursor *pCur){\n  return pCur && pCur->eState==CURSOR_VALID;\n}\n#endif /* NDEBUG */\nint sqlite3BtreeCursorIsValidNN(BtCursor *pCur){\n  assert( pCur!=0 );\n  return pCur->eState==CURSOR_VALID;\n}\n\n/*\n** Return the value of the integer key or \"rowid\" for a table btree.\n** This routine is only valid for a cursor that is pointing into a\n** ordinary table btree.  If the cursor points to an index btree or\n** is invalid, the result of this routine is undefined.\n*/\ni64 sqlite3BtreeIntegerKey(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->curIntKey );\n  getCellInfo(pCur);\n  return pCur->info.nKey;\n}\n\n/*\n** Return the number of bytes of payload for the entry that pCur is\n** currently pointing to.  For table btrees, this will be the amount\n** of data.  For index btrees, this will be the size of the key.\n**\n** The caller must guarantee that the cursor is pointing to a non-NULL\n** valid entry.  In other words, the calling procedure must guarantee\n** that the cursor has Cursor.eState==CURSOR_VALID.\n*/\nu32 sqlite3BtreePayloadSize(BtCursor *pCur){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  getCellInfo(pCur);\n  return pCur->info.nPayload;\n}\n\n/*\n** Given the page number of an overflow page in the database (parameter\n** ovfl), this function finds the page number of the next page in the \n** linked list of overflow pages. If possible, it uses the auto-vacuum\n** pointer-map data instead of reading the content of page ovfl to do so. \n**\n** If an error occurs an SQLite error code is returned. Otherwise:\n**\n** The page number of the next overflow page in the linked list is \n** written to *pPgnoNext. If page ovfl is the last page in its linked \n** list, *pPgnoNext is set to zero. \n**\n** If ppPage is not NULL, and a reference to the MemPage object corresponding\n** to page number pOvfl was obtained, then *ppPage is set to point to that\n** reference. It is the responsibility of the caller to call releasePage()\n** on *ppPage to free the reference. In no reference was obtained (because\n** the pointer-map was used to obtain the value for *pPgnoNext), then\n** *ppPage is set to zero.\n*/\nstatic int getOverflowPage(\n  BtShared *pBt,               /* The database file */\n  Pgno ovfl,                   /* Current overflow page number */\n  MemPage **ppPage,            /* OUT: MemPage handle (may be NULL) */\n  Pgno *pPgnoNext              /* OUT: Next overflow page number */\n){\n  Pgno next = 0;\n  MemPage *pPage = 0;\n  int rc = SQLITE_OK;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert(pPgnoNext);\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* Try to find the next page in the overflow list using the\n  ** autovacuum pointer-map pages. Guess that the next page in \n  ** the overflow list is page number (ovfl+1). If that guess turns \n  ** out to be wrong, fall back to loading the data of page \n  ** number ovfl to determine the next page number.\n  */\n  if( pBt->autoVacuum ){\n    Pgno pgno;\n    Pgno iGuess = ovfl+1;\n    u8 eType;\n\n    while( PTRMAP_ISPAGE(pBt, iGuess) || iGuess==PENDING_BYTE_PAGE(pBt) ){\n      iGuess++;\n    }\n\n    if( iGuess<=btreePagecount(pBt) ){\n      rc = ptrmapGet(pBt, iGuess, &eType, &pgno);\n      if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){\n        next = iGuess;\n        rc = SQLITE_DONE;\n      }\n    }\n  }\n#endif\n\n  assert( next==0 || rc==SQLITE_DONE );\n  if( rc==SQLITE_OK ){\n    rc = btreeGetPage(pBt, ovfl, &pPage, (ppPage==0) ? PAGER_GET_READONLY : 0);\n    assert( rc==SQLITE_OK || pPage==0 );\n    if( rc==SQLITE_OK ){\n      next = get4byte(pPage->aData);\n    }\n  }\n\n  *pPgnoNext = next;\n  if( ppPage ){\n    *ppPage = pPage;\n  }else{\n    releasePage(pPage);\n  }\n  return (rc==SQLITE_DONE ? SQLITE_OK : rc);\n}\n\n/*\n** Copy data from a buffer to a page, or from a page to a buffer.\n**\n** pPayload is a pointer to data stored on database page pDbPage.\n** If argument eOp is false, then nByte bytes of data are copied\n** from pPayload to the buffer pointed at by pBuf. If eOp is true,\n** then sqlite3PagerWrite() is called on pDbPage and nByte bytes\n** of data are copied from the buffer pBuf to pPayload.\n**\n** SQLITE_OK is returned on success, otherwise an error code.\n*/\nstatic int copyPayload(\n  void *pPayload,           /* Pointer to page data */\n  void *pBuf,               /* Pointer to buffer */\n  int nByte,                /* Number of bytes to copy */\n  int eOp,                  /* 0 -> copy from page, 1 -> copy to page */\n  DbPage *pDbPage           /* Page containing pPayload */\n){\n  if( eOp ){\n    /* Copy data from buffer to page (a write operation) */\n    int rc = sqlite3PagerWrite(pDbPage);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    memcpy(pPayload, pBuf, nByte);\n  }else{\n    /* Copy data from page to buffer (a read operation) */\n    memcpy(pBuf, pPayload, nByte);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This function is used to read or overwrite payload information\n** for the entry that the pCur cursor is pointing to. The eOp\n** argument is interpreted as follows:\n**\n**   0: The operation is a read. Populate the overflow cache.\n**   1: The operation is a write. Populate the overflow cache.\n**\n** A total of \"amt\" bytes are read or written beginning at \"offset\".\n** Data is read to or from the buffer pBuf.\n**\n** The content being read or written might appear on the main page\n** or be scattered out on multiple overflow pages.\n**\n** If the current cursor entry uses one or more overflow pages\n** this function may allocate space for and lazily populate\n** the overflow page-list cache array (BtCursor.aOverflow). \n** Subsequent calls use this cache to make seeking to the supplied offset \n** more efficient.\n**\n** Once an overflow page-list cache has been allocated, it must be\n** invalidated if some other cursor writes to the same table, or if\n** the cursor is moved to a different row. Additionally, in auto-vacuum\n** mode, the following events may invalidate an overflow page-list cache.\n**\n**   * An incremental vacuum,\n**   * A commit in auto_vacuum=\"full\" mode,\n**   * Creating a table (may require moving an overflow page).\n*/\nstatic int accessPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 offset,          /* Begin reading this far into payload */\n  u32 amt,             /* Read this many bytes */\n  unsigned char *pBuf, /* Write the bytes into this buffer */ \n  int eOp              /* zero to read. non-zero to write. */\n){\n  unsigned char *aPayload;\n  int rc = SQLITE_OK;\n  int iIdx = 0;\n  MemPage *pPage = pCur->pPage;               /* Btree page of current entry */\n  BtShared *pBt = pCur->pBt;                  /* Btree this cursor belongs to */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n  unsigned char * const pBufStart = pBuf;     /* Start of original out buffer */\n#endif\n\n  assert( pPage );\n  assert( eOp==0 || eOp==1 );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->ix<pPage->nCell );\n  assert( cursorHoldsMutex(pCur) );\n\n  getCellInfo(pCur);\n  aPayload = pCur->info.pPayload;\n  assert( offset+amt <= pCur->info.nPayload );\n\n  assert( aPayload > pPage->aData );\n  if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){\n    /* Trying to read or write past the end of the data is an error.  The\n    ** conditional above is really:\n    **    &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]\n    ** but is recast into its current form to avoid integer overflow problems\n    */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n\n  /* Check if data must be read/written to/from the btree page itself. */\n  if( offset<pCur->info.nLocal ){\n    int a = amt;\n    if( a+offset>pCur->info.nLocal ){\n      a = pCur->info.nLocal - offset;\n    }\n    rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);\n    offset = 0;\n    pBuf += a;\n    amt -= a;\n  }else{\n    offset -= pCur->info.nLocal;\n  }\n\n\n  if( rc==SQLITE_OK && amt>0 ){\n    const u32 ovflSize = pBt->usableSize - 4;  /* Bytes content per ovfl page */\n    Pgno nextPage;\n\n    nextPage = get4byte(&aPayload[pCur->info.nLocal]);\n\n    /* If the BtCursor.aOverflow[] has not been allocated, allocate it now.\n    **\n    ** The aOverflow[] array is sized at one entry for each overflow page\n    ** in the overflow chain. The page number of the first overflow page is\n    ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array\n    ** means \"not yet known\" (the cache is lazily populated).\n    */\n    if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){\n      int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;\n      if( nOvfl>pCur->nOvflAlloc ){\n        Pgno *aNew = (Pgno*)sqlite3Realloc(\n            pCur->aOverflow, nOvfl*2*sizeof(Pgno)\n        );\n        if( aNew==0 ){\n          return SQLITE_NOMEM_BKPT;\n        }else{\n          pCur->nOvflAlloc = nOvfl*2;\n          pCur->aOverflow = aNew;\n        }\n      }\n      memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));\n      pCur->curFlags |= BTCF_ValidOvfl;\n    }else{\n      /* If the overflow page-list cache has been allocated and the\n      ** entry for the first required overflow page is valid, skip\n      ** directly to it.\n      */\n      if( pCur->aOverflow[offset/ovflSize] ){\n        iIdx = (offset/ovflSize);\n        nextPage = pCur->aOverflow[iIdx];\n        offset = (offset%ovflSize);\n      }\n    }\n\n    assert( rc==SQLITE_OK && amt>0 );\n    while( nextPage ){\n      /* If required, populate the overflow page-list cache. */\n      assert( pCur->aOverflow[iIdx]==0\n              || pCur->aOverflow[iIdx]==nextPage\n              || CORRUPT_DB );\n      pCur->aOverflow[iIdx] = nextPage;\n\n      if( offset>=ovflSize ){\n        /* The only reason to read this page is to obtain the page\n        ** number for the next page in the overflow chain. The page\n        ** data is not required. So first try to lookup the overflow\n        ** page-list cache, if any, then fall back to the getOverflowPage()\n        ** function.\n        */\n        assert( pCur->curFlags & BTCF_ValidOvfl );\n        assert( pCur->pBtree->db==pBt->db );\n        if( pCur->aOverflow[iIdx+1] ){\n          nextPage = pCur->aOverflow[iIdx+1];\n        }else{\n          rc = getOverflowPage(pBt, nextPage, 0, &nextPage);\n        }\n        offset -= ovflSize;\n      }else{\n        /* Need to read this page properly. It contains some of the\n        ** range of data that is being read (eOp==0) or written (eOp!=0).\n        */\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        sqlite3_file *fd;      /* File from which to do direct overflow read */\n#endif\n        int a = amt;\n        if( a + offset > ovflSize ){\n          a = ovflSize - offset;\n        }\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n        /* If all the following are true:\n        **\n        **   1) this is a read operation, and \n        **   2) data is required from the start of this overflow page, and\n        **   3) there is no open write-transaction, and\n        **   4) the database is file-backed, and\n        **   5) the page is not in the WAL file\n        **   6) at least 4 bytes have already been read into the output buffer \n        **\n        ** then data can be read directly from the database file into the\n        ** output buffer, bypassing the page-cache altogether. This speeds\n        ** up loading large records that span many overflow pages.\n        */\n        if( eOp==0                                             /* (1) */\n         && offset==0                                          /* (2) */\n         && pBt->inTransaction==TRANS_READ                     /* (3) */\n         && (fd = sqlite3PagerFile(pBt->pPager))->pMethods     /* (4) */\n         && 0==sqlite3PagerUseWal(pBt->pPager, nextPage)       /* (5) */\n         && &pBuf[-4]>=pBufStart                               /* (6) */\n        ){\n          u8 aSave[4];\n          u8 *aWrite = &pBuf[-4];\n          assert( aWrite>=pBufStart );                         /* due to (6) */\n          memcpy(aSave, aWrite, 4);\n          rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));\n          nextPage = get4byte(aWrite);\n          memcpy(aWrite, aSave, 4);\n        }else\n#endif\n\n        {\n          DbPage *pDbPage;\n          rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage,\n              (eOp==0 ? PAGER_GET_READONLY : 0)\n          );\n          if( rc==SQLITE_OK ){\n            aPayload = sqlite3PagerGetData(pDbPage);\n            nextPage = get4byte(aPayload);\n            rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);\n            sqlite3PagerUnref(pDbPage);\n            offset = 0;\n          }\n        }\n        amt -= a;\n        if( amt==0 ) return rc;\n        pBuf += a;\n      }\n      if( rc ) break;\n      iIdx++;\n    }\n  }\n\n  if( rc==SQLITE_OK && amt>0 ){\n    /* Overflow chain ends prematurely */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  return rc;\n}\n\n/*\n** Read part of the payload for the row at which that cursor pCur is currently\n** pointing.  \"amt\" bytes will be transferred into pBuf[].  The transfer\n** begins at \"offset\".\n**\n** pCur can be pointing to either a table or an index b-tree.\n** If pointing to a table btree, then the content section is read.  If\n** pCur is pointing to an index b-tree then the key section is read.\n**\n** For sqlite3BtreePayload(), the caller must ensure that pCur is pointing\n** to a valid row in the table.  For sqlite3BtreePayloadChecked(), the\n** cursor might be invalid or might need to be restored before being read.\n**\n** Return SQLITE_OK on success or an error code if anything goes\n** wrong.  An error is returned if \"offset+amt\" is larger than\n** the available payload.\n*/\nint sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  assert( cursorHoldsMutex(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>=0 && pCur->pPage );\n  assert( pCur->ix<pCur->pPage->nCell );\n  return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);\n}\n\n/*\n** This variant of sqlite3BtreePayload() works even if the cursor has not\n** in the CURSOR_VALID state.  It is only used by the sqlite3_blob_read()\n** interface.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nstatic SQLITE_NOINLINE int accessPayloadChecked(\n  BtCursor *pCur,\n  u32 offset,\n  u32 amt,\n  void *pBuf\n){\n  int rc;\n  if ( pCur->eState==CURSOR_INVALID ){\n    return SQLITE_ABORT;\n  }\n  assert( cursorOwnsBtShared(pCur) );\n  rc = btreeRestoreCursorPosition(pCur);\n  return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);\n}\nint sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){\n  if( pCur->eState==CURSOR_VALID ){\n    assert( cursorOwnsBtShared(pCur) );\n    return accessPayload(pCur, offset, amt, pBuf, 0);\n  }else{\n    return accessPayloadChecked(pCur, offset, amt, pBuf);\n  }\n}\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Return a pointer to payload information from the entry that the \n** pCur cursor is pointing to.  The pointer is to the beginning of\n** the key if index btrees (pPage->intKey==0) and is the data for\n** table btrees (pPage->intKey==1). The number of bytes of available\n** key/data is written into *pAmt.  If *pAmt==0, then the value\n** returned will not be a valid pointer.\n**\n** This routine is an optimization.  It is common for the entire key\n** and data to fit on the local page and for there to be no overflow\n** pages.  When that is so, this routine can be used to access the\n** key and data without making a copy.  If the key and/or data spills\n** onto overflow pages, then accessPayload() must be used to reassemble\n** the key/data and copy it into a preallocated buffer.\n**\n** The pointer returned by this routine looks directly into the cached\n** page of the database.  The data might change or move the next time\n** any btree routine is called.\n*/\nstatic const void *fetchPayload(\n  BtCursor *pCur,      /* Cursor pointing to entry to read from */\n  u32 *pAmt            /* Write the number of available bytes here */\n){\n  int amt;\n  assert( pCur!=0 && pCur->iPage>=0 && pCur->pPage);\n  assert( pCur->eState==CURSOR_VALID );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->info.nSize>0 );\n  assert( pCur->info.pPayload>pCur->pPage->aData || CORRUPT_DB );\n  assert( pCur->info.pPayload<pCur->pPage->aDataEnd ||CORRUPT_DB);\n  amt = pCur->info.nLocal;\n  if( amt>(int)(pCur->pPage->aDataEnd - pCur->info.pPayload) ){\n    /* There is too little space on the page for the expected amount\n    ** of local content. Database must be corrupt. */\n    assert( CORRUPT_DB );\n    amt = MAX(0, (int)(pCur->pPage->aDataEnd - pCur->info.pPayload));\n  }\n  *pAmt = (u32)amt;\n  return (void*)pCur->info.pPayload;\n}\n\n\n/*\n** For the entry that cursor pCur is point to, return as\n** many bytes of the key or data as are available on the local\n** b-tree page.  Write the number of available bytes into *pAmt.\n**\n** The pointer returned is ephemeral.  The key/data may move\n** or be destroyed on the next call to any Btree routine,\n** including calls from other threads against the same cache.\n** Hence, a mutex on the BtShared should be held prior to calling\n** this routine.\n**\n** These routines is used to get quick access to key and data\n** in the common case where no overflow pages are used.\n*/\nconst void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){\n  return fetchPayload(pCur, pAmt);\n}\n\n\n/*\n** Move the cursor down to a new child page.  The newPgno argument is the\n** page number of the child page to move to.\n**\n** This function returns SQLITE_CORRUPT if the page-header flags field of\n** the new child page does not match the flags field of the parent (i.e.\n** if an intkey page appears to be the parent of a non-intkey page, or\n** vice-versa).\n*/\nstatic int moveToChild(BtCursor *pCur, u32 newPgno){\n  BtShared *pBt = pCur->pBt;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage<BTCURSOR_MAX_DEPTH );\n  assert( pCur->iPage>=0 );\n  if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->aiIdx[pCur->iPage] = pCur->ix;\n  pCur->apPage[pCur->iPage] = pCur->pPage;\n  pCur->ix = 0;\n  pCur->iPage++;\n  return getAndInitPage(pBt, newPgno, &pCur->pPage, pCur, pCur->curPagerFlags);\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Page pParent is an internal (non-leaf) tree page. This function \n** asserts that page number iChild is the left-child if the iIdx'th\n** cell in page pParent. Or, if iIdx is equal to the total number of\n** cells in pParent, that page number iChild is the right-child of\n** the page.\n*/\nstatic void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){\n  if( CORRUPT_DB ) return;  /* The conditions tested below might not be true\n                            ** in a corrupt database */\n  assert( iIdx<=pParent->nCell );\n  if( iIdx==pParent->nCell ){\n    assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );\n  }else{\n    assert( get4byte(findCell(pParent, iIdx))==iChild );\n  }\n}\n#else\n#  define assertParentIndex(x,y,z) \n#endif\n\n/*\n** Move the cursor up to the parent page.\n**\n** pCur->idx is set to the cell index that contains the pointer\n** to the page we are coming from.  If we are coming from the\n** right-most child page then pCur->idx is set to one more than\n** the largest cell index.\n*/\nstatic void moveToParent(BtCursor *pCur){\n  MemPage *pLeaf;\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->iPage>0 );\n  assert( pCur->pPage );\n  assertParentIndex(\n    pCur->apPage[pCur->iPage-1], \n    pCur->aiIdx[pCur->iPage-1], \n    pCur->pPage->pgno\n  );\n  testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  pCur->ix = pCur->aiIdx[pCur->iPage-1];\n  pLeaf = pCur->pPage;\n  pCur->pPage = pCur->apPage[--pCur->iPage];\n  releasePageNotNull(pLeaf);\n}\n\n/*\n** Move the cursor to point to the root page of its b-tree structure.\n**\n** If the table has a virtual root page, then the cursor is moved to point\n** to the virtual root page instead of the actual root page. A table has a\n** virtual root page when the actual root page contains no cells and a \n** single child page. This can only happen with the table rooted at page 1.\n**\n** If the b-tree structure is empty, the cursor state is set to \n** CURSOR_INVALID and this routine returns SQLITE_EMPTY. Otherwise,\n** the cursor is set to point to the first cell located on the root\n** (or virtual root) page and the cursor state is set to CURSOR_VALID.\n**\n** If this function returns successfully, it may be assumed that the\n** page-header flags indicate that the [virtual] root-page is the expected \n** kind of b-tree page (i.e. if when opening the cursor the caller did not\n** specify a KeyInfo structure the flags byte is set to 0x05 or 0x0D,\n** indicating a table b-tree, or if the caller did specify a KeyInfo \n** structure the flags byte is set to 0x02 or 0x0A, indicating an index\n** b-tree).\n*/\nstatic int moveToRoot(BtCursor *pCur){\n  MemPage *pRoot;\n  int rc = SQLITE_OK;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );\n  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );\n  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );\n  assert( pCur->eState < CURSOR_REQUIRESEEK || pCur->iPage<0 );\n  assert( pCur->pgnoRoot>0 || pCur->iPage<0 );\n\n  if( pCur->iPage>=0 ){\n    if( pCur->iPage ){\n      releasePageNotNull(pCur->pPage);\n      while( --pCur->iPage ){\n        releasePageNotNull(pCur->apPage[pCur->iPage]);\n      }\n      pCur->pPage = pCur->apPage[0];\n      goto skip_init;\n    }\n  }else if( pCur->pgnoRoot==0 ){\n    pCur->eState = CURSOR_INVALID;\n    return SQLITE_EMPTY;\n  }else{\n    assert( pCur->iPage==(-1) );\n    if( pCur->eState>=CURSOR_REQUIRESEEK ){\n      if( pCur->eState==CURSOR_FAULT ){\n        assert( pCur->skipNext!=SQLITE_OK );\n        return pCur->skipNext;\n      }\n      sqlite3BtreeClearCursor(pCur);\n    }\n    rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->pPage,\n                        0, pCur->curPagerFlags);\n    if( rc!=SQLITE_OK ){\n      pCur->eState = CURSOR_INVALID;\n      return rc;\n    }\n    pCur->iPage = 0;\n    pCur->curIntKey = pCur->pPage->intKey;\n  }\n  pRoot = pCur->pPage;\n  assert( pRoot->pgno==pCur->pgnoRoot );\n\n  /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor\n  ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is\n  ** NULL, the caller expects a table b-tree. If this is not the case,\n  ** return an SQLITE_CORRUPT error. \n  **\n  ** Earlier versions of SQLite assumed that this test could not fail\n  ** if the root page was already loaded when this function was called (i.e.\n  ** if pCur->iPage>=0). But this is not so if the database is corrupted \n  ** in such a way that page pRoot is linked into a second b-tree table \n  ** (or the freelist).  */\n  assert( pRoot->intKey==1 || pRoot->intKey==0 );\n  if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){\n    return SQLITE_CORRUPT_PGNO(pCur->pPage->pgno);\n  }\n\nskip_init:  \n  pCur->ix = 0;\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);\n\n  pRoot = pCur->pPage;\n  if( pRoot->nCell>0 ){\n    pCur->eState = CURSOR_VALID;\n  }else if( !pRoot->leaf ){\n    Pgno subpage;\n    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;\n    subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);\n    pCur->eState = CURSOR_VALID;\n    rc = moveToChild(pCur, subpage);\n  }else{\n    pCur->eState = CURSOR_INVALID;\n    rc = SQLITE_EMPTY;\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the left-most leaf entry beneath the\n** entry to which it is currently pointing.\n**\n** The left-most leaf is the one with the smallest key - the first\n** in ascending order.\n*/\nstatic int moveToLeftmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){\n    assert( pCur->ix<pPage->nCell );\n    pgno = get4byte(findCell(pPage, pCur->ix));\n    rc = moveToChild(pCur, pgno);\n  }\n  return rc;\n}\n\n/*\n** Move the cursor down to the right-most leaf entry beneath the\n** page to which it is currently pointing.  Notice the difference\n** between moveToLeftmost() and moveToRightmost().  moveToLeftmost()\n** finds the left-most entry beneath the *entry* whereas moveToRightmost()\n** finds the right-most entry beneath the *page*.\n**\n** The right-most entry is the one with the largest key - the last\n** key in ascending order.\n*/\nstatic int moveToRightmost(BtCursor *pCur){\n  Pgno pgno;\n  int rc = SQLITE_OK;\n  MemPage *pPage = 0;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->eState==CURSOR_VALID );\n  while( !(pPage = pCur->pPage)->leaf ){\n    pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    pCur->ix = pPage->nCell;\n    rc = moveToChild(pCur, pgno);\n    if( rc ) return rc;\n  }\n  pCur->ix = pPage->nCell-1;\n  assert( pCur->info.nSize==0 );\n  assert( (pCur->curFlags & BTCF_ValidNKey)==0 );\n  return SQLITE_OK;\n}\n\n/* Move the cursor to the first entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nint sqlite3BtreeFirst(BtCursor *pCur, int *pRes){\n  int rc;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->pPage->nCell>0 );\n    *pRes = 0;\n    rc = moveToLeftmost(pCur);\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/* Move the cursor to the last entry in the table.  Return SQLITE_OK\n** on success.  Set *pRes to 0 if the cursor actually points to something\n** or set *pRes to 1 if the table is empty.\n*/\nint sqlite3BtreeLast(BtCursor *pCur, int *pRes){\n  int rc;\n \n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* If the cursor already points to the last entry, this is a no-op. */\n  if( CURSOR_VALID==pCur->eState && (pCur->curFlags & BTCF_AtLast)!=0 ){\n#ifdef SQLITE_DEBUG\n    /* This block serves to assert() that the cursor really does point \n    ** to the last entry in the b-tree. */\n    int ii;\n    for(ii=0; ii<pCur->iPage; ii++){\n      assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell );\n    }\n    assert( pCur->ix==pCur->pPage->nCell-1 );\n    assert( pCur->pPage->leaf );\n#endif\n    return SQLITE_OK;\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_OK ){\n    assert( pCur->eState==CURSOR_VALID );\n    *pRes = 0;\n    rc = moveToRightmost(pCur);\n    if( rc==SQLITE_OK ){\n      pCur->curFlags |= BTCF_AtLast;\n    }else{\n      pCur->curFlags &= ~BTCF_AtLast;\n    }\n  }else if( rc==SQLITE_EMPTY ){\n    assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n    *pRes = 1;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/* Move the cursor so that it points to an entry near the key \n** specified by pIdxKey or intKey.   Return a success code.\n**\n** For INTKEY tables, the intKey parameter is used.  pIdxKey \n** must be NULL.  For index tables, pIdxKey is used and intKey\n** is ignored.\n**\n** If an exact match is not found, then the cursor is always\n** left pointing at a leaf page which would hold the entry if it\n** were present.  The cursor might point to an entry that comes\n** before or after the key.\n**\n** An integer is written into *pRes which is the result of\n** comparing the key with the entry to which the cursor is \n** pointing.  The meaning of the integer written into\n** *pRes is as follows:\n**\n**     *pRes<0      The cursor is left pointing at an entry that\n**                  is smaller than intKey/pIdxKey or if the table is empty\n**                  and the cursor is therefore left point to nothing.\n**\n**     *pRes==0     The cursor is left pointing at an entry that\n**                  exactly matches intKey/pIdxKey.\n**\n**     *pRes>0      The cursor is left pointing at an entry that\n**                  is larger than intKey/pIdxKey.\n**\n** For index tables, the pIdxKey->eqSeen field is set to 1 if there\n** exists an entry in the table that exactly matches pIdxKey.  \n*/\nint sqlite3BtreeMovetoUnpacked(\n  BtCursor *pCur,          /* The cursor to be moved */\n  UnpackedRecord *pIdxKey, /* Unpacked index key */\n  i64 intKey,              /* The table key */\n  int biasRight,           /* If true, bias the search to the high end */\n  int *pRes                /* Write search results here */\n){\n  int rc;\n  RecordCompare xRecordCompare;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n  assert( pRes );\n  assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );\n  assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );\n\n  /* If the cursor is already positioned at the point we are trying\n  ** to move to, then just return without doing any work */\n  if( pIdxKey==0\n   && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0\n  ){\n    if( pCur->info.nKey==intKey ){\n      *pRes = 0;\n      return SQLITE_OK;\n    }\n    if( pCur->info.nKey<intKey ){\n      if( (pCur->curFlags & BTCF_AtLast)!=0 ){\n        *pRes = -1;\n        return SQLITE_OK;\n      }\n      /* If the requested key is one more than the previous key, then\n      ** try to get there using sqlite3BtreeNext() rather than a full\n      ** binary search.  This is an optimization only.  The correct answer\n      ** is still obtained without this case, only a little more slowely */\n      if( pCur->info.nKey+1==intKey && !pCur->skipNext ){\n        *pRes = 0;\n        rc = sqlite3BtreeNext(pCur, 0);\n        if( rc==SQLITE_OK ){\n          getCellInfo(pCur);\n          if( pCur->info.nKey==intKey ){\n            return SQLITE_OK;\n          }\n        }else if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n        }else{\n          return rc;\n        }\n      }\n    }\n  }\n\n  if( pIdxKey ){\n    xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);\n    pIdxKey->errCode = 0;\n    assert( pIdxKey->default_rc==1 \n         || pIdxKey->default_rc==0 \n         || pIdxKey->default_rc==-1\n    );\n  }else{\n    xRecordCompare = 0; /* All keys are integers */\n  }\n\n  rc = moveToRoot(pCur);\n  if( rc ){\n    if( rc==SQLITE_EMPTY ){\n      assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n    return rc;\n  }\n  assert( pCur->pPage );\n  assert( pCur->pPage->isInit );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( pCur->pPage->nCell > 0 );\n  assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );\n  assert( pCur->curIntKey || pIdxKey );\n  for(;;){\n    int lwr, upr, idx, c;\n    Pgno chldPg;\n    MemPage *pPage = pCur->pPage;\n    u8 *pCell;                          /* Pointer to current cell in pPage */\n\n    /* pPage->nCell must be greater than zero. If this is the root-page\n    ** the cursor would have been INVALID above and this for(;;) loop\n    ** not run. If this is not the root-page, then the moveToChild() routine\n    ** would have already detected db corruption. Similarly, pPage must\n    ** be the right kind (index or table) of b-tree page. Otherwise\n    ** a moveToChild() or moveToRoot() call would have detected corruption.  */\n    assert( pPage->nCell>0 );\n    assert( pPage->intKey==(pIdxKey==0) );\n    lwr = 0;\n    upr = pPage->nCell-1;\n    assert( biasRight==0 || biasRight==1 );\n    idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */\n    pCur->ix = (u16)idx;\n    if( xRecordCompare==0 ){\n      for(;;){\n        i64 nCellKey;\n        pCell = findCellPastPtr(pPage, idx);\n        if( pPage->intKeyLeaf ){\n          while( 0x80 <= *(pCell++) ){\n            if( pCell>=pPage->aDataEnd ){\n              return SQLITE_CORRUPT_PGNO(pPage->pgno);\n            }\n          }\n        }\n        getVarint(pCell, (u64*)&nCellKey);\n        if( nCellKey<intKey ){\n          lwr = idx+1;\n          if( lwr>upr ){ c = -1; break; }\n        }else if( nCellKey>intKey ){\n          upr = idx-1;\n          if( lwr>upr ){ c = +1; break; }\n        }else{\n          assert( nCellKey==intKey );\n          pCur->ix = (u16)idx;\n          if( !pPage->leaf ){\n            lwr = idx;\n            goto moveto_next_layer;\n          }else{\n            pCur->curFlags |= BTCF_ValidNKey;\n            pCur->info.nKey = nCellKey;\n            pCur->info.nSize = 0;\n            *pRes = 0;\n            return SQLITE_OK;\n          }\n        }\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2; */\n      }\n    }else{\n      for(;;){\n        int nCell;  /* Size of the pCell cell in bytes */\n        pCell = findCellPastPtr(pPage, idx);\n\n        /* The maximum supported page-size is 65536 bytes. This means that\n        ** the maximum number of record bytes stored on an index B-Tree\n        ** page is less than 16384 bytes and may be stored as a 2-byte\n        ** varint. This information is used to attempt to avoid parsing \n        ** the entire cell by checking for the cases where the record is \n        ** stored entirely within the b-tree page by inspecting the first \n        ** 2 bytes of the cell.\n        */\n        nCell = pCell[0];\n        if( nCell<=pPage->max1bytePayload ){\n          /* This branch runs if the record-size field of the cell is a\n          ** single byte varint and the record fits entirely on the main\n          ** b-tree page.  */\n          testcase( pCell+nCell+1==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);\n        }else if( !(pCell[1] & 0x80) \n          && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal\n        ){\n          /* The record-size field is a 2 byte varint and the record \n          ** fits entirely on the main b-tree page.  */\n          testcase( pCell+nCell+2==pPage->aDataEnd );\n          c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);\n        }else{\n          /* The record flows over onto one or more overflow pages. In\n          ** this case the whole cell needs to be parsed, a buffer allocated\n          ** and accessPayload() used to retrieve the record into the\n          ** buffer before VdbeRecordCompare() can be called. \n          **\n          ** If the record is corrupt, the xRecordCompare routine may read\n          ** up to two varints past the end of the buffer. An extra 18 \n          ** bytes of padding is allocated at the end of the buffer in\n          ** case this happens.  */\n          void *pCellKey;\n          u8 * const pCellBody = pCell - pPage->childPtrSize;\n          pPage->xParseCell(pPage, pCellBody, &pCur->info);\n          nCell = (int)pCur->info.nKey;\n          testcase( nCell<0 );   /* True if key size is 2^32 or more */\n          testcase( nCell==0 );  /* Invalid key size:  0x80 0x80 0x00 */\n          testcase( nCell==1 );  /* Invalid key size:  0x80 0x80 0x01 */\n          testcase( nCell==2 );  /* Minimum legal index key size */\n          if( nCell<2 ){\n            rc = SQLITE_CORRUPT_PGNO(pPage->pgno);\n            goto moveto_finish;\n          }\n          pCellKey = sqlite3Malloc( nCell+18 );\n          if( pCellKey==0 ){\n            rc = SQLITE_NOMEM_BKPT;\n            goto moveto_finish;\n          }\n          pCur->ix = (u16)idx;\n          rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);\n          pCur->curFlags &= ~BTCF_ValidOvfl;\n          if( rc ){\n            sqlite3_free(pCellKey);\n            goto moveto_finish;\n          }\n          c = xRecordCompare(nCell, pCellKey, pIdxKey);\n          sqlite3_free(pCellKey);\n        }\n        assert( \n            (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)\n         && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)\n        );\n        if( c<0 ){\n          lwr = idx+1;\n        }else if( c>0 ){\n          upr = idx-1;\n        }else{\n          assert( c==0 );\n          *pRes = 0;\n          rc = SQLITE_OK;\n          pCur->ix = (u16)idx;\n          if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;\n          goto moveto_finish;\n        }\n        if( lwr>upr ) break;\n        assert( lwr+upr>=0 );\n        idx = (lwr+upr)>>1;  /* idx = (lwr+upr)/2 */\n      }\n    }\n    assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );\n    assert( pPage->isInit );\n    if( pPage->leaf ){\n      assert( pCur->ix<pCur->pPage->nCell );\n      pCur->ix = (u16)idx;\n      *pRes = c;\n      rc = SQLITE_OK;\n      goto moveto_finish;\n    }\nmoveto_next_layer:\n    if( lwr>=pPage->nCell ){\n      chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n    }else{\n      chldPg = get4byte(findCell(pPage, lwr));\n    }\n    pCur->ix = (u16)lwr;\n    rc = moveToChild(pCur, chldPg);\n    if( rc ) break;\n  }\nmoveto_finish:\n  pCur->info.nSize = 0;\n  assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n  return rc;\n}\n\n\n/*\n** Return TRUE if the cursor is not pointing at an entry of the table.\n**\n** TRUE will be returned after a call to sqlite3BtreeNext() moves\n** past the last entry in the table or sqlite3BtreePrev() moves past\n** the first entry.  TRUE is also returned if the table is empty.\n*/\nint sqlite3BtreeEof(BtCursor *pCur){\n  /* TODO: What if the cursor is in CURSOR_REQUIRESEEK but all table entries\n  ** have been deleted? This API will need to change to return an error code\n  ** as well as the boolean result value.\n  */\n  return (CURSOR_VALID!=pCur->eState);\n}\n\n/*\n** Return an estimate for the number of rows in the table that pCur is\n** pointing to.  Return a negative number if no estimate is currently \n** available.\n*/\ni64 sqlite3BtreeRowCountEst(BtCursor *pCur){\n  i64 n;\n  u8 i;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );\n\n  /* Currently this interface is only called by the OP_IfSmaller\n  ** opcode, and it that case the cursor will always be valid and\n  ** will always point to a leaf node. */\n  if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;\n  if( NEVER(pCur->pPage->leaf==0) ) return -1;\n\n  n = pCur->pPage->nCell;\n  for(i=0; i<pCur->iPage; i++){\n    n *= pCur->apPage[i]->nCell;\n  }\n  return n;\n}\n\n/*\n** Advance the cursor to the next entry in the database. \n** Return value:\n**\n**    SQLITE_OK        success\n**    SQLITE_DONE      cursor is already pointing at the last element\n**    otherwise        some kind of error occurred\n**\n** The main entry point is sqlite3BtreeNext().  That routine is optimized\n** for the common case of merely incrementing the cell counter BtCursor.aiIdx\n** to the next cell on the current page.  The (slower) btreeNext() helper\n** routine is called when it is necessary to move to a different page or\n** to restore the cursor.\n**\n** If bit 0x01 of the F argument in sqlite3BtreeNext(C,F) is 1, then the\n** cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument\n** is a hint to the implement.  SQLite btree implementation does not use\n** this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreeNext(BtCursor *pCur){\n  int rc;\n  int idx;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  if( pCur->eState!=CURSOR_VALID ){\n    assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( pCur->skipNext ){\n      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext>0 ){\n        pCur->skipNext = 0;\n        return SQLITE_OK;\n      }\n      pCur->skipNext = 0;\n    }\n  }\n\n  pPage = pCur->pPage;\n  idx = ++pCur->ix;\n  assert( pPage->isInit );\n\n  /* If the database file is corrupt, it is possible for the value of idx \n  ** to be invalid here. This can only occur if a second cursor modifies\n  ** the page while cursor pCur is holding a reference to it. Which can\n  ** only happen if the database is corrupt in such a way as to link the\n  ** page into more than one b-tree structure. */\n  testcase( idx>pPage->nCell );\n\n  if( idx>=pPage->nCell ){\n    if( !pPage->leaf ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n      if( rc ) return rc;\n      return moveToLeftmost(pCur);\n    }\n    do{\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n      pPage = pCur->pPage;\n    }while( pCur->ix>=pPage->nCell );\n    if( pPage->intKey ){\n      return sqlite3BtreeNext(pCur, 0);\n    }else{\n      return SQLITE_OK;\n    }\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\nint sqlite3BtreeNext(BtCursor *pCur, int flags){\n  MemPage *pPage;\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  pCur->info.nSize = 0;\n  pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);\n  if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur);\n  pPage = pCur->pPage;\n  if( (++pCur->ix)>=pPage->nCell ){\n    pCur->ix--;\n    return btreeNext(pCur);\n  }\n  if( pPage->leaf ){\n    return SQLITE_OK;\n  }else{\n    return moveToLeftmost(pCur);\n  }\n}\n\n/*\n** Step the cursor to the back to the previous entry in the database.\n** Return values:\n**\n**     SQLITE_OK     success\n**     SQLITE_DONE   the cursor is already on the first element of the table\n**     otherwise     some kind of error occurred\n**\n** The main entry point is sqlite3BtreePrevious().  That routine is optimized\n** for the common case of merely decrementing the cell counter BtCursor.aiIdx\n** to the previous cell on the current page.  The (slower) btreePrevious()\n** helper routine is called when it is necessary to move to a different page\n** or to restore the cursor.\n**\n** If bit 0x01 of the F argument to sqlite3BtreePrevious(C,F) is 1, then\n** the cursor corresponds to an SQL index and this routine could have been\n** skipped if the SQL index had been a unique index.  The F argument is a\n** hint to the implement.  The native SQLite btree implementation does not\n** use this hint, but COMDB2 does.\n*/\nstatic SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){\n  int rc;\n  MemPage *pPage;\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );\n  assert( pCur->info.nSize==0 );\n  if( pCur->eState!=CURSOR_VALID ){\n    rc = restoreCursorPosition(pCur);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    if( CURSOR_INVALID==pCur->eState ){\n      return SQLITE_DONE;\n    }\n    if( pCur->skipNext ){\n      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );\n      pCur->eState = CURSOR_VALID;\n      if( pCur->skipNext<0 ){\n        pCur->skipNext = 0;\n        return SQLITE_OK;\n      }\n      pCur->skipNext = 0;\n    }\n  }\n\n  pPage = pCur->pPage;\n  assert( pPage->isInit );\n  if( !pPage->leaf ){\n    int idx = pCur->ix;\n    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));\n    if( rc ) return rc;\n    rc = moveToRightmost(pCur);\n  }else{\n    while( pCur->ix==0 ){\n      if( pCur->iPage==0 ){\n        pCur->eState = CURSOR_INVALID;\n        return SQLITE_DONE;\n      }\n      moveToParent(pCur);\n    }\n    assert( pCur->info.nSize==0 );\n    assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );\n\n    pCur->ix--;\n    pPage = pCur->pPage;\n    if( pPage->intKey && !pPage->leaf ){\n      rc = sqlite3BtreePrevious(pCur, 0);\n    }else{\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\nint sqlite3BtreePrevious(BtCursor *pCur, int flags){\n  assert( cursorOwnsBtShared(pCur) );\n  assert( flags==0 || flags==1 );\n  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );\n  UNUSED_PARAMETER( flags );  /* Used in COMDB2 but not native SQLite */\n  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);\n  pCur->info.nSize = 0;\n  if( pCur->eState!=CURSOR_VALID\n   || pCur->ix==0\n   || pCur->pPage->leaf==0\n  ){\n    return btreePrevious(pCur);\n  }\n  pCur->ix--;\n  return SQLITE_OK;\n}\n\n/*\n** Allocate a new page from the database file.\n**\n** The new page is marked as dirty.  (In other words, sqlite3PagerWrite()\n** has already been called on the new page.)  The new page has also\n** been referenced and the calling routine is responsible for calling\n** sqlite3PagerUnref() on the new page when it is done.\n**\n** SQLITE_OK is returned on success.  Any other return value indicates\n** an error.  *ppPage is set to NULL in the event of an error.\n**\n** If the \"nearby\" parameter is not 0, then an effort is made to \n** locate a page close to the page number \"nearby\".  This can be used in an\n** attempt to keep related pages close to each other in the database file,\n** which in turn can make database access faster.\n**\n** If the eMode parameter is BTALLOC_EXACT and the nearby page exists\n** anywhere on the free-list, then it is guaranteed to be returned.  If\n** eMode is BTALLOC_LT then the page returned will be less than or equal\n** to nearby if any such page exists.  If eMode is BTALLOC_ANY then there\n** are no restrictions on which page is returned.\n*/\nstatic int allocateBtreePage(\n  BtShared *pBt,         /* The btree */\n  MemPage **ppPage,      /* Store pointer to the allocated page here */\n  Pgno *pPgno,           /* Store the page number here */\n  Pgno nearby,           /* Search for a page near this one */\n  u8 eMode               /* BTALLOC_EXACT, BTALLOC_LT, or BTALLOC_ANY */\n){\n  MemPage *pPage1;\n  int rc;\n  u32 n;     /* Number of pages on the freelist */\n  u32 k;     /* Number of leaves on the trunk of the freelist */\n  MemPage *pTrunk = 0;\n  MemPage *pPrevTrunk = 0;\n  Pgno mxPage;     /* Total size of the database file */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );\n  pPage1 = pBt->pPage1;\n  mxPage = btreePagecount(pBt);\n  /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36\n  ** stores stores the total number of pages on the freelist. */\n  n = get4byte(&pPage1->aData[36]);\n  testcase( n==mxPage-1 );\n  if( n>=mxPage ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  if( n>0 ){\n    /* There are pages on the freelist.  Reuse one of those pages. */\n    Pgno iTrunk;\n    u8 searchList = 0; /* If the free-list must be searched for 'nearby' */\n    u32 nSearch = 0;   /* Count of the number of search attempts */\n    \n    /* If eMode==BTALLOC_EXACT and a query of the pointer-map\n    ** shows that the page 'nearby' is somewhere on the free-list, then\n    ** the entire-list will be searched for that page.\n    */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( eMode==BTALLOC_EXACT ){\n      if( nearby<=mxPage ){\n        u8 eType;\n        assert( nearby>0 );\n        assert( pBt->autoVacuum );\n        rc = ptrmapGet(pBt, nearby, &eType, 0);\n        if( rc ) return rc;\n        if( eType==PTRMAP_FREEPAGE ){\n          searchList = 1;\n        }\n      }\n    }else if( eMode==BTALLOC_LE ){\n      searchList = 1;\n    }\n#endif\n\n    /* Decrement the free-list count by 1. Set iTrunk to the index of the\n    ** first free-list trunk page. iPrevTrunk is initially 1.\n    */\n    rc = sqlite3PagerWrite(pPage1->pDbPage);\n    if( rc ) return rc;\n    put4byte(&pPage1->aData[36], n-1);\n\n    /* The code within this loop is run only once if the 'searchList' variable\n    ** is not true. Otherwise, it runs once for each trunk-page on the\n    ** free-list until the page 'nearby' is located (eMode==BTALLOC_EXACT)\n    ** or until a page less than 'nearby' is located (eMode==BTALLOC_LT)\n    */\n    do {\n      pPrevTrunk = pTrunk;\n      if( pPrevTrunk ){\n        /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page\n        ** is the page number of the next freelist trunk page in the list or\n        ** zero if this is the last freelist trunk page. */\n        iTrunk = get4byte(&pPrevTrunk->aData[0]);\n      }else{\n        /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32\n        ** stores the page number of the first page of the freelist, or zero if\n        ** the freelist is empty. */\n        iTrunk = get4byte(&pPage1->aData[32]);\n      }\n      testcase( iTrunk==mxPage );\n      if( iTrunk>mxPage || nSearch++ > n ){\n        rc = SQLITE_CORRUPT_PGNO(pPrevTrunk ? pPrevTrunk->pgno : 1);\n      }else{\n        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);\n      }\n      if( rc ){\n        pTrunk = 0;\n        goto end_allocate_page;\n      }\n      assert( pTrunk!=0 );\n      assert( pTrunk->aData!=0 );\n      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page\n      ** is the number of leaf page pointers to follow. */\n      k = get4byte(&pTrunk->aData[4]);\n      if( k==0 && !searchList ){\n        /* The trunk has no leaves and the list is not being searched. \n        ** So extract the trunk page itself and use it as the newly \n        ** allocated page */\n        assert( pPrevTrunk==0 );\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        *pPgno = iTrunk;\n        memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n        *ppPage = pTrunk;\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n      }else if( k>(u32)(pBt->usableSize/4 - 2) ){\n        /* Value of k is out of range.  Database corruption */\n        rc = SQLITE_CORRUPT_PGNO(iTrunk);\n        goto end_allocate_page;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      }else if( searchList \n            && (nearby==iTrunk || (iTrunk<nearby && eMode==BTALLOC_LE)) \n      ){\n        /* The list is being searched and this trunk page is the page\n        ** to allocate, regardless of whether it has leaves.\n        */\n        *pPgno = iTrunk;\n        *ppPage = pTrunk;\n        searchList = 0;\n        rc = sqlite3PagerWrite(pTrunk->pDbPage);\n        if( rc ){\n          goto end_allocate_page;\n        }\n        if( k==0 ){\n          if( !pPrevTrunk ){\n            memcpy(&pPage1->aData[32], &pTrunk->aData[0], 4);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc!=SQLITE_OK ){\n              goto end_allocate_page;\n            }\n            memcpy(&pPrevTrunk->aData[0], &pTrunk->aData[0], 4);\n          }\n        }else{\n          /* The trunk page is required by the caller but it contains \n          ** pointers to free-list leaves. The first leaf becomes a trunk\n          ** page in this case.\n          */\n          MemPage *pNewTrunk;\n          Pgno iNewTrunk = get4byte(&pTrunk->aData[8]);\n          if( iNewTrunk>mxPage ){ \n            rc = SQLITE_CORRUPT_PGNO(iTrunk);\n            goto end_allocate_page;\n          }\n          testcase( iNewTrunk==mxPage );\n          rc = btreeGetUnusedPage(pBt, iNewTrunk, &pNewTrunk, 0);\n          if( rc!=SQLITE_OK ){\n            goto end_allocate_page;\n          }\n          rc = sqlite3PagerWrite(pNewTrunk->pDbPage);\n          if( rc!=SQLITE_OK ){\n            releasePage(pNewTrunk);\n            goto end_allocate_page;\n          }\n          memcpy(&pNewTrunk->aData[0], &pTrunk->aData[0], 4);\n          put4byte(&pNewTrunk->aData[4], k-1);\n          memcpy(&pNewTrunk->aData[8], &pTrunk->aData[12], (k-1)*4);\n          releasePage(pNewTrunk);\n          if( !pPrevTrunk ){\n            assert( sqlite3PagerIswriteable(pPage1->pDbPage) );\n            put4byte(&pPage1->aData[32], iNewTrunk);\n          }else{\n            rc = sqlite3PagerWrite(pPrevTrunk->pDbPage);\n            if( rc ){\n              goto end_allocate_page;\n            }\n            put4byte(&pPrevTrunk->aData[0], iNewTrunk);\n          }\n        }\n        pTrunk = 0;\n        TRACE((\"ALLOCATE: %d trunk - %d free pages left\\n\", *pPgno, n-1));\n#endif\n      }else if( k>0 ){\n        /* Extract a leaf from the trunk */\n        u32 closest;\n        Pgno iPage;\n        unsigned char *aData = pTrunk->aData;\n        if( nearby>0 ){\n          u32 i;\n          closest = 0;\n          if( eMode==BTALLOC_LE ){\n            for(i=0; i<k; i++){\n              iPage = get4byte(&aData[8+i*4]);\n              if( iPage<=nearby ){\n                closest = i;\n                break;\n              }\n            }\n          }else{\n            int dist;\n            dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);\n            for(i=1; i<k; i++){\n              int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);\n              if( d2<dist ){\n                closest = i;\n                dist = d2;\n              }\n            }\n          }\n        }else{\n          closest = 0;\n        }\n\n        iPage = get4byte(&aData[8+closest*4]);\n        testcase( iPage==mxPage );\n        if( iPage>mxPage ){\n          rc = SQLITE_CORRUPT_PGNO(iTrunk);\n          goto end_allocate_page;\n        }\n        testcase( iPage==mxPage );\n        if( !searchList \n         || (iPage==nearby || (iPage<nearby && eMode==BTALLOC_LE)) \n        ){\n          int noContent;\n          *pPgno = iPage;\n          TRACE((\"ALLOCATE: %d was leaf %d of %d on trunk %d\"\n                 \": %d more free pages\\n\",\n                 *pPgno, closest+1, k, pTrunk->pgno, n-1));\n          rc = sqlite3PagerWrite(pTrunk->pDbPage);\n          if( rc ) goto end_allocate_page;\n          if( closest<k-1 ){\n            memcpy(&aData[8+closest*4], &aData[4+k*4], 4);\n          }\n          put4byte(&aData[4], k-1);\n          noContent = !btreeGetHasContent(pBt, *pPgno)? PAGER_GET_NOCONTENT : 0;\n          rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, noContent);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n            if( rc!=SQLITE_OK ){\n              releasePage(*ppPage);\n              *ppPage = 0;\n            }\n          }\n          searchList = 0;\n        }\n      }\n      releasePage(pPrevTrunk);\n      pPrevTrunk = 0;\n    }while( searchList );\n  }else{\n    /* There are no pages on the freelist, so append a new page to the\n    ** database image.\n    **\n    ** Normally, new pages allocated by this block can be requested from the\n    ** pager layer with the 'no-content' flag set. This prevents the pager\n    ** from trying to read the pages content from disk. However, if the\n    ** current transaction has already run one or more incremental-vacuum\n    ** steps, then the page we are about to allocate may contain content\n    ** that is required in the event of a rollback. In this case, do\n    ** not set the no-content flag. This causes the pager to load and journal\n    ** the current page content before overwriting it.\n    **\n    ** Note that the pager will not actually attempt to load or journal \n    ** content for any page that really does lie past the end of the database\n    ** file on disk. So the effects of disabling the no-content optimization\n    ** here are confined to those pages that lie between the end of the\n    ** database image and the end of the database file.\n    */\n    int bNoContent = (0==IfNotOmitAV(pBt->bDoTruncate))? PAGER_GET_NOCONTENT:0;\n\n    rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n    if( rc ) return rc;\n    pBt->nPage++;\n    if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ) pBt->nPage++;\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, pBt->nPage) ){\n      /* If *pPgno refers to a pointer-map page, allocate two new pages\n      ** at the end of the file instead of one. The first allocated page\n      ** becomes a new pointer-map page, the second is used by the caller.\n      */\n      MemPage *pPg = 0;\n      TRACE((\"ALLOCATE: %d from end of file (pointer-map page)\\n\", pBt->nPage));\n      assert( pBt->nPage!=PENDING_BYTE_PAGE(pBt) );\n      rc = btreeGetUnusedPage(pBt, pBt->nPage, &pPg, bNoContent);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pPg->pDbPage);\n        releasePage(pPg);\n      }\n      if( rc ) return rc;\n      pBt->nPage++;\n      if( pBt->nPage==PENDING_BYTE_PAGE(pBt) ){ pBt->nPage++; }\n    }\n#endif\n    put4byte(28 + (u8*)pBt->pPage1->aData, pBt->nPage);\n    *pPgno = pBt->nPage;\n\n    assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n    rc = btreeGetUnusedPage(pBt, *pPgno, ppPage, bNoContent);\n    if( rc ) return rc;\n    rc = sqlite3PagerWrite((*ppPage)->pDbPage);\n    if( rc!=SQLITE_OK ){\n      releasePage(*ppPage);\n      *ppPage = 0;\n    }\n    TRACE((\"ALLOCATE: %d from end of file\\n\", *pPgno));\n  }\n\n  assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );\n\nend_allocate_page:\n  releasePage(pTrunk);\n  releasePage(pPrevTrunk);\n  assert( rc!=SQLITE_OK || sqlite3PagerPageRefcount((*ppPage)->pDbPage)<=1 );\n  assert( rc!=SQLITE_OK || (*ppPage)->isInit==0 );\n  return rc;\n}\n\n/*\n** This function is used to add page iPage to the database file free-list. \n** It is assumed that the page is not already a part of the free-list.\n**\n** The value passed as the second argument to this function is optional.\n** If the caller happens to have a pointer to the MemPage object \n** corresponding to page iPage handy, it may pass it as the second value. \n** Otherwise, it may pass NULL.\n**\n** If a pointer to a MemPage object is passed as the second argument,\n** its reference count is not altered by this function.\n*/\nstatic int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){\n  MemPage *pTrunk = 0;                /* Free-list trunk page */\n  Pgno iTrunk = 0;                    /* Page number of free-list trunk page */ \n  MemPage *pPage1 = pBt->pPage1;      /* Local reference to page 1 */\n  MemPage *pPage;                     /* Page being freed. May be NULL. */\n  int rc;                             /* Return Code */\n  int nFree;                          /* Initial number of pages on free-list */\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( CORRUPT_DB || iPage>1 );\n  assert( !pMemPage || pMemPage->pgno==iPage );\n\n  if( iPage<2 ) return SQLITE_CORRUPT_BKPT;\n  if( pMemPage ){\n    pPage = pMemPage;\n    sqlite3PagerRef(pPage->pDbPage);\n  }else{\n    pPage = btreePageLookup(pBt, iPage);\n  }\n\n  /* Increment the free page count on pPage1 */\n  rc = sqlite3PagerWrite(pPage1->pDbPage);\n  if( rc ) goto freepage_out;\n  nFree = get4byte(&pPage1->aData[36]);\n  put4byte(&pPage1->aData[36], nFree+1);\n\n  if( pBt->btsFlags & BTS_SECURE_DELETE ){\n    /* If the secure_delete option is enabled, then\n    ** always fully overwrite deleted information with zeros.\n    */\n    if( (!pPage && ((rc = btreeGetPage(pBt, iPage, &pPage, 0))!=0) )\n     ||            ((rc = sqlite3PagerWrite(pPage->pDbPage))!=0)\n    ){\n      goto freepage_out;\n    }\n    memset(pPage->aData, 0, pPage->pBt->pageSize);\n  }\n\n  /* If the database supports auto-vacuum, write an entry in the pointer-map\n  ** to indicate that the page is free.\n  */\n  if( ISAUTOVACUUM ){\n    ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);\n    if( rc ) goto freepage_out;\n  }\n\n  /* Now manipulate the actual database free-list structure. There are two\n  ** possibilities. If the free-list is currently empty, or if the first\n  ** trunk page in the free-list is full, then this page will become a\n  ** new free-list trunk page. Otherwise, it will become a leaf of the\n  ** first trunk page in the current free-list. This block tests if it\n  ** is possible to add the page as a new free-list leaf.\n  */\n  if( nFree!=0 ){\n    u32 nLeaf;                /* Initial number of leaf cells on trunk page */\n\n    iTrunk = get4byte(&pPage1->aData[32]);\n    rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);\n    if( rc!=SQLITE_OK ){\n      goto freepage_out;\n    }\n\n    nLeaf = get4byte(&pTrunk->aData[4]);\n    assert( pBt->usableSize>32 );\n    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto freepage_out;\n    }\n    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){\n      /* In this case there is room on the trunk page to insert the page\n      ** being freed as a new leaf.\n      **\n      ** Note that the trunk page is not really full until it contains\n      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have\n      ** coded.  But due to a coding error in versions of SQLite prior to\n      ** 3.6.0, databases with freelist trunk pages holding more than\n      ** usableSize/4 - 8 entries will be reported as corrupt.  In order\n      ** to maintain backwards compatibility with older versions of SQLite,\n      ** we will continue to restrict the number of entries to usableSize/4 - 8\n      ** for now.  At some point in the future (once everyone has upgraded\n      ** to 3.6.0 or later) we should consider fixing the conditional above\n      ** to read \"usableSize/4-2\" instead of \"usableSize/4-8\".\n      **\n      ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still\n      ** avoid using the last six entries in the freelist trunk page array in\n      ** order that database files created by newer versions of SQLite can be\n      ** read by older versions of SQLite.\n      */\n      rc = sqlite3PagerWrite(pTrunk->pDbPage);\n      if( rc==SQLITE_OK ){\n        put4byte(&pTrunk->aData[4], nLeaf+1);\n        put4byte(&pTrunk->aData[8+nLeaf*4], iPage);\n        if( pPage && (pBt->btsFlags & BTS_SECURE_DELETE)==0 ){\n          sqlite3PagerDontWrite(pPage->pDbPage);\n        }\n        rc = btreeSetHasContent(pBt, iPage);\n      }\n      TRACE((\"FREE-PAGE: %d leaf on trunk page %d\\n\",pPage->pgno,pTrunk->pgno));\n      goto freepage_out;\n    }\n  }\n\n  /* If control flows to this point, then it was not possible to add the\n  ** the page being freed as a leaf page of the first trunk in the free-list.\n  ** Possibly because the free-list is empty, or possibly because the \n  ** first trunk in the free-list is full. Either way, the page being freed\n  ** will become the new first trunk page in the free-list.\n  */\n  if( pPage==0 && SQLITE_OK!=(rc = btreeGetPage(pBt, iPage, &pPage, 0)) ){\n    goto freepage_out;\n  }\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc!=SQLITE_OK ){\n    goto freepage_out;\n  }\n  put4byte(pPage->aData, iTrunk);\n  put4byte(&pPage->aData[4], 0);\n  put4byte(&pPage1->aData[32], iPage);\n  TRACE((\"FREE-PAGE: %d new trunk page replacing %d\\n\", pPage->pgno, iTrunk));\n\nfreepage_out:\n  if( pPage ){\n    pPage->isInit = 0;\n  }\n  releasePage(pPage);\n  releasePage(pTrunk);\n  return rc;\n}\nstatic void freePage(MemPage *pPage, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    *pRC = freePage2(pPage->pBt, pPage, pPage->pgno);\n  }\n}\n\n/*\n** Free any overflow pages associated with the given Cell.  Write the\n** local Cell size (the number of bytes on the original page, omitting\n** overflow) into *pnSize.\n*/\nstatic int clearCell(\n  MemPage *pPage,          /* The page that contains the Cell */\n  unsigned char *pCell,    /* First byte of the Cell */\n  CellInfo *pInfo          /* Size information about the cell */\n){\n  BtShared *pBt;\n  Pgno ovflPgno;\n  int rc;\n  int nOvfl;\n  u32 ovflPageSize;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  pPage->xParseCell(pPage, pCell, pInfo);\n  if( pInfo->nLocal==pInfo->nPayload ){\n    return SQLITE_OK;  /* No overflow pages. Return without doing anything */\n  }\n  if( pCell+pInfo->nSize-1 > pPage->aData+pPage->maskPage ){\n    /* Cell extends past end of page */\n    return SQLITE_CORRUPT_PGNO(pPage->pgno);\n  }\n  ovflPgno = get4byte(pCell + pInfo->nSize - 4);\n  pBt = pPage->pBt;\n  assert( pBt->usableSize > 4 );\n  ovflPageSize = pBt->usableSize - 4;\n  nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;\n  assert( nOvfl>0 || \n    (CORRUPT_DB && (pInfo->nPayload + ovflPageSize)<ovflPageSize)\n  );\n  while( nOvfl-- ){\n    Pgno iNext = 0;\n    MemPage *pOvfl = 0;\n    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){\n      /* 0 is not a legal page number and page 1 cannot be an \n      ** overflow page. Therefore if ovflPgno<2 or past the end of the \n      ** file the database must be corrupt. */\n      return SQLITE_CORRUPT_BKPT;\n    }\n    if( nOvfl ){\n      rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);\n      if( rc ) return rc;\n    }\n\n    if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )\n     && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1\n    ){\n      /* There is no reason any cursor should have an outstanding reference \n      ** to an overflow page belonging to a cell that is being deleted/updated.\n      ** So if there exists more than one reference to this page, then it \n      ** must not really be an overflow page and the database must be corrupt. \n      ** It is helpful to detect this before calling freePage2(), as \n      ** freePage2() may zero the page contents if secure-delete mode is\n      ** enabled. If this 'overflow' page happens to be a page that the\n      ** caller is iterating through or using in some other way, this\n      ** can be problematic.\n      */\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = freePage2(pBt, pOvfl, ovflPgno);\n    }\n\n    if( pOvfl ){\n      sqlite3PagerUnref(pOvfl->pDbPage);\n    }\n    if( rc ) return rc;\n    ovflPgno = iNext;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Create the byte sequence used to represent a cell on page pPage\n** and write that byte sequence into pCell[].  Overflow pages are\n** allocated and filled in as necessary.  The calling procedure\n** is responsible for making sure sufficient space has been allocated\n** for pCell[].\n**\n** Note that pCell does not necessary need to point to the pPage->aData\n** area.  pCell might point to some temporary storage.  The cell will\n** be constructed in this temporary area then copied into pPage->aData\n** later.\n*/\nstatic int fillInCell(\n  MemPage *pPage,                /* The page that contains the cell */\n  unsigned char *pCell,          /* Complete text of the cell */\n  const BtreePayload *pX,        /* Payload with which to construct the cell */\n  int *pnSize                    /* Write cell size here */\n){\n  int nPayload;\n  const u8 *pSrc;\n  int nSrc, n, rc, mn;\n  int spaceLeft;\n  MemPage *pToRelease;\n  unsigned char *pPrior;\n  unsigned char *pPayload;\n  BtShared *pBt;\n  Pgno pgnoOvfl;\n  int nHeader;\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n\n  /* pPage is not necessarily writeable since pCell might be auxiliary\n  ** buffer space that is separate from the pPage buffer area */\n  assert( pCell<pPage->aData || pCell>=&pPage->aData[pPage->pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n  /* Fill in the header. */\n  nHeader = pPage->childPtrSize;\n  if( pPage->intKey ){\n    nPayload = pX->nData + pX->nZero;\n    pSrc = pX->pData;\n    nSrc = pX->nData;\n    assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n    nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey);\n  }else{\n    assert( pX->nKey<=0x7fffffff && pX->pKey!=0 );\n    nSrc = nPayload = (int)pX->nKey;\n    pSrc = pX->pKey;\n    nHeader += putVarint32(&pCell[nHeader], nPayload);\n  }\n  \n  /* Fill in the payload */\n  pPayload = &pCell[nHeader];\n  if( nPayload<=pPage->maxLocal ){\n    /* This is the common case where everything fits on the btree page\n    ** and no overflow pages are required. */\n    n = nHeader + nPayload;\n    testcase( n==3 );\n    testcase( n==4 );\n    if( n<4 ) n = 4;\n    *pnSize = n;\n    assert( nSrc<=nPayload );\n    testcase( nSrc<nPayload );\n    memcpy(pPayload, pSrc, nSrc);\n    memset(pPayload+nSrc, 0, nPayload-nSrc);\n    return SQLITE_OK;\n  }\n\n  /* If we reach this point, it means that some of the content will need\n  ** to spill onto overflow pages.\n  */\n  mn = pPage->minLocal;\n  n = mn + (nPayload - mn) % (pPage->pBt->usableSize - 4);\n  testcase( n==pPage->maxLocal );\n  testcase( n==pPage->maxLocal+1 );\n  if( n > pPage->maxLocal ) n = mn;\n  spaceLeft = n;\n  *pnSize = n + nHeader + 4;\n  pPrior = &pCell[nHeader+n];\n  pToRelease = 0;\n  pgnoOvfl = 0;\n  pBt = pPage->pBt;\n\n  /* At this point variables should be set as follows:\n  **\n  **   nPayload           Total payload size in bytes\n  **   pPayload           Begin writing payload here\n  **   spaceLeft          Space available at pPayload.  If nPayload>spaceLeft,\n  **                      that means content must spill into overflow pages.\n  **   *pnSize            Size of the local cell (not counting overflow pages)\n  **   pPrior             Where to write the pgno of the first overflow page\n  **\n  ** Use a call to btreeParseCellPtr() to verify that the values above\n  ** were computed correctly.\n  */\n#ifdef SQLITE_DEBUG\n  {\n    CellInfo info;\n    pPage->xParseCell(pPage, pCell, &info);\n    assert( nHeader==(int)(info.pPayload - pCell) );\n    assert( info.nKey==pX->nKey );\n    assert( *pnSize == info.nSize );\n    assert( spaceLeft == info.nLocal );\n  }\n#endif\n\n  /* Write the payload into the local Cell and any extra into overflow pages */\n  while( 1 ){\n    n = nPayload;\n    if( n>spaceLeft ) n = spaceLeft;\n\n    /* If pToRelease is not zero than pPayload points into the data area\n    ** of pToRelease.  Make sure pToRelease is still writeable. */\n    assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n    /* If pPayload is part of the data area of pPage, then make sure pPage\n    ** is still writeable */\n    assert( pPayload<pPage->aData || pPayload>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n    if( nSrc>=n ){\n      memcpy(pPayload, pSrc, n);\n    }else if( nSrc>0 ){\n      n = nSrc;\n      memcpy(pPayload, pSrc, n);\n    }else{\n      memset(pPayload, 0, n);\n    }\n    nPayload -= n;\n    if( nPayload<=0 ) break;\n    pPayload += n;\n    pSrc += n;\n    nSrc -= n;\n    spaceLeft -= n;\n    if( spaceLeft==0 ){\n      MemPage *pOvfl = 0;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */\n      if( pBt->autoVacuum ){\n        do{\n          pgnoOvfl++;\n        } while( \n          PTRMAP_ISPAGE(pBt, pgnoOvfl) || pgnoOvfl==PENDING_BYTE_PAGE(pBt) \n        );\n      }\n#endif\n      rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      /* If the database supports auto-vacuum, and the second or subsequent\n      ** overflow page is being allocated, add an entry to the pointer-map\n      ** for that page now. \n      **\n      ** If this is the first overflow page, then write a partial entry \n      ** to the pointer-map. If we write nothing to this pointer-map slot,\n      ** then the optimistic overflow chain processing in clearCell()\n      ** may misinterpret the uninitialized values and delete the\n      ** wrong pages from the database.\n      */\n      if( pBt->autoVacuum && rc==SQLITE_OK ){\n        u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);\n        ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);\n        if( rc ){\n          releasePage(pOvfl);\n        }\n      }\n#endif\n      if( rc ){\n        releasePage(pToRelease);\n        return rc;\n      }\n\n      /* If pToRelease is not zero than pPrior points into the data area\n      ** of pToRelease.  Make sure pToRelease is still writeable. */\n      assert( pToRelease==0 || sqlite3PagerIswriteable(pToRelease->pDbPage) );\n\n      /* If pPrior is part of the data area of pPage, then make sure pPage\n      ** is still writeable */\n      assert( pPrior<pPage->aData || pPrior>=&pPage->aData[pBt->pageSize]\n            || sqlite3PagerIswriteable(pPage->pDbPage) );\n\n      put4byte(pPrior, pgnoOvfl);\n      releasePage(pToRelease);\n      pToRelease = pOvfl;\n      pPrior = pOvfl->aData;\n      put4byte(pPrior, 0);\n      pPayload = &pOvfl->aData[4];\n      spaceLeft = pBt->usableSize - 4;\n    }\n  }\n  releasePage(pToRelease);\n  return SQLITE_OK;\n}\n\n/*\n** Remove the i-th cell from pPage.  This routine effects pPage only.\n** The cell content is not freed or deallocated.  It is assumed that\n** the cell content has been copied someplace else.  This routine just\n** removes the reference to the cell from pPage.\n**\n** \"sz\" must be the number of bytes in the cell.\n*/\nstatic void dropCell(MemPage *pPage, int idx, int sz, int *pRC){\n  u32 pc;         /* Offset to cell content of cell being deleted */\n  u8 *data;       /* pPage->aData */\n  u8 *ptr;        /* Used to move bytes around within data[] */\n  int rc;         /* The return code */\n  int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */\n\n  if( *pRC ) return;\n  assert( idx>=0 && idx<pPage->nCell );\n  assert( CORRUPT_DB || sz==cellSize(pPage, idx) );\n  assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  data = pPage->aData;\n  ptr = &pPage->aCellIdx[2*idx];\n  pc = get2byte(ptr);\n  hdr = pPage->hdrOffset;\n  testcase( pc==get2byte(&data[hdr+5]) );\n  testcase( pc+sz==pPage->pBt->usableSize );\n  if( pc+sz > pPage->pBt->usableSize ){\n    *pRC = SQLITE_CORRUPT_BKPT;\n    return;\n  }\n  rc = freeSpace(pPage, pc, sz);\n  if( rc ){\n    *pRC = rc;\n    return;\n  }\n  pPage->nCell--;\n  if( pPage->nCell==0 ){\n    memset(&data[hdr+1], 0, 4);\n    data[hdr+7] = 0;\n    put2byte(&data[hdr+5], pPage->pBt->usableSize);\n    pPage->nFree = pPage->pBt->usableSize - pPage->hdrOffset\n                       - pPage->childPtrSize - 8;\n  }else{\n    memmove(ptr, ptr+2, 2*(pPage->nCell - idx));\n    put2byte(&data[hdr+3], pPage->nCell);\n    pPage->nFree += 2;\n  }\n}\n\n/*\n** Insert a new cell on pPage at cell index \"i\".  pCell points to the\n** content of the cell.\n**\n** If the cell content will fit on the page, then put it there.  If it\n** will not fit, then make a copy of the cell content into pTemp if\n** pTemp is not null.  Regardless of pTemp, allocate a new entry\n** in pPage->apOvfl[] and make it point to the cell content (either\n** in pTemp or the original pCell) and also record its index. \n** Allocating a new entry in pPage->aCell[] implies that \n** pPage->nOverflow is incremented.\n**\n** *pRC must be SQLITE_OK when this routine is called.\n*/\nstatic void insertCell(\n  MemPage *pPage,   /* Page into which we are copying */\n  int i,            /* New cell becomes the i-th cell of the page */\n  u8 *pCell,        /* Content of the new cell */\n  int sz,           /* Bytes of content in pCell */\n  u8 *pTemp,        /* Temp storage space for pCell, if needed */\n  Pgno iChild,      /* If non-zero, replace first 4 bytes with this value */\n  int *pRC          /* Read and write return code from here */\n){\n  int idx = 0;      /* Where to write new cell content in data[] */\n  int j;            /* Loop counter */\n  u8 *data;         /* The content of the whole page */\n  u8 *pIns;         /* The point in pPage->aCellIdx[] where no cell inserted */\n\n  assert( *pRC==SQLITE_OK );\n  assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );\n  assert( MX_CELL(pPage->pBt)<=10921 );\n  assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB );\n  assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) );\n  assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) );\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  /* The cell should normally be sized correctly.  However, when moving a\n  ** malformed cell from a leaf page to an interior page, if the cell size\n  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size\n  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence\n  ** the term after the || in the following assert(). */\n  assert( sz==pPage->xCellSize(pPage, pCell) || (sz==8 && iChild>0) );\n  if( pPage->nOverflow || sz+2>pPage->nFree ){\n    if( pTemp ){\n      memcpy(pTemp, pCell, sz);\n      pCell = pTemp;\n    }\n    if( iChild ){\n      put4byte(pCell, iChild);\n    }\n    j = pPage->nOverflow++;\n    /* Comparison against ArraySize-1 since we hold back one extra slot\n    ** as a contingency.  In other words, never need more than 3 overflow\n    ** slots but 4 are allocated, just to be safe. */\n    assert( j < ArraySize(pPage->apOvfl)-1 );\n    pPage->apOvfl[j] = pCell;\n    pPage->aiOvfl[j] = (u16)i;\n\n    /* When multiple overflows occur, they are always sequential and in\n    ** sorted order.  This invariants arise because multiple overflows can\n    ** only occur when inserting divider cells into the parent page during\n    ** balancing, and the dividers are adjacent and sorted.\n    */\n    assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */\n    assert( j==0 || i==pPage->aiOvfl[j-1]+1 );   /* Overflows are sequential */\n  }else{\n    int rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n    assert( sqlite3PagerIswriteable(pPage->pDbPage) );\n    data = pPage->aData;\n    assert( &data[pPage->cellOffset]==pPage->aCellIdx );\n    rc = allocateSpace(pPage, sz, &idx);\n    if( rc ){ *pRC = rc; return; }\n    /* The allocateSpace() routine guarantees the following properties\n    ** if it returns successfully */\n    assert( idx >= 0 );\n    assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );\n    assert( idx+sz <= (int)pPage->pBt->usableSize );\n    pPage->nFree -= (u16)(2 + sz);\n    memcpy(&data[idx], pCell, sz);\n    if( iChild ){\n      put4byte(&data[idx], iChild);\n    }\n    pIns = pPage->aCellIdx + i*2;\n    memmove(pIns+2, pIns, 2*(pPage->nCell - i));\n    put2byte(pIns, idx);\n    pPage->nCell++;\n    /* increment the cell count */\n    if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;\n    assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell );\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pPage->pBt->autoVacuum ){\n      /* The cell may contain a pointer to an overflow page. If so, write\n      ** the entry for the overflow page into the pointer map.\n      */\n      ptrmapPutOvflPtr(pPage, pCell, pRC);\n    }\n#endif\n  }\n}\n\n/*\n** A CellArray object contains a cache of pointers and sizes for a\n** consecutive sequence of cells that might be held on multiple pages.\n*/\ntypedef struct CellArray CellArray;\nstruct CellArray {\n  int nCell;              /* Number of cells in apCell[] */\n  MemPage *pRef;          /* Reference page */\n  u8 **apCell;            /* All cells begin balanced */\n  u16 *szCell;            /* Local size of all cells in apCell[] */\n};\n\n/*\n** Make sure the cell sizes at idx, idx+1, ..., idx+N-1 have been\n** computed.\n*/\nstatic void populateCellCache(CellArray *p, int idx, int N){\n  assert( idx>=0 && idx+N<=p->nCell );\n  while( N>0 ){\n    assert( p->apCell[idx]!=0 );\n    if( p->szCell[idx]==0 ){\n      p->szCell[idx] = p->pRef->xCellSize(p->pRef, p->apCell[idx]);\n    }else{\n      assert( CORRUPT_DB ||\n              p->szCell[idx]==p->pRef->xCellSize(p->pRef, p->apCell[idx]) );\n    }\n    idx++;\n    N--;\n  }\n}\n\n/*\n** Return the size of the Nth element of the cell array\n*/\nstatic SQLITE_NOINLINE u16 computeCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  assert( p->szCell[N]==0 );\n  p->szCell[N] = p->pRef->xCellSize(p->pRef, p->apCell[N]);\n  return p->szCell[N];\n}\nstatic u16 cachedCellSize(CellArray *p, int N){\n  assert( N>=0 && N<p->nCell );\n  if( p->szCell[N] ) return p->szCell[N];\n  return computeCellSize(p, N);\n}\n\n/*\n** Array apCell[] contains pointers to nCell b-tree page cells. The \n** szCell[] array contains the size in bytes of each cell. This function\n** replaces the current contents of page pPg with the contents of the cell\n** array.\n**\n** Some of the cells in apCell[] may currently be stored in pPg. This\n** function works around problems caused by this by making a copy of any \n** such cells before overwriting the page data.\n**\n** The MemPage.nFree field is invalidated by this function. It is the \n** responsibility of the caller to set it correctly.\n*/\nstatic int rebuildPage(\n  MemPage *pPg,                   /* Edit this page */\n  int nCell,                      /* Final number of cells on page */\n  u8 **apCell,                    /* Array of cells */\n  u16 *szCell                     /* Array of cell sizes */\n){\n  const int hdr = pPg->hdrOffset;          /* Offset of header on pPg */\n  u8 * const aData = pPg->aData;           /* Pointer to data for pPg */\n  const int usableSize = pPg->pBt->usableSize;\n  u8 * const pEnd = &aData[usableSize];\n  int i;\n  u8 *pCellptr = pPg->aCellIdx;\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  u8 *pData;\n\n  i = get2byte(&aData[hdr+5]);\n  memcpy(&pTmp[i], &aData[i], usableSize - i);\n\n  pData = pEnd;\n  for(i=0; i<nCell; i++){\n    u8 *pCell = apCell[i];\n    if( SQLITE_WITHIN(pCell,aData,pEnd) ){\n      pCell = &pTmp[pCell - aData];\n    }\n    pData -= szCell[i];\n    put2byte(pCellptr, (pData - aData));\n    pCellptr += 2;\n    if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;\n    memcpy(pData, pCell, szCell[i]);\n    assert( szCell[i]==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );\n    testcase( szCell[i]!=pPg->xCellSize(pPg,pCell) );\n  }\n\n  /* The pPg->nFree field is now set incorrectly. The caller will fix it. */\n  pPg->nCell = nCell;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+1], 0);\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n  aData[hdr+7] = 0x00;\n  return SQLITE_OK;\n}\n\n/*\n** Array apCell[] contains nCell pointers to b-tree cells. Array szCell\n** contains the size in bytes of each such cell. This function attempts to \n** add the cells stored in the array to page pPg. If it cannot (because \n** the page needs to be defragmented before the cells will fit), non-zero\n** is returned. Otherwise, if the cells are added successfully, zero is\n** returned.\n**\n** Argument pCellptr points to the first entry in the cell-pointer array\n** (part of page pPg) to populate. After cell apCell[0] is written to the\n** page body, a 16-bit offset is written to pCellptr. And so on, for each\n** cell in the array. It is the responsibility of the caller to ensure\n** that it is safe to overwrite this part of the cell-pointer array.\n**\n** When this function is called, *ppData points to the start of the \n** content area on page pPg. If the size of the content area is extended,\n** *ppData is updated to point to the new start of the content area\n** before returning.\n**\n** Finally, argument pBegin points to the byte immediately following the\n** end of the space required by this page for the cell-pointer area (for\n** all cells - not just those inserted by the current call). If the content\n** area must be extended to before this point in order to accomodate all\n** cells in apCell[], then the cells do not fit and non-zero is returned.\n*/\nstatic int pageInsertArray(\n  MemPage *pPg,                   /* Page to add cells to */\n  u8 *pBegin,                     /* End of cell-pointer array */\n  u8 **ppData,                    /* IN/OUT: Page content -area pointer */\n  u8 *pCellptr,                   /* Pointer to cell-pointer area */\n  int iFirst,                     /* Index of first cell to add */\n  int nCell,                      /* Number of cells to add to pPg */\n  CellArray *pCArray              /* Array of cells */\n){\n  int i;\n  u8 *aData = pPg->aData;\n  u8 *pData = *ppData;\n  int iEnd = iFirst + nCell;\n  assert( CORRUPT_DB || pPg->hdrOffset==0 );    /* Never called on page 1 */\n  for(i=iFirst; i<iEnd; i++){\n    int sz, rc;\n    u8 *pSlot;\n    sz = cachedCellSize(pCArray, i);\n    if( (aData[1]==0 && aData[2]==0) || (pSlot = pageFindSlot(pPg,sz,&rc))==0 ){\n      if( (pData - pBegin)<sz ) return 1;\n      pData -= sz;\n      pSlot = pData;\n    }\n    /* pSlot and pCArray->apCell[i] will never overlap on a well-formed\n    ** database.  But they might for a corrupt database.  Hence use memmove()\n    ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */\n    assert( (pSlot+sz)<=pCArray->apCell[i]\n         || pSlot>=(pCArray->apCell[i]+sz)\n         || CORRUPT_DB );\n    memmove(pSlot, pCArray->apCell[i], sz);\n    put2byte(pCellptr, (pSlot - aData));\n    pCellptr += 2;\n  }\n  *ppData = pData;\n  return 0;\n}\n\n/*\n** Array apCell[] contains nCell pointers to b-tree cells. Array szCell \n** contains the size in bytes of each such cell. This function adds the\n** space associated with each cell in the array that is currently stored \n** within the body of pPg to the pPg free-list. The cell-pointers and other\n** fields of the page are not updated.\n**\n** This function returns the total number of cells added to the free-list.\n*/\nstatic int pageFreeArray(\n  MemPage *pPg,                   /* Page to edit */\n  int iFirst,                     /* First cell to delete */\n  int nCell,                      /* Cells to delete */\n  CellArray *pCArray              /* Array of cells */\n){\n  u8 * const aData = pPg->aData;\n  u8 * const pEnd = &aData[pPg->pBt->usableSize];\n  u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];\n  int nRet = 0;\n  int i;\n  int iEnd = iFirst + nCell;\n  u8 *pFree = 0;\n  int szFree = 0;\n\n  for(i=iFirst; i<iEnd; i++){\n    u8 *pCell = pCArray->apCell[i];\n    if( SQLITE_WITHIN(pCell, pStart, pEnd) ){\n      int sz;\n      /* No need to use cachedCellSize() here.  The sizes of all cells that\n      ** are to be freed have already been computing while deciding which\n      ** cells need freeing */\n      sz = pCArray->szCell[i];  assert( sz>0 );\n      if( pFree!=(pCell + sz) ){\n        if( pFree ){\n          assert( pFree>aData && (pFree - aData)<65536 );\n          freeSpace(pPg, (u16)(pFree - aData), szFree);\n        }\n        pFree = pCell;\n        szFree = sz;\n        if( pFree+sz>pEnd ) return 0;\n      }else{\n        pFree = pCell;\n        szFree += sz;\n      }\n      nRet++;\n    }\n  }\n  if( pFree ){\n    assert( pFree>aData && (pFree - aData)<65536 );\n    freeSpace(pPg, (u16)(pFree - aData), szFree);\n  }\n  return nRet;\n}\n\n/*\n** apCell[] and szCell[] contains pointers to and sizes of all cells in the\n** pages being balanced.  The current page, pPg, has pPg->nCell cells starting\n** with apCell[iOld].  After balancing, this page should hold nNew cells\n** starting at apCell[iNew].\n**\n** This routine makes the necessary adjustments to pPg so that it contains\n** the correct cells after being balanced.\n**\n** The pPg->nFree field is invalid when this function returns. It is the\n** responsibility of the caller to set it correctly.\n*/\nstatic int editPage(\n  MemPage *pPg,                   /* Edit this page */\n  int iOld,                       /* Index of first cell currently on page */\n  int iNew,                       /* Index of new first cell on page */\n  int nNew,                       /* Final number of cells on page */\n  CellArray *pCArray              /* Array of cells and sizes */\n){\n  u8 * const aData = pPg->aData;\n  const int hdr = pPg->hdrOffset;\n  u8 *pBegin = &pPg->aCellIdx[nNew * 2];\n  int nCell = pPg->nCell;       /* Cells stored on pPg */\n  u8 *pData;\n  u8 *pCellptr;\n  int i;\n  int iOldEnd = iOld + pPg->nCell + pPg->nOverflow;\n  int iNewEnd = iNew + nNew;\n\n#ifdef SQLITE_DEBUG\n  u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);\n  memcpy(pTmp, aData, pPg->pBt->usableSize);\n#endif\n\n  /* Remove cells from the start and end of the page */\n  if( iOld<iNew ){\n    int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray);\n    memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);\n    nCell -= nShift;\n  }\n  if( iNewEnd < iOldEnd ){\n    nCell -= pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);\n  }\n\n  pData = &aData[get2byteNotZero(&aData[hdr+5])];\n  if( pData<pBegin ) goto editpage_fail;\n\n  /* Add cells to the start of the page */\n  if( iNew<iOld ){\n    int nAdd = MIN(nNew,iOld-iNew);\n    assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );\n    pCellptr = pPg->aCellIdx;\n    memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);\n    if( pageInsertArray(\n          pPg, pBegin, &pData, pCellptr,\n          iNew, nAdd, pCArray\n    ) ) goto editpage_fail;\n    nCell += nAdd;\n  }\n\n  /* Add any overflow cells */\n  for(i=0; i<pPg->nOverflow; i++){\n    int iCell = (iOld + pPg->aiOvfl[i]) - iNew;\n    if( iCell>=0 && iCell<nNew ){\n      pCellptr = &pPg->aCellIdx[iCell * 2];\n      memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);\n      nCell++;\n      if( pageInsertArray(\n            pPg, pBegin, &pData, pCellptr,\n            iCell+iNew, 1, pCArray\n      ) ) goto editpage_fail;\n    }\n  }\n\n  /* Append cells to the end of the page */\n  pCellptr = &pPg->aCellIdx[nCell*2];\n  if( pageInsertArray(\n        pPg, pBegin, &pData, pCellptr,\n        iNew+nCell, nNew-nCell, pCArray\n  ) ) goto editpage_fail;\n\n  pPg->nCell = nNew;\n  pPg->nOverflow = 0;\n\n  put2byte(&aData[hdr+3], pPg->nCell);\n  put2byte(&aData[hdr+5], pData - aData);\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<nNew && !CORRUPT_DB; i++){\n    u8 *pCell = pCArray->apCell[i+iNew];\n    int iOff = get2byteAligned(&pPg->aCellIdx[i*2]);\n    if( SQLITE_WITHIN(pCell, aData, &aData[pPg->pBt->usableSize]) ){\n      pCell = &pTmp[pCell - aData];\n    }\n    assert( 0==memcmp(pCell, &aData[iOff],\n            pCArray->pRef->xCellSize(pCArray->pRef, pCArray->apCell[i+iNew])) );\n  }\n#endif\n\n  return SQLITE_OK;\n editpage_fail:\n  /* Unable to edit this page. Rebuild it from scratch instead. */\n  populateCellCache(pCArray, iNew, nNew);\n  return rebuildPage(pPg, nNew, &pCArray->apCell[iNew], &pCArray->szCell[iNew]);\n}\n\n/*\n** The following parameters determine how many adjacent pages get involved\n** in a balancing operation.  NN is the number of neighbors on either side\n** of the page that participate in the balancing operation.  NB is the\n** total number of pages that participate, including the target page and\n** NN neighbors on either side.\n**\n** The minimum value of NN is 1 (of course).  Increasing NN above 1\n** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance\n** in exchange for a larger degradation in INSERT and UPDATE performance.\n** The value of NN appears to give the best results overall.\n*/\n#define NN 1             /* Number of neighbors on either side of pPage */\n#define NB (NN*2+1)      /* Total pages involved in the balance */\n\n\n#ifndef SQLITE_OMIT_QUICKBALANCE\n/*\n** This version of balance() handles the common special case where\n** a new entry is being inserted on the extreme right-end of the\n** tree, in other words, when the new entry will become the largest\n** entry in the tree.\n**\n** Instead of trying to balance the 3 right-most leaf pages, just add\n** a new page to the right-hand side and put the one new entry in\n** that page.  This leaves the right side of the tree somewhat\n** unbalanced.  But odds are that we will be inserting new entries\n** at the end soon afterwards so the nearly empty page will quickly\n** fill up.  On average.\n**\n** pPage is the leaf page which is the right-most page in the tree.\n** pParent is its parent.  pPage must have a single overflow entry\n** which is also the right-most entry on the page.\n**\n** The pSpace buffer is used to store a temporary copy of the divider\n** cell that will be inserted into pParent. Such a cell consists of a 4\n** byte page number followed by a variable length integer. In other\n** words, at most 13 bytes. Hence the pSpace buffer must be at\n** least 13 bytes in size.\n*/\nstatic int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){\n  BtShared *const pBt = pPage->pBt;    /* B-Tree Database */\n  MemPage *pNew;                       /* Newly allocated page */\n  int rc;                              /* Return Code */\n  Pgno pgnoNew;                        /* Page number of pNew */\n\n  assert( sqlite3_mutex_held(pPage->pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  assert( pPage->nOverflow==1 );\n\n  /* This error condition is now caught prior to reaching this function */\n  if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;\n\n  /* Allocate a new page. This page will become the right-sibling of \n  ** pPage. Make the parent page writable, so that the new divider cell\n  ** may be inserted. If both these operations are successful, proceed.\n  */\n  rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);\n\n  if( rc==SQLITE_OK ){\n\n    u8 *pOut = &pSpace[4];\n    u8 *pCell = pPage->apOvfl[0];\n    u16 szCell = pPage->xCellSize(pPage, pCell);\n    u8 *pStop;\n\n    assert( sqlite3PagerIswriteable(pNew->pDbPage) );\n    assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );\n    zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);\n    rc = rebuildPage(pNew, 1, &pCell, &szCell);\n    if( NEVER(rc) ) return rc;\n    pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;\n\n    /* If this is an auto-vacuum database, update the pointer map\n    ** with entries for the new page, and any pointer from the \n    ** cell on the page to an overflow page. If either of these\n    ** operations fails, the return code is set, but the contents\n    ** of the parent page are still manipulated by thh code below.\n    ** That is Ok, at this point the parent page is guaranteed to\n    ** be marked as dirty. Returning an error code will cause a\n    ** rollback, undoing any changes made to the parent page.\n    */\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);\n      if( szCell>pNew->minLocal ){\n        ptrmapPutOvflPtr(pNew, pCell, &rc);\n      }\n    }\n  \n    /* Create a divider cell to insert into pParent. The divider cell\n    ** consists of a 4-byte page number (the page number of pPage) and\n    ** a variable length key value (which must be the same value as the\n    ** largest key on pPage).\n    **\n    ** To find the largest key value on pPage, first find the right-most \n    ** cell on pPage. The first two fields of this cell are the \n    ** record-length (a variable length integer at most 32-bits in size)\n    ** and the key value (a variable length integer, may have any value).\n    ** The first of the while(...) loops below skips over the record-length\n    ** field. The second while(...) loop copies the key value from the\n    ** cell on pPage into the pSpace buffer.\n    */\n    pCell = findCell(pPage, pPage->nCell-1);\n    pStop = &pCell[9];\n    while( (*(pCell++)&0x80) && pCell<pStop );\n    pStop = &pCell[9];\n    while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop );\n\n    /* Insert the new divider cell into pParent. */\n    if( rc==SQLITE_OK ){\n      insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace),\n                   0, pPage->pgno, &rc);\n    }\n\n    /* Set the right-child pointer of pParent to point to the new page. */\n    put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);\n  \n    /* Release the reference to the new page. */\n    releasePage(pNew);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_OMIT_QUICKBALANCE */\n\n#if 0\n/*\n** This function does not contribute anything to the operation of SQLite.\n** it is sometimes activated temporarily while debugging code responsible \n** for setting pointer-map entries.\n*/\nstatic int ptrmapCheckPages(MemPage **apPage, int nPage){\n  int i, j;\n  for(i=0; i<nPage; i++){\n    Pgno n;\n    u8 e;\n    MemPage *pPage = apPage[i];\n    BtShared *pBt = pPage->pBt;\n    assert( pPage->isInit );\n\n    for(j=0; j<pPage->nCell; j++){\n      CellInfo info;\n      u8 *z;\n     \n      z = findCell(pPage, j);\n      pPage->xParseCell(pPage, z, &info);\n      if( info.nLocal<info.nPayload ){\n        Pgno ovfl = get4byte(&z[info.nSize-4]);\n        ptrmapGet(pBt, ovfl, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );\n      }\n      if( !pPage->leaf ){\n        Pgno child = get4byte(z);\n        ptrmapGet(pBt, child, &e, &n);\n        assert( n==pPage->pgno && e==PTRMAP_BTREE );\n      }\n    }\n    if( !pPage->leaf ){\n      Pgno child = get4byte(&pPage->aData[pPage->hdrOffset+8]);\n      ptrmapGet(pBt, child, &e, &n);\n      assert( n==pPage->pgno && e==PTRMAP_BTREE );\n    }\n  }\n  return 1;\n}\n#endif\n\n/*\n** This function is used to copy the contents of the b-tree node stored \n** on page pFrom to page pTo. If page pFrom was not a leaf page, then\n** the pointer-map entries for each child page are updated so that the\n** parent page stored in the pointer map is page pTo. If pFrom contained\n** any cells with overflow page pointers, then the corresponding pointer\n** map entries are also updated so that the parent page is page pTo.\n**\n** If pFrom is currently carrying any overflow cells (entries in the\n** MemPage.apOvfl[] array), they are not copied to pTo. \n**\n** Before returning, page pTo is reinitialized using btreeInitPage().\n**\n** The performance of this function is not critical. It is only used by \n** the balance_shallower() and balance_deeper() procedures, neither of\n** which are called often under normal circumstances.\n*/\nstatic void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){\n  if( (*pRC)==SQLITE_OK ){\n    BtShared * const pBt = pFrom->pBt;\n    u8 * const aFrom = pFrom->aData;\n    u8 * const aTo = pTo->aData;\n    int const iFromHdr = pFrom->hdrOffset;\n    int const iToHdr = ((pTo->pgno==1) ? 100 : 0);\n    int rc;\n    int iData;\n  \n  \n    assert( pFrom->isInit );\n    assert( pFrom->nFree>=iToHdr );\n    assert( get2byte(&aFrom[iFromHdr+5]) <= (int)pBt->usableSize );\n  \n    /* Copy the b-tree node content from page pFrom to page pTo. */\n    iData = get2byte(&aFrom[iFromHdr+5]);\n    memcpy(&aTo[iData], &aFrom[iData], pBt->usableSize-iData);\n    memcpy(&aTo[iToHdr], &aFrom[iFromHdr], pFrom->cellOffset + 2*pFrom->nCell);\n  \n    /* Reinitialize page pTo so that the contents of the MemPage structure\n    ** match the new data. The initialization of pTo can actually fail under\n    ** fairly obscure circumstances, even though it is a copy of initialized \n    ** page pFrom.\n    */\n    pTo->isInit = 0;\n    rc = btreeInitPage(pTo);\n    if( rc!=SQLITE_OK ){\n      *pRC = rc;\n      return;\n    }\n  \n    /* If this is an auto-vacuum database, update the pointer-map entries\n    ** for any b-tree or overflow pages that pTo now contains the pointers to.\n    */\n    if( ISAUTOVACUUM ){\n      *pRC = setChildPtrmaps(pTo);\n    }\n  }\n}\n\n/*\n** This routine redistributes cells on the iParentIdx'th child of pParent\n** (hereafter \"the page\") and up to 2 siblings so that all pages have about the\n** same amount of free space. Usually a single sibling on either side of the\n** page are used in the balancing, though both siblings might come from one\n** side if the page is the first or last child of its parent. If the page \n** has fewer than 2 siblings (something which can only happen if the page\n** is a root page or a child of a root page) then all available siblings\n** participate in the balancing.\n**\n** The number of siblings of the page might be increased or decreased by \n** one or two in an effort to keep pages nearly full but not over full. \n**\n** Note that when this routine is called, some of the cells on the page\n** might not actually be stored in MemPage.aData[]. This can happen\n** if the page is overfull. This routine ensures that all cells allocated\n** to the page and its siblings fit into MemPage.aData[] before returning.\n**\n** In the course of balancing the page and its siblings, cells may be\n** inserted into or removed from the parent page (pParent). Doing so\n** may cause the parent page to become overfull or underfull. If this\n** happens, it is the responsibility of the caller to invoke the correct\n** balancing routine to fix this problem (see the balance() routine). \n**\n** If this routine fails for any reason, it might leave the database\n** in a corrupted state. So if this routine fails, the database should\n** be rolled back.\n**\n** The third argument to this function, aOvflSpace, is a pointer to a\n** buffer big enough to hold one page. If while inserting cells into the parent\n** page (pParent) the parent page becomes overfull, this buffer is\n** used to store the parent's overflow cells. Because this function inserts\n** a maximum of four divider cells into the parent page, and the maximum\n** size of a cell stored within an internal node is always less than 1/4\n** of the page-size, the aOvflSpace[] buffer is guaranteed to be large\n** enough for all overflow cells.\n**\n** If aOvflSpace is set to a null pointer, this function returns \n** SQLITE_NOMEM.\n*/\nstatic int balance_nonroot(\n  MemPage *pParent,               /* Parent page of siblings being balanced */\n  int iParentIdx,                 /* Index of \"the page\" in pParent */\n  u8 *aOvflSpace,                 /* page-size bytes of space for parent ovfl */\n  int isRoot,                     /* True if pParent is a root-page */\n  int bBulk                       /* True if this call is part of a bulk load */\n){\n  BtShared *pBt;               /* The whole database */\n  int nMaxCells = 0;           /* Allocated size of apCell, szCell, aFrom. */\n  int nNew = 0;                /* Number of pages in apNew[] */\n  int nOld;                    /* Number of pages in apOld[] */\n  int i, j, k;                 /* Loop counters */\n  int nxDiv;                   /* Next divider slot in pParent->aCell[] */\n  int rc = SQLITE_OK;          /* The return code */\n  u16 leafCorrection;          /* 4 if pPage is a leaf.  0 if not */\n  int leafData;                /* True if pPage is a leaf of a LEAFDATA tree */\n  int usableSpace;             /* Bytes in pPage beyond the header */\n  int pageFlags;               /* Value of pPage->aData[0] */\n  int iSpace1 = 0;             /* First unused byte of aSpace1[] */\n  int iOvflSpace = 0;          /* First unused byte of aOvflSpace[] */\n  int szScratch;               /* Size of scratch memory requested */\n  MemPage *apOld[NB];          /* pPage and up to two siblings */\n  MemPage *apNew[NB+2];        /* pPage and up to NB siblings after balancing */\n  u8 *pRight;                  /* Location in parent of right-sibling pointer */\n  u8 *apDiv[NB-1];             /* Divider cells in pParent */\n  int cntNew[NB+2];            /* Index in b.paCell[] of cell after i-th page */\n  int cntOld[NB+2];            /* Old index in b.apCell[] */\n  int szNew[NB+2];             /* Combined size of cells placed on i-th page */\n  u8 *aSpace1;                 /* Space for copies of dividers cells */\n  Pgno pgno;                   /* Temp var to store a page number in */\n  u8 abDone[NB+2];             /* True after i'th new page is populated */\n  Pgno aPgno[NB+2];            /* Page numbers of new pages before shuffling */\n  Pgno aPgOrder[NB+2];         /* Copy of aPgno[] used for sorting pages */\n  u16 aPgFlags[NB+2];          /* flags field of new pages before shuffling */\n  CellArray b;                  /* Parsed information on cells being balanced */\n\n  memset(abDone, 0, sizeof(abDone));\n  b.nCell = 0;\n  b.apCell = 0;\n  pBt = pParent->pBt;\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n\n#if 0\n  TRACE((\"BALANCE: begin page %d child of %d\\n\", pPage->pgno, pParent->pgno));\n#endif\n\n  /* At this point pParent may have at most one overflow cell. And if\n  ** this overflow cell is present, it must be the cell with \n  ** index iParentIdx. This scenario comes about when this function\n  ** is called (indirectly) from sqlite3BtreeDelete().\n  */\n  assert( pParent->nOverflow==0 || pParent->nOverflow==1 );\n  assert( pParent->nOverflow==0 || pParent->aiOvfl[0]==iParentIdx );\n\n  if( !aOvflSpace ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* Find the sibling pages to balance. Also locate the cells in pParent \n  ** that divide the siblings. An attempt is made to find NN siblings on \n  ** either side of pPage. More siblings are taken from one side, however, \n  ** if there are fewer than NN siblings on the other side. If pParent\n  ** has NB or fewer children then all children of pParent are taken.  \n  **\n  ** This loop also drops the divider cells from the parent page. This\n  ** way, the remainder of the function does not have to deal with any\n  ** overflow cells in the parent page, since if any existed they will\n  ** have already been removed.\n  */\n  i = pParent->nOverflow + pParent->nCell;\n  if( i<2 ){\n    nxDiv = 0;\n  }else{\n    assert( bBulk==0 || bBulk==1 );\n    if( iParentIdx==0 ){                 \n      nxDiv = 0;\n    }else if( iParentIdx==i ){\n      nxDiv = i-2+bBulk;\n    }else{\n      nxDiv = iParentIdx-1;\n    }\n    i = 2-bBulk;\n  }\n  nOld = i+1;\n  if( (i+nxDiv-pParent->nOverflow)==pParent->nCell ){\n    pRight = &pParent->aData[pParent->hdrOffset+8];\n  }else{\n    pRight = findCell(pParent, i+nxDiv-pParent->nOverflow);\n  }\n  pgno = get4byte(pRight);\n  while( 1 ){\n    rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);\n    if( rc ){\n      memset(apOld, 0, (i+1)*sizeof(MemPage*));\n      goto balance_cleanup;\n    }\n    nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;\n    if( (i--)==0 ) break;\n\n    if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){\n      apDiv[i] = pParent->apOvfl[0];\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n      pParent->nOverflow = 0;\n    }else{\n      apDiv[i] = findCell(pParent, i+nxDiv-pParent->nOverflow);\n      pgno = get4byte(apDiv[i]);\n      szNew[i] = pParent->xCellSize(pParent, apDiv[i]);\n\n      /* Drop the cell from the parent page. apDiv[i] still points to\n      ** the cell within the parent, even though it has been dropped.\n      ** This is safe because dropping a cell only overwrites the first\n      ** four bytes of it, and this function does not need the first\n      ** four bytes of the divider cell. So the pointer is safe to use\n      ** later on.  \n      **\n      ** But not if we are in secure-delete mode. In secure-delete mode,\n      ** the dropCell() routine will overwrite the entire cell with zeroes.\n      ** In this case, temporarily copy the cell into the aOvflSpace[]\n      ** buffer. It will be copied out again as soon as the aSpace[] buffer\n      ** is allocated.  */\n      if( pBt->btsFlags & BTS_FAST_SECURE ){\n        int iOff;\n\n        iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);\n        if( (iOff+szNew[i])>(int)pBt->usableSize ){\n          rc = SQLITE_CORRUPT_BKPT;\n          memset(apOld, 0, (i+1)*sizeof(MemPage*));\n          goto balance_cleanup;\n        }else{\n          memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]);\n          apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData];\n        }\n      }\n      dropCell(pParent, i+nxDiv-pParent->nOverflow, szNew[i], &rc);\n    }\n  }\n\n  /* Make nMaxCells a multiple of 4 in order to preserve 8-byte\n  ** alignment */\n  nMaxCells = (nMaxCells + 3)&~3;\n\n  /*\n  ** Allocate space for memory structures\n  */\n  szScratch =\n       nMaxCells*sizeof(u8*)                       /* b.apCell */\n     + nMaxCells*sizeof(u16)                       /* b.szCell */\n     + pBt->pageSize;                              /* aSpace1 */\n\n  assert( szScratch<=6*(int)pBt->pageSize );\n  b.apCell = sqlite3StackAllocRaw(0, szScratch );\n  if( b.apCell==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto balance_cleanup;\n  }\n  b.szCell = (u16*)&b.apCell[nMaxCells];\n  aSpace1 = (u8*)&b.szCell[nMaxCells];\n  assert( EIGHT_BYTE_ALIGNMENT(aSpace1) );\n\n  /*\n  ** Load pointers to all cells on sibling pages and the divider cells\n  ** into the local b.apCell[] array.  Make copies of the divider cells\n  ** into space obtained from aSpace1[]. The divider cells have already\n  ** been removed from pParent.\n  **\n  ** If the siblings are on leaf pages, then the child pointers of the\n  ** divider cells are stripped from the cells before they are copied\n  ** into aSpace1[].  In this way, all cells in b.apCell[] are without\n  ** child pointers.  If siblings are not leaves, then all cell in\n  ** b.apCell[] include child pointers.  Either way, all cells in b.apCell[]\n  ** are alike.\n  **\n  ** leafCorrection:  4 if pPage is a leaf.  0 if pPage is not a leaf.\n  **       leafData:  1 if pPage holds key+data and pParent holds only keys.\n  */\n  b.pRef = apOld[0];\n  leafCorrection = b.pRef->leaf*4;\n  leafData = b.pRef->intKeyLeaf;\n  for(i=0; i<nOld; i++){\n    MemPage *pOld = apOld[i];\n    int limit = pOld->nCell;\n    u8 *aData = pOld->aData;\n    u16 maskPage = pOld->maskPage;\n    u8 *piCell = aData + pOld->cellOffset;\n    u8 *piEnd;\n\n    /* Verify that all sibling pages are of the same \"type\" (table-leaf,\n    ** table-interior, index-leaf, or index-interior).\n    */\n    if( pOld->aData[0]!=apOld[0]->aData[0] ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n\n    /* Load b.apCell[] with pointers to all cells in pOld.  If pOld\n    ** constains overflow cells, include them in the b.apCell[] array\n    ** in the correct spot.\n    **\n    ** Note that when there are multiple overflow cells, it is always the\n    ** case that they are sequential and adjacent.  This invariant arises\n    ** because multiple overflows can only occurs when inserting divider\n    ** cells into a parent on a prior balance, and divider cells are always\n    ** adjacent and are inserted in order.  There is an assert() tagged\n    ** with \"NOTE 1\" in the overflow cell insertion loop to prove this\n    ** invariant.\n    **\n    ** This must be done in advance.  Once the balance starts, the cell\n    ** offset section of the btree page will be overwritten and we will no\n    ** long be able to find the cells if a pointer to each cell is not saved\n    ** first.\n    */\n    memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));\n    if( pOld->nOverflow>0 ){\n      limit = pOld->aiOvfl[0];\n      for(j=0; j<limit; j++){\n        b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n        piCell += 2;\n        b.nCell++;\n      }\n      for(k=0; k<pOld->nOverflow; k++){\n        assert( k==0 || pOld->aiOvfl[k-1]+1==pOld->aiOvfl[k] );/* NOTE 1 */\n        b.apCell[b.nCell] = pOld->apOvfl[k];\n        b.nCell++;\n      }\n    }\n    piEnd = aData + pOld->cellOffset + 2*pOld->nCell;\n    while( piCell<piEnd ){\n      assert( b.nCell<nMaxCells );\n      b.apCell[b.nCell] = aData + (maskPage & get2byteAligned(piCell));\n      piCell += 2;\n      b.nCell++;\n    }\n\n    cntOld[i] = b.nCell;\n    if( i<nOld-1 && !leafData){\n      u16 sz = (u16)szNew[i];\n      u8 *pTemp;\n      assert( b.nCell<nMaxCells );\n      b.szCell[b.nCell] = sz;\n      pTemp = &aSpace1[iSpace1];\n      iSpace1 += sz;\n      assert( sz<=pBt->maxLocal+23 );\n      assert( iSpace1 <= (int)pBt->pageSize );\n      memcpy(pTemp, apDiv[i], sz);\n      b.apCell[b.nCell] = pTemp+leafCorrection;\n      assert( leafCorrection==0 || leafCorrection==4 );\n      b.szCell[b.nCell] = b.szCell[b.nCell] - leafCorrection;\n      if( !pOld->leaf ){\n        assert( leafCorrection==0 );\n        assert( pOld->hdrOffset==0 );\n        /* The right pointer of the child page pOld becomes the left\n        ** pointer of the divider cell */\n        memcpy(b.apCell[b.nCell], &pOld->aData[8], 4);\n      }else{\n        assert( leafCorrection==4 );\n        while( b.szCell[b.nCell]<4 ){\n          /* Do not allow any cells smaller than 4 bytes. If a smaller cell\n          ** does exist, pad it with 0x00 bytes. */\n          assert( b.szCell[b.nCell]==3 || CORRUPT_DB );\n          assert( b.apCell[b.nCell]==&aSpace1[iSpace1-3] || CORRUPT_DB );\n          aSpace1[iSpace1++] = 0x00;\n          b.szCell[b.nCell]++;\n        }\n      }\n      b.nCell++;\n    }\n  }\n\n  /*\n  ** Figure out the number of pages needed to hold all b.nCell cells.\n  ** Store this number in \"k\".  Also compute szNew[] which is the total\n  ** size of all cells on the i-th page and cntNew[] which is the index\n  ** in b.apCell[] of the cell that divides page i from page i+1.  \n  ** cntNew[k] should equal b.nCell.\n  **\n  ** Values computed by this block:\n  **\n  **           k: The total number of sibling pages\n  **    szNew[i]: Spaced used on the i-th sibling page.\n  **   cntNew[i]: Index in b.apCell[] and b.szCell[] for the first cell to\n  **              the right of the i-th sibling page.\n  ** usableSpace: Number of bytes of space available on each sibling.\n  ** \n  */\n  usableSpace = pBt->usableSize - 12 + leafCorrection;\n  for(i=0; i<nOld; i++){\n    MemPage *p = apOld[i];\n    szNew[i] = usableSpace - p->nFree;\n    for(j=0; j<p->nOverflow; j++){\n      szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);\n    }\n    cntNew[i] = cntOld[i];\n  }\n  k = nOld;\n  for(i=0; i<k; i++){\n    int sz;\n    while( szNew[i]>usableSpace ){\n      if( i+1>=k ){\n        k = i+2;\n        if( k>NB+2 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }\n        szNew[k-1] = 0;\n        cntNew[k-1] = b.nCell;\n      }\n      sz = 2 + cachedCellSize(&b, cntNew[i]-1);\n      szNew[i] -= sz;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] += sz;\n      cntNew[i]--;\n    }\n    while( cntNew[i]<b.nCell ){\n      sz = 2 + cachedCellSize(&b, cntNew[i]);\n      if( szNew[i]+sz>usableSpace ) break;\n      szNew[i] += sz;\n      cntNew[i]++;\n      if( !leafData ){\n        if( cntNew[i]<b.nCell ){\n          sz = 2 + cachedCellSize(&b, cntNew[i]);\n        }else{\n          sz = 0;\n        }\n      }\n      szNew[i+1] -= sz;\n    }\n    if( cntNew[i]>=b.nCell ){\n      k = i+1;\n    }else if( cntNew[i] <= (i>0 ? cntNew[i-1] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /*\n  ** The packing computed by the previous block is biased toward the siblings\n  ** on the left side (siblings with smaller keys). The left siblings are\n  ** always nearly full, while the right-most sibling might be nearly empty.\n  ** The next block of code attempts to adjust the packing of siblings to\n  ** get a better balance.\n  **\n  ** This adjustment is more than an optimization.  The packing above might\n  ** be so out of balance as to be illegal.  For example, the right-most\n  ** sibling might be completely empty.  This adjustment is not optional.\n  */\n  for(i=k-1; i>0; i--){\n    int szRight = szNew[i];  /* Size of sibling on the right */\n    int szLeft = szNew[i-1]; /* Size of sibling on the left */\n    int r;              /* Index of right-most cell in left sibling */\n    int d;              /* Index of first cell to the left of right sibling */\n\n    r = cntNew[i-1] - 1;\n    d = r + 1 - leafData;\n    (void)cachedCellSize(&b, d);\n    do{\n      assert( d<nMaxCells );\n      assert( r<nMaxCells );\n      (void)cachedCellSize(&b, r);\n      if( szRight!=0\n       && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){\n        break;\n      }\n      szRight += b.szCell[d] + 2;\n      szLeft -= b.szCell[r] + 2;\n      cntNew[i-1] = r;\n      r--;\n      d--;\n    }while( r>=0 );\n    szNew[i] = szRight;\n    szNew[i-1] = szLeft;\n    if( cntNew[i-1] <= (i>1 ? cntNew[i-2] : 0) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto balance_cleanup;\n    }\n  }\n\n  /* Sanity check:  For a non-corrupt database file one of the follwing\n  ** must be true:\n  **    (1) We found one or more cells (cntNew[0])>0), or\n  **    (2) pPage is a virtual root page.  A virtual root page is when\n  **        the real root page is page 1 and we are the only child of\n  **        that page.\n  */\n  assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) || CORRUPT_DB);\n  TRACE((\"BALANCE: old: %d(nc=%d) %d(nc=%d) %d(nc=%d)\\n\",\n    apOld[0]->pgno, apOld[0]->nCell,\n    nOld>=2 ? apOld[1]->pgno : 0, nOld>=2 ? apOld[1]->nCell : 0,\n    nOld>=3 ? apOld[2]->pgno : 0, nOld>=3 ? apOld[2]->nCell : 0\n  ));\n\n  /*\n  ** Allocate k new pages.  Reuse old pages where possible.\n  */\n  pageFlags = apOld[0]->aData[0];\n  for(i=0; i<k; i++){\n    MemPage *pNew;\n    if( i<nOld ){\n      pNew = apNew[i] = apOld[i];\n      apOld[i] = 0;\n      rc = sqlite3PagerWrite(pNew->pDbPage);\n      nNew++;\n      if( rc ) goto balance_cleanup;\n    }else{\n      assert( i>0 );\n      rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);\n      if( rc ) goto balance_cleanup;\n      zeroPage(pNew, pageFlags);\n      apNew[i] = pNew;\n      nNew++;\n      cntOld[i] = b.nCell;\n\n      /* Set the pointer-map entry for the new sibling page. */\n      if( ISAUTOVACUUM ){\n        ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);\n        if( rc!=SQLITE_OK ){\n          goto balance_cleanup;\n        }\n      }\n    }\n  }\n\n  /*\n  ** Reassign page numbers so that the new pages are in ascending order. \n  ** This helps to keep entries in the disk file in order so that a scan\n  ** of the table is closer to a linear scan through the file. That in turn \n  ** helps the operating system to deliver pages from the disk more rapidly.\n  **\n  ** An O(n^2) insertion sort algorithm is used, but since n is never more \n  ** than (NB+2) (a small constant), that should not be a problem.\n  **\n  ** When NB==3, this one optimization makes the database about 25% faster \n  ** for large insertions and deletions.\n  */\n  for(i=0; i<nNew; i++){\n    aPgOrder[i] = aPgno[i] = apNew[i]->pgno;\n    aPgFlags[i] = apNew[i]->pDbPage->flags;\n    for(j=0; j<i; j++){\n      if( aPgno[j]==aPgno[i] ){\n        /* This branch is taken if the set of sibling pages somehow contains\n        ** duplicate entries. This can happen if the database is corrupt. \n        ** It would be simpler to detect this as part of the loop below, but\n        ** we do the detection here in order to avoid populating the pager\n        ** cache with two separate objects associated with the same\n        ** page number.  */\n        assert( CORRUPT_DB );\n        rc = SQLITE_CORRUPT_BKPT;\n        goto balance_cleanup;\n      }\n    }\n  }\n  for(i=0; i<nNew; i++){\n    int iBest = 0;                /* aPgno[] index of page number to use */\n    for(j=1; j<nNew; j++){\n      if( aPgOrder[j]<aPgOrder[iBest] ) iBest = j;\n    }\n    pgno = aPgOrder[iBest];\n    aPgOrder[iBest] = 0xffffffff;\n    if( iBest!=i ){\n      if( iBest>i ){\n        sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, 0);\n      }\n      sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]);\n      apNew[i]->pgno = pgno;\n    }\n  }\n\n  TRACE((\"BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) \"\n         \"%d(%d nc=%d) %d(%d nc=%d)\\n\",\n    apNew[0]->pgno, szNew[0], cntNew[0],\n    nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,\n    nNew>=2 ? cntNew[1] - cntNew[0] - !leafData : 0,\n    nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,\n    nNew>=3 ? cntNew[2] - cntNew[1] - !leafData : 0,\n    nNew>=4 ? apNew[3]->pgno : 0, nNew>=4 ? szNew[3] : 0,\n    nNew>=4 ? cntNew[3] - cntNew[2] - !leafData : 0,\n    nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,\n    nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0\n  ));\n\n  assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  put4byte(pRight, apNew[nNew-1]->pgno);\n\n  /* If the sibling pages are not leaves, ensure that the right-child pointer\n  ** of the right-most new sibling page is set to the value that was \n  ** originally in the same field of the right-most old sibling page. */\n  if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){\n    MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];\n    memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);\n  }\n\n  /* Make any required updates to pointer map entries associated with \n  ** cells stored on sibling pages following the balance operation. Pointer\n  ** map entries associated with divider cells are set by the insertCell()\n  ** routine. The associated pointer map entries are:\n  **\n  **   a) if the cell contains a reference to an overflow chain, the\n  **      entry associated with the first page in the overflow chain, and\n  **\n  **   b) if the sibling pages are not leaves, the child page associated\n  **      with the cell.\n  **\n  ** If the sibling pages are not leaves, then the pointer map entry \n  ** associated with the right-child of each sibling may also need to be \n  ** updated. This happens below, after the sibling pages have been \n  ** populated, not here.\n  */\n  if( ISAUTOVACUUM ){\n    MemPage *pNew = apNew[0];\n    u8 *aOld = pNew->aData;\n    int cntOldNext = pNew->nCell + pNew->nOverflow;\n    int usableSize = pBt->usableSize;\n    int iNew = 0;\n    int iOld = 0;\n\n    for(i=0; i<b.nCell; i++){\n      u8 *pCell = b.apCell[i];\n      if( i==cntOldNext ){\n        MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];\n        cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;\n        aOld = pOld->aData;\n      }\n      if( i==cntNew[iNew] ){\n        pNew = apNew[++iNew];\n        if( !leafData ) continue;\n      }\n\n      /* Cell pCell is destined for new sibling page pNew. Originally, it\n      ** was either part of sibling page iOld (possibly an overflow cell), \n      ** or else the divider cell to the left of sibling page iOld. So,\n      ** if sibling page iOld had the same page number as pNew, and if\n      ** pCell really was a part of sibling page iOld (not a divider or\n      ** overflow cell), we can skip updating the pointer map entries.  */\n      if( iOld>=nNew\n       || pNew->pgno!=aPgno[iOld]\n       || !SQLITE_WITHIN(pCell,aOld,&aOld[usableSize])\n      ){\n        if( !leafCorrection ){\n          ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);\n        }\n        if( cachedCellSize(&b,i)>pNew->minLocal ){\n          ptrmapPutOvflPtr(pNew, pCell, &rc);\n        }\n        if( rc ) goto balance_cleanup;\n      }\n    }\n  }\n\n  /* Insert new divider cells into pParent. */\n  for(i=0; i<nNew-1; i++){\n    u8 *pCell;\n    u8 *pTemp;\n    int sz;\n    MemPage *pNew = apNew[i];\n    j = cntNew[i];\n\n    assert( j<nMaxCells );\n    assert( b.apCell[j]!=0 );\n    pCell = b.apCell[j];\n    sz = b.szCell[j] + leafCorrection;\n    pTemp = &aOvflSpace[iOvflSpace];\n    if( !pNew->leaf ){\n      memcpy(&pNew->aData[8], pCell, 4);\n    }else if( leafData ){\n      /* If the tree is a leaf-data tree, and the siblings are leaves, \n      ** then there is no divider cell in b.apCell[]. Instead, the divider \n      ** cell consists of the integer key for the right-most cell of \n      ** the sibling-page assembled above only.\n      */\n      CellInfo info;\n      j--;\n      pNew->xParseCell(pNew, b.apCell[j], &info);\n      pCell = pTemp;\n      sz = 4 + putVarint(&pCell[4], info.nKey);\n      pTemp = 0;\n    }else{\n      pCell -= 4;\n      /* Obscure case for non-leaf-data trees: If the cell at pCell was\n      ** previously stored on a leaf node, and its reported size was 4\n      ** bytes, then it may actually be smaller than this \n      ** (see btreeParseCellPtr(), 4 bytes is the minimum size of\n      ** any cell). But it is important to pass the correct size to \n      ** insertCell(), so reparse the cell now.\n      **\n      ** This can only happen for b-trees used to evaluate \"IN (SELECT ...)\"\n      ** and WITHOUT ROWID tables with exactly one column which is the\n      ** primary key.\n      */\n      if( b.szCell[j]==4 ){\n        assert(leafCorrection==4);\n        sz = pParent->xCellSize(pParent, pCell);\n      }\n    }\n    iOvflSpace += sz;\n    assert( sz<=pBt->maxLocal+23 );\n    assert( iOvflSpace <= (int)pBt->pageSize );\n    insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);\n    if( rc!=SQLITE_OK ) goto balance_cleanup;\n    assert( sqlite3PagerIswriteable(pParent->pDbPage) );\n  }\n\n  /* Now update the actual sibling pages. The order in which they are updated\n  ** is important, as this code needs to avoid disrupting any page from which\n  ** cells may still to be read. In practice, this means:\n  **\n  **  (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the left-hand sibling apNew[iPg-1] has been updated.\n  **\n  **  (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1])\n  **      then it is not safe to update page apNew[iPg] until after\n  **      the right-hand sibling apNew[iPg+1] has been updated.\n  **\n  ** If neither of the above apply, the page is safe to update.\n  **\n  ** The iPg value in the following loop starts at nNew-1 goes down\n  ** to 0, then back up to nNew-1 again, thus making two passes over\n  ** the pages.  On the initial downward pass, only condition (1) above\n  ** needs to be tested because (2) will always be true from the previous\n  ** step.  On the upward pass, both conditions are always true, so the\n  ** upwards pass simply processes pages that were missed on the downward\n  ** pass.\n  */\n  for(i=1-nNew; i<nNew; i++){\n    int iPg = i<0 ? -i : i;\n    assert( iPg>=0 && iPg<nNew );\n    if( abDone[iPg] ) continue;         /* Skip pages already processed */\n    if( i>=0                            /* On the upwards pass, or... */\n     || cntOld[iPg-1]>=cntNew[iPg-1]    /* Condition (1) is true */\n    ){\n      int iNew;\n      int iOld;\n      int nNewCell;\n\n      /* Verify condition (1):  If cells are moving left, update iPg\n      ** only after iPg-1 has already been updated. */\n      assert( iPg==0 || cntOld[iPg-1]>=cntNew[iPg-1] || abDone[iPg-1] );\n\n      /* Verify condition (2):  If cells are moving right, update iPg\n      ** only after iPg+1 has already been updated. */\n      assert( cntNew[iPg]>=cntOld[iPg] || abDone[iPg+1] );\n\n      if( iPg==0 ){\n        iNew = iOld = 0;\n        nNewCell = cntNew[0];\n      }else{\n        iOld = iPg<nOld ? (cntOld[iPg-1] + !leafData) : b.nCell;\n        iNew = cntNew[iPg-1] + !leafData;\n        nNewCell = cntNew[iPg] - iNew;\n      }\n\n      rc = editPage(apNew[iPg], iOld, iNew, nNewCell, &b);\n      if( rc ) goto balance_cleanup;\n      abDone[iPg]++;\n      apNew[iPg]->nFree = usableSpace-szNew[iPg];\n      assert( apNew[iPg]->nOverflow==0 );\n      assert( apNew[iPg]->nCell==nNewCell );\n    }\n  }\n\n  /* All pages have been processed exactly once */\n  assert( memcmp(abDone, \"\\01\\01\\01\\01\\01\", nNew)==0 );\n\n  assert( nOld>0 );\n  assert( nNew>0 );\n\n  if( isRoot && pParent->nCell==0 && pParent->hdrOffset<=apNew[0]->nFree ){\n    /* The root page of the b-tree now contains no cells. The only sibling\n    ** page is the right-child of the parent. Copy the contents of the\n    ** child page into the parent, decreasing the overall height of the\n    ** b-tree structure by one. This is described as the \"balance-shallower\"\n    ** sub-algorithm in some documentation.\n    **\n    ** If this is an auto-vacuum database, the call to copyNodeContent() \n    ** sets all pointer-map entries corresponding to database image pages \n    ** for which the pointer is stored within the content being copied.\n    **\n    ** It is critical that the child page be defragmented before being\n    ** copied into the parent, because if the parent is page 1 then it will\n    ** by smaller than the child due to the database header, and so all the\n    ** free space needs to be up front.\n    */\n    assert( nNew==1 || CORRUPT_DB );\n    rc = defragmentPage(apNew[0], -1);\n    testcase( rc!=SQLITE_OK );\n    assert( apNew[0]->nFree == \n        (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)\n      || rc!=SQLITE_OK\n    );\n    copyNodeContent(apNew[0], pParent, &rc);\n    freePage(apNew[0], &rc);\n  }else if( ISAUTOVACUUM && !leafCorrection ){\n    /* Fix the pointer map entries associated with the right-child of each\n    ** sibling page. All other pointer map entries have already been taken\n    ** care of.  */\n    for(i=0; i<nNew; i++){\n      u32 key = get4byte(&apNew[i]->aData[8]);\n      ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);\n    }\n  }\n\n  assert( pParent->isInit );\n  TRACE((\"BALANCE: finished: old=%d new=%d cells=%d\\n\",\n          nOld, nNew, b.nCell));\n\n  /* Free any old pages that were not reused as new pages.\n  */\n  for(i=nNew; i<nOld; i++){\n    freePage(apOld[i], &rc);\n  }\n\n#if 0\n  if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){\n    /* The ptrmapCheckPages() contains assert() statements that verify that\n    ** all pointer map pages are set correctly. This is helpful while \n    ** debugging. This is usually disabled because a corrupt database may\n    ** cause an assert() statement to fail.  */\n    ptrmapCheckPages(apNew, nNew);\n    ptrmapCheckPages(&pParent, 1);\n  }\n#endif\n\n  /*\n  ** Cleanup before returning.\n  */\nbalance_cleanup:\n  sqlite3StackFree(0, b.apCell);\n  for(i=0; i<nOld; i++){\n    releasePage(apOld[i]);\n  }\n  for(i=0; i<nNew; i++){\n    releasePage(apNew[i]);\n  }\n\n  return rc;\n}\n\n\n/*\n** This function is called when the root page of a b-tree structure is\n** overfull (has one or more overflow pages).\n**\n** A new child page is allocated and the contents of the current root\n** page, including overflow cells, are copied into the child. The root\n** page is then overwritten to make it an empty page with the right-child \n** pointer pointing to the new page.\n**\n** Before returning, all pointer-map entries corresponding to pages \n** that the new child-page now contains pointers to are updated. The\n** entry corresponding to the new right-child pointer of the root\n** page is also updated.\n**\n** If successful, *ppChild is set to contain a reference to the child \n** page and SQLITE_OK is returned. In this case the caller is required\n** to call releasePage() on *ppChild exactly once. If an error occurs,\n** an error code is returned and *ppChild is set to 0.\n*/\nstatic int balance_deeper(MemPage *pRoot, MemPage **ppChild){\n  int rc;                        /* Return value from subprocedures */\n  MemPage *pChild = 0;           /* Pointer to a new child page */\n  Pgno pgnoChild = 0;            /* Page number of the new child page */\n  BtShared *pBt = pRoot->pBt;    /* The BTree */\n\n  assert( pRoot->nOverflow>0 );\n  assert( sqlite3_mutex_held(pBt->mutex) );\n\n  /* Make pRoot, the root page of the b-tree, writable. Allocate a new \n  ** page that will become the new right-child of pPage. Copy the contents\n  ** of the node stored on pRoot into the new child page.\n  */\n  rc = sqlite3PagerWrite(pRoot->pDbPage);\n  if( rc==SQLITE_OK ){\n    rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);\n    copyNodeContent(pRoot, pChild, &rc);\n    if( ISAUTOVACUUM ){\n      ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);\n    }\n  }\n  if( rc ){\n    *ppChild = 0;\n    releasePage(pChild);\n    return rc;\n  }\n  assert( sqlite3PagerIswriteable(pChild->pDbPage) );\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  assert( pChild->nCell==pRoot->nCell );\n\n  TRACE((\"BALANCE: copy root %d into %d\\n\", pRoot->pgno, pChild->pgno));\n\n  /* Copy the overflow cells from pRoot to pChild */\n  memcpy(pChild->aiOvfl, pRoot->aiOvfl,\n         pRoot->nOverflow*sizeof(pRoot->aiOvfl[0]));\n  memcpy(pChild->apOvfl, pRoot->apOvfl,\n         pRoot->nOverflow*sizeof(pRoot->apOvfl[0]));\n  pChild->nOverflow = pRoot->nOverflow;\n\n  /* Zero the contents of pRoot. Then install pChild as the right-child. */\n  zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);\n  put4byte(&pRoot->aData[pRoot->hdrOffset+8], pgnoChild);\n\n  *ppChild = pChild;\n  return SQLITE_OK;\n}\n\n/*\n** The page that pCur currently points to has just been modified in\n** some way. This function figures out if this modification means the\n** tree needs to be balanced, and if so calls the appropriate balancing \n** routine. Balancing routines are:\n**\n**   balance_quick()\n**   balance_deeper()\n**   balance_nonroot()\n*/\nstatic int balance(BtCursor *pCur){\n  int rc = SQLITE_OK;\n  const int nMin = pCur->pBt->usableSize * 2 / 3;\n  u8 aBalanceQuickSpace[13];\n  u8 *pFree = 0;\n\n  VVA_ONLY( int balance_quick_called = 0 );\n  VVA_ONLY( int balance_deeper_called = 0 );\n\n  do {\n    int iPage = pCur->iPage;\n    MemPage *pPage = pCur->pPage;\n\n    if( iPage==0 ){\n      if( pPage->nOverflow ){\n        /* The root page of the b-tree is overfull. In this case call the\n        ** balance_deeper() function to create a new child for the root-page\n        ** and copy the current contents of the root-page to it. The\n        ** next iteration of the do-loop will balance the child page.\n        */ \n        assert( balance_deeper_called==0 );\n        VVA_ONLY( balance_deeper_called++ );\n        rc = balance_deeper(pPage, &pCur->apPage[1]);\n        if( rc==SQLITE_OK ){\n          pCur->iPage = 1;\n          pCur->ix = 0;\n          pCur->aiIdx[0] = 0;\n          pCur->apPage[0] = pPage;\n          pCur->pPage = pCur->apPage[1];\n          assert( pCur->pPage->nOverflow );\n        }\n      }else{\n        break;\n      }\n    }else if( pPage->nOverflow==0 && pPage->nFree<=nMin ){\n      break;\n    }else{\n      MemPage * const pParent = pCur->apPage[iPage-1];\n      int const iIdx = pCur->aiIdx[iPage-1];\n\n      rc = sqlite3PagerWrite(pParent->pDbPage);\n      if( rc==SQLITE_OK ){\n#ifndef SQLITE_OMIT_QUICKBALANCE\n        if( pPage->intKeyLeaf\n         && pPage->nOverflow==1\n         && pPage->aiOvfl[0]==pPage->nCell\n         && pParent->pgno!=1\n         && pParent->nCell==iIdx\n        ){\n          /* Call balance_quick() to create a new sibling of pPage on which\n          ** to store the overflow cell. balance_quick() inserts a new cell\n          ** into pParent, which may cause pParent overflow. If this\n          ** happens, the next iteration of the do-loop will balance pParent \n          ** use either balance_nonroot() or balance_deeper(). Until this\n          ** happens, the overflow cell is stored in the aBalanceQuickSpace[]\n          ** buffer. \n          **\n          ** The purpose of the following assert() is to check that only a\n          ** single call to balance_quick() is made for each call to this\n          ** function. If this were not verified, a subtle bug involving reuse\n          ** of the aBalanceQuickSpace[] might sneak in.\n          */\n          assert( balance_quick_called==0 ); \n          VVA_ONLY( balance_quick_called++ );\n          rc = balance_quick(pParent, pPage, aBalanceQuickSpace);\n        }else\n#endif\n        {\n          /* In this case, call balance_nonroot() to redistribute cells\n          ** between pPage and up to 2 of its sibling pages. This involves\n          ** modifying the contents of pParent, which may cause pParent to\n          ** become overfull or underfull. The next iteration of the do-loop\n          ** will balance the parent page to correct this.\n          ** \n          ** If the parent page becomes overfull, the overflow cell or cells\n          ** are stored in the pSpace buffer allocated immediately below. \n          ** A subsequent iteration of the do-loop will deal with this by\n          ** calling balance_nonroot() (balance_deeper() may be called first,\n          ** but it doesn't deal with overflow cells - just moves them to a\n          ** different page). Once this subsequent call to balance_nonroot() \n          ** has completed, it is safe to release the pSpace buffer used by\n          ** the previous call, as the overflow cell data will have been \n          ** copied either into the body of a database page or into the new\n          ** pSpace buffer passed to the latter call to balance_nonroot().\n          */\n          u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);\n          rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,\n                               pCur->hints&BTREE_BULKLOAD);\n          if( pFree ){\n            /* If pFree is not NULL, it points to the pSpace buffer used \n            ** by a previous call to balance_nonroot(). Its contents are\n            ** now stored either on real database pages or within the \n            ** new pSpace buffer, so it may be safely freed here. */\n            sqlite3PageFree(pFree);\n          }\n\n          /* The pSpace buffer will be freed after the next call to\n          ** balance_nonroot(), or just before this function returns, whichever\n          ** comes first. */\n          pFree = pSpace;\n        }\n      }\n\n      pPage->nOverflow = 0;\n\n      /* The next iteration of the do-loop balances the parent page. */\n      releasePage(pPage);\n      pCur->iPage--;\n      assert( pCur->iPage>=0 );\n      pCur->pPage = pCur->apPage[pCur->iPage];\n    }\n  }while( rc==SQLITE_OK );\n\n  if( pFree ){\n    sqlite3PageFree(pFree);\n  }\n  return rc;\n}\n\n\n/*\n** Insert a new record into the BTree.  The content of the new record\n** is described by the pX object.  The pCur cursor is used only to\n** define what table the record should be inserted into, and is left\n** pointing at a random location.\n**\n** For a table btree (used for rowid tables), only the pX.nKey value of\n** the key is used. The pX.pKey value must be NULL.  The pX.nKey is the\n** rowid or INTEGER PRIMARY KEY of the row.  The pX.nData,pData,nZero fields\n** hold the content of the row.\n**\n** For an index btree (used for indexes and WITHOUT ROWID tables), the\n** key is an arbitrary byte sequence stored in pX.pKey,nKey.  The \n** pX.pData,nData,nZero fields must be zero.\n**\n** If the seekResult parameter is non-zero, then a successful call to\n** MovetoUnpacked() to seek cursor pCur to (pKey,nKey) has already\n** been performed.  In other words, if seekResult!=0 then the cursor\n** is currently pointing to a cell that will be adjacent to the cell\n** to be inserted.  If seekResult<0 then pCur points to a cell that is\n** smaller then (pKey,nKey).  If seekResult>0 then pCur points to a cell\n** that is larger than (pKey,nKey).\n**\n** If seekResult==0, that means pCur is pointing at some unknown location.\n** In that case, this routine must seek the cursor to the correct insertion\n** point for (pKey,nKey) before doing the insertion.  For index btrees,\n** if pX->nMem is non-zero, then pX->aMem contains pointers to the unpacked\n** key values and pX->aMem can be used instead of pX->pKey to avoid having\n** to decode the key.\n*/\nint sqlite3BtreeInsert(\n  BtCursor *pCur,                /* Insert data into the table of this cursor */\n  const BtreePayload *pX,        /* Content of the row to be inserted */\n  int flags,                     /* True if this is likely an append */\n  int seekResult                 /* Result of prior MovetoUnpacked() call */\n){\n  int rc;\n  int loc = seekResult;          /* -1: before desired location  +1: after */\n  int szNew = 0;\n  int idx;\n  MemPage *pPage;\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;\n  unsigned char *oldCell;\n  unsigned char *newCell = 0;\n\n  assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND))==flags );\n\n  if( pCur->eState==CURSOR_FAULT ){\n    assert( pCur->skipNext!=SQLITE_OK );\n    return pCur->skipNext;\n  }\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( (pCur->curFlags & BTCF_WriteFlag)!=0\n              && pBt->inTransaction==TRANS_WRITE\n              && (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n\n  /* Assert that the caller has been consistent. If this cursor was opened\n  ** expecting an index b-tree, then the caller should be inserting blob\n  ** keys with no associated data. If the cursor was opened expecting an\n  ** intkey table, the caller should be inserting integer keys with a\n  ** blob of associated data.  */\n  assert( (pX->pKey==0)==(pCur->pKeyInfo==0) );\n\n  /* Save the positions of any other cursors open on this table.\n  **\n  ** In some cases, the call to btreeMoveto() below is a no-op. For\n  ** example, when inserting data into a table with auto-generated integer\n  ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the \n  ** integer key to use. It then calls this function to actually insert the \n  ** data into the intkey B-Tree. In this case btreeMoveto() recognizes\n  ** that the cursor is already where it needs to be and returns without\n  ** doing any work. To avoid thwarting these optimizations, it is important\n  ** not to clear the cursor here.\n  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  if( pCur->pKeyInfo==0 ){\n    assert( pX->pKey==0 );\n    /* If this is an insert into a table b-tree, invalidate any incrblob \n    ** cursors open on the row being replaced */\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0);\n\n    /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing \n    ** to a row with the same key as the new entry being inserted.  */\n    assert( (flags & BTREE_SAVEPOSITION)==0 || \n            ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );\n\n    /* If the cursor is currently on the last row and we are appending a\n    ** new row onto the end, set the \"loc\" to avoid an unnecessary\n    ** btreeMoveto() call */\n    if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){\n      loc = 0;\n    }else if( loc==0 ){\n      rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);\n      if( rc ) return rc;\n    }\n  }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){\n    if( pX->nMem ){\n      UnpackedRecord r;\n      r.pKeyInfo = pCur->pKeyInfo;\n      r.aMem = pX->aMem;\n      r.nField = pX->nMem;\n      r.default_rc = 0;\n      r.errCode = 0;\n      r.r1 = 0;\n      r.r2 = 0;\n      r.eqSeen = 0;\n      rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);\n    }else{\n      rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);\n    }\n    if( rc ) return rc;\n  }\n  assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );\n\n  pPage = pCur->pPage;\n  assert( pPage->intKey || pX->nKey>=0 );\n  assert( pPage->leaf || !pPage->intKey );\n\n  TRACE((\"INSERT: table=%d nkey=%lld ndata=%d page=%d %s\\n\",\n          pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno,\n          loc==0 ? \"overwrite\" : \"new entry\"));\n  assert( pPage->isInit );\n  newCell = pBt->pTmpSpace;\n  assert( newCell!=0 );\n  rc = fillInCell(pPage, newCell, pX, &szNew);\n  if( rc ) goto end_insert;\n  assert( szNew==pPage->xCellSize(pPage, newCell) );\n  assert( szNew <= MX_CELL_SIZE(pBt) );\n  idx = pCur->ix;\n  if( loc==0 ){\n    CellInfo info;\n    assert( idx<pPage->nCell );\n    rc = sqlite3PagerWrite(pPage->pDbPage);\n    if( rc ){\n      goto end_insert;\n    }\n    oldCell = findCell(pPage, idx);\n    if( !pPage->leaf ){\n      memcpy(newCell, oldCell, 4);\n    }\n    rc = clearCell(pPage, oldCell, &info);\n    if( info.nSize==szNew && info.nLocal==info.nPayload \n     && (!ISAUTOVACUUM || szNew<pPage->minLocal)\n    ){\n      /* Overwrite the old cell with the new if they are the same size.\n      ** We could also try to do this if the old cell is smaller, then add\n      ** the leftover space to the free list.  But experiments show that\n      ** doing that is no faster then skipping this optimization and just\n      ** calling dropCell() and insertCell(). \n      **\n      ** This optimization cannot be used on an autovacuum database if the\n      ** new entry uses overflow pages, as the insertCell() call below is\n      ** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry.  */\n      assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */\n      if( oldCell+szNew > pPage->aDataEnd ) return SQLITE_CORRUPT_BKPT;\n      memcpy(oldCell, newCell, szNew);\n      return SQLITE_OK;\n    }\n    dropCell(pPage, idx, info.nSize, &rc);\n    if( rc ) goto end_insert;\n  }else if( loc<0 && pPage->nCell>0 ){\n    assert( pPage->leaf );\n    idx = ++pCur->ix;\n    pCur->curFlags &= ~BTCF_ValidNKey;\n  }else{\n    assert( pPage->leaf );\n  }\n  insertCell(pPage, idx, newCell, szNew, 0, 0, &rc);\n  assert( pPage->nOverflow==0 || rc==SQLITE_OK );\n  assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 );\n\n  /* If no error has occurred and pPage has an overflow cell, call balance() \n  ** to redistribute the cells within the tree. Since balance() may move\n  ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey\n  ** variables.\n  **\n  ** Previous versions of SQLite called moveToRoot() to move the cursor\n  ** back to the root page as balance() used to invalidate the contents\n  ** of BtCursor.apPage[] and BtCursor.aiIdx[]. Instead of doing that,\n  ** set the cursor state to \"invalid\". This makes common insert operations\n  ** slightly faster.\n  **\n  ** There is a subtle but important optimization here too. When inserting\n  ** multiple records into an intkey b-tree using a single cursor (as can\n  ** happen while processing an \"INSERT INTO ... SELECT\" statement), it\n  ** is advantageous to leave the cursor pointing to the last entry in\n  ** the b-tree if possible. If the cursor is left pointing to the last\n  ** entry in the table, and the next row inserted has an integer key\n  ** larger than the largest existing key, it is possible to insert the\n  ** row without seeking the cursor. This can be a big performance boost.\n  */\n  pCur->info.nSize = 0;\n  if( pPage->nOverflow ){\n    assert( rc==SQLITE_OK );\n    pCur->curFlags &= ~(BTCF_ValidNKey);\n    rc = balance(pCur);\n\n    /* Must make sure nOverflow is reset to zero even if the balance()\n    ** fails. Internal data structure corruption will result otherwise. \n    ** Also, set the cursor state to invalid. This stops saveCursorPosition()\n    ** from trying to save the current position of the cursor.  */\n    pCur->pPage->nOverflow = 0;\n    pCur->eState = CURSOR_INVALID;\n    if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){\n      btreeReleaseAllCursorPages(pCur);\n      if( pCur->pKeyInfo ){\n        assert( pCur->pKey==0 );\n        pCur->pKey = sqlite3Malloc( pX->nKey );\n        if( pCur->pKey==0 ){\n          rc = SQLITE_NOMEM;\n        }else{\n          memcpy(pCur->pKey, pX->pKey, pX->nKey);\n        }\n      }\n      pCur->eState = CURSOR_REQUIRESEEK;\n      pCur->nKey = pX->nKey;\n    }\n  }\n  assert( pCur->iPage<0 || pCur->pPage->nOverflow==0 );\n\nend_insert:\n  return rc;\n}\n\n/*\n** Delete the entry that the cursor is pointing to. \n**\n** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then\n** the cursor is left pointing at an arbitrary location after the delete.\n** But if that bit is set, then the cursor is left in a state such that\n** the next call to BtreeNext() or BtreePrev() moves it to the same row\n** as it would have been on if the call to BtreeDelete() had been omitted.\n**\n** The BTREE_AUXDELETE bit of flags indicates that is one of several deletes\n** associated with a single table entry and its indexes.  Only one of those\n** deletes is considered the \"primary\" delete.  The primary delete occurs\n** on a cursor that is not a BTREE_FORDELETE cursor.  All but one delete\n** operation on non-FORDELETE cursors is tagged with the AUXDELETE flag.\n** The BTREE_AUXDELETE bit is a hint that is not used by this implementation,\n** but which might be used by alternative storage engines.\n*/\nint sqlite3BtreeDelete(BtCursor *pCur, u8 flags){\n  Btree *p = pCur->pBtree;\n  BtShared *pBt = p->pBt;              \n  int rc;                              /* Return code */\n  MemPage *pPage;                      /* Page to delete cell from */\n  unsigned char *pCell;                /* Pointer to cell to delete */\n  int iCellIdx;                        /* Index of cell to delete */\n  int iCellDepth;                      /* Depth of node containing pCell */ \n  CellInfo info;                       /* Size of the cell being deleted */\n  int bSkipnext = 0;                   /* Leaf cursor in SKIPNEXT state */\n  u8 bPreserve = flags & BTREE_SAVEPOSITION;  /* Keep cursor valid */\n\n  assert( cursorOwnsBtShared(pCur) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n  assert( pCur->curFlags & BTCF_WriteFlag );\n  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );\n  assert( !hasReadConflicts(p, pCur->pgnoRoot) );\n  assert( pCur->ix<pCur->pPage->nCell );\n  assert( pCur->eState==CURSOR_VALID );\n  assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );\n\n  iCellDepth = pCur->iPage;\n  iCellIdx = pCur->ix;\n  pPage = pCur->pPage;\n  pCell = findCell(pPage, iCellIdx);\n\n  /* If the bPreserve flag is set to true, then the cursor position must\n  ** be preserved following this delete operation. If the current delete\n  ** will cause a b-tree rebalance, then this is done by saving the cursor\n  ** key and leaving the cursor in CURSOR_REQUIRESEEK state before \n  ** returning. \n  **\n  ** Or, if the current delete will not cause a rebalance, then the cursor\n  ** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately\n  ** before or after the deleted entry. In this case set bSkipnext to true.  */\n  if( bPreserve ){\n    if( !pPage->leaf \n     || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)\n    ){\n      /* A b-tree rebalance will be required after deleting this entry.\n      ** Save the cursor key.  */\n      rc = saveCursorKey(pCur);\n      if( rc ) return rc;\n    }else{\n      bSkipnext = 1;\n    }\n  }\n\n  /* If the page containing the entry to delete is not a leaf page, move\n  ** the cursor to the largest entry in the tree that is smaller than\n  ** the entry being deleted. This cell will replace the cell being deleted\n  ** from the internal node. The 'previous' entry is used for this instead\n  ** of the 'next' entry, as the previous entry is always a part of the\n  ** sub-tree headed by the child page of the cell being deleted. This makes\n  ** balancing the tree following the delete operation easier.  */\n  if( !pPage->leaf ){\n    rc = sqlite3BtreePrevious(pCur, 0);\n    assert( rc!=SQLITE_DONE );\n    if( rc ) return rc;\n  }\n\n  /* Save the positions of any other cursors open on this table before\n  ** making any modifications.  */\n  if( pCur->curFlags & BTCF_Multiple ){\n    rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);\n    if( rc ) return rc;\n  }\n\n  /* If this is a delete operation to remove a row from a table b-tree,\n  ** invalidate any incrblob cursors open on the row being deleted.  */\n  if( pCur->pKeyInfo==0 ){\n    invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0);\n  }\n\n  /* Make the page containing the entry to be deleted writable. Then free any\n  ** overflow pages associated with the entry and finally remove the cell\n  ** itself from within the page.  */\n  rc = sqlite3PagerWrite(pPage->pDbPage);\n  if( rc ) return rc;\n  rc = clearCell(pPage, pCell, &info);\n  dropCell(pPage, iCellIdx, info.nSize, &rc);\n  if( rc ) return rc;\n\n  /* If the cell deleted was not located on a leaf page, then the cursor\n  ** is currently pointing to the largest entry in the sub-tree headed\n  ** by the child-page of the cell that was just deleted from an internal\n  ** node. The cell from the leaf node needs to be moved to the internal\n  ** node to replace the deleted cell.  */\n  if( !pPage->leaf ){\n    MemPage *pLeaf = pCur->pPage;\n    int nCell;\n    Pgno n;\n    unsigned char *pTmp;\n\n    if( iCellDepth<pCur->iPage-1 ){\n      n = pCur->apPage[iCellDepth+1]->pgno;\n    }else{\n      n = pCur->pPage->pgno;\n    }\n    pCell = findCell(pLeaf, pLeaf->nCell-1);\n    if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT;\n    nCell = pLeaf->xCellSize(pLeaf, pCell);\n    assert( MX_CELL_SIZE(pBt) >= nCell );\n    pTmp = pBt->pTmpSpace;\n    assert( pTmp!=0 );\n    rc = sqlite3PagerWrite(pLeaf->pDbPage);\n    if( rc==SQLITE_OK ){\n      insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc);\n    }\n    dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc);\n    if( rc ) return rc;\n  }\n\n  /* Balance the tree. If the entry deleted was located on a leaf page,\n  ** then the cursor still points to that page. In this case the first\n  ** call to balance() repairs the tree, and the if(...) condition is\n  ** never true.\n  **\n  ** Otherwise, if the entry deleted was on an internal node page, then\n  ** pCur is pointing to the leaf page from which a cell was removed to\n  ** replace the cell deleted from the internal node. This is slightly\n  ** tricky as the leaf node may be underfull, and the internal node may\n  ** be either under or overfull. In this case run the balancing algorithm\n  ** on the leaf node first. If the balance proceeds far enough up the\n  ** tree that we can be sure that any problem in the internal node has\n  ** been corrected, so be it. Otherwise, after balancing the leaf node,\n  ** walk the cursor up the tree to the internal node and balance it as \n  ** well.  */\n  rc = balance(pCur);\n  if( rc==SQLITE_OK && pCur->iPage>iCellDepth ){\n    releasePageNotNull(pCur->pPage);\n    pCur->iPage--;\n    while( pCur->iPage>iCellDepth ){\n      releasePage(pCur->apPage[pCur->iPage--]);\n    }\n    pCur->pPage = pCur->apPage[pCur->iPage];\n    rc = balance(pCur);\n  }\n\n  if( rc==SQLITE_OK ){\n    if( bSkipnext ){\n      assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );\n      assert( pPage==pCur->pPage || CORRUPT_DB );\n      assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );\n      pCur->eState = CURSOR_SKIPNEXT;\n      if( iCellIdx>=pPage->nCell ){\n        pCur->skipNext = -1;\n        pCur->ix = pPage->nCell-1;\n      }else{\n        pCur->skipNext = 1;\n      }\n    }else{\n      rc = moveToRoot(pCur);\n      if( bPreserve ){\n        btreeReleaseAllCursorPages(pCur);\n        pCur->eState = CURSOR_REQUIRESEEK;\n      }\n      if( rc==SQLITE_EMPTY ) rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** Create a new BTree table.  Write into *piTable the page\n** number for the root page of the new table.\n**\n** The type of type is determined by the flags parameter.  Only the\n** following values of flags are currently in use.  Other values for\n** flags might not work:\n**\n**     BTREE_INTKEY|BTREE_LEAFDATA     Used for SQL tables with rowid keys\n**     BTREE_ZERODATA                  Used for SQL indices\n*/\nstatic int btreeCreateTable(Btree *p, int *piTable, int createTabFlags){\n  BtShared *pBt = p->pBt;\n  MemPage *pRoot;\n  Pgno pgnoRoot;\n  int rc;\n  int ptfFlags;          /* Page-type flage for the root page of new table */\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( pBt->inTransaction==TRANS_WRITE );\n  assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n  if( rc ){\n    return rc;\n  }\n#else\n  if( pBt->autoVacuum ){\n    Pgno pgnoMove;      /* Move a page here to make room for the root-page */\n    MemPage *pPageMove; /* The page to move to. */\n\n    /* Creating a new table may probably require moving an existing database\n    ** to make room for the new tables root page. In case this page turns\n    ** out to be an overflow page, delete all overflow page-map caches\n    ** held by open cursors.\n    */\n    invalidateAllOverflowCache(pBt);\n\n    /* Read the value of meta[3] from the database to determine where the\n    ** root page of the new table should go. meta[3] is the largest root-page\n    ** created so far, so the new root-page is (meta[3]+1).\n    */\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);\n    pgnoRoot++;\n\n    /* The new root-page may not be allocated on a pointer-map page, or the\n    ** PENDING_BYTE page.\n    */\n    while( pgnoRoot==PTRMAP_PAGENO(pBt, pgnoRoot) ||\n        pgnoRoot==PENDING_BYTE_PAGE(pBt) ){\n      pgnoRoot++;\n    }\n    assert( pgnoRoot>=3 || CORRUPT_DB );\n    testcase( pgnoRoot<3 );\n\n    /* Allocate a page. The page that currently resides at pgnoRoot will\n    ** be moved to the allocated page (unless the allocated page happens\n    ** to reside at pgnoRoot).\n    */\n    rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, BTALLOC_EXACT);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    if( pgnoMove!=pgnoRoot ){\n      /* pgnoRoot is the page that will be used for the root-page of\n      ** the new table (assuming an error did not occur). But we were\n      ** allocated pgnoMove. If required (i.e. if it was not allocated\n      ** by extending the file), the current page at position pgnoMove\n      ** is already journaled.\n      */\n      u8 eType = 0;\n      Pgno iPtrPage = 0;\n\n      /* Save the positions of any open cursors. This is required in\n      ** case they are holding a reference to an xFetch reference\n      ** corresponding to page pgnoRoot.  */\n      rc = saveAllCursors(pBt, 0, 0);\n      releasePage(pPageMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n\n      /* Move the page currently at pgnoRoot to pgnoMove. */\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);\n      if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){\n        rc = SQLITE_CORRUPT_BKPT;\n      }\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n      assert( eType!=PTRMAP_ROOTPAGE );\n      assert( eType!=PTRMAP_FREEPAGE );\n      rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);\n      releasePage(pRoot);\n\n      /* Obtain the page at pgnoRoot */\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = btreeGetPage(pBt, pgnoRoot, &pRoot, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = sqlite3PagerWrite(pRoot->pDbPage);\n      if( rc!=SQLITE_OK ){\n        releasePage(pRoot);\n        return rc;\n      }\n    }else{\n      pRoot = pPageMove;\n    } \n\n    /* Update the pointer-map and meta-data with the new root-page number. */\n    ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0, &rc);\n    if( rc ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n    /* When the new root page was allocated, page 1 was made writable in\n    ** order either to increase the database filesize, or to decrement the\n    ** freelist count.  Hence, the sqlite3BtreeUpdateMeta() call cannot fail.\n    */\n    assert( sqlite3PagerIswriteable(pBt->pPage1->pDbPage) );\n    rc = sqlite3BtreeUpdateMeta(p, 4, pgnoRoot);\n    if( NEVER(rc) ){\n      releasePage(pRoot);\n      return rc;\n    }\n\n  }else{\n    rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);\n    if( rc ) return rc;\n  }\n#endif\n  assert( sqlite3PagerIswriteable(pRoot->pDbPage) );\n  if( createTabFlags & BTREE_INTKEY ){\n    ptfFlags = PTF_INTKEY | PTF_LEAFDATA | PTF_LEAF;\n  }else{\n    ptfFlags = PTF_ZERODATA | PTF_LEAF;\n  }\n  zeroPage(pRoot, ptfFlags);\n  sqlite3PagerUnref(pRoot->pDbPage);\n  assert( (pBt->openFlags & BTREE_SINGLE)==0 || pgnoRoot==2 );\n  *piTable = (int)pgnoRoot;\n  return SQLITE_OK;\n}\nint sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeCreateTable(p, piTable, flags);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Erase the given database page and all its children.  Return\n** the page to the freelist.\n*/\nstatic int clearDatabasePage(\n  BtShared *pBt,           /* The BTree that contains the table */\n  Pgno pgno,               /* Page number to clear */\n  int freePageFlag,        /* Deallocate page if true */\n  int *pnChange            /* Add number of Cells freed to this counter */\n){\n  MemPage *pPage;\n  int rc;\n  unsigned char *pCell;\n  int i;\n  int hdr;\n  CellInfo info;\n\n  assert( sqlite3_mutex_held(pBt->mutex) );\n  if( pgno>btreePagecount(pBt) ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);\n  if( rc ) return rc;\n  if( pPage->bBusy ){\n    rc = SQLITE_CORRUPT_BKPT;\n    goto cleardatabasepage_out;\n  }\n  pPage->bBusy = 1;\n  hdr = pPage->hdrOffset;\n  for(i=0; i<pPage->nCell; i++){\n    pCell = findCell(pPage, i);\n    if( !pPage->leaf ){\n      rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);\n      if( rc ) goto cleardatabasepage_out;\n    }\n    rc = clearCell(pPage, pCell, &info);\n    if( rc ) goto cleardatabasepage_out;\n  }\n  if( !pPage->leaf ){\n    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);\n    if( rc ) goto cleardatabasepage_out;\n  }else if( pnChange ){\n    assert( pPage->intKey || CORRUPT_DB );\n    testcase( !pPage->intKey );\n    *pnChange += pPage->nCell;\n  }\n  if( freePageFlag ){\n    freePage(pPage, &rc);\n  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){\n    zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);\n  }\n\ncleardatabasepage_out:\n  pPage->bBusy = 0;\n  releasePage(pPage);\n  return rc;\n}\n\n/*\n** Delete all information from a single table in the database.  iTable is\n** the page number of the root of the table.  After this routine returns,\n** the root page is empty, but still exists.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** read cursors on the table.  Open write cursors are moved to the\n** root of the table.\n**\n** If pnChange is not NULL, then table iTable must be an intkey table. The\n** integer value pointed to by pnChange is incremented by the number of\n** entries in the table.\n*/\nint sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){\n  int rc;\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n\n  rc = saveAllCursors(pBt, (Pgno)iTable, 0);\n\n  if( SQLITE_OK==rc ){\n    /* Invalidate all incrblob cursors open on table iTable (assuming iTable\n    ** is the root of a table b-tree - if it is not, the following call is\n    ** a no-op).  */\n    invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);\n    rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n/*\n** Delete all information from the single table that pCur is open on.\n**\n** This routine only work for pCur on an ephemeral table.\n*/\nint sqlite3BtreeClearTableOfCursor(BtCursor *pCur){\n  return sqlite3BtreeClearTable(pCur->pBtree, pCur->pgnoRoot, 0);\n}\n\n/*\n** Erase all information in a table and add the root of the table to\n** the freelist.  Except, the root of the principle table (the one on\n** page 1) is never added to the freelist.\n**\n** This routine will fail with SQLITE_LOCKED if there are any open\n** cursors on the table.\n**\n** If AUTOVACUUM is enabled and the page at iTable is not the last\n** root page in the database file, then the last root page \n** in the database file is moved into the slot formerly occupied by\n** iTable and that last slot formerly occupied by the last root page\n** is added to the freelist instead of iTable.  In this say, all\n** root pages are kept at the beginning of the database file, which\n** is necessary for AUTOVACUUM to work right.  *piMoved is set to the \n** page number that used to be the last root page in the file before\n** the move.  If no page gets moved, *piMoved is set to 0.\n** The last root page is recorded in meta[3] and the value of\n** meta[3] is updated by this procedure.\n*/\nstatic int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){\n  int rc;\n  MemPage *pPage = 0;\n  BtShared *pBt = p->pBt;\n\n  assert( sqlite3BtreeHoldsMutex(p) );\n  assert( p->inTrans==TRANS_WRITE );\n  assert( iTable>=2 );\n\n  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);\n  if( rc ) return rc;\n  rc = sqlite3BtreeClearTable(p, iTable, 0);\n  if( rc ){\n    releasePage(pPage);\n    return rc;\n  }\n\n  *piMoved = 0;\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  freePage(pPage, &rc);\n  releasePage(pPage);\n#else\n  if( pBt->autoVacuum ){\n    Pgno maxRootPgno;\n    sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &maxRootPgno);\n\n    if( iTable==maxRootPgno ){\n      /* If the table being dropped is the table with the largest root-page\n      ** number in the database, put the root page on the free list. \n      */\n      freePage(pPage, &rc);\n      releasePage(pPage);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      /* The table being dropped does not have the largest root-page\n      ** number in the database. So move the page that does into the \n      ** gap left by the deleted root-page.\n      */\n      MemPage *pMove;\n      releasePage(pPage);\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      pMove = 0;\n      rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);\n      freePage(pMove, &rc);\n      releasePage(pMove);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n      *piMoved = maxRootPgno;\n    }\n\n    /* Set the new 'max-root-page' value in the database header. This\n    ** is the old value less one, less one more if that happens to\n    ** be a root-page number, less one again if that is the\n    ** PENDING_BYTE_PAGE.\n    */\n    maxRootPgno--;\n    while( maxRootPgno==PENDING_BYTE_PAGE(pBt)\n           || PTRMAP_ISPAGE(pBt, maxRootPgno) ){\n      maxRootPgno--;\n    }\n    assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );\n\n    rc = sqlite3BtreeUpdateMeta(p, 4, maxRootPgno);\n  }else{\n    freePage(pPage, &rc);\n    releasePage(pPage);\n  }\n#endif\n  return rc;  \n}\nint sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){\n  int rc;\n  sqlite3BtreeEnter(p);\n  rc = btreeDropTable(p, iTable, piMoved);\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n/*\n** This function may only be called if the b-tree connection already\n** has a read or write transaction open on the database.\n**\n** Read the meta-information out of a database file.  Meta[0]\n** is the number of free pages currently in the database.  Meta[1]\n** through meta[15] are available for use by higher layers.  Meta[0]\n** is read-only, the others are read/write.\n** \n** The schema layer numbers meta values differently.  At the schema\n** layer (and the SetCookie and ReadCookie opcodes) the number of\n** free pages is not visible.  So Cookie[0] is the same as Meta[1].\n**\n** This routine treats Meta[BTREE_DATA_VERSION] as a special case.  Instead\n** of reading the value out of the header, it instead loads the \"DataVersion\"\n** from the pager.  The BTREE_DATA_VERSION value is not actually stored in the\n** database file.  It is a number computed by the pager.  But its access\n** pattern is the same as header meta values, and so it is convenient to\n** read it from this routine.\n*/\nvoid sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){\n  BtShared *pBt = p->pBt;\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE );\n  assert( SQLITE_OK==querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK) );\n  assert( pBt->pPage1 );\n  assert( idx>=0 && idx<=15 );\n\n  if( idx==BTREE_DATA_VERSION ){\n    *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;\n  }else{\n    *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);\n  }\n\n  /* If auto-vacuum is disabled in this build and this is an auto-vacuum\n  ** database, mark the database as read-only.  */\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  if( idx==BTREE_LARGEST_ROOT_PAGE && *pMeta>0 ){\n    pBt->btsFlags |= BTS_READ_ONLY;\n  }\n#endif\n\n  sqlite3BtreeLeave(p);\n}\n\n/*\n** Write meta-information back into the database.  Meta[0] is\n** read-only and may not be written.\n*/\nint sqlite3BtreeUpdateMeta(Btree *p, int idx, u32 iMeta){\n  BtShared *pBt = p->pBt;\n  unsigned char *pP1;\n  int rc;\n  assert( idx>=1 && idx<=15 );\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans==TRANS_WRITE );\n  assert( pBt->pPage1!=0 );\n  pP1 = pBt->pPage1->aData;\n  rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n  if( rc==SQLITE_OK ){\n    put4byte(&pP1[36 + idx*4], iMeta);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( idx==BTREE_INCR_VACUUM ){\n      assert( pBt->autoVacuum || iMeta==0 );\n      assert( iMeta==0 || iMeta==1 );\n      pBt->incrVacuum = (u8)iMeta;\n    }\n#endif\n  }\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_BTREECOUNT\n/*\n** The first argument, pCur, is a cursor opened on some b-tree. Count the\n** number of entries in the b-tree and write the result to *pnEntry.\n**\n** SQLITE_OK is returned if the operation is successfully executed. \n** Otherwise, if an error is encountered (i.e. an IO error or database\n** corruption) an SQLite error code is returned.\n*/\nint sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){\n  i64 nEntry = 0;                      /* Value to return in *pnEntry */\n  int rc;                              /* Return code */\n\n  rc = moveToRoot(pCur);\n  if( rc==SQLITE_EMPTY ){\n    *pnEntry = 0;\n    return SQLITE_OK;\n  }\n\n  /* Unless an error occurs, the following loop runs one iteration for each\n  ** page in the B-Tree structure (not including overflow pages). \n  */\n  while( rc==SQLITE_OK ){\n    int iIdx;                          /* Index of child node in parent */\n    MemPage *pPage;                    /* Current page of the b-tree */\n\n    /* If this is a leaf page or the tree is not an int-key tree, then \n    ** this page contains countable entries. Increment the entry counter\n    ** accordingly.\n    */\n    pPage = pCur->pPage;\n    if( pPage->leaf || !pPage->intKey ){\n      nEntry += pPage->nCell;\n    }\n\n    /* pPage is a leaf node. This loop navigates the cursor so that it \n    ** points to the first interior cell that it points to the parent of\n    ** the next page in the tree that has not yet been visited. The\n    ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell\n    ** of the page, or to the number of cells in the page if the next page\n    ** to visit is the right-child of its parent.\n    **\n    ** If all pages in the tree have been visited, return SQLITE_OK to the\n    ** caller.\n    */\n    if( pPage->leaf ){\n      do {\n        if( pCur->iPage==0 ){\n          /* All pages of the b-tree have been visited. Return successfully. */\n          *pnEntry = nEntry;\n          return moveToRoot(pCur);\n        }\n        moveToParent(pCur);\n      }while ( pCur->ix>=pCur->pPage->nCell );\n\n      pCur->ix++;\n      pPage = pCur->pPage;\n    }\n\n    /* Descend to the child node of the cell that the cursor currently \n    ** points at. This is the right-child if (iIdx==pPage->nCell).\n    */\n    iIdx = pCur->ix;\n    if( iIdx==pPage->nCell ){\n      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));\n    }else{\n      rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx)));\n    }\n  }\n\n  /* An error has occurred. Return an error code. */\n  return rc;\n}\n#endif\n\n/*\n** Return the pager associated with a BTree.  This routine is used for\n** testing and debugging only.\n*/\nPager *sqlite3BtreePager(Btree *p){\n  return p->pBt->pPager;\n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Append a message to the error message string.\n*/\nstatic void checkAppendMsg(\n  IntegrityCk *pCheck,\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  if( !pCheck->mxErr ) return;\n  pCheck->mxErr--;\n  pCheck->nErr++;\n  va_start(ap, zFormat);\n  if( pCheck->errMsg.nChar ){\n    sqlite3StrAccumAppend(&pCheck->errMsg, \"\\n\", 1);\n  }\n  if( pCheck->zPfx ){\n    sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);\n  }\n  sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);\n  va_end(ap);\n  if( pCheck->errMsg.accError==STRACCUM_NOMEM ){\n    pCheck->mallocFailed = 1;\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n\n/*\n** Return non-zero if the bit in the IntegrityCk.aPgRef[] array that\n** corresponds to page iPg is already set.\n*/\nstatic int getPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  return (pCheck->aPgRef[iPg/8] & (1 << (iPg & 0x07)));\n}\n\n/*\n** Set the bit in the IntegrityCk.aPgRef[] array that corresponds to page iPg.\n*/\nstatic void setPageReferenced(IntegrityCk *pCheck, Pgno iPg){\n  assert( iPg<=pCheck->nPage && sizeof(pCheck->aPgRef[0])==1 );\n  pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));\n}\n\n\n/*\n** Add 1 to the reference count for page iPage.  If this is the second\n** reference to the page, add an error message to pCheck->zErrMsg.\n** Return 1 if there are 2 or more references to the page and 0 if\n** if this is the first reference to the page.\n**\n** Also check that the page number is in bounds.\n*/\nstatic int checkRef(IntegrityCk *pCheck, Pgno iPage){\n  if( iPage==0 ) return 1;\n  if( iPage>pCheck->nPage ){\n    checkAppendMsg(pCheck, \"invalid page number %d\", iPage);\n    return 1;\n  }\n  if( getPageReferenced(pCheck, iPage) ){\n    checkAppendMsg(pCheck, \"2nd reference to page %d\", iPage);\n    return 1;\n  }\n  setPageReferenced(pCheck, iPage);\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Check that the entry in the pointer-map for page iChild maps to \n** page iParent, pointer type ptrType. If not, append an error message\n** to pCheck.\n*/\nstatic void checkPtrmap(\n  IntegrityCk *pCheck,   /* Integrity check context */\n  Pgno iChild,           /* Child page number */\n  u8 eType,              /* Expected pointer map type */\n  Pgno iParent           /* Expected pointer map parent page number */\n){\n  int rc;\n  u8 ePtrmapType;\n  Pgno iPtrmapParent;\n\n  rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ) pCheck->mallocFailed = 1;\n    checkAppendMsg(pCheck, \"Failed to read ptrmap key=%d\", iChild);\n    return;\n  }\n\n  if( ePtrmapType!=eType || iPtrmapParent!=iParent ){\n    checkAppendMsg(pCheck,\n      \"Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)\", \n      iChild, eType, iParent, ePtrmapType, iPtrmapParent);\n  }\n}\n#endif\n\n/*\n** Check the integrity of the freelist or of an overflow page list.\n** Verify that the number of pages on the list is N.\n*/\nstatic void checkList(\n  IntegrityCk *pCheck,  /* Integrity checking context */\n  int isFreeList,       /* True for a freelist.  False for overflow page list */\n  int iPage,            /* Page number for first page in the list */\n  int N                 /* Expected number of pages in the list */\n){\n  int i;\n  int expected = N;\n  int iFirst = iPage;\n  while( N-- > 0 && pCheck->mxErr ){\n    DbPage *pOvflPage;\n    unsigned char *pOvflData;\n    if( iPage<1 ){\n      checkAppendMsg(pCheck,\n         \"%d of %d pages missing from overflow list starting at %d\",\n          N+1, expected, iFirst);\n      break;\n    }\n    if( checkRef(pCheck, iPage) ) break;\n    if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){\n      checkAppendMsg(pCheck, \"failed to get page %d\", iPage);\n      break;\n    }\n    pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);\n    if( isFreeList ){\n      int n = get4byte(&pOvflData[4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pCheck->pBt->autoVacuum ){\n        checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);\n      }\n#endif\n      if( n>(int)pCheck->pBt->usableSize/4-2 ){\n        checkAppendMsg(pCheck,\n           \"freelist leaf count too big on page %d\", iPage);\n        N--;\n      }else{\n        for(i=0; i<n; i++){\n          Pgno iFreePage = get4byte(&pOvflData[8+i*4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n          if( pCheck->pBt->autoVacuum ){\n            checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);\n          }\n#endif\n          checkRef(pCheck, iFreePage);\n        }\n        N -= n;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    else{\n      /* If this database supports auto-vacuum and iPage is not the last\n      ** page in this overflow list, check that the pointer-map entry for\n      ** the following page matches iPage.\n      */\n      if( pCheck->pBt->autoVacuum && N>0 ){\n        i = get4byte(pOvflData);\n        checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);\n      }\n    }\n#endif\n    iPage = get4byte(pOvflData);\n    sqlite3PagerUnref(pOvflPage);\n\n    if( isFreeList && N<(iPage!=0) ){\n      checkAppendMsg(pCheck, \"free-page count in header is too small\");\n    }\n  }\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** An implementation of a min-heap.\n**\n** aHeap[0] is the number of elements on the heap.  aHeap[1] is the\n** root element.  The daughter nodes of aHeap[N] are aHeap[N*2]\n** and aHeap[N*2+1].\n**\n** The heap property is this:  Every node is less than or equal to both\n** of its daughter nodes.  A consequence of the heap property is that the\n** root node aHeap[1] is always the minimum value currently in the heap.\n**\n** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto\n** the heap, preserving the heap property.  The btreeHeapPull() routine\n** removes the root element from the heap (the minimum value in the heap)\n** and then moves other nodes around as necessary to preserve the heap\n** property.\n**\n** This heap is used for cell overlap and coverage testing.  Each u32\n** entry represents the span of a cell or freeblock on a btree page.  \n** The upper 16 bits are the index of the first byte of a range and the\n** lower 16 bits are the index of the last byte of that range.\n*/\nstatic void btreeHeapInsert(u32 *aHeap, u32 x){\n  u32 j, i = ++aHeap[0];\n  aHeap[i] = x;\n  while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){\n    x = aHeap[j];\n    aHeap[j] = aHeap[i];\n    aHeap[i] = x;\n    i = j;\n  }\n}\nstatic int btreeHeapPull(u32 *aHeap, u32 *pOut){\n  u32 j, i, x;\n  if( (x = aHeap[0])==0 ) return 0;\n  *pOut = aHeap[1];\n  aHeap[1] = aHeap[x];\n  aHeap[x] = 0xffffffff;\n  aHeap[0]--;\n  i = 1;\n  while( (j = i*2)<=aHeap[0] ){\n    if( aHeap[j]>aHeap[j+1] ) j++;\n    if( aHeap[i]<aHeap[j] ) break;\n    x = aHeap[i];\n    aHeap[i] = aHeap[j];\n    aHeap[j] = x;\n    i = j;\n  }\n  return 1;  \n}\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** Do various sanity checks on a single page of a tree.  Return\n** the tree depth.  Root pages return 0.  Parents of root pages\n** return 1, and so forth.\n** \n** These checks are done:\n**\n**      1.  Make sure that cells and freeblocks do not overlap\n**          but combine to completely cover the page.\n**      2.  Make sure integer cell keys are in order.\n**      3.  Check the integrity of overflow pages.\n**      4.  Recursively call checkTreePage on all children.\n**      5.  Verify that the depth of all children is the same.\n*/\nstatic int checkTreePage(\n  IntegrityCk *pCheck,  /* Context for the sanity check */\n  int iPage,            /* Page number of the page to check */\n  i64 *piMinKey,        /* Write minimum integer primary key here */\n  i64 maxKey            /* Error if integer primary key greater than this */\n){\n  MemPage *pPage = 0;      /* The page being analyzed */\n  int i;                   /* Loop counter */\n  int rc;                  /* Result code from subroutine call */\n  int depth = -1, d2;      /* Depth of a subtree */\n  int pgno;                /* Page number */\n  int nFrag;               /* Number of fragmented bytes on the page */\n  int hdr;                 /* Offset to the page header */\n  int cellStart;           /* Offset to the start of the cell pointer array */\n  int nCell;               /* Number of cells */\n  int doCoverageCheck = 1; /* True if cell coverage checking should be done */\n  int keyCanBeEqual = 1;   /* True if IPK can be equal to maxKey\n                           ** False if IPK must be strictly less than maxKey */\n  u8 *data;                /* Page content */\n  u8 *pCell;               /* Cell content */\n  u8 *pCellIdx;            /* Next element of the cell pointer array */\n  BtShared *pBt;           /* The BtShared object that owns pPage */\n  u32 pc;                  /* Address of a cell */\n  u32 usableSize;          /* Usable size of the page */\n  u32 contentOffset;       /* Offset to the start of the cell content area */\n  u32 *heap = 0;           /* Min-heap used for checking cell coverage */\n  u32 x, prev = 0;         /* Next and previous entry on the min-heap */\n  const char *saved_zPfx = pCheck->zPfx;\n  int saved_v1 = pCheck->v1;\n  int saved_v2 = pCheck->v2;\n  u8 savedIsInit = 0;\n\n  /* Check that the page exists\n  */\n  pBt = pCheck->pBt;\n  usableSize = pBt->usableSize;\n  if( iPage==0 ) return 0;\n  if( checkRef(pCheck, iPage) ) return 0;\n  pCheck->zPfx = \"Page %d: \";\n  pCheck->v1 = iPage;\n  if( (rc = btreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){\n    checkAppendMsg(pCheck,\n       \"unable to get the page. error code=%d\", rc);\n    goto end_of_check;\n  }\n\n  /* Clear MemPage.isInit to make sure the corruption detection code in\n  ** btreeInitPage() is executed.  */\n  savedIsInit = pPage->isInit;\n  pPage->isInit = 0;\n  if( (rc = btreeInitPage(pPage))!=0 ){\n    assert( rc==SQLITE_CORRUPT );  /* The only possible error from InitPage */\n    checkAppendMsg(pCheck,\n                   \"btreeInitPage() returns error code %d\", rc);\n    goto end_of_check;\n  }\n  data = pPage->aData;\n  hdr = pPage->hdrOffset;\n\n  /* Set up for cell analysis */\n  pCheck->zPfx = \"On tree page %d cell %d: \";\n  contentOffset = get2byteNotZero(&data[hdr+5]);\n  assert( contentOffset<=usableSize );  /* Enforced by btreeInitPage() */\n\n  /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the\n  ** number of cells on the page. */\n  nCell = get2byte(&data[hdr+3]);\n  assert( pPage->nCell==nCell );\n\n  /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page\n  ** immediately follows the b-tree page header. */\n  cellStart = hdr + 12 - 4*pPage->leaf;\n  assert( pPage->aCellIdx==&data[cellStart] );\n  pCellIdx = &data[cellStart + 2*(nCell-1)];\n\n  if( !pPage->leaf ){\n    /* Analyze the right-child page of internal pages */\n    pgno = get4byte(&data[hdr+8]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum ){\n      pCheck->zPfx = \"On page %d at right child: \";\n      checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n    }\n#endif\n    depth = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n    keyCanBeEqual = 0;\n  }else{\n    /* For leaf pages, the coverage check will occur in the same loop\n    ** as the other cell checks, so initialize the heap.  */\n    heap = pCheck->heap;\n    heap[0] = 0;\n  }\n\n  /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte\n  ** integer offsets to the cell contents. */\n  for(i=nCell-1; i>=0 && pCheck->mxErr; i--){\n    CellInfo info;\n\n    /* Check cell size */\n    pCheck->v2 = i;\n    assert( pCellIdx==&data[cellStart + i*2] );\n    pc = get2byteAligned(pCellIdx);\n    pCellIdx -= 2;\n    if( pc<contentOffset || pc>usableSize-4 ){\n      checkAppendMsg(pCheck, \"Offset %d out of range %d..%d\",\n                             pc, contentOffset, usableSize-4);\n      doCoverageCheck = 0;\n      continue;\n    }\n    pCell = &data[pc];\n    pPage->xParseCell(pPage, pCell, &info);\n    if( pc+info.nSize>usableSize ){\n      checkAppendMsg(pCheck, \"Extends off end of page\");\n      doCoverageCheck = 0;\n      continue;\n    }\n\n    /* Check for integer primary key out of range */\n    if( pPage->intKey ){\n      if( keyCanBeEqual ? (info.nKey > maxKey) : (info.nKey >= maxKey) ){\n        checkAppendMsg(pCheck, \"Rowid %lld out of order\", info.nKey);\n      }\n      maxKey = info.nKey;\n      keyCanBeEqual = 0;     /* Only the first key on the page may ==maxKey */\n    }\n\n    /* Check the content overflow list */\n    if( info.nPayload>info.nLocal ){\n      int nPage;       /* Number of pages on the overflow chain */\n      Pgno pgnoOvfl;   /* First page of the overflow chain */\n      assert( pc + info.nSize - 4 <= usableSize );\n      nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);\n      pgnoOvfl = get4byte(&pCell[info.nSize - 4]);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);\n      }\n#endif\n      checkList(pCheck, 0, pgnoOvfl, nPage);\n    }\n\n    if( !pPage->leaf ){\n      /* Check sanity of left child page for internal pages */\n      pgno = get4byte(pCell);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n      if( pBt->autoVacuum ){\n        checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage);\n      }\n#endif\n      d2 = checkTreePage(pCheck, pgno, &maxKey, maxKey);\n      keyCanBeEqual = 0;\n      if( d2!=depth ){\n        checkAppendMsg(pCheck, \"Child page depth differs\");\n        depth = d2;\n      }\n    }else{\n      /* Populate the coverage-checking heap for leaf pages */\n      btreeHeapInsert(heap, (pc<<16)|(pc+info.nSize-1));\n    }\n  }\n  *piMinKey = maxKey;\n\n  /* Check for complete coverage of the page\n  */\n  pCheck->zPfx = 0;\n  if( doCoverageCheck && pCheck->mxErr>0 ){\n    /* For leaf pages, the min-heap has already been initialized and the\n    ** cells have already been inserted.  But for internal pages, that has\n    ** not yet been done, so do it now */\n    if( !pPage->leaf ){\n      heap = pCheck->heap;\n      heap[0] = 0;\n      for(i=nCell-1; i>=0; i--){\n        u32 size;\n        pc = get2byteAligned(&data[cellStart+i*2]);\n        size = pPage->xCellSize(pPage, &data[pc]);\n        btreeHeapInsert(heap, (pc<<16)|(pc+size-1));\n      }\n    }\n    /* Add the freeblocks to the min-heap\n    **\n    ** EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header\n    ** is the offset of the first freeblock, or zero if there are no\n    ** freeblocks on the page. \n    */\n    i = get2byte(&data[hdr+1]);\n    while( i>0 ){\n      int size, j;\n      assert( (u32)i<=usableSize-4 );     /* Enforced by btreeInitPage() */\n      size = get2byte(&data[i+2]);\n      assert( (u32)(i+size)<=usableSize );  /* Enforced by btreeInitPage() */\n      btreeHeapInsert(heap, (((u32)i)<<16)|(i+size-1));\n      /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a\n      ** big-endian integer which is the offset in the b-tree page of the next\n      ** freeblock in the chain, or zero if the freeblock is the last on the\n      ** chain. */\n      j = get2byte(&data[i]);\n      /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of\n      ** increasing offset. */\n      assert( j==0 || j>i+size );  /* Enforced by btreeInitPage() */\n      assert( (u32)j<=usableSize-4 );   /* Enforced by btreeInitPage() */\n      i = j;\n    }\n    /* Analyze the min-heap looking for overlap between cells and/or \n    ** freeblocks, and counting the number of untracked bytes in nFrag.\n    ** \n    ** Each min-heap entry is of the form:    (start_address<<16)|end_address.\n    ** There is an implied first entry the covers the page header, the cell\n    ** pointer index, and the gap between the cell pointer index and the start\n    ** of cell content.  \n    **\n    ** The loop below pulls entries from the min-heap in order and compares\n    ** the start_address against the previous end_address.  If there is an\n    ** overlap, that means bytes are used multiple times.  If there is a gap,\n    ** that gap is added to the fragmentation count.\n    */\n    nFrag = 0;\n    prev = contentOffset - 1;   /* Implied first min-heap entry */\n    while( btreeHeapPull(heap,&x) ){\n      if( (prev&0xffff)>=(x>>16) ){\n        checkAppendMsg(pCheck,\n          \"Multiple uses for byte %u of page %d\", x>>16, iPage);\n        break;\n      }else{\n        nFrag += (x>>16) - (prev&0xffff) - 1;\n        prev = x;\n      }\n    }\n    nFrag += usableSize - (prev&0xffff) - 1;\n    /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments\n    ** is stored in the fifth field of the b-tree page header.\n    ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the\n    ** number of fragmented free bytes within the cell content area.\n    */\n    if( heap[0]==0 && nFrag!=data[hdr+7] ){\n      checkAppendMsg(pCheck,\n          \"Fragmentation of %d bytes reported as %d on page %d\",\n          nFrag, data[hdr+7], iPage);\n    }\n  }\n\nend_of_check:\n  if( !doCoverageCheck ) pPage->isInit = savedIsInit;\n  releasePage(pPage);\n  pCheck->zPfx = saved_zPfx;\n  pCheck->v1 = saved_v1;\n  pCheck->v2 = saved_v2;\n  return depth+1;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/*\n** This routine does a complete check of the given BTree file.  aRoot[] is\n** an array of pages numbers were each page number is the root page of\n** a table.  nRoot is the number of entries in aRoot.\n**\n** A read-only or read-write transaction must be opened before calling\n** this function.\n**\n** Write the number of error seen in *pnErr.  Except for some memory\n** allocation errors,  an error message held in memory obtained from\n** malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is\n** returned.  If a memory allocation error occurs, NULL is returned.\n*/\nchar *sqlite3BtreeIntegrityCheck(\n  Btree *p,     /* The btree to be checked */\n  int *aRoot,   /* An array of root pages numbers for individual trees */\n  int nRoot,    /* Number of entries in aRoot[] */\n  int mxErr,    /* Stop reporting errors after this many */\n  int *pnErr    /* Write number of errors seen to this variable */\n){\n  Pgno i;\n  IntegrityCk sCheck;\n  BtShared *pBt = p->pBt;\n  int savedDbFlags = pBt->db->flags;\n  char zErr[100];\n  VVA_ONLY( int nRef );\n\n  sqlite3BtreeEnter(p);\n  assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );\n  VVA_ONLY( nRef = sqlite3PagerRefcount(pBt->pPager) );\n  assert( nRef>=0 );\n  sCheck.pBt = pBt;\n  sCheck.pPager = pBt->pPager;\n  sCheck.nPage = btreePagecount(sCheck.pBt);\n  sCheck.mxErr = mxErr;\n  sCheck.nErr = 0;\n  sCheck.mallocFailed = 0;\n  sCheck.zPfx = 0;\n  sCheck.v1 = 0;\n  sCheck.v2 = 0;\n  sCheck.aPgRef = 0;\n  sCheck.heap = 0;\n  sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);\n  sCheck.errMsg.printfFlags = SQLITE_PRINTF_INTERNAL;\n  if( sCheck.nPage==0 ){\n    goto integrity_ck_cleanup;\n  }\n\n  sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1);\n  if( !sCheck.aPgRef ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n  sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize );\n  if( sCheck.heap==0 ){\n    sCheck.mallocFailed = 1;\n    goto integrity_ck_cleanup;\n  }\n\n  i = PENDING_BYTE_PAGE(pBt);\n  if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);\n\n  /* Check the integrity of the freelist\n  */\n  sCheck.zPfx = \"Main freelist: \";\n  checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),\n            get4byte(&pBt->pPage1->aData[36]));\n  sCheck.zPfx = 0;\n\n  /* Check all the tables.\n  */\n  testcase( pBt->db->flags & SQLITE_CellSizeCk );\n  pBt->db->flags &= ~SQLITE_CellSizeCk;\n  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){\n    i64 notUsed;\n    if( aRoot[i]==0 ) continue;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( pBt->autoVacuum && aRoot[i]>1 ){\n      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);\n    }\n#endif\n    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);\n  }\n  pBt->db->flags = savedDbFlags;\n\n  /* Make sure every page in the file is referenced\n  */\n  for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){\n#ifdef SQLITE_OMIT_AUTOVACUUM\n    if( getPageReferenced(&sCheck, i)==0 ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n#else\n    /* If the database supports auto-vacuum, make sure no tables contain\n    ** references to pointer-map pages.\n    */\n    if( getPageReferenced(&sCheck, i)==0 && \n       (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Page %d is never used\", i);\n    }\n    if( getPageReferenced(&sCheck, i)!=0 && \n       (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){\n      checkAppendMsg(&sCheck, \"Pointer map page %d is referenced\", i);\n    }\n#endif\n  }\n\n  /* Clean  up and report errors.\n  */\nintegrity_ck_cleanup:\n  sqlite3PageFree(sCheck.heap);\n  sqlite3_free(sCheck.aPgRef);\n  if( sCheck.mallocFailed ){\n    sqlite3StrAccumReset(&sCheck.errMsg);\n    sCheck.nErr++;\n  }\n  *pnErr = sCheck.nErr;\n  if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);\n  /* Make sure this analysis did not leave any unref() pages. */\n  assert( nRef==sqlite3PagerRefcount(pBt->pPager) );\n  sqlite3BtreeLeave(p);\n  return sqlite3StrAccumFinish(&sCheck.errMsg);\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/*\n** Return the full pathname of the underlying database file.  Return\n** an empty string if the database is in-memory or a TEMP database.\n**\n** The pager filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nconst char *sqlite3BtreeGetFilename(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerFilename(p->pBt->pPager, 1);\n}\n\n/*\n** Return the pathname of the journal file for this database. The return\n** value of this routine is the same regardless of whether the journal file\n** has been created or not.\n**\n** The pager journal filename is invariant as long as the pager is\n** open so it is safe to access without the BtShared mutex.\n*/\nconst char *sqlite3BtreeGetJournalname(Btree *p){\n  assert( p->pBt->pPager!=0 );\n  return sqlite3PagerJournalname(p->pBt->pPager);\n}\n\n/*\n** Return non-zero if a transaction is active.\n*/\nint sqlite3BtreeIsInTrans(Btree *p){\n  assert( p==0 || sqlite3_mutex_held(p->db->mutex) );\n  return (p && (p->inTrans==TRANS_WRITE));\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on the Btree passed as the first argument.\n**\n** Return SQLITE_LOCKED if this or any other connection has an open \n** transaction on the shared-cache the argument Btree is connected to.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nint sqlite3BtreeCheckpoint(Btree *p, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;\n  if( p ){\n    BtShared *pBt = p->pBt;\n    sqlite3BtreeEnter(p);\n    if( pBt->inTransaction!=TRANS_NONE ){\n      rc = SQLITE_LOCKED;\n    }else{\n      rc = sqlite3PagerCheckpoint(pBt->pPager, p->db, eMode, pnLog, pnCkpt);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** Return non-zero if a read (or write) transaction is active.\n*/\nint sqlite3BtreeIsInReadTrans(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->inTrans!=TRANS_NONE;\n}\n\nint sqlite3BtreeIsInBackup(Btree *p){\n  assert( p );\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  return p->nBackup!=0;\n}\n\n/*\n** This function returns a pointer to a blob of memory associated with\n** a single shared-btree. The memory is used by client code for its own\n** purposes (for example, to store a high-level schema associated with \n** the shared-btree). The btree layer manages reference counting issues.\n**\n** The first time this is called on a shared-btree, nBytes bytes of memory\n** are allocated, zeroed, and returned to the caller. For each subsequent \n** call the nBytes parameter is ignored and a pointer to the same blob\n** of memory returned. \n**\n** If the nBytes parameter is 0 and the blob of memory has not yet been\n** allocated, a null pointer is returned. If the blob has already been\n** allocated, it is returned as normal.\n**\n** Just before the shared-btree is closed, the function passed as the \n** xFree argument when the memory allocation was made is invoked on the \n** blob of allocated memory. The xFree function should not call sqlite3_free()\n** on the memory, the btree layer does that.\n*/\nvoid *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){\n  BtShared *pBt = p->pBt;\n  sqlite3BtreeEnter(p);\n  if( !pBt->pSchema && nBytes ){\n    pBt->pSchema = sqlite3DbMallocZero(0, nBytes);\n    pBt->xFreeSchema = xFree;\n  }\n  sqlite3BtreeLeave(p);\n  return pBt->pSchema;\n}\n\n/*\n** Return SQLITE_LOCKED_SHAREDCACHE if another user of the same shared \n** btree as the argument handle holds an exclusive lock on the \n** sqlite_master table. Otherwise SQLITE_OK.\n*/\nint sqlite3BtreeSchemaLocked(Btree *p){\n  int rc;\n  assert( sqlite3_mutex_held(p->db->mutex) );\n  sqlite3BtreeEnter(p);\n  rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);\n  assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE );\n  sqlite3BtreeLeave(p);\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** Obtain a lock on the table whose root page is iTab.  The\n** lock is a write lock if isWritelock is true or a read lock\n** if it is false.\n*/\nint sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){\n  int rc = SQLITE_OK;\n  assert( p->inTrans!=TRANS_NONE );\n  if( p->sharable ){\n    u8 lockType = READ_LOCK + isWriteLock;\n    assert( READ_LOCK+1==WRITE_LOCK );\n    assert( isWriteLock==0 || isWriteLock==1 );\n\n    sqlite3BtreeEnter(p);\n    rc = querySharedCacheTableLock(p, iTab, lockType);\n    if( rc==SQLITE_OK ){\n      rc = setSharedCacheTableLock(p, iTab, lockType);\n    }\n    sqlite3BtreeLeave(p);\n  }\n  return rc;\n}\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Argument pCsr must be a cursor opened for writing on an \n** INTKEY table currently pointing at a valid table entry. \n** This function modifies the data stored as part of that entry.\n**\n** Only the data content may only be modified, it is not possible to \n** change the length of the data stored. If this function is called with\n** parameters that attempt to write past the end of the existing data,\n** no modifications are made and SQLITE_CORRUPT is returned.\n*/\nint sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){\n  int rc;\n  assert( cursorOwnsBtShared(pCsr) );\n  assert( sqlite3_mutex_held(pCsr->pBtree->db->mutex) );\n  assert( pCsr->curFlags & BTCF_Incrblob );\n\n  rc = restoreCursorPosition(pCsr);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n  assert( pCsr->eState!=CURSOR_REQUIRESEEK );\n  if( pCsr->eState!=CURSOR_VALID ){\n    return SQLITE_ABORT;\n  }\n\n  /* Save the positions of all other cursors open on this table. This is\n  ** required in case any of them are holding references to an xFetch\n  ** version of the b-tree page modified by the accessPayload call below.\n  **\n  ** Note that pCsr must be open on a INTKEY table and saveCursorPosition()\n  ** and hence saveAllCursors() cannot fail on a BTREE_INTKEY table, hence\n  ** saveAllCursors can only return SQLITE_OK.\n  */\n  VVA_ONLY(rc =) saveAllCursors(pCsr->pBt, pCsr->pgnoRoot, pCsr);\n  assert( rc==SQLITE_OK );\n\n  /* Check some assumptions: \n  **   (a) the cursor is open for writing,\n  **   (b) there is a read/write transaction open,\n  **   (c) the connection holds a write-lock on the table (if required),\n  **   (d) there are no conflicting read-locks, and\n  **   (e) the cursor points at a valid row of an intKey table.\n  */\n  if( (pCsr->curFlags & BTCF_WriteFlag)==0 ){\n    return SQLITE_READONLY;\n  }\n  assert( (pCsr->pBt->btsFlags & BTS_READ_ONLY)==0\n              && pCsr->pBt->inTransaction==TRANS_WRITE );\n  assert( hasSharedCacheTableLock(pCsr->pBtree, pCsr->pgnoRoot, 0, 2) );\n  assert( !hasReadConflicts(pCsr->pBtree, pCsr->pgnoRoot) );\n  assert( pCsr->pPage->intKey );\n\n  return accessPayload(pCsr, offset, amt, (unsigned char *)z, 1);\n}\n\n/* \n** Mark this cursor as an incremental blob cursor.\n*/\nvoid sqlite3BtreeIncrblobCursor(BtCursor *pCur){\n  pCur->curFlags |= BTCF_Incrblob;\n  pCur->pBtree->hasIncrblobCur = 1;\n}\n#endif\n\n/*\n** Set both the \"read version\" (single byte at byte offset 18) and \n** \"write version\" (single byte at byte offset 19) fields in the database\n** header to iVersion.\n*/\nint sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){\n  BtShared *pBt = pBtree->pBt;\n  int rc;                         /* Return code */\n \n  assert( iVersion==1 || iVersion==2 );\n\n  /* If setting the version fields to 1, do not automatically open the\n  ** WAL connection, even if the version fields are currently set to 2.\n  */\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  if( iVersion==1 ) pBt->btsFlags |= BTS_NO_WAL;\n\n  rc = sqlite3BtreeBeginTrans(pBtree, 0);\n  if( rc==SQLITE_OK ){\n    u8 *aData = pBt->pPage1->aData;\n    if( aData[18]!=(u8)iVersion || aData[19]!=(u8)iVersion ){\n      rc = sqlite3BtreeBeginTrans(pBtree, 2);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerWrite(pBt->pPage1->pDbPage);\n        if( rc==SQLITE_OK ){\n          aData[18] = (u8)iVersion;\n          aData[19] = (u8)iVersion;\n        }\n      }\n    }\n  }\n\n  pBt->btsFlags &= ~BTS_NO_WAL;\n  return rc;\n}\n\n/*\n** Return true if the cursor has a hint specified.  This routine is\n** only used from within assert() statements\n*/\nint sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){\n  return (pCsr->hints & mask)!=0;\n}\n\n/*\n** Return true if the given Btree is read-only.\n*/\nint sqlite3BtreeIsReadonly(Btree *p){\n  return (p->pBt->btsFlags & BTS_READ_ONLY)!=0;\n}\n\n/*\n** Return the size of the header added to each page by this module.\n*/\nint sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); }\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** Return true if the Btree passed as the only argument is sharable.\n*/\nint sqlite3BtreeSharable(Btree *p){\n  return p->sharable;\n}\n\n/*\n** Return the number of connections to the BtShared object accessed by\n** the Btree handle passed as the only argument. For private caches \n** this is always 1. For shared caches it may be 1 or greater.\n*/\nint sqlite3BtreeConnectionCount(Btree *p){\n  testcase( p->sharable );\n  return p->pBt->nRef;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/btree.h",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite B-Tree file\n** subsystem.  See comments in the source code for a detailed description\n** of what each interface routine does.\n*/\n#ifndef SQLITE_BTREE_H\n#define SQLITE_BTREE_H\n\n/* TODO: This definition is just included so other modules compile. It\n** needs to be revisited.\n*/\n#define SQLITE_N_BTREE_META 16\n\n/*\n** If defined as non-zero, auto-vacuum is enabled by default. Otherwise\n** it must be turned on for each database using \"PRAGMA auto_vacuum = 1\".\n*/\n#ifndef SQLITE_DEFAULT_AUTOVACUUM\n  #define SQLITE_DEFAULT_AUTOVACUUM 0\n#endif\n\n#define BTREE_AUTOVACUUM_NONE 0        /* Do not do auto-vacuum */\n#define BTREE_AUTOVACUUM_FULL 1        /* Do full auto-vacuum */\n#define BTREE_AUTOVACUUM_INCR 2        /* Incremental vacuum */\n\n/*\n** Forward declarations of structure\n*/\ntypedef struct Btree Btree;\ntypedef struct BtCursor BtCursor;\ntypedef struct BtShared BtShared;\ntypedef struct BtreePayload BtreePayload;\n\n\nint sqlite3BtreeOpen(\n  sqlite3_vfs *pVfs,       /* VFS to use with this b-tree */\n  const char *zFilename,   /* Name of database file to open */\n  sqlite3 *db,             /* Associated database connection */\n  Btree **ppBtree,         /* Return open Btree* here */\n  int flags,               /* Flags */\n  int vfsFlags             /* Flags passed through to VFS open */\n);\n\n/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the\n** following values.\n**\n** NOTE:  These values must match the corresponding PAGER_ values in\n** pager.h.\n*/\n#define BTREE_OMIT_JOURNAL  1  /* Do not create or use a rollback journal */\n#define BTREE_MEMORY        2  /* This is an in-memory DB */\n#define BTREE_SINGLE        4  /* The file contains at most 1 b-tree */\n#define BTREE_UNORDERED     8  /* Use of a hash implementation is OK */\n\nint sqlite3BtreeClose(Btree*);\nint sqlite3BtreeSetCacheSize(Btree*,int);\nint sqlite3BtreeSetSpillSize(Btree*,int);\n#if SQLITE_MAX_MMAP_SIZE>0\n  int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);\n#endif\nint sqlite3BtreeSetPagerFlags(Btree*,unsigned);\nint sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);\nint sqlite3BtreeGetPageSize(Btree*);\nint sqlite3BtreeMaxPageCount(Btree*,int);\nu32 sqlite3BtreeLastPage(Btree*);\nint sqlite3BtreeSecureDelete(Btree*,int);\nint sqlite3BtreeGetOptimalReserve(Btree*);\nint sqlite3BtreeGetReserveNoMutex(Btree *p);\nint sqlite3BtreeSetAutoVacuum(Btree *, int);\nint sqlite3BtreeGetAutoVacuum(Btree *);\nint sqlite3BtreeBeginTrans(Btree*,int);\nint sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);\nint sqlite3BtreeCommitPhaseTwo(Btree*, int);\nint sqlite3BtreeCommit(Btree*);\nint sqlite3BtreeRollback(Btree*,int,int);\nint sqlite3BtreeBeginStmt(Btree*,int);\nint sqlite3BtreeCreateTable(Btree*, int*, int flags);\nint sqlite3BtreeIsInTrans(Btree*);\nint sqlite3BtreeIsInReadTrans(Btree*);\nint sqlite3BtreeIsInBackup(Btree*);\nvoid *sqlite3BtreeSchema(Btree *, int, void(*)(void *));\nint sqlite3BtreeSchemaLocked(Btree *pBtree);\n#ifndef SQLITE_OMIT_SHARED_CACHE\nint sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);\n#endif\nint sqlite3BtreeSavepoint(Btree *, int, int);\n\nconst char *sqlite3BtreeGetFilename(Btree *);\nconst char *sqlite3BtreeGetJournalname(Btree *);\nint sqlite3BtreeCopyFile(Btree *, Btree *);\n\nint sqlite3BtreeIncrVacuum(Btree *);\n\n/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR\n** of the flags shown below.\n**\n** Every SQLite table must have either BTREE_INTKEY or BTREE_BLOBKEY set.\n** With BTREE_INTKEY, the table key is a 64-bit integer and arbitrary data\n** is stored in the leaves.  (BTREE_INTKEY is used for SQL tables.)  With\n** BTREE_BLOBKEY, the key is an arbitrary BLOB and no content is stored\n** anywhere - the key is the content.  (BTREE_BLOBKEY is used for SQL\n** indices.)\n*/\n#define BTREE_INTKEY     1    /* Table has only 64-bit signed integer keys */\n#define BTREE_BLOBKEY    2    /* Table has keys only - no data */\n\nint sqlite3BtreeDropTable(Btree*, int, int*);\nint sqlite3BtreeClearTable(Btree*, int, int*);\nint sqlite3BtreeClearTableOfCursor(BtCursor*);\nint sqlite3BtreeTripAllCursors(Btree*, int, int);\n\nvoid sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);\nint sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);\n\nint sqlite3BtreeNewDb(Btree *p);\n\n/*\n** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta\n** should be one of the following values. The integer values are assigned \n** to constants so that the offset of the corresponding field in an\n** SQLite database header may be found using the following formula:\n**\n**   offset = 36 + (idx * 4)\n**\n** For example, the free-page-count field is located at byte offset 36 of\n** the database file header. The incr-vacuum-flag field is located at\n** byte offset 64 (== 36+4*7).\n**\n** The BTREE_DATA_VERSION value is not really a value stored in the header.\n** It is a read-only number computed by the pager.  But we merge it with\n** the header value access routines since its access pattern is the same.\n** Call it a \"virtual meta value\".\n*/\n#define BTREE_FREE_PAGE_COUNT     0\n#define BTREE_SCHEMA_VERSION      1\n#define BTREE_FILE_FORMAT         2\n#define BTREE_DEFAULT_CACHE_SIZE  3\n#define BTREE_LARGEST_ROOT_PAGE   4\n#define BTREE_TEXT_ENCODING       5\n#define BTREE_USER_VERSION        6\n#define BTREE_INCR_VACUUM         7\n#define BTREE_APPLICATION_ID      8\n#define BTREE_DATA_VERSION        15  /* A virtual meta-value */\n\n/*\n** Kinds of hints that can be passed into the sqlite3BtreeCursorHint()\n** interface.\n**\n** BTREE_HINT_RANGE  (arguments: Expr*, Mem*)\n**\n**     The first argument is an Expr* (which is guaranteed to be constant for\n**     the lifetime of the cursor) that defines constraints on which rows\n**     might be fetched with this cursor.  The Expr* tree may contain\n**     TK_REGISTER nodes that refer to values stored in the array of registers\n**     passed as the second parameter.  In other words, if Expr.op==TK_REGISTER\n**     then the value of the node is the value in Mem[pExpr.iTable].  Any\n**     TK_COLUMN node in the expression tree refers to the Expr.iColumn-th\n**     column of the b-tree of the cursor.  The Expr tree will not contain\n**     any function calls nor subqueries nor references to b-trees other than\n**     the cursor being hinted.\n**\n**     The design of the _RANGE hint is aid b-tree implementations that try\n**     to prefetch content from remote machines - to provide those\n**     implementations with limits on what needs to be prefetched and thereby\n**     reduce network bandwidth.\n**\n** Note that BTREE_HINT_FLAGS with BTREE_BULKLOAD is the only hint used by\n** standard SQLite.  The other hints are provided for extentions that use\n** the SQLite parser and code generator but substitute their own storage\n** engine.\n*/\n#define BTREE_HINT_RANGE 0       /* Range constraints on queries */\n\n/*\n** Values that may be OR'd together to form the argument to the\n** BTREE_HINT_FLAGS hint for sqlite3BtreeCursorHint():\n**\n** The BTREE_BULKLOAD flag is set on index cursors when the index is going\n** to be filled with content that is already in sorted order.\n**\n** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or\n** OP_SeekLE opcodes for a range search, but where the range of entries\n** selected will all have the same key.  In other words, the cursor will\n** be used only for equality key searches.\n**\n*/\n#define BTREE_BULKLOAD 0x00000001  /* Used to full index in sorted order */\n#define BTREE_SEEK_EQ  0x00000002  /* EQ seeks only - no range seeks */\n\n/* \n** Flags passed as the third argument to sqlite3BtreeCursor().\n**\n** For read-only cursors the wrFlag argument is always zero. For read-write\n** cursors it may be set to either (BTREE_WRCSR|BTREE_FORDELETE) or just\n** (BTREE_WRCSR). If the BTREE_FORDELETE bit is set, then the cursor will\n** only be used by SQLite for the following:\n**\n**   * to seek to and then delete specific entries, and/or\n**\n**   * to read values that will be used to create keys that other\n**     BTREE_FORDELETE cursors will seek to and delete.\n**\n** The BTREE_FORDELETE flag is an optimization hint.  It is not used by\n** by this, the native b-tree engine of SQLite, but it is available to\n** alternative storage engines that might be substituted in place of this\n** b-tree system.  For alternative storage engines in which a delete of\n** the main table row automatically deletes corresponding index rows,\n** the FORDELETE flag hint allows those alternative storage engines to\n** skip a lot of work.  Namely:  FORDELETE cursors may treat all SEEK\n** and DELETE operations as no-ops, and any READ operation against a\n** FORDELETE cursor may return a null row: 0x01 0x00.\n*/\n#define BTREE_WRCSR     0x00000004     /* read-write cursor */\n#define BTREE_FORDELETE 0x00000008     /* Cursor is for seek/delete only */\n\nint sqlite3BtreeCursor(\n  Btree*,                              /* BTree containing table to open */\n  int iTable,                          /* Index of root page */\n  int wrFlag,                          /* 1 for writing.  0 for read-only */\n  struct KeyInfo*,                     /* First argument to compare function */\n  BtCursor *pCursor                    /* Space to write cursor structure */\n);\nBtCursor *sqlite3BtreeFakeValidCursor(void);\nint sqlite3BtreeCursorSize(void);\nvoid sqlite3BtreeCursorZero(BtCursor*);\nvoid sqlite3BtreeCursorHintFlags(BtCursor*, unsigned);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nvoid sqlite3BtreeCursorHint(BtCursor*, int, ...);\n#endif\n\nint sqlite3BtreeCloseCursor(BtCursor*);\nint sqlite3BtreeMovetoUnpacked(\n  BtCursor*,\n  UnpackedRecord *pUnKey,\n  i64 intKey,\n  int bias,\n  int *pRes\n);\nint sqlite3BtreeCursorHasMoved(BtCursor*);\nint sqlite3BtreeCursorRestore(BtCursor*, int*);\nint sqlite3BtreeDelete(BtCursor*, u8 flags);\n\n/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */\n#define BTREE_SAVEPOSITION 0x02  /* Leave cursor pointing at NEXT or PREV */\n#define BTREE_AUXDELETE    0x04  /* not the primary delete operation */\n#define BTREE_APPEND       0x08  /* Insert is likely an append */\n\n/* An instance of the BtreePayload object describes the content of a single\n** entry in either an index or table btree.\n**\n** Index btrees (used for indexes and also WITHOUT ROWID tables) contain\n** an arbitrary key and no data.  These btrees have pKey,nKey set to their\n** key and pData,nData,nZero set to zero.\n**\n** Table btrees (used for rowid tables) contain an integer rowid used as\n** the key and passed in the nKey field.  The pKey field is zero.  \n** pData,nData hold the content of the new entry.  nZero extra zero bytes\n** are appended to the end of the content when constructing the entry.\n**\n** This object is used to pass information into sqlite3BtreeInsert().  The\n** same information used to be passed as five separate parameters.  But placing\n** the information into this object helps to keep the interface more \n** organized and understandable, and it also helps the resulting code to\n** run a little faster by using fewer registers for parameter passing.\n*/\nstruct BtreePayload {\n  const void *pKey;       /* Key content for indexes.  NULL for tables */\n  sqlite3_int64 nKey;     /* Size of pKey for indexes.  PRIMARY KEY for tabs */\n  const void *pData;      /* Data for tables.  NULL for indexes */\n  sqlite3_value *aMem;    /* First of nMem value in the unpacked pKey */\n  u16 nMem;               /* Number of aMem[] value.  Might be zero */\n  int nData;              /* Size of pData.  0 if none. */\n  int nZero;              /* Extra zero data appended after pData,nData */\n};\n\nint sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,\n                       int flags, int seekResult);\nint sqlite3BtreeFirst(BtCursor*, int *pRes);\nint sqlite3BtreeLast(BtCursor*, int *pRes);\nint sqlite3BtreeNext(BtCursor*, int flags);\nint sqlite3BtreeEof(BtCursor*);\nint sqlite3BtreePrevious(BtCursor*, int flags);\ni64 sqlite3BtreeIntegerKey(BtCursor*);\nint sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);\nconst void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);\nu32 sqlite3BtreePayloadSize(BtCursor*);\n\nchar *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);\nstruct Pager *sqlite3BtreePager(Btree*);\ni64 sqlite3BtreeRowCountEst(BtCursor*);\n\n#ifndef SQLITE_OMIT_INCRBLOB\nint sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);\nint sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);\nvoid sqlite3BtreeIncrblobCursor(BtCursor *);\n#endif\nvoid sqlite3BtreeClearCursor(BtCursor *);\nint sqlite3BtreeSetVersion(Btree *pBt, int iVersion);\nint sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);\nint sqlite3BtreeIsReadonly(Btree *pBt);\nint sqlite3HeaderSizeBtree(void);\n\n#ifndef NDEBUG\nint sqlite3BtreeCursorIsValid(BtCursor*);\n#endif\nint sqlite3BtreeCursorIsValidNN(BtCursor*);\n\n#ifndef SQLITE_OMIT_BTREECOUNT\nint sqlite3BtreeCount(BtCursor *, i64 *);\n#endif\n\n#ifdef SQLITE_TEST\nint sqlite3BtreeCursorInfo(BtCursor*, int*, int);\nvoid sqlite3BtreeCursorList(Btree*);\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n  int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);\n#endif\n\n/*\n** If we are not using shared cache, then there is no need to\n** use mutexes to access the BtShared structures.  So make the\n** Enter and Leave procedures no-ops.\n*/\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  void sqlite3BtreeEnter(Btree*);\n  void sqlite3BtreeEnterAll(sqlite3*);\n  int sqlite3BtreeSharable(Btree*);\n  void sqlite3BtreeEnterCursor(BtCursor*);\n  int sqlite3BtreeConnectionCount(Btree*);\n#else\n# define sqlite3BtreeEnter(X) \n# define sqlite3BtreeEnterAll(X)\n# define sqlite3BtreeSharable(X) 0\n# define sqlite3BtreeEnterCursor(X)\n# define sqlite3BtreeConnectionCount(X) 1\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE\n  void sqlite3BtreeLeave(Btree*);\n  void sqlite3BtreeLeaveCursor(BtCursor*);\n  void sqlite3BtreeLeaveAll(sqlite3*);\n#ifndef NDEBUG\n  /* These routines are used inside assert() statements only. */\n  int sqlite3BtreeHoldsMutex(Btree*);\n  int sqlite3BtreeHoldsAllMutexes(sqlite3*);\n  int sqlite3SchemaMutexHeld(sqlite3*,int,Schema*);\n#endif\n#else\n\n# define sqlite3BtreeLeave(X)\n# define sqlite3BtreeLeaveCursor(X)\n# define sqlite3BtreeLeaveAll(X)\n\n# define sqlite3BtreeHoldsMutex(X) 1\n# define sqlite3BtreeHoldsAllMutexes(X) 1\n# define sqlite3SchemaMutexHeld(X,Y,Z) 1\n#endif\n\n\n#endif /* SQLITE_BTREE_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/btreeInt.h",
    "content": "/*\n** 2004 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements an external (disk-based) database using BTrees.\n** For a detailed discussion of BTrees, refer to\n**\n**     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:\n**     \"Sorting And Searching\", pages 473-480. Addison-Wesley\n**     Publishing Company, Reading, Massachusetts.\n**\n** The basic idea is that each page of the file contains N database\n** entries and N+1 pointers to subpages.\n**\n**   ----------------------------------------------------------------\n**   |  Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) |\n**   ----------------------------------------------------------------\n**\n** All of the keys on the page that Ptr(0) points to have values less\n** than Key(0).  All of the keys on page Ptr(1) and its subpages have\n** values greater than Key(0) and less than Key(1).  All of the keys\n** on Ptr(N) and its subpages have values greater than Key(N-1).  And\n** so forth.\n**\n** Finding a particular key requires reading O(log(M)) pages from the \n** disk where M is the number of entries in the tree.\n**\n** In this implementation, a single file can hold one or more separate \n** BTrees.  Each BTree is identified by the index of its root page.  The\n** key and data for any entry are combined to form the \"payload\".  A\n** fixed amount of payload can be carried directly on the database\n** page.  If the payload is larger than the preset amount then surplus\n** bytes are stored on overflow pages.  The payload for an entry\n** and the preceding pointer are combined to form a \"Cell\".  Each \n** page has a small header which contains the Ptr(N) pointer and other\n** information such as the size of key and data.\n**\n** FORMAT DETAILS\n**\n** The file is divided into pages.  The first page is called page 1,\n** the second is page 2, and so forth.  A page number of zero indicates\n** \"no such page\".  The page size can be any power of 2 between 512 and 65536.\n** Each page can be either a btree page, a freelist page, an overflow\n** page, or a pointer-map page.\n**\n** The first page is always a btree page.  The first 100 bytes of the first\n** page contain a special header (the \"file header\") that describes the file.\n** The format of the file header is as follows:\n**\n**   OFFSET   SIZE    DESCRIPTION\n**      0      16     Header string: \"SQLite format 3\\000\"\n**     16       2     Page size in bytes.  (1 means 65536)\n**     18       1     File format write version\n**     19       1     File format read version\n**     20       1     Bytes of unused space at the end of each page\n**     21       1     Max embedded payload fraction (must be 64)\n**     22       1     Min embedded payload fraction (must be 32)\n**     23       1     Min leaf payload fraction (must be 32)\n**     24       4     File change counter\n**     28       4     Reserved for future use\n**     32       4     First freelist page\n**     36       4     Number of freelist pages in the file\n**     40      60     15 4-byte meta values passed to higher layers\n**\n**     40       4     Schema cookie\n**     44       4     File format of schema layer\n**     48       4     Size of page cache\n**     52       4     Largest root-page (auto/incr_vacuum)\n**     56       4     1=UTF-8 2=UTF16le 3=UTF16be\n**     60       4     User version\n**     64       4     Incremental vacuum mode\n**     68       4     Application-ID\n**     72      20     unused\n**     92       4     The version-valid-for number\n**     96       4     SQLITE_VERSION_NUMBER\n**\n** All of the integer values are big-endian (most significant byte first).\n**\n** The file change counter is incremented when the database is changed\n** This counter allows other processes to know when the file has changed\n** and thus when they need to flush their cache.\n**\n** The max embedded payload fraction is the amount of the total usable\n** space in a page that can be consumed by a single cell for standard\n** B-tree (non-LEAFDATA) tables.  A value of 255 means 100%.  The default\n** is to limit the maximum cell size so that at least 4 cells will fit\n** on one page.  Thus the default max embedded payload fraction is 64.\n**\n** If the payload for a cell is larger than the max payload, then extra\n** payload is spilled to overflow pages.  Once an overflow page is allocated,\n** as many bytes as possible are moved into the overflow pages without letting\n** the cell size drop below the min embedded payload fraction.\n**\n** The min leaf payload fraction is like the min embedded payload fraction\n** except that it applies to leaf nodes in a LEAFDATA tree.  The maximum\n** payload fraction for a LEAFDATA tree is always 100% (or 255) and it\n** not specified in the header.\n**\n** Each btree pages is divided into three sections:  The header, the\n** cell pointer array, and the cell content area.  Page 1 also has a 100-byte\n** file header that occurs before the page header.\n**\n**      |----------------|\n**      | file header    |   100 bytes.  Page 1 only.\n**      |----------------|\n**      | page header    |   8 bytes for leaves.  12 bytes for interior nodes\n**      |----------------|\n**      | cell pointer   |   |  2 bytes per cell.  Sorted order.\n**      | array          |   |  Grows downward\n**      |                |   v\n**      |----------------|\n**      | unallocated    |\n**      | space          |\n**      |----------------|   ^  Grows upwards\n**      | cell content   |   |  Arbitrary order interspersed with freeblocks.\n**      | area           |   |  and free space fragments.\n**      |----------------|\n**\n** The page headers looks like this:\n**\n**   OFFSET   SIZE     DESCRIPTION\n**      0       1      Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf\n**      1       2      byte offset to the first freeblock\n**      3       2      number of cells on this page\n**      5       2      first byte of the cell content area\n**      7       1      number of fragmented free bytes\n**      8       4      Right child (the Ptr(N) value).  Omitted on leaves.\n**\n** The flags define the format of this btree page.  The leaf flag means that\n** this page has no children.  The zerodata flag means that this page carries\n** only keys and no data.  The intkey flag means that the key is an integer\n** which is stored in the key size entry of the cell header rather than in\n** the payload area.\n**\n** The cell pointer array begins on the first byte after the page header.\n** The cell pointer array contains zero or more 2-byte numbers which are\n** offsets from the beginning of the page to the cell content in the cell\n** content area.  The cell pointers occur in sorted order.  The system strives\n** to keep free space after the last cell pointer so that new cells can\n** be easily added without having to defragment the page.\n**\n** Cell content is stored at the very end of the page and grows toward the\n** beginning of the page.\n**\n** Unused space within the cell content area is collected into a linked list of\n** freeblocks.  Each freeblock is at least 4 bytes in size.  The byte offset\n** to the first freeblock is given in the header.  Freeblocks occur in\n** increasing order.  Because a freeblock must be at least 4 bytes in size,\n** any group of 3 or fewer unused bytes in the cell content area cannot\n** exist on the freeblock chain.  A group of 3 or fewer free bytes is called\n** a fragment.  The total number of bytes in all fragments is recorded.\n** in the page header at offset 7.\n**\n**    SIZE    DESCRIPTION\n**      2     Byte offset of the next freeblock\n**      2     Bytes in this freeblock\n**\n** Cells are of variable length.  Cells are stored in the cell content area at\n** the end of the page.  Pointers to the cells are in the cell pointer array\n** that immediately follows the page header.  Cells is not necessarily\n** contiguous or in order, but cell pointers are contiguous and in order.\n**\n** Cell content makes use of variable length integers.  A variable\n** length integer is 1 to 9 bytes where the lower 7 bits of each \n** byte are used.  The integer consists of all bytes that have bit 8 set and\n** the first byte with bit 8 clear.  The most significant byte of the integer\n** appears first.  A variable-length integer may not be more than 9 bytes long.\n** As a special case, all 8 bytes of the 9th byte are used as data.  This\n** allows a 64-bit integer to be encoded in 9 bytes.\n**\n**    0x00                      becomes  0x00000000\n**    0x7f                      becomes  0x0000007f\n**    0x81 0x00                 becomes  0x00000080\n**    0x82 0x00                 becomes  0x00000100\n**    0x80 0x7f                 becomes  0x0000007f\n**    0x8a 0x91 0xd1 0xac 0x78  becomes  0x12345678\n**    0x81 0x81 0x81 0x81 0x01  becomes  0x10204081\n**\n** Variable length integers are used for rowids and to hold the number of\n** bytes of key and data in a btree cell.\n**\n** The content of a cell looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of the left child. Omitted if leaf flag is set.\n**     var    Number of bytes of data. Omitted if the zerodata flag is set.\n**     var    Number of bytes of key. Or the key itself if intkey flag is set.\n**      *     Payload\n**      4     First page of the overflow chain.  Omitted if no overflow\n**\n** Overflow pages form a linked list.  Each page except the last is completely\n** filled with data (pagesize - 4 bytes).  The last page can have as little\n** as 1 byte of data.\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next overflow page\n**      *     Data\n**\n** Freelist pages come in two subtypes: trunk pages and leaf pages.  The\n** file header points to the first in a linked list of trunk page.  Each trunk\n** page points to multiple leaf pages.  The content of a leaf page is\n** unspecified.  A trunk page looks like this:\n**\n**    SIZE    DESCRIPTION\n**      4     Page number of next trunk page\n**      4     Number of leaf pointers on this page\n**      *     zero or more pages numbers of leaves\n*/\n#include \"sqliteInt.h\"\n\n\n/* The following value is the maximum cell size assuming a maximum page\n** size give above.\n*/\n#define MX_CELL_SIZE(pBt)  ((int)(pBt->pageSize-8))\n\n/* The maximum number of cells on a single page of the database.  This\n** assumes a minimum cell size of 6 bytes  (4 bytes for the cell itself\n** plus 2 bytes for the index to the cell in the page header).  Such\n** small cells will be rare, but they are possible.\n*/\n#define MX_CELL(pBt) ((pBt->pageSize-8)/6)\n\n/* Forward declarations */\ntypedef struct MemPage MemPage;\ntypedef struct BtLock BtLock;\ntypedef struct CellInfo CellInfo;\n\n/*\n** This is a magic string that appears at the beginning of every\n** SQLite database in order to identify the file as a real database.\n**\n** You can change this value at compile-time by specifying a\n** -DSQLITE_FILE_HEADER=\"...\" on the compiler command-line.  The\n** header must be exactly 16 bytes including the zero-terminator so\n** the string itself should be 15 characters long.  If you change\n** the header, then your custom library will not be able to read \n** databases generated by the standard tools and the standard tools\n** will not be able to read databases created by your custom library.\n*/\n#ifndef SQLITE_FILE_HEADER /* 123456789 123456 */\n#  define SQLITE_FILE_HEADER \"SQLite format 3\"\n#endif\n\n/*\n** Page type flags.  An ORed combination of these flags appear as the\n** first byte of on-disk image of every BTree page.\n*/\n#define PTF_INTKEY    0x01\n#define PTF_ZERODATA  0x02\n#define PTF_LEAFDATA  0x04\n#define PTF_LEAF      0x08\n\n/*\n** An instance of this object stores information about each a single database\n** page that has been loaded into memory.  The information in this object\n** is derived from the raw on-disk page content.\n**\n** As each database page is loaded into memory, the pager allocats an\n** instance of this object and zeros the first 8 bytes.  (This is the\n** \"extra\" information associated with each page of the pager.)\n**\n** Access to all fields of this structure is controlled by the mutex\n** stored in MemPage.pBt->mutex.\n*/\nstruct MemPage {\n  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */\n  u8 bBusy;            /* Prevent endless loops on corrupt database files */\n  u8 intKey;           /* True if table b-trees.  False for index b-trees */\n  u8 intKeyLeaf;       /* True if the leaf of an intKey table */\n  Pgno pgno;           /* Page number for this page */\n  /* Only the first 8 bytes (above) are zeroed by pager.c when a new page\n  ** is allocated. All fields that follow must be initialized before use */\n  u8 leaf;             /* True if a leaf page */\n  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */\n  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */\n  u8 max1bytePayload;  /* min(maxLocal,127) */\n  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */\n  u16 maxLocal;        /* Copy of BtShared.maxLocal or BtShared.maxLeaf */\n  u16 minLocal;        /* Copy of BtShared.minLocal or BtShared.minLeaf */\n  u16 cellOffset;      /* Index in aData of first cell pointer */\n  u16 nFree;           /* Number of free bytes on the page */\n  u16 nCell;           /* Number of cells on this page, local and ovfl */\n  u16 maskPage;        /* Mask for page offset */\n  u16 aiOvfl[4];       /* Insert the i-th overflow cell before the aiOvfl-th\n                       ** non-overflow cell */\n  u8 *apOvfl[4];       /* Pointers to the body of overflow cells */\n  BtShared *pBt;       /* Pointer to BtShared that this page is part of */\n  u8 *aData;           /* Pointer to disk image of the page data */\n  u8 *aDataEnd;        /* One byte past the end of usable data */\n  u8 *aCellIdx;        /* The cell index area */\n  u8 *aDataOfst;       /* Same as aData for leaves.  aData+4 for interior */\n  DbPage *pDbPage;     /* Pager page handle */\n  u16 (*xCellSize)(MemPage*,u8*);             /* cellSizePtr method */\n  void (*xParseCell)(MemPage*,u8*,CellInfo*); /* btreeParseCell method */\n};\n\n/*\n** A linked list of the following structures is stored at BtShared.pLock.\n** Locks are added (or upgraded from READ_LOCK to WRITE_LOCK) when a cursor \n** is opened on the table with root page BtShared.iTable. Locks are removed\n** from this list when a transaction is committed or rolled back, or when\n** a btree handle is closed.\n*/\nstruct BtLock {\n  Btree *pBtree;        /* Btree handle holding this lock */\n  Pgno iTable;          /* Root page of table */\n  u8 eLock;             /* READ_LOCK or WRITE_LOCK */\n  BtLock *pNext;        /* Next in BtShared.pLock list */\n};\n\n/* Candidate values for BtLock.eLock */\n#define READ_LOCK     1\n#define WRITE_LOCK    2\n\n/* A Btree handle\n**\n** A database connection contains a pointer to an instance of\n** this object for every database file that it has open.  This structure\n** is opaque to the database connection.  The database connection cannot\n** see the internals of this structure and only deals with pointers to\n** this structure.\n**\n** For some database files, the same underlying database cache might be \n** shared between multiple connections.  In that case, each connection\n** has it own instance of this object.  But each instance of this object\n** points to the same BtShared object.  The database cache and the\n** schema associated with the database file are all contained within\n** the BtShared object.\n**\n** All fields in this structure are accessed under sqlite3.mutex.\n** The pBt pointer itself may not be changed while there exists cursors \n** in the referenced BtShared that point back to this Btree since those\n** cursors have to go through this Btree to find their BtShared and\n** they often do so without holding sqlite3.mutex.\n*/\nstruct Btree {\n  sqlite3 *db;       /* The database connection holding this btree */\n  BtShared *pBt;     /* Sharable content of this btree */\n  u8 inTrans;        /* TRANS_NONE, TRANS_READ or TRANS_WRITE */\n  u8 sharable;       /* True if we can share pBt with another db */\n  u8 locked;         /* True if db currently has pBt locked */\n  u8 hasIncrblobCur; /* True if there are one or more Incrblob cursors */\n  int wantToLock;    /* Number of nested calls to sqlite3BtreeEnter() */\n  int nBackup;       /* Number of backup operations reading this btree */\n  u32 iDataVersion;  /* Combines with pBt->pPager->iDataVersion */\n  Btree *pNext;      /* List of other sharable Btrees from the same db */\n  Btree *pPrev;      /* Back pointer of the same list */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  BtLock lock;       /* Object used to lock page 1 */\n#endif\n};\n\n/*\n** Btree.inTrans may take one of the following values.\n**\n** If the shared-data extension is enabled, there may be multiple users\n** of the Btree structure. At most one of these may open a write transaction,\n** but any number may have active read transactions.\n*/\n#define TRANS_NONE  0\n#define TRANS_READ  1\n#define TRANS_WRITE 2\n\n/*\n** An instance of this object represents a single database file.\n** \n** A single database file can be in use at the same time by two\n** or more database connections.  When two or more connections are\n** sharing the same database file, each connection has it own\n** private Btree object for the file and each of those Btrees points\n** to this one BtShared object.  BtShared.nRef is the number of\n** connections currently sharing this database file.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** mutex, except for nRef and pNext which are accessed under the\n** global SQLITE_MUTEX_STATIC_MASTER mutex.  The pPager field\n** may not be modified once it is initially set as long as nRef>0.\n** The pSchema field may be set once under BtShared.mutex and\n** thereafter is unchanged as long as nRef>0.\n**\n** isPending:\n**\n**   If a BtShared client fails to obtain a write-lock on a database\n**   table (because there exists one or more read-locks on the table),\n**   the shared-cache enters 'pending-lock' state and isPending is\n**   set to true.\n**\n**   The shared-cache leaves the 'pending lock' state when either of\n**   the following occur:\n**\n**     1) The current writer (BtShared.pWriter) concludes its transaction, OR\n**     2) The number of locks held by other connections drops to zero.\n**\n**   while in the 'pending-lock' state, no connection may start a new\n**   transaction.\n**\n**   This feature is included to help prevent writer-starvation.\n*/\nstruct BtShared {\n  Pager *pPager;        /* The page cache */\n  sqlite3 *db;          /* Database connection currently using this Btree */\n  BtCursor *pCursor;    /* A list of all open cursors */\n  MemPage *pPage1;      /* First page of the database */\n  u8 openFlags;         /* Flags to sqlite3BtreeOpen() */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  u8 autoVacuum;        /* True if auto-vacuum is enabled */\n  u8 incrVacuum;        /* True if incr-vacuum is enabled */\n  u8 bDoTruncate;       /* True to truncate db on commit */\n#endif\n  u8 inTransaction;     /* Transaction state */\n  u8 max1bytePayload;   /* Maximum first byte of cell for a 1-byte payload */\n#ifdef SQLITE_HAS_CODEC\n  u8 optimalReserve;    /* Desired amount of reserved space per page */\n#endif\n  u16 btsFlags;         /* Boolean parameters.  See BTS_* macros below */\n  u16 maxLocal;         /* Maximum local payload in non-LEAFDATA tables */\n  u16 minLocal;         /* Minimum local payload in non-LEAFDATA tables */\n  u16 maxLeaf;          /* Maximum local payload in a LEAFDATA table */\n  u16 minLeaf;          /* Minimum local payload in a LEAFDATA table */\n  u32 pageSize;         /* Total number of bytes on a page */\n  u32 usableSize;       /* Number of usable bytes on each page */\n  int nTransaction;     /* Number of open transactions (read + write) */\n  u32 nPage;            /* Number of pages in the database */\n  void *pSchema;        /* Pointer to space allocated by sqlite3BtreeSchema() */\n  void (*xFreeSchema)(void*);  /* Destructor for BtShared.pSchema */\n  sqlite3_mutex *mutex; /* Non-recursive mutex required to access this object */\n  Bitvec *pHasContent;  /* Set of pages moved to free-list this transaction */\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nRef;             /* Number of references to this structure */\n  BtShared *pNext;      /* Next on a list of sharable BtShared structs */\n  BtLock *pLock;        /* List of locks held on this shared-btree struct */\n  Btree *pWriter;       /* Btree with currently open write transaction */\n#endif\n  u8 *pTmpSpace;        /* Temp space sufficient to hold a single cell */\n};\n\n/*\n** Allowed values for BtShared.btsFlags\n*/\n#define BTS_READ_ONLY        0x0001   /* Underlying file is readonly */\n#define BTS_PAGESIZE_FIXED   0x0002   /* Page size can no longer be changed */\n#define BTS_SECURE_DELETE    0x0004   /* PRAGMA secure_delete is enabled */\n#define BTS_OVERWRITE        0x0008   /* Overwrite deleted content with zeros */\n#define BTS_FAST_SECURE      0x000c   /* Combination of the previous two */\n#define BTS_INITIALLY_EMPTY  0x0010   /* Database was empty at trans start */\n#define BTS_NO_WAL           0x0020   /* Do not open write-ahead-log files */\n#define BTS_EXCLUSIVE        0x0040   /* pWriter has an exclusive lock */\n#define BTS_PENDING          0x0080   /* Waiting for read-locks to clear */\n\n/*\n** An instance of the following structure is used to hold information\n** about a cell.  The parseCellPtr() function fills in this structure\n** based on information extract from the raw disk page.\n*/\nstruct CellInfo {\n  i64 nKey;      /* The key for INTKEY tables, or nPayload otherwise */\n  u8 *pPayload;  /* Pointer to the start of payload */\n  u32 nPayload;  /* Bytes of payload */\n  u16 nLocal;    /* Amount of payload held locally, not on overflow */\n  u16 nSize;     /* Size of the cell content on the main b-tree page */\n};\n\n/*\n** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than\n** this will be declared corrupt. This value is calculated based on a\n** maximum database size of 2^31 pages a minimum fanout of 2 for a\n** root-node and 3 for all other internal nodes.\n**\n** If a tree that appears to be taller than this is encountered, it is\n** assumed that the database is corrupt.\n*/\n#define BTCURSOR_MAX_DEPTH 20\n\n/*\n** A cursor is a pointer to a particular entry within a particular\n** b-tree within a database file.\n**\n** The entry is identified by its MemPage and the index in\n** MemPage.aCell[] of the entry.\n**\n** A single database file can be shared by two more database connections,\n** but cursors cannot be shared.  Each cursor is associated with a\n** particular database connection identified BtCursor.pBtree.db.\n**\n** Fields in this structure are accessed under the BtShared.mutex\n** found at self->pBt->mutex. \n**\n** skipNext meaning:\n**    eState==SKIPNEXT && skipNext>0:  Next sqlite3BtreeNext() is no-op.\n**    eState==SKIPNEXT && skipNext<0:  Next sqlite3BtreePrevious() is no-op.\n**    eState==FAULT:                   Cursor fault with skipNext as error code.\n*/\nstruct BtCursor {\n  u8 eState;                /* One of the CURSOR_XXX constants (see below) */\n  u8 curFlags;              /* zero or more BTCF_* flags defined below */\n  u8 curPagerFlags;         /* Flags to send to sqlite3PagerGet() */\n  u8 hints;                 /* As configured by CursorSetHints() */\n  int nOvflAlloc;           /* Allocated size of aOverflow[] array */\n  Btree *pBtree;            /* The Btree to which this cursor belongs */\n  BtShared *pBt;            /* The BtShared this cursor points to */\n  BtCursor *pNext;          /* Forms a linked list of all cursors */\n  Pgno *aOverflow;          /* Cache of overflow page locations */\n  CellInfo info;            /* A parse of the cell we are pointing at */\n  i64 nKey;                 /* Size of pKey, or last integer key */\n  void *pKey;               /* Saved key that was cursor last known position */\n  Pgno pgnoRoot;            /* The root page of this tree */\n  int skipNext;    /* Prev() is noop if negative. Next() is noop if positive.\n                   ** Error code if eState==CURSOR_FAULT */\n  /* All fields above are zeroed when the cursor is allocated.  See\n  ** sqlite3BtreeCursorZero().  Fields that follow must be manually\n  ** initialized. */\n  i8 iPage;                 /* Index of current page in apPage */\n  u8 curIntKey;             /* Value of apPage[0]->intKey */\n  u16 ix;                   /* Current index for apPage[iPage] */\n  u16 aiIdx[BTCURSOR_MAX_DEPTH-1];     /* Current index in apPage[i] */\n  struct KeyInfo *pKeyInfo;            /* Arg passed to comparison function */\n  MemPage *pPage;                        /* Current page */\n  MemPage *apPage[BTCURSOR_MAX_DEPTH-1]; /* Stack of parents of current page */\n};\n\n/*\n** Legal values for BtCursor.curFlags\n*/\n#define BTCF_WriteFlag    0x01   /* True if a write cursor */\n#define BTCF_ValidNKey    0x02   /* True if info.nKey is valid */\n#define BTCF_ValidOvfl    0x04   /* True if aOverflow is valid */\n#define BTCF_AtLast       0x08   /* Cursor is pointing ot the last entry */\n#define BTCF_Incrblob     0x10   /* True if an incremental I/O handle */\n#define BTCF_Multiple     0x20   /* Maybe another cursor on the same btree */\n\n/*\n** Potential values for BtCursor.eState.\n**\n** CURSOR_INVALID:\n**   Cursor does not point to a valid entry. This can happen (for example) \n**   because the table is empty or because BtreeCursorFirst() has not been\n**   called.\n**\n** CURSOR_VALID:\n**   Cursor points to a valid entry. getPayload() etc. may be called.\n**\n** CURSOR_SKIPNEXT:\n**   Cursor is valid except that the Cursor.skipNext field is non-zero\n**   indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious()\n**   operation should be a no-op.\n**\n** CURSOR_REQUIRESEEK:\n**   The table that this cursor was opened on still exists, but has been \n**   modified since the cursor was last used. The cursor position is saved\n**   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in \n**   this state, restoreCursorPosition() can be called to attempt to\n**   seek the cursor to the saved position.\n**\n** CURSOR_FAULT:\n**   An unrecoverable error (an I/O error or a malloc failure) has occurred\n**   on a different connection that shares the BtShared cache with this\n**   cursor.  The error has left the cache in an inconsistent state.\n**   Do nothing else with this cursor.  Any attempt to use the cursor\n**   should return the error code stored in BtCursor.skipNext\n*/\n#define CURSOR_INVALID           0\n#define CURSOR_VALID             1\n#define CURSOR_SKIPNEXT          2\n#define CURSOR_REQUIRESEEK       3\n#define CURSOR_FAULT             4\n\n/* \n** The database page the PENDING_BYTE occupies. This page is never used.\n*/\n# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)\n\n/*\n** These macros define the location of the pointer-map entry for a \n** database page. The first argument to each is the number of usable\n** bytes on each page of the database (often 1024). The second is the\n** page number to look up in the pointer map.\n**\n** PTRMAP_PAGENO returns the database page number of the pointer-map\n** page that stores the required pointer. PTRMAP_PTROFFSET returns\n** the offset of the requested map entry.\n**\n** If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page,\n** then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be\n** used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements\n** this test.\n*/\n#define PTRMAP_PAGENO(pBt, pgno) ptrmapPageno(pBt, pgno)\n#define PTRMAP_PTROFFSET(pgptrmap, pgno) (5*(pgno-pgptrmap-1))\n#define PTRMAP_ISPAGE(pBt, pgno) (PTRMAP_PAGENO((pBt),(pgno))==(pgno))\n\n/*\n** The pointer map is a lookup table that identifies the parent page for\n** each child page in the database file.  The parent page is the page that\n** contains a pointer to the child.  Every page in the database contains\n** 0 or 1 parent pages.  (In this context 'database page' refers\n** to any page that is not part of the pointer map itself.)  Each pointer map\n** entry consists of a single byte 'type' and a 4 byte parent page number.\n** The PTRMAP_XXX identifiers below are the valid types.\n**\n** The purpose of the pointer map is to facility moving pages from one\n** position in the file to another as part of autovacuum.  When a page\n** is moved, the pointer in its parent must be updated to point to the\n** new location.  The pointer map is used to locate the parent page quickly.\n**\n** PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not\n**                  used in this case.\n**\n** PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number \n**                  is not used in this case.\n**\n** PTRMAP_OVERFLOW1: The database page is the first page in a list of \n**                   overflow pages. The page number identifies the page that\n**                   contains the cell with a pointer to this overflow page.\n**\n** PTRMAP_OVERFLOW2: The database page is the second or later page in a list of\n**                   overflow pages. The page-number identifies the previous\n**                   page in the overflow page list.\n**\n** PTRMAP_BTREE: The database page is a non-root btree page. The page number\n**               identifies the parent page in the btree.\n*/\n#define PTRMAP_ROOTPAGE 1\n#define PTRMAP_FREEPAGE 2\n#define PTRMAP_OVERFLOW1 3\n#define PTRMAP_OVERFLOW2 4\n#define PTRMAP_BTREE 5\n\n/* A bunch of assert() statements to check the transaction state variables\n** of handle p (type Btree*) are internally consistent.\n*/\n#define btreeIntegrity(p) \\\n  assert( p->pBt->inTransaction!=TRANS_NONE || p->pBt->nTransaction==0 ); \\\n  assert( p->pBt->inTransaction>=p->inTrans ); \n\n\n/*\n** The ISAUTOVACUUM macro is used within balance_nonroot() to determine\n** if the database supports auto-vacuum or not. Because it is used\n** within an expression that is an argument to another macro \n** (sqliteMallocRaw), it is not possible to use conditional compilation.\n** So, this macro is defined instead.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\n#define ISAUTOVACUUM (pBt->autoVacuum)\n#else\n#define ISAUTOVACUUM 0\n#endif\n\n\n/*\n** This structure is passed around through all the sanity checking routines\n** in order to keep track of some global state information.\n**\n** The aRef[] array is allocated so that there is 1 bit for each page in\n** the database. As the integrity-check proceeds, for each page used in\n** the database the corresponding bit is set. This allows integrity-check to \n** detect pages that are used twice and orphaned pages (both of which \n** indicate corruption).\n*/\ntypedef struct IntegrityCk IntegrityCk;\nstruct IntegrityCk {\n  BtShared *pBt;    /* The tree being checked out */\n  Pager *pPager;    /* The associated pager.  Also accessible by pBt->pPager */\n  u8 *aPgRef;       /* 1 bit per page in the db (see above) */\n  Pgno nPage;       /* Number of pages in the database */\n  int mxErr;        /* Stop accumulating errors when this reaches zero */\n  int nErr;         /* Number of messages written to zErrMsg so far */\n  int mallocFailed; /* A memory allocation error has occurred */\n  const char *zPfx; /* Error message prefix */\n  int v1, v2;       /* Values for up to two %d fields in zPfx */\n  StrAccum errMsg;  /* Accumulate the error message text here */\n  u32 *heap;        /* Min-heap used for analyzing cell coverage */\n};\n\n/*\n** Routines to read or write a two- and four-byte big-endian integer values.\n*/\n#define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))\n#define get4byte sqlite3Get4byte\n#define put4byte sqlite3Put4byte\n\n/*\n** get2byteAligned(), unlike get2byte(), requires that its argument point to a\n** two-byte aligned address.  get2bytea() is only used for accessing the\n** cell addresses in a btree header.\n*/\n#if SQLITE_BYTEORDER==4321\n# define get2byteAligned(x)  (*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000\n# define get2byteAligned(x)  __builtin_bswap16(*(u16*)(x))\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n# define get2byteAligned(x)  _byteswap_ushort(*(u16*)(x))\n#else\n# define get2byteAligned(x)  ((x)[0]<<8 | (x)[1])\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/build.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the SQLite parser\n** when syntax rules are reduced.  The routines in this file handle the\n** following kinds of SQL syntax:\n**\n**     CREATE TABLE\n**     DROP TABLE\n**     CREATE INDEX\n**     DROP INDEX\n**     creating ID lists\n**     BEGIN TRANSACTION\n**     COMMIT\n**     ROLLBACK\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/*\n** The TableLock structure is only used by the sqlite3TableLock() and\n** codeTableLocks() functions.\n*/\nstruct TableLock {\n  int iDb;               /* The database containing the table to be locked */\n  int iTab;              /* The root page of the table to be locked */\n  u8 isWriteLock;        /* True for write lock.  False for a read lock */\n  const char *zLockName; /* Name of the table */\n};\n\n/*\n** Record the fact that we want to lock a table at run-time.  \n**\n** The table to be locked has root page iTab and is found in database iDb.\n** A read or a write lock can be taken depending on isWritelock.\n**\n** This routine just records the fact that the lock is desired.  The\n** code to make the lock occur is generated by a later call to\n** codeTableLocks() which occurs during sqlite3FinishCoding().\n*/\nvoid sqlite3TableLock(\n  Parse *pParse,     /* Parsing context */\n  int iDb,           /* Index of the database containing the table to lock */\n  int iTab,          /* Root page number of the table to be locked */\n  u8 isWriteLock,    /* True for a write lock */\n  const char *zName  /* Name of the table to be locked */\n){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i;\n  int nBytes;\n  TableLock *p;\n  assert( iDb>=0 );\n\n  if( iDb==1 ) return;\n  if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;\n  for(i=0; i<pToplevel->nTableLock; i++){\n    p = &pToplevel->aTableLock[i];\n    if( p->iDb==iDb && p->iTab==iTab ){\n      p->isWriteLock = (p->isWriteLock || isWriteLock);\n      return;\n    }\n  }\n\n  nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);\n  pToplevel->aTableLock =\n      sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);\n  if( pToplevel->aTableLock ){\n    p = &pToplevel->aTableLock[pToplevel->nTableLock++];\n    p->iDb = iDb;\n    p->iTab = iTab;\n    p->isWriteLock = isWriteLock;\n    p->zLockName = zName;\n  }else{\n    pToplevel->nTableLock = 0;\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Code an OP_TableLock instruction for each table locked by the\n** statement (configured by calls to sqlite3TableLock()).\n*/\nstatic void codeTableLocks(Parse *pParse){\n  int i;\n  Vdbe *pVdbe; \n\n  pVdbe = sqlite3GetVdbe(pParse);\n  assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */\n\n  for(i=0; i<pParse->nTableLock; i++){\n    TableLock *p = &pParse->aTableLock[i];\n    int p1 = p->iDb;\n    sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,\n                      p->zLockName, P4_STATIC);\n  }\n}\n#else\n  #define codeTableLocks(x)\n#endif\n\n/*\n** Return TRUE if the given yDbMask object is empty - if it contains no\n** 1 bits.  This routine is used by the DbMaskAllZero() and DbMaskNotZero()\n** macros when SQLITE_MAX_ATTACHED is greater than 30.\n*/\n#if SQLITE_MAX_ATTACHED>30\nint sqlite3DbMaskAllZero(yDbMask m){\n  int i;\n  for(i=0; i<sizeof(yDbMask); i++) if( m[i] ) return 0;\n  return 1;\n}\n#endif\n\n/*\n** This routine is called after a single SQL statement has been\n** parsed and a VDBE program to execute that statement has been\n** prepared.  This routine puts the finishing touches on the\n** VDBE program and resets the pParse structure for the next\n** parse.\n**\n** Note that if an error occurred, it might be the case that\n** no VDBE code was generated.\n*/\nvoid sqlite3FinishCoding(Parse *pParse){\n  sqlite3 *db;\n  Vdbe *v;\n\n  assert( pParse->pToplevel==0 );\n  db = pParse->db;\n  if( pParse->nested ) return;\n  if( db->mallocFailed || pParse->nErr ){\n    if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;\n    return;\n  }\n\n  /* Begin by generating some termination code at the end of the\n  ** vdbe program\n  */\n  v = sqlite3GetVdbe(pParse);\n  assert( !pParse->isMultiWrite \n       || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));\n  if( v ){\n    sqlite3VdbeAddOp0(v, OP_Halt);\n\n#if SQLITE_USER_AUTHENTICATION\n    if( pParse->nTableLock>0 && db->init.busy==0 ){\n      sqlite3UserAuthInit(db);\n      if( db->auth.authLevel<UAUTH_User ){\n        sqlite3ErrorMsg(pParse, \"user not authenticated\");\n        pParse->rc = SQLITE_AUTH_USER;\n        return;\n      }\n    }\n#endif\n\n    /* The cookie mask contains one bit for each database file open.\n    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are\n    ** set for each database that is used.  Generate code to start a\n    ** transaction on each used database and to verify the schema cookie\n    ** on each used database.\n    */\n    if( db->mallocFailed==0 \n     && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)\n    ){\n      int iDb, i;\n      assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );\n      sqlite3VdbeJumpHere(v, 0);\n      for(iDb=0; iDb<db->nDb; iDb++){\n        Schema *pSchema;\n        if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue;\n        sqlite3VdbeUsesBtree(v, iDb);\n        pSchema = db->aDb[iDb].pSchema;\n        sqlite3VdbeAddOp4Int(v,\n          OP_Transaction,                    /* Opcode */\n          iDb,                               /* P1 */\n          DbMaskTest(pParse->writeMask,iDb), /* P2 */\n          pSchema->schema_cookie,            /* P3 */\n          pSchema->iGeneration               /* P4 */\n        );\n        if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1);\n        VdbeComment((v,\n              \"usesStmtJournal=%d\", pParse->mayAbort && pParse->isMultiWrite));\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      for(i=0; i<pParse->nVtabLock; i++){\n        char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);\n        sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);\n      }\n      pParse->nVtabLock = 0;\n#endif\n\n      /* Once all the cookies have been verified and transactions opened, \n      ** obtain the required table-locks. This is a no-op unless the \n      ** shared-cache feature is enabled.\n      */\n      codeTableLocks(pParse);\n\n      /* Initialize any AUTOINCREMENT data structures required.\n      */\n      sqlite3AutoincrementBegin(pParse);\n\n      /* Code constant expressions that where factored out of inner loops */\n      if( pParse->pConstExpr ){\n        ExprList *pEL = pParse->pConstExpr;\n        pParse->okConstFactor = 0;\n        for(i=0; i<pEL->nExpr; i++){\n          sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);\n        }\n      }\n\n      /* Finally, jump back to the beginning of the executable code. */\n      sqlite3VdbeGoto(v, 1);\n    }\n  }\n\n\n  /* Get the VDBE program ready for execution\n  */\n  if( v && pParse->nErr==0 && !db->mallocFailed ){\n    assert( pParse->iCacheLevel==0 );  /* Disables and re-enables match */\n    /* A minimum of one cursor is required if autoincrement is used\n    *  See ticket [a696379c1f08866] */\n    if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;\n    sqlite3VdbeMakeReady(v, pParse);\n    pParse->rc = SQLITE_DONE;\n  }else{\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Run the parser and code generator recursively in order to generate\n** code for the SQL statement given onto the end of the pParse context\n** currently under construction.  When the parser is run recursively\n** this way, the final OP_Halt is not appended and other initialization\n** and finalization steps are omitted because those are handling by the\n** outermost parser.\n**\n** Not everything is nestable.  This facility is designed to permit\n** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER.  Use\n** care if you decide to try to use this routine for some other purposes.\n*/\nvoid sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  char *zErrMsg = 0;\n  sqlite3 *db = pParse->db;\n  char saveBuf[PARSE_TAIL_SZ];\n\n  if( pParse->nErr ) return;\n  assert( pParse->nested<10 );  /* Nesting should only be of limited depth */\n  va_start(ap, zFormat);\n  zSql = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( zSql==0 ){\n    return;   /* A malloc must have failed */\n  }\n  pParse->nested++;\n  memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);\n  memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);\n  sqlite3RunParser(pParse, zSql, &zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  sqlite3DbFree(db, zSql);\n  memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);\n  pParse->nested--;\n}\n\n#if SQLITE_USER_AUTHENTICATION\n/*\n** Return TRUE if zTable is the name of the system table that stores the\n** list of users and their access credentials.\n*/\nint sqlite3UserAuthTable(const char *zTable){\n  return sqlite3_stricmp(zTable, \"sqlite_user\")==0;\n}\n#endif\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the table and the\n** first matching table is returned.  (No checking for duplicate table\n** names is done.)  The search order is TEMP first, then MAIN, then any\n** auxiliary databases added using the ATTACH command.\n**\n** See also sqlite3LocateTable().\n*/\nTable *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){\n  Table *p = 0;\n  int i;\n\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n#if SQLITE_USER_AUTHENTICATION\n  /* Only the admin user is allowed to know that the sqlite_user table\n  ** exists */\n  if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){\n    return 0;\n  }\n#endif\n  while(1){\n    for(i=OMIT_TEMPDB; i<db->nDb; i++){\n      int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */\n      if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){\n        assert( sqlite3SchemaMutexHeld(db, j, 0) );\n        p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);\n        if( p ) return p;\n      }\n    }\n    /* Not found.  If the name we were looking for was temp.sqlite_master\n    ** then change the name to sqlite_temp_master and try again. */\n    if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;\n    if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;\n    zName = TEMP_MASTER_NAME;\n  }\n  return 0;\n}\n\n/*\n** Locate the in-memory structure that describes a particular database\n** table given the name of that table and (optionally) the name of the\n** database containing the table.  Return NULL if not found.  Also leave an\n** error message in pParse->zErrMsg.\n**\n** The difference between this routine and sqlite3FindTable() is that this\n** routine leaves an error message in pParse->zErrMsg where\n** sqlite3FindTable() does not.\n*/\nTable *sqlite3LocateTable(\n  Parse *pParse,         /* context in which to report errors */\n  u32 flags,             /* LOCATE_VIEW or LOCATE_NOERR */\n  const char *zName,     /* Name of the table we are looking for */\n  const char *zDbase     /* Name of the database.  Might be NULL */\n){\n  Table *p;\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return 0;\n  }\n\n  p = sqlite3FindTable(pParse->db, zName, zDbase);\n  if( p==0 ){\n    const char *zMsg = flags & LOCATE_VIEW ? \"no such view\" : \"no such table\";\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){\n      /* If zName is the not the name of a table in the schema created using\n      ** CREATE, then check to see if it is the name of an virtual table that\n      ** can be an eponymous virtual table. */\n      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);\n      if( pMod==0 && sqlite3_strnicmp(zName, \"pragma_\", 7)==0 ){\n        pMod = sqlite3PragmaVtabRegister(pParse->db, zName);\n      }\n      if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){\n        return pMod->pEpoTab;\n      }\n    }\n#endif\n    if( (flags & LOCATE_NOERR)==0 ){\n      if( zDbase ){\n        sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zMsg, zDbase, zName);\n      }else{\n        sqlite3ErrorMsg(pParse, \"%s: %s\", zMsg, zName);\n      }\n      pParse->checkSchema = 1;\n    }\n  }\n\n  return p;\n}\n\n/*\n** Locate the table identified by *p.\n**\n** This is a wrapper around sqlite3LocateTable(). The difference between\n** sqlite3LocateTable() and this function is that this function restricts\n** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be\n** non-NULL if it is part of a view or trigger program definition. See\n** sqlite3FixSrcList() for details.\n*/\nTable *sqlite3LocateTableItem(\n  Parse *pParse, \n  u32 flags,\n  struct SrcList_item *p\n){\n  const char *zDb;\n  assert( p->pSchema==0 || p->zDatabase==0 );\n  if( p->pSchema ){\n    int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);\n    zDb = pParse->db->aDb[iDb].zDbSName;\n  }else{\n    zDb = p->zDatabase;\n  }\n  return sqlite3LocateTable(pParse, flags, p->zName, zDb);\n}\n\n/*\n** Locate the in-memory structure that describes \n** a particular index given the name of that index\n** and the name of the database that contains the index.\n** Return NULL if not found.\n**\n** If zDatabase is 0, all databases are searched for the\n** table and the first matching index is returned.  (No checking\n** for duplicate index names is done.)  The search order is\n** TEMP first, then MAIN, then any auxiliary databases added\n** using the ATTACH command.\n*/\nIndex *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){\n  Index *p = 0;\n  int i;\n  /* All mutexes are required for schema access.  Make sure we hold them. */\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    Schema *pSchema = db->aDb[j].pSchema;\n    assert( pSchema );\n    if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zDbSName) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    p = sqlite3HashFind(&pSchema->idxHash, zName);\n    if( p ) break;\n  }\n  return p;\n}\n\n/*\n** Reclaim the memory used by an index\n*/\nstatic void freeIndex(sqlite3 *db, Index *p){\n#ifndef SQLITE_OMIT_ANALYZE\n  sqlite3DeleteIndexSamples(db, p);\n#endif\n  sqlite3ExprDelete(db, p->pPartIdxWhere);\n  sqlite3ExprListDelete(db, p->aColExpr);\n  sqlite3DbFree(db, p->zColAff);\n  if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_free(p->aiRowEst);\n#endif\n  sqlite3DbFree(db, p);\n}\n\n/*\n** For the index called zIdxName which is found in the database iDb,\n** unlike that index from its Table then remove the index from\n** the index hash table and free all memory structures associated\n** with the index.\n*/\nvoid sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){\n  Index *pIndex;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &db->aDb[iDb].pSchema->idxHash;\n  pIndex = sqlite3HashInsert(pHash, zIdxName, 0);\n  if( ALWAYS(pIndex) ){\n    if( pIndex->pTable->pIndex==pIndex ){\n      pIndex->pTable->pIndex = pIndex->pNext;\n    }else{\n      Index *p;\n      /* Justification of ALWAYS();  The index must be on the list of\n      ** indices. */\n      p = pIndex->pTable->pIndex;\n      while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }\n      if( ALWAYS(p && p->pNext==pIndex) ){\n        p->pNext = pIndex->pNext;\n      }\n    }\n    freeIndex(db, pIndex);\n  }\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Look through the list of open database files in db->aDb[] and if\n** any have been closed, remove them from the list.  Reallocate the\n** db->aDb[] structure to a smaller size, if possible.\n**\n** Entry 0 (the \"main\" database) and entry 1 (the \"temp\" database)\n** are never candidates for being collapsed.\n*/\nvoid sqlite3CollapseDatabaseArray(sqlite3 *db){\n  int i, j;\n  for(i=j=2; i<db->nDb; i++){\n    struct Db *pDb = &db->aDb[i];\n    if( pDb->pBt==0 ){\n      sqlite3DbFree(db, pDb->zDbSName);\n      pDb->zDbSName = 0;\n      continue;\n    }\n    if( j<i ){\n      db->aDb[j] = db->aDb[i];\n    }\n    j++;\n  }\n  db->nDb = j;\n  if( db->nDb<=2 && db->aDb!=db->aDbStatic ){\n    memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0]));\n    sqlite3DbFree(db, db->aDb);\n    db->aDb = db->aDbStatic;\n  }\n}\n\n/*\n** Reset the schema for the database at index iDb.  Also reset the\n** TEMP schema.  The reset is deferred if db->nSchemaLock is not zero.\n** Deferred resets may be run by calling with iDb<0.\n*/\nvoid sqlite3ResetOneSchema(sqlite3 *db, int iDb){\n  int i;\n  assert( iDb<db->nDb );\n\n  if( iDb>=0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    DbSetProperty(db, iDb, DB_ResetWanted);\n    DbSetProperty(db, 1, DB_ResetWanted);\n  }\n\n  if( db->nSchemaLock==0 ){\n    for(i=0; i<db->nDb; i++){\n      if( DbHasProperty(db, i, DB_ResetWanted) ){\n        sqlite3SchemaClear(db->aDb[i].pSchema);\n      }\n    }\n  }\n}\n\n/*\n** Erase all schema information from all attached databases (including\n** \"main\" and \"temp\") for a single database connection.\n*/\nvoid sqlite3ResetAllSchemasOfConnection(sqlite3 *db){\n  int i;\n  sqlite3BtreeEnterAll(db);\n  assert( db->nSchemaLock==0 );\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pSchema ){\n      sqlite3SchemaClear(pDb->pSchema);\n    }\n  }\n  db->mDbFlags &= ~DBFLAG_SchemaChange;\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n  sqlite3CollapseDatabaseArray(db);\n}\n\n/*\n** This routine is called when a commit occurs.\n*/\nvoid sqlite3CommitInternalChanges(sqlite3 *db){\n  db->mDbFlags &= ~DBFLAG_SchemaChange;\n}\n\n/*\n** Delete memory allocated for the column names of a table or view (the\n** Table.aCol[] array).\n*/\nvoid sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){\n  int i;\n  Column *pCol;\n  assert( pTable!=0 );\n  if( (pCol = pTable->aCol)!=0 ){\n    for(i=0; i<pTable->nCol; i++, pCol++){\n      sqlite3DbFree(db, pCol->zName);\n      sqlite3ExprDelete(db, pCol->pDflt);\n      sqlite3DbFree(db, pCol->zColl);\n    }\n    sqlite3DbFree(db, pTable->aCol);\n  }\n}\n\n/*\n** Remove the memory data structures associated with the given\n** Table.  No changes are made to disk by this routine.\n**\n** This routine just deletes the data structure.  It does not unlink\n** the table data structure from the hash table.  But it does destroy\n** memory structures of the indices and foreign keys associated with \n** the table.\n**\n** The db parameter is optional.  It is needed if the Table object \n** contains lookaside memory.  (Table objects in the schema do not use\n** lookaside memory, but some ephemeral Table objects do.)  Or the\n** db parameter can be used with db->pnBytesFreed to measure the memory\n** used by the Table object.\n*/\nstatic void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){\n  Index *pIndex, *pNext;\n\n#ifdef SQLITE_DEBUG\n  /* Record the number of outstanding lookaside allocations in schema Tables\n  ** prior to doing any free() operations.  Since schema Tables do not use\n  ** lookaside, this number should not change. */\n  int nLookaside = 0;\n  if( db && (pTable->tabFlags & TF_Ephemeral)==0 ){\n    nLookaside = sqlite3LookasideUsed(db, 0);\n  }\n#endif\n\n  /* Delete all indices associated with this table. */\n  for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){\n    pNext = pIndex->pNext;\n    assert( pIndex->pSchema==pTable->pSchema\n         || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );\n    if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){\n      char *zName = pIndex->zName; \n      TESTONLY ( Index *pOld = ) sqlite3HashInsert(\n         &pIndex->pSchema->idxHash, zName, 0\n      );\n      assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n      assert( pOld==pIndex || pOld==0 );\n    }\n    freeIndex(db, pIndex);\n  }\n\n  /* Delete any foreign keys attached to this table. */\n  sqlite3FkDelete(db, pTable);\n\n  /* Delete the Table structure itself.\n  */\n  sqlite3DeleteColumnNames(db, pTable);\n  sqlite3DbFree(db, pTable->zName);\n  sqlite3DbFree(db, pTable->zColAff);\n  sqlite3SelectDelete(db, pTable->pSelect);\n  sqlite3ExprListDelete(db, pTable->pCheck);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3VtabClear(db, pTable);\n#endif\n  sqlite3DbFree(db, pTable);\n\n  /* Verify that no lookaside memory was used by schema tables */\n  assert( nLookaside==0 || nLookaside==sqlite3LookasideUsed(db,0) );\n}\nvoid sqlite3DeleteTable(sqlite3 *db, Table *pTable){\n  /* Do not delete the table until the reference count reaches zero. */\n  if( !pTable ) return;\n  if( ((!db || db->pnBytesFreed==0) && (--pTable->nTabRef)>0) ) return;\n  deleteTable(db, pTable);\n}\n\n\n/*\n** Unlink the given table from the hash tables and the delete the\n** table structure with all its indices and foreign keys.\n*/\nvoid sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){\n  Table *p;\n  Db *pDb;\n\n  assert( db!=0 );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( zTabName );\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  testcase( zTabName[0]==0 );  /* Zero-length table names are allowed */\n  pDb = &db->aDb[iDb];\n  p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, 0);\n  sqlite3DeleteTable(db, p);\n  db->mDbFlags |= DBFLAG_SchemaChange;\n}\n\n/*\n** Given a token, return a string that consists of the text of that\n** token.  Space to hold the returned string\n** is obtained from sqliteMalloc() and must be freed by the calling\n** function.\n**\n** Any quotation marks (ex:  \"name\", 'name', [name], or `name`) that\n** surround the body of the token are removed.\n**\n** Tokens are often just pointers into the original SQL text and so\n** are not \\000 terminated and are not persistent.  The returned string\n** is \\000 terminated and is persistent.\n*/\nchar *sqlite3NameFromToken(sqlite3 *db, Token *pName){\n  char *zName;\n  if( pName ){\n    zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n);\n    sqlite3Dequote(zName);\n  }else{\n    zName = 0;\n  }\n  return zName;\n}\n\n/*\n** Open the sqlite_master table stored in database number iDb for\n** writing. The table is opened using cursor 0.\n*/\nvoid sqlite3OpenMasterTable(Parse *p, int iDb){\n  Vdbe *v = sqlite3GetVdbe(p);\n  sqlite3TableLock(p, iDb, MASTER_ROOT, 1, MASTER_NAME);\n  sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5);\n  if( p->nTab==0 ){\n    p->nTab = 1;\n  }\n}\n\n/*\n** Parameter zName points to a nul-terminated buffer containing the name\n** of a database (\"main\", \"temp\" or the name of an attached db). This\n** function returns the index of the named database in db->aDb[], or\n** -1 if the named db cannot be found.\n*/\nint sqlite3FindDbName(sqlite3 *db, const char *zName){\n  int i = -1;         /* Database number */\n  if( zName ){\n    Db *pDb;\n    for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){\n      if( 0==sqlite3_stricmp(pDb->zDbSName, zName) ) break;\n      /* \"main\" is always an acceptable alias for the primary database\n      ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */\n      if( i==0 && 0==sqlite3_stricmp(\"main\", zName) ) break;\n    }\n  }\n  return i;\n}\n\n/*\n** The token *pName contains the name of a database (either \"main\" or\n** \"temp\" or the name of an attached db). This routine returns the\n** index of the named database in db->aDb[], or -1 if the named db \n** does not exist.\n*/\nint sqlite3FindDb(sqlite3 *db, Token *pName){\n  int i;                               /* Database number */\n  char *zName;                         /* Name we are searching for */\n  zName = sqlite3NameFromToken(db, pName);\n  i = sqlite3FindDbName(db, zName);\n  sqlite3DbFree(db, zName);\n  return i;\n}\n\n/* The table or view or trigger name is passed to this routine via tokens\n** pName1 and pName2. If the table name was fully qualified, for example:\n**\n** CREATE TABLE xxx.yyy (...);\n** \n** Then pName1 is set to \"xxx\" and pName2 \"yyy\". On the other hand if\n** the table name is not fully qualified, i.e.:\n**\n** CREATE TABLE yyy(...);\n**\n** Then pName1 is set to \"yyy\" and pName2 is \"\".\n**\n** This routine sets the *ppUnqual pointer to point at the token (pName1 or\n** pName2) that stores the unqualified table name.  The index of the\n** database \"xxx\" is returned.\n*/\nint sqlite3TwoPartName(\n  Parse *pParse,      /* Parsing and code generating context */\n  Token *pName1,      /* The \"xxx\" in the name \"xxx.yyy\" or \"xxx\" */\n  Token *pName2,      /* The \"yyy\" in the name \"xxx.yyy\" */\n  Token **pUnqual     /* Write the unqualified object name here */\n){\n  int iDb;                    /* Database holding the object */\n  sqlite3 *db = pParse->db;\n\n  assert( pName2!=0 );\n  if( pName2->n>0 ){\n    if( db->init.busy ) {\n      sqlite3ErrorMsg(pParse, \"corrupt database\");\n      return -1;\n    }\n    *pUnqual = pName2;\n    iDb = sqlite3FindDb(db, pName1);\n    if( iDb<0 ){\n      sqlite3ErrorMsg(pParse, \"unknown database %T\", pName1);\n      return -1;\n    }\n  }else{\n    assert( db->init.iDb==0 || db->init.busy\n             || (db->mDbFlags & DBFLAG_Vacuum)!=0);\n    iDb = db->init.iDb;\n    *pUnqual = pName1;\n  }\n  return iDb;\n}\n\n/*\n** This routine is used to check if the UTF-8 string zName is a legal\n** unqualified name for a new schema object (table, index, view or\n** trigger). All names are legal except those that begin with the string\n** \"sqlite_\" (in upper, lower or mixed case). This portion of the namespace\n** is reserved for internal use.\n*/\nint sqlite3CheckObjectName(Parse *pParse, const char *zName){\n  if( !pParse->db->init.busy && pParse->nested==0 \n          && (pParse->db->flags & SQLITE_WriteSchema)==0\n          && 0==sqlite3StrNICmp(zName, \"sqlite_\", 7) ){\n    sqlite3ErrorMsg(pParse, \"object name reserved for internal use: %s\", zName);\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Return the PRIMARY KEY index of a table\n*/\nIndex *sqlite3PrimaryKeyIndex(Table *pTab){\n  Index *p;\n  for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}\n  return p;\n}\n\n/*\n** Return the column of index pIdx that corresponds to table\n** column iCol.  Return -1 if not found.\n*/\ni16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){\n  int i;\n  for(i=0; i<pIdx->nColumn; i++){\n    if( iCol==pIdx->aiColumn[i] ) return i;\n  }\n  return -1;\n}\n\n/*\n** Begin constructing a new table representation in memory.  This is\n** the first of several action routines that get called in response\n** to a CREATE TABLE statement.  In particular, this routine is called\n** after seeing tokens \"CREATE\" and \"TABLE\" and the table name. The isTemp\n** flag is true if the table should be stored in the auxiliary database\n** file instead of in the main database file.  This is normally the case\n** when the \"TEMP\" or \"TEMPORARY\" keyword occurs in between\n** CREATE and TABLE.\n**\n** The new table record is initialized and put in pParse->pNewTable.\n** As more of the CREATE TABLE statement is parsed, additional action\n** routines will be called to add more information to this record.\n** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine\n** is called to complete the construction of the new table record.\n*/\nvoid sqlite3StartTable(\n  Parse *pParse,   /* Parser context */\n  Token *pName1,   /* First part of the name of the table or view */\n  Token *pName2,   /* Second part of the name of the table or view */\n  int isTemp,      /* True if this is a TEMP table */\n  int isView,      /* True if this is a VIEW */\n  int isVirtual,   /* True if this is a VIRTUAL table */\n  int noErr        /* Do nothing if table already exists */\n){\n  Table *pTable;\n  char *zName = 0; /* The name of the new table */\n  sqlite3 *db = pParse->db;\n  Vdbe *v;\n  int iDb;         /* Database number to create the table in */\n  Token *pName;    /* Unqualified name of the table to create */\n\n  if( db->init.busy && db->init.newTnum==1 ){\n    /* Special case:  Parsing the sqlite_master or sqlite_temp_master schema */\n    iDb = db->init.iDb;\n    zName = sqlite3DbStrDup(db, SCHEMA_TABLE(iDb));\n    pName = pName1;\n  }else{\n    /* The common case */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) return;\n    if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){\n      /* If creating a temp table, the name may not be qualified. Unless \n      ** the database name is \"temp\" anyway.  */\n      sqlite3ErrorMsg(pParse, \"temporary table name must be unqualified\");\n      return;\n    }\n    if( !OMIT_TEMPDB && isTemp ) iDb = 1;\n    zName = sqlite3NameFromToken(db, pName);\n  }\n  pParse->sNameToken = *pName;\n  if( zName==0 ) return;\n  if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto begin_table_error;\n  }\n  if( db->init.iDb==1 ) isTemp = 1;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  assert( isTemp==0 || isTemp==1 );\n  assert( isView==0 || isView==1 );\n  {\n    static const u8 aCode[] = {\n       SQLITE_CREATE_TABLE,\n       SQLITE_CREATE_TEMP_TABLE,\n       SQLITE_CREATE_VIEW,\n       SQLITE_CREATE_TEMP_VIEW\n    };\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){\n      goto begin_table_error;\n    }\n    if( !isVirtual && sqlite3AuthCheck(pParse, (int)aCode[isTemp+2*isView],\n                                       zName, 0, zDb) ){\n      goto begin_table_error;\n    }\n  }\n#endif\n\n  /* Make sure the new table name does not collide with an existing\n  ** index or table name in the same database.  Issue an error message if\n  ** it does. The exception is if the statement being parsed was passed\n  ** to an sqlite3_declare_vtab() call. In that case only the column names\n  ** and types will be used, so there is no need to test for namespace\n  ** collisions.\n  */\n  if( !IN_DECLARE_VTAB ){\n    char *zDb = db->aDb[iDb].zDbSName;\n    if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n      goto begin_table_error;\n    }\n    pTable = sqlite3FindTable(db, zName, zDb);\n    if( pTable ){\n      if( !noErr ){\n        sqlite3ErrorMsg(pParse, \"table %T already exists\", pName);\n      }else{\n        assert( !db->init.busy || CORRUPT_DB );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto begin_table_error;\n    }\n    if( sqlite3FindIndex(db, zName, zDb)!=0 ){\n      sqlite3ErrorMsg(pParse, \"there is already an index named %s\", zName);\n      goto begin_table_error;\n    }\n  }\n\n  pTable = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTable==0 ){\n    assert( db->mallocFailed );\n    pParse->rc = SQLITE_NOMEM_BKPT;\n    pParse->nErr++;\n    goto begin_table_error;\n  }\n  pTable->zName = zName;\n  pTable->iPKey = -1;\n  pTable->pSchema = db->aDb[iDb].pSchema;\n  pTable->nTabRef = 1;\n#ifdef SQLITE_DEFAULT_ROWEST\n  pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);\n#else\n  pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n#endif\n  assert( pParse->pNewTable==0 );\n  pParse->pNewTable = pTable;\n\n  /* If this is the magic sqlite_sequence table used by autoincrement,\n  ** then record a pointer to this table in the main database structure\n  ** so that INSERT can find the table easily.\n  */\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  if( !pParse->nested && strcmp(zName, \"sqlite_sequence\")==0 ){\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTable->pSchema->pSeqTab = pTable;\n  }\n#endif\n\n  /* Begin generating the code that will insert the table record into\n  ** the SQLITE_MASTER table.  Note in particular that we must go ahead\n  ** and allocate the record number for the table entry now.  Before any\n  ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause\n  ** indices to be created and the table record must come before the \n  ** indices.  Hence, the record number for the table must be allocated\n  ** now.\n  */\n  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){\n    int addr1;\n    int fileFormat;\n    int reg1, reg2, reg3;\n    /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */\n    static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( isVirtual ){\n      sqlite3VdbeAddOp0(v, OP_VBegin);\n    }\n#endif\n\n    /* If the file format and encoding in the database have not been set, \n    ** set them now.\n    */\n    reg1 = pParse->regRowid = ++pParse->nMem;\n    reg2 = pParse->regRoot = ++pParse->nMem;\n    reg3 = ++pParse->nMem;\n    sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);\n    sqlite3VdbeUsesBtree(v, iDb);\n    addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);\n    fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?\n                  1 : SQLITE_MAX_FILE_FORMAT;\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat);\n    sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, ENC(db));\n    sqlite3VdbeJumpHere(v, addr1);\n\n    /* This just creates a place-holder record in the sqlite_master table.\n    ** The record created does not contain anything yet.  It will be replaced\n    ** by the real entry in code generated at sqlite3EndTable().\n    **\n    ** The rowid for the new entry is left in register pParse->regRowid.\n    ** The root page number of the new table is left in reg pParse->regRoot.\n    ** The rowid and root page number values are needed by the code that\n    ** sqlite3EndTable will generate.\n    */\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n    if( isView || isVirtual ){\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);\n    }else\n#endif\n    {\n      pParse->addrCrTab =\n         sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);\n    }\n    sqlite3OpenMasterTable(pParse, iDb);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);\n    sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);\n    sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);\n    sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n    sqlite3VdbeAddOp0(v, OP_Close);\n  }\n\n  /* Normal (non-error) return. */\n  return;\n\n  /* If an error occurs, we jump here */\nbegin_table_error:\n  sqlite3DbFree(db, zName);\n  return;\n}\n\n/* Set properties of a table column based on the (magical)\n** name of the column.\n*/\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\nvoid sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){\n  if( sqlite3_strnicmp(pCol->zName, \"__hidden__\", 10)==0 ){\n    pCol->colFlags |= COLFLAG_HIDDEN;\n  }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){\n    pTab->tabFlags |= TF_OOOHidden;\n  }\n}\n#endif\n\n\n/*\n** Add a new column to the table currently being constructed.\n**\n** The parser calls this routine once for each column declaration\n** in a CREATE TABLE statement.  sqlite3StartTable() gets called\n** first to get things going.  Then this routine is called for each\n** column.\n*/\nvoid sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){\n  Table *p;\n  int i;\n  char *z;\n  char *zType;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  if( (p = pParse->pNewTable)==0 ) return;\n  if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns on %s\", p->zName);\n    return;\n  }\n  z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);\n  if( z==0 ) return;\n  memcpy(z, pName->z, pName->n);\n  z[pName->n] = 0;\n  sqlite3Dequote(z);\n  for(i=0; i<p->nCol; i++){\n    if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){\n      sqlite3ErrorMsg(pParse, \"duplicate column name: %s\", z);\n      sqlite3DbFree(db, z);\n      return;\n    }\n  }\n  if( (p->nCol & 0x7)==0 ){\n    Column *aNew;\n    aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));\n    if( aNew==0 ){\n      sqlite3DbFree(db, z);\n      return;\n    }\n    p->aCol = aNew;\n  }\n  pCol = &p->aCol[p->nCol];\n  memset(pCol, 0, sizeof(p->aCol[0]));\n  pCol->zName = z;\n  sqlite3ColumnPropertiesFromName(p, pCol);\n \n  if( pType->n==0 ){\n    /* If there is no type specified, columns have the default affinity\n    ** 'BLOB'. */\n    pCol->affinity = SQLITE_AFF_BLOB;\n    pCol->szEst = 1;\n  }else{\n    zType = z + sqlite3Strlen30(z) + 1;\n    memcpy(zType, pType->z, pType->n);\n    zType[pType->n] = 0;\n    sqlite3Dequote(zType);\n    pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);\n    pCol->colFlags |= COLFLAG_HASTYPE;\n  }\n  p->nCol++;\n  pParse->constraintName.n = 0;\n}\n\n/*\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.  A \"NOT NULL\" constraint has\n** been seen on a column.  This routine sets the notNull flag on\n** the column currently under construction.\n*/\nvoid sqlite3AddNotNull(Parse *pParse, int onError){\n  Table *p;\n  p = pParse->pNewTable;\n  if( p==0 || NEVER(p->nCol<1) ) return;\n  p->aCol[p->nCol-1].notNull = (u8)onError;\n  p->tabFlags |= TF_HasNotNull;\n}\n\n/*\n** Scan the column type name zType (length nType) and return the\n** associated affinity type.\n**\n** This routine does a case-independent search of zType for the \n** substrings in the following table. If one of the substrings is\n** found, the corresponding affinity is returned. If zType contains\n** more than one of the substrings, entries toward the top of \n** the table take priority. For example, if zType is 'BLOBINT', \n** SQLITE_AFF_INTEGER is returned.\n**\n** Substring     | Affinity\n** --------------------------------\n** 'INT'         | SQLITE_AFF_INTEGER\n** 'CHAR'        | SQLITE_AFF_TEXT\n** 'CLOB'        | SQLITE_AFF_TEXT\n** 'TEXT'        | SQLITE_AFF_TEXT\n** 'BLOB'        | SQLITE_AFF_BLOB\n** 'REAL'        | SQLITE_AFF_REAL\n** 'FLOA'        | SQLITE_AFF_REAL\n** 'DOUB'        | SQLITE_AFF_REAL\n**\n** If none of the substrings in the above table are found,\n** SQLITE_AFF_NUMERIC is returned.\n*/\nchar sqlite3AffinityType(const char *zIn, u8 *pszEst){\n  u32 h = 0;\n  char aff = SQLITE_AFF_NUMERIC;\n  const char *zChar = 0;\n\n  assert( zIn!=0 );\n  while( zIn[0] ){\n    h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];\n    zIn++;\n    if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){             /* CHAR */\n      aff = SQLITE_AFF_TEXT;\n      zChar = zIn;\n    }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){       /* CLOB */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){       /* TEXT */\n      aff = SQLITE_AFF_TEXT;\n    }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b')          /* BLOB */\n        && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){\n      aff = SQLITE_AFF_BLOB;\n      if( zIn[0]=='(' ) zChar = zIn;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l')          /* REAL */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a')          /* FLOA */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n    }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b')          /* DOUB */\n        && aff==SQLITE_AFF_NUMERIC ){\n      aff = SQLITE_AFF_REAL;\n#endif\n    }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */\n      aff = SQLITE_AFF_INTEGER;\n      break;\n    }\n  }\n\n  /* If pszEst is not NULL, store an estimate of the field size.  The\n  ** estimate is scaled so that the size of an integer is 1.  */\n  if( pszEst ){\n    *pszEst = 1;   /* default size is approx 4 bytes */\n    if( aff<SQLITE_AFF_NUMERIC ){\n      if( zChar ){\n        while( zChar[0] ){\n          if( sqlite3Isdigit(zChar[0]) ){\n            int v = 0;\n            sqlite3GetInt32(zChar, &v);\n            v = v/4 + 1;\n            if( v>255 ) v = 255;\n            *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */\n            break;\n          }\n          zChar++;\n        }\n      }else{\n        *pszEst = 5;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/\n      }\n    }\n  }\n  return aff;\n}\n\n/*\n** The expression is the default value for the most recently added column\n** of the table currently under construction.\n**\n** Default value expressions must be constant.  Raise an exception if this\n** is not the case.\n**\n** This routine is called by the parser while in the middle of\n** parsing a CREATE TABLE statement.\n*/\nvoid sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){\n  Table *p;\n  Column *pCol;\n  sqlite3 *db = pParse->db;\n  p = pParse->pNewTable;\n  if( p!=0 ){\n    pCol = &(p->aCol[p->nCol-1]);\n    if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr, db->init.busy) ){\n      sqlite3ErrorMsg(pParse, \"default value of column [%s] is not constant\",\n          pCol->zName);\n    }else{\n      /* A copy of pExpr is used instead of the original, as pExpr contains\n      ** tokens that point to volatile memory. The 'span' of the expression\n      ** is required by pragma table_info.\n      */\n      Expr x;\n      sqlite3ExprDelete(db, pCol->pDflt);\n      memset(&x, 0, sizeof(x));\n      x.op = TK_SPAN;\n      x.u.zToken = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                    (int)(pSpan->zEnd - pSpan->zStart));\n      x.pLeft = pSpan->pExpr;\n      x.flags = EP_Skip;\n      pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);\n      sqlite3DbFree(db, x.u.zToken);\n    }\n  }\n  sqlite3ExprDelete(db, pSpan->pExpr);\n}\n\n/*\n** Backwards Compatibility Hack:\n** \n** Historical versions of SQLite accepted strings as column names in\n** indexes and PRIMARY KEY constraints and in UNIQUE constraints.  Example:\n**\n**     CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)\n**     CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);\n**\n** This is goofy.  But to preserve backwards compatibility we continue to\n** accept it.  This routine does the necessary conversion.  It converts\n** the expression given in its argument from a TK_STRING into a TK_ID\n** if the expression is just a TK_STRING with an optional COLLATE clause.\n** If the epxression is anything other than TK_STRING, the expression is\n** unchanged.\n*/\nstatic void sqlite3StringToId(Expr *p){\n  if( p->op==TK_STRING ){\n    p->op = TK_ID;\n  }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){\n    p->pLeft->op = TK_ID;\n  }\n}\n\n/*\n** Designate the PRIMARY KEY for the table.  pList is a list of names \n** of columns that form the primary key.  If pList is NULL, then the\n** most recently added column of the table is the primary key.\n**\n** A table can have at most one primary key.  If the table already has\n** a primary key (and this is the second primary key) then create an\n** error.\n**\n** If the PRIMARY KEY is on a single column whose datatype is INTEGER,\n** then we will try to use that column as the rowid.  Set the Table.iPKey\n** field of the table under construction to be the index of the\n** INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is\n** no INTEGER PRIMARY KEY.\n**\n** If the key is not an INTEGER PRIMARY KEY, then create a unique\n** index for the key.  No index is created for INTEGER PRIMARY KEYs.\n*/\nvoid sqlite3AddPrimaryKey(\n  Parse *pParse,    /* Parsing context */\n  ExprList *pList,  /* List of field names to be indexed */\n  int onError,      /* What to do with a uniqueness conflict */\n  int autoInc,      /* True if the AUTOINCREMENT keyword is present */\n  int sortOrder     /* SQLITE_SO_ASC or SQLITE_SO_DESC */\n){\n  Table *pTab = pParse->pNewTable;\n  Column *pCol = 0;\n  int iCol = -1, i;\n  int nTerm;\n  if( pTab==0 ) goto primary_key_exit;\n  if( pTab->tabFlags & TF_HasPrimaryKey ){\n    sqlite3ErrorMsg(pParse, \n      \"table \\\"%s\\\" has more than one primary key\", pTab->zName);\n    goto primary_key_exit;\n  }\n  pTab->tabFlags |= TF_HasPrimaryKey;\n  if( pList==0 ){\n    iCol = pTab->nCol - 1;\n    pCol = &pTab->aCol[iCol];\n    pCol->colFlags |= COLFLAG_PRIMKEY;\n    nTerm = 1;\n  }else{\n    nTerm = pList->nExpr;\n    for(i=0; i<nTerm; i++){\n      Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n      assert( pCExpr!=0 );\n      sqlite3StringToId(pCExpr);\n      if( pCExpr->op==TK_ID ){\n        const char *zCName = pCExpr->u.zToken;\n        for(iCol=0; iCol<pTab->nCol; iCol++){\n          if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){\n            pCol = &pTab->aCol[iCol];\n            pCol->colFlags |= COLFLAG_PRIMKEY;\n            break;\n          }\n        }\n      }\n    }\n  }\n  if( nTerm==1\n   && pCol\n   && sqlite3StrICmp(sqlite3ColumnType(pCol,\"\"), \"INTEGER\")==0\n   && sortOrder!=SQLITE_SO_DESC\n  ){\n    pTab->iPKey = iCol;\n    pTab->keyConf = (u8)onError;\n    assert( autoInc==0 || autoInc==1 );\n    pTab->tabFlags |= autoInc*TF_Autoincrement;\n    if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;\n  }else if( autoInc ){\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    sqlite3ErrorMsg(pParse, \"AUTOINCREMENT is only allowed on an \"\n       \"INTEGER PRIMARY KEY\");\n#endif\n  }else{\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,\n                           0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);\n    pList = 0;\n  }\n\nprimary_key_exit:\n  sqlite3ExprListDelete(pParse->db, pList);\n  return;\n}\n\n/*\n** Add a new CHECK constraint to the table currently under construction.\n*/\nvoid sqlite3AddCheckConstraint(\n  Parse *pParse,    /* Parsing context */\n  Expr *pCheckExpr  /* The check expression */\n){\n#ifndef SQLITE_OMIT_CHECK\n  Table *pTab = pParse->pNewTable;\n  sqlite3 *db = pParse->db;\n  if( pTab && !IN_DECLARE_VTAB\n   && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)\n  ){\n    pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);\n    if( pParse->constraintName.n ){\n      sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);\n    }\n  }else\n#endif\n  {\n    sqlite3ExprDelete(pParse->db, pCheckExpr);\n  }\n}\n\n/*\n** Set the collation function of the most recently parsed table column\n** to the CollSeq given.\n*/\nvoid sqlite3AddCollateType(Parse *pParse, Token *pToken){\n  Table *p;\n  int i;\n  char *zColl;              /* Dequoted name of collation sequence */\n  sqlite3 *db;\n\n  if( (p = pParse->pNewTable)==0 ) return;\n  i = p->nCol-1;\n  db = pParse->db;\n  zColl = sqlite3NameFromToken(db, pToken);\n  if( !zColl ) return;\n\n  if( sqlite3LocateCollSeq(pParse, zColl) ){\n    Index *pIdx;\n    sqlite3DbFree(db, p->aCol[i].zColl);\n    p->aCol[i].zColl = zColl;\n  \n    /* If the column is declared as \"<name> PRIMARY KEY COLLATE <type>\",\n    ** then an index may have been created on this column before the\n    ** collation type was added. Correct this if it is the case.\n    */\n    for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->nKeyCol==1 );\n      if( pIdx->aiColumn[0]==i ){\n        pIdx->azColl[0] = p->aCol[i].zColl;\n      }\n    }\n  }else{\n    sqlite3DbFree(db, zColl);\n  }\n}\n\n/*\n** This function returns the collation sequence for database native text\n** encoding identified by the string zName, length nName.\n**\n** If the requested collation sequence is not available, or not available\n** in the database native encoding, the collation factory is invoked to\n** request it. If the collation factory does not supply such a sequence,\n** and the sequence is available in another text encoding, then that is\n** returned instead.\n**\n** If no versions of the requested collations sequence are available, or\n** another error occurs, NULL is returned and an error message written into\n** pParse.\n**\n** This routine is a wrapper around sqlite3FindCollSeq().  This routine\n** invokes the collation factory if the named collation cannot be found\n** and generates an error message.\n**\n** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()\n*/\nCollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){\n  sqlite3 *db = pParse->db;\n  u8 enc = ENC(db);\n  u8 initbusy = db->init.busy;\n  CollSeq *pColl;\n\n  pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);\n  if( !initbusy && (!pColl || !pColl->xCmp) ){\n    pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);\n  }\n\n  return pColl;\n}\n\n\n/*\n** Generate code that will increment the schema cookie.\n**\n** The schema cookie is used to determine when the schema for the\n** database changes.  After each schema change, the cookie value\n** changes.  When a process first reads the schema it records the\n** cookie.  Thereafter, whenever it goes to access the database,\n** it checks the cookie to make sure the schema has not changed\n** since it was last read.\n**\n** This plan is not completely bullet-proof.  It is possible for\n** the schema to change multiple times and for the cookie to be\n** set back to prior value.  But schema changes are infrequent\n** and the probability of hitting the same cookie value is only\n** 1 chance in 2^32.  So we're safe enough.\n**\n** IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments\n** the schema-version whenever the schema changes.\n*/\nvoid sqlite3ChangeCookie(Parse *pParse, int iDb){\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, \n                    db->aDb[iDb].pSchema->schema_cookie+1);\n}\n\n/*\n** Measure the number of characters needed to output the given\n** identifier.  The number returned includes any quotes used\n** but does not include the null terminator.\n**\n** The estimate is conservative.  It might be larger that what is\n** really needed.\n*/\nstatic int identLength(const char *z){\n  int n;\n  for(n=0; *z; n++, z++){\n    if( *z=='\"' ){ n++; }\n  }\n  return n + 2;\n}\n\n/*\n** The first parameter is a pointer to an output buffer. The second \n** parameter is a pointer to an integer that contains the offset at\n** which to write into the output buffer. This function copies the\n** nul-terminated string pointed to by the third parameter, zSignedIdent,\n** to the specified offset in the buffer and updates *pIdx to refer\n** to the first byte after the last byte written before returning.\n** \n** If the string zSignedIdent consists entirely of alpha-numeric\n** characters, does not begin with a digit and is not an SQL keyword,\n** then it is copied to the output buffer exactly as it is. Otherwise,\n** it is quoted using double-quotes.\n*/\nstatic void identPut(char *z, int *pIdx, char *zSignedIdent){\n  unsigned char *zIdent = (unsigned char*)zSignedIdent;\n  int i, j, needQuote;\n  i = *pIdx;\n\n  for(j=0; zIdent[j]; j++){\n    if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;\n  }\n  needQuote = sqlite3Isdigit(zIdent[0])\n            || sqlite3KeywordCode(zIdent, j)!=TK_ID\n            || zIdent[j]!=0\n            || j==0;\n\n  if( needQuote ) z[i++] = '\"';\n  for(j=0; zIdent[j]; j++){\n    z[i++] = zIdent[j];\n    if( zIdent[j]=='\"' ) z[i++] = '\"';\n  }\n  if( needQuote ) z[i++] = '\"';\n  z[i] = 0;\n  *pIdx = i;\n}\n\n/*\n** Generate a CREATE TABLE statement appropriate for the given\n** table.  Memory to hold the text of the statement is obtained\n** from sqliteMalloc() and must be freed by the calling function.\n*/\nstatic char *createTableStmt(sqlite3 *db, Table *p){\n  int i, k, n;\n  char *zStmt;\n  char *zSep, *zSep2, *zEnd;\n  Column *pCol;\n  n = 0;\n  for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){\n    n += identLength(pCol->zName) + 5;\n  }\n  n += identLength(p->zName);\n  if( n<50 ){ \n    zSep = \"\";\n    zSep2 = \",\";\n    zEnd = \")\";\n  }else{\n    zSep = \"\\n  \";\n    zSep2 = \",\\n  \";\n    zEnd = \"\\n)\";\n  }\n  n += 35 + 6*p->nCol;\n  zStmt = sqlite3DbMallocRaw(0, n);\n  if( zStmt==0 ){\n    sqlite3OomFault(db);\n    return 0;\n  }\n  sqlite3_snprintf(n, zStmt, \"CREATE TABLE \");\n  k = sqlite3Strlen30(zStmt);\n  identPut(zStmt, &k, p->zName);\n  zStmt[k++] = '(';\n  for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){\n    static const char * const azType[] = {\n        /* SQLITE_AFF_BLOB    */ \"\",\n        /* SQLITE_AFF_TEXT    */ \" TEXT\",\n        /* SQLITE_AFF_NUMERIC */ \" NUM\",\n        /* SQLITE_AFF_INTEGER */ \" INT\",\n        /* SQLITE_AFF_REAL    */ \" REAL\"\n    };\n    int len;\n    const char *zType;\n\n    sqlite3_snprintf(n-k, &zStmt[k], zSep);\n    k += sqlite3Strlen30(&zStmt[k]);\n    zSep = zSep2;\n    identPut(zStmt, &k, pCol->zName);\n    assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );\n    assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );\n    testcase( pCol->affinity==SQLITE_AFF_BLOB );\n    testcase( pCol->affinity==SQLITE_AFF_TEXT );\n    testcase( pCol->affinity==SQLITE_AFF_NUMERIC );\n    testcase( pCol->affinity==SQLITE_AFF_INTEGER );\n    testcase( pCol->affinity==SQLITE_AFF_REAL );\n    \n    zType = azType[pCol->affinity - SQLITE_AFF_BLOB];\n    len = sqlite3Strlen30(zType);\n    assert( pCol->affinity==SQLITE_AFF_BLOB \n            || pCol->affinity==sqlite3AffinityType(zType, 0) );\n    memcpy(&zStmt[k], zType, len);\n    k += len;\n    assert( k<=n );\n  }\n  sqlite3_snprintf(n-k, &zStmt[k], \"%s\", zEnd);\n  return zStmt;\n}\n\n/*\n** Resize an Index object to hold N columns total.  Return SQLITE_OK\n** on success and SQLITE_NOMEM on an OOM error.\n*/\nstatic int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){\n  char *zExtra;\n  int nByte;\n  if( pIdx->nColumn>=N ) return SQLITE_OK;\n  assert( pIdx->isResized==0 );\n  nByte = (sizeof(char*) + sizeof(i16) + 1)*N;\n  zExtra = sqlite3DbMallocZero(db, nByte);\n  if( zExtra==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);\n  pIdx->azColl = (const char**)zExtra;\n  zExtra += sizeof(char*)*N;\n  memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);\n  pIdx->aiColumn = (i16*)zExtra;\n  zExtra += sizeof(i16)*N;\n  memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);\n  pIdx->aSortOrder = (u8*)zExtra;\n  pIdx->nColumn = N;\n  pIdx->isResized = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Estimate the total row width for a table.\n*/\nstatic void estimateTableWidth(Table *pTab){\n  unsigned wTable = 0;\n  const Column *pTabCol;\n  int i;\n  for(i=pTab->nCol, pTabCol=pTab->aCol; i>0; i--, pTabCol++){\n    wTable += pTabCol->szEst;\n  }\n  if( pTab->iPKey<0 ) wTable++;\n  pTab->szTabRow = sqlite3LogEst(wTable*4);\n}\n\n/*\n** Estimate the average size of a row for an index.\n*/\nstatic void estimateIndexWidth(Index *pIdx){\n  unsigned wIndex = 0;\n  int i;\n  const Column *aCol = pIdx->pTable->aCol;\n  for(i=0; i<pIdx->nColumn; i++){\n    i16 x = pIdx->aiColumn[i];\n    assert( x<pIdx->pTable->nCol );\n    wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;\n  }\n  pIdx->szIdxRow = sqlite3LogEst(wIndex*4);\n}\n\n/* Return true if value x is found any of the first nCol entries of aiCol[]\n*/\nstatic int hasColumn(const i16 *aiCol, int nCol, int x){\n  while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;\n  return 0;\n}\n\n/*\n** This routine runs at the end of parsing a CREATE TABLE statement that\n** has a WITHOUT ROWID clause.  The job of this routine is to convert both\n** internal schema data structures and the generated VDBE code so that they\n** are appropriate for a WITHOUT ROWID table instead of a rowid table.\n** Changes include:\n**\n**     (1)  Set all columns of the PRIMARY KEY schema object to be NOT NULL.\n**     (2)  Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY \n**          into BTREE_BLOBKEY.\n**     (3)  Bypass the creation of the sqlite_master table entry\n**          for the PRIMARY KEY as the primary key index is now\n**          identified by the sqlite_master table entry of the table itself.\n**     (4)  Set the Index.tnum of the PRIMARY KEY Index object in the\n**          schema to the rootpage from the main table.\n**     (5)  Add all table columns to the PRIMARY KEY Index object\n**          so that the PRIMARY KEY is a covering index.  The surplus\n**          columns are part of KeyInfo.nAllField and are not used for\n**          sorting or lookup or uniqueness checks.\n**     (6)  Replace the rowid tail on all automatically generated UNIQUE\n**          indices with the PRIMARY KEY columns.\n**\n** For virtual tables, only (1) is performed.\n*/\nstatic void convertToWithoutRowidTable(Parse *pParse, Table *pTab){\n  Index *pIdx;\n  Index *pPk;\n  int nPk;\n  int i, j;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n\n  /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)\n  */\n  if( !db->init.imposterTable ){\n    for(i=0; i<pTab->nCol; i++){\n      if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){\n        pTab->aCol[i].notNull = OE_Abort;\n      }\n    }\n  }\n\n  /* The remaining transformations only apply to b-tree tables, not to\n  ** virtual tables */\n  if( IN_DECLARE_VTAB ) return;\n\n  /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY\n  ** into BTREE_BLOBKEY.\n  */\n  if( pParse->addrCrTab ){\n    assert( v );\n    sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY);\n  }\n\n  /* Locate the PRIMARY KEY index.  Or, if this table was originally\n  ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. \n  */\n  if( pTab->iPKey>=0 ){\n    ExprList *pList;\n    Token ipkToken;\n    sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);\n    pList = sqlite3ExprListAppend(pParse, 0, \n                  sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));\n    if( pList==0 ) return;\n    pList->a[0].sortOrder = pParse->iPkSortOrder;\n    assert( pParse->pNewTable==pTab );\n    sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,\n                       SQLITE_IDXTYPE_PRIMARYKEY);\n    if( db->mallocFailed ) return;\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    pTab->iPKey = -1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n\n    /*\n    ** Remove all redundant columns from the PRIMARY KEY.  For example, change\n    ** \"PRIMARY KEY(a,b,a,b,c,b,c,d)\" into just \"PRIMARY KEY(a,b,c,d)\".  Later\n    ** code assumes the PRIMARY KEY contains no repeated columns.\n    */\n    for(i=j=1; i<pPk->nKeyCol; i++){\n      if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){\n        pPk->nColumn--;\n      }else{\n        pPk->aiColumn[j++] = pPk->aiColumn[i];\n      }\n    }\n    pPk->nKeyCol = j;\n  }\n  assert( pPk!=0 );\n  pPk->isCovering = 1;\n  if( !db->init.imposterTable ) pPk->uniqNotNull = 1;\n  nPk = pPk->nKeyCol;\n\n  /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master\n  ** table entry. This is only required if currently generating VDBE\n  ** code for a CREATE TABLE (not when parsing one as part of reading\n  ** a database schema).  */\n  if( v && pPk->tnum>0 ){\n    assert( db->init.busy==0 );\n    sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);\n  }\n\n  /* The root page of the PRIMARY KEY is the table root page */\n  pPk->tnum = pTab->tnum;\n\n  /* Update the in-memory representation of all UNIQUE indices by converting\n  ** the final rowid column into one or more columns of the PRIMARY KEY.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    int n;\n    if( IsPrimaryKeyIndex(pIdx) ) continue;\n    for(i=n=0; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;\n    }\n    if( n==0 ){\n      /* This index is a superset of the primary key */\n      pIdx->nColumn = pIdx->nKeyCol;\n      continue;\n    }\n    if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;\n    for(i=0, j=pIdx->nKeyCol; i<nPk; i++){\n      if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){\n        pIdx->aiColumn[j] = pPk->aiColumn[i];\n        pIdx->azColl[j] = pPk->azColl[i];\n        j++;\n      }\n    }\n    assert( pIdx->nColumn>=pIdx->nKeyCol+n );\n    assert( pIdx->nColumn>=j );\n  }\n\n  /* Add all table columns to the PRIMARY KEY index\n  */\n  if( nPk<pTab->nCol ){\n    if( resizeIndexObject(db, pPk, pTab->nCol) ) return;\n    for(i=0, j=nPk; i<pTab->nCol; i++){\n      if( !hasColumn(pPk->aiColumn, j, i) ){\n        assert( j<pPk->nColumn );\n        pPk->aiColumn[j] = i;\n        pPk->azColl[j] = sqlite3StrBINARY;\n        j++;\n      }\n    }\n    assert( pPk->nColumn==j );\n    assert( pTab->nCol==j );\n  }else{\n    pPk->nColumn = pTab->nCol;\n  }\n}\n\n/*\n** This routine is called to report the final \")\" that terminates\n** a CREATE TABLE statement.\n**\n** The table structure that other action routines have been building\n** is added to the internal hash tables, assuming no errors have\n** occurred.\n**\n** An entry for the table is made in the master table on disk, unless\n** this is a temporary table or db->init.busy==1.  When db->init.busy==1\n** it means we are reading the sqlite_master table because we just\n** connected to the database or because the sqlite_master table has\n** recently changed, so the entry for this table already exists in\n** the sqlite_master table.  We do not want to create it again.\n**\n** If the pSelect argument is not NULL, it means that this routine\n** was called to create a table generated from a \n** \"CREATE TABLE ... AS SELECT ...\" statement.  The column names of\n** the new table will match the result set of the SELECT.\n*/\nvoid sqlite3EndTable(\n  Parse *pParse,          /* Parse context */\n  Token *pCons,           /* The ',' token after the last column defn. */\n  Token *pEnd,            /* The ')' before options in the CREATE TABLE */\n  u8 tabOpts,             /* Extra table options. Usually 0. */\n  Select *pSelect         /* Select from a \"CREATE ... AS SELECT\" */\n){\n  Table *p;                 /* The new table */\n  sqlite3 *db = pParse->db; /* The database connection */\n  int iDb;                  /* Database in which the table lives */\n  Index *pIdx;              /* An implied index of the table */\n\n  if( pEnd==0 && pSelect==0 ){\n    return;\n  }\n  assert( !db->mallocFailed );\n  p = pParse->pNewTable;\n  if( p==0 ) return;\n\n  assert( !db->init.busy || !pSelect );\n\n  /* If the db->init.busy is 1 it means we are reading the SQL off the\n  ** \"sqlite_master\" or \"sqlite_temp_master\" table on the disk.\n  ** So do not write to the disk again.  Extract the root page number\n  ** for the table from the db->init.newTnum field.  (The page number\n  ** should have been put there by the sqliteOpenCb routine.)\n  **\n  ** If the root page number is 1, that means this is the sqlite_master\n  ** table itself.  So mark it read-only.\n  */\n  if( db->init.busy ){\n    p->tnum = db->init.newTnum;\n    if( p->tnum==1 ) p->tabFlags |= TF_Readonly;\n  }\n\n  /* Special processing for WITHOUT ROWID Tables */\n  if( tabOpts & TF_WithoutRowid ){\n    if( (p->tabFlags & TF_Autoincrement) ){\n      sqlite3ErrorMsg(pParse,\n          \"AUTOINCREMENT not allowed on WITHOUT ROWID tables\");\n      return;\n    }\n    if( (p->tabFlags & TF_HasPrimaryKey)==0 ){\n      sqlite3ErrorMsg(pParse, \"PRIMARY KEY missing on table %s\", p->zName);\n    }else{\n      p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;\n      convertToWithoutRowidTable(pParse, p);\n    }\n  }\n\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n\n#ifndef SQLITE_OMIT_CHECK\n  /* Resolve names in all CHECK constraint expressions.\n  */\n  if( p->pCheck ){\n    sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* Estimate the average row size for the table and for all implied indices */\n  estimateTableWidth(p);\n  for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){\n    estimateIndexWidth(pIdx);\n  }\n\n  /* If not initializing, then create a record for the new table\n  ** in the SQLITE_MASTER table of the database.\n  **\n  ** If this is a TEMPORARY table, write the entry into the auxiliary\n  ** file instead of into the main database file.\n  */\n  if( !db->init.busy ){\n    int n;\n    Vdbe *v;\n    char *zType;    /* \"view\" or \"table\" */\n    char *zType2;   /* \"VIEW\" or \"TABLE\" */\n    char *zStmt;    /* Text of the CREATE TABLE or CREATE VIEW statement */\n\n    v = sqlite3GetVdbe(pParse);\n    if( NEVER(v==0) ) return;\n\n    sqlite3VdbeAddOp1(v, OP_Close, 0);\n\n    /* \n    ** Initialize zType for the new view or table.\n    */\n    if( p->pSelect==0 ){\n      /* A regular table */\n      zType = \"table\";\n      zType2 = \"TABLE\";\n#ifndef SQLITE_OMIT_VIEW\n    }else{\n      /* A view */\n      zType = \"view\";\n      zType2 = \"VIEW\";\n#endif\n    }\n\n    /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT\n    ** statement to populate the new table. The root-page number for the\n    ** new table is in register pParse->regRoot.\n    **\n    ** Once the SELECT has been coded by sqlite3Select(), it is in a\n    ** suitable state to query for the column names and types to be used\n    ** by the new table.\n    **\n    ** A shared-cache write-lock is not required to write to the new table,\n    ** as a schema-lock must have already been obtained to create it. Since\n    ** a schema-lock excludes all other database users, the write-lock would\n    ** be redundant.\n    */\n    if( pSelect ){\n      SelectDest dest;    /* Where the SELECT should store results */\n      int regYield;       /* Register holding co-routine entry-point */\n      int addrTop;        /* Top of the co-routine */\n      int regRec;         /* A record to be insert into the new table */\n      int regRowid;       /* Rowid of the next row to insert */\n      int addrInsLoop;    /* Top of the loop for inserting rows */\n      Table *pSelTab;     /* A table that describes the SELECT results */\n\n      regYield = ++pParse->nMem;\n      regRec = ++pParse->nMem;\n      regRowid = ++pParse->nMem;\n      assert(pParse->nTab==1);\n      sqlite3MayAbort(pParse);\n      sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);\n      sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);\n      pParse->nTab = 2;\n      addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n      sqlite3Select(pParse, pSelect, &dest);\n      sqlite3VdbeEndCoroutine(v, regYield);\n      sqlite3VdbeJumpHere(v, addrTop - 1);\n      if( pParse->nErr ) return;\n      pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);\n      if( pSelTab==0 ) return;\n      assert( p->aCol==0 );\n      p->nCol = pSelTab->nCol;\n      p->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      sqlite3DeleteTable(db, pSelTab);\n      addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n      VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);\n      sqlite3TableAffinity(v, p, 0);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);\n      sqlite3VdbeGoto(v, addrInsLoop);\n      sqlite3VdbeJumpHere(v, addrInsLoop);\n      sqlite3VdbeAddOp1(v, OP_Close, 1);\n    }\n\n    /* Compute the complete text of the CREATE statement */\n    if( pSelect ){\n      zStmt = createTableStmt(db, p);\n    }else{\n      Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;\n      n = (int)(pEnd2->z - pParse->sNameToken.z);\n      if( pEnd2->z[0]!=';' ) n += pEnd2->n;\n      zStmt = sqlite3MPrintf(db, \n          \"CREATE %s %.*s\", zType2, n, pParse->sNameToken.z\n      );\n    }\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.\n    */\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      zType,\n      p->zName,\n      p->zName,\n      pParse->regRoot,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    sqlite3ChangeCookie(pParse, iDb);\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    /* Check to see if we need to create an sqlite_sequence table for\n    ** keeping track of autoincrement keys.\n    */\n    if( (p->tabFlags & TF_Autoincrement)!=0 ){\n      Db *pDb = &db->aDb[iDb];\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      if( pDb->pSchema->pSeqTab==0 ){\n        sqlite3NestedParse(pParse,\n          \"CREATE TABLE %Q.sqlite_sequence(name,seq)\",\n          pDb->zDbSName\n        );\n      }\n    }\n#endif\n\n    /* Reparse everything to update our internal data structures */\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n           sqlite3MPrintf(db, \"tbl_name='%q' AND type!='trigger'\", p->zName));\n  }\n\n\n  /* Add the table to the in-memory representation of the database.\n  */\n  if( db->init.busy ){\n    Table *pOld;\n    Schema *pSchema = p->pSchema;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);\n    if( pOld ){\n      assert( p==pOld );  /* Malloc must have failed inside HashInsert() */\n      sqlite3OomFault(db);\n      return;\n    }\n    pParse->pNewTable = 0;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n\n#ifndef SQLITE_OMIT_ALTERTABLE\n    if( !p->pSelect ){\n      const char *zName = (const char *)pParse->sNameToken.z;\n      int nName;\n      assert( !pSelect && pCons && pEnd );\n      if( pCons->z==0 ){\n        pCons = pEnd;\n      }\n      nName = (int)((const char *)pCons->z - zName);\n      p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);\n    }\n#endif\n  }\n}\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** The parser calls this routine in order to create a new VIEW\n*/\nvoid sqlite3CreateView(\n  Parse *pParse,     /* The parsing context */\n  Token *pBegin,     /* The CREATE token that begins the statement */\n  Token *pName1,     /* The token that holds the name of the view */\n  Token *pName2,     /* The token that holds the name of the view */\n  ExprList *pCNames, /* Optional list of view column names */\n  Select *pSelect,   /* A SELECT statement that will become the new view */\n  int isTemp,        /* TRUE for a TEMPORARY view */\n  int noErr          /* Suppress error messages if VIEW already exists */\n){\n  Table *p;\n  int n;\n  const char *z;\n  Token sEnd;\n  DbFixer sFix;\n  Token *pName = 0;\n  int iDb;\n  sqlite3 *db = pParse->db;\n\n  if( pParse->nVar>0 ){\n    sqlite3ErrorMsg(pParse, \"parameters are not allowed in views\");\n    goto create_view_fail;\n  }\n  sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);\n  p = pParse->pNewTable;\n  if( p==0 || pParse->nErr ) goto create_view_fail;\n  sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n  iDb = sqlite3SchemaToIndex(db, p->pSchema);\n  sqlite3FixInit(&sFix, pParse, iDb, \"view\", pName);\n  if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;\n\n  /* Make a copy of the entire SELECT statement that defines the view.\n  ** This will force all the Expr.token.z values to be dynamically\n  ** allocated rather than point to the input string - which means that\n  ** they will persist after the current sqlite3_exec() call returns.\n  */\n  p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n  p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);\n  if( db->mallocFailed ) goto create_view_fail;\n\n  /* Locate the end of the CREATE VIEW statement.  Make sEnd point to\n  ** the end.\n  */\n  sEnd = pParse->sLastToken;\n  assert( sEnd.z[0]!=0 );\n  if( sEnd.z[0]!=';' ){\n    sEnd.z += sEnd.n;\n  }\n  sEnd.n = 0;\n  n = (int)(sEnd.z - pBegin->z);\n  assert( n>0 );\n  z = pBegin->z;\n  while( sqlite3Isspace(z[n-1]) ){ n--; }\n  sEnd.z = &z[n-1];\n  sEnd.n = 1;\n\n  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */\n  sqlite3EndTable(pParse, 0, &sEnd, 0, 0);\n\ncreate_view_fail:\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3ExprListDelete(db, pCNames);\n  return;\n}\n#endif /* SQLITE_OMIT_VIEW */\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n/*\n** The Table structure pTable is really a VIEW.  Fill in the names of\n** the columns of the view in the pTable structure.  Return the number\n** of errors.  If an error is seen leave an error message in pParse->zErrMsg.\n*/\nint sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){\n  Table *pSelTab;   /* A fake table from which we get the result set */\n  Select *pSel;     /* Copy of the SELECT that implements the view */\n  int nErr = 0;     /* Number of errors encountered */\n  int n;            /* Temporarily holds the number of cursors assigned */\n  sqlite3 *db = pParse->db;  /* Database connection for malloc errors */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\t\n  int rc;\n#endif\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;       /* Saved xAuth pointer */\n#endif\n\n  assert( pTable );\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  db->nSchemaLock++;\n  rc = sqlite3VtabCallConnect(pParse, pTable);\n  db->nSchemaLock--;\n  if( rc ){\n    return 1;\n  }\n  if( IsVirtual(pTable) ) return 0;\n#endif\n\n#ifndef SQLITE_OMIT_VIEW\n  /* A positive nCol means the columns names for this view are\n  ** already known.\n  */\n  if( pTable->nCol>0 ) return 0;\n\n  /* A negative nCol is a special marker meaning that we are currently\n  ** trying to compute the column names.  If we enter this routine with\n  ** a negative nCol, it means two or more views form a loop, like this:\n  **\n  **     CREATE VIEW one AS SELECT * FROM two;\n  **     CREATE VIEW two AS SELECT * FROM one;\n  **\n  ** Actually, the error above is now caught prior to reaching this point.\n  ** But the following test is still important as it does come up\n  ** in the following:\n  ** \n  **     CREATE TABLE main.ex1(a);\n  **     CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;\n  **     SELECT * FROM temp.ex1;\n  */\n  if( pTable->nCol<0 ){\n    sqlite3ErrorMsg(pParse, \"view %s is circularly defined\", pTable->zName);\n    return 1;\n  }\n  assert( pTable->nCol>=0 );\n\n  /* If we get this far, it means we need to compute the table names.\n  ** Note that the call to sqlite3ResultSetOfSelect() will expand any\n  ** \"*\" elements in the results set of the view and will assign cursors\n  ** to the elements of the FROM clause.  But we do not want these changes\n  ** to be permanent.  So the computation is done on a copy of the SELECT\n  ** statement that defines the view.\n  */\n  assert( pTable->pSelect );\n  pSel = sqlite3SelectDup(db, pTable->pSelect, 0);\n  if( pSel ){\n    n = pParse->nTab;\n    sqlite3SrcListAssignCursors(pParse, pSel->pSrc);\n    pTable->nCol = -1;\n    db->lookaside.bDisable++;\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    xAuth = db->xAuth;\n    db->xAuth = 0;\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n    db->xAuth = xAuth;\n#else\n    pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);\n#endif\n    pParse->nTab = n;\n    if( pTable->pCheck ){\n      /* CREATE VIEW name(arglist) AS ...\n      ** The names of the columns in the table are taken from\n      ** arglist which is stored in pTable->pCheck.  The pCheck field\n      ** normally holds CHECK constraints on an ordinary table, but for\n      ** a VIEW it holds the list of column names.\n      */\n      sqlite3ColumnsFromExprList(pParse, pTable->pCheck, \n                                 &pTable->nCol, &pTable->aCol);\n      if( db->mallocFailed==0 \n       && pParse->nErr==0\n       && pTable->nCol==pSel->pEList->nExpr\n      ){\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);\n      }\n    }else if( pSelTab ){\n      /* CREATE VIEW name AS...  without an argument list.  Construct\n      ** the column names from the SELECT statement that defines the view.\n      */\n      assert( pTable->aCol==0 );\n      pTable->nCol = pSelTab->nCol;\n      pTable->aCol = pSelTab->aCol;\n      pSelTab->nCol = 0;\n      pSelTab->aCol = 0;\n      assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );\n    }else{\n      pTable->nCol = 0;\n      nErr++;\n    }\n    sqlite3DeleteTable(db, pSelTab);\n    sqlite3SelectDelete(db, pSel);\n    db->lookaside.bDisable--;\n  } else {\n    nErr++;\n  }\n  pTable->pSchema->schemaFlags |= DB_UnresetViews;\n#endif /* SQLITE_OMIT_VIEW */\n  return nErr;  \n}\n#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifndef SQLITE_OMIT_VIEW\n/*\n** Clear the column names from every VIEW in database idx.\n*/\nstatic void sqliteViewResetAll(sqlite3 *db, int idx){\n  HashElem *i;\n  assert( sqlite3SchemaMutexHeld(db, idx, 0) );\n  if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;\n  for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){\n    Table *pTab = sqliteHashData(i);\n    if( pTab->pSelect ){\n      sqlite3DeleteColumnNames(db, pTab);\n      pTab->aCol = 0;\n      pTab->nCol = 0;\n    }\n  }\n  DbClearProperty(db, idx, DB_UnresetViews);\n}\n#else\n# define sqliteViewResetAll(A,B)\n#endif /* SQLITE_OMIT_VIEW */\n\n/*\n** This function is called by the VDBE to adjust the internal schema\n** used by SQLite when the btree layer moves a table root page. The\n** root-page of a table or index in database iDb has changed from iFrom\n** to iTo.\n**\n** Ticket #1728:  The symbol table might still contain information\n** on tables and/or indices that are the process of being deleted.\n** If you are unlucky, one of those deleted indices or tables might\n** have the same rootpage number as the real table or index that is\n** being moved.  So we cannot stop searching after the first match \n** because the first match might be for one of the deleted indices\n** or tables and not the table/index that is actually being moved.\n** We must continue looping until all tables and indices with\n** rootpage==iFrom have been converted to have a rootpage of iTo\n** in order to be certain that we got the right one.\n*/\n#ifndef SQLITE_OMIT_AUTOVACUUM\nvoid sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){\n  HashElem *pElem;\n  Hash *pHash;\n  Db *pDb;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pDb = &db->aDb[iDb];\n  pHash = &pDb->pSchema->tblHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    if( pTab->tnum==iFrom ){\n      pTab->tnum = iTo;\n    }\n  }\n  pHash = &pDb->pSchema->idxHash;\n  for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){\n    Index *pIdx = sqliteHashData(pElem);\n    if( pIdx->tnum==iFrom ){\n      pIdx->tnum = iTo;\n    }\n  }\n}\n#endif\n\n/*\n** Write code to erase the table with root-page iTable from database iDb.\n** Also write code to modify the sqlite_master table and internal schema\n** if a root-page of another table is moved by the btree-layer whilst\n** erasing iTable (this can happen with an auto-vacuum database).\n*/ \nstatic void destroyRootPage(Parse *pParse, int iTable, int iDb){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int r1 = sqlite3GetTempReg(pParse);\n  assert( iTable>1 );\n  sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);\n  sqlite3MayAbort(pParse);\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  /* OP_Destroy stores an in integer r1. If this integer\n  ** is non-zero, then it is the root page number of a table moved to\n  ** location iTable. The following code modifies the sqlite_master table to\n  ** reflect this.\n  **\n  ** The \"#NNN\" in the SQL is a special constant that means whatever value\n  ** is in register NNN.  See grammar rules associated with the TK_REGISTER\n  ** token for additional information.\n  */\n  sqlite3NestedParse(pParse, \n     \"UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d\",\n     pParse->db->aDb[iDb].zDbSName, MASTER_NAME, iTable, r1, r1);\n#endif\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** Write VDBE code to erase table pTab and all associated indices on disk.\n** Code to update the sqlite_master tables and internal schema definitions\n** in case a root-page belonging to another table is moved by the btree layer\n** is also added (this can happen with an auto-vacuum database).\n*/\nstatic void destroyTable(Parse *pParse, Table *pTab){\n  /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM\n  ** is not defined), then it is important to call OP_Destroy on the\n  ** table and index root-pages in order, starting with the numerically \n  ** largest root-page number. This guarantees that none of the root-pages\n  ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the\n  ** following were coded:\n  **\n  ** OP_Destroy 4 0\n  ** ...\n  ** OP_Destroy 5 0\n  **\n  ** and root page 5 happened to be the largest root-page number in the\n  ** database, then root page 5 would be moved to page 4 by the \n  ** \"OP_Destroy 4 0\" opcode. The subsequent \"OP_Destroy 5 0\" would hit\n  ** a free-list page.\n  */\n  int iTab = pTab->tnum;\n  int iDestroyed = 0;\n\n  while( 1 ){\n    Index *pIdx;\n    int iLargest = 0;\n\n    if( iDestroyed==0 || iTab<iDestroyed ){\n      iLargest = iTab;\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int iIdx = pIdx->tnum;\n      assert( pIdx->pSchema==pTab->pSchema );\n      if( (iDestroyed==0 || (iIdx<iDestroyed)) && iIdx>iLargest ){\n        iLargest = iIdx;\n      }\n    }\n    if( iLargest==0 ){\n      return;\n    }else{\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      assert( iDb>=0 && iDb<pParse->db->nDb );\n      destroyRootPage(pParse, iLargest, iDb);\n      iDestroyed = iLargest;\n    }\n  }\n}\n\n/*\n** Remove entries from the sqlite_statN tables (for N in (1,2,3))\n** after a DROP INDEX or DROP TABLE command.\n*/\nstatic void sqlite3ClearStatTables(\n  Parse *pParse,         /* The parsing context */\n  int iDb,               /* The database number */\n  const char *zType,     /* \"idx\" or \"tbl\" */\n  const char *zName      /* Name of index or table */\n){\n  int i;\n  const char *zDbName = pParse->db->aDb[iDb].zDbSName;\n  for(i=1; i<=4; i++){\n    char zTab[24];\n    sqlite3_snprintf(sizeof(zTab),zTab,\"sqlite_stat%d\",i);\n    if( sqlite3FindTable(pParse->db, zTab, zDbName) ){\n      sqlite3NestedParse(pParse,\n        \"DELETE FROM %Q.%s WHERE %s=%Q\",\n        zDbName, zTab, zType, zName\n      );\n    }\n  }\n}\n\n/*\n** Generate code to drop a table.\n*/\nvoid sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  Trigger *pTrigger;\n  Db *pDb = &db->aDb[iDb];\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp0(v, OP_VBegin);\n  }\n#endif\n\n  /* Drop all triggers associated with the table being dropped. Code\n  ** is generated to remove entries from sqlite_master and/or\n  ** sqlite_temp_master if required.\n  */\n  pTrigger = sqlite3TriggerList(pParse, pTab);\n  while( pTrigger ){\n    assert( pTrigger->pSchema==pTab->pSchema || \n        pTrigger->pSchema==db->aDb[1].pSchema );\n    sqlite3DropTriggerPtr(pParse, pTrigger);\n    pTrigger = pTrigger->pNext;\n  }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  /* Remove any entries of the sqlite_sequence table associated with\n  ** the table being dropped. This is done before the table is dropped\n  ** at the btree level, in case the sqlite_sequence table needs to\n  ** move as a result of the drop (can happen in auto-vacuum mode).\n  */\n  if( pTab->tabFlags & TF_Autoincrement ){\n    sqlite3NestedParse(pParse,\n      \"DELETE FROM %Q.sqlite_sequence WHERE name=%Q\",\n      pDb->zDbSName, pTab->zName\n    );\n  }\n#endif\n\n  /* Drop all SQLITE_MASTER table and index entries that refer to the\n  ** table. The program name loops through the master table and deletes\n  ** every row that refers to a table of the same name as the one being\n  ** dropped. Triggers are handled separately because a trigger can be\n  ** created in the temp database that refers to a table in another\n  ** database.\n  */\n  sqlite3NestedParse(pParse, \n      \"DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'\",\n      pDb->zDbSName, MASTER_NAME, pTab->zName);\n  if( !isView && !IsVirtual(pTab) ){\n    destroyTable(pParse, pTab);\n  }\n\n  /* Remove the table entry from SQLite's internal schema and modify\n  ** the schema cookie.\n  */\n  if( IsVirtual(pTab) ){\n    sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);\n  }\n  sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);\n  sqlite3ChangeCookie(pParse, iDb);\n  sqliteViewResetAll(db, iDb);\n}\n\n/*\n** This routine is called to do the work of a DROP TABLE statement.\n** pName is the name of the table to be dropped.\n*/\nvoid sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){\n  Table *pTab;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  if( db->mallocFailed ){\n    goto exit_drop_table;\n  }\n  assert( pParse->nErr==0 );\n  assert( pName->nSrc==1 );\n  if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;\n  if( noErr ) db->suppressErr++;\n  assert( isView==0 || isView==LOCATE_VIEW );\n  pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);\n  if( noErr ) db->suppressErr--;\n\n  if( pTab==0 ){\n    if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    goto exit_drop_table;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n\n  /* If pTab is a virtual table, call ViewGetColumnNames() to ensure\n  ** it is initialized.\n  */\n  if( IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto exit_drop_table;\n  }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zArg2 = 0;\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){\n      goto exit_drop_table;\n    }\n    if( isView ){\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_VIEW;\n      }else{\n        code = SQLITE_DROP_VIEW;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    }else if( IsVirtual(pTab) ){\n      code = SQLITE_DROP_VTABLE;\n      zArg2 = sqlite3GetVTable(db, pTab)->pMod->zName;\n#endif\n    }else{\n      if( !OMIT_TEMPDB && iDb==1 ){\n        code = SQLITE_DROP_TEMP_TABLE;\n      }else{\n        code = SQLITE_DROP_TABLE;\n      }\n    }\n    if( sqlite3AuthCheck(pParse, code, pTab->zName, zArg2, zDb) ){\n      goto exit_drop_table;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){\n      goto exit_drop_table;\n    }\n  }\n#endif\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n    && sqlite3StrNICmp(pTab->zName, \"sqlite_stat\", 11)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be dropped\", pTab->zName);\n    goto exit_drop_table;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used\n  ** on a table.\n  */\n  if( isView && pTab->pSelect==0 ){\n    sqlite3ErrorMsg(pParse, \"use DROP TABLE to delete table %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n  if( !isView && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"use DROP VIEW to delete view %s\", pTab->zName);\n    goto exit_drop_table;\n  }\n#endif\n\n  /* Generate code to remove the table from the master table\n  ** on disk.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3ClearStatTables(pParse, iDb, \"tbl\", pTab->zName);\n    sqlite3FkDropTable(pParse, pName, pTab);\n    sqlite3CodeDropTable(pParse, pTab, iDb, isView);\n  }\n\nexit_drop_table:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** This routine is called to create a new foreign key on the table\n** currently under construction.  pFromCol determines which columns\n** in the current table point to the foreign key.  If pFromCol==0 then\n** connect the key to the last column inserted.  pTo is the name of\n** the table referred to (a.k.a the \"parent\" table).  pToCol is a list\n** of tables in the parent pTo table.  flags contains all\n** information about the conflict resolution algorithms specified\n** in the ON DELETE, ON UPDATE and ON INSERT clauses.\n**\n** An FKey structure is created and added to the table currently\n** under construction in the pParse->pNewTable field.\n**\n** The foreign key is set for IMMEDIATE processing.  A subsequent call\n** to sqlite3DeferForeignKey() might change this to DEFERRED.\n*/\nvoid sqlite3CreateForeignKey(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pFromCol,  /* Columns in this table that point to other table */\n  Token *pTo,          /* Name of the other table */\n  ExprList *pToCol,    /* Columns in the other table */\n  int flags            /* Conflict resolution algorithms. */\n){\n  sqlite3 *db = pParse->db;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  FKey *pFKey = 0;\n  FKey *pNextTo;\n  Table *p = pParse->pNewTable;\n  int nByte;\n  int i;\n  int nCol;\n  char *z;\n\n  assert( pTo!=0 );\n  if( p==0 || IN_DECLARE_VTAB ) goto fk_end;\n  if( pFromCol==0 ){\n    int iCol = p->nCol-1;\n    if( NEVER(iCol<0) ) goto fk_end;\n    if( pToCol && pToCol->nExpr!=1 ){\n      sqlite3ErrorMsg(pParse, \"foreign key on %s\"\n         \" should reference only one column of table %T\",\n         p->aCol[iCol].zName, pTo);\n      goto fk_end;\n    }\n    nCol = 1;\n  }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){\n    sqlite3ErrorMsg(pParse,\n        \"number of columns in foreign key does not match the number of \"\n        \"columns in the referenced table\");\n    goto fk_end;\n  }else{\n    nCol = pFromCol->nExpr;\n  }\n  nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1;\n  if( pToCol ){\n    for(i=0; i<pToCol->nExpr; i++){\n      nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;\n    }\n  }\n  pFKey = sqlite3DbMallocZero(db, nByte );\n  if( pFKey==0 ){\n    goto fk_end;\n  }\n  pFKey->pFrom = p;\n  pFKey->pNextFrom = p->pFKey;\n  z = (char*)&pFKey->aCol[nCol];\n  pFKey->zTo = z;\n  memcpy(z, pTo->z, pTo->n);\n  z[pTo->n] = 0;\n  sqlite3Dequote(z);\n  z += pTo->n+1;\n  pFKey->nCol = nCol;\n  if( pFromCol==0 ){\n    pFKey->aCol[0].iFrom = p->nCol-1;\n  }else{\n    for(i=0; i<nCol; i++){\n      int j;\n      for(j=0; j<p->nCol; j++){\n        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){\n          pFKey->aCol[i].iFrom = j;\n          break;\n        }\n      }\n      if( j>=p->nCol ){\n        sqlite3ErrorMsg(pParse, \n          \"unknown column \\\"%s\\\" in foreign key definition\", \n          pFromCol->a[i].zName);\n        goto fk_end;\n      }\n    }\n  }\n  if( pToCol ){\n    for(i=0; i<nCol; i++){\n      int n = sqlite3Strlen30(pToCol->a[i].zName);\n      pFKey->aCol[i].zCol = z;\n      memcpy(z, pToCol->a[i].zName, n);\n      z[n] = 0;\n      z += n+1;\n    }\n  }\n  pFKey->isDeferred = 0;\n  pFKey->aAction[0] = (u8)(flags & 0xff);            /* ON DELETE action */\n  pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff);    /* ON UPDATE action */\n\n  assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n  pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, \n      pFKey->zTo, (void *)pFKey\n  );\n  if( pNextTo==pFKey ){\n    sqlite3OomFault(db);\n    goto fk_end;\n  }\n  if( pNextTo ){\n    assert( pNextTo->pPrevTo==0 );\n    pFKey->pNextTo = pNextTo;\n    pNextTo->pPrevTo = pFKey;\n  }\n\n  /* Link the foreign key to the table as the last step.\n  */\n  p->pFKey = pFKey;\n  pFKey = 0;\n\nfk_end:\n  sqlite3DbFree(db, pFKey);\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n  sqlite3ExprListDelete(db, pFromCol);\n  sqlite3ExprListDelete(db, pToCol);\n}\n\n/*\n** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED\n** clause is seen as part of a foreign key definition.  The isDeferred\n** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.\n** The behavior of the most recently created foreign key is adjusted\n** accordingly.\n*/\nvoid sqlite3DeferForeignKey(Parse *pParse, int isDeferred){\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  Table *pTab;\n  FKey *pFKey;\n  if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;\n  assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */\n  pFKey->isDeferred = (u8)isDeferred;\n#endif\n}\n\n/*\n** Generate code that will erase and refill index *pIdx.  This is\n** used to initialize a newly created index or to recompute the\n** content of an index in response to a REINDEX command.\n**\n** if memRootPage is not negative, it means that the index is newly\n** created.  The register specified by memRootPage contains the\n** root page number of the index.  If memRootPage is negative, then\n** the index already exists and must be cleared before being refilled and\n** the root page number of the index is taken from pIndex->tnum.\n*/\nstatic void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){\n  Table *pTab = pIndex->pTable;  /* The table that is indexed */\n  int iTab = pParse->nTab++;     /* Btree cursor used for pTab */\n  int iIdx = pParse->nTab++;     /* Btree cursor used for pIndex */\n  int iSorter;                   /* Cursor opened by OpenSorter (if in use) */\n  int addr1;                     /* Address of top of loop */\n  int addr2;                     /* Address to jump to for next iteration */\n  int tnum;                      /* Root page of index */\n  int iPartIdxLabel;             /* Jump to this label to skip a row */\n  Vdbe *v;                       /* Generate code into this virtual machine */\n  KeyInfo *pKey;                 /* KeyInfo for index */\n  int regRecord;                 /* Register holding assembled index record */\n  sqlite3 *db = pParse->db;      /* The database connection */\n  int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,\n      db->aDb[iDb].zDbSName ) ){\n    return;\n  }\n#endif\n\n  /* Require a write-lock on the table to perform this operation */\n  sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) return;\n  if( memRootPage>=0 ){\n    tnum = memRootPage;\n  }else{\n    tnum = pIndex->tnum;\n  }\n  pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);\n  assert( pKey!=0 || db->mallocFailed || pParse->nErr );\n\n  /* Open the sorter cursor if we are to use one. */\n  iSorter = pParse->nTab++;\n  sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, pIndex->nKeyCol, (char*)\n                    sqlite3KeyInfoRef(pKey), P4_KEYINFO);\n\n  /* Open the table. Loop through all rows of the table, inserting index\n  ** records into the sorter. */\n  sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n  addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);\n  regRecord = sqlite3GetTempReg(pParse);\n\n  sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);\n  sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);\n  sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n  sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n  if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);\n  sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, \n                    (char *)pKey, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));\n\n  addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);\n  if( IsUniqueIndex(pIndex) ){\n    int j2 = sqlite3VdbeCurrentAddr(v) + 3;\n    sqlite3VdbeGoto(v, j2);\n    addr2 = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,\n                         pIndex->nKeyCol); VdbeCoverage(v);\n    sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);\n  }else{\n    addr2 = sqlite3VdbeCurrentAddr(v);\n  }\n  sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);\n  sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  sqlite3VdbeAddOp1(v, OP_Close, iTab);\n  sqlite3VdbeAddOp1(v, OP_Close, iIdx);\n  sqlite3VdbeAddOp1(v, OP_Close, iSorter);\n}\n\n/*\n** Allocate heap space to hold an Index object with nCol columns.\n**\n** Increase the allocation size to provide an extra nExtra bytes\n** of 8-byte aligned space after the Index object and return a\n** pointer to this extra space in *ppExtra.\n*/\nIndex *sqlite3AllocateIndexObject(\n  sqlite3 *db,         /* Database connection */\n  i16 nCol,            /* Total number of columns in the index */\n  int nExtra,          /* Number of bytes of extra space to alloc */\n  char **ppExtra       /* Pointer to the \"extra\" space */\n){\n  Index *p;            /* Allocated index object */\n  int nByte;           /* Bytes of space for Index object + arrays */\n\n  nByte = ROUND8(sizeof(Index)) +              /* Index structure  */\n          ROUND8(sizeof(char*)*nCol) +         /* Index.azColl     */\n          ROUND8(sizeof(LogEst)*(nCol+1) +     /* Index.aiRowLogEst   */\n                 sizeof(i16)*nCol +            /* Index.aiColumn   */\n                 sizeof(u8)*nCol);             /* Index.aSortOrder */\n  p = sqlite3DbMallocZero(db, nByte + nExtra);\n  if( p ){\n    char *pExtra = ((char*)p)+ROUND8(sizeof(Index));\n    p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);\n    p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);\n    p->aiColumn = (i16*)pExtra;       pExtra += sizeof(i16)*nCol;\n    p->aSortOrder = (u8*)pExtra;\n    p->nColumn = nCol;\n    p->nKeyCol = nCol - 1;\n    *ppExtra = ((char*)p) + nByte;\n  }\n  return p;\n}\n\n/*\n** Create a new index for an SQL table.  pName1.pName2 is the name of the index \n** and pTblList is the name of the table that is to be indexed.  Both will \n** be NULL for a primary key or an index that is created to satisfy a\n** UNIQUE constraint.  If pTable and pIndex are NULL, use pParse->pNewTable\n** as the table to be indexed.  pParse->pNewTable is a table that is\n** currently being constructed by a CREATE TABLE statement.\n**\n** pList is a list of columns to be indexed.  pList will be NULL if this\n** is a primary key or unique-constraint on the most recent column added\n** to the table currently under construction.  \n*/\nvoid sqlite3CreateIndex(\n  Parse *pParse,     /* All information about this parse */\n  Token *pName1,     /* First part of index name. May be NULL */\n  Token *pName2,     /* Second part of index name. May be NULL */\n  SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */\n  ExprList *pList,   /* A list of columns to be indexed */\n  int onError,       /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  Token *pStart,     /* The CREATE token that begins this statement */\n  Expr *pPIWhere,    /* WHERE clause for partial indices */\n  int sortOrder,     /* Sort order of primary key when pList==NULL */\n  int ifNotExist,    /* Omit error if index already exists */\n  u8 idxType         /* The index type */\n){\n  Table *pTab = 0;     /* Table to be indexed */\n  Index *pIndex = 0;   /* The index to be created */\n  char *zName = 0;     /* Name of the index */\n  int nName;           /* Number of characters in zName */\n  int i, j;\n  DbFixer sFix;        /* For assigning database names to pTable */\n  int sortOrderMask;   /* 1 to honor DESC in index.  0 to ignore. */\n  sqlite3 *db = pParse->db;\n  Db *pDb;             /* The specific table containing the indexed database */\n  int iDb;             /* Index of the database that is being written */\n  Token *pName = 0;    /* Unqualified name of the index to create */\n  struct ExprList_item *pListItem; /* For looping over pList */\n  int nExtra = 0;                  /* Space allocated for zExtra[] */\n  int nExtraCol;                   /* Number of extra columns needed */\n  char *zExtra = 0;                /* Extra space after the Index object */\n  Index *pPk = 0;      /* PRIMARY KEY index for WITHOUT ROWID tables */\n\n  if( db->mallocFailed || pParse->nErr>0 ){\n    goto exit_create_index;\n  }\n  if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){\n    goto exit_create_index;\n  }\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_create_index;\n  }\n\n  /*\n  ** Find the table that is to be indexed.  Return early if not found.\n  */\n  if( pTblName!=0 ){\n\n    /* Use the two-part index name to determine the database \n    ** to search for the table. 'Fix' the table name to this db\n    ** before looking up the table.\n    */\n    assert( pName1 && pName2 );\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ) goto exit_create_index;\n    assert( pName && pName->z );\n\n#ifndef SQLITE_OMIT_TEMPDB\n    /* If the index name was unqualified, check if the table\n    ** is a temp table. If so, set the database to 1. Do not do this\n    ** if initialising a database schema.\n    */\n    if( !db->init.busy ){\n      pTab = sqlite3SrcListLookup(pParse, pTblName);\n      if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){\n        iDb = 1;\n      }\n    }\n#endif\n\n    sqlite3FixInit(&sFix, pParse, iDb, \"index\", pName);\n    if( sqlite3FixSrcList(&sFix, pTblName) ){\n      /* Because the parser constructs pTblName from a single identifier,\n      ** sqlite3FixSrcList can never fail. */\n      assert(0);\n    }\n    pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);\n    assert( db->mallocFailed==0 || pTab==0 );\n    if( pTab==0 ) goto exit_create_index;\n    if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){\n      sqlite3ErrorMsg(pParse, \n           \"cannot create a TEMP index on non-TEMP table \\\"%s\\\"\",\n           pTab->zName);\n      goto exit_create_index;\n    }\n    if( !HasRowid(pTab) ) pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    assert( pName==0 );\n    assert( pStart==0 );\n    pTab = pParse->pNewTable;\n    if( !pTab ) goto exit_create_index;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  }\n  pDb = &db->aDb[iDb];\n\n  assert( pTab!=0 );\n  assert( pParse->nErr==0 );\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 \n       && db->init.busy==0\n#if SQLITE_USER_AUTHENTICATION\n       && sqlite3UserAuthTable(pTab->zName)==0\n#endif\n       && sqlite3StrNICmp(&pTab->zName[7],\"altertab_\",9)!=0 ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be indexed\", pTab->zName);\n    goto exit_create_index;\n  }\n#ifndef SQLITE_OMIT_VIEW\n  if( pTab->pSelect ){\n    sqlite3ErrorMsg(pParse, \"views may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"virtual tables may not be indexed\");\n    goto exit_create_index;\n  }\n#endif\n\n  /*\n  ** Find the name of the index.  Make sure there is not already another\n  ** index or table with the same name.  \n  **\n  ** Exception:  If we are reading the names of permanent indices from the\n  ** sqlite_master table (because some other process changed the schema) and\n  ** one of the index names collides with the name of a temporary table or\n  ** index, then we will continue to process this index.\n  **\n  ** If pName==0 it means that we are\n  ** dealing with a primary key or UNIQUE constraint.  We have to invent our\n  ** own name.\n  */\n  if( pName ){\n    zName = sqlite3NameFromToken(db, pName);\n    if( zName==0 ) goto exit_create_index;\n    assert( pName->z!=0 );\n    if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n      goto exit_create_index;\n    }\n    if( !db->init.busy ){\n      if( sqlite3FindTable(db, zName, 0)!=0 ){\n        sqlite3ErrorMsg(pParse, \"there is already a table named %s\", zName);\n        goto exit_create_index;\n      }\n    }\n    if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){\n      if( !ifNotExist ){\n        sqlite3ErrorMsg(pParse, \"index %s already exists\", zName);\n      }else{\n        assert( !db->init.busy );\n        sqlite3CodeVerifySchema(pParse, iDb);\n      }\n      goto exit_create_index;\n    }\n  }else{\n    int n;\n    Index *pLoop;\n    for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}\n    zName = sqlite3MPrintf(db, \"sqlite_autoindex_%s_%d\", pTab->zName, n);\n    if( zName==0 ){\n      goto exit_create_index;\n    }\n\n    /* Automatic index names generated from within sqlite3_declare_vtab()\n    ** must have names that are distinct from normal automatic index names.\n    ** The following statement converts \"sqlite3_autoindex...\" into\n    ** \"sqlite3_butoindex...\" in order to make the names distinct.\n    ** The \"vtab_err.test\" test demonstrates the need of this statement. */\n    if( IN_DECLARE_VTAB ) zName[7]++;\n  }\n\n  /* Check for authorization to create an index.\n  */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    const char *zDb = pDb->zDbSName;\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){\n      goto exit_create_index;\n    }\n    i = SQLITE_CREATE_INDEX;\n    if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){\n      goto exit_create_index;\n    }\n  }\n#endif\n\n  /* If pList==0, it means this routine was called to make a primary\n  ** key out of the last column added to the table under construction.\n  ** So create a fake list to simulate this.\n  */\n  if( pList==0 ){\n    Token prevCol;\n    sqlite3TokenInit(&prevCol, pTab->aCol[pTab->nCol-1].zName);\n    pList = sqlite3ExprListAppend(pParse, 0,\n              sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));\n    if( pList==0 ) goto exit_create_index;\n    assert( pList->nExpr==1 );\n    sqlite3ExprListSetSortOrder(pList, sortOrder);\n  }else{\n    sqlite3ExprListCheckLength(pParse, pList, \"index\");\n  }\n\n  /* Figure out how many bytes of space are required to store explicitly\n  ** specified collation sequence names.\n  */\n  for(i=0; i<pList->nExpr; i++){\n    Expr *pExpr = pList->a[i].pExpr;\n    assert( pExpr!=0 );\n    if( pExpr->op==TK_COLLATE ){\n      nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));\n    }\n  }\n\n  /* \n  ** Allocate the index structure. \n  */\n  nName = sqlite3Strlen30(zName);\n  nExtraCol = pPk ? pPk->nKeyCol : 1;\n  pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,\n                                      nName + nExtra + 1, &zExtra);\n  if( db->mallocFailed ){\n    goto exit_create_index;\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) );\n  assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );\n  pIndex->zName = zExtra;\n  zExtra += nName + 1;\n  memcpy(pIndex->zName, zName, nName+1);\n  pIndex->pTable = pTab;\n  pIndex->onError = (u8)onError;\n  pIndex->uniqNotNull = onError!=OE_None;\n  pIndex->idxType = idxType;\n  pIndex->pSchema = db->aDb[iDb].pSchema;\n  pIndex->nKeyCol = pList->nExpr;\n  if( pPIWhere ){\n    sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);\n    pIndex->pPartIdxWhere = pPIWhere;\n    pPIWhere = 0;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n\n  /* Check to see if we should honor DESC requests on index columns\n  */\n  if( pDb->pSchema->file_format>=4 ){\n    sortOrderMask = -1;   /* Honor DESC */\n  }else{\n    sortOrderMask = 0;    /* Ignore DESC */\n  }\n\n  /* Analyze the list of expressions that form the terms of the index and\n  ** report any errors.  In the common case where the expression is exactly\n  ** a table column, store that column in aiColumn[].  For general expressions,\n  ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[].\n  **\n  ** TODO: Issue a warning if two or more columns of the index are identical.\n  ** TODO: Issue a warning if the table primary key is used as part of the\n  ** index key.\n  */\n  for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){\n    Expr *pCExpr;                  /* The i-th index expression */\n    int requestedSortOrder;        /* ASC or DESC on the i-th expression */\n    const char *zColl;             /* Collation sequence name */\n\n    sqlite3StringToId(pListItem->pExpr);\n    sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);\n    if( pParse->nErr ) goto exit_create_index;\n    pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);\n    if( pCExpr->op!=TK_COLUMN ){\n      if( pTab==pParse->pNewTable ){\n        sqlite3ErrorMsg(pParse, \"expressions prohibited in PRIMARY KEY and \"\n                                \"UNIQUE constraints\");\n        goto exit_create_index;\n      }\n      if( pIndex->aColExpr==0 ){\n        ExprList *pCopy = sqlite3ExprListDup(db, pList, 0);\n        pIndex->aColExpr = pCopy;\n        if( !db->mallocFailed ){\n          assert( pCopy!=0 );\n          pListItem = &pCopy->a[i];\n        }\n      }\n      j = XN_EXPR;\n      pIndex->aiColumn[i] = XN_EXPR;\n      pIndex->uniqNotNull = 0;\n    }else{\n      j = pCExpr->iColumn;\n      assert( j<=0x7fff );\n      if( j<0 ){\n        j = pTab->iPKey;\n      }else if( pTab->aCol[j].notNull==0 ){\n        pIndex->uniqNotNull = 0;\n      }\n      pIndex->aiColumn[i] = (i16)j;\n    }\n    zColl = 0;\n    if( pListItem->pExpr->op==TK_COLLATE ){\n      int nColl;\n      zColl = pListItem->pExpr->u.zToken;\n      nColl = sqlite3Strlen30(zColl) + 1;\n      assert( nExtra>=nColl );\n      memcpy(zExtra, zColl, nColl);\n      zColl = zExtra;\n      zExtra += nColl;\n      nExtra -= nColl;\n    }else if( j>=0 ){\n      zColl = pTab->aCol[j].zColl;\n    }\n    if( !zColl ) zColl = sqlite3StrBINARY;\n    if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){\n      goto exit_create_index;\n    }\n    pIndex->azColl[i] = zColl;\n    requestedSortOrder = pListItem->sortOrder & sortOrderMask;\n    pIndex->aSortOrder[i] = (u8)requestedSortOrder;\n  }\n\n  /* Append the table key to the end of the index.  For WITHOUT ROWID\n  ** tables (when pPk!=0) this will be the declared PRIMARY KEY.  For\n  ** normal tables (when pPk==0) this will be the rowid.\n  */\n  if( pPk ){\n    for(j=0; j<pPk->nKeyCol; j++){\n      int x = pPk->aiColumn[j];\n      assert( x>=0 );\n      if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){\n        pIndex->nColumn--; \n      }else{\n        pIndex->aiColumn[i] = x;\n        pIndex->azColl[i] = pPk->azColl[j];\n        pIndex->aSortOrder[i] = pPk->aSortOrder[j];\n        i++;\n      }\n    }\n    assert( i==pIndex->nColumn );\n  }else{\n    pIndex->aiColumn[i] = XN_ROWID;\n    pIndex->azColl[i] = sqlite3StrBINARY;\n  }\n  sqlite3DefaultRowEst(pIndex);\n  if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);\n\n  /* If this index contains every column of its table, then mark\n  ** it as a covering index */\n  assert( HasRowid(pTab) \n      || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );\n  if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){\n    pIndex->isCovering = 1;\n    for(j=0; j<pTab->nCol; j++){\n      if( j==pTab->iPKey ) continue;\n      if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;\n      pIndex->isCovering = 0;\n      break;\n    }\n  }\n\n  if( pTab==pParse->pNewTable ){\n    /* This routine has been called to create an automatic index as a\n    ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or\n    ** a PRIMARY KEY or UNIQUE clause following the column definitions.\n    ** i.e. one of:\n    **\n    ** CREATE TABLE t(x PRIMARY KEY, y);\n    ** CREATE TABLE t(x, y, UNIQUE(x, y));\n    **\n    ** Either way, check to see if the table already has such an index. If\n    ** so, don't bother creating this one. This only applies to\n    ** automatically created indices. Users can do as they wish with\n    ** explicit indices.\n    **\n    ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent\n    ** (and thus suppressing the second one) even if they have different\n    ** sort orders.\n    **\n    ** If there are different collating sequences or if the columns of\n    ** the constraint occur in different orders, then the constraints are\n    ** considered distinct and both result in separate indices.\n    */\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int k;\n      assert( IsUniqueIndex(pIdx) );\n      assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );\n      assert( IsUniqueIndex(pIndex) );\n\n      if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;\n      for(k=0; k<pIdx->nKeyCol; k++){\n        const char *z1;\n        const char *z2;\n        assert( pIdx->aiColumn[k]>=0 );\n        if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;\n        z1 = pIdx->azColl[k];\n        z2 = pIndex->azColl[k];\n        if( sqlite3StrICmp(z1, z2) ) break;\n      }\n      if( k==pIdx->nKeyCol ){\n        if( pIdx->onError!=pIndex->onError ){\n          /* This constraint creates the same index as a previous\n          ** constraint specified somewhere in the CREATE TABLE statement.\n          ** However the ON CONFLICT clauses are different. If both this \n          ** constraint and the previous equivalent constraint have explicit\n          ** ON CONFLICT clauses this is an error. Otherwise, use the\n          ** explicitly specified behavior for the index.\n          */\n          if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){\n            sqlite3ErrorMsg(pParse, \n                \"conflicting ON CONFLICT clauses specified\", 0);\n          }\n          if( pIdx->onError==OE_Default ){\n            pIdx->onError = pIndex->onError;\n          }\n        }\n        if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;\n        goto exit_create_index;\n      }\n    }\n  }\n\n  /* Link the new Index structure to its table and to the other\n  ** in-memory database structures. \n  */\n  assert( pParse->nErr==0 );\n  if( db->init.busy ){\n    Index *p;\n    assert( !IN_DECLARE_VTAB );\n    assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );\n    p = sqlite3HashInsert(&pIndex->pSchema->idxHash, \n                          pIndex->zName, pIndex);\n    if( p ){\n      assert( p==pIndex );  /* Malloc must have failed */\n      sqlite3OomFault(db);\n      goto exit_create_index;\n    }\n    db->mDbFlags |= DBFLAG_SchemaChange;\n    if( pTblName!=0 ){\n      pIndex->tnum = db->init.newTnum;\n    }\n  }\n\n  /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the\n  ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then\n  ** emit code to allocate the index rootpage on disk and make an entry for\n  ** the index in the sqlite_master table and populate the index with\n  ** content.  But, do not do this if we are simply reading the sqlite_master\n  ** table to parse the schema, or if this index is the PRIMARY KEY index\n  ** of a WITHOUT ROWID table.\n  **\n  ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY\n  ** or UNIQUE index in a CREATE TABLE statement.  Since the table\n  ** has just been created, it contains no data and the index initialization\n  ** step can be skipped.\n  */\n  else if( HasRowid(pTab) || pTblName!=0 ){\n    Vdbe *v;\n    char *zStmt;\n    int iMem = ++pParse->nMem;\n\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto exit_create_index;\n\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n    /* Create the rootpage for the index using CreateIndex. But before\n    ** doing so, code a Noop instruction and store its address in \n    ** Index.tnum. This is required in case this index is actually a \n    ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In \n    ** that case the convertToWithoutRowidTable() routine will replace\n    ** the Noop with a Goto to jump over the VDBE code generated below. */\n    pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);\n    sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);\n\n    /* Gather the complete text of the CREATE INDEX statement into\n    ** the zStmt variable\n    */\n    if( pStart ){\n      int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;\n      if( pName->z[n-1]==';' ) n--;\n      /* A named index with an explicit CREATE INDEX statement */\n      zStmt = sqlite3MPrintf(db, \"CREATE%s INDEX %.*s\",\n        onError==OE_None ? \"\" : \" UNIQUE\", n, pName->z);\n    }else{\n      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */\n      /* zStmt = sqlite3MPrintf(\"\"); */\n      zStmt = 0;\n    }\n\n    /* Add an entry in sqlite_master for this index\n    */\n    sqlite3NestedParse(pParse, \n        \"INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);\",\n        db->aDb[iDb].zDbSName, MASTER_NAME,\n        pIndex->zName,\n        pTab->zName,\n        iMem,\n        zStmt\n    );\n    sqlite3DbFree(db, zStmt);\n\n    /* Fill the index with data and reparse the schema. Code an OP_Expire\n    ** to invalidate all pre-compiled statements.\n    */\n    if( pTblName ){\n      sqlite3RefillIndex(pParse, pIndex, iMem);\n      sqlite3ChangeCookie(pParse, iDb);\n      sqlite3VdbeAddParseSchemaOp(v, iDb,\n         sqlite3MPrintf(db, \"name='%q' AND type='index'\", pIndex->zName));\n      sqlite3VdbeAddOp0(v, OP_Expire);\n    }\n\n    sqlite3VdbeJumpHere(v, pIndex->tnum);\n  }\n\n  /* When adding an index to the list of indices for a table, make\n  ** sure all indices labeled OE_Replace come after all those labeled\n  ** OE_Ignore.  This is necessary for the correct constraint check\n  ** processing (in sqlite3GenerateConstraintChecks()) as part of\n  ** UPDATE and INSERT statements.  \n  */\n  if( db->init.busy || pTblName==0 ){\n    if( onError!=OE_Replace || pTab->pIndex==0\n         || pTab->pIndex->onError==OE_Replace){\n      pIndex->pNext = pTab->pIndex;\n      pTab->pIndex = pIndex;\n    }else{\n      Index *pOther = pTab->pIndex;\n      while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){\n        pOther = pOther->pNext;\n      }\n      pIndex->pNext = pOther->pNext;\n      pOther->pNext = pIndex;\n    }\n    pIndex = 0;\n  }\n\n  /* Clean up before exiting */\nexit_create_index:\n  if( pIndex ) freeIndex(db, pIndex);\n  sqlite3ExprDelete(db, pPIWhere);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SrcListDelete(db, pTblName);\n  sqlite3DbFree(db, zName);\n}\n\n/*\n** Fill the Index.aiRowEst[] array with default information - information\n** to be used when we have not run the ANALYZE command.\n**\n** aiRowEst[0] is supposed to contain the number of elements in the index.\n** Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the\n** number of rows in the table that match any particular value of the\n** first column of the index.  aiRowEst[2] is an estimate of the number\n** of rows that match any particular combination of the first 2 columns\n** of the index.  And so forth.  It must always be the case that\n*\n**           aiRowEst[N]<=aiRowEst[N-1]\n**           aiRowEst[N]>=1\n**\n** Apart from that, we have little to go on besides intuition as to\n** how aiRowEst[] should be initialized.  The numbers generated here\n** are based on typical values found in actual indices.\n*/\nvoid sqlite3DefaultRowEst(Index *pIdx){\n  /*                10,  9,  8,  7,  6 */\n  LogEst aVal[] = { 33, 32, 30, 28, 26 };\n  LogEst *a = pIdx->aiRowLogEst;\n  int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);\n  int i;\n\n  /* Indexes with default row estimates should not have stat1 data */\n  assert( !pIdx->hasStat1 );\n\n  /* Set the first entry (number of rows in the index) to the estimated \n  ** number of rows in the table, or half the number of rows in the table\n  ** for a partial index.   But do not let the estimate drop below 10. */\n  a[0] = pIdx->pTable->nRowLogEst;\n  if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10;  assert( 10==sqlite3LogEst(2) );\n  if( a[0]<33 ) a[0] = 33;                  assert( 33==sqlite3LogEst(10) );\n\n  /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is\n  ** 6 and each subsequent value (if any) is 5.  */\n  memcpy(&a[1], aVal, nCopy*sizeof(LogEst));\n  for(i=nCopy+1; i<=pIdx->nKeyCol; i++){\n    a[i] = 23;                    assert( 23==sqlite3LogEst(5) );\n  }\n\n  assert( 0==sqlite3LogEst(1) );\n  if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;\n}\n\n/*\n** This routine will drop an existing named index.  This routine\n** implements the DROP INDEX statement.\n*/\nvoid sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){\n  Index *pIndex;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  assert( pParse->nErr==0 );   /* Never called with prior errors */\n  if( db->mallocFailed ){\n    goto exit_drop_index;\n  }\n  assert( pName->nSrc==1 );\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto exit_drop_index;\n  }\n  pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);\n  if( pIndex==0 ){\n    if( !ifExists ){\n      sqlite3ErrorMsg(pParse, \"no such index: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);\n    }\n    pParse->checkSchema = 1;\n    goto exit_drop_index;\n  }\n  if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){\n    sqlite3ErrorMsg(pParse, \"index associated with UNIQUE \"\n      \"or PRIMARY KEY constraint cannot be dropped\", 0);\n    goto exit_drop_index;\n  }\n  iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_INDEX;\n    Table *pTab = pIndex->pTable;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      goto exit_drop_index;\n    }\n    if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;\n    if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){\n      goto exit_drop_index;\n    }\n  }\n#endif\n\n  /* Generate code to remove the index and from the master table */\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3BeginWriteOperation(pParse, 1, iDb);\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='index'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pIndex->zName\n    );\n    sqlite3ClearStatTables(pParse, iDb, \"idx\", pIndex->zName);\n    sqlite3ChangeCookie(pParse, iDb);\n    destroyRootPage(pParse, pIndex->tnum, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);\n  }\n\nexit_drop_index:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** pArray is a pointer to an array of objects. Each object in the\n** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()\n** to extend the array so that there is space for a new object at the end.\n**\n** When this function is called, *pnEntry contains the current size of\n** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes\n** in total).\n**\n** If the realloc() is successful (i.e. if no OOM condition occurs), the\n** space allocated for the new object is zeroed, *pnEntry updated to\n** reflect the new size of the array and a pointer to the new allocation\n** returned. *pIdx is set to the index of the new array entry in this case.\n**\n** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains\n** unchanged and a copy of pArray returned.\n*/\nvoid *sqlite3ArrayAllocate(\n  sqlite3 *db,      /* Connection to notify of malloc failures */\n  void *pArray,     /* Array of objects.  Might be reallocated */\n  int szEntry,      /* Size of each object in the array */\n  int *pnEntry,     /* Number of objects currently in use */\n  int *pIdx         /* Write the index of a new slot here */\n){\n  char *z;\n  int n = *pnEntry;\n  if( (n & (n-1))==0 ){\n    int sz = (n==0) ? 1 : 2*n;\n    void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry);\n    if( pNew==0 ){\n      *pIdx = -1;\n      return pArray;\n    }\n    pArray = pNew;\n  }\n  z = (char*)pArray;\n  memset(&z[n * szEntry], 0, szEntry);\n  *pIdx = n;\n  ++*pnEntry;\n  return pArray;\n}\n\n/*\n** Append a new element to the given IdList.  Create a new IdList if\n** need be.\n**\n** A new IdList is returned, or NULL if malloc() fails.\n*/\nIdList *sqlite3IdListAppend(sqlite3 *db, IdList *pList, Token *pToken){\n  int i;\n  if( pList==0 ){\n    pList = sqlite3DbMallocZero(db, sizeof(IdList) );\n    if( pList==0 ) return 0;\n  }\n  pList->a = sqlite3ArrayAllocate(\n      db,\n      pList->a,\n      sizeof(pList->a[0]),\n      &pList->nId,\n      &i\n  );\n  if( i<0 ){\n    sqlite3IdListDelete(db, pList);\n    return 0;\n  }\n  pList->a[i].zName = sqlite3NameFromToken(db, pToken);\n  return pList;\n}\n\n/*\n** Delete an IdList.\n*/\nvoid sqlite3IdListDelete(sqlite3 *db, IdList *pList){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nId; i++){\n    sqlite3DbFree(db, pList->a[i].zName);\n  }\n  sqlite3DbFree(db, pList->a);\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** Return the index in pList of the identifier named zId.  Return -1\n** if not found.\n*/\nint sqlite3IdListIndex(IdList *pList, const char *zName){\n  int i;\n  if( pList==0 ) return -1;\n  for(i=0; i<pList->nId; i++){\n    if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Expand the space allocated for the given SrcList object by\n** creating nExtra new slots beginning at iStart.  iStart is zero based.\n** New slots are zeroed.\n**\n** For example, suppose a SrcList initially contains two entries: A,B.\n** To append 3 new entries onto the end, do this:\n**\n**    sqlite3SrcListEnlarge(db, pSrclist, 3, 2);\n**\n** After the call above it would contain:  A, B, nil, nil, nil.\n** If the iStart argument had been 1 instead of 2, then the result\n** would have been:  A, nil, nil, nil, B.  To prepend the new slots,\n** the iStart value would be 0.  The result then would\n** be: nil, nil, nil, A, B.\n**\n** If a memory allocation fails the SrcList is unchanged.  The\n** db->mallocFailed flag will be set to true.\n*/\nSrcList *sqlite3SrcListEnlarge(\n  sqlite3 *db,       /* Database connection to notify of OOM errors */\n  SrcList *pSrc,     /* The SrcList to be enlarged */\n  int nExtra,        /* Number of new slots to add to pSrc->a[] */\n  int iStart         /* Index in pSrc->a[] of first new slot */\n){\n  int i;\n\n  /* Sanity checking on calling parameters */\n  assert( iStart>=0 );\n  assert( nExtra>=1 );\n  assert( pSrc!=0 );\n  assert( iStart<=pSrc->nSrc );\n\n  /* Allocate additional space if needed */\n  if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){\n    SrcList *pNew;\n    int nAlloc = pSrc->nSrc*2+nExtra;\n    int nGot;\n    pNew = sqlite3DbRealloc(db, pSrc,\n               sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );\n    if( pNew==0 ){\n      assert( db->mallocFailed );\n      return pSrc;\n    }\n    pSrc = pNew;\n    nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;\n    pSrc->nAlloc = nGot;\n  }\n\n  /* Move existing slots that come after the newly inserted slots\n  ** out of the way */\n  for(i=pSrc->nSrc-1; i>=iStart; i--){\n    pSrc->a[i+nExtra] = pSrc->a[i];\n  }\n  pSrc->nSrc += nExtra;\n\n  /* Zero the newly allocated slots */\n  memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);\n  for(i=iStart; i<iStart+nExtra; i++){\n    pSrc->a[i].iCursor = -1;\n  }\n\n  /* Return a pointer to the enlarged SrcList */\n  return pSrc;\n}\n\n\n/*\n** Append a new table name to the given SrcList.  Create a new SrcList if\n** need be.  A new entry is created in the SrcList even if pTable is NULL.\n**\n** A SrcList is returned, or NULL if there is an OOM error.  The returned\n** SrcList might be the same as the SrcList that was input or it might be\n** a new one.  If an OOM error does occurs, then the prior value of pList\n** that is input to this routine is automatically freed.\n**\n** If pDatabase is not null, it means that the table has an optional\n** database name prefix.  Like this:  \"database.table\".  The pDatabase\n** points to the table name and the pTable points to the database name.\n** The SrcList.a[].zName field is filled with the table name which might\n** come from pTable (if pDatabase is NULL) or from pDatabase.  \n** SrcList.a[].zDatabase is filled with the database name from pTable,\n** or with NULL if no database is specified.\n**\n** In other words, if call like this:\n**\n**         sqlite3SrcListAppend(D,A,B,0);\n**\n** Then B is a table name and the database name is unspecified.  If called\n** like this:\n**\n**         sqlite3SrcListAppend(D,A,B,C);\n**\n** Then C is the table name and B is the database name.  If C is defined\n** then so is B.  In other words, we never have a case where:\n**\n**         sqlite3SrcListAppend(D,A,0,C);\n**\n** Both pTable and pDatabase are assumed to be quoted.  They are dequoted\n** before being added to the SrcList.\n*/\nSrcList *sqlite3SrcListAppend(\n  sqlite3 *db,        /* Connection to notify of malloc failures */\n  SrcList *pList,     /* Append to this SrcList. NULL creates a new SrcList */\n  Token *pTable,      /* Table to append */\n  Token *pDatabase    /* Database of the table */\n){\n  struct SrcList_item *pItem;\n  assert( pDatabase==0 || pTable!=0 );  /* Cannot have C without B */\n  assert( db!=0 );\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(db, sizeof(SrcList) );\n    if( pList==0 ) return 0;\n    pList->nAlloc = 1;\n    pList->nSrc = 1;\n    memset(&pList->a[0], 0, sizeof(pList->a[0]));\n    pList->a[0].iCursor = -1;\n  }else{\n    pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);\n  }\n  if( db->mallocFailed ){\n    sqlite3SrcListDelete(db, pList);\n    return 0;\n  }\n  pItem = &pList->a[pList->nSrc-1];\n  if( pDatabase && pDatabase->z==0 ){\n    pDatabase = 0;\n  }\n  if( pDatabase ){\n    pItem->zName = sqlite3NameFromToken(db, pDatabase);\n    pItem->zDatabase = sqlite3NameFromToken(db, pTable);\n  }else{\n    pItem->zName = sqlite3NameFromToken(db, pTable);\n    pItem->zDatabase = 0;\n  }\n  return pList;\n}\n\n/*\n** Assign VdbeCursor index numbers to all tables in a SrcList\n*/\nvoid sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  assert(pList || pParse->db->mallocFailed );\n  if( pList ){\n    for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){\n      if( pItem->iCursor>=0 ) break;\n      pItem->iCursor = pParse->nTab++;\n      if( pItem->pSelect ){\n        sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);\n      }\n    }\n  }\n}\n\n/*\n** Delete an entire SrcList including all its substructure.\n*/\nvoid sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){\n  int i;\n  struct SrcList_item *pItem;\n  if( pList==0 ) return;\n  for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){\n    sqlite3DbFree(db, pItem->zDatabase);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zAlias);\n    if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy);\n    if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg);\n    sqlite3DeleteTable(db, pItem->pTab);\n    sqlite3SelectDelete(db, pItem->pSelect);\n    sqlite3ExprDelete(db, pItem->pOn);\n    sqlite3IdListDelete(db, pItem->pUsing);\n  }\n  sqlite3DbFreeNN(db, pList);\n}\n\n/*\n** This routine is called by the parser to add a new term to the\n** end of a growing FROM clause.  The \"p\" parameter is the part of\n** the FROM clause that has already been constructed.  \"p\" is NULL\n** if this is the first term of the FROM clause.  pTable and pDatabase\n** are the name of the table and database named in the FROM clause term.\n** pDatabase is NULL if the database name qualifier is missing - the\n** usual case.  If the term has an alias, then pAlias points to the\n** alias token.  If the term is a subquery, then pSubquery is the\n** SELECT statement that the subquery encodes.  The pTable and\n** pDatabase parameters are NULL for subqueries.  The pOn and pUsing\n** parameters are the content of the ON and USING clauses.\n**\n** Return a new SrcList which encodes is the FROM with the new\n** term added.\n*/\nSrcList *sqlite3SrcListAppendFromTerm(\n  Parse *pParse,          /* Parsing context */\n  SrcList *p,             /* The left part of the FROM clause already seen */\n  Token *pTable,          /* Name of the table to add to the FROM clause */\n  Token *pDatabase,       /* Name of the database containing pTable */\n  Token *pAlias,          /* The right-hand side of the AS subexpression */\n  Select *pSubquery,      /* A subquery used in place of a table name */\n  Expr *pOn,              /* The ON clause of a join */\n  IdList *pUsing          /* The USING clause of a join */\n){\n  struct SrcList_item *pItem;\n  sqlite3 *db = pParse->db;\n  if( !p && (pOn || pUsing) ){\n    sqlite3ErrorMsg(pParse, \"a JOIN clause is required before %s\", \n      (pOn ? \"ON\" : \"USING\")\n    );\n    goto append_from_error;\n  }\n  p = sqlite3SrcListAppend(db, p, pTable, pDatabase);\n  if( p==0 || NEVER(p->nSrc==0) ){\n    goto append_from_error;\n  }\n  pItem = &p->a[p->nSrc-1];\n  assert( pAlias!=0 );\n  if( pAlias->n ){\n    pItem->zAlias = sqlite3NameFromToken(db, pAlias);\n  }\n  pItem->pSelect = pSubquery;\n  pItem->pOn = pOn;\n  pItem->pUsing = pUsing;\n  return p;\n\n append_from_error:\n  assert( p==0 );\n  sqlite3ExprDelete(db, pOn);\n  sqlite3IdListDelete(db, pUsing);\n  sqlite3SelectDelete(db, pSubquery);\n  return 0;\n}\n\n/*\n** Add an INDEXED BY or NOT INDEXED clause to the most recently added \n** element of the source-list passed as the second argument.\n*/\nvoid sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){\n  assert( pIndexedBy!=0 );\n  if( p && pIndexedBy->n>0 ){\n    struct SrcList_item *pItem;\n    assert( p->nSrc>0 );\n    pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    if( pIndexedBy->n==1 && !pIndexedBy->z ){\n      /* A \"NOT INDEXED\" clause was supplied. See parse.y \n      ** construct \"indexed_opt\" for details. */\n      pItem->fg.notIndexed = 1;\n    }else{\n      pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy);\n      pItem->fg.isIndexedBy = 1;\n    }\n  }\n}\n\n/*\n** Add the list of function arguments to the SrcList entry for a\n** table-valued-function.\n*/\nvoid sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){\n  if( p ){\n    struct SrcList_item *pItem = &p->a[p->nSrc-1];\n    assert( pItem->fg.notIndexed==0 );\n    assert( pItem->fg.isIndexedBy==0 );\n    assert( pItem->fg.isTabFunc==0 );\n    pItem->u1.pFuncArg = pList;\n    pItem->fg.isTabFunc = 1;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n\n/*\n** When building up a FROM clause in the parser, the join operator\n** is initially attached to the left operand.  But the code generator\n** expects the join operator to be on the right operand.  This routine\n** Shifts all join operators from left to right for an entire FROM\n** clause.\n**\n** Example: Suppose the join is like this:\n**\n**           A natural cross join B\n**\n** The operator is \"natural cross join\".  The A and B operands are stored\n** in p->a[0] and p->a[1], respectively.  The parser initially stores the\n** operator with A.  This routine shifts that operator over to B.\n*/\nvoid sqlite3SrcListShiftJoinType(SrcList *p){\n  if( p ){\n    int i;\n    for(i=p->nSrc-1; i>0; i--){\n      p->a[i].fg.jointype = p->a[i-1].fg.jointype;\n    }\n    p->a[0].fg.jointype = 0;\n  }\n}\n\n/*\n** Generate VDBE code for a BEGIN statement.\n*/\nvoid sqlite3BeginTransaction(Parse *pParse, int type){\n  sqlite3 *db;\n  Vdbe *v;\n  int i;\n\n  assert( pParse!=0 );\n  db = pParse->db;\n  assert( db!=0 );\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \"BEGIN\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( !v ) return;\n  if( type!=TK_DEFERRED ){\n    for(i=0; i<db->nDb; i++){\n      sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);\n      sqlite3VdbeUsesBtree(v, i);\n    }\n  }\n  sqlite3VdbeAddOp0(v, OP_AutoCommit);\n}\n\n/*\n** Generate VDBE code for a COMMIT or ROLLBACK statement.\n** Code for ROLLBACK is generated if eType==TK_ROLLBACK.  Otherwise\n** code is generated for a COMMIT.\n*/\nvoid sqlite3EndTransaction(Parse *pParse, int eType){\n  Vdbe *v;\n  int isRollback;\n\n  assert( pParse!=0 );\n  assert( pParse->db!=0 );\n  assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );\n  isRollback = eType==TK_ROLLBACK;\n  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, \n       isRollback ? \"ROLLBACK\" : \"COMMIT\", 0, 0) ){\n    return;\n  }\n  v = sqlite3GetVdbe(pParse);\n  if( v ){\n    sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);\n  }\n}\n\n/*\n** This function is called by the parser when it parses a command to create,\n** release or rollback an SQL savepoint. \n*/\nvoid sqlite3Savepoint(Parse *pParse, int op, Token *pName){\n  char *zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName ){\n    Vdbe *v = sqlite3GetVdbe(pParse);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    static const char * const az[] = { \"BEGIN\", \"RELEASE\", \"ROLLBACK\" };\n    assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );\n#endif\n    if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){\n      sqlite3DbFree(pParse->db, zName);\n      return;\n    }\n    sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);\n  }\n}\n\n/*\n** Make sure the TEMP database is open and available for use.  Return\n** the number of errors.  Leave any error messages in the pParse structure.\n*/\nint sqlite3OpenTempDatabase(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt==0 && !pParse->explain ){\n    int rc;\n    Btree *pBt;\n    static const int flags = \n          SQLITE_OPEN_READWRITE |\n          SQLITE_OPEN_CREATE |\n          SQLITE_OPEN_EXCLUSIVE |\n          SQLITE_OPEN_DELETEONCLOSE |\n          SQLITE_OPEN_TEMP_DB;\n\n    rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"unable to open a temporary database \"\n        \"file for storing temporary tables\");\n      pParse->rc = rc;\n      return 1;\n    }\n    db->aDb[1].pBt = pBt;\n    assert( db->aDb[1].pSchema );\n    if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){\n      sqlite3OomFault(db);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Record the fact that the schema cookie will need to be verified\n** for database iDb.  The code to actually verify the schema cookie\n** will occur at the end of the top-level VDBE and will be generated\n** later, by sqlite3FinishCoding().\n*/\nvoid sqlite3CodeVerifySchema(Parse *pParse, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n\n  assert( iDb>=0 && iDb<pParse->db->nDb );\n  assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 );\n  assert( iDb<SQLITE_MAX_ATTACHED+2 );\n  assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) );\n  if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){\n    DbMaskSet(pToplevel->cookieMask, iDb);\n    if( !OMIT_TEMPDB && iDb==1 ){\n      sqlite3OpenTempDatabase(pToplevel);\n    }\n  }\n}\n\n/*\n** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each \n** attached database. Otherwise, invoke it for the database named zDb only.\n*/\nvoid sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){\n  sqlite3 *db = pParse->db;\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Db *pDb = &db->aDb[i];\n    if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zDbSName)) ){\n      sqlite3CodeVerifySchema(pParse, i);\n    }\n  }\n}\n\n/*\n** Generate VDBE code that prepares for doing an operation that\n** might change the database.\n**\n** This routine starts a new transaction if we are not already within\n** a transaction.  If we are already within a transaction, then a checkpoint\n** is set if the setStatement parameter is true.  A checkpoint should\n** be set for operations that might fail (due to a constraint) part of\n** the way through and which will need to undo some writes without having to\n** rollback the whole transaction.  For operations where all constraints\n** can be checked before any changes are made to the database, it is never\n** necessary to undo a write and the checkpoint should not be set.\n*/\nvoid sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  sqlite3CodeVerifySchema(pParse, iDb);\n  DbMaskSet(pToplevel->writeMask, iDb);\n  pToplevel->isMultiWrite |= setStatement;\n}\n\n/*\n** Indicate that the statement currently under construction might write\n** more than one entry (example: deleting one row then inserting another,\n** inserting multiple rows in a table, or inserting a row and index entries.)\n** If an abort occurs after some of these writes have completed, then it will\n** be necessary to undo the completed writes.\n*/\nvoid sqlite3MultiWrite(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->isMultiWrite = 1;\n}\n\n/* \n** The code generator calls this routine if is discovers that it is\n** possible to abort a statement prior to completion.  In order to \n** perform this abort without corrupting the database, we need to make\n** sure that the statement is protected by a statement transaction.\n**\n** Technically, we only need to set the mayAbort flag if the\n** isMultiWrite flag was previously set.  There is a time dependency\n** such that the abort must occur after the multiwrite.  This makes\n** some statements involving the REPLACE conflict resolution algorithm\n** go a little faster.  But taking advantage of this time dependency\n** makes it more difficult to prove that the code is correct (in \n** particular, it prevents us from writing an effective\n** implementation of sqlite3AssertMayAbort()) and so we have chosen\n** to take the safe route and skip the optimization.\n*/\nvoid sqlite3MayAbort(Parse *pParse){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  pToplevel->mayAbort = 1;\n}\n\n/*\n** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT\n** error. The onError parameter determines which (if any) of the statement\n** and/or current transaction is rolled back.\n*/\nvoid sqlite3HaltConstraint(\n  Parse *pParse,    /* Parsing context */\n  int errCode,      /* extended error code */\n  int onError,      /* Constraint type */\n  char *p4,         /* Error message */\n  i8 p4type,        /* P4_STATIC or P4_TRANSIENT */\n  u8 p5Errmsg       /* P5_ErrMsg type */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  assert( (errCode&0xff)==SQLITE_CONSTRAINT );\n  if( onError==OE_Abort ){\n    sqlite3MayAbort(pParse);\n  }\n  sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);\n  sqlite3VdbeChangeP5(v, p5Errmsg);\n}\n\n/*\n** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.\n*/\nvoid sqlite3UniqueConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Constraint type */\n  Index *pIdx       /* The index that triggers the constraint */\n){\n  char *zErr;\n  int j;\n  StrAccum errMsg;\n  Table *pTab = pIdx->pTable;\n\n  sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);\n  if( pIdx->aColExpr ){\n    sqlite3XPrintf(&errMsg, \"index '%q'\", pIdx->zName);\n  }else{\n    for(j=0; j<pIdx->nKeyCol; j++){\n      char *zCol;\n      assert( pIdx->aiColumn[j]>=0 );\n      zCol = pTab->aCol[pIdx->aiColumn[j]].zName;\n      if( j ) sqlite3StrAccumAppend(&errMsg, \", \", 2);\n      sqlite3StrAccumAppendAll(&errMsg, pTab->zName);\n      sqlite3StrAccumAppend(&errMsg, \".\", 1);\n      sqlite3StrAccumAppendAll(&errMsg, zCol);\n    }\n  }\n  zErr = sqlite3StrAccumFinish(&errMsg);\n  sqlite3HaltConstraint(pParse, \n    IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY \n                            : SQLITE_CONSTRAINT_UNIQUE,\n    onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);\n}\n\n\n/*\n** Code an OP_Halt due to non-unique rowid.\n*/\nvoid sqlite3RowidConstraint(\n  Parse *pParse,    /* Parsing context */\n  int onError,      /* Conflict resolution algorithm */\n  Table *pTab       /* The table with the non-unique rowid */ \n){\n  char *zMsg;\n  int rc;\n  if( pTab->iPKey>=0 ){\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.%s\", pTab->zName,\n                          pTab->aCol[pTab->iPKey].zName);\n    rc = SQLITE_CONSTRAINT_PRIMARYKEY;\n  }else{\n    zMsg = sqlite3MPrintf(pParse->db, \"%s.rowid\", pTab->zName);\n    rc = SQLITE_CONSTRAINT_ROWID;\n  }\n  sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,\n                        P5_ConstraintUnique);\n}\n\n/*\n** Check to see if pIndex uses the collating sequence pColl.  Return\n** true if it does and false if it does not.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic int collationMatch(const char *zColl, Index *pIndex){\n  int i;\n  assert( zColl!=0 );\n  for(i=0; i<pIndex->nColumn; i++){\n    const char *z = pIndex->azColl[i];\n    assert( z!=0 || pIndex->aiColumn[i]<0 );\n    if( pIndex->aiColumn[i]>=0 && 0==sqlite3StrICmp(z, zColl) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n#endif\n\n/*\n** Recompute all indices of pTab that use the collating sequence pColl.\n** If pColl==0 then recompute all indices of pTab.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexTable(Parse *pParse, Table *pTab, char const *zColl){\n  Index *pIndex;              /* An index associated with pTab */\n\n  for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n    if( zColl==0 || collationMatch(zColl, pIndex) ){\n      int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3RefillIndex(pParse, pIndex, -1);\n    }\n  }\n}\n#endif\n\n/*\n** Recompute all indices of all tables in all databases where the\n** indices use the collating sequence pColl.  If pColl==0 then recompute\n** all indices everywhere.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nstatic void reindexDatabases(Parse *pParse, char const *zColl){\n  Db *pDb;                    /* A single database */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  HashElem *k;                /* For looping over tables in pDb */\n  Table *pTab;                /* A table in the database */\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );  /* Needed for schema access */\n  for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){\n    assert( pDb!=0 );\n    for(k=sqliteHashFirst(&pDb->pSchema->tblHash);  k; k=sqliteHashNext(k)){\n      pTab = (Table*)sqliteHashData(k);\n      reindexTable(pParse, pTab, zColl);\n    }\n  }\n}\n#endif\n\n/*\n** Generate code for the REINDEX command.\n**\n**        REINDEX                            -- 1\n**        REINDEX  <collation>               -- 2\n**        REINDEX  ?<database>.?<tablename>  -- 3\n**        REINDEX  ?<database>.?<indexname>  -- 4\n**\n** Form 1 causes all indices in all attached databases to be rebuilt.\n** Form 2 rebuilds all indices in all databases that use the named\n** collating function.  Forms 3 and 4 rebuild the named index or all\n** indices associated with the named table.\n*/\n#ifndef SQLITE_OMIT_REINDEX\nvoid sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){\n  CollSeq *pColl;             /* Collating sequence to be reindexed, or NULL */\n  char *z;                    /* Name of a table or index */\n  const char *zDb;            /* Name of the database */\n  Table *pTab;                /* A table in the database */\n  Index *pIndex;              /* An index associated with pTab */\n  int iDb;                    /* The database index number */\n  sqlite3 *db = pParse->db;   /* The database connection */\n  Token *pObjName;            /* Name of the table or index to be reindexed */\n\n  /* Read the database schema. If an error occurs, leave an error message\n  ** and code in pParse and return NULL. */\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    return;\n  }\n\n  if( pName1==0 ){\n    reindexDatabases(pParse, 0);\n    return;\n  }else if( NEVER(pName2==0) || pName2->z==0 ){\n    char *zColl;\n    assert( pName1->z );\n    zColl = sqlite3NameFromToken(pParse->db, pName1);\n    if( !zColl ) return;\n    pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n    if( pColl ){\n      reindexDatabases(pParse, zColl);\n      sqlite3DbFree(db, zColl);\n      return;\n    }\n    sqlite3DbFree(db, zColl);\n  }\n  iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);\n  if( iDb<0 ) return;\n  z = sqlite3NameFromToken(db, pObjName);\n  if( z==0 ) return;\n  zDb = db->aDb[iDb].zDbSName;\n  pTab = sqlite3FindTable(db, z, zDb);\n  if( pTab ){\n    reindexTable(pParse, pTab, 0);\n    sqlite3DbFree(db, z);\n    return;\n  }\n  pIndex = sqlite3FindIndex(db, z, zDb);\n  sqlite3DbFree(db, z);\n  if( pIndex ){\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3RefillIndex(pParse, pIndex, -1);\n    return;\n  }\n  sqlite3ErrorMsg(pParse, \"unable to identify the object to be reindexed\");\n}\n#endif\n\n/*\n** Return a KeyInfo structure that is appropriate for the given Index.\n**\n** The caller should invoke sqlite3KeyInfoUnref() on the returned object\n** when it has finished using it.\n*/\nKeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){\n  int i;\n  int nCol = pIdx->nColumn;\n  int nKey = pIdx->nKeyCol;\n  KeyInfo *pKey;\n  if( pParse->nErr ) return 0;\n  if( pIdx->uniqNotNull ){\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);\n  }else{\n    pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);\n  }\n  if( pKey ){\n    assert( sqlite3KeyInfoIsWriteable(pKey) );\n    for(i=0; i<nCol; i++){\n      const char *zColl = pIdx->azColl[i];\n      pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :\n                        sqlite3LocateCollSeq(pParse, zColl);\n      pKey->aSortOrder[i] = pIdx->aSortOrder[i];\n    }\n    if( pParse->nErr ){\n      sqlite3KeyInfoUnref(pKey);\n      pKey = 0;\n    }\n  }\n  return pKey;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/* \n** This routine is invoked once per CTE by the parser while parsing a \n** WITH clause. \n*/\nWith *sqlite3WithAdd(\n  Parse *pParse,          /* Parsing context */\n  With *pWith,            /* Existing WITH clause, or NULL */\n  Token *pName,           /* Name of the common-table */\n  ExprList *pArglist,     /* Optional column name list for the table */\n  Select *pQuery          /* Query used to initialize the table */\n){\n  sqlite3 *db = pParse->db;\n  With *pNew;\n  char *zName;\n\n  /* Check that the CTE name is unique within this WITH clause. If\n  ** not, store an error in the Parse structure. */\n  zName = sqlite3NameFromToken(pParse->db, pName);\n  if( zName && pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      if( sqlite3StrICmp(zName, pWith->a[i].zName)==0 ){\n        sqlite3ErrorMsg(pParse, \"duplicate WITH table name: %s\", zName);\n      }\n    }\n  }\n\n  if( pWith ){\n    int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte);\n    pNew = sqlite3DbRealloc(db, pWith, nByte);\n  }else{\n    pNew = sqlite3DbMallocZero(db, sizeof(*pWith));\n  }\n  assert( (pNew!=0 && zName!=0) || db->mallocFailed );\n\n  if( db->mallocFailed ){\n    sqlite3ExprListDelete(db, pArglist);\n    sqlite3SelectDelete(db, pQuery);\n    sqlite3DbFree(db, zName);\n    pNew = pWith;\n  }else{\n    pNew->a[pNew->nCte].pSelect = pQuery;\n    pNew->a[pNew->nCte].pCols = pArglist;\n    pNew->a[pNew->nCte].zName = zName;\n    pNew->a[pNew->nCte].zCteErr = 0;\n    pNew->nCte++;\n  }\n\n  return pNew;\n}\n\n/*\n** Free the contents of the With object passed as the second argument.\n*/\nvoid sqlite3WithDelete(sqlite3 *db, With *pWith){\n  if( pWith ){\n    int i;\n    for(i=0; i<pWith->nCte; i++){\n      struct Cte *pCte = &pWith->a[i];\n      sqlite3ExprListDelete(db, pCte->pCols);\n      sqlite3SelectDelete(db, pCte->pSelect);\n      sqlite3DbFree(db, pCte->zName);\n    }\n    sqlite3DbFree(db, pWith);\n  }\n}\n#endif /* !defined(SQLITE_OMIT_CTE) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/callback.c",
    "content": "/*\n** 2005 May 23 \n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains functions used to access the internal hash tables\n** of user defined functions and collation sequences.\n*/\n\n#include \"sqliteInt.h\"\n\n/*\n** Invoke the 'collation needed' callback to request a collation sequence\n** in the encoding enc of name zName, length nName.\n*/\nstatic void callCollNeeded(sqlite3 *db, int enc, const char *zName){\n  assert( !db->xCollNeeded || !db->xCollNeeded16 );\n  if( db->xCollNeeded ){\n    char *zExternal = sqlite3DbStrDup(db, zName);\n    if( !zExternal ) return;\n    db->xCollNeeded(db->pCollNeededArg, db, enc, zExternal);\n    sqlite3DbFree(db, zExternal);\n  }\n#ifndef SQLITE_OMIT_UTF16\n  if( db->xCollNeeded16 ){\n    char const *zExternal;\n    sqlite3_value *pTmp = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);\n    zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);\n    if( zExternal ){\n      db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);\n    }\n    sqlite3ValueFree(pTmp);\n  }\n#endif\n}\n\n/*\n** This routine is called if the collation factory fails to deliver a\n** collation function in the best encoding but there may be other versions\n** of this collation function (for other text encodings) available. Use one\n** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if\n** possible.\n*/\nstatic int synthCollSeq(sqlite3 *db, CollSeq *pColl){\n  CollSeq *pColl2;\n  char *z = pColl->zName;\n  int i;\n  static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };\n  for(i=0; i<3; i++){\n    pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, 0);\n    if( pColl2->xCmp!=0 ){\n      memcpy(pColl, pColl2, sizeof(CollSeq));\n      pColl->xDel = 0;         /* Do not copy the destructor */\n      return SQLITE_OK;\n    }\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** This function is responsible for invoking the collation factory callback\n** or substituting a collation sequence of a different encoding when the\n** requested collation sequence is not available in the desired encoding.\n** \n** If it is not NULL, then pColl must point to the database native encoding \n** collation sequence with name zName, length nName.\n**\n** The return value is either the collation sequence to be used in database\n** db for collation type name zName, length nName, or NULL, if no collation\n** sequence can be found.  If no collation is found, leave an error message.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()\n*/\nCollSeq *sqlite3GetCollSeq(\n  Parse *pParse,        /* Parsing context */\n  u8 enc,               /* The desired encoding for the collating sequence */\n  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */\n  const char *zName     /* Collating sequence name */\n){\n  CollSeq *p;\n  sqlite3 *db = pParse->db;\n\n  p = pColl;\n  if( !p ){\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( !p || !p->xCmp ){\n    /* No collation sequence of this type for this encoding is registered.\n    ** Call the collation factory to see if it can supply us with one.\n    */\n    callCollNeeded(db, enc, zName);\n    p = sqlite3FindCollSeq(db, enc, zName, 0);\n  }\n  if( p && !p->xCmp && synthCollSeq(db, p) ){\n    p = 0;\n  }\n  assert( !p || p->xCmp );\n  if( p==0 ){\n    sqlite3ErrorMsg(pParse, \"no such collation sequence: %s\", zName);\n  }\n  return p;\n}\n\n/*\n** This routine is called on a collation sequence before it is used to\n** check that it is defined. An undefined collation sequence exists when\n** a database is loaded that contains references to collation sequences\n** that have not been defined by sqlite3_create_collation() etc.\n**\n** If required, this routine calls the 'collation needed' callback to\n** request a definition of the collating sequence. If this doesn't work, \n** an equivalent collating sequence that uses a text encoding different\n** from the main database is substituted, if one is available.\n*/\nint sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){\n  if( pColl && pColl->xCmp==0 ){\n    const char *zName = pColl->zName;\n    sqlite3 *db = pParse->db;\n    CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);\n    if( !p ){\n      return SQLITE_ERROR;\n    }\n    assert( p==pColl );\n  }\n  return SQLITE_OK;\n}\n\n\n\n/*\n** Locate and return an entry from the db.aCollSeq hash table. If the entry\n** specified by zName and nName is not found and parameter 'create' is\n** true, then create a new entry. Otherwise return NULL.\n**\n** Each pointer stored in the sqlite3.aCollSeq hash table contains an\n** array of three CollSeq structures. The first is the collation sequence\n** preferred for UTF-8, the second UTF-16le, and the third UTF-16be.\n**\n** Stored immediately after the three collation sequences is a copy of\n** the collation sequence name. A pointer to this string is stored in\n** each collation sequence structure.\n*/\nstatic CollSeq *findCollSeqEntry(\n  sqlite3 *db,          /* Database connection */\n  const char *zName,    /* Name of the collating sequence */\n  int create            /* Create a new entry if true */\n){\n  CollSeq *pColl;\n  pColl = sqlite3HashFind(&db->aCollSeq, zName);\n\n  if( 0==pColl && create ){\n    int nName = sqlite3Strlen30(zName) + 1;\n    pColl = sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName);\n    if( pColl ){\n      CollSeq *pDel = 0;\n      pColl[0].zName = (char*)&pColl[3];\n      pColl[0].enc = SQLITE_UTF8;\n      pColl[1].zName = (char*)&pColl[3];\n      pColl[1].enc = SQLITE_UTF16LE;\n      pColl[2].zName = (char*)&pColl[3];\n      pColl[2].enc = SQLITE_UTF16BE;\n      memcpy(pColl[0].zName, zName, nName);\n      pDel = sqlite3HashInsert(&db->aCollSeq, pColl[0].zName, pColl);\n\n      /* If a malloc() failure occurred in sqlite3HashInsert(), it will \n      ** return the pColl pointer to be deleted (because it wasn't added\n      ** to the hash table).\n      */\n      assert( pDel==0 || pDel==pColl );\n      if( pDel!=0 ){\n        sqlite3OomFault(db);\n        sqlite3DbFree(db, pDel);\n        pColl = 0;\n      }\n    }\n  }\n  return pColl;\n}\n\n/*\n** Parameter zName points to a UTF-8 encoded string nName bytes long.\n** Return the CollSeq* pointer for the collation sequence named zName\n** for the encoding 'enc' from the database 'db'.\n**\n** If the entry specified is not found and 'create' is true, then create a\n** new entry.  Otherwise return NULL.\n**\n** A separate function sqlite3LocateCollSeq() is a wrapper around\n** this routine.  sqlite3LocateCollSeq() invokes the collation factory\n** if necessary and generates an error message if the collating sequence\n** cannot be found.\n**\n** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()\n*/\nCollSeq *sqlite3FindCollSeq(\n  sqlite3 *db,\n  u8 enc,\n  const char *zName,\n  int create\n){\n  CollSeq *pColl;\n  if( zName ){\n    pColl = findCollSeqEntry(db, zName, create);\n  }else{\n    pColl = db->pDfltColl;\n  }\n  assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n  assert( enc>=SQLITE_UTF8 && enc<=SQLITE_UTF16BE );\n  if( pColl ) pColl += enc-1;\n  return pColl;\n}\n\n/* During the search for the best function definition, this procedure\n** is called to test how well the function passed as the first argument\n** matches the request for a function with nArg arguments in a system\n** that uses encoding enc. The value returned indicates how well the\n** request is matched. A higher value indicates a better match.\n**\n** If nArg is -1 that means to only return a match (non-zero) if p->nArg\n** is also -1.  In other words, we are searching for a function that\n** takes a variable number of arguments.\n**\n** If nArg is -2 that means that we are searching for any function \n** regardless of the number of arguments it uses, so return a positive\n** match score for any\n**\n** The returned value is always between 0 and 6, as follows:\n**\n** 0: Not a match.\n** 1: UTF8/16 conversion required and function takes any number of arguments.\n** 2: UTF16 byte order change required and function takes any number of args.\n** 3: encoding matches and function takes any number of arguments\n** 4: UTF8/16 conversion required - argument count matches exactly\n** 5: UTF16 byte order conversion required - argument count matches exactly\n** 6: Perfect match:  encoding and argument count match exactly.\n**\n** If nArg==(-2) then any function with a non-null xSFunc is\n** a perfect match and any function with xSFunc NULL is\n** a non-match.\n*/\n#define FUNC_PERFECT_MATCH 6  /* The score for a perfect match */\nstatic int matchQuality(\n  FuncDef *p,     /* The function we are evaluating for match quality */\n  int nArg,       /* Desired number of arguments.  (-1)==any */\n  u8 enc          /* Desired text encoding */\n){\n  int match;\n\n  /* nArg of -2 is a special case */\n  if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;\n\n  /* Wrong number of arguments means \"no match\" */\n  if( p->nArg!=nArg && p->nArg>=0 ) return 0;\n\n  /* Give a better score to a function with a specific number of arguments\n  ** than to function that accepts any number of arguments. */\n  if( p->nArg==nArg ){\n    match = 4;\n  }else{\n    match = 1;\n  }\n\n  /* Bonus points if the text encoding matches */\n  if( enc==(p->funcFlags & SQLITE_FUNC_ENCMASK) ){\n    match += 2;  /* Exact encoding match */\n  }else if( (enc & p->funcFlags & 2)!=0 ){\n    match += 1;  /* Both are UTF16, but with different byte orders */\n  }\n\n  return match;\n}\n\n/*\n** Search a FuncDefHash for a function with the given name.  Return\n** a pointer to the matching FuncDef if found, or 0 if there is no match.\n*/\nstatic FuncDef *functionSearch(\n  int h,               /* Hash of the name */\n  const char *zFunc    /* Name of function */\n){\n  FuncDef *p;\n  for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){\n    if( sqlite3StrICmp(p->zName, zFunc)==0 ){\n      return p;\n    }\n  }\n  return 0;\n}\n\n/*\n** Insert a new FuncDef into a FuncDefHash hash table.\n*/\nvoid sqlite3InsertBuiltinFuncs(\n  FuncDef *aDef,      /* List of global functions to be inserted */\n  int nDef            /* Length of the apDef[] list */\n){\n  int i;\n  for(i=0; i<nDef; i++){\n    FuncDef *pOther;\n    const char *zName = aDef[i].zName;\n    int nName = sqlite3Strlen30(zName);\n    int h = (zName[0] + nName) % SQLITE_FUNC_HASH_SZ;\n    assert( zName[0]>='a' && zName[0]<='z' );\n    pOther = functionSearch(h, zName);\n    if( pOther ){\n      assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );\n      aDef[i].pNext = pOther->pNext;\n      pOther->pNext = &aDef[i];\n    }else{\n      aDef[i].pNext = 0;\n      aDef[i].u.pHash = sqlite3BuiltinFunctions.a[h];\n      sqlite3BuiltinFunctions.a[h] = &aDef[i];\n    }\n  }\n}\n  \n  \n\n/*\n** Locate a user function given a name, a number of arguments and a flag\n** indicating whether the function prefers UTF-16 over UTF-8.  Return a\n** pointer to the FuncDef structure that defines that function, or return\n** NULL if the function does not exist.\n**\n** If the createFlag argument is true, then a new (blank) FuncDef\n** structure is created and liked into the \"db\" structure if a\n** no matching function previously existed.\n**\n** If nArg is -2, then the first valid function found is returned.  A\n** function is valid if xSFunc is non-zero.  The nArg==(-2)\n** case is used to see if zName is a valid function name for some number\n** of arguments.  If nArg is -2, then createFlag must be 0.\n**\n** If createFlag is false, then a function with the required name and\n** number of arguments may be returned even if the eTextRep flag does not\n** match that requested.\n*/\nFuncDef *sqlite3FindFunction(\n  sqlite3 *db,       /* An open database */\n  const char *zName, /* Name of the function.  zero-terminated */\n  int nArg,          /* Number of arguments.  -1 means any number */\n  u8 enc,            /* Preferred text encoding */\n  u8 createFlag      /* Create new entry if true and does not otherwise exist */\n){\n  FuncDef *p;         /* Iterator variable */\n  FuncDef *pBest = 0; /* Best match found so far */\n  int bestScore = 0;  /* Score of best match */\n  int h;              /* Hash value */\n  int nName;          /* Length of the name */\n\n  assert( nArg>=(-2) );\n  assert( nArg>=(-1) || createFlag==0 );\n  nName = sqlite3Strlen30(zName);\n\n  /* First search for a match amongst the application-defined functions.\n  */\n  p = (FuncDef*)sqlite3HashFind(&db->aFunc, zName);\n  while( p ){\n    int score = matchQuality(p, nArg, enc);\n    if( score>bestScore ){\n      pBest = p;\n      bestScore = score;\n    }\n    p = p->pNext;\n  }\n\n  /* If no match is found, search the built-in functions.\n  **\n  ** If the DBFLAG_PreferBuiltin flag is set, then search the built-in\n  ** functions even if a prior app-defined function was found.  And give\n  ** priority to built-in functions.\n  **\n  ** Except, if createFlag is true, that means that we are trying to\n  ** install a new function.  Whatever FuncDef structure is returned it will\n  ** have fields overwritten with new information appropriate for the\n  ** new function.  But the FuncDefs for built-in functions are read-only.\n  ** So we must not search for built-ins when creating a new function.\n  */ \n  if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){\n    bestScore = 0;\n    h = (sqlite3UpperToLower[(u8)zName[0]] + nName) % SQLITE_FUNC_HASH_SZ;\n    p = functionSearch(h, zName);\n    while( p ){\n      int score = matchQuality(p, nArg, enc);\n      if( score>bestScore ){\n        pBest = p;\n        bestScore = score;\n      }\n      p = p->pNext;\n    }\n  }\n\n  /* If the createFlag parameter is true and the search did not reveal an\n  ** exact match for the name, number of arguments and encoding, then add a\n  ** new entry to the hash table and return it.\n  */\n  if( createFlag && bestScore<FUNC_PERFECT_MATCH && \n      (pBest = sqlite3DbMallocZero(db, sizeof(*pBest)+nName+1))!=0 ){\n    FuncDef *pOther;\n    pBest->zName = (const char*)&pBest[1];\n    pBest->nArg = (u16)nArg;\n    pBest->funcFlags = enc;\n    memcpy((char*)&pBest[1], zName, nName+1);\n    pOther = (FuncDef*)sqlite3HashInsert(&db->aFunc, pBest->zName, pBest);\n    if( pOther==pBest ){\n      sqlite3DbFree(db, pBest);\n      sqlite3OomFault(db);\n      return 0;\n    }else{\n      pBest->pNext = pOther;\n    }\n  }\n\n  if( pBest && (pBest->xSFunc || createFlag) ){\n    return pBest;\n  }\n  return 0;\n}\n\n/*\n** Free all resources held by the schema structure. The void* argument points\n** at a Schema struct. This function does not call sqlite3DbFree(db, ) on the \n** pointer itself, it just cleans up subsidiary resources (i.e. the contents\n** of the schema hash tables).\n**\n** The Schema.cache_size variable is not cleared.\n*/\nvoid sqlite3SchemaClear(void *p){\n  Hash temp1;\n  Hash temp2;\n  HashElem *pElem;\n  Schema *pSchema = (Schema *)p;\n\n  temp1 = pSchema->tblHash;\n  temp2 = pSchema->trigHash;\n  sqlite3HashInit(&pSchema->trigHash);\n  sqlite3HashClear(&pSchema->idxHash);\n  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){\n    sqlite3DeleteTrigger(0, (Trigger*)sqliteHashData(pElem));\n  }\n  sqlite3HashClear(&temp2);\n  sqlite3HashInit(&pSchema->tblHash);\n  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){\n    Table *pTab = sqliteHashData(pElem);\n    sqlite3DeleteTable(0, pTab);\n  }\n  sqlite3HashClear(&temp1);\n  sqlite3HashClear(&pSchema->fkeyHash);\n  pSchema->pSeqTab = 0;\n  if( pSchema->schemaFlags & DB_SchemaLoaded ){\n    pSchema->iGeneration++;\n  }\n  pSchema->schemaFlags &= ~(DB_SchemaLoaded|DB_ResetWanted);\n}\n\n/*\n** Find and return the schema associated with a BTree.  Create\n** a new one if necessary.\n*/\nSchema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){\n  Schema * p;\n  if( pBt ){\n    p = (Schema *)sqlite3BtreeSchema(pBt, sizeof(Schema), sqlite3SchemaClear);\n  }else{\n    p = (Schema *)sqlite3DbMallocZero(0, sizeof(Schema));\n  }\n  if( !p ){\n    sqlite3OomFault(db);\n  }else if ( 0==p->file_format ){\n    sqlite3HashInit(&p->tblHash);\n    sqlite3HashInit(&p->idxHash);\n    sqlite3HashInit(&p->trigHash);\n    sqlite3HashInit(&p->fkeyHash);\n    p->enc = SQLITE_UTF8;\n  }\n  return p;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/complete.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that implements the sqlite3_complete() API.\n** This code used to be part of the tokenizer.c source file.  But by\n** separating it out, the code will be automatically omitted from\n** static links that do not use it.\n*/\n#include \"sqliteInt.h\"\n#ifndef SQLITE_OMIT_COMPLETE\n\n/*\n** This is defined in tokenize.c.  We just have to import the definition.\n*/\n#ifndef SQLITE_AMALGAMATION\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nextern const char sqlite3IsEbcdicIdChar[];\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n#endif /* SQLITE_AMALGAMATION */\n\n\n/*\n** Token types used by the sqlite3_complete() routine.  See the header\n** comments on that procedure for additional information.\n*/\n#define tkSEMI    0\n#define tkWS      1\n#define tkOTHER   2\n#ifndef SQLITE_OMIT_TRIGGER\n#define tkEXPLAIN 3\n#define tkCREATE  4\n#define tkTEMP    5\n#define tkTRIGGER 6\n#define tkEND     7\n#endif\n\n/*\n** Return TRUE if the given SQL string ends in a semicolon.\n**\n** Special handling is require for CREATE TRIGGER statements.\n** Whenever the CREATE TRIGGER keywords are seen, the statement\n** must end with \";END;\".\n**\n** This implementation uses a state machine with 8 states:\n**\n**   (0) INVALID   We have not yet seen a non-whitespace character.\n**\n**   (1) START     At the beginning or end of an SQL statement.  This routine\n**                 returns 1 if it ends in the START state and 0 if it ends\n**                 in any other state.\n**\n**   (2) NORMAL    We are in the middle of statement which ends with a single\n**                 semicolon.\n**\n**   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of \n**                 a statement.\n**\n**   (4) CREATE    The keyword CREATE has been seen at the beginning of a\n**                 statement, possibly preceded by EXPLAIN and/or followed by\n**                 TEMP or TEMPORARY\n**\n**   (5) TRIGGER   We are in the middle of a trigger definition that must be\n**                 ended by a semicolon, the keyword END, and another semicolon.\n**\n**   (6) SEMI      We've seen the first semicolon in the \";END;\" that occurs at\n**                 the end of a trigger definition.\n**\n**   (7) END       We've seen the \";END\" of the \";END;\" that occurs at the end\n**                 of a trigger definition.\n**\n** Transitions between states above are determined by tokens extracted\n** from the input.  The following tokens are significant:\n**\n**   (0) tkSEMI      A semicolon.\n**   (1) tkWS        Whitespace.\n**   (2) tkOTHER     Any other SQL token.\n**   (3) tkEXPLAIN   The \"explain\" keyword.\n**   (4) tkCREATE    The \"create\" keyword.\n**   (5) tkTEMP      The \"temp\" or \"temporary\" keyword.\n**   (6) tkTRIGGER   The \"trigger\" keyword.\n**   (7) tkEND       The \"end\" keyword.\n**\n** Whitespace never causes a state transition and is always ignored.\n** This means that a SQL string of all whitespace is invalid.\n**\n** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed\n** to recognize the end of a trigger can be omitted.  All we have to do\n** is look for a semicolon that is not part of an string or comment.\n*/\nint sqlite3_complete(const char *zSql){\n  u8 state = 0;   /* Current state, using numbers defined in header comment */\n  u8 token;       /* Value of the next token */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  /* A complex statement machine used to detect the end of a CREATE TRIGGER\n  ** statement.  This is the normal case.\n  */\n  static const u8 trans[8][8] = {\n                     /* Token:                                                */\n     /* State:       **  SEMI  WS  OTHER  EXPLAIN  CREATE  TEMP  TRIGGER  END */\n     /* 0 INVALID: */ {    1,  0,     2,       3,      4,    2,       2,   2, },\n     /* 1   START: */ {    1,  1,     2,       3,      4,    2,       2,   2, },\n     /* 2  NORMAL: */ {    1,  2,     2,       2,      2,    2,       2,   2, },\n     /* 3 EXPLAIN: */ {    1,  3,     3,       2,      4,    2,       2,   2, },\n     /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },\n     /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },\n     /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },\n     /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },\n  };\n#else\n  /* If triggers are not supported by this compile then the statement machine\n  ** used to detect the end of a statement is much simpler\n  */\n  static const u8 trans[3][3] = {\n                     /* Token:           */\n     /* State:       **  SEMI  WS  OTHER */\n     /* 0 INVALID: */ {    1,  0,     2, },\n     /* 1   START: */ {    1,  1,     2, },\n     /* 2  NORMAL: */ {    1,  2,     2, },\n  };\n#endif /* SQLITE_OMIT_TRIGGER */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zSql==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  while( *zSql ){\n    switch( *zSql ){\n      case ';': {  /* A semicolon */\n        token = tkSEMI;\n        break;\n      }\n      case ' ':\n      case '\\r':\n      case '\\t':\n      case '\\n':\n      case '\\f': {  /* White space is ignored */\n        token = tkWS;\n        break;\n      }\n      case '/': {   /* C-style comments */\n        if( zSql[1]!='*' ){\n          token = tkOTHER;\n          break;\n        }\n        zSql += 2;\n        while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }\n        if( zSql[0]==0 ) return 0;\n        zSql++;\n        token = tkWS;\n        break;\n      }\n      case '-': {   /* SQL-style comments from \"--\" to end of line */\n        if( zSql[1]!='-' ){\n          token = tkOTHER;\n          break;\n        }\n        while( *zSql && *zSql!='\\n' ){ zSql++; }\n        if( *zSql==0 ) return state==1;\n        token = tkWS;\n        break;\n      }\n      case '[': {   /* Microsoft-style identifiers in [...] */\n        zSql++;\n        while( *zSql && *zSql!=']' ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      case '`':     /* Grave-accent quoted symbols used by MySQL */\n      case '\"':     /* single- and double-quoted strings */\n      case '\\'': {\n        int c = *zSql;\n        zSql++;\n        while( *zSql && *zSql!=c ){ zSql++; }\n        if( *zSql==0 ) return 0;\n        token = tkOTHER;\n        break;\n      }\n      default: {\n#ifdef SQLITE_EBCDIC\n        unsigned char c;\n#endif\n        if( IdChar((u8)*zSql) ){\n          /* Keywords and unquoted identifiers */\n          int nId;\n          for(nId=1; IdChar(zSql[nId]); nId++){}\n#ifdef SQLITE_OMIT_TRIGGER\n          token = tkOTHER;\n#else\n          switch( *zSql ){\n            case 'c': case 'C': {\n              if( nId==6 && sqlite3StrNICmp(zSql, \"create\", 6)==0 ){\n                token = tkCREATE;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 't': case 'T': {\n              if( nId==7 && sqlite3StrNICmp(zSql, \"trigger\", 7)==0 ){\n                token = tkTRIGGER;\n              }else if( nId==4 && sqlite3StrNICmp(zSql, \"temp\", 4)==0 ){\n                token = tkTEMP;\n              }else if( nId==9 && sqlite3StrNICmp(zSql, \"temporary\", 9)==0 ){\n                token = tkTEMP;\n              }else{\n                token = tkOTHER;\n              }\n              break;\n            }\n            case 'e':  case 'E': {\n              if( nId==3 && sqlite3StrNICmp(zSql, \"end\", 3)==0 ){\n                token = tkEND;\n              }else\n#ifndef SQLITE_OMIT_EXPLAIN\n              if( nId==7 && sqlite3StrNICmp(zSql, \"explain\", 7)==0 ){\n                token = tkEXPLAIN;\n              }else\n#endif\n              {\n                token = tkOTHER;\n              }\n              break;\n            }\n            default: {\n              token = tkOTHER;\n              break;\n            }\n          }\n#endif /* SQLITE_OMIT_TRIGGER */\n          zSql += nId-1;\n        }else{\n          /* Operators and special symbols */\n          token = tkOTHER;\n        }\n        break;\n      }\n    }\n    state = trans[state][token];\n    zSql++;\n  }\n  return state==1;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine is the same as the sqlite3_complete() routine described\n** above, except that the parameter is required to be UTF-16 encoded, not\n** UTF-8.\n*/\nint sqlite3_complete16(const void *zSql){\n  sqlite3_value *pVal;\n  char const *zSql8;\n  int rc;\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zSql8 ){\n    rc = sqlite3_complete(zSql8);\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_COMPLETE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/ctime.c",
    "content": "/*\n** 2010 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements routines used to report what compile-time options\n** SQLite was built with.\n*/\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n#include \"config.h\"\n#define SQLITECONFIG_H 1\n#endif\n\n/* These macros are provided to \"stringify\" the value of the define\n** for those options in which the value is meaningful. */\n#define CTIMEOPT_VAL_(opt) #opt\n#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)\n\n/*\n** An array of names of all compile-time options.  This array should \n** be sorted A-Z.\n**\n** This array looks large, but in a typical installation actually uses\n** only a handful of compile-time options, so most times this array is usually\n** rather short and uses little memory space.\n*/\nstatic const char * const sqlite3azCompileOpt[] = {\n\n/* \n** BEGIN CODE GENERATED BY tool/mkctime.tcl \n*/\n#if SQLITE_32BIT_ROWID\n  \"32BIT_ROWID\",\n#endif\n#if SQLITE_4_BYTE_ALIGNED_MALLOC\n  \"4_BYTE_ALIGNED_MALLOC\",\n#endif\n#if SQLITE_64BIT_STATS\n  \"64BIT_STATS\",\n#endif\n#if SQLITE_ALLOW_COVERING_INDEX_SCAN\n  \"ALLOW_COVERING_INDEX_SCAN\",\n#endif\n#if SQLITE_ALLOW_URI_AUTHORITY\n  \"ALLOW_URI_AUTHORITY\",\n#endif\n#ifdef SQLITE_BITMASK_TYPE\n  \"BITMASK_TYPE=\" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),\n#endif\n#if SQLITE_BUG_COMPATIBLE_20160819\n  \"BUG_COMPATIBLE_20160819\",\n#endif\n#if SQLITE_CASE_SENSITIVE_LIKE\n  \"CASE_SENSITIVE_LIKE\",\n#endif\n#if SQLITE_CHECK_PAGES\n  \"CHECK_PAGES\",\n#endif\n#if defined(__clang__) && defined(__clang_major__)\n  \"COMPILER=clang-\" CTIMEOPT_VAL(__clang_major__) \".\"\n                    CTIMEOPT_VAL(__clang_minor__) \".\"\n                    CTIMEOPT_VAL(__clang_patchlevel__),\n#elif defined(_MSC_VER)\n  \"COMPILER=msvc-\" CTIMEOPT_VAL(_MSC_VER),\n#elif defined(__GNUC__) && defined(__VERSION__)\n  \"COMPILER=gcc-\" __VERSION__,\n#endif\n#if SQLITE_COVERAGE_TEST\n  \"COVERAGE_TEST\",\n#endif\n#if SQLITE_DEBUG\n  \"DEBUG\",\n#endif\n#if SQLITE_DEFAULT_AUTOMATIC_INDEX\n  \"DEFAULT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_DEFAULT_AUTOVACUUM\n  \"DEFAULT_AUTOVACUUM\",\n#endif\n#ifdef SQLITE_DEFAULT_CACHE_SIZE\n  \"DEFAULT_CACHE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n  \"DEFAULT_CKPTFULLFSYNC\",\n#endif\n#ifdef SQLITE_DEFAULT_FILE_FORMAT\n  \"DEFAULT_FILE_FORMAT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),\n#endif\n#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS\n  \"DEFAULT_FILE_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_FOREIGN_KEYS\n  \"DEFAULT_FOREIGN_KEYS\",\n#endif\n#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  \"DEFAULT_JOURNAL_SIZE_LIMIT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),\n#endif\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  \"DEFAULT_LOCKING_MODE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),\n#endif\n#ifdef SQLITE_DEFAULT_LOOKASIDE\n  \"DEFAULT_LOOKASIDE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_LOOKASIDE),\n#endif\n#if SQLITE_DEFAULT_MEMSTATUS\n  \"DEFAULT_MEMSTATUS\",\n#endif\n#ifdef SQLITE_DEFAULT_MMAP_SIZE\n  \"DEFAULT_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PAGE_SIZE\n  \"DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_PCACHE_INITSZ\n  \"DEFAULT_PCACHE_INITSZ=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),\n#endif\n#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n  \"DEFAULT_PROXYDIR_PERMISSIONS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n  \"DEFAULT_RECURSIVE_TRIGGERS\",\n#endif\n#ifdef SQLITE_DEFAULT_ROWEST\n  \"DEFAULT_ROWEST=\" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),\n#endif\n#ifdef SQLITE_DEFAULT_SECTOR_SIZE\n  \"DEFAULT_SECTOR_SIZE=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),\n#endif\n#ifdef SQLITE_DEFAULT_SYNCHRONOUS\n  \"DEFAULT_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n  \"DEFAULT_WAL_AUTOCHECKPOINT=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),\n#endif\n#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n  \"DEFAULT_WAL_SYNCHRONOUS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),\n#endif\n#ifdef SQLITE_DEFAULT_WORKER_THREADS\n  \"DEFAULT_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),\n#endif\n#if SQLITE_DIRECT_OVERFLOW_READ\n  \"DIRECT_OVERFLOW_READ\",\n#endif\n#if SQLITE_DISABLE_DIRSYNC\n  \"DISABLE_DIRSYNC\",\n#endif\n#if SQLITE_DISABLE_FTS3_UNICODE\n  \"DISABLE_FTS3_UNICODE\",\n#endif\n#if SQLITE_DISABLE_FTS4_DEFERRED\n  \"DISABLE_FTS4_DEFERRED\",\n#endif\n#if SQLITE_DISABLE_INTRINSIC\n  \"DISABLE_INTRINSIC\",\n#endif\n#if SQLITE_DISABLE_LFS\n  \"DISABLE_LFS\",\n#endif\n#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n  \"DISABLE_PAGECACHE_OVERFLOW_STATS\",\n#endif\n#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n  \"DISABLE_SKIPAHEAD_DISTINCT\",\n#endif\n#ifdef SQLITE_ENABLE_8_3_NAMES\n  \"ENABLE_8_3_NAMES=\" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),\n#endif\n#if SQLITE_ENABLE_API_ARMOR\n  \"ENABLE_API_ARMOR\",\n#endif\n#if SQLITE_ENABLE_ATOMIC_WRITE\n  \"ENABLE_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  \"ENABLE_BATCH_ATOMIC_WRITE\",\n#endif\n#if SQLITE_ENABLE_CEROD\n  \"ENABLE_CEROD\",\n#endif\n#if SQLITE_ENABLE_COLUMN_METADATA\n  \"ENABLE_COLUMN_METADATA\",\n#endif\n#if SQLITE_ENABLE_COLUMN_USED_MASK\n  \"ENABLE_COLUMN_USED_MASK\",\n#endif\n#if SQLITE_ENABLE_COSTMULT\n  \"ENABLE_COSTMULT\",\n#endif\n#if SQLITE_ENABLE_CURSOR_HINTS\n  \"ENABLE_CURSOR_HINTS\",\n#endif\n#if SQLITE_ENABLE_DBSTAT_VTAB\n  \"ENABLE_DBSTAT_VTAB\",\n#endif\n#if SQLITE_ENABLE_EXPENSIVE_ASSERT\n  \"ENABLE_EXPENSIVE_ASSERT\",\n#endif\n#if SQLITE_ENABLE_FTS1\n  \"ENABLE_FTS1\",\n#endif\n#if SQLITE_ENABLE_FTS2\n  \"ENABLE_FTS2\",\n#endif\n#if SQLITE_ENABLE_FTS3\n  \"ENABLE_FTS3\",\n#endif\n#if SQLITE_ENABLE_FTS3_PARENTHESIS\n  \"ENABLE_FTS3_PARENTHESIS\",\n#endif\n#if SQLITE_ENABLE_FTS3_TOKENIZER\n  \"ENABLE_FTS3_TOKENIZER\",\n#endif\n#if SQLITE_ENABLE_FTS4\n  \"ENABLE_FTS4\",\n#endif\n#if SQLITE_ENABLE_FTS5\n  \"ENABLE_FTS5\",\n#endif\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\n  \"ENABLE_HIDDEN_COLUMNS\",\n#endif\n#if SQLITE_ENABLE_ICU\n  \"ENABLE_ICU\",\n#endif\n#if SQLITE_ENABLE_IOTRACE\n  \"ENABLE_IOTRACE\",\n#endif\n#if SQLITE_ENABLE_JSON1\n  \"ENABLE_JSON1\",\n#endif\n#if SQLITE_ENABLE_LOAD_EXTENSION\n  \"ENABLE_LOAD_EXTENSION\",\n#endif\n#ifdef SQLITE_ENABLE_LOCKING_STYLE\n  \"ENABLE_LOCKING_STYLE=\" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),\n#endif\n#if SQLITE_ENABLE_MEMORY_MANAGEMENT\n  \"ENABLE_MEMORY_MANAGEMENT\",\n#endif\n#if SQLITE_ENABLE_MEMSYS3\n  \"ENABLE_MEMSYS3\",\n#endif\n#if SQLITE_ENABLE_MEMSYS5\n  \"ENABLE_MEMSYS5\",\n#endif\n#if SQLITE_ENABLE_MULTIPLEX\n  \"ENABLE_MULTIPLEX\",\n#endif\n#if SQLITE_ENABLE_NULL_TRIM\n  \"ENABLE_NULL_TRIM\",\n#endif\n#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK\n  \"ENABLE_OVERSIZE_CELL_CHECK\",\n#endif\n#if SQLITE_ENABLE_PREUPDATE_HOOK\n  \"ENABLE_PREUPDATE_HOOK\",\n#endif\n#if SQLITE_ENABLE_QPSG\n  \"ENABLE_QPSG\",\n#endif\n#if SQLITE_ENABLE_RBU\n  \"ENABLE_RBU\",\n#endif\n#if SQLITE_ENABLE_RTREE\n  \"ENABLE_RTREE\",\n#endif\n#if SQLITE_ENABLE_SELECTTRACE\n  \"ENABLE_SELECTTRACE\",\n#endif\n#if SQLITE_ENABLE_SESSION\n  \"ENABLE_SESSION\",\n#endif\n#if SQLITE_ENABLE_SNAPSHOT\n  \"ENABLE_SNAPSHOT\",\n#endif\n#if SQLITE_ENABLE_SQLLOG\n  \"ENABLE_SQLLOG\",\n#endif\n#if defined(SQLITE_ENABLE_STAT4)\n  \"ENABLE_STAT4\",\n#elif defined(SQLITE_ENABLE_STAT3)\n  \"ENABLE_STAT3\",\n#endif\n#if SQLITE_ENABLE_STMTVTAB\n  \"ENABLE_STMTVTAB\",\n#endif\n#if SQLITE_ENABLE_STMT_SCANSTATUS\n  \"ENABLE_STMT_SCANSTATUS\",\n#endif\n#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n  \"ENABLE_UNKNOWN_SQL_FUNCTION\",\n#endif\n#if SQLITE_ENABLE_UNLOCK_NOTIFY\n  \"ENABLE_UNLOCK_NOTIFY\",\n#endif\n#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT\n  \"ENABLE_UPDATE_DELETE_LIMIT\",\n#endif\n#if SQLITE_ENABLE_URI_00_ERROR\n  \"ENABLE_URI_00_ERROR\",\n#endif\n#if SQLITE_ENABLE_VFSTRACE\n  \"ENABLE_VFSTRACE\",\n#endif\n#if SQLITE_ENABLE_WHERETRACE\n  \"ENABLE_WHERETRACE\",\n#endif\n#if SQLITE_ENABLE_ZIPVFS\n  \"ENABLE_ZIPVFS\",\n#endif\n#if SQLITE_EXPLAIN_ESTIMATED_ROWS\n  \"EXPLAIN_ESTIMATED_ROWS\",\n#endif\n#if SQLITE_EXTRA_IFNULLROW\n  \"EXTRA_IFNULLROW\",\n#endif\n#ifdef SQLITE_EXTRA_INIT\n  \"EXTRA_INIT=\" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),\n#endif\n#ifdef SQLITE_EXTRA_SHUTDOWN\n  \"EXTRA_SHUTDOWN=\" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),\n#endif\n#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH\n  \"FTS3_MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),\n#endif\n#if SQLITE_FTS5_ENABLE_TEST_MI\n  \"FTS5_ENABLE_TEST_MI\",\n#endif\n#if SQLITE_FTS5_NO_WITHOUT_ROWID\n  \"FTS5_NO_WITHOUT_ROWID\",\n#endif\n#if SQLITE_HAS_CODEC\n  \"HAS_CODEC\",\n#endif\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n  \"HAVE_ISNAN\",\n#endif\n#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  \"HOMEGROWN_RECURSIVE_MUTEX\",\n#endif\n#if SQLITE_IGNORE_AFP_LOCK_ERRORS\n  \"IGNORE_AFP_LOCK_ERRORS\",\n#endif\n#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  \"IGNORE_FLOCK_LOCK_ERRORS\",\n#endif\n#if SQLITE_INLINE_MEMCPY\n  \"INLINE_MEMCPY\",\n#endif\n#if SQLITE_INT64_TYPE\n  \"INT64_TYPE\",\n#endif\n#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n  \"INTEGRITY_CHECK_ERROR_MAX=\" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),\n#endif\n#if SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  \"LIKE_DOESNT_MATCH_BLOBS\",\n#endif\n#if SQLITE_LOCK_TRACE\n  \"LOCK_TRACE\",\n#endif\n#if SQLITE_LOG_CACHE_SPILL\n  \"LOG_CACHE_SPILL\",\n#endif\n#ifdef SQLITE_MALLOC_SOFT_LIMIT\n  \"MALLOC_SOFT_LIMIT=\" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),\n#endif\n#ifdef SQLITE_MAX_ATTACHED\n  \"MAX_ATTACHED=\" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),\n#endif\n#ifdef SQLITE_MAX_COLUMN\n  \"MAX_COLUMN=\" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),\n#endif\n#ifdef SQLITE_MAX_COMPOUND_SELECT\n  \"MAX_COMPOUND_SELECT=\" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),\n#endif\n#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE\n  \"MAX_DEFAULT_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_EXPR_DEPTH\n  \"MAX_EXPR_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),\n#endif\n#ifdef SQLITE_MAX_FUNCTION_ARG\n  \"MAX_FUNCTION_ARG=\" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),\n#endif\n#ifdef SQLITE_MAX_LENGTH\n  \"MAX_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),\n#endif\n#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH\n  \"MAX_LIKE_PATTERN_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),\n#endif\n#ifdef SQLITE_MAX_MEMORY\n  \"MAX_MEMORY=\" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE\n  \"MAX_MMAP_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),\n#endif\n#ifdef SQLITE_MAX_MMAP_SIZE_\n  \"MAX_MMAP_SIZE_=\" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),\n#endif\n#ifdef SQLITE_MAX_PAGE_COUNT\n  \"MAX_PAGE_COUNT=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),\n#endif\n#ifdef SQLITE_MAX_PAGE_SIZE\n  \"MAX_PAGE_SIZE=\" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),\n#endif\n#ifdef SQLITE_MAX_SCHEMA_RETRY\n  \"MAX_SCHEMA_RETRY=\" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),\n#endif\n#ifdef SQLITE_MAX_SQL_LENGTH\n  \"MAX_SQL_LENGTH=\" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),\n#endif\n#ifdef SQLITE_MAX_TRIGGER_DEPTH\n  \"MAX_TRIGGER_DEPTH=\" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),\n#endif\n#ifdef SQLITE_MAX_VARIABLE_NUMBER\n  \"MAX_VARIABLE_NUMBER=\" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),\n#endif\n#ifdef SQLITE_MAX_VDBE_OP\n  \"MAX_VDBE_OP=\" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),\n#endif\n#ifdef SQLITE_MAX_WORKER_THREADS\n  \"MAX_WORKER_THREADS=\" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),\n#endif\n#if SQLITE_MEMDEBUG\n  \"MEMDEBUG\",\n#endif\n#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n  \"MIXED_ENDIAN_64BIT_FLOAT\",\n#endif\n#if SQLITE_MMAP_READWRITE\n  \"MMAP_READWRITE\",\n#endif\n#if SQLITE_MUTEX_NOOP\n  \"MUTEX_NOOP\",\n#endif\n#if SQLITE_MUTEX_NREF\n  \"MUTEX_NREF\",\n#endif\n#if SQLITE_MUTEX_OMIT\n  \"MUTEX_OMIT\",\n#endif\n#if SQLITE_MUTEX_PTHREADS\n  \"MUTEX_PTHREADS\",\n#endif\n#if SQLITE_MUTEX_W32\n  \"MUTEX_W32\",\n#endif\n#if SQLITE_NEED_ERR_NAME\n  \"NEED_ERR_NAME\",\n#endif\n#if SQLITE_NOINLINE\n  \"NOINLINE\",\n#endif\n#if SQLITE_NO_SYNC\n  \"NO_SYNC\",\n#endif\n#if SQLITE_OMIT_ALTERTABLE\n  \"OMIT_ALTERTABLE\",\n#endif\n#if SQLITE_OMIT_ANALYZE\n  \"OMIT_ANALYZE\",\n#endif\n#if SQLITE_OMIT_ATTACH\n  \"OMIT_ATTACH\",\n#endif\n#if SQLITE_OMIT_AUTHORIZATION\n  \"OMIT_AUTHORIZATION\",\n#endif\n#if SQLITE_OMIT_AUTOINCREMENT\n  \"OMIT_AUTOINCREMENT\",\n#endif\n#if SQLITE_OMIT_AUTOINIT\n  \"OMIT_AUTOINIT\",\n#endif\n#if SQLITE_OMIT_AUTOMATIC_INDEX\n  \"OMIT_AUTOMATIC_INDEX\",\n#endif\n#if SQLITE_OMIT_AUTORESET\n  \"OMIT_AUTORESET\",\n#endif\n#if SQLITE_OMIT_AUTOVACUUM\n  \"OMIT_AUTOVACUUM\",\n#endif\n#if SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  \"OMIT_BETWEEN_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_BLOB_LITERAL\n  \"OMIT_BLOB_LITERAL\",\n#endif\n#if SQLITE_OMIT_BTREECOUNT\n  \"OMIT_BTREECOUNT\",\n#endif\n#if SQLITE_OMIT_CAST\n  \"OMIT_CAST\",\n#endif\n#if SQLITE_OMIT_CHECK\n  \"OMIT_CHECK\",\n#endif\n#if SQLITE_OMIT_COMPLETE\n  \"OMIT_COMPLETE\",\n#endif\n#if SQLITE_OMIT_COMPOUND_SELECT\n  \"OMIT_COMPOUND_SELECT\",\n#endif\n#if SQLITE_OMIT_CONFLICT_CLAUSE\n  \"OMIT_CONFLICT_CLAUSE\",\n#endif\n#if SQLITE_OMIT_CTE\n  \"OMIT_CTE\",\n#endif\n#if SQLITE_OMIT_DATETIME_FUNCS\n  \"OMIT_DATETIME_FUNCS\",\n#endif\n#if SQLITE_OMIT_DECLTYPE\n  \"OMIT_DECLTYPE\",\n#endif\n#if SQLITE_OMIT_DEPRECATED\n  \"OMIT_DEPRECATED\",\n#endif\n#if SQLITE_OMIT_DISKIO\n  \"OMIT_DISKIO\",\n#endif\n#if SQLITE_OMIT_EXPLAIN\n  \"OMIT_EXPLAIN\",\n#endif\n#if SQLITE_OMIT_FLAG_PRAGMAS\n  \"OMIT_FLAG_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_FLOATING_POINT\n  \"OMIT_FLOATING_POINT\",\n#endif\n#if SQLITE_OMIT_FOREIGN_KEY\n  \"OMIT_FOREIGN_KEY\",\n#endif\n#if SQLITE_OMIT_GET_TABLE\n  \"OMIT_GET_TABLE\",\n#endif\n#if SQLITE_OMIT_HEX_INTEGER\n  \"OMIT_HEX_INTEGER\",\n#endif\n#if SQLITE_OMIT_INCRBLOB\n  \"OMIT_INCRBLOB\",\n#endif\n#if SQLITE_OMIT_INTEGRITY_CHECK\n  \"OMIT_INTEGRITY_CHECK\",\n#endif\n#if SQLITE_OMIT_LIKE_OPTIMIZATION\n  \"OMIT_LIKE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_LOAD_EXTENSION\n  \"OMIT_LOAD_EXTENSION\",\n#endif\n#if SQLITE_OMIT_LOCALTIME\n  \"OMIT_LOCALTIME\",\n#endif\n#if SQLITE_OMIT_LOOKASIDE\n  \"OMIT_LOOKASIDE\",\n#endif\n#if SQLITE_OMIT_MEMORYDB\n  \"OMIT_MEMORYDB\",\n#endif\n#if SQLITE_OMIT_OR_OPTIMIZATION\n  \"OMIT_OR_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_PAGER_PRAGMAS\n  \"OMIT_PAGER_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_PARSER_TRACE\n  \"OMIT_PARSER_TRACE\",\n#endif\n#if SQLITE_OMIT_POPEN\n  \"OMIT_POPEN\",\n#endif\n#if SQLITE_OMIT_PRAGMA\n  \"OMIT_PRAGMA\",\n#endif\n#if SQLITE_OMIT_PROGRESS_CALLBACK\n  \"OMIT_PROGRESS_CALLBACK\",\n#endif\n#if SQLITE_OMIT_QUICKBALANCE\n  \"OMIT_QUICKBALANCE\",\n#endif\n#if SQLITE_OMIT_REINDEX\n  \"OMIT_REINDEX\",\n#endif\n#if SQLITE_OMIT_SCHEMA_PRAGMAS\n  \"OMIT_SCHEMA_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  \"OMIT_SCHEMA_VERSION_PRAGMAS\",\n#endif\n#if SQLITE_OMIT_SHARED_CACHE\n  \"OMIT_SHARED_CACHE\",\n#endif\n#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n  \"OMIT_SHUTDOWN_DIRECTORIES\",\n#endif\n#if SQLITE_OMIT_SUBQUERY\n  \"OMIT_SUBQUERY\",\n#endif\n#if SQLITE_OMIT_TCL_VARIABLE\n  \"OMIT_TCL_VARIABLE\",\n#endif\n#if SQLITE_OMIT_TEMPDB\n  \"OMIT_TEMPDB\",\n#endif\n#if SQLITE_OMIT_TEST_CONTROL\n  \"OMIT_TEST_CONTROL\",\n#endif\n#if SQLITE_OMIT_TRACE\n  \"OMIT_TRACE\",\n#endif\n#if SQLITE_OMIT_TRIGGER\n  \"OMIT_TRIGGER\",\n#endif\n#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  \"OMIT_TRUNCATE_OPTIMIZATION\",\n#endif\n#if SQLITE_OMIT_UTF16\n  \"OMIT_UTF16\",\n#endif\n#if SQLITE_OMIT_VACUUM\n  \"OMIT_VACUUM\",\n#endif\n#if SQLITE_OMIT_VIEW\n  \"OMIT_VIEW\",\n#endif\n#if SQLITE_OMIT_VIRTUALTABLE\n  \"OMIT_VIRTUALTABLE\",\n#endif\n#if SQLITE_OMIT_WAL\n  \"OMIT_WAL\",\n#endif\n#if SQLITE_OMIT_WSD\n  \"OMIT_WSD\",\n#endif\n#if SQLITE_OMIT_XFER_OPT\n  \"OMIT_XFER_OPT\",\n#endif\n#if SQLITE_PCACHE_SEPARATE_HEADER\n  \"PCACHE_SEPARATE_HEADER\",\n#endif\n#if SQLITE_PERFORMANCE_TRACE\n  \"PERFORMANCE_TRACE\",\n#endif\n#if SQLITE_POWERSAFE_OVERWRITE\n  \"POWERSAFE_OVERWRITE\",\n#endif\n#if SQLITE_PREFER_PROXY_LOCKING\n  \"PREFER_PROXY_LOCKING\",\n#endif\n#if SQLITE_PROXY_DEBUG\n  \"PROXY_DEBUG\",\n#endif\n#if SQLITE_REVERSE_UNORDERED_SELECTS\n  \"REVERSE_UNORDERED_SELECTS\",\n#endif\n#if SQLITE_RTREE_INT_ONLY\n  \"RTREE_INT_ONLY\",\n#endif\n#if SQLITE_SECURE_DELETE\n  \"SECURE_DELETE\",\n#endif\n#if SQLITE_SMALL_STACK\n  \"SMALL_STACK\",\n#endif\n#ifdef SQLITE_SORTER_PMASZ\n  \"SORTER_PMASZ=\" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),\n#endif\n#if SQLITE_SOUNDEX\n  \"SOUNDEX\",\n#endif\n#ifdef SQLITE_STAT4_SAMPLES\n  \"STAT4_SAMPLES=\" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),\n#endif\n#ifdef SQLITE_STMTJRNL_SPILL\n  \"STMTJRNL_SPILL=\" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),\n#endif\n#if SQLITE_SUBSTR_COMPATIBILITY\n  \"SUBSTR_COMPATIBILITY\",\n#endif\n#if SQLITE_SYSTEM_MALLOC\n  \"SYSTEM_MALLOC\",\n#endif\n#if SQLITE_TCL\n  \"TCL\",\n#endif\n#ifdef SQLITE_TEMP_STORE\n  \"TEMP_STORE=\" CTIMEOPT_VAL(SQLITE_TEMP_STORE),\n#endif\n#if SQLITE_TEST\n  \"TEST\",\n#endif\n#if defined(SQLITE_THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(SQLITE_THREADSAFE),\n#elif defined(THREADSAFE)\n  \"THREADSAFE=\" CTIMEOPT_VAL(THREADSAFE),\n#else\n  \"THREADSAFE=1\",\n#endif\n#if SQLITE_UNLINK_AFTER_CLOSE\n  \"UNLINK_AFTER_CLOSE\",\n#endif\n#if SQLITE_UNTESTABLE\n  \"UNTESTABLE\",\n#endif\n#if SQLITE_USER_AUTHENTICATION\n  \"USER_AUTHENTICATION\",\n#endif\n#if SQLITE_USE_ALLOCA\n  \"USE_ALLOCA\",\n#endif\n#if SQLITE_USE_FCNTL_TRACE\n  \"USE_FCNTL_TRACE\",\n#endif\n#if SQLITE_USE_URI\n  \"USE_URI\",\n#endif\n#if SQLITE_VDBE_COVERAGE\n  \"VDBE_COVERAGE\",\n#endif\n#if SQLITE_WIN32_MALLOC\n  \"WIN32_MALLOC\",\n#endif\n#if SQLITE_ZERO_MALLOC\n  \"ZERO_MALLOC\",\n#endif\n/* \n** END CODE GENERATED BY tool/mkctime.tcl \n*/\n};\n\nconst char **sqlite3CompileOptions(int *pnOpt){\n  *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);\n  return (const char**)sqlite3azCompileOpt;\n}\n\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/date.c",
    "content": "/*\n** 2003 October 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement date and time\n** functions for SQLite.  \n**\n** There is only one exported symbol in this file - the function\n** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.\n** All other code has file scope.\n**\n** SQLite processes all times and dates as julian day numbers.  The\n** dates and times are stored as the number of days since noon\n** in Greenwich on November 24, 4714 B.C. according to the Gregorian\n** calendar system. \n**\n** 1970-01-01 00:00:00 is JD 2440587.5\n** 2000-01-01 00:00:00 is JD 2451544.5\n**\n** This implementation requires years to be expressed as a 4-digit number\n** which means that only dates between 0000-01-01 and 9999-12-31 can\n** be represented, even though julian day numbers allow a much wider\n** range of dates.\n**\n** The Gregorian calendar system is used for all dates and times,\n** even those that predate the Gregorian calendar.  Historians usually\n** use the julian calendar for dates prior to 1582-10-15 and for some\n** dates afterwards, depending on locale.  Beware of this difference.\n**\n** The conversion algorithms are implemented based on descriptions\n** in the following text:\n**\n**      Jean Meeus\n**      Astronomical Algorithms, 2nd Edition, 1998\n**      ISBM 0-943396-61-1\n**      Willmann-Bell, Inc\n**      Richmond, Virginia (USA)\n*/\n#include \"sqliteInt.h\"\n#include <stdlib.h>\n#include <assert.h>\n#include <time.h>\n\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So declare a substitute.  The substitute function itself is\n** defined in \"os_win.c\".\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\nstruct tm *__cdecl localtime(const time_t *);\n#endif\n\n/*\n** A structure for holding a single date and time.\n*/\ntypedef struct DateTime DateTime;\nstruct DateTime {\n  sqlite3_int64 iJD;  /* The julian day number times 86400000 */\n  int Y, M, D;        /* Year, month, and day */\n  int h, m;           /* Hour and minutes */\n  int tz;             /* Timezone offset in minutes */\n  double s;           /* Seconds */\n  char validJD;       /* True (1) if iJD is valid */\n  char rawS;          /* Raw numeric value stored in s */\n  char validYMD;      /* True (1) if Y,M,D are valid */\n  char validHMS;      /* True (1) if h,m,s are valid */\n  char validTZ;       /* True (1) if tz is valid */\n  char tzSet;         /* Timezone was set explicitly */\n  char isError;       /* An overflow has occurred */\n};\n\n\n/*\n** Convert zDate into one or more integers according to the conversion\n** specifier zFormat.\n**\n** zFormat[] contains 4 characters for each integer converted, except for\n** the last integer which is specified by three characters.  The meaning\n** of a four-character format specifiers ABCD is:\n**\n**    A:   number of digits to convert.  Always \"2\" or \"4\".\n**    B:   minimum value.  Always \"0\" or \"1\".\n**    C:   maximum value, decoded as:\n**           a:  12\n**           b:  14\n**           c:  24\n**           d:  31\n**           e:  59\n**           f:  9999\n**    D:   the separator character, or \\000 to indicate this is the\n**         last number to convert.\n**\n** Example:  To translate an ISO-8601 date YYYY-MM-DD, the format would\n** be \"40f-21a-20c\".  The \"40f-\" indicates the 4-digit year followed by \"-\".\n** The \"21a-\" indicates the 2-digit month followed by \"-\".  The \"20c\" indicates\n** the 2-digit day which is the last integer in the set.\n**\n** The function returns the number of successful conversions.\n*/\nstatic int getDigits(const char *zDate, const char *zFormat, ...){\n  /* The aMx[] array translates the 3rd character of each format\n  ** spec into a max size:    a   b   c   d   e     f */\n  static const u16 aMx[] = { 12, 14, 24, 31, 59, 9999 };\n  va_list ap;\n  int cnt = 0;\n  char nextC;\n  va_start(ap, zFormat);\n  do{\n    char N = zFormat[0] - '0';\n    char min = zFormat[1] - '0';\n    int val = 0;\n    u16 max;\n\n    assert( zFormat[2]>='a' && zFormat[2]<='f' );\n    max = aMx[zFormat[2] - 'a'];\n    nextC = zFormat[3];\n    val = 0;\n    while( N-- ){\n      if( !sqlite3Isdigit(*zDate) ){\n        goto end_getDigits;\n      }\n      val = val*10 + *zDate - '0';\n      zDate++;\n    }\n    if( val<(int)min || val>(int)max || (nextC!=0 && nextC!=*zDate) ){\n      goto end_getDigits;\n    }\n    *va_arg(ap,int*) = val;\n    zDate++;\n    cnt++;\n    zFormat += 4;\n  }while( nextC );\nend_getDigits:\n  va_end(ap);\n  return cnt;\n}\n\n/*\n** Parse a timezone extension on the end of a date-time.\n** The extension is of the form:\n**\n**        (+/-)HH:MM\n**\n** Or the \"zulu\" notation:\n**\n**        Z\n**\n** If the parse is successful, write the number of minutes\n** of change in p->tz and return 0.  If a parser error occurs,\n** return non-zero.\n**\n** A missing specifier is not considered an error.\n*/\nstatic int parseTimezone(const char *zDate, DateTime *p){\n  int sgn = 0;\n  int nHr, nMn;\n  int c;\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tz = 0;\n  c = *zDate;\n  if( c=='-' ){\n    sgn = -1;\n  }else if( c=='+' ){\n    sgn = +1;\n  }else if( c=='Z' || c=='z' ){\n    zDate++;\n    goto zulu_time;\n  }else{\n    return c!=0;\n  }\n  zDate++;\n  if( getDigits(zDate, \"20b:20e\", &nHr, &nMn)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  p->tz = sgn*(nMn + nHr*60);\nzulu_time:\n  while( sqlite3Isspace(*zDate) ){ zDate++; }\n  p->tzSet = 1;\n  return *zDate!=0;\n}\n\n/*\n** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.\n** The HH, MM, and SS must each be exactly 2 digits.  The\n** fractional seconds FFFF can be one or more digits.\n**\n** Return 1 if there is a parsing error and 0 on success.\n*/\nstatic int parseHhMmSs(const char *zDate, DateTime *p){\n  int h, m, s;\n  double ms = 0.0;\n  if( getDigits(zDate, \"20c:20e\", &h, &m)!=2 ){\n    return 1;\n  }\n  zDate += 5;\n  if( *zDate==':' ){\n    zDate++;\n    if( getDigits(zDate, \"20e\", &s)!=1 ){\n      return 1;\n    }\n    zDate += 2;\n    if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){\n      double rScale = 1.0;\n      zDate++;\n      while( sqlite3Isdigit(*zDate) ){\n        ms = ms*10.0 + *zDate - '0';\n        rScale *= 10.0;\n        zDate++;\n      }\n      ms /= rScale;\n    }\n  }else{\n    s = 0;\n  }\n  p->validJD = 0;\n  p->rawS = 0;\n  p->validHMS = 1;\n  p->h = h;\n  p->m = m;\n  p->s = s + ms;\n  if( parseTimezone(zDate, p) ) return 1;\n  p->validTZ = (p->tz!=0)?1:0;\n  return 0;\n}\n\n/*\n** Put the DateTime object into its error state.\n*/\nstatic void datetimeError(DateTime *p){\n  memset(p, 0, sizeof(*p));\n  p->isError = 1;\n}\n\n/*\n** Convert from YYYY-MM-DD HH:MM:SS to julian day.  We always assume\n** that the YYYY-MM-DD is according to the Gregorian calendar.\n**\n** Reference:  Meeus page 61\n*/\nstatic void computeJD(DateTime *p){\n  int Y, M, D, A, B, X1, X2;\n\n  if( p->validJD ) return;\n  if( p->validYMD ){\n    Y = p->Y;\n    M = p->M;\n    D = p->D;\n  }else{\n    Y = 2000;  /* If no YMD specified, assume 2000-Jan-01 */\n    M = 1;\n    D = 1;\n  }\n  if( Y<-4713 || Y>9999 || p->rawS ){\n    datetimeError(p);\n    return;\n  }\n  if( M<=2 ){\n    Y--;\n    M += 12;\n  }\n  A = Y/100;\n  B = 2 - A + (A/4);\n  X1 = 36525*(Y+4716)/100;\n  X2 = 306001*(M+1)/10000;\n  p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);\n  p->validJD = 1;\n  if( p->validHMS ){\n    p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);\n    if( p->validTZ ){\n      p->iJD -= p->tz*60000;\n      p->validYMD = 0;\n      p->validHMS = 0;\n      p->validTZ = 0;\n    }\n  }\n}\n\n/*\n** Parse dates of the form\n**\n**     YYYY-MM-DD HH:MM:SS.FFF\n**     YYYY-MM-DD HH:MM:SS\n**     YYYY-MM-DD HH:MM\n**     YYYY-MM-DD\n**\n** Write the result into the DateTime structure and return 0\n** on success and 1 if the input string is not a well-formed\n** date.\n*/\nstatic int parseYyyyMmDd(const char *zDate, DateTime *p){\n  int Y, M, D, neg;\n\n  if( zDate[0]=='-' ){\n    zDate++;\n    neg = 1;\n  }else{\n    neg = 0;\n  }\n  if( getDigits(zDate, \"40f-21a-21d\", &Y, &M, &D)!=3 ){\n    return 1;\n  }\n  zDate += 10;\n  while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }\n  if( parseHhMmSs(zDate, p)==0 ){\n    /* We got the time */\n  }else if( *zDate==0 ){\n    p->validHMS = 0;\n  }else{\n    return 1;\n  }\n  p->validJD = 0;\n  p->validYMD = 1;\n  p->Y = neg ? -Y : Y;\n  p->M = M;\n  p->D = D;\n  if( p->validTZ ){\n    computeJD(p);\n  }\n  return 0;\n}\n\n/*\n** Set the time to the current time reported by the VFS.\n**\n** Return the number of errors.\n*/\nstatic int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){\n  p->iJD = sqlite3StmtCurrentTime(context);\n  if( p->iJD>0 ){\n    p->validJD = 1;\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Input \"r\" is a numeric quantity which might be a julian day number,\n** or the number of seconds since 1970.  If the value if r is within\n** range of a julian day number, install it as such and set validJD.\n** If the value is a valid unix timestamp, put it in p->s and set p->rawS.\n*/\nstatic void setRawDateNumber(DateTime *p, double r){\n  p->s = r;\n  p->rawS = 1;\n  if( r>=0.0 && r<5373484.5 ){\n    p->iJD = (sqlite3_int64)(r*86400000.0 + 0.5);\n    p->validJD = 1;\n  }\n}\n\n/*\n** Attempt to parse the given string into a julian day number.  Return\n** the number of errors.\n**\n** The following are acceptable forms for the input string:\n**\n**      YYYY-MM-DD HH:MM:SS.FFF  +/-HH:MM\n**      DDDD.DD \n**      now\n**\n** In the first form, the +/-HH:MM is always optional.  The fractional\n** seconds extension (the \".FFF\") is optional.  The seconds portion\n** (\":SS.FFF\") is option.  The year and date can be omitted as long\n** as there is a time string.  The time string can be omitted as long\n** as there is a year and date.\n*/\nstatic int parseDateOrTime(\n  sqlite3_context *context, \n  const char *zDate, \n  DateTime *p\n){\n  double r;\n  if( parseYyyyMmDd(zDate,p)==0 ){\n    return 0;\n  }else if( parseHhMmSs(zDate, p)==0 ){\n    return 0;\n  }else if( sqlite3StrICmp(zDate,\"now\")==0 && sqlite3NotPureFunc(context) ){\n    return setDateTimeToCurrent(context, p);\n  }else if( sqlite3AtoF(zDate, &r, sqlite3Strlen30(zDate), SQLITE_UTF8) ){\n    setRawDateNumber(p, r);\n    return 0;\n  }\n  return 1;\n}\n\n/* The julian day number for 9999-12-31 23:59:59.999 is 5373484.4999999.\n** Multiplying this by 86400000 gives 464269060799999 as the maximum value\n** for DateTime.iJD.\n**\n** But some older compilers (ex: gcc 4.2.1 on older Macs) cannot deal with \n** such a large integer literal, so we have to encode it.\n*/\n#define INT_464269060799999  ((((i64)0x1a640)<<32)|0x1072fdff)\n\n/*\n** Return TRUE if the given julian day number is within range.\n**\n** The input is the JulianDay times 86400000.\n*/\nstatic int validJulianDay(sqlite3_int64 iJD){\n  return iJD>=0 && iJD<=INT_464269060799999;\n}\n\n/*\n** Compute the Year, Month, and Day from the julian day number.\n*/\nstatic void computeYMD(DateTime *p){\n  int Z, A, B, C, D, E, X1;\n  if( p->validYMD ) return;\n  if( !p->validJD ){\n    p->Y = 2000;\n    p->M = 1;\n    p->D = 1;\n  }else if( !validJulianDay(p->iJD) ){\n    datetimeError(p);\n    return;\n  }else{\n    Z = (int)((p->iJD + 43200000)/86400000);\n    A = (int)((Z - 1867216.25)/36524.25);\n    A = Z + 1 + A - (A/4);\n    B = A + 1524;\n    C = (int)((B - 122.1)/365.25);\n    D = (36525*(C&32767))/100;\n    E = (int)((B-D)/30.6001);\n    X1 = (int)(30.6001*E);\n    p->D = B - D - X1;\n    p->M = E<14 ? E-1 : E-13;\n    p->Y = p->M>2 ? C - 4716 : C - 4715;\n  }\n  p->validYMD = 1;\n}\n\n/*\n** Compute the Hour, Minute, and Seconds from the julian day number.\n*/\nstatic void computeHMS(DateTime *p){\n  int s;\n  if( p->validHMS ) return;\n  computeJD(p);\n  s = (int)((p->iJD + 43200000) % 86400000);\n  p->s = s/1000.0;\n  s = (int)p->s;\n  p->s -= s;\n  p->h = s/3600;\n  s -= p->h*3600;\n  p->m = s/60;\n  p->s += s - p->m*60;\n  p->rawS = 0;\n  p->validHMS = 1;\n}\n\n/*\n** Compute both YMD and HMS\n*/\nstatic void computeYMD_HMS(DateTime *p){\n  computeYMD(p);\n  computeHMS(p);\n}\n\n/*\n** Clear the YMD and HMS and the TZ\n*/\nstatic void clearYMD_HMS_TZ(DateTime *p){\n  p->validYMD = 0;\n  p->validHMS = 0;\n  p->validTZ = 0;\n}\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** On recent Windows platforms, the localtime_s() function is available\n** as part of the \"Secure CRT\". It is essentially equivalent to \n** localtime_r() available under most POSIX platforms, except that the \n** order of the parameters is reversed.\n**\n** See http://msdn.microsoft.com/en-us/library/a442x3ye(VS.80).aspx.\n**\n** If the user has not indicated to use localtime_r() or localtime_s()\n** already, check for an MSVC build environment that provides \n** localtime_s().\n*/\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \\\n    && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)\n#undef  HAVE_LOCALTIME_S\n#define HAVE_LOCALTIME_S 1\n#endif\n\n/*\n** The following routine implements the rough equivalent of localtime_r()\n** using whatever operating-system specific localtime facility that\n** is available.  This routine returns 0 on success and\n** non-zero on any kind of error.\n**\n** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this\n** routine will always fail.\n**\n** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C\n** library function localtime_r() is used to assist in the calculation of\n** local time.\n*/\nstatic int osLocaltime(time_t *t, struct tm *pTm){\n  int rc;\n#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S\n  struct tm *pX;\n#if SQLITE_THREADSAFE>0\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  pX = localtime(t);\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;\n#endif\n  if( pX ) *pTm = *pX;\n  sqlite3_mutex_leave(mutex);\n  rc = pX==0;\n#else\n#ifndef SQLITE_UNTESTABLE\n  if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;\n#endif\n#if HAVE_LOCALTIME_R\n  rc = localtime_r(t, pTm)==0;\n#else\n  rc = localtime_s(pTm, t);\n#endif /* HAVE_LOCALTIME_R */\n#endif /* HAVE_LOCALTIME_R || HAVE_LOCALTIME_S */\n  return rc;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n\n#ifndef SQLITE_OMIT_LOCALTIME\n/*\n** Compute the difference (in milliseconds) between localtime and UTC\n** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,\n** return this value and set *pRc to SQLITE_OK. \n**\n** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value\n** is undefined in this case.\n*/\nstatic sqlite3_int64 localtimeOffset(\n  DateTime *p,                    /* Date at which to calculate offset */\n  sqlite3_context *pCtx,          /* Write error here if one occurs */\n  int *pRc                        /* OUT: Error code. SQLITE_OK or ERROR */\n){\n  DateTime x, y;\n  time_t t;\n  struct tm sLocal;\n\n  /* Initialize the contents of sLocal to avoid a compiler warning. */\n  memset(&sLocal, 0, sizeof(sLocal));\n\n  x = *p;\n  computeYMD_HMS(&x);\n  if( x.Y<1971 || x.Y>=2038 ){\n    /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only\n    ** works for years between 1970 and 2037. For dates outside this range,\n    ** SQLite attempts to map the year into an equivalent year within this\n    ** range, do the calculation, then map the year back.\n    */\n    x.Y = 2000;\n    x.M = 1;\n    x.D = 1;\n    x.h = 0;\n    x.m = 0;\n    x.s = 0.0;\n  } else {\n    int s = (int)(x.s + 0.5);\n    x.s = s;\n  }\n  x.tz = 0;\n  x.validJD = 0;\n  computeJD(&x);\n  t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);\n  if( osLocaltime(&t, &sLocal) ){\n    sqlite3_result_error(pCtx, \"local time unavailable\", -1);\n    *pRc = SQLITE_ERROR;\n    return 0;\n  }\n  y.Y = sLocal.tm_year + 1900;\n  y.M = sLocal.tm_mon + 1;\n  y.D = sLocal.tm_mday;\n  y.h = sLocal.tm_hour;\n  y.m = sLocal.tm_min;\n  y.s = sLocal.tm_sec;\n  y.validYMD = 1;\n  y.validHMS = 1;\n  y.validJD = 0;\n  y.rawS = 0;\n  y.validTZ = 0;\n  y.isError = 0;\n  computeJD(&y);\n  *pRc = SQLITE_OK;\n  return y.iJD - x.iJD;\n}\n#endif /* SQLITE_OMIT_LOCALTIME */\n\n/*\n** The following table defines various date transformations of the form\n**\n**            'NNN days'\n**\n** Where NNN is an arbitrary floating-point number and \"days\" can be one\n** of several units of time.\n*/\nstatic const struct {\n  u8 eType;           /* Transformation type code */\n  u8 nName;           /* Length of th name */\n  char *zName;        /* Name of the transformation */\n  double rLimit;      /* Maximum NNN value for this transform */\n  double rXform;      /* Constant used for this transform */\n} aXformType[] = {\n  { 0, 6, \"second\", 464269060800.0, 86400000.0/(24.0*60.0*60.0) },\n  { 0, 6, \"minute\", 7737817680.0,   86400000.0/(24.0*60.0)      },\n  { 0, 4, \"hour\",   128963628.0,    86400000.0/24.0             },\n  { 0, 3, \"day\",    5373485.0,      86400000.0                  },\n  { 1, 5, \"month\",  176546.0,       30.0*86400000.0             },\n  { 2, 4, \"year\",   14713.0,        365.0*86400000.0            },\n};\n\n/*\n** Process a modifier to a date-time stamp.  The modifiers are\n** as follows:\n**\n**     NNN days\n**     NNN hours\n**     NNN minutes\n**     NNN.NNNN seconds\n**     NNN months\n**     NNN years\n**     start of month\n**     start of year\n**     start of week\n**     start of day\n**     weekday N\n**     unixepoch\n**     localtime\n**     utc\n**\n** Return 0 on success and 1 if there is any kind of error. If the error\n** is in a system call (i.e. localtime()), then an error message is written\n** to context pCtx. If the error is an unrecognized modifier, no error is\n** written to pCtx.\n*/\nstatic int parseModifier(\n  sqlite3_context *pCtx,      /* Function context */\n  const char *z,              /* The text of the modifier */\n  int n,                      /* Length of zMod in bytes */\n  DateTime *p                 /* The date/time value to be modified */\n){\n  int rc = 1;\n  double r;\n  switch(sqlite3UpperToLower[(u8)z[0]] ){\n#ifndef SQLITE_OMIT_LOCALTIME\n    case 'l': {\n      /*    localtime\n      **\n      ** Assuming the current time value is UTC (a.k.a. GMT), shift it to\n      ** show local time.\n      */\n      if( sqlite3_stricmp(z, \"localtime\")==0 && sqlite3NotPureFunc(pCtx) ){\n        computeJD(p);\n        p->iJD += localtimeOffset(p, pCtx, &rc);\n        clearYMD_HMS_TZ(p);\n      }\n      break;\n    }\n#endif\n    case 'u': {\n      /*\n      **    unixepoch\n      **\n      ** Treat the current value of p->s as the number of\n      ** seconds since 1970.  Convert to a real julian day number.\n      */\n      if( sqlite3_stricmp(z, \"unixepoch\")==0 && p->rawS ){\n        r = p->s*1000.0 + 210866760000000.0;\n        if( r>=0.0 && r<464269060800000.0 ){\n          clearYMD_HMS_TZ(p);\n          p->iJD = (sqlite3_int64)r;\n          p->validJD = 1;\n          p->rawS = 0;\n          rc = 0;\n        }\n      }\n#ifndef SQLITE_OMIT_LOCALTIME\n      else if( sqlite3_stricmp(z, \"utc\")==0 && sqlite3NotPureFunc(pCtx) ){\n        if( p->tzSet==0 ){\n          sqlite3_int64 c1;\n          computeJD(p);\n          c1 = localtimeOffset(p, pCtx, &rc);\n          if( rc==SQLITE_OK ){\n            p->iJD -= c1;\n            clearYMD_HMS_TZ(p);\n            p->iJD += c1 - localtimeOffset(p, pCtx, &rc);\n          }\n          p->tzSet = 1;\n        }else{\n          rc = SQLITE_OK;\n        }\n      }\n#endif\n      break;\n    }\n    case 'w': {\n      /*\n      **    weekday N\n      **\n      ** Move the date to the same time on the next occurrence of\n      ** weekday N where 0==Sunday, 1==Monday, and so forth.  If the\n      ** date is already on the appropriate weekday, this is a no-op.\n      */\n      if( sqlite3_strnicmp(z, \"weekday \", 8)==0\n               && sqlite3AtoF(&z[8], &r, sqlite3Strlen30(&z[8]), SQLITE_UTF8)\n               && (n=(int)r)==r && n>=0 && r<7 ){\n        sqlite3_int64 Z;\n        computeYMD_HMS(p);\n        p->validTZ = 0;\n        p->validJD = 0;\n        computeJD(p);\n        Z = ((p->iJD + 129600000)/86400000) % 7;\n        if( Z>n ) Z -= 7;\n        p->iJD += (n - Z)*86400000;\n        clearYMD_HMS_TZ(p);\n        rc = 0;\n      }\n      break;\n    }\n    case 's': {\n      /*\n      **    start of TTTTT\n      **\n      ** Move the date backwards to the beginning of the current day,\n      ** or month or year.\n      */\n      if( sqlite3_strnicmp(z, \"start of \", 9)!=0 ) break;\n      if( !p->validJD && !p->validYMD && !p->validHMS ) break;\n      z += 9;\n      computeYMD(p);\n      p->validHMS = 1;\n      p->h = p->m = 0;\n      p->s = 0.0;\n      p->rawS = 0;\n      p->validTZ = 0;\n      p->validJD = 0;\n      if( sqlite3_stricmp(z,\"month\")==0 ){\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"year\")==0 ){\n        p->M = 1;\n        p->D = 1;\n        rc = 0;\n      }else if( sqlite3_stricmp(z,\"day\")==0 ){\n        rc = 0;\n      }\n      break;\n    }\n    case '+':\n    case '-':\n    case '0':\n    case '1':\n    case '2':\n    case '3':\n    case '4':\n    case '5':\n    case '6':\n    case '7':\n    case '8':\n    case '9': {\n      double rRounder;\n      int i;\n      for(n=1; z[n] && z[n]!=':' && !sqlite3Isspace(z[n]); n++){}\n      if( !sqlite3AtoF(z, &r, n, SQLITE_UTF8) ){\n        rc = 1;\n        break;\n      }\n      if( z[n]==':' ){\n        /* A modifier of the form (+|-)HH:MM:SS.FFF adds (or subtracts) the\n        ** specified number of hours, minutes, seconds, and fractional seconds\n        ** to the time.  The \".FFF\" may be omitted.  The \":SS.FFF\" may be\n        ** omitted.\n        */\n        const char *z2 = z;\n        DateTime tx;\n        sqlite3_int64 day;\n        if( !sqlite3Isdigit(*z2) ) z2++;\n        memset(&tx, 0, sizeof(tx));\n        if( parseHhMmSs(z2, &tx) ) break;\n        computeJD(&tx);\n        tx.iJD -= 43200000;\n        day = tx.iJD/86400000;\n        tx.iJD -= day*86400000;\n        if( z[0]=='-' ) tx.iJD = -tx.iJD;\n        computeJD(p);\n        clearYMD_HMS_TZ(p);\n        p->iJD += tx.iJD;\n        rc = 0;\n        break;\n      }\n\n      /* If control reaches this point, it means the transformation is\n      ** one of the forms like \"+NNN days\".  */\n      z += n;\n      while( sqlite3Isspace(*z) ) z++;\n      n = sqlite3Strlen30(z);\n      if( n>10 || n<3 ) break;\n      if( sqlite3UpperToLower[(u8)z[n-1]]=='s' ) n--;\n      computeJD(p);\n      rc = 1;\n      rRounder = r<0 ? -0.5 : +0.5;\n      for(i=0; i<ArraySize(aXformType); i++){\n        if( aXformType[i].nName==n\n         && sqlite3_strnicmp(aXformType[i].zName, z, n)==0\n         && r>-aXformType[i].rLimit && r<aXformType[i].rLimit\n        ){\n          switch( aXformType[i].eType ){\n            case 1: { /* Special processing to add months */\n              int x;\n              computeYMD_HMS(p);\n              p->M += (int)r;\n              x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;\n              p->Y += x;\n              p->M -= x*12;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n            case 2: { /* Special processing to add years */\n              int y = (int)r;\n              computeYMD_HMS(p);\n              p->Y += y;\n              p->validJD = 0;\n              r -= (int)r;\n              break;\n            }\n          }\n          computeJD(p);\n          p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);\n          rc = 0;\n          break;\n        }\n      }\n      clearYMD_HMS_TZ(p);\n      break;\n    }\n    default: {\n      break;\n    }\n  }\n  return rc;\n}\n\n/*\n** Process time function arguments.  argv[0] is a date-time stamp.\n** argv[1] and following are modifiers.  Parse them all and write\n** the resulting time into the DateTime structure p.  Return 0\n** on success and 1 if there are any errors.\n**\n** If there are zero parameters (if even argv[0] is undefined)\n** then assume a default value of \"now\" for argv[0].\n*/\nstatic int isDate(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv, \n  DateTime *p\n){\n  int i, n;\n  const unsigned char *z;\n  int eType;\n  memset(p, 0, sizeof(*p));\n  if( argc==0 ){\n    return setDateTimeToCurrent(context, p);\n  }\n  if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT\n                   || eType==SQLITE_INTEGER ){\n    setRawDateNumber(p, sqlite3_value_double(argv[0]));\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( !z || parseDateOrTime(context, (char*)z, p) ){\n      return 1;\n    }\n  }\n  for(i=1; i<argc; i++){\n    z = sqlite3_value_text(argv[i]);\n    n = sqlite3_value_bytes(argv[i]);\n    if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;\n  }\n  computeJD(p);\n  if( p->isError || !validJulianDay(p->iJD) ) return 1;\n  return 0;\n}\n\n\n/*\n** The following routines implement the various date and time functions\n** of SQLite.\n*/\n\n/*\n**    julianday( TIMESTRING, MOD, MOD, ...)\n**\n** Return the julian day number of the date specified in the arguments\n*/\nstatic void juliandayFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    computeJD(&x);\n    sqlite3_result_double(context, x.iJD/86400000.0);\n  }\n}\n\n/*\n**    datetime( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD HH:MM:SS\n*/\nstatic void datetimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD_HMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d %02d:%02d:%02d\",\n                     x.Y, x.M, x.D, x.h, x.m, (int)(x.s));\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    time( TIMESTRING, MOD, MOD, ...)\n**\n** Return HH:MM:SS\n*/\nstatic void timeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeHMS(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%02d:%02d:%02d\", x.h, x.m, (int)x.s);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    date( TIMESTRING, MOD, MOD, ...)\n**\n** Return YYYY-MM-DD\n*/\nstatic void dateFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  if( isDate(context, argc, argv, &x)==0 ){\n    char zBuf[100];\n    computeYMD(&x);\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%04d-%02d-%02d\", x.Y, x.M, x.D);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n**    strftime( FORMAT, TIMESTRING, MOD, MOD, ...)\n**\n** Return a string described by FORMAT.  Conversions as follows:\n**\n**   %d  day of month\n**   %f  ** fractional seconds  SS.SSS\n**   %H  hour 00-24\n**   %j  day of year 000-366\n**   %J  ** julian day number\n**   %m  month 01-12\n**   %M  minute 00-59\n**   %s  seconds since 1970-01-01\n**   %S  seconds 00-59\n**   %w  day of week 0-6  sunday==0\n**   %W  week of year 00-53\n**   %Y  year 0000-9999\n**   %%  %\n*/\nstatic void strftimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  DateTime x;\n  u64 n;\n  size_t i,j;\n  char *z;\n  sqlite3 *db;\n  const char *zFmt;\n  char zBuf[100];\n  if( argc==0 ) return;\n  zFmt = (const char*)sqlite3_value_text(argv[0]);\n  if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;\n  db = sqlite3_context_db_handle(context);\n  for(i=0, n=1; zFmt[i]; i++, n++){\n    if( zFmt[i]=='%' ){\n      switch( zFmt[i+1] ){\n        case 'd':\n        case 'H':\n        case 'm':\n        case 'M':\n        case 'S':\n        case 'W':\n          n++;\n          /* fall thru */\n        case 'w':\n        case '%':\n          break;\n        case 'f':\n          n += 8;\n          break;\n        case 'j':\n          n += 3;\n          break;\n        case 'Y':\n          n += 8;\n          break;\n        case 's':\n        case 'J':\n          n += 50;\n          break;\n        default:\n          return;  /* ERROR.  return a NULL */\n      }\n      i++;\n    }\n  }\n  testcase( n==sizeof(zBuf)-1 );\n  testcase( n==sizeof(zBuf) );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] );\n  if( n<sizeof(zBuf) ){\n    z = zBuf;\n  }else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    return;\n  }else{\n    z = sqlite3DbMallocRawNN(db, (int)n);\n    if( z==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n  }\n  computeJD(&x);\n  computeYMD_HMS(&x);\n  for(i=j=0; zFmt[i]; i++){\n    if( zFmt[i]!='%' ){\n      z[j++] = zFmt[i];\n    }else{\n      i++;\n      switch( zFmt[i] ){\n        case 'd':  sqlite3_snprintf(3, &z[j],\"%02d\",x.D); j+=2; break;\n        case 'f': {\n          double s = x.s;\n          if( s>59.999 ) s = 59.999;\n          sqlite3_snprintf(7, &z[j],\"%06.3f\", s);\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'H':  sqlite3_snprintf(3, &z[j],\"%02d\",x.h); j+=2; break;\n        case 'W': /* Fall thru */\n        case 'j': {\n          int nDay;             /* Number of days since 1st day of year */\n          DateTime y = x;\n          y.validJD = 0;\n          y.M = 1;\n          y.D = 1;\n          computeJD(&y);\n          nDay = (int)((x.iJD-y.iJD+43200000)/86400000);\n          if( zFmt[i]=='W' ){\n            int wd;   /* 0=Monday, 1=Tuesday, ... 6=Sunday */\n            wd = (int)(((x.iJD+43200000)/86400000)%7);\n            sqlite3_snprintf(3, &z[j],\"%02d\",(nDay+7-wd)/7);\n            j += 2;\n          }else{\n            sqlite3_snprintf(4, &z[j],\"%03d\",nDay+1);\n            j += 3;\n          }\n          break;\n        }\n        case 'J': {\n          sqlite3_snprintf(20, &z[j],\"%.16g\",x.iJD/86400000.0);\n          j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'm':  sqlite3_snprintf(3, &z[j],\"%02d\",x.M); j+=2; break;\n        case 'M':  sqlite3_snprintf(3, &z[j],\"%02d\",x.m); j+=2; break;\n        case 's': {\n          sqlite3_snprintf(30,&z[j],\"%lld\",\n                           (i64)(x.iJD/1000 - 21086676*(i64)10000));\n          j += sqlite3Strlen30(&z[j]);\n          break;\n        }\n        case 'S':  sqlite3_snprintf(3,&z[j],\"%02d\",(int)x.s); j+=2; break;\n        case 'w': {\n          z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0';\n          break;\n        }\n        case 'Y': {\n          sqlite3_snprintf(5,&z[j],\"%04d\",x.Y); j+=sqlite3Strlen30(&z[j]);\n          break;\n        }\n        default:   z[j++] = '%'; break;\n      }\n    }\n  }\n  z[j] = 0;\n  sqlite3_result_text(context, z, -1,\n                      z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC);\n}\n\n/*\n** current_time()\n**\n** This function returns the same value as time('now').\n*/\nstatic void ctimeFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  timeFunc(context, 0, 0);\n}\n\n/*\n** current_date()\n**\n** This function returns the same value as date('now').\n*/\nstatic void cdateFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  dateFunc(context, 0, 0);\n}\n\n/*\n** current_timestamp()\n**\n** This function returns the same value as datetime('now').\n*/\nstatic void ctimestampFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  datetimeFunc(context, 0, 0);\n}\n#endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */\n\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n/*\n** If the library is compiled to omit the full-scale date and time\n** handling (to get a smaller binary), the following minimal version\n** of the functions current_time(), current_date() and current_timestamp()\n** are included instead. This is to support column declarations that\n** include \"DEFAULT CURRENT_TIME\" etc.\n**\n** This function uses the C-library functions time(), gmtime()\n** and strftime(). The format string to pass to strftime() is supplied\n** as the user-data for the function.\n*/\nstatic void currentTimeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  time_t t;\n  char *zFormat = (char *)sqlite3_user_data(context);\n  sqlite3_int64 iT;\n  struct tm *pTm;\n  struct tm sNow;\n  char zBuf[20];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n\n  iT = sqlite3StmtCurrentTime(context);\n  if( iT<=0 ) return;\n  t = iT/1000 - 10000*(sqlite3_int64)21086676;\n#if HAVE_GMTIME_R\n  pTm = gmtime_r(&t, &sNow);\n#else\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  pTm = gmtime(&t);\n  if( pTm ) memcpy(&sNow, pTm, sizeof(sNow));\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n#endif\n  if( pTm ){\n    strftime(zBuf, 20, zFormat, &sNow);\n    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n  }\n}\n#endif\n\n/*\n** This function registered all of the above C functions as SQL\n** functions.  This should be the only routine in this file with\n** external linkage.\n*/\nvoid sqlite3RegisterDateTimeFunctions(void){\n  static FuncDef aDateTimeFuncs[] = {\n#ifndef SQLITE_OMIT_DATETIME_FUNCS\n    PURE_DATE(julianday,        -1, 0, 0, juliandayFunc ),\n    PURE_DATE(date,             -1, 0, 0, dateFunc      ),\n    PURE_DATE(time,             -1, 0, 0, timeFunc      ),\n    PURE_DATE(datetime,         -1, 0, 0, datetimeFunc  ),\n    PURE_DATE(strftime,         -1, 0, 0, strftimeFunc  ),\n    DFUNCTION(current_time,      0, 0, 0, ctimeFunc     ),\n    DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc),\n    DFUNCTION(current_date,      0, 0, 0, cdateFunc     ),\n#else\n    STR_FUNCTION(current_time,      0, \"%H:%M:%S\",          0, currentTimeFunc),\n    STR_FUNCTION(current_date,      0, \"%Y-%m-%d\",          0, currentTimeFunc),\n    STR_FUNCTION(current_timestamp, 0, \"%Y-%m-%d %H:%M:%S\", 0, currentTimeFunc),\n#endif\n  };\n  sqlite3InsertBuiltinFuncs(aDateTimeFuncs, ArraySize(aDateTimeFuncs));\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/dbpage.c",
    "content": "/*\n** 2017-10-11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"sqlite_dbpage\" virtual table.\n**\n** The sqlite_dbpage virtual table is used to read or write whole raw\n** pages of the database file.  The pager interface is used so that \n** uncommitted changes and changes recorded in the WAL file are correctly\n** retrieved.\n**\n** Usage example:\n**\n**    SELECT data FROM sqlite_dbpage('aux1') WHERE pgno=123;\n**\n** This is an eponymous virtual table so it does not need to be created before\n** use.  The optional argument to the sqlite_dbpage() table name is the\n** schema for the database file that is to be read.  The default schema is\n** \"main\".\n**\n** The data field of sqlite_dbpage table can be updated.  The new\n** value must be a BLOB which is the correct page size, otherwise the\n** update fails.  Rows may not be deleted or inserted.\n*/\n\n#include \"sqliteInt.h\"   /* Requires access to internal data structures */\n#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\ntypedef struct DbpageTable DbpageTable;\ntypedef struct DbpageCursor DbpageCursor;\n\nstruct DbpageCursor {\n  sqlite3_vtab_cursor base;       /* Base class.  Must be first */\n  int pgno;                       /* Current page number */\n  int mxPgno;                     /* Last page to visit on this scan */\n};\n\nstruct DbpageTable {\n  sqlite3_vtab base;              /* Base class.  Must be first */\n  sqlite3 *db;                    /* The database */\n  Pager *pPager;                  /* Pager being read/written */\n  int iDb;                        /* Index of database to analyze */\n  int szPage;                     /* Size of each page in bytes */\n  int nPage;                      /* Number of pages in the file */\n};\n\n/*\n** Connect to or create a dbpagevfs virtual table.\n*/\nstatic int dbpageConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  DbpageTable *pTab = 0;\n  int rc = SQLITE_OK;\n  int iDb;\n\n  if( argc>=4 ){\n    Token nm;\n    sqlite3TokenInit(&nm, (char*)argv[3]);\n    iDb = sqlite3FindDb(db, &nm);\n    if( iDb<0 ){\n      *pzErr = sqlite3_mprintf(\"no such schema: %s\", argv[3]);\n      return SQLITE_ERROR;\n    }\n  }else{\n    iDb = 0;\n  }\n  rc = sqlite3_declare_vtab(db, \n          \"CREATE TABLE x(pgno INTEGER PRIMARY KEY, data BLOB, schema HIDDEN)\");\n  if( rc==SQLITE_OK ){\n    pTab = (DbpageTable *)sqlite3_malloc64(sizeof(DbpageTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    Btree *pBt = db->aDb[iDb].pBt;\n    memset(pTab, 0, sizeof(DbpageTable));\n    pTab->db = db;\n    pTab->iDb = iDb;\n    pTab->pPager = pBt ? sqlite3BtreePager(pBt) : 0;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a dbpagevfs virtual table.\n*/\nstatic int dbpageDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** idxNum:\n**\n**     0     full table scan\n**     1     pgno=?1\n*/\nstatic int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n  pIdxInfo->estimatedCost = 1.0e6;  /* Initial cost estimate */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[i];\n    if( p->usable && p->iColumn<=0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      pIdxInfo->estimatedRows = 1;\n      pIdxInfo->idxFlags = SQLITE_INDEX_SCAN_UNIQUE;\n      pIdxInfo->estimatedCost = 1.0;\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n      pIdxInfo->aConstraintUsage[i].omit = 1;\n      break;\n    }\n  }\n  if( pIdxInfo->nOrderBy>=1\n   && pIdxInfo->aOrderBy[0].iColumn<=0\n   && pIdxInfo->aOrderBy[0].desc==0\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Open a new dbpagevfs cursor.\n*/\nstatic int dbpageOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  DbpageCursor *pCsr;\n\n  pCsr = (DbpageCursor *)sqlite3_malloc64(sizeof(DbpageCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(DbpageCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->pgno = -1;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\n/*\n** Close a dbpagevfs cursor.\n*/\nstatic int dbpageClose(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Move a dbpagevfs cursor to the next entry in the file.\n*/\nstatic int dbpageNext(sqlite3_vtab_cursor *pCursor){\n  int rc = SQLITE_OK;\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  pCsr->pgno++;\n  return rc;\n}\n\nstatic int dbpageEof(sqlite3_vtab_cursor *pCursor){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  return pCsr->pgno > pCsr->mxPgno;\n}\n\nstatic int dbpageFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;\n\n  pTab->szPage = sqlite3BtreeGetPageSize(pBt);\n  pTab->nPage = sqlite3BtreeLastPage(pBt);\n  if( idxNum==1 ){\n    pCsr->pgno = sqlite3_value_int(argv[0]);\n    if( pCsr->pgno<1 || pCsr->pgno>pTab->nPage ){\n      pCsr->pgno = 1;\n      pCsr->mxPgno = 0;\n    }else{\n      pCsr->mxPgno = pCsr->pgno;\n    }\n  }else{\n    pCsr->pgno = 1;\n    pCsr->mxPgno = pTab->nPage;\n  }\n  return rc;\n}\n\nstatic int dbpageColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  switch( i ){\n    case 0: {           /* pgno */\n      sqlite3_result_int(ctx, pCsr->pgno);\n      break;\n    }\n    case 1: {           /* data */\n      DbPage *pDbPage = 0;\n      rc = sqlite3PagerGet(pTab->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);\n      if( rc==SQLITE_OK ){\n        sqlite3_result_blob(ctx, sqlite3PagerGetData(pDbPage), pTab->szPage,\n                            SQLITE_TRANSIENT);\n      }\n      sqlite3PagerUnref(pDbPage);\n      break;\n    }\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      sqlite3_result_text(ctx, db->aDb[pTab->iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  DbpageCursor *pCsr = (DbpageCursor *)pCursor;\n  *pRowid = pCsr->pgno;\n  return SQLITE_OK;\n}\n\nstatic int dbpageUpdate(\n  sqlite3_vtab *pVtab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  DbpageTable *pTab = (DbpageTable *)pVtab;\n  int pgno;\n  DbPage *pDbPage = 0;\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n\n  if( argc==1 ){\n    zErr = \"cannot delete\";\n    goto update_fail;\n  }\n  pgno = sqlite3_value_int(argv[0]);\n  if( pgno<1 || pgno>pTab->nPage ){\n    zErr = \"bad page number\";\n    goto update_fail;\n  }\n  if( sqlite3_value_int(argv[1])!=pgno ){\n    zErr = \"cannot insert\";\n    goto update_fail;\n  }\n  if( sqlite3_value_type(argv[3])!=SQLITE_BLOB \n   || sqlite3_value_bytes(argv[3])!=pTab->szPage \n  ){\n    zErr = \"bad page value\";\n    goto update_fail;\n  }\n  rc = sqlite3PagerGet(pTab->pPager, pgno, (DbPage**)&pDbPage, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerWrite(pDbPage);\n    if( rc==SQLITE_OK ){\n      memcpy(sqlite3PagerGetData(pDbPage),\n             sqlite3_value_blob(argv[3]),\n             pTab->szPage);\n    }\n  }\n  sqlite3PagerUnref(pDbPage);\n  return rc;\n\nupdate_fail:\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n  return SQLITE_ERROR;\n}\n\n/*\n** Invoke this routine to register the \"dbpage\" virtual table module\n*/\nint sqlite3DbpageRegister(sqlite3 *db){\n  static sqlite3_module dbpage_module = {\n    0,                            /* iVersion */\n    dbpageConnect,                /* xCreate */\n    dbpageConnect,                /* xConnect */\n    dbpageBestIndex,              /* xBestIndex */\n    dbpageDisconnect,             /* xDisconnect */\n    dbpageDisconnect,             /* xDestroy */\n    dbpageOpen,                   /* xOpen - open a cursor */\n    dbpageClose,                  /* xClose - close a cursor */\n    dbpageFilter,                 /* xFilter - configure scan constraints */\n    dbpageNext,                   /* xNext - advance a cursor */\n    dbpageEof,                    /* xEof - check for end of scan */\n    dbpageColumn,                 /* xColumn - read data */\n    dbpageRowid,                  /* xRowid - read data */\n    dbpageUpdate,                 /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n  };\n  return sqlite3_create_module(db, \"sqlite_dbpage\", &dbpage_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBPAGE_VTAB)\nint sqlite3DbpageRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/dbstat.c",
    "content": "/*\n** 2010 July 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains an implementation of the \"dbstat\" virtual table.\n**\n** The dbstat virtual table is used to extract low-level formatting\n** information from an SQLite database in order to implement the\n** \"sqlite3_analyzer\" utility.  See the ../tool/spaceanal.tcl script\n** for an example implementation.\n**\n** Additional information is available on the \"dbstat.html\" page of the\n** official SQLite documentation.\n*/\n\n#include \"sqliteInt.h\"   /* Requires access to internal data structures */\n#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \\\n    && !defined(SQLITE_OMIT_VIRTUALTABLE)\n\n/*\n** Page paths:\n** \n**   The value of the 'path' column describes the path taken from the \n**   root-node of the b-tree structure to each page. The value of the \n**   root-node path is '/'.\n**\n**   The value of the path for the left-most child page of the root of\n**   a b-tree is '/000/'. (Btrees store content ordered from left to right\n**   so the pages to the left have smaller keys than the pages to the right.)\n**   The next to left-most child of the root page is\n**   '/001', and so on, each sibling page identified by a 3-digit hex \n**   value. The children of the 451st left-most sibling have paths such\n**   as '/1c2/000/, '/1c2/001/' etc.\n**\n**   Overflow pages are specified by appending a '+' character and a \n**   six-digit hexadecimal value to the path to the cell they are linked\n**   from. For example, the three overflow pages in a chain linked from \n**   the left-most cell of the 450th child of the root page are identified\n**   by the paths:\n**\n**      '/1c2/000+000000'         // First page in overflow chain\n**      '/1c2/000+000001'         // Second page in overflow chain\n**      '/1c2/000+000002'         // Third page in overflow chain\n**\n**   If the paths are sorted using the BINARY collation sequence, then\n**   the overflow pages associated with a cell will appear earlier in the\n**   sort-order than its child page:\n**\n**      '/1c2/000/'               // Left-most child of 451st child of root\n*/\n#define VTAB_SCHEMA                                                         \\\n  \"CREATE TABLE xx( \"                                                       \\\n  \"  name       TEXT,             /* Name of table or index */\"             \\\n  \"  path       TEXT,             /* Path to page from root */\"             \\\n  \"  pageno     INTEGER,          /* Page number */\"                        \\\n  \"  pagetype   TEXT,             /* 'internal', 'leaf' or 'overflow' */\"   \\\n  \"  ncell      INTEGER,          /* Cells on page (0 for overflow) */\"     \\\n  \"  payload    INTEGER,          /* Bytes of payload on this page */\"      \\\n  \"  unused     INTEGER,          /* Bytes of unused space on this page */\" \\\n  \"  mx_payload INTEGER,          /* Largest payload size of all cells */\"  \\\n  \"  pgoffset   INTEGER,          /* Offset of page in file */\"             \\\n  \"  pgsize     INTEGER,          /* Size of the page */\"                   \\\n  \"  schema     TEXT HIDDEN       /* Database schema being analyzed */\"     \\\n  \");\"\n\n\ntypedef struct StatTable StatTable;\ntypedef struct StatCursor StatCursor;\ntypedef struct StatPage StatPage;\ntypedef struct StatCell StatCell;\n\nstruct StatCell {\n  int nLocal;                     /* Bytes of local payload */\n  u32 iChildPg;                   /* Child node (or 0 if this is a leaf) */\n  int nOvfl;                      /* Entries in aOvfl[] */\n  u32 *aOvfl;                     /* Array of overflow page numbers */\n  int nLastOvfl;                  /* Bytes of payload on final overflow page */\n  int iOvfl;                      /* Iterates through aOvfl[] */\n};\n\nstruct StatPage {\n  u32 iPgno;\n  DbPage *pPg;\n  int iCell;\n\n  char *zPath;                    /* Path to this page */\n\n  /* Variables populated by statDecodePage(): */\n  u8 flags;                       /* Copy of flags byte */\n  int nCell;                      /* Number of cells on page */\n  int nUnused;                    /* Number of unused bytes on page */\n  StatCell *aCell;                /* Array of parsed cells */\n  u32 iRightChildPg;              /* Right-child page number (or 0) */\n  int nMxPayload;                 /* Largest payload of any cell on this page */\n};\n\nstruct StatCursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Iterates through set of root pages */\n  int isEof;                      /* After pStmt has returned SQLITE_DONE */\n  int iDb;                        /* Schema used for this query */\n\n  StatPage aPage[32];\n  int iPage;                      /* Current entry in aPage[] */\n\n  /* Values to return. */\n  char *zName;                    /* Value of 'name' column */\n  char *zPath;                    /* Value of 'path' column */\n  u32 iPageno;                    /* Value of 'pageno' column */\n  char *zPagetype;                /* Value of 'pagetype' column */\n  int nCell;                      /* Value of 'ncell' column */\n  int nPayload;                   /* Value of 'payload' column */\n  int nUnused;                    /* Value of 'unused' column */\n  int nMxPayload;                 /* Value of 'mx_payload' column */\n  i64 iOffset;                    /* Value of 'pgOffset' column */\n  int szPage;                     /* Value of 'pgSize' column */\n};\n\nstruct StatTable {\n  sqlite3_vtab base;\n  sqlite3 *db;\n  int iDb;                        /* Index of database to analyze */\n};\n\n#ifndef get2byte\n# define get2byte(x)   ((x)[0]<<8 | (x)[1])\n#endif\n\n/*\n** Connect to or create a statvfs virtual table.\n*/\nstatic int statConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  StatTable *pTab = 0;\n  int rc = SQLITE_OK;\n  int iDb;\n\n  if( argc>=4 ){\n    Token nm;\n    sqlite3TokenInit(&nm, (char*)argv[3]);\n    iDb = sqlite3FindDb(db, &nm);\n    if( iDb<0 ){\n      *pzErr = sqlite3_mprintf(\"no such database: %s\", argv[3]);\n      return SQLITE_ERROR;\n    }\n  }else{\n    iDb = 0;\n  }\n  rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);\n  if( rc==SQLITE_OK ){\n    pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));\n    if( pTab==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n  assert( rc==SQLITE_OK || pTab==0 );\n  if( rc==SQLITE_OK ){\n    memset(pTab, 0, sizeof(StatTable));\n    pTab->db = db;\n    pTab->iDb = iDb;\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/*\n** Disconnect from or destroy a statvfs virtual table.\n*/\nstatic int statDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** There is no \"best-index\". This virtual table always does a linear\n** scan.  However, a schema=? constraint should cause this table to\n** operate on a different database schema, so check for it.\n**\n** idxNum is normally 0, but will be 1 if a schema=? constraint exists.\n*/\nstatic int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int i;\n\n  pIdxInfo->estimatedCost = 1.0e6;  /* Initial cost estimate */\n\n  /* Look for a valid schema=? constraint.  If found, change the idxNum to\n  ** 1 and request the value of that constraint be sent to xFilter.  And\n  ** lower the cost estimate to encourage the constrained version to be\n  ** used.\n  */\n  for(i=0; i<pIdxInfo->nConstraint; i++){\n    if( pIdxInfo->aConstraint[i].usable==0 ) continue;\n    if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue;\n    pIdxInfo->idxNum = 1;\n    pIdxInfo->estimatedCost = 1.0;\n    pIdxInfo->aConstraintUsage[i].argvIndex = 1;\n    pIdxInfo->aConstraintUsage[i].omit = 1;\n    break;\n  }\n\n\n  /* Records are always returned in ascending order of (name, path). \n  ** If this will satisfy the client, set the orderByConsumed flag so that \n  ** SQLite does not do an external sort.\n  */\n  if( ( pIdxInfo->nOrderBy==1\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     ) ||\n      ( pIdxInfo->nOrderBy==2\n     && pIdxInfo->aOrderBy[0].iColumn==0\n     && pIdxInfo->aOrderBy[0].desc==0\n     && pIdxInfo->aOrderBy[1].iColumn==1\n     && pIdxInfo->aOrderBy[1].desc==0\n     )\n  ){\n    pIdxInfo->orderByConsumed = 1;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Open a new statvfs cursor.\n*/\nstatic int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  StatTable *pTab = (StatTable *)pVTab;\n  StatCursor *pCsr;\n\n  pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor));\n  if( pCsr==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    memset(pCsr, 0, sizeof(StatCursor));\n    pCsr->base.pVtab = pVTab;\n    pCsr->iDb = pTab->iDb;\n  }\n\n  *ppCursor = (sqlite3_vtab_cursor *)pCsr;\n  return SQLITE_OK;\n}\n\nstatic void statClearPage(StatPage *p){\n  int i;\n  if( p->aCell ){\n    for(i=0; i<p->nCell; i++){\n      sqlite3_free(p->aCell[i].aOvfl);\n    }\n    sqlite3_free(p->aCell);\n  }\n  sqlite3PagerUnref(p->pPg);\n  sqlite3_free(p->zPath);\n  memset(p, 0, sizeof(StatPage));\n}\n\nstatic void statResetCsr(StatCursor *pCsr){\n  int i;\n  sqlite3_reset(pCsr->pStmt);\n  for(i=0; i<ArraySize(pCsr->aPage); i++){\n    statClearPage(&pCsr->aPage[i]);\n  }\n  pCsr->iPage = 0;\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n  pCsr->isEof = 0;\n}\n\n/*\n** Close a statvfs cursor.\n*/\nstatic int statClose(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\nstatic void getLocalPayload(\n  int nUsable,                    /* Usable bytes per page */\n  u8 flags,                       /* Page flags */\n  int nTotal,                     /* Total record (payload) size */\n  int *pnLocal                    /* OUT: Bytes stored locally */\n){\n  int nLocal;\n  int nMinLocal;\n  int nMaxLocal;\n \n  if( flags==0x0D ){              /* Table leaf node */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = nUsable - 35;\n  }else{                          /* Index interior and leaf nodes */\n    nMinLocal = (nUsable - 12) * 32 / 255 - 23;\n    nMaxLocal = (nUsable - 12) * 64 / 255 - 23;\n  }\n\n  nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);\n  if( nLocal>nMaxLocal ) nLocal = nMinLocal;\n  *pnLocal = nLocal;\n}\n\nstatic int statDecodePage(Btree *pBt, StatPage *p){\n  int nUnused;\n  int iOff;\n  int nHdr;\n  int isLeaf;\n  int szPage;\n\n  u8 *aData = sqlite3PagerGetData(p->pPg);\n  u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];\n\n  p->flags = aHdr[0];\n  p->nCell = get2byte(&aHdr[3]);\n  p->nMxPayload = 0;\n\n  isLeaf = (p->flags==0x0A || p->flags==0x0D);\n  nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;\n\n  nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;\n  nUnused += (int)aHdr[7];\n  iOff = get2byte(&aHdr[1]);\n  while( iOff ){\n    nUnused += get2byte(&aData[iOff+2]);\n    iOff = get2byte(&aData[iOff]);\n  }\n  p->nUnused = nUnused;\n  p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);\n  szPage = sqlite3BtreeGetPageSize(pBt);\n\n  if( p->nCell ){\n    int i;                        /* Used to iterate through cells */\n    int nUsable;                  /* Usable bytes per page */\n\n    sqlite3BtreeEnter(pBt);\n    nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);\n    sqlite3BtreeLeave(pBt);\n    p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell));\n    if( p->aCell==0 ) return SQLITE_NOMEM_BKPT;\n    memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));\n\n    for(i=0; i<p->nCell; i++){\n      StatCell *pCell = &p->aCell[i];\n\n      iOff = get2byte(&aData[nHdr+i*2]);\n      if( !isLeaf ){\n        pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);\n        iOff += 4;\n      }\n      if( p->flags==0x05 ){\n        /* A table interior node. nPayload==0. */\n      }else{\n        u32 nPayload;             /* Bytes of payload total (local+overflow) */\n        int nLocal;               /* Bytes of payload stored locally */\n        iOff += getVarint32(&aData[iOff], nPayload);\n        if( p->flags==0x0D ){\n          u64 dummy;\n          iOff += sqlite3GetVarint(&aData[iOff], &dummy);\n        }\n        if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;\n        getLocalPayload(nUsable, p->flags, nPayload, &nLocal);\n        pCell->nLocal = nLocal;\n        assert( nLocal>=0 );\n        assert( nPayload>=(u32)nLocal );\n        assert( nLocal<=(nUsable-35) );\n        if( nPayload>(u32)nLocal ){\n          int j;\n          int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);\n          pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4);\n          pCell->nOvfl = nOvfl;\n          pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl);\n          if( pCell->aOvfl==0 ) return SQLITE_NOMEM_BKPT;\n          pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]);\n          for(j=1; j<nOvfl; j++){\n            int rc;\n            u32 iPrev = pCell->aOvfl[j-1];\n            DbPage *pPg = 0;\n            rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0);\n            if( rc!=SQLITE_OK ){\n              assert( pPg==0 );\n              return rc;\n            } \n            pCell->aOvfl[j] = sqlite3Get4byte(sqlite3PagerGetData(pPg));\n            sqlite3PagerUnref(pPg);\n          }\n        }\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on\n** the current value of pCsr->iPageno.\n*/\nstatic void statSizeAndOffset(StatCursor *pCsr){\n  StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;\n  Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n  sqlite3_file *fd;\n  sqlite3_int64 x[2];\n\n  /* The default page size and offset */\n  pCsr->szPage = sqlite3BtreeGetPageSize(pBt);\n  pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);\n\n  /* If connected to a ZIPVFS backend, override the page size and\n  ** offset with actual values obtained from ZIPVFS.\n  */\n  fd = sqlite3PagerFile(pPager);\n  x[0] = pCsr->iPageno;\n  if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){\n    pCsr->iOffset = x[0];\n    pCsr->szPage = (int)x[1];\n  }\n}\n\n/*\n** Move a statvfs cursor to the next entry in the file.\n*/\nstatic int statNext(sqlite3_vtab_cursor *pCursor){\n  int rc;\n  int nPayload;\n  char *z;\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable *)pCursor->pVtab;\n  Btree *pBt = pTab->db->aDb[pCsr->iDb].pBt;\n  Pager *pPager = sqlite3BtreePager(pBt);\n\n  sqlite3_free(pCsr->zPath);\n  pCsr->zPath = 0;\n\nstatNextRestart:\n  if( pCsr->aPage[0].pPg==0 ){\n    rc = sqlite3_step(pCsr->pStmt);\n    if( rc==SQLITE_ROW ){\n      int nPage;\n      u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);\n      sqlite3PagerPagecount(pPager, &nPage);\n      if( nPage==0 ){\n        pCsr->isEof = 1;\n        return sqlite3_reset(pCsr->pStmt);\n      }\n      rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0);\n      pCsr->aPage[0].iPgno = iRoot;\n      pCsr->aPage[0].iCell = 0;\n      pCsr->aPage[0].zPath = z = sqlite3_mprintf(\"/\");\n      pCsr->iPage = 0;\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n    }else{\n      pCsr->isEof = 1;\n      return sqlite3_reset(pCsr->pStmt);\n    }\n  }else{\n\n    /* Page p itself has already been visited. */\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n\n    while( p->iCell<p->nCell ){\n      StatCell *pCell = &p->aCell[p->iCell];\n      if( pCell->iOvfl<pCell->nOvfl ){\n        int nUsable;\n        sqlite3BtreeEnter(pBt);\n        nUsable = sqlite3BtreeGetPageSize(pBt) - \n                        sqlite3BtreeGetReserveNoMutex(pBt);\n        sqlite3BtreeLeave(pBt);\n        pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n        pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];\n        pCsr->zPagetype = \"overflow\";\n        pCsr->nCell = 0;\n        pCsr->nMxPayload = 0;\n        pCsr->zPath = z = sqlite3_mprintf(\n            \"%s%.3x+%.6x\", p->zPath, p->iCell, pCell->iOvfl\n        );\n        if( pCell->iOvfl<pCell->nOvfl-1 ){\n          pCsr->nUnused = 0;\n          pCsr->nPayload = nUsable - 4;\n        }else{\n          pCsr->nPayload = pCell->nLastOvfl;\n          pCsr->nUnused = nUsable - 4 - pCsr->nPayload;\n        }\n        pCell->iOvfl++;\n        statSizeAndOffset(pCsr);\n        return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n      }\n      if( p->iRightChildPg ) break;\n      p->iCell++;\n    }\n\n    if( !p->iRightChildPg || p->iCell>p->nCell ){\n      statClearPage(p);\n      if( pCsr->iPage==0 ) return statNext(pCursor);\n      pCsr->iPage--;\n      goto statNextRestart; /* Tail recursion */\n    }\n    pCsr->iPage++;\n    assert( p==&pCsr->aPage[pCsr->iPage-1] );\n\n    if( p->iCell==p->nCell ){\n      p[1].iPgno = p->iRightChildPg;\n    }else{\n      p[1].iPgno = p->aCell[p->iCell].iChildPg;\n    }\n    rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0);\n    p[1].iCell = 0;\n    p[1].zPath = z = sqlite3_mprintf(\"%s%.3x/\", p->zPath, p->iCell);\n    p->iCell++;\n    if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n\n\n  /* Populate the StatCursor fields with the values to be returned\n  ** by the xColumn() and xRowid() methods.\n  */\n  if( rc==SQLITE_OK ){\n    int i;\n    StatPage *p = &pCsr->aPage[pCsr->iPage];\n    pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);\n    pCsr->iPageno = p->iPgno;\n\n    rc = statDecodePage(pBt, p);\n    if( rc==SQLITE_OK ){\n      statSizeAndOffset(pCsr);\n\n      switch( p->flags ){\n        case 0x05:             /* table internal */\n        case 0x02:             /* index internal */\n          pCsr->zPagetype = \"internal\";\n          break;\n        case 0x0D:             /* table leaf */\n        case 0x0A:             /* index leaf */\n          pCsr->zPagetype = \"leaf\";\n          break;\n        default:\n          pCsr->zPagetype = \"corrupted\";\n          break;\n      }\n      pCsr->nCell = p->nCell;\n      pCsr->nUnused = p->nUnused;\n      pCsr->nMxPayload = p->nMxPayload;\n      pCsr->zPath = z = sqlite3_mprintf(\"%s\", p->zPath);\n      if( z==0 ) rc = SQLITE_NOMEM_BKPT;\n      nPayload = 0;\n      for(i=0; i<p->nCell; i++){\n        nPayload += p->aCell[i].nLocal;\n      }\n      pCsr->nPayload = nPayload;\n    }\n  }\n\n  return rc;\n}\n\nstatic int statEof(sqlite3_vtab_cursor *pCursor){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  return pCsr->isEof;\n}\n\nstatic int statFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  StatTable *pTab = (StatTable*)(pCursor->pVtab);\n  char *zSql;\n  int rc = SQLITE_OK;\n  char *zMaster;\n\n  if( idxNum==1 ){\n    const char *zDbase = (const char*)sqlite3_value_text(argv[0]);\n    pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase);\n    if( pCsr->iDb<0 ){\n      sqlite3_free(pCursor->pVtab->zErrMsg);\n      pCursor->pVtab->zErrMsg = sqlite3_mprintf(\"no such schema: %s\", zDbase);\n      return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT;\n    }\n  }else{\n    pCsr->iDb = pTab->iDb;\n  }\n  statResetCsr(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  pCsr->pStmt = 0;\n  zMaster = pCsr->iDb==1 ? \"sqlite_temp_master\" : \"sqlite_master\";\n  zSql = sqlite3_mprintf(\n      \"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type\"\n      \"  UNION ALL  \"\n      \"SELECT name, rootpage, type\"\n      \"  FROM \\\"%w\\\".%s WHERE rootpage!=0\"\n      \"  ORDER BY name\", pTab->db->aDb[pCsr->iDb].zDbSName, zMaster);\n  if( zSql==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);\n    sqlite3_free(zSql);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = statNext(pCursor);\n  }\n  return rc;\n}\n\nstatic int statColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  switch( i ){\n    case 0:            /* name */\n      sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);\n      break;\n    case 1:            /* path */\n      sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);\n      break;\n    case 2:            /* pageno */\n      sqlite3_result_int64(ctx, pCsr->iPageno);\n      break;\n    case 3:            /* pagetype */\n      sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);\n      break;\n    case 4:            /* ncell */\n      sqlite3_result_int(ctx, pCsr->nCell);\n      break;\n    case 5:            /* payload */\n      sqlite3_result_int(ctx, pCsr->nPayload);\n      break;\n    case 6:            /* unused */\n      sqlite3_result_int(ctx, pCsr->nUnused);\n      break;\n    case 7:            /* mx_payload */\n      sqlite3_result_int(ctx, pCsr->nMxPayload);\n      break;\n    case 8:            /* pgoffset */\n      sqlite3_result_int64(ctx, pCsr->iOffset);\n      break;\n    case 9:            /* pgsize */\n      sqlite3_result_int(ctx, pCsr->szPage);\n      break;\n    default: {          /* schema */\n      sqlite3 *db = sqlite3_context_db_handle(ctx);\n      int iDb = pCsr->iDb;\n      sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  StatCursor *pCsr = (StatCursor *)pCursor;\n  *pRowid = pCsr->iPageno;\n  return SQLITE_OK;\n}\n\n/*\n** Invoke this routine to register the \"dbstat\" virtual table module\n*/\nint sqlite3DbstatRegister(sqlite3 *db){\n  static sqlite3_module dbstat_module = {\n    0,                            /* iVersion */\n    statConnect,                  /* xCreate */\n    statConnect,                  /* xConnect */\n    statBestIndex,                /* xBestIndex */\n    statDisconnect,               /* xDisconnect */\n    statDisconnect,               /* xDestroy */\n    statOpen,                     /* xOpen - open a cursor */\n    statClose,                    /* xClose - close a cursor */\n    statFilter,                   /* xFilter - configure scan constraints */\n    statNext,                     /* xNext - advance a cursor */\n    statEof,                      /* xEof - check for end of scan */\n    statColumn,                   /* xColumn - read data */\n    statRowid,                    /* xRowid - read data */\n    0,                            /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n    0,                            /* xSavepoint */\n    0,                            /* xRelease */\n    0,                            /* xRollbackTo */\n  };\n  return sqlite3_create_module(db, \"dbstat\", &dbstat_module, 0);\n}\n#elif defined(SQLITE_ENABLE_DBSTAT_VTAB)\nint sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; }\n#endif /* SQLITE_ENABLE_DBSTAT_VTAB */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/delete.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** in order to generate code for DELETE FROM statements.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** While a SrcList can in general represent multiple tables and subqueries\n** (as in the FROM clause of a SELECT statement) in this case it contains\n** the name of a single table, as one might find in an INSERT, DELETE,\n** or UPDATE statement.  Look up that table in the symbol table and\n** return a pointer.  Set an error message and return NULL if the table \n** name is not found or if any other error occurs.\n**\n** The following fields are initialized appropriate in pSrc:\n**\n**    pSrc->a[0].pTab       Pointer to the Table object\n**    pSrc->a[0].pIndex     Pointer to the INDEXED BY index, if there is one\n**\n*/\nTable *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){\n  struct SrcList_item *pItem = pSrc->a;\n  Table *pTab;\n  assert( pItem && pSrc->nSrc==1 );\n  pTab = sqlite3LocateTableItem(pParse, 0, pItem);\n  sqlite3DeleteTable(pParse->db, pItem->pTab);\n  pItem->pTab = pTab;\n  if( pTab ){\n    pTab->nTabRef++;\n  }\n  if( sqlite3IndexedByLookup(pParse, pItem) ){\n    pTab = 0;\n  }\n  return pTab;\n}\n\n/*\n** Check to make sure the given table is writable.  If it is not\n** writable, generate an error message and return 1.  If it is\n** writable return 0;\n*/\nint sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){\n  /* A table is not writable under the following circumstances:\n  **\n  **   1) It is a virtual table and no implementation of the xUpdate method\n  **      has been provided, or\n  **   2) It is a system table (i.e. sqlite_master), this call is not\n  **      part of a nested parse and writable_schema pragma has not \n  **      been specified.\n  **\n  ** In either case leave an error message in pParse and return non-zero.\n  */\n  if( ( IsVirtual(pTab) \n     && sqlite3GetVTable(pParse->db, pTab)->pMod->pModule->xUpdate==0 )\n   || ( (pTab->tabFlags & TF_Readonly)!=0\n     && (pParse->db->flags & SQLITE_WriteSchema)==0\n     && pParse->nested==0 )\n  ){\n    sqlite3ErrorMsg(pParse, \"table %s may not be modified\", pTab->zName);\n    return 1;\n  }\n\n#ifndef SQLITE_OMIT_VIEW\n  if( !viewOk && pTab->pSelect ){\n    sqlite3ErrorMsg(pParse,\"cannot modify %s because it is a view\",pTab->zName);\n    return 1;\n  }\n#endif\n  return 0;\n}\n\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n/*\n** Evaluate a view and store its result in an ephemeral table.  The\n** pWhere argument is an optional WHERE clause that restricts the\n** set of rows in the view that are to be added to the ephemeral table.\n*/\nvoid sqlite3MaterializeView(\n  Parse *pParse,       /* Parsing context */\n  Table *pView,        /* View definition */\n  Expr *pWhere,        /* Optional WHERE clause to be added */\n  int iCur             /* Cursor number for ephemeral table */\n){\n  SelectDest dest;\n  Select *pSel;\n  SrcList *pFrom;\n  sqlite3 *db = pParse->db;\n  int iDb = sqlite3SchemaToIndex(db, pView->pSchema);\n  pWhere = sqlite3ExprDup(db, pWhere, 0);\n  pFrom = sqlite3SrcListAppend(db, 0, 0, 0);\n  if( pFrom ){\n    assert( pFrom->nSrc==1 );\n    pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);\n    pFrom->a[0].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zDbSName);\n    assert( pFrom->a[0].pOn==0 );\n    assert( pFrom->a[0].pUsing==0 );\n  }\n  pSel = sqlite3SelectNew(pParse, 0, pFrom, pWhere, 0, 0, 0, \n                          SF_IncludeHidden, 0, 0);\n  sqlite3SelectDestInit(&dest, SRT_EphemTab, iCur);\n  sqlite3Select(pParse, pSel, &dest);\n  sqlite3SelectDelete(db, pSel);\n}\n#endif /* !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) */\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Generate an expression tree to implement the WHERE, ORDER BY,\n** and LIMIT/OFFSET portion of DELETE and UPDATE statements.\n**\n**     DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;\n**                            \\__________________________/\n**                               pLimitWhere (pInClause)\n*/\nExpr *sqlite3LimitWhere(\n  Parse *pParse,               /* The parser context */\n  SrcList *pSrc,               /* the FROM clause -- which tables to scan */\n  Expr *pWhere,                /* The WHERE clause.  May be null */\n  ExprList *pOrderBy,          /* The ORDER BY clause.  May be null */\n  Expr *pLimit,                /* The LIMIT clause.  May be null */\n  Expr *pOffset,               /* The OFFSET clause.  May be null */\n  char *zStmtType              /* Either DELETE or UPDATE.  For err msgs. */\n){\n  Expr *pWhereRowid = NULL;    /* WHERE rowid .. */\n  Expr *pInClause = NULL;      /* WHERE rowid IN ( select ) */\n  Expr *pSelectRowid = NULL;   /* SELECT rowid ... */\n  ExprList *pEList = NULL;     /* Expression list contaning only pSelectRowid */\n  SrcList *pSelectSrc = NULL;  /* SELECT rowid FROM x ... (dup of pSrc) */\n  Select *pSelect = NULL;      /* Complete SELECT tree */\n\n  /* Check that there isn't an ORDER BY without a LIMIT clause.\n  */\n  if( pOrderBy && (pLimit == 0) ) {\n    sqlite3ErrorMsg(pParse, \"ORDER BY without LIMIT on %s\", zStmtType);\n    goto limit_where_cleanup;\n  }\n\n  /* We only need to generate a select expression if there\n  ** is a limit/offset term to enforce.\n  */\n  if( pLimit == 0 ) {\n    /* if pLimit is null, pOffset will always be null as well. */\n    assert( pOffset == 0 );\n    return pWhere;\n  }\n\n  /* Generate a select expression tree to enforce the limit/offset \n  ** term for the DELETE or UPDATE statement.  For example:\n  **   DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  ** becomes:\n  **   DELETE FROM table_a WHERE rowid IN ( \n  **     SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1\n  **   );\n  */\n\n  pSelectRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0);\n  if( pSelectRowid == 0 ) goto limit_where_cleanup;\n  pEList = sqlite3ExprListAppend(pParse, 0, pSelectRowid);\n  if( pEList == 0 ) goto limit_where_cleanup;\n\n  /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree\n  ** and the SELECT subtree. */\n  pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0);\n  if( pSelectSrc == 0 ) {\n    sqlite3ExprListDelete(pParse->db, pEList);\n    goto limit_where_cleanup;\n  }\n\n  /* generate the SELECT expression tree. */\n  pSelect = sqlite3SelectNew(pParse,pEList,pSelectSrc,pWhere,0,0,\n                             pOrderBy,0,pLimit,pOffset);\n  if( pSelect == 0 ) return 0;\n\n  /* now generate the new WHERE rowid IN clause for the DELETE/UDPATE */\n  pWhereRowid = sqlite3PExpr(pParse, TK_ROW, 0, 0);\n  pInClause = pWhereRowid ? sqlite3PExpr(pParse, TK_IN, pWhereRowid, 0) : 0;\n  sqlite3PExprAddSelect(pParse, pInClause, pSelect);\n  return pInClause;\n\nlimit_where_cleanup:\n  sqlite3ExprDelete(pParse->db, pWhere);\n  sqlite3ExprListDelete(pParse->db, pOrderBy);\n  sqlite3ExprDelete(pParse->db, pLimit);\n  sqlite3ExprDelete(pParse->db, pOffset);\n  return 0;\n}\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) */\n       /*      && !defined(SQLITE_OMIT_SUBQUERY) */\n\n/*\n** Generate code for a DELETE FROM statement.\n**\n**     DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL;\n**                 \\________/       \\________________/\n**                  pTabList              pWhere\n*/\nvoid sqlite3DeleteFrom(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table from which we should delete things */\n  Expr *pWhere           /* The WHERE clause.  May be null */\n){\n  Vdbe *v;               /* The virtual database engine */\n  Table *pTab;           /* The table from which records will be deleted */\n  int i;                 /* Loop counter */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Index *pIdx;           /* For looping over indices of the table */\n  int iTabCur;           /* Cursor number for the table */\n  int iDataCur = 0;      /* VDBE cursor for the canonical data source */\n  int iIdxCur = 0;       /* Cursor number of the first index */\n  int nIdx;              /* Number of indices */\n  sqlite3 *db;           /* Main database structure */\n  AuthContext sContext;  /* Authorization context */\n  NameContext sNC;       /* Name context to resolve expressions in */\n  int iDb;               /* Database number */\n  int memCnt = -1;       /* Memory cell used for change counting */\n  int rcauth;            /* Value returned by authorization callback */\n  int eOnePass;          /* ONEPASS_OFF or _SINGLE or _MULTI */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */\n  Index *pPk;            /* The PRIMARY KEY index on the table */\n  int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */\n  i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */\n  int iKey;              /* Memory cell holding key of row to be deleted */\n  i16 nKey;              /* Number of memory cells in the row key */\n  int iEphCur = 0;       /* Ephemeral table holding all primary key values */\n  int iRowSet = 0;       /* Register for rowset of rows to delete */\n  int addrBypass = 0;    /* Address of jump over the delete logic */\n  int addrLoop = 0;      /* Top of the delete loop */\n  int addrEphOpen = 0;   /* Instruction to open the Ephemeral table */\n  int bComplex;          /* True if there are triggers or FKs or\n                         ** subqueries in the WHERE clause */\n \n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                  /* True if attempting to delete from a view */\n  Trigger *pTrigger;           /* List of table triggers, if required */\n#endif\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto delete_from_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to delete.  This table has to be\n  ** put in an SrcList structure because some of the subroutines we\n  ** will be calling are designed to work with multiple tables and expect\n  ** an SrcList* parameter instead of just a Table* parameter.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 )  goto delete_from_cleanup;\n\n  /* Figure out if we have any triggers and if the table being\n  ** deleted from is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n  isView = pTab->pSelect!=0;\n  bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);\n#else\n# define pTrigger 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  /* If pTab is really a view, make sure it has been initialized.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto delete_from_cleanup;\n  }\n\n  if( sqlite3IsReadOnly(pParse, pTab, (pTrigger?1:0)) ){\n    goto delete_from_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  rcauth = sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, \n                            db->aDb[iDb].zDbSName);\n  assert( rcauth==SQLITE_OK || rcauth==SQLITE_DENY || rcauth==SQLITE_IGNORE );\n  if( rcauth==SQLITE_DENY ){\n    goto delete_from_cleanup;\n  }\n  assert(!isView || pTrigger);\n\n  /* Assign cursor numbers to the table and all its indices.\n  */\n  assert( pTabList->nSrc==1 );\n  iTabCur = pTabList->a[0].iCursor = pParse->nTab++;\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    pParse->nTab++;\n  }\n\n  /* Start the view context\n  */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* Begin generating code.\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ){\n    goto delete_from_cleanup;\n  }\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n  /* If we are trying to delete from a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iTabCur);\n    iDataCur = iIdxCur = iTabCur;\n  }\n#endif\n\n  /* Resolve the column names in the WHERE clause.\n  */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto delete_from_cleanup;\n  }\n\n  /* Initialize the counter of the number of rows deleted, if\n  ** we are counting rows.\n  */\n  if( db->flags & SQLITE_CountRows ){\n    memCnt = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);\n  }\n\n#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  /* Special case: A DELETE without a WHERE clause deletes everything.\n  ** It is easier just to erase the whole table. Prior to version 3.6.5,\n  ** this optimization caused the row change count (the value returned by \n  ** API function sqlite3_count_changes) to be set incorrectly.\n  **\n  ** The \"rcauth==SQLITE_OK\" terms is the\n  ** IMPLEMENTATION-OF: R-17228-37124 If the action code is SQLITE_DELETE and\n  ** the callback returns SQLITE_IGNORE then the DELETE operation proceeds but\n  ** the truncate optimization is disabled and all rows are deleted\n  ** individually.\n  */\n  if( rcauth==SQLITE_OK\n   && pWhere==0\n   && !bComplex\n   && !IsVirtual(pTab)\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n   && db->xPreUpdateCallback==0\n#endif\n  ){\n    assert( !isView );\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);\n    if( HasRowid(pTab) ){\n      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,\n                        pTab->zName, P4_STATIC);\n    }\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      assert( pIdx->pSchema==pTab->pSchema );\n      sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);\n    }\n  }else\n#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */\n  {\n    u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK|WHERE_SEEK_TABLE;\n    if( sNC.ncFlags & NC_VarSelect ) bComplex = 1;\n    wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW);\n    if( HasRowid(pTab) ){\n      /* For a rowid table, initialize the RowSet to an empty set */\n      pPk = 0;\n      nPk = 1;\n      iRowSet = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);\n    }else{\n      /* For a WITHOUT ROWID table, create an ephemeral table used to\n      ** hold all primary keys for rows to be deleted. */\n      pPk = sqlite3PrimaryKeyIndex(pTab);\n      assert( pPk!=0 );\n      nPk = pPk->nKeyCol;\n      iPk = pParse->nMem+1;\n      pParse->nMem += nPk;\n      iEphCur = pParse->nTab++;\n      addrEphOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEphCur, nPk);\n      sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    }\n  \n    /* Construct a query to find the rowid or primary key for every row\n    ** to be deleted, based on the WHERE clause. Set variable eOnePass\n    ** to indicate the strategy used to implement this delete:\n    **\n    **  ONEPASS_OFF:    Two-pass approach - use a FIFO for rowids/PK values.\n    **  ONEPASS_SINGLE: One-pass approach - at most one row deleted.\n    **  ONEPASS_MULTI:  One-pass approach - any number of rows may be deleted.\n    */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);\n    if( pWInfo==0 ) goto delete_from_cleanup;\n    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n    assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );\n    assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );\n  \n    /* Keep track of the number of rows to be deleted */\n    if( db->flags & SQLITE_CountRows ){\n      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);\n    }\n  \n    /* Extract the rowid or primary key for the current row */\n    if( pPk ){\n      for(i=0; i<nPk; i++){\n        assert( pPk->aiColumn[i]>=0 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur,\n                                        pPk->aiColumn[i], iPk+i);\n      }\n      iKey = iPk;\n    }else{\n      iKey = pParse->nMem + 1;\n      iKey = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iTabCur, iKey, 0);\n      if( iKey>pParse->nMem ) pParse->nMem = iKey;\n    }\n  \n    if( eOnePass!=ONEPASS_OFF ){\n      /* For ONEPASS, no need to store the rowid/primary-key. There is only\n      ** one, so just keep it in its register(s) and fall through to the\n      ** delete code.  */\n      nKey = nPk; /* OP_Found will use an unpacked key */\n      aToOpen = sqlite3DbMallocRawNN(db, nIdx+2);\n      if( aToOpen==0 ){\n        sqlite3WhereEnd(pWInfo);\n        goto delete_from_cleanup;\n      }\n      memset(aToOpen, 1, nIdx+1);\n      aToOpen[nIdx+1] = 0;\n      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iTabCur] = 0;\n      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iTabCur] = 0;\n      if( addrEphOpen ) sqlite3VdbeChangeToNoop(v, addrEphOpen);\n    }else{\n      if( pPk ){\n        /* Add the PK key for this row to the temporary table */\n        iKey = ++pParse->nMem;\n        nKey = 0;   /* Zero tells OP_Found to use a composite key */\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey,\n            sqlite3IndexAffinityStr(pParse->db, pPk), nPk);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEphCur, iKey, iPk, nPk);\n      }else{\n        /* Add the rowid of the row to be deleted to the RowSet */\n        nKey = 1;  /* OP_DeferredSeek always uses a single rowid */\n        sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey);\n      }\n    }\n  \n    /* If this DELETE cannot use the ONEPASS strategy, this is the \n    ** end of the WHERE loop */\n    if( eOnePass!=ONEPASS_OFF ){\n      addrBypass = sqlite3VdbeMakeLabel(v);\n    }else{\n      sqlite3WhereEnd(pWInfo);\n    }\n  \n    /* Unless this is a view, open cursors for the table we are \n    ** deleting from and all its indices. If this is a view, then the\n    ** only effect this statement has is to fire the INSTEAD OF \n    ** triggers.\n    */\n    if( !isView ){\n      int iAddrOnce = 0;\n      if( eOnePass==ONEPASS_MULTI ){\n        iAddrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n      }\n      testcase( IsVirtual(pTab) );\n      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, OPFLAG_FORDELETE,\n                                 iTabCur, aToOpen, &iDataCur, &iIdxCur);\n      assert( pPk || IsVirtual(pTab) || iDataCur==iTabCur );\n      assert( pPk || IsVirtual(pTab) || iIdxCur==iDataCur+1 );\n      if( eOnePass==ONEPASS_MULTI ) sqlite3VdbeJumpHere(v, iAddrOnce);\n    }\n  \n    /* Set up a loop over the rowids/primary-keys that were found in the\n    ** where-clause loop above.\n    */\n    if( eOnePass!=ONEPASS_OFF ){\n      assert( nKey==nPk );  /* OP_Found will use an unpacked key */\n      if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){\n        assert( pPk!=0 || pTab->pSelect!=0 );\n        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey);\n        VdbeCoverage(v);\n      }\n    }else if( pPk ){\n      addrLoop = sqlite3VdbeAddOp1(v, OP_Rewind, iEphCur); VdbeCoverage(v);\n      if( IsVirtual(pTab) ){\n        sqlite3VdbeAddOp3(v, OP_Column, iEphCur, 0, iKey);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_RowData, iEphCur, iKey);\n      }\n      assert( nKey==0 );  /* OP_Found will use a composite key */\n    }else{\n      addrLoop = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, 0, iKey);\n      VdbeCoverage(v);\n      assert( nKey==1 );\n    }  \n  \n    /* Delete the row */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 0, 1, iKey, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, OE_Abort);\n      assert( eOnePass==ONEPASS_OFF || eOnePass==ONEPASS_SINGLE );\n      sqlite3MayAbort(pParse);\n      if( eOnePass==ONEPASS_SINGLE && sqlite3IsToplevel(pParse) ){\n        pParse->isMultiWrite = 0;\n      }\n    }else\n#endif\n    {\n      int count = (pParse->nested==0);    /* True to count changes */\n      sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n          iKey, nKey, count, OE_Default, eOnePass, aiCurOnePass[1]);\n    }\n  \n    /* End of the loop over all rowids/primary-keys. */\n    if( eOnePass!=ONEPASS_OFF ){\n      sqlite3VdbeResolveLabel(v, addrBypass);\n      sqlite3WhereEnd(pWInfo);\n    }else if( pPk ){\n      sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }else{\n      sqlite3VdbeGoto(v, addrLoop);\n      sqlite3VdbeJumpHere(v, addrLoop);\n    }     \n  } /* End non-truncate path */\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /* Return the number of rows that were deleted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows deleted\", SQLITE_STATIC);\n  }\n\ndelete_from_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprDelete(db, pWhere);\n  sqlite3DbFree(db, aToOpen);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n/*\n** This routine generates VDBE code that causes a single row of a\n** single table to be deleted.  Both the original table entry and\n** all indices are removed.\n**\n** Preconditions:\n**\n**   1.  iDataCur is an open cursor on the btree that is the canonical data\n**       store for the table.  (This will be either the table itself,\n**       in the case of a rowid table, or the PRIMARY KEY index in the case\n**       of a WITHOUT ROWID table.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.\n**\n**   3.  The primary key for the row to be deleted must be stored in a\n**       sequence of nPk memory cells starting at iPk.  If nPk==0 that means\n**       that a search record formed from OP_MakeRecord is contained in the\n**       single memory location iPk.\n**\n** eMode:\n**   Parameter eMode may be passed either ONEPASS_OFF (0), ONEPASS_SINGLE, or\n**   ONEPASS_MULTI.  If eMode is not ONEPASS_OFF, then the cursor\n**   iDataCur already points to the row to delete. If eMode is ONEPASS_OFF\n**   then this function must seek iDataCur to the entry identified by iPk\n**   and nPk before reading from it.\n**\n**   If eMode is ONEPASS_MULTI, then this call is being made as part\n**   of a ONEPASS delete that affects multiple rows. In this case, if \n**   iIdxNoSeek is a valid cursor number (>=0) and is not the same as\n**   iDataCur, then its position should be preserved following the delete\n**   operation. Or, if iIdxNoSeek is not a valid cursor number, the\n**   position of iDataCur should be preserved instead.\n**\n** iIdxNoSeek:\n**   If iIdxNoSeek is a valid cursor number (>=0) not equal to iDataCur,\n**   then it identifies an index cursor (from within array of cursors\n**   starting at iIdxCur) that already points to the index entry to be deleted.\n**   Except, this optimization is disabled if there are BEFORE triggers since\n**   the trigger body might have moved the cursor.\n*/\nvoid sqlite3GenerateRowDelete(\n  Parse *pParse,     /* Parsing context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  Trigger *pTrigger, /* List of triggers to (potentially) fire */\n  int iDataCur,      /* Cursor from which column data is extracted */\n  int iIdxCur,       /* First index cursor */\n  int iPk,           /* First memory cell containing the PRIMARY KEY */\n  i16 nPk,           /* Number of PRIMARY KEY memory cells */\n  u8 count,          /* If non-zero, increment the row change counter */\n  u8 onconf,         /* Default ON CONFLICT policy for triggers */\n  u8 eMode,          /* ONEPASS_OFF, _SINGLE, or _MULTI.  See above */\n  int iIdxNoSeek     /* Cursor number of cursor that does not need seeking */\n){\n  Vdbe *v = pParse->pVdbe;        /* Vdbe */\n  int iOld = 0;                   /* First register in OLD.* array */\n  int iLabel;                     /* Label resolved to end of generated code */\n  u8 opSeek;                      /* Seek opcode */\n\n  /* Vdbe is guaranteed to have been allocated by this stage. */\n  assert( v );\n  VdbeModuleComment((v, \"BEGIN: GenRowDel(%d,%d,%d,%d)\",\n                         iDataCur, iIdxCur, iPk, (int)nPk));\n\n  /* Seek cursor iCur to the row to delete. If this row no longer exists \n  ** (this can happen if a trigger program has already deleted it), do\n  ** not attempt to delete it or fire any DELETE triggers.  */\n  iLabel = sqlite3VdbeMakeLabel(v);\n  opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;\n  if( eMode==ONEPASS_OFF ){\n    sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n    VdbeCoverageIf(v, opSeek==OP_NotExists);\n    VdbeCoverageIf(v, opSeek==OP_NotFound);\n  }\n \n  /* If there are any triggers to fire, allocate a range of registers to\n  ** use for the old.* references in the triggers.  */\n  if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){\n    u32 mask;                     /* Mask of OLD.* columns in use */\n    int iCol;                     /* Iterator used while populating OLD.* */\n    int addrStart;                /* Start of BEFORE trigger programs */\n\n    /* TODO: Could use temporary registers here. Also could attempt to\n    ** avoid copying the contents of the rowid register.  */\n    mask = sqlite3TriggerColmask(\n        pParse, pTrigger, 0, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onconf\n    );\n    mask |= sqlite3FkOldmask(pParse, pTab);\n    iOld = pParse->nMem+1;\n    pParse->nMem += (1 + pTab->nCol);\n\n    /* Populate the OLD.* pseudo-table register array. These values will be \n    ** used by any BEFORE and AFTER triggers that exist.  */\n    sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld);\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      testcase( mask!=0xffffffff && iCol==31 );\n      testcase( mask!=0xffffffff && iCol==32 );\n      if( mask==0xffffffff || (iCol<=31 && (mask & MASKBIT32(iCol))!=0) ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1);\n      }\n    }\n\n    /* Invoke BEFORE DELETE trigger programs. */\n    addrStart = sqlite3VdbeCurrentAddr(v);\n    sqlite3CodeRowTrigger(pParse, pTrigger, \n        TK_DELETE, 0, TRIGGER_BEFORE, pTab, iOld, onconf, iLabel\n    );\n\n    /* If any BEFORE triggers were coded, then seek the cursor to the \n    ** row to be deleted again. It may be that the BEFORE triggers moved\n    ** the cursor or already deleted the row that the cursor was\n    ** pointing to.\n    **\n    ** Also disable the iIdxNoSeek optimization since the BEFORE trigger\n    ** may have moved that cursor.\n    */\n    if( addrStart<sqlite3VdbeCurrentAddr(v) ){\n      sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);\n      VdbeCoverageIf(v, opSeek==OP_NotExists);\n      VdbeCoverageIf(v, opSeek==OP_NotFound);\n      testcase( iIdxNoSeek>=0 );\n      iIdxNoSeek = -1;\n    }\n\n    /* Do FK processing. This call checks that any FK constraints that\n    ** refer to this table (i.e. constraints attached to other tables) \n    ** are not violated by deleting this row.  */\n    sqlite3FkCheck(pParse, pTab, iOld, 0, 0, 0);\n  }\n\n  /* Delete the index and table entries. Skip this step if pTab is really\n  ** a view (in which case the only effect of the DELETE statement is to\n  ** fire the INSTEAD OF triggers).  \n  **\n  ** If variable 'count' is non-zero, then this OP_Delete instruction should\n  ** invoke the update-hook. The pre-update-hook, on the other hand should\n  ** be invoked unless table pTab is a system table. The difference is that\n  ** the update-hook is not invoked for rows removed by REPLACE, but the \n  ** pre-update-hook is.\n  */ \n  if( pTab->pSelect==0 ){\n    u8 p5 = 0;\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek);\n    sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0));\n    if( pParse->nested==0 ){\n      sqlite3VdbeAppendP4(v, (char*)pTab, P4_TABLE);\n    }\n    if( eMode!=ONEPASS_OFF ){\n      sqlite3VdbeChangeP5(v, OPFLAG_AUXDELETE);\n    }\n    if( iIdxNoSeek>=0 && iIdxNoSeek!=iDataCur ){\n      sqlite3VdbeAddOp1(v, OP_Delete, iIdxNoSeek);\n    }\n    if( eMode==ONEPASS_MULTI ) p5 |= OPFLAG_SAVEPOSITION;\n    sqlite3VdbeChangeP5(v, p5);\n  }\n\n  /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n  ** handle rows (possibly in other tables) that refer via a foreign key\n  ** to the row just deleted. */ \n  sqlite3FkActions(pParse, pTab, 0, iOld, 0, 0);\n\n  /* Invoke AFTER DELETE trigger programs. */\n  sqlite3CodeRowTrigger(pParse, pTrigger, \n      TK_DELETE, 0, TRIGGER_AFTER, pTab, iOld, onconf, iLabel\n  );\n\n  /* Jump here if the row had already been deleted before any BEFORE\n  ** trigger programs were invoked. Or if a trigger program throws a \n  ** RAISE(IGNORE) exception.  */\n  sqlite3VdbeResolveLabel(v, iLabel);\n  VdbeModuleComment((v, \"END: GenRowDel()\"));\n}\n\n/*\n** This routine generates VDBE code that causes the deletion of all\n** index entries associated with a single row of a single table, pTab\n**\n** Preconditions:\n**\n**   1.  A read/write cursor \"iDataCur\" must be open on the canonical storage\n**       btree for the table pTab.  (This will be either the table itself\n**       for rowid tables or to the primary key index for WITHOUT ROWID\n**       tables.)\n**\n**   2.  Read/write cursors for all indices of pTab must be open as\n**       cursor number iIdxCur+i for the i-th index.  (The pTab->pIndex\n**       index is the 0-th index.)\n**\n**   3.  The \"iDataCur\" cursor must be already be positioned on the row\n**       that is to be deleted.\n*/\nvoid sqlite3GenerateRowIndexDelete(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* Table containing the row to be deleted */\n  int iDataCur,      /* Cursor of table holding data. */\n  int iIdxCur,       /* First index cursor */\n  int *aRegIdx,      /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */\n  int iIdxNoSeek     /* Do not delete from this cursor */\n){\n  int i;             /* Index loop counter */\n  int r1 = -1;       /* Register holding an index key */\n  int iPartIdxLabel; /* Jump destination for skipping partial index entries */\n  Index *pIdx;       /* Current index */\n  Index *pPrior = 0; /* Prior index */\n  Vdbe *v;           /* The prepared statement under construction */\n  Index *pPk;        /* PRIMARY KEY index, or NULL for rowid tables */\n\n  v = pParse->pVdbe;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){\n    assert( iIdxCur+i!=iDataCur || pPk==pIdx );\n    if( aRegIdx!=0 && aRegIdx[i]==0 ) continue;\n    if( pIdx==pPk ) continue;\n    if( iIdxCur+i==iIdxNoSeek ) continue;\n    VdbeModuleComment((v, \"GenRowIdxDel for %s\", pIdx->zName));\n    r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1,\n        &iPartIdxLabel, pPrior, r1);\n    sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1,\n        pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn);\n    sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);\n    pPrior = pIdx;\n  }\n}\n\n/*\n** Generate code that will assemble an index key and stores it in register\n** regOut.  The key with be for index pIdx which is an index on pTab.\n** iCur is the index of a cursor open on the pTab table and pointing to\n** the entry that needs indexing.  If pTab is a WITHOUT ROWID table, then\n** iCur must be the cursor of the PRIMARY KEY index.\n**\n** Return a register number which is the first in a block of\n** registers that holds the elements of the index key.  The\n** block of registers has already been deallocated by the time\n** this routine returns.\n**\n** If *piPartIdxLabel is not NULL, fill it in with a label and jump\n** to that label if pIdx is a partial index that should be skipped.\n** The label should be resolved using sqlite3ResolvePartIdxLabel().\n** A partial index should be skipped if its WHERE clause evaluates\n** to false or null.  If pIdx is not a partial index, *piPartIdxLabel\n** will be set to zero which is an empty label that is ignored by\n** sqlite3ResolvePartIdxLabel().\n**\n** The pPrior and regPrior parameters are used to implement a cache to\n** avoid unnecessary register loads.  If pPrior is not NULL, then it is\n** a pointer to a different index for which an index key has just been\n** computed into register regPrior.  If the current pIdx index is generating\n** its key into the same sequence of registers and if pPrior and pIdx share\n** a column in common, then the register corresponding to that column already\n** holds the correct value and the loading of that register is skipped.\n** This optimization is helpful when doing a DELETE or an INTEGRITY_CHECK \n** on a table with multiple indices, and especially with the ROWID or\n** PRIMARY KEY columns of the index.\n*/\nint sqlite3GenerateIndexKey(\n  Parse *pParse,       /* Parsing context */\n  Index *pIdx,         /* The index for which to generate a key */\n  int iDataCur,        /* Cursor number from which to take column data */\n  int regOut,          /* Put the new key into this register if not 0 */\n  int prefixOnly,      /* Compute only a unique prefix of the key */\n  int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */\n  Index *pPrior,       /* Previously generated index key */\n  int regPrior         /* Register holding previous generated key */\n){\n  Vdbe *v = pParse->pVdbe;\n  int j;\n  int regBase;\n  int nCol;\n\n  if( piPartIdxLabel ){\n    if( pIdx->pPartIdxWhere ){\n      *piPartIdxLabel = sqlite3VdbeMakeLabel(v);\n      pParse->iSelfTab = iDataCur + 1;\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, \n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }else{\n      *piPartIdxLabel = 0;\n    }\n  }\n  nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn;\n  regBase = sqlite3GetTempRange(pParse, nCol);\n  if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0;\n  for(j=0; j<nCol; j++){\n    if( pPrior\n     && pPrior->aiColumn[j]==pIdx->aiColumn[j]\n     && pPrior->aiColumn[j]!=XN_EXPR\n    ){\n      /* This column was already computed by the previous index */\n      continue;\n    }\n    sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j);\n    /* If the column affinity is REAL but the number is an integer, then it\n    ** might be stored in the table as an integer (using a compact\n    ** representation) then converted to REAL by an OP_RealAffinity opcode.\n    ** But we are getting ready to store this value back into an index, where\n    ** it should be converted by to INTEGER again.  So omit the OP_RealAffinity\n    ** opcode if it is present */\n    sqlite3VdbeDeletePriorOpcode(v, OP_RealAffinity);\n  }\n  if( regOut ){\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);\n    if( pIdx->pTable->pSelect ){\n      const char *zAff = sqlite3IndexAffinityStr(pParse->db, pIdx);\n      sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);\n    }\n  }\n  sqlite3ReleaseTempRange(pParse, regBase, nCol);\n  return regBase;\n}\n\n/*\n** If a prior call to sqlite3GenerateIndexKey() generated a jump-over label\n** because it was a partial index, then this routine should be called to\n** resolve that label.\n*/\nvoid sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){\n  if( iLabel ){\n    sqlite3VdbeResolveLabel(pParse->pVdbe, iLabel);\n    sqlite3ExprCachePop(pParse);\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/expr.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for analyzing expressions and\n** for generating VDBE code that evaluates expressions in SQLite.\n*/\n#include \"sqliteInt.h\"\n\n/* Forward declarations */\nstatic void exprCodeBetween(Parse*,Expr*,int,void(*)(Parse*,Expr*,int,int),int);\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piToFree);\n\n/*\n** Return the affinity character for a single column of a table.\n*/\nchar sqlite3TableColumnAffinity(Table *pTab, int iCol){\n  assert( iCol<pTab->nCol );\n  return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER;\n}\n\n/*\n** Return the 'affinity' of the expression pExpr if any.\n**\n** If pExpr is a column, a reference to a column via an 'AS' alias,\n** or a sub-select with a column as the return value, then the \n** affinity of that column is returned. Otherwise, 0x00 is returned,\n** indicating no affinity for the expression.\n**\n** i.e. the WHERE clause expressions in the following statements all\n** have an affinity:\n**\n** CREATE TABLE t1(a);\n** SELECT * FROM t1 WHERE a;\n** SELECT a AS b FROM t1 WHERE b;\n** SELECT * FROM t1 WHERE (select a from t1);\n*/\nchar sqlite3ExprAffinity(Expr *pExpr){\n  int op;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( pExpr->flags & EP_Generic ) return 0;\n  op = pExpr->op;\n  if( op==TK_SELECT ){\n    assert( pExpr->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);\n  }\n  if( op==TK_REGISTER ) op = pExpr->op2;\n#ifndef SQLITE_OMIT_CAST\n  if( op==TK_CAST ){\n    assert( !ExprHasProperty(pExpr, EP_IntValue) );\n    return sqlite3AffinityType(pExpr->u.zToken, 0);\n  }\n#endif\n  if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){\n    return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn);\n  }\n  if( op==TK_SELECT_COLUMN ){\n    assert( pExpr->pLeft->flags&EP_xIsSelect );\n    return sqlite3ExprAffinity(\n        pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr\n    );\n  }\n  return pExpr->affinity;\n}\n\n/*\n** Set the collating sequence for expression pExpr to be the collating\n** sequence named by pToken.   Return a pointer to a new Expr node that\n** implements the COLLATE operator.\n**\n** If a memory allocation error occurs, that fact is recorded in pParse->db\n** and the pExpr parameter is returned unchanged.\n*/\nExpr *sqlite3ExprAddCollateToken(\n  Parse *pParse,           /* Parsing context */\n  Expr *pExpr,             /* Add the \"COLLATE\" clause to this expression */\n  const Token *pCollName,  /* Name of collating sequence */\n  int dequote              /* True to dequote pCollName */\n){\n  if( pCollName->n>0 ){\n    Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);\n    if( pNew ){\n      pNew->pLeft = pExpr;\n      pNew->flags |= EP_Collate|EP_Skip;\n      pExpr = pNew;\n    }\n  }\n  return pExpr;\n}\nExpr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){\n  Token s;\n  assert( zC!=0 );\n  sqlite3TokenInit(&s, (char*)zC);\n  return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);\n}\n\n/*\n** Skip over any TK_COLLATE operators and any unlikely()\n** or likelihood() function at the root of an expression.\n*/\nExpr *sqlite3ExprSkipCollate(Expr *pExpr){\n  while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){\n    if( ExprHasProperty(pExpr, EP_Unlikely) ){\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      assert( pExpr->x.pList->nExpr>0 );\n      assert( pExpr->op==TK_FUNCTION );\n      pExpr = pExpr->x.pList->a[0].pExpr;\n    }else{\n      assert( pExpr->op==TK_COLLATE );\n      pExpr = pExpr->pLeft;\n    }\n  }   \n  return pExpr;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return NULL.\n**\n** See also: sqlite3ExprNNCollSeq()\n**\n** The sqlite3ExprNNCollSeq() works the same exact that it returns the\n** default collation if pExpr has no defined collation.\n**\n** The collating sequence might be determined by a COLLATE operator\n** or by the presence of a column with a defined collating sequence.\n** COLLATE operators take first precedence.  Left operands take\n** precedence over right operands.\n*/\nCollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){\n  sqlite3 *db = pParse->db;\n  CollSeq *pColl = 0;\n  Expr *p = pExpr;\n  while( p ){\n    int op = p->op;\n    if( p->flags & EP_Generic ) break;\n    if( op==TK_CAST || op==TK_UPLUS ){\n      p = p->pLeft;\n      continue;\n    }\n    if( op==TK_COLLATE || (op==TK_REGISTER && p->op2==TK_COLLATE) ){\n      pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);\n      break;\n    }\n    if( (op==TK_AGG_COLUMN || op==TK_COLUMN\n          || op==TK_REGISTER || op==TK_TRIGGER)\n     && p->pTab!=0\n    ){\n      /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally\n      ** a TK_COLUMN but was previously evaluated and cached in a register */\n      int j = p->iColumn;\n      if( j>=0 ){\n        const char *zColl = p->pTab->aCol[j].zColl;\n        pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);\n      }\n      break;\n    }\n    if( p->flags & EP_Collate ){\n      if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){\n        p = p->pLeft;\n      }else{\n        Expr *pNext  = p->pRight;\n        /* The Expr.x union is never used at the same time as Expr.pRight */\n        assert( p->x.pList==0 || p->pRight==0 );\n        /* p->flags holds EP_Collate and p->pLeft->flags does not.  And\n        ** p->x.pSelect cannot.  So if p->x.pLeft exists, it must hold at\n        ** least one EP_Collate. Thus the following two ALWAYS. */\n        if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){\n          int i;\n          for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){\n            if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){\n              pNext = p->x.pList->a[i].pExpr;\n              break;\n            }\n          }\n        }\n        p = pNext;\n      }\n    }else{\n      break;\n    }\n  }\n  if( sqlite3CheckCollSeq(pParse, pColl) ){ \n    pColl = 0;\n  }\n  return pColl;\n}\n\n/*\n** Return the collation sequence for the expression pExpr. If\n** there is no defined collating sequence, return a pointer to the\n** defautl collation sequence.\n**\n** See also: sqlite3ExprCollSeq()\n**\n** The sqlite3ExprCollSeq() routine works the same except that it\n** returns NULL if there is no defined collation.\n*/\nCollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr){\n  CollSeq *p = sqlite3ExprCollSeq(pParse, pExpr);\n  if( p==0 ) p = pParse->db->pDfltColl;\n  assert( p!=0 );\n  return p;\n}\n\n/*\n** Return TRUE if the two expressions have equivalent collating sequences.\n*/\nint sqlite3ExprCollSeqMatch(Parse *pParse, Expr *pE1, Expr *pE2){\n  CollSeq *pColl1 = sqlite3ExprNNCollSeq(pParse, pE1);\n  CollSeq *pColl2 = sqlite3ExprNNCollSeq(pParse, pE2);\n  return sqlite3StrICmp(pColl1->zName, pColl2->zName)==0;\n}\n\n/*\n** pExpr is an operand of a comparison operator.  aff2 is the\n** type affinity of the other operand.  This routine returns the\n** type affinity that should be used for the comparison operator.\n*/\nchar sqlite3CompareAffinity(Expr *pExpr, char aff2){\n  char aff1 = sqlite3ExprAffinity(pExpr);\n  if( aff1 && aff2 ){\n    /* Both sides of the comparison are columns. If one has numeric\n    ** affinity, use that. Otherwise use no affinity.\n    */\n    if( sqlite3IsNumericAffinity(aff1) || sqlite3IsNumericAffinity(aff2) ){\n      return SQLITE_AFF_NUMERIC;\n    }else{\n      return SQLITE_AFF_BLOB;\n    }\n  }else if( !aff1 && !aff2 ){\n    /* Neither side of the comparison is a column.  Compare the\n    ** results directly.\n    */\n    return SQLITE_AFF_BLOB;\n  }else{\n    /* One side is a column, the other is not. Use the columns affinity. */\n    assert( aff1==0 || aff2==0 );\n    return (aff1 + aff2);\n  }\n}\n\n/*\n** pExpr is a comparison operator.  Return the type affinity that should\n** be applied to both operands prior to doing the comparison.\n*/\nstatic char comparisonAffinity(Expr *pExpr){\n  char aff;\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_IN || pExpr->op==TK_LT ||\n          pExpr->op==TK_GT || pExpr->op==TK_GE || pExpr->op==TK_LE ||\n          pExpr->op==TK_NE || pExpr->op==TK_IS || pExpr->op==TK_ISNOT );\n  assert( pExpr->pLeft );\n  aff = sqlite3ExprAffinity(pExpr->pLeft);\n  if( pExpr->pRight ){\n    aff = sqlite3CompareAffinity(pExpr->pRight, aff);\n  }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);\n  }else if( aff==0 ){\n    aff = SQLITE_AFF_BLOB;\n  }\n  return aff;\n}\n\n/*\n** pExpr is a comparison expression, eg. '=', '<', IN(...) etc.\n** idx_affinity is the affinity of an indexed column. Return true\n** if the index with affinity idx_affinity may be used to implement\n** the comparison in pExpr.\n*/\nint sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity){\n  char aff = comparisonAffinity(pExpr);\n  switch( aff ){\n    case SQLITE_AFF_BLOB:\n      return 1;\n    case SQLITE_AFF_TEXT:\n      return idx_affinity==SQLITE_AFF_TEXT;\n    default:\n      return sqlite3IsNumericAffinity(idx_affinity);\n  }\n}\n\n/*\n** Return the P5 value that should be used for a binary comparison\n** opcode (OP_Eq, OP_Ge etc.) used to compare pExpr1 and pExpr2.\n*/\nstatic u8 binaryCompareP5(Expr *pExpr1, Expr *pExpr2, int jumpIfNull){\n  u8 aff = (char)sqlite3ExprAffinity(pExpr2);\n  aff = (u8)sqlite3CompareAffinity(pExpr1, aff) | (u8)jumpIfNull;\n  return aff;\n}\n\n/*\n** Return a pointer to the collation sequence that should be used by\n** a binary comparison operator comparing pLeft and pRight.\n**\n** If the left hand expression has a collating sequence type, then it is\n** used. Otherwise the collation sequence for the right hand expression\n** is used, or the default (BINARY) if neither expression has a collating\n** type.\n**\n** Argument pRight (but not pLeft) may be a null pointer. In this case,\n** it is not considered.\n*/\nCollSeq *sqlite3BinaryCompareCollSeq(\n  Parse *pParse, \n  Expr *pLeft, \n  Expr *pRight\n){\n  CollSeq *pColl;\n  assert( pLeft );\n  if( pLeft->flags & EP_Collate ){\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n  }else if( pRight && (pRight->flags & EP_Collate)!=0 ){\n    pColl = sqlite3ExprCollSeq(pParse, pRight);\n  }else{\n    pColl = sqlite3ExprCollSeq(pParse, pLeft);\n    if( !pColl ){\n      pColl = sqlite3ExprCollSeq(pParse, pRight);\n    }\n  }\n  return pColl;\n}\n\n/*\n** Generate code for a comparison operator.\n*/\nstatic int codeCompare(\n  Parse *pParse,    /* The parsing (and code generating) context */\n  Expr *pLeft,      /* The left operand */\n  Expr *pRight,     /* The right operand */\n  int opcode,       /* The comparison opcode */\n  int in1, int in2, /* Register holding operands */\n  int dest,         /* Jump here if true.  */\n  int jumpIfNull    /* If true, jump if either operand is NULL */\n){\n  int p5;\n  int addr;\n  CollSeq *p4;\n\n  p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);\n  p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);\n  addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,\n                           (void*)p4, P4_COLLSEQ);\n  sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);\n  return addr;\n}\n\n/*\n** Return true if expression pExpr is a vector, or false otherwise.\n**\n** A vector is defined as any expression that results in two or more\n** columns of result.  Every TK_VECTOR node is an vector because the\n** parser will not generate a TK_VECTOR with fewer than two entries.\n** But a TK_SELECT might be either a vector or a scalar. It is only\n** considered a vector if it has two or more result columns.\n*/\nint sqlite3ExprIsVector(Expr *pExpr){\n  return sqlite3ExprVectorSize(pExpr)>1;\n}\n\n/*\n** If the expression passed as the only argument is of type TK_VECTOR \n** return the number of expressions in the vector. Or, if the expression\n** is a sub-select, return the number of columns in the sub-select. For\n** any other type of expression, return 1.\n*/\nint sqlite3ExprVectorSize(Expr *pExpr){\n  u8 op = pExpr->op;\n  if( op==TK_REGISTER ) op = pExpr->op2;\n  if( op==TK_VECTOR ){\n    return pExpr->x.pList->nExpr;\n  }else if( op==TK_SELECT ){\n    return pExpr->x.pSelect->pEList->nExpr;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Return a pointer to a subexpression of pVector that is the i-th\n** column of the vector (numbered starting with 0).  The caller must\n** ensure that i is within range.\n**\n** If pVector is really a scalar (and \"scalar\" here includes subqueries\n** that return a single column!) then return pVector unmodified.\n**\n** pVector retains ownership of the returned subexpression.\n**\n** If the vector is a (SELECT ...) then the expression returned is\n** just the expression for the i-th term of the result set, and may\n** not be ready for evaluation because the table cursor has not yet\n** been positioned.\n*/\nExpr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){\n  assert( i<sqlite3ExprVectorSize(pVector) );\n  if( sqlite3ExprIsVector(pVector) ){\n    assert( pVector->op2==0 || pVector->op==TK_REGISTER );\n    if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){\n      return pVector->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      return pVector->x.pList->a[i].pExpr;\n    }\n  }\n  return pVector;\n}\n\n/*\n** Compute and return a new Expr object which when passed to\n** sqlite3ExprCode() will generate all necessary code to compute\n** the iField-th column of the vector expression pVector.\n**\n** It is ok for pVector to be a scalar (as long as iField==0).  \n** In that case, this routine works like sqlite3ExprDup().\n**\n** The caller owns the returned Expr object and is responsible for\n** ensuring that the returned value eventually gets freed.\n**\n** The caller retains ownership of pVector.  If pVector is a TK_SELECT,\n** then the returned object will reference pVector and so pVector must remain\n** valid for the life of the returned object.  If pVector is a TK_VECTOR\n** or a scalar expression, then it can be deleted as soon as this routine\n** returns.\n**\n** A trick to cause a TK_SELECT pVector to be deleted together with\n** the returned Expr object is to attach the pVector to the pRight field\n** of the returned TK_SELECT_COLUMN Expr object.\n*/\nExpr *sqlite3ExprForVectorField(\n  Parse *pParse,       /* Parsing context */\n  Expr *pVector,       /* The vector.  List of expressions or a sub-SELECT */\n  int iField           /* Which column of the vector to return */\n){\n  Expr *pRet;\n  if( pVector->op==TK_SELECT ){\n    assert( pVector->flags & EP_xIsSelect );\n    /* The TK_SELECT_COLUMN Expr node:\n    **\n    ** pLeft:           pVector containing TK_SELECT.  Not deleted.\n    ** pRight:          not used.  But recursively deleted.\n    ** iColumn:         Index of a column in pVector\n    ** iTable:          0 or the number of columns on the LHS of an assignment\n    ** pLeft->iTable:   First in an array of register holding result, or 0\n    **                  if the result is not yet computed.\n    **\n    ** sqlite3ExprDelete() specifically skips the recursive delete of\n    ** pLeft on TK_SELECT_COLUMN nodes.  But pRight is followed, so pVector\n    ** can be attached to pRight to cause this node to take ownership of\n    ** pVector.  Typically there will be multiple TK_SELECT_COLUMN nodes\n    ** with the same pLeft pointer to the pVector, but only one of them\n    ** will own the pVector.\n    */\n    pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);\n    if( pRet ){\n      pRet->iColumn = iField;\n      pRet->pLeft = pVector;\n    }\n    assert( pRet==0 || pRet->iTable==0 );\n  }else{\n    if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;\n    pRet = sqlite3ExprDup(pParse->db, pVector, 0);\n  }\n  return pRet;\n}\n\n/*\n** If expression pExpr is of type TK_SELECT, generate code to evaluate\n** it. Return the register in which the result is stored (or, if the \n** sub-select returns more than one column, the first in an array\n** of registers in which the result is stored).\n**\n** If pExpr is not a TK_SELECT expression, return 0.\n*/\nstatic int exprCodeSubselect(Parse *pParse, Expr *pExpr){\n  int reg = 0;\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->op==TK_SELECT ){\n    reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);\n  }\n#endif\n  return reg;\n}\n\n/*\n** Argument pVector points to a vector expression - either a TK_VECTOR\n** or TK_SELECT that returns more than one column. This function returns\n** the register number of a register that contains the value of\n** element iField of the vector.\n**\n** If pVector is a TK_SELECT expression, then code for it must have \n** already been generated using the exprCodeSubselect() routine. In this\n** case parameter regSelect should be the first in an array of registers\n** containing the results of the sub-select. \n**\n** If pVector is of type TK_VECTOR, then code for the requested field\n** is generated. In this case (*pRegFree) may be set to the number of\n** a temporary register to be freed by the caller before returning.\n**\n** Before returning, output parameter (*ppExpr) is set to point to the\n** Expr object corresponding to element iElem of the vector.\n*/\nstatic int exprVectorRegister(\n  Parse *pParse,                  /* Parse context */\n  Expr *pVector,                  /* Vector to extract element from */\n  int iField,                     /* Field to extract from pVector */\n  int regSelect,                  /* First in array of registers */\n  Expr **ppExpr,                  /* OUT: Expression element */\n  int *pRegFree                   /* OUT: Temp register to free */\n){\n  u8 op = pVector->op;\n  assert( op==TK_VECTOR || op==TK_REGISTER || op==TK_SELECT );\n  if( op==TK_REGISTER ){\n    *ppExpr = sqlite3VectorFieldSubexpr(pVector, iField);\n    return pVector->iTable+iField;\n  }\n  if( op==TK_SELECT ){\n    *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;\n     return regSelect+iField;\n  }\n  *ppExpr = pVector->x.pList->a[iField].pExpr;\n  return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree);\n}\n\n/*\n** Expression pExpr is a comparison between two vector values. Compute\n** the result of the comparison (1, 0, or NULL) and write that\n** result into register dest.\n**\n** The caller must satisfy the following preconditions:\n**\n**    if pExpr->op==TK_IS:      op==TK_EQ and p5==SQLITE_NULLEQ\n**    if pExpr->op==TK_ISNOT:   op==TK_NE and p5==SQLITE_NULLEQ\n**    otherwise:                op==pExpr->op and p5==0\n*/\nstatic void codeVectorCompare(\n  Parse *pParse,        /* Code generator context */\n  Expr *pExpr,          /* The comparison operation */\n  int dest,             /* Write results into this register */\n  u8 op,                /* Comparison operator */\n  u8 p5                 /* SQLITE_NULLEQ or zero */\n){\n  Vdbe *v = pParse->pVdbe;\n  Expr *pLeft = pExpr->pLeft;\n  Expr *pRight = pExpr->pRight;\n  int nLeft = sqlite3ExprVectorSize(pLeft);\n  int i;\n  int regLeft = 0;\n  int regRight = 0;\n  u8 opx = op;\n  int addrDone = sqlite3VdbeMakeLabel(v);\n\n  if( nLeft!=sqlite3ExprVectorSize(pRight) ){\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n    return;\n  }\n  assert( pExpr->op==TK_EQ || pExpr->op==TK_NE \n       || pExpr->op==TK_IS || pExpr->op==TK_ISNOT \n       || pExpr->op==TK_LT || pExpr->op==TK_GT \n       || pExpr->op==TK_LE || pExpr->op==TK_GE \n  );\n  assert( pExpr->op==op || (pExpr->op==TK_IS && op==TK_EQ)\n            || (pExpr->op==TK_ISNOT && op==TK_NE) );\n  assert( p5==0 || pExpr->op!=op );\n  assert( p5==SQLITE_NULLEQ || pExpr->op==op );\n\n  p5 |= SQLITE_STOREP2;\n  if( opx==TK_LE ) opx = TK_LT;\n  if( opx==TK_GE ) opx = TK_GT;\n\n  regLeft = exprCodeSubselect(pParse, pLeft);\n  regRight = exprCodeSubselect(pParse, pRight);\n\n  for(i=0; 1 /*Loop exits by \"break\"*/; i++){\n    int regFree1 = 0, regFree2 = 0;\n    Expr *pL, *pR; \n    int r1, r2;\n    assert( i>=0 && i<nLeft );\n    if( i>0 ) sqlite3ExprCachePush(pParse);\n    r1 = exprVectorRegister(pParse, pLeft, i, regLeft, &pL, &regFree1);\n    r2 = exprVectorRegister(pParse, pRight, i, regRight, &pR, &regFree2);\n    codeCompare(pParse, pL, pR, opx, r1, r2, dest, p5);\n    testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n    testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n    testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n    testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n    testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n    testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n    sqlite3ReleaseTempReg(pParse, regFree1);\n    sqlite3ReleaseTempReg(pParse, regFree2);\n    if( i>0 ) sqlite3ExprCachePop(pParse);\n    if( i==nLeft-1 ){\n      break;\n    }\n    if( opx==TK_EQ ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else if( opx==TK_NE ){\n      sqlite3VdbeAddOp2(v, OP_If, dest, addrDone); VdbeCoverage(v);\n      p5 |= SQLITE_KEEPNULL;\n    }else{\n      assert( op==TK_LT || op==TK_GT || op==TK_LE || op==TK_GE );\n      sqlite3VdbeAddOp2(v, OP_ElseNotEq, 0, addrDone);\n      VdbeCoverageIf(v, op==TK_LT);\n      VdbeCoverageIf(v, op==TK_GT);\n      VdbeCoverageIf(v, op==TK_LE);\n      VdbeCoverageIf(v, op==TK_GE);\n      if( i==nLeft-2 ) opx = op;\n    }\n  }\n  sqlite3VdbeResolveLabel(v, addrDone);\n}\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n/*\n** Check that argument nHeight is less than or equal to the maximum\n** expression depth allowed. If it is not, leave an error message in\n** pParse.\n*/\nint sqlite3ExprCheckHeight(Parse *pParse, int nHeight){\n  int rc = SQLITE_OK;\n  int mxHeight = pParse->db->aLimit[SQLITE_LIMIT_EXPR_DEPTH];\n  if( nHeight>mxHeight ){\n    sqlite3ErrorMsg(pParse, \n       \"Expression tree is too large (maximum depth %d)\", mxHeight\n    );\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/* The following three functions, heightOfExpr(), heightOfExprList()\n** and heightOfSelect(), are used to determine the maximum height\n** of any expression tree referenced by the structure passed as the\n** first argument.\n**\n** If this maximum height is greater than the current value pointed\n** to by pnHeight, the second parameter, then set *pnHeight to that\n** value.\n*/\nstatic void heightOfExpr(Expr *p, int *pnHeight){\n  if( p ){\n    if( p->nHeight>*pnHeight ){\n      *pnHeight = p->nHeight;\n    }\n  }\n}\nstatic void heightOfExprList(ExprList *p, int *pnHeight){\n  if( p ){\n    int i;\n    for(i=0; i<p->nExpr; i++){\n      heightOfExpr(p->a[i].pExpr, pnHeight);\n    }\n  }\n}\nstatic void heightOfSelect(Select *p, int *pnHeight){\n  if( p ){\n    heightOfExpr(p->pWhere, pnHeight);\n    heightOfExpr(p->pHaving, pnHeight);\n    heightOfExpr(p->pLimit, pnHeight);\n    heightOfExpr(p->pOffset, pnHeight);\n    heightOfExprList(p->pEList, pnHeight);\n    heightOfExprList(p->pGroupBy, pnHeight);\n    heightOfExprList(p->pOrderBy, pnHeight);\n    heightOfSelect(p->pPrior, pnHeight);\n  }\n}\n\n/*\n** Set the Expr.nHeight variable in the structure passed as an \n** argument. An expression with no children, Expr.pList or \n** Expr.pSelect member has a height of 1. Any other expression\n** has a height equal to the maximum height of any other \n** referenced Expr plus one.\n**\n** Also propagate EP_Propagate flags up from Expr.x.pList to Expr.flags,\n** if appropriate.\n*/\nstatic void exprSetHeight(Expr *p){\n  int nHeight = 0;\n  heightOfExpr(p->pLeft, &nHeight);\n  heightOfExpr(p->pRight, &nHeight);\n  if( ExprHasProperty(p, EP_xIsSelect) ){\n    heightOfSelect(p->x.pSelect, &nHeight);\n  }else if( p->x.pList ){\n    heightOfExprList(p->x.pList, &nHeight);\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n  p->nHeight = nHeight + 1;\n}\n\n/*\n** Set the Expr.nHeight variable using the exprSetHeight() function. If\n** the height is greater than the maximum allowed expression depth,\n** leave an error in pParse.\n**\n** Also propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nvoid sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( pParse->nErr ) return;\n  exprSetHeight(p);\n  sqlite3ExprCheckHeight(pParse, p->nHeight);\n}\n\n/*\n** Return the maximum height of any expression tree referenced\n** by the select statement passed as an argument.\n*/\nint sqlite3SelectExprHeight(Select *p){\n  int nHeight = 0;\n  heightOfSelect(p, &nHeight);\n  return nHeight;\n}\n#else /* ABOVE:  Height enforcement enabled.  BELOW: Height enforcement off */\n/*\n** Propagate all EP_Propagate flags from the Expr.x.pList into\n** Expr.flags. \n*/\nvoid sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){\n  if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){\n    p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);\n  }\n}\n#define exprSetHeight(y)\n#endif /* SQLITE_MAX_EXPR_DEPTH>0 */\n\n/*\n** This routine is the core allocator for Expr nodes.\n**\n** Construct a new expression node and return a pointer to it.  Memory\n** for this node and for the pToken argument is a single allocation\n** obtained from sqlite3DbMalloc().  The calling function\n** is responsible for making sure the node eventually gets freed.\n**\n** If dequote is true, then the token (if it exists) is dequoted.\n** If dequote is false, no dequoting is performed.  The deQuote\n** parameter is ignored if pToken is NULL or if the token does not\n** appear to be quoted.  If the quotes were of the form \"...\" (double-quotes)\n** then the EP_DblQuoted flag is set on the expression node.\n**\n** Special case:  If op==TK_INTEGER and pToken points to a string that\n** can be translated into a 32-bit integer, then the token is not\n** stored in u.zToken.  Instead, the integer values is written\n** into u.iValue and the EP_IntValue flag is set.  No extra storage\n** is allocated to hold the integer text and the dequote flag is ignored.\n*/\nExpr *sqlite3ExprAlloc(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocRawNN() */\n  int op,                 /* Expression opcode */\n  const Token *pToken,    /* Token argument.  Might be NULL */\n  int dequote             /* True to dequote */\n){\n  Expr *pNew;\n  int nExtra = 0;\n  int iValue = 0;\n\n  assert( db!=0 );\n  if( pToken ){\n    if( op!=TK_INTEGER || pToken->z==0\n          || sqlite3GetInt32(pToken->z, &iValue)==0 ){\n      nExtra = pToken->n+1;\n      assert( iValue>=0 );\n    }\n  }\n  pNew = sqlite3DbMallocRawNN(db, sizeof(Expr)+nExtra);\n  if( pNew ){\n    memset(pNew, 0, sizeof(Expr));\n    pNew->op = (u8)op;\n    pNew->iAgg = -1;\n    if( pToken ){\n      if( nExtra==0 ){\n        pNew->flags |= EP_IntValue|EP_Leaf;\n        pNew->u.iValue = iValue;\n      }else{\n        pNew->u.zToken = (char*)&pNew[1];\n        assert( pToken->z!=0 || pToken->n==0 );\n        if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);\n        pNew->u.zToken[pToken->n] = 0;\n        if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){\n          if( pNew->u.zToken[0]=='\"' ) pNew->flags |= EP_DblQuoted;\n          sqlite3Dequote(pNew->u.zToken);\n        }\n      }\n    }\n#if SQLITE_MAX_EXPR_DEPTH>0\n    pNew->nHeight = 1;\n#endif  \n  }\n  return pNew;\n}\n\n/*\n** Allocate a new expression node from a zero-terminated token that has\n** already been dequoted.\n*/\nExpr *sqlite3Expr(\n  sqlite3 *db,            /* Handle for sqlite3DbMallocZero() (may be null) */\n  int op,                 /* Expression opcode */\n  const char *zToken      /* Token argument.  Might be NULL */\n){\n  Token x;\n  x.z = zToken;\n  x.n = sqlite3Strlen30(zToken);\n  return sqlite3ExprAlloc(db, op, &x, 0);\n}\n\n/*\n** Attach subtrees pLeft and pRight to the Expr node pRoot.\n**\n** If pRoot==NULL that means that a memory allocation error has occurred.\n** In that case, delete the subtrees pLeft and pRight.\n*/\nvoid sqlite3ExprAttachSubtrees(\n  sqlite3 *db,\n  Expr *pRoot,\n  Expr *pLeft,\n  Expr *pRight\n){\n  if( pRoot==0 ){\n    assert( db->mallocFailed );\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n  }else{\n    if( pRight ){\n      pRoot->pRight = pRight;\n      pRoot->flags |= EP_Propagate & pRight->flags;\n    }\n    if( pLeft ){\n      pRoot->pLeft = pLeft;\n      pRoot->flags |= EP_Propagate & pLeft->flags;\n    }\n    exprSetHeight(pRoot);\n  }\n}\n\n/*\n** Allocate an Expr node which joins as many as two subtrees.\n**\n** One or both of the subtrees can be NULL.  Return a pointer to the new\n** Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,\n** free the subtrees and return NULL.\n*/\nExpr *sqlite3PExpr(\n  Parse *pParse,          /* Parsing context */\n  int op,                 /* Expression opcode */\n  Expr *pLeft,            /* Left operand */\n  Expr *pRight            /* Right operand */\n){\n  Expr *p;\n  if( op==TK_AND && pParse->nErr==0 ){\n    /* Take advantage of short-circuit false optimization for AND */\n    p = sqlite3ExprAnd(pParse->db, pLeft, pRight);\n  }else{\n    p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr));\n    if( p ){\n      memset(p, 0, sizeof(Expr));\n      p->op = op & TKFLG_MASK;\n      p->iAgg = -1;\n    }\n    sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);\n  }\n  if( p ) {\n    sqlite3ExprCheckHeight(pParse, p->nHeight);\n  }\n  return p;\n}\n\n/*\n** Add pSelect to the Expr.x.pSelect field.  Or, if pExpr is NULL (due\n** do a memory allocation failure) then delete the pSelect object.\n*/\nvoid sqlite3PExprAddSelect(Parse *pParse, Expr *pExpr, Select *pSelect){\n  if( pExpr ){\n    pExpr->x.pSelect = pSelect;\n    ExprSetProperty(pExpr, EP_xIsSelect|EP_Subquery);\n    sqlite3ExprSetHeightAndFlags(pParse, pExpr);\n  }else{\n    assert( pParse->db->mallocFailed );\n    sqlite3SelectDelete(pParse->db, pSelect);\n  }\n}\n\n\n/*\n** If the expression is always either TRUE or FALSE (respectively),\n** then return 1.  If one cannot determine the truth value of the\n** expression at compile-time return 0.\n**\n** This is an optimization.  If is OK to return 0 here even if\n** the expression really is always false or false (a false negative).\n** But it is a bug to return 1 if the expression might have different\n** boolean values in different circumstances (a false positive.)\n**\n** Note that if the expression is part of conditional for a\n** LEFT JOIN, then we cannot determine at compile-time whether or not\n** is it true or false, so always return 0.\n*/\nstatic int exprAlwaysTrue(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v!=0;\n}\nstatic int exprAlwaysFalse(Expr *p){\n  int v = 0;\n  if( ExprHasProperty(p, EP_FromJoin) ) return 0;\n  if( !sqlite3ExprIsInteger(p, &v) ) return 0;\n  return v==0;\n}\n\n/*\n** Join two expressions using an AND operator.  If either expression is\n** NULL, then just return the other expression.\n**\n** If one side or the other of the AND is known to be false, then instead\n** of returning an AND expression, just return a constant expression with\n** a value of false.\n*/\nExpr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){\n  if( pLeft==0 ){\n    return pRight;\n  }else if( pRight==0 ){\n    return pLeft;\n  }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){\n    sqlite3ExprDelete(db, pLeft);\n    sqlite3ExprDelete(db, pRight);\n    return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);\n  }else{\n    Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);\n    sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);\n    return pNew;\n  }\n}\n\n/*\n** Construct a new expression node for a function with multiple\n** arguments.\n*/\nExpr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *pToken){\n  Expr *pNew;\n  sqlite3 *db = pParse->db;\n  assert( pToken );\n  pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);\n  if( pNew==0 ){\n    sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */\n    return 0;\n  }\n  pNew->x.pList = pList;\n  assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n  sqlite3ExprSetHeightAndFlags(pParse, pNew);\n  return pNew;\n}\n\n/*\n** Assign a variable number to an expression that encodes a wildcard\n** in the original SQL statement.  \n**\n** Wildcards consisting of a single \"?\" are assigned the next sequential\n** variable number.\n**\n** Wildcards of the form \"?nnn\" are assigned the number \"nnn\".  We make\n** sure \"nnn\" is not too big to avoid a denial of service attack when\n** the SQL statement comes from an external source.\n**\n** Wildcards of the form \":aaa\", \"@aaa\", or \"$aaa\" are assigned the same number\n** as the previous instance of the same wildcard.  Or if this is the first\n** instance of the wildcard, the next sequential variable number is\n** assigned.\n*/\nvoid sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){\n  sqlite3 *db = pParse->db;\n  const char *z;\n  ynVar x;\n\n  if( pExpr==0 ) return;\n  assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) );\n  z = pExpr->u.zToken;\n  assert( z!=0 );\n  assert( z[0]!=0 );\n  assert( n==(u32)sqlite3Strlen30(z) );\n  if( z[1]==0 ){\n    /* Wildcard of the form \"?\".  Assign the next variable number */\n    assert( z[0]=='?' );\n    x = (ynVar)(++pParse->nVar);\n  }else{\n    int doAdd = 0;\n    if( z[0]=='?' ){\n      /* Wildcard of the form \"?nnn\".  Convert \"nnn\" to an integer and\n      ** use it as the variable number */\n      i64 i;\n      int bOk;\n      if( n==2 ){ /*OPTIMIZATION-IF-TRUE*/\n        i = z[1]-'0';  /* The common case of ?N for a single digit N */\n        bOk = 1;\n      }else{\n        bOk = 0==sqlite3Atoi64(&z[1], &i, n-1, SQLITE_UTF8);\n      }\n      testcase( i==0 );\n      testcase( i==1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]-1 );\n      testcase( i==db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] );\n      if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n        sqlite3ErrorMsg(pParse, \"variable number must be between ?1 and ?%d\",\n            db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);\n        return;\n      }\n      x = (ynVar)i;\n      if( x>pParse->nVar ){\n        pParse->nVar = (int)x;\n        doAdd = 1;\n      }else if( sqlite3VListNumToName(pParse->pVList, x)==0 ){\n        doAdd = 1;\n      }\n    }else{\n      /* Wildcards like \":aaa\", \"$aaa\" or \"@aaa\".  Reuse the same variable\n      ** number as the prior appearance of the same name, or if the name\n      ** has never appeared before, reuse the same variable number\n      */\n      x = (ynVar)sqlite3VListNameToNum(pParse->pVList, z, n);\n      if( x==0 ){\n        x = (ynVar)(++pParse->nVar);\n        doAdd = 1;\n      }\n    }\n    if( doAdd ){\n      pParse->pVList = sqlite3VListAdd(db, pParse->pVList, z, n, x);\n    }\n  }\n  pExpr->iColumn = x;\n  if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){\n    sqlite3ErrorMsg(pParse, \"too many SQL variables\");\n  }\n}\n\n/*\n** Recursively delete an expression tree.\n*/\nstatic SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){\n  assert( p!=0 );\n  /* Sanity check: Assert that the IntValue is non-negative if it exists */\n  assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 );\n#ifdef SQLITE_DEBUG\n  if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){\n    assert( p->pLeft==0 );\n    assert( p->pRight==0 );\n    assert( p->x.pSelect==0 );\n  }\n#endif\n  if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){\n    /* The Expr.x union is never used at the same time as Expr.pRight */\n    assert( p->x.pList==0 || p->pRight==0 );\n    if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft);\n    if( p->pRight ){\n      sqlite3ExprDeleteNN(db, p->pRight);\n    }else if( ExprHasProperty(p, EP_xIsSelect) ){\n      sqlite3SelectDelete(db, p->x.pSelect);\n    }else{\n      sqlite3ExprListDelete(db, p->x.pList);\n    }\n  }\n  if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken);\n  if( !ExprHasProperty(p, EP_Static) ){\n    sqlite3DbFreeNN(db, p);\n  }\n}\nvoid sqlite3ExprDelete(sqlite3 *db, Expr *p){\n  if( p ) sqlite3ExprDeleteNN(db, p);\n}\n\n/*\n** Return the number of bytes allocated for the expression structure \n** passed as the first argument. This is always one of EXPR_FULLSIZE,\n** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE.\n*/\nstatic int exprStructSize(Expr *p){\n  if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE;\n  if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE;\n  return EXPR_FULLSIZE;\n}\n\n/*\n** The dupedExpr*Size() routines each return the number of bytes required\n** to store a copy of an expression or expression tree.  They differ in\n** how much of the tree is measured.\n**\n**     dupedExprStructSize()     Size of only the Expr structure \n**     dupedExprNodeSize()       Size of Expr + space for token\n**     dupedExprSize()           Expr + token + subtree components\n**\n***************************************************************************\n**\n** The dupedExprStructSize() function returns two values OR-ed together:  \n** (1) the space required for a copy of the Expr structure only and \n** (2) the EP_xxx flags that indicate what the structure size should be.\n** The return values is always one of:\n**\n**      EXPR_FULLSIZE\n**      EXPR_REDUCEDSIZE   | EP_Reduced\n**      EXPR_TOKENONLYSIZE | EP_TokenOnly\n**\n** The size of the structure can be found by masking the return value\n** of this routine with 0xfff.  The flags can be found by masking the\n** return value with EP_Reduced|EP_TokenOnly.\n**\n** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size\n** (unreduced) Expr objects as they or originally constructed by the parser.\n** During expression analysis, extra information is computed and moved into\n** later parts of teh Expr object and that extra information might get chopped\n** off if the expression is reduced.  Note also that it does not work to\n** make an EXPRDUP_REDUCE copy of a reduced expression.  It is only legal\n** to reduce a pristine expression tree from the parser.  The implementation\n** of dupedExprStructSize() contain multiple assert() statements that attempt\n** to enforce this constraint.\n*/\nstatic int dupedExprStructSize(Expr *p, int flags){\n  int nSize;\n  assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */\n  assert( EXPR_FULLSIZE<=0xfff );\n  assert( (0xfff & (EP_Reduced|EP_TokenOnly))==0 );\n  if( 0==flags || p->op==TK_SELECT_COLUMN ){\n    nSize = EXPR_FULLSIZE;\n  }else{\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    assert( !ExprHasProperty(p, EP_FromJoin) ); \n    assert( !ExprHasProperty(p, EP_MemToken) );\n    assert( !ExprHasProperty(p, EP_NoReduce) );\n    if( p->pLeft || p->x.pList ){\n      nSize = EXPR_REDUCEDSIZE | EP_Reduced;\n    }else{\n      assert( p->pRight==0 );\n      nSize = EXPR_TOKENONLYSIZE | EP_TokenOnly;\n    }\n  }\n  return nSize;\n}\n\n/*\n** This function returns the space in bytes required to store the copy \n** of the Expr structure and a copy of the Expr.u.zToken string (if that\n** string is defined.)\n*/\nstatic int dupedExprNodeSize(Expr *p, int flags){\n  int nByte = dupedExprStructSize(p, flags) & 0xfff;\n  if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n    nByte += sqlite3Strlen30(p->u.zToken)+1;\n  }\n  return ROUND8(nByte);\n}\n\n/*\n** Return the number of bytes required to create a duplicate of the \n** expression passed as the first argument. The second argument is a\n** mask containing EXPRDUP_XXX flags.\n**\n** The value returned includes space to create a copy of the Expr struct\n** itself and the buffer referred to by Expr.u.zToken, if any.\n**\n** If the EXPRDUP_REDUCE flag is set, then the return value includes \n** space to duplicate all Expr nodes in the tree formed by Expr.pLeft \n** and Expr.pRight variables (but not for any structures pointed to or \n** descended from the Expr.x.pList or Expr.x.pSelect variables).\n*/\nstatic int dupedExprSize(Expr *p, int flags){\n  int nByte = 0;\n  if( p ){\n    nByte = dupedExprNodeSize(p, flags);\n    if( flags&EXPRDUP_REDUCE ){\n      nByte += dupedExprSize(p->pLeft, flags) + dupedExprSize(p->pRight, flags);\n    }\n  }\n  return nByte;\n}\n\n/*\n** This function is similar to sqlite3ExprDup(), except that if pzBuffer \n** is not NULL then *pzBuffer is assumed to point to a buffer large enough \n** to store the copy of expression p, the copies of p->u.zToken\n** (if applicable), and the copies of the p->pLeft and p->pRight expressions,\n** if any. Before returning, *pzBuffer is set to the first byte past the\n** portion of the buffer copied into by this function.\n*/\nstatic Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){\n  Expr *pNew;           /* Value to return */\n  u8 *zAlloc;           /* Memory space from which to build Expr object */\n  u32 staticFlag;       /* EP_Static if space not obtained from malloc */\n\n  assert( db!=0 );\n  assert( p );\n  assert( dupFlags==0 || dupFlags==EXPRDUP_REDUCE );\n  assert( pzBuffer==0 || dupFlags==EXPRDUP_REDUCE );\n\n  /* Figure out where to write the new Expr structure. */\n  if( pzBuffer ){\n    zAlloc = *pzBuffer;\n    staticFlag = EP_Static;\n  }else{\n    zAlloc = sqlite3DbMallocRawNN(db, dupedExprSize(p, dupFlags));\n    staticFlag = 0;\n  }\n  pNew = (Expr *)zAlloc;\n\n  if( pNew ){\n    /* Set nNewSize to the size allocated for the structure pointed to\n    ** by pNew. This is either EXPR_FULLSIZE, EXPR_REDUCEDSIZE or\n    ** EXPR_TOKENONLYSIZE. nToken is set to the number of bytes consumed\n    ** by the copy of the p->u.zToken string (if any).\n    */\n    const unsigned nStructSize = dupedExprStructSize(p, dupFlags);\n    const int nNewSize = nStructSize & 0xfff;\n    int nToken;\n    if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){\n      nToken = sqlite3Strlen30(p->u.zToken) + 1;\n    }else{\n      nToken = 0;\n    }\n    if( dupFlags ){\n      assert( ExprHasProperty(p, EP_Reduced)==0 );\n      memcpy(zAlloc, p, nNewSize);\n    }else{\n      u32 nSize = (u32)exprStructSize(p);\n      memcpy(zAlloc, p, nSize);\n      if( nSize<EXPR_FULLSIZE ){ \n        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);\n      }\n    }\n\n    /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */\n    pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken);\n    pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly);\n    pNew->flags |= staticFlag;\n\n    /* Copy the p->u.zToken string, if any. */\n    if( nToken ){\n      char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize];\n      memcpy(zToken, p->u.zToken, nToken);\n    }\n\n    if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){\n      /* Fill in the pNew->x.pSelect or pNew->x.pList member. */\n      if( ExprHasProperty(p, EP_xIsSelect) ){\n        pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags);\n      }else{\n        pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags);\n      }\n    }\n\n    /* Fill in pNew->pLeft and pNew->pRight. */\n    if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){\n      zAlloc += dupedExprNodeSize(p, dupFlags);\n      if( !ExprHasProperty(pNew, EP_TokenOnly|EP_Leaf) ){\n        pNew->pLeft = p->pLeft ?\n                      exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc) : 0;\n        pNew->pRight = p->pRight ?\n                       exprDup(db, p->pRight, EXPRDUP_REDUCE, &zAlloc) : 0;\n      }\n      if( pzBuffer ){\n        *pzBuffer = zAlloc;\n      }\n    }else{\n      if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){\n        if( pNew->op==TK_SELECT_COLUMN ){\n          pNew->pLeft = p->pLeft;\n          assert( p->iColumn==0 || p->pRight==0 );\n          assert( p->pRight==0  || p->pRight==p->pLeft );\n        }else{\n          pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);\n        }\n        pNew->pRight = sqlite3ExprDup(db, p->pRight, 0);\n      }\n    }\n  }\n  return pNew;\n}\n\n/*\n** Create and return a deep copy of the object passed as the second \n** argument. If an OOM condition is encountered, NULL is returned\n** and the db->mallocFailed flag set.\n*/\n#ifndef SQLITE_OMIT_CTE\nstatic With *withDup(sqlite3 *db, With *p){\n  With *pRet = 0;\n  if( p ){\n    int nByte = sizeof(*p) + sizeof(p->a[0]) * (p->nCte-1);\n    pRet = sqlite3DbMallocZero(db, nByte);\n    if( pRet ){\n      int i;\n      pRet->nCte = p->nCte;\n      for(i=0; i<p->nCte; i++){\n        pRet->a[i].pSelect = sqlite3SelectDup(db, p->a[i].pSelect, 0);\n        pRet->a[i].pCols = sqlite3ExprListDup(db, p->a[i].pCols, 0);\n        pRet->a[i].zName = sqlite3DbStrDup(db, p->a[i].zName);\n      }\n    }\n  }\n  return pRet;\n}\n#else\n# define withDup(x,y) 0\n#endif\n\n/*\n** The following group of routines make deep copies of expressions,\n** expression lists, ID lists, and select statements.  The copies can\n** be deleted (by being passed to their respective ...Delete() routines)\n** without effecting the originals.\n**\n** The expression list, ID, and source lists return by sqlite3ExprListDup(),\n** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded \n** by subsequent calls to sqlite*ListAppend() routines.\n**\n** Any tables that the SrcList might point to are not duplicated.\n**\n** The flags parameter contains a combination of the EXPRDUP_XXX flags.\n** If the EXPRDUP_REDUCE flag is set, then the structure returned is a\n** truncated version of the usual Expr structure that will be stored as\n** part of the in-memory representation of the database schema.\n*/\nExpr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){\n  assert( flags==0 || flags==EXPRDUP_REDUCE );\n  return p ? exprDup(db, p, flags, 0) : 0;\n}\nExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){\n  ExprList *pNew;\n  struct ExprList_item *pItem, *pOldItem;\n  int i;\n  Expr *pPriorSelectCol = 0;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));\n  if( pNew==0 ) return 0;\n  pNew->nExpr = p->nExpr;\n  pItem = pNew->a;\n  pOldItem = p->a;\n  for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){\n    Expr *pOldExpr = pOldItem->pExpr;\n    Expr *pNewExpr;\n    pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);\n    if( pOldExpr \n     && pOldExpr->op==TK_SELECT_COLUMN\n     && (pNewExpr = pItem->pExpr)!=0 \n    ){\n      assert( pNewExpr->iColumn==0 || i>0 );\n      if( pNewExpr->iColumn==0 ){\n        assert( pOldExpr->pLeft==pOldExpr->pRight );\n        pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;\n      }else{\n        assert( i>0 );\n        assert( pItem[-1].pExpr!=0 );\n        assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );\n        assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );\n        pNewExpr->pLeft = pPriorSelectCol;\n      }\n    }\n    pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);\n    pItem->sortOrder = pOldItem->sortOrder;\n    pItem->done = 0;\n    pItem->bSpanIsTab = pOldItem->bSpanIsTab;\n    pItem->u = pOldItem->u;\n  }\n  return pNew;\n}\n\n/*\n** If cursors, triggers, views and subqueries are all omitted from\n** the build, then none of the following routines, except for \n** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes\n** called with a NULL argument.\n*/\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \\\n || !defined(SQLITE_OMIT_SUBQUERY)\nSrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){\n  SrcList *pNew;\n  int i;\n  int nByte;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);\n  pNew = sqlite3DbMallocRawNN(db, nByte );\n  if( pNew==0 ) return 0;\n  pNew->nSrc = pNew->nAlloc = p->nSrc;\n  for(i=0; i<p->nSrc; i++){\n    struct SrcList_item *pNewItem = &pNew->a[i];\n    struct SrcList_item *pOldItem = &p->a[i];\n    Table *pTab;\n    pNewItem->pSchema = pOldItem->pSchema;\n    pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase);\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias);\n    pNewItem->fg = pOldItem->fg;\n    pNewItem->iCursor = pOldItem->iCursor;\n    pNewItem->addrFillSub = pOldItem->addrFillSub;\n    pNewItem->regReturn = pOldItem->regReturn;\n    if( pNewItem->fg.isIndexedBy ){\n      pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy);\n    }\n    pNewItem->pIBIndex = pOldItem->pIBIndex;\n    if( pNewItem->fg.isTabFunc ){\n      pNewItem->u1.pFuncArg = \n          sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags);\n    }\n    pTab = pNewItem->pTab = pOldItem->pTab;\n    if( pTab ){\n      pTab->nTabRef++;\n    }\n    pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags);\n    pNewItem->pOn = sqlite3ExprDup(db, pOldItem->pOn, flags);\n    pNewItem->pUsing = sqlite3IdListDup(db, pOldItem->pUsing);\n    pNewItem->colUsed = pOldItem->colUsed;\n  }\n  return pNew;\n}\nIdList *sqlite3IdListDup(sqlite3 *db, IdList *p){\n  IdList *pNew;\n  int i;\n  assert( db!=0 );\n  if( p==0 ) return 0;\n  pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  pNew->nId = p->nId;\n  pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) );\n  if( pNew->a==0 ){\n    sqlite3DbFreeNN(db, pNew);\n    return 0;\n  }\n  /* Note that because the size of the allocation for p->a[] is not\n  ** necessarily a power of two, sqlite3IdListAppend() may not be called\n  ** on the duplicate created by this function. */\n  for(i=0; i<p->nId; i++){\n    struct IdList_item *pNewItem = &pNew->a[i];\n    struct IdList_item *pOldItem = &p->a[i];\n    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);\n    pNewItem->idx = pOldItem->idx;\n  }\n  return pNew;\n}\nSelect *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){\n  Select *pRet = 0;\n  Select *pNext = 0;\n  Select **pp = &pRet;\n  Select *p;\n\n  assert( db!=0 );\n  for(p=pDup; p; p=p->pPrior){\n    Select *pNew = sqlite3DbMallocRawNN(db, sizeof(*p) );\n    if( pNew==0 ) break;\n    pNew->pEList = sqlite3ExprListDup(db, p->pEList, flags);\n    pNew->pSrc = sqlite3SrcListDup(db, p->pSrc, flags);\n    pNew->pWhere = sqlite3ExprDup(db, p->pWhere, flags);\n    pNew->pGroupBy = sqlite3ExprListDup(db, p->pGroupBy, flags);\n    pNew->pHaving = sqlite3ExprDup(db, p->pHaving, flags);\n    pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, flags);\n    pNew->op = p->op;\n    pNew->pNext = pNext;\n    pNew->pPrior = 0;\n    pNew->pLimit = sqlite3ExprDup(db, p->pLimit, flags);\n    pNew->pOffset = sqlite3ExprDup(db, p->pOffset, flags);\n    pNew->iLimit = 0;\n    pNew->iOffset = 0;\n    pNew->selFlags = p->selFlags & ~SF_UsesEphemeral;\n    pNew->addrOpenEphm[0] = -1;\n    pNew->addrOpenEphm[1] = -1;\n    pNew->nSelectRow = p->nSelectRow;\n    pNew->pWith = withDup(db, p->pWith);\n    sqlite3SelectSetName(pNew, p->zSelName);\n    *pp = pNew;\n    pp = &pNew->pPrior;\n    pNext = pNew;\n  }\n\n  return pRet;\n}\n#else\nSelect *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){\n  assert( p==0 );\n  return 0;\n}\n#endif\n\n\n/*\n** Add a new element to the end of an expression list.  If pList is\n** initially NULL, then create a new expression list.\n**\n** The pList argument must be either NULL or a pointer to an ExprList\n** obtained from a prior call to sqlite3ExprListAppend().  This routine\n** may not be used with an ExprList obtained from sqlite3ExprListDup().\n** Reason:  This routine assumes that the number of slots in pList->a[]\n** is a power of two.  That is true for sqlite3ExprListAppend() returns\n** but is not necessarily true from the return value of sqlite3ExprListDup().\n**\n** If a memory allocation error occurs, the entire list is freed and\n** NULL is returned.  If non-NULL is returned, then it is guaranteed\n** that the new entry was successfully appended.\n*/\nExprList *sqlite3ExprListAppend(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to append. Might be NULL */\n  Expr *pExpr             /* Expression to be appended. Might be NULL */\n){\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  assert( db!=0 );\n  if( pList==0 ){\n    pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) );\n    if( pList==0 ){\n      goto no_mem;\n    }\n    pList->nExpr = 0;\n  }else if( (pList->nExpr & (pList->nExpr-1))==0 ){\n    ExprList *pNew;\n    pNew = sqlite3DbRealloc(db, pList, \n             sizeof(*pList)+(2*pList->nExpr - 1)*sizeof(pList->a[0]));\n    if( pNew==0 ){\n      goto no_mem;\n    }\n    pList = pNew;\n  }\n  pItem = &pList->a[pList->nExpr++];\n  assert( offsetof(struct ExprList_item,zName)==sizeof(pItem->pExpr) );\n  assert( offsetof(struct ExprList_item,pExpr)==0 );\n  memset(&pItem->zName,0,sizeof(*pItem)-offsetof(struct ExprList_item,zName));\n  pItem->pExpr = pExpr;\n  return pList;\n\nno_mem:     \n  /* Avoid leaking memory if malloc has failed. */\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3ExprListDelete(db, pList);\n  return 0;\n}\n\n/*\n** pColumns and pExpr form a vector assignment which is part of the SET\n** clause of an UPDATE statement.  Like this:\n**\n**        (a,b,c) = (expr1,expr2,expr3)\n** Or:    (a,b,c) = (SELECT x,y,z FROM ....)\n**\n** For each term of the vector assignment, append new entries to the\n** expression list pList.  In the case of a subquery on the RHS, append\n** TK_SELECT_COLUMN expressions.\n*/\nExprList *sqlite3ExprListAppendVector(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pList,       /* List to which to append. Might be NULL */\n  IdList *pColumns,      /* List of names of LHS of the assignment */\n  Expr *pExpr            /* Vector expression to be appended. Might be NULL */\n){\n  sqlite3 *db = pParse->db;\n  int n;\n  int i;\n  int iFirst = pList ? pList->nExpr : 0;\n  /* pColumns can only be NULL due to an OOM but an OOM will cause an\n  ** exit prior to this routine being invoked */\n  if( NEVER(pColumns==0) ) goto vector_append_error;\n  if( pExpr==0 ) goto vector_append_error;\n\n  /* If the RHS is a vector, then we can immediately check to see that \n  ** the size of the RHS and LHS match.  But if the RHS is a SELECT, \n  ** wildcards (\"*\") in the result set of the SELECT must be expanded before\n  ** we can do the size check, so defer the size check until code generation.\n  */\n  if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){\n    sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                    pColumns->nId, n);\n    goto vector_append_error;\n  }\n\n  for(i=0; i<pColumns->nId; i++){\n    Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);\n    pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);\n    if( pList ){\n      assert( pList->nExpr==iFirst+i+1 );\n      pList->a[pList->nExpr-1].zName = pColumns->a[i].zName;\n      pColumns->a[i].zName = 0;\n    }\n  }\n\n  if( !db->mallocFailed && pExpr->op==TK_SELECT && ALWAYS(pList!=0) ){\n    Expr *pFirst = pList->a[iFirst].pExpr;\n    assert( pFirst!=0 );\n    assert( pFirst->op==TK_SELECT_COLUMN );\n     \n    /* Store the SELECT statement in pRight so it will be deleted when\n    ** sqlite3ExprListDelete() is called */\n    pFirst->pRight = pExpr;\n    pExpr = 0;\n\n    /* Remember the size of the LHS in iTable so that we can check that\n    ** the RHS and LHS sizes match during code generation. */\n    pFirst->iTable = pColumns->nId;\n  }\n\nvector_append_error:\n  sqlite3ExprDelete(db, pExpr);\n  sqlite3IdListDelete(db, pColumns);\n  return pList;\n}\n\n/*\n** Set the sort order for the last element on the given ExprList.\n*/\nvoid sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){\n  if( p==0 ) return;\n  assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 );\n  assert( p->nExpr>0 );\n  if( iSortOrder<0 ){\n    assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC );\n    return;\n  }\n  p->a[p->nExpr-1].sortOrder = (u8)iSortOrder;\n}\n\n/*\n** Set the ExprList.a[].zName element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pName should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nvoid sqlite3ExprListSetName(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  Token *pName,           /* Name to be added */\n  int dequote             /* True to cause the name to be dequoted */\n){\n  assert( pList!=0 || pParse->db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem;\n    assert( pList->nExpr>0 );\n    pItem = &pList->a[pList->nExpr-1];\n    assert( pItem->zName==0 );\n    pItem->zName = sqlite3DbStrNDup(pParse->db, pName->z, pName->n);\n    if( dequote ) sqlite3Dequote(pItem->zName);\n  }\n}\n\n/*\n** Set the ExprList.a[].zSpan element of the most recently added item\n** on the expression list.\n**\n** pList might be NULL following an OOM error.  But pSpan should never be\n** NULL.  If a memory allocation fails, the pParse->db->mallocFailed flag\n** is set.\n*/\nvoid sqlite3ExprListSetSpan(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pList,        /* List to which to add the span. */\n  ExprSpan *pSpan         /* The span to be added */\n){\n  sqlite3 *db = pParse->db;\n  assert( pList!=0 || db->mallocFailed!=0 );\n  if( pList ){\n    struct ExprList_item *pItem = &pList->a[pList->nExpr-1];\n    assert( pList->nExpr>0 );\n    assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem->zSpan = sqlite3DbStrNDup(db, (char*)pSpan->zStart,\n                                    (int)(pSpan->zEnd - pSpan->zStart));\n  }\n}\n\n/*\n** If the expression list pEList contains more than iLimit elements,\n** leave an error message in pParse.\n*/\nvoid sqlite3ExprListCheckLength(\n  Parse *pParse,\n  ExprList *pEList,\n  const char *zObject\n){\n  int mx = pParse->db->aLimit[SQLITE_LIMIT_COLUMN];\n  testcase( pEList && pEList->nExpr==mx );\n  testcase( pEList && pEList->nExpr==mx+1 );\n  if( pEList && pEList->nExpr>mx ){\n    sqlite3ErrorMsg(pParse, \"too many columns in %s\", zObject);\n  }\n}\n\n/*\n** Delete an entire expression list.\n*/\nstatic SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){\n  int i = pList->nExpr;\n  struct ExprList_item *pItem =  pList->a;\n  assert( pList->nExpr>0 );\n  do{\n    sqlite3ExprDelete(db, pItem->pExpr);\n    sqlite3DbFree(db, pItem->zName);\n    sqlite3DbFree(db, pItem->zSpan);\n    pItem++;\n  }while( --i>0 );\n  sqlite3DbFreeNN(db, pList);\n}\nvoid sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){\n  if( pList ) exprListDeleteNN(db, pList);\n}\n\n/*\n** Return the bitwise-OR of all Expr.flags fields in the given\n** ExprList.\n*/\nu32 sqlite3ExprListFlags(const ExprList *pList){\n  int i;\n  u32 m = 0;\n  assert( pList!=0 );\n  for(i=0; i<pList->nExpr; i++){\n     Expr *pExpr = pList->a[i].pExpr;\n     assert( pExpr!=0 );\n     m |= pExpr->flags;\n  }\n  return m;\n}\n\n/*\n** This is a SELECT-node callback for the expression walker that\n** always \"fails\".  By \"fail\" in this case, we mean set\n** pWalker->eCode to zero and abort.\n**\n** This callback is used by multiple expression walkers.\n*/\nint sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  pWalker->eCode = 0;\n  return WRC_Abort;\n}\n\n/*\n** These routines are Walker callbacks used to check expressions to\n** see if they are \"constant\" for some definition of constant.  The\n** Walker.eCode value determines the type of \"constant\" we are looking\n** for.\n**\n** These callback routines are used to implement the following:\n**\n**     sqlite3ExprIsConstant()                  pWalker->eCode==1\n**     sqlite3ExprIsConstantNotJoin()           pWalker->eCode==2\n**     sqlite3ExprIsTableConstant()             pWalker->eCode==3\n**     sqlite3ExprIsConstantOrFunction()        pWalker->eCode==4 or 5\n**\n** In all cases, the callbacks set Walker.eCode=0 and abort if the expression\n** is found to not be a constant.\n**\n** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions\n** in a CREATE TABLE statement.  The Walker.eCode value is 5 when parsing\n** an existing schema and 4 when processing a new statement.  A bound\n** parameter raises an error for new statements, but is silently converted\n** to NULL for existing schemas.  This allows sqlite_master tables that \n** contain a bound parameter because they were generated by older versions\n** of SQLite to be parsed by newer versions of SQLite without raising a\n** malformed schema error.\n*/\nstatic int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){\n\n  /* If pWalker->eCode is 2 then any term of the expression that comes from\n  ** the ON or USING clauses of a left join disqualifies the expression\n  ** from being considered constant. */\n  if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  switch( pExpr->op ){\n    /* Consider functions to be constant if all their arguments are constant\n    ** and either pWalker->eCode==4 or 5 or the function has the\n    ** SQLITE_FUNC_CONST flag. */\n    case TK_FUNCTION:\n      if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){\n        return WRC_Continue;\n      }else{\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n    case TK_ID:\n    case TK_COLUMN:\n    case TK_AGG_FUNCTION:\n    case TK_AGG_COLUMN:\n      testcase( pExpr->op==TK_ID );\n      testcase( pExpr->op==TK_COLUMN );\n      testcase( pExpr->op==TK_AGG_FUNCTION );\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){\n        return WRC_Continue;\n      }\n      /* Fall through */\n    case TK_IF_NULL_ROW:\n      testcase( pExpr->op==TK_IF_NULL_ROW );\n      pWalker->eCode = 0;\n      return WRC_Abort;\n    case TK_VARIABLE:\n      if( pWalker->eCode==5 ){\n        /* Silently convert bound parameters that appear inside of CREATE\n        ** statements into a NULL when parsing the CREATE statement text out\n        ** of the sqlite_master table */\n        pExpr->op = TK_NULL;\n      }else if( pWalker->eCode==4 ){\n        /* A bound parameter in a CREATE statement that originates from\n        ** sqlite3_prepare() causes an error */\n        pWalker->eCode = 0;\n        return WRC_Abort;\n      }\n      /* Fall through */\n    default:\n      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail will disallow */\n      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail will disallow */\n      return WRC_Continue;\n  }\n}\nstatic int exprIsConst(Expr *p, int initFlag, int iCur){\n  Walker w;\n  w.eCode = initFlag;\n  w.xExprCallback = exprNodeIsConstant;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  w.u.iCur = iCur;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** and 0 if it involves variables or function calls.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nint sqlite3ExprIsConstant(Expr *p){\n  return exprIsConst(p, 1, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** that does no originate from the ON or USING clauses of a join.\n** Return 0 if it involves variables or function calls or terms from\n** an ON or USING clause.\n*/\nint sqlite3ExprIsConstantNotJoin(Expr *p){\n  return exprIsConst(p, 2, 0);\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** for any single row of the table with cursor iCur.  In other words, the\n** expression must not refer to any non-deterministic function nor any\n** table other than iCur.\n*/\nint sqlite3ExprIsTableConstant(Expr *p, int iCur){\n  return exprIsConst(p, 3, iCur);\n}\n\n\n/*\n** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy().\n*/\nstatic int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){\n  ExprList *pGroupBy = pWalker->u.pGroupBy;\n  int i;\n\n  /* Check if pExpr is identical to any GROUP BY term. If so, consider\n  ** it constant.  */\n  for(i=0; i<pGroupBy->nExpr; i++){\n    Expr *p = pGroupBy->a[i].pExpr;\n    if( sqlite3ExprCompare(0, pExpr, p, -1)<2 ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pWalker->pParse, p);\n      if( sqlite3_stricmp(\"BINARY\", pColl->zName)==0 ){\n        return WRC_Prune;\n      }\n    }\n  }\n\n  /* Check if pExpr is a sub-select. If so, consider it variable. */\n  if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n\n  return exprNodeIsConstant(pWalker, pExpr);\n}\n\n/*\n** Walk the expression tree passed as the first argument. Return non-zero\n** if the expression consists entirely of constants or copies of terms \n** in pGroupBy that sort with the BINARY collation sequence.\n**\n** This routine is used to determine if a term of the HAVING clause can\n** be promoted into the WHERE clause.  In order for such a promotion to work,\n** the value of the HAVING clause term must be the same for all members of\n** a \"group\".  The requirement that the GROUP BY term must be BINARY\n** assumes that no other collating sequence will have a finer-grained\n** grouping than binary.  In other words (A=B COLLATE binary) implies\n** A=B in every other collating sequence.  The requirement that the\n** GROUP BY be BINARY is stricter than necessary.  It would also work\n** to promote HAVING clauses that use the same alternative collating\n** sequence as the GROUP BY term, but that is much harder to check,\n** alternative collating sequences are uncommon, and this is only an\n** optimization, so we take the easy way out and simply require the\n** GROUP BY to use the BINARY collating sequence.\n*/\nint sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsConstantOrGroupBy;\n  w.xSelectCallback = 0;\n  w.u.pGroupBy = pGroupBy;\n  w.pParse = pParse;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Walk an expression tree.  Return non-zero if the expression is constant\n** or a function call with constant arguments.  Return and 0 if there\n** are any variables.\n**\n** For the purposes of this function, a double-quoted string (ex: \"abc\")\n** is considered a variable but a single-quoted string (ex: 'abc') is\n** a constant.\n*/\nint sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){\n  assert( isInit==0 || isInit==1 );\n  return exprIsConst(p, 4+isInit, 0);\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Walk an expression tree.  Return 1 if the expression contains a\n** subquery of some kind.  Return 0 if there are no subqueries.\n*/\nint sqlite3ExprContainsSubquery(Expr *p){\n  Walker w;\n  w.eCode = 1;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n#ifdef SQLITE_DEBUG\n  w.xSelectCallback2 = sqlite3SelectWalkAssert2;\n#endif\n  sqlite3WalkExpr(&w, p);\n  return w.eCode==0;\n}\n#endif\n\n/*\n** If the expression p codes a constant integer that is small enough\n** to fit in a 32-bit integer, return 1 and put the value of the integer\n** in *pValue.  If the expression is not an integer or if it is too big\n** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.\n*/\nint sqlite3ExprIsInteger(Expr *p, int *pValue){\n  int rc = 0;\n  if( p==0 ) return 0;  /* Can only happen following on OOM */\n\n  /* If an expression is an integer literal that fits in a signed 32-bit\n  ** integer, then the EP_IntValue flag will have already been set */\n  assert( p->op!=TK_INTEGER || (p->flags & EP_IntValue)!=0\n           || sqlite3GetInt32(p->u.zToken, &rc)==0 );\n\n  if( p->flags & EP_IntValue ){\n    *pValue = p->u.iValue;\n    return 1;\n  }\n  switch( p->op ){\n    case TK_UPLUS: {\n      rc = sqlite3ExprIsInteger(p->pLeft, pValue);\n      break;\n    }\n    case TK_UMINUS: {\n      int v;\n      if( sqlite3ExprIsInteger(p->pLeft, &v) ){\n        assert( v!=(-2147483647-1) );\n        *pValue = -v;\n        rc = 1;\n      }\n      break;\n    }\n    default: break;\n  }\n  return rc;\n}\n\n/*\n** Return FALSE if there is no chance that the expression can be NULL.\n**\n** If the expression might be NULL or if the expression is too complex\n** to tell return TRUE.  \n**\n** This routine is used as an optimization, to skip OP_IsNull opcodes\n** when we know that a value cannot be NULL.  Hence, a false positive\n** (returning TRUE when in fact the expression can never be NULL) might\n** be a small performance hit but is otherwise harmless.  On the other\n** hand, a false negative (returning FALSE when the result could be NULL)\n** will likely result in an incorrect answer.  So when in doubt, return\n** TRUE.\n*/\nint sqlite3ExprCanBeNull(const Expr *p){\n  u8 op;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER:\n    case TK_STRING:\n    case TK_FLOAT:\n    case TK_BLOB:\n      return 0;\n    case TK_COLUMN:\n      return ExprHasProperty(p, EP_CanBeNull) ||\n             p->pTab==0 ||  /* Reference to column of index on expression */\n             (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);\n    default:\n      return 1;\n  }\n}\n\n/*\n** Return TRUE if the given expression is a constant which would be\n** unchanged by OP_Affinity with the affinity given in the second\n** argument.\n**\n** This routine is used to determine if the OP_Affinity operation\n** can be omitted.  When in doubt return FALSE.  A false negative\n** is harmless.  A false positive, however, can result in the wrong\n** answer.\n*/\nint sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){\n  u8 op;\n  if( aff==SQLITE_AFF_BLOB ) return 1;\n  while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }\n  op = p->op;\n  if( op==TK_REGISTER ) op = p->op2;\n  switch( op ){\n    case TK_INTEGER: {\n      return aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_FLOAT: {\n      return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;\n    }\n    case TK_STRING: {\n      return aff==SQLITE_AFF_TEXT;\n    }\n    case TK_BLOB: {\n      return 1;\n    }\n    case TK_COLUMN: {\n      assert( p->iTable>=0 );  /* p cannot be part of a CHECK constraint */\n      return p->iColumn<0\n          && (aff==SQLITE_AFF_INTEGER || aff==SQLITE_AFF_NUMERIC);\n    }\n    default: {\n      return 0;\n    }\n  }\n}\n\n/*\n** Return TRUE if the given string is a row-id column name.\n*/\nint sqlite3IsRowid(const char *z){\n  if( sqlite3StrICmp(z, \"_ROWID_\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"ROWID\")==0 ) return 1;\n  if( sqlite3StrICmp(z, \"OID\")==0 ) return 1;\n  return 0;\n}\n\n/*\n** pX is the RHS of an IN operator.  If pX is a SELECT statement \n** that can be simplified to a direct table access, then return\n** a pointer to the SELECT statement.  If pX is not a SELECT statement,\n** or if the SELECT statement needs to be manifested into a transient\n** table, then return NULL.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nstatic Select *isCandidateForInOpt(Expr *pX){\n  Select *p;\n  SrcList *pSrc;\n  ExprList *pEList;\n  Table *pTab;\n  int i;\n  if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0;  /* Not a subquery */\n  if( ExprHasProperty(pX, EP_VarSelect)  ) return 0;  /* Correlated subq */\n  p = pX->x.pSelect;\n  if( p->pPrior ) return 0;              /* Not a compound SELECT */\n  if( p->selFlags & (SF_Distinct|SF_Aggregate) ){\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n    testcase( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n    return 0; /* No DISTINCT keyword and no aggregate functions */\n  }\n  assert( p->pGroupBy==0 );              /* Has no GROUP BY clause */\n  if( p->pLimit ) return 0;              /* Has no LIMIT clause */\n  assert( p->pOffset==0 );               /* No LIMIT means no OFFSET */\n  if( p->pWhere ) return 0;              /* Has no WHERE clause */\n  pSrc = p->pSrc;\n  assert( pSrc!=0 );\n  if( pSrc->nSrc!=1 ) return 0;          /* Single term in FROM clause */\n  if( pSrc->a[0].pSelect ) return 0;     /* FROM is not a subquery or view */\n  pTab = pSrc->a[0].pTab;\n  assert( pTab!=0 );\n  assert( pTab->pSelect==0 );            /* FROM clause is not a view */\n  if( IsVirtual(pTab) ) return 0;        /* FROM clause not a virtual table */\n  pEList = p->pEList;\n  assert( pEList!=0 );\n  /* All SELECT results must be columns. */\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *pRes = pEList->a[i].pExpr;\n    if( pRes->op!=TK_COLUMN ) return 0;\n    assert( pRes->iTable==pSrc->a[0].iCursor );  /* Not a correlated subquery */\n  }\n  return p;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code that checks the left-most column of index table iCur to see if\n** it contains any NULL entries.  Cause the register at regHasNull to be set\n** to a non-NULL value if iCur contains no NULLs.  Cause register regHasNull\n** to be set to NULL if iCur contains one or more NULL values.\n*/\nstatic void sqlite3SetHasNullFlag(Vdbe *v, int iCur, int regHasNull){\n  int addr1;\n  sqlite3VdbeAddOp2(v, OP_Integer, 0, regHasNull);\n  addr1 = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_Column, iCur, 0, regHasNull);\n  sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n  VdbeComment((v, \"first_entry_in(%d)\", iCur));\n  sqlite3VdbeJumpHere(v, addr1);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** The argument is an IN operator with a list (not a subquery) on the \n** right-hand side.  Return TRUE if that list is constant.\n*/\nstatic int sqlite3InRhsIsConstant(Expr *pIn){\n  Expr *pLHS;\n  int res;\n  assert( !ExprHasProperty(pIn, EP_xIsSelect) );\n  pLHS = pIn->pLeft;\n  pIn->pLeft = 0;\n  res = sqlite3ExprIsConstant(pIn);\n  pIn->pLeft = pLHS;\n  return res;\n}\n#endif\n\n/*\n** This function is used by the implementation of the IN (...) operator.\n** The pX parameter is the expression on the RHS of the IN operator, which\n** might be either a list of expressions or a subquery.\n**\n** The job of this routine is to find or create a b-tree object that can\n** be used either to test for membership in the RHS set or to iterate through\n** all members of the RHS set, skipping duplicates.\n**\n** A cursor is opened on the b-tree object that is the RHS of the IN operator\n** and pX->iTable is set to the index of that cursor.\n**\n** The returned value of this function indicates the b-tree type, as follows:\n**\n**   IN_INDEX_ROWID      - The cursor was opened on a database table.\n**   IN_INDEX_INDEX_ASC  - The cursor was opened on an ascending index.\n**   IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.\n**   IN_INDEX_EPH        - The cursor was opened on a specially created and\n**                         populated epheremal table.\n**   IN_INDEX_NOOP       - No cursor was allocated.  The IN operator must be\n**                         implemented as a sequence of comparisons.\n**\n** An existing b-tree might be used if the RHS expression pX is a simple\n** subquery such as:\n**\n**     SELECT <column1>, <column2>... FROM <table>\n**\n** If the RHS of the IN operator is a list or a more complex subquery, then\n** an ephemeral table might need to be generated from the RHS and then\n** pX->iTable made to point to the ephemeral table instead of an\n** existing table.\n**\n** The inFlags parameter must contain exactly one of the bits\n** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP.  If inFlags contains\n** IN_INDEX_MEMBERSHIP, then the generated table will be used for a\n** fast membership test.  When the IN_INDEX_LOOP bit is set, the\n** IN index will be used to loop over all values of the RHS of the\n** IN operator.\n**\n** When IN_INDEX_LOOP is used (and the b-tree will be used to iterate\n** through the set members) then the b-tree must not contain duplicates.\n** An epheremal table must be used unless the selected columns are guaranteed\n** to be unique - either because it is an INTEGER PRIMARY KEY or due to\n** a UNIQUE constraint or index.\n**\n** When IN_INDEX_MEMBERSHIP is used (and the b-tree will be used \n** for fast set membership tests) then an epheremal table must \n** be used unless <columns> is a single INTEGER PRIMARY KEY column or an \n** index can be found with the specified <columns> as its left-most.\n**\n** If the IN_INDEX_NOOP_OK and IN_INDEX_MEMBERSHIP are both set and\n** if the RHS of the IN operator is a list (not a subquery) then this\n** routine might decide that creating an ephemeral b-tree for membership\n** testing is too expensive and return IN_INDEX_NOOP.  In that case, the\n** calling routine should implement the IN operator using a sequence\n** of Eq or Ne comparison operations.\n**\n** When the b-tree is being used for membership tests, the calling function\n** might need to know whether or not the RHS side of the IN operator\n** contains a NULL.  If prRhsHasNull is not a NULL pointer and \n** if there is any chance that the (...) might contain a NULL value at\n** runtime, then a register is allocated and the register number written\n** to *prRhsHasNull. If there is no chance that the (...) contains a\n** NULL value, then *prRhsHasNull is left unchanged.\n**\n** If a register is allocated and its location stored in *prRhsHasNull, then\n** the value in that register will be NULL if the b-tree contains one or more\n** NULL values, and it will be some non-NULL value if the b-tree contains no\n** NULL values.\n**\n** If the aiMap parameter is not NULL, it must point to an array containing\n** one element for each column returned by the SELECT statement on the RHS\n** of the IN(...) operator. The i'th entry of the array is populated with the\n** offset of the index column that matches the i'th column returned by the\n** SELECT. For example, if the expression and selected index are:\n**\n**   (?,?,?) IN (SELECT a, b, c FROM t1)\n**   CREATE INDEX i1 ON t1(b, c, a);\n**\n** then aiMap[] is populated with {2, 0, 1}.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nint sqlite3FindInIndex(\n  Parse *pParse,             /* Parsing context */\n  Expr *pX,                  /* The right-hand side (RHS) of the IN operator */\n  u32 inFlags,               /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */\n  int *prRhsHasNull,         /* Register holding NULL status.  See notes */\n  int *aiMap                 /* Mapping from Index fields to RHS fields */\n){\n  Select *p;                            /* SELECT to the right of IN operator */\n  int eType = 0;                        /* Type of RHS table. IN_INDEX_* */\n  int iTab = pParse->nTab++;            /* Cursor of the RHS table */\n  int mustBeUnique;                     /* True if RHS must be unique */\n  Vdbe *v = sqlite3GetVdbe(pParse);     /* Virtual machine being coded */\n\n  assert( pX->op==TK_IN );\n  mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;\n\n  /* If the RHS of this IN(...) operator is a SELECT, and if it matters \n  ** whether or not the SELECT result contains NULL values, check whether\n  ** or not NULL is actually possible (it may not be, for example, due \n  ** to NOT NULL constraints in the schema). If no NULL values are possible,\n  ** set prRhsHasNull to 0 before continuing.  */\n  if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){\n    int i;\n    ExprList *pEList = pX->x.pSelect->pEList;\n    for(i=0; i<pEList->nExpr; i++){\n      if( sqlite3ExprCanBeNull(pEList->a[i].pExpr) ) break;\n    }\n    if( i==pEList->nExpr ){\n      prRhsHasNull = 0;\n    }\n  }\n\n  /* Check to see if an existing table or index can be used to\n  ** satisfy the query.  This is preferable to generating a new \n  ** ephemeral table.  */\n  if( pParse->nErr==0 && (p = isCandidateForInOpt(pX))!=0 ){\n    sqlite3 *db = pParse->db;              /* Database connection */\n    Table *pTab;                           /* Table <table>. */\n    i16 iDb;                               /* Database idx for pTab */\n    ExprList *pEList = p->pEList;\n    int nExpr = pEList->nExpr;\n\n    assert( p->pEList!=0 );             /* Because of isCandidateForInOpt(p) */\n    assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */\n    assert( p->pSrc!=0 );               /* Because of isCandidateForInOpt(p) */\n    pTab = p->pSrc->a[0].pTab;\n\n    /* Code an OP_Transaction and OP_TableLock for <table>. */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3CodeVerifySchema(pParse, iDb);\n    sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n    assert(v);  /* sqlite3GetVdbe() has always been previously called */\n    if( nExpr==1 && pEList->a[0].pExpr->iColumn<0 ){\n      /* The \"x IN (SELECT rowid FROM table)\" case */\n      int iAddr = sqlite3VdbeAddOp0(v, OP_Once);\n      VdbeCoverage(v);\n\n      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);\n      eType = IN_INDEX_ROWID;\n\n      sqlite3VdbeJumpHere(v, iAddr);\n    }else{\n      Index *pIdx;                         /* Iterator variable */\n      int affinity_ok = 1;\n      int i;\n\n      /* Check that the affinity that will be used to perform each \n      ** comparison is the same as the affinity of each column in table\n      ** on the RHS of the IN operator.  If it not, it is not possible to\n      ** use any index of the RHS table.  */\n      for(i=0; i<nExpr && affinity_ok; i++){\n        Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n        int iCol = pEList->a[i].pExpr->iColumn;\n        char idxaff = sqlite3TableColumnAffinity(pTab,iCol); /* RHS table */\n        char cmpaff = sqlite3CompareAffinity(pLhs, idxaff);\n        testcase( cmpaff==SQLITE_AFF_BLOB );\n        testcase( cmpaff==SQLITE_AFF_TEXT );\n        switch( cmpaff ){\n          case SQLITE_AFF_BLOB:\n            break;\n          case SQLITE_AFF_TEXT:\n            /* sqlite3CompareAffinity() only returns TEXT if one side or the\n            ** other has no affinity and the other side is TEXT.  Hence,\n            ** the only way for cmpaff to be TEXT is for idxaff to be TEXT\n            ** and for the term on the LHS of the IN to have no affinity. */\n            assert( idxaff==SQLITE_AFF_TEXT );\n            break;\n          default:\n            affinity_ok = sqlite3IsNumericAffinity(idxaff);\n        }\n      }\n\n      if( affinity_ok ){\n        /* Search for an existing index that will work for this IN operator */\n        for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){\n          Bitmask colUsed;      /* Columns of the index used */\n          Bitmask mCol;         /* Mask for the current column */\n          if( pIdx->nColumn<nExpr ) continue;\n          /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute\n          ** BITMASK(nExpr) without overflowing */\n          testcase( pIdx->nColumn==BMS-2 );\n          testcase( pIdx->nColumn==BMS-1 );\n          if( pIdx->nColumn>=BMS-1 ) continue;\n          if( mustBeUnique ){\n            if( pIdx->nKeyCol>nExpr\n             ||(pIdx->nColumn>nExpr && !IsUniqueIndex(pIdx))\n            ){\n              continue;  /* This index is not unique over the IN RHS columns */\n            }\n          }\n  \n          colUsed = 0;   /* Columns of index used so far */\n          for(i=0; i<nExpr; i++){\n            Expr *pLhs = sqlite3VectorFieldSubexpr(pX->pLeft, i);\n            Expr *pRhs = pEList->a[i].pExpr;\n            CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n            int j;\n  \n            assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );\n            for(j=0; j<nExpr; j++){\n              if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;\n              assert( pIdx->azColl[j] );\n              if( pReq!=0 && sqlite3StrICmp(pReq->zName, pIdx->azColl[j])!=0 ){\n                continue;\n              }\n              break;\n            }\n            if( j==nExpr ) break;\n            mCol = MASKBIT(j);\n            if( mCol & colUsed ) break; /* Each column used only once */\n            colUsed |= mCol;\n            if( aiMap ) aiMap[i] = j;\n          }\n  \n          assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );\n          if( colUsed==(MASKBIT(nExpr)-1) ){\n            /* If we reach this point, that means the index pIdx is usable */\n            int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n#ifndef SQLITE_OMIT_EXPLAIN\n            sqlite3VdbeAddOp4(v, OP_Explain, 0, 0, 0,\n              sqlite3MPrintf(db, \"USING INDEX %s FOR IN-OPERATOR\",pIdx->zName),\n              P4_DYNAMIC);\n#endif\n            sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n            VdbeComment((v, \"%s\", pIdx->zName));\n            assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );\n            eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];\n  \n            if( prRhsHasNull ){\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n              i64 mask = (1<<nExpr)-1;\n              sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, \n                  iTab, 0, 0, (u8*)&mask, P4_INT64);\n#endif\n              *prRhsHasNull = ++pParse->nMem;\n              if( nExpr==1 ){\n                sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);\n              }\n            }\n            sqlite3VdbeJumpHere(v, iAddr);\n          }\n        } /* End loop over indexes */\n      } /* End if( affinity_ok ) */\n    } /* End if not an rowid index */\n  } /* End attempt to optimize using an index */\n\n  /* If no preexisting index is available for the IN clause\n  ** and IN_INDEX_NOOP is an allowed reply\n  ** and the RHS of the IN operator is a list, not a subquery\n  ** and the RHS is not constant or has two or fewer terms,\n  ** then it is not worth creating an ephemeral table to evaluate\n  ** the IN operator so return IN_INDEX_NOOP.\n  */\n  if( eType==0\n   && (inFlags & IN_INDEX_NOOP_OK)\n   && !ExprHasProperty(pX, EP_xIsSelect)\n   && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)\n  ){\n    eType = IN_INDEX_NOOP;\n  }\n\n  if( eType==0 ){\n    /* Could not find an existing table or index to use as the RHS b-tree.\n    ** We will have to generate an ephemeral table to do the job.\n    */\n    u32 savedNQueryLoop = pParse->nQueryLoop;\n    int rMayHaveNull = 0;\n    eType = IN_INDEX_EPH;\n    if( inFlags & IN_INDEX_LOOP ){\n      pParse->nQueryLoop = 0;\n      if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){\n        eType = IN_INDEX_ROWID;\n      }\n    }else if( prRhsHasNull ){\n      *prRhsHasNull = rMayHaveNull = ++pParse->nMem;\n    }\n    sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);\n    pParse->nQueryLoop = savedNQueryLoop;\n  }else{\n    pX->iTable = iTab;\n  }\n\n  if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){\n    int i, n;\n    n = sqlite3ExprVectorSize(pX->pLeft);\n    for(i=0; i<n; i++) aiMap[i] = i;\n  }\n  return eType;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Argument pExpr is an (?, ?...) IN(...) expression. This \n** function allocates and returns a nul-terminated string containing \n** the affinities to be used for each column of the comparison.\n**\n** It is the responsibility of the caller to ensure that the returned\n** string is eventually freed using sqlite3DbFree().\n*/\nstatic char *exprINAffinity(Parse *pParse, Expr *pExpr){\n  Expr *pLeft = pExpr->pLeft;\n  int nVal = sqlite3ExprVectorSize(pLeft);\n  Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;\n  char *zRet;\n\n  assert( pExpr->op==TK_IN );\n  zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);\n  if( zRet ){\n    int i;\n    for(i=0; i<nVal; i++){\n      Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);\n      char a = sqlite3ExprAffinity(pA);\n      if( pSelect ){\n        zRet[i] = sqlite3CompareAffinity(pSelect->pEList->a[i].pExpr, a);\n      }else{\n        zRet[i] = a;\n      }\n    }\n    zRet[nVal] = '\\0';\n  }\n  return zRet;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Load the Parse object passed as the first argument with an error \n** message of the form:\n**\n**   \"sub-select returns N columns - expected M\"\n*/   \nvoid sqlite3SubselectError(Parse *pParse, int nActual, int nExpect){\n  const char *zFmt = \"sub-select returns %d columns - expected %d\";\n  sqlite3ErrorMsg(pParse, zFmt, nActual, nExpect);\n}\n#endif\n\n/*\n** Expression pExpr is a vector that has been used in a context where\n** it is not permitted. If pExpr is a sub-select vector, this routine \n** loads the Parse object with a message of the form:\n**\n**   \"sub-select returns N columns - expected 1\"\n**\n** Or, if it is a regular scalar vector:\n**\n**   \"row value misused\"\n*/   \nvoid sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){\n#ifndef SQLITE_OMIT_SUBQUERY\n  if( pExpr->flags & EP_xIsSelect ){\n    sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1);\n  }else\n#endif\n  {\n    sqlite3ErrorMsg(pParse, \"row value misused\");\n  }\n}\n\n/*\n** Generate code for scalar subqueries used as a subquery expression, EXISTS,\n** or IN operators.  Examples:\n**\n**     (SELECT a FROM b)          -- subquery\n**     EXISTS (SELECT a FROM b)   -- EXISTS subquery\n**     x IN (4,5,11)              -- IN operator with list on right-hand side\n**     x IN (SELECT a FROM b)     -- IN operator with subquery on the right\n**\n** The pExpr parameter describes the expression that contains the IN\n** operator or subquery.\n**\n** If parameter isRowid is non-zero, then expression pExpr is guaranteed\n** to be of the form \"<rowid> IN (?, ?, ?)\", where <rowid> is a reference\n** to some integer key column of a table B-Tree. In this case, use an\n** intkey B-Tree to store the set of IN(...) values instead of the usual\n** (slower) variable length keys B-Tree.\n**\n** If rMayHaveNull is non-zero, that means that the operation is an IN\n** (not a SELECT or EXISTS) and that the RHS might contains NULLs.\n** All this routine does is initialize the register given by rMayHaveNull\n** to NULL.  Calling routines will take care of changing this register\n** value to non-NULL if the RHS is NULL-free.\n**\n** For a SELECT or EXISTS operator, return the register that holds the\n** result.  For a multi-column SELECT, the result is stored in a contiguous\n** array of registers and the return value is the register of the left-most\n** result column.  Return 0 for IN operators or if an error occurs.\n*/\n#ifndef SQLITE_OMIT_SUBQUERY\nint sqlite3CodeSubselect(\n  Parse *pParse,          /* Parsing context */\n  Expr *pExpr,            /* The IN, SELECT, or EXISTS operator */\n  int rHasNullFlag,       /* Register that records whether NULLs exist in RHS */\n  int isRowid             /* If true, LHS of IN operator is a rowid */\n){\n  int jmpIfDynamic = -1;                      /* One-time test address */\n  int rReg = 0;                           /* Register storing resulting */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  if( NEVER(v==0) ) return 0;\n  sqlite3ExprCachePush(pParse);\n\n  /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it\n  ** is encountered if any of the following is true:\n  **\n  **    *  The right-hand side is a correlated subquery\n  **    *  The right-hand side is an expression list containing variables\n  **    *  We are inside a trigger\n  **\n  ** If all of the above are false, then we can run this code just once\n  ** save the results, and reuse the same result on subsequent invocations.\n  */\n  if( !ExprHasProperty(pExpr, EP_VarSelect) ){\n    jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n  }\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( pParse->explain==2 ){\n    char *zMsg = sqlite3MPrintf(pParse->db, \"EXECUTE %s%s SUBQUERY %d\",\n        jmpIfDynamic>=0?\"\":\"CORRELATED \",\n        pExpr->op==TK_IN?\"LIST\":\"SCALAR\",\n        pParse->iNextSelectId\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n#endif\n\n  switch( pExpr->op ){\n    case TK_IN: {\n      int addr;                   /* Address of OP_OpenEphemeral instruction */\n      Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */\n      KeyInfo *pKeyInfo = 0;      /* Key information */\n      int nVal;                   /* Size of vector pLeft */\n      \n      nVal = sqlite3ExprVectorSize(pLeft);\n      assert( !isRowid || nVal==1 );\n\n      /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'\n      ** expression it is handled the same way.  An ephemeral table is \n      ** filled with index keys representing the results from the \n      ** SELECT or the <exprlist>.\n      **\n      ** If the 'x' expression is a column value, or the SELECT...\n      ** statement returns a column value, then the affinity of that\n      ** column is used to build the index keys. If both 'x' and the\n      ** SELECT... statement are columns, then numeric affinity is used\n      ** if either column has NUMERIC or INTEGER affinity. If neither\n      ** 'x' nor the SELECT... statement are columns, then numeric affinity\n      ** is used.\n      */\n      pExpr->iTable = pParse->nTab++;\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, \n          pExpr->iTable, (isRowid?0:nVal));\n      pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);\n\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* Case 1:     expr IN (SELECT ...)\n        **\n        ** Generate code to write the results of the select into the temporary\n        ** table allocated and opened above.\n        */\n        Select *pSelect = pExpr->x.pSelect;\n        ExprList *pEList = pSelect->pEList;\n\n        assert( !isRowid );\n        /* If the LHS and RHS of the IN operator do not match, that\n        ** error will have been caught long before we reach this point. */\n        if( ALWAYS(pEList->nExpr==nVal) ){\n          SelectDest dest;\n          int i;\n          sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);\n          dest.zAffSdst = exprINAffinity(pParse, pExpr);\n          pSelect->iLimit = 0;\n          testcase( pSelect->selFlags & SF_Distinct );\n          testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */\n          if( sqlite3Select(pParse, pSelect, &dest) ){\n            sqlite3DbFree(pParse->db, dest.zAffSdst);\n            sqlite3KeyInfoUnref(pKeyInfo);\n            return 0;\n          }\n          sqlite3DbFree(pParse->db, dest.zAffSdst);\n          assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */\n          assert( pEList!=0 );\n          assert( pEList->nExpr>0 );\n          assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n          for(i=0; i<nVal; i++){\n            Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);\n            pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(\n                pParse, p, pEList->a[i].pExpr\n            );\n          }\n        }\n      }else if( ALWAYS(pExpr->x.pList!=0) ){\n        /* Case 2:     expr IN (exprlist)\n        **\n        ** For each expression, build an index key from the evaluation and\n        ** store it in the temporary table. If <expr> is a column, then use\n        ** that columns affinity when building index keys. If <expr> is not\n        ** a column, use numeric affinity.\n        */\n        char affinity;            /* Affinity of the LHS of the IN */\n        int i;\n        ExprList *pList = pExpr->x.pList;\n        struct ExprList_item *pItem;\n        int r1, r2, r3;\n\n        affinity = sqlite3ExprAffinity(pLeft);\n        if( !affinity ){\n          affinity = SQLITE_AFF_BLOB;\n        }\n        if( pKeyInfo ){\n          assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );\n          pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n        }\n\n        /* Loop through each expression in <exprlist>. */\n        r1 = sqlite3GetTempReg(pParse);\n        r2 = sqlite3GetTempReg(pParse);\n        if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, \"\", P4_STATIC);\n        for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){\n          Expr *pE2 = pItem->pExpr;\n          int iValToIns;\n\n          /* If the expression is not constant then we will need to\n          ** disable the test that was generated above that makes sure\n          ** this code only executes once.  Because for a non-constant\n          ** expression we need to rerun this code each time.\n          */\n          if( jmpIfDynamic>=0 && !sqlite3ExprIsConstant(pE2) ){\n            sqlite3VdbeChangeToNoop(v, jmpIfDynamic);\n            jmpIfDynamic = -1;\n          }\n\n          /* Evaluate the expression and insert it into the temp table */\n          if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){\n            sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);\n          }else{\n            r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);\n            if( isRowid ){\n              sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,\n                                sqlite3VdbeCurrentAddr(v)+2);\n              VdbeCoverage(v);\n              sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);\n            }else{\n              sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);\n              sqlite3ExprCacheAffinityChange(pParse, r3, 1);\n              sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);\n            }\n          }\n        }\n        sqlite3ReleaseTempReg(pParse, r1);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      if( pKeyInfo ){\n        sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);\n      }\n      break;\n    }\n\n    case TK_EXISTS:\n    case TK_SELECT:\n    default: {\n      /* Case 3:    (SELECT ... FROM ...)\n      **     or:    EXISTS(SELECT ... FROM ...)\n      **\n      ** For a SELECT, generate code to put the values for all columns of\n      ** the first row into an array of registers and return the index of\n      ** the first register.\n      **\n      ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)\n      ** into a register and return that register number.\n      **\n      ** In both cases, the query is augmented with \"LIMIT 1\".  Any \n      ** preexisting limit is discarded in place of the new LIMIT 1.\n      */\n      Select *pSel;                         /* SELECT statement to encode */\n      SelectDest dest;                      /* How to deal with SELECT result */\n      int nReg;                             /* Registers to allocate */\n\n      testcase( pExpr->op==TK_EXISTS );\n      testcase( pExpr->op==TK_SELECT );\n      assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n\n      pSel = pExpr->x.pSelect;\n      nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;\n      sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);\n      pParse->nMem += nReg;\n      if( pExpr->op==TK_SELECT ){\n        dest.eDest = SRT_Mem;\n        dest.iSdst = dest.iSDParm;\n        dest.nSdst = nReg;\n        sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);\n        VdbeComment((v, \"Init subquery result\"));\n      }else{\n        dest.eDest = SRT_Exists;\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);\n        VdbeComment((v, \"Init EXISTS result\"));\n      }\n      sqlite3ExprDelete(pParse->db, pSel->pLimit);\n      pSel->pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,\n                                  &sqlite3IntTokens[1], 0);\n      pSel->iLimit = 0;\n      pSel->selFlags &= ~SF_MultiValue;\n      if( sqlite3Select(pParse, pSel, &dest) ){\n        return 0;\n      }\n      rReg = dest.iSDParm;\n      ExprSetVVAProperty(pExpr, EP_NoReduce);\n      break;\n    }\n  }\n\n  if( rHasNullFlag ){\n    sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);\n  }\n\n  if( jmpIfDynamic>=0 ){\n    sqlite3VdbeJumpHere(v, jmpIfDynamic);\n  }\n  sqlite3ExprCachePop(pParse);\n\n  return rReg;\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Expr pIn is an IN(...) expression. This function checks that the \n** sub-select on the RHS of the IN() operator has the same number of \n** columns as the vector on the LHS. Or, if the RHS of the IN() is not \n** a sub-query, that the LHS is a vector of size 1.\n*/\nint sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){\n  int nVector = sqlite3ExprVectorSize(pIn->pLeft);\n  if( (pIn->flags & EP_xIsSelect) ){\n    if( nVector!=pIn->x.pSelect->pEList->nExpr ){\n      sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector);\n      return 1;\n    }\n  }else if( nVector!=1 ){\n    sqlite3VectorErrorMsg(pParse, pIn->pLeft);\n    return 1;\n  }\n  return 0;\n}\n#endif\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** Generate code for an IN expression.\n**\n**      x IN (SELECT ...)\n**      x IN (value, value, ...)\n**\n** The left-hand side (LHS) is a scalar or vector expression.  The \n** right-hand side (RHS) is an array of zero or more scalar values, or a\n** subquery.  If the RHS is a subquery, the number of result columns must\n** match the number of columns in the vector on the LHS.  If the RHS is\n** a list of values, the LHS must be a scalar. \n**\n** The IN operator is true if the LHS value is contained within the RHS.\n** The result is false if the LHS is definitely not in the RHS.  The \n** result is NULL if the presence of the LHS in the RHS cannot be \n** determined due to NULLs.\n**\n** This routine generates code that jumps to destIfFalse if the LHS is not \n** contained within the RHS.  If due to NULLs we cannot determine if the LHS\n** is contained in the RHS then jump to destIfNull.  If the LHS is contained\n** within the RHS then fall through.\n**\n** See the separate in-operator.md documentation file in the canonical\n** SQLite source tree for additional information.\n*/\nstatic void sqlite3ExprCodeIN(\n  Parse *pParse,        /* Parsing and code generating context */\n  Expr *pExpr,          /* The IN expression */\n  int destIfFalse,      /* Jump here if LHS is not contained in the RHS */\n  int destIfNull        /* Jump here if the results are unknown due to NULLs */\n){\n  int rRhsHasNull = 0;  /* Register that is true if RHS contains NULL values */\n  int eType;            /* Type of the RHS */\n  int rLhs;             /* Register(s) holding the LHS values */\n  int rLhsOrig;         /* LHS values prior to reordering by aiMap[] */\n  Vdbe *v;              /* Statement under construction */\n  int *aiMap = 0;       /* Map from vector field to index column */\n  char *zAff = 0;       /* Affinity string for comparisons */\n  int nVector;          /* Size of vectors for this IN operator */\n  int iDummy;           /* Dummy parameter to exprCodeVector() */\n  Expr *pLeft;          /* The LHS of the IN operator */\n  int i;                /* loop counter */\n  int destStep2;        /* Where to jump when NULLs seen in step 2 */\n  int destStep6 = 0;    /* Start of code for Step 6 */\n  int addrTruthOp;      /* Address of opcode that determines the IN is true */\n  int destNotNull;      /* Jump here if a comparison is not true in step 6 */\n  int addrTop;          /* Top of the step-6 loop */ \n\n  pLeft = pExpr->pLeft;\n  if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n  zAff = exprINAffinity(pParse, pExpr);\n  nVector = sqlite3ExprVectorSize(pExpr->pLeft);\n  aiMap = (int*)sqlite3DbMallocZero(\n      pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1\n  );\n  if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;\n\n  /* Attempt to compute the RHS. After this step, if anything other than\n  ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable \n  ** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,\n  ** the RHS has not yet been coded.  */\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* OOM detected prior to this routine */\n  VdbeNoopComment((v, \"begin IN expr\"));\n  eType = sqlite3FindInIndex(pParse, pExpr,\n                             IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,\n                             destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);\n\n  assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH\n       || eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC \n  );\n#ifdef SQLITE_DEBUG\n  /* Confirm that aiMap[] contains nVector integer values between 0 and\n  ** nVector-1. */\n  for(i=0; i<nVector; i++){\n    int j, cnt;\n    for(cnt=j=0; j<nVector; j++) if( aiMap[j]==i ) cnt++;\n    assert( cnt==1 );\n  }\n#endif\n\n  /* Code the LHS, the <expr> from \"<expr> IN (...)\". If the LHS is a \n  ** vector, then it is stored in an array of nVector registers starting \n  ** at r1.\n  **\n  ** sqlite3FindInIndex() might have reordered the fields of the LHS vector\n  ** so that the fields are in the same order as an existing index.   The\n  ** aiMap[] array contains a mapping from the original LHS field order to\n  ** the field order that matches the RHS index.\n  */\n  sqlite3ExprCachePush(pParse);\n  rLhsOrig = exprCodeVector(pParse, pLeft, &iDummy);\n  for(i=0; i<nVector && aiMap[i]==i; i++){} /* Are LHS fields reordered? */\n  if( i==nVector ){\n    /* LHS fields are not reordered */\n    rLhs = rLhsOrig;\n  }else{\n    /* Need to reorder the LHS fields according to aiMap */\n    rLhs = sqlite3GetTempRange(pParse, nVector);\n    for(i=0; i<nVector; i++){\n      sqlite3VdbeAddOp3(v, OP_Copy, rLhsOrig+i, rLhs+aiMap[i], 0);\n    }\n  }\n\n  /* If sqlite3FindInIndex() did not find or create an index that is\n  ** suitable for evaluating the IN operator, then evaluate using a\n  ** sequence of comparisons.\n  **\n  ** This is step (1) in the in-operator.md optimized algorithm.\n  */\n  if( eType==IN_INDEX_NOOP ){\n    ExprList *pList = pExpr->x.pList;\n    CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);\n    int labelOk = sqlite3VdbeMakeLabel(v);\n    int r2, regToFree;\n    int regCkNull = 0;\n    int ii;\n    assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n    if( destIfNull!=destIfFalse ){\n      regCkNull = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull);\n    }\n    for(ii=0; ii<pList->nExpr; ii++){\n      r2 = sqlite3ExprCodeTemp(pParse, pList->a[ii].pExpr, &regToFree);\n      if( regCkNull && sqlite3ExprCanBeNull(pList->a[ii].pExpr) ){\n        sqlite3VdbeAddOp3(v, OP_BitAnd, regCkNull, r2, regCkNull);\n      }\n      if( ii<pList->nExpr-1 || destIfNull!=destIfFalse ){\n        sqlite3VdbeAddOp4(v, OP_Eq, rLhs, labelOk, r2,\n                          (void*)pColl, P4_COLLSEQ);\n        VdbeCoverageIf(v, ii<pList->nExpr-1);\n        VdbeCoverageIf(v, ii==pList->nExpr-1);\n        sqlite3VdbeChangeP5(v, zAff[0]);\n      }else{\n        assert( destIfNull==destIfFalse );\n        sqlite3VdbeAddOp4(v, OP_Ne, rLhs, destIfFalse, r2,\n                          (void*)pColl, P4_COLLSEQ); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, zAff[0] | SQLITE_JUMPIFNULL);\n      }\n      sqlite3ReleaseTempReg(pParse, regToFree);\n    }\n    if( regCkNull ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, destIfFalse);\n    }\n    sqlite3VdbeResolveLabel(v, labelOk);\n    sqlite3ReleaseTempReg(pParse, regCkNull);\n    goto sqlite3ExprCodeIN_finished;\n  }\n\n  /* Step 2: Check to see if the LHS contains any NULL columns.  If the\n  ** LHS does contain NULLs then the result must be either FALSE or NULL.\n  ** We will then skip the binary search of the RHS.\n  */\n  if( destIfNull==destIfFalse ){\n    destStep2 = destIfFalse;\n  }else{\n    destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);\n    if( sqlite3ExprCanBeNull(p) ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);\n      VdbeCoverage(v);\n    }\n  }\n\n  /* Step 3.  The LHS is now known to be non-NULL.  Do the binary search\n  ** of the RHS using the LHS as a probe.  If found, the result is\n  ** true.\n  */\n  if( eType==IN_INDEX_ROWID ){\n    /* In this case, the RHS is the ROWID of table b-tree and so we also\n    ** know that the RHS is non-NULL.  Hence, we combine steps 3 and 4\n    ** into a single opcode. */\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);\n    VdbeCoverage(v);\n    addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto);  /* Return True */\n  }else{\n    sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);\n    if( destIfFalse==destIfNull ){\n      /* Combine Step 3 and Step 5 into a single opcode */\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,\n                           rLhs, nVector); VdbeCoverage(v);\n      goto sqlite3ExprCodeIN_finished;\n    }\n    /* Ordinary Step 3, for the case where FALSE and NULL are distinct */\n    addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,\n                                      rLhs, nVector); VdbeCoverage(v);\n  }\n\n  /* Step 4.  If the RHS is known to be non-NULL and we did not find\n  ** an match on the search above, then the result must be FALSE.\n  */\n  if( rRhsHasNull && nVector==1 ){\n    sqlite3VdbeAddOp2(v, OP_NotNull, rRhsHasNull, destIfFalse);\n    VdbeCoverage(v);\n  }\n\n  /* Step 5.  If we do not care about the difference between NULL and\n  ** FALSE, then just return false. \n  */\n  if( destIfFalse==destIfNull ) sqlite3VdbeGoto(v, destIfFalse);\n\n  /* Step 6: Loop through rows of the RHS.  Compare each row to the LHS.\n  ** If any comparison is NULL, then the result is NULL.  If all\n  ** comparisons are FALSE then the final result is FALSE.\n  **\n  ** For a scalar LHS, it is sufficient to check just the first row\n  ** of the RHS.\n  */\n  if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);\n  VdbeCoverage(v);\n  if( nVector>1 ){\n    destNotNull = sqlite3VdbeMakeLabel(v);\n  }else{\n    /* For nVector==1, combine steps 6 and 7 by immediately returning\n    ** FALSE if the first comparison is not NULL */\n    destNotNull = destIfFalse;\n  }\n  for(i=0; i<nVector; i++){\n    Expr *p;\n    CollSeq *pColl;\n    int r3 = sqlite3GetTempReg(pParse);\n    p = sqlite3VectorFieldSubexpr(pLeft, i);\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);\n    sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,\n                      (void*)pColl, P4_COLLSEQ);\n    VdbeCoverage(v);\n    sqlite3ReleaseTempReg(pParse, r3);\n  }\n  sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);\n  if( nVector>1 ){\n    sqlite3VdbeResolveLabel(v, destNotNull);\n    sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);\n    VdbeCoverage(v);\n\n    /* Step 7:  If we reach this point, we know that the result must\n    ** be false. */\n    sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse);\n  }\n\n  /* Jumps here in order to return true. */\n  sqlite3VdbeJumpHere(v, addrTruthOp);\n\nsqlite3ExprCodeIN_finished:\n  if( rLhs!=rLhsOrig ) sqlite3ReleaseTempReg(pParse, rLhs);\n  sqlite3ExprCachePop(pParse);\n  VdbeComment((v, \"end IN expr\"));\nsqlite3ExprCodeIN_oom_error:\n  sqlite3DbFree(pParse->db, aiMap);\n  sqlite3DbFree(pParse->db, zAff);\n}\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Generate an instruction that will put the floating point\n** value described by z[0..n-1] into register iMem.\n**\n** The z[] string will probably not be zero-terminated.  But the \n** z[n] character is guaranteed to be something that does not look\n** like the continuation of the number.\n*/\nstatic void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){\n  if( ALWAYS(z!=0) ){\n    double value;\n    sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8);\n    assert( !sqlite3IsNaN(value) ); /* The new AtoF never returns NaN */\n    if( negateFlag ) value = -value;\n    sqlite3VdbeAddOp4Dup8(v, OP_Real, 0, iMem, 0, (u8*)&value, P4_REAL);\n  }\n}\n#endif\n\n\n/*\n** Generate an instruction that will put the integer describe by\n** text z[0..n-1] into register iMem.\n**\n** Expr.u.zToken is always UTF8 and zero-terminated.\n*/\nstatic void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){\n  Vdbe *v = pParse->pVdbe;\n  if( pExpr->flags & EP_IntValue ){\n    int i = pExpr->u.iValue;\n    assert( i>=0 );\n    if( negFlag ) i = -i;\n    sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);\n  }else{\n    int c;\n    i64 value;\n    const char *z = pExpr->u.zToken;\n    assert( z!=0 );\n    c = sqlite3DecOrHexToI64(z, &value);\n    if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n      sqlite3ErrorMsg(pParse, \"oversized integer: %s%s\", negFlag ? \"-\" : \"\", z);\n#else\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( sqlite3_strnicmp(z,\"0x\",2)==0 ){\n        sqlite3ErrorMsg(pParse, \"hex literal too big: %s%s\", negFlag?\"-\":\"\",z);\n      }else\n#endif\n      {\n        codeReal(v, z, negFlag, iMem);\n      }\n#endif\n    }else{\n      if( negFlag ){ value = c==3 ? SMALLEST_INT64 : -value; }\n      sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, iMem, 0, (u8*)&value, P4_INT64);\n    }\n  }\n}\n\n/*\n** Erase column-cache entry number i\n*/\nstatic void cacheEntryClear(Parse *pParse, int i){\n  if( pParse->aColCache[i].tempReg ){\n    if( pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n      pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;\n    }\n  }\n  pParse->nColCache--;\n  if( i<pParse->nColCache ){\n    pParse->aColCache[i] = pParse->aColCache[pParse->nColCache];\n  }\n}\n\n\n/*\n** Record in the column cache that a particular column from a\n** particular table is stored in a particular register.\n*/\nvoid sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){\n  int i;\n  int minLru;\n  int idxLru;\n  struct yColCache *p;\n\n  /* Unless an error has occurred, register numbers are always positive. */\n  assert( iReg>0 || pParse->nErr || pParse->db->mallocFailed );\n  assert( iCol>=-1 && iCol<32768 );  /* Finite column numbers */\n\n  /* The SQLITE_ColumnCache flag disables the column cache.  This is used\n  ** for testing only - to verify that SQLite always gets the same answer\n  ** with and without the column cache.\n  */\n  if( OptimizationDisabled(pParse->db, SQLITE_ColumnCache) ) return;\n\n  /* First replace any existing entry.\n  **\n  ** Actually, the way the column cache is currently used, we are guaranteed\n  ** that the object will never already be in cache.  Verify this guarantee.\n  */\n#ifndef NDEBUG\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    assert( p->iTable!=iTab || p->iColumn!=iCol );\n  }\n#endif\n\n  /* If the cache is already full, delete the least recently used entry */\n  if( pParse->nColCache>=SQLITE_N_COLCACHE ){\n    minLru = 0x7fffffff;\n    idxLru = -1;\n    for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){\n      if( p->lru<minLru ){\n        idxLru = i;\n        minLru = p->lru;\n      }\n    }\n    p = &pParse->aColCache[idxLru];\n  }else{\n    p = &pParse->aColCache[pParse->nColCache++];\n  }\n\n  /* Add the new entry to the end of the cache */\n  p->iLevel = pParse->iCacheLevel;\n  p->iTable = iTab;\n  p->iColumn = iCol;\n  p->iReg = iReg;\n  p->tempReg = 0;\n  p->lru = pParse->iCacheCnt++;\n}\n\n/*\n** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.\n** Purge the range of registers from the column cache.\n*/\nvoid sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){\n  int i = 0;\n  while( i<pParse->nColCache ){\n    struct yColCache *p = &pParse->aColCache[i];\n    if( p->iReg >= iReg && p->iReg < iReg+nReg ){\n      cacheEntryClear(pParse, i);\n    }else{\n      i++;\n    }\n  }\n}\n\n/*\n** Remember the current column cache context.  Any new entries added\n** added to the column cache after this call are removed when the\n** corresponding pop occurs.\n*/\nvoid sqlite3ExprCachePush(Parse *pParse){\n  pParse->iCacheLevel++;\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"PUSH to %d\\n\", pParse->iCacheLevel);\n  }\n#endif\n}\n\n/*\n** Remove from the column cache any entries that were added since the\n** the previous sqlite3ExprCachePush operation.  In other words, restore\n** the cache to the state it was in prior the most recent Push.\n*/\nvoid sqlite3ExprCachePop(Parse *pParse){\n  int i = 0;\n  assert( pParse->iCacheLevel>=1 );\n  pParse->iCacheLevel--;\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"POP  to %d\\n\", pParse->iCacheLevel);\n  }\n#endif\n  while( i<pParse->nColCache ){\n    if( pParse->aColCache[i].iLevel>pParse->iCacheLevel ){\n      cacheEntryClear(pParse, i);\n    }else{\n      i++;\n    }\n  }\n}\n\n/*\n** When a cached column is reused, make sure that its register is\n** no longer available as a temp register.  ticket #3879:  that same\n** register might be in the cache in multiple places, so be sure to\n** get them all.\n*/\nstatic void sqlite3ExprCachePinRegister(Parse *pParse, int iReg){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    if( p->iReg==iReg ){\n      p->tempReg = 0;\n    }\n  }\n}\n\n/* Generate code that will load into register regOut a value that is\n** appropriate for the iIdxCol-th column of index pIdx.\n*/\nvoid sqlite3ExprCodeLoadIndexColumn(\n  Parse *pParse,  /* The parsing context */\n  Index *pIdx,    /* The index whose column is to be loaded */\n  int iTabCur,    /* Cursor pointing to a table row */\n  int iIdxCol,    /* The column of the index to be loaded */\n  int regOut      /* Store the index column value in this register */\n){\n  i16 iTabCol = pIdx->aiColumn[iIdxCol];\n  if( iTabCol==XN_EXPR ){\n    assert( pIdx->aColExpr );\n    assert( pIdx->aColExpr->nExpr>iIdxCol );\n    pParse->iSelfTab = iTabCur + 1;\n    sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);\n    pParse->iSelfTab = 0;\n  }else{\n    sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,\n                                    iTabCol, regOut);\n  }\n}\n\n/*\n** Generate code to extract the value of the iCol-th column of a table.\n*/\nvoid sqlite3ExprCodeGetColumnOfTable(\n  Vdbe *v,        /* The VDBE under construction */\n  Table *pTab,    /* The table containing the value */\n  int iTabCur,    /* The table cursor.  Or the PK cursor for WITHOUT ROWID */\n  int iCol,       /* Index of the column to extract */\n  int regOut      /* Extract the value into this register */\n){\n  if( pTab==0 ){\n    sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut);\n    return;\n  }\n  if( iCol<0 || iCol==pTab->iPKey ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);\n  }else{\n    int op = IsVirtual(pTab) ? OP_VColumn : OP_Column;\n    int x = iCol;\n    if( !HasRowid(pTab) && !IsVirtual(pTab) ){\n      x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol);\n    }\n    sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut);\n  }\n  if( iCol>=0 ){\n    sqlite3ColumnDefault(v, pTab, iCol, regOut);\n  }\n}\n\n/*\n** Generate code that will extract the iColumn-th column from\n** table pTab and store the column value in a register. \n**\n** An effort is made to store the column value in register iReg.  This\n** is not garanteeed for GetColumn() - the result can be stored in\n** any register.  But the result is guaranteed to land in register iReg\n** for GetColumnToReg().\n**\n** There must be an open cursor to pTab in iTable when this routine\n** is called.  If iColumn<0 then code is generated that extracts the rowid.\n*/\nint sqlite3ExprCodeGetColumn(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg,        /* Store results here */\n  u8 p5            /* P5 value for OP_Column + FLAGS */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct yColCache *p;\n\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    if( p->iTable==iTable && p->iColumn==iColumn ){\n      p->lru = pParse->iCacheCnt++;\n      sqlite3ExprCachePinRegister(pParse, p->iReg);\n      return p->iReg;\n    }\n  }  \n  assert( v!=0 );\n  sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);\n  if( p5 ){\n    sqlite3VdbeChangeP5(v, p5);\n  }else{   \n    sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);\n  }\n  return iReg;\n}\nvoid sqlite3ExprCodeGetColumnToReg(\n  Parse *pParse,   /* Parsing and code generating context */\n  Table *pTab,     /* Description of the table we are reading from */\n  int iColumn,     /* Index of the table column */\n  int iTable,      /* The cursor pointing to the table */\n  int iReg         /* Store results here */\n){\n  int r1 = sqlite3ExprCodeGetColumn(pParse, pTab, iColumn, iTable, iReg, 0);\n  if( r1!=iReg ) sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, r1, iReg);\n}\n\n\n/*\n** Clear all column cache entries.\n*/\nvoid sqlite3ExprCacheClear(Parse *pParse){\n  int i;\n\n#ifdef SQLITE_DEBUG\n  if( pParse->db->flags & SQLITE_VdbeAddopTrace ){\n    printf(\"CLEAR\\n\");\n  }\n#endif\n  for(i=0; i<pParse->nColCache; i++){\n    if( pParse->aColCache[i].tempReg\n     && pParse->nTempReg<ArraySize(pParse->aTempReg)\n    ){\n       pParse->aTempReg[pParse->nTempReg++] = pParse->aColCache[i].iReg;\n    }\n  }\n  pParse->nColCache = 0;\n}\n\n/*\n** Record the fact that an affinity change has occurred on iCount\n** registers starting with iStart.\n*/\nvoid sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){\n  sqlite3ExprCacheRemove(pParse, iStart, iCount);\n}\n\n/*\n** Generate code to move content from registers iFrom...iFrom+nReg-1\n** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.\n*/\nvoid sqlite3ExprCodeMove(Parse *pParse, int iFrom, int iTo, int nReg){\n  assert( iFrom>=iTo+nReg || iFrom+nReg<=iTo );\n  sqlite3VdbeAddOp3(pParse->pVdbe, OP_Move, iFrom, iTo, nReg);\n  sqlite3ExprCacheRemove(pParse, iFrom, nReg);\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)\n/*\n** Return true if any register in the range iFrom..iTo (inclusive)\n** is used as part of the column cache.\n**\n** This routine is used within assert() and testcase() macros only\n** and does not appear in a normal build.\n*/\nstatic int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){\n  int i;\n  struct yColCache *p;\n  for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n    int r = p->iReg;\n    if( r>=iFrom && r<=iTo ) return 1;    /*NO_TEST*/\n  }\n  return 0;\n}\n#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */\n\n\n/*\n** Convert a scalar expression node to a TK_REGISTER referencing\n** register iReg.  The caller must ensure that iReg already contains\n** the correct value for the expression.\n*/\nstatic void exprToRegister(Expr *p, int iReg){\n  p->op2 = p->op;\n  p->op = TK_REGISTER;\n  p->iTable = iReg;\n  ExprClearProperty(p, EP_Skip);\n}\n\n/*\n** Evaluate an expression (either a vector or a scalar expression) and store\n** the result in continguous temporary registers.  Return the index of\n** the first register used to store the result.\n**\n** If the returned result register is a temporary scalar, then also write\n** that register number into *piFreeable.  If the returned result register\n** is not a temporary or if the expression is a vector set *piFreeable\n** to 0.\n*/\nstatic int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){\n  int iResult;\n  int nResult = sqlite3ExprVectorSize(p);\n  if( nResult==1 ){\n    iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable);\n  }else{\n    *piFreeable = 0;\n    if( p->op==TK_SELECT ){\n#if SQLITE_OMIT_SUBQUERY\n      iResult = 0;\n#else\n      iResult = sqlite3CodeSubselect(pParse, p, 0, 0);\n#endif\n    }else{\n      int i;\n      iResult = pParse->nMem+1;\n      pParse->nMem += nResult;\n      for(i=0; i<nResult; i++){\n        sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult);\n      }\n    }\n  }\n  return iResult;\n}\n\n\n/*\n** Generate code into the current Vdbe to evaluate the given\n** expression.  Attempt to store the results in register \"target\".\n** Return the register where results are stored.\n**\n** With this routine, there is no guarantee that results will\n** be stored in target.  The result might be stored in some other\n** register if it is convenient to do so.  The calling function\n** must check the return code and move the results to the desired\n** register.\n*/\nint sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;  /* The VM under construction */\n  int op;                   /* The opcode being coded */\n  int inReg = target;       /* Results stored in register inReg */\n  int regFree1 = 0;         /* If non-zero free this temporary register */\n  int regFree2 = 0;         /* If non-zero free this temporary register */\n  int r1, r2;               /* Various register numbers */\n  Expr tempX;               /* Temporary expression node */\n  int p5 = 0;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( v==0 ){\n    assert( pParse->db->mallocFailed );\n    return 0;\n  }\n\n  if( pExpr==0 ){\n    op = TK_NULL;\n  }else{\n    op = pExpr->op;\n  }\n  switch( op ){\n    case TK_AGG_COLUMN: {\n      AggInfo *pAggInfo = pExpr->pAggInfo;\n      struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];\n      if( !pAggInfo->directMode ){\n        assert( pCol->iMem>0 );\n        return pCol->iMem;\n      }else if( pAggInfo->useSortingIdx ){\n        sqlite3VdbeAddOp3(v, OP_Column, pAggInfo->sortingIdxPTab,\n                              pCol->iSorterColumn, target);\n        return target;\n      }\n      /* Otherwise, fall thru into the TK_COLUMN case */\n    }\n    case TK_COLUMN: {\n      int iTab = pExpr->iTable;\n      if( iTab<0 ){\n        if( pParse->iSelfTab<0 ){\n          /* Generating CHECK constraints or inserting into partial index */\n          return pExpr->iColumn - pParse->iSelfTab;\n        }else{\n          /* Coding an expression that is part of an index where column names\n          ** in the index refer to the table to which the index belongs */\n          iTab = pParse->iSelfTab - 1;\n        }\n      }\n      return sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,\n                               pExpr->iColumn, iTab, target,\n                               pExpr->op2);\n    }\n    case TK_INTEGER: {\n      codeInteger(pParse, pExpr, 0, target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      codeReal(v, pExpr->u.zToken, 0, target);\n      return target;\n    }\n#endif\n    case TK_STRING: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      sqlite3VdbeLoadString(v, target, pExpr->u.zToken);\n      return target;\n    }\n    case TK_NULL: {\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      return target;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      int n;\n      const char *z;\n      char *zBlob;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n      assert( pExpr->u.zToken[1]=='\\'' );\n      z = &pExpr->u.zToken[2];\n      n = sqlite3Strlen30(z) - 1;\n      assert( z[n]=='\\'' );\n      zBlob = sqlite3HexToBlob(sqlite3VdbeDb(v), z, n);\n      sqlite3VdbeAddOp4(v, OP_Blob, n/2, target, 0, zBlob, P4_DYNAMIC);\n      return target;\n    }\n#endif\n    case TK_VARIABLE: {\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      assert( pExpr->u.zToken!=0 );\n      assert( pExpr->u.zToken[0]!=0 );\n      sqlite3VdbeAddOp2(v, OP_Variable, pExpr->iColumn, target);\n      if( pExpr->u.zToken[1]!=0 ){\n        const char *z = sqlite3VListNumToName(pParse->pVList, pExpr->iColumn);\n        assert( pExpr->u.zToken[0]=='?' || strcmp(pExpr->u.zToken, z)==0 );\n        pParse->pVList[0] = 0; /* Indicate VList may no longer be enlarged */\n        sqlite3VdbeAppendP4(v, (char*)z, P4_STATIC);\n      }\n      return target;\n    }\n    case TK_REGISTER: {\n      return pExpr->iTable;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      if( inReg!=target ){\n        sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);\n        inReg = target;\n      }\n      sqlite3VdbeAddOp2(v, OP_Cast, target,\n                        sqlite3AffinityType(pExpr->u.zToken, 0));\n      testcase( usedAsColumnCache(pParse, inReg, inReg) );\n      sqlite3ExprCacheAffinityChange(pParse, inReg, 1);\n      return inReg;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_IS:\n    case TK_ISNOT:\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      p5 = SQLITE_NULLEQ;\n      /* fall-through */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      Expr *pLeft = pExpr->pLeft;\n      if( sqlite3ExprIsVector(pLeft) ){\n        codeVectorCompare(pParse, pExpr, target, op, p5);\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n        codeCompare(pParse, pLeft, pExpr->pRight, op,\n            r1, r2, inReg, SQLITE_STOREP2 | p5);\n        assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n        assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n        assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n        assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n        assert(TK_EQ==OP_Eq); testcase(op==OP_Eq); VdbeCoverageIf(v,op==OP_Eq);\n        assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne);\n        testcase( regFree1==0 );\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_AND:\n    case TK_OR:\n    case TK_PLUS:\n    case TK_STAR:\n    case TK_MINUS:\n    case TK_REM:\n    case TK_BITAND:\n    case TK_BITOR:\n    case TK_SLASH:\n    case TK_LSHIFT:\n    case TK_RSHIFT: \n    case TK_CONCAT: {\n      assert( TK_AND==OP_And );            testcase( op==TK_AND );\n      assert( TK_OR==OP_Or );              testcase( op==TK_OR );\n      assert( TK_PLUS==OP_Add );           testcase( op==TK_PLUS );\n      assert( TK_MINUS==OP_Subtract );     testcase( op==TK_MINUS );\n      assert( TK_REM==OP_Remainder );      testcase( op==TK_REM );\n      assert( TK_BITAND==OP_BitAnd );      testcase( op==TK_BITAND );\n      assert( TK_BITOR==OP_BitOr );        testcase( op==TK_BITOR );\n      assert( TK_SLASH==OP_Divide );       testcase( op==TK_SLASH );\n      assert( TK_LSHIFT==OP_ShiftLeft );   testcase( op==TK_LSHIFT );\n      assert( TK_RSHIFT==OP_ShiftRight );  testcase( op==TK_RSHIFT );\n      assert( TK_CONCAT==OP_Concat );      testcase( op==TK_CONCAT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      sqlite3VdbeAddOp3(v, op, r2, r1, target);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_UMINUS: {\n      Expr *pLeft = pExpr->pLeft;\n      assert( pLeft );\n      if( pLeft->op==TK_INTEGER ){\n        codeInteger(pParse, pLeft, 1, target);\n        return target;\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      }else if( pLeft->op==TK_FLOAT ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        codeReal(v, pLeft->u.zToken, 1, target);\n        return target;\n#endif\n      }else{\n        tempX.op = TK_INTEGER;\n        tempX.flags = EP_IntValue|EP_TokenOnly;\n        tempX.u.iValue = 0;\n        r1 = sqlite3ExprCodeTemp(pParse, &tempX, &regFree1);\n        r2 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree2);\n        sqlite3VdbeAddOp3(v, OP_Subtract, r2, r1, target);\n        testcase( regFree2==0 );\n      }\n      break;\n    }\n    case TK_BITNOT:\n    case TK_NOT: {\n      assert( TK_BITNOT==OP_BitNot );   testcase( op==TK_BITNOT );\n      assert( TK_NOT==OP_Not );         testcase( op==TK_NOT );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      sqlite3VdbeAddOp2(v, op, r1, inReg);\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      int addr;\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      testcase( regFree1==0 );\n      addr = sqlite3VdbeAddOp1(v, op, r1);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, target);\n      sqlite3VdbeJumpHere(v, addr);\n      break;\n    }\n    case TK_AGG_FUNCTION: {\n      AggInfo *pInfo = pExpr->pAggInfo;\n      if( pInfo==0 ){\n        assert( !ExprHasProperty(pExpr, EP_IntValue) );\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate: %s()\", pExpr->u.zToken);\n      }else{\n        return pInfo->aFunc[pExpr->iAgg].iMem;\n      }\n      break;\n    }\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      int nFarg;             /* Number of function arguments */\n      FuncDef *pDef;         /* The function definition object */\n      const char *zId;       /* The function name */\n      u32 constMask = 0;     /* Mask of function arguments that are constant */\n      int i;                 /* Loop counter */\n      sqlite3 *db = pParse->db;  /* The database connection */\n      u8 enc = ENC(db);      /* The text encoding used by this database */\n      CollSeq *pColl = 0;    /* A collating sequence */\n\n      if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){\n        /* SQL functions can be expensive. So try to move constant functions\n        ** out of the inner loop, even if that means an extra OP_Copy. */\n        return sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n      }\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      nFarg = pFarg ? pFarg->nExpr : 0;\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      zId = pExpr->u.zToken;\n      pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0);\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n      if( pDef==0 && pParse->explain ){\n        pDef = sqlite3FindFunction(db, \"unknown\", nFarg, enc, 0);\n      }\n#endif\n      if( pDef==0 || pDef->xFinalize!=0 ){\n        sqlite3ErrorMsg(pParse, \"unknown function: %s()\", zId);\n        break;\n      }\n\n      /* Attempt a direct implementation of the built-in COALESCE() and\n      ** IFNULL() functions.  This avoids unnecessary evaluation of\n      ** arguments past the first non-NULL argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){\n        int endCoalesce = sqlite3VdbeMakeLabel(v);\n        assert( nFarg>=2 );\n        sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);\n        for(i=1; i<nFarg; i++){\n          sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);\n          VdbeCoverage(v);\n          sqlite3ExprCacheRemove(pParse, target, 1);\n          sqlite3ExprCachePush(pParse);\n          sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);\n          sqlite3ExprCachePop(pParse);\n        }\n        sqlite3VdbeResolveLabel(v, endCoalesce);\n        break;\n      }\n\n      /* The UNLIKELY() function is a no-op.  The result is the value\n      ** of the first argument.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n        assert( nFarg>=1 );\n        return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);\n      }\n\n#ifdef SQLITE_DEBUG\n      /* The AFFINITY() function evaluates to a string that describes\n      ** the type affinity of the argument.  This is used for testing of\n      ** the SQLite type logic.\n      */\n      if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){\n        const char *azAff[] = { \"blob\", \"text\", \"numeric\", \"integer\", \"real\" };\n        char aff;\n        assert( nFarg==1 );\n        aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);\n        sqlite3VdbeLoadString(v, target, \n                              aff ? azAff[aff-SQLITE_AFF_BLOB] : \"none\");\n        return target;\n      }\n#endif\n\n      for(i=0; i<nFarg; i++){\n        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){\n          testcase( i==31 );\n          constMask |= MASKBIT32(i);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){\n          pColl = sqlite3ExprCollSeq(pParse, pFarg->a[i].pExpr);\n        }\n      }\n      if( pFarg ){\n        if( constMask ){\n          r1 = pParse->nMem+1;\n          pParse->nMem += nFarg;\n        }else{\n          r1 = sqlite3GetTempRange(pParse, nFarg);\n        }\n\n        /* For length() and typeof() functions with a column argument,\n        ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG\n        ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data\n        ** loading.\n        */\n        if( (pDef->funcFlags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){\n          u8 exprOp;\n          assert( nFarg==1 );\n          assert( pFarg->a[0].pExpr!=0 );\n          exprOp = pFarg->a[0].pExpr->op;\n          if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){\n            assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );\n            assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );\n            testcase( pDef->funcFlags & OPFLAG_LENGTHARG );\n            pFarg->a[0].pExpr->op2 = \n                  pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG);\n          }\n        }\n\n        sqlite3ExprCachePush(pParse);     /* Ticket 2ea2425d34be */\n        sqlite3ExprCodeExprList(pParse, pFarg, r1, 0,\n                                SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR);\n        sqlite3ExprCachePop(pParse);      /* Ticket 2ea2425d34be */\n      }else{\n        r1 = 0;\n      }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* Possibly overload the function if the first argument is\n      ** a virtual table column.\n      **\n      ** For infix functions (LIKE, GLOB, REGEXP, and MATCH) use the\n      ** second argument, not the first, as the argument to test to\n      ** see if it is a column in a virtual table.  This is done because\n      ** the left operand of infix functions (the operand we want to\n      ** control overloading) ends up as the second argument to the\n      ** function.  The expression \"A glob B\" is equivalent to \n      ** \"glob(B,A).  We want to use the A in \"A glob B\" to test\n      ** for function overloading.  But we use the B term in \"glob(B,A)\".\n      */\n      if( nFarg>=2 && (pExpr->flags & EP_InfixFunc) ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[1].pExpr);\n      }else if( nFarg>0 ){\n        pDef = sqlite3VtabOverloadFunction(db, pDef, nFarg, pFarg->a[0].pExpr);\n      }\n#endif\n      if( pDef->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n        if( !pColl ) pColl = db->pDfltColl; \n        sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);\n      }\n      sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,\n                        constMask, r1, target, (char*)pDef, P4_FUNCDEF);\n      sqlite3VdbeChangeP5(v, (u8)nFarg);\n      if( nFarg && constMask==0 ){\n        sqlite3ReleaseTempRange(pParse, r1, nFarg);\n      }\n      return target;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS:\n    case TK_SELECT: {\n      int nCol;\n      testcase( op==TK_EXISTS );\n      testcase( op==TK_SELECT );\n      if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){\n        sqlite3SubselectError(pParse, nCol, 1);\n      }else{\n        return sqlite3CodeSubselect(pParse, pExpr, 0, 0);\n      }\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      int n;\n      if( pExpr->pLeft->iTable==0 ){\n        pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);\n      }\n      assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );\n      if( pExpr->iTable\n       && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) \n      ){\n        sqlite3ErrorMsg(pParse, \"%d columns assigned %d values\",\n                                pExpr->iTable, n);\n      }\n      return pExpr->pLeft->iTable + pExpr->iColumn;\n    }\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, target);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      sqlite3VdbeAddOp2(v, OP_AddImm, target, 0);\n      sqlite3VdbeResolveLabel(v, destIfNull);\n      return target;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      exprCodeBetween(pParse, pExpr, target, 0, 0);\n      return target;\n    }\n    case TK_SPAN:\n    case TK_COLLATE: \n    case TK_UPLUS: {\n      return sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n    }\n\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      **\n      ** The expression is implemented using an OP_Param opcode. The p1\n      ** parameter is set to 0 for an old.rowid reference, or to (i+1)\n      ** to reference another column of the old.* pseudo-table, where \n      ** i is the index of the column. For a new.rowid reference, p1 is\n      ** set to (n+1), where n is the number of columns in each pseudo-table.\n      ** For a reference to any other column in the new.* pseudo-table, p1\n      ** is set to (n+2+i), where n and i are as defined previously. For\n      ** example, if the table on which triggers are being fired is\n      ** declared as:\n      **\n      **   CREATE TABLE t1(a, b);\n      **\n      ** Then p1 is interpreted as follows:\n      **\n      **   p1==0   ->    old.rowid     p1==3   ->    new.rowid\n      **   p1==1   ->    old.a         p1==4   ->    new.a\n      **   p1==2   ->    old.b         p1==5   ->    new.b       \n      */\n      Table *pTab = pExpr->pTab;\n      int p1 = pExpr->iTable * (pTab->nCol+1) + 1 + pExpr->iColumn;\n\n      assert( pExpr->iTable==0 || pExpr->iTable==1 );\n      assert( pExpr->iColumn>=-1 && pExpr->iColumn<pTab->nCol );\n      assert( pTab->iPKey<0 || pExpr->iColumn!=pTab->iPKey );\n      assert( p1>=0 && p1<(pTab->nCol*2+2) );\n\n      sqlite3VdbeAddOp2(v, OP_Param, p1, target);\n      VdbeComment((v, \"%s.%s -> $%d\",\n        (pExpr->iTable ? \"new\" : \"old\"),\n        (pExpr->iColumn<0 ? \"rowid\" : pExpr->pTab->aCol[pExpr->iColumn].zName),\n        target\n      ));\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      /* If the column has REAL affinity, it may currently be stored as an\n      ** integer. Use OP_RealAffinity to make sure it is really real.\n      **\n      ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to\n      ** floating point when extracting it from the record.  */\n      if( pExpr->iColumn>=0 \n       && pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL\n      ){\n        sqlite3VdbeAddOp1(v, OP_RealAffinity, target);\n      }\n#endif\n      break;\n    }\n\n    case TK_VECTOR: {\n      sqlite3ErrorMsg(pParse, \"row value misused\");\n      break;\n    }\n\n    case TK_IF_NULL_ROW: {\n      int addrINR;\n      addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);\n      sqlite3ExprCachePush(pParse);\n      inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);\n      sqlite3ExprCachePop(pParse);\n      sqlite3VdbeJumpHere(v, addrINR);\n      sqlite3VdbeChangeP3(v, addrINR, inReg);\n      break;\n    }\n\n    /*\n    ** Form A:\n    **   CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form B:\n    **   CASE WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END\n    **\n    ** Form A is can be transformed into the equivalent form B as follows:\n    **   CASE WHEN x=e1 THEN r1 WHEN x=e2 THEN r2 ...\n    **        WHEN x=eN THEN rN ELSE y END\n    **\n    ** X (if it exists) is in pExpr->pLeft.\n    ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is\n    ** odd.  The Y is also optional.  If the number of elements in x.pList\n    ** is even, then Y is omitted and the \"otherwise\" result is NULL.\n    ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1].\n    **\n    ** The result of the expression is the Ri for the first matching Ei,\n    ** or if there is no matching Ei, the ELSE term Y, or if there is\n    ** no ELSE term, NULL.\n    */\n    default: assert( op==TK_CASE ); {\n      int endLabel;                     /* GOTO label for end of CASE stmt */\n      int nextCase;                     /* GOTO label for next WHEN clause */\n      int nExpr;                        /* 2x number of WHEN terms */\n      int i;                            /* Loop counter */\n      ExprList *pEList;                 /* List of WHEN terms */\n      struct ExprList_item *aListelem;  /* Array of WHEN terms */\n      Expr opCompare;                   /* The X==Ei expression */\n      Expr *pX;                         /* The X expression */\n      Expr *pTest = 0;                  /* X==Ei (form A) or just Ei (form B) */\n      VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; )\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );\n      assert(pExpr->x.pList->nExpr > 0);\n      pEList = pExpr->x.pList;\n      aListelem = pEList->a;\n      nExpr = pEList->nExpr;\n      endLabel = sqlite3VdbeMakeLabel(v);\n      if( (pX = pExpr->pLeft)!=0 ){\n        tempX = *pX;\n        testcase( pX->op==TK_COLUMN );\n        exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));\n        testcase( regFree1==0 );\n        memset(&opCompare, 0, sizeof(opCompare));\n        opCompare.op = TK_EQ;\n        opCompare.pLeft = &tempX;\n        pTest = &opCompare;\n        /* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:\n        ** The value in regFree1 might get SCopy-ed into the file result.\n        ** So make sure that the regFree1 register is not reused for other\n        ** purposes and possibly overwritten.  */\n        regFree1 = 0;\n      }\n      for(i=0; i<nExpr-1; i=i+2){\n        sqlite3ExprCachePush(pParse);\n        if( pX ){\n          assert( pTest!=0 );\n          opCompare.pRight = aListelem[i].pExpr;\n        }else{\n          pTest = aListelem[i].pExpr;\n        }\n        nextCase = sqlite3VdbeMakeLabel(v);\n        testcase( pTest->op==TK_COLUMN );\n        sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);\n        testcase( aListelem[i+1].pExpr->op==TK_COLUMN );\n        sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target);\n        sqlite3VdbeGoto(v, endLabel);\n        sqlite3ExprCachePop(pParse);\n        sqlite3VdbeResolveLabel(v, nextCase);\n      }\n      if( (nExpr&1)!=0 ){\n        sqlite3ExprCachePush(pParse);\n        sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target);\n        sqlite3ExprCachePop(pParse);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, target);\n      }\n      assert( pParse->db->mallocFailed || pParse->nErr>0 \n           || pParse->iCacheLevel==iCacheLevel );\n      sqlite3VdbeResolveLabel(v, endLabel);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      assert( pExpr->affinity==OE_Rollback \n           || pExpr->affinity==OE_Abort\n           || pExpr->affinity==OE_Fail\n           || pExpr->affinity==OE_Ignore\n      );\n      if( !pParse->pTriggerTab ){\n        sqlite3ErrorMsg(pParse,\n                       \"RAISE() may only be used within a trigger-program\");\n        return 0;\n      }\n      if( pExpr->affinity==OE_Abort ){\n        sqlite3MayAbort(pParse);\n      }\n      assert( !ExprHasProperty(pExpr, EP_IntValue) );\n      if( pExpr->affinity==OE_Ignore ){\n        sqlite3VdbeAddOp4(\n            v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0);\n        VdbeCoverage(v);\n      }else{\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER,\n                              pExpr->affinity, pExpr->u.zToken, 0, 0);\n      }\n\n      break;\n    }\n#endif\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n  return inReg;\n}\n\n/*\n** Factor out the code of the given expression to initialization time.\n**\n** If regDest>=0 then the result is always stored in that register and the\n** result is not reusable.  If regDest<0 then this routine is free to \n** store the value whereever it wants.  The register where the expression \n** is stored is returned.  When regDest<0, two identical expressions will\n** code to the same register.\n*/\nint sqlite3ExprCodeAtInit(\n  Parse *pParse,    /* Parsing context */\n  Expr *pExpr,      /* The expression to code when the VDBE initializes */\n  int regDest       /* Store the value in this register */\n){\n  ExprList *p;\n  assert( ConstFactorOk(pParse) );\n  p = pParse->pConstExpr;\n  if( regDest<0 && p ){\n    struct ExprList_item *pItem;\n    int i;\n    for(pItem=p->a, i=p->nExpr; i>0; pItem++, i--){\n      if( pItem->reusable && sqlite3ExprCompare(0,pItem->pExpr,pExpr,-1)==0 ){\n        return pItem->u.iConstExprReg;\n      }\n    }\n  }\n  pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);\n  p = sqlite3ExprListAppend(pParse, p, pExpr);\n  if( p ){\n     struct ExprList_item *pItem = &p->a[p->nExpr-1];\n     pItem->reusable = regDest<0;\n     if( regDest<0 ) regDest = ++pParse->nMem;\n     pItem->u.iConstExprReg = regDest;\n  }\n  pParse->pConstExpr = p;\n  return regDest;\n}\n\n/*\n** Generate code to evaluate an expression and store the results\n** into a register.  Return the register number where the results\n** are stored.\n**\n** If the register is a temporary register that can be deallocated,\n** then write its number into *pReg.  If the result register is not\n** a temporary, then set *pReg to zero.\n**\n** If pExpr is a constant, then this routine might generate this\n** code to fill the register in the initialization section of the\n** VDBE program, in order to factor it out of the evaluation loop.\n*/\nint sqlite3ExprCodeTemp(Parse *pParse, Expr *pExpr, int *pReg){\n  int r2;\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n  if( ConstFactorOk(pParse)\n   && pExpr->op!=TK_REGISTER\n   && sqlite3ExprIsConstantNotJoin(pExpr)\n  ){\n    *pReg  = 0;\n    r2 = sqlite3ExprCodeAtInit(pParse, pExpr, -1);\n  }else{\n    int r1 = sqlite3GetTempReg(pParse);\n    r2 = sqlite3ExprCodeTarget(pParse, pExpr, r1);\n    if( r2==r1 ){\n      *pReg = r1;\n    }else{\n      sqlite3ReleaseTempReg(pParse, r1);\n      *pReg = 0;\n    }\n  }\n  return r2;\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.\n*/\nvoid sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){\n  int inReg;\n\n  assert( target>0 && target<=pParse->nMem );\n  if( pExpr && pExpr->op==TK_REGISTER ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);\n  }else{\n    inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);\n    assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );\n    if( inReg!=target && pParse->pVdbe ){\n      sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);\n    }\n  }\n}\n\n/*\n** Make a transient copy of expression pExpr and then code it using\n** sqlite3ExprCode().  This routine works just like sqlite3ExprCode()\n** except that the input expression is guaranteed to be unchanged.\n*/\nvoid sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){\n  sqlite3 *db = pParse->db;\n  pExpr = sqlite3ExprDup(db, pExpr, 0);\n  if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);\n  sqlite3ExprDelete(db, pExpr);\n}\n\n/*\n** Generate code that will evaluate expression pExpr and store the\n** results in register target.  The results are guaranteed to appear\n** in register target.  If the expression is constant, then this routine\n** might choose to code the expression at initialization time.\n*/\nvoid sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){\n  if( pParse->okConstFactor && sqlite3ExprIsConstant(pExpr) ){\n    sqlite3ExprCodeAtInit(pParse, pExpr, target);\n  }else{\n    sqlite3ExprCode(pParse, pExpr, target);\n  }\n}\n\n/*\n** Generate code that evaluates the given expression and puts the result\n** in register target.\n**\n** Also make a copy of the expression results into another \"cache\" register\n** and modify the expression so that the next time it is evaluated,\n** the result is a copy of the cache register.\n**\n** This routine is used for expressions that are used multiple \n** times.  They are evaluated once and the results of the expression\n** are reused.\n*/\nvoid sqlite3ExprCodeAndCache(Parse *pParse, Expr *pExpr, int target){\n  Vdbe *v = pParse->pVdbe;\n  int iMem;\n\n  assert( target>0 );\n  assert( pExpr->op!=TK_REGISTER );\n  sqlite3ExprCode(pParse, pExpr, target);\n  iMem = ++pParse->nMem;\n  sqlite3VdbeAddOp2(v, OP_Copy, target, iMem);\n  exprToRegister(pExpr, iMem);\n}\n\n/*\n** Generate code that pushes the value of every element of the given\n** expression list into a sequence of registers beginning at target.\n**\n** Return the number of elements evaluated.  The number returned will\n** usually be pList->nExpr but might be reduced if SQLITE_ECEL_OMITREF\n** is defined.\n**\n** The SQLITE_ECEL_DUP flag prevents the arguments from being\n** filled using OP_SCopy.  OP_Copy must be used instead.\n**\n** The SQLITE_ECEL_FACTOR argument allows constant arguments to be\n** factored out into initialization code.\n**\n** The SQLITE_ECEL_REF flag means that expressions in the list with\n** ExprList.a[].u.x.iOrderByCol>0 have already been evaluated and stored\n** in registers at srcReg, and so the value can be copied from there.\n** If SQLITE_ECEL_OMITREF is also set, then the values with u.x.iOrderByCol>0\n** are simply omitted rather than being copied from srcReg.\n*/\nint sqlite3ExprCodeExprList(\n  Parse *pParse,     /* Parsing context */\n  ExprList *pList,   /* The expression list to be coded */\n  int target,        /* Where to write results */\n  int srcReg,        /* Source registers if SQLITE_ECEL_REF */\n  u8 flags           /* SQLITE_ECEL_* flags */\n){\n  struct ExprList_item *pItem;\n  int i, j, n;\n  u8 copyOp = (flags & SQLITE_ECEL_DUP) ? OP_Copy : OP_SCopy;\n  Vdbe *v = pParse->pVdbe;\n  assert( pList!=0 );\n  assert( target>0 );\n  assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */\n  n = pList->nExpr;\n  if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;\n  for(pItem=pList->a, i=0; i<n; i++, pItem++){\n    Expr *pExpr = pItem->pExpr;\n    if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){\n      if( flags & SQLITE_ECEL_OMITREF ){\n        i--;\n        n--;\n      }else{\n        sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);\n      }\n    }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){\n      sqlite3ExprCodeAtInit(pParse, pExpr, target+i);\n    }else{\n      int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i);\n      if( inReg!=target+i ){\n        VdbeOp *pOp;\n        if( copyOp==OP_Copy\n         && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy\n         && pOp->p1+pOp->p3+1==inReg\n         && pOp->p2+pOp->p3+1==target+i\n        ){\n          pOp->p3++;\n        }else{\n          sqlite3VdbeAddOp2(v, copyOp, inReg, target+i);\n        }\n      }\n    }\n  }\n  return n;\n}\n\n/*\n** Generate code for a BETWEEN operator.\n**\n**    x BETWEEN y AND z\n**\n** The above is equivalent to \n**\n**    x>=y AND x<=z\n**\n** Code it as such, taking care to do the common subexpression\n** elimination of x.\n**\n** The xJumpIf parameter determines details:\n**\n**    NULL:                   Store the boolean result in reg[dest]\n**    sqlite3ExprIfTrue:      Jump to dest if true\n**    sqlite3ExprIfFalse:     Jump to dest if false\n**\n** The jumpIfNull parameter is ignored if xJumpIf is NULL.\n*/\nstatic void exprCodeBetween(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* The BETWEEN expression */\n  int dest,         /* Jump destination or storage location */\n  void (*xJump)(Parse*,Expr*,int,int), /* Action to take */\n  int jumpIfNull    /* Take the jump if the BETWEEN is NULL */\n){\n Expr exprAnd;     /* The AND operator in  x>=y AND x<=z  */\n  Expr compLeft;    /* The  x>=y  term */\n  Expr compRight;   /* The  x<=z  term */\n  Expr exprX;       /* The  x  subexpression */\n  int regFree1 = 0; /* Temporary use register */\n\n\n  memset(&compLeft, 0, sizeof(Expr));\n  memset(&compRight, 0, sizeof(Expr));\n  memset(&exprAnd, 0, sizeof(Expr));\n\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  exprX = *pExpr->pLeft;\n  exprAnd.op = TK_AND;\n  exprAnd.pLeft = &compLeft;\n  exprAnd.pRight = &compRight;\n  compLeft.op = TK_GE;\n  compLeft.pLeft = &exprX;\n  compLeft.pRight = pExpr->x.pList->a[0].pExpr;\n  compRight.op = TK_LE;\n  compRight.pLeft = &exprX;\n  compRight.pRight = pExpr->x.pList->a[1].pExpr;\n  exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));\n  if( xJump ){\n    xJump(pParse, &exprAnd, dest, jumpIfNull);\n  }else{\n    /* Mark the expression is being from the ON or USING clause of a join\n    ** so that the sqlite3ExprCodeTarget() routine will not attempt to move\n    ** it into the Parse.pConstExpr list.  We should use a new bit for this,\n    ** for clarity, but we are out of bits in the Expr.flags field so we\n    ** have to reuse the EP_FromJoin bit.  Bummer. */\n    exprX.flags |= EP_FromJoin;\n    sqlite3ExprCodeTarget(pParse, &exprAnd, dest);\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n\n  /* Ensure adequate test coverage */\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfTrue  && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull==0 && regFree1!=0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1==0 );\n  testcase( xJump==sqlite3ExprIfFalse && jumpIfNull!=0 && regFree1!=0 );\n  testcase( xJump==0 );\n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is true but execution\n** continues straight thru if the expression is false.\n**\n** If the expression evaluates to NULL (neither true nor false), then\n** take the jump if the jumpIfNull flag is SQLITE_JUMPIFNULL.\n**\n** This code depends on the fact that certain token values (ex: TK_EQ)\n** are the same as opcode values (ex: OP_Eq) that implement the corresponding\n** operation.  Special comments in vdbe.c and the mkopcodeh.awk script in\n** the make process cause these values to align.  Assert()s in the code\n** below verify that the numbers are aligned correctly.\n*/\nvoid sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) )     return;  /* Existence of VDBE checked by caller */\n  if( NEVER(pExpr==0) ) return;  /* No way this can happen */\n  op = pExpr->op;\n  switch( op ){\n    case TK_AND: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_OR: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( op==TK_IS );\n      testcase( op==TK_ISNOT );\n      op = (op==TK_IS) ? TK_EQ : TK_NE;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      assert( TK_ISNULL==OP_IsNull );   testcase( op==TK_ISNULL );\n      assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      VdbeCoverageIf(v, op==TK_ISNULL);\n      VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      int destIfFalse = sqlite3VdbeMakeLabel(v);\n      int destIfNull = jumpIfNull ? dest : destIfFalse;\n      sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);\n      sqlite3VdbeGoto(v, dest);\n      sqlite3VdbeResolveLabel(v, destIfFalse);\n      break;\n    }\n#endif\n    default: {\n    default_expr:\n      if( exprAlwaysTrue(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysFalse(pExpr) ){\n        /* No-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);  \n}\n\n/*\n** Generate code for a boolean expression such that a jump is made\n** to the label \"dest\" if the expression is false but execution\n** continues straight thru if the expression is true.\n**\n** If the expression evaluates to NULL (neither true nor false) then\n** jump if jumpIfNull is SQLITE_JUMPIFNULL or fall through if jumpIfNull\n** is 0.\n*/\nvoid sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){\n  Vdbe *v = pParse->pVdbe;\n  int op = 0;\n  int regFree1 = 0;\n  int regFree2 = 0;\n  int r1, r2;\n\n  assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 );\n  if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */\n  if( pExpr==0 )    return;\n\n  /* The value of pExpr->op and op are related as follows:\n  **\n  **       pExpr->op            op\n  **       ---------          ----------\n  **       TK_ISNULL          OP_NotNull\n  **       TK_NOTNULL         OP_IsNull\n  **       TK_NE              OP_Eq\n  **       TK_EQ              OP_Ne\n  **       TK_GT              OP_Le\n  **       TK_LE              OP_Gt\n  **       TK_GE              OP_Lt\n  **       TK_LT              OP_Ge\n  **\n  ** For other values of pExpr->op, op is undefined and unused.\n  ** The value of TK_ and OP_ constants are arranged such that we\n  ** can compute the mapping above using the following expression.\n  ** Assert()s verify that the computation is correct.\n  */\n  op = ((pExpr->op+(TK_ISNULL&1))^1)-(TK_ISNULL&1);\n\n  /* Verify correct alignment of TK_ and OP_ constants\n  */\n  assert( pExpr->op!=TK_ISNULL || op==OP_NotNull );\n  assert( pExpr->op!=TK_NOTNULL || op==OP_IsNull );\n  assert( pExpr->op!=TK_NE || op==OP_Eq );\n  assert( pExpr->op!=TK_EQ || op==OP_Ne );\n  assert( pExpr->op!=TK_LT || op==OP_Ge );\n  assert( pExpr->op!=TK_LE || op==OP_Gt );\n  assert( pExpr->op!=TK_GT || op==OP_Le );\n  assert( pExpr->op!=TK_GE || op==OP_Lt );\n\n  switch( pExpr->op ){\n    case TK_AND: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_OR: {\n      int d2 = sqlite3VdbeMakeLabel(v);\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);\n      sqlite3ExprCachePush(pParse);\n      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);\n      sqlite3VdbeResolveLabel(v, d2);\n      sqlite3ExprCachePop(pParse);\n      break;\n    }\n    case TK_NOT: {\n      testcase( jumpIfNull==0 );\n      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);\n      break;\n    }\n    case TK_IS:\n    case TK_ISNOT:\n      testcase( pExpr->op==TK_IS );\n      testcase( pExpr->op==TK_ISNOT );\n      op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;\n      jumpIfNull = SQLITE_NULLEQ;\n      /* Fall thru */\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_NE:\n    case TK_EQ: {\n      if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr;\n      testcase( jumpIfNull==0 );\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);\n      codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,\n                  r1, r2, dest, jumpIfNull);\n      assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt);\n      assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le);\n      assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt);\n      assert(TK_GE==OP_Ge); testcase(op==OP_Ge); VdbeCoverageIf(v,op==OP_Ge);\n      assert(TK_EQ==OP_Eq); testcase(op==OP_Eq);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Eq && jumpIfNull==SQLITE_NULLEQ);\n      assert(TK_NE==OP_Ne); testcase(op==OP_Ne);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ);\n      VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ);\n      testcase( regFree1==0 );\n      testcase( regFree2==0 );\n      break;\n    }\n    case TK_ISNULL:\n    case TK_NOTNULL: {\n      r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);\n      sqlite3VdbeAddOp2(v, op, r1, dest);\n      testcase( op==TK_ISNULL );   VdbeCoverageIf(v, op==TK_ISNULL);\n      testcase( op==TK_NOTNULL );  VdbeCoverageIf(v, op==TK_NOTNULL);\n      testcase( regFree1==0 );\n      break;\n    }\n    case TK_BETWEEN: {\n      testcase( jumpIfNull==0 );\n      exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_IN: {\n      if( jumpIfNull ){\n        sqlite3ExprCodeIN(pParse, pExpr, dest, dest);\n      }else{\n        int destIfNull = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);\n        sqlite3VdbeResolveLabel(v, destIfNull);\n      }\n      break;\n    }\n#endif\n    default: {\n    default_expr: \n      if( exprAlwaysFalse(pExpr) ){\n        sqlite3VdbeGoto(v, dest);\n      }else if( exprAlwaysTrue(pExpr) ){\n        /* no-op */\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pExpr, &regFree1);\n        sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0);\n        VdbeCoverage(v);\n        testcase( regFree1==0 );\n        testcase( jumpIfNull==0 );\n      }\n      break;\n    }\n  }\n  sqlite3ReleaseTempReg(pParse, regFree1);\n  sqlite3ReleaseTempReg(pParse, regFree2);\n}\n\n/*\n** Like sqlite3ExprIfFalse() except that a copy is made of pExpr before\n** code generation, and that copy is deleted after code generation. This\n** ensures that the original pExpr is unchanged.\n*/\nvoid sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,int jumpIfNull){\n  sqlite3 *db = pParse->db;\n  Expr *pCopy = sqlite3ExprDup(db, pExpr, 0);\n  if( db->mallocFailed==0 ){\n    sqlite3ExprIfFalse(pParse, pCopy, dest, jumpIfNull);\n  }\n  sqlite3ExprDelete(db, pCopy);\n}\n\n/*\n** Expression pVar is guaranteed to be an SQL variable. pExpr may be any\n** type of expression.\n**\n** If pExpr is a simple SQL value - an integer, real, string, blob\n** or NULL value - then the VDBE currently being prepared is configured\n** to re-prepare each time a new value is bound to variable pVar.\n**\n** Additionally, if pExpr is a simple SQL value and the value is the\n** same as that currently bound to variable pVar, non-zero is returned.\n** Otherwise, if the values are not the same or if pExpr is not a simple\n** SQL value, zero is returned.\n*/\nstatic int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){\n  int res = 0;\n  int iVar;\n  sqlite3_value *pL, *pR = 0;\n  \n  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);\n  if( pR ){\n    iVar = pVar->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iVar);\n    pL = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, SQLITE_AFF_BLOB);\n    if( pL ){\n      if( sqlite3_value_type(pL)==SQLITE_TEXT ){\n        sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */\n      }\n      res =  0==sqlite3MemCompare(pL, pR, 0);\n    }\n    sqlite3ValueFree(pR);\n    sqlite3ValueFree(pL);\n  }\n\n  return res;\n}\n\n/*\n** Do a deep comparison of two expression trees.  Return 0 if the two\n** expressions are completely identical.  Return 1 if they differ only\n** by a COLLATE operator at the top level.  Return 2 if there are differences\n** other than the top-level COLLATE operator.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** The pA side might be using TK_REGISTER.  If that is the case and pB is\n** not using TK_REGISTER but is otherwise equivalent, then still return 0.\n**\n** Sometimes this routine will return 2 even if the two expressions\n** really are equivalent.  If we cannot prove that the expressions are\n** identical, we return 2 just to be safe.  So if this routine\n** returns 2, then you do not really know for certain if the two\n** expressions are the same.  But if you get a 0 or 1 return, then you\n** can be sure the expressions are the same.  In the places where\n** this routine is used, it does not hurt to get an extra 2 - that\n** just might result in some slightly slower code.  But returning\n** an incorrect 0 or 1 could lead to a malfunction.\n**\n** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in\n** pParse->pReprepare can be matched against literals in pB.  The \n** pParse->pVdbe->expmask bitmask is updated for each variable referenced.\n** If pParse is NULL (the normal case) then any TK_VARIABLE term in \n** Argument pParse should normally be NULL. If it is not NULL and pA or\n** pB causes a return value of 2.\n*/\nint sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){\n  u32 combinedFlags;\n  if( pA==0 || pB==0 ){\n    return pB==pA ? 0 : 2;\n  }\n  if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){\n    return 0;\n  }\n  combinedFlags = pA->flags | pB->flags;\n  if( combinedFlags & EP_IntValue ){\n    if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){\n      return 0;\n    }\n    return 2;\n  }\n  if( pA->op!=pB->op ){\n    if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){\n      return 1;\n    }\n    if( pB->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA,pB->pLeft,iTab)<2 ){\n      return 1;\n    }\n    return 2;\n  }\n  if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){\n    if( pA->op==TK_FUNCTION ){\n      if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;\n    }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){\n      return pA->op==TK_COLLATE ? 1 : 2;\n    }\n  }\n  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;\n  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){\n    if( combinedFlags & EP_xIsSelect ) return 2;\n    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;\n    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;\n    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;\n    if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){\n      if( pA->iColumn!=pB->iColumn ) return 2;\n      if( pA->iTable!=pB->iTable \n       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;\n    }\n  }\n  return 0;\n}\n\n/*\n** Compare two ExprList objects.  Return 0 if they are identical and \n** non-zero if they differ in any way.\n**\n** If any subelement of pB has Expr.iTable==(-1) then it is allowed\n** to compare equal to an equivalent element in pA with Expr.iTable==iTab.\n**\n** This routine might return non-zero for equivalent ExprLists.  The\n** only consequence will be disabled optimizations.  But this routine\n** must never return 0 if the two ExprList objects are different, or\n** a malfunction will result.\n**\n** Two NULL pointers are considered to be the same.  But a NULL pointer\n** always differs from a non-NULL pointer.\n*/\nint sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){\n  int i;\n  if( pA==0 && pB==0 ) return 0;\n  if( pA==0 || pB==0 ) return 1;\n  if( pA->nExpr!=pB->nExpr ) return 1;\n  for(i=0; i<pA->nExpr; i++){\n    Expr *pExprA = pA->a[i].pExpr;\n    Expr *pExprB = pB->a[i].pExpr;\n    if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;\n    if( sqlite3ExprCompare(0, pExprA, pExprB, iTab) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Like sqlite3ExprCompare() except COLLATE operators at the top-level\n** are ignored.\n*/\nint sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){\n  return sqlite3ExprCompare(0,\n             sqlite3ExprSkipCollate(pA),\n             sqlite3ExprSkipCollate(pB),\n             iTab);\n}\n\n/*\n** Return true if we can prove the pE2 will always be true if pE1 is\n** true.  Return false if we cannot complete the proof or if pE2 might\n** be false.  Examples:\n**\n**     pE1: x==5       pE2: x==5             Result: true\n**     pE1: x>0        pE2: x==5             Result: false\n**     pE1: x=21       pE2: x=21 OR y=43     Result: true\n**     pE1: x!=123     pE2: x IS NOT NULL    Result: true\n**     pE1: x!=?1      pE2: x IS NOT NULL    Result: true\n**     pE1: x IS NULL  pE2: x IS NOT NULL    Result: false\n**     pE1: x IS ?2    pE2: x IS NOT NULL    Reuslt: false\n**\n** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has\n** Expr.iTable<0 then assume a table number given by iTab.\n**\n** If pParse is not NULL, then the values of bound variables in pE1 are \n** compared against literal values in pE2 and pParse->pVdbe->expmask is\n** modified to record which bound variables are referenced.  If pParse \n** is NULL, then false will be returned if pE1 contains any bound variables.\n**\n** When in doubt, return false.  Returning true might give a performance\n** improvement.  Returning false might cause a performance reduction, but\n** it will always give the correct answer and is hence always safe.\n*/\nint sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){\n  if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){\n    return 1;\n  }\n  if( pE2->op==TK_OR\n   && (sqlite3ExprImpliesExpr(pParse, pE1, pE2->pLeft, iTab)\n             || sqlite3ExprImpliesExpr(pParse, pE1, pE2->pRight, iTab) )\n  ){\n    return 1;\n  }\n  if( pE2->op==TK_NOTNULL && pE1->op!=TK_ISNULL && pE1->op!=TK_IS ){\n    Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);\n    testcase( pX!=pE1->pLeft );\n    if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;\n  }\n  return 0;\n}\n\n/*\n** An instance of the following structure is used by the tree walker\n** to determine if an expression can be evaluated by reference to the\n** index only, without having to do a search for the corresponding\n** table entry.  The IdxCover.pIdx field is the index.  IdxCover.iCur\n** is the cursor for the table.\n*/\nstruct IdxCover {\n  Index *pIdx;     /* The index to be tested for coverage */\n  int iCur;        /* Cursor number for the table corresponding to the index */\n};\n\n/*\n** Check to see if there are references to columns in table \n** pWalker->u.pIdxCover->iCur can be satisfied using the index\n** pWalker->u.pIdxCover->pIdx.\n*/\nstatic int exprIdxCover(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pWalker->u.pIdxCover->iCur\n   && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if an index pIdx on table with cursor iCur contains will\n** the expression pExpr.  Return true if the index does cover the\n** expression and false if the pExpr expression references table columns\n** that are not found in the index pIdx.\n**\n** An index covering an expression means that the expression can be\n** evaluated using only the index and without having to lookup the\n** corresponding table entry.\n*/\nint sqlite3ExprCoveredByIndex(\n  Expr *pExpr,        /* The index to be tested */\n  int iCur,           /* The cursor number for the corresponding table */\n  Index *pIdx         /* The index that might be used for coverage */\n){\n  Walker w;\n  struct IdxCover xcov;\n  memset(&w, 0, sizeof(w));\n  xcov.iCur = iCur;\n  xcov.pIdx = pIdx;\n  w.xExprCallback = exprIdxCover;\n  w.u.pIdxCover = &xcov;\n  sqlite3WalkExpr(&w, pExpr);\n  return !w.eCode;\n}\n\n\n/*\n** An instance of the following structure is used by the tree walker\n** to count references to table columns in the arguments of an \n** aggregate function, in order to implement the\n** sqlite3FunctionThisSrc() routine.\n*/\nstruct SrcCount {\n  SrcList *pSrc;   /* One particular FROM clause in a nested query */\n  int nThis;       /* Number of references to columns in pSrcList */\n  int nOther;      /* Number of references to columns in other FROM clauses */\n};\n\n/*\n** Count the number of references to columns.\n*/\nstatic int exprSrcCount(Walker *pWalker, Expr *pExpr){\n  /* The NEVER() on the second term is because sqlite3FunctionUsesThisSrc()\n  ** is always called before sqlite3ExprAnalyzeAggregates() and so the\n  ** TK_COLUMNs have not yet been converted into TK_AGG_COLUMN.  If\n  ** sqlite3FunctionUsesThisSrc() is used differently in the future, the\n  ** NEVER() will need to be removed. */\n  if( pExpr->op==TK_COLUMN || NEVER(pExpr->op==TK_AGG_COLUMN) ){\n    int i;\n    struct SrcCount *p = pWalker->u.pSrcCount;\n    SrcList *pSrc = p->pSrc;\n    int nSrc = pSrc ? pSrc->nSrc : 0;\n    for(i=0; i<nSrc; i++){\n      if( pExpr->iTable==pSrc->a[i].iCursor ) break;\n    }\n    if( i<nSrc ){\n      p->nThis++;\n    }else{\n      p->nOther++;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Determine if any of the arguments to the pExpr Function reference\n** pSrcList.  Return true if they do.  Also return true if the function\n** has no arguments or has only constant arguments.  Return false if pExpr\n** references columns but not columns of tables found in pSrcList.\n*/\nint sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){\n  Walker w;\n  struct SrcCount cnt;\n  assert( pExpr->op==TK_AGG_FUNCTION );\n  w.xExprCallback = exprSrcCount;\n  w.xSelectCallback = 0;\n  w.u.pSrcCount = &cnt;\n  cnt.pSrc = pSrcList;\n  cnt.nThis = 0;\n  cnt.nOther = 0;\n  sqlite3WalkExprList(&w, pExpr->x.pList);\n  return cnt.nThis>0 || cnt.nOther==0;\n}\n\n/*\n** Add a new element to the pAggInfo->aCol[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoColumn(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aCol = sqlite3ArrayAllocate(\n       db,\n       pInfo->aCol,\n       sizeof(pInfo->aCol[0]),\n       &pInfo->nColumn,\n       &i\n  );\n  return i;\n}    \n\n/*\n** Add a new element to the pAggInfo->aFunc[] array.  Return the index of\n** the new element.  Return a negative number if malloc fails.\n*/\nstatic int addAggInfoFunc(sqlite3 *db, AggInfo *pInfo){\n  int i;\n  pInfo->aFunc = sqlite3ArrayAllocate(\n       db, \n       pInfo->aFunc,\n       sizeof(pInfo->aFunc[0]),\n       &pInfo->nFunc,\n       &i\n  );\n  return i;\n}    \n\n/*\n** This is the xExprCallback for a tree walker.  It is used to\n** implement sqlite3ExprAnalyzeAggregates().  See sqlite3ExprAnalyzeAggregates\n** for additional information.\n*/\nstatic int analyzeAggregate(Walker *pWalker, Expr *pExpr){\n  int i;\n  NameContext *pNC = pWalker->u.pNC;\n  Parse *pParse = pNC->pParse;\n  SrcList *pSrcList = pNC->pSrcList;\n  AggInfo *pAggInfo = pNC->pAggInfo;\n\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      /* Check to see if the column is in one of the tables in the FROM\n      ** clause of the aggregate query */\n      if( ALWAYS(pSrcList!=0) ){\n        struct SrcList_item *pItem = pSrcList->a;\n        for(i=0; i<pSrcList->nSrc; i++, pItem++){\n          struct AggInfo_col *pCol;\n          assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n          if( pExpr->iTable==pItem->iCursor ){\n            /* If we reach this point, it means that pExpr refers to a table\n            ** that is in the FROM clause of the aggregate query.  \n            **\n            ** Make an entry for the column in pAggInfo->aCol[] if there\n            ** is not an entry there already.\n            */\n            int k;\n            pCol = pAggInfo->aCol;\n            for(k=0; k<pAggInfo->nColumn; k++, pCol++){\n              if( pCol->iTable==pExpr->iTable &&\n                  pCol->iColumn==pExpr->iColumn ){\n                break;\n              }\n            }\n            if( (k>=pAggInfo->nColumn)\n             && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 \n            ){\n              pCol = &pAggInfo->aCol[k];\n              pCol->pTab = pExpr->pTab;\n              pCol->iTable = pExpr->iTable;\n              pCol->iColumn = pExpr->iColumn;\n              pCol->iMem = ++pParse->nMem;\n              pCol->iSorterColumn = -1;\n              pCol->pExpr = pExpr;\n              if( pAggInfo->pGroupBy ){\n                int j, n;\n                ExprList *pGB = pAggInfo->pGroupBy;\n                struct ExprList_item *pTerm = pGB->a;\n                n = pGB->nExpr;\n                for(j=0; j<n; j++, pTerm++){\n                  Expr *pE = pTerm->pExpr;\n                  if( pE->op==TK_COLUMN && pE->iTable==pExpr->iTable &&\n                      pE->iColumn==pExpr->iColumn ){\n                    pCol->iSorterColumn = j;\n                    break;\n                  }\n                }\n              }\n              if( pCol->iSorterColumn<0 ){\n                pCol->iSorterColumn = pAggInfo->nSortingColumn++;\n              }\n            }\n            /* There is now an entry for pExpr in pAggInfo->aCol[] (either\n            ** because it was there before or because we just created it).\n            ** Convert the pExpr to be a TK_AGG_COLUMN referring to that\n            ** pAggInfo->aCol[] entry.\n            */\n            ExprSetVVAProperty(pExpr, EP_NoReduce);\n            pExpr->pAggInfo = pAggInfo;\n            pExpr->op = TK_AGG_COLUMN;\n            pExpr->iAgg = (i16)k;\n            break;\n          } /* endif pExpr->iTable==pItem->iCursor */\n        } /* end loop over pSrcList */\n      }\n      return WRC_Prune;\n    }\n    case TK_AGG_FUNCTION: {\n      if( (pNC->ncFlags & NC_InAggFunc)==0\n       && pWalker->walkerDepth==pExpr->op2\n      ){\n        /* Check to see if pExpr is a duplicate of another aggregate \n        ** function that is already in the pAggInfo structure\n        */\n        struct AggInfo_func *pItem = pAggInfo->aFunc;\n        for(i=0; i<pAggInfo->nFunc; i++, pItem++){\n          if( sqlite3ExprCompare(0, pItem->pExpr, pExpr, -1)==0 ){\n            break;\n          }\n        }\n        if( i>=pAggInfo->nFunc ){\n          /* pExpr is original.  Make a new entry in pAggInfo->aFunc[]\n          */\n          u8 enc = ENC(pParse->db);\n          i = addAggInfoFunc(pParse->db, pAggInfo);\n          if( i>=0 ){\n            assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n            pItem = &pAggInfo->aFunc[i];\n            pItem->pExpr = pExpr;\n            pItem->iMem = ++pParse->nMem;\n            assert( !ExprHasProperty(pExpr, EP_IntValue) );\n            pItem->pFunc = sqlite3FindFunction(pParse->db,\n                   pExpr->u.zToken, \n                   pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0);\n            if( pExpr->flags & EP_Distinct ){\n              pItem->iDistinct = pParse->nTab++;\n            }else{\n              pItem->iDistinct = -1;\n            }\n          }\n        }\n        /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry\n        */\n        assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n        ExprSetVVAProperty(pExpr, EP_NoReduce);\n        pExpr->iAgg = (i16)i;\n        pExpr->pAggInfo = pAggInfo;\n        return WRC_Prune;\n      }else{\n        return WRC_Continue;\n      }\n    }\n  }\n  return WRC_Continue;\n}\nstatic int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth++;\n  return WRC_Continue;\n}\nstatic void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){\n  UNUSED_PARAMETER(pSelect);\n  pWalker->walkerDepth--;\n}\n\n/*\n** Analyze the pExpr expression looking for aggregate functions and\n** for variables that need to be added to AggInfo object that pNC->pAggInfo\n** points to.  Additional entries are made on the AggInfo object as\n** necessary.\n**\n** This routine should only be called after the expression has been\n** analyzed by sqlite3ResolveExprNames().\n*/\nvoid sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){\n  Walker w;\n  w.xExprCallback = analyzeAggregate;\n  w.xSelectCallback = analyzeAggregatesInSelect;\n  w.xSelectCallback2 = analyzeAggregatesInSelectEnd;\n  w.walkerDepth = 0;\n  w.u.pNC = pNC;\n  assert( pNC->pSrcList!=0 );\n  sqlite3WalkExpr(&w, pExpr);\n}\n\n/*\n** Call sqlite3ExprAnalyzeAggregates() for every expression in an\n** expression list.  Return the number of errors.\n**\n** If an error is found, the analysis is cut short.\n*/\nvoid sqlite3ExprAnalyzeAggList(NameContext *pNC, ExprList *pList){\n  struct ExprList_item *pItem;\n  int i;\n  if( pList ){\n    for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){\n      sqlite3ExprAnalyzeAggregates(pNC, pItem->pExpr);\n    }\n  }\n}\n\n/*\n** Allocate a single new register for use to hold some intermediate result.\n*/\nint sqlite3GetTempReg(Parse *pParse){\n  if( pParse->nTempReg==0 ){\n    return ++pParse->nMem;\n  }\n  return pParse->aTempReg[--pParse->nTempReg];\n}\n\n/*\n** Deallocate a register, making available for reuse for some other\n** purpose.\n**\n** If a register is currently being used by the column cache, then\n** the deallocation is deferred until the column cache line that uses\n** the register becomes stale.\n*/\nvoid sqlite3ReleaseTempReg(Parse *pParse, int iReg){\n  if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){\n    int i;\n    struct yColCache *p;\n    for(i=0, p=pParse->aColCache; i<pParse->nColCache; i++, p++){\n      if( p->iReg==iReg ){\n        p->tempReg = 1;\n        return;\n      }\n    }\n    pParse->aTempReg[pParse->nTempReg++] = iReg;\n  }\n}\n\n/*\n** Allocate or deallocate a block of nReg consecutive registers.\n*/\nint sqlite3GetTempRange(Parse *pParse, int nReg){\n  int i, n;\n  if( nReg==1 ) return sqlite3GetTempReg(pParse);\n  i = pParse->iRangeReg;\n  n = pParse->nRangeReg;\n  if( nReg<=n ){\n    assert( !usedAsColumnCache(pParse, i, i+n-1) );\n    pParse->iRangeReg += nReg;\n    pParse->nRangeReg -= nReg;\n  }else{\n    i = pParse->nMem+1;\n    pParse->nMem += nReg;\n  }\n  return i;\n}\nvoid sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){\n  if( nReg==1 ){\n    sqlite3ReleaseTempReg(pParse, iReg);\n    return;\n  }\n  sqlite3ExprCacheRemove(pParse, iReg, nReg);\n  if( nReg>pParse->nRangeReg ){\n    pParse->nRangeReg = nReg;\n    pParse->iRangeReg = iReg;\n  }\n}\n\n/*\n** Mark all temporary registers as being unavailable for reuse.\n*/\nvoid sqlite3ClearTempRegCache(Parse *pParse){\n  pParse->nTempReg = 0;\n  pParse->nRangeReg = 0;\n}\n\n/*\n** Validate that no temporary register falls within the range of\n** iFirst..iLast, inclusive.  This routine is only call from within assert()\n** statements.\n*/\n#ifdef SQLITE_DEBUG\nint sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){\n  int i;\n  if( pParse->nRangeReg>0\n   && pParse->iRangeReg+pParse->nRangeReg > iFirst\n   && pParse->iRangeReg <= iLast\n  ){\n     return 0;\n  }\n  for(i=0; i<pParse->nTempReg; i++){\n    if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){\n      return 0;\n    }\n  }\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/fault.c",
    "content": "/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to support the concept of \"benign\" \n** malloc failures (when the xMalloc() or xRealloc() method of the\n** sqlite3_mem_methods structure fails to allocate a block of memory\n** and returns 0). \n**\n** Most malloc failures are non-benign. After they occur, SQLite\n** abandons the current operation and returns an error code (usually\n** SQLITE_NOMEM) to the user. However, sometimes a fault is not necessarily\n** fatal. For example, if a malloc fails while resizing a hash table, this \n** is completely recoverable simply by not carrying out the resize. The \n** hash table will continue to function normally.  So a malloc failure \n** during a hash table resize is a benign fault.\n*/\n\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_UNTESTABLE\n\n/*\n** Global variables.\n*/\ntypedef struct BenignMallocHooks BenignMallocHooks;\nstatic SQLITE_WSD struct BenignMallocHooks {\n  void (*xBenignBegin)(void);\n  void (*xBenignEnd)(void);\n} sqlite3Hooks = { 0, 0 };\n\n/* The \"wsdHooks\" macro will resolve to the appropriate BenignMallocHooks\n** structure.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdHooks can refer directly\n** to the \"sqlite3Hooks\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdHooksInit \\\n  BenignMallocHooks *x = &GLOBAL(BenignMallocHooks,sqlite3Hooks)\n# define wsdHooks x[0]\n#else\n# define wsdHooksInit\n# define wsdHooks sqlite3Hooks\n#endif\n\n\n/*\n** Register hooks to call when sqlite3BeginBenignMalloc() and\n** sqlite3EndBenignMalloc() are called, respectively.\n*/\nvoid sqlite3BenignMallocHooks(\n  void (*xBenignBegin)(void),\n  void (*xBenignEnd)(void)\n){\n  wsdHooksInit;\n  wsdHooks.xBenignBegin = xBenignBegin;\n  wsdHooks.xBenignEnd = xBenignEnd;\n}\n\n/*\n** This (sqlite3EndBenignMalloc()) is called by SQLite code to indicate that\n** subsequent malloc failures are benign. A call to sqlite3EndBenignMalloc()\n** indicates that subsequent malloc failures are non-benign.\n*/\nvoid sqlite3BeginBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignBegin ){\n    wsdHooks.xBenignBegin();\n  }\n}\nvoid sqlite3EndBenignMalloc(void){\n  wsdHooksInit;\n  if( wsdHooks.xBenignEnd ){\n    wsdHooks.xBenignEnd();\n  }\n}\n\n#endif   /* #ifndef SQLITE_UNTESTABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/fkey.c",
    "content": "/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used by the compiler to add foreign key\n** support to compiled SQL statements.\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n\n/*\n** Deferred and Immediate FKs\n** --------------------------\n**\n** Foreign keys in SQLite come in two flavours: deferred and immediate.\n** If an immediate foreign key constraint is violated,\n** SQLITE_CONSTRAINT_FOREIGNKEY is returned and the current\n** statement transaction rolled back. If a \n** deferred foreign key constraint is violated, no action is taken \n** immediately. However if the application attempts to commit the \n** transaction before fixing the constraint violation, the attempt fails.\n**\n** Deferred constraints are implemented using a simple counter associated\n** with the database handle. The counter is set to zero each time a \n** database transaction is opened. Each time a statement is executed \n** that causes a foreign key violation, the counter is incremented. Each\n** time a statement is executed that removes an existing violation from\n** the database, the counter is decremented. When the transaction is\n** committed, the commit fails if the current value of the counter is\n** greater than zero. This scheme has two big drawbacks:\n**\n**   * When a commit fails due to a deferred foreign key constraint, \n**     there is no way to tell which foreign constraint is not satisfied,\n**     or which row it is not satisfied for.\n**\n**   * If the database contains foreign key violations when the \n**     transaction is opened, this may cause the mechanism to malfunction.\n**\n** Despite these problems, this approach is adopted as it seems simpler\n** than the alternatives.\n**\n** INSERT operations:\n**\n**   I.1) For each FK for which the table is the child table, search\n**        the parent table for a match. If none is found increment the\n**        constraint counter.\n**\n**   I.2) For each FK for which the table is the parent table, \n**        search the child table for rows that correspond to the new\n**        row in the parent table. Decrement the counter for each row\n**        found (as the constraint is now satisfied).\n**\n** DELETE operations:\n**\n**   D.1) For each FK for which the table is the child table, \n**        search the parent table for a row that corresponds to the \n**        deleted row in the child table. If such a row is not found, \n**        decrement the counter.\n**\n**   D.2) For each FK for which the table is the parent table, search \n**        the child table for rows that correspond to the deleted row \n**        in the parent table. For each found increment the counter.\n**\n** UPDATE operations:\n**\n**   An UPDATE command requires that all 4 steps above are taken, but only\n**   for FK constraints for which the affected columns are actually \n**   modified (values must be compared at runtime).\n**\n** Note that I.1 and D.1 are very similar operations, as are I.2 and D.2.\n** This simplifies the implementation a bit.\n**\n** For the purposes of immediate FK constraints, the OR REPLACE conflict\n** resolution is considered to delete rows before the new row is inserted.\n** If a delete caused by OR REPLACE violates an FK constraint, an exception\n** is thrown, even if the FK constraint would be satisfied after the new \n** row is inserted.\n**\n** Immediate constraints are usually handled similarly. The only difference \n** is that the counter used is stored as part of each individual statement\n** object (struct Vdbe). If, after the statement has run, its immediate\n** constraint counter is greater than zero,\n** it returns SQLITE_CONSTRAINT_FOREIGNKEY\n** and the statement transaction is rolled back. An exception is an INSERT\n** statement that inserts a single row only (no triggers). In this case,\n** instead of using a counter, an exception is thrown immediately if the\n** INSERT violates a foreign key constraint. This is necessary as such\n** an INSERT does not open a statement transaction.\n**\n** TODO: How should dropping a table be handled? How should renaming a \n** table be handled?\n**\n**\n** Query API Notes\n** ---------------\n**\n** Before coding an UPDATE or DELETE row operation, the code-generator\n** for those two operations needs to know whether or not the operation\n** requires any FK processing and, if so, which columns of the original\n** row are required by the FK processing VDBE code (i.e. if FKs were\n** implemented using triggers, which of the old.* columns would be \n** accessed). No information is required by the code-generator before\n** coding an INSERT operation. The functions used by the UPDATE/DELETE\n** generation code to query for this information are:\n**\n**   sqlite3FkRequired() - Test to see if FK processing is required.\n**   sqlite3FkOldmask()  - Query for the set of required old.* columns.\n**\n**\n** Externally accessible module functions\n** --------------------------------------\n**\n**   sqlite3FkCheck()    - Check for foreign key violations.\n**   sqlite3FkActions()  - Code triggers for ON UPDATE/ON DELETE actions.\n**   sqlite3FkDelete()   - Delete an FKey structure.\n*/\n\n/*\n** VDBE Calling Convention\n** -----------------------\n**\n** Example:\n**\n**   For the following INSERT statement:\n**\n**     CREATE TABLE t1(a, b INTEGER PRIMARY KEY, c);\n**     INSERT INTO t1 VALUES(1, 2, 3.1);\n**\n**   Register (x):        2    (type integer)\n**   Register (x+1):      1    (type integer)\n**   Register (x+2):      NULL (type NULL)\n**   Register (x+3):      3.1  (type real)\n*/\n\n/*\n** A foreign key constraint requires that the key columns in the parent\n** table are collectively subject to a UNIQUE or PRIMARY KEY constraint.\n** Given that pParent is the parent table for foreign key constraint pFKey, \n** search the schema for a unique index on the parent key columns. \n**\n** If successful, zero is returned. If the parent key is an INTEGER PRIMARY \n** KEY column, then output variable *ppIdx is set to NULL. Otherwise, *ppIdx \n** is set to point to the unique index. \n** \n** If the parent key consists of a single column (the foreign key constraint\n** is not a composite foreign key), output variable *paiCol is set to NULL.\n** Otherwise, it is set to point to an allocated array of size N, where\n** N is the number of columns in the parent key. The first element of the\n** array is the index of the child table column that is mapped by the FK\n** constraint to the parent table column stored in the left-most column\n** of index *ppIdx. The second element of the array is the index of the\n** child table column that corresponds to the second left-most column of\n** *ppIdx, and so on.\n**\n** If the required index cannot be found, either because:\n**\n**   1) The named parent key columns do not exist, or\n**\n**   2) The named parent key columns do exist, but are not subject to a\n**      UNIQUE or PRIMARY KEY constraint, or\n**\n**   3) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the parent table does not have a\n**      PRIMARY KEY, or\n**\n**   4) No parent key columns were provided explicitly as part of the\n**      foreign key definition, and the PRIMARY KEY of the parent table \n**      consists of a different number of columns to the child key in \n**      the child table.\n**\n** then non-zero is returned, and a \"foreign key mismatch\" error loaded\n** into pParse. If an OOM error occurs, non-zero is returned and the\n** pParse->db->mallocFailed flag is set.\n*/\nint sqlite3FkLocateIndex(\n  Parse *pParse,                  /* Parse context to store any error in */\n  Table *pParent,                 /* Parent table of FK constraint pFKey */\n  FKey *pFKey,                    /* Foreign key to find index for */\n  Index **ppIdx,                  /* OUT: Unique index on parent table */\n  int **paiCol                    /* OUT: Map of index columns in pFKey */\n){\n  Index *pIdx = 0;                    /* Value to return via *ppIdx */\n  int *aiCol = 0;                     /* Value to return via *paiCol */\n  int nCol = pFKey->nCol;             /* Number of columns in parent key */\n  char *zKey = pFKey->aCol[0].zCol;   /* Name of left-most parent key column */\n\n  /* The caller is responsible for zeroing output parameters. */\n  assert( ppIdx && *ppIdx==0 );\n  assert( !paiCol || *paiCol==0 );\n  assert( pParse );\n\n  /* If this is a non-composite (single column) foreign key, check if it \n  ** maps to the INTEGER PRIMARY KEY of table pParent. If so, leave *ppIdx \n  ** and *paiCol set to zero and return early. \n  **\n  ** Otherwise, for a composite foreign key (more than one column), allocate\n  ** space for the aiCol array (returned via output parameter *paiCol).\n  ** Non-composite foreign keys do not require the aiCol array.\n  */\n  if( nCol==1 ){\n    /* The FK maps to the IPK if any of the following are true:\n    **\n    **   1) There is an INTEGER PRIMARY KEY column and the FK is implicitly \n    **      mapped to the primary key of table pParent, or\n    **   2) The FK is explicitly mapped to a column declared as INTEGER\n    **      PRIMARY KEY.\n    */\n    if( pParent->iPKey>=0 ){\n      if( !zKey ) return 0;\n      if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0;\n    }\n  }else if( paiCol ){\n    assert( nCol>1 );\n    aiCol = (int *)sqlite3DbMallocRawNN(pParse->db, nCol*sizeof(int));\n    if( !aiCol ) return 1;\n    *paiCol = aiCol;\n  }\n\n  for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->nKeyCol==nCol && IsUniqueIndex(pIdx) && pIdx->pPartIdxWhere==0 ){ \n      /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number\n      ** of columns. If each indexed column corresponds to a foreign key\n      ** column of pFKey, then this index is a winner.  */\n\n      if( zKey==0 ){\n        /* If zKey is NULL, then this foreign key is implicitly mapped to \n        ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be \n        ** identified by the test.  */\n        if( IsPrimaryKeyIndex(pIdx) ){\n          if( aiCol ){\n            int i;\n            for(i=0; i<nCol; i++) aiCol[i] = pFKey->aCol[i].iFrom;\n          }\n          break;\n        }\n      }else{\n        /* If zKey is non-NULL, then this foreign key was declared to\n        ** map to an explicit list of columns in table pParent. Check if this\n        ** index matches those columns. Also, check that the index uses\n        ** the default collation sequences for each column. */\n        int i, j;\n        for(i=0; i<nCol; i++){\n          i16 iCol = pIdx->aiColumn[i];     /* Index of column in parent tbl */\n          const char *zDfltColl;            /* Def. collation for column */\n          char *zIdxCol;                    /* Name of indexed column */\n\n          if( iCol<0 ) break; /* No foreign keys against expression indexes */\n\n          /* If the index uses a collation sequence that is different from\n          ** the default collation sequence for the column, this index is\n          ** unusable. Bail out early in this case.  */\n          zDfltColl = pParent->aCol[iCol].zColl;\n          if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;\n          if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;\n\n          zIdxCol = pParent->aCol[iCol].zName;\n          for(j=0; j<nCol; j++){\n            if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){\n              if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom;\n              break;\n            }\n          }\n          if( j==nCol ) break;\n        }\n        if( i==nCol ) break;      /* pIdx is usable */\n      }\n    }\n  }\n\n  if( !pIdx ){\n    if( !pParse->disableTriggers ){\n      sqlite3ErrorMsg(pParse,\n           \"foreign key mismatch - \\\"%w\\\" referencing \\\"%w\\\"\",\n           pFKey->pFrom->zName, pFKey->zTo);\n    }\n    sqlite3DbFree(pParse->db, aiCol);\n    return 1;\n  }\n\n  *ppIdx = pIdx;\n  return 0;\n}\n\n/*\n** This function is called when a row is inserted into or deleted from the \n** child table of foreign key constraint pFKey. If an SQL UPDATE is executed \n** on the child table of pFKey, this function is invoked twice for each row\n** affected - once to \"delete\" the old row, and then again to \"insert\" the\n** new row.\n**\n** Each time it is called, this function generates VDBE code to locate the\n** row in the parent table that corresponds to the row being inserted into \n** or deleted from the child table. If the parent row can be found, no \n** special action is taken. Otherwise, if the parent row can *not* be\n** found in the parent table:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   INSERT      immediate   Increment the \"immediate constraint counter\".\n**\n**   DELETE      immediate   Decrement the \"immediate constraint counter\".\n**\n**   INSERT      deferred    Increment the \"deferred constraint counter\".\n**\n**   DELETE      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.1\" and \"D.1\".\n*/\nstatic void fkLookupParent(\n  Parse *pParse,        /* Parse context */\n  int iDb,              /* Index of database housing pTab */\n  Table *pTab,          /* Parent table of FK pFKey */\n  Index *pIdx,          /* Unique index on parent key columns in pTab */\n  FKey *pFKey,          /* Foreign key constraint */\n  int *aiCol,           /* Map from parent key columns to child table columns */\n  int regData,          /* Address of array containing child table row */\n  int nIncr,            /* Increment constraint counter by this */\n  int isIgnore          /* If true, pretend pTab contains all NULL values */\n){\n  int i;                                    /* Iterator variable */\n  Vdbe *v = sqlite3GetVdbe(pParse);         /* Vdbe to add code to */\n  int iCur = pParse->nTab - 1;              /* Cursor number to use */\n  int iOk = sqlite3VdbeMakeLabel(v);        /* jump here if parent key found */\n\n  /* If nIncr is less than zero, then check at runtime if there are any\n  ** outstanding constraints to resolve. If there are not, there is no need\n  ** to check if deleting this row resolves any outstanding violations.\n  **\n  ** Check if any of the key columns in the child table row are NULL. If \n  ** any are, then the constraint is considered satisfied. No need to \n  ** search for a matching row in the parent table.  */\n  if( nIncr<0 ){\n    sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, iOk);\n    VdbeCoverage(v);\n  }\n  for(i=0; i<pFKey->nCol; i++){\n    int iReg = aiCol[i] + regData + 1;\n    sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v);\n  }\n\n  if( isIgnore==0 ){\n    if( pIdx==0 ){\n      /* If pIdx is NULL, then the parent key is the INTEGER PRIMARY KEY\n      ** column of the parent table (table pTab).  */\n      int iMustBeInt;               /* Address of MustBeInt instruction */\n      int regTemp = sqlite3GetTempReg(pParse);\n  \n      /* Invoke MustBeInt to coerce the child key value to an integer (i.e. \n      ** apply the affinity of the parent key). If this fails, then there\n      ** is no matching parent key. Before using MustBeInt, make a copy of\n      ** the value. Otherwise, the value inserted into the child key column\n      ** will have INTEGER affinity applied to it, which may not be correct.  */\n      sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp);\n      iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0);\n      VdbeCoverage(v);\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter.  */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        sqlite3VdbeAddOp3(v, OP_Eq, regData, iOk, regTemp); VdbeCoverage(v);\n        sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      }\n  \n      sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); VdbeCoverage(v);\n      sqlite3VdbeGoto(v, iOk);\n      sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);\n      sqlite3VdbeJumpHere(v, iMustBeInt);\n      sqlite3ReleaseTempReg(pParse, regTemp);\n    }else{\n      int nCol = pFKey->nCol;\n      int regTemp = sqlite3GetTempRange(pParse, nCol);\n      int regRec = sqlite3GetTempReg(pParse);\n  \n      sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      for(i=0; i<nCol; i++){\n        sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i);\n      }\n  \n      /* If the parent table is the same as the child table, and we are about\n      ** to increment the constraint-counter (i.e. this is an INSERT operation),\n      ** then check if the row being inserted matches itself. If so, do not\n      ** increment the constraint-counter. \n      **\n      ** If any of the parent-key values are NULL, then the row cannot match \n      ** itself. So set JUMPIFNULL to make sure we do the OP_Found if any\n      ** of the parent-key values are NULL (at this point it is known that\n      ** none of the child key values are).\n      */\n      if( pTab==pFKey->pFrom && nIncr==1 ){\n        int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1;\n        for(i=0; i<nCol; i++){\n          int iChild = aiCol[i]+1+regData;\n          int iParent = pIdx->aiColumn[i]+1+regData;\n          assert( pIdx->aiColumn[i]>=0 );\n          assert( aiCol[i]!=pTab->iPKey );\n          if( pIdx->aiColumn[i]==pTab->iPKey ){\n            /* The parent key is a composite key that includes the IPK column */\n            iParent = regData;\n          }\n          sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); VdbeCoverage(v);\n          sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);\n        }\n        sqlite3VdbeGoto(v, iOk);\n      }\n  \n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec,\n                        sqlite3IndexAffinityStr(pParse->db,pIdx), nCol);\n      sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); VdbeCoverage(v);\n  \n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempRange(pParse, regTemp, nCol);\n    }\n  }\n\n  if( !pFKey->isDeferred && !(pParse->db->flags & SQLITE_DeferFKs)\n   && !pParse->pToplevel \n   && !pParse->isMultiWrite \n  ){\n    /* Special case: If this is an INSERT statement that will insert exactly\n    ** one row into the table, raise a constraint immediately instead of\n    ** incrementing a counter. This is necessary as the VM code is being\n    ** generated for will not open a statement transaction.  */\n    assert( nIncr==1 );\n    sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n        OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n  }else{\n    if( nIncr>0 && pFKey->isDeferred==0 ){\n      sqlite3MayAbort(pParse);\n    }\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n  }\n\n  sqlite3VdbeResolveLabel(v, iOk);\n  sqlite3VdbeAddOp1(v, OP_Close, iCur);\n}\n\n\n/*\n** Return an Expr object that refers to a memory register corresponding\n** to column iCol of table pTab.\n**\n** regBase is the first of an array of register that contains the data\n** for pTab.  regBase itself holds the rowid.  regBase+1 holds the first\n** column.  regBase+2 holds the second column, and so forth.\n*/\nstatic Expr *exprTableRegister(\n  Parse *pParse,     /* Parsing and code generating context */\n  Table *pTab,       /* The table whose content is at r[regBase]... */\n  int regBase,       /* Contents of table pTab */\n  i16 iCol           /* Which column of pTab is desired */\n){\n  Expr *pExpr;\n  Column *pCol;\n  const char *zColl;\n  sqlite3 *db = pParse->db;\n\n  pExpr = sqlite3Expr(db, TK_REGISTER, 0);\n  if( pExpr ){\n    if( iCol>=0 && iCol!=pTab->iPKey ){\n      pCol = &pTab->aCol[iCol];\n      pExpr->iTable = regBase + iCol + 1;\n      pExpr->affinity = pCol->affinity;\n      zColl = pCol->zColl;\n      if( zColl==0 ) zColl = db->pDfltColl->zName;\n      pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl);\n    }else{\n      pExpr->iTable = regBase;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n  }\n  return pExpr;\n}\n\n/*\n** Return an Expr object that refers to column iCol of table pTab which\n** has cursor iCur.\n*/\nstatic Expr *exprTableColumn(\n  sqlite3 *db,      /* The database connection */\n  Table *pTab,      /* The table whose column is desired */\n  int iCursor,      /* The open cursor on the table */\n  i16 iCol          /* The column that is wanted */\n){\n  Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0);\n  if( pExpr ){\n    pExpr->pTab = pTab;\n    pExpr->iTable = iCursor;\n    pExpr->iColumn = iCol;\n  }\n  return pExpr;\n}\n\n/*\n** This function is called to generate code executed when a row is deleted\n** from the parent table of foreign key constraint pFKey and, if pFKey is \n** deferred, when a row is inserted into the same table. When generating\n** code for an SQL UPDATE operation, this function may be called twice -\n** once to \"delete\" the old row and once to \"insert\" the new row.\n**\n** Parameter nIncr is passed -1 when inserting a row (as this may decrease\n** the number of FK violations in the db) or +1 when deleting one (as this\n** may increase the number of FK constraint problems).\n**\n** The code generated by this function scans through the rows in the child\n** table that correspond to the parent table row being deleted or inserted.\n** For each child row found, one of the following actions is taken:\n**\n**   Operation | FK type   | Action taken\n**   --------------------------------------------------------------------------\n**   DELETE      immediate   Increment the \"immediate constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      immediate   Decrement the \"immediate constraint counter\".\n**\n**   DELETE      deferred    Increment the \"deferred constraint counter\".\n**                           Or, if the ON (UPDATE|DELETE) action is RESTRICT,\n**                           throw a \"FOREIGN KEY constraint failed\" exception.\n**\n**   INSERT      deferred    Decrement the \"deferred constraint counter\".\n**\n** These operations are identified in the comment at the top of this file \n** (fkey.c) as \"I.2\" and \"D.2\".\n*/\nstatic void fkScanChildren(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pSrc,                  /* The child table to be scanned */\n  Table *pTab,                    /* The parent table */\n  Index *pIdx,                    /* Index on parent covering the foreign key */\n  FKey *pFKey,                    /* The foreign key linking pSrc to pTab */\n  int *aiCol,                     /* Map from pIdx cols to child table cols */\n  int regData,                    /* Parent row data starts here */\n  int nIncr                       /* Amount to increment deferred counter by */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int i;                          /* Iterator variable */\n  Expr *pWhere = 0;               /* WHERE clause to scan with */\n  NameContext sNameContext;       /* Context used to resolve WHERE clause */\n  WhereInfo *pWInfo;              /* Context used by sqlite3WhereXXX() */\n  int iFkIfZero = 0;              /* Address of OP_FkIfZero */\n  Vdbe *v = sqlite3GetVdbe(pParse);\n\n  assert( pIdx==0 || pIdx->pTable==pTab );\n  assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol );\n  assert( pIdx!=0 || pFKey->nCol==1 );\n  assert( pIdx!=0 || HasRowid(pTab) );\n\n  if( nIncr<0 ){\n    iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0);\n    VdbeCoverage(v);\n  }\n\n  /* Create an Expr object representing an SQL expression like:\n  **\n  **   <parent-key1> = <child-key1> AND <parent-key2> = <child-key2> ...\n  **\n  ** The collation sequence used for the comparison should be that of\n  ** the parent key columns. The affinity of the parent key column should\n  ** be applied to each child key value before the comparison takes place.\n  */\n  for(i=0; i<pFKey->nCol; i++){\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    Expr *pEq;                    /* Expression (pLeft = pRight) */\n    i16 iCol;                     /* Index of column in child table */ \n    const char *zCol;             /* Name of column in child table */\n\n    iCol = pIdx ? pIdx->aiColumn[i] : -1;\n    pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n    iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n    assert( iCol>=0 );\n    zCol = pFKey->pFrom->aCol[iCol].zName;\n    pRight = sqlite3Expr(db, TK_ID, zCol);\n    pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);\n    pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n  }\n\n  /* If the child table is the same as the parent table, then add terms\n  ** to the WHERE clause that prevent this entry from being scanned.\n  ** The added WHERE clause terms are like this:\n  **\n  **     $current_rowid!=rowid\n  **     NOT( $current_a==a AND $current_b==b AND ... )\n  **\n  ** The first form is used for rowid tables.  The second form is used\n  ** for WITHOUT ROWID tables.  In the second form, the primary key is\n  ** (a,b,...)\n  */\n  if( pTab==pFKey->pFrom && nIncr>0 ){\n    Expr *pNe;                    /* Expression (pLeft != pRight) */\n    Expr *pLeft;                  /* Value from parent table row */\n    Expr *pRight;                 /* Column ref to child table */\n    if( HasRowid(pTab) ){\n      pLeft = exprTableRegister(pParse, pTab, regData, -1);\n      pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, -1);\n      pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight);\n    }else{\n      Expr *pEq, *pAll = 0;\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      assert( pIdx!=0 );\n      for(i=0; i<pPk->nKeyCol; i++){\n        i16 iCol = pIdx->aiColumn[i];\n        assert( iCol>=0 );\n        pLeft = exprTableRegister(pParse, pTab, regData, iCol);\n        pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, iCol);\n        pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);\n        pAll = sqlite3ExprAnd(db, pAll, pEq);\n      }\n      pNe = sqlite3PExpr(pParse, TK_NOT, pAll, 0);\n    }\n    pWhere = sqlite3ExprAnd(db, pWhere, pNe);\n  }\n\n  /* Resolve the references in the WHERE clause. */\n  memset(&sNameContext, 0, sizeof(NameContext));\n  sNameContext.pSrcList = pSrc;\n  sNameContext.pParse = pParse;\n  sqlite3ResolveExprNames(&sNameContext, pWhere);\n\n  /* Create VDBE to loop through the entries in pSrc that match the WHERE\n  ** clause. For each row found, increment either the deferred or immediate\n  ** foreign key constraint counter. */\n  if( pParse->nErr==0 ){\n    pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);\n    sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);\n    if( pWInfo ){\n      sqlite3WhereEnd(pWInfo);\n    }\n  }\n\n  /* Clean up the WHERE clause constructed above. */\n  sqlite3ExprDelete(db, pWhere);\n  if( iFkIfZero ){\n    sqlite3VdbeJumpHere(v, iFkIfZero);\n  }\n}\n\n/*\n** This function returns a linked list of FKey objects (connected by\n** FKey.pNextTo) holding all children of table pTab.  For example,\n** given the following schema:\n**\n**   CREATE TABLE t1(a PRIMARY KEY);\n**   CREATE TABLE t2(b REFERENCES t1(a);\n**\n** Calling this function with table \"t1\" as an argument returns a pointer\n** to the FKey structure representing the foreign key constraint on table\n** \"t2\". Calling this function with \"t2\" as the argument would return a\n** NULL pointer (as there are no FK constraints for which t2 is the parent\n** table).\n*/\nFKey *sqlite3FkReferences(Table *pTab){\n  return (FKey *)sqlite3HashFind(&pTab->pSchema->fkeyHash, pTab->zName);\n}\n\n/*\n** The second argument is a Trigger structure allocated by the \n** fkActionTrigger() routine. This function deletes the Trigger structure\n** and all of its sub-components.\n**\n** The Trigger structure or any of its sub-components may be allocated from\n** the lookaside buffer belonging to database handle dbMem.\n*/\nstatic void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){\n  if( p ){\n    TriggerStep *pStep = p->step_list;\n    sqlite3ExprDelete(dbMem, pStep->pWhere);\n    sqlite3ExprListDelete(dbMem, pStep->pExprList);\n    sqlite3SelectDelete(dbMem, pStep->pSelect);\n    sqlite3ExprDelete(dbMem, p->pWhen);\n    sqlite3DbFree(dbMem, p);\n  }\n}\n\n/*\n** This function is called to generate code that runs when table pTab is\n** being dropped from the database. The SrcList passed as the second argument\n** to this function contains a single entry guaranteed to resolve to\n** table pTab.\n**\n** Normally, no code is required. However, if either\n**\n**   (a) The table is the parent table of a FK constraint, or\n**   (b) The table is the child table of a deferred FK constraint and it is\n**       determined at runtime that there are outstanding deferred FK \n**       constraint violations in the database,\n**\n** then the equivalent of \"DELETE FROM <tbl>\" is executed before dropping\n** the table from the database. Triggers are disabled while running this\n** DELETE, but foreign key actions are not.\n*/\nvoid sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){\n  sqlite3 *db = pParse->db;\n  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){\n    int iSkip = 0;\n    Vdbe *v = sqlite3GetVdbe(pParse);\n\n    assert( v );                  /* VDBE has already been allocated */\n    if( sqlite3FkReferences(pTab)==0 ){\n      /* Search for a deferred foreign key constraint for which this table\n      ** is the child table. If one cannot be found, return without \n      ** generating any VDBE code. If one can be found, then jump over\n      ** the entire DELETE if there are no outstanding deferred constraints\n      ** when this statement is run.  */\n      FKey *p;\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;\n      }\n      if( !p ) return;\n      iSkip = sqlite3VdbeMakeLabel(v);\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);\n    }\n\n    pParse->disableTriggers = 1;\n    sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);\n    pParse->disableTriggers = 0;\n\n    /* If the DELETE has generated immediate foreign key constraint \n    ** violations, halt the VDBE and return an error at this point, before\n    ** any modifications to the schema are made. This is because statement\n    ** transactions are not able to rollback schema changes.  \n    **\n    ** If the SQLITE_DeferFKs flag is set, then this is not required, as\n    ** the statement transaction will not be rolled back even if FK\n    ** constraints are violated.\n    */\n    if( (db->flags & SQLITE_DeferFKs)==0 ){\n      sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n      sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,\n          OE_Abort, 0, P4_STATIC, P5_ConstraintFK);\n    }\n\n    if( iSkip ){\n      sqlite3VdbeResolveLabel(v, iSkip);\n    }\n  }\n}\n\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the child table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** child key for FK constraint *p are modified.\n*/\nstatic int fkChildIsModified(\n  Table *pTab,                    /* Table being updated */\n  FKey *p,                        /* Foreign key for which pTab is the child */\n  int *aChange,                   /* Array indicating modified columns */\n  int bChngRowid                  /* True if rowid is modified by this update */\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    int iChildKey = p->aCol[i].iFrom;\n    if( aChange[iChildKey]>=0 ) return 1;\n    if( iChildKey==pTab->iPKey && bChngRowid ) return 1;\n  }\n  return 0;\n}\n\n/*\n** The second argument points to an FKey object representing a foreign key\n** for which pTab is the parent table. An UPDATE statement against pTab\n** is currently being processed. For each column of the table that is \n** actually updated, the corresponding element in the aChange[] array\n** is zero or greater (if a column is unmodified the corresponding element\n** is set to -1). If the rowid column is modified by the UPDATE statement\n** the bChngRowid argument is non-zero.\n**\n** This function returns true if any of the columns that are part of the\n** parent key for FK constraint *p are modified.\n*/\nstatic int fkParentIsModified(\n  Table *pTab, \n  FKey *p, \n  int *aChange, \n  int bChngRowid\n){\n  int i;\n  for(i=0; i<p->nCol; i++){\n    char *zKey = p->aCol[i].zCol;\n    int iKey;\n    for(iKey=0; iKey<pTab->nCol; iKey++){\n      if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){\n        Column *pCol = &pTab->aCol[iKey];\n        if( zKey ){\n          if( 0==sqlite3StrICmp(pCol->zName, zKey) ) return 1;\n        }else if( pCol->colFlags & COLFLAG_PRIMKEY ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Return true if the parser passed as the first argument is being\n** used to code a trigger that is really a \"SET NULL\" action belonging\n** to trigger pFKey.\n*/\nstatic int isSetNullAction(Parse *pParse, FKey *pFKey){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  if( pTop->pTriggerPrg ){\n    Trigger *p = pTop->pTriggerPrg->pTrigger;\n    if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull)\n     || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull)\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is called when inserting, deleting or updating a row of\n** table pTab to generate VDBE code to perform foreign key constraint \n** processing for the operation.\n**\n** For a DELETE operation, parameter regOld is passed the index of the\n** first register in an array of (pTab->nCol+1) registers containing the\n** rowid of the row being deleted, followed by each of the column values\n** of the row being deleted, from left to right. Parameter regNew is passed\n** zero in this case.\n**\n** For an INSERT operation, regOld is passed zero and regNew is passed the\n** first register of an array of (pTab->nCol+1) registers containing the new\n** row data.\n**\n** For an UPDATE operation, this function is called twice. Once before\n** the original record is deleted from the table using the calling convention\n** described for DELETE. Then again after the original record is deleted\n** but before the new record is inserted using the INSERT convention. \n*/\nvoid sqlite3FkCheck(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Row is being deleted from this table */ \n  int regOld,                     /* Previous row data is stored here */\n  int regNew,                     /* New row data is stored here */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  FKey *pFKey;                    /* Used to iterate through FKs */\n  int iDb;                        /* Index of database containing pTab */\n  const char *zDb;                /* Name of database containing pTab */\n  int isIgnoreErrors = pParse->disableTriggers;\n\n  /* Exactly one of regOld and regNew should be non-zero. */\n  assert( (regOld==0)!=(regNew==0) );\n\n  /* If foreign-keys are disabled, this function is a no-op. */\n  if( (db->flags&SQLITE_ForeignKeys)==0 ) return;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  zDb = db->aDb[iDb].zDbSName;\n\n  /* Loop through all the foreign key constraints for which pTab is the\n  ** child table (the table that the foreign key definition is part of).  */\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n    Table *pTo;                   /* Parent table of foreign key pFKey */\n    Index *pIdx = 0;              /* Index on key columns in pTo */\n    int *aiFree = 0;\n    int *aiCol;\n    int iCol;\n    int i;\n    int bIgnore = 0;\n\n    if( aChange \n     && sqlite3_stricmp(pTab->zName, pFKey->zTo)!=0\n     && fkChildIsModified(pTab, pFKey, aChange, bChngRowid)==0 \n    ){\n      continue;\n    }\n\n    /* Find the parent table of this foreign key. Also find a unique index \n    ** on the parent key columns in the parent table. If either of these \n    ** schema items cannot be located, set an error in pParse and return \n    ** early.  */\n    if( pParse->disableTriggers ){\n      pTo = sqlite3FindTable(db, pFKey->zTo, zDb);\n    }else{\n      pTo = sqlite3LocateTable(pParse, 0, pFKey->zTo, zDb);\n    }\n    if( !pTo || sqlite3FkLocateIndex(pParse, pTo, pFKey, &pIdx, &aiFree) ){\n      assert( isIgnoreErrors==0 || (regOld!=0 && regNew==0) );\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      if( pTo==0 ){\n        /* If isIgnoreErrors is true, then a table is being dropped. In this\n        ** case SQLite runs a \"DELETE FROM xxx\" on the table being dropped\n        ** before actually dropping it in order to check FK constraints.\n        ** If the parent table of an FK constraint on the current table is\n        ** missing, behave as if it is empty. i.e. decrement the relevant\n        ** FK counter for each row of the current table with non-NULL keys.\n        */\n        Vdbe *v = sqlite3GetVdbe(pParse);\n        int iJump = sqlite3VdbeCurrentAddr(v) + pFKey->nCol + 1;\n        for(i=0; i<pFKey->nCol; i++){\n          int iReg = pFKey->aCol[i].iFrom + regOld + 1;\n          sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iJump); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, -1);\n      }\n      continue;\n    }\n    assert( pFKey->nCol==1 || (aiFree && pIdx) );\n\n    if( aiFree ){\n      aiCol = aiFree;\n    }else{\n      iCol = pFKey->aCol[0].iFrom;\n      aiCol = &iCol;\n    }\n    for(i=0; i<pFKey->nCol; i++){\n      if( aiCol[i]==pTab->iPKey ){\n        aiCol[i] = -1;\n      }\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      /* Request permission to read the parent key columns. If the \n      ** authorization callback returns SQLITE_IGNORE, behave as if any\n      ** values read from the parent table are NULL. */\n      if( db->xAuth ){\n        int rcauth;\n        char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;\n        rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);\n        bIgnore = (rcauth==SQLITE_IGNORE);\n      }\n#endif\n    }\n\n    /* Take a shared-cache advisory read-lock on the parent table. Allocate \n    ** a cursor to use to search the unique index on the parent key columns \n    ** in the parent table.  */\n    sqlite3TableLock(pParse, iDb, pTo->tnum, 0, pTo->zName);\n    pParse->nTab++;\n\n    if( regOld!=0 ){\n      /* A row is being removed from the child table. Search for the parent.\n      ** If the parent does not exist, removing the child row resolves an \n      ** outstanding foreign key constraint violation. */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);\n    }\n    if( regNew!=0 && !isSetNullAction(pParse, pFKey) ){\n      /* A row is being added to the child table. If a parent row cannot\n      ** be found, adding the child row has violated the FK constraint. \n      **\n      ** If this operation is being performed as part of a trigger program\n      ** that is actually a \"SET NULL\" action belonging to this very \n      ** foreign key, then omit this scan altogether. As all child key\n      ** values are guaranteed to be NULL, it is not possible for adding\n      ** this row to cause an FK violation.  */\n      fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);\n    }\n\n    sqlite3DbFree(db, aiFree);\n  }\n\n  /* Loop through all the foreign key constraints that refer to this table.\n  ** (the \"child\" constraints) */\n  for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n    Index *pIdx = 0;              /* Foreign key index for pFKey */\n    SrcList *pSrc;\n    int *aiCol = 0;\n\n    if( aChange && fkParentIsModified(pTab, pFKey, aChange, bChngRowid)==0 ){\n      continue;\n    }\n\n    if( !pFKey->isDeferred && !(db->flags & SQLITE_DeferFKs) \n     && !pParse->pToplevel && !pParse->isMultiWrite \n    ){\n      assert( regOld==0 && regNew!=0 );\n      /* Inserting a single row into a parent table cannot cause (or fix)\n      ** an immediate foreign key violation. So do nothing in this case.  */\n      continue;\n    }\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ){\n      if( !isIgnoreErrors || db->mallocFailed ) return;\n      continue;\n    }\n    assert( aiCol || pFKey->nCol==1 );\n\n    /* Create a SrcList structure containing the child table.  We need the\n    ** child table as a SrcList for sqlite3WhereBegin() */\n    pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n    if( pSrc ){\n      struct SrcList_item *pItem = pSrc->a;\n      pItem->pTab = pFKey->pFrom;\n      pItem->zName = pFKey->pFrom->zName;\n      pItem->pTab->nTabRef++;\n      pItem->iCursor = pParse->nTab++;\n  \n      if( regNew!=0 ){\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);\n      }\n      if( regOld!=0 ){\n        int eAction = pFKey->aAction[aChange!=0];\n        fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);\n        /* If this is a deferred FK constraint, or a CASCADE or SET NULL\n        ** action applies, then any foreign key violations caused by\n        ** removing the parent key will be rectified by the action trigger.\n        ** So do not set the \"may-abort\" flag in this case.\n        **\n        ** Note 1: If the FK is declared \"ON UPDATE CASCADE\", then the\n        ** may-abort flag will eventually be set on this statement anyway\n        ** (when this function is called as part of processing the UPDATE\n        ** within the action trigger).\n        **\n        ** Note 2: At first glance it may seem like SQLite could simply omit\n        ** all OP_FkCounter related scans when either CASCADE or SET NULL\n        ** applies. The trouble starts if the CASCADE or SET NULL action \n        ** trigger causes other triggers or action rules attached to the \n        ** child table to fire. In these cases the fk constraint counters\n        ** might be set incorrectly if any OP_FkCounter related scans are \n        ** omitted.  */\n        if( !pFKey->isDeferred && eAction!=OE_Cascade && eAction!=OE_SetNull ){\n          sqlite3MayAbort(pParse);\n        }\n      }\n      pItem->zName = 0;\n      sqlite3SrcListDelete(db, pSrc);\n    }\n    sqlite3DbFree(db, aiCol);\n  }\n}\n\n#define COLUMN_MASK(x) (((x)>31) ? 0xffffffff : ((u32)1<<(x)))\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab.\n*/\nu32 sqlite3FkOldmask(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab                     /* Table being modified */\n){\n  u32 mask = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *p;\n    int i;\n    for(p=pTab->pFKey; p; p=p->pNextFrom){\n      for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom);\n    }\n    for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n      Index *pIdx = 0;\n      sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0);\n      if( pIdx ){\n        for(i=0; i<pIdx->nKeyCol; i++){\n          assert( pIdx->aiColumn[i]>=0 );\n          mask |= COLUMN_MASK(pIdx->aiColumn[i]);\n        }\n      }\n    }\n  }\n  return mask;\n}\n\n\n/*\n** This function is called before generating code to update or delete a \n** row contained in table pTab. If the operation is a DELETE, then\n** parameter aChange is passed a NULL value. For an UPDATE, aChange points\n** to an array of size N, where N is the number of columns in table pTab.\n** If the i'th column is not modified by the UPDATE, then the corresponding \n** entry in the aChange[] array is set to -1. If the column is modified,\n** the value is 0 or greater. Parameter chngRowid is set to true if the\n** UPDATE statement modifies the rowid fields of the table.\n**\n** If any foreign key processing will be required, this function returns\n** non-zero. If there is no foreign key related processing, this function \n** returns zero.\n**\n** For an UPDATE, this function returns 2 if:\n**\n**   * There are any FKs for which pTab is the child and the parent table, or\n**   * the UPDATE modifies one or more parent keys for which the action is\n**     not \"NO ACTION\" (i.e. is CASCADE, SET DEFAULT or SET NULL).\n**\n** Or, assuming some other foreign key processing is required, 1.\n*/\nint sqlite3FkRequired(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being modified */\n  int *aChange,                   /* Non-NULL for UPDATE operations */\n  int chngRowid                   /* True for UPDATE that affects rowid */\n){\n  int eRet = 0;\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    if( !aChange ){\n      /* A DELETE operation. Foreign key processing is required if the \n      ** table in question is either the child or parent table for any \n      ** foreign key constraint.  */\n      eRet = (sqlite3FkReferences(pTab) || pTab->pFKey);\n    }else{\n      /* This is an UPDATE. Foreign key processing is only required if the\n      ** operation modifies one or more child or parent key columns. */\n      FKey *p;\n\n      /* Check if any child key columns are being modified. */\n      for(p=pTab->pFKey; p; p=p->pNextFrom){\n        if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2;\n        if( fkChildIsModified(pTab, p, aChange, chngRowid) ){\n          eRet = 1;\n        }\n      }\n\n      /* Check if any parent key columns are being modified. */\n      for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){\n        if( fkParentIsModified(pTab, p, aChange, chngRowid) ){\n          if( p->aAction[1]!=OE_None ) return 2;\n          eRet = 1;\n        }\n      }\n    }\n  }\n  return eRet;\n}\n\n/*\n** This function is called when an UPDATE or DELETE operation is being \n** compiled on table pTab, which is the parent table of foreign-key pFKey.\n** If the current operation is an UPDATE, then the pChanges parameter is\n** passed a pointer to the list of columns being modified. If it is a\n** DELETE, pChanges is passed a NULL pointer.\n**\n** It returns a pointer to a Trigger structure containing a trigger\n** equivalent to the ON UPDATE or ON DELETE action specified by pFKey.\n** If the action is \"NO ACTION\" or \"RESTRICT\", then a NULL pointer is\n** returned (these actions require no special handling by the triggers\n** sub-system, code for them is created by fkScanChildren()).\n**\n** For example, if pFKey is the foreign key and pTab is table \"p\" in \n** the following schema:\n**\n**   CREATE TABLE p(pk PRIMARY KEY);\n**   CREATE TABLE c(ck REFERENCES p ON DELETE CASCADE);\n**\n** then the returned trigger structure is equivalent to:\n**\n**   CREATE TRIGGER ... DELETE ON p BEGIN\n**     DELETE FROM c WHERE ck = old.pk;\n**   END;\n**\n** The returned pointer is cached as part of the foreign key object. It\n** is eventually freed along with the rest of the foreign key object by \n** sqlite3FkDelete().\n*/\nstatic Trigger *fkActionTrigger(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  FKey *pFKey,                    /* Foreign key to get action for */\n  ExprList *pChanges              /* Change-list for UPDATE, NULL for DELETE */\n){\n  sqlite3 *db = pParse->db;       /* Database handle */\n  int action;                     /* One of OE_None, OE_Cascade etc. */\n  Trigger *pTrigger;              /* Trigger definition to return */\n  int iAction = (pChanges!=0);    /* 1 for UPDATE, 0 for DELETE */\n\n  action = pFKey->aAction[iAction];\n  if( action==OE_Restrict && (db->flags & SQLITE_DeferFKs) ){\n    return 0;\n  }\n  pTrigger = pFKey->apTrigger[iAction];\n\n  if( action!=OE_None && !pTrigger ){\n    char const *zFrom;            /* Name of child table */\n    int nFrom;                    /* Length in bytes of zFrom */\n    Index *pIdx = 0;              /* Parent key index for this FK */\n    int *aiCol = 0;               /* child table cols -> parent key cols */\n    TriggerStep *pStep = 0;        /* First (only) step of trigger program */\n    Expr *pWhere = 0;             /* WHERE clause of trigger step */\n    ExprList *pList = 0;          /* Changes list if ON UPDATE CASCADE */\n    Select *pSelect = 0;          /* If RESTRICT, \"SELECT RAISE(...)\" */\n    int i;                        /* Iterator variable */\n    Expr *pWhen = 0;              /* WHEN clause for the trigger */\n\n    if( sqlite3FkLocateIndex(pParse, pTab, pFKey, &pIdx, &aiCol) ) return 0;\n    assert( aiCol || pFKey->nCol==1 );\n\n    for(i=0; i<pFKey->nCol; i++){\n      Token tOld = { \"old\", 3 };  /* Literal \"old\" token */\n      Token tNew = { \"new\", 3 };  /* Literal \"new\" token */\n      Token tFromCol;             /* Name of column in child table */\n      Token tToCol;               /* Name of column in parent table */\n      int iFromCol;               /* Idx of column in child table */\n      Expr *pEq;                  /* tFromCol = OLD.tToCol */\n\n      iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;\n      assert( iFromCol>=0 );\n      assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );\n      assert( pIdx==0 || pIdx->aiColumn[i]>=0 );\n      sqlite3TokenInit(&tToCol,\n                   pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName);\n      sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zName);\n\n      /* Create the expression \"OLD.zToCol = zFromCol\". It is important\n      ** that the \"OLD.zToCol\" term is on the LHS of the = operator, so\n      ** that the affinity and collation sequence associated with the\n      ** parent table are used for the comparison. */\n      pEq = sqlite3PExpr(pParse, TK_EQ,\n          sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n          sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0)\n      );\n      pWhere = sqlite3ExprAnd(db, pWhere, pEq);\n\n      /* For ON UPDATE, construct the next term of the WHEN clause.\n      ** The final WHEN clause will be like this:\n      **\n      **    WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)\n      */\n      if( pChanges ){\n        pEq = sqlite3PExpr(pParse, TK_IS,\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tOld, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)),\n            sqlite3PExpr(pParse, TK_DOT, \n              sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n              sqlite3ExprAlloc(db, TK_ID, &tToCol, 0))\n            );\n        pWhen = sqlite3ExprAnd(db, pWhen, pEq);\n      }\n  \n      if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){\n        Expr *pNew;\n        if( action==OE_Cascade ){\n          pNew = sqlite3PExpr(pParse, TK_DOT, \n            sqlite3ExprAlloc(db, TK_ID, &tNew, 0),\n            sqlite3ExprAlloc(db, TK_ID, &tToCol, 0));\n        }else if( action==OE_SetDflt ){\n          Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;\n          if( pDflt ){\n            pNew = sqlite3ExprDup(db, pDflt, 0);\n          }else{\n            pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n          }\n        }else{\n          pNew = sqlite3ExprAlloc(db, TK_NULL, 0, 0);\n        }\n        pList = sqlite3ExprListAppend(pParse, pList, pNew);\n        sqlite3ExprListSetName(pParse, pList, &tFromCol, 0);\n      }\n    }\n    sqlite3DbFree(db, aiCol);\n\n    zFrom = pFKey->pFrom->zName;\n    nFrom = sqlite3Strlen30(zFrom);\n\n    if( action==OE_Restrict ){\n      Token tFrom;\n      Expr *pRaise; \n\n      tFrom.z = zFrom;\n      tFrom.n = nFrom;\n      pRaise = sqlite3Expr(db, TK_RAISE, \"FOREIGN KEY constraint failed\");\n      if( pRaise ){\n        pRaise->affinity = OE_Abort;\n      }\n      pSelect = sqlite3SelectNew(pParse, \n          sqlite3ExprListAppend(pParse, 0, pRaise),\n          sqlite3SrcListAppend(db, 0, &tFrom, 0),\n          pWhere,\n          0, 0, 0, 0, 0, 0\n      );\n      pWhere = 0;\n    }\n\n    /* Disable lookaside memory allocation */\n    db->lookaside.bDisable++;\n\n    pTrigger = (Trigger *)sqlite3DbMallocZero(db, \n        sizeof(Trigger) +         /* struct Trigger */\n        sizeof(TriggerStep) +     /* Single step in trigger program */\n        nFrom + 1                 /* Space for pStep->zTarget */\n    );\n    if( pTrigger ){\n      pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];\n      pStep->zTarget = (char *)&pStep[1];\n      memcpy((char *)pStep->zTarget, zFrom, nFrom);\n  \n      pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n      pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);\n      pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n      if( pWhen ){\n        pWhen = sqlite3PExpr(pParse, TK_NOT, pWhen, 0);\n        pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n      }\n    }\n\n    /* Re-enable the lookaside buffer, if it was disabled earlier. */\n    db->lookaside.bDisable--;\n\n    sqlite3ExprDelete(db, pWhere);\n    sqlite3ExprDelete(db, pWhen);\n    sqlite3ExprListDelete(db, pList);\n    sqlite3SelectDelete(db, pSelect);\n    if( db->mallocFailed==1 ){\n      fkTriggerDelete(db, pTrigger);\n      return 0;\n    }\n    assert( pStep!=0 );\n\n    switch( action ){\n      case OE_Restrict:\n        pStep->op = TK_SELECT; \n        break;\n      case OE_Cascade: \n        if( !pChanges ){ \n          pStep->op = TK_DELETE; \n          break; \n        }\n      default:\n        pStep->op = TK_UPDATE;\n    }\n    pStep->pTrig = pTrigger;\n    pTrigger->pSchema = pTab->pSchema;\n    pTrigger->pTabSchema = pTab->pSchema;\n    pFKey->apTrigger[iAction] = pTrigger;\n    pTrigger->op = (pChanges ? TK_UPDATE : TK_DELETE);\n  }\n\n  return pTrigger;\n}\n\n/*\n** This function is called when deleting or updating a row to implement\n** any required CASCADE, SET NULL or SET DEFAULT actions.\n*/\nvoid sqlite3FkActions(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being updated or deleted from */\n  ExprList *pChanges,             /* Change-list for UPDATE, NULL for DELETE */\n  int regOld,                     /* Address of array containing old row */\n  int *aChange,                   /* Array indicating UPDATEd columns (or 0) */\n  int bChngRowid                  /* True if rowid is UPDATEd */\n){\n  /* If foreign-key support is enabled, iterate through all FKs that \n  ** refer to table pTab. If there is an action associated with the FK \n  ** for this operation (either update or delete), invoke the associated \n  ** trigger sub-program.  */\n  if( pParse->db->flags&SQLITE_ForeignKeys ){\n    FKey *pFKey;                  /* Iterator variable */\n    for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){\n      if( aChange==0 || fkParentIsModified(pTab, pFKey, aChange, bChngRowid) ){\n        Trigger *pAct = fkActionTrigger(pParse, pTab, pFKey, pChanges);\n        if( pAct ){\n          sqlite3CodeRowTriggerDirect(pParse, pAct, pTab, regOld, OE_Abort, 0);\n        }\n      }\n    }\n  }\n}\n\n#endif /* ifndef SQLITE_OMIT_TRIGGER */\n\n/*\n** Free all memory associated with foreign key definitions attached to\n** table pTab. Remove the deleted foreign keys from the Schema.fkeyHash\n** hash table.\n*/\nvoid sqlite3FkDelete(sqlite3 *db, Table *pTab){\n  FKey *pFKey;                    /* Iterator variable */\n  FKey *pNext;                    /* Copy of pFKey->pNextFrom */\n\n  assert( db==0 || IsVirtual(pTab)\n         || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) );\n  for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){\n\n    /* Remove the FK from the fkeyHash hash table. */\n    if( !db || db->pnBytesFreed==0 ){\n      if( pFKey->pPrevTo ){\n        pFKey->pPrevTo->pNextTo = pFKey->pNextTo;\n      }else{\n        void *p = (void *)pFKey->pNextTo;\n        const char *z = (p ? pFKey->pNextTo->zTo : pFKey->zTo);\n        sqlite3HashInsert(&pTab->pSchema->fkeyHash, z, p);\n      }\n      if( pFKey->pNextTo ){\n        pFKey->pNextTo->pPrevTo = pFKey->pPrevTo;\n      }\n    }\n\n    /* EV: R-30323-21917 Each foreign key constraint in SQLite is\n    ** classified as either immediate or deferred.\n    */\n    assert( pFKey->isDeferred==0 || pFKey->isDeferred==1 );\n\n    /* Delete any triggers created to implement actions for this FK. */\n#ifndef SQLITE_OMIT_TRIGGER\n    fkTriggerDelete(db, pFKey->apTrigger[0]);\n    fkTriggerDelete(db, pFKey->apTrigger[1]);\n#endif\n\n    pNext = pFKey->pNextFrom;\n    sqlite3DbFree(db, pFKey);\n  }\n}\n#endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/func.c",
    "content": "/*\n** 2002 February 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C-language implementations for many of the SQL\n** functions of SQLite.  (Some function, and in particular the date and\n** time functions, are implemented separately.)\n*/\n#include \"sqliteInt.h\"\n#include <stdlib.h>\n#include <assert.h>\n#include \"vdbeInt.h\"\n\n/*\n** Return the collating function associated with a function.\n*/\nstatic CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){\n  VdbeOp *pOp;\n  assert( context->pVdbe!=0 );\n  pOp = &context->pVdbe->aOp[context->iOp-1];\n  assert( pOp->opcode==OP_CollSeq );\n  assert( pOp->p4type==P4_COLLSEQ );\n  return pOp->p4.pColl;\n}\n\n/*\n** Indicate that the accumulator load should be skipped on this\n** iteration of the aggregate loop.\n*/\nstatic void sqlite3SkipAccumulatorLoad(sqlite3_context *context){\n  context->skipFlag = 1;\n}\n\n/*\n** Implementation of the non-aggregate min() and max() functions\n*/\nstatic void minmaxFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  int mask;    /* 0 for min() or 0xffffffff for max() */\n  int iBest;\n  CollSeq *pColl;\n\n  assert( argc>1 );\n  mask = sqlite3_user_data(context)==0 ? 0 : -1;\n  pColl = sqlite3GetFuncCollSeq(context);\n  assert( pColl );\n  assert( mask==-1 || mask==0 );\n  iBest = 0;\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  for(i=1; i<argc; i++){\n    if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;\n    if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){\n      testcase( mask==0 );\n      iBest = i;\n    }\n  }\n  sqlite3_result_value(context, argv[iBest]);\n}\n\n/*\n** Return the type of the argument.\n*/\nstatic void typeofFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  static const char *azType[] = { \"integer\", \"real\", \"text\", \"blob\", \"null\" };\n  int i = sqlite3_value_type(argv[0]) - 1;\n  UNUSED_PARAMETER(NotUsed);\n  assert( i>=0 && i<ArraySize(azType) );\n  assert( SQLITE_INTEGER==1 );\n  assert( SQLITE_FLOAT==2 );\n  assert( SQLITE_TEXT==3 );\n  assert( SQLITE_BLOB==4 );\n  assert( SQLITE_NULL==5 );\n  /* EVIDENCE-OF: R-01470-60482 The sqlite3_value_type(V) interface returns\n  ** the datatype code for the initial datatype of the sqlite3_value object\n  ** V. The returned value is one of SQLITE_INTEGER, SQLITE_FLOAT,\n  ** SQLITE_TEXT, SQLITE_BLOB, or SQLITE_NULL. */\n  sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);\n}\n\n\n/*\n** Implementation of the length() function\n*/\nstatic void lengthFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int len;\n\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_BLOB:\n    case SQLITE_INTEGER:\n    case SQLITE_FLOAT: {\n      sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));\n      break;\n    }\n    case SQLITE_TEXT: {\n      const unsigned char *z = sqlite3_value_text(argv[0]);\n      if( z==0 ) return;\n      len = 0;\n      while( *z ){\n        len++;\n        SQLITE_SKIP_UTF8(z);\n      }\n      sqlite3_result_int(context, len);\n      break;\n    }\n    default: {\n      sqlite3_result_null(context);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the abs() function.\n**\n** IMP: R-23979-26855 The abs(X) function returns the absolute value of\n** the numeric argument X. \n*/\nstatic void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_INTEGER: {\n      i64 iVal = sqlite3_value_int64(argv[0]);\n      if( iVal<0 ){\n        if( iVal==SMALLEST_INT64 ){\n          /* IMP: R-31676-45509 If X is the integer -9223372036854775808\n          ** then abs(X) throws an integer overflow error since there is no\n          ** equivalent positive 64-bit two complement value. */\n          sqlite3_result_error(context, \"integer overflow\", -1);\n          return;\n        }\n        iVal = -iVal;\n      } \n      sqlite3_result_int64(context, iVal);\n      break;\n    }\n    case SQLITE_NULL: {\n      /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */\n      sqlite3_result_null(context);\n      break;\n    }\n    default: {\n      /* Because sqlite3_value_double() returns 0.0 if the argument is not\n      ** something that can be converted into a number, we have:\n      ** IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob\n      ** that cannot be converted to a numeric value.\n      */\n      double rVal = sqlite3_value_double(argv[0]);\n      if( rVal<0 ) rVal = -rVal;\n      sqlite3_result_double(context, rVal);\n      break;\n    }\n  }\n}\n\n/*\n** Implementation of the instr() function.\n**\n** instr(haystack,needle) finds the first occurrence of needle\n** in haystack and returns the number of previous characters plus 1,\n** or 0 if needle does not occur within haystack.\n**\n** If both haystack and needle are BLOBs, then the result is one more than\n** the number of bytes in haystack prior to the first occurrence of needle,\n** or 0 if needle never occurs in haystack.\n*/\nstatic void instrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zHaystack;\n  const unsigned char *zNeedle;\n  int nHaystack;\n  int nNeedle;\n  int typeHaystack, typeNeedle;\n  int N = 1;\n  int isText;\n\n  UNUSED_PARAMETER(argc);\n  typeHaystack = sqlite3_value_type(argv[0]);\n  typeNeedle = sqlite3_value_type(argv[1]);\n  if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;\n  nHaystack = sqlite3_value_bytes(argv[0]);\n  nNeedle = sqlite3_value_bytes(argv[1]);\n  if( nNeedle>0 ){\n    if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){\n      zHaystack = sqlite3_value_blob(argv[0]);\n      zNeedle = sqlite3_value_blob(argv[1]);\n      isText = 0;\n    }else{\n      zHaystack = sqlite3_value_text(argv[0]);\n      zNeedle = sqlite3_value_text(argv[1]);\n      isText = 1;\n    }\n    if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;\n    while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){\n      N++;\n      do{\n        nHaystack--;\n        zHaystack++;\n      }while( isText && (zHaystack[0]&0xc0)==0x80 );\n    }\n    if( nNeedle>nHaystack ) N = 0;\n  }\n  sqlite3_result_int(context, N);\n}\n\n/*\n** Implementation of the printf() function.\n*/\nstatic void printfFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  PrintfArguments x;\n  StrAccum str;\n  const char *zFormat;\n  int n;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n\n  if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    x.nArg = argc-1;\n    x.nUsed = 0;\n    x.apArg = argv+1;\n    sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);\n    str.printfFlags = SQLITE_PRINTF_SQLFUNC;\n    sqlite3XPrintf(&str, zFormat, &x);\n    n = str.nChar;\n    sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,\n                        SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Implementation of the substr() function.\n**\n** substr(x,p1,p2)  returns p2 characters of x[] beginning with p1.\n** p1 is 1-indexed.  So substr(x,1,1) returns the first character\n** of x.  If x is text, then we actually count UTF-8 characters.\n** If x is a blob, then we count bytes.\n**\n** If p1 is negative, then we begin abs(p1) from the end of x[].\n**\n** If p2 is negative, return the p2 characters preceding p1.\n*/\nstatic void substrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z;\n  const unsigned char *z2;\n  int len;\n  int p0type;\n  i64 p1, p2;\n  int negP2 = 0;\n\n  assert( argc==3 || argc==2 );\n  if( sqlite3_value_type(argv[1])==SQLITE_NULL\n   || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)\n  ){\n    return;\n  }\n  p0type = sqlite3_value_type(argv[0]);\n  p1 = sqlite3_value_int(argv[1]);\n  if( p0type==SQLITE_BLOB ){\n    len = sqlite3_value_bytes(argv[0]);\n    z = sqlite3_value_blob(argv[0]);\n    if( z==0 ) return;\n    assert( len==sqlite3_value_bytes(argv[0]) );\n  }else{\n    z = sqlite3_value_text(argv[0]);\n    if( z==0 ) return;\n    len = 0;\n    if( p1<0 ){\n      for(z2=z; *z2; len++){\n        SQLITE_SKIP_UTF8(z2);\n      }\n    }\n  }\n#ifdef SQLITE_SUBSTR_COMPATIBILITY\n  /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as\n  ** as substr(X,1,N) - it returns the first N characters of X.  This\n  ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]\n  ** from 2009-02-02 for compatibility of applications that exploited the\n  ** old buggy behavior. */\n  if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */\n#endif\n  if( argc==3 ){\n    p2 = sqlite3_value_int(argv[2]);\n    if( p2<0 ){\n      p2 = -p2;\n      negP2 = 1;\n    }\n  }else{\n    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  if( p1<0 ){\n    p1 += len;\n    if( p1<0 ){\n      p2 += p1;\n      if( p2<0 ) p2 = 0;\n      p1 = 0;\n    }\n  }else if( p1>0 ){\n    p1--;\n  }else if( p2>0 ){\n    p2--;\n  }\n  if( negP2 ){\n    p1 -= p2;\n    if( p1<0 ){\n      p2 += p1;\n      p1 = 0;\n    }\n  }\n  assert( p1>=0 && p2>=0 );\n  if( p0type!=SQLITE_BLOB ){\n    while( *z && p1 ){\n      SQLITE_SKIP_UTF8(z);\n      p1--;\n    }\n    for(z2=z; *z2 && p2; p2--){\n      SQLITE_SKIP_UTF8(z2);\n    }\n    sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,\n                          SQLITE_UTF8);\n  }else{\n    if( p1+p2>len ){\n      p2 = len-p1;\n      if( p2<0 ) p2 = 0;\n    }\n    sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);\n  }\n}\n\n/*\n** Implementation of the round() function\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\nstatic void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  int n = 0;\n  double r;\n  char *zBuf;\n  assert( argc==1 || argc==2 );\n  if( argc==2 ){\n    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;\n    n = sqlite3_value_int(argv[1]);\n    if( n>30 ) n = 30;\n    if( n<0 ) n = 0;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  r = sqlite3_value_double(argv[0]);\n  /* If Y==0 and X will fit in a 64-bit int,\n  ** handle the rounding directly,\n  ** otherwise use printf.\n  */\n  if( n==0 && r>=0 && r<LARGEST_INT64-1 ){\n    r = (double)((sqlite_int64)(r+0.5));\n  }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){\n    r = -(double)((sqlite_int64)((-r)+0.5));\n  }else{\n    zBuf = sqlite3_mprintf(\"%.*f\",n,r);\n    if( zBuf==0 ){\n      sqlite3_result_error_nomem(context);\n      return;\n    }\n    sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);\n    sqlite3_free(zBuf);\n  }\n  sqlite3_result_double(context, r);\n}\n#endif\n\n/*\n** Allocate nByte bytes of space using sqlite3Malloc(). If the\n** allocation fails, call sqlite3_result_error_nomem() to notify\n** the database handle that malloc() has failed and return NULL.\n** If nByte is larger than the maximum string or blob length, then\n** raise an SQLITE_TOOBIG exception and return NULL.\n*/\nstatic void *contextMalloc(sqlite3_context *context, i64 nByte){\n  char *z;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  assert( nByte>0 );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );\n  testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 );\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    sqlite3_result_error_toobig(context);\n    z = 0;\n  }else{\n    z = sqlite3Malloc(nByte);\n    if( !z ){\n      sqlite3_result_error_nomem(context);\n    }\n  }\n  return z;\n}\n\n/*\n** Implementation of the upper() and lower() SQL functions.\n*/\nstatic void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = (char)sqlite3Toupper(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\nstatic void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  char *z1;\n  const char *z2;\n  int i, n;\n  UNUSED_PARAMETER(argc);\n  z2 = (char*)sqlite3_value_text(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  /* Verify that the call to _bytes() does not invalidate the _text() pointer */\n  assert( z2==(char*)sqlite3_value_text(argv[0]) );\n  if( z2 ){\n    z1 = contextMalloc(context, ((i64)n)+1);\n    if( z1 ){\n      for(i=0; i<n; i++){\n        z1[i] = sqlite3Tolower(z2[i]);\n      }\n      sqlite3_result_text(context, z1, n, sqlite3_free);\n    }\n  }\n}\n\n/*\n** Some functions like COALESCE() and IFNULL() and UNLIKELY() are implemented\n** as VDBE code so that unused argument values do not have to be computed.\n** However, we still need some kind of function implementation for this\n** routines in the function table.  The noopFunc macro provides this.\n** noopFunc will never be called so it doesn't matter what the implementation\n** is.  We might as well use the \"version()\" function as a substitute.\n*/\n#define noopFunc versionFunc   /* Substitute function - never called */\n\n/*\n** Implementation of random().  Return a random integer.  \n*/\nstatic void randomFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite_int64 r;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_randomness(sizeof(r), &r);\n  if( r<0 ){\n    /* We need to prevent a random number of 0x8000000000000000 \n    ** (or -9223372036854775808) since when you do abs() of that\n    ** number of you get the same value back again.  To do this\n    ** in a way that is testable, mask the sign bit off of negative\n    ** values, resulting in a positive value.  Then take the \n    ** 2s complement of that positive value.  The end result can\n    ** therefore be no less than -9223372036854775807.\n    */\n    r = -(r & LARGEST_INT64);\n  }\n  sqlite3_result_int64(context, r);\n}\n\n/*\n** Implementation of randomblob(N).  Return a random blob\n** that is N bytes long.\n*/\nstatic void randomBlob(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  unsigned char *p;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int(argv[0]);\n  if( n<1 ){\n    n = 1;\n  }\n  p = contextMalloc(context, n);\n  if( p ){\n    sqlite3_randomness(n, p);\n    sqlite3_result_blob(context, (char*)p, n, sqlite3_free);\n  }\n}\n\n/*\n** Implementation of the last_insert_rowid() SQL function.  The return\n** value is the same as the sqlite3_last_insert_rowid() API function.\n*/\nstatic void last_insert_rowid(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-51513-12026 The last_insert_rowid() SQL function is a\n  ** wrapper around the sqlite3_last_insert_rowid() C/C++ interface\n  ** function. */\n  sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));\n}\n\n/*\n** Implementation of the changes() SQL function.\n**\n** IMP: R-62073-11209 The changes() SQL function is a wrapper\n** around the sqlite3_changes() C/C++ function and hence follows the same\n** rules for counting changes.\n*/\nstatic void changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  sqlite3_result_int(context, sqlite3_changes(db));\n}\n\n/*\n** Implementation of the total_changes() SQL function.  The return value is\n** the same as the sqlite3_total_changes() API function.\n*/\nstatic void total_changes(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-52756-41993 This function is a wrapper around the\n  ** sqlite3_total_changes() C/C++ interface. */\n  sqlite3_result_int(context, sqlite3_total_changes(db));\n}\n\n/*\n** A structure defining how to do GLOB-style comparisons.\n*/\nstruct compareInfo {\n  u8 matchAll;          /* \"*\" or \"%\" */\n  u8 matchOne;          /* \"?\" or \"_\" */\n  u8 matchSet;          /* \"[\" or 0 */\n  u8 noCase;            /* true to ignore case differences */\n};\n\n/*\n** For LIKE and GLOB matching on EBCDIC machines, assume that every\n** character is exactly one byte in size.  Also, provde the Utf8Read()\n** macro for fast reading of the next character in the common case where\n** the next character is ASCII.\n*/\n#if defined(SQLITE_EBCDIC)\n# define sqlite3Utf8Read(A)        (*((*A)++))\n# define Utf8Read(A)               (*(A++))\n#else\n# define Utf8Read(A)               (A[0]<0x80?*(A++):sqlite3Utf8Read(&A))\n#endif\n\nstatic const struct compareInfo globInfo = { '*', '?', '[', 0 };\n/* The correct SQL-92 behavior is for the LIKE operator to ignore\n** case.  Thus  'a' LIKE 'A' would be true. */\nstatic const struct compareInfo likeInfoNorm = { '%', '_',   0, 1 };\n/* If SQLITE_CASE_SENSITIVE_LIKE is defined, then the LIKE operator\n** is case sensitive causing 'a' LIKE 'A' to be false */\nstatic const struct compareInfo likeInfoAlt = { '%', '_',   0, 0 };\n\n/*\n** Possible error returns from patternMatch()\n*/\n#define SQLITE_MATCH             0\n#define SQLITE_NOMATCH           1\n#define SQLITE_NOWILDCARDMATCH   2\n\n/*\n** Compare two UTF-8 strings for equality where the first string is\n** a GLOB or LIKE expression.  Return values:\n**\n**    SQLITE_MATCH:            Match\n**    SQLITE_NOMATCH:          No match\n**    SQLITE_NOWILDCARDMATCH:  No match in spite of having * or % wildcards.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n** With the [...] and [^...] matching, a ']' character can be included\n** in the list by making it the first character after '[' or '^'.  A\n** range of characters can be specified using '-'.  Example:\n** \"[a-z]\" matches any single lower-case letter.  To match a '-', make\n** it the last character in the list.\n**\n** Like matching rules:\n** \n**      '%'       Matches any sequence of zero or more characters\n**\n***     '_'       Matches any one character\n**\n**      Ec        Where E is the \"esc\" character and c is any other\n**                character, including '%', '_', and esc, match exactly c.\n**\n** The comments within this routine usually assume glob matching.\n**\n** This routine is usually quick, but can be N**2 in the worst case.\n*/\nstatic int patternCompare(\n  const u8 *zPattern,              /* The glob pattern */\n  const u8 *zString,               /* The string to compare against the glob */\n  const struct compareInfo *pInfo, /* Information about how to do the compare */\n  u32 matchOther                   /* The escape char (LIKE) or '[' (GLOB) */\n){\n  u32 c, c2;                       /* Next pattern and input string chars */\n  u32 matchOne = pInfo->matchOne;  /* \"?\" or \"_\" */\n  u32 matchAll = pInfo->matchAll;  /* \"*\" or \"%\" */\n  u8 noCase = pInfo->noCase;       /* True if uppercase==lowercase */\n  const u8 *zEscaped = 0;          /* One past the last escaped input char */\n  \n  while( (c = Utf8Read(zPattern))!=0 ){\n    if( c==matchAll ){  /* Match \"*\" */\n      /* Skip over multiple \"*\" characters in the pattern.  If there\n      ** are also \"?\" characters, skip those as well, but consume a\n      ** single character of the input string for each \"?\" skipped */\n      while( (c=Utf8Read(zPattern)) == matchAll || c == matchOne ){\n        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n      if( c==0 ){\n        return SQLITE_MATCH;   /* \"*\" at the end of the pattern matches */\n      }else if( c==matchOther ){\n        if( pInfo->matchSet==0 ){\n          c = sqlite3Utf8Read(&zPattern);\n          if( c==0 ) return SQLITE_NOWILDCARDMATCH;\n        }else{\n          /* \"[...]\" immediately follows the \"*\".  We have to do a slow\n          ** recursive search in this case, but it is an unusual case. */\n          assert( matchOther<0x80 );  /* '[' is a single-byte character */\n          while( *zString ){\n            int bMatch = patternCompare(&zPattern[-1],zString,pInfo,matchOther);\n            if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n            SQLITE_SKIP_UTF8(zString);\n          }\n          return SQLITE_NOWILDCARDMATCH;\n        }\n      }\n\n      /* At this point variable c contains the first character of the\n      ** pattern string past the \"*\".  Search in the input string for the\n      ** first matching character and recursively continue the match from\n      ** that point.\n      **\n      ** For a case-insensitive search, set variable cx to be the same as\n      ** c but in the other case and search the input string for either\n      ** c or cx.\n      */\n      if( c<=0x80 ){\n        u32 cx;\n        int bMatch;\n        if( noCase ){\n          cx = sqlite3Toupper(c);\n          c = sqlite3Tolower(c);\n        }else{\n          cx = c;\n        }\n        while( (c2 = *(zString++))!=0 ){\n          if( c2!=c && c2!=cx ) continue;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }else{\n        int bMatch;\n        while( (c2 = Utf8Read(zString))!=0 ){\n          if( c2!=c ) continue;\n          bMatch = patternCompare(zPattern,zString,pInfo,matchOther);\n          if( bMatch!=SQLITE_NOMATCH ) return bMatch;\n        }\n      }\n      return SQLITE_NOWILDCARDMATCH;\n    }\n    if( c==matchOther ){\n      if( pInfo->matchSet==0 ){\n        c = sqlite3Utf8Read(&zPattern);\n        if( c==0 ) return SQLITE_NOMATCH;\n        zEscaped = zPattern;\n      }else{\n        u32 prior_c = 0;\n        int seen = 0;\n        int invert = 0;\n        c = sqlite3Utf8Read(&zString);\n        if( c==0 ) return SQLITE_NOMATCH;\n        c2 = sqlite3Utf8Read(&zPattern);\n        if( c2=='^' ){\n          invert = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==']' ){\n          if( c==']' ) seen = 1;\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        while( c2 && c2!=']' ){\n          if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){\n            c2 = sqlite3Utf8Read(&zPattern);\n            if( c>=prior_c && c<=c2 ) seen = 1;\n            prior_c = 0;\n          }else{\n            if( c==c2 ){\n              seen = 1;\n            }\n            prior_c = c2;\n          }\n          c2 = sqlite3Utf8Read(&zPattern);\n        }\n        if( c2==0 || (seen ^ invert)==0 ){\n          return SQLITE_NOMATCH;\n        }\n        continue;\n      }\n    }\n    c2 = Utf8Read(zString);\n    if( c==c2 ) continue;\n    if( noCase  && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){\n      continue;\n    }\n    if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;\n    return SQLITE_NOMATCH;\n  }\n  return *zString==0 ? SQLITE_MATCH : SQLITE_NOMATCH;\n}\n\n/*\n** The sqlite3_strglob() interface.  Return 0 on a match (like strcmp()) and\n** non-zero if there is no match.\n*/\nint sqlite3_strglob(const char *zGlobPattern, const char *zString){\n  return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');\n}\n\n/*\n** The sqlite3_strlike() interface.  Return 0 on a match and non-zero for\n** a miss - like strcmp().\n*/\nint sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){\n  return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);\n}\n\n/*\n** Count the number of times that the LIKE operator (or GLOB which is\n** just a variation of LIKE) gets called.  This is used for testing\n** only.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_like_count = 0;\n#endif\n\n\n/*\n** Implementation of the like() SQL function.  This function implements\n** the build-in LIKE operator.  The first argument to the function is the\n** pattern and the second argument is the string.  So, the SQL statements:\n**\n**       A LIKE B\n**\n** is implemented as like(B,A).\n**\n** This same function (with a different compareInfo structure) computes\n** the GLOB operator.\n*/\nstatic void likeFunc(\n  sqlite3_context *context, \n  int argc, \n  sqlite3_value **argv\n){\n  const unsigned char *zA, *zB;\n  u32 escape;\n  int nPat;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  struct compareInfo *pInfo = sqlite3_user_data(context);\n\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( sqlite3_value_type(argv[0])==SQLITE_BLOB\n   || sqlite3_value_type(argv[1])==SQLITE_BLOB\n  ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context, 0);\n    return;\n  }\n#endif\n  zB = sqlite3_value_text(argv[0]);\n  zA = sqlite3_value_text(argv[1]);\n\n  /* Limit the length of the LIKE or GLOB pattern to avoid problems\n  ** of deep recursion and N*N behavior in patternCompare().\n  */\n  nPat = sqlite3_value_bytes(argv[0]);\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] );\n  testcase( nPat==db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]+1 );\n  if( nPat > db->aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] ){\n    sqlite3_result_error(context, \"LIKE or GLOB pattern too complex\", -1);\n    return;\n  }\n  assert( zB==sqlite3_value_text(argv[0]) );  /* Encoding did not change */\n\n  if( argc==3 ){\n    /* The escape character string must consist of a single UTF-8 character.\n    ** Otherwise, return an error.\n    */\n    const unsigned char *zEsc = sqlite3_value_text(argv[2]);\n    if( zEsc==0 ) return;\n    if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1 ){\n      sqlite3_result_error(context, \n          \"ESCAPE expression must be a single character\", -1);\n      return;\n    }\n    escape = sqlite3Utf8Read(&zEsc);\n  }else{\n    escape = pInfo->matchSet;\n  }\n  if( zA && zB ){\n#ifdef SQLITE_TEST\n    sqlite3_like_count++;\n#endif\n    sqlite3_result_int(context,\n                      patternCompare(zB, zA, pInfo, escape)==SQLITE_MATCH);\n  }\n}\n\n/*\n** Implementation of the NULLIF(x,y) function.  The result is the first\n** argument if the arguments are different.  The result is NULL if the\n** arguments are equal to each other.\n*/\nstatic void nullifFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **argv\n){\n  CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n  UNUSED_PARAMETER(NotUsed);\n  if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0 ){\n    sqlite3_result_value(context, argv[0]);\n  }\n}\n\n/*\n** Implementation of the sqlite_version() function.  The result is the version\n** of the SQLite library that is running.\n*/\nstatic void versionFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-48699-48617 This function is an SQL wrapper around the\n  ** sqlite3_libversion() C-interface. */\n  sqlite3_result_text(context, sqlite3_libversion(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_source_id() function. The result is a string\n** that identifies the particular version of the source code used to build\n** SQLite.\n*/\nstatic void sourceidFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  /* IMP: R-24470-31136 This function is an SQL wrapper around the\n  ** sqlite3_sourceid() C interface. */\n  sqlite3_result_text(context, sqlite3_sourceid(), -1, SQLITE_STATIC);\n}\n\n/*\n** Implementation of the sqlite_log() function.  This is a wrapper around\n** sqlite3_log().  The return value is NULL.  The function exists purely for\n** its side-effects.\n*/\nstatic void errlogFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(context);\n  sqlite3_log(sqlite3_value_int(argv[0]), \"%s\", sqlite3_value_text(argv[1]));\n}\n\n/*\n** Implementation of the sqlite_compileoption_used() function.\n** The result is an integer that identifies if the compiler option\n** was used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptionusedFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zOptName;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-39564-36305 The sqlite_compileoption_used() SQL\n  ** function is a wrapper around the sqlite3_compileoption_used() C/C++\n  ** function.\n  */\n  if( (zOptName = (const char*)sqlite3_value_text(argv[0]))!=0 ){\n    sqlite3_result_int(context, sqlite3_compileoption_used(zOptName));\n  }\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/*\n** Implementation of the sqlite_compileoption_get() function. \n** The result is a string that identifies the compiler options \n** used to build SQLite.\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nstatic void compileoptiongetFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int n;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  /* IMP: R-04922-24076 The sqlite_compileoption_get() SQL function\n  ** is a wrapper around the sqlite3_compileoption_get() C/C++ function.\n  */\n  n = sqlite3_value_int(argv[0]);\n  sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, SQLITE_STATIC);\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n/* Array for converting from half-bytes (nybbles) into ASCII hex\n** digits. */\nstatic const char hexdigits[] = {\n  '0', '1', '2', '3', '4', '5', '6', '7',\n  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' \n};\n\n/*\n** Implementation of the QUOTE() function.  This function takes a single\n** argument.  If the argument is numeric, the return value is the same as\n** the argument.  If the argument is NULL, the return value is the string\n** \"NULL\".  Otherwise, the argument is enclosed in single quotes with\n** single-quote escapes.\n*/\nstatic void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  switch( sqlite3_value_type(argv[0]) ){\n    case SQLITE_FLOAT: {\n      double r1, r2;\n      char zBuf[50];\n      r1 = sqlite3_value_double(argv[0]);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.15g\", r1);\n      sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);\n      if( r1!=r2 ){\n        sqlite3_snprintf(sizeof(zBuf), zBuf, \"%!.20e\", r1);\n      }\n      sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case SQLITE_INTEGER: {\n      sqlite3_result_value(context, argv[0]);\n      break;\n    }\n    case SQLITE_BLOB: {\n      char *zText = 0;\n      char const *zBlob = sqlite3_value_blob(argv[0]);\n      int nBlob = sqlite3_value_bytes(argv[0]);\n      assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */\n      zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4); \n      if( zText ){\n        int i;\n        for(i=0; i<nBlob; i++){\n          zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];\n          zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F];\n        }\n        zText[(nBlob*2)+2] = '\\'';\n        zText[(nBlob*2)+3] = '\\0';\n        zText[0] = 'X';\n        zText[1] = '\\'';\n        sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);\n        sqlite3_free(zText);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      int i,j;\n      u64 n;\n      const unsigned char *zArg = sqlite3_value_text(argv[0]);\n      char *z;\n\n      if( zArg==0 ) return;\n      for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\\'' ) n++; }\n      z = contextMalloc(context, ((i64)i)+((i64)n)+3);\n      if( z ){\n        z[0] = '\\'';\n        for(i=0, j=1; zArg[i]; i++){\n          z[j++] = zArg[i];\n          if( zArg[i]=='\\'' ){\n            z[j++] = '\\'';\n          }\n        }\n        z[j++] = '\\'';\n        z[j] = 0;\n        sqlite3_result_text(context, z, j, sqlite3_free);\n      }\n      break;\n    }\n    default: {\n      assert( sqlite3_value_type(argv[0])==SQLITE_NULL );\n      sqlite3_result_text(context, \"NULL\", 4, SQLITE_STATIC);\n      break;\n    }\n  }\n}\n\n/*\n** The unicode() function.  Return the integer unicode code-point value\n** for the first character of the input string. \n*/\nstatic void unicodeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *z = sqlite3_value_text(argv[0]);\n  (void)argc;\n  if( z && z[0] ) sqlite3_result_int(context, sqlite3Utf8Read(&z));\n}\n\n/*\n** The char() function takes zero or more arguments, each of which is\n** an integer.  It constructs a string where each character of the string\n** is the unicode character for the corresponding integer argument.\n*/\nstatic void charFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  unsigned char *z, *zOut;\n  int i;\n  zOut = z = sqlite3_malloc64( argc*4+1 );\n  if( z==0 ){\n    sqlite3_result_error_nomem(context);\n    return;\n  }\n  for(i=0; i<argc; i++){\n    sqlite3_int64 x;\n    unsigned c;\n    x = sqlite3_value_int64(argv[i]);\n    if( x<0 || x>0x10ffff ) x = 0xfffd;\n    c = (unsigned)(x & 0x1fffff);\n    if( c<0x00080 ){\n      *zOut++ = (u8)(c&0xFF);\n    }else if( c<0x00800 ){\n      *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else if( c<0x10000 ){\n      *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }else{\n      *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);\n      *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);\n      *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);\n      *zOut++ = 0x80 + (u8)(c & 0x3F);\n    }                                                    \\\n  }\n  sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, SQLITE_UTF8);\n}\n\n/*\n** The hex() function.  Interpret the argument as a blob.  Return\n** a hexadecimal rendering as text.\n*/\nstatic void hexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i, n;\n  const unsigned char *pBlob;\n  char *zHex, *z;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  pBlob = sqlite3_value_blob(argv[0]);\n  n = sqlite3_value_bytes(argv[0]);\n  assert( pBlob==sqlite3_value_blob(argv[0]) );  /* No encoding change */\n  z = zHex = contextMalloc(context, ((i64)n)*2 + 1);\n  if( zHex ){\n    for(i=0; i<n; i++, pBlob++){\n      unsigned char c = *pBlob;\n      *(z++) = hexdigits[(c>>4)&0xf];\n      *(z++) = hexdigits[c&0xf];\n    }\n    *z = 0;\n    sqlite3_result_text(context, zHex, n*2, sqlite3_free);\n  }\n}\n\n/*\n** The zeroblob(N) function returns a zero-filled blob of size N bytes.\n*/\nstatic void zeroblobFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  i64 n;\n  int rc;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  n = sqlite3_value_int64(argv[0]);\n  if( n<0 ) n = 0;\n  rc = sqlite3_result_zeroblob64(context, n); /* IMP: R-00293-64994 */\n  if( rc ){\n    sqlite3_result_error_code(context, rc);\n  }\n}\n\n/*\n** The replace() function.  Three arguments are all strings: call\n** them A, B, and C. The result is also a string which is derived\n** from A by replacing every occurrence of B with C.  The match\n** must be exact.  Collating sequences are not used.\n*/\nstatic void replaceFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zStr;        /* The input string A */\n  const unsigned char *zPattern;    /* The pattern string B */\n  const unsigned char *zRep;        /* The replacement string C */\n  unsigned char *zOut;              /* The output */\n  int nStr;                /* Size of zStr */\n  int nPattern;            /* Size of zPattern */\n  int nRep;                /* Size of zRep */\n  i64 nOut;                /* Maximum size of zOut */\n  int loopLimit;           /* Last zStr[] that might match zPattern[] */\n  int i, j;                /* Loop counters */\n\n  assert( argc==3 );\n  UNUSED_PARAMETER(argc);\n  zStr = sqlite3_value_text(argv[0]);\n  if( zStr==0 ) return;\n  nStr = sqlite3_value_bytes(argv[0]);\n  assert( zStr==sqlite3_value_text(argv[0]) );  /* No encoding change */\n  zPattern = sqlite3_value_text(argv[1]);\n  if( zPattern==0 ){\n    assert( sqlite3_value_type(argv[1])==SQLITE_NULL\n            || sqlite3_context_db_handle(context)->mallocFailed );\n    return;\n  }\n  if( zPattern[0]==0 ){\n    assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );\n    sqlite3_result_value(context, argv[0]);\n    return;\n  }\n  nPattern = sqlite3_value_bytes(argv[1]);\n  assert( zPattern==sqlite3_value_text(argv[1]) );  /* No encoding change */\n  zRep = sqlite3_value_text(argv[2]);\n  if( zRep==0 ) return;\n  nRep = sqlite3_value_bytes(argv[2]);\n  assert( zRep==sqlite3_value_text(argv[2]) );\n  nOut = nStr + 1;\n  assert( nOut<SQLITE_MAX_LENGTH );\n  zOut = contextMalloc(context, (i64)nOut);\n  if( zOut==0 ){\n    return;\n  }\n  loopLimit = nStr - nPattern;  \n  for(i=j=0; i<=loopLimit; i++){\n    if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){\n      zOut[j++] = zStr[i];\n    }else{\n      u8 *zOld;\n      sqlite3 *db = sqlite3_context_db_handle(context);\n      nOut += nRep - nPattern;\n      testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );\n      if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        sqlite3_result_error_toobig(context);\n        sqlite3_free(zOut);\n        return;\n      }\n      zOld = zOut;\n      zOut = sqlite3_realloc64(zOut, (int)nOut);\n      if( zOut==0 ){\n        sqlite3_result_error_nomem(context);\n        sqlite3_free(zOld);\n        return;\n      }\n      memcpy(&zOut[j], zRep, nRep);\n      j += nRep;\n      i += nPattern-1;\n    }\n  }\n  assert( j+nStr-i+1==nOut );\n  memcpy(&zOut[j], &zStr[i], nStr-i);\n  j += nStr - i;\n  assert( j<=nOut );\n  zOut[j] = 0;\n  sqlite3_result_text(context, (char*)zOut, j, sqlite3_free);\n}\n\n/*\n** Implementation of the TRIM(), LTRIM(), and RTRIM() functions.\n** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both.\n*/\nstatic void trimFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zIn;         /* Input string */\n  const unsigned char *zCharSet;    /* Set of characters to trim */\n  int nIn;                          /* Number of bytes in input */\n  int flags;                        /* 1: trimleft  2: trimright  3: trim */\n  int i;                            /* Loop counter */\n  unsigned char *aLen = 0;          /* Length of each character in zCharSet */\n  unsigned char **azChar = 0;       /* Individual characters in zCharSet */\n  int nChar;                        /* Number of characters in zCharSet */\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    return;\n  }\n  zIn = sqlite3_value_text(argv[0]);\n  if( zIn==0 ) return;\n  nIn = sqlite3_value_bytes(argv[0]);\n  assert( zIn==sqlite3_value_text(argv[0]) );\n  if( argc==1 ){\n    static const unsigned char lenOne[] = { 1 };\n    static unsigned char * const azOne[] = { (u8*)\" \" };\n    nChar = 1;\n    aLen = (u8*)lenOne;\n    azChar = (unsigned char **)azOne;\n    zCharSet = 0;\n  }else if( (zCharSet = sqlite3_value_text(argv[1]))==0 ){\n    return;\n  }else{\n    const unsigned char *z;\n    for(z=zCharSet, nChar=0; *z; nChar++){\n      SQLITE_SKIP_UTF8(z);\n    }\n    if( nChar>0 ){\n      azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));\n      if( azChar==0 ){\n        return;\n      }\n      aLen = (unsigned char*)&azChar[nChar];\n      for(z=zCharSet, nChar=0; *z; nChar++){\n        azChar[nChar] = (unsigned char *)z;\n        SQLITE_SKIP_UTF8(z);\n        aLen[nChar] = (u8)(z - azChar[nChar]);\n      }\n    }\n  }\n  if( nChar>0 ){\n    flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));\n    if( flags & 1 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(zIn, azChar[i], len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        zIn += len;\n        nIn -= len;\n      }\n    }\n    if( flags & 2 ){\n      while( nIn>0 ){\n        int len = 0;\n        for(i=0; i<nChar; i++){\n          len = aLen[i];\n          if( len<=nIn && memcmp(&zIn[nIn-len],azChar[i],len)==0 ) break;\n        }\n        if( i>=nChar ) break;\n        nIn -= len;\n      }\n    }\n    if( zCharSet ){\n      sqlite3_free(azChar);\n    }\n  }\n  sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);\n}\n\n\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n/*\n** The \"unknown\" function is automatically substituted in place of\n** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN\n** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used.\n** When the \"sqlite3\" command-line shell is built using this functionality,\n** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries\n** involving application-defined functions to be examined in a generic\n** sqlite3 shell.\n*/\nstatic void unknownFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  /* no-op */\n}\n#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/\n\n\n/* IMP: R-25361-16150 This function is omitted from SQLite by default. It\n** is only available if the SQLITE_SOUNDEX compile-time option is used\n** when SQLite is built.\n*/\n#ifdef SQLITE_SOUNDEX\n/*\n** Compute the soundex encoding of a word.\n**\n** IMP: R-59782-00072 The soundex(X) function returns a string that is the\n** soundex encoding of the string X. \n*/\nstatic void soundexFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  char zResult[8];\n  const u8 *zIn;\n  int i, j;\n  static const unsigned char iCode[] = {\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n    0, 0, 1, 2, 3, 0, 1, 2, 0, 0, 2, 2, 4, 5, 5, 0,\n    1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,\n  };\n  assert( argc==1 );\n  zIn = (u8*)sqlite3_value_text(argv[0]);\n  if( zIn==0 ) zIn = (u8*)\"\";\n  for(i=0; zIn[i] && !sqlite3Isalpha(zIn[i]); i++){}\n  if( zIn[i] ){\n    u8 prevcode = iCode[zIn[i]&0x7f];\n    zResult[0] = sqlite3Toupper(zIn[i]);\n    for(j=1; j<4 && zIn[i]; i++){\n      int code = iCode[zIn[i]&0x7f];\n      if( code>0 ){\n        if( code!=prevcode ){\n          prevcode = code;\n          zResult[j++] = code + '0';\n        }\n      }else{\n        prevcode = 0;\n      }\n    }\n    while( j<4 ){\n      zResult[j++] = '0';\n    }\n    zResult[j] = 0;\n    sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);\n  }else{\n    /* IMP: R-64894-50321 The string \"?000\" is returned if the argument\n    ** is NULL or contains no ASCII alphabetic characters. */\n    sqlite3_result_text(context, \"?000\", 4, SQLITE_STATIC);\n  }\n}\n#endif /* SQLITE_SOUNDEX */\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** A function that loads a shared-library extension then returns NULL.\n*/\nstatic void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){\n  const char *zFile = (const char *)sqlite3_value_text(argv[0]);\n  const char *zProc;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  char *zErrMsg = 0;\n\n  /* Disallow the load_extension() SQL function unless the SQLITE_LoadExtFunc\n  ** flag is set.  See the sqlite3_enable_load_extension() API.\n  */\n  if( (db->flags & SQLITE_LoadExtFunc)==0 ){\n    sqlite3_result_error(context, \"not authorized\", -1);\n    return;\n  }\n\n  if( argc==2 ){\n    zProc = (const char *)sqlite3_value_text(argv[1]);\n  }else{\n    zProc = 0;\n  }\n  if( zFile && sqlite3_load_extension(db, zFile, zProc, &zErrMsg) ){\n    sqlite3_result_error(context, zErrMsg, -1);\n    sqlite3_free(zErrMsg);\n  }\n}\n#endif\n\n\n/*\n** An instance of the following structure holds the context of a\n** sum() or avg() aggregate computation.\n*/\ntypedef struct SumCtx SumCtx;\nstruct SumCtx {\n  double rSum;      /* Floating point sum */\n  i64 iSum;         /* Integer sum */   \n  i64 cnt;          /* Number of elements summed */\n  u8 overflow;      /* True if integer overflow seen */\n  u8 approx;        /* True if non-integer value was input to the sum */\n};\n\n/*\n** Routines used to compute the sum, average, and total.\n**\n** The SUM() function follows the (broken) SQL standard which means\n** that it returns NULL if it sums over no inputs.  TOTAL returns\n** 0.0 in that case.  In addition, TOTAL always returns a float where\n** SUM might return an integer if it never encounters a floating point\n** value.  TOTAL never fails, but SUM might through an exception if\n** it overflows an integer.\n*/\nstatic void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  SumCtx *p;\n  int type;\n  assert( argc==1 );\n  UNUSED_PARAMETER(argc);\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  type = sqlite3_value_numeric_type(argv[0]);\n  if( p && type!=SQLITE_NULL ){\n    p->cnt++;\n    if( type==SQLITE_INTEGER ){\n      i64 v = sqlite3_value_int64(argv[0]);\n      p->rSum += v;\n      if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, v) ){\n        p->overflow = 1;\n      }\n    }else{\n      p->rSum += sqlite3_value_double(argv[0]);\n      p->approx = 1;\n    }\n  }\n}\nstatic void sumFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    if( p->overflow ){\n      sqlite3_result_error(context,\"integer overflow\",-1);\n    }else if( p->approx ){\n      sqlite3_result_double(context, p->rSum);\n    }else{\n      sqlite3_result_int64(context, p->iSum);\n    }\n  }\n}\nstatic void avgFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->cnt>0 ){\n    sqlite3_result_double(context, p->rSum/(double)p->cnt);\n  }\n}\nstatic void totalFinalize(sqlite3_context *context){\n  SumCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  sqlite3_result_double(context, p ? p->rSum : (double)0);\n}\n\n/*\n** The following structure keeps track of state information for the\n** count() aggregate function.\n*/\ntypedef struct CountCtx CountCtx;\nstruct CountCtx {\n  i64 n;\n};\n\n/*\n** Routines to implement the count() aggregate function.\n*/\nstatic void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){\n    p->n++;\n  }\n\n#ifndef SQLITE_OMIT_DEPRECATED\n  /* The sqlite3_aggregate_count() function is deprecated.  But just to make\n  ** sure it still operates correctly, verify that its count agrees with our \n  ** internal count when using count(*) and when the total count can be\n  ** expressed as a 32-bit integer. */\n  assert( argc==1 || p==0 || p->n>0x7fffffff\n          || p->n==sqlite3_aggregate_count(context) );\n#endif\n}   \nstatic void countFinalize(sqlite3_context *context){\n  CountCtx *p;\n  p = sqlite3_aggregate_context(context, 0);\n  sqlite3_result_int64(context, p ? p->n : 0);\n}\n\n/*\n** Routines to implement min() and max() aggregate functions.\n*/\nstatic void minmaxStep(\n  sqlite3_context *context, \n  int NotUsed, \n  sqlite3_value **argv\n){\n  Mem *pArg  = (Mem *)argv[0];\n  Mem *pBest;\n  UNUSED_PARAMETER(NotUsed);\n\n  pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));\n  if( !pBest ) return;\n\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    if( pBest->flags ) sqlite3SkipAccumulatorLoad(context);\n  }else if( pBest->flags ){\n    int max;\n    int cmp;\n    CollSeq *pColl = sqlite3GetFuncCollSeq(context);\n    /* This step function is used for both the min() and max() aggregates,\n    ** the only difference between the two being that the sense of the\n    ** comparison is inverted. For the max() aggregate, the\n    ** sqlite3_user_data() function returns (void *)-1. For min() it\n    ** returns (void *)db, where db is the sqlite3* database pointer.\n    ** Therefore the next statement sets variable 'max' to 1 for the max()\n    ** aggregate, or 0 for min().\n    */\n    max = sqlite3_user_data(context)!=0;\n    cmp = sqlite3MemCompare(pBest, pArg, pColl);\n    if( (max && cmp<0) || (!max && cmp>0) ){\n      sqlite3VdbeMemCopy(pBest, pArg);\n    }else{\n      sqlite3SkipAccumulatorLoad(context);\n    }\n  }else{\n    pBest->db = sqlite3_context_db_handle(context);\n    sqlite3VdbeMemCopy(pBest, pArg);\n  }\n}\nstatic void minMaxFinalize(sqlite3_context *context){\n  sqlite3_value *pRes;\n  pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0);\n  if( pRes ){\n    if( pRes->flags ){\n      sqlite3_result_value(context, pRes);\n    }\n    sqlite3VdbeMemRelease(pRes);\n  }\n}\n\n/*\n** group_concat(EXPR, ?SEPARATOR?)\n*/\nstatic void groupConcatStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zVal;\n  StrAccum *pAccum;\n  const char *zSep;\n  int nVal, nSep;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));\n\n  if( pAccum ){\n    sqlite3 *db = sqlite3_context_db_handle(context);\n    int firstTerm = pAccum->mxAlloc==0;\n    pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];\n    if( !firstTerm ){\n      if( argc==2 ){\n        zSep = (char*)sqlite3_value_text(argv[1]);\n        nSep = sqlite3_value_bytes(argv[1]);\n      }else{\n        zSep = \",\";\n        nSep = 1;\n      }\n      if( zSep ) sqlite3StrAccumAppend(pAccum, zSep, nSep);\n    }\n    zVal = (char*)sqlite3_value_text(argv[0]);\n    nVal = sqlite3_value_bytes(argv[0]);\n    if( zVal ) sqlite3StrAccumAppend(pAccum, zVal, nVal);\n  }\n}\nstatic void groupConcatFinalize(sqlite3_context *context){\n  StrAccum *pAccum;\n  pAccum = sqlite3_aggregate_context(context, 0);\n  if( pAccum ){\n    if( pAccum->accError==STRACCUM_TOOBIG ){\n      sqlite3_result_error_toobig(context);\n    }else if( pAccum->accError==STRACCUM_NOMEM ){\n      sqlite3_result_error_nomem(context);\n    }else{    \n      sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, \n                          sqlite3_free);\n    }\n  }\n}\n\n/*\n** This routine does per-connection function registration.  Most\n** of the built-in functions above are part of the global function set.\n** This routine only deals with those that are not global.\n*/\nvoid sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){\n  int rc = sqlite3_overload_function(db, \"MATCH\", 2);\n  assert( rc==SQLITE_NOMEM || rc==SQLITE_OK );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3OomFault(db);\n  }\n}\n\n/*\n** Set the LIKEOPT flag on the 2-argument function with the given name.\n*/\nstatic void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){\n  FuncDef *pDef;\n  pDef = sqlite3FindFunction(db, zName, 2, SQLITE_UTF8, 0);\n  if( ALWAYS(pDef) ){\n    pDef->funcFlags |= flagVal;\n  }\n}\n\n/*\n** Register the built-in LIKE and GLOB functions.  The caseSensitive\n** parameter determines whether or not the LIKE operator is case\n** sensitive.  GLOB is always case sensitive.\n*/\nvoid sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){\n  struct compareInfo *pInfo;\n  if( caseSensitive ){\n    pInfo = (struct compareInfo*)&likeInfoAlt;\n  }else{\n    pInfo = (struct compareInfo*)&likeInfoNorm;\n  }\n  sqlite3CreateFunc(db, \"like\", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"like\", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0);\n  sqlite3CreateFunc(db, \"glob\", 2, SQLITE_UTF8, \n      (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0);\n  setLikeOptFlag(db, \"glob\", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE);\n  setLikeOptFlag(db, \"like\", \n      caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE);\n}\n\n/*\n** pExpr points to an expression which implements a function.  If\n** it is appropriate to apply the LIKE optimization to that function\n** then set aWc[0] through aWc[2] to the wildcard characters and the\n** escape character and then return TRUE.  If the function is not a \n** LIKE-style function then return FALSE.\n**\n** The expression \"a LIKE b ESCAPE c\" is only considered a valid LIKE\n** operator if c is a string literal that is exactly one byte in length.\n** That one byte is stored in aWc[3].  aWc[3] is set to zero if there is\n** no ESCAPE clause.\n**\n** *pIsNocase is set to true if uppercase and lowercase are equivalent for\n** the function (default for LIKE).  If the function makes the distinction\n** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to\n** false.\n*/\nint sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){\n  FuncDef *pDef;\n  int nExpr;\n  if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){\n    return 0;\n  }\n  assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n  nExpr = pExpr->x.pList->nExpr;\n  pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0);\n  if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_FUNC_LIKE)==0 ){\n    return 0;\n  }\n  if( nExpr<3 ){\n    aWc[3] = 0;\n  }else{\n    Expr *pEscape = pExpr->x.pList->a[2].pExpr;\n    char *zEscape;\n    if( pEscape->op!=TK_STRING ) return 0;\n    zEscape = pEscape->u.zToken;\n    if( zEscape[0]==0 || zEscape[1]!=0 ) return 0;\n    aWc[3] = zEscape[0];\n  }\n\n  /* The memcpy() statement assumes that the wildcard characters are\n  ** the first three statements in the compareInfo structure.  The\n  ** asserts() that follow verify that assumption\n  */\n  memcpy(aWc, pDef->pUserData, 3);\n  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );\n  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );\n  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );\n  *pIsNocase = (pDef->funcFlags & SQLITE_FUNC_CASE)==0;\n  return 1;\n}\n\n/*\n** All of the FuncDef structures in the aBuiltinFunc[] array above\n** to the global function hash table.  This occurs at start-time (as\n** a consequence of calling sqlite3_initialize()).\n**\n** After this routine runs\n*/\nvoid sqlite3RegisterBuiltinFunctions(void){\n  /*\n  ** The following array holds FuncDef structures for all of the functions\n  ** defined in this file.\n  **\n  ** The array cannot be constant since changes are made to the\n  ** FuncDef.pHash elements at start-time.  The elements of this array\n  ** are read-only after initialization is complete.\n  **\n  ** For peak efficiency, put the most frequently used function last.\n  */\n  static FuncDef aBuiltinFunc[] = {\n#ifdef SQLITE_SOUNDEX\n    FUNCTION(soundex,            1, 0, 0, soundexFunc      ),\n#endif\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    VFUNCTION(load_extension,    1, 0, 0, loadExt          ),\n    VFUNCTION(load_extension,    2, 0, 0, loadExt          ),\n#endif\n#if SQLITE_USER_AUTHENTICATION\n    FUNCTION(sqlite_crypt,       2, 0, 0, sqlite3CryptFunc ),\n#endif\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n    DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),\n    DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n    FUNCTION2(unlikely,          1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likelihood,        2, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n    FUNCTION2(likely,            1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),\n#ifdef SQLITE_DEBUG\n    FUNCTION2(affinity,          1, 0, 0, noopFunc,  SQLITE_FUNC_AFFINITY),\n#endif\n    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),\n    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),\n    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),\n    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),\n    FUNCTION(trim,               1, 3, 0, trimFunc         ),\n    FUNCTION(trim,               2, 3, 0, trimFunc         ),\n    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),\n    FUNCTION(min,                0, 0, 1, 0                ),\n    AGGREGATE2(min,              1, 0, 1, minmaxStep,      minMaxFinalize,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),\n    FUNCTION(max,                0, 1, 1, 0                ),\n    AGGREGATE2(max,              1, 1, 1, minmaxStep,      minMaxFinalize,\n                                          SQLITE_FUNC_MINMAX ),\n    FUNCTION2(typeof,            1, 0, 0, typeofFunc,  SQLITE_FUNC_TYPEOF),\n    FUNCTION2(length,            1, 0, 0, lengthFunc,  SQLITE_FUNC_LENGTH),\n    FUNCTION(instr,              2, 0, 0, instrFunc        ),\n    FUNCTION(printf,            -1, 0, 0, printfFunc       ),\n    FUNCTION(unicode,            1, 0, 0, unicodeFunc      ),\n    FUNCTION(char,              -1, 0, 0, charFunc         ),\n    FUNCTION(abs,                1, 0, 0, absFunc          ),\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    FUNCTION(round,              1, 0, 0, roundFunc        ),\n    FUNCTION(round,              2, 0, 0, roundFunc        ),\n#endif\n    FUNCTION(upper,              1, 0, 0, upperFunc        ),\n    FUNCTION(lower,              1, 0, 0, lowerFunc        ),\n    FUNCTION(hex,                1, 0, 0, hexFunc          ),\n    FUNCTION2(ifnull,            2, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n    VFUNCTION(random,            0, 0, 0, randomFunc       ),\n    VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),\n    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),\n    DFUNCTION(sqlite_version,    0, 0, 0, versionFunc      ),\n    DFUNCTION(sqlite_source_id,  0, 0, 0, sourceidFunc     ),\n    FUNCTION(sqlite_log,         2, 0, 0, errlogFunc       ),\n    FUNCTION(quote,              1, 0, 0, quoteFunc        ),\n    VFUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid),\n    VFUNCTION(changes,           0, 0, 0, changes          ),\n    VFUNCTION(total_changes,     0, 0, 0, total_changes    ),\n    FUNCTION(replace,            3, 0, 0, replaceFunc      ),\n    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),\n    FUNCTION(substr,             2, 0, 0, substrFunc       ),\n    FUNCTION(substr,             3, 0, 0, substrFunc       ),\n    AGGREGATE(sum,               1, 0, 0, sumStep,         sumFinalize    ),\n    AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),\n    AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),\n    AGGREGATE2(count,            0, 0, 0, countStep,       countFinalize,\n               SQLITE_FUNC_COUNT  ),\n    AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),\n    AGGREGATE(group_concat,      1, 0, 0, groupConcatStep, groupConcatFinalize),\n    AGGREGATE(group_concat,      2, 0, 0, groupConcatStep, groupConcatFinalize),\n  \n    LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#ifdef SQLITE_CASE_SENSITIVE_LIKE\n    LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n    LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),\n#else\n    LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),\n    LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),\n#endif\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n    FUNCTION(unknown,           -1, 0, 0, unknownFunc      ),\n#endif\n    FUNCTION(coalesce,           1, 0, 0, 0                ),\n    FUNCTION(coalesce,           0, 0, 0, 0                ),\n    FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),\n  };\n#ifndef SQLITE_OMIT_ALTERTABLE\n  sqlite3AlterFunctions();\n#endif\n#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)\n  sqlite3AnalyzeFunctions();\n#endif\n  sqlite3RegisterDateTimeFunctions();\n  sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));\n\n#if 0  /* Enable to print out how the built-in functions are hashed */\n  {\n    int i;\n    FuncDef *p;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      printf(\"FUNC-HASH %02d:\", i);\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){\n        int n = sqlite3Strlen30(p->zName);\n        int h = p->zName[0] + n;\n        printf(\" %s(%d)\", p->zName, h);\n      }\n      printf(\"\\n\");\n    }\n  }\n#endif\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/global.c",
    "content": "/*\n** 2008 June 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains definitions of global variables and constants.\n*/\n#include \"sqliteInt.h\"\n\n/* An array to map all upper-case characters into their corresponding\n** lower-case character. \n**\n** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not\n** handle case conversions for the UTF character set since the tables\n** involved are nearly as big or bigger than SQLite itself.\n*/\nconst unsigned char sqlite3UpperToLower[] = {\n#ifdef SQLITE_ASCII\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17,\n     18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n     36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,\n     54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 97, 98, 99,100,101,102,103,\n    104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,\n    122, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,101,102,103,104,105,106,107,\n    108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,\n    126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,\n    162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,\n    180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,\n    198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,\n    216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,\n    234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,\n    252,253,254,255\n#endif\n#ifdef SQLITE_EBCDIC\n      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, /* 0x */\n     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */\n     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */\n     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */\n     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */\n     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */\n     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */\n    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */\n    128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */\n    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */\n    160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */\n    176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */\n    192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */\n    208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */\n    224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */\n    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */\n#endif\n};\n\n/*\n** The following 256 byte lookup table is used to support SQLites built-in\n** equivalents to the following standard library functions:\n**\n**   isspace()                        0x01\n**   isalpha()                        0x02\n**   isdigit()                        0x04\n**   isalnum()                        0x06\n**   isxdigit()                       0x08\n**   toupper()                        0x20\n**   SQLite identifier character      0x40\n**   Quote character                  0x80\n**\n** Bit 0x20 is set if the mapped character requires translation to upper\n** case. i.e. if the character is a lower-case ASCII character.\n** If x is a lower-case ASCII character, then its upper-case equivalent\n** is (x - 0x20). Therefore toupper() can be implemented as:\n**\n**   (x & ~(map[x]&0x20))\n**\n** The equivalent of tolower() is implemented using the sqlite3UpperToLower[]\n** array. tolower() is used more often than toupper() by SQLite.\n**\n** Bit 0x40 is set if the character is non-alphanumeric and can be used in an \n** SQLite identifier.  Identifiers are alphanumerics, \"_\", \"$\", and any\n** non-ASCII UTF character. Hence the test for whether or not a character is\n** part of an identifier is 0x46.\n*/\n#ifdef SQLITE_ASCII\nconst unsigned char sqlite3CtypeMap[256] = {\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 00..07    ........ */\n  0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,  /* 08..0f    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 10..17    ........ */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 18..1f    ........ */\n  0x01, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x80,  /* 20..27     !\"#$%&' */\n  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 28..2f    ()*+,-./ */\n  0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,  /* 30..37    01234567 */\n  0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 38..3f    89:;<=>? */\n\n  0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02,  /* 40..47    @ABCDEFG */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 48..4f    HIJKLMNO */\n  0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,  /* 50..57    PQRSTUVW */\n  0x02, 0x02, 0x02, 0x80, 0x00, 0x00, 0x00, 0x40,  /* 58..5f    XYZ[\\]^_ */\n  0x80, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22,  /* 60..67    `abcdefg */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 68..6f    hijklmno */\n  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,  /* 70..77    pqrstuvw */\n  0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,  /* 78..7f    xyz{|}~. */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 80..87    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 88..8f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 90..97    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* 98..9f    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a0..a7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* a8..af    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b0..b7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* b8..bf    ........ */\n\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c0..c7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* c8..cf    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d0..d7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* d8..df    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e0..e7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* e8..ef    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,  /* f0..f7    ........ */\n  0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* f8..ff    ........ */\n};\n#endif\n\n/* EVIDENCE-OF: R-02982-34736 In order to maintain full backwards\n** compatibility for legacy applications, the URI filename capability is\n** disabled by default.\n**\n** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled\n** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.\n**\n** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** SQLITE_USE_URI symbol defined.\n**\n** URI filenames are enabled by default if SQLITE_HAS_CODEC is\n** enabled.\n*/\n#ifndef SQLITE_USE_URI\n# ifdef SQLITE_HAS_CODEC\n#  define SQLITE_USE_URI 1\n# else\n#  define SQLITE_USE_URI 0\n# endif\n#endif\n\n/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the\n** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is \"on\" if\n** that compile-time option is omitted.\n*/\n#ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN\n# define SQLITE_ALLOW_COVERING_INDEX_SCAN 1\n#endif\n\n/* The minimum PMA size is set to this value multiplied by the database\n** page size in bytes.\n*/\n#ifndef SQLITE_SORTER_PMASZ\n# define SQLITE_SORTER_PMASZ 250\n#endif\n\n/* Statement journals spill to disk when their size exceeds the following\n** threshold (in bytes). 0 means that statement journals are created and\n** written to disk immediately (the default behavior for SQLite versions\n** before 3.12.0).  -1 means always keep the entire statement journal in\n** memory.  (The statement journal is also always held entirely in memory\n** if journal_mode=MEMORY or if temp_store=MEMORY, regardless of this\n** setting.)\n*/\n#ifndef SQLITE_STMTJRNL_SPILL \n# define SQLITE_STMTJRNL_SPILL (64*1024)\n#endif\n\n/*\n** The default lookaside-configuration, the format \"SZ,N\".  SZ is the\n** number of bytes in each lookaside slot (should be a multiple of 8)\n** and N is the number of slots.  The lookaside-configuration can be\n** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)\n** or at run-time for an individual database connection using\n** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);\n*/\n#ifndef SQLITE_DEFAULT_LOOKASIDE\n# define SQLITE_DEFAULT_LOOKASIDE 1200,100\n#endif\n\n\n/*\n** The following singleton contains the global configuration for\n** the SQLite library.\n*/\nSQLITE_WSD struct Sqlite3Config sqlite3Config = {\n   SQLITE_DEFAULT_MEMSTATUS,  /* bMemstat */\n   1,                         /* bCoreMutex */\n   SQLITE_THREADSAFE==1,      /* bFullMutex */\n   SQLITE_USE_URI,            /* bOpenUri */\n   SQLITE_ALLOW_COVERING_INDEX_SCAN,   /* bUseCis */\n   0,                         /* bSmallMalloc */\n   0x7ffffffe,                /* mxStrlen */\n   0,                         /* neverCorrupt */\n   SQLITE_DEFAULT_LOOKASIDE,  /* szLookaside, nLookaside */\n   SQLITE_STMTJRNL_SPILL,     /* nStmtSpill */\n   {0,0,0,0,0,0,0,0},         /* m */\n   {0,0,0,0,0,0,0,0,0},       /* mutex */\n   {0,0,0,0,0,0,0,0,0,0,0,0,0},/* pcache2 */\n   (void*)0,                  /* pHeap */\n   0,                         /* nHeap */\n   0, 0,                      /* mnHeap, mxHeap */\n   SQLITE_DEFAULT_MMAP_SIZE,  /* szMmap */\n   SQLITE_MAX_MMAP_SIZE,      /* mxMmap */\n   (void*)0,                  /* pPage */\n   0,                         /* szPage */\n   SQLITE_DEFAULT_PCACHE_INITSZ, /* nPage */\n   0,                         /* mxParserStack */\n   0,                         /* sharedCacheEnabled */\n   SQLITE_SORTER_PMASZ,       /* szPma */\n   /* All the rest should always be initialized to zero */\n   0,                         /* isInit */\n   0,                         /* inProgress */\n   0,                         /* isMutexInit */\n   0,                         /* isMallocInit */\n   0,                         /* isPCacheInit */\n   0,                         /* nRefInitMutex */\n   0,                         /* pInitMutex */\n   0,                         /* xLog */\n   0,                         /* pLogArg */\n#ifdef SQLITE_ENABLE_SQLLOG\n   0,                         /* xSqllog */\n   0,                         /* pSqllogArg */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n   0,                         /* xVdbeBranch */\n   0,                         /* pVbeBranchArg */\n#endif\n#ifndef SQLITE_UNTESTABLE\n   0,                         /* xTestCallback */\n#endif\n   0,                         /* bLocaltimeFault */\n   0x7ffffffe                 /* iOnceResetThreshold */\n};\n\n/*\n** Hash table for global functions - functions common to all\n** database connections.  After initialization, this table is\n** read-only.\n*/\nFuncDefHash sqlite3BuiltinFunctions;\n\n/*\n** Constant tokens for values 0 and 1.\n*/\nconst Token sqlite3IntTokens[] = {\n   { \"0\", 1 },\n   { \"1\", 1 }\n};\n\n\n/*\n** The value of the \"pending\" byte must be 0x40000000 (1 byte past the\n** 1-gibabyte boundary) in a compatible database.  SQLite never uses\n** the database page that contains the pending byte.  It never attempts\n** to read or write that page.  The pending byte page is set aside\n** for use by the VFS layers as space for managing file locks.\n**\n** During testing, it is often desirable to move the pending byte to\n** a different position in the file.  This allows code that has to\n** deal with the pending byte to run on files that are much smaller\n** than 1 GiB.  The sqlite3_test_control() interface can be used to\n** move the pending byte.\n**\n** IMPORTANT:  Changing the pending byte to any value other than\n** 0x40000000 results in an incompatible database file format!\n** Changing the pending byte during operation will result in undefined\n** and incorrect behavior.\n*/\n#ifndef SQLITE_OMIT_WSD\nint sqlite3PendingByte = 0x40000000;\n#endif\n\n#include \"opcodes.h\"\n/*\n** Properties of opcodes.  The OPFLG_INITIALIZER macro is\n** created by mkopcodeh.awk during compilation.  Data is obtained\n** from the comments following the \"case OP_xxxx:\" statements in\n** the vdbe.c file.  \n*/\nconst unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;\n\n/*\n** Name of the default collating sequence\n*/\nconst char sqlite3StrBINARY[] = \"BINARY\";\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/hash.c",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of generic hash-tables\n** used in SQLite.\n*/\n#include \"sqliteInt.h\"\n#include <assert.h>\n\n/* Turn bulk memory into a hash table object by initializing the\n** fields of the Hash structure.\n**\n** \"pNew\" is a pointer to the hash table that is to be initialized.\n*/\nvoid sqlite3HashInit(Hash *pNew){\n  assert( pNew!=0 );\n  pNew->first = 0;\n  pNew->count = 0;\n  pNew->htsize = 0;\n  pNew->ht = 0;\n}\n\n/* Remove all entries from a hash table.  Reclaim all memory.\n** Call this routine to delete a hash table or to reset a hash table\n** to the empty state.\n*/\nvoid sqlite3HashClear(Hash *pH){\n  HashElem *elem;         /* For looping over all elements of the table */\n\n  assert( pH!=0 );\n  elem = pH->first;\n  pH->first = 0;\n  sqlite3_free(pH->ht);\n  pH->ht = 0;\n  pH->htsize = 0;\n  while( elem ){\n    HashElem *next_elem = elem->next;\n    sqlite3_free(elem);\n    elem = next_elem;\n  }\n  pH->count = 0;\n}\n\n/*\n** The hashing function.\n*/\nstatic unsigned int strHash(const char *z){\n  unsigned int h = 0;\n  unsigned char c;\n  while( (c = (unsigned char)*z++)!=0 ){     /*OPTIMIZATION-IF-TRUE*/\n    /* Knuth multiplicative hashing.  (Sorting & Searching, p. 510).\n    ** 0x9e3779b1 is 2654435761 which is the closest prime number to\n    ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */\n    h += sqlite3UpperToLower[c];\n    h *= 0x9e3779b1;\n  }\n  return h;\n}\n\n\n/* Link pNew element into the hash table pH.  If pEntry!=0 then also\n** insert pNew into the pEntry hash bucket.\n*/\nstatic void insertElement(\n  Hash *pH,              /* The complete hash table */\n  struct _ht *pEntry,    /* The entry into which pNew is inserted */\n  HashElem *pNew         /* The element to be inserted */\n){\n  HashElem *pHead;       /* First element already in pEntry */\n  if( pEntry ){\n    pHead = pEntry->count ? pEntry->chain : 0;\n    pEntry->count++;\n    pEntry->chain = pNew;\n  }else{\n    pHead = 0;\n  }\n  if( pHead ){\n    pNew->next = pHead;\n    pNew->prev = pHead->prev;\n    if( pHead->prev ){ pHead->prev->next = pNew; }\n    else             { pH->first = pNew; }\n    pHead->prev = pNew;\n  }else{\n    pNew->next = pH->first;\n    if( pH->first ){ pH->first->prev = pNew; }\n    pNew->prev = 0;\n    pH->first = pNew;\n  }\n}\n\n\n/* Resize the hash table so that it cantains \"new_size\" buckets.\n**\n** The hash table might fail to resize if sqlite3_malloc() fails or\n** if the new size is the same as the prior size.\n** Return TRUE if the resize occurs and false if not.\n*/\nstatic int rehash(Hash *pH, unsigned int new_size){\n  struct _ht *new_ht;            /* The new hash table */\n  HashElem *elem, *next_elem;    /* For looping over existing elements */\n\n#if SQLITE_MALLOC_SOFT_LIMIT>0\n  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){\n    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);\n  }\n  if( new_size==pH->htsize ) return 0;\n#endif\n\n  /* The inability to allocates space for a larger hash table is\n  ** a performance hit but it is not a fatal error.  So mark the\n  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of \n  ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()\n  ** only zeroes the requested number of bytes whereas this module will\n  ** use the actual amount of space allocated for the hash table (which\n  ** may be larger than the requested amount).\n  */\n  sqlite3BeginBenignMalloc();\n  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );\n  sqlite3EndBenignMalloc();\n\n  if( new_ht==0 ) return 0;\n  sqlite3_free(pH->ht);\n  pH->ht = new_ht;\n  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);\n  memset(new_ht, 0, new_size*sizeof(struct _ht));\n  for(elem=pH->first, pH->first=0; elem; elem = next_elem){\n    unsigned int h = strHash(elem->pKey) % new_size;\n    next_elem = elem->next;\n    insertElement(pH, &new_ht[h], elem);\n  }\n  return 1;\n}\n\n/* This function (for internal use only) locates an element in an\n** hash table that matches the given key.  If no element is found,\n** a pointer to a static null element with HashElem.data==0 is returned.\n** If pH is not NULL, then the hash for this key is written to *pH.\n*/\nstatic HashElem *findElementWithHash(\n  const Hash *pH,     /* The pH to be searched */\n  const char *pKey,   /* The key we are searching for */\n  unsigned int *pHash /* Write the hash value here */\n){\n  HashElem *elem;                /* Used to loop thru the element list */\n  int count;                     /* Number of elements left to test */\n  unsigned int h;                /* The computed hash */\n  static HashElem nullElement = { 0, 0, 0, 0 };\n\n  if( pH->ht ){   /*OPTIMIZATION-IF-TRUE*/\n    struct _ht *pEntry;\n    h = strHash(pKey) % pH->htsize;\n    pEntry = &pH->ht[h];\n    elem = pEntry->chain;\n    count = pEntry->count;\n  }else{\n    h = 0;\n    elem = pH->first;\n    count = pH->count;\n  }\n  if( pHash ) *pHash = h;\n  while( count-- ){\n    assert( elem!=0 );\n    if( sqlite3StrICmp(elem->pKey,pKey)==0 ){ \n      return elem;\n    }\n    elem = elem->next;\n  }\n  return &nullElement;\n}\n\n/* Remove a single entry from the hash table given a pointer to that\n** element and a hash on the element's key.\n*/\nstatic void removeElementGivenHash(\n  Hash *pH,         /* The pH containing \"elem\" */\n  HashElem* elem,   /* The element to be removed from the pH */\n  unsigned int h    /* Hash value for the element */\n){\n  struct _ht *pEntry;\n  if( elem->prev ){\n    elem->prev->next = elem->next; \n  }else{\n    pH->first = elem->next;\n  }\n  if( elem->next ){\n    elem->next->prev = elem->prev;\n  }\n  if( pH->ht ){\n    pEntry = &pH->ht[h];\n    if( pEntry->chain==elem ){\n      pEntry->chain = elem->next;\n    }\n    pEntry->count--;\n    assert( pEntry->count>=0 );\n  }\n  sqlite3_free( elem );\n  pH->count--;\n  if( pH->count==0 ){\n    assert( pH->first==0 );\n    assert( pH->count==0 );\n    sqlite3HashClear(pH);\n  }\n}\n\n/* Attempt to locate an element of the hash table pH with a key\n** that matches pKey.  Return the data for this element if it is\n** found, or NULL if there is no match.\n*/\nvoid *sqlite3HashFind(const Hash *pH, const char *pKey){\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  return findElementWithHash(pH, pKey, 0)->data;\n}\n\n/* Insert an element into the hash table pH.  The key is pKey\n** and the data is \"data\".\n**\n** If no element exists with a matching key, then a new\n** element is created and NULL is returned.\n**\n** If another element already exists with the same key, then the\n** new data replaces the old data and the old data is returned.\n** The key is not copied in this instance.  If a malloc fails, then\n** the new data is returned and the hash table is unchanged.\n**\n** If the \"data\" parameter to this function is NULL, then the\n** element corresponding to \"key\" is removed from the hash table.\n*/\nvoid *sqlite3HashInsert(Hash *pH, const char *pKey, void *data){\n  unsigned int h;       /* the hash of the key modulo hash table size */\n  HashElem *elem;       /* Used to loop thru the element list */\n  HashElem *new_elem;   /* New element added to the pH */\n\n  assert( pH!=0 );\n  assert( pKey!=0 );\n  elem = findElementWithHash(pH,pKey,&h);\n  if( elem->data ){\n    void *old_data = elem->data;\n    if( data==0 ){\n      removeElementGivenHash(pH,elem,h);\n    }else{\n      elem->data = data;\n      elem->pKey = pKey;\n    }\n    return old_data;\n  }\n  if( data==0 ) return 0;\n  new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );\n  if( new_elem==0 ) return data;\n  new_elem->pKey = pKey;\n  new_elem->data = data;\n  pH->count++;\n  if( pH->count>=10 && pH->count > 2*pH->htsize ){\n    if( rehash(pH, pH->count*2) ){\n      assert( pH->htsize>0 );\n      h = strHash(pKey) % pH->htsize;\n    }\n  }\n  insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/hash.h",
    "content": "/*\n** 2001 September 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for the generic hash-table implementation\n** used in SQLite.\n*/\n#ifndef SQLITE_HASH_H\n#define SQLITE_HASH_H\n\n/* Forward declarations of structures. */\ntypedef struct Hash Hash;\ntypedef struct HashElem HashElem;\n\n/* A complete hash table is an instance of the following structure.\n** The internals of this structure are intended to be opaque -- client\n** code should not attempt to access or modify the fields of this structure\n** directly.  Change this structure only by using the routines below.\n** However, some of the \"procedures\" and \"functions\" for modifying and\n** accessing this structure are really macros, so we can't really make\n** this structure opaque.\n**\n** All elements of the hash table are on a single doubly-linked list.\n** Hash.first points to the head of this list.\n**\n** There are Hash.htsize buckets.  Each bucket points to a spot in\n** the global doubly-linked list.  The contents of the bucket are the\n** element pointed to plus the next _ht.count-1 elements in the list.\n**\n** Hash.htsize and Hash.ht may be zero.  In that case lookup is done\n** by a linear search of the global list.  For small tables, the \n** Hash.ht table is never allocated because if there are few elements\n** in the table, it is faster to do a linear search than to manage\n** the hash table.\n*/\nstruct Hash {\n  unsigned int htsize;      /* Number of buckets in the hash table */\n  unsigned int count;       /* Number of entries in this table */\n  HashElem *first;          /* The first element of the array */\n  struct _ht {              /* the hash table */\n    int count;                 /* Number of entries with this hash */\n    HashElem *chain;           /* Pointer to first entry with this hash */\n  } *ht;\n};\n\n/* Each element in the hash table is an instance of the following \n** structure.  All elements are stored on a single doubly-linked list.\n**\n** Again, this structure is intended to be opaque, but it can't really\n** be opaque because it is used by macros.\n*/\nstruct HashElem {\n  HashElem *next, *prev;       /* Next and previous elements in the table */\n  void *data;                  /* Data associated with this element */\n  const char *pKey;            /* Key associated with this element */\n};\n\n/*\n** Access routines.  To delete, insert a NULL pointer.\n*/\nvoid sqlite3HashInit(Hash*);\nvoid *sqlite3HashInsert(Hash*, const char *pKey, void *pData);\nvoid *sqlite3HashFind(const Hash*, const char *pKey);\nvoid sqlite3HashClear(Hash*);\n\n/*\n** Macros for looping over all elements of a hash table.  The idiom is\n** like this:\n**\n**   Hash h;\n**   HashElem *p;\n**   ...\n**   for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){\n**     SomeStructure *pData = sqliteHashData(p);\n**     // do something with pData\n**   }\n*/\n#define sqliteHashFirst(H)  ((H)->first)\n#define sqliteHashNext(E)   ((E)->next)\n#define sqliteHashData(E)   ((E)->data)\n/* #define sqliteHashKey(E)    ((E)->pKey) // NOT USED */\n/* #define sqliteHashKeysize(E) ((E)->nKey)  // NOT USED */\n\n/*\n** Number of entries in a hash table\n*/\n/* #define sqliteHashCount(H)  ((H)->count) // NOT USED */\n\n#endif /* SQLITE_HASH_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/hwtime.h",
    "content": "/*\n** 2008 May 27\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains inline asm code for retrieving \"high-performance\"\n** counters for x86 class CPUs.\n*/\n#ifndef SQLITE_HWTIME_H\n#define SQLITE_HWTIME_H\n\n/*\n** The following routine only works on pentium-class (or newer) processors.\n** It uses the RDTSC opcode to read the cycle count value out of the\n** processor and returns that value.  This can be used for high-res\n** profiling.\n*/\n#if (defined(__GNUC__) || defined(_MSC_VER)) && \\\n      (defined(i386) || defined(__i386__) || defined(_M_IX86))\n\n  #if defined(__GNUC__)\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n     unsigned int lo, hi;\n     __asm__ __volatile__ (\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n     return (sqlite_uint64)hi << 32 | lo;\n  }\n\n  #elif defined(_MSC_VER)\n\n  __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){\n     __asm {\n        rdtsc\n        ret       ; return value at EDX:EAX\n     }\n  }\n\n  #endif\n\n#elif (defined(__GNUC__) && defined(__x86_64__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long val;\n      __asm__ __volatile__ (\"rdtsc\" : \"=A\" (val));\n      return val;\n  }\n \n#elif (defined(__GNUC__) && defined(__ppc__))\n\n  __inline__ sqlite_uint64 sqlite3Hwtime(void){\n      unsigned long long retval;\n      unsigned long junk;\n      __asm__ __volatile__ (\"\\n\\\n          1:      mftbu   %1\\n\\\n                  mftb    %L0\\n\\\n                  mftbu   %0\\n\\\n                  cmpw    %0,%1\\n\\\n                  bne     1b\"\n                  : \"=r\" (retval), \"=r\" (junk));\n      return retval;\n  }\n\n#else\n\n  #error Need implementation of sqlite3Hwtime() for your platform.\n\n  /*\n  ** To compile without implementing sqlite3Hwtime() for your platform,\n  ** you can remove the above #error and use the following\n  ** stub function.  You will lose timing support for many\n  ** of the debugging and testing utilities, but it should at\n  ** least compile and run.\n  */\n  sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); }\n\n#endif\n\n#endif /* !defined(SQLITE_HWTIME_H) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/in-operator.md",
    "content": "IN-Operator Implementation Notes\n================================\n\n## Definitions:\n\nAn IN operator has one of the following formats:\n\n>\n     x IN (y1,y2,y3,...,yN)\n     x IN (subquery)\n\nThe \"x\" is referred to as the LHS (left-hand side).  The list or subquery\non the right is called the RHS (right-hand side).  If the RHS is a list\nit must be a non-empty list.  But if the RHS is a subquery, it can be an\nempty set.\n\nThe LHS can be a scalar (a single quantity) or a vector (a list of\ntwo or or more values) or a subquery that returns one or more columns.\nWe use the term \"vector\" to mean an actually list of values or a\nsubquery that returns two or more columns.  An isolated value or\na subquery that returns a single columns is called a scalar.\n\nThe RHS can be a subquery that returns a single column, a subquery\nthat returns two or more columns, or a list of scalars.  It is not\ncurrently support for the RHS to be a list of vectors.\n\nThe number of columns for LHS must match the number of columns for\nthe RHS.  If the RHS is a list of values, then the LHS must be a \nscalar.  If the RHS is a subquery returning N columns, then the LHS\nmust be a vector of size N.\n\nNULL values can occur in either or both of the LHS and RHS.\nIf the LHS contains only\nNULL values then we say that it is a \"total-NULL\".  If the LHS contains\nsome NULL values and some non-NULL values, then it is a \"partial-NULL\".\nFor a scalar, there is no difference between a partial-NULL and a total-NULL.\nThe RHS is a partial-NULL if any row contains a NULL value.  The RHS is\na total-NULL if it contains one or more rows that contain only NULL values.\nThe LHS is called \"non-NULL\" if it contains no NULL values.  The RHS is\ncalled \"non-NULL\" if it contains no NULL values in any row.\n\nThe result of an IN operator is one of TRUE, FALSE, or NULL.  A NULL result\nmeans that it cannot be determined if the LHS is contained in the RHS due\nto the presence of NULL values.  In some contexts (for example, when the IN\noperator occurs in a WHERE clause)\nthe system only needs a binary result: TRUE or NOT-TRUE.  One can also\nto define a binary result of FALSE and NOT-FALSE, but\nit turns out that no extra optimizations are possible in that case, so if\nthe FALSE/NOT-FALSE binary is needed, we have to compute the three-state\nTRUE/FALSE/NULL result and then combine the TRUE and NULL values into \nNOT-FALSE.\n\nA \"NOT IN\" operator is computed by first computing the equivalent IN\noperator, then interchanging the TRUE and FALSE results.\n\n## Simple Full-Scan Algorithm\n\nThe following algorithm always compute the correct answer.  However, this\nalgorithm is suboptimal, especially if there are many rows on the RHS.\n\n  1.  Set the null-flag to false\n  2.  For each row in the RHS:\n      <ol type='a'>\n      <li>  Compare the LHS against the RHS\n      <li>  If the LHS exactly matches the RHS, immediately return TRUE\n      <li>  If the comparison result is NULL, set the null-flag to true\n      </ol>\n  3.  If the null-flag is true, return NULL.\n  4.  Return FALSE\n\n## Optimized Algorithm\n\nThe following procedure computes the same answer as the simple full-scan\nalgorithm, though it does so with less work in the common case.  This\nis the algorithm that is implemented in SQLite.\n\n  1.  If the RHS is a constant list of length 1 or 2, then rewrite the\n      IN operator as a simple expression.  Implement\n\n            x IN (y1,y2)\n\n      as if it were\n\n            x=y1 OR x=y2\n\n      This is the INDEX_NOOP optimization and is only undertaken if the\n      IN operator is used for membership testing.  If the IN operator is\n      driving a loop, then skip this step entirely.\n\n  2.  Check the LHS to see if it is a partial-NULL and if it is, jump\n      ahead to step 5.\n\n  3.  Do a binary search of the RHS using the LHS as a probe.  If\n      an exact match is found, return TRUE.\n\n  4.  If the RHS is non-NULL then return FALSE.\n\n  5.  If we do not need to distinguish between FALSE and NULL,\n      then return FALSE.\n  \n  6.  For each row in the RHS, compare that row against the LHS and\n      if the result is NULL, immediately return NULL.  In the case\n      of a scalar IN operator, we only need to look at the very first\n      row the RHS because for a scalar RHS, all NULLs will always come \n      first.  If the RHS is empty, this step is a no-op.\n\n  7.  Return FALSE.\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/insert.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle INSERT statements in SQLite.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Generate code that will \n**\n**   (1) acquire a lock for table pTab then\n**   (2) open pTab as cursor iCur.\n**\n** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index\n** for that table that is actually opened.\n*/\nvoid sqlite3OpenTable(\n  Parse *pParse,  /* Generate code into this VDBE */\n  int iCur,       /* The cursor number of the table */\n  int iDb,        /* The database index in sqlite3.aDb[] */\n  Table *pTab,    /* The table to be opened */\n  int opcode      /* OP_OpenRead or OP_OpenWrite */\n){\n  Vdbe *v;\n  assert( !IsVirtual(pTab) );\n  v = sqlite3GetVdbe(pParse);\n  assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );\n  sqlite3TableLock(pParse, iDb, pTab->tnum, \n                   (opcode==OP_OpenWrite)?1:0, pTab->zName);\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }else{\n    Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->tnum==pTab->tnum );\n    sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);\n    sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n    VdbeComment((v, \"%s\", pTab->zName));\n  }\n}\n\n/*\n** Return a pointer to the column affinity string associated with index\n** pIdx. A column affinity string has one character for each column in \n** the table, according to the affinity of the column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'F'            REAL\n**\n** An extra 'D' is appended to the end of the string to cover the\n** rowid that appears as the last column in every index.\n**\n** Memory for the buffer containing the column index affinity string\n** is managed along with the rest of the Index structure. It will be\n** released when sqlite3DeleteIndex() is called.\n*/\nconst char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){\n  if( !pIdx->zColAff ){\n    /* The first time a column affinity string for a particular index is\n    ** required, it is allocated and populated here. It is then stored as\n    ** a member of the Index structure for subsequent use.\n    **\n    ** The column affinity string will eventually be deleted by\n    ** sqliteDeleteIndex() when the Index structure itself is cleaned\n    ** up.\n    */\n    int n;\n    Table *pTab = pIdx->pTable;\n    pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1);\n    if( !pIdx->zColAff ){\n      sqlite3OomFault(db);\n      return 0;\n    }\n    for(n=0; n<pIdx->nColumn; n++){\n      i16 x = pIdx->aiColumn[n];\n      if( x>=0 ){\n        pIdx->zColAff[n] = pTab->aCol[x].affinity;\n      }else if( x==XN_ROWID ){\n        pIdx->zColAff[n] = SQLITE_AFF_INTEGER;\n      }else{\n        char aff;\n        assert( x==XN_EXPR );\n        assert( pIdx->aColExpr!=0 );\n        aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr);\n        if( aff==0 ) aff = SQLITE_AFF_BLOB;\n        pIdx->zColAff[n] = aff;\n      }\n    }\n    pIdx->zColAff[n] = 0;\n  }\n \n  return pIdx->zColAff;\n}\n\n/*\n** Compute the affinity string for table pTab, if it has not already been\n** computed.  As an optimization, omit trailing SQLITE_AFF_BLOB affinities.\n**\n** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and\n** if iReg>0 then code an OP_Affinity opcode that will set the affinities\n** for register iReg and following.  Or if affinities exists and iReg==0,\n** then just set the P4 operand of the previous opcode (which should  be\n** an OP_MakeRecord) to the affinity string.\n**\n** A column affinity string has one character per column:\n**\n**  Character      Column affinity\n**  ------------------------------\n**  'A'            BLOB\n**  'B'            TEXT\n**  'C'            NUMERIC\n**  'D'            INTEGER\n**  'E'            REAL\n*/\nvoid sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){\n  int i;\n  char *zColAff = pTab->zColAff;\n  if( zColAff==0 ){\n    sqlite3 *db = sqlite3VdbeDb(v);\n    zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1);\n    if( !zColAff ){\n      sqlite3OomFault(db);\n      return;\n    }\n\n    for(i=0; i<pTab->nCol; i++){\n      zColAff[i] = pTab->aCol[i].affinity;\n    }\n    do{\n      zColAff[i--] = 0;\n    }while( i>=0 && zColAff[i]==SQLITE_AFF_BLOB );\n    pTab->zColAff = zColAff;\n  }\n  i = sqlite3Strlen30(zColAff);\n  if( i ){\n    if( iReg ){\n      sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i);\n    }else{\n      sqlite3VdbeChangeP4(v, -1, zColAff, i);\n    }\n  }\n}\n\n/*\n** Return non-zero if the table pTab in database iDb or any of its indices\n** have been opened at any point in the VDBE program. This is used to see if \n** a statement of the form  \"INSERT INTO <iDb, pTab> SELECT ...\" can \n** run without using a temporary table for the results of the SELECT. \n*/\nstatic int readsTable(Parse *p, int iDb, Table *pTab){\n  Vdbe *v = sqlite3GetVdbe(p);\n  int i;\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  VTable *pVTab = IsVirtual(pTab) ? sqlite3GetVTable(p->db, pTab) : 0;\n#endif\n\n  for(i=1; i<iEnd; i++){\n    VdbeOp *pOp = sqlite3VdbeGetOp(v, i);\n    assert( pOp!=0 );\n    if( pOp->opcode==OP_OpenRead && pOp->p3==iDb ){\n      Index *pIndex;\n      int tnum = pOp->p2;\n      if( tnum==pTab->tnum ){\n        return 1;\n      }\n      for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){\n        if( tnum==pIndex->tnum ){\n          return 1;\n        }\n      }\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( pOp->opcode==OP_VOpen && pOp->p4.pVtab==pVTab ){\n      assert( pOp->p4.pVtab!=0 );\n      assert( pOp->p4type==P4_VTAB );\n      return 1;\n    }\n#endif\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/*\n** Locate or create an AutoincInfo structure associated with table pTab\n** which is in database iDb.  Return the register number for the register\n** that holds the maximum rowid.  Return zero if pTab is not an AUTOINCREMENT\n** table.  (Also return zero when doing a VACUUM since we do not want to\n** update the AUTOINCREMENT counters during a VACUUM.)\n**\n** There is at most one AutoincInfo structure per table even if the\n** same table is autoincremented multiple times due to inserts within\n** triggers.  A new AutoincInfo structure is created if this is the\n** first use of table pTab.  On 2nd and subsequent uses, the original\n** AutoincInfo structure is used.\n**\n** Three memory locations are allocated:\n**\n**   (1)  Register to hold the name of the pTab table.\n**   (2)  Register to hold the maximum ROWID of pTab.\n**   (3)  Register to hold the rowid in sqlite_sequence of pTab\n**\n** The 2nd register is the one that is returned.  That is all the\n** insert routine needs to know about.\n*/\nstatic int autoIncBegin(\n  Parse *pParse,      /* Parsing context */\n  int iDb,            /* Index of the database holding pTab */\n  Table *pTab         /* The table we are writing to */\n){\n  int memId = 0;      /* Register holding maximum rowid */\n  if( (pTab->tabFlags & TF_Autoincrement)!=0\n   && (pParse->db->mDbFlags & DBFLAG_Vacuum)==0\n  ){\n    Parse *pToplevel = sqlite3ParseToplevel(pParse);\n    AutoincInfo *pInfo;\n\n    pInfo = pToplevel->pAinc;\n    while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }\n    if( pInfo==0 ){\n      pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo));\n      if( pInfo==0 ) return 0;\n      pInfo->pNext = pToplevel->pAinc;\n      pToplevel->pAinc = pInfo;\n      pInfo->pTab = pTab;\n      pInfo->iDb = iDb;\n      pToplevel->nMem++;                  /* Register to hold name of table */\n      pInfo->regCtr = ++pToplevel->nMem;  /* Max rowid register */\n      pToplevel->nMem++;                  /* Rowid in sqlite_sequence */\n    }\n    memId = pInfo->regCtr;\n  }\n  return memId;\n}\n\n/*\n** This routine generates code that will initialize all of the\n** register used by the autoincrement tracker.  \n*/\nvoid sqlite3AutoincrementBegin(Parse *pParse){\n  AutoincInfo *p;            /* Information about an AUTOINCREMENT */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  Db *pDb;                   /* Database only autoinc table */\n  int memId;                 /* Register holding max rowid */\n  Vdbe *v = pParse->pVdbe;   /* VDBE under construction */\n\n  /* This routine is never called during trigger-generation.  It is\n  ** only called from the top-level */\n  assert( pParse->pTriggerTab==0 );\n  assert( sqlite3IsToplevel(pParse) );\n\n  assert( v );   /* We failed long ago if this is not so */\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoInc[] = {\n      /* 0  */ {OP_Null,    0,  0, 0},\n      /* 1  */ {OP_Rewind,  0,  9, 0},\n      /* 2  */ {OP_Column,  0,  0, 0},\n      /* 3  */ {OP_Ne,      0,  7, 0},\n      /* 4  */ {OP_Rowid,   0,  0, 0},\n      /* 5  */ {OP_Column,  0,  1, 0},\n      /* 6  */ {OP_Goto,    0,  9, 0},\n      /* 7  */ {OP_Next,    0,  2, 0},\n      /* 8  */ {OP_Integer, 0,  0, 0},\n      /* 9  */ {OP_Close,   0,  0, 0} \n    };\n    VdbeOp *aOp;\n    pDb = &db->aDb[p->iDb];\n    memId = p->regCtr;\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead);\n    sqlite3VdbeLoadString(v, memId-1, p->pTab->zName);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoInc), autoInc, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p2 = memId;\n    aOp[0].p3 = memId+1;\n    aOp[2].p3 = memId;\n    aOp[3].p1 = memId-1;\n    aOp[3].p3 = memId;\n    aOp[3].p5 = SQLITE_JUMPIFNULL;\n    aOp[4].p2 = memId+1;\n    aOp[5].p3 = memId;\n    aOp[8].p2 = memId;\n  }\n}\n\n/*\n** Update the maximum rowid for an autoincrement calculation.\n**\n** This routine should be called when the regRowid register holds a\n** new rowid that is about to be inserted.  If that new rowid is\n** larger than the maximum rowid in the memId memory cell, then the\n** memory cell is updated.\n*/\nstatic void autoIncStep(Parse *pParse, int memId, int regRowid){\n  if( memId>0 ){\n    sqlite3VdbeAddOp2(pParse->pVdbe, OP_MemMax, memId, regRowid);\n  }\n}\n\n/*\n** This routine generates the code needed to write autoincrement\n** maximum rowid values back into the sqlite_sequence register.\n** Every statement that might do an INSERT into an autoincrement\n** table (either directly or through triggers) needs to call this\n** routine just before the \"exit\" code.\n*/\nstatic SQLITE_NOINLINE void autoIncrementEnd(Parse *pParse){\n  AutoincInfo *p;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( v );\n  for(p = pParse->pAinc; p; p = p->pNext){\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList autoIncEnd[] = {\n      /* 0 */ {OP_NotNull,     0, 2, 0},\n      /* 1 */ {OP_NewRowid,    0, 0, 0},\n      /* 2 */ {OP_MakeRecord,  0, 2, 0},\n      /* 3 */ {OP_Insert,      0, 0, 0},\n      /* 4 */ {OP_Close,       0, 0, 0}\n    };\n    VdbeOp *aOp;\n    Db *pDb = &db->aDb[p->iDb];\n    int iRec;\n    int memId = p->regCtr;\n\n    iRec = sqlite3GetTempReg(pParse);\n    assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) );\n    sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenWrite);\n    aOp = sqlite3VdbeAddOpList(v, ArraySize(autoIncEnd), autoIncEnd, iLn);\n    if( aOp==0 ) break;\n    aOp[0].p1 = memId+1;\n    aOp[1].p2 = memId+1;\n    aOp[2].p1 = memId-1;\n    aOp[2].p3 = iRec;\n    aOp[3].p2 = iRec;\n    aOp[3].p3 = memId+1;\n    aOp[3].p5 = OPFLAG_APPEND;\n    sqlite3ReleaseTempReg(pParse, iRec);\n  }\n}\nvoid sqlite3AutoincrementEnd(Parse *pParse){\n  if( pParse->pAinc ) autoIncrementEnd(pParse);\n}\n#else\n/*\n** If SQLITE_OMIT_AUTOINCREMENT is defined, then the three routines\n** above are all no-ops\n*/\n# define autoIncBegin(A,B,C) (0)\n# define autoIncStep(A,B,C)\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n\n/* Forward declaration */\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n);\n\n/*\n** This routine is called to handle SQL of the following forms:\n**\n**    insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...\n**    insert into TABLE (IDLIST) select\n**    insert into TABLE (IDLIST) default values\n**\n** The IDLIST following the table name is always optional.  If omitted,\n** then a list of all (non-hidden) columns for the table is substituted.\n** The IDLIST appears in the pColumn parameter.  pColumn is NULL if IDLIST\n** is omitted.\n**\n** For the pSelect parameter holds the values to be inserted for the\n** first two forms shown above.  A VALUES clause is really just short-hand\n** for a SELECT statement that omits the FROM clause and everything else\n** that follows.  If the pSelect parameter is NULL, that means that the\n** DEFAULT VALUES form of the INSERT statement is intended.\n**\n** The code generated follows one of four templates.  For a simple\n** insert with data coming from a single-row VALUES clause, the code executes\n** once straight down through.  Pseudo-code follows (we call this\n** the \"1st template\"):\n**\n**         open write cursor to <table> and its indices\n**         put VALUES clause expressions into registers\n**         write the resulting record into <table>\n**         cleanup\n**\n** The three remaining templates assume the statement is of the form\n**\n**   INSERT INTO <table> SELECT ...\n**\n** If the SELECT clause is of the restricted form \"SELECT * FROM <table2>\" -\n** in other words if the SELECT pulls all columns from a single table\n** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and\n** if <table2> and <table1> are distinct tables but have identical\n** schemas, including all the same indices, then a special optimization\n** is invoked that copies raw records from <table2> over to <table1>.\n** See the xferOptimization() function for the implementation of this\n** template.  This is the 2nd template.\n**\n**         open a write cursor to <table>\n**         open read cursor on <table2>\n**         transfer all records in <table2> over to <table>\n**         close cursors\n**         foreach index on <table>\n**           open a write cursor on the <table> index\n**           open a read cursor on the corresponding <table2> index\n**           transfer all records from the read to the write cursors\n**           close cursors\n**         end foreach\n**\n** The 3rd template is for when the second template does not apply\n** and the SELECT clause does not read from <table> at any time.\n** The generated code follows this template:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the rows in the SELECT\n**           load values into registers R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end-coroutine X\n**      B: open write cursor to <table> and its indices\n**      C: yield X, at EOF goto D\n**         insert the select result into <table> from R..R+n\n**         goto C\n**      D: cleanup\n**\n** The 4th template is used if the insert statement takes its\n** values from a SELECT but the data is being inserted into a table\n** that is also read as part of the SELECT.  In the third form,\n** we have to use an intermediate table to store the results of\n** the select.  The template is like this:\n**\n**         X <- A\n**         goto B\n**      A: setup for the SELECT\n**         loop over the tables in the SELECT\n**           load value into register R..R+n\n**           yield X\n**         end loop\n**         cleanup after the SELECT\n**         end co-routine R\n**      B: open temp table\n**      L: yield X, at EOF goto M\n**         insert row from R..R+n into temp table\n**         goto L\n**      M: open write cursor to <table> and its indices\n**         rewind temp table\n**      C: loop over rows of intermediate table\n**           transfer values form intermediate table into <table>\n**         end loop\n**      D: cleanup\n*/\nvoid sqlite3Insert(\n  Parse *pParse,        /* Parser context */\n  SrcList *pTabList,    /* Name of table into which we are inserting */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  IdList *pColumn,      /* Column names corresponding to IDLIST. */\n  int onError           /* How to handle constraint errors */\n){\n  sqlite3 *db;          /* The main database structure */\n  Table *pTab;          /* The table to insert into.  aka TABLE */\n  int i, j;             /* Loop counters */\n  Vdbe *v;              /* Generate code into this virtual machine */\n  Index *pIdx;          /* For looping over indices of the table */\n  int nColumn;          /* Number of columns in the data */\n  int nHidden = 0;      /* Number of hidden columns if TABLE is virtual */\n  int iDataCur = 0;     /* VDBE cursor that is the main data repository */\n  int iIdxCur = 0;      /* First index cursor */\n  int ipkColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */\n  int endOfLoop;        /* Label for the end of the insertion loop */\n  int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */\n  int addrInsTop = 0;   /* Jump to label \"D\" */\n  int addrCont = 0;     /* Top of insert loop. Label \"C\" in templates 3 and 4 */\n  SelectDest dest;      /* Destination for SELECT on rhs of INSERT */\n  int iDb;              /* Index of database holding TABLE */\n  u8 useTempTable = 0;  /* Store SELECT results in intermediate table */\n  u8 appendFlag = 0;    /* True if the insert is likely to be an append */\n  u8 withoutRowid;      /* 0 for normal table.  1 for WITHOUT ROWID table */\n  u8 bIdListInOrder;    /* True if IDLIST is in table order */\n  ExprList *pList = 0;  /* List of VALUES() to be inserted  */\n\n  /* Register allocations */\n  int regFromSelect = 0;/* Base register for data coming from SELECT */\n  int regAutoinc = 0;   /* Register holding the AUTOINCREMENT counter */\n  int regRowCount = 0;  /* Memory cell used for the row counter */\n  int regIns;           /* Block of regs holding rowid+data being inserted */\n  int regRowid;         /* registers holding insert rowid */\n  int regData;          /* register holding first column to insert */\n  int *aRegIdx = 0;     /* One register allocated to each index */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;                 /* True if attempting to insert into a view */\n  Trigger *pTrigger;          /* List of triggers on pTab, if required */\n  int tmask;                  /* Mask of trigger times */\n#endif\n\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto insert_cleanup;\n  }\n  dest.iSDParm = 0;  /* Suppress a harmless compiler warning */\n\n  /* If the Select object is really just a simple VALUES() list with a\n  ** single row (the common case) then keep that one row of values\n  ** and discard the other (unused) parts of the pSelect object\n  */\n  if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){\n    pList = pSelect->pEList;\n    pSelect->pEList = 0;\n    sqlite3SelectDelete(db, pSelect);\n    pSelect = 0;\n  }\n\n  /* Locate the table into which we will be inserting new information.\n  */\n  assert( pTabList->nSrc==1 );\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ){\n    goto insert_cleanup;\n  }\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  assert( iDb<db->nDb );\n  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0,\n                       db->aDb[iDb].zDbSName) ){\n    goto insert_cleanup;\n  }\n  withoutRowid = !HasRowid(pTab);\n\n  /* Figure out if we have any triggers and if the table being\n  ** inserted into is a view\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask);\n  isView = pTab->pSelect!=0;\n#else\n# define pTrigger 0\n# define tmask 0\n# define isView 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n  assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) );\n\n  /* If pTab is really a view, make sure it has been initialized.\n  ** ViewGetColumnNames() is a no-op if pTab is not a view.\n  */\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto insert_cleanup;\n  }\n\n  /* Cannot insert into a read-only table.\n  */\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto insert_cleanup;\n  }\n\n  /* Allocate a VDBE\n  */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto insert_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, pSelect || pTrigger, iDb);\n\n#ifndef SQLITE_OMIT_XFER_OPT\n  /* If the statement is of the form\n  **\n  **       INSERT INTO <table1> SELECT * FROM <table2>;\n  **\n  ** Then special optimizations can be applied that make the transfer\n  ** very fast and which reduce fragmentation of indices.\n  **\n  ** This is the 2nd template.\n  */\n  if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){\n    assert( !pTrigger );\n    assert( pList==0 );\n    goto insert_end;\n  }\n#endif /* SQLITE_OMIT_XFER_OPT */\n\n  /* If this is an AUTOINCREMENT table, look up the sequence number in the\n  ** sqlite_sequence table and store it in memory cell regAutoinc.\n  */\n  regAutoinc = autoIncBegin(pParse, iDb, pTab);\n\n  /* Allocate registers for holding the rowid of the new row,\n  ** the content of the new row, and the assembled row record.\n  */\n  regRowid = regIns = pParse->nMem+1;\n  pParse->nMem += pTab->nCol + 1;\n  if( IsVirtual(pTab) ){\n    regRowid++;\n    pParse->nMem++;\n  }\n  regData = regRowid+1;\n\n  /* If the INSERT statement included an IDLIST term, then make sure\n  ** all elements of the IDLIST really are columns of the table and \n  ** remember the column indices.\n  **\n  ** If the table has an INTEGER PRIMARY KEY column and that column\n  ** is named in the IDLIST, then record in the ipkColumn variable\n  ** the index into IDLIST of the primary key column.  ipkColumn is\n  ** the index of the primary key as it appears in IDLIST, not as\n  ** is appears in the original table.  (The index of the INTEGER\n  ** PRIMARY KEY in the original table is pTab->iPKey.)\n  */\n  bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;\n  if( pColumn ){\n    for(i=0; i<pColumn->nId; i++){\n      pColumn->a[i].idx = -1;\n    }\n    for(i=0; i<pColumn->nId; i++){\n      for(j=0; j<pTab->nCol; j++){\n        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){\n          pColumn->a[i].idx = j;\n          if( i!=j ) bIdListInOrder = 0;\n          if( j==pTab->iPKey ){\n            ipkColumn = i;  assert( !withoutRowid );\n          }\n          break;\n        }\n      }\n      if( j>=pTab->nCol ){\n        if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){\n          ipkColumn = i;\n          bIdListInOrder = 0;\n        }else{\n          sqlite3ErrorMsg(pParse, \"table %S has no column named %s\",\n              pTabList, 0, pColumn->a[i].zName);\n          pParse->checkSchema = 1;\n          goto insert_cleanup;\n        }\n      }\n    }\n  }\n\n  /* Figure out how many columns of data are supplied.  If the data\n  ** is coming from a SELECT statement, then generate a co-routine that\n  ** produces a single row of the SELECT on each invocation.  The\n  ** co-routine is the common header to the 3rd and 4th templates.\n  */\n  if( pSelect ){\n    /* Data is coming from a SELECT or from a multi-row VALUES clause.\n    ** Generate a co-routine to run the SELECT. */\n    int regYield;       /* Register holding co-routine entry-point */\n    int addrTop;        /* Top of the co-routine */\n    int rc;             /* Result code */\n\n    regYield = ++pParse->nMem;\n    addrTop = sqlite3VdbeCurrentAddr(v) + 1;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);\n    sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);\n    dest.iSdst = bIdListInOrder ? regData : 0;\n    dest.nSdst = pTab->nCol;\n    rc = sqlite3Select(pParse, pSelect, &dest);\n    regFromSelect = dest.iSdst;\n    if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;\n    sqlite3VdbeEndCoroutine(v, regYield);\n    sqlite3VdbeJumpHere(v, addrTop - 1);                       /* label B: */\n    assert( pSelect->pEList );\n    nColumn = pSelect->pEList->nExpr;\n\n    /* Set useTempTable to TRUE if the result of the SELECT statement\n    ** should be written into a temporary table (template 4).  Set to\n    ** FALSE if each output row of the SELECT can be written directly into\n    ** the destination table (template 3).\n    **\n    ** A temp table must be used if the table being updated is also one\n    ** of the tables being read by the SELECT statement.  Also use a \n    ** temp table in the case of row triggers.\n    */\n    if( pTrigger || readsTable(pParse, iDb, pTab) ){\n      useTempTable = 1;\n    }\n\n    if( useTempTable ){\n      /* Invoke the coroutine to extract information from the SELECT\n      ** and add it to a transient table srcTab.  The code generated\n      ** here is from the 4th template:\n      **\n      **      B: open temp table\n      **      L: yield X, goto M at EOF\n      **         insert row from R..R+n into temp table\n      **         goto L\n      **      M: ...\n      */\n      int regRec;          /* Register to hold packed record */\n      int regTempRowid;    /* Register to hold temp table ROWID */\n      int addrL;           /* Label \"L\" */\n\n      srcTab = pParse->nTab++;\n      regRec = sqlite3GetTempReg(pParse);\n      regTempRowid = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn);\n      addrL = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid);\n      sqlite3VdbeGoto(v, addrL);\n      sqlite3VdbeJumpHere(v, addrL);\n      sqlite3ReleaseTempReg(pParse, regRec);\n      sqlite3ReleaseTempReg(pParse, regTempRowid);\n    }\n  }else{\n    /* This is the case if the data for the INSERT is coming from a \n    ** single-row VALUES clause\n    */\n    NameContext sNC;\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    srcTab = -1;\n    assert( useTempTable==0 );\n    if( pList ){\n      nColumn = pList->nExpr;\n      if( sqlite3ResolveExprListNames(&sNC, pList) ){\n        goto insert_cleanup;\n      }\n    }else{\n      nColumn = 0;\n    }\n  }\n\n  /* If there is no IDLIST term but the table has an integer primary\n  ** key, the set the ipkColumn variable to the integer primary key \n  ** column index in the original table definition.\n  */\n  if( pColumn==0 && nColumn>0 ){\n    ipkColumn = pTab->iPKey;\n  }\n\n  /* Make sure the number of columns in the source data matches the number\n  ** of columns to be inserted into the table.\n  */\n  for(i=0; i<pTab->nCol; i++){\n    nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);\n  }\n  if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){\n    sqlite3ErrorMsg(pParse, \n       \"table %S has %d columns but %d values were supplied\",\n       pTabList, 0, pTab->nCol-nHidden, nColumn);\n    goto insert_cleanup;\n  }\n  if( pColumn!=0 && nColumn!=pColumn->nId ){\n    sqlite3ErrorMsg(pParse, \"%d values for %d columns\", nColumn, pColumn->nId);\n    goto insert_cleanup;\n  }\n    \n  /* Initialize the count of rows to be inserted\n  */\n  if( db->flags & SQLITE_CountRows ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  /* If this is not a view, open the table and and all indices */\n  if( !isView ){\n    int nIdx;\n    nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, -1, 0,\n                                      &iDataCur, &iIdxCur);\n    aRegIdx = sqlite3DbMallocRawNN(db, sizeof(int)*(nIdx+1));\n    if( aRegIdx==0 ){\n      goto insert_cleanup;\n    }\n    for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){\n      assert( pIdx );\n      aRegIdx[i] = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }\n  }\n\n  /* This is the top of the main insertion loop */\n  if( useTempTable ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 4):\n    **\n    **         rewind temp table, if empty goto D\n    **      C: loop over rows of intermediate table\n    **           transfer values form intermediate table into <table>\n    **         end loop\n    **      D: ...\n    */\n    addrInsTop = sqlite3VdbeAddOp1(v, OP_Rewind, srcTab); VdbeCoverage(v);\n    addrCont = sqlite3VdbeCurrentAddr(v);\n  }else if( pSelect ){\n    /* This block codes the top of loop only.  The complete loop is the\n    ** following pseudocode (template 3):\n    **\n    **      C: yield X, at EOF goto D\n    **         insert the select result into <table> from R..R+n\n    **         goto C\n    **      D: ...\n    */\n    addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);\n    VdbeCoverage(v);\n  }\n\n  /* Run the BEFORE and INSTEAD OF triggers, if there are any\n  */\n  endOfLoop = sqlite3VdbeMakeLabel(v);\n  if( tmask & TRIGGER_BEFORE ){\n    int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);\n\n    /* build the NEW.* reference row.  Note that if there is an INTEGER\n    ** PRIMARY KEY into which a NULL is being inserted, that NULL will be\n    ** translated into a unique ID for the row.  But on a BEFORE trigger,\n    ** we do not know what the unique ID will be (because the insert has\n    ** not happened yet) so we substitute a rowid of -1\n    */\n    if( ipkColumn<0 ){\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n    }else{\n      int addr1;\n      assert( !withoutRowid );\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regCols);\n      }else{\n        assert( pSelect==0 );  /* Otherwise useTempTable is true */\n        sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols);\n      }\n      addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); VdbeCoverage(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols);\n      sqlite3VdbeJumpHere(v, addr1);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v);\n    }\n\n    /* Cannot have triggers on a virtual table. If it were possible,\n    ** this block would have to account for hidden column.\n    */\n    assert( !IsVirtual(pTab) );\n\n    /* Create the new column data\n    */\n    for(i=j=0; i<pTab->nCol; i++){\n      if( pColumn ){\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( (!useTempTable && !pList) || (pColumn && j>=pColumn->nId)\n            || (pColumn==0 && IsOrdinaryHiddenColumn(&pTab->aCol[i])) ){\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regCols+i+1);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, regCols+i+1); \n      }else{\n        assert( pSelect==0 ); /* Otherwise useTempTable is true */\n        sqlite3ExprCodeAndCache(pParse, pList->a[j].pExpr, regCols+i+1);\n      }\n      if( pColumn==0 && !IsOrdinaryHiddenColumn(&pTab->aCol[i]) ) j++;\n    }\n\n    /* If this is an INSERT on a view with an INSTEAD OF INSERT trigger,\n    ** do not attempt any conversions before assembling the record.\n    ** If this is a real table, attempt conversions as required by the\n    ** table column affinities.\n    */\n    if( !isView ){\n      sqlite3TableAffinity(v, pTab, regCols+1);\n    }\n\n    /* Fire BEFORE or INSTEAD OF triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE, \n        pTab, regCols-pTab->nCol-1, onError, endOfLoop);\n\n    sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);\n  }\n\n  /* Compute the content of the next row to insert into a range of\n  ** registers beginning at regIns.\n  */\n  if( !isView ){\n    if( IsVirtual(pTab) ){\n      /* The row that the VUpdate opcode will delete: none */\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regIns);\n    }\n    if( ipkColumn>=0 ){\n      if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid);\n      }else if( pSelect ){\n        sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);\n      }else{\n        VdbeOp *pOp;\n        sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);\n        pOp = sqlite3VdbeGetOp(v, -1);\n        if( ALWAYS(pOp) && pOp->opcode==OP_Null && !IsVirtual(pTab) ){\n          appendFlag = 1;\n          pOp->opcode = OP_NewRowid;\n          pOp->p1 = iDataCur;\n          pOp->p2 = regRowid;\n          pOp->p3 = regAutoinc;\n        }\n      }\n      /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid\n      ** to generate a unique primary key value.\n      */\n      if( !appendFlag ){\n        int addr1;\n        if( !IsVirtual(pTab) ){\n          addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); VdbeCoverage(v);\n          sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n          sqlite3VdbeJumpHere(v, addr1);\n        }else{\n          addr1 = sqlite3VdbeCurrentAddr(v);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, addr1+2); VdbeCoverage(v);\n        }\n        sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); VdbeCoverage(v);\n      }\n    }else if( IsVirtual(pTab) || withoutRowid ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);\n      appendFlag = 1;\n    }\n    autoIncStep(pParse, regAutoinc, regRowid);\n\n    /* Compute data for all columns of the new entry, beginning\n    ** with the first column.\n    */\n    nHidden = 0;\n    for(i=0; i<pTab->nCol; i++){\n      int iRegStore = regRowid+1+i;\n      if( i==pTab->iPKey ){\n        /* The value of the INTEGER PRIMARY KEY column is always a NULL.\n        ** Whenever this column is read, the rowid will be substituted\n        ** in its place.  Hence, fill this column with a NULL to avoid\n        ** taking up data space with information that will never be used.\n        ** As there may be shallow copies of this value, make it a soft-NULL */\n        sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);\n        continue;\n      }\n      if( pColumn==0 ){\n        if( IsHiddenColumn(&pTab->aCol[i]) ){\n          j = -1;\n          nHidden++;\n        }else{\n          j = i - nHidden;\n        }\n      }else{\n        for(j=0; j<pColumn->nId; j++){\n          if( pColumn->a[j].idx==i ) break;\n        }\n      }\n      if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){\n        sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore);\n      }else if( useTempTable ){\n        sqlite3VdbeAddOp3(v, OP_Column, srcTab, j, iRegStore); \n      }else if( pSelect ){\n        if( regFromSelect!=regData ){\n          sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+j, iRegStore);\n        }\n      }else{\n        sqlite3ExprCode(pParse, pList->a[j].pExpr, iRegStore);\n      }\n    }\n\n    /* Generate code to check constraints and generate index keys and\n    ** do the insertion.\n    */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pTab) ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      sqlite3VtabMakeWritable(pParse, pTab);\n      sqlite3VdbeAddOp4(v, OP_VUpdate, 1, pTab->nCol+2, regIns, pVTab, P4_VTAB);\n      sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n      sqlite3MayAbort(pParse);\n    }else\n#endif\n    {\n      int isReplace;    /* Set to true if constraints may cause a replace */\n      int bUseSeek;     /* True to use OPFLAG_SEEKRESULT */\n      sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0\n      );\n      sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);\n\n      /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE\n      ** constraints or (b) there are no triggers and this table is not a\n      ** parent table in a foreign key constraint. It is safe to set the\n      ** flag in the second case as if any REPLACE constraint is hit, an\n      ** OP_Delete or OP_IdxDelete instruction will be executed on each \n      ** cursor that is disturbed. And these instructions both clear the\n      ** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT\n      ** functionality.  */\n      bUseSeek = (isReplace==0 || (pTrigger==0 &&\n          ((db->flags & SQLITE_ForeignKeys)==0 || sqlite3FkReferences(pTab)==0)\n      ));\n      sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur,\n          regIns, aRegIdx, 0, appendFlag, bUseSeek\n      );\n    }\n  }\n\n  /* Update the count of rows that are inserted\n  */\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  if( pTrigger ){\n    /* Code AFTER triggers */\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, \n        pTab, regData-2-pTab->nCol, onError, endOfLoop);\n  }\n\n  /* The bottom of the main insertion loop, if the data source\n  ** is a SELECT statement.\n  */\n  sqlite3VdbeResolveLabel(v, endOfLoop);\n  if( useTempTable ){\n    sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n    sqlite3VdbeAddOp1(v, OP_Close, srcTab);\n  }else if( pSelect ){\n    sqlite3VdbeGoto(v, addrCont);\n    sqlite3VdbeJumpHere(v, addrInsTop);\n  }\n\ninsert_end:\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows inserted. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows inserted\", SQLITE_STATIC);\n  }\n\ninsert_cleanup:\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pList);\n  sqlite3SelectDelete(db, pSelect);\n  sqlite3IdListDelete(db, pColumn);\n  sqlite3DbFree(db, aRegIdx);\n}\n\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n#ifdef tmask\n #undef tmask\n#endif\n\n/*\n** Meanings of bits in of pWalker->eCode for checkConstraintUnchanged()\n*/\n#define CKCNSTRNT_COLUMN   0x01    /* CHECK constraint uses a changing column */\n#define CKCNSTRNT_ROWID    0x02    /* CHECK constraint references the ROWID */\n\n/* This is the Walker callback from checkConstraintUnchanged().  Set\n** bit 0x01 of pWalker->eCode if\n** pWalker->eCode to 0 if this expression node references any of the\n** columns that are being modifed by an UPDATE statement.\n*/\nstatic int checkConstraintExprNode(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_COLUMN ){\n    assert( pExpr->iColumn>=0 || pExpr->iColumn==-1 );\n    if( pExpr->iColumn>=0 ){\n      if( pWalker->u.aiCol[pExpr->iColumn]>=0 ){\n        pWalker->eCode |= CKCNSTRNT_COLUMN;\n      }\n    }else{\n      pWalker->eCode |= CKCNSTRNT_ROWID;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** pExpr is a CHECK constraint on a row that is being UPDATE-ed.  The\n** only columns that are modified by the UPDATE are those for which\n** aiChng[i]>=0, and also the ROWID is modified if chngRowid is true.\n**\n** Return true if CHECK constraint pExpr does not use any of the\n** changing columns (or the rowid if it is changing).  In other words,\n** return true if this CHECK constraint can be skipped when validating\n** the new row in the UPDATE statement.\n*/\nstatic int checkConstraintUnchanged(Expr *pExpr, int *aiChng, int chngRowid){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 0;\n  w.xExprCallback = checkConstraintExprNode;\n  w.u.aiCol = aiChng;\n  sqlite3WalkExpr(&w, pExpr);\n  if( !chngRowid ){\n    testcase( (w.eCode & CKCNSTRNT_ROWID)!=0 );\n    w.eCode &= ~CKCNSTRNT_ROWID;\n  }\n  testcase( w.eCode==0 );\n  testcase( w.eCode==CKCNSTRNT_COLUMN );\n  testcase( w.eCode==CKCNSTRNT_ROWID );\n  testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );\n  return !w.eCode;\n}\n\n/*\n** Generate code to do constraint checks prior to an INSERT or an UPDATE\n** on table pTab.\n**\n** The regNewData parameter is the first register in a range that contains\n** the data to be inserted or the data after the update.  There will be\n** pTab->nCol+1 registers in this range.  The first register (the one\n** that regNewData points to) will contain the new rowid, or NULL in the\n** case of a WITHOUT ROWID table.  The second register in the range will\n** contain the content of the first table column.  The third register will\n** contain the content of the second table column.  And so forth.\n**\n** The regOldData parameter is similar to regNewData except that it contains\n** the data prior to an UPDATE rather than afterwards.  regOldData is zero\n** for an INSERT.  This routine can distinguish between UPDATE and INSERT by\n** checking regOldData for zero.\n**\n** For an UPDATE, the pkChng boolean is true if the true primary key (the\n** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table)\n** might be modified by the UPDATE.  If pkChng is false, then the key of\n** the iDataCur content table is guaranteed to be unchanged by the UPDATE.\n**\n** For an INSERT, the pkChng boolean indicates whether or not the rowid\n** was explicitly specified as part of the INSERT statement.  If pkChng\n** is zero, it means that the either rowid is computed automatically or\n** that the table is a WITHOUT ROWID table and has no rowid.  On an INSERT,\n** pkChng will only be true if the INSERT statement provides an integer\n** value for either the rowid column or its INTEGER PRIMARY KEY alias.\n**\n** The code generated by this routine will store new index entries into\n** registers identified by aRegIdx[].  No index entry is created for\n** indices where aRegIdx[i]==0.  The order of indices in aRegIdx[] is\n** the same as the order of indices on the linked list of indices\n** at pTab->pIndex.\n**\n** The caller must have already opened writeable cursors on the main\n** table and all applicable indices (that is to say, all indices for which\n** aRegIdx[] is not zero).  iDataCur is the cursor for the main table when\n** inserting or updating a rowid table, or the cursor for the PRIMARY KEY\n** index when operating on a WITHOUT ROWID table.  iIdxCur is the cursor\n** for the first index in the pTab->pIndex list.  Cursors for other indices\n** are at iIdxCur+N for the N-th element of the pTab->pIndex list.\n**\n** This routine also generates code to check constraints.  NOT NULL,\n** CHECK, and UNIQUE constraints are all checked.  If a constraint fails,\n** then the appropriate action is performed.  There are five possible\n** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE.\n**\n**  Constraint type  Action       What Happens\n**  ---------------  ----------   ----------------------------------------\n**  any              ROLLBACK     The current transaction is rolled back and\n**                                sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.\n**\n**  any              ABORT        Back out changes from the current command\n**                                only (do not do a complete rollback) then\n**                                cause sqlite3_step() to return immediately\n**                                with SQLITE_CONSTRAINT.\n**\n**  any              FAIL         Sqlite3_step() returns immediately with a\n**                                return code of SQLITE_CONSTRAINT.  The\n**                                transaction is not rolled back and any\n**                                changes to prior rows are retained.\n**\n**  any              IGNORE       The attempt in insert or update the current\n**                                row is skipped, without throwing an error.\n**                                Processing continues with the next row.\n**                                (There is an immediate jump to ignoreDest.)\n**\n**  NOT NULL         REPLACE      The NULL value is replace by the default\n**                                value for that column.  If the default value\n**                                is NULL, the action is the same as ABORT.\n**\n**  UNIQUE           REPLACE      The other row that conflicts with the row\n**                                being inserted is removed.\n**\n**  CHECK            REPLACE      Illegal.  The results in an exception.\n**\n** Which action to take is determined by the overrideError parameter.\n** Or if overrideError==OE_Default, then the pParse->onError parameter\n** is used.  Or if pParse->onError==OE_Default then the onError value\n** for the constraint is used.\n*/\nvoid sqlite3GenerateConstraintChecks(\n  Parse *pParse,       /* The parser context */\n  Table *pTab,         /* The table being inserted or updated */\n  int *aRegIdx,        /* Use register aRegIdx[i] for index i.  0 for unused */\n  int iDataCur,        /* Canonical data cursor (main table or PK index) */\n  int iIdxCur,         /* First index cursor */\n  int regNewData,      /* First register in a range holding values to insert */\n  int regOldData,      /* Previous content.  0 for INSERTs */\n  u8 pkChng,           /* Non-zero if the rowid or PRIMARY KEY changed */\n  u8 overrideError,    /* Override onError to this if not OE_Default */\n  int ignoreDest,      /* Jump to this label on an OE_Ignore resolution */\n  int *pbMayReplace,   /* OUT: Set to true if constraint may cause a replace */\n  int *aiChng          /* column i is unchanged if aiChng[i]<0 */\n){\n  Vdbe *v;             /* VDBE under constrution */\n  Index *pIdx;         /* Pointer to one of the indices */\n  Index *pPk = 0;      /* The PRIMARY KEY index */\n  sqlite3 *db;         /* Database connection */\n  int i;               /* loop counter */\n  int ix;              /* Index loop counter */\n  int nCol;            /* Number of columns */\n  int onError;         /* Conflict resolution strategy */\n  int addr1;           /* Address of jump instruction */\n  int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */\n  int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */\n  int ipkTop = 0;      /* Top of the rowid change constraint check */\n  int ipkBottom = 0;   /* Bottom of the rowid change constraint check */\n  u8 isUpdate;         /* True if this is an UPDATE operation */\n  u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */\n\n  isUpdate = regOldData!=0;\n  db = pParse->db;\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  nCol = pTab->nCol;\n  \n  /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for\n  ** normal rowid tables.  nPkField is the number of key fields in the \n  ** pPk index or 1 for a rowid table.  In other words, nPkField is the\n  ** number of fields in the true primary key of the table. */\n  if( HasRowid(pTab) ){\n    pPk = 0;\n    nPkField = 1;\n  }else{\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    nPkField = pPk->nKeyCol;\n  }\n\n  /* Record that this module has started */\n  VdbeModuleComment((v, \"BEGIN: GenCnstCks(%d,%d,%d,%d,%d)\",\n                     iDataCur, iIdxCur, regNewData, regOldData, pkChng));\n\n  /* Test all NOT NULL constraints.\n  */\n  for(i=0; i<nCol; i++){\n    if( i==pTab->iPKey ){\n      continue;        /* ROWID is never NULL */\n    }\n    if( aiChng && aiChng[i]<0 ){\n      /* Don't bother checking for NOT NULL on columns that do not change */\n      continue;\n    }\n    onError = pTab->aCol[i].notNull;\n    if( onError==OE_None ) continue;  /* This column is allowed to be NULL */\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n    if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){\n      onError = OE_Abort;\n    }\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Abort:\n        sqlite3MayAbort(pParse);\n        /* Fall through */\n      case OE_Rollback:\n      case OE_Fail: {\n        char *zMsg = sqlite3MPrintf(db, \"%s.%s\", pTab->zName,\n                                    pTab->aCol[i].zName);\n        sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError,\n                          regNewData+1+i);\n        sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);\n        sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);\n        VdbeCoverage(v);\n        break;\n      }\n      case OE_Ignore: {\n        sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);\n        VdbeCoverage(v);\n        break;\n      }\n      default: {\n        assert( onError==OE_Replace );\n        addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i);\n           VdbeCoverage(v);\n        sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);\n        sqlite3VdbeJumpHere(v, addr1);\n        break;\n      }\n    }\n  }\n\n  /* Test all CHECK constraints\n  */\n#ifndef SQLITE_OMIT_CHECK\n  if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n    ExprList *pCheck = pTab->pCheck;\n    pParse->iSelfTab = -(regNewData+1);\n    onError = overrideError!=OE_Default ? overrideError : OE_Abort;\n    for(i=0; i<pCheck->nExpr; i++){\n      int allOk;\n      Expr *pExpr = pCheck->a[i].pExpr;\n      if( aiChng && checkConstraintUnchanged(pExpr, aiChng, pkChng) ) continue;\n      allOk = sqlite3VdbeMakeLabel(v);\n      sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);\n      if( onError==OE_Ignore ){\n        sqlite3VdbeGoto(v, ignoreDest);\n      }else{\n        char *zName = pCheck->a[i].zName;\n        if( zName==0 ) zName = pTab->zName;\n        if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */\n        sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK,\n                              onError, zName, P4_TRANSIENT,\n                              P5_ConstraintCheck);\n      }\n      sqlite3VdbeResolveLabel(v, allOk);\n    }\n    pParse->iSelfTab = 0;\n  }\n#endif /* !defined(SQLITE_OMIT_CHECK) */\n\n  /* If rowid is changing, make sure the new rowid does not previously\n  ** exist in the table.\n  */\n  if( pkChng && pPk==0 ){\n    int addrRowidOk = sqlite3VdbeMakeLabel(v);\n\n    /* Figure out what action to take in case of a rowid collision */\n    onError = pTab->keyConf;\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    if( isUpdate ){\n      /* pkChng!=0 does not mean that the rowid has changed, only that\n      ** it might have changed.  Skip the conflict logic below if the rowid\n      ** is unchanged. */\n      sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);\n      sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n      VdbeCoverage(v);\n    }\n\n    /* If the response to a rowid conflict is REPLACE but the response\n    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need\n    ** to defer the running of the rowid conflict checking until after\n    ** the UNIQUE constraints have run.\n    */\n    if( onError==OE_Replace && overrideError!=OE_Replace ){\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){\n          ipkTop = sqlite3VdbeAddOp0(v, OP_Goto);\n          break;\n        }\n      }\n    }\n\n    /* Check to see if the new rowid already exists in the table.  Skip\n    ** the following conflict logic if it does not. */\n    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);\n    VdbeCoverage(v);\n\n    /* Generate code that deals with a rowid collision */\n    switch( onError ){\n      default: {\n        onError = OE_Abort;\n        /* Fall thru into the next case */\n      }\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        sqlite3RowidConstraint(pParse, onError, pTab);\n        break;\n      }\n      case OE_Replace: {\n        /* If there are DELETE triggers on this table and the\n        ** recursive-triggers flag is set, call GenerateRowDelete() to\n        ** remove the conflicting row from the table. This will fire\n        ** the triggers and remove both the table and index b-tree entries.\n        **\n        ** Otherwise, if there are no triggers or the recursive-triggers\n        ** flag is not set, but the table has one or more indexes, call \n        ** GenerateRowIndexDelete(). This removes the index b-tree entries \n        ** only. The table b-tree entry will be replaced by the new entry \n        ** when it is inserted.  \n        **\n        ** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,\n        ** also invoke MultiWrite() to indicate that this VDBE may require\n        ** statement rollback (if the statement is aborted after the delete\n        ** takes place). Earlier versions called sqlite3MultiWrite() regardless,\n        ** but being more selective here allows statements like:\n        **\n        **   REPLACE INTO t(rowid) VALUES($newrowid)\n        **\n        ** to run without a statement journal if there are no indexes on the\n        ** table.\n        */\n        Trigger *pTrigger = 0;\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){\n          sqlite3MultiWrite(pParse);\n          sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n                                   regNewData, 1, 0, OE_Replace, 1, -1);\n        }else{\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n          if( HasRowid(pTab) ){\n            /* This OP_Delete opcode fires the pre-update-hook only. It does\n            ** not modify the b-tree. It is more efficient to let the coming\n            ** OP_Insert replace the existing entry than it is to delete the\n            ** existing entry and then insert a new one. */\n            sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);\n            sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n          }\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n          if( pTab->pIndex ){\n            sqlite3MultiWrite(pParse);\n            sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);\n          }\n        }\n        seenReplace = 1;\n        break;\n      }\n      case OE_Ignore: {\n        /*assert( seenReplace==0 );*/\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n    }\n    sqlite3VdbeResolveLabel(v, addrRowidOk);\n    if( ipkTop ){\n      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);\n      sqlite3VdbeJumpHere(v, ipkTop);\n    }\n  }\n\n  /* Test all UNIQUE constraints by creating entries for each UNIQUE\n  ** index and making sure that duplicate entries do not already exist.\n  ** Compute the revised record entries for indices as we go.\n  **\n  ** This loop also handles the case of the PRIMARY KEY index for a\n  ** WITHOUT ROWID table.\n  */\n  for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){\n    int regIdx;          /* Range of registers hold conent for pIdx */\n    int regR;            /* Range of registers holding conflicting PK */\n    int iThisCur;        /* Cursor for this UNIQUE index */\n    int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */\n\n    if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */\n    if( bAffinityDone==0 ){\n      sqlite3TableAffinity(v, pTab, regNewData+1);\n      bAffinityDone = 1;\n    }\n    iThisCur = iIdxCur+ix;\n    addrUniqueOk = sqlite3VdbeMakeLabel(v);\n\n    /* Skip partial indices for which the WHERE clause is not true */\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);\n      pParse->iSelfTab = -(regNewData+1);\n      sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,\n                            SQLITE_JUMPIFNULL);\n      pParse->iSelfTab = 0;\n    }\n\n    /* Create a record for this index entry as it should appear after\n    ** the insert or update.  Store that record in the aRegIdx[ix] register\n    */\n    regIdx = aRegIdx[ix]+1;\n    for(i=0; i<pIdx->nColumn; i++){\n      int iField = pIdx->aiColumn[i];\n      int x;\n      if( iField==XN_EXPR ){\n        pParse->iSelfTab = -(regNewData+1);\n        sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);\n        pParse->iSelfTab = 0;\n        VdbeComment((v, \"%s column %d\", pIdx->zName, i));\n      }else{\n        if( iField==XN_ROWID || iField==pTab->iPKey ){\n          x = regNewData;\n        }else{\n          x = iField + regNewData + 1;\n        }\n        sqlite3VdbeAddOp2(v, iField<0 ? OP_IntCopy : OP_SCopy, x, regIdx+i);\n        VdbeComment((v, \"%s\", iField<0 ? \"rowid\" : pTab->aCol[iField].zName));\n      }\n    }\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);\n    VdbeComment((v, \"for %s\", pIdx->zName));\n#ifdef SQLITE_ENABLE_NULL_TRIM\n    if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);\n#endif\n\n    /* In an UPDATE operation, if this index is the PRIMARY KEY index \n    ** of a WITHOUT ROWID table and there has been no change the\n    ** primary key, then no collision is possible.  The collision detection\n    ** logic below can all be skipped. */\n    if( isUpdate && pPk==pIdx && pkChng==0 ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n\n    /* Find out what action to take in case there is a uniqueness conflict */\n    onError = pIdx->onError;\n    if( onError==OE_None ){ \n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;  /* pIdx is not a UNIQUE index */\n    }\n    if( overrideError!=OE_Default ){\n      onError = overrideError;\n    }else if( onError==OE_Default ){\n      onError = OE_Abort;\n    }\n\n    /* Collision detection may be omitted if all of the following are true:\n    **   (1) The conflict resolution algorithm is REPLACE\n    **   (2) The table is a WITHOUT ROWID table\n    **   (3) There are no secondary indexes on the table\n    **   (4) No delete triggers need to be fired if there is a conflict\n    **   (5) No FK constraint counters need to be updated if a conflict occurs.\n    */ \n    if( (ix==0 && pIdx->pNext==0)                   /* Condition 3 */\n     && pPk==pIdx                                   /* Condition 2 */\n     && onError==OE_Replace                         /* Condition 1 */\n     && ( 0==(db->flags&SQLITE_RecTriggers) ||      /* Condition 4 */\n          0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0))\n     && ( 0==(db->flags&SQLITE_ForeignKeys) ||      /* Condition 5 */\n         (0==pTab->pFKey && 0==sqlite3FkReferences(pTab)))\n    ){\n      sqlite3VdbeResolveLabel(v, addrUniqueOk);\n      continue;\n    }\n\n    /* Check to see if the new index entry will be unique */\n    sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,\n                         regIdx, pIdx->nKeyCol); VdbeCoverage(v);\n\n    /* Generate code to handle collisions */\n    regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);\n    if( isUpdate || onError==OE_Replace ){\n      if( HasRowid(pTab) ){\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR);\n        /* Conflict only if the rowid of the existing index entry\n        ** is different from old-rowid */\n        if( isUpdate ){\n          sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData);\n          sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n          VdbeCoverage(v);\n        }\n      }else{\n        int x;\n        /* Extract the PRIMARY KEY from the end of the index entry and\n        ** store it in registers regR..regR+nPk-1 */\n        if( pIdx!=pPk ){\n          for(i=0; i<pPk->nKeyCol; i++){\n            assert( pPk->aiColumn[i]>=0 );\n            x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);\n            sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);\n            VdbeComment((v, \"%s.%s\", pTab->zName,\n                         pTab->aCol[pPk->aiColumn[i]].zName));\n          }\n        }\n        if( isUpdate ){\n          /* If currently processing the PRIMARY KEY of a WITHOUT ROWID \n          ** table, only conflict if the new PRIMARY KEY values are actually\n          ** different from the old.\n          **\n          ** For a UNIQUE index, only conflict if the PRIMARY KEY values\n          ** of the matched index row are different from the original PRIMARY\n          ** KEY values of this row before the update.  */\n          int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;\n          int op = OP_Ne;\n          int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);\n  \n          for(i=0; i<pPk->nKeyCol; i++){\n            char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);\n            x = pPk->aiColumn[i];\n            assert( x>=0 );\n            if( i==(pPk->nKeyCol-1) ){\n              addrJump = addrUniqueOk;\n              op = OP_Eq;\n            }\n            sqlite3VdbeAddOp4(v, op, \n                regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ\n            );\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            VdbeCoverageIf(v, op==OP_Eq);\n            VdbeCoverageIf(v, op==OP_Ne);\n          }\n        }\n      }\n    }\n\n    /* Generate code that executes if the new index entry is not unique */\n    assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail\n        || onError==OE_Ignore || onError==OE_Replace );\n    switch( onError ){\n      case OE_Rollback:\n      case OE_Abort:\n      case OE_Fail: {\n        sqlite3UniqueConstraint(pParse, onError, pIdx);\n        break;\n      }\n      case OE_Ignore: {\n        sqlite3VdbeGoto(v, ignoreDest);\n        break;\n      }\n      default: {\n        Trigger *pTrigger = 0;\n        assert( onError==OE_Replace );\n        sqlite3MultiWrite(pParse);\n        if( db->flags&SQLITE_RecTriggers ){\n          pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);\n        }\n        sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,\n            regR, nPkField, 0, OE_Replace,\n            (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);\n        seenReplace = 1;\n        break;\n      }\n    }\n    sqlite3VdbeResolveLabel(v, addrUniqueOk);\n    if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);\n  }\n  if( ipkTop ){\n    sqlite3VdbeGoto(v, ipkTop+1);\n    sqlite3VdbeJumpHere(v, ipkBottom);\n  }\n  \n  *pbMayReplace = seenReplace;\n  VdbeModuleComment((v, \"END: GenCnstCks(%d)\", seenReplace));\n}\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n/*\n** Change the P5 operand on the last opcode (which should be an OP_MakeRecord)\n** to be the number of columns in table pTab that must not be NULL-trimmed.\n**\n** Or if no columns of pTab may be NULL-trimmed, leave P5 at zero.\n*/\nvoid sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){\n  u16 i;\n\n  /* Records with omitted columns are only allowed for schema format\n  ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */\n  if( pTab->pSchema->file_format<2 ) return;\n\n  for(i=pTab->nCol-1; i>0; i--){\n    if( pTab->aCol[i].pDflt!=0 ) break;\n    if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;\n  }\n  sqlite3VdbeChangeP5(v, i+1);\n}\n#endif\n\n/*\n** This routine generates code to finish the INSERT or UPDATE operation\n** that was started by a prior call to sqlite3GenerateConstraintChecks.\n** A consecutive range of registers starting at regNewData contains the\n** rowid and the content to be inserted.\n**\n** The arguments to this routine should be the same as the first six\n** arguments to sqlite3GenerateConstraintChecks.\n*/\nvoid sqlite3CompleteInsertion(\n  Parse *pParse,      /* The parser context */\n  Table *pTab,        /* the table into which we are inserting */\n  int iDataCur,       /* Cursor of the canonical data source */\n  int iIdxCur,        /* First index cursor */\n  int regNewData,     /* Range of content */\n  int *aRegIdx,       /* Register used by each index.  0 for unused indices */\n  int update_flags,   /* True for UPDATE, False for INSERT */\n  int appendBias,     /* True if this is likely to be an append */\n  int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */\n){\n  Vdbe *v;            /* Prepared statements under construction */\n  Index *pIdx;        /* An index being inserted or updated */\n  u8 pik_flags;       /* flag values passed to the btree insert */\n  int regData;        /* Content registers (after the rowid) */\n  int regRec;         /* Register holding assembled record for the table */\n  int i;              /* Loop counter */\n  u8 bAffinityDone = 0; /* True if OP_Affinity has been run already */\n\n  assert( update_flags==0\n       || update_flags==OPFLAG_ISUPDATE\n       || update_flags==(OPFLAG_ISUPDATE|OPFLAG_SAVEPOSITION)\n  );\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  assert( pTab->pSelect==0 );  /* This table is not a VIEW */\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    if( aRegIdx[i]==0 ) continue;\n    bAffinityDone = 1;\n    if( pIdx->pPartIdxWhere ){\n      sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2);\n      VdbeCoverage(v);\n    }\n    pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      assert( pParse->nested==0 );\n      pik_flags |= OPFLAG_NCHANGE;\n      pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n      if( update_flags==0 ){\n        sqlite3VdbeAddOp4(v, OP_InsertInt, \n            iIdxCur+i, aRegIdx[i], 0, (char*)pTab, P4_TABLE\n        );\n        sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP);\n      }\n#endif\n    }\n    sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i],\n                         aRegIdx[i]+1,\n                         pIdx->uniqNotNull ? pIdx->nKeyCol: pIdx->nColumn);\n    sqlite3VdbeChangeP5(v, pik_flags);\n  }\n  if( !HasRowid(pTab) ) return;\n  regData = regNewData + 1;\n  regRec = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec);\n  sqlite3SetMakeRecordP5(v, pTab);\n  if( !bAffinityDone ){\n    sqlite3TableAffinity(v, pTab, 0);\n    sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol);\n  }\n  if( pParse->nested ){\n    pik_flags = 0;\n  }else{\n    pik_flags = OPFLAG_NCHANGE;\n    pik_flags |= (update_flags?update_flags:OPFLAG_LASTROWID);\n  }\n  if( appendBias ){\n    pik_flags |= OPFLAG_APPEND;\n  }\n  if( useSeekResult ){\n    pik_flags |= OPFLAG_USESEEKRESULT;\n  }\n  sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData);\n  if( !pParse->nested ){\n    sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n  }\n  sqlite3VdbeChangeP5(v, pik_flags);\n}\n\n/*\n** Allocate cursors for the pTab table and all its indices and generate\n** code to open and initialized those cursors.\n**\n** The cursor for the object that contains the complete data (normally\n** the table itself, but the PRIMARY KEY index in the case of a WITHOUT\n** ROWID table) is returned in *piDataCur.  The first index cursor is\n** returned in *piIdxCur.  The number of indices is returned.\n**\n** Use iBase as the first cursor (either the *piDataCur for rowid tables\n** or the first index for WITHOUT ROWID tables) if it is non-negative.\n** If iBase is negative, then allocate the next available cursor.\n**\n** For a rowid table, *piDataCur will be exactly one less than *piIdxCur.\n** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range\n** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the\n** pTab->pIndex list.\n**\n** If pTab is a virtual table, then this routine is a no-op and the\n** *piDataCur and *piIdxCur values are left uninitialized.\n*/\nint sqlite3OpenTableAndIndices(\n  Parse *pParse,   /* Parsing context */\n  Table *pTab,     /* Table to be opened */\n  int op,          /* OP_OpenRead or OP_OpenWrite */\n  u8 p5,           /* P5 value for OP_Open* opcodes (except on WITHOUT ROWID) */\n  int iBase,       /* Use this for the table cursor, if there is one */\n  u8 *aToOpen,     /* If not NULL: boolean for each table and index */\n  int *piDataCur,  /* Write the database source cursor number here */\n  int *piIdxCur    /* Write the first index cursor number here */\n){\n  int i;\n  int iDb;\n  int iDataCur;\n  Index *pIdx;\n  Vdbe *v;\n\n  assert( op==OP_OpenRead || op==OP_OpenWrite );\n  assert( op==OP_OpenWrite || p5==0 );\n  if( IsVirtual(pTab) ){\n    /* This routine is a no-op for virtual tables. Leave the output\n    ** variables *piDataCur and *piIdxCur uninitialized so that valgrind\n    ** can detect if they are used by mistake in the caller. */\n    return 0;\n  }\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );\n  if( iBase<0 ) iBase = pParse->nTab;\n  iDataCur = iBase++;\n  if( piDataCur ) *piDataCur = iDataCur;\n  if( HasRowid(pTab) && (aToOpen==0 || aToOpen[0]) ){\n    sqlite3OpenTable(pParse, iDataCur, iDb, pTab, op);\n  }else{\n    sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName);\n  }\n  if( piIdxCur ) *piIdxCur = iBase;\n  for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){\n    int iIdxCur = iBase++;\n    assert( pIdx->pSchema==pTab->pSchema );\n    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){\n      if( piDataCur ) *piDataCur = iIdxCur;\n      p5 = 0;\n    }\n    if( aToOpen==0 || aToOpen[i+1] ){\n      sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb);\n      sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n      sqlite3VdbeChangeP5(v, p5);\n      VdbeComment((v, \"%s\", pIdx->zName));\n    }\n  }\n  if( iBase>pParse->nTab ) pParse->nTab = iBase;\n  return i;\n}\n\n\n#ifdef SQLITE_TEST\n/*\n** The following global variable is incremented whenever the\n** transfer optimization is used.  This is used for testing\n** purposes only - to make sure the transfer optimization really\n** is happening when it is supposed to.\n*/\nint sqlite3_xferopt_count;\n#endif /* SQLITE_TEST */\n\n\n#ifndef SQLITE_OMIT_XFER_OPT\n/*\n** Check to see if index pSrc is compatible as a source of data\n** for index pDest in an insert transfer optimization.  The rules\n** for a compatible index:\n**\n**    *   The index is over the same set of columns\n**    *   The same DESC and ASC markings occurs on all columns\n**    *   The same onError processing (OE_Abort, OE_Ignore, etc)\n**    *   The same collating sequence on each column\n**    *   The index has the exact same WHERE clause\n*/\nstatic int xferCompatibleIndex(Index *pDest, Index *pSrc){\n  int i;\n  assert( pDest && pSrc );\n  assert( pDest->pTable!=pSrc->pTable );\n  if( pDest->nKeyCol!=pSrc->nKeyCol ){\n    return 0;   /* Different number of columns */\n  }\n  if( pDest->onError!=pSrc->onError ){\n    return 0;   /* Different conflict resolution strategies */\n  }\n  for(i=0; i<pSrc->nKeyCol; i++){\n    if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){\n      return 0;   /* Different columns indexed */\n    }\n    if( pSrc->aiColumn[i]==XN_EXPR ){\n      assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 );\n      if( sqlite3ExprCompare(0, pSrc->aColExpr->a[i].pExpr,\n                             pDest->aColExpr->a[i].pExpr, -1)!=0 ){\n        return 0;   /* Different expressions in the index */\n      }\n    }\n    if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){\n      return 0;   /* Different sort orders */\n    }\n    if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){\n      return 0;   /* Different collating sequences */\n    }\n  }\n  if( sqlite3ExprCompare(0, pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){\n    return 0;     /* Different WHERE clauses */\n  }\n\n  /* If no test above fails then the indices must be compatible */\n  return 1;\n}\n\n/*\n** Attempt the transfer optimization on INSERTs of the form\n**\n**     INSERT INTO tab1 SELECT * FROM tab2;\n**\n** The xfer optimization transfers raw records from tab2 over to tab1.  \n** Columns are not decoded and reassembled, which greatly improves\n** performance.  Raw index records are transferred in the same way.\n**\n** The xfer optimization is only attempted if tab1 and tab2 are compatible.\n** There are lots of rules for determining compatibility - see comments\n** embedded in the code for details.\n**\n** This routine returns TRUE if the optimization is guaranteed to be used.\n** Sometimes the xfer optimization will only work if the destination table\n** is empty - a factor that can only be determined at run-time.  In that\n** case, this routine generates code for the xfer optimization but also\n** does a test to see if the destination table is empty and jumps over the\n** xfer optimization code if the test fails.  In that case, this routine\n** returns FALSE so that the caller will know to go ahead and generate\n** an unoptimized transfer.  This routine also returns FALSE if there\n** is no chance that the xfer optimization can be applied.\n**\n** This optimization is particularly useful at making VACUUM run faster.\n*/\nstatic int xferOptimization(\n  Parse *pParse,        /* Parser context */\n  Table *pDest,         /* The table we are inserting into */\n  Select *pSelect,      /* A SELECT statement to use as the data source */\n  int onError,          /* How to handle constraint errors */\n  int iDbDest           /* The database of pDest */\n){\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;                /* The result set of the SELECT */\n  Table *pSrc;                     /* The table in the FROM clause of SELECT */\n  Index *pSrcIdx, *pDestIdx;       /* Source and destination indices */\n  struct SrcList_item *pItem;      /* An element of pSelect->pSrc */\n  int i;                           /* Loop counter */\n  int iDbSrc;                      /* The database of pSrc */\n  int iSrc, iDest;                 /* Cursors from source and destination */\n  int addr1, addr2;                /* Loop addresses */\n  int emptyDestTest = 0;           /* Address of test for empty pDest */\n  int emptySrcTest = 0;            /* Address of test for empty pSrc */\n  Vdbe *v;                         /* The VDBE we are building */\n  int regAutoinc;                  /* Memory register used by AUTOINC */\n  int destHasUniqueIdx = 0;        /* True if pDest has a UNIQUE index */\n  int regData, regRowid;           /* Registers holding data and rowid */\n\n  if( pSelect==0 ){\n    return 0;   /* Must be of the form  INSERT INTO ... SELECT ... */\n  }\n  if( pParse->pWith || pSelect->pWith ){\n    /* Do not attempt to process this query if there are an WITH clauses\n    ** attached to it. Proceeding may generate a false \"no such table: xxx\"\n    ** error if pSelect reads from a CTE named \"xxx\".  */\n    return 0;\n  }\n  if( sqlite3TriggerList(pParse, pDest) ){\n    return 0;   /* tab1 must not have triggers */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pDest) ){\n    return 0;   /* tab1 must not be a virtual table */\n  }\n#endif\n  if( onError==OE_Default ){\n    if( pDest->iPKey>=0 ) onError = pDest->keyConf;\n    if( onError==OE_Default ) onError = OE_Abort;\n  }\n  assert(pSelect->pSrc);   /* allocated even if there is no FROM clause */\n  if( pSelect->pSrc->nSrc!=1 ){\n    return 0;   /* FROM clause must have exactly one term */\n  }\n  if( pSelect->pSrc->a[0].pSelect ){\n    return 0;   /* FROM clause cannot contain a subquery */\n  }\n  if( pSelect->pWhere ){\n    return 0;   /* SELECT may not have a WHERE clause */\n  }\n  if( pSelect->pOrderBy ){\n    return 0;   /* SELECT may not have an ORDER BY clause */\n  }\n  /* Do not need to test for a HAVING clause.  If HAVING is present but\n  ** there is no ORDER BY, we will get an error. */\n  if( pSelect->pGroupBy ){\n    return 0;   /* SELECT may not have a GROUP BY clause */\n  }\n  if( pSelect->pLimit ){\n    return 0;   /* SELECT may not have a LIMIT clause */\n  }\n  assert( pSelect->pOffset==0 );  /* Must be so if pLimit==0 */\n  if( pSelect->pPrior ){\n    return 0;   /* SELECT may not be a compound query */\n  }\n  if( pSelect->selFlags & SF_Distinct ){\n    return 0;   /* SELECT may not be DISTINCT */\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );\n  if( pEList->nExpr!=1 ){\n    return 0;   /* The result set must have exactly one column */\n  }\n  assert( pEList->a[0].pExpr );\n  if( pEList->a[0].pExpr->op!=TK_ASTERISK ){\n    return 0;   /* The result set must be the special operator \"*\" */\n  }\n\n  /* At this point we have established that the statement is of the\n  ** correct syntactic form to participate in this optimization.  Now\n  ** we have to check the semantics.\n  */\n  pItem = pSelect->pSrc->a;\n  pSrc = sqlite3LocateTableItem(pParse, 0, pItem);\n  if( pSrc==0 ){\n    return 0;   /* FROM clause does not contain a real table */\n  }\n  if( pSrc==pDest ){\n    return 0;   /* tab1 and tab2 may not be the same table */\n  }\n  if( HasRowid(pDest)!=HasRowid(pSrc) ){\n    return 0;   /* source and destination must both be WITHOUT ROWID or not */\n  }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if( IsVirtual(pSrc) ){\n    return 0;   /* tab2 must not be a virtual table */\n  }\n#endif\n  if( pSrc->pSelect ){\n    return 0;   /* tab2 may not be a view */\n  }\n  if( pDest->nCol!=pSrc->nCol ){\n    return 0;   /* Number of columns must be the same in tab1 and tab2 */\n  }\n  if( pDest->iPKey!=pSrc->iPKey ){\n    return 0;   /* Both tables must have the same INTEGER PRIMARY KEY */\n  }\n  for(i=0; i<pDest->nCol; i++){\n    Column *pDestCol = &pDest->aCol[i];\n    Column *pSrcCol = &pSrc->aCol[i];\n#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS\n    if( (db->mDbFlags & DBFLAG_Vacuum)==0 \n     && (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN \n    ){\n      return 0;    /* Neither table may have __hidden__ columns */\n    }\n#endif\n    if( pDestCol->affinity!=pSrcCol->affinity ){\n      return 0;    /* Affinity must be the same on all columns */\n    }\n    if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){\n      return 0;    /* Collating sequence must be the same on all columns */\n    }\n    if( pDestCol->notNull && !pSrcCol->notNull ){\n      return 0;    /* tab2 must be NOT NULL if tab1 is */\n    }\n    /* Default values for second and subsequent columns need to match. */\n    if( i>0 ){\n      assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );\n      assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );\n      if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0) \n       || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,\n                                       pSrcCol->pDflt->u.zToken)!=0)\n      ){\n        return 0;    /* Default values must be the same for all columns */\n      }\n    }\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    if( IsUniqueIndex(pDestIdx) ){\n      destHasUniqueIdx = 1;\n    }\n    for(pSrcIdx=pSrc->pIndex; pSrcIdx; pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    if( pSrcIdx==0 ){\n      return 0;    /* pDestIdx has no corresponding index in pSrc */\n    }\n  }\n#ifndef SQLITE_OMIT_CHECK\n  if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){\n    return 0;   /* Tables have different CHECK constraints.  Ticket #2252 */\n  }\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  /* Disallow the transfer optimization if the destination table constains\n  ** any foreign key constraints.  This is more restrictive than necessary.\n  ** But the main beneficiary of the transfer optimization is the VACUUM \n  ** command, and the VACUUM command disables foreign key constraints.  So\n  ** the extra complication to make this rule less restrictive is probably\n  ** not worth the effort.  Ticket [6284df89debdfa61db8073e062908af0c9b6118e]\n  */\n  if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){\n    return 0;\n  }\n#endif\n  if( (db->flags & SQLITE_CountRows)!=0 ){\n    return 0;  /* xfer opt does not play well with PRAGMA count_changes */\n  }\n\n  /* If we get this far, it means that the xfer optimization is at\n  ** least a possibility, though it might only work if the destination\n  ** table (tab1) is initially empty.\n  */\n#ifdef SQLITE_TEST\n  sqlite3_xferopt_count++;\n#endif\n  iDbSrc = sqlite3SchemaToIndex(db, pSrc->pSchema);\n  v = sqlite3GetVdbe(pParse);\n  sqlite3CodeVerifySchema(pParse, iDbSrc);\n  iSrc = pParse->nTab++;\n  iDest = pParse->nTab++;\n  regAutoinc = autoIncBegin(pParse, iDbDest, pDest);\n  regData = sqlite3GetTempReg(pParse);\n  regRowid = sqlite3GetTempReg(pParse);\n  sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);\n  assert( HasRowid(pDest) || destHasUniqueIdx );\n  if( (db->mDbFlags & DBFLAG_Vacuum)==0 && (\n      (pDest->iPKey<0 && pDest->pIndex!=0)          /* (1) */\n   || destHasUniqueIdx                              /* (2) */\n   || (onError!=OE_Abort && onError!=OE_Rollback)   /* (3) */\n  )){\n    /* In some circumstances, we are able to run the xfer optimization\n    ** only if the destination table is initially empty. Unless the\n    ** DBFLAG_Vacuum flag is set, this block generates code to make\n    ** that determination. If DBFLAG_Vacuum is set, then the destination\n    ** table is always empty.\n    **\n    ** Conditions under which the destination must be empty:\n    **\n    ** (1) There is no INTEGER PRIMARY KEY but there are indices.\n    **     (If the destination is not initially empty, the rowid fields\n    **     of index entries might need to change.)\n    **\n    ** (2) The destination has a unique index.  (The xfer optimization \n    **     is unable to test uniqueness.)\n    **\n    ** (3) onError is something other than OE_Abort and OE_Rollback.\n    */\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); VdbeCoverage(v);\n    emptyDestTest = sqlite3VdbeAddOp0(v, OP_Goto);\n    sqlite3VdbeJumpHere(v, addr1);\n  }\n  if( HasRowid(pSrc) ){\n    u8 insFlags;\n    sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead);\n    emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    if( pDest->iPKey>=0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid);\n      VdbeCoverage(v);\n      sqlite3RowidConstraint(pParse, onError, pDest);\n      sqlite3VdbeJumpHere(v, addr2);\n      autoIncStep(pParse, regAutoinc, regRowid);\n    }else if( pDest->pIndex==0 ){\n      addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid);\n    }else{\n      addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid);\n      assert( (pDest->tabFlags & TF_Autoincrement)==0 );\n    }\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|\n                           OPFLAG_APPEND|OPFLAG_USESEEKRESULT;\n    }else{\n      insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND;\n    }\n    sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid,\n                      (char*)pDest, P4_TABLE);\n    sqlite3VdbeChangeP5(v, insFlags);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }else{\n    sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);\n    sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);\n  }\n  for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){\n    u8 idxInsFlags = 0;\n    for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){\n      if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;\n    }\n    assert( pSrcIdx );\n    sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);\n    sqlite3VdbeSetP4KeyInfo(pParse, pSrcIdx);\n    VdbeComment((v, \"%s\", pSrcIdx->zName));\n    sqlite3VdbeAddOp3(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest);\n    sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);\n    sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);\n    VdbeComment((v, \"%s\", pDestIdx->zName));\n    addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);\n    if( db->mDbFlags & DBFLAG_Vacuum ){\n      /* This INSERT command is part of a VACUUM operation, which guarantees\n      ** that the destination table is empty. If all indexed columns use\n      ** collation sequence BINARY, then it can also be assumed that the\n      ** index will be populated by inserting keys in strictly sorted \n      ** order. In this case, instead of seeking within the b-tree as part\n      ** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the\n      ** OP_IdxInsert to seek to the point within the b-tree where each key \n      ** should be inserted. This is faster.\n      **\n      ** If any of the indexed columns use a collation sequence other than\n      ** BINARY, this optimization is disabled. This is because the user \n      ** might change the definition of a collation sequence and then run\n      ** a VACUUM command. In that case keys may not be written in strictly\n      ** sorted order.  */\n      for(i=0; i<pSrcIdx->nColumn; i++){\n        const char *zColl = pSrcIdx->azColl[i];\n        if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break;\n      }\n      if( i==pSrcIdx->nColumn ){\n        idxInsFlags = OPFLAG_USESEEKRESULT;\n        sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest);\n      }\n    }\n    if( !HasRowid(pSrc) && pDestIdx->idxType==2 ){\n      idxInsFlags |= OPFLAG_NCHANGE;\n    }\n    sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, regData);\n    sqlite3VdbeChangeP5(v, idxInsFlags|OPFLAG_APPEND);\n    sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n  }\n  if( emptySrcTest ) sqlite3VdbeJumpHere(v, emptySrcTest);\n  sqlite3ReleaseTempReg(pParse, regRowid);\n  sqlite3ReleaseTempReg(pParse, regData);\n  if( emptyDestTest ){\n    sqlite3AutoincrementEnd(pParse);\n    sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0);\n    sqlite3VdbeJumpHere(v, emptyDestTest);\n    sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);\n    return 0;\n  }else{\n    return 1;\n  }\n}\n#endif /* SQLITE_OMIT_XFER_OPT */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/legacy.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n\n#include \"sqliteInt.h\"\n\n/*\n** Execute SQL code.  Return one of the SQLITE_ success/failure\n** codes.  Also write an error message into memory obtained from\n** malloc() and make *pzErrMsg point to that message.\n**\n** If the SQL is a query, then for each row in the query result\n** the xCallback() function is called.  pArg becomes the first\n** argument to xCallback().  If xCallback=NULL then no callback\n** is invoked, even for queries.\n*/\nint sqlite3_exec(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  sqlite3_callback xCallback, /* Invoke this callback routine */\n  void *pArg,                 /* First argument to xCallback() */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc = SQLITE_OK;         /* Return code */\n  const char *zLeftover;      /* Tail of unprocessed SQL */\n  sqlite3_stmt *pStmt = 0;    /* The current SQL statement */\n  char **azCols = 0;          /* Names of result columns */\n  int callbackIsInit;         /* True if callback data is initialized */\n\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n  if( zSql==0 ) zSql = \"\";\n\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3Error(db, SQLITE_OK);\n  while( rc==SQLITE_OK && zSql[0] ){\n    int nCol;\n    char **azVals = 0;\n\n    pStmt = 0;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    assert( rc==SQLITE_OK || pStmt==0 );\n    if( rc!=SQLITE_OK ){\n      continue;\n    }\n    if( !pStmt ){\n      /* this happens for a comment or white-space */\n      zSql = zLeftover;\n      continue;\n    }\n\n    callbackIsInit = 0;\n    nCol = sqlite3_column_count(pStmt);\n\n    while( 1 ){\n      int i;\n      rc = sqlite3_step(pStmt);\n\n      /* Invoke the callback function if required */\n      if( xCallback && (SQLITE_ROW==rc || \n          (SQLITE_DONE==rc && !callbackIsInit\n                           && db->flags&SQLITE_NullCallback)) ){\n        if( !callbackIsInit ){\n          azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));\n          if( azCols==0 ){\n            goto exec_out;\n          }\n          for(i=0; i<nCol; i++){\n            azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n            /* sqlite3VdbeSetColName() installs column names as UTF8\n            ** strings so there is no way for sqlite3_column_name() to fail. */\n            assert( azCols[i]!=0 );\n          }\n          callbackIsInit = 1;\n        }\n        if( rc==SQLITE_ROW ){\n          azVals = &azCols[nCol];\n          for(i=0; i<nCol; i++){\n            azVals[i] = (char *)sqlite3_column_text(pStmt, i);\n            if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){\n              sqlite3OomFault(db);\n              goto exec_out;\n            }\n          }\n          azVals[i] = 0;\n        }\n        if( xCallback(pArg, nCol, azVals, azCols) ){\n          /* EVIDENCE-OF: R-38229-40159 If the callback function to\n          ** sqlite3_exec() returns non-zero, then sqlite3_exec() will\n          ** return SQLITE_ABORT. */\n          rc = SQLITE_ABORT;\n          sqlite3VdbeFinalize((Vdbe *)pStmt);\n          pStmt = 0;\n          sqlite3Error(db, SQLITE_ABORT);\n          goto exec_out;\n        }\n      }\n\n      if( rc!=SQLITE_ROW ){\n        rc = sqlite3VdbeFinalize((Vdbe *)pStmt);\n        pStmt = 0;\n        zSql = zLeftover;\n        while( sqlite3Isspace(zSql[0]) ) zSql++;\n        break;\n      }\n    }\n\n    sqlite3DbFree(db, azCols);\n    azCols = 0;\n  }\n\nexec_out:\n  if( pStmt ) sqlite3VdbeFinalize((Vdbe *)pStmt);\n  sqlite3DbFree(db, azCols);\n\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && pzErrMsg ){\n    *pzErrMsg = sqlite3DbStrDup(0, sqlite3_errmsg(db));\n    if( *pzErrMsg==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      sqlite3Error(db, SQLITE_NOMEM);\n    }\n  }else if( pzErrMsg ){\n    *pzErrMsg = 0;\n  }\n\n  assert( (rc&db->errMask)==rc );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/loadext.c",
    "content": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to dynamically load extensions into\n** the SQLite library.\n*/\n\n#ifndef SQLITE_CORE\n  #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */\n#endif\n#include \"sqlite3ext.h\"\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Some API routines are omitted when various features are\n** excluded from a build of SQLite.  Substitute a NULL pointer\n** for any missing APIs.\n*/\n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n# define sqlite3_column_database_name   0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name      0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name     0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_AUTHORIZATION\n# define sqlite3_set_authorizer         0\n#endif\n\n#ifdef SQLITE_OMIT_UTF16\n# define sqlite3_bind_text16            0\n# define sqlite3_collation_needed16     0\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_name16          0\n# define sqlite3_column_text16          0\n# define sqlite3_complete16             0\n# define sqlite3_create_collation16     0\n# define sqlite3_create_function16      0\n# define sqlite3_errmsg16               0\n# define sqlite3_open16                 0\n# define sqlite3_prepare16              0\n# define sqlite3_prepare16_v2           0\n# define sqlite3_prepare16_v3           0\n# define sqlite3_result_error16         0\n# define sqlite3_result_text16          0\n# define sqlite3_result_text16be        0\n# define sqlite3_result_text16le        0\n# define sqlite3_value_text16           0\n# define sqlite3_value_text16be         0\n# define sqlite3_value_text16le         0\n# define sqlite3_column_database_name16 0\n# define sqlite3_column_table_name16    0\n# define sqlite3_column_origin_name16   0\n#endif\n\n#ifdef SQLITE_OMIT_COMPLETE\n# define sqlite3_complete 0\n# define sqlite3_complete16 0\n#endif\n\n#ifdef SQLITE_OMIT_DECLTYPE\n# define sqlite3_column_decltype16      0\n# define sqlite3_column_decltype        0\n#endif\n\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n# define sqlite3_progress_handler 0\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n# define sqlite3_create_module 0\n# define sqlite3_create_module_v2 0\n# define sqlite3_declare_vtab 0\n# define sqlite3_vtab_config 0\n# define sqlite3_vtab_on_conflict 0\n#endif\n\n#ifdef SQLITE_OMIT_SHARED_CACHE\n# define sqlite3_enable_shared_cache 0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)\n# define sqlite3_profile       0\n# define sqlite3_trace         0\n#endif\n\n#ifdef SQLITE_OMIT_GET_TABLE\n# define sqlite3_free_table    0\n# define sqlite3_get_table     0\n#endif\n\n#ifdef SQLITE_OMIT_INCRBLOB\n#define sqlite3_bind_zeroblob  0\n#define sqlite3_blob_bytes     0\n#define sqlite3_blob_close     0\n#define sqlite3_blob_open      0\n#define sqlite3_blob_read      0\n#define sqlite3_blob_write     0\n#define sqlite3_blob_reopen    0\n#endif\n\n#if defined(SQLITE_OMIT_TRACE)\n# define sqlite3_trace_v2      0\n#endif\n\n/*\n** The following structure contains pointers to all SQLite API routines.\n** A pointer to this structure is passed into extensions when they are\n** loaded so that the extension can make calls back into the SQLite\n** library.\n**\n** When adding new APIs, add them to the bottom of this structure\n** in order to preserve backwards compatibility.\n**\n** Extensions that use newer APIs should first call the\n** sqlite3_libversion_number() to make sure that the API they\n** intend to use is supported by the library.  Extensions should\n** also check to make sure that the pointer to the function is\n** not NULL before calling it.\n*/\nstatic const sqlite3_api_routines sqlite3Apis = {\n  sqlite3_aggregate_context,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_aggregate_count,\n#else\n  0,\n#endif\n  sqlite3_bind_blob,\n  sqlite3_bind_double,\n  sqlite3_bind_int,\n  sqlite3_bind_int64,\n  sqlite3_bind_null,\n  sqlite3_bind_parameter_count,\n  sqlite3_bind_parameter_index,\n  sqlite3_bind_parameter_name,\n  sqlite3_bind_text,\n  sqlite3_bind_text16,\n  sqlite3_bind_value,\n  sqlite3_busy_handler,\n  sqlite3_busy_timeout,\n  sqlite3_changes,\n  sqlite3_close,\n  sqlite3_collation_needed,\n  sqlite3_collation_needed16,\n  sqlite3_column_blob,\n  sqlite3_column_bytes,\n  sqlite3_column_bytes16,\n  sqlite3_column_count,\n  sqlite3_column_database_name,\n  sqlite3_column_database_name16,\n  sqlite3_column_decltype,\n  sqlite3_column_decltype16,\n  sqlite3_column_double,\n  sqlite3_column_int,\n  sqlite3_column_int64,\n  sqlite3_column_name,\n  sqlite3_column_name16,\n  sqlite3_column_origin_name,\n  sqlite3_column_origin_name16,\n  sqlite3_column_table_name,\n  sqlite3_column_table_name16,\n  sqlite3_column_text,\n  sqlite3_column_text16,\n  sqlite3_column_type,\n  sqlite3_column_value,\n  sqlite3_commit_hook,\n  sqlite3_complete,\n  sqlite3_complete16,\n  sqlite3_create_collation,\n  sqlite3_create_collation16,\n  sqlite3_create_function,\n  sqlite3_create_function16,\n  sqlite3_create_module,\n  sqlite3_data_count,\n  sqlite3_db_handle,\n  sqlite3_declare_vtab,\n  sqlite3_enable_shared_cache,\n  sqlite3_errcode,\n  sqlite3_errmsg,\n  sqlite3_errmsg16,\n  sqlite3_exec,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_expired,\n#else\n  0,\n#endif\n  sqlite3_finalize,\n  sqlite3_free,\n  sqlite3_free_table,\n  sqlite3_get_autocommit,\n  sqlite3_get_auxdata,\n  sqlite3_get_table,\n  0,     /* Was sqlite3_global_recover(), but that function is deprecated */\n  sqlite3_interrupt,\n  sqlite3_last_insert_rowid,\n  sqlite3_libversion,\n  sqlite3_libversion_number,\n  sqlite3_malloc,\n  sqlite3_mprintf,\n  sqlite3_open,\n  sqlite3_open16,\n  sqlite3_prepare,\n  sqlite3_prepare16,\n  sqlite3_profile,\n  sqlite3_progress_handler,\n  sqlite3_realloc,\n  sqlite3_reset,\n  sqlite3_result_blob,\n  sqlite3_result_double,\n  sqlite3_result_error,\n  sqlite3_result_error16,\n  sqlite3_result_int,\n  sqlite3_result_int64,\n  sqlite3_result_null,\n  sqlite3_result_text,\n  sqlite3_result_text16,\n  sqlite3_result_text16be,\n  sqlite3_result_text16le,\n  sqlite3_result_value,\n  sqlite3_rollback_hook,\n  sqlite3_set_authorizer,\n  sqlite3_set_auxdata,\n  sqlite3_snprintf,\n  sqlite3_step,\n  sqlite3_table_column_metadata,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup,\n#else\n  0,\n#endif\n  sqlite3_total_changes,\n  sqlite3_trace,\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_transfer_bindings,\n#else\n  0,\n#endif\n  sqlite3_update_hook,\n  sqlite3_user_data,\n  sqlite3_value_blob,\n  sqlite3_value_bytes,\n  sqlite3_value_bytes16,\n  sqlite3_value_double,\n  sqlite3_value_int,\n  sqlite3_value_int64,\n  sqlite3_value_numeric_type,\n  sqlite3_value_text,\n  sqlite3_value_text16,\n  sqlite3_value_text16be,\n  sqlite3_value_text16le,\n  sqlite3_value_type,\n  sqlite3_vmprintf,\n  /*\n  ** The original API set ends here.  All extensions can call any\n  ** of the APIs above provided that the pointer is not NULL.  But\n  ** before calling APIs that follow, extension should check the\n  ** sqlite3_libversion_number() to make sure they are dealing with\n  ** a library that is new enough to support that API.\n  *************************************************************************\n  */\n  sqlite3_overload_function,\n\n  /*\n  ** Added after 3.3.13\n  */\n  sqlite3_prepare_v2,\n  sqlite3_prepare16_v2,\n  sqlite3_clear_bindings,\n\n  /*\n  ** Added for 3.4.1\n  */\n  sqlite3_create_module_v2,\n\n  /*\n  ** Added for 3.5.0\n  */\n  sqlite3_bind_zeroblob,\n  sqlite3_blob_bytes,\n  sqlite3_blob_close,\n  sqlite3_blob_open,\n  sqlite3_blob_read,\n  sqlite3_blob_write,\n  sqlite3_create_collation_v2,\n  sqlite3_file_control,\n  sqlite3_memory_highwater,\n  sqlite3_memory_used,\n#ifdef SQLITE_MUTEX_OMIT\n  0, \n  0, \n  0,\n  0,\n  0,\n#else\n  sqlite3_mutex_alloc,\n  sqlite3_mutex_enter,\n  sqlite3_mutex_free,\n  sqlite3_mutex_leave,\n  sqlite3_mutex_try,\n#endif\n  sqlite3_open_v2,\n  sqlite3_release_memory,\n  sqlite3_result_error_nomem,\n  sqlite3_result_error_toobig,\n  sqlite3_sleep,\n  sqlite3_soft_heap_limit,\n  sqlite3_vfs_find,\n  sqlite3_vfs_register,\n  sqlite3_vfs_unregister,\n\n  /*\n  ** Added for 3.5.8\n  */\n  sqlite3_threadsafe,\n  sqlite3_result_zeroblob,\n  sqlite3_result_error_code,\n  sqlite3_test_control,\n  sqlite3_randomness,\n  sqlite3_context_db_handle,\n\n  /*\n  ** Added for 3.6.0\n  */\n  sqlite3_extended_result_codes,\n  sqlite3_limit,\n  sqlite3_next_stmt,\n  sqlite3_sql,\n  sqlite3_status,\n\n  /*\n  ** Added for 3.7.4\n  */\n  sqlite3_backup_finish,\n  sqlite3_backup_init,\n  sqlite3_backup_pagecount,\n  sqlite3_backup_remaining,\n  sqlite3_backup_step,\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  sqlite3_compileoption_get,\n  sqlite3_compileoption_used,\n#else\n  0,\n  0,\n#endif\n  sqlite3_create_function_v2,\n  sqlite3_db_config,\n  sqlite3_db_mutex,\n  sqlite3_db_status,\n  sqlite3_extended_errcode,\n  sqlite3_log,\n  sqlite3_soft_heap_limit64,\n  sqlite3_sourceid,\n  sqlite3_stmt_status,\n  sqlite3_strnicmp,\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  sqlite3_unlock_notify,\n#else\n  0,\n#endif\n#ifndef SQLITE_OMIT_WAL\n  sqlite3_wal_autocheckpoint,\n  sqlite3_wal_checkpoint,\n  sqlite3_wal_hook,\n#else\n  0,\n  0,\n  0,\n#endif\n  sqlite3_blob_reopen,\n  sqlite3_vtab_config,\n  sqlite3_vtab_on_conflict,\n  sqlite3_close_v2,\n  sqlite3_db_filename,\n  sqlite3_db_readonly,\n  sqlite3_db_release_memory,\n  sqlite3_errstr,\n  sqlite3_stmt_busy,\n  sqlite3_stmt_readonly,\n  sqlite3_stricmp,\n  sqlite3_uri_boolean,\n  sqlite3_uri_int64,\n  sqlite3_uri_parameter,\n  sqlite3_vsnprintf,\n  sqlite3_wal_checkpoint_v2,\n  /* Version 3.8.7 and later */\n  sqlite3_auto_extension,\n  sqlite3_bind_blob64,\n  sqlite3_bind_text64,\n  sqlite3_cancel_auto_extension,\n  sqlite3_load_extension,\n  sqlite3_malloc64,\n  sqlite3_msize,\n  sqlite3_realloc64,\n  sqlite3_reset_auto_extension,\n  sqlite3_result_blob64,\n  sqlite3_result_text64,\n  sqlite3_strglob,\n  /* Version 3.8.11 and later */\n  (sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup,\n  sqlite3_value_free,\n  sqlite3_result_zeroblob64,\n  sqlite3_bind_zeroblob64,\n  /* Version 3.9.0 and later */\n  sqlite3_value_subtype,\n  sqlite3_result_subtype,\n  /* Version 3.10.0 and later */\n  sqlite3_status64,\n  sqlite3_strlike,\n  sqlite3_db_cacheflush,\n  /* Version 3.12.0 and later */\n  sqlite3_system_errno,\n  /* Version 3.14.0 and later */\n  sqlite3_trace_v2,\n  sqlite3_expanded_sql,\n  /* Version 3.18.0 and later */\n  sqlite3_set_last_insert_rowid,\n  /* Version 3.20.0 and later */\n  sqlite3_prepare_v3,\n  sqlite3_prepare16_v3,\n  sqlite3_bind_pointer,\n  sqlite3_result_pointer,\n  sqlite3_value_pointer\n};\n\n/*\n** Attempt to load an SQLite extension library contained in the file\n** zFile.  The entry point is zProc.  zProc may be 0 in which case a\n** default entry point name (sqlite3_extension_init) is used.  Use\n** of the default name is recommended.\n**\n** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.\n**\n** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with \n** error message text.  The calling function should free this memory\n** by calling sqlite3DbFree(db, ).\n*/\nstatic int sqlite3LoadExtension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  sqlite3_vfs *pVfs = db->pVfs;\n  void *handle;\n  sqlite3_loadext_entry xInit;\n  char *zErrmsg = 0;\n  const char *zEntry;\n  char *zAltEntry = 0;\n  void **aHandle;\n  u64 nMsg = 300 + sqlite3Strlen30(zFile);\n  int ii;\n  int rc;\n\n  /* Shared library endings to try if zFile cannot be loaded as written */\n  static const char *azEndings[] = {\n#if SQLITE_OS_WIN\n     \"dll\"   \n#elif defined(__APPLE__)\n     \"dylib\"\n#else\n     \"so\"\n#endif\n  };\n\n\n  if( pzErrMsg ) *pzErrMsg = 0;\n\n  /* Ticket #1863.  To avoid a creating security problems for older\n  ** applications that relink against newer versions of SQLite, the\n  ** ability to run load_extension is turned off by default.  One\n  ** must call either sqlite3_enable_load_extension(db) or\n  ** sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 1, 0)\n  ** to turn on extension loading.\n  */\n  if( (db->flags & SQLITE_LoadExtension)==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"not authorized\");\n    }\n    return SQLITE_ERROR;\n  }\n\n  zEntry = zProc ? zProc : \"sqlite3_extension_init\";\n\n  handle = sqlite3OsDlOpen(pVfs, zFile);\n#if SQLITE_OS_UNIX || SQLITE_OS_WIN\n  for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){\n    char *zAltFile = sqlite3_mprintf(\"%s.%s\", zFile, azEndings[ii]);\n    if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;\n    handle = sqlite3OsDlOpen(pVfs, zAltFile);\n    sqlite3_free(zAltFile);\n  }\n#endif\n  if( handle==0 ){\n    if( pzErrMsg ){\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg, \n            \"unable to open shared library [%s]\", zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    return SQLITE_ERROR;\n  }\n  xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n\n  /* If no entry point was specified and the default legacy\n  ** entry point name \"sqlite3_extension_init\" was not found, then\n  ** construct an entry point name \"sqlite3_X_init\" where the X is\n  ** replaced by the lowercase value of every ASCII alphabetic \n  ** character in the filename after the last \"/\" upto the first \".\",\n  ** and eliding the first three characters if they are \"lib\".  \n  ** Examples:\n  **\n  **    /usr/local/lib/libExample5.4.3.so ==>  sqlite3_example_init\n  **    C:/lib/mathfuncs.dll              ==>  sqlite3_mathfuncs_init\n  */\n  if( xInit==0 && zProc==0 ){\n    int iFile, iEntry, c;\n    int ncFile = sqlite3Strlen30(zFile);\n    zAltEntry = sqlite3_malloc64(ncFile+30);\n    if( zAltEntry==0 ){\n      sqlite3OsDlClose(pVfs, handle);\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(zAltEntry, \"sqlite3_\", 8);\n    for(iFile=ncFile-1; iFile>=0 && zFile[iFile]!='/'; iFile--){}\n    iFile++;\n    if( sqlite3_strnicmp(zFile+iFile, \"lib\", 3)==0 ) iFile += 3;\n    for(iEntry=8; (c = zFile[iFile])!=0 && c!='.'; iFile++){\n      if( sqlite3Isalpha(c) ){\n        zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c];\n      }\n    }\n    memcpy(zAltEntry+iEntry, \"_init\", 6);\n    zEntry = zAltEntry;\n    xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry);\n  }\n  if( xInit==0 ){\n    if( pzErrMsg ){\n      nMsg += sqlite3Strlen30(zEntry);\n      *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);\n      if( zErrmsg ){\n        sqlite3_snprintf(nMsg, zErrmsg,\n            \"no entry point [%s] in shared library [%s]\", zEntry, zFile);\n        sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);\n      }\n    }\n    sqlite3OsDlClose(pVfs, handle);\n    sqlite3_free(zAltEntry);\n    return SQLITE_ERROR;\n  }\n  sqlite3_free(zAltEntry);\n  rc = xInit(db, &zErrmsg, &sqlite3Apis);\n  if( rc ){\n    if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK;\n    if( pzErrMsg ){\n      *pzErrMsg = sqlite3_mprintf(\"error during initialization: %s\", zErrmsg);\n    }\n    sqlite3_free(zErrmsg);\n    sqlite3OsDlClose(pVfs, handle);\n    return SQLITE_ERROR;\n  }\n\n  /* Append the new shared library handle to the db->aExtension array. */\n  aHandle = sqlite3DbMallocZero(db, sizeof(handle)*(db->nExtension+1));\n  if( aHandle==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  if( db->nExtension>0 ){\n    memcpy(aHandle, db->aExtension, sizeof(handle)*db->nExtension);\n  }\n  sqlite3DbFree(db, db->aExtension);\n  db->aExtension = aHandle;\n\n  db->aExtension[db->nExtension++] = handle;\n  return SQLITE_OK;\n}\nint sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Use \"sqlite3_extension_init\" if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n){\n  int rc;\n  sqlite3_mutex_enter(db->mutex);\n  rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Call this routine when the database connection is closing in order\n** to clean up loaded extensions\n*/\nvoid sqlite3CloseExtensions(sqlite3 *db){\n  int i;\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(i=0; i<db->nExtension; i++){\n    sqlite3OsDlClose(db->pVfs, db->aExtension[i]);\n  }\n  sqlite3DbFree(db, db->aExtension);\n}\n\n/*\n** Enable or disable extension loading.  Extension loading is disabled by\n** default so as not to open security holes in older applications.\n*/\nint sqlite3_enable_load_extension(sqlite3 *db, int onoff){\n  sqlite3_mutex_enter(db->mutex);\n  if( onoff ){\n    db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;\n  }else{\n    db->flags &= ~(SQLITE_LoadExtension|SQLITE_LoadExtFunc);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n/*\n** The following object holds the list of automatically loaded\n** extensions.\n**\n** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MASTER\n** mutex must be held while accessing this list.\n*/\ntypedef struct sqlite3AutoExtList sqlite3AutoExtList;\nstatic SQLITE_WSD struct sqlite3AutoExtList {\n  u32 nExt;              /* Number of entries in aExt[] */          \n  void (**aExt)(void);   /* Pointers to the extension init functions */\n} sqlite3Autoext = { 0, 0 };\n\n/* The \"wsdAutoext\" macro will resolve to the autoextension\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Autoext\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdAutoextInit \\\n  sqlite3AutoExtList *x = &GLOBAL(sqlite3AutoExtList,sqlite3Autoext)\n# define wsdAutoext x[0]\n#else\n# define wsdAutoextInit\n# define wsdAutoext sqlite3Autoext\n#endif\n\n\n/*\n** Register a statically linked extension that is automatically\n** loaded by every new database connection.\n*/\nint sqlite3_auto_extension(\n  void (*xInit)(void)\n){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ){\n    return rc;\n  }else\n#endif\n  {\n    u32 i;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    for(i=0; i<wsdAutoext.nExt; i++){\n      if( wsdAutoext.aExt[i]==xInit ) break;\n    }\n    if( i==wsdAutoext.nExt ){\n      u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);\n      void (**aNew)(void);\n      aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte);\n      if( aNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        wsdAutoext.aExt = aNew;\n        wsdAutoext.aExt[wsdAutoext.nExt] = xInit;\n        wsdAutoext.nExt++;\n      }\n    }\n    sqlite3_mutex_leave(mutex);\n    assert( (rc&0xff)==rc );\n    return rc;\n  }\n}\n\n/*\n** Cancel a prior call to sqlite3_auto_extension.  Remove xInit from the\n** set of routines that is invoked for each new database connection, if it\n** is currently on the list.  If xInit is not on the list, then this\n** routine is a no-op.\n**\n** Return 1 if xInit was found on the list and removed.  Return 0 if xInit\n** was not on the list.\n*/\nint sqlite3_cancel_auto_extension(\n  void (*xInit)(void)\n){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  int i;\n  int n = 0;\n  wsdAutoextInit;\n  sqlite3_mutex_enter(mutex);\n  for(i=(int)wsdAutoext.nExt-1; i>=0; i--){\n    if( wsdAutoext.aExt[i]==xInit ){\n      wsdAutoext.nExt--;\n      wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];\n      n++;\n      break;\n    }\n  }\n  sqlite3_mutex_leave(mutex);\n  return n;\n}\n\n/*\n** Reset the automatic extension loading mechanism.\n*/\nvoid sqlite3_reset_auto_extension(void){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize()==SQLITE_OK )\n#endif\n  {\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n    wsdAutoextInit;\n    sqlite3_mutex_enter(mutex);\n    sqlite3_free(wsdAutoext.aExt);\n    wsdAutoext.aExt = 0;\n    wsdAutoext.nExt = 0;\n    sqlite3_mutex_leave(mutex);\n  }\n}\n\n/*\n** Load all automatic extensions.\n**\n** If anything goes wrong, set an error in the database connection.\n*/\nvoid sqlite3AutoLoadExtensions(sqlite3 *db){\n  u32 i;\n  int go = 1;\n  int rc;\n  sqlite3_loadext_entry xInit;\n\n  wsdAutoextInit;\n  if( wsdAutoext.nExt==0 ){\n    /* Common case: early out without every having to acquire a mutex */\n    return;\n  }\n  for(i=0; go; i++){\n    char *zErrmsg;\n#if SQLITE_THREADSAFE\n    sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n    const sqlite3_api_routines *pThunk = 0;\n#else\n    const sqlite3_api_routines *pThunk = &sqlite3Apis;\n#endif\n    sqlite3_mutex_enter(mutex);\n    if( i>=wsdAutoext.nExt ){\n      xInit = 0;\n      go = 0;\n    }else{\n      xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i];\n    }\n    sqlite3_mutex_leave(mutex);\n    zErrmsg = 0;\n    if( xInit && (rc = xInit(db, &zErrmsg, pThunk))!=0 ){\n      sqlite3ErrorWithMsg(db, rc,\n            \"automatic extension loading failed: %s\", zErrmsg);\n      go = 0;\n    }\n    sqlite3_free(zErrmsg);\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/main.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Main file for the SQLite library.  The routines in this file\n** implement the programmer interface to the library.  Routines in\n** other files are for internal use by SQLite and should not be\n** accessed by users of the library.\n*/\n#include \"sqliteInt.h\"\n\n#ifdef SQLITE_ENABLE_FTS3\n# include \"fts3.h\"\n#endif\n#ifdef SQLITE_ENABLE_RTREE\n# include \"rtree.h\"\n#endif\n#ifdef SQLITE_ENABLE_ICU\n# include \"sqliteicu.h\"\n#endif\n#ifdef SQLITE_ENABLE_JSON1\nint sqlite3Json1Init(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_STMTVTAB\nint sqlite3StmtVtabInit(sqlite3*);\n#endif\n#ifdef SQLITE_ENABLE_FTS5\nint sqlite3Fts5Init(sqlite3*);\n#endif\n\n#ifndef SQLITE_AMALGAMATION\n/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant\n** contains the text of SQLITE_VERSION macro. \n*/\nconst char sqlite3_version[] = SQLITE_VERSION;\n#endif\n\n/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns\n** a pointer to the to the sqlite3_version[] string constant. \n*/\nconst char *sqlite3_libversion(void){ return sqlite3_version; }\n\n/* IMPLEMENTATION-OF: R-25063-23286 The sqlite3_sourceid() function returns a\n** pointer to a string constant whose value is the same as the\n** SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using\n** an edited copy of the amalgamation, then the last four characters of\n** the hash might be different from SQLITE_SOURCE_ID.\n*/\nconst char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }\n\n/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function\n** returns an integer equal to SQLITE_VERSION_NUMBER.\n*/\nint sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }\n\n/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns\n** zero if and only if SQLite was compiled with mutexing code omitted due to\n** the SQLITE_THREADSAFE compile-time option being set to 0.\n*/\nint sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }\n\n/*\n** When compiling the test fixture or with debugging enabled (on Win32),\n** this variable being set to non-zero will cause OSTRACE macros to emit\n** extra diagnostic information.\n*/\n#ifdef SQLITE_HAVE_OS_TRACE\n# ifndef SQLITE_DEBUG_OS_TRACE\n#   define SQLITE_DEBUG_OS_TRACE 0\n# endif\n  int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** If the following function pointer is not NULL and if\n** SQLITE_ENABLE_IOTRACE is enabled, then messages describing\n** I/O active are written using this function.  These messages\n** are intended for debugging activity only.\n*/\nSQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;\n#endif\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** temporary files.\n**\n** See also the \"PRAGMA temp_store_directory\" SQL command.\n*/\nchar *sqlite3_temp_directory = 0;\n\n/*\n** If the following global variable points to a string which is the\n** name of a directory, then that directory will be used to store\n** all database files specified with a relative pathname.\n**\n** See also the \"PRAGMA data_store_directory\" SQL command.\n*/\nchar *sqlite3_data_directory = 0;\n\n/*\n** Initialize SQLite.  \n**\n** This routine must be called to initialize the memory allocation,\n** VFS, and mutex subsystems prior to doing any serious work with\n** SQLite.  But as long as you do not compile with SQLITE_OMIT_AUTOINIT\n** this routine will be called automatically by key routines such as\n** sqlite3_open().  \n**\n** This routine is a no-op except on its very first call for the process,\n** or for the first call after a call to sqlite3_shutdown.\n**\n** The first thread to call this routine runs the initialization to\n** completion.  If subsequent threads call this routine before the first\n** thread has finished the initialization process, then the subsequent\n** threads must block until the first thread finishes with the initialization.\n**\n** The first thread might call this routine recursively.  Recursive\n** calls to this routine should not block, of course.  Otherwise the\n** initialization process would never complete.\n**\n** Let X be the first thread to enter this routine.  Let Y be some other\n** thread.  Then while the initial invocation of this routine by X is\n** incomplete, it is required that:\n**\n**    *  Calls to this routine from Y must block until the outer-most\n**       call by X completes.\n**\n**    *  Recursive calls to this routine from thread X return immediately\n**       without blocking.\n*/\nint sqlite3_initialize(void){\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; )       /* The main static mutex */\n  int rc;                                      /* Result code */\n#ifdef SQLITE_EXTRA_INIT\n  int bRunExtraInit = 0;                       /* Extra initialization needed */\n#endif\n\n#ifdef SQLITE_OMIT_WSD\n  rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  /* If the following assert() fails on some obscure processor/compiler\n  ** combination, the work-around is to set the correct pointer\n  ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */\n  assert( SQLITE_PTRSIZE==sizeof(char*) );\n\n  /* If SQLite is already completely initialized, then this call\n  ** to sqlite3_initialize() should be a no-op.  But the initialization\n  ** must be complete.  So isInit must not be set until the very end\n  ** of this routine.\n  */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_OK;\n\n  /* Make sure the mutex subsystem is initialized.  If unable to \n  ** initialize the mutex subsystem, return early with the error.\n  ** If the system is so sick that we are unable to allocate a mutex,\n  ** there is not much SQLite is going to be able to do.\n  **\n  ** The mutex subsystem must take care of serializing its own\n  ** initialization.\n  */\n  rc = sqlite3MutexInit();\n  if( rc ) return rc;\n\n  /* Initialize the malloc() system and the recursive pInitMutex mutex.\n  ** This operation is protected by the STATIC_MASTER mutex.  Note that\n  ** MutexAlloc() is called for a static mutex prior to initializing the\n  ** malloc subsystem - this implies that the allocation of a static\n  ** mutex must not require support from the malloc subsystem.\n  */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.isMutexInit = 1;\n  if( !sqlite3GlobalConfig.isMallocInit ){\n    rc = sqlite3MallocInit();\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.isMallocInit = 1;\n    if( !sqlite3GlobalConfig.pInitMutex ){\n      sqlite3GlobalConfig.pInitMutex =\n           sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n      if( sqlite3GlobalConfig.bCoreMutex && !sqlite3GlobalConfig.pInitMutex ){\n        rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3GlobalConfig.nRefInitMutex++;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* If rc is not SQLITE_OK at this point, then either the malloc\n  ** subsystem could not be initialized or the system failed to allocate\n  ** the pInitMutex mutex. Return an error in either case.  */\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* Do the rest of the initialization under the recursive mutex so\n  ** that we will be able to handle recursive calls into\n  ** sqlite3_initialize().  The recursive calls normally come through\n  ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other\n  ** recursive calls might also be possible.\n  **\n  ** IMPLEMENTATION-OF: R-00140-37445 SQLite automatically serializes calls\n  ** to the xInit method, so the xInit method need not be threadsafe.\n  **\n  ** The following mutex is what serializes access to the appdef pcache xInit\n  ** methods.  The sqlite3_pcache_methods.xInit() all is embedded in the\n  ** call to sqlite3PcacheInitialize().\n  */\n  sqlite3_mutex_enter(sqlite3GlobalConfig.pInitMutex);\n  if( sqlite3GlobalConfig.isInit==0 && sqlite3GlobalConfig.inProgress==0 ){\n    sqlite3GlobalConfig.inProgress = 1;\n#ifdef SQLITE_ENABLE_SQLLOG\n    {\n      extern void sqlite3_init_sqllog(void);\n      sqlite3_init_sqllog();\n    }\n#endif\n    memset(&sqlite3BuiltinFunctions, 0, sizeof(sqlite3BuiltinFunctions));\n    sqlite3RegisterBuiltinFunctions();\n    if( sqlite3GlobalConfig.isPCacheInit==0 ){\n      rc = sqlite3PcacheInitialize();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3GlobalConfig.isPCacheInit = 1;\n      rc = sqlite3OsInit();\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage, \n          sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);\n      sqlite3GlobalConfig.isInit = 1;\n#ifdef SQLITE_EXTRA_INIT\n      bRunExtraInit = 1;\n#endif\n    }\n    sqlite3GlobalConfig.inProgress = 0;\n  }\n  sqlite3_mutex_leave(sqlite3GlobalConfig.pInitMutex);\n\n  /* Go back under the static mutex and clean up the recursive\n  ** mutex to prevent a resource leak.\n  */\n  sqlite3_mutex_enter(pMaster);\n  sqlite3GlobalConfig.nRefInitMutex--;\n  if( sqlite3GlobalConfig.nRefInitMutex<=0 ){\n    assert( sqlite3GlobalConfig.nRefInitMutex==0 );\n    sqlite3_mutex_free(sqlite3GlobalConfig.pInitMutex);\n    sqlite3GlobalConfig.pInitMutex = 0;\n  }\n  sqlite3_mutex_leave(pMaster);\n\n  /* The following is just a sanity check to make sure SQLite has\n  ** been compiled correctly.  It is important to run this code, but\n  ** we don't want to run it too often and soak up CPU cycles for no\n  ** reason.  So we run it once during initialization.\n  */\n#ifndef NDEBUG\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  /* This section of code's only \"output\" is via assert() statements. */\n  if ( rc==SQLITE_OK ){\n    u64 x = (((u64)1)<<63)-1;\n    double y;\n    assert(sizeof(x)==8);\n    assert(sizeof(x)==sizeof(y));\n    memcpy(&y, &x, 8);\n    assert( sqlite3IsNaN(y) );\n  }\n#endif\n#endif\n\n  /* Do extra initialization steps requested by the SQLITE_EXTRA_INIT\n  ** compile-time option.\n  */\n#ifdef SQLITE_EXTRA_INIT\n  if( bRunExtraInit ){\n    int SQLITE_EXTRA_INIT(const char*);\n    rc = SQLITE_EXTRA_INIT(0);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Undo the effects of sqlite3_initialize().  Must not be called while\n** there are outstanding database connections or memory allocations or\n** while any part of SQLite is otherwise in use in any thread.  This\n** routine is not threadsafe.  But it is safe to invoke this routine\n** on when SQLite is already shut down.  If SQLite is already shut down\n** when this routine is invoked, then this routine is a harmless no-op.\n*/\nint sqlite3_shutdown(void){\n#ifdef SQLITE_OMIT_WSD\n  int rc = sqlite3_wsd_init(4096, 24);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n#endif\n\n  if( sqlite3GlobalConfig.isInit ){\n#ifdef SQLITE_EXTRA_SHUTDOWN\n    void SQLITE_EXTRA_SHUTDOWN(void);\n    SQLITE_EXTRA_SHUTDOWN();\n#endif\n    sqlite3_os_end();\n    sqlite3_reset_auto_extension();\n    sqlite3GlobalConfig.isInit = 0;\n  }\n  if( sqlite3GlobalConfig.isPCacheInit ){\n    sqlite3PcacheShutdown();\n    sqlite3GlobalConfig.isPCacheInit = 0;\n  }\n  if( sqlite3GlobalConfig.isMallocInit ){\n    sqlite3MallocEnd();\n    sqlite3GlobalConfig.isMallocInit = 0;\n\n#ifndef SQLITE_OMIT_SHUTDOWN_DIRECTORIES\n    /* The heap subsystem has now been shutdown and these values are supposed\n    ** to be NULL or point to memory that was obtained from sqlite3_malloc(),\n    ** which would rely on that heap subsystem; therefore, make sure these\n    ** values cannot refer to heap memory that was just invalidated when the\n    ** heap subsystem was shutdown.  This is only done if the current call to\n    ** this function resulted in the heap subsystem actually being shutdown.\n    */\n    sqlite3_data_directory = 0;\n    sqlite3_temp_directory = 0;\n#endif\n  }\n  if( sqlite3GlobalConfig.isMutexInit ){\n    sqlite3MutexEnd();\n    sqlite3GlobalConfig.isMutexInit = 0;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** This API allows applications to modify the global configuration of\n** the SQLite library at run-time.\n**\n** This routine should only be called when there are no outstanding\n** database connections or memory allocations.  This routine is not\n** threadsafe.  Failure to heed these warnings can lead to unpredictable\n** behavior.\n*/\nint sqlite3_config(int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n  /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while\n  ** the SQLite library is in use. */\n  if( sqlite3GlobalConfig.isInit ) return SQLITE_MISUSE_BKPT;\n\n  va_start(ap, op);\n  switch( op ){\n\n    /* Mutex configuration options are only available in a threadsafe\n    ** compile.\n    */\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0  /* IMP: R-54466-46756 */\n    case SQLITE_CONFIG_SINGLETHREAD: {\n      /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to\n      ** Single-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 0;  /* Disable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */\n    case SQLITE_CONFIG_MULTITHREAD: {\n      /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to\n      ** Multi-thread. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 0;  /* Disable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */\n    case SQLITE_CONFIG_SERIALIZED: {\n      /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to\n      ** Serialized. */\n      sqlite3GlobalConfig.bCoreMutex = 1;  /* Enable mutex on core */\n      sqlite3GlobalConfig.bFullMutex = 1;  /* Enable mutex on connections */\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */\n    case SQLITE_CONFIG_MUTEX: {\n      /* Specify an alternative mutex implementation */\n      sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);\n      break;\n    }\n#endif\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-14450-37597 */\n    case SQLITE_CONFIG_GETMUTEX: {\n      /* Retrieve the current mutex implementation */\n      *va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MALLOC: {\n      /* EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The argument specifies alternative\n      ** low-level memory allocation routines to be used in place of the memory\n      ** allocation routines built into SQLite. */\n      sqlite3GlobalConfig.m = *va_arg(ap, sqlite3_mem_methods*);\n      break;\n    }\n    case SQLITE_CONFIG_GETMALLOC: {\n      /* EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a\n      ** single argument which is a pointer to an instance of the\n      ** sqlite3_mem_methods structure. The sqlite3_mem_methods structure is\n      ** filled with the currently defined memory allocation routines. */\n      if( sqlite3GlobalConfig.m.xMalloc==0 ) sqlite3MemSetDefault();\n      *va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;\n      break;\n    }\n    case SQLITE_CONFIG_MEMSTATUS: {\n      /* EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes\n      ** single argument of type int, interpreted as a boolean, which enables\n      ** or disables the collection of memory allocation statistics. */\n      sqlite3GlobalConfig.bMemstat = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_SMALL_MALLOC: {\n      sqlite3GlobalConfig.bSmallMalloc = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PAGECACHE: {\n      /* EVIDENCE-OF: R-18761-36601 There are three arguments to\n      ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem),\n      ** the size of each page cache line (sz), and the number of cache lines\n      ** (N). */\n      sqlite3GlobalConfig.pPage = va_arg(ap, void*);\n      sqlite3GlobalConfig.szPage = va_arg(ap, int);\n      sqlite3GlobalConfig.nPage = va_arg(ap, int);\n      break;\n    }\n    case SQLITE_CONFIG_PCACHE_HDRSZ: {\n      /* EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes\n      ** a single parameter which is a pointer to an integer and writes into\n      ** that integer the number of extra bytes per page required for each page\n      ** in SQLITE_CONFIG_PAGECACHE. */\n      *va_arg(ap, int*) = \n          sqlite3HeaderSizeBtree() +\n          sqlite3HeaderSizePcache() +\n          sqlite3HeaderSizePcache1();\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE: {\n      /* no-op */\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE: {\n      /* now an error */\n      rc = SQLITE_ERROR;\n      break;\n    }\n\n    case SQLITE_CONFIG_PCACHE2: {\n      /* EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. This object specifies the interface to a custom page cache\n      ** implementation. */\n      sqlite3GlobalConfig.pcache2 = *va_arg(ap, sqlite3_pcache_methods2*);\n      break;\n    }\n    case SQLITE_CONFIG_GETPCACHE2: {\n      /* EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a\n      ** single argument which is a pointer to an sqlite3_pcache_methods2\n      ** object. SQLite copies of the current page cache implementation into\n      ** that object. */\n      if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n        sqlite3PCacheSetDefault();\n      }\n      *va_arg(ap, sqlite3_pcache_methods2*) = sqlite3GlobalConfig.pcache2;\n      break;\n    }\n\n/* EVIDENCE-OF: R-06626-12911 The SQLITE_CONFIG_HEAP option is only\n** available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or\n** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n    case SQLITE_CONFIG_HEAP: {\n      /* EVIDENCE-OF: R-19854-42126 There are three arguments to\n      ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the\n      ** number of bytes in the memory buffer, and the minimum allocation size.\n      */\n      sqlite3GlobalConfig.pHeap = va_arg(ap, void*);\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      sqlite3GlobalConfig.mnReq = va_arg(ap, int);\n\n      if( sqlite3GlobalConfig.mnReq<1 ){\n        sqlite3GlobalConfig.mnReq = 1;\n      }else if( sqlite3GlobalConfig.mnReq>(1<<12) ){\n        /* cap min request size at 2^12 */\n        sqlite3GlobalConfig.mnReq = (1<<12);\n      }\n\n      if( sqlite3GlobalConfig.pHeap==0 ){\n        /* EVIDENCE-OF: R-49920-60189 If the first pointer (the memory pointer)\n        ** is NULL, then SQLite reverts to using its default memory allocator\n        ** (the system malloc() implementation), undoing any prior invocation of\n        ** SQLITE_CONFIG_MALLOC.\n        **\n        ** Setting sqlite3GlobalConfig.m to all zeros will cause malloc to\n        ** revert to its default implementation when sqlite3_initialize() is run\n        */\n        memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));\n      }else{\n        /* EVIDENCE-OF: R-61006-08918 If the memory pointer is not NULL then the\n        ** alternative memory allocator is engaged to handle all of SQLites\n        ** memory allocation needs. */\n#ifdef SQLITE_ENABLE_MEMSYS3\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS5\n        sqlite3GlobalConfig.m = *sqlite3MemGetMemsys5();\n#endif\n      }\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_LOOKASIDE: {\n      sqlite3GlobalConfig.szLookaside = va_arg(ap, int);\n      sqlite3GlobalConfig.nLookaside = va_arg(ap, int);\n      break;\n    }\n    \n    /* Record a pointer to the logger function and its first argument.\n    ** The default is NULL.  Logging is disabled if the function pointer is\n    ** NULL.\n    */\n    case SQLITE_CONFIG_LOG: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xLog = va_arg(ap, void(*)(void*,int,const char*));\n      */\n      typedef void(*LOGFUNC_t)(void*,int,const char*);\n      sqlite3GlobalConfig.xLog = va_arg(ap, LOGFUNC_t);\n      sqlite3GlobalConfig.pLogArg = va_arg(ap, void*);\n      break;\n    }\n\n    /* EVIDENCE-OF: R-55548-33817 The compile-time setting for URI filenames\n    ** can be changed at start-time using the\n    ** sqlite3_config(SQLITE_CONFIG_URI,1) or\n    ** sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls.\n    */\n    case SQLITE_CONFIG_URI: {\n      /* EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single\n      ** argument of type int. If non-zero, then URI handling is globally\n      ** enabled. If the parameter is zero, then URI handling is globally\n      ** disabled. */\n      sqlite3GlobalConfig.bOpenUri = va_arg(ap, int);\n      break;\n    }\n\n    case SQLITE_CONFIG_COVERING_INDEX_SCAN: {\n      /* EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN\n      ** option takes a single integer argument which is interpreted as a\n      ** boolean in order to enable or disable the use of covering indices for\n      ** full table scans in the query optimizer. */\n      sqlite3GlobalConfig.bUseCis = va_arg(ap, int);\n      break;\n    }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n    case SQLITE_CONFIG_SQLLOG: {\n      typedef void(*SQLLOGFUNC_t)(void*, sqlite3*, const char*, int);\n      sqlite3GlobalConfig.xSqllog = va_arg(ap, SQLLOGFUNC_t);\n      sqlite3GlobalConfig.pSqllogArg = va_arg(ap, void *);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_MMAP_SIZE: {\n      /* EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit\n      ** integer (sqlite3_int64) values that are the default mmap size limit\n      ** (the default setting for PRAGMA mmap_size) and the maximum allowed\n      ** mmap size limit. */\n      sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);\n      sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);\n      /* EVIDENCE-OF: R-53367-43190 If either argument to this option is\n      ** negative, then that argument is changed to its compile-time default.\n      **\n      ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be\n      ** silently truncated if necessary so that it does not exceed the\n      ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE\n      ** compile-time option.\n      */\n      if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){\n        mxMmap = SQLITE_MAX_MMAP_SIZE;\n      }\n      if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;\n      if( szMmap>mxMmap) szMmap = mxMmap;\n      sqlite3GlobalConfig.mxMmap = mxMmap;\n      sqlite3GlobalConfig.szMmap = szMmap;\n      break;\n    }\n\n#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) /* IMP: R-04780-55815 */\n    case SQLITE_CONFIG_WIN32_HEAPSIZE: {\n      /* EVIDENCE-OF: R-34926-03360 SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit\n      ** unsigned integer value that specifies the maximum size of the created\n      ** heap. */\n      sqlite3GlobalConfig.nHeap = va_arg(ap, int);\n      break;\n    }\n#endif\n\n    case SQLITE_CONFIG_PMASZ: {\n      sqlite3GlobalConfig.szPma = va_arg(ap, unsigned int);\n      break;\n    }\n\n    case SQLITE_CONFIG_STMTJRNL_SPILL: {\n      sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int);\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n/*\n** Set up the lookaside buffers for a database connection.\n** Return SQLITE_OK on success.  \n** If lookaside is already active, return SQLITE_BUSY.\n**\n** The sz parameter is the number of bytes in each lookaside slot.\n** The cnt parameter is the number of slots.  If pStart is NULL the\n** space for the lookaside memory is obtained from sqlite3_malloc().\n** If pStart is not NULL then it is sz*cnt bytes of memory to use for\n** the lookaside memory.\n*/\nstatic int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  void *pStart;\n  \n  if( sqlite3LookasideUsed(db,0)>0 ){\n    return SQLITE_BUSY;\n  }\n  /* Free any existing lookaside buffer for this handle before\n  ** allocating a new one so we don't have to have space for \n  ** both at the same time.\n  */\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger\n  ** than a pointer to be useful.\n  */\n  sz = ROUNDDOWN8(sz);  /* IMP: R-33038-09382 */\n  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;\n  if( cnt<0 ) cnt = 0;\n  if( sz==0 || cnt==0 ){\n    sz = 0;\n    pStart = 0;\n  }else if( pBuf==0 ){\n    sqlite3BeginBenignMalloc();\n    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */\n    sqlite3EndBenignMalloc();\n    if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;\n  }else{\n    pStart = pBuf;\n  }\n  db->lookaside.pStart = pStart;\n  db->lookaside.pInit = 0;\n  db->lookaside.pFree = 0;\n  db->lookaside.sz = (u16)sz;\n  if( pStart ){\n    int i;\n    LookasideSlot *p;\n    assert( sz > (int)sizeof(LookasideSlot*) );\n    db->lookaside.nSlot = cnt;\n    p = (LookasideSlot*)pStart;\n    for(i=cnt-1; i>=0; i--){\n      p->pNext = db->lookaside.pInit;\n      db->lookaside.pInit = p;\n      p = (LookasideSlot*)&((u8*)p)[sz];\n    }\n    db->lookaside.pEnd = p;\n    db->lookaside.bDisable = 0;\n    db->lookaside.bMalloced = pBuf==0 ?1:0;\n  }else{\n    db->lookaside.pStart = db;\n    db->lookaside.pEnd = db;\n    db->lookaside.bDisable = 1;\n    db->lookaside.bMalloced = 0;\n    db->lookaside.nSlot = 0;\n  }\n#endif /* SQLITE_OMIT_LOOKASIDE */\n  return SQLITE_OK;\n}\n\n/*\n** Return the mutex associated with a database connection.\n*/\nsqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->mutex;\n}\n\n/*\n** Free up as much memory as we can from the given database\n** connection.\n*/\nint sqlite3_db_release_memory(sqlite3 *db){\n  int i;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      sqlite3PagerShrink(pPager);\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Flush any dirty pages in the pager-cache for any attached database\n** to disk.\n*/\nint sqlite3_db_cacheflush(sqlite3 *db){\n  int i;\n  int rc = SQLITE_OK;\n  int bSeenBusy = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt && sqlite3BtreeIsInTrans(pBt) ){\n      Pager *pPager = sqlite3BtreePager(pBt);\n      rc = sqlite3PagerFlush(pPager);\n      if( rc==SQLITE_BUSY ){\n        bSeenBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);\n}\n\n/*\n** Configuration settings for an individual database connection\n*/\nint sqlite3_db_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc;\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_DBCONFIG_MAINDBNAME: {\n      /* IMP: R-06824-28531 */\n      /* IMP: R-36257-52125 */\n      db->aDb[0].zDbSName = va_arg(ap,char*);\n      rc = SQLITE_OK;\n      break;\n    }\n    case SQLITE_DBCONFIG_LOOKASIDE: {\n      void *pBuf = va_arg(ap, void*); /* IMP: R-26835-10964 */\n      int sz = va_arg(ap, int);       /* IMP: R-47871-25994 */\n      int cnt = va_arg(ap, int);      /* IMP: R-04460-53386 */\n      rc = setupLookaside(db, pBuf, sz, cnt);\n      break;\n    }\n    default: {\n      static const struct {\n        int op;      /* The opcode */\n        u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */\n      } aFlagOp[] = {\n        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },\n        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },\n        { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer  },\n        { SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension  },\n        { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE,      SQLITE_NoCkptOnClose  },\n        { SQLITE_DBCONFIG_ENABLE_QPSG,           SQLITE_EnableQPSG     },\n      };\n      unsigned int i;\n      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */\n      for(i=0; i<ArraySize(aFlagOp); i++){\n        if( aFlagOp[i].op==op ){\n          int onoff = va_arg(ap, int);\n          int *pRes = va_arg(ap, int*);\n          u32 oldFlags = db->flags;\n          if( onoff>0 ){\n            db->flags |= aFlagOp[i].mask;\n          }else if( onoff==0 ){\n            db->flags &= ~aFlagOp[i].mask;\n          }\n          if( oldFlags!=db->flags ){\n            sqlite3ExpirePreparedStatements(db);\n          }\n          if( pRes ){\n            *pRes = (db->flags & aFlagOp[i].mask)!=0;\n          }\n          rc = SQLITE_OK;\n          break;\n        }\n      }\n      break;\n    }\n  }\n  va_end(ap);\n  return rc;\n}\n\n\n/*\n** Return true if the buffer z[0..n-1] contains all spaces.\n*/\nstatic int allSpaces(const char *z, int n){\n  while( n>0 && z[n-1]==' ' ){ n--; }\n  return n==0;\n}\n\n/*\n** This is the default collating function named \"BINARY\" which is always\n** available.\n**\n** If the padFlag argument is not NULL then space padding at the end\n** of strings is ignored.  This implements the RTRIM collation.\n*/\nstatic int binCollFunc(\n  void *padFlag,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares\n  ** strings byte by byte using the memcmp() function from the standard C\n  ** library. */\n  assert( pKey1 && pKey2 );\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ){\n    if( padFlag\n     && allSpaces(((char*)pKey1)+n, nKey1-n)\n     && allSpaces(((char*)pKey2)+n, nKey2-n)\n    ){\n      /* EVIDENCE-OF: R-31624-24737 RTRIM is like BINARY except that extra\n      ** spaces at the end of either string do not change the result. In other\n      ** words, strings will compare equal to one another as long as they\n      ** differ only in the number of spaces at the end.\n      */\n    }else{\n      rc = nKey1 - nKey2;\n    }\n  }\n  return rc;\n}\n\n/*\n** Another built-in collating sequence: NOCASE. \n**\n** This collating sequence is intended to be used for \"case independent\n** comparison\". SQLite's knowledge of upper and lower case equivalents\n** extends only to the 26 characters used in the English language.\n**\n** At the moment there is only a UTF-8 implementation.\n*/\nstatic int nocaseCollatingFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int r = sqlite3StrNICmp(\n      (const char *)pKey1, (const char *)pKey2, (nKey1<nKey2)?nKey1:nKey2);\n  UNUSED_PARAMETER(NotUsed);\n  if( 0==r ){\n    r = nKey1-nKey2;\n  }\n  return r;\n}\n\n/*\n** Return the ROWID of the most recent insert\n*/\nsqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->lastRowid;\n}\n\n/*\n** Set the value returned by the sqlite3_last_insert_rowid() API function.\n*/\nvoid sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->lastRowid = iRowid;\n  sqlite3_mutex_leave(db->mutex);\n}\n\n/*\n** Return the number of changes in the most recent call to sqlite3_exec().\n*/\nint sqlite3_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nChange;\n}\n\n/*\n** Return the number of changes since the database handle was opened.\n*/\nint sqlite3_total_changes(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->nTotalChange;\n}\n\n/*\n** Close all open savepoints. This function only manipulates fields of the\n** database handle object, it does not close any savepoints that may be open\n** at the b-tree/pager level.\n*/\nvoid sqlite3CloseSavepoints(sqlite3 *db){\n  while( db->pSavepoint ){\n    Savepoint *pTmp = db->pSavepoint;\n    db->pSavepoint = pTmp->pNext;\n    sqlite3DbFree(db, pTmp);\n  }\n  db->nSavepoint = 0;\n  db->nStatement = 0;\n  db->isTransactionSavepoint = 0;\n}\n\n/*\n** Invoke the destructor function associated with FuncDef p, if any. Except,\n** if this is not the last copy of the function, do not invoke it. Multiple\n** copies of a single function are created when create_function() is called\n** with SQLITE_ANY as the encoding.\n*/\nstatic void functionDestroy(sqlite3 *db, FuncDef *p){\n  FuncDestructor *pDestructor = p->u.pDestructor;\n  if( pDestructor ){\n    pDestructor->nRef--;\n    if( pDestructor->nRef==0 ){\n      pDestructor->xDestroy(pDestructor->pUserData);\n      sqlite3DbFree(db, pDestructor);\n    }\n  }\n}\n\n/*\n** Disconnect all sqlite3_vtab objects that belong to database connection\n** db. This is called when db is being closed.\n*/\nstatic void disconnectAllVtab(sqlite3 *db){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int i;\n  HashElem *p;\n  sqlite3BtreeEnterAll(db);\n  for(i=0; i<db->nDb; i++){\n    Schema *pSchema = db->aDb[i].pSchema;\n    if( db->aDb[i].pSchema ){\n      for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n        Table *pTab = (Table *)sqliteHashData(p);\n        if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab);\n      }\n    }\n  }\n  for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){\n    Module *pMod = (Module *)sqliteHashData(p);\n    if( pMod->pEpoTab ){\n      sqlite3VtabDisconnect(db, pMod->pEpoTab);\n    }\n  }\n  sqlite3VtabUnlockList(db);\n  sqlite3BtreeLeaveAll(db);\n#else\n  UNUSED_PARAMETER(db);\n#endif\n}\n\n/*\n** Return TRUE if database connection db has unfinalized prepared\n** statements or unfinished sqlite3_backup objects.  \n*/\nstatic int connectionIsBusy(sqlite3 *db){\n  int j;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->pVdbe ) return 1;\n  for(j=0; j<db->nDb; j++){\n    Btree *pBt = db->aDb[j].pBt;\n    if( pBt && sqlite3BtreeIsInBackup(pBt) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** Close an existing SQLite database\n*/\nstatic int sqlite3Close(sqlite3 *db, int forceZombie){\n  if( !db ){\n    /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or\n    ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */\n    return SQLITE_OK;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mTrace & SQLITE_TRACE_CLOSE ){\n    db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);\n  }\n\n  /* Force xDisconnect calls on all virtual tables */\n  disconnectAllVtab(db);\n\n  /* If a transaction is open, the disconnectAllVtab() call above\n  ** will not have called the xDisconnect() method on any virtual\n  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()\n  ** call will do so. We need to do this before the check for active\n  ** SQL statements below, as the v-table implementation may be storing\n  ** some prepared statements internally.\n  */\n  sqlite3VtabRollback(db);\n\n  /* Legacy behavior (sqlite3_close() behavior) is to return\n  ** SQLITE_BUSY if the connection can not be closed immediately.\n  */\n  if( !forceZombie && connectionIsBusy(db) ){\n    sqlite3ErrorWithMsg(db, SQLITE_BUSY, \"unable to close due to unfinalized \"\n       \"statements or unfinished backups\");\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_BUSY;\n  }\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Closing the handle. Fourth parameter is passed the value 2. */\n    sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);\n  }\n#endif\n\n  /* Convert the connection into a zombie and then close it.\n  */\n  db->magic = SQLITE_MAGIC_ZOMBIE;\n  sqlite3LeaveMutexAndCloseZombie(db);\n  return SQLITE_OK;\n}\n\n/*\n** Two variations on the public interface for closing a database\n** connection. The sqlite3_close() version returns SQLITE_BUSY and\n** leaves the connection option if there are unfinalized prepared\n** statements or unfinished sqlite3_backups.  The sqlite3_close_v2()\n** version forces the connection to become a zombie if there are\n** unclosed resources, and arranges for deallocation when the last\n** prepare statement or sqlite3_backup closes.\n*/\nint sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }\nint sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }\n\n\n/*\n** Close the mutex on database connection db.\n**\n** Furthermore, if database connection db is a zombie (meaning that there\n** has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and\n** every sqlite3_stmt has now been finalized and every sqlite3_backup has\n** finished, then free all resources.\n*/\nvoid sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){\n  HashElem *i;                    /* Hash table iterator */\n  int j;\n\n  /* If there are outstanding sqlite3_stmt or sqlite3_backup objects\n  ** or if the connection has not yet been closed by sqlite3_close_v2(),\n  ** then just leave the mutex and return.\n  */\n  if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){\n    sqlite3_mutex_leave(db->mutex);\n    return;\n  }\n\n  /* If we reach this point, it means that the database connection has\n  ** closed all sqlite3_stmt and sqlite3_backup objects and has been\n  ** passed to sqlite3_close (meaning that it is a zombie).  Therefore,\n  ** go ahead and free all resources.\n  */\n\n  /* If a transaction is open, roll it back. This also ensures that if\n  ** any database schemas have been modified by an uncommitted transaction\n  ** they are reset. And that the required b-tree mutex is held to make\n  ** the pager rollback and schema reset an atomic operation. */\n  sqlite3RollbackAll(db, SQLITE_OK);\n\n  /* Free any outstanding Savepoint structures. */\n  sqlite3CloseSavepoints(db);\n\n  /* Close all database connections */\n  for(j=0; j<db->nDb; j++){\n    struct Db *pDb = &db->aDb[j];\n    if( pDb->pBt ){\n      sqlite3BtreeClose(pDb->pBt);\n      pDb->pBt = 0;\n      if( j!=1 ){\n        pDb->pSchema = 0;\n      }\n    }\n  }\n  /* Clear the TEMP schema separately and last */\n  if( db->aDb[1].pSchema ){\n    sqlite3SchemaClear(db->aDb[1].pSchema);\n  }\n  sqlite3VtabUnlockList(db);\n\n  /* Free up the array of auxiliary databases */\n  sqlite3CollapseDatabaseArray(db);\n  assert( db->nDb<=2 );\n  assert( db->aDb==db->aDbStatic );\n\n  /* Tell the code in notify.c that the connection no longer holds any\n  ** locks and does not require any further unlock-notify callbacks.\n  */\n  sqlite3ConnectionClosed(db);\n\n  for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){\n    FuncDef *pNext, *p;\n    p = sqliteHashData(i);\n    do{\n      functionDestroy(db, p);\n      pNext = p->pNext;\n      sqlite3DbFree(db, p);\n      p = pNext;\n    }while( p );\n  }\n  sqlite3HashClear(&db->aFunc);\n  for(i=sqliteHashFirst(&db->aCollSeq); i; i=sqliteHashNext(i)){\n    CollSeq *pColl = (CollSeq *)sqliteHashData(i);\n    /* Invoke any destructors registered for collation sequence user data. */\n    for(j=0; j<3; j++){\n      if( pColl[j].xDel ){\n        pColl[j].xDel(pColl[j].pUser);\n      }\n    }\n    sqlite3DbFree(db, pColl);\n  }\n  sqlite3HashClear(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){\n    Module *pMod = (Module *)sqliteHashData(i);\n    if( pMod->xDestroy ){\n      pMod->xDestroy(pMod->pAux);\n    }\n    sqlite3VtabEponymousTableClear(db, pMod);\n    sqlite3DbFree(db, pMod);\n  }\n  sqlite3HashClear(&db->aModule);\n#endif\n\n  sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */\n  sqlite3ValueFree(db->pErr);\n  sqlite3CloseExtensions(db);\n#if SQLITE_USER_AUTHENTICATION\n  sqlite3_free(db->auth.zAuthUser);\n  sqlite3_free(db->auth.zAuthPW);\n#endif\n\n  db->magic = SQLITE_MAGIC_ERROR;\n\n  /* The temp-database schema is allocated differently from the other schema\n  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).\n  ** So it needs to be freed here. Todo: Why not roll the temp schema into\n  ** the same sqliteMalloc() as the one that allocates the database \n  ** structure?\n  */\n  sqlite3DbFree(db, db->aDb[1].pSchema);\n  sqlite3_mutex_leave(db->mutex);\n  db->magic = SQLITE_MAGIC_CLOSED;\n  sqlite3_mutex_free(db->mutex);\n  assert( sqlite3LookasideUsed(db,0)==0 );\n  if( db->lookaside.bMalloced ){\n    sqlite3_free(db->lookaside.pStart);\n  }\n  sqlite3_free(db);\n}\n\n/*\n** Rollback all database files.  If tripCode is not SQLITE_OK, then\n** any write cursors are invalidated (\"tripped\" - as in \"tripping a circuit\n** breaker\") and made to return tripCode if there are any further\n** attempts to use that cursor.  Read cursors remain open and valid\n** but are \"saved\" in case the table pages are moved around.\n*/\nvoid sqlite3RollbackAll(sqlite3 *db, int tripCode){\n  int i;\n  int inTrans = 0;\n  int schemaChange;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3BeginBenignMalloc();\n\n  /* Obtain all b-tree mutexes before making any calls to BtreeRollback(). \n  ** This is important in case the transaction being rolled back has\n  ** modified the database schema. If the b-tree mutexes are not taken\n  ** here, then another shared-cache connection might sneak in between\n  ** the database rollback and schema reset, which can cause false\n  ** corruption reports in some cases.  */\n  sqlite3BtreeEnterAll(db);\n  schemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0 && db->init.busy==0;\n\n  for(i=0; i<db->nDb; i++){\n    Btree *p = db->aDb[i].pBt;\n    if( p ){\n      if( sqlite3BtreeIsInTrans(p) ){\n        inTrans = 1;\n      }\n      sqlite3BtreeRollback(p, tripCode, !schemaChange);\n    }\n  }\n  sqlite3VtabRollback(db);\n  sqlite3EndBenignMalloc();\n\n  if( (db->mDbFlags&DBFLAG_SchemaChange)!=0 && db->init.busy==0 ){\n    sqlite3ExpirePreparedStatements(db);\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  sqlite3BtreeLeaveAll(db);\n\n  /* Any deferred constraint violations have now been resolved. */\n  db->nDeferredCons = 0;\n  db->nDeferredImmCons = 0;\n  db->flags &= ~SQLITE_DeferFKs;\n\n  /* If one has been configured, invoke the rollback-hook callback */\n  if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){\n    db->xRollbackCallback(db->pRollbackArg);\n  }\n}\n\n/*\n** Return a static string containing the name corresponding to the error code\n** specified in the argument.\n*/\n#if defined(SQLITE_NEED_ERR_NAME)\nconst char *sqlite3ErrName(int rc){\n  const char *zName = 0;\n  int i, origRc = rc;\n  for(i=0; i<2 && zName==0; i++, rc &= 0xff){\n    switch( rc ){\n      case SQLITE_OK:                 zName = \"SQLITE_OK\";                break;\n      case SQLITE_ERROR:              zName = \"SQLITE_ERROR\";             break;\n      case SQLITE_INTERNAL:           zName = \"SQLITE_INTERNAL\";          break;\n      case SQLITE_PERM:               zName = \"SQLITE_PERM\";              break;\n      case SQLITE_ABORT:              zName = \"SQLITE_ABORT\";             break;\n      case SQLITE_ABORT_ROLLBACK:     zName = \"SQLITE_ABORT_ROLLBACK\";    break;\n      case SQLITE_BUSY:               zName = \"SQLITE_BUSY\";              break;\n      case SQLITE_BUSY_RECOVERY:      zName = \"SQLITE_BUSY_RECOVERY\";     break;\n      case SQLITE_BUSY_SNAPSHOT:      zName = \"SQLITE_BUSY_SNAPSHOT\";     break;\n      case SQLITE_LOCKED:             zName = \"SQLITE_LOCKED\";            break;\n      case SQLITE_LOCKED_SHAREDCACHE: zName = \"SQLITE_LOCKED_SHAREDCACHE\";break;\n      case SQLITE_NOMEM:              zName = \"SQLITE_NOMEM\";             break;\n      case SQLITE_READONLY:           zName = \"SQLITE_READONLY\";          break;\n      case SQLITE_READONLY_RECOVERY:  zName = \"SQLITE_READONLY_RECOVERY\"; break;\n      case SQLITE_READONLY_CANTLOCK:  zName = \"SQLITE_READONLY_CANTLOCK\"; break;\n      case SQLITE_READONLY_ROLLBACK:  zName = \"SQLITE_READONLY_ROLLBACK\"; break;\n      case SQLITE_READONLY_DBMOVED:   zName = \"SQLITE_READONLY_DBMOVED\";  break;\n      case SQLITE_INTERRUPT:          zName = \"SQLITE_INTERRUPT\";         break;\n      case SQLITE_IOERR:              zName = \"SQLITE_IOERR\";             break;\n      case SQLITE_IOERR_READ:         zName = \"SQLITE_IOERR_READ\";        break;\n      case SQLITE_IOERR_SHORT_READ:   zName = \"SQLITE_IOERR_SHORT_READ\";  break;\n      case SQLITE_IOERR_WRITE:        zName = \"SQLITE_IOERR_WRITE\";       break;\n      case SQLITE_IOERR_FSYNC:        zName = \"SQLITE_IOERR_FSYNC\";       break;\n      case SQLITE_IOERR_DIR_FSYNC:    zName = \"SQLITE_IOERR_DIR_FSYNC\";   break;\n      case SQLITE_IOERR_TRUNCATE:     zName = \"SQLITE_IOERR_TRUNCATE\";    break;\n      case SQLITE_IOERR_FSTAT:        zName = \"SQLITE_IOERR_FSTAT\";       break;\n      case SQLITE_IOERR_UNLOCK:       zName = \"SQLITE_IOERR_UNLOCK\";      break;\n      case SQLITE_IOERR_RDLOCK:       zName = \"SQLITE_IOERR_RDLOCK\";      break;\n      case SQLITE_IOERR_DELETE:       zName = \"SQLITE_IOERR_DELETE\";      break;\n      case SQLITE_IOERR_NOMEM:        zName = \"SQLITE_IOERR_NOMEM\";       break;\n      case SQLITE_IOERR_ACCESS:       zName = \"SQLITE_IOERR_ACCESS\";      break;\n      case SQLITE_IOERR_CHECKRESERVEDLOCK:\n                                zName = \"SQLITE_IOERR_CHECKRESERVEDLOCK\"; break;\n      case SQLITE_IOERR_LOCK:         zName = \"SQLITE_IOERR_LOCK\";        break;\n      case SQLITE_IOERR_CLOSE:        zName = \"SQLITE_IOERR_CLOSE\";       break;\n      case SQLITE_IOERR_DIR_CLOSE:    zName = \"SQLITE_IOERR_DIR_CLOSE\";   break;\n      case SQLITE_IOERR_SHMOPEN:      zName = \"SQLITE_IOERR_SHMOPEN\";     break;\n      case SQLITE_IOERR_SHMSIZE:      zName = \"SQLITE_IOERR_SHMSIZE\";     break;\n      case SQLITE_IOERR_SHMLOCK:      zName = \"SQLITE_IOERR_SHMLOCK\";     break;\n      case SQLITE_IOERR_SHMMAP:       zName = \"SQLITE_IOERR_SHMMAP\";      break;\n      case SQLITE_IOERR_SEEK:         zName = \"SQLITE_IOERR_SEEK\";        break;\n      case SQLITE_IOERR_DELETE_NOENT: zName = \"SQLITE_IOERR_DELETE_NOENT\";break;\n      case SQLITE_IOERR_MMAP:         zName = \"SQLITE_IOERR_MMAP\";        break;\n      case SQLITE_IOERR_GETTEMPPATH:  zName = \"SQLITE_IOERR_GETTEMPPATH\"; break;\n      case SQLITE_IOERR_CONVPATH:     zName = \"SQLITE_IOERR_CONVPATH\";    break;\n      case SQLITE_CORRUPT:            zName = \"SQLITE_CORRUPT\";           break;\n      case SQLITE_CORRUPT_VTAB:       zName = \"SQLITE_CORRUPT_VTAB\";      break;\n      case SQLITE_NOTFOUND:           zName = \"SQLITE_NOTFOUND\";          break;\n      case SQLITE_FULL:               zName = \"SQLITE_FULL\";              break;\n      case SQLITE_CANTOPEN:           zName = \"SQLITE_CANTOPEN\";          break;\n      case SQLITE_CANTOPEN_NOTEMPDIR: zName = \"SQLITE_CANTOPEN_NOTEMPDIR\";break;\n      case SQLITE_CANTOPEN_ISDIR:     zName = \"SQLITE_CANTOPEN_ISDIR\";    break;\n      case SQLITE_CANTOPEN_FULLPATH:  zName = \"SQLITE_CANTOPEN_FULLPATH\"; break;\n      case SQLITE_CANTOPEN_CONVPATH:  zName = \"SQLITE_CANTOPEN_CONVPATH\"; break;\n      case SQLITE_PROTOCOL:           zName = \"SQLITE_PROTOCOL\";          break;\n      case SQLITE_EMPTY:              zName = \"SQLITE_EMPTY\";             break;\n      case SQLITE_SCHEMA:             zName = \"SQLITE_SCHEMA\";            break;\n      case SQLITE_TOOBIG:             zName = \"SQLITE_TOOBIG\";            break;\n      case SQLITE_CONSTRAINT:         zName = \"SQLITE_CONSTRAINT\";        break;\n      case SQLITE_CONSTRAINT_UNIQUE:  zName = \"SQLITE_CONSTRAINT_UNIQUE\"; break;\n      case SQLITE_CONSTRAINT_TRIGGER: zName = \"SQLITE_CONSTRAINT_TRIGGER\";break;\n      case SQLITE_CONSTRAINT_FOREIGNKEY:\n                                zName = \"SQLITE_CONSTRAINT_FOREIGNKEY\";   break;\n      case SQLITE_CONSTRAINT_CHECK:   zName = \"SQLITE_CONSTRAINT_CHECK\";  break;\n      case SQLITE_CONSTRAINT_PRIMARYKEY:\n                                zName = \"SQLITE_CONSTRAINT_PRIMARYKEY\";   break;\n      case SQLITE_CONSTRAINT_NOTNULL: zName = \"SQLITE_CONSTRAINT_NOTNULL\";break;\n      case SQLITE_CONSTRAINT_COMMITHOOK:\n                                zName = \"SQLITE_CONSTRAINT_COMMITHOOK\";   break;\n      case SQLITE_CONSTRAINT_VTAB:    zName = \"SQLITE_CONSTRAINT_VTAB\";   break;\n      case SQLITE_CONSTRAINT_FUNCTION:\n                                zName = \"SQLITE_CONSTRAINT_FUNCTION\";     break;\n      case SQLITE_CONSTRAINT_ROWID:   zName = \"SQLITE_CONSTRAINT_ROWID\";  break;\n      case SQLITE_MISMATCH:           zName = \"SQLITE_MISMATCH\";          break;\n      case SQLITE_MISUSE:             zName = \"SQLITE_MISUSE\";            break;\n      case SQLITE_NOLFS:              zName = \"SQLITE_NOLFS\";             break;\n      case SQLITE_AUTH:               zName = \"SQLITE_AUTH\";              break;\n      case SQLITE_FORMAT:             zName = \"SQLITE_FORMAT\";            break;\n      case SQLITE_RANGE:              zName = \"SQLITE_RANGE\";             break;\n      case SQLITE_NOTADB:             zName = \"SQLITE_NOTADB\";            break;\n      case SQLITE_ROW:                zName = \"SQLITE_ROW\";               break;\n      case SQLITE_NOTICE:             zName = \"SQLITE_NOTICE\";            break;\n      case SQLITE_NOTICE_RECOVER_WAL: zName = \"SQLITE_NOTICE_RECOVER_WAL\";break;\n      case SQLITE_NOTICE_RECOVER_ROLLBACK:\n                                zName = \"SQLITE_NOTICE_RECOVER_ROLLBACK\"; break;\n      case SQLITE_WARNING:            zName = \"SQLITE_WARNING\";           break;\n      case SQLITE_WARNING_AUTOINDEX:  zName = \"SQLITE_WARNING_AUTOINDEX\"; break;\n      case SQLITE_DONE:               zName = \"SQLITE_DONE\";              break;\n    }\n  }\n  if( zName==0 ){\n    static char zBuf[50];\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"SQLITE_UNKNOWN(%d)\", origRc);\n    zName = zBuf;\n  }\n  return zName;\n}\n#endif\n\n/*\n** Return a static string that describes the kind of error specified in the\n** argument.\n*/\nconst char *sqlite3ErrStr(int rc){\n  static const char* const aMsg[] = {\n    /* SQLITE_OK          */ \"not an error\",\n    /* SQLITE_ERROR       */ \"SQL logic error\",\n    /* SQLITE_INTERNAL    */ 0,\n    /* SQLITE_PERM        */ \"access permission denied\",\n    /* SQLITE_ABORT       */ \"query aborted\",\n    /* SQLITE_BUSY        */ \"database is locked\",\n    /* SQLITE_LOCKED      */ \"database table is locked\",\n    /* SQLITE_NOMEM       */ \"out of memory\",\n    /* SQLITE_READONLY    */ \"attempt to write a readonly database\",\n    /* SQLITE_INTERRUPT   */ \"interrupted\",\n    /* SQLITE_IOERR       */ \"disk I/O error\",\n    /* SQLITE_CORRUPT     */ \"database disk image is malformed\",\n    /* SQLITE_NOTFOUND    */ \"unknown operation\",\n    /* SQLITE_FULL        */ \"database or disk is full\",\n    /* SQLITE_CANTOPEN    */ \"unable to open database file\",\n    /* SQLITE_PROTOCOL    */ \"locking protocol\",\n    /* SQLITE_EMPTY       */ 0,\n    /* SQLITE_SCHEMA      */ \"database schema has changed\",\n    /* SQLITE_TOOBIG      */ \"string or blob too big\",\n    /* SQLITE_CONSTRAINT  */ \"constraint failed\",\n    /* SQLITE_MISMATCH    */ \"datatype mismatch\",\n    /* SQLITE_MISUSE      */ \"bad parameter or other API misuse\",\n#ifdef SQLITE_DISABLE_LFS\n    /* SQLITE_NOLFS       */ \"large file support is disabled\",\n#else\n    /* SQLITE_NOLFS       */ 0,\n#endif\n    /* SQLITE_AUTH        */ \"authorization denied\",\n    /* SQLITE_FORMAT      */ 0,\n    /* SQLITE_RANGE       */ \"column index out of range\",\n    /* SQLITE_NOTADB      */ \"file is not a database\",\n  };\n  const char *zErr = \"unknown error\";\n  switch( rc ){\n    case SQLITE_ABORT_ROLLBACK: {\n      zErr = \"abort due to ROLLBACK\";\n      break;\n    }\n    default: {\n      rc &= 0xff;\n      if( ALWAYS(rc>=0) && rc<ArraySize(aMsg) && aMsg[rc]!=0 ){\n        zErr = aMsg[rc];\n      }\n      break;\n    }\n  }\n  return zErr;\n}\n\n/*\n** This routine implements a busy callback that sleeps and tries\n** again until a timeout value is reached.  The timeout value is\n** an integer number of milliseconds passed in as the first\n** argument.\n*/\nstatic int sqliteDefaultBusyCallback(\n void *ptr,               /* Database connection */\n int count                /* Number of times table has been busy */\n){\n#if SQLITE_OS_WIN || HAVE_USLEEP\n  static const u8 delays[] =\n     { 1, 2, 5, 10, 15, 20, 25, 25,  25,  50,  50, 100 };\n  static const u8 totals[] =\n     { 0, 1, 3,  8, 18, 33, 53, 78, 103, 128, 178, 228 };\n# define NDELAY ArraySize(delays)\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = db->busyTimeout;\n  int delay, prior;\n\n  assert( count>=0 );\n  if( count < NDELAY ){\n    delay = delays[count];\n    prior = totals[count];\n  }else{\n    delay = delays[NDELAY-1];\n    prior = totals[NDELAY-1] + delay*(count-(NDELAY-1));\n  }\n  if( prior + delay > timeout ){\n    delay = timeout - prior;\n    if( delay<=0 ) return 0;\n  }\n  sqlite3OsSleep(db->pVfs, delay*1000);\n  return 1;\n#else\n  sqlite3 *db = (sqlite3 *)ptr;\n  int timeout = ((sqlite3 *)ptr)->busyTimeout;\n  if( (count+1)*1000 > timeout ){\n    return 0;\n  }\n  sqlite3OsSleep(db->pVfs, 1000000);\n  return 1;\n#endif\n}\n\n/*\n** Invoke the given busy handler.\n**\n** This routine is called when an operation failed with a lock.\n** If this routine returns non-zero, the lock is retried.  If it\n** returns 0, the operation aborts with an SQLITE_BUSY error.\n*/\nint sqlite3InvokeBusyHandler(BusyHandler *p){\n  int rc;\n  if( NEVER(p==0) || p->xFunc==0 || p->nBusy<0 ) return 0;\n  rc = p->xFunc(p->pArg, p->nBusy);\n  if( rc==0 ){\n    p->nBusy = -1;\n  }else{\n    p->nBusy++;\n  }\n  return rc; \n}\n\n/*\n** This routine sets the busy callback for an Sqlite database to the\n** given callback function with the given argument.\n*/\nint sqlite3_busy_handler(\n  sqlite3 *db,\n  int (*xBusy)(void*,int),\n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->busyHandler.xFunc = xBusy;\n  db->busyHandler.pArg = pArg;\n  db->busyHandler.nBusy = 0;\n  db->busyTimeout = 0;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This routine sets the progress callback for an Sqlite database to the\n** given callback function with the given argument. The progress callback will\n** be invoked every nOps opcodes.\n*/\nvoid sqlite3_progress_handler(\n  sqlite3 *db, \n  int nOps,\n  int (*xProgress)(void*), \n  void *pArg\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( nOps>0 ){\n    db->xProgress = xProgress;\n    db->nProgressOps = (unsigned)nOps;\n    db->pProgressArg = pArg;\n  }else{\n    db->xProgress = 0;\n    db->nProgressOps = 0;\n    db->pProgressArg = 0;\n  }\n  sqlite3_mutex_leave(db->mutex);\n}\n#endif\n\n\n/*\n** This routine installs a default busy handler that waits for the\n** specified number of milliseconds before returning 0.\n*/\nint sqlite3_busy_timeout(sqlite3 *db, int ms){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( ms>0 ){\n    sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);\n    db->busyTimeout = ms;\n  }else{\n    sqlite3_busy_handler(db, 0, 0);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Cause any pending operation to stop at its earliest opportunity.\n*/\nvoid sqlite3_interrupt(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n  db->u1.isInterrupted = 1;\n}\n\n\n/*\n** This function is exactly the same as sqlite3_create_function(), except\n** that it is designed to be called by internal code. The difference is\n** that if a malloc() fails in sqlite3_create_function(), an error code\n** is returned and the mallocFailed flag cleared. \n*/\nint sqlite3CreateFunc(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int enc,\n  void *pUserData,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  FuncDestructor *pDestructor\n){\n  FuncDef *p;\n  int nName;\n  int extraFlags;\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( zFunctionName==0 ||\n      (xSFunc && (xFinal || xStep)) || \n      (!xSFunc && (xFinal && !xStep)) ||\n      (!xSFunc && (!xFinal && xStep)) ||\n      (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) ||\n      (255<(nName = sqlite3Strlen30( zFunctionName))) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  assert( SQLITE_FUNC_CONSTANT==SQLITE_DETERMINISTIC );\n  extraFlags = enc &  SQLITE_DETERMINISTIC;\n  enc &= (SQLITE_FUNC_ENCMASK|SQLITE_ANY);\n  \n#ifndef SQLITE_OMIT_UTF16\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  **\n  ** If SQLITE_ANY is specified, add three versions of the function\n  ** to the hash table.\n  */\n  if( enc==SQLITE_UTF16 ){\n    enc = SQLITE_UTF16NATIVE;\n  }else if( enc==SQLITE_ANY ){\n    int rc;\n    rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF8|extraFlags,\n         pUserData, xSFunc, xStep, xFinal, pDestructor);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3CreateFunc(db, zFunctionName, nArg, SQLITE_UTF16LE|extraFlags,\n          pUserData, xSFunc, xStep, xFinal, pDestructor);\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    enc = SQLITE_UTF16BE;\n  }\n#else\n  enc = SQLITE_UTF8;\n#endif\n  \n  /* Check if an existing function is being overridden or deleted. If so,\n  ** and there are active VMs, then return SQLITE_BUSY. If a function\n  ** is being overridden/deleted but there are no active VMs, allow the\n  ** operation to continue but invalidate all precompiled statements.\n  */\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 0);\n  if( p && (p->funcFlags & SQLITE_FUNC_ENCMASK)==enc && p->nArg==nArg ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify user-function due to active statements\");\n      assert( !db->mallocFailed );\n      return SQLITE_BUSY;\n    }else{\n      sqlite3ExpirePreparedStatements(db);\n    }\n  }\n\n  p = sqlite3FindFunction(db, zFunctionName, nArg, (u8)enc, 1);\n  assert(p || db->mallocFailed);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* If an older version of the function with a configured destructor is\n  ** being replaced invoke the destructor function here. */\n  functionDestroy(db, p);\n\n  if( pDestructor ){\n    pDestructor->nRef++;\n  }\n  p->u.pDestructor = pDestructor;\n  p->funcFlags = (p->funcFlags & SQLITE_FUNC_ENCMASK) | extraFlags;\n  testcase( p->funcFlags & SQLITE_DETERMINISTIC );\n  p->xSFunc = xSFunc ? xSFunc : xStep;\n  p->xFinalize = xFinal;\n  p->pUserData = pUserData;\n  p->nArg = (u16)nArg;\n  return SQLITE_OK;\n}\n\n/*\n** Create new user functions.\n*/\nint sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*)\n){\n  return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xSFunc, xStep,\n                                    xFinal, 0);\n}\n\nint sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunc,\n  int nArg,\n  int enc,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value **),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value **),\n  void (*xFinal)(sqlite3_context*),\n  void (*xDestroy)(void *)\n){\n  int rc = SQLITE_ERROR;\n  FuncDestructor *pArg = 0;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( xDestroy ){\n    pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));\n    if( !pArg ){\n      xDestroy(p);\n      goto out;\n    }\n    pArg->xDestroy = xDestroy;\n    pArg->pUserData = p;\n  }\n  rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p, xSFunc, xStep, xFinal, pArg);\n  if( pArg && pArg->nRef==0 ){\n    assert( rc!=SQLITE_OK );\n    xDestroy(p);\n    sqlite3DbFree(db, pArg);\n  }\n\n out:\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\nint sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *p,\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n){\n  int rc;\n  char *zFunc8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);\n  rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xSFunc,xStep,xFinal,0);\n  sqlite3DbFree(db, zFunc8);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif\n\n\n/*\n** Declare that a function has been overloaded by a virtual table.\n**\n** If the function already exists as a regular global function, then\n** this routine is a no-op.  If the function does not exist, then create\n** a new one that always throws a run-time error.  \n**\n** When virtual tables intend to provide an overloaded function, they\n** should call this routine to make sure the global function exists.\n** A global function must exist in order for name resolution to work\n** properly.\n*/\nint sqlite3_overload_function(\n  sqlite3 *db,\n  const char *zName,\n  int nArg\n){\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3FindFunction(db, zName, nArg, SQLITE_UTF8, 0)==0 ){\n    rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,\n                           0, sqlite3InvalidFunction, 0, 0, 0);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Register a trace function.  The pArg from the previously registered trace\n** is returned.  \n**\n** A NULL trace function means that no tracing is executes.  A non-NULL\n** trace is a pointer to a function that is invoked at the start of each\n** SQL statement.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nvoid *sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pTraceArg;\n  db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0;\n  db->xTrace = (int(*)(u32,void*,void*,void*))xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n/* Register a trace callback using the version-2 interface.\n*/\nint sqlite3_trace_v2(\n  sqlite3 *db,                               /* Trace this connection */\n  unsigned mTrace,                           /* Mask of events to be traced */\n  int(*xTrace)(unsigned,void*,void*,void*),  /* Callback to invoke */\n  void *pArg                                 /* Context */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( mTrace==0 ) xTrace = 0;\n  if( xTrace==0 ) mTrace = 0;\n  db->mTrace = mTrace;\n  db->xTrace = xTrace;\n  db->pTraceArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Register a profile function.  The pArg from the previously registered \n** profile function is returned.  \n**\n** A NULL profile function means that no profiling is executes.  A non-NULL\n** profile is a pointer to a function that is invoked at the conclusion of\n** each SQL statement that is run.\n*/\nvoid *sqlite3_profile(\n  sqlite3 *db,\n  void (*xProfile)(void*,const char*,sqlite_uint64),\n  void *pArg\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pProfileArg;\n  db->xProfile = xProfile;\n  db->pProfileArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n#endif /* SQLITE_OMIT_TRACE */\n\n/*\n** Register a function to be invoked when a transaction commits.\n** If the invoked function returns non-zero, then the commit becomes a\n** rollback.\n*/\nvoid *sqlite3_commit_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  int (*xCallback)(void*),  /* Function to invoke on each commit */\n  void *pArg                /* Argument to the function */\n){\n  void *pOld;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pOld = db->pCommitArg;\n  db->xCommitCallback = xCallback;\n  db->pCommitArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pOld;\n}\n\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nvoid *sqlite3_update_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pUpdateArg;\n  db->xUpdateCallback = xCallback;\n  db->pUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is rolled\n** back by this database connection.\n*/\nvoid *sqlite3_rollback_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void (*xCallback)(void*), /* Callback function */\n  void *pArg                /* Argument to the function */\n){\n  void *pRet;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pRollbackArg;\n  db->xRollbackCallback = xCallback;\n  db->pRollbackArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Register a callback to be invoked each time a row is updated,\n** inserted or deleted using this database connection.\n*/\nvoid *sqlite3_preupdate_hook(\n  sqlite3 *db,              /* Attach the hook to this database */\n  void(*xCallback)(         /* Callback function */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64),\n  void *pArg                /* First callback argument */\n){\n  void *pRet;\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pPreUpdateArg;\n  db->xPreUpdateCallback = xCallback;\n  db->pPreUpdateArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().\n** Invoke sqlite3_wal_checkpoint if the number of frames in the log file\n** is greater than sqlite3.pWalArg cast to an integer (the value configured by\n** wal_autocheckpoint()).\n*/ \nint sqlite3WalDefaultHook(\n  void *pClientData,     /* Argument */\n  sqlite3 *db,           /* Connection */\n  const char *zDb,       /* Database */\n  int nFrame             /* Size of WAL */\n){\n  if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){\n    sqlite3BeginBenignMalloc();\n    sqlite3_wal_checkpoint(db, zDb);\n    sqlite3EndBenignMalloc();\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** Configure an sqlite3_wal_hook() callback to automatically checkpoint\n** a database after committing a transaction if there are nFrame or\n** more frames in the log file. Passing zero or a negative value as the\n** nFrame parameter disables automatic checkpoints entirely.\n**\n** The callback registered by this function replaces any existing callback\n** registered using sqlite3_wal_hook(). Likewise, registering a callback\n** using sqlite3_wal_hook() disables the automatic checkpoint mechanism\n** configured by this function.\n*/\nint sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){\n#ifdef SQLITE_OMIT_WAL\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(nFrame);\n#else\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  if( nFrame>0 ){\n    sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));\n  }else{\n    sqlite3_wal_hook(db, 0, 0);\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Register a callback to be invoked each time a transaction is written\n** into the write-ahead-log by this database connection.\n*/\nvoid *sqlite3_wal_hook(\n  sqlite3 *db,                    /* Attach the hook to this db handle */\n  int(*xCallback)(void *, sqlite3*, const char*, int),\n  void *pArg                      /* First argument passed to xCallback() */\n){\n#ifndef SQLITE_OMIT_WAL\n  void *pRet;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pRet = db->pWalArg;\n  db->xWalCallback = xCallback;\n  db->pWalArg = pArg;\n  sqlite3_mutex_leave(db->mutex);\n  return pRet;\n#else\n  return 0;\n#endif\n}\n\n/*\n** Checkpoint database zDb.\n*/\nint sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n){\n#ifdef SQLITE_OMIT_WAL\n  return SQLITE_OK;\n#else\n  int rc;                         /* Return code */\n  int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  /* Initialize the output variables to -1 in case an error occurs. */\n  if( pnLog ) *pnLog = -1;\n  if( pnCkpt ) *pnCkpt = -1;\n\n  assert( SQLITE_CHECKPOINT_PASSIVE==0 );\n  assert( SQLITE_CHECKPOINT_FULL==1 );\n  assert( SQLITE_CHECKPOINT_RESTART==2 );\n  assert( SQLITE_CHECKPOINT_TRUNCATE==3 );\n  if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){\n    /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint\n    ** mode: */\n    return SQLITE_MISUSE;\n  }\n\n  sqlite3_mutex_enter(db->mutex);\n  if( zDb && zDb[0] ){\n    iDb = sqlite3FindDbName(db, zDb);\n  }\n  if( iDb<0 ){\n    rc = SQLITE_ERROR;\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, \"unknown database: %s\", zDb);\n  }else{\n    db->busyHandler.nBusy = 0;\n    rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);\n    sqlite3Error(db, rc);\n  }\n  rc = sqlite3ApiExit(db, rc);\n\n  /* If there are no active statements, clear the interrupt flag at this\n  ** point.  */\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n#endif\n}\n\n\n/*\n** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points\n** to contains a zero-length string, all attached databases are \n** checkpointed.\n*/\nint sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){\n  /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to\n  ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */\n  return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Run a checkpoint on database iDb. This is a no-op if database iDb is\n** not currently open in WAL mode.\n**\n** If a transaction is open on the database being checkpointed, this \n** function returns SQLITE_LOCKED and a checkpoint is not attempted. If \n** an error occurs while running the checkpoint, an SQLite error code is \n** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.\n**\n** The mutex on database handle db should be held by the caller. The mutex\n** associated with the specific b-tree being checkpointed is taken by\n** this function while the checkpoint is running.\n**\n** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are\n** checkpointed. If an error is encountered it is returned immediately -\n** no attempt is made to checkpoint any remaining databases.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL, RESTART\n** or TRUNCATE.\n*/\nint sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog, int *pnCkpt){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* Used to iterate through attached dbs */\n  int bBusy = 0;                  /* True if SQLITE_BUSY has been encountered */\n\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( !pnLog || *pnLog==-1 );\n  assert( !pnCkpt || *pnCkpt==-1 );\n\n  for(i=0; i<db->nDb && rc==SQLITE_OK; i++){\n    if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){\n      rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);\n      pnLog = 0;\n      pnCkpt = 0;\n      if( rc==SQLITE_BUSY ){\n        bBusy = 1;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  return (rc==SQLITE_OK && bBusy) ? SQLITE_BUSY : rc;\n}\n#endif /* SQLITE_OMIT_WAL */\n\n/*\n** This function returns true if main-memory should be used instead of\n** a temporary file for transient pager files and statement journals.\n** The value returned depends on the value of db->temp_store (runtime\n** parameter) and the compile time value of SQLITE_TEMP_STORE. The\n** following table describes the relationship between these two values\n** and this functions return value.\n**\n**   SQLITE_TEMP_STORE     db->temp_store     Location of temporary database\n**   -----------------     --------------     ------------------------------\n**   0                     any                file      (return 0)\n**   1                     1                  file      (return 0)\n**   1                     2                  memory    (return 1)\n**   1                     0                  file      (return 0)\n**   2                     1                  file      (return 0)\n**   2                     2                  memory    (return 1)\n**   2                     0                  memory    (return 1)\n**   3                     any                memory    (return 1)\n*/\nint sqlite3TempInMemory(const sqlite3 *db){\n#if SQLITE_TEMP_STORE==1\n  return ( db->temp_store==2 );\n#endif\n#if SQLITE_TEMP_STORE==2\n  return ( db->temp_store!=1 );\n#endif\n#if SQLITE_TEMP_STORE==3\n  UNUSED_PARAMETER(db);\n  return 1;\n#endif\n#if SQLITE_TEMP_STORE<1 || SQLITE_TEMP_STORE>3\n  UNUSED_PARAMETER(db);\n  return 0;\n#endif\n}\n\n/*\n** Return UTF-8 encoded English language explanation of the most recent\n** error.\n*/\nconst char *sqlite3_errmsg(sqlite3 *db){\n  const char *z;\n  if( !db ){\n    return sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return sqlite3ErrStr(SQLITE_MISUSE_BKPT);\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = sqlite3ErrStr(SQLITE_NOMEM_BKPT);\n  }else{\n    testcase( db->pErr==0 );\n    z = (char*)sqlite3_value_text(db->pErr);\n    assert( !db->mallocFailed );\n    if( z==0 ){\n      z = sqlite3ErrStr(db->errCode);\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Return UTF-16 encoded English language explanation of the most recent\n** error.\n*/\nconst void *sqlite3_errmsg16(sqlite3 *db){\n  static const u16 outOfMem[] = {\n    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0\n  };\n  static const u16 misuse[] = {\n    'b', 'a', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ',\n    'o', 'r', ' ', 'o', 't', 'h', 'e', 'r', ' ', 'A', 'P', 'I', ' ',\n    'm', 'i', 's', 'u', 's', 'e', 0\n  };\n\n  const void *z;\n  if( !db ){\n    return (void *)outOfMem;\n  }\n  if( !sqlite3SafetyCheckSickOrOk(db) ){\n    return (void *)misuse;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  if( db->mallocFailed ){\n    z = (void *)outOfMem;\n  }else{\n    z = sqlite3_value_text16(db->pErr);\n    if( z==0 ){\n      sqlite3ErrorWithMsg(db, db->errCode, sqlite3ErrStr(db->errCode));\n      z = sqlite3_value_text16(db->pErr);\n    }\n    /* A malloc() may have failed within the call to sqlite3_value_text16()\n    ** above. If this is the case, then the db->mallocFailed flag needs to\n    ** be cleared before returning. Do this directly, instead of via\n    ** sqlite3ApiExit(), to avoid setting the database handle error message.\n    */\n    sqlite3OomClear(db);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return z;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the most recent error code generated by an SQLite routine. If NULL is\n** passed to this function, we assume a malloc() failed during sqlite3_open().\n*/\nint sqlite3_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode & db->errMask;\n}\nint sqlite3_extended_errcode(sqlite3 *db){\n  if( db && !sqlite3SafetyCheckSickOrOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( !db || db->mallocFailed ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  return db->errCode;\n}\nint sqlite3_system_errno(sqlite3 *db){\n  return db ? db->iSysErrno : 0;\n}  \n\n/*\n** Return a string that describes the kind of error specified in the\n** argument.  For now, this simply calls the internal sqlite3ErrStr()\n** function.\n*/\nconst char *sqlite3_errstr(int rc){\n  return sqlite3ErrStr(rc);\n}\n\n/*\n** Create a new collating function for database \"db\".  The name is zName\n** and the encoding is enc.\n*/\nstatic int createCollation(\n  sqlite3* db,\n  const char *zName, \n  u8 enc,\n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  CollSeq *pColl;\n  int enc2;\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* If SQLITE_UTF16 is specified as the encoding type, transform this\n  ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the\n  ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.\n  */\n  enc2 = enc;\n  testcase( enc2==SQLITE_UTF16 );\n  testcase( enc2==SQLITE_UTF16_ALIGNED );\n  if( enc2==SQLITE_UTF16 || enc2==SQLITE_UTF16_ALIGNED ){\n    enc2 = SQLITE_UTF16NATIVE;\n  }\n  if( enc2<SQLITE_UTF8 || enc2>SQLITE_UTF16BE ){\n    return SQLITE_MISUSE_BKPT;\n  }\n\n  /* Check if this call is removing or replacing an existing collation \n  ** sequence. If so, and there are active VMs, return busy. If there\n  ** are no active VMs, invalidate any pre-compiled statements.\n  */\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 0);\n  if( pColl && pColl->xCmp ){\n    if( db->nVdbeActive ){\n      sqlite3ErrorWithMsg(db, SQLITE_BUSY, \n        \"unable to delete/modify collation sequence due to active statements\");\n      return SQLITE_BUSY;\n    }\n    sqlite3ExpirePreparedStatements(db);\n\n    /* If collation sequence pColl was created directly by a call to\n    ** sqlite3_create_collation, and not generated by synthCollSeq(),\n    ** then any copies made by synthCollSeq() need to be invalidated.\n    ** Also, collation destructor - CollSeq.xDel() - function may need\n    ** to be called.\n    */ \n    if( (pColl->enc & ~SQLITE_UTF16_ALIGNED)==enc2 ){\n      CollSeq *aColl = sqlite3HashFind(&db->aCollSeq, zName);\n      int j;\n      for(j=0; j<3; j++){\n        CollSeq *p = &aColl[j];\n        if( p->enc==pColl->enc ){\n          if( p->xDel ){\n            p->xDel(p->pUser);\n          }\n          p->xCmp = 0;\n        }\n      }\n    }\n  }\n\n  pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, 1);\n  if( pColl==0 ) return SQLITE_NOMEM_BKPT;\n  pColl->xCmp = xCompare;\n  pColl->pUser = pCtx;\n  pColl->xDel = xDel;\n  pColl->enc = (u8)(enc2 | (enc & SQLITE_UTF16_ALIGNED));\n  sqlite3Error(db, SQLITE_OK);\n  return SQLITE_OK;\n}\n\n\n/*\n** This array defines hard upper bounds on limit values.  The\n** initializer must be kept in sync with the SQLITE_LIMIT_*\n** #defines in sqlite3.h.\n*/\nstatic const int aHardLimit[] = {\n  SQLITE_MAX_LENGTH,\n  SQLITE_MAX_SQL_LENGTH,\n  SQLITE_MAX_COLUMN,\n  SQLITE_MAX_EXPR_DEPTH,\n  SQLITE_MAX_COMPOUND_SELECT,\n  SQLITE_MAX_VDBE_OP,\n  SQLITE_MAX_FUNCTION_ARG,\n  SQLITE_MAX_ATTACHED,\n  SQLITE_MAX_LIKE_PATTERN_LENGTH,\n  SQLITE_MAX_VARIABLE_NUMBER,      /* IMP: R-38091-32352 */\n  SQLITE_MAX_TRIGGER_DEPTH,\n  SQLITE_MAX_WORKER_THREADS,\n};\n\n/*\n** Make sure the hard limits are set to reasonable values\n*/\n#if SQLITE_MAX_LENGTH<100\n# error SQLITE_MAX_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH<100\n# error SQLITE_MAX_SQL_LENGTH must be at least 100\n#endif\n#if SQLITE_MAX_SQL_LENGTH>SQLITE_MAX_LENGTH\n# error SQLITE_MAX_SQL_LENGTH must not be greater than SQLITE_MAX_LENGTH\n#endif\n#if SQLITE_MAX_COMPOUND_SELECT<2\n# error SQLITE_MAX_COMPOUND_SELECT must be at least 2\n#endif\n#if SQLITE_MAX_VDBE_OP<40\n# error SQLITE_MAX_VDBE_OP must be at least 40\n#endif\n#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127\n# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127\n#endif\n#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125\n# error SQLITE_MAX_ATTACHED must be between 0 and 125\n#endif\n#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1\n# error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1\n#endif\n#if SQLITE_MAX_COLUMN>32767\n# error SQLITE_MAX_COLUMN must not exceed 32767\n#endif\n#if SQLITE_MAX_TRIGGER_DEPTH<1\n# error SQLITE_MAX_TRIGGER_DEPTH must be at least 1\n#endif\n#if SQLITE_MAX_WORKER_THREADS<0 || SQLITE_MAX_WORKER_THREADS>50\n# error SQLITE_MAX_WORKER_THREADS must be between 0 and 50\n#endif\n\n\n/*\n** Change the value of a limit.  Report the old value.\n** If an invalid limit index is supplied, report -1.\n** Make no changes but still report the old value if the\n** new limit is negative.\n**\n** A new lower limit does not shrink existing constructs.\n** It merely prevents new constructs that exceed the limit\n** from forming.\n*/\nint sqlite3_limit(sqlite3 *db, int limitId, int newLimit){\n  int oldLimit;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n\n  /* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME\n  ** there is a hard upper bound set at compile-time by a C preprocessor\n  ** macro called SQLITE_MAX_NAME. (The \"_LIMIT_\" in the name is changed to\n  ** \"_MAX_\".)\n  */\n  assert( aHardLimit[SQLITE_LIMIT_LENGTH]==SQLITE_MAX_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_SQL_LENGTH]==SQLITE_MAX_SQL_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_COLUMN]==SQLITE_MAX_COLUMN );\n  assert( aHardLimit[SQLITE_LIMIT_EXPR_DEPTH]==SQLITE_MAX_EXPR_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_COMPOUND_SELECT]==SQLITE_MAX_COMPOUND_SELECT);\n  assert( aHardLimit[SQLITE_LIMIT_VDBE_OP]==SQLITE_MAX_VDBE_OP );\n  assert( aHardLimit[SQLITE_LIMIT_FUNCTION_ARG]==SQLITE_MAX_FUNCTION_ARG );\n  assert( aHardLimit[SQLITE_LIMIT_ATTACHED]==SQLITE_MAX_ATTACHED );\n  assert( aHardLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]==\n                                               SQLITE_MAX_LIKE_PATTERN_LENGTH );\n  assert( aHardLimit[SQLITE_LIMIT_VARIABLE_NUMBER]==SQLITE_MAX_VARIABLE_NUMBER);\n  assert( aHardLimit[SQLITE_LIMIT_TRIGGER_DEPTH]==SQLITE_MAX_TRIGGER_DEPTH );\n  assert( aHardLimit[SQLITE_LIMIT_WORKER_THREADS]==SQLITE_MAX_WORKER_THREADS );\n  assert( SQLITE_LIMIT_WORKER_THREADS==(SQLITE_N_LIMIT-1) );\n\n\n  if( limitId<0 || limitId>=SQLITE_N_LIMIT ){\n    return -1;\n  }\n  oldLimit = db->aLimit[limitId];\n  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */\n    if( newLimit>aHardLimit[limitId] ){\n      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */\n    }\n    db->aLimit[limitId] = newLimit;\n  }\n  return oldLimit;                     /* IMP: R-53341-35419 */\n}\n\n/*\n** This function is used to parse both URIs and non-URI filenames passed by the\n** user to API functions sqlite3_open() or sqlite3_open_v2(), and for database\n** URIs specified as part of ATTACH statements.\n**\n** The first argument to this function is the name of the VFS to use (or\n** a NULL to signify the default VFS) if the URI does not contain a \"vfs=xxx\"\n** query parameter. The second argument contains the URI (or non-URI filename)\n** itself. When this function is called the *pFlags variable should contain\n** the default flags to open the database handle with. The value stored in\n** *pFlags may be updated before returning if the URI filename contains \n** \"cache=xxx\" or \"mode=xxx\" query parameters.\n**\n** If successful, SQLITE_OK is returned. In this case *ppVfs is set to point to\n** the VFS that should be used to open the database file. *pzFile is set to\n** point to a buffer containing the name of the file to open. It is the \n** responsibility of the caller to eventually call sqlite3_free() to release\n** this buffer.\n**\n** If an error occurs, then an SQLite error code is returned and *pzErrMsg\n** may be set to point to a buffer containing an English language error \n** message. It is the responsibility of the caller to eventually release\n** this buffer by calling sqlite3_free().\n*/\nint sqlite3ParseUri(\n  const char *zDefaultVfs,        /* VFS to use if no \"vfs=xxx\" query option */\n  const char *zUri,               /* Nul-terminated URI to parse */\n  unsigned int *pFlags,           /* IN/OUT: SQLITE_OPEN_XXX flags */\n  sqlite3_vfs **ppVfs,            /* OUT: VFS to use */ \n  char **pzFile,                  /* OUT: Filename component of URI */\n  char **pzErrMsg                 /* OUT: Error message (if rc!=SQLITE_OK) */\n){\n  int rc = SQLITE_OK;\n  unsigned int flags = *pFlags;\n  const char *zVfs = zDefaultVfs;\n  char *zFile;\n  char c;\n  int nUri = sqlite3Strlen30(zUri);\n\n  assert( *pzErrMsg==0 );\n\n  if( ((flags & SQLITE_OPEN_URI)             /* IMP: R-48725-32206 */\n            || sqlite3GlobalConfig.bOpenUri) /* IMP: R-51689-46548 */\n   && nUri>=5 && memcmp(zUri, \"file:\", 5)==0 /* IMP: R-57884-37496 */\n  ){\n    char *zOpt;\n    int eState;                   /* Parser state when parsing URI */\n    int iIn;                      /* Input character index */\n    int iOut = 0;                 /* Output character index */\n    u64 nByte = nUri+2;           /* Bytes of space to allocate */\n\n    /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen \n    ** method that there may be extra parameters following the file-name.  */\n    flags |= SQLITE_OPEN_URI;\n\n    for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');\n    zFile = sqlite3_malloc64(nByte);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n\n    iIn = 5;\n#ifdef SQLITE_ALLOW_URI_AUTHORITY\n    if( strncmp(zUri+5, \"///\", 3)==0 ){\n      iIn = 7;\n      /* The following condition causes URIs with five leading / characters\n      ** like file://///host/path to be converted into UNCs like //host/path.\n      ** The correct URI for that UNC has only two or four leading / characters\n      ** file://host/path or file:////host/path.  But 5 leading slashes is a \n      ** common error, we are told, so we handle it as a special case. */\n      if( strncmp(zUri+7, \"///\", 3)==0 ){ iIn++; }\n    }else if( strncmp(zUri+5, \"//localhost/\", 12)==0 ){\n      iIn = 16;\n    }\n#else\n    /* Discard the scheme and authority segments of the URI. */\n    if( zUri[5]=='/' && zUri[6]=='/' ){\n      iIn = 7;\n      while( zUri[iIn] && zUri[iIn]!='/' ) iIn++;\n      if( iIn!=7 && (iIn!=16 || memcmp(\"localhost\", &zUri[7], 9)) ){\n        *pzErrMsg = sqlite3_mprintf(\"invalid uri authority: %.*s\", \n            iIn-7, &zUri[7]);\n        rc = SQLITE_ERROR;\n        goto parse_uri_out;\n      }\n    }\n#endif\n\n    /* Copy the filename and any query parameters into the zFile buffer. \n    ** Decode %HH escape codes along the way. \n    **\n    ** Within this loop, variable eState may be set to 0, 1 or 2, depending\n    ** on the parsing context. As follows:\n    **\n    **   0: Parsing file-name.\n    **   1: Parsing name section of a name=value query parameter.\n    **   2: Parsing value section of a name=value query parameter.\n    */\n    eState = 0;\n    while( (c = zUri[iIn])!=0 && c!='#' ){\n      iIn++;\n      if( c=='%' \n       && sqlite3Isxdigit(zUri[iIn]) \n       && sqlite3Isxdigit(zUri[iIn+1]) \n      ){\n        int octet = (sqlite3HexToInt(zUri[iIn++]) << 4);\n        octet += sqlite3HexToInt(zUri[iIn++]);\n\n        assert( octet>=0 && octet<256 );\n        if( octet==0 ){\n#ifndef SQLITE_ENABLE_URI_00_ERROR\n          /* This branch is taken when \"%00\" appears within the URI. In this\n          ** case we ignore all text in the remainder of the path, name or\n          ** value currently being parsed. So ignore the current character\n          ** and skip to the next \"?\", \"=\" or \"&\", as appropriate. */\n          while( (c = zUri[iIn])!=0 && c!='#' \n              && (eState!=0 || c!='?')\n              && (eState!=1 || (c!='=' && c!='&'))\n              && (eState!=2 || c!='&')\n          ){\n            iIn++;\n          }\n          continue;\n#else\n          /* If ENABLE_URI_00_ERROR is defined, \"%00\" in a URI is an error. */\n          *pzErrMsg = sqlite3_mprintf(\"unexpected %%00 in uri\");\n          rc = SQLITE_ERROR;\n          goto parse_uri_out;\n#endif\n        }\n        c = octet;\n      }else if( eState==1 && (c=='&' || c=='=') ){\n        if( zFile[iOut-1]==0 ){\n          /* An empty option name. Ignore this option altogether. */\n          while( zUri[iIn] && zUri[iIn]!='#' && zUri[iIn-1]!='&' ) iIn++;\n          continue;\n        }\n        if( c=='&' ){\n          zFile[iOut++] = '\\0';\n        }else{\n          eState = 2;\n        }\n        c = 0;\n      }else if( (eState==0 && c=='?') || (eState==2 && c=='&') ){\n        c = 0;\n        eState = 1;\n      }\n      zFile[iOut++] = c;\n    }\n    if( eState==1 ) zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n    zFile[iOut++] = '\\0';\n\n    /* Check if there were any options specified that should be interpreted \n    ** here. Options that are interpreted here include \"vfs\" and those that\n    ** correspond to flags that may be passed to the sqlite3_open_v2()\n    ** method. */\n    zOpt = &zFile[sqlite3Strlen30(zFile)+1];\n    while( zOpt[0] ){\n      int nOpt = sqlite3Strlen30(zOpt);\n      char *zVal = &zOpt[nOpt+1];\n      int nVal = sqlite3Strlen30(zVal);\n\n      if( nOpt==3 && memcmp(\"vfs\", zOpt, 3)==0 ){\n        zVfs = zVal;\n      }else{\n        struct OpenMode {\n          const char *z;\n          int mode;\n        } *aMode = 0;\n        char *zModeType = 0;\n        int mask = 0;\n        int limit = 0;\n\n        if( nOpt==5 && memcmp(\"cache\", zOpt, 5)==0 ){\n          static struct OpenMode aCacheMode[] = {\n            { \"shared\",  SQLITE_OPEN_SHAREDCACHE },\n            { \"private\", SQLITE_OPEN_PRIVATECACHE },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_SHAREDCACHE|SQLITE_OPEN_PRIVATECACHE;\n          aMode = aCacheMode;\n          limit = mask;\n          zModeType = \"cache\";\n        }\n        if( nOpt==4 && memcmp(\"mode\", zOpt, 4)==0 ){\n          static struct OpenMode aOpenMode[] = {\n            { \"ro\",  SQLITE_OPEN_READONLY },\n            { \"rw\",  SQLITE_OPEN_READWRITE }, \n            { \"rwc\", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE },\n            { \"memory\", SQLITE_OPEN_MEMORY },\n            { 0, 0 }\n          };\n\n          mask = SQLITE_OPEN_READONLY | SQLITE_OPEN_READWRITE\n                   | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY;\n          aMode = aOpenMode;\n          limit = mask & flags;\n          zModeType = \"access\";\n        }\n\n        if( aMode ){\n          int i;\n          int mode = 0;\n          for(i=0; aMode[i].z; i++){\n            const char *z = aMode[i].z;\n            if( nVal==sqlite3Strlen30(z) && 0==memcmp(zVal, z, nVal) ){\n              mode = aMode[i].mode;\n              break;\n            }\n          }\n          if( mode==0 ){\n            *pzErrMsg = sqlite3_mprintf(\"no such %s mode: %s\", zModeType, zVal);\n            rc = SQLITE_ERROR;\n            goto parse_uri_out;\n          }\n          if( (mode & ~SQLITE_OPEN_MEMORY)>limit ){\n            *pzErrMsg = sqlite3_mprintf(\"%s mode not allowed: %s\",\n                                        zModeType, zVal);\n            rc = SQLITE_PERM;\n            goto parse_uri_out;\n          }\n          flags = (flags & ~mask) | mode;\n        }\n      }\n\n      zOpt = &zVal[nVal+1];\n    }\n\n  }else{\n    zFile = sqlite3_malloc64(nUri+2);\n    if( !zFile ) return SQLITE_NOMEM_BKPT;\n    if( nUri ){\n      memcpy(zFile, zUri, nUri);\n    }\n    zFile[nUri] = '\\0';\n    zFile[nUri+1] = '\\0';\n    flags &= ~SQLITE_OPEN_URI;\n  }\n\n  *ppVfs = sqlite3_vfs_find(zVfs);\n  if( *ppVfs==0 ){\n    *pzErrMsg = sqlite3_mprintf(\"no such vfs: %s\", zVfs);\n    rc = SQLITE_ERROR;\n  }\n parse_uri_out:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(zFile);\n    zFile = 0;\n  }\n  *pFlags = flags;\n  *pzFile = zFile;\n  return rc;\n}\n\n\n/*\n** This routine does the work of opening a database on behalf of\n** sqlite3_open() and sqlite3_open16(). The database filename \"zFilename\"  \n** is UTF-8 encoded.\n*/\nstatic int openDatabase(\n  const char *zFilename, /* Database filename UTF-8 encoded */\n  sqlite3 **ppDb,        /* OUT: Returned database handle */\n  unsigned int flags,    /* Operational flags */\n  const char *zVfs       /* Name of the VFS to use */\n){\n  sqlite3 *db;                    /* Store allocated handle here */\n  int rc;                         /* Return code */\n  int isThreadsafe;               /* True for threadsafe connections */\n  char *zOpen = 0;                /* Filename argument to pass to BtreeOpen() */\n  char *zErrMsg = 0;              /* Error message from sqlite3ParseUri() */\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n\n  if( sqlite3GlobalConfig.bCoreMutex==0 ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_NOMUTEX ){\n    isThreadsafe = 0;\n  }else if( flags & SQLITE_OPEN_FULLMUTEX ){\n    isThreadsafe = 1;\n  }else{\n    isThreadsafe = sqlite3GlobalConfig.bFullMutex;\n  }\n  if( flags & SQLITE_OPEN_PRIVATECACHE ){\n    flags &= ~SQLITE_OPEN_SHAREDCACHE;\n  }else if( sqlite3GlobalConfig.sharedCacheEnabled ){\n    flags |= SQLITE_OPEN_SHAREDCACHE;\n  }\n\n  /* Remove harmful bits from the flags parameter\n  **\n  ** The SQLITE_OPEN_NOMUTEX and SQLITE_OPEN_FULLMUTEX flags were\n  ** dealt with in the previous code block.  Besides these, the only\n  ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY,\n  ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,\n  ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits.  Silently mask\n  ** off all other flags.\n  */\n  flags &=  ~( SQLITE_OPEN_DELETEONCLOSE |\n               SQLITE_OPEN_EXCLUSIVE |\n               SQLITE_OPEN_MAIN_DB |\n               SQLITE_OPEN_TEMP_DB | \n               SQLITE_OPEN_TRANSIENT_DB | \n               SQLITE_OPEN_MAIN_JOURNAL | \n               SQLITE_OPEN_TEMP_JOURNAL | \n               SQLITE_OPEN_SUBJOURNAL | \n               SQLITE_OPEN_MASTER_JOURNAL |\n               SQLITE_OPEN_NOMUTEX |\n               SQLITE_OPEN_FULLMUTEX |\n               SQLITE_OPEN_WAL\n             );\n\n  /* Allocate the sqlite data structure */\n  db = sqlite3MallocZero( sizeof(sqlite3) );\n  if( db==0 ) goto opendb_out;\n  if( isThreadsafe ){\n    db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n    if( db->mutex==0 ){\n      sqlite3_free(db);\n      db = 0;\n      goto opendb_out;\n    }\n  }\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = 0xff;\n  db->nDb = 2;\n  db->magic = SQLITE_MAGIC_BUSY;\n  db->aDb = db->aDbStatic;\n\n  assert( sizeof(db->aLimit)==sizeof(aHardLimit) );\n  memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));\n  db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;\n  db->autoCommit = 1;\n  db->nextAutovac = -1;\n  db->szMmap = sqlite3GlobalConfig.szMmap;\n  db->nextPagesize = 0;\n  db->nMaxSorterMmap = 0x7FFFFFFF;\n  db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill\n#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX\n                 | SQLITE_AutoIndex\n#endif\n#if SQLITE_DEFAULT_CKPTFULLFSYNC\n                 | SQLITE_CkptFullFSync\n#endif\n#if SQLITE_DEFAULT_FILE_FORMAT<4\n                 | SQLITE_LegacyFileFmt\n#endif\n#ifdef SQLITE_ENABLE_LOAD_EXTENSION\n                 | SQLITE_LoadExtension\n#endif\n#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n                 | SQLITE_RecTriggers\n#endif\n#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS\n                 | SQLITE_ForeignKeys\n#endif\n#if defined(SQLITE_REVERSE_UNORDERED_SELECTS)\n                 | SQLITE_ReverseOrder\n#endif\n#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)\n                 | SQLITE_CellSizeCk\n#endif\n#if defined(SQLITE_ENABLE_FTS3_TOKENIZER)\n                 | SQLITE_Fts3Tokenizer\n#endif\n#if defined(SQLITE_ENABLE_QPSG)\n                 | SQLITE_EnableQPSG\n#endif\n      ;\n  sqlite3HashInit(&db->aCollSeq);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3HashInit(&db->aModule);\n#endif\n\n  /* Add the default collation sequence BINARY. BINARY works for both UTF-8\n  ** and UTF-16, so add a version for each to avoid any unnecessary\n  ** conversions. The only error that can occur here is a malloc() failure.\n  **\n  ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating\n  ** functions:\n  */\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0);\n  createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0);\n  createCollation(db, \"NOCASE\", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);\n  createCollation(db, \"RTRIM\", SQLITE_UTF8, (void*)1, binCollFunc, 0);\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n  /* EVIDENCE-OF: R-08308-17224 The default collating function for all\n  ** strings is BINARY. \n  */\n  db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);\n  assert( db->pDfltColl!=0 );\n\n  /* Parse the filename/URI argument\n  **\n  ** Only allow sensible combinations of bits in the flags argument.  \n  ** Throw an error if any non-sense combination is used.  If we\n  ** do not block illegal combinations here, it could trigger\n  ** assert() statements in deeper layers.  Sensible combinations\n  ** are:\n  **\n  **  1:  SQLITE_OPEN_READONLY\n  **  2:  SQLITE_OPEN_READWRITE\n  **  6:  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE\n  */\n  db->openFlags = flags;\n  assert( SQLITE_OPEN_READONLY  == 0x01 );\n  assert( SQLITE_OPEN_READWRITE == 0x02 );\n  assert( SQLITE_OPEN_CREATE    == 0x04 );\n  testcase( (1<<(flags&7))==0x02 ); /* READONLY */\n  testcase( (1<<(flags&7))==0x04 ); /* READWRITE */\n  testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */\n  if( ((1<<(flags&7)) & 0x46)==0 ){\n    rc = SQLITE_MISUSE_BKPT;  /* IMP: R-65497-44594 */\n  }else{\n    rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n    sqlite3ErrorWithMsg(db, rc, zErrMsg ? \"%s\" : 0, zErrMsg);\n    sqlite3_free(zErrMsg);\n    goto opendb_out;\n  }\n\n  /* Open the backend database driver */\n  rc = sqlite3BtreeOpen(db->pVfs, zOpen, db, &db->aDb[0].pBt, 0,\n                        flags | SQLITE_OPEN_MAIN_DB);\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_IOERR_NOMEM ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n    sqlite3Error(db, rc);\n    goto opendb_out;\n  }\n  sqlite3BtreeEnter(db->aDb[0].pBt);\n  db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);\n  if( !db->mallocFailed ) ENC(db) = SCHEMA_ENC(db);\n  sqlite3BtreeLeave(db->aDb[0].pBt);\n  db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);\n\n  /* The default safety_level for the main database is FULL; for the temp\n  ** database it is OFF. This matches the pager layer defaults.  \n  */\n  db->aDb[0].zDbSName = \"main\";\n  db->aDb[0].safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;\n  db->aDb[1].zDbSName = \"temp\";\n  db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF;\n\n  db->magic = SQLITE_MAGIC_OPEN;\n  if( db->mallocFailed ){\n    goto opendb_out;\n  }\n\n  /* Register all built-in functions, but do not attempt to read the\n  ** database schema yet. This is delayed until the first time the database\n  ** is accessed.\n  */\n  sqlite3Error(db, SQLITE_OK);\n  sqlite3RegisterPerConnectionBuiltinFunctions(db);\n  rc = sqlite3_errcode(db);\n\n#ifdef SQLITE_ENABLE_FTS5\n  /* Register any built-in FTS5 module before loading the automatic\n  ** extensions. This allows automatic extensions to register FTS5 \n  ** tokenizers and auxiliary functions.  */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts5Init(db);\n  }\n#endif\n\n  /* Load automatic extensions - extensions that have been registered\n  ** using the sqlite3_automatic_extension() API.\n  */\n  if( rc==SQLITE_OK ){\n    sqlite3AutoLoadExtensions(db);\n    rc = sqlite3_errcode(db);\n    if( rc!=SQLITE_OK ){\n      goto opendb_out;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_FTS1\n  if( !db->mallocFailed ){\n    extern int sqlite3Fts1Init(sqlite3*);\n    rc = sqlite3Fts1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS2\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    extern int sqlite3Fts2Init(sqlite3*);\n    rc = sqlite3Fts2Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_FTS3 /* automatically defined by SQLITE_ENABLE_FTS4 */\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3Fts3Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  if( !db->mallocFailed && rc==SQLITE_OK ){\n    rc = sqlite3IcuInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3RtreeInit(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBPAGE_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbpageRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_DBSTAT_VTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3DbstatRegister(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_JSON1\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3Json1Init(db);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_STMTVTAB\n  if( !db->mallocFailed && rc==SQLITE_OK){\n    rc = sqlite3StmtVtabInit(db);\n  }\n#endif\n\n  /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking\n  ** mode.  -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking\n  ** mode.  Doing nothing at all also makes NORMAL the default.\n  */\n#ifdef SQLITE_DEFAULT_LOCKING_MODE\n  db->dfltLockMode = SQLITE_DEFAULT_LOCKING_MODE;\n  sqlite3PagerLockingMode(sqlite3BtreePager(db->aDb[0].pBt),\n                          SQLITE_DEFAULT_LOCKING_MODE);\n#endif\n\n  if( rc ) sqlite3Error(db, rc);\n\n  /* Enable the lookaside-malloc subsystem */\n  setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,\n                        sqlite3GlobalConfig.nLookaside);\n\n  sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);\n\nopendb_out:\n  if( db ){\n    assert( db->mutex!=0 || isThreadsafe==0\n           || sqlite3GlobalConfig.bFullMutex==0 );\n    sqlite3_mutex_leave(db->mutex);\n  }\n  rc = sqlite3_errcode(db);\n  assert( db!=0 || rc==SQLITE_NOMEM );\n  if( rc==SQLITE_NOMEM ){\n    sqlite3_close(db);\n    db = 0;\n  }else if( rc!=SQLITE_OK ){\n    db->magic = SQLITE_MAGIC_SICK;\n  }\n  *ppDb = db;\n#ifdef SQLITE_ENABLE_SQLLOG\n  if( sqlite3GlobalConfig.xSqllog ){\n    /* Opening a db handle. Fourth parameter is passed 0. */\n    void *pArg = sqlite3GlobalConfig.pSqllogArg;\n    sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC)\n  if( rc==SQLITE_OK ){\n    const char *zKey;\n    if( (zKey = sqlite3_uri_parameter(zOpen, \"hexkey\"))!=0 && zKey[0] ){\n      u8 iByte;\n      int i;\n      char zDecoded[40];\n      for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){\n        iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);\n        if( (i&1)!=0 ) zDecoded[i/2] = iByte;\n      }\n      sqlite3_key_v2(db, 0, zDecoded, i/2);\n    }else if( (zKey = sqlite3_uri_parameter(zOpen, \"key\"))!=0 ){\n      sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));\n    }\n  }\n#endif\n  sqlite3_free(zOpen);\n  return rc & 0xff;\n}\n\n/*\n** Open a new database handle.\n*/\nint sqlite3_open(\n  const char *zFilename, \n  sqlite3 **ppDb \n){\n  return openDatabase(zFilename, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n}\nint sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n){\n  return openDatabase(filename, ppDb, (unsigned int)flags, zVfs);\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Open a new database handle.\n*/\nint sqlite3_open16(\n  const void *zFilename, \n  sqlite3 **ppDb\n){\n  char const *zFilename8;   /* zFilename encoded in UTF-8 instead of UTF-16 */\n  sqlite3_value *pVal;\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppDb==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppDb = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( zFilename==0 ) zFilename = \"\\000\\000\";\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);\n  zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);\n  if( zFilename8 ){\n    rc = openDatabase(zFilename8, ppDb,\n                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);\n    assert( *ppDb || rc==SQLITE_NOMEM );\n    if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){\n      SCHEMA_ENC(*ppDb) = ENC(*ppDb) = SQLITE_UTF16NATIVE;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  sqlite3ValueFree(pVal);\n\n  return rc & 0xff;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nint sqlite3_create_collation(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  return sqlite3_create_collation_v2(db, zName, enc, pCtx, xCompare, 0);\n}\n\n/*\n** Register a new collation sequence with the database handle db.\n*/\nint sqlite3_create_collation_v2(\n  sqlite3* db, \n  const char *zName, \n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDel)(void*)\n){\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a new collation sequence with the database handle db.\n*/\nint sqlite3_create_collation16(\n  sqlite3* db, \n  const void *zName,\n  int enc, \n  void* pCtx,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n){\n  int rc = SQLITE_OK;\n  char *zName8;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  assert( !db->mallocFailed );\n  zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);\n  if( zName8 ){\n    rc = createCollation(db, zName8, (u8)enc, pCtx, xCompare, 0);\n    sqlite3DbFree(db, zName8);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nint sqlite3_collation_needed(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = xCollNeeded;\n  db->xCollNeeded16 = 0;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Register a collation sequence factory callback with the database handle\n** db. Replace any previously installed collation sequence factory.\n*/\nint sqlite3_collation_needed16(\n  sqlite3 *db, \n  void *pCollNeededArg, \n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->xCollNeeded = 0;\n  db->xCollNeeded16 = xCollNeeded16;\n  db->pCollNeededArg = pCollNeededArg;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This function is now an anachronism. It used to be used to recover from a\n** malloc() failure, but SQLite now does this automatically.\n*/\nint sqlite3_global_recover(void){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Test to see whether or not the database connection is in autocommit\n** mode.  Return TRUE if it is and FALSE if not.  Autocommit mode is on\n** by default.  Autocommit is disabled by a BEGIN statement and reenabled\n** by the next COMMIT or ROLLBACK.\n*/\nint sqlite3_get_autocommit(sqlite3 *db){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  return db->autoCommit;\n}\n\n/*\n** The following routines are substitutes for constants SQLITE_CORRUPT,\n** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error\n** constants.  They serve two purposes:\n**\n**   1.  Serve as a convenient place to set a breakpoint in a debugger\n**       to detect when version error conditions occurs.\n**\n**   2.  Invoke sqlite3_log() to provide the source code location where\n**       a low-level error is first detected.\n*/\nstatic int reportError(int iErr, int lineno, const char *zType){\n  sqlite3_log(iErr, \"%s at line %d of [%.10s]\",\n              zType, lineno, 20+sqlite3_sourceid());\n  return iErr;\n}\nint sqlite3CorruptError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CORRUPT, lineno, \"database corruption\");\n}\nint sqlite3MisuseError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_MISUSE, lineno, \"misuse\");\n}\nint sqlite3CantopenError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CANTOPEN, lineno, \"cannot open file\");\n}\n#ifdef SQLITE_DEBUG\nint sqlite3CorruptPgnoError(int lineno, Pgno pgno){\n  char zMsg[100];\n  sqlite3_snprintf(sizeof(zMsg), zMsg, \"database corruption page %d\", pgno);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_CORRUPT, lineno, zMsg);\n}\nint sqlite3NomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_NOMEM, lineno, \"OOM\");\n}\nint sqlite3IoerrnomemError(int lineno){\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  return reportError(SQLITE_IOERR_NOMEM, lineno, \"I/O OOM error\");\n}\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** This is a convenience routine that makes sure that all thread-specific\n** data for this thread has been deallocated.\n**\n** SQLite no longer uses thread-specific data so this routine is now a\n** no-op.  It is retained for historical compatibility.\n*/\nvoid sqlite3_thread_cleanup(void){\n}\n#endif\n\n/*\n** Return meta information about a specific column of a database table.\n** See comment in sqlite3.h (sqlite.h.in) for details.\n*/\nint sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n){\n  int rc;\n  char *zErrMsg = 0;\n  Table *pTab = 0;\n  Column *pCol = 0;\n  int iCol = 0;\n  char const *zDataType = 0;\n  char const *zCollSeq = 0;\n  int notnull = 0;\n  int primarykey = 0;\n  int autoinc = 0;\n\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTableName==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  /* Ensure the database schema has been loaded */\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Init(db, &zErrMsg);\n  if( SQLITE_OK!=rc ){\n    goto error_out;\n  }\n\n  /* Locate the table in question */\n  pTab = sqlite3FindTable(db, zTableName, zDbName);\n  if( !pTab || pTab->pSelect ){\n    pTab = 0;\n    goto error_out;\n  }\n\n  /* Find the column for which info is requested */\n  if( zColumnName==0 ){\n    /* Query for existance of table only */\n  }else{\n    for(iCol=0; iCol<pTab->nCol; iCol++){\n      pCol = &pTab->aCol[iCol];\n      if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){\n        iCol = pTab->iPKey;\n        pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;\n      }else{\n        pTab = 0;\n        goto error_out;\n      }\n    }\n  }\n\n  /* The following block stores the meta information that will be returned\n  ** to the caller in local variables zDataType, zCollSeq, notnull, primarykey\n  ** and autoinc. At this point there are two possibilities:\n  ** \n  **     1. The specified column name was rowid\", \"oid\" or \"_rowid_\" \n  **        and there is no explicitly declared IPK column. \n  **\n  **     2. The table is not a view and the column name identified an \n  **        explicitly declared column. Copy meta information from *pCol.\n  */ \n  if( pCol ){\n    zDataType = sqlite3ColumnType(pCol,0);\n    zCollSeq = pCol->zColl;\n    notnull = pCol->notNull!=0;\n    primarykey  = (pCol->colFlags & COLFLAG_PRIMKEY)!=0;\n    autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0;\n  }else{\n    zDataType = \"INTEGER\";\n    primarykey = 1;\n  }\n  if( !zCollSeq ){\n    zCollSeq = sqlite3StrBINARY;\n  }\n\nerror_out:\n  sqlite3BtreeLeaveAll(db);\n\n  /* Whether the function call succeeded or failed, set the output parameters\n  ** to whatever their local counterparts contain. If an error did occur,\n  ** this has the effect of zeroing all output parameters.\n  */\n  if( pzDataType ) *pzDataType = zDataType;\n  if( pzCollSeq ) *pzCollSeq = zCollSeq;\n  if( pNotNull ) *pNotNull = notnull;\n  if( pPrimaryKey ) *pPrimaryKey = primarykey;\n  if( pAutoinc ) *pAutoinc = autoinc;\n\n  if( SQLITE_OK==rc && !pTab ){\n    sqlite3DbFree(db, zErrMsg);\n    zErrMsg = sqlite3MPrintf(db, \"no such table column: %s.%s\", zTableName,\n        zColumnName);\n    rc = SQLITE_ERROR;\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErrMsg?\"%s\":0), zErrMsg);\n  sqlite3DbFree(db, zErrMsg);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nint sqlite3_sleep(int ms){\n  sqlite3_vfs *pVfs;\n  int rc;\n  pVfs = sqlite3_vfs_find(0);\n  if( pVfs==0 ) return 0;\n\n  /* This function works in milliseconds, but the underlying OsSleep() \n  ** API uses microseconds. Hence the 1000's.\n  */\n  rc = (sqlite3OsSleep(pVfs, 1000*ms)/1000);\n  return rc;\n}\n\n/*\n** Enable or disable the extended result codes.\n*/\nint sqlite3_extended_result_codes(sqlite3 *db, int onoff){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  db->errMask = onoff ? 0xffffffff : 0xff;\n  sqlite3_mutex_leave(db->mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xFileControl method on a particular database.\n*/\nint sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){\n  int rc = SQLITE_ERROR;\n  Btree *pBtree;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pBtree = sqlite3DbNameToBtree(db, zDbName);\n  if( pBtree ){\n    Pager *pPager;\n    sqlite3_file *fd;\n    sqlite3BtreeEnter(pBtree);\n    pPager = sqlite3BtreePager(pBtree);\n    assert( pPager!=0 );\n    fd = sqlite3PagerFile(pPager);\n    assert( fd!=0 );\n    if( op==SQLITE_FCNTL_FILE_POINTER ){\n      *(sqlite3_file**)pArg = fd;\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_VFS_POINTER ){\n      *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager);\n      rc = SQLITE_OK;\n    }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){\n      *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager);\n      rc = SQLITE_OK;\n    }else if( fd->pMethods ){\n      rc = sqlite3OsFileControl(fd, op, pArg);\n    }else{\n      rc = SQLITE_NOTFOUND;\n    }\n    sqlite3BtreeLeave(pBtree);\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Interface to the testing logic.\n*/\nint sqlite3_test_control(int op, ...){\n  int rc = 0;\n#ifdef SQLITE_UNTESTABLE\n  UNUSED_PARAMETER(op);\n#else\n  va_list ap;\n  va_start(ap, op);\n  switch( op ){\n\n    /*\n    ** Save the current state of the PRNG.\n    */\n    case SQLITE_TESTCTRL_PRNG_SAVE: {\n      sqlite3PrngSaveState();\n      break;\n    }\n\n    /*\n    ** Restore the state of the PRNG to the last state saved using\n    ** PRNG_SAVE.  If PRNG_SAVE has never before been called, then\n    ** this verb acts like PRNG_RESET.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESTORE: {\n      sqlite3PrngRestoreState();\n      break;\n    }\n\n    /*\n    ** Reset the PRNG back to its uninitialized state.  The next call\n    ** to sqlite3_randomness() will reseed the PRNG using a single call\n    ** to the xRandomness method of the default VFS.\n    */\n    case SQLITE_TESTCTRL_PRNG_RESET: {\n      sqlite3_randomness(0,0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BITVEC_TEST, size, program)\n    **\n    ** Run a test against a Bitvec object of size.  The program argument\n    ** is an array of integers that defines the test.  Return -1 on a\n    ** memory allocation error, 0 on success, or non-zero for an error.\n    ** See the sqlite3BitvecBuiltinTest() for additional information.\n    */\n    case SQLITE_TESTCTRL_BITVEC_TEST: {\n      int sz = va_arg(ap, int);\n      int *aProg = va_arg(ap, int*);\n      rc = sqlite3BitvecBuiltinTest(sz, aProg);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(FAULT_INSTALL, xCallback)\n    **\n    ** Arrange to invoke xCallback() whenever sqlite3FaultSim() is called,\n    ** if xCallback is not NULL.\n    **\n    ** As a test of the fault simulator mechanism itself, sqlite3FaultSim(0)\n    ** is called immediately after installing the new callback and the return\n    ** value from sqlite3FaultSim(0) becomes the return from\n    ** sqlite3_test_control().\n    */\n    case SQLITE_TESTCTRL_FAULT_INSTALL: {\n      /* MSVC is picky about pulling func ptrs from va lists.\n      ** http://support.microsoft.com/kb/47961\n      ** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));\n      */\n      typedef int(*TESTCALLBACKFUNC_t)(int);\n      sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);\n      rc = sqlite3FaultSim(0);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)\n    **\n    ** Register hooks to call to indicate which malloc() failures \n    ** are benign.\n    */\n    case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS: {\n      typedef void (*void_function)(void);\n      void_function xBenignBegin;\n      void_function xBenignEnd;\n      xBenignBegin = va_arg(ap, void_function);\n      xBenignEnd = va_arg(ap, void_function);\n      sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, unsigned int X)\n    **\n    ** Set the PENDING byte to the value in the argument, if X>0.\n    ** Make no changes if X==0.  Return the value of the pending byte\n    ** as it existing before this routine was called.\n    **\n    ** IMPORTANT:  Changing the PENDING byte from 0x40000000 results in\n    ** an incompatible database file format.  Changing the PENDING byte\n    ** while any database connection is open results in undefined and\n    ** deleterious behavior.\n    */\n    case SQLITE_TESTCTRL_PENDING_BYTE: {\n      rc = PENDING_BYTE;\n#ifndef SQLITE_OMIT_WSD\n      {\n        unsigned int newVal = va_arg(ap, unsigned int);\n        if( newVal ) sqlite3PendingByte = newVal;\n      }\n#endif\n      break;\n    }\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, int X)\n    **\n    ** This action provides a run-time test to see whether or not\n    ** assert() was enabled at compile-time.  If X is true and assert()\n    ** is enabled, then the return value is true.  If X is true and\n    ** assert() is disabled, then the return value is zero.  If X is\n    ** false and assert() is enabled, then the assertion fires and the\n    ** process aborts.  If X is false and assert() is disabled, then the\n    ** return value is zero.\n    */\n    case SQLITE_TESTCTRL_ASSERT: {\n      volatile int x = 0;\n      assert( /*side-effects-ok*/ (x = va_arg(ap,int))!=0 );\n      rc = x;\n      break;\n    }\n\n\n    /*\n    **  sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, int X)\n    **\n    ** This action provides a run-time test to see how the ALWAYS and\n    ** NEVER macros were defined at compile-time.\n    **\n    ** The return value is ALWAYS(X) if X is true, or 0 if X is false.\n    **\n    ** The recommended test is X==2.  If the return value is 2, that means\n    ** ALWAYS() and NEVER() are both no-op pass-through macros, which is the\n    ** default setting.  If the return value is 1, then ALWAYS() is either\n    ** hard-coded to true or else it asserts if its argument is false.\n    ** The first behavior (hard-coded to true) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is disabled and the second\n    ** behavior (assert if the argument to ALWAYS() is false) is the case if\n    ** SQLITE_TESTCTRL_ASSERT shows that assert() is enabled.\n    **\n    ** The run-time test procedure might look something like this:\n    **\n    **    if( sqlite3_test_control(SQLITE_TESTCTRL_ALWAYS, 2)==2 ){\n    **      // ALWAYS() and NEVER() are no-op pass-through macros\n    **    }else if( sqlite3_test_control(SQLITE_TESTCTRL_ASSERT, 1) ){\n    **      // ALWAYS(x) asserts that x is true. NEVER(x) asserts x is false.\n    **    }else{\n    **      // ALWAYS(x) is a constant 1.  NEVER(x) is a constant 0.\n    **    }\n    */\n    case SQLITE_TESTCTRL_ALWAYS: {\n      int x = va_arg(ap,int);\n      rc = x ? ALWAYS(x) : 0;\n      break;\n    }\n\n    /*\n    **   sqlite3_test_control(SQLITE_TESTCTRL_BYTEORDER);\n    **\n    ** The integer returned reveals the byte-order of the computer on which\n    ** SQLite is running:\n    **\n    **       1     big-endian,    determined at run-time\n    **      10     little-endian, determined at run-time\n    **  432101     big-endian,    determined at compile-time\n    **  123410     little-endian, determined at compile-time\n    */ \n    case SQLITE_TESTCTRL_BYTEORDER: {\n      rc = SQLITE_BYTEORDER*100 + SQLITE_LITTLEENDIAN*10 + SQLITE_BIGENDIAN;\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_RESERVE, sqlite3 *db, int N)\n    **\n    ** Set the nReserve size to N for the main database on the database\n    ** connection db.\n    */\n    case SQLITE_TESTCTRL_RESERVE: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      int x = va_arg(ap,int);\n      sqlite3_mutex_enter(db->mutex);\n      sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)\n    **\n    ** Enable or disable various optimizations for testing purposes.  The \n    ** argument N is a bitmask of optimizations to be disabled.  For normal\n    ** operation N should be 0.  The idea is that a test program (like the\n    ** SQL Logic Test or SLT test module) can run the same SQL multiple times\n    ** with various optimizations disabled to verify that the same answer\n    ** is obtained in every case.\n    */\n    case SQLITE_TESTCTRL_OPTIMIZATIONS: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);\n      break;\n    }\n\n#ifdef SQLITE_N_KEYWORD\n    /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)\n    **\n    ** If zWord is a keyword recognized by the parser, then return the\n    ** number of keywords.  Or if zWord is not a keyword, return 0.\n    ** \n    ** This test feature is only available in the amalgamation since\n    ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite\n    ** is built using separate source files.\n    */\n    case SQLITE_TESTCTRL_ISKEYWORD: {\n      const char *zWord = va_arg(ap, const char*);\n      int n = sqlite3Strlen30(zWord);\n      rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;\n      break;\n    }\n#endif \n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);\n    **\n    ** If parameter onoff is non-zero, configure the wrappers so that all\n    ** subsequent calls to localtime() and variants fail. If onoff is zero,\n    ** undo this setting.\n    */\n    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {\n      sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);\n    **\n    ** Set or clear a flag that indicates that the database file is always well-\n    ** formed and never corrupt.  This flag is clear by default, indicating that\n    ** database files might have arbitrary corruption.  Setting the flag during\n    ** testing causes certain assert() statements in the code to be activated\n    ** that demonstrat invariants on well-formed database files.\n    */\n    case SQLITE_TESTCTRL_NEVER_CORRUPT: {\n      sqlite3GlobalConfig.neverCorrupt = va_arg(ap, int);\n      break;\n    }\n\n    /* Set the threshold at which OP_Once counters reset back to zero.\n    ** By default this is 0x7ffffffe (over 2 billion), but that value is\n    ** too big to test in a reasonable amount of time, so this control is\n    ** provided to set a small and easily reachable reset value.\n    */\n    case SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD: {\n      sqlite3GlobalConfig.iOnceResetThreshold = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE, xCallback, ptr);\n    **\n    ** Set the VDBE coverage callback function to xCallback with context \n    ** pointer ptr.\n    */\n    case SQLITE_TESTCTRL_VDBE_COVERAGE: {\n#ifdef SQLITE_VDBE_COVERAGE\n      typedef void (*branch_callback)(void*,int,u8,u8);\n      sqlite3GlobalConfig.xVdbeBranch = va_arg(ap,branch_callback);\n      sqlite3GlobalConfig.pVdbeBranchArg = va_arg(ap,void*);\n#endif\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, nMax); */\n    case SQLITE_TESTCTRL_SORTER_MMAP: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      db->nMaxSorterMmap = va_arg(ap, int);\n      break;\n    }\n\n    /*   sqlite3_test_control(SQLITE_TESTCTRL_ISINIT);\n    **\n    ** Return SQLITE_OK if SQLite has been initialized and SQLITE_ERROR if\n    ** not.\n    */\n    case SQLITE_TESTCTRL_ISINIT: {\n      if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;\n      break;\n    }\n\n    /*  sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);\n    **\n    ** This test control is used to create imposter tables.  \"db\" is a pointer\n    ** to the database connection.  dbName is the database name (ex: \"main\" or\n    ** \"temp\") which will receive the imposter.  \"onOff\" turns imposter mode on\n    ** or off.  \"tnum\" is the root page of the b-tree to which the imposter\n    ** table should connect.\n    **\n    ** Enable imposter mode only when the schema has already been parsed.  Then\n    ** run a single CREATE TABLE statement to construct the imposter table in\n    ** the parsed schema.  Then turn imposter mode back off again.\n    **\n    ** If onOff==0 and tnum>0 then reset the schema for all databases, causing\n    ** the schema to be reparsed the next time it is needed.  This has the\n    ** effect of erasing all imposter tables.\n    */\n    case SQLITE_TESTCTRL_IMPOSTER: {\n      sqlite3 *db = va_arg(ap, sqlite3*);\n      sqlite3_mutex_enter(db->mutex);\n      db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*));\n      db->init.busy = db->init.imposterTable = va_arg(ap,int);\n      db->init.newTnum = va_arg(ap,int);\n      if( db->init.busy==0 && db->init.newTnum>0 ){\n        sqlite3ResetAllSchemasOfConnection(db);\n      }\n      sqlite3_mutex_leave(db->mutex);\n      break;\n    }\n  }\n  va_end(ap);\n#endif /* SQLITE_UNTESTABLE */\n  return rc;\n}\n\n/*\n** This is a utility routine, useful to VFS implementations, that checks\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of the query parameter.\n**\n** The zFilename argument is the filename pointer passed into the xOpen()\n** method of a VFS implementation.  The zParam argument is the name of the\n** query parameter we seek.  This routine returns the value of the zParam\n** parameter if it exists.  If the parameter does not exist, this routine\n** returns a NULL pointer.\n*/\nconst char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){\n  if( zFilename==0 || zParam==0 ) return 0;\n  zFilename += sqlite3Strlen30(zFilename) + 1;\n  while( zFilename[0] ){\n    int x = strcmp(zFilename, zParam);\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n    if( x==0 ) return zFilename;\n    zFilename += sqlite3Strlen30(zFilename) + 1;\n  }\n  return 0;\n}\n\n/*\n** Return a boolean value for a query parameter.\n*/\nint sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  bDflt = bDflt!=0;\n  return z ? sqlite3GetBoolean(z, bDflt) : bDflt;\n}\n\n/*\n** Return a 64-bit integer value for a query parameter.\n*/\nsqlite3_int64 sqlite3_uri_int64(\n  const char *zFilename,    /* Filename as passed to xOpen */\n  const char *zParam,       /* URI parameter sought */\n  sqlite3_int64 bDflt       /* return if parameter is missing */\n){\n  const char *z = sqlite3_uri_parameter(zFilename, zParam);\n  sqlite3_int64 v;\n  if( z && sqlite3DecOrHexToI64(z, &v)==0 ){\n    bDflt = v;\n  }\n  return bDflt;\n}\n\n/*\n** Return the Btree pointer identified by zDbName.  Return NULL if not found.\n*/\nBtree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){\n  int iDb = zDbName ? sqlite3FindDbName(db, zDbName) : 0;\n  return iDb<0 ? 0 : db->aDb[iDb].pBt;\n}\n\n/*\n** Return the filename of the database associated with a database\n** connection.\n*/\nconst char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeGetFilename(pBt) : 0;\n}\n\n/*\n** Return 1 if database is read-only or 0 if read/write.  Return -1 if\n** no such database exists.\n*/\nint sqlite3_db_readonly(sqlite3 *db, const char *zDbName){\n  Btree *pBt;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return -1;\n  }\n#endif\n  pBt = sqlite3DbNameToBtree(db, zDbName);\n  return pBt ? sqlite3BtreeIsReadonly(pBt) : -1;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Obtain a snapshot handle for the snapshot of database zDb currently \n** being read by handle db.\n*/\nint sqlite3_snapshot_get(\n  sqlite3 *db, \n  const char *zDb,\n  sqlite3_snapshot **ppSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n\n  if( db->autoCommit==0 ){\n    int iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( 0==sqlite3BtreeIsInTrans(pBt) ){\n        rc = sqlite3BtreeBeginTrans(pBt, 0);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Open a read-transaction on the snapshot idendified by pSnapshot.\n*/\nint sqlite3_snapshot_open(\n  sqlite3 *db, \n  const char *zDb, \n  sqlite3_snapshot *pSnapshot\n){\n  int rc = SQLITE_ERROR;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  if( db->autoCommit==0 ){\n    int iDb;\n    iDb = sqlite3FindDbName(db, zDb);\n    if( iDb==0 || iDb>1 ){\n      Btree *pBt = db->aDb[iDb].pBt;\n      if( 0==sqlite3BtreeIsInReadTrans(pBt) ){\n        rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3BtreeBeginTrans(pBt, 0);\n          sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);\n        }\n      }\n    }\n  }\n\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Recover as many snapshots as possible from the wal file associated with\n** schema zDb of database db.\n*/\nint sqlite3_snapshot_recover(sqlite3 *db, const char *zDb){\n  int rc = SQLITE_ERROR;\n  int iDb;\n#ifndef SQLITE_OMIT_WAL\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n\n  sqlite3_mutex_enter(db->mutex);\n  iDb = sqlite3FindDbName(db, zDb);\n  if( iDb==0 || iDb>1 ){\n    Btree *pBt = db->aDb[iDb].pBt;\n    if( 0==sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));\n        sqlite3BtreeCommit(pBt);\n      }\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n#endif   /* SQLITE_OMIT_WAL */\n  return rc;\n}\n\n/*\n** Free a snapshot handle obtained from sqlite3_snapshot_get().\n*/\nvoid sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){\n  sqlite3_free(pSnapshot);\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n/*\n** Given the name of a compile-time option, return true if that option\n** was used and false if not.\n**\n** The name can optionally begin with \"SQLITE_\" but the \"SQLITE_\" prefix\n** is not required for a match.\n*/\nint sqlite3_compileoption_used(const char *zOptName){\n  int i, n;\n  int nOpt;\n  const char **azCompileOpt;\n \n#if SQLITE_ENABLE_API_ARMOR\n  if( zOptName==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n\n  if( sqlite3StrNICmp(zOptName, \"SQLITE_\", 7)==0 ) zOptName += 7;\n  n = sqlite3Strlen30(zOptName);\n\n  /* Since nOpt is normally in single digits, a linear search is \n  ** adequate. No need for a binary search. */\n  for(i=0; i<nOpt; i++){\n    if( sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0\n     && sqlite3IsIdChar((unsigned char)azCompileOpt[i][n])==0\n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Return the N-th compile-time option string.  If N is out of range,\n** return a NULL pointer.\n*/\nconst char *sqlite3_compileoption_get(int N){\n  int nOpt;\n  const char **azCompileOpt;\n  azCompileOpt = sqlite3CompileOptions(&nOpt);\n  if( N>=0 && N<nOpt ){\n    return azCompileOpt[N];\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/malloc.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** Memory allocation functions used throughout sqlite.\n*/\n#include \"sqliteInt.h\"\n#include <stdarg.h>\n\n/*\n** Attempt to release up to n bytes of non-essential memory currently\n** held by SQLite. An example of non-essential memory is memory used to\n** cache database pages that are not currently in use.\n*/\nint sqlite3_release_memory(int n){\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  return sqlite3PcacheReleaseMemory(n);\n#else\n  /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine\n  ** is a no-op returning zero if SQLite is not compiled with\n  ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */\n  UNUSED_PARAMETER(n);\n  return 0;\n#endif\n}\n\n/*\n** State information local to the memory allocation subsystem.\n*/\nstatic SQLITE_WSD struct Mem0Global {\n  sqlite3_mutex *mutex;         /* Mutex to serialize access */\n  sqlite3_int64 alarmThreshold; /* The soft heap limit */\n\n  /*\n  ** True if heap is nearly \"full\" where \"full\" is defined by the\n  ** sqlite3_soft_heap_limit() setting.\n  */\n  int nearlyFull;\n} mem0 = { 0, 0, 0 };\n\n#define mem0 GLOBAL(struct Mem0Global, mem0)\n\n/*\n** Return the memory allocator mutex. sqlite3_status() needs it.\n*/\nsqlite3_mutex *sqlite3MallocMutex(void){\n  return mem0.mutex;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  It used to set an alarm callback\n** that was invoked when memory usage grew too large.  Now it is a\n** no-op.\n*/\nint sqlite3_memory_alarm(\n  void(*xCallback)(void *pArg, sqlite3_int64 used,int N),\n  void *pArg,\n  sqlite3_int64 iThreshold\n){\n  (void)xCallback;\n  (void)pArg;\n  (void)iThreshold;\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Set the soft heap-size limit for the library. Passing a zero or \n** negative value indicates no limit.\n*/\nsqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){\n  sqlite3_int64 priorLimit;\n  sqlite3_int64 excess;\n  sqlite3_int64 nUsed;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return -1;\n#endif\n  sqlite3_mutex_enter(mem0.mutex);\n  priorLimit = mem0.alarmThreshold;\n  if( n<0 ){\n    sqlite3_mutex_leave(mem0.mutex);\n    return priorLimit;\n  }\n  mem0.alarmThreshold = n;\n  nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n  mem0.nearlyFull = (n>0 && n<=nUsed);\n  sqlite3_mutex_leave(mem0.mutex);\n  excess = sqlite3_memory_used() - n;\n  if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));\n  return priorLimit;\n}\nvoid sqlite3_soft_heap_limit(int n){\n  if( n<0 ) n = 0;\n  sqlite3_soft_heap_limit64(n);\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nint sqlite3MallocInit(void){\n  int rc;\n  if( sqlite3GlobalConfig.m.xMalloc==0 ){\n    sqlite3MemSetDefault();\n  }\n  memset(&mem0, 0, sizeof(mem0));\n  mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512\n      || sqlite3GlobalConfig.nPage<=0 ){\n    sqlite3GlobalConfig.pPage = 0;\n    sqlite3GlobalConfig.szPage = 0;\n  }\n  rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);\n  if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));\n  return rc;\n}\n\n/*\n** Return true if the heap is currently under memory pressure - in other\n** words if the amount of heap used is close to the limit set by\n** sqlite3_soft_heap_limit().\n*/\nint sqlite3HeapNearlyFull(void){\n  return mem0.nearlyFull;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nvoid sqlite3MallocEnd(void){\n  if( sqlite3GlobalConfig.m.xShutdown ){\n    sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);\n  }\n  memset(&mem0, 0, sizeof(mem0));\n}\n\n/*\n** Return the amount of memory currently checked out.\n*/\nsqlite3_int64 sqlite3_memory_used(void){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, 0);\n  return res;\n}\n\n/*\n** Return the maximum amount of memory that has ever been\n** checked out since either the beginning of this process\n** or since the most recent reset.\n*/\nsqlite3_int64 sqlite3_memory_highwater(int resetFlag){\n  sqlite3_int64 res, mx;\n  sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag);\n  return mx;\n}\n\n/*\n** Trigger the alarm \n*/\nstatic void sqlite3MallocAlarm(int nByte){\n  if( mem0.alarmThreshold<=0 ) return;\n  sqlite3_mutex_leave(mem0.mutex);\n  sqlite3_release_memory(nByte);\n  sqlite3_mutex_enter(mem0.mutex);\n}\n\n/*\n** Do a memory allocation with statistics and alarms.  Assume the\n** lock is already held.\n*/\nstatic void mallocWithAlarm(int n, void **pp){\n  void *p;\n  int nFull;\n  assert( sqlite3_mutex_held(mem0.mutex) );\n  assert( n>0 );\n\n  /* In Firefox (circa 2017-02-08), xRoundup() is remapped to an internal\n  ** implementation of malloc_good_size(), which must be called in debug\n  ** mode and specifically when the DMD \"Dark Matter Detector\" is enabled\n  ** or else a crash results.  Hence, do not attempt to optimize out the\n  ** following xRoundup() call. */\n  nFull = sqlite3GlobalConfig.m.xRoundup(n);\n\n#ifdef SQLITE_MAX_MEMORY\n  if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){\n    *pp = 0;\n    return;\n  }\n#endif\n\n  sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);\n  if( mem0.alarmThreshold>0 ){\n    sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);\n    if( nUsed >= mem0.alarmThreshold - nFull ){\n      mem0.nearlyFull = 1;\n      sqlite3MallocAlarm(nFull);\n    }else{\n      mem0.nearlyFull = 0;\n    }\n  }\n  p = sqlite3GlobalConfig.m.xMalloc(nFull);\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  if( p==0 && mem0.alarmThreshold>0 ){\n    sqlite3MallocAlarm(nFull);\n    p = sqlite3GlobalConfig.m.xMalloc(nFull);\n  }\n#endif\n  if( p ){\n    nFull = sqlite3MallocSize(p);\n    sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);\n    sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);\n  }\n  *pp = p;\n}\n\n/*\n** Allocate memory.  This routine is like sqlite3_malloc() except that it\n** assumes the memory subsystem has already been initialized.\n*/\nvoid *sqlite3Malloc(u64 n){\n  void *p;\n  if( n==0 || n>=0x7fffff00 ){\n    /* A memory allocation of a number of bytes which is near the maximum\n    ** signed integer value might cause an integer overflow inside of the\n    ** xMalloc().  Hence we limit the maximum size to 0x7fffff00, giving\n    ** 255 bytes of overhead.  SQLite itself will never use anything near\n    ** this amount.  The only way to reach the limit is with sqlite3_malloc() */\n    p = 0;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    mallocWithAlarm((int)n, &p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    p = sqlite3GlobalConfig.m.xMalloc((int)n);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(p) );  /* IMP: R-11148-40995 */\n  return p;\n}\n\n/*\n** This version of the memory allocation is for use by the application.\n** First make sure the memory subsystem is initialized, then do the\n** allocation.\n*/\nvoid *sqlite3_malloc(int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return n<=0 ? 0 : sqlite3Malloc(n);\n}\nvoid *sqlite3_malloc64(sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Malloc(n);\n}\n\n/*\n** TRUE if p is a lookaside memory allocation from db\n*/\n#ifndef SQLITE_OMIT_LOOKASIDE\nstatic int isLookaside(sqlite3 *db, void *p){\n  return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd);\n}\n#else\n#define isLookaside(A,B) 0\n#endif\n\n/*\n** Return the size of a memory allocation previously obtained from\n** sqlite3Malloc() or sqlite3_malloc().\n*/\nint sqlite3MallocSize(void *p){\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return sqlite3GlobalConfig.m.xSize(p);\n}\nint sqlite3DbMallocSize(sqlite3 *db, void *p){\n  assert( p!=0 );\n  if( db==0 || !isLookaside(db,p) ){\n#ifdef SQLITE_DEBUG\n    if( db==0 ){\n      assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n      assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n    }\n#endif\n    return sqlite3GlobalConfig.m.xSize(p);\n  }else{\n    assert( sqlite3_mutex_held(db->mutex) );\n    return db->lookaside.sz;\n  }\n}\nsqlite3_uint64 sqlite3_msize(void *p){\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  return p ? sqlite3GlobalConfig.m.xSize(p) : 0;\n}\n\n/*\n** Free memory previously obtained from sqlite3Malloc().\n*/\nvoid sqlite3_free(void *p){\n  if( p==0 ) return;  /* IMP: R-49053-54554 */\n  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );\n  if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));\n    sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);\n    sqlite3GlobalConfig.m.xFree(p);\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    sqlite3GlobalConfig.m.xFree(p);\n  }\n}\n\n/*\n** Add the size of memory allocation \"p\" to the count in\n** *db->pnBytesFreed.\n*/\nstatic SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){\n  *db->pnBytesFreed += sqlite3DbMallocSize(db,p);\n}\n\n/*\n** Free memory that might be associated with a particular database\n** connection.  Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op.\n** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL.\n*/\nvoid sqlite3DbFreeNN(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  assert( p!=0 );\n  if( db ){\n    if( db->pnBytesFreed ){\n      measureAllocationSize(db, p);\n      return;\n    }\n    if( isLookaside(db, p) ){\n      LookasideSlot *pBuf = (LookasideSlot*)p;\n#ifdef SQLITE_DEBUG\n      /* Trash all content in the buffer being freed */\n      memset(p, 0xaa, db->lookaside.sz);\n#endif\n      pBuf->pNext = db->lookaside.pFree;\n      db->lookaside.pFree = pBuf;\n      return;\n    }\n  }\n  assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n  assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  sqlite3_free(p);\n}\nvoid sqlite3DbFree(sqlite3 *db, void *p){\n  assert( db==0 || sqlite3_mutex_held(db->mutex) );\n  if( p ) sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nvoid *sqlite3Realloc(void *pOld, u64 nBytes){\n  int nOld, nNew, nDiff;\n  void *pNew;\n  assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );\n  assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );\n  if( pOld==0 ){\n    return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */\n  }\n  if( nBytes==0 ){\n    sqlite3_free(pOld); /* IMP: R-26507-47431 */\n    return 0;\n  }\n  if( nBytes>=0x7fffff00 ){\n    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */\n    return 0;\n  }\n  nOld = sqlite3MallocSize(pOld);\n  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second\n  ** argument to xRealloc is always a value returned by a prior call to\n  ** xRoundup. */\n  nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);\n  if( nOld==nNew ){\n    pNew = pOld;\n  }else if( sqlite3GlobalConfig.bMemstat ){\n    sqlite3_mutex_enter(mem0.mutex);\n    sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);\n    nDiff = nNew - nOld;\n    if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= \n          mem0.alarmThreshold-nDiff ){\n      sqlite3MallocAlarm(nDiff);\n    }\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    if( pNew==0 && mem0.alarmThreshold>0 ){\n      sqlite3MallocAlarm((int)nBytes);\n      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n    }\n    if( pNew ){\n      nNew = sqlite3MallocSize(pNew);\n      sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);\n    }\n    sqlite3_mutex_leave(mem0.mutex);\n  }else{\n    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-11148-40995 */\n  return pNew;\n}\n\n/*\n** The public interface to sqlite3Realloc.  Make sure that the memory\n** subsystem is initialized prior to invoking sqliteRealloc.\n*/\nvoid *sqlite3_realloc(void *pOld, int n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  if( n<0 ) n = 0;  /* IMP: R-26507-47431 */\n  return sqlite3Realloc(pOld, n);\n}\nvoid *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return sqlite3Realloc(pOld, n);\n}\n\n\n/*\n** Allocate and zero memory.\n*/ \nvoid *sqlite3MallocZero(u64 n){\n  void *p = sqlite3Malloc(n);\n  if( p ){\n    memset(p, 0, (size_t)n);\n  }\n  return p;\n}\n\n/*\n** Allocate and zero memory.  If the allocation fails, make\n** the mallocFailed flag in the connection pointer.\n*/\nvoid *sqlite3DbMallocZero(sqlite3 *db, u64 n){\n  void *p;\n  testcase( db==0 );\n  p = sqlite3DbMallocRaw(db, n);\n  if( p ) memset(p, 0, (size_t)n);\n  return p;\n}\n\n\n/* Finish the work of sqlite3DbMallocRawNN for the unusual and\n** slower case when the allocation cannot be fulfilled using lookaside.\n*/\nstatic SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){\n  void *p;\n  assert( db!=0 );\n  p = sqlite3Malloc(n);\n  if( !p ) sqlite3OomFault(db);\n  sqlite3MemdebugSetType(p, \n         (db->lookaside.bDisable==0) ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP);\n  return p;\n}\n\n/*\n** Allocate memory, either lookaside (if possible) or heap.  \n** If the allocation fails, set the mallocFailed flag in\n** the connection pointer.\n**\n** If db!=0 and db->mallocFailed is true (indicating a prior malloc\n** failure on the same database connection) then always return 0.\n** Hence for a particular database connection, once malloc starts\n** failing, it fails consistently until mallocFailed is reset.\n** This is an important assumption.  There are many places in the\n** code that do things like this:\n**\n**         int *a = (int*)sqlite3DbMallocRaw(db, 100);\n**         int *b = (int*)sqlite3DbMallocRaw(db, 200);\n**         if( b ) a[10] = 9;\n**\n** In other words, if a subsequent malloc (ex: \"b\") worked, it is assumed\n** that all prior mallocs (ex: \"a\") worked too.\n**\n** The sqlite3MallocRawNN() variant guarantees that the \"db\" parameter is\n** not a NULL pointer.\n*/\nvoid *sqlite3DbMallocRaw(sqlite3 *db, u64 n){\n  void *p;\n  if( db ) return sqlite3DbMallocRawNN(db, n);\n  p = sqlite3Malloc(n);\n  sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n  return p;\n}\nvoid *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){\n#ifndef SQLITE_OMIT_LOOKASIDE\n  LookasideSlot *pBuf;\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->lookaside.bDisable==0 ){\n    assert( db->mallocFailed==0 );\n    if( n>db->lookaside.sz ){\n      db->lookaside.anStat[1]++;\n    }else if( (pBuf = db->lookaside.pFree)!=0 ){\n      db->lookaside.pFree = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else if( (pBuf = db->lookaside.pInit)!=0 ){\n      db->lookaside.pInit = pBuf->pNext;\n      db->lookaside.anStat[0]++;\n      return (void*)pBuf;\n    }else{\n      db->lookaside.anStat[2]++;\n    }\n  }else if( db->mallocFailed ){\n    return 0;\n  }\n#else\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( db->pnBytesFreed==0 );\n  if( db->mallocFailed ){\n    return 0;\n  }\n#endif\n  return dbMallocRawFinish(db, n);\n}\n\n/* Forward declaration */\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n);\n\n/*\n** Resize the block of memory pointed to by p to n bytes. If the\n** resize fails, set the mallocFailed flag in the connection object.\n*/\nvoid *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){\n  assert( db!=0 );\n  if( p==0 ) return sqlite3DbMallocRawNN(db, n);\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( isLookaside(db,p) && n<=db->lookaside.sz ) return p;\n  return dbReallocFinish(db, p, n);\n}\nstatic SQLITE_NOINLINE void *dbReallocFinish(sqlite3 *db, void *p, u64 n){\n  void *pNew = 0;\n  assert( db!=0 );\n  assert( p!=0 );\n  if( db->mallocFailed==0 ){\n    if( isLookaside(db, p) ){\n      pNew = sqlite3DbMallocRawNN(db, n);\n      if( pNew ){\n        memcpy(pNew, p, db->lookaside.sz);\n        sqlite3DbFree(db, p);\n      }\n    }else{\n      assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );\n      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n      pNew = sqlite3_realloc64(p, n);\n      if( !pNew ){\n        sqlite3OomFault(db);\n      }\n      sqlite3MemdebugSetType(pNew,\n            (db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));\n    }\n  }\n  return pNew;\n}\n\n/*\n** Attempt to reallocate p.  If the reallocation fails, then free p\n** and set the mallocFailed flag in the database connection.\n*/\nvoid *sqlite3DbReallocOrFree(sqlite3 *db, void *p, u64 n){\n  void *pNew;\n  pNew = sqlite3DbRealloc(db, p, n);\n  if( !pNew ){\n    sqlite3DbFree(db, p);\n  }\n  return pNew;\n}\n\n/*\n** Make a copy of a string in memory obtained from sqliteMalloc(). These \n** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This\n** is because when memory debugging is turned on, these two functions are \n** called via macros that record the current file and line number in the\n** ThreadData structure.\n*/\nchar *sqlite3DbStrDup(sqlite3 *db, const char *z){\n  char *zNew;\n  size_t n;\n  if( z==0 ){\n    return 0;\n  }\n  n = strlen(z) + 1;\n  zNew = sqlite3DbMallocRaw(db, n);\n  if( zNew ){\n    memcpy(zNew, z, n);\n  }\n  return zNew;\n}\nchar *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){\n  char *zNew;\n  assert( db!=0 );\n  if( z==0 ){\n    return 0;\n  }\n  assert( (n&0x7fffffff)==n );\n  zNew = sqlite3DbMallocRawNN(db, n+1);\n  if( zNew ){\n    memcpy(zNew, z, (size_t)n);\n    zNew[n] = 0;\n  }\n  return zNew;\n}\n\n/*\n** Free any prior content in *pz and replace it with a copy of zNew.\n*/\nvoid sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){\n  sqlite3DbFree(db, *pz);\n  *pz = sqlite3DbStrDup(db, zNew);\n}\n\n/*\n** Call this routine to record the fact that an OOM (out-of-memory) error\n** has happened.  This routine will set db->mallocFailed, and also\n** temporarily disable the lookaside memory allocator and interrupt\n** any running VDBEs.\n*/\nvoid sqlite3OomFault(sqlite3 *db){\n  if( db->mallocFailed==0 && db->bBenignMalloc==0 ){\n    db->mallocFailed = 1;\n    if( db->nVdbeExec>0 ){\n      db->u1.isInterrupted = 1;\n    }\n    db->lookaside.bDisable++;\n  }\n}\n\n/*\n** This routine reactivates the memory allocator and clears the\n** db->mallocFailed flag as necessary.\n**\n** The memory allocator is not restarted if there are running\n** VDBEs.\n*/\nvoid sqlite3OomClear(sqlite3 *db){\n  if( db->mallocFailed && db->nVdbeExec==0 ){\n    db->mallocFailed = 0;\n    db->u1.isInterrupted = 0;\n    assert( db->lookaside.bDisable>0 );\n    db->lookaside.bDisable--;\n  }\n}\n\n/*\n** Take actions at the end of an API call to indicate an OOM error\n*/\nstatic SQLITE_NOINLINE int apiOomError(sqlite3 *db){\n  sqlite3OomClear(db);\n  sqlite3Error(db, SQLITE_NOMEM);\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** This function must be called before exiting any API function (i.e. \n** returning control to the user) that has called sqlite3_malloc or\n** sqlite3_realloc.\n**\n** The returned value is normally a copy of the second argument to this\n** function. However, if a malloc() failure has occurred since the previous\n** invocation SQLITE_NOMEM is returned instead. \n**\n** If an OOM as occurred, then the connection error-code (the value\n** returned by sqlite3_errcode()) is set to SQLITE_NOMEM.\n*/\nint sqlite3ApiExit(sqlite3* db, int rc){\n  /* If the db handle must hold the connection handle mutex here.\n  ** Otherwise the read (and possible write) of db->mallocFailed \n  ** is unsafe, as is the call to sqlite3Error().\n  */\n  assert( db!=0 );\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){\n    return apiOomError(db);\n  }\n  return rc & db->errMask;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mem0.c",
    "content": "/*\n** 2008 October 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a no-op memory allocation drivers for use when\n** SQLITE_ZERO_MALLOC is defined.  The allocation drivers implemented\n** here always fail.  SQLite will not operate with these drivers.  These\n** are merely placeholders.  Real drivers must be substituted using\n** sqlite3_config() before SQLite will operate.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_ZERO_MALLOC\n\n/*\n** No-op versions of all memory allocation routines\n*/\nstatic void *sqlite3MemMalloc(int nByte){ return 0; }\nstatic void sqlite3MemFree(void *pPrior){ return; }\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){ return 0; }\nstatic int sqlite3MemSize(void *pPrior){ return 0; }\nstatic int sqlite3MemRoundup(int n){ return n; }\nstatic int sqlite3MemInit(void *NotUsed){ return SQLITE_OK; }\nstatic void sqlite3MemShutdown(void *NotUsed){ return; }\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nvoid sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_ZERO_MALLOC */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mem1.c",
    "content": "/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.  The content of\n** this file is only used if SQLITE_SYSTEM_MALLOC is defined.  The\n** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the\n** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined.  The\n** default configuration is to use memory allocation routines in this\n** file.\n**\n** C-preprocessor macro summary:\n**\n**    HAVE_MALLOC_USABLE_SIZE     The configure script sets this symbol if\n**                                the malloc_usable_size() interface exists\n**                                on the target platform.  Or, this symbol\n**                                can be set manually, if desired.\n**                                If an equivalent interface exists by\n**                                a different name, using a separate -D\n**                                option to rename it.\n**\n**    SQLITE_WITHOUT_ZONEMALLOC   Some older macs lack support for the zone\n**                                memory allocator.  Set this symbol to enable\n**                                building on older macs.\n**\n**    SQLITE_WITHOUT_MSIZE        Set this symbol to disable the use of\n**                                _msize() on windows systems.  This might\n**                                be necessary when compiling for Delphi,\n**                                for example.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** This version of the memory allocator is the default.  It is\n** used when no other memory allocator is specified using compile-time\n** macros.\n*/\n#ifdef SQLITE_SYSTEM_MALLOC\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n\n/*\n** Use the zone allocator available on apple products unless the\n** SQLITE_WITHOUT_ZONEMALLOC symbol is defined.\n*/\n#include <sys/sysctl.h>\n#include <malloc/malloc.h>\n#ifdef SQLITE_MIGHT_BE_SINGLE_CORE\n#include <libkern/OSAtomic.h>\n#endif /* SQLITE_MIGHT_BE_SINGLE_CORE */\nstatic malloc_zone_t* _sqliteZone_;\n#define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x))\n#define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x));\n#define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y))\n#define SQLITE_MALLOCSIZE(x) \\\n        (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))\n\n#else /* if not __APPLE__ */\n\n/*\n** Use standard C library malloc and free on non-Apple systems.  \n** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.\n*/\n#define SQLITE_MALLOC(x)             malloc(x)\n#define SQLITE_FREE(x)               free(x)\n#define SQLITE_REALLOC(x,y)          realloc((x),(y))\n\n/*\n** The malloc.h header file is needed for malloc_usable_size() function\n** on some systems (e.g. Linux).\n*/\n#if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE\n#  define SQLITE_USE_MALLOC_H 1\n#  define SQLITE_USE_MALLOC_USABLE_SIZE 1\n/*\n** The MSVCRT has malloc_usable_size(), but it is called _msize().  The\n** use of _msize() is automatic, but can be disabled by compiling with\n** -DSQLITE_WITHOUT_MSIZE.  Using the _msize() function also requires\n** the malloc.h header file.\n*/\n#elif defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)\n#  define SQLITE_USE_MALLOC_H\n#  define SQLITE_USE_MSIZE\n#endif\n\n/*\n** Include the malloc.h header file, if necessary.  Also set define macro\n** SQLITE_MALLOCSIZE to the appropriate function name, which is _msize()\n** for MSVC and malloc_usable_size() for most other systems (e.g. Linux).\n** The memory size function can always be overridden manually by defining\n** the macro SQLITE_MALLOCSIZE to the desired function name.\n*/\n#if defined(SQLITE_USE_MALLOC_H)\n#  include <malloc.h>\n#  if defined(SQLITE_USE_MALLOC_USABLE_SIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE(x)   malloc_usable_size(x)\n#    endif\n#  elif defined(SQLITE_USE_MSIZE)\n#    if !defined(SQLITE_MALLOCSIZE)\n#      define SQLITE_MALLOCSIZE      _msize\n#    endif\n#  endif\n#endif /* defined(SQLITE_USE_MALLOC_H) */\n\n#endif /* __APPLE__ or not __APPLE__ */\n\n/*\n** Like malloc(), but remember the size of the allocation\n** so that we can find it later using sqlite3MemSize().\n**\n** For this low-level routine, we are guaranteed that nByte>0 because\n** cases of nByte<=0 will be intercepted and dealt with by higher level\n** routines.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p;\n  testcase( ROUND8(nByte)==nByte );\n  p = SQLITE_MALLOC( nByte );\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p;\n  assert( nByte>0 );\n  testcase( ROUND8(nByte)!=nByte );\n  p = SQLITE_MALLOC( nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes of memory\", nByte);\n  }\n  return (void *)p;\n#endif\n}\n\n/*\n** Like free() but works for allocations obtained from sqlite3MemMalloc()\n** or sqlite3MemRealloc().\n**\n** For this low-level routine, we already know that pPrior!=0 since\n** cases where pPrior==0 will have been intecepted and dealt with\n** by higher-level routines.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  SQLITE_FREE(pPrior);\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 );\n  p--;\n  SQLITE_FREE(p);\n#endif\n}\n\n/*\n** Report the allocated size of a prior return from xMalloc()\n** or xRealloc().\n*/\nstatic int sqlite3MemSize(void *pPrior){\n#ifdef SQLITE_MALLOCSIZE\n  assert( pPrior!=0 );\n  return (int)SQLITE_MALLOCSIZE(pPrior);\n#else\n  sqlite3_int64 *p;\n  assert( pPrior!=0 );\n  p = (sqlite3_int64*)pPrior;\n  p--;\n  return (int)p[0];\n#endif\n}\n\n/*\n** Like realloc().  Resize an allocation previously obtained from\n** sqlite3MemMalloc().\n**\n** For this low-level interface, we know that pPrior!=0.  Cases where\n** pPrior==0 while have been intercepted by higher-level routine and\n** redirected to xMalloc.  Similarly, we know that nByte>0 because\n** cases where nByte<=0 will have been intercepted by higher-level\n** routines and redirected to xFree.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n#ifdef SQLITE_MALLOCSIZE\n  void *p = SQLITE_REALLOC(pPrior, nByte);\n  if( p==0 ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      SQLITE_MALLOCSIZE(pPrior), nByte);\n  }\n  return p;\n#else\n  sqlite3_int64 *p = (sqlite3_int64*)pPrior;\n  assert( pPrior!=0 && nByte>0 );\n  assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */\n  p--;\n  p = SQLITE_REALLOC(p, nByte+8 );\n  if( p ){\n    p[0] = nByte;\n    p++;\n  }else{\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM,\n      \"failed memory resize %u to %u bytes\",\n      sqlite3MemSize(pPrior), nByte);\n  }\n  return (void*)p;\n#endif\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Initialize this module.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n#if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC)\n  int cpuCount;\n  size_t len;\n  if( _sqliteZone_ ){\n    return SQLITE_OK;\n  }\n  len = sizeof(cpuCount);\n  /* One usually wants to use hw.acctivecpu for MT decisions, but not here */\n  sysctlbyname(\"hw.ncpu\", &cpuCount, &len, NULL, 0);\n  if( cpuCount>1 ){\n    /* defer MT decisions to system malloc */\n    _sqliteZone_ = malloc_default_zone();\n  }else{\n    /* only 1 core, use our own zone to contention over global locks, \n    ** e.g. we have our own dedicated locks */\n    _sqliteZone_ = malloc_create_zone(4096, 0);\n    malloc_set_zone_name(_sqliteZone_, \"Sqlite_Heap\");\n  }\n#endif /*  defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) */\n  UNUSED_PARAMETER(NotUsed);\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  return;\n}\n\n/*\n** This routine is the only routine in this file with external linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nvoid sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n#endif /* SQLITE_SYSTEM_MALLOC */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mem2.c",
    "content": "/*\n** 2007 August 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains low-level memory allocation drivers for when\n** SQLite will use the standard C-library malloc/realloc/free interface\n** to obtain the memory it needs while adding lots of additional debugging\n** information to each allocation in order to help detect and fix memory\n** leaks and memory usage errors.\n**\n** This file contains implementations of the low-level memory allocation\n** routines specified in the sqlite3_mem_methods object.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** This version of the memory allocator is used only if the\n** SQLITE_MEMDEBUG macro is defined\n*/\n#ifdef SQLITE_MEMDEBUG\n\n/*\n** The backtrace functionality is only available with GLIBC\n*/\n#ifdef __GLIBC__\n  extern int backtrace(void**,int);\n  extern void backtrace_symbols_fd(void*const*,int,int);\n#else\n# define backtrace(A,B) 1\n# define backtrace_symbols_fd(A,B,C)\n#endif\n#include <stdio.h>\n\n/*\n** Each memory allocation looks like this:\n**\n**  ------------------------------------------------------------------------\n**  | Title |  backtrace pointers |  MemBlockHdr |  allocation |  EndGuard |\n**  ------------------------------------------------------------------------\n**\n** The application code sees only a pointer to the allocation.  We have\n** to back up from the allocation pointer to find the MemBlockHdr.  The\n** MemBlockHdr tells us the size of the allocation and the number of\n** backtrace pointers.  There is also a guard word at the end of the\n** MemBlockHdr.\n*/\nstruct MemBlockHdr {\n  i64 iSize;                          /* Size of this allocation */\n  struct MemBlockHdr *pNext, *pPrev;  /* Linked list of all unfreed memory */\n  char nBacktrace;                    /* Number of backtraces on this alloc */\n  char nBacktraceSlots;               /* Available backtrace slots */\n  u8 nTitle;                          /* Bytes of title; includes '\\0' */\n  u8 eType;                           /* Allocation type code */\n  int iForeGuard;                     /* Guard word for sanity */\n};\n\n/*\n** Guard words\n*/\n#define FOREGUARD 0x80F5E153\n#define REARGUARD 0xE4676B53\n\n/*\n** Number of malloc size increments to track.\n*/\n#define NCSIZE  1000\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic struct {\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n  /*\n  ** Head and tail of a linked list of all outstanding allocations\n  */\n  struct MemBlockHdr *pFirst;\n  struct MemBlockHdr *pLast;\n  \n  /*\n  ** The number of levels of backtrace to save in new allocations.\n  */\n  int nBacktrace;\n  void (*xBacktrace)(int, int, void **);\n\n  /*\n  ** Title text to insert in front of each block\n  */\n  int nTitle;        /* Bytes of zTitle to save.  Includes '\\0' and padding */\n  char zTitle[100];  /* The title text */\n\n  /* \n  ** sqlite3MallocDisallow() increments the following counter.\n  ** sqlite3MallocAllow() decrements it.\n  */\n  int disallow; /* Do not allow memory allocation */\n\n  /*\n  ** Gather statistics on the sizes of memory allocations.\n  ** nAlloc[i] is the number of allocation attempts of i*8\n  ** bytes.  i==NCSIZE is the number of allocation attempts for\n  ** sizes more than NCSIZE*8 bytes.\n  */\n  int nAlloc[NCSIZE];      /* Total number of allocations */\n  int nCurrent[NCSIZE];    /* Current number of allocations */\n  int mxCurrent[NCSIZE];   /* Highwater mark for nCurrent */\n\n} mem;\n\n\n/*\n** Adjust memory usage statistics\n*/\nstatic void adjustStats(int iSize, int increment){\n  int i = ROUND8(iSize)/8;\n  if( i>NCSIZE-1 ){\n    i = NCSIZE - 1;\n  }\n  if( increment>0 ){\n    mem.nAlloc[i]++;\n    mem.nCurrent[i]++;\n    if( mem.nCurrent[i]>mem.mxCurrent[i] ){\n      mem.mxCurrent[i] = mem.nCurrent[i];\n    }\n  }else{\n    mem.nCurrent[i]--;\n    assert( mem.nCurrent[i]>=0 );\n  }\n}\n\n/*\n** Given an allocation, find the MemBlockHdr for that allocation.\n**\n** This routine checks the guards at either end of the allocation and\n** if they are incorrect it asserts.\n*/\nstatic struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){\n  struct MemBlockHdr *p;\n  int *pInt;\n  u8 *pU8;\n  int nReserve;\n\n  p = (struct MemBlockHdr*)pAllocation;\n  p--;\n  assert( p->iForeGuard==(int)FOREGUARD );\n  nReserve = ROUND8(p->iSize);\n  pInt = (int*)pAllocation;\n  pU8 = (u8*)pAllocation;\n  assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );\n  /* This checks any of the \"extra\" bytes allocated due\n  ** to rounding up to an 8 byte boundary to ensure \n  ** they haven't been overwritten.\n  */\n  while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );\n  return p;\n}\n\n/*\n** Return the number of bytes currently allocated at address p.\n*/\nstatic int sqlite3MemSize(void *p){\n  struct MemBlockHdr *pHdr;\n  if( !p ){\n    return 0;\n  }\n  pHdr = sqlite3MemsysGetHeader(p);\n  return (int)pHdr->iSize;\n}\n\n/*\n** Initialize the memory allocation subsystem.\n*/\nstatic int sqlite3MemInit(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( (sizeof(struct MemBlockHdr)&7) == 0 );\n  if( !sqlite3GlobalConfig.bMemstat ){\n    /* If memory status is enabled, then the malloc.c wrapper will already\n    ** hold the STATIC_MEM mutex when the routines here are invoked. */\n    mem.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize the memory allocation subsystem.\n*/\nstatic void sqlite3MemShutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem.mutex = 0;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int sqlite3MemRoundup(int n){\n  return ROUND8(n);\n}\n\n/*\n** Fill a buffer with pseudo-random bytes.  This is used to preset\n** the content of a new memory allocation to unpredictable values and\n** to clear the content of a freed allocation to unpredictable values.\n*/\nstatic void randomFill(char *pBuf, int nByte){\n  unsigned int x, y, r;\n  x = SQLITE_PTR_TO_INT(pBuf);\n  y = nByte | 1;\n  while( nByte >= 4 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(int*)pBuf = r;\n    pBuf += 4;\n    nByte -= 4;\n  }\n  while( nByte-- > 0 ){\n    x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);\n    y = y*1103515245 + 12345;\n    r = x ^ y;\n    *(pBuf++) = r & 0xff;\n  }\n}\n\n/*\n** Allocate nByte bytes of memory.\n*/\nstatic void *sqlite3MemMalloc(int nByte){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  int *pInt;\n  void *p = 0;\n  int totalSize;\n  int nReserve;\n  sqlite3_mutex_enter(mem.mutex);\n  assert( mem.disallow==0 );\n  nReserve = ROUND8(nByte);\n  totalSize = nReserve + sizeof(*pHdr) + sizeof(int) +\n               mem.nBacktrace*sizeof(void*) + mem.nTitle;\n  p = malloc(totalSize);\n  if( p ){\n    z = p;\n    pBt = (void**)&z[mem.nTitle];\n    pHdr = (struct MemBlockHdr*)&pBt[mem.nBacktrace];\n    pHdr->pNext = 0;\n    pHdr->pPrev = mem.pLast;\n    if( mem.pLast ){\n      mem.pLast->pNext = pHdr;\n    }else{\n      mem.pFirst = pHdr;\n    }\n    mem.pLast = pHdr;\n    pHdr->iForeGuard = FOREGUARD;\n    pHdr->eType = MEMTYPE_HEAP;\n    pHdr->nBacktraceSlots = mem.nBacktrace;\n    pHdr->nTitle = mem.nTitle;\n    if( mem.nBacktrace ){\n      void *aAddr[40];\n      pHdr->nBacktrace = backtrace(aAddr, mem.nBacktrace+1)-1;\n      memcpy(pBt, &aAddr[1], pHdr->nBacktrace*sizeof(void*));\n      assert(pBt[0]);\n      if( mem.xBacktrace ){\n        mem.xBacktrace(nByte, pHdr->nBacktrace-1, &aAddr[1]);\n      }\n    }else{\n      pHdr->nBacktrace = 0;\n    }\n    if( mem.nTitle ){\n      memcpy(z, mem.zTitle, mem.nTitle);\n    }\n    pHdr->iSize = nByte;\n    adjustStats(nByte, +1);\n    pInt = (int*)&pHdr[1];\n    pInt[nReserve/sizeof(int)] = REARGUARD;\n    randomFill((char*)pInt, nByte);\n    memset(((char*)pInt)+nByte, 0x65, nReserve-nByte);\n    p = (void*)pInt;\n  }\n  sqlite3_mutex_leave(mem.mutex);\n  return p; \n}\n\n/*\n** Free memory.\n*/\nstatic void sqlite3MemFree(void *pPrior){\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  char *z;\n  assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0 \n       || mem.mutex!=0 );\n  pHdr = sqlite3MemsysGetHeader(pPrior);\n  pBt = (void**)pHdr;\n  pBt -= pHdr->nBacktraceSlots;\n  sqlite3_mutex_enter(mem.mutex);\n  if( pHdr->pPrev ){\n    assert( pHdr->pPrev->pNext==pHdr );\n    pHdr->pPrev->pNext = pHdr->pNext;\n  }else{\n    assert( mem.pFirst==pHdr );\n    mem.pFirst = pHdr->pNext;\n  }\n  if( pHdr->pNext ){\n    assert( pHdr->pNext->pPrev==pHdr );\n    pHdr->pNext->pPrev = pHdr->pPrev;\n  }else{\n    assert( mem.pLast==pHdr );\n    mem.pLast = pHdr->pPrev;\n  }\n  z = (char*)pBt;\n  z -= pHdr->nTitle;\n  adjustStats((int)pHdr->iSize, -1);\n  randomFill(z, sizeof(void*)*pHdr->nBacktraceSlots + sizeof(*pHdr) +\n                (int)pHdr->iSize + sizeof(int) + pHdr->nTitle);\n  free(z);\n  sqlite3_mutex_leave(mem.mutex);  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** For this debugging implementation, we *always* make a copy of the\n** allocation into a new place in memory.  In this way, if the \n** higher level code is using pointer to the old allocation, it is \n** much more likely to break and we are much more liking to find\n** the error.\n*/\nstatic void *sqlite3MemRealloc(void *pPrior, int nByte){\n  struct MemBlockHdr *pOldHdr;\n  void *pNew;\n  assert( mem.disallow==0 );\n  assert( (nByte & 7)==0 );     /* EV: R-46199-30249 */\n  pOldHdr = sqlite3MemsysGetHeader(pPrior);\n  pNew = sqlite3MemMalloc(nByte);\n  if( pNew ){\n    memcpy(pNew, pPrior, (int)(nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize));\n    if( nByte>pOldHdr->iSize ){\n      randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);\n    }\n    sqlite3MemFree(pPrior);\n  }\n  return pNew;\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file.\n*/\nvoid sqlite3MemSetDefault(void){\n  static const sqlite3_mem_methods defaultMethods = {\n     sqlite3MemMalloc,\n     sqlite3MemFree,\n     sqlite3MemRealloc,\n     sqlite3MemSize,\n     sqlite3MemRoundup,\n     sqlite3MemInit,\n     sqlite3MemShutdown,\n     0\n  };\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods);\n}\n\n/*\n** Set the \"type\" of an allocation.\n*/\nvoid sqlite3MemdebugSetType(void *p, u8 eType){\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );\n    pHdr->eType = eType;\n  }\n}\n\n/*\n** Return TRUE if the mask of type in eType matches the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );\n*/\nint sqlite3MemdebugHasType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)==0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if the mask of type in eType matches no bits of the type of the\n** allocation p.  Also return true if p==NULL.\n**\n** This routine is designed for use within an assert() statement, to\n** verify the type of an allocation.  For example:\n**\n**     assert( sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );\n*/\nint sqlite3MemdebugNoType(void *p, u8 eType){\n  int rc = 1;\n  if( p && sqlite3GlobalConfig.m.xMalloc==sqlite3MemMalloc ){\n    struct MemBlockHdr *pHdr;\n    pHdr = sqlite3MemsysGetHeader(p);\n    assert( pHdr->iForeGuard==FOREGUARD );         /* Allocation is valid */\n    if( (pHdr->eType&eType)!=0 ){\n      rc = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Set the number of backtrace levels kept for each allocation.\n** A value of zero turns off backtracing.  The number is always rounded\n** up to a multiple of 2.\n*/\nvoid sqlite3MemdebugBacktrace(int depth){\n  if( depth<0 ){ depth = 0; }\n  if( depth>20 ){ depth = 20; }\n  depth = (depth+1)&0xfe;\n  mem.nBacktrace = depth;\n}\n\nvoid sqlite3MemdebugBacktraceCallback(void (*xBacktrace)(int, int, void **)){\n  mem.xBacktrace = xBacktrace;\n}\n\n/*\n** Set the title string for subsequent allocations.\n*/\nvoid sqlite3MemdebugSettitle(const char *zTitle){\n  unsigned int n = sqlite3Strlen30(zTitle) + 1;\n  sqlite3_mutex_enter(mem.mutex);\n  if( n>=sizeof(mem.zTitle) ) n = sizeof(mem.zTitle)-1;\n  memcpy(mem.zTitle, zTitle, n);\n  mem.zTitle[n] = 0;\n  mem.nTitle = ROUND8(n);\n  sqlite3_mutex_leave(mem.mutex);\n}\n\nvoid sqlite3MemdebugSync(){\n  struct MemBlockHdr *pHdr;\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    void **pBt = (void**)pHdr;\n    pBt -= pHdr->nBacktraceSlots;\n    mem.xBacktrace((int)pHdr->iSize, pHdr->nBacktrace-1, &pBt[1]);\n  }\n}\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nvoid sqlite3MemdebugDump(const char *zFilename){\n  FILE *out;\n  struct MemBlockHdr *pHdr;\n  void **pBt;\n  int i;\n  out = fopen(zFilename, \"w\");\n  if( out==0 ){\n    fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                    zFilename);\n    return;\n  }\n  for(pHdr=mem.pFirst; pHdr; pHdr=pHdr->pNext){\n    char *z = (char*)pHdr;\n    z -= pHdr->nBacktraceSlots*sizeof(void*) + pHdr->nTitle;\n    fprintf(out, \"**** %lld bytes at %p from %s ****\\n\", \n            pHdr->iSize, &pHdr[1], pHdr->nTitle ? z : \"???\");\n    if( pHdr->nBacktrace ){\n      fflush(out);\n      pBt = (void**)pHdr;\n      pBt -= pHdr->nBacktraceSlots;\n      backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(out));\n      fprintf(out, \"\\n\");\n    }\n  }\n  fprintf(out, \"COUNTS:\\n\");\n  for(i=0; i<NCSIZE-1; i++){\n    if( mem.nAlloc[i] ){\n      fprintf(out, \"   %5d: %10d %10d %10d\\n\", \n            i*8, mem.nAlloc[i], mem.nCurrent[i], mem.mxCurrent[i]);\n    }\n  }\n  if( mem.nAlloc[NCSIZE-1] ){\n    fprintf(out, \"   %5d: %10d %10d %10d\\n\",\n             NCSIZE*8-8, mem.nAlloc[NCSIZE-1],\n             mem.nCurrent[NCSIZE-1], mem.mxCurrent[NCSIZE-1]);\n  }\n  fclose(out);\n}\n\n/*\n** Return the number of times sqlite3MemMalloc() has been called.\n*/\nint sqlite3MemdebugMallocCount(){\n  int i;\n  int nTotal = 0;\n  for(i=0; i<NCSIZE; i++){\n    nTotal += mem.nAlloc[i];\n  }\n  return nTotal;\n}\n\n\n#endif /* SQLITE_MEMDEBUG */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mem3.c",
    "content": "/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The SQLite user supplies a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS3 is defined.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** This version of the memory allocator is only built into the library\n** SQLITE_ENABLE_MEMSYS3 is defined. Defining this symbol does not\n** mean that the library will use a memory-pool by default, just that\n** it is available. The mempool allocator is activated by calling\n** sqlite3_config().\n*/\n#ifdef SQLITE_ENABLE_MEMSYS3\n\n/*\n** Maximum size (in Mem3Blocks) of a \"small\" chunk.\n*/\n#define MX_SMALL 10\n\n\n/*\n** Number of freelist hash slots\n*/\n#define N_HASH  61\n\n/*\n** A memory allocation (also called a \"chunk\") consists of two or \n** more blocks where each block is 8 bytes.  The first 8 bytes are \n** a header that is not returned to the user.\n**\n** A chunk is two or more blocks that is either checked out or\n** free.  The first block has format u.hdr.  u.hdr.size4x is 4 times the\n** size of the allocation in blocks if the allocation is free.\n** The u.hdr.size4x&1 bit is true if the chunk is checked out and\n** false if the chunk is on the freelist.  The u.hdr.size4x&2 bit\n** is true if the previous chunk is checked out and false if the\n** previous chunk is free.  The u.hdr.prevSize field is the size of\n** the previous chunk in blocks if the previous chunk is on the\n** freelist. If the previous chunk is checked out, then\n** u.hdr.prevSize can be part of the data for that chunk and should\n** not be read or written.\n**\n** We often identify a chunk by its index in mem3.aPool[].  When\n** this is done, the chunk index refers to the second block of\n** the chunk.  In this way, the first chunk has an index of 1.\n** A chunk index of 0 means \"no such chunk\" and is the equivalent\n** of a NULL pointer.\n**\n** The second block of free chunks is of the form u.list.  The\n** two fields form a double-linked list of chunks of related sizes.\n** Pointers to the head of the list are stored in mem3.aiSmall[] \n** for smaller chunks and mem3.aiHash[] for larger chunks.\n**\n** The second block of a chunk is user data if the chunk is checked \n** out.  If a chunk is checked out, the user data may extend into\n** the u.hdr.prevSize value of the following chunk.\n*/\ntypedef struct Mem3Block Mem3Block;\nstruct Mem3Block {\n  union {\n    struct {\n      u32 prevSize;   /* Size of previous chunk in Mem3Block elements */\n      u32 size4x;     /* 4x the size of current chunk in Mem3Block elements */\n    } hdr;\n    struct {\n      u32 next;       /* Index in mem3.aPool[] of next free chunk */\n      u32 prev;       /* Index in mem3.aPool[] of previous free chunk */\n    } list;\n  } u;\n};\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem3\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem3Global {\n  /*\n  ** Memory available for allocation. nPool is the size of the array\n  ** (in Mem3Blocks) pointed to by aPool less 2.\n  */\n  u32 nPool;\n  Mem3Block *aPool;\n\n  /*\n  ** True if we are evaluating an out-of-memory callback.\n  */\n  int alarmBusy;\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n  \n  /*\n  ** The minimum amount of free space that we have seen.\n  */\n  u32 mnMaster;\n\n  /*\n  ** iMaster is the index of the master chunk.  Most new allocations\n  ** occur off of this chunk.  szMaster is the size (in Mem3Blocks)\n  ** of the current master.  iMaster is 0 if there is not master chunk.\n  ** The master chunk is not in either the aiHash[] or aiSmall[].\n  */\n  u32 iMaster;\n  u32 szMaster;\n\n  /*\n  ** Array of lists of free blocks according to the block size \n  ** for smaller chunks, or a hash on the block size for larger\n  ** chunks.\n  */\n  u32 aiSmall[MX_SMALL-1];   /* For sizes 2 through MX_SMALL, inclusive */\n  u32 aiHash[N_HASH];        /* For sizes MX_SMALL+1 and larger */\n} mem3 = { 97535575 };\n\n#define mem3 GLOBAL(struct Mem3Global, mem3)\n\n/*\n** Unlink the chunk at mem3.aPool[i] from list it is currently\n** on.  *pRoot is the list that i is a member of.\n*/\nstatic void memsys3UnlinkFromList(u32 i, u32 *pRoot){\n  u32 next = mem3.aPool[i].u.list.next;\n  u32 prev = mem3.aPool[i].u.list.prev;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  if( prev==0 ){\n    *pRoot = next;\n  }else{\n    mem3.aPool[prev].u.list.next = next;\n  }\n  if( next ){\n    mem3.aPool[next].u.list.prev = prev;\n  }\n  mem3.aPool[i].u.list.next = 0;\n  mem3.aPool[i].u.list.prev = 0;\n}\n\n/*\n** Unlink the chunk at index i from \n** whatever list is currently a member of.\n*/\nstatic void memsys3Unlink(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  assert( i>=1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** Link the chunk at mem3.aPool[i] so that is on the list rooted\n** at *pRoot.\n*/\nstatic void memsys3LinkIntoList(u32 i, u32 *pRoot){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  mem3.aPool[i].u.list.next = *pRoot;\n  mem3.aPool[i].u.list.prev = 0;\n  if( *pRoot ){\n    mem3.aPool[*pRoot].u.list.prev = i;\n  }\n  *pRoot = i;\n}\n\n/*\n** Link the chunk at index i into either the appropriate\n** small chunk list, or into the large chunk hash table.\n*/\nstatic void memsys3Link(u32 i){\n  u32 size, hash;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );\n  assert( size>=2 );\n  if( size <= MX_SMALL ){\n    memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);\n  }else{\n    hash = size % N_HASH;\n    memsys3LinkIntoList(i, &mem3.aiHash[hash]);\n  }\n}\n\n/*\n** If the STATIC_MEM mutex is not already held, obtain it now. The mutex\n** will already be held (obtained by code in malloc.c) if\n** sqlite3GlobalConfig.bMemStat is true.\n*/\nstatic void memsys3Enter(void){\n  if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){\n    mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n  sqlite3_mutex_enter(mem3.mutex);\n}\nstatic void memsys3Leave(void){\n  sqlite3_mutex_leave(mem3.mutex);\n}\n\n/*\n** Called when we are unable to satisfy an allocation of nBytes.\n*/\nstatic void memsys3OutOfMemory(int nByte){\n  if( !mem3.alarmBusy ){\n    mem3.alarmBusy = 1;\n    assert( sqlite3_mutex_held(mem3.mutex) );\n    sqlite3_mutex_leave(mem3.mutex);\n    sqlite3_release_memory(nByte);\n    sqlite3_mutex_enter(mem3.mutex);\n    mem3.alarmBusy = 0;\n  }\n}\n\n\n/*\n** Chunk i is a free chunk that has been unlinked.  Adjust its \n** size parameters for check-out and return a pointer to the \n** user portion of the chunk.\n*/\nstatic void *memsys3Checkout(u32 i, u32 nBlock){\n  u32 x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( i>=1 );\n  assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock );\n  assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock );\n  x = mem3.aPool[i-1].u.hdr.size4x;\n  mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2);\n  mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock;\n  mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2;\n  return &mem3.aPool[i];\n}\n\n/*\n** Carve a piece off of the end of the mem3.iMaster free chunk.\n** Return a pointer to the new allocation.  Or, if the master chunk\n** is not large enough, return 0.\n*/\nstatic void *memsys3FromMaster(u32 nBlock){\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( mem3.szMaster>=nBlock );\n  if( nBlock>=mem3.szMaster-1 ){\n    /* Use the entire master */\n    void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster);\n    mem3.iMaster = 0;\n    mem3.szMaster = 0;\n    mem3.mnMaster = 0;\n    return p;\n  }else{\n    /* Split the master block.  Return the tail. */\n    u32 newi, x;\n    newi = mem3.iMaster + mem3.szMaster - nBlock;\n    assert( newi > mem3.iMaster+1 );\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock;\n    mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2;\n    mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1;\n    mem3.szMaster -= nBlock;\n    mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster;\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n    if( mem3.szMaster < mem3.mnMaster ){\n      mem3.mnMaster = mem3.szMaster;\n    }\n    return (void*)&mem3.aPool[newi];\n  }\n}\n\n/*\n** *pRoot is the head of a list of free chunks of the same size\n** or same size hash.  In other words, *pRoot is an entry in either\n** mem3.aiSmall[] or mem3.aiHash[].  \n**\n** This routine examines all entries on the given list and tries\n** to coalesce each entries with adjacent free chunks.  \n**\n** If it sees a chunk that is larger than mem3.iMaster, it replaces \n** the current mem3.iMaster with the new larger chunk.  In order for\n** this mem3.iMaster replacement to work, the master chunk must be\n** linked into the hash tables.  That is not the normal state of\n** affairs, of course.  The calling routine must link the master\n** chunk before invoking this routine, then must unlink the (possibly\n** changed) master chunk once this routine has finished.\n*/\nstatic void memsys3Merge(u32 *pRoot){\n  u32 iNext, prev, size, i, x;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  for(i=*pRoot; i>0; i=iNext){\n    iNext = mem3.aPool[i].u.list.next;\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    assert( (size&1)==0 );\n    if( (size&2)==0 ){\n      memsys3UnlinkFromList(i, pRoot);\n      assert( i > mem3.aPool[i-1].u.hdr.prevSize );\n      prev = i - mem3.aPool[i-1].u.hdr.prevSize;\n      if( prev==iNext ){\n        iNext = mem3.aPool[prev].u.list.next;\n      }\n      memsys3Unlink(prev);\n      size = i + size/4 - prev;\n      x = mem3.aPool[prev-1].u.hdr.size4x & 2;\n      mem3.aPool[prev-1].u.hdr.size4x = size*4 | x;\n      mem3.aPool[prev+size-1].u.hdr.prevSize = size;\n      memsys3Link(prev);\n      i = prev;\n    }else{\n      size /= 4;\n    }\n    if( size>mem3.szMaster ){\n      mem3.iMaster = i;\n      mem3.szMaster = size;\n    }\n  }\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void *memsys3MallocUnsafe(int nByte){\n  u32 i;\n  u32 nBlock;\n  u32 toFree;\n\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( sizeof(Mem3Block)==8 );\n  if( nByte<=12 ){\n    nBlock = 2;\n  }else{\n    nBlock = (nByte + 11)/8;\n  }\n  assert( nBlock>=2 );\n\n  /* STEP 1:\n  ** Look for an entry of the correct size in either the small\n  ** chunk table or in the large chunk hash table.  This is\n  ** successful most of the time (about 9 times out of 10).\n  */\n  if( nBlock <= MX_SMALL ){\n    i = mem3.aiSmall[nBlock-2];\n    if( i>0 ){\n      memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);\n      return memsys3Checkout(i, nBlock);\n    }\n  }else{\n    int hash = nBlock % N_HASH;\n    for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){\n      if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){\n        memsys3UnlinkFromList(i, &mem3.aiHash[hash]);\n        return memsys3Checkout(i, nBlock);\n      }\n    }\n  }\n\n  /* STEP 2:\n  ** Try to satisfy the allocation by carving a piece off of the end\n  ** of the master chunk.  This step usually works if step 1 fails.\n  */\n  if( mem3.szMaster>=nBlock ){\n    return memsys3FromMaster(nBlock);\n  }\n\n\n  /* STEP 3:  \n  ** Loop through the entire memory pool.  Coalesce adjacent free\n  ** chunks.  Recompute the master chunk as the largest free chunk.\n  ** Then try again to satisfy the allocation by carving a piece off\n  ** of the end of the master chunk.  This step happens very\n  ** rarely (we hope!)\n  */\n  for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){\n    memsys3OutOfMemory(toFree);\n    if( mem3.iMaster ){\n      memsys3Link(mem3.iMaster);\n      mem3.iMaster = 0;\n      mem3.szMaster = 0;\n    }\n    for(i=0; i<N_HASH; i++){\n      memsys3Merge(&mem3.aiHash[i]);\n    }\n    for(i=0; i<MX_SMALL-1; i++){\n      memsys3Merge(&mem3.aiSmall[i]);\n    }\n    if( mem3.szMaster ){\n      memsys3Unlink(mem3.iMaster);\n      if( mem3.szMaster>=nBlock ){\n        return memsys3FromMaster(nBlock);\n      }\n    }\n  }\n\n  /* If none of the above worked, then we fail. */\n  return 0;\n}\n\n/*\n** Free an outstanding memory allocation.\n**\n** This function assumes that the necessary mutexes, if any, are\n** already held by the caller. Hence \"Unsafe\".\n*/\nstatic void memsys3FreeUnsafe(void *pOld){\n  Mem3Block *p = (Mem3Block*)pOld;\n  int i;\n  u32 size, x;\n  assert( sqlite3_mutex_held(mem3.mutex) );\n  assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] );\n  i = p - mem3.aPool;\n  assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 );\n  size = mem3.aPool[i-1].u.hdr.size4x/4;\n  assert( i+size<=mem3.nPool+1 );\n  mem3.aPool[i-1].u.hdr.size4x &= ~1;\n  mem3.aPool[i+size-1].u.hdr.prevSize = size;\n  mem3.aPool[i+size-1].u.hdr.size4x &= ~2;\n  memsys3Link(i);\n\n  /* Try to expand the master using the newly freed chunk */\n  if( mem3.iMaster ){\n    while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){\n      size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize;\n      mem3.iMaster -= size;\n      mem3.szMaster += size;\n      memsys3Unlink(mem3.iMaster);\n      x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n    x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;\n    while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){\n      memsys3Unlink(mem3.iMaster+mem3.szMaster);\n      mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4;\n      mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;\n      mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;\n    }\n  }\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.  The\n** size returned omits the 8-byte header overhead.  This only\n** works for chunks that are currently checked out.\n*/\nstatic int memsys3Size(void *p){\n  Mem3Block *pBlock;\n  assert( p!=0 );\n  pBlock = (Mem3Block*)p;\n  assert( (pBlock[-1].u.hdr.size4x&1)!=0 );\n  return (pBlock[-1].u.hdr.size4x&~3)*2 - 4;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int memsys3Roundup(int n){\n  if( n<=12 ){\n    return 12;\n  }else{\n    return ((n+11)&~7) - 4;\n  }\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys3Malloc(int nBytes){\n  sqlite3_int64 *p;\n  assert( nBytes>0 );          /* malloc.c filters out 0 byte requests */\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  memsys3Leave();\n  return (void*)p; \n}\n\n/*\n** Free memory.\n*/\nstatic void memsys3Free(void *pPrior){\n  assert( pPrior );\n  memsys3Enter();\n  memsys3FreeUnsafe(pPrior);\n  memsys3Leave();\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *memsys3Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  if( pPrior==0 ){\n    return sqlite3_malloc(nBytes);\n  }\n  if( nBytes<=0 ){\n    sqlite3_free(pPrior);\n    return 0;\n  }\n  nOld = memsys3Size(pPrior);\n  if( nBytes<=nOld && nBytes>=nOld-128 ){\n    return pPrior;\n  }\n  memsys3Enter();\n  p = memsys3MallocUnsafe(nBytes);\n  if( p ){\n    if( nOld<nBytes ){\n      memcpy(p, pPrior, nOld);\n    }else{\n      memcpy(p, pPrior, nBytes);\n    }\n    memsys3FreeUnsafe(pPrior);\n  }\n  memsys3Leave();\n  return p;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int memsys3Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  if( !sqlite3GlobalConfig.pHeap ){\n    return SQLITE_ERROR;\n  }\n\n  /* Store a pointer to the memory block in global structure mem3. */\n  assert( sizeof(Mem3Block)==8 );\n  mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap;\n  mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2;\n\n  /* Initialize the master block. */\n  mem3.szMaster = mem3.nPool;\n  mem3.mnMaster = mem3.szMaster;\n  mem3.iMaster = 1;\n  mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2;\n  mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool;\n  mem3.aPool[mem3.nPool].u.hdr.size4x = 1;\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys3Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem3.mutex = 0;\n  return;\n}\n\n\n\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nvoid sqlite3Memsys3Dump(const char *zFilename){\n#ifdef SQLITE_DEBUG\n  FILE *out;\n  u32 i, j;\n  u32 size;\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys3Enter();\n  fprintf(out, \"CHUNKS:\\n\");\n  for(i=1; i<=mem3.nPool; i+=size/4){\n    size = mem3.aPool[i-1].u.hdr.size4x;\n    if( size/4<=1 ){\n      fprintf(out, \"%p size error\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){\n      fprintf(out, \"%p tail size does not match\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){\n      fprintf(out, \"%p tail checkout bit is incorrect\\n\", &mem3.aPool[i]);\n      assert( 0 );\n      break;\n    }\n    if( size&1 ){\n      fprintf(out, \"%p %6d bytes checked out\\n\", &mem3.aPool[i], (size/4)*8-8);\n    }else{\n      fprintf(out, \"%p %6d bytes free%s\\n\", &mem3.aPool[i], (size/4)*8-8,\n                  i==mem3.iMaster ? \" **master**\" : \"\");\n    }\n  }\n  for(i=0; i<MX_SMALL-1; i++){\n    if( mem3.aiSmall[i]==0 ) continue;\n    fprintf(out, \"small(%2d):\", i);\n    for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  for(i=0; i<N_HASH; i++){\n    if( mem3.aiHash[i]==0 ) continue;\n    fprintf(out, \"hash(%2d):\", i);\n    for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){\n      fprintf(out, \" %p(%d)\", &mem3.aPool[j],\n              (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);\n    }\n    fprintf(out, \"\\n\"); \n  }\n  fprintf(out, \"master=%d\\n\", mem3.iMaster);\n  fprintf(out, \"nowUsed=%d\\n\", mem3.nPool*8 - mem3.szMaster*8);\n  fprintf(out, \"mxUsed=%d\\n\", mem3.nPool*8 - mem3.mnMaster*8);\n  sqlite3_mutex_leave(mem3.mutex);\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n#else\n  UNUSED_PARAMETER(zFilename);\n#endif\n}\n\n/*\n** This routine is the only routine in this file with external \n** linkage.\n**\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nconst sqlite3_mem_methods *sqlite3MemGetMemsys3(void){\n  static const sqlite3_mem_methods mempoolMethods = {\n     memsys3Malloc,\n     memsys3Free,\n     memsys3Realloc,\n     memsys3Size,\n     memsys3Roundup,\n     memsys3Init,\n     memsys3Shutdown,\n     0\n  };\n  return &mempoolMethods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS3 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mem5.c",
    "content": "/*\n** 2007 October 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement a memory\n** allocation subsystem for use by SQLite. \n**\n** This version of the memory allocation subsystem omits all\n** use of malloc(). The application gives SQLite a block of memory\n** before calling sqlite3_initialize() from which allocations\n** are made and returned by the xMalloc() and xRealloc() \n** implementations. Once sqlite3_initialize() has been called,\n** the amount of memory available to SQLite is fixed and cannot\n** be changed.\n**\n** This version of the memory allocation subsystem is included\n** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.\n**\n** This memory allocator uses the following algorithm:\n**\n**   1.  All memory allocation sizes are rounded up to a power of 2.\n**\n**   2.  If two adjacent free blocks are the halves of a larger block,\n**       then the two blocks are coalesced into the single larger block.\n**\n**   3.  New memory is allocated from the first available free block.\n**\n** This algorithm is described in: J. M. Robson. \"Bounds for Some Functions\n** Concerning Dynamic Storage Allocation\". Journal of the Association for\n** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499.\n** \n** Let n be the size of the largest allocation divided by the minimum\n** allocation size (after rounding all sizes up to a power of 2.)  Let M\n** be the maximum amount of memory ever outstanding at one time.  Let\n** N be the total amount of memory available for allocation.  Robson\n** proved that this memory allocator will never breakdown due to \n** fragmentation as long as the following constraint holds:\n**\n**      N >=  M*(1 + log2(n)/2) - n + 1\n**\n** The sqlite3_status() logic tracks the maximum values of n and M so\n** that an application can, at any time, verify this constraint.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** This version of the memory allocator is used only when \n** SQLITE_ENABLE_MEMSYS5 is defined.\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\n\n/*\n** A minimum allocation is an instance of the following structure.\n** Larger allocations are an array of these structures where the\n** size of the array is a power of 2.\n**\n** The size of this object must be a power of two.  That fact is\n** verified in memsys5Init().\n*/\ntypedef struct Mem5Link Mem5Link;\nstruct Mem5Link {\n  int next;       /* Index of next free chunk */\n  int prev;       /* Index of previous free chunk */\n};\n\n/*\n** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since\n** mem5.szAtom is always at least 8 and 32-bit integers are used,\n** it is not actually possible to reach this limit.\n*/\n#define LOGMAX 30\n\n/*\n** Masks used for mem5.aCtrl[] elements.\n*/\n#define CTRL_LOGSIZE  0x1f    /* Log2 Size of this block */\n#define CTRL_FREE     0x20    /* True if not checked out */\n\n/*\n** All of the static variables used by this module are collected\n** into a single structure named \"mem5\".  This is to keep the\n** static variables organized and to reduce namespace pollution\n** when this module is combined with other in the amalgamation.\n*/\nstatic SQLITE_WSD struct Mem5Global {\n  /*\n  ** Memory available for allocation\n  */\n  int szAtom;      /* Smallest possible allocation in bytes */\n  int nBlock;      /* Number of szAtom sized blocks in zPool */\n  u8 *zPool;       /* Memory available to be allocated */\n  \n  /*\n  ** Mutex to control access to the memory allocation subsystem.\n  */\n  sqlite3_mutex *mutex;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Performance statistics\n  */\n  u64 nAlloc;         /* Total number of calls to malloc */\n  u64 totalAlloc;     /* Total of all malloc calls - includes internal frag */\n  u64 totalExcess;    /* Total internal fragmentation */\n  u32 currentOut;     /* Current checkout, including internal fragmentation */\n  u32 currentCount;   /* Current number of distinct checkouts */\n  u32 maxOut;         /* Maximum instantaneous currentOut */\n  u32 maxCount;       /* Maximum instantaneous currentCount */\n  u32 maxRequest;     /* Largest allocation (exclusive of internal frag) */\n#endif\n  \n  /*\n  ** Lists of free blocks.  aiFreelist[0] is a list of free blocks of\n  ** size mem5.szAtom.  aiFreelist[1] holds blocks of size szAtom*2.\n  ** aiFreelist[2] holds free blocks of size szAtom*4.  And so forth.\n  */\n  int aiFreelist[LOGMAX+1];\n\n  /*\n  ** Space for tracking which blocks are checked out and the size\n  ** of each block.  One byte per block.\n  */\n  u8 *aCtrl;\n\n} mem5;\n\n/*\n** Access the static variable through a macro for SQLITE_OMIT_WSD.\n*/\n#define mem5 GLOBAL(struct Mem5Global, mem5)\n\n/*\n** Assuming mem5.zPool is divided up into an array of Mem5Link\n** structures, return a pointer to the idx-th such link.\n*/\n#define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))\n\n/*\n** Unlink the chunk at mem5.aPool[i] from list it is currently\n** on.  It should be found on mem5.aiFreelist[iLogsize].\n*/\nstatic void memsys5Unlink(int i, int iLogsize){\n  int next, prev;\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  next = MEM5LINK(i)->next;\n  prev = MEM5LINK(i)->prev;\n  if( prev<0 ){\n    mem5.aiFreelist[iLogsize] = next;\n  }else{\n    MEM5LINK(prev)->next = next;\n  }\n  if( next>=0 ){\n    MEM5LINK(next)->prev = prev;\n  }\n}\n\n/*\n** Link the chunk at mem5.aPool[i] so that is on the iLogsize\n** free list.\n*/\nstatic void memsys5Link(int i, int iLogsize){\n  int x;\n  assert( sqlite3_mutex_held(mem5.mutex) );\n  assert( i>=0 && i<mem5.nBlock );\n  assert( iLogsize>=0 && iLogsize<=LOGMAX );\n  assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );\n\n  x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];\n  MEM5LINK(i)->prev = -1;\n  if( x>=0 ){\n    assert( x<mem5.nBlock );\n    MEM5LINK(x)->prev = i;\n  }\n  mem5.aiFreelist[iLogsize] = i;\n}\n\n/*\n** Obtain or release the mutex needed to access global data structures.\n*/\nstatic void memsys5Enter(void){\n  sqlite3_mutex_enter(mem5.mutex);\n}\nstatic void memsys5Leave(void){\n  sqlite3_mutex_leave(mem5.mutex);\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n** This only works for chunks that are currently checked out.\n*/\nstatic int memsys5Size(void *p){\n  int iSize, i;\n  assert( p!=0 );\n  i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);\n  assert( i>=0 && i<mem5.nBlock );\n  iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));\n  return iSize;\n}\n\n/*\n** Return a block of memory of at least nBytes in size.\n** Return NULL if unable.  Return NULL if nBytes==0.\n**\n** The caller guarantees that nByte is positive.\n**\n** The caller has obtained a mutex prior to invoking this\n** routine so there is never any chance that two or more\n** threads can be in this routine at the same time.\n*/\nstatic void *memsys5MallocUnsafe(int nByte){\n  int i;           /* Index of a mem5.aPool[] slot */\n  int iBin;        /* Index into mem5.aiFreelist[] */\n  int iFullSz;     /* Size of allocation rounded up to power of 2 */\n  int iLogsize;    /* Log2 of iFullSz/POW2_MIN */\n\n  /* nByte must be a positive */\n  assert( nByte>0 );\n\n  /* No more than 1GiB per allocation */\n  if( nByte > 0x40000000 ) return 0;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Keep track of the maximum allocation request.  Even unfulfilled\n  ** requests are counted */\n  if( (u32)nByte>mem5.maxRequest ){\n    mem5.maxRequest = nByte;\n  }\n#endif\n\n\n  /* Round nByte up to the next valid power of two */\n  for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}\n\n  /* Make sure mem5.aiFreelist[iLogsize] contains at least one free\n  ** block.  If not, then split a block of the next larger power of\n  ** two in order to create a new free block of size iLogsize.\n  */\n  for(iBin=iLogsize; iBin<=LOGMAX && mem5.aiFreelist[iBin]<0; iBin++){}\n  if( iBin>LOGMAX ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    sqlite3_log(SQLITE_NOMEM, \"failed to allocate %u bytes\", nByte);\n    return 0;\n  }\n  i = mem5.aiFreelist[iBin];\n  memsys5Unlink(i, iBin);\n  while( iBin>iLogsize ){\n    int newSize;\n\n    iBin--;\n    newSize = 1 << iBin;\n    mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;\n    memsys5Link(i+newSize, iBin);\n  }\n  mem5.aCtrl[i] = iLogsize;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /* Update allocator performance statistics. */\n  mem5.nAlloc++;\n  mem5.totalAlloc += iFullSz;\n  mem5.totalExcess += iFullSz - nByte;\n  mem5.currentCount++;\n  mem5.currentOut += iFullSz;\n  if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;\n  if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Make sure the allocated memory does not assume that it is set to zero\n  ** or retains a value from a previous allocation */\n  memset(&mem5.zPool[i*mem5.szAtom], 0xAA, iFullSz);\n#endif\n\n  /* Return a pointer to the allocated memory. */\n  return (void*)&mem5.zPool[i*mem5.szAtom];\n}\n\n/*\n** Free an outstanding memory allocation.\n*/\nstatic void memsys5FreeUnsafe(void *pOld){\n  u32 size, iLogsize;\n  int iBlock;\n\n  /* Set iBlock to the index of the block pointed to by pOld in \n  ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.\n  */\n  iBlock = (int)(((u8 *)pOld-mem5.zPool)/mem5.szAtom);\n\n  /* Check that the pointer pOld points to a valid, non-free block. */\n  assert( iBlock>=0 && iBlock<mem5.nBlock );\n  assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );\n  assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );\n\n  iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;\n  size = 1<<iLogsize;\n  assert( iBlock+size-1<(u32)mem5.nBlock );\n\n  mem5.aCtrl[iBlock] |= CTRL_FREE;\n  mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  assert( mem5.currentCount>0 );\n  assert( mem5.currentOut>=(size*mem5.szAtom) );\n  mem5.currentCount--;\n  mem5.currentOut -= size*mem5.szAtom;\n  assert( mem5.currentOut>0 || mem5.currentCount==0 );\n  assert( mem5.currentCount>0 || mem5.currentOut==0 );\n#endif\n\n  mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n  while( ALWAYS(iLogsize<LOGMAX) ){\n    int iBuddy;\n    if( (iBlock>>iLogsize) & 1 ){\n      iBuddy = iBlock - size;\n      assert( iBuddy>=0 );\n    }else{\n      iBuddy = iBlock + size;\n      if( iBuddy>=mem5.nBlock ) break;\n    }\n    if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;\n    memsys5Unlink(iBuddy, iLogsize);\n    iLogsize++;\n    if( iBuddy<iBlock ){\n      mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBlock] = 0;\n      iBlock = iBuddy;\n    }else{\n      mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;\n      mem5.aCtrl[iBuddy] = 0;\n    }\n    size *= 2;\n  }\n\n#ifdef SQLITE_DEBUG\n  /* Overwrite freed memory with the 0x55 bit pattern to verify that it is\n  ** not used after being freed */\n  memset(&mem5.zPool[iBlock*mem5.szAtom], 0x55, size);\n#endif\n\n  memsys5Link(iBlock, iLogsize);\n}\n\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *memsys5Malloc(int nBytes){\n  sqlite3_int64 *p = 0;\n  if( nBytes>0 ){\n    memsys5Enter();\n    p = memsys5MallocUnsafe(nBytes);\n    memsys5Leave();\n  }\n  return (void*)p; \n}\n\n/*\n** Free memory.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.\n*/\nstatic void memsys5Free(void *pPrior){\n  assert( pPrior!=0 );\n  memsys5Enter();\n  memsys5FreeUnsafe(pPrior);\n  memsys5Leave();  \n}\n\n/*\n** Change the size of an existing memory allocation.\n**\n** The outer layer memory allocator prevents this routine from\n** being called with pPrior==0.  \n**\n** nBytes is always a value obtained from a prior call to\n** memsys5Round().  Hence nBytes is always a non-negative power\n** of two.  If nBytes==0 that means that an oversize allocation\n** (an allocation larger than 0x40000000) was requested and this\n** routine should return 0 without freeing pPrior.\n*/\nstatic void *memsys5Realloc(void *pPrior, int nBytes){\n  int nOld;\n  void *p;\n  assert( pPrior!=0 );\n  assert( (nBytes&(nBytes-1))==0 );  /* EV: R-46199-30249 */\n  assert( nBytes>=0 );\n  if( nBytes==0 ){\n    return 0;\n  }\n  nOld = memsys5Size(pPrior);\n  if( nBytes<=nOld ){\n    return pPrior;\n  }\n  p = memsys5Malloc(nBytes);\n  if( p ){\n    memcpy(p, pPrior, nOld);\n    memsys5Free(pPrior);\n  }\n  return p;\n}\n\n/*\n** Round up a request size to the next valid allocation size.  If\n** the allocation is too large to be handled by this allocation system,\n** return 0.\n**\n** All allocations must be a power of two and must be expressed by a\n** 32-bit signed integer.  Hence the largest allocation is 0x40000000\n** or 1073741824 bytes.\n*/\nstatic int memsys5Roundup(int n){\n  int iFullSz;\n  if( n > 0x40000000 ) return 0;\n  for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);\n  return iFullSz;\n}\n\n/*\n** Return the ceiling of the logarithm base 2 of iValue.\n**\n** Examples:   memsys5Log(1) -> 0\n**             memsys5Log(2) -> 1\n**             memsys5Log(4) -> 2\n**             memsys5Log(5) -> 3\n**             memsys5Log(8) -> 3\n**             memsys5Log(9) -> 4\n*/\nstatic int memsys5Log(int iValue){\n  int iLog;\n  for(iLog=0; (iLog<(int)((sizeof(int)*8)-1)) && (1<<iLog)<iValue; iLog++);\n  return iLog;\n}\n\n/*\n** Initialize the memory allocator.\n**\n** This routine is not threadsafe.  The caller must be holding a mutex\n** to prevent multiple threads from entering at the same time.\n*/\nstatic int memsys5Init(void *NotUsed){\n  int ii;            /* Loop counter */\n  int nByte;         /* Number of bytes of memory available to this allocator */\n  u8 *zByte;         /* Memory usable by this allocator */\n  int nMinLog;       /* Log base 2 of minimum allocation size in bytes */\n  int iOffset;       /* An offset into mem5.aCtrl[] */\n\n  UNUSED_PARAMETER(NotUsed);\n\n  /* For the purposes of this routine, disable the mutex */\n  mem5.mutex = 0;\n\n  /* The size of a Mem5Link object must be a power of two.  Verify that\n  ** this is case.\n  */\n  assert( (sizeof(Mem5Link)&(sizeof(Mem5Link)-1))==0 );\n\n  nByte = sqlite3GlobalConfig.nHeap;\n  zByte = (u8*)sqlite3GlobalConfig.pHeap;\n  assert( zByte!=0 );  /* sqlite3_config() does not allow otherwise */\n\n  /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */\n  nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);\n  mem5.szAtom = (1<<nMinLog);\n  while( (int)sizeof(Mem5Link)>mem5.szAtom ){\n    mem5.szAtom = mem5.szAtom << 1;\n  }\n\n  mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));\n  mem5.zPool = zByte;\n  mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];\n\n  for(ii=0; ii<=LOGMAX; ii++){\n    mem5.aiFreelist[ii] = -1;\n  }\n\n  iOffset = 0;\n  for(ii=LOGMAX; ii>=0; ii--){\n    int nAlloc = (1<<ii);\n    if( (iOffset+nAlloc)<=mem5.nBlock ){\n      mem5.aCtrl[iOffset] = ii | CTRL_FREE;\n      memsys5Link(iOffset, ii);\n      iOffset += nAlloc;\n    }\n    assert((iOffset+nAlloc)>mem5.nBlock);\n  }\n\n  /* If a mutex is required for normal operation, allocate one */\n  if( sqlite3GlobalConfig.bMemstat==0 ){\n    mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void memsys5Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  mem5.mutex = 0;\n  return;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Open the file indicated and write a log of all unfreed memory \n** allocations into that log.\n*/\nvoid sqlite3Memsys5Dump(const char *zFilename){\n  FILE *out;\n  int i, j, n;\n  int nMinLog;\n\n  if( zFilename==0 || zFilename[0]==0 ){\n    out = stdout;\n  }else{\n    out = fopen(zFilename, \"w\");\n    if( out==0 ){\n      fprintf(stderr, \"** Unable to output memory debug output log: %s **\\n\",\n                      zFilename);\n      return;\n    }\n  }\n  memsys5Enter();\n  nMinLog = memsys5Log(mem5.szAtom);\n  for(i=0; i<=LOGMAX && i+nMinLog<32; i++){\n    for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}\n    fprintf(out, \"freelist items of size %d: %d\\n\", mem5.szAtom << i, n);\n  }\n  fprintf(out, \"mem5.nAlloc       = %llu\\n\", mem5.nAlloc);\n  fprintf(out, \"mem5.totalAlloc   = %llu\\n\", mem5.totalAlloc);\n  fprintf(out, \"mem5.totalExcess  = %llu\\n\", mem5.totalExcess);\n  fprintf(out, \"mem5.currentOut   = %u\\n\", mem5.currentOut);\n  fprintf(out, \"mem5.currentCount = %u\\n\", mem5.currentCount);\n  fprintf(out, \"mem5.maxOut       = %u\\n\", mem5.maxOut);\n  fprintf(out, \"mem5.maxCount     = %u\\n\", mem5.maxCount);\n  fprintf(out, \"mem5.maxRequest   = %u\\n\", mem5.maxRequest);\n  memsys5Leave();\n  if( out==stdout ){\n    fflush(stdout);\n  }else{\n    fclose(out);\n  }\n}\n#endif\n\n/*\n** This routine is the only routine in this file with external \n** linkage. It returns a pointer to a static sqlite3_mem_methods\n** struct populated with the memsys5 methods.\n*/\nconst sqlite3_mem_methods *sqlite3MemGetMemsys5(void){\n  static const sqlite3_mem_methods memsys5Methods = {\n     memsys5Malloc,\n     memsys5Free,\n     memsys5Realloc,\n     memsys5Size,\n     memsys5Roundup,\n     memsys5Init,\n     memsys5Shutdown,\n     0\n  };\n  return &memsys5Methods;\n}\n\n#endif /* SQLITE_ENABLE_MEMSYS5 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/memjournal.c",
    "content": "/*\n** 2008 October 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement an in-memory rollback journal.\n** The in-memory rollback journal is used to journal transactions for\n** \":memory:\" databases and when the journal_mode=MEMORY pragma is used.\n**\n** Update:  The in-memory journal is also used to temporarily cache\n** smaller journals that are not critical for power-loss recovery.\n** For example, statement journals that are not too big will be held\n** entirely in memory, thus reducing the number of file I/O calls, and\n** more importantly, reducing temporary file creation events.  If these\n** journals become too large for memory, they are spilled to disk.  But\n** in the common case, they are usually small and no file I/O needs to\n** occur.\n*/\n#include \"sqliteInt.h\"\n\n/* Forward references to internal structures */\ntypedef struct MemJournal MemJournal;\ntypedef struct FilePoint FilePoint;\ntypedef struct FileChunk FileChunk;\n\n/*\n** The rollback journal is composed of a linked list of these structures.\n**\n** The zChunk array is always at least 8 bytes in size - usually much more.\n** Its actual size is stored in the MemJournal.nChunkSize variable.\n*/\nstruct FileChunk {\n  FileChunk *pNext;               /* Next chunk in the journal */\n  u8 zChunk[8];                   /* Content of this chunk */\n};\n\n/*\n** By default, allocate this many bytes of memory for each FileChunk object.\n*/\n#define MEMJOURNAL_DFLT_FILECHUNKSIZE 1024\n\n/*\n** For chunk size nChunkSize, return the number of bytes that should\n** be allocated for each FileChunk structure.\n*/\n#define fileChunkSize(nChunkSize) (sizeof(FileChunk) + ((nChunkSize)-8))\n\n/*\n** An instance of this object serves as a cursor into the rollback journal.\n** The cursor can be either for reading or writing.\n*/\nstruct FilePoint {\n  sqlite3_int64 iOffset;          /* Offset from the beginning of the file */\n  FileChunk *pChunk;              /* Specific chunk into which cursor points */\n};\n\n/*\n** This structure is a subclass of sqlite3_file. Each open memory-journal\n** is an instance of this class.\n*/\nstruct MemJournal {\n  const sqlite3_io_methods *pMethod; /* Parent class. MUST BE FIRST */\n  int nChunkSize;                 /* In-memory chunk-size */\n\n  int nSpill;                     /* Bytes of data before flushing */\n  int nSize;                      /* Bytes of data currently in memory */\n  FileChunk *pFirst;              /* Head of in-memory chunk-list */\n  FilePoint endpoint;             /* Pointer to the end of the file */\n  FilePoint readpoint;            /* Pointer to the end of the last xRead() */\n\n  int flags;                      /* xOpen flags */\n  sqlite3_vfs *pVfs;              /* The \"real\" underlying VFS */\n  const char *zJournal;           /* Name of the journal file */\n};\n\n/*\n** Read data from the in-memory journal file.  This is the implementation\n** of the sqlite3_vfs.xRead method.\n*/\nstatic int memjrnlRead(\n  sqlite3_file *pJfd,    /* The journal file from which to read */\n  void *zBuf,            /* Put the results here */\n  int iAmt,              /* Number of bytes to read */\n  sqlite_int64 iOfst     /* Begin reading at this offset */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  u8 *zOut = zBuf;\n  int nRead = iAmt;\n  int iChunkOffset;\n  FileChunk *pChunk;\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  if( (iAmt+iOfst)>p->endpoint.iOffset ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n#endif\n\n  assert( (iAmt+iOfst)<=p->endpoint.iOffset );\n  assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );\n  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){\n    sqlite3_int64 iOff = 0;\n    for(pChunk=p->pFirst; \n        ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;\n        pChunk=pChunk->pNext\n    ){\n      iOff += p->nChunkSize;\n    }\n  }else{\n    pChunk = p->readpoint.pChunk;\n    assert( pChunk!=0 );\n  }\n\n  iChunkOffset = (int)(iOfst%p->nChunkSize);\n  do {\n    int iSpace = p->nChunkSize - iChunkOffset;\n    int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));\n    memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);\n    zOut += nCopy;\n    nRead -= iSpace;\n    iChunkOffset = 0;\n  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );\n  p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;\n  p->readpoint.pChunk = pChunk;\n\n  return SQLITE_OK;\n}\n\n/*\n** Free the list of FileChunk structures headed at MemJournal.pFirst.\n*/\nstatic void memjrnlFreeChunks(MemJournal *p){\n  FileChunk *pIter;\n  FileChunk *pNext;\n  for(pIter=p->pFirst; pIter; pIter=pNext){\n    pNext = pIter->pNext;\n    sqlite3_free(pIter);\n  } \n  p->pFirst = 0;\n}\n\n/*\n** Flush the contents of memory to a real file on disk.\n*/\nstatic int memjrnlCreateFile(MemJournal *p){\n  int rc;\n  sqlite3_file *pReal = (sqlite3_file*)p;\n  MemJournal copy = *p;\n\n  memset(p, 0, sizeof(MemJournal));\n  rc = sqlite3OsOpen(copy.pVfs, copy.zJournal, pReal, copy.flags, 0);\n  if( rc==SQLITE_OK ){\n    int nChunk = copy.nChunkSize;\n    i64 iOff = 0;\n    FileChunk *pIter;\n    for(pIter=copy.pFirst; pIter; pIter=pIter->pNext){\n      if( iOff + nChunk > copy.endpoint.iOffset ){\n        nChunk = copy.endpoint.iOffset - iOff;\n      }\n      rc = sqlite3OsWrite(pReal, (u8*)pIter->zChunk, nChunk, iOff);\n      if( rc ) break;\n      iOff += nChunk;\n    }\n    if( rc==SQLITE_OK ){\n      /* No error has occurred. Free the in-memory buffers. */\n      memjrnlFreeChunks(&copy);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    /* If an error occurred while creating or writing to the file, restore\n    ** the original before returning. This way, SQLite uses the in-memory\n    ** journal data to roll back changes made to the internal page-cache\n    ** before this function was called.  */\n    sqlite3OsClose(pReal);\n    *p = copy;\n  }\n  return rc;\n}\n\n\n/*\n** Write data to the file.\n*/\nstatic int memjrnlWrite(\n  sqlite3_file *pJfd,    /* The journal file into which to write */\n  const void *zBuf,      /* Take data to be written from here */\n  int iAmt,              /* Number of bytes to write */\n  sqlite_int64 iOfst     /* Begin writing at this offset into the file */\n){\n  MemJournal *p = (MemJournal *)pJfd;\n  int nWrite = iAmt;\n  u8 *zWrite = (u8 *)zBuf;\n\n  /* If the file should be created now, create it and write the new data\n  ** into the file on disk. */\n  if( p->nSpill>0 && (iAmt+iOfst)>p->nSpill ){\n    int rc = memjrnlCreateFile(p);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsWrite(pJfd, zBuf, iAmt, iOfst);\n    }\n    return rc;\n  }\n\n  /* If the contents of this write should be stored in memory */\n  else{\n    /* An in-memory journal file should only ever be appended to. Random\n    ** access writes are not required. The only exception to this is when\n    ** the in-memory journal is being used by a connection using the\n    ** atomic-write optimization. In this case the first 28 bytes of the\n    ** journal file may be written as part of committing the transaction. */ \n    assert( iOfst==p->endpoint.iOffset || iOfst==0 );\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    if( iOfst==0 && p->pFirst ){\n      assert( p->nChunkSize>iAmt );\n      memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);\n    }else\n#else\n    assert( iOfst>0 || p->pFirst==0 );\n#endif\n    {\n      while( nWrite>0 ){\n        FileChunk *pChunk = p->endpoint.pChunk;\n        int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);\n        int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);\n\n        if( iChunkOffset==0 ){\n          /* New chunk is required to extend the file. */\n          FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));\n          if( !pNew ){\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          pNew->pNext = 0;\n          if( pChunk ){\n            assert( p->pFirst );\n            pChunk->pNext = pNew;\n          }else{\n            assert( !p->pFirst );\n            p->pFirst = pNew;\n          }\n          p->endpoint.pChunk = pNew;\n        }\n\n        memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);\n        zWrite += iSpace;\n        nWrite -= iSpace;\n        p->endpoint.iOffset += iSpace;\n      }\n      p->nSize = iAmt + iOfst;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Truncate the file.\n**\n** If the journal file is already on disk, truncate it there. Or, if it\n** is still in main memory but is being truncated to zero bytes in size,\n** ignore \n*/\nstatic int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){\n  MemJournal *p = (MemJournal *)pJfd;\n  if( ALWAYS(size==0) ){\n    memjrnlFreeChunks(p);\n    p->nSize = 0;\n    p->endpoint.pChunk = 0;\n    p->endpoint.iOffset = 0;\n    p->readpoint.pChunk = 0;\n    p->readpoint.iOffset = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int memjrnlClose(sqlite3_file *pJfd){\n  MemJournal *p = (MemJournal *)pJfd;\n  memjrnlFreeChunks(p);\n  return SQLITE_OK;\n}\n\n/*\n** Sync the file.\n**\n** If the real file has been created, call its xSync method. Otherwise, \n** syncing an in-memory journal is a no-op. \n*/\nstatic int memjrnlSync(sqlite3_file *pJfd, int flags){\n  UNUSED_PARAMETER2(pJfd, flags);\n  return SQLITE_OK;\n}\n\n/*\n** Query the size of the file in bytes.\n*/\nstatic int memjrnlFileSize(sqlite3_file *pJfd, sqlite_int64 *pSize){\n  MemJournal *p = (MemJournal *)pJfd;\n  *pSize = (sqlite_int64) p->endpoint.iOffset;\n  return SQLITE_OK;\n}\n\n/*\n** Table of methods for MemJournal sqlite3_file object.\n*/\nstatic const struct sqlite3_io_methods MemJournalMethods = {\n  1,                /* iVersion */\n  memjrnlClose,     /* xClose */\n  memjrnlRead,      /* xRead */\n  memjrnlWrite,     /* xWrite */\n  memjrnlTruncate,  /* xTruncate */\n  memjrnlSync,      /* xSync */\n  memjrnlFileSize,  /* xFileSize */\n  0,                /* xLock */\n  0,                /* xUnlock */\n  0,                /* xCheckReservedLock */\n  0,                /* xFileControl */\n  0,                /* xSectorSize */\n  0,                /* xDeviceCharacteristics */\n  0,                /* xShmMap */\n  0,                /* xShmLock */\n  0,                /* xShmBarrier */\n  0,                /* xShmUnmap */\n  0,                /* xFetch */\n  0                 /* xUnfetch */\n};\n\n/* \n** Open a journal file. \n**\n** The behaviour of the journal file depends on the value of parameter \n** nSpill. If nSpill is 0, then the journal file is always create and \n** accessed using the underlying VFS. If nSpill is less than zero, then\n** all content is always stored in main-memory. Finally, if nSpill is a\n** positive value, then the journal file is initially created in-memory\n** but may be flushed to disk later on. In this case the journal file is\n** flushed to disk either when it grows larger than nSpill bytes in size,\n** or when sqlite3JournalCreate() is called.\n*/\nint sqlite3JournalOpen(\n  sqlite3_vfs *pVfs,         /* The VFS to use for actual file I/O */\n  const char *zName,         /* Name of the journal file */\n  sqlite3_file *pJfd,        /* Preallocated, blank file handle */\n  int flags,                 /* Opening flags */\n  int nSpill                 /* Bytes buffered before opening the file */\n){\n  MemJournal *p = (MemJournal*)pJfd;\n\n  /* Zero the file-handle object. If nSpill was passed zero, initialize\n  ** it using the sqlite3OsOpen() function of the underlying VFS. In this\n  ** case none of the code in this module is executed as a result of calls\n  ** made on the journal file-handle.  */\n  memset(p, 0, sizeof(MemJournal));\n  if( nSpill==0 ){\n    return sqlite3OsOpen(pVfs, zName, pJfd, flags, 0);\n  }\n\n  if( nSpill>0 ){\n    p->nChunkSize = nSpill;\n  }else{\n    p->nChunkSize = 8 + MEMJOURNAL_DFLT_FILECHUNKSIZE - sizeof(FileChunk);\n    assert( MEMJOURNAL_DFLT_FILECHUNKSIZE==fileChunkSize(p->nChunkSize) );\n  }\n\n  p->pMethod = (const sqlite3_io_methods*)&MemJournalMethods;\n  p->nSpill = nSpill;\n  p->flags = flags;\n  p->zJournal = zName;\n  p->pVfs = pVfs;\n  return SQLITE_OK;\n}\n\n/*\n** Open an in-memory journal file.\n*/\nvoid sqlite3MemJournalOpen(sqlite3_file *pJfd){\n  sqlite3JournalOpen(0, 0, pJfd, 0, -1);\n}\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n/*\n** If the argument p points to a MemJournal structure that is not an \n** in-memory-only journal file (i.e. is one that was opened with a +ve\n** nSpill parameter or as SQLITE_OPEN_MAIN_JOURNAL), and the underlying \n** file has not yet been created, create it now.\n*/\nint sqlite3JournalCreate(sqlite3_file *pJfd){\n  int rc = SQLITE_OK;\n  MemJournal *p = (MemJournal*)pJfd;\n  if( p->pMethod==&MemJournalMethods && (\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n     p->nSpill>0\n#else\n     /* While this appears to not be possible without ATOMIC_WRITE, the\n     ** paths are complex, so it seems prudent to leave the test in as\n     ** a NEVER(), in case our analysis is subtly flawed. */\n     NEVER(p->nSpill>0)\n#endif\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n     || (p->flags & SQLITE_OPEN_MAIN_JOURNAL)\n#endif\n  )){\n    rc = memjrnlCreateFile(p);\n  }\n  return rc;\n}\n#endif\n\n/*\n** The file-handle passed as the only argument is open on a journal file.\n** Return true if this \"journal file\" is currently stored in heap memory,\n** or false otherwise.\n*/\nint sqlite3JournalIsInMemory(sqlite3_file *p){\n  return p->pMethods==&MemJournalMethods;\n}\n\n/* \n** Return the number of bytes required to store a JournalFile that uses vfs\n** pVfs to create the underlying on-disk files.\n*/\nint sqlite3JournalSize(sqlite3_vfs *pVfs){\n  return MAX(pVfs->szOsFile, (int)sizeof(MemJournal));\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/msvc.h",
    "content": "/*\n** 2015 January 12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to MSVC.\n*/\n#ifndef SQLITE_MSVC_H\n#define SQLITE_MSVC_H\n\n#if defined(_MSC_VER)\n#pragma warning(disable : 4054)\n#pragma warning(disable : 4055)\n#pragma warning(disable : 4100)\n#pragma warning(disable : 4127)\n#pragma warning(disable : 4130)\n#pragma warning(disable : 4152)\n#pragma warning(disable : 4189)\n#pragma warning(disable : 4206)\n#pragma warning(disable : 4210)\n#pragma warning(disable : 4232)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 4306)\n#pragma warning(disable : 4702)\n#pragma warning(disable : 4706)\n#endif /* defined(_MSC_VER) */\n\n#endif /* SQLITE_MSVC_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mutex.c",
    "content": "/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This file contains code that is common across all mutex implementations.\n*/\n#include \"sqliteInt.h\"\n\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_MUTEX_OMIT)\n/*\n** For debugging purposes, record when the mutex subsystem is initialized\n** and uninitialized so that we can assert() if there is an attempt to\n** allocate a mutex while the system is uninitialized.\n*/\nstatic SQLITE_WSD int mutexIsInit = 0;\n#endif /* SQLITE_DEBUG && !defined(SQLITE_MUTEX_OMIT) */\n\n\n#ifndef SQLITE_MUTEX_OMIT\n/*\n** Initialize the mutex system.\n*/\nint sqlite3MutexInit(void){ \n  int rc = SQLITE_OK;\n  if( !sqlite3GlobalConfig.mutex.xMutexAlloc ){\n    /* If the xMutexAlloc method has not been set, then the user did not\n    ** install a mutex implementation via sqlite3_config() prior to \n    ** sqlite3_initialize() being called. This block copies pointers to\n    ** the default implementation into the sqlite3GlobalConfig structure.\n    */\n    sqlite3_mutex_methods const *pFrom;\n    sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pFrom = sqlite3DefaultMutex();\n    }else{\n      pFrom = sqlite3NoopMutex();\n    }\n    pTo->xMutexInit = pFrom->xMutexInit;\n    pTo->xMutexEnd = pFrom->xMutexEnd;\n    pTo->xMutexFree = pFrom->xMutexFree;\n    pTo->xMutexEnter = pFrom->xMutexEnter;\n    pTo->xMutexTry = pFrom->xMutexTry;\n    pTo->xMutexLeave = pFrom->xMutexLeave;\n    pTo->xMutexHeld = pFrom->xMutexHeld;\n    pTo->xMutexNotheld = pFrom->xMutexNotheld;\n    sqlite3MemoryBarrier();\n    pTo->xMutexAlloc = pFrom->xMutexAlloc;\n  }\n  assert( sqlite3GlobalConfig.mutex.xMutexInit );\n  rc = sqlite3GlobalConfig.mutex.xMutexInit();\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 1;\n#endif\n\n  return rc;\n}\n\n/*\n** Shutdown the mutex system. This call frees resources allocated by\n** sqlite3MutexInit().\n*/\nint sqlite3MutexEnd(void){\n  int rc = SQLITE_OK;\n  if( sqlite3GlobalConfig.mutex.xMutexEnd ){\n    rc = sqlite3GlobalConfig.mutex.xMutexEnd();\n  }\n\n#ifdef SQLITE_DEBUG\n  GLOBAL(int, mutexIsInit) = 0;\n#endif\n\n  return rc;\n}\n\n/*\n** Retrieve a pointer to a static mutex or allocate a new dynamic one.\n*/\nsqlite3_mutex *sqlite3_mutex_alloc(int id){\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;\n  if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;\n#endif\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\nsqlite3_mutex *sqlite3MutexAlloc(int id){\n  if( !sqlite3GlobalConfig.bCoreMutex ){\n    return 0;\n  }\n  assert( GLOBAL(int, mutexIsInit) );\n  assert( sqlite3GlobalConfig.mutex.xMutexAlloc );\n  return sqlite3GlobalConfig.mutex.xMutexAlloc(id);\n}\n\n/*\n** Free a dynamic mutex.\n*/\nvoid sqlite3_mutex_free(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexFree );\n    sqlite3GlobalConfig.mutex.xMutexFree(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If some other thread already has the mutex, block\n** until it can be obtained.\n*/\nvoid sqlite3_mutex_enter(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexEnter );\n    sqlite3GlobalConfig.mutex.xMutexEnter(p);\n  }\n}\n\n/*\n** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another\n** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.\n*/\nint sqlite3_mutex_try(sqlite3_mutex *p){\n  int rc = SQLITE_OK;\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexTry );\n    return sqlite3GlobalConfig.mutex.xMutexTry(p);\n  }\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was previously\n** entered by the same thread.  The behavior is undefined if the mutex \n** is not currently entered. If a NULL pointer is passed as an argument\n** this function is a no-op.\n*/\nvoid sqlite3_mutex_leave(sqlite3_mutex *p){\n  if( p ){\n    assert( sqlite3GlobalConfig.mutex.xMutexLeave );\n    sqlite3GlobalConfig.mutex.xMutexLeave(p);\n  }\n}\n\n#ifndef NDEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nint sqlite3_mutex_held(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexHeld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);\n}\nint sqlite3_mutex_notheld(sqlite3_mutex *p){\n  assert( p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld );\n  return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);\n}\n#endif\n\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mutex.h",
    "content": "/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the common header for all mutex implementations.\n** The sqliteInt.h header #includes this file so that it is available\n** to all source files.  We break it out in an effort to keep the code\n** better organized.\n**\n** NOTE:  source files should *not* #include this header file directly.\n** Source files should #include the sqliteInt.h file and let that file\n** include this one indirectly.\n*/\n\n\n/*\n** Figure out what version of the code to use.  The choices are\n**\n**   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The\n**                             mutexes implementation cannot be overridden\n**                             at start-time.\n**\n**   SQLITE_MUTEX_NOOP         For single-threaded applications.  No\n**                             mutual exclusion is provided.  But this\n**                             implementation can be overridden at\n**                             start-time.\n**\n**   SQLITE_MUTEX_PTHREADS     For multi-threaded applications on Unix.\n**\n**   SQLITE_MUTEX_W32          For multi-threaded applications on Win32.\n*/\n#if !SQLITE_THREADSAFE\n# define SQLITE_MUTEX_OMIT\n#endif\n#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP)\n#  if SQLITE_OS_UNIX\n#    define SQLITE_MUTEX_PTHREADS\n#  elif SQLITE_OS_WIN\n#    define SQLITE_MUTEX_W32\n#  else\n#    define SQLITE_MUTEX_NOOP\n#  endif\n#endif\n\n#ifdef SQLITE_MUTEX_OMIT\n/*\n** If this is a no-op implementation, implement everything as macros.\n*/\n#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)\n#define sqlite3_mutex_free(X)\n#define sqlite3_mutex_enter(X)    \n#define sqlite3_mutex_try(X)      SQLITE_OK\n#define sqlite3_mutex_leave(X)    \n#define sqlite3_mutex_held(X)     ((void)(X),1)\n#define sqlite3_mutex_notheld(X)  ((void)(X),1)\n#define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)\n#define sqlite3MutexInit()        SQLITE_OK\n#define sqlite3MutexEnd()\n#define MUTEX_LOGIC(X)\n#else\n#define MUTEX_LOGIC(X)            X\n#endif /* defined(SQLITE_MUTEX_OMIT) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mutex_noop.c",
    "content": "/*\n** 2008 October 07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes.\n**\n** This implementation in this file does not provide any mutual\n** exclusion and is thus suitable for use only in applications\n** that use SQLite in a single thread.  The routines defined\n** here are place-holders.  Applications can substitute working\n** mutex routines at start-time using the\n**\n**     sqlite3_config(SQLITE_CONFIG_MUTEX,...)\n**\n** interface.\n**\n** If compiled with SQLITE_DEBUG, then additional logic is inserted\n** that does error checking on mutexes to make sure they are being\n** called correctly.\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_MUTEX_OMIT\n\n#ifndef SQLITE_DEBUG\n/*\n** Stub routines for all mutex methods.\n**\n** This routines provide no mutual exclusion or error checking.\n*/\nstatic int noopMutexInit(void){ return SQLITE_OK; }\nstatic int noopMutexEnd(void){ return SQLITE_OK; }\nstatic sqlite3_mutex *noopMutexAlloc(int id){ \n  UNUSED_PARAMETER(id);\n  return (sqlite3_mutex*)8; \n}\nstatic void noopMutexFree(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic void noopMutexEnter(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\nstatic int noopMutexTry(sqlite3_mutex *p){\n  UNUSED_PARAMETER(p);\n  return SQLITE_OK;\n}\nstatic void noopMutexLeave(sqlite3_mutex *p){ UNUSED_PARAMETER(p); return; }\n\nsqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    noopMutexInit,\n    noopMutexEnd,\n    noopMutexAlloc,\n    noopMutexFree,\n    noopMutexEnter,\n    noopMutexTry,\n    noopMutexLeave,\n\n    0,\n    0,\n  };\n\n  return &sMutex;\n}\n#endif /* !SQLITE_DEBUG */\n\n#ifdef SQLITE_DEBUG\n/*\n** In this implementation, error checking is provided for testing\n** and debugging purposes.  The mutexes still do not provide any\n** mutual exclusion.\n*/\n\n/*\n** The mutex object\n*/\ntypedef struct sqlite3_debug_mutex {\n  int id;     /* The mutex type */\n  int cnt;    /* Number of entries without a matching leave */\n} sqlite3_debug_mutex;\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use inside assert() statements.\n*/\nstatic int debugMutexHeld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt>0;\n}\nstatic int debugMutexNotheld(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  return p==0 || p->cnt==0;\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int debugMutexInit(void){ return SQLITE_OK; }\nstatic int debugMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated. \n*/\nstatic sqlite3_mutex *debugMutexAlloc(int id){\n  static sqlite3_debug_mutex aStatic[SQLITE_MUTEX_STATIC_VFS3 - 1];\n  sqlite3_debug_mutex *pNew = 0;\n  switch( id ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      pNew = sqlite3Malloc(sizeof(*pNew));\n      if( pNew ){\n        pNew->id = id;\n        pNew->cnt = 0;\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( id-2<0 || id-2>=ArraySize(aStatic) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      pNew = &aStatic[id-2];\n      pNew->id = id;\n      break;\n    }\n  }\n  return (sqlite3_mutex*)pNew;\n}\n\n/*\n** This routine deallocates a previously allocated mutex.\n*/\nstatic void debugMutexFree(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->cnt==0 );\n  if( p->id==SQLITE_MUTEX_RECURSIVE || p->id==SQLITE_MUTEX_FAST ){\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void debugMutexEnter(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n}\nstatic int debugMutexTry(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n  p->cnt++;\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void debugMutexLeave(sqlite3_mutex *pX){\n  sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;\n  assert( debugMutexHeld(pX) );\n  p->cnt--;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || debugMutexNotheld(pX) );\n}\n\nsqlite3_mutex_methods const *sqlite3NoopMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    debugMutexInit,\n    debugMutexEnd,\n    debugMutexAlloc,\n    debugMutexFree,\n    debugMutexEnter,\n    debugMutexTry,\n    debugMutexLeave,\n\n    debugMutexHeld,\n    debugMutexNotheld\n  };\n\n  return &sMutex;\n}\n#endif /* SQLITE_DEBUG */\n\n/*\n** If compiled with SQLITE_MUTEX_NOOP, then the no-op mutex implementation\n** is used regardless of the run-time threadsafety setting.\n*/\n#ifdef SQLITE_MUTEX_NOOP\nsqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  return sqlite3NoopMutex();\n}\n#endif /* defined(SQLITE_MUTEX_NOOP) */\n#endif /* !defined(SQLITE_MUTEX_OMIT) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mutex_unix.c",
    "content": "/*\n** 2007 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for pthreads\n*/\n#include \"sqliteInt.h\"\n\n/*\n** The code in this file is only used if we are compiling threadsafe\n** under unix with pthreads.\n**\n** Note that this implementation requires a version of pthreads that\n** supports recursive mutexes.\n*/\n#ifdef SQLITE_MUTEX_PTHREADS\n\n#include <pthread.h>\n\n/*\n** The sqlite3_mutex.id, sqlite3_mutex.nRef, and sqlite3_mutex.owner fields\n** are necessary under two condidtions:  (1) Debug builds and (2) using\n** home-grown mutexes.  Encapsulate these conditions into a single #define.\n*/\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HOMEGROWN_RECURSIVE_MUTEX)\n# define SQLITE_MUTEX_NREF 1\n#else\n# define SQLITE_MUTEX_NREF 0\n#endif\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  pthread_mutex_t mutex;     /* Mutex controlling the lock */\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  int id;                    /* Mutex type */\n#endif\n#if SQLITE_MUTEX_NREF\n  volatile int nRef;         /* Number of entrances */\n  volatile pthread_t owner;  /* Thread that is within this mutex */\n  int trace;                 /* True to trace changes */\n#endif\n};\n#if SQLITE_MUTEX_NREF\n#define SQLITE3_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER,0,0,(pthread_t)0,0}\n#elif defined(SQLITE_ENABLE_API_ARMOR)\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }\n#endif\n\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.  On some platforms,\n** there might be race conditions that can cause these routines to\n** deliver incorrect results.  In particular, if pthread_equal() is\n** not an atomic operation, then these routines might delivery\n** incorrect results.  On most platforms, pthread_equal() is a \n** comparison of two integers and is therefore atomic.  But we are\n** told that HPUX is not such a platform.  If so, then these routines\n** will not always work correctly on HPUX.\n**\n** On those platforms where pthread_equal() is not atomic, SQLite\n** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to\n** make sure no assert() statements are evaluated and hence these\n** routines are never called.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_DEBUG)\nstatic int pthreadMutexHeld(sqlite3_mutex *p){\n  return (p->nRef!=0 && pthread_equal(p->owner, pthread_self()));\n}\nstatic int pthreadMutexNotheld(sqlite3_mutex *p){\n  return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0;\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the implementation of xShmBarrier in the VFS in cases\n** where SQLite is compiled without mutexes.\n*/\nvoid sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__) && GCC_VERSION>=4001000\n  __sync_synchronize();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic int pthreadMutexInit(void){ return SQLITE_OK; }\nstatic int pthreadMutexEnd(void){ return SQLITE_OK; }\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static \n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *pthreadMutexAlloc(int iType){\n  static sqlite3_mutex staticMutexes[] = {\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER,\n    SQLITE3_MUTEX_INITIALIZER\n  };\n  sqlite3_mutex *p;\n  switch( iType ){\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n        /* If recursive mutexes are not available, we will have to\n        ** build our own.  See below. */\n        pthread_mutex_init(&p->mutex, 0);\n#else\n        /* Use a recursive mutex if it is available */\n        pthread_mutexattr_t recursiveAttr;\n        pthread_mutexattr_init(&recursiveAttr);\n        pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);\n        pthread_mutex_init(&p->mutex, &recursiveAttr);\n        pthread_mutexattr_destroy(&recursiveAttr);\n#endif\n      }\n      break;\n    }\n    case SQLITE_MUTEX_FAST: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        pthread_mutex_init(&p->mutex, 0);\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &staticMutexes[iType-2];\n      break;\n    }\n  }\n#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)\n  if( p ) p->id = iType;\n#endif\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void pthreadMutexFree(sqlite3_mutex *p){\n  assert( p->nRef==0 );\n#if SQLITE_ENABLE_API_ARMOR\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE )\n#endif\n  {\n    pthread_mutex_destroy(&p->mutex);\n    sqlite3_free(p);\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  else{\n    (void)SQLITE_MISUSE_BKPT;\n  }\n#endif\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void pthreadMutexEnter(sqlite3_mutex *p){\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n    }else{\n      pthread_mutex_lock(&p->mutex);\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  pthread_mutex_lock(&p->mutex);\n#if SQLITE_MUTEX_NREF\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = pthread_self();\n  p->nRef++;\n#endif\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\nstatic int pthreadMutexTry(sqlite3_mutex *p){\n  int rc;\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  /* If recursive mutexes are not available, then we have to grow\n  ** our own.  This implementation assumes that pthread_equal()\n  ** is atomic - that it cannot be deceived into thinking self\n  ** and p->owner are equal if p->owner changes between two values\n  ** that are not equal to self while the comparison is taking place.\n  ** This implementation also assumes a coherent cache - that \n  ** separate processes cannot read different values from the same\n  ** address at the same time.  If either of these two conditions\n  ** are not met, then the mutexes will fail and problems will result.\n  */\n  {\n    pthread_t self = pthread_self();\n    if( p->nRef>0 && pthread_equal(p->owner, self) ){\n      p->nRef++;\n      rc = SQLITE_OK;\n    }else if( pthread_mutex_trylock(&p->mutex)==0 ){\n      assert( p->nRef==0 );\n      p->owner = self;\n      p->nRef = 1;\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_BUSY;\n    }\n  }\n#else\n  /* Use the built-in recursive mutexes if they are available.\n  */\n  if( pthread_mutex_trylock(&p->mutex)==0 ){\n#if SQLITE_MUTEX_NREF\n    p->owner = pthread_self();\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }else{\n    rc = SQLITE_BUSY;\n  }\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( rc==SQLITE_OK && p->trace ){\n    printf(\"enter mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void pthreadMutexLeave(sqlite3_mutex *p){\n  assert( pthreadMutexHeld(p) );\n#if SQLITE_MUTEX_NREF\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n#endif\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n\n#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX\n  if( p->nRef==0 ){\n    pthread_mutex_unlock(&p->mutex);\n  }\n#else\n  pthread_mutex_unlock(&p->mutex);\n#endif\n\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    printf(\"leave mutex %p (%d) with nRef=%d\\n\", p, p->trace, p->nRef);\n  }\n#endif\n}\n\nsqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    pthreadMutexInit,\n    pthreadMutexEnd,\n    pthreadMutexAlloc,\n    pthreadMutexFree,\n    pthreadMutexEnter,\n    pthreadMutexTry,\n    pthreadMutexLeave,\n#ifdef SQLITE_DEBUG\n    pthreadMutexHeld,\n    pthreadMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_PTHREADS */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/mutex_w32.c",
    "content": "/*\n** 2007 August 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the C functions that implement mutexes for Win32.\n*/\n#include \"sqliteInt.h\"\n\n#if SQLITE_OS_WIN\n/*\n** Include code that is common to all os_*.c files\n*/\n#include \"os_common.h\"\n\n/*\n** Include the header file for the Windows VFS.\n*/\n#include \"os_win.h\"\n#endif\n\n/*\n** The code in this file is only used if we are compiling multithreaded\n** on a Win32 system.\n*/\n#ifdef SQLITE_MUTEX_W32\n\n/*\n** Each recursive mutex is an instance of the following structure.\n*/\nstruct sqlite3_mutex {\n  CRITICAL_SECTION mutex;    /* Mutex controlling the lock */\n  int id;                    /* Mutex type */\n#ifdef SQLITE_DEBUG\n  volatile int nRef;         /* Number of enterances */\n  volatile DWORD owner;      /* Thread holding this mutex */\n  volatile int trace;        /* True to trace changes */\n#endif\n};\n\n/*\n** These are the initializer values used when declaring a \"static\" mutex\n** on Win32.  It should be noted that all mutexes require initialization\n** on the Win32 platform.\n*/\n#define SQLITE_W32_MUTEX_INITIALIZER { 0 }\n\n#ifdef SQLITE_DEBUG\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0, \\\n                                    0L, (DWORD)0, 0 }\n#else\n#define SQLITE3_MUTEX_INITIALIZER { SQLITE_W32_MUTEX_INITIALIZER, 0 }\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are\n** intended for use only inside assert() statements.\n*/\nstatic int winMutexHeld(sqlite3_mutex *p){\n  return p->nRef!=0 && p->owner==GetCurrentThreadId();\n}\n\nstatic int winMutexNotheld2(sqlite3_mutex *p, DWORD tid){\n  return p->nRef==0 || p->owner!=tid;\n}\n\nstatic int winMutexNotheld(sqlite3_mutex *p){\n  DWORD tid = GetCurrentThreadId();\n  return winMutexNotheld2(p, tid);\n}\n#endif\n\n/*\n** Try to provide a memory barrier operation, needed for initialization\n** and also for the xShmBarrier method of the VFS in cases when SQLite is\n** compiled without mutexes (SQLITE_THREADSAFE=0).\n*/\nvoid sqlite3MemoryBarrier(void){\n#if defined(SQLITE_MEMORY_BARRIER)\n  SQLITE_MEMORY_BARRIER;\n#elif defined(__GNUC__)\n  __sync_synchronize();\n#elif MSVC_VERSION>=1300\n  _ReadWriteBarrier();\n#elif defined(MemoryBarrier)\n  MemoryBarrier();\n#endif\n}\n\n/*\n** Initialize and deinitialize the mutex subsystem.\n*/\nstatic sqlite3_mutex winMutex_staticMutexes[] = {\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER,\n  SQLITE3_MUTEX_INITIALIZER\n};\n\nstatic int winMutex_isInit = 0;\nstatic int winMutex_isNt = -1; /* <0 means \"need to query\" */\n\n/* As the winMutexInit() and winMutexEnd() functions are called as part\n** of the sqlite3_initialize() and sqlite3_shutdown() processing, the\n** \"interlocked\" magic used here is probably not strictly necessary.\n*/\nstatic LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;\n\nint sqlite3_win32_is_nt(void); /* os_win.c */\nvoid sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */\n\nstatic int winMutexInit(void){\n  /* The first to increment to 1 does actual initialization */\n  if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){\n    int i;\n    for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n#if SQLITE_OS_WINRT\n      InitializeCriticalSectionEx(&winMutex_staticMutexes[i].mutex, 0, 0);\n#else\n      InitializeCriticalSection(&winMutex_staticMutexes[i].mutex);\n#endif\n    }\n    winMutex_isInit = 1;\n  }else{\n    /* Another thread is (in the process of) initializing the static\n    ** mutexes */\n    while( !winMutex_isInit ){\n      sqlite3_win32_sleep(1);\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int winMutexEnd(void){\n  /* The first to decrement to 0 does actual shutdown\n  ** (which should be the last to shutdown.) */\n  if( InterlockedCompareExchange(&winMutex_lock, 0, 1)==1 ){\n    if( winMutex_isInit==1 ){\n      int i;\n      for(i=0; i<ArraySize(winMutex_staticMutexes); i++){\n        DeleteCriticalSection(&winMutex_staticMutexes[i].mutex);\n      }\n      winMutex_isInit = 0;\n    }\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it.  If it returns NULL\n** that means that a mutex could not be allocated.  SQLite\n** will unwind its stack and return an error.  The argument\n** to sqlite3_mutex_alloc() is one of these integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** The first two constants cause sqlite3_mutex_alloc() to create\n** a new mutex.  The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  But SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** The other allowed parameters to sqlite3_mutex_alloc() each return\n** a pointer to a static preexisting mutex.  Six static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  But for the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n*/\nstatic sqlite3_mutex *winMutexAlloc(int iType){\n  sqlite3_mutex *p;\n\n  switch( iType ){\n    case SQLITE_MUTEX_FAST:\n    case SQLITE_MUTEX_RECURSIVE: {\n      p = sqlite3MallocZero( sizeof(*p) );\n      if( p ){\n        p->id = iType;\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC\n        p->trace = 1;\n#endif\n#endif\n#if SQLITE_OS_WINRT\n        InitializeCriticalSectionEx(&p->mutex, 0, 0);\n#else\n        InitializeCriticalSection(&p->mutex);\n#endif\n      }\n      break;\n    }\n    default: {\n#ifdef SQLITE_ENABLE_API_ARMOR\n      if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){\n        (void)SQLITE_MISUSE_BKPT;\n        return 0;\n      }\n#endif\n      p = &winMutex_staticMutexes[iType-2];\n      p->id = iType;\n#ifdef SQLITE_DEBUG\n#ifdef SQLITE_WIN32_MUTEX_TRACE_STATIC\n      p->trace = 1;\n#endif\n#endif\n      break;\n    }\n  }\n  return p;\n}\n\n\n/*\n** This routine deallocates a previously\n** allocated mutex.  SQLite is careful to deallocate every\n** mutex that it allocates.\n*/\nstatic void winMutexFree(sqlite3_mutex *p){\n  assert( p );\n  assert( p->nRef==0 && p->owner==0 );\n  if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ){\n    DeleteCriticalSection(&p->mutex);\n    sqlite3_free(p);\n  }else{\n#ifdef SQLITE_ENABLE_API_ARMOR\n    (void)SQLITE_MISUSE_BKPT;\n#endif\n  }\n}\n\n/*\n** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK\n** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can\n** be entered multiple times by the same thread.  In such cases the,\n** mutex must be exited an equal number of times before another thread\n** can enter.  If the same thread tries to enter any other kind of mutex\n** more than once, the behavior is undefined.\n*/\nstatic void winMutexEnter(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n#ifdef SQLITE_DEBUG\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n#else\n  assert( p );\n#endif\n  assert( winMutex_isInit==1 );\n  EnterCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 || p->owner==0 );\n  p->owner = tid;\n  p->nRef++;\n  if( p->trace ){\n    OSTRACE((\"ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nstatic int winMutexTry(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  int rc = SQLITE_BUSY;\n  assert( p );\n  assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );\n  /*\n  ** The sqlite3_mutex_try() routine is very rarely used, and when it\n  ** is used it is merely an optimization.  So it is OK for it to always\n  ** fail.\n  **\n  ** The TryEnterCriticalSection() interface is only available on WinNT.\n  ** And some windows compilers complain if you try to use it without\n  ** first doing some #defines that prevent SQLite from building on Win98.\n  ** For that reason, we will omit this optimization for now.  See\n  ** ticket #2685.\n  */\n#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400\n  assert( winMutex_isInit==1 );\n  assert( winMutex_isNt>=-1 && winMutex_isNt<=1 );\n  if( winMutex_isNt<0 ){\n    winMutex_isNt = sqlite3_win32_is_nt();\n  }\n  assert( winMutex_isNt==0 || winMutex_isNt==1 );\n  if( winMutex_isNt && TryEnterCriticalSection(&p->mutex) ){\n#ifdef SQLITE_DEBUG\n    p->owner = tid;\n    p->nRef++;\n#endif\n    rc = SQLITE_OK;\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\\n\",\n             tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));\n  }\n#endif\n  return rc;\n}\n\n/*\n** The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.  The behavior\n** is undefined if the mutex is not currently entered or\n** is not currently allocated.  SQLite will never do either.\n*/\nstatic void winMutexLeave(sqlite3_mutex *p){\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  DWORD tid = GetCurrentThreadId();\n#endif\n  assert( p );\n#ifdef SQLITE_DEBUG\n  assert( p->nRef>0 );\n  assert( p->owner==tid );\n  p->nRef--;\n  if( p->nRef==0 ) p->owner = 0;\n  assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );\n#endif\n  assert( winMutex_isInit==1 );\n  LeaveCriticalSection(&p->mutex);\n#ifdef SQLITE_DEBUG\n  if( p->trace ){\n    OSTRACE((\"LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\\n\",\n             tid, p->id, p, p->trace, p->nRef));\n  }\n#endif\n}\n\nsqlite3_mutex_methods const *sqlite3DefaultMutex(void){\n  static const sqlite3_mutex_methods sMutex = {\n    winMutexInit,\n    winMutexEnd,\n    winMutexAlloc,\n    winMutexFree,\n    winMutexEnter,\n    winMutexTry,\n    winMutexLeave,\n#ifdef SQLITE_DEBUG\n    winMutexHeld,\n    winMutexNotheld\n#else\n    0,\n    0\n#endif\n  };\n  return &sMutex;\n}\n\n#endif /* SQLITE_MUTEX_W32 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/notify.c",
    "content": "/*\n** 2009 March 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of the sqlite3_unlock_notify()\n** API method and its associated functionality.\n*/\n#include \"sqliteInt.h\"\n#include \"btreeInt.h\"\n\n/* Omit this entire file if SQLITE_ENABLE_UNLOCK_NOTIFY is not defined. */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n\n/*\n** Public interfaces:\n**\n**   sqlite3ConnectionBlocked()\n**   sqlite3ConnectionUnlocked()\n**   sqlite3ConnectionClosed()\n**   sqlite3_unlock_notify()\n*/\n\n#define assertMutexHeld() \\\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) )\n\n/*\n** Head of a linked list of all sqlite3 objects created by this process\n** for which either sqlite3.pBlockingConnection or sqlite3.pUnlockConnection\n** is not NULL. This variable may only accessed while the STATIC_MASTER\n** mutex is held.\n*/\nstatic sqlite3 *SQLITE_WSD sqlite3BlockedList = 0;\n\n#ifndef NDEBUG\n/*\n** This function is a complex assert() that verifies the following \n** properties of the blocked connections list:\n**\n**   1) Each entry in the list has a non-NULL value for either \n**      pUnlockConnection or pBlockingConnection, or both.\n**\n**   2) All entries in the list that share a common value for \n**      xUnlockNotify are grouped together.\n**\n**   3) If the argument db is not NULL, then none of the entries in the\n**      blocked connections list have pUnlockConnection or pBlockingConnection\n**      set to db. This is used when closing connection db.\n*/\nstatic void checkListProperties(sqlite3 *db){\n  sqlite3 *p;\n  for(p=sqlite3BlockedList; p; p=p->pNextBlocked){\n    int seen = 0;\n    sqlite3 *p2;\n\n    /* Verify property (1) */\n    assert( p->pUnlockConnection || p->pBlockingConnection );\n\n    /* Verify property (2) */\n    for(p2=sqlite3BlockedList; p2!=p; p2=p2->pNextBlocked){\n      if( p2->xUnlockNotify==p->xUnlockNotify ) seen = 1;\n      assert( p2->xUnlockNotify==p->xUnlockNotify || !seen );\n      assert( db==0 || p->pUnlockConnection!=db );\n      assert( db==0 || p->pBlockingConnection!=db );\n    }\n  }\n}\n#else\n# define checkListProperties(x)\n#endif\n\n/*\n** Remove connection db from the blocked connections list. If connection\n** db is not currently a part of the list, this function is a no-op.\n*/\nstatic void removeFromBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(pp=&sqlite3BlockedList; *pp; pp = &(*pp)->pNextBlocked){\n    if( *pp==db ){\n      *pp = (*pp)->pNextBlocked;\n      break;\n    }\n  }\n}\n\n/*\n** Add connection db to the blocked connections list. It is assumed\n** that it is not already a part of the list.\n*/\nstatic void addToBlockedList(sqlite3 *db){\n  sqlite3 **pp;\n  assertMutexHeld();\n  for(\n    pp=&sqlite3BlockedList; \n    *pp && (*pp)->xUnlockNotify!=db->xUnlockNotify; \n    pp=&(*pp)->pNextBlocked\n  );\n  db->pNextBlocked = *pp;\n  *pp = db;\n}\n\n/*\n** Obtain the STATIC_MASTER mutex.\n*/\nstatic void enterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n  checkListProperties(0);\n}\n\n/*\n** Release the STATIC_MASTER mutex.\n*/\nstatic void leaveMutex(void){\n  assertMutexHeld();\n  checkListProperties(0);\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));\n}\n\n/*\n** Register an unlock-notify callback.\n**\n** This is called after connection \"db\" has attempted some operation\n** but has received an SQLITE_LOCKED error because another connection\n** (call it pOther) in the same process was busy using the same shared\n** cache.  pOther is found by looking at db->pBlockingConnection.\n**\n** If there is no blocking connection, the callback is invoked immediately,\n** before this routine returns.\n**\n** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate\n** a deadlock.\n**\n** Otherwise, make arrangements to invoke xNotify when pOther drops\n** its locks.\n**\n** Each call to this routine overrides any prior callbacks registered\n** on the same \"db\".  If xNotify==0 then any prior callbacks are immediately\n** cancelled.\n*/\nint sqlite3_unlock_notify(\n  sqlite3 *db,\n  void (*xNotify)(void **, int),\n  void *pArg\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  enterMutex();\n\n  if( xNotify==0 ){\n    removeFromBlockedList(db);\n    db->pBlockingConnection = 0;\n    db->pUnlockConnection = 0;\n    db->xUnlockNotify = 0;\n    db->pUnlockArg = 0;\n  }else if( 0==db->pBlockingConnection ){\n    /* The blocking transaction has been concluded. Or there never was a \n    ** blocking transaction. In either case, invoke the notify callback\n    ** immediately. \n    */\n    xNotify(&pArg, 1);\n  }else{\n    sqlite3 *p;\n\n    for(p=db->pBlockingConnection; p && p!=db; p=p->pUnlockConnection){}\n    if( p ){\n      rc = SQLITE_LOCKED;              /* Deadlock detected. */\n    }else{\n      db->pUnlockConnection = db->pBlockingConnection;\n      db->xUnlockNotify = xNotify;\n      db->pUnlockArg = pArg;\n      removeFromBlockedList(db);\n      addToBlockedList(db);\n    }\n  }\n\n  leaveMutex();\n  assert( !db->mallocFailed );\n  sqlite3ErrorWithMsg(db, rc, (rc?\"database is deadlocked\":0));\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is called while stepping or preparing a statement \n** associated with connection db. The operation will return SQLITE_LOCKED\n** to the user because it requires a lock that will not be available\n** until connection pBlocker concludes its current transaction.\n*/\nvoid sqlite3ConnectionBlocked(sqlite3 *db, sqlite3 *pBlocker){\n  enterMutex();\n  if( db->pBlockingConnection==0 && db->pUnlockConnection==0 ){\n    addToBlockedList(db);\n  }\n  db->pBlockingConnection = pBlocker;\n  leaveMutex();\n}\n\n/*\n** This function is called when\n** the transaction opened by database db has just finished. Locks held \n** by database connection db have been released.\n**\n** This function loops through each entry in the blocked connections\n** list and does the following:\n**\n**   1) If the sqlite3.pBlockingConnection member of a list entry is\n**      set to db, then set pBlockingConnection=0.\n**\n**   2) If the sqlite3.pUnlockConnection member of a list entry is\n**      set to db, then invoke the configured unlock-notify callback and\n**      set pUnlockConnection=0.\n**\n**   3) If the two steps above mean that pBlockingConnection==0 and\n**      pUnlockConnection==0, remove the entry from the blocked connections\n**      list.\n*/\nvoid sqlite3ConnectionUnlocked(sqlite3 *db){\n  void (*xUnlockNotify)(void **, int) = 0; /* Unlock-notify cb to invoke */\n  int nArg = 0;                            /* Number of entries in aArg[] */\n  sqlite3 **pp;                            /* Iterator variable */\n  void **aArg;               /* Arguments to the unlock callback */\n  void **aDyn = 0;           /* Dynamically allocated space for aArg[] */\n  void *aStatic[16];         /* Starter space for aArg[].  No malloc required */\n\n  aArg = aStatic;\n  enterMutex();         /* Enter STATIC_MASTER mutex */\n\n  /* This loop runs once for each entry in the blocked-connections list. */\n  for(pp=&sqlite3BlockedList; *pp; /* no-op */ ){\n    sqlite3 *p = *pp;\n\n    /* Step 1. */\n    if( p->pBlockingConnection==db ){\n      p->pBlockingConnection = 0;\n    }\n\n    /* Step 2. */\n    if( p->pUnlockConnection==db ){\n      assert( p->xUnlockNotify );\n      if( p->xUnlockNotify!=xUnlockNotify && nArg!=0 ){\n        xUnlockNotify(aArg, nArg);\n        nArg = 0;\n      }\n\n      sqlite3BeginBenignMalloc();\n      assert( aArg==aDyn || (aDyn==0 && aArg==aStatic) );\n      assert( nArg<=(int)ArraySize(aStatic) || aArg==aDyn );\n      if( (!aDyn && nArg==(int)ArraySize(aStatic))\n       || (aDyn && nArg==(int)(sqlite3MallocSize(aDyn)/sizeof(void*)))\n      ){\n        /* The aArg[] array needs to grow. */\n        void **pNew = (void **)sqlite3Malloc(nArg*sizeof(void *)*2);\n        if( pNew ){\n          memcpy(pNew, aArg, nArg*sizeof(void *));\n          sqlite3_free(aDyn);\n          aDyn = aArg = pNew;\n        }else{\n          /* This occurs when the array of context pointers that need to\n          ** be passed to the unlock-notify callback is larger than the\n          ** aStatic[] array allocated on the stack and the attempt to \n          ** allocate a larger array from the heap has failed.\n          **\n          ** This is a difficult situation to handle. Returning an error\n          ** code to the caller is insufficient, as even if an error code\n          ** is returned the transaction on connection db will still be\n          ** closed and the unlock-notify callbacks on blocked connections\n          ** will go unissued. This might cause the application to wait\n          ** indefinitely for an unlock-notify callback that will never \n          ** arrive.\n          **\n          ** Instead, invoke the unlock-notify callback with the context\n          ** array already accumulated. We can then clear the array and\n          ** begin accumulating any further context pointers without \n          ** requiring any dynamic allocation. This is sub-optimal because\n          ** it means that instead of one callback with a large array of\n          ** context pointers the application will receive two or more\n          ** callbacks with smaller arrays of context pointers, which will\n          ** reduce the applications ability to prioritize multiple \n          ** connections. But it is the best that can be done under the\n          ** circumstances.\n          */\n          xUnlockNotify(aArg, nArg);\n          nArg = 0;\n        }\n      }\n      sqlite3EndBenignMalloc();\n\n      aArg[nArg++] = p->pUnlockArg;\n      xUnlockNotify = p->xUnlockNotify;\n      p->pUnlockConnection = 0;\n      p->xUnlockNotify = 0;\n      p->pUnlockArg = 0;\n    }\n\n    /* Step 3. */\n    if( p->pBlockingConnection==0 && p->pUnlockConnection==0 ){\n      /* Remove connection p from the blocked connections list. */\n      *pp = p->pNextBlocked;\n      p->pNextBlocked = 0;\n    }else{\n      pp = &p->pNextBlocked;\n    }\n  }\n\n  if( nArg!=0 ){\n    xUnlockNotify(aArg, nArg);\n  }\n  sqlite3_free(aDyn);\n  leaveMutex();         /* Leave STATIC_MASTER mutex */\n}\n\n/*\n** This is called when the database connection passed as an argument is \n** being closed. The connection is removed from the blocked list.\n*/\nvoid sqlite3ConnectionClosed(sqlite3 *db){\n  sqlite3ConnectionUnlocked(db);\n  enterMutex();\n  removeFromBlockedList(db);\n  checkListProperties(db);\n  leaveMutex();\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/opcodes.h",
    "content": "/************** Begin file opcodes.h *****************************************/\n/* Automatically generated.  Do not edit */\n/* See the tool/mkopcodeh.tcl script for details */\n#define OP_Savepoint       0\n#define OP_AutoCommit      1\n#define OP_Transaction     2\n#define OP_SorterNext      3 /* jump                                       */\n#define OP_PrevIfOpen      4 /* jump                                       */\n#define OP_NextIfOpen      5 /* jump                                       */\n#define OP_Prev            6 /* jump                                       */\n#define OP_Next            7 /* jump                                       */\n#define OP_Checkpoint      8\n#define OP_JournalMode     9\n#define OP_Vacuum         10\n#define OP_VFilter        11 /* jump, synopsis: iplan=r[P3] zplan='P4'     */\n#define OP_VUpdate        12 /* synopsis: data=r[P3@P2]                    */\n#define OP_Goto           13 /* jump                                       */\n#define OP_Gosub          14 /* jump                                       */\n#define OP_InitCoroutine  15 /* jump                                       */\n#define OP_Yield          16 /* jump                                       */\n#define OP_MustBeInt      17 /* jump                                       */\n#define OP_Jump           18 /* jump                                       */\n#define OP_Not            19 /* same as TK_NOT, synopsis: r[P2]= !r[P1]    */\n#define OP_Once           20 /* jump                                       */\n#define OP_If             21 /* jump                                       */\n#define OP_IfNot          22 /* jump                                       */\n#define OP_IfNullRow      23 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */\n#define OP_SeekLT         24 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekLE         25 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGE         26 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekGT         27 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NoConflict     28 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_NotFound       29 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_Found          30 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_SeekRowid      31 /* jump, synopsis: intkey=r[P3]               */\n#define OP_NotExists      32 /* jump, synopsis: intkey=r[P3]               */\n#define OP_Last           33 /* jump                                       */\n#define OP_IfSmaller      34 /* jump                                       */\n#define OP_SorterSort     35 /* jump                                       */\n#define OP_Sort           36 /* jump                                       */\n#define OP_Rewind         37 /* jump                                       */\n#define OP_IdxLE          38 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGT          39 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxLT          40 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_IdxGE          41 /* jump, synopsis: key=r[P3@P4]               */\n#define OP_RowSetRead     42 /* jump, synopsis: r[P3]=rowset(P1)           */\n#define OP_Or             43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */\n#define OP_And            44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */\n#define OP_RowSetTest     45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */\n#define OP_Program        46 /* jump                                       */\n#define OP_FkIfZero       47 /* jump, synopsis: if fkctr[P1]==0 goto P2    */\n#define OP_IfPos          48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */\n#define OP_IfNotZero      49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */\n#define OP_IsNull         50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */\n#define OP_NotNull        51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */\n#define OP_Ne             52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */\n#define OP_Eq             53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */\n#define OP_Gt             54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */\n#define OP_Le             55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */\n#define OP_Lt             56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */\n#define OP_Ge             57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */\n#define OP_ElseNotEq      58 /* jump, same as TK_ESCAPE                    */\n#define OP_DecrJumpZero   59 /* jump, synopsis: if (--r[P1])==0 goto P2    */\n#define OP_IncrVacuum     60 /* jump                                       */\n#define OP_VNext          61 /* jump                                       */\n#define OP_Init           62 /* jump, synopsis: Start at P2                */\n#define OP_Return         63\n#define OP_EndCoroutine   64\n#define OP_HaltIfNull     65 /* synopsis: if r[P3]=null halt               */\n#define OP_Halt           66\n#define OP_Integer        67 /* synopsis: r[P2]=P1                         */\n#define OP_Int64          68 /* synopsis: r[P2]=P4                         */\n#define OP_String         69 /* synopsis: r[P2]='P4' (len=P1)              */\n#define OP_Null           70 /* synopsis: r[P2..P3]=NULL                   */\n#define OP_SoftNull       71 /* synopsis: r[P1]=NULL                       */\n#define OP_Blob           72 /* synopsis: r[P2]=P4 (len=P1)                */\n#define OP_Variable       73 /* synopsis: r[P2]=parameter(P1,P4)           */\n#define OP_Move           74 /* synopsis: r[P2@P3]=r[P1@P3]                */\n#define OP_Copy           75 /* synopsis: r[P2@P3+1]=r[P1@P3+1]            */\n#define OP_SCopy          76 /* synopsis: r[P2]=r[P1]                      */\n#define OP_IntCopy        77 /* synopsis: r[P2]=r[P1]                      */\n#define OP_ResultRow      78 /* synopsis: output=r[P1@P2]                  */\n#define OP_CollSeq        79\n#define OP_AddImm         80 /* synopsis: r[P1]=r[P1]+P2                   */\n#define OP_RealAffinity   81\n#define OP_Cast           82 /* synopsis: affinity(r[P1])                  */\n#define OP_Permutation    83\n#define OP_BitAnd         84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */\n#define OP_BitOr          85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */\n#define OP_ShiftLeft      86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */\n#define OP_ShiftRight     87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */\n#define OP_Add            88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */\n#define OP_Subtract       89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */\n#define OP_Multiply       90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */\n#define OP_Divide         91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */\n#define OP_Remainder      92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */\n#define OP_Concat         93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */\n#define OP_Compare        94 /* synopsis: r[P1@P3] <-> r[P2@P3]            */\n#define OP_BitNot         95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */\n#define OP_Column         96 /* synopsis: r[P3]=PX                         */\n#define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */\n#define OP_Affinity       98 /* synopsis: affinity(r[P1@P2])               */\n#define OP_MakeRecord     99 /* synopsis: r[P3]=mkrec(r[P1@P2])            */\n#define OP_Count         100 /* synopsis: r[P2]=count()                    */\n#define OP_ReadCookie    101\n#define OP_SetCookie     102\n#define OP_ReopenIdx     103 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenRead      104 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenWrite     105 /* synopsis: root=P2 iDb=P3                   */\n#define OP_OpenDup       106\n#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2                       */\n#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2                       */\n#define OP_SorterOpen    109\n#define OP_SequenceTest  110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2   */\n#define OP_OpenPseudo    111 /* synopsis: P3 columns in r[P2]              */\n#define OP_Close         112\n#define OP_ColumnsUsed   113\n#define OP_Sequence      114 /* synopsis: r[P2]=cursor[P1].ctr++           */\n#define OP_NewRowid      115 /* synopsis: r[P2]=rowid                      */\n#define OP_Insert        116 /* synopsis: intkey=r[P3] data=r[P2]          */\n#define OP_InsertInt     117 /* synopsis: intkey=P3 data=r[P2]             */\n#define OP_Delete        118\n#define OP_ResetCount    119\n#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */\n#define OP_SorterData    121 /* synopsis: r[P2]=data                       */\n#define OP_RowData       122 /* synopsis: r[P2]=data                       */\n#define OP_Rowid         123 /* synopsis: r[P2]=rowid                      */\n#define OP_NullRow       124\n#define OP_SeekEnd       125\n#define OP_SorterInsert  126 /* synopsis: key=r[P2]                        */\n#define OP_IdxInsert     127 /* synopsis: key=r[P2]                        */\n#define OP_IdxDelete     128 /* synopsis: key=r[P2@P3]                     */\n#define OP_DeferredSeek  129 /* synopsis: Move P3 to P1.rowid if needed    */\n#define OP_IdxRowid      130 /* synopsis: r[P2]=rowid                      */\n#define OP_Destroy       131\n#define OP_Real          132 /* same as TK_FLOAT, synopsis: r[P2]=P4       */\n#define OP_Clear         133\n#define OP_ResetSorter   134\n#define OP_CreateBtree   135 /* synopsis: r[P2]=root iDb=P1 flags=P3       */\n#define OP_SqlExec       136\n#define OP_ParseSchema   137\n#define OP_LoadAnalysis  138\n#define OP_DropTable     139\n#define OP_DropIndex     140\n#define OP_DropTrigger   141\n#define OP_IntegrityCk   142\n#define OP_RowSetAdd     143 /* synopsis: rowset(P1)=r[P2]                 */\n#define OP_Param         144\n#define OP_FkCounter     145 /* synopsis: fkctr[P1]+=P2                    */\n#define OP_MemMax        146 /* synopsis: r[P1]=max(r[P1],r[P2])           */\n#define OP_OffsetLimit   147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */\n#define OP_AggStep0      148 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggStep       149 /* synopsis: accum=r[P3] step(r[P2@P5])       */\n#define OP_AggFinal      150 /* synopsis: accum=r[P1] N=P2                 */\n#define OP_Expire        151\n#define OP_TableLock     152 /* synopsis: iDb=P1 root=P2 write=P3          */\n#define OP_VBegin        153\n#define OP_VCreate       154\n#define OP_VDestroy      155\n#define OP_VOpen         156\n#define OP_VColumn       157 /* synopsis: r[P3]=vcolumn(P2)                */\n#define OP_VRename       158\n#define OP_Pagecount     159\n#define OP_MaxPgcnt      160\n#define OP_PureFunc0     161\n#define OP_Function0     162 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_PureFunc      163\n#define OP_Function      164 /* synopsis: r[P3]=func(r[P2@P5])             */\n#define OP_CursorHint    165\n#define OP_Noop          166\n#define OP_Explain       167\n\n/* Properties such as \"out2\" or \"jump\" that are specified in\n** comments following the \"case\" for each opcode in the vdbe.c\n** are encoded into bitvectors as follows:\n*/\n#define OPFLG_JUMP        0x01  /* jump:  P2 holds jmp target */\n#define OPFLG_IN1         0x02  /* in1:   P1 is an input */\n#define OPFLG_IN2         0x04  /* in2:   P2 is an input */\n#define OPFLG_IN3         0x08  /* in3:   P3 is an input */\n#define OPFLG_OUT2        0x10  /* out2:  P2 is an output */\n#define OPFLG_OUT3        0x20  /* out3:  P3 is an output */\n#define OPFLG_INITIALIZER {\\\n/*   0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\\\n/*   8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\\\n/*  16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\\\n/*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\\\n/*  32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\\\n/*  40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\\\n/*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\\\n/*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\\\n/*  64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\\\n/*  72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\\\n/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x26, 0x26, 0x26, 0x26,\\\n/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\\\n/*  96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\\\n/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\\\n/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04,\\\n/* 128 */ 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10,\\\n/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\\\n/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\\\n/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\\\n/* 160 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\\\n}\n\n/* The sqlite3P2Values() routine is able to run faster if it knows\n** the value of the largest JUMP opcode.  The smaller the maximum\n** JUMP opcode the better, so the mkopcodeh.tcl script that\n** generated this include file strives to group all JUMP opcodes\n** together near the beginning of the list.\n*/\n#define SQLITE_MX_JUMP_OPCODE  62  /* Maximum JUMP opcode */\n\n/************** End of opcodes.h *********************************************/\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os.c",
    "content": "/*\n** 2005 November 29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains OS interface code that is common to all\n** architectures.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nint sqlite3_io_error_hit = 0;            /* Total number of I/O Errors */\nint sqlite3_io_error_hardhit = 0;        /* Number of non-benign errors */\nint sqlite3_io_error_pending = 0;        /* Count down to first I/O error */\nint sqlite3_io_error_persist = 0;        /* True if I/O errors persist */\nint sqlite3_io_error_benign = 0;         /* True if errors are benign */\nint sqlite3_diskfull_pending = 0;\nint sqlite3_diskfull = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, also keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nint sqlite3_open_file_count = 0;\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** The default SQLite sqlite3_vfs implementations do not allocate\n** memory (actually, os_unix.c allocates a small amount of memory\n** from within OsOpen()), but some third-party implementations may.\n** So we test the effects of a malloc() failing and the sqlite3OsXXX()\n** function returning SQLITE_IOERR_NOMEM using the DO_OS_MALLOC_TEST macro.\n**\n** The following functions are instrumented for malloc() failure\n** testing:\n**\n**     sqlite3OsRead()\n**     sqlite3OsWrite()\n**     sqlite3OsSync()\n**     sqlite3OsFileSize()\n**     sqlite3OsLock()\n**     sqlite3OsCheckReservedLock()\n**     sqlite3OsFileControl()\n**     sqlite3OsShmMap()\n**     sqlite3OsOpen()\n**     sqlite3OsDelete()\n**     sqlite3OsAccess()\n**     sqlite3OsFullPathname()\n**\n*/\n#if defined(SQLITE_TEST)\nint sqlite3_memdebug_vfs_oom_test = 1;\n  #define DO_OS_MALLOC_TEST(x)                                       \\\n  if (sqlite3_memdebug_vfs_oom_test && (!x || !sqlite3JournalIsInMemory(x))) { \\\n    void *pTstAlloc = sqlite3Malloc(10);                             \\\n    if (!pTstAlloc) return SQLITE_IOERR_NOMEM_BKPT;                  \\\n    sqlite3_free(pTstAlloc);                                         \\\n  }\n#else\n  #define DO_OS_MALLOC_TEST(x)\n#endif\n\n/*\n** The following routines are convenience wrappers around methods\n** of the sqlite3_file object.  This is mostly just syntactic sugar. All\n** of this would be completely automatic if SQLite were coded using\n** C++ instead of plain old C.\n*/\nvoid sqlite3OsClose(sqlite3_file *pId){\n  if( pId->pMethods ){\n    pId->pMethods->xClose(pId);\n    pId->pMethods = 0;\n  }\n}\nint sqlite3OsRead(sqlite3_file *id, void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xRead(id, pBuf, amt, offset);\n}\nint sqlite3OsWrite(sqlite3_file *id, const void *pBuf, int amt, i64 offset){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xWrite(id, pBuf, amt, offset);\n}\nint sqlite3OsTruncate(sqlite3_file *id, i64 size){\n  return id->pMethods->xTruncate(id, size);\n}\nint sqlite3OsSync(sqlite3_file *id, int flags){\n  DO_OS_MALLOC_TEST(id);\n  return flags ? id->pMethods->xSync(id, flags) : SQLITE_OK;\n}\nint sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFileSize(id, pSize);\n}\nint sqlite3OsLock(sqlite3_file *id, int lockType){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xLock(id, lockType);\n}\nint sqlite3OsUnlock(sqlite3_file *id, int lockType){\n  return id->pMethods->xUnlock(id, lockType);\n}\nint sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xCheckReservedLock(id, pResOut);\n}\n\n/*\n** Use sqlite3OsFileControl() when we are doing something that might fail\n** and we need to know about the failures.  Use sqlite3OsFileControlHint()\n** when simply tossing information over the wall to the VFS and we do not\n** really care if the VFS receives and understands the information since it\n** is only a hint and can be safely ignored.  The sqlite3OsFileControlHint()\n** routine has no return value since the return value would be meaningless.\n*/\nint sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){\n#ifdef SQLITE_TEST\n  if( op!=SQLITE_FCNTL_COMMIT_PHASETWO ){\n    /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite\n    ** is using a regular VFS, it is called after the corresponding\n    ** transaction has been committed. Injecting a fault at this point\n    ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM\n    ** but the transaction is committed anyway.\n    **\n    ** The core must call OsFileControl() though, not OsFileControlHint(),\n    ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably\n    ** means the commit really has failed and an error should be returned\n    ** to the user.  */\n    DO_OS_MALLOC_TEST(id);\n  }\n#endif\n  return id->pMethods->xFileControl(id, op, pArg);\n}\nvoid sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){\n  (void)id->pMethods->xFileControl(id, op, pArg);\n}\n\nint sqlite3OsSectorSize(sqlite3_file *id){\n  int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize;\n  return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE);\n}\nint sqlite3OsDeviceCharacteristics(sqlite3_file *id){\n  return id->pMethods->xDeviceCharacteristics(id);\n}\n#ifndef SQLITE_OMIT_WAL\nint sqlite3OsShmLock(sqlite3_file *id, int offset, int n, int flags){\n  return id->pMethods->xShmLock(id, offset, n, flags);\n}\nvoid sqlite3OsShmBarrier(sqlite3_file *id){\n  id->pMethods->xShmBarrier(id);\n}\nint sqlite3OsShmUnmap(sqlite3_file *id, int deleteFlag){\n  return id->pMethods->xShmUnmap(id, deleteFlag);\n}\nint sqlite3OsShmMap(\n  sqlite3_file *id,               /* Database file handle */\n  int iPage,\n  int pgsz,\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Pointer to mapping */\n){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xShmMap(id, iPage, pgsz, bExtend, pp);\n}\n#endif /* SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The real implementation of xFetch and xUnfetch */\nint sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  DO_OS_MALLOC_TEST(id);\n  return id->pMethods->xFetch(id, iOff, iAmt, pp);\n}\nint sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return id->pMethods->xUnfetch(id, iOff, p);\n}\n#else\n/* No-op stubs to use when memory-mapped I/O is disabled */\nint sqlite3OsFetch(sqlite3_file *id, i64 iOff, int iAmt, void **pp){\n  *pp = 0;\n  return SQLITE_OK;\n}\nint sqlite3OsUnfetch(sqlite3_file *id, i64 iOff, void *p){\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The next group of routines are convenience wrappers around the\n** VFS methods.\n*/\nint sqlite3OsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  sqlite3_file *pFile,\n  int flags,\n  int *pFlagsOut\n){\n  int rc;\n  DO_OS_MALLOC_TEST(0);\n  /* 0x87f7f is a mask of SQLITE_OPEN_ flags that are valid to be passed\n  ** down into the VFS layer.  Some SQLITE_OPEN_ flags (for example,\n  ** SQLITE_OPEN_FULLMUTEX or SQLITE_OPEN_SHAREDCACHE) are blocked before\n  ** reaching the VFS. */\n  rc = pVfs->xOpen(pVfs, zPath, pFile, flags & 0x87f7f, pFlagsOut);\n  assert( rc==SQLITE_OK || pFile->pMethods==0 );\n  return rc;\n}\nint sqlite3OsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  DO_OS_MALLOC_TEST(0);\n  assert( dirSync==0 || dirSync==1 );\n  return pVfs->xDelete(pVfs, zPath, dirSync);\n}\nint sqlite3OsAccess(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int flags,\n  int *pResOut\n){\n  DO_OS_MALLOC_TEST(0);\n  return pVfs->xAccess(pVfs, zPath, flags, pResOut);\n}\nint sqlite3OsFullPathname(\n  sqlite3_vfs *pVfs,\n  const char *zPath,\n  int nPathOut,\n  char *zPathOut\n){\n  DO_OS_MALLOC_TEST(0);\n  zPathOut[0] = 0;\n  return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n}\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nvoid *sqlite3OsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nvoid sqlite3OsDlError(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  pVfs->xDlError(pVfs, nByte, zBufOut);\n}\nvoid (*sqlite3OsDlSym(sqlite3_vfs *pVfs, void *pHdle, const char *zSym))(void){\n  return pVfs->xDlSym(pVfs, pHdle, zSym);\n}\nvoid sqlite3OsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  pVfs->xDlClose(pVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nint sqlite3OsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nint sqlite3OsSleep(sqlite3_vfs *pVfs, int nMicro){\n  return pVfs->xSleep(pVfs, nMicro);\n}\nint sqlite3OsGetLastError(sqlite3_vfs *pVfs){\n  return pVfs->xGetLastError ? pVfs->xGetLastError(pVfs, 0, 0) : 0;\n}\nint sqlite3OsCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  int rc;\n  /* IMPLEMENTATION-OF: R-49045-42493 SQLite will use the xCurrentTimeInt64()\n  ** method to get the current date and time if that method is available\n  ** (if iVersion is 2 or greater and the function pointer is not NULL) and\n  ** will fall back to xCurrentTime() if xCurrentTimeInt64() is\n  ** unavailable.\n  */\n  if( pVfs->iVersion>=2 && pVfs->xCurrentTimeInt64 ){\n    rc = pVfs->xCurrentTimeInt64(pVfs, pTimeOut);\n  }else{\n    double r;\n    rc = pVfs->xCurrentTime(pVfs, &r);\n    *pTimeOut = (sqlite3_int64)(r*86400000.0);\n  }\n  return rc;\n}\n\nint sqlite3OsOpenMalloc(\n  sqlite3_vfs *pVfs,\n  const char *zFile,\n  sqlite3_file **ppFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  sqlite3_file *pFile;\n  pFile = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile);\n  if( pFile ){\n    rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags);\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(pFile);\n    }else{\n      *ppFile = pFile;\n    }\n  }else{\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\nvoid sqlite3OsCloseFree(sqlite3_file *pFile){\n  assert( pFile );\n  sqlite3OsClose(pFile);\n  sqlite3_free(pFile);\n}\n\n/*\n** This function is a wrapper around the OS specific implementation of\n** sqlite3_os_init(). The purpose of the wrapper is to provide the\n** ability to simulate a malloc failure, so that the handling of an\n** error in sqlite3_os_init() by the upper layers can be tested.\n*/\nint sqlite3OsInit(void){\n  void *p = sqlite3_malloc(10);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  sqlite3_free(p);\n  return sqlite3_os_init();\n}\n\n/*\n** The list of all registered VFS implementations.\n*/\nstatic sqlite3_vfs * SQLITE_WSD vfsList = 0;\n#define vfsList GLOBAL(sqlite3_vfs *, vfsList)\n\n/*\n** Locate a VFS by name.  If no name is given, simply return the\n** first VFS on the list.\n*/\nsqlite3_vfs *sqlite3_vfs_find(const char *zVfs){\n  sqlite3_vfs *pVfs = 0;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return 0;\n#endif\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(pVfs = vfsList; pVfs; pVfs=pVfs->pNext){\n    if( zVfs==0 ) break;\n    if( strcmp(zVfs, pVfs->zName)==0 ) break;\n  }\n  sqlite3_mutex_leave(mutex);\n  return pVfs;\n}\n\n/*\n** Unlink a VFS from the linked list\n*/\nstatic void vfsUnlink(sqlite3_vfs *pVfs){\n  assert( sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)) );\n  if( pVfs==0 ){\n    /* No-op */\n  }else if( vfsList==pVfs ){\n    vfsList = pVfs->pNext;\n  }else if( vfsList ){\n    sqlite3_vfs *p = vfsList;\n    while( p->pNext && p->pNext!=pVfs ){\n      p = p->pNext;\n    }\n    if( p->pNext==pVfs ){\n      p->pNext = pVfs->pNext;\n    }\n  }\n}\n\n/*\n** Register a VFS with the system.  It is harmless to register the same\n** VFS multiple times.  The new VFS becomes the default if makeDflt is\n** true.\n*/\nint sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){\n  MUTEX_LOGIC(sqlite3_mutex *mutex;)\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pVfs==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n\n  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  if( makeDflt || vfsList==0 ){\n    pVfs->pNext = vfsList;\n    vfsList = pVfs;\n  }else{\n    pVfs->pNext = vfsList->pNext;\n    vfsList->pNext = pVfs;\n  }\n  assert(vfsList);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n\n/*\n** Unregister a VFS so that it is no longer accessible.\n*/\nint sqlite3_vfs_unregister(sqlite3_vfs *pVfs){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);\n#endif\n  sqlite3_mutex_enter(mutex);\n  vfsUnlink(pVfs);\n  sqlite3_mutex_leave(mutex);\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os.h",
    "content": "/*\n** 2001 September 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This header file (together with is companion C source-code file\n** \"os.c\") attempt to abstract the underlying operating system so that\n** the SQLite library will work on both POSIX and windows systems.\n**\n** This header file is #include-ed by sqliteInt.h and thus ends up\n** being included by every source file.\n*/\n#ifndef _SQLITE_OS_H_\n#define _SQLITE_OS_H_\n\n/*\n** Attempt to automatically detect the operating system and setup the\n** necessary pre-processor macros for it.\n*/\n#include \"os_setup.h\"\n\n/* If the SET_FULLSYNC macro is not defined above, then make it\n** a no-op\n*/\n#ifndef SET_FULLSYNC\n# define SET_FULLSYNC(x,y)\n#endif\n\n/*\n** The default size of a disk sector\n*/\n#ifndef SQLITE_DEFAULT_SECTOR_SIZE\n# define SQLITE_DEFAULT_SECTOR_SIZE 4096\n#endif\n\n/*\n** Temporary files are named starting with this prefix followed by 16 random\n** alphanumeric characters, and no file extension. They are stored in the\n** OS's standard temporary file directory, and are deleted prior to exit.\n** If sqlite is being embedded in another program, you may wish to change the\n** prefix to reflect your program's name, so that if your program exits\n** prematurely, old temporary files can be easily identified. This can be done\n** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line.\n**\n** 2006-10-31:  The default prefix used to be \"sqlite_\".  But then\n** Mcafee started using SQLite in their anti-virus product and it\n** started putting files with the \"sqlite\" name in the c:/temp folder.\n** This annoyed many windows users.  Those users would then do a \n** Google search for \"sqlite\", find the telephone numbers of the\n** developers and call to wake them up at night and complain.\n** For this reason, the default name prefix is changed to be \"sqlite\" \n** spelled backwards.  So the temp files are still identified, but\n** anybody smart enough to figure out the code is also likely smart\n** enough to know that calling the developer will not help get rid\n** of the file.\n*/\n#ifndef SQLITE_TEMP_FILE_PREFIX\n# define SQLITE_TEMP_FILE_PREFIX \"etilqs_\"\n#endif\n\n/*\n** The following values may be passed as the second argument to\n** sqlite3OsLock(). The various locks exhibit the following semantics:\n**\n** SHARED:    Any number of processes may hold a SHARED lock simultaneously.\n** RESERVED:  A single process may hold a RESERVED lock on a file at\n**            any time. Other processes may hold and obtain new SHARED locks.\n** PENDING:   A single process may hold a PENDING lock on a file at\n**            any one time. Existing SHARED locks may persist, but no new\n**            SHARED locks may be obtained by other processes.\n** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.\n**\n** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a\n** process that requests an EXCLUSIVE lock may actually obtain a PENDING\n** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to\n** sqlite3OsLock().\n*/\n#define NO_LOCK         0\n#define SHARED_LOCK     1\n#define RESERVED_LOCK   2\n#define PENDING_LOCK    3\n#define EXCLUSIVE_LOCK  4\n\n/*\n** File Locking Notes:  (Mostly about windows but also some info for Unix)\n**\n** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because\n** those functions are not available.  So we use only LockFile() and\n** UnlockFile().\n**\n** LockFile() prevents not just writing but also reading by other processes.\n** A SHARED_LOCK is obtained by locking a single randomly-chosen \n** byte out of a specific range of bytes. The lock byte is obtained at \n** random so two separate readers can probably access the file at the \n** same time, unless they are unlucky and choose the same lock byte.\n** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range.\n** There can only be one writer.  A RESERVED_LOCK is obtained by locking\n** a single byte of the file that is designated as the reserved lock byte.\n** A PENDING_LOCK is obtained by locking a designated byte different from\n** the RESERVED_LOCK byte.\n**\n** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,\n** which means we can use reader/writer locks.  When reader/writer locks\n** are used, the lock is placed on the same range of bytes that is used\n** for probabilistic locking in Win95/98/ME.  Hence, the locking scheme\n** will support two or more Win95 readers or two or more WinNT readers.\n** But a single Win95 reader will lock out all WinNT readers and a single\n** WinNT reader will lock out all other Win95 readers.\n**\n** The following #defines specify the range of bytes used for locking.\n** SHARED_SIZE is the number of bytes available in the pool from which\n** a random byte is selected for a shared lock.  The pool of bytes for\n** shared locks begins at SHARED_FIRST. \n**\n** The same locking strategy and\n** byte ranges are used for Unix.  This leaves open the possibility of having\n** clients on win95, winNT, and unix all talking to the same shared file\n** and all locking correctly.  To do so would require that samba (or whatever\n** tool is being used for file sharing) implements locks correctly between\n** windows and unix.  I'm guessing that isn't likely to happen, but by\n** using the same locking range we are at least open to the possibility.\n**\n** Locking in windows is manditory.  For this reason, we cannot store\n** actual data in the bytes used for locking.  The pager never allocates\n** the pages involved in locking therefore.  SHARED_SIZE is selected so\n** that all locks will fit on a single page even at the minimum page size.\n** PENDING_BYTE defines the beginning of the locks.  By default PENDING_BYTE\n** is set high so that we don't have to allocate an unused page except\n** for very large databases.  But one should test the page skipping logic \n** by setting PENDING_BYTE low and running the entire regression suite.\n**\n** Changing the value of PENDING_BYTE results in a subtly incompatible\n** file format.  Depending on how it is changed, you might not notice\n** the incompatibility right away, even running a full regression test.\n** The default location of PENDING_BYTE is the first byte past the\n** 1GB boundary.\n**\n*/\n#ifdef SQLITE_OMIT_WSD\n# define PENDING_BYTE     (0x40000000)\n#else\n# define PENDING_BYTE      sqlite3PendingByte\n#endif\n#define RESERVED_BYTE     (PENDING_BYTE+1)\n#define SHARED_FIRST      (PENDING_BYTE+2)\n#define SHARED_SIZE       510\n\n/*\n** Wrapper around OS specific sqlite3_os_init() function.\n*/\nint sqlite3OsInit(void);\n\n/* \n** Functions for accessing sqlite3_file methods \n*/\nvoid sqlite3OsClose(sqlite3_file*);\nint sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset);\nint sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset);\nint sqlite3OsTruncate(sqlite3_file*, i64 size);\nint sqlite3OsSync(sqlite3_file*, int);\nint sqlite3OsFileSize(sqlite3_file*, i64 *pSize);\nint sqlite3OsLock(sqlite3_file*, int);\nint sqlite3OsUnlock(sqlite3_file*, int);\nint sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut);\nint sqlite3OsFileControl(sqlite3_file*,int,void*);\nvoid sqlite3OsFileControlHint(sqlite3_file*,int,void*);\n#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0\nint sqlite3OsSectorSize(sqlite3_file *id);\nint sqlite3OsDeviceCharacteristics(sqlite3_file *id);\n#ifndef SQLITE_OMIT_WAL\nint sqlite3OsShmMap(sqlite3_file *,int,int,int,void volatile **);\nint sqlite3OsShmLock(sqlite3_file *id, int, int, int);\nvoid sqlite3OsShmBarrier(sqlite3_file *id);\nint sqlite3OsShmUnmap(sqlite3_file *id, int);\n#endif /* SQLITE_OMIT_WAL */\nint sqlite3OsFetch(sqlite3_file *id, i64, int, void **);\nint sqlite3OsUnfetch(sqlite3_file *, i64, void *);\n\n\n/* \n** Functions for accessing sqlite3_vfs methods \n*/\nint sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *);\nint sqlite3OsDelete(sqlite3_vfs *, const char *, int);\nint sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut);\nint sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nvoid *sqlite3OsDlOpen(sqlite3_vfs *, const char *);\nvoid sqlite3OsDlError(sqlite3_vfs *, int, char *);\nvoid (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void);\nvoid sqlite3OsDlClose(sqlite3_vfs *, void *);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nint sqlite3OsRandomness(sqlite3_vfs *, int, char *);\nint sqlite3OsSleep(sqlite3_vfs *, int);\nint sqlite3OsGetLastError(sqlite3_vfs*);\nint sqlite3OsCurrentTimeInt64(sqlite3_vfs *, sqlite3_int64*);\n\n/*\n** Convenience functions for opening and closing files using \n** sqlite3_malloc() to obtain space for the file-handle structure.\n*/\nint sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*);\nvoid sqlite3OsCloseFree(sqlite3_file *);\n\n#endif /* _SQLITE_OS_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os_common.h",
    "content": "/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains macros and a little bit of code that is common to\n** all of the platform-specific files (os_*.c) and is #included into those\n** files.\n**\n** This file should be #included by the os_*.c files only.  It is not a\n** general purpose header file.\n*/\n#ifndef _OS_COMMON_H_\n#define _OS_COMMON_H_\n\n/*\n** At least two bugs have slipped in because we changed the MEMORY_DEBUG\n** macro to SQLITE_DEBUG and some older makefiles have not yet made the\n** switch.  The following code should catch this problem at compile-time.\n*/\n#ifdef MEMORY_DEBUG\n# error \"The MEMORY_DEBUG macro is obsolete.  Use SQLITE_DEBUG instead.\"\n#endif\n\n/*\n** Macros for performance tracing.  Normally turned off.  Only works\n** on i486 hardware.\n*/\n#ifdef SQLITE_PERFORMANCE_TRACE\n\n/*\n** hwtime.h contains inline assembler code for implementing\n** high-performance timing routines.\n*/\n#include \"hwtime.h\"\n\nstatic sqlite_uint64 g_start;\nstatic sqlite_uint64 g_elapsed;\n#define TIMER_START       g_start=sqlite3Hwtime()\n#define TIMER_END         g_elapsed=sqlite3Hwtime()-g_start\n#define TIMER_ELAPSED     g_elapsed\n#else\n#define TIMER_START\n#define TIMER_END\n#define TIMER_ELAPSED     ((sqlite_uint64)0)\n#endif\n\n/*\n** If we compile with the SQLITE_TEST macro set, then the following block\n** of code will give us the ability to simulate a disk I/O error.  This\n** is used for testing the I/O recovery logic.\n*/\n#if defined(SQLITE_TEST)\nextern int sqlite3_io_error_hit;\nextern int sqlite3_io_error_hardhit;\nextern int sqlite3_io_error_pending;\nextern int sqlite3_io_error_persist;\nextern int sqlite3_io_error_benign;\nextern int sqlite3_diskfull_pending;\nextern int sqlite3_diskfull;\n#define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X)\n#define SimulateIOError(CODE)  \\\n  if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \\\n       || sqlite3_io_error_pending-- == 1 )  \\\n              { local_ioerr(); CODE; }\nstatic void local_ioerr(){\n  IOTRACE((\"IOERR\\n\"));\n  sqlite3_io_error_hit++;\n  if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++;\n}\n#define SimulateDiskfullError(CODE) \\\n   if( sqlite3_diskfull_pending ){ \\\n     if( sqlite3_diskfull_pending == 1 ){ \\\n       local_ioerr(); \\\n       sqlite3_diskfull = 1; \\\n       sqlite3_io_error_hit = 1; \\\n       CODE; \\\n     }else{ \\\n       sqlite3_diskfull_pending--; \\\n     } \\\n   }\n#else\n#define SimulateIOErrorBenign(X)\n#define SimulateIOError(A)\n#define SimulateDiskfullError(A)\n#endif /* defined(SQLITE_TEST) */\n\n/*\n** When testing, keep a count of the number of open files.\n*/\n#if defined(SQLITE_TEST)\nextern int sqlite3_open_file_count;\n#define OpenCounter(X)  sqlite3_open_file_count+=(X)\n#else\n#define OpenCounter(X)\n#endif /* defined(SQLITE_TEST) */\n\n#endif /* !defined(_OS_COMMON_H_) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os_setup.h",
    "content": "/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains pre-processor directives related to operating system\n** detection and/or setup.\n*/\n#ifndef SQLITE_OS_SETUP_H\n#define SQLITE_OS_SETUP_H\n\n/*\n** Figure out if we are dealing with Unix, Windows, or some other operating\n** system.\n**\n** After the following block of preprocess macros, all of SQLITE_OS_UNIX,\n** SQLITE_OS_WIN, and SQLITE_OS_OTHER will defined to either 1 or 0.  One of\n** the three will be 1.  The other two will be 0.\n*/\n#if defined(SQLITE_OS_OTHER)\n#  if SQLITE_OS_OTHER==1\n#    undef SQLITE_OS_UNIX\n#    define SQLITE_OS_UNIX 0\n#    undef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  else\n#    undef SQLITE_OS_OTHER\n#  endif\n#endif\n#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER)\n#  define SQLITE_OS_OTHER 0\n#  ifndef SQLITE_OS_WIN\n#    if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || \\\n        defined(__MINGW32__) || defined(__BORLANDC__)\n#      define SQLITE_OS_WIN 1\n#      define SQLITE_OS_UNIX 0\n#    else\n#      define SQLITE_OS_WIN 0\n#      define SQLITE_OS_UNIX 1\n#    endif\n#  else\n#    define SQLITE_OS_UNIX 0\n#  endif\n#else\n#  ifndef SQLITE_OS_WIN\n#    define SQLITE_OS_WIN 0\n#  endif\n#endif\n\n#endif /* SQLITE_OS_SETUP_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os_unix.c",
    "content": "/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the VFS implementation for unix-like operating systems\n** include Linux, MacOSX, *BSD, QNX, VxWorks, AIX, HPUX, and others.\n**\n** There are actually several different VFS implementations in this file.\n** The differences are in the way that file locking is done.  The default\n** implementation uses Posix Advisory Locks.  Alternative implementations\n** use flock(), dot-files, various proprietary locking schemas, or simply\n** skip locking all together.\n**\n** This source file is organized into divisions where the logic for various\n** subfunctions is contained within the appropriate division.  PLEASE\n** KEEP THE STRUCTURE OF THIS FILE INTACT.  New code should be placed\n** in the correct division and should be clearly labeled.\n**\n** The layout of divisions is as follows:\n**\n**   *  General-purpose declarations and utility functions.\n**   *  Unique file ID logic used by VxWorks.\n**   *  Various locking primitive implementations (all except proxy locking):\n**      + for Posix Advisory Locks\n**      + for no-op locks\n**      + for dot-file locks\n**      + for flock() locking\n**      + for named semaphore locks (VxWorks only)\n**      + for AFP filesystem locks (MacOSX only)\n**   *  sqlite3_file methods not associated with locking.\n**   *  Definitions of sqlite3_io_methods objects for all locking\n**      methods plus \"finder\" functions for each locking method.\n**   *  sqlite3_vfs method implementations.\n**   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)\n**   *  Definitions of sqlite3_vfs objects for all locking methods\n**      plus implementations of sqlite3_os_init() and sqlite3_os_end().\n*/\n#include \"sqliteInt.h\"\n#if SQLITE_OS_UNIX              /* This file is used on unix only */\n\n/*\n** There are various methods for file locking used for concurrency\n** control:\n**\n**   1. POSIX locking (the default),\n**   2. No locking,\n**   3. Dot-file locking,\n**   4. flock() locking,\n**   5. AFP locking (OSX only),\n**   6. Named POSIX semaphores (VXWorks only),\n**   7. proxy locking. (OSX only)\n**\n** Styles 4, 5, and 7 are only available of SQLITE_ENABLE_LOCKING_STYLE\n** is defined to 1.  The SQLITE_ENABLE_LOCKING_STYLE also enables automatic\n** selection of the appropriate locking style based on the filesystem\n** where the database is located.  \n*/\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/* Use pread() and pwrite() if they are available */\n#if defined(__APPLE__)\n# define HAVE_PREAD 1\n# define HAVE_PWRITE 1\n#endif\n#if defined(HAVE_PREAD64) && defined(HAVE_PWRITE64)\n# undef USE_PREAD\n# define USE_PREAD64 1\n#elif defined(HAVE_PREAD) && defined(HAVE_PWRITE)\n# undef USE_PREAD64\n# define USE_PREAD 1\n#endif\n\n/*\n** standard include files.\n*/\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <sys/ioctl.h>\n#include <unistd.h>\n#include <time.h>\n#include <sys/time.h>\n#include <errno.h>\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n# include <sys/mman.h>\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n# include <sys/ioctl.h>\n# include <sys/file.h>\n# include <sys/param.h>\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */\n\n#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \\\n                           (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))\n#  if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \\\n       && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))\n#    define HAVE_GETHOSTUUID 1\n#  else\n#    warning \"gethostuuid() is disabled.\"\n#  endif\n#endif\n\n\n#if OS_VXWORKS\n# include <sys/ioctl.h>\n# include <semaphore.h>\n# include <limits.h>\n#endif /* OS_VXWORKS */\n\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n# include <sys/mount.h>\n#endif\n\n#ifdef HAVE_UTIME\n# include <utime.h>\n#endif\n\n/*\n** Allowed values of unixFile.fsFlags\n*/\n#define SQLITE_FSFLAGS_IS_MSDOS     0x1\n\n/*\n** If we are to be thread-safe, include the pthreads header and define\n** the SQLITE_UNIX_THREADS macro.\n*/\n#if SQLITE_THREADSAFE\n# include <pthread.h>\n# define SQLITE_UNIX_THREADS 1\n#endif\n\n/*\n** Default permissions when creating a new file\n*/\n#ifndef SQLITE_DEFAULT_FILE_PERMISSIONS\n# define SQLITE_DEFAULT_FILE_PERMISSIONS 0644\n#endif\n\n/*\n** Default permissions when creating auto proxy dir\n*/\n#ifndef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n# define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755\n#endif\n\n/*\n** Maximum supported path-length.\n*/\n#define MAX_PATHNAME 512\n\n/*\n** Maximum supported symbolic links\n*/\n#define SQLITE_MAX_SYMLINKS 100\n\n/* Always cast the getpid() return type for compatibility with\n** kernel modules in VxWorks. */\n#define osGetpid(X) (pid_t)getpid()\n\n/*\n** Only set the lastErrno if the error code is a real error and not \n** a normal expected return code of SQLITE_BUSY or SQLITE_OK\n*/\n#define IS_LOCK_ERROR(x)  ((x != SQLITE_OK) && (x != SQLITE_BUSY))\n\n/* Forward references */\ntypedef struct unixShm unixShm;               /* Connection shared memory */\ntypedef struct unixShmNode unixShmNode;       /* Shared memory instance */\ntypedef struct unixInodeInfo unixInodeInfo;   /* An i-node */\ntypedef struct UnixUnusedFd UnixUnusedFd;     /* An unused file descriptor */\n\n/*\n** Sometimes, after a file handle is closed by SQLite, the file descriptor\n** cannot be closed immediately. In these cases, instances of the following\n** structure are used to store the file descriptor while waiting for an\n** opportunity to either close or reuse it.\n*/\nstruct UnixUnusedFd {\n  int fd;                   /* File descriptor to close */\n  int flags;                /* Flags this file descriptor was opened with */\n  UnixUnusedFd *pNext;      /* Next unused file descriptor on same file */\n};\n\n/*\n** The unixFile structure is subclass of sqlite3_file specific to the unix\n** VFS implementations.\n*/\ntypedef struct unixFile unixFile;\nstruct unixFile {\n  sqlite3_io_methods const *pMethod;  /* Always the first entry */\n  sqlite3_vfs *pVfs;                  /* The VFS that created this unixFile */\n  unixInodeInfo *pInode;              /* Info about locks on this inode */\n  int h;                              /* The file descriptor */\n  unsigned char eFileLock;            /* The type of lock held on this fd */\n  unsigned short int ctrlFlags;       /* Behavioral bits.  UNIXFILE_* flags */\n  int lastErrno;                      /* The unix errno from last I/O error */\n  void *lockingContext;               /* Locking style specific state */\n  UnixUnusedFd *pPreallocatedUnused;  /* Pre-allocated UnixUnusedFd */\n  const char *zPath;                  /* Name of the file */\n  unixShm *pShm;                      /* Shared memory segment information */\n  int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                      /* Number of outstanding xFetch refs */\n  sqlite3_int64 mmapSize;             /* Usable size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeActual;       /* Actual size of mapping at pMapRegion */\n  sqlite3_int64 mmapSizeMax;          /* Configured FCNTL_MMAP_SIZE value */\n  void *pMapRegion;                   /* Memory mapped region */\n#endif\n  int sectorSize;                     /* Device sector size */\n  int deviceCharacteristics;          /* Precomputed device characteristics */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int openFlags;                      /* The flags specified at open() */\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)\n  unsigned fsFlags;                   /* cached details from statfs() */\n#endif\n#if OS_VXWORKS\n  struct vxworksFileId *pId;          /* Unique file ID */\n#endif\n#ifdef SQLITE_DEBUG\n  /* The next group of variables are used to track whether or not the\n  ** transaction counter in bytes 24-27 of database files are updated\n  ** whenever any part of the database changes.  An assertion fault will\n  ** occur if a file is updated without also updating the transaction\n  ** counter.  This test is made to avoid new problems similar to the\n  ** one described by ticket #3584. \n  */\n  unsigned char transCntrChng;   /* True if the transaction counter changed */\n  unsigned char dbUpdate;        /* True if any part of database file changed */\n  unsigned char inNormalWrite;   /* True if in a normal write operation */\n\n#endif\n\n#ifdef SQLITE_TEST\n  /* In test mode, increase the size of this structure a bit so that \n  ** it is larger than the struct CrashFile defined in test6.c.\n  */\n  char aPadding[32];\n#endif\n};\n\n/* This variable holds the process id (pid) from when the xRandomness()\n** method was called.  If xOpen() is called from a different process id,\n** indicating that a fork() has occurred, the PRNG will be reset.\n*/\nstatic pid_t randomnessPid = 0;\n\n/*\n** Allowed values for the unixFile.ctrlFlags bitmask:\n*/\n#define UNIXFILE_EXCL        0x01     /* Connections from one process only */\n#define UNIXFILE_RDONLY      0x02     /* Connection is read only */\n#define UNIXFILE_PERSIST_WAL 0x04     /* Persistent WAL mode */\n#ifndef SQLITE_DISABLE_DIRSYNC\n# define UNIXFILE_DIRSYNC    0x08     /* Directory sync needed */\n#else\n# define UNIXFILE_DIRSYNC    0x00\n#endif\n#define UNIXFILE_PSOW        0x10     /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n#define UNIXFILE_DELETE      0x20     /* Delete on close */\n#define UNIXFILE_URI         0x40     /* Filename might have query parameters */\n#define UNIXFILE_NOLOCK      0x80     /* Do no file locking */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n#include \"os_common.h\"\n\n/*\n** Define various macros that are missing from some systems.\n*/\n#ifndef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifdef SQLITE_DISABLE_LFS\n# undef O_LARGEFILE\n# define O_LARGEFILE 0\n#endif\n#ifndef O_NOFOLLOW\n# define O_NOFOLLOW 0\n#endif\n#ifndef O_BINARY\n# define O_BINARY 0\n#endif\n\n/*\n** The threadid macro resolves to the thread-id or to 0.  Used for\n** testing and debugging only.\n*/\n#if SQLITE_THREADSAFE\n#define threadid pthread_self()\n#else\n#define threadid 0\n#endif\n\n/*\n** HAVE_MREMAP defaults to true on Linux and false everywhere else.\n*/\n#if !defined(HAVE_MREMAP)\n# if defined(__linux__) && defined(_GNU_SOURCE)\n#  define HAVE_MREMAP 1\n# else\n#  define HAVE_MREMAP 0\n# endif\n#endif\n\n/*\n** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek()\n** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined.\n*/\n#ifdef __ANDROID__\n# define lseek lseek64\n#endif\n\n#ifdef __linux__\n/*\n** Linux-specific IOCTL magic numbers used for controlling F2FS\n*/\n#define F2FS_IOCTL_MAGIC        0xf5\n#define F2FS_IOC_START_ATOMIC_WRITE     _IO(F2FS_IOCTL_MAGIC, 1)\n#define F2FS_IOC_COMMIT_ATOMIC_WRITE    _IO(F2FS_IOCTL_MAGIC, 2)\n#define F2FS_IOC_START_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 3)\n#define F2FS_IOC_ABORT_VOLATILE_WRITE   _IO(F2FS_IOCTL_MAGIC, 5)\n#define F2FS_IOC_GET_FEATURES           _IOR(F2FS_IOCTL_MAGIC, 12, u32)\n#define F2FS_FEATURE_ATOMIC_WRITE 0x0004\n#endif /* __linux__ */\n\n\n/*\n** Different Unix systems declare open() in different ways.  Same use\n** open(const char*,int,mode_t).  Others use open(const char*,int,...).\n** The difference is important when using a pointer to the function.\n**\n** The safest way to deal with the problem is to always use this wrapper\n** which always has the same well-defined interface.\n*/\nstatic int posixOpen(const char *zFile, int flags, int mode){\n  return open(zFile, flags, mode);\n}\n\n/* Forward reference */\nstatic int openDirectory(const char*, int*);\nstatic int unixGetpagesize(void);\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct unix_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n  { \"open\",         (sqlite3_syscall_ptr)posixOpen,  0  },\n#define osOpen      ((int(*)(const char*,int,int))aSyscall[0].pCurrent)\n\n  { \"close\",        (sqlite3_syscall_ptr)close,      0  },\n#define osClose     ((int(*)(int))aSyscall[1].pCurrent)\n\n  { \"access\",       (sqlite3_syscall_ptr)access,     0  },\n#define osAccess    ((int(*)(const char*,int))aSyscall[2].pCurrent)\n\n  { \"getcwd\",       (sqlite3_syscall_ptr)getcwd,     0  },\n#define osGetcwd    ((char*(*)(char*,size_t))aSyscall[3].pCurrent)\n\n  { \"stat\",         (sqlite3_syscall_ptr)stat,       0  },\n#define osStat      ((int(*)(const char*,struct stat*))aSyscall[4].pCurrent)\n\n/*\n** The DJGPP compiler environment looks mostly like Unix, but it\n** lacks the fcntl() system call.  So redefine fcntl() to be something\n** that always succeeds.  This means that locking does not occur under\n** DJGPP.  But it is DOS - what did you expect?\n*/\n#ifdef __DJGPP__\n  { \"fstat\",        0,                 0  },\n#define osFstat(a,b,c)    0\n#else     \n  { \"fstat\",        (sqlite3_syscall_ptr)fstat,      0  },\n#define osFstat     ((int(*)(int,struct stat*))aSyscall[5].pCurrent)\n#endif\n\n  { \"ftruncate\",    (sqlite3_syscall_ptr)ftruncate,  0  },\n#define osFtruncate ((int(*)(int,off_t))aSyscall[6].pCurrent)\n\n  { \"fcntl\",        (sqlite3_syscall_ptr)fcntl,      0  },\n#define osFcntl     ((int(*)(int,int,...))aSyscall[7].pCurrent)\n\n  { \"read\",         (sqlite3_syscall_ptr)read,       0  },\n#define osRead      ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pread\",        (sqlite3_syscall_ptr)pread,      0  },\n#else\n  { \"pread\",        (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pread64\",      (sqlite3_syscall_ptr)pread64,    0  },\n#else\n  { \"pread64\",      (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)\n\n  { \"write\",        (sqlite3_syscall_ptr)write,      0  },\n#define osWrite     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)\n\n#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE\n  { \"pwrite\",       (sqlite3_syscall_ptr)pwrite,     0  },\n#else\n  { \"pwrite\",       (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                    aSyscall[12].pCurrent)\n\n#if defined(USE_PREAD64)\n  { \"pwrite64\",     (sqlite3_syscall_ptr)pwrite64,   0  },\n#else\n  { \"pwrite64\",     (sqlite3_syscall_ptr)0,          0  },\n#endif\n#define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\\\n                    aSyscall[13].pCurrent)\n\n  { \"fchmod\",       (sqlite3_syscall_ptr)fchmod,          0  },\n#define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n  { \"fallocate\",    (sqlite3_syscall_ptr)posix_fallocate,  0 },\n#else\n  { \"fallocate\",    (sqlite3_syscall_ptr)0,                0 },\n#endif\n#define osFallocate ((int(*)(int,off_t,off_t))aSyscall[15].pCurrent)\n\n  { \"unlink\",       (sqlite3_syscall_ptr)unlink,           0 },\n#define osUnlink    ((int(*)(const char*))aSyscall[16].pCurrent)\n\n  { \"openDirectory\",    (sqlite3_syscall_ptr)openDirectory,      0 },\n#define osOpenDirectory ((int(*)(const char*,int*))aSyscall[17].pCurrent)\n\n  { \"mkdir\",        (sqlite3_syscall_ptr)mkdir,           0 },\n#define osMkdir     ((int(*)(const char*,mode_t))aSyscall[18].pCurrent)\n\n  { \"rmdir\",        (sqlite3_syscall_ptr)rmdir,           0 },\n#define osRmdir     ((int(*)(const char*))aSyscall[19].pCurrent)\n\n#if defined(HAVE_FCHOWN)\n  { \"fchown\",       (sqlite3_syscall_ptr)fchown,          0 },\n#else\n  { \"fchown\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osFchown    ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)\n\n  { \"geteuid\",      (sqlite3_syscall_ptr)geteuid,         0 },\n#define osGeteuid   ((uid_t(*)(void))aSyscall[21].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"mmap\",         (sqlite3_syscall_ptr)mmap,            0 },\n#else\n  { \"mmap\",         (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMmap ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[22].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"munmap\",       (sqlite3_syscall_ptr)munmap,          0 },\n#else\n  { \"munmap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent)\n\n#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"mremap\",       (sqlite3_syscall_ptr)mremap,          0 },\n#else\n  { \"mremap\",       (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[24].pCurrent)\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"getpagesize\",  (sqlite3_syscall_ptr)unixGetpagesize, 0 },\n#else\n  { \"getpagesize\",  (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osGetpagesize ((int(*)(void))aSyscall[25].pCurrent)\n\n#if defined(HAVE_READLINK)\n  { \"readlink\",     (sqlite3_syscall_ptr)readlink,        0 },\n#else\n  { \"readlink\",     (sqlite3_syscall_ptr)0,               0 },\n#endif\n#define osReadlink ((ssize_t(*)(const char*,char*,size_t))aSyscall[26].pCurrent)\n\n#if defined(HAVE_LSTAT)\n  { \"lstat\",         (sqlite3_syscall_ptr)lstat,          0 },\n#else\n  { \"lstat\",         (sqlite3_syscall_ptr)0,              0 },\n#endif\n#define osLstat      ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent)\n\n  { \"ioctl\",         (sqlite3_syscall_ptr)ioctl,          0 },\n#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n\n/*\n** On some systems, calls to fchown() will trigger a message in a security\n** log if they come from non-root processes.  So avoid calling fchown() if\n** we are not running as root.\n*/\nstatic int robustFchown(int fd, uid_t uid, gid_t gid){\n#if defined(HAVE_FCHOWN)\n  return osGeteuid() ? 0 : osFchown(fd,uid,gid);\n#else\n  return 0;\n#endif\n}\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"unix\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int unixSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr unixGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n/*\n** Do not accept any file descriptor less than this value, in order to avoid\n** opening database file using file descriptors that are commonly used for \n** standard input, output, and error.\n*/\n#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR\n# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3\n#endif\n\n/*\n** Invoke open().  Do so multiple times, until it either succeeds or\n** fails for some reason other than EINTR.\n**\n** If the file creation mode \"m\" is 0 then set it to the default for\n** SQLite.  The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally\n** 0644) as modified by the system umask.  If m is not 0, then\n** make the file creation mode be exactly m ignoring the umask.\n**\n** The m parameter will be non-zero only when creating -wal, -journal,\n** and -shm files.  We want those files to have *exactly* the same\n** permissions as their original database, unadulterated by the umask.\n** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a\n** transaction crashes and leaves behind hot journals, then any\n** process that is able to write to the database will also be able to\n** recover the hot journals.\n*/\nstatic int robust_open(const char *z, int f, mode_t m){\n  int fd;\n  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;\n  while(1){\n#if defined(O_CLOEXEC)\n    fd = osOpen(z,f|O_CLOEXEC,m2);\n#else\n    fd = osOpen(z,f,m2);\n#endif\n    if( fd<0 ){\n      if( errno==EINTR ) continue;\n      break;\n    }\n    if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;\n    osClose(fd);\n    sqlite3_log(SQLITE_WARNING, \n                \"attempt to open \\\"%s\\\" as file descriptor %d\", z, fd);\n    fd = -1;\n    if( osOpen(\"/dev/null\", f, m)<0 ) break;\n  }\n  if( fd>=0 ){\n    if( m!=0 ){\n      struct stat statbuf;\n      if( osFstat(fd, &statbuf)==0 \n       && statbuf.st_size==0\n       && (statbuf.st_mode&0777)!=m \n      ){\n        osFchmod(fd, m);\n      }\n    }\n#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)\n    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);\n#endif\n  }\n  return fd;\n}\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the unixInodeInfo and\n** vxworksFileId objects used by this file, all of which may be \n** shared by multiple threads.\n**\n** Function unixMutexHeld() is used to assert() that the global mutex \n** is held when required. This function is only used as part of assert() \n** statements. e.g.\n**\n**   unixEnterMutex()\n**     assert( unixMutexHeld() );\n**   unixEnterLeave()\n*/\nstatic void unixEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\nstatic void unixLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#ifdef SQLITE_DEBUG\nstatic int unixMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#endif\n\n\n#ifdef SQLITE_HAVE_OS_TRACE\n/*\n** Helper function for printing out trace information from debugging\n** binaries. This returns the string representation of the supplied\n** integer lock-type.\n*/\nstatic const char *azFileLock(int eFileLock){\n  switch( eFileLock ){\n    case NO_LOCK: return \"NONE\";\n    case SHARED_LOCK: return \"SHARED\";\n    case RESERVED_LOCK: return \"RESERVED\";\n    case PENDING_LOCK: return \"PENDING\";\n    case EXCLUSIVE_LOCK: return \"EXCLUSIVE\";\n  }\n  return \"ERROR\";\n}\n#endif\n\n#ifdef SQLITE_LOCK_TRACE\n/*\n** Print out information about all locking operations.\n**\n** This routine is used for troubleshooting locks on multithreaded\n** platforms.  Enable by compiling with the -DSQLITE_LOCK_TRACE\n** command-line option on the compiler.  This code is normally\n** turned off.\n*/\nstatic int lockTrace(int fd, int op, struct flock *p){\n  char *zOpName, *zType;\n  int s;\n  int savedErrno;\n  if( op==F_GETLK ){\n    zOpName = \"GETLK\";\n  }else if( op==F_SETLK ){\n    zOpName = \"SETLK\";\n  }else{\n    s = osFcntl(fd, op, p);\n    sqlite3DebugPrintf(\"fcntl unknown %d %d %d\\n\", fd, op, s);\n    return s;\n  }\n  if( p->l_type==F_RDLCK ){\n    zType = \"RDLCK\";\n  }else if( p->l_type==F_WRLCK ){\n    zType = \"WRLCK\";\n  }else if( p->l_type==F_UNLCK ){\n    zType = \"UNLCK\";\n  }else{\n    assert( 0 );\n  }\n  assert( p->l_whence==SEEK_SET );\n  s = osFcntl(fd, op, p);\n  savedErrno = errno;\n  sqlite3DebugPrintf(\"fcntl %d %d %s %s %d %d %d %d\\n\",\n     threadid, fd, zOpName, zType, (int)p->l_start, (int)p->l_len,\n     (int)p->l_pid, s);\n  if( s==(-1) && op==F_SETLK && (p->l_type==F_RDLCK || p->l_type==F_WRLCK) ){\n    struct flock l2;\n    l2 = *p;\n    osFcntl(fd, F_GETLK, &l2);\n    if( l2.l_type==F_RDLCK ){\n      zType = \"RDLCK\";\n    }else if( l2.l_type==F_WRLCK ){\n      zType = \"WRLCK\";\n    }else if( l2.l_type==F_UNLCK ){\n      zType = \"UNLCK\";\n    }else{\n      assert( 0 );\n    }\n    sqlite3DebugPrintf(\"fcntl-failure-reason: %s %d %d %d\\n\",\n       zType, (int)l2.l_start, (int)l2.l_len, (int)l2.l_pid);\n  }\n  errno = savedErrno;\n  return s;\n}\n#undef osFcntl\n#define osFcntl lockTrace\n#endif /* SQLITE_LOCK_TRACE */\n\n/*\n** Retry ftruncate() calls that fail due to EINTR\n**\n** All calls to ftruncate() within this file should be made through\n** this wrapper.  On the Android platform, bypassing the logic below\n** could lead to a corrupt database.\n*/\nstatic int robust_ftruncate(int h, sqlite3_int64 sz){\n  int rc;\n#ifdef __ANDROID__\n  /* On Android, ftruncate() always uses 32-bit offsets, even if \n  ** _FILE_OFFSET_BITS=64 is defined. This means it is unsafe to attempt to\n  ** truncate a file to any size larger than 2GiB. Silently ignore any\n  ** such attempts.  */\n  if( sz>(sqlite3_int64)0x7FFFFFFF ){\n    rc = SQLITE_OK;\n  }else\n#endif\n  do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n\n/*\n** This routine translates a standard POSIX errno code into something\n** useful to the clients of the sqlite3 functions.  Specifically, it is\n** intended to translate a variety of \"try again\" errors into SQLITE_BUSY\n** and a variety of \"please close the file descriptor NOW\" errors into \n** SQLITE_IOERR\n** \n** Errors during initialization of locks, or file system support for locks,\n** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.\n*/\nstatic int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {\n  assert( (sqliteIOErr == SQLITE_IOERR_LOCK) || \n          (sqliteIOErr == SQLITE_IOERR_UNLOCK) || \n          (sqliteIOErr == SQLITE_IOERR_RDLOCK) ||\n          (sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) );\n  switch (posixError) {\n  case EACCES: \n  case EAGAIN:\n  case ETIMEDOUT:\n  case EBUSY:\n  case EINTR:\n  case ENOLCK:  \n    /* random NFS retry error, unless during file system support \n     * introspection, in which it actually means what it says */\n    return SQLITE_BUSY;\n    \n  case EPERM: \n    return SQLITE_PERM;\n    \n  default: \n    return sqliteIOErr;\n  }\n}\n\n\n/******************************************************************************\n****************** Begin Unique File ID Utility Used By VxWorks ***************\n**\n** On most versions of unix, we can get a unique ID for a file by concatenating\n** the device number and the inode number.  But this does not work on VxWorks.\n** On VxWorks, a unique file id must be based on the canonical filename.\n**\n** A pointer to an instance of the following structure can be used as a\n** unique file ID in VxWorks.  Each instance of this structure contains\n** a copy of the canonical filename.  There is also a reference count.  \n** The structure is reclaimed when the number of pointers to it drops to\n** zero.\n**\n** There are never very many files open at one time and lookups are not\n** a performance-critical path, so it is sufficient to put these\n** structures on a linked list.\n*/\nstruct vxworksFileId {\n  struct vxworksFileId *pNext;  /* Next in a list of them all */\n  int nRef;                     /* Number of references to this one */\n  int nName;                    /* Length of the zCanonicalName[] string */\n  char *zCanonicalName;         /* Canonical filename */\n};\n\n#if OS_VXWORKS\n/* \n** All unique filenames are held on a linked list headed by this\n** variable:\n*/\nstatic struct vxworksFileId *vxworksFileList = 0;\n\n/*\n** Simplify a filename into its canonical form\n** by making the following changes:\n**\n**  * removing any trailing and duplicate /\n**  * convert /./ into just /\n**  * convert /A/../ where A is any simple name into just /\n**\n** Changes are made in-place.  Return the new name length.\n**\n** The original filename is in z[0..n-1].  Return the number of\n** characters in the simplified name.\n*/\nstatic int vxworksSimplifyName(char *z, int n){\n  int i, j;\n  while( n>1 && z[n-1]=='/' ){ n--; }\n  for(i=j=0; i<n; i++){\n    if( z[i]=='/' ){\n      if( z[i+1]=='/' ) continue;\n      if( z[i+1]=='.' && i+2<n && z[i+2]=='/' ){\n        i += 1;\n        continue;\n      }\n      if( z[i+1]=='.' && i+3<n && z[i+2]=='.' && z[i+3]=='/' ){\n        while( j>0 && z[j-1]!='/' ){ j--; }\n        if( j>0 ){ j--; }\n        i += 2;\n        continue;\n      }\n    }\n    z[j++] = z[i];\n  }\n  z[j] = 0;\n  return j;\n}\n\n/*\n** Find a unique file ID for the given absolute pathname.  Return\n** a pointer to the vxworksFileId object.  This pointer is the unique\n** file ID.\n**\n** The nRef field of the vxworksFileId object is incremented before\n** the object is returned.  A new vxworksFileId object is created\n** and added to the global list if necessary.\n**\n** If a memory allocation error occurs, return NULL.\n*/\nstatic struct vxworksFileId *vxworksFindFileId(const char *zAbsoluteName){\n  struct vxworksFileId *pNew;         /* search key and new file ID */\n  struct vxworksFileId *pCandidate;   /* For looping over existing file IDs */\n  int n;                              /* Length of zAbsoluteName string */\n\n  assert( zAbsoluteName[0]=='/' );\n  n = (int)strlen(zAbsoluteName);\n  pNew = sqlite3_malloc64( sizeof(*pNew) + (n+1) );\n  if( pNew==0 ) return 0;\n  pNew->zCanonicalName = (char*)&pNew[1];\n  memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);\n  n = vxworksSimplifyName(pNew->zCanonicalName, n);\n\n  /* Search for an existing entry that matching the canonical name.\n  ** If found, increment the reference count and return a pointer to\n  ** the existing file ID.\n  */\n  unixEnterMutex();\n  for(pCandidate=vxworksFileList; pCandidate; pCandidate=pCandidate->pNext){\n    if( pCandidate->nName==n \n     && memcmp(pCandidate->zCanonicalName, pNew->zCanonicalName, n)==0\n    ){\n       sqlite3_free(pNew);\n       pCandidate->nRef++;\n       unixLeaveMutex();\n       return pCandidate;\n    }\n  }\n\n  /* No match was found.  We will make a new file ID */\n  pNew->nRef = 1;\n  pNew->nName = n;\n  pNew->pNext = vxworksFileList;\n  vxworksFileList = pNew;\n  unixLeaveMutex();\n  return pNew;\n}\n\n/*\n** Decrement the reference count on a vxworksFileId object.  Free\n** the object when the reference count reaches zero.\n*/\nstatic void vxworksReleaseFileId(struct vxworksFileId *pId){\n  unixEnterMutex();\n  assert( pId->nRef>0 );\n  pId->nRef--;\n  if( pId->nRef==0 ){\n    struct vxworksFileId **pp;\n    for(pp=&vxworksFileList; *pp && *pp!=pId; pp = &((*pp)->pNext)){}\n    assert( *pp==pId );\n    *pp = pId->pNext;\n    sqlite3_free(pId);\n  }\n  unixLeaveMutex();\n}\n#endif /* OS_VXWORKS */\n/*************** End of Unique File ID Utility Used By VxWorks ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Posix Advisory Locking ****************************\n**\n** POSIX advisory locks are broken by design.  ANSI STD 1003.1 (1996)\n** section 6.5.2.2 lines 483 through 490 specify that when a process\n** sets or clears a lock, that operation overrides any prior locks set\n** by the same process.  It does not explicitly say so, but this implies\n** that it overrides locks set by the same process using a different\n** file descriptor.  Consider this test case:\n**\n**       int fd1 = open(\"./file1\", O_RDWR|O_CREAT, 0644);\n**       int fd2 = open(\"./file2\", O_RDWR|O_CREAT, 0644);\n**\n** Suppose ./file1 and ./file2 are really the same file (because\n** one is a hard or symbolic link to the other) then if you set\n** an exclusive lock on fd1, then try to get an exclusive lock\n** on fd2, it works.  I would have expected the second lock to\n** fail since there was already a lock on the file due to fd1.\n** But not so.  Since both locks came from the same process, the\n** second overrides the first, even though they were on different\n** file descriptors opened on different file names.\n**\n** This means that we cannot use POSIX locks to synchronize file access\n** among competing threads of the same process.  POSIX locks will work fine\n** to synchronize access for threads in separate processes, but not\n** threads within the same process.\n**\n** To work around the problem, SQLite has to manage file locks internally\n** on its own.  Whenever a new database is opened, we have to find the\n** specific inode of the database file (the inode is determined by the\n** st_dev and st_ino fields of the stat structure that fstat() fills in)\n** and check for locks already existing on that inode.  When locks are\n** created or removed, we have to look at our own internal record of the\n** locks to see if another thread has previously set a lock on that same\n** inode.\n**\n** (Aside: The use of inode numbers as unique IDs does not work on VxWorks.\n** For VxWorks, we have to use the alternative unique ID system based on\n** canonical filename and implemented in the previous division.)\n**\n** The sqlite3_file structure for POSIX is no longer just an integer file\n** descriptor.  It is now a structure that holds the integer file\n** descriptor and a pointer to a structure that describes the internal\n** locks on the corresponding inode.  There is one locking structure\n** per inode, so if the same inode is opened twice, both unixFile structures\n** point to the same locking structure.  The locking structure keeps\n** a reference count (so we will know when to delete it) and a \"cnt\"\n** field that tells us its internal lock status.  cnt==0 means the\n** file is unlocked.  cnt==-1 means the file has an exclusive lock.\n** cnt>0 means there are cnt shared locks on the file.\n**\n** Any attempt to lock or unlock a file first checks the locking\n** structure.  The fcntl() system call is only invoked to set a \n** POSIX lock if the internal lock structure transitions between\n** a locked and an unlocked state.\n**\n** But wait:  there are yet more problems with POSIX advisory locks.\n**\n** If you close a file descriptor that points to a file that has locks,\n** all locks on that file that are owned by the current process are\n** released.  To work around this problem, each unixInodeInfo object\n** maintains a count of the number of pending locks on tha inode.\n** When an attempt is made to close an unixFile, if there are\n** other unixFile open on the same inode that are holding locks, the call\n** to close() the file descriptor is deferred until all of the locks clear.\n** The unixInodeInfo structure keeps a list of file descriptors that need to\n** be closed and that list is walked (and cleared) when the last lock\n** clears.\n**\n** Yet another problem:  LinuxThreads do not play well with posix locks.\n**\n** Many older versions of linux use the LinuxThreads library which is\n** not posix compliant.  Under LinuxThreads, a lock created by thread\n** A cannot be modified or overridden by a different thread B.\n** Only thread A can modify the lock.  Locking behavior is correct\n** if the appliation uses the newer Native Posix Thread Library (NPTL)\n** on linux - with NPTL a lock created by thread A can override locks\n** in thread B.  But there is no way to know at compile-time which\n** threading library is being used.  So there is no way to know at\n** compile-time whether or not thread A can override locks on thread B.\n** One has to do a run-time check to discover the behavior of the\n** current process.\n**\n** SQLite used to support LinuxThreads.  But support for LinuxThreads\n** was dropped beginning with version 3.7.0.  SQLite will still work with\n** LinuxThreads provided that (1) there is no more than one connection \n** per database file in the same process and (2) database connections\n** do not move across threads.\n*/\n\n/*\n** An instance of the following structure serves as the key used\n** to locate a particular unixInodeInfo object.\n*/\nstruct unixFileId {\n  dev_t dev;                  /* Device number */\n#if OS_VXWORKS\n  struct vxworksFileId *pId;  /* Unique file ID for vxworks. */\n#else\n  /* We are told that some versions of Android contain a bug that\n  ** sizes ino_t at only 32-bits instead of 64-bits. (See\n  ** https://android-review.googlesource.com/#/c/115351/3/dist/sqlite3.c)\n  ** To work around this, always allocate 64-bits for the inode number.  \n  ** On small machines that only have 32-bit inodes, this wastes 4 bytes,\n  ** but that should not be a big deal. */\n  /* WAS:  ino_t ino;   */\n  u64 ino;                   /* Inode number */\n#endif\n};\n\n/*\n** An instance of the following structure is allocated for each open\n** inode.  Or, on LinuxThreads, there is one of these structures for\n** each inode opened by each thread.\n**\n** A single inode can have multiple file descriptors, so each unixFile\n** structure contains a pointer to an instance of this object and this\n** object keeps a count of the number of unixFile pointing to it.\n*/\nstruct unixInodeInfo {\n  struct unixFileId fileId;       /* The lookup key */\n  int nShared;                    /* Number of SHARED locks held */\n  unsigned char eFileLock;        /* One of SHARED_LOCK, RESERVED_LOCK etc. */\n  unsigned char bProcessLock;     /* An exclusive process lock is held */\n  int nRef;                       /* Number of pointers to this structure */\n  unixShmNode *pShmNode;          /* Shared memory associated with this inode */\n  int nLock;                      /* Number of outstanding file locks */\n  UnixUnusedFd *pUnused;          /* Unused file descriptors to close */\n  unixInodeInfo *pNext;           /* List of all unixInodeInfo objects */\n  unixInodeInfo *pPrev;           /*    .... doubly linked */\n#if SQLITE_ENABLE_LOCKING_STYLE\n  unsigned long long sharedByte;  /* for AFP simulated shared lock */\n#endif\n#if OS_VXWORKS\n  sem_t *pSem;                    /* Named POSIX semaphore */\n  char aSemName[MAX_PATHNAME+2];  /* Name of that semaphore */\n#endif\n};\n\n/*\n** A lists of all unixInodeInfo objects.\n*/\nstatic unixInodeInfo *inodeList = 0;  /* All unixInodeInfo objects */\nstatic unsigned int nUnusedFd = 0;    /* Total unused file descriptors */\n\n/*\n**\n** This function - unixLogErrorAtLine(), is only ever called via the macro\n** unixLogError().\n**\n** It is invoked after an error occurs in an OS function and errno has been\n** set. It logs a message using sqlite3_log() containing the current value of\n** errno and, if possible, the human-readable equivalent from strerror() or\n** strerror_r().\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN). \n** The two subsequent arguments should be the name of the OS function that\n** failed (e.g. \"unlink\", \"open\") and the associated file-system path,\n** if any.\n*/\n#define unixLogError(a,b,c)     unixLogErrorAtLine(a,b,c,__LINE__)\nstatic int unixLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char *zErr;                     /* Message from strerror() or equivalent */\n  int iErrno = errno;             /* Saved syscall error number */\n\n  /* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use\n  ** the strerror() function to obtain the human-readable error message\n  ** equivalent to errno. Otherwise, use strerror_r().\n  */ \n#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)\n  char aErr[80];\n  memset(aErr, 0, sizeof(aErr));\n  zErr = aErr;\n\n  /* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,\n  ** assume that the system provides the GNU version of strerror_r() that\n  ** returns a pointer to a buffer containing the error message. That pointer \n  ** may point to aErr[], or it may point to some static storage somewhere. \n  ** Otherwise, assume that the system provides the POSIX version of \n  ** strerror_r(), which always writes an error message into aErr[].\n  **\n  ** If the code incorrectly assumes that it is the POSIX version that is\n  ** available, the error message will often be an empty string. Not a\n  ** huge problem. Incorrectly concluding that the GNU version is available \n  ** could lead to a segfault though.\n  */\n#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)\n  zErr = \n# endif\n  strerror_r(iErrno, aErr, sizeof(aErr)-1);\n\n#elif SQLITE_THREADSAFE\n  /* This is a threadsafe build, but strerror_r() is not available. */\n  zErr = \"\";\n#else\n  /* Non-threadsafe build, use strerror(). */\n  zErr = strerror(iErrno);\n#endif\n\n  if( zPath==0 ) zPath = \"\";\n  sqlite3_log(errcode,\n      \"os_unix.c:%d: (%d) %s(%s) - %s\",\n      iLine, iErrno, zFunc, zPath, zErr\n  );\n\n  return errcode;\n}\n\n/*\n** Close a file descriptor.\n**\n** We assume that close() almost always works, since it is only in a\n** very sick application or on a very sick platform that it might fail.\n** If it does fail, simply leak the file descriptor, but do log the\n** error.\n**\n** Note that it is not safe to retry close() after EINTR since the\n** file descriptor might have already been reused by another thread.\n** So we don't even try to recover from an EINTR.  Just log the error\n** and move on.\n*/\nstatic void robust_close(unixFile *pFile, int h, int lineno){\n  if( osClose(h) ){\n    unixLogErrorAtLine(SQLITE_IOERR_CLOSE, \"close\",\n                       pFile ? pFile->zPath : 0, lineno);\n  }\n}\n\n/*\n** Set the pFile->lastErrno.  Do this in a subroutine as that provides\n** a convenient place to set a breakpoint.\n*/\nstatic void storeLastErrno(unixFile *pFile, int error){\n  pFile->lastErrno = error;\n}\n\n/*\n** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.\n*/ \nstatic void closePendingFds(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p;\n  UnixUnusedFd *pNext;\n  for(p=pInode->pUnused; p; p=pNext){\n    pNext = p->pNext;\n    robust_close(pFile, p->fd, __LINE__);\n    sqlite3_free(p);\n    nUnusedFd--;\n  }\n  pInode->pUnused = 0;\n}\n\n/*\n** Release a unixInodeInfo structure previously allocated by findInodeInfo().\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n*/\nstatic void releaseInodeInfo(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  if( ALWAYS(pInode) ){\n    pInode->nRef--;\n    if( pInode->nRef==0 ){\n      assert( pInode->pShmNode==0 );\n      closePendingFds(pFile);\n      if( pInode->pPrev ){\n        assert( pInode->pPrev->pNext==pInode );\n        pInode->pPrev->pNext = pInode->pNext;\n      }else{\n        assert( inodeList==pInode );\n        inodeList = pInode->pNext;\n      }\n      if( pInode->pNext ){\n        assert( pInode->pNext->pPrev==pInode );\n        pInode->pNext->pPrev = pInode->pPrev;\n      }\n      sqlite3_free(pInode);\n    }\n  }\n  assert( inodeList!=0 || nUnusedFd==0 );\n}\n\n/*\n** Given a file descriptor, locate the unixInodeInfo object that\n** describes that file descriptor.  Create a new one if necessary.  The\n** return value might be uninitialized if an error occurs.\n**\n** The mutex entered using the unixEnterMutex() function must be held\n** when this function is called.\n**\n** Return an appropriate error code.\n*/\nstatic int findInodeInfo(\n  unixFile *pFile,               /* Unix file with file desc used in the key */\n  unixInodeInfo **ppInode        /* Return the unixInodeInfo object here */\n){\n  int rc;                        /* System call return code */\n  int fd;                        /* The file descriptor for pFile */\n  struct unixFileId fileId;      /* Lookup key for the unixInodeInfo */\n  struct stat statbuf;           /* Low-level file information */\n  unixInodeInfo *pInode = 0;     /* Candidate unixInodeInfo object */\n\n  assert( unixMutexHeld() );\n\n  /* Get low-level information about the file that we can used to\n  ** create a unique name for the file.\n  */\n  fd = pFile->h;\n  rc = osFstat(fd, &statbuf);\n  if( rc!=0 ){\n    storeLastErrno(pFile, errno);\n#if defined(EOVERFLOW) && defined(SQLITE_DISABLE_LFS)\n    if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;\n#endif\n    return SQLITE_IOERR;\n  }\n\n#ifdef __APPLE__\n  /* On OS X on an msdos filesystem, the inode number is reported\n  ** incorrectly for zero-size files.  See ticket #3260.  To work\n  ** around this problem (we consider it a bug in OS X, not SQLite)\n  ** we always increase the file size to 1 by writing a single byte\n  ** prior to accessing the inode number.  The one byte written is\n  ** an ASCII 'S' character which also happens to be the first byte\n  ** in the header of every SQLite database.  In this way, if there\n  ** is a race condition such that another thread has already populated\n  ** the first page of the database, no damage is done.\n  */\n  if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){\n    do{ rc = osWrite(fd, \"S\", 1); }while( rc<0 && errno==EINTR );\n    if( rc!=1 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n    rc = osFstat(fd, &statbuf);\n    if( rc!=0 ){\n      storeLastErrno(pFile, errno);\n      return SQLITE_IOERR;\n    }\n  }\n#endif\n\n  memset(&fileId, 0, sizeof(fileId));\n  fileId.dev = statbuf.st_dev;\n#if OS_VXWORKS\n  fileId.pId = pFile->pId;\n#else\n  fileId.ino = (u64)statbuf.st_ino;\n#endif\n  assert( inodeList!=0 || nUnusedFd==0 );\n  pInode = inodeList;\n  while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){\n    pInode = pInode->pNext;\n  }\n  if( pInode==0 ){\n    pInode = sqlite3_malloc64( sizeof(*pInode) );\n    if( pInode==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(pInode, 0, sizeof(*pInode));\n    memcpy(&pInode->fileId, &fileId, sizeof(fileId));\n    pInode->nRef = 1;\n    pInode->pNext = inodeList;\n    pInode->pPrev = 0;\n    if( inodeList ) inodeList->pPrev = pInode;\n    inodeList = pInode;\n  }else{\n    pInode->nRef++;\n  }\n  *ppInode = pInode;\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if pFile has been renamed or unlinked since it was first opened.\n*/\nstatic int fileHasMoved(unixFile *pFile){\n#if OS_VXWORKS\n  return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId;\n#else\n  struct stat buf;\n  return pFile->pInode!=0 &&\n      (osStat(pFile->zPath, &buf)!=0 \n         || (u64)buf.st_ino!=pFile->pInode->fileId.ino);\n#endif\n}\n\n\n/*\n** Check a unixFile that is a database.  Verify the following:\n**\n** (1) There is exactly one hard link on the file\n** (2) The file is not a symbolic link\n** (3) The file has not been renamed or unlinked\n**\n** Issue sqlite3_log(SQLITE_WARNING,...) messages if anything is not right.\n*/\nstatic void verifyDbFile(unixFile *pFile){\n  struct stat buf;\n  int rc;\n\n  /* These verifications occurs for the main database only */\n  if( pFile->ctrlFlags & UNIXFILE_NOLOCK ) return;\n\n  rc = osFstat(pFile->h, &buf);\n  if( rc!=0 ){\n    sqlite3_log(SQLITE_WARNING, \"cannot fstat db file %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink==0 ){\n    sqlite3_log(SQLITE_WARNING, \"file unlinked while open: %s\", pFile->zPath);\n    return;\n  }\n  if( buf.st_nlink>1 ){\n    sqlite3_log(SQLITE_WARNING, \"multiple links to file: %s\", pFile->zPath);\n    return;\n  }\n  if( fileHasMoved(pFile) ){\n    sqlite3_log(SQLITE_WARNING, \"file renamed while open: %s\", pFile->zPath);\n    return;\n  }\n}\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int unixCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n\n  assert( pFile );\n  assert( pFile->eFileLock<=SHARED_LOCK );\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n\n  /* Otherwise see if some other process holds it.\n  */\n#ifndef __DJGPP__\n  if( !reserved && !pFile->pInode->bProcessLock ){\n    struct flock lock;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = RESERVED_BYTE;\n    lock.l_len = 1;\n    lock.l_type = F_WRLCK;\n    if( osFcntl(pFile->h, F_GETLK, &lock) ){\n      rc = SQLITE_IOERR_CHECKRESERVEDLOCK;\n      storeLastErrno(pFile, errno);\n    } else if( lock.l_type!=F_UNLCK ){\n      reserved = 1;\n    }\n  }\n#endif\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (unix)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Attempt to set a system-lock on the file pFile.  The lock is \n** described by pLock.\n**\n** If the pFile was opened read/write from unix-excl, then the only lock\n** ever obtained is an exclusive lock, and it is obtained exactly once\n** the first time any lock is attempted.  All subsequent system locking\n** operations become no-ops.  Locking operations still happen internally,\n** in order to coordinate access between separate database connections\n** within this process, but all of that is handled in memory and the\n** operating system does not participate.\n**\n** This function is a pass-through to fcntl(F_SETLK) if pFile is using\n** any VFS other than \"unix-excl\" or if pFile is opened on \"unix-excl\"\n** and is read-only.\n**\n** Zero is returned if the call completes successfully, or -1 if a call\n** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).\n*/\nstatic int unixFileLock(unixFile *pFile, struct flock *pLock){\n  int rc;\n  unixInodeInfo *pInode = pFile->pInode;\n  assert( unixMutexHeld() );\n  assert( pInode!=0 );\n  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){\n    if( pInode->bProcessLock==0 ){\n      struct flock lock;\n      assert( pInode->nLock==0 );\n      lock.l_whence = SEEK_SET;\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n      lock.l_type = F_WRLCK;\n      rc = osFcntl(pFile->h, F_SETLK, &lock);\n      if( rc<0 ) return rc;\n      pInode->bProcessLock = 1;\n      pInode->nLock++;\n    }else{\n      rc = 0;\n    }\n  }else{\n    rc = osFcntl(pFile->h, F_SETLK, pLock);\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int unixLock(sqlite3_file *id, int eFileLock){\n  /* The following describes the implementation of the various locks and\n  ** lock transitions in terms of the POSIX advisory shared and exclusive\n  ** lock primitives (called read-locks and write-locks below, to avoid\n  ** confusion with SQLite lock names). The algorithms are complicated\n  ** slightly in order to be compatible with Windows95 systems simultaneously\n  ** accessing the same database file, in case that is ever required.\n  **\n  ** Symbols defined in os.h indentify the 'pending byte' and the 'reserved\n  ** byte', each single bytes at well known offsets, and the 'shared byte\n  ** range', a range of 510 bytes at a well known offset.\n  **\n  ** To obtain a SHARED lock, a read-lock is obtained on the 'pending\n  ** byte'.  If this is successful, 'shared byte range' is read-locked\n  ** and the lock on the 'pending byte' released.  (Legacy note:  When\n  ** SQLite was first developed, Windows95 systems were still very common,\n  ** and Widnows95 lacks a shared-lock capability.  So on Windows95, a\n  ** single randomly selected by from the 'shared byte range' is locked.\n  ** Windows95 is now pretty much extinct, but this work-around for the\n  ** lack of shared-locks on Windows95 lives on, for backwards\n  ** compatibility.)\n  **\n  ** A process may only obtain a RESERVED lock after it has a SHARED lock.\n  ** A RESERVED lock is implemented by grabbing a write-lock on the\n  ** 'reserved byte'. \n  **\n  ** A process may only obtain a PENDING lock after it has obtained a\n  ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock\n  ** on the 'pending byte'. This ensures that no new SHARED locks can be\n  ** obtained, but existing SHARED locks are allowed to persist. A process\n  ** does not have to obtain a RESERVED lock on the way to a PENDING lock.\n  ** This property is used by the algorithm for rolling back a journal file\n  ** after a crash.\n  **\n  ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is\n  ** implemented by obtaining a write-lock on the entire 'shared byte\n  ** range'. Since all other locks require a read-lock on one of the bytes\n  ** within this range, this ensures that no other locks are held on the\n  ** database. \n  */\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int tErrno = 0;\n\n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (unix)\\n\", pFile->h,\n      azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n      azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,\n      osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (unix)\\n\", pFile->h,\n            azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct.\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n\n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n          (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n  ){\n    rc = SQLITE_BUSY;\n    goto end_lock;\n  }\n\n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n      (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto end_lock;\n  }\n\n\n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  lock.l_len = 1L;\n  lock.l_whence = SEEK_SET;\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);\n    lock.l_start = PENDING_BYTE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }\n  }\n\n\n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n    assert( rc==SQLITE_OK );\n\n    /* Now get the read-lock */\n    lock.l_start = SHARED_FIRST;\n    lock.l_len = SHARED_SIZE;\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    }\n\n    /* Drop the temporary PENDING lock */\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 1L;\n    lock.l_type = F_UNLCK;\n    if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){\n      /* This could happen with a network mount */\n      tErrno = errno;\n      rc = SQLITE_IOERR_UNLOCK; \n    }\n\n    if( rc ){\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n      goto end_lock;\n    }else{\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n    ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    assert( 0!=pFile->eFileLock );\n    lock.l_type = F_WRLCK;\n\n    assert( eFileLock==RESERVED_LOCK || eFileLock==EXCLUSIVE_LOCK );\n    if( eFileLock==RESERVED_LOCK ){\n      lock.l_start = RESERVED_BYTE;\n      lock.l_len = 1L;\n    }else{\n      lock.l_start = SHARED_FIRST;\n      lock.l_len = SHARED_SIZE;\n    }\n\n    if( unixFileLock(pFile, &lock) ){\n      tErrno = errno;\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n  }\n  \n\n#ifdef SQLITE_DEBUG\n  /* Set up the transaction-counter change checking flags when\n  ** transitioning from a SHARED to a RESERVED lock.  The change\n  ** from SHARED to RESERVED marks the beginning of a normal\n  ** write operation (not a hot journal rollback).\n  */\n  if( rc==SQLITE_OK\n   && pFile->eFileLock<=SHARED_LOCK\n   && eFileLock==RESERVED_LOCK\n  ){\n    pFile->transCntrChng = 0;\n    pFile->dbUpdate = 0;\n    pFile->inNormalWrite = 1;\n  }\n#endif\n\n\n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n\nend_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (unix)\\n\", pFile->h, azFileLock(eFileLock), \n      rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Add the file descriptor used by file handle pFile to the corresponding\n** pUnused list.\n*/\nstatic void setPendingFd(unixFile *pFile){\n  unixInodeInfo *pInode = pFile->pInode;\n  UnixUnusedFd *p = pFile->pPreallocatedUnused;\n  p->pNext = pInode->pUnused;\n  pInode->pUnused = p;\n  pFile->h = -1;\n  pFile->pPreallocatedUnused = 0;\n  nUnusedFd++;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n** \n** If handleNFSUnlock is true, then on downgrading an EXCLUSIVE_LOCK to SHARED\n** the byte range is divided into 2 parts and the first part is unlocked then\n** set to a read lock, then the other part is simply unlocked.  This works \n** around a bug in BSD NFS lockd (also seen on MacOSX 10.3+) that fails to \n** remove the write lock on a region when a read lock is set.\n*/\nstatic int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  struct flock lock;\n  int rc = SQLITE_OK;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (unix)\\n\", pFile->h, eFileLock,\n      pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n      osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n\n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    pFile->inNormalWrite = 0;\n#endif\n\n    /* downgrading to a shared lock on NFS involves clearing the write lock\n    ** before establishing the readlock - to avoid a race condition we downgrade\n    ** the lock in 2 blocks, so that part of the range will be covered by a \n    ** write lock until the rest is covered by a read lock:\n    **  1:   [WWWWW]\n    **  2:   [....W]\n    **  3:   [RRRRW]\n    **  4:   [RRRR.]\n    */\n    if( eFileLock==SHARED_LOCK ){\n#if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE\n      (void)handleNFSUnlock;\n      assert( handleNFSUnlock==0 );\n#endif\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n      if( handleNFSUnlock ){\n        int tErrno;               /* Error code from system call errors */\n        off_t divSize = SHARED_SIZE - 1;\n        \n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);\n          if( IS_LOCK_ERROR(rc) ){\n            storeLastErrno(pFile, tErrno);\n          }\n          goto end_unlock;\n        }\n        lock.l_type = F_UNLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST+divSize;\n        lock.l_len = SHARED_SIZE-divSize;\n        if( unixFileLock(pFile, &lock)==(-1) ){\n          tErrno = errno;\n          rc = SQLITE_IOERR_UNLOCK;\n          storeLastErrno(pFile, tErrno);\n          goto end_unlock;\n        }\n      }else\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n      {\n        lock.l_type = F_RDLCK;\n        lock.l_whence = SEEK_SET;\n        lock.l_start = SHARED_FIRST;\n        lock.l_len = SHARED_SIZE;\n        if( unixFileLock(pFile, &lock) ){\n          /* In theory, the call to unixFileLock() cannot fail because another\n          ** process is holding an incompatible lock. If it does, this \n          ** indicates that the other process is not following the locking\n          ** protocol. If this happens, return SQLITE_IOERR_RDLOCK. Returning\n          ** SQLITE_BUSY would confuse the upper layer (in practice it causes \n          ** an assert to fail). */ \n          rc = SQLITE_IOERR_RDLOCK;\n          storeLastErrno(pFile, errno);\n          goto end_unlock;\n        }\n      }\n    }\n    lock.l_type = F_UNLCK;\n    lock.l_whence = SEEK_SET;\n    lock.l_start = PENDING_BYTE;\n    lock.l_len = 2L;  assert( PENDING_BYTE+1==RESERVED_BYTE );\n    if( unixFileLock(pFile, &lock)==0 ){\n      pInode->eFileLock = SHARED_LOCK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, errno);\n      goto end_unlock;\n    }\n  }\n  if( eFileLock==NO_LOCK ){\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      lock.l_type = F_UNLCK;\n      lock.l_whence = SEEK_SET;\n      lock.l_start = lock.l_len = 0L;\n      if( unixFileLock(pFile, &lock)==0 ){\n        pInode->eFileLock = NO_LOCK;\n      }else{\n        rc = SQLITE_IOERR_UNLOCK;\n        storeLastErrno(pFile, errno);\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n\n    /* Decrement the count of locks against this same file.  When the\n    ** count reaches zero, close any other file descriptors whose close\n    ** was deferred because of outstanding locks.\n    */\n    pInode->nLock--;\n    assert( pInode->nLock>=0 );\n    if( pInode->nLock==0 ){\n      closePendingFds(pFile);\n    }\n  }\n\nend_unlock:\n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int unixUnlock(sqlite3_file *id, int eFileLock){\n#if SQLITE_MAX_MMAP_SIZE>0\n  assert( eFileLock==SHARED_LOCK || ((unixFile *)id)->nFetchOut==0 );\n#endif\n  return posixUnlock(id, eFileLock, 0);\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int unixMapfile(unixFile *pFd, i64 nByte);\nstatic void unixUnmapfile(unixFile *pFd);\n#endif\n\n/*\n** This function performs the parts of the \"close file\" operation \n** common to all locking schemes. It closes the directory and file\n** handles, if they are valid, and sets all fields of the unixFile\n** structure to 0.\n**\n** It is *not* necessary to hold the mutex when this routine is called,\n** even on VxWorks.  A mutex will be acquired on VxWorks by the\n** vxworksReleaseFileId() routine.\n*/\nstatic int closeUnixFile(sqlite3_file *id){\n  unixFile *pFile = (unixFile*)id;\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixUnmapfile(pFile);\n#endif\n  if( pFile->h>=0 ){\n    robust_close(pFile, pFile->h, __LINE__);\n    pFile->h = -1;\n  }\n#if OS_VXWORKS\n  if( pFile->pId ){\n    if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n      osUnlink(pFile->pId->zCanonicalName);\n    }\n    vxworksReleaseFileId(pFile->pId);\n    pFile->pId = 0;\n  }\n#endif\n#ifdef SQLITE_UNLINK_AFTER_CLOSE\n  if( pFile->ctrlFlags & UNIXFILE_DELETE ){\n    osUnlink(pFile->zPath);\n    sqlite3_free(*(char**)&pFile->zPath);\n    pFile->zPath = 0;\n  }\n#endif\n  OSTRACE((\"CLOSE   %-3d\\n\", pFile->h));\n  OpenCounter(-1);\n  sqlite3_free(pFile->pPreallocatedUnused);\n  memset(pFile, 0, sizeof(unixFile));\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.\n*/\nstatic int unixClose(sqlite3_file *id){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile *)id;\n  verifyDbFile(pFile);\n  unixUnlock(id, NO_LOCK);\n  unixEnterMutex();\n\n  /* unixFile.pInode is always valid here. Otherwise, a different close\n  ** routine (e.g. nolockClose()) would be called instead.\n  */\n  assert( pFile->pInode->nLock>0 || pFile->pInode->bProcessLock==0 );\n  if( ALWAYS(pFile->pInode) && pFile->pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->pUnused list.  It will be automatically closed \n    ** when the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  releaseInodeInfo(pFile);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n/************** End of the posix advisory lock implementation *****************\n******************************************************************************/\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int nolockCheckReservedLock(sqlite3_file *NotUsed, int *pResOut){\n  UNUSED_PARAMETER(NotUsed);\n  *pResOut = 0;\n  return SQLITE_OK;\n}\nstatic int nolockLock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\nstatic int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return SQLITE_OK;\n}\n\n/*\n** Close the file.\n*/\nstatic int nolockClose(sqlite3_file *id) {\n  return closeUnixFile(id);\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************* Begin dot-file Locking ******************************\n**\n** The dotfile locking implementation uses the existence of separate lock\n** files (really a directory) to control access to the database.  This works\n** on just about every filesystem imaginable.  But there are serious downsides:\n**\n**    (1)  There is zero concurrency.  A single reader blocks all other\n**         connections from reading or writing the database.\n**\n**    (2)  An application crash or power loss can leave stale lock files\n**         sitting around that need to be cleared manually.\n**\n** Nevertheless, a dotlock is an appropriate locking mode for use if no\n** other locking strategy is available.\n**\n** Dotfile locking works by creating a subdirectory in the same directory as\n** the database and with the same name but with a \".lock\" extension added.\n** The existence of a lock directory implies an EXCLUSIVE lock.  All other\n** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.\n*/\n\n/*\n** The file suffix added to the data base filename in order to create the\n** lock directory.\n*/\n#define DOTLOCK_SUFFIX \".lock\"\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n**\n** In dotfile locking, either a lock exists or it does not.  So in this\n** variation of CheckReservedLock(), *pResOut is set to true if any lock\n** is held on the file and false if the file is unlocked.\n*/\nstatic int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  reserved = osAccess((const char*)pFile->lockingContext, 0)==0;\n  OSTRACE((\"TEST WR-LOCK %d %d %d (dotlock)\\n\", pFile->h, rc, reserved));\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n**\n** With dotfile locking, we really only support state (4): EXCLUSIVE.\n** But we track the other locking levels internally.\n*/\nstatic int dotlockLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc = SQLITE_OK;\n\n\n  /* If we have any lock, then the lock file already exists.  All we have\n  ** to do is adjust our internal record of the lock level.\n  */\n  if( pFile->eFileLock > NO_LOCK ){\n    pFile->eFileLock = eFileLock;\n    /* Always update the timestamp on the old file */\n#ifdef HAVE_UTIME\n    utime(zLockFile, NULL);\n#else\n    utimes(zLockFile, NULL);\n#endif\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  rc = osMkdir(zLockFile, 0777);\n  if( rc<0 ){\n    /* failed to open/create the lock directory */\n    int tErrno = errno;\n    if( EEXIST == tErrno ){\n      rc = SQLITE_BUSY;\n    } else {\n      rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n      if( rc!=SQLITE_BUSY ){\n        storeLastErrno(pFile, tErrno);\n      }\n    }\n    return rc;\n  } \n  \n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** When the locking level reaches NO_LOCK, delete the lock file.\n*/\nstatic int dotlockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  char *zLockFile = (char *)pFile->lockingContext;\n  int rc;\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (dotlock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n\n  /* To downgrade to shared, simply update our internal notion of the\n  ** lock state.  No need to mess with the file on disk.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    pFile->eFileLock = SHARED_LOCK;\n    return SQLITE_OK;\n  }\n  \n  /* To fully unlock the database, delete the lock file */\n  assert( eFileLock==NO_LOCK );\n  rc = osRmdir(zLockFile);\n  if( rc<0 ){\n    int tErrno = errno;\n    if( tErrno==ENOENT ){\n      rc = SQLITE_OK;\n    }else{\n      rc = SQLITE_IOERR_UNLOCK;\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n** Close a file.  Make sure the lock has been released before closing.\n*/\nstatic int dotlockClose(sqlite3_file *id) {\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  dotlockUnlock(id, NO_LOCK);\n  sqlite3_free(pFile->lockingContext);\n  return closeUnixFile(id);\n}\n/****************** End of the dot-file lock implementation *******************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin flock Locking ********************************\n**\n** Use the flock() system call to do file locking.\n**\n** flock() locking is like dot-file locking in that the various\n** fine-grain locking levels supported by SQLite are collapsed into\n** a single exclusive lock.  In other words, SHARED, RESERVED, and\n** PENDING locks are the same thing as an EXCLUSIVE lock.  SQLite\n** still works when you do this, but concurrency is reduced since\n** only a single process can be reading the database at a time.\n**\n** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off\n*/\n#if SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** Retry flock() calls that fail with EINTR\n*/\n#ifdef EINTR\nstatic int robust_flock(int fd, int op){\n  int rc;\n  do{ rc = flock(fd,op); }while( rc<0 && errno==EINTR );\n  return rc;\n}\n#else\n# define robust_flock(a,b) flock(a,b)\n#endif\n     \n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int flockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    /* attempt to get the lock */\n    int lrc = robust_flock(pFile->h, LOCK_EX | LOCK_NB);\n    if( !lrc ){\n      /* got the lock, unlock it */\n      lrc = robust_flock(pFile->h, LOCK_UN);\n      if ( lrc ) {\n        int tErrno = errno;\n        /* unlock failed with an error */\n        lrc = SQLITE_IOERR_UNLOCK; \n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    } else {\n      int tErrno = errno;\n      reserved = 1;\n      /* someone else might have it reserved */\n      lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); \n      if( IS_LOCK_ERROR(lrc) ){\n        storeLastErrno(pFile, tErrno);\n        rc = lrc;\n      }\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (flock)\\n\", pFile->h, rc, reserved));\n\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_OK;\n    reserved=1;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** flock() only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int flockLock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n\n  assert( pFile );\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* grab an exclusive lock */\n  \n  if (robust_flock(pFile->h, LOCK_EX | LOCK_NB)) {\n    int tErrno = errno;\n    /* didn't get, must be busy */\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n  } else {\n    /* got it, set the type and return ok */\n    pFile->eFileLock = eFileLock;\n  }\n  OSTRACE((\"LOCK    %d %s %s (flock)\\n\", pFile->h, azFileLock(eFileLock), \n           rc==SQLITE_OK ? \"ok\" : \"failed\"));\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n  if( (rc & 0xff) == SQLITE_IOERR ){\n    rc = SQLITE_BUSY;\n  }\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int flockUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  \n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (flock)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really, unlock. */\n  if( robust_flock(pFile->h, LOCK_UN) ){\n#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS\n    return SQLITE_OK;\n#endif /* SQLITE_IGNORE_FLOCK_LOCK_ERRORS */\n    return SQLITE_IOERR_UNLOCK;\n  }else{\n    pFile->eFileLock = NO_LOCK;\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Close a file.\n*/\nstatic int flockClose(sqlite3_file *id) {\n  assert( id!=0 );\n  flockUnlock(id, NO_LOCK);\n  return closeUnixFile(id);\n}\n\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */\n\n/******************* End of the flock lock implementation *********************\n******************************************************************************/\n\n/******************************************************************************\n************************ Begin Named Semaphore Locking ************************\n**\n** Named semaphore locking is only supported on VxWorks.\n**\n** Semaphore locking is like dot-lock and flock in that it really only\n** supports EXCLUSIVE locking.  Only a single process can read or write\n** the database file at a time.  This reduces potential concurrency, but\n** makes the lock implementation much easier.\n*/\n#if OS_VXWORKS\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n\n  /* Check if a thread in this process holds such a lock */\n  if( pFile->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it. */\n  if( !reserved ){\n    sem_t *pSem = pFile->pInode->pSem;\n\n    if( sem_trywait(pSem)==-1 ){\n      int tErrno = errno;\n      if( EAGAIN != tErrno ){\n        rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);\n        storeLastErrno(pFile, tErrno);\n      } else {\n        /* someone else has the lock when we are in NO_LOCK */\n        reserved = (pFile->eFileLock < SHARED_LOCK);\n      }\n    }else{\n      /* we could have it if we want it */\n      sem_post(pSem);\n    }\n  }\n  OSTRACE((\"TEST WR-LOCK %d %d %d (sem)\\n\", pFile->h, rc, reserved));\n\n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** Semaphore locks only really support EXCLUSIVE locks.  We track intermediate\n** lock states in the sqlite3_file structure, but all locks SHARED or\n** above are really EXCLUSIVE locks and exclude all other processes from\n** access the file.\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int semXLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n  int rc = SQLITE_OK;\n\n  /* if we already have a lock, it is exclusive.  \n  ** Just adjust level and punt on outta here. */\n  if (pFile->eFileLock > NO_LOCK) {\n    pFile->eFileLock = eFileLock;\n    rc = SQLITE_OK;\n    goto sem_end_lock;\n  }\n  \n  /* lock semaphore now but bail out when already locked. */\n  if( sem_trywait(pSem)==-1 ){\n    rc = SQLITE_BUSY;\n    goto sem_end_lock;\n  }\n\n  /* got it, set the type and return ok */\n  pFile->eFileLock = eFileLock;\n\n sem_end_lock:\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int semXUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  sem_t *pSem = pFile->pInode->pSem;\n\n  assert( pFile );\n  assert( pSem );\n  OSTRACE((\"UNLOCK  %d %d was %d pid=%d (sem)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, osGetpid(0)));\n  assert( eFileLock<=SHARED_LOCK );\n  \n  /* no-op if possible */\n  if( pFile->eFileLock==eFileLock ){\n    return SQLITE_OK;\n  }\n  \n  /* shared can just be set because we always have an exclusive */\n  if (eFileLock==SHARED_LOCK) {\n    pFile->eFileLock = eFileLock;\n    return SQLITE_OK;\n  }\n  \n  /* no, really unlock. */\n  if ( sem_post(pSem)==-1 ) {\n    int rc, tErrno = errno;\n    rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc; \n  }\n  pFile->eFileLock = NO_LOCK;\n  return SQLITE_OK;\n}\n\n/*\n ** Close a file.\n */\nstatic int semXClose(sqlite3_file *id) {\n  if( id ){\n    unixFile *pFile = (unixFile*)id;\n    semXUnlock(id, NO_LOCK);\n    assert( pFile );\n    unixEnterMutex();\n    releaseInodeInfo(pFile);\n    unixLeaveMutex();\n    closeUnixFile(id);\n  }\n  return SQLITE_OK;\n}\n\n#endif /* OS_VXWORKS */\n/*\n** Named semaphore locking is only available on VxWorks.\n**\n*************** End of the named semaphore lock implementation ****************\n******************************************************************************/\n\n\n/******************************************************************************\n*************************** Begin AFP Locking *********************************\n**\n** AFP is the Apple Filing Protocol.  AFP is a network filesystem found\n** on Apple Macintosh computers - both OS9 and OSX.\n**\n** Third-party implementations of AFP are available.  But this code here\n** only works on OSX.\n*/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n** The afpLockingContext structure contains all afp lock specific state\n*/\ntypedef struct afpLockingContext afpLockingContext;\nstruct afpLockingContext {\n  int reserved;\n  const char *dbPath;             /* Name of the open file */\n};\n\nstruct ByteRangeLockPB2\n{\n  unsigned long long offset;        /* offset to first byte to lock */\n  unsigned long long length;        /* nbr of bytes to lock */\n  unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */\n  unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */\n  unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */\n  int fd;                           /* file desc to assoc this lock with */\n};\n\n#define afpfsByteRangeLock2FSCTL        _IOWR('z', 23, struct ByteRangeLockPB2)\n\n/*\n** This is a utility for setting or clearing a bit-range lock on an\n** AFP filesystem.\n** \n** Return SQLITE_OK on success, SQLITE_BUSY on failure.\n*/\nstatic int afpSetLock(\n  const char *path,              /* Name of the file to be locked or unlocked */\n  unixFile *pFile,               /* Open file descriptor on path */\n  unsigned long long offset,     /* First byte to be locked */\n  unsigned long long length,     /* Number of bytes to lock */\n  int setLockFlag                /* True to set lock.  False to clear lock */\n){\n  struct ByteRangeLockPB2 pb;\n  int err;\n  \n  pb.unLockFlag = setLockFlag ? 0 : 1;\n  pb.startEndFlag = 0;\n  pb.offset = offset;\n  pb.length = length; \n  pb.fd = pFile->h;\n  \n  OSTRACE((\"AFPSETLOCK [%s] for %d%s in range %llx:%llx\\n\", \n    (setLockFlag?\"ON\":\"OFF\"), pFile->h, (pb.fd==-1?\"[testval-1]\":\"\"),\n    offset, length));\n  err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);\n  if ( err==-1 ) {\n    int rc;\n    int tErrno = errno;\n    OSTRACE((\"AFPSETLOCK failed to fsctl() '%s' %d %s\\n\",\n             path, tErrno, strerror(tErrno)));\n#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS\n    rc = SQLITE_BUSY;\n#else\n    rc = sqliteErrorFromPosixError(tErrno,\n                    setLockFlag ? SQLITE_IOERR_LOCK : SQLITE_IOERR_UNLOCK);\n#endif /* SQLITE_IGNORE_AFP_LOCK_ERRORS */\n    if( IS_LOCK_ERROR(rc) ){\n      storeLastErrno(pFile, tErrno);\n    }\n    return rc;\n  } else {\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int afpCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int rc = SQLITE_OK;\n  int reserved = 0;\n  unixFile *pFile = (unixFile*)id;\n  afpLockingContext *context;\n  \n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  \n  assert( pFile );\n  context = (afpLockingContext *) pFile->lockingContext;\n  if( context->reserved ){\n    *pResOut = 1;\n    return SQLITE_OK;\n  }\n  unixEnterMutex(); /* Because pFile->pInode is shared across threads */\n  \n  /* Check if a thread in this process holds such a lock */\n  if( pFile->pInode->eFileLock>SHARED_LOCK ){\n    reserved = 1;\n  }\n  \n  /* Otherwise see if some other process holds it.\n   */\n  if( !reserved ){\n    /* lock the RESERVED byte */\n    int lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);  \n    if( SQLITE_OK==lrc ){\n      /* if we succeeded in taking the reserved lock, unlock it to restore\n      ** the original state */\n      lrc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n    } else {\n      /* if we failed to get the lock then someone else must have it */\n      reserved = 1;\n    }\n    if( IS_LOCK_ERROR(lrc) ){\n      rc=lrc;\n    }\n  }\n  \n  unixLeaveMutex();\n  OSTRACE((\"TEST WR-LOCK %d %d %d (afp)\\n\", pFile->h, rc, reserved));\n  \n  *pResOut = reserved;\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int afpLock(sqlite3_file *id, int eFileLock){\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode = pFile->pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  \n  assert( pFile );\n  OSTRACE((\"LOCK    %d %s was %s(%s,%d) pid=%d (afp)\\n\", pFile->h,\n           azFileLock(eFileLock), azFileLock(pFile->eFileLock),\n           azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as\n  ** unixEnterMutex() hasn't been called yet.\n  */\n  if( pFile->eFileLock>=eFileLock ){\n    OSTRACE((\"LOCK    %d %s ok (already held) (afp)\\n\", pFile->h,\n           azFileLock(eFileLock)));\n    return SQLITE_OK;\n  }\n\n  /* Make sure the locking sequence is correct\n  **  (1) We never move from unlocked to anything higher than shared lock.\n  **  (2) SQLite never explicitly requests a pendig lock.\n  **  (3) A shared lock is always held when a reserve lock is requested.\n  */\n  assert( pFile->eFileLock!=NO_LOCK || eFileLock==SHARED_LOCK );\n  assert( eFileLock!=PENDING_LOCK );\n  assert( eFileLock!=RESERVED_LOCK || pFile->eFileLock==SHARED_LOCK );\n  \n  /* This mutex is needed because pFile->pInode is shared across threads\n  */\n  unixEnterMutex();\n  pInode = pFile->pInode;\n\n  /* If some thread using this PID has a lock via a different unixFile*\n  ** handle that precludes the requested lock, return BUSY.\n  */\n  if( (pFile->eFileLock!=pInode->eFileLock && \n       (pInode->eFileLock>=PENDING_LOCK || eFileLock>SHARED_LOCK))\n     ){\n    rc = SQLITE_BUSY;\n    goto afp_end_lock;\n  }\n  \n  /* If a SHARED lock is requested, and some thread using this PID already\n  ** has a SHARED or RESERVED lock, then increment reference counts and\n  ** return SQLITE_OK.\n  */\n  if( eFileLock==SHARED_LOCK && \n     (pInode->eFileLock==SHARED_LOCK || pInode->eFileLock==RESERVED_LOCK) ){\n    assert( eFileLock==SHARED_LOCK );\n    assert( pFile->eFileLock==0 );\n    assert( pInode->nShared>0 );\n    pFile->eFileLock = SHARED_LOCK;\n    pInode->nShared++;\n    pInode->nLock++;\n    goto afp_end_lock;\n  }\n    \n  /* A PENDING lock is needed before acquiring a SHARED lock and before\n  ** acquiring an EXCLUSIVE lock.  For the SHARED lock, the PENDING will\n  ** be released.\n  */\n  if( eFileLock==SHARED_LOCK \n      || (eFileLock==EXCLUSIVE_LOCK && pFile->eFileLock<PENDING_LOCK)\n  ){\n    int failed;\n    failed = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 1);\n    if (failed) {\n      rc = failed;\n      goto afp_end_lock;\n    }\n  }\n  \n  /* If control gets to this point, then actually go ahead and make\n  ** operating system calls for the specified lock.\n  */\n  if( eFileLock==SHARED_LOCK ){\n    int lrc1, lrc2, lrc1Errno = 0;\n    long lk, mask;\n    \n    assert( pInode->nShared==0 );\n    assert( pInode->eFileLock==0 );\n        \n    mask = (sizeof(long)==8) ? LARGEST_INT64 : 0x7fffffff;\n    /* Now get the read-lock SHARED_LOCK */\n    /* note that the quality of the randomness doesn't matter that much */\n    lk = random(); \n    pInode->sharedByte = (lk & mask)%(SHARED_SIZE - 1);\n    lrc1 = afpSetLock(context->dbPath, pFile, \n          SHARED_FIRST+pInode->sharedByte, 1, 1);\n    if( IS_LOCK_ERROR(lrc1) ){\n      lrc1Errno = pFile->lastErrno;\n    }\n    /* Drop the temporary PENDING lock */\n    lrc2 = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    \n    if( IS_LOCK_ERROR(lrc1) ) {\n      storeLastErrno(pFile, lrc1Errno);\n      rc = lrc1;\n      goto afp_end_lock;\n    } else if( IS_LOCK_ERROR(lrc2) ){\n      rc = lrc2;\n      goto afp_end_lock;\n    } else if( lrc1 != SQLITE_OK ) {\n      rc = lrc1;\n    } else {\n      pFile->eFileLock = SHARED_LOCK;\n      pInode->nLock++;\n      pInode->nShared = 1;\n    }\n  }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){\n    /* We are trying for an exclusive lock but another thread in this\n     ** same process is still holding a shared lock. */\n    rc = SQLITE_BUSY;\n  }else{\n    /* The request was for a RESERVED or EXCLUSIVE lock.  It is\n    ** assumed that there is a SHARED or greater lock on the file\n    ** already.\n    */\n    int failed = 0;\n    assert( 0!=pFile->eFileLock );\n    if (eFileLock >= RESERVED_LOCK && pFile->eFileLock < RESERVED_LOCK) {\n        /* Acquire a RESERVED lock */\n        failed = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1,1);\n      if( !failed ){\n        context->reserved = 1;\n      }\n    }\n    if (!failed && eFileLock == EXCLUSIVE_LOCK) {\n      /* Acquire an EXCLUSIVE lock */\n        \n      /* Remove the shared lock before trying the range.  we'll need to \n      ** reestablish the shared lock if we can't get the  afpUnlock\n      */\n      if( !(failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST +\n                         pInode->sharedByte, 1, 0)) ){\n        int failed2 = SQLITE_OK;\n        /* now attemmpt to get the exclusive lock range */\n        failed = afpSetLock(context->dbPath, pFile, SHARED_FIRST, \n                               SHARED_SIZE, 1);\n        if( failed && (failed2 = afpSetLock(context->dbPath, pFile, \n                       SHARED_FIRST + pInode->sharedByte, 1, 1)) ){\n          /* Can't reestablish the shared lock.  Sqlite can't deal, this is\n          ** a critical I/O error\n          */\n          rc = ((failed & 0xff) == SQLITE_IOERR) ? failed2 : \n               SQLITE_IOERR_LOCK;\n          goto afp_end_lock;\n        } \n      }else{\n        rc = failed; \n      }\n    }\n    if( failed ){\n      rc = failed;\n    }\n  }\n  \n  if( rc==SQLITE_OK ){\n    pFile->eFileLock = eFileLock;\n    pInode->eFileLock = eFileLock;\n  }else if( eFileLock==EXCLUSIVE_LOCK ){\n    pFile->eFileLock = PENDING_LOCK;\n    pInode->eFileLock = PENDING_LOCK;\n  }\n  \nafp_end_lock:\n  unixLeaveMutex();\n  OSTRACE((\"LOCK    %d %s %s (afp)\\n\", pFile->h, azFileLock(eFileLock), \n         rc==SQLITE_OK ? \"ok\" : \"failed\"));\n  return rc;\n}\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int afpUnlock(sqlite3_file *id, int eFileLock) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  unixInodeInfo *pInode;\n  afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;\n  int skipShared = 0;\n#ifdef SQLITE_TEST\n  int h = pFile->h;\n#endif\n\n  assert( pFile );\n  OSTRACE((\"UNLOCK  %d %d was %d(%d,%d) pid=%d (afp)\\n\", pFile->h, eFileLock,\n           pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,\n           osGetpid(0)));\n\n  assert( eFileLock<=SHARED_LOCK );\n  if( pFile->eFileLock<=eFileLock ){\n    return SQLITE_OK;\n  }\n  unixEnterMutex();\n  pInode = pFile->pInode;\n  assert( pInode->nShared!=0 );\n  if( pFile->eFileLock>SHARED_LOCK ){\n    assert( pInode->eFileLock==pFile->eFileLock );\n    SimulateIOErrorBenign(1);\n    SimulateIOError( h=(-1) )\n    SimulateIOErrorBenign(0);\n    \n#ifdef SQLITE_DEBUG\n    /* When reducing a lock such that other processes can start\n    ** reading the database file again, make sure that the\n    ** transaction counter was updated if any part of the database\n    ** file changed.  If the transaction counter is not updated,\n    ** other connections to the same file might not realize that\n    ** the file has changed and hence might not know to flush their\n    ** cache.  The use of a stale cache can lead to database corruption.\n    */\n    assert( pFile->inNormalWrite==0\n           || pFile->dbUpdate==0\n           || pFile->transCntrChng==1 );\n    pFile->inNormalWrite = 0;\n#endif\n    \n    if( pFile->eFileLock==EXCLUSIVE_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, SHARED_FIRST, SHARED_SIZE, 0);\n      if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1) ){\n        /* only re-establish the shared lock if necessary */\n        int sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 1);\n      } else {\n        skipShared = 1;\n      }\n    }\n    if( rc==SQLITE_OK && pFile->eFileLock>=PENDING_LOCK ){\n      rc = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);\n    } \n    if( rc==SQLITE_OK && pFile->eFileLock>=RESERVED_LOCK && context->reserved ){\n      rc = afpSetLock(context->dbPath, pFile, RESERVED_BYTE, 1, 0);\n      if( !rc ){ \n        context->reserved = 0; \n      }\n    }\n    if( rc==SQLITE_OK && (eFileLock==SHARED_LOCK || pInode->nShared>1)){\n      pInode->eFileLock = SHARED_LOCK;\n    }\n  }\n  if( rc==SQLITE_OK && eFileLock==NO_LOCK ){\n\n    /* Decrement the shared lock counter.  Release the lock using an\n    ** OS call only when all threads in this same process have released\n    ** the lock.\n    */\n    unsigned long long sharedLockByte = SHARED_FIRST+pInode->sharedByte;\n    pInode->nShared--;\n    if( pInode->nShared==0 ){\n      SimulateIOErrorBenign(1);\n      SimulateIOError( h=(-1) )\n      SimulateIOErrorBenign(0);\n      if( !skipShared ){\n        rc = afpSetLock(context->dbPath, pFile, sharedLockByte, 1, 0);\n      }\n      if( !rc ){\n        pInode->eFileLock = NO_LOCK;\n        pFile->eFileLock = NO_LOCK;\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pInode->nLock--;\n      assert( pInode->nLock>=0 );\n      if( pInode->nLock==0 ){\n        closePendingFds(pFile);\n      }\n    }\n  }\n  \n  unixLeaveMutex();\n  if( rc==SQLITE_OK ) pFile->eFileLock = eFileLock;\n  return rc;\n}\n\n/*\n** Close a file & cleanup AFP specific locking context \n*/\nstatic int afpClose(sqlite3_file *id) {\n  int rc = SQLITE_OK;\n  unixFile *pFile = (unixFile*)id;\n  assert( id!=0 );\n  afpUnlock(id, NO_LOCK);\n  unixEnterMutex();\n  if( pFile->pInode && pFile->pInode->nLock ){\n    /* If there are outstanding locks, do not actually close the file just\n    ** yet because that would clear those locks.  Instead, add the file\n    ** descriptor to pInode->aPending.  It will be automatically closed when\n    ** the last lock is cleared.\n    */\n    setPendingFd(pFile);\n  }\n  releaseInodeInfo(pFile);\n  sqlite3_free(pFile->lockingContext);\n  rc = closeUnixFile(id);\n  unixLeaveMutex();\n  return rc;\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the AFP lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  If you don't compile for a mac, then the \"unix-afp\"\n** VFS is not available.\n**\n********************* End of the AFP lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n*************************** Begin NFS Locking ********************************/\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/*\n ** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n ** must be either NO_LOCK or SHARED_LOCK.\n **\n ** If the locking level of the file descriptor is already at or below\n ** the requested locking level, this routine is a no-op.\n */\nstatic int nfsUnlock(sqlite3_file *id, int eFileLock){\n  return posixUnlock(id, eFileLock, 1);\n}\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The code above is the NFS lock implementation.  The code is specific\n** to MacOSX and does not work on other unix platforms.  No alternative\n** is available.  \n**\n********************* End of the NFS lock implementation **********************\n******************************************************************************/\n\n/******************************************************************************\n**************** Non-locking sqlite3_file methods *****************************\n**\n** The next division contains implementations for all methods of the \n** sqlite3_file object other than the locking methods.  The locking\n** methods were defined in divisions above (one locking method per\n** division).  Those methods that are common to all locking modes\n** are gather together into this division.\n*/\n\n/*\n** Seek to the offset passed as the second argument, then read cnt \n** bytes into pBuf. Return the number of bytes actually read.\n**\n** NB:  If you define USE_PREAD or USE_PREAD64, then it might also\n** be necessary to define _XOPEN_SOURCE to be 500.  This varies from\n** one system to another.  Since SQLite does not define USE_PREAD\n** in any form by default, we will not attempt to define _XOPEN_SOURCE.\n** See tickets #2741 and #2681.\n**\n** To avoid stomping the errno value on a failed read the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){\n  int got;\n  int prior = 0;\n#if (!defined(USE_PREAD) && !defined(USE_PREAD64))\n  i64 newOffset;\n#endif\n  TIMER_START;\n  assert( cnt==(cnt&0x1ffff) );\n  assert( id->h>2 );\n  do{\n#if defined(USE_PREAD)\n    got = osPread(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#elif defined(USE_PREAD64)\n    got = osPread64(id->h, pBuf, cnt, offset);\n    SimulateIOError( got = -1 );\n#else\n    newOffset = lseek(id->h, offset, SEEK_SET);\n    SimulateIOError( newOffset = -1 );\n    if( newOffset<0 ){\n      storeLastErrno((unixFile*)id, errno);\n      return -1;\n    }\n    got = osRead(id->h, pBuf, cnt);\n#endif\n    if( got==cnt ) break;\n    if( got<0 ){\n      if( errno==EINTR ){ got = 1; continue; }\n      prior = 0;\n      storeLastErrno((unixFile*)id,  errno);\n      break;\n    }else if( got>0 ){\n      cnt -= got;\n      offset += got;\n      prior += got;\n      pBuf = (void*)(got + (char*)pBuf);\n    }\n  }while( got>0 );\n  TIMER_END;\n  OSTRACE((\"READ    %-3d %5d %7lld %llu\\n\",\n            id->h, got+prior, offset-prior, TIMER_ELAPSED));\n  return got+prior;\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int unixRead(\n  sqlite3_file *id, \n  void *pBuf, \n  int amt,\n  sqlite3_int64 offset\n){\n  unixFile *pFile = (unixFile *)id;\n  int got;\n  assert( id );\n  assert( offset>=0 );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n  got = seekAndRead(pFile, offset, pBuf, amt);\n  if( got==amt ){\n    return SQLITE_OK;\n  }else if( got<0 ){\n    /* lastErrno set by seekAndRead */\n    return SQLITE_IOERR_READ;\n  }else{\n    storeLastErrno(pFile, 0);   /* not a system error */\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[got], 0, amt-got);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n}\n\n/*\n** Attempt to seek the file-descriptor passed as the first argument to\n** absolute offset iOff, then attempt to write nBuf bytes of data from\n** pBuf to it. If an error occurs, return -1 and set *piErrno. Otherwise, \n** return the actual number of bytes written (which may be less than\n** nBuf).\n*/\nstatic int seekAndWriteFd(\n  int fd,                         /* File descriptor to write to */\n  i64 iOff,                       /* File offset to begin writing at */\n  const void *pBuf,               /* Copy data from this buffer to the file */\n  int nBuf,                       /* Size of buffer pBuf in bytes */\n  int *piErrno                    /* OUT: Error number if error occurs */\n){\n  int rc = 0;                     /* Value returned by system call */\n\n  assert( nBuf==(nBuf&0x1ffff) );\n  assert( fd>2 );\n  assert( piErrno!=0 );\n  nBuf &= 0x1ffff;\n  TIMER_START;\n\n#if defined(USE_PREAD)\n  do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );\n#elif defined(USE_PREAD64)\n  do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);\n#else\n  do{\n    i64 iSeek = lseek(fd, iOff, SEEK_SET);\n    SimulateIOError( iSeek = -1 );\n    if( iSeek<0 ){\n      rc = -1;\n      break;\n    }\n    rc = osWrite(fd, pBuf, nBuf);\n  }while( rc<0 && errno==EINTR );\n#endif\n\n  TIMER_END;\n  OSTRACE((\"WRITE   %-3d %5d %7lld %llu\\n\", fd, rc, iOff, TIMER_ELAPSED));\n\n  if( rc<0 ) *piErrno = errno;\n  return rc;\n}\n\n\n/*\n** Seek to the offset in id->offset then read cnt bytes into pBuf.\n** Return the number of bytes actually read.  Update the offset.\n**\n** To avoid stomping the errno value on a failed write the lastErrno value\n** is set before returning.\n*/\nstatic int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){\n  return seekAndWriteFd(id->h, offset, pBuf, cnt, &id->lastErrno);\n}\n\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int unixWrite(\n  sqlite3_file *id, \n  const void *pBuf, \n  int amt,\n  sqlite3_int64 offset \n){\n  unixFile *pFile = (unixFile*)id;\n  int wrote = 0;\n  assert( id );\n  assert( amt>0 );\n\n  /* If this is a database file (not a journal, master-journal or temp\n  ** file), the bytes in the locking range should never be read or written. */\n#if 0\n  assert( pFile->pPreallocatedUnused==0\n       || offset>=PENDING_BYTE+512\n       || offset+amt<=PENDING_BYTE \n  );\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* If we are doing a normal write to a database file (as opposed to\n  ** doing a hot-journal rollback or a write to some file other than a\n  ** normal database file) then record the fact that the database\n  ** has changed.  If the transaction counter is modified, record that\n  ** fact too.\n  */\n  if( pFile->inNormalWrite ){\n    pFile->dbUpdate = 1;  /* The database has been modified */\n    if( offset<=24 && offset+amt>=27 ){\n      int rc;\n      char oldCntr[4];\n      SimulateIOErrorBenign(1);\n      rc = seekAndRead(pFile, 24, oldCntr, 4);\n      SimulateIOErrorBenign(0);\n      if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){\n        pFile->transCntrChng = 1;  /* The transaction counter has changed */\n      }\n    }\n  }\n#endif\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      return SQLITE_OK;\n    }else{\n      int nCopy = pFile->mmapSize - offset;\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n \n  while( (wrote = seekAndWrite(pFile, offset, pBuf, amt))<amt && wrote>0 ){\n    amt -= wrote;\n    offset += wrote;\n    pBuf = &((char*)pBuf)[wrote];\n  }\n  SimulateIOError(( wrote=(-1), amt=1 ));\n  SimulateDiskfullError(( wrote=0, amt=1 ));\n\n  if( amt>wrote ){\n    if( wrote<0 && pFile->lastErrno!=ENOSPC ){\n      /* lastErrno set by seekAndWrite */\n      return SQLITE_IOERR_WRITE;\n    }else{\n      storeLastErrno(pFile, 0); /* not a system error */\n      return SQLITE_FULL;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occurring at the right times.\n*/\nint sqlite3_sync_count = 0;\nint sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** We do not trust systems to provide a working fdatasync().  Some do.\n** Others do no.  To be safe, we will stick with the (slightly slower)\n** fsync(). If you know that your system does support fdatasync() correctly,\n** then simply compile with -Dfdatasync=fdatasync or -DHAVE_FDATASYNC\n*/\n#if !defined(fdatasync) && !HAVE_FDATASYNC\n# define fdatasync fsync\n#endif\n\n/*\n** Define HAVE_FULLFSYNC to 0 or 1 depending on whether or not\n** the F_FULLFSYNC macro is defined.  F_FULLFSYNC is currently\n** only available on Mac OS X.  But that could change.\n*/\n#ifdef F_FULLFSYNC\n# define HAVE_FULLFSYNC 1\n#else\n# define HAVE_FULLFSYNC 0\n#endif\n\n\n/*\n** The fsync() system call does not work as advertised on many\n** unix systems.  The following procedure is an attempt to make\n** it work better.\n**\n** The SQLITE_NO_SYNC macro disables all fsync()s.  This is useful\n** for testing when we want to run through the test suite quickly.\n** You are strongly advised *not* to deploy with SQLITE_NO_SYNC\n** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash\n** or power failure will likely corrupt the database file.\n**\n** SQLite sets the dataOnly flag if the size of the file is unchanged.\n** The idea behind dataOnly is that it should only write the file content\n** to disk, not the inode.  We only set dataOnly if the file size is \n** unchanged since the file size is part of the inode.  However, \n** Ted Ts'o tells us that fdatasync() will also write the inode if the\n** file size has changed.  The only real difference between fdatasync()\n** and fsync(), Ted tells us, is that fdatasync() will not flush the\n** inode if the mtime or owner or other inode attributes have changed.\n** We only care about the file size, not the other file attributes, so\n** as far as SQLite is concerned, an fdatasync() is always adequate.\n** So, we always use fdatasync() if it is available, regardless of\n** the value of the dataOnly flag.\n*/\nstatic int full_fsync(int fd, int fullSync, int dataOnly){\n  int rc;\n\n  /* The following \"ifdef/elif/else/\" block has the same structure as\n  ** the one below. It is replicated here solely to avoid cluttering \n  ** up the real code with the UNUSED_PARAMETER() macros.\n  */\n#ifdef SQLITE_NO_SYNC\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#elif HAVE_FULLFSYNC\n  UNUSED_PARAMETER(dataOnly);\n#else\n  UNUSED_PARAMETER(fullSync);\n  UNUSED_PARAMETER(dataOnly);\n#endif\n\n  /* Record the number of times that we do a normal fsync() and \n  ** FULLSYNC.  This is used during testing to verify that this procedure\n  ** gets called with the correct arguments.\n  */\n#ifdef SQLITE_TEST\n  if( fullSync ) sqlite3_fullsync_count++;\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op.  But go ahead and call fstat() to validate the file\n  ** descriptor as we need a method to provoke a failure during\n  ** coverate testing.\n  */\n#ifdef SQLITE_NO_SYNC\n  {\n    struct stat buf;\n    rc = osFstat(fd, &buf);\n  }\n#elif HAVE_FULLFSYNC\n  if( fullSync ){\n    rc = osFcntl(fd, F_FULLFSYNC, 0);\n  }else{\n    rc = 1;\n  }\n  /* If the FULLFSYNC failed, fall back to attempting an fsync().\n  ** It shouldn't be possible for fullfsync to fail on the local \n  ** file system (on OSX), so failure indicates that FULLFSYNC\n  ** isn't supported for this file system. So, attempt an fsync \n  ** and (for now) ignore the overhead of a superfluous fcntl call.  \n  ** It'd be better to detect fullfsync support once and avoid \n  ** the fcntl call every time sync is called.\n  */\n  if( rc ) rc = fsync(fd);\n\n#elif defined(__APPLE__)\n  /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly\n  ** so currently we default to the macro that redefines fdatasync to fsync\n  */\n  rc = fsync(fd);\n#else \n  rc = fdatasync(fd);\n#if OS_VXWORKS\n  if( rc==-1 && errno==ENOTSUP ){\n    rc = fsync(fd);\n  }\n#endif /* OS_VXWORKS */\n#endif /* ifdef SQLITE_NO_SYNC elif HAVE_FULLFSYNC */\n\n  if( OS_VXWORKS && rc!= -1 ){\n    rc = 0;\n  }\n  return rc;\n}\n\n/*\n** Open a file descriptor to the directory containing file zFilename.\n** If successful, *pFd is set to the opened file descriptor and\n** SQLITE_OK is returned. If an error occurs, either SQLITE_NOMEM\n** or SQLITE_CANTOPEN is returned and *pFd is set to an undefined\n** value.\n**\n** The directory file descriptor is used for only one thing - to\n** fsync() a directory to make sure file creation and deletion events\n** are flushed to disk.  Such fsyncs are not needed on newer\n** journaling filesystems, but are required on older filesystems.\n**\n** This routine can be overridden using the xSetSysCall interface.\n** The ability to override this routine was added in support of the\n** chromium sandbox.  Opening a directory is a security risk (we are\n** told) so making it overrideable allows the chromium sandbox to\n** replace this routine with a harmless no-op.  To make this routine\n** a no-op, replace it with a stub that returns SQLITE_OK but leaves\n** *pFd set to a negative number.\n**\n** If SQLITE_OK is returned, the caller is responsible for closing\n** the file descriptor *pFd using close().\n*/\nstatic int openDirectory(const char *zFilename, int *pFd){\n  int ii;\n  int fd = -1;\n  char zDirname[MAX_PATHNAME+1];\n\n  sqlite3_snprintf(MAX_PATHNAME, zDirname, \"%s\", zFilename);\n  for(ii=(int)strlen(zDirname); ii>0 && zDirname[ii]!='/'; ii--);\n  if( ii>0 ){\n    zDirname[ii] = '\\0';\n  }else{\n    if( zDirname[0]!='/' ) zDirname[0] = '.';\n    zDirname[1] = 0;\n  }\n  fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0);\n  if( fd>=0 ){\n    OSTRACE((\"OPENDIR %-3d %s\\n\", fd, zDirname));\n  }\n  *pFd = fd;\n  if( fd>=0 ) return SQLITE_OK;\n  return unixLogError(SQLITE_CANTOPEN_BKPT, \"openDirectory\", zDirname);\n}\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n**\n** If dataOnly==0 then both the file itself and its metadata (file\n** size, access time, etc) are synced.  If dataOnly!=0 then only the\n** file data is synced.\n**\n** Under Unix, also make sure that the directory entry for the file\n** has been created by fsync-ing the directory that contains the file.\n** If we do not do this and we encounter a power failure, the directory\n** entry for the journal might not exist after we reboot.  The next\n** SQLite to access the file will not know that the journal exists (because\n** the directory entry for the journal was never created) and the transaction\n** will not roll back - possibly leading to database corruption.\n*/\nstatic int unixSync(sqlite3_file *id, int flags){\n  int rc;\n  unixFile *pFile = (unixFile*)id;\n\n  int isDataOnly = (flags&SQLITE_SYNC_DATAONLY);\n  int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL;\n\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  assert( pFile );\n  OSTRACE((\"SYNC    %-3d\\n\", pFile->h));\n  rc = full_fsync(pFile->h, isFullsync, isDataOnly);\n  SimulateIOError( rc=1 );\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_FSYNC, \"full_fsync\", pFile->zPath);\n  }\n\n  /* Also fsync the directory containing the file if the DIRSYNC flag\n  ** is set.  This is a one-time occurrence.  Many systems (examples: AIX)\n  ** are unable to fsync a directory, so ignore errors on the fsync.\n  */\n  if( pFile->ctrlFlags & UNIXFILE_DIRSYNC ){\n    int dirfd;\n    OSTRACE((\"DIRSYNC %s (have_fullfsync=%d fullsync=%d)\\n\", pFile->zPath,\n            HAVE_FULLFSYNC, isFullsync));\n    rc = osOpenDirectory(pFile->zPath, &dirfd);\n    if( rc==SQLITE_OK ){\n      full_fsync(dirfd, 0, 0);\n      robust_close(pFile, dirfd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n    pFile->ctrlFlags &= ~UNIXFILE_DIRSYNC;\n  }\n  return rc;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int unixTruncate(sqlite3_file *id, i64 nByte){\n  unixFile *pFile = (unixFile *)id;\n  int rc;\n  assert( pFile );\n  SimulateIOError( return SQLITE_IOERR_TRUNCATE );\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  rc = robust_ftruncate(pFile->h, nByte);\n  if( rc ){\n    storeLastErrno(pFile, errno);\n    return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n  }else{\n#ifdef SQLITE_DEBUG\n    /* If we are doing a normal write to a database file (as opposed to\n    ** doing a hot-journal rollback or a write to some file other than a\n    ** normal database file) and we truncate the file to zero length,\n    ** that effectively updates the change counter.  This might happen\n    ** when restoring a database using the backup API from a zero-length\n    ** source.\n    */\n    if( pFile->inNormalWrite && nByte==0 ){\n      pFile->transCntrChng = 1;\n    }\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n    /* If the file was just truncated to a size smaller than the currently\n    ** mapped region, reduce the effective mapping size as well. SQLite will\n    ** use read() and write() to access data beyond this point from now on.  \n    */\n    if( nByte<pFile->mmapSize ){\n      pFile->mmapSize = nByte;\n    }\n#endif\n\n    return SQLITE_OK;\n  }\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int unixFileSize(sqlite3_file *id, i64 *pSize){\n  int rc;\n  struct stat buf;\n  assert( id );\n  rc = osFstat(((unixFile*)id)->h, &buf);\n  SimulateIOError( rc=1 );\n  if( rc!=0 ){\n    storeLastErrno((unixFile*)id, errno);\n    return SQLITE_IOERR_FSTAT;\n  }\n  *pSize = buf.st_size;\n\n  /* When opening a zero-size database, the findInodeInfo() procedure\n  ** writes a single byte into that file in order to work around a bug\n  ** in the OS-X msdos filesystem.  In order to avoid problems with upper\n  ** layers, we need to report this file size as zero even though it is\n  ** really 1.   Ticket #3260.\n  */\n  if( *pSize==1 ) *pSize = 0;\n\n\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Handler for proxy-locking file-control verbs.  Defined below in the\n** proxying locking division.\n*/\nstatic int proxyFileControl(sqlite3_file*,int,void*);\n#endif\n\n/* \n** This function is called to handle the SQLITE_FCNTL_SIZE_HINT \n** file-control operation.  Enlarge the database to nBytes in size\n** (rounded up to the next chunk-size).  If the database is already\n** nBytes or larger, this routine is a no-op.\n*/\nstatic int fcntlSizeHint(unixFile *pFile, i64 nByte){\n  if( pFile->szChunk>0 ){\n    i64 nSize;                    /* Required file size */\n    struct stat buf;              /* Used to hold return values of fstat() */\n   \n    if( osFstat(pFile->h, &buf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n\n    nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;\n    if( nSize>(i64)buf.st_size ){\n\n#if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE\n      /* The code below is handling the return value of osFallocate() \n      ** correctly. posix_fallocate() is defined to \"returns zero on success, \n      ** or an error number on  failure\". See the manpage for details. */\n      int err;\n      do{\n        err = osFallocate(pFile->h, buf.st_size, nSize-buf.st_size);\n      }while( err==EINTR );\n      if( err ) return SQLITE_IOERR_WRITE;\n#else\n      /* If the OS does not have posix_fallocate(), fake it. Write a \n      ** single byte to the last byte in each block that falls entirely\n      ** within the extended region. Then, if required, a single byte\n      ** at offset (nSize-1), to set the size of the file correctly.\n      ** This is a similar technique to that used by glibc on systems\n      ** that do not have a real fallocate() call.\n      */\n      int nBlk = buf.st_blksize;  /* File-system block size */\n      int nWrite = 0;             /* Number of bytes written by seekAndWrite */\n      i64 iWrite;                 /* Next offset to write to */\n\n      iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;\n      assert( iWrite>=buf.st_size );\n      assert( ((iWrite+1)%nBlk)==0 );\n      for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){\n        if( iWrite>=nSize ) iWrite = nSize - 1;\n        nWrite = seekAndWrite(pFile, iWrite, \"\", 1);\n        if( nWrite!=1 ) return SQLITE_IOERR_WRITE;\n      }\n#endif\n    }\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->mmapSizeMax>0 && nByte>pFile->mmapSize ){\n    int rc;\n    if( pFile->szChunk<=0 ){\n      if( robust_ftruncate(pFile->h, nByte) ){\n        storeLastErrno(pFile, errno);\n        return unixLogError(SQLITE_IOERR_TRUNCATE, \"ftruncate\", pFile->zPath);\n      }\n    }\n\n    rc = unixMapfile(pFile, nByte);\n    return rc;\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward declaration */\nstatic int unixGetTempname(int nBuf, char *zBuf);\n\n/*\n** Information and control of an open file handle.\n*/\nstatic int unixFileControl(sqlite3_file *id, int op, void *pArg){\n  unixFile *pFile = (unixFile*)id;\n  switch( op ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE);\n      return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK;\n    }\n    case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: {\n      int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE);\n      return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->eFileLock;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = pFile->lastErrno;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      int rc;\n      SimulateIOErrorBenign(1);\n      rc = fcntlSizeHint(pFile, *(i64 *)pArg);\n      SimulateIOErrorBenign(0);\n      return rc;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      unixModeBit(pFile, UNIXFILE_PERSIST_WAL, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      unixModeBit(pFile, UNIXFILE_PSOW, (int*)pArg);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );\n      if( zTFile ){\n        unixGetTempname(pFile->pVfs->mxPathname, zTFile);\n        *(char**)pArg = zTFile;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_HAS_MOVED: {\n      *(int*)pArg = fileHasMoved(pFile);\n      return SQLITE_OK;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (size_t) and passed\n      ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a\n      ** 64-bit type. */\n      if( newLimit>0 && sizeof(size_t)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          unixUnmapfile(pFile);\n          rc = unixMapfile(pFile, -1);\n        }\n      }\n      return rc;\n    }\n#endif\n#ifdef SQLITE_DEBUG\n    /* The pager calls this method to signal that it has done\n    ** a rollback and that the database is therefore unchanged and\n    ** it hence it is OK for the transaction change counter to be\n    ** unchanged.\n    */\n    case SQLITE_FCNTL_DB_UNCHANGED: {\n      ((unixFile*)id)->dbUpdate = 0;\n      return SQLITE_OK;\n    }\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE:\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      return proxyFileControl(id,op,pArg);\n    }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */\n  }\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** If pFd->sectorSize is non-zero when this function is called, it is a\n** no-op. Otherwise, the values of pFd->sectorSize and \n** pFd->deviceCharacteristics are set according to the file-system \n** characteristics. \n**\n** There are two versions of this function. One for QNX and one for all\n** other systems.\n*/\n#ifndef __QNXNTO__\nstatic void setDeviceCharacteristics(unixFile *pFd){\n  assert( pFd->deviceCharacteristics==0 || pFd->sectorSize!=0 );\n  if( pFd->sectorSize==0 ){\n#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n    int res;\n    u32 f = 0;\n\n    /* Check for support for F2FS atomic batch writes. */\n    res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f);\n    if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){\n      pFd->deviceCharacteristics = SQLITE_IOCAP_BATCH_ATOMIC;\n    }\n#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */\n\n    /* Set the POWERSAFE_OVERWRITE flag if requested. */\n    if( pFd->ctrlFlags & UNIXFILE_PSOW ){\n      pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n    }\n\n    pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#else\n#include <sys/dcmd_blk.h>\n#include <sys/statvfs.h>\nstatic void setDeviceCharacteristics(unixFile *pFile){\n  if( pFile->sectorSize == 0 ){\n    struct statvfs fsInfo;\n       \n    /* Set defaults for non-supported filesystems */\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n    pFile->deviceCharacteristics = 0;\n    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {\n      return pFile->sectorSize;\n    }\n\n    if( !strcmp(fsInfo.f_basetype, \"tmp\") ) {\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"etfs\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* etfs cluster size writes are atomic */\n        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx6\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( !strcmp(fsInfo.f_basetype, \"qnx4\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else if( strstr(fsInfo.f_basetype, \"dos\") ){\n      pFile->sectorSize = fsInfo.f_bsize;\n      pFile->deviceCharacteristics =\n        /* full bitset of atomics from max sector size and smaller */\n        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |\n        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind\n                                      ** so it is ordered */\n        0;\n    }else{\n      pFile->deviceCharacteristics =\n        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */\n        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until\n                                      ** the write succeeds */\n        0;\n    }\n  }\n  /* Last chance verification.  If the sector size isn't a multiple of 512\n  ** then it isn't valid.*/\n  if( pFile->sectorSize % 512 != 0 ){\n    pFile->deviceCharacteristics = 0;\n    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;\n  }\n}\n#endif\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int unixSectorSize(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->sectorSize;\n}\n\n/*\n** Return the device characteristics for the file.\n**\n** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.\n** However, that choice is controversial since technically the underlying\n** file system does not always provide powersafe overwrites.  (In other\n** words, after a power-loss event, parts of the file that were never\n** written might end up being altered.)  However, non-PSOW behavior is very,\n** very rare.  And asserting PSOW makes a large reduction in the amount\n** of required I/O for journaling, since a lot of padding is eliminated.\n**  Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control\n** available to turn it off and URI query parameter available to turn it off.\n*/\nstatic int unixDeviceCharacteristics(sqlite3_file *id){\n  unixFile *pFd = (unixFile*)id;\n  setDeviceCharacteristics(pFd);\n  return pFd->deviceCharacteristics;\n}\n\n#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n\n/*\n** Return the system page size.\n**\n** This function should not be called directly by other code in this file. \n** Instead, it should be called via macro osGetpagesize().\n*/\nstatic int unixGetpagesize(void){\n#if OS_VXWORKS\n  return 1024;\n#elif defined(_BSD_SOURCE)\n  return getpagesize();\n#else\n  return (int)sysconf(_SC_PAGESIZE);\n#endif\n}\n\n#endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Object used to represent an shared memory buffer.  \n**\n** When multiple threads all reference the same wal-index, each thread\n** has its own unixShm object, but they all point to a single instance\n** of this unixShmNode object.  In other words, each wal-index is opened\n** only once per process.\n**\n** Each unixShmNode object is connected to a single unixInodeInfo object.\n** We could coalesce this object into unixInodeInfo, but that would mean\n** every open file that does not use shared memory (in other words, most\n** open files) would have to carry around this extra information.  So\n** the unixInodeInfo object contains a pointer to this unixShmNode object\n** and the unixShmNode object is created only when needed.\n**\n** unixMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**\n** The following fields are read-only after the object is created:\n** \n**      fid\n**      zFilename\n**\n** Either unixShmNode.mutex must be held or unixShmNode.nRef==0 and\n** unixMutexHeld() is true when reading or writing any other field\n** in this structure.\n*/\nstruct unixShmNode {\n  unixInodeInfo *pInode;     /* unixInodeInfo that owns this SHM node */\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the mmapped file */\n  int h;                     /* Open file descriptor */\n  int szRegion;              /* Size of shared-memory regions */\n  u16 nRegion;               /* Size of array apRegion */\n  u8 isReadonly;             /* True if read-only */\n  char **apRegion;           /* Array of mapped shared-memory regions */\n  int nRef;                  /* Number of unixShm objects pointing to this */\n  unixShm *pFirst;           /* All unixShm objects pointing to this */\n#ifdef SQLITE_DEBUG\n  u8 exclMask;               /* Mask of exclusive locks held */\n  u8 sharedMask;             /* Mask of shared locks held */\n  u8 nextShmId;              /* Next available unixShm.id value */\n#endif\n};\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    unixShm.pFile\n**    unixShm.id\n**\n** All other fields are read/write.  The unixShm.pFile->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct unixShm {\n  unixShmNode *pShmNode;     /* The underlying unixShmNode object */\n  unixShm *pNext;            /* Next unixShm with the same unixShmNode */\n  u8 hasMutex;               /* True if holding the unixShmNode mutex */\n  u8 id;                     /* Id of this connection within its unixShmNode */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n};\n\n/*\n** Constants used for locking\n*/\n#define UNIX_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)         /* first lock byte */\n#define UNIX_SHM_DMS    (UNIX_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply posix advisory locks for all bytes from ofst through ofst+n-1.\n**\n** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking\n** otherwise.\n*/\nstatic int unixShmSystemLock(\n  unixFile *pFile,       /* Open connection to the WAL file */\n  int lockType,          /* F_UNLCK, F_RDLCK, or F_WRLCK */\n  int ofst,              /* First byte of the locking range */\n  int n                  /* Number of bytes to lock */\n){\n  unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */\n  struct flock f;        /* The posix advisory locking structure */\n  int rc = SQLITE_OK;    /* Result code form fcntl() */\n\n  /* Access to the unixShmNode object is serialized by the caller */\n  pShmNode = pFile->pInode->pShmNode;\n  assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );\n\n  /* Shared locks never span more than one byte */\n  assert( n==1 || lockType!=F_RDLCK );\n\n  /* Locks are within range */\n  assert( n>=1 && n<=SQLITE_SHM_NLOCK );\n\n  if( pShmNode->h>=0 ){\n    /* Initialize the locking parameters */\n    memset(&f, 0, sizeof(f));\n    f.l_type = lockType;\n    f.l_whence = SEEK_SET;\n    f.l_start = ofst;\n    f.l_len = n;\n\n    rc = osFcntl(pShmNode->h, F_SETLK, &f);\n    rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;\n  }\n\n  /* Update the global lock state and do debug tracing */\n#ifdef SQLITE_DEBUG\n  { u16 mask;\n  OSTRACE((\"SHM-LOCK \"));\n  mask = ofst>31 ? 0xffff : (1<<(ofst+n)) - (1<<ofst);\n  if( rc==SQLITE_OK ){\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask &= ~mask;\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock %d ok\", ofst));\n      pShmNode->exclMask &= ~mask;\n      pShmNode->sharedMask |= mask;\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d ok\", ofst));\n      pShmNode->exclMask |= mask;\n      pShmNode->sharedMask &= ~mask;\n    }\n  }else{\n    if( lockType==F_UNLCK ){\n      OSTRACE((\"unlock %d failed\", ofst));\n    }else if( lockType==F_RDLCK ){\n      OSTRACE((\"read-lock failed\"));\n    }else{\n      assert( lockType==F_WRLCK );\n      OSTRACE((\"write-lock %d failed\", ofst));\n    }\n  }\n  OSTRACE((\" - afterwards %03x,%03x\\n\",\n           pShmNode->sharedMask, pShmNode->exclMask));\n  }\n#endif\n\n  return rc;        \n}\n\n/*\n** Return the minimum number of 32KB shm regions that should be mapped at\n** a time, assuming that each mapping must be an integer multiple of the\n** current system page-size.\n**\n** Usually, this is 1. The exception seems to be systems that are configured\n** to use 64KB pages - in this case each mapping must cover at least two\n** shm regions.\n*/\nstatic int unixShmRegionPerMap(void){\n  int shmsz = 32*1024;            /* SHM region size */\n  int pgsz = osGetpagesize();   /* System page size */\n  assert( ((pgsz-1)&pgsz)==0 );   /* Page size must be a power of 2 */\n  if( pgsz<shmsz ) return 1;\n  return pgsz/shmsz;\n}\n\n/*\n** Purge the unixShmNodeList list of all entries with unixShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void unixShmPurge(unixFile *pFd){\n  unixShmNode *p = pFd->pInode->pShmNode;\n  assert( unixMutexHeld() );\n  if( p && ALWAYS(p->nRef==0) ){\n    int nShmPerMap = unixShmRegionPerMap();\n    int i;\n    assert( p->pInode==pFd->pInode );\n    sqlite3_mutex_free(p->mutex);\n    for(i=0; i<p->nRegion; i+=nShmPerMap){\n      if( p->h>=0 ){\n        osMunmap(p->apRegion[i], p->szRegion);\n      }else{\n        sqlite3_free(p->apRegion[i]);\n      }\n    }\n    sqlite3_free(p->apRegion);\n    if( p->h>=0 ){\n      robust_close(pFd, p->h, __LINE__);\n      p->h = -1;\n    }\n    p->pInode->pShmNode = 0;\n    sqlite3_free(p);\n  }\n}\n\n/*\n** Open a shared-memory area associated with open database file pDbFd.  \n** This particular implementation uses mmapped files.\n**\n** The file used to implement shared-memory is in the same directory\n** as the open database file and has the same name as the open database\n** file with the \"-shm\" suffix added.  For example, if the database file\n** is \"/home/user1/config.db\" then the file that is created and mmapped\n** for shared memory will be called \"/home/user1/config.db-shm\".  \n**\n** Another approach to is to use files in /dev/shm or /dev/tmp or an\n** some other tmpfs mount. But if a file in a different directory\n** from the database file is used, then differing access permissions\n** or a chroot() might cause two different processes on the same\n** database to end up using different files for shared memory - \n** meaning that their memory would not really be shared - resulting\n** in database corruption.  Nevertheless, this tmpfs file usage\n** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY=\"/dev/shm\"\n** or the equivalent.  The use of the SQLITE_SHM_DIRECTORY compile-time\n** option results in an incompatible build of SQLite;  builds of SQLite\n** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the\n** same database file at the same time, database corruption will likely\n** result. The SQLITE_SHM_DIRECTORY compile-time option is considered\n** \"unsupported\" and may go away in a future SQLite release.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n**\n** If the original database file (pDbFd) is using the \"unix-excl\" VFS\n** that means that an exclusive lock is held on the database file and\n** that no other processes are able to read or write the database.  In\n** that case, we do not really need shared memory.  No shared memory\n** file is created.  The shared memory will be simulated with heap memory.\n*/\nstatic int unixOpenSharedMemory(unixFile *pDbFd){\n  struct unixShm *p = 0;          /* The connection to be opened */\n  struct unixShmNode *pShmNode;   /* The underlying mmapped file */\n  int rc;                         /* Result code */\n  unixInodeInfo *pInode;          /* The inode of fd */\n  char *zShmFilename;             /* Name of the file used for SHM */\n  int nShmFilename;               /* Size of the SHM filename in bytes */\n\n  /* Allocate space for the new unixShm object. */\n  p = sqlite3_malloc64( sizeof(*p) );\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  assert( pDbFd->pShm==0 );\n\n  /* Check to see if a unixShmNode object already exists. Reuse an existing\n  ** one if present. Create a new one if necessary.\n  */\n  unixEnterMutex();\n  pInode = pDbFd->pInode;\n  pShmNode = pInode->pShmNode;\n  if( pShmNode==0 ){\n    struct stat sStat;                 /* fstat() info for database file */\n#ifndef SQLITE_SHM_DIRECTORY\n    const char *zBasePath = pDbFd->zPath;\n#endif\n\n    /* Call fstat() to figure out the permissions on the database file. If\n    ** a new *-shm file is created, an attempt will be made to create it\n    ** with the same permissions.\n    */\n    if( osFstat(pDbFd->h, &sStat) ){\n      rc = SQLITE_IOERR_FSTAT;\n      goto shm_open_err;\n    }\n\n#ifdef SQLITE_SHM_DIRECTORY\n    nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;\n#else\n    nShmFilename = 6 + (int)strlen(zBasePath);\n#endif\n    pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename );\n    if( pShmNode==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto shm_open_err;\n    }\n    memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);\n    zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1];\n#ifdef SQLITE_SHM_DIRECTORY\n    sqlite3_snprintf(nShmFilename, zShmFilename, \n                     SQLITE_SHM_DIRECTORY \"/sqlite-shm-%x-%x\",\n                     (u32)sStat.st_ino, (u32)sStat.st_dev);\n#else\n    sqlite3_snprintf(nShmFilename, zShmFilename, \"%s-shm\", zBasePath);\n    sqlite3FileSuffix3(pDbFd->zPath, zShmFilename);\n#endif\n    pShmNode->h = -1;\n    pDbFd->pInode->pShmNode = pShmNode;\n    pShmNode->pInode = pDbFd->pInode;\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->mutex==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    if( pInode->bProcessLock==0 ){\n      int openFlags = O_RDWR | O_CREAT;\n      if( sqlite3_uri_boolean(pDbFd->zPath, \"readonly_shm\", 0) ){\n        openFlags = O_RDONLY;\n        pShmNode->isReadonly = 1;\n      }\n      pShmNode->h = robust_open(zShmFilename, openFlags, (sStat.st_mode&0777));\n      if( pShmNode->h<0 ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zShmFilename);\n        goto shm_open_err;\n      }\n\n      /* If this process is running as root, make sure that the SHM file\n      ** is owned by the same user that owns the original database.  Otherwise,\n      ** the original owner will not be able to connect.\n      */\n      robustFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);\n  \n      /* Check to see if another process is holding the dead-man switch.\n      ** If not, truncate the file to zero length. \n      */\n      rc = SQLITE_OK;\n      if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){\n        if( robust_ftruncate(pShmNode->h, 0) ){\n          rc = unixLogError(SQLITE_IOERR_SHMOPEN, \"ftruncate\", zShmFilename);\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);\n      }\n      if( rc ) goto shm_open_err;\n    }\n  }\n\n  /* Make the new connection a child of the unixShmNode */\n  p->pShmNode = pShmNode;\n#ifdef SQLITE_DEBUG\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  unixLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the unixEnterMutex() mutex and the pointer from the\n  ** new (struct unixShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex \n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  unixShmPurge(pDbFd);       /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  unixLeaveMutex();\n  return rc;\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the \n** shared-memory associated with the database file fd. Shared-memory regions \n** are numbered starting from zero. Each shared-memory region is szRegion \n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the bExtend parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If \n** bExtend is non-zero and the requested shared-memory region has not yet \n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes \n** address space (if it is not already), *pp is set to point to the mapped \n** memory and SQLITE_OK returned.\n*/\nstatic int unixShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  unixFile *pDbFd = (unixFile*)fd;\n  unixShm *p;\n  unixShmNode *pShmNode;\n  int rc = SQLITE_OK;\n  int nShmPerMap = unixShmRegionPerMap();\n  int nReqRegion;\n\n  /* If the shared-memory file has not yet been opened, open it now. */\n  if( pDbFd->pShm==0 ){\n    rc = unixOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  p = pDbFd->pShm;\n  pShmNode = p->pShmNode;\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  /* Minimum number of regions required to be mapped. */\n  nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;\n\n  if( pShmNode->nRegion<nReqRegion ){\n    char **apNew;                      /* New apRegion[] array */\n    int nByte = nReqRegion*szRegion;   /* Minimum required file size */\n    struct stat sStat;                 /* Used by fstat() */\n\n    pShmNode->szRegion = szRegion;\n\n    if( pShmNode->h>=0 ){\n      /* The requested region is not mapped into this processes address space.\n      ** Check to see if it has been allocated (i.e. if the wal-index file is\n      ** large enough to contain the requested region).\n      */\n      if( osFstat(pShmNode->h, &sStat) ){\n        rc = SQLITE_IOERR_SHMSIZE;\n        goto shmpage_out;\n      }\n  \n      if( sStat.st_size<nByte ){\n        /* The requested memory region does not exist. If bExtend is set to\n        ** false, exit early. *pp will be set to NULL and SQLITE_OK returned.\n        */\n        if( !bExtend ){\n          goto shmpage_out;\n        }\n\n        /* Alternatively, if bExtend is true, extend the file. Do this by\n        ** writing a single byte to the end of each (OS) page being\n        ** allocated or extended. Technically, we need only write to the\n        ** last page in order to extend the file. But writing to all new\n        ** pages forces the OS to allocate them immediately, which reduces\n        ** the chances of SIGBUS while accessing the mapped region later on.\n        */\n        else{\n          static const int pgsz = 4096;\n          int iPg;\n\n          /* Write to the last byte of each newly allocated or extended page */\n          assert( (nByte % pgsz)==0 );\n          for(iPg=(sStat.st_size/pgsz); iPg<(nByte/pgsz); iPg++){\n            int x = 0;\n            if( seekAndWriteFd(pShmNode->h, iPg*pgsz + pgsz-1, \"\", 1, &x)!=1 ){\n              const char *zFile = pShmNode->zFilename;\n              rc = unixLogError(SQLITE_IOERR_SHMSIZE, \"write\", zFile);\n              goto shmpage_out;\n            }\n          }\n        }\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (char **)sqlite3_realloc(\n        pShmNode->apRegion, nReqRegion*sizeof(char *)\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->apRegion = apNew;\n    while( pShmNode->nRegion<nReqRegion ){\n      int nMap = szRegion*nShmPerMap;\n      int i;\n      void *pMem;\n      if( pShmNode->h>=0 ){\n        pMem = osMmap(0, nMap,\n            pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, \n            MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion\n        );\n        if( pMem==MAP_FAILED ){\n          rc = unixLogError(SQLITE_IOERR_SHMMAP, \"mmap\", pShmNode->zFilename);\n          goto shmpage_out;\n        }\n      }else{\n        pMem = sqlite3_malloc64(szRegion);\n        if( pMem==0 ){\n          rc = SQLITE_NOMEM_BKPT;\n          goto shmpage_out;\n        }\n        memset(pMem, 0, szRegion);\n      }\n\n      for(i=0; i<nShmPerMap; i++){\n        pShmNode->apRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i];\n      }\n      pShmNode->nRegion += nShmPerMap;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    *pp = pShmNode->apRegion[iRegion];\n  }else{\n    *pp = 0;\n  }\n  if( pShmNode->isReadonly && rc==SQLITE_OK ) rc = SQLITE_READONLY;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n**\n** Note that the relationship between SHAREd and EXCLUSIVE locks is a little\n** different here than in posix.  In xShmLock(), one can go from unlocked\n** to shared and back or from unlocked to exclusive and back.  But one may\n** not go from shared to exclusive or from exclusive to shared.\n*/\nstatic int unixShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  unixFile *pDbFd = (unixFile*)fd;      /* Connection holding shared memory */\n  unixShm *p = pDbFd->pShm;             /* The shared memory being locked */\n  unixShm *pX;                          /* For looping over all siblings */\n  unixShmNode *pShmNode = p->pShmNode;  /* The underlying file iNode */\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n  assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 );\n  assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 );\n\n  mask = (1<<(ofst+n)) - (1<<ofst);\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    } \n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n  \n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK shmid-%d, pid-%d got %03x,%03x\\n\",\n           p->id, osGetpid(0), p->sharedMask, p->exclMask));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.  \n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void unixShmBarrier(\n  sqlite3_file *fd                /* Database file holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();         /* compiler-defined memory barrier */\n  unixEnterMutex();               /* Also mutex, for redundancy */\n  unixLeaveMutex();\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying \n** storage if deleteFlag is true.\n**\n** If there is no shared memory associated with the connection then this\n** routine is a harmless no-op.\n*/\nstatic int unixShmUnmap(\n  sqlite3_file *fd,               /* The underlying database file */\n  int deleteFlag                  /* Delete shared-memory if true */\n){\n  unixShm *p;                     /* The connection to be closed */\n  unixShmNode *pShmNode;          /* The underlying shared-memory file */\n  unixShm **pp;                   /* For looping over sibling connections */\n  unixFile *pDbFd;                /* The underlying database file */\n\n  pDbFd = (unixFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  assert( pShmNode==pDbFd->pInode->pShmNode );\n  assert( pShmNode->pInode==pDbFd->pInode );\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  unixEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    if( deleteFlag && pShmNode->h>=0 ){\n      osUnlink(pShmNode->zFilename);\n    }\n    unixShmPurge(pDbFd);\n  }\n  unixLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n\n#else\n# define unixShmMap     0\n# define unixShmLock    0\n# define unixShmBarrier 0\n# define unixShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** If it is currently memory mapped, unmap file pFd.\n*/\nstatic void unixUnmapfile(unixFile *pFd){\n  assert( pFd->nFetchOut==0 );\n  if( pFd->pMapRegion ){\n    osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);\n    pFd->pMapRegion = 0;\n    pFd->mmapSize = 0;\n    pFd->mmapSizeActual = 0;\n  }\n}\n\n/*\n** Attempt to set the size of the memory mapping maintained by file \n** descriptor pFd to nNew bytes. Any existing mapping is discarded.\n**\n** If successful, this function sets the following variables:\n**\n**       unixFile.pMapRegion\n**       unixFile.mmapSize\n**       unixFile.mmapSizeActual\n**\n** If unsuccessful, an error message is logged via sqlite3_log() and\n** the three variables above are zeroed. In this case SQLite should\n** continue accessing the database using the xRead() and xWrite()\n** methods.\n*/\nstatic void unixRemapfile(\n  unixFile *pFd,                  /* File descriptor object */\n  i64 nNew                        /* Required mapping size */\n){\n  const char *zErr = \"mmap\";\n  int h = pFd->h;                      /* File descriptor open on db file */\n  u8 *pOrig = (u8 *)pFd->pMapRegion;   /* Pointer to current file mapping */\n  i64 nOrig = pFd->mmapSizeActual;     /* Size of pOrig region in bytes */\n  u8 *pNew = 0;                        /* Location of new mapping */\n  int flags = PROT_READ;               /* Flags to pass to mmap() */\n\n  assert( pFd->nFetchOut==0 );\n  assert( nNew>pFd->mmapSize );\n  assert( nNew<=pFd->mmapSizeMax );\n  assert( nNew>0 );\n  assert( pFd->mmapSizeActual>=pFd->mmapSize );\n  assert( MAP_FAILED!=0 );\n\n#ifdef SQLITE_MMAP_READWRITE\n  if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE;\n#endif\n\n  if( pOrig ){\n#if HAVE_MREMAP\n    i64 nReuse = pFd->mmapSize;\n#else\n    const int szSyspage = osGetpagesize();\n    i64 nReuse = (pFd->mmapSize & ~(szSyspage-1));\n#endif\n    u8 *pReq = &pOrig[nReuse];\n\n    /* Unmap any pages of the existing mapping that cannot be reused. */\n    if( nReuse!=nOrig ){\n      osMunmap(pReq, nOrig-nReuse);\n    }\n\n#if HAVE_MREMAP\n    pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE);\n    zErr = \"mremap\";\n#else\n    pNew = osMmap(pReq, nNew-nReuse, flags, MAP_SHARED, h, nReuse);\n    if( pNew!=MAP_FAILED ){\n      if( pNew!=pReq ){\n        osMunmap(pNew, nNew - nReuse);\n        pNew = 0;\n      }else{\n        pNew = pOrig;\n      }\n    }\n#endif\n\n    /* The attempt to extend the existing mapping failed. Free it. */\n    if( pNew==MAP_FAILED || pNew==0 ){\n      osMunmap(pOrig, nReuse);\n    }\n  }\n\n  /* If pNew is still NULL, try to create an entirely new mapping. */\n  if( pNew==0 ){\n    pNew = osMmap(0, nNew, flags, MAP_SHARED, h, 0);\n  }\n\n  if( pNew==MAP_FAILED ){\n    pNew = 0;\n    nNew = 0;\n    unixLogError(SQLITE_OK, zErr, pFd->zPath);\n\n    /* If the mmap() above failed, assume that all subsequent mmap() calls\n    ** will probably fail too. Fall back to using xRead/xWrite exclusively\n    ** in this case.  */\n    pFd->mmapSizeMax = 0;\n  }\n  pFd->pMapRegion = (void *)pNew;\n  pFd->mmapSize = pFd->mmapSizeActual = nNew;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if \n** there already exists a mapping for this file, and there are still \n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of \n** the mapping to create. Otherwise, if nByte is less than zero, then the \n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured \n** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int unixMapfile(unixFile *pFd, i64 nMap){\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    struct stat statbuf;          /* Low-level file information */\n    if( osFstat(pFd->h, &statbuf) ){\n      return SQLITE_IOERR_FSTAT;\n    }\n    nMap = statbuf.st_size;\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n\n  assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );\n  if( nMap!=pFd->mmapSize ){\n    unixRemapfile(pFd, nMap);\n  }\n\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually \n** release the reference by calling unixUnfetch().\n*/\nstatic int unixFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = unixMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ) return rc;\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a \n** reference obtained by an earlier call to unixFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the unixFetch() invocation. \n**\n** Or, if the third argument is NULL, then this function is being called \n** to inform the VFS layer that, according to POSIX, any existing mapping \n** may now be invalid and should be unmapped.\n*/\nstatic int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  unixFile *pFd = (unixFile *)fd;   /* The underlying database file */\n  UNUSED_PARAMETER(iOff);\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding \n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    unixUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#else\n  UNUSED_PARAMETER(fd);\n  UNUSED_PARAMETER(p);\n  UNUSED_PARAMETER(iOff);\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This division contains definitions of sqlite3_io_methods objects that\n** implement various file locking strategies.  It also contains definitions\n** of \"finder\" functions.  A finder-function is used to locate the appropriate\n** sqlite3_io_methods object for a particular database file.  The pAppData\n** field of the sqlite3_vfs VFS objects are initialized to be pointers to\n** the correct finder-function for that VFS.\n**\n** Most finder functions return a pointer to a fixed sqlite3_io_methods\n** object.  The only interesting finder-function is autolockIoFinder, which\n** looks at the filesystem type and tries to guess the best locking\n** strategy from that.\n**\n** For finder-function F, two objects are created:\n**\n**    (1) The real finder-function named \"FImpt()\".\n**\n**    (2) A constant pointer to this function named just \"F\".\n**\n**\n** A pointer to the F pointer is used as the pAppData value for VFS\n** objects.  We have to do this instead of letting pAppData point\n** directly at the finder-function since C90 rules prevent a void*\n** from be cast into a function pointer.\n**\n**\n** Each instance of this macro generates two objects:\n**\n**   *  A constant sqlite3_io_methods object call METHOD that has locking\n**      methods CLOSE, LOCK, UNLOCK, CKRESLOCK.\n**\n**   *  An I/O method finder function called FINDER that returns a pointer\n**      to the METHOD object in the previous bullet.\n*/\n#define IOMETHODS(FINDER,METHOD,VERSION,CLOSE,LOCK,UNLOCK,CKLOCK,SHMMAP)     \\\nstatic const sqlite3_io_methods METHOD = {                                   \\\n   VERSION,                    /* iVersion */                                \\\n   CLOSE,                      /* xClose */                                  \\\n   unixRead,                   /* xRead */                                   \\\n   unixWrite,                  /* xWrite */                                  \\\n   unixTruncate,               /* xTruncate */                               \\\n   unixSync,                   /* xSync */                                   \\\n   unixFileSize,               /* xFileSize */                               \\\n   LOCK,                       /* xLock */                                   \\\n   UNLOCK,                     /* xUnlock */                                 \\\n   CKLOCK,                     /* xCheckReservedLock */                      \\\n   unixFileControl,            /* xFileControl */                            \\\n   unixSectorSize,             /* xSectorSize */                             \\\n   unixDeviceCharacteristics,  /* xDeviceCapabilities */                     \\\n   SHMMAP,                     /* xShmMap */                                 \\\n   unixShmLock,                /* xShmLock */                                \\\n   unixShmBarrier,             /* xShmBarrier */                             \\\n   unixShmUnmap,               /* xShmUnmap */                               \\\n   unixFetch,                  /* xFetch */                                  \\\n   unixUnfetch,                /* xUnfetch */                                \\\n};                                                                           \\\nstatic const sqlite3_io_methods *FINDER##Impl(const char *z, unixFile *p){   \\\n  UNUSED_PARAMETER(z); UNUSED_PARAMETER(p);                                  \\\n  return &METHOD;                                                            \\\n}                                                                            \\\nstatic const sqlite3_io_methods *(*const FINDER)(const char*,unixFile *p)    \\\n    = FINDER##Impl;\n\n/*\n** Here are all of the sqlite3_io_methods objects for each of the\n** locking strategies.  Functions that return pointers to these methods\n** are also created.\n*/\nIOMETHODS(\n  posixIoFinder,            /* Finder function name */\n  posixIoMethods,           /* sqlite3_io_methods object name */\n  3,                        /* shared memory and mmap are enabled */\n  unixClose,                /* xClose method */\n  unixLock,                 /* xLock method */\n  unixUnlock,               /* xUnlock method */\n  unixCheckReservedLock,    /* xCheckReservedLock method */\n  unixShmMap                /* xShmMap method */\n)\nIOMETHODS(\n  nolockIoFinder,           /* Finder function name */\n  nolockIoMethods,          /* sqlite3_io_methods object name */\n  3,                        /* shared memory is disabled */\n  nolockClose,              /* xClose method */\n  nolockLock,               /* xLock method */\n  nolockUnlock,             /* xUnlock method */\n  nolockCheckReservedLock,  /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\nIOMETHODS(\n  dotlockIoFinder,          /* Finder function name */\n  dotlockIoMethods,         /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  dotlockClose,             /* xClose method */\n  dotlockLock,              /* xLock method */\n  dotlockUnlock,            /* xUnlock method */\n  dotlockCheckReservedLock, /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n\n#if SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  flockIoFinder,            /* Finder function name */\n  flockIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  flockClose,               /* xClose method */\n  flockLock,                /* xLock method */\n  flockUnlock,              /* xUnlock method */\n  flockCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if OS_VXWORKS\nIOMETHODS(\n  semIoFinder,              /* Finder function name */\n  semIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  semXClose,                /* xClose method */\n  semXLock,                 /* xLock method */\n  semXUnlock,               /* xUnlock method */\n  semXCheckReservedLock,    /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  afpIoFinder,              /* Finder function name */\n  afpIoMethods,             /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  afpClose,                 /* xClose method */\n  afpLock,                  /* xLock method */\n  afpUnlock,                /* xUnlock method */\n  afpCheckReservedLock,     /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/*\n** The proxy locking method is a \"super-method\" in the sense that it\n** opens secondary file descriptors for the conch and lock files and\n** it uses proxy, dot-file, AFP, and flock() locking methods on those\n** secondary files.  For this reason, the division that implements\n** proxy locking is located much further down in the file.  But we need\n** to go ahead and define the sqlite3_io_methods and finder function\n** for proxy locking here.  So we forward declare the I/O methods.\n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nstatic int proxyClose(sqlite3_file*);\nstatic int proxyLock(sqlite3_file*, int);\nstatic int proxyUnlock(sqlite3_file*, int);\nstatic int proxyCheckReservedLock(sqlite3_file*, int*);\nIOMETHODS(\n  proxyIoFinder,            /* Finder function name */\n  proxyIoMethods,           /* sqlite3_io_methods object name */\n  1,                        /* shared memory is disabled */\n  proxyClose,               /* xClose method */\n  proxyLock,                /* xLock method */\n  proxyUnlock,              /* xUnlock method */\n  proxyCheckReservedLock,   /* xCheckReservedLock method */\n  0                         /* xShmMap method */\n)\n#endif\n\n/* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\nIOMETHODS(\n  nfsIoFinder,               /* Finder function name */\n  nfsIoMethods,              /* sqlite3_io_methods object name */\n  1,                         /* shared memory is disabled */\n  unixClose,                 /* xClose method */\n  unixLock,                  /* xLock method */\n  nfsUnlock,                 /* xUnlock method */\n  unixCheckReservedLock,     /* xCheckReservedLock method */\n  0                          /* xShmMap method */\n)\n#endif\n\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n/* \n** This \"finder\" function attempts to determine the best locking strategy \n** for the database file \"filePath\".  It then returns the sqlite3_io_methods\n** object that implements that strategy.\n**\n** This is for MacOSX only.\n*/\nstatic const sqlite3_io_methods *autolockIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* open file object for the database file */\n){\n  static const struct Mapping {\n    const char *zFilesystem;              /* Filesystem type name */\n    const sqlite3_io_methods *pMethods;   /* Appropriate locking method */\n  } aMap[] = {\n    { \"hfs\",    &posixIoMethods },\n    { \"ufs\",    &posixIoMethods },\n    { \"afpfs\",  &afpIoMethods },\n    { \"smbfs\",  &afpIoMethods },\n    { \"webdav\", &nolockIoMethods },\n    { 0, 0 }\n  };\n  int i;\n  struct statfs fsInfo;\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n  if( statfs(filePath, &fsInfo) != -1 ){\n    if( fsInfo.f_flags & MNT_RDONLY ){\n      return &nolockIoMethods;\n    }\n    for(i=0; aMap[i].zFilesystem; i++){\n      if( strcmp(fsInfo.f_fstypename, aMap[i].zFilesystem)==0 ){\n        return aMap[i].pMethods;\n      }\n    }\n  }\n\n  /* Default case. Handles, amongst others, \"nfs\".\n  ** Test byte-range lock using fcntl(). If the call succeeds, \n  ** assume that the file-system supports POSIX style locks. \n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    if( strcmp(fsInfo.f_fstypename, \"nfs\")==0 ){\n      return &nfsIoMethods;\n    } else {\n      return &posixIoMethods;\n    }\n  }else{\n    return &dotlockIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n\n#if OS_VXWORKS\n/*\n** This \"finder\" function for VxWorks checks to see if posix advisory\n** locking works.  If it does, then that is what is used.  If it does not\n** work, then fallback to named semaphore locking.\n*/\nstatic const sqlite3_io_methods *vxworksIoFinderImpl(\n  const char *filePath,    /* name of the database file */\n  unixFile *pNew           /* the open file object */\n){\n  struct flock lockInfo;\n\n  if( !filePath ){\n    /* If filePath==NULL that means we are dealing with a transient file\n    ** that does not need to be locked. */\n    return &nolockIoMethods;\n  }\n\n  /* Test if fcntl() is supported and use POSIX style locks.\n  ** Otherwise fall back to the named semaphore method.\n  */\n  lockInfo.l_len = 1;\n  lockInfo.l_start = 0;\n  lockInfo.l_whence = SEEK_SET;\n  lockInfo.l_type = F_RDLCK;\n  if( osFcntl(pNew->h, F_GETLK, &lockInfo)!=-1 ) {\n    return &posixIoMethods;\n  }else{\n    return &semIoMethods;\n  }\n}\nstatic const sqlite3_io_methods \n  *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;\n\n#endif /* OS_VXWORKS */\n\n/*\n** An abstract type for a pointer to an IO method finder function:\n*/\ntypedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);\n\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n/*\n** Initialize the contents of the unixFile structure pointed to by pId.\n*/\nstatic int fillInUnixFile(\n  sqlite3_vfs *pVfs,      /* Pointer to vfs object */\n  int h,                  /* Open file descriptor of file being opened */\n  sqlite3_file *pId,      /* Write to the unixFile structure here */\n  const char *zFilename,  /* Name of the file being opened */\n  int ctrlFlags           /* Zero or more UNIXFILE_* values */\n){\n  const sqlite3_io_methods *pLockingStyle;\n  unixFile *pNew = (unixFile *)pId;\n  int rc = SQLITE_OK;\n\n  assert( pNew->pInode==NULL );\n\n  /* No locking occurs in temporary files */\n  assert( zFilename!=0 || (ctrlFlags & UNIXFILE_NOLOCK)!=0 );\n\n  OSTRACE((\"OPEN    %-3d %s\\n\", h, zFilename));\n  pNew->h = h;\n  pNew->pVfs = pVfs;\n  pNew->zPath = zFilename;\n  pNew->ctrlFlags = (u8)ctrlFlags;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pNew->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n  if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),\n                           \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pNew->ctrlFlags |= UNIXFILE_PSOW;\n  }\n  if( strcmp(pVfs->zName,\"unix-excl\")==0 ){\n    pNew->ctrlFlags |= UNIXFILE_EXCL;\n  }\n\n#if OS_VXWORKS\n  pNew->pId = vxworksFindFileId(zFilename);\n  if( pNew->pId==0 ){\n    ctrlFlags |= UNIXFILE_NOLOCK;\n    rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( ctrlFlags & UNIXFILE_NOLOCK ){\n    pLockingStyle = &nolockIoMethods;\n  }else{\n    pLockingStyle = (**(finder_type*)pVfs->pAppData)(zFilename, pNew);\n#if SQLITE_ENABLE_LOCKING_STYLE\n    /* Cache zFilename in the locking context (AFP and dotlock override) for\n    ** proxyLock activation is possible (remote proxy is based on db name)\n    ** zFilename remains valid until file is closed, to support */\n    pNew->lockingContext = (void*)zFilename;\n#endif\n  }\n\n  if( pLockingStyle == &posixIoMethods\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n    || pLockingStyle == &nfsIoMethods\n#endif\n  ){\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( rc!=SQLITE_OK ){\n      /* If an error occurred in findInodeInfo(), close the file descriptor\n      ** immediately, before releasing the mutex. findInodeInfo() may fail\n      ** in two scenarios:\n      **\n      **   (a) A call to fstat() failed.\n      **   (b) A malloc failed.\n      **\n      ** Scenario (b) may only occur if the process is holding no other\n      ** file descriptors open on the same file. If there were other file\n      ** descriptors on this file, then no malloc would be required by\n      ** findInodeInfo(). If this is the case, it is quite safe to close\n      ** handle h - as it is guaranteed that no posix locks will be released\n      ** by doing so.\n      **\n      ** If scenario (a) caused the error then things are not so safe. The\n      ** implicit assumption here is that if fstat() fails, things are in\n      ** such bad shape that dropping a lock or two doesn't matter much.\n      */\n      robust_close(pNew, h, __LINE__);\n      h = -1;\n    }\n    unixLeaveMutex();\n  }\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  else if( pLockingStyle == &afpIoMethods ){\n    /* AFP locking uses the file path so it needs to be included in\n    ** the afpLockingContext.\n    */\n    afpLockingContext *pCtx;\n    pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n    if( pCtx==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      /* NB: zFilename exists and remains valid until the file is closed\n      ** according to requirement F11141.  So we do not need to make a\n      ** copy of the filename. */\n      pCtx->dbPath = zFilename;\n      pCtx->reserved = 0;\n      srandomdev();\n      unixEnterMutex();\n      rc = findInodeInfo(pNew, &pNew->pInode);\n      if( rc!=SQLITE_OK ){\n        sqlite3_free(pNew->lockingContext);\n        robust_close(pNew, h, __LINE__);\n        h = -1;\n      }\n      unixLeaveMutex();        \n    }\n  }\n#endif\n\n  else if( pLockingStyle == &dotlockIoMethods ){\n    /* Dotfile locking uses the file path so it needs to be included in\n    ** the dotlockLockingContext \n    */\n    char *zLockFile;\n    int nFilename;\n    assert( zFilename!=0 );\n    nFilename = (int)strlen(zFilename) + 6;\n    zLockFile = (char *)sqlite3_malloc64(nFilename);\n    if( zLockFile==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_snprintf(nFilename, zLockFile, \"%s\" DOTLOCK_SUFFIX, zFilename);\n    }\n    pNew->lockingContext = zLockFile;\n  }\n\n#if OS_VXWORKS\n  else if( pLockingStyle == &semIoMethods ){\n    /* Named semaphore locking uses the file path so it needs to be\n    ** included in the semLockingContext\n    */\n    unixEnterMutex();\n    rc = findInodeInfo(pNew, &pNew->pInode);\n    if( (rc==SQLITE_OK) && (pNew->pInode->pSem==NULL) ){\n      char *zSemName = pNew->pInode->aSemName;\n      int n;\n      sqlite3_snprintf(MAX_PATHNAME, zSemName, \"/%s.sem\",\n                       pNew->pId->zCanonicalName);\n      for( n=1; zSemName[n]; n++ )\n        if( zSemName[n]=='/' ) zSemName[n] = '_';\n      pNew->pInode->pSem = sem_open(zSemName, O_CREAT, 0666, 1);\n      if( pNew->pInode->pSem == SEM_FAILED ){\n        rc = SQLITE_NOMEM_BKPT;\n        pNew->pInode->aSemName[0] = '\\0';\n      }\n    }\n    unixLeaveMutex();\n  }\n#endif\n  \n  storeLastErrno(pNew, 0);\n#if OS_VXWORKS\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n    h = -1;\n    osUnlink(zFilename);\n    pNew->ctrlFlags |= UNIXFILE_DELETE;\n  }\n#endif\n  if( rc!=SQLITE_OK ){\n    if( h>=0 ) robust_close(pNew, h, __LINE__);\n  }else{\n    pNew->pMethod = pLockingStyle;\n    OpenCounter(+1);\n    verifyDbFile(pNew);\n  }\n  return rc;\n}\n\n/*\n** Return the name of a directory in which to put temporary files.\n** If no suitable temporary file directory can be found, return NULL.\n*/\nstatic const char *unixTempFileDir(void){\n  static const char *azDirs[] = {\n     0,\n     0,\n     \"/var/tmp\",\n     \"/usr/tmp\",\n     \"/tmp\",\n     \".\"\n  };\n  unsigned int i = 0;\n  struct stat buf;\n  const char *zDir = sqlite3_temp_directory;\n\n  if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n  if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n  while(1){\n    if( zDir!=0\n     && osStat(zDir, &buf)==0\n     && S_ISDIR(buf.st_mode)\n     && osAccess(zDir, 03)==0\n    ){\n      return zDir;\n    }\n    if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break;\n    zDir = azDirs[i++];\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name in zBuf.  zBuf must be allocated\n** by the calling process and must be big enough to hold at least\n** pVfs->mxPathname bytes.\n*/\nstatic int unixGetTempname(int nBuf, char *zBuf){\n  const char *zDir;\n  int iLimit = 0;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. \n  */\n  zBuf[0] = 0;\n  SimulateIOError( return SQLITE_IOERR );\n\n  zDir = unixTempFileDir();\n  if( zDir==0 ) return SQLITE_IOERR_GETTEMPPATH;\n  do{\n    u64 r;\n    sqlite3_randomness(sizeof(r), &r);\n    assert( nBuf>2 );\n    zBuf[nBuf-2] = 0;\n    sqlite3_snprintf(nBuf, zBuf, \"%s/\"SQLITE_TEMP_FILE_PREFIX\"%llx%c\",\n                     zDir, r, 0);\n    if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ) return SQLITE_ERROR;\n  }while( osAccess(zBuf,0)==0 );\n  return SQLITE_OK;\n}\n\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n/*\n** Routine to transform a unixFile into a proxy-locking unixFile.\n** Implementation in the proxy-lock division, but used by unixOpen()\n** if SQLITE_PREFER_PROXY_LOCKING is defined.\n*/\nstatic int proxyTransformUnixFile(unixFile*, const char*);\n#endif\n\n/*\n** Search for an unused file descriptor that was opened on the database \n** file (not a journal or master-journal file) identified by pathname\n** zPath with SQLITE_OPEN_XXX flags matching those passed as the second\n** argument to this function.\n**\n** Such a file descriptor may exist if a database connection was closed\n** but the associated file descriptor could not be closed because some\n** other file descriptor open on the same file is holding a file-lock.\n** Refer to comments in the unixClose() function and the lengthy comment\n** describing \"Posix Advisory Locking\" at the start of this file for \n** further details. Also, ticket #4018.\n**\n** If a suitable file descriptor is found, then it is returned. If no\n** such file descriptor is located, -1 is returned.\n*/\nstatic UnixUnusedFd *findReusableFd(const char *zPath, int flags){\n  UnixUnusedFd *pUnused = 0;\n\n  /* Do not search for an unused file descriptor on vxworks. Not because\n  ** vxworks would not benefit from the change (it might, we're not sure),\n  ** but because no way to test it is currently available. It is better \n  ** not to risk breaking vxworks support for the sake of such an obscure \n  ** feature.  */\n#if !OS_VXWORKS\n  struct stat sStat;                   /* Results of stat() call */\n\n  unixEnterMutex();\n\n  /* A stat() call may fail for various reasons. If this happens, it is\n  ** almost certain that an open() call on the same path will also fail.\n  ** For this reason, if an error occurs in the stat() call here, it is\n  ** ignored and -1 is returned. The caller will try to open a new file\n  ** descriptor on the same path, fail, and return an error to SQLite.\n  **\n  ** Even if a subsequent open() call does succeed, the consequences of\n  ** not searching for a reusable file descriptor are not dire.  */\n  if( nUnusedFd>0 && 0==osStat(zPath, &sStat) ){\n    unixInodeInfo *pInode;\n\n    pInode = inodeList;\n    while( pInode && (pInode->fileId.dev!=sStat.st_dev\n                     || pInode->fileId.ino!=(u64)sStat.st_ino) ){\n       pInode = pInode->pNext;\n    }\n    if( pInode ){\n      UnixUnusedFd **pp;\n      for(pp=&pInode->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));\n      pUnused = *pp;\n      if( pUnused ){\n        nUnusedFd--;\n        *pp = pUnused->pNext;\n      }\n    }\n  }\n  unixLeaveMutex();\n#endif    /* if !OS_VXWORKS */\n  return pUnused;\n}\n\n/*\n** Find the mode, uid and gid of file zFile. \n*/\nstatic int getFileMode(\n  const char *zFile,              /* File name */\n  mode_t *pMode,                  /* OUT: Permissions of zFile */\n  uid_t *pUid,                    /* OUT: uid of zFile. */\n  gid_t *pGid                     /* OUT: gid of zFile. */\n){\n  struct stat sStat;              /* Output of stat() on database file */\n  int rc = SQLITE_OK;\n  if( 0==osStat(zFile, &sStat) ){\n    *pMode = sStat.st_mode & 0777;\n    *pUid = sStat.st_uid;\n    *pGid = sStat.st_gid;\n  }else{\n    rc = SQLITE_IOERR_FSTAT;\n  }\n  return rc;\n}\n\n/*\n** This function is called by unixOpen() to determine the unix permissions\n** to create new files with. If no error occurs, then SQLITE_OK is returned\n** and a value suitable for passing as the third argument to open(2) is\n** written to *pMode. If an IO error occurs, an SQLite error code is \n** returned and the value of *pMode is not modified.\n**\n** In most cases, this routine sets *pMode to 0, which will become\n** an indication to robust_open() to create the file using\n** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.\n** But if the file being opened is a WAL or regular journal file, then \n** this function queries the file-system for the permissions on the \n** corresponding database file and sets *pMode to this value. Whenever \n** possible, WAL and journal files are created using the same permissions \n** as the associated database file.\n**\n** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the\n** original filename is unavailable.  But 8_3_NAMES is only used for\n** FAT filesystems and permissions do not matter there, so just use\n** the default permissions.\n*/\nstatic int findCreateFileMode(\n  const char *zPath,              /* Path of file (possibly) being created */\n  int flags,                      /* Flags passed as 4th argument to xOpen() */\n  mode_t *pMode,                  /* OUT: Permissions to open file with */\n  uid_t *pUid,                    /* OUT: uid to set on the file */\n  gid_t *pGid                     /* OUT: gid to set on the file */\n){\n  int rc = SQLITE_OK;             /* Return Code */\n  *pMode = 0;\n  *pUid = 0;\n  *pGid = 0;\n  if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n    char zDb[MAX_PATHNAME+1];     /* Database file path */\n    int nDb;                      /* Number of valid bytes in zDb */\n\n    /* zPath is a path to a WAL or journal file. The following block derives\n    ** the path to the associated database file from zPath. This block handles\n    ** the following naming conventions:\n    **\n    **   \"<path to db>-journal\"\n    **   \"<path to db>-wal\"\n    **   \"<path to db>-journalNN\"\n    **   \"<path to db>-walNN\"\n    **\n    ** where NN is a decimal number. The NN naming schemes are \n    ** used by the test_multiplex.c module.\n    */\n    nDb = sqlite3Strlen30(zPath) - 1; \n    while( zPath[nDb]!='-' ){\n      /* In normal operation, the journal file name will always contain\n      ** a '-' character.  However in 8+3 filename mode, or if a corrupt\n      ** rollback journal specifies a master journal with a goofy name, then\n      ** the '-' might be missing. */\n      if( nDb==0 || zPath[nDb]=='.' ) return SQLITE_OK;\n      nDb--;\n    }\n    memcpy(zDb, zPath, nDb);\n    zDb[nDb] = '\\0';\n\n    rc = getFileMode(zDb, pMode, pUid, pGid);\n  }else if( flags & SQLITE_OPEN_DELETEONCLOSE ){\n    *pMode = 0600;\n  }else if( flags & SQLITE_OPEN_URI ){\n    /* If this is a main database file and the file was opened using a URI\n    ** filename, check for the \"modeof\" parameter. If present, interpret\n    ** its value as a filename and try to copy the mode, uid and gid from\n    ** that file.  */\n    const char *z = sqlite3_uri_parameter(zPath, \"modeof\");\n    if( z ){\n      rc = getFileMode(z, pMode, pUid, pGid);\n    }\n  }\n  return rc;\n}\n\n/*\n** Open the file zPath.\n** \n** Previously, the SQLite OS layer used three functions in place of this\n** one:\n**\n**     sqlite3OsOpenReadWrite();\n**     sqlite3OsOpenReadOnly();\n**     sqlite3OsOpenExclusive();\n**\n** These calls correspond to the following combinations of flags:\n**\n**     ReadWrite() ->     (READWRITE | CREATE)\n**     ReadOnly()  ->     (READONLY) \n**     OpenExclusive() -> (READWRITE | CREATE | EXCLUSIVE)\n**\n** The old OpenExclusive() accepted a boolean argument - \"delFlag\". If\n** true, the file was configured to be automatically deleted when the\n** file handle closed. To achieve the same effect using this new \n** interface, add the DELETEONCLOSE flag to those specified above for \n** OpenExclusive().\n*/\nstatic int unixOpen(\n  sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */\n  const char *zPath,           /* Pathname of file to be opened */\n  sqlite3_file *pFile,         /* The file descriptor to be filled in */\n  int flags,                   /* Input flags to control the opening */\n  int *pOutFlags               /* Output flags returned to SQLite core */\n){\n  unixFile *p = (unixFile *)pFile;\n  int fd = -1;                   /* File descriptor returned by open() */\n  int openFlags = 0;             /* Flags to pass to open() */\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n  int noLock;                    /* True to omit locking primitives */\n  int rc = SQLITE_OK;            /* Function Return Code */\n  int ctrlFlags = 0;             /* UNIXFILE_* flags */\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n#if SQLITE_ENABLE_LOCKING_STYLE\n  int isAutoProxy  = (flags & SQLITE_OPEN_AUTOPROXY);\n#endif\n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  struct statfs fsInfo;\n#endif\n\n  /* If creating a master or main-file journal, this function will open\n  ** a file-descriptor on the directory too. The first time unixSync()\n  ** is called the directory file descriptor will be fsync()ed and close()d.\n  */\n  int syncDir = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL \n     || eType==SQLITE_OPEN_MAIN_JOURNAL \n     || eType==SQLITE_OPEN_WAL\n  ));\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char zTmpname[MAX_PATHNAME+2];\n  const char *zName = zPath;\n\n  /* Check the following statements are true: \n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and \n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never \n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB \n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL \n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL \n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  /* Detect a pid change and reset the PRNG.  There is a race condition\n  ** here such that two or more threads all trying to open databases at\n  ** the same instant might all reset the PRNG.  But multiple resets\n  ** are harmless.\n  */\n  if( randomnessPid!=osGetpid(0) ){\n    randomnessPid = osGetpid(0);\n    sqlite3_randomness(0,0);\n  }\n\n  memset(p, 0, sizeof(unixFile));\n\n  if( eType==SQLITE_OPEN_MAIN_DB ){\n    UnixUnusedFd *pUnused;\n    pUnused = findReusableFd(zName, flags);\n    if( pUnused ){\n      fd = pUnused->fd;\n    }else{\n      pUnused = sqlite3_malloc64(sizeof(*pUnused));\n      if( !pUnused ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    p->pPreallocatedUnused = pUnused;\n\n    /* Database filenames are double-zero terminated if they are not\n    ** URIs with parameters.  Hence, they can always be passed into\n    ** sqlite3_uri_parameter(). */\n    assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );\n\n  }else if( !zName ){\n    /* If zName is NULL, the upper layer is requesting a temp file. */\n    assert(isDelete && !syncDir);\n    rc = unixGetTempname(pVfs->mxPathname, zTmpname);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    zName = zTmpname;\n\n    /* Generated temporary filenames are always double-zero terminated\n    ** for use by sqlite3_uri_parameter(). */\n    assert( zName[strlen(zName)+1]==0 );\n  }\n\n  /* Determine the value of the flags parameter passed to POSIX function\n  ** open(). These must be calculated even if open() is not called, as\n  ** they may be stored as part of the file handle and used by the \n  ** 'conch file' locking functions later on.  */\n  if( isReadonly )  openFlags |= O_RDONLY;\n  if( isReadWrite ) openFlags |= O_RDWR;\n  if( isCreate )    openFlags |= O_CREAT;\n  if( isExclusive ) openFlags |= (O_EXCL|O_NOFOLLOW);\n  openFlags |= (O_LARGEFILE|O_BINARY);\n\n  if( fd<0 ){\n    mode_t openMode;              /* Permissions to create file with */\n    uid_t uid;                    /* Userid for the file */\n    gid_t gid;                    /* Groupid for the file */\n    rc = findCreateFileMode(zName, flags, &openMode, &uid, &gid);\n    if( rc!=SQLITE_OK ){\n      assert( !p->pPreallocatedUnused );\n      assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );\n      return rc;\n    }\n    fd = robust_open(zName, openFlags, openMode);\n    OSTRACE((\"OPENX   %-3d %s 0%o\\n\", fd, zName, openFlags));\n    assert( !isExclusive || (openFlags & O_CREAT)!=0 );\n    if( fd<0 && errno!=EISDIR && isReadWrite ){\n      /* Failed to open the file for read/write access. Try read-only. */\n      flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);\n      openFlags &= ~(O_RDWR|O_CREAT);\n      flags |= SQLITE_OPEN_READONLY;\n      openFlags |= O_RDONLY;\n      isReadonly = 1;\n      fd = robust_open(zName, openFlags, openMode);\n    }\n    if( fd<0 ){\n      rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"open\", zName);\n      goto open_finished;\n    }\n\n    /* If this process is running as root and if creating a new rollback\n    ** journal or WAL file, set the ownership of the journal or WAL to be\n    ** the same as the original database.\n    */\n    if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){\n      robustFchown(fd, uid, gid);\n    }\n  }\n  assert( fd>=0 );\n  if( pOutFlags ){\n    *pOutFlags = flags;\n  }\n\n  if( p->pPreallocatedUnused ){\n    p->pPreallocatedUnused->fd = fd;\n    p->pPreallocatedUnused->flags = flags;\n  }\n\n  if( isDelete ){\n#if OS_VXWORKS\n    zPath = zName;\n#elif defined(SQLITE_UNLINK_AFTER_CLOSE)\n    zPath = sqlite3_mprintf(\"%s\", zName);\n    if( zPath==0 ){\n      robust_close(p, fd, __LINE__);\n      return SQLITE_NOMEM_BKPT;\n    }\n#else\n    osUnlink(zName);\n#endif\n  }\n#if SQLITE_ENABLE_LOCKING_STYLE\n  else{\n    p->openFlags = openFlags;\n  }\n#endif\n  \n#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE\n  if( fstatfs(fd, &fsInfo) == -1 ){\n    storeLastErrno(p, errno);\n    robust_close(p, fd, __LINE__);\n    return SQLITE_IOERR_ACCESS;\n  }\n  if (0 == strncmp(\"msdos\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n  if (0 == strncmp(\"exfat\", fsInfo.f_fstypename, 5)) {\n    ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;\n  }\n#endif\n\n  /* Set up appropriate ctrlFlags */\n  if( isDelete )                ctrlFlags |= UNIXFILE_DELETE;\n  if( isReadonly )              ctrlFlags |= UNIXFILE_RDONLY;\n  noLock = eType!=SQLITE_OPEN_MAIN_DB;\n  if( noLock )                  ctrlFlags |= UNIXFILE_NOLOCK;\n  if( syncDir )                 ctrlFlags |= UNIXFILE_DIRSYNC;\n  if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n#if SQLITE_PREFER_PROXY_LOCKING\n  isAutoProxy = 1;\n#endif\n  if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){\n    char *envforce = getenv(\"SQLITE_FORCE_PROXY_LOCKING\");\n    int useProxy = 0;\n\n    /* SQLITE_FORCE_PROXY_LOCKING==1 means force always use proxy, 0 means \n    ** never use proxy, NULL means use proxy for non-local files only.  */\n    if( envforce!=NULL ){\n      useProxy = atoi(envforce)>0;\n    }else{\n      useProxy = !(fsInfo.f_flags&MNT_LOCAL);\n    }\n    if( useProxy ){\n      rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n      if( rc==SQLITE_OK ){\n        rc = proxyTransformUnixFile((unixFile*)pFile, \":auto:\");\n        if( rc!=SQLITE_OK ){\n          /* Use unixClose to clean up the resources added in fillInUnixFile \n          ** and clear all the structure's references.  Specifically, \n          ** pFile->pMethods will be NULL so sqlite3OsClose will be a no-op \n          */\n          unixClose(pFile);\n          return rc;\n        }\n      }\n      goto open_finished;\n    }\n  }\n#endif\n  \n  assert( zPath==0 || zPath[0]=='/' \n      || eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL \n  );\n  rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);\n\nopen_finished:\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(p->pPreallocatedUnused);\n  }\n  return rc;\n}\n\n\n/*\n** Delete the file at zPath. If the dirSync argument is true, fsync()\n** the directory after deleting the file.\n*/\nstatic int unixDelete(\n  sqlite3_vfs *NotUsed,     /* VFS containing this as the xDelete method */\n  const char *zPath,        /* Name of file to be deleted */\n  int dirSync               /* If true, fsync() directory after deleting file */\n){\n  int rc = SQLITE_OK;\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  if( osUnlink(zPath)==(-1) ){\n    if( errno==ENOENT\n#if OS_VXWORKS\n        || osAccess(zPath,0)!=0\n#endif\n    ){\n      rc = SQLITE_IOERR_DELETE_NOENT;\n    }else{\n      rc = unixLogError(SQLITE_IOERR_DELETE, \"unlink\", zPath);\n    }\n    return rc;\n  }\n#ifndef SQLITE_DISABLE_DIRSYNC\n  if( (dirSync & 1)!=0 ){\n    int fd;\n    rc = osOpenDirectory(zPath, &fd);\n    if( rc==SQLITE_OK ){\n      if( full_fsync(fd,0,0) ){\n        rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, \"fsync\", zPath);\n      }\n      robust_close(0, fd, __LINE__);\n    }else{\n      assert( rc==SQLITE_CANTOPEN );\n      rc = SQLITE_OK;\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Test the existence of or access permissions of file zPath. The\n** test performed depends on the value of flags:\n**\n**     SQLITE_ACCESS_EXISTS: Return 1 if the file exists\n**     SQLITE_ACCESS_READWRITE: Return 1 if the file is read and writable.\n**     SQLITE_ACCESS_READONLY: Return 1 if the file is readable.\n**\n** Otherwise return 0.\n*/\nstatic int unixAccess(\n  sqlite3_vfs *NotUsed,   /* The VFS containing this xAccess method */\n  const char *zPath,      /* Path of the file to examine */\n  int flags,              /* What do we want to learn about the zPath file? */\n  int *pResOut            /* Write result boolean here */\n){\n  UNUSED_PARAMETER(NotUsed);\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  assert( pResOut!=0 );\n\n  /* The spec says there are three possible values for flags.  But only\n  ** two of them are actually used */\n  assert( flags==SQLITE_ACCESS_EXISTS || flags==SQLITE_ACCESS_READWRITE );\n\n  if( flags==SQLITE_ACCESS_EXISTS ){\n    struct stat buf;\n    *pResOut = (0==osStat(zPath, &buf) && buf.st_size>0);\n  }else{\n    *pResOut = osAccess(zPath, W_OK|R_OK)==0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n**\n*/\nstatic int mkFullPathname(\n  const char *zPath,              /* Input path */\n  char *zOut,                     /* Output buffer */\n  int nOut                        /* Allocated size of buffer zOut */\n){\n  int nPath = sqlite3Strlen30(zPath);\n  int iOff = 0;\n  if( zPath[0]!='/' ){\n    if( osGetcwd(zOut, nOut-2)==0 ){\n      return unixLogError(SQLITE_CANTOPEN_BKPT, \"getcwd\", zPath);\n    }\n    iOff = sqlite3Strlen30(zOut);\n    zOut[iOff++] = '/';\n  }\n  if( (iOff+nPath+1)>nOut ){\n    /* SQLite assumes that xFullPathname() nul-terminates the output buffer\n    ** even if it returns an error.  */\n    zOut[iOff] = '\\0';\n    return SQLITE_CANTOPEN_BKPT;\n  }\n  sqlite3_snprintf(nOut-iOff, &zOut[iOff], \"%s\", zPath);\n  return SQLITE_OK;\n}\n\n/*\n** Turn a relative pathname into a full pathname. The relative path\n** is stored as a nul-terminated string in the buffer pointed to by\n** zPath. \n**\n** zOut points to a buffer of at least sqlite3_vfs.mxPathname bytes \n** (in this case, MAX_PATHNAME bytes). The full-path is written to\n** this buffer before returning.\n*/\nstatic int unixFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zPath,            /* Possibly relative input path */\n  int nOut,                     /* Size of output buffer in bytes */\n  char *zOut                    /* Output buffer */\n){\n#if !defined(HAVE_READLINK) || !defined(HAVE_LSTAT)\n  return mkFullPathname(zPath, zOut, nOut);\n#else\n  int rc = SQLITE_OK;\n  int nByte;\n  int nLink = 1;                /* Number of symbolic links followed so far */\n  const char *zIn = zPath;      /* Input path for each iteration of loop */\n  char *zDel = 0;\n\n  assert( pVfs->mxPathname==MAX_PATHNAME );\n  UNUSED_PARAMETER(pVfs);\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n\n  do {\n\n    /* Call stat() on path zIn. Set bLink to true if the path is a symbolic\n    ** link, or false otherwise.  */\n    int bLink = 0;\n    struct stat buf;\n    if( osLstat(zIn, &buf)!=0 ){\n      if( errno!=ENOENT ){\n        rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"lstat\", zIn);\n      }\n    }else{\n      bLink = S_ISLNK(buf.st_mode);\n    }\n\n    if( bLink ){\n      if( zDel==0 ){\n        zDel = sqlite3_malloc(nOut);\n        if( zDel==0 ) rc = SQLITE_NOMEM_BKPT;\n      }else if( ++nLink>SQLITE_MAX_SYMLINKS ){\n        rc = SQLITE_CANTOPEN_BKPT;\n      }\n\n      if( rc==SQLITE_OK ){\n        nByte = osReadlink(zIn, zDel, nOut-1);\n        if( nByte<0 ){\n          rc = unixLogError(SQLITE_CANTOPEN_BKPT, \"readlink\", zIn);\n        }else{\n          if( zDel[0]!='/' ){\n            int n;\n            for(n = sqlite3Strlen30(zIn); n>0 && zIn[n-1]!='/'; n--);\n            if( nByte+n+1>nOut ){\n              rc = SQLITE_CANTOPEN_BKPT;\n            }else{\n              memmove(&zDel[n], zDel, nByte+1);\n              memcpy(zDel, zIn, n);\n              nByte += n;\n            }\n          }\n          zDel[nByte] = '\\0';\n        }\n      }\n\n      zIn = zDel;\n    }\n\n    assert( rc!=SQLITE_OK || zIn!=zOut || zIn[0]=='/' );\n    if( rc==SQLITE_OK && zIn!=zOut ){\n      rc = mkFullPathname(zIn, zOut, nOut);\n    }\n    if( bLink==0 ) break;\n    zIn = zOut;\n  }while( rc==SQLITE_OK );\n\n  sqlite3_free(zDel);\n  return rc;\n#endif   /* HAVE_READLINK && HAVE_LSTAT */\n}\n\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\n#include <dlfcn.h>\nstatic void *unixDlOpen(sqlite3_vfs *NotUsed, const char *zFilename){\n  UNUSED_PARAMETER(NotUsed);\n  return dlopen(zFilename, RTLD_NOW | RTLD_GLOBAL);\n}\n\n/*\n** SQLite calls this function immediately after a call to unixDlSym() or\n** unixDlOpen() fails (returns a null pointer). If a more detailed error\n** message is available, it is written to zBufOut. If no error message\n** is available, zBufOut is left unmodified and SQLite uses a default\n** error message.\n*/\nstatic void unixDlError(sqlite3_vfs *NotUsed, int nBuf, char *zBufOut){\n  const char *zErr;\n  UNUSED_PARAMETER(NotUsed);\n  unixEnterMutex();\n  zErr = dlerror();\n  if( zErr ){\n    sqlite3_snprintf(nBuf, zBufOut, \"%s\", zErr);\n  }\n  unixLeaveMutex();\n}\nstatic void (*unixDlSym(sqlite3_vfs *NotUsed, void *p, const char*zSym))(void){\n  /* \n  ** GCC with -pedantic-errors says that C90 does not allow a void* to be\n  ** cast into a pointer to a function.  And yet the library dlsym() routine\n  ** returns a void* which is really a pointer to a function.  So how do we\n  ** use dlsym() with -pedantic-errors?\n  **\n  ** Variable x below is defined to be a pointer to a function taking\n  ** parameters void* and const char* and returning a pointer to a function.\n  ** We initialize x by assigning it a pointer to the dlsym() function.\n  ** (That assignment requires a cast.)  Then we call the function that\n  ** x points to.  \n  **\n  ** This work-around is unlikely to work correctly on any system where\n  ** you really cannot cast a function pointer into void*.  But then, on the\n  ** other hand, dlsym() will not work on such a system either, so we have\n  ** not really lost anything.\n  */\n  void (*(*x)(void*,const char*))(void);\n  UNUSED_PARAMETER(NotUsed);\n  x = (void(*(*)(void*,const char*))(void))dlsym;\n  return (*x)(p, zSym);\n}\nstatic void unixDlClose(sqlite3_vfs *NotUsed, void *pHandle){\n  UNUSED_PARAMETER(NotUsed);\n  dlclose(pHandle);\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define unixDlOpen  0\n  #define unixDlError 0\n  #define unixDlSym   0\n  #define unixDlClose 0\n#endif\n\n/*\n** Write nBuf bytes of random data to the supplied buffer zBuf.\n*/\nstatic int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){\n  UNUSED_PARAMETER(NotUsed);\n  assert((size_t)nBuf>=(sizeof(time_t)+sizeof(int)));\n\n  /* We have to initialize zBuf to prevent valgrind from reporting\n  ** errors.  The reports issued by valgrind are incorrect - we would\n  ** prefer that the randomness be increased by making use of the\n  ** uninitialized space in zBuf - but valgrind errors tend to worry\n  ** some users.  Rather than argue, it seems easier just to initialize\n  ** the whole array and silence valgrind, even if that means less randomness\n  ** in the random seed.\n  **\n  ** When testing, initializing zBuf[] to zero is all we do.  That means\n  ** that we always use the same random number sequence.  This makes the\n  ** tests repeatable.\n  */\n  memset(zBuf, 0, nBuf);\n  randomnessPid = osGetpid(0);  \n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n  {\n    int fd, got;\n    fd = robust_open(\"/dev/urandom\", O_RDONLY, 0);\n    if( fd<0 ){\n      time_t t;\n      time(&t);\n      memcpy(zBuf, &t, sizeof(t));\n      memcpy(&zBuf[sizeof(t)], &randomnessPid, sizeof(randomnessPid));\n      assert( sizeof(t)+sizeof(randomnessPid)<=(size_t)nBuf );\n      nBuf = sizeof(t) + sizeof(randomnessPid);\n    }else{\n      do{ got = osRead(fd, zBuf, nBuf); }while( got<0 && errno==EINTR );\n      robust_close(0, fd, __LINE__);\n    }\n  }\n#endif\n  return nBuf;\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n** The argument is the number of microseconds we want to sleep.\n** The return value is the number of microseconds of sleep actually\n** requested from the underlying operating system, a number which\n** might be greater than or equal to the argument, but not less\n** than the argument.\n*/\nstatic int unixSleep(sqlite3_vfs *NotUsed, int microseconds){\n#if OS_VXWORKS\n  struct timespec sp;\n\n  sp.tv_sec = microseconds / 1000000;\n  sp.tv_nsec = (microseconds % 1000000) * 1000;\n  nanosleep(&sp, NULL);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#elif defined(HAVE_USLEEP) && HAVE_USLEEP\n  usleep(microseconds);\n  UNUSED_PARAMETER(NotUsed);\n  return microseconds;\n#else\n  int seconds = (microseconds+999999)/1000000;\n  sleep(seconds);\n  UNUSED_PARAMETER(NotUsed);\n  return seconds*1000000;\n#endif\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date \n** cannot be found.\n*/\nstatic int unixCurrentTimeInt64(sqlite3_vfs *NotUsed, sqlite3_int64 *piNow){\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n  int rc = SQLITE_OK;\n#if defined(NO_GETTOD)\n  time_t t;\n  time(&t);\n  *piNow = ((sqlite3_int64)t)*1000 + unixEpoch;\n#elif OS_VXWORKS\n  struct timespec sNow;\n  clock_gettime(CLOCK_REALTIME, &sNow);\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_nsec/1000000;\n#else\n  struct timeval sNow;\n  (void)gettimeofday(&sNow, 0);  /* Cannot fail given valid arguments */\n  *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;\n#endif\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(NotUsed);\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int unixCurrentTime(sqlite3_vfs *NotUsed, double *prNow){\n  sqlite3_int64 i = 0;\n  int rc;\n  UNUSED_PARAMETER(NotUsed);\n  rc = unixCurrentTimeInt64(0, &i);\n  *prNow = i/86400000.0;\n  return rc;\n}\n#else\n# define unixCurrentTime 0\n#endif\n\n/*\n** The xGetLastError() method is designed to return a better\n** low-level error message when operating-system problems come up\n** during SQLite operation.  Only the integer return code is currently\n** used.\n*/\nstatic int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){\n  UNUSED_PARAMETER(NotUsed);\n  UNUSED_PARAMETER(NotUsed2);\n  UNUSED_PARAMETER(NotUsed3);\n  return errno;\n}\n\n\n/*\n************************ End of sqlite3_vfs methods ***************************\n******************************************************************************/\n\n/******************************************************************************\n************************** Begin Proxy Locking ********************************\n**\n** Proxy locking is a \"uber-locking-method\" in this sense:  It uses the\n** other locking methods on secondary lock files.  Proxy locking is a\n** meta-layer over top of the primitive locking implemented above.  For\n** this reason, the division that implements of proxy locking is deferred\n** until late in the file (here) after all of the other I/O methods have\n** been defined - so that the primitive locking methods are available\n** as services to help with the implementation of proxy locking.\n**\n****\n**\n** The default locking schemes in SQLite use byte-range locks on the\n** database file to coordinate safe, concurrent access by multiple readers\n** and writers [http://sqlite.org/lockingv3.html].  The five file locking\n** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented\n** as POSIX read & write locks over fixed set of locations (via fsctl),\n** on AFP and SMB only exclusive byte-range locks are available via fsctl\n** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states.\n** To simulate a F_RDLCK on the shared range, on AFP a randomly selected\n** address in the shared range is taken for a SHARED lock, the entire\n** shared range is taken for an EXCLUSIVE lock):\n**\n**      PENDING_BYTE        0x40000000\n**      RESERVED_BYTE       0x40000001\n**      SHARED_RANGE        0x40000002 -> 0x40000200\n**\n** This works well on the local file system, but shows a nearly 100x\n** slowdown in read performance on AFP because the AFP client disables\n** the read cache when byte-range locks are present.  Enabling the read\n** cache exposes a cache coherency problem that is present on all OS X\n** supported network file systems.  NFS and AFP both observe the\n** close-to-open semantics for ensuring cache coherency\n** [http://nfs.sourceforge.net/#faq_a8], which does not effectively\n** address the requirements for concurrent database access by multiple\n** readers and writers\n** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html].\n**\n** To address the performance and cache coherency issues, proxy file locking\n** changes the way database access is controlled by limiting access to a\n** single host at a time and moving file locks off of the database file\n** and onto a proxy file on the local file system.  \n**\n**\n** Using proxy locks\n** -----------------\n**\n** C APIs\n**\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,\n**                       <proxy_path> | \":auto:\");\n**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,\n**                       &<proxy_path>);\n**\n**\n** SQL pragmas\n**\n**  PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:\n**  PRAGMA [database.]lock_proxy_file\n**\n** Specifying \":auto:\" means that if there is a conch file with a matching\n** host ID in it, the proxy path in the conch file will be used, otherwise\n** a proxy path based on the user's temp dir\n** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the\n** actual proxy file name is generated from the name and path of the\n** database file.  For example:\n**\n**       For database path \"/Users/me/foo.db\" \n**       The lock path will be \"<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:\")\n**\n** Once a lock proxy is configured for a database connection, it can not\n** be removed, however it may be switched to a different proxy path via\n** the above APIs (assuming the conch file is not being held by another\n** connection or process). \n**\n**\n** How proxy locking works\n** -----------------------\n**\n** Proxy file locking relies primarily on two new supporting files: \n**\n**   *  conch file to limit access to the database file to a single host\n**      at a time\n**\n**   *  proxy file to act as a proxy for the advisory locks normally\n**      taken on the database\n**\n** The conch file - to use a proxy file, sqlite must first \"hold the conch\"\n** by taking an sqlite-style shared lock on the conch file, reading the\n** contents and comparing the host's unique host ID (see below) and lock\n** proxy path against the values stored in the conch.  The conch file is\n** stored in the same directory as the database file and the file name\n** is patterned after the database file name as \".<databasename>-conch\".\n** If the conch file does not exist, or its contents do not match the\n** host ID and/or proxy path, then the lock is escalated to an exclusive\n** lock and the conch file contents is updated with the host ID and proxy\n** path and the lock is downgraded to a shared lock again.  If the conch\n** is held by another process (with a shared lock), the exclusive lock\n** will fail and SQLITE_BUSY is returned.\n**\n** The proxy file - a single-byte file used for all advisory file locks\n** normally taken on the database file.   This allows for safe sharing\n** of the database file for multiple readers and writers on the same\n** host (the conch ensures that they all use the same local lock file).\n**\n** Requesting the lock proxy does not immediately take the conch, it is\n** only taken when the first request to lock database file is made.  \n** This matches the semantics of the traditional locking behavior, where\n** opening a connection to a database file does not take a lock on it.\n** The shared lock and an open file descriptor are maintained until \n** the connection to the database is closed. \n**\n** The proxy file and the lock file are never deleted so they only need\n** to be created the first time they are used.\n**\n** Configuration options\n** ---------------------\n**\n**  SQLITE_PREFER_PROXY_LOCKING\n**\n**       Database files accessed on non-local file systems are\n**       automatically configured for proxy locking, lock files are\n**       named automatically using the same logic as\n**       PRAGMA lock_proxy_file=\":auto:\"\n**    \n**  SQLITE_PROXY_DEBUG\n**\n**       Enables the logging of error messages during host id file\n**       retrieval and creation\n**\n**  LOCKPROXYDIR\n**\n**       Overrides the default directory used for lock proxy files that\n**       are named automatically via the \":auto:\" setting\n**\n**  SQLITE_DEFAULT_PROXYDIR_PERMISSIONS\n**\n**       Permissions to use when creating a directory for storing the\n**       lock proxy files, only used when LOCKPROXYDIR is not set.\n**    \n**    \n** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,\n** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will\n** force proxy locking to be used for every database file opened, and 0\n** will force automatic proxy locking to be disabled for all database\n** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or\n** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).\n*/\n\n/*\n** Proxy locking is only available on MacOSX \n*/\n#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n\n/*\n** The proxyLockingContext has the path and file structures for the remote \n** and local proxy files in it\n*/\ntypedef struct proxyLockingContext proxyLockingContext;\nstruct proxyLockingContext {\n  unixFile *conchFile;         /* Open conch file */\n  char *conchFilePath;         /* Name of the conch file */\n  unixFile *lockProxy;         /* Open proxy lock file */\n  char *lockProxyPath;         /* Name of the proxy lock file */\n  char *dbPath;                /* Name of the open file */\n  int conchHeld;               /* 1 if the conch is held, -1 if lockless */\n  int nFails;                  /* Number of conch taking failures */\n  void *oldLockingContext;     /* Original lockingcontext to restore on close */\n  sqlite3_io_methods const *pOldMethod;     /* Original I/O methods for close */\n};\n\n/* \n** The proxy lock file path for the database at dbPath is written into lPath, \n** which must point to valid, writable memory large enough for a maxLen length\n** file path. \n*/\nstatic int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){\n  int len;\n  int dbLen;\n  int i;\n\n#ifdef LOCKPROXYDIR\n  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);\n#else\n# ifdef _CS_DARWIN_USER_TEMP_DIR\n  {\n    if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){\n      OSTRACE((\"GETLOCKPATH  failed %s errno=%d pid=%d\\n\",\n               lPath, errno, osGetpid(0)));\n      return SQLITE_IOERR_LOCK;\n    }\n    len = strlcat(lPath, \"sqliteplocks\", maxLen);    \n  }\n# else\n  len = strlcpy(lPath, \"/tmp/\", maxLen);\n# endif\n#endif\n\n  if( lPath[len-1]!='/' ){\n    len = strlcat(lPath, \"/\", maxLen);\n  }\n  \n  /* transform the db path to a unique cache name */\n  dbLen = (int)strlen(dbPath);\n  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){\n    char c = dbPath[i];\n    lPath[i+len] = (c=='/')?'_':c;\n  }\n  lPath[i+len]='\\0';\n  strlcat(lPath, \":auto:\", maxLen);\n  OSTRACE((\"GETLOCKPATH  proxy lock path=%s pid=%d\\n\", lPath, osGetpid(0)));\n  return SQLITE_OK;\n}\n\n/* \n ** Creates the lock file and any missing directories in lockPath\n */\nstatic int proxyCreateLockPath(const char *lockPath){\n  int i, len;\n  char buf[MAXPATHLEN];\n  int start = 0;\n  \n  assert(lockPath!=NULL);\n  /* try to create all the intermediate directories */\n  len = (int)strlen(lockPath);\n  buf[0] = lockPath[0];\n  for( i=1; i<len; i++ ){\n    if( lockPath[i] == '/' && (i - start > 0) ){\n      /* only mkdir if leaf dir != \".\" or \"/\" or \"..\" */\n      if( i-start>2 || (i-start==1 && buf[start] != '.' && buf[start] != '/') \n         || (i-start==2 && buf[start] != '.' && buf[start+1] != '.') ){\n        buf[i]='\\0';\n        if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){\n          int err=errno;\n          if( err!=EEXIST ) {\n            OSTRACE((\"CREATELOCKPATH  FAILED creating %s, \"\n                     \"'%s' proxy lock path=%s pid=%d\\n\",\n                     buf, strerror(err), lockPath, osGetpid(0)));\n            return err;\n          }\n        }\n      }\n      start=i+1;\n    }\n    buf[i] = lockPath[i];\n  }\n  OSTRACE((\"CREATELOCKPATH  proxy lock path=%s pid=%d\\n\",lockPath,osGetpid(0)));\n  return 0;\n}\n\n/*\n** Create a new VFS file descriptor (stored in memory obtained from\n** sqlite3_malloc) and open the file named \"path\" in the file descriptor.\n**\n** The caller is responsible not only for closing the file descriptor\n** but also for freeing the memory associated with the file descriptor.\n*/\nstatic int proxyCreateUnixFile(\n    const char *path,        /* path for the new unixFile */\n    unixFile **ppFile,       /* unixFile created and returned by ref */\n    int islockfile           /* if non zero missing dirs will be created */\n) {\n  int fd = -1;\n  unixFile *pNew;\n  int rc = SQLITE_OK;\n  int openFlags = O_RDWR | O_CREAT;\n  sqlite3_vfs dummyVfs;\n  int terrno = 0;\n  UnixUnusedFd *pUnused = NULL;\n\n  /* 1. first try to open/create the file\n  ** 2. if that fails, and this is a lock file (not-conch), try creating\n  ** the parent directories and then try again.\n  ** 3. if that fails, try to open the file read-only\n  ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file\n  */\n  pUnused = findReusableFd(path, openFlags);\n  if( pUnused ){\n    fd = pUnused->fd;\n  }else{\n    pUnused = sqlite3_malloc64(sizeof(*pUnused));\n    if( !pUnused ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( fd<0 ){\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n    if( fd<0 && errno==ENOENT && islockfile ){\n      if( proxyCreateLockPath(path) == SQLITE_OK ){\n        fd = robust_open(path, openFlags, 0);\n      }\n    }\n  }\n  if( fd<0 ){\n    openFlags = O_RDONLY;\n    fd = robust_open(path, openFlags, 0);\n    terrno = errno;\n  }\n  if( fd<0 ){\n    if( islockfile ){\n      return SQLITE_BUSY;\n    }\n    switch (terrno) {\n      case EACCES:\n        return SQLITE_PERM;\n      case EIO: \n        return SQLITE_IOERR_LOCK; /* even though it is the conch */\n      default:\n        return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n  \n  pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew));\n  if( pNew==NULL ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_create_proxy;\n  }\n  memset(pNew, 0, sizeof(unixFile));\n  pNew->openFlags = openFlags;\n  memset(&dummyVfs, 0, sizeof(dummyVfs));\n  dummyVfs.pAppData = (void*)&autolockIoFinder;\n  dummyVfs.zName = \"dummy\";\n  pUnused->fd = fd;\n  pUnused->flags = openFlags;\n  pNew->pPreallocatedUnused = pUnused;\n  \n  rc = fillInUnixFile(&dummyVfs, fd, (sqlite3_file*)pNew, path, 0);\n  if( rc==SQLITE_OK ){\n    *ppFile = pNew;\n    return SQLITE_OK;\n  }\nend_create_proxy:    \n  robust_close(pNew, fd, __LINE__);\n  sqlite3_free(pNew);\n  sqlite3_free(pUnused);\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/* simulate multiple hosts by creating unique hostid file paths */\nint sqlite3_hostid_num = 0;\n#endif\n\n#define PROXY_HOSTIDLEN    16  /* conch file host id length */\n\n#ifdef HAVE_GETHOSTUUID\n/* Not always defined in the headers as it ought to be */\nextern int gethostuuid(uuid_t id, const struct timespec *wait);\n#endif\n\n/* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN \n** bytes of writable memory.\n*/\nstatic int proxyGetHostID(unsigned char *pHostID, int *pError){\n  assert(PROXY_HOSTIDLEN == sizeof(uuid_t));\n  memset(pHostID, 0, PROXY_HOSTIDLEN);\n#ifdef HAVE_GETHOSTUUID\n  {\n    struct timespec timeout = {1, 0}; /* 1 sec timeout */\n    if( gethostuuid(pHostID, &timeout) ){\n      int err = errno;\n      if( pError ){\n        *pError = err;\n      }\n      return SQLITE_IOERR;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pError);\n#endif\n#ifdef SQLITE_TEST\n  /* simulate multiple hosts by creating unique hostid file paths */\n  if( sqlite3_hostid_num != 0){\n    pHostID[0] = (char)(pHostID[0] + (char)(sqlite3_hostid_num & 0xFF));\n  }\n#endif\n  \n  return SQLITE_OK;\n}\n\n/* The conch file contains the header, host id and lock file path\n */\n#define PROXY_CONCHVERSION 2   /* 1-byte header, 16-byte host id, path */\n#define PROXY_HEADERLEN    1   /* conch file header length */\n#define PROXY_PATHINDEX    (PROXY_HEADERLEN+PROXY_HOSTIDLEN)\n#define PROXY_MAXCONCHLEN  (PROXY_HEADERLEN+PROXY_HOSTIDLEN+MAXPATHLEN)\n\n/* \n** Takes an open conch file, copies the contents to a new path and then moves \n** it back.  The newly created file's file descriptor is assigned to the\n** conch file structure and finally the original conch file descriptor is \n** closed.  Returns zero if successful.\n*/\nstatic int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  char tPath[MAXPATHLEN];\n  char buf[PROXY_MAXCONCHLEN];\n  char *cPath = pCtx->conchFilePath;\n  size_t readLen = 0;\n  size_t pathLen = 0;\n  char errmsg[64] = \"\";\n  int fd = -1;\n  int rc = -1;\n  UNUSED_PARAMETER(myHostID);\n\n  /* create a new path by replace the trailing '-conch' with '-break' */\n  pathLen = strlcpy(tPath, cPath, MAXPATHLEN);\n  if( pathLen>MAXPATHLEN || pathLen<6 || \n     (strlcpy(&tPath[pathLen-5], \"break\", 6) != 5) ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"path error (len %d)\",(int)pathLen);\n    goto end_breaklock;\n  }\n  /* read the conch content */\n  readLen = osPread(conchFile->h, buf, PROXY_MAXCONCHLEN, 0);\n  if( readLen<PROXY_PATHINDEX ){\n    sqlite3_snprintf(sizeof(errmsg),errmsg,\"read error (len %d)\",(int)readLen);\n    goto end_breaklock;\n  }\n  /* write it out to the temporary break file */\n  fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0);\n  if( fd<0 ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"create failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"write failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  if( rename(tPath, cPath) ){\n    sqlite3_snprintf(sizeof(errmsg), errmsg, \"rename failed (%d)\", errno);\n    goto end_breaklock;\n  }\n  rc = 0;\n  fprintf(stderr, \"broke stale lock on %s\\n\", cPath);\n  robust_close(pFile, conchFile->h, __LINE__);\n  conchFile->h = fd;\n  conchFile->openFlags = O_RDWR | O_CREAT;\n\nend_breaklock:\n  if( rc ){\n    if( fd>=0 ){\n      osUnlink(tPath);\n      robust_close(pFile, fd, __LINE__);\n    }\n    fprintf(stderr, \"failed to break stale lock on %s, %s\\n\", cPath, errmsg);\n  }\n  return rc;\n}\n\n/* Take the requested lock on the conch file and break a stale lock if the \n** host id matches.\n*/\nstatic int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  unixFile *conchFile = pCtx->conchFile;\n  int rc = SQLITE_OK;\n  int nTries = 0;\n  struct timespec conchModTime;\n  \n  memset(&conchModTime, 0, sizeof(conchModTime));\n  do {\n    rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n    nTries ++;\n    if( rc==SQLITE_BUSY ){\n      /* If the lock failed (busy):\n       * 1st try: get the mod time of the conch, wait 0.5s and try again. \n       * 2nd try: fail if the mod time changed or host id is different, wait \n       *           10 sec and try again\n       * 3rd try: break the lock unless the mod time has changed.\n       */\n      struct stat buf;\n      if( osFstat(conchFile->h, &buf) ){\n        storeLastErrno(pFile, errno);\n        return SQLITE_IOERR_LOCK;\n      }\n      \n      if( nTries==1 ){\n        conchModTime = buf.st_mtimespec;\n        usleep(500000); /* wait 0.5 sec and try the lock again*/\n        continue;  \n      }\n\n      assert( nTries>1 );\n      if( conchModTime.tv_sec != buf.st_mtimespec.tv_sec || \n         conchModTime.tv_nsec != buf.st_mtimespec.tv_nsec ){\n        return SQLITE_BUSY;\n      }\n      \n      if( nTries==2 ){  \n        char tBuf[PROXY_MAXCONCHLEN];\n        int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);\n        if( len<0 ){\n          storeLastErrno(pFile, errno);\n          return SQLITE_IOERR_LOCK;\n        }\n        if( len>PROXY_PATHINDEX && tBuf[0]==(char)PROXY_CONCHVERSION){\n          /* don't break the lock if the host id doesn't match */\n          if( 0!=memcmp(&tBuf[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN) ){\n            return SQLITE_BUSY;\n          }\n        }else{\n          /* don't break the lock on short read or a version mismatch */\n          return SQLITE_BUSY;\n        }\n        usleep(10000000); /* wait 10 sec and try the lock again */\n        continue; \n      }\n      \n      assert( nTries==3 );\n      if( 0==proxyBreakConchLock(pFile, myHostID) ){\n        rc = SQLITE_OK;\n        if( lockType==EXCLUSIVE_LOCK ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);\n        }\n        if( !rc ){\n          rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);\n        }\n      }\n    }\n  } while( rc==SQLITE_BUSY && nTries<3 );\n  \n  return rc;\n}\n\n/* Takes the conch by taking a shared lock and read the contents conch, if \n** lockPath is non-NULL, the host ID and lock file path must match.  A NULL \n** lockPath means that the lockPath in the conch file will be used if the \n** host IDs match, or a new lock path will be generated automatically \n** and written to the conch file.\n*/\nstatic int proxyTakeConch(unixFile *pFile){\n  proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext; \n  \n  if( pCtx->conchHeld!=0 ){\n    return SQLITE_OK;\n  }else{\n    unixFile *conchFile = pCtx->conchFile;\n    uuid_t myHostID;\n    int pError = 0;\n    char readBuf[PROXY_MAXCONCHLEN];\n    char lockPath[MAXPATHLEN];\n    char *tempLockPath = NULL;\n    int rc = SQLITE_OK;\n    int createConch = 0;\n    int hostIdMatch = 0;\n    int readLen = 0;\n    int tryOldLockPath = 0;\n    int forceNewLockPath = 0;\n    \n    OSTRACE((\"TAKECONCH  %d for %s pid=%d\\n\", conchFile->h,\n             (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"),\n             osGetpid(0)));\n\n    rc = proxyGetHostID(myHostID, &pError);\n    if( (rc&0xff)==SQLITE_IOERR ){\n      storeLastErrno(pFile, pError);\n      goto end_takeconch;\n    }\n    rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      goto end_takeconch;\n    }\n    /* read the existing conch file */\n    readLen = seekAndRead((unixFile*)conchFile, 0, readBuf, PROXY_MAXCONCHLEN);\n    if( readLen<0 ){\n      /* I/O error: lastErrno set by seekAndRead */\n      storeLastErrno(pFile, conchFile->lastErrno);\n      rc = SQLITE_IOERR_READ;\n      goto end_takeconch;\n    }else if( readLen<=(PROXY_HEADERLEN+PROXY_HOSTIDLEN) || \n             readBuf[0]!=(char)PROXY_CONCHVERSION ){\n      /* a short read or version format mismatch means we need to create a new \n      ** conch file. \n      */\n      createConch = 1;\n    }\n    /* if the host id matches and the lock path already exists in the conch\n    ** we'll try to use the path there, if we can't open that path, we'll \n    ** retry with a new auto-generated path \n    */\n    do { /* in case we need to try again for an :auto: named lock file */\n\n      if( !createConch && !forceNewLockPath ){\n        hostIdMatch = !memcmp(&readBuf[PROXY_HEADERLEN], myHostID, \n                                  PROXY_HOSTIDLEN);\n        /* if the conch has data compare the contents */\n        if( !pCtx->lockProxyPath ){\n          /* for auto-named local lock file, just check the host ID and we'll\n           ** use the local lock file path that's already in there\n           */\n          if( hostIdMatch ){\n            size_t pathLen = (readLen - PROXY_PATHINDEX);\n            \n            if( pathLen>=MAXPATHLEN ){\n              pathLen=MAXPATHLEN-1;\n            }\n            memcpy(lockPath, &readBuf[PROXY_PATHINDEX], pathLen);\n            lockPath[pathLen] = 0;\n            tempLockPath = lockPath;\n            tryOldLockPath = 1;\n            /* create a copy of the lock path if the conch is taken */\n            goto end_takeconch;\n          }\n        }else if( hostIdMatch\n               && !strncmp(pCtx->lockProxyPath, &readBuf[PROXY_PATHINDEX],\n                           readLen-PROXY_PATHINDEX)\n        ){\n          /* conch host and lock path match */\n          goto end_takeconch; \n        }\n      }\n      \n      /* if the conch isn't writable and doesn't match, we can't take it */\n      if( (conchFile->openFlags&O_RDWR) == 0 ){\n        rc = SQLITE_BUSY;\n        goto end_takeconch;\n      }\n      \n      /* either the conch didn't match or we need to create a new one */\n      if( !pCtx->lockProxyPath ){\n        proxyGetLockPath(pCtx->dbPath, lockPath, MAXPATHLEN);\n        tempLockPath = lockPath;\n        /* create a copy of the lock path _only_ if the conch is taken */\n      }\n      \n      /* update conch with host and path (this will fail if other process\n      ** has a shared lock already), if the host id matches, use the big\n      ** stick.\n      */\n      futimes(conchFile->h, NULL);\n      if( hostIdMatch && !createConch ){\n        if( conchFile->pInode && conchFile->pInode->nShared>1 ){\n          /* We are trying for an exclusive lock but another thread in this\n           ** same process is still holding a shared lock. */\n          rc = SQLITE_BUSY;\n        } else {          \n          rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n        }\n      }else{\n        rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);\n      }\n      if( rc==SQLITE_OK ){\n        char writeBuffer[PROXY_MAXCONCHLEN];\n        int writeSize = 0;\n        \n        writeBuffer[0] = (char)PROXY_CONCHVERSION;\n        memcpy(&writeBuffer[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN);\n        if( pCtx->lockProxyPath!=NULL ){\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath,\n                  MAXPATHLEN);\n        }else{\n          strlcpy(&writeBuffer[PROXY_PATHINDEX], tempLockPath, MAXPATHLEN);\n        }\n        writeSize = PROXY_PATHINDEX + strlen(&writeBuffer[PROXY_PATHINDEX]);\n        robust_ftruncate(conchFile->h, writeSize);\n        rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0);\n        full_fsync(conchFile->h,0,0);\n        /* If we created a new conch file (not just updated the contents of a \n         ** valid conch file), try to match the permissions of the database \n         */\n        if( rc==SQLITE_OK && createConch ){\n          struct stat buf;\n          int err = osFstat(pFile->h, &buf);\n          if( err==0 ){\n            mode_t cmode = buf.st_mode&(S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP |\n                                        S_IROTH|S_IWOTH);\n            /* try to match the database file R/W permissions, ignore failure */\n#ifndef SQLITE_PROXY_DEBUG\n            osFchmod(conchFile->h, cmode);\n#else\n            do{\n              rc = osFchmod(conchFile->h, cmode);\n            }while( rc==(-1) && errno==EINTR );\n            if( rc!=0 ){\n              int code = errno;\n              fprintf(stderr, \"fchmod %o FAILED with %d %s\\n\",\n                      cmode, code, strerror(code));\n            } else {\n              fprintf(stderr, \"fchmod %o SUCCEDED\\n\",cmode);\n            }\n          }else{\n            int code = errno;\n            fprintf(stderr, \"STAT FAILED[%d] with %d %s\\n\", \n                    err, code, strerror(code));\n#endif\n          }\n        }\n      }\n      conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, SHARED_LOCK);\n      \n    end_takeconch:\n      OSTRACE((\"TRANSPROXY: CLOSE  %d\\n\", pFile->h));\n      if( rc==SQLITE_OK && pFile->openFlags ){\n        int fd;\n        if( pFile->h>=0 ){\n          robust_close(pFile, pFile->h, __LINE__);\n        }\n        pFile->h = -1;\n        fd = robust_open(pCtx->dbPath, pFile->openFlags, 0);\n        OSTRACE((\"TRANSPROXY: OPEN  %d\\n\", fd));\n        if( fd>=0 ){\n          pFile->h = fd;\n        }else{\n          rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called\n           during locking */\n        }\n      }\n      if( rc==SQLITE_OK && !pCtx->lockProxy ){\n        char *path = tempLockPath ? tempLockPath : pCtx->lockProxyPath;\n        rc = proxyCreateUnixFile(path, &pCtx->lockProxy, 1);\n        if( rc!=SQLITE_OK && rc!=SQLITE_NOMEM && tryOldLockPath ){\n          /* we couldn't create the proxy lock file with the old lock file path\n           ** so try again via auto-naming \n           */\n          forceNewLockPath = 1;\n          tryOldLockPath = 0;\n          continue; /* go back to the do {} while start point, try again */\n        }\n      }\n      if( rc==SQLITE_OK ){\n        /* Need to make a copy of path if we extracted the value\n         ** from the conch file or the path was allocated on the stack\n         */\n        if( tempLockPath ){\n          pCtx->lockProxyPath = sqlite3DbStrDup(0, tempLockPath);\n          if( !pCtx->lockProxyPath ){\n            rc = SQLITE_NOMEM_BKPT;\n          }\n        }\n      }\n      if( rc==SQLITE_OK ){\n        pCtx->conchHeld = 1;\n        \n        if( pCtx->lockProxy->pMethod == &afpIoMethods ){\n          afpLockingContext *afpCtx;\n          afpCtx = (afpLockingContext *)pCtx->lockProxy->lockingContext;\n          afpCtx->dbPath = pCtx->lockProxyPath;\n        }\n      } else {\n        conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n      }\n      OSTRACE((\"TAKECONCH  %d %s\\n\", conchFile->h,\n               rc==SQLITE_OK?\"ok\":\"failed\"));\n      return rc;\n    } while (1); /* in case we need to retry the :auto: lock file - \n                 ** we should never get here except via the 'continue' call. */\n  }\n}\n\n/*\n** If pFile holds a lock on a conch file, then release that lock.\n*/\nstatic int proxyReleaseConch(unixFile *pFile){\n  int rc = SQLITE_OK;         /* Subroutine return code */\n  proxyLockingContext *pCtx;  /* The locking context for the proxy lock */\n  unixFile *conchFile;        /* Name of the conch file */\n\n  pCtx = (proxyLockingContext *)pFile->lockingContext;\n  conchFile = pCtx->conchFile;\n  OSTRACE((\"RELEASECONCH  %d for %s pid=%d\\n\", conchFile->h,\n           (pCtx->lockProxyPath ? pCtx->lockProxyPath : \":auto:\"), \n           osGetpid(0)));\n  if( pCtx->conchHeld>0 ){\n    rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);\n  }\n  pCtx->conchHeld = 0;\n  OSTRACE((\"RELEASECONCH  %d %s\\n\", conchFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n/*\n** Given the name of a database file, compute the name of its conch file.\n** Store the conch filename in memory obtained from sqlite3_malloc64().\n** Make *pConchPath point to the new name.  Return SQLITE_OK on success\n** or SQLITE_NOMEM if unable to obtain memory.\n**\n** The caller is responsible for ensuring that the allocated memory\n** space is eventually freed.\n**\n** *pConchPath is set to NULL if a memory allocation error occurs.\n*/\nstatic int proxyCreateConchPathname(char *dbPath, char **pConchPath){\n  int i;                        /* Loop counter */\n  int len = (int)strlen(dbPath); /* Length of database filename - dbPath */\n  char *conchPath;              /* buffer in which to construct conch name */\n\n  /* Allocate space for the conch filename and initialize the name to\n  ** the name of the original database file. */  \n  *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8);\n  if( conchPath==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(conchPath, dbPath, len+1);\n  \n  /* now insert a \".\" before the last / character */\n  for( i=(len-1); i>=0; i-- ){\n    if( conchPath[i]=='/' ){\n      i++;\n      break;\n    }\n  }\n  conchPath[i]='.';\n  while ( i<len ){\n    conchPath[i+1]=dbPath[i];\n    i++;\n  }\n\n  /* append the \"-conch\" suffix to the file */\n  memcpy(&conchPath[i+1], \"-conch\", 7);\n  assert( (int)strlen(conchPath) == len+7 );\n\n  return SQLITE_OK;\n}\n\n\n/* Takes a fully configured proxy locking-style unix file and switches\n** the local lock file path \n*/\nstatic int switchLockProxyPath(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n  char *oldPath = pCtx->lockProxyPath;\n  int rc = SQLITE_OK;\n\n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }  \n\n  /* nothing to do if the path is NULL, :auto: or matches the existing path */\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ||\n    (oldPath && !strncmp(oldPath, path, MAXPATHLEN)) ){\n    return SQLITE_OK;\n  }else{\n    unixFile *lockProxy = pCtx->lockProxy;\n    pCtx->lockProxy=NULL;\n    pCtx->conchHeld = 0;\n    if( lockProxy!=NULL ){\n      rc=lockProxy->pMethod->xClose((sqlite3_file *)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n    }\n    sqlite3_free(oldPath);\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, path);\n  }\n  \n  return rc;\n}\n\n/*\n** pFile is a file that has been opened by a prior xOpen call.  dbPath\n** is a string buffer at least MAXPATHLEN+1 characters in size.\n**\n** This routine find the filename associated with pFile and writes it\n** int dbPath.\n*/\nstatic int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){\n#if defined(__APPLE__)\n  if( pFile->pMethod == &afpIoMethods ){\n    /* afp style keeps a reference to the db path in the filePath field \n    ** of the struct */\n    assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath,\n            MAXPATHLEN);\n  } else\n#endif\n  if( pFile->pMethod == &dotlockIoMethods ){\n    /* dot lock style uses the locking context to store the dot lock\n    ** file path */\n    int len = strlen((char *)pFile->lockingContext) - strlen(DOTLOCK_SUFFIX);\n    memcpy(dbPath, (char *)pFile->lockingContext, len + 1);\n  }else{\n    /* all other styles use the locking context to store the db file path */\n    assert( strlen((char*)pFile->lockingContext)<=MAXPATHLEN );\n    strlcpy(dbPath, (char *)pFile->lockingContext, MAXPATHLEN);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Takes an already filled in unix file and alters it so all file locking \n** will be performed on the local proxy lock file.  The following fields\n** are preserved in the locking context so that they can be restored and \n** the unix structure properly cleaned up at close time:\n**  ->lockingContext\n**  ->pMethod\n*/\nstatic int proxyTransformUnixFile(unixFile *pFile, const char *path) {\n  proxyLockingContext *pCtx;\n  char dbPath[MAXPATHLEN+1];       /* Name of the database file */\n  char *lockPath=NULL;\n  int rc = SQLITE_OK;\n  \n  if( pFile->eFileLock!=NO_LOCK ){\n    return SQLITE_BUSY;\n  }\n  proxyGetDbPathForUnixFile(pFile, dbPath);\n  if( !path || path[0]=='\\0' || !strcmp(path, \":auto:\") ){\n    lockPath=NULL;\n  }else{\n    lockPath=(char *)path;\n  }\n  \n  OSTRACE((\"TRANSPROXY  %d for %s pid=%d\\n\", pFile->h,\n           (lockPath ? lockPath : \":auto:\"), osGetpid(0)));\n\n  pCtx = sqlite3_malloc64( sizeof(*pCtx) );\n  if( pCtx==0 ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(pCtx, 0, sizeof(*pCtx));\n\n  rc = proxyCreateConchPathname(dbPath, &pCtx->conchFilePath);\n  if( rc==SQLITE_OK ){\n    rc = proxyCreateUnixFile(pCtx->conchFilePath, &pCtx->conchFile, 0);\n    if( rc==SQLITE_CANTOPEN && ((pFile->openFlags&O_RDWR) == 0) ){\n      /* if (a) the open flags are not O_RDWR, (b) the conch isn't there, and\n      ** (c) the file system is read-only, then enable no-locking access.\n      ** Ugh, since O_RDONLY==0x0000 we test for !O_RDWR since unixOpen asserts\n      ** that openFlags will have only one of O_RDONLY or O_RDWR.\n      */\n      struct statfs fsInfo;\n      struct stat conchInfo;\n      int goLockless = 0;\n\n      if( osStat(pCtx->conchFilePath, &conchInfo) == -1 ) {\n        int err = errno;\n        if( (err==ENOENT) && (statfs(dbPath, &fsInfo) != -1) ){\n          goLockless = (fsInfo.f_flags&MNT_RDONLY) == MNT_RDONLY;\n        }\n      }\n      if( goLockless ){\n        pCtx->conchHeld = -1; /* read only FS/ lockless */\n        rc = SQLITE_OK;\n      }\n    }\n  }  \n  if( rc==SQLITE_OK && lockPath ){\n    pCtx->lockProxyPath = sqlite3DbStrDup(0, lockPath);\n  }\n\n  if( rc==SQLITE_OK ){\n    pCtx->dbPath = sqlite3DbStrDup(0, dbPath);\n    if( pCtx->dbPath==NULL ){\n      rc = SQLITE_NOMEM_BKPT;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    /* all memory is allocated, proxys are created and assigned, \n    ** switch the locking context and pMethod then return.\n    */\n    pCtx->oldLockingContext = pFile->lockingContext;\n    pFile->lockingContext = pCtx;\n    pCtx->pOldMethod = pFile->pMethod;\n    pFile->pMethod = &proxyIoMethods;\n  }else{\n    if( pCtx->conchFile ){ \n      pCtx->conchFile->pMethod->xClose((sqlite3_file *)pCtx->conchFile);\n      sqlite3_free(pCtx->conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath); \n    sqlite3_free(pCtx);\n  }\n  OSTRACE((\"TRANSPROXY  %d %s\\n\", pFile->h,\n           (rc==SQLITE_OK ? \"ok\" : \"failed\")));\n  return rc;\n}\n\n\n/*\n** This routine handles sqlite3_file_control() calls that are specific\n** to proxy locking.\n*/\nstatic int proxyFileControl(sqlite3_file *id, int op, void *pArg){\n  switch( op ){\n    case SQLITE_FCNTL_GET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      if( pFile->pMethod == &proxyIoMethods ){\n        proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;\n        proxyTakeConch(pFile);\n        if( pCtx->lockProxyPath ){\n          *(const char **)pArg = pCtx->lockProxyPath;\n        }else{\n          *(const char **)pArg = \":auto: (not held)\";\n        }\n      } else {\n        *(const char **)pArg = NULL;\n      }\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SET_LOCKPROXYFILE: {\n      unixFile *pFile = (unixFile*)id;\n      int rc = SQLITE_OK;\n      int isProxyStyle = (pFile->pMethod == &proxyIoMethods);\n      if( pArg==NULL || (const char *)pArg==0 ){\n        if( isProxyStyle ){\n          /* turn off proxy locking - not supported.  If support is added for\n          ** switching proxy locking mode off then it will need to fail if\n          ** the journal mode is WAL mode. \n          */\n          rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;\n        }else{\n          /* turn off proxy locking - already off - NOOP */\n          rc = SQLITE_OK;\n        }\n      }else{\n        const char *proxyPath = (const char *)pArg;\n        if( isProxyStyle ){\n          proxyLockingContext *pCtx = \n            (proxyLockingContext*)pFile->lockingContext;\n          if( !strcmp(pArg, \":auto:\") \n           || (pCtx->lockProxyPath &&\n               !strncmp(pCtx->lockProxyPath, proxyPath, MAXPATHLEN))\n          ){\n            rc = SQLITE_OK;\n          }else{\n            rc = switchLockProxyPath(pFile, proxyPath);\n          }\n        }else{\n          /* turn on proxy file locking */\n          rc = proxyTransformUnixFile(pFile, proxyPath);\n        }\n      }\n      return rc;\n    }\n    default: {\n      assert( 0 );  /* The call assures that only valid opcodes are sent */\n    }\n  }\n  /*NOTREACHED*/\n  return SQLITE_ERROR;\n}\n\n/*\n** Within this division (the proxying locking implementation) the procedures\n** above this point are all utilities.  The lock-related methods of the\n** proxy-locking sqlite3_io_method object follow.\n*/\n\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, set *pResOut\n** to a non-zero value otherwise *pResOut is set to zero.  The return value\n** is set to SQLITE_OK unless an I/O error occurs during lock checking.\n*/\nstatic int proxyCheckReservedLock(sqlite3_file *id, int *pResOut) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      return proxy->pMethod->xCheckReservedLock((sqlite3_file*)proxy, pResOut);\n    }else{ /* conchHeld < 0 is lockless */\n      pResOut=0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Lock the file with the lock specified by parameter eFileLock - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  Use the sqlite3OsUnlock()\n** routine to lower a locking level.\n*/\nstatic int proxyLock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xLock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n\n/*\n** Lower the locking level on file descriptor pFile to eFileLock.  eFileLock\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n*/\nstatic int proxyUnlock(sqlite3_file *id, int eFileLock) {\n  unixFile *pFile = (unixFile*)id;\n  int rc = proxyTakeConch(pFile);\n  if( rc==SQLITE_OK ){\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    if( pCtx->conchHeld>0 ){\n      unixFile *proxy = pCtx->lockProxy;\n      rc = proxy->pMethod->xUnlock((sqlite3_file*)proxy, eFileLock);\n      pFile->eFileLock = proxy->eFileLock;\n    }else{\n      /* conchHeld < 0 is lockless */\n    }\n  }\n  return rc;\n}\n\n/*\n** Close a file that uses proxy locks.\n*/\nstatic int proxyClose(sqlite3_file *id) {\n  if( ALWAYS(id) ){\n    unixFile *pFile = (unixFile*)id;\n    proxyLockingContext *pCtx = (proxyLockingContext *)pFile->lockingContext;\n    unixFile *lockProxy = pCtx->lockProxy;\n    unixFile *conchFile = pCtx->conchFile;\n    int rc = SQLITE_OK;\n    \n    if( lockProxy ){\n      rc = lockProxy->pMethod->xUnlock((sqlite3_file*)lockProxy, NO_LOCK);\n      if( rc ) return rc;\n      rc = lockProxy->pMethod->xClose((sqlite3_file*)lockProxy);\n      if( rc ) return rc;\n      sqlite3_free(lockProxy);\n      pCtx->lockProxy = 0;\n    }\n    if( conchFile ){\n      if( pCtx->conchHeld ){\n        rc = proxyReleaseConch(pFile);\n        if( rc ) return rc;\n      }\n      rc = conchFile->pMethod->xClose((sqlite3_file*)conchFile);\n      if( rc ) return rc;\n      sqlite3_free(conchFile);\n    }\n    sqlite3DbFree(0, pCtx->lockProxyPath);\n    sqlite3_free(pCtx->conchFilePath);\n    sqlite3DbFree(0, pCtx->dbPath);\n    /* restore the original locking context and pMethod then close it */\n    pFile->lockingContext = pCtx->oldLockingContext;\n    pFile->pMethod = pCtx->pOldMethod;\n    sqlite3_free(pCtx);\n    return pFile->pMethod->xClose(id);\n  }\n  return SQLITE_OK;\n}\n\n\n\n#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */\n/*\n** The proxy locking style is intended for use with AFP filesystems.\n** And since AFP is only supported on MacOSX, the proxy locking is also\n** restricted to MacOSX.\n** \n**\n******************* End of the proxy lock implementation **********************\n******************************************************************************/\n\n/*\n** Initialize the operating system interface.\n**\n** This routine registers all VFS implementations for unix-like operating\n** systems.  This routine, and the sqlite3_os_end() routine that follows,\n** should be the only routines in this file that are visible from other\n** files.\n**\n** This routine is called once during SQLite initialization and by a\n** single thread.  The memory allocation and mutex subsystems have not\n** necessarily been initialized when this routine is called, and so they\n** should not be used.\n*/\nint sqlite3_os_init(void){ \n  /* \n  ** The following macro defines an initializer for an sqlite3_vfs object.\n  ** The name of the VFS is NAME.  The pAppData is a pointer to a pointer\n  ** to the \"finder\" function.  (pAppData is a pointer to a pointer because\n  ** silly C90 rules prohibit a void* from being cast to a function pointer\n  ** and so we have to go through the intermediate pointer to avoid problems\n  ** when compiling with -pedantic-errors on GCC.)\n  **\n  ** The FINDER parameter to this macro is the name of the pointer to the\n  ** finder-function.  The finder-function returns a pointer to the\n  ** sqlite_io_methods object that implements the desired locking\n  ** behaviors.  See the division above that contains the IOMETHODS\n  ** macro for addition information on finder-functions.\n  **\n  ** Most finders simply return a pointer to a fixed sqlite3_io_methods\n  ** object.  But the \"autolockIoFinder\" available on MacOSX does a little\n  ** more than that; it looks at the filesystem type that hosts the \n  ** database file and tries to choose an locking method appropriate for\n  ** that filesystem time.\n  */\n  #define UNIXVFS(VFSNAME, FINDER) {                        \\\n    3,                    /* iVersion */                    \\\n    sizeof(unixFile),     /* szOsFile */                    \\\n    MAX_PATHNAME,         /* mxPathname */                  \\\n    0,                    /* pNext */                       \\\n    VFSNAME,              /* zName */                       \\\n    (void*)&FINDER,       /* pAppData */                    \\\n    unixOpen,             /* xOpen */                       \\\n    unixDelete,           /* xDelete */                     \\\n    unixAccess,           /* xAccess */                     \\\n    unixFullPathname,     /* xFullPathname */               \\\n    unixDlOpen,           /* xDlOpen */                     \\\n    unixDlError,          /* xDlError */                    \\\n    unixDlSym,            /* xDlSym */                      \\\n    unixDlClose,          /* xDlClose */                    \\\n    unixRandomness,       /* xRandomness */                 \\\n    unixSleep,            /* xSleep */                      \\\n    unixCurrentTime,      /* xCurrentTime */                \\\n    unixGetLastError,     /* xGetLastError */               \\\n    unixCurrentTimeInt64, /* xCurrentTimeInt64 */           \\\n    unixSetSystemCall,    /* xSetSystemCall */              \\\n    unixGetSystemCall,    /* xGetSystemCall */              \\\n    unixNextSystemCall,   /* xNextSystemCall */             \\\n  }\n\n  /*\n  ** All default VFSes for unix are contained in the following array.\n  **\n  ** Note that the sqlite3_vfs.pNext field of the VFS object is modified\n  ** by the SQLite core when the VFS is registered.  So the following\n  ** array cannot be const.\n  */\n  static sqlite3_vfs aVfs[] = {\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix\",          autolockIoFinder ),\n#elif OS_VXWORKS\n    UNIXVFS(\"unix\",          vxworksIoFinder ),\n#else\n    UNIXVFS(\"unix\",          posixIoFinder ),\n#endif\n    UNIXVFS(\"unix-none\",     nolockIoFinder ),\n    UNIXVFS(\"unix-dotfile\",  dotlockIoFinder ),\n    UNIXVFS(\"unix-excl\",     posixIoFinder ),\n#if OS_VXWORKS\n    UNIXVFS(\"unix-namedsem\", semIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS\n    UNIXVFS(\"unix-posix\",    posixIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE\n    UNIXVFS(\"unix-flock\",    flockIoFinder ),\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n    UNIXVFS(\"unix-afp\",      afpIoFinder ),\n    UNIXVFS(\"unix-nfs\",      nfsIoFinder ),\n    UNIXVFS(\"unix-proxy\",    proxyIoFinder ),\n#endif\n  };\n  unsigned int i;          /* Loop counter */\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==29 );\n\n  /* Register all VFSes defined in the aVfs[] array */\n  for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){\n    sqlite3_vfs_register(&aVfs[i], i==0);\n  }\n  return SQLITE_OK; \n}\n\n/*\n** Shutdown the operating system interface.\n**\n** Some operating systems might need to do some cleanup in this routine,\n** to release dynamically allocated objects.  But not on unix.\n** This routine is a no-op for unix.\n*/\nint sqlite3_os_end(void){ \n  return SQLITE_OK; \n}\n \n#endif /* SQLITE_OS_UNIX */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os_win.c",
    "content": "/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n#include \"sqliteInt.h\"\n#if SQLITE_OS_WIN               /* This file is used for Windows only */\n\n/*\n** Include code that is common to all os_*.c files\n*/\n#include \"os_common.h\"\n\n/*\n** Include the header file for the Windows VFS.\n*/\n#include \"os_win.h\"\n\n/*\n** Compiling and using WAL mode requires several APIs that are only\n** available in Windows platforms based on the NT kernel.\n*/\n#if !SQLITE_OS_WINNT && !defined(SQLITE_OMIT_WAL)\n#  error \"WAL mode requires support from the Windows NT kernel, compile\\\n with SQLITE_OMIT_WAL.\"\n#endif\n\n#if !SQLITE_OS_WINNT && SQLITE_MAX_MMAP_SIZE>0\n#  error \"Memory mapped files require support from the Windows NT kernel,\\\n compile with SQLITE_MAX_MMAP_SIZE=0.\"\n#endif\n\n/*\n** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)\n#  define SQLITE_WIN32_HAS_ANSI\n#endif\n\n/*\n** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions\n** based on the sub-platform)?\n*/\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \\\n    !defined(SQLITE_WIN32_NO_WIDE)\n#  define SQLITE_WIN32_HAS_WIDE\n#endif\n\n/*\n** Make sure at least one set of Win32 APIs is available.\n*/\n#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)\n#  error \"At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\\\n must be defined.\"\n#endif\n\n/*\n** Define the required Windows SDK version constants if they are not\n** already available.\n*/\n#ifndef NTDDI_WIN8\n#  define NTDDI_WIN8                        0x06020000\n#endif\n\n#ifndef NTDDI_WINBLUE\n#  define NTDDI_WINBLUE                     0x06030000\n#endif\n\n#ifndef NTDDI_WINTHRESHOLD\n#  define NTDDI_WINTHRESHOLD                0x06040000\n#endif\n\n/*\n** Check to see if the GetVersionEx[AW] functions are deprecated on the\n** target system.  GetVersionEx was first deprecated in Win8.1.\n*/\n#ifndef SQLITE_WIN32_GETVERSIONEX\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINBLUE\n#    define SQLITE_WIN32_GETVERSIONEX   0   /* GetVersionEx() is deprecated */\n#  else\n#    define SQLITE_WIN32_GETVERSIONEX   1   /* GetVersionEx() is current */\n#  endif\n#endif\n\n/*\n** Check to see if the CreateFileMappingA function is supported on the\n** target system.  It is unavailable when using \"mincore.lib\" on Win10.\n** When compiling for Windows 10, always assume \"mincore.lib\" is in use.\n*/\n#ifndef SQLITE_WIN32_CREATEFILEMAPPINGA\n#  if defined(NTDDI_VERSION) && NTDDI_VERSION >= NTDDI_WINTHRESHOLD\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   0\n#  else\n#    define SQLITE_WIN32_CREATEFILEMAPPINGA   1\n#  endif\n#endif\n\n/*\n** This constant should already be defined (in the \"WinDef.h\" SDK file).\n*/\n#ifndef MAX_PATH\n#  define MAX_PATH                      (260)\n#endif\n\n/*\n** Maximum pathname length (in chars) for Win32.  This should normally be\n** MAX_PATH.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_CHARS\n#  define SQLITE_WIN32_MAX_PATH_CHARS   (MAX_PATH)\n#endif\n\n/*\n** This constant should already be defined (in the \"WinNT.h\" SDK file).\n*/\n#ifndef UNICODE_STRING_MAX_CHARS\n#  define UNICODE_STRING_MAX_CHARS      (32767)\n#endif\n\n/*\n** Maximum pathname length (in chars) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS.\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_CHARS\n#  define SQLITE_WINNT_MAX_PATH_CHARS   (UNICODE_STRING_MAX_CHARS)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for Win32.  The MAX_PATH macro is in\n** characters, so we allocate 4 bytes per character assuming worst-case of\n** 4-bytes-per-character for UTF8.\n*/\n#ifndef SQLITE_WIN32_MAX_PATH_BYTES\n#  define SQLITE_WIN32_MAX_PATH_BYTES   (SQLITE_WIN32_MAX_PATH_CHARS*4)\n#endif\n\n/*\n** Maximum pathname length (in bytes) for WinNT.  This should normally be\n** UNICODE_STRING_MAX_CHARS * sizeof(WCHAR).\n*/\n#ifndef SQLITE_WINNT_MAX_PATH_BYTES\n#  define SQLITE_WINNT_MAX_PATH_BYTES   \\\n                            (sizeof(WCHAR) * SQLITE_WINNT_MAX_PATH_CHARS)\n#endif\n\n/*\n** Maximum error message length (in chars) for WinRT.\n*/\n#ifndef SQLITE_WIN32_MAX_ERRMSG_CHARS\n#  define SQLITE_WIN32_MAX_ERRMSG_CHARS (1024)\n#endif\n\n/*\n** Returns non-zero if the character should be treated as a directory\n** separator.\n*/\n#ifndef winIsDirSep\n#  define winIsDirSep(a)                (((a) == '/') || ((a) == '\\\\'))\n#endif\n\n/*\n** This macro is used when a local variable is set to a value that is\n** [sometimes] not used by the code (e.g. via conditional compilation).\n*/\n#ifndef UNUSED_VARIABLE_VALUE\n#  define UNUSED_VARIABLE_VALUE(x)      (void)(x)\n#endif\n\n/*\n** Returns the character that should be used as the directory separator.\n*/\n#ifndef winGetDirSep\n#  define winGetDirSep()                '\\\\'\n#endif\n\n/*\n** Do we need to manually define the Win32 file mapping APIs for use with WAL\n** mode or memory mapped files (e.g. these APIs are available in the Windows\n** CE SDK; however, they are not present in the header file)?\n*/\n#if SQLITE_WIN32_FILEMAPPING_API && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n/*\n** Two of the file mapping APIs are different under WinRT.  Figure out which\n** set we need.\n*/\n#if SQLITE_OS_WINRT\nWINBASEAPI HANDLE WINAPI CreateFileMappingFromApp(HANDLE, \\\n        LPSECURITY_ATTRIBUTES, ULONG, ULONG64, LPCWSTR);\n\nWINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE, ULONG, ULONG64, SIZE_T);\n#else\n#if defined(SQLITE_WIN32_HAS_ANSI)\nWINBASEAPI HANDLE WINAPI CreateFileMappingA(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCSTR);\n#endif /* defined(SQLITE_WIN32_HAS_ANSI) */\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\nWINBASEAPI HANDLE WINAPI CreateFileMappingW(HANDLE, LPSECURITY_ATTRIBUTES, \\\n        DWORD, DWORD, DWORD, LPCWSTR);\n#endif /* defined(SQLITE_WIN32_HAS_WIDE) */\n\nWINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);\n#endif /* SQLITE_OS_WINRT */\n\n/*\n** These file mapping APIs are common to both Win32 and WinRT.\n*/\n\nWINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);\nWINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);\n#endif /* SQLITE_WIN32_FILEMAPPING_API */\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_FILE_ATTRIBUTES\n# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)\n#endif\n\n#ifndef FILE_FLAG_MASK\n# define FILE_FLAG_MASK          (0xFF3C0000)\n#endif\n\n#ifndef FILE_ATTRIBUTE_MASK\n# define FILE_ATTRIBUTE_MASK     (0x0003FFF7)\n#endif\n\n#ifndef SQLITE_OMIT_WAL\n/* Forward references to structures used for WAL */\ntypedef struct winShm winShm;           /* A connection to shared-memory */\ntypedef struct winShmNode winShmNode;   /* A region of shared-memory */\n#endif\n\n/*\n** WinCE lacks native support for file locking so we have to fake it\n** with some code of our own.\n*/\n#if SQLITE_OS_WINCE\ntypedef struct winceLock {\n  int nReaders;       /* Number of reader locks obtained */\n  BOOL bPending;      /* Indicates a pending lock has been obtained */\n  BOOL bReserved;     /* Indicates a reserved lock has been obtained */\n  BOOL bExclusive;    /* Indicates an exclusive lock has been obtained */\n} winceLock;\n#endif\n\n/*\n** The winFile structure is a subclass of sqlite3_file* specific to the win32\n** portability layer.\n*/\ntypedef struct winFile winFile;\nstruct winFile {\n  const sqlite3_io_methods *pMethod; /*** Must be first ***/\n  sqlite3_vfs *pVfs;      /* The VFS used to open this file */\n  HANDLE h;               /* Handle for accessing the file */\n  u8 locktype;            /* Type of lock currently held on this file */\n  short sharedLockByte;   /* Randomly chosen byte used as a shared lock */\n  u8 ctrlFlags;           /* Flags.  See WINFILE_* below */\n  DWORD lastErrno;        /* The Windows errno from the last I/O error */\n#ifndef SQLITE_OMIT_WAL\n  winShm *pShm;           /* Instance of shared memory on this file */\n#endif\n  const char *zPath;      /* Full pathname of this file */\n  int szChunk;            /* Chunk size configured by FCNTL_CHUNK_SIZE */\n#if SQLITE_OS_WINCE\n  LPWSTR zDeleteOnClose;  /* Name of file to delete when closing */\n  HANDLE hMutex;          /* Mutex used to control access to shared lock */\n  HANDLE hShared;         /* Shared memory segment used for locking */\n  winceLock local;        /* Locks obtained by this instance of winFile */\n  winceLock *shared;      /* Global shared lock memory for the file  */\n#endif\n#if SQLITE_MAX_MMAP_SIZE>0\n  int nFetchOut;                /* Number of outstanding xFetch references */\n  HANDLE hMap;                  /* Handle for accessing memory mapping */\n  void *pMapRegion;             /* Area memory mapped */\n  sqlite3_int64 mmapSize;       /* Usable size of mapped region */\n  sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */\n  sqlite3_int64 mmapSizeMax;    /* Configured FCNTL_MMAP_SIZE value */\n#endif\n};\n\n/*\n** The winVfsAppData structure is used for the pAppData member for all of the\n** Win32 VFS variants.\n*/\ntypedef struct winVfsAppData winVfsAppData;\nstruct winVfsAppData {\n  const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */\n  void *pAppData;                    /* The extra pAppData, if any. */\n  BOOL bNoLock;                      /* Non-zero if locking is disabled. */\n};\n\n/*\n** Allowed values for winFile.ctrlFlags\n*/\n#define WINFILE_RDONLY          0x02   /* Connection is read only */\n#define WINFILE_PERSIST_WAL     0x04   /* Persistent WAL mode */\n#define WINFILE_PSOW            0x10   /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */\n\n/*\n * The size of the buffer used by sqlite3_win32_write_debug().\n */\n#ifndef SQLITE_WIN32_DBG_BUF_SIZE\n#  define SQLITE_WIN32_DBG_BUF_SIZE   ((int)(4096-sizeof(DWORD)))\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the data directory should be changed.\n */\n#ifndef SQLITE_WIN32_DATA_DIRECTORY_TYPE\n#  define SQLITE_WIN32_DATA_DIRECTORY_TYPE (1)\n#endif\n\n/*\n * The value used with sqlite3_win32_set_directory() to specify that\n * the temporary directory should be changed.\n */\n#ifndef SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n#  define SQLITE_WIN32_TEMP_DIRECTORY_TYPE (2)\n#endif\n\n/*\n * If compiled with SQLITE_WIN32_MALLOC on Windows, we will use the\n * various Win32 API heap functions instead of our own.\n */\n#ifdef SQLITE_WIN32_MALLOC\n\n/*\n * If this is non-zero, an isolated heap will be created by the native Win32\n * allocator subsystem; otherwise, the default process heap will be used.  This\n * setting has no effect when compiling for WinRT.  By default, this is enabled\n * and an isolated heap will be created to store all allocated data.\n *\n ******************************************************************************\n * WARNING: It is important to note that when this setting is non-zero and the\n *          winMemShutdown function is called (e.g. by the sqlite3_shutdown\n *          function), all data that was allocated using the isolated heap will\n *          be freed immediately and any attempt to access any of that freed\n *          data will almost certainly result in an immediate access violation.\n ******************************************************************************\n */\n#ifndef SQLITE_WIN32_HEAP_CREATE\n#  define SQLITE_WIN32_HEAP_CREATE        (TRUE)\n#endif\n\n/*\n * This is the maximum possible initial size of the Win32-specific heap, in\n * bytes.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)\n#endif\n\n/*\n * This is the extra space for the initial size of the Win32-specific heap,\n * in bytes.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA\n#  define SQLITE_WIN32_HEAP_INIT_EXTRA  (4194304)\n#endif\n\n/*\n * Calculate the maximum legal cache size, in pages, based on the maximum\n * possible initial heap size and the default page size, setting aside the\n * needed extra space.\n */\n#ifndef SQLITE_WIN32_MAX_CACHE_SIZE\n#  define SQLITE_WIN32_MAX_CACHE_SIZE   (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \\\n                                          (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE))\n#endif\n\n/*\n * This is cache size used in the calculation of the initial size of the\n * Win32-specific heap.  It cannot be negative.\n */\n#ifndef SQLITE_WIN32_CACHE_SIZE\n#  if SQLITE_DEFAULT_CACHE_SIZE>=0\n#    define SQLITE_WIN32_CACHE_SIZE     (SQLITE_DEFAULT_CACHE_SIZE)\n#  else\n#    define SQLITE_WIN32_CACHE_SIZE     (-(SQLITE_DEFAULT_CACHE_SIZE))\n#  endif\n#endif\n\n/*\n * Make sure that the calculated cache size, in pages, cannot cause the\n * initial size of the Win32-specific heap to exceed the maximum amount\n * of memory that can be specified in the call to HeapCreate.\n */\n#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE\n#  undef SQLITE_WIN32_CACHE_SIZE\n#  define SQLITE_WIN32_CACHE_SIZE       (2000)\n#endif\n\n/*\n * The initial size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_INIT_SIZE\n#  define SQLITE_WIN32_HEAP_INIT_SIZE   ((SQLITE_WIN32_CACHE_SIZE) * \\\n                                         (SQLITE_DEFAULT_PAGE_SIZE) + \\\n                                         (SQLITE_WIN32_HEAP_INIT_EXTRA))\n#endif\n\n/*\n * The maximum size of the Win32-specific heap.  This value may be zero.\n */\n#ifndef SQLITE_WIN32_HEAP_MAX_SIZE\n#  define SQLITE_WIN32_HEAP_MAX_SIZE    (0)\n#endif\n\n/*\n * The extra flags to use in calls to the Win32 heap APIs.  This value may be\n * zero for the default behavior.\n */\n#ifndef SQLITE_WIN32_HEAP_FLAGS\n#  define SQLITE_WIN32_HEAP_FLAGS       (0)\n#endif\n\n\n/*\n** The winMemData structure stores information required by the Win32-specific\n** sqlite3_mem_methods implementation.\n*/\ntypedef struct winMemData winMemData;\nstruct winMemData {\n#ifndef NDEBUG\n  u32 magic1;   /* Magic number to detect structure corruption. */\n#endif\n  HANDLE hHeap; /* The handle to our heap. */\n  BOOL bOwned;  /* Do we own the heap (i.e. destroy it on shutdown)? */\n#ifndef NDEBUG\n  u32 magic2;   /* Magic number to detect structure corruption. */\n#endif\n};\n\n#ifndef NDEBUG\n#define WINMEM_MAGIC1     0x42b2830b\n#define WINMEM_MAGIC2     0xbd4d7cf4\n#endif\n\nstatic struct winMemData win_mem_data = {\n#ifndef NDEBUG\n  WINMEM_MAGIC1,\n#endif\n  NULL, FALSE\n#ifndef NDEBUG\n  ,WINMEM_MAGIC2\n#endif\n};\n\n#ifndef NDEBUG\n#define winMemAssertMagic1() assert( win_mem_data.magic1==WINMEM_MAGIC1 )\n#define winMemAssertMagic2() assert( win_mem_data.magic2==WINMEM_MAGIC2 )\n#define winMemAssertMagic()  winMemAssertMagic1(); winMemAssertMagic2();\n#else\n#define winMemAssertMagic()\n#endif\n\n#define winMemGetDataPtr()  &win_mem_data\n#define winMemGetHeap()     win_mem_data.hHeap\n#define winMemGetOwned()    win_mem_data.bOwned\n\nstatic void *winMemMalloc(int nBytes);\nstatic void winMemFree(void *pPrior);\nstatic void *winMemRealloc(void *pPrior, int nBytes);\nstatic int winMemSize(void *p);\nstatic int winMemRoundup(int n);\nstatic int winMemInit(void *pAppData);\nstatic void winMemShutdown(void *pAppData);\n\nconst sqlite3_mem_methods *sqlite3MemGetWin32(void);\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** The following variable is (normally) set once and never changes\n** thereafter.  It records whether the operating system is Win9x\n** or WinNT.\n**\n** 0:   Operating system unknown.\n** 1:   Operating system is Win9x.\n** 2:   Operating system is WinNT.\n**\n** In order to facilitate testing on a WinNT system, the test fixture\n** can manually set this value to 1 to emulate Win98 behavior.\n*/\n#ifdef SQLITE_TEST\nLONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#else\nstatic LONG SQLITE_WIN32_VOLATILE sqlite3_os_type = 0;\n#endif\n\n#ifndef SYSCALL\n#  define SYSCALL sqlite3_syscall_ptr\n#endif\n\n/*\n** This function is not available on Windows CE or WinRT.\n */\n\n#if SQLITE_OS_WINCE || SQLITE_OS_WINRT\n#  define osAreFileApisANSI()       1\n#endif\n\n/*\n** Many system calls are accessed through pointer-to-functions so that\n** they may be overridden at runtime to facilitate fault injection during\n** testing and sandboxing.  The following array holds the names and pointers\n** to all overrideable system calls.\n*/\nstatic struct win_syscall {\n  const char *zName;            /* Name of the system call */\n  sqlite3_syscall_ptr pCurrent; /* Current value of the system call */\n  sqlite3_syscall_ptr pDefault; /* Default value */\n} aSyscall[] = {\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"AreFileApisANSI\",         (SYSCALL)AreFileApisANSI,         0 },\n#else\n  { \"AreFileApisANSI\",         (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osAreFileApisANSI\n#define osAreFileApisANSI ((BOOL(WINAPI*)(VOID))aSyscall[0].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharLowerW\",              (SYSCALL)CharLowerW,              0 },\n#else\n  { \"CharLowerW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharLowerW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[1].pCurrent)\n\n#if SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CharUpperW\",              (SYSCALL)CharUpperW,              0 },\n#else\n  { \"CharUpperW\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osCharUpperW ((LPWSTR(WINAPI*)(LPWSTR))aSyscall[2].pCurrent)\n\n  { \"CloseHandle\",             (SYSCALL)CloseHandle,             0 },\n\n#define osCloseHandle ((BOOL(WINAPI*)(HANDLE))aSyscall[3].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"CreateFileA\",             (SYSCALL)CreateFileA,             0 },\n#else\n  { \"CreateFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileA ((HANDLE(WINAPI*)(LPCSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[4].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateFileW\",             (SYSCALL)CreateFileW,             0 },\n#else\n  { \"CreateFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \\\n        LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0) && \\\n        SQLITE_WIN32_CREATEFILEMAPPINGA\n  { \"CreateFileMappingA\",      (SYSCALL)CreateFileMappingA,      0 },\n#else\n  { \"CreateFileMappingA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingA ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"CreateFileMappingW\",      (SYSCALL)CreateFileMappingW,      0 },\n#else\n  { \"CreateFileMappingW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFileMappingW ((HANDLE(WINAPI*)(HANDLE,LPSECURITY_ATTRIBUTES, \\\n        DWORD,DWORD,DWORD,LPCWSTR))aSyscall[7].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"CreateMutexW\",            (SYSCALL)CreateMutexW,            0 },\n#else\n  { \"CreateMutexW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateMutexW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,BOOL, \\\n        LPCWSTR))aSyscall[8].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"DeleteFileA\",             (SYSCALL)DeleteFileA,             0 },\n#else\n  { \"DeleteFileA\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileA ((BOOL(WINAPI*)(LPCSTR))aSyscall[9].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"DeleteFileW\",             (SYSCALL)DeleteFileW,             0 },\n#else\n  { \"DeleteFileW\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osDeleteFileW ((BOOL(WINAPI*)(LPCWSTR))aSyscall[10].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToLocalFileTime\", (SYSCALL)FileTimeToLocalFileTime, 0 },\n#else\n  { \"FileTimeToLocalFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToLocalFileTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPFILETIME))aSyscall[11].pCurrent)\n\n#if SQLITE_OS_WINCE\n  { \"FileTimeToSystemTime\",    (SYSCALL)FileTimeToSystemTime,    0 },\n#else\n  { \"FileTimeToSystemTime\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osFileTimeToSystemTime ((BOOL(WINAPI*)(CONST FILETIME*, \\\n        LPSYSTEMTIME))aSyscall[12].pCurrent)\n\n  { \"FlushFileBuffers\",        (SYSCALL)FlushFileBuffers,        0 },\n\n#define osFlushFileBuffers ((BOOL(WINAPI*)(HANDLE))aSyscall[13].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"FormatMessageA\",          (SYSCALL)FormatMessageA,          0 },\n#else\n  { \"FormatMessageA\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageA ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPSTR, \\\n        DWORD,va_list*))aSyscall[14].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"FormatMessageW\",          (SYSCALL)FormatMessageW,          0 },\n#else\n  { \"FormatMessageW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osFormatMessageW ((DWORD(WINAPI*)(DWORD,LPCVOID,DWORD,DWORD,LPWSTR, \\\n        DWORD,va_list*))aSyscall[15].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"FreeLibrary\",             (SYSCALL)FreeLibrary,             0 },\n#else\n  { \"FreeLibrary\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osFreeLibrary ((BOOL(WINAPI*)(HMODULE))aSyscall[16].pCurrent)\n\n  { \"GetCurrentProcessId\",     (SYSCALL)GetCurrentProcessId,     0 },\n\n#define osGetCurrentProcessId ((DWORD(WINAPI*)(VOID))aSyscall[17].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)GetDiskFreeSpaceA,       0 },\n#else\n  { \"GetDiskFreeSpaceA\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceA ((BOOL(WINAPI*)(LPCSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[18].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)GetDiskFreeSpaceW,       0 },\n#else\n  { \"GetDiskFreeSpaceW\",       (SYSCALL)0,                       0 },\n#endif\n\n#define osGetDiskFreeSpaceW ((BOOL(WINAPI*)(LPCWSTR,LPDWORD,LPDWORD,LPDWORD, \\\n        LPDWORD))aSyscall[19].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFileAttributesA\",      (SYSCALL)GetFileAttributesA,      0 },\n#else\n  { \"GetFileAttributesA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesA ((DWORD(WINAPI*)(LPCSTR))aSyscall[20].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesW\",      (SYSCALL)GetFileAttributesW,      0 },\n#else\n  { \"GetFileAttributesW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesW ((DWORD(WINAPI*)(LPCWSTR))aSyscall[21].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFileAttributesExW\",    (SYSCALL)GetFileAttributesExW,    0 },\n#else\n  { \"GetFileAttributesExW\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileAttributesExW ((BOOL(WINAPI*)(LPCWSTR,GET_FILEEX_INFO_LEVELS, \\\n        LPVOID))aSyscall[22].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetFileSize\",             (SYSCALL)GetFileSize,             0 },\n#else\n  { \"GetFileSize\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFileSize ((DWORD(WINAPI*)(HANDLE,LPDWORD))aSyscall[23].pCurrent)\n\n#if !SQLITE_OS_WINCE && defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetFullPathNameA\",        (SYSCALL)GetFullPathNameA,        0 },\n#else\n  { \"GetFullPathNameA\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameA ((DWORD(WINAPI*)(LPCSTR,DWORD,LPSTR, \\\n        LPSTR*))aSyscall[24].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetFullPathNameW\",        (SYSCALL)GetFullPathNameW,        0 },\n#else\n  { \"GetFullPathNameW\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osGetFullPathNameW ((DWORD(WINAPI*)(LPCWSTR,DWORD,LPWSTR, \\\n        LPWSTR*))aSyscall[25].pCurrent)\n\n  { \"GetLastError\",            (SYSCALL)GetLastError,            0 },\n\n#define osGetLastError ((DWORD(WINAPI*)(VOID))aSyscall[26].pCurrent)\n\n#if !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#if SQLITE_OS_WINCE\n  /* The GetProcAddressA() routine is only available on Windows CE. */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddressA,         0 },\n#else\n  /* All other Windows platforms expect GetProcAddress() to take\n  ** an ANSI string regardless of the _UNICODE setting */\n  { \"GetProcAddressA\",         (SYSCALL)GetProcAddress,          0 },\n#endif\n#else\n  { \"GetProcAddressA\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osGetProcAddressA ((FARPROC(WINAPI*)(HMODULE, \\\n        LPCSTR))aSyscall[27].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetSystemInfo\",           (SYSCALL)GetSystemInfo,           0 },\n#else\n  { \"GetSystemInfo\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemInfo ((VOID(WINAPI*)(LPSYSTEM_INFO))aSyscall[28].pCurrent)\n\n  { \"GetSystemTime\",           (SYSCALL)GetSystemTime,           0 },\n\n#define osGetSystemTime ((VOID(WINAPI*)(LPSYSTEMTIME))aSyscall[29].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)GetSystemTimeAsFileTime, 0 },\n#else\n  { \"GetSystemTimeAsFileTime\", (SYSCALL)0,                       0 },\n#endif\n\n#define osGetSystemTimeAsFileTime ((VOID(WINAPI*)( \\\n        LPFILETIME))aSyscall[30].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"GetTempPathA\",            (SYSCALL)GetTempPathA,            0 },\n#else\n  { \"GetTempPathA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE)\n  { \"GetTempPathW\",            (SYSCALL)GetTempPathW,            0 },\n#else\n  { \"GetTempPathW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTempPathW ((DWORD(WINAPI*)(DWORD,LPWSTR))aSyscall[32].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"GetTickCount\",            (SYSCALL)GetTickCount,            0 },\n#else\n  { \"GetTickCount\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount ((DWORD(WINAPI*)(VOID))aSyscall[33].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExA\",           (SYSCALL)GetVersionExA,           0 },\n#else\n  { \"GetVersionExA\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExA ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOA))aSyscall[34].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        SQLITE_WIN32_GETVERSIONEX\n  { \"GetVersionExW\",           (SYSCALL)GetVersionExW,           0 },\n#else\n  { \"GetVersionExW\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osGetVersionExW ((BOOL(WINAPI*)( \\\n        LPOSVERSIONINFOW))aSyscall[35].pCurrent)\n\n  { \"HeapAlloc\",               (SYSCALL)HeapAlloc,               0 },\n\n#define osHeapAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD, \\\n        SIZE_T))aSyscall[36].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapCreate\",              (SYSCALL)HeapCreate,              0 },\n#else\n  { \"HeapCreate\",              (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCreate ((HANDLE(WINAPI*)(DWORD,SIZE_T, \\\n        SIZE_T))aSyscall[37].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapDestroy\",             (SYSCALL)HeapDestroy,             0 },\n#else\n  { \"HeapDestroy\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapDestroy ((BOOL(WINAPI*)(HANDLE))aSyscall[38].pCurrent)\n\n  { \"HeapFree\",                (SYSCALL)HeapFree,                0 },\n\n#define osHeapFree ((BOOL(WINAPI*)(HANDLE,DWORD,LPVOID))aSyscall[39].pCurrent)\n\n  { \"HeapReAlloc\",             (SYSCALL)HeapReAlloc,             0 },\n\n#define osHeapReAlloc ((LPVOID(WINAPI*)(HANDLE,DWORD,LPVOID, \\\n        SIZE_T))aSyscall[40].pCurrent)\n\n  { \"HeapSize\",                (SYSCALL)HeapSize,                0 },\n\n#define osHeapSize ((SIZE_T(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[41].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"HeapValidate\",            (SYSCALL)HeapValidate,            0 },\n#else\n  { \"HeapValidate\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \\\n        LPCVOID))aSyscall[42].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"HeapCompact\",             (SYSCALL)HeapCompact,             0 },\n#else\n  { \"HeapCompact\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osHeapCompact ((UINT(WINAPI*)(HANDLE,DWORD))aSyscall[43].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryA\",            (SYSCALL)LoadLibraryA,            0 },\n#else\n  { \"LoadLibraryA\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent)\n\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \\\n        !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadLibraryW\",            (SYSCALL)LoadLibraryW,            0 },\n#else\n  { \"LoadLibraryW\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"LocalFree\",               (SYSCALL)LocalFree,               0 },\n#else\n  { \"LocalFree\",               (SYSCALL)0,                       0 },\n#endif\n\n#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"LockFile\",                (SYSCALL)LockFile,                0 },\n#else\n  { \"LockFile\",                (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFile\n#define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[47].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"LockFileEx\",              (SYSCALL)LockFileEx,              0 },\n#else\n  { \"LockFileEx\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osLockFileEx\n#define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[48].pCurrent)\n#endif\n\n#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \\\n        (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))\n  { \"MapViewOfFile\",           (SYSCALL)MapViewOfFile,           0 },\n#else\n  { \"MapViewOfFile\",           (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        SIZE_T))aSyscall[49].pCurrent)\n\n  { \"MultiByteToWideChar\",     (SYSCALL)MultiByteToWideChar,     0 },\n\n#define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \\\n        int))aSyscall[50].pCurrent)\n\n  { \"QueryPerformanceCounter\", (SYSCALL)QueryPerformanceCounter, 0 },\n\n#define osQueryPerformanceCounter ((BOOL(WINAPI*)( \\\n        LARGE_INTEGER*))aSyscall[51].pCurrent)\n\n  { \"ReadFile\",                (SYSCALL)ReadFile,                0 },\n\n#define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[52].pCurrent)\n\n  { \"SetEndOfFile\",            (SYSCALL)SetEndOfFile,            0 },\n\n#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"SetFilePointer\",          (SYSCALL)SetFilePointer,          0 },\n#else\n  { \"SetFilePointer\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \\\n        DWORD))aSyscall[54].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"Sleep\",                   (SYSCALL)Sleep,                   0 },\n#else\n  { \"Sleep\",                   (SYSCALL)0,                       0 },\n#endif\n\n#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent)\n\n  { \"SystemTimeToFileTime\",    (SYSCALL)SystemTimeToFileTime,    0 },\n\n#define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \\\n        LPFILETIME))aSyscall[56].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  { \"UnlockFile\",              (SYSCALL)UnlockFile,              0 },\n#else\n  { \"UnlockFile\",              (SYSCALL)0,                       0 },\n#endif\n\n#ifndef osUnlockFile\n#define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        DWORD))aSyscall[57].pCurrent)\n#endif\n\n#if !SQLITE_OS_WINCE\n  { \"UnlockFileEx\",            (SYSCALL)UnlockFileEx,            0 },\n#else\n  { \"UnlockFileEx\",            (SYSCALL)0,                       0 },\n#endif\n\n#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \\\n        LPOVERLAPPED))aSyscall[58].pCurrent)\n\n#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0\n  { \"UnmapViewOfFile\",         (SYSCALL)UnmapViewOfFile,         0 },\n#else\n  { \"UnmapViewOfFile\",         (SYSCALL)0,                       0 },\n#endif\n\n#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[59].pCurrent)\n\n  { \"WideCharToMultiByte\",     (SYSCALL)WideCharToMultiByte,     0 },\n\n#define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \\\n        LPCSTR,LPBOOL))aSyscall[60].pCurrent)\n\n  { \"WriteFile\",               (SYSCALL)WriteFile,               0 },\n\n#define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \\\n        LPOVERLAPPED))aSyscall[61].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateEventExW\",          (SYSCALL)CreateEventExW,          0 },\n#else\n  { \"CreateEventExW\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \\\n        DWORD,DWORD))aSyscall[62].pCurrent)\n\n#if !SQLITE_OS_WINRT\n  { \"WaitForSingleObject\",     (SYSCALL)WaitForSingleObject,     0 },\n#else\n  { \"WaitForSingleObject\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \\\n        DWORD))aSyscall[63].pCurrent)\n\n#if !SQLITE_OS_WINCE\n  { \"WaitForSingleObjectEx\",   (SYSCALL)WaitForSingleObjectEx,   0 },\n#else\n  { \"WaitForSingleObjectEx\",   (SYSCALL)0,                       0 },\n#endif\n\n#define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \\\n        BOOL))aSyscall[64].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"SetFilePointerEx\",        (SYSCALL)SetFilePointerEx,        0 },\n#else\n  { \"SetFilePointerEx\",        (SYSCALL)0,                       0 },\n#endif\n\n#define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \\\n        PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetFileInformationByHandleEx\", (SYSCALL)GetFileInformationByHandleEx, 0 },\n#else\n  { \"GetFileInformationByHandleEx\", (SYSCALL)0,                  0 },\n#endif\n\n#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \\\n        FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"MapViewOfFileFromApp\",    (SYSCALL)MapViewOfFileFromApp,    0 },\n#else\n  { \"MapViewOfFileFromApp\",    (SYSCALL)0,                       0 },\n#endif\n\n#define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \\\n        SIZE_T))aSyscall[67].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"CreateFile2\",             (SYSCALL)CreateFile2,             0 },\n#else\n  { \"CreateFile2\",             (SYSCALL)0,                       0 },\n#endif\n\n#define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \\\n        LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent)\n\n#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  { \"LoadPackagedLibrary\",     (SYSCALL)LoadPackagedLibrary,     0 },\n#else\n  { \"LoadPackagedLibrary\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \\\n        DWORD))aSyscall[69].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetTickCount64\",          (SYSCALL)GetTickCount64,          0 },\n#else\n  { \"GetTickCount64\",          (SYSCALL)0,                       0 },\n#endif\n\n#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent)\n\n#if SQLITE_OS_WINRT\n  { \"GetNativeSystemInfo\",     (SYSCALL)GetNativeSystemInfo,     0 },\n#else\n  { \"GetNativeSystemInfo\",     (SYSCALL)0,                       0 },\n#endif\n\n#define osGetNativeSystemInfo ((VOID(WINAPI*)( \\\n        LPSYSTEM_INFO))aSyscall[71].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  { \"OutputDebugStringA\",      (SYSCALL)OutputDebugStringA,      0 },\n#else\n  { \"OutputDebugStringA\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[72].pCurrent)\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  { \"OutputDebugStringW\",      (SYSCALL)OutputDebugStringW,      0 },\n#else\n  { \"OutputDebugStringW\",      (SYSCALL)0,                       0 },\n#endif\n\n#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[73].pCurrent)\n\n  { \"GetProcessHeap\",          (SYSCALL)GetProcessHeap,          0 },\n\n#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)\n\n#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)\n  { \"CreateFileMappingFromApp\", (SYSCALL)CreateFileMappingFromApp, 0 },\n#else\n  { \"CreateFileMappingFromApp\", (SYSCALL)0,                      0 },\n#endif\n\n#define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \\\n        LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent)\n\n/*\n** NOTE: On some sub-platforms, the InterlockedCompareExchange \"function\"\n**       is really just a macro that uses a compiler intrinsic (e.g. x64).\n**       So do not try to make this is into a redefinable interface.\n*/\n#if defined(InterlockedCompareExchange)\n  { \"InterlockedCompareExchange\", (SYSCALL)0,                    0 },\n\n#define osInterlockedCompareExchange InterlockedCompareExchange\n#else\n  { \"InterlockedCompareExchange\", (SYSCALL)InterlockedCompareExchange, 0 },\n\n#define osInterlockedCompareExchange ((LONG(WINAPI*)(LONG \\\n        SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)\n#endif /* defined(InterlockedCompareExchange) */\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreate\",               (SYSCALL)UuidCreate,             0 },\n#else\n  { \"UuidCreate\",               (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  { \"UuidCreateSequential\",     (SYSCALL)UuidCreateSequential,   0 },\n#else\n  { \"UuidCreateSequential\",     (SYSCALL)0,                      0 },\n#endif\n\n#define osUuidCreateSequential \\\n        ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)\n\n#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0\n  { \"FlushViewOfFile\",          (SYSCALL)FlushViewOfFile,        0 },\n#else\n  { \"FlushViewOfFile\",          (SYSCALL)0,                      0 },\n#endif\n\n#define osFlushViewOfFile \\\n        ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)\n\n}; /* End of the overrideable system calls */\n\n/*\n** This is the xSetSystemCall() method of sqlite3_vfs for all of the\n** \"win32\" VFSes.  Return SQLITE_OK opon successfully updating the\n** system call pointer, or SQLITE_NOTFOUND if there is no configurable\n** system call named zName.\n*/\nstatic int winSetSystemCall(\n  sqlite3_vfs *pNotUsed,        /* The VFS pointer.  Not used */\n  const char *zName,            /* Name of system call to override */\n  sqlite3_syscall_ptr pNewFunc  /* Pointer to new system call value */\n){\n  unsigned int i;\n  int rc = SQLITE_NOTFOUND;\n\n  UNUSED_PARAMETER(pNotUsed);\n  if( zName==0 ){\n    /* If no zName is given, restore all system calls to their default\n    ** settings and return NULL\n    */\n    rc = SQLITE_OK;\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( aSyscall[i].pDefault ){\n        aSyscall[i].pCurrent = aSyscall[i].pDefault;\n      }\n    }\n  }else{\n    /* If zName is specified, operate on only the one system call\n    ** specified.\n    */\n    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ){\n        if( aSyscall[i].pDefault==0 ){\n          aSyscall[i].pDefault = aSyscall[i].pCurrent;\n        }\n        rc = SQLITE_OK;\n        if( pNewFunc==0 ) pNewFunc = aSyscall[i].pDefault;\n        aSyscall[i].pCurrent = pNewFunc;\n        break;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return the value of a system call.  Return NULL if zName is not a\n** recognized system call name.  NULL is also returned if the system call\n** is currently undefined.\n*/\nstatic sqlite3_syscall_ptr winGetSystemCall(\n  sqlite3_vfs *pNotUsed,\n  const char *zName\n){\n  unsigned int i;\n\n  UNUSED_PARAMETER(pNotUsed);\n  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){\n    if( strcmp(zName, aSyscall[i].zName)==0 ) return aSyscall[i].pCurrent;\n  }\n  return 0;\n}\n\n/*\n** Return the name of the first system call after zName.  If zName==NULL\n** then return the name of the first system call.  Return NULL if zName\n** is the last system call or if zName is not the name of a valid\n** system call.\n*/\nstatic const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){\n  int i = -1;\n\n  UNUSED_PARAMETER(p);\n  if( zName ){\n    for(i=0; i<ArraySize(aSyscall)-1; i++){\n      if( strcmp(zName, aSyscall[i].zName)==0 ) break;\n    }\n  }\n  for(i++; i<ArraySize(aSyscall); i++){\n    if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** compact it.  Upon success, SQLITE_OK will be returned.  Upon failure, one\n** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned.  The\n** \"pnLargest\" argument, if non-zero, will be used to return the size of the\n** largest committed free block in the heap, in bytes.\n*/\nint sqlite3_win32_compact_heap(LPUINT pnLargest){\n  int rc = SQLITE_OK;\n  UINT nLargest = 0;\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){\n    DWORD lastErrno = osGetLastError();\n    if( lastErrno==NO_ERROR ){\n      sqlite3_log(SQLITE_NOMEM, \"failed to HeapCompact (no space), heap=%p\",\n                  (void*)hHeap);\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      sqlite3_log(SQLITE_ERROR, \"failed to HeapCompact (%lu), heap=%p\",\n                  osGetLastError(), (void*)hHeap);\n      rc = SQLITE_ERROR;\n    }\n  }\n#else\n  sqlite3_log(SQLITE_NOTFOUND, \"failed to HeapCompact, heap=%p\",\n              (void*)hHeap);\n  rc = SQLITE_NOTFOUND;\n#endif\n  if( pnLargest ) *pnLargest = nLargest;\n  return rc;\n}\n\n/*\n** If a Win32 native heap has been configured, this function will attempt to\n** destroy and recreate it.  If the Win32 native heap is not isolated and/or\n** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will\n** be returned and no changes will be made to the Win32 native heap.\n*/\nint sqlite3_win32_reset_heap(){\n  int rc;\n  MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */\n  MUTEX_LOGIC( sqlite3_mutex *pMem; )    /* The memsys static mutex */\n  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )\n  MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )\n  sqlite3_mutex_enter(pMaster);\n  sqlite3_mutex_enter(pMem);\n  winMemAssertMagic();\n  if( winMemGetHeap()!=NULL && winMemGetOwned() && sqlite3_memory_used()==0 ){\n    /*\n    ** At this point, there should be no outstanding memory allocations on\n    ** the heap.  Also, since both the master and memsys locks are currently\n    ** being held by us, no other function (i.e. from another thread) should\n    ** be able to even access the heap.  Attempt to destroy and recreate our\n    ** isolated Win32 native heap now.\n    */\n    assert( winMemGetHeap()!=NULL );\n    assert( winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    winMemShutdown(winMemGetDataPtr());\n    assert( winMemGetHeap()==NULL );\n    assert( !winMemGetOwned() );\n    assert( sqlite3_memory_used()==0 );\n    rc = winMemInit(winMemGetDataPtr());\n    assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL );\n    assert( rc!=SQLITE_OK || winMemGetOwned() );\n    assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 );\n  }else{\n    /*\n    ** The Win32 native heap cannot be modified because it may be in use.\n    */\n    rc = SQLITE_BUSY;\n  }\n  sqlite3_mutex_leave(pMem);\n  sqlite3_mutex_leave(pMaster);\n  return rc;\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** This function outputs the specified (ANSI) string to the Win32 debugger\n** (if available).\n*/\n\nvoid sqlite3_win32_write_debug(const char *zBuf, int nBuf){\n  char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];\n  int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */\n  if( nMin<-1 ) nMin = -1; /* all negative values become -1. */\n  assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zBuf ){\n    (void)SQLITE_MISUSE_BKPT;\n    return;\n  }\n#endif\n#if defined(SQLITE_WIN32_HAS_ANSI)\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    osOutputDebugStringA(zDbgBuf);\n  }else{\n    osOutputDebugStringA(zBuf);\n  }\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n  memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n  if ( osMultiByteToWideChar(\n          osAreFileApisANSI() ? CP_ACP : CP_OEMCP, 0, zBuf,\n          nMin, (LPWSTR)zDbgBuf, SQLITE_WIN32_DBG_BUF_SIZE/sizeof(WCHAR))<=0 ){\n    return;\n  }\n  osOutputDebugStringW((LPCWSTR)zDbgBuf);\n#else\n  if( nMin>0 ){\n    memset(zDbgBuf, 0, SQLITE_WIN32_DBG_BUF_SIZE);\n    memcpy(zDbgBuf, zBuf, nMin);\n    fprintf(stderr, \"%s\", zDbgBuf);\n  }else{\n    fprintf(stderr, \"%s\", zBuf);\n  }\n#endif\n}\n\n/*\n** The following routine suspends the current thread for at least ms\n** milliseconds.  This is equivalent to the Win32 Sleep() interface.\n*/\n#if SQLITE_OS_WINRT\nstatic HANDLE sleepObj = NULL;\n#endif\n\nvoid sqlite3_win32_sleep(DWORD milliseconds){\n#if SQLITE_OS_WINRT\n  if ( sleepObj==NULL ){\n    sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,\n                                SYNCHRONIZE);\n  }\n  assert( sleepObj!=NULL );\n  osWaitForSingleObjectEx(sleepObj, milliseconds, FALSE);\n#else\n  osSleep(milliseconds);\n#endif\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0 && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n        SQLITE_THREADSAFE>0\nDWORD sqlite3Win32Wait(HANDLE hObject){\n  DWORD rc;\n  while( (rc = osWaitForSingleObjectEx(hObject, INFINITE,\n                                       TRUE))==WAIT_IO_COMPLETION ){}\n  return rc;\n}\n#endif\n\n/*\n** Return true (non-zero) if we are running under WinNT, Win2K, WinXP,\n** or WinCE.  Return false (zero) for Win95, Win98, or WinME.\n**\n** Here is an interesting observation:  Win95, Win98, and WinME lack\n** the LockFileEx() API.  But we can still statically link against that\n** API as long as we don't call it when running Win95/98/ME.  A call to\n** this routine is used to determine if the host is Win95/98/ME or\n** WinNT/2K/XP so that we will know whether or not we can safely call\n** the LockFileEx() API.\n*/\n\n#if !SQLITE_WIN32_GETVERSIONEX\n# define osIsNT()  (1)\n#elif SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)\n# define osIsNT()  (1)\n#elif !defined(SQLITE_WIN32_HAS_WIDE)\n# define osIsNT()  (0)\n#else\n# define osIsNT()  ((sqlite3_os_type==2) || sqlite3_win32_is_nt())\n#endif\n\n/*\n** This function determines if the machine is running a version of Windows\n** based on the NT kernel.\n*/\nint sqlite3_win32_is_nt(void){\n#if SQLITE_OS_WINRT\n  /*\n  ** NOTE: The WinRT sub-platform is always assumed to be based on the NT\n  **       kernel.\n  */\n  return 1;\n#elif SQLITE_WIN32_GETVERSIONEX\n  if( osInterlockedCompareExchange(&sqlite3_os_type, 0, 0)==0 ){\n#if defined(SQLITE_WIN32_HAS_ANSI)\n    OSVERSIONINFOA sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExA(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    OSVERSIONINFOW sInfo;\n    sInfo.dwOSVersionInfoSize = sizeof(sInfo);\n    osGetVersionExW(&sInfo);\n    osInterlockedCompareExchange(&sqlite3_os_type,\n        (sInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 2 : 1, 0);\n#endif\n  }\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#elif SQLITE_TEST\n  return osInterlockedCompareExchange(&sqlite3_os_type, 2, 2)==2;\n#else\n  /*\n  ** NOTE: All sub-platforms where the GetVersionEx[AW] functions are\n  **       deprecated are always assumed to be based on the NT kernel.\n  */\n  return 1;\n#endif\n}\n\n#ifdef SQLITE_WIN32_MALLOC\n/*\n** Allocate nBytes of memory.\n*/\nstatic void *winMemMalloc(int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  assert( nBytes>=0 );\n  p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapAlloc %u bytes (%lu), heap=%p\",\n                nBytes, osGetLastError(), (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Free memory.\n*/\nstatic void winMemFree(void *pPrior){\n  HANDLE hHeap;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */\n  if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapFree block %p (%lu), heap=%p\",\n                pPrior, osGetLastError(), (void*)hHeap);\n  }\n}\n\n/*\n** Change the size of an existing memory allocation\n*/\nstatic void *winMemRealloc(void *pPrior, int nBytes){\n  HANDLE hHeap;\n  void *p;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) );\n#endif\n  assert( nBytes>=0 );\n  if( !pPrior ){\n    p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes);\n  }else{\n    p = osHeapReAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior, (SIZE_T)nBytes);\n  }\n  if( !p ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to %s %u bytes (%lu), heap=%p\",\n                pPrior ? \"HeapReAlloc\" : \"HeapAlloc\", nBytes, osGetLastError(),\n                (void*)hHeap);\n  }\n  return p;\n}\n\n/*\n** Return the size of an outstanding allocation, in bytes.\n*/\nstatic int winMemSize(void *p){\n  HANDLE hHeap;\n  SIZE_T n;\n\n  winMemAssertMagic();\n  hHeap = winMemGetHeap();\n  assert( hHeap!=0 );\n  assert( hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) );\n#endif\n  if( !p ) return 0;\n  n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p);\n  if( n==(SIZE_T)-1 ){\n    sqlite3_log(SQLITE_NOMEM, \"failed to HeapSize block %p (%lu), heap=%p\",\n                p, osGetLastError(), (void*)hHeap);\n    return 0;\n  }\n  return (int)n;\n}\n\n/*\n** Round up a request size to the next valid allocation size.\n*/\nstatic int winMemRoundup(int n){\n  return n;\n}\n\n/*\n** Initialize this module.\n*/\nstatic int winMemInit(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return SQLITE_ERROR;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n#if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE\n  if( !pWinMemData->hHeap ){\n    DWORD dwInitialSize = SQLITE_WIN32_HEAP_INIT_SIZE;\n    DWORD dwMaximumSize = (DWORD)sqlite3GlobalConfig.nHeap;\n    if( dwMaximumSize==0 ){\n      dwMaximumSize = SQLITE_WIN32_HEAP_MAX_SIZE;\n    }else if( dwInitialSize>dwMaximumSize ){\n      dwInitialSize = dwMaximumSize;\n    }\n    pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS,\n                                      dwInitialSize, dwMaximumSize);\n    if( !pWinMemData->hHeap ){\n      sqlite3_log(SQLITE_NOMEM,\n          \"failed to HeapCreate (%lu), flags=%u, initSize=%lu, maxSize=%lu\",\n          osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, dwInitialSize,\n          dwMaximumSize);\n      return SQLITE_NOMEM_BKPT;\n    }\n    pWinMemData->bOwned = TRUE;\n    assert( pWinMemData->bOwned );\n  }\n#else\n  pWinMemData->hHeap = osGetProcessHeap();\n  if( !pWinMemData->hHeap ){\n    sqlite3_log(SQLITE_NOMEM,\n        \"failed to GetProcessHeap (%lu)\", osGetLastError());\n    return SQLITE_NOMEM_BKPT;\n  }\n  pWinMemData->bOwned = FALSE;\n  assert( !pWinMemData->bOwned );\n#endif\n  assert( pWinMemData->hHeap!=0 );\n  assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n  assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Deinitialize this module.\n*/\nstatic void winMemShutdown(void *pAppData){\n  winMemData *pWinMemData = (winMemData *)pAppData;\n\n  if( !pWinMemData ) return;\n  assert( pWinMemData->magic1==WINMEM_MAGIC1 );\n  assert( pWinMemData->magic2==WINMEM_MAGIC2 );\n\n  if( pWinMemData->hHeap ){\n    assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE );\n#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE)\n    assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) );\n#endif\n    if( pWinMemData->bOwned ){\n      if( !osHeapDestroy(pWinMemData->hHeap) ){\n        sqlite3_log(SQLITE_NOMEM, \"failed to HeapDestroy (%lu), heap=%p\",\n                    osGetLastError(), (void*)pWinMemData->hHeap);\n      }\n      pWinMemData->bOwned = FALSE;\n    }\n    pWinMemData->hHeap = NULL;\n  }\n}\n\n/*\n** Populate the low-level memory allocation function pointers in\n** sqlite3GlobalConfig.m with pointers to the routines in this file. The\n** arguments specify the block of memory to manage.\n**\n** This routine is only called by sqlite3_config(), and therefore\n** is not required to be threadsafe (it is not).\n*/\nconst sqlite3_mem_methods *sqlite3MemGetWin32(void){\n  static const sqlite3_mem_methods winMemMethods = {\n    winMemMalloc,\n    winMemFree,\n    winMemRealloc,\n    winMemSize,\n    winMemRoundup,\n    winMemInit,\n    winMemShutdown,\n    &win_mem_data\n  };\n  return &winMemMethods;\n}\n\nvoid sqlite3MemSetDefault(void){\n  sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetWin32());\n}\n#endif /* SQLITE_WIN32_MALLOC */\n\n/*\n** Convert a UTF-8 string to Microsoft Unicode.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winUtf8ToUnicode(const char *zText){\n  int nChar;\n  LPWSTR zWideText;\n\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, NULL, 0);\n  if( nChar==0 ){\n    return 0;\n  }\n  zWideText = sqlite3MallocZero( nChar*sizeof(WCHAR) );\n  if( zWideText==0 ){\n    return 0;\n  }\n  nChar = osMultiByteToWideChar(CP_UTF8, 0, zText, -1, zWideText,\n                                nChar);\n  if( nChar==0 ){\n    sqlite3_free(zWideText);\n    zWideText = 0;\n  }\n  return zWideText;\n}\n\n/*\n** Convert a Microsoft Unicode string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToUtf8(LPCWSTR zWideText){\n  int nByte;\n  char *zText;\n\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(CP_UTF8, 0, zWideText, -1, zText, nByte,\n                                0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert an ANSI string to Microsoft Unicode, using the ANSI or OEM\n** code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic LPWSTR winMbcsToUnicode(const char *zText, int useAnsi){\n  int nByte;\n  LPWSTR zMbcsText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, NULL,\n                                0)*sizeof(WCHAR);\n  if( nByte==0 ){\n    return 0;\n  }\n  zMbcsText = sqlite3MallocZero( nByte*sizeof(WCHAR) );\n  if( zMbcsText==0 ){\n    return 0;\n  }\n  nByte = osMultiByteToWideChar(codepage, 0, zText, -1, zMbcsText,\n                                nByte);\n  if( nByte==0 ){\n    sqlite3_free(zMbcsText);\n    zMbcsText = 0;\n  }\n  return zMbcsText;\n}\n\n/*\n** Convert a Microsoft Unicode string to a multi-byte character string,\n** using the ANSI or OEM code page.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUnicodeToMbcs(LPCWSTR zWideText, int useAnsi){\n  int nByte;\n  char *zText;\n  int codepage = useAnsi ? CP_ACP : CP_OEMCP;\n\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, 0, 0, 0, 0);\n  if( nByte == 0 ){\n    return 0;\n  }\n  zText = sqlite3MallocZero( nByte );\n  if( zText==0 ){\n    return 0;\n  }\n  nByte = osWideCharToMultiByte(codepage, 0, zWideText, -1, zText,\n                                nByte, 0, 0);\n  if( nByte == 0 ){\n    sqlite3_free(zText);\n    zText = 0;\n  }\n  return zText;\n}\n\n/*\n** Convert a multi-byte character string to UTF-8.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winMbcsToUtf8(const char *zText, int useAnsi){\n  char *zTextUtf8;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winMbcsToUnicode(zText, useAnsi);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextUtf8 = winUnicodeToUtf8(zTmpWide);\n  sqlite3_free(zTmpWide);\n  return zTextUtf8;\n}\n\n/*\n** Convert a UTF-8 string to a multi-byte character string.\n**\n** Space to hold the returned string is obtained from sqlite3_malloc().\n*/\nstatic char *winUtf8ToMbcs(const char *zText, int useAnsi){\n  char *zTextMbcs;\n  LPWSTR zTmpWide;\n\n  zTmpWide = winUtf8ToUnicode(zText);\n  if( zTmpWide==0 ){\n    return 0;\n  }\n  zTextMbcs = winUnicodeToMbcs(zTmpWide, useAnsi);\n  sqlite3_free(zTmpWide);\n  return zTextMbcs;\n}\n\n/*\n** This is a public wrapper for the winUtf8ToUnicode() function.\n*/\nLPWSTR sqlite3_win32_utf8_to_unicode(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToUnicode(zText);\n}\n\n/*\n** This is a public wrapper for the winUnicodeToUtf8() function.\n*/\nchar *sqlite3_win32_unicode_to_utf8(LPCWSTR zWideText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zWideText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUnicodeToUtf8(zWideText);\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nchar *sqlite3_win32_mbcs_to_utf8(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winMbcsToUtf8() function.\n*/\nchar *sqlite3_win32_mbcs_to_utf8_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winMbcsToUtf8(zText, useAnsi);\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nchar *sqlite3_win32_utf8_to_mbcs(const char *zText){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, osAreFileApisANSI());\n}\n\n/*\n** This is a public wrapper for the winUtf8ToMbcs() function.\n*/\nchar *sqlite3_win32_utf8_to_mbcs_v2(const char *zText, int useAnsi){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !zText ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  return winUtf8ToMbcs(zText, useAnsi);\n}\n\n/*\n** This function sets the data directory or the temporary directory based on\n** the provided arguments.  The type argument must be 1 in order to set the\n** data directory or 2 in order to set the temporary directory.  The zValue\n** argument is the name of the directory to use.  The return value will be\n** SQLITE_OK if successful.\n*/\nint sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){\n  char **ppDirectory = 0;\n#ifndef SQLITE_OMIT_AUTOINIT\n  int rc = sqlite3_initialize();\n  if( rc ) return rc;\n#endif\n  if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_data_directory;\n  }else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){\n    ppDirectory = &sqlite3_temp_directory;\n  }\n  assert( !ppDirectory || type==SQLITE_WIN32_DATA_DIRECTORY_TYPE\n          || type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE\n  );\n  assert( !ppDirectory || sqlite3MemdebugHasType(*ppDirectory, MEMTYPE_HEAP) );\n  if( ppDirectory ){\n    char *zValueUtf8 = 0;\n    if( zValue && zValue[0] ){\n      zValueUtf8 = winUnicodeToUtf8(zValue);\n      if ( zValueUtf8==0 ){\n        return SQLITE_NOMEM_BKPT;\n      }\n    }\n    sqlite3_free(*ppDirectory);\n    *ppDirectory = zValueUtf8;\n    return SQLITE_OK;\n  }\n  return SQLITE_ERROR;\n}\n\n/*\n** The return value of winGetLastErrorMsg\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated).\n*/\nstatic int winGetLastErrorMsg(DWORD lastErrno, int nBuf, char *zBuf){\n  /* FormatMessage returns 0 on failure.  Otherwise it\n  ** returns the number of TCHARs written to the output\n  ** buffer, excluding the terminating null char.\n  */\n  DWORD dwLen = 0;\n  char *zOut = 0;\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    WCHAR zTempWide[SQLITE_WIN32_MAX_ERRMSG_CHARS+1];\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             zTempWide,\n                             SQLITE_WIN32_MAX_ERRMSG_CHARS,\n                             0);\n#else\n    LPWSTR zTempWide = NULL;\n    dwLen = osFormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPWSTR) &zTempWide,\n                             0,\n                             0);\n#endif\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winUnicodeToUtf8(zTempWide);\n      sqlite3EndBenignMalloc();\n#if !SQLITE_OS_WINRT\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTempWide);\n#endif\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp = NULL;\n    dwLen = osFormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                             FORMAT_MESSAGE_FROM_SYSTEM |\n                             FORMAT_MESSAGE_IGNORE_INSERTS,\n                             NULL,\n                             lastErrno,\n                             0,\n                             (LPSTR) &zTemp,\n                             0,\n                             0);\n    if( dwLen > 0 ){\n      /* allocate a buffer and convert to UTF8 */\n      sqlite3BeginBenignMalloc();\n      zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n      sqlite3EndBenignMalloc();\n      /* free the system buffer allocated by FormatMessage */\n      osLocalFree(zTemp);\n    }\n  }\n#endif\n  if( 0 == dwLen ){\n    sqlite3_snprintf(nBuf, zBuf, \"OsError 0x%lx (%lu)\", lastErrno, lastErrno);\n  }else{\n    /* copy a maximum of nBuf chars to output buffer */\n    sqlite3_snprintf(nBuf, zBuf, \"%s\", zOut);\n    /* free the UTF8 buffer */\n    sqlite3_free(zOut);\n  }\n  return 0;\n}\n\n/*\n**\n** This function - winLogErrorAtLine() - is only ever called via the macro\n** winLogError().\n**\n** This routine is invoked after an error occurs in an OS function.\n** It logs a message using sqlite3_log() containing the current value of\n** error code and, if possible, the human-readable equivalent from\n** FormatMessage.\n**\n** The first argument passed to the macro should be the error code that\n** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).\n** The two subsequent arguments should be the name of the OS function that\n** failed and the associated file-system path, if any.\n*/\n#define winLogError(a,b,c,d)   winLogErrorAtLine(a,b,c,d,__LINE__)\nstatic int winLogErrorAtLine(\n  int errcode,                    /* SQLite error code */\n  DWORD lastErrno,                /* Win32 last error */\n  const char *zFunc,              /* Name of OS function that failed */\n  const char *zPath,              /* File path associated with error */\n  int iLine                       /* Source line number where error occurred */\n){\n  char zMsg[500];                 /* Human readable error text */\n  int i;                          /* Loop counter */\n\n  zMsg[0] = 0;\n  winGetLastErrorMsg(lastErrno, sizeof(zMsg), zMsg);\n  assert( errcode!=SQLITE_OK );\n  if( zPath==0 ) zPath = \"\";\n  for(i=0; zMsg[i] && zMsg[i]!='\\r' && zMsg[i]!='\\n'; i++){}\n  zMsg[i] = 0;\n  sqlite3_log(errcode,\n      \"os_win.c:%d: (%lu) %s(%s) - %s\",\n      iLine, lastErrno, zFunc, zPath, zMsg\n  );\n\n  return errcode;\n}\n\n/*\n** The number of times that a ReadFile(), WriteFile(), and DeleteFile()\n** will be retried following a locking error - probably caused by\n** antivirus software.  Also the initial delay before the first retry.\n** The delay increases linearly with each retry.\n*/\n#ifndef SQLITE_WIN32_IOERR_RETRY\n# define SQLITE_WIN32_IOERR_RETRY 10\n#endif\n#ifndef SQLITE_WIN32_IOERR_RETRY_DELAY\n# define SQLITE_WIN32_IOERR_RETRY_DELAY 25\n#endif\nstatic int winIoerrRetry = SQLITE_WIN32_IOERR_RETRY;\nstatic int winIoerrRetryDelay = SQLITE_WIN32_IOERR_RETRY_DELAY;\n\n/*\n** The \"winIoerrCanRetry1\" macro is used to determine if a particular I/O\n** error code obtained via GetLastError() is eligible to be retried.  It\n** must accept the error code DWORD as its only argument and should return\n** non-zero if the error code is transient in nature and the operation\n** responsible for generating the original error might succeed upon being\n** retried.  The argument to this macro should be a variable.\n**\n** Additionally, a macro named \"winIoerrCanRetry2\" may be defined.  If it\n** is defined, it will be consulted only when the macro \"winIoerrCanRetry1\"\n** returns zero.  The \"winIoerrCanRetry2\" macro is completely optional and\n** may be used to include additional error codes in the set that should\n** result in the failing I/O operation being retried by the caller.  If\n** defined, the \"winIoerrCanRetry2\" macro must exhibit external semantics\n** identical to those of the \"winIoerrCanRetry1\" macro.\n*/\n#if !defined(winIoerrCanRetry1)\n#define winIoerrCanRetry1(a) (((a)==ERROR_ACCESS_DENIED)        || \\\n                              ((a)==ERROR_SHARING_VIOLATION)    || \\\n                              ((a)==ERROR_LOCK_VIOLATION)       || \\\n                              ((a)==ERROR_DEV_NOT_EXIST)        || \\\n                              ((a)==ERROR_NETNAME_DELETED)      || \\\n                              ((a)==ERROR_SEM_TIMEOUT)          || \\\n                              ((a)==ERROR_NETWORK_UNREACHABLE))\n#endif\n\n/*\n** If a ReadFile() or WriteFile() error occurs, invoke this routine\n** to see if it should be retried.  Return TRUE to retry.  Return FALSE\n** to give up with an error.\n*/\nstatic int winRetryIoerr(int *pnRetry, DWORD *pError){\n  DWORD e = osGetLastError();\n  if( *pnRetry>=winIoerrRetry ){\n    if( pError ){\n      *pError = e;\n    }\n    return 0;\n  }\n  if( winIoerrCanRetry1(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#if defined(winIoerrCanRetry2)\n  else if( winIoerrCanRetry2(e) ){\n    sqlite3_win32_sleep(winIoerrRetryDelay*(1+*pnRetry));\n    ++*pnRetry;\n    return 1;\n  }\n#endif\n  if( pError ){\n    *pError = e;\n  }\n  return 0;\n}\n\n/*\n** Log a I/O error retry episode.\n*/\nstatic void winLogIoerr(int nRetry, int lineno){\n  if( nRetry ){\n    sqlite3_log(SQLITE_NOTICE,\n      \"delayed %dms for lock/sharing conflict at line %d\",\n      winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno\n    );\n  }\n}\n\n/*\n** This #if does not rely on the SQLITE_OS_WINCE define because the\n** corresponding section in \"date.c\" cannot use it.\n*/\n#if !defined(SQLITE_OMIT_LOCALTIME) && defined(_WIN32_WCE) && \\\n    (!defined(SQLITE_MSVC_LOCALTIME_API) || !SQLITE_MSVC_LOCALTIME_API)\n/*\n** The MSVC CRT on Windows CE may not have a localtime() function.\n** So define a substitute.\n*/\n#  include <time.h>\nstruct tm *__cdecl localtime(const time_t *t)\n{\n  static struct tm y;\n  FILETIME uTm, lTm;\n  SYSTEMTIME pTm;\n  sqlite3_int64 t64;\n  t64 = *t;\n  t64 = (t64 + 11644473600)*10000000;\n  uTm.dwLowDateTime = (DWORD)(t64 & 0xFFFFFFFF);\n  uTm.dwHighDateTime= (DWORD)(t64 >> 32);\n  osFileTimeToLocalFileTime(&uTm,&lTm);\n  osFileTimeToSystemTime(&lTm,&pTm);\n  y.tm_year = pTm.wYear - 1900;\n  y.tm_mon = pTm.wMonth - 1;\n  y.tm_wday = pTm.wDayOfWeek;\n  y.tm_mday = pTm.wDay;\n  y.tm_hour = pTm.wHour;\n  y.tm_min = pTm.wMinute;\n  y.tm_sec = pTm.wSecond;\n  return &y;\n}\n#endif\n\n#if SQLITE_OS_WINCE\n/*************************************************************************\n** This section contains code for WinCE only.\n*/\n#define HANDLE_TO_WINFILE(a) (winFile*)&((char*)a)[-(int)offsetof(winFile,h)]\n\n/*\n** Acquire a lock on the handle h\n*/\nstatic void winceMutexAcquire(HANDLE h){\n   DWORD dwErr;\n   do {\n     dwErr = osWaitForSingleObject(h, INFINITE);\n   } while (dwErr != WAIT_OBJECT_0 && dwErr != WAIT_ABANDONED);\n}\n/*\n** Release a lock acquired by winceMutexAcquire()\n*/\n#define winceMutexRelease(h) ReleaseMutex(h)\n\n/*\n** Create the mutex and shared memory used for locking in the file\n** descriptor pFile\n*/\nstatic int winceCreateLock(const char *zFilename, winFile *pFile){\n  LPWSTR zTok;\n  LPWSTR zName;\n  DWORD lastErrno;\n  BOOL bLogged = FALSE;\n  BOOL bInit = TRUE;\n\n  zName = winUtf8ToUnicode(zFilename);\n  if( zName==0 ){\n    /* out of memory */\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Initialize the local lockdata */\n  memset(&pFile->local, 0, sizeof(pFile->local));\n\n  /* Replace the backslashes from the filename and lowercase it\n  ** to derive a mutex name. */\n  zTok = osCharLowerW(zName);\n  for (;*zTok;zTok++){\n    if (*zTok == '\\\\') *zTok = '_';\n  }\n\n  /* Create/open the named mutex */\n  pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);\n  if (!pFile->hMutex){\n    pFile->lastErrno = osGetLastError();\n    sqlite3_free(zName);\n    return winLogError(SQLITE_IOERR, pFile->lastErrno,\n                       \"winceCreateLock1\", zFilename);\n  }\n\n  /* Acquire the mutex before continuing */\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Since the names of named mutexes, semaphores, file mappings etc are\n  ** case-sensitive, take advantage of that by uppercasing the mutex name\n  ** and using that as the shared filemapping name.\n  */\n  osCharUpperW(zName);\n  pFile->hShared = osCreateFileMappingW(INVALID_HANDLE_VALUE, NULL,\n                                        PAGE_READWRITE, 0, sizeof(winceLock),\n                                        zName);\n\n  /* Set a flag that indicates we're the first to create the memory so it\n  ** must be zero-initialized */\n  lastErrno = osGetLastError();\n  if (lastErrno == ERROR_ALREADY_EXISTS){\n    bInit = FALSE;\n  }\n\n  sqlite3_free(zName);\n\n  /* If we succeeded in making the shared memory handle, map it. */\n  if( pFile->hShared ){\n    pFile->shared = (winceLock*)osMapViewOfFile(pFile->hShared,\n             FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));\n    /* If mapping failed, close the shared memory handle and erase it */\n    if( !pFile->shared ){\n      pFile->lastErrno = osGetLastError();\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock2\", zFilename);\n      bLogged = TRUE;\n      osCloseHandle(pFile->hShared);\n      pFile->hShared = NULL;\n    }\n  }\n\n  /* If shared memory could not be created, then close the mutex and fail */\n  if( pFile->hShared==NULL ){\n    if( !bLogged ){\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_IOERR, pFile->lastErrno,\n                  \"winceCreateLock3\", zFilename);\n      bLogged = TRUE;\n    }\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n    return SQLITE_IOERR;\n  }\n\n  /* Initialize the shared memory if we're supposed to */\n  if( bInit ){\n    memset(pFile->shared, 0, sizeof(winceLock));\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return SQLITE_OK;\n}\n\n/*\n** Destroy the part of winFile that deals with wince locks\n*/\nstatic void winceDestroyLock(winFile *pFile){\n  if (pFile->hMutex){\n    /* Acquire the mutex */\n    winceMutexAcquire(pFile->hMutex);\n\n    /* The following blocks should probably assert in debug mode, but they\n       are to cleanup in case any locks remained open */\n    if (pFile->local.nReaders){\n      pFile->shared->nReaders --;\n    }\n    if (pFile->local.bReserved){\n      pFile->shared->bReserved = FALSE;\n    }\n    if (pFile->local.bPending){\n      pFile->shared->bPending = FALSE;\n    }\n    if (pFile->local.bExclusive){\n      pFile->shared->bExclusive = FALSE;\n    }\n\n    /* De-reference and close our copy of the shared memory handle */\n    osUnmapViewOfFile(pFile->shared);\n    osCloseHandle(pFile->hShared);\n\n    /* Done with the mutex */\n    winceMutexRelease(pFile->hMutex);\n    osCloseHandle(pFile->hMutex);\n    pFile->hMutex = NULL;\n  }\n}\n\n/*\n** An implementation of the LockFile() API of Windows for CE\n*/\nstatic BOOL winceLockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToLockLow,\n  DWORD nNumberOfBytesToLockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToLockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Wanting an exclusive lock? */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST\n       && nNumberOfBytesToLockLow == (DWORD)SHARED_SIZE){\n    if (pFile->shared->nReaders == 0 && pFile->shared->bExclusive == 0){\n       pFile->shared->bExclusive = TRUE;\n       pFile->local.bExclusive = TRUE;\n       bReturn = TRUE;\n    }\n  }\n\n  /* Want a read-only lock? */\n  else if (dwFileOffsetLow == (DWORD)SHARED_FIRST &&\n           nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bExclusive == 0){\n      pFile->local.nReaders ++;\n      if (pFile->local.nReaders == 1){\n        pFile->shared->nReaders ++;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a pending lock? */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    /* If no pending lock has been acquired, then acquire it */\n    if (pFile->shared->bPending == 0) {\n      pFile->shared->bPending = TRUE;\n      pFile->local.bPending = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  /* Want a reserved lock? */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToLockLow == 1){\n    if (pFile->shared->bReserved == 0) {\n      pFile->shared->bReserved = TRUE;\n      pFile->local.bReserved = TRUE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n\n/*\n** An implementation of the UnlockFile API of Windows for CE\n*/\nstatic BOOL winceUnlockFile(\n  LPHANDLE phFile,\n  DWORD dwFileOffsetLow,\n  DWORD dwFileOffsetHigh,\n  DWORD nNumberOfBytesToUnlockLow,\n  DWORD nNumberOfBytesToUnlockHigh\n){\n  winFile *pFile = HANDLE_TO_WINFILE(phFile);\n  BOOL bReturn = FALSE;\n\n  UNUSED_PARAMETER(dwFileOffsetHigh);\n  UNUSED_PARAMETER(nNumberOfBytesToUnlockHigh);\n\n  if (!pFile->hMutex) return TRUE;\n  winceMutexAcquire(pFile->hMutex);\n\n  /* Releasing a reader lock or an exclusive lock */\n  if (dwFileOffsetLow == (DWORD)SHARED_FIRST){\n    /* Did we have an exclusive lock? */\n    if (pFile->local.bExclusive){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE);\n      pFile->local.bExclusive = FALSE;\n      pFile->shared->bExclusive = FALSE;\n      bReturn = TRUE;\n    }\n\n    /* Did we just have a reader lock? */\n    else if (pFile->local.nReaders){\n      assert(nNumberOfBytesToUnlockLow == (DWORD)SHARED_SIZE\n             || nNumberOfBytesToUnlockLow == 1);\n      pFile->local.nReaders --;\n      if (pFile->local.nReaders == 0)\n      {\n        pFile->shared->nReaders --;\n      }\n      bReturn = TRUE;\n    }\n  }\n\n  /* Releasing a pending lock */\n  else if (dwFileOffsetLow == (DWORD)PENDING_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bPending){\n      pFile->local.bPending = FALSE;\n      pFile->shared->bPending = FALSE;\n      bReturn = TRUE;\n    }\n  }\n  /* Releasing a reserved lock */\n  else if (dwFileOffsetLow == (DWORD)RESERVED_BYTE\n           && nNumberOfBytesToUnlockLow == 1){\n    if (pFile->local.bReserved) {\n      pFile->local.bReserved = FALSE;\n      pFile->shared->bReserved = FALSE;\n      bReturn = TRUE;\n    }\n  }\n\n  winceMutexRelease(pFile->hMutex);\n  return bReturn;\n}\n/*\n** End of the special code for wince\n*****************************************************************************/\n#endif /* SQLITE_OS_WINCE */\n\n/*\n** Lock a file region.\n*/\nstatic BOOL winLockFile(\n  LPHANDLE phFile,\n  DWORD flags,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API LockFile.\n  */\n  return winceLockFile(phFile, offsetLow, offsetHigh,\n                       numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osLockFileEx(*phFile, flags, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osLockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                      numBytesHigh);\n  }\n#endif\n}\n\n/*\n** Unlock a file region.\n */\nstatic BOOL winUnlockFile(\n  LPHANDLE phFile,\n  DWORD offsetLow,\n  DWORD offsetHigh,\n  DWORD numBytesLow,\n  DWORD numBytesHigh\n){\n#if SQLITE_OS_WINCE\n  /*\n  ** NOTE: Windows CE is handled differently here due its lack of the Win32\n  **       API UnlockFile.\n  */\n  return winceUnlockFile(phFile, offsetLow, offsetHigh,\n                         numBytesLow, numBytesHigh);\n#else\n  if( osIsNT() ){\n    OVERLAPPED ovlp;\n    memset(&ovlp, 0, sizeof(OVERLAPPED));\n    ovlp.Offset = offsetLow;\n    ovlp.OffsetHigh = offsetHigh;\n    return osUnlockFileEx(*phFile, 0, numBytesLow, numBytesHigh, &ovlp);\n  }else{\n    return osUnlockFile(*phFile, offsetLow, offsetHigh, numBytesLow,\n                        numBytesHigh);\n  }\n#endif\n}\n\n/*****************************************************************************\n** The next group of routines implement the I/O methods specified\n** by the sqlite3_io_methods object.\n******************************************************************************/\n\n/*\n** Some Microsoft compilers lack this definition.\n*/\n#ifndef INVALID_SET_FILE_POINTER\n# define INVALID_SET_FILE_POINTER ((DWORD)-1)\n#endif\n\n/*\n** Move the current position of the file handle passed as the first\n** argument to offset iOffset within the file. If successful, return 0.\n** Otherwise, set pFile->lastErrno and return non-zero.\n*/\nstatic int winSeekFile(winFile *pFile, sqlite3_int64 iOffset){\n#if !SQLITE_OS_WINRT\n  LONG upperBits;                 /* Most sig. 32 bits of new offset */\n  LONG lowerBits;                 /* Least sig. 32 bits of new offset */\n  DWORD dwRet;                    /* Value returned by SetFilePointer() */\n  DWORD lastErrno;                /* Value returned by GetLastError() */\n\n  OSTRACE((\"SEEK file=%p, offset=%lld\\n\", pFile->h, iOffset));\n\n  upperBits = (LONG)((iOffset>>32) & 0x7fffffff);\n  lowerBits = (LONG)(iOffset & 0xffffffff);\n\n  /* API oddity: If successful, SetFilePointer() returns a dword\n  ** containing the lower 32-bits of the new file-offset. Or, if it fails,\n  ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,\n  ** INVALID_SET_FILE_POINTER may also be a valid new offset. So to determine\n  ** whether an error has actually occurred, it is also necessary to call\n  ** GetLastError().\n  */\n  dwRet = osSetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);\n\n  if( (dwRet==INVALID_SET_FILE_POINTER\n      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#else\n  /*\n  ** Same as above, except that this implementation works for WinRT.\n  */\n\n  LARGE_INTEGER x;                /* The new offset */\n  BOOL bRet;                      /* Value returned by SetFilePointerEx() */\n\n  x.QuadPart = iOffset;\n  bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);\n\n  if(!bRet){\n    pFile->lastErrno = osGetLastError();\n    winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,\n                \"winSeekFile\", pFile->zPath);\n    OSTRACE((\"SEEK file=%p, rc=SQLITE_IOERR_SEEK\\n\", pFile->h));\n    return 1;\n  }\n\n  OSTRACE((\"SEEK file=%p, rc=SQLITE_OK\\n\", pFile->h));\n  return 0;\n#endif\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* Forward references to VFS helper methods used for memory mapped files */\nstatic int winMapfile(winFile*, sqlite3_int64);\nstatic int winUnmapfile(winFile*);\n#endif\n\n/*\n** Close a file.\n**\n** It is reported that an attempt to close a handle might sometimes\n** fail.  This is a very unreasonable result, but Windows is notorious\n** for being unreasonable so I do not doubt that it might happen.  If\n** the close fails, we pause for 100 milliseconds and try again.  As\n** many as MX_CLOSE_ATTEMPT attempts to close the handle are made before\n** giving up and returning an error.\n*/\n#define MX_CLOSE_ATTEMPT 3\nstatic int winClose(sqlite3_file *id){\n  int rc, cnt = 0;\n  winFile *pFile = (winFile*)id;\n\n  assert( id!=0 );\n#ifndef SQLITE_OMIT_WAL\n  assert( pFile->pShm==0 );\n#endif\n  assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  winUnmapfile(pFile);\n#endif\n\n  do{\n    rc = osCloseHandle(pFile->h);\n    /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */\n  }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) );\n#if SQLITE_OS_WINCE\n#define WINCE_DELETION_ATTEMPTS 3\n  {\n    winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData;\n    if( pAppData==NULL || !pAppData->bNoLock ){\n      winceDestroyLock(pFile);\n    }\n  }\n  if( pFile->zDeleteOnClose ){\n    int cnt = 0;\n    while(\n           osDeleteFileW(pFile->zDeleteOnClose)==0\n        && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff\n        && cnt++ < WINCE_DELETION_ATTEMPTS\n    ){\n       sqlite3_win32_sleep(100);  /* Wait a little before trying again */\n    }\n    sqlite3_free(pFile->zDeleteOnClose);\n  }\n#endif\n  if( rc ){\n    pFile->h = NULL;\n  }\n  OpenCounter(-1);\n  OSTRACE((\"CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, rc ? \"ok\" : \"failed\"));\n  return rc ? SQLITE_OK\n            : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),\n                          \"winClose\", pFile->zPath);\n}\n\n/*\n** Read data from a file into a buffer.  Return SQLITE_OK if all\n** bytes were read successfully and SQLITE_IOERR if anything goes\n** wrong.\n*/\nstatic int winRead(\n  sqlite3_file *id,          /* File to read from */\n  void *pBuf,                /* Write content into this buffer */\n  int amt,                   /* Number of bytes to read */\n  sqlite3_int64 offset       /* Begin reading at this offset */\n){\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n  OVERLAPPED overlapped;          /* The offset for ReadFile. */\n#endif\n  winFile *pFile = (winFile*)id;  /* file handle */\n  DWORD nRead;                    /* Number of bytes actually read from file */\n  int nRetry = 0;                 /* Number of retrys */\n\n  assert( id!=0 );\n  assert( amt>0 );\n  assert( offset>=0 );\n  SimulateIOError(return SQLITE_IOERR_READ);\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this read request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);\n      OSTRACE((\"READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  if( winSeekFile(pFile, offset) ){\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_FULL;\n  }\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){\n#else\n  memset(&overlapped, 0, sizeof(OVERLAPPED));\n  overlapped.Offset = (LONG)(offset & 0xffffffff);\n  overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n  while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&\n         osGetLastError()!=ERROR_HANDLE_EOF ){\n#endif\n    DWORD lastErrno;\n    if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n    pFile->lastErrno = lastErrno;\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,\n                       \"winRead\", pFile->zPath);\n  }\n  winLogIoerr(nRetry, __LINE__);\n  if( nRead<(DWORD)amt ){\n    /* Unread parts of the buffer must be zero-filled */\n    memset(&((char*)pBuf)[nRead], 0, amt-nRead);\n    OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  OSTRACE((\"READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Write data from a buffer into a file.  Return SQLITE_OK on success\n** or some other error code on failure.\n*/\nstatic int winWrite(\n  sqlite3_file *id,               /* File to write into */\n  const void *pBuf,               /* The bytes to be written */\n  int amt,                        /* Number of bytes to write */\n  sqlite3_int64 offset            /* Offset into the file to begin writing at */\n){\n  int rc = 0;                     /* True if error has occurred, else false */\n  winFile *pFile = (winFile*)id;  /* File handle */\n  int nRetry = 0;                 /* Number of retries */\n\n  assert( amt>0 );\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_WRITE);\n  SimulateDiskfullError(return SQLITE_FULL);\n\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, \"\n           \"offset=%lld, lock=%d\\n\", osGetCurrentProcessId(), pFile,\n           pFile->h, pBuf, amt, offset, pFile->locktype));\n\n#if defined(SQLITE_MMAP_READWRITE) && SQLITE_MAX_MMAP_SIZE>0\n  /* Deal with as much of this write request as possible by transfering\n  ** data from the memory mapping using memcpy().  */\n  if( offset<pFile->mmapSize ){\n    if( offset+amt <= pFile->mmapSize ){\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);\n      OSTRACE((\"WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return SQLITE_OK;\n    }else{\n      int nCopy = (int)(pFile->mmapSize - offset);\n      memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);\n      pBuf = &((u8 *)pBuf)[nCopy];\n      amt -= nCopy;\n      offset += nCopy;\n    }\n  }\n#endif\n\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n  rc = winSeekFile(pFile, offset);\n  if( rc==0 ){\n#else\n  {\n#endif\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    OVERLAPPED overlapped;        /* The offset for WriteFile. */\n#endif\n    u8 *aRem = (u8 *)pBuf;        /* Data yet to be written */\n    int nRem = amt;               /* Number of bytes yet to be written */\n    DWORD nWrite;                 /* Bytes written by each WriteFile() call */\n    DWORD lastErrno = NO_ERROR;   /* Value returned by GetLastError() */\n\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n    memset(&overlapped, 0, sizeof(OVERLAPPED));\n    overlapped.Offset = (LONG)(offset & 0xffffffff);\n    overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n\n    while( nRem>0 ){\n#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){\n#else\n      if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){\n#endif\n        if( winRetryIoerr(&nRetry, &lastErrno) ) continue;\n        break;\n      }\n      assert( nWrite==0 || nWrite<=(DWORD)nRem );\n      if( nWrite==0 || nWrite>(DWORD)nRem ){\n        lastErrno = osGetLastError();\n        break;\n      }\n#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)\n      offset += nWrite;\n      overlapped.Offset = (LONG)(offset & 0xffffffff);\n      overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);\n#endif\n      aRem += nWrite;\n      nRem -= nWrite;\n    }\n    if( nRem>0 ){\n      pFile->lastErrno = lastErrno;\n      rc = 1;\n    }\n  }\n\n  if( rc ){\n    if(   ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )\n       || ( pFile->lastErrno==ERROR_DISK_FULL )){\n      OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\\n\",\n               osGetCurrentProcessId(), pFile, pFile->h));\n      return winLogError(SQLITE_FULL, pFile->lastErrno,\n                         \"winWrite1\", pFile->zPath);\n    }\n    OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,\n                       \"winWrite2\", pFile->zPath);\n  }else{\n    winLogIoerr(nRetry, __LINE__);\n  }\n  OSTRACE((\"WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n}\n\n/*\n** Truncate an open file to a specified size\n*/\nstatic int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){\n  winFile *pFile = (winFile*)id;  /* File handle object */\n  int rc = SQLITE_OK;             /* Return code for this function */\n  DWORD lastErrno;\n\n  assert( pFile );\n  SimulateIOError(return SQLITE_IOERR_TRUNCATE);\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));\n\n  /* If the user has configured a chunk-size for this file, truncate the\n  ** file so that it consists of an integer number of chunks (i.e. the\n  ** actual file size after the operation may be larger than the requested\n  ** size).\n  */\n  if( pFile->szChunk>0 ){\n    nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk;\n  }\n\n  /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */\n  if( winSeekFile(pFile, nByte) ){\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate1\", pFile->zPath);\n  }else if( 0==osSetEndOfFile(pFile->h) &&\n            ((lastErrno = osGetLastError())!=ERROR_USER_MAPPED_FILE) ){\n    pFile->lastErrno = lastErrno;\n    rc = winLogError(SQLITE_IOERR_TRUNCATE, pFile->lastErrno,\n                     \"winTruncate2\", pFile->zPath);\n  }\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  /* If the file was truncated to a size smaller than the currently\n  ** mapped region, reduce the effective mapping size as well. SQLite will\n  ** use read() and write() to access data beyond this point from now on.\n  */\n  if( pFile->pMapRegion && nByte<pFile->mmapSize ){\n    pFile->mmapSize = nByte;\n  }\n#endif\n\n  OSTRACE((\"TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n/*\n** Count the number of fullsyncs and normal syncs.  This is used to test\n** that syncs and fullsyncs are occuring at the right times.\n*/\nint sqlite3_sync_count = 0;\nint sqlite3_fullsync_count = 0;\n#endif\n\n/*\n** Make sure all writes to a particular file are committed to disk.\n*/\nstatic int winSync(sqlite3_file *id, int flags){\n#ifndef SQLITE_NO_SYNC\n  /*\n  ** Used only when SQLITE_NO_SYNC is not defined.\n   */\n  BOOL rc;\n#endif\n#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \\\n    defined(SQLITE_HAVE_OS_TRACE)\n  /*\n  ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or\n  ** OSTRACE() macros.\n   */\n  winFile *pFile = (winFile*)id;\n#else\n  UNUSED_PARAMETER(id);\n#endif\n\n  assert( pFile );\n  /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */\n  assert((flags&0x0F)==SQLITE_SYNC_NORMAL\n      || (flags&0x0F)==SQLITE_SYNC_FULL\n  );\n\n  /* Unix cannot, but some systems may return SQLITE_FULL from here. This\n  ** line is to test that doing so does not cause any problems.\n  */\n  SimulateDiskfullError( return SQLITE_FULL );\n\n  OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h, flags,\n           pFile->locktype));\n\n#ifndef SQLITE_TEST\n  UNUSED_PARAMETER(flags);\n#else\n  if( (flags&0x0F)==SQLITE_SYNC_FULL ){\n    sqlite3_fullsync_count++;\n  }\n  sqlite3_sync_count++;\n#endif\n\n  /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a\n  ** no-op\n  */\n#ifdef SQLITE_NO_SYNC\n  OSTRACE((\"SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile, pFile->h));\n  return SQLITE_OK;\n#else\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFile->pMapRegion ){\n    if( osFlushViewOfFile(pFile->pMapRegion, 0) ){\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_OK\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n    }else{\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(),\n               pFile, pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winSync1\", pFile->zPath);\n    }\n  }\n#endif\n  rc = osFlushFileBuffers(pFile->h);\n  SimulateIOError( rc=FALSE );\n  if( rc ){\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return SQLITE_OK;\n  }else{\n    pFile->lastErrno = osGetLastError();\n    OSTRACE((\"SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\\n\",\n             osGetCurrentProcessId(), pFile, pFile->h));\n    return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,\n                       \"winSync2\", pFile->zPath);\n  }\n#endif\n}\n\n/*\n** Determine the current size of a file in bytes\n*/\nstatic int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n\n  assert( id!=0 );\n  assert( pSize!=0 );\n  SimulateIOError(return SQLITE_IOERR_FSTAT);\n  OSTRACE((\"SIZE file=%p, pSize=%p\\n\", pFile->h, pSize));\n\n#if SQLITE_OS_WINRT\n  {\n    FILE_STANDARD_INFO info;\n    if( osGetFileInformationByHandleEx(pFile->h, FileStandardInfo,\n                                     &info, sizeof(info)) ){\n      *pSize = info.EndOfFile.QuadPart;\n    }else{\n      pFile->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#else\n  {\n    DWORD upperBits;\n    DWORD lowerBits;\n    DWORD lastErrno;\n\n    lowerBits = osGetFileSize(pFile->h, &upperBits);\n    *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;\n    if(   (lowerBits == INVALID_FILE_SIZE)\n       && ((lastErrno = osGetLastError())!=NO_ERROR) ){\n      pFile->lastErrno = lastErrno;\n      rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,\n                       \"winFileSize\", pFile->zPath);\n    }\n  }\n#endif\n  OSTRACE((\"SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\\n\",\n           pFile->h, pSize, *pSize, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems.\n*/\n#ifndef LOCKFILE_FAIL_IMMEDIATELY\n# define LOCKFILE_FAIL_IMMEDIATELY 1\n#endif\n\n#ifndef LOCKFILE_EXCLUSIVE_LOCK\n# define LOCKFILE_EXCLUSIVE_LOCK 2\n#endif\n\n/*\n** Historically, SQLite has used both the LockFile and LockFileEx functions.\n** When the LockFile function was used, it was always expected to fail\n** immediately if the lock could not be obtained.  Also, it always expected to\n** obtain an exclusive lock.  These flags are used with the LockFileEx function\n** and reflect those expectations; therefore, they should not be changed.\n*/\n#ifndef SQLITE_LOCKFILE_FLAGS\n# define SQLITE_LOCKFILE_FLAGS   (LOCKFILE_FAIL_IMMEDIATELY | \\\n                                  LOCKFILE_EXCLUSIVE_LOCK)\n#endif\n\n/*\n** Currently, SQLite never calls the LockFileEx function without wanting the\n** call to fail immediately if the lock cannot be obtained.\n*/\n#ifndef SQLITE_LOCKFILEEX_FLAGS\n# define SQLITE_LOCKFILEEX_FLAGS (LOCKFILE_FAIL_IMMEDIATELY)\n#endif\n\n/*\n** Acquire a reader lock.\n** Different API routines are called depending on whether or not this\n** is Win9x or WinNT.\n*/\nstatic int winGetReadLock(winFile *pFile){\n  int res;\n  OSTRACE((\"READ-LOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n#if SQLITE_OS_WINCE\n    /*\n    ** NOTE: Windows CE is handled differently here due its lack of the Win32\n    **       API LockFileEx.\n    */\n    res = winceLockFile(&pFile->h, SHARED_FIRST, 0, 1, 0);\n#else\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    int lk;\n    sqlite3_randomness(sizeof(lk), &lk);\n    pFile->sharedLockByte = (short)((lk & 0x7fffffff)%(SHARED_SIZE - 1));\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                      SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res == 0 ){\n    pFile->lastErrno = osGetLastError();\n    /* No need to log a failure to lock */\n  }\n  OSTRACE((\"READ-LOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Undo a readlock\n*/\nstatic int winUnlockReadLock(winFile *pFile){\n  int res;\n  DWORD lastErrno;\n  OSTRACE((\"READ-UNLOCK file=%p, lock=%d\\n\", pFile->h, pFile->locktype));\n  if( osIsNT() ){\n    res = winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    res = winUnlockFile(&pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);\n  }\n#endif\n  if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){\n    pFile->lastErrno = lastErrno;\n    winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,\n                \"winUnlockReadLock\", pFile->zPath);\n  }\n  OSTRACE((\"READ-UNLOCK file=%p, result=%d\\n\", pFile->h, res));\n  return res;\n}\n\n/*\n** Lock the file with the lock specified by parameter locktype - one\n** of the following:\n**\n**     (1) SHARED_LOCK\n**     (2) RESERVED_LOCK\n**     (3) PENDING_LOCK\n**     (4) EXCLUSIVE_LOCK\n**\n** Sometimes when requesting one lock state, additional lock states\n** are inserted in between.  The locking might fail on one of the later\n** transitions leaving the lock state different from what it started but\n** still short of its goal.  The following chart shows the allowed\n** transitions and the inserted intermediate states:\n**\n**    UNLOCKED -> SHARED\n**    SHARED -> RESERVED\n**    SHARED -> (PENDING) -> EXCLUSIVE\n**    RESERVED -> (PENDING) -> EXCLUSIVE\n**    PENDING -> EXCLUSIVE\n**\n** This routine will only increase a lock.  The winUnlock() routine\n** erases all locks at once and returns us immediately to locking level 0.\n** It is not possible to lower the locking level one step at a time.  You\n** must go straight to locking level 0.\n*/\nstatic int winLock(sqlite3_file *id, int locktype){\n  int rc = SQLITE_OK;    /* Return code from subroutines */\n  int res = 1;           /* Result of a Windows lock call */\n  int newLocktype;       /* Set pFile->locktype to this value before exiting */\n  int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */\n  winFile *pFile = (winFile*)id;\n  DWORD lastErrno = NO_ERROR;\n\n  assert( id!=0 );\n  OSTRACE((\"LOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n\n  /* If there is already a lock of this type or more restrictive on the\n  ** OsFile, do nothing. Don't use the end_lock: exit path, as\n  ** sqlite3OsEnterMutex() hasn't been called yet.\n  */\n  if( pFile->locktype>=locktype ){\n    OSTRACE((\"LOCK-HELD file=%p, rc=SQLITE_OK\\n\", pFile->h));\n    return SQLITE_OK;\n  }\n\n  /* Do not allow any kind of write-lock on a read-only database\n  */\n  if( (pFile->ctrlFlags & WINFILE_RDONLY)!=0 && locktype>=RESERVED_LOCK ){\n    return SQLITE_IOERR_LOCK;\n  }\n\n  /* Make sure the locking sequence is correct\n  */\n  assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK );\n  assert( locktype!=PENDING_LOCK );\n  assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK );\n\n  /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or\n  ** a SHARED lock.  If we are acquiring a SHARED lock, the acquisition of\n  ** the PENDING_LOCK byte is temporary.\n  */\n  newLocktype = pFile->locktype;\n  if( pFile->locktype==NO_LOCK\n   || (locktype==EXCLUSIVE_LOCK && pFile->locktype<=RESERVED_LOCK)\n  ){\n    int cnt = 3;\n    while( cnt-->0 && (res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS,\n                                         PENDING_BYTE, 0, 1, 0))==0 ){\n      /* Try 3 times to get the pending lock.  This is needed to work\n      ** around problems caused by indexing and/or anti-virus software on\n      ** Windows systems.\n      ** If you are using this code as a model for alternative VFSes, do not\n      ** copy this retry logic.  It is a hack intended for Windows only.\n      */\n      lastErrno = osGetLastError();\n      OSTRACE((\"LOCK-PENDING-FAIL file=%p, count=%d, result=%d\\n\",\n               pFile->h, cnt, res));\n      if( lastErrno==ERROR_INVALID_HANDLE ){\n        pFile->lastErrno = lastErrno;\n        rc = SQLITE_IOERR_LOCK;\n        OSTRACE((\"LOCK-FAIL file=%p, count=%d, rc=%s\\n\",\n                 pFile->h, cnt, sqlite3ErrName(rc)));\n        return rc;\n      }\n      if( cnt ) sqlite3_win32_sleep(1);\n    }\n    gotPendingLock = res;\n    if( !res ){\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a shared lock\n  */\n  if( locktype==SHARED_LOCK && res ){\n    assert( pFile->locktype==NO_LOCK );\n    res = winGetReadLock(pFile);\n    if( res ){\n      newLocktype = SHARED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a RESERVED lock\n  */\n  if( locktype==RESERVED_LOCK && res ){\n    assert( pFile->locktype==SHARED_LOCK );\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, RESERVED_BYTE, 0, 1, 0);\n    if( res ){\n      newLocktype = RESERVED_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n    }\n  }\n\n  /* Acquire a PENDING lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    newLocktype = PENDING_LOCK;\n    gotPendingLock = 0;\n  }\n\n  /* Acquire an EXCLUSIVE lock\n  */\n  if( locktype==EXCLUSIVE_LOCK && res ){\n    assert( pFile->locktype>=SHARED_LOCK );\n    res = winUnlockReadLock(pFile);\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILE_FLAGS, SHARED_FIRST, 0,\n                      SHARED_SIZE, 0);\n    if( res ){\n      newLocktype = EXCLUSIVE_LOCK;\n    }else{\n      lastErrno = osGetLastError();\n      winGetReadLock(pFile);\n    }\n  }\n\n  /* If we are holding a PENDING lock that ought to be released, then\n  ** release it now.\n  */\n  if( gotPendingLock && locktype==SHARED_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n\n  /* Update the state of the lock has held in the file descriptor then\n  ** return the appropriate result code.\n  */\n  if( res ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno = lastErrno;\n    rc = SQLITE_BUSY;\n    OSTRACE((\"LOCK-FAIL file=%p, wanted=%d, got=%d\\n\",\n             pFile->h, locktype, newLocktype));\n  }\n  pFile->locktype = (u8)newLocktype;\n  OSTRACE((\"LOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** This routine checks if there is a RESERVED lock held on the specified\n** file by this or any other process. If such a lock is held, return\n** non-zero, otherwise zero.\n*/\nstatic int winCheckReservedLock(sqlite3_file *id, int *pResOut){\n  int res;\n  winFile *pFile = (winFile*)id;\n\n  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p\\n\", pFile->h, pResOut));\n\n  assert( id!=0 );\n  if( pFile->locktype>=RESERVED_LOCK ){\n    res = 1;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (local)\\n\", pFile->h, res));\n  }else{\n    res = winLockFile(&pFile->h, SQLITE_LOCKFILEEX_FLAGS,RESERVED_BYTE,0,1,0);\n    if( res ){\n      winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n    }\n    res = !res;\n    OSTRACE((\"TEST-WR-LOCK file=%p, result=%d (remote)\\n\", pFile->h, res));\n  }\n  *pResOut = res;\n  OSTRACE((\"TEST-WR-LOCK file=%p, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           pFile->h, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Lower the locking level on file descriptor id to locktype.  locktype\n** must be either NO_LOCK or SHARED_LOCK.\n**\n** If the locking level of the file descriptor is already at or below\n** the requested locking level, this routine is a no-op.\n**\n** It is not possible for this routine to fail if the second argument\n** is NO_LOCK.  If the second argument is SHARED_LOCK then this routine\n** might return SQLITE_IOERR;\n*/\nstatic int winUnlock(sqlite3_file *id, int locktype){\n  int type;\n  winFile *pFile = (winFile*)id;\n  int rc = SQLITE_OK;\n  assert( pFile!=0 );\n  assert( locktype<=SHARED_LOCK );\n  OSTRACE((\"UNLOCK file=%p, oldLock=%d(%d), newLock=%d\\n\",\n           pFile->h, pFile->locktype, pFile->sharedLockByte, locktype));\n  type = pFile->locktype;\n  if( type>=EXCLUSIVE_LOCK ){\n    winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);\n    if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){\n      /* This should never happen.  We should always be able to\n      ** reacquire the read lock */\n      rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),\n                       \"winUnlock\", pFile->zPath);\n    }\n  }\n  if( type>=RESERVED_LOCK ){\n    winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);\n  }\n  if( locktype==NO_LOCK && type>=SHARED_LOCK ){\n    winUnlockReadLock(pFile);\n  }\n  if( type>=PENDING_LOCK ){\n    winUnlockFile(&pFile->h, PENDING_BYTE, 0, 1, 0);\n  }\n  pFile->locktype = (u8)locktype;\n  OSTRACE((\"UNLOCK file=%p, lock=%d, rc=%s\\n\",\n           pFile->h, pFile->locktype, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/******************************************************************************\n****************************** No-op Locking **********************************\n**\n** Of the various locking implementations available, this is by far the\n** simplest:  locking is ignored.  No attempt is made to lock the database\n** file for reading or writing.\n**\n** This locking mode is appropriate for use on read-only databases\n** (ex: databases that are burned into CD-ROM, for example.)  It can\n** also be used if the application employs some external mechanism to\n** prevent simultaneous access of the same database by two or more\n** database connections.  But there is a serious risk of database\n** corruption if this locking mode is used in situations where multiple\n** database connections are accessing the same database file at the same\n** time and one or more of those connections are writing.\n*/\n\nstatic int winNolockLock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\nstatic int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(pResOut);\n  return SQLITE_OK;\n}\n\nstatic int winNolockUnlock(sqlite3_file *id, int locktype){\n  UNUSED_PARAMETER(id);\n  UNUSED_PARAMETER(locktype);\n  return SQLITE_OK;\n}\n\n/******************* End of the no-op lock implementation *********************\n******************************************************************************/\n\n/*\n** If *pArg is initially negative then this is a query.  Set *pArg to\n** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.\n**\n** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.\n*/\nstatic void winModeBit(winFile *pFile, unsigned char mask, int *pArg){\n  if( *pArg<0 ){\n    *pArg = (pFile->ctrlFlags & mask)!=0;\n  }else if( (*pArg)==0 ){\n    pFile->ctrlFlags &= ~mask;\n  }else{\n    pFile->ctrlFlags |= mask;\n  }\n}\n\n/* Forward references to VFS helper methods used for temporary files */\nstatic int winGetTempname(sqlite3_vfs *, char **);\nstatic int winIsDir(const void *);\nstatic BOOL winIsDriveLetterAndColon(const char *);\n\n/*\n** Control and query of the open file handle.\n*/\nstatic int winFileControl(sqlite3_file *id, int op, void *pArg){\n  winFile *pFile = (winFile*)id;\n  OSTRACE((\"FCNTL file=%p, op=%d, pArg=%p\\n\", pFile->h, op, pArg));\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE: {\n      *(int*)pArg = pFile->locktype;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_LAST_ERRNO: {\n      *(int*)pArg = (int)pFile->lastErrno;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      pFile->szChunk = *(int *)pArg;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_SIZE_HINT: {\n      if( pFile->szChunk>0 ){\n        sqlite3_int64 oldSz;\n        int rc = winFileSize(id, &oldSz);\n        if( rc==SQLITE_OK ){\n          sqlite3_int64 newSz = *(sqlite3_int64*)pArg;\n          if( newSz>oldSz ){\n            SimulateIOErrorBenign(1);\n            rc = winTruncate(id, newSz);\n            SimulateIOErrorBenign(0);\n          }\n        }\n        OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n        return rc;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_PERSIST_WAL: {\n      winModeBit(pFile, WINFILE_PERSIST_WAL, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {\n      winModeBit(pFile, WINFILE_PSOW, (int*)pArg);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_VFSNAME: {\n      *(char**)pArg = sqlite3_mprintf(\"%s\", pFile->pVfs->zName);\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_AV_RETRY: {\n      int *a = (int*)pArg;\n      if( a[0]>0 ){\n        winIoerrRetry = a[0];\n      }else{\n        a[0] = winIoerrRetry;\n      }\n      if( a[1]>0 ){\n        winIoerrRetryDelay = a[1];\n      }else{\n        a[1] = winIoerrRetryDelay;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n    case SQLITE_FCNTL_WIN32_GET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      *phFile = pFile->h;\n      OSTRACE((\"FCNTL file=%p, rc=SQLITE_OK\\n\", pFile->h));\n      return SQLITE_OK;\n    }\n#ifdef SQLITE_TEST\n    case SQLITE_FCNTL_WIN32_SET_HANDLE: {\n      LPHANDLE phFile = (LPHANDLE)pArg;\n      HANDLE hOldFile = pFile->h;\n      pFile->h = *phFile;\n      *phFile = hOldFile;\n      OSTRACE((\"FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\\n\",\n               hOldFile, pFile->h));\n      return SQLITE_OK;\n    }\n#endif\n    case SQLITE_FCNTL_TEMPFILENAME: {\n      char *zTFile = 0;\n      int rc = winGetTempname(pFile->pVfs, &zTFile);\n      if( rc==SQLITE_OK ){\n        *(char**)pArg = zTFile;\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#if SQLITE_MAX_MMAP_SIZE>0\n    case SQLITE_FCNTL_MMAP_SIZE: {\n      i64 newLimit = *(i64*)pArg;\n      int rc = SQLITE_OK;\n      if( newLimit>sqlite3GlobalConfig.mxMmap ){\n        newLimit = sqlite3GlobalConfig.mxMmap;\n      }\n\n      /* The value of newLimit may be eventually cast to (SIZE_T) and passed\n      ** to MapViewOfFile(). Restrict its value to 2GB if (SIZE_T) is not at\n      ** least a 64-bit type. */\n      if( newLimit>0 && sizeof(SIZE_T)<8 ){\n        newLimit = (newLimit & 0x7FFFFFFF);\n      }\n\n      *(i64*)pArg = pFile->mmapSizeMax;\n      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){\n        pFile->mmapSizeMax = newLimit;\n        if( pFile->mmapSize>0 ){\n          winUnmapfile(pFile);\n          rc = winMapfile(pFile, -1);\n        }\n      }\n      OSTRACE((\"FCNTL file=%p, rc=%s\\n\", pFile->h, sqlite3ErrName(rc)));\n      return rc;\n    }\n#endif\n  }\n  OSTRACE((\"FCNTL file=%p, rc=SQLITE_NOTFOUND\\n\", pFile->h));\n  return SQLITE_NOTFOUND;\n}\n\n/*\n** Return the sector size in bytes of the underlying block device for\n** the specified file. This is almost always 512 bytes, but may be\n** larger for some devices.\n**\n** SQLite code assumes this function cannot fail. It also assumes that\n** if two files are created in the same file-system directory (i.e.\n** a database and its journal file) that the sector size will be the\n** same for both.\n*/\nstatic int winSectorSize(sqlite3_file *id){\n  (void)id;\n  return SQLITE_DEFAULT_SECTOR_SIZE;\n}\n\n/*\n** Return a vector of device characteristics.\n*/\nstatic int winDeviceCharacteristics(sqlite3_file *id){\n  winFile *p = (winFile*)id;\n  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n         ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);\n}\n\n/*\n** Windows will only let you create file view mappings\n** on allocation size granularity boundaries.\n** During sqlite3_os_init() we do a GetSystemInfo()\n** to get the granularity size.\n*/\nstatic SYSTEM_INFO winSysInfo;\n\n#ifndef SQLITE_OMIT_WAL\n\n/*\n** Helper functions to obtain and relinquish the global mutex. The\n** global mutex is used to protect the winLockInfo objects used by\n** this file, all of which may be shared by multiple threads.\n**\n** Function winShmMutexHeld() is used to assert() that the global mutex\n** is held when required. This function is only used as part of assert()\n** statements. e.g.\n**\n**   winShmEnterMutex()\n**     assert( winShmMutexHeld() );\n**   winShmLeaveMutex()\n*/\nstatic void winShmEnterMutex(void){\n  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\nstatic void winShmLeaveMutex(void){\n  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#ifndef NDEBUG\nstatic int winShmMutexHeld(void) {\n  return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_VFS1));\n}\n#endif\n\n/*\n** Object used to represent a single file opened and mmapped to provide\n** shared memory.  When multiple threads all reference the same\n** log-summary, each thread has its own winFile object, but they all\n** point to a single instance of this object.  In other words, each\n** log-summary is opened only once per process.\n**\n** winShmMutexHeld() must be true when creating or destroying\n** this object or while reading or writing the following fields:\n**\n**      nRef\n**      pNext\n**\n** The following fields are read-only after the object is created:\n**\n**      fid\n**      zFilename\n**\n** Either winShmNode.mutex must be held or winShmNode.nRef==0 and\n** winShmMutexHeld() is true when reading or writing any other field\n** in this structure.\n**\n*/\nstruct winShmNode {\n  sqlite3_mutex *mutex;      /* Mutex to access this object */\n  char *zFilename;           /* Name of the file */\n  winFile hFile;             /* File handle from winOpen */\n\n  int szRegion;              /* Size of shared-memory regions */\n  int nRegion;               /* Size of array apRegion */\n  struct ShmRegion {\n    HANDLE hMap;             /* File handle from CreateFileMapping */\n    void *pMap;\n  } *aRegion;\n  DWORD lastErrno;           /* The Windows errno from the last I/O error */\n\n  int nRef;                  /* Number of winShm objects pointing to this */\n  winShm *pFirst;            /* All winShm objects pointing to this */\n  winShmNode *pNext;         /* Next in list of all winShmNode objects */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 nextShmId;              /* Next available winShm.id value */\n#endif\n};\n\n/*\n** A global array of all winShmNode objects.\n**\n** The winShmMutexHeld() must be true while reading or writing this list.\n*/\nstatic winShmNode *winShmNodeList = 0;\n\n/*\n** Structure used internally by this VFS to record the state of an\n** open shared memory connection.\n**\n** The following fields are initialized when this object is created and\n** are read-only thereafter:\n**\n**    winShm.pShmNode\n**    winShm.id\n**\n** All other fields are read/write.  The winShm.pShmNode->mutex must be held\n** while accessing any read/write fields.\n*/\nstruct winShm {\n  winShmNode *pShmNode;      /* The underlying winShmNode object */\n  winShm *pNext;             /* Next winShm with the same winShmNode */\n  u8 hasMutex;               /* True if holding the winShmNode mutex */\n  u16 sharedMask;            /* Mask of shared locks held */\n  u16 exclMask;              /* Mask of exclusive locks held */\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  u8 id;                     /* Id of this connection with its winShmNode */\n#endif\n};\n\n/*\n** Constants used for locking\n*/\n#define WIN_SHM_BASE   ((22+SQLITE_SHM_NLOCK)*4)        /* first lock byte */\n#define WIN_SHM_DMS    (WIN_SHM_BASE+SQLITE_SHM_NLOCK)  /* deadman switch */\n\n/*\n** Apply advisory locks for all n bytes beginning at ofst.\n*/\n#define WINSHM_UNLCK  1\n#define WINSHM_RDLCK  2\n#define WINSHM_WRLCK  3\nstatic int winShmSystemLock(\n  winShmNode *pFile,    /* Apply locks to this open shared-memory segment */\n  int lockType,         /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */\n  int ofst,             /* Offset to first byte to be locked/unlocked */\n  int nByte             /* Number of bytes to lock or unlock */\n){\n  int rc = 0;           /* Result code form Lock/UnlockFileEx() */\n\n  /* Access to the winShmNode object is serialized by the caller */\n  assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );\n\n  OSTRACE((\"SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\\n\",\n           pFile->hFile.h, lockType, ofst, nByte));\n\n  /* Release/Acquire the system-level lock */\n  if( lockType==WINSHM_UNLCK ){\n    rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0);\n  }else{\n    /* Initialize the locking parameters */\n    DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY;\n    if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK;\n    rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0);\n  }\n\n  if( rc!= 0 ){\n    rc = SQLITE_OK;\n  }else{\n    pFile->lastErrno =  osGetLastError();\n    rc = SQLITE_BUSY;\n  }\n\n  OSTRACE((\"SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\\n\",\n           pFile->hFile.h, (lockType == WINSHM_UNLCK) ? \"winUnlockFile\" :\n           \"winLockFile\", pFile->lastErrno, sqlite3ErrName(rc)));\n\n  return rc;\n}\n\n/* Forward references to VFS methods */\nstatic int winOpen(sqlite3_vfs*,const char*,sqlite3_file*,int,int*);\nstatic int winDelete(sqlite3_vfs *,const char*,int);\n\n/*\n** Purge the winShmNodeList list of all entries with winShmNode.nRef==0.\n**\n** This is not a VFS shared-memory method; it is a utility function called\n** by VFS shared-memory methods.\n*/\nstatic void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){\n  winShmNode **pp;\n  winShmNode *p;\n  assert( winShmMutexHeld() );\n  OSTRACE((\"SHM-PURGE pid=%lu, deleteFlag=%d\\n\",\n           osGetCurrentProcessId(), deleteFlag));\n  pp = &winShmNodeList;\n  while( (p = *pp)!=0 ){\n    if( p->nRef==0 ){\n      int i;\n      if( p->mutex ){ sqlite3_mutex_free(p->mutex); }\n      for(i=0; i<p->nRegion; i++){\n        BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);\n        OSTRACE((\"SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n        bRc = osCloseHandle(p->aRegion[i].hMap);\n        OSTRACE((\"SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), i, bRc ? \"ok\" : \"failed\"));\n        UNUSED_VARIABLE_VALUE(bRc);\n      }\n      if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){\n        SimulateIOErrorBenign(1);\n        winClose((sqlite3_file *)&p->hFile);\n        SimulateIOErrorBenign(0);\n      }\n      if( deleteFlag ){\n        SimulateIOErrorBenign(1);\n        sqlite3BeginBenignMalloc();\n        winDelete(pVfs, p->zFilename, 0);\n        sqlite3EndBenignMalloc();\n        SimulateIOErrorBenign(0);\n      }\n      *pp = p->pNext;\n      sqlite3_free(p->aRegion);\n      sqlite3_free(p);\n    }else{\n      pp = &p->pNext;\n    }\n  }\n}\n\n/*\n** Open the shared-memory area associated with database file pDbFd.\n**\n** When opening a new shared-memory file, if no other instances of that\n** file are currently open, in this process or in other processes, then\n** the file must be truncated to zero length or have its header cleared.\n*/\nstatic int winOpenSharedMemory(winFile *pDbFd){\n  struct winShm *p;                  /* The connection to be opened */\n  struct winShmNode *pShmNode = 0;   /* The underlying mmapped file */\n  int rc;                            /* Result code */\n  struct winShmNode *pNew;           /* Newly allocated winShmNode */\n  int nName;                         /* Size of zName in bytes */\n\n  assert( pDbFd->pShm==0 );    /* Not previously opened */\n\n  /* Allocate space for the new sqlite3_shm object.  Also speculatively\n  ** allocate space for a new winShmNode and filename.\n  */\n  p = sqlite3MallocZero( sizeof(*p) );\n  if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;\n  nName = sqlite3Strlen30(pDbFd->zPath);\n  pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );\n  if( pNew==0 ){\n    sqlite3_free(p);\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  pNew->zFilename = (char*)&pNew[1];\n  sqlite3_snprintf(nName+15, pNew->zFilename, \"%s-shm\", pDbFd->zPath);\n  sqlite3FileSuffix3(pDbFd->zPath, pNew->zFilename);\n\n  /* Look to see if there is an existing winShmNode that can be used.\n  ** If no matching winShmNode currently exists, create a new one.\n  */\n  winShmEnterMutex();\n  for(pShmNode = winShmNodeList; pShmNode; pShmNode=pShmNode->pNext){\n    /* TBD need to come up with better match here.  Perhaps\n    ** use FILE_ID_BOTH_DIR_INFO Structure.\n    */\n    if( sqlite3StrICmp(pShmNode->zFilename, pNew->zFilename)==0 ) break;\n  }\n  if( pShmNode ){\n    sqlite3_free(pNew);\n  }else{\n    pShmNode = pNew;\n    pNew = 0;\n    ((winFile*)(&pShmNode->hFile))->h = INVALID_HANDLE_VALUE;\n    pShmNode->pNext = winShmNodeList;\n    winShmNodeList = pShmNode;\n\n    if( sqlite3GlobalConfig.bCoreMutex ){\n      pShmNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n      if( pShmNode->mutex==0 ){\n        rc = SQLITE_IOERR_NOMEM_BKPT;\n        goto shm_open_err;\n      }\n    }\n\n    rc = winOpen(pDbFd->pVfs,\n                 pShmNode->zFilename,             /* Name of the file (UTF-8) */\n                 (sqlite3_file*)&pShmNode->hFile,  /* File handle here */\n                 SQLITE_OPEN_WAL | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,\n                 0);\n    if( SQLITE_OK!=rc ){\n      goto shm_open_err;\n    }\n\n    /* Check to see if another process is holding the dead-man switch.\n    ** If not, truncate the file to zero length.\n    */\n    if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),\n                         \"winOpenShm\", pDbFd->zPath);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n      rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1);\n    }\n    if( rc ) goto shm_open_err;\n  }\n\n  /* Make the new connection a child of the winShmNode */\n  p->pShmNode = pShmNode;\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  p->id = pShmNode->nextShmId++;\n#endif\n  pShmNode->nRef++;\n  pDbFd->pShm = p;\n  winShmLeaveMutex();\n\n  /* The reference count on pShmNode has already been incremented under\n  ** the cover of the winShmEnterMutex() mutex and the pointer from the\n  ** new (struct winShm) object to the pShmNode has been set. All that is\n  ** left to do is to link the new object into the linked list starting\n  ** at pShmNode->pFirst. This must be done while holding the pShmNode->mutex\n  ** mutex.\n  */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  p->pNext = pShmNode->pFirst;\n  pShmNode->pFirst = p;\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return SQLITE_OK;\n\n  /* Jump here on any error */\nshm_open_err:\n  winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1);\n  winShmPurge(pDbFd->pVfs, 0);      /* This call frees pShmNode if required */\n  sqlite3_free(p);\n  sqlite3_free(pNew);\n  winShmLeaveMutex();\n  return rc;\n}\n\n/*\n** Close a connection to shared-memory.  Delete the underlying\n** storage if deleteFlag is true.\n*/\nstatic int winShmUnmap(\n  sqlite3_file *fd,          /* Database holding shared memory */\n  int deleteFlag             /* Delete after closing if true */\n){\n  winFile *pDbFd;       /* Database holding shared-memory */\n  winShm *p;            /* The connection to be closed */\n  winShmNode *pShmNode; /* The underlying shared-memory file */\n  winShm **pp;          /* For looping over sibling connections */\n\n  pDbFd = (winFile*)fd;\n  p = pDbFd->pShm;\n  if( p==0 ) return SQLITE_OK;\n  pShmNode = p->pShmNode;\n\n  /* Remove connection p from the set of connections associated\n  ** with pShmNode */\n  sqlite3_mutex_enter(pShmNode->mutex);\n  for(pp=&pShmNode->pFirst; (*pp)!=p; pp = &(*pp)->pNext){}\n  *pp = p->pNext;\n\n  /* Free the connection p */\n  sqlite3_free(p);\n  pDbFd->pShm = 0;\n  sqlite3_mutex_leave(pShmNode->mutex);\n\n  /* If pShmNode->nRef has reached 0, then close the underlying\n  ** shared-memory file, too */\n  winShmEnterMutex();\n  assert( pShmNode->nRef>0 );\n  pShmNode->nRef--;\n  if( pShmNode->nRef==0 ){\n    winShmPurge(pDbFd->pVfs, deleteFlag);\n  }\n  winShmLeaveMutex();\n\n  return SQLITE_OK;\n}\n\n/*\n** Change the lock state for a shared-memory segment.\n*/\nstatic int winShmLock(\n  sqlite3_file *fd,          /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  winFile *pDbFd = (winFile*)fd;        /* Connection holding shared memory */\n  winShm *p = pDbFd->pShm;              /* The shared memory being locked */\n  winShm *pX;                           /* For looping over all siblings */\n  winShmNode *pShmNode = p->pShmNode;\n  int rc = SQLITE_OK;                   /* Result code */\n  u16 mask;                             /* Mask of locks to take or release */\n\n  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );\n  assert( n>=1 );\n  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED)\n       || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) );\n  assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 );\n\n  mask = (u16)((1U<<(ofst+n)) - (1U<<ofst));\n  assert( n>1 || mask==(1<<ofst) );\n  sqlite3_mutex_enter(pShmNode->mutex);\n  if( flags & SQLITE_SHM_UNLOCK ){\n    u16 allMask = 0; /* Mask of locks held by siblings */\n\n    /* See if any siblings hold this same lock */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( pX==p ) continue;\n      assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 );\n      allMask |= pX->sharedMask;\n    }\n\n    /* Unlock the system-level locks */\n    if( (mask & allMask)==0 ){\n      rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n);\n    }else{\n      rc = SQLITE_OK;\n    }\n\n    /* Undo the local locks */\n    if( rc==SQLITE_OK ){\n      p->exclMask &= ~mask;\n      p->sharedMask &= ~mask;\n    }\n  }else if( flags & SQLITE_SHM_SHARED ){\n    u16 allShared = 0;  /* Union of locks held by connections other than \"p\" */\n\n    /* Find out which shared locks are already held by sibling connections.\n    ** If any sibling already holds an exclusive lock, go ahead and return\n    ** SQLITE_BUSY.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n      allShared |= pX->sharedMask;\n    }\n\n    /* Get shared locks at the system level, if necessary */\n    if( rc==SQLITE_OK ){\n      if( (allShared & mask)==0 ){\n        rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n);\n      }else{\n        rc = SQLITE_OK;\n      }\n    }\n\n    /* Get the local shared locks */\n    if( rc==SQLITE_OK ){\n      p->sharedMask |= mask;\n    }\n  }else{\n    /* Make sure no sibling connections hold locks that will block this\n    ** lock.  If any do, return SQLITE_BUSY right away.\n    */\n    for(pX=pShmNode->pFirst; pX; pX=pX->pNext){\n      if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){\n        rc = SQLITE_BUSY;\n        break;\n      }\n    }\n\n    /* Get the exclusive locks at the system level.  Then if successful\n    ** also mark the local connection as being locked.\n    */\n    if( rc==SQLITE_OK ){\n      rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n);\n      if( rc==SQLITE_OK ){\n        assert( (p->sharedMask & mask)==0 );\n        p->exclMask |= mask;\n      }\n    }\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  OSTRACE((\"SHM-LOCK pid=%lu, id=%d, sharedMask=%03x, exclMask=%03x, rc=%s\\n\",\n           osGetCurrentProcessId(), p->id, p->sharedMask, p->exclMask,\n           sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Implement a memory barrier or memory fence on shared memory.\n**\n** All loads and stores begun before the barrier must complete before\n** any load or store begun after the barrier.\n*/\nstatic void winShmBarrier(\n  sqlite3_file *fd          /* Database holding the shared memory */\n){\n  UNUSED_PARAMETER(fd);\n  sqlite3MemoryBarrier();   /* compiler-defined memory barrier */\n  winShmEnterMutex();       /* Also mutex, for redundancy */\n  winShmLeaveMutex();\n}\n\n/*\n** This function is called to obtain a pointer to region iRegion of the\n** shared-memory associated with the database file fd. Shared-memory regions\n** are numbered starting from zero. Each shared-memory region is szRegion\n** bytes in size.\n**\n** If an error occurs, an error code is returned and *pp is set to NULL.\n**\n** Otherwise, if the isWrite parameter is 0 and the requested shared-memory\n** region has not been allocated (by any client, including one running in a\n** separate process), then *pp is set to NULL and SQLITE_OK returned. If\n** isWrite is non-zero and the requested shared-memory region has not yet\n** been allocated, it is allocated by this function.\n**\n** If the shared-memory region has already been allocated or is allocated by\n** this call as described above, then it is mapped into this processes\n** address space (if it is not already), *pp is set to point to the mapped\n** memory and SQLITE_OK returned.\n*/\nstatic int winShmMap(\n  sqlite3_file *fd,               /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int isWrite,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  winFile *pDbFd = (winFile*)fd;\n  winShm *pShm = pDbFd->pShm;\n  winShmNode *pShmNode;\n  int rc = SQLITE_OK;\n\n  if( !pShm ){\n    rc = winOpenSharedMemory(pDbFd);\n    if( rc!=SQLITE_OK ) return rc;\n    pShm = pDbFd->pShm;\n  }\n  pShmNode = pShm->pShmNode;\n\n  sqlite3_mutex_enter(pShmNode->mutex);\n  assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );\n\n  if( pShmNode->nRegion<=iRegion ){\n    struct ShmRegion *apNew;           /* New aRegion[] array */\n    int nByte = (iRegion+1)*szRegion;  /* Minimum required file size */\n    sqlite3_int64 sz;                  /* Current size of wal-index file */\n\n    pShmNode->szRegion = szRegion;\n\n    /* The requested region is not mapped into this processes address space.\n    ** Check to see if it has been allocated (i.e. if the wal-index file is\n    ** large enough to contain the requested region).\n    */\n    rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);\n    if( rc!=SQLITE_OK ){\n      rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                       \"winShmMap1\", pDbFd->zPath);\n      goto shmpage_out;\n    }\n\n    if( sz<nByte ){\n      /* The requested memory region does not exist. If isWrite is set to\n      ** zero, exit early. *pp will be set to NULL and SQLITE_OK returned.\n      **\n      ** Alternatively, if isWrite is non-zero, use ftruncate() to allocate\n      ** the requested memory region.\n      */\n      if( !isWrite ) goto shmpage_out;\n      rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);\n      if( rc!=SQLITE_OK ){\n        rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),\n                         \"winShmMap2\", pDbFd->zPath);\n        goto shmpage_out;\n      }\n    }\n\n    /* Map the requested memory region into this processes address space. */\n    apNew = (struct ShmRegion *)sqlite3_realloc64(\n        pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])\n    );\n    if( !apNew ){\n      rc = SQLITE_IOERR_NOMEM_BKPT;\n      goto shmpage_out;\n    }\n    pShmNode->aRegion = apNew;\n\n    while( pShmNode->nRegion<=iRegion ){\n      HANDLE hMap = NULL;         /* file-mapping handle */\n      void *pMap = 0;             /* Mapped memory region */\n\n#if SQLITE_OS_WINRT\n      hMap = osCreateFileMappingFromApp(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n      hMap = osCreateFileMappingW(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n      hMap = osCreateFileMappingA(pShmNode->hFile.h,\n          NULL, PAGE_READWRITE, 0, nByte, NULL\n      );\n#endif\n      OSTRACE((\"SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\\n\",\n               osGetCurrentProcessId(), pShmNode->nRegion, nByte,\n               hMap ? \"ok\" : \"failed\"));\n      if( hMap ){\n        int iOffset = pShmNode->nRegion*szRegion;\n        int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n#if SQLITE_OS_WINRT\n        pMap = osMapViewOfFileFromApp(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#else\n        pMap = osMapViewOfFile(hMap, FILE_MAP_WRITE | FILE_MAP_READ,\n            0, iOffset - iOffsetShift, szRegion + iOffsetShift\n        );\n#endif\n        OSTRACE((\"SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\\n\",\n                 osGetCurrentProcessId(), pShmNode->nRegion, iOffset,\n                 szRegion, pMap ? \"ok\" : \"failed\"));\n      }\n      if( !pMap ){\n        pShmNode->lastErrno = osGetLastError();\n        rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,\n                         \"winShmMap3\", pDbFd->zPath);\n        if( hMap ) osCloseHandle(hMap);\n        goto shmpage_out;\n      }\n\n      pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;\n      pShmNode->aRegion[pShmNode->nRegion].hMap = hMap;\n      pShmNode->nRegion++;\n    }\n  }\n\nshmpage_out:\n  if( pShmNode->nRegion>iRegion ){\n    int iOffset = iRegion*szRegion;\n    int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;\n    char *p = (char *)pShmNode->aRegion[iRegion].pMap;\n    *pp = (void *)&p[iOffsetShift];\n  }else{\n    *pp = 0;\n  }\n  sqlite3_mutex_leave(pShmNode->mutex);\n  return rc;\n}\n\n#else\n# define winShmMap     0\n# define winShmLock    0\n# define winShmBarrier 0\n# define winShmUnmap   0\n#endif /* #ifndef SQLITE_OMIT_WAL */\n\n/*\n** Cleans up the mapped region of the specified file, if any.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int winUnmapfile(winFile *pFile){\n  assert( pFile!=0 );\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, pMapRegion=%p, \"\n           \"mmapSize=%lld, mmapSizeActual=%lld, mmapSizeMax=%lld\\n\",\n           osGetCurrentProcessId(), pFile, pFile->hMap, pFile->pMapRegion,\n           pFile->mmapSize, pFile->mmapSizeActual, pFile->mmapSizeMax));\n  if( pFile->pMapRegion ){\n    if( !osUnmapViewOfFile(pFile->pMapRegion) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, \"\n               \"rc=SQLITE_IOERR_MMAP\\n\", osGetCurrentProcessId(), pFile,\n               pFile->pMapRegion));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile1\", pFile->zPath);\n    }\n    pFile->pMapRegion = 0;\n    pFile->mmapSize = 0;\n    pFile->mmapSizeActual = 0;\n  }\n  if( pFile->hMap!=NULL ){\n    if( !osCloseHandle(pFile->hMap) ){\n      pFile->lastErrno = osGetLastError();\n      OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\\n\",\n               osGetCurrentProcessId(), pFile, pFile->hMap));\n      return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,\n                         \"winUnmapfile2\", pFile->zPath);\n    }\n    pFile->hMap = NULL;\n  }\n  OSTRACE((\"UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFile));\n  return SQLITE_OK;\n}\n\n/*\n** Memory map or remap the file opened by file-descriptor pFd (if the file\n** is already mapped, the existing mapping is replaced by the new). Or, if\n** there already exists a mapping for this file, and there are still\n** outstanding xFetch() references to it, this function is a no-op.\n**\n** If parameter nByte is non-negative, then it is the requested size of\n** the mapping to create. Otherwise, if nByte is less than zero, then the\n** requested size is the size of the file on disk. The actual size of the\n** created mapping is either the requested size or the value configured\n** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.\n**\n** SQLITE_OK is returned if no error occurs (even if the mapping is not\n** recreated as a result of outstanding references) or an SQLite error\n** code otherwise.\n*/\nstatic int winMapfile(winFile *pFd, sqlite3_int64 nByte){\n  sqlite3_int64 nMap = nByte;\n  int rc;\n\n  assert( nMap>=0 || pFd->nFetchOut==0 );\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, size=%lld\\n\",\n           osGetCurrentProcessId(), pFd, nByte));\n\n  if( pFd->nFetchOut>0 ) return SQLITE_OK;\n\n  if( nMap<0 ){\n    rc = winFileSize((sqlite3_file*)pFd, &nMap);\n    if( rc ){\n      OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_IOERR_FSTAT\\n\",\n               osGetCurrentProcessId(), pFd));\n      return SQLITE_IOERR_FSTAT;\n    }\n  }\n  if( nMap>pFd->mmapSizeMax ){\n    nMap = pFd->mmapSizeMax;\n  }\n  nMap &= ~(sqlite3_int64)(winSysInfo.dwPageSize - 1);\n\n  if( nMap==0 && pFd->mmapSize>0 ){\n    winUnmapfile(pFd);\n  }\n  if( nMap!=pFd->mmapSize ){\n    void *pNew = 0;\n    DWORD protect = PAGE_READONLY;\n    DWORD flags = FILE_MAP_READ;\n\n    winUnmapfile(pFd);\n#ifdef SQLITE_MMAP_READWRITE\n    if( (pFd->ctrlFlags & WINFILE_RDONLY)==0 ){\n      protect = PAGE_READWRITE;\n      flags |= FILE_MAP_WRITE;\n    }\n#endif\n#if SQLITE_OS_WINRT\n    pFd->hMap = osCreateFileMappingFromApp(pFd->h, NULL, protect, nMap, NULL);\n#elif defined(SQLITE_WIN32_HAS_WIDE)\n    pFd->hMap = osCreateFileMappingW(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA\n    pFd->hMap = osCreateFileMappingA(pFd->h, NULL, protect,\n                                (DWORD)((nMap>>32) & 0xffffffff),\n                                (DWORD)(nMap & 0xffffffff), NULL);\n#endif\n    if( pFd->hMap==NULL ){\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile1\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    assert( (nMap % winSysInfo.dwPageSize)==0 );\n    assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );\n#if SQLITE_OS_WINRT\n    pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);\n#else\n    pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);\n#endif\n    if( pNew==NULL ){\n      osCloseHandle(pFd->hMap);\n      pFd->hMap = NULL;\n      pFd->lastErrno = osGetLastError();\n      rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,\n                       \"winMapfile2\", pFd->zPath);\n      /* Log the error, but continue normal operation using xRead/xWrite */\n      OSTRACE((\"MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\\n\",\n               osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n      return SQLITE_OK;\n    }\n    pFd->pMapRegion = pNew;\n    pFd->mmapSize = nMap;\n    pFd->mmapSizeActual = nMap;\n  }\n\n  OSTRACE((\"MAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), pFd));\n  return SQLITE_OK;\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/*\n** If possible, return a pointer to a mapping of file fd starting at offset\n** iOff. The mapping must be valid for at least nAmt bytes.\n**\n** If such a pointer can be obtained, store it in *pp and return SQLITE_OK.\n** Or, if one cannot but no error occurs, set *pp to 0 and return SQLITE_OK.\n** Finally, if an error does occur, return an SQLite error code. The final\n** value of *pp is undefined in this case.\n**\n** If this function does return a pointer, the caller must eventually\n** release the reference by calling winUnfetch().\n*/\nstatic int winFetch(sqlite3_file *fd, i64 iOff, int nAmt, void **pp){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n#endif\n  *pp = 0;\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, offset=%lld, amount=%d, pp=%p\\n\",\n           osGetCurrentProcessId(), fd, iOff, nAmt, pp));\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  if( pFd->mmapSizeMax>0 ){\n    if( pFd->pMapRegion==0 ){\n      int rc = winMapfile(pFd, -1);\n      if( rc!=SQLITE_OK ){\n        OSTRACE((\"FETCH pid=%lu, pFile=%p, rc=%s\\n\",\n                 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));\n        return rc;\n      }\n    }\n    if( pFd->mmapSize >= iOff+nAmt ){\n      *pp = &((u8 *)pFd->pMapRegion)[iOff];\n      pFd->nFetchOut++;\n    }\n  }\n#endif\n\n  OSTRACE((\"FETCH pid=%lu, pFile=%p, pp=%p, *pp=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd, pp, *pp));\n  return SQLITE_OK;\n}\n\n/*\n** If the third argument is non-NULL, then this function releases a\n** reference obtained by an earlier call to winFetch(). The second\n** argument passed to this function must be the same as the corresponding\n** argument that was passed to the winFetch() invocation.\n**\n** Or, if the third argument is NULL, then this function is being called\n** to inform the VFS layer that, according to POSIX, any existing mapping\n** may now be invalid and should be unmapped.\n*/\nstatic int winUnfetch(sqlite3_file *fd, i64 iOff, void *p){\n#if SQLITE_MAX_MMAP_SIZE>0\n  winFile *pFd = (winFile*)fd;   /* The underlying database file */\n\n  /* If p==0 (unmap the entire file) then there must be no outstanding\n  ** xFetch references. Or, if p!=0 (meaning it is an xFetch reference),\n  ** then there must be at least one outstanding.  */\n  assert( (p==0)==(pFd->nFetchOut==0) );\n\n  /* If p!=0, it must match the iOff value. */\n  assert( p==0 || p==&((u8 *)pFd->pMapRegion)[iOff] );\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, offset=%lld, p=%p\\n\",\n           osGetCurrentProcessId(), pFd, iOff, p));\n\n  if( p ){\n    pFd->nFetchOut--;\n  }else{\n    /* FIXME:  If Windows truly always prevents truncating or deleting a\n    ** file while a mapping is held, then the following winUnmapfile() call\n    ** is unnecessary can be omitted - potentially improving\n    ** performance.  */\n    winUnmapfile(pFd);\n  }\n\n  assert( pFd->nFetchOut>=0 );\n#endif\n\n  OSTRACE((\"UNFETCH pid=%lu, pFile=%p, rc=SQLITE_OK\\n\",\n           osGetCurrentProcessId(), fd));\n  return SQLITE_OK;\n}\n\n/*\n** Here ends the implementation of all sqlite3_file methods.\n**\n********************** End sqlite3_file Methods *******************************\n******************************************************************************/\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32.\n*/\nstatic const sqlite3_io_methods winIoMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winLock,                        /* xLock */\n  winUnlock,                      /* xUnlock */\n  winCheckReservedLock,           /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\n/*\n** This vector defines all the methods that can operate on an\n** sqlite3_file for win32 without performing any locking.\n*/\nstatic const sqlite3_io_methods winIoNolockMethod = {\n  3,                              /* iVersion */\n  winClose,                       /* xClose */\n  winRead,                        /* xRead */\n  winWrite,                       /* xWrite */\n  winTruncate,                    /* xTruncate */\n  winSync,                        /* xSync */\n  winFileSize,                    /* xFileSize */\n  winNolockLock,                  /* xLock */\n  winNolockUnlock,                /* xUnlock */\n  winNolockCheckReservedLock,     /* xCheckReservedLock */\n  winFileControl,                 /* xFileControl */\n  winSectorSize,                  /* xSectorSize */\n  winDeviceCharacteristics,       /* xDeviceCharacteristics */\n  winShmMap,                      /* xShmMap */\n  winShmLock,                     /* xShmLock */\n  winShmBarrier,                  /* xShmBarrier */\n  winShmUnmap,                    /* xShmUnmap */\n  winFetch,                       /* xFetch */\n  winUnfetch                      /* xUnfetch */\n};\n\nstatic winVfsAppData winAppData = {\n  &winIoMethod,       /* pMethod */\n  0,                  /* pAppData */\n  0                   /* bNoLock */\n};\n\nstatic winVfsAppData winNolockAppData = {\n  &winIoNolockMethod, /* pMethod */\n  0,                  /* pAppData */\n  1                   /* bNoLock */\n};\n\n/****************************************************************************\n**************************** sqlite3_vfs methods ****************************\n**\n** This division contains the implementation of methods on the\n** sqlite3_vfs object.\n*/\n\n#if defined(__CYGWIN__)\n/*\n** Convert a filename from whatever the underlying operating system\n** supports for filenames into UTF-8.  Space to hold the result is\n** obtained from malloc and must be freed by the calling function.\n*/\nstatic char *winConvertToUtf8Filename(const void *zFilename){\n  char *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUnicodeToUtf8(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winMbcsToUtf8(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n#endif\n\n/*\n** Convert a UTF-8 filename into whatever form the underlying\n** operating system wants filenames in.  Space to hold the result\n** is obtained from malloc and must be freed by the calling\n** function.\n*/\nstatic void *winConvertFromUtf8Filename(const char *zFilename){\n  void *zConverted = 0;\n  if( osIsNT() ){\n    zConverted = winUtf8ToUnicode(zFilename);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());\n  }\n#endif\n  /* caller will handle out of memory */\n  return zConverted;\n}\n\n/*\n** This function returns non-zero if the specified UTF-8 string buffer\n** ends with a directory separator character or one was successfully\n** added to it.\n*/\nstatic int winMakeEndInDirSep(int nBuf, char *zBuf){\n  if( zBuf ){\n    int nLen = sqlite3Strlen30(zBuf);\n    if( nLen>0 ){\n      if( winIsDirSep(zBuf[nLen-1]) ){\n        return 1;\n      }else if( nLen+1<nBuf ){\n        zBuf[nLen] = winGetDirSep();\n        zBuf[nLen+1] = '\\0';\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a temporary file name and store the resulting pointer into pzBuf.\n** The pointer returned in pzBuf must be freed via sqlite3_free().\n*/\nstatic int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){\n  static char zChars[] =\n    \"abcdefghijklmnopqrstuvwxyz\"\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"0123456789\";\n  size_t i, j;\n  int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);\n  int nMax, nBuf, nDir, nLen;\n  char *zBuf;\n\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing.\n  */\n  SimulateIOError( return SQLITE_IOERR );\n\n  /* Allocate a temporary buffer to store the fully qualified file\n  ** name for the temporary file.  If this fails, we cannot continue.\n  */\n  nMax = pVfs->mxPathname; nBuf = nMax + 2;\n  zBuf = sqlite3MallocZero( nBuf );\n  if( !zBuf ){\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  /* Figure out the effective temporary directory.  First, check if one\n  ** has been explicitly set by the application; otherwise, use the one\n  ** configured by the operating system.\n  */\n  nDir = nMax - (nPre + 15);\n  assert( nDir>0 );\n  if( sqlite3_temp_directory ){\n    int nDirLen = sqlite3Strlen30(sqlite3_temp_directory);\n    if( nDirLen>0 ){\n      if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){\n        nDirLen++;\n      }\n      if( nDirLen>nDir ){\n        sqlite3_free(zBuf);\n        OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n        return winLogError(SQLITE_ERROR, 0, \"winGetTempname1\", 0);\n      }\n      sqlite3_snprintf(nMax, zBuf, \"%s\", sqlite3_temp_directory);\n    }\n  }\n#if defined(__CYGWIN__)\n  else{\n    static const char *azDirs[] = {\n       0, /* getenv(\"SQLITE_TMPDIR\") */\n       0, /* getenv(\"TMPDIR\") */\n       0, /* getenv(\"TMP\") */\n       0, /* getenv(\"TEMP\") */\n       0, /* getenv(\"USERPROFILE\") */\n       \"/var/tmp\",\n       \"/usr/tmp\",\n       \"/tmp\",\n       \".\",\n       0        /* List terminator */\n    };\n    unsigned int i;\n    const char *zDir = 0;\n\n    if( !azDirs[0] ) azDirs[0] = getenv(\"SQLITE_TMPDIR\");\n    if( !azDirs[1] ) azDirs[1] = getenv(\"TMPDIR\");\n    if( !azDirs[2] ) azDirs[2] = getenv(\"TMP\");\n    if( !azDirs[3] ) azDirs[3] = getenv(\"TEMP\");\n    if( !azDirs[4] ) azDirs[4] = getenv(\"USERPROFILE\");\n    for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){\n      void *zConverted;\n      if( zDir==0 ) continue;\n      /* If the path starts with a drive letter followed by the colon\n      ** character, assume it is already a native Win32 path; otherwise,\n      ** it must be converted to a native Win32 path via the Cygwin API\n      ** prior to using it.\n      */\n      if( winIsDriveLetterAndColon(zDir) ){\n        zConverted = winConvertFromUtf8Filename(zDir);\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( winIsDir(zConverted) ){\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zDir);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }else{\n        zConverted = sqlite3MallocZero( nMax+1 );\n        if( !zConverted ){\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n          return SQLITE_IOERR_NOMEM_BKPT;\n        }\n        if( cygwin_conv_path(\n                osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,\n                zConverted, nMax+1)<0 ){\n          sqlite3_free(zConverted);\n          sqlite3_free(zBuf);\n          OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\\n\"));\n          return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,\n                             \"winGetTempname2\", zDir);\n        }\n        if( winIsDir(zConverted) ){\n          /* At this point, we know the candidate directory exists and should\n          ** be used.  However, we may need to convert the string containing\n          ** its name into UTF-8 (i.e. if it is UTF-16 right now).\n          */\n          char *zUtf8 = winConvertToUtf8Filename(zConverted);\n          if( !zUtf8 ){\n            sqlite3_free(zConverted);\n            sqlite3_free(zBuf);\n            OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n            return SQLITE_IOERR_NOMEM_BKPT;\n          }\n          sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n          sqlite3_free(zUtf8);\n          sqlite3_free(zConverted);\n          break;\n        }\n        sqlite3_free(zConverted);\n      }\n    }\n  }\n#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  else if( osIsNT() ){\n    char *zMulti;\n    LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) );\n    if( !zWidePath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathW(nMax, zWidePath)==0 ){\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname2\", 0);\n    }\n    zMulti = winUnicodeToUtf8(zWidePath);\n    if( zMulti ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zMulti);\n      sqlite3_free(zMulti);\n      sqlite3_free(zWidePath);\n    }else{\n      sqlite3_free(zWidePath);\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zUtf8;\n    char *zMbcsPath = sqlite3MallocZero( nMax );\n    if( !zMbcsPath ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( osGetTempPathA(nMax, zMbcsPath)==0 ){\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\\n\"));\n      return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),\n                         \"winGetTempname3\", 0);\n    }\n    zUtf8 = winMbcsToUtf8(zMbcsPath, osAreFileApisANSI());\n    if( zUtf8 ){\n      sqlite3_snprintf(nMax, zBuf, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n    }else{\n      sqlite3_free(zBuf);\n      OSTRACE((\"TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\\n\"));\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n  }\n#endif /* SQLITE_WIN32_HAS_ANSI */\n#endif /* !SQLITE_OS_WINRT */\n\n  /*\n  ** Check to make sure the temporary directory ends with an appropriate\n  ** separator.  If it does not and there is not enough space left to add\n  ** one, fail.\n  */\n  if( !winMakeEndInDirSep(nDir+1, zBuf) ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname4\", 0);\n  }\n\n  /*\n  ** Check that the output buffer is large enough for the temporary file\n  ** name in the following format:\n  **\n  **   \"<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\\0\\0\"\n  **\n  ** If not, return SQLITE_ERROR.  The number 17 is used here in order to\n  ** account for the space used by the 15 character random suffix and the\n  ** two trailing NUL characters.  The final directory separator character\n  ** has already added if it was not already present.\n  */\n  nLen = sqlite3Strlen30(zBuf);\n  if( (nLen + nPre + 17) > nBuf ){\n    sqlite3_free(zBuf);\n    OSTRACE((\"TEMP-FILENAME rc=SQLITE_ERROR\\n\"));\n    return winLogError(SQLITE_ERROR, 0, \"winGetTempname5\", 0);\n  }\n\n  sqlite3_snprintf(nBuf-16-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);\n\n  j = sqlite3Strlen30(zBuf);\n  sqlite3_randomness(15, &zBuf[j]);\n  for(i=0; i<15; i++, j++){\n    zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];\n  }\n  zBuf[j] = 0;\n  zBuf[j+1] = 0;\n  *pzBuf = zBuf;\n\n  OSTRACE((\"TEMP-FILENAME name=%s, rc=SQLITE_OK\\n\", zBuf));\n  return SQLITE_OK;\n}\n\n/*\n** Return TRUE if the named file is really a directory.  Return false if\n** it is something other than a directory, or if there is any kind of memory\n** allocation failure.\n*/\nstatic int winIsDir(const void *zConverted){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno;\n\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( !rc ){\n      return 0; /* Invalid name? */\n    }\n    attr = sAttrData.dwFileAttributes;\n#if SQLITE_OS_WINCE==0\n  }else{\n    attr = osGetFileAttributesA((char*)zConverted);\n#endif\n  }\n  return (attr!=INVALID_FILE_ATTRIBUTES) && (attr&FILE_ATTRIBUTE_DIRECTORY);\n}\n\n/* forward reference */\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n);\n\n/*\n** Open a file.\n*/\nstatic int winOpen(\n  sqlite3_vfs *pVfs,        /* Used to get maximum path length and AppData */\n  const char *zName,        /* Name of the file (UTF-8) */\n  sqlite3_file *id,         /* Write the SQLite file handle here */\n  int flags,                /* Open mode flags */\n  int *pOutFlags            /* Status return flags */\n){\n  HANDLE h;\n  DWORD lastErrno = 0;\n  DWORD dwDesiredAccess;\n  DWORD dwShareMode;\n  DWORD dwCreationDisposition;\n  DWORD dwFlagsAndAttributes = 0;\n#if SQLITE_OS_WINCE\n  int isTemp = 0;\n#endif\n  winVfsAppData *pAppData;\n  winFile *pFile = (winFile*)id;\n  void *zConverted;              /* Filename in OS encoding */\n  const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */\n  int cnt = 0;\n\n  /* If argument zPath is a NULL pointer, this function is required to open\n  ** a temporary file. Use this buffer to store the file name in.\n  */\n  char *zTmpname = 0; /* For temporary filename, if necessary. */\n\n  int rc = SQLITE_OK;            /* Function Return Code */\n#if !defined(NDEBUG) || SQLITE_OS_WINCE\n  int eType = flags&0xFFFFFF00;  /* Type of file to open */\n#endif\n\n  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);\n  int isDelete     = (flags & SQLITE_OPEN_DELETEONCLOSE);\n  int isCreate     = (flags & SQLITE_OPEN_CREATE);\n  int isReadonly   = (flags & SQLITE_OPEN_READONLY);\n  int isReadWrite  = (flags & SQLITE_OPEN_READWRITE);\n\n#ifndef NDEBUG\n  int isOpenJournal = (isCreate && (\n        eType==SQLITE_OPEN_MASTER_JOURNAL\n     || eType==SQLITE_OPEN_MAIN_JOURNAL\n     || eType==SQLITE_OPEN_WAL\n  ));\n#endif\n\n  OSTRACE((\"OPEN name=%s, pFile=%p, flags=%x, pOutFlags=%p\\n\",\n           zUtf8Name, id, flags, pOutFlags));\n\n  /* Check the following statements are true:\n  **\n  **   (a) Exactly one of the READWRITE and READONLY flags must be set, and\n  **   (b) if CREATE is set, then READWRITE must also be set, and\n  **   (c) if EXCLUSIVE is set, then CREATE must also be set.\n  **   (d) if DELETEONCLOSE is set, then CREATE must also be set.\n  */\n  assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly));\n  assert(isCreate==0 || isReadWrite);\n  assert(isExclusive==0 || isCreate);\n  assert(isDelete==0 || isCreate);\n\n  /* The main DB, main journal, WAL file and master journal are never\n  ** automatically deleted. Nor are they ever temporary files.  */\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL );\n  assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL );\n\n  /* Assert that the upper layer has set one of the \"file-type\" flags. */\n  assert( eType==SQLITE_OPEN_MAIN_DB      || eType==SQLITE_OPEN_TEMP_DB\n       || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL\n       || eType==SQLITE_OPEN_SUBJOURNAL   || eType==SQLITE_OPEN_MASTER_JOURNAL\n       || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL\n  );\n\n  assert( pFile!=0 );\n  memset(pFile, 0, sizeof(winFile));\n  pFile->h = INVALID_HANDLE_VALUE;\n\n#if SQLITE_OS_WINRT\n  if( !zUtf8Name && !sqlite3_temp_directory ){\n    sqlite3_log(SQLITE_ERROR,\n        \"sqlite3_temp_directory variable should be set for WinRT\");\n  }\n#endif\n\n  /* If the second argument to this function is NULL, generate a\n  ** temporary file name to use\n  */\n  if( !zUtf8Name ){\n    assert( isDelete && !isOpenJournal );\n    rc = winGetTempname(pVfs, &zTmpname);\n    if( rc!=SQLITE_OK ){\n      OSTRACE((\"OPEN name=%s, rc=%s\", zUtf8Name, sqlite3ErrName(rc)));\n      return rc;\n    }\n    zUtf8Name = zTmpname;\n  }\n\n  /* Database filenames are double-zero terminated if they are not\n  ** URIs with parameters.  Hence, they can always be passed into\n  ** sqlite3_uri_parameter().\n  */\n  assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||\n       zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );\n\n  /* Convert the filename to the system encoding. */\n  zConverted = winConvertFromUtf8Filename(zUtf8Name);\n  if( zConverted==0 ){\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_IOERR_NOMEM\", zUtf8Name));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n\n  if( winIsDir(zConverted) ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    OSTRACE((\"OPEN name=%s, rc=SQLITE_CANTOPEN_ISDIR\", zUtf8Name));\n    return SQLITE_CANTOPEN_ISDIR;\n  }\n\n  if( isReadWrite ){\n    dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;\n  }else{\n    dwDesiredAccess = GENERIC_READ;\n  }\n\n  /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is\n  ** created. SQLite doesn't use it to indicate \"exclusive access\"\n  ** as it is usually understood.\n  */\n  if( isExclusive ){\n    /* Creates a new file, only if it does not already exist. */\n    /* If the file exists, it fails. */\n    dwCreationDisposition = CREATE_NEW;\n  }else if( isCreate ){\n    /* Open existing file, or create if it doesn't exist */\n    dwCreationDisposition = OPEN_ALWAYS;\n  }else{\n    /* Opens a file, only if it exists. */\n    dwCreationDisposition = OPEN_EXISTING;\n  }\n\n  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;\n\n  if( isDelete ){\n#if SQLITE_OS_WINCE\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_HIDDEN;\n    isTemp = 1;\n#else\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_TEMPORARY\n                               | FILE_ATTRIBUTE_HIDDEN\n                               | FILE_FLAG_DELETE_ON_CLOSE;\n#endif\n  }else{\n    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;\n  }\n  /* Reports from the internet are that performance is always\n  ** better if FILE_FLAG_RANDOM_ACCESS is used.  Ticket #2699. */\n#if SQLITE_OS_WINCE\n  dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS;\n#endif\n\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    CREATEFILE2_EXTENDED_PARAMETERS extendedParameters;\n    extendedParameters.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS);\n    extendedParameters.dwFileAttributes =\n            dwFlagsAndAttributes & FILE_ATTRIBUTE_MASK;\n    extendedParameters.dwFileFlags = dwFlagsAndAttributes & FILE_FLAG_MASK;\n    extendedParameters.dwSecurityQosFlags = SECURITY_ANONYMOUS;\n    extendedParameters.lpSecurityAttributes = NULL;\n    extendedParameters.hTemplateFile = NULL;\n    do{\n      h = osCreateFile2((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode,\n                        dwCreationDisposition,\n                        &extendedParameters);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#else\n    do{\n      h = osCreateFileW((LPCWSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do{\n      h = osCreateFileA((LPCSTR)zConverted,\n                        dwDesiredAccess,\n                        dwShareMode, NULL,\n                        dwCreationDisposition,\n                        dwFlagsAndAttributes,\n                        NULL);\n      if( h!=INVALID_HANDLE_VALUE ) break;\n      if( isReadWrite ){\n        int isRO = 0;\n        int rc2 = winAccess(pVfs, zName, SQLITE_ACCESS_READ, &isRO);\n        if( rc2==SQLITE_OK && isRO ) break;\n      }\n    }while( winRetryIoerr(&cnt, &lastErrno) );\n  }\n#endif\n  winLogIoerr(cnt, __LINE__);\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, rc=%s\\n\", h, zUtf8Name,\n           dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  if( h==INVALID_HANDLE_VALUE ){\n    sqlite3_free(zConverted);\n    sqlite3_free(zTmpname);\n    if( isReadWrite && !isExclusive ){\n      return winOpen(pVfs, zName, id,\n         ((flags|SQLITE_OPEN_READONLY) &\n                     ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)),\n         pOutFlags);\n    }else{\n      pFile->lastErrno = lastErrno;\n      winLogError(SQLITE_CANTOPEN, pFile->lastErrno, \"winOpen\", zUtf8Name);\n      return SQLITE_CANTOPEN_BKPT;\n    }\n  }\n\n  if( pOutFlags ){\n    if( isReadWrite ){\n      *pOutFlags = SQLITE_OPEN_READWRITE;\n    }else{\n      *pOutFlags = SQLITE_OPEN_READONLY;\n    }\n  }\n\n  OSTRACE((\"OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, \"\n           \"rc=%s\\n\", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ?\n           *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? \"failed\" : \"ok\"));\n\n  pAppData = (winVfsAppData*)pVfs->pAppData;\n\n#if SQLITE_OS_WINCE\n  {\n    if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB\n         && ((pAppData==NULL) || !pAppData->bNoLock)\n         && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK\n    ){\n      osCloseHandle(h);\n      sqlite3_free(zConverted);\n      sqlite3_free(zTmpname);\n      OSTRACE((\"OPEN-CE-LOCK name=%s, rc=%s\\n\", zName, sqlite3ErrName(rc)));\n      return rc;\n    }\n  }\n  if( isTemp ){\n    pFile->zDeleteOnClose = zConverted;\n  }else\n#endif\n  {\n    sqlite3_free(zConverted);\n  }\n\n  sqlite3_free(zTmpname);\n  pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod;\n  pFile->pVfs = pVfs;\n  pFile->h = h;\n  if( isReadonly ){\n    pFile->ctrlFlags |= WINFILE_RDONLY;\n  }\n  if( sqlite3_uri_boolean(zName, \"psow\", SQLITE_POWERSAFE_OVERWRITE) ){\n    pFile->ctrlFlags |= WINFILE_PSOW;\n  }\n  pFile->lastErrno = NO_ERROR;\n  pFile->zPath = zName;\n#if SQLITE_MAX_MMAP_SIZE>0\n  pFile->hMap = NULL;\n  pFile->pMapRegion = 0;\n  pFile->mmapSize = 0;\n  pFile->mmapSizeActual = 0;\n  pFile->mmapSizeMax = sqlite3GlobalConfig.szMmap;\n#endif\n\n  OpenCounter(+1);\n  return rc;\n}\n\n/*\n** Delete the named file.\n**\n** Note that Windows does not allow a file to be deleted if some other\n** process has it open.  Sometimes a virus scanner or indexing program\n** will open a journal file shortly after it is created in order to do\n** whatever it does.  While this other process is holding the\n** file open, we will be unable to delete it.  To work around this\n** problem, we delay 100 milliseconds and try to delete again.  Up\n** to MX_DELETION_ATTEMPTs deletion attempts are run before giving\n** up and returning an error.\n*/\nstatic int winDelete(\n  sqlite3_vfs *pVfs,          /* Not used on win32 */\n  const char *zFilename,      /* Name of file to delete */\n  int syncDir                 /* Not used on win32 */\n){\n  int cnt = 0;\n  int rc;\n  DWORD attr;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n  UNUSED_PARAMETER(syncDir);\n\n  SimulateIOError(return SQLITE_IOERR_DELETE);\n  OSTRACE((\"DELETE name=%s, syncDir=%d\\n\", zFilename, syncDir));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"DELETE name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    do {\n#if SQLITE_OS_WINRT\n      WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n      memset(&sAttrData, 0, sizeof(sAttrData));\n      if ( osGetFileAttributesExW(zConverted, GetFileExInfoStandard,\n                                  &sAttrData) ){\n        attr = sAttrData.dwFileAttributes;\n      }else{\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n#else\n      attr = osGetFileAttributesW(zConverted);\n#endif\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileW(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    do {\n      attr = osGetFileAttributesA(zConverted);\n      if ( attr==INVALID_FILE_ATTRIBUTES ){\n        lastErrno = osGetLastError();\n        if( lastErrno==ERROR_FILE_NOT_FOUND\n         || lastErrno==ERROR_PATH_NOT_FOUND ){\n          rc = SQLITE_IOERR_DELETE_NOENT; /* Already gone? */\n        }else{\n          rc = SQLITE_ERROR;\n        }\n        break;\n      }\n      if ( attr&FILE_ATTRIBUTE_DIRECTORY ){\n        rc = SQLITE_ERROR; /* Files only. */\n        break;\n      }\n      if ( osDeleteFileA(zConverted) ){\n        rc = SQLITE_OK; /* Deleted OK. */\n        break;\n      }\n      if ( !winRetryIoerr(&cnt, &lastErrno) ){\n        rc = SQLITE_ERROR; /* No more retries. */\n        break;\n      }\n    } while(1);\n  }\n#endif\n  if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){\n    rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, \"winDelete\", zFilename);\n  }else{\n    winLogIoerr(cnt, __LINE__);\n  }\n  sqlite3_free(zConverted);\n  OSTRACE((\"DELETE name=%s, rc=%s\\n\", zFilename, sqlite3ErrName(rc)));\n  return rc;\n}\n\n/*\n** Check the existence and status of a file.\n*/\nstatic int winAccess(\n  sqlite3_vfs *pVfs,         /* Not used on win32 */\n  const char *zFilename,     /* Name of file to check */\n  int flags,                 /* Type of test to make on this file */\n  int *pResOut               /* OUT: Result */\n){\n  DWORD attr;\n  int rc = 0;\n  DWORD lastErrno = 0;\n  void *zConverted;\n  UNUSED_PARAMETER(pVfs);\n\n  SimulateIOError( return SQLITE_IOERR_ACCESS; );\n  OSTRACE((\"ACCESS name=%s, flags=%x, pResOut=%p\\n\",\n           zFilename, flags, pResOut));\n\n  zConverted = winConvertFromUtf8Filename(zFilename);\n  if( zConverted==0 ){\n    OSTRACE((\"ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\\n\", zFilename));\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    int cnt = 0;\n    WIN32_FILE_ATTRIBUTE_DATA sAttrData;\n    memset(&sAttrData, 0, sizeof(sAttrData));\n    while( !(rc = osGetFileAttributesExW((LPCWSTR)zConverted,\n                             GetFileExInfoStandard,\n                             &sAttrData)) && winRetryIoerr(&cnt, &lastErrno) ){}\n    if( rc ){\n      /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file\n      ** as if it does not exist.\n      */\n      if(    flags==SQLITE_ACCESS_EXISTS\n          && sAttrData.nFileSizeHigh==0\n          && sAttrData.nFileSizeLow==0 ){\n        attr = INVALID_FILE_ATTRIBUTES;\n      }else{\n        attr = sAttrData.dwFileAttributes;\n      }\n    }else{\n      winLogIoerr(cnt, __LINE__);\n      if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){\n        sqlite3_free(zConverted);\n        return winLogError(SQLITE_IOERR_ACCESS, lastErrno, \"winAccess\",\n                           zFilename);\n      }else{\n        attr = INVALID_FILE_ATTRIBUTES;\n      }\n    }\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    attr = osGetFileAttributesA((char*)zConverted);\n  }\n#endif\n  sqlite3_free(zConverted);\n  switch( flags ){\n    case SQLITE_ACCESS_READ:\n    case SQLITE_ACCESS_EXISTS:\n      rc = attr!=INVALID_FILE_ATTRIBUTES;\n      break;\n    case SQLITE_ACCESS_READWRITE:\n      rc = attr!=INVALID_FILE_ATTRIBUTES &&\n             (attr & FILE_ATTRIBUTE_READONLY)==0;\n      break;\n    default:\n      assert(!\"Invalid flags argument\");\n  }\n  *pResOut = rc;\n  OSTRACE((\"ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\\n\",\n           zFilename, pResOut, *pResOut));\n  return SQLITE_OK;\n}\n\n/*\n** Returns non-zero if the specified path name starts with a drive letter\n** followed by a colon character.\n*/\nstatic BOOL winIsDriveLetterAndColon(\n  const char *zPathname\n){\n  return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' );\n}\n\n/*\n** Returns non-zero if the specified path name should be used verbatim.  If\n** non-zero is returned from this function, the calling function must simply\n** use the provided path name verbatim -OR- resolve it into a full path name\n** using the GetFullPathName Win32 API function (if available).\n*/\nstatic BOOL winIsVerbatimPathname(\n  const char *zPathname\n){\n  /*\n  ** If the path name starts with a forward slash or a backslash, it is either\n  ** a legal UNC name, a volume relative path, or an absolute path name in the\n  ** \"Unix\" format on Windows.  There is no easy way to differentiate between\n  ** the final two cases; therefore, we return the safer return value of TRUE\n  ** so that callers of this function will simply use it verbatim.\n  */\n  if ( winIsDirSep(zPathname[0]) ){\n    return TRUE;\n  }\n\n  /*\n  ** If the path name starts with a letter and a colon it is either a volume\n  ** relative path or an absolute path.  Callers of this function must not\n  ** attempt to treat it as a relative path name (i.e. they should simply use\n  ** it verbatim).\n  */\n  if ( winIsDriveLetterAndColon(zPathname) ){\n    return TRUE;\n  }\n\n  /*\n  ** If we get to this point, the path name should almost certainly be a purely\n  ** relative one (i.e. not a UNC name, not absolute, and not volume relative).\n  */\n  return FALSE;\n}\n\n/*\n** Turn a relative pathname into a full pathname.  Write the full\n** pathname into zOut[].  zOut[] will be at least pVfs->mxPathname\n** bytes in size.\n*/\nstatic int winFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zRelative,        /* Possibly relative input path */\n  int nFull,                    /* Size of output buffer in bytes */\n  char *zFull                   /* Output buffer */\n){\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  DWORD nByte;\n  void *zConverted;\n  char *zOut;\n#endif\n\n  /* If this path name begins with \"/X:\", where \"X\" is any alphabetic\n  ** character, discard the initial \"/\" from the pathname.\n  */\n  if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){\n    zRelative++;\n  }\n\n#if defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  UNUSED_PARAMETER(nFull);\n  assert( nFull>=pVfs->mxPathname );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a slash.\n    */\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |\n            CCP_RELATIVE, zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname1\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                       sqlite3_data_directory, winGetDirSep(), zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }else{\n    char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );\n    if( !zOut ){\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    if( cygwin_conv_path(\n            (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A),\n            zRelative, zOut, pVfs->mxPathname+1)<0 ){\n      sqlite3_free(zOut);\n      return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,\n                         \"winFullPathname2\", zRelative);\n    }else{\n      char *zUtf8 = winConvertToUtf8Filename(zOut);\n      if( !zUtf8 ){\n        sqlite3_free(zOut);\n        return SQLITE_IOERR_NOMEM_BKPT;\n      }\n      sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zUtf8);\n      sqlite3_free(zUtf8);\n      sqlite3_free(zOut);\n    }\n  }\n  return SQLITE_OK;\n#endif\n\n#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)\n  SimulateIOError( return SQLITE_ERROR );\n  /* WinCE has no concept of a relative pathname, or so I am told. */\n  /* WinRT has no way to convert a relative path to an absolute one. */\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n  }else{\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zRelative);\n  }\n  return SQLITE_OK;\n#endif\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__)\n  /* It's odd to simulate an io-error here, but really this is just\n  ** using the io-error infrastructure to test that SQLite handles this\n  ** function failing. This function could fail if, for example, the\n  ** current working directory has been unlinked.\n  */\n  SimulateIOError( return SQLITE_ERROR );\n  if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){\n    /*\n    ** NOTE: We are dealing with a relative path name and the data\n    **       directory has been set.  Therefore, use it as the basis\n    **       for converting the relative path name to an absolute\n    **       one by prepending the data directory and a backslash.\n    */\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s%c%s\",\n                     sqlite3_data_directory, winGetDirSep(), zRelative);\n    return SQLITE_OK;\n  }\n  zConverted = winConvertFromUtf8Filename(zRelative);\n  if( zConverted==0 ){\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n  if( osIsNT() ){\n    LPWSTR zTemp;\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname1\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname2\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winUnicodeToUtf8(zTemp);\n    sqlite3_free(zTemp);\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    char *zTemp;\n    nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname3\", zRelative);\n    }\n    nByte += 3;\n    zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );\n    if( zTemp==0 ){\n      sqlite3_free(zConverted);\n      return SQLITE_IOERR_NOMEM_BKPT;\n    }\n    nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);\n    if( nByte==0 ){\n      sqlite3_free(zConverted);\n      sqlite3_free(zTemp);\n      return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),\n                         \"winFullPathname4\", zRelative);\n    }\n    sqlite3_free(zConverted);\n    zOut = winMbcsToUtf8(zTemp, osAreFileApisANSI());\n    sqlite3_free(zTemp);\n  }\n#endif\n  if( zOut ){\n    sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, \"%s\", zOut);\n    sqlite3_free(zOut);\n    return SQLITE_OK;\n  }else{\n    return SQLITE_IOERR_NOMEM_BKPT;\n  }\n#endif\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Interfaces for opening a shared library, finding entry points\n** within the shared library, and closing the shared library.\n*/\nstatic void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){\n  HANDLE h;\n#if defined(__CYGWIN__)\n  int nFull = pVfs->mxPathname+1;\n  char *zFull = sqlite3MallocZero( nFull );\n  void *zConverted = 0;\n  if( zFull==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( winFullPathname(pVfs, zFilename, nFull, zFull)!=SQLITE_OK ){\n    sqlite3_free(zFull);\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  zConverted = winConvertFromUtf8Filename(zFull);\n  sqlite3_free(zFull);\n#else\n  void *zConverted = winConvertFromUtf8Filename(zFilename);\n  UNUSED_PARAMETER(pVfs);\n#endif\n  if( zConverted==0 ){\n    OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)0));\n    return 0;\n  }\n  if( osIsNT() ){\n#if SQLITE_OS_WINRT\n    h = osLoadPackagedLibrary((LPCWSTR)zConverted, 0);\n#else\n    h = osLoadLibraryW((LPCWSTR)zConverted);\n#endif\n  }\n#ifdef SQLITE_WIN32_HAS_ANSI\n  else{\n    h = osLoadLibraryA((char*)zConverted);\n  }\n#endif\n  OSTRACE((\"DLOPEN name=%s, handle=%p\\n\", zFilename, (void*)h));\n  sqlite3_free(zConverted);\n  return (void*)h;\n}\nstatic void winDlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){\n  UNUSED_PARAMETER(pVfs);\n  winGetLastErrorMsg(osGetLastError(), nBuf, zBufOut);\n}\nstatic void (*winDlSym(sqlite3_vfs *pVfs,void *pH,const char *zSym))(void){\n  FARPROC proc;\n  UNUSED_PARAMETER(pVfs);\n  proc = osGetProcAddressA((HANDLE)pH, zSym);\n  OSTRACE((\"DLSYM handle=%p, symbol=%s, address=%p\\n\",\n           (void*)pH, zSym, (void*)proc));\n  return (void(*)(void))proc;\n}\nstatic void winDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  UNUSED_PARAMETER(pVfs);\n  osFreeLibrary((HANDLE)pHandle);\n  OSTRACE((\"DLCLOSE handle=%p\\n\", (void*)pHandle));\n}\n#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */\n  #define winDlOpen  0\n  #define winDlError 0\n  #define winDlSym   0\n  #define winDlClose 0\n#endif\n\n/* State information for the randomness gatherer. */\ntypedef struct EntropyGatherer EntropyGatherer;\nstruct EntropyGatherer {\n  unsigned char *a;   /* Gather entropy into this buffer */\n  int na;             /* Size of a[] in bytes */\n  int i;              /* XOR next input into a[i] */\n  int nXor;           /* Number of XOR operations done */\n};\n\n#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)\n/* Mix sz bytes of entropy into p. */\nstatic void xorMemory(EntropyGatherer *p, unsigned char *x, int sz){\n  int j, k;\n  for(j=0, k=p->i; j<sz; j++){\n    p->a[k++] ^= x[j];\n    if( k>=p->na ) k = 0;\n  }\n  p->i = k;\n  p->nXor += sz;\n}\n#endif /* !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS) */\n\n/*\n** Write up to nBuf bytes of randomness into zBuf.\n*/\nstatic int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n#if defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS)\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  return nBuf;\n#else\n  EntropyGatherer e;\n  UNUSED_PARAMETER(pVfs);\n  memset(zBuf, 0, nBuf);\n  e.a = (unsigned char*)zBuf;\n  e.na = nBuf;\n  e.nXor = 0;\n  e.i = 0;\n  {\n    SYSTEMTIME x;\n    osGetSystemTime(&x);\n    xorMemory(&e, (unsigned char*)&x, sizeof(SYSTEMTIME));\n  }\n  {\n    DWORD pid = osGetCurrentProcessId();\n    xorMemory(&e, (unsigned char*)&pid, sizeof(DWORD));\n  }\n#if SQLITE_OS_WINRT\n  {\n    ULONGLONG cnt = osGetTickCount64();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(ULONGLONG));\n  }\n#else\n  {\n    DWORD cnt = osGetTickCount();\n    xorMemory(&e, (unsigned char*)&cnt, sizeof(DWORD));\n  }\n#endif /* SQLITE_OS_WINRT */\n  {\n    LARGE_INTEGER i;\n    osQueryPerformanceCounter(&i);\n    xorMemory(&e, (unsigned char*)&i, sizeof(LARGE_INTEGER));\n  }\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID\n  {\n    UUID id;\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreate(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n    memset(&id, 0, sizeof(UUID));\n    osUuidCreateSequential(&id);\n    xorMemory(&e, (unsigned char*)&id, sizeof(UUID));\n  }\n#endif /* !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID */\n  return e.nXor>nBuf ? nBuf : e.nXor;\n#endif /* defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS) */\n}\n\n\n/*\n** Sleep for a little while.  Return the amount of time slept.\n*/\nstatic int winSleep(sqlite3_vfs *pVfs, int microsec){\n  sqlite3_win32_sleep((microsec+999)/1000);\n  UNUSED_PARAMETER(pVfs);\n  return ((microsec+999)/1000)*1000;\n}\n\n/*\n** The following variable, if set to a non-zero value, is interpreted as\n** the number of seconds since 1970 and is used to set the result of\n** sqlite3OsCurrentTime() during testing.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_current_time = 0;  /* Fake system time in seconds since 1970. */\n#endif\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write into *piNow\n** the current time and date as a Julian Day number times 86_400_000.  In\n** other words, write into *piNow the number of milliseconds since the Julian\n** epoch of noon in Greenwich on November 24, 4714 B.C according to the\n** proleptic Gregorian calendar.\n**\n** On success, return SQLITE_OK.  Return SQLITE_ERROR if the time and date\n** cannot be found.\n*/\nstatic int winCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){\n  /* FILETIME structure is a 64-bit value representing the number of\n     100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).\n  */\n  FILETIME ft;\n  static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;\n#ifdef SQLITE_TEST\n  static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;\n#endif\n  /* 2^32 - to avoid use of LL and warnings in gcc */\n  static const sqlite3_int64 max32BitValue =\n      (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +\n      (sqlite3_int64)294967296;\n\n#if SQLITE_OS_WINCE\n  SYSTEMTIME time;\n  osGetSystemTime(&time);\n  /* if SystemTimeToFileTime() fails, it returns zero. */\n  if (!osSystemTimeToFileTime(&time,&ft)){\n    return SQLITE_ERROR;\n  }\n#else\n  osGetSystemTimeAsFileTime( &ft );\n#endif\n\n  *piNow = winFiletimeEpoch +\n            ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +\n               (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;\n\n#ifdef SQLITE_TEST\n  if( sqlite3_current_time ){\n    *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch;\n  }\n#endif\n  UNUSED_PARAMETER(pVfs);\n  return SQLITE_OK;\n}\n\n/*\n** Find the current time (in Universal Coordinated Time).  Write the\n** current time and date as a Julian Day number into *prNow and\n** return 0.  Return 1 if the time and date cannot be found.\n*/\nstatic int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){\n  int rc;\n  sqlite3_int64 i;\n  rc = winCurrentTimeInt64(pVfs, &i);\n  if( !rc ){\n    *prNow = i/86400000.0;\n  }\n  return rc;\n}\n\n/*\n** The idea is that this function works like a combination of\n** GetLastError() and FormatMessage() on Windows (or errno and\n** strerror_r() on Unix). After an error is returned by an OS\n** function, SQLite calls this function with zBuf pointing to\n** a buffer of nBuf bytes. The OS layer should populate the\n** buffer with a nul-terminated UTF-8 encoded error message\n** describing the last IO error to have occurred within the calling\n** thread.\n**\n** If the error message is too large for the supplied buffer,\n** it should be truncated. The return value of xGetLastError\n** is zero if the error message fits in the buffer, or non-zero\n** otherwise (if the message was truncated). If non-zero is returned,\n** then it is not necessary to include the nul-terminator character\n** in the output buffer.\n**\n** Not supplying an error message will have no adverse effect\n** on SQLite. It is fine to have an implementation that never\n** returns an error message:\n**\n**   int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n**     assert(zBuf[0]=='\\0');\n**     return 0;\n**   }\n**\n** However if an error message is supplied, it will be incorporated\n** by sqlite into the error message available to the user using\n** sqlite3_errmsg(), possibly making IO errors easier to debug.\n*/\nstatic int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){\n  DWORD e = osGetLastError();\n  UNUSED_PARAMETER(pVfs);\n  if( nBuf>0 ) winGetLastErrorMsg(e, nBuf, zBuf);\n  return e;\n}\n\n/*\n** Initialize and deinitialize the operating system interface.\n*/\nint sqlite3_os_init(void){\n  static sqlite3_vfs winVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32\",               /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath\",      /* zName */\n    &winAppData,           /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n  static sqlite3_vfs winNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-none\",          /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  static sqlite3_vfs winLongPathNolockVfs = {\n    3,                     /* iVersion */\n    sizeof(winFile),       /* szOsFile */\n    SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */\n    0,                     /* pNext */\n    \"win32-longpath-none\", /* zName */\n    &winNolockAppData,     /* pAppData */\n    winOpen,               /* xOpen */\n    winDelete,             /* xDelete */\n    winAccess,             /* xAccess */\n    winFullPathname,       /* xFullPathname */\n    winDlOpen,             /* xDlOpen */\n    winDlError,            /* xDlError */\n    winDlSym,              /* xDlSym */\n    winDlClose,            /* xDlClose */\n    winRandomness,         /* xRandomness */\n    winSleep,              /* xSleep */\n    winCurrentTime,        /* xCurrentTime */\n    winGetLastError,       /* xGetLastError */\n    winCurrentTimeInt64,   /* xCurrentTimeInt64 */\n    winSetSystemCall,      /* xSetSystemCall */\n    winGetSystemCall,      /* xGetSystemCall */\n    winNextSystemCall,     /* xNextSystemCall */\n  };\n#endif\n\n  /* Double-check that the aSyscall[] array has been constructed\n  ** correctly.  See ticket [bb3a86e890c8e96ab] */\n  assert( ArraySize(aSyscall)==80 );\n\n  /* get memory map allocation granularity */\n  memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));\n#if SQLITE_OS_WINRT\n  osGetNativeSystemInfo(&winSysInfo);\n#else\n  osGetSystemInfo(&winSysInfo);\n#endif\n  assert( winSysInfo.dwAllocationGranularity>0 );\n  assert( winSysInfo.dwPageSize>0 );\n\n  sqlite3_vfs_register(&winVfs, 1);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathVfs, 0);\n#endif\n\n  sqlite3_vfs_register(&winNolockVfs, 0);\n\n#if defined(SQLITE_WIN32_HAS_WIDE)\n  sqlite3_vfs_register(&winLongPathNolockVfs, 0);\n#endif\n\n  return SQLITE_OK;\n}\n\nint sqlite3_os_end(void){\n#if SQLITE_OS_WINRT\n  if( sleepObj!=NULL ){\n    osCloseHandle(sleepObj);\n    sleepObj = NULL;\n  }\n#endif\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OS_WIN */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/os_win.h",
    "content": "/*\n** 2013 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Windows.\n*/\n#ifndef SQLITE_OS_WIN_H\n#define SQLITE_OS_WIN_H\n\n/*\n** Include the primary Windows SDK header file.\n*/\n#include \"windows.h\"\n\n#ifdef __CYGWIN__\n# include <sys/cygwin.h>\n# include <errno.h> /* amalgamator: dontcache */\n#endif\n\n/*\n** Determine if we are dealing with Windows NT.\n**\n** We ought to be able to determine if we are compiling for Windows 9x or\n** Windows NT using the _WIN32_WINNT macro as follows:\n**\n** #if defined(_WIN32_WINNT)\n** # define SQLITE_OS_WINNT 1\n** #else\n** # define SQLITE_OS_WINNT 0\n** #endif\n**\n** However, Visual Studio 2005 does not set _WIN32_WINNT by default, as\n** it ought to, so the above test does not work.  We'll just assume that\n** everything is Windows NT unless the programmer explicitly says otherwise\n** by setting SQLITE_OS_WINNT to 0.\n*/\n#if SQLITE_OS_WIN && !defined(SQLITE_OS_WINNT)\n# define SQLITE_OS_WINNT 1\n#endif\n\n/*\n** Determine if we are dealing with Windows CE - which has a much reduced\n** API.\n*/\n#if defined(_WIN32_WCE)\n# define SQLITE_OS_WINCE 1\n#else\n# define SQLITE_OS_WINCE 0\n#endif\n\n/*\n** Determine if we are dealing with WinRT, which provides only a subset of\n** the full Win32 API.\n*/\n#if !defined(SQLITE_OS_WINRT)\n# define SQLITE_OS_WINRT 0\n#endif\n\n/*\n** For WinCE, some API function parameters do not appear to be declared as\n** volatile.\n*/\n#if SQLITE_OS_WINCE\n# define SQLITE_WIN32_VOLATILE\n#else\n# define SQLITE_WIN32_VOLATILE volatile\n#endif\n\n/*\n** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()\n** functions are not available (e.g. those not using MSVC, Cygwin, etc).\n*/\n#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \\\n    SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)\n# define SQLITE_OS_WIN_THREADS 1\n#else\n# define SQLITE_OS_WIN_THREADS 0\n#endif\n\n#endif /* SQLITE_OS_WIN_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pager.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the implementation of the page cache subsystem or \"pager\".\n** \n** The pager is used to access a database disk file.  It implements\n** atomic commit and rollback through the use of a journal file that\n** is separate from the database file.  The pager also implements file\n** locking to prevent two processes from writing the same database\n** file simultaneously, or one process from reading the database while\n** another is writing.\n*/\n#ifndef SQLITE_OMIT_DISKIO\n#include \"sqliteInt.h\"\n#include \"wal.h\"\n\n\n/******************* NOTES ON THE DESIGN OF THE PAGER ************************\n**\n** This comment block describes invariants that hold when using a rollback\n** journal.  These invariants do not apply for journal_mode=WAL,\n** journal_mode=MEMORY, or journal_mode=OFF.\n**\n** Within this comment block, a page is deemed to have been synced\n** automatically as soon as it is written when PRAGMA synchronous=OFF.\n** Otherwise, the page is not synced until the xSync method of the VFS\n** is called successfully on the file containing the page.\n**\n** Definition:  A page of the database file is said to be \"overwriteable\" if\n** one or more of the following are true about the page:\n** \n**     (a)  The original content of the page as it was at the beginning of\n**          the transaction has been written into the rollback journal and\n**          synced.\n** \n**     (b)  The page was a freelist leaf page at the start of the transaction.\n** \n**     (c)  The page number is greater than the largest page that existed in\n**          the database file at the start of the transaction.\n** \n** (1) A page of the database file is never overwritten unless one of the\n**     following are true:\n** \n**     (a) The page and all other pages on the same sector are overwriteable.\n** \n**     (b) The atomic page write optimization is enabled, and the entire\n**         transaction other than the update of the transaction sequence\n**         number consists of a single page change.\n** \n** (2) The content of a page written into the rollback journal exactly matches\n**     both the content in the database when the rollback journal was written\n**     and the content in the database at the beginning of the current\n**     transaction.\n** \n** (3) Writes to the database file are an integer multiple of the page size\n**     in length and are aligned on a page boundary.\n** \n** (4) Reads from the database file are either aligned on a page boundary and\n**     an integer multiple of the page size in length or are taken from the\n**     first 100 bytes of the database file.\n** \n** (5) All writes to the database file are synced prior to the rollback journal\n**     being deleted, truncated, or zeroed.\n** \n** (6) If a master journal file is used, then all writes to the database file\n**     are synced prior to the master journal being deleted.\n** \n** Definition: Two databases (or the same database at two points it time)\n** are said to be \"logically equivalent\" if they give the same answer to\n** all queries.  Note in particular the content of freelist leaf\n** pages can be changed arbitrarily without affecting the logical equivalence\n** of the database.\n** \n** (7) At any time, if any subset, including the empty set and the total set,\n**     of the unsynced changes to a rollback journal are removed and the \n**     journal is rolled back, the resulting database file will be logically\n**     equivalent to the database file at the beginning of the transaction.\n** \n** (8) When a transaction is rolled back, the xTruncate method of the VFS\n**     is called to restore the database file to the same size it was at\n**     the beginning of the transaction.  (In some VFSes, the xTruncate\n**     method is a no-op, but that does not change the fact the SQLite will\n**     invoke it.)\n** \n** (9) Whenever the database file is modified, at least one bit in the range\n**     of bytes from 24 through 39 inclusive will be changed prior to releasing\n**     the EXCLUSIVE lock, thus signaling other connections on the same\n**     database to flush their caches.\n**\n** (10) The pattern of bits in bytes 24 through 39 shall not repeat in less\n**      than one billion transactions.\n**\n** (11) A database file is well-formed at the beginning and at the conclusion\n**      of every transaction.\n**\n** (12) An EXCLUSIVE lock is held on the database file when writing to\n**      the database file.\n**\n** (13) A SHARED lock is held on the database file while reading any\n**      content out of the database file.\n**\n******************************************************************************/\n\n/*\n** Macros for troubleshooting.  Normally turned off\n*/\n#if 0\nint sqlite3PagerTrace=1;  /* True to enable tracing */\n#define sqlite3DebugPrintf printf\n#define PAGERTRACE(X)     if( sqlite3PagerTrace ){ sqlite3DebugPrintf X; }\n#else\n#define PAGERTRACE(X)\n#endif\n\n/*\n** The following two macros are used within the PAGERTRACE() macros above\n** to print out file-descriptors. \n**\n** PAGERID() takes a pointer to a Pager struct as its argument. The\n** associated file-descriptor is returned. FILEHANDLEID() takes an sqlite3_file\n** struct as its argument.\n*/\n#define PAGERID(p) (SQLITE_PTR_TO_INT(p->fd))\n#define FILEHANDLEID(fd) (SQLITE_PTR_TO_INT(fd))\n\n/*\n** The Pager.eState variable stores the current 'state' of a pager. A\n** pager may be in any one of the seven states shown in the following\n** state diagram.\n**\n**                            OPEN <------+------+\n**                              |         |      |\n**                              V         |      |\n**               +---------> READER-------+      |\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_LOCKED------> ERROR\n**               |              |                ^  \n**               |              V                |\n**               |<------WRITER_CACHEMOD-------->|\n**               |              |                |\n**               |              V                |\n**               |<-------WRITER_DBMOD---------->|\n**               |              |                |\n**               |              V                |\n**               +<------WRITER_FINISHED-------->+\n**\n**\n** List of state transitions and the C [function] that performs each:\n** \n**   OPEN              -> READER              [sqlite3PagerSharedLock]\n**   READER            -> OPEN                [pager_unlock]\n**\n**   READER            -> WRITER_LOCKED       [sqlite3PagerBegin]\n**   WRITER_LOCKED     -> WRITER_CACHEMOD     [pager_open_journal]\n**   WRITER_CACHEMOD   -> WRITER_DBMOD        [syncJournal]\n**   WRITER_DBMOD      -> WRITER_FINISHED     [sqlite3PagerCommitPhaseOne]\n**   WRITER_***        -> READER              [pager_end_transaction]\n**\n**   WRITER_***        -> ERROR               [pager_error]\n**   ERROR             -> OPEN                [pager_unlock]\n** \n**\n**  OPEN:\n**\n**    The pager starts up in this state. Nothing is guaranteed in this\n**    state - the file may or may not be locked and the database size is\n**    unknown. The database may not be read or written.\n**\n**    * No read or write transaction is active.\n**    * Any lock, or no lock at all, may be held on the database file.\n**    * The dbSize, dbOrigSize and dbFileSize variables may not be trusted.\n**\n**  READER:\n**\n**    In this state all the requirements for reading the database in \n**    rollback (non-WAL) mode are met. Unless the pager is (or recently\n**    was) in exclusive-locking mode, a user-level read transaction is \n**    open. The database size is known in this state.\n**\n**    A connection running with locking_mode=normal enters this state when\n**    it opens a read-transaction on the database and returns to state\n**    OPEN after the read-transaction is completed. However a connection\n**    running in locking_mode=exclusive (including temp databases) remains in\n**    this state even after the read-transaction is closed. The only way\n**    a locking_mode=exclusive connection can transition from READER to OPEN\n**    is via the ERROR state (see below).\n** \n**    * A read transaction may be active (but a write-transaction cannot).\n**    * A SHARED or greater lock is held on the database file.\n**    * The dbSize variable may be trusted (even if a user-level read \n**      transaction is not active). The dbOrigSize and dbFileSize variables\n**      may not be trusted at this point.\n**    * If the database is a WAL database, then the WAL connection is open.\n**    * Even if a read-transaction is not open, it is guaranteed that \n**      there is no hot-journal in the file-system.\n**\n**  WRITER_LOCKED:\n**\n**    The pager moves to this state from READER when a write-transaction\n**    is first opened on the database. In WRITER_LOCKED state, all locks \n**    required to start a write-transaction are held, but no actual \n**    modifications to the cache or database have taken place.\n**\n**    In rollback mode, a RESERVED or (if the transaction was opened with \n**    BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when\n**    moving to this state, but the journal file is not written to or opened \n**    to in this state. If the transaction is committed or rolled back while \n**    in WRITER_LOCKED state, all that is required is to unlock the database \n**    file.\n**\n**    IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.\n**    If the connection is running with locking_mode=exclusive, an attempt\n**    is made to obtain an EXCLUSIVE lock on the database file.\n**\n**    * A write transaction is active.\n**    * If the connection is open in rollback-mode, a RESERVED or greater \n**      lock is held on the database file.\n**    * If the connection is open in WAL-mode, a WAL write transaction\n**      is open (i.e. sqlite3WalBeginWriteTransaction() has been successfully\n**      called).\n**    * The dbSize, dbOrigSize and dbFileSize variables are all valid.\n**    * The contents of the pager cache have not been modified.\n**    * The journal file may or may not be open.\n**    * Nothing (not even the first header) has been written to the journal.\n**\n**  WRITER_CACHEMOD:\n**\n**    A pager moves from WRITER_LOCKED state to this state when a page is\n**    first modified by the upper layer. In rollback mode the journal file\n**    is opened (if it is not already open) and a header written to the\n**    start of it. The database file on disk has not been modified.\n**\n**    * A write transaction is active.\n**    * A RESERVED or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      to it, but the header has not been synced to disk.\n**    * The contents of the page cache have been modified.\n**\n**  WRITER_DBMOD:\n**\n**    The pager transitions from WRITER_CACHEMOD into WRITER_DBMOD state\n**    when it modifies the contents of the database file. WAL connections\n**    never enter this state (since they do not modify the database file,\n**    just the log file).\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * The journal file is open and the first header has been written \n**      and synced to disk.\n**    * The contents of the page cache have been modified (and possibly\n**      written to disk).\n**\n**  WRITER_FINISHED:\n**\n**    It is not possible for a WAL connection to enter this state.\n**\n**    A rollback-mode pager changes to WRITER_FINISHED state from WRITER_DBMOD\n**    state after the entire transaction has been successfully written into the\n**    database file. In this state the transaction may be committed simply\n**    by finalizing the journal file. Once in WRITER_FINISHED state, it is \n**    not possible to modify the database further. At this point, the upper \n**    layer must either commit or rollback the transaction.\n**\n**    * A write transaction is active.\n**    * An EXCLUSIVE or greater lock is held on the database file.\n**    * All writing and syncing of journal and database data has finished.\n**      If no error occurred, all that remains is to finalize the journal to\n**      commit the transaction. If an error did occur, the caller will need\n**      to rollback the transaction. \n**\n**  ERROR:\n**\n**    The ERROR state is entered when an IO or disk-full error (including\n**    SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it \n**    difficult to be sure that the in-memory pager state (cache contents, \n**    db size etc.) are consistent with the contents of the file-system.\n**\n**    Temporary pager files may enter the ERROR state, but in-memory pagers\n**    cannot.\n**\n**    For example, if an IO error occurs while performing a rollback, \n**    the contents of the page-cache may be left in an inconsistent state.\n**    At this point it would be dangerous to change back to READER state\n**    (as usually happens after a rollback). Any subsequent readers might\n**    report database corruption (due to the inconsistent cache), and if\n**    they upgrade to writers, they may inadvertently corrupt the database\n**    file. To avoid this hazard, the pager switches into the ERROR state\n**    instead of READER following such an error.\n**\n**    Once it has entered the ERROR state, any attempt to use the pager\n**    to read or write data returns an error. Eventually, once all \n**    outstanding transactions have been abandoned, the pager is able to\n**    transition back to OPEN state, discarding the contents of the \n**    page-cache and any other in-memory state at the same time. Everything\n**    is reloaded from disk (and, if necessary, hot-journal rollback peformed)\n**    when a read-transaction is next opened on the pager (transitioning\n**    the pager into READER state). At that point the system has recovered \n**    from the error.\n**\n**    Specifically, the pager jumps into the ERROR state if:\n**\n**      1. An error occurs while attempting a rollback. This happens in\n**         function sqlite3PagerRollback().\n**\n**      2. An error occurs while attempting to finalize a journal file\n**         following a commit in function sqlite3PagerCommitPhaseTwo().\n**\n**      3. An error occurs while attempting to write to the journal or\n**         database file in function pagerStress() in order to free up\n**         memory.\n**\n**    In other cases, the error is returned to the b-tree layer. The b-tree\n**    layer then attempts a rollback operation. If the error condition \n**    persists, the pager enters the ERROR state via condition (1) above.\n**\n**    Condition (3) is necessary because it can be triggered by a read-only\n**    statement executed within a transaction. In this case, if the error\n**    code were simply returned to the user, the b-tree layer would not\n**    automatically attempt a rollback, as it assumes that an error in a\n**    read-only statement cannot leave the pager in an internally inconsistent \n**    state.\n**\n**    * The Pager.errCode variable is set to something other than SQLITE_OK.\n**    * There are one or more outstanding references to pages (after the\n**      last reference is dropped the pager should move back to OPEN state).\n**    * The pager is not an in-memory pager.\n**    \n**\n** Notes:\n**\n**   * A pager is never in WRITER_DBMOD or WRITER_FINISHED state if the\n**     connection is open in WAL mode. A WAL connection is always in one\n**     of the first four states.\n**\n**   * Normally, a connection open in exclusive mode is never in PAGER_OPEN\n**     state. There are two exceptions: immediately after exclusive-mode has\n**     been turned on (and before any read or write transactions are \n**     executed), and when the pager is leaving the \"error state\".\n**\n**   * See also: assert_pager_state().\n*/\n#define PAGER_OPEN                  0\n#define PAGER_READER                1\n#define PAGER_WRITER_LOCKED         2\n#define PAGER_WRITER_CACHEMOD       3\n#define PAGER_WRITER_DBMOD          4\n#define PAGER_WRITER_FINISHED       5\n#define PAGER_ERROR                 6\n\n/*\n** The Pager.eLock variable is almost always set to one of the \n** following locking-states, according to the lock currently held on\n** the database file: NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n** This variable is kept up to date as locks are taken and released by\n** the pagerLockDb() and pagerUnlockDb() wrappers.\n**\n** If the VFS xLock() or xUnlock() returns an error other than SQLITE_BUSY\n** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not\n** the operation was successful. In these circumstances pagerLockDb() and\n** pagerUnlockDb() take a conservative approach - eLock is always updated\n** when unlocking the file, and only updated when locking the file if the\n** VFS call is successful. This way, the Pager.eLock variable may be set\n** to a less exclusive (lower) value than the lock that is actually held\n** at the system level, but it is never set to a more exclusive value.\n**\n** This is usually safe. If an xUnlock fails or appears to fail, there may \n** be a few redundant xLock() calls or a lock may be held for longer than\n** required, but nothing really goes wrong.\n**\n** The exception is when the database file is unlocked as the pager moves\n** from ERROR to OPEN state. At this point there may be a hot-journal file \n** in the file-system that needs to be rolled back (as part of an OPEN->SHARED\n** transition, by the same pager or any other). If the call to xUnlock()\n** fails at this point and the pager is left holding an EXCLUSIVE lock, this\n** can confuse the call to xCheckReservedLock() call made later as part\n** of hot-journal detection.\n**\n** xCheckReservedLock() is defined as returning true \"if there is a RESERVED \n** lock held by this process or any others\". So xCheckReservedLock may \n** return true because the caller itself is holding an EXCLUSIVE lock (but\n** doesn't know it because of a previous error in xUnlock). If this happens\n** a hot-journal may be mistaken for a journal being created by an active\n** transaction in another process, causing SQLite to read from the database\n** without rolling it back.\n**\n** To work around this, if a call to xUnlock() fails when unlocking the\n** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It\n** is only changed back to a real locking state after a successful call\n** to xLock(EXCLUSIVE). Also, the code to do the OPEN->SHARED state transition\n** omits the check for a hot-journal if Pager.eLock is set to UNKNOWN_LOCK \n** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE\n** lock on the database file before attempting to roll it back. See function\n** PagerSharedLock() for more detail.\n**\n** Pager.eLock may only be set to UNKNOWN_LOCK when the pager is in \n** PAGER_OPEN state.\n*/\n#define UNKNOWN_LOCK                (EXCLUSIVE_LOCK+1)\n\n/*\n** A macro used for invoking the codec if there is one\n*/\n#ifdef SQLITE_HAS_CODEC\n# define CODEC1(P,D,N,X,E) \\\n    if( P->xCodec && P->xCodec(P->pCodec,D,N,X)==0 ){ E; }\n# define CODEC2(P,D,N,X,E,O) \\\n    if( P->xCodec==0 ){ O=(char*)D; }else \\\n    if( (O=(char*)(P->xCodec(P->pCodec,D,N,X)))==0 ){ E; }\n#else\n# define CODEC1(P,D,N,X,E)   /* NO-OP */\n# define CODEC2(P,D,N,X,E,O) O=(char*)D\n#endif\n\n/*\n** The maximum allowed sector size. 64KiB. If the xSectorsize() method \n** returns a value larger than this, then MAX_SECTOR_SIZE is used instead.\n** This could conceivably cause corruption following a power failure on\n** such a system. This is currently an undocumented limit.\n*/\n#define MAX_SECTOR_SIZE 0x10000\n\n\n/*\n** An instance of the following structure is allocated for each active\n** savepoint and statement transaction in the system. All such structures\n** are stored in the Pager.aSavepoint[] array, which is allocated and\n** resized using sqlite3Realloc().\n**\n** When a savepoint is created, the PagerSavepoint.iHdrOffset field is\n** set to 0. If a journal-header is written into the main journal while\n** the savepoint is active, then iHdrOffset is set to the byte offset \n** immediately following the last journal record written into the main\n** journal before the journal-header. This is required during savepoint\n** rollback (see pagerPlaybackSavepoint()).\n*/\ntypedef struct PagerSavepoint PagerSavepoint;\nstruct PagerSavepoint {\n  i64 iOffset;                 /* Starting offset in main journal */\n  i64 iHdrOffset;              /* See above */\n  Bitvec *pInSavepoint;        /* Set of pages in this savepoint */\n  Pgno nOrig;                  /* Original number of pages in file */\n  Pgno iSubRec;                /* Index of first record in sub-journal */\n#ifndef SQLITE_OMIT_WAL\n  u32 aWalData[WAL_SAVEPOINT_NDATA];        /* WAL savepoint context */\n#endif\n};\n\n/*\n** Bits of the Pager.doNotSpill flag.  See further description below.\n*/\n#define SPILLFLAG_OFF         0x01 /* Never spill cache.  Set via pragma */\n#define SPILLFLAG_ROLLBACK    0x02 /* Current rolling back, so do not spill */\n#define SPILLFLAG_NOSYNC      0x04 /* Spill is ok, but do not sync */\n\n/*\n** An open page cache is an instance of struct Pager. A description of\n** some of the more important member variables follows:\n**\n** eState\n**\n**   The current 'state' of the pager object. See the comment and state\n**   diagram above for a description of the pager state.\n**\n** eLock\n**\n**   For a real on-disk database, the current lock held on the database file -\n**   NO_LOCK, SHARED_LOCK, RESERVED_LOCK or EXCLUSIVE_LOCK.\n**\n**   For a temporary or in-memory database (neither of which require any\n**   locks), this variable is always set to EXCLUSIVE_LOCK. Since such\n**   databases always have Pager.exclusiveMode==1, this tricks the pager\n**   logic into thinking that it already has all the locks it will ever\n**   need (and no reason to release them).\n**\n**   In some (obscure) circumstances, this variable may also be set to\n**   UNKNOWN_LOCK. See the comment above the #define of UNKNOWN_LOCK for\n**   details.\n**\n** changeCountDone\n**\n**   This boolean variable is used to make sure that the change-counter \n**   (the 4-byte header field at byte offset 24 of the database file) is \n**   not updated more often than necessary. \n**\n**   It is set to true when the change-counter field is updated, which \n**   can only happen if an exclusive lock is held on the database file.\n**   It is cleared (set to false) whenever an exclusive lock is \n**   relinquished on the database file. Each time a transaction is committed,\n**   The changeCountDone flag is inspected. If it is true, the work of\n**   updating the change-counter is omitted for the current transaction.\n**\n**   This mechanism means that when running in exclusive mode, a connection \n**   need only update the change-counter once, for the first transaction\n**   committed.\n**\n** setMaster\n**\n**   When PagerCommitPhaseOne() is called to commit a transaction, it may\n**   (or may not) specify a master-journal name to be written into the \n**   journal file before it is synced to disk.\n**\n**   Whether or not a journal file contains a master-journal pointer affects \n**   the way in which the journal file is finalized after the transaction is \n**   committed or rolled back when running in \"journal_mode=PERSIST\" mode.\n**   If a journal file does not contain a master-journal pointer, it is\n**   finalized by overwriting the first journal header with zeroes. If\n**   it does contain a master-journal pointer the journal file is finalized \n**   by truncating it to zero bytes, just as if the connection were \n**   running in \"journal_mode=truncate\" mode.\n**\n**   Journal files that contain master journal pointers cannot be finalized\n**   simply by overwriting the first journal-header with zeroes, as the\n**   master journal pointer could interfere with hot-journal rollback of any\n**   subsequently interrupted transaction that reuses the journal file.\n**\n**   The flag is cleared as soon as the journal file is finalized (either\n**   by PagerCommitPhaseTwo or PagerRollback). If an IO error prevents the\n**   journal file from being successfully finalized, the setMaster flag\n**   is cleared anyway (and the pager will move to ERROR state).\n**\n** doNotSpill\n**\n**   This variables control the behavior of cache-spills  (calls made by\n**   the pcache module to the pagerStress() routine to write cached data\n**   to the file-system in order to free up memory).\n**\n**   When bits SPILLFLAG_OFF or SPILLFLAG_ROLLBACK of doNotSpill are set,\n**   writing to the database from pagerStress() is disabled altogether.\n**   The SPILLFLAG_ROLLBACK case is done in a very obscure case that\n**   comes up during savepoint rollback that requires the pcache module\n**   to allocate a new page to prevent the journal file from being written\n**   while it is being traversed by code in pager_playback().  The SPILLFLAG_OFF\n**   case is a user preference.\n** \n**   If the SPILLFLAG_NOSYNC bit is set, writing to the database from\n**   pagerStress() is permitted, but syncing the journal file is not.\n**   This flag is set by sqlite3PagerWrite() when the file-system sector-size\n**   is larger than the database page-size in order to prevent a journal sync\n**   from happening in between the journalling of two pages on the same sector. \n**\n** subjInMemory\n**\n**   This is a boolean variable. If true, then any required sub-journal\n**   is opened as an in-memory journal file. If false, then in-memory\n**   sub-journals are only used for in-memory pager files.\n**\n**   This variable is updated by the upper layer each time a new \n**   write-transaction is opened.\n**\n** dbSize, dbOrigSize, dbFileSize\n**\n**   Variable dbSize is set to the number of pages in the database file.\n**   It is valid in PAGER_READER and higher states (all states except for\n**   OPEN and ERROR). \n**\n**   dbSize is set based on the size of the database file, which may be \n**   larger than the size of the database (the value stored at offset\n**   28 of the database header by the btree). If the size of the file\n**   is not an integer multiple of the page-size, the value stored in\n**   dbSize is rounded down (i.e. a 5KB file with 2K page-size has dbSize==2).\n**   Except, any file that is greater than 0 bytes in size is considered\n**   to have at least one page. (i.e. a 1KB file with 2K page-size leads\n**   to dbSize==1).\n**\n**   During a write-transaction, if pages with page-numbers greater than\n**   dbSize are modified in the cache, dbSize is updated accordingly.\n**   Similarly, if the database is truncated using PagerTruncateImage(), \n**   dbSize is updated.\n**\n**   Variables dbOrigSize and dbFileSize are valid in states \n**   PAGER_WRITER_LOCKED and higher. dbOrigSize is a copy of the dbSize\n**   variable at the start of the transaction. It is used during rollback,\n**   and to determine whether or not pages need to be journalled before\n**   being modified.\n**\n**   Throughout a write-transaction, dbFileSize contains the size of\n**   the file on disk in pages. It is set to a copy of dbSize when the\n**   write-transaction is first opened, and updated when VFS calls are made\n**   to write or truncate the database file on disk. \n**\n**   The only reason the dbFileSize variable is required is to suppress \n**   unnecessary calls to xTruncate() after committing a transaction. If, \n**   when a transaction is committed, the dbFileSize variable indicates \n**   that the database file is larger than the database image (Pager.dbSize), \n**   pager_truncate() is called. The pager_truncate() call uses xFilesize()\n**   to measure the database file on disk, and then truncates it if required.\n**   dbFileSize is not used when rolling back a transaction. In this case\n**   pager_truncate() is called unconditionally (which means there may be\n**   a call to xFilesize() that is not strictly required). In either case,\n**   pager_truncate() may cause the file to become smaller or larger.\n**\n** dbHintSize\n**\n**   The dbHintSize variable is used to limit the number of calls made to\n**   the VFS xFileControl(FCNTL_SIZE_HINT) method. \n**\n**   dbHintSize is set to a copy of the dbSize variable when a\n**   write-transaction is opened (at the same time as dbFileSize and\n**   dbOrigSize). If the xFileControl(FCNTL_SIZE_HINT) method is called,\n**   dbHintSize is increased to the number of pages that correspond to the\n**   size-hint passed to the method call. See pager_write_pagelist() for \n**   details.\n**\n** errCode\n**\n**   The Pager.errCode variable is only ever used in PAGER_ERROR state. It\n**   is set to zero in all other states. In PAGER_ERROR state, Pager.errCode \n**   is always set to SQLITE_FULL, SQLITE_IOERR or one of the SQLITE_IOERR_XXX \n**   sub-codes.\n**\n** syncFlags, walSyncFlags\n**\n**   syncFlags is either SQLITE_SYNC_NORMAL (0x02) or SQLITE_SYNC_FULL (0x03).\n**   syncFlags is used for rollback mode.  walSyncFlags is used for WAL mode\n**   and contains the flags used to sync the checkpoint operations in the\n**   lower two bits, and sync flags used for transaction commits in the WAL\n**   file in bits 0x04 and 0x08.  In other words, to get the correct sync flags\n**   for checkpoint operations, use (walSyncFlags&0x03) and to get the correct\n**   sync flags for transaction commit, use ((walSyncFlags>>2)&0x03).  Note\n**   that with synchronous=NORMAL in WAL mode, transaction commit is not synced\n**   meaning that the 0x04 and 0x08 bits are both zero.\n*/\nstruct Pager {\n  sqlite3_vfs *pVfs;          /* OS functions to use for IO */\n  u8 exclusiveMode;           /* Boolean. True if locking_mode==EXCLUSIVE */\n  u8 journalMode;             /* One of the PAGER_JOURNALMODE_* values */\n  u8 useJournal;              /* Use a rollback journal on this file */\n  u8 noSync;                  /* Do not sync the journal if true */\n  u8 fullSync;                /* Do extra syncs of the journal for robustness */\n  u8 extraSync;               /* sync directory after journal delete */\n  u8 syncFlags;               /* SYNC_NORMAL or SYNC_FULL otherwise */\n  u8 walSyncFlags;            /* See description above */\n  u8 tempFile;                /* zFilename is a temporary or immutable file */\n  u8 noLock;                  /* Do not lock (except in WAL mode) */\n  u8 readOnly;                /* True for a read-only database */\n  u8 memDb;                   /* True to inhibit all file I/O */\n\n  /**************************************************************************\n  ** The following block contains those class members that change during\n  ** routine operation.  Class members not in this block are either fixed\n  ** when the pager is first created or else only change when there is a\n  ** significant mode change (such as changing the page_size, locking_mode,\n  ** or the journal_mode).  From another view, these class members describe\n  ** the \"state\" of the pager, while other class members describe the\n  ** \"configuration\" of the pager.\n  */\n  u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */\n  u8 eLock;                   /* Current lock held on database file */\n  u8 changeCountDone;         /* Set after incrementing the change-counter */\n  u8 setMaster;               /* True if a m-j name has been written to jrnl */\n  u8 doNotSpill;              /* Do not spill the cache when non-zero */\n  u8 subjInMemory;            /* True to use in-memory sub-journals */\n  u8 bUseFetch;               /* True to use xFetch() */\n  u8 hasHeldSharedLock;       /* True if a shared lock has ever been held */\n  Pgno dbSize;                /* Number of pages in the database */\n  Pgno dbOrigSize;            /* dbSize before the current transaction */\n  Pgno dbFileSize;            /* Number of pages in the database file */\n  Pgno dbHintSize;            /* Value passed to FCNTL_SIZE_HINT call */\n  int errCode;                /* One of several kinds of errors */\n  int nRec;                   /* Pages journalled since last j-header written */\n  u32 cksumInit;              /* Quasi-random value added to every checksum */\n  u32 nSubRec;                /* Number of records written to sub-journal */\n  Bitvec *pInJournal;         /* One bit for each page in the database file */\n  sqlite3_file *fd;           /* File descriptor for database */\n  sqlite3_file *jfd;          /* File descriptor for main journal */\n  sqlite3_file *sjfd;         /* File descriptor for sub-journal */\n  i64 journalOff;             /* Current write offset in the journal file */\n  i64 journalHdr;             /* Byte offset to previous journal header */\n  sqlite3_backup *pBackup;    /* Pointer to list of ongoing backup processes */\n  PagerSavepoint *aSavepoint; /* Array of active savepoints */\n  int nSavepoint;             /* Number of elements in aSavepoint[] */\n  u32 iDataVersion;           /* Changes whenever database content changes */\n  char dbFileVers[16];        /* Changes whenever database file changes */\n\n  int nMmapOut;               /* Number of mmap pages currently outstanding */\n  sqlite3_int64 szMmap;       /* Desired maximum mmap size */\n  PgHdr *pMmapFreelist;       /* List of free mmap page headers (pDirty) */\n  /*\n  ** End of the routinely-changing class members\n  ***************************************************************************/\n\n  u16 nExtra;                 /* Add this many bytes to each in-memory page */\n  i16 nReserve;               /* Number of unused bytes at end of each page */\n  u32 vfsFlags;               /* Flags for sqlite3_vfs.xOpen() */\n  u32 sectorSize;             /* Assumed sector size during rollback */\n  int pageSize;               /* Number of bytes in a page */\n  Pgno mxPgno;                /* Maximum allowed size of the database */\n  i64 journalSizeLimit;       /* Size limit for persistent journal files */\n  char *zFilename;            /* Name of the database file */\n  char *zJournal;             /* Name of the journal file */\n  int (*xBusyHandler)(void*); /* Function to call when busy */\n  void *pBusyHandlerArg;      /* Context argument for xBusyHandler */\n  int aStat[3];               /* Total cache hits, misses and writes */\n#ifdef SQLITE_TEST\n  int nRead;                  /* Database pages read */\n#endif\n  void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */\n  int (*xGet)(Pager*,Pgno,DbPage**,int); /* Routine to fetch a patch */\n#ifdef SQLITE_HAS_CODEC\n  void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */\n  void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */\n  void (*xCodecFree)(void*);             /* Destructor for the codec */\n  void *pCodec;               /* First argument to xCodec... methods */\n#endif\n  char *pTmpSpace;            /* Pager.pageSize bytes of space for tmp use */\n  PCache *pPCache;            /* Pointer to page cache object */\n#ifndef SQLITE_OMIT_WAL\n  Wal *pWal;                  /* Write-ahead log used by \"journal_mode=wal\" */\n  char *zWal;                 /* File name for write-ahead log */\n#endif\n};\n\n/*\n** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains\n** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS \n** or CACHE_WRITE to sqlite3_db_status().\n*/\n#define PAGER_STAT_HIT   0\n#define PAGER_STAT_MISS  1\n#define PAGER_STAT_WRITE 2\n\n/*\n** The following global variables hold counters used for\n** testing purposes only.  These variables do not exist in\n** a non-testing build.  These variables are not thread-safe.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_pager_readdb_count = 0;    /* Number of full pages read from DB */\nint sqlite3_pager_writedb_count = 0;   /* Number of full pages written to DB */\nint sqlite3_pager_writej_count = 0;    /* Number of pages written to journal */\n# define PAGER_INCR(v)  v++\n#else\n# define PAGER_INCR(v)\n#endif\n\n\n\n/*\n** Journal files begin with the following magic string.  The data\n** was obtained from /dev/random.  It is used only as a sanity check.\n**\n** Since version 2.8.0, the journal format contains additional sanity\n** checking information.  If the power fails while the journal is being\n** written, semi-random garbage data might appear in the journal\n** file after power is restored.  If an attempt is then made\n** to roll the journal back, the database could be corrupted.  The additional\n** sanity checking data is an attempt to discover the garbage in the\n** journal and ignore it.\n**\n** The sanity checking information for the new journal format consists\n** of a 32-bit checksum on each page of data.  The checksum covers both\n** the page number and the pPager->pageSize bytes of data for the page.\n** This cksum is initialized to a 32-bit random value that appears in the\n** journal file right after the header.  The random initializer is important,\n** because garbage data that appears at the end of a journal is likely\n** data that was once in other files that have now been deleted.  If the\n** garbage data came from an obsolete journal file, the checksums might\n** be correct.  But by initializing the checksum to random value which\n** is different for every journal, we minimize that risk.\n*/\nstatic const unsigned char aJournalMagic[] = {\n  0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7,\n};\n\n/*\n** The size of the of each page record in the journal is given by\n** the following macro.\n*/\n#define JOURNAL_PG_SZ(pPager)  ((pPager->pageSize) + 8)\n\n/*\n** The journal header size for this pager. This is usually the same \n** size as a single disk sector. See also setSectorSize().\n*/\n#define JOURNAL_HDR_SZ(pPager) (pPager->sectorSize)\n\n/*\n** The macro MEMDB is true if we are dealing with an in-memory database.\n** We do this as a macro so that if the SQLITE_OMIT_MEMORYDB macro is set,\n** the value of MEMDB will be a constant and the compiler will optimize\n** out code that would never execute.\n*/\n#ifdef SQLITE_OMIT_MEMORYDB\n# define MEMDB 0\n#else\n# define MEMDB pPager->memDb\n#endif\n\n/*\n** The macro USEFETCH is true if we are allowed to use the xFetch and xUnfetch\n** interfaces to access the database using memory-mapped I/O.\n*/\n#if SQLITE_MAX_MMAP_SIZE>0\n# define USEFETCH(x) ((x)->bUseFetch)\n#else\n# define USEFETCH(x) 0\n#endif\n\n/*\n** The maximum legal page number is (2^31 - 1).\n*/\n#define PAGER_MAX_PGNO 2147483647\n\n/*\n** The argument to this macro is a file descriptor (type sqlite3_file*).\n** Return 0 if it is not open, or non-zero (but not 1) if it is.\n**\n** This is so that expressions can be written as:\n**\n**   if( isOpen(pPager->jfd) ){ ...\n**\n** instead of\n**\n**   if( pPager->jfd->pMethods ){ ...\n*/\n#define isOpen(pFd) ((pFd)->pMethods!=0)\n\n/*\n** Return true if this pager uses a write-ahead log to read page pgno.\n** Return false if the pager reads pgno directly from the database.\n*/\n#if !defined(SQLITE_OMIT_WAL) && defined(SQLITE_DIRECT_OVERFLOW_READ)\nint sqlite3PagerUseWal(Pager *pPager, Pgno pgno){\n  u32 iRead = 0;\n  int rc;\n  if( pPager->pWal==0 ) return 0;\n  rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);\n  return rc || iRead;\n}\n#endif\n#ifndef SQLITE_OMIT_WAL\n# define pagerUseWal(x) ((x)->pWal!=0)\n#else\n# define pagerUseWal(x) 0\n# define pagerRollbackWal(x) 0\n# define pagerWalFrames(v,w,x,y) 0\n# define pagerOpenWalIfPresent(z) SQLITE_OK\n# define pagerBeginReadTransaction(z) SQLITE_OK\n#endif\n\n#ifndef NDEBUG \n/*\n** Usage:\n**\n**   assert( assert_pager_state(pPager) );\n**\n** This function runs many asserts to try to find inconsistencies in\n** the internal state of the Pager object.\n*/\nstatic int assert_pager_state(Pager *p){\n  Pager *pPager = p;\n\n  /* State must be valid. */\n  assert( p->eState==PAGER_OPEN\n       || p->eState==PAGER_READER\n       || p->eState==PAGER_WRITER_LOCKED\n       || p->eState==PAGER_WRITER_CACHEMOD\n       || p->eState==PAGER_WRITER_DBMOD\n       || p->eState==PAGER_WRITER_FINISHED\n       || p->eState==PAGER_ERROR\n  );\n\n  /* Regardless of the current state, a temp-file connection always behaves\n  ** as if it has an exclusive lock on the database file. It never updates\n  ** the change-counter field, so the changeCountDone flag is always set.\n  */\n  assert( p->tempFile==0 || p->eLock==EXCLUSIVE_LOCK );\n  assert( p->tempFile==0 || pPager->changeCountDone );\n\n  /* If the useJournal flag is clear, the journal-mode must be \"OFF\". \n  ** And if the journal-mode is \"OFF\", the journal file must not be open.\n  */\n  assert( p->journalMode==PAGER_JOURNALMODE_OFF || p->useJournal );\n  assert( p->journalMode!=PAGER_JOURNALMODE_OFF || !isOpen(p->jfd) );\n\n  /* Check that MEMDB implies noSync. And an in-memory journal. Since \n  ** this means an in-memory pager performs no IO at all, it cannot encounter \n  ** either SQLITE_IOERR or SQLITE_FULL during rollback or while finalizing \n  ** a journal file. (although the in-memory journal implementation may \n  ** return SQLITE_IOERR_NOMEM while the journal file is being written). It \n  ** is therefore not possible for an in-memory pager to enter the ERROR \n  ** state.\n  */\n  if( MEMDB ){\n    assert( !isOpen(p->fd) );\n    assert( p->noSync );\n    assert( p->journalMode==PAGER_JOURNALMODE_OFF \n         || p->journalMode==PAGER_JOURNALMODE_MEMORY \n    );\n    assert( p->eState!=PAGER_ERROR && p->eState!=PAGER_OPEN );\n    assert( pagerUseWal(p)==0 );\n  }\n\n  /* If changeCountDone is set, a RESERVED lock or greater must be held\n  ** on the file.\n  */\n  assert( pPager->changeCountDone==0 || pPager->eLock>=RESERVED_LOCK );\n  assert( p->eLock!=PENDING_LOCK );\n\n  switch( p->eState ){\n    case PAGER_OPEN:\n      assert( !MEMDB );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)==0 || pPager->tempFile );\n      break;\n\n    case PAGER_READER:\n      assert( pPager->errCode==SQLITE_OK );\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( p->eLock>=SHARED_LOCK );\n      break;\n\n    case PAGER_WRITER_LOCKED:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        assert( p->eLock>=RESERVED_LOCK );\n      }\n      assert( pPager->dbSize==pPager->dbOrigSize );\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      assert( pPager->setMaster==0 );\n      break;\n\n    case PAGER_WRITER_CACHEMOD:\n      assert( p->eLock!=UNKNOWN_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      if( !pagerUseWal(pPager) ){\n        /* It is possible that if journal_mode=wal here that neither the\n        ** journal file nor the WAL file are open. This happens during\n        ** a rollback transaction that switches from journal_mode=off\n        ** to journal_mode=wal.\n        */\n        assert( p->eLock>=RESERVED_LOCK );\n        assert( isOpen(p->jfd) \n             || p->journalMode==PAGER_JOURNALMODE_OFF \n             || p->journalMode==PAGER_JOURNALMODE_WAL \n        );\n      }\n      assert( pPager->dbOrigSize==pPager->dbFileSize );\n      assert( pPager->dbOrigSize==pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_DBMOD:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( p->eLock>=EXCLUSIVE_LOCK );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      assert( pPager->dbOrigSize<=pPager->dbHintSize );\n      break;\n\n    case PAGER_WRITER_FINISHED:\n      assert( p->eLock==EXCLUSIVE_LOCK );\n      assert( pPager->errCode==SQLITE_OK );\n      assert( !pagerUseWal(pPager) );\n      assert( isOpen(p->jfd) \n           || p->journalMode==PAGER_JOURNALMODE_OFF \n           || p->journalMode==PAGER_JOURNALMODE_WAL \n           || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n      );\n      break;\n\n    case PAGER_ERROR:\n      /* There must be at least one outstanding reference to the pager if\n      ** in ERROR state. Otherwise the pager should have already dropped\n      ** back to OPEN state.\n      */\n      assert( pPager->errCode!=SQLITE_OK );\n      assert( sqlite3PcacheRefCount(pPager->pPCache)>0 || pPager->tempFile );\n      break;\n  }\n\n  return 1;\n}\n#endif /* ifndef NDEBUG */\n\n#ifdef SQLITE_DEBUG \n/*\n** Return a pointer to a human readable string in a static buffer\n** containing the state of the Pager object passed as an argument. This\n** is intended to be used within debuggers. For example, as an alternative\n** to \"print *pPager\" in gdb:\n**\n** (gdb) printf \"%s\", print_pager_state(pPager)\n*/\nstatic char *print_pager_state(Pager *p){\n  static char zRet[1024];\n\n  sqlite3_snprintf(1024, zRet,\n      \"Filename:      %s\\n\"\n      \"State:         %s errCode=%d\\n\"\n      \"Lock:          %s\\n\"\n      \"Locking mode:  locking_mode=%s\\n\"\n      \"Journal mode:  journal_mode=%s\\n\"\n      \"Backing store: tempFile=%d memDb=%d useJournal=%d\\n\"\n      \"Journal:       journalOff=%lld journalHdr=%lld\\n\"\n      \"Size:          dbsize=%d dbOrigSize=%d dbFileSize=%d\\n\"\n      , p->zFilename\n      , p->eState==PAGER_OPEN            ? \"OPEN\" :\n        p->eState==PAGER_READER          ? \"READER\" :\n        p->eState==PAGER_WRITER_LOCKED   ? \"WRITER_LOCKED\" :\n        p->eState==PAGER_WRITER_CACHEMOD ? \"WRITER_CACHEMOD\" :\n        p->eState==PAGER_WRITER_DBMOD    ? \"WRITER_DBMOD\" :\n        p->eState==PAGER_WRITER_FINISHED ? \"WRITER_FINISHED\" :\n        p->eState==PAGER_ERROR           ? \"ERROR\" : \"?error?\"\n      , (int)p->errCode\n      , p->eLock==NO_LOCK         ? \"NO_LOCK\" :\n        p->eLock==RESERVED_LOCK   ? \"RESERVED\" :\n        p->eLock==EXCLUSIVE_LOCK  ? \"EXCLUSIVE\" :\n        p->eLock==SHARED_LOCK     ? \"SHARED\" :\n        p->eLock==UNKNOWN_LOCK    ? \"UNKNOWN\" : \"?error?\"\n      , p->exclusiveMode ? \"exclusive\" : \"normal\"\n      , p->journalMode==PAGER_JOURNALMODE_MEMORY   ? \"memory\" :\n        p->journalMode==PAGER_JOURNALMODE_OFF      ? \"off\" :\n        p->journalMode==PAGER_JOURNALMODE_DELETE   ? \"delete\" :\n        p->journalMode==PAGER_JOURNALMODE_PERSIST  ? \"persist\" :\n        p->journalMode==PAGER_JOURNALMODE_TRUNCATE ? \"truncate\" :\n        p->journalMode==PAGER_JOURNALMODE_WAL      ? \"wal\" : \"?error?\"\n      , (int)p->tempFile, (int)p->memDb, (int)p->useJournal\n      , p->journalOff, p->journalHdr\n      , (int)p->dbSize, (int)p->dbOrigSize, (int)p->dbFileSize\n  );\n\n  return zRet;\n}\n#endif\n\n/* Forward references to the various page getters */\nstatic int getPageNormal(Pager*,Pgno,DbPage**,int);\nstatic int getPageError(Pager*,Pgno,DbPage**,int);\n#if SQLITE_MAX_MMAP_SIZE>0\nstatic int getPageMMap(Pager*,Pgno,DbPage**,int);\n#endif\n\n/*\n** Set the Pager.xGet method for the appropriate routine used to fetch\n** content from the pager.\n*/\nstatic void setGetterMethod(Pager *pPager){\n  if( pPager->errCode ){\n    pPager->xGet = getPageError;\n#if SQLITE_MAX_MMAP_SIZE>0\n  }else if( USEFETCH(pPager)\n#ifdef SQLITE_HAS_CODEC\n   && pPager->xCodec==0\n#endif\n  ){\n    pPager->xGet = getPageMMap;\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n  }else{\n    pPager->xGet = getPageNormal;\n  }\n}\n\n/*\n** Return true if it is necessary to write page *pPg into the sub-journal.\n** A page needs to be written into the sub-journal if there exists one\n** or more open savepoints for which:\n**\n**   * The page-number is less than or equal to PagerSavepoint.nOrig, and\n**   * The bit corresponding to the page-number is not set in\n**     PagerSavepoint.pInSavepoint.\n*/\nstatic int subjRequiresPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  PagerSavepoint *p;\n  Pgno pgno = pPg->pgno;\n  int i;\n  for(i=0; i<pPager->nSavepoint; i++){\n    p = &pPager->aSavepoint[i];\n    if( p->nOrig>=pgno && 0==sqlite3BitvecTestNotNull(p->pInSavepoint, pgno) ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return true if the page is already in the journal file.\n*/\nstatic int pageInJournal(Pager *pPager, PgHdr *pPg){\n  return sqlite3BitvecTest(pPager->pInJournal, pPg->pgno);\n}\n#endif\n\n/*\n** Read a 32-bit integer from the given file descriptor.  Store the integer\n** that is read in *pRes.  Return SQLITE_OK if everything worked, or an\n** error code is something goes wrong.\n**\n** All values are stored on disk as big-endian.\n*/\nstatic int read32bits(sqlite3_file *fd, i64 offset, u32 *pRes){\n  unsigned char ac[4];\n  int rc = sqlite3OsRead(fd, ac, sizeof(ac), offset);\n  if( rc==SQLITE_OK ){\n    *pRes = sqlite3Get4byte(ac);\n  }\n  return rc;\n}\n\n/*\n** Write a 32-bit integer into a string buffer in big-endian byte order.\n*/\n#define put32bits(A,B)  sqlite3Put4byte((u8*)A,B)\n\n\n/*\n** Write a 32-bit integer into the given file descriptor.  Return SQLITE_OK\n** on success or an error code is something goes wrong.\n*/\nstatic int write32bits(sqlite3_file *fd, i64 offset, u32 val){\n  char ac[4];\n  put32bits(ac, val);\n  return sqlite3OsWrite(fd, ac, 4, offset);\n}\n\n/*\n** Unlock the database file to level eLock, which must be either NO_LOCK\n** or SHARED_LOCK. Regardless of whether or not the call to xUnlock()\n** succeeds, set the Pager.eLock variable to match the (attempted) new lock.\n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is\n** called, do not modify it. See the comment above the #define of \n** UNKNOWN_LOCK for an explanation of this.\n*/\nstatic int pagerUnlockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( !pPager->exclusiveMode || pPager->eLock==eLock );\n  assert( eLock==NO_LOCK || eLock==SHARED_LOCK );\n  assert( eLock!=NO_LOCK || pagerUseWal(pPager)==0 );\n  if( isOpen(pPager->fd) ){\n    assert( pPager->eLock>=eLock );\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsUnlock(pPager->fd, eLock);\n    if( pPager->eLock!=UNKNOWN_LOCK ){\n      pPager->eLock = (u8)eLock;\n    }\n    IOTRACE((\"UNLOCK %p %d\\n\", pPager, eLock))\n  }\n  return rc;\n}\n\n/*\n** Lock the database file to level eLock, which must be either SHARED_LOCK,\n** RESERVED_LOCK or EXCLUSIVE_LOCK. If the caller is successful, set the\n** Pager.eLock variable to the new locking state. \n**\n** Except, if Pager.eLock is set to UNKNOWN_LOCK when this function is \n** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK. \n** See the comment above the #define of UNKNOWN_LOCK for an explanation \n** of this.\n*/\nstatic int pagerLockDb(Pager *pPager, int eLock){\n  int rc = SQLITE_OK;\n\n  assert( eLock==SHARED_LOCK || eLock==RESERVED_LOCK || eLock==EXCLUSIVE_LOCK );\n  if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){\n    rc = pPager->noLock ? SQLITE_OK : sqlite3OsLock(pPager->fd, eLock);\n    if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){\n      pPager->eLock = (u8)eLock;\n      IOTRACE((\"LOCK %p %d\\n\", pPager, eLock))\n    }\n  }\n  return rc;\n}\n\n/*\n** This function determines whether or not the atomic-write or\n** atomic-batch-write optimizations can be used with this pager. The\n** atomic-write optimization can be used if:\n**\n**  (a) the value returned by OsDeviceCharacteristics() indicates that\n**      a database page may be written atomically, and\n**  (b) the value returned by OsSectorSize() is less than or equal\n**      to the page size.\n**\n** If it can be used, then the value returned is the size of the journal \n** file when it contains rollback data for exactly one page.\n**\n** The atomic-batch-write optimization can be used if OsDeviceCharacteristics()\n** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is\n** returned in this case.\n**\n** If neither optimization can be used, 0 is returned.\n*/\nstatic int jrnlBufferSize(Pager *pPager){\n  assert( !MEMDB );\n\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  int dc;                           /* Device characteristics */\n\n  assert( isOpen(pPager->fd) );\n  dc = sqlite3OsDeviceCharacteristics(pPager->fd);\n#else\n  UNUSED_PARAMETER(pPager);\n#endif\n\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n  if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){\n    return -1;\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n  {\n    int nSector = pPager->sectorSize;\n    int szPage = pPager->pageSize;\n\n    assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n    assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n    if( 0==(dc&(SQLITE_IOCAP_ATOMIC|(szPage>>8)) || nSector>szPage) ){\n      return 0;\n    }\n  }\n\n  return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager);\n#endif\n\n  return 0;\n}\n\n/*\n** If SQLITE_CHECK_PAGES is defined then we do some sanity checking\n** on the cache using a hash function.  This is used for testing\n** and debugging only.\n*/\n#ifdef SQLITE_CHECK_PAGES\n/*\n** Return a 32-bit hash of the page data for pPage.\n*/\nstatic u32 pager_datahash(int nByte, unsigned char *pData){\n  u32 hash = 0;\n  int i;\n  for(i=0; i<nByte; i++){\n    hash = (hash*1039) + pData[i];\n  }\n  return hash;\n}\nstatic u32 pager_pagehash(PgHdr *pPage){\n  return pager_datahash(pPage->pPager->pageSize, (unsigned char *)pPage->pData);\n}\nstatic void pager_set_pagehash(PgHdr *pPage){\n  pPage->pageHash = pager_pagehash(pPage);\n}\n\n/*\n** The CHECK_PAGE macro takes a PgHdr* as an argument. If SQLITE_CHECK_PAGES\n** is defined, and NDEBUG is not defined, an assert() statement checks\n** that the page is either dirty or still matches the calculated page-hash.\n*/\n#define CHECK_PAGE(x) checkPage(x)\nstatic void checkPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( (pPg->flags&PGHDR_DIRTY) || pPg->pageHash==pager_pagehash(pPg) );\n}\n\n#else\n#define pager_datahash(X,Y)  0\n#define pager_pagehash(X)  0\n#define pager_set_pagehash(X)\n#define CHECK_PAGE(x)\n#endif  /* SQLITE_CHECK_PAGES */\n\n/*\n** When this is called the journal file for pager pPager must be open.\n** This function attempts to read a master journal file name from the \n** end of the file and, if successful, copies it into memory supplied \n** by the caller. See comments above writeMasterJournal() for the format\n** used to store a master journal file name at the end of a journal file.\n**\n** zMaster must point to a buffer of at least nMaster bytes allocated by\n** the caller. This should be sqlite3_vfs.mxPathname+1 (to ensure there is\n** enough space to write the master journal name). If the master journal\n** name in the journal is longer than nMaster bytes (including a\n** nul-terminator), then this is handled as if no master journal name\n** were present in the journal.\n**\n** If a master journal file name is present at the end of the journal\n** file, then it is copied into the buffer pointed to by zMaster. A\n** nul-terminator byte is appended to the buffer following the master\n** journal file name.\n**\n** If it is determined that no master journal file name is present \n** zMaster[0] is set to 0 and SQLITE_OK returned.\n**\n** If an error occurs while reading from the journal file, an SQLite\n** error code is returned.\n*/\nstatic int readMasterJournal(sqlite3_file *pJrnl, char *zMaster, u32 nMaster){\n  int rc;                    /* Return code */\n  u32 len;                   /* Length in bytes of master journal name */\n  i64 szJ;                   /* Total size in bytes of journal file pJrnl */\n  u32 cksum;                 /* MJ checksum value read from journal */\n  u32 u;                     /* Unsigned loop counter */\n  unsigned char aMagic[8];   /* A buffer to hold the magic header */\n  zMaster[0] = '\\0';\n\n  if( SQLITE_OK!=(rc = sqlite3OsFileSize(pJrnl, &szJ))\n   || szJ<16\n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-16, &len))\n   || len>=nMaster \n   || len>szJ-16\n   || len==0 \n   || SQLITE_OK!=(rc = read32bits(pJrnl, szJ-12, &cksum))\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, aMagic, 8, szJ-8))\n   || memcmp(aMagic, aJournalMagic, 8)\n   || SQLITE_OK!=(rc = sqlite3OsRead(pJrnl, zMaster, len, szJ-16-len))\n  ){\n    return rc;\n  }\n\n  /* See if the checksum matches the master journal name */\n  for(u=0; u<len; u++){\n    cksum -= zMaster[u];\n  }\n  if( cksum ){\n    /* If the checksum doesn't add up, then one or more of the disk sectors\n    ** containing the master journal filename is corrupted. This means\n    ** definitely roll back, so just return SQLITE_OK and report a (nul)\n    ** master-journal filename.\n    */\n    len = 0;\n  }\n  zMaster[len] = '\\0';\n   \n  return SQLITE_OK;\n}\n\n/*\n** Return the offset of the sector boundary at or immediately \n** following the value in pPager->journalOff, assuming a sector \n** size of pPager->sectorSize bytes.\n**\n** i.e for a sector size of 512:\n**\n**   Pager.journalOff          Return value\n**   ---------------------------------------\n**   0                         0\n**   512                       512\n**   100                       512\n**   2000                      2048\n** \n*/\nstatic i64 journalHdrOffset(Pager *pPager){\n  i64 offset = 0;\n  i64 c = pPager->journalOff;\n  if( c ){\n    offset = ((c-1)/JOURNAL_HDR_SZ(pPager) + 1) * JOURNAL_HDR_SZ(pPager);\n  }\n  assert( offset%JOURNAL_HDR_SZ(pPager)==0 );\n  assert( offset>=c );\n  assert( (offset-c)<JOURNAL_HDR_SZ(pPager) );\n  return offset;\n}\n\n/*\n** The journal file must be open when this function is called.\n**\n** This function is a no-op if the journal file has not been written to\n** within the current transaction (i.e. if Pager.journalOff==0).\n**\n** If doTruncate is non-zero or the Pager.journalSizeLimit variable is\n** set to 0, then truncate the journal file to zero bytes in size. Otherwise,\n** zero the 28-byte header at the start of the journal file. In either case, \n** if the pager is not in no-sync mode, sync the journal file immediately \n** after writing or truncating it.\n**\n** If Pager.journalSizeLimit is set to a positive, non-zero value, and\n** following the truncation or zeroing described above the size of the \n** journal file in bytes is larger than this value, then truncate the\n** journal file to Pager.journalSizeLimit bytes. The journal file does\n** not need to be synced following this operation.\n**\n** If an IO error occurs, abandon processing and return the IO error code.\n** Otherwise, return SQLITE_OK.\n*/\nstatic int zeroJournalHdr(Pager *pPager, int doTruncate){\n  int rc = SQLITE_OK;                               /* Return code */\n  assert( isOpen(pPager->jfd) );\n  assert( !sqlite3JournalIsInMemory(pPager->jfd) );\n  if( pPager->journalOff ){\n    const i64 iLimit = pPager->journalSizeLimit;    /* Local cache of jsl */\n\n    IOTRACE((\"JZEROHDR %p\\n\", pPager))\n    if( doTruncate || iLimit==0 ){\n      rc = sqlite3OsTruncate(pPager->jfd, 0);\n    }else{\n      static const char zeroHdr[28] = {0};\n      rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0);\n    }\n    if( rc==SQLITE_OK && !pPager->noSync ){\n      rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags);\n    }\n\n    /* At this point the transaction is committed but the write lock \n    ** is still held on the file. If there is a size limit configured for \n    ** the persistent journal and the journal file currently consumes more\n    ** space than that limit allows for, truncate it now. There is no need\n    ** to sync the file following this operation.\n    */\n    if( rc==SQLITE_OK && iLimit>0 ){\n      i64 sz;\n      rc = sqlite3OsFileSize(pPager->jfd, &sz);\n      if( rc==SQLITE_OK && sz>iLimit ){\n        rc = sqlite3OsTruncate(pPager->jfd, iLimit);\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The journal file must be open when this routine is called. A journal\n** header (JOURNAL_HDR_SZ bytes) is written into the journal file at the\n** current location.\n**\n** The format for the journal header is as follows:\n** - 8 bytes: Magic identifying journal format.\n** - 4 bytes: Number of records in journal, or -1 no-sync mode is on.\n** - 4 bytes: Random number used for page hash.\n** - 4 bytes: Initial database page count.\n** - 4 bytes: Sector size used by the process that wrote this journal.\n** - 4 bytes: Database page size.\n** \n** Followed by (JOURNAL_HDR_SZ - 28) bytes of unused space.\n*/\nstatic int writeJournalHdr(Pager *pPager){\n  int rc = SQLITE_OK;                 /* Return code */\n  char *zHeader = pPager->pTmpSpace;  /* Temporary space used to build header */\n  u32 nHeader = (u32)pPager->pageSize;/* Size of buffer pointed to by zHeader */\n  u32 nWrite;                         /* Bytes of header sector written */\n  int ii;                             /* Loop counter */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  if( nHeader>JOURNAL_HDR_SZ(pPager) ){\n    nHeader = JOURNAL_HDR_SZ(pPager);\n  }\n\n  /* If there are active savepoints and any of them were created \n  ** since the most recent journal header was written, update the \n  ** PagerSavepoint.iHdrOffset fields now.\n  */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    if( pPager->aSavepoint[ii].iHdrOffset==0 ){\n      pPager->aSavepoint[ii].iHdrOffset = pPager->journalOff;\n    }\n  }\n\n  pPager->journalHdr = pPager->journalOff = journalHdrOffset(pPager);\n\n  /* \n  ** Write the nRec Field - the number of page records that follow this\n  ** journal header. Normally, zero is written to this value at this time.\n  ** After the records are added to the journal (and the journal synced, \n  ** if in full-sync mode), the zero is overwritten with the true number\n  ** of records (see syncJournal()).\n  **\n  ** A faster alternative is to write 0xFFFFFFFF to the nRec field. When\n  ** reading the journal this value tells SQLite to assume that the\n  ** rest of the journal file contains valid page records. This assumption\n  ** is dangerous, as if a failure occurred whilst writing to the journal\n  ** file it may contain some garbage data. There are two scenarios\n  ** where this risk can be ignored:\n  **\n  **   * When the pager is in no-sync mode. Corruption can follow a\n  **     power failure in this case anyway.\n  **\n  **   * When the SQLITE_IOCAP_SAFE_APPEND flag is set. This guarantees\n  **     that garbage data is never appended to the journal file.\n  */\n  assert( isOpen(pPager->fd) || pPager->noSync );\n  if( pPager->noSync || (pPager->journalMode==PAGER_JOURNALMODE_MEMORY)\n   || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_SAFE_APPEND) \n  ){\n    memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n    put32bits(&zHeader[sizeof(aJournalMagic)], 0xffffffff);\n  }else{\n    memset(zHeader, 0, sizeof(aJournalMagic)+4);\n  }\n\n  /* The random check-hash initializer */ \n  sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);\n  put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);\n  /* The initial database size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbOrigSize);\n  /* The assumed sector size for this process */\n  put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);\n\n  /* The page size */\n  put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);\n\n  /* Initializing the tail of the buffer is not necessary.  Everything\n  ** works find if the following memset() is omitted.  But initializing\n  ** the memory prevents valgrind from complaining, so we are willing to\n  ** take the performance hit.\n  */\n  memset(&zHeader[sizeof(aJournalMagic)+20], 0,\n         nHeader-(sizeof(aJournalMagic)+20));\n\n  /* In theory, it is only necessary to write the 28 bytes that the \n  ** journal header consumes to the journal file here. Then increment the \n  ** Pager.journalOff variable by JOURNAL_HDR_SZ so that the next \n  ** record is written to the following sector (leaving a gap in the file\n  ** that will be implicitly filled in by the OS).\n  **\n  ** However it has been discovered that on some systems this pattern can \n  ** be significantly slower than contiguously writing data to the file,\n  ** even if that means explicitly writing data to the block of \n  ** (JOURNAL_HDR_SZ - 28) bytes that will not be used. So that is what\n  ** is done. \n  **\n  ** The loop is required here in case the sector-size is larger than the \n  ** database page size. Since the zHeader buffer is only Pager.pageSize\n  ** bytes in size, more than one call to sqlite3OsWrite() may be required\n  ** to populate the entire journal header sector.\n  */ \n  for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){\n    IOTRACE((\"JHDR %p %lld %d\\n\", pPager, pPager->journalHdr, nHeader))\n    rc = sqlite3OsWrite(pPager->jfd, zHeader, nHeader, pPager->journalOff);\n    assert( pPager->journalHdr <= pPager->journalOff );\n    pPager->journalOff += nHeader;\n  }\n\n  return rc;\n}\n\n/*\n** The journal file must be open when this is called. A journal header file\n** (JOURNAL_HDR_SZ bytes) is read from the current location in the journal\n** file. The current location in the journal file is given by\n** pPager->journalOff. See comments above function writeJournalHdr() for\n** a description of the journal header format.\n**\n** If the header is read successfully, *pNRec is set to the number of\n** page records following this header and *pDbSize is set to the size of the\n** database before the transaction began, in pages. Also, pPager->cksumInit\n** is set to the value read from the journal header. SQLITE_OK is returned\n** in this case.\n**\n** If the journal header file appears to be corrupted, SQLITE_DONE is\n** returned and *pNRec and *PDbSize are undefined.  If JOURNAL_HDR_SZ bytes\n** cannot be read from the journal file an error code is returned.\n*/\nstatic int readJournalHdr(\n  Pager *pPager,               /* Pager object */\n  int isHot,\n  i64 journalSize,             /* Size of the open journal file in bytes */\n  u32 *pNRec,                  /* OUT: Value read from the nRec field */\n  u32 *pDbSize                 /* OUT: Value of original database size field */\n){\n  int rc;                      /* Return code */\n  unsigned char aMagic[8];     /* A buffer to hold the magic header */\n  i64 iHdrOff;                 /* Offset of journal header being read */\n\n  assert( isOpen(pPager->jfd) );      /* Journal file must be open. */\n\n  /* Advance Pager.journalOff to the start of the next sector. If the\n  ** journal file is too small for there to be a header stored at this\n  ** point, return SQLITE_DONE.\n  */\n  pPager->journalOff = journalHdrOffset(pPager);\n  if( pPager->journalOff+JOURNAL_HDR_SZ(pPager) > journalSize ){\n    return SQLITE_DONE;\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Read in the first 8 bytes of the journal header. If they do not match\n  ** the  magic string found at the start of each journal header, return\n  ** SQLITE_DONE. If an IO error occurs, return an error code. Otherwise,\n  ** proceed.\n  */\n  if( isHot || iHdrOff!=pPager->journalHdr ){\n    rc = sqlite3OsRead(pPager->jfd, aMagic, sizeof(aMagic), iHdrOff);\n    if( rc ){\n      return rc;\n    }\n    if( memcmp(aMagic, aJournalMagic, sizeof(aMagic))!=0 ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* Read the first three 32-bit fields of the journal header: The nRec\n  ** field, the checksum-initializer and the database size at the start\n  ** of the transaction. Return an error code if anything goes wrong.\n  */\n  if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+8, pNRec))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+12, &pPager->cksumInit))\n   || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+16, pDbSize))\n  ){\n    return rc;\n  }\n\n  if( pPager->journalOff==0 ){\n    u32 iPageSize;               /* Page-size field of journal header */\n    u32 iSectorSize;             /* Sector-size field of journal header */\n\n    /* Read the page-size and sector-size journal header fields. */\n    if( SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+20, &iSectorSize))\n     || SQLITE_OK!=(rc = read32bits(pPager->jfd, iHdrOff+24, &iPageSize))\n    ){\n      return rc;\n    }\n\n    /* Versions of SQLite prior to 3.5.8 set the page-size field of the\n    ** journal header to zero. In this case, assume that the Pager.pageSize\n    ** variable is already set to the correct page size.\n    */\n    if( iPageSize==0 ){\n      iPageSize = pPager->pageSize;\n    }\n\n    /* Check that the values read from the page-size and sector-size fields\n    ** are within range. To be 'in range', both values need to be a power\n    ** of two greater than or equal to 512 or 32, and not greater than their \n    ** respective compile time maximum limits.\n    */\n    if( iPageSize<512                  || iSectorSize<32\n     || iPageSize>SQLITE_MAX_PAGE_SIZE || iSectorSize>MAX_SECTOR_SIZE\n     || ((iPageSize-1)&iPageSize)!=0   || ((iSectorSize-1)&iSectorSize)!=0 \n    ){\n      /* If the either the page-size or sector-size in the journal-header is \n      ** invalid, then the process that wrote the journal-header must have \n      ** crashed before the header was synced. In this case stop reading \n      ** the journal file here.\n      */\n      return SQLITE_DONE;\n    }\n\n    /* Update the page-size to match the value read from the journal. \n    ** Use a testcase() macro to make sure that malloc failure within \n    ** PagerSetPagesize() is tested.\n    */\n    rc = sqlite3PagerSetPagesize(pPager, &iPageSize, -1);\n    testcase( rc!=SQLITE_OK );\n\n    /* Update the assumed sector-size to match the value used by \n    ** the process that created this journal. If this journal was\n    ** created by a process other than this one, then this routine\n    ** is being called from within pager_playback(). The local value\n    ** of Pager.sectorSize is restored at the end of that routine.\n    */\n    pPager->sectorSize = iSectorSize;\n  }\n\n  pPager->journalOff += JOURNAL_HDR_SZ(pPager);\n  return rc;\n}\n\n\n/*\n** Write the supplied master journal name into the journal file for pager\n** pPager at the current location. The master journal name must be the last\n** thing written to a journal file. If the pager is in full-sync mode, the\n** journal file descriptor is advanced to the next sector boundary before\n** anything is written. The format is:\n**\n**   + 4 bytes: PAGER_MJ_PGNO.\n**   + N bytes: Master journal filename in utf-8.\n**   + 4 bytes: N (length of master journal name in bytes, no nul-terminator).\n**   + 4 bytes: Master journal name checksum.\n**   + 8 bytes: aJournalMagic[].\n**\n** The master journal page checksum is the sum of the bytes in the master\n** journal name, where each byte is interpreted as a signed 8-bit integer.\n**\n** If zMaster is a NULL pointer (occurs for a single database transaction), \n** this call is a no-op.\n*/\nstatic int writeMasterJournal(Pager *pPager, const char *zMaster){\n  int rc;                          /* Return code */\n  int nMaster;                     /* Length of string zMaster */\n  i64 iHdrOff;                     /* Offset of header in journal file */\n  i64 jrnlSize;                    /* Size of journal file on disk */\n  u32 cksum = 0;                   /* Checksum of string zMaster */\n\n  assert( pPager->setMaster==0 );\n  assert( !pagerUseWal(pPager) );\n\n  if( !zMaster \n   || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n   || !isOpen(pPager->jfd)\n  ){\n    return SQLITE_OK;\n  }\n  pPager->setMaster = 1;\n  assert( pPager->journalHdr <= pPager->journalOff );\n\n  /* Calculate the length in bytes and the checksum of zMaster */\n  for(nMaster=0; zMaster[nMaster]; nMaster++){\n    cksum += zMaster[nMaster];\n  }\n\n  /* If in full-sync mode, advance to the next disk sector before writing\n  ** the master journal name. This is in case the previous page written to\n  ** the journal has already been synced.\n  */\n  if( pPager->fullSync ){\n    pPager->journalOff = journalHdrOffset(pPager);\n  }\n  iHdrOff = pPager->journalOff;\n\n  /* Write the master journal data to the end of the journal file. If\n  ** an error occurs, return the error code to the caller.\n  */\n  if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, zMaster, nMaster, iHdrOff+4)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster, nMaster)))\n   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nMaster+4, cksum)))\n   || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,\n                                 iHdrOff+4+nMaster+8)))\n  ){\n    return rc;\n  }\n  pPager->journalOff += (nMaster+20);\n\n  /* If the pager is in peristent-journal mode, then the physical \n  ** journal-file may extend past the end of the master-journal name\n  ** and 8 bytes of magic data just written to the file. This is \n  ** dangerous because the code to rollback a hot-journal file\n  ** will not be able to find the master-journal name to determine \n  ** whether or not the journal is hot. \n  **\n  ** Easiest thing to do in this scenario is to truncate the journal \n  ** file to the required size.\n  */ \n  if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))\n   && jrnlSize>pPager->journalOff\n  ){\n    rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);\n  }\n  return rc;\n}\n\n/*\n** Discard the entire contents of the in-memory page-cache.\n*/\nstatic void pager_reset(Pager *pPager){\n  pPager->iDataVersion++;\n  sqlite3BackupRestart(pPager->pBackup);\n  sqlite3PcacheClear(pPager->pPCache);\n}\n\n/*\n** Return the pPager->iDataVersion value\n*/\nu32 sqlite3PagerDataVersion(Pager *pPager){\n  assert( pPager->eState>PAGER_OPEN );\n  return pPager->iDataVersion;\n}\n\n/*\n** Free all structures in the Pager.aSavepoint[] array and set both\n** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal\n** if it is open and the pager is not in exclusive mode.\n*/\nstatic void releaseAllSavepoints(Pager *pPager){\n  int ii;               /* Iterator for looping through Pager.aSavepoint */\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n  }\n  if( !pPager->exclusiveMode || sqlite3JournalIsInMemory(pPager->sjfd) ){\n    sqlite3OsClose(pPager->sjfd);\n  }\n  sqlite3_free(pPager->aSavepoint);\n  pPager->aSavepoint = 0;\n  pPager->nSavepoint = 0;\n  pPager->nSubRec = 0;\n}\n\n/*\n** Set the bit number pgno in the PagerSavepoint.pInSavepoint \n** bitvecs of all open savepoints. Return SQLITE_OK if successful\n** or SQLITE_NOMEM if a malloc failure occurs.\n*/\nstatic int addToSavepointBitvecs(Pager *pPager, Pgno pgno){\n  int ii;                   /* Loop counter */\n  int rc = SQLITE_OK;       /* Result code */\n\n  for(ii=0; ii<pPager->nSavepoint; ii++){\n    PagerSavepoint *p = &pPager->aSavepoint[ii];\n    if( pgno<=p->nOrig ){\n      rc |= sqlite3BitvecSet(p->pInSavepoint, pgno);\n      testcase( rc==SQLITE_NOMEM );\n      assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    }\n  }\n  return rc;\n}\n\n/*\n** This function is a no-op if the pager is in exclusive mode and not\n** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN\n** state.\n**\n** If the pager is not in exclusive-access mode, the database file is\n** completely unlocked. If the file is unlocked and the file-system does\n** not exhibit the UNDELETABLE_WHEN_OPEN property, the journal file is\n** closed (if it is open).\n**\n** If the pager is in ERROR state when this function is called, the \n** contents of the pager cache are discarded before switching back to \n** the OPEN state. Regardless of whether the pager is in exclusive-mode\n** or not, any journal file left in the file-system will be treated\n** as a hot-journal and rolled back the next time a read-transaction\n** is opened (by this or by any other connection).\n*/\nstatic void pager_unlock(Pager *pPager){\n\n  assert( pPager->eState==PAGER_READER \n       || pPager->eState==PAGER_OPEN \n       || pPager->eState==PAGER_ERROR \n  );\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  releaseAllSavepoints(pPager);\n\n  if( pagerUseWal(pPager) ){\n    assert( !isOpen(pPager->jfd) );\n    sqlite3WalEndReadTransaction(pPager->pWal);\n    pPager->eState = PAGER_OPEN;\n  }else if( !pPager->exclusiveMode ){\n    int rc;                       /* Error code returned by pagerUnlockDb() */\n    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;\n\n    /* If the operating system support deletion of open files, then\n    ** close the journal file when dropping the database lock.  Otherwise\n    ** another connection with journal_mode=delete might delete the file\n    ** out from under us.\n    */\n    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );\n    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)\n     || 1!=(pPager->journalMode & 5)\n    ){\n      sqlite3OsClose(pPager->jfd);\n    }\n\n    /* If the pager is in the ERROR state and the call to unlock the database\n    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment\n    ** above the #define for UNKNOWN_LOCK for an explanation of why this\n    ** is necessary.\n    */\n    rc = pagerUnlockDb(pPager, NO_LOCK);\n    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){\n      pPager->eLock = UNKNOWN_LOCK;\n    }\n\n    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here\n    ** without clearing the error code. This is intentional - the error\n    ** code is cleared and the cache reset in the block below.\n    */\n    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );\n    pPager->changeCountDone = 0;\n    pPager->eState = PAGER_OPEN;\n  }\n\n  /* If Pager.errCode is set, the contents of the pager cache cannot be\n  ** trusted. Now that there are no outstanding references to the pager,\n  ** it can safely move back to PAGER_OPEN state. This happens in both\n  ** normal and exclusive-locking mode.\n  */\n  assert( pPager->errCode==SQLITE_OK || !MEMDB );\n  if( pPager->errCode ){\n    if( pPager->tempFile==0 ){\n      pager_reset(pPager);\n      pPager->changeCountDone = 0;\n      pPager->eState = PAGER_OPEN;\n    }else{\n      pPager->eState = (isOpen(pPager->jfd) ? PAGER_OPEN : PAGER_READER);\n    }\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n    pPager->errCode = SQLITE_OK;\n    setGetterMethod(pPager);\n  }\n\n  pPager->journalOff = 0;\n  pPager->journalHdr = 0;\n  pPager->setMaster = 0;\n}\n\n/*\n** This function is called whenever an IOERR or FULL error that requires\n** the pager to transition into the ERROR state may ahve occurred.\n** The first argument is a pointer to the pager structure, the second \n** the error-code about to be returned by a pager API function. The \n** value returned is a copy of the second argument to this function. \n**\n** If the second argument is SQLITE_FULL, SQLITE_IOERR or one of the\n** IOERR sub-codes, the pager enters the ERROR state and the error code\n** is stored in Pager.errCode. While the pager remains in the ERROR state,\n** all major API calls on the Pager will immediately return Pager.errCode.\n**\n** The ERROR state indicates that the contents of the pager-cache \n** cannot be trusted. This state can be cleared by completely discarding \n** the contents of the pager-cache. If a transaction was active when\n** the persistent error occurred, then the rollback journal may need\n** to be replayed to restore the contents of the database file (as if\n** it were a hot-journal).\n*/\nstatic int pager_error(Pager *pPager, int rc){\n  int rc2 = rc & 0xff;\n  assert( rc==SQLITE_OK || !MEMDB );\n  assert(\n       pPager->errCode==SQLITE_FULL ||\n       pPager->errCode==SQLITE_OK ||\n       (pPager->errCode & 0xff)==SQLITE_IOERR\n  );\n  if( rc2==SQLITE_FULL || rc2==SQLITE_IOERR ){\n    pPager->errCode = rc;\n    pPager->eState = PAGER_ERROR;\n    setGetterMethod(pPager);\n  }\n  return rc;\n}\n\nstatic int pager_truncate(Pager *pPager, Pgno nPage);\n\n/*\n** The write transaction open on pPager is being committed (bCommit==1)\n** or rolled back (bCommit==0).\n**\n** Return TRUE if and only if all dirty pages should be flushed to disk.\n**\n** Rules:\n**\n**   *  For non-TEMP databases, always sync to disk.  This is necessary\n**      for transactions to be durable.\n**\n**   *  Sync TEMP database only on a COMMIT (not a ROLLBACK) when the backing\n**      file has been created already (via a spill on pagerStress()) and\n**      when the number of dirty pages in memory exceeds 25% of the total\n**      cache size.\n*/\nstatic int pagerFlushOnCommit(Pager *pPager, int bCommit){\n  if( pPager->tempFile==0 ) return 1;\n  if( !bCommit ) return 0;\n  if( !isOpen(pPager->fd) ) return 0;\n  return (sqlite3PCachePercentDirty(pPager->pPCache)>=25);\n}\n\n/*\n** This routine ends a transaction. A transaction is usually ended by \n** either a COMMIT or a ROLLBACK operation. This routine may be called \n** after rollback of a hot-journal, or if an error occurs while opening\n** the journal file or writing the very first journal-header of a\n** database transaction.\n** \n** This routine is never called in PAGER_ERROR state. If it is called\n** in PAGER_NONE or PAGER_SHARED state and the lock held is less\n** exclusive than a RESERVED lock, it is a no-op.\n**\n** Otherwise, any active savepoints are released.\n**\n** If the journal file is open, then it is \"finalized\". Once a journal \n** file has been finalized it is not possible to use it to roll back a \n** transaction. Nor will it be considered to be a hot-journal by this\n** or any other database connection. Exactly how a journal is finalized\n** depends on whether or not the pager is running in exclusive mode and\n** the current journal-mode (Pager.journalMode value), as follows:\n**\n**   journalMode==MEMORY\n**     Journal file descriptor is simply closed. This destroys an \n**     in-memory journal.\n**\n**   journalMode==TRUNCATE\n**     Journal file is truncated to zero bytes in size.\n**\n**   journalMode==PERSIST\n**     The first 28 bytes of the journal file are zeroed. This invalidates\n**     the first journal header in the file, and hence the entire journal\n**     file. An invalid journal file cannot be rolled back.\n**\n**   journalMode==DELETE\n**     The journal file is closed and deleted using sqlite3OsDelete().\n**\n**     If the pager is running in exclusive mode, this method of finalizing\n**     the journal file is never used. Instead, if the journalMode is\n**     DELETE and the pager is in exclusive mode, the method described under\n**     journalMode==PERSIST is used instead.\n**\n** After the journal is finalized, the pager moves to PAGER_READER state.\n** If running in non-exclusive rollback mode, the lock on the file is \n** downgraded to a SHARED_LOCK.\n**\n** SQLITE_OK is returned if no error occurs. If an error occurs during\n** any of the IO operations to finalize the journal file or unlock the\n** database then the IO error code is returned to the user. If the \n** operation to finalize the journal file fails, then the code still\n** tries to unlock the database file if not in exclusive mode. If the\n** unlock operation fails as well, then the first error code related\n** to the first error encountered (the journal finalization one) is\n** returned.\n*/\nstatic int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){\n  int rc = SQLITE_OK;      /* Error code from journal finalization operation */\n  int rc2 = SQLITE_OK;     /* Error code from db file unlock operation */\n\n  /* Do nothing if the pager does not have an open write transaction\n  ** or at least a RESERVED lock. This function may be called when there\n  ** is no write-transaction active but a RESERVED or greater lock is\n  ** held under two circumstances:\n  **\n  **   1. After a successful hot-journal rollback, it is called with\n  **      eState==PAGER_NONE and eLock==EXCLUSIVE_LOCK.\n  **\n  **   2. If a connection with locking_mode=exclusive holding an EXCLUSIVE \n  **      lock switches back to locking_mode=normal and then executes a\n  **      read-transaction, this function is called with eState==PAGER_READER \n  **      and eLock==EXCLUSIVE_LOCK when the read-transaction is closed.\n  */\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState!=PAGER_ERROR );\n  if( pPager->eState<PAGER_WRITER_LOCKED && pPager->eLock<RESERVED_LOCK ){\n    return SQLITE_OK;\n  }\n\n  releaseAllSavepoints(pPager);\n  assert( isOpen(pPager->jfd) || pPager->pInJournal==0 \n      || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_BATCH_ATOMIC)\n  );\n  if( isOpen(pPager->jfd) ){\n    assert( !pagerUseWal(pPager) );\n\n    /* Finalize the journal file. */\n    if( sqlite3JournalIsInMemory(pPager->jfd) ){\n      /* assert( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ); */\n      sqlite3OsClose(pPager->jfd);\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_TRUNCATE ){\n      if( pPager->journalOff==0 ){\n        rc = SQLITE_OK;\n      }else{\n        rc = sqlite3OsTruncate(pPager->jfd, 0);\n        if( rc==SQLITE_OK && pPager->fullSync ){\n          /* Make sure the new file size is written into the inode right away.\n          ** Otherwise the journal might resurrect following a power loss and\n          ** cause the last transaction to roll back.  See\n          ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773\n          */\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n        }\n      }\n      pPager->journalOff = 0;\n    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)\n    ){\n      rc = zeroJournalHdr(pPager, hasMaster||pPager->tempFile);\n      pPager->journalOff = 0;\n    }else{\n      /* This branch may be executed with Pager.journalMode==MEMORY if\n      ** a hot-journal was just rolled back. In this case the journal\n      ** file should be closed and deleted. If this connection writes to\n      ** the database file, it will do so using an in-memory journal.\n      */\n      int bDelete = !pPager->tempFile;\n      assert( sqlite3JournalIsInMemory(pPager->jfd)==0 );\n      assert( pPager->journalMode==PAGER_JOURNALMODE_DELETE \n           || pPager->journalMode==PAGER_JOURNALMODE_MEMORY \n           || pPager->journalMode==PAGER_JOURNALMODE_WAL \n      );\n      sqlite3OsClose(pPager->jfd);\n      if( bDelete ){\n        rc = sqlite3OsDelete(pPager->pVfs, pPager->zJournal, pPager->extraSync);\n      }\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  sqlite3PcacheIterateDirty(pPager->pPCache, pager_set_pagehash);\n  if( pPager->dbSize==0 && sqlite3PcacheRefCount(pPager->pPCache)>0 ){\n    PgHdr *p = sqlite3PagerLookup(pPager, 1);\n    if( p ){\n      p->pageHash = 0;\n      sqlite3PagerUnrefNotNull(p);\n    }\n  }\n#endif\n\n  sqlite3BitvecDestroy(pPager->pInJournal);\n  pPager->pInJournal = 0;\n  pPager->nRec = 0;\n  if( rc==SQLITE_OK ){\n    if( MEMDB || pagerFlushOnCommit(pPager, bCommit) ){\n      sqlite3PcacheCleanAll(pPager->pPCache);\n    }else{\n      sqlite3PcacheClearWritable(pPager->pPCache);\n    }\n    sqlite3PcacheTruncate(pPager->pPCache, pPager->dbSize);\n  }\n\n  if( pagerUseWal(pPager) ){\n    /* Drop the WAL write-lock, if any. Also, if the connection was in \n    ** locking_mode=exclusive mode but is no longer, drop the EXCLUSIVE \n    ** lock held on the database file.\n    */\n    rc2 = sqlite3WalEndWriteTransaction(pPager->pWal);\n    assert( rc2==SQLITE_OK );\n  }else if( rc==SQLITE_OK && bCommit && pPager->dbFileSize>pPager->dbSize ){\n    /* This branch is taken when committing a transaction in rollback-journal\n    ** mode if the database file on disk is larger than the database image.\n    ** At this point the journal has been finalized and the transaction \n    ** successfully committed, but the EXCLUSIVE lock is still held on the\n    ** file. So it is safe to truncate the database file to its minimum\n    ** required size.  */\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    rc = pager_truncate(pPager, pPager->dbSize);\n  }\n\n  if( rc==SQLITE_OK && bCommit && isOpen(pPager->fd) ){\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  }\n\n  if( !pPager->exclusiveMode \n   && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0))\n  ){\n    rc2 = pagerUnlockDb(pPager, SHARED_LOCK);\n    pPager->changeCountDone = 0;\n  }\n  pPager->eState = PAGER_READER;\n  pPager->setMaster = 0;\n\n  return (rc==SQLITE_OK?rc2:rc);\n}\n\n/*\n** Execute a rollback if a transaction is active and unlock the \n** database file. \n**\n** If the pager has already entered the ERROR state, do not attempt \n** the rollback at this time. Instead, pager_unlock() is called. The\n** call to pager_unlock() will discard all in-memory pages, unlock\n** the database file and move the pager back to OPEN state. If this \n** means that there is a hot-journal left in the file-system, the next \n** connection to obtain a shared lock on the pager (which may be this one) \n** will roll it back.\n**\n** If the pager has not already entered the ERROR state, but an IO or\n** malloc error occurs during a rollback, then this will itself cause \n** the pager to enter the ERROR state. Which will be cleared by the\n** call to pager_unlock(), as described above.\n*/\nstatic void pagerUnlockAndRollback(Pager *pPager){\n  if( pPager->eState!=PAGER_ERROR && pPager->eState!=PAGER_OPEN ){\n    assert( assert_pager_state(pPager) );\n    if( pPager->eState>=PAGER_WRITER_LOCKED ){\n      sqlite3BeginBenignMalloc();\n      sqlite3PagerRollback(pPager);\n      sqlite3EndBenignMalloc();\n    }else if( !pPager->exclusiveMode ){\n      assert( pPager->eState==PAGER_READER );\n      pager_end_transaction(pPager, 0, 0);\n    }\n  }\n  pager_unlock(pPager);\n}\n\n/*\n** Parameter aData must point to a buffer of pPager->pageSize bytes\n** of data. Compute and return a checksum based ont the contents of the \n** page of data and the current value of pPager->cksumInit.\n**\n** This is not a real checksum. It is really just the sum of the \n** random initial value (pPager->cksumInit) and every 200th byte\n** of the page data, starting with byte offset (pPager->pageSize%200).\n** Each byte is interpreted as an 8-bit unsigned integer.\n**\n** Changing the formula used to compute this checksum results in an\n** incompatible journal file format.\n**\n** If journal corruption occurs due to a power failure, the most likely \n** scenario is that one end or the other of the record will be changed. \n** It is much less likely that the two ends of the journal record will be\n** correct and the middle be corrupt.  Thus, this \"checksum\" scheme,\n** though fast and simple, catches the mostly likely kind of corruption.\n*/\nstatic u32 pager_cksum(Pager *pPager, const u8 *aData){\n  u32 cksum = pPager->cksumInit;         /* Checksum value to return */\n  int i = pPager->pageSize-200;          /* Loop counter */\n  while( i>0 ){\n    cksum += aData[i];\n    i -= 200;\n  }\n  return cksum;\n}\n\n/*\n** Report the current page size and number of reserved bytes back\n** to the codec.\n*/\n#ifdef SQLITE_HAS_CODEC\nstatic void pagerReportSize(Pager *pPager){\n  if( pPager->xCodecSizeChng ){\n    pPager->xCodecSizeChng(pPager->pCodec, pPager->pageSize,\n                           (int)pPager->nReserve);\n  }\n}\n#else\n# define pagerReportSize(X)     /* No-op if we do not support a codec */\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Make sure the number of reserved bits is the same in the destination\n** pager as it is in the source.  This comes up when a VACUUM changes the\n** number of reserved bits to the \"optimal\" amount.\n*/\nvoid sqlite3PagerAlignReserve(Pager *pDest, Pager *pSrc){\n  if( pDest->nReserve!=pSrc->nReserve ){\n    pDest->nReserve = pSrc->nReserve;\n    pagerReportSize(pDest);\n  }\n}\n#endif\n\n/*\n** Read a single page from either the journal file (if isMainJrnl==1) or\n** from the sub-journal (if isMainJrnl==0) and playback that page.\n** The page begins at offset *pOffset into the file. The *pOffset\n** value is increased to the start of the next page in the journal.\n**\n** The main rollback journal uses checksums - the statement journal does \n** not.\n**\n** If the page number of the page record read from the (sub-)journal file\n** is greater than the current value of Pager.dbSize, then playback is\n** skipped and SQLITE_OK is returned.\n**\n** If pDone is not NULL, then it is a record of pages that have already\n** been played back.  If the page at *pOffset has already been played back\n** (if the corresponding pDone bit is set) then skip the playback.\n** Make sure the pDone bit corresponding to the *pOffset page is set\n** prior to returning.\n**\n** If the page record is successfully read from the (sub-)journal file\n** and played back, then SQLITE_OK is returned. If an IO error occurs\n** while reading the record from the (sub-)journal file or while writing\n** to the database file, then the IO error code is returned. If data\n** is successfully read from the (sub-)journal file but appears to be\n** corrupted, SQLITE_DONE is returned. Data is considered corrupted in\n** two circumstances:\n** \n**   * If the record page-number is illegal (0 or PAGER_MJ_PGNO), or\n**   * If the record is being rolled back from the main journal file\n**     and the checksum field does not match the record content.\n**\n** Neither of these two scenarios are possible during a savepoint rollback.\n**\n** If this is a savepoint rollback, then memory may have to be dynamically\n** allocated by this function. If this is the case and an allocation fails,\n** SQLITE_NOMEM is returned.\n*/\nstatic int pager_playback_one_page(\n  Pager *pPager,                /* The pager being played back */\n  i64 *pOffset,                 /* Offset of record to playback */\n  Bitvec *pDone,                /* Bitvec of pages already played back */\n  int isMainJrnl,               /* 1 -> main journal. 0 -> sub-journal. */\n  int isSavepnt                 /* True for a savepoint rollback */\n){\n  int rc;\n  PgHdr *pPg;                   /* An existing page in the cache */\n  Pgno pgno;                    /* The page number of a page in journal */\n  u32 cksum;                    /* Checksum used for sanity checking */\n  char *aData;                  /* Temporary storage for the page */\n  sqlite3_file *jfd;            /* The file descriptor for the journal file */\n  int isSynced;                 /* True if journal page is synced */\n#ifdef SQLITE_HAS_CODEC\n  /* The jrnlEnc flag is true if Journal pages should be passed through\n  ** the codec.  It is false for pure in-memory journals. */\n  const int jrnlEnc = (isMainJrnl || pPager->subjInMemory==0);\n#endif\n\n  assert( (isMainJrnl&~1)==0 );      /* isMainJrnl is 0 or 1 */\n  assert( (isSavepnt&~1)==0 );       /* isSavepnt is 0 or 1 */\n  assert( isMainJrnl || pDone );     /* pDone always used on sub-journals */\n  assert( isSavepnt || pDone==0 );   /* pDone never used on non-savepoint */\n\n  aData = pPager->pTmpSpace;\n  assert( aData );         /* Temp storage must have already been allocated */\n  assert( pagerUseWal(pPager)==0 || (!isMainJrnl && isSavepnt) );\n\n  /* Either the state is greater than PAGER_WRITER_CACHEMOD (a transaction \n  ** or savepoint rollback done at the request of the caller) or this is\n  ** a hot-journal rollback. If it is a hot-journal rollback, the pager\n  ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback\n  ** only reads from the main journal, not the sub-journal.\n  */\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD\n       || (pPager->eState==PAGER_OPEN && pPager->eLock==EXCLUSIVE_LOCK)\n  );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD || isMainJrnl );\n\n  /* Read the page number and page data from the journal or sub-journal\n  ** file. Return an error code to the caller if an IO error occurs.\n  */\n  jfd = isMainJrnl ? pPager->jfd : pPager->sjfd;\n  rc = read32bits(jfd, *pOffset, &pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsRead(jfd, (u8*)aData, pPager->pageSize, (*pOffset)+4);\n  if( rc!=SQLITE_OK ) return rc;\n  *pOffset += pPager->pageSize + 4 + isMainJrnl*4;\n\n  /* Sanity checking on the page.  This is more important that I originally\n  ** thought.  If a power failure occurs while the journal is being written,\n  ** it could cause invalid data to be written into the journal.  We need to\n  ** detect this invalid data (with high probability) and ignore it.\n  */\n  if( pgno==0 || pgno==PAGER_MJ_PGNO(pPager) ){\n    assert( !isSavepnt );\n    return SQLITE_DONE;\n  }\n  if( pgno>(Pgno)pPager->dbSize || sqlite3BitvecTest(pDone, pgno) ){\n    return SQLITE_OK;\n  }\n  if( isMainJrnl ){\n    rc = read32bits(jfd, (*pOffset)-4, &cksum);\n    if( rc ) return rc;\n    if( !isSavepnt && pager_cksum(pPager, (u8*)aData)!=cksum ){\n      return SQLITE_DONE;\n    }\n  }\n\n  /* If this page has already been played back before during the current\n  ** rollback, then don't bother to play it back again.\n  */\n  if( pDone && (rc = sqlite3BitvecSet(pDone, pgno))!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* When playing back page 1, restore the nReserve setting\n  */\n  if( pgno==1 && pPager->nReserve!=((u8*)aData)[20] ){\n    pPager->nReserve = ((u8*)aData)[20];\n    pagerReportSize(pPager);\n  }\n\n  /* If the pager is in CACHEMOD state, then there must be a copy of this\n  ** page in the pager cache. In this case just update the pager cache,\n  ** not the database file. The page is left marked dirty in this case.\n  **\n  ** An exception to the above rule: If the database is in no-sync mode\n  ** and a page is moved during an incremental vacuum then the page may\n  ** not be in the pager cache. Later: if a malloc() or IO error occurs\n  ** during a Movepage() call, then the page may not be in the cache\n  ** either. So the condition described in the above paragraph is not\n  ** assert()able.\n  **\n  ** If in WRITER_DBMOD, WRITER_FINISHED or OPEN state, then we update the\n  ** pager cache if it exists and the main file. The page is then marked \n  ** not dirty. Since this code is only executed in PAGER_OPEN state for\n  ** a hot-journal rollback, it is guaranteed that the page-cache is empty\n  ** if the pager is in OPEN state.\n  **\n  ** Ticket #1171:  The statement journal might contain page content that is\n  ** different from the page content at the start of the transaction.\n  ** This occurs when a page is changed prior to the start of a statement\n  ** then changed again within the statement.  When rolling back such a\n  ** statement we must not write to the original database unless we know\n  ** for certain that original page contents are synced into the main rollback\n  ** journal.  Otherwise, a power loss might leave modified data in the\n  ** database file without an entry in the rollback journal that can\n  ** restore the database to its original form.  Two conditions must be\n  ** met before writing to the database files. (1) the database must be\n  ** locked.  (2) we know that the original page content is fully synced\n  ** in the main journal either because the page is not in cache or else\n  ** the page is marked as needSync==0.\n  **\n  ** 2008-04-14:  When attempting to vacuum a corrupt database file, it\n  ** is possible to fail a statement on a database that does not yet exist.\n  ** Do not attempt to write if database file has never been opened.\n  */\n  if( pagerUseWal(pPager) ){\n    pPg = 0;\n  }else{\n    pPg = sqlite3PagerLookup(pPager, pgno);\n  }\n  assert( pPg || !MEMDB );\n  assert( pPager->eState!=PAGER_OPEN || pPg==0 || pPager->tempFile );\n  PAGERTRACE((\"PLAYBACK %d page %d hash(%08x) %s\\n\",\n           PAGERID(pPager), pgno, pager_datahash(pPager->pageSize, (u8*)aData),\n           (isMainJrnl?\"main-journal\":\"sub-journal\")\n  ));\n  if( isMainJrnl ){\n    isSynced = pPager->noSync || (*pOffset <= pPager->journalHdr);\n  }else{\n    isSynced = (pPg==0 || 0==(pPg->flags & PGHDR_NEED_SYNC));\n  }\n  if( isOpen(pPager->fd)\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n   && isSynced\n  ){\n    i64 ofst = (pgno-1)*(i64)pPager->pageSize;\n    testcase( !isSavepnt && pPg!=0 && (pPg->flags&PGHDR_NEED_SYNC)!=0 );\n    assert( !pagerUseWal(pPager) );\n\n    /* Write the data read from the journal back into the database file.\n    ** This is usually safe even for an encrypted database - as the data\n    ** was encrypted before it was written to the journal file. The exception\n    ** is if the data was just read from an in-memory sub-journal. In that\n    ** case it must be encrypted here before it is copied into the database\n    ** file.  */\n#ifdef SQLITE_HAS_CODEC\n    if( !jrnlEnc ){\n      CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT, aData);\n      rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n      CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n    }else\n#endif\n    rc = sqlite3OsWrite(pPager->fd, (u8 *)aData, pPager->pageSize, ofst);\n\n    if( pgno>pPager->dbFileSize ){\n      pPager->dbFileSize = pgno;\n    }\n    if( pPager->pBackup ){\n#ifdef SQLITE_HAS_CODEC\n      if( jrnlEnc ){\n        CODEC1(pPager, aData, pgno, 3, rc=SQLITE_NOMEM_BKPT);\n        sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n        CODEC2(pPager, aData, pgno, 7, rc=SQLITE_NOMEM_BKPT,aData);\n      }else\n#endif\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)aData);\n    }\n  }else if( !isMainJrnl && pPg==0 ){\n    /* If this is a rollback of a savepoint and data was not written to\n    ** the database and the page is not in-memory, there is a potential\n    ** problem. When the page is next fetched by the b-tree layer, it \n    ** will be read from the database file, which may or may not be \n    ** current. \n    **\n    ** There are a couple of different ways this can happen. All are quite\n    ** obscure. When running in synchronous mode, this can only happen \n    ** if the page is on the free-list at the start of the transaction, then\n    ** populated, then moved using sqlite3PagerMovepage().\n    **\n    ** The solution is to add an in-memory page to the cache containing\n    ** the data just read from the sub-journal. Mark the page as dirty \n    ** and if the pager requires a journal-sync, then mark the page as \n    ** requiring a journal-sync before it is written.\n    */\n    assert( isSavepnt );\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)==0 );\n    pPager->doNotSpill |= SPILLFLAG_ROLLBACK;\n    rc = sqlite3PagerGet(pPager, pgno, &pPg, 1);\n    assert( (pPager->doNotSpill & SPILLFLAG_ROLLBACK)!=0 );\n    pPager->doNotSpill &= ~SPILLFLAG_ROLLBACK;\n    if( rc!=SQLITE_OK ) return rc;\n    sqlite3PcacheMakeDirty(pPg);\n  }\n  if( pPg ){\n    /* No page should ever be explicitly rolled back that is in use, except\n    ** for page 1 which is held in use in order to keep the lock on the\n    ** database active. However such a page may be rolled back as a result\n    ** of an internal error resulting in an automatic call to\n    ** sqlite3PagerRollback().\n    */\n    void *pData;\n    pData = pPg->pData;\n    memcpy(pData, (u8*)aData, pPager->pageSize);\n    pPager->xReiniter(pPg);\n    /* It used to be that sqlite3PcacheMakeClean(pPg) was called here.  But\n    ** that call was dangerous and had no detectable benefit since the cache\n    ** is normally cleaned by sqlite3PcacheCleanAll() after rollback and so\n    ** has been removed. */\n    pager_set_pagehash(pPg);\n\n    /* If this was page 1, then restore the value of Pager.dbFileVers.\n    ** Do this before any decoding. */\n    if( pgno==1 ){\n      memcpy(&pPager->dbFileVers, &((u8*)pData)[24],sizeof(pPager->dbFileVers));\n    }\n\n    /* Decode the page just read from disk */\n#if SQLITE_HAS_CODEC\n    if( jrnlEnc ){ CODEC1(pPager, pData, pPg->pgno, 3, rc=SQLITE_NOMEM_BKPT); }\n#endif\n    sqlite3PcacheRelease(pPg);\n  }\n  return rc;\n}\n\n/*\n** Parameter zMaster is the name of a master journal file. A single journal\n** file that referred to the master journal file has just been rolled back.\n** This routine checks if it is possible to delete the master journal file,\n** and does so if it is.\n**\n** Argument zMaster may point to Pager.pTmpSpace. So that buffer is not \n** available for use within this function.\n**\n** When a master journal file is created, it is populated with the names \n** of all of its child journals, one after another, formatted as utf-8 \n** encoded text. The end of each child journal file is marked with a \n** nul-terminator byte (0x00). i.e. the entire contents of a master journal\n** file for a transaction involving two databases might be:\n**\n**   \"/home/bill/a.db-journal\\x00/home/bill/b.db-journal\\x00\"\n**\n** A master journal file may only be deleted once all of its child \n** journals have been rolled back.\n**\n** This function reads the contents of the master-journal file into \n** memory and loops through each of the child journal names. For\n** each child journal, it checks if:\n**\n**   * if the child journal exists, and if so\n**   * if the child journal contains a reference to master journal \n**     file zMaster\n**\n** If a child journal can be found that matches both of the criteria\n** above, this function returns without doing anything. Otherwise, if\n** no such child journal can be found, file zMaster is deleted from\n** the file-system using sqlite3OsDelete().\n**\n** If an IO error within this function, an error code is returned. This\n** function allocates memory by calling sqlite3Malloc(). If an allocation\n** fails, SQLITE_NOMEM is returned. Otherwise, if no IO or malloc errors \n** occur, SQLITE_OK is returned.\n**\n** TODO: This function allocates a single block of memory to load\n** the entire contents of the master journal file. This could be\n** a couple of kilobytes or so - potentially larger than the page \n** size.\n*/\nstatic int pager_delmaster(Pager *pPager, const char *zMaster){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  int rc;                   /* Return code */\n  sqlite3_file *pMaster;    /* Malloc'd master-journal file descriptor */\n  sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */\n  char *zMasterJournal = 0; /* Contents of master journal file */\n  i64 nMasterJournal;       /* Size of master journal file */\n  char *zJournal;           /* Pointer to one journal within MJ file */\n  char *zMasterPtr;         /* Space to hold MJ filename from a journal file */\n  int nMasterPtr;           /* Amount of space allocated to zMasterPtr[] */\n\n  /* Allocate space for both the pJournal and pMaster file descriptors.\n  ** If successful, open the master journal file for reading.\n  */\n  pMaster = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);\n  pJournal = (sqlite3_file *)(((u8 *)pMaster) + pVfs->szOsFile);\n  if( !pMaster ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MASTER_JOURNAL);\n    rc = sqlite3OsOpen(pVfs, zMaster, pMaster, flags, 0);\n  }\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n\n  /* Load the entire master journal file into space obtained from\n  ** sqlite3_malloc() and pointed to by zMasterJournal.   Also obtain\n  ** sufficient space (in zMasterPtr) to hold the names of master\n  ** journal files extracted from regular rollback-journals.\n  */\n  rc = sqlite3OsFileSize(pMaster, &nMasterJournal);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  nMasterPtr = pVfs->mxPathname+1;\n  zMasterJournal = sqlite3Malloc(nMasterJournal + nMasterPtr + 1);\n  if( !zMasterJournal ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto delmaster_out;\n  }\n  zMasterPtr = &zMasterJournal[nMasterJournal+1];\n  rc = sqlite3OsRead(pMaster, zMasterJournal, (int)nMasterJournal, 0);\n  if( rc!=SQLITE_OK ) goto delmaster_out;\n  zMasterJournal[nMasterJournal] = 0;\n\n  zJournal = zMasterJournal;\n  while( (zJournal-zMasterJournal)<nMasterJournal ){\n    int exists;\n    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);\n    if( rc!=SQLITE_OK ){\n      goto delmaster_out;\n    }\n    if( exists ){\n      /* One of the journals pointed to by the master journal exists.\n      ** Open it and check if it points at the master journal. If\n      ** so, return without deleting the master journal file.\n      */\n      int c;\n      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL);\n      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      rc = readMasterJournal(pJournal, zMasterPtr, nMasterPtr);\n      sqlite3OsClose(pJournal);\n      if( rc!=SQLITE_OK ){\n        goto delmaster_out;\n      }\n\n      c = zMasterPtr[0]!=0 && strcmp(zMasterPtr, zMaster)==0;\n      if( c ){\n        /* We have a match. Do not delete the master journal file. */\n        goto delmaster_out;\n      }\n    }\n    zJournal += (sqlite3Strlen30(zJournal)+1);\n  }\n \n  sqlite3OsClose(pMaster);\n  rc = sqlite3OsDelete(pVfs, zMaster, 0);\n\ndelmaster_out:\n  sqlite3_free(zMasterJournal);\n  if( pMaster ){\n    sqlite3OsClose(pMaster);\n    assert( !isOpen(pJournal) );\n    sqlite3_free(pMaster);\n  }\n  return rc;\n}\n\n\n/*\n** This function is used to change the actual size of the database \n** file in the file-system. This only happens when committing a transaction,\n** or rolling back a transaction (including rolling back a hot-journal).\n**\n** If the main database file is not open, or the pager is not in either\n** DBMOD or OPEN state, this function is a no-op. Otherwise, the size \n** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). \n** If the file on disk is currently larger than nPage pages, then use the VFS\n** xTruncate() method to truncate it.\n**\n** Or, it might be the case that the file on disk is smaller than \n** nPage pages. Some operating system implementations can get confused if \n** you try to truncate a file to some size that is larger than it \n** currently is, so detect this case and write a single zero byte to \n** the end of the new file instead.\n**\n** If successful, return SQLITE_OK. If an IO error occurs while modifying\n** the database file, return the error code to the caller.\n*/\nstatic int pager_truncate(Pager *pPager, Pgno nPage){\n  int rc = SQLITE_OK;\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState!=PAGER_READER );\n  \n  if( isOpen(pPager->fd) \n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN) \n  ){\n    i64 currentSize, newSize;\n    int szPage = pPager->pageSize;\n    assert( pPager->eLock==EXCLUSIVE_LOCK );\n    /* TODO: Is it safe to use Pager.dbFileSize here? */\n    rc = sqlite3OsFileSize(pPager->fd, &currentSize);\n    newSize = szPage*(i64)nPage;\n    if( rc==SQLITE_OK && currentSize!=newSize ){\n      if( currentSize>newSize ){\n        rc = sqlite3OsTruncate(pPager->fd, newSize);\n      }else if( (currentSize+szPage)<=newSize ){\n        char *pTmp = pPager->pTmpSpace;\n        memset(pTmp, 0, szPage);\n        testcase( (newSize-szPage) == currentSize );\n        testcase( (newSize-szPage) >  currentSize );\n        rc = sqlite3OsWrite(pPager->fd, pTmp, szPage, newSize-szPage);\n      }\n      if( rc==SQLITE_OK ){\n        pPager->dbFileSize = nPage;\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Return a sanitized version of the sector-size of OS file pFile. The\n** return value is guaranteed to lie between 32 and MAX_SECTOR_SIZE.\n*/\nint sqlite3SectorSize(sqlite3_file *pFile){\n  int iRet = sqlite3OsSectorSize(pFile);\n  if( iRet<32 ){\n    iRet = 512;\n  }else if( iRet>MAX_SECTOR_SIZE ){\n    assert( MAX_SECTOR_SIZE>=512 );\n    iRet = MAX_SECTOR_SIZE;\n  }\n  return iRet;\n}\n\n/*\n** Set the value of the Pager.sectorSize variable for the given\n** pager based on the value returned by the xSectorSize method\n** of the open database file. The sector size will be used \n** to determine the size and alignment of journal header and \n** master journal pointers within created journal files.\n**\n** For temporary files the effective sector size is always 512 bytes.\n**\n** Otherwise, for non-temporary files, the effective sector size is\n** the value returned by the xSectorSize() method rounded up to 32 if\n** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it\n** is greater than MAX_SECTOR_SIZE.\n**\n** If the file has the SQLITE_IOCAP_POWERSAFE_OVERWRITE property, then set\n** the effective sector size to its minimum value (512).  The purpose of\n** pPager->sectorSize is to define the \"blast radius\" of bytes that\n** might change if a crash occurs while writing to a single byte in\n** that range.  But with POWERSAFE_OVERWRITE, the blast radius is zero\n** (that is what POWERSAFE_OVERWRITE means), so we minimize the sector\n** size.  For backwards compatibility of the rollback journal file format,\n** we cannot reduce the effective sector size below 512.\n*/\nstatic void setSectorSize(Pager *pPager){\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  if( pPager->tempFile\n   || (sqlite3OsDeviceCharacteristics(pPager->fd) & \n              SQLITE_IOCAP_POWERSAFE_OVERWRITE)!=0\n  ){\n    /* Sector size doesn't matter for temporary files. Also, the file\n    ** may not have been opened yet, in which case the OsSectorSize()\n    ** call will segfault. */\n    pPager->sectorSize = 512;\n  }else{\n    pPager->sectorSize = sqlite3SectorSize(pPager->fd);\n  }\n}\n\n/*\n** Playback the journal and thus restore the database file to\n** the state it was in before we started making changes.  \n**\n** The journal file format is as follows: \n**\n**  (1)  8 byte prefix.  A copy of aJournalMagic[].\n**  (2)  4 byte big-endian integer which is the number of valid page records\n**       in the journal.  If this value is 0xffffffff, then compute the\n**       number of page records from the journal size.\n**  (3)  4 byte big-endian integer which is the initial value for the \n**       sanity checksum.\n**  (4)  4 byte integer which is the number of pages to truncate the\n**       database to during a rollback.\n**  (5)  4 byte big-endian integer which is the sector size.  The header\n**       is this many bytes in size.\n**  (6)  4 byte big-endian integer which is the page size.\n**  (7)  zero padding out to the next sector size.\n**  (8)  Zero or more pages instances, each as follows:\n**        +  4 byte page number.\n**        +  pPager->pageSize bytes of data.\n**        +  4 byte checksum\n**\n** When we speak of the journal header, we mean the first 7 items above.\n** Each entry in the journal is an instance of the 8th item.\n**\n** Call the value from the second bullet \"nRec\".  nRec is the number of\n** valid page entries in the journal.  In most cases, you can compute the\n** value of nRec from the size of the journal file.  But if a power\n** failure occurred while the journal was being written, it could be the\n** case that the size of the journal file had already been increased but\n** the extra entries had not yet made it safely to disk.  In such a case,\n** the value of nRec computed from the file size would be too large.  For\n** that reason, we always use the nRec value in the header.\n**\n** If the nRec value is 0xffffffff it means that nRec should be computed\n** from the file size.  This value is used when the user selects the\n** no-sync option for the journal.  A power failure could lead to corruption\n** in this case.  But for things like temporary table (which will be\n** deleted when the power is restored) we don't care.  \n**\n** If the file opened as the journal file is not a well-formed\n** journal file then all pages up to the first corrupted page are rolled\n** back (or no pages if the journal header is corrupted). The journal file\n** is then deleted and SQLITE_OK returned, just as if no corruption had\n** been encountered.\n**\n** If an I/O or malloc() error occurs, the journal-file is not deleted\n** and an error code is returned.\n**\n** The isHot parameter indicates that we are trying to rollback a journal\n** that might be a hot journal.  Or, it could be that the journal is \n** preserved because of JOURNALMODE_PERSIST or JOURNALMODE_TRUNCATE.\n** If the journal really is hot, reset the pager cache prior rolling\n** back any content.  If the journal is merely persistent, no reset is\n** needed.\n*/\nstatic int pager_playback(Pager *pPager, int isHot){\n  sqlite3_vfs *pVfs = pPager->pVfs;\n  i64 szJ;                 /* Size of the journal file in bytes */\n  u32 nRec;                /* Number of Records in the journal */\n  u32 u;                   /* Unsigned loop counter */\n  Pgno mxPg = 0;           /* Size of the original file in pages */\n  int rc;                  /* Result code of a subroutine */\n  int res = 1;             /* Value returned by sqlite3OsAccess() */\n  char *zMaster = 0;       /* Name of master journal file if any */\n  int needPagerReset;      /* True to reset page prior to first page rollback */\n  int nPlayback = 0;       /* Total number of pages restored from journal */\n  u32 savedPageSize = pPager->pageSize;\n\n  /* Figure out how many records are in the journal.  Abort early if\n  ** the journal is empty.\n  */\n  assert( isOpen(pPager->jfd) );\n  rc = sqlite3OsFileSize(pPager->jfd, &szJ);\n  if( rc!=SQLITE_OK ){\n    goto end_playback;\n  }\n\n  /* Read the master journal name from the journal, if it is present.\n  ** If a master journal file name is specified, but the file is not\n  ** present on disk, then the journal is not hot and does not need to be\n  ** played back.\n  **\n  ** TODO: Technically the following is an error because it assumes that\n  ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that\n  ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,\n  ** mxPathname is 512, which is the same as the minimum allowable value\n  ** for pageSize.\n  */\n  zMaster = pPager->pTmpSpace;\n  rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n  if( rc==SQLITE_OK && zMaster[0] ){\n    rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n  }\n  zMaster = 0;\n  if( rc!=SQLITE_OK || !res ){\n    goto end_playback;\n  }\n  pPager->journalOff = 0;\n  needPagerReset = isHot;\n\n  /* This loop terminates either when a readJournalHdr() or \n  ** pager_playback_one_page() call returns SQLITE_DONE or an IO error \n  ** occurs. \n  */\n  while( 1 ){\n    /* Read the next journal header from the journal file.  If there are\n    ** not enough bytes left in the journal file for a complete header, or\n    ** it is corrupted, then a process must have failed while writing it.\n    ** This indicates nothing more needs to be rolled back.\n    */\n    rc = readJournalHdr(pPager, isHot, szJ, &nRec, &mxPg);\n    if( rc!=SQLITE_OK ){ \n      if( rc==SQLITE_DONE ){\n        rc = SQLITE_OK;\n      }\n      goto end_playback;\n    }\n\n    /* If nRec is 0xffffffff, then this journal was created by a process\n    ** working in no-sync mode. This means that the rest of the journal\n    ** file consists of pages, there are no more journal headers. Compute\n    ** the value of nRec based on this assumption.\n    */\n    if( nRec==0xffffffff ){\n      assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) );\n      nRec = (int)((szJ - JOURNAL_HDR_SZ(pPager))/JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If nRec is 0 and this rollback is of a transaction created by this\n    ** process and if this is the final header in the journal, then it means\n    ** that this part of the journal was being filled but has not yet been\n    ** synced to disk.  Compute the number of pages based on the remaining\n    ** size of the file.\n    **\n    ** The third term of the test was added to fix ticket #2565.\n    ** When rolling back a hot journal, nRec==0 always means that the next\n    ** chunk of the journal contains zero pages to be rolled back.  But\n    ** when doing a ROLLBACK and the nRec==0 chunk is the last chunk in\n    ** the journal, it means that the journal might contain additional\n    ** pages that need to be rolled back and that the number of pages \n    ** should be computed based on the journal file size.\n    */\n    if( nRec==0 && !isHot &&\n        pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff ){\n      nRec = (int)((szJ - pPager->journalOff) / JOURNAL_PG_SZ(pPager));\n    }\n\n    /* If this is the first header read from the journal, truncate the\n    ** database file back to its original size.\n    */\n    if( pPager->journalOff==JOURNAL_HDR_SZ(pPager) ){\n      rc = pager_truncate(pPager, mxPg);\n      if( rc!=SQLITE_OK ){\n        goto end_playback;\n      }\n      pPager->dbSize = mxPg;\n    }\n\n    /* Copy original pages out of the journal and back into the \n    ** database file and/or page cache.\n    */\n    for(u=0; u<nRec; u++){\n      if( needPagerReset ){\n        pager_reset(pPager);\n        needPagerReset = 0;\n      }\n      rc = pager_playback_one_page(pPager,&pPager->journalOff,0,1,0);\n      if( rc==SQLITE_OK ){\n        nPlayback++;\n      }else{\n        if( rc==SQLITE_DONE ){\n          pPager->journalOff = szJ;\n          break;\n        }else if( rc==SQLITE_IOERR_SHORT_READ ){\n          /* If the journal has been truncated, simply stop reading and\n          ** processing the journal. This might happen if the journal was\n          ** not completely written and synced prior to a crash.  In that\n          ** case, the database should have never been written in the\n          ** first place so it is OK to simply abandon the rollback. */\n          rc = SQLITE_OK;\n          goto end_playback;\n        }else{\n          /* If we are unable to rollback, quit and return the error\n          ** code.  This will cause the pager to enter the error state\n          ** so that no further harm will be done.  Perhaps the next\n          ** process to come along will be able to rollback the database.\n          */\n          goto end_playback;\n        }\n      }\n    }\n  }\n  /*NOTREACHED*/\n  assert( 0 );\n\nend_playback:\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerSetPagesize(pPager, &savedPageSize, -1);\n  }\n  /* Following a rollback, the database file should be back in its original\n  ** state prior to the start of the transaction, so invoke the\n  ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the\n  ** assertion that the transaction counter was modified.\n  */\n#ifdef SQLITE_DEBUG\n  if( pPager->fd->pMethods ){\n    sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0);\n  }\n#endif\n\n  /* If this playback is happening automatically as a result of an IO or \n  ** malloc error that occurred after the change-counter was updated but \n  ** before the transaction was committed, then the change-counter \n  ** modification may just have been reverted. If this happens in exclusive \n  ** mode, then subsequent transactions performed by the connection will not\n  ** update the change-counter at all. This may lead to cache inconsistency\n  ** problems for other processes at some point in the future. So, just\n  ** in case this has happened, clear the changeCountDone flag now.\n  */\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( rc==SQLITE_OK ){\n    zMaster = pPager->pTmpSpace;\n    rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK\n   && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)\n  ){\n    rc = sqlite3PagerSync(pPager, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = pager_end_transaction(pPager, zMaster[0]!='\\0', 0);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( rc==SQLITE_OK && zMaster[0] && res ){\n    /* If there was a master journal and this routine will return success,\n    ** see if it is possible to delete the master journal.\n    */\n    rc = pager_delmaster(pPager, zMaster);\n    testcase( rc!=SQLITE_OK );\n  }\n  if( isHot && nPlayback ){\n    sqlite3_log(SQLITE_NOTICE_RECOVER_ROLLBACK, \"recovered %d pages from %s\",\n                nPlayback, pPager->zJournal);\n  }\n\n  /* The Pager.sectorSize variable may have been updated while rolling\n  ** back a journal created by a process with a different sector size\n  ** value. Reset it to the correct value for this process.\n  */\n  setSectorSize(pPager);\n  return rc;\n}\n\n\n/*\n** Read the content for page pPg out of the database file (or out of\n** the WAL if that is where the most recent copy if found) into \n** pPg->pData. A shared lock or greater must be held on the database\n** file before this function is called.\n**\n** If page 1 is read, then the value of Pager.dbFileVers[] is set to\n** the value read from the database file.\n**\n** If an IO error occurs, then the IO error is returned to the caller.\n** Otherwise, SQLITE_OK is returned.\n*/\nstatic int readDbPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */\n  int rc = SQLITE_OK;          /* Return code */\n\n#ifndef SQLITE_OMIT_WAL\n  u32 iFrame = 0;              /* Frame of WAL containing pgno */\n\n  assert( pPager->eState>=PAGER_READER && !MEMDB );\n  assert( isOpen(pPager->fd) );\n\n  if( pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);\n    if( rc ) return rc;\n  }\n  if( iFrame ){\n    rc = sqlite3WalReadFrame(pPager->pWal, iFrame,pPager->pageSize,pPg->pData);\n  }else\n#endif\n  {\n    i64 iOffset = (pPg->pgno-1)*(i64)pPager->pageSize;\n    rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n\n  if( pPg->pgno==1 ){\n    if( rc ){\n      /* If the read is unsuccessful, set the dbFileVers[] to something\n      ** that will never be a valid file version.  dbFileVers[] is a copy\n      ** of bytes 24..39 of the database.  Bytes 28..31 should always be\n      ** zero or the size of the database in page. Bytes 32..35 and 35..39\n      ** should be page numbers which are never 0xffffffff.  So filling\n      ** pPager->dbFileVers[] with all 0xff bytes should suffice.\n      **\n      ** For an encrypted database, the situation is more complex:  bytes\n      ** 24..39 of the database are white noise.  But the probability of\n      ** white noise equaling 16 bytes of 0xff is vanishingly small so\n      ** we should still be ok.\n      */\n      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));\n    }else{\n      u8 *dbFileVers = &((u8*)pPg->pData)[24];\n      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));\n    }\n  }\n  CODEC1(pPager, pPg->pData, pPg->pgno, 3, rc = SQLITE_NOMEM_BKPT);\n\n  PAGER_INCR(sqlite3_pager_readdb_count);\n  PAGER_INCR(pPager->nRead);\n  IOTRACE((\"PGIN %p %d\\n\", pPager, pPg->pgno));\n  PAGERTRACE((\"FETCH %d page %d hash(%08x)\\n\",\n               PAGERID(pPager), pPg->pgno, pager_pagehash(pPg)));\n\n  return rc;\n}\n\n/*\n** Update the value of the change-counter at offsets 24 and 92 in\n** the header and the sqlite version number at offset 96.\n**\n** This is an unconditional update.  See also the pager_incr_changecounter()\n** routine which only updates the change-counter if the update is actually\n** needed, as determined by the pPager->changeCountDone state variable.\n*/\nstatic void pager_write_changecounter(PgHdr *pPg){\n  u32 change_counter;\n\n  /* Increment the value just read and write it back to byte 24. */\n  change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1;\n  put32bits(((char*)pPg->pData)+24, change_counter);\n\n  /* Also store the SQLite version number in bytes 96..99 and in\n  ** bytes 92..95 store the change counter for which the version number\n  ** is valid. */\n  put32bits(((char*)pPg->pData)+92, change_counter);\n  put32bits(((char*)pPg->pData)+96, SQLITE_VERSION_NUMBER);\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is invoked once for each page that has already been \n** written into the log file when a WAL transaction is rolled back.\n** Parameter iPg is the page number of said page. The pCtx argument \n** is actually a pointer to the Pager structure.\n**\n** If page iPg is present in the cache, and has no outstanding references,\n** it is discarded. Otherwise, if there are one or more outstanding\n** references, the page content is reloaded from the database. If the\n** attempt to reload content from the database is required and fails, \n** return an SQLite error code. Otherwise, SQLITE_OK.\n*/\nstatic int pagerUndoCallback(void *pCtx, Pgno iPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = (Pager *)pCtx;\n  PgHdr *pPg;\n\n  assert( pagerUseWal(pPager) );\n  pPg = sqlite3PagerLookup(pPager, iPg);\n  if( pPg ){\n    if( sqlite3PcachePageRefcount(pPg)==1 ){\n      sqlite3PcacheDrop(pPg);\n    }else{\n      rc = readDbPage(pPg);\n      if( rc==SQLITE_OK ){\n        pPager->xReiniter(pPg);\n      }\n      sqlite3PagerUnrefNotNull(pPg);\n    }\n  }\n\n  /* Normally, if a transaction is rolled back, any backup processes are\n  ** updated as data is copied out of the rollback journal and into the\n  ** database. This is not generally possible with a WAL database, as\n  ** rollback involves simply truncating the log file. Therefore, if one\n  ** or more frames have already been written to the log (and therefore \n  ** also copied into the backup databases) as part of this transaction,\n  ** the backups must be restarted.\n  */\n  sqlite3BackupRestart(pPager->pBackup);\n\n  return rc;\n}\n\n/*\n** This function is called to rollback a transaction on a WAL database.\n*/\nstatic int pagerRollbackWal(Pager *pPager){\n  int rc;                         /* Return Code */\n  PgHdr *pList;                   /* List of dirty pages to revert */\n\n  /* For all pages in the cache that are currently dirty or have already\n  ** been written (but not committed) to the log file, do one of the \n  ** following:\n  **\n  **   + Discard the cached page (if refcount==0), or\n  **   + Reload page content from the database (if refcount>0).\n  */\n  pPager->dbSize = pPager->dbOrigSize;\n  rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  while( pList && rc==SQLITE_OK ){\n    PgHdr *pNext = pList->pDirty;\n    rc = pagerUndoCallback((void *)pPager, pList->pgno);\n    pList = pNext;\n  }\n\n  return rc;\n}\n\n/*\n** This function is a wrapper around sqlite3WalFrames(). As well as logging\n** the contents of the list of pages headed by pList (connected by pDirty),\n** this function notifies any active backup processes that the pages have\n** changed. \n**\n** The list of pages passed into this routine is always sorted by page number.\n** Hence, if page 1 appears anywhere on the list, it will be the first page.\n*/ \nstatic int pagerWalFrames(\n  Pager *pPager,                  /* Pager object */\n  PgHdr *pList,                   /* List of frames to log */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit                    /* True if this is a commit */\n){\n  int rc;                         /* Return code */\n  int nList;                      /* Number of pages in pList */\n  PgHdr *p;                       /* For looping over pages */\n\n  assert( pPager->pWal );\n  assert( pList );\n#ifdef SQLITE_DEBUG\n  /* Verify that the page list is in accending order */\n  for(p=pList; p && p->pDirty; p=p->pDirty){\n    assert( p->pgno < p->pDirty->pgno );\n  }\n#endif\n\n  assert( pList->pDirty==0 || isCommit );\n  if( isCommit ){\n    /* If a WAL transaction is being committed, there is no point in writing\n    ** any pages with page numbers greater than nTruncate into the WAL file.\n    ** They will never be read by any client. So remove them from the pDirty\n    ** list here. */\n    PgHdr **ppNext = &pList;\n    nList = 0;\n    for(p=pList; (*ppNext = p)!=0; p=p->pDirty){\n      if( p->pgno<=nTruncate ){\n        ppNext = &p->pDirty;\n        nList++;\n      }\n    }\n    assert( pList );\n  }else{\n    nList = 1;\n  }\n  pPager->aStat[PAGER_STAT_WRITE] += nList;\n\n  if( pList->pgno==1 ) pager_write_changecounter(pList);\n  rc = sqlite3WalFrames(pPager->pWal, \n      pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags\n  );\n  if( rc==SQLITE_OK && pPager->pBackup ){\n    for(p=pList; p; p=p->pDirty){\n      sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);\n    }\n  }\n\n#ifdef SQLITE_CHECK_PAGES\n  pList = sqlite3PcacheDirtyList(pPager->pPCache);\n  for(p=pList; p; p=p->pDirty){\n    pager_set_pagehash(p);\n  }\n#endif\n\n  return rc;\n}\n\n/*\n** Begin a read transaction on the WAL.\n**\n** This routine used to be called \"pagerOpenSnapshot()\" because it essentially\n** makes a snapshot of the database at the current point in time and preserves\n** that snapshot for use by the reader in spite of concurrently changes by\n** other writers or checkpointers.\n*/\nstatic int pagerBeginReadTransaction(Pager *pPager){\n  int rc;                         /* Return code */\n  int changed = 0;                /* True if cache must be reset */\n\n  assert( pagerUseWal(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n\n  /* sqlite3WalEndReadTransaction() was not called for the previous\n  ** transaction in locking_mode=EXCLUSIVE.  So call it now.  If we\n  ** are in locking_mode=NORMAL and EndRead() was previously called,\n  ** the duplicate call is harmless.\n  */\n  sqlite3WalEndReadTransaction(pPager->pWal);\n\n  rc = sqlite3WalBeginReadTransaction(pPager->pWal, &changed);\n  if( rc!=SQLITE_OK || changed ){\n    pager_reset(pPager);\n    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);\n  }\n\n  return rc;\n}\n#endif\n\n/*\n** This function is called as part of the transition from PAGER_OPEN\n** to PAGER_READER state to determine the size of the database file\n** in pages (assuming the page size currently stored in Pager.pageSize).\n**\n** If no error occurs, SQLITE_OK is returned and the size of the database\n** in pages is stored in *pnPage. Otherwise, an error code (perhaps\n** SQLITE_IOERR_FSTAT) is returned and *pnPage is left unmodified.\n*/\nstatic int pagerPagecount(Pager *pPager, Pgno *pnPage){\n  Pgno nPage;                     /* Value to return via *pnPage */\n\n  /* Query the WAL sub-system for the database size. The WalDbsize()\n  ** function returns zero if the WAL is not open (i.e. Pager.pWal==0), or\n  ** if the database size is not available. The database size is not\n  ** available from the WAL sub-system if the log file is empty or\n  ** contains no valid committed transactions.\n  */\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->tempFile==0 );\n  nPage = sqlite3WalDbsize(pPager->pWal);\n\n  /* If the number of pages in the database is not available from the\n  ** WAL sub-system, determine the page count based on the size of\n  ** the database file.  If the size of the database file is not an\n  ** integer multiple of the page-size, round up the result.\n  */\n  if( nPage==0 && ALWAYS(isOpen(pPager->fd)) ){\n    i64 n = 0;                    /* Size of db file in bytes */\n    int rc = sqlite3OsFileSize(pPager->fd, &n);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nPage = (Pgno)((n+pPager->pageSize-1) / pPager->pageSize);\n  }\n\n  /* If the current number of pages in the file is greater than the\n  ** configured maximum pager number, increase the allowed limit so\n  ** that the file can be read.\n  */\n  if( nPage>pPager->mxPgno ){\n    pPager->mxPgno = (Pgno)nPage;\n  }\n\n  *pnPage = nPage;\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** Check if the *-wal file that corresponds to the database opened by pPager\n** exists if the database is not empy, or verify that the *-wal file does\n** not exist (by deleting it) if the database file is empty.\n**\n** If the database is not empty and the *-wal file exists, open the pager\n** in WAL mode.  If the database is empty or if no *-wal file exists and\n** if no error occurs, make sure Pager.journalMode is not set to\n** PAGER_JOURNALMODE_WAL.\n**\n** Return SQLITE_OK or an error code.\n**\n** The caller must hold a SHARED lock on the database file to call this\n** function. Because an EXCLUSIVE lock on the db file is required to delete \n** a WAL on a none-empty database, this ensures there is no race condition \n** between the xAccess() below and an xDelete() being executed by some \n** other connection.\n*/\nstatic int pagerOpenWalIfPresent(Pager *pPager){\n  int rc = SQLITE_OK;\n  assert( pPager->eState==PAGER_OPEN );\n  assert( pPager->eLock>=SHARED_LOCK );\n\n  if( !pPager->tempFile ){\n    int isWal;                    /* True if WAL file exists */\n    rc = sqlite3OsAccess(\n        pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &isWal\n    );\n    if( rc==SQLITE_OK ){\n      if( isWal ){\n        Pgno nPage;                   /* Size of the database file */\n\n        rc = pagerPagecount(pPager, &nPage);\n        if( rc ) return rc;\n        if( nPage==0 ){\n          rc = sqlite3OsDelete(pPager->pVfs, pPager->zWal, 0);\n        }else{\n          testcase( sqlite3PcachePagecount(pPager->pPCache)==0 );\n          rc = sqlite3PagerOpenWal(pPager, 0);\n        }\n      }else if( pPager->journalMode==PAGER_JOURNALMODE_WAL ){\n        pPager->journalMode = PAGER_JOURNALMODE_DELETE;\n      }\n    }\n  }\n  return rc;\n}\n#endif\n\n/*\n** Playback savepoint pSavepoint. Or, if pSavepoint==NULL, then playback\n** the entire master journal file. The case pSavepoint==NULL occurs when \n** a ROLLBACK TO command is invoked on a SAVEPOINT that is a transaction \n** savepoint.\n**\n** When pSavepoint is not NULL (meaning a non-transaction savepoint is \n** being rolled back), then the rollback consists of up to three stages,\n** performed in the order specified:\n**\n**   * Pages are played back from the main journal starting at byte\n**     offset PagerSavepoint.iOffset and continuing to \n**     PagerSavepoint.iHdrOffset, or to the end of the main journal\n**     file if PagerSavepoint.iHdrOffset is zero.\n**\n**   * If PagerSavepoint.iHdrOffset is not zero, then pages are played\n**     back starting from the journal header immediately following \n**     PagerSavepoint.iHdrOffset to the end of the main journal file.\n**\n**   * Pages are then played back from the sub-journal file, starting\n**     with the PagerSavepoint.iSubRec and continuing to the end of\n**     the journal file.\n**\n** Throughout the rollback process, each time a page is rolled back, the\n** corresponding bit is set in a bitvec structure (variable pDone in the\n** implementation below). This is used to ensure that a page is only\n** rolled back the first time it is encountered in either journal.\n**\n** If pSavepoint is NULL, then pages are only played back from the main\n** journal file. There is no need for a bitvec in this case.\n**\n** In either case, before playback commences the Pager.dbSize variable\n** is reset to the value that it held at the start of the savepoint \n** (or transaction). No page with a page-number greater than this value\n** is played back. If one is encountered it is simply skipped.\n*/\nstatic int pagerPlaybackSavepoint(Pager *pPager, PagerSavepoint *pSavepoint){\n  i64 szJ;                 /* Effective size of the main journal */\n  i64 iHdrOff;             /* End of first segment of main-journal records */\n  int rc = SQLITE_OK;      /* Return code */\n  Bitvec *pDone = 0;       /* Bitvec to ensure pages played back only once */\n\n  assert( pPager->eState!=PAGER_ERROR );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n\n  /* Allocate a bitvec to use to store the set of pages rolled back */\n  if( pSavepoint ){\n    pDone = sqlite3BitvecCreate(pSavepoint->nOrig);\n    if( !pDone ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  }\n\n  /* Set the database size back to the value it was before the savepoint \n  ** being reverted was opened.\n  */\n  pPager->dbSize = pSavepoint ? pSavepoint->nOrig : pPager->dbOrigSize;\n  pPager->changeCountDone = pPager->tempFile;\n\n  if( !pSavepoint && pagerUseWal(pPager) ){\n    return pagerRollbackWal(pPager);\n  }\n\n  /* Use pPager->journalOff as the effective size of the main rollback\n  ** journal.  The actual file might be larger than this in\n  ** PAGER_JOURNALMODE_TRUNCATE or PAGER_JOURNALMODE_PERSIST.  But anything\n  ** past pPager->journalOff is off-limits to us.\n  */\n  szJ = pPager->journalOff;\n  assert( pagerUseWal(pPager)==0 || szJ==0 );\n\n  /* Begin by rolling back records from the main journal starting at\n  ** PagerSavepoint.iOffset and continuing to the next journal header.\n  ** There might be records in the main journal that have a page number\n  ** greater than the current database size (pPager->dbSize) but those\n  ** will be skipped automatically.  Pages are added to pDone as they\n  ** are played back.\n  */\n  if( pSavepoint && !pagerUseWal(pPager) ){\n    iHdrOff = pSavepoint->iHdrOffset ? pSavepoint->iHdrOffset : szJ;\n    pPager->journalOff = pSavepoint->iOffset;\n    while( rc==SQLITE_OK && pPager->journalOff<iHdrOff ){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }else{\n    pPager->journalOff = 0;\n  }\n\n  /* Continue rolling back records out of the main journal starting at\n  ** the first journal header seen and continuing until the effective end\n  ** of the main journal file.  Continue to skip out-of-range pages and\n  ** continue adding pages rolled back to pDone.\n  */\n  while( rc==SQLITE_OK && pPager->journalOff<szJ ){\n    u32 ii;            /* Loop counter */\n    u32 nJRec = 0;     /* Number of Journal Records */\n    u32 dummy;\n    rc = readJournalHdr(pPager, 0, szJ, &nJRec, &dummy);\n    assert( rc!=SQLITE_DONE );\n\n    /*\n    ** The \"pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\"\n    ** test is related to ticket #2565.  See the discussion in the\n    ** pager_playback() function for additional information.\n    */\n    if( nJRec==0 \n     && pPager->journalHdr+JOURNAL_HDR_SZ(pPager)==pPager->journalOff\n    ){\n      nJRec = (u32)((szJ - pPager->journalOff)/JOURNAL_PG_SZ(pPager));\n    }\n    for(ii=0; rc==SQLITE_OK && ii<nJRec && pPager->journalOff<szJ; ii++){\n      rc = pager_playback_one_page(pPager, &pPager->journalOff, pDone, 1, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n  assert( rc!=SQLITE_OK || pPager->journalOff>=szJ );\n\n  /* Finally,  rollback pages from the sub-journal.  Page that were\n  ** previously rolled back out of the main journal (and are hence in pDone)\n  ** will be skipped.  Out-of-range pages are also skipped.\n  */\n  if( pSavepoint ){\n    u32 ii;            /* Loop counter */\n    i64 offset = (i64)pSavepoint->iSubRec*(4+pPager->pageSize);\n\n    if( pagerUseWal(pPager) ){\n      rc = sqlite3WalSavepointUndo(pPager->pWal, pSavepoint->aWalData);\n    }\n    for(ii=pSavepoint->iSubRec; rc==SQLITE_OK && ii<pPager->nSubRec; ii++){\n      assert( offset==(i64)ii*(4+pPager->pageSize) );\n      rc = pager_playback_one_page(pPager, &offset, pDone, 0, 1);\n    }\n    assert( rc!=SQLITE_DONE );\n  }\n\n  sqlite3BitvecDestroy(pDone);\n  if( rc==SQLITE_OK ){\n    pPager->journalOff = szJ;\n  }\n\n  return rc;\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to recycle clean and unused pages.\n*/\nvoid sqlite3PagerSetCachesize(Pager *pPager, int mxPage){\n  sqlite3PcacheSetCachesize(pPager->pPCache, mxPage);\n}\n\n/*\n** Change the maximum number of in-memory pages that are allowed\n** before attempting to spill pages to journal.\n*/\nint sqlite3PagerSetSpillsize(Pager *pPager, int mxPage){\n  return sqlite3PcacheSetSpillsize(pPager->pPCache, mxPage);\n}\n\n/*\n** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of szMmap.\n*/\nstatic void pagerFixMaplimit(Pager *pPager){\n#if SQLITE_MAX_MMAP_SIZE>0\n  sqlite3_file *fd = pPager->fd;\n  if( isOpen(fd) && fd->pMethods->iVersion>=3 ){\n    sqlite3_int64 sz;\n    sz = pPager->szMmap;\n    pPager->bUseFetch = (sz>0);\n    setGetterMethod(pPager);\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, &sz);\n  }\n#endif\n}\n\n/*\n** Change the maximum size of any memory mapping made of the database file.\n*/\nvoid sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 szMmap){\n  pPager->szMmap = szMmap;\n  pagerFixMaplimit(pPager);\n}\n\n/*\n** Free as much memory as possible from the pager.\n*/\nvoid sqlite3PagerShrink(Pager *pPager){\n  sqlite3PcacheShrink(pPager->pPCache);\n}\n\n/*\n** Adjust settings of the pager to those specified in the pgFlags parameter.\n**\n** The \"level\" in pgFlags & PAGER_SYNCHRONOUS_MASK sets the robustness\n** of the database to damage due to OS crashes or power failures by\n** changing the number of syncs()s when writing the journals.\n** There are four levels:\n**\n**    OFF       sqlite3OsSync() is never called.  This is the default\n**              for temporary and transient files.\n**\n**    NORMAL    The journal is synced once before writes begin on the\n**              database.  This is normally adequate protection, but\n**              it is theoretically possible, though very unlikely,\n**              that an inopertune power failure could leave the journal\n**              in a state which would cause damage to the database\n**              when it is rolled back.\n**\n**    FULL      The journal is synced twice before writes begin on the\n**              database (with some additional information - the nRec field\n**              of the journal header - being written in between the two\n**              syncs).  If we assume that writing a\n**              single disk sector is atomic, then this mode provides\n**              assurance that the journal will not be corrupted to the\n**              point of causing damage to the database during rollback.\n**\n**    EXTRA     This is like FULL except that is also syncs the directory\n**              that contains the rollback journal after the rollback\n**              journal is unlinked.\n**\n** The above is for a rollback-journal mode.  For WAL mode, OFF continues\n** to mean that no syncs ever occur.  NORMAL means that the WAL is synced\n** prior to the start of checkpoint and that the database file is synced\n** at the conclusion of the checkpoint if the entire content of the WAL\n** was written back into the database.  But no sync operations occur for\n** an ordinary commit in NORMAL mode with WAL.  FULL means that the WAL\n** file is synced following each commit operation, in addition to the\n** syncs associated with NORMAL.  There is no difference between FULL\n** and EXTRA for WAL mode.\n**\n** Do not confuse synchronous=FULL with SQLITE_SYNC_FULL.  The\n** SQLITE_SYNC_FULL macro means to use the MacOSX-style full-fsync\n** using fcntl(F_FULLFSYNC).  SQLITE_SYNC_NORMAL means to do an\n** ordinary fsync() call.  There is no difference between SQLITE_SYNC_FULL\n** and SQLITE_SYNC_NORMAL on platforms other than MacOSX.  But the\n** synchronous=FULL versus synchronous=NORMAL setting determines when\n** the xSync primitive is called and is relevant to all platforms.\n**\n** Numeric values associated with these states are OFF==1, NORMAL=2,\n** and FULL=3.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nvoid sqlite3PagerSetFlags(\n  Pager *pPager,        /* The pager to set safety level for */\n  unsigned pgFlags      /* Various flags */\n){\n  unsigned level = pgFlags & PAGER_SYNCHRONOUS_MASK;\n  if( pPager->tempFile ){\n    pPager->noSync = 1;\n    pPager->fullSync = 0;\n    pPager->extraSync = 0;\n  }else{\n    pPager->noSync =  level==PAGER_SYNCHRONOUS_OFF ?1:0;\n    pPager->fullSync = level>=PAGER_SYNCHRONOUS_FULL ?1:0;\n    pPager->extraSync = level==PAGER_SYNCHRONOUS_EXTRA ?1:0;\n  }\n  if( pPager->noSync ){\n    pPager->syncFlags = 0;\n  }else if( pgFlags & PAGER_FULLFSYNC ){\n    pPager->syncFlags = SQLITE_SYNC_FULL;\n  }else{\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n  }\n  pPager->walSyncFlags = (pPager->syncFlags<<2);\n  if( pPager->fullSync ){\n    pPager->walSyncFlags |= pPager->syncFlags;\n  }\n  if( (pgFlags & PAGER_CKPT_FULLFSYNC) && !pPager->noSync ){\n    pPager->walSyncFlags |= (SQLITE_SYNC_FULL<<2);\n  }\n  if( pgFlags & PAGER_CACHESPILL ){\n    pPager->doNotSpill &= ~SPILLFLAG_OFF;\n  }else{\n    pPager->doNotSpill |= SPILLFLAG_OFF;\n  }\n}\n#endif\n\n/*\n** The following global variable is incremented whenever the library\n** attempts to open a temporary file.  This information is used for\n** testing and analysis only.  \n*/\n#ifdef SQLITE_TEST\nint sqlite3_opentemp_count = 0;\n#endif\n\n/*\n** Open a temporary file.\n**\n** Write the file descriptor into *pFile. Return SQLITE_OK on success \n** or some other error code if we fail. The OS will automatically \n** delete the temporary file when it is closed.\n**\n** The flags passed to the VFS layer xOpen() call are those specified\n** by parameter vfsFlags ORed with the following:\n**\n**     SQLITE_OPEN_READWRITE\n**     SQLITE_OPEN_CREATE\n**     SQLITE_OPEN_EXCLUSIVE\n**     SQLITE_OPEN_DELETEONCLOSE\n*/\nstatic int pagerOpentemp(\n  Pager *pPager,        /* The pager object */\n  sqlite3_file *pFile,  /* Write the file descriptor here */\n  int vfsFlags          /* Flags passed through to the VFS */\n){\n  int rc;               /* Return code */\n\n#ifdef SQLITE_TEST\n  sqlite3_opentemp_count++;  /* Used for testing and analysis only */\n#endif\n\n  vfsFlags |=  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |\n            SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE;\n  rc = sqlite3OsOpen(pPager->pVfs, 0, pFile, vfsFlags, 0);\n  assert( rc!=SQLITE_OK || isOpen(pFile) );\n  return rc;\n}\n\n/*\n** Set the busy handler function.\n**\n** The pager invokes the busy-handler if sqlite3OsLock() returns \n** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,\n** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE \n** lock. It does *not* invoke the busy handler when upgrading from\n** SHARED to RESERVED, or when upgrading from SHARED to EXCLUSIVE\n** (which occurs during hot-journal rollback). Summary:\n**\n**   Transition                        | Invokes xBusyHandler\n**   --------------------------------------------------------\n**   NO_LOCK       -> SHARED_LOCK      | Yes\n**   SHARED_LOCK   -> RESERVED_LOCK    | No\n**   SHARED_LOCK   -> EXCLUSIVE_LOCK   | No\n**   RESERVED_LOCK -> EXCLUSIVE_LOCK   | Yes\n**\n** If the busy-handler callback returns non-zero, the lock is \n** retried. If it returns zero, then the SQLITE_BUSY error is\n** returned to the caller of the pager API function.\n*/\nvoid sqlite3PagerSetBusyhandler(\n  Pager *pPager,                       /* Pager object */\n  int (*xBusyHandler)(void *),         /* Pointer to busy-handler function */\n  void *pBusyHandlerArg                /* Argument to pass to xBusyHandler */\n){\n  pPager->xBusyHandler = xBusyHandler;\n  pPager->pBusyHandlerArg = pBusyHandlerArg;\n\n  if( isOpen(pPager->fd) ){\n    void **ap = (void **)&pPager->xBusyHandler;\n    assert( ((int(*)(void *))(ap[0]))==xBusyHandler );\n    assert( ap[1]==pBusyHandlerArg );\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap);\n  }\n}\n\n/*\n** Change the page size used by the Pager object. The new page size \n** is passed in *pPageSize.\n**\n** If the pager is in the error state when this function is called, it\n** is a no-op. The value returned is the error state error code (i.e. \n** one of SQLITE_IOERR, an SQLITE_IOERR_xxx sub-code or SQLITE_FULL).\n**\n** Otherwise, if all of the following are true:\n**\n**   * the new page size (value of *pPageSize) is valid (a power \n**     of two between 512 and SQLITE_MAX_PAGE_SIZE, inclusive), and\n**\n**   * there are no outstanding page references, and\n**\n**   * the database is either not an in-memory database or it is\n**     an in-memory database that currently consists of zero pages.\n**\n** then the pager object page size is set to *pPageSize.\n**\n** If the page size is changed, then this function uses sqlite3PagerMalloc() \n** to obtain a new Pager.pTmpSpace buffer. If this allocation attempt \n** fails, SQLITE_NOMEM is returned and the page size remains unchanged. \n** In all other cases, SQLITE_OK is returned.\n**\n** If the page size is not changed, either because one of the enumerated\n** conditions above is not true, the pager was in error state when this\n** function was called, or because the memory allocation attempt failed, \n** then *pPageSize is set to the old, retained page size before returning.\n*/\nint sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){\n  int rc = SQLITE_OK;\n\n  /* It is not possible to do a full assert_pager_state() here, as this\n  ** function may be called from within PagerOpen(), before the state\n  ** of the Pager object is internally consistent.\n  **\n  ** At one point this function returned an error if the pager was in \n  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that\n  ** there is at least one outstanding page reference, this function\n  ** is a no-op for that case anyhow.\n  */\n\n  u32 pageSize = *pPageSize;\n  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );\n  if( (pPager->memDb==0 || pPager->dbSize==0)\n   && sqlite3PcacheRefCount(pPager->pPCache)==0 \n   && pageSize && pageSize!=(u32)pPager->pageSize \n  ){\n    char *pNew = NULL;             /* New temp space */\n    i64 nByte = 0;\n\n    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){\n      rc = sqlite3OsFileSize(pPager->fd, &nByte);\n    }\n    if( rc==SQLITE_OK ){\n      pNew = (char *)sqlite3PageMalloc(pageSize);\n      if( !pNew ) rc = SQLITE_NOMEM_BKPT;\n    }\n\n    if( rc==SQLITE_OK ){\n      pager_reset(pPager);\n      rc = sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3PageFree(pPager->pTmpSpace);\n      pPager->pTmpSpace = pNew;\n      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);\n      pPager->pageSize = pageSize;\n    }else{\n      sqlite3PageFree(pNew);\n    }\n  }\n\n  *pPageSize = pPager->pageSize;\n  if( rc==SQLITE_OK ){\n    if( nReserve<0 ) nReserve = pPager->nReserve;\n    assert( nReserve>=0 && nReserve<1000 );\n    pPager->nReserve = (i16)nReserve;\n    pagerReportSize(pPager);\n    pagerFixMaplimit(pPager);\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to the \"temporary page\" buffer held internally\n** by the pager.  This is a buffer that is big enough to hold the\n** entire content of a database page.  This buffer is used internally\n** during rollback and will be overwritten whenever a rollback\n** occurs.  But other modules are free to use it too, as long as\n** no rollbacks are happening.\n*/\nvoid *sqlite3PagerTempSpace(Pager *pPager){\n  return pPager->pTmpSpace;\n}\n\n/*\n** Attempt to set the maximum database page count if mxPage is positive. \n** Make no changes if mxPage is zero or negative.  And never reduce the\n** maximum page count below the current size of the database.\n**\n** Regardless of mxPage, return the current maximum page count.\n*/\nint sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){\n  if( mxPage>0 ){\n    pPager->mxPgno = mxPage;\n  }\n  assert( pPager->eState!=PAGER_OPEN );      /* Called only by OP_MaxPgcnt */\n  assert( pPager->mxPgno>=pPager->dbSize );  /* OP_MaxPgcnt enforces this */\n  return pPager->mxPgno;\n}\n\n/*\n** The following set of routines are used to disable the simulated\n** I/O error mechanism.  These routines are used to avoid simulated\n** errors in places where we do not care about errors.\n**\n** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops\n** and generate no code.\n*/\n#ifdef SQLITE_TEST\nextern int sqlite3_io_error_pending;\nextern int sqlite3_io_error_hit;\nstatic int saved_cnt;\nvoid disable_simulated_io_errors(void){\n  saved_cnt = sqlite3_io_error_pending;\n  sqlite3_io_error_pending = -1;\n}\nvoid enable_simulated_io_errors(void){\n  sqlite3_io_error_pending = saved_cnt;\n}\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n/*\n** Read the first N bytes from the beginning of the file into memory\n** that pDest points to. \n**\n** If the pager was opened on a transient file (zFilename==\"\"), or\n** opened on a file less than N bytes in size, the output buffer is\n** zeroed and SQLITE_OK returned. The rationale for this is that this \n** function is used to read database headers, and a new transient or\n** zero sized database has a header than consists entirely of zeroes.\n**\n** If any IO error apart from SQLITE_IOERR_SHORT_READ is encountered,\n** the error code is returned to the caller and the contents of the\n** output buffer undefined.\n*/\nint sqlite3PagerReadFileheader(Pager *pPager, int N, unsigned char *pDest){\n  int rc = SQLITE_OK;\n  memset(pDest, 0, N);\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n\n  /* This routine is only called by btree immediately after creating\n  ** the Pager object.  There has not been an opportunity to transition\n  ** to WAL mode yet.\n  */\n  assert( !pagerUseWal(pPager) );\n\n  if( isOpen(pPager->fd) ){\n    IOTRACE((\"DBHDR %p 0 %d\\n\", pPager, N))\n    rc = sqlite3OsRead(pPager->fd, pDest, N, 0);\n    if( rc==SQLITE_IOERR_SHORT_READ ){\n      rc = SQLITE_OK;\n    }\n  }\n  return rc;\n}\n\n/*\n** This function may only be called when a read-transaction is open on\n** the pager. It returns the total number of pages in the database.\n**\n** However, if the file is between 1 and <page-size> bytes in size, then \n** this is considered a 1 page file.\n*/\nvoid sqlite3PagerPagecount(Pager *pPager, int *pnPage){\n  assert( pPager->eState>=PAGER_READER );\n  assert( pPager->eState!=PAGER_WRITER_FINISHED );\n  *pnPage = (int)pPager->dbSize;\n}\n\n\n/*\n** Try to obtain a lock of type locktype on the database file. If\n** a similar or greater lock is already held, this function is a no-op\n** (returning SQLITE_OK immediately).\n**\n** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke \n** the busy callback if the lock is currently not available. Repeat \n** until the busy callback returns false or until the attempt to \n** obtain the lock succeeds.\n**\n** Return SQLITE_OK on success and an error code if we cannot obtain\n** the lock. If the lock is obtained successfully, set the Pager.state \n** variable to locktype before returning.\n*/\nstatic int pager_wait_on_lock(Pager *pPager, int locktype){\n  int rc;                              /* Return code */\n\n  /* Check that this is either a no-op (because the requested lock is \n  ** already held), or one of the transitions that the busy-handler\n  ** may be invoked during, according to the comment above\n  ** sqlite3PagerSetBusyhandler().\n  */\n  assert( (pPager->eLock>=locktype)\n       || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)\n       || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)\n  );\n\n  do {\n    rc = pagerLockDb(pPager, locktype);\n  }while( rc==SQLITE_BUSY && pPager->xBusyHandler(pPager->pBusyHandlerArg) );\n  return rc;\n}\n\n/*\n** Function assertTruncateConstraint(pPager) checks that one of the \n** following is true for all dirty pages currently in the page-cache:\n**\n**   a) The page number is less than or equal to the size of the \n**      current database image, in pages, OR\n**\n**   b) if the page content were written at this time, it would not\n**      be necessary to write the current content out to the sub-journal\n**      (as determined by function subjRequiresPage()).\n**\n** If the condition asserted by this function were not true, and the\n** dirty page were to be discarded from the cache via the pagerStress()\n** routine, pagerStress() would not write the current page content to\n** the database file. If a savepoint transaction were rolled back after\n** this happened, the correct behavior would be to restore the current\n** content of the page. However, since this content is not present in either\n** the database file or the portion of the rollback journal and \n** sub-journal rolled back the content could not be restored and the\n** database image would become corrupt. It is therefore fortunate that \n** this circumstance cannot arise.\n*/\n#if defined(SQLITE_DEBUG)\nstatic void assertTruncateConstraintCb(PgHdr *pPg){\n  assert( pPg->flags&PGHDR_DIRTY );\n  assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );\n}\nstatic void assertTruncateConstraint(Pager *pPager){\n  sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);\n}\n#else\n# define assertTruncateConstraint(pPager)\n#endif\n\n/*\n** Truncate the in-memory database file image to nPage pages. This \n** function does not actually modify the database file on disk. It \n** just sets the internal state of the pager object so that the \n** truncation will be done when the current transaction is committed.\n**\n** This function is only called right before committing a transaction.\n** Once this function has been called, the transaction must either be\n** rolled back or committed. It is not safe to call this function and\n** then continue writing to the database.\n*/\nvoid sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){\n  assert( pPager->dbSize>=nPage );\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  pPager->dbSize = nPage;\n\n  /* At one point the code here called assertTruncateConstraint() to\n  ** ensure that all pages being truncated away by this operation are,\n  ** if one or more savepoints are open, present in the savepoint \n  ** journal so that they can be restored if the savepoint is rolled\n  ** back. This is no longer necessary as this function is now only\n  ** called right before committing a transaction. So although the \n  ** Pager object may still have open savepoints (Pager.nSavepoint!=0), \n  ** they cannot be rolled back. So the assertTruncateConstraint() call\n  ** is no longer correct. */\n}\n\n\n/*\n** This function is called before attempting a hot-journal rollback. It\n** syncs the journal file to disk, then sets pPager->journalHdr to the\n** size of the journal file so that the pager_playback() routine knows\n** that the entire journal file has been synced.\n**\n** Syncing a hot-journal to disk before attempting to roll it back ensures \n** that if a power-failure occurs during the rollback, the process that\n** attempts rollback following system recovery sees the same journal\n** content as this process.\n**\n** If everything goes as planned, SQLITE_OK is returned. Otherwise, \n** an SQLite error code.\n*/\nstatic int pagerSyncHotJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !pPager->noSync ){\n    rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_NORMAL);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsFileSize(pPager->jfd, &pPager->journalHdr);\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** Obtain a reference to a memory mapped page object for page number pgno. \n** The new object will use the pointer pData, obtained from xFetch().\n** If successful, set *ppPage to point to the new page reference\n** and return SQLITE_OK. Otherwise, return an SQLite error code and set\n** *ppPage to zero.\n**\n** Page references obtained by calling this function should be released\n** by calling pagerReleaseMapPage().\n*/\nstatic int pagerAcquireMapPage(\n  Pager *pPager,                  /* Pager object */\n  Pgno pgno,                      /* Page number */\n  void *pData,                    /* xFetch()'d data for this page */\n  PgHdr **ppPage                  /* OUT: Acquired page object */\n){\n  PgHdr *p;                       /* Memory mapped page to return */\n  \n  if( pPager->pMmapFreelist ){\n    *ppPage = p = pPager->pMmapFreelist;\n    pPager->pMmapFreelist = p->pDirty;\n    p->pDirty = 0;\n    assert( pPager->nExtra>=8 );\n    memset(p->pExtra, 0, 8);\n  }else{\n    *ppPage = p = (PgHdr *)sqlite3MallocZero(sizeof(PgHdr) + pPager->nExtra);\n    if( p==0 ){\n      sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1) * pPager->pageSize, pData);\n      return SQLITE_NOMEM_BKPT;\n    }\n    p->pExtra = (void *)&p[1];\n    p->flags = PGHDR_MMAP;\n    p->nRef = 1;\n    p->pPager = pPager;\n  }\n\n  assert( p->pExtra==(void *)&p[1] );\n  assert( p->pPage==0 );\n  assert( p->flags==PGHDR_MMAP );\n  assert( p->pPager==pPager );\n  assert( p->nRef==1 );\n\n  p->pgno = pgno;\n  p->pData = pData;\n  pPager->nMmapOut++;\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Release a reference to page pPg. pPg must have been returned by an \n** earlier call to pagerAcquireMapPage().\n*/\nstatic void pagerReleaseMapPage(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  pPager->nMmapOut--;\n  pPg->pDirty = pPager->pMmapFreelist;\n  pPager->pMmapFreelist = pPg;\n\n  assert( pPager->fd->pMethods->iVersion>=3 );\n  sqlite3OsUnfetch(pPager->fd, (i64)(pPg->pgno-1)*pPager->pageSize, pPg->pData);\n}\n\n/*\n** Free all PgHdr objects stored in the Pager.pMmapFreelist list.\n*/\nstatic void pagerFreeMapHdrs(Pager *pPager){\n  PgHdr *p;\n  PgHdr *pNext;\n  for(p=pPager->pMmapFreelist; p; p=pNext){\n    pNext = p->pDirty;\n    sqlite3_free(p);\n  }\n}\n\n\n/*\n** Shutdown the page cache.  Free all memory and close all files.\n**\n** If a transaction was in progress when this routine is called, that\n** transaction is rolled back.  All outstanding pages are invalidated\n** and their memory is freed.  Any attempt to use a page associated\n** with this page cache after this function returns will likely\n** result in a coredump.\n**\n** This function always succeeds. If a transaction is active an attempt\n** is made to roll it back. If an error occurs during the rollback \n** a hot journal may be left in the filesystem but no error is returned\n** to the caller.\n*/\nint sqlite3PagerClose(Pager *pPager, sqlite3 *db){\n  u8 *pTmp = (u8 *)pPager->pTmpSpace;\n\n  assert( db || pagerUseWal(pPager)==0 );\n  assert( assert_pager_state(pPager) );\n  disable_simulated_io_errors();\n  sqlite3BeginBenignMalloc();\n  pagerFreeMapHdrs(pPager);\n  /* pPager->errCode = 0; */\n  pPager->exclusiveMode = 0;\n#ifndef SQLITE_OMIT_WAL\n  assert( db || pPager->pWal==0 );\n  sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,\n      (db && (db->flags & SQLITE_NoCkptOnClose) ? 0 : pTmp)\n  );\n  pPager->pWal = 0;\n#endif\n  pager_reset(pPager);\n  if( MEMDB ){\n    pager_unlock(pPager);\n  }else{\n    /* If it is open, sync the journal file before calling UnlockAndRollback.\n    ** If this is not done, then an unsynced portion of the open journal \n    ** file may be played back into the database. If a power failure occurs \n    ** while this is happening, the database could become corrupt.\n    **\n    ** If an error occurs while trying to sync the journal, shift the pager\n    ** into the ERROR state. This causes UnlockAndRollback to unlock the\n    ** database and close the journal file without attempting to roll it\n    ** back or finalize it. The next database user will have to do hot-journal\n    ** rollback before accessing the database file.\n    */\n    if( isOpen(pPager->jfd) ){\n      pager_error(pPager, pagerSyncHotJournal(pPager));\n    }\n    pagerUnlockAndRollback(pPager);\n  }\n  sqlite3EndBenignMalloc();\n  enable_simulated_io_errors();\n  PAGERTRACE((\"CLOSE %d\\n\", PAGERID(pPager)));\n  IOTRACE((\"CLOSE %p\\n\", pPager))\n  sqlite3OsClose(pPager->jfd);\n  sqlite3OsClose(pPager->fd);\n  sqlite3PageFree(pTmp);\n  sqlite3PcacheClose(pPager->pPCache);\n\n#ifdef SQLITE_HAS_CODEC\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n#endif\n\n  assert( !pPager->aSavepoint && !pPager->pInJournal );\n  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );\n\n  sqlite3_free(pPager);\n  return SQLITE_OK;\n}\n\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\n/*\n** Return the page number for page pPg.\n*/\nPgno sqlite3PagerPagenumber(DbPage *pPg){\n  return pPg->pgno;\n}\n#endif\n\n/*\n** Increment the reference count for page pPg.\n*/\nvoid sqlite3PagerRef(DbPage *pPg){\n  sqlite3PcacheRef(pPg);\n}\n\n/*\n** Sync the journal. In other words, make sure all the pages that have\n** been written to the journal have actually reached the surface of the\n** disk and can be restored in the event of a hot-journal rollback.\n**\n** If the Pager.noSync flag is set, then this function is a no-op.\n** Otherwise, the actions required depend on the journal-mode and the \n** device characteristics of the file-system, as follows:\n**\n**   * If the journal file is an in-memory journal file, no action need\n**     be taken.\n**\n**   * Otherwise, if the device does not support the SAFE_APPEND property,\n**     then the nRec field of the most recently written journal header\n**     is updated to contain the number of journal records that have\n**     been written following it. If the pager is operating in full-sync\n**     mode, then the journal file is synced before this field is updated.\n**\n**   * If the device does not support the SEQUENTIAL property, then \n**     journal file is synced.\n**\n** Or, in pseudo-code:\n**\n**   if( NOT <in-memory journal> ){\n**     if( NOT SAFE_APPEND ){\n**       if( <full-sync mode> ) xSync(<journal file>);\n**       <update nRec field>\n**     } \n**     if( NOT SEQUENTIAL ) xSync(<journal file>);\n**   }\n**\n** If successful, this routine clears the PGHDR_NEED_SYNC flag of every \n** page currently held in memory before returning SQLITE_OK. If an IO\n** error is encountered, then the IO error code is returned to the caller.\n*/\nstatic int syncJournal(Pager *pPager, int newHdr){\n  int rc;                         /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( !pagerUseWal(pPager) );\n\n  rc = sqlite3PagerExclusiveLock(pPager);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( !pPager->noSync ){\n    assert( !pPager->tempFile );\n    if( isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY ){\n      const int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      assert( isOpen(pPager->jfd) );\n\n      if( 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        /* This block deals with an obscure problem. If the last connection\n        ** that wrote to this database was operating in persistent-journal\n        ** mode, then the journal file may at this point actually be larger\n        ** than Pager.journalOff bytes. If the next thing in the journal\n        ** file happens to be a journal-header (written as part of the\n        ** previous connection's transaction), and a crash or power-failure \n        ** occurs after nRec is updated but before this connection writes \n        ** anything else to the journal file (or commits/rolls back its \n        ** transaction), then SQLite may become confused when doing the \n        ** hot-journal rollback following recovery. It may roll back all\n        ** of this connections data, then proceed to rolling back the old,\n        ** out-of-date data that follows it. Database corruption.\n        **\n        ** To work around this, if the journal file does appear to contain\n        ** a valid header following Pager.journalOff, then write a 0x00\n        ** byte to the start of it to prevent it from being recognized.\n        **\n        ** Variable iNextHdrOffset is set to the offset at which this\n        ** problematic header will occur, if it exists. aMagic is used \n        ** as a temporary buffer to inspect the first couple of bytes of\n        ** the potential journal header.\n        */\n        i64 iNextHdrOffset;\n        u8 aMagic[8];\n        u8 zHeader[sizeof(aJournalMagic)+4];\n\n        memcpy(zHeader, aJournalMagic, sizeof(aJournalMagic));\n        put32bits(&zHeader[sizeof(aJournalMagic)], pPager->nRec);\n\n        iNextHdrOffset = journalHdrOffset(pPager);\n        rc = sqlite3OsRead(pPager->jfd, aMagic, 8, iNextHdrOffset);\n        if( rc==SQLITE_OK && 0==memcmp(aMagic, aJournalMagic, 8) ){\n          static const u8 zerobyte = 0;\n          rc = sqlite3OsWrite(pPager->jfd, &zerobyte, 1, iNextHdrOffset);\n        }\n        if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){\n          return rc;\n        }\n\n        /* Write the nRec value into the journal file header. If in\n        ** full-synchronous mode, sync the journal first. This ensures that\n        ** all data has really hit the disk before nRec is updated to mark\n        ** it as a candidate for rollback.\n        **\n        ** This is not required if the persistent media supports the\n        ** SAFE_APPEND property. Because in this case it is not possible \n        ** for garbage data to be appended to the file, the nRec field\n        ** is populated with 0xFFFFFFFF when the journal header is written\n        ** and never needs to be updated.\n        */\n        if( pPager->fullSync && 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n          PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n          IOTRACE((\"JSYNC %p\\n\", pPager))\n          rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);\n          if( rc!=SQLITE_OK ) return rc;\n        }\n        IOTRACE((\"JHDR %p %lld\\n\", pPager, pPager->journalHdr));\n        rc = sqlite3OsWrite(\n            pPager->jfd, zHeader, sizeof(zHeader), pPager->journalHdr\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n      if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n        PAGERTRACE((\"SYNC journal of %d\\n\", PAGERID(pPager)));\n        IOTRACE((\"JSYNC %p\\n\", pPager))\n        rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags| \n          (pPager->syncFlags==SQLITE_SYNC_FULL?SQLITE_SYNC_DATAONLY:0)\n        );\n        if( rc!=SQLITE_OK ) return rc;\n      }\n\n      pPager->journalHdr = pPager->journalOff;\n      if( newHdr && 0==(iDc&SQLITE_IOCAP_SAFE_APPEND) ){\n        pPager->nRec = 0;\n        rc = writeJournalHdr(pPager);\n        if( rc!=SQLITE_OK ) return rc;\n      }\n    }else{\n      pPager->journalHdr = pPager->journalOff;\n    }\n  }\n\n  /* Unless the pager is in noSync mode, the journal file was just \n  ** successfully synced. Either way, clear the PGHDR_NEED_SYNC flag on \n  ** all pages.\n  */\n  sqlite3PcacheClearSyncFlags(pPager->pPCache);\n  pPager->eState = PAGER_WRITER_DBMOD;\n  assert( assert_pager_state(pPager) );\n  return SQLITE_OK;\n}\n\n/*\n** The argument is the first in a linked list of dirty pages connected\n** by the PgHdr.pDirty pointer. This function writes each one of the\n** in-memory pages in the list to the database file. The argument may\n** be NULL, representing an empty list. In this case this function is\n** a no-op.\n**\n** The pager must hold at least a RESERVED lock when this function\n** is called. Before writing anything to the database file, this lock\n** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,\n** SQLITE_BUSY is returned and no data is written to the database file.\n** \n** If the pager is a temp-file pager and the actual file-system file\n** is not yet open, it is created and opened before any data is \n** written out.\n**\n** Once the lock has been upgraded and, if necessary, the file opened,\n** the pages are written out to the database file in list order. Writing\n** a page is skipped if it meets either of the following criteria:\n**\n**   * The page number is greater than Pager.dbSize, or\n**   * The PGHDR_DONT_WRITE flag is set on the page.\n**\n** If writing out a page causes the database file to grow, Pager.dbFileSize\n** is updated accordingly. If page 1 is written out, then the value cached\n** in Pager.dbFileVers[] is updated to match the new value stored in\n** the database file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot\n** be obtained, SQLITE_BUSY is returned.\n*/\nstatic int pager_write_pagelist(Pager *pPager, PgHdr *pList){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This function is only called for rollback pagers in WRITER_DBMOD state. */\n  assert( !pagerUseWal(pPager) );\n  assert( pPager->tempFile || pPager->eState==PAGER_WRITER_DBMOD );\n  assert( pPager->eLock==EXCLUSIVE_LOCK );\n  assert( isOpen(pPager->fd) || pList->pDirty==0 );\n\n  /* If the file is a temp-file has not yet been opened, open it now. It\n  ** is not possible for rc to be other than SQLITE_OK if this branch\n  ** is taken, as pager_wait_on_lock() is a no-op for temp-files.\n  */\n  if( !isOpen(pPager->fd) ){\n    assert( pPager->tempFile && rc==SQLITE_OK );\n    rc = pagerOpentemp(pPager, pPager->fd, pPager->vfsFlags);\n  }\n\n  /* Before the first write, give the VFS a hint of what the final\n  ** file size will be.\n  */\n  assert( rc!=SQLITE_OK || isOpen(pPager->fd) );\n  if( rc==SQLITE_OK \n   && pPager->dbHintSize<pPager->dbSize\n   && (pList->pDirty || pList->pgno>pPager->dbHintSize)\n  ){\n    sqlite3_int64 szFile = pPager->pageSize * (sqlite3_int64)pPager->dbSize;\n    sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_SIZE_HINT, &szFile);\n    pPager->dbHintSize = pPager->dbSize;\n  }\n\n  while( rc==SQLITE_OK && pList ){\n    Pgno pgno = pList->pgno;\n\n    /* If there are dirty pages in the page cache with page numbers greater\n    ** than Pager.dbSize, this means sqlite3PagerTruncateImage() was called to\n    ** make the file smaller (presumably by auto-vacuum code). Do not write\n    ** any such pages to the file.\n    **\n    ** Also, do not write out any page that has the PGHDR_DONT_WRITE flag\n    ** set (set by sqlite3PagerDontWrite()).\n    */\n    if( pgno<=pPager->dbSize && 0==(pList->flags&PGHDR_DONT_WRITE) ){\n      i64 offset = (pgno-1)*(i64)pPager->pageSize;   /* Offset to write */\n      char *pData;                                   /* Data to write */    \n\n      assert( (pList->flags&PGHDR_NEED_SYNC)==0 );\n      if( pList->pgno==1 ) pager_write_changecounter(pList);\n\n      /* Encode the database */\n      CODEC2(pPager, pList->pData, pgno, 6, return SQLITE_NOMEM_BKPT, pData);\n\n      /* Write out the page data. */\n      rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize, offset);\n\n      /* If page 1 was just written, update Pager.dbFileVers to match\n      ** the value now stored in the database file. If writing this \n      ** page caused the database file to grow, update dbFileSize. \n      */\n      if( pgno==1 ){\n        memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));\n      }\n      if( pgno>pPager->dbFileSize ){\n        pPager->dbFileSize = pgno;\n      }\n      pPager->aStat[PAGER_STAT_WRITE]++;\n\n      /* Update any backup objects copying the contents of this pager. */\n      sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);\n\n      PAGERTRACE((\"STORE %d page %d hash(%08x)\\n\",\n                   PAGERID(pPager), pgno, pager_pagehash(pList)));\n      IOTRACE((\"PGOUT %p %d\\n\", pPager, pgno));\n      PAGER_INCR(sqlite3_pager_writedb_count);\n    }else{\n      PAGERTRACE((\"NOSTORE %d page %d\\n\", PAGERID(pPager), pgno));\n    }\n    pager_set_pagehash(pList);\n    pList = pList->pDirty;\n  }\n\n  return rc;\n}\n\n/*\n** Ensure that the sub-journal file is open. If it is already open, this \n** function is a no-op.\n**\n** SQLITE_OK is returned if everything goes according to plan. An \n** SQLITE_IOERR_XXX error code is returned if a call to sqlite3OsOpen() \n** fails.\n*/\nstatic int openSubJournal(Pager *pPager){\n  int rc = SQLITE_OK;\n  if( !isOpen(pPager->sjfd) ){\n    const int flags =  SQLITE_OPEN_SUBJOURNAL | SQLITE_OPEN_READWRITE \n      | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE \n      | SQLITE_OPEN_DELETEONCLOSE;\n    int nStmtSpill = sqlite3Config.nStmtSpill;\n    if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY || pPager->subjInMemory ){\n      nStmtSpill = -1;\n    }\n    rc = sqlite3JournalOpen(pPager->pVfs, 0, pPager->sjfd, flags, nStmtSpill);\n  }\n  return rc;\n}\n\n/*\n** Append a record of the current state of page pPg to the sub-journal. \n**\n** If successful, set the bit corresponding to pPg->pgno in the bitvecs\n** for all open savepoints before returning.\n**\n** This function returns SQLITE_OK if everything is successful, an IO\n** error code if the attempt to write to the sub-journal fails, or \n** SQLITE_NOMEM if a malloc fails while setting a bit in a savepoint\n** bitvec.\n*/\nstatic int subjournalPage(PgHdr *pPg){\n  int rc = SQLITE_OK;\n  Pager *pPager = pPg->pPager;\n  if( pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n\n    /* Open the sub-journal, if it has not already been opened */\n    assert( pPager->useJournal );\n    assert( isOpen(pPager->jfd) || pagerUseWal(pPager) );\n    assert( isOpen(pPager->sjfd) || pPager->nSubRec==0 );\n    assert( pagerUseWal(pPager) \n         || pageInJournal(pPager, pPg) \n         || pPg->pgno>pPager->dbOrigSize \n    );\n    rc = openSubJournal(pPager);\n\n    /* If the sub-journal was opened successfully (or was already open),\n    ** write the journal record into the file.  */\n    if( rc==SQLITE_OK ){\n      void *pData = pPg->pData;\n      i64 offset = (i64)pPager->nSubRec*(4+pPager->pageSize);\n      char *pData2;\n\n#if SQLITE_HAS_CODEC   \n      if( !pPager->subjInMemory ){\n        CODEC2(pPager, pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n      }else\n#endif\n      pData2 = pData;\n      PAGERTRACE((\"STMT-JOURNAL %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n      rc = write32bits(pPager->sjfd, offset, pPg->pgno);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3OsWrite(pPager->sjfd, pData2, pPager->pageSize, offset+4);\n      }\n    }\n  }\n  if( rc==SQLITE_OK ){\n    pPager->nSubRec++;\n    assert( pPager->nSavepoint>0 );\n    rc = addToSavepointBitvecs(pPager, pPg->pgno);\n  }\n  return rc;\n}\nstatic int subjournalPageIfRequired(PgHdr *pPg){\n  if( subjRequiresPage(pPg) ){\n    return subjournalPage(pPg);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n/*\n** This function is called by the pcache layer when it has reached some\n** soft memory limit. The first argument is a pointer to a Pager object\n** (cast as a void*). The pager is always 'purgeable' (not an in-memory\n** database). The second argument is a reference to a page that is \n** currently dirty but has no outstanding references. The page\n** is always associated with the Pager object passed as the first \n** argument.\n**\n** The job of this function is to make pPg clean by writing its contents\n** out to the database file, if possible. This may involve syncing the\n** journal file. \n**\n** If successful, sqlite3PcacheMakeClean() is called on the page and\n** SQLITE_OK returned. If an IO error occurs while trying to make the\n** page clean, the IO error code is returned. If the page cannot be\n** made clean for some other reason, but no error occurs, then SQLITE_OK\n** is returned by sqlite3PcacheMakeClean() is not called.\n*/\nstatic int pagerStress(void *p, PgHdr *pPg){\n  Pager *pPager = (Pager *)p;\n  int rc = SQLITE_OK;\n\n  assert( pPg->pPager==pPager );\n  assert( pPg->flags&PGHDR_DIRTY );\n\n  /* The doNotSpill NOSYNC bit is set during times when doing a sync of\n  ** journal (and adding a new header) is not allowed.  This occurs\n  ** during calls to sqlite3PagerWrite() while trying to journal multiple\n  ** pages belonging to the same sector.\n  **\n  ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling\n  ** regardless of whether or not a sync is required.  This is set during\n  ** a rollback or by user request, respectively.\n  **\n  ** Spilling is also prohibited when in an error state since that could\n  ** lead to database corruption.   In the current implementation it \n  ** is impossible for sqlite3PcacheFetch() to be called with createFlag==3\n  ** while in the error state, hence it is impossible for this routine to\n  ** be called in the error state.  Nevertheless, we include a NEVER()\n  ** test for the error state as a safeguard against future changes.\n  */\n  if( NEVER(pPager->errCode) ) return SQLITE_OK;\n  testcase( pPager->doNotSpill & SPILLFLAG_ROLLBACK );\n  testcase( pPager->doNotSpill & SPILLFLAG_OFF );\n  testcase( pPager->doNotSpill & SPILLFLAG_NOSYNC );\n  if( pPager->doNotSpill\n   && ((pPager->doNotSpill & (SPILLFLAG_ROLLBACK|SPILLFLAG_OFF))!=0\n      || (pPg->flags & PGHDR_NEED_SYNC)!=0)\n  ){\n    return SQLITE_OK;\n  }\n\n  pPg->pDirty = 0;\n  if( pagerUseWal(pPager) ){\n    /* Write a single frame for this page to the log. */\n    rc = subjournalPageIfRequired(pPg); \n    if( rc==SQLITE_OK ){\n      rc = pagerWalFrames(pPager, pPg, 0, 0);\n    }\n  }else{\n    \n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n    if( pPager->tempFile==0 ){\n      rc = sqlite3JournalCreate(pPager->jfd);\n      if( rc!=SQLITE_OK ) return pager_error(pPager, rc);\n    }\n#endif\n  \n    /* Sync the journal file if required. */\n    if( pPg->flags&PGHDR_NEED_SYNC \n     || pPager->eState==PAGER_WRITER_CACHEMOD\n    ){\n      rc = syncJournal(pPager, 1);\n    }\n  \n    /* Write the contents of the page out to the database file. */\n    if( rc==SQLITE_OK ){\n      assert( (pPg->flags&PGHDR_NEED_SYNC)==0 );\n      rc = pager_write_pagelist(pPager, pPg);\n    }\n  }\n\n  /* Mark the page as clean. */\n  if( rc==SQLITE_OK ){\n    PAGERTRACE((\"STRESS %d page %d\\n\", PAGERID(pPager), pPg->pgno));\n    sqlite3PcacheMakeClean(pPg);\n  }\n\n  return pager_error(pPager, rc); \n}\n\n/*\n** Flush all unreferenced dirty pages to disk.\n*/\nint sqlite3PagerFlush(Pager *pPager){\n  int rc = pPager->errCode;\n  if( !MEMDB ){\n    PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n    assert( assert_pager_state(pPager) );\n    while( rc==SQLITE_OK && pList ){\n      PgHdr *pNext = pList->pDirty;\n      if( pList->nRef==0 ){\n        rc = pagerStress((void*)pPager, pList);\n      }\n      pList = pNext;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and initialize a new Pager object and put a pointer to it\n** in *ppPager. The pager should eventually be freed by passing it\n** to sqlite3PagerClose().\n**\n** The zFilename argument is the path to the database file to open.\n** If zFilename is NULL then a randomly-named temporary file is created\n** and used as the file to be cached. Temporary files are be deleted\n** automatically when they are closed. If zFilename is \":memory:\" then \n** all information is held in cache. It is never written to disk. \n** This can be used to implement an in-memory database.\n**\n** The nExtra parameter specifies the number of bytes of space allocated\n** along with each page reference. This space is available to the user\n** via the sqlite3PagerGetExtra() API.  When a new page is allocated, the\n** first 8 bytes of this space are zeroed but the remainder is uninitialized.\n** (The extra space is used by btree as the MemPage object.)\n**\n** The flags argument is used to specify properties that affect the\n** operation of the pager. It should be passed some bitwise combination\n** of the PAGER_* flags.\n**\n** The vfsFlags parameter is a bitmask to pass to the flags parameter\n** of the xOpen() method of the supplied VFS when opening files. \n**\n** If the pager object is allocated and the specified file opened \n** successfully, SQLITE_OK is returned and *ppPager set to point to\n** the new pager object. If an error occurs, *ppPager is set to NULL\n** and error code returned. This function may return SQLITE_NOMEM\n** (sqlite3Malloc() is used to allocate memory), SQLITE_CANTOPEN or \n** various SQLITE_IO_XXX errors.\n*/\nint sqlite3PagerOpen(\n  sqlite3_vfs *pVfs,       /* The virtual file system to use */\n  Pager **ppPager,         /* OUT: Return the Pager structure here */\n  const char *zFilename,   /* Name of the database file to open */\n  int nExtra,              /* Extra bytes append to each in-memory page */\n  int flags,               /* flags controlling this file */\n  int vfsFlags,            /* flags passed through to sqlite3_vfs.xOpen() */\n  void (*xReinit)(DbPage*) /* Function to reinitialize pages */\n){\n  u8 *pPtr;\n  Pager *pPager = 0;       /* Pager object to allocate and return */\n  int rc = SQLITE_OK;      /* Return code */\n  int tempFile = 0;        /* True for temp files (incl. in-memory files) */\n  int memDb = 0;           /* True if this is an in-memory file */\n  int readOnly = 0;        /* True if this is a read-only file */\n  int journalFileSize;     /* Bytes to allocate for each journal fd */\n  char *zPathname = 0;     /* Full path to database file */\n  int nPathname = 0;       /* Number of bytes in zPathname */\n  int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */\n  int pcacheSize = sqlite3PcacheSize();       /* Bytes to allocate for PCache */\n  u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE;  /* Default page size */\n  const char *zUri = 0;    /* URI args to copy */\n  int nUri = 0;            /* Number of bytes of URI args at *zUri */\n\n  /* Figure out how much space is required for each journal file-handle\n  ** (there are two of them, the main journal and the sub-journal).  */\n  journalFileSize = ROUND8(sqlite3JournalSize(pVfs));\n\n  /* Set the output variable to NULL in case an error occurs. */\n  *ppPager = 0;\n\n#ifndef SQLITE_OMIT_MEMORYDB\n  if( flags & PAGER_MEMORY ){\n    memDb = 1;\n    if( zFilename && zFilename[0] ){\n      zPathname = sqlite3DbStrDup(0, zFilename);\n      if( zPathname==0  ) return SQLITE_NOMEM_BKPT;\n      nPathname = sqlite3Strlen30(zPathname);\n      zFilename = 0;\n    }\n  }\n#endif\n\n  /* Compute and store the full pathname in an allocated buffer pointed\n  ** to by zPathname, length nPathname. Or, if this is a temporary file,\n  ** leave both nPathname and zPathname set to 0.\n  */\n  if( zFilename && zFilename[0] ){\n    const char *z;\n    nPathname = pVfs->mxPathname+1;\n    zPathname = sqlite3DbMallocRaw(0, nPathname*2);\n    if( zPathname==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */\n    rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);\n    nPathname = sqlite3Strlen30(zPathname);\n    z = zUri = &zFilename[sqlite3Strlen30(zFilename)+1];\n    while( *z ){\n      z += sqlite3Strlen30(z)+1;\n      z += sqlite3Strlen30(z)+1;\n    }\n    nUri = (int)(&z[1] - zUri);\n    assert( nUri>=0 );\n    if( rc==SQLITE_OK && nPathname+8>pVfs->mxPathname ){\n      /* This branch is taken when the journal path required by\n      ** the database being opened will be more than pVfs->mxPathname\n      ** bytes in length. This means the database cannot be opened,\n      ** as it will not be possible to open the journal file or even\n      ** check for a hot-journal before reading.\n      */\n      rc = SQLITE_CANTOPEN_BKPT;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(0, zPathname);\n      return rc;\n    }\n  }\n\n  /* Allocate memory for the Pager structure, PCache object, the\n  ** three file descriptors, the database file name and the journal \n  ** file name. The layout in memory is as follows:\n  **\n  **     Pager object                    (sizeof(Pager) bytes)\n  **     PCache object                   (sqlite3PcacheSize() bytes)\n  **     Database file handle            (pVfs->szOsFile bytes)\n  **     Sub-journal file handle         (journalFileSize bytes)\n  **     Main journal file handle        (journalFileSize bytes)\n  **     Database file name              (nPathname+1 bytes)\n  **     Journal file name               (nPathname+8+1 bytes)\n  */\n  pPtr = (u8 *)sqlite3MallocZero(\n    ROUND8(sizeof(*pPager)) +      /* Pager structure */\n    ROUND8(pcacheSize) +           /* PCache object */\n    ROUND8(pVfs->szOsFile) +       /* The main db file */\n    journalFileSize * 2 +          /* The two journal files */ \n    nPathname + 1 + nUri +         /* zFilename */\n    nPathname + 8 + 2              /* zJournal */\n#ifndef SQLITE_OMIT_WAL\n    + nPathname + 4 + 2            /* zWal */\n#endif\n  );\n  assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );\n  if( !pPtr ){\n    sqlite3DbFree(0, zPathname);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pPager =              (Pager*)(pPtr);\n  pPager->pPCache =    (PCache*)(pPtr += ROUND8(sizeof(*pPager)));\n  pPager->fd =   (sqlite3_file*)(pPtr += ROUND8(pcacheSize));\n  pPager->sjfd = (sqlite3_file*)(pPtr += ROUND8(pVfs->szOsFile));\n  pPager->jfd =  (sqlite3_file*)(pPtr += journalFileSize);\n  pPager->zFilename =    (char*)(pPtr += journalFileSize);\n  assert( EIGHT_BYTE_ALIGNMENT(pPager->jfd) );\n\n  /* Fill in the Pager.zFilename and Pager.zJournal buffers, if required. */\n  if( zPathname ){\n    assert( nPathname>0 );\n    pPager->zJournal =   (char*)(pPtr += nPathname + 1 + nUri);\n    memcpy(pPager->zFilename, zPathname, nPathname);\n    if( nUri ) memcpy(&pPager->zFilename[nPathname+1], zUri, nUri);\n    memcpy(pPager->zJournal, zPathname, nPathname);\n    memcpy(&pPager->zJournal[nPathname], \"-journal\\000\", 8+2);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zJournal);\n#ifndef SQLITE_OMIT_WAL\n    pPager->zWal = &pPager->zJournal[nPathname+8+1];\n    memcpy(pPager->zWal, zPathname, nPathname);\n    memcpy(&pPager->zWal[nPathname], \"-wal\\000\", 4+1);\n    sqlite3FileSuffix3(pPager->zFilename, pPager->zWal);\n#endif\n    sqlite3DbFree(0, zPathname);\n  }\n  pPager->pVfs = pVfs;\n  pPager->vfsFlags = vfsFlags;\n\n  /* Open the pager file.\n  */\n  if( zFilename && zFilename[0] ){\n    int fout = 0;                    /* VFS flags returned by xOpen() */\n    rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout);\n    assert( !memDb );\n    readOnly = (fout&SQLITE_OPEN_READONLY);\n\n    /* If the file was successfully opened for read/write access,\n    ** choose a default page size in case we have to create the\n    ** database file. The default page size is the maximum of:\n    **\n    **    + SQLITE_DEFAULT_PAGE_SIZE,\n    **    + The value returned by sqlite3OsSectorSize()\n    **    + The largest page size that can be written atomically.\n    */\n    if( rc==SQLITE_OK ){\n      int iDc = sqlite3OsDeviceCharacteristics(pPager->fd);\n      if( !readOnly ){\n        setSectorSize(pPager);\n        assert(SQLITE_DEFAULT_PAGE_SIZE<=SQLITE_MAX_DEFAULT_PAGE_SIZE);\n        if( szPageDflt<pPager->sectorSize ){\n          if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){\n            szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE;\n          }else{\n            szPageDflt = (u32)pPager->sectorSize;\n          }\n        }\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n        {\n          int ii;\n          assert(SQLITE_IOCAP_ATOMIC512==(512>>8));\n          assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8));\n          assert(SQLITE_MAX_DEFAULT_PAGE_SIZE<=65536);\n          for(ii=szPageDflt; ii<=SQLITE_MAX_DEFAULT_PAGE_SIZE; ii=ii*2){\n            if( iDc&(SQLITE_IOCAP_ATOMIC|(ii>>8)) ){\n              szPageDflt = ii;\n            }\n          }\n        }\n#endif\n      }\n      pPager->noLock = sqlite3_uri_boolean(zFilename, \"nolock\", 0);\n      if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0\n       || sqlite3_uri_boolean(zFilename, \"immutable\", 0) ){\n          vfsFlags |= SQLITE_OPEN_READONLY;\n          goto act_like_temp_file;\n      }\n    }\n  }else{\n    /* If a temporary file is requested, it is not opened immediately.\n    ** In this case we accept the default page size and delay actually\n    ** opening the file until the first call to OsWrite().\n    **\n    ** This branch is also run for an in-memory database. An in-memory\n    ** database is the same as a temp-file that is never written out to\n    ** disk and uses an in-memory rollback journal.\n    **\n    ** This branch also runs for files marked as immutable.\n    */ \nact_like_temp_file:\n    tempFile = 1;\n    pPager->eState = PAGER_READER;     /* Pretend we already have a lock */\n    pPager->eLock = EXCLUSIVE_LOCK;    /* Pretend we are in EXCLUSIVE mode */\n    pPager->noLock = 1;                /* Do no locking */\n    readOnly = (vfsFlags&SQLITE_OPEN_READONLY);\n  }\n\n  /* The following call to PagerSetPagesize() serves to set the value of \n  ** Pager.pageSize and to allocate the Pager.pTmpSpace buffer.\n  */\n  if( rc==SQLITE_OK ){\n    assert( pPager->memDb==0 );\n    rc = sqlite3PagerSetPagesize(pPager, &szPageDflt, -1);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  /* Initialize the PCache object. */\n  if( rc==SQLITE_OK ){\n    nExtra = ROUND8(nExtra);\n    assert( nExtra>=8 && nExtra<1000 );\n    rc = sqlite3PcacheOpen(szPageDflt, nExtra, !memDb,\n                       !memDb?pagerStress:0, (void *)pPager, pPager->pPCache);\n  }\n\n  /* If an error occurred above, free the  Pager structure and close the file.\n  */\n  if( rc!=SQLITE_OK ){\n    sqlite3OsClose(pPager->fd);\n    sqlite3PageFree(pPager->pTmpSpace);\n    sqlite3_free(pPager);\n    return rc;\n  }\n\n  PAGERTRACE((\"OPEN %d %s\\n\", FILEHANDLEID(pPager->fd), pPager->zFilename));\n  IOTRACE((\"OPEN %p %s\\n\", pPager, pPager->zFilename))\n\n  pPager->useJournal = (u8)useJournal;\n  /* pPager->stmtOpen = 0; */\n  /* pPager->stmtInUse = 0; */\n  /* pPager->nRef = 0; */\n  /* pPager->stmtSize = 0; */\n  /* pPager->stmtJSize = 0; */\n  /* pPager->nPage = 0; */\n  pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;\n  /* pPager->state = PAGER_UNLOCK; */\n  /* pPager->errMask = 0; */\n  pPager->tempFile = (u8)tempFile;\n  assert( tempFile==PAGER_LOCKINGMODE_NORMAL \n          || tempFile==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_EXCLUSIVE==1 );\n  pPager->exclusiveMode = (u8)tempFile; \n  pPager->changeCountDone = pPager->tempFile;\n  pPager->memDb = (u8)memDb;\n  pPager->readOnly = (u8)readOnly;\n  assert( useJournal || pPager->tempFile );\n  pPager->noSync = pPager->tempFile;\n  if( pPager->noSync ){\n    assert( pPager->fullSync==0 );\n    assert( pPager->extraSync==0 );\n    assert( pPager->syncFlags==0 );\n    assert( pPager->walSyncFlags==0 );\n  }else{\n    pPager->fullSync = 1;\n    pPager->extraSync = 0;\n    pPager->syncFlags = SQLITE_SYNC_NORMAL;\n    pPager->walSyncFlags = SQLITE_SYNC_NORMAL | (SQLITE_SYNC_NORMAL<<2);\n  }\n  /* pPager->pFirst = 0; */\n  /* pPager->pFirstSynced = 0; */\n  /* pPager->pLast = 0; */\n  pPager->nExtra = (u16)nExtra;\n  pPager->journalSizeLimit = SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT;\n  assert( isOpen(pPager->fd) || tempFile );\n  setSectorSize(pPager);\n  if( !useJournal ){\n    pPager->journalMode = PAGER_JOURNALMODE_OFF;\n  }else if( memDb ){\n    pPager->journalMode = PAGER_JOURNALMODE_MEMORY;\n  }\n  /* pPager->xBusyHandler = 0; */\n  /* pPager->pBusyHandlerArg = 0; */\n  pPager->xReiniter = xReinit;\n  setGetterMethod(pPager);\n  /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */\n  /* pPager->szMmap = SQLITE_DEFAULT_MMAP_SIZE // will be set by btree.c */\n\n  *ppPager = pPager;\n  return SQLITE_OK;\n}\n\n\n/* Verify that the database file has not be deleted or renamed out from\n** under the pager.  Return SQLITE_OK if the database is still were it ought\n** to be on disk.  Return non-zero (SQLITE_READONLY_DBMOVED or some other error\n** code from sqlite3OsAccess()) if the database has gone missing.\n*/\nstatic int databaseIsUnmoved(Pager *pPager){\n  int bHasMoved = 0;\n  int rc;\n\n  if( pPager->tempFile ) return SQLITE_OK;\n  if( pPager->dbSize==0 ) return SQLITE_OK;\n  assert( pPager->zFilename && pPager->zFilename[0] );\n  rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_HAS_MOVED, &bHasMoved);\n  if( rc==SQLITE_NOTFOUND ){\n    /* If the HAS_MOVED file-control is unimplemented, assume that the file\n    ** has not been moved.  That is the historical behavior of SQLite: prior to\n    ** version 3.8.3, it never checked */\n    rc = SQLITE_OK;\n  }else if( rc==SQLITE_OK && bHasMoved ){\n    rc = SQLITE_READONLY_DBMOVED;\n  }\n  return rc;\n}\n\n\n/*\n** This function is called after transitioning from PAGER_UNLOCK to\n** PAGER_SHARED state. It tests if there is a hot journal present in\n** the file-system for the given pager. A hot journal is one that \n** needs to be played back. According to this function, a hot-journal\n** file exists if the following criteria are met:\n**\n**   * The journal file exists in the file system, and\n**   * No process holds a RESERVED or greater lock on the database file, and\n**   * The database file itself is greater than 0 bytes in size, and\n**   * The first byte of the journal file exists and is not 0x00.\n**\n** If the current size of the database file is 0 but a journal file\n** exists, that is probably an old journal left over from a prior\n** database with the same name. In this case the journal file is\n** just deleted using OsDelete, *pExists is set to 0 and SQLITE_OK\n** is returned.\n**\n** This routine does not check if there is a master journal filename\n** at the end of the file. If there is, and that master journal file\n** does not exist, then the journal file is not really hot. In this\n** case this routine will return a false-positive. The pager_playback()\n** routine will discover that the journal file is not really hot and \n** will not roll it back. \n**\n** If a hot-journal file is found to exist, *pExists is set to 1 and \n** SQLITE_OK returned. If no hot-journal file is present, *pExists is\n** set to 0 and SQLITE_OK returned. If an IO error occurs while trying\n** to determine whether or not a hot-journal file exists, the IO error\n** code is returned and the value of *pExists is undefined.\n*/\nstatic int hasHotJournal(Pager *pPager, int *pExists){\n  sqlite3_vfs * const pVfs = pPager->pVfs;\n  int rc = SQLITE_OK;           /* Return code */\n  int exists = 1;               /* True if a journal file is present */\n  int jrnlOpen = !!isOpen(pPager->jfd);\n\n  assert( pPager->useJournal );\n  assert( isOpen(pPager->fd) );\n  assert( pPager->eState==PAGER_OPEN );\n\n  assert( jrnlOpen==0 || ( sqlite3OsDeviceCharacteristics(pPager->jfd) &\n    SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n  ));\n\n  *pExists = 0;\n  if( !jrnlOpen ){\n    rc = sqlite3OsAccess(pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &exists);\n  }\n  if( rc==SQLITE_OK && exists ){\n    int locked = 0;             /* True if some process holds a RESERVED lock */\n\n    /* Race condition here:  Another process might have been holding the\n    ** the RESERVED lock and have a journal open at the sqlite3OsAccess() \n    ** call above, but then delete the journal and drop the lock before\n    ** we get to the following sqlite3OsCheckReservedLock() call.  If that\n    ** is the case, this routine might think there is a hot journal when\n    ** in fact there is none.  This results in a false-positive which will\n    ** be dealt with by the playback routine.  Ticket #3883.\n    */\n    rc = sqlite3OsCheckReservedLock(pPager->fd, &locked);\n    if( rc==SQLITE_OK && !locked ){\n      Pgno nPage;                 /* Number of pages in database file */\n\n      assert( pPager->tempFile==0 );\n      rc = pagerPagecount(pPager, &nPage);\n      if( rc==SQLITE_OK ){\n        /* If the database is zero pages in size, that means that either (1) the\n        ** journal is a remnant from a prior database with the same name where\n        ** the database file but not the journal was deleted, or (2) the initial\n        ** transaction that populates a new database is being rolled back.\n        ** In either case, the journal file can be deleted.  However, take care\n        ** not to delete the journal file if it is already open due to\n        ** journal_mode=PERSIST.\n        */\n        if( nPage==0 && !jrnlOpen ){\n          sqlite3BeginBenignMalloc();\n          if( pagerLockDb(pPager, RESERVED_LOCK)==SQLITE_OK ){\n            sqlite3OsDelete(pVfs, pPager->zJournal, 0);\n            if( !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n          }\n          sqlite3EndBenignMalloc();\n        }else{\n          /* The journal file exists and no other connection has a reserved\n          ** or greater lock on the database file. Now check that there is\n          ** at least one non-zero bytes at the start of the journal file.\n          ** If there is, then we consider this journal to be hot. If not, \n          ** it can be ignored.\n          */\n          if( !jrnlOpen ){\n            int f = SQLITE_OPEN_READONLY|SQLITE_OPEN_MAIN_JOURNAL;\n            rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &f);\n          }\n          if( rc==SQLITE_OK ){\n            u8 first = 0;\n            rc = sqlite3OsRead(pPager->jfd, (void *)&first, 1, 0);\n            if( rc==SQLITE_IOERR_SHORT_READ ){\n              rc = SQLITE_OK;\n            }\n            if( !jrnlOpen ){\n              sqlite3OsClose(pPager->jfd);\n            }\n            *pExists = (first!=0);\n          }else if( rc==SQLITE_CANTOPEN ){\n            /* If we cannot open the rollback journal file in order to see if\n            ** it has a zero header, that might be due to an I/O error, or\n            ** it might be due to the race condition described above and in\n            ** ticket #3883.  Either way, assume that the journal is hot.\n            ** This might be a false positive.  But if it is, then the\n            ** automatic journal playback and recovery mechanism will deal\n            ** with it under an EXCLUSIVE lock where we do not need to\n            ** worry so much with race conditions.\n            */\n            *pExists = 1;\n            rc = SQLITE_OK;\n          }\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to obtain a shared lock on the database file.\n** It is illegal to call sqlite3PagerGet() until after this function\n** has been successfully called. If a shared-lock is already held when\n** this function is called, it is a no-op.\n**\n** The following operations are also performed by this function.\n**\n**   1) If the pager is currently in PAGER_OPEN state (no lock held\n**      on the database file), then an attempt is made to obtain a\n**      SHARED lock on the database file. Immediately after obtaining\n**      the SHARED lock, the file-system is checked for a hot-journal,\n**      which is played back if present. Following any hot-journal \n**      rollback, the contents of the cache are validated by checking\n**      the 'change-counter' field of the database file header and\n**      discarded if they are found to be invalid.\n**\n**   2) If the pager is running in exclusive-mode, and there are currently\n**      no outstanding references to any pages, and is in the error state,\n**      then an attempt is made to clear the error state by discarding\n**      the contents of the page cache and rolling back any open journal\n**      file.\n**\n** If everything is successful, SQLITE_OK is returned. If an IO error \n** occurs while locking the database, checking for a hot-journal file or \n** rolling back a journal file, the IO error code is returned.\n*/\nint sqlite3PagerSharedLock(Pager *pPager){\n  int rc = SQLITE_OK;                /* Return code */\n\n  /* This routine is only called from b-tree and only when there are no\n  ** outstanding pages. This implies that the pager state should either\n  ** be OPEN or READER. READER is only possible if the pager is or was in \n  ** exclusive access mode.  */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)==0 );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN || pPager->eState==PAGER_READER );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( !pagerUseWal(pPager) && pPager->eState==PAGER_OPEN ){\n    int bHotJournal = 1;          /* True if there exists a hot journal-file */\n\n    assert( !MEMDB );\n    assert( pPager->tempFile==0 || pPager->eLock==EXCLUSIVE_LOCK );\n\n    rc = pager_wait_on_lock(pPager, SHARED_LOCK);\n    if( rc!=SQLITE_OK ){\n      assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK );\n      goto failed;\n    }\n\n    /* If a journal file exists, and there is no RESERVED lock on the\n    ** database file, then it either needs to be played back or deleted.\n    */\n    if( pPager->eLock<=SHARED_LOCK ){\n      rc = hasHotJournal(pPager, &bHotJournal);\n    }\n    if( rc!=SQLITE_OK ){\n      goto failed;\n    }\n    if( bHotJournal ){\n      if( pPager->readOnly ){\n        rc = SQLITE_READONLY_ROLLBACK;\n        goto failed;\n      }\n\n      /* Get an EXCLUSIVE lock on the database file. At this point it is\n      ** important that a RESERVED lock is not obtained on the way to the\n      ** EXCLUSIVE lock. If it were, another process might open the\n      ** database file, detect the RESERVED lock, and conclude that the\n      ** database is safe to read while this process is still rolling the \n      ** hot-journal back.\n      ** \n      ** Because the intermediate RESERVED lock is not requested, any\n      ** other process attempting to access the database file will get to \n      ** this point in the code and fail to obtain its own EXCLUSIVE lock \n      ** on the database file.\n      **\n      ** Unless the pager is in locking_mode=exclusive mode, the lock is\n      ** downgraded to SHARED_LOCK before this function returns.\n      */\n      rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n      if( rc!=SQLITE_OK ){\n        goto failed;\n      }\n \n      /* If it is not already open and the file exists on disk, open the \n      ** journal for read/write access. Write access is required because \n      ** in exclusive-access mode the file descriptor will be kept open \n      ** and possibly used for a transaction later on. Also, write-access \n      ** is usually required to finalize the journal in journal_mode=persist \n      ** mode (and also for journal_mode=truncate on some systems).\n      **\n      ** If the journal does not exist, it usually means that some \n      ** other connection managed to get in and roll it back before \n      ** this connection obtained the exclusive lock above. Or, it \n      ** may mean that the pager was in the error-state when this\n      ** function was called and the journal file does not exist.\n      */\n      if( !isOpen(pPager->jfd) ){\n        sqlite3_vfs * const pVfs = pPager->pVfs;\n        int bExists;              /* True if journal file exists */\n        rc = sqlite3OsAccess(\n            pVfs, pPager->zJournal, SQLITE_ACCESS_EXISTS, &bExists);\n        if( rc==SQLITE_OK && bExists ){\n          int fout = 0;\n          int f = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_JOURNAL;\n          assert( !pPager->tempFile );\n          rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, f, &fout);\n          assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n          if( rc==SQLITE_OK && fout&SQLITE_OPEN_READONLY ){\n            rc = SQLITE_CANTOPEN_BKPT;\n            sqlite3OsClose(pPager->jfd);\n          }\n        }\n      }\n \n      /* Playback and delete the journal.  Drop the database write\n      ** lock and reacquire the read lock. Purge the cache before\n      ** playing back the hot-journal so that we don't end up with\n      ** an inconsistent cache.  Sync the hot journal before playing\n      ** it back since the process that crashed and left the hot journal\n      ** probably did not sync it and we are required to always sync\n      ** the journal before playing it back.\n      */\n      if( isOpen(pPager->jfd) ){\n        assert( rc==SQLITE_OK );\n        rc = pagerSyncHotJournal(pPager);\n        if( rc==SQLITE_OK ){\n          rc = pager_playback(pPager, !pPager->tempFile);\n          pPager->eState = PAGER_OPEN;\n        }\n      }else if( !pPager->exclusiveMode ){\n        pagerUnlockDb(pPager, SHARED_LOCK);\n      }\n\n      if( rc!=SQLITE_OK ){\n        /* This branch is taken if an error occurs while trying to open\n        ** or roll back a hot-journal while holding an EXCLUSIVE lock. The\n        ** pager_unlock() routine will be called before returning to unlock\n        ** the file. If the unlock attempt fails, then Pager.eLock must be\n        ** set to UNKNOWN_LOCK (see the comment above the #define for \n        ** UNKNOWN_LOCK above for an explanation). \n        **\n        ** In order to get pager_unlock() to do this, set Pager.eState to\n        ** PAGER_ERROR now. This is not actually counted as a transition\n        ** to ERROR state in the state diagram at the top of this file,\n        ** since we know that the same call to pager_unlock() will very\n        ** shortly transition the pager object to the OPEN state. Calling\n        ** assert_pager_state() would fail now, as it should not be possible\n        ** to be in ERROR state when there are zero outstanding page \n        ** references.\n        */\n        pager_error(pPager, rc);\n        goto failed;\n      }\n\n      assert( pPager->eState==PAGER_OPEN );\n      assert( (pPager->eLock==SHARED_LOCK)\n           || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK)\n      );\n    }\n\n    if( !pPager->tempFile && pPager->hasHeldSharedLock ){\n      /* The shared-lock has just been acquired then check to\n      ** see if the database has been modified.  If the database has changed,\n      ** flush the cache.  The hasHeldSharedLock flag prevents this from\n      ** occurring on the very first access to a file, in order to save a\n      ** single unnecessary sqlite3OsRead() call at the start-up.\n      **\n      ** Database changes are detected by looking at 15 bytes beginning\n      ** at offset 24 into the file.  The first 4 of these 16 bytes are\n      ** a 32-bit counter that is incremented with each change.  The\n      ** other bytes change randomly with each file change when\n      ** a codec is in use.\n      ** \n      ** There is a vanishingly small chance that a change will not be \n      ** detected.  The chance of an undetected change is so small that\n      ** it can be neglected.\n      */\n      char dbFileVers[sizeof(pPager->dbFileVers)];\n\n      IOTRACE((\"CKVERS %p %d\\n\", pPager, sizeof(dbFileVers)));\n      rc = sqlite3OsRead(pPager->fd, &dbFileVers, sizeof(dbFileVers), 24);\n      if( rc!=SQLITE_OK ){\n        if( rc!=SQLITE_IOERR_SHORT_READ ){\n          goto failed;\n        }\n        memset(dbFileVers, 0, sizeof(dbFileVers));\n      }\n\n      if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){\n        pager_reset(pPager);\n\n        /* Unmap the database file. It is possible that external processes\n        ** may have truncated the database file and then extended it back\n        ** to its original size while this process was not holding a lock.\n        ** In this case there may exist a Pager.pMap mapping that appears\n        ** to be the right size but is not actually valid. Avoid this\n        ** possibility by unmapping the db here. */\n        if( USEFETCH(pPager) ){\n          sqlite3OsUnfetch(pPager->fd, 0, 0);\n        }\n      }\n    }\n\n    /* If there is a WAL file in the file-system, open this database in WAL\n    ** mode. Otherwise, the following function call is a no-op.\n    */\n    rc = pagerOpenWalIfPresent(pPager);\n#ifndef SQLITE_OMIT_WAL\n    assert( pPager->pWal==0 || rc==SQLITE_OK );\n#endif\n  }\n\n  if( pagerUseWal(pPager) ){\n    assert( rc==SQLITE_OK );\n    rc = pagerBeginReadTransaction(pPager);\n  }\n\n  if( pPager->tempFile==0 && pPager->eState==PAGER_OPEN && rc==SQLITE_OK ){\n    rc = pagerPagecount(pPager, &pPager->dbSize);\n  }\n\n failed:\n  if( rc!=SQLITE_OK ){\n    assert( !MEMDB );\n    pager_unlock(pPager);\n    assert( pPager->eState==PAGER_OPEN );\n  }else{\n    pPager->eState = PAGER_READER;\n    pPager->hasHeldSharedLock = 1;\n  }\n  return rc;\n}\n\n/*\n** If the reference count has reached zero, rollback any active\n** transaction and unlock the pager.\n**\n** Except, in locking_mode=EXCLUSIVE when there is nothing to in\n** the rollback journal, the unlock is not performed and there is\n** nothing to rollback, so this routine is a no-op.\n*/ \nstatic void pagerUnlockIfUnused(Pager *pPager){\n  if( sqlite3PcacheRefCount(pPager->pPCache)==0 ){\n    assert( pPager->nMmapOut==0 ); /* because page1 is never memory mapped */\n    pagerUnlockAndRollback(pPager);\n  }\n}\n\n/*\n** The page getter methods each try to acquire a reference to a\n** page with page number pgno. If the requested reference is \n** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.\n**\n** There are different implementations of the getter method depending\n** on the current state of the pager.\n**\n**     getPageNormal()         --  The normal getter\n**     getPageError()          --  Used if the pager is in an error state\n**     getPageMmap()           --  Used if memory-mapped I/O is enabled\n**\n** If the requested page is already in the cache, it is returned. \n** Otherwise, a new page object is allocated and populated with data\n** read from the database file. In some cases, the pcache module may\n** choose not to allocate a new page object and may reuse an existing\n** object with no outstanding references.\n**\n** The extra data appended to a page is always initialized to zeros the \n** first time a page is loaded into memory. If the page requested is \n** already in the cache when this function is called, then the extra\n** data is left as it was when the page object was last used.\n**\n** If the database image is smaller than the requested page or if \n** the flags parameter contains the PAGER_GET_NOCONTENT bit and the \n** requested page is not already stored in the cache, then no \n** actual disk read occurs. In this case the memory image of the \n** page is initialized to all zeros. \n**\n** If PAGER_GET_NOCONTENT is true, it means that we do not care about\n** the contents of the page. This occurs in two scenarios:\n**\n**   a) When reading a free-list leaf page from the database, and\n**\n**   b) When a savepoint is being rolled back and we need to load\n**      a new page into the cache to be filled with the data read\n**      from the savepoint journal.\n**\n** If PAGER_GET_NOCONTENT is true, then the data returned is zeroed instead\n** of being read from the database. Additionally, the bits corresponding\n** to pgno in Pager.pInJournal (bitvec of pages already written to the\n** journal file) and the PagerSavepoint.pInSavepoint bitvecs of any open\n** savepoints are set. This means if the page is made writable at any\n** point in the future, using a call to sqlite3PagerWrite(), its contents\n** will not be journaled. This saves IO.\n**\n** The acquisition might fail for several reasons.  In all cases,\n** an appropriate error code is returned and *ppPage is set to NULL.\n**\n** See also sqlite3PagerLookup().  Both this routine and Lookup() attempt\n** to find a page in the in-memory cache first.  If the page is not already\n** in memory, this routine goes to disk to read it in whereas Lookup()\n** just returns 0.  This routine acquires a read-lock the first time it\n** has to go to disk, and could also playback an old journal if necessary.\n** Since Lookup() never goes to disk, it never has to deal with locks\n** or journal files.\n*/\nstatic int getPageNormal(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg;\n  u8 noContent;                   /* True if PAGER_GET_NOCONTENT is set */\n  sqlite3_pcache_page *pBase;\n\n  assert( pPager->errCode==SQLITE_OK );\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n\n  if( pgno==0 ) return SQLITE_CORRUPT_BKPT;\n  pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);\n  if( pBase==0 ){\n    pPg = 0;\n    rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);\n    if( rc!=SQLITE_OK ) goto pager_acquire_err;\n    if( pBase==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto pager_acquire_err;\n    }\n  }\n  pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);\n  assert( pPg==(*ppPage) );\n  assert( pPg->pgno==pgno );\n  assert( pPg->pPager==pPager || pPg->pPager==0 );\n\n  noContent = (flags & PAGER_GET_NOCONTENT)!=0;\n  if( pPg->pPager && !noContent ){\n    /* In this case the pcache already contains an initialized copy of\n    ** the page. Return without further ado.  */\n    assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );\n    pPager->aStat[PAGER_STAT_HIT]++;\n    return SQLITE_OK;\n\n  }else{\n    /* The pager cache has created a new page. Its content needs to \n    ** be initialized. But first some error checks:\n    **\n    ** (1) The maximum page number is 2^31\n    ** (2) Never try to fetch the locking page\n    */\n    if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){\n      rc = SQLITE_CORRUPT_BKPT;\n      goto pager_acquire_err;\n    }\n\n    pPg->pPager = pPager;\n\n    assert( !isOpen(pPager->fd) || !MEMDB );\n    if( !isOpen(pPager->fd) || pPager->dbSize<pgno || noContent ){\n      if( pgno>pPager->mxPgno ){\n        rc = SQLITE_FULL;\n        goto pager_acquire_err;\n      }\n      if( noContent ){\n        /* Failure to set the bits in the InJournal bit-vectors is benign.\n        ** It merely means that we might do some extra work to journal a \n        ** page that does not need to be journaled.  Nevertheless, be sure \n        ** to test the case where a malloc error occurs while trying to set \n        ** a bit in a bit vector.\n        */\n        sqlite3BeginBenignMalloc();\n        if( pgno<=pPager->dbOrigSize ){\n          TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);\n          testcase( rc==SQLITE_NOMEM );\n        }\n        TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);\n        testcase( rc==SQLITE_NOMEM );\n        sqlite3EndBenignMalloc();\n      }\n      memset(pPg->pData, 0, pPager->pageSize);\n      IOTRACE((\"ZERO %p %d\\n\", pPager, pgno));\n    }else{\n      assert( pPg->pPager==pPager );\n      pPager->aStat[PAGER_STAT_MISS]++;\n      rc = readDbPage(pPg);\n      if( rc!=SQLITE_OK ){\n        goto pager_acquire_err;\n      }\n    }\n    pager_set_pagehash(pPg);\n  }\n  return SQLITE_OK;\n\npager_acquire_err:\n  assert( rc!=SQLITE_OK );\n  if( pPg ){\n    sqlite3PcacheDrop(pPg);\n  }\n  pagerUnlockIfUnused(pPager);\n  *ppPage = 0;\n  return rc;\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/* The page getter for when memory-mapped I/O is enabled */\nstatic int getPageMMap(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  int rc = SQLITE_OK;\n  PgHdr *pPg = 0;\n  u32 iFrame = 0;                 /* Frame to read from WAL file */\n\n  /* It is acceptable to use a read-only (mmap) page for any page except\n  ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY\n  ** flag was specified by the caller. And so long as the db is not a \n  ** temporary or in-memory database.  */\n  const int bMmapOk = (pgno>1\n   && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))\n  );\n\n  assert( USEFETCH(pPager) );\n#ifdef SQLITE_HAS_CODEC\n  assert( pPager->xCodec==0 );\n#endif\n\n  /* Optimization note:  Adding the \"pgno<=1\" term before \"pgno==0\" here\n  ** allows the compiler optimizer to reuse the results of the \"pgno>1\"\n  ** test in the previous statement, and avoid testing pgno==0 in the\n  ** common case where pgno is large. */\n  if( pgno<=1 && pgno==0 ){\n    return SQLITE_CORRUPT_BKPT;\n  }\n  assert( pPager->eState>=PAGER_READER );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->hasHeldSharedLock==1 );\n  assert( pPager->errCode==SQLITE_OK );\n\n  if( bMmapOk && pagerUseWal(pPager) ){\n    rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  if( bMmapOk && iFrame==0 ){\n    void *pData = 0;\n    rc = sqlite3OsFetch(pPager->fd, \n        (i64)(pgno-1) * pPager->pageSize, pPager->pageSize, &pData\n    );\n    if( rc==SQLITE_OK && pData ){\n      if( pPager->eState>PAGER_READER || pPager->tempFile ){\n        pPg = sqlite3PagerLookup(pPager, pgno);\n      }\n      if( pPg==0 ){\n        rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);\n     }else{\n        sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1)*pPager->pageSize, pData);\n      }\n      if( pPg ){\n        assert( rc==SQLITE_OK );\n        *ppPage = pPg;\n        return SQLITE_OK;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      *ppPage = 0;\n      return rc;\n    }\n  }\n  return getPageNormal(pPager, pgno, ppPage, flags);\n}\n#endif /* SQLITE_MAX_MMAP_SIZE>0 */\n\n/* The page getter method for when the pager is an error state */\nstatic int getPageError(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  UNUSED_PARAMETER(pgno);\n  UNUSED_PARAMETER(flags);\n  assert( pPager->errCode!=SQLITE_OK );\n  *ppPage = 0;\n  return pPager->errCode;\n}\n\n\n/* Dispatch all page fetch requests to the appropriate getter method.\n*/\nint sqlite3PagerGet(\n  Pager *pPager,      /* The pager open on the database file */\n  Pgno pgno,          /* Page number to fetch */\n  DbPage **ppPage,    /* Write a pointer to the page here */\n  int flags           /* PAGER_GET_XXX flags */\n){\n  return pPager->xGet(pPager, pgno, ppPage, flags);\n}\n\n/*\n** Acquire a page if it is already in the in-memory cache.  Do\n** not read the page from disk.  Return a pointer to the page,\n** or 0 if the page is not in cache. \n**\n** See also sqlite3PagerGet().  The difference between this routine\n** and sqlite3PagerGet() is that _get() will go to the disk and read\n** in the page if the page is not already in cache.  This routine\n** returns NULL if the page is not in cache or if a disk I/O error \n** has ever happened.\n*/\nDbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){\n  sqlite3_pcache_page *pPage;\n  assert( pPager!=0 );\n  assert( pgno!=0 );\n  assert( pPager->pPCache!=0 );\n  pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0);\n  assert( pPage==0 || pPager->hasHeldSharedLock );\n  if( pPage==0 ) return 0;\n  return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage);\n}\n\n/*\n** Release a page reference.\n**\n** The sqlite3PagerUnref() and sqlite3PagerUnrefNotNull() may only be\n** used if we know that the page being released is not the last page.\n** The btree layer always holds page1 open until the end, so these first\n** to routines can be used to release any page other than BtShared.pPage1.\n**\n** Use sqlite3PagerUnrefPageOne() to release page1.  This latter routine\n** checks the total number of outstanding pages and if the number of\n** pages reaches zero it drops the database lock.\n*/\nvoid sqlite3PagerUnrefNotNull(DbPage *pPg){\n  TESTONLY( Pager *pPager = pPg->pPager; )\n  assert( pPg!=0 );\n  if( pPg->flags & PGHDR_MMAP ){\n    assert( pPg->pgno!=1 );  /* Page1 is never memory mapped */\n    pagerReleaseMapPage(pPg);\n  }else{\n    sqlite3PcacheRelease(pPg);\n  }\n  /* Do not use this routine to release the last reference to page1 */\n  assert( sqlite3PcacheRefCount(pPager->pPCache)>0 );\n}\nvoid sqlite3PagerUnref(DbPage *pPg){\n  if( pPg ) sqlite3PagerUnrefNotNull(pPg);\n}\nvoid sqlite3PagerUnrefPageOne(DbPage *pPg){\n  Pager *pPager;\n  assert( pPg!=0 );\n  assert( pPg->pgno==1 );\n  assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */\n  pPager = pPg->pPager;\n  sqlite3PcacheRelease(pPg);\n  pagerUnlockIfUnused(pPager);\n}\n\n/*\n** This function is called at the start of every write transaction.\n** There must already be a RESERVED or EXCLUSIVE lock on the database \n** file when this routine is called.\n**\n** Open the journal file for pager pPager and write a journal header\n** to the start of it. If there are active savepoints, open the sub-journal\n** as well. This function is only used when the journal file is being \n** opened to write a rollback log for a transaction. It is not used \n** when opening a hot journal file to roll it back.\n**\n** If the journal file is already open (as it may be in exclusive mode),\n** then this function just writes a journal header to the start of the\n** already open file. \n**\n** Whether or not the journal file is opened by this function, the\n** Pager.pInJournal bitvec structure is allocated.\n**\n** Return SQLITE_OK if everything is successful. Otherwise, return \n** SQLITE_NOMEM if the attempt to allocate Pager.pInJournal fails, or \n** an IO error code if opening or writing the journal file fails.\n*/\nstatic int pager_open_journal(Pager *pPager){\n  int rc = SQLITE_OK;                        /* Return code */\n  sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->pInJournal==0 );\n  \n  /* If already in the error state, this function is a no-op.  But on\n  ** the other hand, this routine is never called if we are already in\n  ** an error state. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){\n    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);\n    if( pPager->pInJournal==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n  \n    /* Open the journal file if it is not already open. */\n    if( !isOpen(pPager->jfd) ){\n      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){\n        sqlite3MemJournalOpen(pPager->jfd);\n      }else{\n        int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;\n        int nSpill;\n\n        if( pPager->tempFile ){\n          flags |= (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL);\n          nSpill = sqlite3Config.nStmtSpill;\n        }else{\n          flags |= SQLITE_OPEN_MAIN_JOURNAL;\n          nSpill = jrnlBufferSize(pPager);\n        }\n          \n        /* Verify that the database still has the same name as it did when\n        ** it was originally opened. */\n        rc = databaseIsUnmoved(pPager);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3JournalOpen (\n              pVfs, pPager->zJournal, pPager->jfd, flags, nSpill\n          );\n        }\n      }\n      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );\n    }\n  \n  \n    /* Write the first journal header to the journal file and open \n    ** the sub-journal if necessary.\n    */\n    if( rc==SQLITE_OK ){\n      /* TODO: Check if all of these are really required. */\n      pPager->nRec = 0;\n      pPager->journalOff = 0;\n      pPager->setMaster = 0;\n      pPager->journalHdr = 0;\n      rc = writeJournalHdr(pPager);\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3BitvecDestroy(pPager->pInJournal);\n    pPager->pInJournal = 0;\n  }else{\n    assert( pPager->eState==PAGER_WRITER_LOCKED );\n    pPager->eState = PAGER_WRITER_CACHEMOD;\n  }\n\n  return rc;\n}\n\n/*\n** Begin a write-transaction on the specified pager object. If a \n** write-transaction has already been opened, this function is a no-op.\n**\n** If the exFlag argument is false, then acquire at least a RESERVED\n** lock on the database file. If exFlag is true, then acquire at least\n** an EXCLUSIVE lock. If such a lock is already held, no locking \n** functions need be called.\n**\n** If the subjInMemory argument is non-zero, then any sub-journal opened\n** within this transaction will be opened as an in-memory file. This\n** has no effect if the sub-journal is already opened (as it may be when\n** running in exclusive mode) or if the transaction does not require a\n** sub-journal. If the subjInMemory argument is zero, then any required\n** sub-journal is implemented in-memory if pPager is an in-memory database, \n** or using a temporary file otherwise.\n*/\nint sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){\n  int rc = SQLITE_OK;\n\n  if( pPager->errCode ) return pPager->errCode;\n  assert( pPager->eState>=PAGER_READER && pPager->eState<PAGER_ERROR );\n  pPager->subjInMemory = (u8)subjInMemory;\n\n  if( ALWAYS(pPager->eState==PAGER_READER) ){\n    assert( pPager->pInJournal==0 );\n\n    if( pagerUseWal(pPager) ){\n      /* If the pager is configured to use locking_mode=exclusive, and an\n      ** exclusive lock on the database is not already held, obtain it now.\n      */\n      if( pPager->exclusiveMode && sqlite3WalExclusiveMode(pPager->pWal, -1) ){\n        rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n        (void)sqlite3WalExclusiveMode(pPager->pWal, 1);\n      }\n\n      /* Grab the write lock on the log file. If successful, upgrade to\n      ** PAGER_RESERVED state. Otherwise, return an error code to the caller.\n      ** The busy-handler is not invoked if another connection already\n      ** holds the write-lock. If possible, the upper layer will call it.\n      */\n      rc = sqlite3WalBeginWriteTransaction(pPager->pWal);\n    }else{\n      /* Obtain a RESERVED lock on the database file. If the exFlag parameter\n      ** is true, then immediately upgrade this to an EXCLUSIVE lock. The\n      ** busy-handler callback can be used when upgrading to the EXCLUSIVE\n      ** lock, but not when obtaining the RESERVED lock.\n      */\n      rc = pagerLockDb(pPager, RESERVED_LOCK);\n      if( rc==SQLITE_OK && exFlag ){\n        rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Change to WRITER_LOCKED state.\n      **\n      ** WAL mode sets Pager.eState to PAGER_WRITER_LOCKED or CACHEMOD\n      ** when it has an open transaction, but never to DBMOD or FINISHED.\n      ** This is because in those states the code to roll back savepoint \n      ** transactions may copy data from the sub-journal into the database \n      ** file as well as into the page cache. Which would be incorrect in \n      ** WAL mode.\n      */\n      pPager->eState = PAGER_WRITER_LOCKED;\n      pPager->dbHintSize = pPager->dbSize;\n      pPager->dbFileSize = pPager->dbSize;\n      pPager->dbOrigSize = pPager->dbSize;\n      pPager->journalOff = 0;\n    }\n\n    assert( rc==SQLITE_OK || pPager->eState==PAGER_READER );\n    assert( rc!=SQLITE_OK || pPager->eState==PAGER_WRITER_LOCKED );\n    assert( assert_pager_state(pPager) );\n  }\n\n  PAGERTRACE((\"TRANSACTION %d\\n\", PAGERID(pPager)));\n  return rc;\n}\n\n/*\n** Write page pPg onto the end of the rollback journal.\n*/\nstatic SQLITE_NOINLINE int pagerAddPageToRollbackJournal(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc;\n  u32 cksum;\n  char *pData2;\n  i64 iOff = pPager->journalOff;\n\n  /* We should never write to the journal file the page that\n  ** contains the database locks.  The following assert verifies\n  ** that we do not. */\n  assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );\n\n  assert( pPager->journalHdr<=pPager->journalOff );\n  CODEC2(pPager, pPg->pData, pPg->pgno, 7, return SQLITE_NOMEM_BKPT, pData2);\n  cksum = pager_cksum(pPager, (u8*)pData2);\n\n  /* Even if an IO or diskfull error occurs while journalling the\n  ** page in the block above, set the need-sync flag for the page.\n  ** Otherwise, when the transaction is rolled back, the logic in\n  ** playback_one_page() will think that the page needs to be restored\n  ** in the database file. And if an IO error occurs while doing so,\n  ** then corruption may follow.\n  */\n  pPg->flags |= PGHDR_NEED_SYNC;\n\n  rc = write32bits(pPager->jfd, iOff, pPg->pgno);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);\n  if( rc!=SQLITE_OK ) return rc;\n  rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);\n  if( rc!=SQLITE_OK ) return rc;\n\n  IOTRACE((\"JOUT %p %d %lld %d\\n\", pPager, pPg->pgno, \n           pPager->journalOff, pPager->pageSize));\n  PAGER_INCR(sqlite3_pager_writej_count);\n  PAGERTRACE((\"JOURNAL %d page %d needSync=%d hash(%08x)\\n\",\n       PAGERID(pPager), pPg->pgno, \n       ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));\n\n  pPager->journalOff += 8 + pPager->pageSize;\n  pPager->nRec++;\n  assert( pPager->pInJournal!=0 );\n  rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);\n  testcase( rc==SQLITE_NOMEM );\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  rc |= addToSavepointBitvecs(pPager, pPg->pgno);\n  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n  return rc;\n}\n\n/*\n** Mark a single data page as writeable. The page is written into the \n** main journal or sub-journal as required. If the page is written into\n** one of the journals, the corresponding bit is set in the \n** Pager.pInJournal bitvec and the PagerSavepoint.pInSavepoint bitvecs\n** of any open savepoints as appropriate.\n*/\nstatic int pager_write(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  int rc = SQLITE_OK;\n\n  /* This routine is not called unless a write-transaction has already \n  ** been started. The journal file may or may not be open at this point.\n  ** It is never called in the ERROR state.\n  */\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n  assert( pPager->errCode==0 );\n  assert( pPager->readOnly==0 );\n  CHECK_PAGE(pPg);\n\n  /* The journal file needs to be opened. Higher level routines have already\n  ** obtained the necessary locks to begin the write-transaction, but the\n  ** rollback journal might not yet be open. Open it now if this is the case.\n  **\n  ** This is done before calling sqlite3PcacheMakeDirty() on the page. \n  ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then\n  ** an error might occur and the pager would end up in WRITER_LOCKED state\n  ** with pages marked as dirty in the cache.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED ){\n    rc = pager_open_journal(pPager);\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  assert( pPager->eState>=PAGER_WRITER_CACHEMOD );\n  assert( assert_pager_state(pPager) );\n\n  /* Mark the page that is about to be modified as dirty. */\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* If a rollback journal is in use, them make sure the page that is about\n  ** to change is in the rollback journal, or if the page is a new page off\n  ** then end of the file, make sure it is marked as PGHDR_NEED_SYNC.\n  */\n  assert( (pPager->pInJournal!=0) == isOpen(pPager->jfd) );\n  if( pPager->pInJournal!=0\n   && sqlite3BitvecTestNotNull(pPager->pInJournal, pPg->pgno)==0\n  ){\n    assert( pagerUseWal(pPager)==0 );\n    if( pPg->pgno<=pPager->dbOrigSize ){\n      rc = pagerAddPageToRollbackJournal(pPg);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }else{\n      if( pPager->eState!=PAGER_WRITER_DBMOD ){\n        pPg->flags |= PGHDR_NEED_SYNC;\n      }\n      PAGERTRACE((\"APPEND %d page %d needSync=%d\\n\",\n              PAGERID(pPager), pPg->pgno,\n             ((pPg->flags&PGHDR_NEED_SYNC)?1:0)));\n    }\n  }\n\n  /* The PGHDR_DIRTY bit is set above when the page was added to the dirty-list\n  ** and before writing the page into the rollback journal.  Wait until now,\n  ** after the page has been successfully journalled, before setting the\n  ** PGHDR_WRITEABLE bit that indicates that the page can be safely modified.\n  */\n  pPg->flags |= PGHDR_WRITEABLE;\n  \n  /* If the statement journal is open and the page is not in it,\n  ** then write the page into the statement journal.\n  */\n  if( pPager->nSavepoint>0 ){\n    rc = subjournalPageIfRequired(pPg);\n  }\n\n  /* Update the database size and return. */\n  if( pPager->dbSize<pPg->pgno ){\n    pPager->dbSize = pPg->pgno;\n  }\n  return rc;\n}\n\n/*\n** This is a variant of sqlite3PagerWrite() that runs when the sector size\n** is larger than the page size.  SQLite makes the (reasonable) assumption that\n** all bytes of a sector are written together by hardware.  Hence, all bytes of\n** a sector need to be journalled in case of a power loss in the middle of\n** a write.\n**\n** Usually, the sector size is less than or equal to the page size, in which\n** case pages can be individually written.  This routine only runs in the\n** exceptional case where the page size is smaller than the sector size.\n*/\nstatic SQLITE_NOINLINE int pagerWriteLargeSector(PgHdr *pPg){\n  int rc = SQLITE_OK;          /* Return code */\n  Pgno nPageCount;             /* Total number of pages in database file */\n  Pgno pg1;                    /* First page of the sector pPg is located on. */\n  int nPage = 0;               /* Number of pages starting at pg1 to journal */\n  int ii;                      /* Loop counter */\n  int needSync = 0;            /* True if any page has PGHDR_NEED_SYNC */\n  Pager *pPager = pPg->pPager; /* The pager that owns pPg */\n  Pgno nPagePerSector = (pPager->sectorSize/pPager->pageSize);\n\n  /* Set the doNotSpill NOSYNC bit to 1. This is because we cannot allow\n  ** a journal header to be written between the pages journaled by\n  ** this function.\n  */\n  assert( !MEMDB );\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)==0 );\n  pPager->doNotSpill |= SPILLFLAG_NOSYNC;\n\n  /* This trick assumes that both the page-size and sector-size are\n  ** an integer power of 2. It sets variable pg1 to the identifier\n  ** of the first page of the sector pPg is located on.\n  */\n  pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;\n\n  nPageCount = pPager->dbSize;\n  if( pPg->pgno>nPageCount ){\n    nPage = (pPg->pgno - pg1)+1;\n  }else if( (pg1+nPagePerSector-1)>nPageCount ){\n    nPage = nPageCount+1-pg1;\n  }else{\n    nPage = nPagePerSector;\n  }\n  assert(nPage>0);\n  assert(pg1<=pPg->pgno);\n  assert((pg1+nPage)>pPg->pgno);\n\n  for(ii=0; ii<nPage && rc==SQLITE_OK; ii++){\n    Pgno pg = pg1+ii;\n    PgHdr *pPage;\n    if( pg==pPg->pgno || !sqlite3BitvecTest(pPager->pInJournal, pg) ){\n      if( pg!=PAGER_MJ_PGNO(pPager) ){\n        rc = sqlite3PagerGet(pPager, pg, &pPage, 0);\n        if( rc==SQLITE_OK ){\n          rc = pager_write(pPage);\n          if( pPage->flags&PGHDR_NEED_SYNC ){\n            needSync = 1;\n          }\n          sqlite3PagerUnrefNotNull(pPage);\n        }\n      }\n    }else if( (pPage = sqlite3PagerLookup(pPager, pg))!=0 ){\n      if( pPage->flags&PGHDR_NEED_SYNC ){\n        needSync = 1;\n      }\n      sqlite3PagerUnrefNotNull(pPage);\n    }\n  }\n\n  /* If the PGHDR_NEED_SYNC flag is set for any of the nPage pages \n  ** starting at pg1, then it needs to be set for all of them. Because\n  ** writing to any of these nPage pages may damage the others, the\n  ** journal file must contain sync()ed copies of all of them\n  ** before any of them can be written out to the database file.\n  */\n  if( rc==SQLITE_OK && needSync ){\n    assert( !MEMDB );\n    for(ii=0; ii<nPage; ii++){\n      PgHdr *pPage = sqlite3PagerLookup(pPager, pg1+ii);\n      if( pPage ){\n        pPage->flags |= PGHDR_NEED_SYNC;\n        sqlite3PagerUnrefNotNull(pPage);\n      }\n    }\n  }\n\n  assert( (pPager->doNotSpill & SPILLFLAG_NOSYNC)!=0 );\n  pPager->doNotSpill &= ~SPILLFLAG_NOSYNC;\n  return rc;\n}\n\n/*\n** Mark a data page as writeable. This routine must be called before \n** making changes to a page. The caller must check the return value \n** of this function and be careful not to change any page data unless \n** this routine returns SQLITE_OK.\n**\n** The difference between this function and pager_write() is that this\n** function also deals with the special case where 2 or more pages\n** fit on a single disk sector. In this case all co-resident pages\n** must have been written to the journal file before returning.\n**\n** If an error occurs, SQLITE_NOMEM or an IO error code is returned\n** as appropriate. Otherwise, SQLITE_OK.\n*/\nint sqlite3PagerWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  assert( (pPg->flags & PGHDR_MMAP)==0 );\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  if( (pPg->flags & PGHDR_WRITEABLE)!=0 && pPager->dbSize>=pPg->pgno ){\n    if( pPager->nSavepoint ) return subjournalPageIfRequired(pPg);\n    return SQLITE_OK;\n  }else if( pPager->errCode ){\n    return pPager->errCode;\n  }else if( pPager->sectorSize > (u32)pPager->pageSize ){\n    assert( pPager->tempFile==0 );\n    return pagerWriteLargeSector(pPg);\n  }else{\n    return pager_write(pPg);\n  }\n}\n\n/*\n** Return TRUE if the page given in the argument was previously passed\n** to sqlite3PagerWrite().  In other words, return TRUE if it is ok\n** to change the content of the page.\n*/\n#ifndef NDEBUG\nint sqlite3PagerIswriteable(DbPage *pPg){\n  return pPg->flags & PGHDR_WRITEABLE;\n}\n#endif\n\n/*\n** A call to this routine tells the pager that it is not necessary to\n** write the information on page pPg back to the disk, even though\n** that page might be marked as dirty.  This happens, for example, when\n** the page has been added as a leaf of the freelist and so its\n** content no longer matters.\n**\n** The overlying software layer calls this routine when all of the data\n** on the given page is unused. The pager marks the page as clean so\n** that it does not get written to disk.\n**\n** Tests show that this optimization can quadruple the speed of large \n** DELETE operations.\n**\n** This optimization cannot be used with a temp-file, as the page may\n** have been dirty at the start of the transaction. In that case, if\n** memory pressure forces page pPg out of the cache, the data does need \n** to be written out to disk so that it may be read back in if the \n** current transaction is rolled back.\n*/\nvoid sqlite3PagerDontWrite(PgHdr *pPg){\n  Pager *pPager = pPg->pPager;\n  if( !pPager->tempFile && (pPg->flags&PGHDR_DIRTY) && pPager->nSavepoint==0 ){\n    PAGERTRACE((\"DONT_WRITE page %d of %d\\n\", pPg->pgno, PAGERID(pPager)));\n    IOTRACE((\"CLEAN %p %d\\n\", pPager, pPg->pgno))\n    pPg->flags |= PGHDR_DONT_WRITE;\n    pPg->flags &= ~PGHDR_WRITEABLE;\n    testcase( pPg->flags & PGHDR_NEED_SYNC );\n    pager_set_pagehash(pPg);\n  }\n}\n\n/*\n** This routine is called to increment the value of the database file \n** change-counter, stored as a 4-byte big-endian integer starting at \n** byte offset 24 of the pager file.  The secondary change counter at\n** 92 is also updated, as is the SQLite version number at offset 96.\n**\n** But this only happens if the pPager->changeCountDone flag is false.\n** To avoid excess churning of page 1, the update only happens once.\n** See also the pager_write_changecounter() routine that does an \n** unconditional update of the change counters.\n**\n** If the isDirectMode flag is zero, then this is done by calling \n** sqlite3PagerWrite() on page 1, then modifying the contents of the\n** page data. In this case the file will be updated when the current\n** transaction is committed.\n**\n** The isDirectMode flag may only be non-zero if the library was compiled\n** with the SQLITE_ENABLE_ATOMIC_WRITE macro defined. In this case,\n** if isDirect is non-zero, then the database file is updated directly\n** by writing an updated version of page 1 using a call to the \n** sqlite3OsWrite() function.\n*/\nstatic int pager_incr_changecounter(Pager *pPager, int isDirectMode){\n  int rc = SQLITE_OK;\n\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* Declare and initialize constant integer 'isDirect'. If the\n  ** atomic-write optimization is enabled in this build, then isDirect\n  ** is initialized to the value passed as the isDirectMode parameter\n  ** to this function. Otherwise, it is always set to zero.\n  **\n  ** The idea is that if the atomic-write optimization is not\n  ** enabled at compile time, the compiler can omit the tests of\n  ** 'isDirect' below, as well as the block enclosed in the\n  ** \"if( isDirect )\" condition.\n  */\n#ifndef SQLITE_ENABLE_ATOMIC_WRITE\n# define DIRECT_MODE 0\n  assert( isDirectMode==0 );\n  UNUSED_PARAMETER(isDirectMode);\n#else\n# define DIRECT_MODE isDirectMode\n#endif\n\n  if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){\n    PgHdr *pPgHdr;                /* Reference to page 1 */\n\n    assert( !pPager->tempFile && isOpen(pPager->fd) );\n\n    /* Open page 1 of the file for writing. */\n    rc = sqlite3PagerGet(pPager, 1, &pPgHdr, 0);\n    assert( pPgHdr==0 || rc==SQLITE_OK );\n\n    /* If page one was fetched successfully, and this function is not\n    ** operating in direct-mode, make page 1 writable.  When not in \n    ** direct mode, page 1 is always held in cache and hence the PagerGet()\n    ** above is always successful - hence the ALWAYS on rc==SQLITE_OK.\n    */\n    if( !DIRECT_MODE && ALWAYS(rc==SQLITE_OK) ){\n      rc = sqlite3PagerWrite(pPgHdr);\n    }\n\n    if( rc==SQLITE_OK ){\n      /* Actually do the update of the change counter */\n      pager_write_changecounter(pPgHdr);\n\n      /* If running in direct mode, write the contents of page 1 to the file. */\n      if( DIRECT_MODE ){\n        const void *zBuf;\n        assert( pPager->dbFileSize>0 );\n        CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM_BKPT, zBuf);\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);\n          pPager->aStat[PAGER_STAT_WRITE]++;\n        }\n        if( rc==SQLITE_OK ){\n          /* Update the pager's copy of the change-counter. Otherwise, the\n          ** next time a read transaction is opened the cache will be\n          ** flushed (as the change-counter values will not match).  */\n          const void *pCopy = (const void *)&((const char *)zBuf)[24];\n          memcpy(&pPager->dbFileVers, pCopy, sizeof(pPager->dbFileVers));\n          pPager->changeCountDone = 1;\n        }\n      }else{\n        pPager->changeCountDone = 1;\n      }\n    }\n\n    /* Release the page reference. */\n    sqlite3PagerUnref(pPgHdr);\n  }\n  return rc;\n}\n\n/*\n** Sync the database file to disk. This is a no-op for in-memory databases\n** or pages with the Pager.noSync flag set.\n**\n** If successful, or if called on a pager for which it is a no-op, this\n** function returns SQLITE_OK. Otherwise, an IO error code is returned.\n*/\nint sqlite3PagerSync(Pager *pPager, const char *zMaster){\n  int rc = SQLITE_OK;\n\n  if( isOpen(pPager->fd) ){\n    void *pArg = (void*)zMaster;\n    rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg);\n    if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n  }\n  if( rc==SQLITE_OK && !pPager->noSync ){\n    assert( !MEMDB );\n    rc = sqlite3OsSync(pPager->fd, pPager->syncFlags);\n  }\n  return rc;\n}\n\n/*\n** This function may only be called while a write-transaction is active in\n** rollback. If the connection is in WAL mode, this call is a no-op. \n** Otherwise, if the connection does not already have an EXCLUSIVE lock on \n** the database file, an attempt is made to obtain one.\n**\n** If the EXCLUSIVE lock is already held or the attempt to obtain it is\n** successful, or the connection is in WAL mode, SQLITE_OK is returned.\n** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is \n** returned.\n*/\nint sqlite3PagerExclusiveLock(Pager *pPager){\n  int rc = pPager->errCode;\n  assert( assert_pager_state(pPager) );\n  if( rc==SQLITE_OK ){\n    assert( pPager->eState==PAGER_WRITER_CACHEMOD \n         || pPager->eState==PAGER_WRITER_DBMOD \n         || pPager->eState==PAGER_WRITER_LOCKED \n    );\n    assert( assert_pager_state(pPager) );\n    if( 0==pagerUseWal(pPager) ){\n      rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);\n    }\n  }\n  return rc;\n}\n\n/*\n** Sync the database file for the pager pPager. zMaster points to the name\n** of a master journal file that should be written into the individual\n** journal file. zMaster may be NULL, which is interpreted as no master\n** journal (a single database transaction).\n**\n** This routine ensures that:\n**\n**   * The database file change-counter is updated,\n**   * the journal is synced (unless the atomic-write optimization is used),\n**   * all dirty pages are written to the database file, \n**   * the database file is truncated (if required), and\n**   * the database file synced. \n**\n** The only thing that remains to commit the transaction is to finalize \n** (delete, truncate or zero the first part of) the journal file (or \n** delete the master journal file if specified).\n**\n** Note that if zMaster==NULL, this does not overwrite a previous value\n** passed to an sqlite3PagerCommitPhaseOne() call.\n**\n** If the final parameter - noSync - is true, then the database file itself\n** is not synced. The caller must call sqlite3PagerSync() directly to\n** sync the database file before calling CommitPhaseTwo() to delete the\n** journal file in this case.\n*/\nint sqlite3PagerCommitPhaseOne(\n  Pager *pPager,                  /* Pager object */\n  const char *zMaster,            /* If not NULL, the master journal name */\n  int noSync                      /* True to omit the xSync on the db file */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n       || pPager->eState==PAGER_ERROR\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* If a prior error occurred, report that error again. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  /* Provide the ability to easily simulate an I/O error during testing */\n  if( sqlite3FaultSim(400) ) return SQLITE_IOERR;\n\n  PAGERTRACE((\"DATABASE SYNC: File=%s zMaster=%s nSize=%d\\n\", \n      pPager->zFilename, zMaster, pPager->dbSize));\n\n  /* If no database changes have been made, return early. */\n  if( pPager->eState<PAGER_WRITER_CACHEMOD ) return SQLITE_OK;\n\n  assert( MEMDB==0 || pPager->tempFile );\n  assert( isOpen(pPager->fd) || pPager->tempFile );\n  if( 0==pagerFlushOnCommit(pPager, 1) ){\n    /* If this is an in-memory db, or no pages have been written to, or this\n    ** function has already been called, it is mostly a no-op.  However, any\n    ** backup in progress needs to be restarted.  */\n    sqlite3BackupRestart(pPager->pBackup);\n  }else{\n    if( pagerUseWal(pPager) ){\n      PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache);\n      PgHdr *pPageOne = 0;\n      if( pList==0 ){\n        /* Must have at least one page for the WAL commit flag.\n        ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */\n        rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0);\n        pList = pPageOne;\n        pList->pDirty = 0;\n      }\n      assert( rc==SQLITE_OK );\n      if( ALWAYS(pList) ){\n        rc = pagerWalFrames(pPager, pList, pPager->dbSize, 1);\n      }\n      sqlite3PagerUnref(pPageOne);\n      if( rc==SQLITE_OK ){\n        sqlite3PcacheCleanAll(pPager->pPCache);\n      }\n    }else{\n      /* The bBatch boolean is true if the batch-atomic-write commit method\n      ** should be used.  No rollback journal is created if batch-atomic-write\n      ** is enabled.\n      */\n      sqlite3_file *fd = pPager->fd;\n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      const int bBatch = zMaster==0    /* An SQLITE_IOCAP_BATCH_ATOMIC commit */\n        && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC)\n        && !pPager->noSync\n        && sqlite3JournalIsInMemory(pPager->jfd);\n#else\n# define bBatch 0\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n      /* The following block updates the change-counter. Exactly how it\n      ** does this depends on whether or not the atomic-update optimization\n      ** was enabled at compile time, and if this transaction meets the \n      ** runtime criteria to use the operation: \n      **\n      **    * The file-system supports the atomic-write property for\n      **      blocks of size page-size, and \n      **    * This commit is not part of a multi-file transaction, and\n      **    * Exactly one page has been modified and store in the journal file.\n      **\n      ** If the optimization was not enabled at compile time, then the\n      ** pager_incr_changecounter() function is called to update the change\n      ** counter in 'indirect-mode'. If the optimization is compiled in but\n      ** is not applicable to this transaction, call sqlite3JournalCreate()\n      ** to make sure the journal file has actually been created, then call\n      ** pager_incr_changecounter() to update the change-counter in indirect\n      ** mode. \n      **\n      ** Otherwise, if the optimization is both enabled and applicable,\n      ** then call pager_incr_changecounter() to update the change-counter\n      ** in 'direct' mode. In this case the journal file will never be\n      ** created for this transaction.\n      */\n      if( bBatch==0 ){\n        PgHdr *pPg;\n        assert( isOpen(pPager->jfd) \n            || pPager->journalMode==PAGER_JOURNALMODE_OFF \n            || pPager->journalMode==PAGER_JOURNALMODE_WAL \n            );\n        if( !zMaster && isOpen(pPager->jfd) \n         && pPager->journalOff==jrnlBufferSize(pPager) \n         && pPager->dbSize>=pPager->dbOrigSize\n         && (!(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty)\n        ){\n          /* Update the db file change counter via the direct-write method. The \n          ** following call will modify the in-memory representation of page 1 \n          ** to include the updated change counter and then write page 1 \n          ** directly to the database file. Because of the atomic-write \n          ** property of the host file-system, this is safe.\n          */\n          rc = pager_incr_changecounter(pPager, 1);\n        }else{\n          rc = sqlite3JournalCreate(pPager->jfd);\n          if( rc==SQLITE_OK ){\n            rc = pager_incr_changecounter(pPager, 0);\n          }\n        }\n      }\n#else \n#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n      if( zMaster ){\n        rc = sqlite3JournalCreate(pPager->jfd);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n#endif\n      rc = pager_incr_changecounter(pPager, 0);\n#endif\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Write the master journal name into the journal file. If a master \n      ** journal file name has already been written to the journal file, \n      ** or if zMaster is NULL (no master journal), then this call is a no-op.\n      */\n      rc = writeMasterJournal(pPager, zMaster);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n  \n      /* Sync the journal file and write all dirty pages to the database.\n      ** If the atomic-update optimization is being used, this sync will not \n      ** create the journal file or perform any real IO.\n      **\n      ** Because the change-counter page was just modified, unless the\n      ** atomic-update optimization is used it is almost certain that the\n      ** journal requires a sync here. However, in locking_mode=exclusive\n      ** on a system under memory pressure it is just possible that this is \n      ** not the case. In this case it is likely enough that the redundant\n      ** xSync() call will be changed to a no-op by the OS anyhow. \n      */\n      rc = syncJournal(pPager, 0);\n      if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n\n      if( bBatch ){\n        /* The pager is now in DBMOD state. But regardless of what happens\n        ** next, attempting to play the journal back into the database would\n        ** be unsafe. Close it now to make sure that does not happen.  */\n        sqlite3OsClose(pPager->jfd);\n        rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n      rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache));\n      if( bBatch ){\n        if( rc==SQLITE_OK ){\n          rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0);\n        }else{\n          sqlite3OsFileControl(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0);\n        }\n      }\n\n      if( rc!=SQLITE_OK ){\n        assert( rc!=SQLITE_IOERR_BLOCKED );\n        goto commit_phase_one_exit;\n      }\n      sqlite3PcacheCleanAll(pPager->pPCache);\n\n      /* If the file on disk is smaller than the database image, use \n      ** pager_truncate to grow the file here. This can happen if the database\n      ** image was extended as part of the current transaction and then the\n      ** last page in the db image moved to the free-list. In this case the\n      ** last page is never written out to disk, leaving the database file\n      ** undersized. Fix this now if it is the case.  */\n      if( pPager->dbSize>pPager->dbFileSize ){\n        Pgno nNew = pPager->dbSize - (pPager->dbSize==PAGER_MJ_PGNO(pPager));\n        assert( pPager->eState==PAGER_WRITER_DBMOD );\n        rc = pager_truncate(pPager, nNew);\n        if( rc!=SQLITE_OK ) goto commit_phase_one_exit;\n      }\n  \n      /* Finally, sync the database file. */\n      if( !noSync ){\n        rc = sqlite3PagerSync(pPager, zMaster);\n      }\n      IOTRACE((\"DBSYNC %p\\n\", pPager))\n    }\n  }\n\ncommit_phase_one_exit:\n  if( rc==SQLITE_OK && !pagerUseWal(pPager) ){\n    pPager->eState = PAGER_WRITER_FINISHED;\n  }\n  return rc;\n}\n\n\n/*\n** When this function is called, the database file has been completely\n** updated to reflect the changes made by the current transaction and\n** synced to disk. The journal file still exists in the file-system \n** though, and if a failure occurs at this point it will eventually\n** be used as a hot-journal and the current transaction rolled back.\n**\n** This function finalizes the journal file, either by deleting, \n** truncating or partially zeroing it, so that it cannot be used \n** for hot-journal rollback. Once this is done the transaction is\n** irrevocably committed.\n**\n** If an error occurs, an IO error code is returned and the pager\n** moves into the error state. Otherwise, SQLITE_OK is returned.\n*/\nint sqlite3PagerCommitPhaseTwo(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n\n  /* This routine should not be called if a prior error has occurred.\n  ** But if (due to a coding error elsewhere in the system) it does get\n  ** called, just return the same error code without doing anything. */\n  if( NEVER(pPager->errCode) ) return pPager->errCode;\n\n  assert( pPager->eState==PAGER_WRITER_LOCKED\n       || pPager->eState==PAGER_WRITER_FINISHED\n       || (pagerUseWal(pPager) && pPager->eState==PAGER_WRITER_CACHEMOD)\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* An optimization. If the database was not actually modified during\n  ** this transaction, the pager is running in exclusive-mode and is\n  ** using persistent journals, then this function is a no-op.\n  **\n  ** The start of the journal file currently contains a single journal \n  ** header with the nRec field set to 0. If such a journal is used as\n  ** a hot-journal during hot-journal rollback, 0 changes will be made\n  ** to the database file. So there is no need to zero the journal \n  ** header. Since the pager is in exclusive mode, there is no need\n  ** to drop any locks either.\n  */\n  if( pPager->eState==PAGER_WRITER_LOCKED \n   && pPager->exclusiveMode \n   && pPager->journalMode==PAGER_JOURNALMODE_PERSIST\n  ){\n    assert( pPager->journalOff==JOURNAL_HDR_SZ(pPager) || !pPager->journalOff );\n    pPager->eState = PAGER_READER;\n    return SQLITE_OK;\n  }\n\n  PAGERTRACE((\"COMMIT %d\\n\", PAGERID(pPager)));\n  pPager->iDataVersion++;\n  rc = pager_end_transaction(pPager, pPager->setMaster, 1);\n  return pager_error(pPager, rc);\n}\n\n/*\n** If a write transaction is open, then all changes made within the \n** transaction are reverted and the current write-transaction is closed.\n** The pager falls back to PAGER_READER state if successful, or PAGER_ERROR\n** state if an error occurs.\n**\n** If the pager is already in PAGER_ERROR state when this function is called,\n** it returns Pager.errCode immediately. No work is performed in this case.\n**\n** Otherwise, in rollback mode, this function performs two functions:\n**\n**   1) It rolls back the journal file, restoring all database file and \n**      in-memory cache pages to the state they were in when the transaction\n**      was opened, and\n**\n**   2) It finalizes the journal file, so that it is not used for hot\n**      rollback at any point in the future.\n**\n** Finalization of the journal file (task 2) is only performed if the \n** rollback is successful.\n**\n** In WAL mode, all cache-entries containing data modified within the\n** current transaction are either expelled from the cache or reverted to\n** their pre-transaction state by re-reading data from the database or\n** WAL files. The WAL transaction is then closed.\n*/\nint sqlite3PagerRollback(Pager *pPager){\n  int rc = SQLITE_OK;                  /* Return code */\n  PAGERTRACE((\"ROLLBACK %d\\n\", PAGERID(pPager)));\n\n  /* PagerRollback() is a no-op if called in READER or OPEN state. If\n  ** the pager is already in the ERROR state, the rollback is not \n  ** attempted here. Instead, the error code is returned to the caller.\n  */\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState==PAGER_ERROR ) return pPager->errCode;\n  if( pPager->eState<=PAGER_READER ) return SQLITE_OK;\n\n  if( pagerUseWal(pPager) ){\n    int rc2;\n    rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, -1);\n    rc2 = pager_end_transaction(pPager, pPager->setMaster, 0);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }else if( !isOpen(pPager->jfd) || pPager->eState==PAGER_WRITER_LOCKED ){\n    int eState = pPager->eState;\n    rc = pager_end_transaction(pPager, 0, 0);\n    if( !MEMDB && eState>PAGER_WRITER_LOCKED ){\n      /* This can happen using journal_mode=off. Move the pager to the error \n      ** state to indicate that the contents of the cache may not be trusted.\n      ** Any active readers will get SQLITE_ABORT.\n      */\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n      return rc;\n    }\n  }else{\n    rc = pager_playback(pPager, 0);\n  }\n\n  assert( pPager->eState==PAGER_READER || rc!=SQLITE_OK );\n  assert( rc==SQLITE_OK || rc==SQLITE_FULL || rc==SQLITE_CORRUPT\n          || rc==SQLITE_NOMEM || (rc&0xFF)==SQLITE_IOERR \n          || rc==SQLITE_CANTOPEN\n  );\n\n  /* If an error occurs during a ROLLBACK, we can no longer trust the pager\n  ** cache. So call pager_error() on the way out to make any error persistent.\n  */\n  return pager_error(pPager, rc);\n}\n\n/*\n** Return TRUE if the database file is opened read-only.  Return FALSE\n** if the database is (in theory) writable.\n*/\nu8 sqlite3PagerIsreadonly(Pager *pPager){\n  return pPager->readOnly;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return the sum of the reference counts for all pages held by pPager.\n*/\nint sqlite3PagerRefcount(Pager *pPager){\n  return sqlite3PcacheRefCount(pPager->pPCache);\n}\n#endif\n\n/*\n** Return the approximate number of bytes of memory currently\n** used by the pager and its associated cache.\n*/\nint sqlite3PagerMemUsed(Pager *pPager){\n  int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr)\n                                     + 5*sizeof(void*);\n  return perPageSize*sqlite3PcachePagecount(pPager->pPCache)\n           + sqlite3MallocSize(pPager)\n           + pPager->pageSize;\n}\n\n/*\n** Return the number of references to the specified page.\n*/\nint sqlite3PagerPageRefcount(DbPage *pPage){\n  return sqlite3PcachePageRefcount(pPage);\n}\n\n#ifdef SQLITE_TEST\n/*\n** This routine is used for testing and analysis only.\n*/\nint *sqlite3PagerStats(Pager *pPager){\n  static int a[11];\n  a[0] = sqlite3PcacheRefCount(pPager->pPCache);\n  a[1] = sqlite3PcachePagecount(pPager->pPCache);\n  a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);\n  a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;\n  a[4] = pPager->eState;\n  a[5] = pPager->errCode;\n  a[6] = pPager->aStat[PAGER_STAT_HIT];\n  a[7] = pPager->aStat[PAGER_STAT_MISS];\n  a[8] = 0;  /* Used to be pPager->nOvfl */\n  a[9] = pPager->nRead;\n  a[10] = pPager->aStat[PAGER_STAT_WRITE];\n  return a;\n}\n#endif\n\n/*\n** Parameter eStat must be either SQLITE_DBSTATUS_CACHE_HIT or\n** SQLITE_DBSTATUS_CACHE_MISS. Before returning, *pnVal is incremented by the\n** current cache hit or miss count, according to the value of eStat. If the \n** reset parameter is non-zero, the cache hit or miss count is zeroed before \n** returning.\n*/\nvoid sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){\n\n  assert( eStat==SQLITE_DBSTATUS_CACHE_HIT\n       || eStat==SQLITE_DBSTATUS_CACHE_MISS\n       || eStat==SQLITE_DBSTATUS_CACHE_WRITE\n  );\n\n  assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );\n  assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );\n  assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );\n\n  *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];\n  if( reset ){\n    pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;\n  }\n}\n\n/*\n** Return true if this is an in-memory or temp-file backed pager.\n*/\nint sqlite3PagerIsMemdb(Pager *pPager){\n  return pPager->tempFile;\n}\n\n/*\n** Check that there are at least nSavepoint savepoints open. If there are\n** currently less than nSavepoints open, then open one or more savepoints\n** to make up the difference. If the number of savepoints is already\n** equal to nSavepoint, then this function is a no-op.\n**\n** If a memory allocation fails, SQLITE_NOMEM is returned. If an error \n** occurs while opening the sub-journal file, then an IO error code is\n** returned. Otherwise, SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  int rc = SQLITE_OK;                       /* Return code */\n  int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */\n  int ii;                                   /* Iterator variable */\n  PagerSavepoint *aNew;                     /* New Pager.aSavepoint array */\n\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n  assert( nSavepoint>nCurrent && pPager->useJournal );\n\n  /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM\n  ** if the allocation fails. Otherwise, zero the new portion in case a \n  ** malloc failure occurs while populating it in the for(...) loop below.\n  */\n  aNew = (PagerSavepoint *)sqlite3Realloc(\n      pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint\n  );\n  if( !aNew ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));\n  pPager->aSavepoint = aNew;\n\n  /* Populate the PagerSavepoint structures just allocated. */\n  for(ii=nCurrent; ii<nSavepoint; ii++){\n    aNew[ii].nOrig = pPager->dbSize;\n    if( isOpen(pPager->jfd) && pPager->journalOff>0 ){\n      aNew[ii].iOffset = pPager->journalOff;\n    }else{\n      aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);\n    }\n    aNew[ii].iSubRec = pPager->nSubRec;\n    aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);\n    if( !aNew[ii].pInSavepoint ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    if( pagerUseWal(pPager) ){\n      sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);\n    }\n    pPager->nSavepoint = ii+1;\n  }\n  assert( pPager->nSavepoint==nSavepoint );\n  assertTruncateConstraint(pPager);\n  return rc;\n}\nint sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){\n  assert( pPager->eState>=PAGER_WRITER_LOCKED );\n  assert( assert_pager_state(pPager) );\n\n  if( nSavepoint>pPager->nSavepoint && pPager->useJournal ){\n    return pagerOpenSavepoint(pPager, nSavepoint);\n  }else{\n    return SQLITE_OK;\n  }\n}\n\n\n/*\n** This function is called to rollback or release (commit) a savepoint.\n** The savepoint to release or rollback need not be the most recently \n** created savepoint.\n**\n** Parameter op is always either SAVEPOINT_ROLLBACK or SAVEPOINT_RELEASE.\n** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with\n** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes\n** that have occurred since the specified savepoint was created.\n**\n** The savepoint to rollback or release is identified by parameter \n** iSavepoint. A value of 0 means to operate on the outermost savepoint\n** (the first created). A value of (Pager.nSavepoint-1) means operate\n** on the most recently created savepoint. If iSavepoint is greater than\n** (Pager.nSavepoint-1), then this function is a no-op.\n**\n** If a negative value is passed to this function, then the current\n** transaction is rolled back. This is different to calling \n** sqlite3PagerRollback() because this function does not terminate\n** the transaction or unlock the database, it just restores the \n** contents of the database to its original state. \n**\n** In any case, all savepoints with an index greater than iSavepoint \n** are destroyed. If this is a release operation (op==SAVEPOINT_RELEASE),\n** then savepoint iSavepoint is also destroyed.\n**\n** This function may return SQLITE_NOMEM if a memory allocation fails,\n** or an IO error code if an IO error occurs while rolling back a \n** savepoint. If no errors occur, SQLITE_OK is returned.\n*/ \nint sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){\n  int rc = pPager->errCode;\n  \n#ifdef SQLITE_ENABLE_ZIPVFS\n  if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;\n#endif\n\n  assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );\n  assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );\n\n  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){\n    int ii;            /* Iterator variable */\n    int nNew;          /* Number of remaining savepoints after this op. */\n\n    /* Figure out how many savepoints will still be active after this\n    ** operation. Store this value in nNew. Then free resources associated \n    ** with any savepoints that are destroyed by this operation.\n    */\n    nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);\n    for(ii=nNew; ii<pPager->nSavepoint; ii++){\n      sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);\n    }\n    pPager->nSavepoint = nNew;\n\n    /* If this is a release of the outermost savepoint, truncate \n    ** the sub-journal to zero bytes in size. */\n    if( op==SAVEPOINT_RELEASE ){\n      if( nNew==0 && isOpen(pPager->sjfd) ){\n        /* Only truncate if it is an in-memory sub-journal. */\n        if( sqlite3JournalIsInMemory(pPager->sjfd) ){\n          rc = sqlite3OsTruncate(pPager->sjfd, 0);\n          assert( rc==SQLITE_OK );\n        }\n        pPager->nSubRec = 0;\n      }\n    }\n    /* Else this is a rollback operation, playback the specified savepoint.\n    ** If this is a temp-file, it is possible that the journal file has\n    ** not yet been opened. In this case there have been no changes to\n    ** the database file, so the playback operation can be skipped.\n    */\n    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){\n      PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];\n      rc = pagerPlaybackSavepoint(pPager, pSavepoint);\n      assert(rc!=SQLITE_DONE);\n    }\n    \n#ifdef SQLITE_ENABLE_ZIPVFS\n    /* If the cache has been modified but the savepoint cannot be rolled \n    ** back journal_mode=off, put the pager in the error state. This way,\n    ** if the VFS used by this pager includes ZipVFS, the entire transaction\n    ** can be rolled back at the ZipVFS level.  */\n    else if( \n        pPager->journalMode==PAGER_JOURNALMODE_OFF \n     && pPager->eState>=PAGER_WRITER_CACHEMOD\n    ){\n      pPager->errCode = SQLITE_ABORT;\n      pPager->eState = PAGER_ERROR;\n      setGetterMethod(pPager);\n    }\n#endif\n  }\n\n  return rc;\n}\n\n/*\n** Return the full pathname of the database file.\n**\n** Except, if the pager is in-memory only, then return an empty string if\n** nullIfMemDb is true.  This routine is called with nullIfMemDb==1 when\n** used to report the filename to the user, for compatibility with legacy\n** behavior.  But when the Btree needs to know the filename for matching to\n** shared cache, it uses nullIfMemDb==0 so that in-memory databases can\n** participate in shared-cache.\n*/\nconst char *sqlite3PagerFilename(Pager *pPager, int nullIfMemDb){\n  return (nullIfMemDb && pPager->memDb) ? \"\" : pPager->zFilename;\n}\n\n/*\n** Return the VFS structure for the pager.\n*/\nsqlite3_vfs *sqlite3PagerVfs(Pager *pPager){\n  return pPager->pVfs;\n}\n\n/*\n** Return the file handle for the database file associated\n** with the pager.  This might return NULL if the file has\n** not yet been opened.\n*/\nsqlite3_file *sqlite3PagerFile(Pager *pPager){\n  return pPager->fd;\n}\n\n/*\n** Return the file handle for the journal file (if it exists).\n** This will be either the rollback journal or the WAL file.\n*/\nsqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){\n#if SQLITE_OMIT_WAL\n  return pPager->jfd;\n#else\n  return pPager->pWal ? sqlite3WalFile(pPager->pWal) : pPager->jfd;\n#endif\n}\n\n/*\n** Return the full pathname of the journal file.\n*/\nconst char *sqlite3PagerJournalname(Pager *pPager){\n  return pPager->zJournal;\n}\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Set or retrieve the codec for this pager\n*/\nvoid sqlite3PagerSetCodec(\n  Pager *pPager,\n  void *(*xCodec)(void*,void*,Pgno,int),\n  void (*xCodecSizeChng)(void*,int,int),\n  void (*xCodecFree)(void*),\n  void *pCodec\n){\n  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);\n  pPager->xCodec = pPager->memDb ? 0 : xCodec;\n  pPager->xCodecSizeChng = xCodecSizeChng;\n  pPager->xCodecFree = xCodecFree;\n  pPager->pCodec = pCodec;\n  setGetterMethod(pPager);\n  pagerReportSize(pPager);\n}\nvoid *sqlite3PagerGetCodec(Pager *pPager){\n  return pPager->pCodec;\n}\n\n/*\n** This function is called by the wal module when writing page content\n** into the log file.\n**\n** This function returns a pointer to a buffer containing the encrypted\n** page content. If a malloc fails, this function may return NULL.\n*/\nvoid *sqlite3PagerCodec(PgHdr *pPg){\n  void *aData = 0;\n  CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);\n  return aData;\n}\n\n/*\n** Return the current pager state\n*/\nint sqlite3PagerState(Pager *pPager){\n  return pPager->eState;\n}\n#endif /* SQLITE_HAS_CODEC */\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Move the page pPg to location pgno in the file.\n**\n** There must be no references to the page previously located at\n** pgno (which we call pPgOld) though that page is allowed to be\n** in cache.  If the page previously located at pgno is not already\n** in the rollback journal, it is not put there by by this routine.\n**\n** References to the page pPg remain valid. Updating any\n** meta-data associated with pPg (i.e. data stored in the nExtra bytes\n** allocated along with the page) is the responsibility of the caller.\n**\n** A transaction must be active when this routine is called. It used to be\n** required that a statement transaction was not active, but this restriction\n** has been removed (CREATE INDEX needs to move a page when a statement\n** transaction is active).\n**\n** If the fourth argument, isCommit, is non-zero, then this page is being\n** moved as part of a database reorganization just before the transaction \n** is being committed. In this case, it is guaranteed that the database page \n** pPg refers to will not be written to again within this transaction.\n**\n** This function may return SQLITE_NOMEM or an IO error code if an error\n** occurs. Otherwise, it returns SQLITE_OK.\n*/\nint sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, int isCommit){\n  PgHdr *pPgOld;               /* The page being overwritten. */\n  Pgno needSyncPgno = 0;       /* Old value of pPg->pgno, if sync is required */\n  int rc;                      /* Return code */\n  Pgno origPgno;               /* The original page number */\n\n  assert( pPg->nRef>0 );\n  assert( pPager->eState==PAGER_WRITER_CACHEMOD\n       || pPager->eState==PAGER_WRITER_DBMOD\n  );\n  assert( assert_pager_state(pPager) );\n\n  /* In order to be able to rollback, an in-memory database must journal\n  ** the page we are moving from.\n  */\n  assert( pPager->tempFile || !MEMDB );\n  if( pPager->tempFile ){\n    rc = sqlite3PagerWrite(pPg);\n    if( rc ) return rc;\n  }\n\n  /* If the page being moved is dirty and has not been saved by the latest\n  ** savepoint, then save the current contents of the page into the \n  ** sub-journal now. This is required to handle the following scenario:\n  **\n  **   BEGIN;\n  **     <journal page X, then modify it in memory>\n  **     SAVEPOINT one;\n  **       <Move page X to location Y>\n  **     ROLLBACK TO one;\n  **\n  ** If page X were not written to the sub-journal here, it would not\n  ** be possible to restore its contents when the \"ROLLBACK TO one\"\n  ** statement were is processed.\n  **\n  ** subjournalPage() may need to allocate space to store pPg->pgno into\n  ** one or more savepoint bitvecs. This is the reason this function\n  ** may return SQLITE_NOMEM.\n  */\n  if( (pPg->flags & PGHDR_DIRTY)!=0\n   && SQLITE_OK!=(rc = subjournalPageIfRequired(pPg))\n  ){\n    return rc;\n  }\n\n  PAGERTRACE((\"MOVE %d page %d (needSync=%d) moves to %d\\n\", \n      PAGERID(pPager), pPg->pgno, (pPg->flags&PGHDR_NEED_SYNC)?1:0, pgno));\n  IOTRACE((\"MOVE %p %d %d\\n\", pPager, pPg->pgno, pgno))\n\n  /* If the journal needs to be sync()ed before page pPg->pgno can\n  ** be written to, store pPg->pgno in local variable needSyncPgno.\n  **\n  ** If the isCommit flag is set, there is no need to remember that\n  ** the journal needs to be sync()ed before database page pPg->pgno \n  ** can be written to. The caller has already promised not to write to it.\n  */\n  if( (pPg->flags&PGHDR_NEED_SYNC) && !isCommit ){\n    needSyncPgno = pPg->pgno;\n    assert( pPager->journalMode==PAGER_JOURNALMODE_OFF ||\n            pageInJournal(pPager, pPg) || pPg->pgno>pPager->dbOrigSize );\n    assert( pPg->flags&PGHDR_DIRTY );\n  }\n\n  /* If the cache contains a page with page-number pgno, remove it\n  ** from its hash chain. Also, if the PGHDR_NEED_SYNC flag was set for \n  ** page pgno before the 'move' operation, it needs to be retained \n  ** for the page moved there.\n  */\n  pPg->flags &= ~PGHDR_NEED_SYNC;\n  pPgOld = sqlite3PagerLookup(pPager, pgno);\n  assert( !pPgOld || pPgOld->nRef==1 );\n  if( pPgOld ){\n    pPg->flags |= (pPgOld->flags&PGHDR_NEED_SYNC);\n    if( pPager->tempFile ){\n      /* Do not discard pages from an in-memory database since we might\n      ** need to rollback later.  Just move the page out of the way. */\n      sqlite3PcacheMove(pPgOld, pPager->dbSize+1);\n    }else{\n      sqlite3PcacheDrop(pPgOld);\n    }\n  }\n\n  origPgno = pPg->pgno;\n  sqlite3PcacheMove(pPg, pgno);\n  sqlite3PcacheMakeDirty(pPg);\n\n  /* For an in-memory database, make sure the original page continues\n  ** to exist, in case the transaction needs to roll back.  Use pPgOld\n  ** as the original page since it has already been allocated.\n  */\n  if( pPager->tempFile && pPgOld ){\n    sqlite3PcacheMove(pPgOld, origPgno);\n    sqlite3PagerUnrefNotNull(pPgOld);\n  }\n\n  if( needSyncPgno ){\n    /* If needSyncPgno is non-zero, then the journal file needs to be \n    ** sync()ed before any data is written to database file page needSyncPgno.\n    ** Currently, no such page exists in the page-cache and the \n    ** \"is journaled\" bitvec flag has been set. This needs to be remedied by\n    ** loading the page into the pager-cache and setting the PGHDR_NEED_SYNC\n    ** flag.\n    **\n    ** If the attempt to load the page into the page-cache fails, (due\n    ** to a malloc() or IO failure), clear the bit in the pInJournal[]\n    ** array. Otherwise, if the page is loaded and written again in\n    ** this transaction, it may be written to the database file before\n    ** it is synced into the journal file. This way, it may end up in\n    ** the journal file twice, but that is not a problem.\n    */\n    PgHdr *pPgHdr;\n    rc = sqlite3PagerGet(pPager, needSyncPgno, &pPgHdr, 0);\n    if( rc!=SQLITE_OK ){\n      if( needSyncPgno<=pPager->dbOrigSize ){\n        assert( pPager->pTmpSpace!=0 );\n        sqlite3BitvecClear(pPager->pInJournal, needSyncPgno, pPager->pTmpSpace);\n      }\n      return rc;\n    }\n    pPgHdr->flags |= PGHDR_NEED_SYNC;\n    sqlite3PcacheMakeDirty(pPgHdr);\n    sqlite3PagerUnrefNotNull(pPgHdr);\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** The page handle passed as the first argument refers to a dirty page \n** with a page number other than iNew. This function changes the page's \n** page number to iNew and sets the value of the PgHdr.flags field to \n** the value passed as the third parameter.\n*/\nvoid sqlite3PagerRekey(DbPage *pPg, Pgno iNew, u16 flags){\n  assert( pPg->pgno!=iNew );\n  pPg->flags = flags;\n  sqlite3PcacheMove(pPg, iNew);\n}\n\n/*\n** Return a pointer to the data for the specified page.\n*/\nvoid *sqlite3PagerGetData(DbPage *pPg){\n  assert( pPg->nRef>0 || pPg->pPager->memDb );\n  return pPg->pData;\n}\n\n/*\n** Return a pointer to the Pager.nExtra bytes of \"extra\" space \n** allocated along with the specified page.\n*/\nvoid *sqlite3PagerGetExtra(DbPage *pPg){\n  return pPg->pExtra;\n}\n\n/*\n** Get/set the locking-mode for this pager. Parameter eMode must be one\n** of PAGER_LOCKINGMODE_QUERY, PAGER_LOCKINGMODE_NORMAL or \n** PAGER_LOCKINGMODE_EXCLUSIVE. If the parameter is not _QUERY, then\n** the locking-mode is set to the value specified.\n**\n** The returned value is either PAGER_LOCKINGMODE_NORMAL or\n** PAGER_LOCKINGMODE_EXCLUSIVE, indicating the current (possibly updated)\n** locking-mode.\n*/\nint sqlite3PagerLockingMode(Pager *pPager, int eMode){\n  assert( eMode==PAGER_LOCKINGMODE_QUERY\n            || eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n  assert( PAGER_LOCKINGMODE_QUERY<0 );\n  assert( PAGER_LOCKINGMODE_NORMAL>=0 && PAGER_LOCKINGMODE_EXCLUSIVE>=0 );\n  assert( pPager->exclusiveMode || 0==sqlite3WalHeapMemory(pPager->pWal) );\n  if( eMode>=0 && !pPager->tempFile && !sqlite3WalHeapMemory(pPager->pWal) ){\n    pPager->exclusiveMode = (u8)eMode;\n  }\n  return (int)pPager->exclusiveMode;\n}\n\n/*\n** Set the journal-mode for this pager. Parameter eMode must be one of:\n**\n**    PAGER_JOURNALMODE_DELETE\n**    PAGER_JOURNALMODE_TRUNCATE\n**    PAGER_JOURNALMODE_PERSIST\n**    PAGER_JOURNALMODE_OFF\n**    PAGER_JOURNALMODE_MEMORY\n**    PAGER_JOURNALMODE_WAL\n**\n** The journalmode is set to the value specified if the change is allowed.\n** The change may be disallowed for the following reasons:\n**\n**   *  An in-memory database can only have its journal_mode set to _OFF\n**      or _MEMORY.\n**\n**   *  Temporary databases cannot have _WAL journalmode.\n**\n** The returned indicate the current (possibly updated) journal-mode.\n*/\nint sqlite3PagerSetJournalMode(Pager *pPager, int eMode){\n  u8 eOld = pPager->journalMode;    /* Prior journalmode */\n\n#ifdef SQLITE_DEBUG\n  /* The print_pager_state() routine is intended to be used by the debugger\n  ** only.  We invoke it once here to suppress a compiler warning. */\n  print_pager_state(pPager);\n#endif\n\n\n  /* The eMode parameter is always valid */\n  assert(      eMode==PAGER_JOURNALMODE_DELETE\n            || eMode==PAGER_JOURNALMODE_TRUNCATE\n            || eMode==PAGER_JOURNALMODE_PERSIST\n            || eMode==PAGER_JOURNALMODE_OFF \n            || eMode==PAGER_JOURNALMODE_WAL \n            || eMode==PAGER_JOURNALMODE_MEMORY );\n\n  /* This routine is only called from the OP_JournalMode opcode, and\n  ** the logic there will never allow a temporary file to be changed\n  ** to WAL mode.\n  */\n  assert( pPager->tempFile==0 || eMode!=PAGER_JOURNALMODE_WAL );\n\n  /* Do allow the journalmode of an in-memory database to be set to\n  ** anything other than MEMORY or OFF\n  */\n  if( MEMDB ){\n    assert( eOld==PAGER_JOURNALMODE_MEMORY || eOld==PAGER_JOURNALMODE_OFF );\n    if( eMode!=PAGER_JOURNALMODE_MEMORY && eMode!=PAGER_JOURNALMODE_OFF ){\n      eMode = eOld;\n    }\n  }\n\n  if( eMode!=eOld ){\n\n    /* Change the journal mode. */\n    assert( pPager->eState!=PAGER_ERROR );\n    pPager->journalMode = (u8)eMode;\n\n    /* When transistioning from TRUNCATE or PERSIST to any other journal\n    ** mode except WAL, unless the pager is in locking_mode=exclusive mode,\n    ** delete the journal file.\n    */\n    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );\n    assert( (PAGER_JOURNALMODE_PERSIST & 5)==1 );\n    assert( (PAGER_JOURNALMODE_DELETE & 5)==0 );\n    assert( (PAGER_JOURNALMODE_MEMORY & 5)==4 );\n    assert( (PAGER_JOURNALMODE_OFF & 5)==0 );\n    assert( (PAGER_JOURNALMODE_WAL & 5)==5 );\n\n    assert( isOpen(pPager->fd) || pPager->exclusiveMode );\n    if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){\n\n      /* In this case we would like to delete the journal file. If it is\n      ** not possible, then that is not a problem. Deleting the journal file\n      ** here is an optimization only.\n      **\n      ** Before deleting the journal file, obtain a RESERVED lock on the\n      ** database file. This ensures that the journal file is not deleted\n      ** while it is in use by some other client.\n      */\n      sqlite3OsClose(pPager->jfd);\n      if( pPager->eLock>=RESERVED_LOCK ){\n        sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n      }else{\n        int rc = SQLITE_OK;\n        int state = pPager->eState;\n        assert( state==PAGER_OPEN || state==PAGER_READER );\n        if( state==PAGER_OPEN ){\n          rc = sqlite3PagerSharedLock(pPager);\n        }\n        if( pPager->eState==PAGER_READER ){\n          assert( rc==SQLITE_OK );\n          rc = pagerLockDb(pPager, RESERVED_LOCK);\n        }\n        if( rc==SQLITE_OK ){\n          sqlite3OsDelete(pPager->pVfs, pPager->zJournal, 0);\n        }\n        if( rc==SQLITE_OK && state==PAGER_READER ){\n          pagerUnlockDb(pPager, SHARED_LOCK);\n        }else if( state==PAGER_OPEN ){\n          pager_unlock(pPager);\n        }\n        assert( state==pPager->eState );\n      }\n    }else if( eMode==PAGER_JOURNALMODE_OFF ){\n      sqlite3OsClose(pPager->jfd);\n    }\n  }\n\n  /* Return the new journal mode */\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return the current journal mode.\n*/\nint sqlite3PagerGetJournalMode(Pager *pPager){\n  return (int)pPager->journalMode;\n}\n\n/*\n** Return TRUE if the pager is in a state where it is OK to change the\n** journalmode.  Journalmode changes can only happen when the database\n** is unmodified.\n*/\nint sqlite3PagerOkToChangeJournalMode(Pager *pPager){\n  assert( assert_pager_state(pPager) );\n  if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;\n  if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;\n  return 1;\n}\n\n/*\n** Get/set the size-limit used for persistent journal files.\n**\n** Setting the size limit to -1 means no limit is enforced.\n** An attempt to set a limit smaller than -1 is a no-op.\n*/\ni64 sqlite3PagerJournalSizeLimit(Pager *pPager, i64 iLimit){\n  if( iLimit>=-1 ){\n    pPager->journalSizeLimit = iLimit;\n    sqlite3WalLimit(pPager->pWal, iLimit);\n  }\n  return pPager->journalSizeLimit;\n}\n\n/*\n** Return a pointer to the pPager->pBackup variable. The backup module\n** in backup.c maintains the content of this variable. This module\n** uses it opaquely as an argument to sqlite3BackupRestart() and\n** sqlite3BackupUpdate() only.\n*/\nsqlite3_backup **sqlite3PagerBackupPtr(Pager *pPager){\n  return &pPager->pBackup;\n}\n\n#ifndef SQLITE_OMIT_VACUUM\n/*\n** Unless this is an in-memory or temporary database, clear the pager cache.\n*/\nvoid sqlite3PagerClearCache(Pager *pPager){\n  assert( MEMDB==0 || pPager->tempFile );\n  if( pPager->tempFile==0 ) pager_reset(pPager);\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_WAL\n/*\n** This function is called when the user invokes \"PRAGMA wal_checkpoint\",\n** \"PRAGMA wal_blocking_checkpoint\" or calls the sqlite3_wal_checkpoint()\n** or wal_blocking_checkpoint() API functions.\n**\n** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.\n*/\nint sqlite3PagerCheckpoint(\n  Pager *pPager,                  /* Checkpoint on this pager */\n  sqlite3 *db,                    /* Db handle used to check for interrupts */\n  int eMode,                      /* Type of checkpoint */\n  int *pnLog,                     /* OUT: Final number of frames in log */\n  int *pnCkpt                     /* OUT: Final number of checkpointed frames */\n){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,\n        (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),\n        pPager->pBusyHandlerArg,\n        pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,\n        pnLog, pnCkpt\n    );\n  }\n  return rc;\n}\n\nint sqlite3PagerWalCallback(Pager *pPager){\n  return sqlite3WalCallback(pPager->pWal);\n}\n\n/*\n** Return true if the underlying VFS for the given pager supports the\n** primitives necessary for write-ahead logging.\n*/\nint sqlite3PagerWalSupported(Pager *pPager){\n  const sqlite3_io_methods *pMethods = pPager->fd->pMethods;\n  if( pPager->noLock ) return 0;\n  return pPager->exclusiveMode || (pMethods->iVersion>=2 && pMethods->xShmMap);\n}\n\n/*\n** Attempt to take an exclusive lock on the database file. If a PENDING lock\n** is obtained instead, immediately release it.\n*/\nstatic int pagerExclusiveLock(Pager *pPager){\n  int rc;                         /* Return code */\n\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n  rc = pagerLockDb(pPager, EXCLUSIVE_LOCK);\n  if( rc!=SQLITE_OK ){\n    /* If the attempt to grab the exclusive lock failed, release the \n    ** pending lock that may have been obtained instead.  */\n    pagerUnlockDb(pPager, SHARED_LOCK);\n  }\n\n  return rc;\n}\n\n/*\n** Call sqlite3WalOpen() to open the WAL handle. If the pager is in \n** exclusive-locking mode when this function is called, take an EXCLUSIVE\n** lock on the database file and use heap-memory to store the wal-index\n** in. Otherwise, use the normal shared-memory.\n*/\nstatic int pagerOpenWal(Pager *pPager){\n  int rc = SQLITE_OK;\n\n  assert( pPager->pWal==0 && pPager->tempFile==0 );\n  assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK );\n\n  /* If the pager is already in exclusive-mode, the WAL module will use \n  ** heap-memory for the wal-index instead of the VFS shared-memory \n  ** implementation. Take the exclusive lock now, before opening the WAL\n  ** file, to make sure this is safe.\n  */\n  if( pPager->exclusiveMode ){\n    rc = pagerExclusiveLock(pPager);\n  }\n\n  /* Open the connection to the log file. If this operation fails, \n  ** (e.g. due to malloc() failure), return an error code.\n  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3WalOpen(pPager->pVfs,\n        pPager->fd, pPager->zWal, pPager->exclusiveMode,\n        pPager->journalSizeLimit, &pPager->pWal\n    );\n  }\n  pagerFixMaplimit(pPager);\n\n  return rc;\n}\n\n\n/*\n** The caller must be holding a SHARED lock on the database file to call\n** this function.\n**\n** If the pager passed as the first argument is open on a real database\n** file (not a temp file or an in-memory database), and the WAL file\n** is not already open, make an attempt to open it now. If successful,\n** return SQLITE_OK. If an error occurs or the VFS used by the pager does \n** not support the xShmXXX() methods, return an error code. *pbOpen is\n** not modified in either case.\n**\n** If the pager is open on a temp-file (or in-memory database), or if\n** the WAL file is already open, set *pbOpen to 1 and return SQLITE_OK\n** without doing anything.\n*/\nint sqlite3PagerOpenWal(\n  Pager *pPager,                  /* Pager object */\n  int *pbOpen                     /* OUT: Set to true if call is a no-op */\n){\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( assert_pager_state(pPager) );\n  assert( pPager->eState==PAGER_OPEN   || pbOpen );\n  assert( pPager->eState==PAGER_READER || !pbOpen );\n  assert( pbOpen==0 || *pbOpen==0 );\n  assert( pbOpen!=0 || (!pPager->tempFile && !pPager->pWal) );\n\n  if( !pPager->tempFile && !pPager->pWal ){\n    if( !sqlite3PagerWalSupported(pPager) ) return SQLITE_CANTOPEN;\n\n    /* Close any rollback journal previously open */\n    sqlite3OsClose(pPager->jfd);\n\n    rc = pagerOpenWal(pPager);\n    if( rc==SQLITE_OK ){\n      pPager->journalMode = PAGER_JOURNALMODE_WAL;\n      pPager->eState = PAGER_OPEN;\n    }\n  }else{\n    *pbOpen = 1;\n  }\n\n  return rc;\n}\n\n/*\n** This function is called to close the connection to the log file prior\n** to switching from WAL to rollback mode.\n**\n** Before closing the log file, this function attempts to take an \n** EXCLUSIVE lock on the database file. If this cannot be obtained, an\n** error (SQLITE_BUSY) is returned and the log connection is not closed.\n** If successful, the EXCLUSIVE lock is not released before returning.\n*/\nint sqlite3PagerCloseWal(Pager *pPager, sqlite3 *db){\n  int rc = SQLITE_OK;\n\n  assert( pPager->journalMode==PAGER_JOURNALMODE_WAL );\n\n  /* If the log file is not already open, but does exist in the file-system,\n  ** it may need to be checkpointed before the connection can switch to\n  ** rollback mode. Open it now so this can happen.\n  */\n  if( !pPager->pWal ){\n    int logexists = 0;\n    rc = pagerLockDb(pPager, SHARED_LOCK);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3OsAccess(\n          pPager->pVfs, pPager->zWal, SQLITE_ACCESS_EXISTS, &logexists\n      );\n    }\n    if( rc==SQLITE_OK && logexists ){\n      rc = pagerOpenWal(pPager);\n    }\n  }\n    \n  /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on\n  ** the database file, the log and log-summary files will be deleted.\n  */\n  if( rc==SQLITE_OK && pPager->pWal ){\n    rc = pagerExclusiveLock(pPager);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags,\n                           pPager->pageSize, (u8*)pPager->pTmpSpace);\n      pPager->pWal = 0;\n      pagerFixMaplimit(pPager);\n      if( rc && !pPager->exclusiveMode ) pagerUnlockDb(pPager, SHARED_LOCK);\n    }\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** If this is a WAL database, obtain a snapshot handle for the snapshot\n** currently open. Otherwise, return an error.\n*/\nint sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_ERROR;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotGet(pPager->pWal, ppSnapshot);\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, store a pointer to pSnapshot. Next time a\n** read transaction is opened, attempt to read from the snapshot it \n** identifies. If this is not a WAL database, return an error.\n*/\nint sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot){\n  int rc = SQLITE_OK;\n  if( pPager->pWal ){\n    sqlite3WalSnapshotOpen(pPager->pWal, pSnapshot);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n\n/*\n** If this is a WAL database, call sqlite3WalSnapshotRecover(). If this \n** is not a WAL database, return an error.\n*/\nint sqlite3PagerSnapshotRecover(Pager *pPager){\n  int rc;\n  if( pPager->pWal ){\n    rc = sqlite3WalSnapshotRecover(pPager->pWal);\n  }else{\n    rc = SQLITE_ERROR;\n  }\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n#endif /* !SQLITE_OMIT_WAL */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** A read-lock must be held on the pager when this function is called. If\n** the pager is in WAL mode and the WAL file currently contains one or more\n** frames, return the size in bytes of the page images stored within the\n** WAL frames. Otherwise, if this is not a WAL database or the WAL file\n** is empty, return 0.\n*/\nint sqlite3PagerWalFramesize(Pager *pPager){\n  assert( pPager->eState>=PAGER_READER );\n  return sqlite3WalFramesize(pPager->pWal);\n}\n#endif\n\n#endif /* SQLITE_OMIT_DISKIO */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pager.h",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem.  The page cache subsystem reads and writes a file a page\n** at a time and provides a journal for rollback.\n*/\n\n#ifndef SQLITE_PAGER_H\n#define SQLITE_PAGER_H\n\n/*\n** Default maximum size for persistent journal files. A negative \n** value means no limit. This value may be overridden using the \n** sqlite3PagerJournalSizeLimit() API. See also \"PRAGMA journal_size_limit\".\n*/\n#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT\n  #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1\n#endif\n\n/*\n** The type used to represent a page number.  The first page in a file\n** is called page 1.  0 is used to represent \"not a page\".\n*/\ntypedef u32 Pgno;\n\n/*\n** Each open file is managed by a separate instance of the \"Pager\" structure.\n*/\ntypedef struct Pager Pager;\n\n/*\n** Handle type for pages.\n*/\ntypedef struct PgHdr DbPage;\n\n/*\n** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is\n** reserved for working around a windows/posix incompatibility). It is\n** used in the journal to signify that the remainder of the journal file \n** is devoted to storing a master journal name - there are no more pages to\n** roll back. See comments for function writeMasterJournal() in pager.c \n** for details.\n*/\n#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))\n\n/*\n** Allowed values for the flags parameter to sqlite3PagerOpen().\n**\n** NOTE: These values must match the corresponding BTREE_ values in btree.h.\n*/\n#define PAGER_OMIT_JOURNAL  0x0001    /* Do not use a rollback journal */\n#define PAGER_MEMORY        0x0002    /* In-memory database */\n\n/*\n** Valid values for the second argument to sqlite3PagerLockingMode().\n*/\n#define PAGER_LOCKINGMODE_QUERY      -1\n#define PAGER_LOCKINGMODE_NORMAL      0\n#define PAGER_LOCKINGMODE_EXCLUSIVE   1\n\n/*\n** Numeric constants that encode the journalmode.\n**\n** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)\n** are exposed in the API via the \"PRAGMA journal_mode\" command and\n** therefore cannot be changed without a compatibility break.\n*/\n#define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */\n#define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */\n#define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */\n#define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */\n#define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */\n#define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */\n#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */\n\n/*\n** Flags that make up the mask passed to sqlite3PagerGet().\n*/\n#define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */\n#define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */\n\n/*\n** Flags for sqlite3PagerSetFlags()\n**\n** Value constraints (enforced via assert()):\n**    PAGER_FULLFSYNC      == SQLITE_FullFSync\n**    PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync\n**    PAGER_CACHE_SPILL    == SQLITE_CacheSpill\n*/\n#define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */\n#define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */\n#define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */\n#define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */\n#define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */\n#define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */\n#define PAGER_CKPT_FULLFSYNC        0x10  /* PRAGMA checkpoint_fullfsync=ON */\n#define PAGER_CACHESPILL            0x20  /* PRAGMA cache_spill=ON */\n#define PAGER_FLAGS_MASK            0x38  /* All above except SYNCHRONOUS */\n\n/*\n** The remainder of this file contains the declarations of the functions\n** that make up the Pager sub-system API. See source code comments for \n** a detailed description of each routine.\n*/\n\n/* Open and close a Pager connection. */ \nint sqlite3PagerOpen(\n  sqlite3_vfs*,\n  Pager **ppPager,\n  const char*,\n  int,\n  int,\n  int,\n  void(*)(DbPage*)\n);\nint sqlite3PagerClose(Pager *pPager, sqlite3*);\nint sqlite3PagerReadFileheader(Pager*, int, unsigned char*);\n\n/* Functions used to configure a Pager object. */\nvoid sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);\nint sqlite3PagerSetPagesize(Pager*, u32*, int);\n#ifdef SQLITE_HAS_CODEC\nvoid sqlite3PagerAlignReserve(Pager*,Pager*);\n#endif\nint sqlite3PagerMaxPageCount(Pager*, int);\nvoid sqlite3PagerSetCachesize(Pager*, int);\nint sqlite3PagerSetSpillsize(Pager*, int);\nvoid sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);\nvoid sqlite3PagerShrink(Pager*);\nvoid sqlite3PagerSetFlags(Pager*,unsigned);\nint sqlite3PagerLockingMode(Pager *, int);\nint sqlite3PagerSetJournalMode(Pager *, int);\nint sqlite3PagerGetJournalMode(Pager*);\nint sqlite3PagerOkToChangeJournalMode(Pager*);\ni64 sqlite3PagerJournalSizeLimit(Pager *, i64);\nsqlite3_backup **sqlite3PagerBackupPtr(Pager*);\nint sqlite3PagerFlush(Pager*);\n\n/* Functions used to obtain and release page references. */ \nint sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);\nDbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);\nvoid sqlite3PagerRef(DbPage*);\nvoid sqlite3PagerUnref(DbPage*);\nvoid sqlite3PagerUnrefNotNull(DbPage*);\nvoid sqlite3PagerUnrefPageOne(DbPage*);\n\n/* Operations on page references. */\nint sqlite3PagerWrite(DbPage*);\nvoid sqlite3PagerDontWrite(DbPage*);\nint sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);\nint sqlite3PagerPageRefcount(DbPage*);\nvoid *sqlite3PagerGetData(DbPage *); \nvoid *sqlite3PagerGetExtra(DbPage *); \n\n/* Functions used to manage pager transactions and savepoints. */\nvoid sqlite3PagerPagecount(Pager*, int*);\nint sqlite3PagerBegin(Pager*, int exFlag, int);\nint sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);\nint sqlite3PagerExclusiveLock(Pager*);\nint sqlite3PagerSync(Pager *pPager, const char *zMaster);\nint sqlite3PagerCommitPhaseTwo(Pager*);\nint sqlite3PagerRollback(Pager*);\nint sqlite3PagerOpenSavepoint(Pager *pPager, int n);\nint sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);\nint sqlite3PagerSharedLock(Pager *pPager);\n\n#ifndef SQLITE_OMIT_WAL\n  int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);\n  int sqlite3PagerWalSupported(Pager *pPager);\n  int sqlite3PagerWalCallback(Pager *pPager);\n  int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);\n  int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);\n# ifdef SQLITE_DIRECT_OVERFLOW_READ\n  int sqlite3PagerUseWal(Pager *pPager, Pgno);\n# endif\n# ifdef SQLITE_ENABLE_SNAPSHOT\n  int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);\n  int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);\n  int sqlite3PagerSnapshotRecover(Pager *pPager);\n# endif\n#else\n# define sqlite3PagerUseWal(x,y) 0\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n  int sqlite3PagerWalFramesize(Pager *pPager);\n#endif\n\n/* Functions used to query pager state and configuration. */\nu8 sqlite3PagerIsreadonly(Pager*);\nu32 sqlite3PagerDataVersion(Pager*);\n#ifdef SQLITE_DEBUG\n  int sqlite3PagerRefcount(Pager*);\n#endif\nint sqlite3PagerMemUsed(Pager*);\nconst char *sqlite3PagerFilename(Pager*, int);\nsqlite3_vfs *sqlite3PagerVfs(Pager*);\nsqlite3_file *sqlite3PagerFile(Pager*);\nsqlite3_file *sqlite3PagerJrnlFile(Pager*);\nconst char *sqlite3PagerJournalname(Pager*);\nvoid *sqlite3PagerTempSpace(Pager*);\nint sqlite3PagerIsMemdb(Pager*);\nvoid sqlite3PagerCacheStat(Pager *, int, int, int *);\nvoid sqlite3PagerClearCache(Pager*);\nint sqlite3SectorSize(sqlite3_file *);\n\n/* Functions used to truncate the database file. */\nvoid sqlite3PagerTruncateImage(Pager*,Pgno);\n\nvoid sqlite3PagerRekey(DbPage*, Pgno, u16);\n\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)\nvoid *sqlite3PagerCodec(DbPage *);\n#endif\n\n/* Functions to support testing and debugging. */\n#if !defined(NDEBUG) || defined(SQLITE_TEST)\n  Pgno sqlite3PagerPagenumber(DbPage*);\n  int sqlite3PagerIswriteable(DbPage*);\n#endif\n#ifdef SQLITE_TEST\n  int *sqlite3PagerStats(Pager*);\n  void sqlite3PagerRefdump(Pager*);\n  void disable_simulated_io_errors(void);\n  void enable_simulated_io_errors(void);\n#else\n# define disable_simulated_io_errors()\n# define enable_simulated_io_errors()\n#endif\n\n#endif /* SQLITE_PAGER_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/parse.h",
    "content": "/************** Begin file parse.h *******************************************/\n#define TK_SEMI                             1\n#define TK_EXPLAIN                          2\n#define TK_QUERY                            3\n#define TK_PLAN                             4\n#define TK_BEGIN                            5\n#define TK_TRANSACTION                      6\n#define TK_DEFERRED                         7\n#define TK_IMMEDIATE                        8\n#define TK_EXCLUSIVE                        9\n#define TK_COMMIT                          10\n#define TK_END                             11\n#define TK_ROLLBACK                        12\n#define TK_SAVEPOINT                       13\n#define TK_RELEASE                         14\n#define TK_TO                              15\n#define TK_TABLE                           16\n#define TK_CREATE                          17\n#define TK_IF                              18\n#define TK_NOT                             19\n#define TK_EXISTS                          20\n#define TK_TEMP                            21\n#define TK_LP                              22\n#define TK_RP                              23\n#define TK_AS                              24\n#define TK_WITHOUT                         25\n#define TK_COMMA                           26\n#define TK_ABORT                           27\n#define TK_ACTION                          28\n#define TK_AFTER                           29\n#define TK_ANALYZE                         30\n#define TK_ASC                             31\n#define TK_ATTACH                          32\n#define TK_BEFORE                          33\n#define TK_BY                              34\n#define TK_CASCADE                         35\n#define TK_CAST                            36\n#define TK_CONFLICT                        37\n#define TK_DATABASE                        38\n#define TK_DESC                            39\n#define TK_DETACH                          40\n#define TK_EACH                            41\n#define TK_FAIL                            42\n#define TK_OR                              43\n#define TK_AND                             44\n#define TK_IS                              45\n#define TK_MATCH                           46\n#define TK_LIKE_KW                         47\n#define TK_BETWEEN                         48\n#define TK_IN                              49\n#define TK_ISNULL                          50\n#define TK_NOTNULL                         51\n#define TK_NE                              52\n#define TK_EQ                              53\n#define TK_GT                              54\n#define TK_LE                              55\n#define TK_LT                              56\n#define TK_GE                              57\n#define TK_ESCAPE                          58\n#define TK_ID                              59\n#define TK_COLUMNKW                        60\n#define TK_FOR                             61\n#define TK_IGNORE                          62\n#define TK_INITIALLY                       63\n#define TK_INSTEAD                         64\n#define TK_NO                              65\n#define TK_KEY                             66\n#define TK_OF                              67\n#define TK_OFFSET                          68\n#define TK_PRAGMA                          69\n#define TK_RAISE                           70\n#define TK_RECURSIVE                       71\n#define TK_REPLACE                         72\n#define TK_RESTRICT                        73\n#define TK_ROW                             74\n#define TK_TRIGGER                         75\n#define TK_VACUUM                          76\n#define TK_VIEW                            77\n#define TK_VIRTUAL                         78\n#define TK_WITH                            79\n#define TK_REINDEX                         80\n#define TK_RENAME                          81\n#define TK_CTIME_KW                        82\n#define TK_ANY                             83\n#define TK_BITAND                          84\n#define TK_BITOR                           85\n#define TK_LSHIFT                          86\n#define TK_RSHIFT                          87\n#define TK_PLUS                            88\n#define TK_MINUS                           89\n#define TK_STAR                            90\n#define TK_SLASH                           91\n#define TK_REM                             92\n#define TK_CONCAT                          93\n#define TK_COLLATE                         94\n#define TK_BITNOT                          95\n#define TK_INDEXED                         96\n#define TK_STRING                          97\n#define TK_JOIN_KW                         98\n#define TK_CONSTRAINT                      99\n#define TK_DEFAULT                        100\n#define TK_NULL                           101\n#define TK_PRIMARY                        102\n#define TK_UNIQUE                         103\n#define TK_CHECK                          104\n#define TK_REFERENCES                     105\n#define TK_AUTOINCR                       106\n#define TK_ON                             107\n#define TK_INSERT                         108\n#define TK_DELETE                         109\n#define TK_UPDATE                         110\n#define TK_SET                            111\n#define TK_DEFERRABLE                     112\n#define TK_FOREIGN                        113\n#define TK_DROP                           114\n#define TK_UNION                          115\n#define TK_ALL                            116\n#define TK_EXCEPT                         117\n#define TK_INTERSECT                      118\n#define TK_SELECT                         119\n#define TK_VALUES                         120\n#define TK_DISTINCT                       121\n#define TK_DOT                            122\n#define TK_FROM                           123\n#define TK_JOIN                           124\n#define TK_USING                          125\n#define TK_ORDER                          126\n#define TK_GROUP                          127\n#define TK_HAVING                         128\n#define TK_LIMIT                          129\n#define TK_WHERE                          130\n#define TK_INTO                           131\n#define TK_FLOAT                          132\n#define TK_BLOB                           133\n#define TK_INTEGER                        134\n#define TK_VARIABLE                       135\n#define TK_CASE                           136\n#define TK_WHEN                           137\n#define TK_THEN                           138\n#define TK_ELSE                           139\n#define TK_INDEX                          140\n#define TK_ALTER                          141\n#define TK_ADD                            142\n#define TK_ISNOT                          143\n#define TK_FUNCTION                       144\n#define TK_COLUMN                         145\n#define TK_AGG_FUNCTION                   146\n#define TK_AGG_COLUMN                     147\n#define TK_UMINUS                         148\n#define TK_UPLUS                          149\n#define TK_REGISTER                       150\n#define TK_VECTOR                         151\n#define TK_SELECT_COLUMN                  152\n#define TK_IF_NULL_ROW                    153\n#define TK_ASTERISK                       154\n#define TK_SPAN                           155\n#define TK_END_OF_FILE                    156\n#define TK_UNCLOSED_STRING                157\n#define TK_SPACE                          158\n#define TK_ILLEGAL                        159\n\n/* The token codes above must all fit in 8 bits */\n#define TKFLG_MASK           0xff  \n\n/* Flags that can be added to a token code when it is not\n** being stored in a u8: */\n#define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */\n\n/************** End of parse.h ***********************************************/\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/parse.y",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains SQLite's grammar for SQL.  Process this file\n** using the lemon parser generator to generate C code that runs\n** the parser.  Lemon will also generate a header file containing\n** numeric codes for all of the tokens.\n*/\n\n// All token codes are small integers with #defines that begin with \"TK_\"\n%token_prefix TK_\n\n// The type of the data attached to each token is Token.  This is also the\n// default type for non-terminals.\n//\n%token_type {Token}\n%default_type {Token}\n\n// The generated parser function takes a 4th argument as follows:\n%extra_argument {Parse *pParse}\n\n// This code runs whenever there is a syntax error\n//\n%syntax_error {\n  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */\n  assert( TOKEN.z[0] );  /* The tokenizer always gives us a token */\n  sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &TOKEN);\n}\n%stack_overflow {\n  sqlite3ErrorMsg(pParse, \"parser stack overflow\");\n}\n\n// The name of the generated procedure that implements the parser\n// is as follows:\n%name sqlite3Parser\n\n// The following text is included near the beginning of the C source\n// code file that implements the parser.\n//\n%include {\n#include \"sqliteInt.h\"\n\n/*\n** Disable all error recovery processing in the parser push-down\n** automaton.\n*/\n#define YYNOERRORRECOVERY 1\n\n/*\n** Make yytestcase() the same as testcase()\n*/\n#define yytestcase(X) testcase(X)\n\n/*\n** Indicate that sqlite3ParserFree() will never be called with a null\n** pointer.\n*/\n#define YYPARSEFREENEVERNULL 1\n\n/*\n** In the amalgamation, the parse.c file generated by lemon and the\n** tokenize.c file are concatenated.  In that case, sqlite3RunParser()\n** has access to the the size of the yyParser object and so the parser\n** engine can be allocated from stack.  In that case, only the\n** sqlite3ParserInit() and sqlite3ParserFinalize() routines are invoked\n** and the sqlite3ParserAlloc() and sqlite3ParserFree() routines can be\n** omitted.\n*/\n#ifdef SQLITE_AMALGAMATION\n# define sqlite3Parser_ENGINEALWAYSONSTACK 1\n#endif\n\n/*\n** Alternative datatype for the argument to the malloc() routine passed\n** into sqlite3ParserAlloc().  The default is size_t.\n*/\n#define YYMALLOCARGTYPE  u64\n\n/*\n** An instance of this structure holds information about the\n** LIMIT clause of a SELECT statement.\n*/\nstruct LimitVal {\n  Expr *pLimit;    /* The LIMIT expression.  NULL if there is no limit */\n  Expr *pOffset;   /* The OFFSET expression.  NULL if there is none */\n};\n\n/*\n** An instance of the following structure describes the event of a\n** TRIGGER.  \"a\" is the event type, one of TK_UPDATE, TK_INSERT,\n** TK_DELETE, or TK_INSTEAD.  If the event is of the form\n**\n**      UPDATE ON (a,b,c)\n**\n** Then the \"b\" IdList records the list \"a,b,c\".\n*/\nstruct TrigEvent { int a; IdList * b; };\n\n/*\n** Disable lookaside memory allocation for objects that might be\n** shared across database connections.\n*/\nstatic void disableLookaside(Parse *pParse){\n  pParse->disableLookaside++;\n  pParse->db->lookaside.bDisable++;\n}\n\n} // end %include\n\n// Input is a single SQL command\ninput ::= cmdlist.\ncmdlist ::= cmdlist ecmd.\ncmdlist ::= ecmd.\necmd ::= SEMI.\necmd ::= explain cmdx SEMI.\nexplain ::= .\n%ifndef SQLITE_OMIT_EXPLAIN\nexplain ::= EXPLAIN.              { pParse->explain = 1; }\nexplain ::= EXPLAIN QUERY PLAN.   { pParse->explain = 2; }\n%endif  SQLITE_OMIT_EXPLAIN\ncmdx ::= cmd.           { sqlite3FinishCoding(pParse); }\n\n///////////////////// Begin and end transactions. ////////////////////////////\n//\n\ncmd ::= BEGIN transtype(Y) trans_opt.  {sqlite3BeginTransaction(pParse, Y);}\ntrans_opt ::= .\ntrans_opt ::= TRANSACTION.\ntrans_opt ::= TRANSACTION nm.\n%type transtype {int}\ntranstype(A) ::= .             {A = TK_DEFERRED;}\ntranstype(A) ::= DEFERRED(X).  {A = @X; /*A-overwrites-X*/}\ntranstype(A) ::= IMMEDIATE(X). {A = @X; /*A-overwrites-X*/}\ntranstype(A) ::= EXCLUSIVE(X). {A = @X; /*A-overwrites-X*/}\ncmd ::= COMMIT|END(X) trans_opt.   {sqlite3EndTransaction(pParse,@X);}\ncmd ::= ROLLBACK(X) trans_opt.     {sqlite3EndTransaction(pParse,@X);}\n\nsavepoint_opt ::= SAVEPOINT.\nsavepoint_opt ::= .\ncmd ::= SAVEPOINT nm(X). {\n  sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &X);\n}\ncmd ::= RELEASE savepoint_opt nm(X). {\n  sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &X);\n}\ncmd ::= ROLLBACK trans_opt TO savepoint_opt nm(X). {\n  sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &X);\n}\n\n///////////////////// The CREATE TABLE statement ////////////////////////////\n//\ncmd ::= create_table create_table_args.\ncreate_table ::= createkw temp(T) TABLE ifnotexists(E) nm(Y) dbnm(Z). {\n   sqlite3StartTable(pParse,&Y,&Z,T,0,0,E);\n}\ncreatekw(A) ::= CREATE(A).  {disableLookaside(pParse);}\n\n%type ifnotexists {int}\nifnotexists(A) ::= .              {A = 0;}\nifnotexists(A) ::= IF NOT EXISTS. {A = 1;}\n%type temp {int}\n%ifndef SQLITE_OMIT_TEMPDB\ntemp(A) ::= TEMP.  {A = 1;}\n%endif  SQLITE_OMIT_TEMPDB\ntemp(A) ::= .      {A = 0;}\ncreate_table_args ::= LP columnlist conslist_opt(X) RP(E) table_options(F). {\n  sqlite3EndTable(pParse,&X,&E,F,0);\n}\ncreate_table_args ::= AS select(S). {\n  sqlite3EndTable(pParse,0,0,0,S);\n  sqlite3SelectDelete(pParse->db, S);\n}\n%type table_options {int}\ntable_options(A) ::= .    {A = 0;}\ntable_options(A) ::= WITHOUT nm(X). {\n  if( X.n==5 && sqlite3_strnicmp(X.z,\"rowid\",5)==0 ){\n    A = TF_WithoutRowid | TF_NoVisibleRowid;\n  }else{\n    A = 0;\n    sqlite3ErrorMsg(pParse, \"unknown table option: %.*s\", X.n, X.z);\n  }\n}\ncolumnlist ::= columnlist COMMA columnname carglist.\ncolumnlist ::= columnname carglist.\ncolumnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,&A,&Y);}\n\n// Declare some tokens early in order to influence their values, to \n// improve performance and reduce the executable size.  The goal here is\n// to get the \"jump\" operations in ISNULL through ESCAPE to have numeric\n// values that are early enough so that all jump operations are clustered\n// at the beginning, but also so that the comparison tokens NE through GE\n// are as large as possible so that they are near to FUNCTION, which is a\n// token synthesized by addopcodes.tcl.\n//\n%token ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST.\n%token CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL.\n%token OR AND NOT IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ.\n%token GT LE LT GE ESCAPE.\n\n// The following directive causes tokens ABORT, AFTER, ASC, etc. to\n// fallback to ID if they will not parse as their original value.\n// This obviates the need for the \"id\" nonterminal.\n//\n%fallback ID\n  ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST COLUMNKW\n  CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR\n  IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH NO PLAN\n  QUERY KEY OF OFFSET PRAGMA RAISE RECURSIVE RELEASE REPLACE RESTRICT ROW\n  ROLLBACK SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL WITH WITHOUT\n%ifdef SQLITE_OMIT_COMPOUND_SELECT\n  EXCEPT INTERSECT UNION\n%endif SQLITE_OMIT_COMPOUND_SELECT\n  REINDEX RENAME CTIME_KW IF\n  .\n%wildcard ANY.\n\n// Define operator precedence early so that this is the first occurrence\n// of the operator tokens in the grammer.  Keeping the operators together\n// causes them to be assigned integer values that are close together,\n// which keeps parser tables smaller.\n//\n// The token values assigned to these symbols is determined by the order\n// in which lemon first sees them.  It must be the case that ISNULL/NOTNULL,\n// NE/EQ, GT/LE, and GE/LT are separated by only a single value.  See\n// the sqlite3ExprIfFalse() routine for additional information on this\n// constraint.\n//\n%left OR.\n%left AND.\n%right NOT.\n%left IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ.\n%left GT LE LT GE.\n%right ESCAPE.\n%left BITAND BITOR LSHIFT RSHIFT.\n%left PLUS MINUS.\n%left STAR SLASH REM.\n%left CONCAT.\n%left COLLATE.\n%right BITNOT.\n\n// An IDENTIFIER can be a generic identifier, or one of several\n// keywords.  Any non-standard keyword can also be an identifier.\n//\n%token_class id  ID|INDEXED.\n\n\n// And \"ids\" is an identifer-or-string.\n//\n%token_class ids  ID|STRING.\n\n// The name of a column or table can be any of the following:\n//\n%type nm {Token}\nnm(A) ::= id(A).\nnm(A) ::= STRING(A).\nnm(A) ::= JOIN_KW(A).\n\n// A typetoken is really zero or more tokens that form a type name such\n// as can be found after the column name in a CREATE TABLE statement.\n// Multiple tokens are concatenated to form the value of the typetoken.\n//\n%type typetoken {Token}\ntypetoken(A) ::= .   {A.n = 0; A.z = 0;}\ntypetoken(A) ::= typename(A).\ntypetoken(A) ::= typename(A) LP signed RP(Y). {\n  A.n = (int)(&Y.z[Y.n] - A.z);\n}\ntypetoken(A) ::= typename(A) LP signed COMMA signed RP(Y). {\n  A.n = (int)(&Y.z[Y.n] - A.z);\n}\n%type typename {Token}\ntypename(A) ::= ids(A).\ntypename(A) ::= typename(A) ids(Y). {A.n=Y.n+(int)(Y.z-A.z);}\nsigned ::= plus_num.\nsigned ::= minus_num.\n\n// \"carglist\" is a list of additional constraints that come after the\n// column name and column type in a CREATE TABLE statement.\n//\ncarglist ::= carglist ccons.\ncarglist ::= .\nccons ::= CONSTRAINT nm(X).           {pParse->constraintName = X;}\nccons ::= DEFAULT term(X).            {sqlite3AddDefaultValue(pParse,&X);}\nccons ::= DEFAULT LP expr(X) RP.      {sqlite3AddDefaultValue(pParse,&X);}\nccons ::= DEFAULT PLUS term(X).       {sqlite3AddDefaultValue(pParse,&X);}\nccons ::= DEFAULT MINUS(A) term(X).      {\n  ExprSpan v;\n  v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, X.pExpr, 0);\n  v.zStart = A.z;\n  v.zEnd = X.zEnd;\n  sqlite3AddDefaultValue(pParse,&v);\n}\nccons ::= DEFAULT id(X).              {\n  ExprSpan v;\n  spanExpr(&v, pParse, TK_STRING, X);\n  sqlite3AddDefaultValue(pParse,&v);\n}\n\n// In addition to the type name, we also care about the primary key and\n// UNIQUE constraints.\n//\nccons ::= NULL onconf.\nccons ::= NOT NULL onconf(R).    {sqlite3AddNotNull(pParse, R);}\nccons ::= PRIMARY KEY sortorder(Z) onconf(R) autoinc(I).\n                                 {sqlite3AddPrimaryKey(pParse,0,R,I,Z);}\nccons ::= UNIQUE onconf(R).      {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0,\n                                   SQLITE_IDXTYPE_UNIQUE);}\nccons ::= CHECK LP expr(X) RP.   {sqlite3AddCheckConstraint(pParse,X.pExpr);}\nccons ::= REFERENCES nm(T) eidlist_opt(TA) refargs(R).\n                                 {sqlite3CreateForeignKey(pParse,0,&T,TA,R);}\nccons ::= defer_subclause(D).    {sqlite3DeferForeignKey(pParse,D);}\nccons ::= COLLATE ids(C).        {sqlite3AddCollateType(pParse, &C);}\n\n// The optional AUTOINCREMENT keyword\n%type autoinc {int}\nautoinc(X) ::= .          {X = 0;}\nautoinc(X) ::= AUTOINCR.  {X = 1;}\n\n// The next group of rules parses the arguments to a REFERENCES clause\n// that determine if the referential integrity checking is deferred or\n// or immediate and which determine what action to take if a ref-integ\n// check fails.\n//\n%type refargs {int}\nrefargs(A) ::= .                  { A = OE_None*0x0101; /* EV: R-19803-45884 */}\nrefargs(A) ::= refargs(A) refarg(Y). { A = (A & ~Y.mask) | Y.value; }\n%type refarg {struct {int value; int mask;}}\nrefarg(A) ::= MATCH nm.              { A.value = 0;     A.mask = 0x000000; }\nrefarg(A) ::= ON INSERT refact.      { A.value = 0;     A.mask = 0x000000; }\nrefarg(A) ::= ON DELETE refact(X).   { A.value = X;     A.mask = 0x0000ff; }\nrefarg(A) ::= ON UPDATE refact(X).   { A.value = X<<8;  A.mask = 0x00ff00; }\n%type refact {int}\nrefact(A) ::= SET NULL.              { A = OE_SetNull;  /* EV: R-33326-45252 */}\nrefact(A) ::= SET DEFAULT.           { A = OE_SetDflt;  /* EV: R-33326-45252 */}\nrefact(A) ::= CASCADE.               { A = OE_Cascade;  /* EV: R-33326-45252 */}\nrefact(A) ::= RESTRICT.              { A = OE_Restrict; /* EV: R-33326-45252 */}\nrefact(A) ::= NO ACTION.             { A = OE_None;     /* EV: R-33326-45252 */}\n%type defer_subclause {int}\ndefer_subclause(A) ::= NOT DEFERRABLE init_deferred_pred_opt.     {A = 0;}\ndefer_subclause(A) ::= DEFERRABLE init_deferred_pred_opt(X).      {A = X;}\n%type init_deferred_pred_opt {int}\ninit_deferred_pred_opt(A) ::= .                       {A = 0;}\ninit_deferred_pred_opt(A) ::= INITIALLY DEFERRED.     {A = 1;}\ninit_deferred_pred_opt(A) ::= INITIALLY IMMEDIATE.    {A = 0;}\n\nconslist_opt(A) ::= .                         {A.n = 0; A.z = 0;}\nconslist_opt(A) ::= COMMA(A) conslist.\nconslist ::= conslist tconscomma tcons.\nconslist ::= tcons.\ntconscomma ::= COMMA.            {pParse->constraintName.n = 0;}\ntconscomma ::= .\ntcons ::= CONSTRAINT nm(X).      {pParse->constraintName = X;}\ntcons ::= PRIMARY KEY LP sortlist(X) autoinc(I) RP onconf(R).\n                                 {sqlite3AddPrimaryKey(pParse,X,R,I,0);}\ntcons ::= UNIQUE LP sortlist(X) RP onconf(R).\n                                 {sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0,\n                                       SQLITE_IDXTYPE_UNIQUE);}\ntcons ::= CHECK LP expr(E) RP onconf.\n                                 {sqlite3AddCheckConstraint(pParse,E.pExpr);}\ntcons ::= FOREIGN KEY LP eidlist(FA) RP\n          REFERENCES nm(T) eidlist_opt(TA) refargs(R) defer_subclause_opt(D). {\n    sqlite3CreateForeignKey(pParse, FA, &T, TA, R);\n    sqlite3DeferForeignKey(pParse, D);\n}\n%type defer_subclause_opt {int}\ndefer_subclause_opt(A) ::= .                    {A = 0;}\ndefer_subclause_opt(A) ::= defer_subclause(A).\n\n// The following is a non-standard extension that allows us to declare the\n// default behavior when there is a constraint conflict.\n//\n%type onconf {int}\n%type orconf {int}\n%type resolvetype {int}\nonconf(A) ::= .                              {A = OE_Default;}\nonconf(A) ::= ON CONFLICT resolvetype(X).    {A = X;}\norconf(A) ::= .                              {A = OE_Default;}\norconf(A) ::= OR resolvetype(X).             {A = X;}\nresolvetype(A) ::= raisetype(A).\nresolvetype(A) ::= IGNORE.                   {A = OE_Ignore;}\nresolvetype(A) ::= REPLACE.                  {A = OE_Replace;}\n\n////////////////////////// The DROP TABLE /////////////////////////////////////\n//\ncmd ::= DROP TABLE ifexists(E) fullname(X). {\n  sqlite3DropTable(pParse, X, 0, E);\n}\n%type ifexists {int}\nifexists(A) ::= IF EXISTS.   {A = 1;}\nifexists(A) ::= .            {A = 0;}\n\n///////////////////// The CREATE VIEW statement /////////////////////////////\n//\n%ifndef SQLITE_OMIT_VIEW\ncmd ::= createkw(X) temp(T) VIEW ifnotexists(E) nm(Y) dbnm(Z) eidlist_opt(C)\n          AS select(S). {\n  sqlite3CreateView(pParse, &X, &Y, &Z, C, S, T, E);\n}\ncmd ::= DROP VIEW ifexists(E) fullname(X). {\n  sqlite3DropTable(pParse, X, 1, E);\n}\n%endif  SQLITE_OMIT_VIEW\n\n//////////////////////// The SELECT statement /////////////////////////////////\n//\ncmd ::= select(X).  {\n  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};\n  sqlite3Select(pParse, X, &dest);\n  sqlite3SelectDelete(pParse->db, X);\n}\n\n%type select {Select*}\n%destructor select {sqlite3SelectDelete(pParse->db, $$);}\n%type selectnowith {Select*}\n%destructor selectnowith {sqlite3SelectDelete(pParse->db, $$);}\n%type oneselect {Select*}\n%destructor oneselect {sqlite3SelectDelete(pParse->db, $$);}\n\n%include {\n  /*\n  ** For a compound SELECT statement, make sure p->pPrior->pNext==p for\n  ** all elements in the list.  And make sure list length does not exceed\n  ** SQLITE_LIMIT_COMPOUND_SELECT.\n  */\n  static void parserDoubleLinkSelect(Parse *pParse, Select *p){\n    if( p->pPrior ){\n      Select *pNext = 0, *pLoop;\n      int mxSelect, cnt = 0;\n      for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){\n        pLoop->pNext = pNext;\n        pLoop->selFlags |= SF_Compound;\n      }\n      if( (p->selFlags & SF_MultiValue)==0 && \n        (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&\n        cnt>mxSelect\n      ){\n        sqlite3ErrorMsg(pParse, \"too many terms in compound SELECT\");\n      }\n    }\n  }\n}\n\nselect(A) ::= with(W) selectnowith(X). {\n  Select *p = X;\n  if( p ){\n    p->pWith = W;\n    parserDoubleLinkSelect(pParse, p);\n  }else{\n    sqlite3WithDelete(pParse->db, W);\n  }\n  A = p; /*A-overwrites-W*/\n}\n\nselectnowith(A) ::= oneselect(A).\n%ifndef SQLITE_OMIT_COMPOUND_SELECT\nselectnowith(A) ::= selectnowith(A) multiselect_op(Y) oneselect(Z).  {\n  Select *pRhs = Z;\n  Select *pLhs = A;\n  if( pRhs && pRhs->pPrior ){\n    SrcList *pFrom;\n    Token x;\n    x.n = 0;\n    parserDoubleLinkSelect(pParse, pRhs);\n    pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);\n    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);\n  }\n  if( pRhs ){\n    pRhs->op = (u8)Y;\n    pRhs->pPrior = pLhs;\n    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;\n    pRhs->selFlags &= ~SF_MultiValue;\n    if( Y!=TK_ALL ) pParse->hasCompound = 1;\n  }else{\n    sqlite3SelectDelete(pParse->db, pLhs);\n  }\n  A = pRhs;\n}\n%type multiselect_op {int}\nmultiselect_op(A) ::= UNION(OP).             {A = @OP; /*A-overwrites-OP*/}\nmultiselect_op(A) ::= UNION ALL.             {A = TK_ALL;}\nmultiselect_op(A) ::= EXCEPT|INTERSECT(OP).  {A = @OP; /*A-overwrites-OP*/}\n%endif SQLITE_OMIT_COMPOUND_SELECT\noneselect(A) ::= SELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y)\n                 groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {\n#if SELECTTRACE_ENABLED\n  Token s = S; /*A-overwrites-S*/\n#endif\n  A = sqlite3SelectNew(pParse,W,X,Y,P,Q,Z,D,L.pLimit,L.pOffset);\n#if SELECTTRACE_ENABLED\n  /* Populate the Select.zSelName[] string that is used to help with\n  ** query planner debugging, to differentiate between multiple Select\n  ** objects in a complex query.\n  **\n  ** If the SELECT keyword is immediately followed by a C-style comment\n  ** then extract the first few alphanumeric characters from within that\n  ** comment to be the zSelName value.  Otherwise, the label is #N where\n  ** is an integer that is incremented with each SELECT statement seen.\n  */\n  if( A!=0 ){\n    const char *z = s.z+6;\n    int i;\n    sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, \"#%d\",\n                     ++pParse->nSelect);\n    while( z[0]==' ' ) z++;\n    if( z[0]=='/' && z[1]=='*' ){\n      z += 2;\n      while( z[0]==' ' ) z++;\n      for(i=0; sqlite3Isalnum(z[i]); i++){}\n      sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, \"%.*s\", i, z);\n    }\n  }\n#endif /* SELECTRACE_ENABLED */\n}\noneselect(A) ::= values(A).\n\n%type values {Select*}\n%destructor values {sqlite3SelectDelete(pParse->db, $$);}\nvalues(A) ::= VALUES LP nexprlist(X) RP. {\n  A = sqlite3SelectNew(pParse,X,0,0,0,0,0,SF_Values,0,0);\n}\nvalues(A) ::= values(A) COMMA LP exprlist(Y) RP. {\n  Select *pRight, *pLeft = A;\n  pRight = sqlite3SelectNew(pParse,Y,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);\n  if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;\n  if( pRight ){\n    pRight->op = TK_ALL;\n    pRight->pPrior = pLeft;\n    A = pRight;\n  }else{\n    A = pLeft;\n  }\n}\n\n// The \"distinct\" nonterminal is true (1) if the DISTINCT keyword is\n// present and false (0) if it is not.\n//\n%type distinct {int}\ndistinct(A) ::= DISTINCT.   {A = SF_Distinct;}\ndistinct(A) ::= ALL.        {A = SF_All;}\ndistinct(A) ::= .           {A = 0;}\n\n// selcollist is a list of expressions that are to become the return\n// values of the SELECT statement.  The \"*\" in statements like\n// \"SELECT * FROM ...\" is encoded as a special expression with an\n// opcode of TK_ASTERISK.\n//\n%type selcollist {ExprList*}\n%destructor selcollist {sqlite3ExprListDelete(pParse->db, $$);}\n%type sclp {ExprList*}\n%destructor sclp {sqlite3ExprListDelete(pParse->db, $$);}\nsclp(A) ::= selcollist(A) COMMA.\nsclp(A) ::= .                                {A = 0;}\nselcollist(A) ::= sclp(A) expr(X) as(Y).     {\n   A = sqlite3ExprListAppend(pParse, A, X.pExpr);\n   if( Y.n>0 ) sqlite3ExprListSetName(pParse, A, &Y, 1);\n   sqlite3ExprListSetSpan(pParse,A,&X);\n}\nselcollist(A) ::= sclp(A) STAR. {\n  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);\n  A = sqlite3ExprListAppend(pParse, A, p);\n}\nselcollist(A) ::= sclp(A) nm(X) DOT STAR. {\n  Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);\n  Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);\n  Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n  A = sqlite3ExprListAppend(pParse,A, pDot);\n}\n\n// An option \"AS <id>\" phrase that can follow one of the expressions that\n// define the result set, or one of the tables in the FROM clause.\n//\n%type as {Token}\nas(X) ::= AS nm(Y).    {X = Y;}\nas(X) ::= ids(X).\nas(X) ::= .            {X.n = 0; X.z = 0;}\n\n\n%type seltablist {SrcList*}\n%destructor seltablist {sqlite3SrcListDelete(pParse->db, $$);}\n%type stl_prefix {SrcList*}\n%destructor stl_prefix {sqlite3SrcListDelete(pParse->db, $$);}\n%type from {SrcList*}\n%destructor from {sqlite3SrcListDelete(pParse->db, $$);}\n\n// A complete FROM clause.\n//\nfrom(A) ::= .                {A = sqlite3DbMallocZero(pParse->db, sizeof(*A));}\nfrom(A) ::= FROM seltablist(X). {\n  A = X;\n  sqlite3SrcListShiftJoinType(A);\n}\n\n// \"seltablist\" is a \"Select Table List\" - the content of the FROM clause\n// in a SELECT statement.  \"stl_prefix\" is a prefix of this list.\n//\nstl_prefix(A) ::= seltablist(A) joinop(Y).    {\n   if( ALWAYS(A && A->nSrc>0) ) A->a[A->nSrc-1].fg.jointype = (u8)Y;\n}\nstl_prefix(A) ::= .                           {A = 0;}\nseltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) as(Z) indexed_opt(I)\n                  on_opt(N) using_opt(U). {\n  A = sqlite3SrcListAppendFromTerm(pParse,A,&Y,&D,&Z,0,N,U);\n  sqlite3SrcListIndexedBy(pParse, A, &I);\n}\nseltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z)\n                  on_opt(N) using_opt(U). {\n  A = sqlite3SrcListAppendFromTerm(pParse,A,&Y,&D,&Z,0,N,U);\n  sqlite3SrcListFuncArgs(pParse, A, E);\n}\n%ifndef SQLITE_OMIT_SUBQUERY\n  seltablist(A) ::= stl_prefix(A) LP select(S) RP\n                    as(Z) on_opt(N) using_opt(U). {\n    A = sqlite3SrcListAppendFromTerm(pParse,A,0,0,&Z,S,N,U);\n  }\n  seltablist(A) ::= stl_prefix(A) LP seltablist(F) RP\n                    as(Z) on_opt(N) using_opt(U). {\n    if( A==0 && Z.n==0 && N==0 && U==0 ){\n      A = F;\n    }else if( F->nSrc==1 ){\n      A = sqlite3SrcListAppendFromTerm(pParse,A,0,0,&Z,0,N,U);\n      if( A ){\n        struct SrcList_item *pNew = &A->a[A->nSrc-1];\n        struct SrcList_item *pOld = F->a;\n        pNew->zName = pOld->zName;\n        pNew->zDatabase = pOld->zDatabase;\n        pNew->pSelect = pOld->pSelect;\n        pOld->zName = pOld->zDatabase = 0;\n        pOld->pSelect = 0;\n      }\n      sqlite3SrcListDelete(pParse->db, F);\n    }else{\n      Select *pSubquery;\n      sqlite3SrcListShiftJoinType(F);\n      pSubquery = sqlite3SelectNew(pParse,0,F,0,0,0,0,SF_NestedFrom,0,0);\n      A = sqlite3SrcListAppendFromTerm(pParse,A,0,0,&Z,pSubquery,N,U);\n    }\n  }\n%endif  SQLITE_OMIT_SUBQUERY\n\n%type dbnm {Token}\ndbnm(A) ::= .          {A.z=0; A.n=0;}\ndbnm(A) ::= DOT nm(X). {A = X;}\n\n%type fullname {SrcList*}\n%destructor fullname {sqlite3SrcListDelete(pParse->db, $$);}\nfullname(A) ::= nm(X) dbnm(Y).  \n   {A = sqlite3SrcListAppend(pParse->db,0,&X,&Y); /*A-overwrites-X*/}\n\n%type joinop {int}\njoinop(X) ::= COMMA|JOIN.              { X = JT_INNER; }\njoinop(X) ::= JOIN_KW(A) JOIN.\n                  {X = sqlite3JoinType(pParse,&A,0,0);  /*X-overwrites-A*/}\njoinop(X) ::= JOIN_KW(A) nm(B) JOIN.\n                  {X = sqlite3JoinType(pParse,&A,&B,0); /*X-overwrites-A*/}\njoinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.\n                  {X = sqlite3JoinType(pParse,&A,&B,&C);/*X-overwrites-A*/}\n\n%type on_opt {Expr*}\n%destructor on_opt {sqlite3ExprDelete(pParse->db, $$);}\non_opt(N) ::= ON expr(E).   {N = E.pExpr;}\non_opt(N) ::= .             {N = 0;}\n\n// Note that this block abuses the Token type just a little. If there is\n// no \"INDEXED BY\" clause, the returned token is empty (z==0 && n==0). If\n// there is an INDEXED BY clause, then the token is populated as per normal,\n// with z pointing to the token data and n containing the number of bytes\n// in the token.\n//\n// If there is a \"NOT INDEXED\" clause, then (z==0 && n==1), which is \n// normally illegal. The sqlite3SrcListIndexedBy() function \n// recognizes and interprets this as a special case.\n//\n%type indexed_opt {Token}\nindexed_opt(A) ::= .                 {A.z=0; A.n=0;}\nindexed_opt(A) ::= INDEXED BY nm(X). {A = X;}\nindexed_opt(A) ::= NOT INDEXED.      {A.z=0; A.n=1;}\n\n%type using_opt {IdList*}\n%destructor using_opt {sqlite3IdListDelete(pParse->db, $$);}\nusing_opt(U) ::= USING LP idlist(L) RP.  {U = L;}\nusing_opt(U) ::= .                        {U = 0;}\n\n\n%type orderby_opt {ExprList*}\n%destructor orderby_opt {sqlite3ExprListDelete(pParse->db, $$);}\n\n// the sortlist non-terminal stores a list of expression where each\n// expression is optionally followed by ASC or DESC to indicate the\n// sort order.\n//\n%type sortlist {ExprList*}\n%destructor sortlist {sqlite3ExprListDelete(pParse->db, $$);}\n\norderby_opt(A) ::= .                          {A = 0;}\norderby_opt(A) ::= ORDER BY sortlist(X).      {A = X;}\nsortlist(A) ::= sortlist(A) COMMA expr(Y) sortorder(Z). {\n  A = sqlite3ExprListAppend(pParse,A,Y.pExpr);\n  sqlite3ExprListSetSortOrder(A,Z);\n}\nsortlist(A) ::= expr(Y) sortorder(Z). {\n  A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/\n  sqlite3ExprListSetSortOrder(A,Z);\n}\n\n%type sortorder {int}\n\nsortorder(A) ::= ASC.           {A = SQLITE_SO_ASC;}\nsortorder(A) ::= DESC.          {A = SQLITE_SO_DESC;}\nsortorder(A) ::= .              {A = SQLITE_SO_UNDEFINED;}\n\n%type groupby_opt {ExprList*}\n%destructor groupby_opt {sqlite3ExprListDelete(pParse->db, $$);}\ngroupby_opt(A) ::= .                      {A = 0;}\ngroupby_opt(A) ::= GROUP BY nexprlist(X). {A = X;}\n\n%type having_opt {Expr*}\n%destructor having_opt {sqlite3ExprDelete(pParse->db, $$);}\nhaving_opt(A) ::= .                {A = 0;}\nhaving_opt(A) ::= HAVING expr(X).  {A = X.pExpr;}\n\n%type limit_opt {struct LimitVal}\n\n// The destructor for limit_opt will never fire in the current grammar.\n// The limit_opt non-terminal only occurs at the end of a single production\n// rule for SELECT statements.  As soon as the rule that create the \n// limit_opt non-terminal reduces, the SELECT statement rule will also\n// reduce.  So there is never a limit_opt non-terminal on the stack \n// except as a transient.  So there is never anything to destroy.\n//\n//%destructor limit_opt {\n//  sqlite3ExprDelete(pParse->db, $$.pLimit);\n//  sqlite3ExprDelete(pParse->db, $$.pOffset);\n//}\nlimit_opt(A) ::= .                    {A.pLimit = 0; A.pOffset = 0;}\nlimit_opt(A) ::= LIMIT expr(X).       {A.pLimit = X.pExpr; A.pOffset = 0;}\nlimit_opt(A) ::= LIMIT expr(X) OFFSET expr(Y). \n                                      {A.pLimit = X.pExpr; A.pOffset = Y.pExpr;}\nlimit_opt(A) ::= LIMIT expr(X) COMMA expr(Y). \n                                      {A.pOffset = X.pExpr; A.pLimit = Y.pExpr;}\n\n/////////////////////////// The DELETE statement /////////////////////////////\n//\n%ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\ncmd ::= with(C) DELETE FROM fullname(X) indexed_opt(I) where_opt(W) \n        orderby_opt(O) limit_opt(L). {\n  sqlite3WithPush(pParse, C, 1);\n  sqlite3SrcListIndexedBy(pParse, X, &I);\n  W = sqlite3LimitWhere(pParse, X, W, O, L.pLimit, L.pOffset, \"DELETE\");\n  sqlite3DeleteFrom(pParse,X,W);\n}\n%endif\n%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\ncmd ::= with(C) DELETE FROM fullname(X) indexed_opt(I) where_opt(W). {\n  sqlite3WithPush(pParse, C, 1);\n  sqlite3SrcListIndexedBy(pParse, X, &I);\n  sqlite3DeleteFrom(pParse,X,W);\n}\n%endif\n\n%type where_opt {Expr*}\n%destructor where_opt {sqlite3ExprDelete(pParse->db, $$);}\n\nwhere_opt(A) ::= .                    {A = 0;}\nwhere_opt(A) ::= WHERE expr(X).       {A = X.pExpr;}\n\n////////////////////////// The UPDATE command ////////////////////////////////\n//\n%ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\ncmd ::= with(C) UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)\n        where_opt(W) orderby_opt(O) limit_opt(L).  {\n  sqlite3WithPush(pParse, C, 1);\n  sqlite3SrcListIndexedBy(pParse, X, &I);\n  sqlite3ExprListCheckLength(pParse,Y,\"set list\"); \n  W = sqlite3LimitWhere(pParse, X, W, O, L.pLimit, L.pOffset, \"UPDATE\");\n  sqlite3Update(pParse,X,Y,W,R);\n}\n%endif\n%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT\ncmd ::= with(C) UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)\n        where_opt(W).  {\n  sqlite3WithPush(pParse, C, 1);\n  sqlite3SrcListIndexedBy(pParse, X, &I);\n  sqlite3ExprListCheckLength(pParse,Y,\"set list\"); \n  sqlite3Update(pParse,X,Y,W,R);\n}\n%endif\n\n%type setlist {ExprList*}\n%destructor setlist {sqlite3ExprListDelete(pParse->db, $$);}\n\nsetlist(A) ::= setlist(A) COMMA nm(X) EQ expr(Y). {\n  A = sqlite3ExprListAppend(pParse, A, Y.pExpr);\n  sqlite3ExprListSetName(pParse, A, &X, 1);\n}\nsetlist(A) ::= setlist(A) COMMA LP idlist(X) RP EQ expr(Y). {\n  A = sqlite3ExprListAppendVector(pParse, A, X, Y.pExpr);\n}\nsetlist(A) ::= nm(X) EQ expr(Y). {\n  A = sqlite3ExprListAppend(pParse, 0, Y.pExpr);\n  sqlite3ExprListSetName(pParse, A, &X, 1);\n}\nsetlist(A) ::= LP idlist(X) RP EQ expr(Y). {\n  A = sqlite3ExprListAppendVector(pParse, 0, X, Y.pExpr);\n}\n\n////////////////////////// The INSERT command /////////////////////////////////\n//\ncmd ::= with(W) insert_cmd(R) INTO fullname(X) idlist_opt(F) select(S). {\n  sqlite3WithPush(pParse, W, 1);\n  sqlite3Insert(pParse, X, S, F, R);\n}\ncmd ::= with(W) insert_cmd(R) INTO fullname(X) idlist_opt(F) DEFAULT VALUES.\n{\n  sqlite3WithPush(pParse, W, 1);\n  sqlite3Insert(pParse, X, 0, F, R);\n}\n\n%type insert_cmd {int}\ninsert_cmd(A) ::= INSERT orconf(R).   {A = R;}\ninsert_cmd(A) ::= REPLACE.            {A = OE_Replace;}\n\n%type idlist_opt {IdList*}\n%destructor idlist_opt {sqlite3IdListDelete(pParse->db, $$);}\n%type idlist {IdList*}\n%destructor idlist {sqlite3IdListDelete(pParse->db, $$);}\n\nidlist_opt(A) ::= .                       {A = 0;}\nidlist_opt(A) ::= LP idlist(X) RP.    {A = X;}\nidlist(A) ::= idlist(A) COMMA nm(Y).\n    {A = sqlite3IdListAppend(pParse->db,A,&Y);}\nidlist(A) ::= nm(Y).\n    {A = sqlite3IdListAppend(pParse->db,0,&Y); /*A-overwrites-Y*/}\n\n/////////////////////////// Expression Processing /////////////////////////////\n//\n\n%type expr {ExprSpan}\n%destructor expr {sqlite3ExprDelete(pParse->db, $$.pExpr);}\n%type term {ExprSpan}\n%destructor term {sqlite3ExprDelete(pParse->db, $$.pExpr);}\n\n%include {\n  /* This is a utility routine used to set the ExprSpan.zStart and\n  ** ExprSpan.zEnd values of pOut so that the span covers the complete\n  ** range of text beginning with pStart and going to the end of pEnd.\n  */\n  static void spanSet(ExprSpan *pOut, Token *pStart, Token *pEnd){\n    pOut->zStart = pStart->z;\n    pOut->zEnd = &pEnd->z[pEnd->n];\n  }\n\n  /* Construct a new Expr object from a single identifier.  Use the\n  ** new Expr to populate pOut.  Set the span of pOut to be the identifier\n  ** that created the expression.\n  */\n  static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token t){\n    Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);\n    if( p ){\n      memset(p, 0, sizeof(Expr));\n      p->op = (u8)op;\n      p->flags = EP_Leaf;\n      p->iAgg = -1;\n      p->u.zToken = (char*)&p[1];\n      memcpy(p->u.zToken, t.z, t.n);\n      p->u.zToken[t.n] = 0;\n      if( sqlite3Isquote(p->u.zToken[0]) ){\n        if( p->u.zToken[0]=='\"' ) p->flags |= EP_DblQuoted;\n        sqlite3Dequote(p->u.zToken);\n      }\n#if SQLITE_MAX_EXPR_DEPTH>0\n      p->nHeight = 1;\n#endif  \n    }\n    pOut->pExpr = p;\n    pOut->zStart = t.z;\n    pOut->zEnd = &t.z[t.n];\n  }\n}\n\nexpr(A) ::= term(A).\nexpr(A) ::= LP(B) expr(X) RP(E).\n            {spanSet(&A,&B,&E); /*A-overwrites-B*/  A.pExpr = X.pExpr;}\nexpr(A) ::= id(X).          {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}\nexpr(A) ::= JOIN_KW(X).     {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}\nexpr(A) ::= nm(X) DOT nm(Y). {\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);\n  spanSet(&A,&X,&Y); /*A-overwrites-X*/\n  A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);\n}\nexpr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {\n  Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);\n  Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);\n  Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &Z, 1);\n  Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);\n  spanSet(&A,&X,&Z); /*A-overwrites-X*/\n  A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);\n}\nterm(A) ::= NULL|FLOAT|BLOB(X). {spanExpr(&A,pParse,@X,X); /*A-overwrites-X*/}\nterm(A) ::= STRING(X).          {spanExpr(&A,pParse,@X,X); /*A-overwrites-X*/}\nterm(A) ::= INTEGER(X). {\n  A.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &X, 1);\n  A.zStart = X.z;\n  A.zEnd = X.z + X.n;\n}\nexpr(A) ::= VARIABLE(X).     {\n  if( !(X.z[0]=='#' && sqlite3Isdigit(X.z[1])) ){\n    u32 n = X.n;\n    spanExpr(&A, pParse, TK_VARIABLE, X);\n    sqlite3ExprAssignVarNumber(pParse, A.pExpr, n);\n  }else{\n    /* When doing a nested parse, one can include terms in an expression\n    ** that look like this:   #1 #2 ...  These terms refer to registers\n    ** in the virtual machine.  #N is the N-th register. */\n    Token t = X; /*A-overwrites-X*/\n    assert( t.n>=2 );\n    spanSet(&A, &t, &t);\n    if( pParse->nested==0 ){\n      sqlite3ErrorMsg(pParse, \"near \\\"%T\\\": syntax error\", &t);\n      A.pExpr = 0;\n    }else{\n      A.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);\n      if( A.pExpr ) sqlite3GetInt32(&t.z[1], &A.pExpr->iTable);\n    }\n  }\n}\nexpr(A) ::= expr(A) COLLATE ids(C). {\n  A.pExpr = sqlite3ExprAddCollateToken(pParse, A.pExpr, &C, 1);\n  A.zEnd = &C.z[C.n];\n}\n%ifndef SQLITE_OMIT_CAST\nexpr(A) ::= CAST(X) LP expr(E) AS typetoken(T) RP(Y). {\n  spanSet(&A,&X,&Y); /*A-overwrites-X*/\n  A.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &T, 1);\n  sqlite3ExprAttachSubtrees(pParse->db, A.pExpr, E.pExpr, 0);\n}\n%endif  SQLITE_OMIT_CAST\nexpr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). {\n  if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){\n    sqlite3ErrorMsg(pParse, \"too many arguments on function %T\", &X);\n  }\n  A.pExpr = sqlite3ExprFunction(pParse, Y, &X);\n  spanSet(&A,&X,&E);\n  if( D==SF_Distinct && A.pExpr ){\n    A.pExpr->flags |= EP_Distinct;\n  }\n}\nexpr(A) ::= id(X) LP STAR RP(E). {\n  A.pExpr = sqlite3ExprFunction(pParse, 0, &X);\n  spanSet(&A,&X,&E);\n}\nterm(A) ::= CTIME_KW(OP). {\n  A.pExpr = sqlite3ExprFunction(pParse, 0, &OP);\n  spanSet(&A, &OP, &OP);\n}\n\n%include {\n  /* This routine constructs a binary expression node out of two ExprSpan\n  ** objects and uses the result to populate a new ExprSpan object.\n  */\n  static void spanBinaryExpr(\n    Parse *pParse,      /* The parsing context.  Errors accumulate here */\n    int op,             /* The binary operation */\n    ExprSpan *pLeft,    /* The left operand, and output */\n    ExprSpan *pRight    /* The right operand */\n  ){\n    pLeft->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr);\n    pLeft->zEnd = pRight->zEnd;\n  }\n\n  /* If doNot is true, then add a TK_NOT Expr-node wrapper around the\n  ** outside of *ppExpr.\n  */\n  static void exprNot(Parse *pParse, int doNot, ExprSpan *pSpan){\n    if( doNot ){\n      pSpan->pExpr = sqlite3PExpr(pParse, TK_NOT, pSpan->pExpr, 0);\n    }\n  }\n}\n\nexpr(A) ::= LP(L) nexprlist(X) COMMA expr(Y) RP(R). {\n  ExprList *pList = sqlite3ExprListAppend(pParse, X, Y.pExpr);\n  A.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);\n  if( A.pExpr ){\n    A.pExpr->x.pList = pList;\n    spanSet(&A, &L, &R);\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  }\n}\n\nexpr(A) ::= expr(A) AND(OP) expr(Y).    {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) OR(OP) expr(Y).     {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) LT|GT|GE|LE(OP) expr(Y).\n                                        {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) EQ|NE(OP) expr(Y).  {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).\n                                        {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) PLUS|MINUS(OP) expr(Y).\n                                        {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) STAR|SLASH|REM(OP) expr(Y).\n                                        {spanBinaryExpr(pParse,@OP,&A,&Y);}\nexpr(A) ::= expr(A) CONCAT(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}\n%type likeop {Token}\nlikeop(A) ::= LIKE_KW|MATCH(A).\nlikeop(A) ::= NOT LIKE_KW|MATCH(X). {A=X; A.n|=0x80000000; /*A-overwrite-X*/}\nexpr(A) ::= expr(A) likeop(OP) expr(Y).  [LIKE_KW]  {\n  ExprList *pList;\n  int bNot = OP.n & 0x80000000;\n  OP.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);\n  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);\n  exprNot(pParse, bNot, &A);\n  A.zEnd = Y.zEnd;\n  if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;\n}\nexpr(A) ::= expr(A) likeop(OP) expr(Y) ESCAPE expr(E).  [LIKE_KW]  {\n  ExprList *pList;\n  int bNot = OP.n & 0x80000000;\n  OP.n &= 0x7fffffff;\n  pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, E.pExpr);\n  A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);\n  exprNot(pParse, bNot, &A);\n  A.zEnd = E.zEnd;\n  if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;\n}\n\n%include {\n  /* Construct an expression node for a unary postfix operator\n  */\n  static void spanUnaryPostfix(\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand, and output */\n    Token *pPostOp         /* The operand token for setting the span */\n  ){\n    pOperand->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);\n    pOperand->zEnd = &pPostOp->z[pPostOp->n];\n  }                           \n}\n\nexpr(A) ::= expr(A) ISNULL|NOTNULL(E).   {spanUnaryPostfix(pParse,@E,&A,&E);}\nexpr(A) ::= expr(A) NOT NULL(E). {spanUnaryPostfix(pParse,TK_NOTNULL,&A,&E);}\n\n%include {\n  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a\n  ** unary TK_ISNULL or TK_NOTNULL expression. */\n  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){\n    sqlite3 *db = pParse->db;\n    if( pA && pY && pY->op==TK_NULL ){\n      pA->op = (u8)op;\n      sqlite3ExprDelete(db, pA->pRight);\n      pA->pRight = 0;\n    }\n  }\n}\n\n//    expr1 IS expr2\n//    expr1 IS NOT expr2\n//\n// If expr2 is NULL then code as TK_ISNULL or TK_NOTNULL.  If expr2\n// is any other expression, code as TK_IS or TK_ISNOT.\n// \nexpr(A) ::= expr(A) IS expr(Y).     {\n  spanBinaryExpr(pParse,TK_IS,&A,&Y);\n  binaryToUnaryIfNull(pParse, Y.pExpr, A.pExpr, TK_ISNULL);\n}\nexpr(A) ::= expr(A) IS NOT expr(Y). {\n  spanBinaryExpr(pParse,TK_ISNOT,&A,&Y);\n  binaryToUnaryIfNull(pParse, Y.pExpr, A.pExpr, TK_NOTNULL);\n}\n\n%include {\n  /* Construct an expression node for a unary prefix operator\n  */\n  static void spanUnaryPrefix(\n    ExprSpan *pOut,        /* Write the new expression node here */\n    Parse *pParse,         /* Parsing context to record errors */\n    int op,                /* The operator */\n    ExprSpan *pOperand,    /* The operand */\n    Token *pPreOp         /* The operand token for setting the span */\n  ){\n    pOut->zStart = pPreOp->z;\n    pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);\n    pOut->zEnd = pOperand->zEnd;\n  }\n}\n\n\n\nexpr(A) ::= NOT(B) expr(X).  \n              {spanUnaryPrefix(&A,pParse,@B,&X,&B);/*A-overwrites-B*/}\nexpr(A) ::= BITNOT(B) expr(X).\n              {spanUnaryPrefix(&A,pParse,@B,&X,&B);/*A-overwrites-B*/}\nexpr(A) ::= MINUS(B) expr(X). [BITNOT]\n              {spanUnaryPrefix(&A,pParse,TK_UMINUS,&X,&B);/*A-overwrites-B*/}\nexpr(A) ::= PLUS(B) expr(X). [BITNOT]\n              {spanUnaryPrefix(&A,pParse,TK_UPLUS,&X,&B);/*A-overwrites-B*/}\n\n%type between_op {int}\nbetween_op(A) ::= BETWEEN.     {A = 0;}\nbetween_op(A) ::= NOT BETWEEN. {A = 1;}\nexpr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {\n  ExprList *pList = sqlite3ExprListAppend(pParse,0, X.pExpr);\n  pList = sqlite3ExprListAppend(pParse,pList, Y.pExpr);\n  A.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, A.pExpr, 0);\n  if( A.pExpr ){\n    A.pExpr->x.pList = pList;\n  }else{\n    sqlite3ExprListDelete(pParse->db, pList);\n  } \n  exprNot(pParse, N, &A);\n  A.zEnd = Y.zEnd;\n}\n%ifndef SQLITE_OMIT_SUBQUERY\n  %type in_op {int}\n  in_op(A) ::= IN.      {A = 0;}\n  in_op(A) ::= NOT IN.  {A = 1;}\n  expr(A) ::= expr(A) in_op(N) LP exprlist(Y) RP(E). [IN] {\n    if( Y==0 ){\n      /* Expressions of the form\n      **\n      **      expr1 IN ()\n      **      expr1 NOT IN ()\n      **\n      ** simplify to constants 0 (false) and 1 (true), respectively,\n      ** regardless of the value of expr1.\n      */\n      sqlite3ExprDelete(pParse->db, A.pExpr);\n      A.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);\n    }else if( Y->nExpr==1 ){\n      /* Expressions of the form:\n      **\n      **      expr1 IN (?1)\n      **      expr1 NOT IN (?2)\n      **\n      ** with exactly one value on the RHS can be simplified to something\n      ** like this:\n      **\n      **      expr1 == ?1\n      **      expr1 <> ?2\n      **\n      ** But, the RHS of the == or <> is marked with the EP_Generic flag\n      ** so that it may not contribute to the computation of comparison\n      ** affinity or the collating sequence to use for comparison.  Otherwise,\n      ** the semantics would be subtly different from IN or NOT IN.\n      */\n      Expr *pRHS = Y->a[0].pExpr;\n      Y->a[0].pExpr = 0;\n      sqlite3ExprListDelete(pParse->db, Y);\n      /* pRHS cannot be NULL because a malloc error would have been detected\n      ** before now and control would have never reached this point */\n      if( ALWAYS(pRHS) ){\n        pRHS->flags &= ~EP_Collate;\n        pRHS->flags |= EP_Generic;\n      }\n      A.pExpr = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, A.pExpr, pRHS);\n    }else{\n      A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);\n      if( A.pExpr ){\n        A.pExpr->x.pList = Y;\n        sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);\n      }else{\n        sqlite3ExprListDelete(pParse->db, Y);\n      }\n      exprNot(pParse, N, &A);\n    }\n    A.zEnd = &E.z[E.n];\n  }\n  expr(A) ::= LP(B) select(X) RP(E). {\n    spanSet(&A,&B,&E); /*A-overwrites-B*/\n    A.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, A.pExpr, X);\n  }\n  expr(A) ::= expr(A) in_op(N) LP select(Y) RP(E).  [IN] {\n    A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);\n    sqlite3PExprAddSelect(pParse, A.pExpr, Y);\n    exprNot(pParse, N, &A);\n    A.zEnd = &E.z[E.n];\n  }\n  expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) paren_exprlist(E). [IN] {\n    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);\n    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);\n    if( E )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E);\n    A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);\n    sqlite3PExprAddSelect(pParse, A.pExpr, pSelect);\n    exprNot(pParse, N, &A);\n    A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];\n  }\n  expr(A) ::= EXISTS(B) LP select(Y) RP(E). {\n    Expr *p;\n    spanSet(&A,&B,&E); /*A-overwrites-B*/\n    p = A.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);\n    sqlite3PExprAddSelect(pParse, p, Y);\n  }\n%endif SQLITE_OMIT_SUBQUERY\n\n/* CASE expressions */\nexpr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {\n  spanSet(&A,&C,&E);  /*A-overwrites-C*/\n  A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0);\n  if( A.pExpr ){\n    A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y;\n    sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);\n  }else{\n    sqlite3ExprListDelete(pParse->db, Y);\n    sqlite3ExprDelete(pParse->db, Z);\n  }\n}\n%type case_exprlist {ExprList*}\n%destructor case_exprlist {sqlite3ExprListDelete(pParse->db, $$);}\ncase_exprlist(A) ::= case_exprlist(A) WHEN expr(Y) THEN expr(Z). {\n  A = sqlite3ExprListAppend(pParse,A, Y.pExpr);\n  A = sqlite3ExprListAppend(pParse,A, Z.pExpr);\n}\ncase_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {\n  A = sqlite3ExprListAppend(pParse,0, Y.pExpr);\n  A = sqlite3ExprListAppend(pParse,A, Z.pExpr);\n}\n%type case_else {Expr*}\n%destructor case_else {sqlite3ExprDelete(pParse->db, $$);}\ncase_else(A) ::=  ELSE expr(X).         {A = X.pExpr;}\ncase_else(A) ::=  .                     {A = 0;} \n%type case_operand {Expr*}\n%destructor case_operand {sqlite3ExprDelete(pParse->db, $$);}\ncase_operand(A) ::= expr(X).            {A = X.pExpr; /*A-overwrites-X*/} \ncase_operand(A) ::= .                   {A = 0;} \n\n%type exprlist {ExprList*}\n%destructor exprlist {sqlite3ExprListDelete(pParse->db, $$);}\n%type nexprlist {ExprList*}\n%destructor nexprlist {sqlite3ExprListDelete(pParse->db, $$);}\n\nexprlist(A) ::= nexprlist(A).\nexprlist(A) ::= .                            {A = 0;}\nnexprlist(A) ::= nexprlist(A) COMMA expr(Y).\n    {A = sqlite3ExprListAppend(pParse,A,Y.pExpr);}\nnexprlist(A) ::= expr(Y).\n    {A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/}\n\n%ifndef SQLITE_OMIT_SUBQUERY\n/* A paren_exprlist is an optional expression list contained inside\n** of parenthesis */\n%type paren_exprlist {ExprList*}\n%destructor paren_exprlist {sqlite3ExprListDelete(pParse->db, $$);}\nparen_exprlist(A) ::= .   {A = 0;}\nparen_exprlist(A) ::= LP exprlist(X) RP.  {A = X;}\n%endif SQLITE_OMIT_SUBQUERY\n\n\n///////////////////////////// The CREATE INDEX command ///////////////////////\n//\ncmd ::= createkw(S) uniqueflag(U) INDEX ifnotexists(NE) nm(X) dbnm(D)\n        ON nm(Y) LP sortlist(Z) RP where_opt(W). {\n  sqlite3CreateIndex(pParse, &X, &D, \n                     sqlite3SrcListAppend(pParse->db,0,&Y,0), Z, U,\n                      &S, W, SQLITE_SO_ASC, NE, SQLITE_IDXTYPE_APPDEF);\n}\n\n%type uniqueflag {int}\nuniqueflag(A) ::= UNIQUE.  {A = OE_Abort;}\nuniqueflag(A) ::= .        {A = OE_None;}\n\n\n// The eidlist non-terminal (Expression Id List) generates an ExprList\n// from a list of identifiers.  The identifier names are in ExprList.a[].zName.\n// This list is stored in an ExprList rather than an IdList so that it\n// can be easily sent to sqlite3ColumnsExprList().\n//\n// eidlist is grouped with CREATE INDEX because it used to be the non-terminal\n// used for the arguments to an index.  That is just an historical accident.\n//\n// IMPORTANT COMPATIBILITY NOTE:  Some prior versions of SQLite accepted\n// COLLATE clauses and ASC or DESC keywords on ID lists in inappropriate\n// places - places that might have been stored in the sqlite_master schema.\n// Those extra features were ignored.  But because they might be in some\n// (busted) old databases, we need to continue parsing them when loading\n// historical schemas.\n//\n%type eidlist {ExprList*}\n%destructor eidlist {sqlite3ExprListDelete(pParse->db, $$);}\n%type eidlist_opt {ExprList*}\n%destructor eidlist_opt {sqlite3ExprListDelete(pParse->db, $$);}\n\n%include {\n  /* Add a single new term to an ExprList that is used to store a\n  ** list of identifiers.  Report an error if the ID list contains\n  ** a COLLATE clause or an ASC or DESC keyword, except ignore the\n  ** error while parsing a legacy schema.\n  */\n  static ExprList *parserAddExprIdListTerm(\n    Parse *pParse,\n    ExprList *pPrior,\n    Token *pIdToken,\n    int hasCollate,\n    int sortOrder\n  ){\n    ExprList *p = sqlite3ExprListAppend(pParse, pPrior, 0);\n    if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED)\n        && pParse->db->init.busy==0\n    ){\n      sqlite3ErrorMsg(pParse, \"syntax error after column name \\\"%.*s\\\"\",\n                         pIdToken->n, pIdToken->z);\n    }\n    sqlite3ExprListSetName(pParse, p, pIdToken, 1);\n    return p;\n  }\n} // end %include\n\neidlist_opt(A) ::= .                         {A = 0;}\neidlist_opt(A) ::= LP eidlist(X) RP.         {A = X;}\neidlist(A) ::= eidlist(A) COMMA nm(Y) collate(C) sortorder(Z).  {\n  A = parserAddExprIdListTerm(pParse, A, &Y, C, Z);\n}\neidlist(A) ::= nm(Y) collate(C) sortorder(Z). {\n  A = parserAddExprIdListTerm(pParse, 0, &Y, C, Z); /*A-overwrites-Y*/\n}\n\n%type collate {int}\ncollate(C) ::= .              {C = 0;}\ncollate(C) ::= COLLATE ids.   {C = 1;}\n\n\n///////////////////////////// The DROP INDEX command /////////////////////////\n//\ncmd ::= DROP INDEX ifexists(E) fullname(X).   {sqlite3DropIndex(pParse, X, E);}\n\n///////////////////////////// The VACUUM command /////////////////////////////\n//\n%ifndef SQLITE_OMIT_VACUUM\n%ifndef SQLITE_OMIT_ATTACH\ncmd ::= VACUUM.                {sqlite3Vacuum(pParse,0);}\ncmd ::= VACUUM nm(X).          {sqlite3Vacuum(pParse,&X);}\n%endif  SQLITE_OMIT_ATTACH\n%endif  SQLITE_OMIT_VACUUM\n\n///////////////////////////// The PRAGMA command /////////////////////////////\n//\n%ifndef SQLITE_OMIT_PRAGMA\ncmd ::= PRAGMA nm(X) dbnm(Z).                {sqlite3Pragma(pParse,&X,&Z,0,0);}\ncmd ::= PRAGMA nm(X) dbnm(Z) EQ nmnum(Y).    {sqlite3Pragma(pParse,&X,&Z,&Y,0);}\ncmd ::= PRAGMA nm(X) dbnm(Z) LP nmnum(Y) RP. {sqlite3Pragma(pParse,&X,&Z,&Y,0);}\ncmd ::= PRAGMA nm(X) dbnm(Z) EQ minus_num(Y). \n                                             {sqlite3Pragma(pParse,&X,&Z,&Y,1);}\ncmd ::= PRAGMA nm(X) dbnm(Z) LP minus_num(Y) RP.\n                                             {sqlite3Pragma(pParse,&X,&Z,&Y,1);}\n\nnmnum(A) ::= plus_num(A).\nnmnum(A) ::= nm(A).\nnmnum(A) ::= ON(A).\nnmnum(A) ::= DELETE(A).\nnmnum(A) ::= DEFAULT(A).\n%endif SQLITE_OMIT_PRAGMA\n%token_class number INTEGER|FLOAT.\nplus_num(A) ::= PLUS number(X).       {A = X;}\nplus_num(A) ::= number(A).\nminus_num(A) ::= MINUS number(X).     {A = X;}\n//////////////////////////// The CREATE TRIGGER command /////////////////////\n\n%ifndef SQLITE_OMIT_TRIGGER\n\ncmd ::= createkw trigger_decl(A) BEGIN trigger_cmd_list(S) END(Z). {\n  Token all;\n  all.z = A.z;\n  all.n = (int)(Z.z - A.z) + Z.n;\n  sqlite3FinishTrigger(pParse, S, &all);\n}\n\ntrigger_decl(A) ::= temp(T) TRIGGER ifnotexists(NOERR) nm(B) dbnm(Z) \n                    trigger_time(C) trigger_event(D)\n                    ON fullname(E) foreach_clause when_clause(G). {\n  sqlite3BeginTrigger(pParse, &B, &Z, C, D.a, D.b, E, G, T, NOERR);\n  A = (Z.n==0?B:Z); /*A-overwrites-T*/\n}\n\n%type trigger_time {int}\ntrigger_time(A) ::= BEFORE|AFTER(X).  { A = @X; /*A-overwrites-X*/ }\ntrigger_time(A) ::= INSTEAD OF.  { A = TK_INSTEAD;}\ntrigger_time(A) ::= .            { A = TK_BEFORE; }\n\n%type trigger_event {struct TrigEvent}\n%destructor trigger_event {sqlite3IdListDelete(pParse->db, $$.b);}\ntrigger_event(A) ::= DELETE|INSERT(X).   {A.a = @X; /*A-overwrites-X*/ A.b = 0;}\ntrigger_event(A) ::= UPDATE(X).          {A.a = @X; /*A-overwrites-X*/ A.b = 0;}\ntrigger_event(A) ::= UPDATE OF idlist(X).{A.a = TK_UPDATE; A.b = X;}\n\nforeach_clause ::= .\nforeach_clause ::= FOR EACH ROW.\n\n%type when_clause {Expr*}\n%destructor when_clause {sqlite3ExprDelete(pParse->db, $$);}\nwhen_clause(A) ::= .             { A = 0; }\nwhen_clause(A) ::= WHEN expr(X). { A = X.pExpr; }\n\n%type trigger_cmd_list {TriggerStep*}\n%destructor trigger_cmd_list {sqlite3DeleteTriggerStep(pParse->db, $$);}\ntrigger_cmd_list(A) ::= trigger_cmd_list(A) trigger_cmd(X) SEMI. {\n  assert( A!=0 );\n  A->pLast->pNext = X;\n  A->pLast = X;\n}\ntrigger_cmd_list(A) ::= trigger_cmd(A) SEMI. { \n  assert( A!=0 );\n  A->pLast = A;\n}\n\n// Disallow qualified table names on INSERT, UPDATE, and DELETE statements\n// within a trigger.  The table to INSERT, UPDATE, or DELETE is always in \n// the same database as the table that the trigger fires on.\n//\n%type trnm {Token}\ntrnm(A) ::= nm(A).\ntrnm(A) ::= nm DOT nm(X). {\n  A = X;\n  sqlite3ErrorMsg(pParse, \n        \"qualified table names are not allowed on INSERT, UPDATE, and DELETE \"\n        \"statements within triggers\");\n}\n\n// Disallow the INDEX BY and NOT INDEXED clauses on UPDATE and DELETE\n// statements within triggers.  We make a specific error message for this\n// since it is an exception to the default grammar rules.\n//\ntridxby ::= .\ntridxby ::= INDEXED BY nm. {\n  sqlite3ErrorMsg(pParse,\n        \"the INDEXED BY clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\ntridxby ::= NOT INDEXED. {\n  sqlite3ErrorMsg(pParse,\n        \"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements \"\n        \"within triggers\");\n}\n\n\n\n%type trigger_cmd {TriggerStep*}\n%destructor trigger_cmd {sqlite3DeleteTriggerStep(pParse->db, $$);}\n// UPDATE \ntrigger_cmd(A) ::=\n   UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z).  \n   {A = sqlite3TriggerUpdateStep(pParse->db, &X, Y, Z, R);}\n\n// INSERT\ntrigger_cmd(A) ::= insert_cmd(R) INTO trnm(X) idlist_opt(F) select(S).\n   {A = sqlite3TriggerInsertStep(pParse->db, &X, F, S, R);/*A-overwrites-R*/}\n\n// DELETE\ntrigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(Y).\n   {A = sqlite3TriggerDeleteStep(pParse->db, &X, Y);}\n\n// SELECT\ntrigger_cmd(A) ::= select(X).\n   {A = sqlite3TriggerSelectStep(pParse->db, X); /*A-overwrites-X*/}\n\n// The special RAISE expression that may occur in trigger programs\nexpr(A) ::= RAISE(X) LP IGNORE RP(Y).  {\n  spanSet(&A,&X,&Y);  /*A-overwrites-X*/\n  A.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0); \n  if( A.pExpr ){\n    A.pExpr->affinity = OE_Ignore;\n  }\n}\nexpr(A) ::= RAISE(X) LP raisetype(T) COMMA nm(Z) RP(Y).  {\n  spanSet(&A,&X,&Y);  /*A-overwrites-X*/\n  A.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1); \n  if( A.pExpr ) {\n    A.pExpr->affinity = (char)T;\n  }\n}\n%endif  !SQLITE_OMIT_TRIGGER\n\n%type raisetype {int}\nraisetype(A) ::= ROLLBACK.  {A = OE_Rollback;}\nraisetype(A) ::= ABORT.     {A = OE_Abort;}\nraisetype(A) ::= FAIL.      {A = OE_Fail;}\n\n\n////////////////////////  DROP TRIGGER statement //////////////////////////////\n%ifndef SQLITE_OMIT_TRIGGER\ncmd ::= DROP TRIGGER ifexists(NOERR) fullname(X). {\n  sqlite3DropTrigger(pParse,X,NOERR);\n}\n%endif  !SQLITE_OMIT_TRIGGER\n\n//////////////////////// ATTACH DATABASE file AS name /////////////////////////\n%ifndef SQLITE_OMIT_ATTACH\ncmd ::= ATTACH database_kw_opt expr(F) AS expr(D) key_opt(K). {\n  sqlite3Attach(pParse, F.pExpr, D.pExpr, K);\n}\ncmd ::= DETACH database_kw_opt expr(D). {\n  sqlite3Detach(pParse, D.pExpr);\n}\n\n%type key_opt {Expr*}\n%destructor key_opt {sqlite3ExprDelete(pParse->db, $$);}\nkey_opt(A) ::= .                     { A = 0; }\nkey_opt(A) ::= KEY expr(X).          { A = X.pExpr; }\n\ndatabase_kw_opt ::= DATABASE.\ndatabase_kw_opt ::= .\n%endif SQLITE_OMIT_ATTACH\n\n////////////////////////// REINDEX collation //////////////////////////////////\n%ifndef SQLITE_OMIT_REINDEX\ncmd ::= REINDEX.                {sqlite3Reindex(pParse, 0, 0);}\ncmd ::= REINDEX nm(X) dbnm(Y).  {sqlite3Reindex(pParse, &X, &Y);}\n%endif  SQLITE_OMIT_REINDEX\n\n/////////////////////////////////// ANALYZE ///////////////////////////////////\n%ifndef SQLITE_OMIT_ANALYZE\ncmd ::= ANALYZE.                {sqlite3Analyze(pParse, 0, 0);}\ncmd ::= ANALYZE nm(X) dbnm(Y).  {sqlite3Analyze(pParse, &X, &Y);}\n%endif\n\n//////////////////////// ALTER TABLE table ... ////////////////////////////////\n%ifndef SQLITE_OMIT_ALTERTABLE\ncmd ::= ALTER TABLE fullname(X) RENAME TO nm(Z). {\n  sqlite3AlterRenameTable(pParse,X,&Z);\n}\ncmd ::= ALTER TABLE add_column_fullname\n        ADD kwcolumn_opt columnname(Y) carglist. {\n  Y.n = (int)(pParse->sLastToken.z-Y.z) + pParse->sLastToken.n;\n  sqlite3AlterFinishAddColumn(pParse, &Y);\n}\nadd_column_fullname ::= fullname(X). {\n  disableLookaside(pParse);\n  sqlite3AlterBeginAddColumn(pParse, X);\n}\nkwcolumn_opt ::= .\nkwcolumn_opt ::= COLUMNKW.\n%endif  SQLITE_OMIT_ALTERTABLE\n\n//////////////////////// CREATE VIRTUAL TABLE ... /////////////////////////////\n%ifndef SQLITE_OMIT_VIRTUALTABLE\ncmd ::= create_vtab.                       {sqlite3VtabFinishParse(pParse,0);}\ncmd ::= create_vtab LP vtabarglist RP(X).  {sqlite3VtabFinishParse(pParse,&X);}\ncreate_vtab ::= createkw VIRTUAL TABLE ifnotexists(E)\n                nm(X) dbnm(Y) USING nm(Z). {\n    sqlite3VtabBeginParse(pParse, &X, &Y, &Z, E);\n}\nvtabarglist ::= vtabarg.\nvtabarglist ::= vtabarglist COMMA vtabarg.\nvtabarg ::= .                       {sqlite3VtabArgInit(pParse);}\nvtabarg ::= vtabarg vtabargtoken.\nvtabargtoken ::= ANY(X).            {sqlite3VtabArgExtend(pParse,&X);}\nvtabargtoken ::= lp anylist RP(X).  {sqlite3VtabArgExtend(pParse,&X);}\nlp ::= LP(X).                       {sqlite3VtabArgExtend(pParse,&X);}\nanylist ::= .\nanylist ::= anylist LP anylist RP.\nanylist ::= anylist ANY.\n%endif  SQLITE_OMIT_VIRTUALTABLE\n\n\n//////////////////////// COMMON TABLE EXPRESSIONS ////////////////////////////\n%type with {With*}\n%type wqlist {With*}\n%destructor with {sqlite3WithDelete(pParse->db, $$);}\n%destructor wqlist {sqlite3WithDelete(pParse->db, $$);}\n\nwith(A) ::= . {A = 0;}\n%ifndef SQLITE_OMIT_CTE\nwith(A) ::= WITH wqlist(W).              { A = W; }\nwith(A) ::= WITH RECURSIVE wqlist(W).    { A = W; }\n\nwqlist(A) ::= nm(X) eidlist_opt(Y) AS LP select(Z) RP. {\n  A = sqlite3WithAdd(pParse, 0, &X, Y, Z); /*A-overwrites-X*/\n}\nwqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {\n  A = sqlite3WithAdd(pParse, A, &X, Y, Z);\n}\n%endif  SQLITE_OMIT_CTE\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pcache.c",
    "content": "/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements that page cache.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** A complete page cache is an instance of this structure.  Every\n** entry in the cache holds a single page of the database file.  The\n** btree layer only operates on the cached copy of the database pages.\n**\n** A page cache entry is \"clean\" if it exactly matches what is currently\n** on disk.  A page is \"dirty\" if it has been modified and needs to be\n** persisted to disk.\n**\n** pDirty, pDirtyTail, pSynced:\n**   All dirty pages are linked into the doubly linked list using\n**   PgHdr.pDirtyNext and pDirtyPrev. The list is maintained in LRU order\n**   such that p was added to the list more recently than p->pDirtyNext.\n**   PCache.pDirty points to the first (newest) element in the list and\n**   pDirtyTail to the last (oldest).\n**\n**   The PCache.pSynced variable is used to optimize searching for a dirty\n**   page to eject from the cache mid-transaction. It is better to eject\n**   a page that does not require a journal sync than one that does. \n**   Therefore, pSynced is maintained to that it *almost* always points\n**   to either the oldest page in the pDirty/pDirtyTail list that has a\n**   clear PGHDR_NEED_SYNC flag or to a page that is older than this one\n**   (so that the right page to eject can be found by following pDirtyPrev\n**   pointers).\n*/\nstruct PCache {\n  PgHdr *pDirty, *pDirtyTail;         /* List of dirty pages in LRU order */\n  PgHdr *pSynced;                     /* Last synced page in dirty page list */\n  int nRefSum;                        /* Sum of ref counts over all pages */\n  int szCache;                        /* Configured cache size */\n  int szSpill;                        /* Size before spilling occurs */\n  int szPage;                         /* Size of every page in this cache */\n  int szExtra;                        /* Size of extra space for each page */\n  u8 bPurgeable;                      /* True if pages are on backing store */\n  u8 eCreate;                         /* eCreate value for for xFetch() */\n  int (*xStress)(void*,PgHdr*);       /* Call to try make a page clean */\n  void *pStress;                      /* Argument to xStress */\n  sqlite3_pcache *pCache;             /* Pluggable cache module */\n};\n\n/********************************** Test and Debug Logic **********************/\n/*\n** Debug tracing macros.  Enable by by changing the \"0\" to \"1\" and\n** recompiling.\n**\n** When sqlite3PcacheTrace is 1, single line trace messages are issued.\n** When sqlite3PcacheTrace is 2, a dump of the pcache showing all cache entries\n** is displayed for many operations, resulting in a lot of output.\n*/\n#if defined(SQLITE_DEBUG) && 0\n  int sqlite3PcacheTrace = 2;       /* 0: off  1: simple  2: cache dumps */\n  int sqlite3PcacheMxDump = 9999;   /* Max cache entries for pcacheDump() */\n# define pcacheTrace(X) if(sqlite3PcacheTrace){sqlite3DebugPrintf X;}\n  void pcacheDump(PCache *pCache){\n    int N;\n    int i, j;\n    sqlite3_pcache_page *pLower;\n    PgHdr *pPg;\n    unsigned char *a;\n  \n    if( sqlite3PcacheTrace<2 ) return;\n    if( pCache->pCache==0 ) return;\n    N = sqlite3PcachePagecount(pCache);\n    if( N>sqlite3PcacheMxDump ) N = sqlite3PcacheMxDump;\n    for(i=1; i<=N; i++){\n       pLower = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, i, 0);\n       if( pLower==0 ) continue;\n       pPg = (PgHdr*)pLower->pExtra;\n       printf(\"%3d: nRef %2d flgs %02x data \", i, pPg->nRef, pPg->flags);\n       a = (unsigned char *)pLower->pBuf;\n       for(j=0; j<12; j++) printf(\"%02x\", a[j]);\n       printf(\"\\n\");\n       if( pPg->pPage==0 ){\n         sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pLower, 0);\n       }\n    }\n  }\n  #else\n# define pcacheTrace(X)\n# define pcacheDump(X)\n#endif\n\n/*\n** Check invariants on a PgHdr entry.  Return true if everything is OK.\n** Return false if any invariant is violated.\n**\n** This routine is for use inside of assert() statements only.  For\n** example:\n**\n**          assert( sqlite3PcachePageSanity(pPg) );\n*/\n#ifdef SQLITE_DEBUG\nint sqlite3PcachePageSanity(PgHdr *pPg){\n  PCache *pCache;\n  assert( pPg!=0 );\n  assert( pPg->pgno>0 || pPg->pPager==0 );    /* Page number is 1 or more */\n  pCache = pPg->pCache;\n  assert( pCache!=0 );      /* Every page has an associated PCache */\n  if( pPg->flags & PGHDR_CLEAN ){\n    assert( (pPg->flags & PGHDR_DIRTY)==0 );/* Cannot be both CLEAN and DIRTY */\n    assert( pCache->pDirty!=pPg );          /* CLEAN pages not on dirty list */\n    assert( pCache->pDirtyTail!=pPg );\n  }\n  /* WRITEABLE pages must also be DIRTY */\n  if( pPg->flags & PGHDR_WRITEABLE ){\n    assert( pPg->flags & PGHDR_DIRTY );     /* WRITEABLE implies DIRTY */\n  }\n  /* NEED_SYNC can be set independently of WRITEABLE.  This can happen,\n  ** for example, when using the sqlite3PagerDontWrite() optimization:\n  **    (1)  Page X is journalled, and gets WRITEABLE and NEED_SEEK.\n  **    (2)  Page X moved to freelist, WRITEABLE is cleared\n  **    (3)  Page X reused, WRITEABLE is set again\n  ** If NEED_SYNC had been cleared in step 2, then it would not be reset\n  ** in step 3, and page might be written into the database without first\n  ** syncing the rollback journal, which might cause corruption on a power\n  ** loss.\n  **\n  ** Another example is when the database page size is smaller than the\n  ** disk sector size.  When any page of a sector is journalled, all pages\n  ** in that sector are marked NEED_SYNC even if they are still CLEAN, just\n  ** in case they are later modified, since all pages in the same sector\n  ** must be journalled and synced before any of those pages can be safely\n  ** written.\n  */\n  return 1;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/********************************** Linked List Management ********************/\n\n/* Allowed values for second argument to pcacheManageDirtyList() */\n#define PCACHE_DIRTYLIST_REMOVE   1    /* Remove pPage from dirty list */\n#define PCACHE_DIRTYLIST_ADD      2    /* Add pPage to the dirty list */\n#define PCACHE_DIRTYLIST_FRONT    3    /* Move pPage to the front of the list */\n\n/*\n** Manage pPage's participation on the dirty list.  Bits of the addRemove\n** argument determines what operation to do.  The 0x01 bit means first\n** remove pPage from the dirty list.  The 0x02 means add pPage back to\n** the dirty list.  Doing both moves pPage to the front of the dirty list.\n*/\nstatic void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){\n  PCache *p = pPage->pCache;\n\n  pcacheTrace((\"%p.DIRTYLIST.%s %d\\n\", p,\n                addRemove==1 ? \"REMOVE\" : addRemove==2 ? \"ADD\" : \"FRONT\",\n                pPage->pgno));\n  if( addRemove & PCACHE_DIRTYLIST_REMOVE ){\n    assert( pPage->pDirtyNext || pPage==p->pDirtyTail );\n    assert( pPage->pDirtyPrev || pPage==p->pDirty );\n  \n    /* Update the PCache1.pSynced variable if necessary. */\n    if( p->pSynced==pPage ){\n      p->pSynced = pPage->pDirtyPrev;\n    }\n  \n    if( pPage->pDirtyNext ){\n      pPage->pDirtyNext->pDirtyPrev = pPage->pDirtyPrev;\n    }else{\n      assert( pPage==p->pDirtyTail );\n      p->pDirtyTail = pPage->pDirtyPrev;\n    }\n    if( pPage->pDirtyPrev ){\n      pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;\n    }else{\n      /* If there are now no dirty pages in the cache, set eCreate to 2. \n      ** This is an optimization that allows sqlite3PcacheFetch() to skip\n      ** searching for a dirty page to eject from the cache when it might\n      ** otherwise have to.  */\n      assert( pPage==p->pDirty );\n      p->pDirty = pPage->pDirtyNext;\n      assert( p->bPurgeable || p->eCreate==2 );\n      if( p->pDirty==0 ){         /*OPTIMIZATION-IF-TRUE*/\n        assert( p->bPurgeable==0 || p->eCreate==1 );\n        p->eCreate = 2;\n      }\n    }\n  }\n  if( addRemove & PCACHE_DIRTYLIST_ADD ){\n    pPage->pDirtyPrev = 0;\n    pPage->pDirtyNext = p->pDirty;\n    if( pPage->pDirtyNext ){\n      assert( pPage->pDirtyNext->pDirtyPrev==0 );\n      pPage->pDirtyNext->pDirtyPrev = pPage;\n    }else{\n      p->pDirtyTail = pPage;\n      if( p->bPurgeable ){\n        assert( p->eCreate==2 );\n        p->eCreate = 1;\n      }\n    }\n    p->pDirty = pPage;\n\n    /* If pSynced is NULL and this page has a clear NEED_SYNC flag, set\n    ** pSynced to point to it. Checking the NEED_SYNC flag is an \n    ** optimization, as if pSynced points to a page with the NEED_SYNC\n    ** flag set sqlite3PcacheFetchStress() searches through all newer \n    ** entries of the dirty-list for a page with NEED_SYNC clear anyway.  */\n    if( !p->pSynced \n     && 0==(pPage->flags&PGHDR_NEED_SYNC)   /*OPTIMIZATION-IF-FALSE*/\n    ){\n      p->pSynced = pPage;\n    }\n  }\n  pcacheDump(p);\n}\n\n/*\n** Wrapper around the pluggable caches xUnpin method. If the cache is\n** being used for an in-memory database, this function is a no-op.\n*/\nstatic void pcacheUnpin(PgHdr *p){\n  if( p->pCache->bPurgeable ){\n    pcacheTrace((\"%p.UNPIN %d\\n\", p->pCache, p->pgno));\n    sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0);\n    pcacheDump(p->pCache);\n  }\n}\n\n/*\n** Compute the number of pages of cache requested.   p->szCache is the\n** cache size requested by the \"PRAGMA cache_size\" statement.\n*/\nstatic int numberOfCachePages(PCache *p){\n  if( p->szCache>=0 ){\n    /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the\n    ** suggested cache size is set to N. */\n    return p->szCache;\n  }else{\n    /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then\n    ** the number of cache pages is adjusted to use approximately abs(N*1024)\n    ** bytes of memory. */\n    return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));\n  }\n}\n\n/*************************************************** General Interfaces ******\n**\n** Initialize and shutdown the page cache subsystem. Neither of these \n** functions are threadsafe.\n*/\nint sqlite3PcacheInitialize(void){\n  if( sqlite3GlobalConfig.pcache2.xInit==0 ){\n    /* IMPLEMENTATION-OF: R-26801-64137 If the xInit() method is NULL, then the\n    ** built-in default page cache is used instead of the application defined\n    ** page cache. */\n    sqlite3PCacheSetDefault();\n  }\n  return sqlite3GlobalConfig.pcache2.xInit(sqlite3GlobalConfig.pcache2.pArg);\n}\nvoid sqlite3PcacheShutdown(void){\n  if( sqlite3GlobalConfig.pcache2.xShutdown ){\n    /* IMPLEMENTATION-OF: R-26000-56589 The xShutdown() method may be NULL. */\n    sqlite3GlobalConfig.pcache2.xShutdown(sqlite3GlobalConfig.pcache2.pArg);\n  }\n}\n\n/*\n** Return the size in bytes of a PCache object.\n*/\nint sqlite3PcacheSize(void){ return sizeof(PCache); }\n\n/*\n** Create a new PCache object. Storage space to hold the object\n** has already been allocated and is passed in as the p pointer. \n** The caller discovers how much space needs to be allocated by \n** calling sqlite3PcacheSize().\n**\n** szExtra is some extra space allocated for each page.  The first\n** 8 bytes of the extra space will be zeroed as the page is allocated,\n** but remaining content will be uninitialized.  Though it is opaque\n** to this module, the extra space really ends up being the MemPage\n** structure in the pager.\n*/\nint sqlite3PcacheOpen(\n  int szPage,                  /* Size of every page */\n  int szExtra,                 /* Extra space associated with each page */\n  int bPurgeable,              /* True if pages are on backing store */\n  int (*xStress)(void*,PgHdr*),/* Call to try to make pages clean */\n  void *pStress,               /* Argument to xStress */\n  PCache *p                    /* Preallocated space for the PCache */\n){\n  memset(p, 0, sizeof(PCache));\n  p->szPage = 1;\n  p->szExtra = szExtra;\n  assert( szExtra>=8 );  /* First 8 bytes will be zeroed */\n  p->bPurgeable = bPurgeable;\n  p->eCreate = 2;\n  p->xStress = xStress;\n  p->pStress = pStress;\n  p->szCache = 100;\n  p->szSpill = 1;\n  pcacheTrace((\"%p.OPEN szPage %d bPurgeable %d\\n\",p,szPage,bPurgeable));\n  return sqlite3PcacheSetPageSize(p, szPage);\n}\n\n/*\n** Change the page size for PCache object. The caller must ensure that there\n** are no outstanding page references when this function is called.\n*/\nint sqlite3PcacheSetPageSize(PCache *pCache, int szPage){\n  assert( pCache->nRefSum==0 && pCache->pDirty==0 );\n  if( pCache->szPage ){\n    sqlite3_pcache *pNew;\n    pNew = sqlite3GlobalConfig.pcache2.xCreate(\n                szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),\n                pCache->bPurgeable\n    );\n    if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n    sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));\n    if( pCache->pCache ){\n      sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n    }\n    pCache->pCache = pNew;\n    pCache->szPage = szPage;\n    pcacheTrace((\"%p.PAGESIZE %d\\n\",pCache,szPage));\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Try to obtain a page from the cache.\n**\n** This routine returns a pointer to an sqlite3_pcache_page object if\n** such an object is already in cache, or if a new one is created.\n** This routine returns a NULL pointer if the object was not in cache\n** and could not be created.\n**\n** The createFlags should be 0 to check for existing pages and should\n** be 3 (not 1, but 3) to try to create a new page.\n**\n** If the createFlag is 0, then NULL is always returned if the page\n** is not already in the cache.  If createFlag is 1, then a new page\n** is created only if that can be done without spilling dirty pages\n** and without exceeding the cache size limit.\n**\n** The caller needs to invoke sqlite3PcacheFetchFinish() to properly\n** initialize the sqlite3_pcache_page object and convert it into a\n** PgHdr object.  The sqlite3PcacheFetch() and sqlite3PcacheFetchFinish()\n** routines are split this way for performance reasons. When separated\n** they can both (usually) operate without having to push values to\n** the stack on entry and pop them back off on exit, which saves a\n** lot of pushing and popping.\n*/\nsqlite3_pcache_page *sqlite3PcacheFetch(\n  PCache *pCache,       /* Obtain the page from this cache */\n  Pgno pgno,            /* Page number to obtain */\n  int createFlag        /* If true, create page if it does not exist already */\n){\n  int eCreate;\n  sqlite3_pcache_page *pRes;\n\n  assert( pCache!=0 );\n  assert( pCache->pCache!=0 );\n  assert( createFlag==3 || createFlag==0 );\n  assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );\n\n  /* eCreate defines what to do if the page does not exist.\n  **    0     Do not allocate a new page.  (createFlag==0)\n  **    1     Allocate a new page if doing so is inexpensive.\n  **          (createFlag==1 AND bPurgeable AND pDirty)\n  **    2     Allocate a new page even it doing so is difficult.\n  **          (createFlag==1 AND !(bPurgeable AND pDirty)\n  */\n  eCreate = createFlag & pCache->eCreate;\n  assert( eCreate==0 || eCreate==1 || eCreate==2 );\n  assert( createFlag==0 || pCache->eCreate==eCreate );\n  assert( createFlag==0 || eCreate==1+(!pCache->bPurgeable||!pCache->pDirty) );\n  pRes = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, eCreate);\n  pcacheTrace((\"%p.FETCH %d%s (result: %p)\\n\",pCache,pgno,\n               createFlag?\" create\":\"\",pRes));\n  return pRes;\n}\n\n/*\n** If the sqlite3PcacheFetch() routine is unable to allocate a new\n** page because no clean pages are available for reuse and the cache\n** size limit has been reached, then this routine can be invoked to \n** try harder to allocate a page.  This routine might invoke the stress\n** callback to spill dirty pages to the journal.  It will then try to\n** allocate the new page and will only fail to allocate a new page on\n** an OOM error.\n**\n** This routine should be invoked only after sqlite3PcacheFetch() fails.\n*/\nint sqlite3PcacheFetchStress(\n  PCache *pCache,                 /* Obtain the page from this cache */\n  Pgno pgno,                      /* Page number to obtain */\n  sqlite3_pcache_page **ppPage    /* Write result here */\n){\n  PgHdr *pPg;\n  if( pCache->eCreate==2 ) return 0;\n\n  if( sqlite3PcachePagecount(pCache)>pCache->szSpill ){\n    /* Find a dirty page to write-out and recycle. First try to find a \n    ** page that does not require a journal-sync (one with PGHDR_NEED_SYNC\n    ** cleared), but if that is not possible settle for any other \n    ** unreferenced dirty page.\n    **\n    ** If the LRU page in the dirty list that has a clear PGHDR_NEED_SYNC\n    ** flag is currently referenced, then the following may leave pSynced\n    ** set incorrectly (pointing to other than the LRU page with NEED_SYNC\n    ** cleared). This is Ok, as pSynced is just an optimization.  */\n    for(pPg=pCache->pSynced; \n        pPg && (pPg->nRef || (pPg->flags&PGHDR_NEED_SYNC)); \n        pPg=pPg->pDirtyPrev\n    );\n    pCache->pSynced = pPg;\n    if( !pPg ){\n      for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pDirtyPrev);\n    }\n    if( pPg ){\n      int rc;\n#ifdef SQLITE_LOG_CACHE_SPILL\n      sqlite3_log(SQLITE_FULL, \n                  \"spill page %d making room for %d - cache used: %d/%d\",\n                  pPg->pgno, pgno,\n                  sqlite3GlobalConfig.pcache.xPagecount(pCache->pCache),\n                numberOfCachePages(pCache));\n#endif\n      pcacheTrace((\"%p.SPILL %d\\n\",pCache,pPg->pgno));\n      rc = pCache->xStress(pCache->pStress, pPg);\n      pcacheDump(pCache);\n      if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  *ppPage = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, pgno, 2);\n  return *ppPage==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK;\n}\n\n/*\n** This is a helper routine for sqlite3PcacheFetchFinish()\n**\n** In the uncommon case where the page being fetched has not been\n** initialized, this routine is invoked to do the initialization.\n** This routine is broken out into a separate function since it\n** requires extra stack manipulation that can be avoided in the common\n** case.\n*/\nstatic SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr*)pPage->pExtra;\n  assert( pPgHdr->pPage==0 );\n  memset(&pPgHdr->pDirty, 0, sizeof(PgHdr) - offsetof(PgHdr,pDirty));\n  pPgHdr->pPage = pPage;\n  pPgHdr->pData = pPage->pBuf;\n  pPgHdr->pExtra = (void *)&pPgHdr[1];\n  memset(pPgHdr->pExtra, 0, 8);\n  pPgHdr->pCache = pCache;\n  pPgHdr->pgno = pgno;\n  pPgHdr->flags = PGHDR_CLEAN;\n  return sqlite3PcacheFetchFinish(pCache,pgno,pPage);\n}\n\n/*\n** This routine converts the sqlite3_pcache_page object returned by\n** sqlite3PcacheFetch() into an initialized PgHdr object.  This routine\n** must be called after sqlite3PcacheFetch() in order to get a usable\n** result.\n*/\nPgHdr *sqlite3PcacheFetchFinish(\n  PCache *pCache,             /* Obtain the page from this cache */\n  Pgno pgno,                  /* Page number obtained */\n  sqlite3_pcache_page *pPage  /* Page obtained by prior PcacheFetch() call */\n){\n  PgHdr *pPgHdr;\n\n  assert( pPage!=0 );\n  pPgHdr = (PgHdr *)pPage->pExtra;\n\n  if( !pPgHdr->pPage ){\n    return pcacheFetchFinishWithInit(pCache, pgno, pPage);\n  }\n  pCache->nRefSum++;\n  pPgHdr->nRef++;\n  assert( sqlite3PcachePageSanity(pPgHdr) );\n  return pPgHdr;\n}\n\n/*\n** Decrement the reference count on a page. If the page is clean and the\n** reference count drops to 0, then it is made eligible for recycling.\n*/\nvoid SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){\n  assert( p->nRef>0 );\n  p->pCache->nRefSum--;\n  if( (--p->nRef)==0 ){\n    if( p->flags&PGHDR_CLEAN ){\n      pcacheUnpin(p);\n    }else{\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n    }\n  }\n}\n\n/*\n** Increase the reference count of a supplied page by 1.\n*/\nvoid sqlite3PcacheRef(PgHdr *p){\n  assert(p->nRef>0);\n  assert( sqlite3PcachePageSanity(p) );\n  p->nRef++;\n  p->pCache->nRefSum++;\n}\n\n/*\n** Drop a page from the cache. There must be exactly one reference to the\n** page. This function deletes that reference, so after it returns the\n** page pointed to by p is invalid.\n*/\nvoid sqlite3PcacheDrop(PgHdr *p){\n  assert( p->nRef==1 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags&PGHDR_DIRTY ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n  }\n  p->pCache->nRefSum--;\n  sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1);\n}\n\n/*\n** Make sure the page is marked as dirty. If it isn't dirty already,\n** make it so.\n*/\nvoid sqlite3PcacheMakeDirty(PgHdr *p){\n  assert( p->nRef>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){    /*OPTIMIZATION-IF-FALSE*/\n    p->flags &= ~PGHDR_DONT_WRITE;\n    if( p->flags & PGHDR_CLEAN ){\n      p->flags ^= (PGHDR_DIRTY|PGHDR_CLEAN);\n      pcacheTrace((\"%p.DIRTY %d\\n\",p->pCache,p->pgno));\n      assert( (p->flags & (PGHDR_DIRTY|PGHDR_CLEAN))==PGHDR_DIRTY );\n      pcacheManageDirtyList(p, PCACHE_DIRTYLIST_ADD);\n    }\n    assert( sqlite3PcachePageSanity(p) );\n  }\n}\n\n/*\n** Make sure the page is marked as clean. If it isn't clean already,\n** make it so.\n*/\nvoid sqlite3PcacheMakeClean(PgHdr *p){\n  assert( sqlite3PcachePageSanity(p) );\n  if( ALWAYS((p->flags & PGHDR_DIRTY)!=0) ){\n    assert( (p->flags & PGHDR_CLEAN)==0 );\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE);\n    p->flags &= ~(PGHDR_DIRTY|PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n    p->flags |= PGHDR_CLEAN;\n    pcacheTrace((\"%p.CLEAN %d\\n\",p->pCache,p->pgno));\n    assert( sqlite3PcachePageSanity(p) );\n    if( p->nRef==0 ){\n      pcacheUnpin(p);\n    }\n  }\n}\n\n/*\n** Make every page in the cache clean.\n*/\nvoid sqlite3PcacheCleanAll(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAN-ALL\\n\",pCache));\n  while( (p = pCache->pDirty)!=0 ){\n    sqlite3PcacheMakeClean(p);\n  }\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC and PGHDR_WRITEABLE flag from all dirty pages.\n*/\nvoid sqlite3PcacheClearWritable(PCache *pCache){\n  PgHdr *p;\n  pcacheTrace((\"%p.CLEAR-WRITEABLE\\n\",pCache));\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~(PGHDR_NEED_SYNC|PGHDR_WRITEABLE);\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Clear the PGHDR_NEED_SYNC flag from all dirty pages.\n*/\nvoid sqlite3PcacheClearSyncFlags(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->flags &= ~PGHDR_NEED_SYNC;\n  }\n  pCache->pSynced = pCache->pDirtyTail;\n}\n\n/*\n** Change the page number of page p to newPgno. \n*/\nvoid sqlite3PcacheMove(PgHdr *p, Pgno newPgno){\n  PCache *pCache = p->pCache;\n  assert( p->nRef>0 );\n  assert( newPgno>0 );\n  assert( sqlite3PcachePageSanity(p) );\n  pcacheTrace((\"%p.MOVE %d -> %d\\n\",pCache,p->pgno,newPgno));\n  sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);\n  p->pgno = newPgno;\n  if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){\n    pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);\n  }\n}\n\n/*\n** Drop every cache entry whose page number is greater than \"pgno\". The\n** caller must ensure that there are no outstanding references to any pages\n** other than page 1 with a page number greater than pgno.\n**\n** If there is a reference to page 1 and the pgno parameter passed to this\n** function is 0, then the data area associated with page 1 is zeroed, but\n** the page object is not dropped.\n*/\nvoid sqlite3PcacheTruncate(PCache *pCache, Pgno pgno){\n  if( pCache->pCache ){\n    PgHdr *p;\n    PgHdr *pNext;\n    pcacheTrace((\"%p.TRUNCATE %d\\n\",pCache,pgno));\n    for(p=pCache->pDirty; p; p=pNext){\n      pNext = p->pDirtyNext;\n      /* This routine never gets call with a positive pgno except right\n      ** after sqlite3PcacheCleanAll().  So if there are dirty pages,\n      ** it must be that pgno==0.\n      */\n      assert( p->pgno>0 );\n      if( p->pgno>pgno ){\n        assert( p->flags&PGHDR_DIRTY );\n        sqlite3PcacheMakeClean(p);\n      }\n    }\n    if( pgno==0 && pCache->nRefSum ){\n      sqlite3_pcache_page *pPage1;\n      pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0);\n      if( ALWAYS(pPage1) ){  /* Page 1 is always available in cache, because\n                             ** pCache->nRefSum>0 */\n        memset(pPage1->pBuf, 0, pCache->szPage);\n        pgno = 1;\n      }\n    }\n    sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1);\n  }\n}\n\n/*\n** Close a cache.\n*/\nvoid sqlite3PcacheClose(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  pcacheTrace((\"%p.CLOSE\\n\",pCache));\n  sqlite3GlobalConfig.pcache2.xDestroy(pCache->pCache);\n}\n\n/* \n** Discard the contents of the cache.\n*/\nvoid sqlite3PcacheClear(PCache *pCache){\n  sqlite3PcacheTruncate(pCache, 0);\n}\n\n/*\n** Merge two lists of pages connected by pDirty and in pgno order.\n** Do not bother fixing the pDirtyPrev pointers.\n*/\nstatic PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){\n  PgHdr result, *pTail;\n  pTail = &result;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n      if( pA==0 ){\n        pTail->pDirty = pB;\n        break;\n      }\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n      if( pB==0 ){\n        pTail->pDirty = pA;\n        break;\n      }\n    }\n  }\n  return result.pDirty;\n}\n\n/*\n** Sort the list of pages in accending order by pgno.  Pages are\n** connected by pDirty pointers.  The pDirtyPrev pointers are\n** corrupted by this sort.\n**\n** Since there cannot be more than 2^31 distinct pages in a database,\n** there cannot be more than 31 buckets required by the merge sorter.\n** One extra bucket is added to catch overflow in case something\n** ever changes to make the previous sentence incorrect.\n*/\n#define N_SORT_BUCKET  32\nstatic PgHdr *pcacheSortDirtyList(PgHdr *pIn){\n  PgHdr *a[N_SORT_BUCKET], *p;\n  int i;\n  memset(a, 0, sizeof(a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; ALWAYS(i<N_SORT_BUCKET-1); i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = pcacheMergeDirtyList(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( NEVER(i==N_SORT_BUCKET-1) ){\n      /* To get here, there need to be 2^(N_SORT_BUCKET) elements in\n      ** the input list.  But that is impossible.\n      */\n      a[i] = pcacheMergeDirtyList(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<N_SORT_BUCKET; i++){\n    if( a[i]==0 ) continue;\n    p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];\n  }\n  return p;\n}\n\n/*\n** Return a list of all dirty pages in the cache, sorted by page number.\n*/\nPgHdr *sqlite3PcacheDirtyList(PCache *pCache){\n  PgHdr *p;\n  for(p=pCache->pDirty; p; p=p->pDirtyNext){\n    p->pDirty = p->pDirtyNext;\n  }\n  return pcacheSortDirtyList(pCache->pDirty);\n}\n\n/* \n** Return the total number of references to all pages held by the cache.\n**\n** This is not the total number of pages referenced, but the sum of the\n** reference count for all pages.\n*/\nint sqlite3PcacheRefCount(PCache *pCache){\n  return pCache->nRefSum;\n}\n\n/*\n** Return the number of references to the page supplied as an argument.\n*/\nint sqlite3PcachePageRefcount(PgHdr *p){\n  return p->nRef;\n}\n\n/* \n** Return the total number of pages in the cache.\n*/\nint sqlite3PcachePagecount(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  return sqlite3GlobalConfig.pcache2.xPagecount(pCache->pCache);\n}\n\n#ifdef SQLITE_TEST\n/*\n** Get the suggested cache-size value.\n*/\nint sqlite3PcacheGetCachesize(PCache *pCache){\n  return numberOfCachePages(pCache);\n}\n#endif\n\n/*\n** Set the suggested cache-size value.\n*/\nvoid sqlite3PcacheSetCachesize(PCache *pCache, int mxPage){\n  assert( pCache->pCache!=0 );\n  pCache->szCache = mxPage;\n  sqlite3GlobalConfig.pcache2.xCachesize(pCache->pCache,\n                                         numberOfCachePages(pCache));\n}\n\n/*\n** Set the suggested cache-spill value.  Make no changes if if the\n** argument is zero.  Return the effective cache-spill size, which will\n** be the larger of the szSpill and szCache.\n*/\nint sqlite3PcacheSetSpillsize(PCache *p, int mxPage){\n  int res;\n  assert( p->pCache!=0 );\n  if( mxPage ){\n    if( mxPage<0 ){\n      mxPage = (int)((-1024*(i64)mxPage)/(p->szPage+p->szExtra));\n    }\n    p->szSpill = mxPage;\n  }\n  res = numberOfCachePages(p);\n  if( res<p->szSpill ) res = p->szSpill; \n  return res;\n}\n\n/*\n** Free up as much memory as possible from the page cache.\n*/\nvoid sqlite3PcacheShrink(PCache *pCache){\n  assert( pCache->pCache!=0 );\n  sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);\n}\n\n/*\n** Return the size of the header added by this middleware layer\n** in the page-cache hierarchy.\n*/\nint sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }\n\n/*\n** Return the number of dirty pages currently in the cache, as a percentage\n** of the configured cache size.\n*/\nint sqlite3PCachePercentDirty(PCache *pCache){\n  PgHdr *pDirty;\n  int nDirty = 0;\n  int nCache = numberOfCachePages(pCache);\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext) nDirty++;\n  return nCache ? (int)(((i64)nDirty * 100) / nCache) : 0;\n}\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/*\n** For all dirty pages currently in the cache, invoke the specified\n** callback. This is only used if the SQLITE_CHECK_PAGES macro is\n** defined.\n*/\nvoid sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)){\n  PgHdr *pDirty;\n  for(pDirty=pCache->pDirty; pDirty; pDirty=pDirty->pDirtyNext){\n    xIter(pDirty);\n  }\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pcache.h",
    "content": "/*\n** 2008 August 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the sqlite page cache\n** subsystem. \n*/\n\n#ifndef _PCACHE_H_\n\ntypedef struct PgHdr PgHdr;\ntypedef struct PCache PCache;\n\n/*\n** Every page in the cache is controlled by an instance of the following\n** structure.\n*/\nstruct PgHdr {\n  sqlite3_pcache_page *pPage;    /* Pcache object page handle */\n  void *pData;                   /* Page data */\n  void *pExtra;                  /* Extra content */\n  PCache *pCache;                /* PRIVATE: Cache that owns this page */\n  PgHdr *pDirty;                 /* Transient list of dirty sorted by pgno */\n  Pager *pPager;                 /* The pager this page is part of */\n  Pgno pgno;                     /* Page number for this page */\n#ifdef SQLITE_CHECK_PAGES\n  u32 pageHash;                  /* Hash of page content */\n#endif\n  u16 flags;                     /* PGHDR flags defined below */\n\n  /**********************************************************************\n  ** Elements above, except pCache, are public.  All that follow are \n  ** private to pcache.c and should not be accessed by other modules.\n  ** pCache is grouped with the public elements for efficiency.\n  */\n  i16 nRef;                      /* Number of users of this page */\n  PgHdr *pDirtyNext;             /* Next element in list of dirty pages */\n  PgHdr *pDirtyPrev;             /* Previous element in list of dirty pages */\n                          /* NB: pDirtyNext and pDirtyPrev are undefined if the\n                          ** PgHdr object is not dirty */\n};\n\n/* Bit values for PgHdr.flags */\n#define PGHDR_CLEAN           0x001  /* Page not on the PCache.pDirty list */\n#define PGHDR_DIRTY           0x002  /* Page is on the PCache.pDirty list */\n#define PGHDR_WRITEABLE       0x004  /* Journaled and ready to modify */\n#define PGHDR_NEED_SYNC       0x008  /* Fsync the rollback journal before\n                                     ** writing this page to the database */\n#define PGHDR_DONT_WRITE      0x010  /* Do not write content to disk */\n#define PGHDR_MMAP            0x020  /* This is an mmap page object */\n\n#define PGHDR_WAL_APPEND      0x040  /* Appended to wal file */\n\n/* Initialize and shutdown the page cache subsystem */\nint sqlite3PcacheInitialize(void);\nvoid sqlite3PcacheShutdown(void);\n\n/* Page cache buffer management:\n** These routines implement SQLITE_CONFIG_PAGECACHE.\n*/\nvoid sqlite3PCacheBufferSetup(void *, int sz, int n);\n\n/* Create a new pager cache.\n** Under memory stress, invoke xStress to try to make pages clean.\n** Only clean and unpinned pages can be reclaimed.\n*/\nint sqlite3PcacheOpen(\n  int szPage,                    /* Size of every page */\n  int szExtra,                   /* Extra space associated with each page */\n  int bPurgeable,                /* True if pages are on backing store */\n  int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */\n  void *pStress,                 /* Argument to xStress */\n  PCache *pToInit                /* Preallocated space for the PCache */\n);\n\n/* Modify the page-size after the cache has been created. */\nint sqlite3PcacheSetPageSize(PCache *, int);\n\n/* Return the size in bytes of a PCache object.  Used to preallocate\n** storage space.\n*/\nint sqlite3PcacheSize(void);\n\n/* One release per successful fetch.  Page is pinned until released.\n** Reference counted. \n*/\nsqlite3_pcache_page *sqlite3PcacheFetch(PCache*, Pgno, int createFlag);\nint sqlite3PcacheFetchStress(PCache*, Pgno, sqlite3_pcache_page**);\nPgHdr *sqlite3PcacheFetchFinish(PCache*, Pgno, sqlite3_pcache_page *pPage);\nvoid sqlite3PcacheRelease(PgHdr*);\n\nvoid sqlite3PcacheDrop(PgHdr*);         /* Remove page from cache */\nvoid sqlite3PcacheMakeDirty(PgHdr*);    /* Make sure page is marked dirty */\nvoid sqlite3PcacheMakeClean(PgHdr*);    /* Mark a single page as clean */\nvoid sqlite3PcacheCleanAll(PCache*);    /* Mark all dirty list pages as clean */\nvoid sqlite3PcacheClearWritable(PCache*);\n\n/* Change a page number.  Used by incr-vacuum. */\nvoid sqlite3PcacheMove(PgHdr*, Pgno);\n\n/* Remove all pages with pgno>x.  Reset the cache if x==0 */\nvoid sqlite3PcacheTruncate(PCache*, Pgno x);\n\n/* Get a list of all dirty pages in the cache, sorted by page number */\nPgHdr *sqlite3PcacheDirtyList(PCache*);\n\n/* Reset and close the cache object */\nvoid sqlite3PcacheClose(PCache*);\n\n/* Clear flags from pages of the page cache */\nvoid sqlite3PcacheClearSyncFlags(PCache *);\n\n/* Discard the contents of the cache */\nvoid sqlite3PcacheClear(PCache*);\n\n/* Return the total number of outstanding page references */\nint sqlite3PcacheRefCount(PCache*);\n\n/* Increment the reference count of an existing page */\nvoid sqlite3PcacheRef(PgHdr*);\n\nint sqlite3PcachePageRefcount(PgHdr*);\n\n/* Return the total number of pages stored in the cache */\nint sqlite3PcachePagecount(PCache*);\n\n#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)\n/* Iterate through all dirty pages currently stored in the cache. This\n** interface is only available if SQLITE_CHECK_PAGES is defined when the \n** library is built.\n*/\nvoid sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *));\n#endif\n\n#if defined(SQLITE_DEBUG)\n/* Check invariants on a PgHdr object */\nint sqlite3PcachePageSanity(PgHdr*);\n#endif\n\n/* Set and get the suggested cache-size for the specified pager-cache.\n**\n** If no global maximum is configured, then the system attempts to limit\n** the total number of pages cached by purgeable pager-caches to the sum\n** of the suggested cache-sizes.\n*/\nvoid sqlite3PcacheSetCachesize(PCache *, int);\n#ifdef SQLITE_TEST\nint sqlite3PcacheGetCachesize(PCache *);\n#endif\n\n/* Set or get the suggested spill-size for the specified pager-cache.\n**\n** The spill-size is the minimum number of pages in cache before the cache\n** will attempt to spill dirty pages by calling xStress.\n*/\nint sqlite3PcacheSetSpillsize(PCache *, int);\n\n/* Free up as much memory as possible from the page cache */\nvoid sqlite3PcacheShrink(PCache*);\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/* Try to return memory used by the pcache module to the main memory heap */\nint sqlite3PcacheReleaseMemory(int);\n#endif\n\n#ifdef SQLITE_TEST\nvoid sqlite3PcacheStats(int*,int*,int*,int*);\n#endif\n\nvoid sqlite3PCacheSetDefault(void);\n\n/* Return the header size */\nint sqlite3HeaderSizePcache(void);\nint sqlite3HeaderSizePcache1(void);\n\n/* Number of dirty pages as a percentage of the configured cache size */\nint sqlite3PCachePercentDirty(PCache*);\n\n#endif /* _PCACHE_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pcache1.c",
    "content": "/*\n** 2008 November 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements the default page cache implementation (the\n** sqlite3_pcache interface). It also contains part of the implementation\n** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.\n** If the default page cache implementation is overridden, then neither of\n** these two features are available.\n**\n** A Page cache line looks like this:\n**\n**  -------------------------------------------------------------\n**  |  database page content   |  PgHdr1  |  MemPage  |  PgHdr  |\n**  -------------------------------------------------------------\n**\n** The database page content is up front (so that buffer overreads tend to\n** flow harmlessly into the PgHdr1, MemPage, and PgHdr extensions).   MemPage\n** is the extension added by the btree.c module containing information such\n** as the database page number and how that database page is used.  PgHdr\n** is added by the pcache.c layer and contains information used to keep track\n** of which pages are \"dirty\".  PgHdr1 is an extension added by this\n** module (pcache1.c).  The PgHdr1 header is a subclass of sqlite3_pcache_page.\n** PgHdr1 contains information needed to look up a page by its page number.\n** The superclass sqlite3_pcache_page.pBuf points to the start of the\n** database page content and sqlite3_pcache_page.pExtra points to PgHdr.\n**\n** The size of the extension (MemPage+PgHdr+PgHdr1) can be determined at\n** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size).  The\n** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this\n** size can vary according to architecture, compile-time options, and\n** SQLite library version number.\n**\n** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained\n** using a separate memory allocation from the database page content.  This\n** seeks to overcome the \"clownshoe\" problem (also called \"internal\n** fragmentation\" in academic literature) of allocating a few bytes more\n** than a power of two with the memory allocator rounding up to the next\n** power of two, and leaving the rounded-up space unused.\n**\n** This module tracks pointers to PgHdr1 objects.  Only pcache.c communicates\n** with this module.  Information is passed back and forth as PgHdr1 pointers.\n**\n** The pcache.c and pager.c modules deal pointers to PgHdr objects.\n** The btree.c module deals with pointers to MemPage objects.\n**\n** SOURCE OF PAGE CACHE MEMORY:\n**\n** Memory for a page might come from any of three sources:\n**\n**    (1)  The general-purpose memory allocator - sqlite3Malloc()\n**    (2)  Global page-cache memory provided using sqlite3_config() with\n**         SQLITE_CONFIG_PAGECACHE.\n**    (3)  PCache-local bulk allocation.\n**\n** The third case is a chunk of heap memory (defaulting to 100 pages worth)\n** that is allocated when the page cache is created.  The size of the local\n** bulk allocation can be adjusted using \n**\n**     sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, N).\n**\n** If N is positive, then N pages worth of memory are allocated using a single\n** sqlite3Malloc() call and that memory is used for the first N pages allocated.\n** Or if N is negative, then -1024*N bytes of memory are allocated and used\n** for as many pages as can be accomodated.\n**\n** Only one of (2) or (3) can be used.  Once the memory available to (2) or\n** (3) is exhausted, subsequent allocations fail over to the general-purpose\n** memory allocator (1).\n**\n** Earlier versions of SQLite used only methods (1) and (2).  But experiments\n** show that method (3) with N==100 provides about a 5% performance boost for\n** common workloads.\n*/\n#include \"sqliteInt.h\"\n\ntypedef struct PCache1 PCache1;\ntypedef struct PgHdr1 PgHdr1;\ntypedef struct PgFreeslot PgFreeslot;\ntypedef struct PGroup PGroup;\n\n/*\n** Each cache entry is represented by an instance of the following \n** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of\n** PgHdr1.pCache->szPage bytes is allocated directly before this structure \n** in memory.\n*/\nstruct PgHdr1 {\n  sqlite3_pcache_page page;      /* Base class. Must be first. pBuf & pExtra */\n  unsigned int iKey;             /* Key value (page number) */\n  u8 isBulkLocal;                /* This page from bulk local storage */\n  u8 isAnchor;                   /* This is the PGroup.lru element */\n  PgHdr1 *pNext;                 /* Next in hash table chain */\n  PCache1 *pCache;               /* Cache that currently owns this page */\n  PgHdr1 *pLruNext;              /* Next in LRU list of unpinned pages */\n  PgHdr1 *pLruPrev;              /* Previous in LRU list of unpinned pages */\n};\n\n/*\n** A page is pinned if it is no on the LRU list\n*/\n#define PAGE_IS_PINNED(p)    ((p)->pLruNext==0)\n#define PAGE_IS_UNPINNED(p)  ((p)->pLruNext!=0)\n\n/* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set \n** of one or more PCaches that are able to recycle each other's unpinned\n** pages when they are under memory pressure.  A PGroup is an instance of\n** the following object.\n**\n** This page cache implementation works in one of two modes:\n**\n**   (1)  Every PCache is the sole member of its own PGroup.  There is\n**        one PGroup per PCache.\n**\n**   (2)  There is a single global PGroup that all PCaches are a member\n**        of.\n**\n** Mode 1 uses more memory (since PCache instances are not able to rob\n** unused pages from other PCaches) but it also operates without a mutex,\n** and is therefore often faster.  Mode 2 requires a mutex in order to be\n** threadsafe, but recycles pages more efficiently.\n**\n** For mode (1), PGroup.mutex is NULL.  For mode (2) there is only a single\n** PGroup which is the pcache1.grp global variable and its mutex is\n** SQLITE_MUTEX_STATIC_LRU.\n*/\nstruct PGroup {\n  sqlite3_mutex *mutex;          /* MUTEX_STATIC_LRU or NULL */\n  unsigned int nMaxPage;         /* Sum of nMax for purgeable caches */\n  unsigned int nMinPage;         /* Sum of nMin for purgeable caches */\n  unsigned int mxPinned;         /* nMaxpage + 10 - nMinPage */\n  unsigned int nPurgeable;       /* Number of purgeable pages allocated */\n  PgHdr1 lru;                    /* The beginning and end of the LRU list */\n};\n\n/* Each page cache is an instance of the following object.  Every\n** open database file (including each in-memory database and each\n** temporary or transient database) has a single page cache which\n** is an instance of this object.\n**\n** Pointers to structures of this type are cast and returned as \n** opaque sqlite3_pcache* handles.\n*/\nstruct PCache1 {\n  /* Cache configuration parameters. Page size (szPage) and the purgeable\n  ** flag (bPurgeable) and the pnPurgeable pointer are all set when the\n  ** cache is created and are never changed thereafter. nMax may be \n  ** modified at any time by a call to the pcache1Cachesize() method.\n  ** The PGroup mutex must be held when accessing nMax.\n  */\n  PGroup *pGroup;                     /* PGroup this cache belongs to */\n  unsigned int *pnPurgeable;          /* Pointer to pGroup->nPurgeable */\n  int szPage;                         /* Size of database content section */\n  int szExtra;                        /* sizeof(MemPage)+sizeof(PgHdr) */\n  int szAlloc;                        /* Total size of one pcache line */\n  int bPurgeable;                     /* True if cache is purgeable */\n  unsigned int nMin;                  /* Minimum number of pages reserved */\n  unsigned int nMax;                  /* Configured \"cache_size\" value */\n  unsigned int n90pct;                /* nMax*9/10 */\n  unsigned int iMaxKey;               /* Largest key seen since xTruncate() */\n\n  /* Hash table of all pages. The following variables may only be accessed\n  ** when the accessor is holding the PGroup mutex.\n  */\n  unsigned int nRecyclable;           /* Number of pages in the LRU list */\n  unsigned int nPage;                 /* Total number of pages in apHash */\n  unsigned int nHash;                 /* Number of slots in apHash[] */\n  PgHdr1 **apHash;                    /* Hash table for fast lookup by key */\n  PgHdr1 *pFree;                      /* List of unused pcache-local pages */\n  void *pBulk;                        /* Bulk memory used by pcache-local */\n};\n\n/*\n** Free slots in the allocator used to divide up the global page cache\n** buffer provided using the SQLITE_CONFIG_PAGECACHE mechanism.\n*/\nstruct PgFreeslot {\n  PgFreeslot *pNext;  /* Next free slot */\n};\n\n/*\n** Global data used by this cache.\n*/\nstatic SQLITE_WSD struct PCacheGlobal {\n  PGroup grp;                    /* The global PGroup for mode (2) */\n\n  /* Variables related to SQLITE_CONFIG_PAGECACHE settings.  The\n  ** szSlot, nSlot, pStart, pEnd, nReserve, and isInit values are all\n  ** fixed at sqlite3_initialize() time and do not require mutex protection.\n  ** The nFreeSlot and pFree values do require mutex protection.\n  */\n  int isInit;                    /* True if initialized */\n  int separateCache;             /* Use a new PGroup for each PCache */\n  int nInitPage;                 /* Initial bulk allocation size */   \n  int szSlot;                    /* Size of each free slot */\n  int nSlot;                     /* The number of pcache slots */\n  int nReserve;                  /* Try to keep nFreeSlot above this */\n  void *pStart, *pEnd;           /* Bounds of global page cache memory */\n  /* Above requires no mutex.  Use mutex below for variable that follow. */\n  sqlite3_mutex *mutex;          /* Mutex for accessing the following: */\n  PgFreeslot *pFree;             /* Free page blocks */\n  int nFreeSlot;                 /* Number of unused pcache slots */\n  /* The following value requires a mutex to change.  We skip the mutex on\n  ** reading because (1) most platforms read a 32-bit integer atomically and\n  ** (2) even if an incorrect value is read, no great harm is done since this\n  ** is really just an optimization. */\n  int bUnderPressure;            /* True if low on PAGECACHE memory */\n} pcache1_g;\n\n/*\n** All code in this file should access the global structure above via the\n** alias \"pcache1\". This ensures that the WSD emulation is used when\n** compiling for systems that do not support real WSD.\n*/\n#define pcache1 (GLOBAL(struct PCacheGlobal, pcache1_g))\n\n/*\n** Macros to enter and leave the PCache LRU mutex.\n*/\n#if !defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || SQLITE_THREADSAFE==0\n# define pcache1EnterMutex(X)  assert((X)->mutex==0)\n# define pcache1LeaveMutex(X)  assert((X)->mutex==0)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 0\n#else\n# define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex)\n# define pcache1LeaveMutex(X) sqlite3_mutex_leave((X)->mutex)\n# define PCACHE1_MIGHT_USE_GROUP_MUTEX 1\n#endif\n\n/******************************************************************************/\n/******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/\n\n\n/*\n** This function is called during initialization if a static buffer is \n** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE\n** verb to sqlite3_config(). Parameter pBuf points to an allocation large\n** enough to contain 'n' buffers of 'sz' bytes each.\n**\n** This routine is called from sqlite3_initialize() and so it is guaranteed\n** to be serialized already.  There is no need for further mutexing.\n*/\nvoid sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){\n  if( pcache1.isInit ){\n    PgFreeslot *p;\n    if( pBuf==0 ) sz = n = 0;\n    if( n==0 ) sz = 0;\n    sz = ROUNDDOWN8(sz);\n    pcache1.szSlot = sz;\n    pcache1.nSlot = pcache1.nFreeSlot = n;\n    pcache1.nReserve = n>90 ? 10 : (n/10 + 1);\n    pcache1.pStart = pBuf;\n    pcache1.pFree = 0;\n    pcache1.bUnderPressure = 0;\n    while( n-- ){\n      p = (PgFreeslot*)pBuf;\n      p->pNext = pcache1.pFree;\n      pcache1.pFree = p;\n      pBuf = (void*)&((char*)pBuf)[sz];\n    }\n    pcache1.pEnd = pBuf;\n  }\n}\n\n/*\n** Try to initialize the pCache->pFree and pCache->pBulk fields.  Return\n** true if pCache->pFree ends up containing one or more free pages.\n*/\nstatic int pcache1InitBulk(PCache1 *pCache){\n  i64 szBulk;\n  char *zBulk;\n  if( pcache1.nInitPage==0 ) return 0;\n  /* Do not bother with a bulk allocation if the cache size very small */\n  if( pCache->nMax<3 ) return 0;\n  sqlite3BeginBenignMalloc();\n  if( pcache1.nInitPage>0 ){\n    szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;\n  }else{\n    szBulk = -1024 * (i64)pcache1.nInitPage;\n  }\n  if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){\n    szBulk = pCache->szAlloc*(i64)pCache->nMax;\n  }\n  zBulk = pCache->pBulk = sqlite3Malloc( szBulk );\n  sqlite3EndBenignMalloc();\n  if( zBulk ){\n    int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;\n    do{\n      PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];\n      pX->page.pBuf = zBulk;\n      pX->page.pExtra = &pX[1];\n      pX->isBulkLocal = 1;\n      pX->isAnchor = 0;\n      pX->pNext = pCache->pFree;\n      pCache->pFree = pX;\n      zBulk += pCache->szAlloc;\n    }while( --nBulk );\n  }\n  return pCache->pFree!=0;\n}\n\n/*\n** Malloc function used within this file to allocate space from the buffer\n** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no \n** such buffer exists or there is no space left in it, this function falls \n** back to sqlite3Malloc().\n**\n** Multiple threads can run this routine at the same time.  Global variables\n** in pcache1 need to be protected via mutex.\n*/\nstatic void *pcache1Alloc(int nByte){\n  void *p = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  if( nByte<=pcache1.szSlot ){\n    sqlite3_mutex_enter(pcache1.mutex);\n    p = (PgHdr1 *)pcache1.pFree;\n    if( p ){\n      pcache1.pFree = pcache1.pFree->pNext;\n      pcache1.nFreeSlot--;\n      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n      assert( pcache1.nFreeSlot>=0 );\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);\n    }\n    sqlite3_mutex_leave(pcache1.mutex);\n  }\n  if( p==0 ){\n    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get\n    ** it from sqlite3Malloc instead.\n    */\n    p = sqlite3Malloc(nByte);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    if( p ){\n      int sz = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);\n      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n  }\n  return p;\n}\n\n/*\n** Free an allocated buffer obtained from pcache1Alloc().\n*/\nstatic void pcache1Free(void *p){\n  if( p==0 ) return;\n  if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){\n    PgFreeslot *pSlot;\n    sqlite3_mutex_enter(pcache1.mutex);\n    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);\n    pSlot = (PgFreeslot*)p;\n    pSlot->pNext = pcache1.pFree;\n    pcache1.pFree = pSlot;\n    pcache1.nFreeSlot++;\n    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;\n    assert( pcache1.nFreeSlot<=pcache1.nSlot );\n    sqlite3_mutex_leave(pcache1.mutex);\n  }else{\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n    {\n      int nFreed = 0;\n      nFreed = sqlite3MallocSize(p);\n      sqlite3_mutex_enter(pcache1.mutex);\n      sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);\n      sqlite3_mutex_leave(pcache1.mutex);\n    }\n#endif\n    sqlite3_free(p);\n  }\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** Return the size of a pcache allocation\n*/\nstatic int pcache1MemSize(void *p){\n  if( p>=pcache1.pStart && p<pcache1.pEnd ){\n    return pcache1.szSlot;\n  }else{\n    int iSize;\n    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );\n    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);\n    iSize = sqlite3MallocSize(p);\n    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);\n    return iSize;\n  }\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n/*\n** Allocate a new page object initially associated with cache pCache.\n*/\nstatic PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){\n  PgHdr1 *p = 0;\n  void *pPg;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){\n    p = pCache->pFree;\n    pCache->pFree = p->pNext;\n    p->pNext = 0;\n  }else{\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    /* The group mutex must be released before pcache1Alloc() is called. This\n    ** is because it might call sqlite3_release_memory(), which assumes that \n    ** this mutex is not held. */\n    assert( pcache1.separateCache==0 );\n    assert( pCache->pGroup==&pcache1.grp );\n    pcache1LeaveMutex(pCache->pGroup);\n#endif\n    if( benignMalloc ){ sqlite3BeginBenignMalloc(); }\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    pPg = pcache1Alloc(pCache->szPage);\n    p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);\n    if( !pPg || !p ){\n      pcache1Free(pPg);\n      sqlite3_free(p);\n      pPg = 0;\n    }\n#else\n    pPg = pcache1Alloc(pCache->szAlloc);\n    p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];\n#endif\n    if( benignMalloc ){ sqlite3EndBenignMalloc(); }\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n    pcache1EnterMutex(pCache->pGroup);\n#endif\n    if( pPg==0 ) return 0;\n    p->page.pBuf = pPg;\n    p->page.pExtra = &p[1];\n    p->isBulkLocal = 0;\n    p->isAnchor = 0;\n  }\n  (*pCache->pnPurgeable)++;\n  return p;\n}\n\n/*\n** Free a page object allocated by pcache1AllocPage().\n*/\nstatic void pcache1FreePage(PgHdr1 *p){\n  PCache1 *pCache;\n  assert( p!=0 );\n  pCache = p->pCache;\n  assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) );\n  if( p->isBulkLocal ){\n    p->pNext = pCache->pFree;\n    pCache->pFree = p;\n  }else{\n    pcache1Free(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n    sqlite3_free(p);\n#endif\n  }\n  (*pCache->pnPurgeable)--;\n}\n\n/*\n** Malloc function used by SQLite to obtain space from the buffer configured\n** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer\n** exists, this function falls back to sqlite3Malloc().\n*/\nvoid *sqlite3PageMalloc(int sz){\n  return pcache1Alloc(sz);\n}\n\n/*\n** Free an allocated buffer obtained from sqlite3PageMalloc().\n*/\nvoid sqlite3PageFree(void *p){\n  pcache1Free(p);\n}\n\n\n/*\n** Return true if it desirable to avoid allocating a new page cache\n** entry.\n**\n** If memory was allocated specifically to the page cache using\n** SQLITE_CONFIG_PAGECACHE but that memory has all been used, then\n** it is desirable to avoid allocating a new page cache entry because\n** presumably SQLITE_CONFIG_PAGECACHE was suppose to be sufficient\n** for all page cache needs and we should not need to spill the\n** allocation onto the heap.\n**\n** Or, the heap is used for all page cache memory but the heap is\n** under memory pressure, then again it is desirable to avoid\n** allocating a new page cache entry in order to avoid stressing\n** the heap even further.\n*/\nstatic int pcache1UnderMemoryPressure(PCache1 *pCache){\n  if( pcache1.nSlot && (pCache->szPage+pCache->szExtra)<=pcache1.szSlot ){\n    return pcache1.bUnderPressure;\n  }else{\n    return sqlite3HeapNearlyFull();\n  }\n}\n\n/******************************************************************************/\n/******** General Implementation Functions ************************************/\n\n/*\n** This function is used to resize the hash table used by the cache passed\n** as the first argument.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1ResizeHash(PCache1 *p){\n  PgHdr1 **apNew;\n  unsigned int nNew;\n  unsigned int i;\n\n  assert( sqlite3_mutex_held(p->pGroup->mutex) );\n\n  nNew = p->nHash*2;\n  if( nNew<256 ){\n    nNew = 256;\n  }\n\n  pcache1LeaveMutex(p->pGroup);\n  if( p->nHash ){ sqlite3BeginBenignMalloc(); }\n  apNew = (PgHdr1 **)sqlite3MallocZero(sizeof(PgHdr1 *)*nNew);\n  if( p->nHash ){ sqlite3EndBenignMalloc(); }\n  pcache1EnterMutex(p->pGroup);\n  if( apNew ){\n    for(i=0; i<p->nHash; i++){\n      PgHdr1 *pPage;\n      PgHdr1 *pNext = p->apHash[i];\n      while( (pPage = pNext)!=0 ){\n        unsigned int h = pPage->iKey % nNew;\n        pNext = pPage->pNext;\n        pPage->pNext = apNew[h];\n        apNew[h] = pPage;\n      }\n    }\n    sqlite3_free(p->apHash);\n    p->apHash = apNew;\n    p->nHash = nNew;\n  }\n}\n\n/*\n** This function is used internally to remove the page pPage from the \n** PGroup LRU list, if is part of it. If pPage is not part of the PGroup\n** LRU list, then this function is a no-op.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic PgHdr1 *pcache1PinPage(PgHdr1 *pPage){\n  assert( pPage!=0 );\n  assert( PAGE_IS_UNPINNED(pPage) );\n  assert( pPage->pLruNext );\n  assert( pPage->pLruPrev );\n  assert( sqlite3_mutex_held(pPage->pCache->pGroup->mutex) );\n  pPage->pLruPrev->pLruNext = pPage->pLruNext;\n  pPage->pLruNext->pLruPrev = pPage->pLruPrev;\n  pPage->pLruNext = 0;\n  pPage->pLruPrev = 0;\n  assert( pPage->isAnchor==0 );\n  assert( pPage->pCache->pGroup->lru.isAnchor==1 );\n  pPage->pCache->nRecyclable--;\n  return pPage;\n}\n\n\n/*\n** Remove the page supplied as an argument from the hash table \n** (PCache1.apHash structure) that it is currently stored in.\n** Also free the page if freePage is true.\n**\n** The PGroup mutex must be held when this function is called.\n*/\nstatic void pcache1RemoveFromHash(PgHdr1 *pPage, int freeFlag){\n  unsigned int h;\n  PCache1 *pCache = pPage->pCache;\n  PgHdr1 **pp;\n\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  h = pPage->iKey % pCache->nHash;\n  for(pp=&pCache->apHash[h]; (*pp)!=pPage; pp=&(*pp)->pNext);\n  *pp = (*pp)->pNext;\n\n  pCache->nPage--;\n  if( freeFlag ) pcache1FreePage(pPage);\n}\n\n/*\n** If there are currently more than nMaxPage pages allocated, try\n** to recycle pages to reduce the number allocated to nMaxPage.\n*/\nstatic void pcache1EnforceMaxPage(PCache1 *pCache){\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *p;\n  assert( sqlite3_mutex_held(pGroup->mutex) );\n  while( pGroup->nPurgeable>pGroup->nMaxPage\n      && (p=pGroup->lru.pLruPrev)->isAnchor==0\n  ){\n    assert( p->pCache->pGroup==pGroup );\n    assert( PAGE_IS_UNPINNED(p) );\n    pcache1PinPage(p);\n    pcache1RemoveFromHash(p, 1);\n  }\n  if( pCache->nPage==0 && pCache->pBulk ){\n    sqlite3_free(pCache->pBulk);\n    pCache->pBulk = pCache->pFree = 0;\n  }\n}\n\n/*\n** Discard all pages from cache pCache with a page number (key value) \n** greater than or equal to iLimit. Any pinned pages that meet this \n** criteria are unpinned before they are discarded.\n**\n** The PCache mutex must be held when this function is called.\n*/\nstatic void pcache1TruncateUnsafe(\n  PCache1 *pCache,             /* The cache to truncate */\n  unsigned int iLimit          /* Drop pages with this pgno or larger */\n){\n  TESTONLY( int nPage = 0; )  /* To assert pCache->nPage is correct */\n  unsigned int h, iStop;\n  assert( sqlite3_mutex_held(pCache->pGroup->mutex) );\n  assert( pCache->iMaxKey >= iLimit );\n  assert( pCache->nHash > 0 );\n  if( pCache->iMaxKey - iLimit < pCache->nHash ){\n    /* If we are just shaving the last few pages off the end of the\n    ** cache, then there is no point in scanning the entire hash table.\n    ** Only scan those hash slots that might contain pages that need to\n    ** be removed. */\n    h = iLimit % pCache->nHash;\n    iStop = pCache->iMaxKey % pCache->nHash;\n    TESTONLY( nPage = -10; )  /* Disable the pCache->nPage validity check */\n  }else{\n    /* This is the general case where many pages are being removed.\n    ** It is necessary to scan the entire hash table */\n    h = pCache->nHash/2;\n    iStop = h - 1;\n  }\n  for(;;){\n    PgHdr1 **pp;\n    PgHdr1 *pPage;\n    assert( h<pCache->nHash );\n    pp = &pCache->apHash[h]; \n    while( (pPage = *pp)!=0 ){\n      if( pPage->iKey>=iLimit ){\n        pCache->nPage--;\n        *pp = pPage->pNext;\n        if( PAGE_IS_UNPINNED(pPage) ) pcache1PinPage(pPage);\n        pcache1FreePage(pPage);\n      }else{\n        pp = &pPage->pNext;\n        TESTONLY( if( nPage>=0 ) nPage++; )\n      }\n    }\n    if( h==iStop ) break;\n    h = (h+1) % pCache->nHash;\n  }\n  assert( nPage<0 || pCache->nPage==(unsigned)nPage );\n}\n\n/******************************************************************************/\n/******** sqlite3_pcache Methods **********************************************/\n\n/*\n** Implementation of the sqlite3_pcache.xInit method.\n*/\nstatic int pcache1Init(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit==0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n\n\n  /*\n  ** The pcache1.separateCache variable is true if each PCache has its own\n  ** private PGroup (mode-1).  pcache1.separateCache is false if the single\n  ** PGroup in pcache1.grp is used for all page caches (mode-2).\n  **\n  **   *  Always use a unified cache (mode-2) if ENABLE_MEMORY_MANAGEMENT\n  **\n  **   *  Use a unified cache in single-threaded applications that have\n  **      configured a start-time buffer for use as page-cache memory using\n  **      sqlite3_config(SQLITE_CONFIG_PAGECACHE, pBuf, sz, N) with non-NULL \n  **      pBuf argument.\n  **\n  **   *  Otherwise use separate caches (mode-1)\n  */\n#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)\n  pcache1.separateCache = 0;\n#elif SQLITE_THREADSAFE\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0\n                          || sqlite3GlobalConfig.bCoreMutex>0;\n#else\n  pcache1.separateCache = sqlite3GlobalConfig.pPage==0;\n#endif\n\n#if SQLITE_THREADSAFE\n  if( sqlite3GlobalConfig.bCoreMutex ){\n    pcache1.grp.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_LRU);\n    pcache1.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PMEM);\n  }\n#endif\n  if( pcache1.separateCache\n   && sqlite3GlobalConfig.nPage!=0\n   && sqlite3GlobalConfig.pPage==0\n  ){\n    pcache1.nInitPage = sqlite3GlobalConfig.nPage;\n  }else{\n    pcache1.nInitPage = 0;\n  }\n  pcache1.grp.mxPinned = 10;\n  pcache1.isInit = 1;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShutdown method.\n** Note that the static mutex allocated in xInit does \n** not need to be freed.\n*/\nstatic void pcache1Shutdown(void *NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  assert( pcache1.isInit!=0 );\n  memset(&pcache1, 0, sizeof(pcache1));\n}\n\n/* forward declaration */\nstatic void pcache1Destroy(sqlite3_pcache *p);\n\n/*\n** Implementation of the sqlite3_pcache.xCreate method.\n**\n** Allocate a new cache.\n*/\nstatic sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){\n  PCache1 *pCache;      /* The newly created page cache */\n  PGroup *pGroup;       /* The group the new page cache will belong to */\n  int sz;               /* Bytes of memory required to allocate the new cache */\n\n  assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );\n  assert( szExtra < 300 );\n\n  sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;\n  pCache = (PCache1 *)sqlite3MallocZero(sz);\n  if( pCache ){\n    if( pcache1.separateCache ){\n      pGroup = (PGroup*)&pCache[1];\n      pGroup->mxPinned = 10;\n    }else{\n      pGroup = &pcache1.grp;\n    }\n    if( pGroup->lru.isAnchor==0 ){\n      pGroup->lru.isAnchor = 1;\n      pGroup->lru.pLruPrev = pGroup->lru.pLruNext = &pGroup->lru;\n    }\n    pCache->pGroup = pGroup;\n    pCache->szPage = szPage;\n    pCache->szExtra = szExtra;\n    pCache->szAlloc = szPage + szExtra + ROUND8(sizeof(PgHdr1));\n    pCache->bPurgeable = (bPurgeable ? 1 : 0);\n    pcache1EnterMutex(pGroup);\n    pcache1ResizeHash(pCache);\n    if( bPurgeable ){\n      pCache->nMin = 10;\n      pGroup->nMinPage += pCache->nMin;\n      pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n      pCache->pnPurgeable = &pGroup->nPurgeable;\n    }else{\n      static unsigned int dummyCurrentPage;\n      pCache->pnPurgeable = &dummyCurrentPage;\n    }\n    pcache1LeaveMutex(pGroup);\n    if( pCache->nHash==0 ){\n      pcache1Destroy((sqlite3_pcache*)pCache);\n      pCache = 0;\n    }\n  }\n  return (sqlite3_pcache *)pCache;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xCachesize method. \n**\n** Configure the cache_size limit for a cache.\n*/\nstatic void pcache1Cachesize(sqlite3_pcache *p, int nMax){\n  PCache1 *pCache = (PCache1 *)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    pcache1EnterMutex(pGroup);\n    pGroup->nMaxPage += (nMax - pCache->nMax);\n    pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n    pCache->nMax = nMax;\n    pCache->n90pct = pCache->nMax*9/10;\n    pcache1EnforceMaxPage(pCache);\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xShrink method. \n**\n** Free up as much memory as possible.\n*/\nstatic void pcache1Shrink(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1*)p;\n  if( pCache->bPurgeable ){\n    PGroup *pGroup = pCache->pGroup;\n    int savedMaxPage;\n    pcache1EnterMutex(pGroup);\n    savedMaxPage = pGroup->nMaxPage;\n    pGroup->nMaxPage = 0;\n    pcache1EnforceMaxPage(pCache);\n    pGroup->nMaxPage = savedMaxPage;\n    pcache1LeaveMutex(pGroup);\n  }\n}\n\n/*\n** Implementation of the sqlite3_pcache.xPagecount method. \n*/\nstatic int pcache1Pagecount(sqlite3_pcache *p){\n  int n;\n  PCache1 *pCache = (PCache1*)p;\n  pcache1EnterMutex(pCache->pGroup);\n  n = pCache->nPage;\n  pcache1LeaveMutex(pCache->pGroup);\n  return n;\n}\n\n\n/*\n** Implement steps 3, 4, and 5 of the pcache1Fetch() algorithm described\n** in the header of the pcache1Fetch() procedure.\n**\n** This steps are broken out into a separate procedure because they are\n** usually not needed, and by avoiding the stack initialization required\n** for these steps, the main pcache1Fetch() procedure can run faster.\n*/\nstatic SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(\n  PCache1 *pCache, \n  unsigned int iKey, \n  int createFlag\n){\n  unsigned int nPinned;\n  PGroup *pGroup = pCache->pGroup;\n  PgHdr1 *pPage = 0;\n\n  /* Step 3: Abort if createFlag is 1 but the cache is nearly full */\n  assert( pCache->nPage >= pCache->nRecyclable );\n  nPinned = pCache->nPage - pCache->nRecyclable;\n  assert( pGroup->mxPinned == pGroup->nMaxPage + 10 - pGroup->nMinPage );\n  assert( pCache->n90pct == pCache->nMax*9/10 );\n  if( createFlag==1 && (\n        nPinned>=pGroup->mxPinned\n     || nPinned>=pCache->n90pct\n     || (pcache1UnderMemoryPressure(pCache) && pCache->nRecyclable<nPinned)\n  )){\n    return 0;\n  }\n\n  if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache);\n  assert( pCache->nHash>0 && pCache->apHash );\n\n  /* Step 4. Try to recycle a page. */\n  if( pCache->bPurgeable\n   && !pGroup->lru.pLruPrev->isAnchor\n   && ((pCache->nPage+1>=pCache->nMax) || pcache1UnderMemoryPressure(pCache))\n  ){\n    PCache1 *pOther;\n    pPage = pGroup->lru.pLruPrev;\n    assert( PAGE_IS_UNPINNED(pPage) );\n    pcache1RemoveFromHash(pPage, 0);\n    pcache1PinPage(pPage);\n    pOther = pPage->pCache;\n    if( pOther->szAlloc != pCache->szAlloc ){\n      pcache1FreePage(pPage);\n      pPage = 0;\n    }else{\n      pGroup->nPurgeable -= (pOther->bPurgeable - pCache->bPurgeable);\n    }\n  }\n\n  /* Step 5. If a usable page buffer has still not been found, \n  ** attempt to allocate a new one. \n  */\n  if( !pPage ){\n    pPage = pcache1AllocPage(pCache, createFlag==1);\n  }\n\n  if( pPage ){\n    unsigned int h = iKey % pCache->nHash;\n    pCache->nPage++;\n    pPage->iKey = iKey;\n    pPage->pNext = pCache->apHash[h];\n    pPage->pCache = pCache;\n    pPage->pLruPrev = 0;\n    pPage->pLruNext = 0;\n    *(void **)pPage->page.pExtra = 0;\n    pCache->apHash[h] = pPage;\n    if( iKey>pCache->iMaxKey ){\n      pCache->iMaxKey = iKey;\n    }\n  }\n  return pPage;\n}\n\n/*\n** Implementation of the sqlite3_pcache.xFetch method. \n**\n** Fetch a page by key value.\n**\n** Whether or not a new page may be allocated by this function depends on\n** the value of the createFlag argument.  0 means do not allocate a new\n** page.  1 means allocate a new page if space is easily available.  2 \n** means to try really hard to allocate a new page.\n**\n** For a non-purgeable cache (a cache used as the storage for an in-memory\n** database) there is really no difference between createFlag 1 and 2.  So\n** the calling function (pcache.c) will never have a createFlag of 1 on\n** a non-purgeable cache.\n**\n** There are three different approaches to obtaining space for a page,\n** depending on the value of parameter createFlag (which may be 0, 1 or 2).\n**\n**   1. Regardless of the value of createFlag, the cache is searched for a \n**      copy of the requested page. If one is found, it is returned.\n**\n**   2. If createFlag==0 and the page is not already in the cache, NULL is\n**      returned.\n**\n**   3. If createFlag is 1, and the page is not already in the cache, then\n**      return NULL (do not allocate a new page) if any of the following\n**      conditions are true:\n**\n**       (a) the number of pages pinned by the cache is greater than\n**           PCache1.nMax, or\n**\n**       (b) the number of pages pinned by the cache is greater than\n**           the sum of nMax for all purgeable caches, less the sum of \n**           nMin for all other purgeable caches, or\n**\n**   4. If none of the first three conditions apply and the cache is marked\n**      as purgeable, and if one of the following is true:\n**\n**       (a) The number of pages allocated for the cache is already \n**           PCache1.nMax, or\n**\n**       (b) The number of pages allocated for all purgeable caches is\n**           already equal to or greater than the sum of nMax for all\n**           purgeable caches,\n**\n**       (c) The system is under memory pressure and wants to avoid\n**           unnecessary pages cache entry allocations\n**\n**      then attempt to recycle a page from the LRU list. If it is the right\n**      size, return the recycled buffer. Otherwise, free the buffer and\n**      proceed to step 5. \n**\n**   5. Otherwise, allocate and return a new page buffer.\n**\n** There are two versions of this routine.  pcache1FetchWithMutex() is\n** the general case.  pcache1FetchNoMutex() is a faster implementation for\n** the common case where pGroup->mutex is NULL.  The pcache1Fetch() wrapper\n** invokes the appropriate routine.\n*/\nstatic PgHdr1 *pcache1FetchNoMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = 0;\n\n  /* Step 1: Search the hash table for an existing entry. */\n  pPage = pCache->apHash[iKey % pCache->nHash];\n  while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; }\n\n  /* Step 2: If the page was found in the hash table, then return it.\n  ** If the page was not in the hash table and createFlag is 0, abort.\n  ** Otherwise (page not in hash and createFlag!=0) continue with\n  ** subsequent steps to try to create the page. */\n  if( pPage ){\n    if( PAGE_IS_UNPINNED(pPage) ){\n      return pcache1PinPage(pPage);\n    }else{\n      return pPage;\n    }\n  }else if( createFlag ){\n    /* Steps 3, 4, and 5 implemented by this subroutine */\n    return pcache1FetchStage2(pCache, iKey, createFlag);\n  }else{\n    return 0;\n  }\n}\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\nstatic PgHdr1 *pcache1FetchWithMutex(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage;\n\n  pcache1EnterMutex(pCache->pGroup);\n  pPage = pcache1FetchNoMutex(p, iKey, createFlag);\n  assert( pPage==0 || pCache->iMaxKey>=iKey );\n  pcache1LeaveMutex(pCache->pGroup);\n  return pPage;\n}\n#endif\nstatic sqlite3_pcache_page *pcache1Fetch(\n  sqlite3_pcache *p, \n  unsigned int iKey, \n  int createFlag\n){\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX || defined(SQLITE_DEBUG)\n  PCache1 *pCache = (PCache1 *)p;\n#endif\n\n  assert( offsetof(PgHdr1,page)==0 );\n  assert( pCache->bPurgeable || createFlag!=1 );\n  assert( pCache->bPurgeable || pCache->nMin==0 );\n  assert( pCache->bPurgeable==0 || pCache->nMin==10 );\n  assert( pCache->nMin==0 || pCache->bPurgeable );\n  assert( pCache->nHash>0 );\n#if PCACHE1_MIGHT_USE_GROUP_MUTEX\n  if( pCache->pGroup->mutex ){\n    return (sqlite3_pcache_page*)pcache1FetchWithMutex(p, iKey, createFlag);\n  }else\n#endif\n  {\n    return (sqlite3_pcache_page*)pcache1FetchNoMutex(p, iKey, createFlag);\n  }\n}\n\n\n/*\n** Implementation of the sqlite3_pcache.xUnpin method.\n**\n** Mark a page as unpinned (eligible for asynchronous recycling).\n*/\nstatic void pcache1Unpin(\n  sqlite3_pcache *p, \n  sqlite3_pcache_page *pPg, \n  int reuseUnlikely\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PGroup *pGroup = pCache->pGroup;\n \n  assert( pPage->pCache==pCache );\n  pcache1EnterMutex(pGroup);\n\n  /* It is an error to call this function if the page is already \n  ** part of the PGroup LRU list.\n  */\n  assert( pPage->pLruPrev==0 && pPage->pLruNext==0 );\n  assert( PAGE_IS_PINNED(pPage) );\n\n  if( reuseUnlikely || pGroup->nPurgeable>pGroup->nMaxPage ){\n    pcache1RemoveFromHash(pPage, 1);\n  }else{\n    /* Add the page to the PGroup LRU list. */\n    PgHdr1 **ppFirst = &pGroup->lru.pLruNext;\n    pPage->pLruPrev = &pGroup->lru;\n    (pPage->pLruNext = *ppFirst)->pLruPrev = pPage;\n    *ppFirst = pPage;\n    pCache->nRecyclable++;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xRekey method. \n*/\nstatic void pcache1Rekey(\n  sqlite3_pcache *p,\n  sqlite3_pcache_page *pPg,\n  unsigned int iOld,\n  unsigned int iNew\n){\n  PCache1 *pCache = (PCache1 *)p;\n  PgHdr1 *pPage = (PgHdr1 *)pPg;\n  PgHdr1 **pp;\n  unsigned int h; \n  assert( pPage->iKey==iOld );\n  assert( pPage->pCache==pCache );\n\n  pcache1EnterMutex(pCache->pGroup);\n\n  h = iOld%pCache->nHash;\n  pp = &pCache->apHash[h];\n  while( (*pp)!=pPage ){\n    pp = &(*pp)->pNext;\n  }\n  *pp = pPage->pNext;\n\n  h = iNew%pCache->nHash;\n  pPage->iKey = iNew;\n  pPage->pNext = pCache->apHash[h];\n  pCache->apHash[h] = pPage;\n  if( iNew>pCache->iMaxKey ){\n    pCache->iMaxKey = iNew;\n  }\n\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xTruncate method. \n**\n** Discard all unpinned pages in the cache with a page number equal to\n** or greater than parameter iLimit. Any pinned pages with a page number\n** equal to or greater than iLimit are implicitly unpinned.\n*/\nstatic void pcache1Truncate(sqlite3_pcache *p, unsigned int iLimit){\n  PCache1 *pCache = (PCache1 *)p;\n  pcache1EnterMutex(pCache->pGroup);\n  if( iLimit<=pCache->iMaxKey ){\n    pcache1TruncateUnsafe(pCache, iLimit);\n    pCache->iMaxKey = iLimit-1;\n  }\n  pcache1LeaveMutex(pCache->pGroup);\n}\n\n/*\n** Implementation of the sqlite3_pcache.xDestroy method. \n**\n** Destroy a cache allocated using pcache1Create().\n*/\nstatic void pcache1Destroy(sqlite3_pcache *p){\n  PCache1 *pCache = (PCache1 *)p;\n  PGroup *pGroup = pCache->pGroup;\n  assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );\n  pcache1EnterMutex(pGroup);\n  if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);\n  assert( pGroup->nMaxPage >= pCache->nMax );\n  pGroup->nMaxPage -= pCache->nMax;\n  assert( pGroup->nMinPage >= pCache->nMin );\n  pGroup->nMinPage -= pCache->nMin;\n  pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;\n  pcache1EnforceMaxPage(pCache);\n  pcache1LeaveMutex(pGroup);\n  sqlite3_free(pCache->pBulk);\n  sqlite3_free(pCache->apHash);\n  sqlite3_free(pCache);\n}\n\n/*\n** This function is called during initialization (sqlite3_initialize()) to\n** install the default pluggable cache module, assuming the user has not\n** already provided an alternative.\n*/\nvoid sqlite3PCacheSetDefault(void){\n  static const sqlite3_pcache_methods2 defaultMethods = {\n    1,                       /* iVersion */\n    0,                       /* pArg */\n    pcache1Init,             /* xInit */\n    pcache1Shutdown,         /* xShutdown */\n    pcache1Create,           /* xCreate */\n    pcache1Cachesize,        /* xCachesize */\n    pcache1Pagecount,        /* xPagecount */\n    pcache1Fetch,            /* xFetch */\n    pcache1Unpin,            /* xUnpin */\n    pcache1Rekey,            /* xRekey */\n    pcache1Truncate,         /* xTruncate */\n    pcache1Destroy,          /* xDestroy */\n    pcache1Shrink            /* xShrink */\n  };\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);\n}\n\n/*\n** Return the size of the header on each page of this PCACHE implementation.\n*/\nint sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }\n\n/*\n** Return the global mutex used by this PCACHE implementation.  The\n** sqlite3_status() routine needs access to this mutex.\n*/\nsqlite3_mutex *sqlite3Pcache1Mutex(void){\n  return pcache1.mutex;\n}\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n/*\n** This function is called to free superfluous dynamically allocated memory\n** held by the pager system. Memory in use by any SQLite pager allocated\n** by the current thread may be sqlite3_free()ed.\n**\n** nReq is the number of bytes of memory required. Once this much has\n** been released, the function returns. The return value is the total number \n** of bytes of memory released.\n*/\nint sqlite3PcacheReleaseMemory(int nReq){\n  int nFree = 0;\n  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );\n  assert( sqlite3_mutex_notheld(pcache1.mutex) );\n  if( sqlite3GlobalConfig.pPage==0 ){\n    PgHdr1 *p;\n    pcache1EnterMutex(&pcache1.grp);\n    while( (nReq<0 || nFree<nReq)\n       &&  (p=pcache1.grp.lru.pLruPrev)!=0\n       &&  p->isAnchor==0\n    ){\n      nFree += pcache1MemSize(p->page.pBuf);\n#ifdef SQLITE_PCACHE_SEPARATE_HEADER\n      nFree += sqlite3MemSize(p);\n#endif\n      assert( PAGE_IS_UNPINNED(p) );\n      pcache1PinPage(p);\n      pcache1RemoveFromHash(p, 1);\n    }\n    pcache1LeaveMutex(&pcache1.grp);\n  }\n  return nFree;\n}\n#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */\n\n#ifdef SQLITE_TEST\n/*\n** This function is used by test procedures to inspect the internal state\n** of the global cache.\n*/\nvoid sqlite3PcacheStats(\n  int *pnCurrent,      /* OUT: Total number of pages cached */\n  int *pnMax,          /* OUT: Global maximum cache size */\n  int *pnMin,          /* OUT: Sum of PCache1.nMin for purgeable caches */\n  int *pnRecyclable    /* OUT: Total number of pages available for recycling */\n){\n  PgHdr1 *p;\n  int nRecyclable = 0;\n  for(p=pcache1.grp.lru.pLruNext; p && !p->isAnchor; p=p->pLruNext){\n    assert( PAGE_IS_UNPINNED(p) );\n    nRecyclable++;\n  }\n  *pnCurrent = pcache1.grp.nPurgeable;\n  *pnMax = (int)pcache1.grp.nMaxPage;\n  *pnMin = (int)pcache1.grp.nMinPage;\n  *pnRecyclable = nRecyclable;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pragma.c",
    "content": "/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the PRAGMA command.\n*/\n#include \"sqliteInt.h\"\n\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n\n/***************************************************************************\n** The \"pragma.h\" include file is an automatically generated file that\n** that includes the PragType_XXXX macro definitions and the aPragmaName[]\n** object.  This ensures that the aPragmaName[] table is arranged in\n** lexicographical order to facility a binary search of the pragma name.\n** Do not edit pragma.h directly.  Edit and rerun the script in at \n** ../tool/mkpragmatab.tcl. */\n#include \"pragma.h\"\n\n/*\n** Interpret the given string as a safety level.  Return 0 for OFF,\n** 1 for ON or NORMAL, 2 for FULL, and 3 for EXTRA.  Return 1 for an empty or \n** unrecognized string argument.  The FULL and EXTRA option is disallowed\n** if the omitFull parameter it 1.\n**\n** Note that the values returned are one less that the values that\n** should be passed into sqlite3BtreeSetSafetyLevel().  The is done\n** to support legacy SQL code.  The safety level used to be boolean\n** and older scripts may have used numbers 0 for OFF and 1 for ON.\n*/\nstatic u8 getSafetyLevel(const char *z, int omitFull, u8 dflt){\n                             /* 123456789 123456789 123 */\n  static const char zText[] = \"onoffalseyestruextrafull\";\n  static const u8 iOffset[] = {0, 1, 2,  4,    9,  12,  15,   20};\n  static const u8 iLength[] = {2, 2, 3,  5,    3,   4,   5,    4};\n  static const u8 iValue[] =  {1, 0, 0,  0,    1,   1,   3,    2};\n                            /* on no off false yes true extra full */\n  int i, n;\n  if( sqlite3Isdigit(*z) ){\n    return (u8)sqlite3Atoi(z);\n  }\n  n = sqlite3Strlen30(z);\n  for(i=0; i<ArraySize(iLength); i++){\n    if( iLength[i]==n && sqlite3StrNICmp(&zText[iOffset[i]],z,n)==0\n     && (!omitFull || iValue[i]<=1)\n    ){\n      return iValue[i];\n    }\n  }\n  return dflt;\n}\n\n/*\n** Interpret the given string as a boolean value.\n*/\nu8 sqlite3GetBoolean(const char *z, u8 dflt){\n  return getSafetyLevel(z,1,dflt)!=0;\n}\n\n/* The sqlite3GetBoolean() function is used by other modules but the\n** remainder of this file is specific to PRAGMA processing.  So omit\n** the rest of the file if PRAGMAs are omitted from the build.\n*/\n#if !defined(SQLITE_OMIT_PRAGMA)\n\n/*\n** Interpret the given string as a locking mode value.\n*/\nstatic int getLockingMode(const char *z){\n  if( z ){\n    if( 0==sqlite3StrICmp(z, \"exclusive\") ) return PAGER_LOCKINGMODE_EXCLUSIVE;\n    if( 0==sqlite3StrICmp(z, \"normal\") ) return PAGER_LOCKINGMODE_NORMAL;\n  }\n  return PAGER_LOCKINGMODE_QUERY;\n}\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n/*\n** Interpret the given string as an auto-vacuum mode value.\n**\n** The following strings, \"none\", \"full\" and \"incremental\" are \n** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.\n*/\nstatic int getAutoVacuum(const char *z){\n  int i;\n  if( 0==sqlite3StrICmp(z, \"none\") ) return BTREE_AUTOVACUUM_NONE;\n  if( 0==sqlite3StrICmp(z, \"full\") ) return BTREE_AUTOVACUUM_FULL;\n  if( 0==sqlite3StrICmp(z, \"incremental\") ) return BTREE_AUTOVACUUM_INCR;\n  i = sqlite3Atoi(z);\n  return (u8)((i>=0&&i<=2)?i:0);\n}\n#endif /* ifndef SQLITE_OMIT_AUTOVACUUM */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Interpret the given string as a temp db location. Return 1 for file\n** backed temporary databases, 2 for the Red-Black tree in memory database\n** and 0 to use the compile-time default.\n*/\nstatic int getTempStore(const char *z){\n  if( z[0]>='0' && z[0]<='2' ){\n    return z[0] - '0';\n  }else if( sqlite3StrICmp(z, \"file\")==0 ){\n    return 1;\n  }else if( sqlite3StrICmp(z, \"memory\")==0 ){\n    return 2;\n  }else{\n    return 0;\n  }\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** Invalidate temp storage, either when the temp storage is changed\n** from default, or when 'file' and the temp_store_directory has changed\n*/\nstatic int invalidateTempStorage(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  if( db->aDb[1].pBt!=0 ){\n    if( !db->autoCommit || sqlite3BtreeIsInReadTrans(db->aDb[1].pBt) ){\n      sqlite3ErrorMsg(pParse, \"temporary storage cannot be changed \"\n        \"from within a transaction\");\n      return SQLITE_ERROR;\n    }\n    sqlite3BtreeClose(db->aDb[1].pBt);\n    db->aDb[1].pBt = 0;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n/*\n** If the TEMP database is open, close it and mark the database schema\n** as needing reloading.  This must be done when using the SQLITE_TEMP_STORE\n** or DEFAULT_TEMP_STORE pragmas.\n*/\nstatic int changeTempStorage(Parse *pParse, const char *zStorageType){\n  int ts = getTempStore(zStorageType);\n  sqlite3 *db = pParse->db;\n  if( db->temp_store==ts ) return SQLITE_OK;\n  if( invalidateTempStorage( pParse ) != SQLITE_OK ){\n    return SQLITE_ERROR;\n  }\n  db->temp_store = (u8)ts;\n  return SQLITE_OK;\n}\n#endif /* SQLITE_PAGER_PRAGMAS */\n\n/*\n** Set result column names for a pragma.\n*/\nstatic void setPragmaResultColumnNames(\n  Vdbe *v,                     /* The query under construction */\n  const PragmaName *pPragma    /* The pragma */\n){\n  u8 n = pPragma->nPragCName;\n  sqlite3VdbeSetNumCols(v, n==0 ? 1 : n);\n  if( n==0 ){\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, pPragma->zName, SQLITE_STATIC);\n  }else{\n    int i, j;\n    for(i=0, j=pPragma->iPragCName; i<n; i++, j++){\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, pragCName[j], SQLITE_STATIC);\n    }\n  }\n}\n\n/*\n** Generate code to return a single integer value.\n*/\nstatic void returnSingleInt(Vdbe *v, i64 value){\n  sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, 1, 0, (const u8*)&value, P4_INT64);\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n}\n\n/*\n** Generate code to return a single text value.\n*/\nstatic void returnSingleText(\n  Vdbe *v,                /* Prepared statement under construction */\n  const char *zValue      /* Value to be returned */\n){\n  if( zValue ){\n    sqlite3VdbeLoadString(v, 1, (const char*)zValue);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n  }\n}\n\n\n/*\n** Set the safety_level and pager flags for pager iDb.  Or if iDb<0\n** set these values for all pagers.\n*/\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\nstatic void setAllPagerFlags(sqlite3 *db){\n  if( db->autoCommit ){\n    Db *pDb = db->aDb;\n    int n = db->nDb;\n    assert( SQLITE_FullFSync==PAGER_FULLFSYNC );\n    assert( SQLITE_CkptFullFSync==PAGER_CKPT_FULLFSYNC );\n    assert( SQLITE_CacheSpill==PAGER_CACHESPILL );\n    assert( (PAGER_FULLFSYNC | PAGER_CKPT_FULLFSYNC | PAGER_CACHESPILL)\n             ==  PAGER_FLAGS_MASK );\n    assert( (pDb->safety_level & PAGER_SYNCHRONOUS_MASK)==pDb->safety_level );\n    while( (n--) > 0 ){\n      if( pDb->pBt ){\n        sqlite3BtreeSetPagerFlags(pDb->pBt,\n                 pDb->safety_level | (db->flags & PAGER_FLAGS_MASK) );\n      }\n      pDb++;\n    }\n  }\n}\n#else\n# define setAllPagerFlags(X)  /* no-op */\n#endif\n\n\n/*\n** Return a human-readable name for a constraint resolution action.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nstatic const char *actionName(u8 action){\n  const char *zName;\n  switch( action ){\n    case OE_SetNull:  zName = \"SET NULL\";        break;\n    case OE_SetDflt:  zName = \"SET DEFAULT\";     break;\n    case OE_Cascade:  zName = \"CASCADE\";         break;\n    case OE_Restrict: zName = \"RESTRICT\";        break;\n    default:          zName = \"NO ACTION\";  \n                      assert( action==OE_None ); break;\n  }\n  return zName;\n}\n#endif\n\n\n/*\n** Parameter eMode must be one of the PAGER_JOURNALMODE_XXX constants\n** defined in pager.h. This function returns the associated lowercase\n** journal-mode name.\n*/\nconst char *sqlite3JournalModename(int eMode){\n  static char * const azModeName[] = {\n    \"delete\", \"persist\", \"off\", \"truncate\", \"memory\"\n#ifndef SQLITE_OMIT_WAL\n     , \"wal\"\n#endif\n  };\n  assert( PAGER_JOURNALMODE_DELETE==0 );\n  assert( PAGER_JOURNALMODE_PERSIST==1 );\n  assert( PAGER_JOURNALMODE_OFF==2 );\n  assert( PAGER_JOURNALMODE_TRUNCATE==3 );\n  assert( PAGER_JOURNALMODE_MEMORY==4 );\n  assert( PAGER_JOURNALMODE_WAL==5 );\n  assert( eMode>=0 && eMode<=ArraySize(azModeName) );\n\n  if( eMode==ArraySize(azModeName) ) return 0;\n  return azModeName[eMode];\n}\n\n/*\n** Locate a pragma in the aPragmaName[] array.\n*/\nstatic const PragmaName *pragmaLocate(const char *zName){\n  int upr, lwr, mid = 0, rc;\n  lwr = 0;\n  upr = ArraySize(aPragmaName)-1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    rc = sqlite3_stricmp(zName, aPragmaName[mid].zName);\n    if( rc==0 ) break;\n    if( rc<0 ){\n      upr = mid - 1;\n    }else{\n      lwr = mid + 1;\n    }\n  }\n  return lwr>upr ? 0 : &aPragmaName[mid];\n}\n\n/*\n** Helper subroutine for PRAGMA integrity_check:\n**\n** Generate code to output a single-column result row with a value of the\n** string held in register 3.  Decrement the result count in register 1\n** and halt if the maximum number of result rows have been issued.\n*/\nstatic int integrityCheckResultRow(Vdbe *v){\n  int addr;\n  sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);\n  addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);\n  VdbeCoverage(v);\n  sqlite3VdbeAddOp0(v, OP_Halt);\n  return addr;\n}\n\n/*\n** Process a pragma statement.  \n**\n** Pragmas are of this form:\n**\n**      PRAGMA [schema.]id [= value]\n**\n** The identifier might also be a string.  The value is a string, and\n** identifier, or a number.  If minusFlag is true, then the value is\n** a number that was preceded by a minus sign.\n**\n** If the left side is \"database.id\" then pId1 is the database name\n** and pId2 is the id.  If the left side is just \"id\" then pId1 is the\n** id and pId2 is any empty string.\n*/\nvoid sqlite3Pragma(\n  Parse *pParse, \n  Token *pId1,        /* First part of [schema.]id field */\n  Token *pId2,        /* Second part of [schema.]id field, or NULL */\n  Token *pValue,      /* Token for <value>, or NULL */\n  int minusFlag       /* True if a '-' sign preceded <value> */\n){\n  char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */\n  char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */\n  const char *zDb = 0;   /* The database name */\n  Token *pId;            /* Pointer to <id> token */\n  char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */\n  int iDb;               /* Database index for <database> */\n  int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */\n  sqlite3 *db = pParse->db;    /* The database connection */\n  Db *pDb;                     /* The specific database being pragmaed */\n  Vdbe *v = sqlite3GetVdbe(pParse);  /* Prepared statement */\n  const PragmaName *pPragma;   /* The pragma */\n\n  if( v==0 ) return;\n  sqlite3VdbeRunOnlyOnce(v);\n  pParse->nMem = 2;\n\n  /* Interpret the [schema.] part of the pragma statement. iDb is the\n  ** index of the database this pragma is being applied to in db.aDb[]. */\n  iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);\n  if( iDb<0 ) return;\n  pDb = &db->aDb[iDb];\n\n  /* If the temp database has been explicitly named as part of the \n  ** pragma, make sure it is open. \n  */\n  if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){\n    return;\n  }\n\n  zLeft = sqlite3NameFromToken(db, pId);\n  if( !zLeft ) return;\n  if( minusFlag ){\n    zRight = sqlite3MPrintf(db, \"-%T\", pValue);\n  }else{\n    zRight = sqlite3NameFromToken(db, pValue);\n  }\n\n  assert( pId2 );\n  zDb = pId2->n>0 ? pDb->zDbSName : 0;\n  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){\n    goto pragma_out;\n  }\n\n  /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS\n  ** connection.  If it returns SQLITE_OK, then assume that the VFS\n  ** handled the pragma and generate a no-op prepared statement.\n  **\n  ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,\n  ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file\n  ** object corresponding to the database file to which the pragma\n  ** statement refers.\n  **\n  ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA\n  ** file control is an array of pointers to strings (char**) in which the\n  ** second element of the array is the name of the pragma and the third\n  ** element is the argument to the pragma or NULL if the pragma has no\n  ** argument.\n  */\n  aFcntl[0] = 0;\n  aFcntl[1] = zLeft;\n  aFcntl[2] = zRight;\n  aFcntl[3] = 0;\n  db->busyHandler.nBusy = 0;\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, aFcntl[0], SQLITE_TRANSIENT);\n    returnSingleText(v, aFcntl[0]);\n    sqlite3_free(aFcntl[0]);\n    goto pragma_out;\n  }\n  if( rc!=SQLITE_NOTFOUND ){\n    if( aFcntl[0] ){\n      sqlite3ErrorMsg(pParse, \"%s\", aFcntl[0]);\n      sqlite3_free(aFcntl[0]);\n    }\n    pParse->nErr++;\n    pParse->rc = rc;\n    goto pragma_out;\n  }\n\n  /* Locate the pragma in the lookup table */\n  pPragma = pragmaLocate(zLeft);\n  if( pPragma==0 ) goto pragma_out;\n\n  /* Make sure the database schema is loaded if the pragma requires that */\n  if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){\n    if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n  }\n\n  /* Register the result column names for pragmas that return results */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns)==0 \n   && ((pPragma->mPragFlg & PragFlg_NoColumns1)==0 || zRight==0)\n  ){\n    setPragmaResultColumnNames(v, pPragma);\n  }\n\n  /* Jump to the appropriate pragma handler */\n  switch( pPragma->ePragTyp ){\n  \n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n  /*\n  **  PRAGMA [schema.]default_cache_size\n  **  PRAGMA [schema.]default_cache_size=N\n  **\n  ** The first form reports the current persistent setting for the\n  ** page cache size.  The value returned is the maximum number of\n  ** pages in the page cache.  The second form sets both the current\n  ** page cache size value and the persistent page cache size value\n  ** stored in the database file.\n  **\n  ** Older versions of SQLite would set the default cache size to a\n  ** negative number to indicate synchronous=OFF.  These days, synchronous\n  ** is always on by default regardless of the sign of the default cache\n  ** size.  But continue to take the absolute value of the default cache\n  ** size of historical compatibility.\n  */\n  case PragTyp_DEFAULT_CACHE_SIZE: {\n    static const int iLn = VDBE_OFFSET_LINENO(2);\n    static const VdbeOpList getCacheSize[] = {\n      { OP_Transaction, 0, 0,        0},                         /* 0 */\n      { OP_ReadCookie,  0, 1,        BTREE_DEFAULT_CACHE_SIZE},  /* 1 */\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 2,        0},\n      { OP_Subtract,    1, 2,        1},\n      { OP_IfPos,       1, 8,        0},\n      { OP_Integer,     0, 1,        0},                         /* 6 */\n      { OP_Noop,        0, 0,        0},\n      { OP_ResultRow,   1, 1,        0},\n    };\n    VdbeOp *aOp;\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( !zRight ){\n      pParse->nMem += 2;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(getCacheSize));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize, iLn);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[6].p1 = SQLITE_DEFAULT_CACHE_SIZE;\n    }else{\n      int size = sqlite3AbsInt32(sqlite3Atoi(zRight));\n      sqlite3BeginWriteOperation(pParse, 0, iDb);\n      sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_DEFAULT_CACHE_SIZE, size);\n      assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n#endif /* !SQLITE_OMIT_PAGER_PRAGMAS && !SQLITE_OMIT_DEPRECATED */\n\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n  /*\n  **  PRAGMA [schema.]page_size\n  **  PRAGMA [schema.]page_size=N\n  **\n  ** The first form reports the current setting for the\n  ** database page size in bytes.  The second form sets the\n  ** database page size value.  The value can only be set if\n  ** the database has not yet been created.\n  */\n  case PragTyp_PAGE_SIZE: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0;\n      returnSingleInt(v, size);\n    }else{\n      /* Malloc may fail when setting the page-size, as there is an internal\n      ** buffer that the pager module resizes using sqlite3_realloc().\n      */\n      db->nextPagesize = sqlite3Atoi(zRight);\n      if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize,-1,0) ){\n        sqlite3OomFault(db);\n      }\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]secure_delete\n  **  PRAGMA [schema.]secure_delete=ON/OFF/FAST\n  **\n  ** The first form reports the current setting for the\n  ** secure_delete flag.  The second form changes the secure_delete\n  ** flag setting and reports the new value.\n  */\n  case PragTyp_SECURE_DELETE: {\n    Btree *pBt = pDb->pBt;\n    int b = -1;\n    assert( pBt!=0 );\n    if( zRight ){\n      if( sqlite3_stricmp(zRight, \"fast\")==0 ){\n        b = 2;\n      }else{\n        b = sqlite3GetBoolean(zRight, 0);\n      }\n    }\n    if( pId2->n==0 && b>=0 ){\n      int ii;\n      for(ii=0; ii<db->nDb; ii++){\n        sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b);\n      }\n    }\n    b = sqlite3BtreeSecureDelete(pBt, b);\n    returnSingleInt(v, b);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]max_page_count\n  **  PRAGMA [schema.]max_page_count=N\n  **\n  ** The first form reports the current setting for the\n  ** maximum number of pages in the database file.  The \n  ** second form attempts to change this setting.  Both\n  ** forms return the current setting.\n  **\n  ** The absolute value of N is used.  This is undocumented and might\n  ** change.  The only purpose is to provide an easy way to test\n  ** the sqlite3AbsInt32() function.\n  **\n  **  PRAGMA [schema.]page_count\n  **\n  ** Return the number of pages in the specified database.\n  */\n  case PragTyp_PAGE_COUNT: {\n    int iReg;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    iReg = ++pParse->nMem;\n    if( sqlite3Tolower(zLeft[0])=='p' ){\n      sqlite3VdbeAddOp2(v, OP_Pagecount, iDb, iReg);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_MaxPgcnt, iDb, iReg, \n                        sqlite3AbsInt32(sqlite3Atoi(zRight)));\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, iReg, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]locking_mode\n  **  PRAGMA [schema.]locking_mode = (normal|exclusive)\n  */\n  case PragTyp_LOCKING_MODE: {\n    const char *zRet = \"normal\";\n    int eMode = getLockingMode(zRight);\n\n    if( pId2->n==0 && eMode==PAGER_LOCKINGMODE_QUERY ){\n      /* Simple \"PRAGMA locking_mode;\" statement. This is a query for\n      ** the current default locking mode (which may be different to\n      ** the locking-mode of the main database).\n      */\n      eMode = db->dfltLockMode;\n    }else{\n      Pager *pPager;\n      if( pId2->n==0 ){\n        /* This indicates that no database name was specified as part\n        ** of the PRAGMA command. In this case the locking-mode must be\n        ** set on all attached databases, as well as the main db file.\n        **\n        ** Also, the sqlite3.dfltLockMode variable is set so that\n        ** any subsequently attached databases also use the specified\n        ** locking mode.\n        */\n        int ii;\n        assert(pDb==&db->aDb[0]);\n        for(ii=2; ii<db->nDb; ii++){\n          pPager = sqlite3BtreePager(db->aDb[ii].pBt);\n          sqlite3PagerLockingMode(pPager, eMode);\n        }\n        db->dfltLockMode = (u8)eMode;\n      }\n      pPager = sqlite3BtreePager(pDb->pBt);\n      eMode = sqlite3PagerLockingMode(pPager, eMode);\n    }\n\n    assert( eMode==PAGER_LOCKINGMODE_NORMAL\n            || eMode==PAGER_LOCKINGMODE_EXCLUSIVE );\n    if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){\n      zRet = \"exclusive\";\n    }\n    returnSingleText(v, zRet);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_mode\n  **  PRAGMA [schema.]journal_mode =\n  **                      (delete|persist|off|truncate|memory|wal|off)\n  */\n  case PragTyp_JOURNAL_MODE: {\n    int eMode;        /* One of the PAGER_JOURNALMODE_XXX symbols */\n    int ii;           /* Loop counter */\n\n    if( zRight==0 ){\n      /* If there is no \"=MODE\" part of the pragma, do a query for the\n      ** current mode */\n      eMode = PAGER_JOURNALMODE_QUERY;\n    }else{\n      const char *zMode;\n      int n = sqlite3Strlen30(zRight);\n      for(eMode=0; (zMode = sqlite3JournalModename(eMode))!=0; eMode++){\n        if( sqlite3StrNICmp(zRight, zMode, n)==0 ) break;\n      }\n      if( !zMode ){\n        /* If the \"=MODE\" part does not match any known journal mode,\n        ** then do a query */\n        eMode = PAGER_JOURNALMODE_QUERY;\n      }\n    }\n    if( eMode==PAGER_JOURNALMODE_QUERY && pId2->n==0 ){\n      /* Convert \"PRAGMA journal_mode\" into \"PRAGMA main.journal_mode\" */\n      iDb = 0;\n      pId2->n = 1;\n    }\n    for(ii=db->nDb-1; ii>=0; ii--){\n      if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n        sqlite3VdbeUsesBtree(v, ii);\n        sqlite3VdbeAddOp3(v, OP_JournalMode, ii, 1, eMode);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]journal_size_limit\n  **  PRAGMA [schema.]journal_size_limit=N\n  **\n  ** Get or set the size limit on rollback journal files.\n  */\n  case PragTyp_JOURNAL_SIZE_LIMIT: {\n    Pager *pPager = sqlite3BtreePager(pDb->pBt);\n    i64 iLimit = -2;\n    if( zRight ){\n      sqlite3DecOrHexToI64(zRight, &iLimit);\n      if( iLimit<-1 ) iLimit = -1;\n    }\n    iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit);\n    returnSingleInt(v, iLimit);\n    break;\n  }\n\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n  /*\n  **  PRAGMA [schema.]auto_vacuum\n  **  PRAGMA [schema.]auto_vacuum=N\n  **\n  ** Get or set the value of the database 'auto-vacuum' parameter.\n  ** The value is one of:  0 NONE 1 FULL 2 INCREMENTAL\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_AUTO_VACUUM: {\n    Btree *pBt = pDb->pBt;\n    assert( pBt!=0 );\n    if( !zRight ){\n      returnSingleInt(v, sqlite3BtreeGetAutoVacuum(pBt));\n    }else{\n      int eAuto = getAutoVacuum(zRight);\n      assert( eAuto>=0 && eAuto<=2 );\n      db->nextAutovac = (u8)eAuto;\n      /* Call SetAutoVacuum() to set initialize the internal auto and\n      ** incr-vacuum flags. This is required in case this connection\n      ** creates the database file. It is important that it is created\n      ** as an auto-vacuum capable db.\n      */\n      rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto);\n      if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){\n        /* When setting the auto_vacuum mode to either \"full\" or \n        ** \"incremental\", write the value of meta[6] in the database\n        ** file. Before writing to meta[6], check that meta[3] indicates\n        ** that this really is an auto-vacuum capable database.\n        */\n        static const int iLn = VDBE_OFFSET_LINENO(2);\n        static const VdbeOpList setMeta6[] = {\n          { OP_Transaction,    0,         1,                 0},    /* 0 */\n          { OP_ReadCookie,     0,         1,         BTREE_LARGEST_ROOT_PAGE},\n          { OP_If,             1,         0,                 0},    /* 2 */\n          { OP_Halt,           SQLITE_OK, OE_Abort,          0},    /* 3 */\n          { OP_SetCookie,      0,         BTREE_INCR_VACUUM, 0},    /* 4 */\n        };\n        VdbeOp *aOp;\n        int iAddr = sqlite3VdbeCurrentAddr(v);\n        sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setMeta6));\n        aOp = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6, iLn);\n        if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n        aOp[0].p1 = iDb;\n        aOp[1].p1 = iDb;\n        aOp[2].p2 = iAddr+4;\n        aOp[4].p1 = iDb;\n        aOp[4].p3 = eAuto - 1;\n        sqlite3VdbeUsesBtree(v, iDb);\n      }\n    }\n    break;\n  }\n#endif\n\n  /*\n  **  PRAGMA [schema.]incremental_vacuum(N)\n  **\n  ** Do N steps of incremental vacuuming on a database.\n  */\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  case PragTyp_INCREMENTAL_VACUUM: {\n    int iLimit, addr;\n    if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){\n      iLimit = 0x7fffffff;\n    }\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);\n    addr = sqlite3VdbeAddOp1(v, OP_IncrVacuum, iDb); VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_ResultRow, 1);\n    sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);\n    sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    break;\n  }\n#endif\n\n#ifndef SQLITE_OMIT_PAGER_PRAGMAS\n  /*\n  **  PRAGMA [schema.]cache_size\n  **  PRAGMA [schema.]cache_size=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache size. The second form sets the local\n  ** page cache size value.  If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  */\n  case PragTyp_CACHE_SIZE: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v, pDb->pSchema->cache_size);\n    }else{\n      int size = sqlite3Atoi(zRight);\n      pDb->pSchema->cache_size = size;\n      sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]cache_spill\n  **  PRAGMA cache_spill=BOOLEAN\n  **  PRAGMA [schema.]cache_spill=N\n  **\n  ** The first form reports the current local setting for the\n  ** page cache spill size. The second form turns cache spill on\n  ** or off.  When turnning cache spill on, the size is set to the\n  ** current cache_size.  The third form sets a spill size that\n  ** may be different form the cache size.\n  ** If N is positive then that is the\n  ** number of pages in the cache.  If N is negative, then the\n  ** number of pages is adjusted so that the cache uses -N kibibytes\n  ** of memory.\n  **\n  ** If the number of cache_spill pages is less then the number of\n  ** cache_size pages, no spilling occurs until the page count exceeds\n  ** the number of cache_size pages.\n  **\n  ** The cache_spill=BOOLEAN setting applies to all attached schemas,\n  ** not just the schema specified.\n  */\n  case PragTyp_CACHE_SPILL: {\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( !zRight ){\n      returnSingleInt(v,\n         (db->flags & SQLITE_CacheSpill)==0 ? 0 : \n            sqlite3BtreeSetSpillSize(pDb->pBt,0));\n    }else{\n      int size = 1;\n      if( sqlite3GetInt32(zRight, &size) ){\n        sqlite3BtreeSetSpillSize(pDb->pBt, size);\n      }\n      if( sqlite3GetBoolean(zRight, size!=0) ){\n        db->flags |= SQLITE_CacheSpill;\n      }else{\n        db->flags &= ~SQLITE_CacheSpill;\n      }\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n\n  /*\n  **  PRAGMA [schema.]mmap_size(N)\n  **\n  ** Used to set mapping size limit. The mapping size limit is\n  ** used to limit the aggregate size of all memory mapped regions of the\n  ** database file. If this parameter is set to zero, then memory mapping\n  ** is not used at all.  If N is negative, then the default memory map\n  ** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_SIZE) is set.\n  ** The parameter N is measured in bytes.\n  **\n  ** This value is advisory.  The underlying VFS is free to memory map\n  ** as little or as much as it wants.  Except, if N is set to 0 then the\n  ** upper layers will never invoke the xFetch interfaces to the VFS.\n  */\n  case PragTyp_MMAP_SIZE: {\n    sqlite3_int64 sz;\n#if SQLITE_MAX_MMAP_SIZE>0\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( zRight ){\n      int ii;\n      sqlite3DecOrHexToI64(zRight, &sz);\n      if( sz<0 ) sz = sqlite3GlobalConfig.szMmap;\n      if( pId2->n==0 ) db->szMmap = sz;\n      for(ii=db->nDb-1; ii>=0; ii--){\n        if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){\n          sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz);\n        }\n      }\n    }\n    sz = -1;\n    rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_MMAP_SIZE, &sz);\n#else\n    sz = 0;\n    rc = SQLITE_OK;\n#endif\n    if( rc==SQLITE_OK ){\n      returnSingleInt(v, sz);\n    }else if( rc!=SQLITE_NOTFOUND ){\n      pParse->nErr++;\n      pParse->rc = rc;\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store\n  **   PRAGMA temp_store = \"default\"|\"memory\"|\"file\"\n  **\n  ** Return or set the local value of the temp_store flag.  Changing\n  ** the local value does not make changes to the disk file and the default\n  ** value will be restored the next time the database is opened.\n  **\n  ** Note that it is possible for the library compile-time options to\n  ** override this setting\n  */\n  case PragTyp_TEMP_STORE: {\n    if( !zRight ){\n      returnSingleInt(v, db->temp_store);\n    }else{\n      changeTempStorage(pParse, zRight);\n    }\n    break;\n  }\n\n  /*\n  **   PRAGMA temp_store_directory\n  **   PRAGMA temp_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the temp_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for temporary files.\n  ** Setting to a null string reverts to the default temporary directory search.\n  ** If temporary directory is changed, then invalidateTempStorage.\n  **\n  */\n  case PragTyp_TEMP_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_temp_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      if( SQLITE_TEMP_STORE==0\n       || (SQLITE_TEMP_STORE==1 && db->temp_store<=1)\n       || (SQLITE_TEMP_STORE==2 && db->temp_store==1)\n      ){\n        invalidateTempStorage(pParse);\n      }\n      sqlite3_free(sqlite3_temp_directory);\n      if( zRight[0] ){\n        sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_temp_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n\n#if SQLITE_OS_WIN\n  /*\n  **   PRAGMA data_store_directory\n  **   PRAGMA data_store_directory = \"\"|\"directory_name\"\n  **\n  ** Return or set the local value of the data_store_directory flag.  Changing\n  ** the value sets a specific directory to be used for database files that\n  ** were specified with a relative pathname.  Setting to a null string reverts\n  ** to the default database directory, which for database files specified with\n  ** a relative path will probably be based on the current directory for the\n  ** process.  Database file specified with an absolute path are not impacted\n  ** by this setting, regardless of its value.\n  **\n  */\n  case PragTyp_DATA_STORE_DIRECTORY: {\n    if( !zRight ){\n      returnSingleText(v, sqlite3_data_directory);\n    }else{\n#ifndef SQLITE_OMIT_WSD\n      if( zRight[0] ){\n        int res;\n        rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);\n        if( rc!=SQLITE_OK || res==0 ){\n          sqlite3ErrorMsg(pParse, \"not a writable directory\");\n          goto pragma_out;\n        }\n      }\n      sqlite3_free(sqlite3_data_directory);\n      if( zRight[0] ){\n        sqlite3_data_directory = sqlite3_mprintf(\"%s\", zRight);\n      }else{\n        sqlite3_data_directory = 0;\n      }\n#endif /* SQLITE_OMIT_WSD */\n    }\n    break;\n  }\n#endif\n\n#if SQLITE_ENABLE_LOCKING_STYLE\n  /*\n  **   PRAGMA [schema.]lock_proxy_file\n  **   PRAGMA [schema.]lock_proxy_file = \":auto:\"|\"lock_file_path\"\n  **\n  ** Return or set the value of the lock_proxy_file flag.  Changing\n  ** the value sets a specific file to be used for database access locks.\n  **\n  */\n  case PragTyp_LOCK_PROXY_FILE: {\n    if( !zRight ){\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      char *proxy_file_path = NULL;\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, \n                           &proxy_file_path);\n      returnSingleText(v, proxy_file_path);\n    }else{\n      Pager *pPager = sqlite3BtreePager(pDb->pBt);\n      sqlite3_file *pFile = sqlite3PagerFile(pPager);\n      int res;\n      if( zRight[0] ){\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     zRight);\n      } else {\n        res=sqlite3OsFileControl(pFile, SQLITE_SET_LOCKPROXYFILE, \n                                     NULL);\n      }\n      if( res!=SQLITE_OK ){\n        sqlite3ErrorMsg(pParse, \"failed to set lock proxy file\");\n        goto pragma_out;\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_ENABLE_LOCKING_STYLE */      \n    \n  /*\n  **   PRAGMA [schema.]synchronous\n  **   PRAGMA [schema.]synchronous=OFF|ON|NORMAL|FULL|EXTRA\n  **\n  ** Return or set the local value of the synchronous flag.  Changing\n  ** the local value does not make changes to the disk file and the\n  ** default value will be restored the next time the database is\n  ** opened.\n  */\n  case PragTyp_SYNCHRONOUS: {\n    if( !zRight ){\n      returnSingleInt(v, pDb->safety_level-1);\n    }else{\n      if( !db->autoCommit ){\n        sqlite3ErrorMsg(pParse, \n            \"Safety level may not be changed inside a transaction\");\n      }else if( iDb!=1 ){\n        int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;\n        if( iLevel==0 ) iLevel = 1;\n        pDb->safety_level = iLevel;\n        pDb->bSyncSet = 1;\n        setAllPagerFlags(db);\n      }\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_PAGER_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FLAG_PRAGMAS\n  case PragTyp_FLAG: {\n    if( zRight==0 ){\n      setPragmaResultColumnNames(v, pPragma);\n      returnSingleInt(v, (db->flags & pPragma->iArg)!=0 );\n    }else{\n      int mask = pPragma->iArg;    /* Mask of bits to set or clear. */\n      if( db->autoCommit==0 ){\n        /* Foreign key support may not be enabled or disabled while not\n        ** in auto-commit mode.  */\n        mask &= ~(SQLITE_ForeignKeys);\n      }\n#if SQLITE_USER_AUTHENTICATION\n      if( db->auth.authLevel==UAUTH_User ){\n        /* Do not allow non-admin users to modify the schema arbitrarily */\n        mask &= ~(SQLITE_WriteSchema);\n      }\n#endif\n\n      if( sqlite3GetBoolean(zRight, 0) ){\n        db->flags |= mask;\n      }else{\n        db->flags &= ~mask;\n        if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;\n      }\n\n      /* Many of the flag-pragmas modify the code generated by the SQL \n      ** compiler (eg. count_changes). So add an opcode to expire all\n      ** compiled SQL statements after modifying a pragma value.\n      */\n      sqlite3VdbeAddOp0(v, OP_Expire);\n      setAllPagerFlags(db);\n    }\n    break;\n  }\n#endif /* SQLITE_OMIT_FLAG_PRAGMAS */\n\n#ifndef SQLITE_OMIT_SCHEMA_PRAGMAS\n  /*\n  **   PRAGMA table_info(<table>)\n  **\n  ** Return a single row for each column of the named table. The columns of\n  ** the returned data set are:\n  **\n  ** cid:        Column id (numbered from left to right, starting at 0)\n  ** name:       Column name\n  ** type:       Column declaration type.\n  ** notnull:    True if 'NOT NULL' is part of column declaration\n  ** dflt_value: The default value for the column, if any.\n  */\n  case PragTyp_TABLE_INFO: if( zRight ){\n    Table *pTab;\n    pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);\n    if( pTab ){\n      int i, k;\n      int nHidden = 0;\n      Column *pCol;\n      Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n      pParse->nMem = 6;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      sqlite3ViewGetColumnNames(pParse, pTab);\n      for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n        if( IsHiddenColumn(pCol) ){\n          nHidden++;\n          continue;\n        }\n        if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){\n          k = 0;\n        }else if( pPk==0 ){\n          k = 1;\n        }else{\n          for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}\n        }\n        assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );\n        sqlite3VdbeMultiLoad(v, 1, \"issisi\",\n               i-nHidden,\n               pCol->zName,\n               sqlite3ColumnType(pCol,\"\"),\n               pCol->notNull ? 1 : 0,\n               pCol->pDflt ? pCol->pDflt->u.zToken : 0,\n               k);\n      }\n    }\n  }\n  break;\n\n#ifdef SQLITE_DEBUG\n  case PragTyp_STATS: {\n    Index *pIdx;\n    HashElem *i;\n    pParse->nMem = 5;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){\n      Table *pTab = sqliteHashData(i);\n      sqlite3VdbeMultiLoad(v, 1, \"ssiii\",\n           pTab->zName,\n           0,\n           pTab->szTabRow,\n           pTab->nRowLogEst,\n           pTab->tabFlags);\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        sqlite3VdbeMultiLoad(v, 2, \"siiiX\",\n           pIdx->zName,\n           pIdx->szIdxRow,\n           pIdx->aiRowLogEst[0],\n           pIdx->hasStat1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);\n      }\n    }\n  }\n  break;\n#endif\n\n  case PragTyp_INDEX_INFO: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    pIdx = sqlite3FindIndex(db, zRight, zDb);\n    if( pIdx ){\n      int i;\n      int mx;\n      if( pPragma->iArg ){\n        /* PRAGMA index_xinfo (newer version with more rows and columns) */\n        mx = pIdx->nColumn;\n        pParse->nMem = 6;\n      }else{\n        /* PRAGMA index_info (legacy version) */\n        mx = pIdx->nKeyCol;\n        pParse->nMem = 3;\n      }\n      pTab = pIdx->pTable;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      assert( pParse->nMem<=pPragma->nPragCName );\n      for(i=0; i<mx; i++){\n        i16 cnum = pIdx->aiColumn[i];\n        sqlite3VdbeMultiLoad(v, 1, \"iisX\", i, cnum,\n                             cnum<0 ? 0 : pTab->aCol[cnum].zName);\n        if( pPragma->iArg ){\n          sqlite3VdbeMultiLoad(v, 4, \"isiX\",\n            pIdx->aSortOrder[i],\n            pIdx->azColl[i],\n            i<pIdx->nKeyCol);\n        }\n        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_INDEX_LIST: if( zRight ){\n    Index *pIdx;\n    Table *pTab;\n    int i;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      pParse->nMem = 5;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){\n        const char *azOrigin[] = { \"c\", \"u\", \"pk\" };\n        sqlite3VdbeMultiLoad(v, 1, \"isisi\",\n           i,\n           pIdx->zName,\n           IsUniqueIndex(pIdx),\n           azOrigin[pIdx->idxType],\n           pIdx->pPartIdxWhere!=0);\n      }\n    }\n  }\n  break;\n\n  case PragTyp_DATABASE_LIST: {\n    int i;\n    pParse->nMem = 3;\n    for(i=0; i<db->nDb; i++){\n      if( db->aDb[i].pBt==0 ) continue;\n      assert( db->aDb[i].zDbSName!=0 );\n      sqlite3VdbeMultiLoad(v, 1, \"iss\",\n         i,\n         db->aDb[i].zDbSName,\n         sqlite3BtreeGetFilename(db->aDb[i].pBt));\n    }\n  }\n  break;\n\n  case PragTyp_COLLATION_LIST: {\n    int i = 0;\n    HashElem *p;\n    pParse->nMem = 2;\n    for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){\n      CollSeq *pColl = (CollSeq *)sqliteHashData(p);\n      sqlite3VdbeMultiLoad(v, 1, \"is\", i++, pColl->zName);\n    }\n  }\n  break;\n\n#ifdef SQLITE_INTROSPECTION_PRAGMAS\n  case PragTyp_FUNCTION_LIST: {\n    int i;\n    HashElem *j;\n    FuncDef *p;\n    pParse->nMem = 2;\n    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){\n      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){\n        sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 1);\n      }\n    }\n    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){\n      p = (FuncDef*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"si\", p->zName, 0);\n    }\n  }\n  break;\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  case PragTyp_MODULE_LIST: {\n    HashElem *j;\n    pParse->nMem = 1;\n    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){\n      Module *pMod = (Module*)sqliteHashData(j);\n      sqlite3VdbeMultiLoad(v, 1, \"s\", pMod->zName);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  case PragTyp_PRAGMA_LIST: {\n    int i;\n    for(i=0; i<ArraySize(aPragmaName); i++){\n      sqlite3VdbeMultiLoad(v, 1, \"s\", aPragmaName[i].zName);\n    }\n  }\n  break;\n#endif /* SQLITE_INTROSPECTION_PRAGMAS */\n\n#endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  case PragTyp_FOREIGN_KEY_LIST: if( zRight ){\n    FKey *pFK;\n    Table *pTab;\n    pTab = sqlite3FindTable(db, zRight, zDb);\n    if( pTab ){\n      pFK = pTab->pFKey;\n      if( pFK ){\n        int i = 0; \n        pParse->nMem = 8;\n        sqlite3CodeVerifySchema(pParse, iDb);\n        while(pFK){\n          int j;\n          for(j=0; j<pFK->nCol; j++){\n            sqlite3VdbeMultiLoad(v, 1, \"iissssss\",\n                   i,\n                   j,\n                   pFK->zTo,\n                   pTab->aCol[pFK->aCol[j].iFrom].zName,\n                   pFK->aCol[j].zCol,\n                   actionName(pFK->aAction[1]),  /* ON UPDATE */\n                   actionName(pFK->aAction[0]),  /* ON DELETE */\n                   \"NONE\");\n          }\n          ++i;\n          pFK = pFK->pNextFrom;\n        }\n      }\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n#ifndef SQLITE_OMIT_TRIGGER\n  case PragTyp_FOREIGN_KEY_CHECK: {\n    FKey *pFK;             /* A foreign key constraint */\n    Table *pTab;           /* Child table contain \"REFERENCES\" keyword */\n    Table *pParent;        /* Parent table that child points to */\n    Index *pIdx;           /* Index in the parent table */\n    int i;                 /* Loop counter:  Foreign key number for pTab */\n    int j;                 /* Loop counter:  Field of the foreign key */\n    HashElem *k;           /* Loop counter:  Next table in schema */\n    int x;                 /* result variable */\n    int regResult;         /* 3 registers to hold a result row */\n    int regKey;            /* Register to hold key for checking the FK */\n    int regRow;            /* Registers to hold a row from pTab */\n    int addrTop;           /* Top of a loop checking foreign keys */\n    int addrOk;            /* Jump here if the key is OK */\n    int *aiCols;           /* child to parent column mapping */\n\n    regResult = pParse->nMem+1;\n    pParse->nMem += 4;\n    regKey = ++pParse->nMem;\n    regRow = ++pParse->nMem;\n    sqlite3CodeVerifySchema(pParse, iDb);\n    k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash);\n    while( k ){\n      if( zRight ){\n        pTab = sqlite3LocateTable(pParse, 0, zRight, zDb);\n        k = 0;\n      }else{\n        pTab = (Table*)sqliteHashData(k);\n        k = sqliteHashNext(k);\n      }\n      if( pTab==0 || pTab->pFKey==0 ) continue;\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n      if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;\n      sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);\n      sqlite3VdbeLoadString(v, regResult, pTab->zName);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        if( pParent==0 ) continue;\n        pIdx = 0;\n        sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);\n        x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);\n        if( x==0 ){\n          if( pIdx==0 ){\n            sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb);\n            sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n          }\n        }else{\n          k = 0;\n          break;\n        }\n      }\n      assert( pParse->nErr>0 || pFK==0 );\n      if( pFK ) break;\n      if( pParse->nTab<i ) pParse->nTab = i;\n      addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v);\n      for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){\n        pParent = sqlite3FindTable(db, pFK->zTo, zDb);\n        pIdx = 0;\n        aiCols = 0;\n        if( pParent ){\n          x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);\n          assert( x==0 );\n        }\n        addrOk = sqlite3VdbeMakeLabel(v);\n\n        /* Generate code to read the child key values into registers\n        ** regRow..regRow+n. If any of the child key values are NULL, this \n        ** row cannot cause an FK violation. Jump directly to addrOk in \n        ** this case. */\n        for(j=0; j<pFK->nCol; j++){\n          int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);\n          sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);\n        }\n\n        /* Generate code to query the parent index for a matching parent\n        ** key. If a match is found, jump to addrOk. */\n        if( pIdx ){\n          sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey,\n              sqlite3IndexAffinityStr(db,pIdx), pFK->nCol);\n          sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);\n          VdbeCoverage(v);\n        }else if( pParent ){\n          int jmp = sqlite3VdbeCurrentAddr(v)+2;\n          sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v);\n          sqlite3VdbeGoto(v, addrOk);\n          assert( pFK->nCol==1 );\n        }\n\n        /* Generate code to report an FK violation to the caller. */\n        if( HasRowid(pTab) ){\n          sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);\n        }else{\n          sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1);\n        }\n        sqlite3VdbeMultiLoad(v, regResult+2, \"siX\", pFK->zTo, i-1);\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4);\n        sqlite3VdbeResolveLabel(v, addrOk);\n        sqlite3DbFree(db, aiCols);\n      }\n      sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v);\n      sqlite3VdbeJumpHere(v, addrTop);\n    }\n  }\n  break;\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */\n\n#ifndef NDEBUG\n  case PragTyp_PARSER_TRACE: {\n    if( zRight ){\n      if( sqlite3GetBoolean(zRight, 0) ){\n        sqlite3ParserTrace(stdout, \"parser: \");\n      }else{\n        sqlite3ParserTrace(0, 0);\n      }\n    }\n  }\n  break;\n#endif\n\n  /* Reinstall the LIKE and GLOB functions.  The variant of LIKE\n  ** used will be case sensitive or not depending on the RHS.\n  */\n  case PragTyp_CASE_SENSITIVE_LIKE: {\n    if( zRight ){\n      sqlite3RegisterLikeFunctions(db, sqlite3GetBoolean(zRight, 0));\n    }\n  }\n  break;\n\n#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX\n# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100\n#endif\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n  /*    PRAGMA integrity_check\n  **    PRAGMA integrity_check(N)\n  **    PRAGMA quick_check\n  **    PRAGMA quick_check(N)\n  **\n  ** Verify the integrity of the database.\n  **\n  ** The \"quick_check\" is reduced version of \n  ** integrity_check designed to detect most database corruption\n  ** without the overhead of cross-checking indexes.  Quick_check\n  ** is linear time wherease integrity_check is O(NlogN).\n  */\n  case PragTyp_INTEGRITY_CHECK: {\n    int i, j, addr, mxErr;\n\n    int isQuick = (sqlite3Tolower(zLeft[0])=='q');\n\n    /* If the PRAGMA command was of the form \"PRAGMA <db>.integrity_check\",\n    ** then iDb is set to the index of the database identified by <db>.\n    ** In this case, the integrity of database iDb only is verified by\n    ** the VDBE created below.\n    **\n    ** Otherwise, if the command was simply \"PRAGMA integrity_check\" (or\n    ** \"PRAGMA quick_check\"), then iDb is set to 0. In this case, set iDb\n    ** to -1 here, to indicate that the VDBE should verify the integrity\n    ** of all attached databases.  */\n    assert( iDb>=0 );\n    assert( iDb==0 || pId2->z );\n    if( pId2->z==0 ) iDb = -1;\n\n    /* Initialize the VDBE program */\n    pParse->nMem = 6;\n\n    /* Set the maximum error count */\n    mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n    if( zRight ){\n      sqlite3GetInt32(zRight, &mxErr);\n      if( mxErr<=0 ){\n        mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */\n\n    /* Do an integrity check on each database file */\n    for(i=0; i<db->nDb; i++){\n      HashElem *x;     /* For looping over tables in the schema */\n      Hash *pTbls;     /* Set of all tables in the schema */\n      int *aRoot;      /* Array of root page numbers of all btrees */\n      int cnt = 0;     /* Number of entries in aRoot[] */\n      int mxIdx = 0;   /* Maximum number of indexes for any table */\n\n      if( OMIT_TEMPDB && i==1 ) continue;\n      if( iDb>=0 && i!=iDb ) continue;\n\n      sqlite3CodeVerifySchema(pParse, i);\n\n      /* Do an integrity check of the B-Tree\n      **\n      ** Begin by finding the root pages numbers\n      ** for all tables and indices in the database.\n      */\n      assert( sqlite3SchemaMutexHeld(db, i, 0) );\n      pTbls = &db->aDb[i].pSchema->tblHash;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);  /* Current table */\n        Index *pIdx;                      /* An index on pTab */\n        int nIdx;                         /* Number of indexes on pTab */\n        if( HasRowid(pTab) ) cnt++;\n        for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ cnt++; }\n        if( nIdx>mxIdx ) mxIdx = nIdx;\n      }\n      aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1));\n      if( aRoot==0 ) break;\n      for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx;\n        if( HasRowid(pTab) ) aRoot[++cnt] = pTab->tnum;\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          aRoot[++cnt] = pIdx->tnum;\n        }\n      }\n      aRoot[0] = cnt;\n\n      /* Make sure sufficient number of registers have been allocated */\n      pParse->nMem = MAX( pParse->nMem, 8+mxIdx );\n      sqlite3ClearTempRegCache(pParse);\n\n      /* Do the b-tree integrity checks */\n      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);\n      sqlite3VdbeChangeP5(v, (u8)i);\n      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);\n      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,\n         sqlite3MPrintf(db, \"*** in database %s ***\\n\", db->aDb[i].zDbSName),\n         P4_DYNAMIC);\n      sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);\n      integrityCheckResultRow(v);\n      sqlite3VdbeJumpHere(v, addr);\n\n      /* Make sure all the indices are constructed correctly.\n      */\n      for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){\n        Table *pTab = sqliteHashData(x);\n        Index *pIdx, *pPk;\n        Index *pPrior = 0;\n        int loopTop;\n        int iDataCur, iIdxCur;\n        int r1 = -1;\n\n        if( pTab->tnum<1 ) continue;  /* Skip VIEWs or VIRTUAL TABLEs */\n        pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n        sqlite3ExprCacheClear(pParse);\n        sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,\n                                   1, 0, &iDataCur, &iIdxCur);\n        /* reg[7] counts the number of entries in the table.\n        ** reg[8+i] counts the number of entries in the i-th index \n        */\n        sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);\n        for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n          sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */\n        }\n        assert( pParse->nMem>=8+j );\n        assert( sqlite3NoTempsInRange(pParse,1,7+j) );\n        sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);\n        loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);\n        /* Verify that all NOT NULL columns really are NOT NULL */\n        for(j=0; j<pTab->nCol; j++){\n          char *zErr;\n          int jmp2;\n          if( j==pTab->iPKey ) continue;\n          if( pTab->aCol[j].notNull==0 ) continue;\n          sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n          jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);\n          zErr = sqlite3MPrintf(db, \"NULL value in %s.%s\", pTab->zName,\n                              pTab->aCol[j].zName);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n          integrityCheckResultRow(v);\n          sqlite3VdbeJumpHere(v, jmp2);\n        }\n        /* Verify CHECK constraints */\n        if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){\n          ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);\n          if( db->mallocFailed==0 ){\n            int addrCkFault = sqlite3VdbeMakeLabel(v);\n            int addrCkOk = sqlite3VdbeMakeLabel(v);\n            char *zErr;\n            int k;\n            pParse->iSelfTab = iDataCur + 1;\n            sqlite3ExprCachePush(pParse);\n            for(k=pCheck->nExpr-1; k>0; k--){\n              sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);\n            }\n            sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, \n                SQLITE_JUMPIFNULL);\n            sqlite3VdbeResolveLabel(v, addrCkFault);\n            pParse->iSelfTab = 0;\n            zErr = sqlite3MPrintf(db, \"CHECK constraint failed in %s\",\n                pTab->zName);\n            sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);\n            integrityCheckResultRow(v);\n            sqlite3VdbeResolveLabel(v, addrCkOk);\n            sqlite3ExprCachePop(pParse);\n          }\n          sqlite3ExprListDelete(db, pCheck);\n        }\n        if( !isQuick ){ /* Omit the remaining tests for quick_check */\n          /* Sanity check on record header decoding */\n          sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nCol-1, 3);\n          sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);\n          /* Validate index entries for the current row */\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            int jmp2, jmp3, jmp4, jmp5;\n            int ckUniq = sqlite3VdbeMakeLabel(v);\n            if( pPk==pIdx ) continue;\n            r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,\n                                         pPrior, r1);\n            pPrior = pIdx;\n            sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1);/* increment entry count */\n            /* Verify that an index entry exists for the current table row */\n            jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,\n                                        pIdx->nColumn); VdbeCoverage(v);\n            sqlite3VdbeLoadString(v, 3, \"row \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);\n            sqlite3VdbeLoadString(v, 4, \" missing from index \");\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);\n            jmp4 = integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, jmp2);\n            /* For UNIQUE indexes, verify that only one entry exists with the\n            ** current key.  The entry is unique if (1) any column is NULL\n            ** or (2) the next entry has a different key */\n            if( IsUniqueIndex(pIdx) ){\n              int uniqOk = sqlite3VdbeMakeLabel(v);\n              int jmp6;\n              int kk;\n              for(kk=0; kk<pIdx->nKeyCol; kk++){\n                int iCol = pIdx->aiColumn[kk];\n                assert( iCol!=XN_ROWID && iCol<pTab->nCol );\n                if( iCol>=0 && pTab->aCol[iCol].notNull ) continue;\n                sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk);\n                VdbeCoverage(v);\n              }\n              jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);\n              sqlite3VdbeGoto(v, uniqOk);\n              sqlite3VdbeJumpHere(v, jmp6);\n              sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,\n                                   pIdx->nKeyCol); VdbeCoverage(v);\n              sqlite3VdbeLoadString(v, 3, \"non-unique entry in index \");\n              sqlite3VdbeGoto(v, jmp5);\n              sqlite3VdbeResolveLabel(v, uniqOk);\n            }\n            sqlite3VdbeJumpHere(v, jmp4);\n            sqlite3ResolvePartIdxLabel(pParse, jmp3);\n          }\n        }\n        sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);\n        sqlite3VdbeJumpHere(v, loopTop-1);\n#ifndef SQLITE_OMIT_BTREECOUNT\n        if( !isQuick ){\n          sqlite3VdbeLoadString(v, 2, \"wrong # of entries in index \");\n          for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n            if( pPk==pIdx ) continue;\n            sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);\n            addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);\n            sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);\n            sqlite3VdbeLoadString(v, 4, pIdx->zName);\n            sqlite3VdbeAddOp3(v, OP_Concat, 4, 2, 3);\n            integrityCheckResultRow(v);\n            sqlite3VdbeJumpHere(v, addr);\n          }\n        }\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      } \n    }\n    {\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList endCode[] = {\n        { OP_AddImm,      1, 0,        0},    /* 0 */\n        { OP_IfNotZero,   1, 4,        0},    /* 1 */\n        { OP_String8,     0, 3,        0},    /* 2 */\n        { OP_ResultRow,   3, 1,        0},    /* 3 */\n        { OP_Halt,        0, 0,        0},    /* 4 */\n        { OP_String8,     0, 3,        0},    /* 5 */\n        { OP_Goto,        0, 3,        0},    /* 6 */\n      };\n      VdbeOp *aOp;\n\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);\n      if( aOp ){\n        aOp[0].p2 = 1-mxErr;\n        aOp[2].p4type = P4_STATIC;\n        aOp[2].p4.z = \"ok\";\n        aOp[5].p4type = P4_STATIC;\n        aOp[5].p4.z = (char*)sqlite3ErrStr(SQLITE_CORRUPT);\n      }\n      sqlite3VdbeChangeP3(v, 0, sqlite3VdbeCurrentAddr(v)-2);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n#ifndef SQLITE_OMIT_UTF16\n  /*\n  **   PRAGMA encoding\n  **   PRAGMA encoding = \"utf-8\"|\"utf-16\"|\"utf-16le\"|\"utf-16be\"\n  **\n  ** In its first form, this pragma returns the encoding of the main\n  ** database. If the database is not initialized, it is initialized now.\n  **\n  ** The second form of this pragma is a no-op if the main database file\n  ** has not already been initialized. In this case it sets the default\n  ** encoding that will be used for the main database file if a new file\n  ** is created. If an existing main database file is opened, then the\n  ** default text encoding for the existing database is used.\n  ** \n  ** In all cases new databases created using the ATTACH command are\n  ** created to use the same default text encoding as the main database. If\n  ** the main database has not been initialized and/or created when ATTACH\n  ** is executed, this is done before the ATTACH operation.\n  **\n  ** In the second form this pragma sets the text encoding to be used in\n  ** new database files created using this database handle. It is only\n  ** useful if invoked immediately after the main database i\n  */\n  case PragTyp_ENCODING: {\n    static const struct EncName {\n      char *zName;\n      u8 enc;\n    } encnames[] = {\n      { \"UTF8\",     SQLITE_UTF8        },\n      { \"UTF-8\",    SQLITE_UTF8        },  /* Must be element [1] */\n      { \"UTF-16le\", SQLITE_UTF16LE     },  /* Must be element [2] */\n      { \"UTF-16be\", SQLITE_UTF16BE     },  /* Must be element [3] */\n      { \"UTF16le\",  SQLITE_UTF16LE     },\n      { \"UTF16be\",  SQLITE_UTF16BE     },\n      { \"UTF-16\",   0                  }, /* SQLITE_UTF16NATIVE */\n      { \"UTF16\",    0                  }, /* SQLITE_UTF16NATIVE */\n      { 0, 0 }\n    };\n    const struct EncName *pEnc;\n    if( !zRight ){    /* \"PRAGMA encoding\" */\n      if( sqlite3ReadSchema(pParse) ) goto pragma_out;\n      assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 );\n      assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE );\n      assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE );\n      returnSingleText(v, encnames[ENC(pParse->db)].zName);\n    }else{                        /* \"PRAGMA encoding = XXX\" */\n      /* Only change the value of sqlite.enc if the database handle is not\n      ** initialized. If the main database exists, the new sqlite.enc value\n      ** will be overwritten when the schema is next loaded. If it does not\n      ** already exists, it will be created to use the new encoding value.\n      */\n      if( \n        !(DbHasProperty(db, 0, DB_SchemaLoaded)) || \n        DbHasProperty(db, 0, DB_Empty) \n      ){\n        for(pEnc=&encnames[0]; pEnc->zName; pEnc++){\n          if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){\n            SCHEMA_ENC(db) = ENC(db) =\n                pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;\n            break;\n          }\n        }\n        if( !pEnc->zName ){\n          sqlite3ErrorMsg(pParse, \"unsupported encoding: %s\", zRight);\n        }\n      }\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  /*\n  **   PRAGMA [schema.]schema_version\n  **   PRAGMA [schema.]schema_version = <integer>\n  **\n  **   PRAGMA [schema.]user_version\n  **   PRAGMA [schema.]user_version = <integer>\n  **\n  **   PRAGMA [schema.]freelist_count\n  **\n  **   PRAGMA [schema.]data_version\n  **\n  **   PRAGMA [schema.]application_id\n  **   PRAGMA [schema.]application_id = <integer>\n  **\n  ** The pragma's schema_version and user_version are used to set or get\n  ** the value of the schema-version and user-version, respectively. Both\n  ** the schema-version and the user-version are 32-bit signed integers\n  ** stored in the database header.\n  **\n  ** The schema-cookie is usually only manipulated internally by SQLite. It\n  ** is incremented by SQLite whenever the database schema is modified (by\n  ** creating or dropping a table or index). The schema version is used by\n  ** SQLite each time a query is executed to ensure that the internal cache\n  ** of the schema used when compiling the SQL query matches the schema of\n  ** the database against which the compiled query is actually executed.\n  ** Subverting this mechanism by using \"PRAGMA schema_version\" to modify\n  ** the schema-version is potentially dangerous and may lead to program\n  ** crashes or database corruption. Use with caution!\n  **\n  ** The user-version is not used internally by SQLite. It may be used by\n  ** applications for any purpose.\n  */\n  case PragTyp_HEADER_VALUE: {\n    int iCookie = pPragma->iArg;  /* Which cookie to read or write */\n    sqlite3VdbeUsesBtree(v, iDb);\n    if( zRight && (pPragma->mPragFlg & PragFlg_ReadOnly)==0 ){\n      /* Write the specified cookie value */\n      static const VdbeOpList setCookie[] = {\n        { OP_Transaction,    0,  1,  0},    /* 0 */\n        { OP_SetCookie,      0,  0,  0},    /* 1 */\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(setCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(setCookie), setCookie, 0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p2 = iCookie;\n      aOp[1].p3 = sqlite3Atoi(zRight);\n    }else{\n      /* Read the specified cookie value */\n      static const VdbeOpList readCookie[] = {\n        { OP_Transaction,     0,  0,  0},    /* 0 */\n        { OP_ReadCookie,      0,  1,  0},    /* 1 */\n        { OP_ResultRow,       1,  1,  0}\n      };\n      VdbeOp *aOp;\n      sqlite3VdbeVerifyNoMallocRequired(v, ArraySize(readCookie));\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(readCookie),readCookie,0);\n      if( ONLY_IF_REALLOC_STRESS(aOp==0) ) break;\n      aOp[0].p1 = iDb;\n      aOp[1].p1 = iDb;\n      aOp[1].p3 = iCookie;\n      sqlite3VdbeReusable(v);\n    }\n  }\n  break;\n#endif /* SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS */\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  /*\n  **   PRAGMA compile_options\n  **\n  ** Return the names of all compile-time options used in this build,\n  ** one option per row.\n  */\n  case PragTyp_COMPILE_OPTIONS: {\n    int i = 0;\n    const char *zOpt;\n    pParse->nMem = 1;\n    while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){\n      sqlite3VdbeLoadString(v, 1, zOpt);\n      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);\n    }\n    sqlite3VdbeReusable(v);\n  }\n  break;\n#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */\n\n#ifndef SQLITE_OMIT_WAL\n  /*\n  **   PRAGMA [schema.]wal_checkpoint = passive|full|restart|truncate\n  **\n  ** Checkpoint the database.\n  */\n  case PragTyp_WAL_CHECKPOINT: {\n    int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED);\n    int eMode = SQLITE_CHECKPOINT_PASSIVE;\n    if( zRight ){\n      if( sqlite3StrICmp(zRight, \"full\")==0 ){\n        eMode = SQLITE_CHECKPOINT_FULL;\n      }else if( sqlite3StrICmp(zRight, \"restart\")==0 ){\n        eMode = SQLITE_CHECKPOINT_RESTART;\n      }else if( sqlite3StrICmp(zRight, \"truncate\")==0 ){\n        eMode = SQLITE_CHECKPOINT_TRUNCATE;\n      }\n    }\n    pParse->nMem = 3;\n    sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1);\n    sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);\n  }\n  break;\n\n  /*\n  **   PRAGMA wal_autocheckpoint\n  **   PRAGMA wal_autocheckpoint = N\n  **\n  ** Configure a database connection to automatically checkpoint a database\n  ** after accumulating N frames in the log. Or query for the current value\n  ** of N.\n  */\n  case PragTyp_WAL_AUTOCHECKPOINT: {\n    if( zRight ){\n      sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, \n       db->xWalCallback==sqlite3WalDefaultHook ? \n           SQLITE_PTR_TO_INT(db->pWalArg) : 0);\n  }\n  break;\n#endif\n\n  /*\n  **  PRAGMA shrink_memory\n  **\n  ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database\n  ** connection on which it is invoked to free up as much memory as it\n  ** can, by calling sqlite3_db_release_memory().\n  */\n  case PragTyp_SHRINK_MEMORY: {\n    sqlite3_db_release_memory(db);\n    break;\n  }\n\n  /*\n  **  PRAGMA optimize\n  **  PRAGMA optimize(MASK)\n  **  PRAGMA schema.optimize\n  **  PRAGMA schema.optimize(MASK)\n  **\n  ** Attempt to optimize the database.  All schemas are optimized in the first\n  ** two forms, and only the specified schema is optimized in the latter two.\n  **\n  ** The details of optimizations performed by this pragma are expected\n  ** to change and improve over time.  Applications should anticipate that\n  ** this pragma will perform new optimizations in future releases.\n  **\n  ** The optional argument is a bitmask of optimizations to perform:\n  **\n  **    0x0001    Debugging mode.  Do not actually perform any optimizations\n  **              but instead return one line of text for each optimization\n  **              that would have been done.  Off by default.\n  **\n  **    0x0002    Run ANALYZE on tables that might benefit.  On by default.\n  **              See below for additional information.\n  **\n  **    0x0004    (Not yet implemented) Record usage and performance \n  **              information from the current session in the\n  **              database file so that it will be available to \"optimize\"\n  **              pragmas run by future database connections.\n  **\n  **    0x0008    (Not yet implemented) Create indexes that might have\n  **              been helpful to recent queries\n  **\n  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all\n  ** of the optimizations listed above except Debug Mode, including new\n  ** optimizations that have not yet been invented.  If new optimizations are\n  ** ever added that should be off by default, those off-by-default \n  ** optimizations will have bitmasks of 0x10000 or larger.\n  **\n  ** DETERMINATION OF WHEN TO RUN ANALYZE\n  **\n  ** In the current implementation, a table is analyzed if only if all of\n  ** the following are true:\n  **\n  ** (1) MASK bit 0x02 is set.\n  **\n  ** (2) The query planner used sqlite_stat1-style statistics for one or\n  **     more indexes of the table at some point during the lifetime of\n  **     the current connection.\n  **\n  ** (3) One or more indexes of the table are currently unanalyzed OR\n  **     the number of rows in the table has increased by 25 times or more\n  **     since the last time ANALYZE was run.\n  **\n  ** The rules for when tables are analyzed are likely to change in\n  ** future releases.\n  */\n  case PragTyp_OPTIMIZE: {\n    int iDbLast;           /* Loop termination point for the schema loop */\n    int iTabCur;           /* Cursor for a table whose size needs checking */\n    HashElem *k;           /* Loop over tables of a schema */\n    Schema *pSchema;       /* The current schema */\n    Table *pTab;           /* A table in the schema */\n    Index *pIdx;           /* An index of the table */\n    LogEst szThreshold;    /* Size threshold above which reanalysis is needd */\n    char *zSubSql;         /* SQL statement for the OP_SqlExec opcode */\n    u32 opMask;            /* Mask of operations to perform */\n\n    if( zRight ){\n      opMask = (u32)sqlite3Atoi(zRight);\n      if( (opMask & 0x02)==0 ) break;\n    }else{\n      opMask = 0xfffe;\n    }\n    iTabCur = pParse->nTab++;\n    for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){\n      if( iDb==1 ) continue;\n      sqlite3CodeVerifySchema(pParse, iDb);\n      pSchema = db->aDb[iDb].pSchema;\n      for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){\n        pTab = (Table*)sqliteHashData(k);\n\n        /* If table pTab has not been used in a way that would benefit from\n        ** having analysis statistics during the current session, then skip it.\n        ** This also has the effect of skipping virtual tables and views */\n        if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;\n\n        /* Reanalyze if the table is 25 times larger than the last analysis */\n        szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( !pIdx->hasStat1 ){\n            szThreshold = 0; /* Always analyze if any index lacks statistics */\n            break;\n          }\n        }\n        if( szThreshold ){\n          sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);\n          sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur, \n                         sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);\n          VdbeCoverage(v);\n        }\n        zSubSql = sqlite3MPrintf(db, \"ANALYZE \\\"%w\\\".\\\"%w\\\"\",\n                                 db->aDb[iDb].zDbSName, pTab->zName);\n        if( opMask & 0x01 ){\n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);\n          sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);\n        }else{\n          sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);\n        }\n      }\n    }\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    break;\n  }\n\n  /*\n  **   PRAGMA busy_timeout\n  **   PRAGMA busy_timeout = N\n  **\n  ** Call sqlite3_busy_timeout(db, N).  Return the current timeout value\n  ** if one is set.  If no busy handler or a different busy handler is set\n  ** then 0 is returned.  Setting the busy_timeout to 0 or negative\n  ** disables the timeout.\n  */\n  /*case PragTyp_BUSY_TIMEOUT*/ default: {\n    assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT );\n    if( zRight ){\n      sqlite3_busy_timeout(db, sqlite3Atoi(zRight));\n    }\n    returnSingleInt(v, db->busyTimeout);\n    break;\n  }\n\n  /*\n  **   PRAGMA soft_heap_limit\n  **   PRAGMA soft_heap_limit = N\n  **\n  ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the\n  ** sqlite3_soft_heap_limit64() interface with the argument N, if N is\n  ** specified and is a non-negative integer.\n  ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always\n  ** returns the same integer that would be returned by the\n  ** sqlite3_soft_heap_limit64(-1) C-language function.\n  */\n  case PragTyp_SOFT_HEAP_LIMIT: {\n    sqlite3_int64 N;\n    if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){\n      sqlite3_soft_heap_limit64(N);\n    }\n    returnSingleInt(v, sqlite3_soft_heap_limit64(-1));\n    break;\n  }\n\n  /*\n  **   PRAGMA threads\n  **   PRAGMA threads = N\n  **\n  ** Configure the maximum number of worker threads.  Return the new\n  ** maximum, which might be less than requested.\n  */\n  case PragTyp_THREADS: {\n    sqlite3_int64 N;\n    if( zRight\n     && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK\n     && N>=0\n    ){\n      sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, (int)(N&0x7fffffff));\n    }\n    returnSingleInt(v, sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1));\n    break;\n  }\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n  /*\n  ** Report the current state of file logs for all databases\n  */\n  case PragTyp_LOCK_STATUS: {\n    static const char *const azLockName[] = {\n      \"unlocked\", \"shared\", \"reserved\", \"pending\", \"exclusive\"\n    };\n    int i;\n    pParse->nMem = 2;\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt;\n      const char *zState = \"unknown\";\n      int j;\n      if( db->aDb[i].zDbSName==0 ) continue;\n      pBt = db->aDb[i].pBt;\n      if( pBt==0 || sqlite3BtreePager(pBt)==0 ){\n        zState = \"closed\";\n      }else if( sqlite3_file_control(db, i ? db->aDb[i].zDbSName : 0, \n                                     SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){\n         zState = azLockName[j];\n      }\n      sqlite3VdbeMultiLoad(v, 1, \"ss\", db->aDb[i].zDbSName, zState);\n    }\n    break;\n  }\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n  case PragTyp_KEY: {\n    if( zRight ) sqlite3_key_v2(db, zDb, zRight, sqlite3Strlen30(zRight));\n    break;\n  }\n  case PragTyp_REKEY: {\n    if( zRight ) sqlite3_rekey_v2(db, zDb, zRight, sqlite3Strlen30(zRight));\n    break;\n  }\n  case PragTyp_HEXKEY: {\n    if( zRight ){\n      u8 iByte;\n      int i;\n      char zKey[40];\n      for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zRight[i]); i++){\n        iByte = (iByte<<4) + sqlite3HexToInt(zRight[i]);\n        if( (i&1)!=0 ) zKey[i/2] = iByte;\n      }\n      if( (zLeft[3] & 0xf)==0xb ){\n        sqlite3_key_v2(db, zDb, zKey, i/2);\n      }else{\n        sqlite3_rekey_v2(db, zDb, zKey, i/2);\n      }\n    }\n    break;\n  }\n#endif\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n  case PragTyp_ACTIVATE_EXTENSIONS: if( zRight ){\n#ifdef SQLITE_HAS_CODEC\n    if( sqlite3StrNICmp(zRight, \"see-\", 4)==0 ){\n      sqlite3_activate_see(&zRight[4]);\n    }\n#endif\n#ifdef SQLITE_ENABLE_CEROD\n    if( sqlite3StrNICmp(zRight, \"cerod-\", 6)==0 ){\n      sqlite3_activate_cerod(&zRight[6]);\n    }\n#endif\n  }\n  break;\n#endif\n\n  } /* End of the PRAGMA switch */\n\n  /* The following block is a no-op unless SQLITE_DEBUG is defined. Its only\n  ** purpose is to execute assert() statements to verify that if the\n  ** PragFlg_NoColumns1 flag is set and the caller specified an argument\n  ** to the PRAGMA, the implementation has not added any OP_ResultRow \n  ** instructions to the VM.  */\n  if( (pPragma->mPragFlg & PragFlg_NoColumns1) && zRight ){\n    sqlite3VdbeVerifyNoResultRow(v);\n  }\n\npragma_out:\n  sqlite3DbFree(db, zLeft);\n  sqlite3DbFree(db, zRight);\n}\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*****************************************************************************\n** Implementation of an eponymous virtual table that runs a pragma.\n**\n*/\ntypedef struct PragmaVtab PragmaVtab;\ntypedef struct PragmaVtabCursor PragmaVtabCursor;\nstruct PragmaVtab {\n  sqlite3_vtab base;        /* Base class.  Must be first */\n  sqlite3 *db;              /* The database connection to which it belongs */\n  const PragmaName *pName;  /* Name of the pragma */\n  u8 nHidden;               /* Number of hidden columns */\n  u8 iHidden;               /* Index of the first hidden column */\n};\nstruct PragmaVtabCursor {\n  sqlite3_vtab_cursor base; /* Base class.  Must be first */\n  sqlite3_stmt *pPragma;    /* The pragma statement to run */\n  sqlite_int64 iRowid;      /* Current rowid */\n  char *azArg[2];           /* Value of the argument and schema */\n};\n\n/* \n** Pragma virtual table module xConnect method.\n*/\nstatic int pragmaVtabConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  const PragmaName *pPragma = (const PragmaName*)pAux;\n  PragmaVtab *pTab = 0;\n  int rc;\n  int i, j;\n  char cSep = '(';\n  StrAccum acc;\n  char zBuf[200];\n\n  UNUSED_PARAMETER(argc);\n  UNUSED_PARAMETER(argv);\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  sqlite3StrAccumAppendAll(&acc, \"CREATE TABLE x\");\n  for(i=0, j=pPragma->iPragCName; i<pPragma->nPragCName; i++, j++){\n    sqlite3XPrintf(&acc, \"%c\\\"%s\\\"\", cSep, pragCName[j]);\n    cSep = ',';\n  }\n  if( i==0 ){\n    sqlite3XPrintf(&acc, \"(\\\"%s\\\"\", pPragma->zName);\n    cSep = ',';\n    i++;\n  }\n  j = 0;\n  if( pPragma->mPragFlg & PragFlg_Result1 ){\n    sqlite3StrAccumAppendAll(&acc, \",arg HIDDEN\");\n    j++;\n  }\n  if( pPragma->mPragFlg & (PragFlg_SchemaOpt|PragFlg_SchemaReq) ){\n    sqlite3StrAccumAppendAll(&acc, \",schema HIDDEN\");\n    j++;\n  }\n  sqlite3StrAccumAppend(&acc, \")\", 1);\n  sqlite3StrAccumFinish(&acc);\n  assert( strlen(zBuf) < sizeof(zBuf)-1 );\n  rc = sqlite3_declare_vtab(db, zBuf);\n  if( rc==SQLITE_OK ){\n    pTab = (PragmaVtab*)sqlite3_malloc(sizeof(PragmaVtab));\n    if( pTab==0 ){\n      rc = SQLITE_NOMEM;\n    }else{\n      memset(pTab, 0, sizeof(PragmaVtab));\n      pTab->pName = pPragma;\n      pTab->db = db;\n      pTab->iHidden = i;\n      pTab->nHidden = j;\n    }\n  }else{\n    *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n  }\n\n  *ppVtab = (sqlite3_vtab*)pTab;\n  return rc;\n}\n\n/* \n** Pragma virtual table module xDisconnect method.\n*/\nstatic int pragmaVtabDisconnect(sqlite3_vtab *pVtab){\n  PragmaVtab *pTab = (PragmaVtab*)pVtab;\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/* Figure out the best index to use to search a pragma virtual table.\n**\n** There are not really any index choices.  But we want to encourage the\n** query planner to give == constraints on as many hidden parameters as\n** possible, and especially on the first hidden parameter.  So return a\n** high cost if hidden parameters are unconstrained.\n*/\nstatic int pragmaVtabBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  PragmaVtab *pTab = (PragmaVtab*)tab;\n  const struct sqlite3_index_constraint *pConstraint;\n  int i, j;\n  int seen[2];\n\n  pIdxInfo->estimatedCost = (double)1;\n  if( pTab->nHidden==0 ){ return SQLITE_OK; }\n  pConstraint = pIdxInfo->aConstraint;\n  seen[0] = 0;\n  seen[1] = 0;\n  for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){\n    if( pConstraint->usable==0 ) continue;\n    if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;\n    if( pConstraint->iColumn < pTab->iHidden ) continue;\n    j = pConstraint->iColumn - pTab->iHidden;\n    assert( j < 2 );\n    seen[j] = i+1;\n  }\n  if( seen[0]==0 ){\n    pIdxInfo->estimatedCost = (double)2147483647;\n    pIdxInfo->estimatedRows = 2147483647;\n    return SQLITE_OK;\n  }\n  j = seen[0]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 1;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  if( seen[1]==0 ) return SQLITE_OK;\n  pIdxInfo->estimatedCost = (double)20;\n  pIdxInfo->estimatedRows = 20;\n  j = seen[1]-1;\n  pIdxInfo->aConstraintUsage[j].argvIndex = 2;\n  pIdxInfo->aConstraintUsage[j].omit = 1;\n  return SQLITE_OK;\n}\n\n/* Create a new cursor for the pragma virtual table */\nstatic int pragmaVtabOpen(sqlite3_vtab *pVtab, sqlite3_vtab_cursor **ppCursor){\n  PragmaVtabCursor *pCsr;\n  pCsr = (PragmaVtabCursor*)sqlite3_malloc(sizeof(*pCsr));\n  if( pCsr==0 ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(PragmaVtabCursor));\n  pCsr->base.pVtab = pVtab;\n  *ppCursor = &pCsr->base;\n  return SQLITE_OK;\n}\n\n/* Clear all content from pragma virtual table cursor. */\nstatic void pragmaVtabCursorClear(PragmaVtabCursor *pCsr){\n  int i;\n  sqlite3_finalize(pCsr->pPragma);\n  pCsr->pPragma = 0;\n  for(i=0; i<ArraySize(pCsr->azArg); i++){\n    sqlite3_free(pCsr->azArg[i]);\n    pCsr->azArg[i] = 0;\n  }\n}\n\n/* Close a pragma virtual table cursor */\nstatic int pragmaVtabClose(sqlite3_vtab_cursor *cur){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)cur;\n  pragmaVtabCursorClear(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/* Advance the pragma virtual table cursor to the next row */\nstatic int pragmaVtabNext(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  int rc = SQLITE_OK;\n\n  /* Increment the xRowid value */\n  pCsr->iRowid++;\n  assert( pCsr->pPragma );\n  if( SQLITE_ROW!=sqlite3_step(pCsr->pPragma) ){\n    rc = sqlite3_finalize(pCsr->pPragma);\n    pCsr->pPragma = 0;\n    pragmaVtabCursorClear(pCsr);\n  }\n  return rc;\n}\n\n/* \n** Pragma virtual table module xFilter method.\n*/\nstatic int pragmaVtabFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  int rc;\n  int i, j;\n  StrAccum acc;\n  char *zSql;\n\n  UNUSED_PARAMETER(idxNum);\n  UNUSED_PARAMETER(idxStr);\n  pragmaVtabCursorClear(pCsr);\n  j = (pTab->pName->mPragFlg & PragFlg_Result1)!=0 ? 0 : 1;\n  for(i=0; i<argc; i++, j++){\n    const char *zText = (const char*)sqlite3_value_text(argv[i]);\n    assert( j<ArraySize(pCsr->azArg) );\n    assert( pCsr->azArg[j]==0 );\n    if( zText ){\n      pCsr->azArg[j] = sqlite3_mprintf(\"%s\", zText);\n      if( pCsr->azArg[j]==0 ){\n        return SQLITE_NOMEM;\n      }\n    }\n  }\n  sqlite3StrAccumInit(&acc, 0, 0, 0, pTab->db->aLimit[SQLITE_LIMIT_SQL_LENGTH]);\n  sqlite3StrAccumAppendAll(&acc, \"PRAGMA \");\n  if( pCsr->azArg[1] ){\n    sqlite3XPrintf(&acc, \"%Q.\", pCsr->azArg[1]);\n  }\n  sqlite3StrAccumAppendAll(&acc, pTab->pName->zName);\n  if( pCsr->azArg[0] ){\n    sqlite3XPrintf(&acc, \"=%Q\", pCsr->azArg[0]);\n  }\n  zSql = sqlite3StrAccumFinish(&acc);\n  if( zSql==0 ) return SQLITE_NOMEM;\n  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pPragma, 0);\n  sqlite3_free(zSql);\n  if( rc!=SQLITE_OK ){\n    pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pTab->db));\n    return rc;\n  }\n  return pragmaVtabNext(pVtabCursor);\n}\n\n/*\n** Pragma virtual table module xEof method.\n*/\nstatic int pragmaVtabEof(sqlite3_vtab_cursor *pVtabCursor){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  return (pCsr->pPragma==0);\n}\n\n/* The xColumn method simply returns the corresponding column from\n** the PRAGMA.  \n*/\nstatic int pragmaVtabColumn(\n  sqlite3_vtab_cursor *pVtabCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  PragmaVtab *pTab = (PragmaVtab*)(pVtabCursor->pVtab);\n  if( i<pTab->iHidden ){\n    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pPragma, i));\n  }else{\n    sqlite3_result_text(ctx, pCsr->azArg[i-pTab->iHidden],-1,SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Pragma virtual table module xRowid method.\n*/\nstatic int pragmaVtabRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *p){\n  PragmaVtabCursor *pCsr = (PragmaVtabCursor*)pVtabCursor;\n  *p = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\n/* The pragma virtual table object */\nstatic const sqlite3_module pragmaVtabModule = {\n  0,                           /* iVersion */\n  0,                           /* xCreate - create a table */\n  pragmaVtabConnect,           /* xConnect - connect to an existing table */\n  pragmaVtabBestIndex,         /* xBestIndex - Determine search strategy */\n  pragmaVtabDisconnect,        /* xDisconnect - Disconnect from a table */\n  0,                           /* xDestroy - Drop a table */\n  pragmaVtabOpen,              /* xOpen - open a cursor */\n  pragmaVtabClose,             /* xClose - close a cursor */\n  pragmaVtabFilter,            /* xFilter - configure scan constraints */\n  pragmaVtabNext,              /* xNext - advance a cursor */\n  pragmaVtabEof,               /* xEof */\n  pragmaVtabColumn,            /* xColumn - read data */\n  pragmaVtabRowid,             /* xRowid - read data */\n  0,                           /* xUpdate - write data */\n  0,                           /* xBegin - begin transaction */\n  0,                           /* xSync - sync transaction */\n  0,                           /* xCommit - commit transaction */\n  0,                           /* xRollback - rollback transaction */\n  0,                           /* xFindFunction - function overloading */\n  0,                           /* xRename - rename the table */\n  0,                           /* xSavepoint */\n  0,                           /* xRelease */\n  0                            /* xRollbackTo */\n};\n\n/*\n** Check to see if zTabName is really the name of a pragma.  If it is,\n** then register an eponymous virtual table for that pragma and return\n** a pointer to the Module object for the new virtual table.\n*/\nModule *sqlite3PragmaVtabRegister(sqlite3 *db, const char *zName){\n  const PragmaName *pName;\n  assert( sqlite3_strnicmp(zName, \"pragma_\", 7)==0 );\n  pName = pragmaLocate(zName+7);\n  if( pName==0 ) return 0;\n  if( (pName->mPragFlg & (PragFlg_Result0|PragFlg_Result1))==0 ) return 0;\n  assert( sqlite3HashFind(&db->aModule, zName)==0 );\n  return sqlite3VtabCreateModule(db, zName, &pragmaVtabModule, (void*)pName, 0);\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#endif /* SQLITE_OMIT_PRAGMA */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/pragma.h",
    "content": "/* DO NOT EDIT!\n** This file is automatically generated by the script at\n** ../tool/mkpragmatab.tcl.  To update the set of pragmas, edit\n** that script and rerun it.\n*/\n\n/* The various pragma types */\n#define PragTyp_HEADER_VALUE                   0\n#define PragTyp_AUTO_VACUUM                    1\n#define PragTyp_FLAG                           2\n#define PragTyp_BUSY_TIMEOUT                   3\n#define PragTyp_CACHE_SIZE                     4\n#define PragTyp_CACHE_SPILL                    5\n#define PragTyp_CASE_SENSITIVE_LIKE            6\n#define PragTyp_COLLATION_LIST                 7\n#define PragTyp_COMPILE_OPTIONS                8\n#define PragTyp_DATA_STORE_DIRECTORY           9\n#define PragTyp_DATABASE_LIST                 10\n#define PragTyp_DEFAULT_CACHE_SIZE            11\n#define PragTyp_ENCODING                      12\n#define PragTyp_FOREIGN_KEY_CHECK             13\n#define PragTyp_FOREIGN_KEY_LIST              14\n#define PragTyp_FUNCTION_LIST                 15\n#define PragTyp_INCREMENTAL_VACUUM            16\n#define PragTyp_INDEX_INFO                    17\n#define PragTyp_INDEX_LIST                    18\n#define PragTyp_INTEGRITY_CHECK               19\n#define PragTyp_JOURNAL_MODE                  20\n#define PragTyp_JOURNAL_SIZE_LIMIT            21\n#define PragTyp_LOCK_PROXY_FILE               22\n#define PragTyp_LOCKING_MODE                  23\n#define PragTyp_PAGE_COUNT                    24\n#define PragTyp_MMAP_SIZE                     25\n#define PragTyp_MODULE_LIST                   26\n#define PragTyp_OPTIMIZE                      27\n#define PragTyp_PAGE_SIZE                     28\n#define PragTyp_PRAGMA_LIST                   29\n#define PragTyp_SECURE_DELETE                 30\n#define PragTyp_SHRINK_MEMORY                 31\n#define PragTyp_SOFT_HEAP_LIMIT               32\n#define PragTyp_SYNCHRONOUS                   33\n#define PragTyp_TABLE_INFO                    34\n#define PragTyp_TEMP_STORE                    35\n#define PragTyp_TEMP_STORE_DIRECTORY          36\n#define PragTyp_THREADS                       37\n#define PragTyp_WAL_AUTOCHECKPOINT            38\n#define PragTyp_WAL_CHECKPOINT                39\n#define PragTyp_ACTIVATE_EXTENSIONS           40\n#define PragTyp_HEXKEY                        41\n#define PragTyp_KEY                           42\n#define PragTyp_REKEY                         43\n#define PragTyp_LOCK_STATUS                   44\n#define PragTyp_PARSER_TRACE                  45\n#define PragTyp_STATS                         46\n\n/* Property flags associated with various pragma. */\n#define PragFlg_NeedSchema 0x01 /* Force schema load before running */\n#define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */\n#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */\n#define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */\n#define PragFlg_Result0    0x10 /* Acts as query when no argument */\n#define PragFlg_Result1    0x20 /* Acts as query when has one argument */\n#define PragFlg_SchemaOpt  0x40 /* Schema restricts name search if present */\n#define PragFlg_SchemaReq  0x80 /* Schema required - \"main\" is default */\n\n/* Names of columns for pragmas that return multi-column result\n** or that return single-column results where the name of the\n** result column is different from the name of the pragma\n*/\nstatic const char *const pragCName[] = {\n  /*   0 */ \"cache_size\",  /* Used by: default_cache_size */\n  /*   1 */ \"cid\",         /* Used by: table_info */\n  /*   2 */ \"name\",       \n  /*   3 */ \"type\",       \n  /*   4 */ \"notnull\",    \n  /*   5 */ \"dflt_value\", \n  /*   6 */ \"pk\",         \n  /*   7 */ \"tbl\",         /* Used by: stats */\n  /*   8 */ \"idx\",        \n  /*   9 */ \"wdth\",       \n  /*  10 */ \"hght\",       \n  /*  11 */ \"flgs\",       \n  /*  12 */ \"seqno\",       /* Used by: index_info */\n  /*  13 */ \"cid\",        \n  /*  14 */ \"name\",       \n  /*  15 */ \"seqno\",       /* Used by: index_xinfo */\n  /*  16 */ \"cid\",        \n  /*  17 */ \"name\",       \n  /*  18 */ \"desc\",       \n  /*  19 */ \"coll\",       \n  /*  20 */ \"key\",        \n  /*  21 */ \"seq\",         /* Used by: index_list */\n  /*  22 */ \"name\",       \n  /*  23 */ \"unique\",     \n  /*  24 */ \"origin\",     \n  /*  25 */ \"partial\",    \n  /*  26 */ \"seq\",         /* Used by: database_list */\n  /*  27 */ \"name\",       \n  /*  28 */ \"file\",       \n  /*  29 */ \"name\",        /* Used by: function_list */\n  /*  30 */ \"builtin\",    \n  /*  31 */ \"name\",        /* Used by: module_list pragma_list */\n  /*  32 */ \"seq\",         /* Used by: collation_list */\n  /*  33 */ \"name\",       \n  /*  34 */ \"id\",          /* Used by: foreign_key_list */\n  /*  35 */ \"seq\",        \n  /*  36 */ \"table\",      \n  /*  37 */ \"from\",       \n  /*  38 */ \"to\",         \n  /*  39 */ \"on_update\",  \n  /*  40 */ \"on_delete\",  \n  /*  41 */ \"match\",      \n  /*  42 */ \"table\",       /* Used by: foreign_key_check */\n  /*  43 */ \"rowid\",      \n  /*  44 */ \"parent\",     \n  /*  45 */ \"fkid\",       \n  /*  46 */ \"busy\",        /* Used by: wal_checkpoint */\n  /*  47 */ \"log\",        \n  /*  48 */ \"checkpointed\",\n  /*  49 */ \"timeout\",     /* Used by: busy_timeout */\n  /*  50 */ \"database\",    /* Used by: lock_status */\n  /*  51 */ \"status\",     \n};\n\n/* Definitions of all built-in pragmas */\ntypedef struct PragmaName {\n  const char *const zName; /* Name of pragma */\n  u8 ePragTyp;             /* PragTyp_XXX value */\n  u8 mPragFlg;             /* Zero or more PragFlg_XXX values */\n  u8 iPragCName;           /* Start of column names in pragCName[] */\n  u8 nPragCName;           /* Num of col names. 0 means use pragma name */\n  u32 iArg;                /* Extra argument */\n} PragmaName;\nstatic const PragmaName aPragmaName[] = {\n#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_ENABLE_CEROD)\n {/* zName:     */ \"activate_extensions\",\n  /* ePragTyp:  */ PragTyp_ACTIVATE_EXTENSIONS,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"application_id\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_APPLICATION_ID },\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"auto_vacuum\",\n  /* ePragTyp:  */ PragTyp_AUTO_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)\n {/* zName:     */ \"automatic_index\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_AutoIndex },\n#endif\n#endif\n {/* zName:     */ \"busy_timeout\",\n  /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 49, 1,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"cache_size\",\n  /* ePragTyp:  */ PragTyp_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"cache_spill\",\n  /* ePragTyp:  */ PragTyp_CACHE_SPILL,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n {/* zName:     */ \"case_sensitive_like\",\n  /* ePragTyp:  */ PragTyp_CASE_SENSITIVE_LIKE,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"cell_size_check\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CellSizeCk },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"checkpoint_fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CkptFullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"collation_list\",\n  /* ePragTyp:  */ PragTyp_COLLATION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 32, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)\n {/* zName:     */ \"compile_options\",\n  /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"count_changes\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_CountRows },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN\n {/* zName:     */ \"data_store_directory\",\n  /* ePragTyp:  */ PragTyp_DATA_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"data_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_DATA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"database_list\",\n  /* ePragTyp:  */ PragTyp_DATABASE_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 26, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)\n {/* zName:     */ \"default_cache_size\",\n  /* ePragTyp:  */ PragTyp_DEFAULT_CACHE_SIZE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"defer_foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_DeferFKs },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"empty_result_callbacks\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_NullCallback },\n#endif\n#if !defined(SQLITE_OMIT_UTF16)\n {/* zName:     */ \"encoding\",\n  /* ePragTyp:  */ PragTyp_ENCODING,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_key_check\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,\n  /* ColNames:  */ 42, 4,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FOREIGN_KEY)\n {/* zName:     */ \"foreign_key_list\",\n  /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 34, 8,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n {/* zName:     */ \"foreign_keys\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ForeignKeys },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"freelist_count\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_ReadOnly|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_FREE_PAGE_COUNT },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"full_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullColNames },\n {/* zName:     */ \"fullfsync\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_FullFSync },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"function_list\",\n  /* ePragTyp:  */ PragTyp_FUNCTION_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 29, 2,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"hexkey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"hexrekey\",\n  /* ePragTyp:  */ PragTyp_HEXKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if !defined(SQLITE_OMIT_CHECK)\n {/* zName:     */ \"ignore_check_constraints\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_IgnoreChecks },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n {/* zName:     */ \"incremental_vacuum\",\n  /* ePragTyp:  */ PragTyp_INCREMENTAL_VACUUM,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"index_info\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 12, 3,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_list\",\n  /* ePragTyp:  */ PragTyp_INDEX_LIST,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 21, 5,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"index_xinfo\",\n  /* ePragTyp:  */ PragTyp_INDEX_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 15, 6,\n  /* iArg:      */ 1 },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"integrity_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"journal_mode\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_MODE,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"journal_size_limit\",\n  /* ePragTyp:  */ PragTyp_JOURNAL_SIZE_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"key\",\n  /* ePragTyp:  */ PragTyp_KEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"legacy_file_format\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_LegacyFileFmt },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE\n {/* zName:     */ \"lock_proxy_file\",\n  /* ePragTyp:  */ PragTyp_LOCK_PROXY_FILE,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)\n {/* zName:     */ \"lock_status\",\n  /* ePragTyp:  */ PragTyp_LOCK_STATUS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 50, 2,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"locking_mode\",\n  /* ePragTyp:  */ PragTyp_LOCKING_MODE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"max_page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"mmap_size\",\n  /* ePragTyp:  */ PragTyp_MMAP_SIZE,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n#if !defined(SQLITE_OMIT_VIRTUALTABLE)\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"module_list\",\n  /* ePragTyp:  */ PragTyp_MODULE_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 31, 1,\n  /* iArg:      */ 0 },\n#endif\n#endif\n#endif\n {/* zName:     */ \"optimize\",\n  /* ePragTyp:  */ PragTyp_OPTIMIZE,\n  /* ePragFlg:  */ PragFlg_Result1|PragFlg_NeedSchema,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"page_count\",\n  /* ePragTyp:  */ PragTyp_PAGE_COUNT,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"page_size\",\n  /* ePragTyp:  */ PragTyp_PAGE_SIZE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)\n {/* zName:     */ \"parser_trace\",\n  /* ePragTyp:  */ PragTyp_PARSER_TRACE,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if defined(SQLITE_INTROSPECTION_PRAGMAS)\n {/* zName:     */ \"pragma_list\",\n  /* ePragTyp:  */ PragTyp_PRAGMA_LIST,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 31, 1,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"query_only\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_QueryOnly },\n#endif\n#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)\n {/* zName:     */ \"quick_check\",\n  /* ePragTyp:  */ PragTyp_INTEGRITY_CHECK,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"read_uncommitted\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReadUncommit },\n {/* zName:     */ \"recursive_triggers\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_RecTriggers },\n#endif\n#if defined(SQLITE_HAS_CODEC)\n {/* zName:     */ \"rekey\",\n  /* ePragTyp:  */ PragTyp_REKEY,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"reverse_unordered_selects\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ReverseOrder },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"schema_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_SCHEMA_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"secure_delete\",\n  /* ePragTyp:  */ PragTyp_SECURE_DELETE,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"short_column_names\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_ShortColNames },\n#endif\n {/* zName:     */ \"shrink_memory\",\n  /* ePragTyp:  */ PragTyp_SHRINK_MEMORY,\n  /* ePragFlg:  */ PragFlg_NoColumns,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"soft_heap_limit\",\n  /* ePragTyp:  */ PragTyp_SOFT_HEAP_LIMIT,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"sql_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)\n {/* zName:     */ \"stats\",\n  /* ePragTyp:  */ PragTyp_STATS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,\n  /* ColNames:  */ 7, 5,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"synchronous\",\n  /* ePragTyp:  */ PragTyp_SYNCHRONOUS,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)\n {/* zName:     */ \"table_info\",\n  /* ePragTyp:  */ PragTyp_TABLE_INFO,\n  /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,\n  /* ColNames:  */ 1, 6,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)\n {/* zName:     */ \"temp_store\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"temp_store_directory\",\n  /* ePragTyp:  */ PragTyp_TEMP_STORE_DIRECTORY,\n  /* ePragFlg:  */ PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#endif\n {/* zName:     */ \"threads\",\n  /* ePragTyp:  */ PragTyp_THREADS,\n  /* ePragFlg:  */ PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)\n {/* zName:     */ \"user_version\",\n  /* ePragTyp:  */ PragTyp_HEADER_VALUE,\n  /* ePragFlg:  */ PragFlg_NoColumns1|PragFlg_Result0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ BTREE_USER_VERSION },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n#if defined(SQLITE_DEBUG)\n {/* zName:     */ \"vdbe_addoptrace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeAddopTrace },\n {/* zName:     */ \"vdbe_debug\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_SqlTrace|SQLITE_VdbeListing|SQLITE_VdbeTrace },\n {/* zName:     */ \"vdbe_eqp\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeEQP },\n {/* zName:     */ \"vdbe_listing\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeListing },\n {/* zName:     */ \"vdbe_trace\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_VdbeTrace },\n#endif\n#endif\n#if !defined(SQLITE_OMIT_WAL)\n {/* zName:     */ \"wal_autocheckpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,\n  /* ePragFlg:  */ 0,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ 0 },\n {/* zName:     */ \"wal_checkpoint\",\n  /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,\n  /* ePragFlg:  */ PragFlg_NeedSchema,\n  /* ColNames:  */ 46, 3,\n  /* iArg:      */ 0 },\n#endif\n#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)\n {/* zName:     */ \"writable_schema\",\n  /* ePragTyp:  */ PragTyp_FLAG,\n  /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,\n  /* ColNames:  */ 0, 0,\n  /* iArg:      */ SQLITE_WriteSchema },\n#endif\n};\n/* Number of pragmas: 60 on by default, 77 total. */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/prepare.c",
    "content": "/*\n** 2005 May 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation of the sqlite3_prepare()\n** interface, and routines that contribute to loading the database schema\n** from disk.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Fill the InitData structure with an error message that indicates\n** that the database is corrupt.\n*/\nstatic void corruptSchema(\n  InitData *pData,     /* Initialization context */\n  const char *zObj,    /* Object being parsed at the point of error */\n  const char *zExtra   /* Error information */\n){\n  sqlite3 *db = pData->db;\n  if( !db->mallocFailed && (db->flags & SQLITE_WriteSchema)==0 ){\n    char *z;\n    if( zObj==0 ) zObj = \"?\";\n    z = sqlite3MPrintf(db, \"malformed database schema (%s)\", zObj);\n    if( zExtra ) z = sqlite3MPrintf(db, \"%z - %s\", z, zExtra);\n    sqlite3DbFree(db, *pData->pzErrMsg);\n    *pData->pzErrMsg = z;\n  }\n  pData->rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** This is the callback routine for the code that initializes the\n** database.  See sqlite3Init() below for additional information.\n** This routine is also called from the OP_ParseSchema opcode of the VDBE.\n**\n** Each callback contains the following information:\n**\n**     argv[0] = name of thing being created\n**     argv[1] = root page number for table or index. 0 for trigger or view.\n**     argv[2] = SQL text for the CREATE statement.\n**\n*/\nint sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){\n  InitData *pData = (InitData*)pInit;\n  sqlite3 *db = pData->db;\n  int iDb = pData->iDb;\n\n  assert( argc==3 );\n  UNUSED_PARAMETER2(NotUsed, argc);\n  assert( sqlite3_mutex_held(db->mutex) );\n  DbClearProperty(db, iDb, DB_Empty);\n  if( db->mallocFailed ){\n    corruptSchema(pData, argv[0], 0);\n    return 1;\n  }\n\n  assert( iDb>=0 && iDb<db->nDb );\n  if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */\n  if( argv[1]==0 ){\n    corruptSchema(pData, argv[0], 0);\n  }else if( sqlite3_strnicmp(argv[2],\"create \",7)==0 ){\n    /* Call the parser to process a CREATE TABLE, INDEX or VIEW.\n    ** But because db->init.busy is set to 1, no VDBE code is generated\n    ** or executed.  All the parser does is build the internal data\n    ** structures that describe the table, index, or view.\n    */\n    int rc;\n    u8 saved_iDb = db->init.iDb;\n    sqlite3_stmt *pStmt;\n    TESTONLY(int rcp);            /* Return code from sqlite3_prepare() */\n\n    assert( db->init.busy );\n    db->init.iDb = iDb;\n    db->init.newTnum = sqlite3Atoi(argv[1]);\n    db->init.orphanTrigger = 0;\n    TESTONLY(rcp = ) sqlite3_prepare(db, argv[2], -1, &pStmt, 0);\n    rc = db->errCode;\n    assert( (rc&0xFF)==(rcp&0xFF) );\n    db->init.iDb = saved_iDb;\n    assert( saved_iDb==0 || (db->mDbFlags & DBFLAG_Vacuum)!=0 );\n    if( SQLITE_OK!=rc ){\n      if( db->init.orphanTrigger ){\n        assert( iDb==1 );\n      }else{\n        pData->rc = rc;\n        if( rc==SQLITE_NOMEM ){\n          sqlite3OomFault(db);\n        }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){\n          corruptSchema(pData, argv[0], sqlite3_errmsg(db));\n        }\n      }\n    }\n    sqlite3_finalize(pStmt);\n  }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){\n    corruptSchema(pData, argv[0], 0);\n  }else{\n    /* If the SQL column is blank it means this is an index that\n    ** was created to be the PRIMARY KEY or to fulfill a UNIQUE\n    ** constraint for a CREATE TABLE.  The index should have already\n    ** been created when we processed the CREATE TABLE.  All we have\n    ** to do here is record the root page number for that index.\n    */\n    Index *pIndex;\n    pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);\n    if( pIndex==0 ){\n      /* This can occur if there exists an index on a TEMP table which\n      ** has the same name as another index on a permanent index.  Since\n      ** the permanent table is hidden by the TEMP table, we can also\n      ** safely ignore the index on the permanent table.\n      */\n      /* Do Nothing */;\n    }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){\n      corruptSchema(pData, argv[0], \"invalid rootpage\");\n    }\n  }\n  return 0;\n}\n\n/*\n** Attempt to read the database schema and initialize internal\n** data structures for a single database file.  The index of the\n** database file is given by iDb.  iDb==0 is used for the main\n** database.  iDb==1 should never be used.  iDb>=2 is used for\n** auxiliary databases.  Return one of the SQLITE_ error codes to\n** indicate success or failure.\n*/\nstatic int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){\n  int rc;\n  int i;\n#ifndef SQLITE_OMIT_DEPRECATED\n  int size;\n#endif\n  Db *pDb;\n  char const *azArg[4];\n  int meta[5];\n  InitData initData;\n  const char *zMasterName;\n  int openedTransaction = 0;\n\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n\n  db->init.busy = 1;\n\n  /* Construct the in-memory representation schema tables (sqlite_master or\n  ** sqlite_temp_master) by invoking the parser directly.  The appropriate\n  ** table name will be inserted automatically by the parser so we can just\n  ** use the abbreviation \"x\" here.  The parser will also automatically tag\n  ** the schema table as read-only. */\n  azArg[0] = zMasterName = SCHEMA_TABLE(iDb);\n  azArg[1] = \"1\";\n  azArg[2] = \"CREATE TABLE x(type text,name text,tbl_name text,\"\n                            \"rootpage int,sql text)\";\n  azArg[3] = 0;\n  initData.db = db;\n  initData.iDb = iDb;\n  initData.rc = SQLITE_OK;\n  initData.pzErrMsg = pzErrMsg;\n  sqlite3InitCallback(&initData, 3, (char **)azArg, 0);\n  if( initData.rc ){\n    rc = initData.rc;\n    goto error_out;\n  }\n\n  /* Create a cursor to hold the database open\n  */\n  pDb = &db->aDb[iDb];\n  if( pDb->pBt==0 ){\n    assert( iDb==1 );\n    DbSetProperty(db, 1, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n    goto error_out;\n  }\n\n  /* If there is not already a read-only (or read-write) transaction opened\n  ** on the b-tree database, open one now. If a transaction is opened, it \n  ** will be closed before this function returns.  */\n  sqlite3BtreeEnter(pDb->pBt);\n  if( !sqlite3BtreeIsInReadTrans(pDb->pBt) ){\n    rc = sqlite3BtreeBeginTrans(pDb->pBt, 0);\n    if( rc!=SQLITE_OK ){\n      sqlite3SetString(pzErrMsg, db, sqlite3ErrStr(rc));\n      goto initone_error_out;\n    }\n    openedTransaction = 1;\n  }\n\n  /* Get the database meta information.\n  **\n  ** Meta values are as follows:\n  **    meta[0]   Schema cookie.  Changes with each schema change.\n  **    meta[1]   File format of schema layer.\n  **    meta[2]   Size of the page cache.\n  **    meta[3]   Largest rootpage (auto/incr_vacuum mode)\n  **    meta[4]   Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE\n  **    meta[5]   User version\n  **    meta[6]   Incremental vacuum mode\n  **    meta[7]   unused\n  **    meta[8]   unused\n  **    meta[9]   unused\n  **\n  ** Note: The #defined SQLITE_UTF* symbols in sqliteInt.h correspond to\n  ** the possible values of meta[4].\n  */\n  for(i=0; i<ArraySize(meta); i++){\n    sqlite3BtreeGetMeta(pDb->pBt, i+1, (u32 *)&meta[i]);\n  }\n  pDb->pSchema->schema_cookie = meta[BTREE_SCHEMA_VERSION-1];\n\n  /* If opening a non-empty database, check the text encoding. For the\n  ** main database, set sqlite3.enc to the encoding of the main database.\n  ** For an attached db, it is an error if the encoding is not the same\n  ** as sqlite3.enc.\n  */\n  if( meta[BTREE_TEXT_ENCODING-1] ){  /* text encoding */\n    if( iDb==0 ){\n#ifndef SQLITE_OMIT_UTF16\n      u8 encoding;\n      /* If opening the main database, set ENC(db). */\n      encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3;\n      if( encoding==0 ) encoding = SQLITE_UTF8;\n      ENC(db) = encoding;\n#else\n      ENC(db) = SQLITE_UTF8;\n#endif\n    }else{\n      /* If opening an attached database, the encoding much match ENC(db) */\n      if( meta[BTREE_TEXT_ENCODING-1]!=ENC(db) ){\n        sqlite3SetString(pzErrMsg, db, \"attached databases must use the same\"\n            \" text encoding as main database\");\n        rc = SQLITE_ERROR;\n        goto initone_error_out;\n      }\n    }\n  }else{\n    DbSetProperty(db, iDb, DB_Empty);\n  }\n  pDb->pSchema->enc = ENC(db);\n\n  if( pDb->pSchema->cache_size==0 ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    size = sqlite3AbsInt32(meta[BTREE_DEFAULT_CACHE_SIZE-1]);\n    if( size==0 ){ size = SQLITE_DEFAULT_CACHE_SIZE; }\n    pDb->pSchema->cache_size = size;\n#else\n    pDb->pSchema->cache_size = SQLITE_DEFAULT_CACHE_SIZE;\n#endif\n    sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size);\n  }\n\n  /*\n  ** file_format==1    Version 3.0.0.\n  ** file_format==2    Version 3.1.3.  // ALTER TABLE ADD COLUMN\n  ** file_format==3    Version 3.1.4.  // ditto but with non-NULL defaults\n  ** file_format==4    Version 3.3.0.  // DESC indices.  Boolean constants\n  */\n  pDb->pSchema->file_format = (u8)meta[BTREE_FILE_FORMAT-1];\n  if( pDb->pSchema->file_format==0 ){\n    pDb->pSchema->file_format = 1;\n  }\n  if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){\n    sqlite3SetString(pzErrMsg, db, \"unsupported file format\");\n    rc = SQLITE_ERROR;\n    goto initone_error_out;\n  }\n\n  /* Ticket #2804:  When we open a database in the newer file format,\n  ** clear the legacy_file_format pragma flag so that a VACUUM will\n  ** not downgrade the database and thus invalidate any descending\n  ** indices that the user might have created.\n  */\n  if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){\n    db->flags &= ~SQLITE_LegacyFileFmt;\n  }\n\n  /* Read the schema information out of the schema tables\n  */\n  assert( db->init.busy );\n  {\n    char *zSql;\n    zSql = sqlite3MPrintf(db, \n        \"SELECT name, rootpage, sql FROM \\\"%w\\\".%s ORDER BY rowid\",\n        db->aDb[iDb].zDbSName, zMasterName);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      sqlite3_xauth xAuth;\n      xAuth = db->xAuth;\n      db->xAuth = 0;\n#endif\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n      db->xAuth = xAuth;\n    }\n#endif\n    if( rc==SQLITE_OK ) rc = initData.rc;\n    sqlite3DbFree(db, zSql);\n#ifndef SQLITE_OMIT_ANALYZE\n    if( rc==SQLITE_OK ){\n      sqlite3AnalysisLoad(db, iDb);\n    }\n#endif\n  }\n  if( db->mallocFailed ){\n    rc = SQLITE_NOMEM_BKPT;\n    sqlite3ResetAllSchemasOfConnection(db);\n  }\n  if( rc==SQLITE_OK || (db->flags&SQLITE_WriteSchema)){\n    /* Black magic: If the SQLITE_WriteSchema flag is set, then consider\n    ** the schema loaded, even if errors occurred. In this situation the \n    ** current sqlite3_prepare() operation will fail, but the following one\n    ** will attempt to compile the supplied statement against whatever subset\n    ** of the schema was loaded before the error occurred. The primary\n    ** purpose of this is to allow access to the sqlite_master table\n    ** even when its contents have been corrupted.\n    */\n    DbSetProperty(db, iDb, DB_SchemaLoaded);\n    rc = SQLITE_OK;\n  }\n\n  /* Jump here for an error that occurs after successfully allocating\n  ** curMain and calling sqlite3BtreeEnter(). For an error that occurs\n  ** before that point, jump to error_out.\n  */\ninitone_error_out:\n  if( openedTransaction ){\n    sqlite3BtreeCommit(pDb->pBt);\n  }\n  sqlite3BtreeLeave(pDb->pBt);\n\nerror_out:\n  if( rc ){\n    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    sqlite3ResetOneSchema(db, iDb);\n  }\n  db->init.busy = 0;\n  return rc;\n}\n\n/*\n** Initialize all database files - the main database file, the file\n** used to store temporary tables, and any additional database files\n** created using ATTACH statements.  Return a success code.  If an\n** error occurs, write an error message into *pzErrMsg.\n**\n** After a database is initialized, the DB_SchemaLoaded bit is set\n** bit is set in the flags field of the Db structure. If the database\n** file was of zero-length, then the DB_Empty flag is also set.\n*/\nint sqlite3Init(sqlite3 *db, char **pzErrMsg){\n  int i, rc;\n  int commit_internal = !(db->mDbFlags&DBFLAG_SchemaChange);\n  \n  assert( sqlite3_mutex_held(db->mutex) );\n  assert( sqlite3BtreeHoldsMutex(db->aDb[0].pBt) );\n  assert( db->init.busy==0 );\n  ENC(db) = SCHEMA_ENC(db);\n  assert( db->nDb>0 );\n  /* Do the main schema first */\n  if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){\n    rc = sqlite3InitOne(db, 0, pzErrMsg);\n    if( rc ) return rc;\n  }\n  /* All other schemas after the main schema. The \"temp\" schema must be last */\n  for(i=db->nDb-1; i>0; i--){\n    if( !DbHasProperty(db, i, DB_SchemaLoaded) ){\n      rc = sqlite3InitOne(db, i, pzErrMsg);\n      if( rc ) return rc;\n    }\n  }\n  if( commit_internal ){\n    sqlite3CommitInternalChanges(db);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** This routine is a no-op if the database schema is already initialized.\n** Otherwise, the schema is loaded. An error code is returned.\n*/\nint sqlite3ReadSchema(Parse *pParse){\n  int rc = SQLITE_OK;\n  sqlite3 *db = pParse->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( !db->init.busy ){\n    rc = sqlite3Init(db, &pParse->zErrMsg);\n  }\n  if( rc!=SQLITE_OK ){\n    pParse->rc = rc;\n    pParse->nErr++;\n  }\n  return rc;\n}\n\n\n/*\n** Check schema cookies in all databases.  If any cookie is out\n** of date set pParse->rc to SQLITE_SCHEMA.  If all schema cookies\n** make no changes to pParse->rc.\n*/\nstatic void schemaIsValid(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  int iDb;\n  int rc;\n  int cookie;\n\n  assert( pParse->checkSchema );\n  assert( sqlite3_mutex_held(db->mutex) );\n  for(iDb=0; iDb<db->nDb; iDb++){\n    int openedTransaction = 0;         /* True if a transaction is opened */\n    Btree *pBt = db->aDb[iDb].pBt;     /* Btree database to read cookie from */\n    if( pBt==0 ) continue;\n\n    /* If there is not already a read-only (or read-write) transaction opened\n    ** on the b-tree database, open one now. If a transaction is opened, it \n    ** will be closed immediately after reading the meta-value. */\n    if( !sqlite3BtreeIsInReadTrans(pBt) ){\n      rc = sqlite3BtreeBeginTrans(pBt, 0);\n      if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){\n        sqlite3OomFault(db);\n      }\n      if( rc!=SQLITE_OK ) return;\n      openedTransaction = 1;\n    }\n\n    /* Read the schema cookie from the database. If it does not match the \n    ** value stored as part of the in-memory schema representation,\n    ** set Parse.rc to SQLITE_SCHEMA. */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){\n      sqlite3ResetOneSchema(db, iDb);\n      pParse->rc = SQLITE_SCHEMA;\n    }\n\n    /* Close the transaction, if one was opened. */\n    if( openedTransaction ){\n      sqlite3BtreeCommit(pBt);\n    }\n  }\n}\n\n/*\n** Convert a schema pointer into the iDb index that indicates\n** which database file in db->aDb[] the schema refers to.\n**\n** If the same database is attached more than once, the first\n** attached database is returned.\n*/\nint sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){\n  int i = -1000000;\n\n  /* If pSchema is NULL, then return -1000000. This happens when code in \n  ** expr.c is trying to resolve a reference to a transient table (i.e. one\n  ** created by a sub-select). In this case the return value of this \n  ** function should never be used.\n  **\n  ** We return -1000000 instead of the more usual -1 simply because using\n  ** -1000000 as the incorrect index into db->aDb[] is much \n  ** more likely to cause a segfault than -1 (of course there are assert()\n  ** statements too, but it never hurts to play the odds).\n  */\n  assert( sqlite3_mutex_held(db->mutex) );\n  if( pSchema ){\n    for(i=0; ALWAYS(i<db->nDb); i++){\n      if( db->aDb[i].pSchema==pSchema ){\n        break;\n      }\n    }\n    assert( i>=0 && i<db->nDb );\n  }\n  return i;\n}\n\n/*\n** Free all memory allocations in the pParse object\n*/\nvoid sqlite3ParserReset(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  sqlite3DbFree(db, pParse->aLabel);\n  sqlite3ExprListDelete(db, pParse->pConstExpr);\n  if( db ){\n    assert( db->lookaside.bDisable >= pParse->disableLookaside );\n    db->lookaside.bDisable -= pParse->disableLookaside;\n  }\n  pParse->disableLookaside = 0;\n}\n\n/*\n** Compile the UTF-8 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pReprepare,         /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  char *zErrMsg = 0;        /* Error message */\n  int rc = SQLITE_OK;       /* Result code */\n  int i;                    /* Loop counter */\n  Parse sParse;             /* Parsing context */\n\n  memset(&sParse, 0, PARSE_HDR_SZ);\n  memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);\n  sParse.pReprepare = pReprepare;\n  assert( ppStmt && *ppStmt==0 );\n  /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  /* For a long-term use prepared statement avoid the use of\n  ** lookaside memory.\n  */\n  if( prepFlags & SQLITE_PREPARE_PERSISTENT ){\n    sParse.disableLookaside++;\n    db->lookaside.bDisable++;\n  }\n\n  /* Check to verify that it is possible to get a read lock on all\n  ** database schemas.  The inability to get a read lock indicates that\n  ** some other database connection is holding a write-lock, which in\n  ** turn means that the other connection has made uncommitted changes\n  ** to the schema.\n  **\n  ** Were we to proceed and prepare the statement against the uncommitted\n  ** schema changes and if those schema changes are subsequently rolled\n  ** back and different changes are made in their place, then when this\n  ** prepared statement goes to run the schema cookie would fail to detect\n  ** the schema change.  Disaster would follow.\n  **\n  ** This thread is currently holding mutexes on all Btrees (because\n  ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it\n  ** is not possible for another thread to start a new schema change\n  ** while this routine is running.  Hence, we do not need to hold \n  ** locks on the schema, we just need to make sure nobody else is \n  ** holding them.\n  **\n  ** Note that setting READ_UNCOMMITTED overrides most lock detection,\n  ** but it does *not* override schema lock detection, so this all still\n  ** works even if READ_UNCOMMITTED is set.\n  */\n  for(i=0; i<db->nDb; i++) {\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      assert( sqlite3BtreeHoldsMutex(pBt) );\n      rc = sqlite3BtreeSchemaLocked(pBt);\n      if( rc ){\n        const char *zDb = db->aDb[i].zDbSName;\n        sqlite3ErrorWithMsg(db, rc, \"database schema is locked: %s\", zDb);\n        testcase( db->flags & SQLITE_ReadUncommit );\n        goto end_prepare;\n      }\n    }\n  }\n\n  sqlite3VtabUnlockList(db);\n\n  sParse.db = db;\n  if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){\n    char *zSqlCopy;\n    int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n    testcase( nBytes==mxLen );\n    testcase( nBytes==mxLen+1 );\n    if( nBytes>mxLen ){\n      sqlite3ErrorWithMsg(db, SQLITE_TOOBIG, \"statement too long\");\n      rc = sqlite3ApiExit(db, SQLITE_TOOBIG);\n      goto end_prepare;\n    }\n    zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);\n    if( zSqlCopy ){\n      sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);\n      sParse.zTail = &zSql[sParse.zTail-zSqlCopy];\n      sqlite3DbFree(db, zSqlCopy);\n    }else{\n      sParse.zTail = &zSql[nBytes];\n    }\n  }else{\n    sqlite3RunParser(&sParse, zSql, &zErrMsg);\n  }\n  assert( 0==sParse.nQueryLoop );\n\n  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;\n  if( sParse.checkSchema ){\n    schemaIsValid(&sParse);\n  }\n  if( db->mallocFailed ){\n    sParse.rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pzTail ){\n    *pzTail = sParse.zTail;\n  }\n  rc = sParse.rc;\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( rc==SQLITE_OK && sParse.pVdbe && sParse.explain ){\n    static const char * const azColName[] = {\n       \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\",\n       \"selectid\", \"order\", \"from\", \"detail\"\n    };\n    int iFirst, mx;\n    if( sParse.explain==2 ){\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 4);\n      iFirst = 8;\n      mx = 12;\n    }else{\n      sqlite3VdbeSetNumCols(sParse.pVdbe, 8);\n      iFirst = 0;\n      mx = 8;\n    }\n    for(i=iFirst; i<mx; i++){\n      sqlite3VdbeSetColName(sParse.pVdbe, i-iFirst, COLNAME_NAME,\n                            azColName[i], SQLITE_STATIC);\n    }\n  }\n#endif\n\n  if( db->init.busy==0 ){\n    sqlite3VdbeSetSql(sParse.pVdbe, zSql, (int)(sParse.zTail-zSql), prepFlags);\n  }\n  if( sParse.pVdbe && (rc!=SQLITE_OK || db->mallocFailed) ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n    assert(!(*ppStmt));\n  }else{\n    *ppStmt = (sqlite3_stmt*)sParse.pVdbe;\n  }\n\n  if( zErrMsg ){\n    sqlite3ErrorWithMsg(db, rc, \"%s\", zErrMsg);\n    sqlite3DbFree(db, zErrMsg);\n  }else{\n    sqlite3Error(db, rc);\n  }\n\n  /* Delete any TriggerPrg structures allocated while parsing this statement. */\n  while( sParse.pTriggerPrg ){\n    TriggerPrg *pT = sParse.pTriggerPrg;\n    sParse.pTriggerPrg = pT->pNext;\n    sqlite3DbFree(db, pT);\n  }\n\nend_prepare:\n\n  sqlite3ParserReset(&sParse);\n  rc = sqlite3ApiExit(db, rc);\n  assert( (rc&db->errMask)==rc );\n  return rc;\n}\nstatic int sqlite3LockAndPrepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  Vdbe *pOld,               /* VM being reprepared */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  sqlite3BtreeEnterAll(db);\n  rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);\n  if( rc==SQLITE_SCHEMA ){\n    sqlite3ResetOneSchema(db, -1);\n    sqlite3_finalize(*ppStmt);\n    rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);\n  }\n  sqlite3BtreeLeaveAll(db);\n  sqlite3_mutex_leave(db->mutex);\n  assert( rc==SQLITE_OK || *ppStmt==0 );\n  return rc;\n}\n\n/*\n** Rerun the compilation of a statement after a schema change.\n**\n** If the statement is successfully recompiled, return SQLITE_OK. Otherwise,\n** if the statement cannot be recompiled because another connection has\n** locked the sqlite3_master table, return SQLITE_LOCKED. If any other error\n** occurs, return SQLITE_SCHEMA.\n*/\nint sqlite3Reprepare(Vdbe *p){\n  int rc;\n  sqlite3_stmt *pNew;\n  const char *zSql;\n  sqlite3 *db;\n  u8 prepFlags;\n\n  assert( sqlite3_mutex_held(sqlite3VdbeDb(p)->mutex) );\n  zSql = sqlite3_sql((sqlite3_stmt *)p);\n  assert( zSql!=0 );  /* Reprepare only called for prepare_v2() statements */\n  db = sqlite3VdbeDb(p);\n  assert( sqlite3_mutex_held(db->mutex) );\n  prepFlags = sqlite3VdbePrepareFlags(p);\n  rc = sqlite3LockAndPrepare(db, zSql, -1, prepFlags, p, &pNew, 0);\n  if( rc ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(db);\n    }\n    assert( pNew==0 );\n    return rc;\n  }else{\n    assert( pNew!=0 );\n  }\n  sqlite3VdbeSwap((Vdbe*)pNew, p);\n  sqlite3TransferBindings(pNew, (sqlite3_stmt*)p);\n  sqlite3VdbeResetStepResult((Vdbe*)pNew);\n  sqlite3VdbeFinalize((Vdbe*)pNew);\n  return SQLITE_OK;\n}\n\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nint sqlite3_prepare(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nint sqlite3_prepare_v2(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-37923-12173 The sqlite3_prepare_v2() interface works\n  ** exactly the same as sqlite3_prepare_v3() with a zero prepFlags\n  ** parameter.\n  **\n  ** Proof in that the 5th parameter to sqlite3LockAndPrepare is 0 */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,0,\n                             ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\nint sqlite3_prepare_v3(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  /* EVIDENCE-OF: R-56861-42673 sqlite3_prepare_v3() differs from\n  ** sqlite3_prepare_v2() only in having the extra prepFlags parameter,\n  ** which is a bit array consisting of zero or more of the\n  ** SQLITE_PREPARE_* flags.\n  **\n  ** Proof by comparison to the implementation of sqlite3_prepare_v2()\n  ** directly above. */\n  rc = sqlite3LockAndPrepare(db,zSql,nBytes,\n                 SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n                 0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );\n  return rc;\n}\n\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Compile the UTF-16 encoded SQL statement zSql into a statement handle.\n*/\nstatic int sqlite3Prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  /* This function currently works by first transforming the UTF-16\n  ** encoded string to UTF-8, then invoking sqlite3_prepare(). The\n  ** tricky bit is figuring out the pointer to return in *pzTail.\n  */\n  char *zSql8;\n  const char *zTail8 = 0;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *ppStmt = 0;\n  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( nBytes>=0 ){\n    int sz;\n    const char *z = (const char*)zSql;\n    for(sz=0; sz<nBytes && (z[sz]!=0 || z[sz+1]!=0); sz += 2){}\n    nBytes = sz;\n  }\n  sqlite3_mutex_enter(db->mutex);\n  zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);\n  if( zSql8 ){\n    rc = sqlite3LockAndPrepare(db, zSql8, -1, prepFlags, 0, ppStmt, &zTail8);\n  }\n\n  if( zTail8 && pzTail ){\n    /* If sqlite3_prepare returns a tail pointer, we calculate the\n    ** equivalent pointer into the UTF-16 string by counting the unicode\n    ** characters between zSql8 and zTail8, and then returning a pointer\n    ** the same number of characters into the UTF-16 string.\n    */\n    int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));\n    *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);\n  }\n  sqlite3DbFree(db, zSql8); \n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Two versions of the official API.  Legacy and new use.  In the legacy\n** version, the original SQL text is not saved in the prepared statement\n** and so if a schema change occurs, SQLITE_SCHEMA is returned by\n** sqlite3_step().  In the new version, the original SQL text is retained\n** and the statement is automatically recompiled if an schema change\n** occurs.\n*/\nint sqlite3_prepare16(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nint sqlite3_prepare16_v2(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,SQLITE_PREPARE_SAVESQL,ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\nint sqlite3_prepare16_v3(\n  sqlite3 *db,              /* Database handle. */ \n  const void *zSql,         /* UTF-16 encoded SQL statement. */\n  int nBytes,               /* Length of zSql in bytes. */\n  unsigned int prepFlags,   /* Zero or more SQLITE_PREPARE_* flags */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const void **pzTail       /* OUT: End of parsed string */\n){\n  int rc;\n  rc = sqlite3Prepare16(db,zSql,nBytes,\n         SQLITE_PREPARE_SAVESQL|(prepFlags&SQLITE_PREPARE_MASK),\n         ppStmt,pzTail);\n  assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 );  /* VERIFY: F13021 */\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_UTF16 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/printf.c",
    "content": "/*\n** The \"printf\" code that follows dates from the 1980's.  It is in\n** the public domain. \n**\n**************************************************************************\n**\n** This file contains code for a set of \"printf\"-like routines.  These\n** routines format strings much like the printf() from the standard C\n** library, though the implementation here has enhancements to support\n** SQLite.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Conversion types fall into various categories as defined by the\n** following enumeration.\n*/\n#define etRADIX       0 /* non-decimal integer types.  %x %o */\n#define etFLOAT       1 /* Floating point.  %f */\n#define etEXP         2 /* Exponentional notation. %e and %E */\n#define etGENERIC     3 /* Floating or exponential, depending on exponent. %g */\n#define etSIZE        4 /* Return number of characters processed so far. %n */\n#define etSTRING      5 /* Strings. %s */\n#define etDYNSTRING   6 /* Dynamically allocated strings. %z */\n#define etPERCENT     7 /* Percent symbol. %% */\n#define etCHARX       8 /* Characters. %c */\n/* The rest are extensions, not normally found in printf() */\n#define etSQLESCAPE   9 /* Strings with '\\'' doubled.  %q */\n#define etSQLESCAPE2 10 /* Strings with '\\'' doubled and enclosed in '',\n                          NULL pointers replaced by SQL NULL.  %Q */\n#define etTOKEN      11 /* a pointer to a Token structure */\n#define etSRCLIST    12 /* a pointer to a SrcList */\n#define etPOINTER    13 /* The %p conversion */\n#define etSQLESCAPE3 14 /* %w -> Strings with '\\\"' doubled */\n#define etORDINAL    15 /* %r -> 1st, 2nd, 3rd, 4th, etc.  English only */\n#define etDECIMAL    16 /* %d or %u, but not %x, %o */\n\n#define etINVALID    17 /* Any unrecognized conversion type */\n\n\n/*\n** An \"etByte\" is an 8-bit unsigned value.\n*/\ntypedef unsigned char etByte;\n\n/*\n** Each builtin conversion character (ex: the 'd' in \"%d\") is described\n** by an instance of the following structure\n*/\ntypedef struct et_info {   /* Information about each format field */\n  char fmttype;            /* The format field code letter */\n  etByte base;             /* The base for radix conversion */\n  etByte flags;            /* One or more of FLAG_ constants below */\n  etByte type;             /* Conversion paradigm */\n  etByte charset;          /* Offset into aDigits[] of the digits string */\n  etByte prefix;           /* Offset into aPrefix[] of the prefix string */\n} et_info;\n\n/*\n** Allowed values for et_info.flags\n*/\n#define FLAG_SIGNED    1     /* True if the value to convert is signed */\n#define FLAG_STRING    4     /* Allow infinite precision */\n\n\n/*\n** The following table is searched linearly, so it is good to put the\n** most frequently used conversion types first.\n*/\nstatic const char aDigits[] = \"0123456789ABCDEF0123456789abcdef\";\nstatic const char aPrefix[] = \"-x0\\000X0\";\nstatic const et_info fmtinfo[] = {\n  {  'd', 10, 1, etDECIMAL,    0,  0 },\n  {  's',  0, 4, etSTRING,     0,  0 },\n  {  'g',  0, 1, etGENERIC,    30, 0 },\n  {  'z',  0, 4, etDYNSTRING,  0,  0 },\n  {  'q',  0, 4, etSQLESCAPE,  0,  0 },\n  {  'Q',  0, 4, etSQLESCAPE2, 0,  0 },\n  {  'w',  0, 4, etSQLESCAPE3, 0,  0 },\n  {  'c',  0, 0, etCHARX,      0,  0 },\n  {  'o',  8, 0, etRADIX,      0,  2 },\n  {  'u', 10, 0, etDECIMAL,    0,  0 },\n  {  'x', 16, 0, etRADIX,      16, 1 },\n  {  'X', 16, 0, etRADIX,      0,  4 },\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  {  'f',  0, 1, etFLOAT,      0,  0 },\n  {  'e',  0, 1, etEXP,        30, 0 },\n  {  'E',  0, 1, etEXP,        14, 0 },\n  {  'G',  0, 1, etGENERIC,    14, 0 },\n#endif\n  {  'i', 10, 1, etDECIMAL,    0,  0 },\n  {  'n',  0, 0, etSIZE,       0,  0 },\n  {  '%',  0, 0, etPERCENT,    0,  0 },\n  {  'p', 16, 0, etPOINTER,    0,  1 },\n\n  /* All the rest are undocumented and are for internal use only */\n  {  'T',  0, 0, etTOKEN,      0,  0 },\n  {  'S',  0, 0, etSRCLIST,    0,  0 },\n  {  'r', 10, 1, etORDINAL,    0,  0 },\n};\n\n/*\n** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point\n** conversions will work.\n*/\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** \"*val\" is a double such that 0.1 <= *val < 10.0\n** Return the ascii code for the leading digit of *val, then\n** multiply \"*val\" by 10.0 to renormalize.\n**\n** Example:\n**     input:     *val = 3.14159\n**     output:    *val = 1.4159    function return = '3'\n**\n** The counter *cnt is incremented each time.  After counter exceeds\n** 16 (the number of significant digits in a 64-bit float) '0' is\n** always returned.\n*/\nstatic char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){\n  int digit;\n  LONGDOUBLE_TYPE d;\n  if( (*cnt)<=0 ) return '0';\n  (*cnt)--;\n  digit = (int)*val;\n  d = digit;\n  digit += '0';\n  *val = (*val - d)*10.0;\n  return (char)digit;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Set the StrAccum object to an error mode.\n*/\nstatic void setStrAccumError(StrAccum *p, u8 eError){\n  assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );\n  p->accError = eError;\n  p->nAlloc = 0;\n}\n\n/*\n** Extra argument values from a PrintfArguments object\n*/\nstatic sqlite3_int64 getIntArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return sqlite3_value_int64(p->apArg[p->nUsed++]);\n}\nstatic double getDoubleArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0.0;\n  return sqlite3_value_double(p->apArg[p->nUsed++]);\n}\nstatic char *getTextArg(PrintfArguments *p){\n  if( p->nArg<=p->nUsed ) return 0;\n  return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);\n}\n\n\n/*\n** On machines with a small stack size, you can redefine the\n** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.\n*/\n#ifndef SQLITE_PRINT_BUF_SIZE\n# define SQLITE_PRINT_BUF_SIZE 70\n#endif\n#define etBUFSIZE SQLITE_PRINT_BUF_SIZE  /* Size of the output buffer */\n\n/*\n** Render a string given by \"fmt\" into the StrAccum object.\n*/\nvoid sqlite3VXPrintf(\n  StrAccum *pAccum,          /* Accumulate results here */\n  const char *fmt,           /* Format string */\n  va_list ap                 /* arguments */\n){\n  int c;                     /* Next character in the format string */\n  char *bufpt;               /* Pointer to the conversion buffer */\n  int precision;             /* Precision of the current field */\n  int length;                /* Length of the field */\n  int idx;                   /* A general purpose loop counter */\n  int width;                 /* Width of the current field */\n  etByte flag_leftjustify;   /* True if \"-\" flag is present */\n  etByte flag_prefix;        /* '+' or ' ' or 0 for prefix */\n  etByte flag_alternateform; /* True if \"#\" flag is present */\n  etByte flag_altform2;      /* True if \"!\" flag is present */\n  etByte flag_zeropad;       /* True if field width constant starts with zero */\n  etByte flag_long;          /* 1 for the \"l\" flag, 2 for \"ll\", 0 by default */\n  etByte done;               /* Loop termination flag */\n  etByte cThousand;          /* Thousands separator for %d and %u */\n  etByte xtype = etINVALID;  /* Conversion paradigm */\n  u8 bArgList;               /* True for SQLITE_PRINTF_SQLFUNC */\n  char prefix;               /* Prefix character.  \"+\" or \"-\" or \" \" or '\\0'. */\n  sqlite_uint64 longvalue;   /* Value for integer types */\n  LONGDOUBLE_TYPE realvalue; /* Value for real types */\n  const et_info *infop;      /* Pointer to the appropriate info structure */\n  char *zOut;                /* Rendering buffer */\n  int nOut;                  /* Size of the rendering buffer */\n  char *zExtra = 0;          /* Malloced memory used by some conversion */\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int  exp, e2;              /* exponent of real numbers */\n  int nsd;                   /* Number of significant digits returned */\n  double rounder;            /* Used for rounding floating point values */\n  etByte flag_dp;            /* True if decimal point should be shown */\n  etByte flag_rtz;           /* True if trailing zeros should be removed */\n#endif\n  PrintfArguments *pArgList = 0; /* Arguments for SQLITE_PRINTF_SQLFUNC */\n  char buf[etBUFSIZE];       /* Conversion buffer */\n\n  bufpt = 0;\n  if( (pAccum->printfFlags & SQLITE_PRINTF_SQLFUNC)!=0 ){\n    pArgList = va_arg(ap, PrintfArguments*);\n    bArgList = 1;\n  }else{\n    bArgList = 0;\n  }\n  for(; (c=(*fmt))!=0; ++fmt){\n    if( c!='%' ){\n      bufpt = (char *)fmt;\n#if HAVE_STRCHRNUL\n      fmt = strchrnul(fmt, '%');\n#else\n      do{ fmt++; }while( *fmt && *fmt != '%' );\n#endif\n      sqlite3StrAccumAppend(pAccum, bufpt, (int)(fmt - bufpt));\n      if( *fmt==0 ) break;\n    }\n    if( (c=(*++fmt))==0 ){\n      sqlite3StrAccumAppend(pAccum, \"%\", 1);\n      break;\n    }\n    /* Find out what flags are present */\n    flag_leftjustify = flag_prefix = cThousand =\n     flag_alternateform = flag_altform2 = flag_zeropad = 0;\n    done = 0;\n    do{\n      switch( c ){\n        case '-':   flag_leftjustify = 1;     break;\n        case '+':   flag_prefix = '+';        break;\n        case ' ':   flag_prefix = ' ';        break;\n        case '#':   flag_alternateform = 1;   break;\n        case '!':   flag_altform2 = 1;        break;\n        case '0':   flag_zeropad = 1;         break;\n        case ',':   cThousand = ',';          break;\n        default:    done = 1;                 break;\n      }\n    }while( !done && (c=(*++fmt))!=0 );\n    /* Get the field width */\n    if( c=='*' ){\n      if( bArgList ){\n        width = (int)getIntArg(pArgList);\n      }else{\n        width = va_arg(ap,int);\n      }\n      if( width<0 ){\n        flag_leftjustify = 1;\n        width = width >= -2147483647 ? -width : 0;\n      }\n      c = *++fmt;\n    }else{\n      unsigned wx = 0;\n      while( c>='0' && c<='9' ){\n        wx = wx*10 + c - '0';\n        c = *++fmt;\n      }\n      testcase( wx>0x7fffffff );\n      width = wx & 0x7fffffff;\n    }\n    assert( width>=0 );\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n    if( width>SQLITE_PRINTF_PRECISION_LIMIT ){\n      width = SQLITE_PRINTF_PRECISION_LIMIT;\n    }\n#endif\n\n    /* Get the precision */\n    if( c=='.' ){\n      c = *++fmt;\n      if( c=='*' ){\n        if( bArgList ){\n          precision = (int)getIntArg(pArgList);\n        }else{\n          precision = va_arg(ap,int);\n        }\n        c = *++fmt;\n        if( precision<0 ){\n          precision = precision >= -2147483647 ? -precision : -1;\n        }\n      }else{\n        unsigned px = 0;\n        while( c>='0' && c<='9' ){\n          px = px*10 + c - '0';\n          c = *++fmt;\n        }\n        testcase( px>0x7fffffff );\n        precision = px & 0x7fffffff;\n      }\n    }else{\n      precision = -1;\n    }\n    assert( precision>=(-1) );\n#ifdef SQLITE_PRINTF_PRECISION_LIMIT\n    if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){\n      precision = SQLITE_PRINTF_PRECISION_LIMIT;\n    }\n#endif\n\n\n    /* Get the conversion type modifier */\n    if( c=='l' ){\n      flag_long = 1;\n      c = *++fmt;\n      if( c=='l' ){\n        flag_long = 2;\n        c = *++fmt;\n      }\n    }else{\n      flag_long = 0;\n    }\n    /* Fetch the info entry for the field */\n    infop = &fmtinfo[0];\n    xtype = etINVALID;\n    for(idx=0; idx<ArraySize(fmtinfo); idx++){\n      if( c==fmtinfo[idx].fmttype ){\n        infop = &fmtinfo[idx];\n        xtype = infop->type;\n        break;\n      }\n    }\n\n    /*\n    ** At this point, variables are initialized as follows:\n    **\n    **   flag_alternateform          TRUE if a '#' is present.\n    **   flag_altform2               TRUE if a '!' is present.\n    **   flag_prefix                 '+' or ' ' or zero\n    **   flag_leftjustify            TRUE if a '-' is present or if the\n    **                               field width was negative.\n    **   flag_zeropad                TRUE if the width began with 0.\n    **   flag_long                   1 for \"l\", 2 for \"ll\"\n    **   width                       The specified field width.  This is\n    **                               always non-negative.  Zero is the default.\n    **   precision                   The specified precision.  The default\n    **                               is -1.\n    **   xtype                       The class of the conversion.\n    **   infop                       Pointer to the appropriate info struct.\n    */\n    switch( xtype ){\n      case etPOINTER:\n        flag_long = sizeof(char*)==sizeof(i64) ? 2 :\n                     sizeof(char*)==sizeof(long int) ? 1 : 0;\n        /* Fall through into the next case */\n      case etORDINAL:\n      case etRADIX:      \n        cThousand = 0;\n        /* Fall through into the next case */\n      case etDECIMAL:\n        if( infop->flags & FLAG_SIGNED ){\n          i64 v;\n          if( bArgList ){\n            v = getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              v = va_arg(ap,i64) ;\n            }else{\n              v = va_arg(ap,long int);\n            }\n          }else{\n            v = va_arg(ap,int);\n          }\n          if( v<0 ){\n            if( v==SMALLEST_INT64 ){\n              longvalue = ((u64)1)<<63;\n            }else{\n              longvalue = -v;\n            }\n            prefix = '-';\n          }else{\n            longvalue = v;\n            prefix = flag_prefix;\n          }\n        }else{\n          if( bArgList ){\n            longvalue = (u64)getIntArg(pArgList);\n          }else if( flag_long ){\n            if( flag_long==2 ){\n              longvalue = va_arg(ap,u64);\n            }else{\n              longvalue = va_arg(ap,unsigned long int);\n            }\n          }else{\n            longvalue = va_arg(ap,unsigned int);\n          }\n          prefix = 0;\n        }\n        if( longvalue==0 ) flag_alternateform = 0;\n        if( flag_zeropad && precision<width-(prefix!=0) ){\n          precision = width-(prefix!=0);\n        }\n        if( precision<etBUFSIZE-10-etBUFSIZE/3 ){\n          nOut = etBUFSIZE;\n          zOut = buf;\n        }else{\n          u64 n = (u64)precision + 10 + precision/3;\n          zOut = zExtra = sqlite3Malloc( n );\n          if( zOut==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n          nOut = (int)n;\n        }\n        bufpt = &zOut[nOut-1];\n        if( xtype==etORDINAL ){\n          static const char zOrd[] = \"thstndrd\";\n          int x = (int)(longvalue % 10);\n          if( x>=4 || (longvalue/10)%10==1 ){\n            x = 0;\n          }\n          *(--bufpt) = zOrd[x*2+1];\n          *(--bufpt) = zOrd[x*2];\n        }\n        {\n          const char *cset = &aDigits[infop->charset];\n          u8 base = infop->base;\n          do{                                           /* Convert to ascii */\n            *(--bufpt) = cset[longvalue%base];\n            longvalue = longvalue/base;\n          }while( longvalue>0 );\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        while( precision>length ){\n          *(--bufpt) = '0';                             /* Zero pad */\n          length++;\n        }\n        if( cThousand ){\n          int nn = (length - 1)/3;  /* Number of \",\" to insert */\n          int ix = (length - 1)%3 + 1;\n          bufpt -= nn;\n          for(idx=0; nn>0; idx++){\n            bufpt[idx] = bufpt[idx+nn];\n            ix--;\n            if( ix==0 ){\n              bufpt[++idx] = cThousand;\n              nn--;\n              ix = 3;\n            }\n          }\n        }\n        if( prefix ) *(--bufpt) = prefix;               /* Add sign */\n        if( flag_alternateform && infop->prefix ){      /* Add \"0\" or \"0x\" */\n          const char *pre;\n          char x;\n          pre = &aPrefix[infop->prefix];\n          for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;\n        }\n        length = (int)(&zOut[nOut-1]-bufpt);\n        break;\n      case etFLOAT:\n      case etEXP:\n      case etGENERIC:\n        if( bArgList ){\n          realvalue = getDoubleArg(pArgList);\n        }else{\n          realvalue = va_arg(ap,double);\n        }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n        length = 0;\n#else\n        if( precision<0 ) precision = 6;         /* Set default precision */\n        if( realvalue<0.0 ){\n          realvalue = -realvalue;\n          prefix = '-';\n        }else{\n          prefix = flag_prefix;\n        }\n        if( xtype==etGENERIC && precision>0 ) precision--;\n        testcase( precision>0xfff );\n        for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}\n        if( xtype==etFLOAT ) realvalue += rounder;\n        /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */\n        exp = 0;\n        if( sqlite3IsNaN((double)realvalue) ){\n          bufpt = \"NaN\";\n          length = 3;\n          break;\n        }\n        if( realvalue>0.0 ){\n          LONGDOUBLE_TYPE scale = 1.0;\n          while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;}\n          while( realvalue>=1e10*scale && exp<=350 ){ scale *= 1e10; exp+=10; }\n          while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; }\n          realvalue /= scale;\n          while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; }\n          while( realvalue<1.0 ){ realvalue *= 10.0; exp--; }\n          if( exp>350 ){\n            bufpt = buf;\n            buf[0] = prefix;\n            memcpy(buf+(prefix!=0),\"Inf\",4);\n            length = 3+(prefix!=0);\n            break;\n          }\n        }\n        bufpt = buf;\n        /*\n        ** If the field type is etGENERIC, then convert to either etEXP\n        ** or etFLOAT, as appropriate.\n        */\n        if( xtype!=etFLOAT ){\n          realvalue += rounder;\n          if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }\n        }\n        if( xtype==etGENERIC ){\n          flag_rtz = !flag_alternateform;\n          if( exp<-4 || exp>precision ){\n            xtype = etEXP;\n          }else{\n            precision = precision - exp;\n            xtype = etFLOAT;\n          }\n        }else{\n          flag_rtz = flag_altform2;\n        }\n        if( xtype==etEXP ){\n          e2 = 0;\n        }else{\n          e2 = exp;\n        }\n        if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){\n          bufpt = zExtra \n              = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );\n          if( bufpt==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n        }\n        zOut = bufpt;\n        nsd = 16 + flag_altform2*10;\n        flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;\n        /* The sign in front of the number */\n        if( prefix ){\n          *(bufpt++) = prefix;\n        }\n        /* Digits prior to the decimal point */\n        if( e2<0 ){\n          *(bufpt++) = '0';\n        }else{\n          for(; e2>=0; e2--){\n            *(bufpt++) = et_getdigit(&realvalue,&nsd);\n          }\n        }\n        /* The decimal point */\n        if( flag_dp ){\n          *(bufpt++) = '.';\n        }\n        /* \"0\" digits after the decimal point but before the first\n        ** significant digit of the number */\n        for(e2++; e2<0; precision--, e2++){\n          assert( precision>0 );\n          *(bufpt++) = '0';\n        }\n        /* Significant digits after the decimal point */\n        while( (precision--)>0 ){\n          *(bufpt++) = et_getdigit(&realvalue,&nsd);\n        }\n        /* Remove trailing zeros and the \".\" if no digits follow the \".\" */\n        if( flag_rtz && flag_dp ){\n          while( bufpt[-1]=='0' ) *(--bufpt) = 0;\n          assert( bufpt>zOut );\n          if( bufpt[-1]=='.' ){\n            if( flag_altform2 ){\n              *(bufpt++) = '0';\n            }else{\n              *(--bufpt) = 0;\n            }\n          }\n        }\n        /* Add the \"eNNN\" suffix */\n        if( xtype==etEXP ){\n          *(bufpt++) = aDigits[infop->charset];\n          if( exp<0 ){\n            *(bufpt++) = '-'; exp = -exp;\n          }else{\n            *(bufpt++) = '+';\n          }\n          if( exp>=100 ){\n            *(bufpt++) = (char)((exp/100)+'0');        /* 100's digit */\n            exp %= 100;\n          }\n          *(bufpt++) = (char)(exp/10+'0');             /* 10's digit */\n          *(bufpt++) = (char)(exp%10+'0');             /* 1's digit */\n        }\n        *bufpt = 0;\n\n        /* The converted number is in buf[] and zero terminated. Output it.\n        ** Note that the number is in the usual order, not reversed as with\n        ** integer conversions. */\n        length = (int)(bufpt-zOut);\n        bufpt = zOut;\n\n        /* Special case:  Add leading zeros if the flag_zeropad flag is\n        ** set and we are not left justified */\n        if( flag_zeropad && !flag_leftjustify && length < width){\n          int i;\n          int nPad = width - length;\n          for(i=width; i>=nPad; i--){\n            bufpt[i] = bufpt[i-nPad];\n          }\n          i = prefix!=0;\n          while( nPad-- ) bufpt[i++] = '0';\n          length = width;\n        }\n#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */\n        break;\n      case etSIZE:\n        if( !bArgList ){\n          *(va_arg(ap,int*)) = pAccum->nChar;\n        }\n        length = width = 0;\n        break;\n      case etPERCENT:\n        buf[0] = '%';\n        bufpt = buf;\n        length = 1;\n        break;\n      case etCHARX:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          c = bufpt ? bufpt[0] : 0;\n        }else{\n          c = va_arg(ap,int);\n        }\n        if( precision>1 ){\n          width -= precision-1;\n          if( width>1 && !flag_leftjustify ){\n            sqlite3AppendChar(pAccum, width-1, ' ');\n            width = 0;\n          }\n          sqlite3AppendChar(pAccum, precision-1, c);\n        }\n        length = 1;\n        buf[0] = c;\n        bufpt = buf;\n        break;\n      case etSTRING:\n      case etDYNSTRING:\n        if( bArgList ){\n          bufpt = getTextArg(pArgList);\n          xtype = etSTRING;\n        }else{\n          bufpt = va_arg(ap,char*);\n        }\n        if( bufpt==0 ){\n          bufpt = \"\";\n        }else if( xtype==etDYNSTRING ){\n          zExtra = bufpt;\n        }\n        if( precision>=0 ){\n          for(length=0; length<precision && bufpt[length]; length++){}\n        }else{\n          length = 0x7fffffff & (int)strlen(bufpt);\n        }\n        break;\n      case etSQLESCAPE:           /* Escape ' characters */\n      case etSQLESCAPE2:          /* Escape ' and enclose in '...' */\n      case etSQLESCAPE3: {        /* Escape \" characters */\n        int i, j, k, n, isnull;\n        int needQuote;\n        char ch;\n        char q = ((xtype==etSQLESCAPE3)?'\"':'\\'');   /* Quote character */\n        char *escarg;\n\n        if( bArgList ){\n          escarg = getTextArg(pArgList);\n        }else{\n          escarg = va_arg(ap,char*);\n        }\n        isnull = escarg==0;\n        if( isnull ) escarg = (xtype==etSQLESCAPE2 ? \"NULL\" : \"(NULL)\");\n        k = precision;\n        for(i=n=0; k!=0 && (ch=escarg[i])!=0; i++, k--){\n          if( ch==q )  n++;\n        }\n        needQuote = !isnull && xtype==etSQLESCAPE2;\n        n += i + 3;\n        if( n>etBUFSIZE ){\n          bufpt = zExtra = sqlite3Malloc( n );\n          if( bufpt==0 ){\n            setStrAccumError(pAccum, STRACCUM_NOMEM);\n            return;\n          }\n        }else{\n          bufpt = buf;\n        }\n        j = 0;\n        if( needQuote ) bufpt[j++] = q;\n        k = i;\n        for(i=0; i<k; i++){\n          bufpt[j++] = ch = escarg[i];\n          if( ch==q ) bufpt[j++] = ch;\n        }\n        if( needQuote ) bufpt[j++] = q;\n        bufpt[j] = 0;\n        length = j;\n        /* The precision in %q and %Q means how many input characters to\n        ** consume, not the length of the output...\n        ** if( precision>=0 && precision<length ) length = precision; */\n        break;\n      }\n      case etTOKEN: {\n        Token *pToken;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pToken = va_arg(ap, Token*);\n        assert( bArgList==0 );\n        if( pToken && pToken->n ){\n          sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);\n        }\n        length = width = 0;\n        break;\n      }\n      case etSRCLIST: {\n        SrcList *pSrc;\n        int k;\n        struct SrcList_item *pItem;\n        if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;\n        pSrc = va_arg(ap, SrcList*);\n        k = va_arg(ap, int);\n        pItem = &pSrc->a[k];\n        assert( bArgList==0 );\n        assert( k>=0 && k<pSrc->nSrc );\n        if( pItem->zDatabase ){\n          sqlite3StrAccumAppendAll(pAccum, pItem->zDatabase);\n          sqlite3StrAccumAppend(pAccum, \".\", 1);\n        }\n        sqlite3StrAccumAppendAll(pAccum, pItem->zName);\n        length = width = 0;\n        break;\n      }\n      default: {\n        assert( xtype==etINVALID );\n        return;\n      }\n    }/* End switch over the format type */\n    /*\n    ** The text of the conversion is pointed to by \"bufpt\" and is\n    ** \"length\" characters long.  The field width is \"width\".  Do\n    ** the output.\n    */\n    width -= length;\n    if( width>0 ){\n      if( !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');\n      sqlite3StrAccumAppend(pAccum, bufpt, length);\n      if( flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');\n    }else{\n      sqlite3StrAccumAppend(pAccum, bufpt, length);\n    }\n\n    if( zExtra ){\n      sqlite3DbFree(pAccum->db, zExtra);\n      zExtra = 0;\n    }\n  }/* End for loop over the format string */\n} /* End of function */\n\n/*\n** Enlarge the memory allocation on a StrAccum object so that it is\n** able to accept at least N more bytes of text.\n**\n** Return the number of bytes of text that StrAccum is able to accept\n** after the attempted enlargement.  The value returned might be zero.\n*/\nstatic int sqlite3StrAccumEnlarge(StrAccum *p, int N){\n  char *zNew;\n  assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */\n  if( p->accError ){\n    testcase(p->accError==STRACCUM_TOOBIG);\n    testcase(p->accError==STRACCUM_NOMEM);\n    return 0;\n  }\n  if( p->mxAlloc==0 ){\n    N = p->nAlloc - p->nChar - 1;\n    setStrAccumError(p, STRACCUM_TOOBIG);\n    return N;\n  }else{\n    char *zOld = isMalloced(p) ? p->zText : 0;\n    i64 szNew = p->nChar;\n    szNew += N + 1;\n    if( szNew+p->nChar<=p->mxAlloc ){\n      /* Force exponential buffer size growth as long as it does not overflow,\n      ** to avoid having to call this routine too often */\n      szNew += p->nChar;\n    }\n    if( szNew > p->mxAlloc ){\n      sqlite3StrAccumReset(p);\n      setStrAccumError(p, STRACCUM_TOOBIG);\n      return 0;\n    }else{\n      p->nAlloc = (int)szNew;\n    }\n    if( p->db ){\n      zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);\n    }else{\n      zNew = sqlite3_realloc64(zOld, p->nAlloc);\n    }\n    if( zNew ){\n      assert( p->zText!=0 || p->nChar==0 );\n      if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);\n      p->zText = zNew;\n      p->nAlloc = sqlite3DbMallocSize(p->db, zNew);\n      p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n    }else{\n      sqlite3StrAccumReset(p);\n      setStrAccumError(p, STRACCUM_NOMEM);\n      return 0;\n    }\n  }\n  return N;\n}\n\n/*\n** Append N copies of character c to the given string buffer.\n*/\nvoid sqlite3AppendChar(StrAccum *p, int N, char c){\n  testcase( p->nChar + (i64)N > 0x7fffffff );\n  if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){\n    return;\n  }\n  while( (N--)>0 ) p->zText[p->nChar++] = c;\n}\n\n/*\n** The StrAccum \"p\" is not large enough to accept N new bytes of z[].\n** So enlarge if first, then do the append.\n**\n** This is a helper routine to sqlite3StrAccumAppend() that does special-case\n** work (enlarging the buffer) using tail recursion, so that the\n** sqlite3StrAccumAppend() routine can use fast calling semantics.\n*/\nstatic void SQLITE_NOINLINE enlargeAndAppend(StrAccum *p, const char *z, int N){\n  N = sqlite3StrAccumEnlarge(p, N);\n  if( N>0 ){\n    memcpy(&p->zText[p->nChar], z, N);\n    p->nChar += N;\n  }\n}\n\n/*\n** Append N bytes of text from z to the StrAccum object.  Increase the\n** size of the memory allocation for StrAccum if necessary.\n*/\nvoid sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){\n  assert( z!=0 || N==0 );\n  assert( p->zText!=0 || p->nChar==0 || p->accError );\n  assert( N>=0 );\n  assert( p->accError==0 || p->nAlloc==0 );\n  if( p->nChar+N >= p->nAlloc ){\n    enlargeAndAppend(p,z,N);\n  }else if( N ){\n    assert( p->zText );\n    p->nChar += N;\n    memcpy(&p->zText[p->nChar-N], z, N);\n  }\n}\n\n/*\n** Append the complete text of zero-terminated string z[] to the p string.\n*/\nvoid sqlite3StrAccumAppendAll(StrAccum *p, const char *z){\n  sqlite3StrAccumAppend(p, z, sqlite3Strlen30(z));\n}\n\n\n/*\n** Finish off a string by making sure it is zero-terminated.\n** Return a pointer to the resulting string.  Return a NULL\n** pointer if any kind of error was encountered.\n*/\nstatic SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){\n  char *zText;\n  assert( p->mxAlloc>0 && !isMalloced(p) );\n  zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );\n  if( zText ){\n    memcpy(zText, p->zText, p->nChar+1);\n    p->printfFlags |= SQLITE_PRINTF_MALLOCED;\n  }else{\n    setStrAccumError(p, STRACCUM_NOMEM);\n  }\n  p->zText = zText;\n  return zText;\n}\nchar *sqlite3StrAccumFinish(StrAccum *p){\n  if( p->zText ){\n    p->zText[p->nChar] = 0;\n    if( p->mxAlloc>0 && !isMalloced(p) ){\n      return strAccumFinishRealloc(p);\n    }\n  }\n  return p->zText;\n}\n\n/*\n** Reset an StrAccum string.  Reclaim all malloced memory.\n*/\nvoid sqlite3StrAccumReset(StrAccum *p){\n  if( isMalloced(p) ){\n    sqlite3DbFree(p->db, p->zText);\n    p->printfFlags &= ~SQLITE_PRINTF_MALLOCED;\n  }\n  p->zText = 0;\n}\n\n/*\n** Initialize a string accumulator.\n**\n** p:     The accumulator to be initialized.\n** db:    Pointer to a database connection.  May be NULL.  Lookaside\n**        memory is used if not NULL. db->mallocFailed is set appropriately\n**        when not NULL.\n** zBase: An initial buffer.  May be NULL in which case the initial buffer\n**        is malloced.\n** n:     Size of zBase in bytes.  If total space requirements never exceed\n**        n then no memory allocations ever occur.\n** mx:    Maximum number of bytes to accumulate.  If mx==0 then no memory\n**        allocations will ever occur.\n*/\nvoid sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){\n  p->zText = zBase;\n  p->db = db;\n  p->nAlloc = n;\n  p->mxAlloc = mx;\n  p->nChar = 0;\n  p->accError = 0;\n  p->printfFlags = 0;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nchar *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n  assert( db!=0 );\n  sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),\n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  acc.printfFlags = SQLITE_PRINTF_INTERNAL;\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  if( acc.accError==STRACCUM_NOMEM ){\n    sqlite3OomFault(db);\n  }\n  return z;\n}\n\n/*\n** Print into memory obtained from sqliteMalloc().  Use the internal\n** %-conversion extensions.\n*/\nchar *sqlite3MPrintf(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  va_start(ap, zFormat);\n  z = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc().  Omit the internal\n** %-conversion extensions.\n*/\nchar *sqlite3_vmprintf(const char *zFormat, va_list ap){\n  char *z;\n  char zBase[SQLITE_PRINT_BUF_SIZE];\n  StrAccum acc;\n\n#ifdef SQLITE_ENABLE_API_ARMOR  \n  if( zFormat==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  z = sqlite3StrAccumFinish(&acc);\n  return z;\n}\n\n/*\n** Print into memory obtained from sqlite3_malloc()().  Omit the internal\n** %-conversion extensions.\n*/\nchar *sqlite3_mprintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return 0;\n#endif\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** sqlite3_snprintf() works like snprintf() except that it ignores the\n** current locale settings.  This is important for SQLite because we\n** are not able to use a \",\" as the decimal point in place of \".\" as\n** specified by some locales.\n**\n** Oops:  The first two arguments of sqlite3_snprintf() are backwards\n** from the snprintf() standard.  Unfortunately, it is too late to change\n** this without breaking compatibility, so we just have to live with the\n** mistake.\n**\n** sqlite3_vsnprintf() is the varargs version.\n*/\nchar *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){\n  StrAccum acc;\n  if( n<=0 ) return zBuf;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( zBuf==0 || zFormat==0 ) {\n    (void)SQLITE_MISUSE_BKPT;\n    if( zBuf ) zBuf[0] = 0;\n    return zBuf;\n  }\n#endif\n  sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  zBuf[acc.nChar] = 0;\n  return zBuf;\n}\nchar *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){\n  char *z;\n  va_list ap;\n  va_start(ap,zFormat);\n  z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);\n  va_end(ap);\n  return z;\n}\n\n/*\n** This is the routine that actually formats the sqlite3_log() message.\n** We house it in a separate routine from sqlite3_log() to avoid using\n** stack space on small-stack systems when logging is disabled.\n**\n** sqlite3_log() must render into a static buffer.  It cannot dynamically\n** allocate memory because it might be called while the memory allocator\n** mutex is held.\n**\n** sqlite3VXPrintf() might ask for *temporary* memory allocations for\n** certain format characters (%q) or for very large precisions or widths.\n** Care must be taken that any sqlite3_log() calls that occur while the\n** memory mutex is held do not use these mechanisms.\n*/\nstatic void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){\n  StrAccum acc;                          /* String accumulator */\n  char zMsg[SQLITE_PRINT_BUF_SIZE*3];    /* Complete log message */\n\n  sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,\n                           sqlite3StrAccumFinish(&acc));\n}\n\n/*\n** Format and write a message to the log if logging is enabled.\n*/\nvoid sqlite3_log(int iErrCode, const char *zFormat, ...){\n  va_list ap;                             /* Vararg list */\n  if( sqlite3GlobalConfig.xLog ){\n    va_start(ap, zFormat);\n    renderLogMsg(iErrCode, zFormat, ap);\n    va_end(ap);\n  }\n}\n\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n/*\n** A version of printf() that understands %lld.  Used for debugging.\n** The printf() built into some versions of windows does not understand %lld\n** and segfaults if you give it a long long int.\n*/\nvoid sqlite3DebugPrintf(const char *zFormat, ...){\n  va_list ap;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  va_end(ap);\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n#endif\n\n\n/*\n** variable-argument wrapper around sqlite3VXPrintf().  The bFlags argument\n** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats.\n*/\nvoid sqlite3XPrintf(StrAccum *p, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap,zFormat);\n  sqlite3VXPrintf(p, zFormat, ap);\n  va_end(ap);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/random.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement a pseudo-random number\n** generator (PRNG) for SQLite.\n**\n** Random numbers are used by some of the database backends in order\n** to generate random integer keys for tables or random filenames.\n*/\n#include \"sqliteInt.h\"\n\n\n/* All threads share a single random number generator.\n** This structure is the current state of the generator.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType {\n  unsigned char isInit;          /* True if initialized */\n  unsigned char i, j;            /* State variables */\n  unsigned char s[256];          /* State variables */\n} sqlite3Prng;\n\n/*\n** Return N random bytes.\n*/\nvoid sqlite3_randomness(int N, void *pBuf){\n  unsigned char t;\n  unsigned char *zBuf = pBuf;\n\n  /* The \"wsdPrng\" macro will resolve to the pseudo-random number generator\n  ** state vector.  If writable static data is unsupported on the target,\n  ** we have to locate the state vector at run-time.  In the more common\n  ** case where writable static data is supported, wsdPrng can refer directly\n  ** to the \"sqlite3Prng\" state vector declared above.\n  */\n#ifdef SQLITE_OMIT_WSD\n  struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng);\n# define wsdPrng p[0]\n#else\n# define wsdPrng sqlite3Prng\n#endif\n\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex;\n#endif\n\n#ifndef SQLITE_OMIT_AUTOINIT\n  if( sqlite3_initialize() ) return;\n#endif\n\n#if SQLITE_THREADSAFE\n  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);\n#endif\n\n  sqlite3_mutex_enter(mutex);\n  if( N<=0 || pBuf==0 ){\n    wsdPrng.isInit = 0;\n    sqlite3_mutex_leave(mutex);\n    return;\n  }\n\n  /* Initialize the state of the random number generator once,\n  ** the first time this routine is called.  The seed value does\n  ** not need to contain a lot of randomness since we are not\n  ** trying to do secure encryption or anything like that...\n  **\n  ** Nothing in this file or anywhere else in SQLite does any kind of\n  ** encryption.  The RC4 algorithm is being used as a PRNG (pseudo-random\n  ** number generator) not as an encryption device.\n  */\n  if( !wsdPrng.isInit ){\n    int i;\n    char k[256];\n    wsdPrng.j = 0;\n    wsdPrng.i = 0;\n    sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k);\n    for(i=0; i<256; i++){\n      wsdPrng.s[i] = (u8)i;\n    }\n    for(i=0; i<256; i++){\n      wsdPrng.j += wsdPrng.s[i] + k[i];\n      t = wsdPrng.s[wsdPrng.j];\n      wsdPrng.s[wsdPrng.j] = wsdPrng.s[i];\n      wsdPrng.s[i] = t;\n    }\n    wsdPrng.isInit = 1;\n  }\n\n  assert( N>0 );\n  do{\n    wsdPrng.i++;\n    t = wsdPrng.s[wsdPrng.i];\n    wsdPrng.j += t;\n    wsdPrng.s[wsdPrng.i] = wsdPrng.s[wsdPrng.j];\n    wsdPrng.s[wsdPrng.j] = t;\n    t += wsdPrng.s[wsdPrng.i];\n    *(zBuf++) = wsdPrng.s[t];\n  }while( --N );\n  sqlite3_mutex_leave(mutex);\n}\n\n#ifndef SQLITE_UNTESTABLE\n/*\n** For testing purposes, we sometimes want to preserve the state of\n** PRNG and restore the PRNG to its saved state at a later time, or\n** to reset the PRNG to its initial state.  These routines accomplish\n** those tasks.\n**\n** The sqlite3_test_control() interface calls these routines to\n** control the PRNG.\n*/\nstatic SQLITE_WSD struct sqlite3PrngType sqlite3SavedPrng;\nvoid sqlite3PrngSaveState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    sizeof(sqlite3Prng)\n  );\n}\nvoid sqlite3PrngRestoreState(void){\n  memcpy(\n    &GLOBAL(struct sqlite3PrngType, sqlite3Prng),\n    &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),\n    sizeof(sqlite3Prng)\n  );\n}\n#endif /* SQLITE_UNTESTABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/resolve.c",
    "content": "/*\n** 2008 August 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains routines used for walking the parser tree and\n** resolve all identifiers by associating them with a particular\n** table and column.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Walk the expression tree pExpr and increase the aggregate function\n** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node.\n** This needs to occur when copying a TK_AGG_FUNCTION node from an\n** outer query into an inner subquery.\n**\n** incrAggFunctionDepth(pExpr,n) is the main routine.  incrAggDepth(..)\n** is a helper function - a callback for the tree walker.\n*/\nstatic int incrAggDepth(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;\n  return WRC_Continue;\n}\nstatic void incrAggFunctionDepth(Expr *pExpr, int N){\n  if( N>0 ){\n    Walker w;\n    memset(&w, 0, sizeof(w));\n    w.xExprCallback = incrAggDepth;\n    w.u.n = N;\n    sqlite3WalkExpr(&w, pExpr);\n  }\n}\n\n/*\n** Turn the pExpr expression into an alias for the iCol-th column of the\n** result set in pEList.\n**\n** If the reference is followed by a COLLATE operator, then make sure\n** the COLLATE operator is preserved.  For example:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase;\n**\n** Should be transformed into:\n**\n**     SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;\n**\n** The nSubquery parameter specifies how many levels of subquery the\n** alias is removed from the original expression.  The usual value is\n** zero but it might be more if the alias is contained within a subquery\n** of the original expression.  The Expr.op2 field of TK_AGG_FUNCTION\n** structures must be increased by the nSubquery amount.\n*/\nstatic void resolveAlias(\n  Parse *pParse,         /* Parsing context */\n  ExprList *pEList,      /* A result set */\n  int iCol,              /* A column in the result set.  0..pEList->nExpr-1 */\n  Expr *pExpr,           /* Transform this into an alias to the result set */\n  const char *zType,     /* \"GROUP\" or \"ORDER\" or \"\" */\n  int nSubquery          /* Number of subqueries that the label is moving */\n){\n  Expr *pOrig;           /* The iCol-th column of the result set */\n  Expr *pDup;            /* Copy of pOrig */\n  sqlite3 *db;           /* The database connection */\n\n  assert( iCol>=0 && iCol<pEList->nExpr );\n  pOrig = pEList->a[iCol].pExpr;\n  assert( pOrig!=0 );\n  db = pParse->db;\n  pDup = sqlite3ExprDup(db, pOrig, 0);\n  if( pDup==0 ) return;\n  if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery);\n  if( pExpr->op==TK_COLLATE ){\n    pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);\n  }\n  ExprSetProperty(pDup, EP_Alias);\n\n  /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This \n  ** prevents ExprDelete() from deleting the Expr structure itself,\n  ** allowing it to be repopulated by the memcpy() on the following line.\n  ** The pExpr->u.zToken might point into memory that will be freed by the\n  ** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to\n  ** make a copy of the token before doing the sqlite3DbFree().\n  */\n  ExprSetProperty(pExpr, EP_Static);\n  sqlite3ExprDelete(db, pExpr);\n  memcpy(pExpr, pDup, sizeof(*pExpr));\n  if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){\n    assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );\n    pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);\n    pExpr->flags |= EP_MemToken;\n  }\n  sqlite3DbFree(db, pDup);\n}\n\n\n/*\n** Return TRUE if the name zCol occurs anywhere in the USING clause.\n**\n** Return FALSE if the USING clause is NULL or if it does not contain\n** zCol.\n*/\nstatic int nameInUsingClause(IdList *pUsing, const char *zCol){\n  if( pUsing ){\n    int k;\n    for(k=0; k<pUsing->nId; k++){\n      if( sqlite3StrICmp(pUsing->a[k].zName, zCol)==0 ) return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Subqueries stores the original database, table and column names for their\n** result sets in ExprList.a[].zSpan, in the form \"DATABASE.TABLE.COLUMN\".\n** Check to see if the zSpan given to this routine matches the zDb, zTab,\n** and zCol.  If any of zDb, zTab, and zCol are NULL then those fields will\n** match anything.\n*/\nint sqlite3MatchSpanName(\n  const char *zSpan,\n  const char *zCol,\n  const char *zTab,\n  const char *zDb\n){\n  int n;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zDb && (sqlite3StrNICmp(zSpan, zDb, n)!=0 || zDb[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  for(n=0; ALWAYS(zSpan[n]) && zSpan[n]!='.'; n++){}\n  if( zTab && (sqlite3StrNICmp(zSpan, zTab, n)!=0 || zTab[n]!=0) ){\n    return 0;\n  }\n  zSpan += n+1;\n  if( zCol && sqlite3StrICmp(zSpan, zCol)!=0 ){\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up\n** that name in the set of source tables in pSrcList and make the pExpr \n** expression node refer back to that source column.  The following changes\n** are made to pExpr:\n**\n**    pExpr->iDb           Set the index in db->aDb[] of the database X\n**                         (even if X is implied).\n**    pExpr->iTable        Set to the cursor number for the table obtained\n**                         from pSrcList.\n**    pExpr->pTab          Points to the Table structure of X.Y (even if\n**                         X and/or Y are implied.)\n**    pExpr->iColumn       Set to the column number within the table.\n**    pExpr->op            Set to TK_COLUMN.\n**    pExpr->pLeft         Any expression this points to is deleted\n**    pExpr->pRight        Any expression this points to is deleted.\n**\n** The zDb variable is the name of the database (the \"X\").  This value may be\n** NULL meaning that name is of the form Y.Z or Z.  Any available database\n** can be used.  The zTable variable is the name of the table (the \"Y\").  This\n** value can be NULL if zDb is also NULL.  If zTable is NULL it\n** means that the form of the name is Z and that columns from any table\n** can be used.\n**\n** If the name cannot be resolved unambiguously, leave an error message\n** in pParse and return WRC_Abort.  Return WRC_Prune on success.\n*/\nstatic int lookupName(\n  Parse *pParse,       /* The parsing context */\n  const char *zDb,     /* Name of the database containing table, or NULL */\n  const char *zTab,    /* Name of table containing column, or NULL */\n  const char *zCol,    /* Name of the column. */\n  NameContext *pNC,    /* The name context used to resolve the name */\n  Expr *pExpr          /* Make this EXPR node point to the selected column */\n){\n  int i, j;                         /* Loop counters */\n  int cnt = 0;                      /* Number of matching column names */\n  int cntTab = 0;                   /* Number of matching table names */\n  int nSubquery = 0;                /* How many levels of subquery */\n  sqlite3 *db = pParse->db;         /* The database connection */\n  struct SrcList_item *pItem;       /* Use for looping over pSrcList items */\n  struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */\n  NameContext *pTopNC = pNC;        /* First namecontext in the list */\n  Schema *pSchema = 0;              /* Schema of the expression */\n  int isTrigger = 0;                /* True if resolved to a trigger column */\n  Table *pTab = 0;                  /* Table hold the row */\n  Column *pCol;                     /* A column of pTab */\n\n  assert( pNC );     /* the name context cannot be NULL. */\n  assert( zCol );    /* The Z in X.Y.Z cannot be NULL */\n  assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );\n\n  /* Initialize the node to no-match */\n  pExpr->iTable = -1;\n  pExpr->pTab = 0;\n  ExprSetVVAProperty(pExpr, EP_NoReduce);\n\n  /* Translate the schema name in zDb into a pointer to the corresponding\n  ** schema.  If not found, pSchema will remain NULL and nothing will match\n  ** resulting in an appropriate error message toward the end of this routine\n  */\n  if( zDb ){\n    testcase( pNC->ncFlags & NC_PartIdx );\n    testcase( pNC->ncFlags & NC_IsCheck );\n    if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){\n      /* Silently ignore database qualifiers inside CHECK constraints and\n      ** partial indices.  Do not raise errors because that might break\n      ** legacy and because it does not hurt anything to just ignore the\n      ** database name. */\n      zDb = 0;\n    }else{\n      for(i=0; i<db->nDb; i++){\n        assert( db->aDb[i].zDbSName );\n        if( sqlite3StrICmp(db->aDb[i].zDbSName,zDb)==0 ){\n          pSchema = db->aDb[i].pSchema;\n          break;\n        }\n      }\n    }\n  }\n\n  /* Start at the inner-most context and move outward until a match is found */\n  assert( pNC && cnt==0 );\n  do{\n    ExprList *pEList;\n    SrcList *pSrcList = pNC->pSrcList;\n\n    if( pSrcList ){\n      for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){\n        pTab = pItem->pTab;\n        assert( pTab!=0 && pTab->zName!=0 );\n        assert( pTab->nCol>0 );\n        if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){\n          int hit = 0;\n          pEList = pItem->pSelect->pEList;\n          for(j=0; j<pEList->nExpr; j++){\n            if( sqlite3MatchSpanName(pEList->a[j].zSpan, zCol, zTab, zDb) ){\n              cnt++;\n              cntTab = 2;\n              pMatch = pItem;\n              pExpr->iColumn = j;\n              hit = 1;\n            }\n          }\n          if( hit || zTab==0 ) continue;\n        }\n        if( zDb && pTab->pSchema!=pSchema ){\n          continue;\n        }\n        if( zTab ){\n          const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;\n          assert( zTabName!=0 );\n          if( sqlite3StrICmp(zTabName, zTab)!=0 ){\n            continue;\n          }\n        }\n        if( 0==(cntTab++) ){\n          pMatch = pItem;\n        }\n        for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            /* If there has been exactly one prior match and this match\n            ** is for the right-hand table of a NATURAL JOIN or is in a \n            ** USING clause, then skip this match.\n            */\n            if( cnt==1 ){\n              if( pItem->fg.jointype & JT_NATURAL ) continue;\n              if( nameInUsingClause(pItem->pUsing, zCol) ) continue;\n            }\n            cnt++;\n            pMatch = pItem;\n            /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */\n            pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;\n            break;\n          }\n        }\n      }\n      if( pMatch ){\n        pExpr->iTable = pMatch->iCursor;\n        pExpr->pTab = pMatch->pTab;\n        /* RIGHT JOIN not (yet) supported */\n        assert( (pMatch->fg.jointype & JT_RIGHT)==0 );\n        if( (pMatch->fg.jointype & JT_LEFT)!=0 ){\n          ExprSetProperty(pExpr, EP_CanBeNull);\n        }\n        pSchema = pExpr->pTab->pSchema;\n      }\n    } /* if( pSrcList ) */\n\n#ifndef SQLITE_OMIT_TRIGGER\n    /* If we have not already resolved the name, then maybe \n    ** it is a new.* or old.* trigger argument reference\n    */\n    if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){\n      int op = pParse->eTriggerOp;\n      assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );\n      if( op!=TK_DELETE && sqlite3StrICmp(\"new\",zTab) == 0 ){\n        pExpr->iTable = 1;\n        pTab = pParse->pTriggerTab;\n      }else if( op!=TK_INSERT && sqlite3StrICmp(\"old\",zTab)==0 ){\n        pExpr->iTable = 0;\n        pTab = pParse->pTriggerTab;\n      }else{\n        pTab = 0;\n      }\n\n      if( pTab ){ \n        int iCol;\n        pSchema = pTab->pSchema;\n        cntTab++;\n        for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){\n          if( sqlite3StrICmp(pCol->zName, zCol)==0 ){\n            if( iCol==pTab->iPKey ){\n              iCol = -1;\n            }\n            break;\n          }\n        }\n        if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){\n          /* IMP: R-51414-32910 */\n          iCol = -1;\n        }\n        if( iCol<pTab->nCol ){\n          cnt++;\n          if( iCol<0 ){\n            pExpr->affinity = SQLITE_AFF_INTEGER;\n          }else if( pExpr->iTable==0 ){\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }else{\n            testcase( iCol==31 );\n            testcase( iCol==32 );\n            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));\n          }\n          pExpr->iColumn = (i16)iCol;\n          pExpr->pTab = pTab;\n          isTrigger = 1;\n        }\n      }\n    }\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n\n    /*\n    ** Perhaps the name is a reference to the ROWID\n    */\n    if( cnt==0\n     && cntTab==1\n     && pMatch\n     && (pNC->ncFlags & NC_IdxExpr)==0\n     && sqlite3IsRowid(zCol)\n     && VisibleRowid(pMatch->pTab)\n    ){\n      cnt = 1;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n    }\n\n    /*\n    ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z\n    ** might refer to an result-set alias.  This happens, for example, when\n    ** we are resolving names in the WHERE clause of the following command:\n    **\n    **     SELECT a+b AS x FROM table WHERE x<10;\n    **\n    ** In cases like this, replace pExpr with a copy of the expression that\n    ** forms the result set entry (\"a+b\" in the example) and return immediately.\n    ** Note that the expression in the result set should have already been\n    ** resolved by the time the WHERE clause is resolved.\n    **\n    ** The ability to use an output result-set column in the WHERE, GROUP BY,\n    ** or HAVING clauses, or as part of a larger expression in the ORDER BY\n    ** clause is not standard SQL.  This is a (goofy) SQLite extension, that\n    ** is supported for backwards compatibility only. Hence, we issue a warning\n    ** on sqlite3_log() whenever the capability is used.\n    */\n    if( (pEList = pNC->pEList)!=0\n     && zTab==0\n     && cnt==0\n    ){\n      for(j=0; j<pEList->nExpr; j++){\n        char *zAs = pEList->a[j].zName;\n        if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n          Expr *pOrig;\n          assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n          assert( pExpr->x.pList==0 );\n          assert( pExpr->x.pSelect==0 );\n          pOrig = pEList->a[j].pExpr;\n          if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){\n            sqlite3ErrorMsg(pParse, \"misuse of aliased aggregate %s\", zAs);\n            return WRC_Abort;\n          }\n          if( sqlite3ExprVectorSize(pOrig)!=1 ){\n            sqlite3ErrorMsg(pParse, \"row value misused\");\n            return WRC_Abort;\n          }\n          resolveAlias(pParse, pEList, j, pExpr, \"\", nSubquery);\n          cnt = 1;\n          pMatch = 0;\n          assert( zTab==0 && zDb==0 );\n          goto lookupname_end;\n        }\n      } \n    }\n\n    /* Advance to the next name context.  The loop will exit when either\n    ** we have a match (cnt>0) or when we run out of name contexts.\n    */\n    if( cnt ) break;\n    pNC = pNC->pNext;\n    nSubquery++;\n  }while( pNC );\n\n\n  /*\n  ** If X and Y are NULL (in other words if only the column name Z is\n  ** supplied) and the value of Z is enclosed in double-quotes, then\n  ** Z is a string literal if it doesn't match any column names.  In that\n  ** case, we need to return right away and not make any changes to\n  ** pExpr.\n  **\n  ** Because no reference was made to outer contexts, the pNC->nRef\n  ** fields are not changed in any context.\n  */\n  if( cnt==0 && zTab==0 && ExprHasProperty(pExpr,EP_DblQuoted) ){\n    pExpr->op = TK_STRING;\n    pExpr->pTab = 0;\n    return WRC_Prune;\n  }\n\n  /*\n  ** cnt==0 means there was not match.  cnt>1 means there were two or\n  ** more matches.  Either way, we have an error.\n  */\n  if( cnt!=1 ){\n    const char *zErr;\n    zErr = cnt==0 ? \"no such column\" : \"ambiguous column name\";\n    if( zDb ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s.%s\", zErr, zDb, zTab, zCol);\n    }else if( zTab ){\n      sqlite3ErrorMsg(pParse, \"%s: %s.%s\", zErr, zTab, zCol);\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s: %s\", zErr, zCol);\n    }\n    pParse->checkSchema = 1;\n    pTopNC->nErr++;\n  }\n\n  /* If a column from a table in pSrcList is referenced, then record\n  ** this fact in the pSrcList.a[].colUsed bitmask.  Column 0 causes\n  ** bit 0 to be set.  Column 1 sets bit 1.  And so forth.  If the\n  ** column number is greater than the number of bits in the bitmask\n  ** then set the high-order bit of the bitmask.\n  */\n  if( pExpr->iColumn>=0 && pMatch!=0 ){\n    int n = pExpr->iColumn;\n    testcase( n==BMS-1 );\n    if( n>=BMS ){\n      n = BMS-1;\n    }\n    assert( pMatch->iCursor==pExpr->iTable );\n    pMatch->colUsed |= ((Bitmask)1)<<n;\n  }\n\n  /* Clean up and return\n  */\n  sqlite3ExprDelete(db, pExpr->pLeft);\n  pExpr->pLeft = 0;\n  sqlite3ExprDelete(db, pExpr->pRight);\n  pExpr->pRight = 0;\n  pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);\n  ExprSetProperty(pExpr, EP_Leaf);\nlookupname_end:\n  if( cnt==1 ){\n    assert( pNC!=0 );\n    if( !ExprHasProperty(pExpr, EP_Alias) ){\n      sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);\n    }\n    /* Increment the nRef value on all name contexts from TopNC up to\n    ** the point where the name matched. */\n    for(;;){\n      assert( pTopNC!=0 );\n      pTopNC->nRef++;\n      if( pTopNC==pNC ) break;\n      pTopNC = pTopNC->pNext;\n    }\n    return WRC_Prune;\n  } else {\n    return WRC_Abort;\n  }\n}\n\n/*\n** Allocate and return a pointer to an expression to load the column iCol\n** from datasource iSrc in SrcList pSrc.\n*/\nExpr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){\n  Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0);\n  if( p ){\n    struct SrcList_item *pItem = &pSrc->a[iSrc];\n    p->pTab = pItem->pTab;\n    p->iTable = pItem->iCursor;\n    if( p->pTab->iPKey==iCol ){\n      p->iColumn = -1;\n    }else{\n      p->iColumn = (ynVar)iCol;\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      pItem->colUsed |= ((Bitmask)1)<<(iCol>=BMS ? BMS-1 : iCol);\n    }\n  }\n  return p;\n}\n\n/*\n** Report an error that an expression is not valid for some set of\n** pNC->ncFlags values determined by validMask.\n*/\nstatic void notValid(\n  Parse *pParse,       /* Leave error message here */\n  NameContext *pNC,    /* The name context */\n  const char *zMsg,    /* Type of error */\n  int validMask        /* Set of contexts for which prohibited */\n){\n  assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 );\n  if( (pNC->ncFlags & validMask)!=0 ){\n    const char *zIn = \"partial index WHERE clauses\";\n    if( pNC->ncFlags & NC_IdxExpr )      zIn = \"index expressions\";\n#ifndef SQLITE_OMIT_CHECK\n    else if( pNC->ncFlags & NC_IsCheck ) zIn = \"CHECK constraints\";\n#endif\n    sqlite3ErrorMsg(pParse, \"%s prohibited in %s\", zMsg, zIn);\n  }\n}\n\n/*\n** Expression p should encode a floating point value between 1.0 and 0.0.\n** Return 1024 times this value.  Or return -1 if p is not a floating point\n** value between 1.0 and 0.0.\n*/\nstatic int exprProbability(Expr *p){\n  double r = -1.0;\n  if( p->op!=TK_FLOAT ) return -1;\n  sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);\n  assert( r>=0.0 );\n  if( r>1.0 ) return -1;\n  return (int)(r*134217728.0);\n}\n\n/*\n** This routine is callback for sqlite3WalkExpr().\n**\n** Resolve symbolic names into TK_COLUMN operators for the current\n** node in the expression tree.  Return 0 to continue the search down\n** the tree or 2 to abort the tree walk.\n**\n** This routine also does error checking and name resolution for\n** function names.  The operator for aggregate functions is changed\n** to TK_AGG_FUNCTION.\n*/\nstatic int resolveExprStep(Walker *pWalker, Expr *pExpr){\n  NameContext *pNC;\n  Parse *pParse;\n\n  pNC = pWalker->u.pNC;\n  assert( pNC!=0 );\n  pParse = pNC->pParse;\n  assert( pParse==pWalker->pParse );\n\n#ifndef NDEBUG\n  if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){\n    SrcList *pSrcList = pNC->pSrcList;\n    int i;\n    for(i=0; i<pNC->pSrcList->nSrc; i++){\n      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);\n    }\n  }\n#endif\n  switch( pExpr->op ){\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n    /* The special operator TK_ROW means use the rowid for the first\n    ** column in the FROM clause.  This is used by the LIMIT and ORDER BY\n    ** clause processing on UPDATE and DELETE statements.\n    */\n    case TK_ROW: {\n      SrcList *pSrcList = pNC->pSrcList;\n      struct SrcList_item *pItem;\n      assert( pSrcList && pSrcList->nSrc==1 );\n      pItem = pSrcList->a; \n      pExpr->op = TK_COLUMN;\n      pExpr->pTab = pItem->pTab;\n      pExpr->iTable = pItem->iCursor;\n      pExpr->iColumn = -1;\n      pExpr->affinity = SQLITE_AFF_INTEGER;\n      break;\n    }\n#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)\n          && !defined(SQLITE_OMIT_SUBQUERY) */\n\n    /* A column name:                    ID\n    ** Or table name and column name:    ID.ID\n    ** Or a database, table and column:  ID.ID.ID\n    **\n    ** The TK_ID and TK_OUT cases are combined so that there will only\n    ** be one call to lookupName().  Then the compiler will in-line \n    ** lookupName() for a size reduction and performance increase.\n    */\n    case TK_ID:\n    case TK_DOT: {\n      const char *zColumn;\n      const char *zTable;\n      const char *zDb;\n      Expr *pRight;\n\n      if( pExpr->op==TK_ID ){\n        zDb = 0;\n        zTable = 0;\n        zColumn = pExpr->u.zToken;\n      }else{\n        notValid(pParse, pNC, \"the \\\".\\\" operator\", NC_IdxExpr);\n        pRight = pExpr->pRight;\n        if( pRight->op==TK_ID ){\n          zDb = 0;\n          zTable = pExpr->pLeft->u.zToken;\n          zColumn = pRight->u.zToken;\n        }else{\n          assert( pRight->op==TK_DOT );\n          zDb = pExpr->pLeft->u.zToken;\n          zTable = pRight->pLeft->u.zToken;\n          zColumn = pRight->pRight->u.zToken;\n        }\n      }\n      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);\n    }\n\n    /* Resolve function names\n    */\n    case TK_FUNCTION: {\n      ExprList *pList = pExpr->x.pList;    /* The argument list */\n      int n = pList ? pList->nExpr : 0;    /* Number of arguments */\n      int no_such_func = 0;       /* True if no such function exists */\n      int wrong_num_args = 0;     /* True if wrong number of arguments */\n      int is_agg = 0;             /* True if is an aggregate function */\n      int nId;                    /* Number of characters in function name */\n      const char *zId;            /* The function name. */\n      FuncDef *pDef;              /* Information about the function */\n      u8 enc = ENC(pParse->db);   /* The database encoding */\n\n      assert( !ExprHasProperty(pExpr, EP_xIsSelect) );\n      zId = pExpr->u.zToken;\n      nId = sqlite3Strlen30(zId);\n      pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);\n      if( pDef==0 ){\n        pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);\n        if( pDef==0 ){\n          no_such_func = 1;\n        }else{\n          wrong_num_args = 1;\n        }\n      }else{\n        is_agg = pDef->xFinalize!=0;\n        if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){\n          ExprSetProperty(pExpr, EP_Unlikely|EP_Skip);\n          if( n==2 ){\n            pExpr->iTable = exprProbability(pList->a[1].pExpr);\n            if( pExpr->iTable<0 ){\n              sqlite3ErrorMsg(pParse,\n                \"second argument to likelihood() must be a \"\n                \"constant between 0.0 and 1.0\");\n              pNC->nErr++;\n            }\n          }else{\n            /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is\n            ** equivalent to likelihood(X, 0.0625).\n            ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is\n            ** short-hand for likelihood(X,0.0625).\n            ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand\n            ** for likelihood(X,0.9375).\n            ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent\n            ** to likelihood(X,0.9375). */\n            /* TUNING: unlikely() probability is 0.0625.  likely() is 0.9375 */\n            pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;\n          }             \n        }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n        {\n          int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);\n          if( auth!=SQLITE_OK ){\n            if( auth==SQLITE_DENY ){\n              sqlite3ErrorMsg(pParse, \"not authorized to use function: %s\",\n                                      pDef->zName);\n              pNC->nErr++;\n            }\n            pExpr->op = TK_NULL;\n            return WRC_Prune;\n          }\n        }\n#endif\n        if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){\n          /* For the purposes of the EP_ConstFunc flag, date and time\n          ** functions and other functions that change slowly are considered\n          ** constant because they are constant for the duration of one query */\n          ExprSetProperty(pExpr,EP_ConstFunc);\n        }\n        if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){\n          /* Date/time functions that use 'now', and other functions like\n          ** sqlite_version() that might change over time cannot be used\n          ** in an index. */\n          notValid(pParse, pNC, \"non-deterministic functions\",\n                   NC_IdxExpr|NC_PartIdx);\n        }\n      }\n      if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){\n        sqlite3ErrorMsg(pParse, \"misuse of aggregate function %.*s()\", nId,zId);\n        pNC->nErr++;\n        is_agg = 0;\n      }else if( no_such_func && pParse->db->init.busy==0\n#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION\n                && pParse->explain==0\n#endif\n      ){\n        sqlite3ErrorMsg(pParse, \"no such function: %.*s\", nId, zId);\n        pNC->nErr++;\n      }else if( wrong_num_args ){\n        sqlite3ErrorMsg(pParse,\"wrong number of arguments to function %.*s()\",\n             nId, zId);\n        pNC->nErr++;\n      }\n      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;\n      sqlite3WalkExprList(pWalker, pList);\n      if( is_agg ){\n        NameContext *pNC2 = pNC;\n        pExpr->op = TK_AGG_FUNCTION;\n        pExpr->op2 = 0;\n        while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){\n          pExpr->op2++;\n          pNC2 = pNC2->pNext;\n        }\n        assert( pDef!=0 );\n        if( pNC2 ){\n          assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );\n          testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );\n          pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);\n\n        }\n        pNC->ncFlags |= NC_AllowAgg;\n      }\n      /* FIX ME:  Compute pExpr->affinity based on the expected return\n      ** type of the function \n      */\n      return WRC_Prune;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT:\n    case TK_EXISTS:  testcase( pExpr->op==TK_EXISTS );\n#endif\n    case TK_IN: {\n      testcase( pExpr->op==TK_IN );\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        int nRef = pNC->nRef;\n        notValid(pParse, pNC, \"subqueries\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n        sqlite3WalkSelect(pWalker, pExpr->x.pSelect);\n        assert( pNC->nRef>=nRef );\n        if( nRef!=pNC->nRef ){\n          ExprSetProperty(pExpr, EP_VarSelect);\n          pNC->ncFlags |= NC_VarSelect;\n        }\n      }\n      break;\n    }\n    case TK_VARIABLE: {\n      notValid(pParse, pNC, \"parameters\", NC_IsCheck|NC_PartIdx|NC_IdxExpr);\n      break;\n    }\n    case TK_BETWEEN:\n    case TK_EQ:\n    case TK_NE:\n    case TK_LT:\n    case TK_LE:\n    case TK_GT:\n    case TK_GE:\n    case TK_IS:\n    case TK_ISNOT: {\n      int nLeft, nRight;\n      if( pParse->db->mallocFailed ) break;\n      assert( pExpr->pLeft!=0 );\n      nLeft = sqlite3ExprVectorSize(pExpr->pLeft);\n      if( pExpr->op==TK_BETWEEN ){\n        nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr);\n        if( nRight==nLeft ){\n          nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr);\n        }\n      }else{\n        assert( pExpr->pRight!=0 );\n        nRight = sqlite3ExprVectorSize(pExpr->pRight);\n      }\n      if( nLeft!=nRight ){\n        testcase( pExpr->op==TK_EQ );\n        testcase( pExpr->op==TK_NE );\n        testcase( pExpr->op==TK_LT );\n        testcase( pExpr->op==TK_LE );\n        testcase( pExpr->op==TK_GT );\n        testcase( pExpr->op==TK_GE );\n        testcase( pExpr->op==TK_IS );\n        testcase( pExpr->op==TK_ISNOT );\n        testcase( pExpr->op==TK_BETWEEN );\n        sqlite3ErrorMsg(pParse, \"row value misused\");\n      }\n      break; \n    }\n  }\n  return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;\n}\n\n/*\n** pEList is a list of expressions which are really the result set of the\n** a SELECT statement.  pE is a term in an ORDER BY or GROUP BY clause.\n** This routine checks to see if pE is a simple identifier which corresponds\n** to the AS-name of one of the terms of the expression list.  If it is,\n** this routine return an integer between 1 and N where N is the number of\n** elements in pEList, corresponding to the matching entry.  If there is\n** no match, or if pE is not a simple identifier, then this routine\n** return 0.\n**\n** pEList has been resolved.  pE has not.\n*/\nstatic int resolveAsName(\n  Parse *pParse,     /* Parsing context for error messages */\n  ExprList *pEList,  /* List of expressions to scan */\n  Expr *pE           /* Expression we are trying to match */\n){\n  int i;             /* Loop counter */\n\n  UNUSED_PARAMETER(pParse);\n\n  if( pE->op==TK_ID ){\n    char *zCol = pE->u.zToken;\n    for(i=0; i<pEList->nExpr; i++){\n      char *zAs = pEList->a[i].zName;\n      if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){\n        return i+1;\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** pE is a pointer to an expression which is a single term in the\n** ORDER BY of a compound SELECT.  The expression has not been\n** name resolved.\n**\n** At the point this routine is called, we already know that the\n** ORDER BY term is not an integer index into the result set.  That\n** case is handled by the calling routine.\n**\n** Attempt to match pE against result set columns in the left-most\n** SELECT statement.  Return the index i of the matching column,\n** as an indication to the caller that it should sort by the i-th column.\n** The left-most column is 1.  In other words, the value returned is the\n** same integer value that would be used in the SQL statement to indicate\n** the column.\n**\n** If there is no match, return 0.  Return -1 if an error occurs.\n*/\nstatic int resolveOrderByTermToExprList(\n  Parse *pParse,     /* Parsing context for error messages */\n  Select *pSelect,   /* The SELECT statement with the ORDER BY clause */\n  Expr *pE           /* The specific ORDER BY term */\n){\n  int i;             /* Loop counter */\n  ExprList *pEList;  /* The columns of the result set */\n  NameContext nc;    /* Name context for resolving pE */\n  sqlite3 *db;       /* Database connection */\n  int rc;            /* Return code from subprocedures */\n  u8 savedSuppErr;   /* Saved value of db->suppressErr */\n\n  assert( sqlite3ExprIsInteger(pE, &i)==0 );\n  pEList = pSelect->pEList;\n\n  /* Resolve all names in the ORDER BY term expression\n  */\n  memset(&nc, 0, sizeof(nc));\n  nc.pParse = pParse;\n  nc.pSrcList = pSelect->pSrc;\n  nc.pEList = pEList;\n  nc.ncFlags = NC_AllowAgg;\n  nc.nErr = 0;\n  db = pParse->db;\n  savedSuppErr = db->suppressErr;\n  db->suppressErr = 1;\n  rc = sqlite3ResolveExprNames(&nc, pE);\n  db->suppressErr = savedSuppErr;\n  if( rc ) return 0;\n\n  /* Try to match the ORDER BY expression against an expression\n  ** in the result set.  Return an 1-based index of the matching\n  ** result-set entry.\n  */\n  for(i=0; i<pEList->nExpr; i++){\n    if( sqlite3ExprCompare(0, pEList->a[i].pExpr, pE, -1)<2 ){\n      return i+1;\n    }\n  }\n\n  /* If no match, return 0. */\n  return 0;\n}\n\n/*\n** Generate an ORDER BY or GROUP BY term out-of-range error.\n*/\nstatic void resolveOutOfRangeError(\n  Parse *pParse,         /* The error context into which to write the error */\n  const char *zType,     /* \"ORDER\" or \"GROUP\" */\n  int i,                 /* The index (1-based) of the term out of range */\n  int mx                 /* Largest permissible value of i */\n){\n  sqlite3ErrorMsg(pParse, \n    \"%r %s BY term out of range - should be \"\n    \"between 1 and %d\", i, zType, mx);\n}\n\n/*\n** Analyze the ORDER BY clause in a compound SELECT statement.   Modify\n** each term of the ORDER BY clause is a constant integer between 1\n** and N where N is the number of columns in the compound SELECT.\n**\n** ORDER BY terms that are already an integer between 1 and N are\n** unmodified.  ORDER BY terms that are integers outside the range of\n** 1 through N generate an error.  ORDER BY terms that are expressions\n** are matched against result set expressions of compound SELECT\n** beginning with the left-most SELECT and working toward the right.\n** At the first match, the ORDER BY expression is transformed into\n** the integer column number.\n**\n** Return the number of errors seen.\n*/\nstatic int resolveCompoundOrderBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect       /* The SELECT statement containing the ORDER BY */\n){\n  int i;\n  ExprList *pOrderBy;\n  ExprList *pEList;\n  sqlite3 *db;\n  int moreToDo = 1;\n\n  pOrderBy = pSelect->pOrderBy;\n  if( pOrderBy==0 ) return 0;\n  db = pParse->db;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in ORDER BY clause\");\n    return 1;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    pOrderBy->a[i].done = 0;\n  }\n  pSelect->pNext = 0;\n  while( pSelect->pPrior ){\n    pSelect->pPrior->pNext = pSelect;\n    pSelect = pSelect->pPrior;\n  }\n  while( pSelect && moreToDo ){\n    struct ExprList_item *pItem;\n    moreToDo = 0;\n    pEList = pSelect->pEList;\n    assert( pEList!=0 );\n    for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n      int iCol = -1;\n      Expr *pE, *pDup;\n      if( pItem->done ) continue;\n      pE = sqlite3ExprSkipCollate(pItem->pExpr);\n      if( sqlite3ExprIsInteger(pE, &iCol) ){\n        if( iCol<=0 || iCol>pEList->nExpr ){\n          resolveOutOfRangeError(pParse, \"ORDER\", i+1, pEList->nExpr);\n          return 1;\n        }\n      }else{\n        iCol = resolveAsName(pParse, pEList, pE);\n        if( iCol==0 ){\n          pDup = sqlite3ExprDup(db, pE, 0);\n          if( !db->mallocFailed ){\n            assert(pDup);\n            iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);\n          }\n          sqlite3ExprDelete(db, pDup);\n        }\n      }\n      if( iCol>0 ){\n        /* Convert the ORDER BY term into an integer column number iCol,\n        ** taking care to preserve the COLLATE clause if it exists */\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return 1;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = iCol;\n        if( pItem->pExpr==pE ){\n          pItem->pExpr = pNew;\n        }else{\n          Expr *pParent = pItem->pExpr;\n          assert( pParent->op==TK_COLLATE );\n          while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;\n          assert( pParent->pLeft==pE );\n          pParent->pLeft = pNew;\n        }\n        sqlite3ExprDelete(db, pE);\n        pItem->u.x.iOrderByCol = (u16)iCol;\n        pItem->done = 1;\n      }else{\n        moreToDo = 1;\n      }\n    }\n    pSelect = pSelect->pNext;\n  }\n  for(i=0; i<pOrderBy->nExpr; i++){\n    if( pOrderBy->a[i].done==0 ){\n      sqlite3ErrorMsg(pParse, \"%r ORDER BY term does not match any \"\n            \"column in the result set\", i+1);\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Check every term in the ORDER BY or GROUP BY clause pOrderBy of\n** the SELECT statement pSelect.  If any term is reference to a\n** result set expression (as determined by the ExprList.a.u.x.iOrderByCol\n** field) then convert that term into a copy of the corresponding result set\n** column.\n**\n** If any errors are detected, add an error message to pParse and\n** return non-zero.  Return zero if no errors are seen.\n*/\nint sqlite3ResolveOrderGroupBy(\n  Parse *pParse,        /* Parsing context.  Leave error messages here */\n  Select *pSelect,      /* The SELECT statement containing the clause */\n  ExprList *pOrderBy,   /* The ORDER BY or GROUP BY clause to be processed */\n  const char *zType     /* \"ORDER\" or \"GROUP\" */\n){\n  int i;\n  sqlite3 *db = pParse->db;\n  ExprList *pEList;\n  struct ExprList_item *pItem;\n\n  if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;\n  if( pOrderBy->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many terms in %s BY clause\", zType);\n    return 1;\n  }\n  pEList = pSelect->pEList;\n  assert( pEList!=0 );  /* sqlite3SelectNew() guarantees this */\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    if( pItem->u.x.iOrderByCol ){\n      if( pItem->u.x.iOrderByCol>pEList->nExpr ){\n        resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);\n        return 1;\n      }\n      resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,\n                   zType,0);\n    }\n  }\n  return 0;\n}\n\n/*\n** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.\n** The Name context of the SELECT statement is pNC.  zType is either\n** \"ORDER\" or \"GROUP\" depending on which type of clause pOrderBy is.\n**\n** This routine resolves each term of the clause into an expression.\n** If the order-by term is an integer I between 1 and N (where N is the\n** number of columns in the result set of the SELECT) then the expression\n** in the resolution is a copy of the I-th result-set expression.  If\n** the order-by term is an identifier that corresponds to the AS-name of\n** a result-set expression, then the term resolves to a copy of the\n** result-set expression.  Otherwise, the expression is resolved in\n** the usual way - using sqlite3ResolveExprNames().\n**\n** This routine returns the number of errors.  If errors occur, then\n** an appropriate error message might be left in pParse.  (OOM errors\n** excepted.)\n*/\nstatic int resolveOrderGroupBy(\n  NameContext *pNC,     /* The name context of the SELECT statement */\n  Select *pSelect,      /* The SELECT statement holding pOrderBy */\n  ExprList *pOrderBy,   /* An ORDER BY or GROUP BY clause to resolve */\n  const char *zType     /* Either \"ORDER\" or \"GROUP\", as appropriate */\n){\n  int i, j;                      /* Loop counters */\n  int iCol;                      /* Column number */\n  struct ExprList_item *pItem;   /* A term of the ORDER BY clause */\n  Parse *pParse;                 /* Parsing context */\n  int nResult;                   /* Number of terms in the result set */\n\n  if( pOrderBy==0 ) return 0;\n  nResult = pSelect->pEList->nExpr;\n  pParse = pNC->pParse;\n  for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){\n    Expr *pE = pItem->pExpr;\n    Expr *pE2 = sqlite3ExprSkipCollate(pE);\n    if( zType[0]!='G' ){\n      iCol = resolveAsName(pParse, pSelect->pEList, pE2);\n      if( iCol>0 ){\n        /* If an AS-name match is found, mark this ORDER BY column as being\n        ** a copy of the iCol-th result-set column.  The subsequent call to\n        ** sqlite3ResolveOrderGroupBy() will convert the expression to a\n        ** copy of the iCol-th result-set expression. */\n        pItem->u.x.iOrderByCol = (u16)iCol;\n        continue;\n      }\n    }\n    if( sqlite3ExprIsInteger(pE2, &iCol) ){\n      /* The ORDER BY term is an integer constant.  Again, set the column\n      ** number so that sqlite3ResolveOrderGroupBy() will convert the\n      ** order-by term to a copy of the result-set expression */\n      if( iCol<1 || iCol>0xffff ){\n        resolveOutOfRangeError(pParse, zType, i+1, nResult);\n        return 1;\n      }\n      pItem->u.x.iOrderByCol = (u16)iCol;\n      continue;\n    }\n\n    /* Otherwise, treat the ORDER BY term as an ordinary expression */\n    pItem->u.x.iOrderByCol = 0;\n    if( sqlite3ResolveExprNames(pNC, pE) ){\n      return 1;\n    }\n    for(j=0; j<pSelect->pEList->nExpr; j++){\n      if( sqlite3ExprCompare(0, pE, pSelect->pEList->a[j].pExpr, -1)==0 ){\n        pItem->u.x.iOrderByCol = j+1;\n      }\n    }\n  }\n  return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);\n}\n\n/*\n** Resolve names in the SELECT statement p and all of its descendants.\n*/\nstatic int resolveSelectStep(Walker *pWalker, Select *p){\n  NameContext *pOuterNC;  /* Context that contains this SELECT */\n  NameContext sNC;        /* Name context of this SELECT */\n  int isCompound;         /* True if p is a compound select */\n  int nCompound;          /* Number of compound terms processed so far */\n  Parse *pParse;          /* Parsing context */\n  int i;                  /* Loop counter */\n  ExprList *pGroupBy;     /* The GROUP BY clause */\n  Select *pLeftmost;      /* Left-most of SELECT of a compound */\n  sqlite3 *db;            /* Database connection */\n  \n\n  assert( p!=0 );\n  if( p->selFlags & SF_Resolved ){\n    return WRC_Prune;\n  }\n  pOuterNC = pWalker->u.pNC;\n  pParse = pWalker->pParse;\n  db = pParse->db;\n\n  /* Normally sqlite3SelectExpand() will be called first and will have\n  ** already expanded this SELECT.  However, if this is a subquery within\n  ** an expression, sqlite3ResolveExprNames() will be called without a\n  ** prior call to sqlite3SelectExpand().  When that happens, let\n  ** sqlite3SelectPrep() do all of the processing for this SELECT.\n  ** sqlite3SelectPrep() will invoke both sqlite3SelectExpand() and\n  ** this routine in the correct order.\n  */\n  if( (p->selFlags & SF_Expanded)==0 ){\n    sqlite3SelectPrep(pParse, p, pOuterNC);\n    return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;\n  }\n\n  isCompound = p->pPrior!=0;\n  nCompound = 0;\n  pLeftmost = p;\n  while( p ){\n    assert( (p->selFlags & SF_Expanded)!=0 );\n    assert( (p->selFlags & SF_Resolved)==0 );\n    p->selFlags |= SF_Resolved;\n\n    /* Resolve the expressions in the LIMIT and OFFSET clauses. These\n    ** are not allowed to refer to any names, so pass an empty NameContext.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||\n        sqlite3ResolveExprNames(&sNC, p->pOffset) ){\n      return WRC_Abort;\n    }\n\n    /* If the SF_Converted flags is set, then this Select object was\n    ** was created by the convertCompoundSelectToSubquery() function.\n    ** In this case the ORDER BY clause (p->pOrderBy) should be resolved\n    ** as if it were part of the sub-query, not the parent. This block\n    ** moves the pOrderBy down to the sub-query. It will be moved back\n    ** after the names have been resolved.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      assert( p->pSrc->nSrc==1 && p->pOrderBy );\n      assert( pSub->pPrior && pSub->pOrderBy==0 );\n      pSub->pOrderBy = p->pOrderBy;\n      p->pOrderBy = 0;\n    }\n  \n    /* Recursively resolve names in all subqueries\n    */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->pSelect ){\n        NameContext *pNC;         /* Used to iterate name contexts */\n        int nRef = 0;             /* Refcount for pOuterNC and outer contexts */\n        const char *zSavedContext = pParse->zAuthContext;\n\n        /* Count the total number of references to pOuterNC and all of its\n        ** parent contexts. After resolving references to expressions in\n        ** pItem->pSelect, check if this value has changed. If so, then\n        ** SELECT statement pItem->pSelect must be correlated. Set the\n        ** pItem->fg.isCorrelated flag if this is the case. */\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef;\n\n        if( pItem->zName ) pParse->zAuthContext = pItem->zName;\n        sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);\n        pParse->zAuthContext = zSavedContext;\n        if( pParse->nErr || db->mallocFailed ) return WRC_Abort;\n\n        for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef;\n        assert( pItem->fg.isCorrelated==0 && nRef<=0 );\n        pItem->fg.isCorrelated = (nRef!=0);\n      }\n    }\n  \n    /* Set up the local name-context to pass to sqlite3ResolveExprNames() to\n    ** resolve the result-set expression list.\n    */\n    sNC.ncFlags = NC_AllowAgg;\n    sNC.pSrcList = p->pSrc;\n    sNC.pNext = pOuterNC;\n  \n    /* Resolve names in the result set. */\n    if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort;\n  \n    /* If there are no aggregate functions in the result-set, and no GROUP BY \n    ** expression, do not allow aggregates in any of the other expressions.\n    */\n    assert( (p->selFlags & SF_Aggregate)==0 );\n    pGroupBy = p->pGroupBy;\n    if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){\n      assert( NC_MinMaxAgg==SF_MinMaxAgg );\n      p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);\n    }else{\n      sNC.ncFlags &= ~NC_AllowAgg;\n    }\n  \n    /* If a HAVING clause is present, then there must be a GROUP BY clause.\n    */\n    if( p->pHaving && !pGroupBy ){\n      sqlite3ErrorMsg(pParse, \"a GROUP BY clause is required before HAVING\");\n      return WRC_Abort;\n    }\n  \n    /* Add the output column list to the name-context before parsing the\n    ** other expressions in the SELECT statement. This is so that\n    ** expressions in the WHERE clause (etc.) can refer to expressions by\n    ** aliases in the result set.\n    **\n    ** Minor point: If this is the case, then the expression will be\n    ** re-evaluated for each reference to it.\n    */\n    sNC.pEList = p->pEList;\n    if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;\n    if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;\n\n    /* Resolve names in table-valued-function arguments */\n    for(i=0; i<p->pSrc->nSrc; i++){\n      struct SrcList_item *pItem = &p->pSrc->a[i];\n      if( pItem->fg.isTabFunc\n       && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) \n      ){\n        return WRC_Abort;\n      }\n    }\n\n    /* The ORDER BY and GROUP BY clauses may not refer to terms in\n    ** outer queries \n    */\n    sNC.pNext = 0;\n    sNC.ncFlags |= NC_AllowAgg;\n\n    /* If this is a converted compound query, move the ORDER BY clause from \n    ** the sub-query back to the parent query. At this point each term\n    ** within the ORDER BY clause has been transformed to an integer value.\n    ** These integers will be replaced by copies of the corresponding result\n    ** set expressions by the call to resolveOrderGroupBy() below.  */\n    if( p->selFlags & SF_Converted ){\n      Select *pSub = p->pSrc->a[0].pSelect;\n      p->pOrderBy = pSub->pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n\n    /* Process the ORDER BY clause for singleton SELECT statements.\n    ** The ORDER BY clause for compounds SELECT statements is handled\n    ** below, after all of the result-sets for all of the elements of\n    ** the compound have been resolved.\n    **\n    ** If there is an ORDER BY clause on a term of a compound-select other\n    ** than the right-most term, then that is a syntax error.  But the error\n    ** is not detected until much later, and so we need to go ahead and\n    ** resolve those symbols on the incorrect ORDER BY for consistency.\n    */\n    if( isCompound<=nCompound  /* Defer right-most ORDER BY of a compound */\n     && resolveOrderGroupBy(&sNC, p, p->pOrderBy, \"ORDER\")\n    ){\n      return WRC_Abort;\n    }\n    if( db->mallocFailed ){\n      return WRC_Abort;\n    }\n  \n    /* Resolve the GROUP BY clause.  At the same time, make sure \n    ** the GROUP BY clause does not contain aggregate functions.\n    */\n    if( pGroupBy ){\n      struct ExprList_item *pItem;\n    \n      if( resolveOrderGroupBy(&sNC, p, pGroupBy, \"GROUP\") || db->mallocFailed ){\n        return WRC_Abort;\n      }\n      for(i=0, pItem=pGroupBy->a; i<pGroupBy->nExpr; i++, pItem++){\n        if( ExprHasProperty(pItem->pExpr, EP_Agg) ){\n          sqlite3ErrorMsg(pParse, \"aggregate functions are not allowed in \"\n              \"the GROUP BY clause\");\n          return WRC_Abort;\n        }\n      }\n    }\n\n    /* If this is part of a compound SELECT, check that it has the right\n    ** number of expressions in the select list. */\n    if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){\n      sqlite3SelectWrongNumTermsError(pParse, p->pNext);\n      return WRC_Abort;\n    }\n\n    /* Advance to the next term of the compound\n    */\n    p = p->pPrior;\n    nCompound++;\n  }\n\n  /* Resolve the ORDER BY on a compound SELECT after all terms of\n  ** the compound have been resolved.\n  */\n  if( isCompound && resolveCompoundOrderBy(pParse, pLeftmost) ){\n    return WRC_Abort;\n  }\n\n  return WRC_Prune;\n}\n\n/*\n** This routine walks an expression tree and resolves references to\n** table columns and result-set columns.  At the same time, do error\n** checking on function usage and set a flag if any aggregate functions\n** are seen.\n**\n** To resolve table columns references we look for nodes (or subtrees) of the \n** form X.Y.Z or Y.Z or just Z where\n**\n**      X:   The name of a database.  Ex:  \"main\" or \"temp\" or\n**           the symbolic name assigned to an ATTACH-ed database.\n**\n**      Y:   The name of a table in a FROM clause.  Or in a trigger\n**           one of the special names \"old\" or \"new\".\n**\n**      Z:   The name of a column in table Y.\n**\n** The node at the root of the subtree is modified as follows:\n**\n**    Expr.op        Changed to TK_COLUMN\n**    Expr.pTab      Points to the Table object for X.Y\n**    Expr.iColumn   The column index in X.Y.  -1 for the rowid.\n**    Expr.iTable    The VDBE cursor number for X.Y\n**\n**\n** To resolve result-set references, look for expression nodes of the\n** form Z (with no X and Y prefix) where the Z matches the right-hand\n** size of an AS clause in the result-set of a SELECT.  The Z expression\n** is replaced by a copy of the left-hand side of the result-set expression.\n** Table-name and function resolution occurs on the substituted expression\n** tree.  For example, in:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;\n**\n** The \"x\" term of the order by is replaced by \"a+b\" to render:\n**\n**      SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;\n**\n** Function calls are checked to make sure that the function is \n** defined and that the correct number of arguments are specified.\n** If the function is an aggregate function, then the NC_HasAgg flag is\n** set and the opcode is changed from TK_FUNCTION to TK_AGG_FUNCTION.\n** If an expression contains aggregate functions then the EP_Agg\n** property on the expression is set.\n**\n** An error message is left in pParse if anything is amiss.  The number\n** if errors is returned.\n*/\nint sqlite3ResolveExprNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  Expr *pExpr             /* The expression to be analyzed. */\n){\n  u16 savedHasAgg;\n  Walker w;\n\n  if( pExpr==0 ) return SQLITE_OK;\n  savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);\n  pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);\n  w.pParse = pNC->pParse;\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.u.pNC = pNC;\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight += pExpr->nHeight;\n  if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){\n    return SQLITE_ERROR;\n  }\n#endif\n  sqlite3WalkExpr(&w, pExpr);\n#if SQLITE_MAX_EXPR_DEPTH>0\n  w.pParse->nHeight -= pExpr->nHeight;\n#endif\n  if( pNC->ncFlags & NC_HasAgg ){\n    ExprSetProperty(pExpr, EP_Agg);\n  }\n  pNC->ncFlags |= savedHasAgg;\n  return pNC->nErr>0 || w.pParse->nErr>0;\n}\n\n/*\n** Resolve all names for all expression in an expression list.  This is\n** just like sqlite3ResolveExprNames() except that it works for an expression\n** list rather than a single expression.\n*/\nint sqlite3ResolveExprListNames( \n  NameContext *pNC,       /* Namespace to resolve expressions in. */\n  ExprList *pList         /* The expression list to be analyzed. */\n){\n  int i;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Resolve all names in all expressions of a SELECT and in all\n** decendents of the SELECT, including compounds off of p->pPrior,\n** subqueries in expressions, and subqueries used as FROM clause\n** terms.\n**\n** See sqlite3ResolveExprNames() for a description of the kinds of\n** transformations that occur.\n**\n** All SELECT statements should have been expanded using\n** sqlite3SelectExpand() prior to invoking this routine.\n*/\nvoid sqlite3ResolveSelectNames(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for parent SELECT statement */\n){\n  Walker w;\n\n  assert( p!=0 );\n  w.xExprCallback = resolveExprStep;\n  w.xSelectCallback = resolveSelectStep;\n  w.xSelectCallback2 = 0;\n  w.pParse = pParse;\n  w.u.pNC = pOuterNC;\n  sqlite3WalkSelect(&w, p);\n}\n\n/*\n** Resolve names in expressions that can only reference a single table:\n**\n**    *   CHECK constraints\n**    *   WHERE clauses on partial indices\n**\n** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression\n** is set to -1 and the Expr.iColumn value is set to the column number.\n**\n** Any errors cause an error message to be set in pParse.\n*/\nvoid sqlite3ResolveSelfReference(\n  Parse *pParse,      /* Parsing context */\n  Table *pTab,        /* The table being referenced */\n  int type,           /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */\n  Expr *pExpr,        /* Expression to resolve.  May be NULL. */\n  ExprList *pList     /* Expression list to resolve.  May be NUL. */\n){\n  SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */\n  NameContext sNC;                /* Name context for pParse->pNewTable */\n\n  assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );\n  memset(&sNC, 0, sizeof(sNC));\n  memset(&sSrc, 0, sizeof(sSrc));\n  sSrc.nSrc = 1;\n  sSrc.a[0].zName = pTab->zName;\n  sSrc.a[0].pTab = pTab;\n  sSrc.a[0].iCursor = -1;\n  sNC.pParse = pParse;\n  sNC.pSrcList = &sSrc;\n  sNC.ncFlags = type;\n  if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;\n  if( pList ) sqlite3ResolveExprListNames(&sNC, pList);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/rowset.c",
    "content": "/*\n** 2008 December 3\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements an object we call a \"RowSet\".\n**\n** The RowSet object is a collection of rowids.  Rowids\n** are inserted into the RowSet in an arbitrary order.  Inserts\n** can be intermixed with tests to see if a given rowid has been\n** previously inserted into the RowSet.\n**\n** After all inserts are finished, it is possible to extract the\n** elements of the RowSet in sorted order.  Once this extraction\n** process has started, no new elements may be inserted.\n**\n** Hence, the primitive operations for a RowSet are:\n**\n**    CREATE\n**    INSERT\n**    TEST\n**    SMALLEST\n**    DESTROY\n**\n** The CREATE and DESTROY primitives are the constructor and destructor,\n** obviously.  The INSERT primitive adds a new element to the RowSet.\n** TEST checks to see if an element is already in the RowSet.  SMALLEST\n** extracts the least value from the RowSet.\n**\n** The INSERT primitive might allocate additional memory.  Memory is\n** allocated in chunks so most INSERTs do no allocation.  There is an \n** upper bound on the size of allocated memory.  No memory is freed\n** until DESTROY.\n**\n** The TEST primitive includes a \"batch\" number.  The TEST primitive\n** will only see elements that were inserted before the last change\n** in the batch number.  In other words, if an INSERT occurs between\n** two TESTs where the TESTs have the same batch nubmer, then the\n** value added by the INSERT will not be visible to the second TEST.\n** The initial batch number is zero, so if the very first TEST contains\n** a non-zero batch number, it will see all prior INSERTs.\n**\n** No INSERTs may occurs after a SMALLEST.  An assertion will fail if\n** that is attempted.\n**\n** The cost of an INSERT is roughly constant.  (Sometimes new memory\n** has to be allocated on an INSERT.)  The cost of a TEST with a new\n** batch number is O(NlogN) where N is the number of elements in the RowSet.\n** The cost of a TEST using the same batch number is O(logN).  The cost\n** of the first SMALLEST is O(NlogN).  Second and subsequent SMALLEST\n** primitives are constant time.  The cost of DESTROY is O(N).\n**\n** TEST and SMALLEST may not be used by the same RowSet.  This used to\n** be possible, but the feature was not used, so it was removed in order\n** to simplify the code.\n*/\n#include \"sqliteInt.h\"\n\n\n/*\n** Target size for allocation chunks.\n*/\n#define ROWSET_ALLOCATION_SIZE 1024\n\n/*\n** The number of rowset entries per allocation chunk.\n*/\n#define ROWSET_ENTRY_PER_CHUNK  \\\n                       ((ROWSET_ALLOCATION_SIZE-8)/sizeof(struct RowSetEntry))\n\n/*\n** Each entry in a RowSet is an instance of the following object.\n**\n** This same object is reused to store a linked list of trees of RowSetEntry\n** objects.  In that alternative use, pRight points to the next entry\n** in the list, pLeft points to the tree, and v is unused.  The\n** RowSet.pForest value points to the head of this forest list.\n*/\nstruct RowSetEntry {            \n  i64 v;                        /* ROWID value for this entry */\n  struct RowSetEntry *pRight;   /* Right subtree (larger entries) or list */\n  struct RowSetEntry *pLeft;    /* Left subtree (smaller entries) */\n};\n\n/*\n** RowSetEntry objects are allocated in large chunks (instances of the\n** following structure) to reduce memory allocation overhead.  The\n** chunks are kept on a linked list so that they can be deallocated\n** when the RowSet is destroyed.\n*/\nstruct RowSetChunk {\n  struct RowSetChunk *pNextChunk;        /* Next chunk on list of them all */\n  struct RowSetEntry aEntry[ROWSET_ENTRY_PER_CHUNK]; /* Allocated entries */\n};\n\n/*\n** A RowSet in an instance of the following structure.\n**\n** A typedef of this structure if found in sqliteInt.h.\n*/\nstruct RowSet {\n  struct RowSetChunk *pChunk;    /* List of all chunk allocations */\n  sqlite3 *db;                   /* The database connection */\n  struct RowSetEntry *pEntry;    /* List of entries using pRight */\n  struct RowSetEntry *pLast;     /* Last entry on the pEntry list */\n  struct RowSetEntry *pFresh;    /* Source of new entry objects */\n  struct RowSetEntry *pForest;   /* List of binary trees of entries */\n  u16 nFresh;                    /* Number of objects on pFresh */\n  u16 rsFlags;                   /* Various flags */\n  int iBatch;                    /* Current insert batch */\n};\n\n/*\n** Allowed values for RowSet.rsFlags\n*/\n#define ROWSET_SORTED  0x01   /* True if RowSet.pEntry is sorted */\n#define ROWSET_NEXT    0x02   /* True if sqlite3RowSetNext() has been called */\n\n/*\n** Turn bulk memory into a RowSet object.  N bytes of memory\n** are available at pSpace.  The db pointer is used as a memory context\n** for any subsequent allocations that need to occur.\n** Return a pointer to the new RowSet object.\n**\n** It must be the case that N is sufficient to make a Rowset.  If not\n** an assertion fault occurs.\n** \n** If N is larger than the minimum, use the surplus as an initial\n** allocation of entries available to be filled.\n*/\nRowSet *sqlite3RowSetInit(sqlite3 *db, void *pSpace, unsigned int N){\n  RowSet *p;\n  assert( N >= ROUND8(sizeof(*p)) );\n  p = pSpace;\n  p->pChunk = 0;\n  p->db = db;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->pFresh = (struct RowSetEntry*)(ROUND8(sizeof(*p)) + (char*)p);\n  p->nFresh = (u16)((N - ROUND8(sizeof(*p)))/sizeof(struct RowSetEntry));\n  p->rsFlags = ROWSET_SORTED;\n  p->iBatch = 0;\n  return p;\n}\n\n/*\n** Deallocate all chunks from a RowSet.  This frees all memory that\n** the RowSet has allocated over its lifetime.  This routine is\n** the destructor for the RowSet.\n*/\nvoid sqlite3RowSetClear(RowSet *p){\n  struct RowSetChunk *pChunk, *pNextChunk;\n  for(pChunk=p->pChunk; pChunk; pChunk = pNextChunk){\n    pNextChunk = pChunk->pNextChunk;\n    sqlite3DbFree(p->db, pChunk);\n  }\n  p->pChunk = 0;\n  p->nFresh = 0;\n  p->pEntry = 0;\n  p->pLast = 0;\n  p->pForest = 0;\n  p->rsFlags = ROWSET_SORTED;\n}\n\n/*\n** Allocate a new RowSetEntry object that is associated with the\n** given RowSet.  Return a pointer to the new and completely uninitialized\n** objected.\n**\n** In an OOM situation, the RowSet.db->mallocFailed flag is set and this\n** routine returns NULL.\n*/\nstatic struct RowSetEntry *rowSetEntryAlloc(RowSet *p){\n  assert( p!=0 );\n  if( p->nFresh==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    /* We could allocate a fresh RowSetEntry each time one is needed, but it\n    ** is more efficient to pull a preallocated entry from the pool */\n    struct RowSetChunk *pNew;\n    pNew = sqlite3DbMallocRawNN(p->db, sizeof(*pNew));\n    if( pNew==0 ){\n      return 0;\n    }\n    pNew->pNextChunk = p->pChunk;\n    p->pChunk = pNew;\n    p->pFresh = pNew->aEntry;\n    p->nFresh = ROWSET_ENTRY_PER_CHUNK;\n  }\n  p->nFresh--;\n  return p->pFresh++;\n}\n\n/*\n** Insert a new value into a RowSet.\n**\n** The mallocFailed flag of the database connection is set if a\n** memory allocation fails.\n*/\nvoid sqlite3RowSetInsert(RowSet *p, i64 rowid){\n  struct RowSetEntry *pEntry;  /* The new entry */\n  struct RowSetEntry *pLast;   /* The last prior entry */\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( p!=0 && (p->rsFlags & ROWSET_NEXT)==0 );\n\n  pEntry = rowSetEntryAlloc(p);\n  if( pEntry==0 ) return;\n  pEntry->v = rowid;\n  pEntry->pRight = 0;\n  pLast = p->pLast;\n  if( pLast ){\n    if( rowid<=pLast->v ){  /*OPTIMIZATION-IF-FALSE*/\n      /* Avoid unnecessary sorts by preserving the ROWSET_SORTED flags\n      ** where possible */\n      p->rsFlags &= ~ROWSET_SORTED;\n    }\n    pLast->pRight = pEntry;\n  }else{\n    p->pEntry = pEntry;\n  }\n  p->pLast = pEntry;\n}\n\n/*\n** Merge two lists of RowSetEntry objects.  Remove duplicates.\n**\n** The input lists are connected via pRight pointers and are \n** assumed to each already be in sorted order.\n*/\nstatic struct RowSetEntry *rowSetEntryMerge(\n  struct RowSetEntry *pA,    /* First sorted list to be merged */\n  struct RowSetEntry *pB     /* Second sorted list to be merged */\n){\n  struct RowSetEntry head;\n  struct RowSetEntry *pTail;\n\n  pTail = &head;\n  assert( pA!=0 && pB!=0 );\n  for(;;){\n    assert( pA->pRight==0 || pA->v<=pA->pRight->v );\n    assert( pB->pRight==0 || pB->v<=pB->pRight->v );\n    if( pA->v<=pB->v ){\n      if( pA->v<pB->v ) pTail = pTail->pRight = pA;\n      pA = pA->pRight;\n      if( pA==0 ){\n        pTail->pRight = pB;\n        break;\n      }\n    }else{\n      pTail = pTail->pRight = pB;\n      pB = pB->pRight;\n      if( pB==0 ){\n        pTail->pRight = pA;\n        break;\n      }\n    }\n  }\n  return head.pRight;\n}\n\n/*\n** Sort all elements on the list of RowSetEntry objects into order of\n** increasing v.\n*/ \nstatic struct RowSetEntry *rowSetEntrySort(struct RowSetEntry *pIn){\n  unsigned int i;\n  struct RowSetEntry *pNext, *aBucket[40];\n\n  memset(aBucket, 0, sizeof(aBucket));\n  while( pIn ){\n    pNext = pIn->pRight;\n    pIn->pRight = 0;\n    for(i=0; aBucket[i]; i++){\n      pIn = rowSetEntryMerge(aBucket[i], pIn);\n      aBucket[i] = 0;\n    }\n    aBucket[i] = pIn;\n    pIn = pNext;\n  }\n  pIn = aBucket[0];\n  for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){\n    if( aBucket[i]==0 ) continue;\n    pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i];\n  }\n  return pIn;\n}\n\n\n/*\n** The input, pIn, is a binary tree (or subtree) of RowSetEntry objects.\n** Convert this tree into a linked list connected by the pRight pointers\n** and return pointers to the first and last elements of the new list.\n*/\nstatic void rowSetTreeToList(\n  struct RowSetEntry *pIn,         /* Root of the input tree */\n  struct RowSetEntry **ppFirst,    /* Write head of the output list here */\n  struct RowSetEntry **ppLast      /* Write tail of the output list here */\n){\n  assert( pIn!=0 );\n  if( pIn->pLeft ){\n    struct RowSetEntry *p;\n    rowSetTreeToList(pIn->pLeft, ppFirst, &p);\n    p->pRight = pIn;\n  }else{\n    *ppFirst = pIn;\n  }\n  if( pIn->pRight ){\n    rowSetTreeToList(pIn->pRight, &pIn->pRight, ppLast);\n  }else{\n    *ppLast = pIn;\n  }\n  assert( (*ppLast)->pRight==0 );\n}\n\n\n/*\n** Convert a sorted list of elements (connected by pRight) into a binary\n** tree with depth of iDepth.  A depth of 1 means the tree contains a single\n** node taken from the head of *ppList.  A depth of 2 means a tree with\n** three nodes.  And so forth.\n**\n** Use as many entries from the input list as required and update the\n** *ppList to point to the unused elements of the list.  If the input\n** list contains too few elements, then construct an incomplete tree\n** and leave *ppList set to NULL.\n**\n** Return a pointer to the root of the constructed binary tree.\n*/\nstatic struct RowSetEntry *rowSetNDeepTree(\n  struct RowSetEntry **ppList,\n  int iDepth\n){\n  struct RowSetEntry *p;         /* Root of the new tree */\n  struct RowSetEntry *pLeft;     /* Left subtree */\n  if( *ppList==0 ){ /*OPTIMIZATION-IF-TRUE*/\n    /* Prevent unnecessary deep recursion when we run out of entries */\n    return 0; \n  }\n  if( iDepth>1 ){   /*OPTIMIZATION-IF-TRUE*/\n    /* This branch causes a *balanced* tree to be generated.  A valid tree\n    ** is still generated without this branch, but the tree is wildly\n    ** unbalanced and inefficient. */\n    pLeft = rowSetNDeepTree(ppList, iDepth-1);\n    p = *ppList;\n    if( p==0 ){     /*OPTIMIZATION-IF-FALSE*/\n      /* It is safe to always return here, but the resulting tree\n      ** would be unbalanced */\n      return pLeft;\n    }\n    p->pLeft = pLeft;\n    *ppList = p->pRight;\n    p->pRight = rowSetNDeepTree(ppList, iDepth-1);\n  }else{\n    p = *ppList;\n    *ppList = p->pRight;\n    p->pLeft = p->pRight = 0;\n  }\n  return p;\n}\n\n/*\n** Convert a sorted list of elements into a binary tree. Make the tree\n** as deep as it needs to be in order to contain the entire list.\n*/\nstatic struct RowSetEntry *rowSetListToTree(struct RowSetEntry *pList){\n  int iDepth;           /* Depth of the tree so far */\n  struct RowSetEntry *p;       /* Current tree root */\n  struct RowSetEntry *pLeft;   /* Left subtree */\n\n  assert( pList!=0 );\n  p = pList;\n  pList = p->pRight;\n  p->pLeft = p->pRight = 0;\n  for(iDepth=1; pList; iDepth++){\n    pLeft = p;\n    p = pList;\n    pList = p->pRight;\n    p->pLeft = pLeft;\n    p->pRight = rowSetNDeepTree(&pList, iDepth);\n  }\n  return p;\n}\n\n/*\n** Extract the smallest element from the RowSet.\n** Write the element into *pRowid.  Return 1 on success.  Return\n** 0 if the RowSet is already empty.\n**\n** After this routine has been called, the sqlite3RowSetInsert()\n** routine may not be called again.\n**\n** This routine may not be called after sqlite3RowSetTest() has\n** been used.  Older versions of RowSet allowed that, but as the\n** capability was not used by the code generator, it was removed\n** for code economy.\n*/\nint sqlite3RowSetNext(RowSet *p, i64 *pRowid){\n  assert( p!=0 );\n  assert( p->pForest==0 );  /* Cannot be used with sqlite3RowSetText() */\n\n  /* Merge the forest into a single sorted list on first call */\n  if( (p->rsFlags & ROWSET_NEXT)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n    if( (p->rsFlags & ROWSET_SORTED)==0 ){  /*OPTIMIZATION-IF-FALSE*/\n      p->pEntry = rowSetEntrySort(p->pEntry);\n    }\n    p->rsFlags |= ROWSET_SORTED|ROWSET_NEXT;\n  }\n\n  /* Return the next entry on the list */\n  if( p->pEntry ){\n    *pRowid = p->pEntry->v;\n    p->pEntry = p->pEntry->pRight;\n    if( p->pEntry==0 ){ /*OPTIMIZATION-IF-TRUE*/\n      /* Free memory immediately, rather than waiting on sqlite3_finalize() */\n      sqlite3RowSetClear(p);\n    }\n    return 1;\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Check to see if element iRowid was inserted into the rowset as\n** part of any insert batch prior to iBatch.  Return 1 or 0.\n**\n** If this is the first test of a new batch and if there exist entries\n** on pRowSet->pEntry, then sort those entries into the forest at\n** pRowSet->pForest so that they can be tested.\n*/\nint sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 iRowid){\n  struct RowSetEntry *p, *pTree;\n\n  /* This routine is never called after sqlite3RowSetNext() */\n  assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );\n\n  /* Sort entries into the forest on the first test of a new batch.\n  ** To save unnecessary work, only do this when the batch number changes.\n  */\n  if( iBatch!=pRowSet->iBatch ){  /*OPTIMIZATION-IF-FALSE*/\n    p = pRowSet->pEntry;\n    if( p ){\n      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;\n      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n        /* Only sort the current set of entiries if they need it */\n        p = rowSetEntrySort(p);\n      }\n      for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n        ppPrevTree = &pTree->pRight;\n        if( pTree->pLeft==0 ){\n          pTree->pLeft = rowSetListToTree(p);\n          break;\n        }else{\n          struct RowSetEntry *pAux, *pTail;\n          rowSetTreeToList(pTree->pLeft, &pAux, &pTail);\n          pTree->pLeft = 0;\n          p = rowSetEntryMerge(pAux, p);\n        }\n      }\n      if( pTree==0 ){\n        *ppPrevTree = pTree = rowSetEntryAlloc(pRowSet);\n        if( pTree ){\n          pTree->v = 0;\n          pTree->pRight = 0;\n          pTree->pLeft = rowSetListToTree(p);\n        }\n      }\n      pRowSet->pEntry = 0;\n      pRowSet->pLast = 0;\n      pRowSet->rsFlags |= ROWSET_SORTED;\n    }\n    pRowSet->iBatch = iBatch;\n  }\n\n  /* Test to see if the iRowid value appears anywhere in the forest.\n  ** Return 1 if it does and 0 if not.\n  */\n  for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){\n    p = pTree->pLeft;\n    while( p ){\n      if( p->v<iRowid ){\n        p = p->pRight;\n      }else if( p->v>iRowid ){\n        p = p->pLeft;\n      }else{\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/select.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle SELECT statements in SQLite.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Trace output macros\n*/\n#if SELECTTRACE_ENABLED\n/***/ int sqlite3SelectTrace = 0;\n# define SELECTTRACE(K,P,S,X)  \\\n  if(sqlite3SelectTrace&(K))   \\\n    sqlite3DebugPrintf(\"%*s%s.%p: \",(P)->nSelectIndent*2-2,\"\",\\\n        (S)->zSelName,(S)),\\\n    sqlite3DebugPrintf X\n#else\n# define SELECTTRACE(K,P,S,X)\n#endif\n\n\n/*\n** An instance of the following object is used to record information about\n** how to process the DISTINCT keyword, to simplify passing that information\n** into the selectInnerLoop() routine.\n*/\ntypedef struct DistinctCtx DistinctCtx;\nstruct DistinctCtx {\n  u8 isTnct;      /* True if the DISTINCT keyword is present */\n  u8 eTnctType;   /* One of the WHERE_DISTINCT_* operators */\n  int tabTnct;    /* Ephemeral table used for DISTINCT processing */\n  int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */\n};\n\n/*\n** An instance of the following object is used to record information about\n** the ORDER BY (or GROUP BY) clause of query is being coded.\n*/\ntypedef struct SortCtx SortCtx;\nstruct SortCtx {\n  ExprList *pOrderBy;   /* The ORDER BY (or GROUP BY clause) */\n  int nOBSat;           /* Number of ORDER BY terms satisfied by indices */\n  int iECursor;         /* Cursor number for the sorter */\n  int regReturn;        /* Register holding block-output return address */\n  int labelBkOut;       /* Start label for the block-output subroutine */\n  int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */\n  int labelDone;        /* Jump here when done, ex: LIMIT reached */\n  u8 sortFlags;         /* Zero or more SORTFLAG_* bits */\n  u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */\n};\n#define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */\n\n/*\n** Delete all the content of a Select structure.  Deallocate the structure\n** itself only if bFree is true.\n*/\nstatic void clearSelect(sqlite3 *db, Select *p, int bFree){\n  while( p ){\n    Select *pPrior = p->pPrior;\n    sqlite3ExprListDelete(db, p->pEList);\n    sqlite3SrcListDelete(db, p->pSrc);\n    sqlite3ExprDelete(db, p->pWhere);\n    sqlite3ExprListDelete(db, p->pGroupBy);\n    sqlite3ExprDelete(db, p->pHaving);\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    sqlite3ExprDelete(db, p->pLimit);\n    sqlite3ExprDelete(db, p->pOffset);\n    if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith);\n    if( bFree ) sqlite3DbFreeNN(db, p);\n    p = pPrior;\n    bFree = 1;\n  }\n}\n\n/*\n** Initialize a SelectDest structure.\n*/\nvoid sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){\n  pDest->eDest = (u8)eDest;\n  pDest->iSDParm = iParm;\n  pDest->zAffSdst = 0;\n  pDest->iSdst = 0;\n  pDest->nSdst = 0;\n}\n\n\n/*\n** Allocate a new Select structure and return a pointer to that\n** structure.\n*/\nSelect *sqlite3SelectNew(\n  Parse *pParse,        /* Parsing context */\n  ExprList *pEList,     /* which columns to include in the result */\n  SrcList *pSrc,        /* the FROM clause -- which tables to scan */\n  Expr *pWhere,         /* the WHERE clause */\n  ExprList *pGroupBy,   /* the GROUP BY clause */\n  Expr *pHaving,        /* the HAVING clause */\n  ExprList *pOrderBy,   /* the ORDER BY clause */\n  u32 selFlags,         /* Flag parameters, such as SF_Distinct */\n  Expr *pLimit,         /* LIMIT value.  NULL means not used */\n  Expr *pOffset         /* OFFSET value.  NULL means no offset */\n){\n  Select *pNew;\n  Select standin;\n  pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) );\n  if( pNew==0 ){\n    assert( pParse->db->mallocFailed );\n    pNew = &standin;\n  }\n  if( pEList==0 ){\n    pEList = sqlite3ExprListAppend(pParse, 0,\n                                   sqlite3Expr(pParse->db,TK_ASTERISK,0));\n  }\n  pNew->pEList = pEList;\n  pNew->op = TK_SELECT;\n  pNew->selFlags = selFlags;\n  pNew->iLimit = 0;\n  pNew->iOffset = 0;\n#if SELECTTRACE_ENABLED\n  pNew->zSelName[0] = 0;\n#endif\n  pNew->addrOpenEphm[0] = -1;\n  pNew->addrOpenEphm[1] = -1;\n  pNew->nSelectRow = 0;\n  if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc));\n  pNew->pSrc = pSrc;\n  pNew->pWhere = pWhere;\n  pNew->pGroupBy = pGroupBy;\n  pNew->pHaving = pHaving;\n  pNew->pOrderBy = pOrderBy;\n  pNew->pPrior = 0;\n  pNew->pNext = 0;\n  pNew->pLimit = pLimit;\n  pNew->pOffset = pOffset;\n  pNew->pWith = 0;\n  assert( pOffset==0 || pLimit!=0 || pParse->nErr>0\n                     || pParse->db->mallocFailed!=0 );\n  if( pParse->db->mallocFailed ) {\n    clearSelect(pParse->db, pNew, pNew!=&standin);\n    pNew = 0;\n  }else{\n    assert( pNew->pSrc!=0 || pParse->nErr>0 );\n  }\n  assert( pNew!=&standin );\n  return pNew;\n}\n\n#if SELECTTRACE_ENABLED\n/*\n** Set the name of a Select object\n*/\nvoid sqlite3SelectSetName(Select *p, const char *zName){\n  if( p && zName ){\n    sqlite3_snprintf(sizeof(p->zSelName), p->zSelName, \"%s\", zName);\n  }\n}\n#endif\n\n\n/*\n** Delete the given Select structure and all of its substructures.\n*/\nvoid sqlite3SelectDelete(sqlite3 *db, Select *p){\n  if( OK_IF_ALWAYS_TRUE(p) ) clearSelect(db, p, 1);\n}\n\n/*\n** Return a pointer to the right-most SELECT statement in a compound.\n*/\nstatic Select *findRightmost(Select *p){\n  while( p->pNext ) p = p->pNext;\n  return p;\n}\n\n/*\n** Given 1 to 3 identifiers preceding the JOIN keyword, determine the\n** type of join.  Return an integer constant that expresses that type\n** in terms of the following bit values:\n**\n**     JT_INNER\n**     JT_CROSS\n**     JT_OUTER\n**     JT_NATURAL\n**     JT_LEFT\n**     JT_RIGHT\n**\n** A full outer join is the combination of JT_LEFT and JT_RIGHT.\n**\n** If an illegal or unsupported join type is seen, then still return\n** a join type, but put an error in the pParse structure.\n*/\nint sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){\n  int jointype = 0;\n  Token *apAll[3];\n  Token *p;\n                             /*   0123456789 123456789 123456789 123 */\n  static const char zKeyText[] = \"naturaleftouterightfullinnercross\";\n  static const struct {\n    u8 i;        /* Beginning of keyword text in zKeyText[] */\n    u8 nChar;    /* Length of the keyword in characters */\n    u8 code;     /* Join type mask */\n  } aKeyword[] = {\n    /* natural */ { 0,  7, JT_NATURAL                },\n    /* left    */ { 6,  4, JT_LEFT|JT_OUTER          },\n    /* outer   */ { 10, 5, JT_OUTER                  },\n    /* right   */ { 14, 5, JT_RIGHT|JT_OUTER         },\n    /* full    */ { 19, 4, JT_LEFT|JT_RIGHT|JT_OUTER },\n    /* inner   */ { 23, 5, JT_INNER                  },\n    /* cross   */ { 28, 5, JT_INNER|JT_CROSS         },\n  };\n  int i, j;\n  apAll[0] = pA;\n  apAll[1] = pB;\n  apAll[2] = pC;\n  for(i=0; i<3 && apAll[i]; i++){\n    p = apAll[i];\n    for(j=0; j<ArraySize(aKeyword); j++){\n      if( p->n==aKeyword[j].nChar \n          && sqlite3StrNICmp((char*)p->z, &zKeyText[aKeyword[j].i], p->n)==0 ){\n        jointype |= aKeyword[j].code;\n        break;\n      }\n    }\n    testcase( j==0 || j==1 || j==2 || j==3 || j==4 || j==5 || j==6 );\n    if( j>=ArraySize(aKeyword) ){\n      jointype |= JT_ERROR;\n      break;\n    }\n  }\n  if(\n     (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||\n     (jointype & JT_ERROR)!=0\n  ){\n    const char *zSp = \" \";\n    assert( pB!=0 );\n    if( pC==0 ){ zSp++; }\n    sqlite3ErrorMsg(pParse, \"unknown or unsupported join type: \"\n       \"%T %T%s%T\", pA, pB, zSp, pC);\n    jointype = JT_INNER;\n  }else if( (jointype & JT_OUTER)!=0 \n         && (jointype & (JT_LEFT|JT_RIGHT))!=JT_LEFT ){\n    sqlite3ErrorMsg(pParse, \n      \"RIGHT and FULL OUTER JOINs are not currently supported\");\n    jointype = JT_INNER;\n  }\n  return jointype;\n}\n\n/*\n** Return the index of a column in a table.  Return -1 if the column\n** is not contained in the table.\n*/\nstatic int columnIndex(Table *pTab, const char *zCol){\n  int i;\n  for(i=0; i<pTab->nCol; i++){\n    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;\n  }\n  return -1;\n}\n\n/*\n** Search the first N tables in pSrc, from left to right, looking for a\n** table that has a column named zCol.  \n**\n** When found, set *piTab and *piCol to the table index and column index\n** of the matching column and return TRUE.\n**\n** If not found, return FALSE.\n*/\nstatic int tableAndColumnIndex(\n  SrcList *pSrc,       /* Array of tables to search */\n  int N,               /* Number of tables in pSrc->a[] to search */\n  const char *zCol,    /* Name of the column we are looking for */\n  int *piTab,          /* Write index of pSrc->a[] here */\n  int *piCol           /* Write index of pSrc->a[*piTab].pTab->aCol[] here */\n){\n  int i;               /* For looping over tables in pSrc */\n  int iCol;            /* Index of column matching zCol */\n\n  assert( (piTab==0)==(piCol==0) );  /* Both or neither are NULL */\n  for(i=0; i<N; i++){\n    iCol = columnIndex(pSrc->a[i].pTab, zCol);\n    if( iCol>=0 ){\n      if( piTab ){\n        *piTab = i;\n        *piCol = iCol;\n      }\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** This function is used to add terms implied by JOIN syntax to the\n** WHERE clause expression of a SELECT statement. The new term, which\n** is ANDed with the existing WHERE clause, is of the form:\n**\n**    (tab1.col1 = tab2.col2)\n**\n** where tab1 is the iSrc'th table in SrcList pSrc and tab2 is the \n** (iSrc+1)'th. Column col1 is column iColLeft of tab1, and col2 is\n** column iColRight of tab2.\n*/\nstatic void addWhereTerm(\n  Parse *pParse,                  /* Parsing context */\n  SrcList *pSrc,                  /* List of tables in FROM clause */\n  int iLeft,                      /* Index of first table to join in pSrc */\n  int iColLeft,                   /* Index of column in first table */\n  int iRight,                     /* Index of second table in pSrc */\n  int iColRight,                  /* Index of column in second table */\n  int isOuterJoin,                /* True if this is an OUTER join */\n  Expr **ppWhere                  /* IN/OUT: The WHERE clause to add to */\n){\n  sqlite3 *db = pParse->db;\n  Expr *pE1;\n  Expr *pE2;\n  Expr *pEq;\n\n  assert( iLeft<iRight );\n  assert( pSrc->nSrc>iRight );\n  assert( pSrc->a[iLeft].pTab );\n  assert( pSrc->a[iRight].pTab );\n\n  pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);\n  pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);\n\n  pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2);\n  if( pEq && isOuterJoin ){\n    ExprSetProperty(pEq, EP_FromJoin);\n    assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(pEq, EP_NoReduce);\n    pEq->iRightJoinTable = (i16)pE2->iTable;\n  }\n  *ppWhere = sqlite3ExprAnd(db, *ppWhere, pEq);\n}\n\n/*\n** Set the EP_FromJoin property on all terms of the given expression.\n** And set the Expr.iRightJoinTable to iTable for every term in the\n** expression.\n**\n** The EP_FromJoin property is used on terms of an expression to tell\n** the LEFT OUTER JOIN processing logic that this term is part of the\n** join restriction specified in the ON or USING clause and not a part\n** of the more general WHERE clause.  These terms are moved over to the\n** WHERE clause during join processing but we need to remember that they\n** originated in the ON or USING clause.\n**\n** The Expr.iRightJoinTable tells the WHERE clause processing that the\n** expression depends on table iRightJoinTable even if that table is not\n** explicitly mentioned in the expression.  That information is needed\n** for cases like this:\n**\n**    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5\n**\n** The where clause needs to defer the handling of the t1.x=5\n** term until after the t2 loop of the join.  In that way, a\n** NULL t2 row will be inserted whenever t1.x!=5.  If we do not\n** defer the handling of t1.x=5, it will be processed immediately\n** after the t1 loop and rows with t1.x!=5 will never appear in\n** the output, which is incorrect.\n*/\nstatic void setJoinExpr(Expr *p, int iTable){\n  while( p ){\n    ExprSetProperty(p, EP_FromJoin);\n    assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );\n    ExprSetVVAProperty(p, EP_NoReduce);\n    p->iRightJoinTable = (i16)iTable;\n    if( p->op==TK_FUNCTION && p->x.pList ){\n      int i;\n      for(i=0; i<p->x.pList->nExpr; i++){\n        setJoinExpr(p->x.pList->a[i].pExpr, iTable);\n      }\n    }\n    setJoinExpr(p->pLeft, iTable);\n    p = p->pRight;\n  } \n}\n\n/*\n** This routine processes the join information for a SELECT statement.\n** ON and USING clauses are converted into extra terms of the WHERE clause.\n** NATURAL joins also create extra WHERE clause terms.\n**\n** The terms of a FROM clause are contained in the Select.pSrc structure.\n** The left most table is the first entry in Select.pSrc.  The right-most\n** table is the last entry.  The join operator is held in the entry to\n** the left.  Thus entry 0 contains the join operator for the join between\n** entries 0 and 1.  Any ON or USING clauses associated with the join are\n** also attached to the left entry.\n**\n** This routine returns the number of errors encountered.\n*/\nstatic int sqliteProcessJoin(Parse *pParse, Select *p){\n  SrcList *pSrc;                  /* All tables in the FROM clause */\n  int i, j;                       /* Loop counters */\n  struct SrcList_item *pLeft;     /* Left table being joined */\n  struct SrcList_item *pRight;    /* Right table being joined */\n\n  pSrc = p->pSrc;\n  pLeft = &pSrc->a[0];\n  pRight = &pLeft[1];\n  for(i=0; i<pSrc->nSrc-1; i++, pRight++, pLeft++){\n    Table *pRightTab = pRight->pTab;\n    int isOuter;\n\n    if( NEVER(pLeft->pTab==0 || pRightTab==0) ) continue;\n    isOuter = (pRight->fg.jointype & JT_OUTER)!=0;\n\n    /* When the NATURAL keyword is present, add WHERE clause terms for\n    ** every column that the two tables have in common.\n    */\n    if( pRight->fg.jointype & JT_NATURAL ){\n      if( pRight->pOn || pRight->pUsing ){\n        sqlite3ErrorMsg(pParse, \"a NATURAL join may not have \"\n           \"an ON or USING clause\", 0);\n        return 1;\n      }\n      for(j=0; j<pRightTab->nCol; j++){\n        char *zName;   /* Name of column in the right table */\n        int iLeft;     /* Matching left table */\n        int iLeftCol;  /* Matching column in the left table */\n\n        zName = pRightTab->aCol[j].zName;\n        if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){\n          addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,\n                       isOuter, &p->pWhere);\n        }\n      }\n    }\n\n    /* Disallow both ON and USING clauses in the same join\n    */\n    if( pRight->pOn && pRight->pUsing ){\n      sqlite3ErrorMsg(pParse, \"cannot have both ON and USING \"\n        \"clauses in the same join\");\n      return 1;\n    }\n\n    /* Add the ON clause to the end of the WHERE clause, connected by\n    ** an AND operator.\n    */\n    if( pRight->pOn ){\n      if( isOuter ) setJoinExpr(pRight->pOn, pRight->iCursor);\n      p->pWhere = sqlite3ExprAnd(pParse->db, p->pWhere, pRight->pOn);\n      pRight->pOn = 0;\n    }\n\n    /* Create extra terms on the WHERE clause for each column named\n    ** in the USING clause.  Example: If the two tables to be joined are \n    ** A and B and the USING clause names X, Y, and Z, then add this\n    ** to the WHERE clause:    A.X=B.X AND A.Y=B.Y AND A.Z=B.Z\n    ** Report an error if any column mentioned in the USING clause is\n    ** not contained in both tables to be joined.\n    */\n    if( pRight->pUsing ){\n      IdList *pList = pRight->pUsing;\n      for(j=0; j<pList->nId; j++){\n        char *zName;     /* Name of the term in the USING clause */\n        int iLeft;       /* Table on the left with matching column name */\n        int iLeftCol;    /* Column number of matching column on the left */\n        int iRightCol;   /* Column number of matching column on the right */\n\n        zName = pList->a[j].zName;\n        iRightCol = columnIndex(pRightTab, zName);\n        if( iRightCol<0\n         || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)\n        ){\n          sqlite3ErrorMsg(pParse, \"cannot join using column %s - column \"\n            \"not present in both tables\", zName);\n          return 1;\n        }\n        addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,\n                     isOuter, &p->pWhere);\n      }\n    }\n  }\n  return 0;\n}\n\n/* Forward reference */\nstatic KeyInfo *keyInfoFromExprList(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pList,     /* Form the KeyInfo object from this ExprList */\n  int iStart,          /* Begin with this column of pList */\n  int nExtra           /* Add this many extra columns to the end */\n);\n\n/*\n** Generate code that will push the record in registers regData\n** through regData+nData-1 onto the sorter.\n*/\nstatic void pushOntoSorter(\n  Parse *pParse,         /* Parser context */\n  SortCtx *pSort,        /* Information about the ORDER BY clause */\n  Select *pSelect,       /* The whole SELECT statement */\n  int regData,           /* First register holding data to be sorted */\n  int regOrigData,       /* First register holding data before packing */\n  int nData,             /* Number of elements in the data array */\n  int nPrefixReg         /* No. of reg prior to regData available for use */\n){\n  Vdbe *v = pParse->pVdbe;                         /* Stmt under construction */\n  int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0);\n  int nExpr = pSort->pOrderBy->nExpr;              /* No. of ORDER BY terms */\n  int nBase = nExpr + bSeq + nData;                /* Fields in sorter record */\n  int regBase;                                     /* Regs for sorter record */\n  int regRecord = ++pParse->nMem;                  /* Assembled sorter record */\n  int nOBSat = pSort->nOBSat;                      /* ORDER BY terms to skip */\n  int op;                            /* Opcode to add sorter record to sorter */\n  int iLimit;                        /* LIMIT counter */\n\n  assert( bSeq==0 || bSeq==1 );\n  assert( nData==1 || regData==regOrigData || regOrigData==0 );\n  if( nPrefixReg ){\n    assert( nPrefixReg==nExpr+bSeq );\n    regBase = regData - nExpr - bSeq;\n  }else{\n    regBase = pParse->nMem + 1;\n    pParse->nMem += nBase;\n  }\n  assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );\n  iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;\n  pSort->labelDone = sqlite3VdbeMakeLabel(v);\n  sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,\n                          SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));\n  if( bSeq ){\n    sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr);\n  }\n  if( nPrefixReg==0 && nData>0 ){\n    sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData);\n  }\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase+nOBSat, nBase-nOBSat, regRecord);\n  if( nOBSat>0 ){\n    int regPrevKey;   /* The first nOBSat columns of the previous row */\n    int addrFirst;    /* Address of the OP_IfNot opcode */\n    int addrJmp;      /* Address of the OP_Jump opcode */\n    VdbeOp *pOp;      /* Opcode that opens the sorter */\n    int nKey;         /* Number of sorting key columns, including OP_Sequence */\n    KeyInfo *pKI;     /* Original KeyInfo on the sorter table */\n\n    regPrevKey = pParse->nMem+1;\n    pParse->nMem += pSort->nOBSat;\n    nKey = nExpr - pSort->nOBSat + bSeq;\n    if( bSeq ){\n      addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); \n    }else{\n      addrFirst = sqlite3VdbeAddOp1(v, OP_SequenceTest, pSort->iECursor);\n    }\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);\n    pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);\n    if( pParse->db->mallocFailed ) return;\n    pOp->p2 = nKey + nData;\n    pKI = pOp->p4.pKeyInfo;\n    memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */\n    sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);\n    testcase( pKI->nAllField > pKI->nKeyField+2 );\n    pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,\n                                           pKI->nAllField-pKI->nKeyField-1);\n    addrJmp = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);\n    pSort->labelBkOut = sqlite3VdbeMakeLabel(v);\n    pSort->regReturn = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);\n    if( iLimit ){\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, pSort->labelDone);\n      VdbeCoverage(v);\n    }\n    sqlite3VdbeJumpHere(v, addrFirst);\n    sqlite3ExprCodeMove(pParse, regBase, regPrevKey, pSort->nOBSat);\n    sqlite3VdbeJumpHere(v, addrJmp);\n  }\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    op = OP_SorterInsert;\n  }else{\n    op = OP_IdxInsert;\n  }\n  sqlite3VdbeAddOp4Int(v, op, pSort->iECursor, regRecord,\n                       regBase+nOBSat, nBase-nOBSat);\n  if( iLimit ){\n    int addr;\n    int r1 = 0;\n    /* Fill the sorter until it contains LIMIT+OFFSET entries.  (The iLimit\n    ** register is initialized with value of LIMIT+OFFSET.)  After the sorter\n    ** fills up, delete the least entry in the sorter after each insert.\n    ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */\n    addr = sqlite3VdbeAddOp1(v, OP_IfNotZero, iLimit); VdbeCoverage(v);\n    sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);\n    if( pSort->bOrderedInnerLoop ){\n      r1 = ++pParse->nMem;\n      sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1);\n      VdbeComment((v, \"seq\"));\n    }\n    sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);\n    if( pSort->bOrderedInnerLoop ){\n      /* If the inner loop is driven by an index such that values from\n      ** the same iteration of the inner loop are in sorted order, then\n      ** immediately jump to the next iteration of an inner loop if the\n      ** entry from the current iteration does not fit into the top\n      ** LIMIT+OFFSET entries of the sorter. */\n      int iBrk = sqlite3VdbeCurrentAddr(v) + 2;\n      sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1);\n      sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n      VdbeCoverage(v);\n    }\n    sqlite3VdbeJumpHere(v, addr);\n  }\n}\n\n/*\n** Add code to implement the OFFSET\n*/\nstatic void codeOffset(\n  Vdbe *v,          /* Generate code into this VM */\n  int iOffset,      /* Register holding the offset counter */\n  int iContinue     /* Jump here to skip the current record */\n){\n  if( iOffset>0 ){\n    sqlite3VdbeAddOp3(v, OP_IfPos, iOffset, iContinue, 1); VdbeCoverage(v);\n    VdbeComment((v, \"OFFSET\"));\n  }\n}\n\n/*\n** Add code that will check to make sure the N registers starting at iMem\n** form a distinct entry.  iTab is a sorting index that holds previously\n** seen combinations of the N values.  A new entry is made in iTab\n** if the current N values are new.\n**\n** A jump to addrRepeat is made and the N+1 values are popped from the\n** stack if the top N elements are not distinct.\n*/\nstatic void codeDistinct(\n  Parse *pParse,     /* Parsing and code generating context */\n  int iTab,          /* A sorting index used to test for distinctness */\n  int addrRepeat,    /* Jump to here if not distinct */\n  int N,             /* Number of elements */\n  int iMem           /* First element */\n){\n  Vdbe *v;\n  int r1;\n\n  v = pParse->pVdbe;\n  r1 = sqlite3GetTempReg(pParse);\n  sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);\n  sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);\n  sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  sqlite3ReleaseTempReg(pParse, r1);\n}\n\n/*\n** This routine generates the code for the inside of the inner loop\n** of a SELECT.\n**\n** If srcTab is negative, then the p->pEList expressions\n** are evaluated in order to get the data for this row.  If srcTab is\n** zero or more, then data is pulled from srcTab and p->pEList is used only \n** to get the number of columns and the collation sequence for each column.\n*/\nstatic void selectInnerLoop(\n  Parse *pParse,          /* The parser context */\n  Select *p,              /* The complete select statement being coded */\n  int srcTab,             /* Pull data from this table if non-negative */\n  SortCtx *pSort,         /* If not NULL, info on how to process ORDER BY */\n  DistinctCtx *pDistinct, /* If not NULL, info on how to process DISTINCT */\n  SelectDest *pDest,      /* How to dispose of the results */\n  int iContinue,          /* Jump here to continue with next row */\n  int iBreak              /* Jump here to break out of the inner loop */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int hasDistinct;            /* True if the DISTINCT keyword is present */\n  int eDest = pDest->eDest;   /* How to dispose of results */\n  int iParm = pDest->iSDParm; /* First argument to disposal method */\n  int nResultCol;             /* Number of result columns */\n  int nPrefixReg = 0;         /* Number of extra registers before regResult */\n\n  /* Usually, regResult is the first cell in an array of memory cells\n  ** containing the current result row. In this case regOrig is set to the\n  ** same value. However, if the results are being sent to the sorter, the\n  ** values for any expressions that are also part of the sort-key are omitted\n  ** from this array. In this case regOrig is set to zero.  */\n  int regResult;              /* Start of memory holding current results */\n  int regOrig;                /* Start of memory holding full result (or 0) */\n\n  assert( v );\n  assert( p->pEList!=0 );\n  hasDistinct = pDistinct ? pDistinct->eTnctType : WHERE_DISTINCT_NOOP;\n  if( pSort && pSort->pOrderBy==0 ) pSort = 0;\n  if( pSort==0 && !hasDistinct ){\n    assert( iContinue!=0 );\n    codeOffset(v, p->iOffset, iContinue);\n  }\n\n  /* Pull the requested columns.\n  */\n  nResultCol = p->pEList->nExpr;\n\n  if( pDest->iSdst==0 ){\n    if( pSort ){\n      nPrefixReg = pSort->pOrderBy->nExpr;\n      if( !(pSort->sortFlags & SORTFLAG_UseSorter) ) nPrefixReg++;\n      pParse->nMem += nPrefixReg;\n    }\n    pDest->iSdst = pParse->nMem+1;\n    pParse->nMem += nResultCol;\n  }else if( pDest->iSdst+nResultCol > pParse->nMem ){\n    /* This is an error condition that can result, for example, when a SELECT\n    ** on the right-hand side of an INSERT contains more result columns than\n    ** there are columns in the table on the left.  The error will be caught\n    ** and reported later.  But we need to make sure enough memory is allocated\n    ** to avoid other spurious errors in the meantime. */\n    pParse->nMem += nResultCol;\n  }\n  pDest->nSdst = nResultCol;\n  regOrig = regResult = pDest->iSdst;\n  if( srcTab>=0 ){\n    for(i=0; i<nResultCol; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);\n      VdbeComment((v, \"%s\", p->pEList->a[i].zName));\n    }\n  }else if( eDest!=SRT_Exists ){\n    /* If the destination is an EXISTS(...) expression, the actual\n    ** values returned by the SELECT are not required.\n    */\n    u8 ecelFlags;\n    if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){\n      ecelFlags = SQLITE_ECEL_DUP;\n    }else{\n      ecelFlags = 0;\n    }\n    if( pSort && hasDistinct==0 && eDest!=SRT_EphemTab && eDest!=SRT_Table ){\n      /* For each expression in p->pEList that is a copy of an expression in\n      ** the ORDER BY clause (pSort->pOrderBy), set the associated \n      ** iOrderByCol value to one more than the index of the ORDER BY \n      ** expression within the sort-key that pushOntoSorter() will generate.\n      ** This allows the p->pEList field to be omitted from the sorted record,\n      ** saving space and CPU cycles.  */\n      ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);\n      for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){\n        int j;\n        if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){\n          p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;\n        }\n      }\n      regOrig = 0;\n      assert( eDest==SRT_Set || eDest==SRT_Mem \n           || eDest==SRT_Coroutine || eDest==SRT_Output );\n    }\n    nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult,\n                                         0,ecelFlags);\n  }\n\n  /* If the DISTINCT keyword was present on the SELECT statement\n  ** and this row has been seen before, then do not make this row\n  ** part of the result.\n  */\n  if( hasDistinct ){\n    switch( pDistinct->eTnctType ){\n      case WHERE_DISTINCT_ORDERED: {\n        VdbeOp *pOp;            /* No longer required OpenEphemeral instr. */\n        int iJump;              /* Jump destination */\n        int regPrev;            /* Previous row content */\n\n        /* Allocate space for the previous row */\n        regPrev = pParse->nMem+1;\n        pParse->nMem += nResultCol;\n\n        /* Change the OP_OpenEphemeral coded earlier to an OP_Null\n        ** sets the MEM_Cleared bit on the first register of the\n        ** previous value.  This will cause the OP_Ne below to always\n        ** fail on the first iteration of the loop even if the first\n        ** row is all NULLs.\n        */\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        pOp = sqlite3VdbeGetOp(v, pDistinct->addrTnct);\n        pOp->opcode = OP_Null;\n        pOp->p1 = 1;\n        pOp->p2 = regPrev;\n\n        iJump = sqlite3VdbeCurrentAddr(v) + nResultCol;\n        for(i=0; i<nResultCol; i++){\n          CollSeq *pColl = sqlite3ExprCollSeq(pParse, p->pEList->a[i].pExpr);\n          if( i<nResultCol-1 ){\n            sqlite3VdbeAddOp3(v, OP_Ne, regResult+i, iJump, regPrev+i);\n            VdbeCoverage(v);\n          }else{\n            sqlite3VdbeAddOp3(v, OP_Eq, regResult+i, iContinue, regPrev+i);\n            VdbeCoverage(v);\n           }\n          sqlite3VdbeChangeP4(v, -1, (const char *)pColl, P4_COLLSEQ);\n          sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);\n        }\n        assert( sqlite3VdbeCurrentAddr(v)==iJump || pParse->db->mallocFailed );\n        sqlite3VdbeAddOp3(v, OP_Copy, regResult, regPrev, nResultCol-1);\n        break;\n      }\n\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3VdbeChangeToNoop(v, pDistinct->addrTnct);\n        break;\n      }\n\n      default: {\n        assert( pDistinct->eTnctType==WHERE_DISTINCT_UNORDERED );\n        codeDistinct(pParse, pDistinct->tabTnct, iContinue, nResultCol,\n                     regResult);\n        break;\n      }\n    }\n    if( pSort==0 ){\n      codeOffset(v, p->iOffset, iContinue);\n    }\n  }\n\n  switch( eDest ){\n    /* In this mode, write each query result to the key of the temporary\n    ** table iParm.\n    */\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n    case SRT_Union: {\n      int r1;\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* Construct a record from the query result, but instead of\n    ** saving that record, use it as a key to delete elements from\n    ** the temporary table iParm.\n    */\n    case SRT_Except: {\n      sqlite3VdbeAddOp3(v, OP_IdxDelete, iParm, regResult, nResultCol);\n      break;\n    }\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n    /* Store the result as data using a unique key.\n    */\n    case SRT_Fifo:\n    case SRT_DistFifo:\n    case SRT_Table:\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempRange(pParse, nPrefixReg+1);\n      testcase( eDest==SRT_Table );\n      testcase( eDest==SRT_EphemTab );\n      testcase( eDest==SRT_Fifo );\n      testcase( eDest==SRT_DistFifo );\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r1+nPrefixReg);\n#ifndef SQLITE_OMIT_CTE\n      if( eDest==SRT_DistFifo ){\n        /* If the destination is DistFifo, then cursor (iParm+1) is open\n        ** on an ephemeral index. If the current row is already present\n        ** in the index, do not write it to the output. If not, add the\n        ** current row to the index and proceed with writing it to the\n        ** output table as well.  */\n        int addr = sqlite3VdbeCurrentAddr(v) + 4;\n        sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, addr, r1, 0);\n        VdbeCoverage(v);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm+1, r1,regResult,nResultCol);\n        assert( pSort==0 );\n      }\n#endif\n      if( pSort ){\n        pushOntoSorter(pParse, pSort, p, r1+nPrefixReg,regResult,1,nPrefixReg);\n      }else{\n        int r2 = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2);\n        sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2);\n        sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n        sqlite3ReleaseTempReg(pParse, r2);\n      }\n      sqlite3ReleaseTempRange(pParse, r1, nPrefixReg+1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\" construct,\n    ** then there should be a single item on the stack.  Write this\n    ** item into the set table with bogus data.\n    */\n    case SRT_Set: {\n      if( pSort ){\n        /* At first glance you would think we could optimize out the\n        ** ORDER BY in this case since the order of entries in the set\n        ** does not matter.  But there might be a LIMIT clause, in which\n        ** case the order does matter */\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        int r1 = sqlite3GetTempReg(pParse);\n        assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol );\n        sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult, nResultCol, \n            r1, pDest->zAffSdst, nResultCol);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);\n        sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, regResult, nResultCol);\n        sqlite3ReleaseTempReg(pParse, r1);\n      }\n      break;\n    }\n\n    /* If any row exist in the result set, record that fact and abort.\n    */\n    case SRT_Exists: {\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iParm);\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell or array of \n    ** memory cells and break out of the scan loop.\n    */\n    case SRT_Mem: {\n      if( pSort ){\n        assert( nResultCol<=pDest->nSdst );\n        pushOntoSorter(\n            pParse, pSort, p, regResult, regOrig, nResultCol, nPrefixReg);\n      }else{\n        assert( nResultCol==pDest->nSdst );\n        assert( regResult==iParm );\n        /* The LIMIT clause will jump out of the loop for us */\n      }\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    case SRT_Coroutine:       /* Send data to a co-routine */\n    case SRT_Output: {        /* Return the results */\n      testcase( eDest==SRT_Coroutine );\n      testcase( eDest==SRT_Output );\n      if( pSort ){\n        pushOntoSorter(pParse, pSort, p, regResult, regOrig, nResultCol,\n                       nPrefixReg);\n      }else if( eDest==SRT_Coroutine ){\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol);\n        sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol);\n      }\n      break;\n    }\n\n#ifndef SQLITE_OMIT_CTE\n    /* Write the results into a priority queue that is order according to\n    ** pDest->pOrderBy (in pSO).  pDest->iSDParm (in iParm) is the cursor for an\n    ** index with pSO->nExpr+2 columns.  Build a key using pSO for the first\n    ** pSO->nExpr columns, then make sure all keys are unique by adding a\n    ** final OP_Sequence column.  The last column is the record as a blob.\n    */\n    case SRT_DistQueue:\n    case SRT_Queue: {\n      int nKey;\n      int r1, r2, r3;\n      int addrTest = 0;\n      ExprList *pSO;\n      pSO = pDest->pOrderBy;\n      assert( pSO );\n      nKey = pSO->nExpr;\n      r1 = sqlite3GetTempReg(pParse);\n      r2 = sqlite3GetTempRange(pParse, nKey+2);\n      r3 = r2+nKey+1;\n      if( eDest==SRT_DistQueue ){\n        /* If the destination is DistQueue, then cursor (iParm+1) is open\n        ** on a second ephemeral index that holds all values every previously\n        ** added to the queue. */\n        addrTest = sqlite3VdbeAddOp4Int(v, OP_Found, iParm+1, 0, \n                                        regResult, nResultCol);\n        VdbeCoverage(v);\n      }\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, regResult, nResultCol, r3);\n      if( eDest==SRT_DistQueue ){\n        sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r3);\n        sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n      }\n      for(i=0; i<nKey; i++){\n        sqlite3VdbeAddOp2(v, OP_SCopy,\n                          regResult + pSO->a[i].u.x.iOrderByCol - 1,\n                          r2+i);\n      }\n      sqlite3VdbeAddOp2(v, OP_Sequence, iParm, r2+nKey);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, r2, nKey+2, r1);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, r1, r2, nKey+2);\n      if( addrTest ) sqlite3VdbeJumpHere(v, addrTest);\n      sqlite3ReleaseTempReg(pParse, r1);\n      sqlite3ReleaseTempRange(pParse, r2, nKey+2);\n      break;\n    }\n#endif /* SQLITE_OMIT_CTE */\n\n\n\n#if !defined(SQLITE_OMIT_TRIGGER)\n    /* Discard the results.  This is used for SELECT statements inside\n    ** the body of a TRIGGER.  The purpose of such selects is to call\n    ** user-defined functions that have side effects.  We do not care\n    ** about the actual results of the select.\n    */\n    default: {\n      assert( eDest==SRT_Discard );\n      break;\n    }\n#endif\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.  Except, if\n  ** there is a sorter, in which case the sorter has already limited\n  ** the output for us.\n  */\n  if( pSort==0 && p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n}\n\n/*\n** Allocate a KeyInfo object sufficient for an index of N key columns and\n** X extra columns.\n*/\nKeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){\n  int nExtra = (N+X)*(sizeof(CollSeq*)+1) - sizeof(CollSeq*);\n  KeyInfo *p = sqlite3DbMallocRawNN(db, sizeof(KeyInfo) + nExtra);\n  if( p ){\n    p->aSortOrder = (u8*)&p->aColl[N+X];\n    p->nKeyField = (u16)N;\n    p->nAllField = (u16)(N+X);\n    p->enc = ENC(db);\n    p->db = db;\n    p->nRef = 1;\n    memset(&p[1], 0, nExtra);\n  }else{\n    sqlite3OomFault(db);\n  }\n  return p;\n}\n\n/*\n** Deallocate a KeyInfo object\n*/\nvoid sqlite3KeyInfoUnref(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef--;\n    if( p->nRef==0 ) sqlite3DbFreeNN(p->db, p);\n  }\n}\n\n/*\n** Make a new pointer to a KeyInfo object\n*/\nKeyInfo *sqlite3KeyInfoRef(KeyInfo *p){\n  if( p ){\n    assert( p->nRef>0 );\n    p->nRef++;\n  }\n  return p;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Return TRUE if a KeyInfo object can be change.  The KeyInfo object\n** can only be changed if this is just a single reference to the object.\n**\n** This routine is used only inside of assert() statements.\n*/\nint sqlite3KeyInfoIsWriteable(KeyInfo *p){ return p->nRef==1; }\n#endif /* SQLITE_DEBUG */\n\n/*\n** Given an expression list, generate a KeyInfo structure that records\n** the collating sequence for each expression in that expression list.\n**\n** If the ExprList is an ORDER BY or GROUP BY clause then the resulting\n** KeyInfo structure is appropriate for initializing a virtual index to\n** implement that clause.  If the ExprList is the result set of a SELECT\n** then the KeyInfo structure is appropriate for initializing a virtual\n** index to implement a DISTINCT test.\n**\n** Space to hold the KeyInfo structure is obtained from malloc.  The calling\n** function is responsible for seeing that this structure is eventually\n** freed.\n*/\nstatic KeyInfo *keyInfoFromExprList(\n  Parse *pParse,       /* Parsing context */\n  ExprList *pList,     /* Form the KeyInfo object from this ExprList */\n  int iStart,          /* Begin with this column of pList */\n  int nExtra           /* Add this many extra columns to the end */\n){\n  int nExpr;\n  KeyInfo *pInfo;\n  struct ExprList_item *pItem;\n  sqlite3 *db = pParse->db;\n  int i;\n\n  nExpr = pList->nExpr;\n  pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);\n  if( pInfo ){\n    assert( sqlite3KeyInfoIsWriteable(pInfo) );\n    for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){\n      pInfo->aColl[i-iStart] = sqlite3ExprNNCollSeq(pParse, pItem->pExpr);\n      pInfo->aSortOrder[i-iStart] = pItem->sortOrder;\n    }\n  }\n  return pInfo;\n}\n\n/*\n** Name of the connection operator, used for error messages.\n*/\nstatic const char *selectOpName(int id){\n  char *z;\n  switch( id ){\n    case TK_ALL:       z = \"UNION ALL\";   break;\n    case TK_INTERSECT: z = \"INTERSECT\";   break;\n    case TK_EXCEPT:    z = \"EXCEPT\";      break;\n    default:           z = \"UNION\";       break;\n  }\n  return z;\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of the form:\n**\n**   \"USE TEMP B-TREE FOR xxx\"\n**\n** where xxx is one of \"DISTINCT\", \"ORDER BY\" or \"GROUP BY\". Exactly which\n** is determined by the zUsage argument.\n*/\nstatic void explainTempTable(Parse *pParse, const char *zUsage){\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(pParse->db, \"USE TEMP B-TREE FOR %s\", zUsage);\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n\n/*\n** Assign expression b to lvalue a. A second, no-op, version of this macro\n** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code\n** in sqlite3Select() to assign values to structure member variables that\n** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the\n** code with #ifndef directives.\n*/\n# define explainSetInteger(a, b) a = b\n\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainTempTable(y,z)\n# define explainSetInteger(y,z)\n#endif\n\n#if !defined(SQLITE_OMIT_EXPLAIN) && !defined(SQLITE_OMIT_COMPOUND_SELECT)\n/*\n** Unless an \"EXPLAIN QUERY PLAN\" command is being processed, this function\n** is a no-op. Otherwise, it adds a single row of output to the EQP result,\n** where the caption is of one of the two forms:\n**\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 (op)\"\n**   \"COMPOSITE SUBQUERIES iSub1 and iSub2 USING TEMP B-TREE (op)\"\n**\n** where iSub1 and iSub2 are the integers passed as the corresponding\n** function parameters, and op is the text representation of the parameter\n** of the same name. The parameter \"op\" must be one of TK_UNION, TK_EXCEPT,\n** TK_INTERSECT or TK_ALL. The first form is used if argument bUseTmp is \n** false, or the second form if it is true.\n*/\nstatic void explainComposite(\n  Parse *pParse,                  /* Parse context */\n  int op,                         /* One of TK_UNION, TK_EXCEPT etc. */\n  int iSub1,                      /* Subquery id 1 */\n  int iSub2,                      /* Subquery id 2 */\n  int bUseTmp                     /* True if a temp table was used */\n){\n  assert( op==TK_UNION || op==TK_EXCEPT || op==TK_INTERSECT || op==TK_ALL );\n  if( pParse->explain==2 ){\n    Vdbe *v = pParse->pVdbe;\n    char *zMsg = sqlite3MPrintf(\n        pParse->db, \"COMPOUND SUBQUERIES %d AND %d %s(%s)\", iSub1, iSub2,\n        bUseTmp?\"USING TEMP B-TREE \":\"\", selectOpName(op)\n    );\n    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);\n  }\n}\n#else\n/* No-op versions of the explainXXX() functions and macros. */\n# define explainComposite(v,w,x,y,z)\n#endif\n\n/*\n** If the inner loop was generated using a non-null pOrderBy argument,\n** then the results were placed in a sorter.  After the loop is terminated\n** we need to run the sorter and output the results.  The following\n** routine generates the code needed to do that.\n*/\nstatic void generateSortTail(\n  Parse *pParse,    /* Parsing context */\n  Select *p,        /* The SELECT statement */\n  SortCtx *pSort,   /* Information on the ORDER BY clause */\n  int nColumn,      /* Number of columns of data */\n  SelectDest *pDest /* Write the sorted results here */\n){\n  Vdbe *v = pParse->pVdbe;                     /* The prepared statement */\n  int addrBreak = pSort->labelDone;            /* Jump here to exit loop */\n  int addrContinue = sqlite3VdbeMakeLabel(v);  /* Jump here for next cycle */\n  int addr;\n  int addrOnce = 0;\n  int iTab;\n  ExprList *pOrderBy = pSort->pOrderBy;\n  int eDest = pDest->eDest;\n  int iParm = pDest->iSDParm;\n  int regRow;\n  int regRowid;\n  int iCol;\n  int nKey;\n  int iSortTab;                   /* Sorter cursor to read from */\n  int nSortData;                  /* Trailing values to read from sorter */\n  int i;\n  int bSeq;                       /* True if sorter record includes seq. no. */\n  struct ExprList_item *aOutEx = p->pEList->a;\n\n  assert( addrBreak<0 );\n  if( pSort->labelBkOut ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);\n    sqlite3VdbeGoto(v, addrBreak);\n    sqlite3VdbeResolveLabel(v, pSort->labelBkOut);\n  }\n  iTab = pSort->iECursor;\n  if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){\n    regRowid = 0;\n    regRow = pDest->iSdst;\n    nSortData = nColumn;\n  }else{\n    regRowid = sqlite3GetTempReg(pParse);\n    regRow = sqlite3GetTempRange(pParse, nColumn);\n    nSortData = nColumn;\n  }\n  nKey = pOrderBy->nExpr - pSort->nOBSat;\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    int regSortOut = ++pParse->nMem;\n    iSortTab = pParse->nTab++;\n    if( pSort->labelBkOut ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n    }\n    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);\n    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);\n    VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);\n    bSeq = 0;\n  }else{\n    addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);\n    codeOffset(v, p->iOffset, addrContinue);\n    iSortTab = iTab;\n    bSeq = 1;\n  }\n  for(i=0, iCol=nKey+bSeq; i<nSortData; i++){\n    int iRead;\n    if( aOutEx[i].u.x.iOrderByCol ){\n      iRead = aOutEx[i].u.x.iOrderByCol-1;\n    }else{\n      iRead = iCol++;\n    }\n    sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);\n    VdbeComment((v, \"%s\", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));\n  }\n  switch( eDest ){\n    case SRT_Table:\n    case SRT_EphemTab: {\n      sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);\n      sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case SRT_Set: {\n      assert( nColumn==sqlite3Strlen30(pDest->zAffSdst) );\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, nColumn, regRowid,\n                        pDest->zAffSdst, nColumn);\n      sqlite3ExprCacheAffinityChange(pParse, regRow, nColumn);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iParm, regRowid, regRow, nColumn);\n      break;\n    }\n    case SRT_Mem: {\n      /* The LIMIT clause will terminate the loop for us */\n      break;\n    }\n#endif\n    default: {\n      assert( eDest==SRT_Output || eDest==SRT_Coroutine ); \n      testcase( eDest==SRT_Output );\n      testcase( eDest==SRT_Coroutine );\n      if( eDest==SRT_Output ){\n        sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn);\n        sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn);\n      }else{\n        sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      }\n      break;\n    }\n  }\n  if( regRowid ){\n    if( eDest==SRT_Set ){\n      sqlite3ReleaseTempRange(pParse, regRow, nColumn);\n    }else{\n      sqlite3ReleaseTempReg(pParse, regRow);\n    }\n    sqlite3ReleaseTempReg(pParse, regRowid);\n  }\n  /* The bottom of the loop\n  */\n  sqlite3VdbeResolveLabel(v, addrContinue);\n  if( pSort->sortFlags & SORTFLAG_UseSorter ){\n    sqlite3VdbeAddOp2(v, OP_SorterNext, iTab, addr); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, iTab, addr); VdbeCoverage(v);\n  }\n  if( pSort->regReturn ) sqlite3VdbeAddOp1(v, OP_Return, pSort->regReturn);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n}\n\n/*\n** Return a pointer to a string containing the 'declaration type' of the\n** expression pExpr. The string may be treated as static by the caller.\n**\n** Also try to estimate the size of the returned value and return that\n** result in *pEstWidth.\n**\n** The declaration type is the exact datatype definition extracted from the\n** original CREATE TABLE statement if the expression is a column. The\n** declaration type for a ROWID field is INTEGER. Exactly when an expression\n** is considered a column can be complex in the presence of subqueries. The\n** result-set expression in all of the following SELECT statements is \n** considered a column by this function.\n**\n**   SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl;\n**   SELECT (SELECT col FROM tbl);\n**   SELECT abc FROM (SELECT col AS abc FROM tbl);\n** \n** The declaration type for any expression other than a column is NULL.\n**\n** This routine has either 3 or 6 parameters depending on whether or not\n** the SQLITE_ENABLE_COLUMN_METADATA compile-time option is used.\n*/\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B,C,D,E)\n#else /* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */\n# define columnType(A,B,C,D,E) columnTypeImpl(A,B)\n#endif\nstatic const char *columnTypeImpl(\n  NameContext *pNC, \n#ifndef SQLITE_ENABLE_COLUMN_METADATA\n  Expr *pExpr\n#else\n  Expr *pExpr,\n  const char **pzOrigDb,\n  const char **pzOrigTab,\n  const char **pzOrigCol\n#endif\n){\n  char const *zType = 0;\n  int j;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n  char const *zOrigDb = 0;\n  char const *zOrigTab = 0;\n  char const *zOrigCol = 0;\n#endif\n\n  assert( pExpr!=0 );\n  assert( pNC->pSrcList!=0 );\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN:\n    case TK_COLUMN: {\n      /* The expression is a column. Locate the table the column is being\n      ** extracted from in NameContext.pSrcList. This table may be real\n      ** database table or a subquery.\n      */\n      Table *pTab = 0;            /* Table structure column is extracted from */\n      Select *pS = 0;             /* Select the column is extracted from */\n      int iCol = pExpr->iColumn;  /* Index of column in pTab */\n      testcase( pExpr->op==TK_AGG_COLUMN );\n      testcase( pExpr->op==TK_COLUMN );\n      while( pNC && !pTab ){\n        SrcList *pTabList = pNC->pSrcList;\n        for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);\n        if( j<pTabList->nSrc ){\n          pTab = pTabList->a[j].pTab;\n          pS = pTabList->a[j].pSelect;\n        }else{\n          pNC = pNC->pNext;\n        }\n      }\n\n      if( pTab==0 ){\n        /* At one time, code such as \"SELECT new.x\" within a trigger would\n        ** cause this condition to run.  Since then, we have restructured how\n        ** trigger code is generated and so this condition is no longer \n        ** possible. However, it can still be true for statements like\n        ** the following:\n        **\n        **   CREATE TABLE t1(col INTEGER);\n        **   SELECT (SELECT t1.col) FROM FROM t1;\n        **\n        ** when columnType() is called on the expression \"t1.col\" in the \n        ** sub-select. In this case, set the column type to NULL, even\n        ** though it should really be \"INTEGER\".\n        **\n        ** This is not a problem, as the column type of \"t1.col\" is never\n        ** used. When columnType() is called on the expression \n        ** \"(SELECT t1.col)\", the correct type is returned (see the TK_SELECT\n        ** branch below.  */\n        break;\n      }\n\n      assert( pTab && pExpr->pTab==pTab );\n      if( pS ){\n        /* The \"table\" is actually a sub-select or a view in the FROM clause\n        ** of the SELECT statement. Return the declaration type and origin\n        ** data for the result-set column of the sub-select.\n        */\n        if( iCol>=0 && iCol<pS->pEList->nExpr ){\n          /* If iCol is less than zero, then the expression requests the\n          ** rowid of the sub-select or view. This expression is legal (see \n          ** test case misc2.2.2) - it always evaluates to NULL.\n          */\n          NameContext sNC;\n          Expr *p = pS->pEList->a[iCol].pExpr;\n          sNC.pSrcList = pS->pSrc;\n          sNC.pNext = pNC;\n          sNC.pParse = pNC->pParse;\n          zType = columnType(&sNC, p,&zOrigDb,&zOrigTab,&zOrigCol); \n        }\n      }else{\n        /* A real table or a CTE table */\n        assert( !pS );\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n        if( iCol<0 ) iCol = pTab->iPKey;\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n          zOrigCol = \"rowid\";\n        }else{\n          zOrigCol = pTab->aCol[iCol].zName;\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n        zOrigTab = pTab->zName;\n        if( pNC->pParse && pTab->pSchema ){\n          int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema);\n          zOrigDb = pNC->pParse->db->aDb[iDb].zDbSName;\n        }\n#else\n        assert( iCol==XN_ROWID || (iCol>=0 && iCol<pTab->nCol) );\n        if( iCol<0 ){\n          zType = \"INTEGER\";\n        }else{\n          zType = sqlite3ColumnType(&pTab->aCol[iCol],0);\n        }\n#endif\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_SELECT: {\n      /* The expression is a sub-select. Return the declaration type and\n      ** origin info for the single column in the result set of the SELECT\n      ** statement.\n      */\n      NameContext sNC;\n      Select *pS = pExpr->x.pSelect;\n      Expr *p = pS->pEList->a[0].pExpr;\n      assert( ExprHasProperty(pExpr, EP_xIsSelect) );\n      sNC.pSrcList = pS->pSrc;\n      sNC.pNext = pNC;\n      sNC.pParse = pNC->pParse;\n      zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol); \n      break;\n    }\n#endif\n  }\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA  \n  if( pzOrigDb ){\n    assert( pzOrigTab && pzOrigCol );\n    *pzOrigDb = zOrigDb;\n    *pzOrigTab = zOrigTab;\n    *pzOrigCol = zOrigCol;\n  }\n#endif\n  return zType;\n}\n\n/*\n** Generate code that will tell the VDBE the declaration types of columns\n** in the result set.\n*/\nstatic void generateColumnTypes(\n  Parse *pParse,      /* Parser context */\n  SrcList *pTabList,  /* List of tables */\n  ExprList *pEList    /* Expressions defining the result set */\n){\n#ifndef SQLITE_OMIT_DECLTYPE\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  NameContext sNC;\n  sNC.pSrcList = pTabList;\n  sNC.pParse = pParse;\n  sNC.pNext = 0;\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n    const char *zType;\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n    const char *zOrigDb = 0;\n    const char *zOrigTab = 0;\n    const char *zOrigCol = 0;\n    zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol);\n\n    /* The vdbe must make its own copy of the column-type and other \n    ** column specific strings, in case the schema is reset before this\n    ** virtual machine is deleted.\n    */\n    sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab, SQLITE_TRANSIENT);\n    sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol, SQLITE_TRANSIENT);\n#else\n    zType = columnType(&sNC, p, 0, 0, 0);\n#endif\n    sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT);\n  }\n#endif /* !defined(SQLITE_OMIT_DECLTYPE) */\n}\n\n\n/*\n** Compute the column names for a SELECT statement.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: sqlite3ColumnsFromExprList()\n**\n** The PRAGMA short_column_names and PRAGMA full_column_names settings are\n** deprecated.  The default setting is short=ON, full=OFF.  99.9% of all\n** applications should operate this way.  Nevertheless, we need to support the\n** other modes for legacy:\n**\n**    short=OFF, full=OFF:      Column name is the text of the expression has it\n**                              originally appears in the SELECT statement.  In\n**                              other words, the zSpan of the result expression.\n**\n**    short=ON, full=OFF:       (This is the default setting).  If the result\n**                              refers directly to a table column, then the\n**                              result column name is just the table column\n**                              name: COLUMN.  Otherwise use zSpan.\n**\n**    full=ON, short=ANY:       If the result refers directly to a table column,\n**                              then the result column name with the table name\n**                              prefix, ex: TABLE.COLUMN.  Otherwise use zSpan.\n*/\nstatic void generateColumnNames(\n  Parse *pParse,      /* Parser context */\n  Select *pSelect     /* Generate column names for this SELECT statement */\n){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  Table *pTab;\n  SrcList *pTabList;\n  ExprList *pEList;\n  sqlite3 *db = pParse->db;\n  int fullName;    /* TABLE.COLUMN if no AS clause and is a direct table ref */\n  int srcName;     /* COLUMN or TABLE.COLUMN if no AS clause and is direct */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  /* If this is an EXPLAIN, skip this step */\n  if( pParse->explain ){\n    return;\n  }\n#endif\n\n  if( pParse->colNamesSet || db->mallocFailed ) return;\n  /* Column names are determined by the left-most term of a compound select */\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  pTabList = pSelect->pSrc;\n  pEList = pSelect->pEList;\n  assert( v!=0 );\n  assert( pTabList!=0 );\n  pParse->colNamesSet = 1;\n  fullName = (db->flags & SQLITE_FullColNames)!=0;\n  srcName = (db->flags & SQLITE_ShortColNames)!=0 || fullName;\n  sqlite3VdbeSetNumCols(v, pEList->nExpr);\n  for(i=0; i<pEList->nExpr; i++){\n    Expr *p = pEList->a[i].pExpr;\n\n    assert( p!=0 );\n    assert( p->op!=TK_AGG_COLUMN );  /* Agg processing has not run yet */\n    assert( p->op!=TK_COLUMN || p->pTab!=0 ); /* Covering idx not yet coded */\n    if( pEList->a[i].zName ){\n      /* An AS clause always takes first priority */\n      char *zName = pEList->a[i].zName;\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT);\n    }else if( srcName && p->op==TK_COLUMN ){\n      char *zCol;\n      int iCol = p->iColumn;\n      pTab = p->pTab;\n      assert( pTab!=0 );\n      if( iCol<0 ) iCol = pTab->iPKey;\n      assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );\n      if( iCol<0 ){\n        zCol = \"rowid\";\n      }else{\n        zCol = pTab->aCol[iCol].zName;\n      }\n      if( fullName ){\n        char *zName = 0;\n        zName = sqlite3MPrintf(db, \"%s.%s\", pTab->zName, zCol);\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_DYNAMIC);\n      }else{\n        sqlite3VdbeSetColName(v, i, COLNAME_NAME, zCol, SQLITE_TRANSIENT);\n      }\n    }else{\n      const char *z = pEList->a[i].zSpan;\n      z = z==0 ? sqlite3MPrintf(db, \"column%d\", i+1) : sqlite3DbStrDup(db, z);\n      sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);\n    }\n  }\n  generateColumnTypes(pParse, pTabList, pEList);\n}\n\n/*\n** Given an expression list (which is really the list of expressions\n** that form the result set of a SELECT statement) compute appropriate\n** column names for a table that would hold the expression list.\n**\n** All column names will be unique.\n**\n** Only the column names are computed.  Column.zType, Column.zColl,\n** and other fields of Column are zeroed.\n**\n** Return SQLITE_OK on success.  If a memory allocation error occurs,\n** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM.\n**\n** The only guarantee that SQLite makes about column names is that if the\n** column has an AS clause assigning it a name, that will be the name used.\n** That is the only documented guarantee.  However, countless applications\n** developed over the years have made baseless assumptions about column names\n** and will break if those assumptions changes.  Hence, use extreme caution\n** when modifying this routine to avoid breaking legacy.\n**\n** See Also: generateColumnNames()\n*/\nint sqlite3ColumnsFromExprList(\n  Parse *pParse,          /* Parsing context */\n  ExprList *pEList,       /* Expr list from which to derive column names */\n  i16 *pnCol,             /* Write the number of columns here */\n  Column **paCol          /* Write the new column list here */\n){\n  sqlite3 *db = pParse->db;   /* Database connection */\n  int i, j;                   /* Loop counters */\n  u32 cnt;                    /* Index added to make the name unique */\n  Column *aCol, *pCol;        /* For looping over result columns */\n  int nCol;                   /* Number of columns in the result set */\n  char *zName;                /* Column name */\n  int nName;                  /* Size of name in zName[] */\n  Hash ht;                    /* Hash table of column names */\n\n  sqlite3HashInit(&ht);\n  if( pEList ){\n    nCol = pEList->nExpr;\n    aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);\n    testcase( aCol==0 );\n    if( nCol>32767 ) nCol = 32767;\n  }else{\n    nCol = 0;\n    aCol = 0;\n  }\n  assert( nCol==(i16)nCol );\n  *pnCol = nCol;\n  *paCol = aCol;\n\n  for(i=0, pCol=aCol; i<nCol && !db->mallocFailed; i++, pCol++){\n    /* Get an appropriate name for the column\n    */\n    if( (zName = pEList->a[i].zName)!=0 ){\n      /* If the column contains an \"AS <name>\" phrase, use <name> as the name */\n    }else{\n      Expr *pColExpr = sqlite3ExprSkipCollate(pEList->a[i].pExpr);\n      while( pColExpr->op==TK_DOT ){\n        pColExpr = pColExpr->pRight;\n        assert( pColExpr!=0 );\n      }\n      if( (pColExpr->op==TK_COLUMN || pColExpr->op==TK_AGG_COLUMN)\n       && pColExpr->pTab!=0 \n      ){\n        /* For columns use the column name name */\n        int iCol = pColExpr->iColumn;\n        Table *pTab = pColExpr->pTab;\n        if( iCol<0 ) iCol = pTab->iPKey;\n        zName = iCol>=0 ? pTab->aCol[iCol].zName : \"rowid\";\n      }else if( pColExpr->op==TK_ID ){\n        assert( !ExprHasProperty(pColExpr, EP_IntValue) );\n        zName = pColExpr->u.zToken;\n      }else{\n        /* Use the original text of the column expression as its name */\n        zName = pEList->a[i].zSpan;\n      }\n    }\n    if( zName ){\n      zName = sqlite3DbStrDup(db, zName);\n    }else{\n      zName = sqlite3MPrintf(db,\"column%d\",i+1);\n    }\n\n    /* Make sure the column name is unique.  If the name is not unique,\n    ** append an integer to the name so that it becomes unique.\n    */\n    cnt = 0;\n    while( zName && sqlite3HashFind(&ht, zName)!=0 ){\n      nName = sqlite3Strlen30(zName);\n      if( nName>0 ){\n        for(j=nName-1; j>0 && sqlite3Isdigit(zName[j]); j--){}\n        if( zName[j]==':' ) nName = j;\n      }\n      zName = sqlite3MPrintf(db, \"%.*z:%u\", nName, zName, ++cnt);\n      if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);\n    }\n    pCol->zName = zName;\n    sqlite3ColumnPropertiesFromName(0, pCol);\n    if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){\n      sqlite3OomFault(db);\n    }\n  }\n  sqlite3HashClear(&ht);\n  if( db->mallocFailed ){\n    for(j=0; j<i; j++){\n      sqlite3DbFree(db, aCol[j].zName);\n    }\n    sqlite3DbFree(db, aCol);\n    *paCol = 0;\n    *pnCol = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Add type and collation information to a column list based on\n** a SELECT statement.\n** \n** The column list presumably came from selectColumnNamesFromExprList().\n** The column list has only names, not types or collations.  This\n** routine goes through and adds the types and collations.\n**\n** This routine requires that all identifiers in the SELECT\n** statement be resolved.\n*/\nvoid sqlite3SelectAddColumnTypeAndCollation(\n  Parse *pParse,        /* Parsing contexts */\n  Table *pTab,          /* Add column type information to this table */\n  Select *pSelect       /* SELECT used to determine types and collations */\n){\n  sqlite3 *db = pParse->db;\n  NameContext sNC;\n  Column *pCol;\n  CollSeq *pColl;\n  int i;\n  Expr *p;\n  struct ExprList_item *a;\n\n  assert( pSelect!=0 );\n  assert( (pSelect->selFlags & SF_Resolved)!=0 );\n  assert( pTab->nCol==pSelect->pEList->nExpr || db->mallocFailed );\n  if( db->mallocFailed ) return;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pSrcList = pSelect->pSrc;\n  a = pSelect->pEList->a;\n  for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){\n    const char *zType;\n    int n, m;\n    p = a[i].pExpr;\n    zType = columnType(&sNC, p, 0, 0, 0);\n    /* pCol->szEst = ... // Column size est for SELECT tables never used */\n    pCol->affinity = sqlite3ExprAffinity(p);\n    if( zType ){\n      m = sqlite3Strlen30(zType);\n      n = sqlite3Strlen30(pCol->zName);\n      pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2);\n      if( pCol->zName ){\n        memcpy(&pCol->zName[n+1], zType, m+1);\n        pCol->colFlags |= COLFLAG_HASTYPE;\n      }\n    }\n    if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_BLOB;\n    pColl = sqlite3ExprCollSeq(pParse, p);\n    if( pColl && pCol->zColl==0 ){\n      pCol->zColl = sqlite3DbStrDup(db, pColl->zName);\n    }\n  }\n  pTab->szTabRow = 1; /* Any non-zero value works */\n}\n\n/*\n** Given a SELECT statement, generate a Table structure that describes\n** the result set of that SELECT.\n*/\nTable *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){\n  Table *pTab;\n  sqlite3 *db = pParse->db;\n  int savedFlags;\n\n  savedFlags = db->flags;\n  db->flags &= ~SQLITE_FullColNames;\n  db->flags |= SQLITE_ShortColNames;\n  sqlite3SelectPrep(pParse, pSelect, 0);\n  if( pParse->nErr ) return 0;\n  while( pSelect->pPrior ) pSelect = pSelect->pPrior;\n  db->flags = savedFlags;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table) );\n  if( pTab==0 ){\n    return 0;\n  }\n  /* The sqlite3ResultSetOfSelect() is only used n contexts where lookaside\n  ** is disabled */\n  assert( db->lookaside.bDisable );\n  pTab->nTabRef = 1;\n  pTab->zName = 0;\n  pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n  sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol);\n  sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSelect);\n  pTab->iPKey = -1;\n  if( db->mallocFailed ){\n    sqlite3DeleteTable(db, pTab);\n    return 0;\n  }\n  return pTab;\n}\n\n/*\n** Get a VDBE for the given parser context.  Create a new one if necessary.\n** If an error occurs, return NULL and leave a message in pParse.\n*/\nVdbe *sqlite3GetVdbe(Parse *pParse){\n  if( pParse->pVdbe ){\n    return pParse->pVdbe;\n  }\n  if( pParse->pToplevel==0\n   && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst)\n  ){\n    pParse->okConstFactor = 1;\n  }\n  return sqlite3VdbeCreate(pParse);\n}\n\n\n/*\n** Compute the iLimit and iOffset fields of the SELECT based on the\n** pLimit and pOffset expressions.  pLimit and pOffset hold the expressions\n** that appear in the original SQL statement after the LIMIT and OFFSET\n** keywords.  Or NULL if those keywords are omitted. iLimit and iOffset \n** are the integer memory register numbers for counters used to compute \n** the limit and offset.  If there is no limit and/or offset, then \n** iLimit and iOffset are negative.\n**\n** This routine changes the values of iLimit and iOffset only if\n** a limit or offset is defined by pLimit and pOffset.  iLimit and\n** iOffset should have been preset to appropriate default values (zero)\n** prior to calling this routine.\n**\n** The iOffset register (if it exists) is initialized to the value\n** of the OFFSET.  The iLimit register is initialized to LIMIT.  Register\n** iOffset+1 is initialized to LIMIT+OFFSET.\n**\n** Only if pLimit!=0 or pOffset!=0 do the limit registers get\n** redefined.  The UNION ALL operator uses this property to force\n** the reuse of the same limit and offset registers across multiple\n** SELECT statements.\n*/\nstatic void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){\n  Vdbe *v = 0;\n  int iLimit = 0;\n  int iOffset;\n  int n;\n  if( p->iLimit ) return;\n\n  /* \n  ** \"LIMIT -1\" always shows all rows.  There is some\n  ** controversy about what the correct behavior should be.\n  ** The current implementation interprets \"LIMIT 0\" to mean\n  ** no rows.\n  */\n  sqlite3ExprCacheClear(pParse);\n  assert( p->pOffset==0 || p->pLimit!=0 );\n  if( p->pLimit ){\n    p->iLimit = iLimit = ++pParse->nMem;\n    v = sqlite3GetVdbe(pParse);\n    assert( v!=0 );\n    if( sqlite3ExprIsInteger(p->pLimit, &n) ){\n      sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit);\n      VdbeComment((v, \"LIMIT counter\"));\n      if( n==0 ){\n        sqlite3VdbeGoto(v, iBreak);\n      }else if( n>=0 && p->nSelectRow>sqlite3LogEst((u64)n) ){\n        p->nSelectRow = sqlite3LogEst((u64)n);\n        p->selFlags |= SF_FixedLimit;\n      }\n    }else{\n      sqlite3ExprCode(pParse, p->pLimit, iLimit);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);\n      VdbeComment((v, \"LIMIT counter\"));\n      sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);\n    }\n    if( p->pOffset ){\n      p->iOffset = iOffset = ++pParse->nMem;\n      pParse->nMem++;   /* Allocate an extra register for limit+offset */\n      sqlite3ExprCode(pParse, p->pOffset, iOffset);\n      sqlite3VdbeAddOp1(v, OP_MustBeInt, iOffset); VdbeCoverage(v);\n      VdbeComment((v, \"OFFSET counter\"));\n      sqlite3VdbeAddOp3(v, OP_OffsetLimit, iLimit, iOffset+1, iOffset);\n      VdbeComment((v, \"LIMIT+OFFSET\"));\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n/*\n** Return the appropriate collating sequence for the iCol-th column of\n** the result set for the compound-select statement \"p\".  Return NULL if\n** the column has no default collating sequence.\n**\n** The collating sequence for the compound select is taken from the\n** left-most term of the select that has a collating sequence.\n*/\nstatic CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){\n  CollSeq *pRet;\n  if( p->pPrior ){\n    pRet = multiSelectCollSeq(pParse, p->pPrior, iCol);\n  }else{\n    pRet = 0;\n  }\n  assert( iCol>=0 );\n  /* iCol must be less than p->pEList->nExpr.  Otherwise an error would\n  ** have been thrown during name resolution and we would not have gotten\n  ** this far */\n  if( pRet==0 && ALWAYS(iCol<p->pEList->nExpr) ){\n    pRet = sqlite3ExprCollSeq(pParse, p->pEList->a[iCol].pExpr);\n  }\n  return pRet;\n}\n\n/*\n** The select statement passed as the second parameter is a compound SELECT\n** with an ORDER BY clause. This function allocates and returns a KeyInfo\n** structure suitable for implementing the ORDER BY.\n**\n** Space to hold the KeyInfo structure is obtained from malloc. The calling\n** function is responsible for ensuring that this structure is eventually\n** freed.\n*/\nstatic KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){\n  ExprList *pOrderBy = p->pOrderBy;\n  int nOrderBy = p->pOrderBy->nExpr;\n  sqlite3 *db = pParse->db;\n  KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1);\n  if( pRet ){\n    int i;\n    for(i=0; i<nOrderBy; i++){\n      struct ExprList_item *pItem = &pOrderBy->a[i];\n      Expr *pTerm = pItem->pExpr;\n      CollSeq *pColl;\n\n      if( pTerm->flags & EP_Collate ){\n        pColl = sqlite3ExprCollSeq(pParse, pTerm);\n      }else{\n        pColl = multiSelectCollSeq(pParse, p, pItem->u.x.iOrderByCol-1);\n        if( pColl==0 ) pColl = db->pDfltColl;\n        pOrderBy->a[i].pExpr =\n          sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName);\n      }\n      assert( sqlite3KeyInfoIsWriteable(pRet) );\n      pRet->aColl[i] = pColl;\n      pRet->aSortOrder[i] = pOrderBy->a[i].sortOrder;\n    }\n  }\n\n  return pRet;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** This routine generates VDBE code to compute the content of a WITH RECURSIVE\n** query of the form:\n**\n**   <recursive-table> AS (<setup-query> UNION [ALL] <recursive-query>)\n**                         \\___________/             \\_______________/\n**                           p->pPrior                      p\n**\n**\n** There is exactly one reference to the recursive-table in the FROM clause\n** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag.\n**\n** The setup-query runs once to generate an initial set of rows that go\n** into a Queue table.  Rows are extracted from the Queue table one by\n** one.  Each row extracted from Queue is output to pDest.  Then the single\n** extracted row (now in the iCurrent table) becomes the content of the\n** recursive-table for a recursive-query run.  The output of the recursive-query\n** is added back into the Queue table.  Then another row is extracted from Queue\n** and the iteration continues until the Queue table is empty.\n**\n** If the compound query operator is UNION then no duplicate rows are ever\n** inserted into the Queue table.  The iDistinct table keeps a copy of all rows\n** that have ever been inserted into Queue and causes duplicates to be\n** discarded.  If the operator is UNION ALL, then duplicates are allowed.\n** \n** If the query has an ORDER BY, then entries in the Queue table are kept in\n** ORDER BY order and the first entry is extracted for each cycle.  Without\n** an ORDER BY, the Queue table is just a FIFO.\n**\n** If a LIMIT clause is provided, then the iteration stops after LIMIT rows\n** have been output to pDest.  A LIMIT of zero means to output no rows and a\n** negative LIMIT means to output all rows.  If there is also an OFFSET clause\n** with a positive value, then the first OFFSET outputs are discarded rather\n** than being sent to pDest.  The LIMIT count does not begin until after OFFSET\n** rows have been skipped.\n*/\nstatic void generateWithRecursiveQuery(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The recursive SELECT to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  SrcList *pSrc = p->pSrc;      /* The FROM clause of the recursive query */\n  int nCol = p->pEList->nExpr;  /* Number of columns in the recursive table */\n  Vdbe *v = pParse->pVdbe;      /* The prepared statement under construction */\n  Select *pSetup = p->pPrior;   /* The setup query */\n  int addrTop;                  /* Top of the loop */\n  int addrCont, addrBreak;      /* CONTINUE and BREAK addresses */\n  int iCurrent = 0;             /* The Current table */\n  int regCurrent;               /* Register holding Current table */\n  int iQueue;                   /* The Queue table */\n  int iDistinct = 0;            /* To ensure unique results if UNION */\n  int eDest = SRT_Fifo;         /* How to write to Queue */\n  SelectDest destQueue;         /* SelectDest targetting the Queue table */\n  int i;                        /* Loop counter */\n  int rc;                       /* Result code */\n  ExprList *pOrderBy;           /* The ORDER BY clause */\n  Expr *pLimit, *pOffset;       /* Saved LIMIT and OFFSET */\n  int regLimit, regOffset;      /* Registers used by LIMIT and OFFSET */\n\n  /* Obtain authorization to do a recursive query */\n  if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;\n\n  /* Process the LIMIT and OFFSET clauses, if they exist */\n  addrBreak = sqlite3VdbeMakeLabel(v);\n  p->nSelectRow = 320;  /* 4 billion rows */\n  computeLimitRegisters(pParse, p, addrBreak);\n  pLimit = p->pLimit;\n  pOffset = p->pOffset;\n  regLimit = p->iLimit;\n  regOffset = p->iOffset;\n  p->pLimit = p->pOffset = 0;\n  p->iLimit = p->iOffset = 0;\n  pOrderBy = p->pOrderBy;\n\n  /* Locate the cursor number of the Current table */\n  for(i=0; ALWAYS(i<pSrc->nSrc); i++){\n    if( pSrc->a[i].fg.isRecursive ){\n      iCurrent = pSrc->a[i].iCursor;\n      break;\n    }\n  }\n\n  /* Allocate cursors numbers for Queue and Distinct.  The cursor number for\n  ** the Distinct table must be exactly one greater than Queue in order\n  ** for the SRT_DistFifo and SRT_DistQueue destinations to work. */\n  iQueue = pParse->nTab++;\n  if( p->op==TK_UNION ){\n    eDest = pOrderBy ? SRT_DistQueue : SRT_DistFifo;\n    iDistinct = pParse->nTab++;\n  }else{\n    eDest = pOrderBy ? SRT_Queue : SRT_Fifo;\n  }\n  sqlite3SelectDestInit(&destQueue, eDest, iQueue);\n\n  /* Allocate cursors for Current, Queue, and Distinct. */\n  regCurrent = ++pParse->nMem;\n  sqlite3VdbeAddOp3(v, OP_OpenPseudo, iCurrent, regCurrent, nCol);\n  if( pOrderBy ){\n    KeyInfo *pKeyInfo = multiSelectOrderByKeyInfo(pParse, p, 1);\n    sqlite3VdbeAddOp4(v, OP_OpenEphemeral, iQueue, pOrderBy->nExpr+2, 0,\n                      (char*)pKeyInfo, P4_KEYINFO);\n    destQueue.pOrderBy = pOrderBy;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iQueue, nCol);\n  }\n  VdbeComment((v, \"Queue table\"));\n  if( iDistinct ){\n    p->addrOpenEphm[0] = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iDistinct, 0);\n    p->selFlags |= SF_UsesEphemeral;\n  }\n\n  /* Detach the ORDER BY clause from the compound SELECT */\n  p->pOrderBy = 0;\n\n  /* Store the results of the setup-query in Queue. */\n  pSetup->pNext = 0;\n  rc = sqlite3Select(pParse, pSetup, &destQueue);\n  pSetup->pNext = p;\n  if( rc ) goto end_of_recursive_query;\n\n  /* Find the next row in the Queue and output that row */\n  addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iQueue, addrBreak); VdbeCoverage(v);\n\n  /* Transfer the next row in Queue over to Current */\n  sqlite3VdbeAddOp1(v, OP_NullRow, iCurrent); /* To reset column cache */\n  if( pOrderBy ){\n    sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent);\n  }else{\n    sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent);\n  }\n  sqlite3VdbeAddOp1(v, OP_Delete, iQueue);\n\n  /* Output the single row in Current */\n  addrCont = sqlite3VdbeMakeLabel(v);\n  codeOffset(v, regOffset, addrCont);\n  selectInnerLoop(pParse, p, iCurrent,\n      0, 0, pDest, addrCont, addrBreak);\n  if( regLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);\n    VdbeCoverage(v);\n  }\n  sqlite3VdbeResolveLabel(v, addrCont);\n\n  /* Execute the recursive SELECT taking the single row in Current as\n  ** the value for the recursive-table. Store the results in the Queue.\n  */\n  if( p->selFlags & SF_Aggregate ){\n    sqlite3ErrorMsg(pParse, \"recursive aggregate queries not supported\");\n  }else{\n    p->pPrior = 0;\n    sqlite3Select(pParse, p, &destQueue);\n    assert( p->pPrior==0 );\n    p->pPrior = pSetup;\n  }\n\n  /* Keep running the loop until the Queue is empty */\n  sqlite3VdbeGoto(v, addrTop);\n  sqlite3VdbeResolveLabel(v, addrBreak);\n\nend_of_recursive_query:\n  sqlite3ExprListDelete(pParse->db, p->pOrderBy);\n  p->pOrderBy = pOrderBy;\n  p->pLimit = pLimit;\n  p->pOffset = pOffset;\n  return;\n}\n#endif /* SQLITE_OMIT_CTE */\n\n/* Forward references */\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n);\n\n/*\n** Handle the special case of a compound-select that originates from a\n** VALUES clause.  By handling this as a special case, we avoid deep\n** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT\n** on a VALUES clause.\n**\n** Because the Select object originates from a VALUES clause:\n**   (1) It has no LIMIT or OFFSET\n**   (2) All terms are UNION ALL\n**   (3) There is no ORDER BY clause\n*/\nstatic int multiSelectValues(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  Select *pPrior;\n  int nRow = 1;\n  int rc = 0;\n  assert( p->selFlags & SF_MultiValue );\n  do{\n    assert( p->selFlags & SF_Values );\n    assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );\n    assert( p->pLimit==0 );\n    assert( p->pOffset==0 );\n    assert( p->pNext==0 || p->pEList->nExpr==p->pNext->pEList->nExpr );\n    if( p->pPrior==0 ) break;\n    assert( p->pPrior->pNext==p );\n    p = p->pPrior;\n    nRow++;\n  }while(1);\n  while( p ){\n    pPrior = p->pPrior;\n    p->pPrior = 0;\n    rc = sqlite3Select(pParse, p, pDest);\n    p->pPrior = pPrior;\n    if( rc ) break;\n    p->nSelectRow = nRow;\n    p = p->pNext;\n  }\n  return rc;\n}\n\n/*\n** This routine is called to process a compound query form from\n** two or more separate queries using UNION, UNION ALL, EXCEPT, or\n** INTERSECT\n**\n** \"p\" points to the right-most of the two queries.  the query on the\n** left is p->pPrior.  The left query could also be a compound query\n** in which case this routine will be called recursively. \n**\n** The results of the total query are to be written into a destination\n** of type eDest with parameter iParm.\n**\n** Example 1:  Consider a three-way compound SQL statement.\n**\n**     SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3\n**\n** This statement is parsed up as follows:\n**\n**     SELECT c FROM t3\n**      |\n**      `----->  SELECT b FROM t2\n**                |\n**                `------>  SELECT a FROM t1\n**\n** The arrows in the diagram above represent the Select.pPrior pointer.\n** So if this routine is called with p equal to the t3 query, then\n** pPrior will be the t2 query.  p->op will be TK_UNION in this case.\n**\n** Notice that because of the way SQLite parses compound SELECTs, the\n** individual selects always group from left to right.\n*/\nstatic int multiSelect(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int rc = SQLITE_OK;   /* Success code from a subroutine */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest dest;      /* Alternative data destination */\n  Select *pDelete = 0;  /* Chain of simple selects to delete */\n  sqlite3 *db;          /* Database connection */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1 = 0;        /* EQP id of left-hand query */\n  int iSub2 = 0;        /* EQP id of right-hand query */\n#endif\n\n  /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs.  Only\n  ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.\n  */\n  assert( p && p->pPrior );  /* Calling function guarantees this much */\n  assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );\n  db = pParse->db;\n  pPrior = p->pPrior;\n  dest = *pDest;\n  if( pPrior->pOrderBy || pPrior->pLimit ){\n    sqlite3ErrorMsg(pParse,\"%s clause should come after %s not before\",\n      pPrior->pOrderBy!=0 ? \"ORDER BY\" : \"LIMIT\", selectOpName(p->op));\n    rc = 1;\n    goto multi_select_end;\n  }\n\n  v = sqlite3GetVdbe(pParse);\n  assert( v!=0 );  /* The VDBE already created by calling function */\n\n  /* Create the destination temporary table if necessary\n  */\n  if( dest.eDest==SRT_EphemTab ){\n    assert( p->pEList );\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr);\n    dest.eDest = SRT_Table;\n  }\n\n  /* Special handling for a compound-select that originates as a VALUES clause.\n  */\n  if( p->selFlags & SF_MultiValue ){\n    rc = multiSelectValues(pParse, p, &dest);\n    goto multi_select_end;\n  }\n\n  /* Make sure all SELECTs in the statement have the same number of elements\n  ** in their result sets.\n  */\n  assert( p->pEList && pPrior->pEList );\n  assert( p->pEList->nExpr==pPrior->pEList->nExpr );\n\n#ifndef SQLITE_OMIT_CTE\n  if( p->selFlags & SF_Recursive ){\n    generateWithRecursiveQuery(pParse, p, &dest);\n  }else\n#endif\n\n  /* Compound SELECTs that have an ORDER BY clause are handled separately.\n  */\n  if( p->pOrderBy ){\n    return multiSelectOrderBy(pParse, p, pDest);\n  }else\n\n  /* Generate code for the left and right SELECT statements.\n  */\n  switch( p->op ){\n    case TK_ALL: {\n      int addr = 0;\n      int nLimit;\n      assert( !pPrior->pLimit );\n      pPrior->iLimit = p->iLimit;\n      pPrior->iOffset = p->iOffset;\n      pPrior->pLimit = p->pLimit;\n      pPrior->pOffset = p->pOffset;\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &dest);\n      p->pLimit = 0;\n      p->pOffset = 0;\n      if( rc ){\n        goto multi_select_end;\n      }\n      p->pPrior = 0;\n      p->iLimit = pPrior->iLimit;\n      p->iOffset = pPrior->iOffset;\n      if( p->iLimit ){\n        addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);\n        VdbeComment((v, \"Jump ahead if LIMIT reached\"));\n        if( p->iOffset ){\n          sqlite3VdbeAddOp3(v, OP_OffsetLimit,\n                            p->iLimit, p->iOffset+1, p->iOffset);\n        }\n      }\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &dest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n      if( pPrior->pLimit\n       && sqlite3ExprIsInteger(pPrior->pLimit, &nLimit)\n       && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) \n      ){\n        p->nSelectRow = sqlite3LogEst((u64)nLimit);\n      }\n      if( addr ){\n        sqlite3VdbeJumpHere(v, addr);\n      }\n      break;\n    }\n    case TK_EXCEPT:\n    case TK_UNION: {\n      int unionTab;    /* Cursor number of the temporary table holding result */\n      u8 op = 0;       /* One of the SRT_ operations to apply to self */\n      int priorOp;     /* The SRT_ operation to apply to prior selects */\n      Expr *pLimit, *pOffset; /* Saved values of p->nLimit and p->nOffset */\n      int addr;\n      SelectDest uniondest;\n\n      testcase( p->op==TK_EXCEPT );\n      testcase( p->op==TK_UNION );\n      priorOp = SRT_Union;\n      if( dest.eDest==priorOp ){\n        /* We can reuse a temporary table generated by a SELECT to our\n        ** right.\n        */\n        assert( p->pLimit==0 );      /* Not allowed on leftward elements */\n        assert( p->pOffset==0 );     /* Not allowed on leftward elements */\n        unionTab = dest.iSDParm;\n      }else{\n        /* We will need to create our own temporary table to hold the\n        ** intermediate results.\n        */\n        unionTab = pParse->nTab++;\n        assert( p->pOrderBy==0 );\n        addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, unionTab, 0);\n        assert( p->addrOpenEphm[0] == -1 );\n        p->addrOpenEphm[0] = addr;\n        findRightmost(p)->selFlags |= SF_UsesEphemeral;\n        assert( p->pEList );\n      }\n\n      /* Code the SELECT statements to our left\n      */\n      assert( !pPrior->pOrderBy );\n      sqlite3SelectDestInit(&uniondest, priorOp, unionTab);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &uniondest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT statement\n      */\n      if( p->op==TK_EXCEPT ){\n        op = SRT_Except;\n      }else{\n        assert( p->op==TK_UNION );\n        op = SRT_Union;\n      }\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      uniondest.eDest = op;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &uniondest);\n      testcase( rc!=SQLITE_OK );\n      /* Query flattening in sqlite3Select() might refill p->pOrderBy.\n      ** Be sure to delete p->pOrderBy, therefore, to avoid a memory leak. */\n      sqlite3ExprListDelete(db, p->pOrderBy);\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      p->pOrderBy = 0;\n      if( p->op==TK_UNION ){\n        p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n      }\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n      p->iLimit = 0;\n      p->iOffset = 0;\n\n      /* Convert the data in the temporary table into whatever form\n      ** it is that we currently need.\n      */\n      assert( unionTab==dest.iSDParm || dest.eDest!=priorOp );\n      if( dest.eDest!=priorOp ){\n        int iCont, iBreak, iStart;\n        assert( p->pEList );\n        iBreak = sqlite3VdbeMakeLabel(v);\n        iCont = sqlite3VdbeMakeLabel(v);\n        computeLimitRegisters(pParse, p, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);\n        iStart = sqlite3VdbeCurrentAddr(v);\n        selectInnerLoop(pParse, p, unionTab,\n                        0, 0, &dest, iCont, iBreak);\n        sqlite3VdbeResolveLabel(v, iCont);\n        sqlite3VdbeAddOp2(v, OP_Next, unionTab, iStart); VdbeCoverage(v);\n        sqlite3VdbeResolveLabel(v, iBreak);\n        sqlite3VdbeAddOp2(v, OP_Close, unionTab, 0);\n      }\n      break;\n    }\n    default: assert( p->op==TK_INTERSECT ); {\n      int tab1, tab2;\n      int iCont, iBreak, iStart;\n      Expr *pLimit, *pOffset;\n      int addr;\n      SelectDest intersectdest;\n      int r1;\n\n      /* INTERSECT is different from the others since it requires\n      ** two temporary tables.  Hence it has its own case.  Begin\n      ** by allocating the tables we will need.\n      */\n      tab1 = pParse->nTab++;\n      tab2 = pParse->nTab++;\n      assert( p->pOrderBy==0 );\n\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab1, 0);\n      assert( p->addrOpenEphm[0] == -1 );\n      p->addrOpenEphm[0] = addr;\n      findRightmost(p)->selFlags |= SF_UsesEphemeral;\n      assert( p->pEList );\n\n      /* Code the SELECTs to our left into temporary table \"tab1\".\n      */\n      sqlite3SelectDestInit(&intersectdest, SRT_Union, tab1);\n      explainSetInteger(iSub1, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, pPrior, &intersectdest);\n      if( rc ){\n        goto multi_select_end;\n      }\n\n      /* Code the current SELECT into temporary table \"tab2\"\n      */\n      addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);\n      assert( p->addrOpenEphm[1] == -1 );\n      p->addrOpenEphm[1] = addr;\n      p->pPrior = 0;\n      pLimit = p->pLimit;\n      p->pLimit = 0;\n      pOffset = p->pOffset;\n      p->pOffset = 0;\n      intersectdest.iSDParm = tab2;\n      explainSetInteger(iSub2, pParse->iNextSelectId);\n      rc = sqlite3Select(pParse, p, &intersectdest);\n      testcase( rc!=SQLITE_OK );\n      pDelete = p->pPrior;\n      p->pPrior = pPrior;\n      if( p->nSelectRow>pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n      sqlite3ExprDelete(db, p->pLimit);\n      p->pLimit = pLimit;\n      p->pOffset = pOffset;\n\n      /* Generate code to take the intersection of the two temporary\n      ** tables.\n      */\n      assert( p->pEList );\n      iBreak = sqlite3VdbeMakeLabel(v);\n      iCont = sqlite3VdbeMakeLabel(v);\n      computeLimitRegisters(pParse, p, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);\n      r1 = sqlite3GetTempReg(pParse);\n      iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); VdbeCoverage(v);\n      sqlite3ReleaseTempReg(pParse, r1);\n      selectInnerLoop(pParse, p, tab1,\n                      0, 0, &dest, iCont, iBreak);\n      sqlite3VdbeResolveLabel(v, iCont);\n      sqlite3VdbeAddOp2(v, OP_Next, tab1, iStart); VdbeCoverage(v);\n      sqlite3VdbeResolveLabel(v, iBreak);\n      sqlite3VdbeAddOp2(v, OP_Close, tab2, 0);\n      sqlite3VdbeAddOp2(v, OP_Close, tab1, 0);\n      break;\n    }\n  }\n\n  explainComposite(pParse, p->op, iSub1, iSub2, p->op!=TK_ALL);\n\n  /* Compute collating sequences used by \n  ** temporary tables needed to implement the compound select.\n  ** Attach the KeyInfo structure to all temporary tables.\n  **\n  ** This section is run by the right-most SELECT statement only.\n  ** SELECT statements to the left always skip this part.  The right-most\n  ** SELECT might also skip this part if it has no ORDER BY clause and\n  ** no temp tables are required.\n  */\n  if( p->selFlags & SF_UsesEphemeral ){\n    int i;                        /* Loop counter */\n    KeyInfo *pKeyInfo;            /* Collating sequence for the result set */\n    Select *pLoop;                /* For looping through SELECT statements */\n    CollSeq **apColl;             /* For looping through pKeyInfo->aColl[] */\n    int nCol;                     /* Number of columns in result set */\n\n    assert( p->pNext==0 );\n    nCol = p->pEList->nExpr;\n    pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1);\n    if( !pKeyInfo ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto multi_select_end;\n    }\n    for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){\n      *apColl = multiSelectCollSeq(pParse, p, i);\n      if( 0==*apColl ){\n        *apColl = db->pDfltColl;\n      }\n    }\n\n    for(pLoop=p; pLoop; pLoop=pLoop->pPrior){\n      for(i=0; i<2; i++){\n        int addr = pLoop->addrOpenEphm[i];\n        if( addr<0 ){\n          /* If [0] is unused then [1] is also unused.  So we can\n          ** always safely abort as soon as the first unused slot is found */\n          assert( pLoop->addrOpenEphm[1]<0 );\n          break;\n        }\n        sqlite3VdbeChangeP2(v, addr, nCol);\n        sqlite3VdbeChangeP4(v, addr, (char*)sqlite3KeyInfoRef(pKeyInfo),\n                            P4_KEYINFO);\n        pLoop->addrOpenEphm[i] = -1;\n      }\n    }\n    sqlite3KeyInfoUnref(pKeyInfo);\n  }\n\nmulti_select_end:\n  pDest->iSdst = dest.iSdst;\n  pDest->nSdst = dest.nSdst;\n  sqlite3SelectDelete(db, pDelete);\n  return rc;\n}\n#endif /* SQLITE_OMIT_COMPOUND_SELECT */\n\n/*\n** Error message for when two or more terms of a compound select have different\n** size result sets.\n*/\nvoid sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){\n  if( p->selFlags & SF_Values ){\n    sqlite3ErrorMsg(pParse, \"all VALUES must have the same number of terms\");\n  }else{\n    sqlite3ErrorMsg(pParse, \"SELECTs to the left and right of %s\"\n      \" do not have the same number of result columns\", selectOpName(p->op));\n  }\n}\n\n/*\n** Code an output subroutine for a coroutine implementation of a\n** SELECT statment.\n**\n** The data to be output is contained in pIn->iSdst.  There are\n** pIn->nSdst columns to be output.  pDest is where the output should\n** be sent.\n**\n** regReturn is the number of the register holding the subroutine\n** return address.\n**\n** If regPrev>0 then it is the first register in a vector that\n** records the previous output.  mem[regPrev] is a flag that is false\n** if there has been no previous output.  If regPrev>0 then code is\n** generated to suppress duplicates.  pKeyInfo is used for comparing\n** keys.\n**\n** If the LIMIT found in p->iLimit is reached, jump immediately to\n** iBreak.\n*/\nstatic int generateOutputSubroutine(\n  Parse *pParse,          /* Parsing context */\n  Select *p,              /* The SELECT statement */\n  SelectDest *pIn,        /* Coroutine supplying data */\n  SelectDest *pDest,      /* Where to send the data */\n  int regReturn,          /* The return address register */\n  int regPrev,            /* Previous result register.  No uniqueness if 0 */\n  KeyInfo *pKeyInfo,      /* For comparing with previous entry */\n  int iBreak              /* Jump here if we hit the LIMIT */\n){\n  Vdbe *v = pParse->pVdbe;\n  int iContinue;\n  int addr;\n\n  addr = sqlite3VdbeCurrentAddr(v);\n  iContinue = sqlite3VdbeMakeLabel(v);\n\n  /* Suppress duplicates for UNION, EXCEPT, and INTERSECT \n  */\n  if( regPrev ){\n    int addr1, addr2;\n    addr1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); VdbeCoverage(v);\n    addr2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst,\n                              (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n    sqlite3VdbeAddOp3(v, OP_Jump, addr2+2, iContinue, addr2+2); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr1);\n    sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev);\n  }\n  if( pParse->db->mallocFailed ) return 0;\n\n  /* Suppress the first OFFSET entries if there is an OFFSET clause\n  */\n  codeOffset(v, p->iOffset, iContinue);\n\n  assert( pDest->eDest!=SRT_Exists );\n  assert( pDest->eDest!=SRT_Table );\n  switch( pDest->eDest ){\n    /* Store the result as data using a unique key.\n    */\n    case SRT_EphemTab: {\n      int r1 = sqlite3GetTempReg(pParse);\n      int r2 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1);\n      sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2);\n      sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2);\n      sqlite3VdbeChangeP5(v, OPFLAG_APPEND);\n      sqlite3ReleaseTempReg(pParse, r2);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n#ifndef SQLITE_OMIT_SUBQUERY\n    /* If we are creating a set for an \"expr IN (SELECT ...)\".\n    */\n    case SRT_Set: {\n      int r1;\n      testcase( pIn->nSdst>1 );\n      r1 = sqlite3GetTempReg(pParse);\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, \n          r1, pDest->zAffSdst, pIn->nSdst);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pDest->iSDParm, r1,\n                           pIn->iSdst, pIn->nSdst);\n      sqlite3ReleaseTempReg(pParse, r1);\n      break;\n    }\n\n    /* If this is a scalar select that is part of an expression, then\n    ** store the results in the appropriate memory cell and break out\n    ** of the scan loop.\n    */\n    case SRT_Mem: {\n      assert( pIn->nSdst==1 || pParse->nErr>0 );  testcase( pIn->nSdst!=1 );\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);\n      /* The LIMIT clause will jump out of the loop for us */\n      break;\n    }\n#endif /* #ifndef SQLITE_OMIT_SUBQUERY */\n\n    /* The results are stored in a sequence of registers\n    ** starting at pDest->iSdst.  Then the co-routine yields.\n    */\n    case SRT_Coroutine: {\n      if( pDest->iSdst==0 ){\n        pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);\n        pDest->nSdst = pIn->nSdst;\n      }\n      sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);\n      sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);\n      break;\n    }\n\n    /* If none of the above, then the result destination must be\n    ** SRT_Output.  This routine is never called with any other\n    ** destination other than the ones handled above or SRT_Output.\n    **\n    ** For SRT_Output, results are stored in a sequence of registers.  \n    ** Then the OP_ResultRow opcode is used to cause sqlite3_step() to\n    ** return the next row of result.\n    */\n    default: {\n      assert( pDest->eDest==SRT_Output );\n      sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst);\n      sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst);\n      break;\n    }\n  }\n\n  /* Jump to the end of the loop if the LIMIT is reached.\n  */\n  if( p->iLimit ){\n    sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);\n  }\n\n  /* Generate the subroutine return\n  */\n  sqlite3VdbeResolveLabel(v, iContinue);\n  sqlite3VdbeAddOp1(v, OP_Return, regReturn);\n\n  return addr;\n}\n\n/*\n** Alternative compound select code generator for cases when there\n** is an ORDER BY clause.\n**\n** We assume a query of the following form:\n**\n**      <selectA>  <operator>  <selectB>  ORDER BY <orderbylist>\n**\n** <operator> is one of UNION ALL, UNION, EXCEPT, or INTERSECT.  The idea\n** is to code both <selectA> and <selectB> with the ORDER BY clause as\n** co-routines.  Then run the co-routines in parallel and merge the results\n** into the output.  In addition to the two coroutines (called selectA and\n** selectB) there are 7 subroutines:\n**\n**    outA:    Move the output of the selectA coroutine into the output\n**             of the compound query.\n**\n**    outB:    Move the output of the selectB coroutine into the output\n**             of the compound query.  (Only generated for UNION and\n**             UNION ALL.  EXCEPT and INSERTSECT never output a row that\n**             appears only in B.)\n**\n**    AltB:    Called when there is data from both coroutines and A<B.\n**\n**    AeqB:    Called when there is data from both coroutines and A==B.\n**\n**    AgtB:    Called when there is data from both coroutines and A>B.\n**\n**    EofA:    Called when data is exhausted from selectA.\n**\n**    EofB:    Called when data is exhausted from selectB.\n**\n** The implementation of the latter five subroutines depend on which \n** <operator> is used:\n**\n**\n**             UNION ALL         UNION            EXCEPT          INTERSECT\n**          -------------  -----------------  --------------  -----------------\n**   AltB:   outA, nextA      outA, nextA       outA, nextA         nextA\n**\n**   AeqB:   outA, nextA         nextA             nextA         outA, nextA\n**\n**   AgtB:   outB, nextB      outB, nextB          nextB            nextB\n**\n**   EofA:   outB, nextB      outB, nextB          halt             halt\n**\n**   EofB:   outA, nextA      outA, nextA       outA, nextA         halt\n**\n** In the AltB, AeqB, and AgtB subroutines, an EOF on A following nextA\n** causes an immediate jump to EofA and an EOF on B following nextB causes\n** an immediate jump to EofB.  Within EofA and EofB, and EOF on entry or\n** following nextX causes a jump to the end of the select processing.\n**\n** Duplicate removal in the UNION, EXCEPT, and INTERSECT cases is handled\n** within the output subroutine.  The regPrev register set holds the previously\n** output value.  A comparison is made against this value and the output\n** is skipped if the next results would be the same as the previous.\n**\n** The implementation plan is to implement the two coroutines and seven\n** subroutines first, then put the control logic at the bottom.  Like this:\n**\n**          goto Init\n**     coA: coroutine for left query (A)\n**     coB: coroutine for right query (B)\n**    outA: output one row of A\n**    outB: output one row of B (UNION and UNION ALL only)\n**    EofA: ...\n**    EofB: ...\n**    AltB: ...\n**    AeqB: ...\n**    AgtB: ...\n**    Init: initialize coroutine registers\n**          yield coA\n**          if eof(A) goto EofA\n**          yield coB\n**          if eof(B) goto EofB\n**    Cmpr: Compare A, B\n**          Jump AltB, AeqB, AgtB\n**     End: ...\n**\n** We call AltB, AeqB, AgtB, EofA, and EofB \"subroutines\" but they are not\n** actually called using Gosub and they do not Return.  EofA and EofB loop\n** until all data is exhausted then jump to the \"end\" labe.  AltB, AeqB,\n** and AgtB jump to either L2 or to one of EofA or EofB.\n*/\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\nstatic int multiSelectOrderBy(\n  Parse *pParse,        /* Parsing context */\n  Select *p,            /* The right-most of SELECTs to be coded */\n  SelectDest *pDest     /* What to do with query results */\n){\n  int i, j;             /* Loop counters */\n  Select *pPrior;       /* Another SELECT immediately to our left */\n  Vdbe *v;              /* Generate code to this VDBE */\n  SelectDest destA;     /* Destination for coroutine A */\n  SelectDest destB;     /* Destination for coroutine B */\n  int regAddrA;         /* Address register for select-A coroutine */\n  int regAddrB;         /* Address register for select-B coroutine */\n  int addrSelectA;      /* Address of the select-A coroutine */\n  int addrSelectB;      /* Address of the select-B coroutine */\n  int regOutA;          /* Address register for the output-A subroutine */\n  int regOutB;          /* Address register for the output-B subroutine */\n  int addrOutA;         /* Address of the output-A subroutine */\n  int addrOutB = 0;     /* Address of the output-B subroutine */\n  int addrEofA;         /* Address of the select-A-exhausted subroutine */\n  int addrEofA_noB;     /* Alternate addrEofA if B is uninitialized */\n  int addrEofB;         /* Address of the select-B-exhausted subroutine */\n  int addrAltB;         /* Address of the A<B subroutine */\n  int addrAeqB;         /* Address of the A==B subroutine */\n  int addrAgtB;         /* Address of the A>B subroutine */\n  int regLimitA;        /* Limit register for select-A */\n  int regLimitB;        /* Limit register for select-A */\n  int regPrev;          /* A range of registers to hold previous output */\n  int savedLimit;       /* Saved value of p->iLimit */\n  int savedOffset;      /* Saved value of p->iOffset */\n  int labelCmpr;        /* Label for the start of the merge algorithm */\n  int labelEnd;         /* Label for the end of the overall SELECT stmt */\n  int addr1;            /* Jump instructions that get retargetted */\n  int op;               /* One of TK_ALL, TK_UNION, TK_EXCEPT, TK_INTERSECT */\n  KeyInfo *pKeyDup = 0; /* Comparison information for duplicate removal */\n  KeyInfo *pKeyMerge;   /* Comparison information for merging rows */\n  sqlite3 *db;          /* Database connection */\n  ExprList *pOrderBy;   /* The ORDER BY clause */\n  int nOrderBy;         /* Number of terms in the ORDER BY clause */\n  int *aPermute;        /* Mapping from ORDER BY terms to result set columns */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSub1;            /* EQP id of left-hand query */\n  int iSub2;            /* EQP id of right-hand query */\n#endif\n\n  assert( p->pOrderBy!=0 );\n  assert( pKeyDup==0 ); /* \"Managed\" code needs this.  Ticket #3382. */\n  db = pParse->db;\n  v = pParse->pVdbe;\n  assert( v!=0 );       /* Already thrown the error if VDBE alloc failed */\n  labelEnd = sqlite3VdbeMakeLabel(v);\n  labelCmpr = sqlite3VdbeMakeLabel(v);\n\n\n  /* Patch up the ORDER BY clause\n  */\n  op = p->op;  \n  pPrior = p->pPrior;\n  assert( pPrior->pOrderBy==0 );\n  pOrderBy = p->pOrderBy;\n  assert( pOrderBy );\n  nOrderBy = pOrderBy->nExpr;\n\n  /* For operators other than UNION ALL we have to make sure that\n  ** the ORDER BY clause covers every term of the result set.  Add\n  ** terms to the ORDER BY clause as necessary.\n  */\n  if( op!=TK_ALL ){\n    for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){\n      struct ExprList_item *pItem;\n      for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){\n        assert( pItem->u.x.iOrderByCol>0 );\n        if( pItem->u.x.iOrderByCol==i ) break;\n      }\n      if( j==nOrderBy ){\n        Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);\n        if( pNew==0 ) return SQLITE_NOMEM_BKPT;\n        pNew->flags |= EP_IntValue;\n        pNew->u.iValue = i;\n        p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew);\n        if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i;\n      }\n    }\n  }\n\n  /* Compute the comparison permutation and keyinfo that is used with\n  ** the permutation used to determine if the next\n  ** row of results comes from selectA or selectB.  Also add explicit\n  ** collations to the ORDER BY clause terms so that when the subqueries\n  ** to the right and the left are evaluated, they use the correct\n  ** collation.\n  */\n  aPermute = sqlite3DbMallocRawNN(db, sizeof(int)*(nOrderBy + 1));\n  if( aPermute ){\n    struct ExprList_item *pItem;\n    aPermute[0] = nOrderBy;\n    for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){\n      assert( pItem->u.x.iOrderByCol>0 );\n      assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr );\n      aPermute[i] = pItem->u.x.iOrderByCol - 1;\n    }\n    pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);\n  }else{\n    pKeyMerge = 0;\n  }\n\n  /* Reattach the ORDER BY clause to the query.\n  */\n  p->pOrderBy = pOrderBy;\n  pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);\n\n  /* Allocate a range of temporary registers and the KeyInfo needed\n  ** for the logic that removes duplicate result rows when the\n  ** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).\n  */\n  if( op==TK_ALL ){\n    regPrev = 0;\n  }else{\n    int nExpr = p->pEList->nExpr;\n    assert( nOrderBy>=nExpr || db->mallocFailed );\n    regPrev = pParse->nMem+1;\n    pParse->nMem += nExpr+1;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev);\n    pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1);\n    if( pKeyDup ){\n      assert( sqlite3KeyInfoIsWriteable(pKeyDup) );\n      for(i=0; i<nExpr; i++){\n        pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i);\n        pKeyDup->aSortOrder[i] = 0;\n      }\n    }\n  }\n \n  /* Separate the left and the right query from one another\n  */\n  p->pPrior = 0;\n  pPrior->pNext = 0;\n  sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, \"ORDER\");\n  if( pPrior->pPrior==0 ){\n    sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, \"ORDER\");\n  }\n\n  /* Compute the limit registers */\n  computeLimitRegisters(pParse, p, labelEnd);\n  if( p->iLimit && op==TK_ALL ){\n    regLimitA = ++pParse->nMem;\n    regLimitB = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Copy, p->iOffset ? p->iOffset+1 : p->iLimit,\n                                  regLimitA);\n    sqlite3VdbeAddOp2(v, OP_Copy, regLimitA, regLimitB);\n  }else{\n    regLimitA = regLimitB = 0;\n  }\n  sqlite3ExprDelete(db, p->pLimit);\n  p->pLimit = 0;\n  sqlite3ExprDelete(db, p->pOffset);\n  p->pOffset = 0;\n\n  regAddrA = ++pParse->nMem;\n  regAddrB = ++pParse->nMem;\n  regOutA = ++pParse->nMem;\n  regOutB = ++pParse->nMem;\n  sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA);\n  sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB);\n\n  /* Generate a coroutine to evaluate the SELECT statement to the\n  ** left of the compound operator - the \"A\" select.\n  */\n  addrSelectA = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrA, 0, addrSelectA);\n  VdbeComment((v, \"left SELECT\"));\n  pPrior->iLimit = regLimitA;\n  explainSetInteger(iSub1, pParse->iNextSelectId);\n  sqlite3Select(pParse, pPrior, &destA);\n  sqlite3VdbeEndCoroutine(v, regAddrA);\n  sqlite3VdbeJumpHere(v, addr1);\n\n  /* Generate a coroutine to evaluate the SELECT statement on \n  ** the right - the \"B\" select\n  */\n  addrSelectB = sqlite3VdbeCurrentAddr(v) + 1;\n  addr1 = sqlite3VdbeAddOp3(v, OP_InitCoroutine, regAddrB, 0, addrSelectB);\n  VdbeComment((v, \"right SELECT\"));\n  savedLimit = p->iLimit;\n  savedOffset = p->iOffset;\n  p->iLimit = regLimitB;\n  p->iOffset = 0;  \n  explainSetInteger(iSub2, pParse->iNextSelectId);\n  sqlite3Select(pParse, p, &destB);\n  p->iLimit = savedLimit;\n  p->iOffset = savedOffset;\n  sqlite3VdbeEndCoroutine(v, regAddrB);\n\n  /* Generate a subroutine that outputs the current row of the A\n  ** select as the next output row of the compound select.\n  */\n  VdbeNoopComment((v, \"Output routine for A\"));\n  addrOutA = generateOutputSubroutine(pParse,\n                 p, &destA, pDest, regOutA,\n                 regPrev, pKeyDup, labelEnd);\n  \n  /* Generate a subroutine that outputs the current row of the B\n  ** select as the next output row of the compound select.\n  */\n  if( op==TK_ALL || op==TK_UNION ){\n    VdbeNoopComment((v, \"Output routine for B\"));\n    addrOutB = generateOutputSubroutine(pParse,\n                 p, &destB, pDest, regOutB,\n                 regPrev, pKeyDup, labelEnd);\n  }\n  sqlite3KeyInfoUnref(pKeyDup);\n\n  /* Generate a subroutine to run when the results from select A\n  ** are exhausted and only data in select B remains.\n  */\n  if( op==TK_EXCEPT || op==TK_INTERSECT ){\n    addrEofA_noB = addrEofA = labelEnd;\n  }else{  \n    VdbeNoopComment((v, \"eof-A subroutine\"));\n    addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n    addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd);\n                                     VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofA);\n    p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow);\n  }\n\n  /* Generate a subroutine to run when the results from select B\n  ** are exhausted and only data in select A remains.\n  */\n  if( op==TK_INTERSECT ){\n    addrEofB = addrEofA;\n    if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow;\n  }else{  \n    VdbeNoopComment((v, \"eof-B subroutine\"));\n    addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, addrEofB);\n  }\n\n  /* Generate code to handle the case of A<B\n  */\n  VdbeNoopComment((v, \"A-lt-B subroutine\"));\n  addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* Generate code to handle the case of A==B\n  */\n  if( op==TK_ALL ){\n    addrAeqB = addrAltB;\n  }else if( op==TK_INTERSECT ){\n    addrAeqB = addrAltB;\n    addrAltB++;\n  }else{\n    VdbeNoopComment((v, \"A-eq-B subroutine\"));\n    addrAeqB =\n    sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v);\n    sqlite3VdbeGoto(v, labelCmpr);\n  }\n\n  /* Generate code to handle the case of A>B\n  */\n  VdbeNoopComment((v, \"A-gt-B subroutine\"));\n  addrAgtB = sqlite3VdbeCurrentAddr(v);\n  if( op==TK_ALL || op==TK_UNION ){\n    sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB);\n  }\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n  sqlite3VdbeGoto(v, labelCmpr);\n\n  /* This code runs once to initialize everything.\n  */\n  sqlite3VdbeJumpHere(v, addr1);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v);\n  sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v);\n\n  /* Implement the main merge loop\n  */\n  sqlite3VdbeResolveLabel(v, labelCmpr);\n  sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);\n  sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,\n                         (char*)pKeyMerge, P4_KEYINFO);\n  sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);\n  sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); VdbeCoverage(v);\n\n  /* Jump to the this point in order to terminate the query.\n  */\n  sqlite3VdbeResolveLabel(v, labelEnd);\n\n  /* Reassembly the compound query so that it will be freed correctly\n  ** by the calling function */\n  if( p->pPrior ){\n    sqlite3SelectDelete(db, p->pPrior);\n  }\n  p->pPrior = pPrior;\n  pPrior->pNext = p;\n\n  /*** TBD:  Insert subroutine calls to close cursors on incomplete\n  **** subqueries ****/\n  explainComposite(pParse, p->op, iSub1, iSub2, 0);\n  return pParse->nErr!=0;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n\n/* An instance of the SubstContext object describes an substitution edit\n** to be performed on a parse tree.\n**\n** All references to columns in table iTable are to be replaced by corresponding\n** expressions in pEList.\n*/\ntypedef struct SubstContext {\n  Parse *pParse;            /* The parsing context */\n  int iTable;               /* Replace references to this table */\n  int iNewTable;            /* New table number */\n  int isLeftJoin;           /* Add TK_IF_NULL_ROW opcodes on each replacement */\n  ExprList *pEList;         /* Replacement expressions */\n} SubstContext;\n\n/* Forward Declarations */\nstatic void substExprList(SubstContext*, ExprList*);\nstatic void substSelect(SubstContext*, Select*, int);\n\n/*\n** Scan through the expression pExpr.  Replace every reference to\n** a column in table number iTable with a copy of the iColumn-th\n** entry in pEList.  (But leave references to the ROWID column \n** unchanged.)\n**\n** This routine is part of the flattening procedure.  A subquery\n** whose result set is defined by pEList appears as entry in the\n** FROM clause of a SELECT such that the VDBE cursor assigned to that\n** FORM clause entry is iTable.  This routine makes the necessary \n** changes to pExpr so that it refers directly to the source table\n** of the subquery rather the result set of the subquery.\n*/\nstatic Expr *substExpr(\n  SubstContext *pSubst,  /* Description of the substitution */\n  Expr *pExpr            /* Expr in which substitution occurs */\n){\n  if( pExpr==0 ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin)\n   && pExpr->iRightJoinTable==pSubst->iTable\n  ){\n    pExpr->iRightJoinTable = pSubst->iNewTable;\n  }\n  if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){\n    if( pExpr->iColumn<0 ){\n      pExpr->op = TK_NULL;\n    }else{\n      Expr *pNew;\n      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;\n      Expr ifNullRow;\n      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );\n      assert( pExpr->pLeft==0 && pExpr->pRight==0 );\n      if( sqlite3ExprIsVector(pCopy) ){\n        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);\n      }else{\n        sqlite3 *db = pSubst->pParse->db;\n        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){\n          memset(&ifNullRow, 0, sizeof(ifNullRow));\n          ifNullRow.op = TK_IF_NULL_ROW;\n          ifNullRow.pLeft = pCopy;\n          ifNullRow.iTable = pSubst->iNewTable;\n          pCopy = &ifNullRow;\n        }\n        pNew = sqlite3ExprDup(db, pCopy, 0);\n        if( pNew && pSubst->isLeftJoin ){\n          ExprSetProperty(pNew, EP_CanBeNull);\n        }\n        if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){\n          pNew->iRightJoinTable = pExpr->iRightJoinTable;\n          ExprSetProperty(pNew, EP_FromJoin);\n        }\n        sqlite3ExprDelete(db, pExpr);\n        pExpr = pNew;\n      }\n    }\n  }else{\n    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){\n      pExpr->iTable = pSubst->iNewTable;\n    }\n    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);\n    pExpr->pRight = substExpr(pSubst, pExpr->pRight);\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      substSelect(pSubst, pExpr->x.pSelect, 1);\n    }else{\n      substExprList(pSubst, pExpr->x.pList);\n    }\n  }\n  return pExpr;\n}\nstatic void substExprList(\n  SubstContext *pSubst, /* Description of the substitution */\n  ExprList *pList       /* List to scan and in which to make substitutes */\n){\n  int i;\n  if( pList==0 ) return;\n  for(i=0; i<pList->nExpr; i++){\n    pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr);\n  }\n}\nstatic void substSelect(\n  SubstContext *pSubst, /* Description of the substitution */\n  Select *p,            /* SELECT statement in which to make substitutions */\n  int doPrior           /* Do substitutes on p->pPrior too */\n){\n  SrcList *pSrc;\n  struct SrcList_item *pItem;\n  int i;\n  if( !p ) return;\n  do{\n    substExprList(pSubst, p->pEList);\n    substExprList(pSubst, p->pGroupBy);\n    substExprList(pSubst, p->pOrderBy);\n    p->pHaving = substExpr(pSubst, p->pHaving);\n    p->pWhere = substExpr(pSubst, p->pWhere);\n    pSrc = p->pSrc;\n    assert( pSrc!=0 );\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      substSelect(pSubst, pItem->pSelect, 1);\n      if( pItem->fg.isTabFunc ){\n        substExprList(pSubst, pItem->u1.pFuncArg);\n      }\n    }\n  }while( doPrior && (p = p->pPrior)!=0 );\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** This routine attempts to flatten subqueries as a performance optimization.\n** This routine returns 1 if it makes changes and 0 if no flattening occurs.\n**\n** To understand the concept of flattening, consider the following\n** query:\n**\n**     SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5\n**\n** The default way of implementing this query is to execute the\n** subquery first and store the results in a temporary table, then\n** run the outer query on that temporary table.  This requires two\n** passes over the data.  Furthermore, because the temporary table\n** has no indices, the WHERE clause on the outer query cannot be\n** optimized.\n**\n** This routine attempts to rewrite queries such as the above into\n** a single flat select, like this:\n**\n**     SELECT x+y AS a FROM t1 WHERE z<100 AND a>5\n**\n** The code generated for this simplification gives the same result\n** but only has to scan the data once.  And because indices might \n** exist on the table t1, a complete scan of the data might be\n** avoided.\n**\n** Flattening is subject to the following constraints:\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        The subquery and the outer query cannot both be aggregates.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries. Was:\n**        (2) If the subquery is an aggregate then\n**        (2a) the outer query must not be a join and\n**        (2b) the outer query must not use subqueries\n**             other than the one FROM-clause subquery that is a candidate\n**             for flattening.  (This is due to ticket [2f7170d73bf9abf80]\n**             from 2015-02-09.)\n**\n**   (3)  If the subquery is the right operand of a LEFT JOIN then\n**        (3a) the subquery may not be a join and\n**        (3b) the FROM clause of the subquery may not contain a virtual\n**             table and\n**        (3c) the outer query may not be an aggregate.\n**\n**   (4)  The subquery can not be DISTINCT.\n**\n**  (**)  At one point restrictions (4) and (5) defined a subset of DISTINCT\n**        sub-queries that were excluded from this optimization. Restriction \n**        (4) has since been expanded to exclude all DISTINCT subqueries.\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        If the subquery is aggregate, the outer query may not be DISTINCT.\n**\n**   (7)  The subquery must have a FROM clause.  TODO:  For subqueries without\n**        A FROM clause, consider adding a FROM clause with the special\n**        table sqlite_once that consists of a single row containing a\n**        single NULL.\n**\n**   (8)  If the subquery uses LIMIT then the outer query may not be a join.\n**\n**   (9)  If the subquery uses LIMIT then the outer query may not be aggregate.\n**\n**  (**)  Restriction (10) was removed from the code on 2005-02-05 but we\n**        accidently carried the comment forward until 2014-09-15.  Original\n**        constraint: \"If the subquery is aggregate then the outer query \n**        may not use LIMIT.\"\n**\n**  (11)  The subquery and the outer query may not both have ORDER BY clauses.\n**\n**  (**)  Not implemented.  Subsumed into restriction (3).  Was previously\n**        a separate restriction deriving from ticket #350.\n**\n**  (13)  The subquery and outer query may not both use LIMIT.\n**\n**  (14)  The subquery may not use OFFSET.\n**\n**  (15)  If the outer query is part of a compound select, then the\n**        subquery may not use LIMIT.\n**        (See ticket #2339 and ticket [02a8e81d44]).\n**\n**  (16)  If the outer query is aggregate, then the subquery may not\n**        use ORDER BY.  (Ticket #2942)  This used to not matter\n**        until we introduced the group_concat() function.  \n**\n**  (17)  If the subquery is a compound select, then\n**        (17a) all compound operators must be a UNION ALL, and\n**        (17b) no terms within the subquery compound may be aggregate\n**              or DISTINCT, and\n**        (17c) every term within the subquery compound must have a FROM clause\n**        (17d) the outer query may not be\n**              (17d1) aggregate, or\n**              (17d2) DISTINCT, or\n**              (17d3) a join.\n**\n**        The parent and sub-query may contain WHERE clauses. Subject to\n**        rules (11), (13) and (14), they may also contain ORDER BY,\n**        LIMIT and OFFSET clauses.  The subquery cannot use any compound\n**        operator other than UNION ALL because all the other compound\n**        operators have an implied DISTINCT which is disallowed by\n**        restriction (4).\n**\n**        Also, each component of the sub-query must return the same number\n**        of result columns. This is actually a requirement for any compound\n**        SELECT statement, but all the code here does is make sure that no\n**        such (illegal) sub-query is flattened. The caller will detect the\n**        syntax error and return a detailed message.\n**\n**  (18)  If the sub-query is a compound select, then all terms of the\n**        ORDER BY clause of the parent must be simple references to \n**        columns of the sub-query.\n**\n**  (19)  If the subquery uses LIMIT then the outer query may not\n**        have a WHERE clause.\n**\n**  (**)  Subsumed into (17d3).  Was: If the sub-query is a compound select,\n**        then it must not use an ORDER BY clause - Ticket #3773.  Because\n**        of (17d3), then only way to have a compound subquery is if it is\n**        the only term in the FROM clause of the outer query.  But if the\n**        only term in the FROM clause has an ORDER BY, then it will be\n**        implemented as a co-routine and the flattener will never be called.\n**\n**  (21)  If the subquery uses LIMIT then the outer query may not be\n**        DISTINCT.  (See ticket [752e1646fc]).\n**\n**  (22)  The subquery may not be a recursive CTE.\n**\n**  (**)  Subsumed into restriction (17d3).  Was: If the outer query is\n**        a recursive CTE, then the sub-query may not be a compound query.\n**        This restriction is because transforming the\n**        parent to a compound query confuses the code that handles\n**        recursive queries in multiSelect().\n**\n**  (**)  We no longer attempt to flatten aggregate subqueries.  Was:\n**        The subquery may not be an aggregate that uses the built-in min() or \n**        or max() functions.  (Without this restriction, a query like:\n**        \"SELECT x FROM (SELECT max(y), x FROM t1)\" would not necessarily\n**        return the value X for which Y was maximal.)\n**\n**\n** In this routine, the \"p\" parameter is a pointer to the outer query.\n** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query\n** uses aggregates.\n**\n** If flattening is not attempted, this routine is a no-op and returns 0.\n** If flattening is attempted this routine returns 1.\n**\n** All of the expression analysis must occur on both the outer query and\n** the subquery before this routine runs.\n*/\nstatic int flattenSubquery(\n  Parse *pParse,       /* Parsing context */\n  Select *p,           /* The parent or outer SELECT statement */\n  int iFrom,           /* Index in p->pSrc->a[] of the inner subquery */\n  int isAgg            /* True if outer SELECT uses aggregate functions */\n){\n  const char *zSavedAuthContext = pParse->zAuthContext;\n  Select *pParent;    /* Current UNION ALL term of the other query */\n  Select *pSub;       /* The inner query or \"subquery\" */\n  Select *pSub1;      /* Pointer to the rightmost select in sub-query */\n  SrcList *pSrc;      /* The FROM clause of the outer query */\n  SrcList *pSubSrc;   /* The FROM clause of the subquery */\n  int iParent;        /* VDBE cursor number of the pSub result set temp table */\n  int iNewParent = -1;/* Replacement table for iParent */\n  int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */    \n  int i;              /* Loop counter */\n  Expr *pWhere;                    /* The WHERE clause */\n  struct SrcList_item *pSubitem;   /* The subquery */\n  sqlite3 *db = pParse->db;\n\n  /* Check to see if flattening is permitted.  Return 0 if not.\n  */\n  assert( p!=0 );\n  assert( p->pPrior==0 );\n  if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;\n  pSrc = p->pSrc;\n  assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );\n  pSubitem = &pSrc->a[iFrom];\n  iParent = pSubitem->iCursor;\n  pSub = pSubitem->pSelect;\n  assert( pSub!=0 );\n\n  pSubSrc = pSub->pSrc;\n  assert( pSubSrc );\n  /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,\n  ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET\n  ** because they could be computed at compile-time.  But when LIMIT and OFFSET\n  ** became arbitrary expressions, we were forced to add restrictions (13)\n  ** and (14). */\n  if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */\n  if( pSub->pOffset ) return 0;                          /* Restriction (14) */\n  if( (p->selFlags & SF_Compound)!=0 && pSub->pLimit ){\n    return 0;                                            /* Restriction (15) */\n  }\n  if( pSubSrc->nSrc==0 ) return 0;                       /* Restriction (7)  */\n  if( pSub->selFlags & SF_Distinct ) return 0;           /* Restriction (4)  */\n  if( pSub->pLimit && (pSrc->nSrc>1 || isAgg) ){\n     return 0;         /* Restrictions (8)(9) */\n  }\n  if( p->pOrderBy && pSub->pOrderBy ){\n     return 0;                                           /* Restriction (11) */\n  }\n  if( isAgg && pSub->pOrderBy ) return 0;                /* Restriction (16) */\n  if( pSub->pLimit && p->pWhere ) return 0;              /* Restriction (19) */\n  if( pSub->pLimit && (p->selFlags & SF_Distinct)!=0 ){\n     return 0;         /* Restriction (21) */\n  }\n  if( pSub->selFlags & (SF_Recursive) ){\n    return 0; /* Restrictions (22) */\n  }\n\n  /*\n  ** If the subquery is the right operand of a LEFT JOIN, then the\n  ** subquery may not be a join itself (3a). Example of why this is not\n  ** allowed:\n  **\n  **         t1 LEFT OUTER JOIN (t2 JOIN t3)\n  **\n  ** If we flatten the above, we would get\n  **\n  **         (t1 LEFT OUTER JOIN t2) JOIN t3\n  **\n  ** which is not at all the same thing.\n  **\n  ** If the subquery is the right operand of a LEFT JOIN, then the outer\n  ** query cannot be an aggregate. (3c)  This is an artifact of the way\n  ** aggregates are processed - there is no mechanism to determine if\n  ** the LEFT JOIN table should be all-NULL.\n  **\n  ** See also tickets #306, #350, and #3300.\n  */\n  if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){\n    isLeftJoin = 1;\n    if( pSubSrc->nSrc>1 || isAgg || IsVirtual(pSubSrc->a[0].pTab) ){\n      /*  (3a)             (3c)     (3b) */\n      return 0;\n    }\n  }\n#ifdef SQLITE_EXTRA_IFNULLROW\n  else if( iFrom>0 && !isAgg ){\n    /* Setting isLeftJoin to -1 causes OP_IfNullRow opcodes to be generated for\n    ** every reference to any result column from subquery in a join, even\n    ** though they are not necessary.  This will stress-test the OP_IfNullRow \n    ** opcode. */\n    isLeftJoin = -1;\n  }\n#endif\n\n  /* Restriction (17): If the sub-query is a compound SELECT, then it must\n  ** use only the UNION ALL operator. And none of the simple select queries\n  ** that make up the compound SELECT are allowed to be aggregate or distinct\n  ** queries.\n  */\n  if( pSub->pPrior ){\n    if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){\n      return 0; /* (17d1), (17d2), or (17d3) */\n    }\n    for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct );\n      testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate );\n      assert( pSub->pSrc!=0 );\n      assert( pSub->pEList->nExpr==pSub1->pEList->nExpr );\n      if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0    /* (17b) */\n       || (pSub1->pPrior && pSub1->op!=TK_ALL)                 /* (17a) */\n       || pSub1->pSrc->nSrc<1                                  /* (17c) */\n      ){\n        return 0;\n      }\n      testcase( pSub1->pSrc->nSrc>1 );\n    }\n\n    /* Restriction (18). */\n    if( p->pOrderBy ){\n      int ii;\n      for(ii=0; ii<p->pOrderBy->nExpr; ii++){\n        if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0;\n      }\n    }\n  }\n\n  /* Ex-restriction (23):\n  ** The only way that the recursive part of a CTE can contain a compound\n  ** subquery is for the subquery to be one term of a join.  But if the\n  ** subquery is a join, then the flattening has already been stopped by\n  ** restriction (17d3)\n  */\n  assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 );\n\n  /* Ex-restriction (20):\n  ** A compound subquery must be the only term in the FROM clause of the\n  ** outer query by restriction (17d3).  But if that term also has an\n  ** ORDER BY clause, then the subquery will be implemented by co-routine\n  ** and so the flattener will never be invoked.  Hence, it is not possible\n  ** for the subquery to be a compound and have an ORDER BY clause.\n  */\n  assert( pSub->pPrior==0 || pSub->pOrderBy==0 );\n\n  /***** If we reach this point, flattening is permitted. *****/\n  SELECTTRACE(1,pParse,p,(\"flatten %s.%p from term %d\\n\",\n                   pSub->zSelName, pSub, iFrom));\n\n  /* Authorize the subquery */\n  pParse->zAuthContext = pSubitem->zName;\n  TESTONLY(i =) sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0);\n  testcase( i==SQLITE_DENY );\n  pParse->zAuthContext = zSavedAuthContext;\n\n  /* If the sub-query is a compound SELECT statement, then (by restrictions\n  ** 17 and 18 above) it must be a UNION ALL and the parent query must \n  ** be of the form:\n  **\n  **     SELECT <expr-list> FROM (<sub-query>) <where-clause> \n  **\n  ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block\n  ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or \n  ** OFFSET clauses and joins them to the left-hand-side of the original\n  ** using UNION ALL operators. In this case N is the number of simple\n  ** select statements in the compound sub-query.\n  **\n  ** Example:\n  **\n  **     SELECT a+1 FROM (\n  **        SELECT x FROM tab\n  **        UNION ALL\n  **        SELECT y FROM tab\n  **        UNION ALL\n  **        SELECT abs(z*2) FROM tab2\n  **     ) WHERE a!=5 ORDER BY 1\n  **\n  ** Transformed into:\n  **\n  **     SELECT x+1 FROM tab WHERE x+1!=5\n  **     UNION ALL\n  **     SELECT y+1 FROM tab WHERE y+1!=5\n  **     UNION ALL\n  **     SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5\n  **     ORDER BY 1\n  **\n  ** We call this the \"compound-subquery flattening\".\n  */\n  for(pSub=pSub->pPrior; pSub; pSub=pSub->pPrior){\n    Select *pNew;\n    ExprList *pOrderBy = p->pOrderBy;\n    Expr *pLimit = p->pLimit;\n    Expr *pOffset = p->pOffset;\n    Select *pPrior = p->pPrior;\n    p->pOrderBy = 0;\n    p->pSrc = 0;\n    p->pPrior = 0;\n    p->pLimit = 0;\n    p->pOffset = 0;\n    pNew = sqlite3SelectDup(db, p, 0);\n    sqlite3SelectSetName(pNew, pSub->zSelName);\n    p->pOffset = pOffset;\n    p->pLimit = pLimit;\n    p->pOrderBy = pOrderBy;\n    p->pSrc = pSrc;\n    p->op = TK_ALL;\n    if( pNew==0 ){\n      p->pPrior = pPrior;\n    }else{\n      pNew->pPrior = pPrior;\n      if( pPrior ) pPrior->pNext = pNew;\n      pNew->pNext = p;\n      p->pPrior = pNew;\n      SELECTTRACE(2,pParse,p,\n         (\"compound-subquery flattener creates %s.%p as peer\\n\",\n         pNew->zSelName, pNew));\n    }\n    if( db->mallocFailed ) return 1;\n  }\n\n  /* Begin flattening the iFrom-th entry of the FROM clause \n  ** in the outer query.\n  */\n  pSub = pSub1 = pSubitem->pSelect;\n\n  /* Delete the transient table structure associated with the\n  ** subquery\n  */\n  sqlite3DbFree(db, pSubitem->zDatabase);\n  sqlite3DbFree(db, pSubitem->zName);\n  sqlite3DbFree(db, pSubitem->zAlias);\n  pSubitem->zDatabase = 0;\n  pSubitem->zName = 0;\n  pSubitem->zAlias = 0;\n  pSubitem->pSelect = 0;\n\n  /* Defer deleting the Table object associated with the\n  ** subquery until code generation is\n  ** complete, since there may still exist Expr.pTab entries that\n  ** refer to the subquery even after flattening.  Ticket #3346.\n  **\n  ** pSubitem->pTab is always non-NULL by test restrictions and tests above.\n  */\n  if( ALWAYS(pSubitem->pTab!=0) ){\n    Table *pTabToDel = pSubitem->pTab;\n    if( pTabToDel->nTabRef==1 ){\n      Parse *pToplevel = sqlite3ParseToplevel(pParse);\n      pTabToDel->pNextZombie = pToplevel->pZombieTab;\n      pToplevel->pZombieTab = pTabToDel;\n    }else{\n      pTabToDel->nTabRef--;\n    }\n    pSubitem->pTab = 0;\n  }\n\n  /* The following loop runs once for each term in a compound-subquery\n  ** flattening (as described above).  If we are doing a different kind\n  ** of flattening - a flattening other than a compound-subquery flattening -\n  ** then this loop only runs once.\n  **\n  ** This loop moves all of the FROM elements of the subquery into the\n  ** the FROM clause of the outer query.  Before doing this, remember\n  ** the cursor number for the original outer query FROM element in\n  ** iParent.  The iParent cursor will never be used.  Subsequent code\n  ** will scan expressions looking for iParent references and replace\n  ** those references with expressions that resolve to the subquery FROM\n  ** elements we are now copying in.\n  */\n  for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){\n    int nSubSrc;\n    u8 jointype = 0;\n    pSubSrc = pSub->pSrc;     /* FROM clause of subquery */\n    nSubSrc = pSubSrc->nSrc;  /* Number of terms in subquery FROM clause */\n    pSrc = pParent->pSrc;     /* FROM clause of the outer query */\n\n    if( pSrc ){\n      assert( pParent==p );  /* First time through the loop */\n      jointype = pSubitem->fg.jointype;\n    }else{\n      assert( pParent!=p );  /* 2nd and subsequent times through the loop */\n      pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n      if( pSrc==0 ){\n        assert( db->mallocFailed );\n        break;\n      }\n    }\n\n    /* The subquery uses a single slot of the FROM clause of the outer\n    ** query.  If the subquery has more than one element in its FROM clause,\n    ** then expand the outer query to make space for it to hold all elements\n    ** of the subquery.\n    **\n    ** Example:\n    **\n    **    SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;\n    **\n    ** The outer query has 3 slots in its FROM clause.  One slot of the\n    ** outer query (the middle slot) is used by the subquery.  The next\n    ** block of code will expand the outer query FROM clause to 4 slots.\n    ** The middle slot is expanded to two slots in order to make space\n    ** for the two elements in the FROM clause of the subquery.\n    */\n    if( nSubSrc>1 ){\n      pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);\n      if( db->mallocFailed ){\n        break;\n      }\n    }\n\n    /* Transfer the FROM clause terms from the subquery into the\n    ** outer query.\n    */\n    for(i=0; i<nSubSrc; i++){\n      sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing);\n      assert( pSrc->a[i+iFrom].fg.isTabFunc==0 );\n      pSrc->a[i+iFrom] = pSubSrc->a[i];\n      iNewParent = pSubSrc->a[i].iCursor;\n      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));\n    }\n    pSrc->a[iFrom].fg.jointype = jointype;\n  \n    /* Now begin substituting subquery result set expressions for \n    ** references to the iParent in the outer query.\n    ** \n    ** Example:\n    **\n    **   SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;\n    **   \\                     \\_____________ subquery __________/          /\n    **    \\_____________________ outer query ______________________________/\n    **\n    ** We look at every expression in the outer query and every place we see\n    ** \"a\" we substitute \"x*3\" and every place we see \"b\" we substitute \"y+10\".\n    */\n    if( pSub->pOrderBy ){\n      /* At this point, any non-zero iOrderByCol values indicate that the\n      ** ORDER BY column expression is identical to the iOrderByCol'th\n      ** expression returned by SELECT statement pSub. Since these values\n      ** do not necessarily correspond to columns in SELECT statement pParent,\n      ** zero them before transfering the ORDER BY clause.\n      **\n      ** Not doing this may cause an error if a subsequent call to this\n      ** function attempts to flatten a compound sub-query into pParent\n      ** (the only way this can happen is if the compound sub-query is\n      ** currently part of pSub->pSrc). See ticket [d11a6e908f].  */\n      ExprList *pOrderBy = pSub->pOrderBy;\n      for(i=0; i<pOrderBy->nExpr; i++){\n        pOrderBy->a[i].u.x.iOrderByCol = 0;\n      }\n      assert( pParent->pOrderBy==0 );\n      assert( pSub->pPrior==0 );\n      pParent->pOrderBy = pOrderBy;\n      pSub->pOrderBy = 0;\n    }\n    pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);\n    if( isLeftJoin>0 ){\n      setJoinExpr(pWhere, iNewParent);\n    }\n    pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere);\n    if( db->mallocFailed==0 ){\n      SubstContext x;\n      x.pParse = pParse;\n      x.iTable = iParent;\n      x.iNewTable = iNewParent;\n      x.isLeftJoin = isLeftJoin;\n      x.pEList = pSub->pEList;\n      substSelect(&x, pParent, 0);\n    }\n  \n    /* The flattened query is distinct if either the inner or the\n    ** outer query is distinct. \n    */\n    pParent->selFlags |= pSub->selFlags & SF_Distinct;\n  \n    /*\n    ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;\n    **\n    ** One is tempted to try to add a and b to combine the limits.  But this\n    ** does not work if either limit is negative.\n    */\n    if( pSub->pLimit ){\n      pParent->pLimit = pSub->pLimit;\n      pSub->pLimit = 0;\n    }\n  }\n\n  /* Finially, delete what is left of the subquery and return\n  ** success.\n  */\n  sqlite3SelectDelete(db, pSub1);\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x100 ){\n    SELECTTRACE(0x100,pParse,p,(\"After flattening:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  return 1;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n/*\n** Make copies of relevant WHERE clause terms of the outer query into\n** the WHERE clause of subquery.  Example:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1) WHERE x=5 AND y=10;\n**\n** Transformed into:\n**\n**    SELECT * FROM (SELECT a AS x, c-d AS y FROM t1 WHERE a=5 AND c-d=10)\n**     WHERE x=5 AND y=10;\n**\n** The hope is that the terms added to the inner query will make it more\n** efficient.\n**\n** Do not attempt this optimization if:\n**\n**   (1) (** This restriction was removed on 2017-09-29.  We used to\n**           disallow this optimization for aggregate subqueries, but now\n**           it is allowed by putting the extra terms on the HAVING clause.\n**           The added HAVING clause is pointless if the subquery lacks\n**           a GROUP BY clause.  But such a HAVING clause is also harmless\n**           so there does not appear to be any reason to add extra logic\n**           to suppress it. **)\n**\n**   (2) The inner query is the recursive part of a common table expression.\n**\n**   (3) The inner query has a LIMIT clause (since the changes to the WHERE\n**       close would change the meaning of the LIMIT).\n**\n**   (4) The inner query is the right operand of a LEFT JOIN.  (The caller\n**       enforces this restriction since this routine does not have enough\n**       information to know.)\n**\n**   (5) The WHERE clause expression originates in the ON or USING clause\n**       of a LEFT JOIN.\n**\n** Return 0 if no changes are made and non-zero if one or more WHERE clause\n** terms are duplicated into the subquery.\n*/\nstatic int pushDownWhereTerms(\n  Parse *pParse,        /* Parse context (for malloc() and error reporting) */\n  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */\n  Expr *pWhere,         /* The WHERE clause of the outer query */\n  int iCursor           /* Cursor number of the subquery */\n){\n  Expr *pNew;\n  int nChng = 0;\n  if( pWhere==0 ) return 0;\n  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */\n\n#ifdef SQLITE_DEBUG\n  /* Only the first term of a compound can have a WITH clause.  But make\n  ** sure no other terms are marked SF_Recursive in case something changes\n  ** in the future.\n  */\n  {\n    Select *pX;  \n    for(pX=pSubq; pX; pX=pX->pPrior){\n      assert( (pX->selFlags & (SF_Recursive))==0 );\n    }\n  }\n#endif\n\n  if( pSubq->pLimit!=0 ){\n    return 0; /* restriction (3) */\n  }\n  while( pWhere->op==TK_AND ){\n    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, iCursor);\n    pWhere = pWhere->pLeft;\n  }\n  if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction (5) */\n  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){\n    nChng++;\n    while( pSubq ){\n      SubstContext x;\n      pNew = sqlite3ExprDup(pParse->db, pWhere, 0);\n      x.pParse = pParse;\n      x.iTable = iCursor;\n      x.iNewTable = iCursor;\n      x.isLeftJoin = 0;\n      x.pEList = pSubq->pEList;\n      pNew = substExpr(&x, pNew);\n      if( pSubq->selFlags & SF_Aggregate ){\n        pSubq->pHaving = sqlite3ExprAnd(pParse->db, pSubq->pHaving, pNew);\n      }else{\n        pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew);\n      }\n      pSubq = pSubq->pPrior;\n    }\n  }\n  return nChng;\n}\n#endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */\n\n/*\n** Based on the contents of the AggInfo structure indicated by the first\n** argument, this function checks if the following are true:\n**\n**    * the query contains just a single aggregate function,\n**    * the aggregate function is either min() or max(), and\n**    * the argument to the aggregate function is a column value.\n**\n** If all of the above are true, then WHERE_ORDERBY_MIN or WHERE_ORDERBY_MAX\n** is returned as appropriate. Also, *ppMinMax is set to point to the \n** list of arguments passed to the aggregate before returning.\n**\n** Or, if the conditions above are not met, *ppMinMax is set to 0 and\n** WHERE_ORDERBY_NORMAL is returned.\n*/\nstatic u8 minMaxQuery(AggInfo *pAggInfo, ExprList **ppMinMax){\n  int eRet = WHERE_ORDERBY_NORMAL;          /* Return value */\n\n  *ppMinMax = 0;\n  if( pAggInfo->nFunc==1 ){\n    Expr *pExpr = pAggInfo->aFunc[0].pExpr; /* Aggregate function */\n    ExprList *pEList = pExpr->x.pList;      /* Arguments to agg function */\n\n    assert( pExpr->op==TK_AGG_FUNCTION );\n    if( pEList && pEList->nExpr==1 && pEList->a[0].pExpr->op==TK_AGG_COLUMN ){\n      const char *zFunc = pExpr->u.zToken;\n      if( sqlite3StrICmp(zFunc, \"min\")==0 ){\n        eRet = WHERE_ORDERBY_MIN;\n        *ppMinMax = pEList;\n      }else if( sqlite3StrICmp(zFunc, \"max\")==0 ){\n        eRet = WHERE_ORDERBY_MAX;\n        *ppMinMax = pEList;\n      }\n    }\n  }\n\n  assert( *ppMinMax==0 || (*ppMinMax)->nExpr==1 );\n  return eRet;\n}\n\n/*\n** The select statement passed as the first argument is an aggregate query.\n** The second argument is the associated aggregate-info object. This \n** function tests if the SELECT is of the form:\n**\n**   SELECT count(*) FROM <tbl>\n**\n** where table is a database table, not a sub-select or view. If the query\n** does match this pattern, then a pointer to the Table object representing\n** <tbl> is returned. Otherwise, 0 is returned.\n*/\nstatic Table *isSimpleCount(Select *p, AggInfo *pAggInfo){\n  Table *pTab;\n  Expr *pExpr;\n\n  assert( !p->pGroupBy );\n\n  if( p->pWhere || p->pEList->nExpr!=1 \n   || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect\n  ){\n    return 0;\n  }\n  pTab = p->pSrc->a[0].pTab;\n  pExpr = p->pEList->a[0].pExpr;\n  assert( pTab && !pTab->pSelect && pExpr );\n\n  if( IsVirtual(pTab) ) return 0;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;\n  if( NEVER(pAggInfo->nFunc==0) ) return 0;\n  if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0;\n  if( pExpr->flags&EP_Distinct ) return 0;\n\n  return pTab;\n}\n\n/*\n** If the source-list item passed as an argument was augmented with an\n** INDEXED BY clause, then try to locate the specified index. If there\n** was such a clause and the named index cannot be found, return \n** SQLITE_ERROR and leave an error in pParse. Otherwise, populate \n** pFrom->pIndex and return SQLITE_OK.\n*/\nint sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->pTab && pFrom->fg.isIndexedBy ){\n    Table *pTab = pFrom->pTab;\n    char *zIndexedBy = pFrom->u1.zIndexedBy;\n    Index *pIdx;\n    for(pIdx=pTab->pIndex; \n        pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); \n        pIdx=pIdx->pNext\n    );\n    if( !pIdx ){\n      sqlite3ErrorMsg(pParse, \"no such index: %s\", zIndexedBy, 0);\n      pParse->checkSchema = 1;\n      return SQLITE_ERROR;\n    }\n    pFrom->pIBIndex = pIdx;\n  }\n  return SQLITE_OK;\n}\n/*\n** Detect compound SELECT statements that use an ORDER BY clause with \n** an alternative collating sequence.\n**\n**    SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ...\n**\n** These are rewritten as a subquery:\n**\n**    SELECT * FROM (SELECT ... FROM t1 EXCEPT SELECT ... FROM t2)\n**     ORDER BY ... COLLATE ...\n**\n** This transformation is necessary because the multiSelectOrderBy() routine\n** above that generates the code for a compound SELECT with an ORDER BY clause\n** uses a merge algorithm that requires the same collating sequence on the\n** result columns as on the ORDER BY clause.  See ticket\n** http://www.sqlite.org/src/info/6709574d2a\n**\n** This transformation is only needed for EXCEPT, INTERSECT, and UNION.\n** The UNION ALL operator works fine with multiSelectOrderBy() even when\n** there are COLLATE terms in the ORDER BY.\n*/\nstatic int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){\n  int i;\n  Select *pNew;\n  Select *pX;\n  sqlite3 *db;\n  struct ExprList_item *a;\n  SrcList *pNewSrc;\n  Parse *pParse;\n  Token dummy;\n\n  if( p->pPrior==0 ) return WRC_Continue;\n  if( p->pOrderBy==0 ) return WRC_Continue;\n  for(pX=p; pX && (pX->op==TK_ALL || pX->op==TK_SELECT); pX=pX->pPrior){}\n  if( pX==0 ) return WRC_Continue;\n  a = p->pOrderBy->a;\n  for(i=p->pOrderBy->nExpr-1; i>=0; i--){\n    if( a[i].pExpr->flags & EP_Collate ) break;\n  }\n  if( i<0 ) return WRC_Continue;\n\n  /* If we reach this point, that means the transformation is required. */\n\n  pParse = pWalker->pParse;\n  db = pParse->db;\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );\n  if( pNew==0 ) return WRC_Abort;\n  memset(&dummy, 0, sizeof(dummy));\n  pNewSrc = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&dummy,pNew,0,0);\n  if( pNewSrc==0 ) return WRC_Abort;\n  *pNew = *p;\n  p->pSrc = pNewSrc;\n  p->pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ASTERISK, 0));\n  p->op = TK_SELECT;\n  p->pWhere = 0;\n  pNew->pGroupBy = 0;\n  pNew->pHaving = 0;\n  pNew->pOrderBy = 0;\n  p->pPrior = 0;\n  p->pNext = 0;\n  p->pWith = 0;\n  p->selFlags &= ~SF_Compound;\n  assert( (p->selFlags & SF_Converted)==0 );\n  p->selFlags |= SF_Converted;\n  assert( pNew->pPrior!=0 );\n  pNew->pPrior->pNext = pNew;\n  pNew->pLimit = 0;\n  pNew->pOffset = 0;\n  return WRC_Continue;\n}\n\n/*\n** Check to see if the FROM clause term pFrom has table-valued function\n** arguments.  If it does, leave an error message in pParse and return\n** non-zero, since pFrom is not allowed to be a table-valued function.\n*/\nstatic int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){\n  if( pFrom->fg.isTabFunc ){\n    sqlite3ErrorMsg(pParse, \"'%s' is not a function\", pFrom->zName);\n    return 1;\n  }\n  return 0;\n}\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** Argument pWith (which may be NULL) points to a linked list of nested \n** WITH contexts, from inner to outermost. If the table identified by \n** FROM clause element pItem is really a common-table-expression (CTE) \n** then return a pointer to the CTE definition for that table. Otherwise\n** return NULL.\n**\n** If a non-NULL value is returned, set *ppContext to point to the With\n** object that the returned CTE belongs to.\n*/\nstatic struct Cte *searchWith(\n  With *pWith,                    /* Current innermost WITH clause */\n  struct SrcList_item *pItem,     /* FROM clause element to resolve */\n  With **ppContext                /* OUT: WITH clause return value belongs to */\n){\n  const char *zName;\n  if( pItem->zDatabase==0 && (zName = pItem->zName)!=0 ){\n    With *p;\n    for(p=pWith; p; p=p->pOuter){\n      int i;\n      for(i=0; i<p->nCte; i++){\n        if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){\n          *ppContext = p;\n          return &p->a[i];\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/* The code generator maintains a stack of active WITH clauses\n** with the inner-most WITH clause being at the top of the stack.\n**\n** This routine pushes the WITH clause passed as the second argument\n** onto the top of the stack. If argument bFree is true, then this\n** WITH clause will never be popped from the stack. In this case it\n** should be freed along with the Parse object. In other cases, when\n** bFree==0, the With object will be freed along with the SELECT \n** statement with which it is associated.\n*/\nvoid sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){\n  assert( bFree==0 || (pParse->pWith==0 && pParse->pWithToFree==0) );\n  if( pWith ){\n    assert( pParse->pWith!=pWith );\n    pWith->pOuter = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bFree ) pParse->pWithToFree = pWith;\n  }\n}\n\n/*\n** This function checks if argument pFrom refers to a CTE declared by \n** a WITH clause on the stack currently maintained by the parser. And,\n** if currently processing a CTE expression, if it is a recursive\n** reference to the current CTE.\n**\n** If pFrom falls into either of the two categories above, pFrom->pTab\n** and other fields are populated accordingly. The caller should check\n** (pFrom->pTab!=0) to determine whether or not a successful match\n** was found.\n**\n** Whether or not a match is found, SQLITE_OK is returned if no error\n** occurs. If an error does occur, an error message is stored in the\n** parser and some error code other than SQLITE_OK returned.\n*/\nstatic int withExpand(\n  Walker *pWalker, \n  struct SrcList_item *pFrom\n){\n  Parse *pParse = pWalker->pParse;\n  sqlite3 *db = pParse->db;\n  struct Cte *pCte;               /* Matched CTE (or NULL if no match) */\n  With *pWith;                    /* WITH clause that pCte belongs to */\n\n  assert( pFrom->pTab==0 );\n\n  pCte = searchWith(pParse->pWith, pFrom, &pWith);\n  if( pCte ){\n    Table *pTab;\n    ExprList *pEList;\n    Select *pSel;\n    Select *pLeft;                /* Left-most SELECT statement */\n    int bMayRecursive;            /* True if compound joined by UNION [ALL] */\n    With *pSavedWith;             /* Initial value of pParse->pWith */\n\n    /* If pCte->zCteErr is non-NULL at this point, then this is an illegal\n    ** recursive reference to CTE pCte. Leave an error in pParse and return\n    ** early. If pCte->zCteErr is NULL, then this is not a recursive reference.\n    ** In this case, proceed.  */\n    if( pCte->zCteErr ){\n      sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName);\n      return SQLITE_ERROR;\n    }\n    if( cannotBeFunction(pParse, pFrom) ) return SQLITE_ERROR;\n\n    assert( pFrom->pTab==0 );\n    pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n    if( pTab==0 ) return WRC_Abort;\n    pTab->nTabRef = 1;\n    pTab->zName = sqlite3DbStrDup(db, pCte->zName);\n    pTab->iPKey = -1;\n    pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n    pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid;\n    pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0);\n    if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n    assert( pFrom->pSelect );\n\n    /* Check if this is a recursive CTE. */\n    pSel = pFrom->pSelect;\n    bMayRecursive = ( pSel->op==TK_ALL || pSel->op==TK_UNION );\n    if( bMayRecursive ){\n      int i;\n      SrcList *pSrc = pFrom->pSelect->pSrc;\n      for(i=0; i<pSrc->nSrc; i++){\n        struct SrcList_item *pItem = &pSrc->a[i];\n        if( pItem->zDatabase==0 \n         && pItem->zName!=0 \n         && 0==sqlite3StrICmp(pItem->zName, pCte->zName)\n          ){\n          pItem->pTab = pTab;\n          pItem->fg.isRecursive = 1;\n          pTab->nTabRef++;\n          pSel->selFlags |= SF_Recursive;\n        }\n      }\n    }\n\n    /* Only one recursive reference is permitted. */ \n    if( pTab->nTabRef>2 ){\n      sqlite3ErrorMsg(\n          pParse, \"multiple references to recursive table: %s\", pCte->zName\n      );\n      return SQLITE_ERROR;\n    }\n    assert( pTab->nTabRef==1 || \n            ((pSel->selFlags&SF_Recursive) && pTab->nTabRef==2 ));\n\n    pCte->zCteErr = \"circular reference: %s\";\n    pSavedWith = pParse->pWith;\n    pParse->pWith = pWith;\n    if( bMayRecursive ){\n      Select *pPrior = pSel->pPrior;\n      assert( pPrior->pWith==0 );\n      pPrior->pWith = pSel->pWith;\n      sqlite3WalkSelect(pWalker, pPrior);\n      pPrior->pWith = 0;\n    }else{\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pParse->pWith = pWith;\n\n    for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);\n    pEList = pLeft->pEList;\n    if( pCte->pCols ){\n      if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){\n        sqlite3ErrorMsg(pParse, \"table %s has %d values for %d columns\",\n            pCte->zName, pEList->nExpr, pCte->pCols->nExpr\n        );\n        pParse->pWith = pSavedWith;\n        return SQLITE_ERROR;\n      }\n      pEList = pCte->pCols;\n    }\n\n    sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol);\n    if( bMayRecursive ){\n      if( pSel->selFlags & SF_Recursive ){\n        pCte->zCteErr = \"multiple recursive references: %s\";\n      }else{\n        pCte->zCteErr = \"recursive reference in a subquery: %s\";\n      }\n      sqlite3WalkSelect(pWalker, pSel);\n    }\n    pCte->zCteErr = 0;\n    pParse->pWith = pSavedWith;\n  }\n\n  return SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CTE\n/*\n** If the SELECT passed as the second argument has an associated WITH \n** clause, pop it from the stack stored as part of the Parse object.\n**\n** This function is used as the xSelectCallback2() callback by\n** sqlite3SelectExpand() when walking a SELECT tree to resolve table\n** names and other FROM clause elements. \n*/\nstatic void selectPopWith(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->pWith) && p->pPrior==0 ){\n    With *pWith = findRightmost(p)->pWith;\n    if( pWith!=0 ){\n      assert( pParse->pWith==pWith );\n      pParse->pWith = pWith->pOuter;\n    }\n  }\n}\n#else\n#define selectPopWith 0\n#endif\n\n/*\n** This routine is a Walker callback for \"expanding\" a SELECT statement.\n** \"Expanding\" means to do the following:\n**\n**    (1)  Make sure VDBE cursor numbers have been assigned to every\n**         element of the FROM clause.\n**\n**    (2)  Fill in the pTabList->a[].pTab fields in the SrcList that \n**         defines FROM clause.  When views appear in the FROM clause,\n**         fill pTabList->a[].pSelect with a copy of the SELECT statement\n**         that implements the view.  A copy is made of the view's SELECT\n**         statement so that we can freely modify or delete that statement\n**         without worrying about messing up the persistent representation\n**         of the view.\n**\n**    (3)  Add terms to the WHERE clause to accommodate the NATURAL keyword\n**         on joins and the ON and USING clause of joins.\n**\n**    (4)  Scan the list of columns in the result set (pEList) looking\n**         for instances of the \"*\" operator or the TABLE.* operator.\n**         If found, expand each \"*\" to be every column in every table\n**         and TABLE.* to be every column in TABLE.\n**\n*/\nstatic int selectExpander(Walker *pWalker, Select *p){\n  Parse *pParse = pWalker->pParse;\n  int i, j, k;\n  SrcList *pTabList;\n  ExprList *pEList;\n  struct SrcList_item *pFrom;\n  sqlite3 *db = pParse->db;\n  Expr *pE, *pRight, *pExpr;\n  u16 selFlags = p->selFlags;\n\n  p->selFlags |= SF_Expanded;\n  if( db->mallocFailed  ){\n    return WRC_Abort;\n  }\n  if( NEVER(p->pSrc==0) || (selFlags & SF_Expanded)!=0 ){\n    return WRC_Prune;\n  }\n  pTabList = p->pSrc;\n  pEList = p->pEList;\n  if( OK_IF_ALWAYS_TRUE(p->pWith) ){\n    sqlite3WithPush(pParse, p->pWith, 0);\n  }\n\n  /* Make sure cursor numbers have been assigned to all entries in\n  ** the FROM clause of the SELECT statement.\n  */\n  sqlite3SrcListAssignCursors(pParse, pTabList);\n\n  /* Look up every table named in the FROM clause of the select.  If\n  ** an entry of the FROM clause is a subquery instead of a table or view,\n  ** then create a transient table structure to describe the subquery.\n  */\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab;\n    assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 );\n    if( pFrom->fg.isRecursive ) continue;\n    assert( pFrom->pTab==0 );\n#ifndef SQLITE_OMIT_CTE\n    if( withExpand(pWalker, pFrom) ) return WRC_Abort;\n    if( pFrom->pTab ) {} else\n#endif\n    if( pFrom->zName==0 ){\n#ifndef SQLITE_OMIT_SUBQUERY\n      Select *pSel = pFrom->pSelect;\n      /* A sub-query in the FROM clause of a SELECT */\n      assert( pSel!=0 );\n      assert( pFrom->pTab==0 );\n      if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;\n      pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));\n      if( pTab==0 ) return WRC_Abort;\n      pTab->nTabRef = 1;\n      if( pFrom->zAlias ){\n        pTab->zName = sqlite3DbStrDup(db, pFrom->zAlias);\n      }else{\n        pTab->zName = sqlite3MPrintf(db, \"subquery_%p\", (void*)pTab);\n      }\n      while( pSel->pPrior ){ pSel = pSel->pPrior; }\n      sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol);\n      pTab->iPKey = -1;\n      pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );\n      pTab->tabFlags |= TF_Ephemeral;\n#endif\n    }else{\n      /* An ordinary table or view name in the FROM clause */\n      assert( pFrom->pTab==0 );\n      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);\n      if( pTab==0 ) return WRC_Abort;\n      if( pTab->nTabRef>=0xffff ){\n        sqlite3ErrorMsg(pParse, \"too many references to \\\"%s\\\": max 65535\",\n           pTab->zName);\n        pFrom->pTab = 0;\n        return WRC_Abort;\n      }\n      pTab->nTabRef++;\n      if( !IsVirtual(pTab) && cannotBeFunction(pParse, pFrom) ){\n        return WRC_Abort;\n      }\n#if !defined(SQLITE_OMIT_VIEW) || !defined (SQLITE_OMIT_VIRTUALTABLE)\n      if( IsVirtual(pTab) || pTab->pSelect ){\n        i16 nCol;\n        if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort;\n        assert( pFrom->pSelect==0 );\n        pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0);\n        sqlite3SelectSetName(pFrom->pSelect, pTab->zName);\n        nCol = pTab->nCol;\n        pTab->nCol = -1;\n        sqlite3WalkSelect(pWalker, pFrom->pSelect);\n        pTab->nCol = nCol;\n      }\n#endif\n    }\n\n    /* Locate the index named by the INDEXED BY clause, if any. */\n    if( sqlite3IndexedByLookup(pParse, pFrom) ){\n      return WRC_Abort;\n    }\n  }\n\n  /* Process NATURAL keywords, and ON and USING clauses of joins.\n  */\n  if( db->mallocFailed || sqliteProcessJoin(pParse, p) ){\n    return WRC_Abort;\n  }\n\n  /* For every \"*\" that occurs in the column list, insert the names of\n  ** all columns in all tables.  And for every TABLE.* insert the names\n  ** of all columns in TABLE.  The parser inserted a special expression\n  ** with the TK_ASTERISK operator for each \"*\" that it found in the column\n  ** list.  The following code just has to locate the TK_ASTERISK\n  ** expressions and expand each one to the list of all columns in\n  ** all tables.\n  **\n  ** The first loop just checks to see if there are any \"*\" operators\n  ** that need expanding.\n  */\n  for(k=0; k<pEList->nExpr; k++){\n    pE = pEList->a[k].pExpr;\n    if( pE->op==TK_ASTERISK ) break;\n    assert( pE->op!=TK_DOT || pE->pRight!=0 );\n    assert( pE->op!=TK_DOT || (pE->pLeft!=0 && pE->pLeft->op==TK_ID) );\n    if( pE->op==TK_DOT && pE->pRight->op==TK_ASTERISK ) break;\n  }\n  if( k<pEList->nExpr ){\n    /*\n    ** If we get here it means the result set contains one or more \"*\"\n    ** operators that need to be expanded.  Loop through each expression\n    ** in the result set and expand them one by one.\n    */\n    struct ExprList_item *a = pEList->a;\n    ExprList *pNew = 0;\n    int flags = pParse->db->flags;\n    int longNames = (flags & SQLITE_FullColNames)!=0\n                      && (flags & SQLITE_ShortColNames)==0;\n\n    for(k=0; k<pEList->nExpr; k++){\n      pE = a[k].pExpr;\n      pRight = pE->pRight;\n      assert( pE->op!=TK_DOT || pRight!=0 );\n      if( pE->op!=TK_ASTERISK\n       && (pE->op!=TK_DOT || pRight->op!=TK_ASTERISK)\n      ){\n        /* This particular expression does not need to be expanded.\n        */\n        pNew = sqlite3ExprListAppend(pParse, pNew, a[k].pExpr);\n        if( pNew ){\n          pNew->a[pNew->nExpr-1].zName = a[k].zName;\n          pNew->a[pNew->nExpr-1].zSpan = a[k].zSpan;\n          a[k].zName = 0;\n          a[k].zSpan = 0;\n        }\n        a[k].pExpr = 0;\n      }else{\n        /* This expression is a \"*\" or a \"TABLE.*\" and needs to be\n        ** expanded. */\n        int tableSeen = 0;      /* Set to 1 when TABLE matches */\n        char *zTName = 0;       /* text of name of TABLE */\n        if( pE->op==TK_DOT ){\n          assert( pE->pLeft!=0 );\n          assert( !ExprHasProperty(pE->pLeft, EP_IntValue) );\n          zTName = pE->pLeft->u.zToken;\n        }\n        for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n          Table *pTab = pFrom->pTab;\n          Select *pSub = pFrom->pSelect;\n          char *zTabName = pFrom->zAlias;\n          const char *zSchemaName = 0;\n          int iDb;\n          if( zTabName==0 ){\n            zTabName = pTab->zName;\n          }\n          if( db->mallocFailed ) break;\n          if( pSub==0 || (pSub->selFlags & SF_NestedFrom)==0 ){\n            pSub = 0;\n            if( zTName && sqlite3StrICmp(zTName, zTabName)!=0 ){\n              continue;\n            }\n            iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n            zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : \"*\";\n          }\n          for(j=0; j<pTab->nCol; j++){\n            char *zName = pTab->aCol[j].zName;\n            char *zColname;  /* The computed column name */\n            char *zToFree;   /* Malloced string that needs to be freed */\n            Token sColname;  /* Computed column name as a token */\n\n            assert( zName );\n            if( zTName && pSub\n             && sqlite3MatchSpanName(pSub->pEList->a[j].zSpan, 0, zTName, 0)==0\n            ){\n              continue;\n            }\n\n            /* If a column is marked as 'hidden', omit it from the expanded\n            ** result-set list unless the SELECT has the SF_IncludeHidden\n            ** bit set.\n            */\n            if( (p->selFlags & SF_IncludeHidden)==0\n             && IsHiddenColumn(&pTab->aCol[j]) \n            ){\n              continue;\n            }\n            tableSeen = 1;\n\n            if( i>0 && zTName==0 ){\n              if( (pFrom->fg.jointype & JT_NATURAL)!=0\n                && tableAndColumnIndex(pTabList, i, zName, 0, 0)\n              ){\n                /* In a NATURAL join, omit the join columns from the \n                ** table to the right of the join */\n                continue;\n              }\n              if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){\n                /* In a join with a USING clause, omit columns in the\n                ** using clause from the table on the right. */\n                continue;\n              }\n            }\n            pRight = sqlite3Expr(db, TK_ID, zName);\n            zColname = zName;\n            zToFree = 0;\n            if( longNames || pTabList->nSrc>1 ){\n              Expr *pLeft;\n              pLeft = sqlite3Expr(db, TK_ID, zTabName);\n              pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);\n              if( zSchemaName ){\n                pLeft = sqlite3Expr(db, TK_ID, zSchemaName);\n                pExpr = sqlite3PExpr(pParse, TK_DOT, pLeft, pExpr);\n              }\n              if( longNames ){\n                zColname = sqlite3MPrintf(db, \"%s.%s\", zTabName, zName);\n                zToFree = zColname;\n              }\n            }else{\n              pExpr = pRight;\n            }\n            pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);\n            sqlite3TokenInit(&sColname, zColname);\n            sqlite3ExprListSetName(pParse, pNew, &sColname, 0);\n            if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){\n              struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];\n              if( pSub ){\n                pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);\n                testcase( pX->zSpan==0 );\n              }else{\n                pX->zSpan = sqlite3MPrintf(db, \"%s.%s.%s\",\n                                           zSchemaName, zTabName, zColname);\n                testcase( pX->zSpan==0 );\n              }\n              pX->bSpanIsTab = 1;\n            }\n            sqlite3DbFree(db, zToFree);\n          }\n        }\n        if( !tableSeen ){\n          if( zTName ){\n            sqlite3ErrorMsg(pParse, \"no such table: %s\", zTName);\n          }else{\n            sqlite3ErrorMsg(pParse, \"no tables specified\");\n          }\n        }\n      }\n    }\n    sqlite3ExprListDelete(db, pEList);\n    p->pEList = pNew;\n  }\n  if( p->pEList && p->pEList->nExpr>db->aLimit[SQLITE_LIMIT_COLUMN] ){\n    sqlite3ErrorMsg(pParse, \"too many columns in result set\");\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker.\n**\n** When this routine is the Walker.xExprCallback then expression trees\n** are walked without any actions being taken at each node.  Presumably,\n** when this routine is used for Walker.xExprCallback then \n** Walker.xSelectCallback is set to do something useful for every \n** subquery in the parser tree.\n*/\nint sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n/*\n** No-op routine for the parse-tree walker for SELECT statements.\n** subquery in the parser tree.\n*/\nint sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  return WRC_Continue;\n}\n\n#if SQLITE_DEBUG\n/*\n** Always assert.  This xSelectCallback2 implementation proves that the\n** xSelectCallback2 is never invoked.\n*/\nvoid sqlite3SelectWalkAssert2(Walker *NotUsed, Select *NotUsed2){\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  assert( 0 );\n}\n#endif\n/*\n** This routine \"expands\" a SELECT statement and all of its subqueries.\n** For additional information on what it means to \"expand\" a SELECT\n** statement, see the comment on the selectExpand worker callback above.\n**\n** Expanding a SELECT statement is the first step in processing a\n** SELECT statement.  The SELECT statement must be expanded before\n** name resolution is performed.\n**\n** If anything goes wrong, an error message is written into pParse.\n** The calling function can detect the problem by looking at pParse->nErr\n** and/or pParse->db->mallocFailed.\n*/\nstatic void sqlite3SelectExpand(Parse *pParse, Select *pSelect){\n  Walker w;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  if( OK_IF_ALWAYS_TRUE(pParse->hasCompound) ){\n    w.xSelectCallback = convertCompoundSelectToSubquery;\n    w.xSelectCallback2 = 0;\n    sqlite3WalkSelect(&w, pSelect);\n  }\n  w.xSelectCallback = selectExpander;\n  w.xSelectCallback2 = selectPopWith;\n  sqlite3WalkSelect(&w, pSelect);\n}\n\n\n#ifndef SQLITE_OMIT_SUBQUERY\n/*\n** This is a Walker.xSelectCallback callback for the sqlite3SelectTypeInfo()\n** interface.\n**\n** For each FROM-clause subquery, add Column.zType and Column.zColl\n** information to the Table structure that represents the result set\n** of that subquery.\n**\n** The Table structure that represents the result set was constructed\n** by selectExpander() but the type and collation information was omitted\n** at that point because identifiers had not yet been resolved.  This\n** routine is called after identifier resolution.\n*/\nstatic void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){\n  Parse *pParse;\n  int i;\n  SrcList *pTabList;\n  struct SrcList_item *pFrom;\n\n  assert( p->selFlags & SF_Resolved );\n  assert( (p->selFlags & SF_HasTypeInfo)==0 );\n  p->selFlags |= SF_HasTypeInfo;\n  pParse = pWalker->pParse;\n  pTabList = p->pSrc;\n  for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){\n    Table *pTab = pFrom->pTab;\n    assert( pTab!=0 );\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 ){\n      /* A sub-query in the FROM clause of a SELECT */\n      Select *pSel = pFrom->pSelect;\n      if( pSel ){\n        while( pSel->pPrior ) pSel = pSel->pPrior;\n        sqlite3SelectAddColumnTypeAndCollation(pParse, pTab, pSel);\n      }\n    }\n  }\n}\n#endif\n\n\n/*\n** This routine adds datatype and collating sequence information to\n** the Table structures of all FROM-clause subqueries in a\n** SELECT statement.\n**\n** Use this routine after name resolution.\n*/\nstatic void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){\n#ifndef SQLITE_OMIT_SUBQUERY\n  Walker w;\n  w.xSelectCallback = sqlite3SelectWalkNoop;\n  w.xSelectCallback2 = selectAddSubqueryTypeInfo;\n  w.xExprCallback = sqlite3ExprWalkNoop;\n  w.pParse = pParse;\n  sqlite3WalkSelect(&w, pSelect);\n#endif\n}\n\n\n/*\n** This routine sets up a SELECT statement for processing.  The\n** following is accomplished:\n**\n**     *  VDBE Cursor numbers are assigned to all FROM-clause terms.\n**     *  Ephemeral Table objects are created for all FROM-clause subqueries.\n**     *  ON and USING clauses are shifted into WHERE statements\n**     *  Wildcards \"*\" and \"TABLE.*\" in result sets are expanded.\n**     *  Identifiers in expression are matched to tables.\n**\n** This routine acts recursively on all subqueries within the SELECT.\n*/\nvoid sqlite3SelectPrep(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  NameContext *pOuterNC  /* Name context for container */\n){\n  assert( p!=0 || pParse->db->mallocFailed );\n  if( pParse->db->mallocFailed ) return;\n  if( p->selFlags & SF_HasTypeInfo ) return;\n  sqlite3SelectExpand(pParse, p);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3ResolveSelectNames(pParse, p, pOuterNC);\n  if( pParse->nErr || pParse->db->mallocFailed ) return;\n  sqlite3SelectAddTypeInfo(pParse, p);\n}\n\n/*\n** Reset the aggregate accumulator.\n**\n** The aggregate accumulator is a set of memory cells that hold\n** intermediate results while calculating an aggregate.  This\n** routine generates code that stores NULLs in all of those memory\n** cells.\n*/\nstatic void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pFunc;\n  int nReg = pAggInfo->nFunc + pAggInfo->nColumn;\n  if( nReg==0 ) return;\n#ifdef SQLITE_DEBUG\n  /* Verify that all AggInfo registers are within the range specified by\n  ** AggInfo.mnReg..AggInfo.mxReg */\n  assert( nReg==pAggInfo->mxReg-pAggInfo->mnReg+1 );\n  for(i=0; i<pAggInfo->nColumn; i++){\n    assert( pAggInfo->aCol[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aCol[i].iMem<=pAggInfo->mxReg );\n  }\n  for(i=0; i<pAggInfo->nFunc; i++){\n    assert( pAggInfo->aFunc[i].iMem>=pAggInfo->mnReg\n         && pAggInfo->aFunc[i].iMem<=pAggInfo->mxReg );\n  }\n#endif\n  sqlite3VdbeAddOp3(v, OP_Null, 0, pAggInfo->mnReg, pAggInfo->mxReg);\n  for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){\n    if( pFunc->iDistinct>=0 ){\n      Expr *pE = pFunc->pExpr;\n      assert( !ExprHasProperty(pE, EP_xIsSelect) );\n      if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){\n        sqlite3ErrorMsg(pParse, \"DISTINCT aggregates must have exactly one \"\n           \"argument\");\n        pFunc->iDistinct = -1;\n      }else{\n        KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList, 0, 0);\n        sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0,\n                          (char*)pKeyInfo, P4_KEYINFO);\n      }\n    }\n  }\n}\n\n/*\n** Invoke the OP_AggFinalize opcode for every aggregate function\n** in the AggInfo structure.\n*/\nstatic void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  struct AggInfo_func *pF;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n  }\n}\n\n/*\n** Update the accumulator memory cells for an aggregate based on\n** the current cursor position.\n*/\nstatic void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  int regHit = 0;\n  int addrHitTest = 0;\n  struct AggInfo_func *pF;\n  struct AggInfo_col *pC;\n\n  pAggInfo->directMode = 1;\n  for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){\n    int nArg;\n    int addrNext = 0;\n    int regAgg;\n    ExprList *pList = pF->pExpr->x.pList;\n    assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) );\n    if( pList ){\n      nArg = pList->nExpr;\n      regAgg = sqlite3GetTempRange(pParse, nArg);\n      sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP);\n    }else{\n      nArg = 0;\n      regAgg = 0;\n    }\n    if( pF->iDistinct>=0 ){\n      addrNext = sqlite3VdbeMakeLabel(v);\n      testcase( nArg==0 );  /* Error condition */\n      testcase( nArg>1 );   /* Also an error */\n      codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);\n    }\n    if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){\n      CollSeq *pColl = 0;\n      struct ExprList_item *pItem;\n      int j;\n      assert( pList!=0 );  /* pList!=0 if pF->pFunc has NEEDCOLL */\n      for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){\n        pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);\n      }\n      if( !pColl ){\n        pColl = pParse->db->pDfltColl;\n      }\n      if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem;\n      sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ);\n    }\n    sqlite3VdbeAddOp3(v, OP_AggStep0, 0, regAgg, pF->iMem);\n    sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);\n    sqlite3VdbeChangeP5(v, (u8)nArg);\n    sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);\n    sqlite3ReleaseTempRange(pParse, regAgg, nArg);\n    if( addrNext ){\n      sqlite3VdbeResolveLabel(v, addrNext);\n      sqlite3ExprCacheClear(pParse);\n    }\n  }\n\n  /* Before populating the accumulator registers, clear the column cache.\n  ** Otherwise, if any of the required column values are already present \n  ** in registers, sqlite3ExprCode() may use OP_SCopy to copy the value\n  ** to pC->iMem. But by the time the value is used, the original register\n  ** may have been used, invalidating the underlying buffer holding the\n  ** text or blob value. See ticket [883034dcb5].\n  **\n  ** Another solution would be to change the OP_SCopy used to copy cached\n  ** values to an OP_Copy.\n  */\n  if( regHit ){\n    addrHitTest = sqlite3VdbeAddOp1(v, OP_If, regHit); VdbeCoverage(v);\n  }\n  sqlite3ExprCacheClear(pParse);\n  for(i=0, pC=pAggInfo->aCol; i<pAggInfo->nAccumulator; i++, pC++){\n    sqlite3ExprCode(pParse, pC->pExpr, pC->iMem);\n  }\n  pAggInfo->directMode = 0;\n  sqlite3ExprCacheClear(pParse);\n  if( addrHitTest ){\n    sqlite3VdbeJumpHere(v, addrHitTest);\n  }\n}\n\n/*\n** Add a single OP_Explain instruction to the VDBE to explain a simple\n** count(*) query (\"SELECT count(*) FROM pTab\").\n*/\n#ifndef SQLITE_OMIT_EXPLAIN\nstatic void explainSimpleCount(\n  Parse *pParse,                  /* Parse context */\n  Table *pTab,                    /* Table being queried */\n  Index *pIdx                     /* Index used to optimize scan, or NULL */\n){\n  if( pParse->explain==2 ){\n    int bCover = (pIdx!=0 && (HasRowid(pTab) || !IsPrimaryKeyIndex(pIdx)));\n    char *zEqp = sqlite3MPrintf(pParse->db, \"SCAN TABLE %s%s%s\",\n        pTab->zName,\n        bCover ? \" USING COVERING INDEX \" : \"\",\n        bCover ? pIdx->zName : \"\"\n    );\n    sqlite3VdbeAddOp4(\n        pParse->pVdbe, OP_Explain, pParse->iSelectId, 0, 0, zEqp, P4_DYNAMIC\n    );\n  }\n}\n#else\n# define explainSimpleCount(a,b,c)\n#endif\n\n/*\n** Context object for havingToWhereExprCb().\n*/\nstruct HavingToWhereCtx {\n  Expr **ppWhere;\n  ExprList *pGroupBy;\n};\n\n/*\n** sqlite3WalkExpr() callback used by havingToWhere().\n**\n** If the node passed to the callback is a TK_AND node, return \n** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes.\n**\n** Otherwise, return WRC_Prune. In this case, also check if the \n** sub-expression matches the criteria for being moved to the WHERE\n** clause. If so, add it to the WHERE clause and replace the sub-expression\n** within the HAVING expression with a constant \"1\".\n*/\nstatic int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op!=TK_AND ){\n    struct HavingToWhereCtx *p = pWalker->u.pHavingCtx;\n    if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){\n      sqlite3 *db = pWalker->pParse->db;\n      Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0);\n      if( pNew ){\n        Expr *pWhere = *(p->ppWhere);\n        SWAP(Expr, *pNew, *pExpr);\n        pNew = sqlite3ExprAnd(db, pWhere, pNew);\n        *(p->ppWhere) = pNew;\n      }\n    }\n    return WRC_Prune;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Transfer eligible terms from the HAVING clause of a query, which is\n** processed after grouping, to the WHERE clause, which is processed before\n** grouping. For example, the query:\n**\n**   SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=?\n**\n** can be rewritten as:\n**\n**   SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=?\n**\n** A term of the HAVING expression is eligible for transfer if it consists\n** entirely of constants and expressions that are also GROUP BY terms that\n** use the \"BINARY\" collation sequence.\n*/\nstatic void havingToWhere(\n  Parse *pParse,\n  ExprList *pGroupBy,\n  Expr *pHaving, \n  Expr **ppWhere\n){\n  struct HavingToWhereCtx sCtx;\n  Walker sWalker;\n\n  sCtx.ppWhere = ppWhere;\n  sCtx.pGroupBy = pGroupBy;\n\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.xExprCallback = havingToWhereExprCb;\n  sWalker.u.pHavingCtx = &sCtx;\n  sqlite3WalkExpr(&sWalker, pHaving);\n}\n\n/*\n** Check to see if the pThis entry of pTabList is a self-join of a prior view.\n** If it is, then return the SrcList_item for the prior view.  If it is not,\n** then return 0.\n*/\nstatic struct SrcList_item *isSelfJoinView(\n  SrcList *pTabList,           /* Search for self-joins in this FROM clause */\n  struct SrcList_item *pThis   /* Search for prior reference to this subquery */\n){\n  struct SrcList_item *pItem;\n  for(pItem = pTabList->a; pItem<pThis; pItem++){\n    if( pItem->pSelect==0 ) continue;\n    if( pItem->fg.viaCoroutine ) continue;\n    if( pItem->zName==0 ) continue;\n    if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;\n    if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;\n    if( sqlite3ExprCompare(0, \n          pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) \n    ){\n      /* The view was modified by some other optimization such as\n      ** pushDownWhereTerms() */\n      continue;\n    }\n    return pItem;\n  }\n  return 0;\n}\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n/*\n** Attempt to transform a query of the form\n**\n**    SELECT count(*) FROM (SELECT x FROM t1 UNION ALL SELECT y FROM t2)\n**\n** Into this:\n**\n**    SELECT (SELECT count(*) FROM t1)+(SELECT count(*) FROM t2)\n**\n** The transformation only works if all of the following are true:\n**\n**   *  The subquery is a UNION ALL of two or more terms\n**   *  There is no WHERE or GROUP BY or HAVING clauses on the subqueries\n**   *  The outer query is a simple count(*)\n**\n** Return TRUE if the optimization is undertaken.\n*/\nstatic int countOfViewOptimization(Parse *pParse, Select *p){\n  Select *pSub, *pPrior;\n  Expr *pExpr;\n  Expr *pCount;\n  sqlite3 *db;\n  if( (p->selFlags & SF_Aggregate)==0 ) return 0;   /* This is an aggregate */\n  if( p->pEList->nExpr!=1 ) return 0;               /* Single result column */\n  pExpr = p->pEList->a[0].pExpr;\n  if( pExpr->op!=TK_AGG_FUNCTION ) return 0;        /* Result is an aggregate */\n  if( sqlite3_stricmp(pExpr->u.zToken,\"count\") ) return 0;  /* Is count() */\n  if( pExpr->x.pList!=0 ) return 0;                 /* Must be count(*) */\n  if( p->pSrc->nSrc!=1 ) return 0;                  /* One table in FROM  */\n  pSub = p->pSrc->a[0].pSelect;\n  if( pSub==0 ) return 0;                           /* The FROM is a subquery */\n  if( pSub->pPrior==0 ) return 0;                   /* Must be a compound ry */\n  do{\n    if( pSub->op!=TK_ALL && pSub->pPrior ) return 0;  /* Must be UNION ALL */\n    if( pSub->pWhere ) return 0;                      /* No WHERE clause */\n    if( pSub->selFlags & SF_Aggregate ) return 0;     /* Not an aggregate */\n    pSub = pSub->pPrior;                              /* Repeat over compound */\n  }while( pSub );\n\n  /* If we reach this point then it is OK to perform the transformation */\n\n  db = pParse->db;\n  pCount = pExpr;\n  pExpr = 0;\n  pSub = p->pSrc->a[0].pSelect;\n  p->pSrc->a[0].pSelect = 0;\n  sqlite3SrcListDelete(db, p->pSrc);\n  p->pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*p->pSrc));\n  while( pSub ){\n    Expr *pTerm;\n    pPrior = pSub->pPrior;\n    pSub->pPrior = 0;\n    pSub->pNext = 0;\n    pSub->selFlags |= SF_Aggregate;\n    pSub->selFlags &= ~SF_Compound;\n    pSub->nSelectRow = 0;\n    sqlite3ExprListDelete(db, pSub->pEList);\n    pTerm = pPrior ? sqlite3ExprDup(db, pCount, 0) : pCount;\n    pSub->pEList = sqlite3ExprListAppend(pParse, 0, pTerm);\n    pTerm = sqlite3PExpr(pParse, TK_SELECT, 0, 0);\n    sqlite3PExprAddSelect(pParse, pTerm, pSub);\n    if( pExpr==0 ){\n      pExpr = pTerm;\n    }else{\n      pExpr = sqlite3PExpr(pParse, TK_PLUS, pTerm, pExpr);\n    }\n    pSub = pPrior;\n  }\n  p->pEList->a[0].pExpr = pExpr;\n  p->selFlags &= ~SF_Aggregate;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After count-of-view optimization:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n  return 1;\n}\n#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */\n\n/*\n** Generate code for the SELECT statement given in the p argument.  \n**\n** The results are returned according to the SelectDest structure.\n** See comments in sqliteInt.h for further information.\n**\n** This routine returns the number of errors.  If any errors are\n** encountered, then an appropriate error message is left in\n** pParse->zErrMsg.\n**\n** This routine does NOT free the Select structure passed in.  The\n** calling function needs to do that.\n*/\nint sqlite3Select(\n  Parse *pParse,         /* The parser context */\n  Select *p,             /* The SELECT statement being coded. */\n  SelectDest *pDest      /* What to do with the query results */\n){\n  int i, j;              /* Loop counters */\n  WhereInfo *pWInfo;     /* Return from sqlite3WhereBegin() */\n  Vdbe *v;               /* The virtual machine under construction */\n  int isAgg;             /* True for select lists like \"count(*)\" */\n  ExprList *pEList = 0;  /* List of columns to extract. */\n  SrcList *pTabList;     /* List of tables to select from */\n  Expr *pWhere;          /* The WHERE clause.  May be NULL */\n  ExprList *pGroupBy;    /* The GROUP BY clause.  May be NULL */\n  Expr *pHaving;         /* The HAVING clause.  May be NULL */\n  int rc = 1;            /* Value to return from this function */\n  DistinctCtx sDistinct; /* Info on how to code the DISTINCT keyword */\n  SortCtx sSort;         /* Info on how to code the ORDER BY clause */\n  AggInfo sAggInfo;      /* Information used by aggregate queries */\n  int iEnd;              /* Address of the end of the query */\n  sqlite3 *db;           /* The database connection */\n\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iRestoreSelectId = pParse->iSelectId;\n  pParse->iSelectId = pParse->iNextSelectId++;\n#endif\n\n  db = pParse->db;\n  if( p==0 || db->mallocFailed || pParse->nErr ){\n    return 1;\n  }\n  if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;\n  memset(&sAggInfo, 0, sizeof(sAggInfo));\n#if SELECTTRACE_ENABLED\n  pParse->nSelectIndent++;\n  SELECTTRACE(1,pParse,p, (\"begin processing:\\n\"));\n  if( sqlite3SelectTrace & 0x100 ){\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue );\n  assert( p->pOrderBy==0 || pDest->eDest!=SRT_Queue );\n  if( IgnorableOrderby(pDest) ){\n    assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union || \n           pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||\n           pDest->eDest==SRT_Queue  || pDest->eDest==SRT_DistFifo ||\n           pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);\n    /* If ORDER BY makes no difference in the output then neither does\n    ** DISTINCT so it can be removed too. */\n    sqlite3ExprListDelete(db, p->pOrderBy);\n    p->pOrderBy = 0;\n    p->selFlags &= ~SF_Distinct;\n  }\n  sqlite3SelectPrep(pParse, p, 0);\n  memset(&sSort, 0, sizeof(sSort));\n  sSort.pOrderBy = p->pOrderBy;\n  pTabList = p->pSrc;\n  if( pParse->nErr || db->mallocFailed ){\n    goto select_end;\n  }\n  assert( p->pEList!=0 );\n  isAgg = (p->selFlags & SF_Aggregate)!=0;\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x100 ){\n    SELECTTRACE(0x100,pParse,p, (\"after name resolution:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n  /* Get a pointer the VDBE under construction, allocating a new VDBE if one\n  ** does not already exist */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto select_end;\n  if( pDest->eDest==SRT_Output ){\n    generateColumnNames(pParse, p);\n  }\n\n  /* Try to flatten subqueries in the FROM clause up into the main query\n  */\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    Select *pSub = pItem->pSelect;\n    Table *pTab = pItem->pTab;\n    if( pSub==0 ) continue;\n\n    /* Catch mismatch in the declared columns of a view and the number of\n    ** columns in the SELECT on the RHS */\n    if( pTab->nCol!=pSub->pEList->nExpr ){\n      sqlite3ErrorMsg(pParse, \"expected %d columns for '%s' but got %d\",\n                      pTab->nCol, pTab->zName, pSub->pEList->nExpr);\n      goto select_end;\n    }\n\n    /* Do not try to flatten an aggregate subquery.\n    **\n    ** Flattening an aggregate subquery is only possible if the outer query\n    ** is not a join.  But if the outer query is not a join, then the subquery\n    ** will be implemented as a co-routine and there is no advantage to\n    ** flattening in that case.\n    */\n    if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;\n    assert( pSub->pGroupBy==0 );\n\n    /* If the subquery contains an ORDER BY clause and if\n    ** it will be implemented as a co-routine, then do not flatten.  This\n    ** restriction allows SQL constructs like this:\n    **\n    **  SELECT expensive_function(x)\n    **    FROM (SELECT x FROM tab ORDER BY y LIMIT 10);\n    **\n    ** The expensive_function() is only computed on the 10 rows that\n    ** are output, rather than every row of the table.\n    */\n    if( pSub->pOrderBy!=0\n     && i==0\n     && (pTabList->nSrc==1\n         || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)\n    ){\n      continue;\n    }\n\n    if( flattenSubquery(pParse, p, i, isAgg) ){\n      /* This subquery can be absorbed into its parent. */\n      i = -1;\n    }\n    pTabList = p->pSrc;\n    if( db->mallocFailed ) goto select_end;\n    if( !IgnorableOrderby(pDest) ){\n      sSort.pOrderBy = p->pOrderBy;\n    }\n  }\n#endif\n\n#ifndef SQLITE_OMIT_COMPOUND_SELECT\n  /* Handle compound SELECT statements using the separate multiSelect()\n  ** procedure.\n  */\n  if( p->pPrior ){\n    rc = multiSelect(pParse, p, pDest);\n    explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n#if SELECTTRACE_ENABLED\n    SELECTTRACE(1,pParse,p,(\"end compound-select processing\\n\"));\n    pParse->nSelectIndent--;\n#endif\n    return rc;\n  }\n#endif\n\n  /* For each term in the FROM clause, do two things:\n  ** (1) Authorized unreferenced tables\n  ** (2) Generate code for all sub-queries\n  */\n  for(i=0; i<pTabList->nSrc; i++){\n    struct SrcList_item *pItem = &pTabList->a[i];\n    SelectDest dest;\n    Select *pSub;\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    const char *zSavedAuthContext;\n#endif\n\n    /* Issue SQLITE_READ authorizations with a fake column name for any\n    ** tables that are referenced but from which no values are extracted.\n    ** Examples of where these kinds of null SQLITE_READ authorizations\n    ** would occur:\n    **\n    **     SELECT count(*) FROM t1;   -- SQLITE_READ t1.\"\"\n    **     SELECT t1.* FROM t1, t2;   -- SQLITE_READ t2.\"\"\n    **\n    ** The fake column name is an empty string.  It is possible for a table to\n    ** have a column named by the empty string, in which case there is no way to\n    ** distinguish between an unreferenced table and an actual reference to the\n    ** \"\" column. The original design was for the fake column name to be a NULL,\n    ** which would be unambiguous.  But legacy authorization callbacks might\n    ** assume the column name is non-NULL and segfault.  The use of an empty\n    ** string for the fake column name seems safer.\n    */\n    if( pItem->colUsed==0 ){\n      sqlite3AuthCheck(pParse, SQLITE_READ, pItem->zName, \"\", pItem->zDatabase);\n    }\n\n#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)\n    /* Generate code for all sub-queries in the FROM clause\n    */\n    pSub = pItem->pSelect;\n    if( pSub==0 ) continue;\n\n    /* Sometimes the code for a subquery will be generated more than\n    ** once, if the subquery is part of the WHERE clause in a LEFT JOIN,\n    ** for example.  In that case, do not regenerate the code to manifest\n    ** a view or the co-routine to implement a view.  The first instance\n    ** is sufficient, though the subroutine to manifest the view does need\n    ** to be invoked again. */\n    if( pItem->addrFillSub ){\n      if( pItem->fg.viaCoroutine==0 ){\n        /* The subroutine that manifests the view might be a one-time routine,\n        ** or it might need to be rerun on each iteration because it\n        ** encodes a correlated subquery. */\n        testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once );\n        sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub);\n      }\n      continue;\n    }\n\n    /* Increment Parse.nHeight by the height of the largest expression\n    ** tree referred to by this, the parent select. The child select\n    ** may contain expression trees of at most\n    ** (SQLITE_MAX_EXPR_DEPTH-Parse.nHeight) height. This is a bit\n    ** more conservative than necessary, but much easier than enforcing\n    ** an exact limit.\n    */\n    pParse->nHeight += sqlite3SelectExprHeight(p);\n\n    /* Make copies of constant WHERE-clause terms in the outer query down\n    ** inside the subquery.  This can help the subquery to run more efficiently.\n    */\n    if( (pItem->fg.jointype & JT_OUTER)==0\n     && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor)\n    ){\n#if SELECTTRACE_ENABLED\n      if( sqlite3SelectTrace & 0x100 ){\n        SELECTTRACE(0x100,pParse,p,(\"After WHERE-clause push-down:\\n\"));\n        sqlite3TreeViewSelect(0, p, 0);\n      }\n#endif\n    }\n\n    zSavedAuthContext = pParse->zAuthContext;\n    pParse->zAuthContext = pItem->zName;\n\n    /* Generate code to implement the subquery\n    **\n    ** The subquery is implemented as a co-routine if the subquery is\n    ** guaranteed to be the outer loop (so that it does not need to be\n    ** computed more than once)\n    **\n    ** TODO: Are there other reasons beside (1) to use a co-routine\n    ** implementation?\n    */\n    if( i==0\n     && (pTabList->nSrc==1\n            || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0)  /* (1) */\n    ){\n      /* Implement a co-routine that will return a single row of the result\n      ** set on each invocation.\n      */\n      int addrTop = sqlite3VdbeCurrentAddr(v)+1;\n     \n      pItem->regReturn = ++pParse->nMem;\n      sqlite3VdbeAddOp3(v, OP_InitCoroutine, pItem->regReturn, 0, addrTop);\n      VdbeComment((v, \"%s\", pItem->pTab->zName));\n      pItem->addrFillSub = addrTop;\n      sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn);\n      explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n      sqlite3Select(pParse, pSub, &dest);\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      pItem->fg.viaCoroutine = 1;\n      pItem->regResult = dest.iSdst;\n      sqlite3VdbeEndCoroutine(v, pItem->regReturn);\n      sqlite3VdbeJumpHere(v, addrTop-1);\n      sqlite3ClearTempRegCache(pParse);\n    }else{\n      /* Generate a subroutine that will fill an ephemeral table with\n      ** the content of this subquery.  pItem->addrFillSub will point\n      ** to the address of the generated subroutine.  pItem->regReturn\n      ** is a register allocated to hold the subroutine return address\n      */\n      int topAddr;\n      int onceAddr = 0;\n      int retAddr;\n      struct SrcList_item *pPrior;\n\n      assert( pItem->addrFillSub==0 );\n      pItem->regReturn = ++pParse->nMem;\n      topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn);\n      pItem->addrFillSub = topAddr+1;\n      if( pItem->fg.isCorrelated==0 ){\n        /* If the subquery is not correlated and if we are not inside of\n        ** a trigger, then we only need to compute the value of the subquery\n        ** once. */\n        onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n        VdbeComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }else{\n        VdbeNoopComment((v, \"materialize \\\"%s\\\"\", pItem->pTab->zName));\n      }\n      pPrior = isSelfJoinView(pTabList, pItem);\n      if( pPrior ){\n        sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor);\n        explainSetInteger(pItem->iSelectId, pPrior->iSelectId);\n        assert( pPrior->pSelect!=0 );\n        pSub->nSelectRow = pPrior->pSelect->nSelectRow;\n      }else{\n        sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor);\n        explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId);\n        sqlite3Select(pParse, pSub, &dest);\n      }\n      pItem->pTab->nRowLogEst = pSub->nSelectRow;\n      if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr);\n      retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn);\n      VdbeComment((v, \"end %s\", pItem->pTab->zName));\n      sqlite3VdbeChangeP1(v, topAddr, retAddr);\n      sqlite3ClearTempRegCache(pParse);\n    }\n    if( db->mallocFailed ) goto select_end;\n    pParse->nHeight -= sqlite3SelectExprHeight(p);\n    pParse->zAuthContext = zSavedAuthContext;\n#endif\n  }\n\n  /* Various elements of the SELECT copied into local variables for\n  ** convenience */\n  pEList = p->pEList;\n  pWhere = p->pWhere;\n  pGroupBy = p->pGroupBy;\n  pHaving = p->pHaving;\n  sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0;\n\n#if SELECTTRACE_ENABLED\n  if( sqlite3SelectTrace & 0x400 ){\n    SELECTTRACE(0x400,pParse,p,(\"After all FROM-clause analysis:\\n\"));\n    sqlite3TreeViewSelect(0, p, 0);\n  }\n#endif\n\n#ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION\n  if( OptimizationEnabled(db, SQLITE_QueryFlattener|SQLITE_CountOfView)\n   && countOfViewOptimization(pParse, p)\n  ){\n    if( db->mallocFailed ) goto select_end;\n    pEList = p->pEList;\n    pTabList = p->pSrc;\n  }\n#endif\n\n  /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and \n  ** if the select-list is the same as the ORDER BY list, then this query\n  ** can be rewritten as a GROUP BY. In other words, this:\n  **\n  **     SELECT DISTINCT xyz FROM ... ORDER BY xyz\n  **\n  ** is transformed to:\n  **\n  **     SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz\n  **\n  ** The second form is preferred as a single index (or temp-table) may be \n  ** used for both the ORDER BY and DISTINCT processing. As originally \n  ** written the query must use a temp-table for at least one of the ORDER \n  ** BY and DISTINCT, and an index or separate temp-table for the other.\n  */\n  if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct \n   && sqlite3ExprListCompare(sSort.pOrderBy, pEList, -1)==0\n  ){\n    p->selFlags &= ~SF_Distinct;\n    pGroupBy = p->pGroupBy = sqlite3ExprListDup(db, pEList, 0);\n    /* Notice that even thought SF_Distinct has been cleared from p->selFlags,\n    ** the sDistinct.isTnct is still set.  Hence, isTnct represents the\n    ** original setting of the SF_Distinct flag, not the current setting */\n    assert( sDistinct.isTnct );\n\n#if SELECTTRACE_ENABLED\n    if( sqlite3SelectTrace & 0x400 ){\n      SELECTTRACE(0x400,pParse,p,(\"Transform DISTINCT into GROUP BY:\\n\"));\n      sqlite3TreeViewSelect(0, p, 0);\n    }\n#endif\n  }\n\n  /* If there is an ORDER BY clause, then create an ephemeral index to\n  ** do the sorting.  But this sorting ephemeral index might end up\n  ** being unused if the data can be extracted in pre-sorted order.\n  ** If that is the case, then the OP_OpenEphemeral instruction will be\n  ** changed to an OP_Noop once we figure out that the sorting index is\n  ** not needed.  The sSort.addrSortIndex variable is used to facilitate\n  ** that change.\n  */\n  if( sSort.pOrderBy ){\n    KeyInfo *pKeyInfo;\n    pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);\n    sSort.iECursor = pParse->nTab++;\n    sSort.addrSortIndex =\n      sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n          sSort.iECursor, sSort.pOrderBy->nExpr+1+pEList->nExpr, 0,\n          (char*)pKeyInfo, P4_KEYINFO\n      );\n  }else{\n    sSort.addrSortIndex = -1;\n  }\n\n  /* If the output is destined for a temporary table, open that table.\n  */\n  if( pDest->eDest==SRT_EphemTab ){\n    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr);\n  }\n\n  /* Set the limiter.\n  */\n  iEnd = sqlite3VdbeMakeLabel(v);\n  if( (p->selFlags & SF_FixedLimit)==0 ){\n    p->nSelectRow = 320;  /* 4 billion rows */\n  }\n  computeLimitRegisters(pParse, p, iEnd);\n  if( p->iLimit==0 && sSort.addrSortIndex>=0 ){\n    sqlite3VdbeChangeOpcode(v, sSort.addrSortIndex, OP_SorterOpen);\n    sSort.sortFlags |= SORTFLAG_UseSorter;\n  }\n\n  /* Open an ephemeral index to use for the distinct set.\n  */\n  if( p->selFlags & SF_Distinct ){\n    sDistinct.tabTnct = pParse->nTab++;\n    sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral,\n                             sDistinct.tabTnct, 0, 0,\n                             (char*)keyInfoFromExprList(pParse, p->pEList,0,0),\n                             P4_KEYINFO);\n    sqlite3VdbeChangeP5(v, BTREE_UNORDERED);\n    sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED;\n  }else{\n    sDistinct.eTnctType = WHERE_DISTINCT_NOOP;\n  }\n\n  if( !isAgg && pGroupBy==0 ){\n    /* No aggregate functions and no GROUP BY clause */\n    u16 wctrlFlags = (sDistinct.isTnct ? WHERE_WANT_DISTINCT : 0);\n    assert( WHERE_USE_LIMIT==SF_FixedLimit );\n    wctrlFlags |= p->selFlags & SF_FixedLimit;\n\n    /* Begin the database scan. */\n    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,\n                               p->pEList, wctrlFlags, p->nSelectRow);\n    if( pWInfo==0 ) goto select_end;\n    if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){\n      p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);\n    }\n    if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){\n      sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo);\n    }\n    if( sSort.pOrderBy ){\n      sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo);\n      sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo);\n      if( sSort.nOBSat==sSort.pOrderBy->nExpr ){\n        sSort.pOrderBy = 0;\n      }\n    }\n\n    /* If sorting index that was created by a prior OP_OpenEphemeral \n    ** instruction ended up not being needed, then change the OP_OpenEphemeral\n    ** into an OP_Noop.\n    */\n    if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){\n      sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n    }\n\n    /* Use the standard inner loop. */\n    assert( p->pEList==pEList );\n    selectInnerLoop(pParse, p, -1, &sSort, &sDistinct, pDest,\n                    sqlite3WhereContinueLabel(pWInfo),\n                    sqlite3WhereBreakLabel(pWInfo));\n\n    /* End the database scan loop.\n    */\n    sqlite3WhereEnd(pWInfo);\n  }else{\n    /* This case when there exist aggregate functions or a GROUP BY clause\n    ** or both */\n    NameContext sNC;    /* Name context for processing aggregate information */\n    int iAMem;          /* First Mem address for storing current GROUP BY */\n    int iBMem;          /* First Mem address for previous GROUP BY */\n    int iUseFlag;       /* Mem address holding flag indicating that at least\n                        ** one row of the input to the aggregator has been\n                        ** processed */\n    int iAbortFlag;     /* Mem address which causes query abort if positive */\n    int groupBySort;    /* Rows come from source in GROUP BY order */\n    int addrEnd;        /* End of processing for this SELECT */\n    int sortPTab = 0;   /* Pseudotable used to decode sorting results */\n    int sortOut = 0;    /* Output register from the sorter */\n    int orderByGrp = 0; /* True if the GROUP BY and ORDER BY are the same */\n\n    /* Remove any and all aliases between the result set and the\n    ** GROUP BY clause.\n    */\n    if( pGroupBy ){\n      int k;                        /* Loop counter */\n      struct ExprList_item *pItem;  /* For looping over expression in a list */\n\n      for(k=p->pEList->nExpr, pItem=p->pEList->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      for(k=pGroupBy->nExpr, pItem=pGroupBy->a; k>0; k--, pItem++){\n        pItem->u.x.iAlias = 0;\n      }\n      assert( 66==sqlite3LogEst(100) );\n      if( p->nSelectRow>66 ) p->nSelectRow = 66;\n    }else{\n      assert( 0==sqlite3LogEst(1) );\n      p->nSelectRow = 0;\n    }\n\n    /* If there is both a GROUP BY and an ORDER BY clause and they are\n    ** identical, then it may be possible to disable the ORDER BY clause \n    ** on the grounds that the GROUP BY will cause elements to come out \n    ** in the correct order. It also may not - the GROUP BY might use a\n    ** database index that causes rows to be grouped together as required\n    ** but not actually sorted. Either way, record the fact that the\n    ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp\n    ** variable.  */\n    if( sqlite3ExprListCompare(pGroupBy, sSort.pOrderBy, -1)==0 ){\n      orderByGrp = 1;\n    }\n \n    /* Create a label to jump to when we want to abort the query */\n    addrEnd = sqlite3VdbeMakeLabel(v);\n\n    /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in\n    ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the\n    ** SELECT statement.\n    */\n    memset(&sNC, 0, sizeof(sNC));\n    sNC.pParse = pParse;\n    sNC.pSrcList = pTabList;\n    sNC.pAggInfo = &sAggInfo;\n    sAggInfo.mnReg = pParse->nMem+1;\n    sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;\n    sAggInfo.pGroupBy = pGroupBy;\n    sqlite3ExprAnalyzeAggList(&sNC, pEList);\n    sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy);\n    if( pHaving ){\n      if( pGroupBy ){\n        assert( pWhere==p->pWhere );\n        havingToWhere(pParse, pGroupBy, pHaving, &p->pWhere);\n        pWhere = p->pWhere;\n      }\n      sqlite3ExprAnalyzeAggregates(&sNC, pHaving);\n    }\n    sAggInfo.nAccumulator = sAggInfo.nColumn;\n    for(i=0; i<sAggInfo.nFunc; i++){\n      assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) );\n      sNC.ncFlags |= NC_InAggFunc;\n      sqlite3ExprAnalyzeAggList(&sNC, sAggInfo.aFunc[i].pExpr->x.pList);\n      sNC.ncFlags &= ~NC_InAggFunc;\n    }\n    sAggInfo.mxReg = pParse->nMem;\n    if( db->mallocFailed ) goto select_end;\n\n    /* Processing for aggregates with GROUP BY is very different and\n    ** much more complex than aggregates without a GROUP BY.\n    */\n    if( pGroupBy ){\n      KeyInfo *pKeyInfo;  /* Keying information for the group by clause */\n      int addr1;          /* A-vs-B comparision jump */\n      int addrOutputRow;  /* Start of subroutine that outputs a result row */\n      int regOutputRow;   /* Return address register for output subroutine */\n      int addrSetAbort;   /* Set the abort flag and return */\n      int addrTopOfLoop;  /* Top of the input loop */\n      int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */\n      int addrReset;      /* Subroutine for resetting the accumulator */\n      int regReset;       /* Return address register for reset subroutine */\n\n      /* If there is a GROUP BY clause we might need a sorting index to\n      ** implement it.  Allocate that sorting index now.  If it turns out\n      ** that we do not need it after all, the OP_SorterOpen instruction\n      ** will be converted into a Noop.  \n      */\n      sAggInfo.sortingIdx = pParse->nTab++;\n      pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);\n      addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen, \n          sAggInfo.sortingIdx, sAggInfo.nSortingColumn, \n          0, (char*)pKeyInfo, P4_KEYINFO);\n\n      /* Initialize memory locations used by GROUP BY aggregate processing\n      */\n      iUseFlag = ++pParse->nMem;\n      iAbortFlag = ++pParse->nMem;\n      regOutputRow = ++pParse->nMem;\n      addrOutputRow = sqlite3VdbeMakeLabel(v);\n      regReset = ++pParse->nMem;\n      addrReset = sqlite3VdbeMakeLabel(v);\n      iAMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      iBMem = pParse->nMem + 1;\n      pParse->nMem += pGroupBy->nExpr;\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);\n      VdbeComment((v, \"clear abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Integer, 0, iUseFlag);\n      VdbeComment((v, \"indicate accumulator empty\"));\n      sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);\n\n      /* Begin a loop that will extract all source rows in GROUP BY order.\n      ** This might involve two separate loops with an OP_Sort in between, or\n      ** it might be a single loop that uses an index to extract information\n      ** in the right order to begin with.\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, 0,\n          WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0\n      );\n      if( pWInfo==0 ) goto select_end;\n      if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){\n        /* The optimizer is able to deliver rows in group by order so\n        ** we do not have to sort.  The OP_OpenEphemeral table will be\n        ** cancelled later because we still need to use the pKeyInfo\n        */\n        groupBySort = 0;\n      }else{\n        /* Rows are coming out in undetermined order.  We have to push\n        ** each row into a sorting index, terminate the first loop,\n        ** then loop over the sorting index in order to get the output\n        ** in sorted order\n        */\n        int regBase;\n        int regRecord;\n        int nCol;\n        int nGroupBy;\n\n        explainTempTable(pParse, \n            (sDistinct.isTnct && (p->selFlags&SF_Distinct)==0) ?\n                    \"DISTINCT\" : \"GROUP BY\");\n\n        groupBySort = 1;\n        nGroupBy = pGroupBy->nExpr;\n        nCol = nGroupBy;\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          if( sAggInfo.aCol[i].iSorterColumn>=j ){\n            nCol++;\n            j++;\n          }\n        }\n        regBase = sqlite3GetTempRange(pParse, nCol);\n        sqlite3ExprCacheClear(pParse);\n        sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0);\n        j = nGroupBy;\n        for(i=0; i<sAggInfo.nColumn; i++){\n          struct AggInfo_col *pCol = &sAggInfo.aCol[i];\n          if( pCol->iSorterColumn>=j ){\n            int r1 = j + regBase;\n            sqlite3ExprCodeGetColumnToReg(pParse, \n                               pCol->pTab, pCol->iColumn, pCol->iTable, r1);\n            j++;\n          }\n        }\n        regRecord = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regRecord);\n        sqlite3VdbeAddOp2(v, OP_SorterInsert, sAggInfo.sortingIdx, regRecord);\n        sqlite3ReleaseTempReg(pParse, regRecord);\n        sqlite3ReleaseTempRange(pParse, regBase, nCol);\n        sqlite3WhereEnd(pWInfo);\n        sAggInfo.sortingIdxPTab = sortPTab = pParse->nTab++;\n        sortOut = sqlite3GetTempReg(pParse);\n        sqlite3VdbeAddOp3(v, OP_OpenPseudo, sortPTab, sortOut, nCol);\n        sqlite3VdbeAddOp2(v, OP_SorterSort, sAggInfo.sortingIdx, addrEnd);\n        VdbeComment((v, \"GROUP BY sort\")); VdbeCoverage(v);\n        sAggInfo.useSortingIdx = 1;\n        sqlite3ExprCacheClear(pParse);\n\n      }\n\n      /* If the index or temporary table used by the GROUP BY sort\n      ** will naturally deliver rows in the order required by the ORDER BY\n      ** clause, cancel the ephemeral table open coded earlier.\n      **\n      ** This is an optimization - the correct answer should result regardless.\n      ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER to \n      ** disable this optimization for testing purposes.  */\n      if( orderByGrp && OptimizationEnabled(db, SQLITE_GroupByOrder) \n       && (groupBySort || sqlite3WhereIsSorted(pWInfo))\n      ){\n        sSort.pOrderBy = 0;\n        sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex);\n      }\n\n      /* Evaluate the current GROUP BY terms and store in b0, b1, b2...\n      ** (b0 is memory location iBMem+0, b1 is iBMem+1, and so forth)\n      ** Then compare the current GROUP BY terms against the GROUP BY terms\n      ** from the previous row currently stored in a0, a1, a2...\n      */\n      addrTopOfLoop = sqlite3VdbeCurrentAddr(v);\n      sqlite3ExprCacheClear(pParse);\n      if( groupBySort ){\n        sqlite3VdbeAddOp3(v, OP_SorterData, sAggInfo.sortingIdx,\n                          sortOut, sortPTab);\n      }\n      for(j=0; j<pGroupBy->nExpr; j++){\n        if( groupBySort ){\n          sqlite3VdbeAddOp3(v, OP_Column, sortPTab, j, iBMem+j);\n        }else{\n          sAggInfo.directMode = 1;\n          sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j);\n        }\n      }\n      sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr,\n                          (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO);\n      addr1 = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp3(v, OP_Jump, addr1+1, 0, addr1+1); VdbeCoverage(v);\n\n      /* Generate code that runs whenever the GROUP BY changes.\n      ** Changes in the GROUP BY are detected by the previous code\n      ** block.  If there were no changes, this block is skipped.\n      **\n      ** This code copies current group by terms in b0,b1,b2,...\n      ** over to a0,a1,a2.  It then calls the output subroutine\n      ** and resets the aggregate accumulator registers in preparation\n      ** for the next GROUP BY batch.\n      */\n      sqlite3ExprCodeMove(pParse, iBMem, iAMem, pGroupBy->nExpr);\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output one row\"));\n      sqlite3VdbeAddOp2(v, OP_IfPos, iAbortFlag, addrEnd); VdbeCoverage(v);\n      VdbeComment((v, \"check abort flag\"));\n      sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);\n      VdbeComment((v, \"reset accumulator\"));\n\n      /* Update the aggregate accumulators based on the content of\n      ** the current row\n      */\n      sqlite3VdbeJumpHere(v, addr1);\n      updateAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iUseFlag);\n      VdbeComment((v, \"indicate data in accumulator\"));\n\n      /* End of the loop\n      */\n      if( groupBySort ){\n        sqlite3VdbeAddOp2(v, OP_SorterNext, sAggInfo.sortingIdx, addrTopOfLoop);\n        VdbeCoverage(v);\n      }else{\n        sqlite3WhereEnd(pWInfo);\n        sqlite3VdbeChangeToNoop(v, addrSortingIdx);\n      }\n\n      /* Output the final row of result\n      */\n      sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow);\n      VdbeComment((v, \"output final row\"));\n\n      /* Jump over the subroutines\n      */\n      sqlite3VdbeGoto(v, addrEnd);\n\n      /* Generate a subroutine that outputs a single row of the result\n      ** set.  This subroutine first looks at the iUseFlag.  If iUseFlag\n      ** is less than or equal to zero, the subroutine is a no-op.  If\n      ** the processing calls for the query to abort, this subroutine\n      ** increments the iAbortFlag memory location before returning in\n      ** order to signal the caller to abort.\n      */\n      addrSetAbort = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_Integer, 1, iAbortFlag);\n      VdbeComment((v, \"set abort flag\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      sqlite3VdbeResolveLabel(v, addrOutputRow);\n      addrOutputRow = sqlite3VdbeCurrentAddr(v);\n      sqlite3VdbeAddOp2(v, OP_IfPos, iUseFlag, addrOutputRow+2);\n      VdbeCoverage(v);\n      VdbeComment((v, \"Groupby result generator entry point\"));\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      finalizeAggFunctions(pParse, &sAggInfo);\n      sqlite3ExprIfFalse(pParse, pHaving, addrOutputRow+1, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, &sSort,\n                      &sDistinct, pDest,\n                      addrOutputRow+1, addrSetAbort);\n      sqlite3VdbeAddOp1(v, OP_Return, regOutputRow);\n      VdbeComment((v, \"end groupby result generator\"));\n\n      /* Generate a subroutine that will reset the group-by accumulator\n      */\n      sqlite3VdbeResolveLabel(v, addrReset);\n      resetAccumulator(pParse, &sAggInfo);\n      sqlite3VdbeAddOp1(v, OP_Return, regReset);\n     \n    } /* endif pGroupBy.  Begin aggregate queries without GROUP BY: */\n    else {\n      ExprList *pDel = 0;\n#ifndef SQLITE_OMIT_BTREECOUNT\n      Table *pTab;\n      if( (pTab = isSimpleCount(p, &sAggInfo))!=0 ){\n        /* If isSimpleCount() returns a pointer to a Table structure, then\n        ** the SQL statement is of the form:\n        **\n        **   SELECT count(*) FROM <tbl>\n        **\n        ** where the Table structure returned represents table <tbl>.\n        **\n        ** This statement is so common that it is optimized specially. The\n        ** OP_Count instruction is executed either on the intkey table that\n        ** contains the data for table <tbl> or on one of its indexes. It\n        ** is better to execute the op on an index, as indexes are almost\n        ** always spread across less pages than their corresponding tables.\n        */\n        const int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n        const int iCsr = pParse->nTab++;     /* Cursor to scan b-tree */\n        Index *pIdx;                         /* Iterator variable */\n        KeyInfo *pKeyInfo = 0;               /* Keyinfo for scanned index */\n        Index *pBest = 0;                    /* Best index found so far */\n        int iRoot = pTab->tnum;              /* Root page of scanned b-tree */\n\n        sqlite3CodeVerifySchema(pParse, iDb);\n        sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n\n        /* Search for the index that has the lowest scan cost.\n        **\n        ** (2011-04-15) Do not do a full scan of an unordered index.\n        **\n        ** (2013-10-03) Do not count the entries in a partial index.\n        **\n        ** In practice the KeyInfo structure will not be used. It is only \n        ** passed to keep OP_OpenRead happy.\n        */\n        if( !HasRowid(pTab) ) pBest = sqlite3PrimaryKeyIndex(pTab);\n        for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n          if( pIdx->bUnordered==0\n           && pIdx->szIdxRow<pTab->szTabRow\n           && pIdx->pPartIdxWhere==0\n           && (!pBest || pIdx->szIdxRow<pBest->szIdxRow)\n          ){\n            pBest = pIdx;\n          }\n        }\n        if( pBest ){\n          iRoot = pBest->tnum;\n          pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pBest);\n        }\n\n        /* Open a read-only cursor, execute the OP_Count, close the cursor. */\n        sqlite3VdbeAddOp4Int(v, OP_OpenRead, iCsr, iRoot, iDb, 1);\n        if( pKeyInfo ){\n          sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO);\n        }\n        sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem);\n        sqlite3VdbeAddOp1(v, OP_Close, iCsr);\n        explainSimpleCount(pParse, pTab, pBest);\n      }else\n#endif /* SQLITE_OMIT_BTREECOUNT */\n      {\n        /* Check if the query is of one of the following forms:\n        **\n        **   SELECT min(x) FROM ...\n        **   SELECT max(x) FROM ...\n        **\n        ** If it is, then ask the code in where.c to attempt to sort results\n        ** as if there was an \"ORDER ON x\" or \"ORDER ON x DESC\" clause. \n        ** If where.c is able to produce results sorted in this order, then\n        ** add vdbe code to break out of the processing loop after the \n        ** first iteration (since the first iteration of the loop is \n        ** guaranteed to operate on the row with the minimum or maximum \n        ** value of x, the only row required).\n        **\n        ** A special flag must be passed to sqlite3WhereBegin() to slightly\n        ** modify behavior as follows:\n        **\n        **   + If the query is a \"SELECT min(x)\", then the loop coded by\n        **     where.c should not iterate over any values with a NULL value\n        **     for x.\n        **\n        **   + The optimizer code in where.c (the thing that decides which\n        **     index or indices to use) should place a different priority on \n        **     satisfying the 'ORDER BY' clause than it does in other cases.\n        **     Refer to code and comments in where.c for details.\n        */\n        ExprList *pMinMax = 0;\n        u8 flag = WHERE_ORDERBY_NORMAL;\n        \n        assert( p->pGroupBy==0 );\n        assert( flag==0 );\n        if( p->pHaving==0 ){\n          flag = minMaxQuery(&sAggInfo, &pMinMax);\n        }\n        assert( flag==0 || (pMinMax!=0 && pMinMax->nExpr==1) );\n\n        if( flag ){\n          pMinMax = sqlite3ExprListDup(db, pMinMax, 0);\n          pDel = pMinMax;\n          assert( db->mallocFailed || pMinMax!=0 );\n          if( !db->mallocFailed ){\n            pMinMax->a[0].sortOrder = flag!=WHERE_ORDERBY_MIN ?1:0;\n            pMinMax->a[0].pExpr->op = TK_COLUMN;\n          }\n        }\n  \n        /* This case runs if the aggregate has no GROUP BY clause.  The\n        ** processing is much simpler since there is only a single row\n        ** of output.\n        */\n        resetAccumulator(pParse, &sAggInfo);\n        pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMax, 0,flag,0);\n        if( pWInfo==0 ){\n          sqlite3ExprListDelete(db, pDel);\n          goto select_end;\n        }\n        updateAccumulator(pParse, &sAggInfo);\n        assert( pMinMax==0 || pMinMax->nExpr==1 );\n        if( sqlite3WhereIsOrdered(pWInfo)>0 ){\n          sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo));\n          VdbeComment((v, \"%s() by index\",\n                (flag==WHERE_ORDERBY_MIN?\"min\":\"max\")));\n        }\n        sqlite3WhereEnd(pWInfo);\n        finalizeAggFunctions(pParse, &sAggInfo);\n      }\n\n      sSort.pOrderBy = 0;\n      sqlite3ExprIfFalse(pParse, pHaving, addrEnd, SQLITE_JUMPIFNULL);\n      selectInnerLoop(pParse, p, -1, 0, 0, \n                      pDest, addrEnd, addrEnd);\n      sqlite3ExprListDelete(db, pDel);\n    }\n    sqlite3VdbeResolveLabel(v, addrEnd);\n    \n  } /* endif aggregate query */\n\n  if( sDistinct.eTnctType==WHERE_DISTINCT_UNORDERED ){\n    explainTempTable(pParse, \"DISTINCT\");\n  }\n\n  /* If there is an ORDER BY clause, then we need to sort the results\n  ** and send them to the callback one by one.\n  */\n  if( sSort.pOrderBy ){\n    explainTempTable(pParse,\n                     sSort.nOBSat>0 ? \"RIGHT PART OF ORDER BY\":\"ORDER BY\");\n    generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);\n  }\n\n  /* Jump here to skip this query\n  */\n  sqlite3VdbeResolveLabel(v, iEnd);\n\n  /* The SELECT has been coded. If there is an error in the Parse structure,\n  ** set the return code to 1. Otherwise 0. */\n  rc = (pParse->nErr>0);\n\n  /* Control jumps to here if an error is encountered above, or upon\n  ** successful coding of the SELECT.\n  */\nselect_end:\n  explainSetInteger(pParse->iSelectId, iRestoreSelectId);\n\n  sqlite3DbFree(db, sAggInfo.aCol);\n  sqlite3DbFree(db, sAggInfo.aFunc);\n#if SELECTTRACE_ENABLED\n  SELECTTRACE(1,pParse,p,(\"end processing\\n\"));\n  pParse->nSelectIndent--;\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/shell.c.in",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement the \"sqlite\" command line\n** utility for accessing SQLite databases.\n*/\n#if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)\n/* This needs to come before any includes for MSVC compiler */\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n/*\n** Warning pragmas copied from msvc.h in the core.\n*/\n#if defined(_MSC_VER)\n#pragma warning(disable : 4054)\n#pragma warning(disable : 4055)\n#pragma warning(disable : 4100)\n#pragma warning(disable : 4127)\n#pragma warning(disable : 4130)\n#pragma warning(disable : 4152)\n#pragma warning(disable : 4189)\n#pragma warning(disable : 4206)\n#pragma warning(disable : 4210)\n#pragma warning(disable : 4232)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 4306)\n#pragma warning(disable : 4702)\n#pragma warning(disable : 4706)\n#endif /* defined(_MSC_VER) */\n\n/*\n** No support for loadable extensions in VxWorks.\n*/\n#if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION\n# define SQLITE_OMIT_LOAD_EXTENSION 1\n#endif\n\n/*\n** Enable large-file support for fopen() and friends on unix.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n#include <assert.h>\n#include \"sqlite3.h\"\n#if SQLITE_USER_AUTHENTICATION\n# include \"sqlite3userauth.h\"\n#endif\n#include <ctype.h>\n#include <stdarg.h>\n\n#if !defined(_WIN32) && !defined(WIN32)\n# include <signal.h>\n# if !defined(__RTP__) && !defined(_WRS_KERNEL)\n#  include <pwd.h>\n# endif\n# include <unistd.h>\n# include <sys/types.h>\n#endif\n\n#if HAVE_READLINE\n# include <readline/readline.h>\n# include <readline/history.h>\n#endif\n\n#if HAVE_EDITLINE\n# include <editline/readline.h>\n#endif\n\n#if HAVE_EDITLINE || HAVE_READLINE\n\n# define shell_add_history(X) add_history(X)\n# define shell_read_history(X) read_history(X)\n# define shell_write_history(X) write_history(X)\n# define shell_stifle_history(X) stifle_history(X)\n# define shell_readline(X) readline(X)\n\n#elif HAVE_LINENOISE\n\n# include \"linenoise.h\"\n# define shell_add_history(X) linenoiseHistoryAdd(X)\n# define shell_read_history(X) linenoiseHistoryLoad(X)\n# define shell_write_history(X) linenoiseHistorySave(X)\n# define shell_stifle_history(X) linenoiseHistorySetMaxLen(X)\n# define shell_readline(X) linenoise(X)\n\n#else\n\n# define shell_read_history(X)\n# define shell_write_history(X)\n# define shell_stifle_history(X)\n\n# define SHELL_USE_LOCAL_GETLINE 1\n#endif\n\n\n#if defined(_WIN32) || defined(WIN32)\n# include <io.h>\n# include <fcntl.h>\n# define isatty(h) _isatty(h)\n# ifndef access\n#  define access(f,m) _access((f),(m))\n# endif\n# undef popen\n# define popen _popen\n# undef pclose\n# define pclose _pclose\n#else\n /* Make sure isatty() has a prototype. */\n extern int isatty(int);\n\n# if !defined(__RTP__) && !defined(_WRS_KERNEL)\n  /* popen and pclose are not C89 functions and so are\n  ** sometimes omitted from the <stdio.h> header */\n   extern FILE *popen(const char*,const char*);\n   extern int pclose(FILE*);\n# else\n#  define SQLITE_OMIT_POPEN 1\n# endif\n#endif\n\n#if defined(_WIN32_WCE)\n/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()\n * thus we always assume that we have a console. That can be\n * overridden with the -batch command line option.\n */\n#define isatty(x) 1\n#endif\n\n/* ctype macros that work with signed characters */\n#define IsSpace(X)  isspace((unsigned char)X)\n#define IsDigit(X)  isdigit((unsigned char)X)\n#define ToLower(X)  (char)tolower((unsigned char)X)\n\n#if defined(_WIN32) || defined(WIN32)\n#include <windows.h>\n\n/* string conversion routines only needed on Win32 */\nextern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);\nextern char *sqlite3_win32_mbcs_to_utf8_v2(const char *, int);\nextern char *sqlite3_win32_utf8_to_mbcs_v2(const char *, int);\nextern LPWSTR sqlite3_win32_utf8_to_unicode(const char *zText);\n#endif\n\n/* On Windows, we normally run with output mode of TEXT so that \\n characters\n** are automatically translated into \\r\\n.  However, this behavior needs\n** to be disabled in some cases (ex: when generating CSV output and when\n** rendering quoted strings that contain \\n characters).  The following\n** routines take care of that.\n*/\n#if defined(_WIN32) || defined(WIN32)\nstatic void setBinaryMode(FILE *file, int isOutput){\n  if( isOutput ) fflush(file);\n  _setmode(_fileno(file), _O_BINARY);\n}\nstatic void setTextMode(FILE *file, int isOutput){\n  if( isOutput ) fflush(file);\n  _setmode(_fileno(file), _O_TEXT);\n}\n#else\n# define setBinaryMode(X,Y)\n# define setTextMode(X,Y)\n#endif\n\n\n/* True if the timer is enabled */\nstatic int enableTimer = 0;\n\n/* Return the current wall-clock time */\nstatic sqlite3_int64 timeOfDay(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)\n#include <sys/time.h>\n#include <sys/resource.h>\n\n/* VxWorks does not support getrusage() as far as we can determine */\n#if defined(_WRS_KERNEL) || defined(__RTP__)\nstruct rusage {\n  struct timeval ru_utime; /* user CPU time used */\n  struct timeval ru_stime; /* system CPU time used */\n};\n#define getrusage(A,B) memset(B,0,sizeof(*B))\n#endif\n\n/* Saved resource information for the beginning of an operation */\nstatic struct rusage sBegin;  /* CPU time at start */\nstatic sqlite3_int64 iBegin;  /* Wall-clock time at start */\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer ){\n    getrusage(RUSAGE_SELF, &sBegin);\n    iBegin = timeOfDay();\n  }\n}\n\n/* Return the difference of two time_structs in seconds */\nstatic double timeDiff(struct timeval *pStart, struct timeval *pEnd){\n  return (pEnd->tv_usec - pStart->tv_usec)*0.000001 +\n         (double)(pEnd->tv_sec - pStart->tv_sec);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer ){\n    sqlite3_int64 iEnd = timeOfDay();\n    struct rusage sEnd;\n    getrusage(RUSAGE_SELF, &sEnd);\n    printf(\"Run Time: real %.3f user %f sys %f\\n\",\n       (iEnd - iBegin)*0.001,\n       timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),\n       timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER 1\n\n#elif (defined(_WIN32) || defined(WIN32))\n\n/* Saved resource information for the beginning of an operation */\nstatic HANDLE hProcess;\nstatic FILETIME ftKernelBegin;\nstatic FILETIME ftUserBegin;\nstatic sqlite3_int64 ftWallBegin;\ntypedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,\n                                    LPFILETIME, LPFILETIME);\nstatic GETPROCTIMES getProcessTimesAddr = NULL;\n\n/*\n** Check to see if we have timer support.  Return 1 if necessary\n** support found (or found previously).\n*/\nstatic int hasTimer(void){\n  if( getProcessTimesAddr ){\n    return 1;\n  } else {\n    /* GetProcessTimes() isn't supported in WIN95 and some other Windows\n    ** versions. See if the version we are running on has it, and if it\n    ** does, save off a pointer to it and the current process handle.\n    */\n    hProcess = GetCurrentProcess();\n    if( hProcess ){\n      HINSTANCE hinstLib = LoadLibrary(TEXT(\"Kernel32.dll\"));\n      if( NULL != hinstLib ){\n        getProcessTimesAddr =\n            (GETPROCTIMES) GetProcAddress(hinstLib, \"GetProcessTimes\");\n        if( NULL != getProcessTimesAddr ){\n          return 1;\n        }\n        FreeLibrary(hinstLib);\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Begin timing an operation\n*/\nstatic void beginTimer(void){\n  if( enableTimer && getProcessTimesAddr ){\n    FILETIME ftCreation, ftExit;\n    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,\n                        &ftKernelBegin,&ftUserBegin);\n    ftWallBegin = timeOfDay();\n  }\n}\n\n/* Return the difference of two FILETIME structs in seconds */\nstatic double timeDiff(FILETIME *pStart, FILETIME *pEnd){\n  sqlite_int64 i64Start = *((sqlite_int64 *) pStart);\n  sqlite_int64 i64End = *((sqlite_int64 *) pEnd);\n  return (double) ((i64End - i64Start) / 10000000.0);\n}\n\n/*\n** Print the timing results.\n*/\nstatic void endTimer(void){\n  if( enableTimer && getProcessTimesAddr){\n    FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;\n    sqlite3_int64 ftWallEnd = timeOfDay();\n    getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);\n    printf(\"Run Time: real %.3f user %f sys %f\\n\",\n       (ftWallEnd - ftWallBegin)*0.001,\n       timeDiff(&ftUserBegin, &ftUserEnd),\n       timeDiff(&ftKernelBegin, &ftKernelEnd));\n  }\n}\n\n#define BEGIN_TIMER beginTimer()\n#define END_TIMER endTimer()\n#define HAS_TIMER hasTimer()\n\n#else\n#define BEGIN_TIMER\n#define END_TIMER\n#define HAS_TIMER 0\n#endif\n\n/*\n** Used to prevent warnings about unused parameters\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n\n/*\n** If the following flag is set, then command execution stops\n** at an error if we are not interactive.\n*/\nstatic int bail_on_error = 0;\n\n/*\n** Threat stdin as an interactive input if the following variable\n** is true.  Otherwise, assume stdin is connected to a file or pipe.\n*/\nstatic int stdin_is_interactive = 1;\n\n/*\n** On Windows systems we have to know if standard output is a console\n** in order to translate UTF-8 into MBCS.  The following variable is\n** true if translation is required.\n*/\nstatic int stdout_is_console = 1;\n\n/*\n** The following is the open SQLite database.  We make a pointer\n** to this database a static variable so that it can be accessed\n** by the SIGINT handler to interrupt database processing.\n*/\nstatic sqlite3 *globalDb = 0;\n\n/*\n** True if an interrupt (Control-C) has been received.\n*/\nstatic volatile int seenInterrupt = 0;\n\n/*\n** This is the name of our program. It is set in main(), used\n** in a number of other places, mostly for error messages.\n*/\nstatic char *Argv0;\n\n/*\n** Prompt strings. Initialized in main. Settable with\n**   .prompt main continue\n*/\nstatic char mainPrompt[20];     /* First line prompt. default: \"sqlite> \"*/\nstatic char continuePrompt[20]; /* Continuation prompt. default: \"   ...> \" */\n\n/*\n** Render output like fprintf().  Except, if the output is going to the\n** console and if this is running on a Windows machine, translate the\n** output from UTF-8 into MBCS.\n*/\n#if defined(_WIN32) || defined(WIN32)\nvoid utf8_printf(FILE *out, const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  if( stdout_is_console && (out==stdout || out==stderr) ){\n    char *z1 = sqlite3_vmprintf(zFormat, ap);\n    char *z2 = sqlite3_win32_utf8_to_mbcs_v2(z1, 0);\n    sqlite3_free(z1);\n    fputs(z2, out);\n    sqlite3_free(z2);\n  }else{\n    vfprintf(out, zFormat, ap);\n  }\n  va_end(ap);\n}\n#elif !defined(utf8_printf)\n# define utf8_printf fprintf\n#endif\n\n/*\n** Render output like fprintf().  This should not be used on anything that\n** includes string formatting (e.g. \"%s\").\n*/\n#if !defined(raw_printf)\n# define raw_printf fprintf\n#endif\n\n/*\n** Write I/O traces to the following stream.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic FILE *iotrace = 0;\n#endif\n\n/*\n** This routine works like printf in that its first argument is a\n** format string and subsequent arguments are values to be substituted\n** in place of % fields.  The result of formatting this string\n** is written to iotrace.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\nstatic void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){\n  va_list ap;\n  char *z;\n  if( iotrace==0 ) return;\n  va_start(ap, zFormat);\n  z = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  utf8_printf(iotrace, \"%s\", z);\n  sqlite3_free(z);\n}\n#endif\n\n/*\n** Output string zUtf to stream pOut as w characters.  If w is negative,\n** then right-justify the text.  W is the width in UTF-8 characters, not\n** in bytes.  This is different from the %*.*s specification in printf\n** since with %*.*s the width is measured in bytes, not characters.\n*/\nstatic void utf8_width_print(FILE *pOut, int w, const char *zUtf){\n  int i;\n  int n;\n  int aw = w<0 ? -w : w;\n  char zBuf[1000];\n  if( aw>(int)sizeof(zBuf)/3 ) aw = (int)sizeof(zBuf)/3;\n  for(i=n=0; zUtf[i]; i++){\n    if( (zUtf[i]&0xc0)!=0x80 ){\n      n++;\n      if( n==aw ){\n        do{ i++; }while( (zUtf[i]&0xc0)==0x80 );\n        break;\n      }\n    }\n  }\n  if( n>=aw ){\n    utf8_printf(pOut, \"%.*s\", i, zUtf);\n  }else if( w<0 ){\n    utf8_printf(pOut, \"%*s%s\", aw-n, \"\", zUtf);\n  }else{\n    utf8_printf(pOut, \"%s%*s\", zUtf, aw-n, \"\");\n  }\n}\n\n\n/*\n** Determines if a string is a number of not.\n*/\nstatic int isNumber(const char *z, int *realnum){\n  if( *z=='-' || *z=='+' ) z++;\n  if( !IsDigit(*z) ){\n    return 0;\n  }\n  z++;\n  if( realnum ) *realnum = 0;\n  while( IsDigit(*z) ){ z++; }\n  if( *z=='.' ){\n    z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  if( *z=='e' || *z=='E' ){\n    z++;\n    if( *z=='+' || *z=='-' ) z++;\n    if( !IsDigit(*z) ) return 0;\n    while( IsDigit(*z) ){ z++; }\n    if( realnum ) *realnum = 1;\n  }\n  return *z==0;\n}\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n*/\nstatic int strlen30(const char *z){\n  const char *z2 = z;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n/*\n** Return the length of a string in characters.  Multibyte UTF8 characters\n** count as a single character.\n*/\nstatic int strlenChar(const char *z){\n  int n = 0;\n  while( *z ){\n    if( (0xc0&*(z++))!=0x80 ) n++;\n  }\n  return n;\n}\n\n/*\n** This routine reads a line of text from FILE in, stores\n** the text in memory obtained from malloc() and returns a pointer\n** to the text.  NULL is returned at end of file, or if malloc()\n** fails.\n**\n** If zLine is not NULL then it is a malloced buffer returned from\n** a previous call to this routine that may be reused.\n*/\nstatic char *local_getline(char *zLine, FILE *in){\n  int nLine = zLine==0 ? 0 : 100;\n  int n = 0;\n\n  while( 1 ){\n    if( n+100>nLine ){\n      nLine = nLine*2 + 100;\n      zLine = realloc(zLine, nLine);\n      if( zLine==0 ) return 0;\n    }\n    if( fgets(&zLine[n], nLine - n, in)==0 ){\n      if( n==0 ){\n        free(zLine);\n        return 0;\n      }\n      zLine[n] = 0;\n      break;\n    }\n    while( zLine[n] ) n++;\n    if( n>0 && zLine[n-1]=='\\n' ){\n      n--;\n      if( n>0 && zLine[n-1]=='\\r' ) n--;\n      zLine[n] = 0;\n      break;\n    }\n  }\n#if defined(_WIN32) || defined(WIN32)\n  /* For interactive input on Windows systems, translate the\n  ** multi-byte characterset characters into UTF-8. */\n  if( stdin_is_interactive && in==stdin ){\n    char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);\n    if( zTrans ){\n      int nTrans = strlen30(zTrans)+1;\n      if( nTrans>nLine ){\n        zLine = realloc(zLine, nTrans);\n        if( zLine==0 ){\n          sqlite3_free(zTrans);\n          return 0;\n        }\n      }\n      memcpy(zLine, zTrans, nTrans);\n      sqlite3_free(zTrans);\n    }\n  }\n#endif /* defined(_WIN32) || defined(WIN32) */\n  return zLine;\n}\n\n/*\n** Retrieve a single line of input text.\n**\n** If in==0 then read from standard input and prompt before each line.\n** If isContinuation is true, then a continuation prompt is appropriate.\n** If isContinuation is zero, then the main prompt should be used.\n**\n** If zPrior is not NULL then it is a buffer from a prior call to this\n** routine that can be reused.\n**\n** The result is stored in space obtained from malloc() and must either\n** be freed by the caller or else passed back into this routine via the\n** zPrior argument for reuse.\n*/\nstatic char *one_input_line(FILE *in, char *zPrior, int isContinuation){\n  char *zPrompt;\n  char *zResult;\n  if( in!=0 ){\n    zResult = local_getline(zPrior, in);\n  }else{\n    zPrompt = isContinuation ? continuePrompt : mainPrompt;\n#if SHELL_USE_LOCAL_GETLINE\n    printf(\"%s\", zPrompt);\n    fflush(stdout);\n    zResult = local_getline(zPrior, stdin);\n#else\n    free(zPrior);\n    zResult = shell_readline(zPrompt);\n    if( zResult && *zResult ) shell_add_history(zResult);\n#endif\n  }\n  return zResult;\n}\n/*\n** A variable length string to which one can append text.\n*/\ntypedef struct ShellText ShellText;\nstruct ShellText {\n  char *z;\n  int n;\n  int nAlloc;\n};\n\n/*\n** Initialize and destroy a ShellText object\n*/\nstatic void initText(ShellText *p){\n  memset(p, 0, sizeof(*p));\n}\nstatic void freeText(ShellText *p){\n  free(p->z);\n  initText(p);\n}\n\n/* zIn is either a pointer to a NULL-terminated string in memory obtained\n** from malloc(), or a NULL pointer. The string pointed to by zAppend is\n** added to zIn, and the result returned in memory obtained from malloc().\n** zIn, if it was not NULL, is freed.\n**\n** If the third argument, quote, is not '\\0', then it is used as a\n** quote character for zAppend.\n*/\nstatic void appendText(ShellText *p, char const *zAppend, char quote){\n  int len;\n  int i;\n  int nAppend = strlen30(zAppend);\n\n  len = nAppend+p->n+1;\n  if( quote ){\n    len += 2;\n    for(i=0; i<nAppend; i++){\n      if( zAppend[i]==quote ) len++;\n    }\n  }\n\n  if( p->n+len>=p->nAlloc ){\n    p->nAlloc = p->nAlloc*2 + len + 20;\n    p->z = realloc(p->z, p->nAlloc);\n    if( p->z==0 ){\n      memset(p, 0, sizeof(*p));\n      return;\n    }\n  }\n\n  if( quote ){\n    char *zCsr = p->z+p->n;\n    *zCsr++ = quote;\n    for(i=0; i<nAppend; i++){\n      *zCsr++ = zAppend[i];\n      if( zAppend[i]==quote ) *zCsr++ = quote;\n    }\n    *zCsr++ = quote;\n    p->n = (int)(zCsr - p->z);\n    *zCsr = '\\0';\n  }else{\n    memcpy(p->z+p->n, zAppend, nAppend);\n    p->n += nAppend;\n    p->z[p->n] = '\\0';\n  }\n}\n\n/*\n** Attempt to determine if identifier zName needs to be quoted, either\n** because it contains non-alphanumeric characters, or because it is an\n** SQLite keyword.  Be conservative in this estimate:  When in doubt assume\n** that quoting is required.\n**\n** Return '\"' if quoting is required.  Return 0 if no quoting is required.\n*/\nstatic char quoteChar(const char *zName){\n  /* All SQLite keywords, in alphabetical order */\n  static const char *azKeywords[] = {\n    \"ABORT\", \"ACTION\", \"ADD\", \"AFTER\", \"ALL\", \"ALTER\", \"ANALYZE\", \"AND\", \"AS\",\n    \"ASC\", \"ATTACH\", \"AUTOINCREMENT\", \"BEFORE\", \"BEGIN\", \"BETWEEN\", \"BY\",\n    \"CASCADE\", \"CASE\", \"CAST\", \"CHECK\", \"COLLATE\", \"COLUMN\", \"COMMIT\",\n    \"CONFLICT\", \"CONSTRAINT\", \"CREATE\", \"CROSS\", \"CURRENT_DATE\",\n    \"CURRENT_TIME\", \"CURRENT_TIMESTAMP\", \"DATABASE\", \"DEFAULT\", \"DEFERRABLE\",\n    \"DEFERRED\", \"DELETE\", \"DESC\", \"DETACH\", \"DISTINCT\", \"DROP\", \"EACH\",\n    \"ELSE\", \"END\", \"ESCAPE\", \"EXCEPT\", \"EXCLUSIVE\", \"EXISTS\", \"EXPLAIN\",\n    \"FAIL\", \"FOR\", \"FOREIGN\", \"FROM\", \"FULL\", \"GLOB\", \"GROUP\", \"HAVING\", \"IF\",\n    \"IGNORE\", \"IMMEDIATE\", \"IN\", \"INDEX\", \"INDEXED\", \"INITIALLY\", \"INNER\",\n    \"INSERT\", \"INSTEAD\", \"INTERSECT\", \"INTO\", \"IS\", \"ISNULL\", \"JOIN\", \"KEY\",\n    \"LEFT\", \"LIKE\", \"LIMIT\", \"MATCH\", \"NATURAL\", \"NO\", \"NOT\", \"NOTNULL\",\n    \"NULL\", \"OF\", \"OFFSET\", \"ON\", \"OR\", \"ORDER\", \"OUTER\", \"PLAN\", \"PRAGMA\",\n    \"PRIMARY\", \"QUERY\", \"RAISE\", \"RECURSIVE\", \"REFERENCES\", \"REGEXP\",\n    \"REINDEX\", \"RELEASE\", \"RENAME\", \"REPLACE\", \"RESTRICT\", \"RIGHT\",\n    \"ROLLBACK\", \"ROW\", \"SAVEPOINT\", \"SELECT\", \"SET\", \"TABLE\", \"TEMP\",\n    \"TEMPORARY\", \"THEN\", \"TO\", \"TRANSACTION\", \"TRIGGER\", \"UNION\", \"UNIQUE\",\n    \"UPDATE\", \"USING\", \"VACUUM\", \"VALUES\", \"VIEW\", \"VIRTUAL\", \"WHEN\", \"WHERE\",\n    \"WITH\", \"WITHOUT\",\n  };\n  int i, lwr, upr, mid, c;\n  if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '\"';\n  for(i=0; zName[i]; i++){\n    if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '\"';\n  }\n  lwr = 0;\n  upr = sizeof(azKeywords)/sizeof(azKeywords[0]) - 1;\n  while( lwr<=upr ){\n    mid = (lwr+upr)/2;\n    c = sqlite3_stricmp(azKeywords[mid], zName);\n    if( c==0 ) return '\"';\n    if( c<0 ){\n      lwr = mid+1;\n    }else{\n      upr = mid-1;\n    }\n  }\n  return 0;\n}\n\n/*\n** SQL function:  shell_add_schema(S,X)\n**\n** Add the schema name X to the CREATE statement in S and return the result.\n** Examples:\n**\n**    CREATE TABLE t1(x)   ->   CREATE TABLE xyz.t1(x);\n**\n** Also works on\n**\n**    CREATE INDEX\n**    CREATE UNIQUE INDEX\n**    CREATE VIEW\n**    CREATE TRIGGER\n**    CREATE VIRTUAL TABLE\n**\n** This UDF is used by the .schema command to insert the schema name of\n** attached databases into the middle of the sqlite_master.sql field.\n*/\nstatic void shellAddSchemaName(\n  sqlite3_context *pCtx,\n  int nVal,\n  sqlite3_value **apVal\n){\n  static const char *aPrefix[] = {\n     \"TABLE\",\n     \"INDEX\",\n     \"UNIQUE INDEX\",\n     \"VIEW\",\n     \"TRIGGER\",\n     \"VIRTUAL TABLE\"\n  };\n  int i = 0;\n  const char *zIn = (const char*)sqlite3_value_text(apVal[0]);\n  const char *zSchema = (const char*)sqlite3_value_text(apVal[1]);\n  assert( nVal==2 );\n  if( zIn!=0 && strncmp(zIn, \"CREATE \", 7)==0 ){\n    for(i=0; i<(int)(sizeof(aPrefix)/sizeof(aPrefix[0])); i++){\n      int n = strlen30(aPrefix[i]);\n      if( strncmp(zIn+7, aPrefix[i], n)==0 && zIn[n+7]==' ' ){\n        char cQuote = quoteChar(zSchema);\n        char *z;\n        if( cQuote ){\n         z = sqlite3_mprintf(\"%.*s \\\"%w\\\".%s\", n+7, zIn, zSchema, zIn+n+8);\n        }else{\n          z = sqlite3_mprintf(\"%.*s %s.%s\", n+7, zIn, zSchema, zIn+n+8);\n        }\n        sqlite3_result_text(pCtx, z, -1, sqlite3_free);\n        return;\n      }\n    }\n  }\n  sqlite3_result_value(pCtx, apVal[0]);\n}\n\n/*\n** The source code for several run-time loadable extensions is inserted\n** below by the ../tool/mkshellc.tcl script.  Before processing that included\n** code, we need to override some macros to make the included program code\n** work here in the middle of this regular program.\n*/\n#define SQLITE_EXTENSION_INIT1\n#define SQLITE_EXTENSION_INIT2(X) (void)(X)\n\nINCLUDE ../ext/misc/shathree.c\nINCLUDE ../ext/misc/fileio.c\nINCLUDE ../ext/misc/completion.c\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** State information for a single open session\n*/\ntypedef struct OpenSession OpenSession;\nstruct OpenSession {\n  char *zName;             /* Symbolic name for this session */\n  int nFilter;             /* Number of xFilter rejection GLOB patterns */\n  char **azFilter;         /* Array of xFilter rejection GLOB patterns */\n  sqlite3_session *p;      /* The open session */\n};\n#endif\n\n/*\n** Shell output mode information from before \".explain on\",\n** saved so that it can be restored by \".explain off\"\n*/\ntypedef struct SavedModeInfo SavedModeInfo;\nstruct SavedModeInfo {\n  int valid;          /* Is there legit data in here? */\n  int mode;           /* Mode prior to \".explain on\" */\n  int showHeader;     /* The \".header\" setting prior to \".explain on\" */\n  int colWidth[100];  /* Column widths prior to \".explain on\" */\n};\n\n/*\n** State information about the database connection is contained in an\n** instance of the following structure.\n*/\ntypedef struct ShellState ShellState;\nstruct ShellState {\n  sqlite3 *db;           /* The database */\n  int autoExplain;       /* Automatically turn on .explain mode */\n  int autoEQP;           /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */\n  int statsOn;           /* True to display memory stats before each finalize */\n  int scanstatsOn;       /* True to display scan stats before each finalize */\n  int outCount;          /* Revert to stdout when reaching zero */\n  int cnt;               /* Number of records displayed so far */\n  FILE *out;             /* Write results here */\n  FILE *traceOut;        /* Output for sqlite3_trace() */\n  int nErr;              /* Number of errors seen */\n  int mode;              /* An output mode setting */\n  int cMode;             /* temporary output mode for the current query */\n  int normalMode;        /* Output mode before \".explain on\" */\n  int writableSchema;    /* True if PRAGMA writable_schema=ON */\n  int showHeader;        /* True to show column names in List or Column mode */\n  int nCheck;            /* Number of \".check\" commands run */\n  unsigned shellFlgs;    /* Various flags */\n  char *zDestTable;      /* Name of destination table when MODE_Insert */\n  char zTestcase[30];    /* Name of current test case */\n  char colSeparator[20]; /* Column separator character for several modes */\n  char rowSeparator[20]; /* Row separator character for MODE_Ascii */\n  int colWidth[100];     /* Requested width of each column when in column mode*/\n  int actualWidth[100];  /* Actual width of each column */\n  char nullValue[20];    /* The text to print when a NULL comes back from\n                         ** the database */\n  char outfile[FILENAME_MAX]; /* Filename for *out */\n  const char *zDbFilename;    /* name of the database file */\n  char *zFreeOnClose;         /* Filename to free when closing */\n  const char *zVfs;           /* Name of VFS to use */\n  sqlite3_stmt *pStmt;   /* Current statement if any. */\n  FILE *pLog;            /* Write log output here */\n  int *aiIndent;         /* Array of indents used in MODE_Explain */\n  int nIndent;           /* Size of array aiIndent[] */\n  int iIndent;           /* Index of current op in aiIndent[] */\n#if defined(SQLITE_ENABLE_SESSION)\n  int nSession;             /* Number of active sessions */\n  OpenSession aSession[4];  /* Array of sessions.  [0] is in focus. */\n#endif\n};\n\n/*\n** These are the allowed shellFlgs values\n*/\n#define SHFLG_Pagecache      0x00000001 /* The --pagecache option is used */\n#define SHFLG_Lookaside      0x00000002 /* Lookaside memory is used */\n#define SHFLG_Backslash      0x00000004 /* The --backslash option is used */\n#define SHFLG_PreserveRowid  0x00000008 /* .dump preserves rowid values */\n#define SHFLG_Newlines       0x00000010 /* .dump --newline flag */\n#define SHFLG_CountChanges   0x00000020 /* .changes setting */\n#define SHFLG_Echo           0x00000040 /* .echo or --echo setting */\n\n/*\n** Macros for testing and setting shellFlgs\n*/\n#define ShellHasFlag(P,X)    (((P)->shellFlgs & (X))!=0)\n#define ShellSetFlag(P,X)    ((P)->shellFlgs|=(X))\n#define ShellClearFlag(P,X)  ((P)->shellFlgs&=(~(X)))\n\n/*\n** These are the allowed modes.\n*/\n#define MODE_Line     0  /* One column per line.  Blank line between records */\n#define MODE_Column   1  /* One record per line in neat columns */\n#define MODE_List     2  /* One record per line with a separator */\n#define MODE_Semi     3  /* Same as MODE_List but append \";\" to each line */\n#define MODE_Html     4  /* Generate an XHTML table */\n#define MODE_Insert   5  /* Generate SQL \"insert\" statements */\n#define MODE_Quote    6  /* Quote values as for SQL */\n#define MODE_Tcl      7  /* Generate ANSI-C or TCL quoted elements */\n#define MODE_Csv      8  /* Quote strings, numbers are plain */\n#define MODE_Explain  9  /* Like MODE_Column, but do not truncate data */\n#define MODE_Ascii   10  /* Use ASCII unit and record separators (0x1F/0x1E) */\n#define MODE_Pretty  11  /* Pretty-print schemas */\n\nstatic const char *modeDescr[] = {\n  \"line\",\n  \"column\",\n  \"list\",\n  \"semi\",\n  \"html\",\n  \"insert\",\n  \"quote\",\n  \"tcl\",\n  \"csv\",\n  \"explain\",\n  \"ascii\",\n  \"prettyprint\",\n};\n\n/*\n** These are the column/row/line separators used by the various\n** import/export modes.\n*/\n#define SEP_Column    \"|\"\n#define SEP_Row       \"\\n\"\n#define SEP_Tab       \"\\t\"\n#define SEP_Space     \" \"\n#define SEP_Comma     \",\"\n#define SEP_CrLf      \"\\r\\n\"\n#define SEP_Unit      \"\\x1F\"\n#define SEP_Record    \"\\x1E\"\n\n/*\n** Number of elements in an array\n*/\n#define ArraySize(X)  (int)(sizeof(X)/sizeof(X[0]))\n\n/*\n** A callback for the sqlite3_log() interface.\n*/\nstatic void shellLog(void *pArg, int iErrCode, const char *zMsg){\n  ShellState *p = (ShellState*)pArg;\n  if( p->pLog==0 ) return;\n  utf8_printf(p->pLog, \"(%d) %s\\n\", iErrCode, zMsg);\n  fflush(p->pLog);\n}\n\n/*\n** Output the given string as a hex-encoded blob (eg. X'1234' )\n*/\nstatic void output_hex_blob(FILE *out, const void *pBlob, int nBlob){\n  int i;\n  char *zBlob = (char *)pBlob;\n  raw_printf(out,\"X'\");\n  for(i=0; i<nBlob; i++){ raw_printf(out,\"%02x\",zBlob[i]&0xff); }\n  raw_printf(out,\"'\");\n}\n\n/*\n** Find a string that is not found anywhere in z[].  Return a pointer\n** to that string.\n**\n** Try to use zA and zB first.  If both of those are already found in z[]\n** then make up some string and store it in the buffer zBuf.\n*/\nstatic const char *unused_string(\n  const char *z,                    /* Result must not appear anywhere in z */\n  const char *zA, const char *zB,   /* Try these first */\n  char *zBuf                        /* Space to store a generated string */\n){\n  unsigned i = 0;\n  if( strstr(z, zA)==0 ) return zA;\n  if( strstr(z, zB)==0 ) return zB;\n  do{\n    sqlite3_snprintf(20,zBuf,\"(%s%u)\", zA, i++);\n  }while( strstr(z,zBuf)!=0 );\n  return zBuf;\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n**\n** See also: output_quoted_escaped_string()\n*/\nstatic void output_quoted_string(FILE *out, const char *z){\n  int i;\n  char c;\n  setBinaryMode(out, 1);\n  for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n  if( c==0 ){\n    utf8_printf(out,\"'%s'\",z);\n  }else{\n    raw_printf(out, \"'\");\n    while( *z ){\n      for(i=0; (c = z[i])!=0 && c!='\\''; i++){}\n      if( c=='\\'' ) i++;\n      if( i ){\n        utf8_printf(out, \"%.*s\", i, z);\n        z += i;\n      }\n      if( c=='\\'' ){\n        raw_printf(out, \"'\");\n        continue;\n      }\n      if( c==0 ){\n        break;\n      }\n      z++;\n    }\n    raw_printf(out, \"'\");\n  }\n  setTextMode(out, 1);\n}\n\n/*\n** Output the given string as a quoted string using SQL quoting conventions.\n** Additionallly , escape the \"\\n\" and \"\\r\" characters so that they do not\n** get corrupted by end-of-line translation facilities in some operating\n** systems.\n**\n** This is like output_quoted_string() but with the addition of the \\r\\n\n** escape mechanism.\n*/\nstatic void output_quoted_escaped_string(FILE *out, const char *z){\n  int i;\n  char c;\n  setBinaryMode(out, 1);\n  for(i=0; (c = z[i])!=0 && c!='\\'' && c!='\\n' && c!='\\r'; i++){}\n  if( c==0 ){\n    utf8_printf(out,\"'%s'\",z);\n  }else{\n    const char *zNL = 0;\n    const char *zCR = 0;\n    int nNL = 0;\n    int nCR = 0;\n    char zBuf1[20], zBuf2[20];\n    for(i=0; z[i]; i++){\n      if( z[i]=='\\n' ) nNL++;\n      if( z[i]=='\\r' ) nCR++;\n    }\n    if( nNL ){\n      raw_printf(out, \"replace(\");\n      zNL = unused_string(z, \"\\\\n\", \"\\\\012\", zBuf1);\n    }\n    if( nCR ){\n      raw_printf(out, \"replace(\");\n      zCR = unused_string(z, \"\\\\r\", \"\\\\015\", zBuf2);\n    }\n    raw_printf(out, \"'\");\n    while( *z ){\n      for(i=0; (c = z[i])!=0 && c!='\\n' && c!='\\r' && c!='\\''; i++){}\n      if( c=='\\'' ) i++;\n      if( i ){\n        utf8_printf(out, \"%.*s\", i, z);\n        z += i;\n      }\n      if( c=='\\'' ){\n        raw_printf(out, \"'\");\n        continue;\n      }\n      if( c==0 ){\n        break;\n      }\n      z++;\n      if( c=='\\n' ){\n        raw_printf(out, \"%s\", zNL);\n        continue;\n      }\n      raw_printf(out, \"%s\", zCR);\n    }\n    raw_printf(out, \"'\");\n    if( nCR ){\n      raw_printf(out, \",'%s',char(13))\", zCR);\n    }\n    if( nNL ){\n      raw_printf(out, \",'%s',char(10))\", zNL);\n    }\n  }\n  setTextMode(out, 1);\n}\n\n/*\n** Output the given string as a quoted according to C or TCL quoting rules.\n*/\nstatic void output_c_string(FILE *out, const char *z){\n  unsigned int c;\n  fputc('\"', out);\n  while( (c = *(z++))!=0 ){\n    if( c=='\\\\' ){\n      fputc(c, out);\n      fputc(c, out);\n    }else if( c=='\"' ){\n      fputc('\\\\', out);\n      fputc('\"', out);\n    }else if( c=='\\t' ){\n      fputc('\\\\', out);\n      fputc('t', out);\n    }else if( c=='\\n' ){\n      fputc('\\\\', out);\n      fputc('n', out);\n    }else if( c=='\\r' ){\n      fputc('\\\\', out);\n      fputc('r', out);\n    }else if( !isprint(c&0xff) ){\n      raw_printf(out, \"\\\\%03o\", c&0xff);\n    }else{\n      fputc(c, out);\n    }\n  }\n  fputc('\"', out);\n}\n\n/*\n** Output the given string with characters that are special to\n** HTML escaped.\n*/\nstatic void output_html_string(FILE *out, const char *z){\n  int i;\n  if( z==0 ) z = \"\";\n  while( *z ){\n    for(i=0;   z[i]\n            && z[i]!='<'\n            && z[i]!='&'\n            && z[i]!='>'\n            && z[i]!='\\\"'\n            && z[i]!='\\'';\n        i++){}\n    if( i>0 ){\n      utf8_printf(out,\"%.*s\",i,z);\n    }\n    if( z[i]=='<' ){\n      raw_printf(out,\"&lt;\");\n    }else if( z[i]=='&' ){\n      raw_printf(out,\"&amp;\");\n    }else if( z[i]=='>' ){\n      raw_printf(out,\"&gt;\");\n    }else if( z[i]=='\\\"' ){\n      raw_printf(out,\"&quot;\");\n    }else if( z[i]=='\\'' ){\n      raw_printf(out,\"&#39;\");\n    }else{\n      break;\n    }\n    z += i + 1;\n  }\n}\n\n/*\n** If a field contains any character identified by a 1 in the following\n** array, then the string must be quoted for CSV.\n*/\nstatic const char needCsvQuote[] = {\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,\n};\n\n/*\n** Output a single term of CSV.  Actually, p->colSeparator is used for\n** the separator, which may or may not be a comma.  p->nullValue is\n** the null value.  Strings are quoted if necessary.  The separator\n** is only issued if bSep is true.\n*/\nstatic void output_csv(ShellState *p, const char *z, int bSep){\n  FILE *out = p->out;\n  if( z==0 ){\n    utf8_printf(out,\"%s\",p->nullValue);\n  }else{\n    int i;\n    int nSep = strlen30(p->colSeparator);\n    for(i=0; z[i]; i++){\n      if( needCsvQuote[((unsigned char*)z)[i]]\n         || (z[i]==p->colSeparator[0] &&\n             (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){\n        i = 0;\n        break;\n      }\n    }\n    if( i==0 ){\n      putc('\"', out);\n      for(i=0; z[i]; i++){\n        if( z[i]=='\"' ) putc('\"', out);\n        putc(z[i], out);\n      }\n      putc('\"', out);\n    }else{\n      utf8_printf(out, \"%s\", z);\n    }\n  }\n  if( bSep ){\n    utf8_printf(p->out, \"%s\", p->colSeparator);\n  }\n}\n\n#ifdef SIGINT\n/*\n** This routine runs when the user presses Ctrl-C\n*/\nstatic void interrupt_handler(int NotUsed){\n  UNUSED_PARAMETER(NotUsed);\n  seenInterrupt++;\n  if( seenInterrupt>2 ) exit(1);\n  if( globalDb ) sqlite3_interrupt(globalDb);\n}\n#endif\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n/*\n** When the \".auth ON\" is set, the following authorizer callback is\n** invoked.  It always returns SQLITE_OK.\n*/\nstatic int shellAuth(\n  void *pClientData,\n  int op,\n  const char *zA1,\n  const char *zA2,\n  const char *zA3,\n  const char *zA4\n){\n  ShellState *p = (ShellState*)pClientData;\n  static const char *azAction[] = { 0,\n     \"CREATE_INDEX\",         \"CREATE_TABLE\",         \"CREATE_TEMP_INDEX\",\n     \"CREATE_TEMP_TABLE\",    \"CREATE_TEMP_TRIGGER\",  \"CREATE_TEMP_VIEW\",\n     \"CREATE_TRIGGER\",       \"CREATE_VIEW\",          \"DELETE\",\n     \"DROP_INDEX\",           \"DROP_TABLE\",           \"DROP_TEMP_INDEX\",\n     \"DROP_TEMP_TABLE\",      \"DROP_TEMP_TRIGGER\",    \"DROP_TEMP_VIEW\",\n     \"DROP_TRIGGER\",         \"DROP_VIEW\",            \"INSERT\",\n     \"PRAGMA\",               \"READ\",                 \"SELECT\",\n     \"TRANSACTION\",          \"UPDATE\",               \"ATTACH\",\n     \"DETACH\",               \"ALTER_TABLE\",          \"REINDEX\",\n     \"ANALYZE\",              \"CREATE_VTABLE\",        \"DROP_VTABLE\",\n     \"FUNCTION\",             \"SAVEPOINT\",            \"RECURSIVE\"\n  };\n  int i;\n  const char *az[4];\n  az[0] = zA1;\n  az[1] = zA2;\n  az[2] = zA3;\n  az[3] = zA4;\n  utf8_printf(p->out, \"authorizer: %s\", azAction[op]);\n  for(i=0; i<4; i++){\n    raw_printf(p->out, \" \");\n    if( az[i] ){\n      output_c_string(p->out, az[i]);\n    }else{\n      raw_printf(p->out, \"NULL\");\n    }\n  }\n  raw_printf(p->out, \"\\n\");\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Print a schema statement.  Part of MODE_Semi and MODE_Pretty output.\n**\n** This routine converts some CREATE TABLE statements for shadow tables\n** in FTS3/4/5 into CREATE TABLE IF NOT EXISTS statements.\n*/\nstatic void printSchemaLine(FILE *out, const char *z, const char *zTail){\n  if( sqlite3_strglob(\"CREATE TABLE ['\\\"]*\", z)==0 ){\n    utf8_printf(out, \"CREATE TABLE IF NOT EXISTS %s%s\", z+13, zTail);\n  }else{\n    utf8_printf(out, \"%s%s\", z, zTail);\n  }\n}\nstatic void printSchemaLineN(FILE *out, char *z, int n, const char *zTail){\n  char c = z[n];\n  z[n] = 0;\n  printSchemaLine(out, z, zTail);\n  z[n] = c;\n}\n\n/*\n** This is the callback routine that the shell\n** invokes for each row of a query result.\n*/\nstatic int shell_callback(\n  void *pArg,\n  int nArg,        /* Number of result columns */\n  char **azArg,    /* Text of each result column */\n  char **azCol,    /* Column names */\n  int *aiType      /* Column types */\n){\n  int i;\n  ShellState *p = (ShellState*)pArg;\n\n  if( azArg==0 ) return 0;\n  switch( p->cMode ){\n    case MODE_Line: {\n      int w = 5;\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int len = strlen30(azCol[i] ? azCol[i] : \"\");\n        if( len>w ) w = len;\n      }\n      if( p->cnt++>0 ) utf8_printf(p->out, \"%s\", p->rowSeparator);\n      for(i=0; i<nArg; i++){\n        utf8_printf(p->out,\"%*s = %s%s\", w, azCol[i],\n                azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);\n      }\n      break;\n    }\n    case MODE_Explain:\n    case MODE_Column: {\n      static const int aExplainWidths[] = {4, 13, 4, 4, 4, 13, 2, 13};\n      const int *colWidth;\n      int showHdr;\n      char *rowSep;\n      if( p->cMode==MODE_Column ){\n        colWidth = p->colWidth;\n        showHdr = p->showHeader;\n        rowSep = p->rowSeparator;\n      }else{\n        colWidth = aExplainWidths;\n        showHdr = 1;\n        rowSep = SEP_Row;\n      }\n      if( p->cnt++==0 ){\n        for(i=0; i<nArg; i++){\n          int w, n;\n          if( i<ArraySize(p->colWidth) ){\n            w = colWidth[i];\n          }else{\n            w = 0;\n          }\n          if( w==0 ){\n            w = strlenChar(azCol[i] ? azCol[i] : \"\");\n            if( w<10 ) w = 10;\n            n = strlenChar(azArg && azArg[i] ? azArg[i] : p->nullValue);\n            if( w<n ) w = n;\n          }\n          if( i<ArraySize(p->actualWidth) ){\n            p->actualWidth[i] = w;\n          }\n          if( showHdr ){\n            utf8_width_print(p->out, w, azCol[i]);\n            utf8_printf(p->out, \"%s\", i==nArg-1 ? rowSep : \"  \");\n          }\n        }\n        if( showHdr ){\n          for(i=0; i<nArg; i++){\n            int w;\n            if( i<ArraySize(p->actualWidth) ){\n               w = p->actualWidth[i];\n               if( w<0 ) w = -w;\n            }else{\n               w = 10;\n            }\n            utf8_printf(p->out,\"%-*.*s%s\",w,w,\n                   \"----------------------------------------------------------\"\n                   \"----------------------------------------------------------\",\n                    i==nArg-1 ? rowSep : \"  \");\n          }\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        int w;\n        if( i<ArraySize(p->actualWidth) ){\n           w = p->actualWidth[i];\n        }else{\n           w = 10;\n        }\n        if( p->cMode==MODE_Explain && azArg[i] && strlenChar(azArg[i])>w ){\n          w = strlenChar(azArg[i]);\n        }\n        if( i==1 && p->aiIndent && p->pStmt ){\n          if( p->iIndent<p->nIndent ){\n            utf8_printf(p->out, \"%*.s\", p->aiIndent[p->iIndent], \"\");\n          }\n          p->iIndent++;\n        }\n        utf8_width_print(p->out, w, azArg[i] ? azArg[i] : p->nullValue);\n        utf8_printf(p->out, \"%s\", i==nArg-1 ? rowSep : \"  \");\n      }\n      break;\n    }\n    case MODE_Semi: {   /* .schema and .fullschema output */\n      printSchemaLine(p->out, azArg[0], \";\\n\");\n      break;\n    }\n    case MODE_Pretty: {  /* .schema and .fullschema with --indent */\n      char *z;\n      int j;\n      int nParen = 0;\n      char cEnd = 0;\n      char c;\n      int nLine = 0;\n      assert( nArg==1 );\n      if( azArg[0]==0 ) break;\n      if( sqlite3_strlike(\"CREATE VIEW%\", azArg[0], 0)==0\n       || sqlite3_strlike(\"CREATE TRIG%\", azArg[0], 0)==0\n      ){\n        utf8_printf(p->out, \"%s;\\n\", azArg[0]);\n        break;\n      }\n      z = sqlite3_mprintf(\"%s\", azArg[0]);\n      j = 0;\n      for(i=0; IsSpace(z[i]); i++){}\n      for(; (c = z[i])!=0; i++){\n        if( IsSpace(c) ){\n          if( z[j-1]=='\\r' ) z[j-1] = '\\n';\n          if( IsSpace(z[j-1]) || z[j-1]=='(' ) continue;\n        }else if( (c=='(' || c==')') && j>0 && IsSpace(z[j-1]) ){\n          j--;\n        }\n        z[j++] = c;\n      }\n      while( j>0 && IsSpace(z[j-1]) ){ j--; }\n      z[j] = 0;\n      if( strlen30(z)>=79 ){\n        for(i=j=0; (c = z[i])!=0; i++){\n          if( c==cEnd ){\n            cEnd = 0;\n          }else if( c=='\"' || c=='\\'' || c=='`' ){\n            cEnd = c;\n          }else if( c=='[' ){\n            cEnd = ']';\n          }else if( c=='(' ){\n            nParen++;\n          }else if( c==')' ){\n            nParen--;\n            if( nLine>0 && nParen==0 && j>0 ){\n              printSchemaLineN(p->out, z, j, \"\\n\");\n              j = 0;\n            }\n          }\n          z[j++] = c;\n          if( nParen==1 && (c=='(' || c==',' || c=='\\n') ){\n            if( c=='\\n' ) j--;\n            printSchemaLineN(p->out, z, j, \"\\n  \");\n            j = 0;\n            nLine++;\n            while( IsSpace(z[i+1]) ){ i++; }\n          }\n        }\n        z[j] = 0;\n      }\n      printSchemaLine(p->out, z, \";\\n\");\n      sqlite3_free(z);\n      break;\n    }\n    case MODE_List: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          utf8_printf(p->out,\"%s%s\",azCol[i],\n                  i==nArg-1 ? p->rowSeparator : p->colSeparator);\n        }\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        char *z = azArg[i];\n        if( z==0 ) z = p->nullValue;\n        utf8_printf(p->out, \"%s\", z);\n        if( i<nArg-1 ){\n          utf8_printf(p->out, \"%s\", p->colSeparator);\n        }else{\n          utf8_printf(p->out, \"%s\", p->rowSeparator);\n        }\n      }\n      break;\n    }\n    case MODE_Html: {\n      if( p->cnt++==0 && p->showHeader ){\n        raw_printf(p->out,\"<TR>\");\n        for(i=0; i<nArg; i++){\n          raw_printf(p->out,\"<TH>\");\n          output_html_string(p->out, azCol[i]);\n          raw_printf(p->out,\"</TH>\\n\");\n        }\n        raw_printf(p->out,\"</TR>\\n\");\n      }\n      if( azArg==0 ) break;\n      raw_printf(p->out,\"<TR>\");\n      for(i=0; i<nArg; i++){\n        raw_printf(p->out,\"<TD>\");\n        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);\n        raw_printf(p->out,\"</TD>\\n\");\n      }\n      raw_printf(p->out,\"</TR>\\n\");\n      break;\n    }\n    case MODE_Tcl: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_c_string(p->out,azCol[i] ? azCol[i] : \"\");\n          if(i<nArg-1) utf8_printf(p->out, \"%s\", p->colSeparator);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);\n        if(i<nArg-1) utf8_printf(p->out, \"%s\", p->colSeparator);\n      }\n      utf8_printf(p->out, \"%s\", p->rowSeparator);\n      break;\n    }\n    case MODE_Csv: {\n      setBinaryMode(p->out, 1);\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          output_csv(p, azCol[i] ? azCol[i] : \"\", i<nArg-1);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( nArg>0 ){\n        for(i=0; i<nArg; i++){\n          output_csv(p, azArg[i], i<nArg-1);\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      setTextMode(p->out, 1);\n      break;\n    }\n    case MODE_Insert: {\n      if( azArg==0 ) break;\n      utf8_printf(p->out,\"INSERT INTO %s\",p->zDestTable);\n      if( p->showHeader ){\n        raw_printf(p->out,\"(\");\n        for(i=0; i<nArg; i++){\n          if( i>0 ) raw_printf(p->out, \",\");\n          if( quoteChar(azCol[i]) ){\n            char *z = sqlite3_mprintf(\"\\\"%w\\\"\", azCol[i]);\n            utf8_printf(p->out, \"%s\", z);\n            sqlite3_free(z);\n          }else{\n            raw_printf(p->out, \"%s\", azCol[i]);\n          }\n        }\n        raw_printf(p->out,\")\");\n      }\n      p->cnt++;\n      for(i=0; i<nArg; i++){\n        raw_printf(p->out, i>0 ? \",\" : \" VALUES(\");\n        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){\n          utf8_printf(p->out,\"NULL\");\n        }else if( aiType && aiType[i]==SQLITE_TEXT ){\n          if( ShellHasFlag(p, SHFLG_Newlines) ){\n            output_quoted_string(p->out, azArg[i]);\n          }else{\n            output_quoted_escaped_string(p->out, azArg[i]);\n          }\n        }else if( aiType && aiType[i]==SQLITE_INTEGER ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_FLOAT ){\n          char z[50];\n          double r = sqlite3_column_double(p->pStmt, i);\n          sqlite3_snprintf(50,z,\"%!.20g\", r);\n          raw_printf(p->out, \"%s\", z);\n        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){\n          const void *pBlob = sqlite3_column_blob(p->pStmt, i);\n          int nBlob = sqlite3_column_bytes(p->pStmt, i);\n          output_hex_blob(p->out, pBlob, nBlob);\n        }else if( isNumber(azArg[i], 0) ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( ShellHasFlag(p, SHFLG_Newlines) ){\n          output_quoted_string(p->out, azArg[i]);\n        }else{\n          output_quoted_escaped_string(p->out, azArg[i]);\n        }\n      }\n      raw_printf(p->out,\");\\n\");\n      break;\n    }\n    case MODE_Quote: {\n      if( azArg==0 ) break;\n      if( p->cnt==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          if( i>0 ) raw_printf(p->out, \",\");\n          output_quoted_string(p->out, azCol[i]);\n        }\n        raw_printf(p->out,\"\\n\");\n      }\n      p->cnt++;\n      for(i=0; i<nArg; i++){\n        if( i>0 ) raw_printf(p->out, \",\");\n        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){\n          utf8_printf(p->out,\"NULL\");\n        }else if( aiType && aiType[i]==SQLITE_TEXT ){\n          output_quoted_string(p->out, azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_INTEGER ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else if( aiType && aiType[i]==SQLITE_FLOAT ){\n          char z[50];\n          double r = sqlite3_column_double(p->pStmt, i);\n          sqlite3_snprintf(50,z,\"%!.20g\", r);\n          raw_printf(p->out, \"%s\", z);\n        }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){\n          const void *pBlob = sqlite3_column_blob(p->pStmt, i);\n          int nBlob = sqlite3_column_bytes(p->pStmt, i);\n          output_hex_blob(p->out, pBlob, nBlob);\n        }else if( isNumber(azArg[i], 0) ){\n          utf8_printf(p->out,\"%s\", azArg[i]);\n        }else{\n          output_quoted_string(p->out, azArg[i]);\n        }\n      }\n      raw_printf(p->out,\"\\n\");\n      break;\n    }\n    case MODE_Ascii: {\n      if( p->cnt++==0 && p->showHeader ){\n        for(i=0; i<nArg; i++){\n          if( i>0 ) utf8_printf(p->out, \"%s\", p->colSeparator);\n          utf8_printf(p->out,\"%s\",azCol[i] ? azCol[i] : \"\");\n        }\n        utf8_printf(p->out, \"%s\", p->rowSeparator);\n      }\n      if( azArg==0 ) break;\n      for(i=0; i<nArg; i++){\n        if( i>0 ) utf8_printf(p->out, \"%s\", p->colSeparator);\n        utf8_printf(p->out,\"%s\",azArg[i] ? azArg[i] : p->nullValue);\n      }\n      utf8_printf(p->out, \"%s\", p->rowSeparator);\n      break;\n    }\n  }\n  return 0;\n}\n\n/*\n** This is the callback routine that the SQLite library\n** invokes for each row of a query result.\n*/\nstatic int callback(void *pArg, int nArg, char **azArg, char **azCol){\n  /* since we don't have type info, call the shell_callback with a NULL value */\n  return shell_callback(pArg, nArg, azArg, azCol, NULL);\n}\n\n/*\n** This is the callback routine from sqlite3_exec() that appends all\n** output onto the end of a ShellText object.\n*/\nstatic int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){\n  ShellText *p = (ShellText*)pArg;\n  int i;\n  UNUSED_PARAMETER(az);\n  if( azArg==0 ) return 0;\n  if( p->n ) appendText(p, \"|\", 0);\n  for(i=0; i<nArg; i++){\n    if( i ) appendText(p, \",\", 0);\n    if( azArg[i] ) appendText(p, azArg[i], 0);\n  }\n  return 0;\n}\n\n/*\n** Generate an appropriate SELFTEST table in the main database.\n*/\nstatic void createSelftestTable(ShellState *p){\n  char *zErrMsg = 0;\n  sqlite3_exec(p->db,\n    \"SAVEPOINT selftest_init;\\n\"\n    \"CREATE TABLE IF NOT EXISTS selftest(\\n\"\n    \"  tno INTEGER PRIMARY KEY,\\n\"   /* Test number */\n    \"  op TEXT,\\n\"                   /* Operator:  memo run */\n    \"  cmd TEXT,\\n\"                  /* Command text */\n    \"  ans TEXT\\n\"                   /* Desired answer */\n    \");\"\n    \"CREATE TEMP TABLE [_shell$self](op,cmd,ans);\\n\"\n    \"INSERT INTO [_shell$self](rowid,op,cmd)\\n\"\n    \"  VALUES(coalesce((SELECT (max(tno)+100)/10 FROM selftest),10),\\n\"\n    \"         'memo','Tests generated by --init');\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  SELECT 'run',\\n\"\n    \"    'SELECT hex(sha3_query(''SELECT type,name,tbl_name,sql \"\n                                 \"FROM sqlite_master ORDER BY 2'',224))',\\n\"\n    \"    hex(sha3_query('SELECT type,name,tbl_name,sql \"\n                          \"FROM sqlite_master ORDER BY 2',224));\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  SELECT 'run',\"\n    \"    'SELECT hex(sha3_query(''SELECT * FROM \\\"' ||\"\n    \"        printf('%w',name) || '\\\" NOT INDEXED'',224))',\\n\"\n    \"    hex(sha3_query(printf('SELECT * FROM \\\"%w\\\" NOT INDEXED',name),224))\\n\"\n    \"  FROM (\\n\"\n    \"    SELECT name FROM sqlite_master\\n\"\n    \"     WHERE type='table'\\n\"\n    \"       AND name<>'selftest'\\n\"\n    \"       AND coalesce(rootpage,0)>0\\n\"\n    \"  )\\n\"\n    \" ORDER BY name;\\n\"\n    \"INSERT INTO [_shell$self]\\n\"\n    \"  VALUES('run','PRAGMA integrity_check','ok');\\n\"\n    \"INSERT INTO selftest(tno,op,cmd,ans)\"\n    \"  SELECT rowid*10,op,cmd,ans FROM [_shell$self];\\n\"\n    \"DROP TABLE [_shell$self];\"\n    ,0,0,&zErrMsg);\n  if( zErrMsg ){\n    utf8_printf(stderr, \"SELFTEST initialization failure: %s\\n\", zErrMsg);\n    sqlite3_free(zErrMsg);\n  }\n  sqlite3_exec(p->db, \"RELEASE selftest_init\",0,0,0);\n}\n\n\n/*\n** Set the destination table field of the ShellState structure to\n** the name of the table given.  Escape any quote characters in the\n** table name.\n*/\nstatic void set_table_name(ShellState *p, const char *zName){\n  int i, n;\n  char cQuote;\n  char *z;\n\n  if( p->zDestTable ){\n    free(p->zDestTable);\n    p->zDestTable = 0;\n  }\n  if( zName==0 ) return;\n  cQuote = quoteChar(zName);\n  n = strlen30(zName);\n  if( cQuote ) n += n+2;\n  z = p->zDestTable = malloc( n+1 );\n  if( z==0 ){\n    raw_printf(stderr,\"Error: out of memory\\n\");\n    exit(1);\n  }\n  n = 0;\n  if( cQuote ) z[n++] = cQuote;\n  for(i=0; zName[i]; i++){\n    z[n++] = zName[i];\n    if( zName[i]==cQuote ) z[n++] = cQuote;\n  }\n  if( cQuote ) z[n++] = cQuote;\n  z[n] = 0;\n}\n\n\n/*\n** Execute a query statement that will generate SQL output.  Print\n** the result columns, comma-separated, on a line and then add a\n** semicolon terminator to the end of that line.\n**\n** If the number of columns is 1 and that column contains text \"--\"\n** then write the semicolon on a separate line.  That way, if a\n** \"--\" comment occurs at the end of the statement, the comment\n** won't consume the semicolon terminator.\n*/\nstatic int run_table_dump_query(\n  ShellState *p,           /* Query context */\n  const char *zSelect,     /* SELECT statement to extract content */\n  const char *zFirstRow    /* Print before first row, if not NULL */\n){\n  sqlite3_stmt *pSelect;\n  int rc;\n  int nResult;\n  int i;\n  const char *z;\n  rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);\n  if( rc!=SQLITE_OK || !pSelect ){\n    utf8_printf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;\n    return rc;\n  }\n  rc = sqlite3_step(pSelect);\n  nResult = sqlite3_column_count(pSelect);\n  while( rc==SQLITE_ROW ){\n    if( zFirstRow ){\n      utf8_printf(p->out, \"%s\", zFirstRow);\n      zFirstRow = 0;\n    }\n    z = (const char*)sqlite3_column_text(pSelect, 0);\n    utf8_printf(p->out, \"%s\", z);\n    for(i=1; i<nResult; i++){\n      utf8_printf(p->out, \",%s\", sqlite3_column_text(pSelect, i));\n    }\n    if( z==0 ) z = \"\";\n    while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;\n    if( z[0] ){\n      raw_printf(p->out, \"\\n;\\n\");\n    }else{\n      raw_printf(p->out, \";\\n\");\n    }\n    rc = sqlite3_step(pSelect);\n  }\n  rc = sqlite3_finalize(pSelect);\n  if( rc!=SQLITE_OK ){\n    utf8_printf(p->out, \"/**** ERROR: (%d) %s *****/\\n\", rc,\n                sqlite3_errmsg(p->db));\n    if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;\n  }\n  return rc;\n}\n\n/*\n** Allocate space and save off current error string.\n*/\nstatic char *save_err_msg(\n  sqlite3 *db            /* Database to query */\n){\n  int nErrMsg = 1+strlen30(sqlite3_errmsg(db));\n  char *zErrMsg = sqlite3_malloc64(nErrMsg);\n  if( zErrMsg ){\n    memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);\n  }\n  return zErrMsg;\n}\n\n#ifdef __linux__\n/*\n** Attempt to display I/O stats on Linux using /proc/PID/io\n*/\nstatic void displayLinuxIoStats(FILE *out){\n  FILE *in;\n  char z[200];\n  sqlite3_snprintf(sizeof(z), z, \"/proc/%d/io\", getpid());\n  in = fopen(z, \"rb\");\n  if( in==0 ) return;\n  while( fgets(z, sizeof(z), in)!=0 ){\n    static const struct {\n      const char *zPattern;\n      const char *zDesc;\n    } aTrans[] = {\n      { \"rchar: \",                  \"Bytes received by read():\" },\n      { \"wchar: \",                  \"Bytes sent to write():\"    },\n      { \"syscr: \",                  \"Read() system calls:\"      },\n      { \"syscw: \",                  \"Write() system calls:\"     },\n      { \"read_bytes: \",             \"Bytes read from storage:\"  },\n      { \"write_bytes: \",            \"Bytes written to storage:\" },\n      { \"cancelled_write_bytes: \",  \"Cancelled write bytes:\"    },\n    };\n    int i;\n    for(i=0; i<ArraySize(aTrans); i++){\n      int n = (int)strlen(aTrans[i].zPattern);\n      if( strncmp(aTrans[i].zPattern, z, n)==0 ){\n        utf8_printf(out, \"%-36s %s\", aTrans[i].zDesc, &z[n]);\n        break;\n      }\n    }\n  }\n  fclose(in);\n}\n#endif\n\n/*\n** Display a single line of status using 64-bit values.\n*/\nstatic void displayStatLine(\n  ShellState *p,            /* The shell context */\n  char *zLabel,             /* Label for this one line */\n  char *zFormat,            /* Format for the result */\n  int iStatusCtrl,          /* Which status to display */\n  int bReset                /* True to reset the stats */\n){\n  sqlite3_int64 iCur = -1;\n  sqlite3_int64 iHiwtr = -1;\n  int i, nPercent;\n  char zLine[200];\n  sqlite3_status64(iStatusCtrl, &iCur, &iHiwtr, bReset);\n  for(i=0, nPercent=0; zFormat[i]; i++){\n    if( zFormat[i]=='%' ) nPercent++;\n  }\n  if( nPercent>1 ){\n    sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iCur, iHiwtr);\n  }else{\n    sqlite3_snprintf(sizeof(zLine), zLine, zFormat, iHiwtr);\n  }\n  raw_printf(p->out, \"%-36s %s\\n\", zLabel, zLine);\n}\n\n/*\n** Display memory stats.\n*/\nstatic int display_stats(\n  sqlite3 *db,                /* Database to query */\n  ShellState *pArg,           /* Pointer to ShellState */\n  int bReset                  /* True to reset the stats */\n){\n  int iCur;\n  int iHiwtr;\n\n  if( pArg && pArg->out ){\n    displayStatLine(pArg, \"Memory Used:\",\n       \"%lld (max %lld) bytes\", SQLITE_STATUS_MEMORY_USED, bReset);\n    displayStatLine(pArg, \"Number of Outstanding Allocations:\",\n       \"%lld (max %lld)\", SQLITE_STATUS_MALLOC_COUNT, bReset);\n    if( pArg->shellFlgs & SHFLG_Pagecache ){\n      displayStatLine(pArg, \"Number of Pcache Pages Used:\",\n         \"%lld (max %lld) pages\", SQLITE_STATUS_PAGECACHE_USED, bReset);\n    }\n    displayStatLine(pArg, \"Number of Pcache Overflow Bytes:\",\n       \"%lld (max %lld) bytes\", SQLITE_STATUS_PAGECACHE_OVERFLOW, bReset);\n    displayStatLine(pArg, \"Largest Allocation:\",\n       \"%lld bytes\", SQLITE_STATUS_MALLOC_SIZE, bReset);\n    displayStatLine(pArg, \"Largest Pcache Allocation:\",\n       \"%lld bytes\", SQLITE_STATUS_PAGECACHE_SIZE, bReset);\n#ifdef YYTRACKMAXSTACKDEPTH\n    displayStatLine(pArg, \"Deepest Parser Stack:\",\n       \"%lld (max %lld)\", SQLITE_STATUS_PARSER_STACK, bReset);\n#endif\n  }\n\n  if( pArg && pArg->out && db ){\n    if( pArg->shellFlgs & SHFLG_Lookaside ){\n      iHiwtr = iCur = -1;\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out,\n              \"Lookaside Slots Used:                %d (max %d)\\n\",\n              iCur, iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Successful lookaside attempts:       %d\\n\",\n              iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Lookaside failures due to size:      %d\\n\",\n              iHiwtr);\n      sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,\n                        &iCur, &iHiwtr, bReset);\n      raw_printf(pArg->out, \"Lookaside failures due to OOM:       %d\\n\",\n              iHiwtr);\n    }\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Pager Heap Usage:                    %d bytes\\n\",\n            iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache hits:                     %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache misses:                   %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);\n    raw_printf(pArg->out, \"Page cache writes:                   %d\\n\", iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Schema Heap Usage:                   %d bytes\\n\",\n            iCur);\n    iHiwtr = iCur = -1;\n    sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);\n    raw_printf(pArg->out, \"Statement Heap/Lookaside Usage:      %d bytes\\n\",\n            iCur);\n  }\n\n  if( pArg && pArg->out && db && pArg->pStmt ){\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,\n                               bReset);\n    raw_printf(pArg->out, \"Fullscan Steps:                      %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);\n    raw_printf(pArg->out, \"Sort Operations:                     %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);\n    raw_printf(pArg->out, \"Autoindex Inserts:                   %d\\n\", iCur);\n    iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);\n    raw_printf(pArg->out, \"Virtual Machine Steps:               %d\\n\", iCur);\n  }\n\n#ifdef __linux__\n  displayLinuxIoStats(pArg->out);\n#endif\n\n  /* Do not remove this machine readable comment: extra-stats-output-here */\n\n  return 0;\n}\n\n/*\n** Display scan stats.\n*/\nstatic void display_scanstats(\n  sqlite3 *db,                    /* Database to query */\n  ShellState *pArg                /* Pointer to ShellState */\n){\n#ifndef SQLITE_ENABLE_STMT_SCANSTATUS\n  UNUSED_PARAMETER(db);\n  UNUSED_PARAMETER(pArg);\n#else\n  int i, k, n, mx;\n  raw_printf(pArg->out, \"-------- scanstats --------\\n\");\n  mx = 0;\n  for(k=0; k<=mx; k++){\n    double rEstLoop = 1.0;\n    for(i=n=0; 1; i++){\n      sqlite3_stmt *p = pArg->pStmt;\n      sqlite3_int64 nLoop, nVisit;\n      double rEst;\n      int iSid;\n      const char *zExplain;\n      if( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop) ){\n        break;\n      }\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_SELECTID, (void*)&iSid);\n      if( iSid>mx ) mx = iSid;\n      if( iSid!=k ) continue;\n      if( n==0 ){\n        rEstLoop = (double)nLoop;\n        if( k>0 ) raw_printf(pArg->out, \"-------- subquery %d -------\\n\", k);\n      }\n      n++;\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);\n      sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);\n      utf8_printf(pArg->out, \"Loop %2d: %s\\n\", n, zExplain);\n      rEstLoop *= rEst;\n      raw_printf(pArg->out,\n          \"         nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\\n\",\n          nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst\n      );\n    }\n  }\n  raw_printf(pArg->out, \"---------------------------\\n\");\n#endif\n}\n\n/*\n** Parameter azArray points to a zero-terminated array of strings. zStr\n** points to a single nul-terminated string. Return non-zero if zStr\n** is equal, according to strcmp(), to any of the strings in the array.\n** Otherwise, return zero.\n*/\nstatic int str_in_array(const char *zStr, const char **azArray){\n  int i;\n  for(i=0; azArray[i]; i++){\n    if( 0==strcmp(zStr, azArray[i]) ) return 1;\n  }\n  return 0;\n}\n\n/*\n** If compiled statement pSql appears to be an EXPLAIN statement, allocate\n** and populate the ShellState.aiIndent[] array with the number of\n** spaces each opcode should be indented before it is output.\n**\n** The indenting rules are:\n**\n**     * For each \"Next\", \"Prev\", \"VNext\" or \"VPrev\" instruction, indent\n**       all opcodes that occur between the p2 jump destination and the opcode\n**       itself by 2 spaces.\n**\n**     * For each \"Goto\", if the jump destination is earlier in the program\n**       and ends on one of:\n**          Yield  SeekGt  SeekLt  RowSetRead  Rewind\n**       or if the P1 parameter is one instead of zero,\n**       then indent all opcodes between the earlier instruction\n**       and \"Goto\" by 2 spaces.\n*/\nstatic void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){\n  const char *zSql;               /* The text of the SQL statement */\n  const char *z;                  /* Used to check if this is an EXPLAIN */\n  int *abYield = 0;               /* True if op is an OP_Yield */\n  int nAlloc = 0;                 /* Allocated size of p->aiIndent[], abYield */\n  int iOp;                        /* Index of operation in p->aiIndent[] */\n\n  const char *azNext[] = { \"Next\", \"Prev\", \"VPrev\", \"VNext\", \"SorterNext\",\n                           \"NextIfOpen\", \"PrevIfOpen\", 0 };\n  const char *azYield[] = { \"Yield\", \"SeekLT\", \"SeekGT\", \"RowSetRead\",\n                            \"Rewind\", 0 };\n  const char *azGoto[] = { \"Goto\", 0 };\n\n  /* Try to figure out if this is really an EXPLAIN statement. If this\n  ** cannot be verified, return early.  */\n  if( sqlite3_column_count(pSql)!=8 ){\n    p->cMode = p->mode;\n    return;\n  }\n  zSql = sqlite3_sql(pSql);\n  if( zSql==0 ) return;\n  for(z=zSql; *z==' ' || *z=='\\t' || *z=='\\n' || *z=='\\f' || *z=='\\r'; z++);\n  if( sqlite3_strnicmp(z, \"explain\", 7) ){\n    p->cMode = p->mode;\n    return;\n  }\n\n  for(iOp=0; SQLITE_ROW==sqlite3_step(pSql); iOp++){\n    int i;\n    int iAddr = sqlite3_column_int(pSql, 0);\n    const char *zOp = (const char*)sqlite3_column_text(pSql, 1);\n\n    /* Set p2 to the P2 field of the current opcode. Then, assuming that\n    ** p2 is an instruction address, set variable p2op to the index of that\n    ** instruction in the aiIndent[] array. p2 and p2op may be different if\n    ** the current instruction is part of a sub-program generated by an\n    ** SQL trigger or foreign key.  */\n    int p2 = sqlite3_column_int(pSql, 3);\n    int p2op = (p2 + (iOp-iAddr));\n\n    /* Grow the p->aiIndent array as required */\n    if( iOp>=nAlloc ){\n      if( iOp==0 ){\n        /* Do further verfication that this is explain output.  Abort if\n        ** it is not */\n        static const char *explainCols[] = {\n           \"addr\", \"opcode\", \"p1\", \"p2\", \"p3\", \"p4\", \"p5\", \"comment\" };\n        int jj;\n        for(jj=0; jj<ArraySize(explainCols); jj++){\n          if( strcmp(sqlite3_column_name(pSql,jj),explainCols[jj])!=0 ){\n            p->cMode = p->mode;\n            sqlite3_reset(pSql);\n            return;\n          }\n        }\n      }\n      nAlloc += 100;\n      p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));\n      abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));\n    }\n    abYield[iOp] = str_in_array(zOp, azYield);\n    p->aiIndent[iOp] = 0;\n    p->nIndent = iOp+1;\n\n    if( str_in_array(zOp, azNext) ){\n      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;\n    }\n    if( str_in_array(zOp, azGoto) && p2op<p->nIndent\n     && (abYield[p2op] || sqlite3_column_int(pSql, 2))\n    ){\n      for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;\n    }\n  }\n\n  p->iIndent = 0;\n  sqlite3_free(abYield);\n  sqlite3_reset(pSql);\n}\n\n/*\n** Free the array allocated by explain_data_prepare().\n*/\nstatic void explain_data_delete(ShellState *p){\n  sqlite3_free(p->aiIndent);\n  p->aiIndent = 0;\n  p->nIndent = 0;\n  p->iIndent = 0;\n}\n\n/*\n** Disable and restore .wheretrace and .selecttrace settings.\n*/\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\nextern int sqlite3SelectTrace;\nstatic int savedSelectTrace;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\nextern int sqlite3WhereTrace;\nstatic int savedWhereTrace;\n#endif\nstatic void disable_debug_trace_modes(void){\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  savedSelectTrace = sqlite3SelectTrace;\n  sqlite3SelectTrace = 0;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  savedWhereTrace = sqlite3WhereTrace;\n  sqlite3WhereTrace = 0;\n#endif\n}\nstatic void restore_debug_trace_modes(void){\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  sqlite3SelectTrace = savedSelectTrace;\n#endif\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  sqlite3WhereTrace = savedWhereTrace;\n#endif\n}\n\n/*\n** Run a prepared statement\n*/\nstatic void exec_prepared_stmt(\n  ShellState *pArg,                                /* Pointer to ShellState */\n  sqlite3_stmt *pStmt,                             /* Statment to run */\n  int (*xCallback)(void*,int,char**,char**,int*)   /* Callback function */\n){\n  int rc;\n\n  /* perform the first step.  this will tell us if we\n  ** have a result set or not and how wide it is.\n  */\n  rc = sqlite3_step(pStmt);\n  /* if we have a result set... */\n  if( SQLITE_ROW == rc ){\n    /* if we have a callback... */\n    if( xCallback ){\n      /* allocate space for col name ptr, value ptr, and type */\n      int nCol = sqlite3_column_count(pStmt);\n      void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);\n      if( !pData ){\n        rc = SQLITE_NOMEM;\n      }else{\n        char **azCols = (char **)pData;      /* Names of result columns */\n        char **azVals = &azCols[nCol];       /* Results */\n        int *aiTypes = (int *)&azVals[nCol]; /* Result types */\n        int i, x;\n        assert(sizeof(int) <= sizeof(char *));\n        /* save off ptrs to column names */\n        for(i=0; i<nCol; i++){\n          azCols[i] = (char *)sqlite3_column_name(pStmt, i);\n        }\n        do{\n          /* extract the data and data types */\n          for(i=0; i<nCol; i++){\n            aiTypes[i] = x = sqlite3_column_type(pStmt, i);\n            if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){\n              azVals[i] = \"\";\n            }else{\n              azVals[i] = (char*)sqlite3_column_text(pStmt, i);\n            }\n            if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){\n              rc = SQLITE_NOMEM;\n              break; /* from for */\n            }\n          } /* end for */\n\n          /* if data and types extracted successfully... */\n          if( SQLITE_ROW == rc ){\n            /* call the supplied callback with the result row data */\n            if( xCallback(pArg, nCol, azVals, azCols, aiTypes) ){\n              rc = SQLITE_ABORT;\n            }else{\n              rc = sqlite3_step(pStmt);\n            }\n          }\n        } while( SQLITE_ROW == rc );\n        sqlite3_free(pData);\n      }\n    }else{\n      do{\n        rc = sqlite3_step(pStmt);\n      } while( rc == SQLITE_ROW );\n    }\n  }\n}\n\n/*\n** Execute a statement or set of statements.  Print\n** any result rows/columns depending on the current mode\n** set via the supplied callback.\n**\n** This is very similar to SQLite's built-in sqlite3_exec()\n** function except it takes a slightly different callback\n** and callback data argument.\n*/\nstatic int shell_exec(\n  sqlite3 *db,                              /* An open database */\n  const char *zSql,                         /* SQL to be evaluated */\n  int (*xCallback)(void*,int,char**,char**,int*),   /* Callback function */\n                                            /* (not the same as sqlite3_exec) */\n  ShellState *pArg,                         /* Pointer to ShellState */\n  char **pzErrMsg                           /* Error msg written here */\n){\n  sqlite3_stmt *pStmt = NULL;     /* Statement to execute. */\n  int rc = SQLITE_OK;             /* Return Code */\n  int rc2;\n  const char *zLeftover;          /* Tail of unprocessed SQL */\n\n  if( pzErrMsg ){\n    *pzErrMsg = NULL;\n  }\n\n  while( zSql[0] && (SQLITE_OK == rc) ){\n    static const char *zStmtSql;\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);\n    if( SQLITE_OK != rc ){\n      if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n    }else{\n      if( !pStmt ){\n        /* this happens for a comment or white-space */\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n        continue;\n      }\n      zStmtSql = sqlite3_sql(pStmt);\n      if( zStmtSql==0 ) zStmtSql = \"\";\n      while( IsSpace(zStmtSql[0]) ) zStmtSql++;\n\n      /* save off the prepared statment handle and reset row count */\n      if( pArg ){\n        pArg->pStmt = pStmt;\n        pArg->cnt = 0;\n      }\n\n      /* echo the sql statement if echo on */\n      if( pArg && ShellHasFlag(pArg, SHFLG_Echo) ){\n        utf8_printf(pArg->out, \"%s\\n\", zStmtSql ? zStmtSql : zSql);\n      }\n\n      /* Show the EXPLAIN QUERY PLAN if .eqp is on */\n      if( pArg && pArg->autoEQP && sqlite3_strlike(\"EXPLAIN%\",zStmtSql,0)!=0 ){\n        sqlite3_stmt *pExplain;\n        char *zEQP;\n        disable_debug_trace_modes();\n        zEQP = sqlite3_mprintf(\"EXPLAIN QUERY PLAN %s\", zStmtSql);\n        rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n        if( rc==SQLITE_OK ){\n          while( sqlite3_step(pExplain)==SQLITE_ROW ){\n            raw_printf(pArg->out,\"--EQP-- %d,\",sqlite3_column_int(pExplain, 0));\n            raw_printf(pArg->out,\"%d,\", sqlite3_column_int(pExplain, 1));\n            raw_printf(pArg->out,\"%d,\", sqlite3_column_int(pExplain, 2));\n            utf8_printf(pArg->out,\"%s\\n\", sqlite3_column_text(pExplain, 3));\n          }\n        }\n        sqlite3_finalize(pExplain);\n        sqlite3_free(zEQP);\n        if( pArg->autoEQP>=2 ){\n          /* Also do an EXPLAIN for \".eqp full\" mode */\n          zEQP = sqlite3_mprintf(\"EXPLAIN %s\", zStmtSql);\n          rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n          if( rc==SQLITE_OK ){\n            pArg->cMode = MODE_Explain;\n            explain_data_prepare(pArg, pExplain);\n            exec_prepared_stmt(pArg, pExplain, xCallback);\n            explain_data_delete(pArg);\n          }\n          sqlite3_finalize(pExplain);\n          sqlite3_free(zEQP);\n        }\n        restore_debug_trace_modes();\n      }\n\n      if( pArg ){\n        pArg->cMode = pArg->mode;\n        if( pArg->autoExplain\n         && sqlite3_column_count(pStmt)==8\n         && sqlite3_strlike(\"EXPLAIN%\", zStmtSql,0)==0\n        ){\n          pArg->cMode = MODE_Explain;\n        }\n\n        /* If the shell is currently in \".explain\" mode, gather the extra\n        ** data required to add indents to the output.*/\n        if( pArg->cMode==MODE_Explain ){\n          explain_data_prepare(pArg, pStmt);\n        }\n      }\n\n      exec_prepared_stmt(pArg, pStmt, xCallback);\n      explain_data_delete(pArg);\n\n      /* print usage stats if stats on */\n      if( pArg && pArg->statsOn ){\n        display_stats(db, pArg, 0);\n      }\n\n      /* print loop-counters if required */\n      if( pArg && pArg->scanstatsOn ){\n        display_scanstats(db, pArg);\n      }\n\n      /* Finalize the statement just executed. If this fails, save a\n      ** copy of the error message. Otherwise, set zSql to point to the\n      ** next statement to execute. */\n      rc2 = sqlite3_finalize(pStmt);\n      if( rc!=SQLITE_NOMEM ) rc = rc2;\n      if( rc==SQLITE_OK ){\n        zSql = zLeftover;\n        while( IsSpace(zSql[0]) ) zSql++;\n      }else if( pzErrMsg ){\n        *pzErrMsg = save_err_msg(db);\n      }\n\n      /* clear saved stmt handle */\n      if( pArg ){\n        pArg->pStmt = NULL;\n      }\n    }\n  } /* end while */\n\n  return rc;\n}\n\n/*\n** Release memory previously allocated by tableColumnList().\n*/\nstatic void freeColumnList(char **azCol){\n  int i;\n  for(i=1; azCol[i]; i++){\n    sqlite3_free(azCol[i]);\n  }\n  /* azCol[0] is a static string */\n  sqlite3_free(azCol);\n}\n\n/*\n** Return a list of pointers to strings which are the names of all\n** columns in table zTab.   The memory to hold the names is dynamically\n** allocated and must be released by the caller using a subsequent call\n** to freeColumnList().\n**\n** The azCol[0] entry is usually NULL.  However, if zTab contains a rowid\n** value that needs to be preserved, then azCol[0] is filled in with the\n** name of the rowid column.\n**\n** The first regular column in the table is azCol[1].  The list is terminated\n** by an entry with azCol[i]==0.\n*/\nstatic char **tableColumnList(ShellState *p, const char *zTab){\n  char **azCol = 0;\n  sqlite3_stmt *pStmt;\n  char *zSql;\n  int nCol = 0;\n  int nAlloc = 0;\n  int nPK = 0;       /* Number of PRIMARY KEY columns seen */\n  int isIPK = 0;     /* True if one PRIMARY KEY column of type INTEGER */\n  int preserveRowid = ShellHasFlag(p, SHFLG_PreserveRowid);\n  int rc;\n\n  zSql = sqlite3_mprintf(\"PRAGMA table_info=%Q\", zTab);\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  if( rc ) return 0;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    if( nCol>=nAlloc-2 ){\n      nAlloc = nAlloc*2 + nCol + 10;\n      azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));\n      if( azCol==0 ){\n        raw_printf(stderr, \"Error: out of memory\\n\");\n        exit(1);\n      }\n    }\n    azCol[++nCol] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 1));\n    if( sqlite3_column_int(pStmt, 5) ){\n      nPK++;\n      if( nPK==1\n       && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),\n                          \"INTEGER\")==0\n      ){\n        isIPK = 1;\n      }else{\n        isIPK = 0;\n      }\n    }\n  }\n  sqlite3_finalize(pStmt);\n  if( azCol==0 ) return 0;\n  azCol[0] = 0;\n  azCol[nCol+1] = 0;\n\n  /* The decision of whether or not a rowid really needs to be preserved\n  ** is tricky.  We never need to preserve a rowid for a WITHOUT ROWID table\n  ** or a table with an INTEGER PRIMARY KEY.  We are unable to preserve\n  ** rowids on tables where the rowid is inaccessible because there are other\n  ** columns in the table named \"rowid\", \"_rowid_\", and \"oid\".\n  */\n  if( preserveRowid && isIPK ){\n    /* If a single PRIMARY KEY column with type INTEGER was seen, then it\n    ** might be an alise for the ROWID.  But it might also be a WITHOUT ROWID\n    ** table or a INTEGER PRIMARY KEY DESC column, neither of which are\n    ** ROWID aliases.  To distinguish these cases, check to see if\n    ** there is a \"pk\" entry in \"PRAGMA index_list\".  There will be\n    ** no \"pk\" index if the PRIMARY KEY really is an alias for the ROWID.\n    */\n    zSql = sqlite3_mprintf(\"SELECT 1 FROM pragma_index_list(%Q)\"\n                           \" WHERE origin='pk'\", zTab);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      freeColumnList(azCol);\n      return 0;\n    }\n    rc = sqlite3_step(pStmt);\n    sqlite3_finalize(pStmt);\n    preserveRowid = rc==SQLITE_ROW;\n  }\n  if( preserveRowid ){\n    /* Only preserve the rowid if we can find a name to use for the\n    ** rowid */\n    static char *azRowid[] = { \"rowid\", \"_rowid_\", \"oid\" };\n    int i, j;\n    for(j=0; j<3; j++){\n      for(i=1; i<=nCol; i++){\n        if( sqlite3_stricmp(azRowid[j],azCol[i])==0 ) break;\n      }\n      if( i>nCol ){\n        /* At this point, we know that azRowid[j] is not the name of any\n        ** ordinary column in the table.  Verify that azRowid[j] is a valid\n        ** name for the rowid before adding it to azCol[0].  WITHOUT ROWID\n        ** tables will fail this last check */\n        rc = sqlite3_table_column_metadata(p->db,0,zTab,azRowid[j],0,0,0,0,0);\n        if( rc==SQLITE_OK ) azCol[0] = azRowid[j];\n        break;\n      }\n    }\n  }\n  return azCol;\n}\n\n/*\n** Toggle the reverse_unordered_selects setting.\n*/\nstatic void toggleSelectOrder(sqlite3 *db){\n  sqlite3_stmt *pStmt = 0;\n  int iSetting = 0;\n  char zStmt[100];\n  sqlite3_prepare_v2(db, \"PRAGMA reverse_unordered_selects\", -1, &pStmt, 0);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    iSetting = sqlite3_column_int(pStmt, 0);\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_snprintf(sizeof(zStmt), zStmt,\n       \"PRAGMA reverse_unordered_selects(%d)\", !iSetting);\n  sqlite3_exec(db, zStmt, 0, 0, 0);\n}\n\n/*\n** This is a different callback routine used for dumping the database.\n** Each row received by this callback consists of a table name,\n** the table type (\"index\" or \"table\") and SQL to create the table.\n** This routine should print text sufficient to recreate the table.\n*/\nstatic int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){\n  int rc;\n  const char *zTable;\n  const char *zType;\n  const char *zSql;\n  ShellState *p = (ShellState *)pArg;\n\n  UNUSED_PARAMETER(azNotUsed);\n  if( nArg!=3 || azArg==0 ) return 0;\n  zTable = azArg[0];\n  zType = azArg[1];\n  zSql = azArg[2];\n\n  if( strcmp(zTable, \"sqlite_sequence\")==0 ){\n    raw_printf(p->out, \"DELETE FROM sqlite_sequence;\\n\");\n  }else if( sqlite3_strglob(\"sqlite_stat?\", zTable)==0 ){\n    raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n  }else if( strncmp(zTable, \"sqlite_\", 7)==0 ){\n    return 0;\n  }else if( strncmp(zSql, \"CREATE VIRTUAL TABLE\", 20)==0 ){\n    char *zIns;\n    if( !p->writableSchema ){\n      raw_printf(p->out, \"PRAGMA writable_schema=ON;\\n\");\n      p->writableSchema = 1;\n    }\n    zIns = sqlite3_mprintf(\n       \"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)\"\n       \"VALUES('table','%q','%q',0,'%q');\",\n       zTable, zTable, zSql);\n    utf8_printf(p->out, \"%s\\n\", zIns);\n    sqlite3_free(zIns);\n    return 0;\n  }else{\n    printSchemaLine(p->out, zSql, \";\\n\");\n  }\n\n  if( strcmp(zType, \"table\")==0 ){\n    ShellText sSelect;\n    ShellText sTable;\n    char **azCol;\n    int i;\n    char *savedDestTable;\n    int savedMode;\n\n    azCol = tableColumnList(p, zTable);\n    if( azCol==0 ){\n      p->nErr++;\n      return 0;\n    }\n\n    /* Always quote the table name, even if it appears to be pure ascii,\n    ** in case it is a keyword. Ex:  INSERT INTO \"table\" ... */\n    initText(&sTable);\n    appendText(&sTable, zTable, quoteChar(zTable));\n    /* If preserving the rowid, add a column list after the table name.\n    ** In other words:  \"INSERT INTO tab(rowid,a,b,c,...) VALUES(...)\"\n    ** instead of the usual \"INSERT INTO tab VALUES(...)\".\n    */\n    if( azCol[0] ){\n      appendText(&sTable, \"(\", 0);\n      appendText(&sTable, azCol[0], 0);\n      for(i=1; azCol[i]; i++){\n        appendText(&sTable, \",\", 0);\n        appendText(&sTable, azCol[i], quoteChar(azCol[i]));\n      }\n      appendText(&sTable, \")\", 0);\n    }\n\n    /* Build an appropriate SELECT statement */\n    initText(&sSelect);\n    appendText(&sSelect, \"SELECT \", 0);\n    if( azCol[0] ){\n      appendText(&sSelect, azCol[0], 0);\n      appendText(&sSelect, \",\", 0);\n    }\n    for(i=1; azCol[i]; i++){\n      appendText(&sSelect, azCol[i], quoteChar(azCol[i]));\n      if( azCol[i+1] ){\n        appendText(&sSelect, \",\", 0);\n      }\n    }\n    freeColumnList(azCol);\n    appendText(&sSelect, \" FROM \", 0);\n    appendText(&sSelect, zTable, quoteChar(zTable));\n\n    savedDestTable = p->zDestTable;\n    savedMode = p->mode;\n    p->zDestTable = sTable.z;\n    p->mode = p->cMode = MODE_Insert;\n    rc = shell_exec(p->db, sSelect.z, shell_callback, p, 0);\n    if( (rc&0xff)==SQLITE_CORRUPT ){\n      raw_printf(p->out, \"/****** CORRUPTION ERROR *******/\\n\");\n      toggleSelectOrder(p->db);\n      shell_exec(p->db, sSelect.z, shell_callback, p, 0);\n      toggleSelectOrder(p->db);\n    }\n    p->zDestTable = savedDestTable;\n    p->mode = savedMode;\n    freeText(&sTable);\n    freeText(&sSelect);\n    if( rc ) p->nErr++;\n  }\n  return 0;\n}\n\n/*\n** Run zQuery.  Use dump_callback() as the callback routine so that\n** the contents of the query are output as SQL statements.\n**\n** If we get a SQLITE_CORRUPT error, rerun the query after appending\n** \"ORDER BY rowid DESC\" to the end.\n*/\nstatic int run_schema_dump_query(\n  ShellState *p,\n  const char *zQuery\n){\n  int rc;\n  char *zErr = 0;\n  rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);\n  if( rc==SQLITE_CORRUPT ){\n    char *zQ2;\n    int len = strlen30(zQuery);\n    raw_printf(p->out, \"/****** CORRUPTION ERROR *******/\\n\");\n    if( zErr ){\n      utf8_printf(p->out, \"/****** %s ******/\\n\", zErr);\n      sqlite3_free(zErr);\n      zErr = 0;\n    }\n    zQ2 = malloc( len+100 );\n    if( zQ2==0 ) return rc;\n    sqlite3_snprintf(len+100, zQ2, \"%s ORDER BY rowid DESC\", zQuery);\n    rc = sqlite3_exec(p->db, zQ2, dump_callback, p, &zErr);\n    if( rc ){\n      utf8_printf(p->out, \"/****** ERROR: %s ******/\\n\", zErr);\n    }else{\n      rc = SQLITE_CORRUPT;\n    }\n    sqlite3_free(zErr);\n    free(zQ2);\n  }\n  return rc;\n}\n\n/*\n** Text of a help message\n*/\nstatic char zHelp[] =\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  \".auth ON|OFF           Show authorizer callbacks\\n\"\n#endif\n  \".backup ?DB? FILE      Backup DB (default \\\"main\\\") to FILE\\n\"\n  \".bail on|off           Stop after hitting an error.  Default OFF\\n\"\n  \".binary on|off         Turn binary output on or off.  Default OFF\\n\"\n  \".cd DIRECTORY          Change the working directory to DIRECTORY\\n\"\n  \".changes on|off        Show number of rows changed by SQL\\n\"\n  \".check GLOB            Fail if output since .testcase does not match\\n\"\n  \".clone NEWDB           Clone data into NEWDB from the existing database\\n\"\n  \".databases             List names and files of attached databases\\n\"\n  \".dbinfo ?DB?           Show status information about the database\\n\"\n  \".dump ?TABLE? ...      Dump the database in an SQL text format\\n\"\n  \"                         If TABLE specified, only dump tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".echo on|off           Turn command echo on or off\\n\"\n  \".eqp on|off|full       Enable or disable automatic EXPLAIN QUERY PLAN\\n\"\n  \".exit                  Exit this program\\n\"\n/* Because explain mode comes on automatically now, the \".explain\" mode\n** is removed from the help screen.  It is still supported for legacy, however */\n/*\".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\\n\"*/\n  \".fullschema ?--indent? Show schema and the content of sqlite_stat tables\\n\"\n  \".headers on|off        Turn display of headers on or off\\n\"\n  \".help                  Show this message\\n\"\n  \".import FILE TABLE     Import data from FILE into TABLE\\n\"\n#ifndef SQLITE_OMIT_TEST_CONTROL\n  \".imposter INDEX TABLE  Create imposter table TABLE on index INDEX\\n\"\n#endif\n  \".indexes ?TABLE?       Show names of all indexes\\n\"\n  \"                         If TABLE specified, only show indexes for tables\\n\"\n  \"                         matching LIKE pattern TABLE.\\n\"\n#ifdef SQLITE_ENABLE_IOTRACE\n  \".iotrace FILE          Enable I/O diagnostic logging to FILE\\n\"\n#endif\n  \".limit ?LIMIT? ?VAL?   Display or change the value of an SQLITE_LIMIT\\n\"\n  \".lint OPTIONS          Report potential schema issues. Options:\\n\"\n  \"                         fkey-indexes     Find missing foreign key indexes\\n\"\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  \".load FILE ?ENTRY?     Load an extension library\\n\"\n#endif\n  \".log FILE|off          Turn logging on or off.  FILE can be stderr/stdout\\n\"\n  \".mode MODE ?TABLE?     Set output mode where MODE is one of:\\n\"\n  \"                         ascii    Columns/rows delimited by 0x1F and 0x1E\\n\"\n  \"                         csv      Comma-separated values\\n\"\n  \"                         column   Left-aligned columns.  (See .width)\\n\"\n  \"                         html     HTML <table> code\\n\"\n  \"                         insert   SQL insert statements for TABLE\\n\"\n  \"                         line     One value per line\\n\"\n  \"                         list     Values delimited by \\\"|\\\"\\n\"\n  \"                         quote    Escape answers as for SQL\\n\"\n  \"                         tabs     Tab-separated values\\n\"\n  \"                         tcl      TCL list elements\\n\"\n  \".nullvalue STRING      Use STRING in place of NULL values\\n\"\n  \".once FILENAME         Output for the next SQL command only to FILENAME\\n\"\n  \".open ?OPTIONS? ?FILE? Close existing database and reopen FILE\\n\"\n  \"                         The --new option starts with an empty file\\n\"\n  \".output ?FILENAME?     Send output to FILENAME or stdout\\n\"\n  \".print STRING...       Print literal STRING\\n\"\n  \".prompt MAIN CONTINUE  Replace the standard prompts\\n\"\n  \".quit                  Exit this program\\n\"\n  \".read FILENAME         Execute SQL in FILENAME\\n\"\n  \".restore ?DB? FILE     Restore content of DB (default \\\"main\\\") from FILE\\n\"\n  \".save FILE             Write in-memory database into FILE\\n\"\n  \".scanstats on|off      Turn sqlite3_stmt_scanstatus() metrics on or off\\n\"\n  \".schema ?PATTERN?      Show the CREATE statements matching PATTERN\\n\"\n  \"                          Add --indent for pretty-printing\\n\"\n  \".selftest ?--init?     Run tests defined in the SELFTEST table\\n\"\n  \".separator COL ?ROW?   Change the column separator and optionally the row\\n\"\n  \"                         separator for both the output mode and .import\\n\"\n#if defined(SQLITE_ENABLE_SESSION)\n  \".session CMD ...       Create or control sessions\\n\"\n#endif\n  \".sha3sum ?OPTIONS...?  Compute a SHA3 hash of database content\\n\"\n  \".shell CMD ARGS...     Run CMD ARGS... in a system shell\\n\"\n  \".show                  Show the current values for various settings\\n\"\n  \".stats ?on|off?        Show stats or turn stats on or off\\n\"\n  \".system CMD ARGS...    Run CMD ARGS... in a system shell\\n\"\n  \".tables ?TABLE?        List names of tables\\n\"\n  \"                         If TABLE specified, only list tables matching\\n\"\n  \"                         LIKE pattern TABLE.\\n\"\n  \".testcase NAME         Begin redirecting output to 'testcase-out.txt'\\n\"\n  \".timeout MS            Try opening locked tables for MS milliseconds\\n\"\n  \".timer on|off          Turn SQL timer on or off\\n\"\n  \".trace FILE|off        Output each SQL statement as it is run\\n\"\n  \".vfsinfo ?AUX?         Information about the top-level VFS\\n\"\n  \".vfslist               List all available VFSes\\n\"\n  \".vfsname ?AUX?         Print the name of the VFS stack\\n\"\n  \".width NUM1 NUM2 ...   Set column widths for \\\"column\\\" mode\\n\"\n  \"                         Negative values right-justify\\n\"\n;\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** Print help information for the \".sessions\" command\n*/\nvoid session_help(ShellState *p){\n  raw_printf(p->out,\n    \".session ?NAME? SUBCOMMAND ?ARGS...?\\n\"\n    \"If ?NAME? is omitted, the first defined session is used.\\n\"\n    \"Subcommands:\\n\"\n    \"   attach TABLE             Attach TABLE\\n\"\n    \"   changeset FILE           Write a changeset into FILE\\n\"\n    \"   close                    Close one session\\n\"\n    \"   enable ?BOOLEAN?         Set or query the enable bit\\n\"\n    \"   filter GLOB...           Reject tables matching GLOBs\\n\"\n    \"   indirect ?BOOLEAN?       Mark or query the indirect status\\n\"\n    \"   isempty                  Query whether the session is empty\\n\"\n    \"   list                     List currently open session names\\n\"\n    \"   open DB NAME             Open a new session on DB\\n\"\n    \"   patchset FILE            Write a patchset into FILE\\n\"\n  );\n}\n#endif\n\n\n/* Forward reference */\nstatic int process_input(ShellState *p, FILE *in);\n\n/*\n** Read the content of file zName into memory obtained from sqlite3_malloc64()\n** and return a pointer to the buffer. The caller is responsible for freeing\n** the memory.\n**\n** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes\n** read.\n**\n** For convenience, a nul-terminator byte is always appended to the data read\n** from the file before the buffer is returned. This byte is not included in\n** the final value of (*pnByte), if applicable.\n**\n** NULL is returned if any error is encountered. The final value of *pnByte\n** is undefined in this case.\n*/\nstatic char *readFile(const char *zName, int *pnByte){\n  FILE *in = fopen(zName, \"rb\");\n  long nIn;\n  size_t nRead;\n  char *pBuf;\n  if( in==0 ) return 0;\n  fseek(in, 0, SEEK_END);\n  nIn = ftell(in);\n  rewind(in);\n  pBuf = sqlite3_malloc64( nIn+1 );\n  if( pBuf==0 ) return 0;\n  nRead = fread(pBuf, nIn, 1, in);\n  fclose(in);\n  if( nRead!=1 ){\n    sqlite3_free(pBuf);\n    return 0;\n  }\n  pBuf[nIn] = 0;\n  if( pnByte ) *pnByte = nIn;\n  return pBuf;\n}\n\n#if defined(SQLITE_ENABLE_SESSION)\n/*\n** Close a single OpenSession object and release all of its associated\n** resources.\n*/\nstatic void session_close(OpenSession *pSession){\n  int i;\n  sqlite3session_delete(pSession->p);\n  sqlite3_free(pSession->zName);\n  for(i=0; i<pSession->nFilter; i++){\n    sqlite3_free(pSession->azFilter[i]);\n  }\n  sqlite3_free(pSession->azFilter);\n  memset(pSession, 0, sizeof(OpenSession));\n}\n#endif\n\n/*\n** Close all OpenSession objects and release all associated resources.\n*/\n#if defined(SQLITE_ENABLE_SESSION)\nstatic void session_close_all(ShellState *p){\n  int i;\n  for(i=0; i<p->nSession; i++){\n    session_close(&p->aSession[i]);\n  }\n  p->nSession = 0;\n}\n#else\n# define session_close_all(X)\n#endif\n\n/*\n** Implementation of the xFilter function for an open session.  Omit\n** any tables named by \".session filter\" but let all other table through.\n*/\n#if defined(SQLITE_ENABLE_SESSION)\nstatic int session_filter(void *pCtx, const char *zTab){\n  OpenSession *pSession = (OpenSession*)pCtx;\n  int i;\n  for(i=0; i<pSession->nFilter; i++){\n    if( sqlite3_strglob(pSession->azFilter[i], zTab)==0 ) return 0;\n  }\n  return 1;\n}\n#endif\n\n/*\n** Make sure the database is open.  If it is not, then open it.  If\n** the database fails to open, print an error message and exit.\n*/\nstatic void open_db(ShellState *p, int keepAlive){\n  if( p->db==0 ){\n    sqlite3_initialize();\n    sqlite3_open(p->zDbFilename, &p->db);\n    globalDb = p->db;\n    if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){\n      utf8_printf(stderr,\"Error: unable to open database \\\"%s\\\": %s\\n\",\n          p->zDbFilename, sqlite3_errmsg(p->db));\n      if( keepAlive ) return;\n      exit(1);\n    }\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    sqlite3_enable_load_extension(p->db, 1);\n#endif\n    sqlite3_fileio_init(p->db, 0, 0);\n    sqlite3_shathree_init(p->db, 0, 0);\n    sqlite3_completion_init(p->db, 0, 0);\n    sqlite3_create_function(p->db, \"shell_add_schema\", 2, SQLITE_UTF8, 0,\n                            shellAddSchemaName, 0, 0);\n  }\n}\n\n#if HAVE_READLINE || HAVE_EDITLINE\n/*\n** Readline completion callbacks\n*/\nstatic char *readline_completion_generator(const char *text, int state){\n  static sqlite3_stmt *pStmt = 0;\n  char *zRet;\n  if( state==0 ){\n    char *zSql;\n    sqlite3_finalize(pStmt);\n    zSql = sqlite3_mprintf(\"SELECT DISTINCT candidate COLLATE nocase\"\n                           \"  FROM completion(%Q) ORDER BY 1\", text);\n    sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n  }\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));\n  }else{\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    zRet = 0;\n  }\n  return zRet;\n}\nstatic char **readline_completion(const char *zText, int iStart, int iEnd){\n  rl_attempted_completion_over = 1;\n  return rl_completion_matches(zText, readline_completion_generator);\n}\n\n#elif HAVE_LINENOISE\n/*\n** Linenoise completion callback\n*/\nstatic void linenoise_completion(const char *zLine, linenoiseCompletions *lc){\n  int nLine = (int)strlen(zLine);\n  int i, iStart;\n  sqlite3_stmt *pStmt = 0;\n  char *zSql;\n  char zBuf[1000];\n\n  if( nLine>sizeof(zBuf)-30 ) return;\n  if( zLine[0]=='.' ) return;\n  for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}\n  if( i==nLine-1 ) return;\n  iStart = i+1;\n  memcpy(zBuf, zLine, iStart);\n  zSql = sqlite3_mprintf(\"SELECT DISTINCT candidate COLLATE nocase\"\n                         \"  FROM completion(%Q,%Q) ORDER BY 1\",\n                         &zLine[iStart], zLine);\n  sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n  sqlite3_exec(globalDb, \"PRAGMA page_count\", 0, 0, 0); /* Load the schema */\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);\n    int nCompletion = sqlite3_column_bytes(pStmt, 0);\n    if( iStart+nCompletion < sizeof(zBuf)-1 ){\n      memcpy(zBuf+iStart, zCompletion, nCompletion+1);\n      linenoiseAddCompletion(lc, zBuf);\n    }\n  }\n  sqlite3_finalize(pStmt);\n}\n#endif\n\n/*\n** Do C-language style dequoting.\n**\n**    \\a    -> alarm\n**    \\b    -> backspace\n**    \\t    -> tab\n**    \\n    -> newline\n**    \\v    -> vertical tab\n**    \\f    -> form feed\n**    \\r    -> carriage return\n**    \\s    -> space\n**    \\\"    -> \"\n**    \\'    -> '\n**    \\\\    -> backslash\n**    \\NNN  -> ascii character NNN in octal\n*/\nstatic void resolve_backslashes(char *z){\n  int i, j;\n  char c;\n  while( *z && *z!='\\\\' ) z++;\n  for(i=j=0; (c = z[i])!=0; i++, j++){\n    if( c=='\\\\' && z[i+1]!=0 ){\n      c = z[++i];\n      if( c=='a' ){\n        c = '\\a';\n      }else if( c=='b' ){\n        c = '\\b';\n      }else if( c=='t' ){\n        c = '\\t';\n      }else if( c=='n' ){\n        c = '\\n';\n      }else if( c=='v' ){\n        c = '\\v';\n      }else if( c=='f' ){\n        c = '\\f';\n      }else if( c=='r' ){\n        c = '\\r';\n      }else if( c=='\"' ){\n        c = '\"';\n      }else if( c=='\\'' ){\n        c = '\\'';\n      }else if( c=='\\\\' ){\n        c = '\\\\';\n      }else if( c>='0' && c<='7' ){\n        c -= '0';\n        if( z[i+1]>='0' && z[i+1]<='7' ){\n          i++;\n          c = (c<<3) + z[i] - '0';\n          if( z[i+1]>='0' && z[i+1]<='7' ){\n            i++;\n            c = (c<<3) + z[i] - '0';\n          }\n        }\n      }\n    }\n    z[j] = c;\n  }\n  if( j<i ) z[j] = 0;\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic sqlite3_int64 integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( IsDigit(zArg[0]) ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<ArraySize(aMult); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  return isNeg? -v : v;\n}\n\n/*\n** Interpret zArg as either an integer or a boolean value.  Return 1 or 0\n** for TRUE and FALSE.  Return the integer value if appropriate.\n*/\nstatic int booleanValue(const char *zArg){\n  int i;\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    for(i=2; hexDigitValue(zArg[i])>=0; i++){}\n  }else{\n    for(i=0; zArg[i]>='0' && zArg[i]<='9'; i++){}\n  }\n  if( i>0 && zArg[i]==0 ) return (int)(integerValue(zArg) & 0xffffffff);\n  if( sqlite3_stricmp(zArg, \"on\")==0 || sqlite3_stricmp(zArg,\"yes\")==0 ){\n    return 1;\n  }\n  if( sqlite3_stricmp(zArg, \"off\")==0 || sqlite3_stricmp(zArg,\"no\")==0 ){\n    return 0;\n  }\n  utf8_printf(stderr, \"ERROR: Not a boolean value: \\\"%s\\\". Assuming \\\"no\\\".\\n\",\n          zArg);\n  return 0;\n}\n\n/*\n** Set or clear a shell flag according to a boolean value.\n*/\nstatic void setOrClearFlag(ShellState *p, unsigned mFlag, const char *zArg){\n  if( booleanValue(zArg) ){\n    ShellSetFlag(p, mFlag);\n  }else{\n    ShellClearFlag(p, mFlag);\n  }\n}\n\n/*\n** Close an output file, assuming it is not stderr or stdout\n*/\nstatic void output_file_close(FILE *f){\n  if( f && f!=stdout && f!=stderr ) fclose(f);\n}\n\n/*\n** Try to open an output file.   The names \"stdout\" and \"stderr\" are\n** recognized and do the right thing.  NULL is returned if the output\n** filename is \"off\".\n*/\nstatic FILE *output_file_open(const char *zFile){\n  FILE *f;\n  if( strcmp(zFile,\"stdout\")==0 ){\n    f = stdout;\n  }else if( strcmp(zFile, \"stderr\")==0 ){\n    f = stderr;\n  }else if( strcmp(zFile, \"off\")==0 ){\n    f = 0;\n  }else{\n    f = fopen(zFile, \"wb\");\n    if( f==0 ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n    }\n  }\n  return f;\n}\n\n#if !defined(SQLITE_UNTESTABLE)\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n/*\n** A routine for handling output from sqlite3_trace().\n*/\nstatic int sql_trace_callback(\n  unsigned mType,\n  void *pArg,\n  void *pP,\n  void *pX\n){\n  FILE *f = (FILE*)pArg;\n  UNUSED_PARAMETER(mType);\n  UNUSED_PARAMETER(pP);\n  if( f ){\n    const char *z = (const char*)pX;\n    int i = (int)strlen(z);\n    while( i>0 && z[i-1]==';' ){ i--; }\n    utf8_printf(f, \"%.*s;\\n\", i, z);\n  }\n  return 0;\n}\n#endif\n#endif\n\n/*\n** A no-op routine that runs with the \".breakpoint\" doc-command.  This is\n** a useful spot to set a debugger breakpoint.\n*/\nstatic void test_breakpoint(void){\n  static int nCall = 0;\n  nCall++;\n}\n\n/*\n** An object used to read a CSV and other files for import.\n*/\ntypedef struct ImportCtx ImportCtx;\nstruct ImportCtx {\n  const char *zFile;  /* Name of the input file */\n  FILE *in;           /* Read the CSV text from this input stream */\n  char *z;            /* Accumulated text for a field */\n  int n;              /* Number of bytes in z */\n  int nAlloc;         /* Space allocated for z[] */\n  int nLine;          /* Current line number */\n  int bNotFirst;      /* True if one or more bytes already read */\n  int cTerm;          /* Character that terminated the most recent field */\n  int cColSep;        /* The column separator character.  (Usually \",\") */\n  int cRowSep;        /* The row separator character.  (Usually \"\\n\") */\n};\n\n/* Append a single byte to z[] */\nstatic void import_append_char(ImportCtx *p, int c){\n  if( p->n+1>=p->nAlloc ){\n    p->nAlloc += p->nAlloc + 100;\n    p->z = sqlite3_realloc64(p->z, p->nAlloc);\n    if( p->z==0 ){\n      raw_printf(stderr, \"out of memory\\n\");\n      exit(1);\n    }\n  }\n  p->z[p->n++] = (char)c;\n}\n\n/* Read a single field of CSV text.  Compatible with rfc4180 and extended\n** with the option of having a separator other than \",\".\n**\n**   +  Input comes from p->in.\n**   +  Store results in p->z of length p->n.  Space to hold p->z comes\n**      from sqlite3_malloc64().\n**   +  Use p->cSep as the column separator.  The default is \",\".\n**   +  Use p->rSep as the row separator.  The default is \"\\n\".\n**   +  Keep track of the line number in p->nLine.\n**   +  Store the character that terminates the field in p->cTerm.  Store\n**      EOF on end-of-file.\n**   +  Report syntax errors on stderr\n*/\nstatic char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){\n  int c;\n  int cSep = p->cColSep;\n  int rSep = p->cRowSep;\n  p->n = 0;\n  c = fgetc(p->in);\n  if( c==EOF || seenInterrupt ){\n    p->cTerm = EOF;\n    return 0;\n  }\n  if( c=='\"' ){\n    int pc, ppc;\n    int startLine = p->nLine;\n    int cQuote = c;\n    pc = ppc = 0;\n    while( 1 ){\n      c = fgetc(p->in);\n      if( c==rSep ) p->nLine++;\n      if( c==cQuote ){\n        if( pc==cQuote ){\n          pc = 0;\n          continue;\n        }\n      }\n      if( (c==cSep && pc==cQuote)\n       || (c==rSep && pc==cQuote)\n       || (c==rSep && pc=='\\r' && ppc==cQuote)\n       || (c==EOF && pc==cQuote)\n      ){\n        do{ p->n--; }while( p->z[p->n]!=cQuote );\n        p->cTerm = c;\n        break;\n      }\n      if( pc==cQuote && c!='\\r' ){\n        utf8_printf(stderr, \"%s:%d: unescaped %c character\\n\",\n                p->zFile, p->nLine, cQuote);\n      }\n      if( c==EOF ){\n        utf8_printf(stderr, \"%s:%d: unterminated %c-quoted field\\n\",\n                p->zFile, startLine, cQuote);\n        p->cTerm = c;\n        break;\n      }\n      import_append_char(p, c);\n      ppc = pc;\n      pc = c;\n    }\n  }else{\n    /* If this is the first field being parsed and it begins with the\n    ** UTF-8 BOM  (0xEF BB BF) then skip the BOM */\n    if( (c&0xff)==0xef && p->bNotFirst==0 ){\n      import_append_char(p, c);\n      c = fgetc(p->in);\n      if( (c&0xff)==0xbb ){\n        import_append_char(p, c);\n        c = fgetc(p->in);\n        if( (c&0xff)==0xbf ){\n          p->bNotFirst = 1;\n          p->n = 0;\n          return csv_read_one_field(p);\n        }\n      }\n    }\n    while( c!=EOF && c!=cSep && c!=rSep ){\n      import_append_char(p, c);\n      c = fgetc(p->in);\n    }\n    if( c==rSep ){\n      p->nLine++;\n      if( p->n>0 && p->z[p->n-1]=='\\r' ) p->n--;\n    }\n    p->cTerm = c;\n  }\n  if( p->z ) p->z[p->n] = 0;\n  p->bNotFirst = 1;\n  return p->z;\n}\n\n/* Read a single field of ASCII delimited text.\n**\n**   +  Input comes from p->in.\n**   +  Store results in p->z of length p->n.  Space to hold p->z comes\n**      from sqlite3_malloc64().\n**   +  Use p->cSep as the column separator.  The default is \"\\x1F\".\n**   +  Use p->rSep as the row separator.  The default is \"\\x1E\".\n**   +  Keep track of the row number in p->nLine.\n**   +  Store the character that terminates the field in p->cTerm.  Store\n**      EOF on end-of-file.\n**   +  Report syntax errors on stderr\n*/\nstatic char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){\n  int c;\n  int cSep = p->cColSep;\n  int rSep = p->cRowSep;\n  p->n = 0;\n  c = fgetc(p->in);\n  if( c==EOF || seenInterrupt ){\n    p->cTerm = EOF;\n    return 0;\n  }\n  while( c!=EOF && c!=cSep && c!=rSep ){\n    import_append_char(p, c);\n    c = fgetc(p->in);\n  }\n  if( c==rSep ){\n    p->nLine++;\n  }\n  p->cTerm = c;\n  if( p->z ) p->z[p->n] = 0;\n  return p->z;\n}\n\n/*\n** Try to transfer data for table zTable.  If an error is seen while\n** moving forward, try to go backwards.  The backwards movement won't\n** work for WITHOUT ROWID tables.\n*/\nstatic void tryToCloneData(\n  ShellState *p,\n  sqlite3 *newDb,\n  const char *zTable\n){\n  sqlite3_stmt *pQuery = 0;\n  sqlite3_stmt *pInsert = 0;\n  char *zQuery = 0;\n  char *zInsert = 0;\n  int rc;\n  int i, j, n;\n  int nTable = (int)strlen(zTable);\n  int k = 0;\n  int cnt = 0;\n  const int spinRate = 10000;\n\n  zQuery = sqlite3_mprintf(\"SELECT * FROM \\\"%w\\\"\", zTable);\n  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error %d: %s on [%s]\\n\",\n            sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n            zQuery);\n    goto end_data_xfer;\n  }\n  n = sqlite3_column_count(pQuery);\n  zInsert = sqlite3_malloc64(200 + nTable + n*3);\n  if( zInsert==0 ){\n    raw_printf(stderr, \"out of memory\\n\");\n    goto end_data_xfer;\n  }\n  sqlite3_snprintf(200+nTable,zInsert,\n                   \"INSERT OR IGNORE INTO \\\"%s\\\" VALUES(?\", zTable);\n  i = (int)strlen(zInsert);\n  for(j=1; j<n; j++){\n    memcpy(zInsert+i, \",?\", 2);\n    i += 2;\n  }\n  memcpy(zInsert+i, \");\", 3);\n  rc = sqlite3_prepare_v2(newDb, zInsert, -1, &pInsert, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error %d: %s on [%s]\\n\",\n            sqlite3_extended_errcode(newDb), sqlite3_errmsg(newDb),\n            zQuery);\n    goto end_data_xfer;\n  }\n  for(k=0; k<2; k++){\n    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n      for(i=0; i<n; i++){\n        switch( sqlite3_column_type(pQuery, i) ){\n          case SQLITE_NULL: {\n            sqlite3_bind_null(pInsert, i+1);\n            break;\n          }\n          case SQLITE_INTEGER: {\n            sqlite3_bind_int64(pInsert, i+1, sqlite3_column_int64(pQuery,i));\n            break;\n          }\n          case SQLITE_FLOAT: {\n            sqlite3_bind_double(pInsert, i+1, sqlite3_column_double(pQuery,i));\n            break;\n          }\n          case SQLITE_TEXT: {\n            sqlite3_bind_text(pInsert, i+1,\n                             (const char*)sqlite3_column_text(pQuery,i),\n                             -1, SQLITE_STATIC);\n            break;\n          }\n          case SQLITE_BLOB: {\n            sqlite3_bind_blob(pInsert, i+1, sqlite3_column_blob(pQuery,i),\n                                            sqlite3_column_bytes(pQuery,i),\n                                            SQLITE_STATIC);\n            break;\n          }\n        }\n      } /* End for */\n      rc = sqlite3_step(pInsert);\n      if( rc!=SQLITE_OK && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){\n        utf8_printf(stderr, \"Error %d: %s\\n\", sqlite3_extended_errcode(newDb),\n                        sqlite3_errmsg(newDb));\n      }\n      sqlite3_reset(pInsert);\n      cnt++;\n      if( (cnt%spinRate)==0 ){\n        printf(\"%c\\b\", \"|/-\\\\\"[(cnt/spinRate)%4]);\n        fflush(stdout);\n      }\n    } /* End while */\n    if( rc==SQLITE_DONE ) break;\n    sqlite3_finalize(pQuery);\n    sqlite3_free(zQuery);\n    zQuery = sqlite3_mprintf(\"SELECT * FROM \\\"%w\\\" ORDER BY rowid DESC;\",\n                             zTable);\n    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n    if( rc ){\n      utf8_printf(stderr, \"Warning: cannot step \\\"%s\\\" backwards\", zTable);\n      break;\n    }\n  } /* End for(k=0...) */\n\nend_data_xfer:\n  sqlite3_finalize(pQuery);\n  sqlite3_finalize(pInsert);\n  sqlite3_free(zQuery);\n  sqlite3_free(zInsert);\n}\n\n\n/*\n** Try to transfer all rows of the schema that match zWhere.  For\n** each row, invoke xForEach() on the object defined by that row.\n** If an error is encountered while moving forward through the\n** sqlite_master table, try again moving backwards.\n*/\nstatic void tryToCloneSchema(\n  ShellState *p,\n  sqlite3 *newDb,\n  const char *zWhere,\n  void (*xForEach)(ShellState*,sqlite3*,const char*)\n){\n  sqlite3_stmt *pQuery = 0;\n  char *zQuery = 0;\n  int rc;\n  const unsigned char *zName;\n  const unsigned char *zSql;\n  char *zErrMsg = 0;\n\n  zQuery = sqlite3_mprintf(\"SELECT name, sql FROM sqlite_master\"\n                           \" WHERE %s\", zWhere);\n  rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n  if( rc ){\n    utf8_printf(stderr, \"Error: (%d) %s on [%s]\\n\",\n                    sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n                    zQuery);\n    goto end_schema_xfer;\n  }\n  while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n    zName = sqlite3_column_text(pQuery, 0);\n    zSql = sqlite3_column_text(pQuery, 1);\n    printf(\"%s... \", zName); fflush(stdout);\n    sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);\n    if( zErrMsg ){\n      utf8_printf(stderr, \"Error: %s\\nSQL: [%s]\\n\", zErrMsg, zSql);\n      sqlite3_free(zErrMsg);\n      zErrMsg = 0;\n    }\n    if( xForEach ){\n      xForEach(p, newDb, (const char*)zName);\n    }\n    printf(\"done\\n\");\n  }\n  if( rc!=SQLITE_DONE ){\n    sqlite3_finalize(pQuery);\n    sqlite3_free(zQuery);\n    zQuery = sqlite3_mprintf(\"SELECT name, sql FROM sqlite_master\"\n                             \" WHERE %s ORDER BY rowid DESC\", zWhere);\n    rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);\n    if( rc ){\n      utf8_printf(stderr, \"Error: (%d) %s on [%s]\\n\",\n                      sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),\n                      zQuery);\n      goto end_schema_xfer;\n    }\n    while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){\n      zName = sqlite3_column_text(pQuery, 0);\n      zSql = sqlite3_column_text(pQuery, 1);\n      printf(\"%s... \", zName); fflush(stdout);\n      sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);\n      if( zErrMsg ){\n        utf8_printf(stderr, \"Error: %s\\nSQL: [%s]\\n\", zErrMsg, zSql);\n        sqlite3_free(zErrMsg);\n        zErrMsg = 0;\n      }\n      if( xForEach ){\n        xForEach(p, newDb, (const char*)zName);\n      }\n      printf(\"done\\n\");\n    }\n  }\nend_schema_xfer:\n  sqlite3_finalize(pQuery);\n  sqlite3_free(zQuery);\n}\n\n/*\n** Open a new database file named \"zNewDb\".  Try to recover as much information\n** as possible out of the main database (which might be corrupt) and write it\n** into zNewDb.\n*/\nstatic void tryToClone(ShellState *p, const char *zNewDb){\n  int rc;\n  sqlite3 *newDb = 0;\n  if( access(zNewDb,0)==0 ){\n    utf8_printf(stderr, \"File \\\"%s\\\" already exists.\\n\", zNewDb);\n    return;\n  }\n  rc = sqlite3_open(zNewDb, &newDb);\n  if( rc ){\n    utf8_printf(stderr, \"Cannot create output database: %s\\n\",\n            sqlite3_errmsg(newDb));\n  }else{\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=ON;\", 0, 0, 0);\n    sqlite3_exec(newDb, \"BEGIN EXCLUSIVE;\", 0, 0, 0);\n    tryToCloneSchema(p, newDb, \"type='table'\", tryToCloneData);\n    tryToCloneSchema(p, newDb, \"type!='table'\", 0);\n    sqlite3_exec(newDb, \"COMMIT;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n  }\n  sqlite3_close(newDb);\n}\n\n/*\n** Change the output file back to stdout\n*/\nstatic void output_reset(ShellState *p){\n  if( p->outfile[0]=='|' ){\n#ifndef SQLITE_OMIT_POPEN\n    pclose(p->out);\n#endif\n  }else{\n    output_file_close(p->out);\n  }\n  p->outfile[0] = 0;\n  p->out = stdout;\n}\n\n/*\n** Run an SQL command and return the single integer result.\n*/\nstatic int db_int(ShellState *p, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int res = 0;\n  sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    res = sqlite3_column_int(pStmt,0);\n  }\n  sqlite3_finalize(pStmt);\n  return res;\n}\n\n/*\n** Convert a 2-byte or 4-byte big-endian integer into a native integer\n*/\nstatic unsigned int get2byteInt(unsigned char *a){\n  return (a[0]<<8) + a[1];\n}\nstatic unsigned int get4byteInt(unsigned char *a){\n  return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];\n}\n\n/*\n** Implementation of the \".info\" command.\n**\n** Return 1 on error, 2 to exit, and 0 otherwise.\n*/\nstatic int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){\n  static const struct { const char *zName; int ofst; } aField[] = {\n     { \"file change counter:\",  24  },\n     { \"database page count:\",  28  },\n     { \"freelist page count:\",  36  },\n     { \"schema cookie:\",        40  },\n     { \"schema format:\",        44  },\n     { \"default cache size:\",   48  },\n     { \"autovacuum top root:\",  52  },\n     { \"incremental vacuum:\",   64  },\n     { \"text encoding:\",        56  },\n     { \"user version:\",         60  },\n     { \"application id:\",       68  },\n     { \"software version:\",     96  },\n  };\n  static const struct { const char *zName; const char *zSql; } aQuery[] = {\n     { \"number of tables:\",\n       \"SELECT count(*) FROM %s WHERE type='table'\" },\n     { \"number of indexes:\",\n       \"SELECT count(*) FROM %s WHERE type='index'\" },\n     { \"number of triggers:\",\n       \"SELECT count(*) FROM %s WHERE type='trigger'\" },\n     { \"number of views:\",\n       \"SELECT count(*) FROM %s WHERE type='view'\" },\n     { \"schema size:\",\n       \"SELECT total(length(sql)) FROM %s\" },\n  };\n  int i;\n  char *zSchemaTab;\n  char *zDb = nArg>=2 ? azArg[1] : \"main\";\n  sqlite3_stmt *pStmt = 0;\n  unsigned char aHdr[100];\n  open_db(p, 0);\n  if( p->db==0 ) return 1;\n  sqlite3_prepare_v2(p->db,\"SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1\",\n                     -1, &pStmt, 0);\n  sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC);\n  if( sqlite3_step(pStmt)==SQLITE_ROW\n   && sqlite3_column_bytes(pStmt,0)>100\n  ){\n    memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100);\n    sqlite3_finalize(pStmt);\n  }else{\n    raw_printf(stderr, \"unable to read database header\\n\");\n    sqlite3_finalize(pStmt);\n    return 1;\n  }\n  i = get2byteInt(aHdr+16);\n  if( i==1 ) i = 65536;\n  utf8_printf(p->out, \"%-20s %d\\n\", \"database page size:\", i);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"write format:\", aHdr[18]);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"read format:\", aHdr[19]);\n  utf8_printf(p->out, \"%-20s %d\\n\", \"reserved bytes:\", aHdr[20]);\n  for(i=0; i<ArraySize(aField); i++){\n    int ofst = aField[i].ofst;\n    unsigned int val = get4byteInt(aHdr + ofst);\n    utf8_printf(p->out, \"%-20s %u\", aField[i].zName, val);\n    switch( ofst ){\n      case 56: {\n        if( val==1 ) raw_printf(p->out, \" (utf8)\");\n        if( val==2 ) raw_printf(p->out, \" (utf16le)\");\n        if( val==3 ) raw_printf(p->out, \" (utf16be)\");\n      }\n    }\n    raw_printf(p->out, \"\\n\");\n  }\n  if( zDb==0 ){\n    zSchemaTab = sqlite3_mprintf(\"main.sqlite_master\");\n  }else if( strcmp(zDb,\"temp\")==0 ){\n    zSchemaTab = sqlite3_mprintf(\"%s\", \"sqlite_temp_master\");\n  }else{\n    zSchemaTab = sqlite3_mprintf(\"\\\"%w\\\".sqlite_master\", zDb);\n  }\n  for(i=0; i<ArraySize(aQuery); i++){\n    char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);\n    int val = db_int(p, zSql);\n    sqlite3_free(zSql);\n    utf8_printf(p->out, \"%-20s %d\\n\", aQuery[i].zName, val);\n  }\n  sqlite3_free(zSchemaTab);\n  return 0;\n}\n\n/*\n** Print the current sqlite3_errmsg() value to stderr and return 1.\n*/\nstatic int shellDatabaseError(sqlite3 *db){\n  const char *zErr = sqlite3_errmsg(db);\n  utf8_printf(stderr, \"Error: %s\\n\", zErr);\n  return 1;\n}\n\n/*\n** Print an out-of-memory message to stderr and return 1.\n*/\nstatic int shellNomemError(void){\n  raw_printf(stderr, \"Error: out of memory\\n\");\n  return 1;\n}\n\n/*\n** Compare the pattern in zGlob[] against the text in z[].  Return TRUE\n** if they match and FALSE (0) if they do not match.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n**      '#'       Matches any sequence of one or more digits with an\n**                optional + or - sign in front\n**\n**      ' '       Any span of whitespace matches any other span of\n**                whitespace.\n**\n** Extra whitespace at the end of z[] is ignored.\n*/\nstatic int testcase_glob(const char *zGlob, const char *z){\n  int c, c2;\n  int invert;\n  int seen;\n\n  while( (c = (*(zGlob++)))!=0 ){\n    if( IsSpace(c) ){\n      if( !IsSpace(*z) ) return 0;\n      while( IsSpace(*zGlob) ) zGlob++;\n      while( IsSpace(*z) ) z++;\n    }else if( c=='*' ){\n      while( (c=(*(zGlob++))) == '*' || c=='?' ){\n        if( c=='?' && (*(z++))==0 ) return 0;\n      }\n      if( c==0 ){\n        return 1;\n      }else if( c=='[' ){\n        while( *z && testcase_glob(zGlob-1,z)==0 ){\n          z++;\n        }\n        return (*z)!=0;\n      }\n      while( (c2 = (*(z++)))!=0 ){\n        while( c2!=c ){\n          c2 = *(z++);\n          if( c2==0 ) return 0;\n        }\n        if( testcase_glob(zGlob,z) ) return 1;\n      }\n      return 0;\n    }else if( c=='?' ){\n      if( (*(z++))==0 ) return 0;\n    }else if( c=='[' ){\n      int prior_c = 0;\n      seen = 0;\n      invert = 0;\n      c = *(z++);\n      if( c==0 ) return 0;\n      c2 = *(zGlob++);\n      if( c2=='^' ){\n        invert = 1;\n        c2 = *(zGlob++);\n      }\n      if( c2==']' ){\n        if( c==']' ) seen = 1;\n        c2 = *(zGlob++);\n      }\n      while( c2 && c2!=']' ){\n        if( c2=='-' && zGlob[0]!=']' && zGlob[0]!=0 && prior_c>0 ){\n          c2 = *(zGlob++);\n          if( c>=prior_c && c<=c2 ) seen = 1;\n          prior_c = 0;\n        }else{\n          if( c==c2 ){\n            seen = 1;\n          }\n          prior_c = c2;\n        }\n        c2 = *(zGlob++);\n      }\n      if( c2==0 || (seen ^ invert)==0 ) return 0;\n    }else if( c=='#' ){\n      if( (z[0]=='-' || z[0]=='+') && IsDigit(z[1]) ) z++;\n      if( !IsDigit(z[0]) ) return 0;\n      z++;\n      while( IsDigit(z[0]) ){ z++; }\n    }else{\n      if( c!=(*(z++)) ) return 0;\n    }\n  }\n  while( IsSpace(*z) ){ z++; }\n  return *z==0;\n}\n\n\n/*\n** Compare the string as a command-line option with either one or two\n** initial \"-\" characters.\n*/\nstatic int optionMatch(const char *zStr, const char *zOpt){\n  if( zStr[0]!='-' ) return 0;\n  zStr++;\n  if( zStr[0]=='-' ) zStr++;\n  return strcmp(zStr, zOpt)==0;\n}\n\n/*\n** Delete a file.\n*/\nint shellDeleteFile(const char *zFilename){\n  int rc;\n#ifdef _WIN32\n  wchar_t *z = sqlite3_win32_utf8_to_unicode(zFilename);\n  rc = _wunlink(z);\n  sqlite3_free(z);\n#else\n  rc = unlink(zFilename);\n#endif\n  return rc;\n}\n\n\n/*\n** The implementation of SQL scalar function fkey_collate_clause(), used\n** by the \".lint fkey-indexes\" command. This scalar function is always\n** called with four arguments - the parent table name, the parent column name,\n** the child table name and the child column name.\n**\n**   fkey_collate_clause('parent-tab', 'parent-col', 'child-tab', 'child-col')\n**\n** If either of the named tables or columns do not exist, this function\n** returns an empty string. An empty string is also returned if both tables\n** and columns exist but have the same default collation sequence. Or,\n** if both exist but the default collation sequences are different, this\n** function returns the string \" COLLATE <parent-collation>\", where\n** <parent-collation> is the default collation sequence of the parent column.\n*/\nstatic void shellFkeyCollateClause(\n  sqlite3_context *pCtx,\n  int nVal,\n  sqlite3_value **apVal\n){\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zParent;\n  const char *zParentCol;\n  const char *zParentSeq;\n  const char *zChild;\n  const char *zChildCol;\n  const char *zChildSeq = 0;  /* Initialize to avoid false-positive warning */\n  int rc;\n\n  assert( nVal==4 );\n  zParent = (const char*)sqlite3_value_text(apVal[0]);\n  zParentCol = (const char*)sqlite3_value_text(apVal[1]);\n  zChild = (const char*)sqlite3_value_text(apVal[2]);\n  zChildCol = (const char*)sqlite3_value_text(apVal[3]);\n\n  sqlite3_result_text(pCtx, \"\", -1, SQLITE_STATIC);\n  rc = sqlite3_table_column_metadata(\n      db, \"main\", zParent, zParentCol, 0, &zParentSeq, 0, 0, 0\n  );\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_table_column_metadata(\n        db, \"main\", zChild, zChildCol, 0, &zChildSeq, 0, 0, 0\n    );\n  }\n\n  if( rc==SQLITE_OK && sqlite3_stricmp(zParentSeq, zChildSeq) ){\n    char *z = sqlite3_mprintf(\" COLLATE %s\", zParentSeq);\n    sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT);\n    sqlite3_free(z);\n  }\n}\n\n\n/*\n** The implementation of dot-command \".lint fkey-indexes\".\n*/\nstatic int lintFkeyIndexes(\n  ShellState *pState,             /* Current shell tool state */\n  char **azArg,                   /* Array of arguments passed to dot command */\n  int nArg                        /* Number of entries in azArg[] */\n){\n  sqlite3 *db = pState->db;       /* Database handle to query \"main\" db of */\n  FILE *out = pState->out;        /* Stream to write non-error output to */\n  int bVerbose = 0;               /* If -verbose is present */\n  int bGroupByParent = 0;         /* If -groupbyparent is present */\n  int i;                          /* To iterate through azArg[] */\n  const char *zIndent = \"\";       /* How much to indent CREATE INDEX by */\n  int rc;                         /* Return code */\n  sqlite3_stmt *pSql = 0;         /* Compiled version of SQL statement below */\n\n  /*\n  ** This SELECT statement returns one row for each foreign key constraint\n  ** in the schema of the main database. The column values are:\n  **\n  ** 0. The text of an SQL statement similar to:\n  **\n  **      \"EXPLAIN QUERY PLAN SELECT rowid FROM child_table WHERE child_key=?\"\n  **\n  **    This is the same SELECT that the foreign keys implementation needs\n  **    to run internally on child tables. If there is an index that can\n  **    be used to optimize this query, then it can also be used by the FK\n  **    implementation to optimize DELETE or UPDATE statements on the parent\n  **    table.\n  **\n  ** 1. A GLOB pattern suitable for sqlite3_strglob(). If the plan output by\n  **    the EXPLAIN QUERY PLAN command matches this pattern, then the schema\n  **    contains an index that can be used to optimize the query.\n  **\n  ** 2. Human readable text that describes the child table and columns. e.g.\n  **\n  **       \"child_table(child_key1, child_key2)\"\n  **\n  ** 3. Human readable text that describes the parent table and columns. e.g.\n  **\n  **       \"parent_table(parent_key1, parent_key2)\"\n  **\n  ** 4. A full CREATE INDEX statement for an index that could be used to\n  **    optimize DELETE or UPDATE statements on the parent table. e.g.\n  **\n  **       \"CREATE INDEX child_table_child_key ON child_table(child_key)\"\n  **\n  ** 5. The name of the parent table.\n  **\n  ** These six values are used by the C logic below to generate the report.\n  */\n  const char *zSql =\n  \"SELECT \"\n    \"     'EXPLAIN QUERY PLAN SELECT rowid FROM ' || quote(s.name) || ' WHERE '\"\n    \"  || group_concat(quote(s.name) || '.' || quote(f.[from]) || '=?' \"\n    \"  || fkey_collate_clause(\"\n    \"       f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]),' AND ')\"\n    \", \"\n    \"     'SEARCH TABLE ' || s.name || ' USING COVERING INDEX*('\"\n    \"  || group_concat('*=?', ' AND ') || ')'\"\n    \", \"\n    \"     s.name  || '(' || group_concat(f.[from],  ', ') || ')'\"\n    \", \"\n    \"     f.[table] || '(' || group_concat(COALESCE(f.[to], p.[name])) || ')'\"\n    \", \"\n    \"     'CREATE INDEX ' || quote(s.name ||'_'|| group_concat(f.[from], '_'))\"\n    \"  || ' ON ' || quote(s.name) || '('\"\n    \"  || group_concat(quote(f.[from]) ||\"\n    \"        fkey_collate_clause(\"\n    \"          f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]), ', ')\"\n    \"  || ');'\"\n    \", \"\n    \"     f.[table] \"\n    \"FROM sqlite_master AS s, pragma_foreign_key_list(s.name) AS f \"\n    \"LEFT JOIN pragma_table_info AS p ON (pk-1=seq AND p.arg=f.[table]) \"\n    \"GROUP BY s.name, f.id \"\n    \"ORDER BY (CASE WHEN ? THEN f.[table] ELSE s.name END)\"\n  ;\n  const char *zGlobIPK = \"SEARCH TABLE * USING INTEGER PRIMARY KEY (rowid=?)\";\n\n  for(i=2; i<nArg; i++){\n    int n = (int)strlen(azArg[i]);\n    if( n>1 && sqlite3_strnicmp(\"-verbose\", azArg[i], n)==0 ){\n      bVerbose = 1;\n    }\n    else if( n>1 && sqlite3_strnicmp(\"-groupbyparent\", azArg[i], n)==0 ){\n      bGroupByParent = 1;\n      zIndent = \"    \";\n    }\n    else{\n      raw_printf(stderr, \"Usage: %s %s ?-verbose? ?-groupbyparent?\\n\",\n          azArg[0], azArg[1]\n      );\n      return SQLITE_ERROR;\n    }\n  }\n\n  /* Register the fkey_collate_clause() SQL function */\n  rc = sqlite3_create_function(db, \"fkey_collate_clause\", 4, SQLITE_UTF8,\n      0, shellFkeyCollateClause, 0, 0\n  );\n\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0);\n  }\n  if( rc==SQLITE_OK ){\n    sqlite3_bind_int(pSql, 1, bGroupByParent);\n  }\n\n  if( rc==SQLITE_OK ){\n    int rc2;\n    char *zPrev = 0;\n    while( SQLITE_ROW==sqlite3_step(pSql) ){\n      int res = -1;\n      sqlite3_stmt *pExplain = 0;\n      const char *zEQP = (const char*)sqlite3_column_text(pSql, 0);\n      const char *zGlob = (const char*)sqlite3_column_text(pSql, 1);\n      const char *zFrom = (const char*)sqlite3_column_text(pSql, 2);\n      const char *zTarget = (const char*)sqlite3_column_text(pSql, 3);\n      const char *zCI = (const char*)sqlite3_column_text(pSql, 4);\n      const char *zParent = (const char*)sqlite3_column_text(pSql, 5);\n\n      rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);\n      if( rc!=SQLITE_OK ) break;\n      if( SQLITE_ROW==sqlite3_step(pExplain) ){\n        const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);\n        res = (\n              0==sqlite3_strglob(zGlob, zPlan)\n           || 0==sqlite3_strglob(zGlobIPK, zPlan)\n        );\n      }\n      rc = sqlite3_finalize(pExplain);\n      if( rc!=SQLITE_OK ) break;\n\n      if( res<0 ){\n        raw_printf(stderr, \"Error: internal error\");\n        break;\n      }else{\n        if( bGroupByParent\n        && (bVerbose || res==0)\n        && (zPrev==0 || sqlite3_stricmp(zParent, zPrev))\n        ){\n          raw_printf(out, \"-- Parent table %s\\n\", zParent);\n          sqlite3_free(zPrev);\n          zPrev = sqlite3_mprintf(\"%s\", zParent);\n        }\n\n        if( res==0 ){\n          raw_printf(out, \"%s%s --> %s\\n\", zIndent, zCI, zTarget);\n        }else if( bVerbose ){\n          raw_printf(out, \"%s/* no extra indexes required for %s -> %s */\\n\",\n              zIndent, zFrom, zTarget\n          );\n        }\n      }\n    }\n    sqlite3_free(zPrev);\n\n    if( rc!=SQLITE_OK ){\n      raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n    }\n\n    rc2 = sqlite3_finalize(pSql);\n    if( rc==SQLITE_OK && rc2!=SQLITE_OK ){\n      rc = rc2;\n      raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n    }\n  }else{\n    raw_printf(stderr, \"%s\\n\", sqlite3_errmsg(db));\n  }\n\n  return rc;\n}\n\n/*\n** Implementation of \".lint\" dot command.\n*/\nstatic int lintDotCommand(\n  ShellState *pState,             /* Current shell tool state */\n  char **azArg,                   /* Array of arguments passed to dot command */\n  int nArg                        /* Number of entries in azArg[] */\n){\n  int n;\n  n = (nArg>=2 ? (int)strlen(azArg[1]) : 0);\n  if( n<1 || sqlite3_strnicmp(azArg[1], \"fkey-indexes\", n) ) goto usage;\n  return lintFkeyIndexes(pState, azArg, nArg);\n\n usage:\n  raw_printf(stderr, \"Usage %s sub-command ?switches...?\\n\", azArg[0]);\n  raw_printf(stderr, \"Where sub-commands are:\\n\");\n  raw_printf(stderr, \"    fkey-indexes\\n\");\n  return SQLITE_ERROR;\n}\n\n\n/*\n** If an input line begins with \".\" then invoke this routine to\n** process that line.\n**\n** Return 1 on error, 2 to exit, and 0 otherwise.\n*/\nstatic int do_meta_command(char *zLine, ShellState *p){\n  int h = 1;\n  int nArg = 0;\n  int n, c;\n  int rc = 0;\n  char *azArg[50];\n\n  /* Parse the input line into tokens.\n  */\n  while( zLine[h] && nArg<ArraySize(azArg) ){\n    while( IsSpace(zLine[h]) ){ h++; }\n    if( zLine[h]==0 ) break;\n    if( zLine[h]=='\\'' || zLine[h]=='\"' ){\n      int delim = zLine[h++];\n      azArg[nArg++] = &zLine[h];\n      while( zLine[h] && zLine[h]!=delim ){\n        if( zLine[h]=='\\\\' && delim=='\"' && zLine[h+1]!=0 ) h++;\n        h++;\n      }\n      if( zLine[h]==delim ){\n        zLine[h++] = 0;\n      }\n      if( delim=='\"' ) resolve_backslashes(azArg[nArg-1]);\n    }else{\n      azArg[nArg++] = &zLine[h];\n      while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }\n      if( zLine[h] ) zLine[h++] = 0;\n      resolve_backslashes(azArg[nArg-1]);\n    }\n  }\n\n  /* Process the input line.\n  */\n  if( nArg==0 ) return 0; /* no tokens, no error */\n  n = strlen30(azArg[0]);\n  c = azArg[0][0];\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  if( c=='a' && strncmp(azArg[0], \"auth\", n)==0 ){\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .auth ON|OFF\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    if( booleanValue(azArg[1]) ){\n      sqlite3_set_authorizer(p->db, shellAuth, p);\n    }else{\n      sqlite3_set_authorizer(p->db, 0, 0);\n    }\n  }else\n#endif\n\n  if( (c=='b' && n>=3 && strncmp(azArg[0], \"backup\", n)==0)\n   || (c=='s' && n>=3 && strncmp(azArg[0], \"save\", n)==0)\n  ){\n    const char *zDestFile = 0;\n    const char *zDb = 0;\n    sqlite3 *pDest;\n    sqlite3_backup *pBackup;\n    int j;\n    for(j=1; j<nArg; j++){\n      const char *z = azArg[j];\n      if( z[0]=='-' ){\n        while( z[0]=='-' ) z++;\n        /* No options to process at this time */\n        {\n          utf8_printf(stderr, \"unknown option: %s\\n\", azArg[j]);\n          return 1;\n        }\n      }else if( zDestFile==0 ){\n        zDestFile = azArg[j];\n      }else if( zDb==0 ){\n        zDb = zDestFile;\n        zDestFile = azArg[j];\n      }else{\n        raw_printf(stderr, \"too many arguments to .backup\\n\");\n        return 1;\n      }\n    }\n    if( zDestFile==0 ){\n      raw_printf(stderr, \"missing FILENAME argument on .backup\\n\");\n      return 1;\n    }\n    if( zDb==0 ) zDb = \"main\";\n    rc = sqlite3_open(zDestFile, &pDest);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zDestFile);\n      sqlite3_close(pDest);\n      return 1;\n    }\n    open_db(p, 0);\n    pBackup = sqlite3_backup_init(pDest, \"main\", p->db, zDb);\n    if( pBackup==0 ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      sqlite3_close(pDest);\n      return 1;\n    }\n    while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else{\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(pDest));\n      rc = 1;\n    }\n    sqlite3_close(pDest);\n  }else\n\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"bail\", n)==0 ){\n    if( nArg==2 ){\n      bail_on_error = booleanValue(azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .bail on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"binary\", n)==0 ){\n    if( nArg==2 ){\n      if( booleanValue(azArg[1]) ){\n        setBinaryMode(p->out, 1);\n      }else{\n        setTextMode(p->out, 1);\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .binary on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='c' && strcmp(azArg[0],\"cd\")==0 ){\n    if( nArg==2 ){\n#if defined(_WIN32) || defined(WIN32)\n      wchar_t *z = sqlite3_win32_utf8_to_unicode(azArg[1]);\n      rc = !SetCurrentDirectoryW(z);\n      sqlite3_free(z);\n#else\n      rc = chdir(azArg[1]);\n#endif\n      if( rc ){\n        utf8_printf(stderr, \"Cannot change to directory \\\"%s\\\"\\n\", azArg[1]);\n        rc = 1;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .cd DIRECTORY\\n\");\n      rc = 1;\n    }\n  }else\n\n  /* The undocumented \".breakpoint\" command causes a call to the no-op\n  ** routine named test_breakpoint().\n  */\n  if( c=='b' && n>=3 && strncmp(azArg[0], \"breakpoint\", n)==0 ){\n    test_breakpoint();\n  }else\n\n  if( c=='c' && n>=3 && strncmp(azArg[0], \"changes\", n)==0 ){\n    if( nArg==2 ){\n      setOrClearFlag(p, SHFLG_CountChanges, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .changes on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  /* Cancel output redirection, if it is currently set (by .testcase)\n  ** Then read the content of the testcase-out.txt file and compare against\n  ** azArg[1].  If there are differences, report an error and exit.\n  */\n  if( c=='c' && n>=3 && strncmp(azArg[0], \"check\", n)==0 ){\n    char *zRes = 0;\n    output_reset(p);\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .check GLOB-PATTERN\\n\");\n      rc = 2;\n    }else if( (zRes = readFile(\"testcase-out.txt\", 0))==0 ){\n      raw_printf(stderr, \"Error: cannot read 'testcase-out.txt'\\n\");\n      rc = 2;\n    }else if( testcase_glob(azArg[1],zRes)==0 ){\n      utf8_printf(stderr,\n                 \"testcase-%s FAILED\\n Expected: [%s]\\n      Got: [%s]\\n\",\n                 p->zTestcase, azArg[1], zRes);\n      rc = 1;\n    }else{\n      utf8_printf(stdout, \"testcase-%s ok\\n\", p->zTestcase);\n      p->nCheck++;\n    }\n    sqlite3_free(zRes);\n  }else\n\n  if( c=='c' && strncmp(azArg[0], \"clone\", n)==0 ){\n    if( nArg==2 ){\n      tryToClone(p, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .clone FILENAME\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='d' && n>1 && strncmp(azArg[0], \"databases\", n)==0 ){\n    ShellState data;\n    char *zErrMsg = 0;\n    open_db(p, 0);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_List;\n    sqlite3_snprintf(sizeof(data.colSeparator),data.colSeparator,\": \");\n    data.cnt = 0;\n    sqlite3_exec(p->db, \"SELECT name, file FROM pragma_database_list\",\n                 callback, &data, &zErrMsg);\n    if( zErrMsg ){\n      utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n\n  if( c=='d' && strncmp(azArg[0], \"dbinfo\", n)==0 ){\n    rc = shell_dbinfo_command(p, nArg, azArg);\n  }else\n\n  if( c=='d' && strncmp(azArg[0], \"dump\", n)==0 ){\n    const char *zLike = 0;\n    int i;\n    int savedShowHeader = p->showHeader;\n    ShellClearFlag(p, SHFLG_PreserveRowid|SHFLG_Newlines);\n    for(i=1; i<nArg; i++){\n      if( azArg[i][0]=='-' ){\n        const char *z = azArg[i]+1;\n        if( z[0]=='-' ) z++;\n        if( strcmp(z,\"preserve-rowids\")==0 ){\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n          raw_printf(stderr, \"The --preserve-rowids option is not compatible\"\n                             \" with SQLITE_OMIT_VIRTUALTABLE\\n\");\n          rc = 1;\n          goto meta_command_exit;\n#else\n          ShellSetFlag(p, SHFLG_PreserveRowid);\n#endif\n        }else\n        if( strcmp(z,\"newlines\")==0 ){\n          ShellSetFlag(p, SHFLG_Newlines);\n        }else\n        {\n          raw_printf(stderr, \"Unknown option \\\"%s\\\" on \\\".dump\\\"\\n\", azArg[i]);\n          rc = 1;\n          goto meta_command_exit;\n        }\n      }else if( zLike ){\n        raw_printf(stderr, \"Usage: .dump ?--preserve-rowids? \"\n                           \"?--newlines? ?LIKE-PATTERN?\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }else{\n        zLike = azArg[i];\n      }\n    }\n    open_db(p, 0);\n    /* When playing back a \"dump\", the content might appear in an order\n    ** which causes immediate foreign key constraints to be violated.\n    ** So disable foreign-key constraint enforcement to prevent problems. */\n    raw_printf(p->out, \"PRAGMA foreign_keys=OFF;\\n\");\n    raw_printf(p->out, \"BEGIN TRANSACTION;\\n\");\n    p->writableSchema = 0;\n    p->showHeader = 0;\n    /* Set writable_schema=ON since doing so forces SQLite to initialize\n    ** as much of the schema as it can even if the sqlite_master table is\n    ** corrupt. */\n    sqlite3_exec(p->db, \"SAVEPOINT dump; PRAGMA writable_schema=ON\", 0, 0, 0);\n    p->nErr = 0;\n    if( zLike==0 ){\n      run_schema_dump_query(p,\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'\"\n      );\n      run_schema_dump_query(p,\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE name=='sqlite_sequence'\"\n      );\n      run_table_dump_query(p,\n        \"SELECT sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL AND type IN ('index','trigger','view')\", 0\n      );\n    }else{\n      char *zSql;\n      zSql = sqlite3_mprintf(\n        \"SELECT name, type, sql FROM sqlite_master \"\n        \"WHERE tbl_name LIKE %Q AND type=='table'\"\n        \"  AND sql NOT NULL\", zLike);\n      run_schema_dump_query(p,zSql);\n      sqlite3_free(zSql);\n      zSql = sqlite3_mprintf(\n        \"SELECT sql FROM sqlite_master \"\n        \"WHERE sql NOT NULL\"\n        \"  AND type IN ('index','trigger','view')\"\n        \"  AND tbl_name LIKE %Q\", zLike);\n      run_table_dump_query(p, zSql, 0);\n      sqlite3_free(zSql);\n    }\n    if( p->writableSchema ){\n      raw_printf(p->out, \"PRAGMA writable_schema=OFF;\\n\");\n      p->writableSchema = 0;\n    }\n    sqlite3_exec(p->db, \"PRAGMA writable_schema=OFF;\", 0, 0, 0);\n    sqlite3_exec(p->db, \"RELEASE dump;\", 0, 0, 0);\n    raw_printf(p->out, p->nErr ? \"ROLLBACK; -- due to errors\\n\" : \"COMMIT;\\n\");\n    p->showHeader = savedShowHeader;\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"echo\", n)==0 ){\n    if( nArg==2 ){\n      setOrClearFlag(p, SHFLG_Echo, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .echo on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"eqp\", n)==0 ){\n    if( nArg==2 ){\n      if( strcmp(azArg[1],\"full\")==0 ){\n        p->autoEQP = 2;\n      }else{\n        p->autoEQP = booleanValue(azArg[1]);\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .eqp on|off|full\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='e' && strncmp(azArg[0], \"exit\", n)==0 ){\n    if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);\n    rc = 2;\n  }else\n\n  /* The \".explain\" command is automatic now.  It is largely pointless.  It\n  ** retained purely for backwards compatibility */\n  if( c=='e' && strncmp(azArg[0], \"explain\", n)==0 ){\n    int val = 1;\n    if( nArg>=2 ){\n      if( strcmp(azArg[1],\"auto\")==0 ){\n        val = 99;\n      }else{\n        val =  booleanValue(azArg[1]);\n      }\n    }\n    if( val==1 && p->mode!=MODE_Explain ){\n      p->normalMode = p->mode;\n      p->mode = MODE_Explain;\n      p->autoExplain = 0;\n    }else if( val==0 ){\n      if( p->mode==MODE_Explain ) p->mode = p->normalMode;\n      p->autoExplain = 0;\n    }else if( val==99 ){\n      if( p->mode==MODE_Explain ) p->mode = p->normalMode;\n      p->autoExplain = 1;\n    }\n  }else\n\n  if( c=='f' && strncmp(azArg[0], \"fullschema\", n)==0 ){\n    ShellState data;\n    char *zErrMsg = 0;\n    int doStats = 0;\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_Semi;\n    if( nArg==2 && optionMatch(azArg[1], \"indent\") ){\n      data.cMode = data.mode = MODE_Pretty;\n      nArg = 1;\n    }\n    if( nArg!=1 ){\n      raw_printf(stderr, \"Usage: .fullschema ?--indent?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    rc = sqlite3_exec(p->db,\n       \"SELECT sql FROM\"\n       \"  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x\"\n       \"     FROM sqlite_master UNION ALL\"\n       \"   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) \"\n       \"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' \"\n       \"ORDER BY rowid\",\n       callback, &data, &zErrMsg\n    );\n    if( rc==SQLITE_OK ){\n      sqlite3_stmt *pStmt;\n      rc = sqlite3_prepare_v2(p->db,\n               \"SELECT rowid FROM sqlite_master\"\n               \" WHERE name GLOB 'sqlite_stat[134]'\",\n               -1, &pStmt, 0);\n      doStats = sqlite3_step(pStmt)==SQLITE_ROW;\n      sqlite3_finalize(pStmt);\n    }\n    if( doStats==0 ){\n      raw_printf(p->out, \"/* No STAT tables available */\\n\");\n    }else{\n      raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n      sqlite3_exec(p->db, \"SELECT 'ANALYZE sqlite_master'\",\n                   callback, &data, &zErrMsg);\n      data.cMode = data.mode = MODE_Insert;\n      data.zDestTable = \"sqlite_stat1\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat1\",\n                 shell_callback, &data,&zErrMsg);\n      data.zDestTable = \"sqlite_stat3\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat3\",\n                 shell_callback, &data,&zErrMsg);\n      data.zDestTable = \"sqlite_stat4\";\n      shell_exec(p->db, \"SELECT * FROM sqlite_stat4\",\n                 shell_callback, &data, &zErrMsg);\n      raw_printf(p->out, \"ANALYZE sqlite_master;\\n\");\n    }\n  }else\n\n  if( c=='h' && strncmp(azArg[0], \"headers\", n)==0 ){\n    if( nArg==2 ){\n      p->showHeader = booleanValue(azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .headers on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='h' && strncmp(azArg[0], \"help\", n)==0 ){\n    utf8_printf(p->out, \"%s\", zHelp);\n  }else\n\n  if( c=='i' && strncmp(azArg[0], \"import\", n)==0 ){\n    char *zTable;               /* Insert data into this table */\n    char *zFile;                /* Name of file to extra content from */\n    sqlite3_stmt *pStmt = NULL; /* A statement */\n    int nCol;                   /* Number of columns in the table */\n    int nByte;                  /* Number of bytes in an SQL string */\n    int i, j;                   /* Loop counters */\n    int needCommit;             /* True to COMMIT or ROLLBACK at end */\n    int nSep;                   /* Number of bytes in p->colSeparator[] */\n    char *zSql;                 /* An SQL statement */\n    ImportCtx sCtx;             /* Reader context */\n    char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */\n    int (SQLITE_CDECL *xCloser)(FILE*);      /* Func to close file */\n\n    if( nArg!=3 ){\n      raw_printf(stderr, \"Usage: .import FILE TABLE\\n\");\n      goto meta_command_exit;\n    }\n    zFile = azArg[1];\n    zTable = azArg[2];\n    seenInterrupt = 0;\n    memset(&sCtx, 0, sizeof(sCtx));\n    open_db(p, 0);\n    nSep = strlen30(p->colSeparator);\n    if( nSep==0 ){\n      raw_printf(stderr,\n                 \"Error: non-null column separator required for import\\n\");\n      return 1;\n    }\n    if( nSep>1 ){\n      raw_printf(stderr, \"Error: multi-character column separators not allowed\"\n                      \" for import\\n\");\n      return 1;\n    }\n    nSep = strlen30(p->rowSeparator);\n    if( nSep==0 ){\n      raw_printf(stderr, \"Error: non-null row separator required for import\\n\");\n      return 1;\n    }\n    if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){\n      /* When importing CSV (only), if the row separator is set to the\n      ** default output row separator, change it to the default input\n      ** row separator.  This avoids having to maintain different input\n      ** and output row separators. */\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n      nSep = strlen30(p->rowSeparator);\n    }\n    if( nSep>1 ){\n      raw_printf(stderr, \"Error: multi-character row separators not allowed\"\n                      \" for import\\n\");\n      return 1;\n    }\n    sCtx.zFile = zFile;\n    sCtx.nLine = 1;\n    if( sCtx.zFile[0]=='|' ){\n#ifdef SQLITE_OMIT_POPEN\n      raw_printf(stderr, \"Error: pipes are not supported in this OS\\n\");\n      return 1;\n#else\n      sCtx.in = popen(sCtx.zFile+1, \"r\");\n      sCtx.zFile = \"<pipe>\";\n      xCloser = pclose;\n#endif\n    }else{\n      sCtx.in = fopen(sCtx.zFile, \"rb\");\n      xCloser = fclose;\n    }\n    if( p->mode==MODE_Ascii ){\n      xRead = ascii_read_one_field;\n    }else{\n      xRead = csv_read_one_field;\n    }\n    if( sCtx.in==0 ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zFile);\n      return 1;\n    }\n    sCtx.cColSep = p->colSeparator[0];\n    sCtx.cRowSep = p->rowSeparator[0];\n    zSql = sqlite3_mprintf(\"SELECT * FROM %s\", zTable);\n    if( zSql==0 ){\n      raw_printf(stderr, \"Error: out of memory\\n\");\n      xCloser(sCtx.in);\n      return 1;\n    }\n    nByte = strlen30(zSql);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */\n    if( rc && sqlite3_strglob(\"no such table: *\", sqlite3_errmsg(p->db))==0 ){\n      char *zCreate = sqlite3_mprintf(\"CREATE TABLE %s\", zTable);\n      char cSep = '(';\n      while( xRead(&sCtx) ){\n        zCreate = sqlite3_mprintf(\"%z%c\\n  \\\"%w\\\" TEXT\", zCreate, cSep, sCtx.z);\n        cSep = ',';\n        if( sCtx.cTerm!=sCtx.cColSep ) break;\n      }\n      if( cSep=='(' ){\n        sqlite3_free(zCreate);\n        sqlite3_free(sCtx.z);\n        xCloser(sCtx.in);\n        utf8_printf(stderr,\"%s: empty file\\n\", sCtx.zFile);\n        return 1;\n      }\n      zCreate = sqlite3_mprintf(\"%z\\n)\", zCreate);\n      rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);\n      sqlite3_free(zCreate);\n      if( rc ){\n        utf8_printf(stderr, \"CREATE TABLE %s(...) failed: %s\\n\", zTable,\n                sqlite3_errmsg(p->db));\n        sqlite3_free(sCtx.z);\n        xCloser(sCtx.in);\n        return 1;\n      }\n      rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    }\n    sqlite3_free(zSql);\n    if( rc ){\n      if (pStmt) sqlite3_finalize(pStmt);\n      utf8_printf(stderr,\"Error: %s\\n\", sqlite3_errmsg(p->db));\n      xCloser(sCtx.in);\n      return 1;\n    }\n    nCol = sqlite3_column_count(pStmt);\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( nCol==0 ) return 0; /* no columns, no error */\n    zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );\n    if( zSql==0 ){\n      raw_printf(stderr, \"Error: out of memory\\n\");\n      xCloser(sCtx.in);\n      return 1;\n    }\n    sqlite3_snprintf(nByte+20, zSql, \"INSERT INTO \\\"%w\\\" VALUES(?\", zTable);\n    j = strlen30(zSql);\n    for(i=1; i<nCol; i++){\n      zSql[j++] = ',';\n      zSql[j++] = '?';\n    }\n    zSql[j++] = ')';\n    zSql[j] = 0;\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      if (pStmt) sqlite3_finalize(pStmt);\n      xCloser(sCtx.in);\n      return 1;\n    }\n    needCommit = sqlite3_get_autocommit(p->db);\n    if( needCommit ) sqlite3_exec(p->db, \"BEGIN\", 0, 0, 0);\n    do{\n      int startLine = sCtx.nLine;\n      for(i=0; i<nCol; i++){\n        char *z = xRead(&sCtx);\n        /*\n        ** Did we reach end-of-file before finding any columns?\n        ** If so, stop instead of NULL filling the remaining columns.\n        */\n        if( z==0 && i==0 ) break;\n        /*\n        ** Did we reach end-of-file OR end-of-line before finding any\n        ** columns in ASCII mode?  If so, stop instead of NULL filling\n        ** the remaining columns.\n        */\n        if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break;\n        sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT);\n        if( i<nCol-1 && sCtx.cTerm!=sCtx.cColSep ){\n          utf8_printf(stderr, \"%s:%d: expected %d columns but found %d - \"\n                          \"filling the rest with NULL\\n\",\n                          sCtx.zFile, startLine, nCol, i+1);\n          i += 2;\n          while( i<=nCol ){ sqlite3_bind_null(pStmt, i); i++; }\n        }\n      }\n      if( sCtx.cTerm==sCtx.cColSep ){\n        do{\n          xRead(&sCtx);\n          i++;\n        }while( sCtx.cTerm==sCtx.cColSep );\n        utf8_printf(stderr, \"%s:%d: expected %d columns but found %d - \"\n                        \"extras ignored\\n\",\n                        sCtx.zFile, startLine, nCol, i);\n      }\n      if( i>=nCol ){\n        sqlite3_step(pStmt);\n        rc = sqlite3_reset(pStmt);\n        if( rc!=SQLITE_OK ){\n          utf8_printf(stderr, \"%s:%d: INSERT failed: %s\\n\", sCtx.zFile,\n                      startLine, sqlite3_errmsg(p->db));\n        }\n      }\n    }while( sCtx.cTerm!=EOF );\n\n    xCloser(sCtx.in);\n    sqlite3_free(sCtx.z);\n    sqlite3_finalize(pStmt);\n    if( needCommit ) sqlite3_exec(p->db, \"COMMIT\", 0, 0, 0);\n  }else\n\n#ifndef SQLITE_UNTESTABLE\n  if( c=='i' && strncmp(azArg[0], \"imposter\", n)==0 ){\n    char *zSql;\n    char *zCollist = 0;\n    sqlite3_stmt *pStmt;\n    int tnum = 0;\n    int i;\n    if( nArg!=3 ){\n      utf8_printf(stderr, \"Usage: .imposter INDEX IMPOSTER\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    zSql = sqlite3_mprintf(\"SELECT rootpage FROM sqlite_master\"\n                           \" WHERE name='%q' AND type='index'\", azArg[1]);\n    sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( sqlite3_step(pStmt)==SQLITE_ROW ){\n      tnum = sqlite3_column_int(pStmt, 0);\n    }\n    sqlite3_finalize(pStmt);\n    if( tnum==0 ){\n      utf8_printf(stderr, \"no such index: \\\"%s\\\"\\n\", azArg[1]);\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zSql = sqlite3_mprintf(\"PRAGMA index_xinfo='%q'\", azArg[1]);\n    rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    i = 0;\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      char zLabel[20];\n      const char *zCol = (const char*)sqlite3_column_text(pStmt,2);\n      i++;\n      if( zCol==0 ){\n        if( sqlite3_column_int(pStmt,1)==-1 ){\n          zCol = \"_ROWID_\";\n        }else{\n          sqlite3_snprintf(sizeof(zLabel),zLabel,\"expr%d\",i);\n          zCol = zLabel;\n        }\n      }\n      if( zCollist==0 ){\n        zCollist = sqlite3_mprintf(\"\\\"%w\\\"\", zCol);\n      }else{\n        zCollist = sqlite3_mprintf(\"%z,\\\"%w\\\"\", zCollist, zCol);\n      }\n    }\n    sqlite3_finalize(pStmt);\n    zSql = sqlite3_mprintf(\n          \"CREATE TABLE \\\"%w\\\"(%s,PRIMARY KEY(%s))WITHOUT ROWID\",\n          azArg[2], zCollist, zCollist);\n    sqlite3_free(zCollist);\n    rc = sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, \"main\", 1, tnum);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, \"main\", 0, 0);\n      if( rc ){\n        utf8_printf(stderr, \"Error in [%s]: %s\\n\", zSql, sqlite3_errmsg(p->db));\n      }else{\n        utf8_printf(stdout, \"%s;\\n\", zSql);\n        raw_printf(stdout,\n           \"WARNING: writing to an imposter table will corrupt the index!\\n\"\n        );\n      }\n    }else{\n      raw_printf(stderr, \"SQLITE_TESTCTRL_IMPOSTER returns %d\\n\", rc);\n      rc = 1;\n    }\n    sqlite3_free(zSql);\n  }else\n#endif /* !defined(SQLITE_OMIT_TEST_CONTROL) */\n\n#ifdef SQLITE_ENABLE_IOTRACE\n  if( c=='i' && strncmp(azArg[0], \"iotrace\", n)==0 ){\n    SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);\n    if( iotrace && iotrace!=stdout ) fclose(iotrace);\n    iotrace = 0;\n    if( nArg<2 ){\n      sqlite3IoTrace = 0;\n    }else if( strcmp(azArg[1], \"-\")==0 ){\n      sqlite3IoTrace = iotracePrintf;\n      iotrace = stdout;\n    }else{\n      iotrace = fopen(azArg[1], \"w\");\n      if( iotrace==0 ){\n        utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n        sqlite3IoTrace = 0;\n        rc = 1;\n      }else{\n        sqlite3IoTrace = iotracePrintf;\n      }\n    }\n  }else\n#endif\n\n  if( c=='l' && n>=5 && strncmp(azArg[0], \"limits\", n)==0 ){\n    static const struct {\n       const char *zLimitName;   /* Name of a limit */\n       int limitCode;            /* Integer code for that limit */\n    } aLimit[] = {\n      { \"length\",                SQLITE_LIMIT_LENGTH                    },\n      { \"sql_length\",            SQLITE_LIMIT_SQL_LENGTH                },\n      { \"column\",                SQLITE_LIMIT_COLUMN                    },\n      { \"expr_depth\",            SQLITE_LIMIT_EXPR_DEPTH                },\n      { \"compound_select\",       SQLITE_LIMIT_COMPOUND_SELECT           },\n      { \"vdbe_op\",               SQLITE_LIMIT_VDBE_OP                   },\n      { \"function_arg\",          SQLITE_LIMIT_FUNCTION_ARG              },\n      { \"attached\",              SQLITE_LIMIT_ATTACHED                  },\n      { \"like_pattern_length\",   SQLITE_LIMIT_LIKE_PATTERN_LENGTH       },\n      { \"variable_number\",       SQLITE_LIMIT_VARIABLE_NUMBER           },\n      { \"trigger_depth\",         SQLITE_LIMIT_TRIGGER_DEPTH             },\n      { \"worker_threads\",        SQLITE_LIMIT_WORKER_THREADS            },\n    };\n    int i, n2;\n    open_db(p, 0);\n    if( nArg==1 ){\n      for(i=0; i<ArraySize(aLimit); i++){\n        printf(\"%20s %d\\n\", aLimit[i].zLimitName,\n               sqlite3_limit(p->db, aLimit[i].limitCode, -1));\n      }\n    }else if( nArg>3 ){\n      raw_printf(stderr, \"Usage: .limit NAME ?NEW-VALUE?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }else{\n      int iLimit = -1;\n      n2 = strlen30(azArg[1]);\n      for(i=0; i<ArraySize(aLimit); i++){\n        if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){\n          if( iLimit<0 ){\n            iLimit = i;\n          }else{\n            utf8_printf(stderr, \"ambiguous limit: \\\"%s\\\"\\n\", azArg[1]);\n            rc = 1;\n            goto meta_command_exit;\n          }\n        }\n      }\n      if( iLimit<0 ){\n        utf8_printf(stderr, \"unknown limit: \\\"%s\\\"\\n\"\n                        \"enter \\\".limits\\\" with no arguments for a list.\\n\",\n                         azArg[1]);\n        rc = 1;\n        goto meta_command_exit;\n      }\n      if( nArg==3 ){\n        sqlite3_limit(p->db, aLimit[iLimit].limitCode,\n                      (int)integerValue(azArg[2]));\n      }\n      printf(\"%20s %d\\n\", aLimit[iLimit].zLimitName,\n             sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));\n    }\n  }else\n\n  if( c=='l' && n>2 && strncmp(azArg[0], \"lint\", n)==0 ){\n    open_db(p, 0);\n    lintDotCommand(p, azArg, nArg);\n  }else\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  if( c=='l' && strncmp(azArg[0], \"load\", n)==0 ){\n    const char *zFile, *zProc;\n    char *zErrMsg = 0;\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .load FILE ?ENTRYPOINT?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zFile = azArg[1];\n    zProc = nArg>=3 ? azArg[2] : 0;\n    open_db(p, 0);\n    rc = sqlite3_load_extension(p->db, zFile, zProc, &zErrMsg);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }\n  }else\n#endif\n\n  if( c=='l' && strncmp(azArg[0], \"log\", n)==0 ){\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .log FILENAME\\n\");\n      rc = 1;\n    }else{\n      const char *zFile = azArg[1];\n      output_file_close(p->pLog);\n      p->pLog = output_file_open(zFile);\n    }\n  }else\n\n  if( c=='m' && strncmp(azArg[0], \"mode\", n)==0 ){\n    const char *zMode = nArg>=2 ? azArg[1] : \"\";\n    int n2 = (int)strlen(zMode);\n    int c2 = zMode[0];\n    if( c2=='l' && n2>2 && strncmp(azArg[1],\"lines\",n2)==0 ){\n      p->mode = MODE_Line;\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='c' && strncmp(azArg[1],\"columns\",n2)==0 ){\n      p->mode = MODE_Column;\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='l' && n2>2 && strncmp(azArg[1],\"list\",n2)==0 ){\n      p->mode = MODE_List;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Column);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='h' && strncmp(azArg[1],\"html\",n2)==0 ){\n      p->mode = MODE_Html;\n    }else if( c2=='t' && strncmp(azArg[1],\"tcl\",n2)==0 ){\n      p->mode = MODE_Tcl;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);\n    }else if( c2=='c' && strncmp(azArg[1],\"csv\",n2)==0 ){\n      p->mode = MODE_Csv;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);\n    }else if( c2=='t' && strncmp(azArg[1],\"tabs\",n2)==0 ){\n      p->mode = MODE_List;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);\n    }else if( c2=='i' && strncmp(azArg[1],\"insert\",n2)==0 ){\n      p->mode = MODE_Insert;\n      set_table_name(p, nArg>=3 ? azArg[2] : \"table\");\n    }else if( c2=='q' && strncmp(azArg[1],\"quote\",n2)==0 ){\n      p->mode = MODE_Quote;\n    }else if( c2=='a' && strncmp(azArg[1],\"ascii\",n2)==0 ){\n      p->mode = MODE_Ascii;\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);\n    }else if( nArg==1 ){\n      raw_printf(p->out, \"current output mode: %s\\n\", modeDescr[p->mode]);\n    }else{\n      raw_printf(stderr, \"Error: mode should be one of: \"\n         \"ascii column csv html insert line list quote tabs tcl\\n\");\n      rc = 1;\n    }\n    p->cMode = p->mode;\n  }else\n\n  if( c=='n' && strncmp(azArg[0], \"nullvalue\", n)==0 ){\n    if( nArg==2 ){\n      sqlite3_snprintf(sizeof(p->nullValue), p->nullValue,\n                       \"%.*s\", (int)ArraySize(p->nullValue)-1, azArg[1]);\n    }else{\n      raw_printf(stderr, \"Usage: .nullvalue STRING\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='o' && strncmp(azArg[0], \"open\", n)==0 && n>=2 ){\n    char *zNewFilename;  /* Name of the database file to open */\n    int iName = 1;       /* Index in azArg[] of the filename */\n    int newFlag = 0;     /* True to delete file before opening */\n    /* Close the existing database */\n    session_close_all(p);\n    sqlite3_close(p->db);\n    p->db = 0;\n    p->zDbFilename = 0;\n    sqlite3_free(p->zFreeOnClose);\n    p->zFreeOnClose = 0;\n    /* Check for command-line arguments */\n    for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){\n      const char *z = azArg[iName];\n      if( optionMatch(z,\"new\") ){\n        newFlag = 1;\n      }else if( z[0]=='-' ){\n        utf8_printf(stderr, \"unknown option: %s\\n\", z);\n        rc = 1;\n        goto meta_command_exit;\n      }\n    }\n    /* If a filename is specified, try to open it first */\n    zNewFilename = nArg>iName ? sqlite3_mprintf(\"%s\", azArg[iName]) : 0;\n    if( zNewFilename ){\n      if( newFlag ) shellDeleteFile(zNewFilename);\n      p->zDbFilename = zNewFilename;\n      open_db(p, 1);\n      if( p->db==0 ){\n        utf8_printf(stderr, \"Error: cannot open '%s'\\n\", zNewFilename);\n        sqlite3_free(zNewFilename);\n      }else{\n        p->zFreeOnClose = zNewFilename;\n      }\n    }\n    if( p->db==0 ){\n      /* As a fall-back open a TEMP database */\n      p->zDbFilename = 0;\n      open_db(p, 0);\n    }\n  }else\n\n  if( c=='o'\n   && (strncmp(azArg[0], \"output\", n)==0 || strncmp(azArg[0], \"once\", n)==0)\n  ){\n    const char *zFile = nArg>=2 ? azArg[1] : \"stdout\";\n    if( nArg>2 ){\n      utf8_printf(stderr, \"Usage: .%s FILE\\n\", azArg[0]);\n      rc = 1;\n      goto meta_command_exit;\n    }\n    if( n>1 && strncmp(azArg[0], \"once\", n)==0 ){\n      if( nArg<2 ){\n        raw_printf(stderr, \"Usage: .once FILE\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      p->outCount = 2;\n    }else{\n      p->outCount = 0;\n    }\n    output_reset(p);\n    if( zFile[0]=='|' ){\n#ifdef SQLITE_OMIT_POPEN\n      raw_printf(stderr, \"Error: pipes are not supported in this OS\\n\");\n      rc = 1;\n      p->out = stdout;\n#else\n      p->out = popen(zFile + 1, \"w\");\n      if( p->out==0 ){\n        utf8_printf(stderr,\"Error: cannot open pipe \\\"%s\\\"\\n\", zFile + 1);\n        p->out = stdout;\n        rc = 1;\n      }else{\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", zFile);\n      }\n#endif\n    }else{\n      p->out = output_file_open(zFile);\n      if( p->out==0 ){\n        if( strcmp(zFile,\"off\")!=0 ){\n          utf8_printf(stderr,\"Error: cannot write to \\\"%s\\\"\\n\", zFile);\n        }\n        p->out = stdout;\n        rc = 1;\n      } else {\n        sqlite3_snprintf(sizeof(p->outfile), p->outfile, \"%s\", zFile);\n      }\n    }\n  }else\n\n  if( c=='p' && n>=3 && strncmp(azArg[0], \"print\", n)==0 ){\n    int i;\n    for(i=1; i<nArg; i++){\n      if( i>1 ) raw_printf(p->out, \" \");\n      utf8_printf(p->out, \"%s\", azArg[i]);\n    }\n    raw_printf(p->out, \"\\n\");\n  }else\n\n  if( c=='p' && strncmp(azArg[0], \"prompt\", n)==0 ){\n    if( nArg >= 2) {\n      strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);\n    }\n    if( nArg >= 3) {\n      strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);\n    }\n  }else\n\n  if( c=='q' && strncmp(azArg[0], \"quit\", n)==0 ){\n    rc = 2;\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"read\", n)==0 ){\n    FILE *alt;\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .read FILE\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    alt = fopen(azArg[1], \"rb\");\n    if( alt==0 ){\n      utf8_printf(stderr,\"Error: cannot open \\\"%s\\\"\\n\", azArg[1]);\n      rc = 1;\n    }else{\n      rc = process_input(p, alt);\n      fclose(alt);\n    }\n  }else\n\n  if( c=='r' && n>=3 && strncmp(azArg[0], \"restore\", n)==0 ){\n    const char *zSrcFile;\n    const char *zDb;\n    sqlite3 *pSrc;\n    sqlite3_backup *pBackup;\n    int nTimeout = 0;\n\n    if( nArg==2 ){\n      zSrcFile = azArg[1];\n      zDb = \"main\";\n    }else if( nArg==3 ){\n      zSrcFile = azArg[2];\n      zDb = azArg[1];\n    }else{\n      raw_printf(stderr, \"Usage: .restore ?DB? FILE\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    rc = sqlite3_open(zSrcFile, &pSrc);\n    if( rc!=SQLITE_OK ){\n      utf8_printf(stderr, \"Error: cannot open \\\"%s\\\"\\n\", zSrcFile);\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    open_db(p, 0);\n    pBackup = sqlite3_backup_init(p->db, zDb, pSrc, \"main\");\n    if( pBackup==0 ){\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      sqlite3_close(pSrc);\n      return 1;\n    }\n    while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK\n          || rc==SQLITE_BUSY  ){\n      if( rc==SQLITE_BUSY ){\n        if( nTimeout++ >= 3 ) break;\n        sqlite3_sleep(100);\n      }\n    }\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = 0;\n    }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      raw_printf(stderr, \"Error: source database is busy\\n\");\n      rc = 1;\n    }else{\n      utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n      rc = 1;\n    }\n    sqlite3_close(pSrc);\n  }else\n\n\n  if( c=='s' && strncmp(azArg[0], \"scanstats\", n)==0 ){\n    if( nArg==2 ){\n      p->scanstatsOn = booleanValue(azArg[1]);\n#ifndef SQLITE_ENABLE_STMT_SCANSTATUS\n      raw_printf(stderr, \"Warning: .scanstats not available in this build.\\n\");\n#endif\n    }else{\n      raw_printf(stderr, \"Usage: .scanstats on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"schema\", n)==0 ){\n    ShellText sSelect;\n    ShellState data;\n    char *zErrMsg = 0;\n    const char *zDiv = 0;\n    int iSchema = 0;\n\n    open_db(p, 0);\n    memcpy(&data, p, sizeof(data));\n    data.showHeader = 0;\n    data.cMode = data.mode = MODE_Semi;\n    initText(&sSelect);\n    if( nArg>=2 && optionMatch(azArg[1], \"indent\") ){\n      data.cMode = data.mode = MODE_Pretty;\n      nArg--;\n      if( nArg==2 ) azArg[1] = azArg[2];\n    }\n    if( nArg==2 && azArg[1][0]!='-' ){\n      int i;\n      for(i=0; azArg[1][i]; i++) azArg[1][i] = ToLower(azArg[1][i]);\n      if( strcmp(azArg[1],\"sqlite_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TABLE sqlite_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else if( strcmp(azArg[1],\"sqlite_temp_master\")==0 ){\n        char *new_argv[2], *new_colv[2];\n        new_argv[0] = \"CREATE TEMP TABLE sqlite_temp_master (\\n\"\n                      \"  type text,\\n\"\n                      \"  name text,\\n\"\n                      \"  tbl_name text,\\n\"\n                      \"  rootpage integer,\\n\"\n                      \"  sql text\\n\"\n                      \")\";\n        new_argv[1] = 0;\n        new_colv[0] = \"sql\";\n        new_colv[1] = 0;\n        callback(&data, 1, new_argv, new_colv);\n        rc = SQLITE_OK;\n      }else{\n        zDiv = \"(\";\n      }\n    }else if( nArg==1 ){\n      zDiv = \"(\";\n    }else{\n      raw_printf(stderr, \"Usage: .schema ?--indent? ?LIKE-PATTERN?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    if( zDiv ){\n      sqlite3_stmt *pStmt = 0;\n      rc = sqlite3_prepare_v2(p->db, \"SELECT name FROM pragma_database_list\",\n                              -1, &pStmt, 0);\n      if( rc ){\n        utf8_printf(stderr, \"Error: %s\\n\", sqlite3_errmsg(p->db));\n        sqlite3_finalize(pStmt);\n        rc = 1;\n        goto meta_command_exit;\n      }\n      appendText(&sSelect, \"SELECT sql FROM\", 0);\n      iSchema = 0;\n      while( sqlite3_step(pStmt)==SQLITE_ROW ){\n        const char *zDb = (const char*)sqlite3_column_text(pStmt, 0);\n        char zScNum[30];\n        sqlite3_snprintf(sizeof(zScNum), zScNum, \"%d\", ++iSchema);\n        appendText(&sSelect, zDiv, 0);\n        zDiv = \" UNION ALL \";\n        if( strcmp(zDb, \"main\")!=0 ){\n          appendText(&sSelect, \"SELECT shell_add_schema(sql,\", 0);\n          appendText(&sSelect, zDb, '\"');\n          appendText(&sSelect, \") AS sql, type, tbl_name, name, rowid,\", 0);\n          appendText(&sSelect, zScNum, 0);\n          appendText(&sSelect, \" AS snum, \", 0);\n          appendText(&sSelect, zDb, '\\'');\n          appendText(&sSelect, \" AS sname FROM \", 0);\n          appendText(&sSelect, zDb, '\"');\n          appendText(&sSelect, \".sqlite_master\", 0);\n        }else{\n          appendText(&sSelect, \"SELECT sql, type, tbl_name, name, rowid, \", 0);\n          appendText(&sSelect, zScNum, 0);\n          appendText(&sSelect, \" AS snum, 'main' AS sname FROM sqlite_master\",0);\n        }\n      }\n      sqlite3_finalize(pStmt);\n      appendText(&sSelect, \") WHERE \", 0);\n      if( nArg>1 ){\n        char *zQarg = sqlite3_mprintf(\"%Q\", azArg[1]);\n        if( strchr(azArg[1], '.') ){\n          appendText(&sSelect, \"lower(printf('%s.%s',sname,tbl_name))\", 0);\n        }else{\n          appendText(&sSelect, \"lower(tbl_name)\", 0);\n        }\n        appendText(&sSelect, strchr(azArg[1], '*') ? \" GLOB \" : \" LIKE \", 0);\n        appendText(&sSelect, zQarg, 0);\n        appendText(&sSelect, \" AND \", 0);\n        sqlite3_free(zQarg);\n      }\n      appendText(&sSelect, \"type!='meta' AND sql IS NOT NULL\"\n                           \" ORDER BY snum, rowid\", 0);\n      rc = sqlite3_exec(p->db, sSelect.z, callback, &data, &zErrMsg);\n      freeText(&sSelect);\n    }\n    if( zErrMsg ){\n      utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n      sqlite3_free(zErrMsg);\n      rc = 1;\n    }else if( rc != SQLITE_OK ){\n      raw_printf(stderr,\"Error: querying schema information\\n\");\n      rc = 1;\n    }else{\n      rc = 0;\n    }\n  }else\n\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)\n  if( c=='s' && n==11 && strncmp(azArg[0], \"selecttrace\", n)==0 ){\n    sqlite3SelectTrace = (int)integerValue(azArg[1]);\n  }else\n#endif\n\n#if defined(SQLITE_ENABLE_SESSION)\n  if( c=='s' && strncmp(azArg[0],\"session\",n)==0 && n>=3 ){\n    OpenSession *pSession = &p->aSession[0];\n    char **azCmd = &azArg[1];\n    int iSes = 0;\n    int nCmd = nArg - 1;\n    int i;\n    if( nArg<=1 ) goto session_syntax_error;\n    open_db(p, 0);\n    if( nArg>=3 ){\n      for(iSes=0; iSes<p->nSession; iSes++){\n        if( strcmp(p->aSession[iSes].zName, azArg[1])==0 ) break;\n      }\n      if( iSes<p->nSession ){\n        pSession = &p->aSession[iSes];\n        azCmd++;\n        nCmd--;\n      }else{\n        pSession = &p->aSession[0];\n        iSes = 0;\n      }\n    }\n\n    /* .session attach TABLE\n    ** Invoke the sqlite3session_attach() interface to attach a particular\n    ** table so that it is never filtered.\n    */\n    if( strcmp(azCmd[0],\"attach\")==0 ){\n      if( nCmd!=2 ) goto session_syntax_error;\n      if( pSession->p==0 ){\n        session_not_open:\n        raw_printf(stderr, \"ERROR: No sessions are open\\n\");\n      }else{\n        rc = sqlite3session_attach(pSession->p, azCmd[1]);\n        if( rc ){\n          raw_printf(stderr, \"ERROR: sqlite3session_attach() returns %d\\n\", rc);\n          rc = 0;\n        }\n      }\n    }else\n\n    /* .session changeset FILE\n    ** .session patchset FILE\n    ** Write a changeset or patchset into a file.  The file is overwritten.\n    */\n    if( strcmp(azCmd[0],\"changeset\")==0 || strcmp(azCmd[0],\"patchset\")==0 ){\n      FILE *out = 0;\n      if( nCmd!=2 ) goto session_syntax_error;\n      if( pSession->p==0 ) goto session_not_open;\n      out = fopen(azCmd[1], \"wb\");\n      if( out==0 ){\n        utf8_printf(stderr, \"ERROR: cannot open \\\"%s\\\" for writing\\n\", azCmd[1]);\n      }else{\n        int szChng;\n        void *pChng;\n        if( azCmd[0][0]=='c' ){\n          rc = sqlite3session_changeset(pSession->p, &szChng, &pChng);\n        }else{\n          rc = sqlite3session_patchset(pSession->p, &szChng, &pChng);\n        }\n        if( rc ){\n          printf(\"Error: error code %d\\n\", rc);\n          rc = 0;\n        }\n        if( pChng\n          && fwrite(pChng, szChng, 1, out)!=1 ){\n          raw_printf(stderr, \"ERROR: Failed to write entire %d-byte output\\n\",\n                  szChng);\n        }\n        sqlite3_free(pChng);\n        fclose(out);\n      }\n    }else\n\n    /* .session close\n    ** Close the identified session\n    */\n    if( strcmp(azCmd[0], \"close\")==0 ){\n      if( nCmd!=1 ) goto session_syntax_error;\n      if( p->nSession ){\n        session_close(pSession);\n        p->aSession[iSes] = p->aSession[--p->nSession];\n      }\n    }else\n\n    /* .session enable ?BOOLEAN?\n    ** Query or set the enable flag\n    */\n    if( strcmp(azCmd[0], \"enable\")==0 ){\n      int ii;\n      if( nCmd>2 ) goto session_syntax_error;\n      ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);\n      if( p->nSession ){\n        ii = sqlite3session_enable(pSession->p, ii);\n        utf8_printf(p->out, \"session %s enable flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session filter GLOB ....\n    ** Set a list of GLOB patterns of table names to be excluded.\n    */\n    if( strcmp(azCmd[0], \"filter\")==0 ){\n      int ii, nByte;\n      if( nCmd<2 ) goto session_syntax_error;\n      if( p->nSession ){\n        for(ii=0; ii<pSession->nFilter; ii++){\n          sqlite3_free(pSession->azFilter[ii]);\n        }\n        sqlite3_free(pSession->azFilter);\n        nByte = sizeof(pSession->azFilter[0])*(nCmd-1);\n        pSession->azFilter = sqlite3_malloc( nByte );\n        if( pSession->azFilter==0 ){\n          raw_printf(stderr, \"Error: out or memory\\n\");\n          exit(1);\n        }\n        for(ii=1; ii<nCmd; ii++){\n          pSession->azFilter[ii-1] = sqlite3_mprintf(\"%s\", azCmd[ii]);\n        }\n        pSession->nFilter = ii-1;\n      }\n    }else\n\n    /* .session indirect ?BOOLEAN?\n    ** Query or set the indirect flag\n    */\n    if( strcmp(azCmd[0], \"indirect\")==0 ){\n      int ii;\n      if( nCmd>2 ) goto session_syntax_error;\n      ii = nCmd==1 ? -1 : booleanValue(azCmd[1]);\n      if( p->nSession ){\n        ii = sqlite3session_indirect(pSession->p, ii);\n        utf8_printf(p->out, \"session %s indirect flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session isempty\n    ** Determine if the session is empty\n    */\n    if( strcmp(azCmd[0], \"isempty\")==0 ){\n      int ii;\n      if( nCmd!=1 ) goto session_syntax_error;\n      if( p->nSession ){\n        ii = sqlite3session_isempty(pSession->p);\n        utf8_printf(p->out, \"session %s isempty flag = %d\\n\",\n                    pSession->zName, ii);\n      }\n    }else\n\n    /* .session list\n    ** List all currently open sessions\n    */\n    if( strcmp(azCmd[0],\"list\")==0 ){\n      for(i=0; i<p->nSession; i++){\n        utf8_printf(p->out, \"%d %s\\n\", i, p->aSession[i].zName);\n      }\n    }else\n\n    /* .session open DB NAME\n    ** Open a new session called NAME on the attached database DB.\n    ** DB is normally \"main\".\n    */\n    if( strcmp(azCmd[0],\"open\")==0 ){\n      char *zName;\n      if( nCmd!=3 ) goto session_syntax_error;\n      zName = azCmd[2];\n      if( zName[0]==0 ) goto session_syntax_error;\n      for(i=0; i<p->nSession; i++){\n        if( strcmp(p->aSession[i].zName,zName)==0 ){\n          utf8_printf(stderr, \"Session \\\"%s\\\" already exists\\n\", zName);\n          goto meta_command_exit;\n        }\n      }\n      if( p->nSession>=ArraySize(p->aSession) ){\n        raw_printf(stderr, \"Maximum of %d sessions\\n\", ArraySize(p->aSession));\n        goto meta_command_exit;\n      }\n      pSession = &p->aSession[p->nSession];\n      rc = sqlite3session_create(p->db, azCmd[1], &pSession->p);\n      if( rc ){\n        raw_printf(stderr, \"Cannot open session: error code=%d\\n\", rc);\n        rc = 0;\n        goto meta_command_exit;\n      }\n      pSession->nFilter = 0;\n      sqlite3session_table_filter(pSession->p, session_filter, pSession);\n      p->nSession++;\n      pSession->zName = sqlite3_mprintf(\"%s\", zName);\n    }else\n    /* If no command name matches, show a syntax error */\n    session_syntax_error:\n    session_help(p);\n  }else\n#endif\n\n#ifdef SQLITE_DEBUG\n  /* Undocumented commands for internal testing.  Subject to change\n  ** without notice. */\n  if( c=='s' && n>=10 && strncmp(azArg[0], \"selftest-\", 9)==0 ){\n    if( strncmp(azArg[0]+9, \"boolean\", n-9)==0 ){\n      int i, v;\n      for(i=1; i<nArg; i++){\n        v = booleanValue(azArg[i]);\n        utf8_printf(p->out, \"%s: %d 0x%x\\n\", azArg[i], v, v);\n      }\n    }\n    if( strncmp(azArg[0]+9, \"integer\", n-9)==0 ){\n      int i; sqlite3_int64 v;\n      for(i=1; i<nArg; i++){\n        char zBuf[200];\n        v = integerValue(azArg[i]);\n        sqlite3_snprintf(sizeof(zBuf),zBuf,\"%s: %lld 0x%llx\\n\", azArg[i],v,v);\n        utf8_printf(p->out, \"%s\", zBuf);\n      }\n    }\n  }else\n#endif\n\n  if( c=='s' && n>=4 && strncmp(azArg[0],\"selftest\",n)==0 ){\n    int bIsInit = 0;         /* True to initialize the SELFTEST table */\n    int bVerbose = 0;        /* Verbose output */\n    int bSelftestExists;     /* True if SELFTEST already exists */\n    int i, k;                /* Loop counters */\n    int nTest = 0;           /* Number of tests runs */\n    int nErr = 0;            /* Number of errors seen */\n    ShellText str;           /* Answer for a query */\n    sqlite3_stmt *pStmt = 0; /* Query against the SELFTEST table */\n\n    open_db(p,0);\n    for(i=1; i<nArg; i++){\n      const char *z = azArg[i];\n      if( z[0]=='-' && z[1]=='-' ) z++;\n      if( strcmp(z,\"-init\")==0 ){\n        bIsInit = 1;\n      }else\n      if( strcmp(z,\"-v\")==0 ){\n        bVerbose++;\n      }else\n      {\n        utf8_printf(stderr, \"Unknown option \\\"%s\\\" on \\\"%s\\\"\\n\",\n                    azArg[i], azArg[0]);\n        raw_printf(stderr, \"Should be one of: --init -v\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n    }\n    if( sqlite3_table_column_metadata(p->db,\"main\",\"selftest\",0,0,0,0,0,0)\n           != SQLITE_OK ){\n      bSelftestExists = 0;\n    }else{\n      bSelftestExists = 1;\n    }\n    if( bIsInit ){\n      createSelftestTable(p);\n      bSelftestExists = 1;\n    }\n    initText(&str);\n    appendText(&str, \"x\", 0);\n    for(k=bSelftestExists; k>=0; k--){\n      if( k==1 ){\n        rc = sqlite3_prepare_v2(p->db,\n            \"SELECT tno,op,cmd,ans FROM selftest ORDER BY tno\",\n            -1, &pStmt, 0);\n      }else{\n        rc = sqlite3_prepare_v2(p->db,\n          \"VALUES(0,'memo','Missing SELFTEST table - default checks only',''),\"\n          \"      (1,'run','PRAGMA integrity_check','ok')\",\n          -1, &pStmt, 0);\n      }\n      if( rc ){\n        raw_printf(stderr, \"Error querying the selftest table\\n\");\n        rc = 1;\n        sqlite3_finalize(pStmt);\n        goto meta_command_exit;\n      }\n      for(i=1; sqlite3_step(pStmt)==SQLITE_ROW; i++){\n        int tno = sqlite3_column_int(pStmt, 0);\n        const char *zOp = (const char*)sqlite3_column_text(pStmt, 1);\n        const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);\n        const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);\n\n        k = 0;\n        if( bVerbose>0 ){\n          char *zQuote = sqlite3_mprintf(\"%q\", zSql);\n          printf(\"%d: %s %s\\n\", tno, zOp, zSql);\n          sqlite3_free(zQuote);\n        }\n        if( strcmp(zOp,\"memo\")==0 ){\n          utf8_printf(p->out, \"%s\\n\", zSql);\n        }else\n        if( strcmp(zOp,\"run\")==0 ){\n          char *zErrMsg = 0;\n          str.n = 0;\n          str.z[0] = 0;\n          rc = sqlite3_exec(p->db, zSql, captureOutputCallback, &str, &zErrMsg);\n          nTest++;\n          if( bVerbose ){\n            utf8_printf(p->out, \"Result: %s\\n\", str.z);\n          }\n          if( rc || zErrMsg ){\n            nErr++;\n            rc = 1;\n            utf8_printf(p->out, \"%d: error-code-%d: %s\\n\", tno, rc, zErrMsg);\n            sqlite3_free(zErrMsg);\n          }else if( strcmp(zAns,str.z)!=0 ){\n            nErr++;\n            rc = 1;\n            utf8_printf(p->out, \"%d: Expected: [%s]\\n\", tno, zAns);\n            utf8_printf(p->out, \"%d:      Got: [%s]\\n\", tno, str.z);\n          }\n        }else\n        {\n          utf8_printf(stderr,\n            \"Unknown operation \\\"%s\\\" on selftest line %d\\n\", zOp, tno);\n          rc = 1;\n          break;\n        }\n      } /* End loop over rows of content from SELFTEST */\n      sqlite3_finalize(pStmt);\n    } /* End loop over k */\n    freeText(&str);\n    utf8_printf(p->out, \"%d errors out of %d tests\\n\", nErr, nTest);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"separator\", n)==0 ){\n    if( nArg<2 || nArg>3 ){\n      raw_printf(stderr, \"Usage: .separator COL ?ROW?\\n\");\n      rc = 1;\n    }\n    if( nArg>=2 ){\n      sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator,\n                       \"%.*s\", (int)ArraySize(p->colSeparator)-1, azArg[1]);\n    }\n    if( nArg>=3 ){\n      sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator,\n                       \"%.*s\", (int)ArraySize(p->rowSeparator)-1, azArg[2]);\n    }\n  }else\n\n  if( c=='s' && n>=4 && strncmp(azArg[0],\"sha3sum\",n)==0 ){\n    const char *zLike = 0;   /* Which table to checksum. 0 means everything */\n    int i;                   /* Loop counter */\n    int bSchema = 0;         /* Also hash the schema */\n    int bSeparate = 0;       /* Hash each table separately */\n    int iSize = 224;         /* Hash algorithm to use */\n    int bDebug = 0;          /* Only show the query that would have run */\n    sqlite3_stmt *pStmt;     /* For querying tables names */\n    char *zSql;              /* SQL to be run */\n    char *zSep;              /* Separator */\n    ShellText sSql;          /* Complete SQL for the query to run the hash */\n    ShellText sQuery;        /* Set of queries used to read all content */\n    open_db(p, 0);\n    for(i=1; i<nArg; i++){\n      const char *z = azArg[i];\n      if( z[0]=='-' ){\n        z++;\n        if( z[0]=='-' ) z++;\n        if( strcmp(z,\"schema\")==0 ){\n          bSchema = 1;\n        }else\n        if( strcmp(z,\"sha3-224\")==0 || strcmp(z,\"sha3-256\")==0\n         || strcmp(z,\"sha3-384\")==0 || strcmp(z,\"sha3-512\")==0\n        ){\n          iSize = atoi(&z[5]);\n        }else\n        if( strcmp(z,\"debug\")==0 ){\n          bDebug = 1;\n        }else\n        {\n          utf8_printf(stderr, \"Unknown option \\\"%s\\\" on \\\"%s\\\"\\n\",\n                      azArg[i], azArg[0]);\n          raw_printf(stderr, \"Should be one of: --schema\"\n                             \" --sha3-224 --sha3-255 --sha3-384 --sha3-512\\n\");\n          rc = 1;\n          goto meta_command_exit;\n        }\n      }else if( zLike ){\n        raw_printf(stderr, \"Usage: .sha3sum ?OPTIONS? ?LIKE-PATTERN?\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }else{\n        zLike = z;\n        bSeparate = 1;\n        if( sqlite3_strlike(\"sqlite_%\", zLike, 0)==0 ) bSchema = 1;\n      }\n    }\n    if( bSchema ){\n      zSql = \"SELECT lower(name) FROM sqlite_master\"\n             \" WHERE type='table' AND coalesce(rootpage,0)>1\"\n             \" UNION ALL SELECT 'sqlite_master'\"\n             \" ORDER BY 1 collate nocase\";\n    }else{\n      zSql = \"SELECT lower(name) FROM sqlite_master\"\n             \" WHERE type='table' AND coalesce(rootpage,0)>1\"\n             \" AND name NOT LIKE 'sqlite_%'\"\n             \" ORDER BY 1 collate nocase\";\n    }\n    sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n    initText(&sQuery);\n    initText(&sSql);\n    appendText(&sSql, \"WITH [sha3sum$query](a,b) AS(\",0);\n    zSep = \"VALUES(\";\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zTab = (const char*)sqlite3_column_text(pStmt,0);\n      if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;\n      if( strncmp(zTab, \"sqlite_\",7)!=0 ){\n        appendText(&sQuery,\"SELECT * FROM \", 0);\n        appendText(&sQuery,zTab,'\"');\n        appendText(&sQuery,\" NOT INDEXED;\", 0);\n      }else if( strcmp(zTab, \"sqlite_master\")==0 ){\n        appendText(&sQuery,\"SELECT type,name,tbl_name,sql FROM sqlite_master\"\n                           \" ORDER BY name;\", 0);\n      }else if( strcmp(zTab, \"sqlite_sequence\")==0 ){\n        appendText(&sQuery,\"SELECT name,seq FROM sqlite_sequence\"\n                           \" ORDER BY name;\", 0);\n      }else if( strcmp(zTab, \"sqlite_stat1\")==0 ){\n        appendText(&sQuery,\"SELECT tbl,idx,stat FROM sqlite_stat1\"\n                           \" ORDER BY tbl,idx;\", 0);\n      }else if( strcmp(zTab, \"sqlite_stat3\")==0\n             || strcmp(zTab, \"sqlite_stat4\")==0 ){\n        appendText(&sQuery, \"SELECT * FROM \", 0);\n        appendText(&sQuery, zTab, 0);\n        appendText(&sQuery, \" ORDER BY tbl, idx, rowid;\\n\", 0);\n      }\n      appendText(&sSql, zSep, 0);\n      appendText(&sSql, sQuery.z, '\\'');\n      sQuery.n = 0;\n      appendText(&sSql, \",\", 0);\n      appendText(&sSql, zTab, '\\'');\n      zSep = \"),(\";\n    }\n    sqlite3_finalize(pStmt);\n    if( bSeparate ){\n      zSql = sqlite3_mprintf(\n          \"%s))\"\n          \" SELECT lower(hex(sha3_query(a,%d))) AS hash, b AS label\"\n          \"   FROM [sha3sum$query]\",\n          sSql.z, iSize);\n    }else{\n      zSql = sqlite3_mprintf(\n          \"%s))\"\n          \" SELECT lower(hex(sha3_query(group_concat(a,''),%d))) AS hash\"\n          \"   FROM [sha3sum$query]\",\n          sSql.z, iSize);\n    }\n    freeText(&sQuery);\n    freeText(&sSql);\n    if( bDebug ){\n      utf8_printf(p->out, \"%s\\n\", zSql);\n    }else{\n      shell_exec(p->db, zSql, shell_callback, p, 0);\n    }\n    sqlite3_free(zSql);\n  }else\n\n  if( c=='s'\n   && (strncmp(azArg[0], \"shell\", n)==0 || strncmp(azArg[0],\"system\",n)==0)\n  ){\n    char *zCmd;\n    int i, x;\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .system COMMAND\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?\"%s\":\"\\\"%s\\\"\", azArg[1]);\n    for(i=2; i<nArg; i++){\n      zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?\"%z %s\":\"%z \\\"%s\\\"\",\n                             zCmd, azArg[i]);\n    }\n    x = system(zCmd);\n    sqlite3_free(zCmd);\n    if( x ) raw_printf(stderr, \"System command returns %d\\n\", x);\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"show\", n)==0 ){\n    static const char *azBool[] = { \"off\", \"on\", \"full\", \"unk\" };\n    int i;\n    if( nArg!=1 ){\n      raw_printf(stderr, \"Usage: .show\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"echo\",\n                                  azBool[ShellHasFlag(p, SHFLG_Echo)]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"eqp\", azBool[p->autoEQP&3]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"explain\",\n         p->mode==MODE_Explain ? \"on\" : p->autoExplain ? \"auto\" : \"off\");\n    utf8_printf(p->out,\"%12.12s: %s\\n\",\"headers\", azBool[p->showHeader!=0]);\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"mode\", modeDescr[p->mode]);\n    utf8_printf(p->out, \"%12.12s: \", \"nullvalue\");\n      output_c_string(p->out, p->nullValue);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out,\"%12.12s: %s\\n\",\"output\",\n            strlen30(p->outfile) ? p->outfile : \"stdout\");\n    utf8_printf(p->out,\"%12.12s: \", \"colseparator\");\n      output_c_string(p->out, p->colSeparator);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out,\"%12.12s: \", \"rowseparator\");\n      output_c_string(p->out, p->rowSeparator);\n      raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out, \"%12.12s: %s\\n\",\"stats\", azBool[p->statsOn!=0]);\n    utf8_printf(p->out, \"%12.12s: \", \"width\");\n    for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {\n      raw_printf(p->out, \"%d \", p->colWidth[i]);\n    }\n    raw_printf(p->out, \"\\n\");\n    utf8_printf(p->out, \"%12.12s: %s\\n\", \"filename\",\n                p->zDbFilename ? p->zDbFilename : \"\");\n  }else\n\n  if( c=='s' && strncmp(azArg[0], \"stats\", n)==0 ){\n    if( nArg==2 ){\n      p->statsOn = booleanValue(azArg[1]);\n    }else if( nArg==1 ){\n      display_stats(p->db, p, 0);\n    }else{\n      raw_printf(stderr, \"Usage: .stats ?on|off?\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( (c=='t' && n>1 && strncmp(azArg[0], \"tables\", n)==0)\n   || (c=='i' && (strncmp(azArg[0], \"indices\", n)==0\n                 || strncmp(azArg[0], \"indexes\", n)==0) )\n  ){\n    sqlite3_stmt *pStmt;\n    char **azResult;\n    int nRow, nAlloc;\n    int ii;\n    ShellText s;\n    initText(&s);\n    open_db(p, 0);\n    rc = sqlite3_prepare_v2(p->db, \"PRAGMA database_list\", -1, &pStmt, 0);\n    if( rc ) return shellDatabaseError(p->db);\n\n    if( nArg>2 && c=='i' ){\n      /* It is an historical accident that the .indexes command shows an error\n      ** when called with the wrong number of arguments whereas the .tables\n      ** command does not. */\n      raw_printf(stderr, \"Usage: .indexes ?LIKE-PATTERN?\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    for(ii=0; sqlite3_step(pStmt)==SQLITE_ROW; ii++){\n      const char *zDbName = (const char*)sqlite3_column_text(pStmt, 1);\n      if( zDbName==0 ) continue;\n      if( s.z && s.z[0] ) appendText(&s, \" UNION ALL \", 0);\n      if( sqlite3_stricmp(zDbName, \"main\")==0 ){\n        appendText(&s, \"SELECT name FROM \", 0);\n      }else{\n        appendText(&s, \"SELECT \", 0);\n        appendText(&s, zDbName, '\\'');\n        appendText(&s, \"||'.'||name FROM \", 0);\n      }\n      appendText(&s, zDbName, '\"');\n      appendText(&s, \".sqlite_master \", 0);\n      if( c=='t' ){\n        appendText(&s,\" WHERE type IN ('table','view')\"\n                      \"   AND name NOT LIKE 'sqlite_%'\"\n                      \"   AND name LIKE ?1\", 0);\n      }else{\n        appendText(&s,\" WHERE type='index'\"\n                      \"   AND tbl_name LIKE ?1\", 0);\n      }\n    }\n    rc = sqlite3_finalize(pStmt);\n    appendText(&s, \" ORDER BY 1\", 0);\n    rc = sqlite3_prepare_v2(p->db, s.z, -1, &pStmt, 0);\n    freeText(&s);\n    if( rc ) return shellDatabaseError(p->db);\n\n    /* Run the SQL statement prepared by the above block. Store the results\n    ** as an array of nul-terminated strings in azResult[].  */\n    nRow = nAlloc = 0;\n    azResult = 0;\n    if( nArg>1 ){\n      sqlite3_bind_text(pStmt, 1, azArg[1], -1, SQLITE_TRANSIENT);\n    }else{\n      sqlite3_bind_text(pStmt, 1, \"%\", -1, SQLITE_STATIC);\n    }\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      if( nRow>=nAlloc ){\n        char **azNew;\n        int n2 = nAlloc*2 + 10;\n        azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);\n        if( azNew==0 ){\n          rc = shellNomemError();\n          break;\n        }\n        nAlloc = n2;\n        azResult = azNew;\n      }\n      azResult[nRow] = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 0));\n      if( 0==azResult[nRow] ){\n        rc = shellNomemError();\n        break;\n      }\n      nRow++;\n    }\n    if( sqlite3_finalize(pStmt)!=SQLITE_OK ){\n      rc = shellDatabaseError(p->db);\n    }\n\n    /* Pretty-print the contents of array azResult[] to the output */\n    if( rc==0 && nRow>0 ){\n      int len, maxlen = 0;\n      int i, j;\n      int nPrintCol, nPrintRow;\n      for(i=0; i<nRow; i++){\n        len = strlen30(azResult[i]);\n        if( len>maxlen ) maxlen = len;\n      }\n      nPrintCol = 80/(maxlen+2);\n      if( nPrintCol<1 ) nPrintCol = 1;\n      nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;\n      for(i=0; i<nPrintRow; i++){\n        for(j=i; j<nRow; j+=nPrintRow){\n          char *zSp = j<nPrintRow ? \"\" : \"  \";\n          utf8_printf(p->out, \"%s%-*s\", zSp, maxlen,\n                      azResult[j] ? azResult[j]:\"\");\n        }\n        raw_printf(p->out, \"\\n\");\n      }\n    }\n\n    for(ii=0; ii<nRow; ii++) sqlite3_free(azResult[ii]);\n    sqlite3_free(azResult);\n  }else\n\n  /* Begin redirecting output to the file \"testcase-out.txt\" */\n  if( c=='t' && strcmp(azArg[0],\"testcase\")==0 ){\n    output_reset(p);\n    p->out = output_file_open(\"testcase-out.txt\");\n    if( p->out==0 ){\n      raw_printf(stderr, \"Error: cannot open 'testcase-out.txt'\\n\");\n    }\n    if( nArg>=2 ){\n      sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, \"%s\", azArg[1]);\n    }else{\n      sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, \"?\");\n    }\n  }else\n\n#ifndef SQLITE_UNTESTABLE\n  if( c=='t' && n>=8 && strncmp(azArg[0], \"testctrl\", n)==0 && nArg>=2 ){\n    static const struct {\n       const char *zCtrlName;   /* Name of a test-control option */\n       int ctrlCode;            /* Integer code for that option */\n    } aCtrl[] = {\n      { \"prng_save\",             SQLITE_TESTCTRL_PRNG_SAVE              },\n      { \"prng_restore\",          SQLITE_TESTCTRL_PRNG_RESTORE           },\n      { \"prng_reset\",            SQLITE_TESTCTRL_PRNG_RESET             },\n      { \"bitvec_test\",           SQLITE_TESTCTRL_BITVEC_TEST            },\n      { \"fault_install\",         SQLITE_TESTCTRL_FAULT_INSTALL          },\n      { \"benign_malloc_hooks\",   SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS    },\n      { \"pending_byte\",          SQLITE_TESTCTRL_PENDING_BYTE           },\n      { \"assert\",                SQLITE_TESTCTRL_ASSERT                 },\n      { \"always\",                SQLITE_TESTCTRL_ALWAYS                 },\n      { \"reserve\",               SQLITE_TESTCTRL_RESERVE                },\n      { \"optimizations\",         SQLITE_TESTCTRL_OPTIMIZATIONS          },\n      { \"iskeyword\",             SQLITE_TESTCTRL_ISKEYWORD              },\n      { \"byteorder\",             SQLITE_TESTCTRL_BYTEORDER              },\n      { \"never_corrupt\",         SQLITE_TESTCTRL_NEVER_CORRUPT          },\n      { \"imposter\",              SQLITE_TESTCTRL_IMPOSTER               },\n    };\n    int testctrl = -1;\n    int rc2 = 0;\n    int i, n2;\n    open_db(p, 0);\n\n    /* convert testctrl text option to value. allow any unique prefix\n    ** of the option name, or a numerical value. */\n    n2 = strlen30(azArg[1]);\n    for(i=0; i<ArraySize(aCtrl); i++){\n      if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){\n        if( testctrl<0 ){\n          testctrl = aCtrl[i].ctrlCode;\n        }else{\n          utf8_printf(stderr, \"ambiguous option name: \\\"%s\\\"\\n\", azArg[1]);\n          testctrl = -1;\n          break;\n        }\n      }\n    }\n    if( testctrl<0 ) testctrl = (int)integerValue(azArg[1]);\n    if( (testctrl<SQLITE_TESTCTRL_FIRST) || (testctrl>SQLITE_TESTCTRL_LAST) ){\n      utf8_printf(stderr,\"Error: invalid testctrl option: %s\\n\", azArg[1]);\n    }else{\n      switch(testctrl){\n\n        /* sqlite3_test_control(int, db, int) */\n        case SQLITE_TESTCTRL_OPTIMIZATIONS:\n        case SQLITE_TESTCTRL_RESERVE:\n          if( nArg==3 ){\n            int opt = (int)strtol(azArg[2], 0, 0);\n            rc2 = sqlite3_test_control(testctrl, p->db, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                    azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int) */\n        case SQLITE_TESTCTRL_PRNG_SAVE:\n        case SQLITE_TESTCTRL_PRNG_RESTORE:\n        case SQLITE_TESTCTRL_PRNG_RESET:\n        case SQLITE_TESTCTRL_BYTEORDER:\n          if( nArg==2 ){\n            rc2 = sqlite3_test_control(testctrl);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes no options\\n\",\n                        azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, uint) */\n        case SQLITE_TESTCTRL_PENDING_BYTE:\n          if( nArg==3 ){\n            unsigned int opt = (unsigned int)integerValue(azArg[2]);\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single unsigned\"\n                           \" int option\\n\", azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, int) */\n        case SQLITE_TESTCTRL_ASSERT:\n        case SQLITE_TESTCTRL_ALWAYS:\n        case SQLITE_TESTCTRL_NEVER_CORRUPT:\n          if( nArg==3 ){\n            int opt = booleanValue(azArg[2]);\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\"Error: testctrl %s takes a single int option\\n\",\n                            azArg[1]);\n          }\n          break;\n\n        /* sqlite3_test_control(int, char *) */\n#ifdef SQLITE_N_KEYWORD\n        case SQLITE_TESTCTRL_ISKEYWORD:\n          if( nArg==3 ){\n            const char *opt = azArg[2];\n            rc2 = sqlite3_test_control(testctrl, opt);\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          } else {\n            utf8_printf(stderr,\n                        \"Error: testctrl %s takes a single char * option\\n\",\n                        azArg[1]);\n          }\n          break;\n#endif\n\n        case SQLITE_TESTCTRL_IMPOSTER:\n          if( nArg==5 ){\n            rc2 = sqlite3_test_control(testctrl, p->db,\n                          azArg[2],\n                          integerValue(azArg[3]),\n                          integerValue(azArg[4]));\n            raw_printf(p->out, \"%d (0x%08x)\\n\", rc2, rc2);\n          }else{\n            raw_printf(stderr,\"Usage: .testctrl imposter dbName onoff tnum\\n\");\n          }\n          break;\n\n        case SQLITE_TESTCTRL_BITVEC_TEST:\n        case SQLITE_TESTCTRL_FAULT_INSTALL:\n        case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:\n        default:\n          utf8_printf(stderr,\n                      \"Error: CLI support for testctrl %s not implemented\\n\",\n                      azArg[1]);\n          break;\n      }\n    }\n  }else\n#endif /* !defined(SQLITE_UNTESTABLE) */\n\n  if( c=='t' && n>4 && strncmp(azArg[0], \"timeout\", n)==0 ){\n    open_db(p, 0);\n    sqlite3_busy_timeout(p->db, nArg>=2 ? (int)integerValue(azArg[1]) : 0);\n  }else\n\n  if( c=='t' && n>=5 && strncmp(azArg[0], \"timer\", n)==0 ){\n    if( nArg==2 ){\n      enableTimer = booleanValue(azArg[1]);\n      if( enableTimer && !HAS_TIMER ){\n        raw_printf(stderr, \"Error: timer not available on this system.\\n\");\n        enableTimer = 0;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .timer on|off\\n\");\n      rc = 1;\n    }\n  }else\n\n  if( c=='t' && strncmp(azArg[0], \"trace\", n)==0 ){\n    open_db(p, 0);\n    if( nArg!=2 ){\n      raw_printf(stderr, \"Usage: .trace FILE|off\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    output_file_close(p->traceOut);\n    p->traceOut = output_file_open(azArg[1]);\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    if( p->traceOut==0 ){\n      sqlite3_trace_v2(p->db, 0, 0, 0);\n    }else{\n      sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);\n    }\n#endif\n  }else\n\n#if SQLITE_USER_AUTHENTICATION\n  if( c=='u' && strncmp(azArg[0], \"user\", n)==0 ){\n    if( nArg<2 ){\n      raw_printf(stderr, \"Usage: .user SUBCOMMAND ...\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n    open_db(p, 0);\n    if( strcmp(azArg[1],\"login\")==0 ){\n      if( nArg!=4 ){\n        raw_printf(stderr, \"Usage: .user login USER PASSWORD\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],\n                                    (int)strlen(azArg[3]));\n      if( rc ){\n        utf8_printf(stderr, \"Authentication failed for user %s\\n\", azArg[2]);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"add\")==0 ){\n      if( nArg!=5 ){\n        raw_printf(stderr, \"Usage: .user add USER PASSWORD ISADMIN\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_add(p->db, azArg[2],\n                            azArg[3], (int)strlen(azArg[3]),\n                            booleanValue(azArg[4]));\n      if( rc ){\n        raw_printf(stderr, \"User-Add failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"edit\")==0 ){\n      if( nArg!=5 ){\n        raw_printf(stderr, \"Usage: .user edit USER PASSWORD ISADMIN\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_change(p->db, azArg[2],\n                              azArg[3], (int)strlen(azArg[3]),\n                              booleanValue(azArg[4]));\n      if( rc ){\n        raw_printf(stderr, \"User-Edit failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else if( strcmp(azArg[1],\"delete\")==0 ){\n      if( nArg!=3 ){\n        raw_printf(stderr, \"Usage: .user delete USER\\n\");\n        rc = 1;\n        goto meta_command_exit;\n      }\n      rc = sqlite3_user_delete(p->db, azArg[2]);\n      if( rc ){\n        raw_printf(stderr, \"User-Delete failed: %d\\n\", rc);\n        rc = 1;\n      }\n    }else{\n      raw_printf(stderr, \"Usage: .user login|add|edit|delete ...\\n\");\n      rc = 1;\n      goto meta_command_exit;\n    }\n  }else\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n  if( c=='v' && strncmp(azArg[0], \"version\", n)==0 ){\n    utf8_printf(p->out, \"SQLite %s %s\\n\" /*extra-version-info*/,\n        sqlite3_libversion(), sqlite3_sourceid());\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfsinfo\", n)==0 ){\n    const char *zDbName = nArg==2 ? azArg[1] : \"main\";\n    sqlite3_vfs *pVfs = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFS_POINTER, &pVfs);\n      if( pVfs ){\n        utf8_printf(p->out, \"vfs.zName      = \\\"%s\\\"\\n\", pVfs->zName);\n        raw_printf(p->out, \"vfs.iVersion   = %d\\n\", pVfs->iVersion);\n        raw_printf(p->out, \"vfs.szOsFile   = %d\\n\", pVfs->szOsFile);\n        raw_printf(p->out, \"vfs.mxPathname = %d\\n\", pVfs->mxPathname);\n      }\n    }\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfslist\", n)==0 ){\n    sqlite3_vfs *pVfs;\n    sqlite3_vfs *pCurrent = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, \"main\", SQLITE_FCNTL_VFS_POINTER, &pCurrent);\n    }\n    for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){\n      utf8_printf(p->out, \"vfs.zName      = \\\"%s\\\"%s\\n\", pVfs->zName,\n           pVfs==pCurrent ? \"  <--- CURRENT\" : \"\");\n      raw_printf(p->out, \"vfs.iVersion   = %d\\n\", pVfs->iVersion);\n      raw_printf(p->out, \"vfs.szOsFile   = %d\\n\", pVfs->szOsFile);\n      raw_printf(p->out, \"vfs.mxPathname = %d\\n\", pVfs->mxPathname);\n      if( pVfs->pNext ){\n        raw_printf(p->out, \"-----------------------------------\\n\");\n      }\n    }\n  }else\n\n  if( c=='v' && strncmp(azArg[0], \"vfsname\", n)==0 ){\n    const char *zDbName = nArg==2 ? azArg[1] : \"main\";\n    char *zVfsName = 0;\n    if( p->db ){\n      sqlite3_file_control(p->db, zDbName, SQLITE_FCNTL_VFSNAME, &zVfsName);\n      if( zVfsName ){\n        utf8_printf(p->out, \"%s\\n\", zVfsName);\n        sqlite3_free(zVfsName);\n      }\n    }\n  }else\n\n#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)\n  if( c=='w' && strncmp(azArg[0], \"wheretrace\", n)==0 ){\n    sqlite3WhereTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;\n  }else\n#endif\n\n  if( c=='w' && strncmp(azArg[0], \"width\", n)==0 ){\n    int j;\n    assert( nArg<=ArraySize(azArg) );\n    for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){\n      p->colWidth[j-1] = (int)integerValue(azArg[j]);\n    }\n  }else\n\n  {\n    utf8_printf(stderr, \"Error: unknown command or invalid arguments: \"\n      \" \\\"%s\\\". Enter \\\".help\\\" for help\\n\", azArg[0]);\n    rc = 1;\n  }\n\nmeta_command_exit:\n  if( p->outCount ){\n    p->outCount--;\n    if( p->outCount==0 ) output_reset(p);\n  }\n  return rc;\n}\n\n/*\n** Return TRUE if a semicolon occurs anywhere in the first N characters\n** of string z[].\n*/\nstatic int line_contains_semicolon(const char *z, int N){\n  int i;\n  for(i=0; i<N; i++){  if( z[i]==';' ) return 1; }\n  return 0;\n}\n\n/*\n** Test to see if a line consists entirely of whitespace.\n*/\nstatic int _all_whitespace(const char *z){\n  for(; *z; z++){\n    if( IsSpace(z[0]) ) continue;\n    if( *z=='/' && z[1]=='*' ){\n      z += 2;\n      while( *z && (*z!='*' || z[1]!='/') ){ z++; }\n      if( *z==0 ) return 0;\n      z++;\n      continue;\n    }\n    if( *z=='-' && z[1]=='-' ){\n      z += 2;\n      while( *z && *z!='\\n' ){ z++; }\n      if( *z==0 ) return 1;\n      continue;\n    }\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Return TRUE if the line typed in is an SQL command terminator other\n** than a semi-colon.  The SQL Server style \"go\" command is understood\n** as is the Oracle \"/\".\n*/\nstatic int line_is_command_terminator(const char *zLine){\n  while( IsSpace(zLine[0]) ){ zLine++; };\n  if( zLine[0]=='/' && _all_whitespace(&zLine[1]) ){\n    return 1;  /* Oracle */\n  }\n  if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'\n         && _all_whitespace(&zLine[2]) ){\n    return 1;  /* SQL Server */\n  }\n  return 0;\n}\n\n/*\n** Return true if zSql is a complete SQL statement.  Return false if it\n** ends in the middle of a string literal or C-style comment.\n*/\nstatic int line_is_complete(char *zSql, int nSql){\n  int rc;\n  if( zSql==0 ) return 1;\n  zSql[nSql] = ';';\n  zSql[nSql+1] = 0;\n  rc = sqlite3_complete(zSql);\n  zSql[nSql] = 0;\n  return rc;\n}\n\n/*\n** Run a single line of SQL\n*/\nstatic int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){\n  int rc;\n  char *zErrMsg = 0;\n\n  open_db(p, 0);\n  if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);\n  BEGIN_TIMER;\n  rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);\n  END_TIMER;\n  if( rc || zErrMsg ){\n    char zPrefix[100];\n    if( in!=0 || !stdin_is_interactive ){\n      sqlite3_snprintf(sizeof(zPrefix), zPrefix,\n                       \"Error: near line %d:\", startline);\n    }else{\n      sqlite3_snprintf(sizeof(zPrefix), zPrefix, \"Error:\");\n    }\n    if( zErrMsg!=0 ){\n      utf8_printf(stderr, \"%s %s\\n\", zPrefix, zErrMsg);\n      sqlite3_free(zErrMsg);\n      zErrMsg = 0;\n    }else{\n      utf8_printf(stderr, \"%s %s\\n\", zPrefix, sqlite3_errmsg(p->db));\n    }\n    return 1;\n  }else if( ShellHasFlag(p, SHFLG_CountChanges) ){\n    raw_printf(p->out, \"changes: %3d   total_changes: %d\\n\",\n            sqlite3_changes(p->db), sqlite3_total_changes(p->db));\n  }\n  return 0;\n}\n\n\n/*\n** Read input from *in and process it.  If *in==0 then input\n** is interactive - the user is typing it it.  Otherwise, input\n** is coming from a file or device.  A prompt is issued and history\n** is saved only if input is interactive.  An interrupt signal will\n** cause this routine to exit immediately, unless input is interactive.\n**\n** Return the number of errors.\n*/\nstatic int process_input(ShellState *p, FILE *in){\n  char *zLine = 0;          /* A single input line */\n  char *zSql = 0;           /* Accumulated SQL text */\n  int nLine;                /* Length of current line */\n  int nSql = 0;             /* Bytes of zSql[] used */\n  int nAlloc = 0;           /* Allocated zSql[] space */\n  int nSqlPrior = 0;        /* Bytes of zSql[] used by prior line */\n  int rc;                   /* Error code */\n  int errCnt = 0;           /* Number of errors seen */\n  int lineno = 0;           /* Current line number */\n  int startline = 0;        /* Line number for start of current input */\n\n  while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){\n    fflush(p->out);\n    zLine = one_input_line(in, zLine, nSql>0);\n    if( zLine==0 ){\n      /* End of input */\n      if( in==0 && stdin_is_interactive ) printf(\"\\n\");\n      break;\n    }\n    if( seenInterrupt ){\n      if( in!=0 ) break;\n      seenInterrupt = 0;\n    }\n    lineno++;\n    if( nSql==0 && _all_whitespace(zLine) ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zLine);\n      continue;\n    }\n    if( zLine && zLine[0]=='.' && nSql==0 ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zLine);\n      rc = do_meta_command(zLine, p);\n      if( rc==2 ){ /* exit requested */\n        break;\n      }else if( rc ){\n        errCnt++;\n      }\n      continue;\n    }\n    if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){\n      memcpy(zLine,\";\",2);\n    }\n    nLine = strlen30(zLine);\n    if( nSql+nLine+2>=nAlloc ){\n      nAlloc = nSql+nLine+100;\n      zSql = realloc(zSql, nAlloc);\n      if( zSql==0 ){\n        raw_printf(stderr, \"Error: out of memory\\n\");\n        exit(1);\n      }\n    }\n    nSqlPrior = nSql;\n    if( nSql==0 ){\n      int i;\n      for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}\n      assert( nAlloc>0 && zSql!=0 );\n      memcpy(zSql, zLine+i, nLine+1-i);\n      startline = lineno;\n      nSql = nLine-i;\n    }else{\n      zSql[nSql++] = '\\n';\n      memcpy(zSql+nSql, zLine, nLine+1);\n      nSql += nLine;\n    }\n    if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)\n                && sqlite3_complete(zSql) ){\n      errCnt += runOneSqlLine(p, zSql, in, startline);\n      nSql = 0;\n      if( p->outCount ){\n        output_reset(p);\n        p->outCount = 0;\n      }\n    }else if( nSql && _all_whitespace(zSql) ){\n      if( ShellHasFlag(p, SHFLG_Echo) ) printf(\"%s\\n\", zSql);\n      nSql = 0;\n    }\n  }\n  if( nSql && !_all_whitespace(zSql) ){\n    runOneSqlLine(p, zSql, in, startline);\n  }\n  free(zSql);\n  free(zLine);\n  return errCnt>0;\n}\n\n/*\n** Return a pathname which is the user's home directory.  A\n** 0 return indicates an error of some kind.\n*/\nstatic char *find_home_dir(int clearFlag){\n  static char *home_dir = NULL;\n  if( clearFlag ){\n    free(home_dir);\n    home_dir = 0;\n    return 0;\n  }\n  if( home_dir ) return home_dir;\n\n#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \\\n     && !defined(__RTP__) && !defined(_WRS_KERNEL)\n  {\n    struct passwd *pwent;\n    uid_t uid = getuid();\n    if( (pwent=getpwuid(uid)) != NULL) {\n      home_dir = pwent->pw_dir;\n    }\n  }\n#endif\n\n#if defined(_WIN32_WCE)\n  /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()\n   */\n  home_dir = \"/\";\n#else\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    home_dir = getenv(\"USERPROFILE\");\n  }\n#endif\n\n  if (!home_dir) {\n    home_dir = getenv(\"HOME\");\n  }\n\n#if defined(_WIN32) || defined(WIN32)\n  if (!home_dir) {\n    char *zDrive, *zPath;\n    int n;\n    zDrive = getenv(\"HOMEDRIVE\");\n    zPath = getenv(\"HOMEPATH\");\n    if( zDrive && zPath ){\n      n = strlen30(zDrive) + strlen30(zPath) + 1;\n      home_dir = malloc( n );\n      if( home_dir==0 ) return 0;\n      sqlite3_snprintf(n, home_dir, \"%s%s\", zDrive, zPath);\n      return home_dir;\n    }\n    home_dir = \"c:\\\\\";\n  }\n#endif\n\n#endif /* !_WIN32_WCE */\n\n  if( home_dir ){\n    int n = strlen30(home_dir) + 1;\n    char *z = malloc( n );\n    if( z ) memcpy(z, home_dir, n);\n    home_dir = z;\n  }\n\n  return home_dir;\n}\n\n/*\n** Read input from the file given by sqliterc_override.  Or if that\n** parameter is NULL, take input from ~/.sqliterc\n**\n** Returns the number of errors.\n*/\nstatic void process_sqliterc(\n  ShellState *p,                  /* Configuration data */\n  const char *sqliterc_override   /* Name of config file. NULL to use default */\n){\n  char *home_dir = NULL;\n  const char *sqliterc = sqliterc_override;\n  char *zBuf = 0;\n  FILE *in = NULL;\n\n  if (sqliterc == NULL) {\n    home_dir = find_home_dir(0);\n    if( home_dir==0 ){\n      raw_printf(stderr, \"-- warning: cannot find home directory;\"\n                      \" cannot read ~/.sqliterc\\n\");\n      return;\n    }\n    sqlite3_initialize();\n    zBuf = sqlite3_mprintf(\"%s/.sqliterc\",home_dir);\n    sqliterc = zBuf;\n  }\n  in = fopen(sqliterc,\"rb\");\n  if( in ){\n    if( stdin_is_interactive ){\n      utf8_printf(stderr,\"-- Loading resources from %s\\n\",sqliterc);\n    }\n    process_input(p,in);\n    fclose(in);\n  }\n  sqlite3_free(zBuf);\n}\n\n/*\n** Show available command line options\n*/\nstatic const char zOptions[] =\n  \"   -ascii               set output mode to 'ascii'\\n\"\n  \"   -bail                stop after hitting an error\\n\"\n  \"   -batch               force batch I/O\\n\"\n  \"   -column              set output mode to 'column'\\n\"\n  \"   -cmd COMMAND         run \\\"COMMAND\\\" before reading stdin\\n\"\n  \"   -csv                 set output mode to 'csv'\\n\"\n  \"   -echo                print commands before execution\\n\"\n  \"   -init FILENAME       read/process named file\\n\"\n  \"   -[no]header          turn headers on or off\\n\"\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n  \"   -heap SIZE           Size of heap for memsys3 or memsys5\\n\"\n#endif\n  \"   -help                show this message\\n\"\n  \"   -html                set output mode to HTML\\n\"\n  \"   -interactive         force interactive I/O\\n\"\n  \"   -line                set output mode to 'line'\\n\"\n  \"   -list                set output mode to 'list'\\n\"\n  \"   -lookaside SIZE N    use N entries of SZ bytes for lookaside memory\\n\"\n  \"   -mmap N              default mmap size set to N\\n\"\n#ifdef SQLITE_ENABLE_MULTIPLEX\n  \"   -multiplex           enable the multiplexor VFS\\n\"\n#endif\n  \"   -newline SEP         set output row separator. Default: '\\\\n'\\n\"\n  \"   -nullvalue TEXT      set text string for NULL values. Default ''\\n\"\n  \"   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory\\n\"\n  \"   -quote               set output mode to 'quote'\\n\"\n  \"   -separator SEP       set output column separator. Default: '|'\\n\"\n  \"   -stats               print memory stats before each finalize\\n\"\n  \"   -version             show SQLite version\\n\"\n  \"   -vfs NAME            use NAME as the default VFS\\n\"\n#ifdef SQLITE_ENABLE_VFSTRACE\n  \"   -vfstrace            enable tracing of all VFS calls\\n\"\n#endif\n;\nstatic void usage(int showDetail){\n  utf8_printf(stderr,\n      \"Usage: %s [OPTIONS] FILENAME [SQL]\\n\"\n      \"FILENAME is the name of an SQLite database. A new database is created\\n\"\n      \"if the file does not previously exist.\\n\", Argv0);\n  if( showDetail ){\n    utf8_printf(stderr, \"OPTIONS include:\\n%s\", zOptions);\n  }else{\n    raw_printf(stderr, \"Use the -help option for additional information\\n\");\n  }\n  exit(1);\n}\n\n/*\n** Initialize the state information in data\n*/\nstatic void main_init(ShellState *data) {\n  memset(data, 0, sizeof(*data));\n  data->normalMode = data->cMode = data->mode = MODE_List;\n  data->autoExplain = 1;\n  memcpy(data->colSeparator,SEP_Column, 2);\n  memcpy(data->rowSeparator,SEP_Row, 2);\n  data->showHeader = 0;\n  data->shellFlgs = SHFLG_Lookaside;\n  sqlite3_config(SQLITE_CONFIG_URI, 1);\n  sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);\n  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n  sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,\"sqlite> \");\n  sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,\"   ...> \");\n}\n\n/*\n** Output text to the console in a font that attracts extra attention.\n*/\n#ifdef _WIN32\nstatic void printBold(const char *zText){\n  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);\n  CONSOLE_SCREEN_BUFFER_INFO defaultScreenInfo;\n  GetConsoleScreenBufferInfo(out, &defaultScreenInfo);\n  SetConsoleTextAttribute(out,\n         FOREGROUND_RED|FOREGROUND_INTENSITY\n  );\n  printf(\"%s\", zText);\n  SetConsoleTextAttribute(out, defaultScreenInfo.wAttributes);\n}\n#else\nstatic void printBold(const char *zText){\n  printf(\"\\033[1m%s\\033[0m\", zText);\n}\n#endif\n\n/*\n** Get the argument to an --option.  Throw an error and die if no argument\n** is available.\n*/\nstatic char *cmdline_option_value(int argc, char **argv, int i){\n  if( i==argc ){\n    utf8_printf(stderr, \"%s: Error: missing argument to %s\\n\",\n            argv[0], argv[argc-1]);\n    exit(1);\n  }\n  return argv[i];\n}\n\n#ifndef SQLITE_SHELL_IS_UTF8\n#  if (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)\n#    define SQLITE_SHELL_IS_UTF8          (0)\n#  else\n#    define SQLITE_SHELL_IS_UTF8          (1)\n#  endif\n#endif\n\n#if SQLITE_SHELL_IS_UTF8\nint SQLITE_CDECL main(int argc, char **argv){\n#else\nint SQLITE_CDECL wmain(int argc, wchar_t **wargv){\n  char **argv;\n#endif\n  char *zErrMsg = 0;\n  ShellState data;\n  const char *zInitFile = 0;\n  int i;\n  int rc = 0;\n  int warnInmemoryDb = 0;\n  int readStdin = 1;\n  int nCmd = 0;\n  char **azCmd = 0;\n\n  setBinaryMode(stdin, 0);\n  setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */\n  stdin_is_interactive = isatty(0);\n  stdout_is_console = isatty(1);\n\n#if USE_SYSTEM_SQLITE+0!=1\n  if( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,60)!=0 ){\n    utf8_printf(stderr, \"SQLite header and source version mismatch\\n%s\\n%s\\n\",\n            sqlite3_sourceid(), SQLITE_SOURCE_ID);\n    exit(1);\n  }\n#endif\n  main_init(&data);\n#if !SQLITE_SHELL_IS_UTF8\n  sqlite3_initialize();\n  argv = sqlite3_malloc64(sizeof(argv[0])*argc);\n  if( argv==0 ){\n    raw_printf(stderr, \"out of memory\\n\");\n    exit(1);\n  }\n  for(i=0; i<argc; i++){\n    argv[i] = sqlite3_win32_unicode_to_utf8(wargv[i]);\n    if( argv[i]==0 ){\n      raw_printf(stderr, \"out of memory\\n\");\n      exit(1);\n    }\n  }\n#endif\n  assert( argc>=1 && argv && argv[0] );\n  Argv0 = argv[0];\n\n  /* Make sure we have a valid signal handler early, before anything\n  ** else is done.\n  */\n#ifdef SIGINT\n  signal(SIGINT, interrupt_handler);\n#endif\n\n#ifdef SQLITE_SHELL_DBNAME_PROC\n  {\n    /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name\n    ** of a C-function that will provide the name of the database file.  Use\n    ** this compile-time option to embed this shell program in larger\n    ** applications. */\n    extern void SQLITE_SHELL_DBNAME_PROC(const char**);\n    SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);\n    warnInmemoryDb = 0;\n  }\n#endif\n\n  /* Do an initial pass through the command-line argument to locate\n  ** the name of the database file, the name of the initialization file,\n  ** the size of the alternative malloc heap,\n  ** and the first command to execute.\n  */\n  for(i=1; i<argc; i++){\n    char *z;\n    z = argv[i];\n    if( z[0]!='-' ){\n      if( data.zDbFilename==0 ){\n        data.zDbFilename = z;\n      }else{\n        /* Excesss arguments are interpreted as SQL (or dot-commands) and\n        ** mean that nothing is read from stdin */\n        readStdin = 0;\n        nCmd++;\n        azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);\n        if( azCmd==0 ){\n          raw_printf(stderr, \"out of memory\\n\");\n          exit(1);\n        }\n        azCmd[nCmd-1] = z;\n      }\n    }\n    if( z[1]=='-' ) z++;\n    if( strcmp(z,\"-separator\")==0\n     || strcmp(z,\"-nullvalue\")==0\n     || strcmp(z,\"-newline\")==0\n     || strcmp(z,\"-cmd\")==0\n    ){\n      (void)cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-init\")==0 ){\n      zInitFile = cmdline_option_value(argc, argv, ++i);\n    }else if( strcmp(z,\"-batch\")==0 ){\n      /* Need to check for batch mode here to so we can avoid printing\n      ** informational messages (like from process_sqliterc) before\n      ** we do the actual processing of arguments later in a second pass.\n      */\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)\n      const char *zSize;\n      sqlite3_int64 szHeap;\n\n      zSize = cmdline_option_value(argc, argv, ++i);\n      szHeap = integerValue(zSize);\n      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;\n      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);\n#else\n      (void)cmdline_option_value(argc, argv, ++i);\n#endif\n    }else if( strcmp(z,\"-pagecache\")==0 ){\n      int n, sz;\n      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( sz>70000 ) sz = 70000;\n      if( sz<0 ) sz = 0;\n      n = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      sqlite3_config(SQLITE_CONFIG_PAGECACHE,\n                    (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);\n      data.shellFlgs |= SHFLG_Pagecache;\n    }else if( strcmp(z,\"-lookaside\")==0 ){\n      int n, sz;\n      sz = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( sz<0 ) sz = 0;\n      n = (int)integerValue(cmdline_option_value(argc,argv,++i));\n      if( n<0 ) n = 0;\n      sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);\n      if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      extern int vfstrace_register(\n         const char *zTraceName,\n         const char *zOldVfsName,\n         int (*xOut)(const char*,void*),\n         void *pOutArg,\n         int makeDefault\n      );\n      vfstrace_register(\"trace\",0,(int(*)(const char*,void*))fputs,stderr,1);\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      extern int sqlite3_multiple_initialize(const char*,int);\n      sqlite3_multiplex_initialize(0, 1);\n#endif\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));\n      sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, sz, sz);\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));\n      if( pVfs ){\n        sqlite3_vfs_register(pVfs, 1);\n      }else{\n        utf8_printf(stderr, \"no such VFS: \\\"%s\\\"\\n\", argv[i]);\n        exit(1);\n      }\n    }\n  }\n  if( data.zDbFilename==0 ){\n#ifndef SQLITE_OMIT_MEMORYDB\n    data.zDbFilename = \":memory:\";\n    warnInmemoryDb = argc==1;\n#else\n    utf8_printf(stderr,\"%s: Error: no database filename specified\\n\", Argv0);\n    return 1;\n#endif\n  }\n  data.out = stdout;\n\n  /* Go ahead and open the database file if it already exists.  If the\n  ** file does not exist, delay opening it.  This prevents empty database\n  ** files from being created if a user mistypes the database name argument\n  ** to the sqlite command-line tool.\n  */\n  if( access(data.zDbFilename, 0)==0 ){\n    open_db(&data, 0);\n  }\n\n  /* Process the initialization file if there is one.  If no -init option\n  ** is given on the command line, look for a file named ~/.sqliterc and\n  ** try to process it.\n  */\n  process_sqliterc(&data,zInitFile);\n\n  /* Make a second pass through the command-line argument and set\n  ** options.  This second pass is delayed until after the initialization\n  ** file is processed so that the command-line arguments will override\n  ** settings in the initialization file.\n  */\n  for(i=1; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) continue;\n    if( z[1]=='-' ){ z++; }\n    if( strcmp(z,\"-init\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-html\")==0 ){\n      data.mode = MODE_Html;\n    }else if( strcmp(z,\"-list\")==0 ){\n      data.mode = MODE_List;\n    }else if( strcmp(z,\"-quote\")==0 ){\n      data.mode = MODE_Quote;\n    }else if( strcmp(z,\"-line\")==0 ){\n      data.mode = MODE_Line;\n    }else if( strcmp(z,\"-column\")==0 ){\n      data.mode = MODE_Column;\n    }else if( strcmp(z,\"-csv\")==0 ){\n      data.mode = MODE_Csv;\n      memcpy(data.colSeparator,\",\",2);\n    }else if( strcmp(z,\"-ascii\")==0 ){\n      data.mode = MODE_Ascii;\n      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,\n                       SEP_Unit);\n      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,\n                       SEP_Record);\n    }else if( strcmp(z,\"-separator\")==0 ){\n      sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-newline\")==0 ){\n      sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-nullvalue\")==0 ){\n      sqlite3_snprintf(sizeof(data.nullValue), data.nullValue,\n                       \"%s\",cmdline_option_value(argc,argv,++i));\n    }else if( strcmp(z,\"-header\")==0 ){\n      data.showHeader = 1;\n    }else if( strcmp(z,\"-noheader\")==0 ){\n      data.showHeader = 0;\n    }else if( strcmp(z,\"-echo\")==0 ){\n      ShellSetFlag(&data, SHFLG_Echo);\n    }else if( strcmp(z,\"-eqp\")==0 ){\n      data.autoEQP = 1;\n    }else if( strcmp(z,\"-eqpfull\")==0 ){\n      data.autoEQP = 2;\n    }else if( strcmp(z,\"-stats\")==0 ){\n      data.statsOn = 1;\n    }else if( strcmp(z,\"-scanstats\")==0 ){\n      data.scanstatsOn = 1;\n    }else if( strcmp(z,\"-backslash\")==0 ){\n      /* Undocumented command-line option: -backslash\n      ** Causes C-style backslash escapes to be evaluated in SQL statements\n      ** prior to sending the SQL into SQLite.  Useful for injecting\n      ** crazy bytes in the middle of SQL statements for testing and debugging.\n      */\n      ShellSetFlag(&data, SHFLG_Backslash);\n    }else if( strcmp(z,\"-bail\")==0 ){\n      bail_on_error = 1;\n    }else if( strcmp(z,\"-version\")==0 ){\n      printf(\"%s %s\\n\", sqlite3_libversion(), sqlite3_sourceid());\n      return 0;\n    }else if( strcmp(z,\"-interactive\")==0 ){\n      stdin_is_interactive = 1;\n    }else if( strcmp(z,\"-batch\")==0 ){\n      stdin_is_interactive = 0;\n    }else if( strcmp(z,\"-heap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-pagecache\")==0 ){\n      i+=2;\n    }else if( strcmp(z,\"-lookaside\")==0 ){\n      i+=2;\n    }else if( strcmp(z,\"-mmap\")==0 ){\n      i++;\n    }else if( strcmp(z,\"-vfs\")==0 ){\n      i++;\n#ifdef SQLITE_ENABLE_VFSTRACE\n    }else if( strcmp(z,\"-vfstrace\")==0 ){\n      i++;\n#endif\n#ifdef SQLITE_ENABLE_MULTIPLEX\n    }else if( strcmp(z,\"-multiplex\")==0 ){\n      i++;\n#endif\n    }else if( strcmp(z,\"-help\")==0 ){\n      usage(1);\n    }else if( strcmp(z,\"-cmd\")==0 ){\n      /* Run commands that follow -cmd first and separately from commands\n      ** that simply appear on the command-line.  This seems goofy.  It would\n      ** be better if all commands ran in the order that they appear.  But\n      ** we retain the goofy behavior for historical compatibility. */\n      if( i==argc-1 ) break;\n      z = cmdline_option_value(argc,argv,++i);\n      if( z[0]=='.' ){\n        rc = do_meta_command(z, &data);\n        if( rc && bail_on_error ) return rc==2 ? 0 : rc;\n      }else{\n        open_db(&data, 0);\n        rc = shell_exec(data.db, z, shell_callback, &data, &zErrMsg);\n        if( zErrMsg!=0 ){\n          utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n          if( bail_on_error ) return rc!=0 ? rc : 1;\n        }else if( rc!=0 ){\n          utf8_printf(stderr,\"Error: unable to process SQL \\\"%s\\\"\\n\", z);\n          if( bail_on_error ) return rc;\n        }\n      }\n    }else{\n      utf8_printf(stderr,\"%s: Error: unknown option: %s\\n\", Argv0, z);\n      raw_printf(stderr,\"Use -help for a list of options.\\n\");\n      return 1;\n    }\n    data.cMode = data.mode;\n  }\n\n  if( !readStdin ){\n    /* Run all arguments that do not begin with '-' as if they were separate\n    ** command-line inputs, except for the argToSkip argument which contains\n    ** the database filename.\n    */\n    for(i=0; i<nCmd; i++){\n      if( azCmd[i][0]=='.' ){\n        rc = do_meta_command(azCmd[i], &data);\n        if( rc ) return rc==2 ? 0 : rc;\n      }else{\n        open_db(&data, 0);\n        rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);\n        if( zErrMsg!=0 ){\n          utf8_printf(stderr,\"Error: %s\\n\", zErrMsg);\n          return rc!=0 ? rc : 1;\n        }else if( rc!=0 ){\n          utf8_printf(stderr,\"Error: unable to process SQL: %s\\n\", azCmd[i]);\n          return rc;\n        }\n      }\n    }\n    free(azCmd);\n  }else{\n    /* Run commands received from standard input\n    */\n    if( stdin_is_interactive ){\n      char *zHome;\n      char *zHistory = 0;\n      int nHistory;\n      printf(\n        \"SQLite version %s %.19s\\n\" /*extra-version-info*/\n        \"Enter \\\".help\\\" for usage hints.\\n\",\n        sqlite3_libversion(), sqlite3_sourceid()\n      );\n      if( warnInmemoryDb ){\n        printf(\"Connected to a \");\n        printBold(\"transient in-memory database\");\n        printf(\".\\nUse \\\".open FILENAME\\\" to reopen on a \"\n               \"persistent database.\\n\");\n      }\n      zHome = find_home_dir(0);\n      if( zHome ){\n        nHistory = strlen30(zHome) + 20;\n        if( (zHistory = malloc(nHistory))!=0 ){\n          sqlite3_snprintf(nHistory, zHistory,\"%s/.sqlite_history\", zHome);\n        }\n      }\n      if( zHistory ){ shell_read_history(zHistory); }\n#if HAVE_READLINE || HAVE_EDITLINE\n      rl_attempted_completion_function = readline_completion;\n#elif HAVE_LINENOISE\n      linenoiseSetCompletionCallback(linenoise_completion);\n#endif\n      rc = process_input(&data, 0);\n      if( zHistory ){\n        shell_stifle_history(2000);\n        shell_write_history(zHistory);\n        free(zHistory);\n      }\n    }else{\n      rc = process_input(&data, stdin);\n    }\n  }\n  set_table_name(&data, 0);\n  if( data.db ){\n    session_close_all(&data);\n    sqlite3_close(data.db);\n  }\n  sqlite3_free(data.zFreeOnClose);\n  find_home_dir(1);\n#if !SQLITE_SHELL_IS_UTF8\n  for(i=0; i<argc; i++) sqlite3_free(argv[i]);\n  sqlite3_free(argv);\n#endif\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/sqlite.h.in",
    "content": "/*\n** 2001-09-15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface that the SQLite library\n** presents to client programs.  If a C-function, structure, datatype,\n** or constant definition does not appear in this file, then it is\n** not a published API of SQLite, is subject to change without\n** notice, and should not be referenced by programs that use SQLite.\n**\n** Some of the definitions that are in this file are marked as\n** \"experimental\".  Experimental interfaces are normally new\n** features recently added to SQLite.  We do not anticipate changes\n** to experimental interfaces but reserve the right to make minor changes\n** if experience from use \"in the wild\" suggest such changes are prudent.\n**\n** The official C-language API documentation for SQLite is derived\n** from comments in this file.  This file is the authoritative source\n** on how SQLite interfaces are supposed to operate.\n**\n** The name of this file under configuration management is \"sqlite.h.in\".\n** The makefile makes some minor changes to this file (such as inserting\n** the version number) and changes its name to \"sqlite3.h\" as\n** part of the build process.\n*/\n#ifndef SQLITE3_H\n#define SQLITE3_H\n#include <stdarg.h>     /* Needed for the definition of va_list */\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n** Provide the ability to override linkage features of the interface.\n*/\n#ifndef SQLITE_EXTERN\n# define SQLITE_EXTERN extern\n#endif\n#ifndef SQLITE_API\n# define SQLITE_API\n#endif\n#ifndef SQLITE_CDECL\n# define SQLITE_CDECL\n#endif\n#ifndef SQLITE_APICALL\n# define SQLITE_APICALL\n#endif\n#ifndef SQLITE_STDCALL\n# define SQLITE_STDCALL SQLITE_APICALL\n#endif\n#ifndef SQLITE_CALLBACK\n# define SQLITE_CALLBACK\n#endif\n#ifndef SQLITE_SYSAPI\n# define SQLITE_SYSAPI\n#endif\n\n/*\n** These no-op macros are used in front of interfaces to mark those\n** interfaces as either deprecated or experimental.  New applications\n** should not use deprecated interfaces - they are supported for backwards\n** compatibility only.  Application writers should be aware that\n** experimental interfaces are subject to change in point releases.\n**\n** These macros used to resolve to various kinds of compiler magic that\n** would generate warning messages when they were used.  But that\n** compiler magic ended up generating such a flurry of bug reports\n** that we have taken it all out and gone back to using simple\n** noop macros.\n*/\n#define SQLITE_DEPRECATED\n#define SQLITE_EXPERIMENTAL\n\n/*\n** Ensure these symbols were not defined by some previous header file.\n*/\n#ifdef SQLITE_VERSION\n# undef SQLITE_VERSION\n#endif\n#ifdef SQLITE_VERSION_NUMBER\n# undef SQLITE_VERSION_NUMBER\n#endif\n\n/*\n** CAPI3REF: Compile-Time Library Version Numbers\n**\n** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header\n** evaluates to a string literal that is the SQLite version in the\n** format \"X.Y.Z\" where X is the major version number (always 3 for\n** SQLite3) and Y is the minor version number and Z is the release number.)^\n** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer\n** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same\n** numbers used in [SQLITE_VERSION].)^\n** The SQLITE_VERSION_NUMBER for any given release of SQLite will also\n** be larger than the release from which it is derived.  Either Y will\n** be held constant and Z will be incremented or else Y will be incremented\n** and Z will be reset to zero.\n**\n** Since [version 3.6.18] ([dateof:3.6.18]), \n** SQLite source code has been stored in the\n** <a href=\"http://www.fossil-scm.org/\">Fossil configuration management\n** system</a>.  ^The SQLITE_SOURCE_ID macro evaluates to\n** a string which identifies a particular check-in of SQLite\n** within its configuration management system.  ^The SQLITE_SOURCE_ID\n** string contains the date and time of the check-in (UTC) and a SHA1\n** or SHA3-256 hash of the entire source tree.  If the source code has\n** been edited in any way since it was last checked in, then the last\n** four hexadecimal digits of the hash may be modified.\n**\n** See also: [sqlite3_libversion()],\n** [sqlite3_libversion_number()], [sqlite3_sourceid()],\n** [sqlite_version()] and [sqlite_source_id()].\n*/\n#define SQLITE_VERSION        \"--VERS--\"\n#define SQLITE_VERSION_NUMBER --VERSION-NUMBER--\n#define SQLITE_SOURCE_ID      \"--SOURCE-ID--\"\n\n/*\n** CAPI3REF: Run-Time Library Version Numbers\n** KEYWORDS: sqlite3_version sqlite3_sourceid\n**\n** These interfaces provide the same information as the [SQLITE_VERSION],\n** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros\n** but are associated with the library instead of the header file.  ^(Cautious\n** programmers might include assert() statements in their application to\n** verify that values returned by these interfaces match the macros in\n** the header, and thus ensure that the application is\n** compiled with matching library and header files.\n**\n** <blockquote><pre>\n** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );\n** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );\n** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );\n** </pre></blockquote>)^\n**\n** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]\n** macro.  ^The sqlite3_libversion() function returns a pointer to the\n** to the sqlite3_version[] string constant.  The sqlite3_libversion()\n** function is provided for use in DLLs since DLL users usually do not have\n** direct access to string constants within the DLL.  ^The\n** sqlite3_libversion_number() function returns an integer equal to\n** [SQLITE_VERSION_NUMBER].  ^(The sqlite3_sourceid() function returns \n** a pointer to a string constant whose value is the same as the \n** [SQLITE_SOURCE_ID] C preprocessor macro.  Except if SQLite is built\n** using an edited copy of [the amalgamation], then the last four characters\n** of the hash might be different from [SQLITE_SOURCE_ID].)^\n**\n** See also: [sqlite_version()] and [sqlite_source_id()].\n*/\nSQLITE_EXTERN const char sqlite3_version[];\nconst char *sqlite3_libversion(void);\nconst char *sqlite3_sourceid(void);\nint sqlite3_libversion_number(void);\n\n/*\n** CAPI3REF: Run-Time Library Compilation Options Diagnostics\n**\n** ^The sqlite3_compileoption_used() function returns 0 or 1 \n** indicating whether the specified option was defined at \n** compile time.  ^The SQLITE_ prefix may be omitted from the \n** option name passed to sqlite3_compileoption_used().  \n**\n** ^The sqlite3_compileoption_get() function allows iterating\n** over the list of options that were defined at compile time by\n** returning the N-th compile time option string.  ^If N is out of range,\n** sqlite3_compileoption_get() returns a NULL pointer.  ^The SQLITE_ \n** prefix is omitted from any strings returned by \n** sqlite3_compileoption_get().\n**\n** ^Support for the diagnostic functions sqlite3_compileoption_used()\n** and sqlite3_compileoption_get() may be omitted by specifying the \n** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.\n**\n** See also: SQL functions [sqlite_compileoption_used()] and\n** [sqlite_compileoption_get()] and the [compile_options pragma].\n*/\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nint sqlite3_compileoption_used(const char *zOptName);\nconst char *sqlite3_compileoption_get(int N);\n#endif\n\n/*\n** CAPI3REF: Test To See If The Library Is Threadsafe\n**\n** ^The sqlite3_threadsafe() function returns zero if and only if\n** SQLite was compiled with mutexing code omitted due to the\n** [SQLITE_THREADSAFE] compile-time option being set to 0.\n**\n** SQLite can be compiled with or without mutexes.  When\n** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes\n** are enabled and SQLite is threadsafe.  When the\n** [SQLITE_THREADSAFE] macro is 0, \n** the mutexes are omitted.  Without the mutexes, it is not safe\n** to use SQLite concurrently from more than one thread.\n**\n** Enabling mutexes incurs a measurable performance penalty.\n** So if speed is of utmost importance, it makes sense to disable\n** the mutexes.  But for maximum safety, mutexes should be enabled.\n** ^The default behavior is for mutexes to be enabled.\n**\n** This interface can be used by an application to make sure that the\n** version of SQLite that it is linking against was compiled with\n** the desired setting of the [SQLITE_THREADSAFE] macro.\n**\n** This interface only reports on the compile-time mutex setting\n** of the [SQLITE_THREADSAFE] flag.  If SQLite is compiled with\n** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but\n** can be fully or partially disabled using a call to [sqlite3_config()]\n** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],\n** or [SQLITE_CONFIG_SERIALIZED].  ^(The return value of the\n** sqlite3_threadsafe() function shows only the compile-time setting of\n** thread safety, not any run-time changes to that setting made by\n** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()\n** is unchanged by calls to sqlite3_config().)^\n**\n** See the [threading mode] documentation for additional information.\n*/\nint sqlite3_threadsafe(void);\n\n/*\n** CAPI3REF: Database Connection Handle\n** KEYWORDS: {database connection} {database connections}\n**\n** Each open SQLite database is represented by a pointer to an instance of\n** the opaque structure named \"sqlite3\".  It is useful to think of an sqlite3\n** pointer as an object.  The [sqlite3_open()], [sqlite3_open16()], and\n** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]\n** and [sqlite3_close_v2()] are its destructors.  There are many other\n** interfaces (such as\n** [sqlite3_prepare_v2()], [sqlite3_create_function()], and\n** [sqlite3_busy_timeout()] to name but three) that are methods on an\n** sqlite3 object.\n*/\ntypedef struct sqlite3 sqlite3;\n\n/*\n** CAPI3REF: 64-Bit Integer Types\n** KEYWORDS: sqlite_int64 sqlite_uint64\n**\n** Because there is no cross-platform way to specify 64-bit integer types\n** SQLite includes typedefs for 64-bit signed and unsigned integers.\n**\n** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.\n** The sqlite_int64 and sqlite_uint64 types are supported for backwards\n** compatibility only.\n**\n** ^The sqlite3_int64 and sqlite_int64 types can store integer values\n** between -9223372036854775808 and +9223372036854775807 inclusive.  ^The\n** sqlite3_uint64 and sqlite_uint64 types can store integer values \n** between 0 and +18446744073709551615 inclusive.\n*/\n#ifdef SQLITE_INT64_TYPE\n  typedef SQLITE_INT64_TYPE sqlite_int64;\n# ifdef SQLITE_UINT64_TYPE\n    typedef SQLITE_UINT64_TYPE sqlite_uint64;\n# else  \n    typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;\n# endif\n#elif defined(_MSC_VER) || defined(__BORLANDC__)\n  typedef __int64 sqlite_int64;\n  typedef unsigned __int64 sqlite_uint64;\n#else\n  typedef long long int sqlite_int64;\n  typedef unsigned long long int sqlite_uint64;\n#endif\ntypedef sqlite_int64 sqlite3_int64;\ntypedef sqlite_uint64 sqlite3_uint64;\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite3_int64\n#endif\n\n/*\n** CAPI3REF: Closing A Database Connection\n** DESTRUCTOR: sqlite3\n**\n** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors\n** for the [sqlite3] object.\n** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if\n** the [sqlite3] object is successfully destroyed and all associated\n** resources are deallocated.\n**\n** ^If the database connection is associated with unfinalized prepared\n** statements or unfinished sqlite3_backup objects then sqlite3_close()\n** will leave the database connection open and return [SQLITE_BUSY].\n** ^If sqlite3_close_v2() is called with unfinalized prepared statements\n** and/or unfinished sqlite3_backups, then the database connection becomes\n** an unusable \"zombie\" which will automatically be deallocated when the\n** last prepared statement is finalized or the last sqlite3_backup is\n** finished.  The sqlite3_close_v2() interface is intended for use with\n** host languages that are garbage collected, and where the order in which\n** destructors are called is arbitrary.\n**\n** Applications should [sqlite3_finalize | finalize] all [prepared statements],\n** [sqlite3_blob_close | close] all [BLOB handles], and \n** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated\n** with the [sqlite3] object prior to attempting to close the object.  ^If\n** sqlite3_close_v2() is called on a [database connection] that still has\n** outstanding [prepared statements], [BLOB handles], and/or\n** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation\n** of resources is deferred until all [prepared statements], [BLOB handles],\n** and [sqlite3_backup] objects are also destroyed.\n**\n** ^If an [sqlite3] object is destroyed while a transaction is open,\n** the transaction is automatically rolled back.\n**\n** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]\n** must be either a NULL\n** pointer or an [sqlite3] object pointer obtained\n** from [sqlite3_open()], [sqlite3_open16()], or\n** [sqlite3_open_v2()], and not previously closed.\n** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer\n** argument is a harmless no-op.\n*/\nint sqlite3_close(sqlite3*);\nint sqlite3_close_v2(sqlite3*);\n\n/*\n** The type for a callback function.\n** This is legacy and deprecated.  It is included for historical\n** compatibility and is not documented.\n*/\ntypedef int (*sqlite3_callback)(void*,int,char**, char**);\n\n/*\n** CAPI3REF: One-Step Query Execution Interface\n** METHOD: sqlite3\n**\n** The sqlite3_exec() interface is a convenience wrapper around\n** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],\n** that allows an application to run multiple statements of SQL\n** without having to use a lot of C code. \n**\n** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,\n** semicolon-separate SQL statements passed into its 2nd argument,\n** in the context of the [database connection] passed in as its 1st\n** argument.  ^If the callback function of the 3rd argument to\n** sqlite3_exec() is not NULL, then it is invoked for each result row\n** coming out of the evaluated SQL statements.  ^The 4th argument to\n** sqlite3_exec() is relayed through to the 1st argument of each\n** callback invocation.  ^If the callback pointer to sqlite3_exec()\n** is NULL, then no callback is ever invoked and result rows are\n** ignored.\n**\n** ^If an error occurs while evaluating the SQL statements passed into\n** sqlite3_exec(), then execution of the current statement stops and\n** subsequent statements are skipped.  ^If the 5th parameter to sqlite3_exec()\n** is not NULL then any error message is written into memory obtained\n** from [sqlite3_malloc()] and passed back through the 5th parameter.\n** To avoid memory leaks, the application should invoke [sqlite3_free()]\n** on error message strings returned through the 5th parameter of\n** sqlite3_exec() after the error message string is no longer needed.\n** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors\n** occur, then sqlite3_exec() sets the pointer in its 5th parameter to\n** NULL before returning.\n**\n** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()\n** routine returns SQLITE_ABORT without invoking the callback again and\n** without running any subsequent SQL statements.\n**\n** ^The 2nd argument to the sqlite3_exec() callback function is the\n** number of columns in the result.  ^The 3rd argument to the sqlite3_exec()\n** callback is an array of pointers to strings obtained as if from\n** [sqlite3_column_text()], one for each column.  ^If an element of a\n** result row is NULL then the corresponding string pointer for the\n** sqlite3_exec() callback is a NULL pointer.  ^The 4th argument to the\n** sqlite3_exec() callback is an array of pointers to strings where each\n** entry represents the name of corresponding result column as obtained\n** from [sqlite3_column_name()].\n**\n** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer\n** to an empty string, or a pointer that contains only whitespace and/or \n** SQL comments, then no SQL statements are evaluated and the database\n** is not changed.\n**\n** Restrictions:\n**\n** <ul>\n** <li> The application must ensure that the 1st parameter to sqlite3_exec()\n**      is a valid and open [database connection].\n** <li> The application must not close the [database connection] specified by\n**      the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.\n** <li> The application must not modify the SQL statement text passed into\n**      the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.\n** </ul>\n*/\nint sqlite3_exec(\n  sqlite3*,                                  /* An open database */\n  const char *sql,                           /* SQL to be evaluated */\n  int (*callback)(void*,int,char**,char**),  /* Callback function */\n  void *,                                    /* 1st argument to callback */\n  char **errmsg                              /* Error msg written here */\n);\n\n/*\n** CAPI3REF: Result Codes\n** KEYWORDS: {result code definitions}\n**\n** Many SQLite functions return an integer result code from the set shown\n** here in order to indicate success or failure.\n**\n** New error codes may be added in future versions of SQLite.\n**\n** See also: [extended result code definitions]\n*/\n#define SQLITE_OK           0   /* Successful result */\n/* beginning-of-error-codes */\n#define SQLITE_ERROR        1   /* Generic error */\n#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */\n#define SQLITE_PERM         3   /* Access permission denied */\n#define SQLITE_ABORT        4   /* Callback routine requested an abort */\n#define SQLITE_BUSY         5   /* The database file is locked */\n#define SQLITE_LOCKED       6   /* A table in the database is locked */\n#define SQLITE_NOMEM        7   /* A malloc() failed */\n#define SQLITE_READONLY     8   /* Attempt to write a readonly database */\n#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/\n#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */\n#define SQLITE_CORRUPT     11   /* The database disk image is malformed */\n#define SQLITE_NOTFOUND    12   /* Unknown opcode in sqlite3_file_control() */\n#define SQLITE_FULL        13   /* Insertion failed because database is full */\n#define SQLITE_CANTOPEN    14   /* Unable to open the database file */\n#define SQLITE_PROTOCOL    15   /* Database lock protocol error */\n#define SQLITE_EMPTY       16   /* Internal use only */\n#define SQLITE_SCHEMA      17   /* The database schema changed */\n#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */\n#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */\n#define SQLITE_MISMATCH    20   /* Data type mismatch */\n#define SQLITE_MISUSE      21   /* Library used incorrectly */\n#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */\n#define SQLITE_AUTH        23   /* Authorization denied */\n#define SQLITE_FORMAT      24   /* Not used */\n#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */\n#define SQLITE_NOTADB      26   /* File opened that is not a database file */\n#define SQLITE_NOTICE      27   /* Notifications from sqlite3_log() */\n#define SQLITE_WARNING     28   /* Warnings from sqlite3_log() */\n#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */\n#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */\n/* end-of-error-codes */\n\n/*\n** CAPI3REF: Extended Result Codes\n** KEYWORDS: {extended result code definitions}\n**\n** In its default configuration, SQLite API routines return one of 30 integer\n** [result codes].  However, experience has shown that many of\n** these result codes are too coarse-grained.  They do not provide as\n** much information about problems as programmers might like.  In an effort to\n** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]\n** and later) include\n** support for additional result codes that provide more detailed information\n** about errors. These [extended result codes] are enabled or disabled\n** on a per database connection basis using the\n** [sqlite3_extended_result_codes()] API.  Or, the extended code for\n** the most recent error can be obtained using\n** [sqlite3_extended_errcode()].\n*/\n#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))\n#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))\n#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))\n#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))\n#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))\n#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))\n#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))\n#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8<<8))\n#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9<<8))\n#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10<<8))\n#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11<<8))\n#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12<<8))\n#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13<<8))\n#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))\n#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15<<8))\n#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16<<8))\n#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17<<8))\n#define SQLITE_IOERR_SHMOPEN           (SQLITE_IOERR | (18<<8))\n#define SQLITE_IOERR_SHMSIZE           (SQLITE_IOERR | (19<<8))\n#define SQLITE_IOERR_SHMLOCK           (SQLITE_IOERR | (20<<8))\n#define SQLITE_IOERR_SHMMAP            (SQLITE_IOERR | (21<<8))\n#define SQLITE_IOERR_SEEK              (SQLITE_IOERR | (22<<8))\n#define SQLITE_IOERR_DELETE_NOENT      (SQLITE_IOERR | (23<<8))\n#define SQLITE_IOERR_MMAP              (SQLITE_IOERR | (24<<8))\n#define SQLITE_IOERR_GETTEMPPATH       (SQLITE_IOERR | (25<<8))\n#define SQLITE_IOERR_CONVPATH          (SQLITE_IOERR | (26<<8))\n#define SQLITE_IOERR_VNODE             (SQLITE_IOERR | (27<<8))\n#define SQLITE_IOERR_AUTH              (SQLITE_IOERR | (28<<8))\n#define SQLITE_IOERR_BEGIN_ATOMIC      (SQLITE_IOERR | (29<<8))\n#define SQLITE_IOERR_COMMIT_ATOMIC     (SQLITE_IOERR | (30<<8))\n#define SQLITE_IOERR_ROLLBACK_ATOMIC   (SQLITE_IOERR | (31<<8))\n#define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))\n#define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))\n#define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))\n#define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))\n#define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))\n#define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))\n#define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))\n#define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))\n#define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))\n#define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))\n#define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))\n#define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))\n#define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))\n#define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))\n#define SQLITE_CONSTRAINT_COMMITHOOK   (SQLITE_CONSTRAINT | (2<<8))\n#define SQLITE_CONSTRAINT_FOREIGNKEY   (SQLITE_CONSTRAINT | (3<<8))\n#define SQLITE_CONSTRAINT_FUNCTION     (SQLITE_CONSTRAINT | (4<<8))\n#define SQLITE_CONSTRAINT_NOTNULL      (SQLITE_CONSTRAINT | (5<<8))\n#define SQLITE_CONSTRAINT_PRIMARYKEY   (SQLITE_CONSTRAINT | (6<<8))\n#define SQLITE_CONSTRAINT_TRIGGER      (SQLITE_CONSTRAINT | (7<<8))\n#define SQLITE_CONSTRAINT_UNIQUE       (SQLITE_CONSTRAINT | (8<<8))\n#define SQLITE_CONSTRAINT_VTAB         (SQLITE_CONSTRAINT | (9<<8))\n#define SQLITE_CONSTRAINT_ROWID        (SQLITE_CONSTRAINT |(10<<8))\n#define SQLITE_NOTICE_RECOVER_WAL      (SQLITE_NOTICE | (1<<8))\n#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))\n#define SQLITE_WARNING_AUTOINDEX       (SQLITE_WARNING | (1<<8))\n#define SQLITE_AUTH_USER               (SQLITE_AUTH | (1<<8))\n#define SQLITE_OK_LOAD_PERMANENTLY     (SQLITE_OK | (1<<8))\n\n/*\n** CAPI3REF: Flags For File Open Operations\n**\n** These bit values are intended for use in the\n** 3rd parameter to the [sqlite3_open_v2()] interface and\n** in the 4th parameter to the [sqlite3_vfs.xOpen] method.\n*/\n#define SQLITE_OPEN_READONLY         0x00000001  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_READWRITE        0x00000002  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_CREATE           0x00000004  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_DELETEONCLOSE    0x00000008  /* VFS only */\n#define SQLITE_OPEN_EXCLUSIVE        0x00000010  /* VFS only */\n#define SQLITE_OPEN_AUTOPROXY        0x00000020  /* VFS only */\n#define SQLITE_OPEN_URI              0x00000040  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MEMORY           0x00000080  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_MAIN_DB          0x00000100  /* VFS only */\n#define SQLITE_OPEN_TEMP_DB          0x00000200  /* VFS only */\n#define SQLITE_OPEN_TRANSIENT_DB     0x00000400  /* VFS only */\n#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800  /* VFS only */\n#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000  /* VFS only */\n#define SQLITE_OPEN_SUBJOURNAL       0x00002000  /* VFS only */\n#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000  /* VFS only */\n#define SQLITE_OPEN_NOMUTEX          0x00008000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_FULLMUTEX        0x00010000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_SHAREDCACHE      0x00020000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_PRIVATECACHE     0x00040000  /* Ok for sqlite3_open_v2() */\n#define SQLITE_OPEN_WAL              0x00080000  /* VFS only */\n\n/* Reserved:                         0x00F00000 */\n\n/*\n** CAPI3REF: Device Characteristics\n**\n** The xDeviceCharacteristics method of the [sqlite3_io_methods]\n** object returns an integer which is a vector of these\n** bit values expressing I/O characteristics of the mass storage\n** device that holds the file that the [sqlite3_io_methods]\n** refers to.\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().  The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that\n** after reboot following a crash or power loss, the only bytes in a\n** file that were written at the application level might have changed\n** and that adjacent bytes, even bytes within the same sector are\n** guaranteed to be unchanged.  The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN\n** flag indicates that a file cannot be deleted when open.  The\n** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on\n** read-only media and cannot be changed even by processes with\n** elevated privileges.\n**\n** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying\n** filesystem supports doing multiple write operations atomically when those\n** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and\n** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].\n*/\n#define SQLITE_IOCAP_ATOMIC                 0x00000001\n#define SQLITE_IOCAP_ATOMIC512              0x00000002\n#define SQLITE_IOCAP_ATOMIC1K               0x00000004\n#define SQLITE_IOCAP_ATOMIC2K               0x00000008\n#define SQLITE_IOCAP_ATOMIC4K               0x00000010\n#define SQLITE_IOCAP_ATOMIC8K               0x00000020\n#define SQLITE_IOCAP_ATOMIC16K              0x00000040\n#define SQLITE_IOCAP_ATOMIC32K              0x00000080\n#define SQLITE_IOCAP_ATOMIC64K              0x00000100\n#define SQLITE_IOCAP_SAFE_APPEND            0x00000200\n#define SQLITE_IOCAP_SEQUENTIAL             0x00000400\n#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN  0x00000800\n#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000\n#define SQLITE_IOCAP_IMMUTABLE              0x00002000\n#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000\n\n/*\n** CAPI3REF: File Locking Levels\n**\n** SQLite uses one of these integer values as the second\n** argument to calls it makes to the xLock() and xUnlock() methods\n** of an [sqlite3_io_methods] object.\n*/\n#define SQLITE_LOCK_NONE          0\n#define SQLITE_LOCK_SHARED        1\n#define SQLITE_LOCK_RESERVED      2\n#define SQLITE_LOCK_PENDING       3\n#define SQLITE_LOCK_EXCLUSIVE     4\n\n/*\n** CAPI3REF: Synchronization Type Flags\n**\n** When SQLite invokes the xSync() method of an\n** [sqlite3_io_methods] object it uses a combination of\n** these integer values as the second argument.\n**\n** When the SQLITE_SYNC_DATAONLY flag is used, it means that the\n** sync operation only needs to flush data to mass storage.  Inode\n** information need not be flushed. If the lower four bits of the flag\n** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.\n** If the lower four bits equal SQLITE_SYNC_FULL, that means\n** to use Mac OS X style fullsync instead of fsync().\n**\n** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags\n** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL\n** settings.  The [synchronous pragma] determines when calls to the\n** xSync VFS method occur and applies uniformly across all platforms.\n** The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how\n** energetic or rigorous or forceful the sync operations are and\n** only make a difference on Mac OSX for the default SQLite code.\n** (Third-party VFS implementations might also make the distinction\n** between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the\n** operating systems natively supported by SQLite, only Mac OSX\n** cares about the difference.)\n*/\n#define SQLITE_SYNC_NORMAL        0x00002\n#define SQLITE_SYNC_FULL          0x00003\n#define SQLITE_SYNC_DATAONLY      0x00010\n\n/*\n** CAPI3REF: OS Interface Open File Handle\n**\n** An [sqlite3_file] object represents an open file in the \n** [sqlite3_vfs | OS interface layer].  Individual OS interface\n** implementations will\n** want to subclass this object by appending additional fields\n** for their own use.  The pMethods entry is a pointer to an\n** [sqlite3_io_methods] object that defines methods for performing\n** I/O operations on the open file.\n*/\ntypedef struct sqlite3_file sqlite3_file;\nstruct sqlite3_file {\n  const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */\n};\n\n/*\n** CAPI3REF: OS Interface File Virtual Methods Object\n**\n** Every file opened by the [sqlite3_vfs.xOpen] method populates an\n** [sqlite3_file] object (or, more commonly, a subclass of the\n** [sqlite3_file] object) with a pointer to an instance of this object.\n** This object defines the methods used to perform various operations\n** against the open file represented by the [sqlite3_file] object.\n**\n** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element \n** to a non-NULL pointer, then the sqlite3_io_methods.xClose method\n** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed.  The\n** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]\n** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element\n** to NULL.\n**\n** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or\n** [SQLITE_SYNC_FULL].  The first choice is the normal fsync().\n** The second choice is a Mac OS X style fullsync.  The [SQLITE_SYNC_DATAONLY]\n** flag may be ORed in to indicate that only the data of the file\n** and not its inode needs to be synced.\n**\n** The integer values to xLock() and xUnlock() are one of\n** <ul>\n** <li> [SQLITE_LOCK_NONE],\n** <li> [SQLITE_LOCK_SHARED],\n** <li> [SQLITE_LOCK_RESERVED],\n** <li> [SQLITE_LOCK_PENDING], or\n** <li> [SQLITE_LOCK_EXCLUSIVE].\n** </ul>\n** xLock() increases the lock. xUnlock() decreases the lock.\n** The xCheckReservedLock() method checks whether any database connection,\n** either in this process or in some other process, is holding a RESERVED,\n** PENDING, or EXCLUSIVE lock on the file.  It returns true\n** if such a lock exists and false otherwise.\n**\n** The xFileControl() method is a generic interface that allows custom\n** VFS implementations to directly control an open file using the\n** [sqlite3_file_control()] interface.  The second \"op\" argument is an\n** integer opcode.  The third argument is a generic pointer intended to\n** point to a structure that may contain arguments or space in which to\n** write return values.  Potential uses for xFileControl() might be\n** functions to enable blocking locks with timeouts, to change the\n** locking strategy (for example to use dot-file locks), to inquire\n** about the status of a lock, or to break stale locks.  The SQLite\n** core reserves all opcodes less than 100 for its own use.\n** A [file control opcodes | list of opcodes] less than 100 is available.\n** Applications that define a custom xFileControl method should use opcodes\n** greater than 100 to avoid conflicts.  VFS implementations should\n** return [SQLITE_NOTFOUND] for file control opcodes that they do not\n** recognize.\n**\n** The xSectorSize() method returns the sector size of the\n** device that underlies the file.  The sector size is the\n** minimum write that can be performed without disturbing\n** other bytes in the file.  The xDeviceCharacteristics()\n** method returns a bit vector describing behaviors of the\n** underlying device:\n**\n** <ul>\n** <li> [SQLITE_IOCAP_ATOMIC]\n** <li> [SQLITE_IOCAP_ATOMIC512]\n** <li> [SQLITE_IOCAP_ATOMIC1K]\n** <li> [SQLITE_IOCAP_ATOMIC2K]\n** <li> [SQLITE_IOCAP_ATOMIC4K]\n** <li> [SQLITE_IOCAP_ATOMIC8K]\n** <li> [SQLITE_IOCAP_ATOMIC16K]\n** <li> [SQLITE_IOCAP_ATOMIC32K]\n** <li> [SQLITE_IOCAP_ATOMIC64K]\n** <li> [SQLITE_IOCAP_SAFE_APPEND]\n** <li> [SQLITE_IOCAP_SEQUENTIAL]\n** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]\n** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]\n** <li> [SQLITE_IOCAP_IMMUTABLE]\n** <li> [SQLITE_IOCAP_BATCH_ATOMIC]\n** </ul>\n**\n** The SQLITE_IOCAP_ATOMIC property means that all writes of\n** any size are atomic.  The SQLITE_IOCAP_ATOMICnnn values\n** mean that writes of blocks that are nnn bytes in size and\n** are aligned to an address which is an integer multiple of\n** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means\n** that when data is appended to a file, the data is appended\n** first then the size of the file is extended, never the other\n** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that\n** information is written to disk in the same order as calls\n** to xWrite().\n**\n** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill\n** in the unread portions of the buffer with zeros.  A VFS that\n** fails to zero-fill short reads might seem to work.  However,\n** failure to zero-fill short reads will eventually lead to\n** database corruption.\n*/\ntypedef struct sqlite3_io_methods sqlite3_io_methods;\nstruct sqlite3_io_methods {\n  int iVersion;\n  int (*xClose)(sqlite3_file*);\n  int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\n  int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);\n  int (*xSync)(sqlite3_file*, int flags);\n  int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);\n  int (*xLock)(sqlite3_file*, int);\n  int (*xUnlock)(sqlite3_file*, int);\n  int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);\n  int (*xFileControl)(sqlite3_file*, int op, void *pArg);\n  int (*xSectorSize)(sqlite3_file*);\n  int (*xDeviceCharacteristics)(sqlite3_file*);\n  /* Methods above are valid for version 1 */\n  int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);\n  int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);\n  void (*xShmBarrier)(sqlite3_file*);\n  int (*xShmUnmap)(sqlite3_file*, int deleteFlag);\n  /* Methods above are valid for version 2 */\n  int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);\n  int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);\n  /* Methods above are valid for version 3 */\n  /* Additional methods may be added in future releases */\n};\n\n/*\n** CAPI3REF: Standard File Control Opcodes\n** KEYWORDS: {file control opcodes} {file control opcode}\n**\n** These integer constants are opcodes for the xFileControl method\n** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]\n** interface.\n**\n** <ul>\n** <li>[[SQLITE_FCNTL_LOCKSTATE]]\n** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to write the current state of\n** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],\n** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])\n** into an integer that the pArg argument points to. This capability\n** is used during testing and is only available when the SQLITE_TEST\n** compile-time option is used.\n**\n** <li>[[SQLITE_FCNTL_SIZE_HINT]]\n** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS\n** layer a hint of how large the database file will grow to be during the\n** current transaction.  This hint is not guaranteed to be accurate but it\n** is often close.  The underlying VFS might choose to preallocate database\n** file space based on this hint in order to help writes to the database\n** file run faster.\n**\n** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]\n** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS\n** extends and truncates the database file in chunks of a size specified\n** by the user. The fourth argument to [sqlite3_file_control()] should \n** point to an integer (type int) containing the new chunk-size to use\n** for the nominated database. Allocating database file space in large\n** chunks (say 1MB at a time), may reduce file-system fragmentation and\n** improve performance on some systems.\n**\n** <li>[[SQLITE_FCNTL_FILE_POINTER]]\n** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with a particular database\n** connection.  See also [SQLITE_FCNTL_JOURNAL_POINTER].\n**\n** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]\n** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer\n** to the [sqlite3_file] object associated with the journal file (either\n** the [rollback journal] or the [write-ahead log]) for a particular database\n** connection.  See also [SQLITE_FCNTL_FILE_POINTER].\n**\n** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]\n** No longer in use.\n**\n** <li>[[SQLITE_FCNTL_SYNC]]\n** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and\n** sent to the VFS immediately before the xSync method is invoked on a\n** database file descriptor. Or, if the xSync method is not invoked \n** because the user has configured SQLite with \n** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place \n** of the xSync method. In most cases, the pointer argument passed with\n** this file-control is NULL. However, if the database file is being synced\n** as part of a multi-database commit, the argument points to a nul-terminated\n** string containing the transactions master-journal file name. VFSes that \n** do not need this signal should silently ignore this opcode. Applications \n** should not call [sqlite3_file_control()] with this opcode as doing so may \n** disrupt the operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]\n** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite\n** and sent to the VFS after a transaction has been committed immediately\n** but before the database is unlocked. VFSes that do not need this signal\n** should silently ignore this opcode. Applications should not call\n** [sqlite3_file_control()] with this opcode as doing so may disrupt the \n** operation of the specialized VFSes that do require it.  \n**\n** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]\n** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic\n** retry counts and intervals for certain disk I/O operations for the\n** windows [VFS] in order to provide robustness in the presence of\n** anti-virus programs.  By default, the windows VFS will retry file read,\n** file write, and file delete operations up to 10 times, with a delay\n** of 25 milliseconds before the first retry and with the delay increasing\n** by an additional 25 milliseconds with each subsequent retry.  This\n** opcode allows these two values (10 retries and 25 milliseconds of delay)\n** to be adjusted.  The values are changed for all database connections\n** within the same process.  The argument is a pointer to an array of two\n** integers where the first integer is the new retry count and the second\n** integer is the delay.  If either integer is negative, then the setting\n** is not changed but instead the prior value of that setting is written\n** into the array entry, allowing the current retry settings to be\n** interrogated.  The zDbName parameter is ignored.\n**\n** <li>[[SQLITE_FCNTL_PERSIST_WAL]]\n** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the\n** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary\n** write ahead log and shared memory files used for transaction control\n** are automatically deleted when the latest connection to the database\n** closes.  Setting persistent WAL mode causes those files to persist after\n** close.  Persisting the files is useful when other processes that do not\n** have write permission on the directory containing the database file want\n** to read the database file, as the WAL and shared memory files must exist\n** in order for the database to be readable.  The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable persistent WAL mode or 1 to enable persistent\n** WAL mode.  If the integer is -1, then it is overwritten with the current\n** WAL persistence setting.\n**\n** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]\n** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the\n** persistent \"powersafe-overwrite\" or \"PSOW\" setting.  The PSOW setting\n** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the\n** xDeviceCharacteristics methods. The fourth parameter to\n** [sqlite3_file_control()] for this opcode should be a pointer to an integer.\n** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage\n** mode.  If the integer is -1, then it is overwritten with the current\n** zero-damage mode setting.\n**\n** <li>[[SQLITE_FCNTL_OVERWRITE]]\n** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening\n** a write transaction to indicate that, unless it is rolled back for some\n** reason, the entire database file will be overwritten by the current \n** transaction. This is used by VACUUM operations.\n**\n** <li>[[SQLITE_FCNTL_VFSNAME]]\n** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of\n** all [VFSes] in the VFS stack.  The names are of all VFS shims and the\n** final bottom-level VFS are written into memory obtained from \n** [sqlite3_malloc()] and the result is stored in the char* variable\n** that the fourth parameter of [sqlite3_file_control()] points to.\n** The caller is responsible for freeing the memory when done.  As with\n** all file-control actions, there is no guarantee that this will actually\n** do anything.  Callers should initialize the char* variable to a NULL\n** pointer in case this file-control is not implemented.  This file-control\n** is intended for diagnostic use only.\n**\n** <li>[[SQLITE_FCNTL_VFS_POINTER]]\n** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level\n** [VFSes] currently in use.  ^(The argument X in\n** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be\n** of type \"[sqlite3_vfs] **\".  This opcodes will set *X\n** to a pointer to the top-level VFS.)^\n** ^When there are multiple VFS shims in the stack, this opcode finds the\n** upper-most shim only.\n**\n** <li>[[SQLITE_FCNTL_PRAGMA]]\n** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] \n** file control is sent to the open [sqlite3_file] object corresponding\n** to the database file to which the pragma statement refers. ^The argument\n** to the [SQLITE_FCNTL_PRAGMA] file control is an array of\n** pointers to strings (char**) in which the second element of the array\n** is the name of the pragma and the third element is the argument to the\n** pragma or NULL if the pragma has no argument.  ^The handler for an\n** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element\n** of the char** argument point to a string obtained from [sqlite3_mprintf()]\n** or the equivalent and that string will become the result of the pragma or\n** the error message if the pragma fails. ^If the\n** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal \n** [PRAGMA] processing continues.  ^If the [SQLITE_FCNTL_PRAGMA]\n** file control returns [SQLITE_OK], then the parser assumes that the\n** VFS has handled the PRAGMA itself and the parser generates a no-op\n** prepared statement if result string is NULL, or that returns a copy\n** of the result string if the string is non-NULL.\n** ^If the [SQLITE_FCNTL_PRAGMA] file control returns\n** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means\n** that the VFS encountered an error while handling the [PRAGMA] and the\n** compilation of the PRAGMA fails with an error.  ^The [SQLITE_FCNTL_PRAGMA]\n** file control occurs at the beginning of pragma statement analysis and so\n** it is able to override built-in [PRAGMA] statements.\n**\n** <li>[[SQLITE_FCNTL_BUSYHANDLER]]\n** ^The [SQLITE_FCNTL_BUSYHANDLER]\n** file-control may be invoked by SQLite on the database file handle\n** shortly after it is opened in order to provide a custom VFS with access\n** to the connections busy-handler callback. The argument is of type (void **)\n** - an array of two (void *) values. The first (void *) actually points\n** to a function of type (int (*)(void *)). In order to invoke the connections\n** busy-handler, this function should be invoked with the second (void *) in\n** the array as the only argument. If it returns non-zero, then the operation\n** should be retried. If it returns zero, the custom VFS should abandon the\n** current operation.\n**\n** <li>[[SQLITE_FCNTL_TEMPFILENAME]]\n** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control\n** to have SQLite generate a\n** temporary filename using the same algorithm that is followed to generate\n** temporary filenames for TEMP tables and other internal uses.  The\n** argument should be a char** which will be filled with the filename\n** written into memory obtained from [sqlite3_malloc()].  The caller should\n** invoke [sqlite3_free()] on the result to avoid a memory leak.\n**\n** <li>[[SQLITE_FCNTL_MMAP_SIZE]]\n** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the\n** maximum number of bytes that will be used for memory-mapped I/O.\n** The argument is a pointer to a value of type sqlite3_int64 that\n** is an advisory maximum number of bytes in the file to memory map.  The\n** pointer is overwritten with the old value.  The limit is not changed if\n** the value originally pointed to is negative, and so the current limit \n** can be queried by passing in a pointer to a negative number.  This\n** file-control is used internally to implement [PRAGMA mmap_size].\n**\n** <li>[[SQLITE_FCNTL_TRACE]]\n** The [SQLITE_FCNTL_TRACE] file control provides advisory information\n** to the VFS about what the higher layers of the SQLite stack are doing.\n** This file control is used by some VFS activity tracing [shims].\n** The argument is a zero-terminated string.  Higher layers in the\n** SQLite stack may generate instances of this file control if\n** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.\n**\n** <li>[[SQLITE_FCNTL_HAS_MOVED]]\n** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a\n** pointer to an integer and it writes a boolean into that integer depending\n** on whether or not the file has been renamed, moved, or deleted since it\n** was first opened.\n**\n** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the\n** underlying native file handle associated with a file handle.  This file\n** control interprets its argument as a pointer to a native file handle and\n** writes the resulting value there.\n**\n** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]\n** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging.  This\n** opcode causes the xFileControl method to swap the file handle with the one\n** pointed to by the pArg argument.  This capability is used during testing\n** and only needs to be supported when SQLITE_TEST is defined.\n**\n** <li>[[SQLITE_FCNTL_WAL_BLOCK]]\n** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might\n** be advantageous to block on the next WAL lock if the lock is not immediately\n** available.  The WAL subsystem issues this signal during rare\n** circumstances in order to fix a problem with priority inversion.\n** Applications should <em>not</em> use this file-control.\n**\n** <li>[[SQLITE_FCNTL_ZIPVFS]]\n** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other\n** VFS should return SQLITE_NOTFOUND for this opcode.\n**\n** <li>[[SQLITE_FCNTL_RBU]]\n** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by\n** the RBU extension only.  All other VFS should return SQLITE_NOTFOUND for\n** this opcode.  \n**\n** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]\n** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then\n** the file descriptor is placed in \"batch write mode\", which\n** means all subsequent write operations will be deferred and done\n** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].  Systems\n** that do not support batch atomic writes will return SQLITE_NOTFOUND.\n** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to\n** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or\n** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make\n** no VFS interface calls on the same [sqlite3_file] file descriptor\n** except for calls to the xWrite method and the xFileControl method\n** with [SQLITE_FCNTL_SIZE_HINT].\n**\n** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.\n** This file control returns [SQLITE_OK] if and only if the writes were\n** all performed successfully and have been committed to persistent storage.\n** ^Regardless of whether or not it is successful, this file control takes\n** the file descriptor out of batch write mode so that all subsequent\n** write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n**\n** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]\n** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write\n** operations since the previous successful call to \n** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.\n** ^This file control takes the file descriptor out of batch write mode\n** so that all subsequent write operations are independent.\n** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without\n** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].\n** </ul>\n*/\n#define SQLITE_FCNTL_LOCKSTATE               1\n#define SQLITE_FCNTL_GET_LOCKPROXYFILE       2\n#define SQLITE_FCNTL_SET_LOCKPROXYFILE       3\n#define SQLITE_FCNTL_LAST_ERRNO              4\n#define SQLITE_FCNTL_SIZE_HINT               5\n#define SQLITE_FCNTL_CHUNK_SIZE              6\n#define SQLITE_FCNTL_FILE_POINTER            7\n#define SQLITE_FCNTL_SYNC_OMITTED            8\n#define SQLITE_FCNTL_WIN32_AV_RETRY          9\n#define SQLITE_FCNTL_PERSIST_WAL            10\n#define SQLITE_FCNTL_OVERWRITE              11\n#define SQLITE_FCNTL_VFSNAME                12\n#define SQLITE_FCNTL_POWERSAFE_OVERWRITE    13\n#define SQLITE_FCNTL_PRAGMA                 14\n#define SQLITE_FCNTL_BUSYHANDLER            15\n#define SQLITE_FCNTL_TEMPFILENAME           16\n#define SQLITE_FCNTL_MMAP_SIZE              18\n#define SQLITE_FCNTL_TRACE                  19\n#define SQLITE_FCNTL_HAS_MOVED              20\n#define SQLITE_FCNTL_SYNC                   21\n#define SQLITE_FCNTL_COMMIT_PHASETWO        22\n#define SQLITE_FCNTL_WIN32_SET_HANDLE       23\n#define SQLITE_FCNTL_WAL_BLOCK              24\n#define SQLITE_FCNTL_ZIPVFS                 25\n#define SQLITE_FCNTL_RBU                    26\n#define SQLITE_FCNTL_VFS_POINTER            27\n#define SQLITE_FCNTL_JOURNAL_POINTER        28\n#define SQLITE_FCNTL_WIN32_GET_HANDLE       29\n#define SQLITE_FCNTL_PDB                    30\n#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31\n#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32\n#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33\n\n/* deprecated names */\n#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE\n#define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE\n#define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO\n\n\n/*\n** CAPI3REF: Mutex Handle\n**\n** The mutex module within SQLite defines [sqlite3_mutex] to be an\n** abstract type for a mutex object.  The SQLite core never looks\n** at the internal representation of an [sqlite3_mutex].  It only\n** deals with pointers to the [sqlite3_mutex] object.\n**\n** Mutexes are created using [sqlite3_mutex_alloc()].\n*/\ntypedef struct sqlite3_mutex sqlite3_mutex;\n\n/*\n** CAPI3REF: Loadable Extension Thunk\n**\n** A pointer to the opaque sqlite3_api_routines structure is passed as\n** the third parameter to entry points of [loadable extensions].  This\n** structure must be typedefed in order to work around compiler warnings\n** on some platforms.\n*/\ntypedef struct sqlite3_api_routines sqlite3_api_routines;\n\n/*\n** CAPI3REF: OS Interface Object\n**\n** An instance of the sqlite3_vfs object defines the interface between\n** the SQLite core and the underlying operating system.  The \"vfs\"\n** in the name of the object stands for \"virtual file system\".  See\n** the [VFS | VFS documentation] for further information.\n**\n** The value of the iVersion field is initially 1 but may be larger in\n** future versions of SQLite.  Additional fields may be appended to this\n** object when the iVersion value is increased.  Note that the structure\n** of the sqlite3_vfs object changes in the transaction between\n** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not\n** modified.\n**\n** The szOsFile field is the size of the subclassed [sqlite3_file]\n** structure used by this VFS.  mxPathname is the maximum length of\n** a pathname in this VFS.\n**\n** Registered sqlite3_vfs objects are kept on a linked list formed by\n** the pNext pointer.  The [sqlite3_vfs_register()]\n** and [sqlite3_vfs_unregister()] interfaces manage this list\n** in a thread-safe way.  The [sqlite3_vfs_find()] interface\n** searches the list.  Neither the application code nor the VFS\n** implementation should use the pNext pointer.\n**\n** The pNext field is the only field in the sqlite3_vfs\n** structure that SQLite will ever modify.  SQLite will only access\n** or modify this field while holding a particular static mutex.\n** The application should never modify anything within the sqlite3_vfs\n** object once the object has been registered.\n**\n** The zName field holds the name of the VFS module.  The name must\n** be unique across all VFS modules.\n**\n** [[sqlite3_vfs.xOpen]]\n** ^SQLite guarantees that the zFilename parameter to xOpen\n** is either a NULL pointer or string obtained\n** from xFullPathname() with an optional suffix added.\n** ^If a suffix is added to the zFilename parameter, it will\n** consist of a single \"-\" character followed by no more than\n** 11 alphanumeric and/or \"-\" characters.\n** ^SQLite further guarantees that\n** the string will be valid and unchanged until xClose() is\n** called. Because of the previous sentence,\n** the [sqlite3_file] can safely store a pointer to the\n** filename if it needs to remember the filename for some reason.\n** If the zFilename parameter to xOpen is a NULL pointer then xOpen\n** must invent its own temporary name for the file.  ^Whenever the \n** xFilename parameter is NULL it will also be the case that the\n** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE].\n**\n** The flags argument to xOpen() includes all bits set in\n** the flags argument to [sqlite3_open_v2()].  Or if [sqlite3_open()]\n** or [sqlite3_open16()] is used, then flags includes at least\n** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. \n** If xOpen() opens a file read-only then it sets *pOutFlags to\n** include [SQLITE_OPEN_READONLY].  Other bits in *pOutFlags may be set.\n**\n** ^(SQLite will also add one of the following flags to the xOpen()\n** call, depending on the object being opened:\n**\n** <ul>\n** <li>  [SQLITE_OPEN_MAIN_DB]\n** <li>  [SQLITE_OPEN_MAIN_JOURNAL]\n** <li>  [SQLITE_OPEN_TEMP_DB]\n** <li>  [SQLITE_OPEN_TEMP_JOURNAL]\n** <li>  [SQLITE_OPEN_TRANSIENT_DB]\n** <li>  [SQLITE_OPEN_SUBJOURNAL]\n** <li>  [SQLITE_OPEN_MASTER_JOURNAL]\n** <li>  [SQLITE_OPEN_WAL]\n** </ul>)^\n**\n** The file I/O implementation can use the object type flags to\n** change the way it deals with files.  For example, an application\n** that does not care about crash recovery or rollback might make\n** the open of a journal file a no-op.  Writes to this journal would\n** also be no-ops, and any attempt to read the journal would return\n** SQLITE_IOERR.  Or the implementation might recognize that a database\n** file will be doing page-aligned sector reads and writes in a random\n** order and set up its I/O subsystem accordingly.\n**\n** SQLite might also add one of the following flags to the xOpen method:\n**\n** <ul>\n** <li> [SQLITE_OPEN_DELETEONCLOSE]\n** <li> [SQLITE_OPEN_EXCLUSIVE]\n** </ul>\n**\n** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be\n** deleted when it is closed.  ^The [SQLITE_OPEN_DELETEONCLOSE]\n** will be set for TEMP databases and their journals, transient\n** databases, and subjournals.\n**\n** ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction\n** with the [SQLITE_OPEN_CREATE] flag, which are both directly\n** analogous to the O_EXCL and O_CREAT flags of the POSIX open()\n** API.  The SQLITE_OPEN_EXCLUSIVE flag, when paired with the \n** SQLITE_OPEN_CREATE, is used to indicate that file should always\n** be created, and that it is an error if it already exists.\n** It is <i>not</i> used to indicate the file should be opened \n** for exclusive access.\n**\n** ^At least szOsFile bytes of memory are allocated by SQLite\n** to hold the  [sqlite3_file] structure passed as the third\n** argument to xOpen.  The xOpen method does not have to\n** allocate the structure; it should just fill it in.  Note that\n** the xOpen method must set the sqlite3_file.pMethods to either\n** a valid [sqlite3_io_methods] object or to NULL.  xOpen must do\n** this even if the open fails.  SQLite expects that the sqlite3_file.pMethods\n** element will be valid after xOpen returns regardless of the success\n** or failure of the xOpen call.\n**\n** [[sqlite3_vfs.xAccess]]\n** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]\n** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to\n** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]\n** to test whether a file is at least readable.   The file can be a\n** directory.\n**\n** ^SQLite will always allocate at least mxPathname+1 bytes for the\n** output buffer xFullPathname.  The exact size of the output buffer\n** is also passed as a parameter to both  methods. If the output buffer\n** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is\n** handled as a fatal error by SQLite, vfs implementations should endeavor\n** to prevent this by setting mxPathname to a sufficiently large value.\n**\n** The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64()\n** interfaces are not strictly a part of the filesystem, but they are\n** included in the VFS structure for completeness.\n** The xRandomness() function attempts to return nBytes bytes\n** of good-quality randomness into zOut.  The return value is\n** the actual number of bytes of randomness obtained.\n** The xSleep() method causes the calling thread to sleep for at\n** least the number of microseconds given.  ^The xCurrentTime()\n** method returns a Julian Day Number for the current date and time as\n** a floating point value.\n** ^The xCurrentTimeInt64() method returns, as an integer, the Julian\n** Day Number multiplied by 86400000 (the number of milliseconds in \n** a 24-hour day).  \n** ^SQLite will use the xCurrentTimeInt64() method to get the current\n** date and time if that method is available (if iVersion is 2 or \n** greater and the function pointer is not NULL) and will fall back\n** to xCurrentTime() if xCurrentTimeInt64() is unavailable.\n**\n** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces\n** are not used by the SQLite core.  These optional interfaces are provided\n** by some VFSes to facilitate testing of the VFS code. By overriding \n** system calls with functions under its control, a test program can\n** simulate faults and error conditions that would otherwise be difficult\n** or impossible to induce.  The set of system calls that can be overridden\n** varies from one VFS to another, and from one version of the same VFS to the\n** next.  Applications that use these interfaces must be prepared for any\n** or all of these interfaces to be NULL or for their behavior to change\n** from one release to the next.  Applications must not attempt to access\n** any of these methods if the iVersion of the VFS is less than 3.\n*/\ntypedef struct sqlite3_vfs sqlite3_vfs;\ntypedef void (*sqlite3_syscall_ptr)(void);\nstruct sqlite3_vfs {\n  int iVersion;            /* Structure version number (currently 3) */\n  int szOsFile;            /* Size of subclassed sqlite3_file */\n  int mxPathname;          /* Maximum file pathname length */\n  sqlite3_vfs *pNext;      /* Next registered VFS */\n  const char *zName;       /* Name of this virtual file system */\n  void *pAppData;          /* Pointer to application-specific data */\n  int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,\n               int flags, int *pOutFlags);\n  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);\n  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);\n  int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);\n  void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);\n  void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);\n  void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);\n  void (*xDlClose)(sqlite3_vfs*, void*);\n  int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);\n  int (*xSleep)(sqlite3_vfs*, int microseconds);\n  int (*xCurrentTime)(sqlite3_vfs*, double*);\n  int (*xGetLastError)(sqlite3_vfs*, int, char *);\n  /*\n  ** The methods above are in version 1 of the sqlite_vfs object\n  ** definition.  Those that follow are added in version 2 or later\n  */\n  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);\n  /*\n  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.\n  ** Those below are for version 3 and greater.\n  */\n  int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);\n  sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);\n  const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);\n  /*\n  ** The methods above are in versions 1 through 3 of the sqlite_vfs object.\n  ** New fields may be appended in future versions.  The iVersion\n  ** value will increment whenever this happens. \n  */\n};\n\n/*\n** CAPI3REF: Flags for the xAccess VFS method\n**\n** These integer constants can be used as the third parameter to\n** the xAccess method of an [sqlite3_vfs] object.  They determine\n** what kind of permissions the xAccess method is looking for.\n** With SQLITE_ACCESS_EXISTS, the xAccess method\n** simply checks whether the file exists.\n** With SQLITE_ACCESS_READWRITE, the xAccess method\n** checks whether the named directory is both readable and writable\n** (in other words, if files can be added, removed, and renamed within\n** the directory).\n** The SQLITE_ACCESS_READWRITE constant is currently used only by the\n** [temp_store_directory pragma], though this could change in a future\n** release of SQLite.\n** With SQLITE_ACCESS_READ, the xAccess method\n** checks whether the file is readable.  The SQLITE_ACCESS_READ constant is\n** currently unused, though it might be used in a future release of\n** SQLite.\n*/\n#define SQLITE_ACCESS_EXISTS    0\n#define SQLITE_ACCESS_READWRITE 1   /* Used by PRAGMA temp_store_directory */\n#define SQLITE_ACCESS_READ      2   /* Unused */\n\n/*\n** CAPI3REF: Flags for the xShmLock VFS method\n**\n** These integer constants define the various locking operations\n** allowed by the xShmLock method of [sqlite3_io_methods].  The\n** following are the only legal combinations of flags to the\n** xShmLock method:\n**\n** <ul>\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED\n** <li>  SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE\n** </ul>\n**\n** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as\n** was given on the corresponding lock.  \n**\n** The xShmLock method can transition between unlocked and SHARED or\n** between unlocked and EXCLUSIVE.  It cannot transition between SHARED\n** and EXCLUSIVE.\n*/\n#define SQLITE_SHM_UNLOCK       1\n#define SQLITE_SHM_LOCK         2\n#define SQLITE_SHM_SHARED       4\n#define SQLITE_SHM_EXCLUSIVE    8\n\n/*\n** CAPI3REF: Maximum xShmLock index\n**\n** The xShmLock method on [sqlite3_io_methods] may use values\n** between 0 and this upper bound as its \"offset\" argument.\n** The SQLite core will never attempt to acquire or release a\n** lock outside of this range\n*/\n#define SQLITE_SHM_NLOCK        8\n\n\n/*\n** CAPI3REF: Initialize The SQLite Library\n**\n** ^The sqlite3_initialize() routine initializes the\n** SQLite library.  ^The sqlite3_shutdown() routine\n** deallocates any resources that were allocated by sqlite3_initialize().\n** These routines are designed to aid in process initialization and\n** shutdown on embedded systems.  Workstation applications using\n** SQLite normally do not need to invoke either of these routines.\n**\n** A call to sqlite3_initialize() is an \"effective\" call if it is\n** the first time sqlite3_initialize() is invoked during the lifetime of\n** the process, or if it is the first time sqlite3_initialize() is invoked\n** following a call to sqlite3_shutdown().  ^(Only an effective call\n** of sqlite3_initialize() does any initialization.  All other calls\n** are harmless no-ops.)^\n**\n** A call to sqlite3_shutdown() is an \"effective\" call if it is the first\n** call to sqlite3_shutdown() since the last sqlite3_initialize().  ^(Only\n** an effective call to sqlite3_shutdown() does any deinitialization.\n** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^\n**\n** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()\n** is not.  The sqlite3_shutdown() interface must only be called from a\n** single thread.  All open [database connections] must be closed and all\n** other SQLite resources must be deallocated prior to invoking\n** sqlite3_shutdown().\n**\n** Among other things, ^sqlite3_initialize() will invoke\n** sqlite3_os_init().  Similarly, ^sqlite3_shutdown()\n** will invoke sqlite3_os_end().\n**\n** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.\n** ^If for some reason, sqlite3_initialize() is unable to initialize\n** the library (perhaps it is unable to allocate a needed resource such\n** as a mutex) it returns an [error code] other than [SQLITE_OK].\n**\n** ^The sqlite3_initialize() routine is called internally by many other\n** SQLite interfaces so that an application usually does not need to\n** invoke sqlite3_initialize() directly.  For example, [sqlite3_open()]\n** calls sqlite3_initialize() so the SQLite library will be automatically\n** initialized when [sqlite3_open()] is called if it has not be initialized\n** already.  ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]\n** compile-time option, then the automatic calls to sqlite3_initialize()\n** are omitted and the application must call sqlite3_initialize() directly\n** prior to using any other SQLite interface.  For maximum portability,\n** it is recommended that applications always invoke sqlite3_initialize()\n** directly prior to using any other SQLite interface.  Future releases\n** of SQLite may require this.  In other words, the behavior exhibited\n** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the\n** default behavior in some future release of SQLite.\n**\n** The sqlite3_os_init() routine does operating-system specific\n** initialization of the SQLite library.  The sqlite3_os_end()\n** routine undoes the effect of sqlite3_os_init().  Typical tasks\n** performed by these routines include allocation or deallocation\n** of static resources, initialization of global variables,\n** setting up a default [sqlite3_vfs] module, or setting up\n** a default configuration using [sqlite3_config()].\n**\n** The application should never invoke either sqlite3_os_init()\n** or sqlite3_os_end() directly.  The application should only invoke\n** sqlite3_initialize() and sqlite3_shutdown().  The sqlite3_os_init()\n** interface is called automatically by sqlite3_initialize() and\n** sqlite3_os_end() is called by sqlite3_shutdown().  Appropriate\n** implementations for sqlite3_os_init() and sqlite3_os_end()\n** are built into SQLite when it is compiled for Unix, Windows, or OS/2.\n** When [custom builds | built for other platforms]\n** (using the [SQLITE_OS_OTHER=1] compile-time\n** option) the application must supply a suitable implementation for\n** sqlite3_os_init() and sqlite3_os_end().  An application-supplied\n** implementation of sqlite3_os_init() or sqlite3_os_end()\n** must return [SQLITE_OK] on success and some other [error code] upon\n** failure.\n*/\nint sqlite3_initialize(void);\nint sqlite3_shutdown(void);\nint sqlite3_os_init(void);\nint sqlite3_os_end(void);\n\n/*\n** CAPI3REF: Configuring The SQLite Library\n**\n** The sqlite3_config() interface is used to make global configuration\n** changes to SQLite in order to tune SQLite to the specific needs of\n** the application.  The default configuration is recommended for most\n** applications and so this routine is usually not necessary.  It is\n** provided to support rare applications with unusual needs.\n**\n** <b>The sqlite3_config() interface is not threadsafe. The application\n** must ensure that no other SQLite interfaces are invoked by other\n** threads while sqlite3_config() is running.</b>\n**\n** The sqlite3_config() interface\n** may only be invoked prior to library initialization using\n** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].\n** ^If sqlite3_config() is called after [sqlite3_initialize()] and before\n** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.\n** Note, however, that ^sqlite3_config() can be called as part of the\n** implementation of an application-defined [sqlite3_os_init()].\n**\n** The first argument to sqlite3_config() is an integer\n** [configuration option] that determines\n** what property of SQLite is to be configured.  Subsequent arguments\n** vary depending on the [configuration option]\n** in the first argument.\n**\n** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].\n** ^If the option is unknown or SQLite is unable to set the option\n** then this routine returns a non-zero [error code].\n*/\nint sqlite3_config(int, ...);\n\n/*\n** CAPI3REF: Configure database connections\n** METHOD: sqlite3\n**\n** The sqlite3_db_config() interface is used to make configuration\n** changes to a [database connection].  The interface is similar to\n** [sqlite3_config()] except that the changes apply to a single\n** [database connection] (specified in the first argument).\n**\n** The second argument to sqlite3_db_config(D,V,...)  is the\n** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code \n** that indicates what aspect of the [database connection] is being configured.\n** Subsequent arguments vary depending on the configuration verb.\n**\n** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if\n** the call is considered successful.\n*/\nint sqlite3_db_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Memory Allocation Routines\n**\n** An instance of this object defines the interface between SQLite\n** and low-level memory allocation routines.\n**\n** This object is used in only one place in the SQLite interface.\n** A pointer to an instance of this object is the argument to\n** [sqlite3_config()] when the configuration option is\n** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC].  \n** By creating an instance of this object\n** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])\n** during configuration, an application can specify an alternative\n** memory allocation subsystem for SQLite to use for all of its\n** dynamic memory needs.\n**\n** Note that SQLite comes with several [built-in memory allocators]\n** that are perfectly adequate for the overwhelming majority of applications\n** and that this object is only useful to a tiny minority of applications\n** with specialized memory allocation requirements.  This object is\n** also used during testing of SQLite in order to specify an alternative\n** memory allocator that simulates memory out-of-memory conditions in\n** order to verify that SQLite recovers gracefully from such\n** conditions.\n**\n** The xMalloc, xRealloc, and xFree methods must work like the\n** malloc(), realloc() and free() functions from the standard C library.\n** ^SQLite guarantees that the second argument to\n** xRealloc is always a value returned by a prior call to xRoundup.\n**\n** xSize should return the allocated size of a memory allocation\n** previously obtained from xMalloc or xRealloc.  The allocated size\n** is always at least as big as the requested size but may be larger.\n**\n** The xRoundup method returns what would be the allocated size of\n** a memory allocation given a particular requested size.  Most memory\n** allocators round up memory allocations at least to the next multiple\n** of 8.  Some allocators round up to a larger multiple or to a power of 2.\n** Every memory allocation request coming in through [sqlite3_malloc()]\n** or [sqlite3_realloc()] first calls xRoundup.  If xRoundup returns 0, \n** that causes the corresponding memory allocation to fail.\n**\n** The xInit method initializes the memory allocator.  For example,\n** it might allocate any require mutexes or initialize internal data\n** structures.  The xShutdown method is invoked (indirectly) by\n** [sqlite3_shutdown()] and should deallocate any resources acquired\n** by xInit.  The pAppData pointer is used as the only parameter to\n** xInit and xShutdown.\n**\n** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes\n** the xInit method, so the xInit method need not be threadsafe.  The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  For all other methods, SQLite\n** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the\n** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which\n** it is by default) and so the methods are automatically serialized.\n** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other\n** methods must be threadsafe or else make their own arrangements for\n** serialization.\n**\n** SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n*/\ntypedef struct sqlite3_mem_methods sqlite3_mem_methods;\nstruct sqlite3_mem_methods {\n  void *(*xMalloc)(int);         /* Memory allocation function */\n  void (*xFree)(void*);          /* Free a prior allocation */\n  void *(*xRealloc)(void*,int);  /* Resize an allocation */\n  int (*xSize)(void*);           /* Return the size of an allocation */\n  int (*xRoundup)(int);          /* Round up request size to allocation size */\n  int (*xInit)(void*);           /* Initialize the memory allocator */\n  void (*xShutdown)(void*);      /* Deinitialize the memory allocator */\n  void *pAppData;                /* Argument to xInit() and xShutdown() */\n};\n\n/*\n** CAPI3REF: Configuration Options\n** KEYWORDS: {configuration option}\n**\n** These constants are the available integer configuration options that\n** can be passed as the first argument to the [sqlite3_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_config()] to make sure that\n** the call worked.  The [sqlite3_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Single-thread.  In other words, it disables\n** all mutexing and puts SQLite into a mode where it can only be used\n** by a single thread.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to change the [threading mode] from its default\n** value of Single-thread and so [sqlite3_config()] will return \n** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD\n** configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Multi-thread.  In other words, it disables\n** mutexing on [database connection] and [prepared statement] objects.\n** The application is responsible for serializing access to\n** [database connections] and [prepared statements].  But other mutexes\n** are enabled so that SQLite will be safe to use in a multi-threaded\n** environment as long as no two threads attempt to use the same\n** [database connection] at the same time.  ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Multi-thread [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>\n**\n** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>\n** <dd>There are no arguments to this option.  ^This option sets the\n** [threading mode] to Serialized. In other words, this option enables\n** all mutexes including the recursive\n** mutexes on [database connection] and [prepared statement] objects.\n** In this mode (which is the default when SQLite is compiled with\n** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access\n** to [database connections] and [prepared statements] so that the\n** application is free to use the same [database connection] or the\n** same [prepared statement] in different threads at the same time.\n** ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** it is not possible to set the Serialized [threading mode] and\n** [sqlite3_config()] will return [SQLITE_ERROR] if called with the\n** SQLITE_CONFIG_SERIALIZED configuration option.</dd>\n**\n** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is \n** a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The argument specifies\n** alternative low-level memory allocation routines to be used in place of\n** the memory allocation routines built into SQLite.)^ ^SQLite makes\n** its own private copy of the content of the [sqlite3_mem_methods] structure\n** before the [sqlite3_config()] call returns.</dd>\n**\n** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mem_methods] structure.\n** The [sqlite3_mem_methods]\n** structure is filled with the currently defined memory allocation routines.)^\n** This option can be used to overload the default memory allocation\n** routines with a wrapper that simulations memory allocation failure or\n** tracks memory usage, for example. </dd>\n**\n** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt>\n** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of\n** type int, interpreted as a boolean, which if true provides a hint to\n** SQLite that it should avoid large memory allocations if possible.\n** SQLite will run faster if it is free to make large memory allocations,\n** but some application might prefer to run slower in exchange for\n** guarantees about memory fragmentation that are possible if large\n** allocations are avoided.  This hint is normally off.\n** </dd>\n**\n** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>\n** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,\n** interpreted as a boolean, which enables or disables the collection of\n** memory allocation statistics. ^(When memory allocation statistics are\n** disabled, the following SQLite interfaces become non-operational:\n**   <ul>\n**   <li> [sqlite3_memory_used()]\n**   <li> [sqlite3_memory_highwater()]\n**   <li> [sqlite3_soft_heap_limit64()]\n**   <li> [sqlite3_status64()]\n**   </ul>)^\n** ^Memory allocation statistics are enabled by default unless SQLite is\n** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory\n** allocation statistics are disabled by default.\n** </dd>\n**\n** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>\n** <dd> The SQLITE_CONFIG_SCRATCH option is no longer used.\n** </dd>\n**\n** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>\n** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a memory pool\n** that SQLite can use for the database page cache with the default page\n** cache implementation.  \n** This configuration option is a no-op if an application-define page\n** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2].\n** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to\n** 8-byte aligned memory (pMem), the size of each page cache line (sz),\n** and the number of cache lines (N).\n** The sz argument should be the size of the largest database page\n** (a power of two between 512 and 65536) plus some extra bytes for each\n** page header.  ^The number of extra bytes needed by the page header\n** can be determined using [SQLITE_CONFIG_PCACHE_HDRSZ].\n** ^It is harmless, apart from the wasted memory,\n** for the sz parameter to be larger than necessary.  The pMem\n** argument must be either a NULL pointer or a pointer to an 8-byte\n** aligned block of memory of at least sz*N bytes, otherwise\n** subsequent behavior is undefined.\n** ^When pMem is not NULL, SQLite will strive to use the memory provided\n** to satisfy page cache needs, falling back to [sqlite3_malloc()] if\n** a page cache line is larger than sz bytes or if all of the pMem buffer\n** is exhausted.\n** ^If pMem is NULL and N is non-zero, then each database connection\n** does an initial bulk allocation for page cache memory\n** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or\n** of -1024*N bytes if N is negative, . ^If additional\n** page cache memory is needed beyond what is provided by the initial\n** allocation, then SQLite goes to [sqlite3_malloc()] separately for each\n** additional cache line. </dd>\n**\n** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>\n** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer \n** that SQLite will use for all of its dynamic memory allocation needs\n** beyond those provided for by [SQLITE_CONFIG_PAGECACHE].\n** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled\n** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns\n** [SQLITE_ERROR] if invoked otherwise.\n** ^There are three arguments to SQLITE_CONFIG_HEAP:\n** An 8-byte aligned pointer to the memory,\n** the number of bytes in the memory buffer, and the minimum allocation size.\n** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts\n** to using its default memory allocator (the system malloc() implementation),\n** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  ^If the\n** memory pointer is not NULL then the alternative memory\n** allocator is engaged to handle all of SQLites memory allocation needs.\n** The first pointer (the memory pointer) must be aligned to an 8-byte\n** boundary or subsequent behavior of SQLite will be undefined.\n** The minimum allocation size is capped at 2**12. Reasonable values\n** for the minimum allocation size are 2**5 through 2**8.</dd>\n**\n** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a\n** pointer to an instance of the [sqlite3_mutex_methods] structure.\n** The argument specifies alternative low-level mutex routines to be used\n** in place the mutex routines built into SQLite.)^  ^SQLite makes a copy of\n** the content of the [sqlite3_mutex_methods] structure before the call to\n** [sqlite3_config()] returns. ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>\n** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which\n** is a pointer to an instance of the [sqlite3_mutex_methods] structure.  The\n** [sqlite3_mutex_methods]\n** structure is filled with the currently defined mutex routines.)^\n** This option can be used to overload the default mutex allocation\n** routines with a wrapper used to track mutex usage for performance\n** profiling or testing, for example.   ^If SQLite is compiled with\n** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then\n** the entire mutexing subsystem is omitted from the build and hence calls to\n** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will\n** return [SQLITE_ERROR].</dd>\n**\n** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>\n** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine\n** the default size of lookaside memory on each [database connection].\n** The first argument is the\n** size of each lookaside buffer slot and the second is the number of\n** slots allocated to each database connection.)^  ^(SQLITE_CONFIG_LOOKASIDE\n** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]\n** option to [sqlite3_db_config()] can be used to change the lookaside\n** configuration on individual connections.)^ </dd>\n**\n** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is \n** a pointer to an [sqlite3_pcache_methods2] object.  This object specifies\n** the interface to a custom page cache implementation.)^\n** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>\n**\n** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>\n** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which\n** is a pointer to an [sqlite3_pcache_methods2] object.  SQLite copies of\n** the current page cache implementation into that object.)^ </dd>\n**\n** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>\n** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite\n** global [error log].\n** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a\n** function with a call signature of void(*)(void*,int,const char*), \n** and a pointer to void. ^If the function pointer is not NULL, it is\n** invoked by [sqlite3_log()] to process each logging event.  ^If the\n** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.\n** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is\n** passed through as the first parameter to the application-defined logger\n** function whenever that function is invoked.  ^The second parameter to\n** the logger function is a copy of the first parameter to the corresponding\n** [sqlite3_log()] call and is intended to be a [result code] or an\n** [extended result code].  ^The third parameter passed to the logger is\n** log message after formatting via [sqlite3_snprintf()].\n** The SQLite logging interface is not reentrant; the logger function\n** supplied by the application must not invoke any SQLite interface.\n** In a multi-threaded application, the application-defined logger\n** function must be threadsafe. </dd>\n**\n** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI\n** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.\n** If non-zero, then URI handling is globally enabled. If the parameter is zero,\n** then URI handling is globally disabled.)^ ^If URI handling is globally\n** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],\n** [sqlite3_open16()] or\n** specified as part of [ATTACH] commands are interpreted as URIs, regardless\n** of whether or not the [SQLITE_OPEN_URI] flag is set when the database\n** connection is opened. ^If it is globally disabled, filenames are\n** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the\n** database connection is opened. ^(By default, URI handling is globally\n** disabled. The default value may be changed by compiling with the\n** [SQLITE_USE_URI] symbol defined.)^\n**\n** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN\n** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer\n** argument which is interpreted as a boolean in order to enable or disable\n** the use of covering indices for full table scans in the query optimizer.\n** ^The default setting is determined\n** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is \"on\"\n** if that compile-time option is omitted.\n** The ability to disable the use of covering indices for full table scans\n** is because some incorrectly coded legacy applications might malfunction\n** when the optimization is enabled.  Providing the ability to\n** disable the optimization allows the older, buggy application code to work\n** without change even with newer versions of SQLite.\n**\n** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]\n** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE\n** <dd> These options are obsolete and should not be used by new code.\n** They are retained for backwards compatibility but are now no-ops.\n** </dd>\n**\n** [[SQLITE_CONFIG_SQLLOG]]\n** <dt>SQLITE_CONFIG_SQLLOG\n** <dd>This option is only available if sqlite is compiled with the\n** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should\n** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).\n** The second should be of type (void*). The callback is invoked by the library\n** in three separate circumstances, identified by the value passed as the\n** fourth parameter. If the fourth parameter is 0, then the database connection\n** passed as the second argument has just been opened. The third argument\n** points to a buffer containing the name of the main database file. If the\n** fourth parameter is 1, then the SQL statement that the third parameter\n** points to has just been executed. Or, if the fourth parameter is 2, then\n** the connection being passed as the second parameter is being closed. The\n** third parameter is passed NULL In this case.  An example of using this\n** configuration option can be seen in the \"test_sqllog.c\" source file in\n** the canonical SQLite source tree.</dd>\n**\n** [[SQLITE_CONFIG_MMAP_SIZE]]\n** <dt>SQLITE_CONFIG_MMAP_SIZE\n** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values\n** that are the default mmap size limit (the default setting for\n** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.\n** ^The default setting can be overridden by each database connection using\n** either the [PRAGMA mmap_size] command, or by using the\n** [SQLITE_FCNTL_MMAP_SIZE] file control.  ^(The maximum allowed mmap size\n** will be silently truncated if necessary so that it does not exceed the\n** compile-time maximum mmap size set by the\n** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^\n** ^If either argument to this option is negative, then that argument is\n** changed to its compile-time default.\n**\n** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]\n** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE\n** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is\n** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro\n** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value\n** that specifies the maximum size of the created heap.\n**\n** [[SQLITE_CONFIG_PCACHE_HDRSZ]]\n** <dt>SQLITE_CONFIG_PCACHE_HDRSZ\n** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which\n** is a pointer to an integer and writes into that integer the number of extra\n** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].\n** The amount of extra space required can change depending on the compiler,\n** target platform, and SQLite version.\n**\n** [[SQLITE_CONFIG_PMASZ]]\n** <dt>SQLITE_CONFIG_PMASZ\n** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which\n** is an unsigned integer and sets the \"Minimum PMA Size\" for the multithreaded\n** sorter to that integer.  The default minimum PMA Size is set by the\n** [SQLITE_SORTER_PMASZ] compile-time option.  New threads are launched\n** to help with sort operations when multithreaded sorting\n** is enabled (using the [PRAGMA threads] command) and the amount of content\n** to be sorted exceeds the page size times the minimum of the\n** [PRAGMA cache_size] setting and this value.\n**\n** [[SQLITE_CONFIG_STMTJRNL_SPILL]]\n** <dt>SQLITE_CONFIG_STMTJRNL_SPILL\n** <dd>^The SQLITE_CONFIG_STMTJRNL_SPILL option takes a single parameter which\n** becomes the [statement journal] spill-to-disk threshold.  \n** [Statement journals] are held in memory until their size (in bytes)\n** exceeds this threshold, at which point they are written to disk.\n** Or if the threshold is -1, statement journals are always held\n** exclusively in memory.\n** Since many statement journals never become large, setting the spill\n** threshold to a value such as 64KiB can greatly reduce the amount of\n** I/O required to support statement rollback.\n** The default value for this setting is controlled by the\n** [SQLITE_STMTJRNL_SPILL] compile-time option.\n** </dl>\n*/\n#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */\n#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */\n#define SQLITE_CONFIG_SERIALIZED    3  /* nil */\n#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */\n#define SQLITE_CONFIG_SCRATCH       6  /* No longer used */\n#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */\n#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */\n#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */\n#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */\n#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */\n/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ \n#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */\n#define SQLITE_CONFIG_PCACHE       14  /* no-op */\n#define SQLITE_CONFIG_GETPCACHE    15  /* no-op */\n#define SQLITE_CONFIG_LOG          16  /* xFunc, void* */\n#define SQLITE_CONFIG_URI          17  /* int */\n#define SQLITE_CONFIG_PCACHE2      18  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_GETPCACHE2   19  /* sqlite3_pcache_methods2* */\n#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20  /* int */\n#define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */\n#define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */\n#define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */\n#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */\n#define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */\n#define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */\n#define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */\n\n/*\n** CAPI3REF: Database Connection Configuration Options\n**\n** These constants are the available integer configuration options that\n** can be passed as the second argument to the [sqlite3_db_config()] interface.\n**\n** New configuration options may be added in future releases of SQLite.\n** Existing configuration options might be discontinued.  Applications\n** should check the return code from [sqlite3_db_config()] to make sure that\n** the call worked.  ^The [sqlite3_db_config()] interface will return a\n** non-zero [error code] if a discontinued or unsupported configuration option\n** is invoked.\n**\n** <dl>\n** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>\n** <dd> ^This option takes three additional arguments that determine the \n** [lookaside memory allocator] configuration for the [database connection].\n** ^The first argument (the third parameter to [sqlite3_db_config()] is a\n** pointer to a memory buffer to use for lookaside memory.\n** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb\n** may be NULL in which case SQLite will allocate the\n** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the\n** size of each lookaside buffer slot.  ^The third argument is the number of\n** slots.  The size of the buffer in the first argument must be greater than\n** or equal to the product of the second and third arguments.  The buffer\n** must be aligned to an 8-byte boundary.  ^If the second argument to\n** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally\n** rounded down to the next smaller multiple of 8.  ^(The lookaside memory\n** configuration for a database connection can only be changed when that\n** connection is not currently using lookaside memory, or in other words\n** when the \"current value\" returned by\n** [sqlite3_db_status](D,[SQLITE_CONFIG_LOOKASIDE],...) is zero.\n** Any attempt to change the lookaside memory configuration when lookaside\n** memory is in use leaves the configuration unchanged and returns \n** [SQLITE_BUSY].)^</dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>\n** <dd> ^This option is used to enable or disable the enforcement of\n** [foreign key constraints].  There should be two additional arguments.\n** The first argument is an integer which is 0 to disable FK enforcement,\n** positive to enable FK enforcement or negative to leave FK enforcement\n** unchanged.  The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether FK enforcement is off or on\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the FK enforcement setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>\n** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable triggers,\n** positive to enable triggers or negative to leave the setting unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether triggers are disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the trigger setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>\n** <dd> ^This option is used to enable or disable the two-argument\n** version of the [fts3_tokenizer()] function which is part of the\n** [FTS3] full-text search engine extension.\n** There should be two additional arguments.\n** The first argument is an integer which is 0 to disable fts3_tokenizer() or\n** positive to enable fts3_tokenizer() or negative to leave the setting\n** unchanged.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled\n** following this call.  The second parameter may be a NULL pointer, in\n** which case the new setting is not reported back. </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>\n** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]\n** interface independently of the [load_extension()] SQL function.\n** The [sqlite3_enable_load_extension()] API enables or disables both the\n** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].\n** There should be two additional arguments.\n** When the first argument to this interface is 1, then only the C-API is\n** enabled and the SQL function remains disabled.  If the first argument to\n** this interface is 0, then both the C-API and the SQL function are disabled.\n** If the first argument is -1, then no changes are made to state of either the\n** C-API or the SQL function.\n** The second parameter is a pointer to an integer into which\n** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface\n** is disabled or enabled following this call.  The second parameter may\n** be a NULL pointer, in which case the new setting is not reported back.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>\n** <dd> ^This option is used to change the name of the \"main\" database\n** schema.  ^The sole argument is a pointer to a constant UTF8 string\n** which will become the new schema name in place of \"main\".  ^SQLite\n** does not make a copy of the new main schema name string, so the application\n** must ensure that the argument passed into this DBCONFIG option is unchanged\n** until after the database connection closes.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>\n** <dd> Usually, when a database in wal mode is closed or detached from a \n** database handle, SQLite checks if this will mean that there are now no \n** connections at all to the database. If so, it performs a checkpoint \n** operation before closing the connection. This option may be used to\n** override this behaviour. The first parameter passed to this operation\n** is an integer - non-zero to disable checkpoints-on-close, or zero (the\n** default) to enable them. The second parameter is a pointer to an integer\n** into which is written 0 or 1 to indicate whether checkpoints-on-close\n** have been disabled - 0 if they are not disabled, 1 if they are.\n** </dd>\n**\n** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>\n** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates\n** the [query planner stability guarantee] (QPSG).  When the QPSG is active,\n** a single SQL query statement will always use the same algorithm regardless\n** of values of [bound parameters].)^ The QPSG disables some query optimizations\n** that look at the values of bound parameters, which can make some queries\n** slower.  But the QPSG has the advantage of more predictable behavior.  With\n** the QPSG active, SQLite will always use the same query plan in the field as\n** was used during testing in the lab.\n** </dd>\n**\n** </dl>\n*/\n#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */\n#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */\n#define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */\n#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE      1006 /* int int* */\n#define SQLITE_DBCONFIG_ENABLE_QPSG           1007 /* int int* */\n\n\n/*\n** CAPI3REF: Enable Or Disable Extended Result Codes\n** METHOD: sqlite3\n**\n** ^The sqlite3_extended_result_codes() routine enables or disables the\n** [extended result codes] feature of SQLite. ^The extended result\n** codes are disabled by default for historical compatibility.\n*/\nint sqlite3_extended_result_codes(sqlite3*, int onoff);\n\n/*\n** CAPI3REF: Last Insert Rowid\n** METHOD: sqlite3\n**\n** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)\n** has a unique 64-bit signed\n** integer key called the [ROWID | \"rowid\"]. ^The rowid is always available\n** as an undeclared column named ROWID, OID, or _ROWID_ as long as those\n** names are not also used by explicitly declared columns. ^If\n** the table has a column of type [INTEGER PRIMARY KEY] then that column\n** is another alias for the rowid.\n**\n** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of\n** the most recent successful [INSERT] into a rowid table or [virtual table]\n** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not\n** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred \n** on the database connection D, then sqlite3_last_insert_rowid(D) returns \n** zero.\n**\n** As well as being set automatically as rows are inserted into database\n** tables, the value returned by this function may be set explicitly by\n** [sqlite3_set_last_insert_rowid()]\n**\n** Some virtual table implementations may INSERT rows into rowid tables as\n** part of committing a transaction (e.g. to flush data accumulated in memory\n** to disk). In this case subsequent calls to this function return the rowid\n** associated with these internal INSERT operations, which leads to \n** unintuitive results. Virtual table implementations that do write to rowid\n** tables in this way can avoid this problem by restoring the original \n** rowid value using [sqlite3_set_last_insert_rowid()] before returning \n** control to the user.\n**\n** ^(If an [INSERT] occurs within a trigger then this routine will \n** return the [rowid] of the inserted row as long as the trigger is \n** running. Once the trigger program ends, the value returned \n** by this routine reverts to what it was before the trigger was fired.)^\n**\n** ^An [INSERT] that fails due to a constraint violation is not a\n** successful [INSERT] and does not change the value returned by this\n** routine.  ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,\n** and INSERT OR ABORT make no changes to the return value of this\n** routine when their insertion fails.  ^(When INSERT OR REPLACE\n** encounters a constraint violation, it does not fail.  The\n** INSERT continues to completion after deleting rows that caused\n** the constraint problem so INSERT OR REPLACE will always change\n** the return value of this interface.)^\n**\n** ^For the purposes of this routine, an [INSERT] is considered to\n** be successful even if it is subsequently rolled back.\n**\n** This function is accessible to SQL statements via the\n** [last_insert_rowid() SQL function].\n**\n** If a separate thread performs a new [INSERT] on the same\n** database connection while the [sqlite3_last_insert_rowid()]\n** function is running and thus changes the last insert [rowid],\n** then the value returned by [sqlite3_last_insert_rowid()] is\n** unpredictable and might not equal either the old or the new\n** last insert [rowid].\n*/\nsqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);\n\n/*\n** CAPI3REF: Set the Last Insert Rowid value.\n** METHOD: sqlite3\n**\n** The sqlite3_set_last_insert_rowid(D, R) method allows the application to\n** set the value returned by calling sqlite3_last_insert_rowid(D) to R \n** without inserting a row into the database.\n*/\nvoid sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);\n\n/*\n** CAPI3REF: Count The Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the number of rows modified, inserted or\n** deleted by the most recently completed INSERT, UPDATE or DELETE\n** statement on the database connection specified by the only parameter.\n** ^Executing any other type of SQL statement does not modify the value\n** returned by this function.\n**\n** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are\n** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], \n** [foreign key actions] or [REPLACE] constraint resolution are not counted.\n** \n** Changes to a view that are intercepted by \n** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value \n** returned by sqlite3_changes() immediately after an INSERT, UPDATE or \n** DELETE statement run on a view is always zero. Only changes made to real \n** tables are counted.\n**\n** Things are more complicated if the sqlite3_changes() function is\n** executed while a trigger program is running. This may happen if the\n** program uses the [changes() SQL function], or if some other callback\n** function invokes sqlite3_changes() directly. Essentially:\n** \n** <ul>\n**   <li> ^(Before entering a trigger program the value returned by\n**        sqlite3_changes() function is saved. After the trigger program \n**        has finished, the original value is restored.)^\n** \n**   <li> ^(Within a trigger program each INSERT, UPDATE and DELETE \n**        statement sets the value returned by sqlite3_changes() \n**        upon completion as normal. Of course, this value will not include \n**        any changes performed by sub-triggers, as the sqlite3_changes() \n**        value will be saved and restored after each sub-trigger has run.)^\n** </ul>\n** \n** ^This means that if the changes() SQL function (or similar) is used\n** by the first INSERT, UPDATE or DELETE statement within a trigger, it \n** returns the value as set when the calling statement began executing.\n** ^If it is used by the second or subsequent such statement within a trigger \n** program, the value returned reflects the number of rows modified by the \n** previous INSERT, UPDATE or DELETE statement within the same trigger.\n**\n** See also the [sqlite3_total_changes()] interface, the\n** [count_changes pragma], and the [changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_changes()] is running then the value returned\n** is unpredictable and not meaningful.\n*/\nint sqlite3_changes(sqlite3*);\n\n/*\n** CAPI3REF: Total Number Of Rows Modified\n** METHOD: sqlite3\n**\n** ^This function returns the total number of rows inserted, modified or\n** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed\n** since the database connection was opened, including those executed as\n** part of trigger programs. ^Executing any other type of SQL statement\n** does not affect the value returned by sqlite3_total_changes().\n** \n** ^Changes made as part of [foreign key actions] are included in the\n** count, but those made as part of REPLACE constraint resolution are\n** not. ^Changes to a view that are intercepted by INSTEAD OF triggers \n** are not counted.\n** \n** See also the [sqlite3_changes()] interface, the\n** [count_changes pragma], and the [total_changes() SQL function].\n**\n** If a separate thread makes changes on the same database connection\n** while [sqlite3_total_changes()] is running then the value\n** returned is unpredictable and not meaningful.\n*/\nint sqlite3_total_changes(sqlite3*);\n\n/*\n** CAPI3REF: Interrupt A Long-Running Query\n** METHOD: sqlite3\n**\n** ^This function causes any pending database operation to abort and\n** return at its earliest opportunity. This routine is typically\n** called in response to a user action such as pressing \"Cancel\"\n** or Ctrl-C where the user wants a long query operation to halt\n** immediately.\n**\n** ^It is safe to call this routine from a thread different from the\n** thread that is currently running the database operation.  But it\n** is not safe to call this routine with a [database connection] that\n** is closed or might close before sqlite3_interrupt() returns.\n**\n** ^If an SQL operation is very nearly finished at the time when\n** sqlite3_interrupt() is called, then it might not have an opportunity\n** to be interrupted and might continue to completion.\n**\n** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].\n** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE\n** that is inside an explicit transaction, then the entire transaction\n** will be rolled back automatically.\n**\n** ^The sqlite3_interrupt(D) call is in effect until all currently running\n** SQL statements on [database connection] D complete.  ^Any new SQL statements\n** that are started after the sqlite3_interrupt() call and before the \n** running statements reaches zero are interrupted as if they had been\n** running prior to the sqlite3_interrupt() call.  ^New SQL statements\n** that are started after the running statement count reaches zero are\n** not effected by the sqlite3_interrupt().\n** ^A call to sqlite3_interrupt(D) that occurs when there are no running\n** SQL statements is a no-op and has no effect on SQL statements\n** that are started after the sqlite3_interrupt() call returns.\n*/\nvoid sqlite3_interrupt(sqlite3*);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Is Complete\n**\n** These routines are useful during command-line input to determine if the\n** currently entered text seems to form a complete SQL statement or\n** if additional input is needed before sending the text into\n** SQLite for parsing.  ^These routines return 1 if the input string\n** appears to be a complete SQL statement.  ^A statement is judged to be\n** complete if it ends with a semicolon token and is not a prefix of a\n** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within\n** string literals or quoted identifier names or comments are not\n** independent tokens (they are part of the token in which they are\n** embedded) and thus do not count as a statement terminator.  ^Whitespace\n** and comments that follow the final semicolon are ignored.\n**\n** ^These routines return 0 if the statement is incomplete.  ^If a\n** memory allocation fails, then SQLITE_NOMEM is returned.\n**\n** ^These routines do not parse the SQL statements thus\n** will not detect syntactically incorrect SQL.\n**\n** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior \n** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked\n** automatically by sqlite3_complete16().  If that initialization fails,\n** then the return value from sqlite3_complete16() will be non-zero\n** regardless of whether or not the input SQL is complete.)^\n**\n** The input to [sqlite3_complete()] must be a zero-terminated\n** UTF-8 string.\n**\n** The input to [sqlite3_complete16()] must be a zero-terminated\n** UTF-16 string in native byte order.\n*/\nint sqlite3_complete(const char *sql);\nint sqlite3_complete16(const void *sql);\n\n/*\n** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors\n** KEYWORDS: {busy-handler callback} {busy handler}\n** METHOD: sqlite3\n**\n** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X\n** that might be invoked with argument P whenever\n** an attempt is made to access a database table associated with\n** [database connection] D when another thread\n** or process has the table locked.\n** The sqlite3_busy_handler() interface is used to implement\n** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout].\n**\n** ^If the busy callback is NULL, then [SQLITE_BUSY]\n** is returned immediately upon encountering the lock.  ^If the busy callback\n** is not NULL, then the callback might be invoked with two arguments.\n**\n** ^The first argument to the busy handler is a copy of the void* pointer which\n** is the third argument to sqlite3_busy_handler().  ^The second argument to\n** the busy handler callback is the number of times that the busy handler has\n** been invoked previously for the same locking event.  ^If the\n** busy callback returns 0, then no additional attempts are made to\n** access the database and [SQLITE_BUSY] is returned\n** to the application.\n** ^If the callback returns non-zero, then another attempt\n** is made to access the database and the cycle repeats.\n**\n** The presence of a busy handler does not guarantee that it will be invoked\n** when there is lock contention. ^If SQLite determines that invoking the busy\n** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]\n** to the application instead of invoking the \n** busy handler.\n** Consider a scenario where one process is holding a read lock that\n** it is trying to promote to a reserved lock and\n** a second process is holding a reserved lock that it is trying\n** to promote to an exclusive lock.  The first process cannot proceed\n** because it is blocked by the second and the second process cannot\n** proceed because it is blocked by the first.  If both processes\n** invoke the busy handlers, neither will make any progress.  Therefore,\n** SQLite returns [SQLITE_BUSY] for the first process, hoping that this\n** will induce the first process to release its read lock and allow\n** the second process to proceed.\n**\n** ^The default busy callback is NULL.\n**\n** ^(There can only be a single busy handler defined for each\n** [database connection].  Setting a new busy handler clears any\n** previously set handler.)^  ^Note that calling [sqlite3_busy_timeout()]\n** or evaluating [PRAGMA busy_timeout=N] will change the\n** busy handler and thus clear any previously set busy handler.\n**\n** The busy callback should not take any actions which modify the\n** database connection that invoked the busy handler.  In other words,\n** the busy handler is not reentrant.  Any such actions\n** result in undefined behavior.\n** \n** A busy handler must not close the database connection\n** or [prepared statement] that invoked the busy handler.\n*/\nint sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);\n\n/*\n** CAPI3REF: Set A Busy Timeout\n** METHOD: sqlite3\n**\n** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps\n** for a specified amount of time when a table is locked.  ^The handler\n** will sleep multiple times until at least \"ms\" milliseconds of sleeping\n** have accumulated.  ^After at least \"ms\" milliseconds of sleeping,\n** the handler returns 0 which causes [sqlite3_step()] to return\n** [SQLITE_BUSY].\n**\n** ^Calling this routine with an argument less than or equal to zero\n** turns off all busy handlers.\n**\n** ^(There can only be a single busy handler for a particular\n** [database connection] at any given moment.  If another busy handler\n** was defined  (using [sqlite3_busy_handler()]) prior to calling\n** this routine, that other busy handler is cleared.)^\n**\n** See also:  [PRAGMA busy_timeout]\n*/\nint sqlite3_busy_timeout(sqlite3*, int ms);\n\n/*\n** CAPI3REF: Convenience Routines For Running Queries\n** METHOD: sqlite3\n**\n** This is a legacy interface that is preserved for backwards compatibility.\n** Use of this interface is not recommended.\n**\n** Definition: A <b>result table</b> is memory data structure created by the\n** [sqlite3_get_table()] interface.  A result table records the\n** complete query results from one or more queries.\n**\n** The table conceptually has a number of rows and columns.  But\n** these numbers are not part of the result table itself.  These\n** numbers are obtained separately.  Let N be the number of rows\n** and M be the number of columns.\n**\n** A result table is an array of pointers to zero-terminated UTF-8 strings.\n** There are (N+1)*M elements in the array.  The first M pointers point\n** to zero-terminated strings that  contain the names of the columns.\n** The remaining entries all point to query results.  NULL values result\n** in NULL pointers.  All other values are in their UTF-8 zero-terminated\n** string representation as returned by [sqlite3_column_text()].\n**\n** A result table might consist of one or more memory allocations.\n** It is not safe to pass a result table directly to [sqlite3_free()].\n** A result table should be deallocated using [sqlite3_free_table()].\n**\n** ^(As an example of the result table format, suppose a query result\n** is as follows:\n**\n** <blockquote><pre>\n**        Name        | Age\n**        -----------------------\n**        Alice       | 43\n**        Bob         | 28\n**        Cindy       | 21\n** </pre></blockquote>\n**\n** There are two column (M==2) and three rows (N==3).  Thus the\n** result table has 8 entries.  Suppose the result table is stored\n** in an array names azResult.  Then azResult holds this content:\n**\n** <blockquote><pre>\n**        azResult&#91;0] = \"Name\";\n**        azResult&#91;1] = \"Age\";\n**        azResult&#91;2] = \"Alice\";\n**        azResult&#91;3] = \"43\";\n**        azResult&#91;4] = \"Bob\";\n**        azResult&#91;5] = \"28\";\n**        azResult&#91;6] = \"Cindy\";\n**        azResult&#91;7] = \"21\";\n** </pre></blockquote>)^\n**\n** ^The sqlite3_get_table() function evaluates one or more\n** semicolon-separated SQL statements in the zero-terminated UTF-8\n** string of its 2nd parameter and returns a result table to the\n** pointer given in its 3rd parameter.\n**\n** After the application has finished with the result from sqlite3_get_table(),\n** it must pass the result table pointer to sqlite3_free_table() in order to\n** release the memory that was malloced.  Because of the way the\n** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling\n** function must not try to call [sqlite3_free()] directly.  Only\n** [sqlite3_free_table()] is able to release the memory properly and safely.\n**\n** The sqlite3_get_table() interface is implemented as a wrapper around\n** [sqlite3_exec()].  The sqlite3_get_table() routine does not have access\n** to any internal data structures of SQLite.  It uses only the public\n** interface defined here.  As a consequence, errors that occur in the\n** wrapper layer outside of the internal [sqlite3_exec()] call are not\n** reflected in subsequent calls to [sqlite3_errcode()] or\n** [sqlite3_errmsg()].\n*/\nint sqlite3_get_table(\n  sqlite3 *db,          /* An open database */\n  const char *zSql,     /* SQL to be evaluated */\n  char ***pazResult,    /* Results of the query */\n  int *pnRow,           /* Number of result rows written here */\n  int *pnColumn,        /* Number of result columns written here */\n  char **pzErrmsg       /* Error msg written here */\n);\nvoid sqlite3_free_table(char **result);\n\n/*\n** CAPI3REF: Formatted String Printing Functions\n**\n** These routines are work-alikes of the \"printf()\" family of functions\n** from the standard C library.\n** These routines understand most of the common K&R formatting options,\n** plus some additional non-standard formats, detailed below.\n** Note that some of the more obscure formatting options from recent\n** C-library standards are omitted from this implementation.\n**\n** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their\n** results into memory obtained from [sqlite3_malloc()].\n** The strings returned by these two routines should be\n** released by [sqlite3_free()].  ^Both routines return a\n** NULL pointer if [sqlite3_malloc()] is unable to allocate enough\n** memory to hold the resulting string.\n**\n** ^(The sqlite3_snprintf() routine is similar to \"snprintf()\" from\n** the standard C library.  The result is written into the\n** buffer supplied as the second parameter whose size is given by\n** the first parameter. Note that the order of the\n** first two parameters is reversed from snprintf().)^  This is an\n** historical accident that cannot be fixed without breaking\n** backwards compatibility.  ^(Note also that sqlite3_snprintf()\n** returns a pointer to its buffer instead of the number of\n** characters actually written into the buffer.)^  We admit that\n** the number of characters written would be a more useful return\n** value but we cannot change the implementation of sqlite3_snprintf()\n** now without breaking compatibility.\n**\n** ^As long as the buffer size is greater than zero, sqlite3_snprintf()\n** guarantees that the buffer is always zero-terminated.  ^The first\n** parameter \"n\" is the total size of the buffer, including space for\n** the zero terminator.  So the longest string that can be completely\n** written will be n-1 characters.\n**\n** ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf().\n**\n** These routines all implement some additional formatting\n** options that are useful for constructing SQL statements.\n** All of the usual printf() formatting options apply.  In addition, there\n** is are \"%q\", \"%Q\", \"%w\" and \"%z\" options.\n**\n** ^(The %q option works like %s in that it substitutes a nul-terminated\n** string from the argument list.  But %q also doubles every '\\'' character.\n** %q is designed for use inside a string literal.)^  By doubling each '\\''\n** character it escapes that character and allows it to be inserted into\n** the string.\n**\n** For example, assume the string variable zText contains text as follows:\n**\n** <blockquote><pre>\n**  char *zText = \"It's a happy day!\";\n** </pre></blockquote>\n**\n** One can use this text in an SQL statement as follows:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES('%q')\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** Because the %q format string is used, the '\\'' character in zText\n** is escaped and the SQL generated is as follows:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It''s a happy day!')\n** </pre></blockquote>\n**\n** This is correct.  Had we used %s instead of %q, the generated SQL\n** would have looked like this:\n**\n** <blockquote><pre>\n**  INSERT INTO table1 VALUES('It's a happy day!');\n** </pre></blockquote>\n**\n** This second example is an SQL syntax error.  As a general rule you should\n** always use %q instead of %s when inserting text into a string literal.\n**\n** ^(The %Q option works like %q except it also adds single quotes around\n** the outside of the total string.  Additionally, if the parameter in the\n** argument list is a NULL pointer, %Q substitutes the text \"NULL\" (without\n** single quotes).)^  So, for example, one could say:\n**\n** <blockquote><pre>\n**  char *zSQL = sqlite3_mprintf(\"INSERT INTO table VALUES(%Q)\", zText);\n**  sqlite3_exec(db, zSQL, 0, 0, 0);\n**  sqlite3_free(zSQL);\n** </pre></blockquote>\n**\n** The code above will render a correct SQL statement in the zSQL\n** variable even if the zText variable is a NULL pointer.\n**\n** ^(The \"%w\" formatting option is like \"%q\" except that it expects to\n** be contained within double-quotes instead of single quotes, and it\n** escapes the double-quote character instead of the single-quote\n** character.)^  The \"%w\" formatting option is intended for safely inserting\n** table and column names into a constructed SQL statement.\n**\n** ^(The \"%z\" formatting option works like \"%s\" but with the\n** addition that after the string has been read and copied into\n** the result, [sqlite3_free()] is called on the input string.)^\n*/\nchar *sqlite3_mprintf(const char*,...);\nchar *sqlite3_vmprintf(const char*, va_list);\nchar *sqlite3_snprintf(int,char*,const char*, ...);\nchar *sqlite3_vsnprintf(int,char*,const char*, va_list);\n\n/*\n** CAPI3REF: Memory Allocation Subsystem\n**\n** The SQLite core uses these three routines for all of its own\n** internal memory allocation needs. \"Core\" in the previous sentence\n** does not include operating-system specific VFS implementation.  The\n** Windows VFS uses native malloc() and free() for some operations.\n**\n** ^The sqlite3_malloc() routine returns a pointer to a block\n** of memory at least N bytes in length, where N is the parameter.\n** ^If sqlite3_malloc() is unable to obtain sufficient free\n** memory, it returns a NULL pointer.  ^If the parameter N to\n** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns\n** a NULL pointer.\n**\n** ^The sqlite3_malloc64(N) routine works just like\n** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead\n** of a signed 32-bit integer.\n**\n** ^Calling sqlite3_free() with a pointer previously returned\n** by sqlite3_malloc() or sqlite3_realloc() releases that memory so\n** that it might be reused.  ^The sqlite3_free() routine is\n** a no-op if is called with a NULL pointer.  Passing a NULL pointer\n** to sqlite3_free() is harmless.  After being freed, memory\n** should neither be read nor written.  Even reading previously freed\n** memory might result in a segmentation fault or other severe error.\n** Memory corruption, a segmentation fault, or other severe error\n** might result if sqlite3_free() is called with a non-NULL pointer that\n** was not obtained from sqlite3_malloc() or sqlite3_realloc().\n**\n** ^The sqlite3_realloc(X,N) interface attempts to resize a\n** prior memory allocation X to be at least N bytes.\n** ^If the X parameter to sqlite3_realloc(X,N)\n** is a NULL pointer then its behavior is identical to calling\n** sqlite3_malloc(N).\n** ^If the N parameter to sqlite3_realloc(X,N) is zero or\n** negative then the behavior is exactly the same as calling\n** sqlite3_free(X).\n** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation\n** of at least N bytes in size or NULL if insufficient memory is available.\n** ^If M is the size of the prior allocation, then min(N,M) bytes\n** of the prior allocation are copied into the beginning of buffer returned\n** by sqlite3_realloc(X,N) and the prior allocation is freed.\n** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the\n** prior allocation is not freed.\n**\n** ^The sqlite3_realloc64(X,N) interfaces works the same as\n** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead\n** of a 32-bit signed integer.\n**\n** ^If X is a memory allocation previously obtained from sqlite3_malloc(),\n** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then\n** sqlite3_msize(X) returns the size of that memory allocation in bytes.\n** ^The value returned by sqlite3_msize(X) might be larger than the number\n** of bytes requested when X was allocated.  ^If X is a NULL pointer then\n** sqlite3_msize(X) returns zero.  If X points to something that is not\n** the beginning of memory allocation, or if it points to a formerly\n** valid memory allocation that has now been freed, then the behavior\n** of sqlite3_msize(X) is undefined and possibly harmful.\n**\n** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),\n** sqlite3_malloc64(), and sqlite3_realloc64()\n** is always aligned to at least an 8 byte boundary, or to a\n** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time\n** option is used.\n**\n** In SQLite version 3.5.0 and 3.5.1, it was possible to define\n** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in\n** implementation of these routines to be omitted.  That capability\n** is no longer provided.  Only built-in memory allocators can be used.\n**\n** Prior to SQLite version 3.7.10, the Windows OS interface layer called\n** the system malloc() and free() directly when converting\n** filenames between the UTF-8 encoding used by SQLite\n** and whatever filename encoding is used by the particular Windows\n** installation.  Memory allocation errors were detected, but\n** they were reported back as [SQLITE_CANTOPEN] or\n** [SQLITE_IOERR] rather than [SQLITE_NOMEM].\n**\n** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]\n** must be either NULL or else pointers obtained from a prior\n** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have\n** not yet been released.\n**\n** The application must not read or write any part of\n** a block of memory after it has been released using\n** [sqlite3_free()] or [sqlite3_realloc()].\n*/\nvoid *sqlite3_malloc(int);\nvoid *sqlite3_malloc64(sqlite3_uint64);\nvoid *sqlite3_realloc(void*, int);\nvoid *sqlite3_realloc64(void*, sqlite3_uint64);\nvoid sqlite3_free(void*);\nsqlite3_uint64 sqlite3_msize(void*);\n\n/*\n** CAPI3REF: Memory Allocator Statistics\n**\n** SQLite provides these two interfaces for reporting on the status\n** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]\n** routines, which form the built-in memory allocation subsystem.\n**\n** ^The [sqlite3_memory_used()] routine returns the number of bytes\n** of memory currently outstanding (malloced but not freed).\n** ^The [sqlite3_memory_highwater()] routine returns the maximum\n** value of [sqlite3_memory_used()] since the high-water mark\n** was last reset.  ^The values returned by [sqlite3_memory_used()] and\n** [sqlite3_memory_highwater()] include any overhead\n** added by SQLite in its implementation of [sqlite3_malloc()],\n** but not overhead added by the any underlying system library\n** routines that [sqlite3_malloc()] may call.\n**\n** ^The memory high-water mark is reset to the current value of\n** [sqlite3_memory_used()] if and only if the parameter to\n** [sqlite3_memory_highwater()] is true.  ^The value returned\n** by [sqlite3_memory_highwater(1)] is the high-water mark\n** prior to the reset.\n*/\nsqlite3_int64 sqlite3_memory_used(void);\nsqlite3_int64 sqlite3_memory_highwater(int resetFlag);\n\n/*\n** CAPI3REF: Pseudo-Random Number Generator\n**\n** SQLite contains a high-quality pseudo-random number generator (PRNG) used to\n** select random [ROWID | ROWIDs] when inserting new records into a table that\n** already uses the largest possible [ROWID].  The PRNG is also used for\n** the build-in random() and randomblob() SQL functions.  This interface allows\n** applications to access the same PRNG for other purposes.\n**\n** ^A call to this routine stores N bytes of randomness into buffer P.\n** ^The P parameter can be a NULL pointer.\n**\n** ^If this routine has not been previously called or if the previous\n** call had N less than one or a NULL pointer for P, then the PRNG is\n** seeded using randomness obtained from the xRandomness method of\n** the default [sqlite3_vfs] object.\n** ^If the previous call to this routine had an N of 1 or more and a\n** non-NULL P then the pseudo-randomness is generated\n** internally and without recourse to the [sqlite3_vfs] xRandomness\n** method.\n*/\nvoid sqlite3_randomness(int N, void *P);\n\n/*\n** CAPI3REF: Compile-Time Authorization Callbacks\n** METHOD: sqlite3\n** KEYWORDS: {authorizer callback}\n**\n** ^This routine registers an authorizer callback with a particular\n** [database connection], supplied in the first argument.\n** ^The authorizer callback is invoked as SQL statements are being compiled\n** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],\n** [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()],\n** and [sqlite3_prepare16_v3()].  ^At various\n** points during the compilation process, as logic is being created\n** to perform various actions, the authorizer callback is invoked to\n** see if those actions are allowed.  ^The authorizer callback should\n** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the\n** specific action but allow the SQL statement to continue to be\n** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be\n** rejected with an error.  ^If the authorizer callback returns\n** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]\n** then the [sqlite3_prepare_v2()] or equivalent call that triggered\n** the authorizer will fail with an error message.\n**\n** When the callback returns [SQLITE_OK], that means the operation\n** requested is ok.  ^When the callback returns [SQLITE_DENY], the\n** [sqlite3_prepare_v2()] or equivalent call that triggered the\n** authorizer will fail with an error message explaining that\n** access is denied. \n**\n** ^The first parameter to the authorizer callback is a copy of the third\n** parameter to the sqlite3_set_authorizer() interface. ^The second parameter\n** to the callback is an integer [SQLITE_COPY | action code] that specifies\n** the particular action to be authorized. ^The third through sixth parameters\n** to the callback are either NULL pointers or zero-terminated strings\n** that contain additional details about the action to be authorized.\n** Applications must always be prepared to encounter a NULL pointer in any\n** of the third through the sixth parameters of the authorization callback.\n**\n** ^If the action code is [SQLITE_READ]\n** and the callback returns [SQLITE_IGNORE] then the\n** [prepared statement] statement is constructed to substitute\n** a NULL value in place of the table column that would have\n** been read if [SQLITE_OK] had been returned.  The [SQLITE_IGNORE]\n** return can be used to deny an untrusted user access to individual\n** columns of a table.\n** ^When a table is referenced by a [SELECT] but no column values are\n** extracted from that table (for example in a query like\n** \"SELECT count(*) FROM tab\") then the [SQLITE_READ] authorizer callback\n** is invoked once for that table with a column name that is an empty string.\n** ^If the action code is [SQLITE_DELETE] and the callback returns\n** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the\n** [truncate optimization] is disabled and all rows are deleted individually.\n**\n** An authorizer is used when [sqlite3_prepare | preparing]\n** SQL statements from an untrusted source, to ensure that the SQL statements\n** do not try to access data they are not allowed to see, or that they do not\n** try to execute malicious statements that damage the database.  For\n** example, an application may allow a user to enter arbitrary\n** SQL queries for evaluation by a database.  But the application does\n** not want the user to be able to make arbitrary changes to the\n** database.  An authorizer could then be put in place while the\n** user-entered SQL is being [sqlite3_prepare | prepared] that\n** disallows everything except [SELECT] statements.\n**\n** Applications that need to process SQL from untrusted sources\n** might also consider lowering resource limits using [sqlite3_limit()]\n** and limiting database size using the [max_page_count] [PRAGMA]\n** in addition to using an authorizer.\n**\n** ^(Only a single authorizer can be in place on a database connection\n** at a time.  Each call to sqlite3_set_authorizer overrides the\n** previous call.)^  ^Disable the authorizer by installing a NULL callback.\n** The authorizer is disabled by default.\n**\n** The authorizer callback must not do anything that will modify\n** the database connection that invoked the authorizer callback.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the\n** statement might be re-prepared during [sqlite3_step()] due to a \n** schema change.  Hence, the application should ensure that the\n** correct authorizer callback remains in place during the [sqlite3_step()].\n**\n** ^Note that the authorizer callback is invoked only during\n** [sqlite3_prepare()] or its variants.  Authorization is not\n** performed during statement evaluation in [sqlite3_step()], unless\n** as stated in the previous paragraph, sqlite3_step() invokes\n** sqlite3_prepare_v2() to reprepare a statement after a schema change.\n*/\nint sqlite3_set_authorizer(\n  sqlite3*,\n  int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),\n  void *pUserData\n);\n\n/*\n** CAPI3REF: Authorizer Return Codes\n**\n** The [sqlite3_set_authorizer | authorizer callback function] must\n** return either [SQLITE_OK] or one of these two constants in order\n** to signal SQLite whether or not the action is permitted.  See the\n** [sqlite3_set_authorizer | authorizer documentation] for additional\n** information.\n**\n** Note that SQLITE_IGNORE is also used as a [conflict resolution mode]\n** returned from the [sqlite3_vtab_on_conflict()] interface.\n*/\n#define SQLITE_DENY   1   /* Abort the SQL statement with an error */\n#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */\n\n/*\n** CAPI3REF: Authorizer Action Codes\n**\n** The [sqlite3_set_authorizer()] interface registers a callback function\n** that is invoked to authorize certain SQL statement actions.  The\n** second parameter to the callback is an integer code that specifies\n** what action is being authorized.  These are the integer action codes that\n** the authorizer callback may be passed.\n**\n** These action code values signify what kind of operation is to be\n** authorized.  The 3rd and 4th parameters to the authorization\n** callback function will be parameters or NULL depending on which of these\n** codes is used as the second parameter.  ^(The 5th parameter to the\n** authorizer callback is the name of the database (\"main\", \"temp\",\n** etc.) if applicable.)^  ^The 6th parameter to the authorizer callback\n** is the name of the inner-most trigger or view that is responsible for\n** the access attempt or NULL if this access attempt is directly from\n** top-level SQL code.\n*/\n/******************************************* 3rd ************ 4th ***********/\n#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */\n#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */\n#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */\n#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */\n#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */\n#define SQLITE_DELETE                9   /* Table Name      NULL            */\n#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */\n#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */\n#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */\n#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */\n#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */\n#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */\n#define SQLITE_INSERT               18   /* Table Name      NULL            */\n#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */\n#define SQLITE_READ                 20   /* Table Name      Column Name     */\n#define SQLITE_SELECT               21   /* NULL            NULL            */\n#define SQLITE_TRANSACTION          22   /* Operation       NULL            */\n#define SQLITE_UPDATE               23   /* Table Name      Column Name     */\n#define SQLITE_ATTACH               24   /* Filename        NULL            */\n#define SQLITE_DETACH               25   /* Database Name   NULL            */\n#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */\n#define SQLITE_REINDEX              27   /* Index Name      NULL            */\n#define SQLITE_ANALYZE              28   /* Table Name      NULL            */\n#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */\n#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */\n#define SQLITE_FUNCTION             31   /* NULL            Function Name   */\n#define SQLITE_SAVEPOINT            32   /* Operation       Savepoint Name  */\n#define SQLITE_COPY                  0   /* No longer used */\n#define SQLITE_RECURSIVE            33   /* NULL            NULL            */\n\n/*\n** CAPI3REF: Tracing And Profiling Functions\n** METHOD: sqlite3\n**\n** These routines are deprecated. Use the [sqlite3_trace_v2()] interface\n** instead of the routines described here.\n**\n** These routines register callback functions that can be used for\n** tracing and profiling the execution of SQL statements.\n**\n** ^The callback function registered by sqlite3_trace() is invoked at\n** various times when an SQL statement is being run by [sqlite3_step()].\n** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the\n** SQL statement text as the statement first begins executing.\n** ^(Additional sqlite3_trace() callbacks might occur\n** as each triggered subprogram is entered.  The callbacks for triggers\n** contain a UTF-8 SQL comment that identifies the trigger.)^\n**\n** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit\n** the length of [bound parameter] expansion in the output of sqlite3_trace().\n**\n** ^The callback function registered by sqlite3_profile() is invoked\n** as each SQL statement finishes.  ^The profile callback contains\n** the original statement text and an estimate of wall-clock time\n** of how long that statement took to run.  ^The profile callback\n** time is in units of nanoseconds, however the current implementation\n** is only capable of millisecond resolution so the six least significant\n** digits in the time are meaningless.  Future versions of SQLite\n** might provide greater resolution on the profiler callback.  The\n** sqlite3_profile() function is considered experimental and is\n** subject to change in future versions of SQLite.\n*/\nSQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,\n   void(*xTrace)(void*,const char*), void*);\nSQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,\n   void(*xProfile)(void*,const char*,sqlite3_uint64), void*);\n\n/*\n** CAPI3REF: SQL Trace Event Codes\n** KEYWORDS: SQLITE_TRACE\n**\n** These constants identify classes of events that can be monitored\n** using the [sqlite3_trace_v2()] tracing logic.  The third argument\n** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of\n** the following constants.  ^The first argument to the trace callback\n** is one of the following constants.\n**\n** New tracing constants may be added in future releases.\n**\n** ^A trace callback has four arguments: xCallback(T,C,P,X).\n** ^The T argument is one of the integer type codes above.\n** ^The C argument is a copy of the context pointer passed in as the\n** fourth argument to [sqlite3_trace_v2()].\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** <dl>\n** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>\n** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement\n** first begins running and possibly at other times during the\n** execution of the prepared statement, such as at the start of each\n** trigger subprogram. ^The P argument is a pointer to the\n** [prepared statement]. ^The X argument is a pointer to a string which\n** is the unexpanded SQL text of the prepared statement or an SQL comment \n** that indicates the invocation of a trigger.  ^The callback can compute\n** the same text that would have been returned by the legacy [sqlite3_trace()]\n** interface by using the X argument when X begins with \"--\" and invoking\n** [sqlite3_expanded_sql(P)] otherwise.\n**\n** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>\n** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same\n** information as is provided by the [sqlite3_profile()] callback.\n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument points to a 64-bit integer which is the estimated of\n** the number of nanosecond that the prepared statement took to run.\n** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.\n**\n** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>\n** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared\n** statement generates a single row of result.  \n** ^The P argument is a pointer to the [prepared statement] and the\n** X argument is unused.\n**\n** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>\n** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database\n** connection closes.\n** ^The P argument is a pointer to the [database connection] object\n** and the X argument is unused.\n** </dl>\n*/\n#define SQLITE_TRACE_STMT       0x01\n#define SQLITE_TRACE_PROFILE    0x02\n#define SQLITE_TRACE_ROW        0x04\n#define SQLITE_TRACE_CLOSE      0x08\n\n/*\n** CAPI3REF: SQL Trace Hook\n** METHOD: sqlite3\n**\n** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback\n** function X against [database connection] D, using property mask M\n** and context pointer P.  ^If the X callback is\n** NULL or if the M mask is zero, then tracing is disabled.  The\n** M argument should be the bitwise OR-ed combination of\n** zero or more [SQLITE_TRACE] constants.\n**\n** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides \n** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().\n**\n** ^The X callback is invoked whenever any of the events identified by \n** mask M occur.  ^The integer return value from the callback is currently\n** ignored, though this may change in future releases.  Callback\n** implementations should return zero to ensure future compatibility.\n**\n** ^A trace callback is invoked with four arguments: callback(T,C,P,X).\n** ^The T argument is one of the [SQLITE_TRACE]\n** constants to indicate why the callback was invoked.\n** ^The C argument is a copy of the context pointer.\n** The P and X arguments are pointers whose meanings depend on T.\n**\n** The sqlite3_trace_v2() interface is intended to replace the legacy\n** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which\n** are deprecated.\n*/\nint sqlite3_trace_v2(\n  sqlite3*,\n  unsigned uMask,\n  int(*xCallback)(unsigned,void*,void*,void*),\n  void *pCtx\n);\n\n/*\n** CAPI3REF: Query Progress Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback\n** function X to be invoked periodically during long running calls to\n** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for\n** database connection D.  An example use for this\n** interface is to keep a GUI updated during a large query.\n**\n** ^The parameter P is passed through as the only parameter to the \n** callback function X.  ^The parameter N is the approximate number of \n** [virtual machine instructions] that are evaluated between successive\n** invocations of the callback X.  ^If N is less than one then the progress\n** handler is disabled.\n**\n** ^Only a single progress handler may be defined at one time per\n** [database connection]; setting a new progress handler cancels the\n** old one.  ^Setting parameter X to NULL disables the progress handler.\n** ^The progress handler is also disabled by setting N to a value less\n** than 1.\n**\n** ^If the progress callback returns non-zero, the operation is\n** interrupted.  This feature can be used to implement a\n** \"Cancel\" button on a GUI progress dialog box.\n**\n** The progress handler callback must not do anything that will modify\n** the database connection that invoked the progress handler.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n*/\nvoid sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);\n\n/*\n** CAPI3REF: Opening A New Database Connection\n** CONSTRUCTOR: sqlite3\n**\n** ^These routines open an SQLite database file as specified by the \n** filename argument. ^The filename argument is interpreted as UTF-8 for\n** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte\n** order for sqlite3_open16(). ^(A [database connection] handle is usually\n** returned in *ppDb, even if an error occurs.  The only exception is that\n** if SQLite is unable to allocate memory to hold the [sqlite3] object,\n** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]\n** object.)^ ^(If the database is opened (and/or created) successfully, then\n** [SQLITE_OK] is returned.  Otherwise an [error code] is returned.)^ ^The\n** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain\n** an English language description of the error following a failure of any\n** of the sqlite3_open() routines.\n**\n** ^The default encoding will be UTF-8 for databases created using\n** sqlite3_open() or sqlite3_open_v2().  ^The default encoding for databases\n** created using sqlite3_open16() will be UTF-16 in the native byte order.\n**\n** Whether or not an error occurs when it is opened, resources\n** associated with the [database connection] handle should be released by\n** passing it to [sqlite3_close()] when it is no longer required.\n**\n** The sqlite3_open_v2() interface works like sqlite3_open()\n** except that it accepts two additional parameters for additional control\n** over the new database connection.  ^(The flags parameter to\n** sqlite3_open_v2() can take one of\n** the following three values, optionally combined with the \n** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],\n** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^\n**\n** <dl>\n** ^(<dt>[SQLITE_OPEN_READONLY]</dt>\n** <dd>The database is opened in read-only mode.  If the database does not\n** already exist, an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>\n** <dd>The database is opened for reading and writing if possible, or reading\n** only if the file is write protected by the operating system.  In either\n** case the database must already exist, otherwise an error is returned.</dd>)^\n**\n** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>\n** <dd>The database is opened for reading and writing, and is created if\n** it does not already exist. This is the behavior that is always used for\n** sqlite3_open() and sqlite3_open16().</dd>)^\n** </dl>\n**\n** If the 3rd parameter to sqlite3_open_v2() is not one of the\n** combinations shown above optionally combined with other\n** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]\n** then the behavior is undefined.\n**\n** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection\n** opens in the multi-thread [threading mode] as long as the single-thread\n** mode has not been set at compile-time or start-time.  ^If the\n** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens\n** in the serialized [threading mode] unless single-thread was\n** previously selected at compile-time or start-time.\n** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be\n** eligible to use [shared cache mode], regardless of whether or not shared\n** cache is enabled using [sqlite3_enable_shared_cache()].  ^The\n** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not\n** participate in [shared cache mode] even if it is enabled.\n**\n** ^The fourth parameter to sqlite3_open_v2() is the name of the\n** [sqlite3_vfs] object that defines the operating system interface that\n** the new database connection should use.  ^If the fourth parameter is\n** a NULL pointer then the default [sqlite3_vfs] object is used.\n**\n** ^If the filename is \":memory:\", then a private, temporary in-memory database\n** is created for the connection.  ^This in-memory database will vanish when\n** the database connection is closed.  Future versions of SQLite might\n** make use of additional special filenames that begin with the \":\" character.\n** It is recommended that when a database filename actually does begin with\n** a \":\" character you should prefix the filename with a pathname such as\n** \"./\" to avoid ambiguity.\n**\n** ^If the filename is an empty string, then a private, temporary\n** on-disk database will be created.  ^This private database will be\n** automatically deleted as soon as the database connection is closed.\n**\n** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>\n**\n** ^If [URI filename] interpretation is enabled, and the filename argument\n** begins with \"file:\", then the filename is interpreted as a URI. ^URI\n** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is\n** set in the third argument to sqlite3_open_v2(), or if it has\n** been enabled globally using the [SQLITE_CONFIG_URI] option with the\n** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.\n** URI filename interpretation is turned off\n** by default, but future releases of SQLite might enable URI filename\n** interpretation by default.  See \"[URI filenames]\" for additional\n** information.\n**\n** URI filenames are parsed according to RFC 3986. ^If the URI contains an\n** authority, then it must be either an empty string or the string \n** \"localhost\". ^If the authority is not an empty string or \"localhost\", an \n** error is returned to the caller. ^The fragment component of a URI, if \n** present, is ignored.\n**\n** ^SQLite uses the path component of the URI as the name of the disk file\n** which contains the database. ^If the path begins with a '/' character, \n** then it is interpreted as an absolute path. ^If the path does not begin \n** with a '/' (meaning that the authority section is omitted from the URI)\n** then the path is interpreted as a relative path. \n** ^(On windows, the first component of an absolute path \n** is a drive specification (e.g. \"C:\").)^\n**\n** [[core URI query parameters]]\n** The query component of a URI may contain parameters that are interpreted\n** either by SQLite itself, or by a [VFS | custom VFS implementation].\n** SQLite and its built-in [VFSes] interpret the\n** following query parameters:\n**\n** <ul>\n**   <li> <b>vfs</b>: ^The \"vfs\" parameter may be used to specify the name of\n**     a VFS object that provides the operating system interface that should\n**     be used to access the database file on disk. ^If this option is set to\n**     an empty string the default VFS object is used. ^Specifying an unknown\n**     VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is\n**     present, then the VFS specified by the option takes precedence over\n**     the value passed as the fourth parameter to sqlite3_open_v2().\n**\n**   <li> <b>mode</b>: ^(The mode parameter may be set to either \"ro\", \"rw\",\n**     \"rwc\", or \"memory\". Attempting to set it to any other value is\n**     an error)^. \n**     ^If \"ro\" is specified, then the database is opened for read-only \n**     access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the \n**     third argument to sqlite3_open_v2(). ^If the mode option is set to \n**     \"rw\", then the database is opened for read-write (but not create) \n**     access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had \n**     been set. ^Value \"rwc\" is equivalent to setting both \n**     SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.  ^If the mode option is\n**     set to \"memory\" then a pure [in-memory database] that never reads\n**     or writes from disk is used. ^It is an error to specify a value for\n**     the mode parameter that is less restrictive than that specified by\n**     the flags passed in the third parameter to sqlite3_open_v2().\n**\n**   <li> <b>cache</b>: ^The cache parameter may be set to either \"shared\" or\n**     \"private\". ^Setting it to \"shared\" is equivalent to setting the\n**     SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to\n**     sqlite3_open_v2(). ^Setting the cache parameter to \"private\" is \n**     equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n**     ^If sqlite3_open_v2() is used and the \"cache\" parameter is present in\n**     a URI filename, its value overrides any behavior requested by setting\n**     SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.\n**\n**  <li> <b>psow</b>: ^The psow parameter indicates whether or not the\n**     [powersafe overwrite] property does or does not apply to the\n**     storage media on which the database file resides.\n**\n**  <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter\n**     which if set disables file locking in rollback journal modes.  This\n**     is useful for accessing a database on a filesystem that does not\n**     support locking.  Caution:  Database corruption might result if two\n**     or more processes write to the same database and any one of those\n**     processes uses nolock=1.\n**\n**  <li> <b>immutable</b>: ^The immutable parameter is a boolean query\n**     parameter that indicates that the database file is stored on\n**     read-only media.  ^When immutable is set, SQLite assumes that the\n**     database file cannot be changed, even by a process with higher\n**     privilege, and so the database is opened read-only and all locking\n**     and change detection is disabled.  Caution: Setting the immutable\n**     property on a database file that does in fact change can result\n**     in incorrect query results and/or [SQLITE_CORRUPT] errors.\n**     See also: [SQLITE_IOCAP_IMMUTABLE].\n**       \n** </ul>\n**\n** ^Specifying an unknown parameter in the query component of a URI is not an\n** error.  Future versions of SQLite might understand additional query\n** parameters.  See \"[query parameters with special meaning to SQLite]\" for\n** additional information.\n**\n** [[URI filename examples]] <h3>URI filename examples</h3>\n**\n** <table border=\"1\" align=center cellpadding=5>\n** <tr><th> URI filenames <th> Results\n** <tr><td> file:data.db <td> \n**          Open the file \"data.db\" in the current directory.\n** <tr><td> file:/home/fred/data.db<br>\n**          file:///home/fred/data.db <br> \n**          file://localhost/home/fred/data.db <br> <td> \n**          Open the database file \"/home/fred/data.db\".\n** <tr><td> file://darkstar/home/fred/data.db <td> \n**          An error. \"darkstar\" is not a recognized authority.\n** <tr><td style=\"white-space:nowrap\"> \n**          file:///C:/Documents%20and%20Settings/fred/Desktop/data.db\n**     <td> Windows only: Open the file \"data.db\" on fred's desktop on drive\n**          C:. Note that the %20 escaping in this example is not strictly \n**          necessary - space characters can be used literally\n**          in URI filenames.\n** <tr><td> file:data.db?mode=ro&cache=private <td> \n**          Open file \"data.db\" in the current directory for read-only access.\n**          Regardless of whether or not shared-cache mode is enabled by\n**          default, use a private cache.\n** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>\n**          Open file \"/home/fred/data.db\". Use the special VFS \"unix-dotfile\"\n**          that uses dot-files in place of posix advisory locking.\n** <tr><td> file:data.db?mode=readonly <td> \n**          An error. \"readonly\" is not a valid option for the \"mode\" parameter.\n** </table>\n**\n** ^URI hexadecimal escape sequences (%HH) are supported within the path and\n** query components of a URI. A hexadecimal escape sequence consists of a\n** percent sign - \"%\" - followed by exactly two hexadecimal digits \n** specifying an octet value. ^Before the path or query components of a\n** URI filename are interpreted, they are encoded using UTF-8 and all \n** hexadecimal escape sequences replaced by a single byte containing the\n** corresponding octet. If this process generates an invalid UTF-8 encoding,\n** the results are undefined.\n**\n** <b>Note to Windows users:</b>  The encoding used for the filename argument\n** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever\n** codepage is currently defined.  Filenames containing international\n** characters must be converted to UTF-8 prior to passing them into\n** sqlite3_open() or sqlite3_open_v2().\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling sqlite3_open() or sqlite3_open_v2().  Otherwise, various\n** features that require the use of temporary files may fail.\n**\n** See also: [sqlite3_temp_directory]\n*/\nint sqlite3_open(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nint sqlite3_open16(\n  const void *filename,   /* Database filename (UTF-16) */\n  sqlite3 **ppDb          /* OUT: SQLite db handle */\n);\nint sqlite3_open_v2(\n  const char *filename,   /* Database filename (UTF-8) */\n  sqlite3 **ppDb,         /* OUT: SQLite db handle */\n  int flags,              /* Flags */\n  const char *zVfs        /* Name of VFS module to use */\n);\n\n/*\n** CAPI3REF: Obtain Values For URI Parameters\n**\n** These are utility routines, useful to VFS implementations, that check\n** to see if a database file was a URI that contained a specific query \n** parameter, and if so obtains the value of that query parameter.\n**\n** If F is the database filename pointer passed into the xOpen() method of \n** a VFS implementation when the flags parameter to xOpen() has one or \n** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and\n** P is the name of the query parameter, then\n** sqlite3_uri_parameter(F,P) returns the value of the P\n** parameter if it exists or a NULL pointer if P does not appear as a \n** query parameter on F.  If P is a query parameter of F\n** has no explicit value, then sqlite3_uri_parameter(F,P) returns\n** a pointer to an empty string.\n**\n** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean\n** parameter and returns true (1) or false (0) according to the value\n** of P.  The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the\n** value of query parameter P is one of \"yes\", \"true\", or \"on\" in any\n** case or if the value begins with a non-zero number.  The \n** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of\n** query parameter P is one of \"no\", \"false\", or \"off\" in any case or\n** if the value begins with a numeric zero.  If P is not a query\n** parameter on F or if the value of P is does not match any of the\n** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).\n**\n** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a\n** 64-bit signed integer and returns that integer, or D if P does not\n** exist.  If the value of P is something other than an integer, then\n** zero is returned.\n** \n** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and\n** sqlite3_uri_boolean(F,P,B) returns B.  If F is not a NULL pointer and\n** is not a database file pathname pointer that SQLite passed into the xOpen\n** VFS method, then the behavior of this routine is undefined and probably\n** undesirable.\n*/\nconst char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);\nint sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);\nsqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);\n\n\n/*\n** CAPI3REF: Error Codes And Messages\n** METHOD: sqlite3\n**\n** ^If the most recent sqlite3_* API call associated with \n** [database connection] D failed, then the sqlite3_errcode(D) interface\n** returns the numeric [result code] or [extended result code] for that\n** API call.\n** If the most recent API call was successful,\n** then the return value from sqlite3_errcode() is undefined.\n** ^The sqlite3_extended_errcode()\n** interface is the same except that it always returns the \n** [extended result code] even when extended result codes are\n** disabled.\n**\n** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language\n** text that describes the error, as either UTF-8 or UTF-16 respectively.\n** ^(Memory to hold the error message string is managed internally.\n** The application does not need to worry about freeing the result.\n** However, the error string might be overwritten or deallocated by\n** subsequent calls to other SQLite interface functions.)^\n**\n** ^The sqlite3_errstr() interface returns the English-language text\n** that describes the [result code], as UTF-8.\n** ^(Memory to hold the error message string is managed internally\n** and must not be freed by the application)^.\n**\n** When the serialized [threading mode] is in use, it might be the\n** case that a second error occurs on a separate thread in between\n** the time of the first error and the call to these interfaces.\n** When that happens, the second error will be reported since these\n** interfaces always report the most recent result.  To avoid\n** this, each thread can obtain exclusive use of the [database connection] D\n** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning\n** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after\n** all calls to the interfaces listed here are completed.\n**\n** If an interface fails with SQLITE_MISUSE, that means the interface\n** was invoked incorrectly by the application.  In that case, the\n** error code and message may or may not be set.\n*/\nint sqlite3_errcode(sqlite3 *db);\nint sqlite3_extended_errcode(sqlite3 *db);\nconst char *sqlite3_errmsg(sqlite3*);\nconst void *sqlite3_errmsg16(sqlite3*);\nconst char *sqlite3_errstr(int);\n\n/*\n** CAPI3REF: Prepared Statement Object\n** KEYWORDS: {prepared statement} {prepared statements}\n**\n** An instance of this object represents a single SQL statement that\n** has been compiled into binary form and is ready to be evaluated.\n**\n** Think of each SQL statement as a separate computer program.  The\n** original SQL text is source code.  A prepared statement object \n** is the compiled object code.  All SQL must be converted into a\n** prepared statement before it can be run.\n**\n** The life-cycle of a prepared statement object usually goes like this:\n**\n** <ol>\n** <li> Create the prepared statement object using [sqlite3_prepare_v2()].\n** <li> Bind values to [parameters] using the sqlite3_bind_*()\n**      interfaces.\n** <li> Run the SQL by calling [sqlite3_step()] one or more times.\n** <li> Reset the prepared statement using [sqlite3_reset()] then go back\n**      to step 2.  Do this zero or more times.\n** <li> Destroy the object using [sqlite3_finalize()].\n** </ol>\n*/\ntypedef struct sqlite3_stmt sqlite3_stmt;\n\n/*\n** CAPI3REF: Run-time Limits\n** METHOD: sqlite3\n**\n** ^(This interface allows the size of various constructs to be limited\n** on a connection by connection basis.  The first parameter is the\n** [database connection] whose limit is to be set or queried.  The\n** second parameter is one of the [limit categories] that define a\n** class of constructs to be size limited.  The third parameter is the\n** new limit for that construct.)^\n**\n** ^If the new limit is a negative number, the limit is unchanged.\n** ^(For each limit category SQLITE_LIMIT_<i>NAME</i> there is a \n** [limits | hard upper bound]\n** set at compile-time by a C preprocessor macro called\n** [limits | SQLITE_MAX_<i>NAME</i>].\n** (The \"_LIMIT_\" in the name is changed to \"_MAX_\".))^\n** ^Attempts to increase a limit above its hard upper bound are\n** silently truncated to the hard upper bound.\n**\n** ^Regardless of whether or not the limit was changed, the \n** [sqlite3_limit()] interface returns the prior value of the limit.\n** ^Hence, to find the current value of a limit without changing it,\n** simply invoke this interface with the third parameter set to -1.\n**\n** Run-time limits are intended for use in applications that manage\n** both their own internal database and also databases that are controlled\n** by untrusted external sources.  An example application might be a\n** web browser that has its own databases for storing history and\n** separate databases controlled by JavaScript applications downloaded\n** off the Internet.  The internal databases can be given the\n** large, default limits.  Databases managed by external sources can\n** be given much smaller limits designed to prevent a denial of service\n** attack.  Developers might also want to use the [sqlite3_set_authorizer()]\n** interface to further control untrusted SQL.  The size of the database\n** created by an untrusted script can be contained using the\n** [max_page_count] [PRAGMA].\n**\n** New run-time limit categories may be added in future releases.\n*/\nint sqlite3_limit(sqlite3*, int id, int newVal);\n\n/*\n** CAPI3REF: Run-Time Limit Categories\n** KEYWORDS: {limit category} {*limit categories}\n**\n** These constants define various performance limits\n** that can be lowered at run-time using [sqlite3_limit()].\n** The synopsis of the meanings of the various limits is shown below.\n** Additional information is available at [limits | Limits in SQLite].\n**\n** <dl>\n** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>\n** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^\n**\n** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>\n** <dd>The maximum length of an SQL statement, in bytes.</dd>)^\n**\n** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>\n** <dd>The maximum number of columns in a table definition or in the\n** result set of a [SELECT] or the maximum number of columns in an index\n** or in an ORDER BY or GROUP BY clause.</dd>)^\n**\n** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>\n** <dd>The maximum depth of the parse tree on any expression.</dd>)^\n**\n** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>\n** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^\n**\n** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>\n** <dd>The maximum number of instructions in a virtual machine program\n** used to implement an SQL statement.  If [sqlite3_prepare_v2()] or\n** the equivalent tries to allocate space for more than this many opcodes\n** in a single prepared statement, an SQLITE_NOMEM error is returned.</dd>)^\n**\n** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>\n** <dd>The maximum number of arguments on a function.</dd>)^\n**\n** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>\n** <dd>The maximum number of [ATTACH | attached databases].)^</dd>\n**\n** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]\n** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>\n** <dd>The maximum length of the pattern argument to the [LIKE] or\n** [GLOB] operators.</dd>)^\n**\n** [[SQLITE_LIMIT_VARIABLE_NUMBER]]\n** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>\n** <dd>The maximum index number of any [parameter] in an SQL statement.)^\n**\n** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>\n** <dd>The maximum depth of recursion for triggers.</dd>)^\n**\n** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>\n** <dd>The maximum number of auxiliary worker threads that a single\n** [prepared statement] may start.</dd>)^\n** </dl>\n*/\n#define SQLITE_LIMIT_LENGTH                    0\n#define SQLITE_LIMIT_SQL_LENGTH                1\n#define SQLITE_LIMIT_COLUMN                    2\n#define SQLITE_LIMIT_EXPR_DEPTH                3\n#define SQLITE_LIMIT_COMPOUND_SELECT           4\n#define SQLITE_LIMIT_VDBE_OP                   5\n#define SQLITE_LIMIT_FUNCTION_ARG              6\n#define SQLITE_LIMIT_ATTACHED                  7\n#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8\n#define SQLITE_LIMIT_VARIABLE_NUMBER           9\n#define SQLITE_LIMIT_TRIGGER_DEPTH            10\n#define SQLITE_LIMIT_WORKER_THREADS           11\n\n/*\n** CAPI3REF: Prepare Flags\n**\n** These constants define various flags that can be passed into\n** \"prepFlags\" parameter of the [sqlite3_prepare_v3()] and\n** [sqlite3_prepare16_v3()] interfaces.\n**\n** New flags may be added in future releases of SQLite.\n**\n** <dl>\n** [[SQLITE_PREPARE_PERSISTENT]] ^(<dt>SQLITE_PREPARE_PERSISTENT</dt>\n** <dd>The SQLITE_PREPARE_PERSISTENT flag is a hint to the query planner\n** that the prepared statement will be retained for a long time and\n** probably reused many times.)^ ^Without this flag, [sqlite3_prepare_v3()]\n** and [sqlite3_prepare16_v3()] assume that the prepared statement will \n** be used just once or at most a few times and then destroyed using\n** [sqlite3_finalize()] relatively soon. The current implementation acts\n** on this hint by avoiding the use of [lookaside memory] so as not to\n** deplete the limited store of lookaside memory. Future versions of\n** SQLite may act on this hint differently.\n** </dl>\n*/\n#define SQLITE_PREPARE_PERSISTENT              0x01\n\n/*\n** CAPI3REF: Compiling An SQL Statement\n** KEYWORDS: {SQL statement compiler}\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_stmt\n**\n** To execute an SQL statement, it must first be compiled into a byte-code\n** program using one of these routines.  Or, in other words, these routines\n** are constructors for the [prepared statement] object.\n**\n** The preferred routine to use is [sqlite3_prepare_v2()].  The\n** [sqlite3_prepare()] interface is legacy and should be avoided.\n** [sqlite3_prepare_v3()] has an extra \"prepFlags\" option that is used\n** for special purposes.\n**\n** The use of the UTF-8 interfaces is preferred, as SQLite currently\n** does all parsing using UTF-8.  The UTF-16 interfaces are provided\n** as a convenience.  The UTF-16 interfaces work by converting the\n** input text into UTF-8, then invoking the corresponding UTF-8 interface.\n**\n** The first argument, \"db\", is a [database connection] obtained from a\n** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or\n** [sqlite3_open16()].  The database connection must not have been closed.\n**\n** The second argument, \"zSql\", is the statement to be compiled, encoded\n** as either UTF-8 or UTF-16.  The sqlite3_prepare(), sqlite3_prepare_v2(),\n** and sqlite3_prepare_v3()\n** interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() use UTF-16.\n**\n** ^If the nByte argument is negative, then zSql is read up to the\n** first zero terminator. ^If nByte is positive, then it is the\n** number of bytes read from zSql.  ^If nByte is zero, then no prepared\n** statement is generated.\n** If the caller knows that the supplied string is nul-terminated, then\n** there is a small performance advantage to passing an nByte parameter that\n** is the number of bytes in the input string <i>including</i>\n** the nul-terminator.\n**\n** ^If pzTail is not NULL then *pzTail is made to point to the first byte\n** past the end of the first SQL statement in zSql.  These routines only\n** compile the first statement in zSql, so *pzTail is left pointing to\n** what remains uncompiled.\n**\n** ^*ppStmt is left pointing to a compiled [prepared statement] that can be\n** executed using [sqlite3_step()].  ^If there is an error, *ppStmt is set\n** to NULL.  ^If the input text contains no SQL (if the input is an empty\n** string or a comment) then *ppStmt is set to NULL.\n** The calling procedure is responsible for deleting the compiled\n** SQL statement using [sqlite3_finalize()] after it has finished with it.\n** ppStmt may not be NULL.\n**\n** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];\n** otherwise an [error code] is returned.\n**\n** The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(),\n** and sqlite3_prepare16_v3() interfaces are recommended for all new programs.\n** The older interfaces (sqlite3_prepare() and sqlite3_prepare16())\n** are retained for backwards compatibility, but their use is discouraged.\n** ^In the \"vX\" interfaces, the prepared statement\n** that is returned (the [sqlite3_stmt] object) contains a copy of the\n** original SQL text. This causes the [sqlite3_step()] interface to\n** behave differently in three ways:\n**\n** <ol>\n** <li>\n** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it\n** always used to do, [sqlite3_step()] will automatically recompile the SQL\n** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]\n** retries will occur before sqlite3_step() gives up and returns an error.\n** </li>\n**\n** <li>\n** ^When an error occurs, [sqlite3_step()] will return one of the detailed\n** [error codes] or [extended error codes].  ^The legacy behavior was that\n** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code\n** and the application would have to make a second call to [sqlite3_reset()]\n** in order to find the underlying cause of the problem. With the \"v2\" prepare\n** interfaces, the underlying reason for the error is returned immediately.\n** </li>\n**\n** <li>\n** ^If the specific value bound to [parameter | host parameter] in the \n** WHERE clause might influence the choice of query plan for a statement,\n** then the statement will be automatically recompiled, as if there had been \n** a schema change, on the first  [sqlite3_step()] call following any change\n** to the [sqlite3_bind_text | bindings] of that [parameter]. \n** ^The specific value of WHERE-clause [parameter] might influence the \n** choice of query plan if the parameter is the left-hand side of a [LIKE]\n** or [GLOB] operator or if the parameter is compared to an indexed column\n** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.\n** </li>\n**\n** <p>^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having\n** the extra prepFlags parameter, which is a bit array consisting of zero or\n** more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags.  ^The\n** sqlite3_prepare_v2() interface works exactly the same as\n** sqlite3_prepare_v3() with a zero prepFlags parameter.\n** </ol>\n*/\nint sqlite3_prepare(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nint sqlite3_prepare_v2(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nint sqlite3_prepare_v3(\n  sqlite3 *db,            /* Database handle */\n  const char *zSql,       /* SQL statement, UTF-8 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const char **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nint sqlite3_prepare16(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nint sqlite3_prepare16_v2(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\nint sqlite3_prepare16_v3(\n  sqlite3 *db,            /* Database handle */\n  const void *zSql,       /* SQL statement, UTF-16 encoded */\n  int nByte,              /* Maximum length of zSql in bytes. */\n  unsigned int prepFlags, /* Zero or more SQLITE_PREPARE_ flags */\n  sqlite3_stmt **ppStmt,  /* OUT: Statement handle */\n  const void **pzTail     /* OUT: Pointer to unused portion of zSql */\n);\n\n/*\n** CAPI3REF: Retrieving Statement SQL\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8\n** SQL text used to create [prepared statement] P if P was\n** created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8\n** string containing the SQL text of prepared statement P with\n** [bound parameters] expanded.\n**\n** ^(For example, if a prepared statement is created using the SQL\n** text \"SELECT $abc,:xyz\" and if parameter $abc is bound to integer 2345\n** and parameter :xyz is unbound, then sqlite3_sql() will return\n** the original string, \"SELECT $abc,:xyz\" but sqlite3_expanded_sql()\n** will return \"SELECT 2345,NULL\".)^\n**\n** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory\n** is available to hold the result, or if the result would exceed the\n** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].\n**\n** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of\n** bound parameter expansions.  ^The [SQLITE_OMIT_TRACE] compile-time\n** option causes sqlite3_expanded_sql() to always return NULL.\n**\n** ^The string returned by sqlite3_sql(P) is managed by SQLite and is\n** automatically freed when the prepared statement is finalized.\n** ^The string returned by sqlite3_expanded_sql(P), on the other hand,\n** is obtained from [sqlite3_malloc()] and must be free by the application\n** by passing it to [sqlite3_free()].\n*/\nconst char *sqlite3_sql(sqlite3_stmt *pStmt);\nchar *sqlite3_expanded_sql(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If An SQL Statement Writes The Database\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if\n** and only if the [prepared statement] X makes no direct changes to\n** the content of the database file.\n**\n** Note that [application-defined SQL functions] or\n** [virtual tables] might change the database indirectly as a side effect.  \n** ^(For example, if an application defines a function \"eval()\" that \n** calls [sqlite3_exec()], then the following SQL statement would\n** change the database file through side-effects:\n**\n** <blockquote><pre>\n**    SELECT eval('DELETE FROM t1') FROM t2;\n** </pre></blockquote>\n**\n** But because the [SELECT] statement does not change the database file\n** directly, sqlite3_stmt_readonly() would still return true.)^\n**\n** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK],\n** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true,\n** since the statements themselves do not actually modify the database but\n** rather they control the timing of when other statements modify the \n** database.  ^The [ATTACH] and [DETACH] statements also cause\n** sqlite3_stmt_readonly() to return true since, while those statements\n** change the configuration of a database connection, they do not make \n** changes to the content of the database files on disk.\n** ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since\n** [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and\n** [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so\n** sqlite3_stmt_readonly() returns false for those commands.\n*/\nint sqlite3_stmt_readonly(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Determine If A Prepared Statement Has Been Reset\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the\n** [prepared statement] S has been stepped at least once using \n** [sqlite3_step(S)] but has neither run to completion (returned\n** [SQLITE_DONE] from [sqlite3_step(S)]) nor\n** been reset using [sqlite3_reset(S)].  ^The sqlite3_stmt_busy(S)\n** interface returns false if S is a NULL pointer.  If S is not a \n** NULL pointer and is not a pointer to a valid [prepared statement]\n** object, then the behavior is undefined and probably undesirable.\n**\n** This interface can be used in combination [sqlite3_next_stmt()]\n** to locate all prepared statements associated with a database \n** connection that are in need of being reset.  This can be used,\n** for example, in diagnostic routines to search for prepared \n** statements that are holding a transaction open.\n*/\nint sqlite3_stmt_busy(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Dynamically Typed Value Object\n** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}\n**\n** SQLite uses the sqlite3_value object to represent all values\n** that can be stored in a database table. SQLite uses dynamic typing\n** for the values it stores.  ^Values stored in sqlite3_value objects\n** can be integers, floating point values, strings, BLOBs, or NULL.\n**\n** An sqlite3_value object may be either \"protected\" or \"unprotected\".\n** Some interfaces require a protected sqlite3_value.  Other interfaces\n** will accept either a protected or an unprotected sqlite3_value.\n** Every interface that accepts sqlite3_value arguments specifies\n** whether or not it requires a protected sqlite3_value.  The\n** [sqlite3_value_dup()] interface can be used to construct a new \n** protected sqlite3_value from an unprotected sqlite3_value.\n**\n** The terms \"protected\" and \"unprotected\" refer to whether or not\n** a mutex is held.  An internal mutex is held for a protected\n** sqlite3_value object but no mutex is held for an unprotected\n** sqlite3_value object.  If SQLite is compiled to be single-threaded\n** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)\n** or if SQLite is run in one of reduced mutex modes \n** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD]\n** then there is no distinction between protected and unprotected\n** sqlite3_value objects and they can be used interchangeably.  However,\n** for maximum code portability it is recommended that applications\n** still make the distinction between protected and unprotected\n** sqlite3_value objects even when not strictly required.\n**\n** ^The sqlite3_value objects that are passed as parameters into the\n** implementation of [application-defined SQL functions] are protected.\n** ^The sqlite3_value object returned by\n** [sqlite3_column_value()] is unprotected.\n** Unprotected sqlite3_value objects may only be used as arguments\n** to [sqlite3_result_value()], [sqlite3_bind_value()], and\n** [sqlite3_value_dup()].\n** The [sqlite3_value_blob | sqlite3_value_type()] family of\n** interfaces require protected sqlite3_value objects.\n*/\ntypedef struct sqlite3_value sqlite3_value;\n\n/*\n** CAPI3REF: SQL Function Context Object\n**\n** The context in which an SQL function executes is stored in an\n** sqlite3_context object.  ^A pointer to an sqlite3_context object\n** is always first parameter to [application-defined SQL functions].\n** The application-defined SQL function implementation will pass this\n** pointer through into calls to [sqlite3_result_int | sqlite3_result()],\n** [sqlite3_aggregate_context()], [sqlite3_user_data()],\n** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],\n** and/or [sqlite3_set_auxdata()].\n*/\ntypedef struct sqlite3_context sqlite3_context;\n\n/*\n** CAPI3REF: Binding Values To Prepared Statements\n** KEYWORDS: {host parameter} {host parameters} {host parameter name}\n** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}\n** METHOD: sqlite3_stmt\n**\n** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,\n** literals may be replaced by a [parameter] that matches one of following\n** templates:\n**\n** <ul>\n** <li>  ?\n** <li>  ?NNN\n** <li>  :VVV\n** <li>  @VVV\n** <li>  $VVV\n** </ul>\n**\n** In the templates above, NNN represents an integer literal,\n** and VVV represents an alphanumeric identifier.)^  ^The values of these\n** parameters (also called \"host parameter names\" or \"SQL parameters\")\n** can be set using the sqlite3_bind_*() routines defined here.\n**\n** ^The first argument to the sqlite3_bind_*() routines is always\n** a pointer to the [sqlite3_stmt] object returned from\n** [sqlite3_prepare_v2()] or its variants.\n**\n** ^The second argument is the index of the SQL parameter to be set.\n** ^The leftmost SQL parameter has an index of 1.  ^When the same named\n** SQL parameter is used more than once, second and subsequent\n** occurrences have the same index as the first occurrence.\n** ^The index for named parameters can be looked up using the\n** [sqlite3_bind_parameter_index()] API if desired.  ^The index\n** for \"?NNN\" parameters is the value of NNN.\n** ^The NNN value must be between 1 and the [sqlite3_limit()]\n** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).\n**\n** ^The third argument is the value to bind to the parameter.\n** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter\n** is ignored and the end result is the same as sqlite3_bind_null().\n**\n** ^(In those routines that have a fourth argument, its value is the\n** number of bytes in the parameter.  To be clear: the value is the\n** number of <u>bytes</u> in the value, not the number of characters.)^\n** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()\n** is negative, then the length of the string is\n** the number of bytes up to the first zero terminator.\n** If the fourth parameter to sqlite3_bind_blob() is negative, then\n** the behavior is undefined.\n** If a non-negative fourth parameter is provided to sqlite3_bind_text()\n** or sqlite3_bind_text16() or sqlite3_bind_text64() then\n** that parameter must be the byte offset\n** where the NUL terminator would occur assuming the string were NUL\n** terminated.  If any NUL characters occur at byte offsets less than \n** the value of the fourth parameter then the resulting string value will\n** contain embedded NULs.  The result of expressions involving strings\n** with embedded NULs is undefined.\n**\n** ^The fifth argument to the BLOB and string binding interfaces\n** is a destructor used to dispose of the BLOB or\n** string after SQLite has finished with it.  ^The destructor is called\n** to dispose of the BLOB or string even if the call to bind API fails.\n** ^If the fifth argument is\n** the special value [SQLITE_STATIC], then SQLite assumes that the\n** information is in static, unmanaged space and does not need to be freed.\n** ^If the fifth argument has the value [SQLITE_TRANSIENT], then\n** SQLite makes its own private copy of the data immediately, before\n** the sqlite3_bind_*() routine returns.\n**\n** ^The sixth argument to sqlite3_bind_text64() must be one of\n** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]\n** to specify the encoding of the text in the third parameter.  If\n** the sixth argument to sqlite3_bind_text64() is not one of the\n** allowed values shown above, or if the text encoding is different\n** from the encoding specified by the sixth parameter, then the behavior\n** is undefined.\n**\n** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that\n** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory\n** (just an integer to hold its size) while it is being processed.\n** Zeroblobs are intended to serve as placeholders for BLOBs whose\n** content is later written using\n** [sqlite3_blob_open | incremental BLOB I/O] routines.\n** ^A negative value for the zeroblob results in a zero-length BLOB.\n**\n** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in\n** [prepared statement] S to have an SQL value of NULL, but to also be\n** associated with the pointer P of type T.  ^D is either a NULL pointer or\n** a pointer to a destructor function for P. ^SQLite will invoke the\n** destructor D with a single argument of P when it is finished using\n** P.  The T parameter should be a static string, preferably a string\n** literal. The sqlite3_bind_pointer() routine is part of the\n** [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer\n** for the [prepared statement] or with a prepared statement for which\n** [sqlite3_step()] has been called more recently than [sqlite3_reset()],\n** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()\n** routine is passed a [prepared statement] that has been finalized, the\n** result is undefined and probably harmful.\n**\n** ^Bindings are not cleared by the [sqlite3_reset()] routine.\n** ^Unbound parameters are interpreted as NULL.\n**\n** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an\n** [error code] if anything goes wrong.\n** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB\n** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or\n** [SQLITE_MAX_LENGTH].\n** ^[SQLITE_RANGE] is returned if the parameter\n** index is out of range.  ^[SQLITE_NOMEM] is returned if malloc() fails.\n**\n** See also: [sqlite3_bind_parameter_count()],\n** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].\n*/\nint sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));\nint sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,\n                        void(*)(void*));\nint sqlite3_bind_double(sqlite3_stmt*, int, double);\nint sqlite3_bind_int(sqlite3_stmt*, int, int);\nint sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);\nint sqlite3_bind_null(sqlite3_stmt*, int);\nint sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));\nint sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));\nint sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,\n                         void(*)(void*), unsigned char encoding);\nint sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);\nint sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));\nint sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);\nint sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);\n\n/*\n** CAPI3REF: Number Of SQL Parameters\n** METHOD: sqlite3_stmt\n**\n** ^This routine can be used to find the number of [SQL parameters]\n** in a [prepared statement].  SQL parameters are tokens of the\n** form \"?\", \"?NNN\", \":AAA\", \"$AAA\", or \"@AAA\" that serve as\n** placeholders for values that are [sqlite3_bind_blob | bound]\n** to the parameters at a later time.\n**\n** ^(This routine actually returns the index of the largest (rightmost)\n** parameter. For all forms except ?NNN, this will correspond to the\n** number of unique parameters.  If parameters of the ?NNN form are used,\n** there may be gaps in the list.)^\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_name()], and\n** [sqlite3_bind_parameter_index()].\n*/\nint sqlite3_bind_parameter_count(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Name Of A Host Parameter\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_bind_parameter_name(P,N) interface returns\n** the name of the N-th [SQL parameter] in the [prepared statement] P.\n** ^(SQL parameters of the form \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** have a name which is the string \"?NNN\" or \":AAA\" or \"@AAA\" or \"$AAA\"\n** respectively.\n** In other words, the initial \":\" or \"$\" or \"@\" or \"?\"\n** is included as part of the name.)^\n** ^Parameters of the form \"?\" without a following integer have no name\n** and are referred to as \"nameless\" or \"anonymous parameters\".\n**\n** ^The first host parameter has an index of 1, not 0.\n**\n** ^If the value N is out of range or if the N-th parameter is\n** nameless, then NULL is returned.  ^The returned string is\n** always in UTF-8 encoding even if the named parameter was\n** originally specified as UTF-16 in [sqlite3_prepare16()],\n** [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_index()].\n*/\nconst char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);\n\n/*\n** CAPI3REF: Index Of A Parameter With A Given Name\n** METHOD: sqlite3_stmt\n**\n** ^Return the index of an SQL parameter given its name.  ^The\n** index value returned is suitable for use as the second\n** parameter to [sqlite3_bind_blob|sqlite3_bind()].  ^A zero\n** is returned if no matching parameter is found.  ^The parameter\n** name must be given in UTF-8 even if the original statement\n** was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or\n** [sqlite3_prepare16_v3()].\n**\n** See also: [sqlite3_bind_blob|sqlite3_bind()],\n** [sqlite3_bind_parameter_count()], and\n** [sqlite3_bind_parameter_name()].\n*/\nint sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);\n\n/*\n** CAPI3REF: Reset All Bindings On A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset\n** the [sqlite3_bind_blob | bindings] on a [prepared statement].\n** ^Use this routine to reset all host parameters to NULL.\n*/\nint sqlite3_clear_bindings(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number Of Columns In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^Return the number of columns in the result set returned by the\n** [prepared statement]. ^If this routine returns 0, that means the \n** [prepared statement] returns no data (for example an [UPDATE]).\n** ^However, just because this routine returns a positive number does not\n** mean that one or more rows of data will be returned.  ^A SELECT statement\n** will always have a positive sqlite3_column_count() but depending on the\n** WHERE clause constraints and the table content, it might return no rows.\n**\n** See also: [sqlite3_data_count()]\n*/\nint sqlite3_column_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Column Names In A Result Set\n** METHOD: sqlite3_stmt\n**\n** ^These routines return the name assigned to a particular column\n** in the result set of a [SELECT] statement.  ^The sqlite3_column_name()\n** interface returns a pointer to a zero-terminated UTF-8 string\n** and sqlite3_column_name16() returns a pointer to a zero-terminated\n** UTF-16 string.  ^The first parameter is the [prepared statement]\n** that implements the [SELECT] statement. ^The second parameter is the\n** column number.  ^The leftmost column is number 0.\n**\n** ^The returned string pointer is valid until either the [prepared statement]\n** is destroyed by [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the next call to\n** sqlite3_column_name() or sqlite3_column_name16() on the same column.\n**\n** ^If sqlite3_malloc() fails during the processing of either routine\n** (for example during a conversion from UTF-8 to UTF-16) then a\n** NULL pointer is returned.\n**\n** ^The name of a result column is the value of the \"AS\" clause for\n** that column, if there is an AS clause.  If there is no AS clause\n** then the name of the column is unspecified and may change from\n** one release of SQLite to the next.\n*/\nconst char *sqlite3_column_name(sqlite3_stmt*, int N);\nconst void *sqlite3_column_name16(sqlite3_stmt*, int N);\n\n/*\n** CAPI3REF: Source Of Data In A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^These routines provide a means to determine the database, table, and\n** table column that is the origin of a particular result column in\n** [SELECT] statement.\n** ^The name of the database or table or column can be returned as\n** either a UTF-8 or UTF-16 string.  ^The _database_ routines return\n** the database name, the _table_ routines return the table name, and\n** the origin_ routines return the column name.\n** ^The returned string is valid until the [prepared statement] is destroyed\n** using [sqlite3_finalize()] or until the statement is automatically\n** reprepared by the first call to [sqlite3_step()] for a particular run\n** or until the same information is requested\n** again in a different encoding.\n**\n** ^The names returned are the original un-aliased names of the\n** database, table, and column.\n**\n** ^The first argument to these interfaces is a [prepared statement].\n** ^These functions return information about the Nth result column returned by\n** the statement, where N is the second function argument.\n** ^The left-most column is column 0 for these routines.\n**\n** ^If the Nth column returned by the statement is an expression or\n** subquery and is not a column value, then all of these functions return\n** NULL.  ^These routine might also return NULL if a memory allocation error\n** occurs.  ^Otherwise, they return the name of the attached database, table,\n** or column that query result column was extracted from.\n**\n** ^As with all other SQLite APIs, those whose names end with \"16\" return\n** UTF-16 encoded strings and the other functions return UTF-8.\n**\n** ^These APIs are only available if the library was compiled with the\n** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.\n**\n** If two or more threads call one or more of these routines against the same\n** prepared statement and column at the same time then the results are\n** undefined.\n**\n** If two or more threads call one or more\n** [sqlite3_column_database_name | column metadata interfaces]\n** for the same [prepared statement] and result column\n** at the same time then the results are undefined.\n*/\nconst char *sqlite3_column_database_name(sqlite3_stmt*,int);\nconst void *sqlite3_column_database_name16(sqlite3_stmt*,int);\nconst char *sqlite3_column_table_name(sqlite3_stmt*,int);\nconst void *sqlite3_column_table_name16(sqlite3_stmt*,int);\nconst char *sqlite3_column_origin_name(sqlite3_stmt*,int);\nconst void *sqlite3_column_origin_name16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Declared Datatype Of A Query Result\n** METHOD: sqlite3_stmt\n**\n** ^(The first parameter is a [prepared statement].\n** If this statement is a [SELECT] statement and the Nth column of the\n** returned result set of that [SELECT] is a table column (not an\n** expression or subquery) then the declared type of the table\n** column is returned.)^  ^If the Nth column of the result set is an\n** expression or subquery, then a NULL pointer is returned.\n** ^The returned string is always UTF-8 encoded.\n**\n** ^(For example, given the database schema:\n**\n** CREATE TABLE t1(c1 VARIANT);\n**\n** and the following statement to be compiled:\n**\n** SELECT c1 + 1, c1 FROM t1;\n**\n** this routine would return the string \"VARIANT\" for the second result\n** column (i==1), and a NULL pointer for the first result column (i==0).)^\n**\n** ^SQLite uses dynamic run-time typing.  ^So just because a column\n** is declared to contain a particular type does not mean that the\n** data stored in that column is of the declared type.  SQLite is\n** strongly typed, but the typing is dynamic not static.  ^Type\n** is associated with individual values, not with the containers\n** used to hold those values.\n*/\nconst char *sqlite3_column_decltype(sqlite3_stmt*,int);\nconst void *sqlite3_column_decltype16(sqlite3_stmt*,int);\n\n/*\n** CAPI3REF: Evaluate An SQL Statement\n** METHOD: sqlite3_stmt\n**\n** After a [prepared statement] has been prepared using any of\n** [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()],\n** or [sqlite3_prepare16_v3()] or one of the legacy\n** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function\n** must be called one or more times to evaluate the statement.\n**\n** The details of the behavior of the sqlite3_step() interface depend\n** on whether the statement was prepared using the newer \"vX\" interfaces\n** [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()],\n** [sqlite3_prepare16_v2()] or the older legacy\n** interfaces [sqlite3_prepare()] and [sqlite3_prepare16()].  The use of the\n** new \"vX\" interface is recommended for new applications but the legacy\n** interface will continue to be supported.\n**\n** ^In the legacy interface, the return value will be either [SQLITE_BUSY],\n** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].\n** ^With the \"v2\" interface, any of the other [result codes] or\n** [extended result codes] might be returned as well.\n**\n** ^[SQLITE_BUSY] means that the database engine was unable to acquire the\n** database locks it needs to do its job.  ^If the statement is a [COMMIT]\n** or occurs outside of an explicit transaction, then you can retry the\n** statement.  If the statement is not a [COMMIT] and occurs within an\n** explicit transaction then you should rollback the transaction before\n** continuing.\n**\n** ^[SQLITE_DONE] means that the statement has finished executing\n** successfully.  sqlite3_step() should not be called again on this virtual\n** machine without first calling [sqlite3_reset()] to reset the virtual\n** machine back to its initial state.\n**\n** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]\n** is returned each time a new row of data is ready for processing by the\n** caller. The values may be accessed using the [column access functions].\n** sqlite3_step() is called again to retrieve the next row of data.\n**\n** ^[SQLITE_ERROR] means that a run-time error (such as a constraint\n** violation) has occurred.  sqlite3_step() should not be called again on\n** the VM. More information may be found by calling [sqlite3_errmsg()].\n** ^With the legacy interface, a more specific error code (for example,\n** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)\n** can be obtained by calling [sqlite3_reset()] on the\n** [prepared statement].  ^In the \"v2\" interface,\n** the more specific error code is returned directly by sqlite3_step().\n**\n** [SQLITE_MISUSE] means that the this routine was called inappropriately.\n** Perhaps it was called on a [prepared statement] that has\n** already been [sqlite3_finalize | finalized] or on one that had\n** previously returned [SQLITE_ERROR] or [SQLITE_DONE].  Or it could\n** be the case that the same database connection is being used by two or\n** more threads at the same moment in time.\n**\n** For all versions of SQLite up to and including 3.6.23.1, a call to\n** [sqlite3_reset()] was required after sqlite3_step() returned anything\n** other than [SQLITE_ROW] before any subsequent invocation of\n** sqlite3_step().  Failure to reset the prepared statement using \n** [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from\n** sqlite3_step().  But after [version 3.6.23.1] ([dateof:3.6.23.1],\n** sqlite3_step() began\n** calling [sqlite3_reset()] automatically in this circumstance rather\n** than returning [SQLITE_MISUSE].  This is not considered a compatibility\n** break because any application that ever receives an SQLITE_MISUSE error\n** is broken by definition.  The [SQLITE_OMIT_AUTORESET] compile-time option\n** can be used to restore the legacy behavior.\n**\n** <b>Goofy Interface Alert:</b> In the legacy interface, the sqlite3_step()\n** API always returns a generic error code, [SQLITE_ERROR], following any\n** error other than [SQLITE_BUSY] and [SQLITE_MISUSE].  You must call\n** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the\n** specific [error codes] that better describes the error.\n** We admit that this is a goofy design.  The problem has been fixed\n** with the \"v2\" interface.  If you prepare all of your SQL statements\n** using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()]\n** or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead\n** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,\n** then the more specific [error codes] are returned directly\n** by sqlite3_step().  The use of the \"vX\" interfaces is recommended.\n*/\nint sqlite3_step(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Number of columns in a result set\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_data_count(P) interface returns the number of columns in the\n** current row of the result set of [prepared statement] P.\n** ^If prepared statement P does not have results ready to return\n** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of\n** interfaces) then sqlite3_data_count(P) returns 0.\n** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.\n** ^The sqlite3_data_count(P) routine returns 0 if the previous call to\n** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)\n** will return non-zero if previous call to [sqlite3_step](P) returned\n** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]\n** where it always returns zero since each step of that multi-step\n** pragma returns 0 columns of data.\n**\n** See also: [sqlite3_column_count()]\n*/\nint sqlite3_data_count(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Fundamental Datatypes\n** KEYWORDS: SQLITE_TEXT\n**\n** ^(Every value in SQLite has one of five fundamental datatypes:\n**\n** <ul>\n** <li> 64-bit signed integer\n** <li> 64-bit IEEE floating point number\n** <li> string\n** <li> BLOB\n** <li> NULL\n** </ul>)^\n**\n** These constants are codes for each of those types.\n**\n** Note that the SQLITE_TEXT constant was also used in SQLite version 2\n** for a completely different meaning.  Software that links against both\n** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not\n** SQLITE_TEXT.\n*/\n#define SQLITE_INTEGER  1\n#define SQLITE_FLOAT    2\n#define SQLITE_BLOB     4\n#define SQLITE_NULL     5\n#ifdef SQLITE_TEXT\n# undef SQLITE_TEXT\n#else\n# define SQLITE_TEXT     3\n#endif\n#define SQLITE3_TEXT     3\n\n/*\n** CAPI3REF: Result Values From A Query\n** KEYWORDS: {column access functions}\n** METHOD: sqlite3_stmt\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_column_blob</b><td>&rarr;<td>BLOB result\n** <tr><td><b>sqlite3_column_double</b><td>&rarr;<td>REAL result\n** <tr><td><b>sqlite3_column_int</b><td>&rarr;<td>32-bit INTEGER result\n** <tr><td><b>sqlite3_column_int64</b><td>&rarr;<td>64-bit INTEGER result\n** <tr><td><b>sqlite3_column_text</b><td>&rarr;<td>UTF-8 TEXT result\n** <tr><td><b>sqlite3_column_text16</b><td>&rarr;<td>UTF-16 TEXT result\n** <tr><td><b>sqlite3_column_value</b><td>&rarr;<td>The result as an \n** [sqlite3_value|unprotected sqlite3_value] object.\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_column_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT result in bytes\n** <tr><td><b>sqlite3_column_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_column_type</b><td>&rarr;<td>Default\n** datatype of the result\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** ^These routines return information about a single column of the current\n** result row of a query.  ^In every case the first argument is a pointer\n** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]\n** that was returned from [sqlite3_prepare_v2()] or one of its variants)\n** and the second argument is the index of the column for which information\n** should be returned. ^The leftmost column of the result set has the index 0.\n** ^The number of columns in the result can be determined using\n** [sqlite3_column_count()].\n**\n** If the SQL statement does not currently point to a valid row, or if the\n** column index is out of range, the result is undefined.\n** These routines may only be called when the most recent call to\n** [sqlite3_step()] has returned [SQLITE_ROW] and neither\n** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently.\n** If any of these routines are called after [sqlite3_reset()] or\n** [sqlite3_finalize()] or after [sqlite3_step()] has returned\n** something other than [SQLITE_ROW], the results are undefined.\n** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]\n** are called from a different thread while any of these routines\n** are pending, then the results are undefined.\n**\n** The first six interfaces (_blob, _double, _int, _int64, _text, and _text16)\n** each return the value of a result column in a specific data format.  If\n** the result column is not initially in the requested format (for example,\n** if the query returns an integer but the sqlite3_column_text() interface\n** is used to extract the value) then an automatic type conversion is performed.\n**\n** ^The sqlite3_column_type() routine returns the\n** [SQLITE_INTEGER | datatype code] for the initial data type\n** of the result column.  ^The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].\n** The return value of sqlite3_column_type() can be used to decide which\n** of the first six interface should be used to extract the column value.\n** The value returned by sqlite3_column_type() is only meaningful if no\n** automatic type conversions have occurred for the value in question.  \n** After a type conversion, the result of calling sqlite3_column_type()\n** is undefined, though harmless.  Future\n** versions of SQLite may change the behavior of sqlite3_column_type()\n** following a type conversion.\n**\n** If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes()\n** or sqlite3_column_bytes16() interfaces can be used to determine the size\n** of that BLOB or string.\n**\n** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts\n** the string to UTF-8 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes() returns zero.\n**\n** ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16()\n** routine returns the number of bytes in that BLOB or string.\n** ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts\n** the string to UTF-16 and then returns the number of bytes.\n** ^If the result is a numeric value then sqlite3_column_bytes16() uses\n** [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns\n** the number of bytes in that string.\n** ^If the result is NULL, then sqlite3_column_bytes16() returns zero.\n**\n** ^The values returned by [sqlite3_column_bytes()] and \n** [sqlite3_column_bytes16()] do not include the zero terminators at the end\n** of the string.  ^For clarity: the values returned by\n** [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of\n** bytes in the string, not the number of characters.\n**\n** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),\n** even empty strings, are always zero-terminated.  ^The return\n** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.\n**\n** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an\n** [unprotected sqlite3_value] object.  In a multithreaded environment,\n** an unprotected sqlite3_value object may only be used safely with\n** [sqlite3_bind_value()] and [sqlite3_result_value()].\n** If the [unprotected sqlite3_value] object returned by\n** [sqlite3_column_value()] is used in any other way, including calls\n** to routines like [sqlite3_value_int()], [sqlite3_value_text()],\n** or [sqlite3_value_bytes()], the behavior is not threadsafe.\n** Hence, the sqlite3_column_value() interface\n** is normally only useful within the implementation of \n** [application-defined SQL functions] or [virtual tables], not within\n** top-level application code.\n**\n** The these routines may attempt to convert the datatype of the result.\n** ^For example, if the internal representation is FLOAT and a text result\n** is requested, [sqlite3_snprintf()] is used internally to perform the\n** conversion automatically.  ^(The following table details the conversions\n** that are applied:\n**\n** <blockquote>\n** <table border=\"1\">\n** <tr><th> Internal<br>Type <th> Requested<br>Type <th>  Conversion\n**\n** <tr><td>  NULL    <td> INTEGER   <td> Result is 0\n** <tr><td>  NULL    <td>  FLOAT    <td> Result is 0.0\n** <tr><td>  NULL    <td>   TEXT    <td> Result is a NULL pointer\n** <tr><td>  NULL    <td>   BLOB    <td> Result is a NULL pointer\n** <tr><td> INTEGER  <td>  FLOAT    <td> Convert from integer to float\n** <tr><td> INTEGER  <td>   TEXT    <td> ASCII rendering of the integer\n** <tr><td> INTEGER  <td>   BLOB    <td> Same as INTEGER->TEXT\n** <tr><td>  FLOAT   <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  FLOAT   <td>   TEXT    <td> ASCII rendering of the float\n** <tr><td>  FLOAT   <td>   BLOB    <td> [CAST] to BLOB\n** <tr><td>  TEXT    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  TEXT    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  TEXT    <td>   BLOB    <td> No change\n** <tr><td>  BLOB    <td> INTEGER   <td> [CAST] to INTEGER\n** <tr><td>  BLOB    <td>  FLOAT    <td> [CAST] to REAL\n** <tr><td>  BLOB    <td>   TEXT    <td> Add a zero terminator if needed\n** </table>\n** </blockquote>)^\n**\n** Note that when type conversions occur, pointers returned by prior\n** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or\n** sqlite3_column_text16() may be invalidated.\n** Type conversions and pointer invalidations might occur\n** in the following cases:\n**\n** <ul>\n** <li> The initial content is a BLOB and sqlite3_column_text() or\n**      sqlite3_column_text16() is called.  A zero-terminator might\n**      need to be added to the string.</li>\n** <li> The initial content is UTF-8 text and sqlite3_column_bytes16() or\n**      sqlite3_column_text16() is called.  The content must be converted\n**      to UTF-16.</li>\n** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or\n**      sqlite3_column_text() is called.  The content must be converted\n**      to UTF-8.</li>\n** </ul>\n**\n** ^Conversions between UTF-16be and UTF-16le are always done in place and do\n** not invalidate a prior pointer, though of course the content of the buffer\n** that the prior pointer references will have been modified.  Other kinds\n** of conversion are done in place when it is possible, but sometimes they\n** are not possible and in those cases prior pointers are invalidated.\n**\n** The safest policy is to invoke these routines\n** in one of the following ways:\n**\n** <ul>\n**  <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>\n**  <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>\n** </ul>\n**\n** In other words, you should call sqlite3_column_text(),\n** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result\n** into the desired format, then invoke sqlite3_column_bytes() or\n** sqlite3_column_bytes16() to find the size of the result.  Do not mix calls\n** to sqlite3_column_text() or sqlite3_column_blob() with calls to\n** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()\n** with calls to sqlite3_column_bytes().\n**\n** ^The pointers returned are valid until a type conversion occurs as\n** described above, or until [sqlite3_step()] or [sqlite3_reset()] or\n** [sqlite3_finalize()] is called.  ^The memory space used to hold strings\n** and BLOBs is freed automatically.  Do not pass the pointers returned\n** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into\n** [sqlite3_free()].\n**\n** ^(If a memory allocation error occurs during the evaluation of any\n** of these routines, a default value is returned.  The default value\n** is either the integer 0, the floating point number 0.0, or a NULL\n** pointer.  Subsequent calls to [sqlite3_errcode()] will return\n** [SQLITE_NOMEM].)^\n*/\nconst void *sqlite3_column_blob(sqlite3_stmt*, int iCol);\ndouble sqlite3_column_double(sqlite3_stmt*, int iCol);\nint sqlite3_column_int(sqlite3_stmt*, int iCol);\nsqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);\nconst unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);\nconst void *sqlite3_column_text16(sqlite3_stmt*, int iCol);\nsqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);\nint sqlite3_column_bytes(sqlite3_stmt*, int iCol);\nint sqlite3_column_bytes16(sqlite3_stmt*, int iCol);\nint sqlite3_column_type(sqlite3_stmt*, int iCol);\n\n/*\n** CAPI3REF: Destroy A Prepared Statement Object\n** DESTRUCTOR: sqlite3_stmt\n**\n** ^The sqlite3_finalize() function is called to delete a [prepared statement].\n** ^If the most recent evaluation of the statement encountered no errors\n** or if the statement is never been evaluated, then sqlite3_finalize() returns\n** SQLITE_OK.  ^If the most recent evaluation of statement S failed, then\n** sqlite3_finalize(S) returns the appropriate [error code] or\n** [extended error code].\n**\n** ^The sqlite3_finalize(S) routine can be called at any point during\n** the life cycle of [prepared statement] S:\n** before statement S is ever evaluated, after\n** one or more calls to [sqlite3_reset()], or after any call\n** to [sqlite3_step()] regardless of whether or not the statement has\n** completed execution.\n**\n** ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op.\n**\n** The application must finalize every [prepared statement] in order to avoid\n** resource leaks.  It is a grievous error for the application to try to use\n** a prepared statement after it has been finalized.  Any use of a prepared\n** statement after it has been finalized can result in undefined and\n** undesirable behavior such as segfaults and heap corruption.\n*/\nint sqlite3_finalize(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Reset A Prepared Statement Object\n** METHOD: sqlite3_stmt\n**\n** The sqlite3_reset() function is called to reset a [prepared statement]\n** object back to its initial state, ready to be re-executed.\n** ^Any SQL statement variables that had values bound to them using\n** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.\n** Use [sqlite3_clear_bindings()] to reset the bindings.\n**\n** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S\n** back to the beginning of its program.\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],\n** or if [sqlite3_step(S)] has never before been called on S,\n** then [sqlite3_reset(S)] returns [SQLITE_OK].\n**\n** ^If the most recent call to [sqlite3_step(S)] for the\n** [prepared statement] S indicated an error, then\n** [sqlite3_reset(S)] returns an appropriate [error code].\n**\n** ^The [sqlite3_reset(S)] interface does not change the values\n** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.\n*/\nint sqlite3_reset(sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Create Or Redefine SQL Functions\n** KEYWORDS: {function creation routines}\n** KEYWORDS: {application-defined SQL function}\n** KEYWORDS: {application-defined SQL functions}\n** METHOD: sqlite3\n**\n** ^These functions (collectively known as \"function creation routines\")\n** are used to add SQL functions or aggregates or to redefine the behavior\n** of existing SQL functions or aggregates.  The only differences between\n** these routines are the text encoding expected for\n** the second parameter (the name of the function being created)\n** and the presence or absence of a destructor callback for\n** the application data pointer.\n**\n** ^The first parameter is the [database connection] to which the SQL\n** function is to be added.  ^If an application uses more than one database\n** connection then application-defined SQL functions must be added\n** to each database connection separately.\n**\n** ^The second parameter is the name of the SQL function to be created or\n** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8\n** representation, exclusive of the zero-terminator.  ^Note that the name\n** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  \n** ^Any attempt to create a function with a longer name\n** will result in [SQLITE_MISUSE] being returned.\n**\n** ^The third parameter (nArg)\n** is the number of arguments that the SQL function or\n** aggregate takes. ^If this parameter is -1, then the SQL function or\n** aggregate may take any number of arguments between 0 and the limit\n** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]).  If the third\n** parameter is less than -1 or greater than 127 then the behavior is\n** undefined.\n**\n** ^The fourth parameter, eTextRep, specifies what\n** [SQLITE_UTF8 | text encoding] this SQL function prefers for\n** its parameters.  The application should set this parameter to\n** [SQLITE_UTF16LE] if the function implementation invokes \n** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the\n** implementation invokes [sqlite3_value_text16be()] on an input, or\n** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]\n** otherwise.  ^The same SQL function may be registered multiple times using\n** different preferred text encodings, with different implementations for\n** each encoding.\n** ^When multiple implementations of the same function are available, SQLite\n** will pick the one that involves the least amount of data conversion.\n**\n** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]\n** to signal that the function will always return the same result given\n** the same inputs within a single SQL statement.  Most SQL functions are\n** deterministic.  The built-in [random()] SQL function is an example of a\n** function that is not deterministic.  The SQLite query planner is able to\n** perform additional optimizations on deterministic functions, so use\n** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.\n**\n** ^(The fifth parameter is an arbitrary pointer.  The implementation of the\n** function can gain access to this pointer using [sqlite3_user_data()].)^\n**\n** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are\n** pointers to C-language functions that implement the SQL function or\n** aggregate. ^A scalar SQL function requires an implementation of the xFunc\n** callback only; NULL pointers must be passed as the xStep and xFinal\n** parameters. ^An aggregate SQL function requires an implementation of xStep\n** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing\n** SQL function or aggregate, pass NULL pointers for all three function\n** callbacks.\n**\n** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,\n** then it is destructor for the application data pointer. \n** The destructor is invoked when the function is deleted, either by being\n** overloaded or when the database connection closes.)^\n** ^The destructor is also invoked if the call to\n** sqlite3_create_function_v2() fails.\n** ^When the destructor callback of the tenth parameter is invoked, it\n** is passed a single argument which is a copy of the application data \n** pointer which was the fifth parameter to sqlite3_create_function_v2().\n**\n** ^It is permitted to register multiple implementations of the same\n** functions with the same name but with either differing numbers of\n** arguments or differing preferred text encodings.  ^SQLite will use\n** the implementation that most closely matches the way in which the\n** SQL function is used.  ^A function implementation with a non-negative\n** nArg parameter is a better match than a function implementation with\n** a negative nArg.  ^A function where the preferred text encoding\n** matches the database encoding is a better\n** match than a function where the encoding is different.  \n** ^A function where the encoding difference is between UTF16le and UTF16be\n** is a closer match than a function where the encoding difference is\n** between UTF8 and UTF16.\n**\n** ^Built-in functions may be overloaded by new application-defined functions.\n**\n** ^An application-defined function is permitted to call other\n** SQLite interfaces.  However, such calls must not\n** close the database connection nor finalize or reset the prepared\n** statement in which the function is running.\n*/\nint sqlite3_create_function(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nint sqlite3_create_function16(\n  sqlite3 *db,\n  const void *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*)\n);\nint sqlite3_create_function_v2(\n  sqlite3 *db,\n  const char *zFunctionName,\n  int nArg,\n  int eTextRep,\n  void *pApp,\n  void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n  void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n  void (*xFinal)(sqlite3_context*),\n  void(*xDestroy)(void*)\n);\n\n/*\n** CAPI3REF: Text Encodings\n**\n** These constant define integer codes that represent the various\n** text encodings supported by SQLite.\n*/\n#define SQLITE_UTF8           1    /* IMP: R-37514-35566 */\n#define SQLITE_UTF16LE        2    /* IMP: R-03371-37637 */\n#define SQLITE_UTF16BE        3    /* IMP: R-51971-34154 */\n#define SQLITE_UTF16          4    /* Use native byte order */\n#define SQLITE_ANY            5    /* Deprecated */\n#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */\n\n/*\n** CAPI3REF: Function Flags\n**\n** These constants may be ORed together with the \n** [SQLITE_UTF8 | preferred text encoding] as the fourth argument\n** to [sqlite3_create_function()], [sqlite3_create_function16()], or\n** [sqlite3_create_function_v2()].\n*/\n#define SQLITE_DETERMINISTIC    0x800\n\n/*\n** CAPI3REF: Deprecated Functions\n** DEPRECATED\n**\n** These functions are [deprecated].  In order to maintain\n** backwards compatibility with older code, these functions continue \n** to be supported.  However, new applications should avoid\n** the use of these functions.  To encourage programmers to avoid\n** these functions, we will not explain what they do.\n*/\n#ifndef SQLITE_OMIT_DEPRECATED\nSQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);\nSQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);\nSQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);\nSQLITE_DEPRECATED int sqlite3_global_recover(void);\nSQLITE_DEPRECATED void sqlite3_thread_cleanup(void);\nSQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),\n                      void*,sqlite3_int64);\n#endif\n\n/*\n** CAPI3REF: Obtaining SQL Values\n** METHOD: sqlite3_value\n**\n** <b>Summary:</b>\n** <blockquote><table border=0 cellpadding=0 cellspacing=0>\n** <tr><td><b>sqlite3_value_blob</b><td>&rarr;<td>BLOB value\n** <tr><td><b>sqlite3_value_double</b><td>&rarr;<td>REAL value\n** <tr><td><b>sqlite3_value_int</b><td>&rarr;<td>32-bit INTEGER value\n** <tr><td><b>sqlite3_value_int64</b><td>&rarr;<td>64-bit INTEGER value\n** <tr><td><b>sqlite3_value_pointer</b><td>&rarr;<td>Pointer value\n** <tr><td><b>sqlite3_value_text</b><td>&rarr;<td>UTF-8 TEXT value\n** <tr><td><b>sqlite3_value_text16</b><td>&rarr;<td>UTF-16 TEXT value in\n** the native byteorder\n** <tr><td><b>sqlite3_value_text16be</b><td>&rarr;<td>UTF-16be TEXT value\n** <tr><td><b>sqlite3_value_text16le</b><td>&rarr;<td>UTF-16le TEXT value\n** <tr><td>&nbsp;<td>&nbsp;<td>&nbsp;\n** <tr><td><b>sqlite3_value_bytes</b><td>&rarr;<td>Size of a BLOB\n** or a UTF-8 TEXT in bytes\n** <tr><td><b>sqlite3_value_bytes16&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Size of UTF-16\n** TEXT in bytes\n** <tr><td><b>sqlite3_value_type</b><td>&rarr;<td>Default\n** datatype of the value\n** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>\n** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value\n** </table></blockquote>\n**\n** <b>Details:</b>\n**\n** These routines extract type, size, and content information from\n** [protected sqlite3_value] objects.  Protected sqlite3_value objects\n** are used to pass parameter information into implementation of\n** [application-defined SQL functions] and [virtual tables].\n**\n** These routines work only with [protected sqlite3_value] objects.\n** Any attempt to use these routines on an [unprotected sqlite3_value]\n** is not threadsafe.\n**\n** ^These routines work just like the corresponding [column access functions]\n** except that these routines take a single [protected sqlite3_value] object\n** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.\n**\n** ^The sqlite3_value_text16() interface extracts a UTF-16 string\n** in the native byte-order of the host machine.  ^The\n** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces\n** extract UTF-16 strings as big-endian and little-endian respectively.\n**\n** ^If [sqlite3_value] object V was initialized \n** using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)]\n** and if X and Y are strings that compare equal according to strcmp(X,Y),\n** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,\n** sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() \n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** ^(The sqlite3_value_type(V) interface returns the\n** [SQLITE_INTEGER | datatype code] for the initial datatype of the\n** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],\n** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^\n** Other interfaces might change the datatype for an sqlite3_value object.\n** For example, if the datatype is initially SQLITE_INTEGER and\n** sqlite3_value_text(V) is called to extract a text value for that\n** integer, then subsequent calls to sqlite3_value_type(V) might return\n** SQLITE_TEXT.  Whether or not a persistent internal datatype conversion\n** occurs is undefined and may change from one release of SQLite to the next.\n**\n** ^(The sqlite3_value_numeric_type() interface attempts to apply\n** numeric affinity to the value.  This means that an attempt is\n** made to convert the value to an integer or floating point.  If\n** such a conversion is possible without loss of information (in other\n** words, if the value is a string that looks like a number)\n** then the conversion is performed.  Otherwise no conversion occurs.\n** The [SQLITE_INTEGER | datatype] after conversion is returned.)^\n**\n** Please pay particular attention to the fact that the pointer returned\n** from [sqlite3_value_blob()], [sqlite3_value_text()], or\n** [sqlite3_value_text16()] can be invalidated by a subsequent call to\n** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],\n** or [sqlite3_value_text16()].\n**\n** These routines must be called from the same thread as\n** the SQL function that supplied the [sqlite3_value*] parameters.\n*/\nconst void *sqlite3_value_blob(sqlite3_value*);\ndouble sqlite3_value_double(sqlite3_value*);\nint sqlite3_value_int(sqlite3_value*);\nsqlite3_int64 sqlite3_value_int64(sqlite3_value*);\nvoid *sqlite3_value_pointer(sqlite3_value*, const char*);\nconst unsigned char *sqlite3_value_text(sqlite3_value*);\nconst void *sqlite3_value_text16(sqlite3_value*);\nconst void *sqlite3_value_text16le(sqlite3_value*);\nconst void *sqlite3_value_text16be(sqlite3_value*);\nint sqlite3_value_bytes(sqlite3_value*);\nint sqlite3_value_bytes16(sqlite3_value*);\nint sqlite3_value_type(sqlite3_value*);\nint sqlite3_value_numeric_type(sqlite3_value*);\n\n/*\n** CAPI3REF: Finding The Subtype Of SQL Values\n** METHOD: sqlite3_value\n**\n** The sqlite3_value_subtype(V) function returns the subtype for\n** an [application-defined SQL function] argument V.  The subtype\n** information can be used to pass a limited amount of context from\n** one SQL function to another.  Use the [sqlite3_result_subtype()]\n** routine to set the subtype for the return value of an SQL function.\n*/\nunsigned int sqlite3_value_subtype(sqlite3_value*);\n\n/*\n** CAPI3REF: Copy And Free SQL Values\n** METHOD: sqlite3_value\n**\n** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value]\n** object D and returns a pointer to that copy.  ^The [sqlite3_value] returned\n** is a [protected sqlite3_value] object even if the input is not.\n** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a\n** memory allocation fails.\n**\n** ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object\n** previously obtained from [sqlite3_value_dup()].  ^If V is a NULL pointer\n** then sqlite3_value_free(V) is a harmless no-op.\n*/\nsqlite3_value *sqlite3_value_dup(const sqlite3_value*);\nvoid sqlite3_value_free(sqlite3_value*);\n\n/*\n** CAPI3REF: Obtain Aggregate Function Context\n** METHOD: sqlite3_context\n**\n** Implementations of aggregate SQL functions use this\n** routine to allocate memory for storing their state.\n**\n** ^The first time the sqlite3_aggregate_context(C,N) routine is called \n** for a particular aggregate function, SQLite\n** allocates N of memory, zeroes out that memory, and returns a pointer\n** to the new memory. ^On second and subsequent calls to\n** sqlite3_aggregate_context() for the same aggregate function instance,\n** the same buffer is returned.  Sqlite3_aggregate_context() is normally\n** called once for each invocation of the xStep callback and then one\n** last time when the xFinal callback is invoked.  ^(When no rows match\n** an aggregate query, the xStep() callback of the aggregate function\n** implementation is never called and xFinal() is called exactly once.\n** In those cases, sqlite3_aggregate_context() might be called for the\n** first time from within xFinal().)^\n**\n** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer \n** when first called if N is less than or equal to zero or if a memory\n** allocate error occurs.\n**\n** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is\n** determined by the N parameter on first successful call.  Changing the\n** value of N in subsequent call to sqlite3_aggregate_context() within\n** the same aggregate function instance will not resize the memory\n** allocation.)^  Within the xFinal callback, it is customary to set\n** N=0 in calls to sqlite3_aggregate_context(C,N) so that no \n** pointless memory allocations occur.\n**\n** ^SQLite automatically frees the memory allocated by \n** sqlite3_aggregate_context() when the aggregate query concludes.\n**\n** The first parameter must be a copy of the\n** [sqlite3_context | SQL function context] that is the first parameter\n** to the xStep or xFinal callback routine that implements the aggregate\n** function.\n**\n** This routine must be called from the same thread in which\n** the aggregate SQL function is running.\n*/\nvoid *sqlite3_aggregate_context(sqlite3_context*, int nBytes);\n\n/*\n** CAPI3REF: User Data For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_user_data() interface returns a copy of\n** the pointer that was the pUserData parameter (the 5th parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n**\n** This routine must be called from the same thread in which\n** the application-defined function is running.\n*/\nvoid *sqlite3_user_data(sqlite3_context*);\n\n/*\n** CAPI3REF: Database Connection For Functions\n** METHOD: sqlite3_context\n**\n** ^The sqlite3_context_db_handle() interface returns a copy of\n** the pointer to the [database connection] (the 1st parameter)\n** of the [sqlite3_create_function()]\n** and [sqlite3_create_function16()] routines that originally\n** registered the application defined function.\n*/\nsqlite3 *sqlite3_context_db_handle(sqlite3_context*);\n\n/*\n** CAPI3REF: Function Auxiliary Data\n** METHOD: sqlite3_context\n**\n** These functions may be used by (non-aggregate) SQL functions to\n** associate metadata with argument values. If the same value is passed to\n** multiple invocations of the same SQL function during query execution, under\n** some circumstances the associated metadata may be preserved.  An example\n** of where this might be useful is in a regular-expression matching\n** function. The compiled version of the regular expression can be stored as\n** metadata associated with the pattern string.  \n** Then as long as the pattern string remains the same,\n** the compiled regular expression can be reused on multiple\n** invocations of the same function.\n**\n** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata\n** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument\n** value to the application-defined function.  ^N is zero for the left-most\n** function argument.  ^If there is no metadata\n** associated with the function argument, the sqlite3_get_auxdata(C,N) interface\n** returns a NULL pointer.\n**\n** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th\n** argument of the application-defined function.  ^Subsequent\n** calls to sqlite3_get_auxdata(C,N) return P from the most recent\n** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or\n** NULL if the metadata has been discarded.\n** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,\n** SQLite will invoke the destructor function X with parameter P exactly\n** once, when the metadata is discarded.\n** SQLite is free to discard the metadata at any time, including: <ul>\n** <li> ^(when the corresponding function parameter changes)^, or\n** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the\n**      SQL statement)^, or\n** <li> ^(when sqlite3_set_auxdata() is invoked again on the same\n**       parameter)^, or\n** <li> ^(during the original sqlite3_set_auxdata() call when a memory \n**      allocation error occurs.)^ </ul>\n**\n** Note the last bullet in particular.  The destructor X in \n** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the\n** sqlite3_set_auxdata() interface even returns.  Hence sqlite3_set_auxdata()\n** should be called near the end of the function implementation and the\n** function implementation should not make any use of P after\n** sqlite3_set_auxdata() has been called.\n**\n** ^(In practice, metadata is preserved between function calls for\n** function parameters that are compile-time constants, including literal\n** values and [parameters] and expressions composed from the same.)^\n**\n** The value of the N parameter to these interfaces should be non-negative.\n** Future enhancements may make use of negative N values to define new\n** kinds of function caching behavior.\n**\n** These routines must be called from the same thread in which\n** the SQL function is running.\n*/\nvoid *sqlite3_get_auxdata(sqlite3_context*, int N);\nvoid sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));\n\n\n/*\n** CAPI3REF: Constants Defining Special Destructor Behavior\n**\n** These are special values for the destructor that is passed in as the\n** final argument to routines like [sqlite3_result_blob()].  ^If the destructor\n** argument is SQLITE_STATIC, it means that the content pointer is constant\n** and will never change.  It does not need to be destroyed.  ^The\n** SQLITE_TRANSIENT value means that the content will likely change in\n** the near future and that SQLite should make its own private copy of\n** the content before returning.\n**\n** The typedef is necessary to work around problems in certain\n** C++ compilers.\n*/\ntypedef void (*sqlite3_destructor_type)(void*);\n#define SQLITE_STATIC      ((sqlite3_destructor_type)0)\n#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)\n\n/*\n** CAPI3REF: Setting The Result Of An SQL Function\n** METHOD: sqlite3_context\n**\n** These routines are used by the xFunc or xFinal callbacks that\n** implement SQL functions and aggregates.  See\n** [sqlite3_create_function()] and [sqlite3_create_function16()]\n** for additional information.\n**\n** These functions work very much like the [parameter binding] family of\n** functions used to bind values to host parameters in prepared statements.\n** Refer to the [SQL parameter] documentation for additional information.\n**\n** ^The sqlite3_result_blob() interface sets the result from\n** an application-defined function to be the BLOB whose content is pointed\n** to by the second parameter and which is N bytes long where N is the\n** third parameter.\n**\n** ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N)\n** interfaces set the result of the application-defined function to be\n** a BLOB containing all zero bytes and N bytes in size.\n**\n** ^The sqlite3_result_double() interface sets the result from\n** an application-defined function to be a floating point value specified\n** by its 2nd argument.\n**\n** ^The sqlite3_result_error() and sqlite3_result_error16() functions\n** cause the implemented SQL function to throw an exception.\n** ^SQLite uses the string pointed to by the\n** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()\n** as the text of an error message.  ^SQLite interprets the error\n** message string from sqlite3_result_error() as UTF-8. ^SQLite\n** interprets the string from sqlite3_result_error16() as UTF-16 in native\n** byte order.  ^If the third parameter to sqlite3_result_error()\n** or sqlite3_result_error16() is negative then SQLite takes as the error\n** message all text up through the first zero character.\n** ^If the third parameter to sqlite3_result_error() or\n** sqlite3_result_error16() is non-negative then SQLite takes that many\n** bytes (not characters) from the 2nd parameter as the error message.\n** ^The sqlite3_result_error() and sqlite3_result_error16()\n** routines make a private copy of the error message text before\n** they return.  Hence, the calling function can deallocate or\n** modify the text after they return without harm.\n** ^The sqlite3_result_error_code() function changes the error code\n** returned by SQLite as a result of an error in a function.  ^By default,\n** the error code is SQLITE_ERROR.  ^A subsequent call to sqlite3_result_error()\n** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.\n**\n** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an\n** error indicating that a string or BLOB is too long to represent.\n**\n** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an\n** error indicating that a memory allocation failed.\n**\n** ^The sqlite3_result_int() interface sets the return value\n** of the application-defined function to be the 32-bit signed integer\n** value given in the 2nd argument.\n** ^The sqlite3_result_int64() interface sets the return value\n** of the application-defined function to be the 64-bit signed integer\n** value given in the 2nd argument.\n**\n** ^The sqlite3_result_null() interface sets the return value\n** of the application-defined function to be NULL.\n**\n** ^The sqlite3_result_text(), sqlite3_result_text16(),\n** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces\n** set the return value of the application-defined function to be\n** a text string which is represented as UTF-8, UTF-16 native byte order,\n** UTF-16 little endian, or UTF-16 big endian, respectively.\n** ^The sqlite3_result_text64() interface sets the return value of an\n** application-defined function to be a text string in an encoding\n** specified by the fifth (and last) parameter, which must be one\n** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].\n** ^SQLite takes the text result from the application from\n** the 2nd parameter of the sqlite3_result_text* interfaces.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is negative, then SQLite takes result text from the 2nd parameter\n** through the first zero character.\n** ^If the 3rd parameter to the sqlite3_result_text* interfaces\n** is non-negative, then as many bytes (not characters) of the text\n** pointed to by the 2nd parameter are taken as the application-defined\n** function result.  If the 3rd parameter is non-negative, then it\n** must be the byte offset into the string where the NUL terminator would\n** appear if the string where NUL terminated.  If any NUL characters occur\n** in the string at a byte offset that is less than the value of the 3rd\n** parameter, then the resulting string will contain embedded NULs and the\n** result of expressions operating on strings with embedded NULs is undefined.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that\n** function as the destructor on the text or BLOB result when it has\n** finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces or to\n** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite\n** assumes that the text or BLOB result is in constant space and does not\n** copy the content of the parameter nor call a destructor on the content\n** when it has finished using that result.\n** ^If the 4th parameter to the sqlite3_result_text* interfaces\n** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT\n** then SQLite makes a copy of the result into space obtained\n** from [sqlite3_malloc()] before it returns.\n**\n** ^The sqlite3_result_value() interface sets the result of\n** the application-defined function to be a copy of the\n** [unprotected sqlite3_value] object specified by the 2nd parameter.  ^The\n** sqlite3_result_value() interface makes a copy of the [sqlite3_value]\n** so that the [sqlite3_value] specified in the parameter may change or\n** be deallocated after sqlite3_result_value() returns without harm.\n** ^A [protected sqlite3_value] object may always be used where an\n** [unprotected sqlite3_value] object is required, so either\n** kind of [sqlite3_value] object can be used with this interface.\n**\n** ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an\n** SQL NULL value, just like [sqlite3_result_null(C)], except that it\n** also associates the host-language pointer P or type T with that \n** NULL value such that the pointer can be retrieved within an\n** [application-defined SQL function] using [sqlite3_value_pointer()].\n** ^If the D parameter is not NULL, then it is a pointer to a destructor\n** for the P parameter.  ^SQLite invokes D with P as its only argument\n** when SQLite is finished with P.  The T parameter should be a static\n** string and preferably a string literal. The sqlite3_result_pointer()\n** routine is part of the [pointer passing interface] added for SQLite 3.20.0.\n**\n** If these routines are called from within the different thread\n** than the one containing the application-defined function that received\n** the [sqlite3_context] pointer, the results are undefined.\n*/\nvoid sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));\nvoid sqlite3_result_blob64(sqlite3_context*,const void*,\n                           sqlite3_uint64,void(*)(void*));\nvoid sqlite3_result_double(sqlite3_context*, double);\nvoid sqlite3_result_error(sqlite3_context*, const char*, int);\nvoid sqlite3_result_error16(sqlite3_context*, const void*, int);\nvoid sqlite3_result_error_toobig(sqlite3_context*);\nvoid sqlite3_result_error_nomem(sqlite3_context*);\nvoid sqlite3_result_error_code(sqlite3_context*, int);\nvoid sqlite3_result_int(sqlite3_context*, int);\nvoid sqlite3_result_int64(sqlite3_context*, sqlite3_int64);\nvoid sqlite3_result_null(sqlite3_context*);\nvoid sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));\nvoid sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,\n                           void(*)(void*), unsigned char encoding);\nvoid sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));\nvoid sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));\nvoid sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));\nvoid sqlite3_result_value(sqlite3_context*, sqlite3_value*);\nvoid sqlite3_result_pointer(sqlite3_context*, void*,const char*,void(*)(void*));\nvoid sqlite3_result_zeroblob(sqlite3_context*, int n);\nint sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);\n\n\n/*\n** CAPI3REF: Setting The Subtype Of An SQL Function\n** METHOD: sqlite3_context\n**\n** The sqlite3_result_subtype(C,T) function causes the subtype of\n** the result from the [application-defined SQL function] with \n** [sqlite3_context] C to be the value T.  Only the lower 8 bits \n** of the subtype T are preserved in current versions of SQLite;\n** higher order bits are discarded.\n** The number of subtype bytes preserved by SQLite might increase\n** in future releases of SQLite.\n*/\nvoid sqlite3_result_subtype(sqlite3_context*,unsigned int);\n\n/*\n** CAPI3REF: Define New Collating Sequences\n** METHOD: sqlite3\n**\n** ^These functions add, remove, or modify a [collation] associated\n** with the [database connection] specified as the first argument.\n**\n** ^The name of the collation is a UTF-8 string\n** for sqlite3_create_collation() and sqlite3_create_collation_v2()\n** and a UTF-16 string in native byte order for sqlite3_create_collation16().\n** ^Collation names that compare equal according to [sqlite3_strnicmp()] are\n** considered to be the same name.\n**\n** ^(The third argument (eTextRep) must be one of the constants:\n** <ul>\n** <li> [SQLITE_UTF8],\n** <li> [SQLITE_UTF16LE],\n** <li> [SQLITE_UTF16BE],\n** <li> [SQLITE_UTF16], or\n** <li> [SQLITE_UTF16_ALIGNED].\n** </ul>)^\n** ^The eTextRep argument determines the encoding of strings passed\n** to the collating function callback, xCallback.\n** ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep\n** force strings to be UTF16 with native byte order.\n** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin\n** on an even byte address.\n**\n** ^The fourth argument, pArg, is an application data pointer that is passed\n** through as the first argument to the collating function callback.\n**\n** ^The fifth argument, xCallback, is a pointer to the collating function.\n** ^Multiple collating functions can be registered using the same name but\n** with different eTextRep parameters and SQLite will use whichever\n** function requires the least amount of data transformation.\n** ^If the xCallback argument is NULL then the collating function is\n** deleted.  ^When all collating functions having the same name are deleted,\n** that collation is no longer usable.\n**\n** ^The collating function callback is invoked with a copy of the pArg \n** application data pointer and with two strings in the encoding specified\n** by the eTextRep argument.  The collating function must return an\n** integer that is negative, zero, or positive\n** if the first string is less than, equal to, or greater than the second,\n** respectively.  A collating function must always return the same answer\n** given the same inputs.  If two or more collating functions are registered\n** to the same collation name (using different eTextRep values) then all\n** must give an equivalent answer when invoked with equivalent strings.\n** The collating function must obey the following properties for all\n** strings A, B, and C:\n**\n** <ol>\n** <li> If A==B then B==A.\n** <li> If A==B and B==C then A==C.\n** <li> If A&lt;B THEN B&gt;A.\n** <li> If A&lt;B and B&lt;C then A&lt;C.\n** </ol>\n**\n** If a collating function fails any of the above constraints and that\n** collating function is  registered and used, then the behavior of SQLite\n** is undefined.\n**\n** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()\n** with the addition that the xDestroy callback is invoked on pArg when\n** the collating function is deleted.\n** ^Collating functions are deleted when they are overridden by later\n** calls to the collation creation functions or when the\n** [database connection] is closed using [sqlite3_close()].\n**\n** ^The xDestroy callback is <u>not</u> called if the \n** sqlite3_create_collation_v2() function fails.  Applications that invoke\n** sqlite3_create_collation_v2() with a non-NULL xDestroy argument should \n** check the return code and dispose of the application data pointer\n** themselves rather than expecting SQLite to deal with it for them.\n** This is different from every other SQLite interface.  The inconsistency \n** is unfortunate but cannot be changed without breaking backwards \n** compatibility.\n**\n** See also:  [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].\n*/\nint sqlite3_create_collation(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\nint sqlite3_create_collation_v2(\n  sqlite3*, \n  const char *zName, \n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*),\n  void(*xDestroy)(void*)\n);\nint sqlite3_create_collation16(\n  sqlite3*, \n  const void *zName,\n  int eTextRep, \n  void *pArg,\n  int(*xCompare)(void*,int,const void*,int,const void*)\n);\n\n/*\n** CAPI3REF: Collation Needed Callbacks\n** METHOD: sqlite3\n**\n** ^To avoid having to register all collation sequences before a database\n** can be used, a single callback function may be registered with the\n** [database connection] to be invoked whenever an undefined collation\n** sequence is required.\n**\n** ^If the function is registered using the sqlite3_collation_needed() API,\n** then it is passed the names of undefined collation sequences as strings\n** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,\n** the names are passed as UTF-16 in machine native byte order.\n** ^A call to either function replaces the existing collation-needed callback.\n**\n** ^(When the callback is invoked, the first argument passed is a copy\n** of the second argument to sqlite3_collation_needed() or\n** sqlite3_collation_needed16().  The second argument is the database\n** connection.  The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],\n** or [SQLITE_UTF16LE], indicating the most desirable form of the collation\n** sequence function required.  The fourth parameter is the name of the\n** required collation sequence.)^\n**\n** The callback function should register the desired collation using\n** [sqlite3_create_collation()], [sqlite3_create_collation16()], or\n** [sqlite3_create_collation_v2()].\n*/\nint sqlite3_collation_needed(\n  sqlite3*, \n  void*, \n  void(*)(void*,sqlite3*,int eTextRep,const char*)\n);\nint sqlite3_collation_needed16(\n  sqlite3*, \n  void*,\n  void(*)(void*,sqlite3*,int eTextRep,const void*)\n);\n\n#ifdef SQLITE_HAS_CODEC\n/*\n** Specify the key for an encrypted database.  This routine should be\n** called right after sqlite3_open().\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nint sqlite3_key(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The key */\n);\nint sqlite3_key_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The key */\n);\n\n/*\n** Change the key on an open database.  If the current database is not\n** encrypted, this routine will encrypt it.  If pNew==0 or nNew==0, the\n** database is decrypted.\n**\n** The code to implement this API is not available in the public release\n** of SQLite.\n*/\nint sqlite3_rekey(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const void *pKey, int nKey     /* The new key */\n);\nint sqlite3_rekey_v2(\n  sqlite3 *db,                   /* Database to be rekeyed */\n  const char *zDbName,           /* Name of the database */\n  const void *pKey, int nKey     /* The new key */\n);\n\n/*\n** Specify the activation key for a SEE database.  Unless \n** activated, none of the SEE routines will work.\n*/\nvoid sqlite3_activate_see(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n#ifdef SQLITE_ENABLE_CEROD\n/*\n** Specify the activation key for a CEROD database.  Unless \n** activated, none of the CEROD routines will work.\n*/\nvoid sqlite3_activate_cerod(\n  const char *zPassPhrase        /* Activation phrase */\n);\n#endif\n\n/*\n** CAPI3REF: Suspend Execution For A Short Time\n**\n** The sqlite3_sleep() function causes the current thread to suspend execution\n** for at least a number of milliseconds specified in its parameter.\n**\n** If the operating system does not support sleep requests with\n** millisecond time resolution, then the time will be rounded up to\n** the nearest second. The number of milliseconds of sleep actually\n** requested from the operating system is returned.\n**\n** ^SQLite implements this interface by calling the xSleep()\n** method of the default [sqlite3_vfs] object.  If the xSleep() method\n** of the default VFS is not implemented correctly, or not implemented at\n** all, then the behavior of sqlite3_sleep() may deviate from the description\n** in the previous paragraphs.\n*/\nint sqlite3_sleep(int);\n\n/*\n** CAPI3REF: Name Of The Folder Holding Temporary Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all temporary files\n** created by SQLite when using a built-in [sqlite3_vfs | VFS]\n** will be placed in that directory.)^  ^If this variable\n** is a NULL pointer, then SQLite performs a search for an appropriate\n** temporary file directory.\n**\n** Applications are strongly discouraged from using this global variable.\n** It is required to set a temporary folder on Windows Runtime (WinRT).\n** But for all other platforms, it is highly recommended that applications\n** neither read nor write this variable.  This global variable is a relic\n** that exists for backwards compatibility of legacy applications and should\n** be avoided in new projects.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [temp_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [temp_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [temp_store_directory pragma] should be avoided.\n** Except when requested by the [temp_store_directory pragma], SQLite\n** does not free the memory that sqlite3_temp_directory points to.  If\n** the application wants that memory to be freed, it must do\n** so itself, taking care to only do so after all [database connection]\n** objects have been destroyed.\n**\n** <b>Note to Windows Runtime users:</b>  The temporary directory must be set\n** prior to calling [sqlite3_open] or [sqlite3_open_v2].  Otherwise, various\n** features that require the use of temporary files may fail.  Here is an\n** example of how to do this using C++ with the Windows Runtime:\n**\n** <blockquote><pre>\n** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->\n** &nbsp;     TemporaryFolder->Path->Data();\n** char zPathBuf&#91;MAX_PATH + 1&#93;;\n** memset(zPathBuf, 0, sizeof(zPathBuf));\n** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),\n** &nbsp;     NULL, NULL);\n** sqlite3_temp_directory = sqlite3_mprintf(\"%s\", zPathBuf);\n** </pre></blockquote>\n*/\nSQLITE_EXTERN char *sqlite3_temp_directory;\n\n/*\n** CAPI3REF: Name Of The Folder Holding Database Files\n**\n** ^(If this global variable is made to point to a string which is\n** the name of a folder (a.k.a. directory), then all database files\n** specified with a relative pathname and created or accessed by\n** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed\n** to be relative to that directory.)^ ^If this variable is a NULL\n** pointer, then SQLite assumes that all database files specified\n** with a relative pathname are relative to the current directory\n** for the process.  Only the windows VFS makes use of this global\n** variable; it is ignored by the unix VFS.\n**\n** Changing the value of this variable while a database connection is\n** open can result in a corrupt database.\n**\n** It is not safe to read or modify this variable in more than one\n** thread at a time.  It is not safe to read or modify this variable\n** if a [database connection] is being used at the same time in a separate\n** thread.\n** It is intended that this variable be set once\n** as part of process initialization and before any SQLite interface\n** routines have been called and that this variable remain unchanged\n** thereafter.\n**\n** ^The [data_store_directory pragma] may modify this variable and cause\n** it to point to memory obtained from [sqlite3_malloc].  ^Furthermore,\n** the [data_store_directory pragma] always assumes that any string\n** that this variable points to is held in memory obtained from \n** [sqlite3_malloc] and the pragma may attempt to free that memory\n** using [sqlite3_free].\n** Hence, if this variable is modified directly, either it should be\n** made NULL or made to point to memory obtained from [sqlite3_malloc]\n** or else the use of the [data_store_directory pragma] should be avoided.\n*/\nSQLITE_EXTERN char *sqlite3_data_directory;\n\n/*\n** CAPI3REF: Test For Auto-Commit Mode\n** KEYWORDS: {autocommit mode}\n** METHOD: sqlite3\n**\n** ^The sqlite3_get_autocommit() interface returns non-zero or\n** zero if the given database connection is or is not in autocommit mode,\n** respectively.  ^Autocommit mode is on by default.\n** ^Autocommit mode is disabled by a [BEGIN] statement.\n** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].\n**\n** If certain kinds of errors occur on a statement within a multi-statement\n** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],\n** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the\n** transaction might be rolled back automatically.  The only way to\n** find out whether SQLite automatically rolled back the transaction after\n** an error is to use this function.\n**\n** If another thread changes the autocommit status of the database\n** connection while this routine is running, then the return value\n** is undefined.\n*/\nint sqlite3_get_autocommit(sqlite3*);\n\n/*\n** CAPI3REF: Find The Database Handle Of A Prepared Statement\n** METHOD: sqlite3_stmt\n**\n** ^The sqlite3_db_handle interface returns the [database connection] handle\n** to which a [prepared statement] belongs.  ^The [database connection]\n** returned by sqlite3_db_handle is the same [database connection]\n** that was the first argument\n** to the [sqlite3_prepare_v2()] call (or its variants) that was used to\n** create the statement in the first place.\n*/\nsqlite3 *sqlite3_db_handle(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Return The Filename For A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename\n** associated with database N of connection D.  ^The main database file\n** has the name \"main\".  If there is no attached database N on the database\n** connection D, or if database N is a temporary or in-memory database, then\n** a NULL pointer is returned.\n**\n** ^The filename returned by this function is the output of the\n** xFullPathname method of the [VFS].  ^In other words, the filename\n** will be an absolute pathname, even if the filename used\n** to open the database originally was a URI or relative pathname.\n*/\nconst char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Determine if a database is read-only\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N\n** of connection D is read-only, 0 if it is read/write, or -1 if N is not\n** the name of a database on connection D.\n*/\nint sqlite3_db_readonly(sqlite3 *db, const char *zDbName);\n\n/*\n** CAPI3REF: Find the next prepared statement\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer to the next [prepared statement] after\n** pStmt associated with the [database connection] pDb.  ^If pStmt is NULL\n** then this interface returns a pointer to the first prepared statement\n** associated with the database connection pDb.  ^If no prepared statement\n** satisfies the conditions of this routine, it returns NULL.\n**\n** The [database connection] pointer D in a call to\n** [sqlite3_next_stmt(D,S)] must refer to an open database\n** connection and in particular must not be a NULL pointer.\n*/\nsqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);\n\n/*\n** CAPI3REF: Commit And Rollback Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_commit_hook() interface registers a callback\n** function to be invoked whenever a transaction is [COMMIT | committed].\n** ^Any callback set by a previous call to sqlite3_commit_hook()\n** for the same database connection is overridden.\n** ^The sqlite3_rollback_hook() interface registers a callback\n** function to be invoked whenever a transaction is [ROLLBACK | rolled back].\n** ^Any callback set by a previous call to sqlite3_rollback_hook()\n** for the same database connection is overridden.\n** ^The pArg argument is passed through to the callback.\n** ^If the callback on a commit hook function returns non-zero,\n** then the commit is converted into a rollback.\n**\n** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions\n** return the P argument from the previous call of the same function\n** on the same [database connection] D, or NULL for\n** the first call for each function on D.\n**\n** The commit and rollback hook callbacks are not reentrant.\n** The callback implementation must not do anything that will modify\n** the database connection that invoked the callback.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the commit\n** or rollback hook in the first place.\n** Note that running any other SQL statements, including SELECT statements,\n** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify\n** the database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^Registering a NULL function disables the callback.\n**\n** ^When the commit hook callback routine returns zero, the [COMMIT]\n** operation is allowed to continue normally.  ^If the commit hook\n** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].\n** ^The rollback hook is invoked on a rollback that results from a commit\n** hook returning non-zero, just as it would be with any other rollback.\n**\n** ^For the purposes of this API, a transaction is said to have been\n** rolled back if an explicit \"ROLLBACK\" statement is executed, or\n** an error or constraint causes an implicit rollback to occur.\n** ^The rollback callback is not invoked if a transaction is\n** automatically rolled back because the database connection is closed.\n**\n** See also the [sqlite3_update_hook()] interface.\n*/\nvoid *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);\nvoid *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);\n\n/*\n** CAPI3REF: Data Change Notification Callbacks\n** METHOD: sqlite3\n**\n** ^The sqlite3_update_hook() interface registers a callback function\n** with the [database connection] identified by the first argument\n** to be invoked whenever a row is updated, inserted or deleted in\n** a [rowid table].\n** ^Any callback set by a previous call to this function\n** for the same database connection is overridden.\n**\n** ^The second argument is a pointer to the function to invoke when a\n** row is updated, inserted or deleted in a rowid table.\n** ^The first argument to the callback is a copy of the third argument\n** to sqlite3_update_hook().\n** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],\n** or [SQLITE_UPDATE], depending on the operation that caused the callback\n** to be invoked.\n** ^The third and fourth arguments to the callback contain pointers to the\n** database and table name containing the affected row.\n** ^The final callback parameter is the [rowid] of the row.\n** ^In the case of an update, this is the [rowid] after the update takes place.\n**\n** ^(The update hook is not invoked when internal system tables are\n** modified (i.e. sqlite_master and sqlite_sequence).)^\n** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.\n**\n** ^In the current implementation, the update hook\n** is not invoked when conflicting rows are deleted because of an\n** [ON CONFLICT | ON CONFLICT REPLACE] clause.  ^Nor is the update hook\n** invoked when rows are deleted using the [truncate optimization].\n** The exceptions defined in this paragraph might change in a future\n** release of SQLite.\n**\n** The update hook implementation must not do anything that will modify\n** the database connection that invoked the update hook.  Any actions\n** to modify the database connection must be deferred until after the\n** completion of the [sqlite3_step()] call that triggered the update hook.\n** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their\n** database connections for the meaning of \"modify\" in this paragraph.\n**\n** ^The sqlite3_update_hook(D,C,P) function\n** returns the P argument from the previous call\n** on the same [database connection] D, or NULL for\n** the first call on D.\n**\n** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],\n** and [sqlite3_preupdate_hook()] interfaces.\n*/\nvoid *sqlite3_update_hook(\n  sqlite3*, \n  void(*)(void *,int ,char const *,char const *,sqlite3_int64),\n  void*\n);\n\n/*\n** CAPI3REF: Enable Or Disable Shared Pager Cache\n**\n** ^(This routine enables or disables the sharing of the database cache\n** and schema data structures between [database connection | connections]\n** to the same database. Sharing is enabled if the argument is true\n** and disabled if the argument is false.)^\n**\n** ^Cache sharing is enabled and disabled for an entire process.\n** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). \n** In prior versions of SQLite,\n** sharing was enabled or disabled for each thread separately.\n**\n** ^(The cache sharing mode set by this interface effects all subsequent\n** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].\n** Existing database connections continue use the sharing mode\n** that was in effect at the time they were opened.)^\n**\n** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled\n** successfully.  An [error code] is returned otherwise.)^\n**\n** ^Shared cache is disabled by default. But this might change in\n** future releases of SQLite.  Applications that care about shared\n** cache setting should set it explicitly.\n**\n** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0\n** and will always return SQLITE_MISUSE. On those systems, \n** shared cache mode should be enabled per-database connection via \n** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].\n**\n** This interface is threadsafe on processors where writing a\n** 32-bit integer is atomic.\n**\n** See Also:  [SQLite Shared-Cache Mode]\n*/\nint sqlite3_enable_shared_cache(int);\n\n/*\n** CAPI3REF: Attempt To Free Heap Memory\n**\n** ^The sqlite3_release_memory() interface attempts to free N bytes\n** of heap memory by deallocating non-essential memory allocations\n** held by the database library.   Memory used to cache database\n** pages to improve performance is an example of non-essential memory.\n** ^sqlite3_release_memory() returns the number of bytes actually freed,\n** which might be more or less than the amount requested.\n** ^The sqlite3_release_memory() routine is a no-op returning zero\n** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** See also: [sqlite3_db_release_memory()]\n*/\nint sqlite3_release_memory(int);\n\n/*\n** CAPI3REF: Free Memory Used By A Database Connection\n** METHOD: sqlite3\n**\n** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap\n** memory as possible from database connection D. Unlike the\n** [sqlite3_release_memory()] interface, this interface is in effect even\n** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is\n** omitted.\n**\n** See also: [sqlite3_release_memory()]\n*/\nint sqlite3_db_release_memory(sqlite3*);\n\n/*\n** CAPI3REF: Impose A Limit On Heap Size\n**\n** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the\n** soft limit on the amount of heap memory that may be allocated by SQLite.\n** ^SQLite strives to keep heap memory utilization below the soft heap\n** limit by reducing the number of pages held in the page cache\n** as heap memory usages approaches the limit.\n** ^The soft heap limit is \"soft\" because even though SQLite strives to stay\n** below the limit, it will exceed the limit rather than generate\n** an [SQLITE_NOMEM] error.  In other words, the soft heap limit \n** is advisory only.\n**\n** ^The return value from sqlite3_soft_heap_limit64() is the size of\n** the soft heap limit prior to the call, or negative in the case of an\n** error.  ^If the argument N is negative\n** then no change is made to the soft heap limit.  Hence, the current\n** size of the soft heap limit can be determined by invoking\n** sqlite3_soft_heap_limit64() with a negative argument.\n**\n** ^If the argument N is zero then the soft heap limit is disabled.\n**\n** ^(The soft heap limit is not enforced in the current implementation\n** if one or more of following conditions are true:\n**\n** <ul>\n** <li> The soft heap limit is set to zero.\n** <li> Memory accounting is disabled using a combination of the\n**      [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and\n**      the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.\n** <li> An alternative page cache implementation is specified using\n**      [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).\n** <li> The page cache allocates from its own memory pool supplied\n**      by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than\n**      from the heap.\n** </ul>)^\n**\n** Beginning with SQLite [version 3.7.3] ([dateof:3.7.3]), \n** the soft heap limit is enforced\n** regardless of whether or not the [SQLITE_ENABLE_MEMORY_MANAGEMENT]\n** compile-time option is invoked.  With [SQLITE_ENABLE_MEMORY_MANAGEMENT],\n** the soft heap limit is enforced on every memory allocation.  Without\n** [SQLITE_ENABLE_MEMORY_MANAGEMENT], the soft heap limit is only enforced\n** when memory is allocated by the page cache.  Testing suggests that because\n** the page cache is the predominate memory user in SQLite, most\n** applications will achieve adequate soft heap limit enforcement without\n** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].\n**\n** The circumstances under which SQLite will enforce the soft heap limit may\n** changes in future releases of SQLite.\n*/\nsqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);\n\n/*\n** CAPI3REF: Deprecated Soft Heap Limit Interface\n** DEPRECATED\n**\n** This is a deprecated version of the [sqlite3_soft_heap_limit64()]\n** interface.  This routine is provided for historical compatibility\n** only.  All new applications should use the\n** [sqlite3_soft_heap_limit64()] interface rather than this one.\n*/\nSQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);\n\n\n/*\n** CAPI3REF: Extract Metadata About A Column Of A Table\n** METHOD: sqlite3\n**\n** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns\n** information about column C of table T in database D\n** on [database connection] X.)^  ^The sqlite3_table_column_metadata()\n** interface returns SQLITE_OK and fills in the non-NULL pointers in\n** the final five arguments with appropriate values if the specified\n** column exists.  ^The sqlite3_table_column_metadata() interface returns\n** SQLITE_ERROR and if the specified column does not exist.\n** ^If the column-name parameter to sqlite3_table_column_metadata() is a\n** NULL pointer, then this routine simply checks for the existence of the\n** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it\n** does not.  If the table name parameter T in a call to\n** sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is\n** undefined behavior.\n**\n** ^The column is identified by the second, third and fourth parameters to\n** this function. ^(The second parameter is either the name of the database\n** (i.e. \"main\", \"temp\", or an attached database) containing the specified\n** table or NULL.)^ ^If it is NULL, then all attached databases are searched\n** for the table using the same algorithm used by the database engine to\n** resolve unqualified table references.\n**\n** ^The third and fourth parameters to this function are the table and column\n** name of the desired column, respectively.\n**\n** ^Metadata is returned by writing to the memory locations passed as the 5th\n** and subsequent parameters to this function. ^Any of these arguments may be\n** NULL, in which case the corresponding element of metadata is omitted.\n**\n** ^(<blockquote>\n** <table border=\"1\">\n** <tr><th> Parameter <th> Output<br>Type <th>  Description\n**\n** <tr><td> 5th <td> const char* <td> Data type\n** <tr><td> 6th <td> const char* <td> Name of default collation sequence\n** <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint\n** <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY\n** <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]\n** </table>\n** </blockquote>)^\n**\n** ^The memory pointed to by the character pointers returned for the\n** declaration type and collation sequence is valid until the next\n** call to any SQLite API function.\n**\n** ^If the specified table is actually a view, an [error code] is returned.\n**\n** ^If the specified column is \"rowid\", \"oid\" or \"_rowid_\" and the table \n** is not a [WITHOUT ROWID] table and an\n** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output\n** parameters are set for the explicitly declared column. ^(If there is no\n** [INTEGER PRIMARY KEY] column, then the outputs\n** for the [rowid] are set as follows:\n**\n** <pre>\n**     data type: \"INTEGER\"\n**     collation sequence: \"BINARY\"\n**     not null: 0\n**     primary key: 1\n**     auto increment: 0\n** </pre>)^\n**\n** ^This function causes all database schemas to be read from disk and\n** parsed, if that has not already been done, and returns an error if\n** any errors are encountered while loading the schema.\n*/\nint sqlite3_table_column_metadata(\n  sqlite3 *db,                /* Connection handle */\n  const char *zDbName,        /* Database name or NULL */\n  const char *zTableName,     /* Table name */\n  const char *zColumnName,    /* Column name */\n  char const **pzDataType,    /* OUTPUT: Declared data type */\n  char const **pzCollSeq,     /* OUTPUT: Collation sequence name */\n  int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */\n  int *pPrimaryKey,           /* OUTPUT: True if column part of PK */\n  int *pAutoinc               /* OUTPUT: True if column is auto-increment */\n);\n\n/*\n** CAPI3REF: Load An Extension\n** METHOD: sqlite3\n**\n** ^This interface loads an SQLite extension library from the named file.\n**\n** ^The sqlite3_load_extension() interface attempts to load an\n** [SQLite extension] library contained in the file zFile.  If\n** the file cannot be loaded directly, attempts are made to load\n** with various operating-system specific extensions added.\n** So for example, if \"samplelib\" cannot be loaded, then names like\n** \"samplelib.so\" or \"samplelib.dylib\" or \"samplelib.dll\" might\n** be tried also.\n**\n** ^The entry point is zProc.\n** ^(zProc may be 0, in which case SQLite will try to come up with an\n** entry point name on its own.  It first tries \"sqlite3_extension_init\".\n** If that does not work, it constructs a name \"sqlite3_X_init\" where the\n** X is consists of the lower-case equivalent of all ASCII alphabetic\n** characters in the filename from the last \"/\" to the first following\n** \".\" and omitting any initial \"lib\".)^\n** ^The sqlite3_load_extension() interface returns\n** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.\n** ^If an error occurs and pzErrMsg is not 0, then the\n** [sqlite3_load_extension()] interface shall attempt to\n** fill *pzErrMsg with error message text stored in memory\n** obtained from [sqlite3_malloc()]. The calling function\n** should free this memory by calling [sqlite3_free()].\n**\n** ^Extension loading must be enabled using\n** [sqlite3_enable_load_extension()] or\n** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)\n** prior to calling this API,\n** otherwise an error will be returned.\n**\n** <b>Security warning:</b> It is recommended that the \n** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this\n** interface.  The use of the [sqlite3_enable_load_extension()] interface\n** should be avoided.  This will keep the SQL function [load_extension()]\n** disabled and prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n**\n** See also the [load_extension() SQL function].\n*/\nint sqlite3_load_extension(\n  sqlite3 *db,          /* Load the extension into this database connection */\n  const char *zFile,    /* Name of the shared library containing extension */\n  const char *zProc,    /* Entry point.  Derived from zFile if 0 */\n  char **pzErrMsg       /* Put error message here if not 0 */\n);\n\n/*\n** CAPI3REF: Enable Or Disable Extension Loading\n** METHOD: sqlite3\n**\n** ^So as not to open security holes in older applications that are\n** unprepared to deal with [extension loading], and as a means of disabling\n** [extension loading] while evaluating user-entered SQL, the following API\n** is provided to turn the [sqlite3_load_extension()] mechanism on and off.\n**\n** ^Extension loading is off by default.\n** ^Call the sqlite3_enable_load_extension() routine with onoff==1\n** to turn extension loading on and call it with onoff==0 to turn\n** it back off again.\n**\n** ^This interface enables or disables both the C-API\n** [sqlite3_load_extension()] and the SQL function [load_extension()].\n** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)\n** to enable or disable only the C-API.)^\n**\n** <b>Security warning:</b> It is recommended that extension loading\n** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method\n** rather than this interface, so the [load_extension()] SQL function\n** remains disabled. This will prevent SQL injections from giving attackers\n** access to extension loading capabilities.\n*/\nint sqlite3_enable_load_extension(sqlite3 *db, int onoff);\n\n/*\n** CAPI3REF: Automatically Load Statically Linked Extensions\n**\n** ^This interface causes the xEntryPoint() function to be invoked for\n** each new [database connection] that is created.  The idea here is that\n** xEntryPoint() is the entry point for a statically linked [SQLite extension]\n** that is to be automatically loaded into all new database connections.\n**\n** ^(Even though the function prototype shows that xEntryPoint() takes\n** no arguments and returns void, SQLite invokes xEntryPoint() with three\n** arguments and expects an integer result as if the signature of the\n** entry point where as follows:\n**\n** <blockquote><pre>\n** &nbsp;  int xEntryPoint(\n** &nbsp;    sqlite3 *db,\n** &nbsp;    const char **pzErrMsg,\n** &nbsp;    const struct sqlite3_api_routines *pThunk\n** &nbsp;  );\n** </pre></blockquote>)^\n**\n** If the xEntryPoint routine encounters an error, it should make *pzErrMsg\n** point to an appropriate error message (obtained from [sqlite3_mprintf()])\n** and return an appropriate [error code].  ^SQLite ensures that *pzErrMsg\n** is NULL before calling the xEntryPoint().  ^SQLite will invoke\n** [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns.  ^If any\n** xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()],\n** or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail.\n**\n** ^Calling sqlite3_auto_extension(X) with an entry point X that is already\n** on the list of automatic extensions is a harmless no-op. ^No entry point\n** will be called more than once for each database connection that is opened.\n**\n** See also: [sqlite3_reset_auto_extension()]\n** and [sqlite3_cancel_auto_extension()]\n*/\nint sqlite3_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Cancel Automatic Extension Loading\n**\n** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the\n** initialization routine X that was registered using a prior call to\n** [sqlite3_auto_extension(X)].  ^The [sqlite3_cancel_auto_extension(X)]\n** routine returns 1 if initialization routine X was successfully \n** unregistered and it returns 0 if X was not on the list of initialization\n** routines.\n*/\nint sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));\n\n/*\n** CAPI3REF: Reset Automatic Extension Loading\n**\n** ^This interface disables all automatic extensions previously\n** registered using [sqlite3_auto_extension()].\n*/\nvoid sqlite3_reset_auto_extension(void);\n\n/*\n** The interface to the virtual-table mechanism is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** Structures used by the virtual table interface\n*/\ntypedef struct sqlite3_vtab sqlite3_vtab;\ntypedef struct sqlite3_index_info sqlite3_index_info;\ntypedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;\ntypedef struct sqlite3_module sqlite3_module;\n\n/*\n** CAPI3REF: Virtual Table Object\n** KEYWORDS: sqlite3_module {virtual table module}\n**\n** This structure, sometimes called a \"virtual table module\", \n** defines the implementation of a [virtual tables].  \n** This structure consists mostly of methods for the module.\n**\n** ^A virtual table module is created by filling in a persistent\n** instance of this structure and passing a pointer to that instance\n** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].\n** ^The registration remains valid until it is replaced by a different\n** module or until the [database connection] closes.  The content\n** of this structure must not change while it is registered with\n** any database connection.\n*/\nstruct sqlite3_module {\n  int iVersion;\n  int (*xCreate)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xConnect)(sqlite3*, void *pAux,\n               int argc, const char *const*argv,\n               sqlite3_vtab **ppVTab, char**);\n  int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);\n  int (*xDisconnect)(sqlite3_vtab *pVTab);\n  int (*xDestroy)(sqlite3_vtab *pVTab);\n  int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);\n  int (*xClose)(sqlite3_vtab_cursor*);\n  int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,\n                int argc, sqlite3_value **argv);\n  int (*xNext)(sqlite3_vtab_cursor*);\n  int (*xEof)(sqlite3_vtab_cursor*);\n  int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);\n  int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);\n  int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);\n  int (*xBegin)(sqlite3_vtab *pVTab);\n  int (*xSync)(sqlite3_vtab *pVTab);\n  int (*xCommit)(sqlite3_vtab *pVTab);\n  int (*xRollback)(sqlite3_vtab *pVTab);\n  int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,\n                       void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n                       void **ppArg);\n  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);\n  /* The methods above are in version 1 of the sqlite_module object. Those \n  ** below are for version 2 and greater. */\n  int (*xSavepoint)(sqlite3_vtab *pVTab, int);\n  int (*xRelease)(sqlite3_vtab *pVTab, int);\n  int (*xRollbackTo)(sqlite3_vtab *pVTab, int);\n};\n\n/*\n** CAPI3REF: Virtual Table Indexing Information\n** KEYWORDS: sqlite3_index_info\n**\n** The sqlite3_index_info structure and its substructures is used as part\n** of the [virtual table] interface to\n** pass information into and receive the reply from the [xBestIndex]\n** method of a [virtual table module].  The fields under **Inputs** are the\n** inputs to xBestIndex and are read-only.  xBestIndex inserts its\n** results into the **Outputs** fields.\n**\n** ^(The aConstraint[] array records WHERE clause constraints of the form:\n**\n** <blockquote>column OP expr</blockquote>\n**\n** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^  ^(The particular operator is\n** stored in aConstraint[].op using one of the\n** [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^\n** ^(The index of the column is stored in\n** aConstraint[].iColumn.)^  ^(aConstraint[].usable is TRUE if the\n** expr on the right-hand side can be evaluated (and thus the constraint\n** is usable) and false if it cannot.)^\n**\n** ^The optimizer automatically inverts terms of the form \"expr OP column\"\n** and makes other simplifications to the WHERE clause in an attempt to\n** get as many WHERE clause terms into the form shown above as possible.\n** ^The aConstraint[] array only reports WHERE clause terms that are\n** relevant to the particular virtual table being queried.\n**\n** ^Information about the ORDER BY clause is stored in aOrderBy[].\n** ^Each term of aOrderBy records a column of the ORDER BY clause.\n**\n** The colUsed field indicates which columns of the virtual table may be\n** required by the current scan. Virtual table columns are numbered from\n** zero in the order in which they appear within the CREATE TABLE statement\n** passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62),\n** the corresponding bit is set within the colUsed mask if the column may be\n** required by SQLite. If the table has at least 64 columns and any column\n** to the right of the first 63 is required, then bit 63 of colUsed is also\n** set. In other words, column iCol may be required if the expression\n** (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to \n** non-zero.\n**\n** The [xBestIndex] method must fill aConstraintUsage[] with information\n** about what parameters to pass to xFilter.  ^If argvIndex>0 then\n** the right-hand side of the corresponding aConstraint[] is evaluated\n** and becomes the argvIndex-th entry in argv.  ^(If aConstraintUsage[].omit\n** is true, then the constraint is assumed to be fully handled by the\n** virtual table and is not checked again by SQLite.)^\n**\n** ^The idxNum and idxPtr values are recorded and passed into the\n** [xFilter] method.\n** ^[sqlite3_free()] is used to free idxPtr if and only if\n** needToFreeIdxPtr is true.\n**\n** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in\n** the correct order to satisfy the ORDER BY clause so that no separate\n** sorting step is required.\n**\n** ^The estimatedCost value is an estimate of the cost of a particular\n** strategy. A cost of N indicates that the cost of the strategy is similar\n** to a linear scan of an SQLite table with N rows. A cost of log(N) \n** indicates that the expense of the operation is similar to that of a\n** binary search on a unique indexed field of an SQLite table with N rows.\n**\n** ^The estimatedRows value is an estimate of the number of rows that\n** will be returned by the strategy.\n**\n** The xBestIndex method may optionally populate the idxFlags field with a \n** mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag -\n** SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite\n** assumes that the strategy may visit at most one row. \n**\n** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then\n** SQLite also assumes that if a call to the xUpdate() method is made as\n** part of the same statement to delete or update a virtual table row and the\n** implementation returns SQLITE_CONSTRAINT, then there is no need to rollback\n** any database changes. In other words, if the xUpdate() returns\n** SQLITE_CONSTRAINT, the database contents must be exactly as they were\n** before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not\n** set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by\n** the xUpdate method are automatically rolled back by SQLite.\n**\n** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info\n** structure for SQLite [version 3.8.2] ([dateof:3.8.2]). \n** If a virtual table extension is\n** used with an SQLite version earlier than 3.8.2, the results of attempting \n** to read or write the estimatedRows field are undefined (but are likely \n** to included crashing the application). The estimatedRows field should\n** therefore only be used if [sqlite3_libversion_number()] returns a\n** value greater than or equal to 3008002. Similarly, the idxFlags field\n** was added for [version 3.9.0] ([dateof:3.9.0]). \n** It may therefore only be used if\n** sqlite3_libversion_number() returns a value greater than or equal to\n** 3009000.\n*/\nstruct sqlite3_index_info {\n  /* Inputs */\n  int nConstraint;           /* Number of entries in aConstraint */\n  struct sqlite3_index_constraint {\n     int iColumn;              /* Column constrained.  -1 for ROWID */\n     unsigned char op;         /* Constraint operator */\n     unsigned char usable;     /* True if this constraint is usable */\n     int iTermOffset;          /* Used internally - xBestIndex should ignore */\n  } *aConstraint;            /* Table of WHERE clause constraints */\n  int nOrderBy;              /* Number of terms in the ORDER BY clause */\n  struct sqlite3_index_orderby {\n     int iColumn;              /* Column number */\n     unsigned char desc;       /* True for DESC.  False for ASC. */\n  } *aOrderBy;               /* The ORDER BY clause */\n  /* Outputs */\n  struct sqlite3_index_constraint_usage {\n    int argvIndex;           /* if >0, constraint is part of argv to xFilter */\n    unsigned char omit;      /* Do not code a test for this constraint */\n  } *aConstraintUsage;\n  int idxNum;                /* Number used to identify the index */\n  char *idxStr;              /* String, possibly obtained from sqlite3_malloc */\n  int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */\n  int orderByConsumed;       /* True if output is already ordered */\n  double estimatedCost;           /* Estimated cost of using this index */\n  /* Fields below are only available in SQLite 3.8.2 and later */\n  sqlite3_int64 estimatedRows;    /* Estimated number of rows returned */\n  /* Fields below are only available in SQLite 3.9.0 and later */\n  int idxFlags;              /* Mask of SQLITE_INDEX_SCAN_* flags */\n  /* Fields below are only available in SQLite 3.10.0 and later */\n  sqlite3_uint64 colUsed;    /* Input: Mask of columns used by statement */\n};\n\n/*\n** CAPI3REF: Virtual Table Scan Flags\n*/\n#define SQLITE_INDEX_SCAN_UNIQUE      1     /* Scan visits at most 1 row */\n\n/*\n** CAPI3REF: Virtual Table Constraint Operator Codes\n**\n** These macros defined the allowed values for the\n** [sqlite3_index_info].aConstraint[].op field.  Each value represents\n** an operator that is part of a constraint term in the wHERE clause of\n** a query that uses a [virtual table].\n*/\n#define SQLITE_INDEX_CONSTRAINT_EQ         2\n#define SQLITE_INDEX_CONSTRAINT_GT         4\n#define SQLITE_INDEX_CONSTRAINT_LE         8\n#define SQLITE_INDEX_CONSTRAINT_LT        16\n#define SQLITE_INDEX_CONSTRAINT_GE        32\n#define SQLITE_INDEX_CONSTRAINT_MATCH     64\n#define SQLITE_INDEX_CONSTRAINT_LIKE      65\n#define SQLITE_INDEX_CONSTRAINT_GLOB      66\n#define SQLITE_INDEX_CONSTRAINT_REGEXP    67\n#define SQLITE_INDEX_CONSTRAINT_NE        68\n#define SQLITE_INDEX_CONSTRAINT_ISNOT     69\n#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70\n#define SQLITE_INDEX_CONSTRAINT_ISNULL    71\n#define SQLITE_INDEX_CONSTRAINT_IS        72\n\n/*\n** CAPI3REF: Register A Virtual Table Implementation\n** METHOD: sqlite3\n**\n** ^These routines are used to register a new [virtual table module] name.\n** ^Module names must be registered before\n** creating a new [virtual table] using the module and before using a\n** preexisting [virtual table] for the module.\n**\n** ^The module name is registered on the [database connection] specified\n** by the first parameter.  ^The name of the module is given by the \n** second parameter.  ^The third parameter is a pointer to\n** the implementation of the [virtual table module].   ^The fourth\n** parameter is an arbitrary client data pointer that is passed through\n** into the [xCreate] and [xConnect] methods of the virtual table module\n** when a new virtual table is be being created or reinitialized.\n**\n** ^The sqlite3_create_module_v2() interface has a fifth parameter which\n** is a pointer to a destructor for the pClientData.  ^SQLite will\n** invoke the destructor function (if it is not NULL) when SQLite\n** no longer needs the pClientData pointer.  ^The destructor will also\n** be invoked if the call to sqlite3_create_module_v2() fails.\n** ^The sqlite3_create_module()\n** interface is equivalent to sqlite3_create_module_v2() with a NULL\n** destructor.\n*/\nint sqlite3_create_module(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData          /* Client data for xCreate/xConnect */\n);\nint sqlite3_create_module_v2(\n  sqlite3 *db,               /* SQLite connection to register module with */\n  const char *zName,         /* Name of the module */\n  const sqlite3_module *p,   /* Methods for the module */\n  void *pClientData,         /* Client data for xCreate/xConnect */\n  void(*xDestroy)(void*)     /* Module destructor function */\n);\n\n/*\n** CAPI3REF: Virtual Table Instance Object\n** KEYWORDS: sqlite3_vtab\n**\n** Every [virtual table module] implementation uses a subclass\n** of this object to describe a particular instance\n** of the [virtual table].  Each subclass will\n** be tailored to the specific needs of the module implementation.\n** The purpose of this superclass is to define certain fields that are\n** common to all module implementations.\n**\n** ^Virtual tables methods can set an error message by assigning a\n** string obtained from [sqlite3_mprintf()] to zErrMsg.  The method should\n** take care that any prior string is freed by a call to [sqlite3_free()]\n** prior to assigning a new string to zErrMsg.  ^After the error message\n** is delivered up to the client application, the string will be automatically\n** freed by sqlite3_free() and the zErrMsg field will be zeroed.\n*/\nstruct sqlite3_vtab {\n  const sqlite3_module *pModule;  /* The module for this virtual table */\n  int nRef;                       /* Number of open cursors */\n  char *zErrMsg;                  /* Error message from sqlite3_mprintf() */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Virtual Table Cursor Object\n** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}\n**\n** Every [virtual table module] implementation uses a subclass of the\n** following structure to describe cursors that point into the\n** [virtual table] and are used\n** to loop through the virtual table.  Cursors are created using the\n** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed\n** by the [sqlite3_module.xClose | xClose] method.  Cursors are used\n** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods\n** of the module.  Each module implementation will define\n** the content of a cursor structure to suit its own needs.\n**\n** This superclass exists in order to define fields of the cursor that\n** are common to all implementations.\n*/\nstruct sqlite3_vtab_cursor {\n  sqlite3_vtab *pVtab;      /* Virtual table of this cursor */\n  /* Virtual table implementations will typically add additional fields */\n};\n\n/*\n** CAPI3REF: Declare The Schema Of A Virtual Table\n**\n** ^The [xCreate] and [xConnect] methods of a\n** [virtual table module] call this interface\n** to declare the format (the names and datatypes of the columns) of\n** the virtual tables they implement.\n*/\nint sqlite3_declare_vtab(sqlite3*, const char *zSQL);\n\n/*\n** CAPI3REF: Overload A Function For A Virtual Table\n** METHOD: sqlite3\n**\n** ^(Virtual tables can provide alternative implementations of functions\n** using the [xFindFunction] method of the [virtual table module].  \n** But global versions of those functions\n** must exist in order to be overloaded.)^\n**\n** ^(This API makes sure a global version of a function with a particular\n** name and number of parameters exists.  If no such function exists\n** before this API is called, a new function is created.)^  ^The implementation\n** of the new function always causes an exception to be thrown.  So\n** the new function is not good for anything by itself.  Its only\n** purpose is to be a placeholder function that can be overloaded\n** by a [virtual table].\n*/\nint sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);\n\n/*\n** The interface to the virtual-table mechanism defined above (back up\n** to a comment remarkably similar to this one) is currently considered\n** to be experimental.  The interface might change in incompatible ways.\n** If this is a problem for you, do not use the interface at this time.\n**\n** When the virtual-table mechanism stabilizes, we will declare the\n** interface fixed, support it indefinitely, and remove this comment.\n*/\n\n/*\n** CAPI3REF: A Handle To An Open BLOB\n** KEYWORDS: {BLOB handle} {BLOB handles}\n**\n** An instance of this object represents an open BLOB on which\n** [sqlite3_blob_open | incremental BLOB I/O] can be performed.\n** ^Objects of this type are created by [sqlite3_blob_open()]\n** and destroyed by [sqlite3_blob_close()].\n** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces\n** can be used to read or write small subsections of the BLOB.\n** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.\n*/\ntypedef struct sqlite3_blob sqlite3_blob;\n\n/*\n** CAPI3REF: Open A BLOB For Incremental I/O\n** METHOD: sqlite3\n** CONSTRUCTOR: sqlite3_blob\n**\n** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located\n** in row iRow, column zColumn, table zTable in database zDb;\n** in other words, the same BLOB that would be selected by:\n**\n** <pre>\n**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;\n** </pre>)^\n**\n** ^(Parameter zDb is not the filename that contains the database, but \n** rather the symbolic name of the database. For attached databases, this is\n** the name that appears after the AS keyword in the [ATTACH] statement.\n** For the main database file, the database name is \"main\". For TEMP\n** tables, the database name is \"temp\".)^\n**\n** ^If the flags parameter is non-zero, then the BLOB is opened for read\n** and write access. ^If the flags parameter is zero, the BLOB is opened for\n** read-only access.\n**\n** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored\n** in *ppBlob. Otherwise an [error code] is returned and, unless the error\n** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided\n** the API is not misused, it is always safe to call [sqlite3_blob_close()] \n** on *ppBlob after this function it returns.\n**\n** This function fails with SQLITE_ERROR if any of the following are true:\n** <ul>\n**   <li> ^(Database zDb does not exist)^, \n**   <li> ^(Table zTable does not exist within database zDb)^, \n**   <li> ^(Table zTable is a WITHOUT ROWID table)^, \n**   <li> ^(Column zColumn does not exist)^,\n**   <li> ^(Row iRow is not present in the table)^,\n**   <li> ^(The specified column of row iRow contains a value that is not\n**         a TEXT or BLOB value)^,\n**   <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE \n**         constraint and the blob is being opened for read/write access)^,\n**   <li> ^([foreign key constraints | Foreign key constraints] are enabled, \n**         column zColumn is part of a [child key] definition and the blob is\n**         being opened for read/write access)^.\n** </ul>\n**\n** ^Unless it returns SQLITE_MISUSE, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** A BLOB referenced by sqlite3_blob_open() may be read using the\n** [sqlite3_blob_read()] interface and modified by using\n** [sqlite3_blob_write()].  The [BLOB handle] can be moved to a\n** different row of the same table using the [sqlite3_blob_reopen()]\n** interface.  However, the column, table, or database of a [BLOB handle]\n** cannot be changed after the [BLOB handle] is opened.\n**\n** ^(If the row that a BLOB handle points to is modified by an\n** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects\n** then the BLOB handle is marked as \"expired\".\n** This is true if any column of the row is changed, even a column\n** other than the one the BLOB handle is open on.)^\n** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for\n** an expired BLOB handle fail with a return code of [SQLITE_ABORT].\n** ^(Changes written into a BLOB prior to the BLOB expiring are not\n** rolled back by the expiration of the BLOB.  Such changes will eventually\n** commit if the transaction continues to completion.)^\n**\n** ^Use the [sqlite3_blob_bytes()] interface to determine the size of\n** the opened blob.  ^The size of a blob may not be changed by this\n** interface.  Use the [UPDATE] SQL command to change the size of a\n** blob.\n**\n** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces\n** and the built-in [zeroblob] SQL function may be used to create a \n** zero-filled blob to read or write using the incremental-blob interface.\n**\n** To avoid a resource leak, every open [BLOB handle] should eventually\n** be released by a call to [sqlite3_blob_close()].\n**\n** See also: [sqlite3_blob_close()],\n** [sqlite3_blob_reopen()], [sqlite3_blob_read()],\n** [sqlite3_blob_bytes()], [sqlite3_blob_write()].\n*/\nint sqlite3_blob_open(\n  sqlite3*,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite3_int64 iRow,\n  int flags,\n  sqlite3_blob **ppBlob\n);\n\n/*\n** CAPI3REF: Move a BLOB Handle to a New Row\n** METHOD: sqlite3_blob\n**\n** ^This function is used to move an existing [BLOB handle] so that it points\n** to a different row of the same database table. ^The new row is identified\n** by the rowid value passed as the second argument. Only the row can be\n** changed. ^The database, table and column on which the blob handle is open\n** remain the same. Moving an existing [BLOB handle] to a new row is\n** faster than closing the existing handle and opening a new one.\n**\n** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -\n** it must exist and there must be either a blob or text value stored in\n** the nominated column.)^ ^If the new row is not present in the table, or if\n** it does not contain a blob or text value, or if another error occurs, an\n** SQLite error code is returned and the blob handle is considered aborted.\n** ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or\n** [sqlite3_blob_reopen()] on an aborted blob handle immediately return\n** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle\n** always returns zero.\n**\n** ^This function sets the database handle error code and message.\n*/\nint sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);\n\n/*\n** CAPI3REF: Close A BLOB Handle\n** DESTRUCTOR: sqlite3_blob\n**\n** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed\n** unconditionally.  Even if this routine returns an error code, the \n** handle is still closed.)^\n**\n** ^If the blob handle being closed was opened for read-write access, and if\n** the database is in auto-commit mode and there are no other open read-write\n** blob handles or active write statements, the current transaction is\n** committed. ^If an error occurs while committing the transaction, an error\n** code is returned and the transaction rolled back.\n**\n** Calling this function with an argument that is not a NULL pointer or an\n** open blob handle results in undefined behaviour. ^Calling this routine \n** with a null pointer (such as would be returned by a failed call to \n** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function\n** is passed a valid open blob handle, the values returned by the \n** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.\n*/\nint sqlite3_blob_close(sqlite3_blob *);\n\n/*\n** CAPI3REF: Return The Size Of An Open BLOB\n** METHOD: sqlite3_blob\n**\n** ^Returns the size in bytes of the BLOB accessible via the \n** successfully opened [BLOB handle] in its only argument.  ^The\n** incremental blob I/O routines can only read or overwriting existing\n** blob content; they cannot change the size of a blob.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n*/\nint sqlite3_blob_bytes(sqlite3_blob *);\n\n/*\n** CAPI3REF: Read Data From A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to read data from an open [BLOB handle] into a\n** caller-supplied buffer. N bytes of data are copied into buffer Z\n** from the open BLOB, starting at offset iOffset.)^\n**\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is read.  ^If N or iOffset is\n** less than zero, [SQLITE_ERROR] is returned and no data is read.\n** ^The size of the blob (and hence the maximum value of N+iOffset)\n** can be determined using the [sqlite3_blob_bytes()] interface.\n**\n** ^An attempt to read from an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].\n**\n** ^(On success, sqlite3_blob_read() returns SQLITE_OK.\n** Otherwise, an [error code] or an [extended error code] is returned.)^\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_write()].\n*/\nint sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);\n\n/*\n** CAPI3REF: Write Data Into A BLOB Incrementally\n** METHOD: sqlite3_blob\n**\n** ^(This function is used to write data into an open [BLOB handle] from a\n** caller-supplied buffer. N bytes of data are copied from the buffer Z\n** into the open BLOB, starting at offset iOffset.)^\n**\n** ^(On success, sqlite3_blob_write() returns SQLITE_OK.\n** Otherwise, an  [error code] or an [extended error code] is returned.)^\n** ^Unless SQLITE_MISUSE is returned, this function sets the \n** [database connection] error code and message accessible via \n** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. \n**\n** ^If the [BLOB handle] passed as the first argument was not opened for\n** writing (the flags parameter to [sqlite3_blob_open()] was zero),\n** this function returns [SQLITE_READONLY].\n**\n** This function may only modify the contents of the BLOB; it is\n** not possible to increase the size of a BLOB using this API.\n** ^If offset iOffset is less than N bytes from the end of the BLOB,\n** [SQLITE_ERROR] is returned and no data is written. The size of the \n** BLOB (and hence the maximum value of N+iOffset) can be determined \n** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less \n** than zero [SQLITE_ERROR] is returned and no data is written.\n**\n** ^An attempt to write to an expired [BLOB handle] fails with an\n** error code of [SQLITE_ABORT].  ^Writes to the BLOB that occurred\n** before the [BLOB handle] expired are not rolled back by the\n** expiration of the handle, though of course those changes might\n** have been overwritten by the statement that expired the BLOB handle\n** or by other independent statements.\n**\n** This routine only works on a [BLOB handle] which has been created\n** by a prior successful call to [sqlite3_blob_open()] and which has not\n** been closed by [sqlite3_blob_close()].  Passing any other pointer in\n** to this routine results in undefined and probably undesirable behavior.\n**\n** See also: [sqlite3_blob_read()].\n*/\nint sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);\n\n/*\n** CAPI3REF: Virtual File System Objects\n**\n** A virtual filesystem (VFS) is an [sqlite3_vfs] object\n** that SQLite uses to interact\n** with the underlying operating system.  Most SQLite builds come with a\n** single default VFS that is appropriate for the host computer.\n** New VFSes can be registered and existing VFSes can be unregistered.\n** The following interfaces are provided.\n**\n** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.\n** ^Names are case sensitive.\n** ^Names are zero-terminated UTF-8 strings.\n** ^If there is no match, a NULL pointer is returned.\n** ^If zVfsName is NULL then the default VFS is returned.\n**\n** ^New VFSes are registered with sqlite3_vfs_register().\n** ^Each new VFS becomes the default VFS if the makeDflt flag is set.\n** ^The same VFS can be registered multiple times without injury.\n** ^To make an existing VFS into the default VFS, register it again\n** with the makeDflt flag set.  If two different VFSes with the\n** same name are registered, the behavior is undefined.  If a\n** VFS is registered with a name that is NULL or an empty string,\n** then the behavior is undefined.\n**\n** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.\n** ^(If the default VFS is unregistered, another VFS is chosen as\n** the default.  The choice for the new VFS is arbitrary.)^\n*/\nsqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);\nint sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);\nint sqlite3_vfs_unregister(sqlite3_vfs*);\n\n/*\n** CAPI3REF: Mutexes\n**\n** The SQLite core uses these routines for thread\n** synchronization. Though they are intended for internal\n** use by SQLite, code that links against SQLite is\n** permitted to use any of these routines.\n**\n** The SQLite source code contains multiple implementations\n** of these mutex routines.  An appropriate implementation\n** is selected automatically at compile-time.  The following\n** implementations are available in the SQLite core:\n**\n** <ul>\n** <li>   SQLITE_MUTEX_PTHREADS\n** <li>   SQLITE_MUTEX_W32\n** <li>   SQLITE_MUTEX_NOOP\n** </ul>\n**\n** The SQLITE_MUTEX_NOOP implementation is a set of routines\n** that does no real locking and is appropriate for use in\n** a single-threaded application.  The SQLITE_MUTEX_PTHREADS and\n** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix\n** and Windows.\n**\n** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor\n** macro defined (with \"-DSQLITE_MUTEX_APPDEF=1\"), then no mutex\n** implementation is included with the library. In this case the\n** application must supply a custom mutex implementation using the\n** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function\n** before calling sqlite3_initialize() or any other public sqlite3_\n** function that calls sqlite3_initialize().\n**\n** ^The sqlite3_mutex_alloc() routine allocates a new\n** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()\n** routine returns NULL if it is unable to allocate the requested\n** mutex.  The argument to sqlite3_mutex_alloc() must one of these\n** integer constants:\n**\n** <ul>\n** <li>  SQLITE_MUTEX_FAST\n** <li>  SQLITE_MUTEX_RECURSIVE\n** <li>  SQLITE_MUTEX_STATIC_MASTER\n** <li>  SQLITE_MUTEX_STATIC_MEM\n** <li>  SQLITE_MUTEX_STATIC_OPEN\n** <li>  SQLITE_MUTEX_STATIC_PRNG\n** <li>  SQLITE_MUTEX_STATIC_LRU\n** <li>  SQLITE_MUTEX_STATIC_PMEM\n** <li>  SQLITE_MUTEX_STATIC_APP1\n** <li>  SQLITE_MUTEX_STATIC_APP2\n** <li>  SQLITE_MUTEX_STATIC_APP3\n** <li>  SQLITE_MUTEX_STATIC_VFS1\n** <li>  SQLITE_MUTEX_STATIC_VFS2\n** <li>  SQLITE_MUTEX_STATIC_VFS3\n** </ul>\n**\n** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)\n** cause sqlite3_mutex_alloc() to create\n** a new mutex.  ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE\n** is used but not necessarily so when SQLITE_MUTEX_FAST is used.\n** The mutex implementation does not need to make a distinction\n** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does\n** not want to.  SQLite will only request a recursive mutex in\n** cases where it really needs one.  If a faster non-recursive mutex\n** implementation is available on the host platform, the mutex subsystem\n** might return such a mutex in response to SQLITE_MUTEX_FAST.\n**\n** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other\n** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return\n** a pointer to a static preexisting mutex.  ^Nine static mutexes are\n** used by the current version of SQLite.  Future versions of SQLite\n** may add additional static mutexes.  Static mutexes are for internal\n** use by SQLite only.  Applications that use SQLite mutexes should\n** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or\n** SQLITE_MUTEX_RECURSIVE.\n**\n** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST\n** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()\n** returns a different mutex on every call.  ^For the static\n** mutex types, the same mutex is returned on every call that has\n** the same type number.\n**\n** ^The sqlite3_mutex_free() routine deallocates a previously\n** allocated dynamic mutex.  Attempting to deallocate a static\n** mutex results in undefined behavior.\n**\n** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt\n** to enter a mutex.  ^If another thread is already within the mutex,\n** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return\n** SQLITE_BUSY.  ^The sqlite3_mutex_try() interface returns [SQLITE_OK]\n** upon successful entry.  ^(Mutexes created using\n** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.\n** In such cases, the\n** mutex must be exited an equal number of times before another thread\n** can enter.)^  If the same thread tries to enter any mutex other\n** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.\n**\n** ^(Some systems (for example, Windows 95) do not support the operation\n** implemented by sqlite3_mutex_try().  On those systems, sqlite3_mutex_try()\n** will always return SQLITE_BUSY. The SQLite core only ever uses\n** sqlite3_mutex_try() as an optimization so this is acceptable \n** behavior.)^\n**\n** ^The sqlite3_mutex_leave() routine exits a mutex that was\n** previously entered by the same thread.   The behavior\n** is undefined if the mutex is not currently entered by the\n** calling thread or is not currently allocated.\n**\n** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or\n** sqlite3_mutex_leave() is a NULL pointer, then all three routines\n** behave as no-ops.\n**\n** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].\n*/\nsqlite3_mutex *sqlite3_mutex_alloc(int);\nvoid sqlite3_mutex_free(sqlite3_mutex*);\nvoid sqlite3_mutex_enter(sqlite3_mutex*);\nint sqlite3_mutex_try(sqlite3_mutex*);\nvoid sqlite3_mutex_leave(sqlite3_mutex*);\n\n/*\n** CAPI3REF: Mutex Methods Object\n**\n** An instance of this structure defines the low-level routines\n** used to allocate and use mutexes.\n**\n** Usually, the default mutex implementations provided by SQLite are\n** sufficient, however the application has the option of substituting a custom\n** implementation for specialized deployments or systems for which SQLite\n** does not provide a suitable implementation. In this case, the application\n** creates and populates an instance of this structure to pass\n** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.\n** Additionally, an instance of this structure can be used as an\n** output variable when querying the system for the current mutex\n** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.\n**\n** ^The xMutexInit method defined by this structure is invoked as\n** part of system initialization by the sqlite3_initialize() function.\n** ^The xMutexInit routine is called by SQLite exactly once for each\n** effective call to [sqlite3_initialize()].\n**\n** ^The xMutexEnd method defined by this structure is invoked as\n** part of system shutdown by the sqlite3_shutdown() function. The\n** implementation of this method is expected to release all outstanding\n** resources obtained by the mutex methods implementation, especially\n** those obtained by the xMutexInit method.  ^The xMutexEnd()\n** interface is invoked exactly once for each call to [sqlite3_shutdown()].\n**\n** ^(The remaining seven methods defined by this structure (xMutexAlloc,\n** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and\n** xMutexNotheld) implement the following interfaces (respectively):\n**\n** <ul>\n**   <li>  [sqlite3_mutex_alloc()] </li>\n**   <li>  [sqlite3_mutex_free()] </li>\n**   <li>  [sqlite3_mutex_enter()] </li>\n**   <li>  [sqlite3_mutex_try()] </li>\n**   <li>  [sqlite3_mutex_leave()] </li>\n**   <li>  [sqlite3_mutex_held()] </li>\n**   <li>  [sqlite3_mutex_notheld()] </li>\n** </ul>)^\n**\n** The only difference is that the public sqlite3_XXX functions enumerated\n** above silently ignore any invocations that pass a NULL pointer instead\n** of a valid mutex handle. The implementations of the methods defined\n** by this structure are not required to handle this case, the results\n** of passing a NULL pointer instead of a valid mutex handle are undefined\n** (i.e. it is acceptable to provide an implementation that segfaults if\n** it is passed a NULL pointer).\n**\n** The xMutexInit() method must be threadsafe.  It must be harmless to\n** invoke xMutexInit() multiple times within the same process and without\n** intervening calls to xMutexEnd().  Second and subsequent calls to\n** xMutexInit() must be no-ops.\n**\n** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]\n** and its associates).  Similarly, xMutexAlloc() must not use SQLite memory\n** allocation for a static mutex.  ^However xMutexAlloc() may use SQLite\n** memory allocation for a fast or recursive mutex.\n**\n** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is\n** called, but only if the prior call to xMutexInit returned SQLITE_OK.\n** If xMutexInit fails in any way, it is expected to clean up after itself\n** prior to returning.\n*/\ntypedef struct sqlite3_mutex_methods sqlite3_mutex_methods;\nstruct sqlite3_mutex_methods {\n  int (*xMutexInit)(void);\n  int (*xMutexEnd)(void);\n  sqlite3_mutex *(*xMutexAlloc)(int);\n  void (*xMutexFree)(sqlite3_mutex *);\n  void (*xMutexEnter)(sqlite3_mutex *);\n  int (*xMutexTry)(sqlite3_mutex *);\n  void (*xMutexLeave)(sqlite3_mutex *);\n  int (*xMutexHeld)(sqlite3_mutex *);\n  int (*xMutexNotheld)(sqlite3_mutex *);\n};\n\n/*\n** CAPI3REF: Mutex Verification Routines\n**\n** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines\n** are intended for use inside assert() statements.  The SQLite core\n** never uses these routines except inside an assert() and applications\n** are advised to follow the lead of the core.  The SQLite core only\n** provides implementations for these routines when it is compiled\n** with the SQLITE_DEBUG flag.  External mutex implementations\n** are only required to provide these routines if SQLITE_DEBUG is\n** defined and if NDEBUG is not defined.\n**\n** These routines should return true if the mutex in their argument\n** is held or not held, respectively, by the calling thread.\n**\n** The implementation is not required to provide versions of these\n** routines that actually work. If the implementation does not provide working\n** versions of these routines, it should at least provide stubs that always\n** return true so that one does not get spurious assertion failures.\n**\n** If the argument to sqlite3_mutex_held() is a NULL pointer then\n** the routine should return 1.   This seems counter-intuitive since\n** clearly the mutex cannot be held if it does not exist.  But\n** the reason the mutex does not exist is because the build is not\n** using mutexes.  And we do not want the assert() containing the\n** call to sqlite3_mutex_held() to fail, so a non-zero return is\n** the appropriate thing to do.  The sqlite3_mutex_notheld()\n** interface should also return 1 when given a NULL pointer.\n*/\n#ifndef NDEBUG\nint sqlite3_mutex_held(sqlite3_mutex*);\nint sqlite3_mutex_notheld(sqlite3_mutex*);\n#endif\n\n/*\n** CAPI3REF: Mutex Types\n**\n** The [sqlite3_mutex_alloc()] interface takes a single argument\n** which is one of these integer constants.\n**\n** The set of static mutexes may change from one SQLite release to the\n** next.  Applications that override the built-in mutex logic must be\n** prepared to accommodate additional static mutexes.\n*/\n#define SQLITE_MUTEX_FAST             0\n#define SQLITE_MUTEX_RECURSIVE        1\n#define SQLITE_MUTEX_STATIC_MASTER    2\n#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */\n#define SQLITE_MUTEX_STATIC_MEM2      4  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_OPEN      4  /* sqlite3BtreeOpen() */\n#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_randomness() */\n#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */\n#define SQLITE_MUTEX_STATIC_LRU2      7  /* NOT USED */\n#define SQLITE_MUTEX_STATIC_PMEM      7  /* sqlite3PageMalloc() */\n#define SQLITE_MUTEX_STATIC_APP1      8  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP2      9  /* For use by application */\n#define SQLITE_MUTEX_STATIC_APP3     10  /* For use by application */\n#define SQLITE_MUTEX_STATIC_VFS1     11  /* For use by built-in VFS */\n#define SQLITE_MUTEX_STATIC_VFS2     12  /* For use by extension VFS */\n#define SQLITE_MUTEX_STATIC_VFS3     13  /* For use by application VFS */\n\n/*\n** CAPI3REF: Retrieve the mutex for a database connection\n** METHOD: sqlite3\n**\n** ^This interface returns a pointer the [sqlite3_mutex] object that \n** serializes access to the [database connection] given in the argument\n** when the [threading mode] is Serialized.\n** ^If the [threading mode] is Single-thread or Multi-thread then this\n** routine returns a NULL pointer.\n*/\nsqlite3_mutex *sqlite3_db_mutex(sqlite3*);\n\n/*\n** CAPI3REF: Low-Level Control Of Database Files\n** METHOD: sqlite3\n**\n** ^The [sqlite3_file_control()] interface makes a direct call to the\n** xFileControl method for the [sqlite3_io_methods] object associated\n** with a particular database identified by the second argument. ^The\n** name of the database is \"main\" for the main database or \"temp\" for the\n** TEMP database, or the name that appears after the AS keyword for\n** databases that are added using the [ATTACH] SQL command.\n** ^A NULL pointer can be used in place of \"main\" to refer to the\n** main database file.\n** ^The third and fourth parameters to this routine\n** are passed directly through to the second and third parameters of\n** the xFileControl method.  ^The return value of the xFileControl\n** method becomes the return value of this routine.\n**\n** ^The SQLITE_FCNTL_FILE_POINTER value for the op parameter causes\n** a pointer to the underlying [sqlite3_file] object to be written into\n** the space pointed to by the 4th parameter.  ^The SQLITE_FCNTL_FILE_POINTER\n** case is a short-circuit path which does not actually invoke the\n** underlying sqlite3_io_methods.xFileControl method.\n**\n** ^If the second parameter (zDbName) does not match the name of any\n** open database file, then SQLITE_ERROR is returned.  ^This error\n** code is not remembered and will not be recalled by [sqlite3_errcode()]\n** or [sqlite3_errmsg()].  The underlying xFileControl method might\n** also return SQLITE_ERROR.  There is no way to distinguish between\n** an incorrect zDbName and an SQLITE_ERROR return from the underlying\n** xFileControl method.\n**\n** See also: [SQLITE_FCNTL_LOCKSTATE]\n*/\nint sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);\n\n/*\n** CAPI3REF: Testing Interface\n**\n** ^The sqlite3_test_control() interface is used to read out internal\n** state of SQLite and to inject faults into SQLite for testing\n** purposes.  ^The first parameter is an operation code that determines\n** the number, meaning, and operation of all subsequent parameters.\n**\n** This interface is not for use by applications.  It exists solely\n** for verifying the correct operation of the SQLite library.  Depending\n** on how the SQLite library is compiled, this interface might not exist.\n**\n** The details of the operation codes, their meanings, the parameters\n** they take, and what they do are all subject to change without notice.\n** Unlike most of the SQLite API, this function is not guaranteed to\n** operate consistently from one release to the next.\n*/\nint sqlite3_test_control(int op, ...);\n\n/*\n** CAPI3REF: Testing Interface Operation Codes\n**\n** These constants are the valid operation code parameters used\n** as the first argument to [sqlite3_test_control()].\n**\n** These parameters and their meanings are subject to change\n** without notice.  These values are for testing purposes only.\n** Applications should not use any of these parameters or the\n** [sqlite3_test_control()] interface.\n*/\n#define SQLITE_TESTCTRL_FIRST                    5\n#define SQLITE_TESTCTRL_PRNG_SAVE                5\n#define SQLITE_TESTCTRL_PRNG_RESTORE             6\n#define SQLITE_TESTCTRL_PRNG_RESET               7\n#define SQLITE_TESTCTRL_BITVEC_TEST              8\n#define SQLITE_TESTCTRL_FAULT_INSTALL            9\n#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10\n#define SQLITE_TESTCTRL_PENDING_BYTE            11\n#define SQLITE_TESTCTRL_ASSERT                  12\n#define SQLITE_TESTCTRL_ALWAYS                  13\n#define SQLITE_TESTCTRL_RESERVE                 14\n#define SQLITE_TESTCTRL_OPTIMIZATIONS           15\n#define SQLITE_TESTCTRL_ISKEYWORD               16\n#define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */\n#define SQLITE_TESTCTRL_LOCALTIME_FAULT         18\n#define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */\n#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19\n#define SQLITE_TESTCTRL_NEVER_CORRUPT           20\n#define SQLITE_TESTCTRL_VDBE_COVERAGE           21\n#define SQLITE_TESTCTRL_BYTEORDER               22\n#define SQLITE_TESTCTRL_ISINIT                  23\n#define SQLITE_TESTCTRL_SORTER_MMAP             24\n#define SQLITE_TESTCTRL_IMPOSTER                25\n#define SQLITE_TESTCTRL_LAST                    25\n\n/*\n** CAPI3REF: SQLite Runtime Status\n**\n** ^These interfaces are used to retrieve runtime status information\n** about the performance of SQLite, and optionally to reset various\n** highwater marks.  ^The first argument is an integer code for\n** the specific parameter to measure.  ^(Recognized integer codes\n** are of the form [status parameters | SQLITE_STATUS_...].)^\n** ^The current value of the parameter is returned into *pCurrent.\n** ^The highest recorded value is returned in *pHighwater.  ^If the\n** resetFlag is true, then the highest record value is reset after\n** *pHighwater is written.  ^(Some parameters do not record the highest\n** value.  For those parameters\n** nothing is written into *pHighwater and the resetFlag is ignored.)^\n** ^(Other parameters record only the highwater mark and not the current\n** value.  For these latter parameters nothing is written into *pCurrent.)^\n**\n** ^The sqlite3_status() and sqlite3_status64() routines return\n** SQLITE_OK on success and a non-zero [error code] on failure.\n**\n** If either the current value or the highwater mark is too large to\n** be represented by a 32-bit integer, then the values returned by\n** sqlite3_status() are undefined.\n**\n** See also: [sqlite3_db_status()]\n*/\nint sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);\nint sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n);\n\n\n/*\n** CAPI3REF: Status Parameters\n** KEYWORDS: {status parameters}\n**\n** These integer constants designate various run-time status parameters\n** that can be returned by [sqlite3_status()].\n**\n** <dl>\n** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>\n** <dd>This parameter is the current amount of memory checked out\n** using [sqlite3_malloc()], either directly or indirectly.  The\n** figure includes calls made to [sqlite3_malloc()] by the application\n** and internal memory usage by the SQLite library.  Auxiliary page-cache\n** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in\n** this parameter.  The amount returned is the sum of the allocation\n** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their\n** internal equivalents).  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>\n** <dd>This parameter records the number of separate memory allocations\n** currently checked out.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>\n** <dd>This parameter returns the number of pages used out of the\n** [pagecache memory allocator] that was configured using \n** [SQLITE_CONFIG_PAGECACHE].  The\n** value returned is in pages, not in bytes.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]] \n** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>\n** <dd>This parameter returns the number of bytes of page cache\n** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]\n** buffer and where forced to overflow to [sqlite3_malloc()].  The\n** returned value includes allocations that overflowed because they\n** where too large (they were larger than the \"sz\" parameter to\n** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because\n** no space was left in the page cache.</dd>)^\n**\n** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>\n** <dd>This parameter records the largest memory allocation request\n** handed to [pagecache memory allocator].  Only the value returned in the\n** *pHighwater parameter to [sqlite3_status()] is of interest.  \n** The value written into the *pCurrent parameter is undefined.</dd>)^\n**\n** [[SQLITE_STATUS_SCRATCH_USED]] <dt>SQLITE_STATUS_SCRATCH_USED</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_SCRATCH_SIZE]] <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>\n** <dd>No longer used.</dd>\n**\n** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>\n** <dd>The *pHighwater parameter records the deepest parser stack. \n** The *pCurrent value is undefined.  The *pHighwater value is only\n** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^\n** </dl>\n**\n** New status parameters may be added from time to time.\n*/\n#define SQLITE_STATUS_MEMORY_USED          0\n#define SQLITE_STATUS_PAGECACHE_USED       1\n#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2\n#define SQLITE_STATUS_SCRATCH_USED         3  /* NOT USED */\n#define SQLITE_STATUS_SCRATCH_OVERFLOW     4  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_SIZE          5\n#define SQLITE_STATUS_PARSER_STACK         6\n#define SQLITE_STATUS_PAGECACHE_SIZE       7\n#define SQLITE_STATUS_SCRATCH_SIZE         8  /* NOT USED */\n#define SQLITE_STATUS_MALLOC_COUNT         9\n\n/*\n** CAPI3REF: Database Connection Status\n** METHOD: sqlite3\n**\n** ^This interface is used to retrieve runtime status information \n** about a single [database connection].  ^The first argument is the\n** database connection object to be interrogated.  ^The second argument\n** is an integer constant, taken from the set of\n** [SQLITE_DBSTATUS options], that\n** determines the parameter to interrogate.  The set of \n** [SQLITE_DBSTATUS options] is likely\n** to grow in future releases of SQLite.\n**\n** ^The current value of the requested parameter is written into *pCur\n** and the highest instantaneous value is written into *pHiwtr.  ^If\n** the resetFlg is true, then the highest instantaneous value is\n** reset back down to the current value.\n**\n** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a\n** non-zero [error code] on failure.\n**\n** See also: [sqlite3_status()] and [sqlite3_stmt_status()].\n*/\nint sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for database connections\n** KEYWORDS: {SQLITE_DBSTATUS options}\n**\n** These constants are the available integer \"verbs\" that can be passed as\n** the second argument to the [sqlite3_db_status()] interface.\n**\n** New verbs may be added in future releases of SQLite. Existing verbs\n** might be discontinued. Applications should check the return code from\n** [sqlite3_db_status()] to make sure that the call worked.\n** The [sqlite3_db_status()] interface will return a non-zero error code\n** if a discontinued or unsupported verb is invoked.\n**\n** <dl>\n** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>\n** <dd>This parameter returns the number of lookaside memory slots currently\n** checked out.</dd>)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>\n** <dd>This parameter returns the number malloc attempts that were \n** satisfied using lookaside memory. Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to the amount of\n** memory requested being larger than the lookaside slot size.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]\n** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>\n** <dd>This parameter returns the number malloc attempts that might have\n** been satisfied using lookaside memory but failed due to all lookaside\n** memory already being in use.\n** Only the high-water value is meaningful;\n** the current value is always zero.)^\n**\n** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used by all pager caches associated with the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] \n** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>\n** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a\n** pager cache is shared between two or more connections the bytes of heap\n** memory used by that pager cache is divided evenly between the attached\n** connections.)^  In other words, if none of the pager caches associated\n** with the database connection are shared, this request returns the same\n** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are\n** shared, the value returned by this call will be smaller than that returned\n** by DBSTATUS_CACHE_USED. ^The highwater mark associated with\n** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.\n**\n** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** memory used to store the schema for all databases associated\n** with the connection - main, temp, and any [ATTACH]-ed databases.)^ \n** ^The full amount of memory used by the schemas is reported, even if the\n** schema memory is shared with other database connections due to\n** [shared cache mode] being enabled.\n** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.\n**\n** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>\n** <dd>This parameter returns the approximate number of bytes of heap\n** and lookaside memory used by all prepared statements associated with\n** the database connection.)^\n** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>\n** <dd>This parameter returns the number of pager cache hits that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>\n** <dd>This parameter returns the number of pager cache misses that have\n** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS \n** is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>\n** <dd>This parameter returns the number of dirty cache entries that have\n** been written to disk. Specifically, the number of pages written to the\n** wal file in wal mode databases, or the number of pages written to the\n** database file in rollback mode databases. Any pages written as part of\n** transaction rollback or database recovery operations are not included.\n** If an IO or other error occurs while writing a page to disk, the effect\n** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The\n** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.\n** </dd>\n**\n** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>\n** <dd>This parameter returns zero for the current value if and only if\n** all foreign key constraints (deferred or immediate) have been\n** resolved.)^  ^The highwater mark is always 0.\n** </dd>\n** </dl>\n*/\n#define SQLITE_DBSTATUS_LOOKASIDE_USED       0\n#define SQLITE_DBSTATUS_CACHE_USED           1\n#define SQLITE_DBSTATUS_SCHEMA_USED          2\n#define SQLITE_DBSTATUS_STMT_USED            3\n#define SQLITE_DBSTATUS_LOOKASIDE_HIT        4\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  5\n#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  6\n#define SQLITE_DBSTATUS_CACHE_HIT            7\n#define SQLITE_DBSTATUS_CACHE_MISS           8\n#define SQLITE_DBSTATUS_CACHE_WRITE          9\n#define SQLITE_DBSTATUS_DEFERRED_FKS        10\n#define SQLITE_DBSTATUS_CACHE_USED_SHARED   11\n#define SQLITE_DBSTATUS_MAX                 11   /* Largest defined DBSTATUS */\n\n\n/*\n** CAPI3REF: Prepared Statement Status\n** METHOD: sqlite3_stmt\n**\n** ^(Each prepared statement maintains various\n** [SQLITE_STMTSTATUS counters] that measure the number\n** of times it has performed specific operations.)^  These counters can\n** be used to monitor the performance characteristics of the prepared\n** statements.  For example, if the number of table steps greatly exceeds\n** the number of table searches or result rows, that would tend to indicate\n** that the prepared statement is using a full table scan rather than\n** an index.  \n**\n** ^(This interface is used to retrieve and reset counter values from\n** a [prepared statement].  The first argument is the prepared statement\n** object to be interrogated.  The second argument\n** is an integer code for a specific [SQLITE_STMTSTATUS counter]\n** to be interrogated.)^\n** ^The current value of the requested counter is returned.\n** ^If the resetFlg is true, then the counter is reset to zero after this\n** interface call returns.\n**\n** See also: [sqlite3_status()] and [sqlite3_db_status()].\n*/\nint sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);\n\n/*\n** CAPI3REF: Status Parameters for prepared statements\n** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}\n**\n** These preprocessor macros define integer codes that name counter\n** values associated with the [sqlite3_stmt_status()] interface.\n** The meanings of the various counters are as follows:\n**\n** <dl>\n** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>\n** <dd>^This is the number of times that SQLite has stepped forward in\n** a table as part of a full table scan.  Large numbers for this counter\n** may indicate opportunities for performance improvement through \n** careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>\n** <dd>^This is the number of sort operations that have occurred.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance through careful use of indices.</dd>\n**\n** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>\n** <dd>^This is the number of rows inserted into transient indices that\n** were created automatically in order to help joins run faster.\n** A non-zero value in this counter may indicate an opportunity to\n** improvement performance by adding permanent indices that do not\n** need to be reinitialized each time the statement is run.</dd>\n**\n** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>\n** <dd>^This is the number of virtual machine operations executed\n** by the prepared statement if that number is less than or equal\n** to 2147483647.  The number of virtual machine operations can be \n** used as a proxy for the total work done by the prepared statement.\n** If the number of virtual machine operations exceeds 2147483647\n** then the value returned by this statement status code is undefined.\n**\n** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt>\n** <dd>^This is the number of times that the prepare statement has been\n** automatically regenerated due to schema changes or change to \n** [bound parameters] that might affect the query plan.\n**\n** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt>\n** <dd>^This is the number of times that the prepared statement has\n** been run.  A single \"run\" for the purposes of this counter is one\n** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()].\n** The counter is incremented on the first [sqlite3_step()] call of each\n** cycle.\n**\n** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>\n** <dd>^This is the approximate number of bytes of heap memory\n** used to store the prepared statement.  ^This value is not actually\n** a counter, and so the resetFlg parameter to sqlite3_stmt_status()\n** is ignored when the opcode is SQLITE_STMTSTATUS_MEMUSED.\n** </dd>\n** </dl>\n*/\n#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1\n#define SQLITE_STMTSTATUS_SORT              2\n#define SQLITE_STMTSTATUS_AUTOINDEX         3\n#define SQLITE_STMTSTATUS_VM_STEP           4\n#define SQLITE_STMTSTATUS_REPREPARE         5\n#define SQLITE_STMTSTATUS_RUN               6\n#define SQLITE_STMTSTATUS_MEMUSED           99\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache type is opaque.  It is implemented by\n** the pluggable module.  The SQLite core has no knowledge of\n** its size or internal structure and never deals with the\n** sqlite3_pcache object except by holding and passing pointers\n** to the object.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache sqlite3_pcache;\n\n/*\n** CAPI3REF: Custom Page Cache Object\n**\n** The sqlite3_pcache_page object represents a single page in the\n** page cache.  The page cache will allocate instances of this\n** object.  Various methods of the page cache use pointers to instances\n** of this object as parameters or as their return value.\n**\n** See [sqlite3_pcache_methods2] for additional information.\n*/\ntypedef struct sqlite3_pcache_page sqlite3_pcache_page;\nstruct sqlite3_pcache_page {\n  void *pBuf;        /* The content of the page */\n  void *pExtra;      /* Extra information associated with the page */\n};\n\n/*\n** CAPI3REF: Application Defined Page Cache.\n** KEYWORDS: {page cache}\n**\n** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can\n** register an alternative page cache implementation by passing in an \n** instance of the sqlite3_pcache_methods2 structure.)^\n** In many applications, most of the heap memory allocated by \n** SQLite is used for the page cache.\n** By implementing a \n** custom page cache using this API, an application can better control\n** the amount of memory consumed by SQLite, the way in which \n** that memory is allocated and released, and the policies used to \n** determine exactly which parts of a database file are cached and for \n** how long.\n**\n** The alternative page cache mechanism is an\n** extreme measure that is only needed by the most demanding applications.\n** The built-in page cache is recommended for most uses.\n**\n** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an\n** internal buffer by SQLite within the call to [sqlite3_config].  Hence\n** the application may discard the parameter after the call to\n** [sqlite3_config()] returns.)^\n**\n** [[the xInit() page cache method]]\n** ^(The xInit() method is called once for each effective \n** call to [sqlite3_initialize()])^\n** (usually only once during the lifetime of the process). ^(The xInit()\n** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^\n** The intent of the xInit() method is to set up global data structures \n** required by the custom page cache implementation. \n** ^(If the xInit() method is NULL, then the \n** built-in default page cache is used instead of the application defined\n** page cache.)^\n**\n** [[the xShutdown() page cache method]]\n** ^The xShutdown() method is called by [sqlite3_shutdown()].\n** It can be used to clean up \n** any outstanding resources before process shutdown, if required.\n** ^The xShutdown() method may be NULL.\n**\n** ^SQLite automatically serializes calls to the xInit method,\n** so the xInit method need not be threadsafe.  ^The\n** xShutdown method is only called from [sqlite3_shutdown()] so it does\n** not need to be threadsafe either.  All other methods must be threadsafe\n** in multithreaded applications.\n**\n** ^SQLite will never invoke xInit() more than once without an intervening\n** call to xShutdown().\n**\n** [[the xCreate() page cache methods]]\n** ^SQLite invokes the xCreate() method to construct a new cache instance.\n** SQLite will typically create one cache instance for each open database file,\n** though this is not guaranteed. ^The\n** first parameter, szPage, is the size in bytes of the pages that must\n** be allocated by the cache.  ^szPage will always a power of two.  ^The\n** second parameter szExtra is a number of bytes of extra storage \n** associated with each page cache entry.  ^The szExtra parameter will\n** a number less than 250.  SQLite will use the\n** extra szExtra bytes on each page to store metadata about the underlying\n** database page on disk.  The value passed into szExtra depends\n** on the SQLite version, the target platform, and how SQLite was compiled.\n** ^The third argument to xCreate(), bPurgeable, is true if the cache being\n** created will be used to cache database pages of a file stored on disk, or\n** false if it is used for an in-memory database. The cache implementation\n** does not have to do anything special based with the value of bPurgeable;\n** it is purely advisory.  ^On a cache where bPurgeable is false, SQLite will\n** never invoke xUnpin() except to deliberately delete a page.\n** ^In other words, calls to xUnpin() on a cache with bPurgeable set to\n** false will always have the \"discard\" flag set to true.  \n** ^Hence, a cache created with bPurgeable false will\n** never contain any unpinned pages.\n**\n** [[the xCachesize() page cache method]]\n** ^(The xCachesize() method may be called at any time by SQLite to set the\n** suggested maximum cache-size (number of pages stored by) the cache\n** instance passed as the first argument. This is the value configured using\n** the SQLite \"[PRAGMA cache_size]\" command.)^  As with the bPurgeable\n** parameter, the implementation is not required to do anything with this\n** value; it is advisory only.\n**\n** [[the xPagecount() page cache methods]]\n** The xPagecount() method must return the number of pages currently\n** stored in the cache, both pinned and unpinned.\n** \n** [[the xFetch() page cache methods]]\n** The xFetch() method locates a page in the cache and returns a pointer to \n** an sqlite3_pcache_page object associated with that page, or a NULL pointer.\n** The pBuf element of the returned sqlite3_pcache_page object will be a\n** pointer to a buffer of szPage bytes used to store the content of a \n** single database page.  The pExtra element of sqlite3_pcache_page will be\n** a pointer to the szExtra bytes of extra storage that SQLite has requested\n** for each entry in the page cache.\n**\n** The page to be fetched is determined by the key. ^The minimum key value\n** is 1.  After it has been retrieved using xFetch, the page is considered\n** to be \"pinned\".\n**\n** If the requested page is already in the page cache, then the page cache\n** implementation must return a pointer to the page buffer with its content\n** intact.  If the requested page is not already in the cache, then the\n** cache implementation should use the value of the createFlag\n** parameter to help it determined what action to take:\n**\n** <table border=1 width=85% align=center>\n** <tr><th> createFlag <th> Behavior when page is not already in cache\n** <tr><td> 0 <td> Do not allocate a new page.  Return NULL.\n** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.\n**                 Otherwise return NULL.\n** <tr><td> 2 <td> Make every effort to allocate a new page.  Only return\n**                 NULL if allocating a new page is effectively impossible.\n** </table>\n**\n** ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1.  SQLite\n** will only use a createFlag of 2 after a prior call with a createFlag of 1\n** failed.)^  In between the to xFetch() calls, SQLite may\n** attempt to unpin one or more cache pages by spilling the content of\n** pinned pages to disk and synching the operating system disk cache.\n**\n** [[the xUnpin() page cache method]]\n** ^xUnpin() is called by SQLite with a pointer to a currently pinned page\n** as its second argument.  If the third parameter, discard, is non-zero,\n** then the page must be evicted from the cache.\n** ^If the discard parameter is\n** zero, then the page may be discarded or retained at the discretion of\n** page cache implementation. ^The page cache implementation\n** may choose to evict unpinned pages at any time.\n**\n** The cache must not perform any reference counting. A single \n** call to xUnpin() unpins the page regardless of the number of prior calls \n** to xFetch().\n**\n** [[the xRekey() page cache methods]]\n** The xRekey() method is used to change the key value associated with the\n** page passed as the second argument. If the cache\n** previously contains an entry associated with newKey, it must be\n** discarded. ^Any prior cache entry associated with newKey is guaranteed not\n** to be pinned.\n**\n** When SQLite calls the xTruncate() method, the cache must discard all\n** existing cache entries with page numbers (keys) greater than or equal\n** to the value of the iLimit parameter passed to xTruncate(). If any\n** of these pages are pinned, they are implicitly unpinned, meaning that\n** they can be safely discarded.\n**\n** [[the xDestroy() page cache method]]\n** ^The xDestroy() method is used to delete a cache allocated by xCreate().\n** All resources associated with the specified cache should be freed. ^After\n** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]\n** handle invalid, and will not use it with any other sqlite3_pcache_methods2\n** functions.\n**\n** [[the xShrink() page cache method]]\n** ^SQLite invokes the xShrink() method when it wants the page cache to\n** free up as much of heap memory as possible.  The page cache implementation\n** is not obligated to free any memory, but well-behaved implementations should\n** do their best.\n*/\ntypedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;\nstruct sqlite3_pcache_methods2 {\n  int iVersion;\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);\n  void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*, \n      unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n  void (*xShrink)(sqlite3_pcache*);\n};\n\n/*\n** This is the obsolete pcache_methods object that has now been replaced\n** by sqlite3_pcache_methods2.  This object is not used by SQLite.  It is\n** retained in the header file for backwards compatibility only.\n*/\ntypedef struct sqlite3_pcache_methods sqlite3_pcache_methods;\nstruct sqlite3_pcache_methods {\n  void *pArg;\n  int (*xInit)(void*);\n  void (*xShutdown)(void*);\n  sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable);\n  void (*xCachesize)(sqlite3_pcache*, int nCachesize);\n  int (*xPagecount)(sqlite3_pcache*);\n  void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);\n  void (*xUnpin)(sqlite3_pcache*, void*, int discard);\n  void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey);\n  void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);\n  void (*xDestroy)(sqlite3_pcache*);\n};\n\n\n/*\n** CAPI3REF: Online Backup Object\n**\n** The sqlite3_backup object records state information about an ongoing\n** online backup operation.  ^The sqlite3_backup object is created by\n** a call to [sqlite3_backup_init()] and is destroyed by a call to\n** [sqlite3_backup_finish()].\n**\n** See Also: [Using the SQLite Online Backup API]\n*/\ntypedef struct sqlite3_backup sqlite3_backup;\n\n/*\n** CAPI3REF: Online Backup API.\n**\n** The backup API copies the content of one database into another.\n** It is useful either for creating backups of databases or\n** for copying in-memory databases to or from persistent files. \n**\n** See Also: [Using the SQLite Online Backup API]\n**\n** ^SQLite holds a write transaction open on the destination database file\n** for the duration of the backup operation.\n** ^The source database is read-locked only while it is being read;\n** it is not locked continuously for the entire backup operation.\n** ^Thus, the backup may be performed on a live source database without\n** preventing other database connections from\n** reading or writing to the source database while the backup is underway.\n** \n** ^(To perform a backup operation: \n**   <ol>\n**     <li><b>sqlite3_backup_init()</b> is called once to initialize the\n**         backup, \n**     <li><b>sqlite3_backup_step()</b> is called one or more times to transfer \n**         the data between the two databases, and finally\n**     <li><b>sqlite3_backup_finish()</b> is called to release all resources \n**         associated with the backup operation. \n**   </ol>)^\n** There should be exactly one call to sqlite3_backup_finish() for each\n** successful call to sqlite3_backup_init().\n**\n** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>\n**\n** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the \n** [database connection] associated with the destination database \n** and the database name, respectively.\n** ^The database name is \"main\" for the main database, \"temp\" for the\n** temporary database, or the name specified after the AS keyword in\n** an [ATTACH] statement for an attached database.\n** ^The S and M arguments passed to \n** sqlite3_backup_init(D,N,S,M) identify the [database connection]\n** and database name of the source database, respectively.\n** ^The source and destination [database connections] (parameters S and D)\n** must be different or else sqlite3_backup_init(D,N,S,M) will fail with\n** an error.\n**\n** ^A call to sqlite3_backup_init() will fail, returning NULL, if \n** there is already a read or read-write transaction open on the \n** destination database.\n**\n** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is\n** returned and an error code and error message are stored in the\n** destination [database connection] D.\n** ^The error code and message for the failed call to sqlite3_backup_init()\n** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or\n** [sqlite3_errmsg16()] functions.\n** ^A successful call to sqlite3_backup_init() returns a pointer to an\n** [sqlite3_backup] object.\n** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and\n** sqlite3_backup_finish() functions to perform the specified backup \n** operation.\n**\n** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>\n**\n** ^Function sqlite3_backup_step(B,N) will copy up to N pages between \n** the source and destination databases specified by [sqlite3_backup] object B.\n** ^If N is negative, all remaining source pages are copied. \n** ^If sqlite3_backup_step(B,N) successfully copies N pages and there\n** are still more pages to be copied, then the function returns [SQLITE_OK].\n** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages\n** from source to destination, then it returns [SQLITE_DONE].\n** ^If an error occurs while running sqlite3_backup_step(B,N),\n** then an [error code] is returned. ^As well as [SQLITE_OK] and\n** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],\n** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.\n**\n** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if\n** <ol>\n** <li> the destination database was opened read-only, or\n** <li> the destination database is using write-ahead-log journaling\n** and the destination and source page sizes differ, or\n** <li> the destination database is an in-memory database and the\n** destination and source page sizes differ.\n** </ol>)^\n**\n** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then\n** the [sqlite3_busy_handler | busy-handler function]\n** is invoked (if one is specified). ^If the \n** busy-handler returns non-zero before the lock is available, then \n** [SQLITE_BUSY] is returned to the caller. ^In this case the call to\n** sqlite3_backup_step() can be retried later. ^If the source\n** [database connection]\n** is being used to write to the source database when sqlite3_backup_step()\n** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this\n** case the call to sqlite3_backup_step() can be retried later on. ^(If\n** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or\n** [SQLITE_READONLY] is returned, then \n** there is no point in retrying the call to sqlite3_backup_step(). These \n** errors are considered fatal.)^  The application must accept \n** that the backup operation has failed and pass the backup operation handle \n** to the sqlite3_backup_finish() to release associated resources.\n**\n** ^The first call to sqlite3_backup_step() obtains an exclusive lock\n** on the destination file. ^The exclusive lock is not released until either \n** sqlite3_backup_finish() is called or the backup operation is complete \n** and sqlite3_backup_step() returns [SQLITE_DONE].  ^Every call to\n** sqlite3_backup_step() obtains a [shared lock] on the source database that\n** lasts for the duration of the sqlite3_backup_step() call.\n** ^Because the source database is not locked between calls to\n** sqlite3_backup_step(), the source database may be modified mid-way\n** through the backup process.  ^If the source database is modified by an\n** external process or via a database connection other than the one being\n** used by the backup operation, then the backup will be automatically\n** restarted by the next call to sqlite3_backup_step(). ^If the source \n** database is modified by the using the same database connection as is used\n** by the backup operation, then the backup database is automatically\n** updated at the same time.\n**\n** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>\n**\n** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the \n** application wishes to abandon the backup operation, the application\n** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().\n** ^The sqlite3_backup_finish() interfaces releases all\n** resources associated with the [sqlite3_backup] object. \n** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any\n** active write-transaction on the destination database is rolled back.\n** The [sqlite3_backup] object is invalid\n** and may not be used following a call to sqlite3_backup_finish().\n**\n** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no\n** sqlite3_backup_step() errors occurred, regardless or whether or not\n** sqlite3_backup_step() completed.\n** ^If an out-of-memory condition or IO error occurred during any prior\n** sqlite3_backup_step() call on the same [sqlite3_backup] object, then\n** sqlite3_backup_finish() returns the corresponding [error code].\n**\n** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()\n** is not a permanent error and does not affect the return value of\n** sqlite3_backup_finish().\n**\n** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]\n** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>\n**\n** ^The sqlite3_backup_remaining() routine returns the number of pages still\n** to be backed up at the conclusion of the most recent sqlite3_backup_step().\n** ^The sqlite3_backup_pagecount() routine returns the total number of pages\n** in the source database at the conclusion of the most recent\n** sqlite3_backup_step().\n** ^(The values returned by these functions are only updated by\n** sqlite3_backup_step(). If the source database is modified in a way that\n** changes the size of the source database or the number of pages remaining,\n** those changes are not reflected in the output of sqlite3_backup_pagecount()\n** and sqlite3_backup_remaining() until after the next\n** sqlite3_backup_step().)^\n**\n** <b>Concurrent Usage of Database Handles</b>\n**\n** ^The source [database connection] may be used by the application for other\n** purposes while a backup operation is underway or being initialized.\n** ^If SQLite is compiled and configured to support threadsafe database\n** connections, then the source database connection may be used concurrently\n** from within other threads.\n**\n** However, the application must guarantee that the destination \n** [database connection] is not passed to any other API (by any thread) after \n** sqlite3_backup_init() is called and before the corresponding call to\n** sqlite3_backup_finish().  SQLite does not currently check to see\n** if the application incorrectly accesses the destination [database connection]\n** and so no error code is reported, but the operations may malfunction\n** nevertheless.  Use of the destination database connection while a\n** backup is in progress might also also cause a mutex deadlock.\n**\n** If running in [shared cache mode], the application must\n** guarantee that the shared cache used by the destination database\n** is not accessed while the backup is running. In practice this means\n** that the application must guarantee that the disk file being \n** backed up to is not accessed by any connection within the process,\n** not just the specific connection that was passed to sqlite3_backup_init().\n**\n** The [sqlite3_backup] object itself is partially threadsafe. Multiple \n** threads may safely make multiple concurrent calls to sqlite3_backup_step().\n** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()\n** APIs are not strictly speaking threadsafe. If they are invoked at the\n** same time as another thread is invoking sqlite3_backup_step() it is\n** possible that they return invalid values.\n*/\nsqlite3_backup *sqlite3_backup_init(\n  sqlite3 *pDest,                        /* Destination database handle */\n  const char *zDestName,                 /* Destination database name */\n  sqlite3 *pSource,                      /* Source database handle */\n  const char *zSourceName                /* Source database name */\n);\nint sqlite3_backup_step(sqlite3_backup *p, int nPage);\nint sqlite3_backup_finish(sqlite3_backup *p);\nint sqlite3_backup_remaining(sqlite3_backup *p);\nint sqlite3_backup_pagecount(sqlite3_backup *p);\n\n/*\n** CAPI3REF: Unlock Notification\n** METHOD: sqlite3\n**\n** ^When running in shared-cache mode, a database operation may fail with\n** an [SQLITE_LOCKED] error if the required locks on the shared-cache or\n** individual tables within the shared-cache cannot be obtained. See\n** [SQLite Shared-Cache Mode] for a description of shared-cache locking. \n** ^This API may be used to register a callback that SQLite will invoke \n** when the connection currently holding the required lock relinquishes it.\n** ^This API is only available if the library was compiled with the\n** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.\n**\n** See Also: [Using the SQLite Unlock Notification Feature].\n**\n** ^Shared-cache locks are released when a database connection concludes\n** its current transaction, either by committing it or rolling it back. \n**\n** ^When a connection (known as the blocked connection) fails to obtain a\n** shared-cache lock and SQLITE_LOCKED is returned to the caller, the\n** identity of the database connection (the blocking connection) that\n** has locked the required resource is stored internally. ^After an \n** application receives an SQLITE_LOCKED error, it may call the\n** sqlite3_unlock_notify() method with the blocked connection handle as \n** the first argument to register for a callback that will be invoked\n** when the blocking connections current transaction is concluded. ^The\n** callback is invoked from within the [sqlite3_step] or [sqlite3_close]\n** call that concludes the blocking connections transaction.\n**\n** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,\n** there is a chance that the blocking connection will have already\n** concluded its transaction by the time sqlite3_unlock_notify() is invoked.\n** If this happens, then the specified callback is invoked immediately,\n** from within the call to sqlite3_unlock_notify().)^\n**\n** ^If the blocked connection is attempting to obtain a write-lock on a\n** shared-cache table, and more than one other connection currently holds\n** a read-lock on the same table, then SQLite arbitrarily selects one of \n** the other connections to use as the blocking connection.\n**\n** ^(There may be at most one unlock-notify callback registered by a \n** blocked connection. If sqlite3_unlock_notify() is called when the\n** blocked connection already has a registered unlock-notify callback,\n** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is\n** called with a NULL pointer as its second argument, then any existing\n** unlock-notify callback is canceled. ^The blocked connections \n** unlock-notify callback may also be canceled by closing the blocked\n** connection using [sqlite3_close()].\n**\n** The unlock-notify callback is not reentrant. If an application invokes\n** any sqlite3_xxx API functions from within an unlock-notify callback, a\n** crash or deadlock may be the result.\n**\n** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always\n** returns SQLITE_OK.\n**\n** <b>Callback Invocation Details</b>\n**\n** When an unlock-notify callback is registered, the application provides a \n** single void* pointer that is passed to the callback when it is invoked.\n** However, the signature of the callback function allows SQLite to pass\n** it an array of void* context pointers. The first argument passed to\n** an unlock-notify callback is a pointer to an array of void* pointers,\n** and the second is the number of entries in the array.\n**\n** When a blocking connections transaction is concluded, there may be\n** more than one blocked connection that has registered for an unlock-notify\n** callback. ^If two or more such blocked connections have specified the\n** same callback function, then instead of invoking the callback function\n** multiple times, it is invoked once with the set of void* context pointers\n** specified by the blocked connections bundled together into an array.\n** This gives the application an opportunity to prioritize any actions \n** related to the set of unblocked database connections.\n**\n** <b>Deadlock Detection</b>\n**\n** Assuming that after registering for an unlock-notify callback a \n** database waits for the callback to be issued before taking any further\n** action (a reasonable assumption), then using this API may cause the\n** application to deadlock. For example, if connection X is waiting for\n** connection Y's transaction to be concluded, and similarly connection\n** Y is waiting on connection X's transaction, then neither connection\n** will proceed and the system may remain deadlocked indefinitely.\n**\n** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock\n** detection. ^If a given call to sqlite3_unlock_notify() would put the\n** system in a deadlocked state, then SQLITE_LOCKED is returned and no\n** unlock-notify callback is registered. The system is said to be in\n** a deadlocked state if connection A has registered for an unlock-notify\n** callback on the conclusion of connection B's transaction, and connection\n** B has itself registered for an unlock-notify callback when connection\n** A's transaction is concluded. ^Indirect deadlock is also detected, so\n** the system is also considered to be deadlocked if connection B has\n** registered for an unlock-notify callback on the conclusion of connection\n** C's transaction, where connection C is waiting on connection A. ^Any\n** number of levels of indirection are allowed.\n**\n** <b>The \"DROP TABLE\" Exception</b>\n**\n** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost \n** always appropriate to call sqlite3_unlock_notify(). There is however,\n** one exception. When executing a \"DROP TABLE\" or \"DROP INDEX\" statement,\n** SQLite checks if there are any currently executing SELECT statements\n** that belong to the same connection. If there are, SQLITE_LOCKED is\n** returned. In this case there is no \"blocking connection\", so invoking\n** sqlite3_unlock_notify() results in the unlock-notify callback being\n** invoked immediately. If the application then re-attempts the \"DROP TABLE\"\n** or \"DROP INDEX\" query, an infinite loop might be the result.\n**\n** One way around this problem is to check the extended error code returned\n** by an sqlite3_step() call. ^(If there is a blocking connection, then the\n** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in\n** the special \"DROP TABLE/INDEX\" case, the extended error code is just \n** SQLITE_LOCKED.)^\n*/\nint sqlite3_unlock_notify(\n  sqlite3 *pBlocked,                          /* Waiting connection */\n  void (*xNotify)(void **apArg, int nArg),    /* Callback function to invoke */\n  void *pNotifyArg                            /* Argument to pass to xNotify */\n);\n\n\n/*\n** CAPI3REF: String Comparison\n**\n** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications\n** and extensions to compare the contents of two buffers containing UTF-8\n** strings in a case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nint sqlite3_stricmp(const char *, const char *);\nint sqlite3_strnicmp(const char *, const char *, int);\n\n/*\n** CAPI3REF: String Globbing\n*\n** ^The [sqlite3_strglob(P,X)] interface returns zero if and only if\n** string X matches the [GLOB] pattern P.\n** ^The definition of [GLOB] pattern matching used in\n** [sqlite3_strglob(P,X)] is the same as for the \"X GLOB P\" operator in the\n** SQL dialect understood by SQLite.  ^The [sqlite3_strglob(P,X)] function\n** is case sensitive.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strlike()].\n*/\nint sqlite3_strglob(const char *zGlob, const char *zStr);\n\n/*\n** CAPI3REF: String LIKE Matching\n*\n** ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if\n** string X matches the [LIKE] pattern P with escape character E.\n** ^The definition of [LIKE] pattern matching used in\n** [sqlite3_strlike(P,X,E)] is the same as for the \"X LIKE P ESCAPE E\"\n** operator in the SQL dialect understood by SQLite.  ^For \"X LIKE P\" without\n** the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0.\n** ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case\n** insensitive - equivalent upper and lower case ASCII characters match\n** one another.\n**\n** ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though\n** only ASCII characters are case folded.\n**\n** Note that this routine returns zero on a match and non-zero if the strings\n** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].\n**\n** See also: [sqlite3_strglob()].\n*/\nint sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);\n\n/*\n** CAPI3REF: Error Logging Interface\n**\n** ^The [sqlite3_log()] interface writes a message into the [error log]\n** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].\n** ^If logging is enabled, the zFormat string and subsequent arguments are\n** used with [sqlite3_snprintf()] to generate the final output string.\n**\n** The sqlite3_log() interface is intended for use by extensions such as\n** virtual tables, collating functions, and SQL functions.  While there is\n** nothing to prevent an application from calling sqlite3_log(), doing so\n** is considered bad form.\n**\n** The zFormat string must not be NULL.\n**\n** To avoid deadlocks and other threading problems, the sqlite3_log() routine\n** will not use dynamically allocated memory.  The log message is stored in\n** a fixed-length buffer on the stack.  If the log message is longer than\n** a few hundred characters, it will be truncated to the length of the\n** buffer.\n*/\nvoid sqlite3_log(int iErrCode, const char *zFormat, ...);\n\n/*\n** CAPI3REF: Write-Ahead Log Commit Hook\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_hook()] function is used to register a callback that\n** is invoked each time data is committed to a database in wal mode.\n**\n** ^(The callback is invoked by SQLite after the commit has taken place and \n** the associated write-lock on the database released)^, so the implementation \n** may read, write or [checkpoint] the database as required.\n**\n** ^The first parameter passed to the callback function when it is invoked\n** is a copy of the third parameter passed to sqlite3_wal_hook() when\n** registering the callback. ^The second is a copy of the database handle.\n** ^The third parameter is the name of the database that was written to -\n** either \"main\" or the name of an [ATTACH]-ed database. ^The fourth parameter\n** is the number of pages currently in the write-ahead log file,\n** including those that were just committed.\n**\n** The callback function should normally return [SQLITE_OK].  ^If an error\n** code is returned, that error will propagate back up through the\n** SQLite code base to cause the statement that provoked the callback\n** to report an error, though the commit will have still occurred. If the\n** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value\n** that does not correspond to any valid SQLite error code, the results\n** are undefined.\n**\n** A single database handle may have at most a single write-ahead log callback \n** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any\n** previously registered write-ahead log callback. ^Note that the\n** [sqlite3_wal_autocheckpoint()] interface and the\n** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will\n** overwrite any prior [sqlite3_wal_hook()] settings.\n*/\nvoid *sqlite3_wal_hook(\n  sqlite3*, \n  int(*)(void *,sqlite3*,const char*,int),\n  void*\n);\n\n/*\n** CAPI3REF: Configure an auto-checkpoint\n** METHOD: sqlite3\n**\n** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around\n** [sqlite3_wal_hook()] that causes any database on [database connection] D\n** to automatically [checkpoint]\n** after committing a transaction if there are N or\n** more frames in the [write-ahead log] file.  ^Passing zero or \n** a negative value as the nFrame parameter disables automatic\n** checkpoints entirely.\n**\n** ^The callback registered by this function replaces any existing callback\n** registered using [sqlite3_wal_hook()].  ^Likewise, registering a callback\n** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism\n** configured by this function.\n**\n** ^The [wal_autocheckpoint pragma] can be used to invoke this interface\n** from SQL.\n**\n** ^Checkpoints initiated by this mechanism are\n** [sqlite3_wal_checkpoint_v2|PASSIVE].\n**\n** ^Every new [database connection] defaults to having the auto-checkpoint\n** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]\n** pages.  The use of this interface\n** is only necessary if the default setting is found to be suboptimal\n** for a particular application.\n*/\nint sqlite3_wal_autocheckpoint(sqlite3 *db, int N);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to\n** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^\n**\n** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the \n** [write-ahead log] for database X on [database connection] D to be\n** transferred into the database file and for the write-ahead log to\n** be reset.  See the [checkpointing] documentation for addition\n** information.\n**\n** This interface used to be the only way to cause a checkpoint to\n** occur.  But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]\n** interface was added.  This interface is retained for backwards\n** compatibility and as a convenience for applications that need to manually\n** start a callback but which do not need the full power (and corresponding\n** complication) of [sqlite3_wal_checkpoint_v2()].\n*/\nint sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);\n\n/*\n** CAPI3REF: Checkpoint a database\n** METHOD: sqlite3\n**\n** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint\n** operation on database X of [database connection] D in mode M.  Status\n** information is written back into integers pointed to by L and C.)^\n** ^(The M parameter must be a valid [checkpoint mode]:)^\n**\n** <dl>\n** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>\n**   ^Checkpoint as many frames as possible without waiting for any database \n**   readers or writers to finish, then sync the database file if all frames \n**   in the log were checkpointed. ^The [busy-handler callback]\n**   is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.  \n**   ^On the other hand, passive mode might leave the checkpoint unfinished\n**   if there are concurrent readers or writers.\n**\n** <dt>SQLITE_CHECKPOINT_FULL<dd>\n**   ^This mode blocks (it invokes the\n**   [sqlite3_busy_handler|busy-handler callback]) until there is no\n**   database writer and all readers are reading from the most recent database\n**   snapshot. ^It then checkpoints all frames in the log file and syncs the\n**   database file. ^This mode blocks new database writers while it is pending,\n**   but new database readers are allowed to continue unimpeded.\n**\n** <dt>SQLITE_CHECKPOINT_RESTART<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition\n**   that after checkpointing the log file it blocks (calls the \n**   [busy-handler callback])\n**   until all readers are reading from the database file only. ^This ensures \n**   that the next writer will restart the log file from the beginning.\n**   ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new\n**   database writer attempts while it is pending, but does not impede readers.\n**\n** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>\n**   ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the\n**   addition that it also truncates the log file to zero bytes just prior\n**   to a successful return.\n** </dl>\n**\n** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in\n** the log file or to -1 if the checkpoint could not run because\n** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not\n** NULL,then *pnCkpt is set to the total number of checkpointed frames in the\n** log file (including any that were already checkpointed before the function\n** was called) or to -1 if the checkpoint could not run due to an error or\n** because the database is not in WAL mode. ^Note that upon successful\n** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been\n** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n**\n** ^All calls obtain an exclusive \"checkpoint\" lock on the database file. ^If\n** any other process is running a checkpoint operation at the same time, the \n** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a \n** busy-handler configured, it will not be invoked in this case.\n**\n** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the \n** exclusive \"writer\" lock on the database file. ^If the writer lock cannot be\n** obtained immediately, and a busy-handler is configured, it is invoked and\n** the writer lock retried until either the busy-handler returns 0 or the lock\n** is successfully obtained. ^The busy-handler is also invoked while waiting for\n** database readers as described above. ^If the busy-handler returns 0 before\n** the writer lock is obtained or while waiting for database readers, the\n** checkpoint operation proceeds from that point in the same way as \n** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible \n** without blocking any further. ^SQLITE_BUSY is returned in this case.\n**\n** ^If parameter zDb is NULL or points to a zero length string, then the\n** specified operation is attempted on all WAL databases [attached] to \n** [database connection] db.  In this case the\n** values written to output parameters *pnLog and *pnCkpt are undefined. ^If \n** an SQLITE_BUSY error is encountered when processing one or more of the \n** attached WAL databases, the operation is still attempted on any remaining \n** attached databases and SQLITE_BUSY is returned at the end. ^If any other \n** error occurs while processing an attached database, processing is abandoned \n** and the error code is returned to the caller immediately. ^If no error \n** (SQLITE_BUSY or otherwise) is encountered while processing the attached \n** databases, SQLITE_OK is returned.\n**\n** ^If database zDb is the name of an attached database that is not in WAL\n** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If\n** zDb is not NULL (or a zero length string) and is not the name of any\n** attached database, SQLITE_ERROR is returned to the caller.\n**\n** ^Unless it returns SQLITE_MISUSE,\n** the sqlite3_wal_checkpoint_v2() interface\n** sets the error information that is queried by\n** [sqlite3_errcode()] and [sqlite3_errmsg()].\n**\n** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface\n** from SQL.\n*/\nint sqlite3_wal_checkpoint_v2(\n  sqlite3 *db,                    /* Database handle */\n  const char *zDb,                /* Name of attached database (or NULL) */\n  int eMode,                      /* SQLITE_CHECKPOINT_* value */\n  int *pnLog,                     /* OUT: Size of WAL log in frames */\n  int *pnCkpt                     /* OUT: Total number of frames checkpointed */\n);\n\n/*\n** CAPI3REF: Checkpoint Mode Values\n** KEYWORDS: {checkpoint mode}\n**\n** These constants define all valid values for the \"checkpoint mode\" passed\n** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.\n** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the\n** meaning of each of these checkpoint modes.\n*/\n#define SQLITE_CHECKPOINT_PASSIVE  0  /* Do as much as possible w/o blocking */\n#define SQLITE_CHECKPOINT_FULL     1  /* Wait for writers, then checkpoint */\n#define SQLITE_CHECKPOINT_RESTART  2  /* Like FULL but wait for for readers */\n#define SQLITE_CHECKPOINT_TRUNCATE 3  /* Like RESTART but also truncate WAL */\n\n/*\n** CAPI3REF: Virtual Table Interface Configuration\n**\n** This function may be called by either the [xConnect] or [xCreate] method\n** of a [virtual table] implementation to configure\n** various facets of the virtual table interface.\n**\n** If this interface is invoked outside the context of an xConnect or\n** xCreate virtual table method then the behavior is undefined.\n**\n** At present, there is only one option that may be configured using\n** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].)  Further options\n** may be added in the future.\n*/\nint sqlite3_vtab_config(sqlite3*, int op, ...);\n\n/*\n** CAPI3REF: Virtual Table Configuration Options\n**\n** These macros define the various options to the\n** [sqlite3_vtab_config()] interface that [virtual table] implementations\n** can use to customize and optimize their behavior.\n**\n** <dl>\n** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT\n** <dd>Calls of the form\n** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,\n** where X is an integer.  If X is zero, then the [virtual table] whose\n** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not\n** support constraints.  In this configuration (which is the default) if\n** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire\n** statement is rolled back as if [ON CONFLICT | OR ABORT] had been\n** specified as part of the users SQL statement, regardless of the actual\n** ON CONFLICT mode specified.\n**\n** If X is non-zero, then the virtual table implementation guarantees\n** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before\n** any modifications to internal or persistent data structures have been made.\n** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite \n** is able to roll back a statement or database transaction, and abandon\n** or continue processing the current SQL statement as appropriate. \n** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns\n** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode\n** had been ABORT.\n**\n** Virtual table implementations that are required to handle OR REPLACE\n** must do so within the [xUpdate] method. If a call to the \n** [sqlite3_vtab_on_conflict()] function indicates that the current ON \n** CONFLICT policy is REPLACE, the virtual table implementation should \n** silently replace the appropriate rows within the xUpdate callback and\n** return SQLITE_OK. Or, if this is not possible, it may return\n** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT \n** constraint handling.\n** </dl>\n*/\n#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1\n\n/*\n** CAPI3REF: Determine The Virtual Table Conflict Policy\n**\n** This function may only be called from within a call to the [xUpdate] method\n** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The\n** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],\n** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode\n** of the SQL statement that triggered the call to the [xUpdate] method of the\n** [virtual table].\n*/\nint sqlite3_vtab_on_conflict(sqlite3 *);\n\n/*\n** CAPI3REF: Conflict resolution modes\n** KEYWORDS: {conflict resolution mode}\n**\n** These constants are returned by [sqlite3_vtab_on_conflict()] to\n** inform a [virtual table] implementation what the [ON CONFLICT] mode\n** is for the SQL statement being evaluated.\n**\n** Note that the [SQLITE_IGNORE] constant is also used as a potential\n** return value from the [sqlite3_set_authorizer()] callback and that\n** [SQLITE_ABORT] is also a [result code].\n*/\n#define SQLITE_ROLLBACK 1\n/* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */\n#define SQLITE_FAIL     3\n/* #define SQLITE_ABORT 4  // Also an error code */\n#define SQLITE_REPLACE  5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status Opcodes\n** KEYWORDS: {scanstatus options}\n**\n** The following constants can be used for the T parameter to the\n** [sqlite3_stmt_scanstatus(S,X,T,V)] interface.  Each constant designates a\n** different metric for sqlite3_stmt_scanstatus() to return.\n**\n** When the value returned to V is a string, space to hold that string is\n** managed by the prepared statement S and will be automatically freed when\n** S is finalized.\n**\n** <dl>\n** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be\n** set to the total number of times that the X-th loop has run.</dd>\n**\n** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>\n** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set\n** to the total number of rows examined by all iterations of the X-th loop.</dd>\n**\n** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>\n** <dd>^The \"double\" variable pointed to by the T parameter will be set to the\n** query planner's estimate for the average number of rows output from each\n** iteration of the X-th loop.  If the query planner's estimates was accurate,\n** then this value will approximate the quotient NVISIT/NLOOP and the\n** product of this value for all prior loops with the same SELECTID will\n** be the NLOOP value for the current loop.\n**\n** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the name of the index or table\n** used for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>\n** <dd>^The \"const char *\" variable pointed to by the T parameter will be set\n** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]\n** description for the X-th loop.\n**\n** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>\n** <dd>^The \"int\" variable pointed to by the T parameter will be set to the\n** \"select-id\" for the X-th loop.  The select-id identifies which query or\n** subquery the loop is part of.  The main query has a select-id of zero.\n** The select-id is the same value as is output in the first column\n** of an [EXPLAIN QUERY PLAN] query.\n** </dl>\n*/\n#define SQLITE_SCANSTAT_NLOOP    0\n#define SQLITE_SCANSTAT_NVISIT   1\n#define SQLITE_SCANSTAT_EST      2\n#define SQLITE_SCANSTAT_NAME     3\n#define SQLITE_SCANSTAT_EXPLAIN  4\n#define SQLITE_SCANSTAT_SELECTID 5\n\n/*\n** CAPI3REF: Prepared Statement Scan Status\n** METHOD: sqlite3_stmt\n**\n** This interface returns information about the predicted and measured\n** performance for pStmt.  Advanced applications can use this\n** interface to compare the predicted and the measured performance and\n** issue warnings and/or rerun [ANALYZE] if discrepancies are found.\n**\n** Since this interface is expected to be rarely used, it is only\n** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]\n** compile-time option.\n**\n** The \"iScanStatusOp\" parameter determines which status information to return.\n** The \"iScanStatusOp\" must be one of the [scanstatus options] or the behavior\n** of this interface is undefined.\n** ^The requested measurement is written into a variable pointed to by\n** the \"pOut\" parameter.\n** Parameter \"idx\" identifies the specific loop to retrieve statistics for.\n** Loops are numbered starting from zero. ^If idx is out of range - less than\n** zero or greater than or equal to the total number of loops used to implement\n** the statement - a non-zero value is returned and the variable that pOut\n** points to is unchanged.\n**\n** ^Statistics might not be available for all loops in all statements. ^In cases\n** where there exist loops with no available statistics, this function behaves\n** as if the loop did not exist - it returns non-zero and leave the variable\n** that pOut points to unchanged.\n**\n** See also: [sqlite3_stmt_scanstatus_reset()]\n*/\nint sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,      /* Prepared statement for which info desired */\n  int idx,                  /* Index of loop to report on */\n  int iScanStatusOp,        /* Information desired.  SQLITE_SCANSTAT_* */\n  void *pOut                /* Result written here */\n);     \n\n/*\n** CAPI3REF: Zero Scan-Status Counters\n** METHOD: sqlite3_stmt\n**\n** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.\n**\n** This API is only available if the library is built with pre-processor\n** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.\n*/\nvoid sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);\n\n/*\n** CAPI3REF: Flush caches to disk mid-transaction\n**\n** ^If a write-transaction is open on [database connection] D when the\n** [sqlite3_db_cacheflush(D)] interface invoked, any dirty\n** pages in the pager-cache that are not currently in use are written out \n** to disk. A dirty page may be in use if a database cursor created by an\n** active SQL statement is reading from it, or if it is page 1 of a database\n** file (page 1 is always \"in use\").  ^The [sqlite3_db_cacheflush(D)]\n** interface flushes caches for all schemas - \"main\", \"temp\", and\n** any [attached] databases.\n**\n** ^If this function needs to obtain extra database locks before dirty pages \n** can be flushed to disk, it does so. ^If those locks cannot be obtained \n** immediately and there is a busy-handler callback configured, it is invoked\n** in the usual manner. ^If the required lock still cannot be obtained, then\n** the database is skipped and an attempt made to flush any dirty pages\n** belonging to the next (if any) database. ^If any databases are skipped\n** because locks cannot be obtained, but no other error occurs, this\n** function returns SQLITE_BUSY.\n**\n** ^If any other error occurs while flushing dirty pages to disk (for\n** example an IO error or out-of-memory condition), then processing is\n** abandoned and an SQLite [error code] is returned to the caller immediately.\n**\n** ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK.\n**\n** ^This function does not set the database handle error code or message\n** returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions.\n*/\nint sqlite3_db_cacheflush(sqlite3*);\n\n/*\n** CAPI3REF: The pre-update hook.\n**\n** ^These interfaces are only available if SQLite is compiled using the\n** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.\n**\n** ^The [sqlite3_preupdate_hook()] interface registers a callback function\n** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation\n** on a database table.\n** ^At most one preupdate hook may be registered at a time on a single\n** [database connection]; each call to [sqlite3_preupdate_hook()] overrides\n** the previous setting.\n** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]\n** with a NULL pointer as the second parameter.\n** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as\n** the first parameter to callbacks.\n**\n** ^The preupdate hook only fires for changes to real database tables; the\n** preupdate hook is not invoked for changes to [virtual tables] or to\n** system tables like sqlite_master or sqlite_stat1.\n**\n** ^The second parameter to the preupdate callback is a pointer to\n** the [database connection] that registered the preupdate hook.\n** ^The third parameter to the preupdate callback is one of the constants\n** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the\n** kind of update operation that is about to occur.\n** ^(The fourth parameter to the preupdate callback is the name of the\n** database within the database connection that is being modified.  This\n** will be \"main\" for the main database or \"temp\" for TEMP tables or \n** the name given after the AS keyword in the [ATTACH] statement for attached\n** databases.)^\n** ^The fifth parameter to the preupdate callback is the name of the\n** table that is being modified.\n**\n** For an UPDATE or DELETE operation on a [rowid table], the sixth\n** parameter passed to the preupdate callback is the initial [rowid] of the \n** row being modified or deleted. For an INSERT operation on a rowid table,\n** or any operation on a WITHOUT ROWID table, the value of the sixth \n** parameter is undefined. For an INSERT or UPDATE on a rowid table the\n** seventh parameter is the final rowid value of the row being inserted\n** or updated. The value of the seventh parameter passed to the callback\n** function is not defined for operations on WITHOUT ROWID tables, or for\n** INSERT operations on rowid tables.\n**\n** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],\n** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces\n** provide additional information about a preupdate event. These routines\n** may only be called from within a preupdate callback.  Invoking any of\n** these routines from outside of a preupdate callback or with a\n** [database connection] pointer that is different from the one supplied\n** to the preupdate callback results in undefined and probably undesirable\n** behavior.\n**\n** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns\n** in the row that is being inserted, updated, or deleted.\n**\n** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row before it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE\n** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to\n** a [protected sqlite3_value] that contains the value of the Nth column of\n** the table row after it is updated.  The N parameter must be between 0\n** and one less than the number of columns or the behavior will be\n** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE\n** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the\n** behavior is undefined.  The [sqlite3_value] that P points to\n** will be destroyed when the preupdate callback returns.\n**\n** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate\n** callback was invoked as a result of a direct insert, update, or delete\n** operation; or 1 for inserts, updates, or deletes invoked by top-level \n** triggers; or 2 for changes resulting from triggers called by top-level\n** triggers; and so forth.\n**\n** See also:  [sqlite3_update_hook()]\n*/\n#if defined(SQLITE_ENABLE_PREUPDATE_HOOK)\nvoid *sqlite3_preupdate_hook(\n  sqlite3 *db,\n  void(*xPreUpdate)(\n    void *pCtx,                   /* Copy of third arg to preupdate_hook() */\n    sqlite3 *db,                  /* Database handle */\n    int op,                       /* SQLITE_UPDATE, DELETE or INSERT */\n    char const *zDb,              /* Database name */\n    char const *zName,            /* Table name */\n    sqlite3_int64 iKey1,          /* Rowid of row about to be deleted/updated */\n    sqlite3_int64 iKey2           /* New rowid value (for a rowid UPDATE) */\n  ),\n  void*\n);\nint sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);\nint sqlite3_preupdate_count(sqlite3 *);\nint sqlite3_preupdate_depth(sqlite3 *);\nint sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);\n#endif\n\n/*\n** CAPI3REF: Low-level system error code\n**\n** ^Attempt to return the underlying operating system error code or error\n** number that caused the most recent I/O error or failure to open a file.\n** The return value is OS-dependent.  For example, on unix systems, after\n** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be\n** called to get back the underlying \"errno\" that caused the problem, such\n** as ENOSPC, EAUTH, EISDIR, and so forth.  \n*/\nint sqlite3_system_errno(sqlite3*);\n\n/*\n** CAPI3REF: Database Snapshot\n** KEYWORDS: {snapshot} {sqlite3_snapshot}\n** EXPERIMENTAL\n**\n** An instance of the snapshot object records the state of a [WAL mode]\n** database for some specific point in history.\n**\n** In [WAL mode], multiple [database connections] that are open on the\n** same database file can each be reading a different historical version\n** of the database file.  When a [database connection] begins a read\n** transaction, that connection sees an unchanging copy of the database\n** as it existed for the point in time when the transaction first started.\n** Subsequent changes to the database from other connections are not seen\n** by the reader until a new read transaction is started.\n**\n** The sqlite3_snapshot object records state information about an historical\n** version of the database file so that it is possible to later open a new read\n** transaction that sees that historical version of the database rather than\n** the most recent version.\n**\n** The constructor for this object is [sqlite3_snapshot_get()].  The\n** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer\n** to an historical snapshot (if possible).  The destructor for \n** sqlite3_snapshot objects is [sqlite3_snapshot_free()].\n*/\ntypedef struct sqlite3_snapshot {\n  unsigned char hidden[48];\n} sqlite3_snapshot;\n\n/*\n** CAPI3REF: Record A Database Snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a\n** new [sqlite3_snapshot] object that records the current state of\n** schema S in database connection D.  ^On success, the\n** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly\n** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.\n** If there is not already a read-transaction open on schema S when\n** this function is called, one is opened automatically. \n**\n** The following must be true for this function to succeed. If any of\n** the following statements are false when sqlite3_snapshot_get() is\n** called, SQLITE_ERROR is returned. The final value of *P is undefined\n** in this case. \n**\n** <ul>\n**   <li> The database handle must be in [autocommit mode].\n**\n**   <li> Schema S of [database connection] D must be a [WAL mode] database.\n**\n**   <li> There must not be a write transaction open on schema S of database\n**        connection D.\n**\n**   <li> One or more transactions must have been written to the current wal\n**        file since it was created on disk (by any connection). This means\n**        that a snapshot cannot be taken on a wal mode database with no wal \n**        file immediately after it is first opened. At least one transaction\n**        must be written to it first.\n** </ul>\n**\n** This function may also return SQLITE_NOMEM.  If it is called with the\n** database handle in autocommit mode but fails for some other reason, \n** whether or not a read transaction is opened on schema S is undefined.\n**\n** The [sqlite3_snapshot] object returned from a successful call to\n** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]\n** to avoid a memory leak.\n**\n** The [sqlite3_snapshot_get()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_EXPERIMENTAL int sqlite3_snapshot_get(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot **ppSnapshot\n);\n\n/*\n** CAPI3REF: Start a read transaction on an historical snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a\n** read transaction for schema S of\n** [database connection] D such that the read transaction\n** refers to historical [snapshot] P, rather than the most\n** recent change to the database.\n** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success\n** or an appropriate [error code] if it fails.\n**\n** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be\n** the first operation following the [BEGIN] that takes the schema S\n** out of [autocommit mode].\n** ^In other words, schema S must not currently be in\n** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the\n** database connection D must be out of [autocommit mode].\n** ^A [snapshot] will fail to open if it has been overwritten by a\n** [checkpoint].\n** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the\n** database connection D does not know that the database file for\n** schema S is in [WAL mode].  A database connection might not know\n** that the database file is in [WAL mode] if there has been no prior\n** I/O on that database connection, or if the database entered [WAL mode] \n** after the most recent I/O on the database connection.)^\n** (Hint: Run \"[PRAGMA application_id]\" against a newly opened\n** database connection in order to make it ready to use snapshots.)\n**\n** The [sqlite3_snapshot_open()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_EXPERIMENTAL int sqlite3_snapshot_open(\n  sqlite3 *db,\n  const char *zSchema,\n  sqlite3_snapshot *pSnapshot\n);\n\n/*\n** CAPI3REF: Destroy a snapshot\n** EXPERIMENTAL\n**\n** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.\n** The application must eventually free every [sqlite3_snapshot] object\n** using this routine to avoid a memory leak.\n**\n** The [sqlite3_snapshot_free()] interface is only available when the\n** SQLITE_ENABLE_SNAPSHOT compile-time option is used.\n*/\nSQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);\n\n/*\n** CAPI3REF: Compare the ages of two snapshot handles.\n** EXPERIMENTAL\n**\n** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages\n** of two valid snapshot handles. \n**\n** If the two snapshot handles are not associated with the same database \n** file, the result of the comparison is undefined. \n**\n** Additionally, the result of the comparison is only valid if both of the\n** snapshot handles were obtained by calling sqlite3_snapshot_get() since the\n** last time the wal file was deleted. The wal file is deleted when the\n** database is changed back to rollback mode or when the number of database\n** clients drops to zero. If either snapshot handle was obtained before the \n** wal file was last deleted, the value returned by this function \n** is undefined.\n**\n** Otherwise, this API returns a negative value if P1 refers to an older\n** snapshot than P2, zero if the two handles refer to the same database\n** snapshot, and a positive value if P1 is a newer snapshot than P2.\n*/\nSQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(\n  sqlite3_snapshot *p1,\n  sqlite3_snapshot *p2\n);\n\n/*\n** CAPI3REF: Recover snapshots from a wal file\n** EXPERIMENTAL\n**\n** If all connections disconnect from a database file but do not perform\n** a checkpoint, the existing wal file is opened along with the database\n** file the next time the database is opened. At this point it is only\n** possible to successfully call sqlite3_snapshot_open() to open the most\n** recent snapshot of the database (the one at the head of the wal file),\n** even though the wal file may contain other valid snapshots for which\n** clients have sqlite3_snapshot handles.\n**\n** This function attempts to scan the wal file associated with database zDb\n** of database handle db and make all valid snapshots available to\n** sqlite3_snapshot_open(). It is an error if there is already a read\n** transaction open on the database, or if the database is not a wal mode\n** database.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nSQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);\n\n/*\n** Undo the hack that converts floating point types to integer for\n** builds on processors without floating point support.\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# undef double\n#endif\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE3_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/sqlite3.rc",
    "content": "/*\n** 2012 September 2\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code and resources that are specific to Windows.\n*/\n\n#if !defined(_WIN32_WCE)\n#include \"winresrc.h\"\n#else\n#include \"windows.h\"\n#endif /* !defined(_WIN32_WCE) */\n\n#if !defined(VS_FF_NONE)\n#  define VS_FF_NONE            0x00000000L\n#endif /* !defined(VS_FF_NONE) */\n\n#include \"sqlite3.h\"\n#include \"sqlite3rc.h\"\n\n/*\n * English (U.S.) resources\n */\n\n#if defined(_WIN32)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#endif /* defined(_WIN32) */\n\n/*\n * Icon\n */\n\n#if !defined(RC_VERONLY)\n#define IDI_SQLITE 101\n\nIDI_SQLITE ICON \"..\\\\art\\\\sqlite370.ico\"\n#endif /* !defined(RC_VERONLY) */\n\n/*\n * Version\n */\n\nVS_VERSION_INFO VERSIONINFO\n  FILEVERSION SQLITE_RESOURCE_VERSION\n  PRODUCTVERSION SQLITE_RESOURCE_VERSION\n  FILEFLAGSMASK VS_FFI_FILEFLAGSMASK\n#if defined(_DEBUG)\n  FILEFLAGS VS_FF_DEBUG\n#else\n  FILEFLAGS VS_FF_NONE\n#endif /* defined(_DEBUG) */\n  FILEOS VOS__WINDOWS32\n  FILETYPE VFT_DLL\n  FILESUBTYPE VFT2_UNKNOWN\nBEGIN\n  BLOCK \"StringFileInfo\"\n  BEGIN\n    BLOCK \"040904b0\"\n    BEGIN\n      VALUE \"CompanyName\", \"SQLite Development Team\"\n      VALUE \"FileDescription\", \"SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.\"\n      VALUE \"FileVersion\", SQLITE_VERSION\n      VALUE \"InternalName\", \"sqlite3\"\n      VALUE \"LegalCopyright\", \"http://www.sqlite.org/copyright.html\"\n      VALUE \"ProductName\", \"SQLite\"\n      VALUE \"ProductVersion\", SQLITE_VERSION\n      VALUE \"SourceId\", SQLITE_SOURCE_ID\n    END\n  END\n  BLOCK \"VarFileInfo\"\n  BEGIN\n    VALUE \"Translation\", 0x409, 0x4b0\n  END\nEND\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/sqlite3ext.h",
    "content": "/*\n** 2006 June 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the SQLite interface for use by\n** shared libraries that want to be imported as extensions into\n** an SQLite instance.  Shared libraries that intend to be loaded\n** as extensions by SQLite should #include this file instead of \n** sqlite3.h.\n*/\n#ifndef SQLITE3EXT_H\n#define SQLITE3EXT_H\n#include \"sqlite3.h\"\n\n/*\n** The following structure holds pointers to all of the SQLite API\n** routines.\n**\n** WARNING:  In order to maintain backwards compatibility, add new\n** interfaces to the end of this structure only.  If you insert new\n** interfaces in the middle of this structure, then older different\n** versions of SQLite will not be able to load each other's shared\n** libraries!\n*/\nstruct sqlite3_api_routines {\n  void * (*aggregate_context)(sqlite3_context*,int nBytes);\n  int  (*aggregate_count)(sqlite3_context*);\n  int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));\n  int  (*bind_double)(sqlite3_stmt*,int,double);\n  int  (*bind_int)(sqlite3_stmt*,int,int);\n  int  (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);\n  int  (*bind_null)(sqlite3_stmt*,int);\n  int  (*bind_parameter_count)(sqlite3_stmt*);\n  int  (*bind_parameter_index)(sqlite3_stmt*,const char*zName);\n  const char * (*bind_parameter_name)(sqlite3_stmt*,int);\n  int  (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));\n  int  (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));\n  int  (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);\n  int  (*busy_handler)(sqlite3*,int(*)(void*,int),void*);\n  int  (*busy_timeout)(sqlite3*,int ms);\n  int  (*changes)(sqlite3*);\n  int  (*close)(sqlite3*);\n  int  (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                           int eTextRep,const char*));\n  int  (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,\n                             int eTextRep,const void*));\n  const void * (*column_blob)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes)(sqlite3_stmt*,int iCol);\n  int  (*column_bytes16)(sqlite3_stmt*,int iCol);\n  int  (*column_count)(sqlite3_stmt*pStmt);\n  const char * (*column_database_name)(sqlite3_stmt*,int);\n  const void * (*column_database_name16)(sqlite3_stmt*,int);\n  const char * (*column_decltype)(sqlite3_stmt*,int i);\n  const void * (*column_decltype16)(sqlite3_stmt*,int);\n  double  (*column_double)(sqlite3_stmt*,int iCol);\n  int  (*column_int)(sqlite3_stmt*,int iCol);\n  sqlite_int64  (*column_int64)(sqlite3_stmt*,int iCol);\n  const char * (*column_name)(sqlite3_stmt*,int);\n  const void * (*column_name16)(sqlite3_stmt*,int);\n  const char * (*column_origin_name)(sqlite3_stmt*,int);\n  const void * (*column_origin_name16)(sqlite3_stmt*,int);\n  const char * (*column_table_name)(sqlite3_stmt*,int);\n  const void * (*column_table_name16)(sqlite3_stmt*,int);\n  const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);\n  const void * (*column_text16)(sqlite3_stmt*,int iCol);\n  int  (*column_type)(sqlite3_stmt*,int iCol);\n  sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);\n  void * (*commit_hook)(sqlite3*,int(*)(void*),void*);\n  int  (*complete)(const char*sql);\n  int  (*complete16)(const void*sql);\n  int  (*create_collation)(sqlite3*,const char*,int,void*,\n                           int(*)(void*,int,const void*,int,const void*));\n  int  (*create_collation16)(sqlite3*,const void*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*));\n  int  (*create_function)(sqlite3*,const char*,int,int,void*,\n                          void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                          void (*xFinal)(sqlite3_context*));\n  int  (*create_function16)(sqlite3*,const void*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*));\n  int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);\n  int  (*data_count)(sqlite3_stmt*pStmt);\n  sqlite3 * (*db_handle)(sqlite3_stmt*);\n  int (*declare_vtab)(sqlite3*,const char*);\n  int  (*enable_shared_cache)(int);\n  int  (*errcode)(sqlite3*db);\n  const char * (*errmsg)(sqlite3*);\n  const void * (*errmsg16)(sqlite3*);\n  int  (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);\n  int  (*expired)(sqlite3_stmt*);\n  int  (*finalize)(sqlite3_stmt*pStmt);\n  void  (*free)(void*);\n  void  (*free_table)(char**result);\n  int  (*get_autocommit)(sqlite3*);\n  void * (*get_auxdata)(sqlite3_context*,int);\n  int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);\n  int  (*global_recover)(void);\n  void  (*interruptx)(sqlite3*);\n  sqlite_int64  (*last_insert_rowid)(sqlite3*);\n  const char * (*libversion)(void);\n  int  (*libversion_number)(void);\n  void *(*malloc)(int);\n  char * (*mprintf)(const char*,...);\n  int  (*open)(const char*,sqlite3**);\n  int  (*open16)(const void*,sqlite3**);\n  int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);\n  void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);\n  void *(*realloc)(void*,int);\n  int  (*reset)(sqlite3_stmt*pStmt);\n  void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_double)(sqlite3_context*,double);\n  void  (*result_error)(sqlite3_context*,const char*,int);\n  void  (*result_error16)(sqlite3_context*,const void*,int);\n  void  (*result_int)(sqlite3_context*,int);\n  void  (*result_int64)(sqlite3_context*,sqlite_int64);\n  void  (*result_null)(sqlite3_context*);\n  void  (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));\n  void  (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));\n  void  (*result_value)(sqlite3_context*,sqlite3_value*);\n  void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);\n  int  (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,\n                         const char*,const char*),void*);\n  void  (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));\n  char * (*xsnprintf)(int,char*,const char*,...);\n  int  (*step)(sqlite3_stmt*);\n  int  (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,\n                                char const**,char const**,int*,int*,int*);\n  void  (*thread_cleanup)(void);\n  int  (*total_changes)(sqlite3*);\n  void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);\n  int  (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);\n  void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,\n                                         sqlite_int64),void*);\n  void * (*user_data)(sqlite3_context*);\n  const void * (*value_blob)(sqlite3_value*);\n  int  (*value_bytes)(sqlite3_value*);\n  int  (*value_bytes16)(sqlite3_value*);\n  double  (*value_double)(sqlite3_value*);\n  int  (*value_int)(sqlite3_value*);\n  sqlite_int64  (*value_int64)(sqlite3_value*);\n  int  (*value_numeric_type)(sqlite3_value*);\n  const unsigned char * (*value_text)(sqlite3_value*);\n  const void * (*value_text16)(sqlite3_value*);\n  const void * (*value_text16be)(sqlite3_value*);\n  const void * (*value_text16le)(sqlite3_value*);\n  int  (*value_type)(sqlite3_value*);\n  char *(*vmprintf)(const char*,va_list);\n  /* Added ??? */\n  int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);\n  /* Added by 3.3.13 */\n  int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);\n  int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);\n  int (*clear_bindings)(sqlite3_stmt*);\n  /* Added by 3.4.1 */\n  int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,\n                          void (*xDestroy)(void *));\n  /* Added by 3.5.0 */\n  int (*bind_zeroblob)(sqlite3_stmt*,int,int);\n  int (*blob_bytes)(sqlite3_blob*);\n  int (*blob_close)(sqlite3_blob*);\n  int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,\n                   int,sqlite3_blob**);\n  int (*blob_read)(sqlite3_blob*,void*,int,int);\n  int (*blob_write)(sqlite3_blob*,const void*,int,int);\n  int (*create_collation_v2)(sqlite3*,const char*,int,void*,\n                             int(*)(void*,int,const void*,int,const void*),\n                             void(*)(void*));\n  int (*file_control)(sqlite3*,const char*,int,void*);\n  sqlite3_int64 (*memory_highwater)(int);\n  sqlite3_int64 (*memory_used)(void);\n  sqlite3_mutex *(*mutex_alloc)(int);\n  void (*mutex_enter)(sqlite3_mutex*);\n  void (*mutex_free)(sqlite3_mutex*);\n  void (*mutex_leave)(sqlite3_mutex*);\n  int (*mutex_try)(sqlite3_mutex*);\n  int (*open_v2)(const char*,sqlite3**,int,const char*);\n  int (*release_memory)(int);\n  void (*result_error_nomem)(sqlite3_context*);\n  void (*result_error_toobig)(sqlite3_context*);\n  int (*sleep)(int);\n  void (*soft_heap_limit)(int);\n  sqlite3_vfs *(*vfs_find)(const char*);\n  int (*vfs_register)(sqlite3_vfs*,int);\n  int (*vfs_unregister)(sqlite3_vfs*);\n  int (*xthreadsafe)(void);\n  void (*result_zeroblob)(sqlite3_context*,int);\n  void (*result_error_code)(sqlite3_context*,int);\n  int (*test_control)(int, ...);\n  void (*randomness)(int,void*);\n  sqlite3 *(*context_db_handle)(sqlite3_context*);\n  int (*extended_result_codes)(sqlite3*,int);\n  int (*limit)(sqlite3*,int,int);\n  sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);\n  const char *(*sql)(sqlite3_stmt*);\n  int (*status)(int,int*,int*,int);\n  int (*backup_finish)(sqlite3_backup*);\n  sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);\n  int (*backup_pagecount)(sqlite3_backup*);\n  int (*backup_remaining)(sqlite3_backup*);\n  int (*backup_step)(sqlite3_backup*,int);\n  const char *(*compileoption_get)(int);\n  int (*compileoption_used)(const char*);\n  int (*create_function_v2)(sqlite3*,const char*,int,int,void*,\n                            void (*xFunc)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xStep)(sqlite3_context*,int,sqlite3_value**),\n                            void (*xFinal)(sqlite3_context*),\n                            void(*xDestroy)(void*));\n  int (*db_config)(sqlite3*,int,...);\n  sqlite3_mutex *(*db_mutex)(sqlite3*);\n  int (*db_status)(sqlite3*,int,int*,int*,int);\n  int (*extended_errcode)(sqlite3*);\n  void (*log)(int,const char*,...);\n  sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);\n  const char *(*sourceid)(void);\n  int (*stmt_status)(sqlite3_stmt*,int,int);\n  int (*strnicmp)(const char*,const char*,int);\n  int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);\n  int (*wal_autocheckpoint)(sqlite3*,int);\n  int (*wal_checkpoint)(sqlite3*,const char*);\n  void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);\n  int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);\n  int (*vtab_config)(sqlite3*,int op,...);\n  int (*vtab_on_conflict)(sqlite3*);\n  /* Version 3.7.16 and later */\n  int (*close_v2)(sqlite3*);\n  const char *(*db_filename)(sqlite3*,const char*);\n  int (*db_readonly)(sqlite3*,const char*);\n  int (*db_release_memory)(sqlite3*);\n  const char *(*errstr)(int);\n  int (*stmt_busy)(sqlite3_stmt*);\n  int (*stmt_readonly)(sqlite3_stmt*);\n  int (*stricmp)(const char*,const char*);\n  int (*uri_boolean)(const char*,const char*,int);\n  sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);\n  const char *(*uri_parameter)(const char*,const char*);\n  char *(*xvsnprintf)(int,char*,const char*,va_list);\n  int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);\n  /* Version 3.8.7 and later */\n  int (*auto_extension)(void(*)(void));\n  int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,\n                     void(*)(void*));\n  int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,\n                      void(*)(void*),unsigned char);\n  int (*cancel_auto_extension)(void(*)(void));\n  int (*load_extension)(sqlite3*,const char*,const char*,char**);\n  void *(*malloc64)(sqlite3_uint64);\n  sqlite3_uint64 (*msize)(void*);\n  void *(*realloc64)(void*,sqlite3_uint64);\n  void (*reset_auto_extension)(void);\n  void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,\n                        void(*)(void*));\n  void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,\n                         void(*)(void*), unsigned char);\n  int (*strglob)(const char*,const char*);\n  /* Version 3.8.11 and later */\n  sqlite3_value *(*value_dup)(const sqlite3_value*);\n  void (*value_free)(sqlite3_value*);\n  int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64);\n  int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64);\n  /* Version 3.9.0 and later */\n  unsigned int (*value_subtype)(sqlite3_value*);\n  void (*result_subtype)(sqlite3_context*,unsigned int);\n  /* Version 3.10.0 and later */\n  int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int);\n  int (*strlike)(const char*,const char*,unsigned int);\n  int (*db_cacheflush)(sqlite3*);\n  /* Version 3.12.0 and later */\n  int (*system_errno)(sqlite3*);\n  /* Version 3.14.0 and later */\n  int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);\n  char *(*expanded_sql)(sqlite3_stmt*);\n  /* Version 3.18.0 and later */\n  void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);\n  /* Version 3.20.0 and later */\n  int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,\n                    sqlite3_stmt**,const char**);\n  int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,\n                      sqlite3_stmt**,const void**);\n  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*));\n  void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*));\n  void *(*value_pointer)(sqlite3_value*,const char*);\n};\n\n/*\n** This is the function signature used for all extension entry points.  It\n** is also defined in the file \"loadext.c\".\n*/\ntypedef int (*sqlite3_loadext_entry)(\n  sqlite3 *db,                       /* Handle to the database. */\n  char **pzErrMsg,                   /* Used to set error string on failure. */\n  const sqlite3_api_routines *pThunk /* Extension API function pointers. */\n);\n\n/*\n** The following macros redefine the API routines so that they are\n** redirected through the global sqlite3_api structure.\n**\n** This header file is also used by the loadext.c source file\n** (part of the main SQLite library - not an extension) so that\n** it can get access to the sqlite3_api_routines structure\n** definition.  But the main library does not want to redefine\n** the API.  So the redefinition macros are only valid if the\n** SQLITE_CORE macros is undefined.\n*/\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n#define sqlite3_aggregate_context      sqlite3_api->aggregate_context\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_aggregate_count        sqlite3_api->aggregate_count\n#endif\n#define sqlite3_bind_blob              sqlite3_api->bind_blob\n#define sqlite3_bind_double            sqlite3_api->bind_double\n#define sqlite3_bind_int               sqlite3_api->bind_int\n#define sqlite3_bind_int64             sqlite3_api->bind_int64\n#define sqlite3_bind_null              sqlite3_api->bind_null\n#define sqlite3_bind_parameter_count   sqlite3_api->bind_parameter_count\n#define sqlite3_bind_parameter_index   sqlite3_api->bind_parameter_index\n#define sqlite3_bind_parameter_name    sqlite3_api->bind_parameter_name\n#define sqlite3_bind_text              sqlite3_api->bind_text\n#define sqlite3_bind_text16            sqlite3_api->bind_text16\n#define sqlite3_bind_value             sqlite3_api->bind_value\n#define sqlite3_busy_handler           sqlite3_api->busy_handler\n#define sqlite3_busy_timeout           sqlite3_api->busy_timeout\n#define sqlite3_changes                sqlite3_api->changes\n#define sqlite3_close                  sqlite3_api->close\n#define sqlite3_collation_needed       sqlite3_api->collation_needed\n#define sqlite3_collation_needed16     sqlite3_api->collation_needed16\n#define sqlite3_column_blob            sqlite3_api->column_blob\n#define sqlite3_column_bytes           sqlite3_api->column_bytes\n#define sqlite3_column_bytes16         sqlite3_api->column_bytes16\n#define sqlite3_column_count           sqlite3_api->column_count\n#define sqlite3_column_database_name   sqlite3_api->column_database_name\n#define sqlite3_column_database_name16 sqlite3_api->column_database_name16\n#define sqlite3_column_decltype        sqlite3_api->column_decltype\n#define sqlite3_column_decltype16      sqlite3_api->column_decltype16\n#define sqlite3_column_double          sqlite3_api->column_double\n#define sqlite3_column_int             sqlite3_api->column_int\n#define sqlite3_column_int64           sqlite3_api->column_int64\n#define sqlite3_column_name            sqlite3_api->column_name\n#define sqlite3_column_name16          sqlite3_api->column_name16\n#define sqlite3_column_origin_name     sqlite3_api->column_origin_name\n#define sqlite3_column_origin_name16   sqlite3_api->column_origin_name16\n#define sqlite3_column_table_name      sqlite3_api->column_table_name\n#define sqlite3_column_table_name16    sqlite3_api->column_table_name16\n#define sqlite3_column_text            sqlite3_api->column_text\n#define sqlite3_column_text16          sqlite3_api->column_text16\n#define sqlite3_column_type            sqlite3_api->column_type\n#define sqlite3_column_value           sqlite3_api->column_value\n#define sqlite3_commit_hook            sqlite3_api->commit_hook\n#define sqlite3_complete               sqlite3_api->complete\n#define sqlite3_complete16             sqlite3_api->complete16\n#define sqlite3_create_collation       sqlite3_api->create_collation\n#define sqlite3_create_collation16     sqlite3_api->create_collation16\n#define sqlite3_create_function        sqlite3_api->create_function\n#define sqlite3_create_function16      sqlite3_api->create_function16\n#define sqlite3_create_module          sqlite3_api->create_module\n#define sqlite3_create_module_v2       sqlite3_api->create_module_v2\n#define sqlite3_data_count             sqlite3_api->data_count\n#define sqlite3_db_handle              sqlite3_api->db_handle\n#define sqlite3_declare_vtab           sqlite3_api->declare_vtab\n#define sqlite3_enable_shared_cache    sqlite3_api->enable_shared_cache\n#define sqlite3_errcode                sqlite3_api->errcode\n#define sqlite3_errmsg                 sqlite3_api->errmsg\n#define sqlite3_errmsg16               sqlite3_api->errmsg16\n#define sqlite3_exec                   sqlite3_api->exec\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_expired                sqlite3_api->expired\n#endif\n#define sqlite3_finalize               sqlite3_api->finalize\n#define sqlite3_free                   sqlite3_api->free\n#define sqlite3_free_table             sqlite3_api->free_table\n#define sqlite3_get_autocommit         sqlite3_api->get_autocommit\n#define sqlite3_get_auxdata            sqlite3_api->get_auxdata\n#define sqlite3_get_table              sqlite3_api->get_table\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_global_recover         sqlite3_api->global_recover\n#endif\n#define sqlite3_interrupt              sqlite3_api->interruptx\n#define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid\n#define sqlite3_libversion             sqlite3_api->libversion\n#define sqlite3_libversion_number      sqlite3_api->libversion_number\n#define sqlite3_malloc                 sqlite3_api->malloc\n#define sqlite3_mprintf                sqlite3_api->mprintf\n#define sqlite3_open                   sqlite3_api->open\n#define sqlite3_open16                 sqlite3_api->open16\n#define sqlite3_prepare                sqlite3_api->prepare\n#define sqlite3_prepare16              sqlite3_api->prepare16\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_profile                sqlite3_api->profile\n#define sqlite3_progress_handler       sqlite3_api->progress_handler\n#define sqlite3_realloc                sqlite3_api->realloc\n#define sqlite3_reset                  sqlite3_api->reset\n#define sqlite3_result_blob            sqlite3_api->result_blob\n#define sqlite3_result_double          sqlite3_api->result_double\n#define sqlite3_result_error           sqlite3_api->result_error\n#define sqlite3_result_error16         sqlite3_api->result_error16\n#define sqlite3_result_int             sqlite3_api->result_int\n#define sqlite3_result_int64           sqlite3_api->result_int64\n#define sqlite3_result_null            sqlite3_api->result_null\n#define sqlite3_result_text            sqlite3_api->result_text\n#define sqlite3_result_text16          sqlite3_api->result_text16\n#define sqlite3_result_text16be        sqlite3_api->result_text16be\n#define sqlite3_result_text16le        sqlite3_api->result_text16le\n#define sqlite3_result_value           sqlite3_api->result_value\n#define sqlite3_rollback_hook          sqlite3_api->rollback_hook\n#define sqlite3_set_authorizer         sqlite3_api->set_authorizer\n#define sqlite3_set_auxdata            sqlite3_api->set_auxdata\n#define sqlite3_snprintf               sqlite3_api->xsnprintf\n#define sqlite3_step                   sqlite3_api->step\n#define sqlite3_table_column_metadata  sqlite3_api->table_column_metadata\n#define sqlite3_thread_cleanup         sqlite3_api->thread_cleanup\n#define sqlite3_total_changes          sqlite3_api->total_changes\n#define sqlite3_trace                  sqlite3_api->trace\n#ifndef SQLITE_OMIT_DEPRECATED\n#define sqlite3_transfer_bindings      sqlite3_api->transfer_bindings\n#endif\n#define sqlite3_update_hook            sqlite3_api->update_hook\n#define sqlite3_user_data              sqlite3_api->user_data\n#define sqlite3_value_blob             sqlite3_api->value_blob\n#define sqlite3_value_bytes            sqlite3_api->value_bytes\n#define sqlite3_value_bytes16          sqlite3_api->value_bytes16\n#define sqlite3_value_double           sqlite3_api->value_double\n#define sqlite3_value_int              sqlite3_api->value_int\n#define sqlite3_value_int64            sqlite3_api->value_int64\n#define sqlite3_value_numeric_type     sqlite3_api->value_numeric_type\n#define sqlite3_value_text             sqlite3_api->value_text\n#define sqlite3_value_text16           sqlite3_api->value_text16\n#define sqlite3_value_text16be         sqlite3_api->value_text16be\n#define sqlite3_value_text16le         sqlite3_api->value_text16le\n#define sqlite3_value_type             sqlite3_api->value_type\n#define sqlite3_vmprintf               sqlite3_api->vmprintf\n#define sqlite3_vsnprintf              sqlite3_api->xvsnprintf\n#define sqlite3_overload_function      sqlite3_api->overload_function\n#define sqlite3_prepare_v2             sqlite3_api->prepare_v2\n#define sqlite3_prepare16_v2           sqlite3_api->prepare16_v2\n#define sqlite3_clear_bindings         sqlite3_api->clear_bindings\n#define sqlite3_bind_zeroblob          sqlite3_api->bind_zeroblob\n#define sqlite3_blob_bytes             sqlite3_api->blob_bytes\n#define sqlite3_blob_close             sqlite3_api->blob_close\n#define sqlite3_blob_open              sqlite3_api->blob_open\n#define sqlite3_blob_read              sqlite3_api->blob_read\n#define sqlite3_blob_write             sqlite3_api->blob_write\n#define sqlite3_create_collation_v2    sqlite3_api->create_collation_v2\n#define sqlite3_file_control           sqlite3_api->file_control\n#define sqlite3_memory_highwater       sqlite3_api->memory_highwater\n#define sqlite3_memory_used            sqlite3_api->memory_used\n#define sqlite3_mutex_alloc            sqlite3_api->mutex_alloc\n#define sqlite3_mutex_enter            sqlite3_api->mutex_enter\n#define sqlite3_mutex_free             sqlite3_api->mutex_free\n#define sqlite3_mutex_leave            sqlite3_api->mutex_leave\n#define sqlite3_mutex_try              sqlite3_api->mutex_try\n#define sqlite3_open_v2                sqlite3_api->open_v2\n#define sqlite3_release_memory         sqlite3_api->release_memory\n#define sqlite3_result_error_nomem     sqlite3_api->result_error_nomem\n#define sqlite3_result_error_toobig    sqlite3_api->result_error_toobig\n#define sqlite3_sleep                  sqlite3_api->sleep\n#define sqlite3_soft_heap_limit        sqlite3_api->soft_heap_limit\n#define sqlite3_vfs_find               sqlite3_api->vfs_find\n#define sqlite3_vfs_register           sqlite3_api->vfs_register\n#define sqlite3_vfs_unregister         sqlite3_api->vfs_unregister\n#define sqlite3_threadsafe             sqlite3_api->xthreadsafe\n#define sqlite3_result_zeroblob        sqlite3_api->result_zeroblob\n#define sqlite3_result_error_code      sqlite3_api->result_error_code\n#define sqlite3_test_control           sqlite3_api->test_control\n#define sqlite3_randomness             sqlite3_api->randomness\n#define sqlite3_context_db_handle      sqlite3_api->context_db_handle\n#define sqlite3_extended_result_codes  sqlite3_api->extended_result_codes\n#define sqlite3_limit                  sqlite3_api->limit\n#define sqlite3_next_stmt              sqlite3_api->next_stmt\n#define sqlite3_sql                    sqlite3_api->sql\n#define sqlite3_status                 sqlite3_api->status\n#define sqlite3_backup_finish          sqlite3_api->backup_finish\n#define sqlite3_backup_init            sqlite3_api->backup_init\n#define sqlite3_backup_pagecount       sqlite3_api->backup_pagecount\n#define sqlite3_backup_remaining       sqlite3_api->backup_remaining\n#define sqlite3_backup_step            sqlite3_api->backup_step\n#define sqlite3_compileoption_get      sqlite3_api->compileoption_get\n#define sqlite3_compileoption_used     sqlite3_api->compileoption_used\n#define sqlite3_create_function_v2     sqlite3_api->create_function_v2\n#define sqlite3_db_config              sqlite3_api->db_config\n#define sqlite3_db_mutex               sqlite3_api->db_mutex\n#define sqlite3_db_status              sqlite3_api->db_status\n#define sqlite3_extended_errcode       sqlite3_api->extended_errcode\n#define sqlite3_log                    sqlite3_api->log\n#define sqlite3_soft_heap_limit64      sqlite3_api->soft_heap_limit64\n#define sqlite3_sourceid               sqlite3_api->sourceid\n#define sqlite3_stmt_status            sqlite3_api->stmt_status\n#define sqlite3_strnicmp               sqlite3_api->strnicmp\n#define sqlite3_unlock_notify          sqlite3_api->unlock_notify\n#define sqlite3_wal_autocheckpoint     sqlite3_api->wal_autocheckpoint\n#define sqlite3_wal_checkpoint         sqlite3_api->wal_checkpoint\n#define sqlite3_wal_hook               sqlite3_api->wal_hook\n#define sqlite3_blob_reopen            sqlite3_api->blob_reopen\n#define sqlite3_vtab_config            sqlite3_api->vtab_config\n#define sqlite3_vtab_on_conflict       sqlite3_api->vtab_on_conflict\n/* Version 3.7.16 and later */\n#define sqlite3_close_v2               sqlite3_api->close_v2\n#define sqlite3_db_filename            sqlite3_api->db_filename\n#define sqlite3_db_readonly            sqlite3_api->db_readonly\n#define sqlite3_db_release_memory      sqlite3_api->db_release_memory\n#define sqlite3_errstr                 sqlite3_api->errstr\n#define sqlite3_stmt_busy              sqlite3_api->stmt_busy\n#define sqlite3_stmt_readonly          sqlite3_api->stmt_readonly\n#define sqlite3_stricmp                sqlite3_api->stricmp\n#define sqlite3_uri_boolean            sqlite3_api->uri_boolean\n#define sqlite3_uri_int64              sqlite3_api->uri_int64\n#define sqlite3_uri_parameter          sqlite3_api->uri_parameter\n#define sqlite3_uri_vsnprintf          sqlite3_api->xvsnprintf\n#define sqlite3_wal_checkpoint_v2      sqlite3_api->wal_checkpoint_v2\n/* Version 3.8.7 and later */\n#define sqlite3_auto_extension         sqlite3_api->auto_extension\n#define sqlite3_bind_blob64            sqlite3_api->bind_blob64\n#define sqlite3_bind_text64            sqlite3_api->bind_text64\n#define sqlite3_cancel_auto_extension  sqlite3_api->cancel_auto_extension\n#define sqlite3_load_extension         sqlite3_api->load_extension\n#define sqlite3_malloc64               sqlite3_api->malloc64\n#define sqlite3_msize                  sqlite3_api->msize\n#define sqlite3_realloc64              sqlite3_api->realloc64\n#define sqlite3_reset_auto_extension   sqlite3_api->reset_auto_extension\n#define sqlite3_result_blob64          sqlite3_api->result_blob64\n#define sqlite3_result_text64          sqlite3_api->result_text64\n#define sqlite3_strglob                sqlite3_api->strglob\n/* Version 3.8.11 and later */\n#define sqlite3_value_dup              sqlite3_api->value_dup\n#define sqlite3_value_free             sqlite3_api->value_free\n#define sqlite3_result_zeroblob64      sqlite3_api->result_zeroblob64\n#define sqlite3_bind_zeroblob64        sqlite3_api->bind_zeroblob64\n/* Version 3.9.0 and later */\n#define sqlite3_value_subtype          sqlite3_api->value_subtype\n#define sqlite3_result_subtype         sqlite3_api->result_subtype\n/* Version 3.10.0 and later */\n#define sqlite3_status64               sqlite3_api->status64\n#define sqlite3_strlike                sqlite3_api->strlike\n#define sqlite3_db_cacheflush          sqlite3_api->db_cacheflush\n/* Version 3.12.0 and later */\n#define sqlite3_system_errno           sqlite3_api->system_errno\n/* Version 3.14.0 and later */\n#define sqlite3_trace_v2               sqlite3_api->trace_v2\n#define sqlite3_expanded_sql           sqlite3_api->expanded_sql\n/* Version 3.18.0 and later */\n#define sqlite3_set_last_insert_rowid  sqlite3_api->set_last_insert_rowid\n/* Version 3.20.0 and later */\n#define sqlite3_prepare_v3             sqlite3_api->prepare_v3\n#define sqlite3_prepare16_v3           sqlite3_api->prepare16_v3\n#define sqlite3_bind_pointer           sqlite3_api->bind_pointer\n#define sqlite3_result_pointer         sqlite3_api->result_pointer\n#define sqlite3_value_pointer          sqlite3_api->value_pointer\n#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */\n\n#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)\n  /* This case when the file really is being compiled as a loadable \n  ** extension */\n# define SQLITE_EXTENSION_INIT1     const sqlite3_api_routines *sqlite3_api=0;\n# define SQLITE_EXTENSION_INIT2(v)  sqlite3_api=v;\n# define SQLITE_EXTENSION_INIT3     \\\n    extern const sqlite3_api_routines *sqlite3_api;\n#else\n  /* This case when the file is being statically linked into the \n  ** application */\n# define SQLITE_EXTENSION_INIT1     /*no-op*/\n# define SQLITE_EXTENSION_INIT2(v)  (void)v; /* unused parameter */\n# define SQLITE_EXTENSION_INIT3     /*no-op*/\n#endif\n\n#endif /* SQLITE3EXT_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/sqliteInt.h",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Internal interface definitions for SQLite.\n**\n*/\n#ifndef SQLITEINT_H\n#define SQLITEINT_H\n\n/* Special Comments:\n**\n** Some comments have special meaning to the tools that measure test\n** coverage:\n**\n**    NO_TEST                     - The branches on this line are not\n**                                  measured by branch coverage.  This is\n**                                  used on lines of code that actually\n**                                  implement parts of coverage testing.\n**\n**    OPTIMIZATION-IF-TRUE        - This branch is allowed to alway be false\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    OPTIMIZATION-IF-FALSE       - This branch is allowed to alway be true\n**                                  and the correct answer is still obtained,\n**                                  though perhaps more slowly.\n**\n**    PREVENTS-HARMLESS-OVERREAD  - This branch prevents a buffer overread\n**                                  that would be harmless and undetectable\n**                                  if it did occur.  \n**\n** In all cases, the special comment must be enclosed in the usual\n** slash-asterisk...asterisk-slash comment marks, with no spaces between the \n** asterisks and the comment text.\n*/\n\n/*\n** Make sure the Tcl calling convention macro is defined.  This macro is\n** only used by test code and Tcl integration code.\n*/\n#ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n#endif\n\n/*\n** Include the header file used to customize the compiler options for MSVC.\n** This should be done first so that it can successfully prevent spurious\n** compiler warnings due to subsequent content in this file and other files\n** that are included by this file.\n*/\n#include \"msvc.h\"\n\n/*\n** Special setup for VxWorks\n*/\n#include \"vxworks.h\"\n\n/*\n** These #defines should enable >2GB file support on POSIX if the\n** underlying operating system supports it.  If the OS lacks\n** large file support, or if the OS is windows, these should be no-ops.\n**\n** Ticket #2739:  The _LARGEFILE_SOURCE macro must appear before any\n** system #includes.  Hence, this block of code must be the very first\n** code in all source files.\n**\n** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch\n** on the compiler command line.  This is necessary if you are compiling\n** on a recent machine (ex: Red Hat 7.2) but you want your code to work\n** on an older machine (ex: Red Hat 6.0).  If you compile on Red Hat 7.2\n** without this option, LFS is enable.  But LFS does not exist in the kernel\n** in Red Hat 6.0, so the code won't work.  Hence, for maximum binary\n** portability you should omit LFS.\n**\n** The previous paragraph was written in 2005.  (This paragraph is written\n** on 2008-11-28.) These days, all Linux kernels support large files, so\n** you should probably leave LFS enabled.  But some embedded platforms might\n** lack LFS in which case the SQLITE_DISABLE_LFS macro might still be useful.\n**\n** Similar is true for Mac OS X.  LFS is only supported on Mac OS X 9 and later.\n*/\n#ifndef SQLITE_DISABLE_LFS\n# define _LARGE_FILE       1\n# ifndef _FILE_OFFSET_BITS\n#   define _FILE_OFFSET_BITS 64\n# endif\n# define _LARGEFILE_SOURCE 1\n#endif\n\n/* The GCC_VERSION and MSVC_VERSION macros are used to\n** conditionally include optimizations for each of these compilers.  A\n** value of 0 means that compiler is not being used.  The\n** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific\n** optimizations, and hence set all compiler macros to 0\n**\n** There was once also a CLANG_VERSION macro.  However, we learn that the\n** version numbers in clang are for \"marketing\" only and are inconsistent\n** and unreliable.  Fortunately, all versions of clang also recognize the\n** gcc version numbers and have reasonable settings for gcc version numbers,\n** so the GCC_VERSION macro will be set to a correct non-zero value even\n** when compiling with clang.\n*/\n#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__)\n#else\n# define GCC_VERSION 0\n#endif\n#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC)\n# define MSVC_VERSION _MSC_VER\n#else\n# define MSVC_VERSION 0\n#endif\n\n/* Needed for various definitions... */\n#if defined(__GNUC__) && !defined(_GNU_SOURCE)\n# define _GNU_SOURCE\n#endif\n\n#if defined(__OpenBSD__) && !defined(_BSD_SOURCE)\n# define _BSD_SOURCE\n#endif\n\n/*\n** For MinGW, check to see if we can include the header file containing its\n** version information, among other things.  Normally, this internal MinGW\n** header file would [only] be included automatically by other MinGW header\n** files; however, the contained version information is now required by this\n** header file to work around binary compatibility issues (see below) and\n** this is the only known way to reliably obtain it.  This entire #if block\n** would be completely unnecessary if there was any other way of detecting\n** MinGW via their preprocessor (e.g. if they customized their GCC to define\n** some MinGW-specific macros).  When compiling for MinGW, either the\n** _HAVE_MINGW_H or _HAVE__MINGW_H (note the extra underscore) macro must be\n** defined; otherwise, detection of conditions specific to MinGW will be\n** disabled.\n*/\n#if defined(_HAVE_MINGW_H)\n# include \"mingw.h\"\n#elif defined(_HAVE__MINGW_H)\n# include \"_mingw.h\"\n#endif\n\n/*\n** For MinGW version 4.x (and higher), check to see if the _USE_32BIT_TIME_T\n** define is required to maintain binary compatibility with the MSVC runtime\n** library in use (e.g. for Windows XP).\n*/\n#if !defined(_USE_32BIT_TIME_T) && !defined(_USE_64BIT_TIME_T) && \\\n    defined(_WIN32) && !defined(_WIN64) && \\\n    defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \\\n    defined(__MSVCRT__)\n# define _USE_32BIT_TIME_T\n#endif\n\n/* The public SQLite interface.  The _FILE_OFFSET_BITS macro must appear\n** first in QNX.  Also, the _USE_32BIT_TIME_T macro must appear first for\n** MinGW.\n*/\n#include \"sqlite3.h\"\n\n/*\n** Include the configuration header output by 'configure' if we're using the\n** autoconf-based build\n*/\n#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)\n#include \"config.h\"\n#define SQLITECONFIG_H 1\n#endif\n\n#include \"sqliteLimit.h\"\n\n/* Disable nuisance warnings on Borland compilers */\n#if defined(__BORLANDC__)\n#pragma warn -rch /* unreachable code */\n#pragma warn -ccc /* Condition is always true or false */\n#pragma warn -aus /* Assigned value is never used */\n#pragma warn -csu /* Comparing signed and unsigned */\n#pragma warn -spa /* Suspicious pointer arithmetic */\n#endif\n\n/*\n** Include standard header files as necessary\n*/\n#ifdef HAVE_STDINT_H\n#include <stdint.h>\n#endif\n#ifdef HAVE_INTTYPES_H\n#include <inttypes.h>\n#endif\n\n/*\n** The following macros are used to cast pointers to integers and\n** integers to pointers.  The way you do this varies from one compiler\n** to the next, so we have developed the following set of #if statements\n** to generate appropriate macros for a wide range of compilers.\n**\n** The correct \"ANSI\" way to do this is to use the intptr_t type.\n** Unfortunately, that typedef is not available on all compilers, or\n** if it is available, it requires an #include of specific headers\n** that vary from one machine to the next.\n**\n** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on\n** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).\n** So we have to define the macros in different ways depending on the\n** compiler.\n*/\n#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(__PTRDIFF_TYPE__)(X))\n#elif !defined(__GNUC__)       /* Works for compilers other than LLVM */\n# define SQLITE_INT_TO_PTR(X)  ((void*)&((char*)0)[X])\n# define SQLITE_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))\n#elif defined(HAVE_STDINT_H)   /* Use this case if we have ANSI headers */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(intptr_t)(X))\n#else                          /* Generates a warning - but it always works */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(X))\n# define SQLITE_PTR_TO_INT(X)  ((int)(X))\n#endif\n\n/*\n** A macro to hint to the compiler that a function should not be\n** inlined.\n*/\n#if defined(__GNUC__)\n#  define SQLITE_NOINLINE  __attribute__((noinline))\n#elif defined(_MSC_VER) && _MSC_VER>=1310\n#  define SQLITE_NOINLINE  __declspec(noinline)\n#else\n#  define SQLITE_NOINLINE\n#endif\n\n/*\n** Make sure that the compiler intrinsics we desire are enabled when\n** compiling with an appropriate version of MSVC unless prevented by\n** the SQLITE_DISABLE_INTRINSIC define.\n*/\n#if !defined(SQLITE_DISABLE_INTRINSIC)\n#  if defined(_MSC_VER) && _MSC_VER>=1400\n#    if !defined(_WIN32_WCE)\n#      include <intrin.h>\n#      pragma intrinsic(_byteswap_ushort)\n#      pragma intrinsic(_byteswap_ulong)\n#      pragma intrinsic(_byteswap_uint64)\n#      pragma intrinsic(_ReadWriteBarrier)\n#    else\n#      include <cmnintrin.h>\n#    endif\n#  endif\n#endif\n\n/*\n** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.\n** 0 means mutexes are permanently disable and the library is never\n** threadsafe.  1 means the library is serialized which is the highest\n** level of threadsafety.  2 means the library is multithreaded - multiple\n** threads can use SQLite as long as no two threads try to use the same\n** database connection at the same time.\n**\n** Older versions of SQLite used an optional THREADSAFE macro.\n** We support that for legacy.\n**\n** To ensure that the correct value of \"THREADSAFE\" is reported when querying\n** for compile-time options at runtime (e.g. \"PRAGMA compile_options\"), this\n** logic is partially replicated in ctime.c. If it is updated here, it should\n** also be updated there.\n*/\n#if !defined(SQLITE_THREADSAFE)\n# if defined(THREADSAFE)\n#   define SQLITE_THREADSAFE THREADSAFE\n# else\n#   define SQLITE_THREADSAFE 1 /* IMP: R-07272-22309 */\n# endif\n#endif\n\n/*\n** Powersafe overwrite is on by default.  But can be turned off using\n** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.\n*/\n#ifndef SQLITE_POWERSAFE_OVERWRITE\n# define SQLITE_POWERSAFE_OVERWRITE 1\n#endif\n\n/*\n** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by\n** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in\n** which case memory allocation statistics are disabled by default.\n*/\n#if !defined(SQLITE_DEFAULT_MEMSTATUS)\n# define SQLITE_DEFAULT_MEMSTATUS 1\n#endif\n\n/*\n** Exactly one of the following macros must be defined in order to\n** specify which memory allocation subsystem to use.\n**\n**     SQLITE_SYSTEM_MALLOC          // Use normal system malloc()\n**     SQLITE_WIN32_MALLOC           // Use Win32 native heap API\n**     SQLITE_ZERO_MALLOC            // Use a stub allocator that always fails\n**     SQLITE_MEMDEBUG               // Debugging version of system malloc()\n**\n** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the\n** assert() macro is enabled, each call into the Win32 native heap subsystem\n** will cause HeapValidate to be called.  If heap validation should fail, an\n** assertion will be triggered.\n**\n** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as\n** the default.\n*/\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)>1\n# error \"Two or more of the following compile-time configuration options\\\n are defined but at most one is allowed:\\\n SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\\\n SQLITE_ZERO_MALLOC\"\n#endif\n#if defined(SQLITE_SYSTEM_MALLOC) \\\n  + defined(SQLITE_WIN32_MALLOC) \\\n  + defined(SQLITE_ZERO_MALLOC) \\\n  + defined(SQLITE_MEMDEBUG)==0\n# define SQLITE_SYSTEM_MALLOC 1\n#endif\n\n/*\n** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the\n** sizes of memory allocations below this value where possible.\n*/\n#if !defined(SQLITE_MALLOC_SOFT_LIMIT)\n# define SQLITE_MALLOC_SOFT_LIMIT 1024\n#endif\n\n/*\n** We need to define _XOPEN_SOURCE as follows in order to enable\n** recursive mutexes on most Unix systems and fchmod() on OpenBSD.\n** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit\n** it.\n*/\n#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)\n#  define _XOPEN_SOURCE 600\n#endif\n\n/*\n** NDEBUG and SQLITE_DEBUG are opposites.  It should always be true that\n** defined(NDEBUG)==!defined(SQLITE_DEBUG).  If this is not currently true,\n** make it true by defining or undefining NDEBUG.\n**\n** Setting NDEBUG makes the code smaller and faster by disabling the\n** assert() statements in the code.  So we want the default action\n** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG\n** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out\n** feature.\n*/\n#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)\n# define NDEBUG 1\n#endif\n#if defined(NDEBUG) && defined(SQLITE_DEBUG)\n# undef NDEBUG\n#endif\n\n/*\n** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.\n*/\n#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)\n# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1\n#endif\n\n/*\n** The testcase() macro is used to aid in coverage testing.  When\n** doing coverage testing, the condition inside the argument to\n** testcase() must be evaluated both true and false in order to\n** get full branch coverage.  The testcase() macro is inserted\n** to help ensure adequate test coverage in places where simple\n** condition/decision coverage is inadequate.  For example, testcase()\n** can be used to make sure boundary values are tested.  For\n** bitmask tests, testcase() can be used to make sure each bit\n** is significant and used at least once.  On switch statements\n** where multiple cases go to the same block of code, testcase()\n** can insure that all cases are evaluated.\n**\n*/\n#ifdef SQLITE_COVERAGE_TEST\n  void sqlite3Coverage(int);\n# define testcase(X)  if( X ){ sqlite3Coverage(__LINE__); }\n#else\n# define testcase(X)\n#endif\n\n/*\n** The TESTONLY macro is used to enclose variable declarations or\n** other bits of code that are needed to support the arguments\n** within testcase() and assert() macros.\n*/\n#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST)\n# define TESTONLY(X)  X\n#else\n# define TESTONLY(X)\n#endif\n\n/*\n** Sometimes we need a small amount of code such as a variable initialization\n** to setup for a later assert() statement.  We do not want this code to\n** appear when assert() is disabled.  The following macro is therefore\n** used to contain that setup code.  The \"VVA\" acronym stands for\n** \"Verification, Validation, and Accreditation\".  In other words, the\n** code within VVA_ONLY() will only run during verification processes.\n*/\n#ifndef NDEBUG\n# define VVA_ONLY(X)  X\n#else\n# define VVA_ONLY(X)\n#endif\n\n/*\n** The ALWAYS and NEVER macros surround boolean expressions which\n** are intended to always be true or false, respectively.  Such\n** expressions could be omitted from the code completely.  But they\n** are included in a few cases in order to enhance the resilience\n** of SQLite to unexpected behavior - to make the code \"self-healing\"\n** or \"ductile\" rather than being \"brittle\" and crashing at the first\n** hint of unplanned behavior.\n**\n** In other words, ALWAYS and NEVER are added for defensive code.\n**\n** When doing coverage testing ALWAYS and NEVER are hard-coded to\n** be true and false so that the unreachable code they specify will\n** not be counted as untested code.\n*/\n#if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)\n# define ALWAYS(X)      (1)\n# define NEVER(X)       (0)\n#elif !defined(NDEBUG)\n# define ALWAYS(X)      ((X)?1:(assert(0),0))\n# define NEVER(X)       ((X)?(assert(0),1):0)\n#else\n# define ALWAYS(X)      (X)\n# define NEVER(X)       (X)\n#endif\n\n/*\n** Some conditionals are optimizations only.  In other words, if the\n** conditionals are replaced with a constant 1 (true) or 0 (false) then\n** the correct answer is still obtained, though perhaps not as quickly.\n**\n** The following macros mark these optimizations conditionals.\n*/\n#if defined(SQLITE_MUTATION_TEST)\n# define OK_IF_ALWAYS_TRUE(X)  (1)\n# define OK_IF_ALWAYS_FALSE(X) (0)\n#else\n# define OK_IF_ALWAYS_TRUE(X)  (X)\n# define OK_IF_ALWAYS_FALSE(X) (X)\n#endif\n\n/*\n** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is\n** defined.  We need to defend against those failures when testing with\n** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches\n** during a normal build.  The following macro can be used to disable tests\n** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.\n*/\n#if defined(SQLITE_TEST_REALLOC_STRESS)\n# define ONLY_IF_REALLOC_STRESS(X)  (X)\n#elif !defined(NDEBUG)\n# define ONLY_IF_REALLOC_STRESS(X)  ((X)?(assert(0),1):0)\n#else\n# define ONLY_IF_REALLOC_STRESS(X)  (0)\n#endif\n\n/*\n** Declarations used for tracing the operating system interfaces.\n*/\n#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n  extern int sqlite3OSTrace;\n# define OSTRACE(X)          if( sqlite3OSTrace ) sqlite3DebugPrintf X\n# define SQLITE_HAVE_OS_TRACE\n#else\n# define OSTRACE(X)\n# undef  SQLITE_HAVE_OS_TRACE\n#endif\n\n/*\n** Is the sqlite3ErrName() function needed in the build?  Currently,\n** it is needed by \"mutex_w32.c\" (when debugging), \"os_win.c\" (when\n** OSTRACE is enabled), and by several \"test*.c\" files (which are\n** compiled using SQLITE_TEST).\n*/\n#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \\\n    (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)\n# define SQLITE_NEED_ERR_NAME\n#else\n# undef  SQLITE_NEED_ERR_NAME\n#endif\n\n/*\n** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN\n*/\n#ifdef SQLITE_OMIT_EXPLAIN\n# undef SQLITE_ENABLE_EXPLAIN_COMMENTS\n#endif\n\n/*\n** Return true (non-zero) if the input is an integer that is too large\n** to fit in 32-bits.  This macro is used inside of various testcase()\n** macros to verify that we have tested SQLite for large-file support.\n*/\n#define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)\n\n/*\n** The macro unlikely() is a hint that surrounds a boolean\n** expression that is usually false.  Macro likely() surrounds\n** a boolean expression that is usually true.  These hints could,\n** in theory, be used by the compiler to generate better code, but\n** currently they are just comments for human readers.\n*/\n#define likely(X)    (X)\n#define unlikely(X)  (X)\n\n#include \"hash.h\"\n#include \"parse.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#include <stddef.h>\n\n/*\n** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.\n** This allows better measurements of where memcpy() is used when running\n** cachegrind.  But this macro version of memcpy() is very slow so it\n** should not be used in production.  This is a performance measurement\n** hack only.\n*/\n#ifdef SQLITE_INLINE_MEMCPY\n# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\\\n                        int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}\n#endif\n\n/*\n** If compiling for a processor that lacks floating point support,\n** substitute integer for floating-point\n*/\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define double sqlite_int64\n# define float sqlite_int64\n# define LONGDOUBLE_TYPE sqlite_int64\n# ifndef SQLITE_BIG_DBL\n#   define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50)\n# endif\n# define SQLITE_OMIT_DATETIME_FUNCS 1\n# define SQLITE_OMIT_TRACE 1\n# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\n# undef SQLITE_HAVE_ISNAN\n#endif\n#ifndef SQLITE_BIG_DBL\n# define SQLITE_BIG_DBL (1e99)\n#endif\n\n/*\n** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0\n** afterward. Having this macro allows us to cause the C compiler\n** to omit code used by TEMP tables without messy #ifndef statements.\n*/\n#ifdef SQLITE_OMIT_TEMPDB\n#define OMIT_TEMPDB 1\n#else\n#define OMIT_TEMPDB 0\n#endif\n\n/*\n** The \"file format\" number is an integer that is incremented whenever\n** the VDBE-level file format changes.  The following macros define the\n** the default file format for new databases and the maximum file format\n** that the library can read.\n*/\n#define SQLITE_MAX_FILE_FORMAT 4\n#ifndef SQLITE_DEFAULT_FILE_FORMAT\n# define SQLITE_DEFAULT_FILE_FORMAT 4\n#endif\n\n/*\n** Determine whether triggers are recursive by default.  This can be\n** changed at run-time using a pragma.\n*/\n#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS\n# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0\n#endif\n\n/*\n** Provide a default value for SQLITE_TEMP_STORE in case it is not specified\n** on the command-line\n*/\n#ifndef SQLITE_TEMP_STORE\n# define SQLITE_TEMP_STORE 1\n#endif\n\n/*\n** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if\n** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it\n** to zero.\n*/\n#if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 0\n#endif\n#ifndef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS 8\n#endif\n#ifndef SQLITE_DEFAULT_WORKER_THREADS\n# define SQLITE_DEFAULT_WORKER_THREADS 0\n#endif\n#if SQLITE_DEFAULT_WORKER_THREADS>SQLITE_MAX_WORKER_THREADS\n# undef SQLITE_MAX_WORKER_THREADS\n# define SQLITE_MAX_WORKER_THREADS SQLITE_DEFAULT_WORKER_THREADS\n#endif\n\n/*\n** The default initial allocation for the pagecache when using separate\n** pagecaches for each database connection.  A positive number is the\n** number of pages.  A negative number N translations means that a buffer\n** of -1024*N bytes is allocated and used for as many pages as it will hold.\n**\n** The default value of \"20\" was choosen to minimize the run-time of the\n** speedtest1 test program with options: --shrink-memory --reprepare\n*/\n#ifndef SQLITE_DEFAULT_PCACHE_INITSZ\n# define SQLITE_DEFAULT_PCACHE_INITSZ 20\n#endif\n\n/*\n** The compile-time options SQLITE_MMAP_READWRITE and \n** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.\n** You must choose one or the other (or neither) but not both.\n*/\n#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE\n#endif\n\n/*\n** GCC does not define the offsetof() macro so we'll have to do it\n** ourselves.\n*/\n#ifndef offsetof\n#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))\n#endif\n\n/*\n** Macros to compute minimum and maximum of two numbers.\n*/\n#ifndef MIN\n# define MIN(A,B) ((A)<(B)?(A):(B))\n#endif\n#ifndef MAX\n# define MAX(A,B) ((A)>(B)?(A):(B))\n#endif\n\n/*\n** Swap two objects of type TYPE.\n*/\n#define SWAP(TYPE,A,B) {TYPE t=A; A=B; B=t;}\n\n/*\n** Check to see if this machine uses EBCDIC.  (Yes, believe it or\n** not, there are still machines out there that use EBCDIC.)\n*/\n#if 'A' == '\\301'\n# define SQLITE_EBCDIC 1\n#else\n# define SQLITE_ASCII 1\n#endif\n\n/*\n** Integers of known sizes.  These typedefs might change for architectures\n** where the sizes very.  Preprocessor macros are available so that the\n** types can be conveniently redefined at compile-type.  Like this:\n**\n**         cc '-DUINTPTR_TYPE=long long int' ...\n*/\n#ifndef UINT32_TYPE\n# ifdef HAVE_UINT32_T\n#  define UINT32_TYPE uint32_t\n# else\n#  define UINT32_TYPE unsigned int\n# endif\n#endif\n#ifndef UINT16_TYPE\n# ifdef HAVE_UINT16_T\n#  define UINT16_TYPE uint16_t\n# else\n#  define UINT16_TYPE unsigned short int\n# endif\n#endif\n#ifndef INT16_TYPE\n# ifdef HAVE_INT16_T\n#  define INT16_TYPE int16_t\n# else\n#  define INT16_TYPE short int\n# endif\n#endif\n#ifndef UINT8_TYPE\n# ifdef HAVE_UINT8_T\n#  define UINT8_TYPE uint8_t\n# else\n#  define UINT8_TYPE unsigned char\n# endif\n#endif\n#ifndef INT8_TYPE\n# ifdef HAVE_INT8_T\n#  define INT8_TYPE int8_t\n# else\n#  define INT8_TYPE signed char\n# endif\n#endif\n#ifndef LONGDOUBLE_TYPE\n# define LONGDOUBLE_TYPE long double\n#endif\ntypedef sqlite_int64 i64;          /* 8-byte signed integer */\ntypedef sqlite_uint64 u64;         /* 8-byte unsigned integer */\ntypedef UINT32_TYPE u32;           /* 4-byte unsigned integer */\ntypedef UINT16_TYPE u16;           /* 2-byte unsigned integer */\ntypedef INT16_TYPE i16;            /* 2-byte signed integer */\ntypedef UINT8_TYPE u8;             /* 1-byte unsigned integer */\ntypedef INT8_TYPE i8;              /* 1-byte signed integer */\n\n/*\n** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value\n** that can be stored in a u32 without loss of data.  The value\n** is 0x00000000ffffffff.  But because of quirks of some compilers, we\n** have to specify the value in the less intuitive manner shown:\n*/\n#define SQLITE_MAX_U32  ((((u64)1)<<32)-1)\n\n/*\n** The datatype used to store estimates of the number of rows in a\n** table or index.  This is an unsigned integer type.  For 99.9% of\n** the world, a 32-bit integer is sufficient.  But a 64-bit integer\n** can be used at compile-time if desired.\n*/\n#ifdef SQLITE_64BIT_STATS\n typedef u64 tRowcnt;    /* 64-bit only if requested at compile-time */\n#else\n typedef u32 tRowcnt;    /* 32-bit is the default */\n#endif\n\n/*\n** Estimated quantities used for query planning are stored as 16-bit\n** logarithms.  For quantity X, the value stored is 10*log2(X).  This\n** gives a possible range of values of approximately 1.0e986 to 1e-986.\n** But the allowed values are \"grainy\".  Not every value is representable.\n** For example, quantities 16 and 17 are both represented by a LogEst\n** of 40.  However, since LogEst quantities are suppose to be estimates,\n** not exact values, this imprecision is not a problem.\n**\n** \"LogEst\" is short for \"Logarithmic Estimate\".\n**\n** Examples:\n**      1 -> 0              20 -> 43          10000 -> 132\n**      2 -> 10             25 -> 46          25000 -> 146\n**      3 -> 16            100 -> 66        1000000 -> 199\n**      4 -> 20           1000 -> 99        1048576 -> 200\n**     10 -> 33           1024 -> 100    4294967296 -> 320\n**\n** The LogEst can be negative to indicate fractional values.\n** Examples:\n**\n**    0.5 -> -10           0.1 -> -33        0.0625 -> -40\n*/\ntypedef INT16_TYPE LogEst;\n\n/*\n** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer\n*/\n#ifndef SQLITE_PTRSIZE\n# if defined(__SIZEOF_POINTER__)\n#   define SQLITE_PTRSIZE __SIZEOF_POINTER__\n# elif defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n       defined(_M_ARM)   || defined(__arm__)    || defined(__x86)\n#   define SQLITE_PTRSIZE 4\n# else\n#   define SQLITE_PTRSIZE 8\n# endif\n#endif\n\n/* The uptr type is an unsigned integer large enough to hold a pointer\n*/\n#if defined(HAVE_STDINT_H)\n  typedef uintptr_t uptr;\n#elif SQLITE_PTRSIZE==4\n  typedef u32 uptr;\n#else\n  typedef u64 uptr;\n#endif\n\n/*\n** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to\n** something between S (inclusive) and E (exclusive).\n**\n** In other words, S is a buffer and E is a pointer to the first byte after\n** the end of buffer S.  This macro returns true if P points to something\n** contained within the buffer S.\n*/\n#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))\n\n\n/*\n** Macros to determine whether the machine is big or little endian,\n** and whether or not that determination is run-time or compile-time.\n**\n** For best performance, an attempt is made to guess at the byte-order\n** using C-preprocessor macros.  If that is unsuccessful, or if\n** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined\n** at run-time.\n*/\n#ifndef SQLITE_BYTEORDER\n# if defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \\\n     defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \\\n     defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \\\n     defined(__arm__)\n#   define SQLITE_BYTEORDER    1234\n# elif defined(sparc)    || defined(__ppc__)\n#   define SQLITE_BYTEORDER    4321\n# else\n#   define SQLITE_BYTEORDER 0\n# endif\n#endif\n#if SQLITE_BYTEORDER==4321\n# define SQLITE_BIGENDIAN    1\n# define SQLITE_LITTLEENDIAN 0\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16BE\n#elif SQLITE_BYTEORDER==1234\n# define SQLITE_BIGENDIAN    0\n# define SQLITE_LITTLEENDIAN 1\n# define SQLITE_UTF16NATIVE  SQLITE_UTF16LE\n#else\n# ifdef SQLITE_AMALGAMATION\n  const int sqlite3one = 1;\n# else\n  extern const int sqlite3one;\n# endif\n# define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)\n# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)\n# define SQLITE_UTF16NATIVE  (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)\n#endif\n\n/*\n** Constants for the largest and smallest possible 64-bit signed integers.\n** These macros are designed to work correctly on both 32-bit and 64-bit\n** compilers.\n*/\n#define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))\n#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)\n\n/*\n** Round up a number to the next larger multiple of 8.  This is used\n** to force 8-byte alignment on 64-bit architectures.\n*/\n#define ROUND8(x)     (((x)+7)&~7)\n\n/*\n** Round down to the nearest multiple of 8\n*/\n#define ROUNDDOWN8(x) ((x)&~7)\n\n/*\n** Assert that the pointer X is aligned to an 8-byte boundary.  This\n** macro is used only within assert() to verify that the code gets\n** all alignment restrictions correct.\n**\n** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the\n** underlying malloc() implementation might return us 4-byte aligned\n** pointers.  In that case, only verify 4-byte alignment.\n*/\n#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)\n#else\n# define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)\n#endif\n\n/*\n** Disable MMAP on platforms where it is known to not work\n*/\n#if defined(__OpenBSD__) || defined(__QNXNTO__)\n# undef SQLITE_MAX_MMAP_SIZE\n# define SQLITE_MAX_MMAP_SIZE 0\n#endif\n\n/*\n** Default maximum size of memory used by memory-mapped I/O in the VFS\n*/\n#ifdef __APPLE__\n# include <TargetConditionals.h>\n#endif\n#ifndef SQLITE_MAX_MMAP_SIZE\n# if defined(__linux__) \\\n  || defined(_WIN32) \\\n  || (defined(__APPLE__) && defined(__MACH__)) \\\n  || defined(__sun) \\\n  || defined(__FreeBSD__) \\\n  || defined(__DragonFly__)\n#   define SQLITE_MAX_MMAP_SIZE 0x7fff0000  /* 2147418112 */\n# else\n#   define SQLITE_MAX_MMAP_SIZE 0\n# endif\n#endif\n\n/*\n** The default MMAP_SIZE is zero on all platforms.  Or, even if a larger\n** default MMAP_SIZE is specified at compile-time, make sure that it does\n** not exceed the maximum mmap size.\n*/\n#ifndef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE 0\n#endif\n#if SQLITE_DEFAULT_MMAP_SIZE>SQLITE_MAX_MMAP_SIZE\n# undef SQLITE_DEFAULT_MMAP_SIZE\n# define SQLITE_DEFAULT_MMAP_SIZE SQLITE_MAX_MMAP_SIZE\n#endif\n\n/*\n** Only one of SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4 can be defined.\n** Priority is given to SQLITE_ENABLE_STAT4.  If either are defined, also\n** define SQLITE_ENABLE_STAT3_OR_STAT4\n*/\n#ifdef SQLITE_ENABLE_STAT4\n# undef SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3\n# define SQLITE_ENABLE_STAT3_OR_STAT4 1\n#elif SQLITE_ENABLE_STAT3_OR_STAT4\n# undef SQLITE_ENABLE_STAT3_OR_STAT4\n#endif\n\n/*\n** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not\n** the Select query generator tracing logic is turned on.\n*/\n#if defined(SQLITE_ENABLE_SELECTTRACE)\n# define SELECTTRACE_ENABLED 1\n#else\n# define SELECTTRACE_ENABLED 0\n#endif\n\n/*\n** An instance of the following structure is used to store the busy-handler\n** callback for a given sqlite handle.\n**\n** The sqlite.busyHandler member of the sqlite struct contains the busy\n** callback for the database handle. Each pager opened via the sqlite\n** handle is passed a pointer to sqlite.busyHandler. The busy-handler\n** callback is currently invoked only from within pager.c.\n*/\ntypedef struct BusyHandler BusyHandler;\nstruct BusyHandler {\n  int (*xFunc)(void *,int);  /* The busy callback */\n  void *pArg;                /* First arg to busy callback */\n  int nBusy;                 /* Incremented with each busy call */\n};\n\n/*\n** Name of the master database table.  The master database table\n** is a special table that holds the names and attributes of all\n** user tables and indices.\n*/\n#define MASTER_NAME       \"sqlite_master\"\n#define TEMP_MASTER_NAME  \"sqlite_temp_master\"\n\n/*\n** The root-page of the master database table.\n*/\n#define MASTER_ROOT       1\n\n/*\n** The name of the schema table.\n*/\n#define SCHEMA_TABLE(x)  ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME)\n\n/*\n** A convenience macro that returns the number of elements in\n** an array.\n*/\n#define ArraySize(X)    ((int)(sizeof(X)/sizeof(X[0])))\n\n/*\n** Determine if the argument is a power of two\n*/\n#define IsPowerOfTwo(X) (((X)&((X)-1))==0)\n\n/*\n** The following value as a destructor means to use sqlite3DbFree().\n** The sqlite3DbFree() routine requires two parameters instead of the\n** one parameter that destructors normally want.  So we have to introduce\n** this magic value that the code knows to handle differently.  Any\n** pointer will work here as long as it is distinct from SQLITE_STATIC\n** and SQLITE_TRANSIENT.\n*/\n#define SQLITE_DYNAMIC   ((sqlite3_destructor_type)sqlite3MallocSize)\n\n/*\n** When SQLITE_OMIT_WSD is defined, it means that the target platform does\n** not support Writable Static Data (WSD) such as global and static variables.\n** All variables must either be on the stack or dynamically allocated from\n** the heap.  When WSD is unsupported, the variable declarations scattered\n** throughout the SQLite code must become constants instead.  The SQLITE_WSD\n** macro is used for this purpose.  And instead of referencing the variable\n** directly, we use its constant as a key to lookup the run-time allocated\n** buffer that holds real variable.  The constant is also the initializer\n** for the run-time allocated buffer.\n**\n** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL\n** macros become no-ops and have zero performance impact.\n*/\n#ifdef SQLITE_OMIT_WSD\n  #define SQLITE_WSD const\n  #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))\n  #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)\n  int sqlite3_wsd_init(int N, int J);\n  void *sqlite3_wsd_find(void *K, int L);\n#else\n  #define SQLITE_WSD\n  #define GLOBAL(t,v) v\n  #define sqlite3GlobalConfig sqlite3Config\n#endif\n\n/*\n** The following macros are used to suppress compiler warnings and to\n** make it clear to human readers when a function parameter is deliberately\n** left unused within the body of a function. This usually happens when\n** a function is called via a function pointer. For example the\n** implementation of an SQL aggregate step callback may not use the\n** parameter indicating the number of arguments passed to the aggregate,\n** if it knows that this is enforced elsewhere.\n**\n** When a function parameter is not used at all within the body of a function,\n** it is generally named \"NotUsed\" or \"NotUsed2\" to make things even clearer.\n** However, these macros may also be used to suppress warnings related to\n** parameters that may or may not be used depending on compilation options.\n** For example those parameters only used in assert() statements. In these\n** cases the parameters are named as per the usual conventions.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y)\n\n/*\n** Forward references to structures\n*/\ntypedef struct AggInfo AggInfo;\ntypedef struct AuthContext AuthContext;\ntypedef struct AutoincInfo AutoincInfo;\ntypedef struct Bitvec Bitvec;\ntypedef struct CollSeq CollSeq;\ntypedef struct Column Column;\ntypedef struct Db Db;\ntypedef struct Schema Schema;\ntypedef struct Expr Expr;\ntypedef struct ExprList ExprList;\ntypedef struct ExprSpan ExprSpan;\ntypedef struct FKey FKey;\ntypedef struct FuncDestructor FuncDestructor;\ntypedef struct FuncDef FuncDef;\ntypedef struct FuncDefHash FuncDefHash;\ntypedef struct IdList IdList;\ntypedef struct Index Index;\ntypedef struct IndexSample IndexSample;\ntypedef struct KeyClass KeyClass;\ntypedef struct KeyInfo KeyInfo;\ntypedef struct Lookaside Lookaside;\ntypedef struct LookasideSlot LookasideSlot;\ntypedef struct Module Module;\ntypedef struct NameContext NameContext;\ntypedef struct Parse Parse;\ntypedef struct PreUpdate PreUpdate;\ntypedef struct PrintfArguments PrintfArguments;\ntypedef struct RowSet RowSet;\ntypedef struct Savepoint Savepoint;\ntypedef struct Select Select;\ntypedef struct SQLiteThread SQLiteThread;\ntypedef struct SelectDest SelectDest;\ntypedef struct SrcList SrcList;\ntypedef struct StrAccum StrAccum;\ntypedef struct Table Table;\ntypedef struct TableLock TableLock;\ntypedef struct Token Token;\ntypedef struct TreeView TreeView;\ntypedef struct Trigger Trigger;\ntypedef struct TriggerPrg TriggerPrg;\ntypedef struct TriggerStep TriggerStep;\ntypedef struct UnpackedRecord UnpackedRecord;\ntypedef struct VTable VTable;\ntypedef struct VtabCtx VtabCtx;\ntypedef struct Walker Walker;\ntypedef struct WhereInfo WhereInfo;\ntypedef struct With With;\n\n/* A VList object records a mapping between parameters/variables/wildcards\n** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer\n** variable number associated with that parameter.  See the format description\n** on the sqlite3VListAdd() routine for more information.  A VList is really\n** just an array of integers.\n*/\ntypedef int VList;\n\n/*\n** Defer sourcing vdbe.h and btree.h until after the \"u8\" and\n** \"BusyHandler\" typedefs. vdbe.h also requires a few of the opaque\n** pointer types (i.e. FuncDef) defined above.\n*/\n#include \"btree.h\"\n#include \"vdbe.h\"\n#include \"pager.h\"\n#include \"pcache.h\"\n#include \"os.h\"\n#include \"mutex.h\"\n\n/* The SQLITE_EXTRA_DURABLE compile-time option used to set the default\n** synchronous setting to EXTRA.  It is no longer supported.\n*/\n#ifdef SQLITE_EXTRA_DURABLE\n# warning Use SQLITE_DEFAULT_SYNCHRONOUS=3 instead of SQLITE_EXTRA_DURABLE\n# define SQLITE_DEFAULT_SYNCHRONOUS 3\n#endif\n\n/*\n** Default synchronous levels.\n**\n** Note that (for historcal reasons) the PAGER_SYNCHRONOUS_* macros differ\n** from the SQLITE_DEFAULT_SYNCHRONOUS value by 1.\n**\n**           PAGER_SYNCHRONOUS       DEFAULT_SYNCHRONOUS\n**   OFF           1                         0\n**   NORMAL        2                         1\n**   FULL          3                         2\n**   EXTRA         4                         3\n**\n** The \"PRAGMA synchronous\" statement also uses the zero-based numbers.\n** In other words, the zero-based numbers are used for all external interfaces\n** and the one-based values are used internally.\n*/\n#ifndef SQLITE_DEFAULT_SYNCHRONOUS\n# define SQLITE_DEFAULT_SYNCHRONOUS 2\n#endif\n#ifndef SQLITE_DEFAULT_WAL_SYNCHRONOUS\n# define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS\n#endif\n\n/*\n** Each database file to be accessed by the system is an instance\n** of the following structure.  There are normally two of these structures\n** in the sqlite.aDb[] array.  aDb[0] is the main database file and\n** aDb[1] is the database file used to hold temporary tables.  Additional\n** databases may be attached.\n*/\nstruct Db {\n  char *zDbSName;      /* Name of this database. (schema name, not filename) */\n  Btree *pBt;          /* The B*Tree structure for this database file */\n  u8 safety_level;     /* How aggressive at syncing data to disk */\n  u8 bSyncSet;         /* True if \"PRAGMA synchronous=N\" has been run */\n  Schema *pSchema;     /* Pointer to database schema (possibly shared) */\n};\n\n/*\n** An instance of the following structure stores a database schema.\n**\n** Most Schema objects are associated with a Btree.  The exception is\n** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.\n** In shared cache mode, a single Schema object can be shared by multiple\n** Btrees that refer to the same underlying BtShared object.\n**\n** Schema objects are automatically deallocated when the last Btree that\n** references them is destroyed.   The TEMP Schema is manually freed by\n** sqlite3_close().\n*\n** A thread must be holding a mutex on the corresponding Btree in order\n** to access Schema content.  This implies that the thread must also be\n** holding a mutex on the sqlite3 connection pointer that owns the Btree.\n** For a TEMP Schema, only the connection mutex is required.\n*/\nstruct Schema {\n  int schema_cookie;   /* Database schema version number for this file */\n  int iGeneration;     /* Generation counter.  Incremented with each change */\n  Hash tblHash;        /* All tables indexed by name */\n  Hash idxHash;        /* All (named) indices indexed by name */\n  Hash trigHash;       /* All triggers indexed by name */\n  Hash fkeyHash;       /* All foreign keys by referenced table name */\n  Table *pSeqTab;      /* The sqlite_sequence table used by AUTOINCREMENT */\n  u8 file_format;      /* Schema format version for this file */\n  u8 enc;              /* Text encoding used by this database */\n  u16 schemaFlags;     /* Flags associated with this schema */\n  int cache_size;      /* Number of pages to use in the cache */\n};\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Db.pSchema->flags field.\n*/\n#define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))\n#define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)\n#define DbSetProperty(D,I,P)     (D)->aDb[I].pSchema->schemaFlags|=(P)\n#define DbClearProperty(D,I,P)   (D)->aDb[I].pSchema->schemaFlags&=~(P)\n\n/*\n** Allowed values for the DB.pSchema->flags field.\n**\n** The DB_SchemaLoaded flag is set after the database schema has been\n** read into internal hash tables.\n**\n** DB_UnresetViews means that one or more views have column names that\n** have been filled out.  If the schema changes, these column names might\n** changes and so the view will need to be reset.\n*/\n#define DB_SchemaLoaded    0x0001  /* The schema has been loaded */\n#define DB_UnresetViews    0x0002  /* Some views have defined column names */\n#define DB_Empty           0x0004  /* The file is empty (length 0 bytes) */\n#define DB_ResetWanted     0x0008  /* Reset the schema when nSchemaLock==0 */\n\n/*\n** The number of different kinds of things that can be limited\n** using the sqlite3_limit() interface.\n*/\n#define SQLITE_N_LIMIT (SQLITE_LIMIT_WORKER_THREADS+1)\n\n/*\n** Lookaside malloc is a set of fixed-size buffers that can be used\n** to satisfy small transient memory allocation requests for objects\n** associated with a particular database connection.  The use of\n** lookaside malloc provides a significant performance enhancement\n** (approx 10%) by avoiding numerous malloc/free requests while parsing\n** SQL statements.\n**\n** The Lookaside structure holds configuration information about the\n** lookaside malloc subsystem.  Each available memory allocation in\n** the lookaside subsystem is stored on a linked list of LookasideSlot\n** objects.\n**\n** Lookaside allocations are only allowed for objects that are associated\n** with a particular database connection.  Hence, schema information cannot\n** be stored in lookaside because in shared cache mode the schema information\n** is shared by multiple database connections.  Therefore, while parsing\n** schema information, the Lookaside.bEnabled flag is cleared so that\n** lookaside allocations are not used to construct the schema objects.\n*/\nstruct Lookaside {\n  u32 bDisable;           /* Only operate the lookaside when zero */\n  u16 sz;                 /* Size of each buffer in bytes */\n  u8 bMalloced;           /* True if pStart obtained from sqlite3_malloc() */\n  u32 nSlot;              /* Number of lookaside slots allocated */\n  u32 anStat[3];          /* 0: hits.  1: size misses.  2: full misses */\n  LookasideSlot *pInit;   /* List of buffers not previously used */\n  LookasideSlot *pFree;   /* List of available buffers */\n  void *pStart;           /* First byte of available memory space */\n  void *pEnd;             /* First byte past end of available space */\n};\nstruct LookasideSlot {\n  LookasideSlot *pNext;    /* Next buffer in the list of free buffers */\n};\n\n/*\n** A hash table for built-in function definitions.  (Application-defined\n** functions use a regular table table from hash.h.)\n**\n** Hash each FuncDef structure into one of the FuncDefHash.a[] slots.\n** Collisions are on the FuncDef.u.pHash chain.\n*/\n#define SQLITE_FUNC_HASH_SZ 23\nstruct FuncDefHash {\n  FuncDef *a[SQLITE_FUNC_HASH_SZ];       /* Hash table for functions */\n};\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** Information held in the \"sqlite3\" database connection object and used\n** to manage user authentication.\n*/\ntypedef struct sqlite3_userauth sqlite3_userauth;\nstruct sqlite3_userauth {\n  u8 authLevel;                 /* Current authentication level */\n  int nAuthPW;                  /* Size of the zAuthPW in bytes */\n  char *zAuthPW;                /* Password used to authenticate */\n  char *zAuthUser;              /* User name used to authenticate */\n};\n\n/* Allowed values for sqlite3_userauth.authLevel */\n#define UAUTH_Unknown     0     /* Authentication not yet checked */\n#define UAUTH_Fail        1     /* User authentication failed */\n#define UAUTH_User        2     /* Authenticated as a normal user */\n#define UAUTH_Admin       3     /* Authenticated as an administrator */\n\n/* Functions used only by user authorization logic */\nint sqlite3UserAuthTable(const char*);\nint sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);\nvoid sqlite3UserAuthInit(sqlite3*);\nvoid sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);\n\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n/*\n** typedef for the authorization callback function.\n*/\n#ifdef SQLITE_USER_AUTHENTICATION\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*, const char*);\n#else\n  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,\n                               const char*);\n#endif\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/* This is an extra SQLITE_TRACE macro that indicates \"legacy\" tracing\n** in the style of sqlite3_trace()\n*/\n#define SQLITE_TRACE_LEGACY  0x80\n#else\n#define SQLITE_TRACE_LEGACY  0\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n\n/*\n** Each database connection is an instance of the following structure.\n*/\nstruct sqlite3 {\n  sqlite3_vfs *pVfs;            /* OS Interface */\n  struct Vdbe *pVdbe;           /* List of active virtual machines */\n  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */\n  sqlite3_mutex *mutex;         /* Connection mutex */\n  Db *aDb;                      /* All backends */\n  int nDb;                      /* Number of backends currently in use */\n  u32 mDbFlags;                 /* flags recording internal state */\n  u32 flags;                    /* flags settable by pragmas. See below */\n  i64 lastRowid;                /* ROWID of most recent insert (see above) */\n  i64 szMmap;                   /* Default mmap_size setting */\n  u32 nSchemaLock;              /* Do not reset the schema when non-zero */\n  unsigned int openFlags;       /* Flags passed to sqlite3_vfs.xOpen() */\n  int errCode;                  /* Most recent error code (SQLITE_*) */\n  int errMask;                  /* & result codes with this before returning */\n  int iSysErrno;                /* Errno value from last system error */\n  u16 dbOptFlags;               /* Flags to enable/disable optimizations */\n  u8 enc;                       /* Text encoding */\n  u8 autoCommit;                /* The auto-commit flag. */\n  u8 temp_store;                /* 1: file 2: memory 0: default */\n  u8 mallocFailed;              /* True if we have seen a malloc failure */\n  u8 bBenignMalloc;             /* Do not require OOMs if true */\n  u8 dfltLockMode;              /* Default locking-mode for attached dbs */\n  signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */\n  u8 suppressErr;               /* Do not issue error messages if true */\n  u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */\n  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */\n  u8 mTrace;                    /* zero or more SQLITE_TRACE flags */\n  u8 skipBtreeMutex;            /* True if no shared-cache backends */\n  u8 nSqlExec;                  /* Number of pending OP_SqlExec opcodes */\n  int nextPagesize;             /* Pagesize after VACUUM if >0 */\n  u32 magic;                    /* Magic number for detect library misuse */\n  int nChange;                  /* Value returned by sqlite3_changes() */\n  int nTotalChange;             /* Value returned by sqlite3_total_changes() */\n  int aLimit[SQLITE_N_LIMIT];   /* Limits */\n  int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */\n  struct sqlite3InitInfo {      /* Information used during initialization */\n    int newTnum;                /* Rootpage of table being initialized */\n    u8 iDb;                     /* Which db file is being initialized */\n    u8 busy;                    /* TRUE if currently initializing */\n    u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */\n    u8 imposterTable;           /* Building an imposter table */\n  } init;\n  int nVdbeActive;              /* Number of VDBEs currently running */\n  int nVdbeRead;                /* Number of active VDBEs that read or write */\n  int nVdbeWrite;               /* Number of active VDBEs that read and write */\n  int nVdbeExec;                /* Number of nested calls to VdbeExec() */\n  int nVDestroy;                /* Number of active OP_VDestroy operations */\n  int nExtension;               /* Number of loaded extensions */\n  void **aExtension;            /* Array of shared library handles */\n  int (*xTrace)(u32,void*,void*,void*);     /* Trace function */\n  void *pTraceArg;                          /* Argument to the trace function */\n  void (*xProfile)(void*,const char*,u64);  /* Profiling function */\n  void *pProfileArg;                        /* Argument to profile function */\n  void *pCommitArg;                 /* Argument to xCommitCallback() */\n  int (*xCommitCallback)(void*);    /* Invoked at every commit. */\n  void *pRollbackArg;               /* Argument to xRollbackCallback() */\n  void (*xRollbackCallback)(void*); /* Invoked at every commit. */\n  void *pUpdateArg;\n  void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  void *pPreUpdateArg;          /* First argument to xPreUpdateCallback */\n  void (*xPreUpdateCallback)(   /* Registered using sqlite3_preupdate_hook() */\n    void*,sqlite3*,int,char const*,char const*,sqlite3_int64,sqlite3_int64\n  );\n  PreUpdate *pPreUpdate;        /* Context for active pre-update callback */\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n#ifndef SQLITE_OMIT_WAL\n  int (*xWalCallback)(void *, sqlite3 *, const char *, int);\n  void *pWalArg;\n#endif\n  void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);\n  void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);\n  void *pCollNeededArg;\n  sqlite3_value *pErr;          /* Most recent error message */\n  union {\n    volatile int isInterrupted; /* True if sqlite3_interrupt has been called */\n    double notUsed1;            /* Spacer */\n  } u1;\n  Lookaside lookaside;          /* Lookaside malloc configuration */\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  sqlite3_xauth xAuth;          /* Access authorization function */\n  void *pAuthArg;               /* 1st argument to the access auth function */\n#endif\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  int (*xProgress)(void *);     /* The progress callback */\n  void *pProgressArg;           /* Argument to the progress callback */\n  unsigned nProgressOps;        /* Number of opcodes for progress callback */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nVTrans;                  /* Allocated size of aVTrans */\n  Hash aModule;                 /* populated by sqlite3_create_module() */\n  VtabCtx *pVtabCtx;            /* Context for active vtab connect/create */\n  VTable **aVTrans;             /* Virtual tables with open transactions */\n  VTable *pDisconnect;    /* Disconnect these in next sqlite3_prepare() */\n#endif\n  Hash aFunc;                   /* Hash table of connection functions */\n  Hash aCollSeq;                /* All collating sequences */\n  BusyHandler busyHandler;      /* Busy callback */\n  Db aDbStatic[2];              /* Static space for the 2 default backends */\n  Savepoint *pSavepoint;        /* List of active savepoints */\n  int busyTimeout;              /* Busy handler timeout, in msec */\n  int nSavepoint;               /* Number of non-transaction savepoints */\n  int nStatement;               /* Number of nested statement-transactions  */\n  i64 nDeferredCons;            /* Net deferred constraints this transaction. */\n  i64 nDeferredImmCons;         /* Net deferred immediate constraints */\n  int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  /* The following variables are all protected by the STATIC_MASTER\n  ** mutex, not by sqlite3.mutex. They are used by code in notify.c.\n  **\n  ** When X.pUnlockConnection==Y, that means that X is waiting for Y to\n  ** unlock so that it can proceed.\n  **\n  ** When X.pBlockingConnection==Y, that means that something that X tried\n  ** tried to do recently failed with an SQLITE_LOCKED error due to locks\n  ** held by Y.\n  */\n  sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */\n  sqlite3 *pUnlockConnection;           /* Connection to watch for unlock */\n  void *pUnlockArg;                     /* Argument to xUnlockNotify */\n  void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */\n  sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */\n#endif\n#ifdef SQLITE_USER_AUTHENTICATION\n  sqlite3_userauth auth;        /* User authentication information */\n#endif\n};\n\n/*\n** A macro to discover the encoding of a database.\n*/\n#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)\n#define ENC(db)        ((db)->enc)\n\n/*\n** Possible values for the sqlite3.flags.\n**\n** Value constraints (enforced via assert()):\n**      SQLITE_FullFSync     == PAGER_FULLFSYNC\n**      SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC\n**      SQLITE_CacheSpill    == PAGER_CACHE_SPILL\n*/\n#define SQLITE_WriteSchema    0x00000001  /* OK to update SQLITE_MASTER */\n#define SQLITE_LegacyFileFmt  0x00000002  /* Create new databases in format 1 */\n#define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */\n#define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */\n#define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */\n#define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */\n#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */\n#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */\n                                          /*   DELETE, or UPDATE and return */\n                                          /*   the count using a callback. */\n#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */\n                                          /*   result set is empty */\n#define SQLITE_IgnoreChecks   0x00000200  /* Do not enforce check constraints */\n#define SQLITE_ReadUncommit   0x00000400  /* READ UNCOMMITTED in shared-cache */\n#define SQLITE_NoCkptOnClose  0x00000800  /* No checkpoint on close()/DETACH */\n#define SQLITE_ReverseOrder   0x00001000  /* Reverse unordered SELECTs */\n#define SQLITE_RecTriggers    0x00002000  /* Enable recursive triggers */\n#define SQLITE_ForeignKeys    0x00004000  /* Enforce foreign key constraints  */\n#define SQLITE_AutoIndex      0x00008000  /* Enable automatic indexes */\n#define SQLITE_LoadExtension  0x00010000  /* Enable load_extension */\n#define SQLITE_LoadExtFunc    0x00020000  /* Enable load_extension() SQL func */\n#define SQLITE_EnableTrigger  0x00040000  /* True to enable triggers */\n#define SQLITE_DeferFKs       0x00080000  /* Defer all FK constraints */\n#define SQLITE_QueryOnly      0x00100000  /* Disable database changes */\n#define SQLITE_CellSizeCk     0x00200000  /* Check btree cell sizes on load */\n#define SQLITE_Fts3Tokenizer  0x00400000  /* Enable fts3_tokenizer(2) */\n#define SQLITE_EnableQPSG     0x00800000  /* Query Planner Stability Guarantee */\n/* Flags used only if debugging */\n#ifdef SQLITE_DEBUG\n#define SQLITE_SqlTrace       0x08000000  /* Debug print SQL as it executes */\n#define SQLITE_VdbeListing    0x10000000  /* Debug listings of VDBE programs */\n#define SQLITE_VdbeTrace      0x20000000  /* True to trace VDBE execution */\n#define SQLITE_VdbeAddopTrace 0x40000000  /* Trace sqlite3VdbeAddOp() calls */\n#define SQLITE_VdbeEQP        0x80000000  /* Debug EXPLAIN QUERY PLAN */\n#endif\n\n/*\n** Allowed values for sqlite3.mDbFlags\n*/\n#define DBFLAG_SchemaChange   0x0001  /* Uncommitted Hash table changes */\n#define DBFLAG_PreferBuiltin  0x0002  /* Preference to built-in funcs */\n#define DBFLAG_Vacuum         0x0004  /* Currently in a VACUUM */\n\n/*\n** Bits of the sqlite3.dbOptFlags field that are used by the\n** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to\n** selectively disable various optimizations.\n*/\n#define SQLITE_QueryFlattener 0x0001   /* Query flattening */\n#define SQLITE_ColumnCache    0x0002   /* Column cache */\n#define SQLITE_GroupByOrder   0x0004   /* GROUPBY cover of ORDERBY */\n#define SQLITE_FactorOutConst 0x0008   /* Constant factoring */\n#define SQLITE_DistinctOpt    0x0010   /* DISTINCT using indexes */\n#define SQLITE_CoverIdxScan   0x0020   /* Covering index scans */\n#define SQLITE_OrderByIdxJoin 0x0040   /* ORDER BY of joins via index */\n#define SQLITE_Transitive     0x0080   /* Transitive constraints */\n#define SQLITE_OmitNoopJoin   0x0100   /* Omit unused tables in joins */\n#define SQLITE_CountOfView    0x0200   /* The count-of-view optimization */\n#define SQLITE_CursorHints    0x0400   /* Add OP_CursorHint opcodes */\n#define SQLITE_Stat34         0x0800   /* Use STAT3 or STAT4 data */\n   /* TH3 expects the Stat34  ^^^^^^ value to be 0x0800.  Don't change it */\n#define SQLITE_AllOpts        0xffff   /* All optimizations */\n\n/*\n** Macros for testing whether or not optimizations are enabled or disabled.\n*/\n#define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)\n#define OptimizationEnabled(db, mask)   (((db)->dbOptFlags&(mask))==0)\n\n/*\n** Return true if it OK to factor constant expressions into the initialization\n** code. The argument is a Parse object for the code generator.\n*/\n#define ConstFactorOk(P) ((P)->okConstFactor)\n\n/*\n** Possible values for the sqlite.magic field.\n** The numbers are obtained at random and have no special meaning, other\n** than being distinct from one another.\n*/\n#define SQLITE_MAGIC_OPEN     0xa029a697  /* Database is open */\n#define SQLITE_MAGIC_CLOSED   0x9f3c2d33  /* Database is closed */\n#define SQLITE_MAGIC_SICK     0x4b771290  /* Error and awaiting close */\n#define SQLITE_MAGIC_BUSY     0xf03b7906  /* Database currently in use */\n#define SQLITE_MAGIC_ERROR    0xb5357930  /* An SQLITE_MISUSE error occurred */\n#define SQLITE_MAGIC_ZOMBIE   0x64cffc7f  /* Close with last statement close */\n\n/*\n** Each SQL function is defined by an instance of the following\n** structure.  For global built-in functions (ex: substr(), max(), count())\n** a pointer to this structure is held in the sqlite3BuiltinFunctions object.\n** For per-connection application-defined functions, a pointer to this\n** structure is held in the db->aHash hash table.\n**\n** The u.pHash field is used by the global built-ins.  The u.pDestructor\n** field is used by per-connection app-def functions.\n*/\nstruct FuncDef {\n  i8 nArg;             /* Number of arguments.  -1 means unlimited */\n  u16 funcFlags;       /* Some combination of SQLITE_FUNC_* */\n  void *pUserData;     /* User data parameter */\n  FuncDef *pNext;      /* Next function with same name */\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */\n  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */\n  const char *zName;   /* SQL name of the function. */\n  union {\n    FuncDef *pHash;      /* Next with a different name but the same hash */\n    FuncDestructor *pDestructor;   /* Reference counted destructor function */\n  } u;\n};\n\n/*\n** This structure encapsulates a user-function destructor callback (as\n** configured using create_function_v2()) and a reference counter. When\n** create_function_v2() is called to create a function with a destructor,\n** a single object of this type is allocated. FuncDestructor.nRef is set to\n** the number of FuncDef objects created (either 1 or 3, depending on whether\n** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor\n** member of each of the new FuncDef objects is set to point to the allocated\n** FuncDestructor.\n**\n** Thereafter, when one of the FuncDef objects is deleted, the reference\n** count on this object is decremented. When it reaches 0, the destructor\n** is invoked and the FuncDestructor structure freed.\n*/\nstruct FuncDestructor {\n  int nRef;\n  void (*xDestroy)(void *);\n  void *pUserData;\n};\n\n/*\n** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF\n** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And\n** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There\n** are assert() statements in the code to verify this.\n**\n** Value constraints (enforced via assert()):\n**     SQLITE_FUNC_MINMAX    ==  NC_MinMaxAgg      == SF_MinMaxAgg\n**     SQLITE_FUNC_LENGTH    ==  OPFLAG_LENGTHARG\n**     SQLITE_FUNC_TYPEOF    ==  OPFLAG_TYPEOFARG\n**     SQLITE_FUNC_CONSTANT  ==  SQLITE_DETERMINISTIC from the API\n**     SQLITE_FUNC_ENCMASK   depends on SQLITE_UTF* macros in the API\n*/\n#define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */\n#define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */\n#define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */\n#define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */\n#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/\n#define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */\n#define SQLITE_FUNC_TYPEOF   0x0080 /* Built-in typeof() function */\n#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */\n#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */\n#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */\n#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */\n#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */\n#define SQLITE_FUNC_SLOCHNG  0x2000 /* \"Slow Change\". Value constant during a\n                                    ** single query - might change over time */\n#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */\n\n/*\n** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are\n** used to create the initializers for the FuncDef structures.\n**\n**   FUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Used to create a scalar function definition of a function zName\n**     implemented by C function xFunc that accepts nArg arguments. The\n**     value passed as iArg is cast to a (void*) and made available\n**     as the user-data (sqlite3_user_data()) for the function. If\n**     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.\n**\n**   VFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.\n**\n**   DFUNCTION(zName, nArg, iArg, bNC, xFunc)\n**     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and\n**     adds the SQLITE_FUNC_SLOCHNG flag.  Used for date & time functions\n**     and functions like sqlite_version() that can change, but not during\n**     a single query.  The iArg is ignored.  The user-data is always set\n**     to a NULL pointer.  The bNC parameter is not used.\n**\n**   PURE_DATE(zName, nArg, iArg, bNC, xFunc)\n**     Used for \"pure\" date/time functions, this macro is like DFUNCTION\n**     except that it does set the SQLITE_FUNC_CONSTANT flags.  iArg is\n**     ignored and the user-data for these functions is set to an \n**     arbitrary non-NULL pointer.  The bNC parameter is not used.\n**\n**   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)\n**     Used to create an aggregate function definition implemented by\n**     the C functions xStep and xFinal. The first four parameters\n**     are interpreted in the same way as the first 4 parameters to\n**     FUNCTION().\n**\n**   LIKEFUNC(zName, nArg, pArg, flags)\n**     Used to create a scalar function definition of a function zName\n**     that accepts nArg arguments and is implemented by a call to C\n**     function likeFunc. Argument pArg is cast to a (void *) and made\n**     available as the function user-data (sqlite3_user_data()). The\n**     FuncDef.flags variable is set to the value passed as the flags\n**     parameter.\n*/\n#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \\\n   0, 0, xFunc, 0, #zName, {0} }\n#define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \\\n   (void*)&sqlite3Config, 0, xFunc, 0, #zName, {0} }\n#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \\\n  {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\\\n   SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, #zName, {0} }\n#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \\\n  {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \\\n   pArg, 0, xFunc, 0, #zName, }\n#define LIKEFUNC(zName, nArg, arg, flags) \\\n  {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \\\n   (void *)arg, 0, likeFunc, 0, #zName, {0} }\n#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}\n#define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \\\n  {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \\\n   SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,#zName, {0}}\n\n/*\n** All current savepoints are stored in a linked list starting at\n** sqlite3.pSavepoint. The first element in the list is the most recently\n** opened savepoint. Savepoints are added to the list by the vdbe\n** OP_Savepoint instruction.\n*/\nstruct Savepoint {\n  char *zName;                        /* Savepoint name (nul-terminated) */\n  i64 nDeferredCons;                  /* Number of deferred fk violations */\n  i64 nDeferredImmCons;               /* Number of deferred imm fk. */\n  Savepoint *pNext;                   /* Parent savepoint (if any) */\n};\n\n/*\n** The following are used as the second parameter to sqlite3Savepoint(),\n** and as the P1 argument to the OP_Savepoint instruction.\n*/\n#define SAVEPOINT_BEGIN      0\n#define SAVEPOINT_RELEASE    1\n#define SAVEPOINT_ROLLBACK   2\n\n\n/*\n** Each SQLite module (virtual table definition) is defined by an\n** instance of the following structure, stored in the sqlite3.aModule\n** hash table.\n*/\nstruct Module {\n  const sqlite3_module *pModule;       /* Callback pointers */\n  const char *zName;                   /* Name passed to create_module() */\n  void *pAux;                          /* pAux passed to create_module() */\n  void (*xDestroy)(void *);            /* Module destructor function */\n  Table *pEpoTab;                      /* Eponymous table for this module */\n};\n\n/*\n** information about each column of an SQL table is held in an instance\n** of this structure.\n*/\nstruct Column {\n  char *zName;     /* Name of this column, \\000, then the type */\n  Expr *pDflt;     /* Default value of this column */\n  char *zColl;     /* Collating sequence.  If NULL, use the default */\n  u8 notNull;      /* An OE_ code for handling a NOT NULL constraint */\n  char affinity;   /* One of the SQLITE_AFF_... values */\n  u8 szEst;        /* Estimated size of value in this column. sizeof(INT)==1 */\n  u8 colFlags;     /* Boolean properties.  See COLFLAG_ defines below */\n};\n\n/* Allowed values for Column.colFlags:\n*/\n#define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */\n#define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */\n#define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */\n\n/*\n** A \"Collating Sequence\" is defined by an instance of the following\n** structure. Conceptually, a collating sequence consists of a name and\n** a comparison routine that defines the order of that sequence.\n**\n** If CollSeq.xCmp is NULL, it means that the\n** collating sequence is undefined.  Indices built on an undefined\n** collating sequence may not be read or written.\n*/\nstruct CollSeq {\n  char *zName;          /* Name of the collating sequence, UTF-8 encoded */\n  u8 enc;               /* Text encoding handled by xCmp() */\n  void *pUser;          /* First argument to xCmp() */\n  int (*xCmp)(void*,int, const void*, int, const void*);\n  void (*xDel)(void*);  /* Destructor for pUser */\n};\n\n/*\n** A sort order can be either ASC or DESC.\n*/\n#define SQLITE_SO_ASC       0  /* Sort in ascending order */\n#define SQLITE_SO_DESC      1  /* Sort in ascending order */\n#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */\n\n/*\n** Column affinity types.\n**\n** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and\n** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve\n** the speed a little by numbering the values consecutively.\n**\n** But rather than start with 0 or 1, we begin with 'A'.  That way,\n** when multiple affinity types are concatenated into a string and\n** used as the P4 operand, they will be more readable.\n**\n** Note also that the numeric types are grouped together so that testing\n** for a numeric type is a single comparison.  And the BLOB type is first.\n*/\n#define SQLITE_AFF_BLOB     'A'\n#define SQLITE_AFF_TEXT     'B'\n#define SQLITE_AFF_NUMERIC  'C'\n#define SQLITE_AFF_INTEGER  'D'\n#define SQLITE_AFF_REAL     'E'\n\n#define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)\n\n/*\n** The SQLITE_AFF_MASK values masks off the significant bits of an\n** affinity value.\n*/\n#define SQLITE_AFF_MASK     0x47\n\n/*\n** Additional bit values that can be ORed with an affinity without\n** changing the affinity.\n**\n** The SQLITE_NOTNULL flag is a combination of NULLEQ and JUMPIFNULL.\n** It causes an assert() to fire if either operand to a comparison\n** operator is NULL.  It is added to certain comparison operators to\n** prove that the operands are always NOT NULL.\n*/\n#define SQLITE_KEEPNULL     0x08  /* Used by vector == or <> */\n#define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */\n#define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */\n#define SQLITE_NULLEQ       0x80  /* NULL=NULL */\n#define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */\n\n/*\n** An object of this type is created for each virtual table present in\n** the database schema.\n**\n** If the database schema is shared, then there is one instance of this\n** structure for each database connection (sqlite3*) that uses the shared\n** schema. This is because each database connection requires its own unique\n** instance of the sqlite3_vtab* handle used to access the virtual table\n** implementation. sqlite3_vtab* handles can not be shared between\n** database connections, even when the rest of the in-memory database\n** schema is shared, as the implementation often stores the database\n** connection handle passed to it via the xConnect() or xCreate() method\n** during initialization internally. This database connection handle may\n** then be used by the virtual table implementation to access real tables\n** within the database. So that they appear as part of the callers\n** transaction, these accesses need to be made via the same database\n** connection as that used to execute SQL operations on the virtual table.\n**\n** All VTable objects that correspond to a single table in a shared\n** database schema are initially stored in a linked-list pointed to by\n** the Table.pVTable member variable of the corresponding Table object.\n** When an sqlite3_prepare() operation is required to access the virtual\n** table, it searches the list for the VTable that corresponds to the\n** database connection doing the preparing so as to use the correct\n** sqlite3_vtab* handle in the compiled query.\n**\n** When an in-memory Table object is deleted (for example when the\n** schema is being reloaded for some reason), the VTable objects are not\n** deleted and the sqlite3_vtab* handles are not xDisconnect()ed\n** immediately. Instead, they are moved from the Table.pVTable list to\n** another linked list headed by the sqlite3.pDisconnect member of the\n** corresponding sqlite3 structure. They are then deleted/xDisconnected\n** next time a statement is prepared using said sqlite3*. This is done\n** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.\n** Refer to comments above function sqlite3VtabUnlockList() for an\n** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect\n** list without holding the corresponding sqlite3.mutex mutex.\n**\n** The memory for objects of this type is always allocated by\n** sqlite3DbMalloc(), using the connection handle stored in VTable.db as\n** the first argument.\n*/\nstruct VTable {\n  sqlite3 *db;              /* Database connection associated with this table */\n  Module *pMod;             /* Pointer to module implementation */\n  sqlite3_vtab *pVtab;      /* Pointer to vtab instance */\n  int nRef;                 /* Number of pointers to this structure */\n  u8 bConstraint;           /* True if constraints are supported */\n  int iSavepoint;           /* Depth of the SAVEPOINT stack */\n  VTable *pNext;            /* Next in linked list (see above) */\n};\n\n/*\n** The schema for each SQL table and view is represented in memory\n** by an instance of the following structure.\n*/\nstruct Table {\n  char *zName;         /* Name of the table or view */\n  Column *aCol;        /* Information about each column */\n  Index *pIndex;       /* List of SQL indexes on this table. */\n  Select *pSelect;     /* NULL for tables.  Points to definition if a view. */\n  FKey *pFKey;         /* Linked list of all foreign keys in this table */\n  char *zColAff;       /* String defining the affinity of each column */\n  ExprList *pCheck;    /* All CHECK constraints */\n                       /*   ... also used as column name list in a VIEW */\n  int tnum;            /* Root BTree page for this table */\n  u32 nTabRef;         /* Number of pointers to this Table */\n  u32 tabFlags;        /* Mask of TF_* values */\n  i16 iPKey;           /* If not negative, use aCol[iPKey] as the rowid */\n  i16 nCol;            /* Number of columns in this table */\n  LogEst nRowLogEst;   /* Estimated rows in table - from sqlite_stat1 table */\n  LogEst szTabRow;     /* Estimated size of each table row in bytes */\n#ifdef SQLITE_ENABLE_COSTMULT\n  LogEst costMult;     /* Cost multiplier for using this table */\n#endif\n  u8 keyConf;          /* What to do in case of uniqueness conflict on iPKey */\n#ifndef SQLITE_OMIT_ALTERTABLE\n  int addColOffset;    /* Offset in CREATE TABLE stmt to add a new column */\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  int nModuleArg;      /* Number of arguments to the module */\n  char **azModuleArg;  /* 0: module 1: schema 2: vtab name 3...: args */\n  VTable *pVTable;     /* List of VTable objects. */\n#endif\n  Trigger *pTrigger;   /* List of triggers stored in pSchema */\n  Schema *pSchema;     /* Schema that contains this table */\n  Table *pNextZombie;  /* Next on the Parse.pZombieTab list */\n};\n\n/*\n** Allowed values for Table.tabFlags.\n**\n** TF_OOOHidden applies to tables or view that have hidden columns that are\n** followed by non-hidden columns.  Example:  \"CREATE VIRTUAL TABLE x USING\n** vtab1(a HIDDEN, b);\".  Since \"b\" is a non-hidden column but \"a\" is hidden,\n** the TF_OOOHidden attribute would apply in this case.  Such tables require\n** special handling during INSERT processing.\n*/\n#define TF_Readonly        0x0001    /* Read-only system table */\n#define TF_Ephemeral       0x0002    /* An ephemeral table */\n#define TF_HasPrimaryKey   0x0004    /* Table has a primary key */\n#define TF_Autoincrement   0x0008    /* Integer primary key is autoincrement */\n#define TF_HasStat1        0x0010    /* nRowLogEst set from sqlite_stat1 */\n#define TF_WithoutRowid    0x0020    /* No rowid.  PRIMARY KEY is the key */\n#define TF_NoVisibleRowid  0x0040    /* No user-visible \"rowid\" column */\n#define TF_OOOHidden       0x0080    /* Out-of-Order hidden columns */\n#define TF_StatsUsed       0x0100    /* Query planner decisions affected by\n                                     ** Index.aiRowLogEst[] values */\n#define TF_HasNotNull      0x0200    /* Contains NOT NULL constraints */\n\n/*\n** Test to see whether or not a table is a virtual table.  This is\n** done as a macro so that it will be optimized out when virtual\n** table support is omitted from the build.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n#  define IsVirtual(X)      ((X)->nModuleArg)\n#else\n#  define IsVirtual(X)      0\n#endif\n\n/*\n** Macros to determine if a column is hidden.  IsOrdinaryHiddenColumn()\n** only works for non-virtual tables (ordinary tables and views) and is\n** always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined.  The\n** IsHiddenColumn() macro is general purpose.\n*/\n#if defined(SQLITE_ENABLE_HIDDEN_COLUMNS)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#elif !defined(SQLITE_OMIT_VIRTUALTABLE)\n#  define IsHiddenColumn(X)         (((X)->colFlags & COLFLAG_HIDDEN)!=0)\n#  define IsOrdinaryHiddenColumn(X) 0\n#else\n#  define IsHiddenColumn(X)         0\n#  define IsOrdinaryHiddenColumn(X) 0\n#endif\n\n\n/* Does the table have a rowid */\n#define HasRowid(X)     (((X)->tabFlags & TF_WithoutRowid)==0)\n#define VisibleRowid(X) (((X)->tabFlags & TF_NoVisibleRowid)==0)\n\n/*\n** Each foreign key constraint is an instance of the following structure.\n**\n** A foreign key is associated with two tables.  The \"from\" table is\n** the table that contains the REFERENCES clause that creates the foreign\n** key.  The \"to\" table is the table that is named in the REFERENCES clause.\n** Consider this example:\n**\n**     CREATE TABLE ex1(\n**       a INTEGER PRIMARY KEY,\n**       b INTEGER CONSTRAINT fk1 REFERENCES ex2(x)\n**     );\n**\n** For foreign key \"fk1\", the from-table is \"ex1\" and the to-table is \"ex2\".\n** Equivalent names:\n**\n**     from-table == child-table\n**       to-table == parent-table\n**\n** Each REFERENCES clause generates an instance of the following structure\n** which is attached to the from-table.  The to-table need not exist when\n** the from-table is created.  The existence of the to-table is not checked.\n**\n** The list of all parents for child Table X is held at X.pFKey.\n**\n** A list of all children for a table named Z (which might not even exist)\n** is held in Schema.fkeyHash with a hash key of Z.\n*/\nstruct FKey {\n  Table *pFrom;     /* Table containing the REFERENCES clause (aka: Child) */\n  FKey *pNextFrom;  /* Next FKey with the same in pFrom. Next parent of pFrom */\n  char *zTo;        /* Name of table that the key points to (aka: Parent) */\n  FKey *pNextTo;    /* Next with the same zTo. Next child of zTo. */\n  FKey *pPrevTo;    /* Previous with the same zTo */\n  int nCol;         /* Number of columns in this key */\n  /* EV: R-30323-21917 */\n  u8 isDeferred;       /* True if constraint checking is deferred till COMMIT */\n  u8 aAction[2];        /* ON DELETE and ON UPDATE actions, respectively */\n  Trigger *apTrigger[2];/* Triggers for aAction[] actions */\n  struct sColMap {      /* Mapping of columns in pFrom to columns in zTo */\n    int iFrom;            /* Index of column in pFrom */\n    char *zCol;           /* Name of column in zTo.  If NULL use PRIMARY KEY */\n  } aCol[1];            /* One entry for each of nCol columns */\n};\n\n/*\n** SQLite supports many different ways to resolve a constraint\n** error.  ROLLBACK processing means that a constraint violation\n** causes the operation in process to fail and for the current transaction\n** to be rolled back.  ABORT processing means the operation in process\n** fails and any prior changes from that one operation are backed out,\n** but the transaction is not rolled back.  FAIL processing means that\n** the operation in progress stops and returns an error code.  But prior\n** changes due to the same operation are not backed out and no rollback\n** occurs.  IGNORE means that the particular row that caused the constraint\n** error is not inserted or updated.  Processing continues and no error\n** is returned.  REPLACE means that preexisting database rows that caused\n** a UNIQUE constraint violation are removed so that the new insert or\n** update can proceed.  Processing continues and no error is reported.\n**\n** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.\n** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the\n** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign\n** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the\n** referenced table row is propagated into the row that holds the\n** foreign key.\n**\n** The following symbolic values are used to record which type\n** of action to take.\n*/\n#define OE_None     0   /* There is no constraint to check */\n#define OE_Rollback 1   /* Fail the operation and rollback the transaction */\n#define OE_Abort    2   /* Back out changes but do no rollback transaction */\n#define OE_Fail     3   /* Stop the operation but leave all prior changes */\n#define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */\n#define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */\n\n#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */\n#define OE_SetNull  7   /* Set the foreign key value to NULL */\n#define OE_SetDflt  8   /* Set the foreign key value to its default */\n#define OE_Cascade  9   /* Cascade the changes */\n\n#define OE_Default  10  /* Do whatever the default action is */\n\n\n/*\n** An instance of the following structure is passed as the first\n** argument to sqlite3VdbeKeyCompare and is used to control the\n** comparison of the two index keys.\n**\n** Note that aSortOrder[] and aColl[] have nField+1 slots.  There\n** are nField slots for the columns of an index then one extra slot\n** for the rowid at the end.\n*/\nstruct KeyInfo {\n  u32 nRef;           /* Number of references to this KeyInfo object */\n  u8 enc;             /* Text encoding - one of the SQLITE_UTF* values */\n  u16 nKeyField;      /* Number of key columns in the index */\n  u16 nAllField;      /* Total columns, including key plus others */\n  sqlite3 *db;        /* The database connection */\n  u8 *aSortOrder;     /* Sort order for each column. */\n  CollSeq *aColl[1];  /* Collating sequence for each term of the key */\n};\n\n/*\n** This object holds a record which has been parsed out into individual\n** fields, for the purposes of doing a comparison.\n**\n** A record is an object that contains one or more fields of data.\n** Records are used to store the content of a table row and to store\n** the key of an index.  A blob encoding of a record is created by\n** the OP_MakeRecord opcode of the VDBE and is disassembled by the\n** OP_Column opcode.\n**\n** An instance of this object serves as a \"key\" for doing a search on\n** an index b+tree. The goal of the search is to find the entry that\n** is closed to the key described by this object.  This object might hold\n** just a prefix of the key.  The number of fields is given by\n** pKeyInfo->nField.\n**\n** The r1 and r2 fields are the values to return if this key is less than\n** or greater than a key in the btree, respectively.  These are normally\n** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree\n** is in DESC order.\n**\n** The key comparison functions actually return default_rc when they find\n** an equals comparison.  default_rc can be -1, 0, or +1.  If there are\n** multiple entries in the b-tree with the same key (when only looking\n** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to\n** cause the search to find the last match, or +1 to cause the search to\n** find the first match.\n**\n** The key comparison functions will set eqSeen to true if they ever\n** get and equal results when comparing this structure to a b-tree record.\n** When default_rc!=0, the search might end up on the record immediately\n** before the first match or immediately after the last match.  The\n** eqSeen field will indicate whether or not an exact match exists in the\n** b-tree.\n*/\nstruct UnpackedRecord {\n  KeyInfo *pKeyInfo;  /* Collation and sort-order information */\n  Mem *aMem;          /* Values */\n  u16 nField;         /* Number of entries in apMem[] */\n  i8 default_rc;      /* Comparison result if keys are equal */\n  u8 errCode;         /* Error detected by xRecordCompare (CORRUPT or NOMEM) */\n  i8 r1;              /* Value to return if (lhs < rhs) */\n  i8 r2;              /* Value to return if (lhs > rhs) */\n  u8 eqSeen;          /* True if an equality comparison has been seen */\n};\n\n\n/*\n** Each SQL index is represented in memory by an\n** instance of the following structure.\n**\n** The columns of the table that are to be indexed are described\n** by the aiColumn[] field of this structure.  For example, suppose\n** we have the following table and index:\n**\n**     CREATE TABLE Ex1(c1 int, c2 int, c3 text);\n**     CREATE INDEX Ex2 ON Ex1(c3,c1);\n**\n** In the Table structure describing Ex1, nCol==3 because there are\n** three columns in the table.  In the Index structure describing\n** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.\n** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the\n** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].\n** The second column to be indexed (c1) has an index of 0 in\n** Ex1.aCol[], hence Ex2.aiColumn[1]==0.\n**\n** The Index.onError field determines whether or not the indexed columns\n** must be unique and what to do if they are not.  When Index.onError=OE_None,\n** it means this is not a unique index.  Otherwise it is a unique index\n** and the value of Index.onError indicate the which conflict resolution\n** algorithm to employ whenever an attempt is made to insert a non-unique\n** element.\n**\n** While parsing a CREATE TABLE or CREATE INDEX statement in order to\n** generate VDBE code (as opposed to parsing one read from an sqlite_master\n** table as part of parsing an existing database schema), transient instances\n** of this structure may be created. In this case the Index.tnum variable is\n** used to store the address of a VDBE instruction, not a database page\n** number (it cannot - the database page is not allocated until the VDBE\n** program is executed). See convertToWithoutRowidTable() for details.\n*/\nstruct Index {\n  char *zName;             /* Name of this index */\n  i16 *aiColumn;           /* Which columns are used by this index.  1st is 0 */\n  LogEst *aiRowLogEst;     /* From ANALYZE: Est. rows selected by each column */\n  Table *pTable;           /* The SQL table being indexed */\n  char *zColAff;           /* String defining the affinity of each column */\n  Index *pNext;            /* The next index associated with the same table */\n  Schema *pSchema;         /* Schema containing this index */\n  u8 *aSortOrder;          /* for each column: True==DESC, False==ASC */\n  const char **azColl;     /* Array of collation sequence names for index */\n  Expr *pPartIdxWhere;     /* WHERE clause for partial indices */\n  ExprList *aColExpr;      /* Column expressions */\n  int tnum;                /* DB Page containing root of this index */\n  LogEst szIdxRow;         /* Estimated average row size in bytes */\n  u16 nKeyCol;             /* Number of columns forming the key */\n  u16 nColumn;             /* Number of columns stored in the index */\n  u8 onError;              /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */\n  unsigned idxType:2;      /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */\n  unsigned bUnordered:1;   /* Use this index for == or IN queries only */\n  unsigned uniqNotNull:1;  /* True if UNIQUE and NOT NULL for all columns */\n  unsigned isResized:1;    /* True if resizeIndexObject() has been called */\n  unsigned isCovering:1;   /* True if this is a covering index */\n  unsigned noSkipScan:1;   /* Do not try to use skip-scan if true */\n  unsigned hasStat1:1;     /* aiRowLogEst values come from sqlite_stat1 */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  int nSample;             /* Number of elements in aSample[] */\n  int nSampleCol;          /* Size of IndexSample.anEq[] and so on */\n  tRowcnt *aAvgEq;         /* Average nEq values for keys not in aSample */\n  IndexSample *aSample;    /* Samples of the left-most key */\n  tRowcnt *aiRowEst;       /* Non-logarithmic stat1 data for this index */\n  tRowcnt nRowEst0;        /* Non-logarithmic number of rows in the index */\n#endif\n};\n\n/*\n** Allowed values for Index.idxType\n*/\n#define SQLITE_IDXTYPE_APPDEF      0   /* Created using CREATE INDEX */\n#define SQLITE_IDXTYPE_UNIQUE      1   /* Implements a UNIQUE constraint */\n#define SQLITE_IDXTYPE_PRIMARYKEY  2   /* Is the PRIMARY KEY for the table */\n\n/* Return true if index X is a PRIMARY KEY index */\n#define IsPrimaryKeyIndex(X)  ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)\n\n/* Return true if index X is a UNIQUE index */\n#define IsUniqueIndex(X)      ((X)->onError!=OE_None)\n\n/* The Index.aiColumn[] values are normally positive integer.  But\n** there are some negative values that have special meaning:\n*/\n#define XN_ROWID     (-1)     /* Indexed column is the rowid */\n#define XN_EXPR      (-2)     /* Indexed column is an expression */\n\n/*\n** Each sample stored in the sqlite_stat3 table is represented in memory\n** using a structure of this type.  See documentation at the top of the\n** analyze.c source file for additional information.\n*/\nstruct IndexSample {\n  void *p;          /* Pointer to sampled record */\n  int n;            /* Size of record in bytes */\n  tRowcnt *anEq;    /* Est. number of rows where the key equals this sample */\n  tRowcnt *anLt;    /* Est. number of rows where key is less than this sample */\n  tRowcnt *anDLt;   /* Est. number of distinct keys less than this sample */\n};\n\n/*\n** Each token coming out of the lexer is an instance of\n** this structure.  Tokens are also used as part of an expression.\n**\n** Note if Token.z==0 then Token.dyn and Token.n are undefined and\n** may contain random values.  Do not make any assumptions about Token.dyn\n** and Token.n when Token.z==0.\n*/\nstruct Token {\n  const char *z;     /* Text of the token.  Not NULL-terminated! */\n  unsigned int n;    /* Number of characters in this token */\n};\n\n/*\n** An instance of this structure contains information needed to generate\n** code for a SELECT that contains aggregate functions.\n**\n** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a\n** pointer to this structure.  The Expr.iColumn field is the index in\n** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate\n** code for that node.\n**\n** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the\n** original Select structure that describes the SELECT statement.  These\n** fields do not need to be freed when deallocating the AggInfo structure.\n*/\nstruct AggInfo {\n  u8 directMode;          /* Direct rendering mode means take data directly\n                          ** from source tables rather than from accumulators */\n  u8 useSortingIdx;       /* In direct mode, reference the sorting index rather\n                          ** than the source table */\n  int sortingIdx;         /* Cursor number of the sorting index */\n  int sortingIdxPTab;     /* Cursor number of pseudo-table */\n  int nSortingColumn;     /* Number of columns in the sorting index */\n  int mnReg, mxReg;       /* Range of registers allocated for aCol and aFunc */\n  ExprList *pGroupBy;     /* The group by clause */\n  struct AggInfo_col {    /* For each column used in source tables */\n    Table *pTab;             /* Source table */\n    int iTable;              /* Cursor number of the source table */\n    int iColumn;             /* Column number within the source table */\n    int iSorterColumn;       /* Column number in the sorting index */\n    int iMem;                /* Memory location that acts as accumulator */\n    Expr *pExpr;             /* The original expression */\n  } *aCol;\n  int nColumn;            /* Number of used entries in aCol[] */\n  int nAccumulator;       /* Number of columns that show through to the output.\n                          ** Additional columns are used only as parameters to\n                          ** aggregate functions */\n  struct AggInfo_func {   /* For each aggregate function */\n    Expr *pExpr;             /* Expression encoding the function */\n    FuncDef *pFunc;          /* The aggregate function implementation */\n    int iMem;                /* Memory location that acts as accumulator */\n    int iDistinct;           /* Ephemeral table used to enforce DISTINCT */\n  } *aFunc;\n  int nFunc;              /* Number of entries in aFunc[] */\n};\n\n/*\n** The datatype ynVar is a signed integer, either 16-bit or 32-bit.\n** Usually it is 16-bits.  But if SQLITE_MAX_VARIABLE_NUMBER is greater\n** than 32767 we have to make it 32-bit.  16-bit is preferred because\n** it uses less memory in the Expr object, which is a big memory user\n** in systems with lots of prepared statements.  And few applications\n** need more than about 10 or 20 variables.  But some extreme users want\n** to have prepared statements with over 32767 variables, and for them\n** the option is available (at compile-time).\n*/\n#if SQLITE_MAX_VARIABLE_NUMBER<=32767\ntypedef i16 ynVar;\n#else\ntypedef int ynVar;\n#endif\n\n/*\n** Each node of an expression in the parse tree is an instance\n** of this structure.\n**\n** Expr.op is the opcode. The integer parser token codes are reused\n** as opcodes here. For example, the parser defines TK_GE to be an integer\n** code representing the \">=\" operator. This same integer code is reused\n** to represent the greater-than-or-equal-to operator in the expression\n** tree.\n**\n** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,\n** or TK_STRING), then Expr.token contains the text of the SQL literal. If\n** the expression is a variable (TK_VARIABLE), then Expr.token contains the\n** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),\n** then Expr.token contains the name of the function.\n**\n** Expr.pRight and Expr.pLeft are the left and right subexpressions of a\n** binary operator. Either or both may be NULL.\n**\n** Expr.x.pList is a list of arguments if the expression is an SQL function,\n** a CASE expression or an IN expression of the form \"<lhs> IN (<y>, <z>...)\".\n** Expr.x.pSelect is used if the expression is a sub-select or an expression of\n** the form \"<lhs> IN (SELECT ...)\". If the EP_xIsSelect bit is set in the\n** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is\n** valid.\n**\n** An expression of the form ID or ID.ID refers to a column in a table.\n** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is\n** the integer cursor number of a VDBE cursor pointing to that table and\n** Expr.iColumn is the column number for the specific column.  If the\n** expression is used as a result in an aggregate SELECT, then the\n** value is also stored in the Expr.iAgg column in the aggregate so that\n** it can be accessed after all aggregates are computed.\n**\n** If the expression is an unbound variable marker (a question mark\n** character '?' in the original SQL) then the Expr.iTable holds the index\n** number for that variable.\n**\n** If the expression is a subquery then Expr.iColumn holds an integer\n** register number containing the result of the subquery.  If the\n** subquery gives a constant result, then iTable is -1.  If the subquery\n** gives a different answer at different times during statement processing\n** then iTable is the address of a subroutine that computes the subquery.\n**\n** If the Expr is of type OP_Column, and the table it is selecting from\n** is a disk table or the \"old.*\" pseudo-table, then pTab points to the\n** corresponding table definition.\n**\n** ALLOCATION NOTES:\n**\n** Expr objects can use a lot of memory space in database schema.  To\n** help reduce memory requirements, sometimes an Expr object will be\n** truncated.  And to reduce the number of memory allocations, sometimes\n** two or more Expr objects will be stored in a single memory allocation,\n** together with Expr.zToken strings.\n**\n** If the EP_Reduced and EP_TokenOnly flags are set when\n** an Expr object is truncated.  When EP_Reduced is set, then all\n** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees\n** are contained within the same memory allocation.  Note, however, that\n** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately\n** allocated, regardless of whether or not EP_Reduced is set.\n*/\nstruct Expr {\n  u8 op;                 /* Operation performed by this node */\n  char affinity;         /* The affinity of the column or 0 if not a column */\n  u32 flags;             /* Various flags.  EP_* See below */\n  union {\n    char *zToken;          /* Token value. Zero terminated and dequoted */\n    int iValue;            /* Non-negative integer value if EP_IntValue */\n  } u;\n\n  /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n  Expr *pLeft;           /* Left subnode */\n  Expr *pRight;          /* Right subnode */\n  union {\n    ExprList *pList;     /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */\n    Select *pSelect;     /* EP_xIsSelect and op = IN, EXISTS, SELECT */\n  } x;\n\n  /* If the EP_Reduced flag is set in the Expr.flags mask, then no\n  ** space is allocated for the fields below this point. An attempt to\n  ** access them will result in a segfault or malfunction.\n  *********************************************************************/\n\n#if SQLITE_MAX_EXPR_DEPTH>0\n  int nHeight;           /* Height of the tree headed by this node */\n#endif\n  int iTable;            /* TK_COLUMN: cursor number of table holding column\n                         ** TK_REGISTER: register number\n                         ** TK_TRIGGER: 1 -> new, 0 -> old\n                         ** EP_Unlikely:  134217728 times likelihood\n                         ** TK_SELECT: 1st register of result vector */\n  ynVar iColumn;         /* TK_COLUMN: column index.  -1 for rowid.\n                         ** TK_VARIABLE: variable number (always >= 1).\n                         ** TK_SELECT_COLUMN: column of the result vector */\n  i16 iAgg;              /* Which entry in pAggInfo->aCol[] or ->aFunc[] */\n  i16 iRightJoinTable;   /* If EP_FromJoin, the right table of the join */\n  u8 op2;                /* TK_REGISTER: original value of Expr.op\n                         ** TK_COLUMN: the value of p5 for OP_Column\n                         ** TK_AGG_FUNCTION: nesting depth */\n  AggInfo *pAggInfo;     /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */\n  Table *pTab;           /* Table for TK_COLUMN expressions.  Can be NULL\n                         ** for a column of an index on an expression */\n};\n\n/*\n** The following are the meanings of bits in the Expr.flags field.\n*/\n#define EP_FromJoin  0x000001 /* Originates in ON/USING clause of outer join */\n#define EP_Agg       0x000002 /* Contains one or more aggregate functions */\n                  /* 0x000004 // available for use */\n                  /* 0x000008 // available for use */\n#define EP_Distinct  0x000010 /* Aggregate function with DISTINCT keyword */\n#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */\n#define EP_DblQuoted 0x000040 /* token.z was originally in \"...\" */\n#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */\n#define EP_Collate   0x000100 /* Tree contains a TK_COLLATE operator */\n#define EP_Generic   0x000200 /* Ignore COLLATE or affinity on this tree */\n#define EP_IntValue  0x000400 /* Integer value contained in u.iValue */\n#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */\n#define EP_Skip      0x001000 /* COLLATE, AS, or UNLIKELY */\n#define EP_Reduced   0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */\n#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */\n#define EP_Static    0x008000 /* Held in memory not obtained from malloc() */\n#define EP_MemToken  0x010000 /* Need to sqlite3DbFree() Expr.zToken */\n#define EP_NoReduce  0x020000 /* Cannot EXPRDUP_REDUCE this Expr */\n#define EP_Unlikely  0x040000 /* unlikely() or likelihood() function */\n#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */\n#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */\n#define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */\n#define EP_Alias     0x400000 /* Is an alias for a result set column */\n#define EP_Leaf      0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */\n\n/*\n** Combinations of two or more EP_* flags\n*/\n#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */\n\n/*\n** These macros can be used to test, set, or clear bits in the\n** Expr.flags field.\n*/\n#define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)\n#define ExprHasAllProperty(E,P)  (((E)->flags&(P))==(P))\n#define ExprSetProperty(E,P)     (E)->flags|=(P)\n#define ExprClearProperty(E,P)   (E)->flags&=~(P)\n\n/* The ExprSetVVAProperty() macro is used for Verification, Validation,\n** and Accreditation only.  It works like ExprSetProperty() during VVA\n** processes but is a no-op for delivery.\n*/\n#ifdef SQLITE_DEBUG\n# define ExprSetVVAProperty(E,P)  (E)->flags|=(P)\n#else\n# define ExprSetVVAProperty(E,P)\n#endif\n\n/*\n** Macros to determine the number of bytes required by a normal Expr\n** struct, an Expr struct with the EP_Reduced flag set in Expr.flags\n** and an Expr struct with the EP_TokenOnly flag set.\n*/\n#define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */\n#define EXPR_REDUCEDSIZE        offsetof(Expr,iTable)  /* Common features */\n#define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */\n\n/*\n** Flags passed to the sqlite3ExprDup() function. See the header comment\n** above sqlite3ExprDup() for details.\n*/\n#define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */\n\n/*\n** A list of expressions.  Each expression may optionally have a\n** name.  An expr/name combination can be used in several ways, such\n** as the list of \"expr AS ID\" fields following a \"SELECT\" or in the\n** list of \"ID = expr\" items in an UPDATE.  A list of expressions can\n** also be used as the argument to a function, in which case the a.zName\n** field is not used.\n**\n** By default the Expr.zSpan field holds a human-readable description of\n** the expression that is used in the generation of error messages and\n** column labels.  In this case, Expr.zSpan is typically the text of a\n** column expression as it exists in a SELECT statement.  However, if\n** the bSpanIsTab flag is set, then zSpan is overloaded to mean the name\n** of the result column in the form: DATABASE.TABLE.COLUMN.  This later\n** form is used for name resolution with nested FROM clauses.\n*/\nstruct ExprList {\n  int nExpr;             /* Number of expressions on the list */\n  struct ExprList_item { /* For each expression in the list */\n    Expr *pExpr;            /* The parse tree for this expression */\n    char *zName;            /* Token associated with this expression */\n    char *zSpan;            /* Original text of the expression */\n    u8 sortOrder;           /* 1 for DESC or 0 for ASC */\n    unsigned done :1;       /* A flag to indicate when processing is finished */\n    unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */\n    unsigned reusable :1;   /* Constant expression is reusable */\n    union {\n      struct {\n        u16 iOrderByCol;      /* For ORDER BY, column number in result set */\n        u16 iAlias;           /* Index into Parse.aAlias[] for zName */\n      } x;\n      int iConstExprReg;      /* Register in which Expr value is cached */\n    } u;\n  } a[1];                  /* One slot for each expression in the list */\n};\n\n/*\n** An instance of this structure is used by the parser to record both\n** the parse tree for an expression and the span of input text for an\n** expression.\n*/\nstruct ExprSpan {\n  Expr *pExpr;          /* The expression parse tree */\n  const char *zStart;   /* First character of input text */\n  const char *zEnd;     /* One character past the end of input text */\n};\n\n/*\n** An instance of this structure can hold a simple list of identifiers,\n** such as the list \"a,b,c\" in the following statements:\n**\n**      INSERT INTO t(a,b,c) VALUES ...;\n**      CREATE INDEX idx ON t(a,b,c);\n**      CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...;\n**\n** The IdList.a.idx field is used when the IdList represents the list of\n** column names after a table name in an INSERT statement.  In the statement\n**\n**     INSERT INTO t(a,b,c) ...\n**\n** If \"a\" is the k-th column of table \"t\", then IdList.a[0].idx==k.\n*/\nstruct IdList {\n  struct IdList_item {\n    char *zName;      /* Name of the identifier */\n    int idx;          /* Index in some Table.aCol[] of a column named zName */\n  } *a;\n  int nId;         /* Number of identifiers on the list */\n};\n\n/*\n** The bitmask datatype defined below is used for various optimizations.\n**\n** Changing this from a 64-bit to a 32-bit type limits the number of\n** tables in a join to 32 instead of 64.  But it also reduces the size\n** of the library by 738 bytes on ix86.\n*/\n#ifdef SQLITE_BITMASK_TYPE\n  typedef SQLITE_BITMASK_TYPE Bitmask;\n#else\n  typedef u64 Bitmask;\n#endif\n\n/*\n** The number of bits in a Bitmask.  \"BMS\" means \"BitMask Size\".\n*/\n#define BMS  ((int)(sizeof(Bitmask)*8))\n\n/*\n** A bit in a Bitmask\n*/\n#define MASKBIT(n)   (((Bitmask)1)<<(n))\n#define MASKBIT32(n) (((unsigned int)1)<<(n))\n#define ALLBITS      ((Bitmask)-1)\n\n/*\n** The following structure describes the FROM clause of a SELECT statement.\n** Each table or subquery in the FROM clause is a separate element of\n** the SrcList.a[] array.\n**\n** With the addition of multiple database support, the following structure\n** can also be used to describe a particular table such as the table that\n** is modified by an INSERT, DELETE, or UPDATE statement.  In standard SQL,\n** such a table must be a simple name: ID.  But in SQLite, the table can\n** now be identified by a database name, a dot, then the table name: ID.ID.\n**\n** The jointype starts out showing the join type between the current table\n** and the next table on the list.  The parser builds the list this way.\n** But sqlite3SrcListShiftJoinType() later shifts the jointypes so that each\n** jointype expresses the join between the table and the previous table.\n**\n** In the colUsed field, the high-order bit (bit 63) is set if the table\n** contains more than 63 columns and the 64-th or later column is used.\n*/\nstruct SrcList {\n  int nSrc;        /* Number of tables or subqueries in the FROM clause */\n  u32 nAlloc;      /* Number of entries allocated in a[] below */\n  struct SrcList_item {\n    Schema *pSchema;  /* Schema to which this item is fixed */\n    char *zDatabase;  /* Name of database holding this table */\n    char *zName;      /* Name of the table */\n    char *zAlias;     /* The \"B\" part of a \"A AS B\" phrase.  zName is the \"A\" */\n    Table *pTab;      /* An SQL table corresponding to zName */\n    Select *pSelect;  /* A SELECT statement used in place of a table name */\n    int addrFillSub;  /* Address of subroutine to manifest a subquery */\n    int regReturn;    /* Register holding return address of addrFillSub */\n    int regResult;    /* Registers holding results of a co-routine */\n    struct {\n      u8 jointype;      /* Type of join between this table and the previous */\n      unsigned notIndexed :1;    /* True if there is a NOT INDEXED clause */\n      unsigned isIndexedBy :1;   /* True if there is an INDEXED BY clause */\n      unsigned isTabFunc :1;     /* True if table-valued-function syntax */\n      unsigned isCorrelated :1;  /* True if sub-query is correlated */\n      unsigned viaCoroutine :1;  /* Implemented as a co-routine */\n      unsigned isRecursive :1;   /* True for recursive reference in WITH */\n    } fg;\n#ifndef SQLITE_OMIT_EXPLAIN\n    u8 iSelectId;     /* If pSelect!=0, the id of the sub-select in EQP */\n#endif\n    int iCursor;      /* The VDBE cursor number used to access this table */\n    Expr *pOn;        /* The ON clause of a join */\n    IdList *pUsing;   /* The USING clause of a join */\n    Bitmask colUsed;  /* Bit N (1<<N) set if column N of pTab is used */\n    union {\n      char *zIndexedBy;    /* Identifier from \"INDEXED BY <zIndex>\" clause */\n      ExprList *pFuncArg;  /* Arguments to table-valued-function */\n    } u1;\n    Index *pIBIndex;  /* Index structure corresponding to u1.zIndexedBy */\n  } a[1];             /* One entry for each identifier on the list */\n};\n\n/*\n** Permitted values of the SrcList.a.jointype field\n*/\n#define JT_INNER     0x0001    /* Any kind of inner or cross join */\n#define JT_CROSS     0x0002    /* Explicit use of the CROSS keyword */\n#define JT_NATURAL   0x0004    /* True for a \"natural\" join */\n#define JT_LEFT      0x0008    /* Left outer join */\n#define JT_RIGHT     0x0010    /* Right outer join */\n#define JT_OUTER     0x0020    /* The \"OUTER\" keyword is present */\n#define JT_ERROR     0x0040    /* unknown or unsupported join type */\n\n\n/*\n** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()\n** and the WhereInfo.wctrlFlags member.\n**\n** Value constraints (enforced via assert()):\n**     WHERE_USE_LIMIT  == SF_FixedLimit\n*/\n#define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */\n#define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */\n#define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */\n#define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */\n#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */\n#define WHERE_DUPLICATES_OK    0x0010 /* Ok to return a row more than once */\n#define WHERE_OR_SUBCLAUSE     0x0020 /* Processing a sub-WHERE as part of\n                                      ** the OR optimization  */\n#define WHERE_GROUPBY          0x0040 /* pOrderBy is really a GROUP BY */\n#define WHERE_DISTINCTBY       0x0080 /* pOrderby is really a DISTINCT clause */\n#define WHERE_WANT_DISTINCT    0x0100 /* All output needs to be distinct */\n#define WHERE_SORTBYGROUP      0x0200 /* Support sqlite3WhereIsSorted() */\n#define WHERE_SEEK_TABLE       0x0400 /* Do not defer seeks on main table */\n#define WHERE_ORDERBY_LIMIT    0x0800 /* ORDERBY+LIMIT on the inner loop */\n#define WHERE_SEEK_UNIQ_TABLE  0x1000 /* Do not defer seeks if unique */\n                        /*     0x2000    not currently used */\n#define WHERE_USE_LIMIT        0x4000 /* Use the LIMIT in cost estimates */\n                        /*     0x8000    not currently used */\n\n/* Allowed return values from sqlite3WhereIsDistinct()\n*/\n#define WHERE_DISTINCT_NOOP      0  /* DISTINCT keyword not used */\n#define WHERE_DISTINCT_UNIQUE    1  /* No duplicates */\n#define WHERE_DISTINCT_ORDERED   2  /* All duplicates are adjacent */\n#define WHERE_DISTINCT_UNORDERED 3  /* Duplicates are scattered */\n\n/*\n** A NameContext defines a context in which to resolve table and column\n** names.  The context consists of a list of tables (the pSrcList) field and\n** a list of named expression (pEList).  The named expression list may\n** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or\n** to the table being operated on by INSERT, UPDATE, or DELETE.  The\n** pEList corresponds to the result set of a SELECT and is NULL for\n** other statements.\n**\n** NameContexts can be nested.  When resolving names, the inner-most\n** context is searched first.  If no match is found, the next outer\n** context is checked.  If there is still no match, the next context\n** is checked.  This process continues until either a match is found\n** or all contexts are check.  When a match is found, the nRef member of\n** the context containing the match is incremented.\n**\n** Each subquery gets a new NameContext.  The pNext field points to the\n** NameContext in the parent query.  Thus the process of scanning the\n** NameContext list corresponds to searching through successively outer\n** subqueries looking for a match.\n*/\nstruct NameContext {\n  Parse *pParse;       /* The parser */\n  SrcList *pSrcList;   /* One or more tables used to resolve names */\n  ExprList *pEList;    /* Optional list of result-set columns */\n  AggInfo *pAggInfo;   /* Information about aggregates at this level */\n  NameContext *pNext;  /* Next outer name context.  NULL for outermost */\n  int nRef;            /* Number of names resolved by this context */\n  int nErr;            /* Number of errors encountered while resolving names */\n  u16 ncFlags;         /* Zero or more NC_* flags defined below */\n};\n\n/*\n** Allowed values for the NameContext, ncFlags field.\n**\n** Value constraints (all checked via assert()):\n**    NC_HasAgg    == SF_HasAgg\n**    NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX\n**\n*/\n#define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */\n#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */\n#define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */\n#define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */\n#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */\n#define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */\n#define NC_VarSelect 0x0040  /* A correlated subquery has been seen */\n#define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */\n\n/*\n** An instance of the following structure contains all information\n** needed to generate code for a single SELECT statement.\n**\n** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.\n** If there is a LIMIT clause, the parser sets nLimit to the value of the\n** limit and nOffset to the value of the offset (or 0 if there is not\n** offset).  But later on, nLimit and nOffset become the memory locations\n** in the VDBE that record the limit and offset counters.\n**\n** addrOpenEphm[] entries contain the address of OP_OpenEphemeral opcodes.\n** These addresses must be stored so that we can go back and fill in\n** the P4_KEYINFO and P2 parameters later.  Neither the KeyInfo nor\n** the number of columns in P2 can be computed at the same time\n** as the OP_OpenEphm instruction is coded because not\n** enough information about the compound query is known at that point.\n** The KeyInfo for addrOpenTran[0] and [1] contains collating sequences\n** for the result set.  The KeyInfo for addrOpenEphm[2] contains collating\n** sequences for the ORDER BY clause.\n*/\nstruct Select {\n  ExprList *pEList;      /* The fields of the result */\n  u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */\n  LogEst nSelectRow;     /* Estimated number of result rows */\n  u32 selFlags;          /* Various SF_* values */\n  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */\n#if SELECTTRACE_ENABLED\n  char zSelName[12];     /* Symbolic name of this SELECT use for debugging */\n#endif\n  int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */\n  SrcList *pSrc;         /* The FROM clause */\n  Expr *pWhere;          /* The WHERE clause */\n  ExprList *pGroupBy;    /* The GROUP BY clause */\n  Expr *pHaving;         /* The HAVING clause */\n  ExprList *pOrderBy;    /* The ORDER BY clause */\n  Select *pPrior;        /* Prior select in a compound select statement */\n  Select *pNext;         /* Next select to the left in a compound */\n  Expr *pLimit;          /* LIMIT expression. NULL means not used. */\n  Expr *pOffset;         /* OFFSET expression. NULL means not used. */\n  With *pWith;           /* WITH clause attached to this select. Or NULL. */\n};\n\n/*\n** Allowed values for Select.selFlags.  The \"SF\" prefix stands for\n** \"Select Flag\".\n**\n** Value constraints (all checked via assert())\n**     SF_HasAgg     == NC_HasAgg\n**     SF_MinMaxAgg  == NC_MinMaxAgg     == SQLITE_FUNC_MINMAX\n**     SF_FixedLimit == WHERE_USE_LIMIT\n*/\n#define SF_Distinct       0x00001  /* Output should be DISTINCT */\n#define SF_All            0x00002  /* Includes the ALL keyword */\n#define SF_Resolved       0x00004  /* Identifiers have been resolved */\n#define SF_Aggregate      0x00008  /* Contains agg functions or a GROUP BY */\n#define SF_HasAgg         0x00010  /* Contains aggregate functions */\n#define SF_UsesEphemeral  0x00020  /* Uses the OpenEphemeral opcode */\n#define SF_Expanded       0x00040  /* sqlite3SelectExpand() called on this */\n#define SF_HasTypeInfo    0x00080  /* FROM subqueries have Table metadata */\n#define SF_Compound       0x00100  /* Part of a compound query */\n#define SF_Values         0x00200  /* Synthesized from VALUES clause */\n#define SF_MultiValue     0x00400  /* Single VALUES term with multiple rows */\n#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */\n#define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */\n#define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */\n#define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */\n#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */\n#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */\n#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */\n\n\n/*\n** The results of a SELECT can be distributed in several ways, as defined\n** by one of the following macros.  The \"SRT\" prefix means \"SELECT Result\n** Type\".\n**\n**     SRT_Union       Store results as a key in a temporary index\n**                     identified by pDest->iSDParm.\n**\n**     SRT_Except      Remove results from the temporary index pDest->iSDParm.\n**\n**     SRT_Exists      Store a 1 in memory cell pDest->iSDParm if the result\n**                     set is not empty.\n**\n**     SRT_Discard     Throw the results away.  This is used by SELECT\n**                     statements within triggers whose only purpose is\n**                     the side-effects of functions.\n**\n** All of the above are free to ignore their ORDER BY clause. Those that\n** follow must honor the ORDER BY clause.\n**\n**     SRT_Output      Generate a row of output (using the OP_ResultRow\n**                     opcode) for each row in the result set.\n**\n**     SRT_Mem         Only valid if the result is a single column.\n**                     Store the first column of the first result row\n**                     in register pDest->iSDParm then abandon the rest\n**                     of the query.  This destination implies \"LIMIT 1\".\n**\n**     SRT_Set         The result must be a single column.  Store each\n**                     row of result as the key in table pDest->iSDParm.\n**                     Apply the affinity pDest->affSdst before storing\n**                     results.  Used to implement \"IN (SELECT ...)\".\n**\n**     SRT_EphemTab    Create an temporary table pDest->iSDParm and store\n**                     the result there. The cursor is left open after\n**                     returning.  This is like SRT_Table except that\n**                     this destination uses OP_OpenEphemeral to create\n**                     the table first.\n**\n**     SRT_Coroutine   Generate a co-routine that returns a new row of\n**                     results each time it is invoked.  The entry point\n**                     of the co-routine is stored in register pDest->iSDParm\n**                     and the result row is stored in pDest->nDest registers\n**                     starting with pDest->iSdst.\n**\n**     SRT_Table       Store results in temporary table pDest->iSDParm.\n**     SRT_Fifo        This is like SRT_EphemTab except that the table\n**                     is assumed to already be open.  SRT_Fifo has\n**                     the additional property of being able to ignore\n**                     the ORDER BY clause.\n**\n**     SRT_DistFifo    Store results in a temporary table pDest->iSDParm.\n**                     But also use temporary table pDest->iSDParm+1 as\n**                     a record of all prior results and ignore any duplicate\n**                     rows.  Name means:  \"Distinct Fifo\".\n**\n**     SRT_Queue       Store results in priority queue pDest->iSDParm (really\n**                     an index).  Append a sequence number so that all entries\n**                     are distinct.\n**\n**     SRT_DistQueue   Store results in priority queue pDest->iSDParm only if\n**                     the same record has never been stored before.  The\n**                     index at pDest->iSDParm+1 hold all prior stores.\n*/\n#define SRT_Union        1  /* Store result as keys in an index */\n#define SRT_Except       2  /* Remove result from a UNION index */\n#define SRT_Exists       3  /* Store 1 if the result is not empty */\n#define SRT_Discard      4  /* Do not save the results anywhere */\n#define SRT_Fifo         5  /* Store result as data with an automatic rowid */\n#define SRT_DistFifo     6  /* Like SRT_Fifo, but unique results only */\n#define SRT_Queue        7  /* Store result in an queue */\n#define SRT_DistQueue    8  /* Like SRT_Queue, but unique results only */\n\n/* The ORDER BY clause is ignored for all of the above */\n#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue)\n\n#define SRT_Output       9  /* Output each row of result */\n#define SRT_Mem         10  /* Store result in a memory cell */\n#define SRT_Set         11  /* Store results as keys in an index */\n#define SRT_EphemTab    12  /* Create transient tab and store like SRT_Table */\n#define SRT_Coroutine   13  /* Generate a single row of result */\n#define SRT_Table       14  /* Store result as data with an automatic rowid */\n\n/*\n** An instance of this object describes where to put of the results of\n** a SELECT statement.\n*/\nstruct SelectDest {\n  u8 eDest;            /* How to dispose of the results.  On of SRT_* above. */\n  int iSDParm;         /* A parameter used by the eDest disposal method */\n  int iSdst;           /* Base register where results are written */\n  int nSdst;           /* Number of registers allocated */\n  char *zAffSdst;      /* Affinity used when eDest==SRT_Set */\n  ExprList *pOrderBy;  /* Key columns for SRT_Queue and SRT_DistQueue */\n};\n\n/*\n** During code generation of statements that do inserts into AUTOINCREMENT\n** tables, the following information is attached to the Table.u.autoInc.p\n** pointer of each autoincrement table to record some side information that\n** the code generator needs.  We have to keep per-table autoincrement\n** information in case inserts are done within triggers.  Triggers do not\n** normally coordinate their activities, but we do need to coordinate the\n** loading and saving of autoincrement information.\n*/\nstruct AutoincInfo {\n  AutoincInfo *pNext;   /* Next info block in a list of them all */\n  Table *pTab;          /* Table this info block refers to */\n  int iDb;              /* Index in sqlite3.aDb[] of database holding pTab */\n  int regCtr;           /* Memory register holding the rowid counter */\n};\n\n/*\n** Size of the column cache\n*/\n#ifndef SQLITE_N_COLCACHE\n# define SQLITE_N_COLCACHE 10\n#endif\n\n/*\n** At least one instance of the following structure is created for each\n** trigger that may be fired while parsing an INSERT, UPDATE or DELETE\n** statement. All such objects are stored in the linked list headed at\n** Parse.pTriggerPrg and deleted once statement compilation has been\n** completed.\n**\n** A Vdbe sub-program that implements the body and WHEN clause of trigger\n** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of\n** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.\n** The Parse.pTriggerPrg list never contains two entries with the same\n** values for both pTrigger and orconf.\n**\n** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns\n** accessed (or set to 0 for triggers fired as a result of INSERT\n** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to\n** a mask of new.* columns used by the program.\n*/\nstruct TriggerPrg {\n  Trigger *pTrigger;      /* Trigger this program was coded from */\n  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */\n  SubProgram *pProgram;   /* Program implementing pTrigger/orconf */\n  int orconf;             /* Default ON CONFLICT policy */\n  u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */\n};\n\n/*\n** The yDbMask datatype for the bitmask of all attached databases.\n*/\n#if SQLITE_MAX_ATTACHED>30\n  typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8];\n# define DbMaskTest(M,I)    (((M)[(I)/8]&(1<<((I)&7)))!=0)\n# define DbMaskZero(M)      memset((M),0,sizeof(M))\n# define DbMaskSet(M,I)     (M)[(I)/8]|=(1<<((I)&7))\n# define DbMaskAllZero(M)   sqlite3DbMaskAllZero(M)\n# define DbMaskNonZero(M)   (sqlite3DbMaskAllZero(M)==0)\n#else\n  typedef unsigned int yDbMask;\n# define DbMaskTest(M,I)    (((M)&(((yDbMask)1)<<(I)))!=0)\n# define DbMaskZero(M)      (M)=0\n# define DbMaskSet(M,I)     (M)|=(((yDbMask)1)<<(I))\n# define DbMaskAllZero(M)   (M)==0\n# define DbMaskNonZero(M)   (M)!=0\n#endif\n\n/*\n** An SQL parser context.  A copy of this structure is passed through\n** the parser and down into all the parser action routine in order to\n** carry around information that is global to the entire parse.\n**\n** The structure is divided into two parts.  When the parser and code\n** generate call themselves recursively, the first part of the structure\n** is constant but the second part is reset at the beginning and end of\n** each recursion.\n**\n** The nTableLock and aTableLock variables are only used if the shared-cache\n** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are\n** used to store the set of table-locks required by the statement being\n** compiled. Function sqlite3TableLock() is used to add entries to the\n** list.\n*/\nstruct Parse {\n  sqlite3 *db;         /* The main database structure */\n  char *zErrMsg;       /* An error message */\n  Vdbe *pVdbe;         /* An engine for executing database bytecode */\n  int rc;              /* Return code from execution */\n  u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */\n  u8 checkSchema;      /* Causes schema cookie check after an error */\n  u8 nested;           /* Number of nested calls to the parser/code generator */\n  u8 nTempReg;         /* Number of temporary registers in aTempReg[] */\n  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */\n  u8 mayAbort;         /* True if statement may throw an ABORT exception */\n  u8 hasCompound;      /* Need to invoke convertCompoundSelectToSubquery() */\n  u8 okConstFactor;    /* OK to factor out constants */\n  u8 disableLookaside; /* Number of times lookaside has been disabled */\n  u8 nColCache;        /* Number of entries in aColCache[] */\n  int nRangeReg;       /* Size of the temporary register block */\n  int iRangeReg;       /* First register in temporary register block */\n  int nErr;            /* Number of errors seen */\n  int nTab;            /* Number of previously allocated VDBE cursors */\n  int nMem;            /* Number of memory cells used so far */\n  int nOpAlloc;        /* Number of slots allocated for Vdbe.aOp[] */\n  int szOpAlloc;       /* Bytes of memory space allocated for Vdbe.aOp[] */\n  int iSelfTab;        /* Table for associated with an index on expr, or negative\n                       ** of the base register during check-constraint eval */\n  int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */\n  int iCacheCnt;       /* Counter used to generate aColCache[].lru values */\n  int nLabel;          /* Number of labels used */\n  int *aLabel;         /* Space to hold the labels */\n  ExprList *pConstExpr;/* Constant expressions */\n  Token constraintName;/* Name of the constraint currently being parsed */\n  yDbMask writeMask;   /* Start a write transaction on these databases */\n  yDbMask cookieMask;  /* Bitmask of schema verified databases */\n  int regRowid;        /* Register holding rowid of CREATE TABLE entry */\n  int regRoot;         /* Register holding root page number for new objects */\n  int nMaxArg;         /* Max args passed to user function by sub-program */\n#if SELECTTRACE_ENABLED\n  int nSelect;         /* Number of SELECT statements seen */\n  int nSelectIndent;   /* How far to indent SELECTTRACE() output */\n#endif\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  int nTableLock;        /* Number of locks in aTableLock */\n  TableLock *aTableLock; /* Required table locks for shared-cache mode */\n#endif\n  AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */\n  Parse *pToplevel;    /* Parse structure for main program (or NULL) */\n  Table *pTriggerTab;  /* Table triggers are being coded for */\n  int addrCrTab;       /* Address of OP_CreateBtree opcode on CREATE TABLE */\n  u32 nQueryLoop;      /* Est number of iterations of a query (10*log2(N)) */\n  u32 oldmask;         /* Mask of old.* columns referenced */\n  u32 newmask;         /* Mask of new.* columns referenced */\n  u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */\n  u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */\n  u8 disableTriggers;  /* True to disable triggers */\n\n  /**************************************************************************\n  ** Fields above must be initialized to zero.  The fields that follow,\n  ** down to the beginning of the recursive section, do not need to be\n  ** initialized as they will be set before being used.  The boundary is\n  ** determined by offsetof(Parse,aColCache).\n  **************************************************************************/\n\n  struct yColCache {\n    int iTable;           /* Table cursor number */\n    i16 iColumn;          /* Table column number */\n    u8 tempReg;           /* iReg is a temp register that needs to be freed */\n    int iLevel;           /* Nesting level */\n    int iReg;             /* Reg with value of this column. 0 means none. */\n    int lru;              /* Least recently used entry has the smallest value */\n  } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */\n  int aTempReg[8];        /* Holding area for temporary registers */\n  Token sNameToken;       /* Token with unqualified schema object name */\n\n  /************************************************************************\n  ** Above is constant between recursions.  Below is reset before and after\n  ** each recursion.  The boundary between these two regions is determined\n  ** using offsetof(Parse,sLastToken) so the sLastToken field must be the\n  ** first field in the recursive region.\n  ************************************************************************/\n\n  Token sLastToken;       /* The last token parsed */\n  ynVar nVar;               /* Number of '?' variables seen in the SQL so far */\n  u8 iPkSortOrder;          /* ASC or DESC for INTEGER PRIMARY KEY */\n  u8 explain;               /* True if the EXPLAIN flag is found on the query */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */\n  int nVtabLock;            /* Number of virtual tables to lock */\n#endif\n  int nHeight;              /* Expression tree height of current sub-select */\n#ifndef SQLITE_OMIT_EXPLAIN\n  int iSelectId;            /* ID of current select for EXPLAIN output */\n  int iNextSelectId;        /* Next available select ID for EXPLAIN output */\n#endif\n  VList *pVList;            /* Mapping between variable names and numbers */\n  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */\n  const char *zTail;        /* All SQL text past the last semicolon parsed */\n  Table *pNewTable;         /* A table being constructed by CREATE TABLE */\n  Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */\n  const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  Token sArg;               /* Complete text of a module argument */\n  Table **apVtabLock;       /* Pointer to virtual tables needing locking */\n#endif\n  Table *pZombieTab;        /* List of Table objects to delete after code gen */\n  TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */\n  With *pWith;              /* Current WITH clause, or NULL */\n  With *pWithToFree;        /* Free this WITH object at the end of the parse */\n};\n\n/*\n** Sizes and pointers of various parts of the Parse object.\n*/\n#define PARSE_HDR_SZ offsetof(Parse,aColCache) /* Recursive part w/o aColCache*/\n#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken)    /* Recursive part */\n#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */\n#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ)  /* Pointer to tail */\n\n/*\n** Return true if currently inside an sqlite3_declare_vtab() call.\n*/\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  #define IN_DECLARE_VTAB 0\n#else\n  #define IN_DECLARE_VTAB (pParse->declareVtab)\n#endif\n\n/*\n** An instance of the following structure can be declared on a stack and used\n** to save the Parse.zAuthContext value so that it can be restored later.\n*/\nstruct AuthContext {\n  const char *zAuthContext;   /* Put saved Parse.zAuthContext here */\n  Parse *pParse;              /* The Parse structure */\n};\n\n/*\n** Bitfield flags for P5 value in various opcodes.\n**\n** Value constraints (enforced via assert()):\n**    OPFLAG_LENGTHARG    == SQLITE_FUNC_LENGTH\n**    OPFLAG_TYPEOFARG    == SQLITE_FUNC_TYPEOF\n**    OPFLAG_BULKCSR      == BTREE_BULKLOAD\n**    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ\n**    OPFLAG_FORDELETE    == BTREE_FORDELETE\n**    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION\n**    OPFLAG_AUXDELETE    == BTREE_AUXDELETE\n*/\n#define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */\n                                     /* Also used in P2 (not P5) of OP_Delete */\n#define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */\n#define OPFLAG_LASTROWID     0x20    /* Set to update db->lastRowid */\n#define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */\n#define OPFLAG_APPEND        0x08    /* This is likely to be an append */\n#define OPFLAG_USESEEKRESULT 0x10    /* Try to avoid a seek in BtreeInsert() */\n#define OPFLAG_ISNOOP        0x40    /* OP_Delete does pre-update-hook only */\n#define OPFLAG_LENGTHARG     0x40    /* OP_Column only used for length() */\n#define OPFLAG_TYPEOFARG     0x80    /* OP_Column only used for typeof() */\n#define OPFLAG_BULKCSR       0x01    /* OP_Open** used to open bulk cursor */\n#define OPFLAG_SEEKEQ        0x02    /* OP_Open** cursor uses EQ seek only */\n#define OPFLAG_FORDELETE     0x08    /* OP_Open should use BTREE_FORDELETE */\n#define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */\n#define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */\n#define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete/Insert: save cursor pos */\n#define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */\n\n/*\n * Each trigger present in the database schema is stored as an instance of\n * struct Trigger.\n *\n * Pointers to instances of struct Trigger are stored in two ways.\n * 1. In the \"trigHash\" hash table (part of the sqlite3* that represents the\n *    database). This allows Trigger structures to be retrieved by name.\n * 2. All triggers associated with a single table form a linked list, using the\n *    pNext member of struct Trigger. A pointer to the first element of the\n *    linked list is stored as the \"pTrigger\" member of the associated\n *    struct Table.\n *\n * The \"step_list\" member points to the first element of a linked list\n * containing the SQL statements specified as the trigger program.\n */\nstruct Trigger {\n  char *zName;            /* The name of the trigger                        */\n  char *table;            /* The table or view to which the trigger applies */\n  u8 op;                  /* One of TK_DELETE, TK_UPDATE, TK_INSERT         */\n  u8 tr_tm;               /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Expr *pWhen;            /* The WHEN clause of the expression (may be NULL) */\n  IdList *pColumns;       /* If this is an UPDATE OF <column-list> trigger,\n                             the <column-list> is stored here */\n  Schema *pSchema;        /* Schema containing the trigger */\n  Schema *pTabSchema;     /* Schema containing the table */\n  TriggerStep *step_list; /* Link list of trigger program steps             */\n  Trigger *pNext;         /* Next trigger associated with the table */\n};\n\n/*\n** A trigger is either a BEFORE or an AFTER trigger.  The following constants\n** determine which.\n**\n** If there are multiple triggers, you might of some BEFORE and some AFTER.\n** In that cases, the constants below can be ORed together.\n*/\n#define TRIGGER_BEFORE  1\n#define TRIGGER_AFTER   2\n\n/*\n * An instance of struct TriggerStep is used to store a single SQL statement\n * that is a part of a trigger-program.\n *\n * Instances of struct TriggerStep are stored in a singly linked list (linked\n * using the \"pNext\" member) referenced by the \"step_list\" member of the\n * associated struct Trigger instance. The first element of the linked list is\n * the first step of the trigger-program.\n *\n * The \"op\" member indicates whether this is a \"DELETE\", \"INSERT\", \"UPDATE\" or\n * \"SELECT\" statement. The meanings of the other members is determined by the\n * value of \"op\" as follows:\n *\n * (op == TK_INSERT)\n * orconf    -> stores the ON CONFLICT algorithm\n * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then\n *              this stores a pointer to the SELECT statement. Otherwise NULL.\n * zTarget   -> Dequoted name of the table to insert into.\n * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then\n *              this stores values to be inserted. Otherwise NULL.\n * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...\n *              statement, then this stores the column-names to be\n *              inserted into.\n *\n * (op == TK_DELETE)\n * zTarget   -> Dequoted name of the table to delete from.\n * pWhere    -> The WHERE clause of the DELETE statement if one is specified.\n *              Otherwise NULL.\n *\n * (op == TK_UPDATE)\n * zTarget   -> Dequoted name of the table to update.\n * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.\n *              Otherwise NULL.\n * pExprList -> A list of the columns to update and the expressions to update\n *              them to. See sqlite3Update() documentation of \"pChanges\"\n *              argument.\n *\n */\nstruct TriggerStep {\n  u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */\n  u8 orconf;           /* OE_Rollback etc. */\n  Trigger *pTrig;      /* The trigger that this step is a part of */\n  Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */\n  char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */\n  Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */\n  ExprList *pExprList; /* SET clause for UPDATE. */\n  IdList *pIdList;     /* Column names for INSERT */\n  TriggerStep *pNext;  /* Next in the link-list */\n  TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */\n};\n\n/*\n** The following structure contains information used by the sqliteFix...\n** routines as they walk the parse tree to make database references\n** explicit.\n*/\ntypedef struct DbFixer DbFixer;\nstruct DbFixer {\n  Parse *pParse;      /* The parsing context.  Error messages written here */\n  Schema *pSchema;    /* Fix items to this schema */\n  int bVarOnly;       /* Check for variable references only */\n  const char *zDb;    /* Make sure all objects are contained in this database */\n  const char *zType;  /* Type of the container - used for error messages */\n  const Token *pName; /* Name of the container - used for error messages */\n};\n\n/*\n** An objected used to accumulate the text of a string where we\n** do not necessarily know how big the string will be in the end.\n*/\nstruct StrAccum {\n  sqlite3 *db;         /* Optional database for lookaside.  Can be NULL */\n  char *zText;         /* The string collected so far */\n  u32  nAlloc;         /* Amount of space allocated in zText */\n  u32  mxAlloc;        /* Maximum allowed allocation.  0 for no malloc usage */\n  u32  nChar;          /* Length of the string so far */\n  u8   accError;       /* STRACCUM_NOMEM or STRACCUM_TOOBIG */\n  u8   printfFlags;    /* SQLITE_PRINTF flags below */\n};\n#define STRACCUM_NOMEM   1\n#define STRACCUM_TOOBIG  2\n#define SQLITE_PRINTF_INTERNAL 0x01  /* Internal-use-only converters allowed */\n#define SQLITE_PRINTF_SQLFUNC  0x02  /* SQL function arguments to VXPrintf */\n#define SQLITE_PRINTF_MALLOCED 0x04  /* True if xText is allocated space */\n\n#define isMalloced(X)  (((X)->printfFlags & SQLITE_PRINTF_MALLOCED)!=0)\n\n\n/*\n** A pointer to this structure is used to communicate information\n** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.\n*/\ntypedef struct {\n  sqlite3 *db;        /* The database being initialized */\n  char **pzErrMsg;    /* Error message stored here */\n  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */\n  int rc;             /* Result code stored here */\n} InitData;\n\n/*\n** Structure containing global configuration data for the SQLite library.\n**\n** This structure also contains some state information.\n*/\nstruct Sqlite3Config {\n  int bMemstat;                     /* True to enable memory status */\n  int bCoreMutex;                   /* True to enable core mutexing */\n  int bFullMutex;                   /* True to enable full mutexing */\n  int bOpenUri;                     /* True to interpret filenames as URIs */\n  int bUseCis;                      /* Use covering indices for full-scans */\n  int bSmallMalloc;                 /* Avoid large memory allocations if true */\n  int mxStrlen;                     /* Maximum string length */\n  int neverCorrupt;                 /* Database is always well-formed */\n  int szLookaside;                  /* Default lookaside buffer size */\n  int nLookaside;                   /* Default lookaside buffer count */\n  int nStmtSpill;                   /* Stmt-journal spill-to-disk threshold */\n  sqlite3_mem_methods m;            /* Low-level memory allocation interface */\n  sqlite3_mutex_methods mutex;      /* Low-level mutex interface */\n  sqlite3_pcache_methods2 pcache2;  /* Low-level page-cache interface */\n  void *pHeap;                      /* Heap storage space */\n  int nHeap;                        /* Size of pHeap[] */\n  int mnReq, mxReq;                 /* Min and max heap requests sizes */\n  sqlite3_int64 szMmap;             /* mmap() space per open file */\n  sqlite3_int64 mxMmap;             /* Maximum value for szMmap */\n  void *pPage;                      /* Page cache memory */\n  int szPage;                       /* Size of each page in pPage[] */\n  int nPage;                        /* Number of pages in pPage[] */\n  int mxParserStack;                /* maximum depth of the parser stack */\n  int sharedCacheEnabled;           /* true if shared-cache mode enabled */\n  u32 szPma;                        /* Maximum Sorter PMA size */\n  /* The above might be initialized to non-zero.  The following need to always\n  ** initially be zero, however. */\n  int isInit;                       /* True after initialization has finished */\n  int inProgress;                   /* True while initialization in progress */\n  int isMutexInit;                  /* True after mutexes are initialized */\n  int isMallocInit;                 /* True after malloc is initialized */\n  int isPCacheInit;                 /* True after malloc is initialized */\n  int nRefInitMutex;                /* Number of users of pInitMutex */\n  sqlite3_mutex *pInitMutex;        /* Mutex used by sqlite3_initialize() */\n  void (*xLog)(void*,int,const char*); /* Function for logging */\n  void *pLogArg;                       /* First argument to xLog() */\n#ifdef SQLITE_ENABLE_SQLLOG\n  void(*xSqllog)(void*,sqlite3*,const char*, int);\n  void *pSqllogArg;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  /* The following callback (if not NULL) is invoked on every VDBE branch\n  ** operation.  Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.\n  */\n  void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx);  /* Callback */\n  void *pVdbeBranchArg;                                     /* 1st argument */\n#endif\n#ifndef SQLITE_UNTESTABLE\n  int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */\n#endif\n  int bLocaltimeFault;              /* True to fail localtime() calls */\n  int iOnceResetThreshold;          /* When to reset OP_Once counters */\n};\n\n/*\n** This macro is used inside of assert() statements to indicate that\n** the assert is only valid on a well-formed database.  Instead of:\n**\n**     assert( X );\n**\n** One writes:\n**\n**     assert( X || CORRUPT_DB );\n**\n** CORRUPT_DB is true during normal operation.  CORRUPT_DB does not indicate\n** that the database is definitely corrupt, only that it might be corrupt.\n** For most test cases, CORRUPT_DB is set to false using a special\n** sqlite3_test_control().  This enables assert() statements to prove\n** things that are always true for well-formed databases.\n*/\n#define CORRUPT_DB  (sqlite3Config.neverCorrupt==0)\n\n/*\n** Context pointer passed down through the tree-walk.\n*/\nstruct Walker {\n  Parse *pParse;                            /* Parser context.  */\n  int (*xExprCallback)(Walker*, Expr*);     /* Callback for expressions */\n  int (*xSelectCallback)(Walker*,Select*);  /* Callback for SELECTs */\n  void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */\n  int walkerDepth;                          /* Number of subqueries */\n  u8 eCode;                                 /* A small processing code */\n  union {                                   /* Extra data for callback */\n    NameContext *pNC;                         /* Naming context */\n    int n;                                    /* A counter */\n    int iCur;                                 /* A cursor number */\n    SrcList *pSrcList;                        /* FROM clause */\n    struct SrcCount *pSrcCount;               /* Counting column references */\n    struct CCurHint *pCCurHint;               /* Used by codeCursorHint() */\n    int *aiCol;                               /* array of column indexes */\n    struct IdxCover *pIdxCover;               /* Check for index coverage */\n    struct IdxExprTrans *pIdxTrans;           /* Convert indexed expr to column */\n    ExprList *pGroupBy;                       /* GROUP BY clause */\n    struct HavingToWhereCtx *pHavingCtx;      /* HAVING to WHERE clause ctx */\n  } u;\n};\n\n/* Forward declarations */\nint sqlite3WalkExpr(Walker*, Expr*);\nint sqlite3WalkExprList(Walker*, ExprList*);\nint sqlite3WalkSelect(Walker*, Select*);\nint sqlite3WalkSelectExpr(Walker*, Select*);\nint sqlite3WalkSelectFrom(Walker*, Select*);\nint sqlite3ExprWalkNoop(Walker*, Expr*);\nint sqlite3SelectWalkNoop(Walker*, Select*);\nint sqlite3SelectWalkFail(Walker*, Select*);\n#ifdef SQLITE_DEBUG\nvoid sqlite3SelectWalkAssert2(Walker*, Select*);\n#endif\n\n/*\n** Return code from the parse-tree walking primitives and their\n** callbacks.\n*/\n#define WRC_Continue    0   /* Continue down into children */\n#define WRC_Prune       1   /* Omit children but continue walking siblings */\n#define WRC_Abort       2   /* Abandon the tree walk */\n\n/*\n** An instance of this structure represents a set of one or more CTEs\n** (common table expressions) created by a single WITH clause.\n*/\nstruct With {\n  int nCte;                       /* Number of CTEs in the WITH clause */\n  With *pOuter;                   /* Containing WITH clause, or NULL */\n  struct Cte {                    /* For each CTE in the WITH clause.... */\n    char *zName;                    /* Name of this CTE */\n    ExprList *pCols;                /* List of explicit column names, or NULL */\n    Select *pSelect;                /* The definition of this CTE */\n    const char *zCteErr;            /* Error message for circular references */\n  } a[1];\n};\n\n#ifdef SQLITE_DEBUG\n/*\n** An instance of the TreeView object is used for printing the content of\n** data structures on sqlite3DebugPrintf() using a tree-like view.\n*/\nstruct TreeView {\n  int iLevel;             /* Which level of the tree we are on */\n  u8  bLine[100];         /* Draw vertical in column i if bLine[i] is true */\n};\n#endif /* SQLITE_DEBUG */\n\n/*\n** Assuming zIn points to the first byte of a UTF-8 character,\n** advance zIn to point to the first byte of the next UTF-8 character.\n*/\n#define SQLITE_SKIP_UTF8(zIn) {                        \\\n  if( (*(zIn++))>=0xc0 ){                              \\\n    while( (*zIn & 0xc0)==0x80 ){ zIn++; }             \\\n  }                                                    \\\n}\n\n/*\n** The SQLITE_*_BKPT macros are substitutes for the error codes with\n** the same name but without the _BKPT suffix.  These macros invoke\n** routines that report the line-number on which the error originated\n** using sqlite3_log().  The routines also provide a convenient place\n** to set a debugger breakpoint.\n*/\nint sqlite3CorruptError(int);\nint sqlite3MisuseError(int);\nint sqlite3CantopenError(int);\n#define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)\n#define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)\n#define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)\n#ifdef SQLITE_DEBUG\n  int sqlite3NomemError(int);\n  int sqlite3IoerrnomemError(int);\n  int sqlite3CorruptPgnoError(int,Pgno);\n# define SQLITE_NOMEM_BKPT sqlite3NomemError(__LINE__)\n# define SQLITE_IOERR_NOMEM_BKPT sqlite3IoerrnomemError(__LINE__)\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptPgnoError(__LINE__,(P))\n#else\n# define SQLITE_NOMEM_BKPT SQLITE_NOMEM\n# define SQLITE_IOERR_NOMEM_BKPT SQLITE_IOERR_NOMEM\n# define SQLITE_CORRUPT_PGNO(P) sqlite3CorruptError(__LINE__)\n#endif\n\n/*\n** FTS3 and FTS4 both require virtual table support\n*/\n#if defined(SQLITE_OMIT_VIRTUALTABLE)\n# undef SQLITE_ENABLE_FTS3\n# undef SQLITE_ENABLE_FTS4\n#endif\n\n/*\n** FTS4 is really an extension for FTS3.  It is enabled using the\n** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call\n** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.\n*/\n#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)\n# define SQLITE_ENABLE_FTS3 1\n#endif\n\n/*\n** The ctype.h header is needed for non-ASCII systems.  It is also\n** needed by FTS3 when FTS3 is included in the amalgamation.\n*/\n#if !defined(SQLITE_ASCII) || \\\n    (defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_AMALGAMATION))\n# include <ctype.h>\n#endif\n\n/*\n** The following macros mimic the standard library functions toupper(),\n** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The\n** sqlite versions only work for ASCII characters, regardless of locale.\n*/\n#ifdef SQLITE_ASCII\n# define sqlite3Toupper(x)  ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))\n# define sqlite3Isspace(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x01)\n# define sqlite3Isalnum(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x06)\n# define sqlite3Isalpha(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x02)\n# define sqlite3Isdigit(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x04)\n# define sqlite3Isxdigit(x)  (sqlite3CtypeMap[(unsigned char)(x)]&0x08)\n# define sqlite3Tolower(x)   (sqlite3UpperToLower[(unsigned char)(x)])\n# define sqlite3Isquote(x)   (sqlite3CtypeMap[(unsigned char)(x)]&0x80)\n#else\n# define sqlite3Toupper(x)   toupper((unsigned char)(x))\n# define sqlite3Isspace(x)   isspace((unsigned char)(x))\n# define sqlite3Isalnum(x)   isalnum((unsigned char)(x))\n# define sqlite3Isalpha(x)   isalpha((unsigned char)(x))\n# define sqlite3Isdigit(x)   isdigit((unsigned char)(x))\n# define sqlite3Isxdigit(x)  isxdigit((unsigned char)(x))\n# define sqlite3Tolower(x)   tolower((unsigned char)(x))\n# define sqlite3Isquote(x)   ((x)=='\"'||(x)=='\\''||(x)=='['||(x)=='`')\n#endif\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nint sqlite3IsIdChar(u8);\n#endif\n\n/*\n** Internal function prototypes\n*/\nint sqlite3StrICmp(const char*,const char*);\nint sqlite3Strlen30(const char*);\nchar *sqlite3ColumnType(Column*,char*);\n#define sqlite3StrNICmp sqlite3_strnicmp\n\nint sqlite3MallocInit(void);\nvoid sqlite3MallocEnd(void);\nvoid *sqlite3Malloc(u64);\nvoid *sqlite3MallocZero(u64);\nvoid *sqlite3DbMallocZero(sqlite3*, u64);\nvoid *sqlite3DbMallocRaw(sqlite3*, u64);\nvoid *sqlite3DbMallocRawNN(sqlite3*, u64);\nchar *sqlite3DbStrDup(sqlite3*,const char*);\nchar *sqlite3DbStrNDup(sqlite3*,const char*, u64);\nvoid *sqlite3Realloc(void*, u64);\nvoid *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);\nvoid *sqlite3DbRealloc(sqlite3 *, void *, u64);\nvoid sqlite3DbFree(sqlite3*, void*);\nvoid sqlite3DbFreeNN(sqlite3*, void*);\nint sqlite3MallocSize(void*);\nint sqlite3DbMallocSize(sqlite3*, void*);\nvoid *sqlite3PageMalloc(int);\nvoid sqlite3PageFree(void*);\nvoid sqlite3MemSetDefault(void);\n#ifndef SQLITE_UNTESTABLE\nvoid sqlite3BenignMallocHooks(void (*)(void), void (*)(void));\n#endif\nint sqlite3HeapNearlyFull(void);\n\n/*\n** On systems with ample stack space and that support alloca(), make\n** use of alloca() to obtain space for large automatic objects.  By default,\n** obtain space from malloc().\n**\n** The alloca() routine never returns NULL.  This will cause code paths\n** that deal with sqlite3StackAlloc() failures to be unreachable.\n*/\n#ifdef SQLITE_USE_ALLOCA\n# define sqlite3StackAllocRaw(D,N)   alloca(N)\n# define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)\n# define sqlite3StackFree(D,P)\n#else\n# define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)\n# define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)\n# define sqlite3StackFree(D,P)       sqlite3DbFree(D,P)\n#endif\n\n/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together.  If they\n** are, disable MEMSYS3\n*/\n#ifdef SQLITE_ENABLE_MEMSYS5\nconst sqlite3_mem_methods *sqlite3MemGetMemsys5(void);\n#undef SQLITE_ENABLE_MEMSYS3\n#endif\n#ifdef SQLITE_ENABLE_MEMSYS3\nconst sqlite3_mem_methods *sqlite3MemGetMemsys3(void);\n#endif\n\n\n#ifndef SQLITE_MUTEX_OMIT\n  sqlite3_mutex_methods const *sqlite3DefaultMutex(void);\n  sqlite3_mutex_methods const *sqlite3NoopMutex(void);\n  sqlite3_mutex *sqlite3MutexAlloc(int);\n  int sqlite3MutexInit(void);\n  int sqlite3MutexEnd(void);\n#endif\n#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP)\n  void sqlite3MemoryBarrier(void);\n#else\n# define sqlite3MemoryBarrier()\n#endif\n\nsqlite3_int64 sqlite3StatusValue(int);\nvoid sqlite3StatusUp(int, int);\nvoid sqlite3StatusDown(int, int);\nvoid sqlite3StatusHighwater(int, int);\nint sqlite3LookasideUsed(sqlite3*,int*);\n\n/* Access to mutexes used by sqlite3_status() */\nsqlite3_mutex *sqlite3Pcache1Mutex(void);\nsqlite3_mutex *sqlite3MallocMutex(void);\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int sqlite3IsNaN(double);\n#else\n# define sqlite3IsNaN(X)  0\n#endif\n\n/*\n** An instance of the following structure holds information about SQL\n** functions arguments that are the parameters to the printf() function.\n*/\nstruct PrintfArguments {\n  int nArg;                /* Total number of arguments */\n  int nUsed;               /* Number of arguments used so far */\n  sqlite3_value **apArg;   /* The argument values */\n};\n\nvoid sqlite3VXPrintf(StrAccum*, const char*, va_list);\nvoid sqlite3XPrintf(StrAccum*, const char*, ...);\nchar *sqlite3MPrintf(sqlite3*,const char*, ...);\nchar *sqlite3VMPrintf(sqlite3*,const char*, va_list);\n#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)\n  void sqlite3DebugPrintf(const char*, ...);\n#endif\n#if defined(SQLITE_TEST)\n  void *sqlite3TestTextToPtr(const char*);\n#endif\n\n#if defined(SQLITE_DEBUG)\n  void sqlite3TreeViewExpr(TreeView*, const Expr*, u8);\n  void sqlite3TreeViewBareExprList(TreeView*, const ExprList*, const char*);\n  void sqlite3TreeViewExprList(TreeView*, const ExprList*, u8, const char*);\n  void sqlite3TreeViewSelect(TreeView*, const Select*, u8);\n  void sqlite3TreeViewWith(TreeView*, const With*, u8);\n#endif\n\n\nvoid sqlite3SetString(char **, sqlite3*, const char*);\nvoid sqlite3ErrorMsg(Parse*, const char*, ...);\nvoid sqlite3Dequote(char*);\nvoid sqlite3TokenInit(Token*,char*);\nint sqlite3KeywordCode(const unsigned char*, int);\nint sqlite3RunParser(Parse*, const char*, char **);\nvoid sqlite3FinishCoding(Parse*);\nint sqlite3GetTempReg(Parse*);\nvoid sqlite3ReleaseTempReg(Parse*,int);\nint sqlite3GetTempRange(Parse*,int);\nvoid sqlite3ReleaseTempRange(Parse*,int,int);\nvoid sqlite3ClearTempRegCache(Parse*);\n#ifdef SQLITE_DEBUG\nint sqlite3NoTempsInRange(Parse*,int,int);\n#endif\nExpr *sqlite3ExprAlloc(sqlite3*,int,const Token*,int);\nExpr *sqlite3Expr(sqlite3*,int,const char*);\nvoid sqlite3ExprAttachSubtrees(sqlite3*,Expr*,Expr*,Expr*);\nExpr *sqlite3PExpr(Parse*, int, Expr*, Expr*);\nvoid sqlite3PExprAddSelect(Parse*, Expr*, Select*);\nExpr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*);\nExpr *sqlite3ExprFunction(Parse*,ExprList*, Token*);\nvoid sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);\nvoid sqlite3ExprDelete(sqlite3*, Expr*);\nExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);\nExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);\nvoid sqlite3ExprListSetSortOrder(ExprList*,int);\nvoid sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);\nvoid sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);\nvoid sqlite3ExprListDelete(sqlite3*, ExprList*);\nu32 sqlite3ExprListFlags(const ExprList*);\nint sqlite3Init(sqlite3*, char**);\nint sqlite3InitCallback(void*, int, char**, char**);\nvoid sqlite3Pragma(Parse*,Token*,Token*,Token*,int);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nModule *sqlite3PragmaVtabRegister(sqlite3*,const char *zName);\n#endif\nvoid sqlite3ResetAllSchemasOfConnection(sqlite3*);\nvoid sqlite3ResetOneSchema(sqlite3*,int);\nvoid sqlite3CollapseDatabaseArray(sqlite3*);\nvoid sqlite3CommitInternalChanges(sqlite3*);\nvoid sqlite3DeleteColumnNames(sqlite3*,Table*);\nint sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**);\nvoid sqlite3SelectAddColumnTypeAndCollation(Parse*,Table*,Select*);\nTable *sqlite3ResultSetOfSelect(Parse*,Select*);\nvoid sqlite3OpenMasterTable(Parse *, int);\nIndex *sqlite3PrimaryKeyIndex(Table*);\ni16 sqlite3ColumnOfIndex(Index*, i16);\nvoid sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);\n#if SQLITE_ENABLE_HIDDEN_COLUMNS\n  void sqlite3ColumnPropertiesFromName(Table*, Column*);\n#else\n# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */\n#endif\nvoid sqlite3AddColumn(Parse*,Token*,Token*);\nvoid sqlite3AddNotNull(Parse*, int);\nvoid sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);\nvoid sqlite3AddCheckConstraint(Parse*, Expr*);\nvoid sqlite3AddDefaultValue(Parse*,ExprSpan*);\nvoid sqlite3AddCollateType(Parse*, Token*);\nvoid sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);\nint sqlite3ParseUri(const char*,const char*,unsigned int*,\n                    sqlite3_vfs**,char**,char **);\nBtree *sqlite3DbNameToBtree(sqlite3*,const char*);\n\n#ifdef SQLITE_UNTESTABLE\n# define sqlite3FaultSim(X) SQLITE_OK\n#else\n  int sqlite3FaultSim(int);\n#endif\n\nBitvec *sqlite3BitvecCreate(u32);\nint sqlite3BitvecTest(Bitvec*, u32);\nint sqlite3BitvecTestNotNull(Bitvec*, u32);\nint sqlite3BitvecSet(Bitvec*, u32);\nvoid sqlite3BitvecClear(Bitvec*, u32, void*);\nvoid sqlite3BitvecDestroy(Bitvec*);\nu32 sqlite3BitvecSize(Bitvec*);\n#ifndef SQLITE_UNTESTABLE\nint sqlite3BitvecBuiltinTest(int,int*);\n#endif\n\nRowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);\nvoid sqlite3RowSetClear(RowSet*);\nvoid sqlite3RowSetInsert(RowSet*, i64);\nint sqlite3RowSetTest(RowSet*, int iBatch, i64);\nint sqlite3RowSetNext(RowSet*, i64*);\n\nvoid sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int);\n\n#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)\n  int sqlite3ViewGetColumnNames(Parse*,Table*);\n#else\n# define sqlite3ViewGetColumnNames(A,B) 0\n#endif\n\n#if SQLITE_MAX_ATTACHED>30\n  int sqlite3DbMaskAllZero(yDbMask);\n#endif\nvoid sqlite3DropTable(Parse*, SrcList*, int, int);\nvoid sqlite3CodeDropTable(Parse*, Table*, int, int);\nvoid sqlite3DeleteTable(sqlite3*, Table*);\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n  void sqlite3AutoincrementBegin(Parse *pParse);\n  void sqlite3AutoincrementEnd(Parse *pParse);\n#else\n# define sqlite3AutoincrementBegin(X)\n# define sqlite3AutoincrementEnd(X)\n#endif\nvoid sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);\nvoid *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);\nIdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);\nint sqlite3IdListIndex(IdList*,const char*);\nSrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);\nSrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);\nSrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,\n                                      Token*, Select*, Expr*, IdList*);\nvoid sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);\nvoid sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*);\nint sqlite3IndexedByLookup(Parse *, struct SrcList_item *);\nvoid sqlite3SrcListShiftJoinType(SrcList*);\nvoid sqlite3SrcListAssignCursors(Parse*, SrcList*);\nvoid sqlite3IdListDelete(sqlite3*, IdList*);\nvoid sqlite3SrcListDelete(sqlite3*, SrcList*);\nIndex *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**);\nvoid sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*,\n                          Expr*, int, int, u8);\nvoid sqlite3DropIndex(Parse*, SrcList*, int);\nint sqlite3Select(Parse*, Select*, SelectDest*);\nSelect *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,\n                         Expr*,ExprList*,u32,Expr*,Expr*);\nvoid sqlite3SelectDelete(sqlite3*, Select*);\nTable *sqlite3SrcListLookup(Parse*, SrcList*);\nint sqlite3IsReadOnly(Parse*, Table*, int);\nvoid sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\nExpr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,Expr*,char*);\n#endif\nvoid sqlite3DeleteFrom(Parse*, SrcList*, Expr*);\nvoid sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);\nWhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);\nvoid sqlite3WhereEnd(WhereInfo*);\nLogEst sqlite3WhereOutputRowCount(WhereInfo*);\nint sqlite3WhereIsDistinct(WhereInfo*);\nint sqlite3WhereIsOrdered(WhereInfo*);\nint sqlite3WhereOrderedInnerLoop(WhereInfo*);\nint sqlite3WhereIsSorted(WhereInfo*);\nint sqlite3WhereContinueLabel(WhereInfo*);\nint sqlite3WhereBreakLabel(WhereInfo*);\nint sqlite3WhereOkOnePass(WhereInfo*, int*);\n#define ONEPASS_OFF      0        /* Use of ONEPASS not allowed */\n#define ONEPASS_SINGLE   1        /* ONEPASS valid for a single row update */\n#define ONEPASS_MULTI    2        /* ONEPASS is valid for multiple rows */\nvoid sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int);\nint sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);\nvoid sqlite3ExprCodeGetColumnToReg(Parse*, Table*, int, int, int);\nvoid sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);\nvoid sqlite3ExprCodeMove(Parse*, int, int, int);\nvoid sqlite3ExprCacheStore(Parse*, int, int, int);\nvoid sqlite3ExprCachePush(Parse*);\nvoid sqlite3ExprCachePop(Parse*);\nvoid sqlite3ExprCacheRemove(Parse*, int, int);\nvoid sqlite3ExprCacheClear(Parse*);\nvoid sqlite3ExprCacheAffinityChange(Parse*, int, int);\nvoid sqlite3ExprCode(Parse*, Expr*, int);\nvoid sqlite3ExprCodeCopy(Parse*, Expr*, int);\nvoid sqlite3ExprCodeFactorable(Parse*, Expr*, int);\nint sqlite3ExprCodeAtInit(Parse*, Expr*, int);\nint sqlite3ExprCodeTemp(Parse*, Expr*, int*);\nint sqlite3ExprCodeTarget(Parse*, Expr*, int);\nvoid sqlite3ExprCodeAndCache(Parse*, Expr*, int);\nint sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);\n#define SQLITE_ECEL_DUP      0x01  /* Deep, not shallow copies */\n#define SQLITE_ECEL_FACTOR   0x02  /* Factor out constant terms */\n#define SQLITE_ECEL_REF      0x04  /* Use ExprList.u.x.iOrderByCol */\n#define SQLITE_ECEL_OMITREF  0x08  /* Omit if ExprList.u.x.iOrderByCol */\nvoid sqlite3ExprIfTrue(Parse*, Expr*, int, int);\nvoid sqlite3ExprIfFalse(Parse*, Expr*, int, int);\nvoid sqlite3ExprIfFalseDup(Parse*, Expr*, int, int);\nTable *sqlite3FindTable(sqlite3*,const char*, const char*);\n#define LOCATE_VIEW    0x01\n#define LOCATE_NOERR   0x02\nTable *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*);\nTable *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);\nIndex *sqlite3FindIndex(sqlite3*,const char*, const char*);\nvoid sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);\nvoid sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);\nvoid sqlite3Vacuum(Parse*,Token*);\nint sqlite3RunVacuum(char**, sqlite3*, int);\nchar *sqlite3NameFromToken(sqlite3*, Token*);\nint sqlite3ExprCompare(Parse*,Expr*, Expr*, int);\nint sqlite3ExprCompareSkip(Expr*, Expr*, int);\nint sqlite3ExprListCompare(ExprList*, ExprList*, int);\nint sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int);\nvoid sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);\nvoid sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);\nint sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);\nint sqlite3FunctionUsesThisSrc(Expr*, SrcList*);\nVdbe *sqlite3GetVdbe(Parse*);\n#ifndef SQLITE_UNTESTABLE\nvoid sqlite3PrngSaveState(void);\nvoid sqlite3PrngRestoreState(void);\n#endif\nvoid sqlite3RollbackAll(sqlite3*,int);\nvoid sqlite3CodeVerifySchema(Parse*, int);\nvoid sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);\nvoid sqlite3BeginTransaction(Parse*, int);\nvoid sqlite3EndTransaction(Parse*,int);\nvoid sqlite3Savepoint(Parse*, int, Token*);\nvoid sqlite3CloseSavepoints(sqlite3 *);\nvoid sqlite3LeaveMutexAndCloseZombie(sqlite3*);\nint sqlite3ExprIsConstant(Expr*);\nint sqlite3ExprIsConstantNotJoin(Expr*);\nint sqlite3ExprIsConstantOrFunction(Expr*, u8);\nint sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*);\nint sqlite3ExprIsTableConstant(Expr*,int);\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\nint sqlite3ExprContainsSubquery(Expr*);\n#endif\nint sqlite3ExprIsInteger(Expr*, int*);\nint sqlite3ExprCanBeNull(const Expr*);\nint sqlite3ExprNeedsNoAffinityChange(const Expr*, char);\nint sqlite3IsRowid(const char*);\nvoid sqlite3GenerateRowDelete(\n    Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);\nvoid sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);\nint sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);\nvoid sqlite3ResolvePartIdxLabel(Parse*,int);\nvoid sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,\n                                     u8,u8,int,int*,int*);\n#ifdef SQLITE_ENABLE_NULL_TRIM\n  void sqlite3SetMakeRecordP5(Vdbe*,Table*);\n#else\n# define sqlite3SetMakeRecordP5(A,B)\n#endif\nvoid sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);\nint sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);\nvoid sqlite3BeginWriteOperation(Parse*, int, int);\nvoid sqlite3MultiWrite(Parse*);\nvoid sqlite3MayAbort(Parse*);\nvoid sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8);\nvoid sqlite3UniqueConstraint(Parse*, int, Index*);\nvoid sqlite3RowidConstraint(Parse*, int, Table*);\nExpr *sqlite3ExprDup(sqlite3*,Expr*,int);\nExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);\nSrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);\nIdList *sqlite3IdListDup(sqlite3*,IdList*);\nSelect *sqlite3SelectDup(sqlite3*,Select*,int);\n#if SELECTTRACE_ENABLED\nvoid sqlite3SelectSetName(Select*,const char*);\n#else\n# define sqlite3SelectSetName(A,B)\n#endif\nvoid sqlite3InsertBuiltinFuncs(FuncDef*,int);\nFuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);\nvoid sqlite3RegisterBuiltinFunctions(void);\nvoid sqlite3RegisterDateTimeFunctions(void);\nvoid sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);\nint sqlite3SafetyCheckOk(sqlite3*);\nint sqlite3SafetyCheckSickOrOk(sqlite3*);\nvoid sqlite3ChangeCookie(Parse*, int);\n\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\nvoid sqlite3MaterializeView(Parse*, Table*, Expr*, int);\n#endif\n\n#ifndef SQLITE_OMIT_TRIGGER\n  void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,\n                           Expr*,int, int);\n  void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);\n  void sqlite3DropTrigger(Parse*, SrcList*, int);\n  void sqlite3DropTriggerPtr(Parse*, Trigger*);\n  Trigger *sqlite3TriggersExist(Parse *, Table*, int, ExprList*, int *pMask);\n  Trigger *sqlite3TriggerList(Parse *, Table *);\n  void sqlite3CodeRowTrigger(Parse*, Trigger *, int, ExprList*, int, Table *,\n                            int, int, int);\n  void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);\n  void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);\n  void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);\n  TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);\n  TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,\n                                        Select*,u8);\n  TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);\n  TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);\n  void sqlite3DeleteTrigger(sqlite3*, Trigger*);\n  void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);\n  u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);\n# define sqlite3ParseToplevel(p) ((p)->pToplevel ? (p)->pToplevel : (p))\n# define sqlite3IsToplevel(p) ((p)->pToplevel==0)\n#else\n# define sqlite3TriggersExist(B,C,D,E,F) 0\n# define sqlite3DeleteTrigger(A,B)\n# define sqlite3DropTriggerPtr(A,B)\n# define sqlite3UnlinkAndDeleteTrigger(A,B,C)\n# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I)\n# define sqlite3CodeRowTriggerDirect(A,B,C,D,E,F)\n# define sqlite3TriggerList(X, Y) 0\n# define sqlite3ParseToplevel(p) p\n# define sqlite3IsToplevel(p) 1\n# define sqlite3TriggerColmask(A,B,C,D,E,F,G) 0\n#endif\n\nint sqlite3JoinType(Parse*, Token*, Token*, Token*);\nvoid sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);\nvoid sqlite3DeferForeignKey(Parse*, int);\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);\n  int sqlite3AuthCheck(Parse*,int, const char*, const char*, const char*);\n  void sqlite3AuthContextPush(Parse*, AuthContext*, const char*);\n  void sqlite3AuthContextPop(AuthContext*);\n  int sqlite3AuthReadCol(Parse*, const char *, const char *, int);\n#else\n# define sqlite3AuthRead(a,b,c,d)\n# define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK\n# define sqlite3AuthContextPush(a,b,c)\n# define sqlite3AuthContextPop(a)  ((void)(a))\n#endif\nvoid sqlite3Attach(Parse*, Expr*, Expr*, Expr*);\nvoid sqlite3Detach(Parse*, Expr*);\nvoid sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);\nint sqlite3FixSrcList(DbFixer*, SrcList*);\nint sqlite3FixSelect(DbFixer*, Select*);\nint sqlite3FixExpr(DbFixer*, Expr*);\nint sqlite3FixExprList(DbFixer*, ExprList*);\nint sqlite3FixTriggerStep(DbFixer*, TriggerStep*);\nint sqlite3AtoF(const char *z, double*, int, u8);\nint sqlite3GetInt32(const char *, int*);\nint sqlite3Atoi(const char*);\n#ifndef SQLITE_OMIT_UTF16\nint sqlite3Utf16ByteLen(const void *pData, int nChar);\n#endif\nint sqlite3Utf8CharLen(const char *pData, int nByte);\nu32 sqlite3Utf8Read(const u8**);\nLogEst sqlite3LogEst(u64);\nLogEst sqlite3LogEstAdd(LogEst,LogEst);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\nLogEst sqlite3LogEstFromDouble(double);\n#endif\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\nu64 sqlite3LogEstToInt(LogEst);\n#endif\nVList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);\nconst char *sqlite3VListNumToName(VList*,int);\nint sqlite3VListNameToNum(VList*,const char*,int);\n\n/*\n** Routines to read and write variable-length integers.  These used to\n** be defined locally, but now we use the varint routines in the util.c\n** file.\n*/\nint sqlite3PutVarint(unsigned char*, u64);\nu8 sqlite3GetVarint(const unsigned char *, u64 *);\nu8 sqlite3GetVarint32(const unsigned char *, u32 *);\nint sqlite3VarintLen(u64 v);\n\n/*\n** The common case is for a varint to be a single byte.  They following\n** macros handle the common case without a procedure call, but then call\n** the procedure for larger varints.\n*/\n#define getVarint32(A,B)  \\\n  (u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))\n#define putVarint32(A,B)  \\\n  (u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\\\n  sqlite3PutVarint((A),(B)))\n#define getVarint    sqlite3GetVarint\n#define putVarint    sqlite3PutVarint\n\n\nconst char *sqlite3IndexAffinityStr(sqlite3*, Index*);\nvoid sqlite3TableAffinity(Vdbe*, Table*, int);\nchar sqlite3CompareAffinity(Expr *pExpr, char aff2);\nint sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);\nchar sqlite3TableColumnAffinity(Table*,int);\nchar sqlite3ExprAffinity(Expr *pExpr);\nint sqlite3Atoi64(const char*, i64*, int, u8);\nint sqlite3DecOrHexToI64(const char*, i64*);\nvoid sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);\nvoid sqlite3Error(sqlite3*,int);\nvoid sqlite3SystemError(sqlite3*,int);\nvoid *sqlite3HexToBlob(sqlite3*, const char *z, int n);\nu8 sqlite3HexToInt(int h);\nint sqlite3TwoPartName(Parse *, Token *, Token *, Token **);\n\n#if defined(SQLITE_NEED_ERR_NAME)\nconst char *sqlite3ErrName(int);\n#endif\n\nconst char *sqlite3ErrStr(int);\nint sqlite3ReadSchema(Parse *pParse);\nCollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);\nCollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);\nCollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);\nCollSeq *sqlite3ExprNNCollSeq(Parse *pParse, Expr *pExpr);\nint sqlite3ExprCollSeqMatch(Parse*,Expr*,Expr*);\nExpr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);\nExpr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);\nExpr *sqlite3ExprSkipCollate(Expr*);\nint sqlite3CheckCollSeq(Parse *, CollSeq *);\nint sqlite3CheckObjectName(Parse *, const char *);\nvoid sqlite3VdbeSetChanges(sqlite3 *, int);\nint sqlite3AddInt64(i64*,i64);\nint sqlite3SubInt64(i64*,i64);\nint sqlite3MulInt64(i64*,i64);\nint sqlite3AbsInt32(int);\n#ifdef SQLITE_ENABLE_8_3_NAMES\nvoid sqlite3FileSuffix3(const char*, char*);\n#else\n# define sqlite3FileSuffix3(X,Y)\n#endif\nu8 sqlite3GetBoolean(const char *z,u8);\n\nconst void *sqlite3ValueText(sqlite3_value*, u8);\nint sqlite3ValueBytes(sqlite3_value*, u8);\nvoid sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,\n                        void(*)(void*));\nvoid sqlite3ValueSetNull(sqlite3_value*);\nvoid sqlite3ValueFree(sqlite3_value*);\nsqlite3_value *sqlite3ValueNew(sqlite3 *);\n#ifndef SQLITE_OMIT_UTF16\nchar *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);\n#endif\nint sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);\nvoid sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);\n#ifndef SQLITE_AMALGAMATION\nextern const unsigned char sqlite3OpcodeProperty[];\nextern const char sqlite3StrBINARY[];\nextern const unsigned char sqlite3UpperToLower[];\nextern const unsigned char sqlite3CtypeMap[];\nextern const Token sqlite3IntTokens[];\nextern SQLITE_WSD struct Sqlite3Config sqlite3Config;\nextern FuncDefHash sqlite3BuiltinFunctions;\n#ifndef SQLITE_OMIT_WSD\nextern int sqlite3PendingByte;\n#endif\n#endif\nvoid sqlite3RootPageMoved(sqlite3*, int, int, int);\nvoid sqlite3Reindex(Parse*, Token*, Token*);\nvoid sqlite3AlterFunctions(void);\nvoid sqlite3AlterRenameTable(Parse*, SrcList*, Token*);\nint sqlite3GetToken(const unsigned char *, int *);\nvoid sqlite3NestedParse(Parse*, const char*, ...);\nvoid sqlite3ExpirePreparedStatements(sqlite3*);\nint sqlite3CodeSubselect(Parse*, Expr *, int, int);\nvoid sqlite3SelectPrep(Parse*, Select*, NameContext*);\nvoid sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);\nint sqlite3MatchSpanName(const char*, const char*, const char*, const char*);\nint sqlite3ResolveExprNames(NameContext*, Expr*);\nint sqlite3ResolveExprListNames(NameContext*, ExprList*);\nvoid sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);\nvoid sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);\nint sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);\nvoid sqlite3ColumnDefault(Vdbe *, Table *, int, int);\nvoid sqlite3AlterFinishAddColumn(Parse *, Token *);\nvoid sqlite3AlterBeginAddColumn(Parse *, SrcList *);\nCollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);\nchar sqlite3AffinityType(const char*, u8*);\nvoid sqlite3Analyze(Parse*, Token*, Token*);\nint sqlite3InvokeBusyHandler(BusyHandler*);\nint sqlite3FindDb(sqlite3*, Token*);\nint sqlite3FindDbName(sqlite3 *, const char *);\nint sqlite3AnalysisLoad(sqlite3*,int iDB);\nvoid sqlite3DeleteIndexSamples(sqlite3*,Index*);\nvoid sqlite3DefaultRowEst(Index*);\nvoid sqlite3RegisterLikeFunctions(sqlite3*, int);\nint sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*);\nvoid sqlite3SchemaClear(void *);\nSchema *sqlite3SchemaGet(sqlite3 *, Btree *);\nint sqlite3SchemaToIndex(sqlite3 *db, Schema *);\nKeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);\nvoid sqlite3KeyInfoUnref(KeyInfo*);\nKeyInfo *sqlite3KeyInfoRef(KeyInfo*);\nKeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);\n#ifdef SQLITE_DEBUG\nint sqlite3KeyInfoIsWriteable(KeyInfo*);\n#endif\nint sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,\n  void (*)(sqlite3_context*,int,sqlite3_value **),\n  void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),\n  FuncDestructor *pDestructor\n);\nvoid sqlite3OomFault(sqlite3*);\nvoid sqlite3OomClear(sqlite3*);\nint sqlite3ApiExit(sqlite3 *db, int);\nint sqlite3OpenTempDatabase(Parse *);\n\nvoid sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);\nvoid sqlite3StrAccumAppend(StrAccum*,const char*,int);\nvoid sqlite3StrAccumAppendAll(StrAccum*,const char*);\nvoid sqlite3AppendChar(StrAccum*,int,char);\nchar *sqlite3StrAccumFinish(StrAccum*);\nvoid sqlite3StrAccumReset(StrAccum*);\nvoid sqlite3SelectDestInit(SelectDest*,int,int);\nExpr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);\n\nvoid sqlite3BackupRestart(sqlite3_backup *);\nvoid sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);\n\n#ifndef SQLITE_OMIT_SUBQUERY\nint sqlite3ExprCheckIN(Parse*, Expr*);\n#else\n# define sqlite3ExprCheckIN(x,y) SQLITE_OK\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nvoid sqlite3AnalyzeFunctions(void);\nint sqlite3Stat4ProbeSetValue(\n    Parse*,Index*,UnpackedRecord**,Expr*,int,int,int*);\nint sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);\nvoid sqlite3Stat4ProbeFree(UnpackedRecord*);\nint sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);\nchar sqlite3IndexColumnAffinity(sqlite3*, Index*, int);\n#endif\n\n/*\n** The interface to the LEMON-generated parser\n*/\n#ifndef SQLITE_AMALGAMATION\n  void *sqlite3ParserAlloc(void*(*)(u64));\n  void sqlite3ParserFree(void*, void(*)(void*));\n#endif\nvoid sqlite3Parser(void*, int, Token, Parse*);\n#ifdef YYTRACKMAXSTACKDEPTH\n  int sqlite3ParserStackPeak(void*);\n#endif\n\nvoid sqlite3AutoLoadExtensions(sqlite3*);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  void sqlite3CloseExtensions(sqlite3*);\n#else\n# define sqlite3CloseExtensions(X)\n#endif\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  void sqlite3TableLock(Parse *, int, int, u8, const char *);\n#else\n  #define sqlite3TableLock(v,w,x,y,z)\n#endif\n\n#ifdef SQLITE_TEST\n  int sqlite3Utf8To8(unsigned char*);\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n#  define sqlite3VtabClear(Y)\n#  define sqlite3VtabSync(X,Y) SQLITE_OK\n#  define sqlite3VtabRollback(X)\n#  define sqlite3VtabCommit(X)\n#  define sqlite3VtabInSync(db) 0\n#  define sqlite3VtabLock(X)\n#  define sqlite3VtabUnlock(X)\n#  define sqlite3VtabUnlockList(X)\n#  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK\n#  define sqlite3GetVTable(X,Y)  ((VTable*)0)\n#else\n   void sqlite3VtabClear(sqlite3 *db, Table*);\n   void sqlite3VtabDisconnect(sqlite3 *db, Table *p);\n   int sqlite3VtabSync(sqlite3 *db, Vdbe*);\n   int sqlite3VtabRollback(sqlite3 *db);\n   int sqlite3VtabCommit(sqlite3 *db);\n   void sqlite3VtabLock(VTable *);\n   void sqlite3VtabUnlock(VTable *);\n   void sqlite3VtabUnlockList(sqlite3*);\n   int sqlite3VtabSavepoint(sqlite3 *, int, int);\n   void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*);\n   VTable *sqlite3GetVTable(sqlite3*, Table*);\n   Module *sqlite3VtabCreateModule(\n     sqlite3*,\n     const char*,\n     const sqlite3_module*,\n     void*,\n     void(*)(void*)\n   );\n#  define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)\n#endif\nint sqlite3VtabEponymousTableInit(Parse*,Module*);\nvoid sqlite3VtabEponymousTableClear(sqlite3*,Module*);\nvoid sqlite3VtabMakeWritable(Parse*,Table*);\nvoid sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);\nvoid sqlite3VtabFinishParse(Parse*, Token*);\nvoid sqlite3VtabArgInit(Parse*);\nvoid sqlite3VtabArgExtend(Parse*, Token*);\nint sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);\nint sqlite3VtabCallConnect(Parse*, Table*);\nint sqlite3VtabCallDestroy(sqlite3*, int, const char *);\nint sqlite3VtabBegin(sqlite3 *, VTable *);\nFuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);\nvoid sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);\nsqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);\nint sqlite3VdbeParameterIndex(Vdbe*, const char*, int);\nint sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);\nvoid sqlite3ParserReset(Parse*);\nint sqlite3Reprepare(Vdbe*);\nvoid sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);\nCollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);\nint sqlite3TempInMemory(const sqlite3*);\nconst char *sqlite3JournalModename(int);\n#ifndef SQLITE_OMIT_WAL\n  int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);\n  int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);\n#endif\n#ifndef SQLITE_OMIT_CTE\n  With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);\n  void sqlite3WithDelete(sqlite3*,With*);\n  void sqlite3WithPush(Parse*, With*, u8);\n#else\n#define sqlite3WithPush(x,y,z)\n#define sqlite3WithDelete(x,y)\n#endif\n\n/* Declarations for functions in fkey.c. All of these are replaced by\n** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign\n** key functionality is available. If OMIT_TRIGGER is defined but\n** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In\n** this case foreign keys are parsed, but no other functionality is\n** provided (enforcement of FK constraints requires the triggers sub-system).\n*/\n#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)\n  void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);\n  void sqlite3FkDropTable(Parse*, SrcList *, Table*);\n  void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);\n  int sqlite3FkRequired(Parse*, Table*, int*, int);\n  u32 sqlite3FkOldmask(Parse*, Table*);\n  FKey *sqlite3FkReferences(Table *);\n#else\n  #define sqlite3FkActions(a,b,c,d,e,f)\n  #define sqlite3FkCheck(a,b,c,d,e,f)\n  #define sqlite3FkDropTable(a,b,c)\n  #define sqlite3FkOldmask(a,b)         0\n  #define sqlite3FkRequired(a,b,c,d)    0\n  #define sqlite3FkReferences(a)        0\n#endif\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n  void sqlite3FkDelete(sqlite3 *, Table*);\n  int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);\n#else\n  #define sqlite3FkDelete(a,b)\n  #define sqlite3FkLocateIndex(a,b,c,d,e)\n#endif\n\n\n/*\n** Available fault injectors.  Should be numbered beginning with 0.\n*/\n#define SQLITE_FAULTINJECTOR_MALLOC     0\n#define SQLITE_FAULTINJECTOR_COUNT      1\n\n/*\n** The interface to the code in fault.c used for identifying \"benign\"\n** malloc failures. This is only present if SQLITE_UNTESTABLE\n** is not defined.\n*/\n#ifndef SQLITE_UNTESTABLE\n  void sqlite3BeginBenignMalloc(void);\n  void sqlite3EndBenignMalloc(void);\n#else\n  #define sqlite3BeginBenignMalloc()\n  #define sqlite3EndBenignMalloc()\n#endif\n\n/*\n** Allowed return values from sqlite3FindInIndex()\n*/\n#define IN_INDEX_ROWID        1   /* Search the rowid of the table */\n#define IN_INDEX_EPH          2   /* Search an ephemeral b-tree */\n#define IN_INDEX_INDEX_ASC    3   /* Existing index ASCENDING */\n#define IN_INDEX_INDEX_DESC   4   /* Existing index DESCENDING */\n#define IN_INDEX_NOOP         5   /* No table available. Use comparisons */\n/*\n** Allowed flags for the 3rd parameter to sqlite3FindInIndex().\n*/\n#define IN_INDEX_NOOP_OK     0x0001  /* OK to return IN_INDEX_NOOP */\n#define IN_INDEX_MEMBERSHIP  0x0002  /* IN operator used for membership test */\n#define IN_INDEX_LOOP        0x0004  /* IN operator used as a loop */\nint sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);\n\nint sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);\nint sqlite3JournalSize(sqlite3_vfs *);\n#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \\\n || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)\n  int sqlite3JournalCreate(sqlite3_file *);\n#endif\n\nint sqlite3JournalIsInMemory(sqlite3_file *p);\nvoid sqlite3MemJournalOpen(sqlite3_file *);\n\nvoid sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);\n#if SQLITE_MAX_EXPR_DEPTH>0\n  int sqlite3SelectExprHeight(Select *);\n  int sqlite3ExprCheckHeight(Parse*, int);\n#else\n  #define sqlite3SelectExprHeight(x) 0\n  #define sqlite3ExprCheckHeight(x,y)\n#endif\n\nu32 sqlite3Get4byte(const u8*);\nvoid sqlite3Put4byte(u8*, u32);\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n  void sqlite3ConnectionBlocked(sqlite3 *, sqlite3 *);\n  void sqlite3ConnectionUnlocked(sqlite3 *db);\n  void sqlite3ConnectionClosed(sqlite3 *db);\n#else\n  #define sqlite3ConnectionBlocked(x,y)\n  #define sqlite3ConnectionUnlocked(x)\n  #define sqlite3ConnectionClosed(x)\n#endif\n\n#ifdef SQLITE_DEBUG\n  void sqlite3ParserTrace(FILE*, char *);\n#endif\n\n/*\n** If the SQLITE_ENABLE IOTRACE exists then the global variable\n** sqlite3IoTrace is a pointer to a printf-like routine used to\n** print I/O tracing messages.\n*/\n#ifdef SQLITE_ENABLE_IOTRACE\n# define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }\n  void sqlite3VdbeIOTraceSql(Vdbe*);\nSQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);\n#else\n# define IOTRACE(A)\n# define sqlite3VdbeIOTraceSql(X)\n#endif\n\n/*\n** These routines are available for the mem2.c debugging memory allocator\n** only.  They are used to verify that different \"types\" of memory\n** allocations are properly tracked by the system.\n**\n** sqlite3MemdebugSetType() sets the \"type\" of an allocation to one of\n** the MEMTYPE_* macros defined below.  The type must be a bitmask with\n** a single bit set.\n**\n** sqlite3MemdebugHasType() returns true if any of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n** sqlite3MemdebugHasType() is intended for use inside assert() statements.\n**\n** sqlite3MemdebugNoType() returns true if none of the bits in its second\n** argument match the type set by the previous sqlite3MemdebugSetType().\n**\n** Perhaps the most important point is the difference between MEMTYPE_HEAP\n** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means\n** it might have been allocated by lookaside, except the allocation was\n** too large or lookaside was already full.  It is important to verify\n** that allocations that might have been satisfied by lookaside are not\n** passed back to non-lookaside free() routines.  Asserts such as the\n** example above are placed on the non-lookaside free() routines to verify\n** this constraint.\n**\n** All of this is no-op for a production build.  It only comes into\n** play when the SQLITE_MEMDEBUG compile-time option is used.\n*/\n#ifdef SQLITE_MEMDEBUG\n  void sqlite3MemdebugSetType(void*,u8);\n  int sqlite3MemdebugHasType(void*,u8);\n  int sqlite3MemdebugNoType(void*,u8);\n#else\n# define sqlite3MemdebugSetType(X,Y)  /* no-op */\n# define sqlite3MemdebugHasType(X,Y)  1\n# define sqlite3MemdebugNoType(X,Y)   1\n#endif\n#define MEMTYPE_HEAP       0x01  /* General heap allocations */\n#define MEMTYPE_LOOKASIDE  0x02  /* Heap that might have been lookaside */\n#define MEMTYPE_PCACHE     0x04  /* Page cache allocations */\n\n/*\n** Threading interface\n*/\n#if SQLITE_MAX_WORKER_THREADS>0\nint sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);\nint sqlite3ThreadJoin(SQLiteThread*, void**);\n#endif\n\n#if defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)\nint sqlite3DbpageRegister(sqlite3*);\n#endif\n#if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)\nint sqlite3DbstatRegister(sqlite3*);\n#endif\n\nint sqlite3ExprVectorSize(Expr *pExpr);\nint sqlite3ExprIsVector(Expr *pExpr);\nExpr *sqlite3VectorFieldSubexpr(Expr*, int);\nExpr *sqlite3ExprForVectorField(Parse*,Expr*,int);\nvoid sqlite3VectorErrorMsg(Parse*, Expr*);\n\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nconst char **sqlite3CompileOptions(int *pnOpt);\n#endif\n\n#endif /* SQLITEINT_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/sqliteLimit.h",
    "content": "/*\n** 2007 May 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file defines various limits of what SQLite can process.\n*/\n\n/*\n** The maximum length of a TEXT or BLOB in bytes.   This also\n** limits the size of a row in a table or index.\n**\n** The hard limit is the ability of a 32-bit signed integer\n** to count the size: 2^31-1 or 2147483647.\n*/\n#ifndef SQLITE_MAX_LENGTH\n# define SQLITE_MAX_LENGTH 1000000000\n#endif\n\n/*\n** This is the maximum number of\n**\n**    * Columns in a table\n**    * Columns in an index\n**    * Columns in a view\n**    * Terms in the SET clause of an UPDATE statement\n**    * Terms in the result set of a SELECT statement\n**    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.\n**    * Terms in the VALUES clause of an INSERT statement\n**\n** The hard upper limit here is 32676.  Most database people will\n** tell you that in a well-normalized database, you usually should\n** not have more than a dozen or so columns in any table.  And if\n** that is the case, there is no point in having more than a few\n** dozen values in any of the other situations described above.\n*/\n#ifndef SQLITE_MAX_COLUMN\n# define SQLITE_MAX_COLUMN 2000\n#endif\n\n/*\n** The maximum length of a single SQL statement in bytes.\n**\n** It used to be the case that setting this value to zero would\n** turn the limit off.  That is no longer true.  It is not possible\n** to turn this limit off.\n*/\n#ifndef SQLITE_MAX_SQL_LENGTH\n# define SQLITE_MAX_SQL_LENGTH 1000000000\n#endif\n\n/*\n** The maximum depth of an expression tree. This is limited to \n** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might \n** want to place more severe limits on the complexity of an \n** expression.\n**\n** A value of 0 used to mean that the limit was not enforced.\n** But that is no longer true.  The limit is now strictly enforced\n** at all times.\n*/\n#ifndef SQLITE_MAX_EXPR_DEPTH\n# define SQLITE_MAX_EXPR_DEPTH 1000\n#endif\n\n/*\n** The maximum number of terms in a compound SELECT statement.\n** The code generator for compound SELECT statements does one\n** level of recursion for each term.  A stack overflow can result\n** if the number of terms is too large.  In practice, most SQL\n** never has more than 3 or 4 terms.  Use a value of 0 to disable\n** any limit on the number of terms in a compount SELECT.\n*/\n#ifndef SQLITE_MAX_COMPOUND_SELECT\n# define SQLITE_MAX_COMPOUND_SELECT 500\n#endif\n\n/*\n** The maximum number of opcodes in a VDBE program.\n** Not currently enforced.\n*/\n#ifndef SQLITE_MAX_VDBE_OP\n# define SQLITE_MAX_VDBE_OP 250000000\n#endif\n\n/*\n** The maximum number of arguments to an SQL function.\n*/\n#ifndef SQLITE_MAX_FUNCTION_ARG\n# define SQLITE_MAX_FUNCTION_ARG 127\n#endif\n\n/*\n** The suggested maximum number of in-memory pages to use for\n** the main database table and for temporary tables.\n**\n** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,\n** which means the cache size is limited to 2048000 bytes of memory.\n** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be\n** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.\n*/\n#ifndef SQLITE_DEFAULT_CACHE_SIZE\n# define SQLITE_DEFAULT_CACHE_SIZE  -2000\n#endif\n\n/*\n** The default number of frames to accumulate in the log file before\n** checkpointing the database in WAL mode.\n*/\n#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT\n# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000\n#endif\n\n/*\n** The maximum number of attached databases.  This must be between 0\n** and 125.  The upper bound of 125 is because the attached databases are\n** counted using a signed 8-bit integer which has a maximum value of 127\n** and we have to allow 2 extra counts for the \"main\" and \"temp\" databases.\n*/\n#ifndef SQLITE_MAX_ATTACHED\n# define SQLITE_MAX_ATTACHED 10\n#endif\n\n\n/*\n** The maximum value of a ?nnn wildcard that the parser will accept.\n*/\n#ifndef SQLITE_MAX_VARIABLE_NUMBER\n# define SQLITE_MAX_VARIABLE_NUMBER 999\n#endif\n\n/* Maximum page size.  The upper bound on this value is 65536.  This a limit\n** imposed by the use of 16-bit offsets within each page.\n**\n** Earlier versions of SQLite allowed the user to change this value at\n** compile time. This is no longer permitted, on the grounds that it creates\n** a library that is technically incompatible with an SQLite library \n** compiled with a different limit. If a process operating on a database \n** with a page-size of 65536 bytes crashes, then an instance of SQLite \n** compiled with the default page-size limit will not be able to rollback \n** the aborted transaction. This could lead to database corruption.\n*/\n#ifdef SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_PAGE_SIZE\n#endif\n#define SQLITE_MAX_PAGE_SIZE 65536\n\n\n/*\n** The default size of a database page.\n*/\n#ifndef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE 4096\n#endif\n#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_DEFAULT_PAGE_SIZE\n# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n/*\n** Ordinarily, if no value is explicitly provided, SQLite creates databases\n** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain\n** device characteristics (sector-size and atomic write() support),\n** SQLite may choose a larger value. This constant is the maximum value\n** SQLite will choose on its own.\n*/\n#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192\n#endif\n#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE\n# undef SQLITE_MAX_DEFAULT_PAGE_SIZE\n# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE\n#endif\n\n\n/*\n** Maximum number of pages in one database file.\n**\n** This is really just the default value for the max_page_count pragma.\n** This value can be lowered (or raised) at run-time using that the\n** max_page_count macro.\n*/\n#ifndef SQLITE_MAX_PAGE_COUNT\n# define SQLITE_MAX_PAGE_COUNT 1073741823\n#endif\n\n/*\n** Maximum length (in bytes) of the pattern in a LIKE or GLOB\n** operator.\n*/\n#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH\n# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000\n#endif\n\n/*\n** Maximum depth of recursion for triggers.\n**\n** A value of 1 means that a trigger program will not be able to itself\n** fire any triggers. A value of 0 means that no trigger programs at all \n** may be executed.\n*/\n#ifndef SQLITE_MAX_TRIGGER_DEPTH\n# define SQLITE_MAX_TRIGGER_DEPTH 1000\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/status.c",
    "content": "/*\n** 2008 June 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This module implements the sqlite3_status() interface and related\n** functionality.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n/*\n** Variables in which to record status information.\n*/\n#if SQLITE_PTRSIZE>4\ntypedef sqlite3_int64 sqlite3StatValueType;\n#else\ntypedef u32 sqlite3StatValueType;\n#endif\ntypedef struct sqlite3StatType sqlite3StatType;\nstatic SQLITE_WSD struct sqlite3StatType {\n  sqlite3StatValueType nowValue[10];  /* Current value */\n  sqlite3StatValueType mxValue[10];   /* Maximum value */\n} sqlite3Stat = { {0,}, {0,} };\n\n/*\n** Elements of sqlite3Stat[] are protected by either the memory allocator\n** mutex, or by the pcache1 mutex.  The following array determines which.\n*/\nstatic const char statMutex[] = {\n  0,  /* SQLITE_STATUS_MEMORY_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_USED */\n  1,  /* SQLITE_STATUS_PAGECACHE_OVERFLOW */\n  0,  /* SQLITE_STATUS_SCRATCH_USED */\n  0,  /* SQLITE_STATUS_SCRATCH_OVERFLOW */\n  0,  /* SQLITE_STATUS_MALLOC_SIZE */\n  0,  /* SQLITE_STATUS_PARSER_STACK */\n  1,  /* SQLITE_STATUS_PAGECACHE_SIZE */\n  0,  /* SQLITE_STATUS_SCRATCH_SIZE */\n  0,  /* SQLITE_STATUS_MALLOC_COUNT */\n};\n\n\n/* The \"wsdStat\" macro will resolve to the status information\n** state vector.  If writable static data is unsupported on the target,\n** we have to locate the state vector at run-time.  In the more common\n** case where writable static data is supported, wsdStat can refer directly\n** to the \"sqlite3Stat\" state vector declared above.\n*/\n#ifdef SQLITE_OMIT_WSD\n# define wsdStatInit  sqlite3StatType *x = &GLOBAL(sqlite3StatType,sqlite3Stat)\n# define wsdStat x[0]\n#else\n# define wsdStatInit\n# define wsdStat sqlite3Stat\n#endif\n\n/*\n** Return the current value of a status parameter.  The caller must\n** be holding the appropriate mutex.\n*/\nsqlite3_int64 sqlite3StatusValue(int op){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  return wsdStat.nowValue[op];\n}\n\n/*\n** Add N to the value of a status record.  The caller must hold the\n** appropriate mutex.  (Locking is checked by assert()).\n**\n** The StatusUp() routine can accept positive or negative values for N.\n** The value of N is added to the current status value and the high-water\n** mark is adjusted if necessary.\n**\n** The StatusDown() routine lowers the current value by N.  The highwater\n** mark is unchanged.  N must be non-negative for StatusDown().\n*/\nvoid sqlite3StatusUp(int op, int N){\n  wsdStatInit;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  wsdStat.nowValue[op] += N;\n  if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n}\nvoid sqlite3StatusDown(int op, int N){\n  wsdStatInit;\n  assert( N>=0 );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  wsdStat.nowValue[op] -= N;\n}\n\n/*\n** Adjust the highwater mark if necessary.\n** The caller must hold the appropriate mutex.\n*/\nvoid sqlite3StatusHighwater(int op, int X){\n  sqlite3StatValueType newValue;\n  wsdStatInit;\n  assert( X>=0 );\n  newValue = (sqlite3StatValueType)X;\n  assert( op>=0 && op<ArraySize(wsdStat.nowValue) );\n  assert( op>=0 && op<ArraySize(statMutex) );\n  assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()\n                                           : sqlite3MallocMutex()) );\n  assert( op==SQLITE_STATUS_MALLOC_SIZE\n          || op==SQLITE_STATUS_PAGECACHE_SIZE\n          || op==SQLITE_STATUS_PARSER_STACK );\n  if( newValue>wsdStat.mxValue[op] ){\n    wsdStat.mxValue[op] = newValue;\n  }\n}\n\n/*\n** Query status information.\n*/\nint sqlite3_status64(\n  int op,\n  sqlite3_int64 *pCurrent,\n  sqlite3_int64 *pHighwater,\n  int resetFlag\n){\n  sqlite3_mutex *pMutex;\n  wsdStatInit;\n  if( op<0 || op>=ArraySize(wsdStat.nowValue) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();\n  sqlite3_mutex_enter(pMutex);\n  *pCurrent = wsdStat.nowValue[op];\n  *pHighwater = wsdStat.mxValue[op];\n  if( resetFlag ){\n    wsdStat.mxValue[op] = wsdStat.nowValue[op];\n  }\n  sqlite3_mutex_leave(pMutex);\n  (void)pMutex;  /* Prevent warning when SQLITE_THREADSAFE=0 */\n  return SQLITE_OK;\n}\nint sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){\n  sqlite3_int64 iCur = 0, iHwtr = 0;\n  int rc;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);\n  if( rc==0 ){\n    *pCurrent = (int)iCur;\n    *pHighwater = (int)iHwtr;\n  }\n  return rc;\n}\n\n/*\n** Return the number of LookasideSlot elements on the linked list\n*/\nstatic u32 countLookasideSlots(LookasideSlot *p){\n  u32 cnt = 0;\n  while( p ){\n    p = p->pNext;\n    cnt++;\n  }\n  return cnt;\n}\n\n/*\n** Count the number of slots of lookaside memory that are outstanding\n*/\nint sqlite3LookasideUsed(sqlite3 *db, int *pHighwater){\n  u32 nInit = countLookasideSlots(db->lookaside.pInit);\n  u32 nFree = countLookasideSlots(db->lookaside.pFree);\n  if( pHighwater ) *pHighwater = db->lookaside.nSlot - nInit;\n  return db->lookaside.nSlot - (nInit+nFree);\n}\n\n/*\n** Query status information for a single database connection\n*/\nint sqlite3_db_status(\n  sqlite3 *db,          /* The database connection whose status is desired */\n  int op,               /* Status verb */\n  int *pCurrent,        /* Write current value here */\n  int *pHighwater,      /* Write high-water mark here */\n  int resetFlag         /* Reset high-water mark if true */\n){\n  int rc = SQLITE_OK;   /* Return code */\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  switch( op ){\n    case SQLITE_DBSTATUS_LOOKASIDE_USED: {\n      *pCurrent = sqlite3LookasideUsed(db, pHighwater);\n      if( resetFlag ){\n        LookasideSlot *p = db->lookaside.pFree;\n        if( p ){\n          while( p->pNext ) p = p->pNext;\n          p->pNext = db->lookaside.pInit;\n          db->lookaside.pInit = db->lookaside.pFree;\n          db->lookaside.pFree = 0;\n        }\n      }\n      break;\n    }\n\n    case SQLITE_DBSTATUS_LOOKASIDE_HIT:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:\n    case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );\n      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );\n      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );\n      *pCurrent = 0;\n      *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];\n      if( resetFlag ){\n        db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;\n      }\n      break;\n    }\n\n    /* \n    ** Return an approximation for the amount of memory currently used\n    ** by all pagers associated with the given database connection.  The\n    ** highwater mark is meaningless and is returned as zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_USED_SHARED:\n    case SQLITE_DBSTATUS_CACHE_USED: {\n      int totalUsed = 0;\n      int i;\n      sqlite3BtreeEnterAll(db);\n      for(i=0; i<db->nDb; i++){\n        Btree *pBt = db->aDb[i].pBt;\n        if( pBt ){\n          Pager *pPager = sqlite3BtreePager(pBt);\n          int nByte = sqlite3PagerMemUsed(pPager);\n          if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){\n            nByte = nByte / sqlite3BtreeConnectionCount(pBt);\n          }\n          totalUsed += nByte;\n        }\n      }\n      sqlite3BtreeLeaveAll(db);\n      *pCurrent = totalUsed;\n      *pHighwater = 0;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store the schema for all databases (main, temp, and any ATTACHed\n    ** databases.  *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_SCHEMA_USED: {\n      int i;                      /* Used to iterate through schemas */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      sqlite3BtreeEnterAll(db);\n      db->pnBytesFreed = &nByte;\n      for(i=0; i<db->nDb; i++){\n        Schema *pSchema = db->aDb[i].pSchema;\n        if( ALWAYS(pSchema!=0) ){\n          HashElem *p;\n\n          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (\n              pSchema->tblHash.count \n            + pSchema->trigHash.count\n            + pSchema->idxHash.count\n            + pSchema->fkeyHash.count\n          );\n          nByte += sqlite3_msize(pSchema->tblHash.ht);\n          nByte += sqlite3_msize(pSchema->trigHash.ht);\n          nByte += sqlite3_msize(pSchema->idxHash.ht);\n          nByte += sqlite3_msize(pSchema->fkeyHash.ht);\n\n          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));\n          }\n          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){\n            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));\n          }\n        }\n      }\n      db->pnBytesFreed = 0;\n      sqlite3BtreeLeaveAll(db);\n\n      *pHighwater = 0;\n      *pCurrent = nByte;\n      break;\n    }\n\n    /*\n    ** *pCurrent gets an accurate estimate of the amount of memory used\n    ** to store all prepared statements.\n    ** *pHighwater is set to zero.\n    */\n    case SQLITE_DBSTATUS_STMT_USED: {\n      struct Vdbe *pVdbe;         /* Used to iterate through VMs */\n      int nByte = 0;              /* Used to accumulate return value */\n\n      db->pnBytesFreed = &nByte;\n      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){\n        sqlite3VdbeClearObject(db, pVdbe);\n        sqlite3DbFree(db, pVdbe);\n      }\n      db->pnBytesFreed = 0;\n\n      *pHighwater = 0;  /* IMP: R-64479-57858 */\n      *pCurrent = nByte;\n\n      break;\n    }\n\n    /*\n    ** Set *pCurrent to the total cache hits or misses encountered by all\n    ** pagers the database handle is connected to. *pHighwater is always set \n    ** to zero.\n    */\n    case SQLITE_DBSTATUS_CACHE_HIT:\n    case SQLITE_DBSTATUS_CACHE_MISS:\n    case SQLITE_DBSTATUS_CACHE_WRITE:{\n      int i;\n      int nRet = 0;\n      assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );\n      assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );\n\n      for(i=0; i<db->nDb; i++){\n        if( db->aDb[i].pBt ){\n          Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);\n          sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);\n        }\n      }\n      *pHighwater = 0; /* IMP: R-42420-56072 */\n                       /* IMP: R-54100-20147 */\n                       /* IMP: R-29431-39229 */\n      *pCurrent = nRet;\n      break;\n    }\n\n    /* Set *pCurrent to non-zero if there are unresolved deferred foreign\n    ** key constraints.  Set *pCurrent to zero if all foreign key constraints\n    ** have been satisfied.  The *pHighwater is always set to zero.\n    */\n    case SQLITE_DBSTATUS_DEFERRED_FKS: {\n      *pHighwater = 0;  /* IMP: R-11967-56545 */\n      *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;\n      break;\n    }\n\n    default: {\n      rc = SQLITE_ERROR;\n    }\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/table.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the sqlite3_get_table() and sqlite3_free_table()\n** interface routines.  These are just wrappers around the main\n** interface routine of sqlite3_exec().\n**\n** These routines are in a separate files so that they will not be linked\n** if they are not used.\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_GET_TABLE\n\n/*\n** This structure is used to pass data from sqlite3_get_table() through\n** to the callback function is uses to build the result.\n*/\ntypedef struct TabResult {\n  char **azResult;   /* Accumulated output */\n  char *zErrMsg;     /* Error message text, if an error occurs */\n  u32 nAlloc;        /* Slots allocated for azResult[] */\n  u32 nRow;          /* Number of rows in the result */\n  u32 nColumn;       /* Number of columns in the result */\n  u32 nData;         /* Slots used in azResult[].  (nRow+1)*nColumn */\n  int rc;            /* Return code from sqlite3_exec() */\n} TabResult;\n\n/*\n** This routine is called once for each row in the result table.  Its job\n** is to fill in the TabResult structure appropriately, allocating new\n** memory as necessary.\n*/\nstatic int sqlite3_get_table_cb(void *pArg, int nCol, char **argv, char **colv){\n  TabResult *p = (TabResult*)pArg;  /* Result accumulator */\n  int need;                         /* Slots needed in p->azResult[] */\n  int i;                            /* Loop counter */\n  char *z;                          /* A single column of result */\n\n  /* Make sure there is enough space in p->azResult to hold everything\n  ** we need to remember from this invocation of the callback.\n  */\n  if( p->nRow==0 && argv!=0 ){\n    need = nCol*2;\n  }else{\n    need = nCol;\n  }\n  if( p->nData + need > p->nAlloc ){\n    char **azNew;\n    p->nAlloc = p->nAlloc*2 + need;\n    azNew = sqlite3_realloc64( p->azResult, sizeof(char*)*p->nAlloc );\n    if( azNew==0 ) goto malloc_failed;\n    p->azResult = azNew;\n  }\n\n  /* If this is the first row, then generate an extra row containing\n  ** the names of all columns.\n  */\n  if( p->nRow==0 ){\n    p->nColumn = nCol;\n    for(i=0; i<nCol; i++){\n      z = sqlite3_mprintf(\"%s\", colv[i]);\n      if( z==0 ) goto malloc_failed;\n      p->azResult[p->nData++] = z;\n    }\n  }else if( (int)p->nColumn!=nCol ){\n    sqlite3_free(p->zErrMsg);\n    p->zErrMsg = sqlite3_mprintf(\n       \"sqlite3_get_table() called with two or more incompatible queries\"\n    );\n    p->rc = SQLITE_ERROR;\n    return 1;\n  }\n\n  /* Copy over the row data\n  */\n  if( argv!=0 ){\n    for(i=0; i<nCol; i++){\n      if( argv[i]==0 ){\n        z = 0;\n      }else{\n        int n = sqlite3Strlen30(argv[i])+1;\n        z = sqlite3_malloc64( n );\n        if( z==0 ) goto malloc_failed;\n        memcpy(z, argv[i], n);\n      }\n      p->azResult[p->nData++] = z;\n    }\n    p->nRow++;\n  }\n  return 0;\n\nmalloc_failed:\n  p->rc = SQLITE_NOMEM_BKPT;\n  return 1;\n}\n\n/*\n** Query the database.  But instead of invoking a callback for each row,\n** malloc() for space to hold the result and return the entire results\n** at the conclusion of the call.\n**\n** The result that is written to ***pazResult is held in memory obtained\n** from malloc().  But the caller cannot free this memory directly.  \n** Instead, the entire table should be passed to sqlite3_free_table() when\n** the calling procedure is finished using it.\n*/\nint sqlite3_get_table(\n  sqlite3 *db,                /* The database on which the SQL executes */\n  const char *zSql,           /* The SQL to be executed */\n  char ***pazResult,          /* Write the result table here */\n  int *pnRow,                 /* Write the number of rows in the result here */\n  int *pnColumn,              /* Write the number of columns of result here */\n  char **pzErrMsg             /* Write error messages here */\n){\n  int rc;\n  TabResult res;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  *pazResult = 0;\n  if( pnColumn ) *pnColumn = 0;\n  if( pnRow ) *pnRow = 0;\n  if( pzErrMsg ) *pzErrMsg = 0;\n  res.zErrMsg = 0;\n  res.nRow = 0;\n  res.nColumn = 0;\n  res.nData = 1;\n  res.nAlloc = 20;\n  res.rc = SQLITE_OK;\n  res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );\n  if( res.azResult==0 ){\n     db->errCode = SQLITE_NOMEM;\n     return SQLITE_NOMEM_BKPT;\n  }\n  res.azResult[0] = 0;\n  rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);\n  assert( sizeof(res.azResult[0])>= sizeof(res.nData) );\n  res.azResult[0] = SQLITE_INT_TO_PTR(res.nData);\n  if( (rc&0xff)==SQLITE_ABORT ){\n    sqlite3_free_table(&res.azResult[1]);\n    if( res.zErrMsg ){\n      if( pzErrMsg ){\n        sqlite3_free(*pzErrMsg);\n        *pzErrMsg = sqlite3_mprintf(\"%s\",res.zErrMsg);\n      }\n      sqlite3_free(res.zErrMsg);\n    }\n    db->errCode = res.rc;  /* Assume 32-bit assignment is atomic */\n    return res.rc;\n  }\n  sqlite3_free(res.zErrMsg);\n  if( rc!=SQLITE_OK ){\n    sqlite3_free_table(&res.azResult[1]);\n    return rc;\n  }\n  if( res.nAlloc>res.nData ){\n    char **azNew;\n    azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );\n    if( azNew==0 ){\n      sqlite3_free_table(&res.azResult[1]);\n      db->errCode = SQLITE_NOMEM;\n      return SQLITE_NOMEM_BKPT;\n    }\n    res.azResult = azNew;\n  }\n  *pazResult = &res.azResult[1];\n  if( pnColumn ) *pnColumn = res.nColumn;\n  if( pnRow ) *pnRow = res.nRow;\n  return rc;\n}\n\n/*\n** This routine frees the space the sqlite3_get_table() malloced.\n*/\nvoid sqlite3_free_table(\n  char **azResult            /* Result returned from sqlite3_get_table() */\n){\n  if( azResult ){\n    int i, n;\n    azResult--;\n    assert( azResult!=0 );\n    n = SQLITE_PTR_TO_INT(azResult[0]);\n    for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }\n    sqlite3_free(azResult);\n  }\n}\n\n#endif /* SQLITE_OMIT_GET_TABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/tclsqlite.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** A TCL Interface to SQLite.  Append this file to sqlite3.c and\n** compile the whole thing to build a TCL-enabled version of SQLite.\n**\n** Compile-time options:\n**\n**  -DTCLSH         Add a \"main()\" routine that works as a tclsh.\n**\n**  -DTCLSH_INIT_PROC=name\n**\n**                  Invoke name(interp) to initialize the Tcl interpreter.\n**                  If name(interp) returns a non-NULL string, then run\n**                  that string as a Tcl script to launch the application.\n**                  If name(interp) returns NULL, then run the regular\n**                  tclsh-emulator code.\n*/\n#ifdef TCLSH_INIT_PROC\n# define TCLSH 1\n#endif\n\n/*\n** If requested, include the SQLite compiler options file for MSVC.\n*/\n#if defined(INCLUDE_MSVC_H)\n# include \"msvc.h\"\n#endif\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n# include \"sqlite_tcl.h\"\n#else\n# include \"tcl.h\"\n# ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n# endif\n#endif\n#include <errno.h>\n\n/*\n** Some additional include files are needed if this file is not\n** appended to the amalgamation.\n*/\n#ifndef SQLITE_AMALGAMATION\n# include \"sqlite3.h\"\n# include <stdlib.h>\n# include <string.h>\n# include <assert.h>\n  typedef unsigned char u8;\n#endif\n#include <ctype.h>\n\n/* Used to get the current process ID */\n#if !defined(_WIN32)\n# include <unistd.h>\n# define GETPID getpid\n#elif !defined(_WIN32_WCE)\n# ifndef SQLITE_AMALGAMATION\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n# endif\n# define GETPID (int)GetCurrentProcessId\n#endif\n\n/*\n * Windows needs to know which symbols to export.  Unix does not.\n * BUILD_sqlite should be undefined for Unix.\n */\n#ifdef BUILD_sqlite\n#undef TCL_STORAGE_CLASS\n#define TCL_STORAGE_CLASS DLLEXPORT\n#endif /* BUILD_sqlite */\n\n#define NUM_PREPARED_STMTS 10\n#define MAX_PREPARED_STMTS 100\n\n/* Forward declaration */\ntypedef struct SqliteDb SqliteDb;\n\n/*\n** New SQL functions can be created as TCL scripts.  Each such function\n** is described by an instance of the following structure.\n*/\ntypedef struct SqlFunc SqlFunc;\nstruct SqlFunc {\n  Tcl_Interp *interp;   /* The TCL interpret to execute the function */\n  Tcl_Obj *pScript;     /* The Tcl_Obj representation of the script */\n  SqliteDb *pDb;        /* Database connection that owns this function */\n  int useEvalObjv;      /* True if it is safe to use Tcl_EvalObjv */\n  char *zName;          /* Name of this function */\n  SqlFunc *pNext;       /* Next function on the list of them all */\n};\n\n/*\n** New collation sequences function can be created as TCL scripts.  Each such\n** function is described by an instance of the following structure.\n*/\ntypedef struct SqlCollate SqlCollate;\nstruct SqlCollate {\n  Tcl_Interp *interp;   /* The TCL interpret to execute the function */\n  char *zScript;        /* The script to be run */\n  SqlCollate *pNext;    /* Next function on the list of them all */\n};\n\n/*\n** Prepared statements are cached for faster execution.  Each prepared\n** statement is described by an instance of the following structure.\n*/\ntypedef struct SqlPreparedStmt SqlPreparedStmt;\nstruct SqlPreparedStmt {\n  SqlPreparedStmt *pNext;  /* Next in linked list */\n  SqlPreparedStmt *pPrev;  /* Previous on the list */\n  sqlite3_stmt *pStmt;     /* The prepared statement */\n  int nSql;                /* chars in zSql[] */\n  const char *zSql;        /* Text of the SQL statement */\n  int nParm;               /* Size of apParm array */\n  Tcl_Obj **apParm;        /* Array of referenced object pointers */\n};\n\ntypedef struct IncrblobChannel IncrblobChannel;\n\n/*\n** There is one instance of this structure for each SQLite database\n** that has been opened by the SQLite TCL interface.\n**\n** If this module is built with SQLITE_TEST defined (to create the SQLite\n** testfixture executable), then it may be configured to use either\n** sqlite3_prepare_v2() or sqlite3_prepare() to prepare SQL statements.\n** If SqliteDb.bLegacyPrepare is true, sqlite3_prepare() is used.\n*/\nstruct SqliteDb {\n  sqlite3 *db;               /* The \"real\" database structure. MUST BE FIRST */\n  Tcl_Interp *interp;        /* The interpreter used for this database */\n  char *zBusy;               /* The busy callback routine */\n  char *zCommit;             /* The commit hook callback routine */\n  char *zTrace;              /* The trace callback routine */\n  char *zTraceV2;            /* The trace_v2 callback routine */\n  char *zProfile;            /* The profile callback routine */\n  char *zProgress;           /* The progress callback routine */\n  char *zAuth;               /* The authorization callback routine */\n  int disableAuth;           /* Disable the authorizer if it exists */\n  char *zNull;               /* Text to substitute for an SQL NULL value */\n  SqlFunc *pFunc;            /* List of SQL functions */\n  Tcl_Obj *pUpdateHook;      /* Update hook script (if any) */\n  Tcl_Obj *pPreUpdateHook;   /* Pre-update hook script (if any) */\n  Tcl_Obj *pRollbackHook;    /* Rollback hook script (if any) */\n  Tcl_Obj *pWalHook;         /* WAL hook script (if any) */\n  Tcl_Obj *pUnlockNotify;    /* Unlock notify script (if any) */\n  SqlCollate *pCollate;      /* List of SQL collation functions */\n  int rc;                    /* Return code of most recent sqlite3_exec() */\n  Tcl_Obj *pCollateNeeded;   /* Collation needed script */\n  SqlPreparedStmt *stmtList; /* List of prepared statements*/\n  SqlPreparedStmt *stmtLast; /* Last statement in the list */\n  int maxStmt;               /* The next maximum number of stmtList */\n  int nStmt;                 /* Number of statements in stmtList */\n  IncrblobChannel *pIncrblob;/* Linked list of open incrblob channels */\n  int nStep, nSort, nIndex;  /* Statistics for most recent operation */\n  int nVMStep;               /* Another statistic for most recent operation */\n  int nTransaction;          /* Number of nested [transaction] methods */\n  int openFlags;             /* Flags used to open.  (SQLITE_OPEN_URI) */\n#ifdef SQLITE_TEST\n  int bLegacyPrepare;        /* True to use sqlite3_prepare() */\n#endif\n};\n\nstruct IncrblobChannel {\n  sqlite3_blob *pBlob;      /* sqlite3 blob handle */\n  SqliteDb *pDb;            /* Associated database connection */\n  int iSeek;                /* Current seek offset */\n  Tcl_Channel channel;      /* Channel identifier */\n  IncrblobChannel *pNext;   /* Linked list of all open incrblob channels */\n  IncrblobChannel *pPrev;   /* Linked list of all open incrblob channels */\n};\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n*/\nstatic int strlen30(const char *z){\n  const char *z2 = z;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n\n#ifndef SQLITE_OMIT_INCRBLOB\n/*\n** Close all incrblob channels opened using database connection pDb.\n** This is called when shutting down the database connection.\n*/\nstatic void closeIncrblobChannels(SqliteDb *pDb){\n  IncrblobChannel *p;\n  IncrblobChannel *pNext;\n\n  for(p=pDb->pIncrblob; p; p=pNext){\n    pNext = p->pNext;\n\n    /* Note: Calling unregister here call Tcl_Close on the incrblob channel,\n    ** which deletes the IncrblobChannel structure at *p. So do not\n    ** call Tcl_Free() here.\n    */\n    Tcl_UnregisterChannel(pDb->interp, p->channel);\n  }\n}\n\n/*\n** Close an incremental blob channel.\n*/\nstatic int SQLITE_TCLAPI incrblobClose(\n  ClientData instanceData,\n  Tcl_Interp *interp\n){\n  IncrblobChannel *p = (IncrblobChannel *)instanceData;\n  int rc = sqlite3_blob_close(p->pBlob);\n  sqlite3 *db = p->pDb->db;\n\n  /* Remove the channel from the SqliteDb.pIncrblob list. */\n  if( p->pNext ){\n    p->pNext->pPrev = p->pPrev;\n  }\n  if( p->pPrev ){\n    p->pPrev->pNext = p->pNext;\n  }\n  if( p->pDb->pIncrblob==p ){\n    p->pDb->pIncrblob = p->pNext;\n  }\n\n  /* Free the IncrblobChannel structure */\n  Tcl_Free((char *)p);\n\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char *)sqlite3_errmsg(db), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Read data from an incremental blob channel.\n*/\nstatic int SQLITE_TCLAPI incrblobInput(\n  ClientData instanceData,\n  char *buf,\n  int bufSize,\n  int *errorCodePtr\n){\n  IncrblobChannel *p = (IncrblobChannel *)instanceData;\n  int nRead = bufSize;         /* Number of bytes to read */\n  int nBlob;                   /* Total size of the blob */\n  int rc;                      /* sqlite error code */\n\n  nBlob = sqlite3_blob_bytes(p->pBlob);\n  if( (p->iSeek+nRead)>nBlob ){\n    nRead = nBlob-p->iSeek;\n  }\n  if( nRead<=0 ){\n    return 0;\n  }\n\n  rc = sqlite3_blob_read(p->pBlob, (void *)buf, nRead, p->iSeek);\n  if( rc!=SQLITE_OK ){\n    *errorCodePtr = rc;\n    return -1;\n  }\n\n  p->iSeek += nRead;\n  return nRead;\n}\n\n/*\n** Write data to an incremental blob channel.\n*/\nstatic int SQLITE_TCLAPI incrblobOutput(\n  ClientData instanceData,\n  CONST char *buf,\n  int toWrite,\n  int *errorCodePtr\n){\n  IncrblobChannel *p = (IncrblobChannel *)instanceData;\n  int nWrite = toWrite;        /* Number of bytes to write */\n  int nBlob;                   /* Total size of the blob */\n  int rc;                      /* sqlite error code */\n\n  nBlob = sqlite3_blob_bytes(p->pBlob);\n  if( (p->iSeek+nWrite)>nBlob ){\n    *errorCodePtr = EINVAL;\n    return -1;\n  }\n  if( nWrite<=0 ){\n    return 0;\n  }\n\n  rc = sqlite3_blob_write(p->pBlob, (void *)buf, nWrite, p->iSeek);\n  if( rc!=SQLITE_OK ){\n    *errorCodePtr = EIO;\n    return -1;\n  }\n\n  p->iSeek += nWrite;\n  return nWrite;\n}\n\n/*\n** Seek an incremental blob channel.\n*/\nstatic int SQLITE_TCLAPI incrblobSeek(\n  ClientData instanceData,\n  long offset,\n  int seekMode,\n  int *errorCodePtr\n){\n  IncrblobChannel *p = (IncrblobChannel *)instanceData;\n\n  switch( seekMode ){\n    case SEEK_SET:\n      p->iSeek = offset;\n      break;\n    case SEEK_CUR:\n      p->iSeek += offset;\n      break;\n    case SEEK_END:\n      p->iSeek = sqlite3_blob_bytes(p->pBlob) + offset;\n      break;\n\n    default: assert(!\"Bad seekMode\");\n  }\n\n  return p->iSeek;\n}\n\n\nstatic void SQLITE_TCLAPI incrblobWatch(\n  ClientData instanceData,\n  int mode\n){\n  /* NO-OP */\n}\nstatic int SQLITE_TCLAPI incrblobHandle(\n  ClientData instanceData,\n  int dir,\n  ClientData *hPtr\n){\n  return TCL_ERROR;\n}\n\nstatic Tcl_ChannelType IncrblobChannelType = {\n  \"incrblob\",                        /* typeName                             */\n  TCL_CHANNEL_VERSION_2,             /* version                              */\n  incrblobClose,                     /* closeProc                            */\n  incrblobInput,                     /* inputProc                            */\n  incrblobOutput,                    /* outputProc                           */\n  incrblobSeek,                      /* seekProc                             */\n  0,                                 /* setOptionProc                        */\n  0,                                 /* getOptionProc                        */\n  incrblobWatch,                     /* watchProc (this is a no-op)          */\n  incrblobHandle,                    /* getHandleProc (always returns error) */\n  0,                                 /* close2Proc                           */\n  0,                                 /* blockModeProc                        */\n  0,                                 /* flushProc                            */\n  0,                                 /* handlerProc                          */\n  0,                                 /* wideSeekProc                         */\n};\n\n/*\n** Create a new incrblob channel.\n*/\nstatic int createIncrblobChannel(\n  Tcl_Interp *interp,\n  SqliteDb *pDb,\n  const char *zDb,\n  const char *zTable,\n  const char *zColumn,\n  sqlite_int64 iRow,\n  int isReadonly\n){\n  IncrblobChannel *p;\n  sqlite3 *db = pDb->db;\n  sqlite3_blob *pBlob;\n  int rc;\n  int flags = TCL_READABLE|(isReadonly ? 0 : TCL_WRITABLE);\n\n  /* This variable is used to name the channels: \"incrblob_[incr count]\" */\n  static int count = 0;\n  char zChannel[64];\n\n  rc = sqlite3_blob_open(db, zDb, zTable, zColumn, iRow, !isReadonly, &pBlob);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n\n  p = (IncrblobChannel *)Tcl_Alloc(sizeof(IncrblobChannel));\n  p->iSeek = 0;\n  p->pBlob = pBlob;\n\n  sqlite3_snprintf(sizeof(zChannel), zChannel, \"incrblob_%d\", ++count);\n  p->channel = Tcl_CreateChannel(&IncrblobChannelType, zChannel, p, flags);\n  Tcl_RegisterChannel(interp, p->channel);\n\n  /* Link the new channel into the SqliteDb.pIncrblob list. */\n  p->pNext = pDb->pIncrblob;\n  p->pPrev = 0;\n  if( p->pNext ){\n    p->pNext->pPrev = p;\n  }\n  pDb->pIncrblob = p;\n  p->pDb = pDb;\n\n  Tcl_SetResult(interp, (char *)Tcl_GetChannelName(p->channel), TCL_VOLATILE);\n  return TCL_OK;\n}\n#else  /* else clause for \"#ifndef SQLITE_OMIT_INCRBLOB\" */\n  #define closeIncrblobChannels(pDb)\n#endif\n\n/*\n** Look at the script prefix in pCmd.  We will be executing this script\n** after first appending one or more arguments.  This routine analyzes\n** the script to see if it is safe to use Tcl_EvalObjv() on the script\n** rather than the more general Tcl_EvalEx().  Tcl_EvalObjv() is much\n** faster.\n**\n** Scripts that are safe to use with Tcl_EvalObjv() consists of a\n** command name followed by zero or more arguments with no [...] or $\n** or {...} or ; to be seen anywhere.  Most callback scripts consist\n** of just a single procedure name and they meet this requirement.\n*/\nstatic int safeToUseEvalObjv(Tcl_Interp *interp, Tcl_Obj *pCmd){\n  /* We could try to do something with Tcl_Parse().  But we will instead\n  ** just do a search for forbidden characters.  If any of the forbidden\n  ** characters appear in pCmd, we will report the string as unsafe.\n  */\n  const char *z;\n  int n;\n  z = Tcl_GetStringFromObj(pCmd, &n);\n  while( n-- > 0 ){\n    int c = *(z++);\n    if( c=='$' || c=='[' || c==';' ) return 0;\n  }\n  return 1;\n}\n\n/*\n** Find an SqlFunc structure with the given name.  Or create a new\n** one if an existing one cannot be found.  Return a pointer to the\n** structure.\n*/\nstatic SqlFunc *findSqlFunc(SqliteDb *pDb, const char *zName){\n  SqlFunc *p, *pNew;\n  int nName = strlen30(zName);\n  pNew = (SqlFunc*)Tcl_Alloc( sizeof(*pNew) + nName + 1 );\n  pNew->zName = (char*)&pNew[1];\n  memcpy(pNew->zName, zName, nName+1);\n  for(p=pDb->pFunc; p; p=p->pNext){\n    if( sqlite3_stricmp(p->zName, pNew->zName)==0 ){\n      Tcl_Free((char*)pNew);\n      return p;\n    }\n  }\n  pNew->interp = pDb->interp;\n  pNew->pDb = pDb;\n  pNew->pScript = 0;\n  pNew->pNext = pDb->pFunc;\n  pDb->pFunc = pNew;\n  return pNew;\n}\n\n/*\n** Free a single SqlPreparedStmt object.\n*/\nstatic void dbFreeStmt(SqlPreparedStmt *pStmt){\n#ifdef SQLITE_TEST\n  if( sqlite3_sql(pStmt->pStmt)==0 ){\n    Tcl_Free((char *)pStmt->zSql);\n  }\n#endif\n  sqlite3_finalize(pStmt->pStmt);\n  Tcl_Free((char *)pStmt);\n}\n\n/*\n** Finalize and free a list of prepared statements\n*/\nstatic void flushStmtCache(SqliteDb *pDb){\n  SqlPreparedStmt *pPreStmt;\n  SqlPreparedStmt *pNext;\n\n  for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pNext){\n    pNext = pPreStmt->pNext;\n    dbFreeStmt(pPreStmt);\n  }\n  pDb->nStmt = 0;\n  pDb->stmtLast = 0;\n  pDb->stmtList = 0;\n}\n\n/*\n** TCL calls this procedure when an sqlite3 database command is\n** deleted.\n*/\nstatic void SQLITE_TCLAPI DbDeleteCmd(void *db){\n  SqliteDb *pDb = (SqliteDb*)db;\n  flushStmtCache(pDb);\n  closeIncrblobChannels(pDb);\n  sqlite3_close(pDb->db);\n  while( pDb->pFunc ){\n    SqlFunc *pFunc = pDb->pFunc;\n    pDb->pFunc = pFunc->pNext;\n    assert( pFunc->pDb==pDb );\n    Tcl_DecrRefCount(pFunc->pScript);\n    Tcl_Free((char*)pFunc);\n  }\n  while( pDb->pCollate ){\n    SqlCollate *pCollate = pDb->pCollate;\n    pDb->pCollate = pCollate->pNext;\n    Tcl_Free((char*)pCollate);\n  }\n  if( pDb->zBusy ){\n    Tcl_Free(pDb->zBusy);\n  }\n  if( pDb->zTrace ){\n    Tcl_Free(pDb->zTrace);\n  }\n  if( pDb->zTraceV2 ){\n    Tcl_Free(pDb->zTraceV2);\n  }\n  if( pDb->zProfile ){\n    Tcl_Free(pDb->zProfile);\n  }\n  if( pDb->zAuth ){\n    Tcl_Free(pDb->zAuth);\n  }\n  if( pDb->zNull ){\n    Tcl_Free(pDb->zNull);\n  }\n  if( pDb->pUpdateHook ){\n    Tcl_DecrRefCount(pDb->pUpdateHook);\n  }\n  if( pDb->pPreUpdateHook ){\n    Tcl_DecrRefCount(pDb->pPreUpdateHook);\n  }\n  if( pDb->pRollbackHook ){\n    Tcl_DecrRefCount(pDb->pRollbackHook);\n  }\n  if( pDb->pWalHook ){\n    Tcl_DecrRefCount(pDb->pWalHook);\n  }\n  if( pDb->pCollateNeeded ){\n    Tcl_DecrRefCount(pDb->pCollateNeeded);\n  }\n  Tcl_Free((char*)pDb);\n}\n\n/*\n** This routine is called when a database file is locked while trying\n** to execute SQL.\n*/\nstatic int DbBusyHandler(void *cd, int nTries){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  int rc;\n  char zVal[30];\n\n  sqlite3_snprintf(sizeof(zVal), zVal, \"%d\", nTries);\n  rc = Tcl_VarEval(pDb->interp, pDb->zBusy, \" \", zVal, (char*)0);\n  if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){\n    return 0;\n  }\n  return 1;\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This routine is invoked as the 'progress callback' for the database.\n*/\nstatic int DbProgressHandler(void *cd){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  int rc;\n\n  assert( pDb->zProgress );\n  rc = Tcl_Eval(pDb->interp, pDb->zProgress);\n  if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){\n    return 1;\n  }\n  return 0;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \\\n    !defined(SQLITE_OMIT_DEPRECATED)\n/*\n** This routine is called by the SQLite trace handler whenever a new\n** block of SQL is executed.  The TCL script in pDb->zTrace is executed.\n*/\nstatic void DbTraceHandler(void *cd, const char *zSql){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  Tcl_DString str;\n\n  Tcl_DStringInit(&str);\n  Tcl_DStringAppend(&str, pDb->zTrace, -1);\n  Tcl_DStringAppendElement(&str, zSql);\n  Tcl_Eval(pDb->interp, Tcl_DStringValue(&str));\n  Tcl_DStringFree(&str);\n  Tcl_ResetResult(pDb->interp);\n}\n#endif\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** This routine is called by the SQLite trace_v2 handler whenever a new\n** supported event is generated.  Unsupported event types are ignored.\n** The TCL script in pDb->zTraceV2 is executed, with the arguments for\n** the event appended to it (as list elements).\n*/\nstatic int DbTraceV2Handler(\n  unsigned type, /* One of the SQLITE_TRACE_* event types. */\n  void *cd,      /* The original context data pointer. */\n  void *pd,      /* Primary event data, depends on event type. */\n  void *xd       /* Extra event data, depends on event type. */\n){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  Tcl_Obj *pCmd;\n\n  switch( type ){\n    case SQLITE_TRACE_STMT: {\n      sqlite3_stmt *pStmt = (sqlite3_stmt *)pd;\n      char *zSql = (char *)xd;\n\n      pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1);\n      Tcl_IncrRefCount(pCmd);\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewWideIntObj((Tcl_WideInt)pStmt));\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewStringObj(zSql, -1));\n      Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n      Tcl_DecrRefCount(pCmd);\n      Tcl_ResetResult(pDb->interp);\n      break;\n    }\n    case SQLITE_TRACE_PROFILE: {\n      sqlite3_stmt *pStmt = (sqlite3_stmt *)pd;\n      sqlite3_int64 ns = (sqlite3_int64)xd;\n\n      pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1);\n      Tcl_IncrRefCount(pCmd);\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewWideIntObj((Tcl_WideInt)pStmt));\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewWideIntObj((Tcl_WideInt)ns));\n      Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n      Tcl_DecrRefCount(pCmd);\n      Tcl_ResetResult(pDb->interp);\n      break;\n    }\n    case SQLITE_TRACE_ROW: {\n      sqlite3_stmt *pStmt = (sqlite3_stmt *)pd;\n\n      pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1);\n      Tcl_IncrRefCount(pCmd);\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewWideIntObj((Tcl_WideInt)pStmt));\n      Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n      Tcl_DecrRefCount(pCmd);\n      Tcl_ResetResult(pDb->interp);\n      break;\n    }\n    case SQLITE_TRACE_CLOSE: {\n      sqlite3 *db = (sqlite3 *)pd;\n\n      pCmd = Tcl_NewStringObj(pDb->zTraceV2, -1);\n      Tcl_IncrRefCount(pCmd);\n      Tcl_ListObjAppendElement(pDb->interp, pCmd,\n                               Tcl_NewWideIntObj((Tcl_WideInt)db));\n      Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n      Tcl_DecrRefCount(pCmd);\n      Tcl_ResetResult(pDb->interp);\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \\\n    !defined(SQLITE_OMIT_DEPRECATED)\n/*\n** This routine is called by the SQLite profile handler after a statement\n** SQL has executed.  The TCL script in pDb->zProfile is evaluated.\n*/\nstatic void DbProfileHandler(void *cd, const char *zSql, sqlite_uint64 tm){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  Tcl_DString str;\n  char zTm[100];\n\n  sqlite3_snprintf(sizeof(zTm)-1, zTm, \"%lld\", tm);\n  Tcl_DStringInit(&str);\n  Tcl_DStringAppend(&str, pDb->zProfile, -1);\n  Tcl_DStringAppendElement(&str, zSql);\n  Tcl_DStringAppendElement(&str, zTm);\n  Tcl_Eval(pDb->interp, Tcl_DStringValue(&str));\n  Tcl_DStringFree(&str);\n  Tcl_ResetResult(pDb->interp);\n}\n#endif\n\n/*\n** This routine is called when a transaction is committed.  The\n** TCL script in pDb->zCommit is executed.  If it returns non-zero or\n** if it throws an exception, the transaction is rolled back instead\n** of being committed.\n*/\nstatic int DbCommitHandler(void *cd){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  int rc;\n\n  rc = Tcl_Eval(pDb->interp, pDb->zCommit);\n  if( rc!=TCL_OK || atoi(Tcl_GetStringResult(pDb->interp)) ){\n    return 1;\n  }\n  return 0;\n}\n\nstatic void DbRollbackHandler(void *clientData){\n  SqliteDb *pDb = (SqliteDb*)clientData;\n  assert(pDb->pRollbackHook);\n  if( TCL_OK!=Tcl_EvalObjEx(pDb->interp, pDb->pRollbackHook, 0) ){\n    Tcl_BackgroundError(pDb->interp);\n  }\n}\n\n/*\n** This procedure handles wal_hook callbacks.\n*/\nstatic int DbWalHandler(\n  void *clientData,\n  sqlite3 *db,\n  const char *zDb,\n  int nEntry\n){\n  int ret = SQLITE_OK;\n  Tcl_Obj *p;\n  SqliteDb *pDb = (SqliteDb*)clientData;\n  Tcl_Interp *interp = pDb->interp;\n  assert(pDb->pWalHook);\n\n  assert( db==pDb->db );\n  p = Tcl_DuplicateObj(pDb->pWalHook);\n  Tcl_IncrRefCount(p);\n  Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(zDb, -1));\n  Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(nEntry));\n  if( TCL_OK!=Tcl_EvalObjEx(interp, p, 0)\n   || TCL_OK!=Tcl_GetIntFromObj(interp, Tcl_GetObjResult(interp), &ret)\n  ){\n    Tcl_BackgroundError(interp);\n  }\n  Tcl_DecrRefCount(p);\n\n  return ret;\n}\n\n#if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\nstatic void setTestUnlockNotifyVars(Tcl_Interp *interp, int iArg, int nArg){\n  char zBuf[64];\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", iArg);\n  Tcl_SetVar(interp, \"sqlite_unlock_notify_arg\", zBuf, TCL_GLOBAL_ONLY);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", nArg);\n  Tcl_SetVar(interp, \"sqlite_unlock_notify_argcount\", zBuf, TCL_GLOBAL_ONLY);\n}\n#else\n# define setTestUnlockNotifyVars(x,y,z)\n#endif\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nstatic void DbUnlockNotify(void **apArg, int nArg){\n  int i;\n  for(i=0; i<nArg; i++){\n    const int flags = (TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);\n    SqliteDb *pDb = (SqliteDb *)apArg[i];\n    setTestUnlockNotifyVars(pDb->interp, i, nArg);\n    assert( pDb->pUnlockNotify);\n    Tcl_EvalObjEx(pDb->interp, pDb->pUnlockNotify, flags);\n    Tcl_DecrRefCount(pDb->pUnlockNotify);\n    pDb->pUnlockNotify = 0;\n  }\n}\n#endif\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Pre-update hook callback.\n*/\nstatic void DbPreUpdateHandler(\n  void *p,\n  sqlite3 *db,\n  int op,\n  const char *zDb,\n  const char *zTbl,\n  sqlite_int64 iKey1,\n  sqlite_int64 iKey2\n){\n  SqliteDb *pDb = (SqliteDb *)p;\n  Tcl_Obj *pCmd;\n  static const char *azStr[] = {\"DELETE\", \"INSERT\", \"UPDATE\"};\n\n  assert( (SQLITE_DELETE-1)/9 == 0 );\n  assert( (SQLITE_INSERT-1)/9 == 1 );\n  assert( (SQLITE_UPDATE-1)/9 == 2 );\n  assert( pDb->pPreUpdateHook );\n  assert( db==pDb->db );\n  assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );\n\n  pCmd = Tcl_DuplicateObj(pDb->pPreUpdateHook);\n  Tcl_IncrRefCount(pCmd);\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(azStr[(op-1)/9], -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zDb, -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zTbl, -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(iKey1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(iKey2));\n  Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n  Tcl_DecrRefCount(pCmd);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\nstatic void DbUpdateHandler(\n  void *p,\n  int op,\n  const char *zDb,\n  const char *zTbl,\n  sqlite_int64 rowid\n){\n  SqliteDb *pDb = (SqliteDb *)p;\n  Tcl_Obj *pCmd;\n  static const char *azStr[] = {\"DELETE\", \"INSERT\", \"UPDATE\"};\n\n  assert( (SQLITE_DELETE-1)/9 == 0 );\n  assert( (SQLITE_INSERT-1)/9 == 1 );\n  assert( (SQLITE_UPDATE-1)/9 == 2 );\n\n  assert( pDb->pUpdateHook );\n  assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );\n\n  pCmd = Tcl_DuplicateObj(pDb->pUpdateHook);\n  Tcl_IncrRefCount(pCmd);\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(azStr[(op-1)/9], -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zDb, -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewStringObj(zTbl, -1));\n  Tcl_ListObjAppendElement(0, pCmd, Tcl_NewWideIntObj(rowid));\n  Tcl_EvalObjEx(pDb->interp, pCmd, TCL_EVAL_DIRECT);\n  Tcl_DecrRefCount(pCmd);\n}\n\nstatic void tclCollateNeeded(\n  void *pCtx,\n  sqlite3 *db,\n  int enc,\n  const char *zName\n){\n  SqliteDb *pDb = (SqliteDb *)pCtx;\n  Tcl_Obj *pScript = Tcl_DuplicateObj(pDb->pCollateNeeded);\n  Tcl_IncrRefCount(pScript);\n  Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(zName, -1));\n  Tcl_EvalObjEx(pDb->interp, pScript, 0);\n  Tcl_DecrRefCount(pScript);\n}\n\n/*\n** This routine is called to evaluate an SQL collation function implemented\n** using TCL script.\n*/\nstatic int tclSqlCollate(\n  void *pCtx,\n  int nA,\n  const void *zA,\n  int nB,\n  const void *zB\n){\n  SqlCollate *p = (SqlCollate *)pCtx;\n  Tcl_Obj *pCmd;\n\n  pCmd = Tcl_NewStringObj(p->zScript, -1);\n  Tcl_IncrRefCount(pCmd);\n  Tcl_ListObjAppendElement(p->interp, pCmd, Tcl_NewStringObj(zA, nA));\n  Tcl_ListObjAppendElement(p->interp, pCmd, Tcl_NewStringObj(zB, nB));\n  Tcl_EvalObjEx(p->interp, pCmd, TCL_EVAL_DIRECT);\n  Tcl_DecrRefCount(pCmd);\n  return (atoi(Tcl_GetStringResult(p->interp)));\n}\n\n/*\n** This routine is called to evaluate an SQL function implemented\n** using TCL script.\n*/\nstatic void tclSqlFunc(sqlite3_context *context, int argc, sqlite3_value**argv){\n  SqlFunc *p = sqlite3_user_data(context);\n  Tcl_Obj *pCmd;\n  int i;\n  int rc;\n\n  if( argc==0 ){\n    /* If there are no arguments to the function, call Tcl_EvalObjEx on the\n    ** script object directly.  This allows the TCL compiler to generate\n    ** bytecode for the command on the first invocation and thus make\n    ** subsequent invocations much faster. */\n    pCmd = p->pScript;\n    Tcl_IncrRefCount(pCmd);\n    rc = Tcl_EvalObjEx(p->interp, pCmd, 0);\n    Tcl_DecrRefCount(pCmd);\n  }else{\n    /* If there are arguments to the function, make a shallow copy of the\n    ** script object, lappend the arguments, then evaluate the copy.\n    **\n    ** By \"shallow\" copy, we mean only the outer list Tcl_Obj is duplicated.\n    ** The new Tcl_Obj contains pointers to the original list elements.\n    ** That way, when Tcl_EvalObjv() is run and shimmers the first element\n    ** of the list to tclCmdNameType, that alternate representation will\n    ** be preserved and reused on the next invocation.\n    */\n    Tcl_Obj **aArg;\n    int nArg;\n    if( Tcl_ListObjGetElements(p->interp, p->pScript, &nArg, &aArg) ){\n      sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1);\n      return;\n    }\n    pCmd = Tcl_NewListObj(nArg, aArg);\n    Tcl_IncrRefCount(pCmd);\n    for(i=0; i<argc; i++){\n      sqlite3_value *pIn = argv[i];\n      Tcl_Obj *pVal;\n\n      /* Set pVal to contain the i'th column of this row. */\n      switch( sqlite3_value_type(pIn) ){\n        case SQLITE_BLOB: {\n          int bytes = sqlite3_value_bytes(pIn);\n          pVal = Tcl_NewByteArrayObj(sqlite3_value_blob(pIn), bytes);\n          break;\n        }\n        case SQLITE_INTEGER: {\n          sqlite_int64 v = sqlite3_value_int64(pIn);\n          if( v>=-2147483647 && v<=2147483647 ){\n            pVal = Tcl_NewIntObj((int)v);\n          }else{\n            pVal = Tcl_NewWideIntObj(v);\n          }\n          break;\n        }\n        case SQLITE_FLOAT: {\n          double r = sqlite3_value_double(pIn);\n          pVal = Tcl_NewDoubleObj(r);\n          break;\n        }\n        case SQLITE_NULL: {\n          pVal = Tcl_NewStringObj(p->pDb->zNull, -1);\n          break;\n        }\n        default: {\n          int bytes = sqlite3_value_bytes(pIn);\n          pVal = Tcl_NewStringObj((char *)sqlite3_value_text(pIn), bytes);\n          break;\n        }\n      }\n      rc = Tcl_ListObjAppendElement(p->interp, pCmd, pVal);\n      if( rc ){\n        Tcl_DecrRefCount(pCmd);\n        sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1);\n        return;\n      }\n    }\n    if( !p->useEvalObjv ){\n      /* Tcl_EvalObjEx() will automatically call Tcl_EvalObjv() if pCmd\n      ** is a list without a string representation.  To prevent this from\n      ** happening, make sure pCmd has a valid string representation */\n      Tcl_GetString(pCmd);\n    }\n    rc = Tcl_EvalObjEx(p->interp, pCmd, TCL_EVAL_DIRECT);\n    Tcl_DecrRefCount(pCmd);\n  }\n\n  if( rc && rc!=TCL_RETURN ){\n    sqlite3_result_error(context, Tcl_GetStringResult(p->interp), -1);\n  }else{\n    Tcl_Obj *pVar = Tcl_GetObjResult(p->interp);\n    int n;\n    u8 *data;\n    const char *zType = (pVar->typePtr ? pVar->typePtr->name : \"\");\n    char c = zType[0];\n    if( c=='b' && strcmp(zType,\"bytearray\")==0 && pVar->bytes==0 ){\n      /* Only return a BLOB type if the Tcl variable is a bytearray and\n      ** has no string representation. */\n      data = Tcl_GetByteArrayFromObj(pVar, &n);\n      sqlite3_result_blob(context, data, n, SQLITE_TRANSIENT);\n    }else if( c=='b' && strcmp(zType,\"boolean\")==0 ){\n      Tcl_GetIntFromObj(0, pVar, &n);\n      sqlite3_result_int(context, n);\n    }else if( c=='d' && strcmp(zType,\"double\")==0 ){\n      double r;\n      Tcl_GetDoubleFromObj(0, pVar, &r);\n      sqlite3_result_double(context, r);\n    }else if( (c=='w' && strcmp(zType,\"wideInt\")==0) ||\n          (c=='i' && strcmp(zType,\"int\")==0) ){\n      Tcl_WideInt v;\n      Tcl_GetWideIntFromObj(0, pVar, &v);\n      sqlite3_result_int64(context, v);\n    }else{\n      data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n);\n      sqlite3_result_text(context, (char *)data, n, SQLITE_TRANSIENT);\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n/*\n** This is the authentication function.  It appends the authentication\n** type code and the two arguments to zCmd[] then invokes the result\n** on the interpreter.  The reply is examined to determine if the\n** authentication fails or succeeds.\n*/\nstatic int auth_callback(\n  void *pArg,\n  int code,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3,\n  const char *zArg4\n#ifdef SQLITE_USER_AUTHENTICATION\n  ,const char *zArg5\n#endif\n){\n  const char *zCode;\n  Tcl_DString str;\n  int rc;\n  const char *zReply;\n  /* EVIDENCE-OF: R-38590-62769 The first parameter to the authorizer\n  ** callback is a copy of the third parameter to the\n  ** sqlite3_set_authorizer() interface.\n  */\n  SqliteDb *pDb = (SqliteDb*)pArg;\n  if( pDb->disableAuth ) return SQLITE_OK;\n\n  /* EVIDENCE-OF: R-56518-44310 The second parameter to the callback is an\n  ** integer action code that specifies the particular action to be\n  ** authorized. */\n  switch( code ){\n    case SQLITE_COPY              : zCode=\"SQLITE_COPY\"; break;\n    case SQLITE_CREATE_INDEX      : zCode=\"SQLITE_CREATE_INDEX\"; break;\n    case SQLITE_CREATE_TABLE      : zCode=\"SQLITE_CREATE_TABLE\"; break;\n    case SQLITE_CREATE_TEMP_INDEX : zCode=\"SQLITE_CREATE_TEMP_INDEX\"; break;\n    case SQLITE_CREATE_TEMP_TABLE : zCode=\"SQLITE_CREATE_TEMP_TABLE\"; break;\n    case SQLITE_CREATE_TEMP_TRIGGER: zCode=\"SQLITE_CREATE_TEMP_TRIGGER\"; break;\n    case SQLITE_CREATE_TEMP_VIEW  : zCode=\"SQLITE_CREATE_TEMP_VIEW\"; break;\n    case SQLITE_CREATE_TRIGGER    : zCode=\"SQLITE_CREATE_TRIGGER\"; break;\n    case SQLITE_CREATE_VIEW       : zCode=\"SQLITE_CREATE_VIEW\"; break;\n    case SQLITE_DELETE            : zCode=\"SQLITE_DELETE\"; break;\n    case SQLITE_DROP_INDEX        : zCode=\"SQLITE_DROP_INDEX\"; break;\n    case SQLITE_DROP_TABLE        : zCode=\"SQLITE_DROP_TABLE\"; break;\n    case SQLITE_DROP_TEMP_INDEX   : zCode=\"SQLITE_DROP_TEMP_INDEX\"; break;\n    case SQLITE_DROP_TEMP_TABLE   : zCode=\"SQLITE_DROP_TEMP_TABLE\"; break;\n    case SQLITE_DROP_TEMP_TRIGGER : zCode=\"SQLITE_DROP_TEMP_TRIGGER\"; break;\n    case SQLITE_DROP_TEMP_VIEW    : zCode=\"SQLITE_DROP_TEMP_VIEW\"; break;\n    case SQLITE_DROP_TRIGGER      : zCode=\"SQLITE_DROP_TRIGGER\"; break;\n    case SQLITE_DROP_VIEW         : zCode=\"SQLITE_DROP_VIEW\"; break;\n    case SQLITE_INSERT            : zCode=\"SQLITE_INSERT\"; break;\n    case SQLITE_PRAGMA            : zCode=\"SQLITE_PRAGMA\"; break;\n    case SQLITE_READ              : zCode=\"SQLITE_READ\"; break;\n    case SQLITE_SELECT            : zCode=\"SQLITE_SELECT\"; break;\n    case SQLITE_TRANSACTION       : zCode=\"SQLITE_TRANSACTION\"; break;\n    case SQLITE_UPDATE            : zCode=\"SQLITE_UPDATE\"; break;\n    case SQLITE_ATTACH            : zCode=\"SQLITE_ATTACH\"; break;\n    case SQLITE_DETACH            : zCode=\"SQLITE_DETACH\"; break;\n    case SQLITE_ALTER_TABLE       : zCode=\"SQLITE_ALTER_TABLE\"; break;\n    case SQLITE_REINDEX           : zCode=\"SQLITE_REINDEX\"; break;\n    case SQLITE_ANALYZE           : zCode=\"SQLITE_ANALYZE\"; break;\n    case SQLITE_CREATE_VTABLE     : zCode=\"SQLITE_CREATE_VTABLE\"; break;\n    case SQLITE_DROP_VTABLE       : zCode=\"SQLITE_DROP_VTABLE\"; break;\n    case SQLITE_FUNCTION          : zCode=\"SQLITE_FUNCTION\"; break;\n    case SQLITE_SAVEPOINT         : zCode=\"SQLITE_SAVEPOINT\"; break;\n    case SQLITE_RECURSIVE         : zCode=\"SQLITE_RECURSIVE\"; break;\n    default                       : zCode=\"????\"; break;\n  }\n  Tcl_DStringInit(&str);\n  Tcl_DStringAppend(&str, pDb->zAuth, -1);\n  Tcl_DStringAppendElement(&str, zCode);\n  Tcl_DStringAppendElement(&str, zArg1 ? zArg1 : \"\");\n  Tcl_DStringAppendElement(&str, zArg2 ? zArg2 : \"\");\n  Tcl_DStringAppendElement(&str, zArg3 ? zArg3 : \"\");\n  Tcl_DStringAppendElement(&str, zArg4 ? zArg4 : \"\");\n#ifdef SQLITE_USER_AUTHENTICATION\n  Tcl_DStringAppendElement(&str, zArg5 ? zArg5 : \"\");\n#endif\n  rc = Tcl_GlobalEval(pDb->interp, Tcl_DStringValue(&str));\n  Tcl_DStringFree(&str);\n  zReply = rc==TCL_OK ? Tcl_GetStringResult(pDb->interp) : \"SQLITE_DENY\";\n  if( strcmp(zReply,\"SQLITE_OK\")==0 ){\n    rc = SQLITE_OK;\n  }else if( strcmp(zReply,\"SQLITE_DENY\")==0 ){\n    rc = SQLITE_DENY;\n  }else if( strcmp(zReply,\"SQLITE_IGNORE\")==0 ){\n    rc = SQLITE_IGNORE;\n  }else{\n    rc = 999;\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_AUTHORIZATION */\n\n/*\n** This routine reads a line of text from FILE in, stores\n** the text in memory obtained from malloc() and returns a pointer\n** to the text.  NULL is returned at end of file, or if malloc()\n** fails.\n**\n** The interface is like \"readline\" but no command-line editing\n** is done.\n**\n** copied from shell.c from '.import' command\n*/\nstatic char *local_getline(char *zPrompt, FILE *in){\n  char *zLine;\n  int nLine;\n  int n;\n\n  nLine = 100;\n  zLine = malloc( nLine );\n  if( zLine==0 ) return 0;\n  n = 0;\n  while( 1 ){\n    if( n+100>nLine ){\n      nLine = nLine*2 + 100;\n      zLine = realloc(zLine, nLine);\n      if( zLine==0 ) return 0;\n    }\n    if( fgets(&zLine[n], nLine - n, in)==0 ){\n      if( n==0 ){\n        free(zLine);\n        return 0;\n      }\n      zLine[n] = 0;\n      break;\n    }\n    while( zLine[n] ){ n++; }\n    if( n>0 && zLine[n-1]=='\\n' ){\n      n--;\n      zLine[n] = 0;\n      break;\n    }\n  }\n  zLine = realloc( zLine, n+1 );\n  return zLine;\n}\n\n\n/*\n** This function is part of the implementation of the command:\n**\n**   $db transaction [-deferred|-immediate|-exclusive] SCRIPT\n**\n** It is invoked after evaluating the script SCRIPT to commit or rollback\n** the transaction or savepoint opened by the [transaction] command.\n*/\nstatic int SQLITE_TCLAPI DbTransPostCmd(\n  ClientData data[],                   /* data[0] is the Sqlite3Db* for $db */\n  Tcl_Interp *interp,                  /* Tcl interpreter */\n  int result                           /* Result of evaluating SCRIPT */\n){\n  static const char *const azEnd[] = {\n    \"RELEASE _tcl_transaction\",        /* rc==TCL_ERROR, nTransaction!=0 */\n    \"COMMIT\",                          /* rc!=TCL_ERROR, nTransaction==0 */\n    \"ROLLBACK TO _tcl_transaction ; RELEASE _tcl_transaction\",\n    \"ROLLBACK\"                         /* rc==TCL_ERROR, nTransaction==0 */\n  };\n  SqliteDb *pDb = (SqliteDb*)data[0];\n  int rc = result;\n  const char *zEnd;\n\n  pDb->nTransaction--;\n  zEnd = azEnd[(rc==TCL_ERROR)*2 + (pDb->nTransaction==0)];\n\n  pDb->disableAuth++;\n  if( sqlite3_exec(pDb->db, zEnd, 0, 0, 0) ){\n      /* This is a tricky scenario to handle. The most likely cause of an\n      ** error is that the exec() above was an attempt to commit the\n      ** top-level transaction that returned SQLITE_BUSY. Or, less likely,\n      ** that an IO-error has occurred. In either case, throw a Tcl exception\n      ** and try to rollback the transaction.\n      **\n      ** But it could also be that the user executed one or more BEGIN,\n      ** COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing\n      ** this method's logic. Not clear how this would be best handled.\n      */\n    if( rc!=TCL_ERROR ){\n      Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0);\n      rc = TCL_ERROR;\n    }\n    sqlite3_exec(pDb->db, \"ROLLBACK\", 0, 0, 0);\n  }\n  pDb->disableAuth--;\n\n  return rc;\n}\n\n/*\n** Unless SQLITE_TEST is defined, this function is a simple wrapper around\n** sqlite3_prepare_v2(). If SQLITE_TEST is defined, then it uses either\n** sqlite3_prepare_v2() or legacy interface sqlite3_prepare(), depending\n** on whether or not the [db_use_legacy_prepare] command has been used to\n** configure the connection.\n*/\nstatic int dbPrepare(\n  SqliteDb *pDb,                  /* Database object */\n  const char *zSql,               /* SQL to compile */\n  sqlite3_stmt **ppStmt,          /* OUT: Prepared statement */\n  const char **pzOut              /* OUT: Pointer to next SQL statement */\n){\n  unsigned int prepFlags = 0;\n#ifdef SQLITE_TEST\n  if( pDb->bLegacyPrepare ){\n    return sqlite3_prepare(pDb->db, zSql, -1, ppStmt, pzOut);\n  }\n#endif\n  /* If the statement cache is large, use the SQLITE_PREPARE_PERSISTENT\n  ** flags, which uses less lookaside memory.  But if the cache is small,\n  ** omit that flag to make full use of lookaside */\n  if( pDb->maxStmt>5 ) prepFlags = SQLITE_PREPARE_PERSISTENT;\n\n  return sqlite3_prepare_v3(pDb->db, zSql, -1, prepFlags, ppStmt, pzOut);\n}\n\n/*\n** Search the cache for a prepared-statement object that implements the\n** first SQL statement in the buffer pointed to by parameter zIn. If\n** no such prepared-statement can be found, allocate and prepare a new\n** one. In either case, bind the current values of the relevant Tcl\n** variables to any $var, :var or @var variables in the statement. Before\n** returning, set *ppPreStmt to point to the prepared-statement object.\n**\n** Output parameter *pzOut is set to point to the next SQL statement in\n** buffer zIn, or to the '\\0' byte at the end of zIn if there is no\n** next statement.\n**\n** If successful, TCL_OK is returned. Otherwise, TCL_ERROR is returned\n** and an error message loaded into interpreter pDb->interp.\n*/\nstatic int dbPrepareAndBind(\n  SqliteDb *pDb,                  /* Database object */\n  char const *zIn,                /* SQL to compile */\n  char const **pzOut,             /* OUT: Pointer to next SQL statement */\n  SqlPreparedStmt **ppPreStmt     /* OUT: Object used to cache statement */\n){\n  const char *zSql = zIn;         /* Pointer to first SQL statement in zIn */\n  sqlite3_stmt *pStmt = 0;        /* Prepared statement object */\n  SqlPreparedStmt *pPreStmt;      /* Pointer to cached statement */\n  int nSql;                       /* Length of zSql in bytes */\n  int nVar = 0;                   /* Number of variables in statement */\n  int iParm = 0;                  /* Next free entry in apParm */\n  char c;\n  int i;\n  Tcl_Interp *interp = pDb->interp;\n\n  *ppPreStmt = 0;\n\n  /* Trim spaces from the start of zSql and calculate the remaining length. */\n  while( (c = zSql[0])==' ' || c=='\\t' || c=='\\r' || c=='\\n' ){ zSql++; }\n  nSql = strlen30(zSql);\n\n  for(pPreStmt = pDb->stmtList; pPreStmt; pPreStmt=pPreStmt->pNext){\n    int n = pPreStmt->nSql;\n    if( nSql>=n\n        && memcmp(pPreStmt->zSql, zSql, n)==0\n        && (zSql[n]==0 || zSql[n-1]==';')\n    ){\n      pStmt = pPreStmt->pStmt;\n      *pzOut = &zSql[pPreStmt->nSql];\n\n      /* When a prepared statement is found, unlink it from the\n      ** cache list.  It will later be added back to the beginning\n      ** of the cache list in order to implement LRU replacement.\n      */\n      if( pPreStmt->pPrev ){\n        pPreStmt->pPrev->pNext = pPreStmt->pNext;\n      }else{\n        pDb->stmtList = pPreStmt->pNext;\n      }\n      if( pPreStmt->pNext ){\n        pPreStmt->pNext->pPrev = pPreStmt->pPrev;\n      }else{\n        pDb->stmtLast = pPreStmt->pPrev;\n      }\n      pDb->nStmt--;\n      nVar = sqlite3_bind_parameter_count(pStmt);\n      break;\n    }\n  }\n\n  /* If no prepared statement was found. Compile the SQL text. Also allocate\n  ** a new SqlPreparedStmt structure.  */\n  if( pPreStmt==0 ){\n    int nByte;\n\n    if( SQLITE_OK!=dbPrepare(pDb, zSql, &pStmt, pzOut) ){\n      Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1));\n      return TCL_ERROR;\n    }\n    if( pStmt==0 ){\n      if( SQLITE_OK!=sqlite3_errcode(pDb->db) ){\n        /* A compile-time error in the statement. */\n        Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1));\n        return TCL_ERROR;\n      }else{\n        /* The statement was a no-op.  Continue to the next statement\n        ** in the SQL string.\n        */\n        return TCL_OK;\n      }\n    }\n\n    assert( pPreStmt==0 );\n    nVar = sqlite3_bind_parameter_count(pStmt);\n    nByte = sizeof(SqlPreparedStmt) + nVar*sizeof(Tcl_Obj *);\n    pPreStmt = (SqlPreparedStmt*)Tcl_Alloc(nByte);\n    memset(pPreStmt, 0, nByte);\n\n    pPreStmt->pStmt = pStmt;\n    pPreStmt->nSql = (int)(*pzOut - zSql);\n    pPreStmt->zSql = sqlite3_sql(pStmt);\n    pPreStmt->apParm = (Tcl_Obj **)&pPreStmt[1];\n#ifdef SQLITE_TEST\n    if( pPreStmt->zSql==0 ){\n      char *zCopy = Tcl_Alloc(pPreStmt->nSql + 1);\n      memcpy(zCopy, zSql, pPreStmt->nSql);\n      zCopy[pPreStmt->nSql] = '\\0';\n      pPreStmt->zSql = zCopy;\n    }\n#endif\n  }\n  assert( pPreStmt );\n  assert( strlen30(pPreStmt->zSql)==pPreStmt->nSql );\n  assert( 0==memcmp(pPreStmt->zSql, zSql, pPreStmt->nSql) );\n\n  /* Bind values to parameters that begin with $ or : */\n  for(i=1; i<=nVar; i++){\n    const char *zVar = sqlite3_bind_parameter_name(pStmt, i);\n    if( zVar!=0 && (zVar[0]=='$' || zVar[0]==':' || zVar[0]=='@') ){\n      Tcl_Obj *pVar = Tcl_GetVar2Ex(interp, &zVar[1], 0, 0);\n      if( pVar ){\n        int n;\n        u8 *data;\n        const char *zType = (pVar->typePtr ? pVar->typePtr->name : \"\");\n        c = zType[0];\n        if( zVar[0]=='@' ||\n           (c=='b' && strcmp(zType,\"bytearray\")==0 && pVar->bytes==0) ){\n          /* Load a BLOB type if the Tcl variable is a bytearray and\n          ** it has no string representation or the host\n          ** parameter name begins with \"@\". */\n          data = Tcl_GetByteArrayFromObj(pVar, &n);\n          sqlite3_bind_blob(pStmt, i, data, n, SQLITE_STATIC);\n          Tcl_IncrRefCount(pVar);\n          pPreStmt->apParm[iParm++] = pVar;\n        }else if( c=='b' && strcmp(zType,\"boolean\")==0 ){\n          Tcl_GetIntFromObj(interp, pVar, &n);\n          sqlite3_bind_int(pStmt, i, n);\n        }else if( c=='d' && strcmp(zType,\"double\")==0 ){\n          double r;\n          Tcl_GetDoubleFromObj(interp, pVar, &r);\n          sqlite3_bind_double(pStmt, i, r);\n        }else if( (c=='w' && strcmp(zType,\"wideInt\")==0) ||\n              (c=='i' && strcmp(zType,\"int\")==0) ){\n          Tcl_WideInt v;\n          Tcl_GetWideIntFromObj(interp, pVar, &v);\n          sqlite3_bind_int64(pStmt, i, v);\n        }else{\n          data = (unsigned char *)Tcl_GetStringFromObj(pVar, &n);\n          sqlite3_bind_text(pStmt, i, (char *)data, n, SQLITE_STATIC);\n          Tcl_IncrRefCount(pVar);\n          pPreStmt->apParm[iParm++] = pVar;\n        }\n      }else{\n        sqlite3_bind_null(pStmt, i);\n      }\n    }\n  }\n  pPreStmt->nParm = iParm;\n  *ppPreStmt = pPreStmt;\n\n  return TCL_OK;\n}\n\n/*\n** Release a statement reference obtained by calling dbPrepareAndBind().\n** There should be exactly one call to this function for each call to\n** dbPrepareAndBind().\n**\n** If the discard parameter is non-zero, then the statement is deleted\n** immediately. Otherwise it is added to the LRU list and may be returned\n** by a subsequent call to dbPrepareAndBind().\n*/\nstatic void dbReleaseStmt(\n  SqliteDb *pDb,                  /* Database handle */\n  SqlPreparedStmt *pPreStmt,      /* Prepared statement handle to release */\n  int discard                     /* True to delete (not cache) the pPreStmt */\n){\n  int i;\n\n  /* Free the bound string and blob parameters */\n  for(i=0; i<pPreStmt->nParm; i++){\n    Tcl_DecrRefCount(pPreStmt->apParm[i]);\n  }\n  pPreStmt->nParm = 0;\n\n  if( pDb->maxStmt<=0 || discard ){\n    /* If the cache is turned off, deallocated the statement */\n    dbFreeStmt(pPreStmt);\n  }else{\n    /* Add the prepared statement to the beginning of the cache list. */\n    pPreStmt->pNext = pDb->stmtList;\n    pPreStmt->pPrev = 0;\n    if( pDb->stmtList ){\n     pDb->stmtList->pPrev = pPreStmt;\n    }\n    pDb->stmtList = pPreStmt;\n    if( pDb->stmtLast==0 ){\n      assert( pDb->nStmt==0 );\n      pDb->stmtLast = pPreStmt;\n    }else{\n      assert( pDb->nStmt>0 );\n    }\n    pDb->nStmt++;\n\n    /* If we have too many statement in cache, remove the surplus from\n    ** the end of the cache list.  */\n    while( pDb->nStmt>pDb->maxStmt ){\n      SqlPreparedStmt *pLast = pDb->stmtLast;\n      pDb->stmtLast = pLast->pPrev;\n      pDb->stmtLast->pNext = 0;\n      pDb->nStmt--;\n      dbFreeStmt(pLast);\n    }\n  }\n}\n\n/*\n** Structure used with dbEvalXXX() functions:\n**\n**   dbEvalInit()\n**   dbEvalStep()\n**   dbEvalFinalize()\n**   dbEvalRowInfo()\n**   dbEvalColumnValue()\n*/\ntypedef struct DbEvalContext DbEvalContext;\nstruct DbEvalContext {\n  SqliteDb *pDb;                  /* Database handle */\n  Tcl_Obj *pSql;                  /* Object holding string zSql */\n  const char *zSql;               /* Remaining SQL to execute */\n  SqlPreparedStmt *pPreStmt;      /* Current statement */\n  int nCol;                       /* Number of columns returned by pStmt */\n  int evalFlags;                  /* Flags used */\n  Tcl_Obj *pArray;                /* Name of array variable */\n  Tcl_Obj **apColName;            /* Array of column names */\n};\n\n#define SQLITE_EVAL_WITHOUTNULLS  0x00001  /* Unset array(*) for NULL */\n\n/*\n** Release any cache of column names currently held as part of\n** the DbEvalContext structure passed as the first argument.\n*/\nstatic void dbReleaseColumnNames(DbEvalContext *p){\n  if( p->apColName ){\n    int i;\n    for(i=0; i<p->nCol; i++){\n      Tcl_DecrRefCount(p->apColName[i]);\n    }\n    Tcl_Free((char *)p->apColName);\n    p->apColName = 0;\n  }\n  p->nCol = 0;\n}\n\n/*\n** Initialize a DbEvalContext structure.\n**\n** If pArray is not NULL, then it contains the name of a Tcl array\n** variable. The \"*\" member of this array is set to a list containing\n** the names of the columns returned by the statement as part of each\n** call to dbEvalStep(), in order from left to right. e.g. if the names\n** of the returned columns are a, b and c, it does the equivalent of the\n** tcl command:\n**\n**     set ${pArray}(*) {a b c}\n*/\nstatic void dbEvalInit(\n  DbEvalContext *p,               /* Pointer to structure to initialize */\n  SqliteDb *pDb,                  /* Database handle */\n  Tcl_Obj *pSql,                  /* Object containing SQL script */\n  Tcl_Obj *pArray,                /* Name of Tcl array to set (*) element of */\n  int evalFlags                   /* Flags controlling evaluation */\n){\n  memset(p, 0, sizeof(DbEvalContext));\n  p->pDb = pDb;\n  p->zSql = Tcl_GetString(pSql);\n  p->pSql = pSql;\n  Tcl_IncrRefCount(pSql);\n  if( pArray ){\n    p->pArray = pArray;\n    Tcl_IncrRefCount(pArray);\n  }\n  p->evalFlags = evalFlags;\n}\n\n/*\n** Obtain information about the row that the DbEvalContext passed as the\n** first argument currently points to.\n*/\nstatic void dbEvalRowInfo(\n  DbEvalContext *p,               /* Evaluation context */\n  int *pnCol,                     /* OUT: Number of column names */\n  Tcl_Obj ***papColName           /* OUT: Array of column names */\n){\n  /* Compute column names */\n  if( 0==p->apColName ){\n    sqlite3_stmt *pStmt = p->pPreStmt->pStmt;\n    int i;                        /* Iterator variable */\n    int nCol;                     /* Number of columns returned by pStmt */\n    Tcl_Obj **apColName = 0;      /* Array of column names */\n\n    p->nCol = nCol = sqlite3_column_count(pStmt);\n    if( nCol>0 && (papColName || p->pArray) ){\n      apColName = (Tcl_Obj**)Tcl_Alloc( sizeof(Tcl_Obj*)*nCol );\n      for(i=0; i<nCol; i++){\n        apColName[i] = Tcl_NewStringObj(sqlite3_column_name(pStmt,i), -1);\n        Tcl_IncrRefCount(apColName[i]);\n      }\n      p->apColName = apColName;\n    }\n\n    /* If results are being stored in an array variable, then create\n    ** the array(*) entry for that array\n    */\n    if( p->pArray ){\n      Tcl_Interp *interp = p->pDb->interp;\n      Tcl_Obj *pColList = Tcl_NewObj();\n      Tcl_Obj *pStar = Tcl_NewStringObj(\"*\", -1);\n\n      for(i=0; i<nCol; i++){\n        Tcl_ListObjAppendElement(interp, pColList, apColName[i]);\n      }\n      Tcl_IncrRefCount(pStar);\n      Tcl_ObjSetVar2(interp, p->pArray, pStar, pColList, 0);\n      Tcl_DecrRefCount(pStar);\n    }\n  }\n\n  if( papColName ){\n    *papColName = p->apColName;\n  }\n  if( pnCol ){\n    *pnCol = p->nCol;\n  }\n}\n\n/*\n** Return one of TCL_OK, TCL_BREAK or TCL_ERROR. If TCL_ERROR is\n** returned, then an error message is stored in the interpreter before\n** returning.\n**\n** A return value of TCL_OK means there is a row of data available. The\n** data may be accessed using dbEvalRowInfo() and dbEvalColumnValue(). This\n** is analogous to a return of SQLITE_ROW from sqlite3_step(). If TCL_BREAK\n** is returned, then the SQL script has finished executing and there are\n** no further rows available. This is similar to SQLITE_DONE.\n*/\nstatic int dbEvalStep(DbEvalContext *p){\n  const char *zPrevSql = 0;       /* Previous value of p->zSql */\n\n  while( p->zSql[0] || p->pPreStmt ){\n    int rc;\n    if( p->pPreStmt==0 ){\n      zPrevSql = (p->zSql==zPrevSql ? 0 : p->zSql);\n      rc = dbPrepareAndBind(p->pDb, p->zSql, &p->zSql, &p->pPreStmt);\n      if( rc!=TCL_OK ) return rc;\n    }else{\n      int rcs;\n      SqliteDb *pDb = p->pDb;\n      SqlPreparedStmt *pPreStmt = p->pPreStmt;\n      sqlite3_stmt *pStmt = pPreStmt->pStmt;\n\n      rcs = sqlite3_step(pStmt);\n      if( rcs==SQLITE_ROW ){\n        return TCL_OK;\n      }\n      if( p->pArray ){\n        dbEvalRowInfo(p, 0, 0);\n      }\n      rcs = sqlite3_reset(pStmt);\n\n      pDb->nStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_FULLSCAN_STEP,1);\n      pDb->nSort = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_SORT,1);\n      pDb->nIndex = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_AUTOINDEX,1);\n      pDb->nVMStep = sqlite3_stmt_status(pStmt,SQLITE_STMTSTATUS_VM_STEP,1);\n      dbReleaseColumnNames(p);\n      p->pPreStmt = 0;\n\n      if( rcs!=SQLITE_OK ){\n        /* If a run-time error occurs, report the error and stop reading\n        ** the SQL.  */\n        dbReleaseStmt(pDb, pPreStmt, 1);\n#if SQLITE_TEST\n        if( p->pDb->bLegacyPrepare && rcs==SQLITE_SCHEMA && zPrevSql ){\n          /* If the runtime error was an SQLITE_SCHEMA, and the database\n          ** handle is configured to use the legacy sqlite3_prepare()\n          ** interface, retry prepare()/step() on the same SQL statement.\n          ** This only happens once. If there is a second SQLITE_SCHEMA\n          ** error, the error will be returned to the caller. */\n          p->zSql = zPrevSql;\n          continue;\n        }\n#endif\n        Tcl_SetObjResult(pDb->interp,\n                         Tcl_NewStringObj(sqlite3_errmsg(pDb->db), -1));\n        return TCL_ERROR;\n      }else{\n        dbReleaseStmt(pDb, pPreStmt, 0);\n      }\n    }\n  }\n\n  /* Finished */\n  return TCL_BREAK;\n}\n\n/*\n** Free all resources currently held by the DbEvalContext structure passed\n** as the first argument. There should be exactly one call to this function\n** for each call to dbEvalInit().\n*/\nstatic void dbEvalFinalize(DbEvalContext *p){\n  if( p->pPreStmt ){\n    sqlite3_reset(p->pPreStmt->pStmt);\n    dbReleaseStmt(p->pDb, p->pPreStmt, 0);\n    p->pPreStmt = 0;\n  }\n  if( p->pArray ){\n    Tcl_DecrRefCount(p->pArray);\n    p->pArray = 0;\n  }\n  Tcl_DecrRefCount(p->pSql);\n  dbReleaseColumnNames(p);\n}\n\n/*\n** Return a pointer to a Tcl_Obj structure with ref-count 0 that contains\n** the value for the iCol'th column of the row currently pointed to by\n** the DbEvalContext structure passed as the first argument.\n*/\nstatic Tcl_Obj *dbEvalColumnValue(DbEvalContext *p, int iCol){\n  sqlite3_stmt *pStmt = p->pPreStmt->pStmt;\n  switch( sqlite3_column_type(pStmt, iCol) ){\n    case SQLITE_BLOB: {\n      int bytes = sqlite3_column_bytes(pStmt, iCol);\n      const char *zBlob = sqlite3_column_blob(pStmt, iCol);\n      if( !zBlob ) bytes = 0;\n      return Tcl_NewByteArrayObj((u8*)zBlob, bytes);\n    }\n    case SQLITE_INTEGER: {\n      sqlite_int64 v = sqlite3_column_int64(pStmt, iCol);\n      if( v>=-2147483647 && v<=2147483647 ){\n        return Tcl_NewIntObj((int)v);\n      }else{\n        return Tcl_NewWideIntObj(v);\n      }\n    }\n    case SQLITE_FLOAT: {\n      return Tcl_NewDoubleObj(sqlite3_column_double(pStmt, iCol));\n    }\n    case SQLITE_NULL: {\n      return Tcl_NewStringObj(p->pDb->zNull, -1);\n    }\n  }\n\n  return Tcl_NewStringObj((char*)sqlite3_column_text(pStmt, iCol), -1);\n}\n\n/*\n** If using Tcl version 8.6 or greater, use the NR functions to avoid\n** recursive evalution of scripts by the [db eval] and [db trans]\n** commands. Even if the headers used while compiling the extension\n** are 8.6 or newer, the code still tests the Tcl version at runtime.\n** This allows stubs-enabled builds to be used with older Tcl libraries.\n*/\n#if TCL_MAJOR_VERSION>8 || (TCL_MAJOR_VERSION==8 && TCL_MINOR_VERSION>=6)\n# define SQLITE_TCL_NRE 1\nstatic int DbUseNre(void){\n  int major, minor;\n  Tcl_GetVersion(&major, &minor, 0, 0);\n  return( (major==8 && minor>=6) || major>8 );\n}\n#else\n/*\n** Compiling using headers earlier than 8.6. In this case NR cannot be\n** used, so DbUseNre() to always return zero. Add #defines for the other\n** Tcl_NRxxx() functions to prevent them from causing compilation errors,\n** even though the only invocations of them are within conditional blocks\n** of the form:\n**\n**   if( DbUseNre() ) { ... }\n*/\n# define SQLITE_TCL_NRE 0\n# define DbUseNre() 0\n# define Tcl_NRAddCallback(a,b,c,d,e,f) (void)0\n# define Tcl_NREvalObj(a,b,c) 0\n# define Tcl_NRCreateCommand(a,b,c,d,e,f) (void)0\n#endif\n\n/*\n** This function is part of the implementation of the command:\n**\n**   $db eval SQL ?ARRAYNAME? SCRIPT\n*/\nstatic int SQLITE_TCLAPI DbEvalNextCmd(\n  ClientData data[],                   /* data[0] is the (DbEvalContext*) */\n  Tcl_Interp *interp,                  /* Tcl interpreter */\n  int result                           /* Result so far */\n){\n  int rc = result;                     /* Return code */\n\n  /* The first element of the data[] array is a pointer to a DbEvalContext\n  ** structure allocated using Tcl_Alloc(). The second element of data[]\n  ** is a pointer to a Tcl_Obj containing the script to run for each row\n  ** returned by the queries encapsulated in data[0]. */\n  DbEvalContext *p = (DbEvalContext *)data[0];\n  Tcl_Obj *pScript = (Tcl_Obj *)data[1];\n  Tcl_Obj *pArray = p->pArray;\n\n  while( (rc==TCL_OK || rc==TCL_CONTINUE) && TCL_OK==(rc = dbEvalStep(p)) ){\n    int i;\n    int nCol;\n    Tcl_Obj **apColName;\n    dbEvalRowInfo(p, &nCol, &apColName);\n    for(i=0; i<nCol; i++){\n      if( pArray==0 ){\n        Tcl_ObjSetVar2(interp, apColName[i], 0, dbEvalColumnValue(p,i), 0);\n      }else if( (p->evalFlags & SQLITE_EVAL_WITHOUTNULLS)!=0\n             && sqlite3_column_type(p->pPreStmt->pStmt, i)==SQLITE_NULL \n      ){\n        Tcl_UnsetVar2(interp, Tcl_GetString(pArray), \n                      Tcl_GetString(apColName[i]), 0);\n      }else{\n        Tcl_ObjSetVar2(interp, pArray, apColName[i], dbEvalColumnValue(p,i), 0);\n      }\n    }\n\n    /* The required interpreter variables are now populated with the data\n    ** from the current row. If using NRE, schedule callbacks to evaluate\n    ** script pScript, then to invoke this function again to fetch the next\n    ** row (or clean up if there is no next row or the script throws an\n    ** exception). After scheduling the callbacks, return control to the\n    ** caller.\n    **\n    ** If not using NRE, evaluate pScript directly and continue with the\n    ** next iteration of this while(...) loop.  */\n    if( DbUseNre() ){\n      Tcl_NRAddCallback(interp, DbEvalNextCmd, (void*)p, (void*)pScript, 0, 0);\n      return Tcl_NREvalObj(interp, pScript, 0);\n    }else{\n      rc = Tcl_EvalObjEx(interp, pScript, 0);\n    }\n  }\n\n  Tcl_DecrRefCount(pScript);\n  dbEvalFinalize(p);\n  Tcl_Free((char *)p);\n\n  if( rc==TCL_OK || rc==TCL_BREAK ){\n    Tcl_ResetResult(interp);\n    rc = TCL_OK;\n  }\n  return rc;\n}\n\n/*\n** This function is used by the implementations of the following database\n** handle sub-commands:\n**\n**   $db update_hook ?SCRIPT?\n**   $db wal_hook ?SCRIPT?\n**   $db commit_hook ?SCRIPT?\n**   $db preupdate hook ?SCRIPT?\n*/\nstatic void DbHookCmd(\n  Tcl_Interp *interp,             /* Tcl interpreter */\n  SqliteDb *pDb,                  /* Database handle */\n  Tcl_Obj *pArg,                  /* SCRIPT argument (or NULL) */\n  Tcl_Obj **ppHook                /* Pointer to member of SqliteDb */\n){\n  sqlite3 *db = pDb->db;\n\n  if( *ppHook ){\n    Tcl_SetObjResult(interp, *ppHook);\n    if( pArg ){\n      Tcl_DecrRefCount(*ppHook);\n      *ppHook = 0;\n    }\n  }\n  if( pArg ){\n    assert( !(*ppHook) );\n    if( Tcl_GetCharLength(pArg)>0 ){\n      *ppHook = pArg;\n      Tcl_IncrRefCount(*ppHook);\n    }\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  sqlite3_preupdate_hook(db, (pDb->pPreUpdateHook?DbPreUpdateHandler:0), pDb);\n#endif\n  sqlite3_update_hook(db, (pDb->pUpdateHook?DbUpdateHandler:0), pDb);\n  sqlite3_rollback_hook(db, (pDb->pRollbackHook?DbRollbackHandler:0), pDb);\n  sqlite3_wal_hook(db, (pDb->pWalHook?DbWalHandler:0), pDb);\n}\n\n/*\n** The \"sqlite\" command below creates a new Tcl command for each\n** connection it opens to an SQLite database.  This routine is invoked\n** whenever one of those connection-specific commands is executed\n** in Tcl.  For example, if you run Tcl code like this:\n**\n**       sqlite3 db1  \"my_database\"\n**       db1 close\n**\n** The first command opens a connection to the \"my_database\" database\n** and calls that connection \"db1\".  The second command causes this\n** subroutine to be invoked.\n*/\nstatic int SQLITE_TCLAPI DbObjCmd(\n  void *cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *const*objv\n){\n  SqliteDb *pDb = (SqliteDb*)cd;\n  int choice;\n  int rc = TCL_OK;\n  static const char *DB_strs[] = {\n    \"authorizer\",         \"backup\",            \"busy\",\n    \"cache\",              \"changes\",           \"close\",\n    \"collate\",            \"collation_needed\",  \"commit_hook\",\n    \"complete\",           \"copy\",              \"enable_load_extension\",\n    \"errorcode\",          \"eval\",              \"exists\",\n    \"function\",           \"incrblob\",          \"interrupt\",\n    \"last_insert_rowid\",  \"nullvalue\",         \"onecolumn\",\n    \"preupdate\",          \"profile\",           \"progress\",\n    \"rekey\",              \"restore\",           \"rollback_hook\",\n    \"status\",             \"timeout\",           \"total_changes\",\n    \"trace\",              \"trace_v2\",          \"transaction\",\n    \"unlock_notify\",      \"update_hook\",       \"version\",\n    \"wal_hook\",\n    0\n  };\n  enum DB_enum {\n    DB_AUTHORIZER,        DB_BACKUP,           DB_BUSY,\n    DB_CACHE,             DB_CHANGES,          DB_CLOSE,\n    DB_COLLATE,           DB_COLLATION_NEEDED, DB_COMMIT_HOOK,\n    DB_COMPLETE,          DB_COPY,             DB_ENABLE_LOAD_EXTENSION,\n    DB_ERRORCODE,         DB_EVAL,             DB_EXISTS,\n    DB_FUNCTION,          DB_INCRBLOB,         DB_INTERRUPT,\n    DB_LAST_INSERT_ROWID, DB_NULLVALUE,        DB_ONECOLUMN,\n    DB_PREUPDATE,         DB_PROFILE,          DB_PROGRESS,\n    DB_REKEY,             DB_RESTORE,          DB_ROLLBACK_HOOK,\n    DB_STATUS,            DB_TIMEOUT,          DB_TOTAL_CHANGES,\n    DB_TRACE,             DB_TRACE_V2,         DB_TRANSACTION,\n    DB_UNLOCK_NOTIFY,     DB_UPDATE_HOOK,      DB_VERSION,\n    DB_WAL_HOOK,\n  };\n  /* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUBCOMMAND ...\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIndexFromObj(interp, objv[1], DB_strs, \"option\", 0, &choice) ){\n    return TCL_ERROR;\n  }\n\n  switch( (enum DB_enum)choice ){\n\n  /*    $db authorizer ?CALLBACK?\n  **\n  ** Invoke the given callback to authorize each SQL operation as it is\n  ** compiled.  5 arguments are appended to the callback before it is\n  ** invoked:\n  **\n  **   (1) The authorization type (ex: SQLITE_CREATE_TABLE, SQLITE_INSERT, ...)\n  **   (2) First descriptive name (depends on authorization type)\n  **   (3) Second descriptive name\n  **   (4) Name of the database (ex: \"main\", \"temp\")\n  **   (5) Name of trigger that is doing the access\n  **\n  ** The callback should return on of the following strings: SQLITE_OK,\n  ** SQLITE_IGNORE, or SQLITE_DENY.  Any other return value is an error.\n  **\n  ** If this method is invoked with no arguments, the current authorization\n  ** callback string is returned.\n  */\n  case DB_AUTHORIZER: {\n#ifdef SQLITE_OMIT_AUTHORIZATION\n    Tcl_AppendResult(interp, \"authorization not available in this build\",\n                     (char*)0);\n    return TCL_ERROR;\n#else\n    if( objc>3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?CALLBACK?\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zAuth ){\n        Tcl_AppendResult(interp, pDb->zAuth, (char*)0);\n      }\n    }else{\n      char *zAuth;\n      int len;\n      if( pDb->zAuth ){\n        Tcl_Free(pDb->zAuth);\n      }\n      zAuth = Tcl_GetStringFromObj(objv[2], &len);\n      if( zAuth && len>0 ){\n        pDb->zAuth = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zAuth, zAuth, len+1);\n      }else{\n        pDb->zAuth = 0;\n      }\n      if( pDb->zAuth ){\n        typedef int (*sqlite3_auth_cb)(\n           void*,int,const char*,const char*,\n           const char*,const char*);\n        pDb->interp = interp;\n        sqlite3_set_authorizer(pDb->db,(sqlite3_auth_cb)auth_callback,pDb);\n      }else{\n        sqlite3_set_authorizer(pDb->db, 0, 0);\n      }\n    }\n#endif\n    break;\n  }\n\n  /*    $db backup ?DATABASE? FILENAME\n  **\n  ** Open or create a database file named FILENAME.  Transfer the\n  ** content of local database DATABASE (default: \"main\") into the\n  ** FILENAME database.\n  */\n  case DB_BACKUP: {\n    const char *zDestFile;\n    const char *zSrcDb;\n    sqlite3 *pDest;\n    sqlite3_backup *pBackup;\n\n    if( objc==3 ){\n      zSrcDb = \"main\";\n      zDestFile = Tcl_GetString(objv[2]);\n    }else if( objc==4 ){\n      zSrcDb = Tcl_GetString(objv[2]);\n      zDestFile = Tcl_GetString(objv[3]);\n    }else{\n      Tcl_WrongNumArgs(interp, 2, objv, \"?DATABASE? FILENAME\");\n      return TCL_ERROR;\n    }\n    rc = sqlite3_open_v2(zDestFile, &pDest,\n               SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE| pDb->openFlags, 0);\n    if( rc!=SQLITE_OK ){\n      Tcl_AppendResult(interp, \"cannot open target database: \",\n           sqlite3_errmsg(pDest), (char*)0);\n      sqlite3_close(pDest);\n      return TCL_ERROR;\n    }\n    pBackup = sqlite3_backup_init(pDest, \"main\", pDb->db, zSrcDb);\n    if( pBackup==0 ){\n      Tcl_AppendResult(interp, \"backup failed: \",\n           sqlite3_errmsg(pDest), (char*)0);\n      sqlite3_close(pDest);\n      return TCL_ERROR;\n    }\n    while(  (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = TCL_OK;\n    }else{\n      Tcl_AppendResult(interp, \"backup failed: \",\n           sqlite3_errmsg(pDest), (char*)0);\n      rc = TCL_ERROR;\n    }\n    sqlite3_close(pDest);\n    break;\n  }\n\n  /*    $db busy ?CALLBACK?\n  **\n  ** Invoke the given callback if an SQL statement attempts to open\n  ** a locked database file.\n  */\n  case DB_BUSY: {\n    if( objc>3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"CALLBACK\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zBusy ){\n        Tcl_AppendResult(interp, pDb->zBusy, (char*)0);\n      }\n    }else{\n      char *zBusy;\n      int len;\n      if( pDb->zBusy ){\n        Tcl_Free(pDb->zBusy);\n      }\n      zBusy = Tcl_GetStringFromObj(objv[2], &len);\n      if( zBusy && len>0 ){\n        pDb->zBusy = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zBusy, zBusy, len+1);\n      }else{\n        pDb->zBusy = 0;\n      }\n      if( pDb->zBusy ){\n        pDb->interp = interp;\n        sqlite3_busy_handler(pDb->db, DbBusyHandler, pDb);\n      }else{\n        sqlite3_busy_handler(pDb->db, 0, 0);\n      }\n    }\n    break;\n  }\n\n  /*     $db cache flush\n  **     $db cache size n\n  **\n  ** Flush the prepared statement cache, or set the maximum number of\n  ** cached statements.\n  */\n  case DB_CACHE: {\n    char *subCmd;\n    int n;\n\n    if( objc<=2 ){\n      Tcl_WrongNumArgs(interp, 1, objv, \"cache option ?arg?\");\n      return TCL_ERROR;\n    }\n    subCmd = Tcl_GetStringFromObj( objv[2], 0 );\n    if( *subCmd=='f' && strcmp(subCmd,\"flush\")==0 ){\n      if( objc!=3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"flush\");\n        return TCL_ERROR;\n      }else{\n        flushStmtCache( pDb );\n      }\n    }else if( *subCmd=='s' && strcmp(subCmd,\"size\")==0 ){\n      if( objc!=4 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"size n\");\n        return TCL_ERROR;\n      }else{\n        if( TCL_ERROR==Tcl_GetIntFromObj(interp, objv[3], &n) ){\n          Tcl_AppendResult( interp, \"cannot convert \\\"\",\n               Tcl_GetStringFromObj(objv[3],0), \"\\\" to integer\", (char*)0);\n          return TCL_ERROR;\n        }else{\n          if( n<0 ){\n            flushStmtCache( pDb );\n            n = 0;\n          }else if( n>MAX_PREPARED_STMTS ){\n            n = MAX_PREPARED_STMTS;\n          }\n          pDb->maxStmt = n;\n        }\n      }\n    }else{\n      Tcl_AppendResult( interp, \"bad option \\\"\",\n          Tcl_GetStringFromObj(objv[2],0), \"\\\": must be flush or size\",\n          (char*)0);\n      return TCL_ERROR;\n    }\n    break;\n  }\n\n  /*     $db changes\n  **\n  ** Return the number of rows that were modified, inserted, or deleted by\n  ** the most recent INSERT, UPDATE or DELETE statement, not including\n  ** any changes made by trigger programs.\n  */\n  case DB_CHANGES: {\n    Tcl_Obj *pResult;\n    if( objc!=2 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"\");\n      return TCL_ERROR;\n    }\n    pResult = Tcl_GetObjResult(interp);\n    Tcl_SetIntObj(pResult, sqlite3_changes(pDb->db));\n    break;\n  }\n\n  /*    $db close\n  **\n  ** Shutdown the database\n  */\n  case DB_CLOSE: {\n    Tcl_DeleteCommand(interp, Tcl_GetStringFromObj(objv[0], 0));\n    break;\n  }\n\n  /*\n  **     $db collate NAME SCRIPT\n  **\n  ** Create a new SQL collation function called NAME.  Whenever\n  ** that function is called, invoke SCRIPT to evaluate the function.\n  */\n  case DB_COLLATE: {\n    SqlCollate *pCollate;\n    char *zName;\n    char *zScript;\n    int nScript;\n    if( objc!=4 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"NAME SCRIPT\");\n      return TCL_ERROR;\n    }\n    zName = Tcl_GetStringFromObj(objv[2], 0);\n    zScript = Tcl_GetStringFromObj(objv[3], &nScript);\n    pCollate = (SqlCollate*)Tcl_Alloc( sizeof(*pCollate) + nScript + 1 );\n    if( pCollate==0 ) return TCL_ERROR;\n    pCollate->interp = interp;\n    pCollate->pNext = pDb->pCollate;\n    pCollate->zScript = (char*)&pCollate[1];\n    pDb->pCollate = pCollate;\n    memcpy(pCollate->zScript, zScript, nScript+1);\n    if( sqlite3_create_collation(pDb->db, zName, SQLITE_UTF8,\n        pCollate, tclSqlCollate) ){\n      Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE);\n      return TCL_ERROR;\n    }\n    break;\n  }\n\n  /*\n  **     $db collation_needed SCRIPT\n  **\n  ** Create a new SQL collation function called NAME.  Whenever\n  ** that function is called, invoke SCRIPT to evaluate the function.\n  */\n  case DB_COLLATION_NEEDED: {\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"SCRIPT\");\n      return TCL_ERROR;\n    }\n    if( pDb->pCollateNeeded ){\n      Tcl_DecrRefCount(pDb->pCollateNeeded);\n    }\n    pDb->pCollateNeeded = Tcl_DuplicateObj(objv[2]);\n    Tcl_IncrRefCount(pDb->pCollateNeeded);\n    sqlite3_collation_needed(pDb->db, pDb, tclCollateNeeded);\n    break;\n  }\n\n  /*    $db commit_hook ?CALLBACK?\n  **\n  ** Invoke the given callback just before committing every SQL transaction.\n  ** If the callback throws an exception or returns non-zero, then the\n  ** transaction is aborted.  If CALLBACK is an empty string, the callback\n  ** is disabled.\n  */\n  case DB_COMMIT_HOOK: {\n    if( objc>3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?CALLBACK?\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zCommit ){\n        Tcl_AppendResult(interp, pDb->zCommit, (char*)0);\n      }\n    }else{\n      const char *zCommit;\n      int len;\n      if( pDb->zCommit ){\n        Tcl_Free(pDb->zCommit);\n      }\n      zCommit = Tcl_GetStringFromObj(objv[2], &len);\n      if( zCommit && len>0 ){\n        pDb->zCommit = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zCommit, zCommit, len+1);\n      }else{\n        pDb->zCommit = 0;\n      }\n      if( pDb->zCommit ){\n        pDb->interp = interp;\n        sqlite3_commit_hook(pDb->db, DbCommitHandler, pDb);\n      }else{\n        sqlite3_commit_hook(pDb->db, 0, 0);\n      }\n    }\n    break;\n  }\n\n  /*    $db complete SQL\n  **\n  ** Return TRUE if SQL is a complete SQL statement.  Return FALSE if\n  ** additional lines of input are needed.  This is similar to the\n  ** built-in \"info complete\" command of Tcl.\n  */\n  case DB_COMPLETE: {\n#ifndef SQLITE_OMIT_COMPLETE\n    Tcl_Obj *pResult;\n    int isComplete;\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"SQL\");\n      return TCL_ERROR;\n    }\n    isComplete = sqlite3_complete( Tcl_GetStringFromObj(objv[2], 0) );\n    pResult = Tcl_GetObjResult(interp);\n    Tcl_SetBooleanObj(pResult, isComplete);\n#endif\n    break;\n  }\n\n  /*    $db copy conflict-algorithm table filename ?SEPARATOR? ?NULLINDICATOR?\n  **\n  ** Copy data into table from filename, optionally using SEPARATOR\n  ** as column separators.  If a column contains a null string, or the\n  ** value of NULLINDICATOR, a NULL is inserted for the column.\n  ** conflict-algorithm is one of the sqlite conflict algorithms:\n  **    rollback, abort, fail, ignore, replace\n  ** On success, return the number of lines processed, not necessarily same\n  ** as 'db changes' due to conflict-algorithm selected.\n  **\n  ** This code is basically an implementation/enhancement of\n  ** the sqlite3 shell.c \".import\" command.\n  **\n  ** This command usage is equivalent to the sqlite2.x COPY statement,\n  ** which imports file data into a table using the PostgreSQL COPY file format:\n  **   $db copy $conflit_algo $table_name $filename \\t \\\\N\n  */\n  case DB_COPY: {\n    char *zTable;               /* Insert data into this table */\n    char *zFile;                /* The file from which to extract data */\n    char *zConflict;            /* The conflict algorithm to use */\n    sqlite3_stmt *pStmt;        /* A statement */\n    int nCol;                   /* Number of columns in the table */\n    int nByte;                  /* Number of bytes in an SQL string */\n    int i, j;                   /* Loop counters */\n    int nSep;                   /* Number of bytes in zSep[] */\n    int nNull;                  /* Number of bytes in zNull[] */\n    char *zSql;                 /* An SQL statement */\n    char *zLine;                /* A single line of input from the file */\n    char **azCol;               /* zLine[] broken up into columns */\n    const char *zCommit;        /* How to commit changes */\n    FILE *in;                   /* The input file */\n    int lineno = 0;             /* Line number of input file */\n    char zLineNum[80];          /* Line number print buffer */\n    Tcl_Obj *pResult;           /* interp result */\n\n    const char *zSep;\n    const char *zNull;\n    if( objc<5 || objc>7 ){\n      Tcl_WrongNumArgs(interp, 2, objv,\n         \"CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?\");\n      return TCL_ERROR;\n    }\n    if( objc>=6 ){\n      zSep = Tcl_GetStringFromObj(objv[5], 0);\n    }else{\n      zSep = \"\\t\";\n    }\n    if( objc>=7 ){\n      zNull = Tcl_GetStringFromObj(objv[6], 0);\n    }else{\n      zNull = \"\";\n    }\n    zConflict = Tcl_GetStringFromObj(objv[2], 0);\n    zTable = Tcl_GetStringFromObj(objv[3], 0);\n    zFile = Tcl_GetStringFromObj(objv[4], 0);\n    nSep = strlen30(zSep);\n    nNull = strlen30(zNull);\n    if( nSep==0 ){\n      Tcl_AppendResult(interp,\"Error: non-null separator required for copy\",\n                       (char*)0);\n      return TCL_ERROR;\n    }\n    if(strcmp(zConflict, \"rollback\") != 0 &&\n       strcmp(zConflict, \"abort\"   ) != 0 &&\n       strcmp(zConflict, \"fail\"    ) != 0 &&\n       strcmp(zConflict, \"ignore\"  ) != 0 &&\n       strcmp(zConflict, \"replace\" ) != 0 ) {\n      Tcl_AppendResult(interp, \"Error: \\\"\", zConflict,\n            \"\\\", conflict-algorithm must be one of: rollback, \"\n            \"abort, fail, ignore, or replace\", (char*)0);\n      return TCL_ERROR;\n    }\n    zSql = sqlite3_mprintf(\"SELECT * FROM '%q'\", zTable);\n    if( zSql==0 ){\n      Tcl_AppendResult(interp, \"Error: no such table: \", zTable, (char*)0);\n      return TCL_ERROR;\n    }\n    nByte = strlen30(zSql);\n    rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0);\n    sqlite3_free(zSql);\n    if( rc ){\n      Tcl_AppendResult(interp, \"Error: \", sqlite3_errmsg(pDb->db), (char*)0);\n      nCol = 0;\n    }else{\n      nCol = sqlite3_column_count(pStmt);\n    }\n    sqlite3_finalize(pStmt);\n    if( nCol==0 ) {\n      return TCL_ERROR;\n    }\n    zSql = malloc( nByte + 50 + nCol*2 );\n    if( zSql==0 ) {\n      Tcl_AppendResult(interp, \"Error: can't malloc()\", (char*)0);\n      return TCL_ERROR;\n    }\n    sqlite3_snprintf(nByte+50, zSql, \"INSERT OR %q INTO '%q' VALUES(?\",\n         zConflict, zTable);\n    j = strlen30(zSql);\n    for(i=1; i<nCol; i++){\n      zSql[j++] = ',';\n      zSql[j++] = '?';\n    }\n    zSql[j++] = ')';\n    zSql[j] = 0;\n    rc = sqlite3_prepare(pDb->db, zSql, -1, &pStmt, 0);\n    free(zSql);\n    if( rc ){\n      Tcl_AppendResult(interp, \"Error: \", sqlite3_errmsg(pDb->db), (char*)0);\n      sqlite3_finalize(pStmt);\n      return TCL_ERROR;\n    }\n    in = fopen(zFile, \"rb\");\n    if( in==0 ){\n      Tcl_AppendResult(interp, \"Error: cannot open file: \", zFile, (char*)0);\n      sqlite3_finalize(pStmt);\n      return TCL_ERROR;\n    }\n    azCol = malloc( sizeof(azCol[0])*(nCol+1) );\n    if( azCol==0 ) {\n      Tcl_AppendResult(interp, \"Error: can't malloc()\", (char*)0);\n      fclose(in);\n      return TCL_ERROR;\n    }\n    (void)sqlite3_exec(pDb->db, \"BEGIN\", 0, 0, 0);\n    zCommit = \"COMMIT\";\n    while( (zLine = local_getline(0, in))!=0 ){\n      char *z;\n      lineno++;\n      azCol[0] = zLine;\n      for(i=0, z=zLine; *z; z++){\n        if( *z==zSep[0] && strncmp(z, zSep, nSep)==0 ){\n          *z = 0;\n          i++;\n          if( i<nCol ){\n            azCol[i] = &z[nSep];\n            z += nSep-1;\n          }\n        }\n      }\n      if( i+1!=nCol ){\n        char *zErr;\n        int nErr = strlen30(zFile) + 200;\n        zErr = malloc(nErr);\n        if( zErr ){\n          sqlite3_snprintf(nErr, zErr,\n             \"Error: %s line %d: expected %d columns of data but found %d\",\n             zFile, lineno, nCol, i+1);\n          Tcl_AppendResult(interp, zErr, (char*)0);\n          free(zErr);\n        }\n        zCommit = \"ROLLBACK\";\n        break;\n      }\n      for(i=0; i<nCol; i++){\n        /* check for null data, if so, bind as null */\n        if( (nNull>0 && strcmp(azCol[i], zNull)==0)\n          || strlen30(azCol[i])==0\n        ){\n          sqlite3_bind_null(pStmt, i+1);\n        }else{\n          sqlite3_bind_text(pStmt, i+1, azCol[i], -1, SQLITE_STATIC);\n        }\n      }\n      sqlite3_step(pStmt);\n      rc = sqlite3_reset(pStmt);\n      free(zLine);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp,\"Error: \", sqlite3_errmsg(pDb->db), (char*)0);\n        zCommit = \"ROLLBACK\";\n        break;\n      }\n    }\n    free(azCol);\n    fclose(in);\n    sqlite3_finalize(pStmt);\n    (void)sqlite3_exec(pDb->db, zCommit, 0, 0, 0);\n\n    if( zCommit[0] == 'C' ){\n      /* success, set result as number of lines processed */\n      pResult = Tcl_GetObjResult(interp);\n      Tcl_SetIntObj(pResult, lineno);\n      rc = TCL_OK;\n    }else{\n      /* failure, append lineno where failed */\n      sqlite3_snprintf(sizeof(zLineNum), zLineNum,\"%d\",lineno);\n      Tcl_AppendResult(interp,\", failed while processing line: \",zLineNum,\n                       (char*)0);\n      rc = TCL_ERROR;\n    }\n    break;\n  }\n\n  /*\n  **    $db enable_load_extension BOOLEAN\n  **\n  ** Turn the extension loading feature on or off.  It if off by\n  ** default.\n  */\n  case DB_ENABLE_LOAD_EXTENSION: {\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    int onoff;\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"BOOLEAN\");\n      return TCL_ERROR;\n    }\n    if( Tcl_GetBooleanFromObj(interp, objv[2], &onoff) ){\n      return TCL_ERROR;\n    }\n    sqlite3_enable_load_extension(pDb->db, onoff);\n    break;\n#else\n    Tcl_AppendResult(interp, \"extension loading is turned off at compile-time\",\n                     (char*)0);\n    return TCL_ERROR;\n#endif\n  }\n\n  /*\n  **    $db errorcode\n  **\n  ** Return the numeric error code that was returned by the most recent\n  ** call to sqlite3_exec().\n  */\n  case DB_ERRORCODE: {\n    Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_errcode(pDb->db)));\n    break;\n  }\n\n  /*\n  **    $db exists $sql\n  **    $db onecolumn $sql\n  **\n  ** The onecolumn method is the equivalent of:\n  **     lindex [$db eval $sql] 0\n  */\n  case DB_EXISTS:\n  case DB_ONECOLUMN: {\n    Tcl_Obj *pResult = 0;\n    DbEvalContext sEval;\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"SQL\");\n      return TCL_ERROR;\n    }\n\n    dbEvalInit(&sEval, pDb, objv[2], 0, 0);\n    rc = dbEvalStep(&sEval);\n    if( choice==DB_ONECOLUMN ){\n      if( rc==TCL_OK ){\n        pResult = dbEvalColumnValue(&sEval, 0);\n      }else if( rc==TCL_BREAK ){\n        Tcl_ResetResult(interp);\n      }\n    }else if( rc==TCL_BREAK || rc==TCL_OK ){\n      pResult = Tcl_NewBooleanObj(rc==TCL_OK);\n    }\n    dbEvalFinalize(&sEval);\n    if( pResult ) Tcl_SetObjResult(interp, pResult);\n\n    if( rc==TCL_BREAK ){\n      rc = TCL_OK;\n    }\n    break;\n  }\n\n  /*\n  **    $db eval ?options? $sql ?array? ?{  ...code... }?\n  **\n  ** The SQL statement in $sql is evaluated.  For each row, the values are\n  ** placed in elements of the array named \"array\" and ...code... is executed.\n  ** If \"array\" and \"code\" are omitted, then no callback is every invoked.\n  ** If \"array\" is an empty string, then the values are placed in variables\n  ** that have the same name as the fields extracted by the query.\n  */\n  case DB_EVAL: {\n    int evalFlags = 0;\n    const char *zOpt;\n    while( objc>3 && (zOpt = Tcl_GetString(objv[2]))!=0 && zOpt[0]=='-' ){\n      if( strcmp(zOpt, \"-withoutnulls\")==0 ){\n        evalFlags |= SQLITE_EVAL_WITHOUTNULLS;\n      }\n      else{\n        Tcl_AppendResult(interp, \"unknown option: \\\"\", zOpt, \"\\\"\", (void*)0);\n        return TCL_ERROR;\n      }\n      objc--;\n      objv++;\n    }\n    if( objc<3 || objc>5 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \n          \"?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?\");\n      return TCL_ERROR;\n    }\n\n    if( objc==3 ){\n      DbEvalContext sEval;\n      Tcl_Obj *pRet = Tcl_NewObj();\n      Tcl_IncrRefCount(pRet);\n      dbEvalInit(&sEval, pDb, objv[2], 0, 0);\n      while( TCL_OK==(rc = dbEvalStep(&sEval)) ){\n        int i;\n        int nCol;\n        dbEvalRowInfo(&sEval, &nCol, 0);\n        for(i=0; i<nCol; i++){\n          Tcl_ListObjAppendElement(interp, pRet, dbEvalColumnValue(&sEval, i));\n        }\n      }\n      dbEvalFinalize(&sEval);\n      if( rc==TCL_BREAK ){\n        Tcl_SetObjResult(interp, pRet);\n        rc = TCL_OK;\n      }\n      Tcl_DecrRefCount(pRet);\n    }else{\n      ClientData cd2[2];\n      DbEvalContext *p;\n      Tcl_Obj *pArray = 0;\n      Tcl_Obj *pScript;\n\n      if( objc>=5 && *(char *)Tcl_GetString(objv[3]) ){\n        pArray = objv[3];\n      }\n      pScript = objv[objc-1];\n      Tcl_IncrRefCount(pScript);\n\n      p = (DbEvalContext *)Tcl_Alloc(sizeof(DbEvalContext));\n      dbEvalInit(p, pDb, objv[2], pArray, evalFlags);\n\n      cd2[0] = (void *)p;\n      cd2[1] = (void *)pScript;\n      rc = DbEvalNextCmd(cd2, interp, TCL_OK);\n    }\n    break;\n  }\n\n  /*\n  **     $db function NAME [-argcount N] [-deterministic] SCRIPT\n  **\n  ** Create a new SQL function called NAME.  Whenever that function is\n  ** called, invoke SCRIPT to evaluate the function.\n  */\n  case DB_FUNCTION: {\n    int flags = SQLITE_UTF8;\n    SqlFunc *pFunc;\n    Tcl_Obj *pScript;\n    char *zName;\n    int nArg = -1;\n    int i;\n    if( objc<4 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"NAME ?SWITCHES? SCRIPT\");\n      return TCL_ERROR;\n    }\n    for(i=3; i<(objc-1); i++){\n      const char *z = Tcl_GetString(objv[i]);\n      int n = strlen30(z);\n      if( n>2 && strncmp(z, \"-argcount\",n)==0 ){\n        if( i==(objc-2) ){\n          Tcl_AppendResult(interp, \"option requires an argument: \", z,(char*)0);\n          return TCL_ERROR;\n        }\n        if( Tcl_GetIntFromObj(interp, objv[i+1], &nArg) ) return TCL_ERROR;\n        if( nArg<0 ){\n          Tcl_AppendResult(interp, \"number of arguments must be non-negative\",\n                           (char*)0);\n          return TCL_ERROR;\n        }\n        i++;\n      }else\n      if( n>2 && strncmp(z, \"-deterministic\",n)==0 ){\n        flags |= SQLITE_DETERMINISTIC;\n      }else{\n        Tcl_AppendResult(interp, \"bad option \\\"\", z,\n            \"\\\": must be -argcount or -deterministic\", (char*)0\n        );\n        return TCL_ERROR;\n      }\n    }\n\n    pScript = objv[objc-1];\n    zName = Tcl_GetStringFromObj(objv[2], 0);\n    pFunc = findSqlFunc(pDb, zName);\n    if( pFunc==0 ) return TCL_ERROR;\n    if( pFunc->pScript ){\n      Tcl_DecrRefCount(pFunc->pScript);\n    }\n    pFunc->pScript = pScript;\n    Tcl_IncrRefCount(pScript);\n    pFunc->useEvalObjv = safeToUseEvalObjv(interp, pScript);\n    rc = sqlite3_create_function(pDb->db, zName, nArg, flags,\n        pFunc, tclSqlFunc, 0, 0);\n    if( rc!=SQLITE_OK ){\n      rc = TCL_ERROR;\n      Tcl_SetResult(interp, (char *)sqlite3_errmsg(pDb->db), TCL_VOLATILE);\n    }\n    break;\n  }\n\n  /*\n  **     $db incrblob ?-readonly? ?DB? TABLE COLUMN ROWID\n  */\n  case DB_INCRBLOB: {\n#ifdef SQLITE_OMIT_INCRBLOB\n    Tcl_AppendResult(interp, \"incrblob not available in this build\", (char*)0);\n    return TCL_ERROR;\n#else\n    int isReadonly = 0;\n    const char *zDb = \"main\";\n    const char *zTable;\n    const char *zColumn;\n    Tcl_WideInt iRow;\n\n    /* Check for the -readonly option */\n    if( objc>3 && strcmp(Tcl_GetString(objv[2]), \"-readonly\")==0 ){\n      isReadonly = 1;\n    }\n\n    if( objc!=(5+isReadonly) && objc!=(6+isReadonly) ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?-readonly? ?DB? TABLE COLUMN ROWID\");\n      return TCL_ERROR;\n    }\n\n    if( objc==(6+isReadonly) ){\n      zDb = Tcl_GetString(objv[2]);\n    }\n    zTable = Tcl_GetString(objv[objc-3]);\n    zColumn = Tcl_GetString(objv[objc-2]);\n    rc = Tcl_GetWideIntFromObj(interp, objv[objc-1], &iRow);\n\n    if( rc==TCL_OK ){\n      rc = createIncrblobChannel(\n          interp, pDb, zDb, zTable, zColumn, (sqlite3_int64)iRow, isReadonly\n      );\n    }\n#endif\n    break;\n  }\n\n  /*\n  **     $db interrupt\n  **\n  ** Interrupt the execution of the inner-most SQL interpreter.  This\n  ** causes the SQL statement to return an error of SQLITE_INTERRUPT.\n  */\n  case DB_INTERRUPT: {\n    sqlite3_interrupt(pDb->db);\n    break;\n  }\n\n  /*\n  **     $db nullvalue ?STRING?\n  **\n  ** Change text used when a NULL comes back from the database. If ?STRING?\n  ** is not present, then the current string used for NULL is returned.\n  ** If STRING is present, then STRING is returned.\n  **\n  */\n  case DB_NULLVALUE: {\n    if( objc!=2 && objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"NULLVALUE\");\n      return TCL_ERROR;\n    }\n    if( objc==3 ){\n      int len;\n      char *zNull = Tcl_GetStringFromObj(objv[2], &len);\n      if( pDb->zNull ){\n        Tcl_Free(pDb->zNull);\n      }\n      if( zNull && len>0 ){\n        pDb->zNull = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zNull, zNull, len);\n        pDb->zNull[len] = '\\0';\n      }else{\n        pDb->zNull = 0;\n      }\n    }\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(pDb->zNull, -1));\n    break;\n  }\n\n  /*\n  **     $db last_insert_rowid\n  **\n  ** Return an integer which is the ROWID for the most recent insert.\n  */\n  case DB_LAST_INSERT_ROWID: {\n    Tcl_Obj *pResult;\n    Tcl_WideInt rowid;\n    if( objc!=2 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"\");\n      return TCL_ERROR;\n    }\n    rowid = sqlite3_last_insert_rowid(pDb->db);\n    pResult = Tcl_GetObjResult(interp);\n    Tcl_SetWideIntObj(pResult, rowid);\n    break;\n  }\n\n  /*\n  ** The DB_ONECOLUMN method is implemented together with DB_EXISTS.\n  */\n\n  /*    $db progress ?N CALLBACK?\n  **\n  ** Invoke the given callback every N virtual machine opcodes while executing\n  ** queries.\n  */\n  case DB_PROGRESS: {\n    if( objc==2 ){\n      if( pDb->zProgress ){\n        Tcl_AppendResult(interp, pDb->zProgress, (char*)0);\n      }\n    }else if( objc==4 ){\n      char *zProgress;\n      int len;\n      int N;\n      if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &N) ){\n        return TCL_ERROR;\n      };\n      if( pDb->zProgress ){\n        Tcl_Free(pDb->zProgress);\n      }\n      zProgress = Tcl_GetStringFromObj(objv[3], &len);\n      if( zProgress && len>0 ){\n        pDb->zProgress = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zProgress, zProgress, len+1);\n      }else{\n        pDb->zProgress = 0;\n      }\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n      if( pDb->zProgress ){\n        pDb->interp = interp;\n        sqlite3_progress_handler(pDb->db, N, DbProgressHandler, pDb);\n      }else{\n        sqlite3_progress_handler(pDb->db, 0, 0, 0);\n      }\n#endif\n    }else{\n      Tcl_WrongNumArgs(interp, 2, objv, \"N CALLBACK\");\n      return TCL_ERROR;\n    }\n    break;\n  }\n\n  /*    $db profile ?CALLBACK?\n  **\n  ** Make arrangements to invoke the CALLBACK routine after each SQL statement\n  ** that has run.  The text of the SQL and the amount of elapse time are\n  ** appended to CALLBACK before the script is run.\n  */\n  case DB_PROFILE: {\n    if( objc>3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?CALLBACK?\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zProfile ){\n        Tcl_AppendResult(interp, pDb->zProfile, (char*)0);\n      }\n    }else{\n      char *zProfile;\n      int len;\n      if( pDb->zProfile ){\n        Tcl_Free(pDb->zProfile);\n      }\n      zProfile = Tcl_GetStringFromObj(objv[2], &len);\n      if( zProfile && len>0 ){\n        pDb->zProfile = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zProfile, zProfile, len+1);\n      }else{\n        pDb->zProfile = 0;\n      }\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \\\n    !defined(SQLITE_OMIT_DEPRECATED)\n      if( pDb->zProfile ){\n        pDb->interp = interp;\n        sqlite3_profile(pDb->db, DbProfileHandler, pDb);\n      }else{\n        sqlite3_profile(pDb->db, 0, 0);\n      }\n#endif\n    }\n    break;\n  }\n\n  /*\n  **     $db rekey KEY\n  **\n  ** Change the encryption key on the currently open database.\n  */\n  case DB_REKEY: {\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n    int nKey;\n    void *pKey;\n#endif\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"KEY\");\n      return TCL_ERROR;\n    }\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n    pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey);\n    rc = sqlite3_rekey(pDb->db, pKey, nKey);\n    if( rc ){\n      Tcl_AppendResult(interp, sqlite3_errstr(rc), (char*)0);\n      rc = TCL_ERROR;\n    }\n#endif\n    break;\n  }\n\n  /*    $db restore ?DATABASE? FILENAME\n  **\n  ** Open a database file named FILENAME.  Transfer the content\n  ** of FILENAME into the local database DATABASE (default: \"main\").\n  */\n  case DB_RESTORE: {\n    const char *zSrcFile;\n    const char *zDestDb;\n    sqlite3 *pSrc;\n    sqlite3_backup *pBackup;\n    int nTimeout = 0;\n\n    if( objc==3 ){\n      zDestDb = \"main\";\n      zSrcFile = Tcl_GetString(objv[2]);\n    }else if( objc==4 ){\n      zDestDb = Tcl_GetString(objv[2]);\n      zSrcFile = Tcl_GetString(objv[3]);\n    }else{\n      Tcl_WrongNumArgs(interp, 2, objv, \"?DATABASE? FILENAME\");\n      return TCL_ERROR;\n    }\n    rc = sqlite3_open_v2(zSrcFile, &pSrc,\n                         SQLITE_OPEN_READONLY | pDb->openFlags, 0);\n    if( rc!=SQLITE_OK ){\n      Tcl_AppendResult(interp, \"cannot open source database: \",\n           sqlite3_errmsg(pSrc), (char*)0);\n      sqlite3_close(pSrc);\n      return TCL_ERROR;\n    }\n    pBackup = sqlite3_backup_init(pDb->db, zDestDb, pSrc, \"main\");\n    if( pBackup==0 ){\n      Tcl_AppendResult(interp, \"restore failed: \",\n           sqlite3_errmsg(pDb->db), (char*)0);\n      sqlite3_close(pSrc);\n      return TCL_ERROR;\n    }\n    while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK\n              || rc==SQLITE_BUSY ){\n      if( rc==SQLITE_BUSY ){\n        if( nTimeout++ >= 3 ) break;\n        sqlite3_sleep(100);\n      }\n    }\n    sqlite3_backup_finish(pBackup);\n    if( rc==SQLITE_DONE ){\n      rc = TCL_OK;\n    }else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      Tcl_AppendResult(interp, \"restore failed: source database busy\",\n                       (char*)0);\n      rc = TCL_ERROR;\n    }else{\n      Tcl_AppendResult(interp, \"restore failed: \",\n           sqlite3_errmsg(pDb->db), (char*)0);\n      rc = TCL_ERROR;\n    }\n    sqlite3_close(pSrc);\n    break;\n  }\n\n  /*\n  **     $db status (step|sort|autoindex|vmstep)\n  **\n  ** Display SQLITE_STMTSTATUS_FULLSCAN_STEP or\n  ** SQLITE_STMTSTATUS_SORT for the most recent eval.\n  */\n  case DB_STATUS: {\n    int v;\n    const char *zOp;\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"(step|sort|autoindex)\");\n      return TCL_ERROR;\n    }\n    zOp = Tcl_GetString(objv[2]);\n    if( strcmp(zOp, \"step\")==0 ){\n      v = pDb->nStep;\n    }else if( strcmp(zOp, \"sort\")==0 ){\n      v = pDb->nSort;\n    }else if( strcmp(zOp, \"autoindex\")==0 ){\n      v = pDb->nIndex;\n    }else if( strcmp(zOp, \"vmstep\")==0 ){\n      v = pDb->nVMStep;\n    }else{\n      Tcl_AppendResult(interp,\n            \"bad argument: should be autoindex, step, sort or vmstep\",\n            (char*)0);\n      return TCL_ERROR;\n    }\n    Tcl_SetObjResult(interp, Tcl_NewIntObj(v));\n    break;\n  }\n\n  /*\n  **     $db timeout MILLESECONDS\n  **\n  ** Delay for the number of milliseconds specified when a file is locked.\n  */\n  case DB_TIMEOUT: {\n    int ms;\n    if( objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"MILLISECONDS\");\n      return TCL_ERROR;\n    }\n    if( Tcl_GetIntFromObj(interp, objv[2], &ms) ) return TCL_ERROR;\n    sqlite3_busy_timeout(pDb->db, ms);\n    break;\n  }\n\n  /*\n  **     $db total_changes\n  **\n  ** Return the number of rows that were modified, inserted, or deleted\n  ** since the database handle was created.\n  */\n  case DB_TOTAL_CHANGES: {\n    Tcl_Obj *pResult;\n    if( objc!=2 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"\");\n      return TCL_ERROR;\n    }\n    pResult = Tcl_GetObjResult(interp);\n    Tcl_SetIntObj(pResult, sqlite3_total_changes(pDb->db));\n    break;\n  }\n\n  /*    $db trace ?CALLBACK?\n  **\n  ** Make arrangements to invoke the CALLBACK routine for each SQL statement\n  ** that is executed.  The text of the SQL is appended to CALLBACK before\n  ** it is executed.\n  */\n  case DB_TRACE: {\n    if( objc>3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?CALLBACK?\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zTrace ){\n        Tcl_AppendResult(interp, pDb->zTrace, (char*)0);\n      }\n    }else{\n      char *zTrace;\n      int len;\n      if( pDb->zTrace ){\n        Tcl_Free(pDb->zTrace);\n      }\n      zTrace = Tcl_GetStringFromObj(objv[2], &len);\n      if( zTrace && len>0 ){\n        pDb->zTrace = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zTrace, zTrace, len+1);\n      }else{\n        pDb->zTrace = 0;\n      }\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) && \\\n    !defined(SQLITE_OMIT_DEPRECATED)\n      if( pDb->zTrace ){\n        pDb->interp = interp;\n        sqlite3_trace(pDb->db, DbTraceHandler, pDb);\n      }else{\n        sqlite3_trace(pDb->db, 0, 0);\n      }\n#endif\n    }\n    break;\n  }\n\n  /*    $db trace_v2 ?CALLBACK? ?MASK?\n  **\n  ** Make arrangements to invoke the CALLBACK routine for each trace event\n  ** matching the mask that is generated.  The parameters are appended to\n  ** CALLBACK before it is executed.\n  */\n  case DB_TRACE_V2: {\n    if( objc>4 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?CALLBACK? ?MASK?\");\n      return TCL_ERROR;\n    }else if( objc==2 ){\n      if( pDb->zTraceV2 ){\n        Tcl_AppendResult(interp, pDb->zTraceV2, (char*)0);\n      }\n    }else{\n      char *zTraceV2;\n      int len;\n      Tcl_WideInt wMask = 0;\n      if( objc==4 ){\n        static const char *TTYPE_strs[] = {\n          \"statement\", \"profile\", \"row\", \"close\", 0\n        };\n        enum TTYPE_enum {\n          TTYPE_STMT, TTYPE_PROFILE, TTYPE_ROW, TTYPE_CLOSE\n        };\n        int i;\n        if( TCL_OK!=Tcl_ListObjLength(interp, objv[3], &len) ){\n          return TCL_ERROR;\n        }\n        for(i=0; i<len; i++){\n          Tcl_Obj *pObj;\n          int ttype;\n          if( TCL_OK!=Tcl_ListObjIndex(interp, objv[3], i, &pObj) ){\n            return TCL_ERROR;\n          }\n          if( Tcl_GetIndexFromObj(interp, pObj, TTYPE_strs, \"trace type\",\n                                  0, &ttype)!=TCL_OK ){\n            Tcl_WideInt wType;\n            Tcl_Obj *pError = Tcl_DuplicateObj(Tcl_GetObjResult(interp));\n            Tcl_IncrRefCount(pError);\n            if( TCL_OK==Tcl_GetWideIntFromObj(interp, pObj, &wType) ){\n              Tcl_DecrRefCount(pError);\n              wMask |= wType;\n            }else{\n              Tcl_SetObjResult(interp, pError);\n              Tcl_DecrRefCount(pError);\n              return TCL_ERROR;\n            }\n          }else{\n            switch( (enum TTYPE_enum)ttype ){\n              case TTYPE_STMT:    wMask |= SQLITE_TRACE_STMT;    break;\n              case TTYPE_PROFILE: wMask |= SQLITE_TRACE_PROFILE; break;\n              case TTYPE_ROW:     wMask |= SQLITE_TRACE_ROW;     break;\n              case TTYPE_CLOSE:   wMask |= SQLITE_TRACE_CLOSE;   break;\n            }\n          }\n        }\n      }else{\n        wMask = SQLITE_TRACE_STMT; /* use the \"legacy\" default */\n      }\n      if( pDb->zTraceV2 ){\n        Tcl_Free(pDb->zTraceV2);\n      }\n      zTraceV2 = Tcl_GetStringFromObj(objv[2], &len);\n      if( zTraceV2 && len>0 ){\n        pDb->zTraceV2 = Tcl_Alloc( len + 1 );\n        memcpy(pDb->zTraceV2, zTraceV2, len+1);\n      }else{\n        pDb->zTraceV2 = 0;\n      }\n#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)\n      if( pDb->zTraceV2 ){\n        pDb->interp = interp;\n        sqlite3_trace_v2(pDb->db, (unsigned)wMask, DbTraceV2Handler, pDb);\n      }else{\n        sqlite3_trace_v2(pDb->db, 0, 0, 0);\n      }\n#endif\n    }\n    break;\n  }\n\n  /*    $db transaction [-deferred|-immediate|-exclusive] SCRIPT\n  **\n  ** Start a new transaction (if we are not already in the midst of a\n  ** transaction) and execute the TCL script SCRIPT.  After SCRIPT\n  ** completes, either commit the transaction or roll it back if SCRIPT\n  ** throws an exception.  Or if no new transation was started, do nothing.\n  ** pass the exception on up the stack.\n  **\n  ** This command was inspired by Dave Thomas's talk on Ruby at the\n  ** 2005 O'Reilly Open Source Convention (OSCON).\n  */\n  case DB_TRANSACTION: {\n    Tcl_Obj *pScript;\n    const char *zBegin = \"SAVEPOINT _tcl_transaction\";\n    if( objc!=3 && objc!=4 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"[TYPE] SCRIPT\");\n      return TCL_ERROR;\n    }\n\n    if( pDb->nTransaction==0 && objc==4 ){\n      static const char *TTYPE_strs[] = {\n        \"deferred\",   \"exclusive\",  \"immediate\", 0\n      };\n      enum TTYPE_enum {\n        TTYPE_DEFERRED, TTYPE_EXCLUSIVE, TTYPE_IMMEDIATE\n      };\n      int ttype;\n      if( Tcl_GetIndexFromObj(interp, objv[2], TTYPE_strs, \"transaction type\",\n                              0, &ttype) ){\n        return TCL_ERROR;\n      }\n      switch( (enum TTYPE_enum)ttype ){\n        case TTYPE_DEFERRED:    /* no-op */;                 break;\n        case TTYPE_EXCLUSIVE:   zBegin = \"BEGIN EXCLUSIVE\";  break;\n        case TTYPE_IMMEDIATE:   zBegin = \"BEGIN IMMEDIATE\";  break;\n      }\n    }\n    pScript = objv[objc-1];\n\n    /* Run the SQLite BEGIN command to open a transaction or savepoint. */\n    pDb->disableAuth++;\n    rc = sqlite3_exec(pDb->db, zBegin, 0, 0, 0);\n    pDb->disableAuth--;\n    if( rc!=SQLITE_OK ){\n      Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0);\n      return TCL_ERROR;\n    }\n    pDb->nTransaction++;\n\n    /* If using NRE, schedule a callback to invoke the script pScript, then\n    ** a second callback to commit (or rollback) the transaction or savepoint\n    ** opened above. If not using NRE, evaluate the script directly, then\n    ** call function DbTransPostCmd() to commit (or rollback) the transaction\n    ** or savepoint.  */\n    if( DbUseNre() ){\n      Tcl_NRAddCallback(interp, DbTransPostCmd, cd, 0, 0, 0);\n      (void)Tcl_NREvalObj(interp, pScript, 0);\n    }else{\n      rc = DbTransPostCmd(&cd, interp, Tcl_EvalObjEx(interp, pScript, 0));\n    }\n    break;\n  }\n\n  /*\n  **    $db unlock_notify ?script?\n  */\n  case DB_UNLOCK_NOTIFY: {\n#ifndef SQLITE_ENABLE_UNLOCK_NOTIFY\n    Tcl_AppendResult(interp, \"unlock_notify not available in this build\",\n                     (char*)0);\n    rc = TCL_ERROR;\n#else\n    if( objc!=2 && objc!=3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"?SCRIPT?\");\n      rc = TCL_ERROR;\n    }else{\n      void (*xNotify)(void **, int) = 0;\n      void *pNotifyArg = 0;\n\n      if( pDb->pUnlockNotify ){\n        Tcl_DecrRefCount(pDb->pUnlockNotify);\n        pDb->pUnlockNotify = 0;\n      }\n\n      if( objc==3 ){\n        xNotify = DbUnlockNotify;\n        pNotifyArg = (void *)pDb;\n        pDb->pUnlockNotify = objv[2];\n        Tcl_IncrRefCount(pDb->pUnlockNotify);\n      }\n\n      if( sqlite3_unlock_notify(pDb->db, xNotify, pNotifyArg) ){\n        Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0);\n        rc = TCL_ERROR;\n      }\n    }\n#endif\n    break;\n  }\n\n  /*\n  **    $db preupdate_hook count\n  **    $db preupdate_hook hook ?SCRIPT?\n  **    $db preupdate_hook new INDEX\n  **    $db preupdate_hook old INDEX\n  */\n  case DB_PREUPDATE: {\n#ifndef SQLITE_ENABLE_PREUPDATE_HOOK\n    Tcl_AppendResult(interp, \"preupdate_hook was omitted at compile-time\", \n                     (char*)0);\n    rc = TCL_ERROR;\n#else\n    static const char *azSub[] = {\"count\", \"depth\", \"hook\", \"new\", \"old\", 0};\n    enum DbPreupdateSubCmd {\n      PRE_COUNT, PRE_DEPTH, PRE_HOOK, PRE_NEW, PRE_OLD\n    };\n    int iSub;\n\n    if( objc<3 ){\n      Tcl_WrongNumArgs(interp, 2, objv, \"SUB-COMMAND ?ARGS?\");\n    }\n    if( Tcl_GetIndexFromObj(interp, objv[2], azSub, \"sub-command\", 0, &iSub) ){\n      return TCL_ERROR;\n    }\n\n    switch( (enum DbPreupdateSubCmd)iSub ){\n      case PRE_COUNT: {\n        int nCol = sqlite3_preupdate_count(pDb->db);\n        Tcl_SetObjResult(interp, Tcl_NewIntObj(nCol));\n        break;\n      }\n\n      case PRE_HOOK: {\n        if( objc>4 ){\n          Tcl_WrongNumArgs(interp, 2, objv, \"hook ?SCRIPT?\");\n          return TCL_ERROR;\n        }\n        DbHookCmd(interp, pDb, (objc==4 ? objv[3] : 0), &pDb->pPreUpdateHook);\n        break;\n      }\n\n      case PRE_DEPTH: {\n        Tcl_Obj *pRet;\n        if( objc!=3 ){\n          Tcl_WrongNumArgs(interp, 3, objv, \"\");\n          return TCL_ERROR;\n        }\n        pRet = Tcl_NewIntObj(sqlite3_preupdate_depth(pDb->db));\n        Tcl_SetObjResult(interp, pRet);\n        break;\n      }\n\n      case PRE_NEW:\n      case PRE_OLD: {\n        int iIdx;\n        sqlite3_value *pValue;\n        if( objc!=4 ){\n          Tcl_WrongNumArgs(interp, 3, objv, \"INDEX\");\n          return TCL_ERROR;\n        }\n        if( Tcl_GetIntFromObj(interp, objv[3], &iIdx) ){\n          return TCL_ERROR;\n        }\n\n        if( iSub==PRE_OLD ){\n          rc = sqlite3_preupdate_old(pDb->db, iIdx, &pValue);\n        }else{\n          assert( iSub==PRE_NEW );\n          rc = sqlite3_preupdate_new(pDb->db, iIdx, &pValue);\n        }\n\n        if( rc==SQLITE_OK ){\n          Tcl_Obj *pObj;\n          pObj = Tcl_NewStringObj((char*)sqlite3_value_text(pValue), -1);\n          Tcl_SetObjResult(interp, pObj);\n        }else{\n          Tcl_AppendResult(interp, sqlite3_errmsg(pDb->db), (char*)0);\n          return TCL_ERROR;\n        }\n      }\n    }\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n    break;\n  }\n\n  /*\n  **    $db wal_hook ?script?\n  **    $db update_hook ?script?\n  **    $db rollback_hook ?script?\n  */\n  case DB_WAL_HOOK:\n  case DB_UPDATE_HOOK:\n  case DB_ROLLBACK_HOOK: {\n    /* set ppHook to point at pUpdateHook or pRollbackHook, depending on\n    ** whether [$db update_hook] or [$db rollback_hook] was invoked.\n    */\n    Tcl_Obj **ppHook = 0;\n    if( choice==DB_WAL_HOOK ) ppHook = &pDb->pWalHook;\n    if( choice==DB_UPDATE_HOOK ) ppHook = &pDb->pUpdateHook;\n    if( choice==DB_ROLLBACK_HOOK ) ppHook = &pDb->pRollbackHook;\n    if( objc>3 ){\n       Tcl_WrongNumArgs(interp, 2, objv, \"?SCRIPT?\");\n       return TCL_ERROR;\n    }\n\n    DbHookCmd(interp, pDb, (objc==3 ? objv[2] : 0), ppHook);\n    break;\n  }\n\n  /*    $db version\n  **\n  ** Return the version string for this database.\n  */\n  case DB_VERSION: {\n    int i;\n    for(i=2; i<objc; i++){\n      const char *zArg = Tcl_GetString(objv[i]);\n      /* Optional arguments to $db version are used for testing purpose */\n#ifdef SQLITE_TEST\n      /* $db version -use-legacy-prepare BOOLEAN\n      **\n      ** Turn the use of legacy sqlite3_prepare() on or off.\n      */\n      if( strcmp(zArg, \"-use-legacy-prepare\")==0 && i+1<objc ){\n        i++;\n        if( Tcl_GetBooleanFromObj(interp, objv[i], &pDb->bLegacyPrepare) ){\n          return TCL_ERROR;\n        }\n      }else\n\n      /* $db version -last-stmt-ptr\n      **\n      ** Return a string which is a hex encoding of the pointer to the\n      ** most recent sqlite3_stmt in the statement cache.\n      */\n      if( strcmp(zArg, \"-last-stmt-ptr\")==0 ){\n        char zBuf[100];\n        sqlite3_snprintf(sizeof(zBuf), zBuf, \"%p\",\n                         pDb->stmtList ? pDb->stmtList->pStmt: 0);\n        Tcl_SetResult(interp, zBuf, TCL_VOLATILE);\n      }else\n#endif /* SQLITE_TEST */\n      {\n        Tcl_AppendResult(interp, \"unknown argument: \", zArg, (char*)0);\n        return TCL_ERROR;\n      }\n    }\n    if( i==2 ){   \n      Tcl_SetResult(interp, (char *)sqlite3_libversion(), TCL_STATIC);\n    }\n    break;\n  }\n\n\n  } /* End of the SWITCH statement */\n  return rc;\n}\n\n#if SQLITE_TCL_NRE\n/*\n** Adaptor that provides an objCmd interface to the NRE-enabled\n** interface implementation.\n*/\nstatic int SQLITE_TCLAPI DbObjCmdAdaptor(\n  void *cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *const*objv\n){\n  return Tcl_NRCallObjProc(interp, DbObjCmd, cd, objc, objv);\n}\n#endif /* SQLITE_TCL_NRE */\n\n/*\n**   sqlite3 DBNAME FILENAME ?-vfs VFSNAME? ?-key KEY? ?-readonly BOOLEAN?\n**                           ?-create BOOLEAN? ?-nomutex BOOLEAN?\n**\n** This is the main Tcl command.  When the \"sqlite\" Tcl command is\n** invoked, this routine runs to process that command.\n**\n** The first argument, DBNAME, is an arbitrary name for a new\n** database connection.  This command creates a new command named\n** DBNAME that is used to control that connection.  The database\n** connection is deleted when the DBNAME command is deleted.\n**\n** The second argument is the name of the database file.\n**\n*/\nstatic int SQLITE_TCLAPI DbMain(\n  void *cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *const*objv\n){\n  SqliteDb *p;\n  const char *zArg;\n  char *zErrMsg;\n  int i;\n  const char *zFile;\n  const char *zVfs = 0;\n  int flags;\n  Tcl_DString translatedFilename;\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n  void *pKey = 0;\n  int nKey = 0;\n#endif\n  int rc;\n\n  /* In normal use, each TCL interpreter runs in a single thread.  So\n  ** by default, we can turn of mutexing on SQLite database connections.\n  ** However, for testing purposes it is useful to have mutexes turned\n  ** on.  So, by default, mutexes default off.  But if compiled with\n  ** SQLITE_TCL_DEFAULT_FULLMUTEX then mutexes default on.\n  */\n#ifdef SQLITE_TCL_DEFAULT_FULLMUTEX\n  flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX;\n#else\n  flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX;\n#endif\n\n  if( objc==2 ){\n    zArg = Tcl_GetStringFromObj(objv[1], 0);\n    if( strcmp(zArg,\"-version\")==0 ){\n      Tcl_AppendResult(interp,sqlite3_libversion(), (char*)0);\n      return TCL_OK;\n    }\n    if( strcmp(zArg,\"-sourceid\")==0 ){\n      Tcl_AppendResult(interp,sqlite3_sourceid(), (char*)0);\n      return TCL_OK;\n    }\n    if( strcmp(zArg,\"-has-codec\")==0 ){\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n      Tcl_AppendResult(interp,\"1\",(char*)0);\n#else\n      Tcl_AppendResult(interp,\"0\",(char*)0);\n#endif\n      return TCL_OK;\n    }\n  }\n  for(i=3; i+1<objc; i+=2){\n    zArg = Tcl_GetString(objv[i]);\n    if( strcmp(zArg,\"-key\")==0 ){\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n      pKey = Tcl_GetByteArrayFromObj(objv[i+1], &nKey);\n#endif\n    }else if( strcmp(zArg, \"-vfs\")==0 ){\n      zVfs = Tcl_GetString(objv[i+1]);\n    }else if( strcmp(zArg, \"-readonly\")==0 ){\n      int b;\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;\n      if( b ){\n        flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);\n        flags |= SQLITE_OPEN_READONLY;\n      }else{\n        flags &= ~SQLITE_OPEN_READONLY;\n        flags |= SQLITE_OPEN_READWRITE;\n      }\n    }else if( strcmp(zArg, \"-create\")==0 ){\n      int b;\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;\n      if( b && (flags & SQLITE_OPEN_READONLY)==0 ){\n        flags |= SQLITE_OPEN_CREATE;\n      }else{\n        flags &= ~SQLITE_OPEN_CREATE;\n      }\n    }else if( strcmp(zArg, \"-nomutex\")==0 ){\n      int b;\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;\n      if( b ){\n        flags |= SQLITE_OPEN_NOMUTEX;\n        flags &= ~SQLITE_OPEN_FULLMUTEX;\n      }else{\n        flags &= ~SQLITE_OPEN_NOMUTEX;\n      }\n    }else if( strcmp(zArg, \"-fullmutex\")==0 ){\n      int b;\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;\n      if( b ){\n        flags |= SQLITE_OPEN_FULLMUTEX;\n        flags &= ~SQLITE_OPEN_NOMUTEX;\n      }else{\n        flags &= ~SQLITE_OPEN_FULLMUTEX;\n      }\n    }else if( strcmp(zArg, \"-uri\")==0 ){\n      int b;\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &b) ) return TCL_ERROR;\n      if( b ){\n        flags |= SQLITE_OPEN_URI;\n      }else{\n        flags &= ~SQLITE_OPEN_URI;\n      }\n    }else{\n      Tcl_AppendResult(interp, \"unknown option: \", zArg, (char*)0);\n      return TCL_ERROR;\n    }\n  }\n  if( objc<3 || (objc&1)!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv,\n      \"HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN?\"\n      \" ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?\"\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n      \" ?-key CODECKEY?\"\n#endif\n    );\n    return TCL_ERROR;\n  }\n  zErrMsg = 0;\n  p = (SqliteDb*)Tcl_Alloc( sizeof(*p) );\n  memset(p, 0, sizeof(*p));\n  zFile = Tcl_GetStringFromObj(objv[2], 0);\n  zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);\n  rc = sqlite3_open_v2(zFile, &p->db, flags, zVfs);\n  Tcl_DStringFree(&translatedFilename);\n  if( p->db ){\n    if( SQLITE_OK!=sqlite3_errcode(p->db) ){\n      zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errmsg(p->db));\n      sqlite3_close(p->db);\n      p->db = 0;\n    }\n  }else{\n    zErrMsg = sqlite3_mprintf(\"%s\", sqlite3_errstr(rc));\n  }\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n  if( p->db ){\n    sqlite3_key(p->db, pKey, nKey);\n  }\n#endif\n  if( p->db==0 ){\n    Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE);\n    Tcl_Free((char*)p);\n    sqlite3_free(zErrMsg);\n    return TCL_ERROR;\n  }\n  p->maxStmt = NUM_PREPARED_STMTS;\n  p->openFlags = flags & SQLITE_OPEN_URI;\n  p->interp = interp;\n  zArg = Tcl_GetStringFromObj(objv[1], 0);\n  if( DbUseNre() ){\n    Tcl_NRCreateCommand(interp, zArg, DbObjCmdAdaptor, DbObjCmd,\n                        (char*)p, DbDeleteCmd);\n  }else{\n    Tcl_CreateObjCommand(interp, zArg, DbObjCmd, (char*)p, DbDeleteCmd);\n  }\n  return TCL_OK;\n}\n\n/*\n** Provide a dummy Tcl_InitStubs if we are using this as a static\n** library.\n*/\n#ifndef USE_TCL_STUBS\n# undef  Tcl_InitStubs\n# define Tcl_InitStubs(a,b,c) TCL_VERSION\n#endif\n\n/*\n** Make sure we have a PACKAGE_VERSION macro defined.  This will be\n** defined automatically by the TEA makefile.  But other makefiles\n** do not define it.\n*/\n#ifndef PACKAGE_VERSION\n# define PACKAGE_VERSION SQLITE_VERSION\n#endif\n\n/*\n** Initialize this module.\n**\n** This Tcl module contains only a single new Tcl command named \"sqlite\".\n** (Hence there is no namespace.  There is no point in using a namespace\n** if the extension only supplies one new name!)  The \"sqlite\" command is\n** used to open a new SQLite database.  See the DbMain() routine above\n** for additional information.\n**\n** The EXTERN macros are required by TCL in order to work on windows.\n*/\nEXTERN int Sqlite3_Init(Tcl_Interp *interp){\n  int rc = Tcl_InitStubs(interp, \"8.4\", 0) ? TCL_OK : TCL_ERROR;\n  if( rc==TCL_OK ){\n    Tcl_CreateObjCommand(interp, \"sqlite3\", (Tcl_ObjCmdProc*)DbMain, 0, 0);\n#ifndef SQLITE_3_SUFFIX_ONLY\n    /* The \"sqlite\" alias is undocumented.  It is here only to support\n    ** legacy scripts.  All new scripts should use only the \"sqlite3\"\n    ** command. */\n    Tcl_CreateObjCommand(interp, \"sqlite\", (Tcl_ObjCmdProc*)DbMain, 0, 0);\n#endif\n    rc = Tcl_PkgProvide(interp, \"sqlite3\", PACKAGE_VERSION);\n  }\n  return rc;\n}\nEXTERN int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); }\nEXTERN int Sqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }\nEXTERN int Tclsqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }\n\n/* Because it accesses the file-system and uses persistent state, SQLite\n** is not considered appropriate for safe interpreters.  Hence, we cause\n** the _SafeInit() interfaces return TCL_ERROR.\n*/\nEXTERN int Sqlite3_SafeInit(Tcl_Interp *interp){ return TCL_ERROR; }\nEXTERN int Sqlite3_SafeUnload(Tcl_Interp *interp, int flags){return TCL_ERROR;}\n\n\n\n#ifndef SQLITE_3_SUFFIX_ONLY\nint Sqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); }\nint Tclsqlite_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); }\nint Sqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }\nint Tclsqlite_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }\n#endif\n\n/*\n** If the TCLSH macro is defined, add code to make a stand-alone program.\n*/\n#if defined(TCLSH)\n\n/* This is the main routine for an ordinary TCL shell.  If there are\n** are arguments, run the first argument as a script.  Otherwise,\n** read TCL commands from standard input\n*/\nstatic const char *tclsh_main_loop(void){\n  static const char zMainloop[] =\n    \"if {[llength $argv]>=1} {\\n\"\n      \"set argv0 [lindex $argv 0]\\n\"\n      \"set argv [lrange $argv 1 end]\\n\"\n      \"source $argv0\\n\"\n    \"} else {\\n\"\n      \"set line {}\\n\"\n      \"while {![eof stdin]} {\\n\"\n        \"if {$line!=\\\"\\\"} {\\n\"\n          \"puts -nonewline \\\"> \\\"\\n\"\n        \"} else {\\n\"\n          \"puts -nonewline \\\"% \\\"\\n\"\n        \"}\\n\"\n        \"flush stdout\\n\"\n        \"append line [gets stdin]\\n\"\n        \"if {[info complete $line]} {\\n\"\n          \"if {[catch {uplevel #0 $line} result]} {\\n\"\n            \"puts stderr \\\"Error: $result\\\"\\n\"\n          \"} elseif {$result!=\\\"\\\"} {\\n\"\n            \"puts $result\\n\"\n          \"}\\n\"\n          \"set line {}\\n\"\n        \"} else {\\n\"\n          \"append line \\\\n\\n\"\n        \"}\\n\"\n      \"}\\n\"\n    \"}\\n\"\n  ;\n  return zMainloop;\n}\n\n#define TCLSH_MAIN main   /* Needed to fake out mktclapp */\nint SQLITE_CDECL TCLSH_MAIN(int argc, char **argv){\n  Tcl_Interp *interp;\n  int i;\n  const char *zScript = 0;\n  char zArgc[32];\n#if defined(TCLSH_INIT_PROC)\n  extern const char *TCLSH_INIT_PROC(Tcl_Interp*);\n#endif\n\n#if !defined(_WIN32_WCE)\n  if( getenv(\"BREAK\") ){\n    fprintf(stderr,\n        \"attach debugger to process %d and press any key to continue.\\n\",\n        GETPID());\n    fgetc(stdin);\n  }\n#endif\n\n  /* Call sqlite3_shutdown() once before doing anything else. This is to\n  ** test that sqlite3_shutdown() can be safely called by a process before\n  ** sqlite3_initialize() is. */\n  sqlite3_shutdown();\n\n  Tcl_FindExecutable(argv[0]);\n  Tcl_SetSystemEncoding(NULL, \"utf-8\");\n  interp = Tcl_CreateInterp();\n  Sqlite3_Init(interp);\n\n  sqlite3_snprintf(sizeof(zArgc), zArgc, \"%d\", argc-1);\n  Tcl_SetVar(interp,\"argc\", zArgc, TCL_GLOBAL_ONLY);\n  Tcl_SetVar(interp,\"argv0\",argv[0],TCL_GLOBAL_ONLY);\n  Tcl_SetVar(interp,\"argv\", \"\", TCL_GLOBAL_ONLY);\n  for(i=1; i<argc; i++){\n    Tcl_SetVar(interp, \"argv\", argv[i],\n        TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT | TCL_APPEND_VALUE);\n  }\n#if defined(TCLSH_INIT_PROC)\n  zScript = TCLSH_INIT_PROC(interp);\n#endif\n  if( zScript==0 ){\n    zScript = tclsh_main_loop();\n  }\n  if( Tcl_GlobalEval(interp, zScript)!=TCL_OK ){\n    const char *zInfo = Tcl_GetVar(interp, \"errorInfo\", TCL_GLOBAL_ONLY);\n    if( zInfo==0 ) zInfo = Tcl_GetStringResult(interp);\n    fprintf(stderr,\"%s: %s\\n\", *argv, zInfo);\n    return 1;\n  }\n  return 0;\n}\n#endif /* TCLSH */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test1.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing all sorts of SQLite interfaces.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n#include \"sqliteInt.h\"\n#if SQLITE_OS_WIN\n#  include \"os_win.h\"\n#endif\n\n#include \"vdbeInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** This is a copy of the first part of the SqliteDb structure in \n** tclsqlite.c.  We need it here so that the get_sqlite_pointer routine\n** can extract the sqlite3* pointer from an existing Tcl SQLite\n** connection.\n*/\nstruct SqliteDb {\n  sqlite3 *db;\n};\n\n/*\n** Convert text generated by the \"%p\" conversion format back into\n** a pointer.\n*/\nstatic int testHexToInt(int h){\n  if( h>='0' && h<='9' ){\n    return h - '0';\n  }else if( h>='a' && h<='f' ){\n    return h - 'a' + 10;\n  }else{\n    assert( h>='A' && h<='F' );\n    return h - 'A' + 10;\n  }\n}\nvoid *sqlite3TestTextToPtr(const char *z){\n  void *p;\n  u64 v;\n  u32 v2;\n  if( z[0]=='0' && z[1]=='x' ){\n    z += 2;\n  }\n  v = 0;\n  while( *z ){\n    v = (v<<4) + testHexToInt(*z);\n    z++;\n  }\n  if( sizeof(p)==sizeof(v) ){\n    memcpy(&p, &v, sizeof(p));\n  }else{\n    assert( sizeof(p)==sizeof(v2) );\n    v2 = (u32)v;\n    memcpy(&p, &v2, sizeof(p));\n  }\n  return p;\n}\n\n\n/*\n** A TCL command that returns the address of the sqlite* pointer\n** for an sqlite connection instance.  Bad things happen if the\n** input is not an sqlite connection.\n*/\nstatic int SQLITE_TCLAPI get_sqlite_pointer(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct SqliteDb *p;\n  Tcl_CmdInfo cmdInfo;\n  char zBuf[100];\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SQLITE-CONNECTION\");\n    return TCL_ERROR;\n  }\n  if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){\n    Tcl_AppendResult(interp, \"command not found: \",\n           Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  p = (struct SqliteDb*)cmdInfo.objClientData;\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%p\", p->db);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nint getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){\n  struct SqliteDb *p;\n  Tcl_CmdInfo cmdInfo;\n  if( Tcl_GetCommandInfo(interp, zA, &cmdInfo) ){\n    p = (struct SqliteDb*)cmdInfo.objClientData;\n    *ppDb = p->db;\n  }else{\n    *ppDb = (sqlite3*)sqlite3TestTextToPtr(zA);\n  }\n  return TCL_OK;\n}\n\n#if SQLITE_OS_WIN\n/*\n** Decode a Win32 HANDLE object.\n*/\nint getWin32Handle(Tcl_Interp *interp, const char *zA, LPHANDLE phFile){\n  *phFile = (HANDLE)sqlite3TestTextToPtr(zA);\n  return TCL_OK;\n}\n#endif\n\nextern const char *sqlite3ErrName(int);\n#define t1ErrorName sqlite3ErrName\n\n/*\n** Convert an sqlite3_stmt* into an sqlite3*.  This depends on the\n** fact that the sqlite3* is the first field in the Vdbe structure.\n*/\n#define StmtToDb(X)   sqlite3_db_handle(X)\n\n/*\n** Check a return value to make sure it agrees with the results\n** from sqlite3_errcode.\n*/\nint sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){\n  if( sqlite3_threadsafe()==0 && rc!=SQLITE_MISUSE && rc!=SQLITE_OK\n   && sqlite3_errcode(db)!=rc ){\n    char zBuf[200];\n    int r2 = sqlite3_errcode(db);\n    sqlite3_snprintf(sizeof(zBuf), zBuf,\n       \"error code %s (%d) does not match sqlite3_errcode %s (%d)\",\n       t1ErrorName(rc), rc, t1ErrorName(r2), r2);\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, zBuf, 0);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Decode a pointer to an sqlite3_stmt object.\n*/\nstatic int getStmtPointer(\n  Tcl_Interp *interp, \n  const char *zArg,  \n  sqlite3_stmt **ppStmt\n){\n  *ppStmt = (sqlite3_stmt*)sqlite3TestTextToPtr(zArg);\n  return TCL_OK;\n}\n\n/*\n** Generate a text representation of a pointer that can be understood\n** by the getDbPointer and getVmPointer routines above.\n**\n** The problem is, on some machines (Solaris) if you do a printf with\n** \"%p\" you cannot turn around and do a scanf with the same \"%p\" and\n** get your pointer back.  You have to prepend a \"0x\" before it will\n** work.  Or at least that is what is reported to me (drh).  But this\n** behavior varies from machine to machine.  The solution used her is\n** to test the string right after it is generated to see if it can be\n** understood by scanf, and if not, try prepending an \"0x\" to see if\n** that helps.  If nothing works, a fatal error is generated.\n*/\nint sqlite3TestMakePointerStr(Tcl_Interp *interp, char *zPtr, void *p){\n  sqlite3_snprintf(100, zPtr, \"%p\", p);\n  return TCL_OK;\n}\n\n/*\n** The callback routine for sqlite3_exec_printf().\n*/\nstatic int exec_printf_cb(void *pArg, int argc, char **argv, char **name){\n  Tcl_DString *str = (Tcl_DString*)pArg;\n  int i;\n\n  if( Tcl_DStringLength(str)==0 ){\n    for(i=0; i<argc; i++){\n      Tcl_DStringAppendElement(str, name[i] ? name[i] : \"NULL\");\n    }\n  }\n  for(i=0; i<argc; i++){\n    Tcl_DStringAppendElement(str, argv[i] ? argv[i] : \"NULL\");\n  }\n  return 0;\n}\n\n/*\n** The I/O tracing callback.\n*/\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\nstatic FILE *iotrace_file = 0;\nstatic void io_trace_callback(const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  vfprintf(iotrace_file, zFormat, ap);\n  va_end(ap);\n  fflush(iotrace_file);\n}\n#endif\n\n/*\n** Usage:  io_trace FILENAME\n**\n** Turn I/O tracing on or off.  If FILENAME is not an empty string,\n** I/O tracing begins going into FILENAME. If FILENAME is an empty\n** string, I/O tracing is turned off.\n*/\nstatic int SQLITE_TCLAPI test_io_trace(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n          \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( iotrace_file ){\n    if( iotrace_file!=stdout && iotrace_file!=stderr ){\n      fclose(iotrace_file);\n    }\n    iotrace_file = 0;\n    sqlite3IoTrace = 0;\n  }\n  if( argv[1][0] ){\n    if( strcmp(argv[1],\"stdout\")==0 ){\n      iotrace_file = stdout;\n    }else if( strcmp(argv[1],\"stderr\")==0 ){\n      iotrace_file = stderr;\n    }else{\n      iotrace_file = fopen(argv[1], \"w\");\n    }\n    sqlite3IoTrace = io_trace_callback;\n  }\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:  clang_sanitize_address \n**\n** Returns true if the program was compiled using clang with the \n** -fsanitize=address switch on the command line. False otherwise.\n**\n** Also return true if the OMIT_MISUSE environment variable exists.\n*/\nstatic int SQLITE_TCLAPI clang_sanitize_address(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int res = 0;\n#if defined(__has_feature)\n# if __has_feature(address_sanitizer)\n  res = 1;\n# endif\n#endif\n#ifdef __SANITIZE_ADDRESS__\n  res = 1;\n#endif\n  if( res==0 && getenv(\"OMIT_MISUSE\")!=0 ) res = 1;\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(res));\n  return TCL_OK;\n}\n  \n/*\n** Usage:  sqlite3_exec_printf  DB  FORMAT  STRING\n**\n** Invoke the sqlite3_exec_printf() interface using the open database\n** DB.  The SQL is the string FORMAT.  The format string should contain\n** one %s or %q.  STRING is the value inserted into %s or %q.\n*/\nstatic int SQLITE_TCLAPI test_exec_printf(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  Tcl_DString str;\n  int rc;\n  char *zErr = 0;\n  char *zSql;\n  char zBuf[30];\n  if( argc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB FORMAT STRING\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  Tcl_DStringInit(&str);\n  zSql = sqlite3_mprintf(argv[2], argv[3]);\n  rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr);\n  sqlite3_free(zSql);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", rc);\n  Tcl_AppendElement(interp, zBuf);\n  Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);\n  Tcl_DStringFree(&str);\n  if( zErr ) sqlite3_free(zErr);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_exec_hex  DB  HEX\n**\n** Invoke the sqlite3_exec() on a string that is obtained by translating\n** HEX into ASCII.  Most characters are translated as is.  %HH becomes\n** a hex character.\n*/\nstatic int SQLITE_TCLAPI test_exec_hex(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  Tcl_DString str;\n  int rc, i, j;\n  char *zErr = 0;\n  char *zHex;\n  char zSql[501];\n  char zBuf[30];\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB HEX\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  zHex = argv[2];\n  for(i=j=0; i<(sizeof(zSql)-1) && zHex[j]; i++, j++){\n    if( zHex[j]=='%' && zHex[j+2] && zHex[j+2] ){\n      zSql[i] = (testHexToInt(zHex[j+1])<<4) + testHexToInt(zHex[j+2]);\n      j += 2;\n    }else{\n      zSql[i] = zHex[j];\n    }\n  }\n  zSql[i] = 0;\n  Tcl_DStringInit(&str);\n  rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", rc);\n  Tcl_AppendElement(interp, zBuf);\n  Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);\n  Tcl_DStringFree(&str);\n  if( zErr ) sqlite3_free(zErr);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  db_enter DB\n**         db_leave DB\n**\n** Enter or leave the mutex on a database connection.\n*/\nstatic int SQLITE_TCLAPI db_enter(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  sqlite3_mutex_enter(db->mutex);\n  return TCL_OK;\n}\nstatic int SQLITE_TCLAPI db_leave(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  sqlite3_mutex_leave(db->mutex);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_exec  DB  SQL\n**\n** Invoke the sqlite3_exec interface using the open database DB\n*/\nstatic int SQLITE_TCLAPI test_exec(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  Tcl_DString str;\n  int rc;\n  char *zErr = 0;\n  char *zSql;\n  int i, j;\n  char zBuf[30];\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB SQL\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  Tcl_DStringInit(&str);\n  zSql = sqlite3_mprintf(\"%s\", argv[2]);\n  for(i=j=0; zSql[i];){\n    if( zSql[i]=='%' ){\n      zSql[j++] = (testHexToInt(zSql[i+1])<<4) + testHexToInt(zSql[i+2]);\n      i += 3;\n    }else{\n      zSql[j++] = zSql[i++];\n    }\n  }\n  zSql[j] = 0;\n  rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr);\n  sqlite3_free(zSql);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", rc);\n  Tcl_AppendElement(interp, zBuf);\n  Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr);\n  Tcl_DStringFree(&str);\n  if( zErr ) sqlite3_free(zErr);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_exec_nr  DB  SQL\n**\n** Invoke the sqlite3_exec interface using the open database DB.  Discard\n** all results\n*/\nstatic int SQLITE_TCLAPI test_exec_nr(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  int rc;\n  char *zErr = 0;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB SQL\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_z_test  SEPARATOR  ARG0  ARG1 ...\n**\n** Test the %z format of sqlite_mprintf().  Use multiple mprintf() calls to \n** concatenate arg0 through argn using separator as the separator.\n** Return the result.\n*/\nstatic int SQLITE_TCLAPI test_mprintf_z(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  char *zResult = 0;\n  int i;\n\n  for(i=2; i<argc && (i==2 || zResult); i++){\n    zResult = sqlite3_mprintf(\"%z%s%s\", zResult, argv[1], argv[i]);\n  }\n  Tcl_AppendResult(interp, zResult, 0);\n  sqlite3_free(zResult);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_n_test  STRING\n**\n** Test the %n format of sqlite_mprintf().  Return the length of the\n** input string.\n*/\nstatic int SQLITE_TCLAPI test_mprintf_n(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  char *zStr;\n  int n = 0;\n  zStr = sqlite3_mprintf(\"%s%n\", argv[1], &n);\n  sqlite3_free(zStr);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(n));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_snprintf_int  SIZE FORMAT  INT\n**\n** Test the of sqlite3_snprintf() routine.  SIZE is the size of the\n** output buffer in bytes.  The maximum size is 100.  FORMAT is the\n** format string.  INT is a single integer argument.  The FORMAT\n** string must require no more than this one integer argument.  If\n** You pass in a format string that requires more than one argument,\n** bad things will happen.\n*/\nstatic int SQLITE_TCLAPI test_snprintf_int(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  char zStr[100];\n  int n = atoi(argv[1]);\n  const char *zFormat = argv[2];\n  int a1 = atoi(argv[3]);\n  if( n>sizeof(zStr) ) n = sizeof(zStr);\n  sqlite3_snprintf(sizeof(zStr), zStr, \"abcdefghijklmnopqrstuvwxyz\");\n  sqlite3_snprintf(n, zStr, zFormat, a1);\n  Tcl_AppendResult(interp, zStr, 0);\n  return TCL_OK;\n}\n\n#ifndef SQLITE_OMIT_GET_TABLE\n\n/*\n** Usage:  sqlite3_get_table_printf  DB  FORMAT  STRING  ?--no-counts?\n**\n** Invoke the sqlite3_get_table_printf() interface using the open database\n** DB.  The SQL is the string FORMAT.  The format string should contain\n** one %s or %q.  STRING is the value inserted into %s or %q.\n*/\nstatic int SQLITE_TCLAPI test_get_table_printf(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  Tcl_DString str;\n  int rc;\n  char *zErr = 0;\n  int nRow = 0, nCol = 0;\n  char **aResult;\n  int i;\n  char zBuf[30];\n  char *zSql;\n  int resCount = -1;\n  if( argc==5 ){\n    if( Tcl_GetInt(interp, argv[4], &resCount) ) return TCL_ERROR;\n  }\n  if( argc!=4 && argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB FORMAT STRING ?COUNT?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  Tcl_DStringInit(&str);\n  zSql = sqlite3_mprintf(argv[2],argv[3]);\n  if( argc==5 ){\n    rc = sqlite3_get_table(db, zSql, &aResult, 0, 0, &zErr);\n  }else{\n    rc = sqlite3_get_table(db, zSql, &aResult, &nRow, &nCol, &zErr);\n    resCount = (nRow+1)*nCol;\n  }\n  sqlite3_free(zSql);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", rc);\n  Tcl_AppendElement(interp, zBuf);\n  if( rc==SQLITE_OK ){\n    if( argc==4 ){\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", nRow);\n      Tcl_AppendElement(interp, zBuf);\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", nCol);\n      Tcl_AppendElement(interp, zBuf);\n    }\n    for(i=0; i<resCount; i++){\n      Tcl_AppendElement(interp, aResult[i] ? aResult[i] : \"NULL\");\n    }\n  }else{\n    Tcl_AppendElement(interp, zErr);\n  }\n  sqlite3_free_table(aResult);\n  if( zErr ) sqlite3_free(zErr);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n#endif /* SQLITE_OMIT_GET_TABLE */\n\n\n/*\n** Usage:  sqlite3_last_insert_rowid DB\n**\n** Returns the integer ROWID of the most recent insert.\n*/\nstatic int SQLITE_TCLAPI test_last_rowid(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  char zBuf[30];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \" DB\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%lld\", sqlite3_last_insert_rowid(db));\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Usage:  sqlite3_key DB KEY\n**\n** Set the codec key.\n*/\nstatic int SQLITE_TCLAPI test_key(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_CODEC_FROM_TCL)\n  sqlite3 *db;\n  const char *zKey;\n  int nKey;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  zKey = argv[2];\n  nKey = strlen(zKey);\n  sqlite3_key(db, zKey, nKey);\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_rekey DB KEY\n**\n** Change the codec key.\n*/\nstatic int SQLITE_TCLAPI test_rekey(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n#ifdef SQLITE_HAS_CODEC\n  sqlite3 *db;\n  const char *zKey;\n  int nKey;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  zKey = argv[2];\n  nKey = strlen(zKey);\n  sqlite3_rekey(db, zKey, nKey);\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_close DB\n**\n** Closes the database opened by sqlite3_open.\n*/\nstatic int SQLITE_TCLAPI sqlite_test_close(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_close(db);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_close_v2 DB\n**\n** Closes the database opened by sqlite3_open.\n*/\nstatic int SQLITE_TCLAPI sqlite_test_close_v2(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_close_v2(db);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** Implementation of the x_coalesce() function.\n** Return the first argument non-NULL argument.\n*/\nstatic void t1_ifnullFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int i;\n  for(i=0; i<argc; i++){\n    if( SQLITE_NULL!=sqlite3_value_type(argv[i]) ){\n      int n = sqlite3_value_bytes(argv[i]);\n      sqlite3_result_text(context, (char*)sqlite3_value_text(argv[i]),\n          n, SQLITE_TRANSIENT);\n      break;\n    }\n  }\n}\n\n/*\n** These are test functions.    hex8() interprets its argument as\n** UTF8 and returns a hex encoding.  hex16le() interprets its argument\n** as UTF16le and returns a hex encoding.\n*/\nstatic void hex8Func(sqlite3_context *p, int argc, sqlite3_value **argv){\n  const unsigned char *z;\n  int i;\n  char zBuf[200];\n  z = sqlite3_value_text(argv[0]);\n  for(i=0; i<sizeof(zBuf)/2 - 2 && z[i]; i++){\n    sqlite3_snprintf(sizeof(zBuf)-i*2, &zBuf[i*2], \"%02x\", z[i]);\n  }\n  zBuf[i*2] = 0;\n  sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT);\n}\n#ifndef SQLITE_OMIT_UTF16\nstatic void hex16Func(sqlite3_context *p, int argc, sqlite3_value **argv){\n  const unsigned short int *z;\n  int i;\n  char zBuf[400];\n  z = sqlite3_value_text16(argv[0]);\n  for(i=0; i<sizeof(zBuf)/4 - 4 && z[i]; i++){\n    sqlite3_snprintf(sizeof(zBuf)-i*4, &zBuf[i*4],\"%04x\", z[i]&0xff);\n  }\n  zBuf[i*4] = 0;\n  sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT);\n}\n#endif\n\n/*\n** A structure into which to accumulate text.\n*/\nstruct dstr {\n  int nAlloc;  /* Space allocated */\n  int nUsed;   /* Space used */\n  char *z;     /* The space */\n};\n\n/*\n** Append text to a dstr\n*/\nstatic void dstrAppend(struct dstr *p, const char *z, int divider){\n  int n = (int)strlen(z);\n  if( p->nUsed + n + 2 > p->nAlloc ){\n    char *zNew;\n    p->nAlloc = p->nAlloc*2 + n + 200;\n    zNew = sqlite3_realloc(p->z, p->nAlloc);\n    if( zNew==0 ){\n      sqlite3_free(p->z);\n      memset(p, 0, sizeof(*p));\n      return;\n    }\n    p->z = zNew;\n  }\n  if( divider && p->nUsed>0 ){\n    p->z[p->nUsed++] = divider;\n  }\n  memcpy(&p->z[p->nUsed], z, n+1);\n  p->nUsed += n;\n}\n\n/*\n** Invoked for each callback from sqlite3ExecFunc\n*/\nstatic int execFuncCallback(void *pData, int argc, char **argv, char **NotUsed){\n  struct dstr *p = (struct dstr*)pData;\n  int i;\n  for(i=0; i<argc; i++){\n    if( argv[i]==0 ){\n      dstrAppend(p, \"NULL\", ' ');\n    }else{\n      dstrAppend(p, argv[i], ' ');\n    }\n  }\n  return 0;\n}\n\n/*\n** Implementation of the x_sqlite_exec() function.  This function takes\n** a single argument and attempts to execute that argument as SQL code.\n** This is illegal and should set the SQLITE_MISUSE flag on the database.\n**\n** 2004-Jan-07:  We have changed this to make it legal to call sqlite3_exec()\n** from within a function call.  \n** \n** This routine simulates the effect of having two threads attempt to\n** use the same database at the same time.\n*/\nstatic void sqlite3ExecFunc(\n  sqlite3_context *context, \n  int argc,  \n  sqlite3_value **argv\n){\n  struct dstr x;\n  memset(&x, 0, sizeof(x));\n  (void)sqlite3_exec((sqlite3*)sqlite3_user_data(context),\n      (char*)sqlite3_value_text(argv[0]),\n      execFuncCallback, &x, 0);\n  sqlite3_result_text(context, x.z, x.nUsed, SQLITE_TRANSIENT);\n  sqlite3_free(x.z);\n}\n\n/*\n** Implementation of tkt2213func(), a scalar function that takes exactly\n** one argument. It has two interesting features:\n**\n** * It calls sqlite3_value_text() 3 times on the argument sqlite3_value*.\n**   If the three pointers returned are not the same an SQL error is raised.\n**\n** * Otherwise it returns a copy of the text representation of its \n**   argument in such a way as the VDBE representation is a Mem* cell \n**   with the MEM_Term flag clear. \n**\n** Ticket #2213 can therefore be tested by evaluating the following\n** SQL expression:\n**\n**   tkt2213func(tkt2213func('a string'));\n*/\nstatic void tkt2213Function(\n  sqlite3_context *context, \n  int argc,  \n  sqlite3_value **argv\n){\n  int nText;\n  unsigned char const *zText1;\n  unsigned char const *zText2;\n  unsigned char const *zText3;\n\n  nText = sqlite3_value_bytes(argv[0]);\n  zText1 = sqlite3_value_text(argv[0]);\n  zText2 = sqlite3_value_text(argv[0]);\n  zText3 = sqlite3_value_text(argv[0]);\n\n  if( zText1!=zText2 || zText2!=zText3 ){\n    sqlite3_result_error(context, \"tkt2213 is not fixed\", -1);\n  }else{\n    char *zCopy = (char *)sqlite3_malloc(nText);\n    memcpy(zCopy, zText1, nText);\n    sqlite3_result_text(context, zCopy, nText, sqlite3_free);\n  }\n}\n\n/*\n** The following SQL function takes 4 arguments.  The 2nd and\n** 4th argument must be one of these strings:  'text', 'text16',\n** or 'blob' corresponding to API functions\n**\n**      sqlite3_value_text()\n**      sqlite3_value_text16()\n**      sqlite3_value_blob()\n**\n** The third argument is a string, either 'bytes' or 'bytes16' or 'noop',\n** corresponding to APIs:\n**\n**      sqlite3_value_bytes()\n**      sqlite3_value_bytes16()\n**      noop\n**\n** The APIs designated by the 2nd through 4th arguments are applied\n** to the first argument in order.  If the pointers returned by the\n** second and fourth are different, this routine returns 1.  Otherwise,\n** this routine returns 0.\n**\n** This function is used to test to see when returned pointers from\n** the _text(), _text16() and _blob() APIs become invalidated.\n*/\nstatic void ptrChngFunction(\n  sqlite3_context *context, \n  int argc,  \n  sqlite3_value **argv\n){\n  const void *p1, *p2;\n  const char *zCmd;\n  if( argc!=4 ) return;\n  zCmd = (const char*)sqlite3_value_text(argv[1]);\n  if( zCmd==0 ) return;\n  if( strcmp(zCmd,\"text\")==0 ){\n    p1 = (const void*)sqlite3_value_text(argv[0]);\n#ifndef SQLITE_OMIT_UTF16\n  }else if( strcmp(zCmd, \"text16\")==0 ){\n    p1 = (const void*)sqlite3_value_text16(argv[0]);\n#endif\n  }else if( strcmp(zCmd, \"blob\")==0 ){\n    p1 = (const void*)sqlite3_value_blob(argv[0]);\n  }else{\n    return;\n  }\n  zCmd = (const char*)sqlite3_value_text(argv[2]);\n  if( zCmd==0 ) return;\n  if( strcmp(zCmd,\"bytes\")==0 ){\n    sqlite3_value_bytes(argv[0]);\n#ifndef SQLITE_OMIT_UTF16\n  }else if( strcmp(zCmd, \"bytes16\")==0 ){\n    sqlite3_value_bytes16(argv[0]);\n#endif\n  }else if( strcmp(zCmd, \"noop\")==0 ){\n    /* do nothing */\n  }else{\n    return;\n  }\n  zCmd = (const char*)sqlite3_value_text(argv[3]);\n  if( zCmd==0 ) return;\n  if( strcmp(zCmd,\"text\")==0 ){\n    p2 = (const void*)sqlite3_value_text(argv[0]);\n#ifndef SQLITE_OMIT_UTF16\n  }else if( strcmp(zCmd, \"text16\")==0 ){\n    p2 = (const void*)sqlite3_value_text16(argv[0]);\n#endif\n  }else if( strcmp(zCmd, \"blob\")==0 ){\n    p2 = (const void*)sqlite3_value_blob(argv[0]);\n  }else{\n    return;\n  }\n  sqlite3_result_int(context, p1!=p2);\n}\n\n/*\n** This SQL function returns a different answer each time it is called, even if\n** the arguments are the same.\n*/\nstatic void nondeterministicFunction(\n  sqlite3_context *context, \n  int argc,  \n  sqlite3_value **argv\n){\n  static int cnt = 0;\n  sqlite3_result_int(context, cnt++);\n}\n\n/*\n** Usage:  sqlite3_create_function DB\n**\n** Call the sqlite3_create_function API on the given database in order\n** to create a function named \"x_coalesce\".  This function does the same thing\n** as the \"coalesce\" function.  This function also registers an SQL function\n** named \"x_sqlite_exec\" that invokes sqlite3_exec().  Invoking sqlite3_exec()\n** in this way is illegal recursion and should raise an SQLITE_MISUSE error.\n** The effect is similar to trying to use the same database connection from\n** two threads at the same time.\n**\n** The original motivation for this routine was to be able to call the\n** sqlite3_create_function function while a query is in progress in order\n** to test the SQLITE_MISUSE detection logic.\n*/\nstatic int SQLITE_TCLAPI test_create_function(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int rc;\n  sqlite3 *db;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" DB\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_create_function(db, \"x_coalesce\", -1, SQLITE_UTF8, 0, \n        t1_ifnullFunc, 0, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"hex8\", 1, SQLITE_UTF8 | SQLITE_DETERMINISTIC,\n          0, hex8Func, 0, 0);\n  }\n#ifndef SQLITE_OMIT_UTF16\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"hex16\", 1, SQLITE_UTF16 | SQLITE_DETERMINISTIC,\n          0, hex16Func, 0, 0);\n  }\n#endif\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"tkt2213func\", 1, SQLITE_ANY, 0, \n          tkt2213Function, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"pointer_change\", 4, SQLITE_ANY, 0, \n          ptrChngFunction, 0, 0);\n  }\n\n  /* Functions counter1() and counter2() have the same implementation - they\n  ** both return an ascending integer with each call.  But counter1() is marked\n  ** as non-deterministic and counter2() is marked as deterministic.\n  */\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"counter1\", -1, SQLITE_UTF8,\n          0, nondeterministicFunction, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"counter2\", -1, SQLITE_UTF8|SQLITE_DETERMINISTIC,\n          0, nondeterministicFunction, 0, 0);\n  }\n\n#ifndef SQLITE_OMIT_UTF16\n  /* Use the sqlite3_create_function16() API here. Mainly for fun, but also \n  ** because it is not tested anywhere else. */\n  if( rc==SQLITE_OK ){\n    const void *zUtf16;\n    sqlite3_value *pVal;\n    sqlite3_mutex_enter(db->mutex);\n    pVal = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pVal, -1, \"x_sqlite_exec\", SQLITE_UTF8, SQLITE_STATIC);\n    zUtf16 = sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n    if( db->mallocFailed ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_create_function16(db, zUtf16, \n                1, SQLITE_UTF16, db, sqlite3ExecFunc, 0, 0);\n    }\n    sqlite3ValueFree(pVal);\n    sqlite3_mutex_leave(db->mutex);\n  }\n#endif\n\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n\n/*\n** Routines to implement the x_count() aggregate function.\n**\n** x_count() counts the number of non-null arguments.  But there are\n** some twists for testing purposes.\n**\n** If the argument to x_count() is 40 then a UTF-8 error is reported\n** on the step function.  If x_count(41) is seen, then a UTF-16 error\n** is reported on the step function.  If the total count is 42, then\n** a UTF-8 error is reported on the finalize function.\n*/\ntypedef struct t1CountCtx t1CountCtx;\nstruct t1CountCtx {\n  int n;\n};\nstatic void t1CountStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  t1CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0]) ) && p ){\n    p->n++;\n  }\n  if( argc>0 ){\n    int v = sqlite3_value_int(argv[0]);\n    if( v==40 ){\n      sqlite3_result_error(context, \"value of 40 handed to x_count\", -1);\n#ifndef SQLITE_OMIT_UTF16\n    }else if( v==41 ){\n      const char zUtf16ErrMsg[] = { 0, 0x61, 0, 0x62, 0, 0x63, 0, 0, 0};\n      sqlite3_result_error16(context, &zUtf16ErrMsg[1-SQLITE_BIGENDIAN], -1);\n#endif\n    }\n  }\n}   \nstatic void t1CountFinalize(sqlite3_context *context){\n  t1CountCtx *p;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( p ){\n    if( p->n==42 ){\n      sqlite3_result_error(context, \"x_count totals to 42\", -1);\n    }else{\n      sqlite3_result_int(context, p ? p->n : 0);\n    }\n  }\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\nstatic void legacyCountStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  /* no-op */\n}\n\nstatic void legacyCountFinalize(sqlite3_context *context){\n  sqlite3_result_int(context, sqlite3_aggregate_count(context));\n}\n#endif\n\n/*\n** Usage:  sqlite3_create_aggregate DB\n**\n** Call the sqlite3_create_function API on the given database in order\n** to create a function named \"x_count\".  This function is similar\n** to the built-in count() function, with a few special quirks\n** for testing the sqlite3_result_error() APIs.\n**\n** The original motivation for this routine was to be able to call the\n** sqlite3_create_aggregate function while a query is in progress in order\n** to test the SQLITE_MISUSE detection logic.  See misuse.test.\n**\n** This routine was later extended to test the use of sqlite3_result_error()\n** within aggregate functions.\n**\n** Later: It is now also extended to register the aggregate function\n** \"legacy_count()\" with the supplied database handle. This is used\n** to test the deprecated sqlite3_aggregate_count() API.\n*/\nstatic int SQLITE_TCLAPI test_create_aggregate(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_create_function(db, \"x_count\", 0, SQLITE_UTF8, 0, 0,\n      t1CountStep,t1CountFinalize);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"x_count\", 1, SQLITE_UTF8, 0, 0,\n        t1CountStep,t1CountFinalize);\n  }\n#ifndef SQLITE_OMIT_DEPRECATED\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_create_function(db, \"legacy_count\", 0, SQLITE_ANY, 0, 0,\n        legacyCountStep, legacyCountFinalize\n    );\n  }\n#endif\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n\n\n/*\n** Usage:  printf TEXT\n**\n** Send output to printf.  Use this rather than puts to merge the output\n** in the correct sequence with debugging printfs inserted into C code.\n** Puts uses a separate buffer and debugging statements will be out of\n** sequence if it is used.\n*/\nstatic int SQLITE_TCLAPI test_printf(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" TEXT\\\"\", 0);\n    return TCL_ERROR;\n  }\n  printf(\"%s\\n\", argv[1]);\n  return TCL_OK;\n}\n\n\n\n/*\n** Usage:  sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER\n**\n** Call mprintf with three integer arguments\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_int(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int a[3], i;\n  char *z;\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT INT INT INT\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<5; i++){\n    if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;\n  }\n  z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER\n**\n** Call mprintf with three 64-bit integer arguments\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_int64(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int i;\n  sqlite_int64 a[3];\n  char *z;\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT INT INT INT\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<5; i++){\n    if( sqlite3Atoi64(argv[i], &a[i-2], sqlite3Strlen30(argv[i]), SQLITE_UTF8) ){\n      Tcl_AppendResult(interp, \"argument is not a valid 64-bit integer\", 0);\n      return TCL_ERROR;\n    }\n  }\n  z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER\n**\n** Call mprintf with three long integer arguments.   This might be the\n** same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on\n** platform.\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_long(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int i;\n  long int a[3];\n  int b[3];\n  char *z;\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT INT INT INT\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<5; i++){\n    if( Tcl_GetInt(interp, argv[i], &b[i-2]) ) return TCL_ERROR;\n    a[i-2] = (long int)b[i-2];\n    a[i-2] &= (((u64)1)<<(sizeof(int)*8))-1;\n  }\n  z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING\n**\n** Call mprintf with two integer arguments and one string argument\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_str(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int a[3], i;\n  char *z;\n  if( argc<4 || argc>5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT INT INT ?STRING?\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<4; i++){\n    if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;\n  }\n  z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING\n**\n** Call mprintf with two integer arguments and one string argument\n*/\nstatic int SQLITE_TCLAPI sqlite3_snprintf_str(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int a[3], i;\n  int n;\n  char *z;\n  if( argc<5 || argc>6 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" INT FORMAT INT INT ?STRING?\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;\n  if( n<0 ){\n    Tcl_AppendResult(interp, \"N must be non-negative\", 0);\n    return TCL_ERROR;\n  }\n  for(i=3; i<5; i++){\n    if( Tcl_GetInt(interp, argv[i], &a[i-3]) ) return TCL_ERROR;\n  }\n  z = sqlite3_malloc( n+1 );\n  sqlite3_snprintf(n, z, argv[2], a[0], a[1], argc>4 ? argv[5] : NULL);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE\n**\n** Call mprintf with two integer arguments and one double argument\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_double(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int a[3], i;\n  double r;\n  char *z;\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT INT INT DOUBLE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<4; i++){\n    if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;\n  }\n  if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR;\n  z = sqlite3_mprintf(argv[1], a[0], a[1], r);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_scaled FORMAT DOUBLE DOUBLE\n**\n** Call mprintf with a single double argument which is the product of the\n** two arguments given above.  This is used to generate overflow and underflow\n** doubles to test that they are converted properly.\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_scaled(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  int i;\n  double r[2];\n  char *z;\n  if( argc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT DOUBLE DOUBLE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  for(i=2; i<4; i++){\n    if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR;\n  }\n  z = sqlite3_mprintf(argv[1], r[0]*r[1]);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_stronly FORMAT STRING\n**\n** Call mprintf with a single double argument which is the product of the\n** two arguments given above.  This is used to generate overflow and underflow\n** doubles to test that they are converted properly.\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_stronly(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  char *z;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT STRING\\\"\", 0);\n    return TCL_ERROR;\n  }\n  z = sqlite3_mprintf(argv[1], argv[2]);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_mprintf_hexdouble FORMAT HEX\n**\n** Call mprintf with a single double argument which is derived from the\n** hexadecimal encoding of an IEEE double.\n*/\nstatic int SQLITE_TCLAPI sqlite3_mprintf_hexdouble(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  char *z;\n  double r;\n  unsigned int x1, x2;\n  sqlite_uint64 d;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FORMAT STRING\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( sscanf(argv[2], \"%08x%08x\", &x2, &x1)!=2 ){\n    Tcl_AppendResult(interp, \"2nd argument should be 16-characters of hex\", 0);\n    return TCL_ERROR;\n  }\n  d = x2;\n  d = (d<<32) + x1;\n  memcpy(&r, &d, sizeof(r));\n  z = sqlite3_mprintf(argv[1], r);\n  Tcl_AppendResult(interp, z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_enable_shared_cache ?BOOLEAN?\n**\n*/\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\nstatic int SQLITE_TCLAPI test_enable_shared(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int rc;\n  int enable;\n  int ret = 0;\n\n  if( objc!=2 && objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?BOOLEAN?\");\n    return TCL_ERROR;\n  }\n  ret = sqlite3GlobalConfig.sharedCacheEnabled;\n\n  if( objc==2 ){\n    if( Tcl_GetBooleanFromObj(interp, objv[1], &enable) ){\n      return TCL_ERROR;\n    }\n    rc = sqlite3_enable_shared_cache(enable);\n    if( rc!=SQLITE_OK ){\n      Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC);\n      return TCL_ERROR;\n    }\n  }\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(ret));\n  return TCL_OK;\n}\n#endif\n\n\n\n/*\n** Usage: sqlite3_extended_result_codes   DB    BOOLEAN\n**\n*/\nstatic int SQLITE_TCLAPI test_extended_result_codes(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int enable;\n  sqlite3 *db;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB BOOLEAN\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &enable) ) return TCL_ERROR;\n  sqlite3_extended_result_codes(db, enable);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_libversion_number\n**\n*/\nstatic int SQLITE_TCLAPI test_libversion_number(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_libversion_number()));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_table_column_metadata DB dbname tblname colname\n**\n*/\nstatic int SQLITE_TCLAPI test_table_column_metadata(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zDb;\n  const char *zTbl;\n  const char *zCol;\n  int rc;\n  Tcl_Obj *pRet;\n\n  const char *zDatatype;\n  const char *zCollseq;\n  int notnull;\n  int primarykey;\n  int autoincrement;\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB dbname tblname colname\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zDb = Tcl_GetString(objv[2]);\n  zTbl = Tcl_GetString(objv[3]);\n  zCol = objc==5 ? Tcl_GetString(objv[4]) : 0;\n\n  if( strlen(zDb)==0 ) zDb = 0;\n\n  rc = sqlite3_table_column_metadata(db, zDb, zTbl, zCol, \n      &zDatatype, &zCollseq, &notnull, &primarykey, &autoincrement);\n\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zDatatype, -1));\n  Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zCollseq, -1));\n  Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(notnull));\n  Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(primarykey));\n  Tcl_ListObjAppendElement(0, pRet, Tcl_NewIntObj(autoincrement));\n  Tcl_SetObjResult(interp, pRet);\n\n  return TCL_OK;\n}\n\n#ifndef SQLITE_OMIT_INCRBLOB\n\nstatic int SQLITE_TCLAPI blobHandleFromObj(\n  Tcl_Interp *interp, \n  Tcl_Obj *pObj,\n  sqlite3_blob **ppBlob\n){\n  char *z;\n  int n;\n\n  z = Tcl_GetStringFromObj(pObj, &n);\n  if( n==0 ){\n    *ppBlob = 0;\n  }else{\n    int notUsed;\n    Tcl_Channel channel;\n    ClientData instanceData;\n    \n    channel = Tcl_GetChannel(interp, z, &notUsed);\n    if( !channel ) return TCL_ERROR;\n\n    Tcl_Flush(channel);\n    Tcl_Seek(channel, 0, SEEK_SET);\n\n    instanceData = Tcl_GetChannelInstanceData(channel);\n    *ppBlob = *((sqlite3_blob **)instanceData);\n  }\n\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_blob_reopen(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_WideInt iRowid;\n  sqlite3_blob *pBlob;\n  int rc;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"CHANNEL ROWID\");\n    return TCL_ERROR;\n  }\n\n  if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;\n  if( Tcl_GetWideIntFromObj(interp, objv[2], &iRowid) ) return TCL_ERROR;\n\n  rc = sqlite3_blob_reopen(pBlob, iRowid);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  }\n\n  return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);\n}\n\n#endif\n\n/*\n** Usage: sqlite3_create_collation_v2 DB-HANDLE NAME CMP-PROC DEL-PROC\n**\n**   This Tcl proc is used for testing the experimental\n**   sqlite3_create_collation_v2() interface.\n*/\nstruct TestCollationX {\n  Tcl_Interp *interp;\n  Tcl_Obj *pCmp;\n  Tcl_Obj *pDel;\n};\ntypedef struct TestCollationX TestCollationX;\nstatic void testCreateCollationDel(void *pCtx){\n  TestCollationX *p = (TestCollationX *)pCtx;\n\n  int rc = Tcl_EvalObjEx(p->interp, p->pDel, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL);\n  if( rc!=TCL_OK ){\n    Tcl_BackgroundError(p->interp);\n  }\n\n  Tcl_DecrRefCount(p->pCmp);\n  Tcl_DecrRefCount(p->pDel);\n  sqlite3_free((void *)p);\n}\nstatic int testCreateCollationCmp(\n  void *pCtx,\n  int nLeft,\n  const void *zLeft,\n  int nRight,\n  const void *zRight\n){\n  TestCollationX *p = (TestCollationX *)pCtx;\n  Tcl_Obj *pScript = Tcl_DuplicateObj(p->pCmp);\n  int iRes = 0;\n\n  Tcl_IncrRefCount(pScript);\n  Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj((char *)zLeft, nLeft));\n  Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj((char *)zRight,nRight));\n\n  if( TCL_OK!=Tcl_EvalObjEx(p->interp, pScript, TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL)\n   || TCL_OK!=Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iRes)\n  ){\n    Tcl_BackgroundError(p->interp);\n  }\n  Tcl_DecrRefCount(pScript);\n\n  return iRes;\n}\nstatic int SQLITE_TCLAPI test_create_collation_v2(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  TestCollationX *p;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB-HANDLE NAME CMP-PROC DEL-PROC\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  p = (TestCollationX *)sqlite3_malloc(sizeof(TestCollationX));\n  p->pCmp = objv[3];\n  p->pDel = objv[4];\n  p->interp = interp;\n  Tcl_IncrRefCount(p->pCmp);\n  Tcl_IncrRefCount(p->pDel);\n\n  rc = sqlite3_create_collation_v2(db, Tcl_GetString(objv[2]), 16, \n      (void *)p, testCreateCollationCmp, testCreateCollationDel\n  );\n  if( rc!=SQLITE_MISUSE ){\n    Tcl_AppendResult(interp, \"sqlite3_create_collate_v2() failed to detect \"\n      \"an invalid encoding\", (char*)0);\n    return TCL_ERROR;\n  }\n  rc = sqlite3_create_collation_v2(db, Tcl_GetString(objv[2]), SQLITE_UTF8, \n      (void *)p, testCreateCollationCmp, testCreateCollationDel\n  );\n  return TCL_OK;\n}\n\n/*\n** USAGE: sqlite3_create_function_v2 DB NAME NARG ENC ?SWITCHES?\n**\n** Available switches are:\n**\n**   -func    SCRIPT\n**   -step    SCRIPT\n**   -final   SCRIPT\n**   -destroy SCRIPT\n*/\ntypedef struct CreateFunctionV2 CreateFunctionV2;\nstruct CreateFunctionV2 {\n  Tcl_Interp *interp;\n  Tcl_Obj *pFunc;                 /* Script for function invocation */\n  Tcl_Obj *pStep;                 /* Script for agg. step invocation */\n  Tcl_Obj *pFinal;                /* Script for agg. finalization invocation */\n  Tcl_Obj *pDestroy;              /* Destructor script */\n};\nstatic void cf2Func(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n}\nstatic void cf2Step(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){\n}\nstatic void cf2Final(sqlite3_context *ctx){\n}\nstatic void cf2Destroy(void *pUser){\n  CreateFunctionV2 *p = (CreateFunctionV2 *)pUser;\n\n  if( p->interp && p->pDestroy ){\n    int rc = Tcl_EvalObjEx(p->interp, p->pDestroy, 0);\n    if( rc!=TCL_OK ) Tcl_BackgroundError(p->interp);\n  }\n\n  if( p->pFunc ) Tcl_DecrRefCount(p->pFunc); \n  if( p->pStep ) Tcl_DecrRefCount(p->pStep); \n  if( p->pFinal ) Tcl_DecrRefCount(p->pFinal); \n  if( p->pDestroy ) Tcl_DecrRefCount(p->pDestroy); \n  sqlite3_free(p);\n}\nstatic int SQLITE_TCLAPI test_create_function_v2(\n  ClientData clientData,          /* Not used */\n  Tcl_Interp *interp,             /* The invoking TCL interpreter */\n  int objc,                       /* Number of arguments */\n  Tcl_Obj *CONST objv[]           /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zFunc;\n  int nArg;\n  int enc;\n  CreateFunctionV2 *p;\n  int i;\n  int rc;\n\n  struct EncTable {\n    const char *zEnc;\n    int enc;\n  } aEnc[] = {\n    {\"utf8\",    SQLITE_UTF8 },\n    {\"utf16\",   SQLITE_UTF16 },\n    {\"utf16le\", SQLITE_UTF16LE },\n    {\"utf16be\", SQLITE_UTF16BE },\n    {\"any\",     SQLITE_ANY },\n    {\"0\", 0 }\n  };\n\n  if( objc<5 || (objc%2)==0 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB NAME NARG ENC SWITCHES...\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zFunc = Tcl_GetString(objv[2]);\n  if( Tcl_GetIntFromObj(interp, objv[3], &nArg) ) return TCL_ERROR;\n  if( Tcl_GetIndexFromObjStruct(interp, objv[4], aEnc, sizeof(aEnc[0]), \n          \"encoding\", 0, &enc)\n  ){\n    return TCL_ERROR;\n  }\n  enc = aEnc[enc].enc;\n\n  p = sqlite3_malloc(sizeof(CreateFunctionV2));\n  assert( p );\n  memset(p, 0, sizeof(CreateFunctionV2));\n  p->interp = interp;\n\n  for(i=5; i<objc; i+=2){\n    int iSwitch;\n    const char *azSwitch[] = {\"-func\", \"-step\", \"-final\", \"-destroy\", 0};\n    if( Tcl_GetIndexFromObj(interp, objv[i], azSwitch, \"switch\", 0, &iSwitch) ){\n      sqlite3_free(p);\n      return TCL_ERROR;\n    }\n\n    switch( iSwitch ){\n      case 0: p->pFunc = objv[i+1];      break;\n      case 1: p->pStep = objv[i+1];      break;\n      case 2: p->pFinal = objv[i+1];     break;\n      case 3: p->pDestroy = objv[i+1];   break;\n    }\n  }\n  if( p->pFunc ) p->pFunc = Tcl_DuplicateObj(p->pFunc); \n  if( p->pStep ) p->pStep = Tcl_DuplicateObj(p->pStep); \n  if( p->pFinal ) p->pFinal = Tcl_DuplicateObj(p->pFinal); \n  if( p->pDestroy ) p->pDestroy = Tcl_DuplicateObj(p->pDestroy); \n\n  if( p->pFunc ) Tcl_IncrRefCount(p->pFunc); \n  if( p->pStep ) Tcl_IncrRefCount(p->pStep); \n  if( p->pFinal ) Tcl_IncrRefCount(p->pFinal); \n  if( p->pDestroy ) Tcl_IncrRefCount(p->pDestroy); \n\n  rc = sqlite3_create_function_v2(db, zFunc, nArg, enc, (void *)p, \n      (p->pFunc ? cf2Func : 0),\n      (p->pStep ? cf2Step : 0),\n      (p->pFinal ? cf2Final : 0),\n      cf2Destroy\n  );\n  if( rc!=SQLITE_OK ){\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC?\n*/\nstatic int SQLITE_TCLAPI test_load_extension(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_CmdInfo cmdInfo;\n  sqlite3 *db;\n  int rc;\n  char *zDb;\n  char *zFile;\n  char *zProc = 0;\n  char *zErr = 0;\n\n  if( objc!=4 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB-HANDLE FILE ?PROC?\");\n    return TCL_ERROR;\n  }\n  zDb = Tcl_GetString(objv[1]);\n  zFile = Tcl_GetString(objv[2]);\n  if( objc==4 ){\n    zProc = Tcl_GetString(objv[3]);\n  }\n\n  /* Extract the C database handle from the Tcl command name */\n  if( !Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){\n    Tcl_AppendResult(interp, \"command not found: \", zDb, (char*)0);\n    return TCL_ERROR;\n  }\n  db = ((struct SqliteDb*)cmdInfo.objClientData)->db;\n  assert(db);\n\n  /* Call the underlying C function. If an error occurs, set rc to \n  ** TCL_ERROR and load any error string into the interpreter. If no \n  ** error occurs, set rc to TCL_OK.\n  */\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n  rc = SQLITE_ERROR;\n  zErr = sqlite3_mprintf(\"this build omits sqlite3_load_extension()\");\n  (void)zProc;\n  (void)zFile;\n#else\n  rc = sqlite3_load_extension(db, zFile, zProc, &zErr);\n#endif\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, zErr ? zErr : \"\", TCL_VOLATILE);\n    rc = TCL_ERROR;\n  }else{\n    rc = TCL_OK;\n  }\n  sqlite3_free(zErr);\n\n  return rc;\n}\n\n/*\n** Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF\n*/\nstatic int SQLITE_TCLAPI test_enable_load(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_CmdInfo cmdInfo;\n  sqlite3 *db;\n  char *zDb;\n  int onoff;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB-HANDLE ONOFF\");\n    return TCL_ERROR;\n  }\n  zDb = Tcl_GetString(objv[1]);\n\n  /* Extract the C database handle from the Tcl command name */\n  if( !Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){\n    Tcl_AppendResult(interp, \"command not found: \", zDb, (char*)0);\n    return TCL_ERROR;\n  }\n  db = ((struct SqliteDb*)cmdInfo.objClientData)->db;\n  assert(db);\n\n  /* Get the onoff parameter */\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &onoff) ){\n    return TCL_ERROR;\n  }\n\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n  Tcl_AppendResult(interp, \"this build omits sqlite3_load_extension()\");\n  return TCL_ERROR;\n#else\n  sqlite3_enable_load_extension(db, onoff);\n  return TCL_OK;\n#endif\n}\n\n/*\n** Usage:  sqlite_abort\n**\n** Shutdown the process immediately.  This is not a clean shutdown.\n** This command is used to test the recoverability of a database in\n** the event of a program crash.\n*/\nstatic int SQLITE_TCLAPI sqlite_abort(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n#if defined(_MSC_VER)\n  /* We do this, otherwise the test will halt with a popup message\n   * that we have to click away before the test will continue.\n   */\n  _set_abort_behavior( 0, _CALL_REPORTFAULT );\n#endif\n  exit(255);\n  assert( interp==0 );   /* This will always fail */\n  return TCL_OK;\n}\n\n/*\n** The following routine is a user-defined SQL function whose purpose\n** is to test the sqlite_set_result() API.\n*/\nstatic void testFunc(sqlite3_context *context, int argc, sqlite3_value **argv){\n  while( argc>=2 ){\n    const char *zArg0 = (char*)sqlite3_value_text(argv[0]);\n    if( zArg0 ){\n      if( 0==sqlite3StrICmp(zArg0, \"int\") ){\n        sqlite3_result_int(context, sqlite3_value_int(argv[1]));\n      }else if( sqlite3StrICmp(zArg0,\"int64\")==0 ){\n        sqlite3_result_int64(context, sqlite3_value_int64(argv[1]));\n      }else if( sqlite3StrICmp(zArg0,\"string\")==0 ){\n        sqlite3_result_text(context, (char*)sqlite3_value_text(argv[1]), -1,\n            SQLITE_TRANSIENT);\n      }else if( sqlite3StrICmp(zArg0,\"double\")==0 ){\n        sqlite3_result_double(context, sqlite3_value_double(argv[1]));\n      }else if( sqlite3StrICmp(zArg0,\"null\")==0 ){\n        sqlite3_result_null(context);\n      }else if( sqlite3StrICmp(zArg0,\"value\")==0 ){\n        sqlite3_result_value(context, argv[sqlite3_value_int(argv[1])]);\n      }else{\n        goto error_out;\n      }\n    }else{\n      goto error_out;\n    }\n    argc -= 2;\n    argv += 2;\n  }\n  return;\n\nerror_out:\n  sqlite3_result_error(context,\"first argument should be one of: \"\n      \"int int64 string double null value\", -1);\n}\n\n/*\n** Usage:   sqlite_register_test_function  DB  NAME\n**\n** Register the test SQL function on the database DB under the name NAME.\n*/\nstatic int SQLITE_TCLAPI test_register_func(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3 *db;\n  int rc;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" DB FUNCTION-NAME\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, \n      testFunc, 0, 0);\n  if( rc!=0 ){\n    Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);\n    return TCL_ERROR;\n  }\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_finalize  STMT \n**\n** Finalize a statement handle.\n*/\nstatic int SQLITE_TCLAPI test_finalize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  sqlite3 *db = 0;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" <STMT>\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n\n  if( pStmt ){\n    db = StmtToDb(pStmt);\n  }\n  rc = sqlite3_finalize(pStmt);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  if( db && sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_stmt_status  STMT  CODE  RESETFLAG\n**\n** Get the value of a status counter from a statement.\n*/\nstatic int SQLITE_TCLAPI test_stmt_status(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int iValue;\n  int i, op = 0, resetFlag;\n  const char *zOpName;\n  sqlite3_stmt *pStmt;\n\n  static const struct {\n    const char *zName;\n    int op;\n  } aOp[] = {\n    { \"SQLITE_STMTSTATUS_FULLSCAN_STEP\",   SQLITE_STMTSTATUS_FULLSCAN_STEP   },\n    { \"SQLITE_STMTSTATUS_SORT\",            SQLITE_STMTSTATUS_SORT            },\n    { \"SQLITE_STMTSTATUS_AUTOINDEX\",       SQLITE_STMTSTATUS_AUTOINDEX       },\n    { \"SQLITE_STMTSTATUS_VM_STEP\",         SQLITE_STMTSTATUS_VM_STEP         },\n    { \"SQLITE_STMTSTATUS_REPREPARE\",       SQLITE_STMTSTATUS_REPREPARE       },\n    { \"SQLITE_STMTSTATUS_RUN\",             SQLITE_STMTSTATUS_RUN             },\n    { \"SQLITE_STMTSTATUS_MEMUSED\",         SQLITE_STMTSTATUS_MEMUSED         },\n  };\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT PARAMETER RESETFLAG\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  zOpName = Tcl_GetString(objv[2]);\n  for(i=0; i<ArraySize(aOp); i++){\n    if( strcmp(aOp[i].zName, zOpName)==0 ){\n      op = aOp[i].op;\n      break;\n    }\n  }\n  if( i>=ArraySize(aOp) ){\n    if( Tcl_GetIntFromObj(interp, objv[2], &op) ) return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR;\n  iValue = sqlite3_stmt_status(pStmt, op, resetFlag);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(iValue));\n  return TCL_OK;\n}\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Usage:  sqlite3_stmt_scanstatus STMT IDX\n*/\nstatic int SQLITE_TCLAPI test_stmt_scanstatus(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;            /* First argument */\n  int idx;                        /* Second argument */\n\n  const char *zName;\n  const char *zExplain;\n  sqlite3_int64 nLoop;\n  sqlite3_int64 nVisit;\n  double rEst;\n  int res;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT IDX\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n\n  res = sqlite3_stmt_scanstatus(pStmt, idx, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop);\n  if( res==0 ){\n    Tcl_Obj *pRet = Tcl_NewObj();\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(\"nLoop\", -1));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewWideIntObj(nLoop));\n    sqlite3_stmt_scanstatus(pStmt, idx, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(\"nVisit\", -1));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewWideIntObj(nVisit));\n    sqlite3_stmt_scanstatus(pStmt, idx, SQLITE_SCANSTAT_EST, (void*)&rEst);\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(\"nEst\", -1));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewDoubleObj(rEst));\n    sqlite3_stmt_scanstatus(pStmt, idx, SQLITE_SCANSTAT_NAME, (void*)&zName);\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(\"zName\", -1));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zName, -1));\n    sqlite3_stmt_scanstatus(pStmt, idx, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(\"zExplain\", -1));\n    Tcl_ListObjAppendElement(0, pRet, Tcl_NewStringObj(zExplain, -1));\n    Tcl_SetObjResult(interp, pRet);\n  }else{\n    Tcl_ResetResult(interp);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_stmt_scanstatus_reset  STMT\n*/\nstatic int SQLITE_TCLAPI test_stmt_scanstatus_reset(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;            /* First argument */\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  sqlite3_stmt_scanstatus_reset(pStmt);\n  return TCL_OK;\n}\n#endif\n\n#ifdef SQLITE_ENABLE_SQLLOG\n/*\n** Usage:  sqlite3_config_sqllog\n**\n** Zero the SQLITE_CONFIG_SQLLOG configuration\n*/\nstatic int SQLITE_TCLAPI test_config_sqllog(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  sqlite3_config(SQLITE_CONFIG_SQLLOG, 0, 0);\n  return TCL_OK;\n}\n#endif\n\n/*\n** Usage: vfs_current_time_int64\n**\n** Return the value returned by the default VFS's xCurrentTimeInt64 method.\n*/\nstatic int SQLITE_TCLAPI vfsCurrentTimeInt64(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  i64 t;\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  pVfs->xCurrentTimeInt64(pVfs, &t);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(t));\n  return TCL_OK;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_get DB DBNAME\n*/\nstatic int SQLITE_TCLAPI test_snapshot_get(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  char *zName;\n  sqlite3_snapshot *pSnapshot = 0;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n\n  rc = sqlite3_snapshot_get(db, zName, &pSnapshot);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }else{\n    char zBuf[100];\n    if( sqlite3TestMakePointerStr(interp, zBuf, pSnapshot) ) return TCL_ERROR;\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(zBuf, -1));\n  }\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_recover DB DBNAME\n*/\nstatic int SQLITE_TCLAPI test_snapshot_recover(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  char *zName;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n\n  rc = sqlite3_snapshot_recover(db, zName);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }else{\n    Tcl_ResetResult(interp);\n  }\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT\n*/\nstatic int SQLITE_TCLAPI test_snapshot_open(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  char *zName;\n  sqlite3_snapshot *pSnapshot;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME SNAPSHOT\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n  pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[3]));\n\n  rc = sqlite3_snapshot_open(db, zName, pSnapshot);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_free SNAPSHOT\n*/\nstatic int SQLITE_TCLAPI test_snapshot_free(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_snapshot *pSnapshot;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SNAPSHOT\");\n    return TCL_ERROR;\n  }\n  pSnapshot = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  sqlite3_snapshot_free(pSnapshot);\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2\n*/\nstatic int SQLITE_TCLAPI test_snapshot_cmp(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int res;\n  sqlite3_snapshot *p1;\n  sqlite3_snapshot *p2;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SNAPSHOT1 SNAPSHOT2\");\n    return TCL_ERROR;\n  }\n  p1 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  p2 = (sqlite3_snapshot*)sqlite3TestTextToPtr(Tcl_GetString(objv[2]));\n  res = sqlite3_snapshot_cmp(p1, p2);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(res));\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_get_blob DB DBNAME\n*/\nstatic int SQLITE_TCLAPI test_snapshot_get_blob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  char *zName;\n  sqlite3_snapshot *pSnapshot = 0;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n\n  rc = sqlite3_snapshot_get(db, zName, &pSnapshot);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }else{\n    Tcl_SetObjResult(interp, \n        Tcl_NewByteArrayObj((unsigned char*)pSnapshot, sizeof(sqlite3_snapshot))\n    );\n    sqlite3_snapshot_free(pSnapshot);\n  }\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  /*\n  ** Usage: sqlite3_snapshot_open_blob DB DBNAME SNAPSHOT\n*/\nstatic int SQLITE_TCLAPI test_snapshot_open_blob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  char *zName;\n  unsigned char *pBlob;\n  int nBlob;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME SNAPSHOT\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n  pBlob = Tcl_GetByteArrayFromObj(objv[3], &nBlob);\n  if( nBlob!=sizeof(sqlite3_snapshot) ){\n    Tcl_AppendResult(interp, \"bad SNAPSHOT\", 0);\n    return TCL_ERROR;\n  }\n  rc = sqlite3_snapshot_open(db, zName, (sqlite3_snapshot*)pBlob);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Usage: sqlite3_snapshot_cmp_blob SNAPSHOT1 SNAPSHOT2\n*/\nstatic int SQLITE_TCLAPI test_snapshot_cmp_blob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int res;\n  unsigned char *p1;\n  unsigned char *p2;\n  int n1;\n  int n2;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SNAPSHOT1 SNAPSHOT2\");\n    return TCL_ERROR;\n  }\n\n  p1 = Tcl_GetByteArrayFromObj(objv[1], &n1);\n  p2 = Tcl_GetByteArrayFromObj(objv[2], &n2);\n\n  if( n1!=sizeof(sqlite3_snapshot) || n1!=n2 ){\n    Tcl_AppendResult(interp, \"bad SNAPSHOT\", 0);\n    return TCL_ERROR;\n  }\n\n  res = sqlite3_snapshot_cmp((sqlite3_snapshot*)p1, (sqlite3_snapshot*)p2);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(res));\n  return TCL_OK;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n/*\n** Usage: sqlite3_delete_database FILENAME\n*/\nint sqlite3_delete_database(const char*);   /* in test_delete.c */\nstatic int SQLITE_TCLAPI test_delete_database(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  const char *zFile;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILE\");\n    return TCL_ERROR;\n  }\n  zFile = (const char*)Tcl_GetString(objv[1]);\n  rc = sqlite3_delete_database(zFile);\n\n  Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n  return TCL_OK;\n}\n\n/*\n** Usage: atomic_batch_write PATH\n*/\nstatic int SQLITE_TCLAPI test_atomic_batch_write(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char *zFile = 0;                /* Path to file to test */\n  sqlite3 *db = 0;                /* Database handle */\n  sqlite3_file *pFd = 0;          /* SQLite fd open on zFile */\n  int bRes = 0;                   /* Integer result of this command */\n  int dc = 0;                     /* Device-characteristics mask */\n  int rc;                         /* sqlite3_open() return code */\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PATH\");\n    return TCL_ERROR;\n  }\n  zFile = Tcl_GetString(objv[1]);\n\n  rc = sqlite3_open(zFile, &db);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3_errmsg(db), 0);\n    sqlite3_close(db);\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);\n  dc = pFd->pMethods->xDeviceCharacteristics(pFd);\n  if( dc & SQLITE_IOCAP_BATCH_ATOMIC ){\n    bRes = 1;\n  }\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(bRes));\n  sqlite3_close(db);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_next_stmt  DB  STMT\n**\n** Return the next statment in sequence after STMT.\n*/\nstatic int SQLITE_TCLAPI test_next_stmt(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  sqlite3 *db = 0;\n  char zBuf[50];\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB STMT\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt) ) return TCL_ERROR;\n  pStmt = sqlite3_next_stmt(db, pStmt);\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_stmt_readonly  STMT\n**\n** Return true if STMT is a NULL pointer or a pointer to a statement\n** that is guaranteed to leave the database unmodified.\n*/\nstatic int SQLITE_TCLAPI test_stmt_readonly(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  rc = sqlite3_stmt_readonly(pStmt);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_stmt_busy  STMT\n**\n** Return true if STMT is a non-NULL pointer to a statement\n** that has been stepped but not to completion.\n*/\nstatic int SQLITE_TCLAPI test_stmt_busy(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  rc = sqlite3_stmt_busy(pStmt);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc));\n  return TCL_OK;\n}\n\n/*\n** Usage:  uses_stmt_journal  STMT\n**\n** Return true if STMT uses a statement journal.\n*/\nstatic int SQLITE_TCLAPI uses_stmt_journal(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  sqlite3_stmt_readonly(pStmt);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(((Vdbe *)pStmt)->usesStmtJournal));\n  return TCL_OK;\n}\n\n\n/*\n** Usage:  sqlite3_reset  STMT \n**\n** Reset a statement handle.\n*/\nstatic int SQLITE_TCLAPI test_reset(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" <STMT>\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n\n  rc = sqlite3_reset(pStmt);\n  if( pStmt && sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ){\n    return TCL_ERROR;\n  }\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n/*\n  if( rc ){\n    return TCL_ERROR;\n  }\n*/\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_expired STMT \n**\n** Return TRUE if a recompilation of the statement is recommended.\n*/\nstatic int SQLITE_TCLAPI test_expired(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_stmt *pStmt;\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" <STMT>\", 0);\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(sqlite3_expired(pStmt)));\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_transfer_bindings FROMSTMT TOSTMT\n**\n** Transfer all bindings from FROMSTMT over to TOSTMT\n*/\nstatic int SQLITE_TCLAPI test_transfer_bind(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_stmt *pStmt1, *pStmt2;\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" FROM-STMT TO-STMT\", 0);\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt1)) return TCL_ERROR;\n  if( getStmtPointer(interp, Tcl_GetString(objv[2]), &pStmt2)) return TCL_ERROR;\n  Tcl_SetObjResult(interp, \n     Tcl_NewIntObj(sqlite3_transfer_bindings(pStmt1,pStmt2)));\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_changes DB\n**\n** Return the number of changes made to the database by the last SQL\n** execution.\n*/\nstatic int SQLITE_TCLAPI test_changes(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n       Tcl_GetString(objv[0]), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_changes(db)));\n  return TCL_OK;\n}\n\n/*\n** This is the \"static_bind_value\" that variables are bound to when\n** the FLAG option of sqlite3_bind is \"static\"\n*/\nstatic char *sqlite_static_bind_value = 0;\nstatic int sqlite_static_bind_nbyte = 0;\n\n/*\n** Usage:  sqlite3_bind  VM  IDX  VALUE  FLAGS\n**\n** Sets the value of the IDX-th occurrence of \"?\" in the original SQL\n** string.  VALUE is the new value.  If FLAGS==\"null\" then VALUE is\n** ignored and the value is set to NULL.  If FLAGS==\"static\" then\n** the value is set to the value of a static variable named\n** \"sqlite_static_bind_value\".  If FLAGS==\"normal\" then a copy\n** of the VALUE is made.  If FLAGS==\"blob10\" then a VALUE is ignored\n** an a 10-byte blob \"abc\\000xyz\\000pq\" is inserted.\n*/\nstatic int SQLITE_TCLAPI test_bind(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  int idx;\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n       \" VM IDX VALUE (null|static|normal)\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, argv[1], &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetInt(interp, argv[2], &idx) ) return TCL_ERROR;\n  if( strcmp(argv[4],\"null\")==0 ){\n    rc = sqlite3_bind_null(pStmt, idx);\n  }else if( strcmp(argv[4],\"static\")==0 ){\n    rc = sqlite3_bind_text(pStmt, idx, sqlite_static_bind_value, -1, 0);\n  }else if( strcmp(argv[4],\"static-nbytes\")==0 ){\n    rc = sqlite3_bind_text(pStmt, idx, sqlite_static_bind_value,\n                                       sqlite_static_bind_nbyte, 0);\n  }else if( strcmp(argv[4],\"normal\")==0 ){\n    rc = sqlite3_bind_text(pStmt, idx, argv[3], -1, SQLITE_TRANSIENT);\n  }else if( strcmp(argv[4],\"blob10\")==0 ){\n    rc = sqlite3_bind_text(pStmt, idx, \"abc\\000xyz\\000pq\", 10, SQLITE_STATIC);\n  }else{\n    Tcl_AppendResult(interp, \"4th argument should be \"\n        \"\\\"null\\\" or \\\"static\\\" or \\\"normal\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc ){\n    char zBuf[50];\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"(%d) \", rc);\n    Tcl_AppendResult(interp, zBuf, sqlite3ErrStr(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Usage: add_test_collate <db ptr> <utf8> <utf16le> <utf16be>\n**\n** This function is used to test that SQLite selects the correct collation\n** sequence callback when multiple versions (for different text encodings)\n** are available.\n**\n** Calling this routine registers the collation sequence \"test_collate\"\n** with database handle <db>. The second argument must be a list of three\n** boolean values. If the first is true, then a version of test_collate is\n** registered for UTF-8, if the second is true, a version is registered for\n** UTF-16le, if the third is true, a UTF-16be version is available.\n** Previous versions of test_collate are deleted.\n**\n** The collation sequence test_collate is implemented by calling the\n** following TCL script:\n**\n**   \"test_collate <enc> <lhs> <rhs>\"\n**\n** The <lhs> and <rhs> are the two values being compared, encoded in UTF-8.\n** The <enc> parameter is the encoding of the collation function that\n** SQLite selected to call. The TCL test script implements the\n** \"test_collate\" proc.\n**\n** Note that this will only work with one interpreter at a time, as the\n** interp pointer to use when evaluating the TCL script is stored in\n** pTestCollateInterp.\n*/\nstatic Tcl_Interp* pTestCollateInterp;\nstatic int test_collate_func(\n  void *pCtx, \n  int nA, const void *zA,\n  int nB, const void *zB\n){\n  Tcl_Interp *i = pTestCollateInterp;\n  int encin = SQLITE_PTR_TO_INT(pCtx);\n  int res;\n  int n;\n\n  sqlite3_value *pVal;\n  Tcl_Obj *pX;\n\n  pX = Tcl_NewStringObj(\"test_collate\", -1);\n  Tcl_IncrRefCount(pX);\n\n  switch( encin ){\n    case SQLITE_UTF8:\n      Tcl_ListObjAppendElement(i,pX,Tcl_NewStringObj(\"UTF-8\",-1));\n      break;\n    case SQLITE_UTF16LE:\n      Tcl_ListObjAppendElement(i,pX,Tcl_NewStringObj(\"UTF-16LE\",-1));\n      break;\n    case SQLITE_UTF16BE:\n      Tcl_ListObjAppendElement(i,pX,Tcl_NewStringObj(\"UTF-16BE\",-1));\n      break;\n    default:\n      assert(0);\n  }\n\n  sqlite3BeginBenignMalloc();\n  pVal = sqlite3ValueNew(0);\n  if( pVal ){\n    sqlite3ValueSetStr(pVal, nA, zA, encin, SQLITE_STATIC);\n    n = sqlite3_value_bytes(pVal);\n    Tcl_ListObjAppendElement(i,pX,\n        Tcl_NewStringObj((char*)sqlite3_value_text(pVal),n));\n    sqlite3ValueSetStr(pVal, nB, zB, encin, SQLITE_STATIC);\n    n = sqlite3_value_bytes(pVal);\n    Tcl_ListObjAppendElement(i,pX,\n        Tcl_NewStringObj((char*)sqlite3_value_text(pVal),n));\n    sqlite3ValueFree(pVal);\n  }\n  sqlite3EndBenignMalloc();\n\n  Tcl_EvalObjEx(i, pX, 0);\n  Tcl_DecrRefCount(pX);\n  Tcl_GetIntFromObj(i, Tcl_GetObjResult(i), &res);\n  return res;\n}\nstatic int SQLITE_TCLAPI test_collate(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int val;\n  sqlite3_value *pVal;\n  int rc;\n\n  if( objc!=5 ) goto bad_args;\n  pTestCollateInterp = interp;\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;\n  rc = sqlite3_create_collation(db, \"test_collate\", SQLITE_UTF8, \n          (void *)SQLITE_UTF8, val?test_collate_func:0);\n  if( rc==SQLITE_OK ){\n    const void *zUtf16;\n    if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[3], &val) ) return TCL_ERROR;\n    rc = sqlite3_create_collation(db, \"test_collate\", SQLITE_UTF16LE, \n            (void *)SQLITE_UTF16LE, val?test_collate_func:0);\n    if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[4], &val) ) return TCL_ERROR;\n\n#if 0\n    if( sqlite3_iMallocFail>0 ){\n      sqlite3_iMallocFail++;\n    }\n#endif\n    sqlite3_mutex_enter(db->mutex);\n    pVal = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(pVal, -1, \"test_collate\", SQLITE_UTF8, SQLITE_STATIC);\n    zUtf16 = sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n    if( db->mallocFailed ){\n      rc = SQLITE_NOMEM;\n    }else{\n      rc = sqlite3_create_collation16(db, zUtf16, SQLITE_UTF16BE, \n          (void *)SQLITE_UTF16BE, val?test_collate_func:0);\n    }\n    sqlite3ValueFree(pVal);\n    sqlite3_mutex_leave(db->mutex);\n  }\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  \n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n\nbad_args:\n  Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n      Tcl_GetStringFromObj(objv[0], 0), \" <DB> <utf8> <utf16le> <utf16be>\", 0);\n  return TCL_ERROR;\n}\n\n/*\n** Usage: add_test_utf16bin_collate <db ptr>\n**\n** Add a utf-16 collation sequence named \"utf16bin\" to the database\n** handle. This collation sequence compares arguments in the same way as the\n** built-in collation \"binary\".\n*/\nstatic int test_utf16bin_collate_func(\n  void *pCtx, \n  int nA, const void *zA,\n  int nB, const void *zB\n){\n  int nCmp = (nA>nB ? nB : nA);\n  int res = memcmp(zA, zB, nCmp);\n  if( res==0 ) res = nA - nB;\n  return res;\n}\nstatic int SQLITE_TCLAPI test_utf16bin_collate(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ) goto bad_args;\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  rc = sqlite3_create_collation(db, \"utf16bin\", SQLITE_UTF16, 0, \n      test_utf16bin_collate_func\n  );\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n\nbad_args:\n  Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n  return TCL_ERROR;\n}\n\n/*\n** When the collation needed callback is invoked, record the name of \n** the requested collating function here.  The recorded name is linked\n** to a TCL variable and used to make sure that the requested collation\n** name is correct.\n*/\nstatic char zNeededCollation[200];\nstatic char *pzNeededCollation = zNeededCollation;\n\n\n/*\n** Called when a collating sequence is needed.  Registered using\n** sqlite3_collation_needed16().\n*/\nstatic void test_collate_needed_cb(\n  void *pCtx, \n  sqlite3 *db,\n  int eTextRep,\n  const void *pName\n){\n  int enc = ENC(db);\n  int i;\n  char *z;\n  for(z = (char*)pName, i=0; *z || z[1]; z++){\n    if( *z ) zNeededCollation[i++] = *z;\n  }\n  zNeededCollation[i] = 0;\n  sqlite3_create_collation(\n      db, \"test_collate\", ENC(db), SQLITE_INT_TO_PTR(enc), test_collate_func);\n}\n\n/*\n** Usage: add_test_collate_needed DB\n*/\nstatic int SQLITE_TCLAPI test_collate_needed(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ) goto bad_args;\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_collation_needed16(db, 0, test_collate_needed_cb);\n  zNeededCollation[0] = 0;\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  return TCL_OK;\n\nbad_args:\n  Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n  return TCL_ERROR;\n}\n\n/*\n** tclcmd:   add_alignment_test_collations  DB\n**\n** Add two new collating sequences to the database DB\n**\n**     utf16_aligned\n**     utf16_unaligned\n**\n** Both collating sequences use the same sort order as BINARY.\n** The only difference is that the utf16_aligned collating\n** sequence is declared with the SQLITE_UTF16_ALIGNED flag.\n** Both collating functions increment the unaligned utf16 counter\n** whenever they see a string that begins on an odd byte boundary.\n*/\nstatic int unaligned_string_counter = 0;\nstatic int alignmentCollFunc(\n  void *NotUsed,\n  int nKey1, const void *pKey1,\n  int nKey2, const void *pKey2\n){\n  int rc, n;\n  n = nKey1<nKey2 ? nKey1 : nKey2;\n  if( nKey1>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey1))) ) unaligned_string_counter++;\n  if( nKey2>0 && 1==(1&(SQLITE_PTR_TO_INT(pKey2))) ) unaligned_string_counter++;\n  rc = memcmp(pKey1, pKey2, n);\n  if( rc==0 ){\n    rc = nKey1 - nKey2;\n  }\n  return rc;\n}\nstatic int SQLITE_TCLAPI add_alignment_test_collations(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  if( objc>=2 ){\n    if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n    sqlite3_create_collation(db, \"utf16_unaligned\", SQLITE_UTF16, \n        0, alignmentCollFunc);\n    sqlite3_create_collation(db, \"utf16_aligned\", SQLITE_UTF16_ALIGNED, \n        0, alignmentCollFunc);\n  }\n  return SQLITE_OK;\n}\n#endif /* !defined(SQLITE_OMIT_UTF16) */\n\n/*\n** Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be>\n**\n** This function is used to test that SQLite selects the correct user\n** function callback when multiple versions (for different text encodings)\n** are available.\n**\n** Calling this routine registers up to three versions of the user function\n** \"test_function\" with database handle <db>.  If the second argument is\n** true, then a version of test_function is registered for UTF-8, if the\n** third is true, a version is registered for UTF-16le, if the fourth is\n** true, a UTF-16be version is available.  Previous versions of\n** test_function are deleted.\n**\n** The user function is implemented by calling the following TCL script:\n**\n**   \"test_function <enc> <arg>\"\n**\n** Where <enc> is one of UTF-8, UTF-16LE or UTF16BE, and <arg> is the\n** single argument passed to the SQL function. The value returned by\n** the TCL script is used as the return value of the SQL function. It\n** is passed to SQLite using UTF-16BE for a UTF-8 test_function(), UTF-8\n** for a UTF-16LE test_function(), and UTF-16LE for an implementation that\n** prefers UTF-16BE.\n*/\n#ifndef SQLITE_OMIT_UTF16\nstatic void test_function_utf8(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  Tcl_Interp *interp;\n  Tcl_Obj *pX;\n  sqlite3_value *pVal;\n  interp = (Tcl_Interp *)sqlite3_user_data(pCtx);\n  pX = Tcl_NewStringObj(\"test_function\", -1);\n  Tcl_IncrRefCount(pX);\n  Tcl_ListObjAppendElement(interp, pX, Tcl_NewStringObj(\"UTF-8\", -1));\n  Tcl_ListObjAppendElement(interp, pX, \n      Tcl_NewStringObj((char*)sqlite3_value_text(argv[0]), -1));\n  Tcl_EvalObjEx(interp, pX, 0);\n  Tcl_DecrRefCount(pX);\n  sqlite3_result_text(pCtx, Tcl_GetStringResult(interp), -1, SQLITE_TRANSIENT);\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, Tcl_GetStringResult(interp), \n      SQLITE_UTF8, SQLITE_STATIC);\n  sqlite3_result_text16be(pCtx, sqlite3_value_text16be(pVal),\n      -1, SQLITE_TRANSIENT);\n  sqlite3ValueFree(pVal);\n}\nstatic void test_function_utf16le(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  Tcl_Interp *interp;\n  Tcl_Obj *pX;\n  sqlite3_value *pVal;\n  interp = (Tcl_Interp *)sqlite3_user_data(pCtx);\n  pX = Tcl_NewStringObj(\"test_function\", -1);\n  Tcl_IncrRefCount(pX);\n  Tcl_ListObjAppendElement(interp, pX, Tcl_NewStringObj(\"UTF-16LE\", -1));\n  Tcl_ListObjAppendElement(interp, pX, \n      Tcl_NewStringObj((char*)sqlite3_value_text(argv[0]), -1));\n  Tcl_EvalObjEx(interp, pX, 0);\n  Tcl_DecrRefCount(pX);\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, Tcl_GetStringResult(interp), \n      SQLITE_UTF8, SQLITE_STATIC);\n  sqlite3_result_text(pCtx,(char*)sqlite3_value_text(pVal),-1,SQLITE_TRANSIENT);\n  sqlite3ValueFree(pVal);\n}\nstatic void test_function_utf16be(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  Tcl_Interp *interp;\n  Tcl_Obj *pX;\n  sqlite3_value *pVal;\n  interp = (Tcl_Interp *)sqlite3_user_data(pCtx);\n  pX = Tcl_NewStringObj(\"test_function\", -1);\n  Tcl_IncrRefCount(pX);\n  Tcl_ListObjAppendElement(interp, pX, Tcl_NewStringObj(\"UTF-16BE\", -1));\n  Tcl_ListObjAppendElement(interp, pX, \n      Tcl_NewStringObj((char*)sqlite3_value_text(argv[0]), -1));\n  Tcl_EvalObjEx(interp, pX, 0);\n  Tcl_DecrRefCount(pX);\n  pVal = sqlite3ValueNew(0);\n  sqlite3ValueSetStr(pVal, -1, Tcl_GetStringResult(interp), \n      SQLITE_UTF8, SQLITE_STATIC);\n  sqlite3_result_text16(pCtx, sqlite3_value_text16le(pVal),\n      -1, SQLITE_TRANSIENT);\n  sqlite3_result_text16be(pCtx, sqlite3_value_text16le(pVal),\n      -1, SQLITE_TRANSIENT);\n  sqlite3_result_text16le(pCtx, sqlite3_value_text16le(pVal),\n      -1, SQLITE_TRANSIENT);\n  sqlite3ValueFree(pVal);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nstatic int SQLITE_TCLAPI test_function(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3 *db;\n  int val;\n\n  if( objc!=5 ) goto bad_args;\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;\n  if( val ){\n    sqlite3_create_function(db, \"test_function\", 1, SQLITE_UTF8, \n        interp, test_function_utf8, 0, 0);\n  }\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[3], &val) ) return TCL_ERROR;\n  if( val ){\n    sqlite3_create_function(db, \"test_function\", 1, SQLITE_UTF16LE, \n        interp, test_function_utf16le, 0, 0);\n  }\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[4], &val) ) return TCL_ERROR;\n  if( val ){\n    sqlite3_create_function(db, \"test_function\", 1, SQLITE_UTF16BE, \n        interp, test_function_utf16be, 0, 0);\n  }\n\n  return TCL_OK;\nbad_args:\n  Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n      Tcl_GetStringFromObj(objv[0], 0), \" <DB> <utf8> <utf16le> <utf16be>\", 0);\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_ERROR;\n}\n\n/*\n** Usage:         sqlite3_test_errstr <err code>\n**\n** Test that the english language string equivalents for sqlite error codes\n** are sane. The parameter is an integer representing an sqlite error code.\n** The result is a list of two elements, the string representation of the\n** error code and the english language explanation.\n*/\nstatic int SQLITE_TCLAPI test_errstr(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char *zCode;\n  int i;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"<error code>\");\n  }\n\n  zCode = Tcl_GetString(objv[1]);\n  for(i=0; i<200; i++){\n    if( 0==strcmp(t1ErrorName(i), zCode) ) break;\n  }\n  Tcl_SetResult(interp, (char *)sqlite3ErrStr(i), 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:    breakpoint\n**\n** This routine exists for one purpose - to provide a place to put a\n** breakpoint with GDB that can be triggered using TCL code.  The use\n** for this is when a particular test fails on (say) the 1485th iteration.\n** In the TCL test script, we can add code like this:\n**\n**     if {$i==1485} breakpoint\n**\n** Then run testfixture in the debugger and wait for the breakpoint to\n** fire.  Then additional breakpoints can be set to trace down the bug.\n*/\nstatic int SQLITE_TCLAPI test_breakpoint(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  char **argv            /* Text of each argument */\n){\n  return TCL_OK;         /* Do nothing */\n}\n\n/*\n** Usage:   sqlite3_bind_zeroblob  STMT IDX N\n**\n** Test the sqlite3_bind_zeroblob interface.  STMT is a prepared statement.\n** IDX is the index of a wildcard in the prepared statement.  This command\n** binds a N-byte zero-filled BLOB to the wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_zeroblob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  int n;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT IDX N\");\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &n) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_zeroblob(pStmt, idx, n);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_zeroblob64  STMT IDX N\n**\n** Test the sqlite3_bind_zeroblob64 interface.  STMT is a prepared statement.\n** IDX is the index of a wildcard in the prepared statement.  This command\n** binds a N-byte zero-filled BLOB to the wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_zeroblob64(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  Tcl_WideInt n;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT IDX N\");\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n  if( Tcl_GetWideIntFromObj(interp, objv[3], &n) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_zeroblob64(pStmt, idx, n);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_int  STMT N VALUE\n**\n** Test the sqlite3_bind_int interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a 32-bit integer VALUE to that wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_int(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  int value;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N VALUE\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &value) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_int(pStmt, idx, value);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   intarray_addr  INT  ...\n**\n** Return the address of a C-language array of 32-bit integers.\n**\n** Space to hold the array is obtained from malloc().  Call this procedure once\n** with no arguments in order to release memory.  Each call to this procedure\n** overwrites the previous array.\n*/\nstatic int SQLITE_TCLAPI test_intarray_addr(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int i;\n  static int *p = 0;\n\n  sqlite3_free(p);\n  p = 0;\n  if( objc>1 ){\n    p = sqlite3_malloc( sizeof(p[0])*(objc-1) );\n    if( p==0 ) return TCL_ERROR;\n    for(i=0; i<objc-1; i++){\n      if( Tcl_GetIntFromObj(interp, objv[1+i], &p[i]) ){\n        sqlite3_free(p);\n        p = 0;\n        return TCL_ERROR;\n      }\n    }\n  }  \n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));\n  return TCL_OK;\n}\n/*\n** Usage:   intarray_addr  INT  ...\n**\n** Return the address of a C-language array of 32-bit integers.\n**\n** Space to hold the array is obtained from malloc().  Call this procedure once\n** with no arguments in order to release memory.  Each call to this procedure\n** overwrites the previous array.\n*/\nstatic int SQLITE_TCLAPI test_int64array_addr(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int i;\n  static sqlite3_int64 *p = 0;\n\n  sqlite3_free(p);\n  p = 0;\n  if( objc>1 ){\n    p = sqlite3_malloc( sizeof(p[0])*(objc-1) );\n    if( p==0 ) return TCL_ERROR;\n    for(i=0; i<objc-1; i++){\n      Tcl_WideInt v;\n      if( Tcl_GetWideIntFromObj(interp, objv[1+i], &v) ){\n        sqlite3_free(p);\n        p = 0;\n        return TCL_ERROR;\n      }\n      p[i] = v;\n    }\n  }  \n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));\n  return TCL_OK;\n}\n/*\n** Usage:   doublearray_addr  INT  ...\n**\n** Return the address of a C-language array of doubles.\n**\n** Space to hold the array is obtained from malloc().  Call this procedure once\n** with no arguments in order to release memory.  Each call to this procedure\n** overwrites the previous array.\n*/\nstatic int SQLITE_TCLAPI test_doublearray_addr(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int i;\n  static double *p = 0;\n\n  sqlite3_free(p);\n  p = 0;\n  if( objc>1 ){\n    p = sqlite3_malloc( sizeof(p[0])*(objc-1) );\n    if( p==0 ) return TCL_ERROR;\n    for(i=0; i<objc-1; i++){\n      if( Tcl_GetDoubleFromObj(interp, objv[1+i], &p[i]) ){\n        sqlite3_free(p);\n        p = 0;\n        return TCL_ERROR;\n      }\n    }\n  }  \n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));\n  return TCL_OK;\n}\n/*\n** Usage:   textarray_addr  TEXT ...\n**\n** Return the address of a C-language array of strings.\n**\n** Space to hold the array is obtained from malloc().  Call this procedure once\n** with no arguments in order to release memory.  Each call to this procedure\n** overwrites the previous array.\n*/\nstatic int SQLITE_TCLAPI test_textarray_addr(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int i;\n  static int n = 0;\n  static char **p = 0;\n\n  for(i=0; i<n; i++) sqlite3_free(p[i]);\n  sqlite3_free(p);\n  p = 0;\n  if( objc>1 ){\n    p = sqlite3_malloc( sizeof(p[0])*(objc-1) );\n    if( p==0 ) return TCL_ERROR;\n    for(i=0; i<objc-1; i++){\n      p[i] = sqlite3_mprintf(\"%s\", Tcl_GetString(objv[1+i]));\n    }\n  }\n  n = objc-1;\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj((sqlite3_int64)p));\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   sqlite3_bind_int64  STMT N VALUE\n**\n** Test the sqlite3_bind_int64 interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a 64-bit integer VALUE to that wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_int64(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  Tcl_WideInt value;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N VALUE\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n  if( Tcl_GetWideIntFromObj(interp, objv[3], &value) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_int64(pStmt, idx, value);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   sqlite3_bind_double  STMT N VALUE\n**\n** Test the sqlite3_bind_double interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a 64-bit integer VALUE to that wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_double(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  double value = 0;\n  int rc;\n  const char *zVal;\n  int i;\n  static const struct {\n    const char *zName;     /* Name of the special floating point value */\n    unsigned int iUpper;   /* Upper 32 bits */\n    unsigned int iLower;   /* Lower 32 bits */\n  } aSpecialFp[] = {\n    {  \"NaN\",      0x7fffffff, 0xffffffff },\n    {  \"SNaN\",     0x7ff7ffff, 0xffffffff },\n    {  \"-NaN\",     0xffffffff, 0xffffffff },\n    {  \"-SNaN\",    0xfff7ffff, 0xffffffff },\n    {  \"+Inf\",     0x7ff00000, 0x00000000 },\n    {  \"-Inf\",     0xfff00000, 0x00000000 },\n    {  \"Epsilon\",  0x00000000, 0x00000001 },\n    {  \"-Epsilon\", 0x80000000, 0x00000001 },\n    {  \"NaN0\",     0x7ff80000, 0x00000000 },\n    {  \"-NaN0\",    0xfff80000, 0x00000000 },\n  };\n\n  if( objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N VALUE\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n\n  /* Intercept the string \"NaN\" and generate a NaN value for it.\n  ** All other strings are passed through to Tcl_GetDoubleFromObj().\n  ** Tcl_GetDoubleFromObj() should understand \"NaN\" but some versions\n  ** contain a bug.\n  */\n  zVal = Tcl_GetString(objv[3]);\n  for(i=0; i<sizeof(aSpecialFp)/sizeof(aSpecialFp[0]); i++){\n    if( strcmp(aSpecialFp[i].zName, zVal)==0 ){\n      sqlite3_uint64 x;\n      x = aSpecialFp[i].iUpper;\n      x <<= 32;\n      x |= aSpecialFp[i].iLower;\n      assert( sizeof(value)==8 );\n      assert( sizeof(x)==8 );\n      memcpy(&value, &x, 8);\n      break;\n    }\n  }\n  if( i>=sizeof(aSpecialFp)/sizeof(aSpecialFp[0]) &&\n         Tcl_GetDoubleFromObj(interp, objv[3], &value) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_bind_double(pStmt, idx, value);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_null  STMT N\n**\n** Test the sqlite3_bind_null interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a NULL to the wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_null(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  int rc;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_null(pStmt, idx);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_text  STMT N STRING BYTES\n**\n** Test the sqlite3_bind_text interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a UTF-8 string STRING to the wildcard.  The string is BYTES bytes\n** long.\n*/\nstatic int SQLITE_TCLAPI test_bind_text(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int idx;\n  int bytes;\n  char *value;\n  int rc;\n\n  if( objc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N VALUE BYTES\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n  value = (char*)Tcl_GetByteArrayFromObj(objv[3], &bytes);\n  if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_text16 ?-static? STMT N STRING BYTES\n**\n** Test the sqlite3_bind_text16 interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a UTF-16 string STRING to the wildcard.  The string is BYTES bytes\n** long.\n*/\nstatic int SQLITE_TCLAPI test_bind_text16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3_stmt *pStmt;\n  int idx;\n  int bytes;\n  char *value;\n  int rc;\n\n  void (*xDel)(void*) = (objc==6?SQLITE_STATIC:SQLITE_TRANSIENT);\n  Tcl_Obj *oStmt    = objv[objc-4];\n  Tcl_Obj *oN       = objv[objc-3];\n  Tcl_Obj *oString  = objv[objc-2];\n  Tcl_Obj *oBytes   = objv[objc-1];\n\n  if( objc!=5 && objc!=6){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N VALUE BYTES\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(oStmt), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, oN, &idx) ) return TCL_ERROR;\n  value = (char*)Tcl_GetByteArrayFromObj(oString, 0);\n  if( Tcl_GetIntFromObj(interp, oBytes, &bytes) ) return TCL_ERROR;\n\n  rc = sqlite3_bind_text16(pStmt, idx, (void *)value, bytes, xDel);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_blob ?-static? STMT N DATA BYTES\n**\n** Test the sqlite3_bind_blob interface.  STMT is a prepared statement.\n** N is the index of a wildcard in the prepared statement.  This command\n** binds a BLOB to the wildcard.  The BLOB is BYTES bytes in size.\n*/\nstatic int SQLITE_TCLAPI test_bind_blob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int len, idx;\n  int bytes;\n  char *value;\n  int rc;\n  sqlite3_destructor_type xDestructor = SQLITE_TRANSIENT;\n\n  if( objc!=5 && objc!=6 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" STMT N DATA BYTES\", 0);\n    return TCL_ERROR;\n  }\n\n  if( objc==6 ){\n    xDestructor = SQLITE_STATIC;\n    objv++;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;\n\n  value = (char*)Tcl_GetByteArrayFromObj(objv[3], &len);\n  if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR;\n\n  if( bytes>len ){\n    char zBuf[200];\n    sqlite3_snprintf(sizeof(zBuf), zBuf,\n                     \"cannot use %d blob bytes, have %d\", bytes, len);\n    Tcl_AppendResult(interp, zBuf, -1);\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_bind_blob(pStmt, idx, value, bytes, xDestructor);\n  if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_parameter_count  STMT\n**\n** Return the number of wildcards in the given statement.\n*/\nstatic int SQLITE_TCLAPI test_bind_parameter_count(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_bind_parameter_count(pStmt)));\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_parameter_name  STMT  N\n**\n** Return the name of the Nth wildcard.  The first wildcard is 1.\n** An empty string is returned if N is out of range or if the wildcard\n** is nameless.\n*/\nstatic int SQLITE_TCLAPI test_bind_parameter_name(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int i;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT N\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &i) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, \n     Tcl_NewStringObj(sqlite3_bind_parameter_name(pStmt,i),-1)\n  );\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_bind_parameter_index  STMT  NAME\n**\n** Return the index of the wildcard called NAME.  Return 0 if there is\n** no such wildcard.\n*/\nstatic int SQLITE_TCLAPI test_bind_parameter_index(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT NAME\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, \n     Tcl_NewIntObj(\n       sqlite3_bind_parameter_index(pStmt,Tcl_GetString(objv[2]))\n     )\n  );\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_clear_bindings STMT\n**\n*/\nstatic int SQLITE_TCLAPI test_clear_bindings(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_clear_bindings(pStmt)));\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_sleep MILLISECONDS\n*/\nstatic int SQLITE_TCLAPI test_sleep(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int ms;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"MILLISECONDS\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){\n    return TCL_ERROR;\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(ms)));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_extended_errcode DB\n**\n** Return the string representation of the most recent sqlite3_* API\n** error code. e.g. \"SQLITE_ERROR\".\n*/\nstatic int SQLITE_TCLAPI test_ex_errcode(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_extended_errcode(db);\n  Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n\n\n/*\n** Usage: sqlite3_errcode DB\n**\n** Return the string representation of the most recent sqlite3_* API\n** error code. e.g. \"SQLITE_ERROR\".\n*/\nstatic int SQLITE_TCLAPI test_errcode(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_errcode(db);\n  Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_errmsg DB\n**\n** Returns the UTF-8 representation of the error message string for the\n** most recent sqlite3_* API call.\n*/\nstatic int SQLITE_TCLAPI test_errmsg(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zErr;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  zErr = sqlite3_errmsg(db);\n  Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1));\n  return TCL_OK;\n}\n\n/*\n** Usage:   test_errmsg16 DB\n**\n** Returns the UTF-16 representation of the error message string for the\n** most recent sqlite3_* API call. This is a byte array object at the TCL \n** level, and it includes the 0x00 0x00 terminator bytes at the end of the\n** UTF-16 string.\n*/\nstatic int SQLITE_TCLAPI test_errmsg16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3 *db;\n  const void *zErr;\n  const char *z;\n  int bytes = 0;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  zErr = sqlite3_errmsg16(db);\n  if( zErr ){\n    z = zErr;\n    for(bytes=0; z[bytes] || z[bytes+1]; bytes+=2){}\n  }\n  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zErr, bytes));\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_prepare DB sql bytes ?tailvar?\n**\n** Compile up to <bytes> bytes of the supplied SQL string <sql> using\n** database handle <DB>. The parameter <tailval> is the name of a global\n** variable that is set to the unused portion of <sql> (if any). A\n** STMT handle is returned.\n*/\nstatic int SQLITE_TCLAPI test_prepare(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zSql;\n  int bytes;\n  const char *zTail = 0;\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50];\n  int rc;\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes ?tailvar?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql = Tcl_GetString(objv[2]);\n  if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;\n\n  rc = sqlite3_prepare(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0);\n  Tcl_ResetResult(interp);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  if( zTail && objc>=5 ){\n    if( bytes>=0 ){\n      bytes = bytes - (int)(zTail-zSql);\n    }\n    if( (int)strlen(zTail)<bytes ){\n      bytes = (int)strlen(zTail);\n    }\n    Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0);\n  }\n  if( rc!=SQLITE_OK ){\n    assert( pStmt==0 );\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"(%d) \", rc);\n    Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_prepare_v2 DB sql bytes ?tailvar?\n**\n** Compile up to <bytes> bytes of the supplied SQL string <sql> using\n** database handle <DB>. The parameter <tailval> is the name of a global\n** variable that is set to the unused portion of <sql> (if any). A\n** STMT handle is returned.\n*/\nstatic int SQLITE_TCLAPI test_prepare_v2(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zSql;\n  char *zCopy = 0;                /* malloc() copy of zSql */\n  int bytes;\n  const char *zTail = 0;\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50];\n  int rc;\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes tailvar\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql = Tcl_GetString(objv[2]);\n  if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;\n\n  /* Instead of using zSql directly, make a copy into a buffer obtained\n  ** directly from malloc(). The idea is to make it easier for valgrind\n  ** to spot buffer overreads.  */\n  if( bytes>=0 ){\n    zCopy = malloc(bytes);\n    memcpy(zCopy, zSql, bytes);\n  }else{\n    int n = (int)strlen(zSql) + 1;\n    zCopy = malloc(n);\n    memcpy(zCopy, zSql, n);\n  }\n  rc = sqlite3_prepare_v2(db, zCopy, bytes, &pStmt, objc>=5 ? &zTail : 0);\n  free(zCopy);\n  zTail = &zSql[(zTail - zCopy)];\n\n  assert(rc==SQLITE_OK || pStmt==0);\n  Tcl_ResetResult(interp);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  if( rc==SQLITE_OK && zTail && objc>=5 ){\n    if( bytes>=0 ){\n      bytes = bytes - (int)(zTail-zSql);\n    }\n    Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0);\n  }\n  if( rc!=SQLITE_OK ){\n    assert( pStmt==0 );\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"(%d) \", rc);\n    Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_prepare_tkt3134 DB\n**\n** Generate a prepared statement for a zero-byte string as a test\n** for ticket #3134.  The string should be preceded by a zero byte.\n*/\nstatic int SQLITE_TCLAPI test_prepare_tkt3134(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  static const char zSql[] = \"\\000SELECT 1\";\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50];\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes tailvar\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_prepare_v2(db, &zSql[1], 0, &pStmt, 0);\n  assert(rc==SQLITE_OK || pStmt==0);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  if( rc!=SQLITE_OK ){\n    assert( pStmt==0 );\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"(%d) \", rc);\n    Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_prepare16 DB sql bytes tailvar\n**\n** Compile up to <bytes> bytes of the supplied SQL string <sql> using\n** database handle <DB>. The parameter <tailval> is the name of a global\n** variable that is set to the unused portion of <sql> (if any). A\n** STMT handle is returned.\n*/\nstatic int SQLITE_TCLAPI test_prepare16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3 *db;\n  const void *zSql;\n  const void *zTail = 0;\n  Tcl_Obj *pTail = 0;\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50]; \n  int rc;\n  int bytes;                /* The integer specified as arg 3 */\n  int objlen;               /* The byte-array length of arg 2 */\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes ?tailvar?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql = Tcl_GetByteArrayFromObj(objv[2], &objlen);\n  if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;\n\n  rc = sqlite3_prepare16(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  if( rc ){\n    return TCL_ERROR;\n  }\n\n  if( objc>=5 ){\n    if( zTail ){\n      objlen = objlen - (int)((u8 *)zTail-(u8 *)zSql);\n    }else{\n      objlen = 0;\n    }\n    pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen);\n    Tcl_IncrRefCount(pTail);\n    Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0);\n    Tcl_DecrRefCount(pTail);\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, zBuf, 0);\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_prepare16_v2 DB sql bytes ?tailvar?\n**\n** Compile up to <bytes> bytes of the supplied SQL string <sql> using\n** database handle <DB>. The parameter <tailval> is the name of a global\n** variable that is set to the unused portion of <sql> (if any). A\n** STMT handle is returned.\n*/\nstatic int SQLITE_TCLAPI test_prepare16_v2(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3 *db;\n  const void *zSql;\n  const void *zTail = 0;\n  Tcl_Obj *pTail = 0;\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50]; \n  int rc;\n  int bytes;                /* The integer specified as arg 3 */\n  int objlen;               /* The byte-array length of arg 2 */\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes ?tailvar?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql = Tcl_GetByteArrayFromObj(objv[2], &objlen);\n  if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;\n\n  rc = sqlite3_prepare16_v2(db, zSql, bytes, &pStmt, objc>=5 ? &zTail : 0);\n  if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;\n  if( rc ){\n    return TCL_ERROR;\n  }\n\n  if( objc>=5 ){\n    if( zTail ){\n      objlen = objlen - (int)((u8 *)zTail-(u8 *)zSql);\n    }else{\n      objlen = 0;\n    }\n    pTail = Tcl_NewByteArrayObj((u8 *)zTail, objlen);\n    Tcl_IncrRefCount(pTail);\n    Tcl_ObjSetVar2(interp, objv[4], 0, pTail, 0);\n    Tcl_DecrRefCount(pTail);\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, zBuf, 0);\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_open filename ?options-list?\n*/\nstatic int SQLITE_TCLAPI test_open(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zFilename;\n  sqlite3 *db;\n  char zBuf[100];\n\n  if( objc!=3 && objc!=2 && objc!=1 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" filename options-list\", 0);\n    return TCL_ERROR;\n  }\n\n  zFilename = objc>1 ? Tcl_GetString(objv[1]) : 0;\n  sqlite3_open(zFilename, &db);\n  \n  if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR;\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_open_v2 FILENAME FLAGS VFS\n*/\nstatic int SQLITE_TCLAPI test_open_v2(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zFilename;\n  const char *zVfs;\n  int flags = 0;\n  sqlite3 *db;\n  int rc;\n  char zBuf[100];\n\n  int nFlag;\n  Tcl_Obj **apFlag;\n  int i;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME FLAGS VFS\");\n    return TCL_ERROR;\n  }\n  zFilename = Tcl_GetString(objv[1]);\n  zVfs = Tcl_GetString(objv[3]);\n  if( zVfs[0]==0x00 ) zVfs = 0;\n\n  rc = Tcl_ListObjGetElements(interp, objv[2], &nFlag, &apFlag);\n  if( rc!=TCL_OK ) return rc;\n  for(i=0; i<nFlag; i++){\n    int iFlag;\n    struct OpenFlag {\n      const char *zFlag;\n      int flag;\n    } aFlag[] = {\n      { \"SQLITE_OPEN_READONLY\", SQLITE_OPEN_READONLY },\n      { \"SQLITE_OPEN_READWRITE\", SQLITE_OPEN_READWRITE },\n      { \"SQLITE_OPEN_CREATE\", SQLITE_OPEN_CREATE },\n      { \"SQLITE_OPEN_DELETEONCLOSE\", SQLITE_OPEN_DELETEONCLOSE },\n      { \"SQLITE_OPEN_EXCLUSIVE\", SQLITE_OPEN_EXCLUSIVE },\n      { \"SQLITE_OPEN_AUTOPROXY\", SQLITE_OPEN_AUTOPROXY },\n      { \"SQLITE_OPEN_MAIN_DB\", SQLITE_OPEN_MAIN_DB },\n      { \"SQLITE_OPEN_TEMP_DB\", SQLITE_OPEN_TEMP_DB },\n      { \"SQLITE_OPEN_TRANSIENT_DB\", SQLITE_OPEN_TRANSIENT_DB },\n      { \"SQLITE_OPEN_MAIN_JOURNAL\", SQLITE_OPEN_MAIN_JOURNAL },\n      { \"SQLITE_OPEN_TEMP_JOURNAL\", SQLITE_OPEN_TEMP_JOURNAL },\n      { \"SQLITE_OPEN_SUBJOURNAL\", SQLITE_OPEN_SUBJOURNAL },\n      { \"SQLITE_OPEN_MASTER_JOURNAL\", SQLITE_OPEN_MASTER_JOURNAL },\n      { \"SQLITE_OPEN_NOMUTEX\", SQLITE_OPEN_NOMUTEX },\n      { \"SQLITE_OPEN_FULLMUTEX\", SQLITE_OPEN_FULLMUTEX },\n      { \"SQLITE_OPEN_SHAREDCACHE\", SQLITE_OPEN_SHAREDCACHE },\n      { \"SQLITE_OPEN_PRIVATECACHE\", SQLITE_OPEN_PRIVATECACHE },\n      { \"SQLITE_OPEN_WAL\", SQLITE_OPEN_WAL },\n      { \"SQLITE_OPEN_URI\", SQLITE_OPEN_URI },\n      { 0, 0 }\n    };\n    rc = Tcl_GetIndexFromObjStruct(interp, apFlag[i], aFlag, sizeof(aFlag[0]), \n        \"flag\", 0, &iFlag\n    );\n    if( rc!=TCL_OK ) return rc;\n    flags |= aFlag[iFlag].flag;\n  }\n\n  rc = sqlite3_open_v2(zFilename, &db, flags, zVfs);\n  if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR;\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_open16 filename options\n*/\nstatic int SQLITE_TCLAPI test_open16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  const void *zFilename;\n  sqlite3 *db;\n  char zBuf[100];\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" filename options-list\", 0);\n    return TCL_ERROR;\n  }\n\n  zFilename = Tcl_GetByteArrayFromObj(objv[1], 0);\n  sqlite3_open16(zFilename, &db);\n  \n  if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR;\n  Tcl_AppendResult(interp, zBuf, 0);\n#endif /* SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_complete16 <UTF-16 string>\n**\n** Return 1 if the supplied argument is a complete SQL statement, or zero\n** otherwise.\n*/\nstatic int SQLITE_TCLAPI test_complete16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#if !defined(SQLITE_OMIT_COMPLETE) && !defined(SQLITE_OMIT_UTF16)\n  char *zBuf;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"<utf-16 sql>\");\n    return TCL_ERROR;\n  }\n\n  zBuf = (char*)Tcl_GetByteArrayFromObj(objv[1], 0);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_complete16(zBuf)));\n#endif /* SQLITE_OMIT_COMPLETE && SQLITE_OMIT_UTF16 */\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_step STMT\n**\n** Advance the statement to the next row.\n*/\nstatic int SQLITE_TCLAPI test_step(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  rc = sqlite3_step(pStmt);\n\n  /* if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; */\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_sql(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  Tcl_SetResult(interp, (char *)sqlite3_sql(pStmt), TCL_VOLATILE);\n  return TCL_OK;\n}\nstatic int SQLITE_TCLAPI test_ex_sql(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  char *z;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  z = sqlite3_expanded_sql(pStmt);\n  Tcl_SetResult(interp, z, TCL_VOLATILE);\n  sqlite3_free(z);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_count STMT \n**\n** Return the number of columns returned by the sql statement STMT.\n*/\nstatic int SQLITE_TCLAPI test_column_count(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_column_count(pStmt)));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_type STMT column\n**\n** Return the type of the data in column 'column' of the current row.\n*/\nstatic int SQLITE_TCLAPI test_column_type(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n  int tp;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  tp = sqlite3_column_type(pStmt, col);\n  switch( tp ){\n    case SQLITE_INTEGER: \n      Tcl_SetResult(interp, \"INTEGER\", TCL_STATIC); \n      break;\n    case SQLITE_NULL:\n      Tcl_SetResult(interp, \"NULL\", TCL_STATIC); \n      break;\n    case SQLITE_FLOAT:\n      Tcl_SetResult(interp, \"FLOAT\", TCL_STATIC); \n      break;\n    case SQLITE_TEXT:\n      Tcl_SetResult(interp, \"TEXT\", TCL_STATIC); \n      break;\n    case SQLITE_BLOB:\n      Tcl_SetResult(interp, \"BLOB\", TCL_STATIC); \n      break;\n    default:\n      assert(0);\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_int64 STMT column\n**\n** Return the data in column 'column' of the current row cast as an\n** wide (64-bit) integer.\n*/\nstatic int SQLITE_TCLAPI test_column_int64(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n  i64 iVal;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  iVal = sqlite3_column_int64(pStmt, col);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(iVal));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_blob STMT column\n*/\nstatic int SQLITE_TCLAPI test_column_blob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n\n  int len;\n  const void *pBlob;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  len = sqlite3_column_bytes(pStmt, col);\n  pBlob = sqlite3_column_blob(pStmt, col);\n  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pBlob, len));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_double STMT column\n**\n** Return the data in column 'column' of the current row cast as a double.\n*/\nstatic int SQLITE_TCLAPI test_column_double(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n  double rVal;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  rVal = sqlite3_column_double(pStmt, col);\n  Tcl_SetObjResult(interp, Tcl_NewDoubleObj(rVal));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_data_count STMT \n**\n** Return the number of columns returned by the sql statement STMT.\n*/\nstatic int SQLITE_TCLAPI test_data_count(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_data_count(pStmt)));\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_text STMT column\n**\n** Usage: sqlite3_column_decltype STMT column\n**\n** Usage: sqlite3_column_name STMT column\n*/\nstatic int SQLITE_TCLAPI test_stmt_utf8(\n  void * clientData,        /* Pointer to SQLite API function to be invoke */\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n  const char *(*xFunc)(sqlite3_stmt*, int);\n  const char *zRet;\n\n  xFunc = (const char *(*)(sqlite3_stmt*, int))clientData;\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n  zRet = xFunc(pStmt, col);\n  if( zRet ){\n    Tcl_SetResult(interp, (char *)zRet, 0);\n  }\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_global_recover(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_DEPRECATED\n  int rc;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  rc = sqlite3_global_recover();\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_text STMT column\n**\n** Usage: sqlite3_column_decltype STMT column\n**\n** Usage: sqlite3_column_name STMT column\n*/\nstatic int SQLITE_TCLAPI test_stmt_utf16(\n  void * clientData,     /* Pointer to SQLite API function to be invoked */\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3_stmt *pStmt;\n  int col;\n  Tcl_Obj *pRet;\n  const void *zName16;\n  const void *(*xFunc)(sqlite3_stmt*, int);\n\n  xFunc = (const void *(*)(sqlite3_stmt*, int))clientData;\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  zName16 = xFunc(pStmt, col);\n  if( zName16 ){\n    int n;\n    const char *z = zName16;\n    for(n=0; z[n] || z[n+1]; n+=2){}\n    pRet = Tcl_NewByteArrayObj(zName16, n+2);\n    Tcl_SetObjResult(interp, pRet);\n  }\n#endif /* SQLITE_OMIT_UTF16 */\n\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_column_int STMT column\n**\n** Usage: sqlite3_column_bytes STMT column\n**\n** Usage: sqlite3_column_bytes16 STMT column\n**\n*/\nstatic int SQLITE_TCLAPI test_stmt_int(\n  void * clientData,    /* Pointer to SQLite API function to be invoked */\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_stmt *pStmt;\n  int col;\n  int (*xFunc)(sqlite3_stmt*, int);\n\n  xFunc = (int (*)(sqlite3_stmt*, int))clientData;\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" STMT column\", 0);\n    return TCL_ERROR;\n  }\n\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(xFunc(pStmt, col)));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite_set_magic  DB  MAGIC-NUMBER\n**\n** Set the db->magic value.  This is used to test error recovery logic.\n*/\nstatic int SQLITE_TCLAPI sqlite_set_magic(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  sqlite3 *db;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n         \" DB MAGIC\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  if( strcmp(argv[2], \"SQLITE_MAGIC_OPEN\")==0 ){\n    db->magic = SQLITE_MAGIC_OPEN;\n  }else if( strcmp(argv[2], \"SQLITE_MAGIC_CLOSED\")==0 ){\n    db->magic = SQLITE_MAGIC_CLOSED;\n  }else if( strcmp(argv[2], \"SQLITE_MAGIC_BUSY\")==0 ){\n    db->magic = SQLITE_MAGIC_BUSY;\n  }else if( strcmp(argv[2], \"SQLITE_MAGIC_ERROR\")==0 ){\n    db->magic = SQLITE_MAGIC_ERROR;\n  }else if( Tcl_GetInt(interp, argv[2], (int*)&db->magic) ){\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_interrupt  DB \n**\n** Trigger an interrupt on DB\n*/\nstatic int SQLITE_TCLAPI test_interrupt(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  sqlite3 *db;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  sqlite3_interrupt(db);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite_delete_function DB function-name\n**\n** Delete the user function 'function-name' from database handle DB. It\n** is assumed that the user function was created as UTF8, any number of\n** arguments (the way the TCL interface does it).\n*/\nstatic int SQLITE_TCLAPI delete_function(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  int rc;\n  sqlite3 *db;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n        \" DB function-name\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, 0, 0, 0);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite_delete_collation DB collation-name\n**\n** Delete the collation sequence 'collation-name' from database handle \n** DB. It is assumed that the collation sequence was created as UTF8 (the \n** way the TCL interface does it).\n*/\nstatic int SQLITE_TCLAPI delete_collation(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  int rc;\n  sqlite3 *db;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n        \" DB function-name\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  rc = sqlite3_create_collation(db, argv[2], SQLITE_UTF8, 0, 0);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_get_autocommit DB\n**\n** Return true if the database DB is currently in auto-commit mode.\n** Return false if not.\n*/\nstatic int SQLITE_TCLAPI get_autocommit(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  char zBuf[30];\n  sqlite3 *db;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n        \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", sqlite3_get_autocommit(db));\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_busy_timeout DB MS\n**\n** Set the busy timeout.  This is more easily done using the timeout\n** method of the TCL interface.  But we need a way to test the case\n** where it returns SQLITE_MISUSE.\n*/\nstatic int SQLITE_TCLAPI test_busy_timeout(\n  void * clientData,\n  Tcl_Interp *interp,\n  int argc,\n  char **argv\n){\n  int rc, ms;\n  sqlite3 *db;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0], \n        \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;\n  if( Tcl_GetInt(interp, argv[2], &ms) ) return TCL_ERROR;\n  rc = sqlite3_busy_timeout(db, ms);\n  Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:  tcl_variable_type VARIABLENAME\n**\n** Return the name of the internal representation for the\n** value of the given variable.\n*/\nstatic int SQLITE_TCLAPI tcl_variable_type(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_Obj *pVar;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"VARIABLE\");\n    return TCL_ERROR;\n  }\n  pVar = Tcl_GetVar2Ex(interp, Tcl_GetString(objv[1]), 0, TCL_LEAVE_ERR_MSG);\n  if( pVar==0 ) return TCL_ERROR;\n  if( pVar->typePtr ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(pVar->typePtr->name, -1));\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_release_memory ?N?\n**\n** Attempt to release memory currently held but not actually required.\n** The integer N is the number of bytes we are trying to release.  The \n** return value is the amount of memory actually released.\n*/\nstatic int SQLITE_TCLAPI test_release_memory(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)\n  int N;\n  int amt;\n  if( objc!=1 && objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?N?\");\n    return TCL_ERROR;\n  }\n  if( objc==2 ){\n    if( Tcl_GetIntFromObj(interp, objv[1], &N) ) return TCL_ERROR;\n  }else{\n    N = -1;\n  }\n  amt = sqlite3_release_memory(N);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(amt));\n#endif\n  return TCL_OK;\n}\n\n\n/*\n** Usage:  sqlite3_db_release_memory DB\n**\n** Attempt to release memory currently held by database DB.  Return the\n** result code (which in the current implementation is always zero).\n*/\nstatic int SQLITE_TCLAPI test_db_release_memory(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_db_release_memory(db);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_db_cacheflush DB\n**\n** Attempt to flush any dirty pages to disk.\n*/\nstatic int SQLITE_TCLAPI test_db_cacheflush(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int rc;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_db_cacheflush(db);\n  if( rc ){\n    Tcl_SetResult(interp, (char *)sqlite3ErrStr(rc), TCL_STATIC);\n    return TCL_ERROR;\n  }\n\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_system_errno DB\n**\n** Return the low-level system errno value.\n*/\nstatic int SQLITE_TCLAPI test_system_errno(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int iErrno;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  iErrno = sqlite3_system_errno(db);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(iErrno));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_db_filename DB DBNAME\n**\n** Return the name of a file associated with a database.\n*/\nstatic int SQLITE_TCLAPI test_db_filename(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zDbName;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zDbName = Tcl_GetString(objv[2]);\n  Tcl_AppendResult(interp, sqlite3_db_filename(db, zDbName), (void*)0);\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_db_readonly DB DBNAME\n**\n** Return 1 or 0 if DBNAME is readonly or not.  Return -1 if DBNAME does\n** not exist.\n*/\nstatic int SQLITE_TCLAPI test_db_readonly(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zDbName;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zDbName = Tcl_GetString(objv[2]);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_db_readonly(db, zDbName)));\n  return TCL_OK;\n}\n\n/*\n** Usage:  sqlite3_soft_heap_limit ?N?\n**\n** Query or set the soft heap limit for the current thread.  The\n** limit is only changed if the N is present.  The previous limit\n** is returned.\n*/\nstatic int SQLITE_TCLAPI test_soft_heap_limit(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_int64 amt;\n  Tcl_WideInt N = -1;\n  if( objc!=1 && objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?N?\");\n    return TCL_ERROR;\n  }\n  if( objc==2 ){\n    if( Tcl_GetWideIntFromObj(interp, objv[1], &N) ) return TCL_ERROR;\n  }\n  amt = sqlite3_soft_heap_limit64(N);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(amt));\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_thread_cleanup\n**\n** Call the sqlite3_thread_cleanup API.\n*/\nstatic int SQLITE_TCLAPI test_thread_cleanup(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup();\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:   sqlite3_pager_refcounts  DB\n**\n** Return a list of numbers which are the PagerRefcount for all\n** pagers on each database connection.\n*/\nstatic int SQLITE_TCLAPI test_pager_refcounts(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  int i;\n  int v, *a;\n  Tcl_Obj *pResult;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  pResult = Tcl_NewObj();\n  for(i=0; i<db->nDb; i++){\n    if( db->aDb[i].pBt==0 ){\n      v = -1;\n    }else{\n      sqlite3_mutex_enter(db->mutex);\n      a = sqlite3PagerStats(sqlite3BtreePager(db->aDb[i].pBt));\n      v = a[0];\n      sqlite3_mutex_leave(db->mutex);\n    }\n    Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(v));\n  }\n  Tcl_SetObjResult(interp, pResult);\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd:   working_64bit_int\n**\n** Some TCL builds (ex: cygwin) do not support 64-bit integers.  This\n** leads to a number of test failures.  The present command checks the\n** TCL build to see whether or not it supports 64-bit integers.  It\n** returns TRUE if it does and FALSE if not.\n**\n** This command is used to warn users that their TCL build is defective\n** and that the errors they are seeing in the test scripts might be\n** a result of their defective TCL rather than problems in SQLite.\n*/\nstatic int SQLITE_TCLAPI working_64bit_int(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_Obj *pTestObj;\n  int working = 0;\n\n  pTestObj = Tcl_NewWideIntObj(1000000*(i64)1234567890);\n  working = strcmp(Tcl_GetString(pTestObj), \"1234567890000000\")==0;\n  Tcl_DecrRefCount(pTestObj);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(working));\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd:   vfs_unlink_test\n**\n** This TCL command unregisters the primary VFS and then registers\n** it back again.  This is used to test the ability to register a\n** VFS when none are previously registered, and the ability to \n** unregister the only available VFS.  Ticket #2738\n*/\nstatic int SQLITE_TCLAPI vfs_unlink_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int i;\n  sqlite3_vfs *pMain;\n  sqlite3_vfs *apVfs[20];\n  sqlite3_vfs one, two;\n\n  sqlite3_vfs_unregister(0);   /* Unregister of NULL is harmless */\n  one.zName = \"__one\";\n  two.zName = \"__two\";\n\n  /* Calling sqlite3_vfs_register with 2nd argument of 0 does not\n  ** change the default VFS\n  */\n  pMain = sqlite3_vfs_find(0);\n  sqlite3_vfs_register(&one, 0);\n  assert( pMain==0 || pMain==sqlite3_vfs_find(0) );\n  sqlite3_vfs_register(&two, 0);\n  assert( pMain==0 || pMain==sqlite3_vfs_find(0) );\n\n  /* We can find a VFS by its name */\n  assert( sqlite3_vfs_find(\"__one\")==&one );\n  assert( sqlite3_vfs_find(\"__two\")==&two );\n\n  /* Calling sqlite_vfs_register with non-zero second parameter changes the\n  ** default VFS, even if the 1st parameter is an existig VFS that is\n  ** previously registered as the non-default.\n  */\n  sqlite3_vfs_register(&one, 1);\n  assert( sqlite3_vfs_find(\"__one\")==&one );\n  assert( sqlite3_vfs_find(\"__two\")==&two );\n  assert( sqlite3_vfs_find(0)==&one );\n  sqlite3_vfs_register(&two, 1);\n  assert( sqlite3_vfs_find(\"__one\")==&one );\n  assert( sqlite3_vfs_find(\"__two\")==&two );\n  assert( sqlite3_vfs_find(0)==&two );\n  if( pMain ){\n    sqlite3_vfs_register(pMain, 1);\n    assert( sqlite3_vfs_find(\"__one\")==&one );\n    assert( sqlite3_vfs_find(\"__two\")==&two );\n    assert( sqlite3_vfs_find(0)==pMain );\n  }\n  \n  /* Unlink the default VFS.  Repeat until there are no more VFSes\n  ** registered.\n  */\n  for(i=0; i<sizeof(apVfs)/sizeof(apVfs[0]); i++){\n    apVfs[i] = sqlite3_vfs_find(0);\n    if( apVfs[i] ){\n      assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) );\n      sqlite3_vfs_unregister(apVfs[i]);\n      assert( 0==sqlite3_vfs_find(apVfs[i]->zName) );\n    }\n  }\n  assert( 0==sqlite3_vfs_find(0) );\n  \n  /* Register the main VFS as non-default (will be made default, since\n  ** it'll be the only one in existence).\n  */\n  sqlite3_vfs_register(pMain, 0);\n  assert( sqlite3_vfs_find(0)==pMain );\n  \n  /* Un-register the main VFS again to restore an empty VFS list */\n  sqlite3_vfs_unregister(pMain);\n  assert( 0==sqlite3_vfs_find(0) );\n\n  /* Relink all VFSes in reverse order. */  \n  for(i=sizeof(apVfs)/sizeof(apVfs[0])-1; i>=0; i--){\n    if( apVfs[i] ){\n      sqlite3_vfs_register(apVfs[i], 1);\n      assert( apVfs[i]==sqlite3_vfs_find(0) );\n      assert( apVfs[i]==sqlite3_vfs_find(apVfs[i]->zName) );\n    }\n  }\n\n  /* Unregister out sample VFSes. */\n  sqlite3_vfs_unregister(&one);\n  sqlite3_vfs_unregister(&two);\n\n  /* Unregistering a VFS that is not currently registered is harmless */\n  sqlite3_vfs_unregister(&one);\n  sqlite3_vfs_unregister(&two);\n  assert( sqlite3_vfs_find(\"__one\")==0 );\n  assert( sqlite3_vfs_find(\"__two\")==0 );\n\n  /* We should be left with the original default VFS back as the\n  ** original */\n  assert( sqlite3_vfs_find(0)==pMain );\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   vfs_initfail_test\n**\n** This TCL command attempts to vfs_find and vfs_register when the\n** sqlite3_initialize() interface is failing.  All calls should fail.\n*/\nstatic int SQLITE_TCLAPI vfs_initfail_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_vfs one;\n  one.zName = \"__one\";\n\n  if( sqlite3_vfs_find(0) ) return TCL_ERROR;\n  sqlite3_vfs_register(&one, 0);\n  if( sqlite3_vfs_find(0) ) return TCL_ERROR;\n  sqlite3_vfs_register(&one, 1);\n  if( sqlite3_vfs_find(0) ) return TCL_ERROR;\n  return TCL_OK;\n}\n\n/*\n** Saved VFSes\n*/\nstatic sqlite3_vfs *apVfs[20];\nstatic int nVfs = 0;\n\n/*\n** tclcmd:   vfs_unregister_all\n**\n** Unregister all VFSes.\n*/\nstatic int SQLITE_TCLAPI vfs_unregister_all(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int i;\n  for(i=0; i<ArraySize(apVfs); i++){\n    apVfs[i] = sqlite3_vfs_find(0);\n    if( apVfs[i]==0 ) break;\n    sqlite3_vfs_unregister(apVfs[i]);\n  }\n  nVfs = i;\n  return TCL_OK;\n}\n/*\n** tclcmd:   vfs_reregister_all\n**\n** Restore all VFSes that were removed using vfs_unregister_all. Taking\n** care to put the linked list back together in the same order as it was\n** in before vfs_unregister_all was invoked.\n*/\nstatic int SQLITE_TCLAPI vfs_reregister_all(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int i;\n  for(i=nVfs-1; i>=0; i--){\n    sqlite3_vfs_register(apVfs[i], 1);\n  }\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd:   file_control_test DB\n**\n** This TCL command runs the sqlite3_file_control interface and\n** verifies correct operation of the same.\n*/\nstatic int SQLITE_TCLAPI file_control_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int iArg = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_file_control(db, 0, 0, &iArg);\n  assert( rc==SQLITE_NOTFOUND );\n  rc = sqlite3_file_control(db, \"notadatabase\", SQLITE_FCNTL_LOCKSTATE, &iArg);\n  assert( rc==SQLITE_ERROR );\n  rc = sqlite3_file_control(db, \"main\", -1, &iArg);\n  assert( rc==SQLITE_NOTFOUND );\n  rc = sqlite3_file_control(db, \"temp\", -1, &iArg);\n  assert( rc==SQLITE_NOTFOUND || rc==SQLITE_ERROR );\n\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd:   file_control_lasterrno_test DB\n**\n** This TCL command runs the sqlite3_file_control interface and\n** verifies correct operation of the SQLITE_LAST_ERRNO verb.\n*/\nstatic int SQLITE_TCLAPI file_control_lasterrno_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int iArg = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_file_control(db, NULL, SQLITE_LAST_ERRNO, &iArg);\n  if( rc ){ \n    Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); \n    return TCL_ERROR; \n  }\n  if( iArg!=0 ) {\n    Tcl_AppendResult(interp, \"Unexpected non-zero errno: \",\n                     Tcl_GetStringFromObj(Tcl_NewIntObj(iArg), 0), \" \", 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:   file_control_chunksize_test DB DBNAME SIZE\n**\n** This TCL command runs the sqlite3_file_control interface and\n** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and\n** SQLITE_SET_LOCKPROXYFILE verbs.\n*/\nstatic int SQLITE_TCLAPI file_control_chunksize_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int nSize;                      /* New chunk size */\n  char *zDb;                      /* Db name (\"main\", \"temp\" etc.) */\n  sqlite3 *db;                    /* Database handle */\n  int rc;                         /* file_control() return code */\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME SIZE\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) \n   || Tcl_GetIntFromObj(interp, objv[3], &nSize)\n  ){\n   return TCL_ERROR;\n  }\n  zDb = Tcl_GetString(objv[2]);\n  if( zDb[0]=='\\0' ) zDb = NULL;\n\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_CHUNK_SIZE, (void *)&nSize);\n  if( rc ){\n    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   file_control_sizehint_test DB DBNAME SIZE\n**\n** This TCL command runs the sqlite3_file_control interface \n** with SQLITE_FCNTL_SIZE_HINT\n*/\nstatic int SQLITE_TCLAPI file_control_sizehint_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_WideInt nSize;              /* Hinted size */\n  char *zDb;                      /* Db name (\"main\", \"temp\" etc.) */\n  sqlite3 *db;                    /* Database handle */\n  int rc;                         /* file_control() return code */\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB DBNAME SIZE\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) \n   || Tcl_GetWideIntFromObj(interp, objv[3], &nSize)\n  ){\n   return TCL_ERROR;\n  }\n  zDb = Tcl_GetString(objv[2]);\n  if( zDb[0]=='\\0' ) zDb = NULL;\n\n  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_SIZE_HINT, (void *)&nSize);\n  if( rc ){\n    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   file_control_lockproxy_test DB PWD\n**\n** This TCL command runs the sqlite3_file_control interface and\n** verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and\n** SQLITE_SET_LOCKPROXYFILE verbs.\n*/\nstatic int SQLITE_TCLAPI file_control_lockproxy_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  \n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n                     Tcl_GetStringFromObj(objv[0], 0), \" DB PWD\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n   return TCL_ERROR;\n  }\n  \n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  {\n    char *testPath;\n    int rc;\n    int nPwd;\n    const char *zPwd;\n    char proxyPath[400];\n    \n    zPwd = Tcl_GetStringFromObj(objv[2], &nPwd);\n    if( sizeof(proxyPath)<nPwd+20 ){\n      Tcl_AppendResult(interp, \"PWD too big\", (void*)0);\n      return TCL_ERROR;\n    }\n    sqlite3_snprintf(sizeof(proxyPath), proxyPath, \"%s/test.proxy\", zPwd);\n    rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath);\n    if( rc ){\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); \n      return TCL_ERROR;\n    }\n    rc = sqlite3_file_control(db, NULL, SQLITE_GET_LOCKPROXYFILE, &testPath);\n    if( strncmp(proxyPath,testPath,11) ){\n      Tcl_AppendResult(interp, \"Lock proxy file did not match the \"\n                               \"previously assigned value\", 0);\n      return TCL_ERROR;\n    }\n    if( rc ){\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n      return TCL_ERROR;\n    }\n    rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath);\n    if( rc ){\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n      return TCL_ERROR;\n    }\n  }\n#endif\n  return TCL_OK;  \n}\n\n#if SQLITE_OS_WIN\n/*\n** tclcmd:   file_control_win32_av_retry DB  NRETRY  DELAY\n**\n** This TCL command runs the sqlite3_file_control interface with\n** the SQLITE_FCNTL_WIN32_AV_RETRY opcode.\n*/\nstatic int SQLITE_TCLAPI file_control_win32_av_retry(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  int a[2];\n  char z[100];\n\n  if( objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB NRETRY DELAY\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &a[0]) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &a[1]) ) return TCL_ERROR;\n  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_AV_RETRY, (void*)a);\n  sqlite3_snprintf(sizeof(z), z, \"%d %d %d\", rc, a[0], a[1]);\n  Tcl_AppendResult(interp, z, (char*)0);\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:   file_control_win32_get_handle DB\n**\n** This TCL command runs the sqlite3_file_control interface with\n** the SQLITE_FCNTL_WIN32_GET_HANDLE opcode.\n*/\nstatic int file_control_win32_get_handle(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  HANDLE hFile = NULL;\n  char z[100];\n\n  if( objc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_GET_HANDLE,\n                            (void*)&hFile);\n  sqlite3_snprintf(sizeof(z), z, \"%d %p\", rc, (void*)hFile);\n  Tcl_AppendResult(interp, z, (char*)0);\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   file_control_win32_set_handle DB HANDLE\n**\n** This TCL command runs the sqlite3_file_control interface with\n** the SQLITE_FCNTL_WIN32_SET_HANDLE opcode.\n*/\nstatic int SQLITE_TCLAPI file_control_win32_set_handle(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  HANDLE hFile = NULL;\n  char z[100];\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB HANDLE\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( getWin32Handle(interp, Tcl_GetString(objv[2]), &hFile) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_WIN32_SET_HANDLE,\n                            (void*)&hFile);\n  sqlite3_snprintf(sizeof(z), z, \"%d %p\", rc, (void*)hFile);\n  Tcl_AppendResult(interp, z, (char*)0);\n  return TCL_OK;  \n}\n#endif\n\n/*\n** tclcmd:   file_control_persist_wal DB PERSIST-FLAG\n**\n** This TCL command runs the sqlite3_file_control interface with\n** the SQLITE_FCNTL_PERSIST_WAL opcode.\n*/\nstatic int SQLITE_TCLAPI file_control_persist_wal(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  int bPersist;\n  char z[100];\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB FLAG\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &bPersist) ) return TCL_ERROR;\n  rc = sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, (void*)&bPersist);\n  sqlite3_snprintf(sizeof(z), z, \"%d %d\", rc, bPersist);\n  Tcl_AppendResult(interp, z, (char*)0);\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:   file_control_powersafe_overwrite DB PSOW-FLAG\n**\n** This TCL command runs the sqlite3_file_control interface with\n** the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode.\n*/\nstatic int SQLITE_TCLAPI file_control_powersafe_overwrite(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  int b;\n  char z[100];\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB FLAG\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &b) ) return TCL_ERROR;\n  rc = sqlite3_file_control(db,NULL,SQLITE_FCNTL_POWERSAFE_OVERWRITE,(void*)&b);\n  sqlite3_snprintf(sizeof(z), z, \"%d %d\", rc, b);\n  Tcl_AppendResult(interp, z, (char*)0);\n  return TCL_OK;  \n}\n\n\n/*\n** tclcmd:   file_control_vfsname DB ?AUXDB?\n**\n** Return a string that describes the stack of VFSes.\n*/\nstatic int SQLITE_TCLAPI file_control_vfsname(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zDbName = \"main\";\n  char *zVfsName = 0;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB ?AUXDB?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( objc==3 ){\n    zDbName = Tcl_GetString(objv[2]);\n  }\n  sqlite3_file_control(db, zDbName, SQLITE_FCNTL_VFSNAME,(void*)&zVfsName);\n  Tcl_AppendResult(interp, zVfsName, (char*)0);\n  sqlite3_free(zVfsName);\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:   file_control_tempfilename DB ?AUXDB?\n**\n** Return a string that is a temporary filename\n*/\nstatic int SQLITE_TCLAPI file_control_tempfilename(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zDbName = \"main\";\n  char *zTName = 0;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB ?AUXDB?\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( objc==3 ){\n    zDbName = Tcl_GetString(objv[2]);\n  }\n  sqlite3_file_control(db, zDbName, SQLITE_FCNTL_TEMPFILENAME, (void*)&zTName);\n  Tcl_AppendResult(interp, zTName, (char*)0);\n  sqlite3_free(zTName);\n  return TCL_OK;  \n}\n\n\n/*\n** tclcmd:   sqlite3_vfs_list\n**\n**   Return a tcl list containing the names of all registered vfs's.\n*/\nstatic int SQLITE_TCLAPI vfs_list(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_vfs *pVfs;\n  Tcl_Obj *pRet = Tcl_NewObj();\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  for(pVfs=sqlite3_vfs_find(0); pVfs; pVfs=pVfs->pNext){\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(pVfs->zName, -1));\n  }\n  Tcl_SetObjResult(interp, pRet);\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:   sqlite3_limit DB ID VALUE\n**\n** This TCL command runs the sqlite3_limit interface and\n** verifies correct operation of the same.\n*/\nstatic int SQLITE_TCLAPI test_limit(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  static const struct {\n     char *zName;\n     int id;\n  } aId[] = {\n    { \"SQLITE_LIMIT_LENGTH\",              SQLITE_LIMIT_LENGTH               },\n    { \"SQLITE_LIMIT_SQL_LENGTH\",          SQLITE_LIMIT_SQL_LENGTH           },\n    { \"SQLITE_LIMIT_COLUMN\",              SQLITE_LIMIT_COLUMN               },\n    { \"SQLITE_LIMIT_EXPR_DEPTH\",          SQLITE_LIMIT_EXPR_DEPTH           },\n    { \"SQLITE_LIMIT_COMPOUND_SELECT\",     SQLITE_LIMIT_COMPOUND_SELECT      },\n    { \"SQLITE_LIMIT_VDBE_OP\",             SQLITE_LIMIT_VDBE_OP              },\n    { \"SQLITE_LIMIT_FUNCTION_ARG\",        SQLITE_LIMIT_FUNCTION_ARG         },\n    { \"SQLITE_LIMIT_ATTACHED\",            SQLITE_LIMIT_ATTACHED             },\n    { \"SQLITE_LIMIT_LIKE_PATTERN_LENGTH\", SQLITE_LIMIT_LIKE_PATTERN_LENGTH  },\n    { \"SQLITE_LIMIT_VARIABLE_NUMBER\",     SQLITE_LIMIT_VARIABLE_NUMBER      },\n    { \"SQLITE_LIMIT_TRIGGER_DEPTH\",       SQLITE_LIMIT_TRIGGER_DEPTH        },\n    { \"SQLITE_LIMIT_WORKER_THREADS\",      SQLITE_LIMIT_WORKER_THREADS       },\n    \n    /* Out of range test cases */\n    { \"SQLITE_LIMIT_TOOSMALL\",            -1,                               },\n    { \"SQLITE_LIMIT_TOOBIG\",              SQLITE_LIMIT_WORKER_THREADS+1     },\n  };\n  int i, id = 0;\n  int val;\n  const char *zId;\n\n  if( objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" DB ID VALUE\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zId = Tcl_GetString(objv[2]);\n  for(i=0; i<sizeof(aId)/sizeof(aId[0]); i++){\n    if( strcmp(zId, aId[i].zName)==0 ){\n      id = aId[i].id;\n      break;\n    }\n  }\n  if( i>=sizeof(aId)/sizeof(aId[0]) ){\n    Tcl_AppendResult(interp, \"unknown limit type: \", zId, (char*)0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[3], &val) ) return TCL_ERROR;\n  rc = sqlite3_limit(db, id, val);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;  \n}\n\n/*\n** tclcmd:  save_prng_state\n**\n** Save the state of the pseudo-random number generator.\n** At the same time, verify that sqlite3_test_control works even when\n** called with an out-of-range opcode.\n*/\nstatic int SQLITE_TCLAPI save_prng_state(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int rc = sqlite3_test_control(9999);\n  assert( rc==0 );\n  rc = sqlite3_test_control(-1);\n  assert( rc==0 );\n  sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SAVE);\n  return TCL_OK;\n}\n/*\n** tclcmd:  restore_prng_state\n*/\nstatic int SQLITE_TCLAPI restore_prng_state(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESTORE);\n  return TCL_OK;\n}\n/*\n** tclcmd:  reset_prng_state\n*/\nstatic int SQLITE_TCLAPI reset_prng_state(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET);\n  return TCL_OK;\n}\n\n/*\n** tclcmd:  database_may_be_corrupt\n**\n** Indicate that database files might be corrupt.  In other words, set the normal\n** state of operation.\n*/\nstatic int SQLITE_TCLAPI database_may_be_corrupt(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0);\n  return TCL_OK;\n}\n/*\n** tclcmd:  database_never_corrupt\n**\n** Indicate that database files are always well-formed.  This enables extra assert()\n** statements that test conditions that are always true for well-formed databases.\n*/\nstatic int SQLITE_TCLAPI database_never_corrupt(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 1);\n  return TCL_OK;\n}\n\n/*\n** tclcmd:  pcache_stats\n*/\nstatic int SQLITE_TCLAPI test_pcache_stats(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int nMin;\n  int nMax;\n  int nCurrent;\n  int nRecyclable;\n  Tcl_Obj *pRet;\n\n  sqlite3PcacheStats(&nCurrent, &nMax, &nMin, &nRecyclable);\n\n  pRet = Tcl_NewObj();\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"current\", -1));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nCurrent));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"max\", -1));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nMax));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"min\", -1));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nMin));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"recyclable\", -1));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nRecyclable));\n\n  Tcl_SetObjResult(interp, pRet);\n\n  return TCL_OK;\n}\n\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nstatic void test_unlock_notify_cb(void **aArg, int nArg){\n  int ii;\n  for(ii=0; ii<nArg; ii++){\n    Tcl_EvalEx((Tcl_Interp *)aArg[ii], \"unlock_notify\", -1, TCL_EVAL_GLOBAL);\n  }\n}\n#endif /* SQLITE_ENABLE_UNLOCK_NOTIFY */\n\n/*\n** tclcmd:  sqlite3_unlock_notify db\n*/\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\nstatic int SQLITE_TCLAPI test_unlock_notify(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_unlock_notify(db, test_unlock_notify_cb, (void *)interp);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n#endif\n\n/*\n** tclcmd:  sqlite3_wal_checkpoint db ?NAME?\n*/\nstatic int SQLITE_TCLAPI test_wal_checkpoint(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zDb = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=3 && objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB ?NAME?\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  if( objc==3 ){\n    zDb = Tcl_GetString(objv[2]);\n  }\n  rc = sqlite3_wal_checkpoint(db, zDb);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** tclcmd:  sqlite3_wal_checkpoint_v2 db MODE ?NAME?\n**\n** This command calls the wal_checkpoint_v2() function with the specified\n** mode argument (passive, full or restart). If present, the database name\n** NAME is passed as the second argument to wal_checkpoint_v2(). If it the\n** NAME argument is not present, a NULL pointer is passed instead.\n**\n** If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or\n** SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set\n** to the error message obtained from sqlite3_errmsg().\n**\n** Otherwise, this command returns a list of three integers. The first integer\n** is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers\n** are the values returned via the output parameters by wal_checkpoint_v2() -\n** the number of frames in the log and the number of frames in the log\n** that have been checkpointed.\n*/\nstatic int SQLITE_TCLAPI test_wal_checkpoint_v2(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zDb = 0;\n  sqlite3 *db;\n  int rc;\n\n  int eMode;\n  int nLog = -555;\n  int nCkpt = -555;\n  Tcl_Obj *pRet;\n\n  const char * aMode[] = { \"passive\", \"full\", \"restart\", \"truncate\", 0 };\n  assert( SQLITE_CHECKPOINT_PASSIVE==0 );\n  assert( SQLITE_CHECKPOINT_FULL==1 );\n  assert( SQLITE_CHECKPOINT_RESTART==2 );\n  assert( SQLITE_CHECKPOINT_TRUNCATE==3 );\n\n  if( objc!=3 && objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB MODE ?NAME?\");\n    return TCL_ERROR;\n  }\n\n  if( objc==4 ){\n    zDb = Tcl_GetString(objv[3]);\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) || (\n      TCL_OK!=Tcl_GetIntFromObj(0, objv[2], &eMode)\n   && TCL_OK!=Tcl_GetIndexFromObj(interp, objv[2], aMode, \"mode\", 0, &eMode) \n  )){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_wal_checkpoint_v2(db, zDb, eMode, &nLog, &nCkpt);\n  if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n    const char *zErrCode = sqlite3ErrName(rc);\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, zErrCode, \" - \", (char *)sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(rc==SQLITE_BUSY?1:0));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nLog));\n  Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(nCkpt));\n  Tcl_SetObjResult(interp, pRet);\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd:  sqlite3_wal_autocheckpoint db VALUE\n*/\nstatic int SQLITE_TCLAPI test_wal_autocheckpoint(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  int iVal;\n\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB VALUE\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) \n   || Tcl_GetIntFromObj(0, objv[2], &iVal)\n  ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_wal_autocheckpoint(db, iVal);\n  Tcl_ResetResult(interp);\n  if( rc!=SQLITE_OK ){\n    const char *zErrCode = sqlite3ErrName(rc);\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(zErrCode, -1));\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd:  test_sqlite3_log ?SCRIPT?\n*/\nstatic struct LogCallback {\n  Tcl_Interp *pInterp;\n  Tcl_Obj *pObj;\n} logcallback = {0, 0};\nstatic void xLogcallback(void *unused, int err, char *zMsg){\n  Tcl_Obj *pNew = Tcl_DuplicateObj(logcallback.pObj);\n  Tcl_IncrRefCount(pNew);\n  Tcl_ListObjAppendElement(\n      0, pNew, Tcl_NewStringObj(sqlite3ErrName(err), -1)\n  );\n  Tcl_ListObjAppendElement(0, pNew, Tcl_NewStringObj(zMsg, -1));\n  Tcl_EvalObjEx(logcallback.pInterp, pNew, TCL_EVAL_GLOBAL|TCL_EVAL_DIRECT);\n  Tcl_DecrRefCount(pNew);\n}\nstatic int SQLITE_TCLAPI test_sqlite3_log(\n  ClientData clientData,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  if( objc>2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SCRIPT\");\n    return TCL_ERROR;\n  }\n  if( logcallback.pObj ){\n    Tcl_DecrRefCount(logcallback.pObj);\n    logcallback.pObj = 0;\n    logcallback.pInterp = 0;\n    sqlite3_config(SQLITE_CONFIG_LOG, (void*)0, (void*)0);\n  }\n  if( objc>1 ){\n    logcallback.pObj = objv[1];\n    Tcl_IncrRefCount(logcallback.pObj);\n    logcallback.pInterp = interp;\n    sqlite3_config(SQLITE_CONFIG_LOG, xLogcallback, (void*)0);\n  }\n  return TCL_OK;\n}\n\n/*\n**     tcl_objproc COMMANDNAME ARGS...\n**\n** Run a TCL command using its objProc interface.  Throw an error if\n** the command has no objProc interface.\n*/\nstatic int SQLITE_TCLAPI runAsObjProc(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_CmdInfo cmdInfo;\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"COMMAND ...\");\n    return TCL_ERROR;\n  }\n  if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){\n    Tcl_AppendResult(interp, \"command not found: \",\n           Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  if( cmdInfo.objProc==0 ){\n    Tcl_AppendResult(interp, \"command has no objProc: \",\n           Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  return cmdInfo.objProc(cmdInfo.objClientData, interp, objc-1, objv+1);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** WARNING: The following function, printExplainQueryPlan() is an exact\n** copy of example code from eqp.in (eqp.html). If this code is modified,\n** then the documentation copy needs to be modified as well.\n*/\n/*\n** Argument pStmt is a prepared SQL statement. This function compiles\n** an EXPLAIN QUERY PLAN command to report on the prepared statement,\n** and prints the report to stdout using printf().\n*/\nint printExplainQueryPlan(sqlite3_stmt *pStmt){\n  const char *zSql;               /* Input SQL */\n  char *zExplain;                 /* SQL with EXPLAIN QUERY PLAN prepended */\n  sqlite3_stmt *pExplain;         /* Compiled EXPLAIN QUERY PLAN command */\n  int rc;                         /* Return code from sqlite3_prepare_v2() */\n\n  zSql = sqlite3_sql(pStmt);\n  if( zSql==0 ) return SQLITE_ERROR;\n\n  zExplain = sqlite3_mprintf(\"EXPLAIN QUERY PLAN %s\", zSql);\n  if( zExplain==0 ) return SQLITE_NOMEM;\n\n  rc = sqlite3_prepare_v2(sqlite3_db_handle(pStmt), zExplain, -1, &pExplain, 0);\n  sqlite3_free(zExplain);\n  if( rc!=SQLITE_OK ) return rc;\n\n  while( SQLITE_ROW==sqlite3_step(pExplain) ){\n    int iSelectid = sqlite3_column_int(pExplain, 0);\n    int iOrder = sqlite3_column_int(pExplain, 1);\n    int iFrom = sqlite3_column_int(pExplain, 2);\n    const char *zDetail = (const char *)sqlite3_column_text(pExplain, 3);\n\n    printf(\"%d %d %d %s\\n\", iSelectid, iOrder, iFrom, zDetail);\n  }\n\n  return sqlite3_finalize(pExplain);\n}\n\nstatic int SQLITE_TCLAPI test_print_eqp(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3_stmt *pStmt;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;\n  rc = printExplainQueryPlan(pStmt);\n  /* This is needed on Windows so that a test case using this \n  ** function can open a read pipe and get the output of\n  ** printExplainQueryPlan() immediately.\n  */\n  fflush(stdout);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);\n  return TCL_OK;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n/*\n** sqlite3_test_control VERB ARGS...\n*/\nstatic int SQLITE_TCLAPI test_test_control(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct Verb {\n    const char *zName;\n    int i;\n  } aVerb[] = {\n    { \"SQLITE_TESTCTRL_LOCALTIME_FAULT\", SQLITE_TESTCTRL_LOCALTIME_FAULT }, \n    { \"SQLITE_TESTCTRL_SORTER_MMAP\",     SQLITE_TESTCTRL_SORTER_MMAP     }, \n    { \"SQLITE_TESTCTRL_IMPOSTER\",        SQLITE_TESTCTRL_IMPOSTER        },\n  };\n  int iVerb;\n  int iFlag;\n  int rc;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"VERB ARGS...\");\n    return TCL_ERROR;\n  }\n\n  rc = Tcl_GetIndexFromObjStruct(\n      interp, objv[1], aVerb, sizeof(aVerb[0]), \"VERB\", 0, &iVerb\n  );\n  if( rc!=TCL_OK ) return rc;\n\n  iFlag = aVerb[iVerb].i;\n  switch( iFlag ){\n    case SQLITE_TESTCTRL_LOCALTIME_FAULT: {\n      int val;\n      if( objc!=3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"ONOFF\");\n        return TCL_ERROR;\n      }\n      if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;\n      sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, val);\n      break;\n    }\n\n    case SQLITE_TESTCTRL_SORTER_MMAP: {\n      int val;\n      sqlite3 *db;\n      if( objc!=4 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"DB LIMIT\");\n        return TCL_ERROR;\n      }\n      if( getDbPointer(interp, Tcl_GetString(objv[2]), &db) ) return TCL_ERROR;\n      if( Tcl_GetIntFromObj(interp, objv[3], &val) ) return TCL_ERROR;\n      sqlite3_test_control(SQLITE_TESTCTRL_SORTER_MMAP, db, val);\n      break;\n    }\n\n    case SQLITE_TESTCTRL_IMPOSTER: {\n      int onOff, tnum;\n      const char *zDbName;\n      sqlite3 *db;\n      if( objc!=6 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"DB dbName onOff tnum\");\n        return TCL_ERROR;\n      }\n      if( getDbPointer(interp, Tcl_GetString(objv[2]), &db) ) return TCL_ERROR;\n      zDbName = Tcl_GetString(objv[3]);\n      if( Tcl_GetIntFromObj(interp, objv[4], &onOff) ) return TCL_ERROR;\n      if( Tcl_GetIntFromObj(interp, objv[5], &tnum) ) return TCL_ERROR;\n      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, zDbName, onOff, tnum);\n      break;\n    }\n  }\n\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n#if SQLITE_OS_UNIX\n#include <sys/time.h>\n#include <sys/resource.h>\n\nstatic int SQLITE_TCLAPI test_getrusage(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  char buf[1024];\n  struct rusage r;\n  memset(&r, 0, sizeof(r));\n  getrusage(RUSAGE_SELF, &r);\n\n  sqlite3_snprintf(sizeof(buf), buf,\n    \"ru_utime=%d.%06d ru_stime=%d.%06d ru_minflt=%d ru_majflt=%d\", \n    (int)r.ru_utime.tv_sec, (int)r.ru_utime.tv_usec, \n    (int)r.ru_stime.tv_sec, (int)r.ru_stime.tv_usec, \n    (int)r.ru_minflt, (int)r.ru_majflt\n  );\n  Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));\n  return TCL_OK;\n}\n#endif\n\n#if SQLITE_OS_WIN\n/*\n** Information passed from the main thread into the windows file locker\n** background thread.\n*/\nstruct win32FileLocker {\n  char *evName;       /* Name of event to signal thread startup */\n  HANDLE h;           /* Handle of the file to be locked */\n  int delay1;         /* Delay before locking */\n  int delay2;         /* Delay before unlocking */\n  int ok;             /* Finished ok */\n  int err;            /* True if an error occurs */\n};\n#endif\n\n\n#if SQLITE_OS_WIN\n#include <process.h>\n/*\n** The background thread that does file locking.\n*/\nstatic void SQLITE_CDECL win32_file_locker(void *pAppData){\n  struct win32FileLocker *p = (struct win32FileLocker*)pAppData;\n  if( p->evName ){\n    HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName);\n    if ( ev ){\n      SetEvent(ev);\n      CloseHandle(ev);\n    }\n  }\n  if( p->delay1 ) Sleep(p->delay1);\n  if( LockFile(p->h, 0, 0, 100000000, 0) ){\n    Sleep(p->delay2);\n    UnlockFile(p->h, 0, 0, 100000000, 0);\n    p->ok = 1;\n  }else{\n    p->err = 1;\n  }\n  CloseHandle(p->h);\n  p->h = 0;\n  p->delay1 = 0;\n  p->delay2 = 0;\n}\n#endif\n\n#if SQLITE_OS_WIN\n/*\n**      lock_win32_file FILENAME DELAY1 DELAY2\n**\n** Get an exclusive manditory lock on file for DELAY2 milliseconds.\n** Wait DELAY1 milliseconds before acquiring the lock.\n*/\nstatic int SQLITE_TCLAPI win32_file_lock(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  static struct win32FileLocker x = { \"win32_file_lock\", 0, 0, 0, 0, 0 };\n  const char *zFilename;\n  char zBuf[200];\n  int retry = 0;\n  HANDLE ev;\n  DWORD wResult;\n  \n  if( objc!=4 && objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME DELAY1 DELAY2\");\n    return TCL_ERROR;\n  }\n  if( objc==1 ){\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d %d %d %d %d\",\n                     x.ok, x.err, x.delay1, x.delay2, x.h);\n    Tcl_AppendResult(interp, zBuf, (char*)0);\n    return TCL_OK;\n  }\n  while( x.h && retry<30 ){\n    retry++;\n    Sleep(100);\n  }\n  if( x.h ){\n    Tcl_AppendResult(interp, \"busy\", (char*)0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &x.delay1) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &x.delay2) ) return TCL_ERROR;\n  zFilename = Tcl_GetString(objv[1]);\n  x.h = CreateFile(zFilename, GENERIC_READ|GENERIC_WRITE,\n              FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS,\n              FILE_ATTRIBUTE_NORMAL, 0);\n  if( !x.h ){\n    Tcl_AppendResult(interp, \"cannot open file: \", zFilename, (char*)0);\n    return TCL_ERROR;\n  }\n  ev = CreateEvent(NULL, TRUE, FALSE, x.evName);\n  if ( !ev ){\n    Tcl_AppendResult(interp, \"cannot create event: \", x.evName, (char*)0);\n    return TCL_ERROR;\n  }\n  _beginthread(win32_file_locker, 0, (void*)&x);\n  Sleep(0);\n  if ( (wResult = WaitForSingleObject(ev, 10000))!=WAIT_OBJECT_0 ){\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"0x%x\", wResult);\n    Tcl_AppendResult(interp, \"wait failed: \", zBuf, (char*)0);\n    CloseHandle(ev);\n    return TCL_ERROR;\n  }\n  CloseHandle(ev);\n  return TCL_OK;\n}\n\n/*\n**      exists_win32_path PATH\n**\n** Returns non-zero if the specified path exists, whose fully qualified name\n** may exceed 260 characters if it is prefixed with \"\\\\?\\\".\n*/\nstatic int SQLITE_TCLAPI win32_exists_path(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PATH\");\n    return TCL_ERROR;\n  }\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(\n      GetFileAttributesW( Tcl_GetUnicode(objv[1]))!=INVALID_FILE_ATTRIBUTES ));\n  return TCL_OK;\n}\n\n/*\n**      find_win32_file PATTERN\n**\n** Returns a list of entries in a directory that match the specified pattern,\n** whose fully qualified name may exceed 248 characters if it is prefixed with\n** \"\\\\?\\\".\n*/\nstatic int SQLITE_TCLAPI win32_find_file(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  HANDLE hFindFile = INVALID_HANDLE_VALUE;\n  WIN32_FIND_DATAW findData;\n  Tcl_Obj *listObj;\n  DWORD lastErrno;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PATTERN\");\n    return TCL_ERROR;\n  }\n  hFindFile = FindFirstFileW(Tcl_GetUnicode(objv[1]), &findData);\n  if( hFindFile==INVALID_HANDLE_VALUE ){\n    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError()));\n    return TCL_ERROR;\n  }\n  listObj = Tcl_NewObj();\n  Tcl_IncrRefCount(listObj);\n  do {\n    Tcl_ListObjAppendElement(interp, listObj, Tcl_NewUnicodeObj(\n        findData.cFileName, -1));\n    Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(\n        findData.dwFileAttributes));\n  } while( FindNextFileW(hFindFile, &findData) );\n  lastErrno = GetLastError();\n  if( lastErrno!=NO_ERROR && lastErrno!=ERROR_NO_MORE_FILES ){\n    FindClose(hFindFile);\n    Tcl_DecrRefCount(listObj);\n    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError()));\n    return TCL_ERROR;\n  }\n  FindClose(hFindFile);\n  Tcl_SetObjResult(interp, listObj);\n  return TCL_OK;\n}\n\n/*\n**      delete_win32_file FILENAME\n**\n** Deletes the specified file, whose fully qualified name may exceed 260\n** characters if it is prefixed with \"\\\\?\\\".\n*/\nstatic int SQLITE_TCLAPI win32_delete_file(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME\");\n    return TCL_ERROR;\n  }\n  if( !DeleteFileW(Tcl_GetUnicode(objv[1])) ){\n    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError()));\n    return TCL_ERROR;\n  }\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n**      make_win32_dir DIRECTORY\n**\n** Creates the specified directory, whose fully qualified name may exceed 248\n** characters if it is prefixed with \"\\\\?\\\".\n*/\nstatic int SQLITE_TCLAPI win32_mkdir(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DIRECTORY\");\n    return TCL_ERROR;\n  }\n  if( !CreateDirectoryW(Tcl_GetUnicode(objv[1]), NULL) ){\n    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError()));\n    return TCL_ERROR;\n  }\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n**      remove_win32_dir DIRECTORY\n**\n** Removes the specified directory, whose fully qualified name may exceed 248\n** characters if it is prefixed with \"\\\\?\\\".\n*/\nstatic int SQLITE_TCLAPI win32_rmdir(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DIRECTORY\");\n    return TCL_ERROR;\n  }\n  if( !RemoveDirectoryW(Tcl_GetUnicode(objv[1])) ){\n    Tcl_SetObjResult(interp, Tcl_NewWideIntObj(GetLastError()));\n    return TCL_ERROR;\n  }\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n#endif\n\n\n/*\n**      optimization_control DB OPT BOOLEAN\n**\n** Enable or disable query optimizations using the sqlite3_test_control()\n** interface.  Disable if BOOLEAN is false and enable if BOOLEAN is true.\n** OPT is the name of the optimization to be disabled.\n*/\nstatic int SQLITE_TCLAPI optimization_control(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int i;\n  sqlite3 *db;\n  const char *zOpt;\n  int onoff;\n  int mask = 0;\n  static const struct {\n    const char *zOptName;\n    int mask;\n  } aOpt[] = {\n    { \"all\",                 SQLITE_AllOpts        },\n    { \"none\",                0                     },\n    { \"query-flattener\",     SQLITE_QueryFlattener },\n    { \"column-cache\",        SQLITE_ColumnCache    },\n    { \"groupby-order\",       SQLITE_GroupByOrder   },\n    { \"factor-constants\",    SQLITE_FactorOutConst },\n    { \"distinct-opt\",        SQLITE_DistinctOpt    },\n    { \"cover-idx-scan\",      SQLITE_CoverIdxScan   },\n    { \"order-by-idx-join\",   SQLITE_OrderByIdxJoin },\n    { \"transitive\",          SQLITE_Transitive     },\n    { \"omit-noop-join\",      SQLITE_OmitNoopJoin   },\n    { \"stat3\",               SQLITE_Stat34         },\n    { \"stat4\",               SQLITE_Stat34         },\n  };\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB OPT BOOLEAN\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  if( Tcl_GetBooleanFromObj(interp, objv[3], &onoff) ) return TCL_ERROR;\n  zOpt = Tcl_GetString(objv[2]);\n  for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){\n    if( strcmp(zOpt, aOpt[i].zOptName)==0 ){\n      mask = aOpt[i].mask;\n      break;\n    }\n  }\n  if( onoff ) mask = ~mask;\n  if( i>=sizeof(aOpt)/sizeof(aOpt[0]) ){\n    Tcl_AppendResult(interp, \"unknown optimization - should be one of:\",\n                     (char*)0);\n    for(i=0; i<sizeof(aOpt)/sizeof(aOpt[0]); i++){\n      Tcl_AppendResult(interp, \" \", aOpt[i].zOptName, (char*)0);\n    }\n    return TCL_ERROR;\n  }\n  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, db, mask);\n  return TCL_OK;\n}\n\n/*\n**     load_static_extension DB NAME ...\n**\n** Load one or more statically linked extensions.\n*/\nstatic int SQLITE_TCLAPI tclLoadStaticExtensionCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_carray_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_csv_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_eval_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_remember_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*);\n  extern int sqlite3_unionvtab_init(sqlite3*,char**,const sqlite3_api_routines*);\n  static const struct {\n    const char *zExtName;\n    int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*);\n  } aExtension[] = {\n    { \"amatch\",                sqlite3_amatch_init               },\n    { \"carray\",                sqlite3_carray_init               },\n    { \"closure\",               sqlite3_closure_init              },\n    { \"csv\",                   sqlite3_csv_init                  },\n    { \"eval\",                  sqlite3_eval_init                 },\n    { \"fileio\",                sqlite3_fileio_init               },\n    { \"fuzzer\",                sqlite3_fuzzer_init               },\n    { \"ieee754\",               sqlite3_ieee_init                 },\n    { \"nextchar\",              sqlite3_nextchar_init             },\n    { \"percentile\",            sqlite3_percentile_init           },\n    { \"regexp\",                sqlite3_regexp_init               },\n    { \"remember\",              sqlite3_remember_init             },\n    { \"series\",                sqlite3_series_init               },\n    { \"spellfix\",              sqlite3_spellfix_init             },\n    { \"totype\",                sqlite3_totype_init               },\n    { \"unionvtab\",             sqlite3_unionvtab_init            },\n    { \"wholenumber\",           sqlite3_wholenumber_init          },\n  };\n  sqlite3 *db;\n  const char *zName;\n  int i, j, rc;\n  char *zErrMsg = 0;\n  if( objc<3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB NAME ...\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  for(j=2; j<objc; j++){\n    zName = Tcl_GetString(objv[j]);\n    for(i=0; i<ArraySize(aExtension); i++){\n      if( strcmp(zName, aExtension[i].zExtName)==0 ) break;\n    }\n    if( i>=ArraySize(aExtension) ){\n      Tcl_AppendResult(interp, \"no such extension: \", zName, (char*)0);\n      return TCL_ERROR;\n    }\n    if( aExtension[i].pInit ){\n      rc = aExtension[i].pInit(db, &zErrMsg, 0);\n    }else{\n      rc = SQLITE_OK;\n    }\n    if( rc!=SQLITE_OK || zErrMsg ){\n      Tcl_AppendResult(interp, \"initialization of \", zName, \" failed: \", zErrMsg,\n                       (char*)0);\n      sqlite3_free(zErrMsg);\n      return TCL_ERROR;\n    }\n  }\n  return TCL_OK;\n}\n\n/*\n**     sorter_test_fakeheap BOOL\n**\n*/\nstatic int SQLITE_TCLAPI sorter_test_fakeheap(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int bArg;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOL\");\n    return TCL_ERROR;\n  }\n\n  if( Tcl_GetBooleanFromObj(interp, objv[1], &bArg) ){\n    return TCL_ERROR;\n  }\n\n  if( bArg ){\n    if( sqlite3GlobalConfig.pHeap==0 ){\n      sqlite3GlobalConfig.pHeap = SQLITE_INT_TO_PTR(-1);\n    }\n  }else{\n    if( sqlite3GlobalConfig.pHeap==SQLITE_INT_TO_PTR(-1) ){\n      sqlite3GlobalConfig.pHeap = 0;\n    }\n  }\n\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\n/*\n**     sorter_test_sort4_helper DB SQL1 NSTEP SQL2\n**\n** Compile SQL statement $SQL1 and step it $NSTEP times. For each row, \n** check that the leftmost and rightmost columns returned are both integers,\n** and that both contain the same value.\n**\n** Then execute statement $SQL2. Check that the statement returns the same\n** set of integers in the same order as in the previous step (using $SQL1).\n*/\nstatic int SQLITE_TCLAPI sorter_test_sort4_helper(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zSql1;\n  const char *zSql2;\n  int nStep; \n  int iStep; \n  unsigned int iCksum1 = 0; \n  unsigned int iCksum2 = 0; \n  int rc;\n  int iB;\n  sqlite3 *db;\n  sqlite3_stmt *pStmt;\n  \n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB SQL1 NSTEP SQL2\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql1 = Tcl_GetString(objv[2]);\n  if( Tcl_GetIntFromObj(interp, objv[3], &nStep) ) return TCL_ERROR;\n  zSql2 = Tcl_GetString(objv[4]);\n\n  rc = sqlite3_prepare_v2(db, zSql1, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) goto sql_error;\n\n  iB = sqlite3_column_count(pStmt)-1;\n  for(iStep=0; iStep<nStep && SQLITE_ROW==sqlite3_step(pStmt); iStep++){\n    int a = sqlite3_column_int(pStmt, 0);\n    if( a!=sqlite3_column_int(pStmt, iB) ){\n      Tcl_AppendResult(interp, \"data error: (a!=b)\", 0);\n      return TCL_ERROR;\n    }\n\n    iCksum1 += (iCksum1 << 3) + (unsigned int)a;\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc!=SQLITE_OK ) goto sql_error;\n\n  rc = sqlite3_prepare_v2(db, zSql2, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) goto sql_error;\n  for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){\n    int a = sqlite3_column_int(pStmt, 0);\n    iCksum2 += (iCksum2 << 3) + (unsigned int)a;\n  }\n  rc = sqlite3_finalize(pStmt);\n  if( rc!=SQLITE_OK ) goto sql_error;\n\n  if( iCksum1!=iCksum2 ){\n    Tcl_AppendResult(interp, \"checksum mismatch\", 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n sql_error:\n  Tcl_AppendResult(interp, \"sql error: \", sqlite3_errmsg(db), 0);\n  return TCL_ERROR;\n}\n\n\n#ifdef SQLITE_USER_AUTHENTICATION\n#include \"sqlite3userauth.h\"\n/*\n** tclcmd:  sqlite3_user_authenticate DB USERNAME PASSWORD\n*/\nstatic int SQLITE_TCLAPI test_user_authenticate(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zUser = 0;\n  char *zPasswd = 0;\n  int nPasswd = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB USERNAME PASSWORD\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  zUser = Tcl_GetString(objv[2]);\n  zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd);\n  rc = sqlite3_user_authenticate(db, zUser, zPasswd, nPasswd);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** tclcmd:  sqlite3_user_add DB USERNAME PASSWORD ISADMIN\n*/\nstatic int SQLITE_TCLAPI test_user_add(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zUser = 0;\n  char *zPasswd = 0;\n  int nPasswd = 0;\n  int isAdmin = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB USERNAME PASSWORD ISADMIN\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  zUser = Tcl_GetString(objv[2]);\n  zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd);\n  Tcl_GetBooleanFromObj(interp, objv[4], &isAdmin);\n  rc = sqlite3_user_add(db, zUser, zPasswd, nPasswd, isAdmin);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** tclcmd:  sqlite3_user_change DB USERNAME PASSWORD ISADMIN\n*/\nstatic int SQLITE_TCLAPI test_user_change(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zUser = 0;\n  char *zPasswd = 0;\n  int nPasswd = 0;\n  int isAdmin = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB USERNAME PASSWORD ISADMIN\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  zUser = Tcl_GetString(objv[2]);\n  zPasswd = Tcl_GetStringFromObj(objv[3], &nPasswd);\n  Tcl_GetBooleanFromObj(interp, objv[4], &isAdmin);\n  rc = sqlite3_user_change(db, zUser, zPasswd, nPasswd, isAdmin);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n#ifdef SQLITE_USER_AUTHENTICATION\n/*\n** tclcmd:  sqlite3_user_delete DB USERNAME\n*/\nstatic int SQLITE_TCLAPI test_user_delete(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  char *zUser = 0;\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB USERNAME\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ){\n    return TCL_ERROR;\n  }\n  zUser = Tcl_GetString(objv[2]);\n  rc = sqlite3_user_delete(db, zUser);\n  Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n#endif /* SQLITE_USER_AUTHENTICATION */\n\n/*\n** tclcmd: bad_behavior TYPE\n**\n** Do some things that should trigger a valgrind or -fsanitize=undefined\n** warning.  This is used to verify that errors and warnings output by those\n** tools are detected by the test scripts.\n**\n**       TYPE       BEHAVIOR\n**       1          Overflow a signed integer\n**       2          Jump based on an uninitialized variable\n**       3          Read after free\n**       4          Panic\n*/\nstatic int SQLITE_TCLAPI test_bad_behavior(\n  ClientData clientData, /* Pointer to an integer containing zero */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int iType;\n  int xyz;\n  int i = *(int*)clientData;\n  int j;\n  int w[10];\n  int *a;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"TYPE\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &iType) ) return TCL_ERROR;\n  switch( iType ){\n    case 1: {\n      xyz = 0x7fffff00 - i;\n      xyz += 0x100;\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(xyz));\n      break;\n    }\n    case 2: {\n      w[1] = 5;\n      if( w[i]>0 ) w[1]++;\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(w[1]));\n      break;\n    }\n    case 3: {\n      a = malloc( sizeof(int)*10 );\n      for(j=0; j<10; j++) a[j] = j;\n      free(a);\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(a[i]));\n      break;\n    }\n    case 4: {\n      Tcl_Panic(\"Deliberate panic\");\n      break;\n    }\n  }\n  return TCL_OK;\n}  \n\n/*\n** tclcmd:   register_dbstat_vtab DB\n**\n** Cause the dbstat virtual table to be available on the connection DB\n*/\nstatic int SQLITE_TCLAPI test_register_dbstat_vtab(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  Tcl_AppendResult(interp, \"dbstat not available because of \"\n                           \"SQLITE_OMIT_VIRTUALTABLE\", (void*)0);\n  return TCL_ERROR;\n#else\n  struct SqliteDb { sqlite3 *db; };\n  char *zDb;\n  Tcl_CmdInfo cmdInfo;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n\n  zDb = Tcl_GetString(objv[1]);\n  if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){\n    sqlite3* db = ((struct SqliteDb*)cmdInfo.objClientData)->db;\n    sqlite3DbstatRegister(db);\n  }\n  return TCL_OK;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n}\n\n/*\n** tclcmd:   sqlite3_db_config DB SETTING VALUE\n**\n** Invoke sqlite3_db_config() for one of the setting values.\n*/\nstatic int SQLITE_TCLAPI test_sqlite3_db_config(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  static const struct {\n    const char *zName;\n    int eVal;\n  } aSetting[] = {\n    { \"FKEY\",            SQLITE_DBCONFIG_ENABLE_FKEY },\n    { \"TRIGGER\",         SQLITE_DBCONFIG_ENABLE_TRIGGER },\n    { \"FTS3_TOKENIZER\",  SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER },\n    { \"LOAD_EXTENSION\",  SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION },\n    { \"NO_CKPT_ON_CLOSE\",SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE },\n    { \"QPSG\",            SQLITE_DBCONFIG_ENABLE_QPSG },\n  };\n  int i;\n  int v;\n  const char *zSetting;\n  sqlite3 *db;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB SETTING VALUE\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSetting = Tcl_GetString(objv[2]);\n  if( sqlite3_strglob(\"SQLITE_*\", zSetting)==0 ) zSetting += 7;\n  if( sqlite3_strglob(\"DBCONFIG_*\", zSetting)==0 ) zSetting += 9;\n  if( sqlite3_strglob(\"ENABLE_*\", zSetting)==0 ) zSetting += 7;\n  for(i=0; i<ArraySize(aSetting); i++){\n    if( strcmp(zSetting, aSetting[i].zName)==0 ) break;\n  }\n  if( i>=ArraySize(aSetting) ){\n    Tcl_SetObjResult(interp,\n      Tcl_NewStringObj(\"unknown sqlite3_db_config setting\", -1));\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[3], &v) ) return TCL_ERROR;\n  sqlite3_db_config(db, aSetting[i].eVal, v, &v);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(v));\n  return TCL_OK;\n}\n\n/*\n** Change the name of the main database schema from \"main\" to \"icecube\".\n*/\nstatic int SQLITE_TCLAPI test_dbconfig_maindbname_icecube(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  sqlite3 *db;\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }else{\n    if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n    rc = sqlite3_db_config(db, SQLITE_DBCONFIG_MAINDBNAME, \"icecube\");\n    Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n    return TCL_OK;\n  }\n}\n\n/*\n** Usage: sqlite3_mmap_warm DB DBNAME\n*/\nstatic int SQLITE_TCLAPI test_mmap_warm(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  extern int sqlite3_mmap_warm(sqlite3 *db, const char *);\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB ?DBNAME?\");\n    return TCL_ERROR;\n  }else{\n    int rc;\n    sqlite3 *db;\n    const char *zDb = 0;\n    if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n    if( objc==3 ){\n      zDb = Tcl_GetString(objv[2]);\n    }\n    rc = sqlite3_mmap_warm(db, zDb);\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_OK;\n  }\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest1_Init(Tcl_Interp *interp){\n  extern int sqlite3_search_count;\n  extern int sqlite3_found_count;\n  extern int sqlite3_interrupt_count;\n  extern int sqlite3_open_file_count;\n  extern int sqlite3_sort_count;\n  extern int sqlite3_current_time;\n#if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n  extern int sqlite3_hostid_num;\n#endif\n  extern int sqlite3_max_blobsize;\n  extern int SQLITE_TCLAPI sqlite3BtreeSharedCacheReport(void*,\n                                          Tcl_Interp*,int,Tcl_Obj*CONST*);\n  static int iZero = 0;\n  static struct {\n     char *zName;\n     Tcl_CmdProc *xProc;\n  } aCmd[] = {\n     { \"db_enter\",                      (Tcl_CmdProc*)db_enter               },\n     { \"db_leave\",                      (Tcl_CmdProc*)db_leave               },\n     { \"sqlite3_mprintf_int\",           (Tcl_CmdProc*)sqlite3_mprintf_int    },\n     { \"sqlite3_mprintf_int64\",         (Tcl_CmdProc*)sqlite3_mprintf_int64  },\n     { \"sqlite3_mprintf_long\",          (Tcl_CmdProc*)sqlite3_mprintf_long   },\n     { \"sqlite3_mprintf_str\",           (Tcl_CmdProc*)sqlite3_mprintf_str    },\n     { \"sqlite3_snprintf_str\",          (Tcl_CmdProc*)sqlite3_snprintf_str   },\n     { \"sqlite3_mprintf_stronly\",       (Tcl_CmdProc*)sqlite3_mprintf_stronly},\n     { \"sqlite3_mprintf_double\",        (Tcl_CmdProc*)sqlite3_mprintf_double },\n     { \"sqlite3_mprintf_scaled\",        (Tcl_CmdProc*)sqlite3_mprintf_scaled },\n     { \"sqlite3_mprintf_hexdouble\",   (Tcl_CmdProc*)sqlite3_mprintf_hexdouble},\n     { \"sqlite3_mprintf_z_test\",        (Tcl_CmdProc*)test_mprintf_z        },\n     { \"sqlite3_mprintf_n_test\",        (Tcl_CmdProc*)test_mprintf_n        },\n     { \"sqlite3_snprintf_int\",          (Tcl_CmdProc*)test_snprintf_int     },\n     { \"sqlite3_last_insert_rowid\",     (Tcl_CmdProc*)test_last_rowid       },\n     { \"sqlite3_exec_printf\",           (Tcl_CmdProc*)test_exec_printf      },\n     { \"sqlite3_exec_hex\",              (Tcl_CmdProc*)test_exec_hex         },\n     { \"sqlite3_exec\",                  (Tcl_CmdProc*)test_exec             },\n     { \"sqlite3_exec_nr\",               (Tcl_CmdProc*)test_exec_nr          },\n#ifndef SQLITE_OMIT_GET_TABLE\n     { \"sqlite3_get_table_printf\",      (Tcl_CmdProc*)test_get_table_printf },\n#endif\n     { \"sqlite3_close\",                 (Tcl_CmdProc*)sqlite_test_close     },\n     { \"sqlite3_close_v2\",              (Tcl_CmdProc*)sqlite_test_close_v2  },\n     { \"sqlite3_create_function\",       (Tcl_CmdProc*)test_create_function  },\n     { \"sqlite3_create_aggregate\",      (Tcl_CmdProc*)test_create_aggregate },\n     { \"sqlite_register_test_function\", (Tcl_CmdProc*)test_register_func    },\n     { \"sqlite_abort\",                  (Tcl_CmdProc*)sqlite_abort          },\n     { \"sqlite_bind\",                   (Tcl_CmdProc*)test_bind             },\n     { \"breakpoint\",                    (Tcl_CmdProc*)test_breakpoint       },\n     { \"sqlite3_key\",                   (Tcl_CmdProc*)test_key              },\n     { \"sqlite3_rekey\",                 (Tcl_CmdProc*)test_rekey            },\n     { \"sqlite_set_magic\",              (Tcl_CmdProc*)sqlite_set_magic      },\n     { \"sqlite3_interrupt\",             (Tcl_CmdProc*)test_interrupt        },\n     { \"sqlite_delete_function\",        (Tcl_CmdProc*)delete_function       },\n     { \"sqlite_delete_collation\",       (Tcl_CmdProc*)delete_collation      },\n     { \"sqlite3_get_autocommit\",        (Tcl_CmdProc*)get_autocommit        },\n     { \"sqlite3_busy_timeout\",          (Tcl_CmdProc*)test_busy_timeout     },\n     { \"printf\",                        (Tcl_CmdProc*)test_printf           },\n     { \"sqlite3IoTrace\",              (Tcl_CmdProc*)test_io_trace         },\n     { \"clang_sanitize_address\",        (Tcl_CmdProc*)clang_sanitize_address },\n  };\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"sqlite3_db_config\",             test_sqlite3_db_config, 0 },\n     { \"bad_behavior\",                  test_bad_behavior,  (void*)&iZero },\n     { \"register_dbstat_vtab\",          test_register_dbstat_vtab  },\n     { \"sqlite3_connection_pointer\",    get_sqlite_pointer, 0 },\n     { \"intarray_addr\",                 test_intarray_addr, 0 },\n     { \"int64array_addr\",               test_int64array_addr, 0 },\n     { \"doublearray_addr\",              test_doublearray_addr, 0 },\n     { \"textarray_addr\",                test_textarray_addr, 0 },\n     { \"sqlite3_bind_int\",              test_bind_int,      0 },\n     { \"sqlite3_bind_zeroblob\",         test_bind_zeroblob, 0 },\n     { \"sqlite3_bind_zeroblob64\",       test_bind_zeroblob64, 0 },\n     { \"sqlite3_bind_int64\",            test_bind_int64,    0 },\n     { \"sqlite3_bind_double\",           test_bind_double,   0 },\n     { \"sqlite3_bind_null\",             test_bind_null     ,0 },\n     { \"sqlite3_bind_text\",             test_bind_text     ,0 },\n     { \"sqlite3_bind_text16\",           test_bind_text16   ,0 },\n     { \"sqlite3_bind_blob\",             test_bind_blob     ,0 },\n     { \"sqlite3_bind_parameter_count\",  test_bind_parameter_count, 0},\n     { \"sqlite3_bind_parameter_name\",   test_bind_parameter_name,  0},\n     { \"sqlite3_bind_parameter_index\",  test_bind_parameter_index, 0},\n     { \"sqlite3_clear_bindings\",        test_clear_bindings, 0},\n     { \"sqlite3_sleep\",                 test_sleep,          0},\n     { \"sqlite3_errcode\",               test_errcode       ,0 },\n     { \"sqlite3_extended_errcode\",      test_ex_errcode    ,0 },\n     { \"sqlite3_errmsg\",                test_errmsg        ,0 },\n     { \"sqlite3_errmsg16\",              test_errmsg16      ,0 },\n     { \"sqlite3_open\",                  test_open          ,0 },\n     { \"sqlite3_open16\",                test_open16        ,0 },\n     { \"sqlite3_open_v2\",               test_open_v2       ,0 },\n     { \"sqlite3_complete16\",            test_complete16    ,0 },\n\n     { \"sqlite3_prepare\",               test_prepare       ,0 },\n     { \"sqlite3_prepare16\",             test_prepare16     ,0 },\n     { \"sqlite3_prepare_v2\",            test_prepare_v2    ,0 },\n     { \"sqlite3_prepare_tkt3134\",       test_prepare_tkt3134, 0},\n     { \"sqlite3_prepare16_v2\",          test_prepare16_v2  ,0 },\n     { \"sqlite3_finalize\",              test_finalize      ,0 },\n     { \"sqlite3_stmt_status\",           test_stmt_status   ,0 },\n     { \"sqlite3_reset\",                 test_reset         ,0 },\n     { \"sqlite3_expired\",               test_expired       ,0 },\n     { \"sqlite3_transfer_bindings\",     test_transfer_bind ,0 },\n     { \"sqlite3_changes\",               test_changes       ,0 },\n     { \"sqlite3_step\",                  test_step          ,0 },\n     { \"sqlite3_sql\",                   test_sql           ,0 },\n     { \"sqlite3_expanded_sql\",          test_ex_sql        ,0 },\n     { \"sqlite3_next_stmt\",             test_next_stmt     ,0 },\n     { \"sqlite3_stmt_readonly\",         test_stmt_readonly ,0 },\n     { \"sqlite3_stmt_busy\",             test_stmt_busy     ,0 },\n     { \"uses_stmt_journal\",             uses_stmt_journal ,0 },\n\n     { \"sqlite3_release_memory\",        test_release_memory,     0},\n     { \"sqlite3_db_release_memory\",     test_db_release_memory,  0},\n     { \"sqlite3_db_cacheflush\",         test_db_cacheflush,      0},\n     { \"sqlite3_system_errno\",          test_system_errno,       0},\n     { \"sqlite3_db_filename\",           test_db_filename,        0},\n     { \"sqlite3_db_readonly\",           test_db_readonly,        0},\n     { \"sqlite3_soft_heap_limit\",       test_soft_heap_limit,    0},\n     { \"sqlite3_thread_cleanup\",        test_thread_cleanup,     0},\n     { \"sqlite3_pager_refcounts\",       test_pager_refcounts,    0},\n\n     { \"sqlite3_load_extension\",        test_load_extension,     0},\n     { \"sqlite3_enable_load_extension\", test_enable_load,        0},\n     { \"sqlite3_extended_result_codes\", test_extended_result_codes, 0},\n     { \"sqlite3_limit\",                 test_limit,                 0},\n     { \"dbconfig_maindbname_icecube\",   test_dbconfig_maindbname_icecube },\n\n     { \"save_prng_state\",               save_prng_state,    0 },\n     { \"restore_prng_state\",            restore_prng_state, 0 },\n     { \"reset_prng_state\",              reset_prng_state,   0 },\n     { \"database_never_corrupt\",        database_never_corrupt, 0},\n     { \"database_may_be_corrupt\",       database_may_be_corrupt, 0},\n     { \"optimization_control\",          optimization_control,0},\n#if SQLITE_OS_WIN\n     { \"lock_win32_file\",               win32_file_lock,    0 },\n     { \"exists_win32_path\",             win32_exists_path,  0 },\n     { \"find_win32_file\",               win32_find_file,    0 },\n     { \"delete_win32_file\",             win32_delete_file,  0 },\n     { \"make_win32_dir\",                win32_mkdir,        0 },\n     { \"remove_win32_dir\",              win32_rmdir,        0 },\n#endif\n     { \"tcl_objproc\",                   runAsObjProc,       0 },\n\n     /* sqlite3_column_*() API */\n     { \"sqlite3_column_count\",          test_column_count  ,0 },\n     { \"sqlite3_data_count\",            test_data_count    ,0 },\n     { \"sqlite3_column_type\",           test_column_type   ,0 },\n     { \"sqlite3_column_blob\",           test_column_blob   ,0 },\n     { \"sqlite3_column_double\",         test_column_double ,0 },\n     { \"sqlite3_column_int64\",          test_column_int64  ,0 },\n     { \"sqlite3_column_text\",   test_stmt_utf8,  (void*)sqlite3_column_text },\n     { \"sqlite3_column_name\",   test_stmt_utf8,  (void*)sqlite3_column_name },\n     { \"sqlite3_column_int\",    test_stmt_int,   (void*)sqlite3_column_int  },\n     { \"sqlite3_column_bytes\",  test_stmt_int,   (void*)sqlite3_column_bytes},\n#ifndef SQLITE_OMIT_DECLTYPE\n     { \"sqlite3_column_decltype\",test_stmt_utf8,(void*)sqlite3_column_decltype},\n#endif\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n{ \"sqlite3_column_database_name\",test_stmt_utf8,(void*)sqlite3_column_database_name},\n{ \"sqlite3_column_table_name\",test_stmt_utf8,(void*)sqlite3_column_table_name},\n{ \"sqlite3_column_origin_name\",test_stmt_utf8,(void*)sqlite3_column_origin_name},\n#endif\n\n#ifndef SQLITE_OMIT_UTF16\n     { \"sqlite3_column_bytes16\", test_stmt_int, (void*)sqlite3_column_bytes16 },\n     { \"sqlite3_column_text16\",  test_stmt_utf16, (void*)sqlite3_column_text16},\n     { \"sqlite3_column_name16\",  test_stmt_utf16, (void*)sqlite3_column_name16},\n     { \"add_alignment_test_collations\", add_alignment_test_collations, 0      },\n#ifndef SQLITE_OMIT_DECLTYPE\n     { \"sqlite3_column_decltype16\",test_stmt_utf16,(void*)sqlite3_column_decltype16},\n#endif\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n{\"sqlite3_column_database_name16\",\n  test_stmt_utf16, (void*)sqlite3_column_database_name16},\n{\"sqlite3_column_table_name16\", test_stmt_utf16, (void*)sqlite3_column_table_name16},\n{\"sqlite3_column_origin_name16\", test_stmt_utf16, (void*)sqlite3_column_origin_name16},\n#endif\n#endif\n     { \"sqlite3_create_collation_v2\", test_create_collation_v2, 0 },\n     { \"sqlite3_global_recover\",     test_global_recover, 0   },\n     { \"working_64bit_int\",          working_64bit_int,   0   },\n     { \"vfs_unlink_test\",            vfs_unlink_test,     0   },\n     { \"vfs_initfail_test\",          vfs_initfail_test,   0   },\n     { \"vfs_unregister_all\",         vfs_unregister_all,  0   },\n     { \"vfs_reregister_all\",         vfs_reregister_all,  0   },\n     { \"file_control_test\",          file_control_test,   0   },\n     { \"file_control_lasterrno_test\", file_control_lasterrno_test,  0   },\n     { \"file_control_lockproxy_test\", file_control_lockproxy_test,  0   },\n     { \"file_control_chunksize_test\", file_control_chunksize_test,  0   },\n     { \"file_control_sizehint_test\",  file_control_sizehint_test,   0   },\n#if SQLITE_OS_WIN\n     { \"file_control_win32_av_retry\", file_control_win32_av_retry,  0   },\n     { \"file_control_win32_get_handle\", file_control_win32_get_handle, 0  },\n     { \"file_control_win32_set_handle\", file_control_win32_set_handle, 0  },\n#endif\n     { \"file_control_persist_wal\",    file_control_persist_wal,     0   },\n     { \"file_control_powersafe_overwrite\",file_control_powersafe_overwrite,0},\n     { \"file_control_vfsname\",        file_control_vfsname,         0   },\n     { \"file_control_tempfilename\",   file_control_tempfilename,    0   },\n     { \"sqlite3_vfs_list\",           vfs_list,     0   },\n     { \"sqlite3_create_function_v2\", test_create_function_v2, 0 },\n\n     /* Functions from os.h */\n#ifndef SQLITE_OMIT_UTF16\n     { \"add_test_collate\",        test_collate, 0            },\n     { \"add_test_collate_needed\", test_collate_needed, 0     },\n     { \"add_test_function\",       test_function, 0           },\n     { \"add_test_utf16bin_collate\",    test_utf16bin_collate, 0        },\n#endif\n     { \"sqlite3_test_errstr\",     test_errstr, 0             },\n     { \"tcl_variable_type\",       tcl_variable_type, 0       },\n#ifndef SQLITE_OMIT_SHARED_CACHE\n     { \"sqlite3_enable_shared_cache\", test_enable_shared, 0  },\n     { \"sqlite3_shared_cache_report\", sqlite3BtreeSharedCacheReport, 0},\n#endif\n     { \"sqlite3_libversion_number\", test_libversion_number, 0  },\n     { \"sqlite3_table_column_metadata\", test_table_column_metadata, 0  },\n#ifndef SQLITE_OMIT_INCRBLOB\n     { \"sqlite3_blob_reopen\", test_blob_reopen, 0  },\n#endif\n     { \"pcache_stats\",       test_pcache_stats, 0  },\n#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY\n     { \"sqlite3_unlock_notify\", test_unlock_notify, 0  },\n#endif\n     { \"sqlite3_wal_checkpoint\",   test_wal_checkpoint, 0  },\n     { \"sqlite3_wal_checkpoint_v2\",test_wal_checkpoint_v2, 0  },\n     { \"sqlite3_wal_autocheckpoint\",test_wal_autocheckpoint, 0  },\n     { \"test_sqlite3_log\",         test_sqlite3_log, 0  },\n#ifndef SQLITE_OMIT_EXPLAIN\n     { \"print_explain_query_plan\", test_print_eqp, 0  },\n#endif\n     { \"sqlite3_test_control\", test_test_control },\n#if SQLITE_OS_UNIX\n     { \"getrusage\", test_getrusage },\n#endif\n     { \"load_static_extension\", tclLoadStaticExtensionCmd },\n     { \"sorter_test_fakeheap\", sorter_test_fakeheap },\n     { \"sorter_test_sort4_helper\", sorter_test_sort4_helper },\n#ifdef SQLITE_USER_AUTHENTICATION\n     { \"sqlite3_user_authenticate\", test_user_authenticate, 0 },\n     { \"sqlite3_user_add\",          test_user_add,          0 },\n     { \"sqlite3_user_change\",       test_user_change,       0 },\n     { \"sqlite3_user_delete\",       test_user_delete,       0 },\n#endif\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n     { \"sqlite3_stmt_scanstatus\",       test_stmt_scanstatus,   0 },\n     { \"sqlite3_stmt_scanstatus_reset\", test_stmt_scanstatus_reset,   0 },\n#endif\n#ifdef SQLITE_ENABLE_SQLLOG\n     { \"sqlite3_config_sqllog\",         test_config_sqllog,   0 },\n#endif\n     { \"vfs_current_time_int64\",           vfsCurrentTimeInt64,   0 },\n#ifdef SQLITE_ENABLE_SNAPSHOT\n     { \"sqlite3_snapshot_get\", test_snapshot_get, 0 },\n     { \"sqlite3_snapshot_open\", test_snapshot_open, 0 },\n     { \"sqlite3_snapshot_free\", test_snapshot_free, 0 },\n     { \"sqlite3_snapshot_cmp\", test_snapshot_cmp, 0 },\n     { \"sqlite3_snapshot_recover\", test_snapshot_recover, 0 },\n     { \"sqlite3_snapshot_get_blob\", test_snapshot_get_blob, 0 },\n     { \"sqlite3_snapshot_open_blob\", test_snapshot_open_blob, 0 },\n     { \"sqlite3_snapshot_cmp_blob\", test_snapshot_cmp_blob, 0 },\n#endif\n     { \"sqlite3_delete_database\", test_delete_database,    0 },\n     { \"atomic_batch_write\",      test_atomic_batch_write, 0 },\n     { \"sqlite3_mmap_warm\",       test_mmap_warm,          0 },\n  };\n  static int bitmask_size = sizeof(Bitmask)*8;\n  static int longdouble_size = sizeof(LONGDOUBLE_TYPE);\n  int i;\n  extern int sqlite3_sync_count, sqlite3_fullsync_count;\n  extern int sqlite3_opentemp_count;\n  extern int sqlite3_like_count;\n  extern int sqlite3_xferopt_count;\n  extern int sqlite3_pager_readdb_count;\n  extern int sqlite3_pager_writedb_count;\n  extern int sqlite3_pager_writej_count;\n#if SQLITE_OS_WIN\n  extern LONG volatile sqlite3_os_type;\n#endif\n#ifdef SQLITE_DEBUG\n  extern int sqlite3WhereTrace;\n  extern int sqlite3OSTrace;\n  extern int sqlite3WalTrace;\n#endif\n#ifdef SQLITE_TEST\n#ifdef SQLITE_ENABLE_FTS3\n  extern int sqlite3_fts3_enable_parentheses;\n#endif\n#endif\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n  Tcl_LinkVar(interp, \"sqlite_search_count\", \n      (char*)&sqlite3_search_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_found_count\", \n      (char*)&sqlite3_found_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_sort_count\", \n      (char*)&sqlite3_sort_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite3_max_blobsize\", \n      (char*)&sqlite3_max_blobsize, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_like_count\", \n      (char*)&sqlite3_like_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_interrupt_count\", \n      (char*)&sqlite3_interrupt_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_open_file_count\", \n      (char*)&sqlite3_open_file_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_current_time\", \n      (char*)&sqlite3_current_time, TCL_LINK_INT);\n#if SQLITE_OS_UNIX && defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE\n  Tcl_LinkVar(interp, \"sqlite_hostid_num\", \n      (char*)&sqlite3_hostid_num, TCL_LINK_INT);\n#endif\n  Tcl_LinkVar(interp, \"sqlite3_xferopt_count\",\n      (char*)&sqlite3_xferopt_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite3_pager_readdb_count\",\n      (char*)&sqlite3_pager_readdb_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite3_pager_writedb_count\",\n      (char*)&sqlite3_pager_writedb_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite3_pager_writej_count\",\n      (char*)&sqlite3_pager_writej_count, TCL_LINK_INT);\n#ifndef SQLITE_OMIT_UTF16\n  Tcl_LinkVar(interp, \"unaligned_string_counter\",\n      (char*)&unaligned_string_counter, TCL_LINK_INT);\n#endif\n#ifndef SQLITE_OMIT_UTF16\n  Tcl_LinkVar(interp, \"sqlite_last_needed_collation\",\n      (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY);\n#endif\n#if SQLITE_OS_WIN\n  Tcl_LinkVar(interp, \"sqlite_os_type\",\n      (char*)&sqlite3_os_type, TCL_LINK_LONG);\n#endif\n#ifdef SQLITE_TEST\n  {\n    static const char *query_plan = \"*** OBSOLETE VARIABLE ***\";\n    Tcl_LinkVar(interp, \"sqlite_query_plan\",\n       (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY);\n  }\n#endif\n#ifdef SQLITE_DEBUG\n  Tcl_LinkVar(interp, \"sqlite_where_trace\",\n      (char*)&sqlite3WhereTrace, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_os_trace\",\n      (char*)&sqlite3OSTrace, TCL_LINK_INT);\n#ifndef SQLITE_OMIT_WAL\n  Tcl_LinkVar(interp, \"sqlite_wal_trace\",\n      (char*)&sqlite3WalTrace, TCL_LINK_INT);\n#endif\n#endif\n#ifndef SQLITE_OMIT_DISKIO\n  Tcl_LinkVar(interp, \"sqlite_opentemp_count\",\n      (char*)&sqlite3_opentemp_count, TCL_LINK_INT);\n#endif\n  Tcl_LinkVar(interp, \"sqlite_static_bind_value\",\n      (char*)&sqlite_static_bind_value, TCL_LINK_STRING);\n  Tcl_LinkVar(interp, \"sqlite_static_bind_nbyte\",\n      (char*)&sqlite_static_bind_nbyte, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_temp_directory\",\n      (char*)&sqlite3_temp_directory, TCL_LINK_STRING);\n  Tcl_LinkVar(interp, \"sqlite_data_directory\",\n      (char*)&sqlite3_data_directory, TCL_LINK_STRING);\n  Tcl_LinkVar(interp, \"bitmask_size\",\n      (char*)&bitmask_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);\n  Tcl_LinkVar(interp, \"longdouble_size\",\n      (char*)&longdouble_size, TCL_LINK_INT|TCL_LINK_READ_ONLY);\n  Tcl_LinkVar(interp, \"sqlite_sync_count\",\n      (char*)&sqlite3_sync_count, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_fullsync_count\",\n      (char*)&sqlite3_fullsync_count, TCL_LINK_INT);\n#if defined(SQLITE_ENABLE_FTS3) && defined(SQLITE_TEST)\n  Tcl_LinkVar(interp, \"sqlite_fts3_enable_parentheses\",\n      (char*)&sqlite3_fts3_enable_parentheses, TCL_LINK_INT);\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test2.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the pager.c module in SQLite.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <ctype.h>\n\nextern const char *sqlite3ErrName(int);\n\n/*\n** Page size and reserved size used for testing.\n*/\nstatic int test_pagesize = 1024;\n\n/*\n** Dummy page reinitializer\n*/\nstatic void pager_test_reiniter(DbPage *pNotUsed){\n  return;\n}\n\n/*\n** Usage:   pager_open FILENAME N-PAGE\n**\n** Open a new pager\n*/\nstatic int SQLITE_TCLAPI pager_open(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  u32 pageSize;\n  Pager *pPager;\n  int nPage;\n  int rc;\n  char zBuf[100];\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME N-PAGE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &nPage) ) return TCL_ERROR;\n  rc = sqlite3PagerOpen(sqlite3_vfs_find(0), &pPager, argv[1], 0, 0,\n      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB,\n      pager_test_reiniter);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3PagerSetCachesize(pPager, nPage);\n  pageSize = test_pagesize;\n  sqlite3PagerSetPagesize(pPager, &pageSize, -1);\n  sqlite3_snprintf(sizeof(zBuf),zBuf,\"%p\",pPager);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_close ID\n**\n** Close the given pager.\n*/\nstatic int SQLITE_TCLAPI pager_close(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerClose(pPager, 0);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_rollback ID\n**\n** Rollback changes\n*/\nstatic int SQLITE_TCLAPI pager_rollback(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerRollback(pPager);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_commit ID\n**\n** Commit all changes\n*/\nstatic int SQLITE_TCLAPI pager_commit(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerCommitPhaseOne(pPager, 0, 0);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  rc = sqlite3PagerCommitPhaseTwo(pPager);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_stmt_begin ID\n**\n** Start a new checkpoint.\n*/\nstatic int SQLITE_TCLAPI pager_stmt_begin(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerOpenSavepoint(pPager, 1);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_stmt_rollback ID\n**\n** Rollback changes to a checkpoint\n*/\nstatic int SQLITE_TCLAPI pager_stmt_rollback(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_ROLLBACK, 0);\n  sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_stmt_commit ID\n**\n** Commit changes to a checkpoint\n*/\nstatic int SQLITE_TCLAPI pager_stmt_commit(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerSavepoint(pPager, SAVEPOINT_RELEASE, 0);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_stats ID\n**\n** Return pager statistics.\n*/\nstatic int SQLITE_TCLAPI pager_stats(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int i, *a;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  a = sqlite3PagerStats(pPager);\n  for(i=0; i<9; i++){\n    static char *zName[] = {\n      \"ref\", \"page\", \"max\", \"size\", \"state\", \"err\",\n      \"hit\", \"miss\", \"ovfl\",\n    };\n    char zBuf[100];\n    Tcl_AppendElement(interp, zName[i]);\n    sqlite3_snprintf(sizeof(zBuf),zBuf,\"%d\",a[i]);\n    Tcl_AppendElement(interp, zBuf);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_pagecount ID\n**\n** Return the size of the database file.\n*/\nstatic int SQLITE_TCLAPI pager_pagecount(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  char zBuf[100];\n  int nPage;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  sqlite3PagerPagecount(pPager, &nPage);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", nPage);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   page_get ID PGNO\n**\n** Return a pointer to a page from the database.\n*/\nstatic int SQLITE_TCLAPI page_get(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  char zBuf[100];\n  DbPage *pPage = 0;\n  int pgno;\n  int rc;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID PGNO\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;\n  rc = sqlite3PagerSharedLock(pPager);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3PagerGet(pPager, pgno, &pPage, 0);\n  }\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3_snprintf(sizeof(zBuf),zBuf,\"%p\",pPage);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   page_lookup ID PGNO\n**\n** Return a pointer to a page if the page is already in cache.\n** If not in cache, return an empty string.\n*/\nstatic int SQLITE_TCLAPI page_lookup(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  char zBuf[100];\n  DbPage *pPage;\n  int pgno;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID PGNO\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;\n  pPage = sqlite3PagerLookup(pPager, pgno);\n  if( pPage ){\n    sqlite3_snprintf(sizeof(zBuf),zBuf,\"%p\",pPage);\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   pager_truncate ID PGNO\n*/\nstatic int SQLITE_TCLAPI pager_truncate(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Pager *pPager;\n  int pgno;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID PGNO\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPager = sqlite3TestTextToPtr(argv[1]);\n  if( Tcl_GetInt(interp, argv[2], &pgno) ) return TCL_ERROR;\n  sqlite3PagerTruncateImage(pPager, pgno);\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   page_unref PAGE\n**\n** Drop a pointer to a page.\n*/\nstatic int SQLITE_TCLAPI page_unref(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  DbPage *pPage;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" PAGE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]);\n  sqlite3PagerUnref(pPage);\n  return TCL_OK;\n}\n\n/*\n** Usage:   page_read PAGE\n**\n** Return the content of a page\n*/\nstatic int SQLITE_TCLAPI page_read(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  char zBuf[100];\n  DbPage *pPage;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" PAGE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPage = sqlite3TestTextToPtr(argv[1]);\n  memcpy(zBuf, sqlite3PagerGetData(pPage), sizeof(zBuf));\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   page_number PAGE\n**\n** Return the page number for a page.\n*/\nstatic int SQLITE_TCLAPI page_number(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  char zBuf[100];\n  DbPage *pPage;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" PAGE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", sqlite3PagerPagenumber(pPage));\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   page_write PAGE DATA\n**\n** Write something into a page.\n*/\nstatic int SQLITE_TCLAPI page_write(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  DbPage *pPage;\n  char *pData;\n  int rc;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" PAGE DATA\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pPage = (DbPage *)sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3PagerWrite(pPage);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  pData = sqlite3PagerGetData(pPage);\n  strncpy(pData, argv[2], test_pagesize-1);\n  pData[test_pagesize-1] = 0;\n  return TCL_OK;\n}\n\n#ifndef SQLITE_OMIT_DISKIO\n/*\n** Usage:   fake_big_file  N  FILENAME\n**\n** Write a few bytes at the N megabyte point of FILENAME.  This will\n** create a large file.  If the file was a valid SQLite database, then\n** the next time the database is opened, SQLite will begin allocating\n** new pages after N.  If N is 2096 or bigger, this will test the\n** ability of SQLite to write to large files.\n*/\nstatic int SQLITE_TCLAPI fake_big_file(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  sqlite3_vfs *pVfs;\n  sqlite3_file *fd = 0;\n  int rc;\n  int n;\n  i64 offset;\n  char *zFile;\n  int nFile;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" N-MEGABYTES FILE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;\n\n  pVfs = sqlite3_vfs_find(0);\n  nFile = (int)strlen(argv[2]);\n  zFile = sqlite3_malloc( nFile+2 );\n  if( zFile==0 ) return TCL_ERROR;\n  memcpy(zFile, argv[2], nFile+1);\n  zFile[nFile+1] = 0;\n  rc = sqlite3OsOpenMalloc(pVfs, zFile, &fd, \n      (SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0\n  );\n  if( rc ){\n    Tcl_AppendResult(interp, \"open failed: \", sqlite3ErrName(rc), 0);\n    sqlite3_free(zFile);\n    return TCL_ERROR;\n  }\n  offset = n;\n  offset *= 1024*1024;\n  rc = sqlite3OsWrite(fd, \"Hello, World!\", 14, offset);\n  sqlite3OsCloseFree(fd);\n  sqlite3_free(zFile);\n  if( rc ){\n    Tcl_AppendResult(interp, \"write failed: \", sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n#endif\n\n\n/*\n** test_control_pending_byte  PENDING_BYTE\n**\n** Set the PENDING_BYTE using the sqlite3_test_control() interface.\n*/\nstatic int SQLITE_TCLAPI testPendingByte(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int pbyte;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n                     \" PENDING-BYTE\\\"\", (void*)0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[1], &pbyte) ) return TCL_ERROR;\n  rc = sqlite3_test_control(SQLITE_TESTCTRL_PENDING_BYTE, pbyte);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** The sqlite3FaultSim() callback:\n*/\nstatic Tcl_Interp *faultSimInterp = 0;\nstatic int faultSimScriptSize = 0;\nstatic char *faultSimScript;\nstatic int faultSimCallback(int x){\n  char zInt[30];\n  int i;\n  int isNeg;\n  int rc;\n  if( x==0 ){\n    memcpy(faultSimScript+faultSimScriptSize, \"0\", 2);\n  }else{\n    /* Convert x to text without using any sqlite3 routines */\n    if( x<0 ){\n      isNeg = 1;\n      x = -x;\n    }else{\n      isNeg = 0;\n    }\n    zInt[sizeof(zInt)-1] = 0;\n    for(i=sizeof(zInt)-2; i>0 && x>0; i--, x /= 10){\n      zInt[i] = (x%10) + '0';\n    }\n    if( isNeg ) zInt[i--] = '-';\n    memcpy(faultSimScript+faultSimScriptSize, zInt+i+1, sizeof(zInt)-i);\n  }\n  rc = Tcl_Eval(faultSimInterp, faultSimScript);\n  if( rc ){\n    fprintf(stderr, \"fault simulator script failed: [%s]\", faultSimScript);\n    rc = SQLITE_ERROR;\n  }else{\n    rc = atoi(Tcl_GetStringResult(faultSimInterp));\n  }\n  Tcl_ResetResult(faultSimInterp);\n  return rc;\n}\n\n/*\n** sqlite3_test_control_fault_install SCRIPT\n**\n** Arrange to invoke SCRIPT with the integer argument to sqlite3FaultSim()\n** appended, whenever sqlite3FaultSim() is called.  Or, if SCRIPT is the\n** empty string, cancel the sqlite3FaultSim() callback.\n*/\nstatic int SQLITE_TCLAPI faultInstallCmd(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  const char *zScript;\n  int nScript;\n  int rc;\n  if( argc!=1 && argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n                     \" SCRIPT\\\"\", (void*)0);\n  }\n  zScript = argc==2 ? argv[1] : \"\";\n  nScript = (int)strlen(zScript);\n  if( faultSimScript ){\n    free(faultSimScript);\n    faultSimScript = 0;\n  }\n  if( nScript==0 ){\n    rc = sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL, 0);\n  }else{\n    faultSimScript = malloc( nScript+100 );\n    if( faultSimScript==0 ){\n      Tcl_AppendResult(interp, \"out of memory\", (void*)0);\n      return SQLITE_ERROR;\n    }\n    memcpy(faultSimScript, zScript, nScript);\n    faultSimScript[nScript] = ' ';\n    faultSimScriptSize = nScript+1;\n    faultSimInterp = interp;\n    rc = sqlite3_test_control(SQLITE_TESTCTRL_FAULT_INSTALL, faultSimCallback);\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** sqlite3BitvecBuiltinTest SIZE PROGRAM\n**\n** Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control.\n** See comments on sqlite3BitvecBuiltinTest() for additional information.\n*/\nstatic int SQLITE_TCLAPI testBitvecBuiltinTest(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int sz, rc;\n  int nProg = 0;\n  int aProg[100];\n  const char *z;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n                     \" SIZE PROGRAM\\\"\", (void*)0);\n  }\n  if( Tcl_GetInt(interp, argv[1], &sz) ) return TCL_ERROR;\n  z = argv[2];\n  while( nProg<99 && *z ){\n    while( *z && !sqlite3Isdigit(*z) ){ z++; }\n    if( *z==0 ) break;\n    aProg[nProg++] = atoi(z);\n    while( sqlite3Isdigit(*z) ){ z++; }\n  }\n  aProg[nProg] = 0;\n  rc = sqlite3_test_control(SQLITE_TESTCTRL_BITVEC_TEST, sz, aProg);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}  \n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest2_Init(Tcl_Interp *interp){\n  extern int sqlite3_io_error_persist;\n  extern int sqlite3_io_error_pending;\n  extern int sqlite3_io_error_hit;\n  extern int sqlite3_io_error_hardhit;\n  extern int sqlite3_diskfull_pending;\n  extern int sqlite3_diskfull;\n  static struct {\n    char *zName;\n    Tcl_CmdProc *xProc;\n  } aCmd[] = {\n    { \"pager_open\",              (Tcl_CmdProc*)pager_open          },\n    { \"pager_close\",             (Tcl_CmdProc*)pager_close         },\n    { \"pager_commit\",            (Tcl_CmdProc*)pager_commit        },\n    { \"pager_rollback\",          (Tcl_CmdProc*)pager_rollback      },\n    { \"pager_stmt_begin\",        (Tcl_CmdProc*)pager_stmt_begin    },\n    { \"pager_stmt_commit\",       (Tcl_CmdProc*)pager_stmt_commit   },\n    { \"pager_stmt_rollback\",     (Tcl_CmdProc*)pager_stmt_rollback },\n    { \"pager_stats\",             (Tcl_CmdProc*)pager_stats         },\n    { \"pager_pagecount\",         (Tcl_CmdProc*)pager_pagecount     },\n    { \"page_get\",                (Tcl_CmdProc*)page_get            },\n    { \"page_lookup\",             (Tcl_CmdProc*)page_lookup         },\n    { \"page_unref\",              (Tcl_CmdProc*)page_unref          },\n    { \"page_read\",               (Tcl_CmdProc*)page_read           },\n    { \"page_write\",              (Tcl_CmdProc*)page_write          },\n    { \"page_number\",             (Tcl_CmdProc*)page_number         },\n    { \"pager_truncate\",          (Tcl_CmdProc*)pager_truncate      },\n#ifndef SQLITE_OMIT_DISKIO\n    { \"fake_big_file\",           (Tcl_CmdProc*)fake_big_file       },\n#endif\n    { \"sqlite3BitvecBuiltinTest\",(Tcl_CmdProc*)testBitvecBuiltinTest     },\n    { \"sqlite3_test_control_pending_byte\",  (Tcl_CmdProc*)testPendingByte },\n    { \"sqlite3_test_control_fault_install\", (Tcl_CmdProc*)faultInstallCmd },\n  };\n  int i;\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n  Tcl_LinkVar(interp, \"sqlite_io_error_pending\",\n     (char*)&sqlite3_io_error_pending, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_io_error_persist\",\n     (char*)&sqlite3_io_error_persist, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_io_error_hit\",\n     (char*)&sqlite3_io_error_hit, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_io_error_hardhit\",\n     (char*)&sqlite3_io_error_hardhit, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_diskfull_pending\",\n     (char*)&sqlite3_diskfull_pending, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"sqlite_diskfull\",\n     (char*)&sqlite3_diskfull, TCL_LINK_INT);\n#ifndef SQLITE_OMIT_WSD\n  Tcl_LinkVar(interp, \"sqlite_pending_byte\",\n     (char*)&sqlite3PendingByte, TCL_LINK_INT | TCL_LINK_READ_ONLY);\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test3.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the btree.c module in SQLite.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n#include \"sqliteInt.h\"\n#include \"btreeInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\nextern const char *sqlite3ErrName(int);\n\n/*\n** A bogus sqlite3 connection structure for use in the btree\n** tests.\n*/\nstatic sqlite3 sDb;\nstatic int nRefSqlite3 = 0;\n\n/*\n** Usage:   btree_open FILENAME NCACHE\n**\n** Open a new database\n*/\nstatic int SQLITE_TCLAPI btree_open(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int rc, nCache;\n  char zBuf[100];\n  int n;\n  char *zFilename;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" FILENAME NCACHE FLAGS\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &nCache) ) return TCL_ERROR;\n  nRefSqlite3++;\n  if( nRefSqlite3==1 ){\n    sDb.pVfs = sqlite3_vfs_find(0);\n    sDb.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);\n    sqlite3_mutex_enter(sDb.mutex);\n  }\n  n = (int)strlen(argv[1]);\n  zFilename = sqlite3_malloc( n+2 );\n  if( zFilename==0 ) return TCL_ERROR;\n  memcpy(zFilename, argv[1], n+1);\n  zFilename[n+1] = 0;\n  rc = sqlite3BtreeOpen(sDb.pVfs, zFilename, &sDb, &pBt, 0, \n     SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MAIN_DB);\n  sqlite3_free(zFilename);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3BtreeSetCacheSize(pBt, nCache);\n  sqlite3_snprintf(sizeof(zBuf), zBuf,\"%p\", pBt);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage:   btree_close ID\n**\n** Close the given database.\n*/\nstatic int SQLITE_TCLAPI btree_close(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n  rc = sqlite3BtreeClose(pBt);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  nRefSqlite3--;\n  if( nRefSqlite3==0 ){\n    sqlite3_mutex_leave(sDb.mutex);\n    sqlite3_mutex_free(sDb.mutex);\n    sDb.mutex = 0;\n    sDb.pVfs = 0;\n  }\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   btree_begin_transaction ID\n**\n** Start a new transaction\n*/\nstatic int SQLITE_TCLAPI btree_begin_transaction(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int rc;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n  sqlite3BtreeEnter(pBt);\n  rc = sqlite3BtreeBeginTrans(pBt, 1);\n  sqlite3BtreeLeave(pBt);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:   btree_pager_stats ID\n**\n** Returns pager statistics\n*/\nstatic int SQLITE_TCLAPI btree_pager_stats(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int i;\n  int *a;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n \n  /* Normally in this file, with a b-tree handle opened using the \n  ** [btree_open] command it is safe to call sqlite3BtreeEnter() directly.\n  ** But this function is sometimes called with a btree handle obtained\n  ** from an open SQLite connection (using [btree_from_db]). In this case\n  ** we need to obtain the mutex for the controlling SQLite handle before\n  ** it is safe to call sqlite3BtreeEnter().\n  */\n  sqlite3_mutex_enter(pBt->db->mutex);\n\n  sqlite3BtreeEnter(pBt);\n  a = sqlite3PagerStats(sqlite3BtreePager(pBt));\n  for(i=0; i<11; i++){\n    static char *zName[] = {\n      \"ref\", \"page\", \"max\", \"size\", \"state\", \"err\",\n      \"hit\", \"miss\", \"ovfl\", \"read\", \"write\"\n    };\n    char zBuf[100];\n    Tcl_AppendElement(interp, zName[i]);\n    sqlite3_snprintf(sizeof(zBuf), zBuf,\"%d\",a[i]);\n    Tcl_AppendElement(interp, zBuf);\n  }\n  sqlite3BtreeLeave(pBt);\n\n  /* Release the mutex on the SQLite handle that controls this b-tree */\n  sqlite3_mutex_leave(pBt->db->mutex);\n  return TCL_OK;\n}\n\n/*\n** Usage:   btree_cursor ID TABLENUM WRITEABLE\n**\n** Create a new cursor.  Return the ID for the cursor.\n*/\nstatic int SQLITE_TCLAPI btree_cursor(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int iTable;\n  BtCursor *pCur;\n  int rc = SQLITE_OK;\n  int wrFlag;\n  char zBuf[30];\n\n  if( argc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID TABLENUM WRITEABLE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n  if( Tcl_GetInt(interp, argv[2], &iTable) ) return TCL_ERROR;\n  if( Tcl_GetBoolean(interp, argv[3], &wrFlag) ) return TCL_ERROR;\n  if( wrFlag ) wrFlag = BTREE_WRCSR;\n  pCur = (BtCursor *)ckalloc(sqlite3BtreeCursorSize());\n  memset(pCur, 0, sqlite3BtreeCursorSize());\n  sqlite3_mutex_enter(pBt->db->mutex);\n  sqlite3BtreeEnter(pBt);\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  rc = sqlite3BtreeLockTable(pBt, iTable, !!wrFlag);\n#endif\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeCursor(pBt, iTable, wrFlag, 0, pCur);\n  }\n  sqlite3BtreeLeave(pBt);\n  sqlite3_mutex_leave(pBt->db->mutex);\n  if( rc ){\n    ckfree((char *)pCur);\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3_snprintf(sizeof(zBuf), zBuf,\"%p\", pCur);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Usage:   btree_close_cursor ID\n**\n** Close a cursor opened using btree_cursor.\n*/\nstatic int SQLITE_TCLAPI btree_close_cursor(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  BtCursor *pCur;\n  int rc;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pCur = sqlite3TestTextToPtr(argv[1]);\n#if SQLITE_THREADSAFE>0\n  {\n    Btree *pBt = pCur->pBtree;\n    sqlite3_mutex_enter(pBt->db->mutex);\n    sqlite3BtreeEnter(pBt);\n    rc = sqlite3BtreeCloseCursor(pCur);\n    sqlite3BtreeLeave(pBt);\n    sqlite3_mutex_leave(pBt->db->mutex);\n  }\n#else\n  rc = sqlite3BtreeCloseCursor(pCur);\n#endif\n  ckfree((char *)pCur);\n  if( rc ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Usage:   btree_next ID\n**\n** Move the cursor to the next entry in the table.  Return 0 on success\n** or 1 if the cursor was already on the last entry in the table or if\n** the table is empty.\n*/\nstatic int SQLITE_TCLAPI btree_next(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  BtCursor *pCur;\n  int rc;\n  int res = 0;\n  char zBuf[100];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pCur = sqlite3TestTextToPtr(argv[1]);\n  sqlite3BtreeEnter(pCur->pBtree);\n  rc = sqlite3BtreeNext(pCur, 0);\n  if( rc==SQLITE_DONE ){\n    res = 1;\n    rc = SQLITE_OK;\n  }\n  sqlite3BtreeLeave(pCur->pBtree);\n  if( rc ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3_snprintf(sizeof(zBuf),zBuf,\"%d\",res);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Usage:   btree_first ID\n**\n** Move the cursor to the first entry in the table.  Return 0 if the\n** cursor was left point to something and 1 if the table is empty.\n*/\nstatic int SQLITE_TCLAPI btree_first(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  BtCursor *pCur;\n  int rc;\n  int res = 0;\n  char zBuf[100];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pCur = sqlite3TestTextToPtr(argv[1]);\n  sqlite3BtreeEnter(pCur->pBtree);\n  rc = sqlite3BtreeFirst(pCur, &res);\n  sqlite3BtreeLeave(pCur->pBtree);\n  if( rc ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  sqlite3_snprintf(sizeof(zBuf),zBuf,\"%d\",res);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Usage:   btree_eof ID\n**\n** Return TRUE if the given cursor is not pointing at a valid entry.\n** Return FALSE if the cursor does point to a valid entry.\n*/\nstatic int SQLITE_TCLAPI btree_eof(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  BtCursor *pCur;\n  int rc;\n  char zBuf[50];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pCur = sqlite3TestTextToPtr(argv[1]);\n  sqlite3BtreeEnter(pCur->pBtree);\n  rc = sqlite3BtreeEof(pCur);\n  sqlite3BtreeLeave(pCur->pBtree);\n  sqlite3_snprintf(sizeof(zBuf),zBuf, \"%d\", rc);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Usage:   btree_payload_size ID\n**\n** Return the number of bytes of payload\n*/\nstatic int SQLITE_TCLAPI btree_payload_size(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  BtCursor *pCur;\n  u32 n;\n  char zBuf[50];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pCur = sqlite3TestTextToPtr(argv[1]);\n  sqlite3BtreeEnter(pCur->pBtree);\n  n = sqlite3BtreePayloadSize(pCur);\n  sqlite3BtreeLeave(pCur->pBtree);\n  sqlite3_snprintf(sizeof(zBuf),zBuf, \"%u\", n);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return SQLITE_OK;\n}\n\n/*\n** usage:   varint_test  START  MULTIPLIER  COUNT  INCREMENT\n**\n** This command tests the putVarint() and getVarint()\n** routines, both for accuracy and for speed.\n**\n** An integer is written using putVarint() and read back with\n** getVarint() and varified to be unchanged.  This repeats COUNT\n** times.  The first integer is START*MULTIPLIER.  Each iteration\n** increases the integer by INCREMENT.\n**\n** This command returns nothing if it works.  It returns an error message\n** if something goes wrong.\n*/\nstatic int SQLITE_TCLAPI btree_varint_test(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  u32 start, mult, count, incr;\n  u64 in, out;\n  int n1, n2, i, j;\n  unsigned char zBuf[100];\n  if( argc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" START MULTIPLIER COUNT INCREMENT\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[1], (int*)&start) ) return TCL_ERROR;\n  if( Tcl_GetInt(interp, argv[2], (int*)&mult) ) return TCL_ERROR;\n  if( Tcl_GetInt(interp, argv[3], (int*)&count) ) return TCL_ERROR;\n  if( Tcl_GetInt(interp, argv[4], (int*)&incr) ) return TCL_ERROR;\n  in = start;\n  in *= mult;\n  for(i=0; i<(int)count; i++){\n    char zErr[200];\n    n1 = putVarint(zBuf, in);\n    if( n1>9 || n1<1 ){\n      sqlite3_snprintf(sizeof(zErr), zErr,\n         \"putVarint returned %d - should be between 1 and 9\", n1);\n      Tcl_AppendResult(interp, zErr, 0);\n      return TCL_ERROR;\n    }\n    n2 = getVarint(zBuf, &out);\n    if( n1!=n2 ){\n      sqlite3_snprintf(sizeof(zErr), zErr,\n          \"putVarint returned %d and getVarint returned %d\", n1, n2);\n      Tcl_AppendResult(interp, zErr, 0);\n      return TCL_ERROR;\n    }\n    if( in!=out ){\n      sqlite3_snprintf(sizeof(zErr), zErr,\n          \"Wrote 0x%016llx and got back 0x%016llx\", in, out);\n      Tcl_AppendResult(interp, zErr, 0);\n      return TCL_ERROR;\n    }\n    if( (in & 0xffffffff)==in ){\n      u32 out32;\n      n2 = getVarint32(zBuf, out32);\n      out = out32;\n      if( n1!=n2 ){\n        sqlite3_snprintf(sizeof(zErr), zErr,\n          \"putVarint returned %d and GetVarint32 returned %d\", \n                  n1, n2);\n        Tcl_AppendResult(interp, zErr, 0);\n        return TCL_ERROR;\n      }\n      if( in!=out ){\n        sqlite3_snprintf(sizeof(zErr), zErr,\n          \"Wrote 0x%016llx and got back 0x%016llx from GetVarint32\",\n            in, out);\n        Tcl_AppendResult(interp, zErr, 0);\n        return TCL_ERROR;\n      }\n    }\n\n    /* In order to get realistic timings, run getVarint 19 more times.\n    ** This is because getVarint is called about 20 times more often\n    ** than putVarint.\n    */\n    for(j=0; j<19; j++){\n      getVarint(zBuf, &out);\n    }\n    in += incr;\n  }\n  return TCL_OK;\n}\n\n/*\n** usage:   btree_from_db  DB-HANDLE\n**\n** This command returns the btree handle for the main database associated\n** with the database-handle passed as the argument. Example usage:\n**\n** sqlite3 db test.db\n** set bt [btree_from_db db]\n*/\nstatic int SQLITE_TCLAPI btree_from_db(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  char zBuf[100];\n  Tcl_CmdInfo info;\n  sqlite3 *db;\n  Btree *pBt;\n  int iDb = 0;\n\n  if( argc!=2 && argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" DB-HANDLE ?N?\\\"\", 0);\n    return TCL_ERROR;\n  }\n\n  if( 1!=Tcl_GetCommandInfo(interp, argv[1], &info) ){\n    Tcl_AppendResult(interp, \"No such db-handle: \\\"\", argv[1], \"\\\"\", 0);\n    return TCL_ERROR;\n  }\n  if( argc==3 ){\n    iDb = atoi(argv[2]);\n  }\n\n  db = *((sqlite3 **)info.objClientData);\n  assert( db );\n\n  pBt = db->aDb[iDb].pBt;\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%p\", pBt);\n  Tcl_SetResult(interp, zBuf, TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** Usage:   btree_ismemdb ID\n**\n** Return true if the B-Tree is currently stored entirely in memory.\n*/\nstatic int SQLITE_TCLAPI btree_ismemdb(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  Btree *pBt;\n  int res;\n  sqlite3_file *pFile;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n  sqlite3_mutex_enter(pBt->db->mutex);\n  sqlite3BtreeEnter(pBt);\n  pFile = sqlite3PagerFile(sqlite3BtreePager(pBt));\n  res = (pFile->pMethods==0);\n  sqlite3BtreeLeave(pBt);\n  sqlite3_mutex_leave(pBt->db->mutex);\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(res));\n  return SQLITE_OK;\n}\n\n/*\n** usage:   btree_set_cache_size ID NCACHE\n**\n** Set the size of the cache used by btree $ID.\n*/\nstatic int SQLITE_TCLAPI btree_set_cache_size(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int nCache;\n  Btree *pBt;\n  \n  if( argc!=3 ){\n    Tcl_AppendResult(\n        interp, \"wrong # args: should be \\\"\", argv[0], \" BT NCACHE\\\"\", 0);\n    return TCL_ERROR;\n  }\n  pBt = sqlite3TestTextToPtr(argv[1]);\n  if( Tcl_GetInt(interp, argv[2], &nCache) ) return TCL_ERROR;\n\n  sqlite3_mutex_enter(pBt->db->mutex);\n  sqlite3BtreeEnter(pBt);\n  sqlite3BtreeSetCacheSize(pBt, nCache);\n  sqlite3BtreeLeave(pBt);\n  sqlite3_mutex_leave(pBt->db->mutex);\n  return TCL_OK;\n}      \n\n/*\n** usage:   btree_insert CSR ?KEY? VALUE\n**\n** Set the size of the cache used by btree $ID.\n*/\nstatic int SQLITE_TCLAPI btree_insert(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *const objv[]\n){\n  BtCursor *pCur;\n  int rc;\n  BtreePayload x;\n\n  if( objc!=4 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-intkey? CSR KEY VALUE\");\n    return TCL_ERROR;\n  }\n\n  memset(&x, 0, sizeof(x));\n  if( objc==4 ){\n    if( Tcl_GetIntFromObj(interp, objv[2], &rc) ) return TCL_ERROR;\n    x.nKey = rc;\n    x.pData = (void*)Tcl_GetByteArrayFromObj(objv[3], &x.nData);\n  }else{\n    x.pKey = (void*)Tcl_GetByteArrayFromObj(objv[2], &rc);\n    x.nKey = rc;\n  }\n  pCur = (BtCursor*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n\n  sqlite3_mutex_enter(pCur->pBtree->db->mutex);\n  sqlite3BtreeEnter(pCur->pBtree);\n  rc = sqlite3BtreeInsert(pCur, &x, 0, 0);\n  sqlite3BtreeLeave(pCur->pBtree);\n  sqlite3_mutex_leave(pCur->pBtree->db->mutex);\n\n  Tcl_ResetResult(interp);\n  if( rc ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), 0);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest3_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_CmdProc *xProc;\n  } aCmd[] = {\n     { \"btree_open\",               (Tcl_CmdProc*)btree_open               },\n     { \"btree_close\",              (Tcl_CmdProc*)btree_close              },\n     { \"btree_begin_transaction\",  (Tcl_CmdProc*)btree_begin_transaction  },\n     { \"btree_pager_stats\",        (Tcl_CmdProc*)btree_pager_stats        },\n     { \"btree_cursor\",             (Tcl_CmdProc*)btree_cursor             },\n     { \"btree_close_cursor\",       (Tcl_CmdProc*)btree_close_cursor       },\n     { \"btree_next\",               (Tcl_CmdProc*)btree_next               },\n     { \"btree_eof\",                (Tcl_CmdProc*)btree_eof                },\n     { \"btree_payload_size\",       (Tcl_CmdProc*)btree_payload_size       },\n     { \"btree_first\",              (Tcl_CmdProc*)btree_first              },\n     { \"btree_varint_test\",        (Tcl_CmdProc*)btree_varint_test        },\n     { \"btree_from_db\",            (Tcl_CmdProc*)btree_from_db            },\n     { \"btree_ismemdb\",            (Tcl_CmdProc*)btree_ismemdb            },\n     { \"btree_set_cache_size\",     (Tcl_CmdProc*)btree_set_cache_size     }\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n\n  Tcl_CreateObjCommand(interp, \"btree_insert\", btree_insert, 0, 0);\n\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test4.c",
    "content": "/*\n** 2003 December 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the SQLite library in a multithreaded environment.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#if SQLITE_OS_UNIX && SQLITE_THREADSAFE\n#include <stdlib.h>\n#include <string.h>\n#include <pthread.h>\n#include <sched.h>\n#include <ctype.h>\n\nextern const char *sqlite3ErrName(int);\n\n/*\n** Each thread is controlled by an instance of the following\n** structure.\n*/\ntypedef struct Thread Thread;\nstruct Thread {\n  /* The first group of fields are writable by the master and read-only\n  ** to the thread. */\n  char *zFilename;       /* Name of database file */\n  void (*xOp)(Thread*);  /* next operation to do */\n  char *zArg;            /* argument usable by xOp */\n  int opnum;             /* Operation number */\n  int busy;              /* True if this thread is in use */\n\n  /* The next group of fields are writable by the thread but read-only to the\n  ** master. */\n  int completed;        /* Number of operations completed */\n  sqlite3 *db;           /* Open database */\n  sqlite3_stmt *pStmt;     /* Pending operation */\n  char *zErr;           /* operation error */\n  char *zStaticErr;     /* Static error message */\n  int rc;               /* operation return code */\n  int argc;             /* number of columns in result */\n  const char *argv[100];    /* result columns */\n  const char *colv[100];    /* result column names */\n};\n\n/*\n** There can be as many as 26 threads running at once.  Each is named\n** by a capital letter: A, B, C, ..., Y, Z.\n*/\n#define N_THREAD 26\nstatic Thread threadset[N_THREAD];\n\n\n/*\n** The main loop for a thread.  Threads use busy waiting. \n*/\nstatic void *thread_main(void *pArg){\n  Thread *p = (Thread*)pArg;\n  if( p->db ){\n    sqlite3_close(p->db);\n  }\n  sqlite3_open(p->zFilename, &p->db);\n  if( SQLITE_OK!=sqlite3_errcode(p->db) ){\n    p->zErr = strdup(sqlite3_errmsg(p->db));\n    sqlite3_close(p->db);\n    p->db = 0;\n  }\n  p->pStmt = 0;\n  p->completed = 1;\n  while( p->opnum<=p->completed ) sched_yield();\n  while( p->xOp ){\n    if( p->zErr && p->zErr!=p->zStaticErr ){\n      sqlite3_free(p->zErr);\n      p->zErr = 0;\n    }\n    (*p->xOp)(p);\n    p->completed++;\n    while( p->opnum<=p->completed ) sched_yield();\n  }\n  if( p->pStmt ){\n    sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n  }\n  if( p->db ){\n    sqlite3_close(p->db);\n    p->db = 0;\n  }\n  if( p->zErr && p->zErr!=p->zStaticErr ){\n    sqlite3_free(p->zErr);\n    p->zErr = 0;\n  }\n  p->completed++;\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup();\n#endif\n  return 0;\n}\n\n/*\n** Get a thread ID which is an upper case letter.  Return the index.\n** If the argument is not a valid thread ID put an error message in\n** the interpreter and return -1.\n*/\nstatic int parse_thread_id(Tcl_Interp *interp, const char *zArg){\n  if( zArg==0 || zArg[0]==0 || zArg[1]!=0 || !isupper((unsigned char)zArg[0]) ){\n    Tcl_AppendResult(interp, \"thread ID must be an upper case letter\", 0);\n    return -1;\n  }\n  return zArg[0] - 'A';\n}\n\n/*\n** Usage:    thread_create NAME  FILENAME\n**\n** NAME should be an upper case letter.  Start the thread running with\n** an open connection to the given database.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_create(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  pthread_t x;\n  int rc;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID FILENAME\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( threadset[i].busy ){\n    Tcl_AppendResult(interp, \"thread \", argv[1], \" is already running\", 0);\n    return TCL_ERROR;\n  }\n  threadset[i].busy = 1;\n  sqlite3_free(threadset[i].zFilename);\n  threadset[i].zFilename = sqlite3_mprintf(\"%s\", argv[2]);\n  threadset[i].opnum = 1;\n  threadset[i].completed = 0;\n  rc = pthread_create(&x, 0, thread_main, &threadset[i]);\n  if( rc ){\n    Tcl_AppendResult(interp, \"failed to create the thread\", 0);\n    sqlite3_free(threadset[i].zFilename);\n    threadset[i].busy = 0;\n    return TCL_ERROR;\n  }\n  pthread_detach(x);\n  return TCL_OK;\n}\n\n/*\n** Wait for a thread to reach its idle state.\n*/\nstatic void thread_wait(Thread *p){\n  while( p->opnum>p->completed ) sched_yield();\n}\n\n/*\n** Usage:  thread_wait ID\n**\n** Wait on thread ID to reach its idle state.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_wait(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  return TCL_OK;\n}\n\n/*\n** Stop a thread.\n*/\nstatic void stop_thread(Thread *p){\n  thread_wait(p);\n  p->xOp = 0;\n  p->opnum++;\n  thread_wait(p);\n  sqlite3_free(p->zArg);\n  p->zArg = 0;\n  sqlite3_free(p->zFilename);\n  p->zFilename = 0;\n  p->busy = 0;\n}\n\n/*\n** Usage:  thread_halt ID\n**\n** Cause a thread to shut itself down.  Wait for the shutdown to be\n** completed.  If ID is \"*\" then stop all threads.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_halt(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  if( argv[1][0]=='*' && argv[1][1]==0 ){\n    for(i=0; i<N_THREAD; i++){\n      if( threadset[i].busy ) stop_thread(&threadset[i]);\n    }\n  }else{\n    i = parse_thread_id(interp, argv[1]);\n    if( i<0 ) return TCL_ERROR;\n    if( !threadset[i].busy ){\n      Tcl_AppendResult(interp, \"no such thread\", 0);\n      return TCL_ERROR;\n    }\n    stop_thread(&threadset[i]);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_argc  ID\n**\n** Wait on the most recent thread_step to complete, then return the\n** number of columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_argc(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  char zBuf[100];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", threadset[i].argc);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_argv  ID   N\n**\n** Wait on the most recent thread_step to complete, then return the\n** value of the N-th columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_argv(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  int n;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID N\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;\n  thread_wait(&threadset[i]);\n  if( n<0 || n>=threadset[i].argc ){\n    Tcl_AppendResult(interp, \"column number out of range\", 0);\n    return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, threadset[i].argv[n], 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_colname  ID   N\n**\n** Wait on the most recent thread_step to complete, then return the\n** name of the N-th columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_colname(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  int n;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID N\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;\n  thread_wait(&threadset[i]);\n  if( n<0 || n>=threadset[i].argc ){\n    Tcl_AppendResult(interp, \"column number out of range\", 0);\n    return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, threadset[i].colv[n], 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_result  ID\n**\n** Wait on the most recent operation to complete, then return the\n** result code from that operation.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_result(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  const char *zName;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  zName = sqlite3ErrName(threadset[i].rc);\n  Tcl_AppendResult(interp, zName, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_error  ID\n**\n** Wait on the most recent operation to complete, then return the\n** error string.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_error(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  Tcl_AppendResult(interp, threadset[i].zErr, 0);\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to compile an SQL statement.\n*/\nstatic void do_compile(Thread *p){\n  if( p->db==0 ){\n    p->zErr = p->zStaticErr = \"no database is open\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  if( p->pStmt ){\n    sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n  }\n  p->rc = sqlite3_prepare(p->db, p->zArg, -1, &p->pStmt, 0);\n}\n\n/*\n** Usage: thread_compile ID SQL\n**\n** Compile a new virtual machine.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_compile(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID SQL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  threadset[i].xOp = do_compile;\n  sqlite3_free(threadset[i].zArg);\n  threadset[i].zArg = sqlite3_mprintf(\"%s\", argv[2]);\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to step the virtual machine.\n*/\nstatic void do_step(Thread *p){\n  int i;\n  if( p->pStmt==0 ){\n    p->zErr = p->zStaticErr = \"no virtual machine available\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  p->rc = sqlite3_step(p->pStmt);\n  if( p->rc==SQLITE_ROW ){\n    p->argc = sqlite3_column_count(p->pStmt);\n    for(i=0; i<sqlite3_data_count(p->pStmt); i++){\n      p->argv[i] = (char*)sqlite3_column_text(p->pStmt, i);\n    }\n    for(i=0; i<p->argc; i++){\n      p->colv[i] = sqlite3_column_name(p->pStmt, i);\n    }\n  }\n}\n\n/*\n** Usage: thread_step ID\n**\n** Advance the virtual machine by one step\n*/\nstatic int SQLITE_TCLAPI tcl_thread_step(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" IDL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  threadset[i].xOp = do_step;\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to finalize a virtual machine.\n*/\nstatic void do_finalize(Thread *p){\n  if( p->pStmt==0 ){\n    p->zErr = p->zStaticErr = \"no virtual machine available\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  p->rc = sqlite3_finalize(p->pStmt);\n  p->pStmt = 0;\n}\n\n/*\n** Usage: thread_finalize ID\n**\n** Finalize the virtual machine.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_finalize(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" IDL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  threadset[i].xOp = do_finalize;\n  sqlite3_free(threadset[i].zArg);\n  threadset[i].zArg = 0;\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_swap ID ID\n**\n** Interchange the sqlite* pointer between two threads.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_swap(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i, j;\n  sqlite3 *temp;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID1 ID2\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  j = parse_thread_id(interp, argv[2]);\n  if( j<0 ) return TCL_ERROR;\n  if( !threadset[j].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[j]);\n  temp = threadset[i].db;\n  threadset[i].db = threadset[j].db;\n  threadset[j].db = temp;\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_db_get ID\n**\n** Return the database connection pointer for the given thread.  Then\n** remove the pointer from the thread itself.  Afterwards, the thread\n** can be stopped and the connection can be used by the main thread.\n*/\nstatic int SQLITE_TCLAPI tcl_thread_db_get(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  char zBuf[100];\n  extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  sqlite3TestMakePointerStr(interp, zBuf, threadset[i].db);\n  threadset[i].db = 0;\n  Tcl_AppendResult(interp, zBuf, (char*)0);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_db_put ID DB\n**\n*/\nstatic int SQLITE_TCLAPI tcl_thread_db_put(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);\n  extern void *sqlite3TestTextToPtr(const char *);\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID DB\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  assert( !threadset[i].db );\n  threadset[i].db = (sqlite3*)sqlite3TestTextToPtr(argv[2]);\n  return TCL_OK;\n}\n\n/*\n** Usage: thread_stmt_get ID\n**\n** Return the database stmt pointer for the given thread.  Then\n** remove the pointer from the thread itself. \n*/\nstatic int SQLITE_TCLAPI tcl_thread_stmt_get(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  char zBuf[100];\n  extern int sqlite3TestMakePointerStr(Tcl_Interp*, char*, void*);\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_thread_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  thread_wait(&threadset[i]);\n  sqlite3TestMakePointerStr(interp, zBuf, threadset[i].pStmt);\n  threadset[i].pStmt = 0;\n  Tcl_AppendResult(interp, zBuf, (char*)0);\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest4_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_CmdProc *xProc;\n  } aCmd[] = {\n     { \"thread_create\",     (Tcl_CmdProc*)tcl_thread_create     },\n     { \"thread_wait\",       (Tcl_CmdProc*)tcl_thread_wait       },\n     { \"thread_halt\",       (Tcl_CmdProc*)tcl_thread_halt       },\n     { \"thread_argc\",       (Tcl_CmdProc*)tcl_thread_argc       },\n     { \"thread_argv\",       (Tcl_CmdProc*)tcl_thread_argv       },\n     { \"thread_colname\",    (Tcl_CmdProc*)tcl_thread_colname    },\n     { \"thread_result\",     (Tcl_CmdProc*)tcl_thread_result     },\n     { \"thread_error\",      (Tcl_CmdProc*)tcl_thread_error      },\n     { \"thread_compile\",    (Tcl_CmdProc*)tcl_thread_compile    },\n     { \"thread_step\",       (Tcl_CmdProc*)tcl_thread_step       },\n     { \"thread_finalize\",   (Tcl_CmdProc*)tcl_thread_finalize   },\n     { \"thread_swap\",       (Tcl_CmdProc*)tcl_thread_swap       },\n     { \"thread_db_get\",     (Tcl_CmdProc*)tcl_thread_db_get     },\n     { \"thread_db_put\",     (Tcl_CmdProc*)tcl_thread_db_put     },\n     { \"thread_stmt_get\",   (Tcl_CmdProc*)tcl_thread_stmt_get   },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n  return TCL_OK;\n}\n#else\nint Sqlitetest4_Init(Tcl_Interp *interp){ return TCL_OK; }\n#endif /* SQLITE_OS_UNIX */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test5.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the utf.c module in SQLite.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library. Specifically, the code in this file\n** is used for testing the SQLite routines for converting between\n** the various supported unicode encodings.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** The first argument is a TCL UTF-8 string. Return the byte array\n** object with the encoded representation of the string, including\n** the NULL terminator.\n*/\nstatic int SQLITE_TCLAPI binarize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int len;\n  char *bytes;\n  Tcl_Obj *pRet;\n  assert(objc==2);\n\n  bytes = Tcl_GetStringFromObj(objv[1], &len);\n  pRet = Tcl_NewByteArrayObj((u8*)bytes, len+1);\n  Tcl_SetObjResult(interp, pRet);\n  return TCL_OK;\n}\n\n/*\n** Usage: test_value_overhead <repeat-count> <do-calls>.\n**\n** This routine is used to test the overhead of calls to\n** sqlite3_value_text(), on a value that contains a UTF-8 string. The idea\n** is to figure out whether or not it is a problem to use sqlite3_value\n** structures with collation sequence functions.\n**\n** If <do-calls> is 0, then the calls to sqlite3_value_text() are not\n** actually made.\n*/\nstatic int SQLITE_TCLAPI test_value_overhead(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int do_calls;\n  int repeat_count;\n  int i;\n  Mem val;\n\n  if( objc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \" <repeat-count> <do-calls>\", 0);\n    return TCL_ERROR;\n  }\n\n  if( Tcl_GetIntFromObj(interp, objv[1], &repeat_count) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &do_calls) ) return TCL_ERROR;\n\n  val.flags = MEM_Str|MEM_Term|MEM_Static;\n  val.z = \"hello world\";\n  val.enc = SQLITE_UTF8;\n\n  for(i=0; i<repeat_count; i++){\n    if( do_calls ){\n      sqlite3_value_text(&val);\n    }\n  }\n\n  return TCL_OK;\n}\n\nstatic u8 name_to_enc(Tcl_Interp *interp, Tcl_Obj *pObj){\n  struct EncName {\n    char *zName;\n    u8 enc;\n  } encnames[] = {\n    { \"UTF8\", SQLITE_UTF8 },\n    { \"UTF16LE\", SQLITE_UTF16LE },\n    { \"UTF16BE\", SQLITE_UTF16BE },\n    { \"UTF16\", SQLITE_UTF16 },\n    { 0, 0 }\n  };\n  struct EncName *pEnc;\n  char *z = Tcl_GetString(pObj);\n  for(pEnc=&encnames[0]; pEnc->zName; pEnc++){\n    if( 0==sqlite3StrICmp(z, pEnc->zName) ){\n      break;\n    }\n  }\n  if( !pEnc->enc ){\n    Tcl_AppendResult(interp, \"No such encoding: \", z, 0);\n  }\n  if( pEnc->enc==SQLITE_UTF16 ){\n    return SQLITE_UTF16NATIVE;\n  }\n  return pEnc->enc;\n}\n\n/*\n** Usage:   test_translate <string/blob> <from enc> <to enc> ?<transient>?\n**\n*/\nstatic int SQLITE_TCLAPI test_translate(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  u8 enc_from;\n  u8 enc_to;\n  sqlite3_value *pVal;\n\n  char *z;\n  int len;\n  void (*xDel)(void *p) = SQLITE_STATIC;\n\n  if( objc!=4 && objc!=5 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\",\n        Tcl_GetStringFromObj(objv[0], 0), \n        \" <string/blob> <from enc> <to enc>\", 0\n    );\n    return TCL_ERROR;\n  }\n  if( objc==5 ){\n    xDel = sqlite3_free;\n  }\n\n  enc_from = name_to_enc(interp, objv[2]);\n  if( !enc_from ) return TCL_ERROR;\n  enc_to = name_to_enc(interp, objv[3]);\n  if( !enc_to ) return TCL_ERROR;\n\n  pVal = sqlite3ValueNew(0);\n\n  if( enc_from==SQLITE_UTF8 ){\n    z = Tcl_GetString(objv[1]);\n    if( objc==5 ){\n      z = sqlite3_mprintf(\"%s\", z);\n    }\n    sqlite3ValueSetStr(pVal, -1, z, enc_from, xDel);\n  }else{\n    z = (char*)Tcl_GetByteArrayFromObj(objv[1], &len);\n    if( objc==5 ){\n      char *zTmp = z;\n      z = sqlite3_malloc(len);\n      memcpy(z, zTmp, len);\n    }\n    sqlite3ValueSetStr(pVal, -1, z, enc_from, xDel);\n  }\n\n  z = (char *)sqlite3ValueText(pVal, enc_to);\n  len = sqlite3ValueBytes(pVal, enc_to) + (enc_to==SQLITE_UTF8?1:2);\n  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj((u8*)z, len));\n\n  sqlite3ValueFree(pVal);\n\n  return TCL_OK;\n}\n\n/*\n** Usage: translate_selftest\n**\n** Call sqlite3UtfSelfTest() to run the internal tests for unicode\n** translation. If there is a problem an assert() will fail.\n**/\nvoid sqlite3UtfSelfTest(void);\nstatic int SQLITE_TCLAPI test_translate_selftest(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3UtfSelfTest();\n#endif\n  return SQLITE_OK;\n}\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest5_Init(Tcl_Interp *interp){\n  static struct {\n    char *zName;\n    Tcl_ObjCmdProc *xProc;\n  } aCmd[] = {\n    { \"binarize\",                (Tcl_ObjCmdProc*)binarize },\n    { \"test_value_overhead\",     (Tcl_ObjCmdProc*)test_value_overhead },\n    { \"test_translate\",          (Tcl_ObjCmdProc*)test_translate     },\n    { \"translate_selftest\",      (Tcl_ObjCmdProc*)test_translate_selftest},\n  };\n  int i;\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test6.c",
    "content": "/*\n** 2004 May 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that modified the OS layer in order to simulate\n** the effect on the database file of an OS crash or power failure.  This\n** is used to test the ability of SQLite to recover from those situations.\n*/\n#if SQLITE_TEST          /* This file is used for testing only */\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n#ifndef SQLITE_OMIT_DISKIO  /* This file is a no-op if disk I/O is disabled */\n\n/* #define TRACE_CRASHTEST */\n\ntypedef struct CrashFile CrashFile;\ntypedef struct CrashGlobal CrashGlobal;\ntypedef struct WriteBuffer WriteBuffer;\n\n/*\n** Method:\n**\n**   This layer is implemented as a wrapper around the \"real\" \n**   sqlite3_file object for the host system. Each time data is \n**   written to the file object, instead of being written to the\n**   underlying file, the write operation is stored in an in-memory \n**   structure (type WriteBuffer). This structure is placed at the\n**   end of a global ordered list (the write-list).\n**\n**   When data is read from a file object, the requested region is\n**   first retrieved from the real file. The write-list is then \n**   traversed and data copied from any overlapping WriteBuffer \n**   structures to the output buffer. i.e. a read() operation following\n**   one or more write() operations works as expected, even if no\n**   data has actually been written out to the real file.\n**\n**   When a fsync() operation is performed, an operating system crash \n**   may be simulated, in which case exit(-1) is called (the call to \n**   xSync() never returns). Whether or not a crash is simulated,\n**   the data associated with a subset of the WriteBuffer structures \n**   stored in the write-list is written to the real underlying files \n**   and the entries removed from the write-list. If a crash is simulated,\n**   a subset of the buffers may be corrupted before the data is written.\n**\n**   The exact subset of the write-list written and/or corrupted is\n**   determined by the simulated device characteristics and sector-size.\n**\n** \"Normal\" mode:\n**\n**   Normal mode is used when the simulated device has none of the\n**   SQLITE_IOCAP_XXX flags set.\n**\n**   In normal mode, if the fsync() is not a simulated crash, the \n**   write-list is traversed from beginning to end. Each WriteBuffer\n**   structure associated with the file handle used to call xSync()\n**   is written to the real file and removed from the write-list.\n**\n**   If a crash is simulated, one of the following takes place for \n**   each WriteBuffer in the write-list, regardless of which \n**   file-handle it is associated with:\n**\n**     1. The buffer is correctly written to the file, just as if\n**        a crash were not being simulated.\n**\n**     2. Nothing is done.\n**\n**     3. Garbage data is written to all sectors of the file that \n**        overlap the region specified by the WriteBuffer. Or garbage\n**        data is written to some contiguous section within the \n**        overlapped sectors.\n**\n** Device Characteristic flag handling:\n**\n**   If the IOCAP_ATOMIC flag is set, then option (3) above is \n**   never selected.\n**\n**   If the IOCAP_ATOMIC512 flag is set, and the WriteBuffer represents\n**   an aligned write() of an integer number of 512 byte regions, then\n**   option (3) above is never selected. Instead, each 512 byte region\n**   is either correctly written or left completely untouched. Similar\n**   logic governs the behavior if any of the other ATOMICXXX flags\n**   is set.\n**\n**   If either the IOCAP_SAFEAPPEND or IOCAP_SEQUENTIAL flags are set\n**   and a crash is being simulated, then an entry of the write-list is\n**   selected at random. Everything in the list after the selected entry \n**   is discarded before processing begins.\n**\n**   If IOCAP_SEQUENTIAL is set and a crash is being simulated, option \n**   (1) is selected for all write-list entries except the last. If a \n**   crash is not being simulated, then all entries in the write-list\n**   that occur before at least one write() on the file-handle specified\n**   as part of the xSync() are written to their associated real files.\n**\n**   If IOCAP_SAFEAPPEND is set and the first byte written by the write()\n**   operation is one byte past the current end of the file, then option\n**   (1) is always selected.\n*/\n\n/*\n** Each write operation in the write-list is represented by an instance\n** of the following structure.\n**\n** If zBuf is 0, then this structure represents a call to xTruncate(), \n** not xWrite(). In that case, iOffset is the size that the file is\n** truncated to.\n*/\nstruct WriteBuffer {\n  i64 iOffset;                 /* Byte offset of the start of this write() */\n  int nBuf;                    /* Number of bytes written */\n  u8 *zBuf;                    /* Pointer to copy of written data */\n  CrashFile *pFile;            /* File this write() applies to */\n\n  WriteBuffer *pNext;          /* Next in CrashGlobal.pWriteList */\n};\n\nstruct CrashFile {\n  const sqlite3_io_methods *pMethod;   /* Must be first */\n  sqlite3_file *pRealFile;             /* Underlying \"real\" file handle */\n  char *zName;\n  int flags;                           /* Flags the file was opened with */\n\n  /* Cache of the entire file. This is used to speed up OsRead() and \n  ** OsFileSize() calls. Although both could be done by traversing the\n  ** write-list, in practice this is impractically slow.\n  */\n  u8 *zData;                           /* Buffer containing file contents */\n  int nData;                           /* Size of buffer allocated at zData */\n  i64 iSize;                           /* Size of file in bytes */\n};\n\nstruct CrashGlobal {\n  WriteBuffer *pWriteList;     /* Head of write-list */\n  WriteBuffer *pWriteListEnd;  /* End of write-list */\n\n  int iSectorSize;             /* Value of simulated sector size */\n  int iDeviceCharacteristics;  /* Value of simulated device characteristics */\n\n  int iCrash;                  /* Crash on the iCrash'th call to xSync() */\n  char zCrashFile[500];        /* Crash during an xSync() on this file */ \n};\n\nstatic CrashGlobal g = {0, 0, SQLITE_DEFAULT_SECTOR_SIZE, 0, 0};\n\n/*\n** Set this global variable to 1 to enable crash testing.\n*/\nstatic int sqlite3CrashTestEnable = 0;\n\nstatic void *crash_malloc(int nByte){\n  return (void *)Tcl_AttemptAlloc((size_t)nByte);\n}\nstatic void crash_free(void *p){\n  Tcl_Free(p);\n}\nstatic void *crash_realloc(void *p, int n){\n  return (void *)Tcl_AttemptRealloc(p, (size_t)n);\n}\n\n/*\n** Wrapper around the sqlite3OsWrite() function that avoids writing to the\n** 512 byte block begining at offset PENDING_BYTE.\n*/\nstatic int writeDbFile(CrashFile *p, u8 *z, i64 iAmt, i64 iOff){\n  int rc = SQLITE_OK;\n  int iSkip = 0;\n  if( (iAmt-iSkip)>0 ){\n    rc = sqlite3OsWrite(p->pRealFile, &z[iSkip], (int)(iAmt-iSkip), iOff+iSkip);\n  }\n  return rc;\n}\n\n/*\n** Flush the write-list as if xSync() had been called on file handle\n** pFile. If isCrash is true, simulate a crash.\n*/\nstatic int writeListSync(CrashFile *pFile, int isCrash){\n  int rc = SQLITE_OK;\n  int iDc = g.iDeviceCharacteristics;\n\n  WriteBuffer *pWrite;\n  WriteBuffer **ppPtr;\n\n  /* If this is not a crash simulation, set pFinal to point to the \n  ** last element of the write-list that is associated with file handle\n  ** pFile.\n  **\n  ** If this is a crash simulation, set pFinal to an arbitrarily selected\n  ** element of the write-list.\n  */\n  WriteBuffer *pFinal = 0;\n  if( !isCrash ){\n    for(pWrite=g.pWriteList; pWrite; pWrite=pWrite->pNext){\n      if( pWrite->pFile==pFile ){\n        pFinal = pWrite;\n      }\n    }\n  }else if( iDc&(SQLITE_IOCAP_SEQUENTIAL|SQLITE_IOCAP_SAFE_APPEND) ){\n    int nWrite = 0;\n    int iFinal;\n    for(pWrite=g.pWriteList; pWrite; pWrite=pWrite->pNext) nWrite++;\n    sqlite3_randomness(sizeof(int), &iFinal);\n    iFinal = ((iFinal<0)?-1*iFinal:iFinal)%nWrite;\n    for(pWrite=g.pWriteList; iFinal>0; pWrite=pWrite->pNext) iFinal--;\n    pFinal = pWrite;\n  }\n\n#ifdef TRACE_CRASHTEST\n  if( pFile ){\n    printf(\"Sync %s (is %s crash)\\n\", pFile->zName, (isCrash?\"a\":\"not a\"));\n  }\n#endif\n\n  ppPtr = &g.pWriteList;\n  for(pWrite=*ppPtr; rc==SQLITE_OK && pWrite; pWrite=*ppPtr){\n    sqlite3_file *pRealFile = pWrite->pFile->pRealFile;\n\n    /* (eAction==1)      -> write block out normally,\n    ** (eAction==2)      -> do nothing,\n    ** (eAction==3)      -> trash sectors.\n    */\n    int eAction = 0;\n    if( !isCrash ){\n      eAction = 2;\n      if( (pWrite->pFile==pFile || iDc&SQLITE_IOCAP_SEQUENTIAL) ){\n        eAction = 1;\n      }\n    }else{\n      char random;\n      sqlite3_randomness(1, &random);\n\n      /* Do not select option 3 (sector trashing) if the IOCAP_ATOMIC flag \n      ** is set or this is an OsTruncate(), not an Oswrite().\n      */\n      if( (iDc&SQLITE_IOCAP_ATOMIC) || (pWrite->zBuf==0) ){\n        random &= 0x01;\n      }\n\n      /* If IOCAP_SEQUENTIAL is set and this is not the final entry\n      ** in the truncated write-list, always select option 1 (write\n      ** out correctly).\n      */\n      if( (iDc&SQLITE_IOCAP_SEQUENTIAL && pWrite!=pFinal) ){\n        random = 0;\n      }\n\n      /* If IOCAP_SAFE_APPEND is set and this OsWrite() operation is\n      ** an append (first byte of the written region is 1 byte past the\n      ** current EOF), always select option 1 (write out correctly).\n      */\n      if( iDc&SQLITE_IOCAP_SAFE_APPEND && pWrite->zBuf ){\n        i64 iSize;\n        sqlite3OsFileSize(pRealFile, &iSize);\n        if( iSize==pWrite->iOffset ){\n          random = 0;\n        }\n      }\n\n      if( (random&0x06)==0x06 ){\n        eAction = 3;\n      }else{\n        eAction = ((random&0x01)?2:1);\n      }\n    }\n\n    switch( eAction ){\n      case 1: {               /* Write out correctly */\n        if( pWrite->zBuf ){\n          rc = writeDbFile(\n              pWrite->pFile, pWrite->zBuf, pWrite->nBuf, pWrite->iOffset\n          );\n        }else{\n          rc = sqlite3OsTruncate(pRealFile, pWrite->iOffset);\n        }\n        *ppPtr = pWrite->pNext;\n#ifdef TRACE_CRASHTEST\n        if( isCrash ){\n          printf(\"Writing %d bytes @ %d (%s)\\n\", \n            pWrite->nBuf, (int)pWrite->iOffset, pWrite->pFile->zName\n          );\n        }\n#endif\n        crash_free(pWrite);\n        break;\n      }\n      case 2: {               /* Do nothing */\n        ppPtr = &pWrite->pNext;\n#ifdef TRACE_CRASHTEST\n        if( isCrash ){\n          printf(\"Omiting %d bytes @ %d (%s)\\n\", \n            pWrite->nBuf, (int)pWrite->iOffset, pWrite->pFile->zName\n          );\n        }\n#endif\n        break;\n      }\n      case 3: {               /* Trash sectors */\n        u8 *zGarbage;\n        int iFirst = (int)(pWrite->iOffset/g.iSectorSize);\n        int iLast = (int)((pWrite->iOffset+pWrite->nBuf-1)/g.iSectorSize);\n\n        assert(pWrite->zBuf);\n\n#ifdef TRACE_CRASHTEST\n        printf(\"Trashing %d sectors (%d bytes) @ %lld (sector %d) (%s)\\n\", \n            1+iLast-iFirst, (1+iLast-iFirst)*g.iSectorSize,\n            pWrite->iOffset, iFirst, pWrite->pFile->zName\n        );\n#endif\n\n        zGarbage = crash_malloc(g.iSectorSize);\n        if( zGarbage ){\n          sqlite3_int64 i;\n          for(i=iFirst; rc==SQLITE_OK && i<=iLast; i++){\n            sqlite3_randomness(g.iSectorSize, zGarbage); \n            rc = writeDbFile(\n              pWrite->pFile, zGarbage, g.iSectorSize, i*g.iSectorSize\n            );\n          }\n          crash_free(zGarbage);\n        }else{\n          rc = SQLITE_NOMEM;\n        }\n\n        ppPtr = &pWrite->pNext;\n        break;\n      }\n\n      default:\n        assert(!\"Cannot happen\");\n    }\n\n    if( pWrite==pFinal ) break;\n  }\n\n  if( rc==SQLITE_OK && isCrash ){\n    exit(-1);\n  }\n\n  for(pWrite=g.pWriteList; pWrite && pWrite->pNext; pWrite=pWrite->pNext);\n  g.pWriteListEnd = pWrite;\n\n  return rc;\n}\n\n/*\n** Add an entry to the end of the write-list.\n*/\nstatic int writeListAppend(\n  sqlite3_file *pFile,\n  sqlite3_int64 iOffset,\n  const u8 *zBuf,\n  int nBuf\n){\n  WriteBuffer *pNew;\n\n  assert((zBuf && nBuf) || (!nBuf && !zBuf));\n\n  pNew = (WriteBuffer *)crash_malloc(sizeof(WriteBuffer) + nBuf);\n  if( pNew==0 ){\n    fprintf(stderr, \"out of memory in the crash simulator\\n\");\n  }\n  memset(pNew, 0, sizeof(WriteBuffer)+nBuf);\n  pNew->iOffset = iOffset;\n  pNew->nBuf = nBuf;\n  pNew->pFile = (CrashFile *)pFile;\n  if( zBuf ){\n    pNew->zBuf = (u8 *)&pNew[1];\n    memcpy(pNew->zBuf, zBuf, nBuf);\n  }\n\n  if( g.pWriteList ){\n    assert(g.pWriteListEnd);\n    g.pWriteListEnd->pNext = pNew;\n  }else{\n    g.pWriteList = pNew;\n  }\n  g.pWriteListEnd = pNew;\n  \n  return SQLITE_OK;\n}\n\n/*\n** Close a crash-file.\n*/\nstatic int cfClose(sqlite3_file *pFile){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  writeListSync(pCrash, 0);\n  sqlite3OsClose(pCrash->pRealFile);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from a crash-file.\n*/\nstatic int cfRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  int nCopy = (int)MIN((i64)iAmt, (pCrash->iSize - iOfst));\n\n  if( nCopy>0 ){\n    memcpy(zBuf, &pCrash->zData[iOfst], nCopy);\n  }\n\n  /* Check the file-size to see if this is a short-read */\n  if( nCopy<iAmt ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Write data to a crash-file.\n*/\nstatic int cfWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  if( iAmt+iOfst>pCrash->iSize ){\n    pCrash->iSize = (int)(iAmt+iOfst);\n  }\n  while( pCrash->iSize>pCrash->nData ){\n    u8 *zNew;\n    int nNew = (pCrash->nData*2) + 4096;\n    zNew = crash_realloc(pCrash->zData, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    memset(&zNew[pCrash->nData], 0, nNew-pCrash->nData);\n    pCrash->nData = nNew;\n    pCrash->zData = zNew;\n  }\n  memcpy(&pCrash->zData[iOfst], zBuf, iAmt);\n  return writeListAppend(pFile, iOfst, zBuf, iAmt);\n}\n\n/*\n** Truncate a crash-file.\n*/\nstatic int cfTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  assert(size>=0);\n  if( pCrash->iSize>size ){\n    pCrash->iSize = (int)size;\n  }\n  return writeListAppend(pFile, size, 0, 0);\n}\n\n/*\n** Sync a crash-file.\n*/\nstatic int cfSync(sqlite3_file *pFile, int flags){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  int isCrash = 0;\n\n  const char *zName = pCrash->zName;\n  const char *zCrashFile = g.zCrashFile;\n  int nName = (int)strlen(zName);\n  int nCrashFile = (int)strlen(zCrashFile);\n\n  if( nCrashFile>0 && zCrashFile[nCrashFile-1]=='*' ){\n    nCrashFile--;\n    if( nName>nCrashFile ) nName = nCrashFile;\n  }\n\n#ifdef TRACE_CRASHTEST\n  printf(\"cfSync(): nName = %d, nCrashFile = %d, zName = %s, zCrashFile = %s\\n\",\n         nName, nCrashFile, zName, zCrashFile);\n#endif\n\n  if( nName==nCrashFile && 0==memcmp(zName, zCrashFile, nName) ){\n#ifdef TRACE_CRASHTEST\n    printf(\"cfSync(): name matched, g.iCrash = %d\\n\", g.iCrash);\n#endif\n    if( (--g.iCrash)==0 ) isCrash = 1;\n  }\n\n  return writeListSync(pCrash, isCrash);\n}\n\n/*\n** Return the current file-size of the crash-file.\n*/\nstatic int cfFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  CrashFile *pCrash = (CrashFile *)pFile;\n  *pSize = (i64)pCrash->iSize;\n  return SQLITE_OK;\n}\n\n/*\n** Calls related to file-locks are passed on to the real file handle.\n*/\nstatic int cfLock(sqlite3_file *pFile, int eLock){\n  return sqlite3OsLock(((CrashFile *)pFile)->pRealFile, eLock);\n}\nstatic int cfUnlock(sqlite3_file *pFile, int eLock){\n  return sqlite3OsUnlock(((CrashFile *)pFile)->pRealFile, eLock);\n}\nstatic int cfCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  return sqlite3OsCheckReservedLock(((CrashFile *)pFile)->pRealFile, pResOut);\n}\nstatic int cfFileControl(sqlite3_file *pFile, int op, void *pArg){\n  if( op==SQLITE_FCNTL_SIZE_HINT ){\n    CrashFile *pCrash = (CrashFile *)pFile;\n    i64 nByte = *(i64 *)pArg;\n    if( nByte>pCrash->iSize ){\n      if( SQLITE_OK==writeListAppend(pFile, nByte, 0, 0) ){\n        pCrash->iSize = (int)nByte;\n      }\n    }\n    return SQLITE_OK;\n  }\n  return sqlite3OsFileControl(((CrashFile *)pFile)->pRealFile, op, pArg);\n}\n\n/*\n** The xSectorSize() and xDeviceCharacteristics() functions return\n** the global values configured by the [sqlite_crashparams] tcl\n*  interface.\n*/\nstatic int cfSectorSize(sqlite3_file *pFile){\n  return g.iSectorSize;\n}\nstatic int cfDeviceCharacteristics(sqlite3_file *pFile){\n  return g.iDeviceCharacteristics;\n}\n\n/*\n** Pass-throughs for WAL support.\n*/\nstatic int cfShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  return sqlite3OsShmLock(((CrashFile*)pFile)->pRealFile, ofst, n, flags);\n}\nstatic void cfShmBarrier(sqlite3_file *pFile){\n  sqlite3OsShmBarrier(((CrashFile*)pFile)->pRealFile);\n}\nstatic int cfShmUnmap(sqlite3_file *pFile, int delFlag){\n  return sqlite3OsShmUnmap(((CrashFile*)pFile)->pRealFile, delFlag);\n}\nstatic int cfShmMap(\n  sqlite3_file *pFile,            /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int sz,                         /* Size of regions */\n  int w,                          /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  return sqlite3OsShmMap(((CrashFile*)pFile)->pRealFile, iRegion, sz, w, pp);\n}\n\nstatic const sqlite3_io_methods CrashFileVtab = {\n  2,                            /* iVersion */\n  cfClose,                      /* xClose */\n  cfRead,                       /* xRead */\n  cfWrite,                      /* xWrite */\n  cfTruncate,                   /* xTruncate */\n  cfSync,                       /* xSync */\n  cfFileSize,                   /* xFileSize */\n  cfLock,                       /* xLock */\n  cfUnlock,                     /* xUnlock */\n  cfCheckReservedLock,          /* xCheckReservedLock */\n  cfFileControl,                /* xFileControl */\n  cfSectorSize,                 /* xSectorSize */\n  cfDeviceCharacteristics,      /* xDeviceCharacteristics */\n  cfShmMap,                     /* xShmMap */\n  cfShmLock,                    /* xShmLock */\n  cfShmBarrier,                 /* xShmBarrier */\n  cfShmUnmap                    /* xShmUnmap */\n};\n\n/*\n** Application data for the crash VFS\n*/\nstruct crashAppData {\n  sqlite3_vfs *pOrig;                   /* Wrapped vfs structure */\n};\n\n/*\n** Open a crash-file file handle.\n**\n** The caller will have allocated pVfs->szOsFile bytes of space\n** at pFile. This file uses this space for the CrashFile structure\n** and allocates space for the \"real\" file structure using \n** sqlite3_malloc(). The assumption here is (pVfs->szOsFile) is\n** equal or greater than sizeof(CrashFile).\n*/\nstatic int cfOpen(\n  sqlite3_vfs *pCfVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  int rc;\n  CrashFile *pWrapper = (CrashFile *)pFile;\n  sqlite3_file *pReal = (sqlite3_file*)&pWrapper[1];\n\n  memset(pWrapper, 0, sizeof(CrashFile));\n  rc = sqlite3OsOpen(pVfs, zName, pReal, flags, pOutFlags);\n\n  if( rc==SQLITE_OK ){\n    i64 iSize;\n    pWrapper->pMethod = &CrashFileVtab;\n    pWrapper->zName = (char *)zName;\n    pWrapper->pRealFile = pReal;\n    rc = sqlite3OsFileSize(pReal, &iSize);\n    pWrapper->iSize = (int)iSize;\n    pWrapper->flags = flags;\n  }\n  if( rc==SQLITE_OK ){\n    pWrapper->nData = (int)(4096 + pWrapper->iSize);\n    pWrapper->zData = crash_malloc(pWrapper->nData);\n    if( pWrapper->zData ){\n      /* os_unix.c contains an assert() that fails if the caller attempts\n      ** to read data from the 512-byte locking region of a file opened\n      ** with the SQLITE_OPEN_MAIN_DB flag. This region of a database file\n      ** never contains valid data anyhow. So avoid doing such a read here.\n      **\n      ** UPDATE: It also contains an assert() verifying that each call\n      ** to the xRead() method reads less than 128KB of data.\n      */\n      i64 iOff;\n\n      memset(pWrapper->zData, 0, pWrapper->nData);\n      for(iOff=0; iOff<pWrapper->iSize; iOff += 512){\n        int nRead = (int)(pWrapper->iSize - iOff);\n        if( nRead>512 ) nRead = 512;\n        rc = sqlite3OsRead(pReal, &pWrapper->zData[iOff], nRead, iOff);\n      }\n    }else{\n      rc = SQLITE_NOMEM;\n    }\n  }\n  if( rc!=SQLITE_OK && pWrapper->pMethod ){\n    sqlite3OsClose(pFile);\n  }\n  return rc;\n}\n\nstatic int cfDelete(sqlite3_vfs *pCfVfs, const char *zPath, int dirSync){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xDelete(pVfs, zPath, dirSync);\n}\nstatic int cfAccess(\n  sqlite3_vfs *pCfVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xAccess(pVfs, zPath, flags, pResOut);\n}\nstatic int cfFullPathname(\n  sqlite3_vfs *pCfVfs, \n  const char *zPath, \n  int nPathOut,\n  char *zPathOut\n){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xFullPathname(pVfs, zPath, nPathOut, zPathOut);\n}\nstatic void *cfDlOpen(sqlite3_vfs *pCfVfs, const char *zPath){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xDlOpen(pVfs, zPath);\n}\nstatic void cfDlError(sqlite3_vfs *pCfVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  pVfs->xDlError(pVfs, nByte, zErrMsg);\n}\nstatic void (*cfDlSym(sqlite3_vfs *pCfVfs, void *pH, const char *zSym))(void){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xDlSym(pVfs, pH, zSym);\n}\nstatic void cfDlClose(sqlite3_vfs *pCfVfs, void *pHandle){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  pVfs->xDlClose(pVfs, pHandle);\n}\nstatic int cfRandomness(sqlite3_vfs *pCfVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xRandomness(pVfs, nByte, zBufOut);\n}\nstatic int cfSleep(sqlite3_vfs *pCfVfs, int nMicro){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xSleep(pVfs, nMicro);\n}\nstatic int cfCurrentTime(sqlite3_vfs *pCfVfs, double *pTimeOut){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xCurrentTime(pVfs, pTimeOut);\n}\nstatic int cfGetLastError(sqlite3_vfs *pCfVfs, int n, char *z){\n  sqlite3_vfs *pVfs = (sqlite3_vfs *)pCfVfs->pAppData;\n  return pVfs->xGetLastError(pVfs, n, z);\n}\n\nstatic int processDevSymArgs(\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[],\n  int *piDeviceChar,\n  int *piSectorSize\n){\n  struct DeviceFlag {\n    char *zName;\n    int iValue;\n  } aFlag[] = {\n    { \"atomic\",              SQLITE_IOCAP_ATOMIC                },\n    { \"atomic512\",           SQLITE_IOCAP_ATOMIC512             },\n    { \"atomic1k\",            SQLITE_IOCAP_ATOMIC1K              },\n    { \"atomic2k\",            SQLITE_IOCAP_ATOMIC2K              },\n    { \"atomic4k\",            SQLITE_IOCAP_ATOMIC4K              },\n    { \"atomic8k\",            SQLITE_IOCAP_ATOMIC8K              },\n    { \"atomic16k\",           SQLITE_IOCAP_ATOMIC16K             },\n    { \"atomic32k\",           SQLITE_IOCAP_ATOMIC32K             },\n    { \"atomic64k\",           SQLITE_IOCAP_ATOMIC64K             },\n    { \"sequential\",          SQLITE_IOCAP_SEQUENTIAL            },\n    { \"safe_append\",         SQLITE_IOCAP_SAFE_APPEND           },\n    { \"powersafe_overwrite\", SQLITE_IOCAP_POWERSAFE_OVERWRITE   },\n    { \"batch-atomic\",        SQLITE_IOCAP_BATCH_ATOMIC          },\n    { 0, 0 }\n  };\n\n  int i;\n  int iDc = 0;\n  int iSectorSize = 0;\n  int setSectorsize = 0;\n  int setDeviceChar = 0;\n\n  for(i=0; i<objc; i+=2){\n    int nOpt;\n    char *zOpt = Tcl_GetStringFromObj(objv[i], &nOpt);\n\n    if( (nOpt>11 || nOpt<2 || strncmp(\"-sectorsize\", zOpt, nOpt)) \n     && (nOpt>16 || nOpt<2 || strncmp(\"-characteristics\", zOpt, nOpt))\n    ){\n      Tcl_AppendResult(interp, \n        \"Bad option: \\\"\", zOpt, \n        \"\\\" - must be \\\"-characteristics\\\" or \\\"-sectorsize\\\"\", 0\n      );\n      return TCL_ERROR;\n    }\n    if( i==objc-1 ){\n      Tcl_AppendResult(interp, \"Option requires an argument: \\\"\", zOpt, \"\\\"\",0);\n      return TCL_ERROR;\n    }\n\n    if( zOpt[1]=='s' ){\n      if( Tcl_GetIntFromObj(interp, objv[i+1], &iSectorSize) ){\n        return TCL_ERROR;\n      }\n      setSectorsize = 1;\n    }else{\n      int j;\n      Tcl_Obj **apObj;\n      int nObj;\n      if( Tcl_ListObjGetElements(interp, objv[i+1], &nObj, &apObj) ){\n        return TCL_ERROR;\n      }\n      for(j=0; j<nObj; j++){\n        int rc;\n        int iChoice;\n        Tcl_Obj *pFlag = Tcl_DuplicateObj(apObj[j]);\n        Tcl_IncrRefCount(pFlag);\n        Tcl_UtfToLower(Tcl_GetString(pFlag));\n \n        rc = Tcl_GetIndexFromObjStruct(\n            interp, pFlag, aFlag, sizeof(aFlag[0]), \"no such flag\", 0, &iChoice\n        );\n        Tcl_DecrRefCount(pFlag);\n        if( rc ){\n          return TCL_ERROR;\n        }\n\n        iDc |= aFlag[iChoice].iValue;\n      }\n      setDeviceChar = 1;\n    }\n  }\n\n  if( setDeviceChar ){\n    *piDeviceChar = iDc;\n  }\n  if( setSectorsize ){\n    *piSectorSize = iSectorSize;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   sqlite3_crash_now\n**\n** Simulate a crash immediately. This function does not return \n** (writeListSync() calls exit(-1)).\n*/\nstatic int SQLITE_TCLAPI crashNowCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  writeListSync(0, 1);\n  assert( 0 );\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   sqlite_crash_enable ENABLE ?DEFAULT?\n**\n** Parameter ENABLE must be a boolean value. If true, then the \"crash\"\n** vfs is added to the system. If false, it is removed.\n*/\nstatic int SQLITE_TCLAPI crashEnableCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int isEnable;\n  int isDefault = 0;\n  static sqlite3_vfs crashVfs = {\n    2,                  /* iVersion */\n    0,                  /* szOsFile */\n    0,                  /* mxPathname */\n    0,                  /* pNext */\n    \"crash\",            /* zName */\n    0,                  /* pAppData */\n  \n    cfOpen,               /* xOpen */\n    cfDelete,             /* xDelete */\n    cfAccess,             /* xAccess */\n    cfFullPathname,       /* xFullPathname */\n    cfDlOpen,             /* xDlOpen */\n    cfDlError,            /* xDlError */\n    cfDlSym,              /* xDlSym */\n    cfDlClose,            /* xDlClose */\n    cfRandomness,         /* xRandomness */\n    cfSleep,              /* xSleep */\n    cfCurrentTime,        /* xCurrentTime */\n    cfGetLastError,       /* xGetLastError */\n    0,                    /* xCurrentTimeInt64 */\n  };\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"ENABLE ?DEFAULT?\");\n    return TCL_ERROR;\n  }\n\n  if( Tcl_GetBooleanFromObj(interp, objv[1], &isEnable) ){\n    return TCL_ERROR;\n  }\n  if( objc==3 && Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){\n    return TCL_ERROR;\n  }\n\n  if( (isEnable && crashVfs.pAppData) || (!isEnable && !crashVfs.pAppData) ){\n    return TCL_OK;\n  }\n\n  if( crashVfs.pAppData==0 ){\n    sqlite3_vfs *pOriginalVfs = sqlite3_vfs_find(0);\n    crashVfs.mxPathname = pOriginalVfs->mxPathname;\n    crashVfs.pAppData = (void *)pOriginalVfs;\n    crashVfs.szOsFile = sizeof(CrashFile) + pOriginalVfs->szOsFile;\n    sqlite3_vfs_register(&crashVfs, isDefault);\n  }else{\n    crashVfs.pAppData = 0;\n    sqlite3_vfs_unregister(&crashVfs);\n  }\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd:   sqlite_crashparams ?OPTIONS? DELAY CRASHFILE\n**\n** This procedure implements a TCL command that enables crash testing\n** in testfixture.  Once enabled, crash testing cannot be disabled.\n**\n** Available options are \"-characteristics\" and \"-sectorsize\". Both require\n** an argument. For -sectorsize, this is the simulated sector size in\n** bytes. For -characteristics, the argument must be a list of io-capability\n** flags to simulate. Valid flags are \"atomic\", \"atomic512\", \"atomic1K\",\n** \"atomic2K\", \"atomic4K\", \"atomic8K\", \"atomic16K\", \"atomic32K\", \n** \"atomic64K\", \"sequential\" and \"safe_append\".\n**\n** Example:\n**\n**   sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1\n**\n*/\nstatic int SQLITE_TCLAPI crashParamsObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int iDelay;\n  const char *zCrashFile;\n  int nCrashFile, iDc, iSectorSize;\n\n  iDc = -1;\n  iSectorSize = -1;\n\n  if( objc<3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?OPTIONS? DELAY CRASHFILE\");\n    goto error;\n  }\n\n  zCrashFile = Tcl_GetStringFromObj(objv[objc-1], &nCrashFile);\n  if( nCrashFile>=sizeof(g.zCrashFile) ){\n    Tcl_AppendResult(interp, \"Filename is too long: \\\"\", zCrashFile, \"\\\"\", 0);\n    goto error;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[objc-2], &iDelay) ){\n    goto error;\n  }\n\n  if( processDevSymArgs(interp, objc-3, &objv[1], &iDc, &iSectorSize) ){\n    return TCL_ERROR;\n  }\n\n  if( iDc>=0 ){\n    g.iDeviceCharacteristics = iDc;\n  }\n  if( iSectorSize>=0 ){\n    g.iSectorSize = iSectorSize;\n  }\n\n  g.iCrash = iDelay;\n  memcpy(g.zCrashFile, zCrashFile, nCrashFile+1);\n  sqlite3CrashTestEnable = 1;\n  return TCL_OK;\n\nerror:\n  return TCL_ERROR;\n}\n\nstatic int SQLITE_TCLAPI devSymObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void devsym_register(int iDeviceChar, int iSectorSize);\n\n  int iDc = -1;\n  int iSectorSize = -1;\n\n  if( processDevSymArgs(interp, objc-1, &objv[1], &iDc, &iSectorSize) ){\n    return TCL_ERROR;\n  }\n  devsym_register(iDc, iSectorSize);\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_crash_on_write N\n*/\nstatic int SQLITE_TCLAPI writeCrashObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void devsym_crash_on_write(int);\n  int nWrite = 0;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NWRITE\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &nWrite) ){\n    return TCL_ERROR;\n  }\n\n  devsym_crash_on_write(nWrite);\n  return TCL_OK;\n}\n\n/*\n** tclcmd: unregister_devsim\n*/\nstatic int SQLITE_TCLAPI dsUnregisterObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void devsym_unregister(void);\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  devsym_unregister();\n  return TCL_OK;\n}\n\n/*\n** tclcmd: register_jt_vfs ?-default? PARENT-VFS\n*/\nstatic int SQLITE_TCLAPI jtObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int jt_register(char *, int);\n  char *zParent = 0;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-default? PARENT-VFS\");\n    return TCL_ERROR;\n  }\n  zParent = Tcl_GetString(objv[1]);\n  if( objc==3 ){\n    if( strcmp(zParent, \"-default\") ){\n      Tcl_AppendResult(interp, \n          \"bad option \\\"\", zParent, \"\\\": must be -default\", 0\n      );\n      return TCL_ERROR;\n    }\n    zParent = Tcl_GetString(objv[2]);\n  }\n\n  if( !(*zParent) ){\n    zParent = 0;\n  }\n  if( jt_register(zParent, objc==3) ){\n    Tcl_AppendResult(interp, \"Error in jt_register\", 0);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd: unregister_jt_vfs\n*/\nstatic int SQLITE_TCLAPI jtUnregisterObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void jt_unregister(void);\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  jt_unregister();\n  return TCL_OK;\n}\n\n#endif /* SQLITE_OMIT_DISKIO */\n\n/*\n** This procedure registers the TCL procedures defined in this file.\n*/\nint Sqlitetest6_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_DISKIO\n  Tcl_CreateObjCommand(interp, \"sqlite3_crash_enable\", crashEnableCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_crashparams\", crashParamsObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_crash_now\", crashNowCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_simulate_device\", devSymObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_crash_on_write\", writeCrashObjCmd,0,0);\n  Tcl_CreateObjCommand(interp, \"unregister_devsim\", dsUnregisterObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"register_jt_vfs\", jtObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"unregister_jt_vfs\", jtUnregisterObjCmd, 0, 0);\n#endif\n  return TCL_OK;\n}\n\n#endif /* SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test7.c",
    "content": "/*\n** 2006 January 09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the client/server version of the SQLite library.\n** Derived from test4.c.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n/*\n** This test only works on UNIX with a SQLITE_THREADSAFE build that includes\n** the SQLITE_SERVER option.\n*/\n#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE) && \\\n    SQLITE_OS_UNIX && SQLITE_THREADSAFE\n\n#include <stdlib.h>\n#include <string.h>\n#include <pthread.h>\n#include <sched.h>\n#include <ctype.h>\n\n/*\n** Interfaces defined in server.c\n*/\nint sqlite3_client_open(const char*, sqlite3**);\nint sqlite3_client_prepare(sqlite3*,const char*,int,\n                           sqlite3_stmt**,const char**);\nint sqlite3_client_step(sqlite3_stmt*);\nint sqlite3_client_reset(sqlite3_stmt*);\nint sqlite3_client_finalize(sqlite3_stmt*);\nint sqlite3_client_close(sqlite3*);\nint sqlite3_server_start(void);\nint sqlite3_server_stop(void);\nvoid sqlite3_server_start2(int *pnDecr);\n\n/*\n** Each thread is controlled by an instance of the following\n** structure.\n*/\ntypedef struct Thread Thread;\nstruct Thread {\n  /* The first group of fields are writable by the supervisor thread\n  ** and read-only to the client threads\n  */\n  char *zFilename;         /* Name of database file */\n  void (*xOp)(Thread*);    /* next operation to do */\n  char *zArg;              /* argument usable by xOp */\n  volatile int opnum;      /* Operation number */\n  volatile int busy;       /* True if this thread is in use */\n\n  /* The next group of fields are writable by the client threads \n  ** but read-only to the superviser thread.\n  */\n  volatile int completed;  /* Number of operations completed */\n  sqlite3 *db;             /* Open database */\n  sqlite3_stmt *pStmt;     /* Pending operation */\n  char *zErr;              /* operation error */\n  char *zStaticErr;        /* Static error message */\n  int rc;                  /* operation return code */\n  int argc;                /* number of columns in result */\n  const char *argv[100];   /* result columns */\n  const char *colv[100];   /* result column names */\n\n  /* Initialized to 1 by the supervisor thread when the client is \n  ** created, and then deemed read-only to the supervisor thread. \n  ** Is set to 0 by the server thread belonging to this client \n  ** just before it exits.  \n  */\n  int nServer;             /* Number of server threads running */\n};\n\n/*\n** There can be as many as 26 threads running at once.  Each is named\n** by a capital letter: A, B, C, ..., Y, Z.\n*/\n#define N_THREAD 26\nstatic Thread threadset[N_THREAD];\n\n/*\n** The main loop for a thread.  Threads use busy waiting. \n*/\nstatic void *client_main(void *pArg){\n  Thread *p = (Thread*)pArg;\n  if( p->db ){\n    sqlite3_client_close(p->db);\n  }\n  sqlite3_client_open(p->zFilename, &p->db);\n  if( SQLITE_OK!=sqlite3_errcode(p->db) ){\n    p->zErr = strdup(sqlite3_errmsg(p->db));\n    sqlite3_client_close(p->db);\n    p->db = 0;\n  }\n  p->pStmt = 0;\n  p->completed = 1;\n  while( p->opnum<=p->completed ) sched_yield();\n  while( p->xOp ){\n    if( p->zErr && p->zErr!=p->zStaticErr ){\n      sqlite3_free(p->zErr);\n      p->zErr = 0;\n    }\n    (*p->xOp)(p);\n    p->completed++;\n    while( p->opnum<=p->completed ) sched_yield();\n  }\n  if( p->pStmt ){\n    sqlite3_client_finalize(p->pStmt);\n    p->pStmt = 0;\n  }\n  if( p->db ){\n    sqlite3_client_close(p->db);\n    p->db = 0;\n  }\n  if( p->zErr && p->zErr!=p->zStaticErr ){\n    sqlite3_free(p->zErr);\n    p->zErr = 0;\n  }\n  p->completed++;\n#ifndef SQLITE_OMIT_DEPRECATED\n  sqlite3_thread_cleanup();\n#endif\n  return 0;\n}\n\n/*\n** Get a thread ID which is an upper case letter.  Return the index.\n** If the argument is not a valid thread ID put an error message in\n** the interpreter and return -1.\n*/\nstatic int parse_client_id(Tcl_Interp *interp, const char *zArg){\n  if( zArg==0 || zArg[0]==0 || zArg[1]!=0 || !isupper((unsigned char)zArg[0]) ){\n    Tcl_AppendResult(interp, \"thread ID must be an upper case letter\", 0);\n    return -1;\n  }\n  return zArg[0] - 'A';\n}\n\n/*\n** Usage:    client_create NAME  FILENAME\n**\n** NAME should be an upper case letter.  Start the thread running with\n** an open connection to the given database.\n*/\nstatic int SQLITE_TCLAPI tcl_client_create(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  pthread_t x;\n  int rc;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID FILENAME\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( threadset[i].busy ){\n    Tcl_AppendResult(interp, \"thread \", argv[1], \" is already running\", 0);\n    return TCL_ERROR;\n  }\n  threadset[i].busy = 1;\n  sqlite3_free(threadset[i].zFilename);\n  threadset[i].zFilename = sqlite3_mprintf(\"%s\", argv[2]);\n  threadset[i].opnum = 1;\n  threadset[i].completed = 0;\n  rc = pthread_create(&x, 0, client_main, &threadset[i]);\n  if( rc ){\n    Tcl_AppendResult(interp, \"failed to create the thread\", 0);\n    sqlite3_free(threadset[i].zFilename);\n    threadset[i].busy = 0;\n    return TCL_ERROR;\n  }\n  pthread_detach(x);\n  if( threadset[i].nServer==0 ){\n    threadset[i].nServer = 1;\n    sqlite3_server_start2(&threadset[i].nServer);\n  }\n  return TCL_OK;\n}\n\n/*\n** Wait for a thread to reach its idle state.\n*/\nstatic void client_wait(Thread *p){\n  while( p->opnum>p->completed ) sched_yield();\n}\n\n/*\n** Usage:  client_wait ID\n**\n** Wait on thread ID to reach its idle state.\n*/\nstatic int SQLITE_TCLAPI tcl_client_wait(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  return TCL_OK;\n}\n\n/*\n** Stop a thread.\n*/\nstatic void stop_thread(Thread *p){\n  client_wait(p);\n  p->xOp = 0;\n  p->opnum++;\n  client_wait(p);\n  sqlite3_free(p->zArg);\n  p->zArg = 0;\n  sqlite3_free(p->zFilename);\n  p->zFilename = 0;\n  p->busy = 0;\n}\n\n/*\n** Usage:  client_halt ID\n**\n** Cause a client thread to shut itself down.  Wait for the shutdown to be\n** completed.  If ID is \"*\" then stop all client threads.\n*/\nstatic int SQLITE_TCLAPI tcl_client_halt(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  if( argv[1][0]=='*' && argv[1][1]==0 ){\n    for(i=0; i<N_THREAD; i++){\n      if( threadset[i].busy ){\n        stop_thread(&threadset[i]);\n      }\n    }\n  }else{\n    i = parse_client_id(interp, argv[1]);\n    if( i<0 ) return TCL_ERROR;\n    if( !threadset[i].busy ){\n      Tcl_AppendResult(interp, \"no such thread\", 0);\n      return TCL_ERROR;\n    }\n    stop_thread(&threadset[i]);\n  }\n\n  /* If no client threads are still running, also stop the server */\n  for(i=0; i<N_THREAD && threadset[i].busy==0; i++){}\n  if( i>=N_THREAD ){\n    sqlite3_server_stop();\n    while( 1 ){\n      for(i=0; i<N_THREAD && threadset[i].nServer==0; i++);\n      if( i==N_THREAD ) break;\n      sched_yield();\n    }\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage: client_argc  ID\n**\n** Wait on the most recent client_step to complete, then return the\n** number of columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_client_argc(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  char zBuf[100];\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", threadset[i].argc);\n  Tcl_AppendResult(interp, zBuf, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: client_argv  ID   N\n**\n** Wait on the most recent client_step to complete, then return the\n** value of the N-th columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_client_argv(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  int n;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID N\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;\n  client_wait(&threadset[i]);\n  if( n<0 || n>=threadset[i].argc ){\n    Tcl_AppendResult(interp, \"column number out of range\", 0);\n    return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, threadset[i].argv[n], 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: client_colname  ID   N\n**\n** Wait on the most recent client_step to complete, then return the\n** name of the N-th columns in the result set.\n*/\nstatic int SQLITE_TCLAPI tcl_client_colname(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  int n;\n\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID N\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetInt(interp, argv[2], &n) ) return TCL_ERROR;\n  client_wait(&threadset[i]);\n  if( n<0 || n>=threadset[i].argc ){\n    Tcl_AppendResult(interp, \"column number out of range\", 0);\n    return TCL_ERROR;\n  }\n  Tcl_AppendResult(interp, threadset[i].colv[n], 0);\n  return TCL_OK;\n}\n\nextern const char *sqlite3ErrName(int);\n\n/*\n** Usage: client_result  ID\n**\n** Wait on the most recent operation to complete, then return the\n** result code from that operation.\n*/\nstatic int SQLITE_TCLAPI tcl_client_result(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  const char *zName;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  zName = sqlite3ErrName(threadset[i].rc);\n  Tcl_AppendResult(interp, zName, 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: client_error  ID\n**\n** Wait on the most recent operation to complete, then return the\n** error string.\n*/\nstatic int SQLITE_TCLAPI tcl_client_error(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  Tcl_AppendResult(interp, threadset[i].zErr, 0);\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to compile an SQL statement.\n*/\nstatic void do_compile(Thread *p){\n  if( p->db==0 ){\n    p->zErr = p->zStaticErr = \"no database is open\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  if( p->pStmt ){\n    sqlite3_client_finalize(p->pStmt);\n    p->pStmt = 0;\n  }\n  p->rc = sqlite3_client_prepare(p->db, p->zArg, -1, &p->pStmt, 0);\n}\n\n/*\n** Usage: client_compile ID SQL\n**\n** Compile a new virtual machine.\n*/\nstatic int SQLITE_TCLAPI tcl_client_compile(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID SQL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  threadset[i].xOp = do_compile;\n  sqlite3_free(threadset[i].zArg);\n  threadset[i].zArg = sqlite3_mprintf(\"%s\", argv[2]);\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to step the virtual machine.\n*/\nstatic void do_step(Thread *p){\n  int i;\n  if( p->pStmt==0 ){\n    p->zErr = p->zStaticErr = \"no virtual machine available\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  p->rc = sqlite3_client_step(p->pStmt);\n  if( p->rc==SQLITE_ROW ){\n    p->argc = sqlite3_column_count(p->pStmt);\n    for(i=0; i<sqlite3_data_count(p->pStmt); i++){\n      p->argv[i] = (char*)sqlite3_column_text(p->pStmt, i);\n    }\n    for(i=0; i<p->argc; i++){\n      p->colv[i] = sqlite3_column_name(p->pStmt, i);\n    }\n  }\n}\n\n/*\n** Usage: client_step ID\n**\n** Advance the virtual machine by one step\n*/\nstatic int SQLITE_TCLAPI tcl_client_step(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" IDL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  threadset[i].xOp = do_step;\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to finalize a virtual machine.\n*/\nstatic void do_finalize(Thread *p){\n  if( p->pStmt==0 ){\n    p->zErr = p->zStaticErr = \"no virtual machine available\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  p->rc = sqlite3_client_finalize(p->pStmt);\n  p->pStmt = 0;\n}\n\n/*\n** Usage: client_finalize ID\n**\n** Finalize the virtual machine.\n*/\nstatic int SQLITE_TCLAPI tcl_client_finalize(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" IDL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  threadset[i].xOp = do_finalize;\n  sqlite3_free(threadset[i].zArg);\n  threadset[i].zArg = 0;\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** This procedure runs in the thread to reset a virtual machine.\n*/\nstatic void do_reset(Thread *p){\n  if( p->pStmt==0 ){\n    p->zErr = p->zStaticErr = \"no virtual machine available\";\n    p->rc = SQLITE_ERROR;\n    return;\n  }\n  p->rc = sqlite3_client_reset(p->pStmt);\n  p->pStmt = 0;\n}\n\n/*\n** Usage: client_reset ID\n**\n** Finalize the virtual machine.\n*/\nstatic int SQLITE_TCLAPI tcl_client_reset(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i;\n  if( argc!=2 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" IDL\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  threadset[i].xOp = do_reset;\n  sqlite3_free(threadset[i].zArg);\n  threadset[i].zArg = 0;\n  threadset[i].opnum++;\n  return TCL_OK;\n}\n\n/*\n** Usage: client_swap ID ID\n**\n** Interchange the sqlite* pointer between two threads.\n*/\nstatic int SQLITE_TCLAPI tcl_client_swap(\n  void *NotUsed,\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int argc,              /* Number of arguments */\n  const char **argv      /* Text of each argument */\n){\n  int i, j;\n  sqlite3 *temp;\n  if( argc!=3 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", argv[0],\n       \" ID1 ID2\", 0);\n    return TCL_ERROR;\n  }\n  i = parse_client_id(interp, argv[1]);\n  if( i<0 ) return TCL_ERROR;\n  if( !threadset[i].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[i]);\n  j = parse_client_id(interp, argv[2]);\n  if( j<0 ) return TCL_ERROR;\n  if( !threadset[j].busy ){\n    Tcl_AppendResult(interp, \"no such thread\", 0);\n    return TCL_ERROR;\n  }\n  client_wait(&threadset[j]);\n  temp = threadset[i].db;\n  threadset[i].db = threadset[j].db;\n  threadset[j].db = temp;\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest7_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_CmdProc *xProc;\n  } aCmd[] = {\n     { \"client_create\",     (Tcl_CmdProc*)tcl_client_create     },\n     { \"client_wait\",       (Tcl_CmdProc*)tcl_client_wait       },\n     { \"client_halt\",       (Tcl_CmdProc*)tcl_client_halt       },\n     { \"client_argc\",       (Tcl_CmdProc*)tcl_client_argc       },\n     { \"client_argv\",       (Tcl_CmdProc*)tcl_client_argv       },\n     { \"client_colname\",    (Tcl_CmdProc*)tcl_client_colname    },\n     { \"client_result\",     (Tcl_CmdProc*)tcl_client_result     },\n     { \"client_error\",      (Tcl_CmdProc*)tcl_client_error      },\n     { \"client_compile\",    (Tcl_CmdProc*)tcl_client_compile    },\n     { \"client_step\",       (Tcl_CmdProc*)tcl_client_step       },\n     { \"client_reset\",      (Tcl_CmdProc*)tcl_client_reset      },\n     { \"client_finalize\",   (Tcl_CmdProc*)tcl_client_finalize   },\n     { \"client_swap\",       (Tcl_CmdProc*)tcl_client_swap       },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n  return TCL_OK;\n}\n#else\nint Sqlitetest7_Init(Tcl_Interp *interp){ return TCL_OK; }\n#endif /* SQLITE_OS_UNIX */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test8.c",
    "content": "/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the virtual table interfaces.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\ntypedef struct echo_vtab echo_vtab;\ntypedef struct echo_cursor echo_cursor;\n\n/*\n** The test module defined in this file uses four global Tcl variables to\n** commicate with test-scripts:\n**\n**     $::echo_module\n**     $::echo_module_sync_fail\n**     $::echo_module_begin_fail\n**     $::echo_module_cost\n**\n** The variable ::echo_module is a list. Each time one of the following\n** methods is called, one or more elements are appended to the list.\n** This is used for automated testing of virtual table modules.\n**\n** The ::echo_module_sync_fail variable is set by test scripts and read\n** by code in this file. If it is set to the name of a real table in the\n** the database, then all xSync operations on echo virtual tables that\n** use the named table as a backing store will fail.\n*/\n\n/*\n** Errors can be provoked within the following echo virtual table methods:\n**\n**   xBestIndex   xOpen     xFilter   xNext   \n**   xColumn      xRowid    xUpdate   xSync   \n**   xBegin       xRename\n**\n** This is done by setting the global tcl variable:\n**\n**   echo_module_fail($method,$tbl)\n**\n** where $method is set to the name of the virtual table method to fail\n** (i.e. \"xBestIndex\") and $tbl is the name of the table being echoed (not\n** the name of the virtual table, the name of the underlying real table).\n*/\n\n/* \n** An echo virtual-table object.\n**\n** echo.vtab.aIndex is an array of booleans. The nth entry is true if \n** the nth column of the real table is the left-most column of an index\n** (implicit or otherwise). In other words, if SQLite can optimize\n** a query like \"SELECT * FROM real_table WHERE col = ?\".\n**\n** Member variable aCol[] contains copies of the column names of the real\n** table.\n*/\nstruct echo_vtab {\n  sqlite3_vtab base;\n  Tcl_Interp *interp;     /* Tcl interpreter containing debug variables */\n  sqlite3 *db;            /* Database connection */\n\n  int isPattern;\n  int inTransaction;      /* True if within a transaction */\n  char *zThis;            /* Name of the echo table */\n  char *zTableName;       /* Name of the real table */\n  char *zLogName;         /* Name of the log table */\n  int nCol;               /* Number of columns in the real table */\n  int *aIndex;            /* Array of size nCol. True if column has an index */\n  char **aCol;            /* Array of size nCol. Column names */\n};\n\n/* An echo cursor object */\nstruct echo_cursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;\n};\n\nstatic int simulateVtabError(echo_vtab *p, const char *zMethod){\n  const char *zErr;\n  char zVarname[128];\n  zVarname[127] = '\\0';\n  sqlite3_snprintf(127, zVarname, \"echo_module_fail(%s,%s)\", zMethod, p->zTableName);\n  zErr = Tcl_GetVar(p->interp, zVarname, TCL_GLOBAL_ONLY);\n  if( zErr ){\n    p->base.zErrMsg = sqlite3_mprintf(\"echo-vtab-error: %s\", zErr);\n  }\n  return (zErr!=0);\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** Examples:\n**\n**     \"abc\"   becomes   abc\n**     'xyz'   becomes   xyz\n**     [pqr]   becomes   pqr\n**     `mno`   becomes   mno\n*/\nstatic void dequoteString(char *z){\n  int quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  switch( quote ){\n    case '\\'':  break;\n    case '\"':   break;\n    case '`':   break;                /* For MySQL compatibility */\n    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */\n    default:    return;\n  }\n  for(i=1, j=0; z[i]; i++){\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        z[j++] = 0;\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n}\n\n/*\n** Retrieve the column names for the table named zTab via database\n** connection db. SQLITE_OK is returned on success, or an sqlite error\n** code otherwise.\n**\n** If successful, the number of columns is written to *pnCol. *paCol is\n** set to point at sqlite3_malloc()'d space containing the array of\n** nCol column names. The caller is responsible for calling sqlite3_free\n** on *paCol.\n*/\nstatic int getColumnNames(\n  sqlite3 *db, \n  const char *zTab,\n  char ***paCol, \n  int *pnCol\n){\n  char **aCol = 0;\n  char *zSql;\n  sqlite3_stmt *pStmt = 0;\n  int rc = SQLITE_OK;\n  int nCol = 0;\n\n  /* Prepare the statement \"SELECT * FROM <tbl>\". The column names\n  ** of the result set of the compiled SELECT will be the same as\n  ** the column names of table <tbl>.\n  */\n  zSql = sqlite3_mprintf(\"SELECT * FROM %Q\", zTab);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n    goto out;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n\n  if( rc==SQLITE_OK ){\n    int ii;\n    int nBytes;\n    char *zSpace;\n    nCol = sqlite3_column_count(pStmt);\n\n    /* Figure out how much space to allocate for the array of column names \n    ** (including space for the strings themselves). Then allocate it.\n    */\n    nBytes = sizeof(char *) * nCol;\n    for(ii=0; ii<nCol; ii++){\n      const char *zName = sqlite3_column_name(pStmt, ii);\n      if( !zName ){\n        rc = SQLITE_NOMEM;\n        goto out;\n      }\n      nBytes += (int)strlen(zName)+1;\n    }\n    aCol = (char **)sqlite3MallocZero(nBytes);\n    if( !aCol ){\n      rc = SQLITE_NOMEM;\n      goto out;\n    }\n\n    /* Copy the column names into the allocated space and set up the\n    ** pointers in the aCol[] array.\n    */\n    zSpace = (char *)(&aCol[nCol]);\n    for(ii=0; ii<nCol; ii++){\n      aCol[ii] = zSpace;\n      sqlite3_snprintf(nBytes, zSpace, \"%s\", sqlite3_column_name(pStmt,ii));\n      zSpace += (int)strlen(zSpace) + 1;\n    }\n    assert( (zSpace-nBytes)==(char *)aCol );\n  }\n\n  *paCol = aCol;\n  *pnCol = nCol;\n\nout:\n  sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** Parameter zTab is the name of a table in database db with nCol \n** columns. This function allocates an array of integers nCol in \n** size and populates it according to any implicit or explicit \n** indices on table zTab.\n**\n** If successful, SQLITE_OK is returned and *paIndex set to point \n** at the allocated array. Otherwise, an error code is returned.\n**\n** See comments associated with the member variable aIndex above \n** \"struct echo_vtab\" for details of the contents of the array.\n*/\nstatic int getIndexArray(\n  sqlite3 *db,             /* Database connection */\n  const char *zTab,        /* Name of table in database db */\n  int nCol,\n  int **paIndex\n){\n  sqlite3_stmt *pStmt = 0;\n  int *aIndex = 0;\n  int rc;\n  char *zSql;\n\n  /* Allocate space for the index array */\n  aIndex = (int *)sqlite3MallocZero(sizeof(int) * nCol);\n  if( !aIndex ){\n    rc = SQLITE_NOMEM;\n    goto get_index_array_out;\n  }\n\n  /* Compile an sqlite pragma to loop through all indices on table zTab */\n  zSql = sqlite3_mprintf(\"PRAGMA index_list(%s)\", zTab);\n  if( !zSql ){\n    rc = SQLITE_NOMEM;\n    goto get_index_array_out;\n  }\n  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);\n  sqlite3_free(zSql);\n\n  /* For each index, figure out the left-most column and set the \n  ** corresponding entry in aIndex[] to 1.\n  */\n  while( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n    const char *zIdx = (const char *)sqlite3_column_text(pStmt, 1);\n    sqlite3_stmt *pStmt2 = 0;\n    if( zIdx==0 ) continue;\n    zSql = sqlite3_mprintf(\"PRAGMA index_info(%s)\", zIdx);\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n      goto get_index_array_out;\n    }\n    rc = sqlite3_prepare(db, zSql, -1, &pStmt2, 0);\n    sqlite3_free(zSql);\n    if( pStmt2 && sqlite3_step(pStmt2)==SQLITE_ROW ){\n      int cid = sqlite3_column_int(pStmt2, 1);\n      assert( cid>=0 && cid<nCol );\n      aIndex[cid] = 1;\n    }\n    if( pStmt2 ){\n      rc = sqlite3_finalize(pStmt2);\n    }\n    if( rc!=SQLITE_OK ){\n      goto get_index_array_out;\n    }\n  }\n\n\nget_index_array_out:\n  if( pStmt ){\n    int rc2 = sqlite3_finalize(pStmt);\n    if( rc==SQLITE_OK ){\n      rc = rc2;\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    sqlite3_free(aIndex);\n    aIndex = 0;\n  }\n  *paIndex = aIndex;\n  return rc;\n}\n\n/*\n** Global Tcl variable $echo_module is a list. This routine appends\n** the string element zArg to that list in interpreter interp.\n*/\nstatic void appendToEchoModule(Tcl_Interp *interp, const char *zArg){\n  int flags = (TCL_APPEND_VALUE | TCL_LIST_ELEMENT | TCL_GLOBAL_ONLY);\n  Tcl_SetVar(interp, \"echo_module\", (zArg?zArg:\"\"), flags);\n}\n\n/*\n** This function is called from within the echo-modules xCreate and\n** xConnect methods. The argc and argv arguments are copies of those \n** passed to the calling method. This function is responsible for\n** calling sqlite3_declare_vtab() to declare the schema of the virtual\n** table being created or connected.\n**\n** If the constructor was passed just one argument, i.e.:\n**\n**   CREATE TABLE t1 AS echo(t2);\n**\n** Then t2 is assumed to be the name of a *real* database table. The\n** schema of the virtual table is declared by passing a copy of the \n** CREATE TABLE statement for the real table to sqlite3_declare_vtab().\n** Hence, the virtual table should have exactly the same column names and \n** types as the real table.\n*/\nstatic int echoDeclareVtab(\n  echo_vtab *pVtab, \n  sqlite3 *db \n){\n  int rc = SQLITE_OK;\n\n  if( pVtab->zTableName ){\n    sqlite3_stmt *pStmt = 0;\n    rc = sqlite3_prepare(db, \n        \"SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?\",\n        -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_text(pStmt, 1, pVtab->zTableName, -1, 0);\n      if( sqlite3_step(pStmt)==SQLITE_ROW ){\n        int rc2;\n        const char *zCreateTable = (const char *)sqlite3_column_text(pStmt, 0);\n        rc = sqlite3_declare_vtab(db, zCreateTable);\n        rc2 = sqlite3_finalize(pStmt);\n        if( rc==SQLITE_OK ){\n          rc = rc2;\n        }\n      } else {\n        rc = sqlite3_finalize(pStmt);\n        if( rc==SQLITE_OK ){ \n          rc = SQLITE_ERROR;\n        }\n      }\n      if( rc==SQLITE_OK ){\n        rc = getColumnNames(db, pVtab->zTableName, &pVtab->aCol, &pVtab->nCol);\n      }\n      if( rc==SQLITE_OK ){\n        rc = getIndexArray(db, pVtab->zTableName, pVtab->nCol, &pVtab->aIndex);\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function frees all runtime structures associated with the virtual\n** table pVtab.\n*/\nstatic int echoDestructor(sqlite3_vtab *pVtab){\n  echo_vtab *p = (echo_vtab*)pVtab;\n  sqlite3_free(p->aIndex);\n  sqlite3_free(p->aCol);\n  sqlite3_free(p->zThis);\n  sqlite3_free(p->zTableName);\n  sqlite3_free(p->zLogName);\n  sqlite3_free(p);\n  return 0;\n}\n\ntypedef struct EchoModule EchoModule;\nstruct EchoModule {\n  Tcl_Interp *interp;\n};\n\n/*\n** This function is called to do the work of the xConnect() method -\n** to allocate the required in-memory structures for a newly connected\n** virtual table.\n*/\nstatic int echoConstructor(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc;\n  int i;\n  echo_vtab *pVtab;\n\n  /* Allocate the sqlite3_vtab/echo_vtab structure itself */\n  pVtab = sqlite3MallocZero( sizeof(*pVtab) );\n  if( !pVtab ){\n    return SQLITE_NOMEM;\n  }\n  pVtab->interp = ((EchoModule *)pAux)->interp;\n  pVtab->db = db;\n\n  /* Allocate echo_vtab.zThis */\n  pVtab->zThis = sqlite3_mprintf(\"%s\", argv[2]);\n  if( !pVtab->zThis ){\n    echoDestructor((sqlite3_vtab *)pVtab);\n    return SQLITE_NOMEM;\n  }\n\n  /* Allocate echo_vtab.zTableName */\n  if( argc>3 ){\n    pVtab->zTableName = sqlite3_mprintf(\"%s\", argv[3]);\n    dequoteString(pVtab->zTableName);\n    if( pVtab->zTableName && pVtab->zTableName[0]=='*' ){\n      char *z = sqlite3_mprintf(\"%s%s\", argv[2], &(pVtab->zTableName[1]));\n      sqlite3_free(pVtab->zTableName);\n      pVtab->zTableName = z;\n      pVtab->isPattern = 1;\n    }\n    if( !pVtab->zTableName ){\n      echoDestructor((sqlite3_vtab *)pVtab);\n      return SQLITE_NOMEM;\n    }\n  }\n\n  /* Log the arguments to this function to Tcl var ::echo_module */\n  for(i=0; i<argc; i++){\n    appendToEchoModule(pVtab->interp, argv[i]);\n  }\n\n  /* Invoke sqlite3_declare_vtab and set up other members of the echo_vtab\n  ** structure. If an error occurs, delete the sqlite3_vtab structure and\n  ** return an error code.\n  */\n  rc = echoDeclareVtab(pVtab, db);\n  if( rc!=SQLITE_OK ){\n    echoDestructor((sqlite3_vtab *)pVtab);\n    return rc;\n  }\n\n  /* Success. Set *ppVtab and return */\n  *ppVtab = &pVtab->base;\n  return SQLITE_OK;\n}\n\n/* \n** Echo virtual table module xCreate method.\n*/\nstatic int echoCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc = SQLITE_OK;\n  appendToEchoModule(((EchoModule *)pAux)->interp, \"xCreate\");\n  rc = echoConstructor(db, pAux, argc, argv, ppVtab, pzErr);\n\n  /* If there were two arguments passed to the module at the SQL level \n  ** (i.e. \"CREATE VIRTUAL TABLE tbl USING echo(arg1, arg2)\"), then \n  ** the second argument is used as a table name. Attempt to create\n  ** such a table with a single column, \"logmsg\". This table will\n  ** be used to log calls to the xUpdate method. It will be deleted\n  ** when the virtual table is DROPed.\n  **\n  ** Note: The main point of this is to test that we can drop tables\n  ** from within an xDestroy method call.\n  */\n  if( rc==SQLITE_OK && argc==5 ){\n    char *zSql;\n    echo_vtab *pVtab = *(echo_vtab **)ppVtab;\n    pVtab->zLogName = sqlite3_mprintf(\"%s\", argv[4]);\n    zSql = sqlite3_mprintf(\"CREATE TABLE %Q(logmsg)\", pVtab->zLogName);\n    rc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    if( rc!=SQLITE_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(db));\n    }\n  }\n\n  if( *ppVtab && rc!=SQLITE_OK ){\n    echoDestructor(*ppVtab);\n    *ppVtab = 0;\n  }\n\n  if( rc==SQLITE_OK ){\n    (*(echo_vtab**)ppVtab)->inTransaction = 1;\n  }\n\n  return rc;\n}\n\n/* \n** Echo virtual table module xConnect method.\n*/\nstatic int echoConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  appendToEchoModule(((EchoModule *)pAux)->interp, \"xConnect\");\n  return echoConstructor(db, pAux, argc, argv, ppVtab, pzErr);\n}\n\n/* \n** Echo virtual table module xDisconnect method.\n*/\nstatic int echoDisconnect(sqlite3_vtab *pVtab){\n  appendToEchoModule(((echo_vtab *)pVtab)->interp, \"xDisconnect\");\n  return echoDestructor(pVtab);\n}\n\n/* \n** Echo virtual table module xDestroy method.\n*/\nstatic int echoDestroy(sqlite3_vtab *pVtab){\n  int rc = SQLITE_OK;\n  echo_vtab *p = (echo_vtab *)pVtab;\n  appendToEchoModule(((echo_vtab *)pVtab)->interp, \"xDestroy\");\n\n  /* Drop the \"log\" table, if one exists (see echoCreate() for details) */\n  if( p && p->zLogName ){\n    char *zSql;\n    zSql = sqlite3_mprintf(\"DROP TABLE %Q\", p->zLogName);\n    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = echoDestructor(pVtab);\n  }\n  return rc;\n}\n\n/* \n** Echo virtual table module xOpen method.\n*/\nstatic int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  echo_cursor *pCur;\n  if( simulateVtabError((echo_vtab *)pVTab, \"xOpen\") ){\n    return SQLITE_ERROR;\n  }\n  pCur = sqlite3MallocZero(sizeof(echo_cursor));\n  *ppCursor = (sqlite3_vtab_cursor *)pCur;\n  return (pCur ? SQLITE_OK : SQLITE_NOMEM);\n}\n\n/* \n** Echo virtual table module xClose method.\n*/\nstatic int echoClose(sqlite3_vtab_cursor *cur){\n  int rc;\n  echo_cursor *pCur = (echo_cursor *)cur;\n  sqlite3_stmt *pStmt = pCur->pStmt;\n  pCur->pStmt = 0;\n  sqlite3_free(pCur);\n  rc = sqlite3_finalize(pStmt);\n  return rc;\n}\n\n/*\n** Return non-zero if the cursor does not currently point to a valid record\n** (i.e if the scan has finished), or zero otherwise.\n*/\nstatic int echoEof(sqlite3_vtab_cursor *cur){\n  return (((echo_cursor *)cur)->pStmt ? 0 : 1);\n}\n\n/* \n** Echo virtual table module xNext method.\n*/\nstatic int echoNext(sqlite3_vtab_cursor *cur){\n  int rc = SQLITE_OK;\n  echo_cursor *pCur = (echo_cursor *)cur;\n\n  if( simulateVtabError((echo_vtab *)(cur->pVtab), \"xNext\") ){\n    return SQLITE_ERROR;\n  }\n\n  if( pCur->pStmt ){\n    rc = sqlite3_step(pCur->pStmt);\n    if( rc==SQLITE_ROW ){\n      rc = SQLITE_OK;\n    }else{\n      rc = sqlite3_finalize(pCur->pStmt);\n      pCur->pStmt = 0;\n    }\n  }\n\n  return rc;\n}\n\n/* \n** Echo virtual table module xColumn method.\n*/\nstatic int echoColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  int iCol = i + 1;\n  sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt;\n\n  if( simulateVtabError((echo_vtab *)(cur->pVtab), \"xColumn\") ){\n    return SQLITE_ERROR;\n  }\n\n  if( !pStmt ){\n    sqlite3_result_null(ctx);\n  }else{\n    assert( sqlite3_data_count(pStmt)>iCol );\n    sqlite3_result_value(ctx, sqlite3_column_value(pStmt, iCol));\n  }\n  return SQLITE_OK;\n}\n\n/* \n** Echo virtual table module xRowid method.\n*/\nstatic int echoRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  sqlite3_stmt *pStmt = ((echo_cursor *)cur)->pStmt;\n\n  if( simulateVtabError((echo_vtab *)(cur->pVtab), \"xRowid\") ){\n    return SQLITE_ERROR;\n  }\n\n  *pRowid = sqlite3_column_int64(pStmt, 0);\n  return SQLITE_OK;\n}\n\n/*\n** Compute a simple hash of the null terminated string zString.\n**\n** This module uses only sqlite3_index_info.idxStr, not \n** sqlite3_index_info.idxNum. So to test idxNum, when idxStr is set\n** in echoBestIndex(), idxNum is set to the corresponding hash value.\n** In echoFilter(), code assert()s that the supplied idxNum value is\n** indeed the hash of the supplied idxStr.\n*/\nstatic int hashString(const char *zString){\n  u32 val = 0;\n  int ii;\n  for(ii=0; zString[ii]; ii++){\n    val = (val << 3) + (int)zString[ii];\n  }\n  return (int)(val&0x7fffffff);\n}\n\n/* \n** Echo virtual table module xFilter method.\n*/\nstatic int echoFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  int rc;\n  int i;\n\n  echo_cursor *pCur = (echo_cursor *)pVtabCursor;\n  echo_vtab *pVtab = (echo_vtab *)pVtabCursor->pVtab;\n  sqlite3 *db = pVtab->db;\n\n  if( simulateVtabError(pVtab, \"xFilter\") ){\n    return SQLITE_ERROR;\n  }\n\n  /* Check that idxNum matches idxStr */\n  assert( idxNum==hashString(idxStr) );\n\n  /* Log arguments to the ::echo_module Tcl variable */\n  appendToEchoModule(pVtab->interp, \"xFilter\");\n  appendToEchoModule(pVtab->interp, idxStr);\n  for(i=0; i<argc; i++){\n    appendToEchoModule(pVtab->interp, (const char*)sqlite3_value_text(argv[i]));\n  }\n\n  sqlite3_finalize(pCur->pStmt);\n  pCur->pStmt = 0;\n\n  /* Prepare the SQL statement created by echoBestIndex and bind the\n  ** runtime parameters passed to this function to it.\n  */\n  rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0);\n  assert( pCur->pStmt || rc!=SQLITE_OK );\n  for(i=0; rc==SQLITE_OK && i<argc; i++){\n    rc = sqlite3_bind_value(pCur->pStmt, i+1, argv[i]);\n  }\n\n  /* If everything was successful, advance to the first row of the scan */\n  if( rc==SQLITE_OK ){\n    rc = echoNext(pVtabCursor);\n  }\n\n  return rc;\n}\n\n\n/*\n** A helper function used by echoUpdate() and echoBestIndex() for\n** manipulating strings in concert with the sqlite3_mprintf() function.\n**\n** Parameter pzStr points to a pointer to a string allocated with\n** sqlite3_mprintf. The second parameter, zAppend, points to another\n** string. The two strings are concatenated together and *pzStr\n** set to point at the result. The initial buffer pointed to by *pzStr\n** is deallocated via sqlite3_free().\n**\n** If the third argument, doFree, is true, then sqlite3_free() is\n** also called to free the buffer pointed to by zAppend.\n*/\nstatic void string_concat(char **pzStr, char *zAppend, int doFree, int *pRc){\n  char *zIn = *pzStr;\n  if( !zAppend && doFree && *pRc==SQLITE_OK ){\n    *pRc = SQLITE_NOMEM;\n  }\n  if( *pRc!=SQLITE_OK ){\n    sqlite3_free(zIn);\n    zIn = 0;\n  }else{\n    if( zIn ){\n      char *zTemp = zIn;\n      zIn = sqlite3_mprintf(\"%s%s\", zIn, zAppend);\n      sqlite3_free(zTemp);\n    }else{\n      zIn = sqlite3_mprintf(\"%s\", zAppend);\n    }\n    if( !zIn ){\n      *pRc = SQLITE_NOMEM;\n    }\n  }\n  *pzStr = zIn;\n  if( doFree ){\n    sqlite3_free(zAppend);\n  }\n}\n\n/*\n** This function returns a pointer to an sqlite3_malloc()ed buffer \n** containing the select-list (the thing between keywords SELECT and FROM)\n** to query the underlying real table with for the scan described by\n** argument pIdxInfo.\n**\n** If the current SQLite version is earlier than 3.10.0, this is just \"*\"\n** (select all columns). Or, for version 3.10.0 and greater, the list of\n** columns identified by the pIdxInfo->colUsed mask.\n*/\nstatic char *echoSelectList(echo_vtab *pTab, sqlite3_index_info *pIdxInfo){\n  char *zRet = 0;\n  if( sqlite3_libversion_number()<3010000 ){\n    zRet = sqlite3_mprintf(\", *\");\n  }else{\n    int i;\n    for(i=0; i<pTab->nCol; i++){\n      if( pIdxInfo->colUsed & ((sqlite3_uint64)1 << (i>=63 ? 63 : i)) ){\n        zRet = sqlite3_mprintf(\"%z, %s\", zRet, pTab->aCol[i]);\n      }else{\n        zRet = sqlite3_mprintf(\"%z, NULL\", zRet);\n      }\n      if( !zRet ) break;\n    }\n  }\n  return zRet;\n}\n\n/*\n** The echo module implements the subset of query constraints and sort\n** orders that may take advantage of SQLite indices on the underlying\n** real table. For example, if the real table is declared as:\n**\n**     CREATE TABLE real(a, b, c);\n**     CREATE INDEX real_index ON real(b);\n**\n** then the echo module handles WHERE or ORDER BY clauses that refer\n** to the column \"b\", but not \"a\" or \"c\". If a multi-column index is\n** present, only its left most column is considered. \n**\n** This xBestIndex method encodes the proposed search strategy as\n** an SQL query on the real table underlying the virtual echo module \n** table and stores the query in sqlite3_index_info.idxStr. The SQL\n** statement is of the form:\n**\n**   SELECT rowid, * FROM <real-table> ?<where-clause>? ?<order-by-clause>?\n**\n** where the <where-clause> and <order-by-clause> are determined\n** by the contents of the structure pointed to by the pIdxInfo argument.\n*/\nstatic int echoBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int ii;\n  char *zQuery = 0;\n  char *zCol = 0;\n  char *zNew;\n  int nArg = 0;\n  const char *zSep = \"WHERE\";\n  echo_vtab *pVtab = (echo_vtab *)tab;\n  sqlite3_stmt *pStmt = 0;\n  Tcl_Interp *interp = pVtab->interp;\n\n  int nRow = 0;\n  int useIdx = 0;\n  int rc = SQLITE_OK;\n  int useCost = 0;\n  double cost = 0;\n  int isIgnoreUsable = 0;\n  if( Tcl_GetVar(interp, \"echo_module_ignore_usable\", TCL_GLOBAL_ONLY) ){\n    isIgnoreUsable = 1;\n  }\n\n  if( simulateVtabError(pVtab, \"xBestIndex\") ){\n    return SQLITE_ERROR;\n  }\n\n  /* Determine the number of rows in the table and store this value in local\n  ** variable nRow. The 'estimated-cost' of the scan will be the number of\n  ** rows in the table for a linear scan, or the log (base 2) of the \n  ** number of rows if the proposed scan uses an index.  \n  */\n  if( Tcl_GetVar(interp, \"echo_module_cost\", TCL_GLOBAL_ONLY) ){\n    cost = atof(Tcl_GetVar(interp, \"echo_module_cost\", TCL_GLOBAL_ONLY));\n    useCost = 1;\n  } else {\n    zQuery = sqlite3_mprintf(\"SELECT count(*) FROM %Q\", pVtab->zTableName);\n    if( !zQuery ){\n      return SQLITE_NOMEM;\n    }\n    rc = sqlite3_prepare(pVtab->db, zQuery, -1, &pStmt, 0);\n    sqlite3_free(zQuery);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    sqlite3_step(pStmt);\n    nRow = sqlite3_column_int(pStmt, 0);\n    rc = sqlite3_finalize(pStmt);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  zCol = echoSelectList(pVtab, pIdxInfo);\n  if( !zCol ) return SQLITE_NOMEM;\n  zQuery = sqlite3_mprintf(\"SELECT rowid%z FROM %Q\", zCol, pVtab->zTableName);\n  if( !zQuery ) return SQLITE_NOMEM;\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    const struct sqlite3_index_constraint *pConstraint;\n    struct sqlite3_index_constraint_usage *pUsage;\n    int iCol;\n\n    pConstraint = &pIdxInfo->aConstraint[ii];\n    pUsage = &pIdxInfo->aConstraintUsage[ii];\n\n    if( !isIgnoreUsable && !pConstraint->usable ) continue;\n\n    iCol = pConstraint->iColumn;\n    if( iCol<0 || pVtab->aIndex[iCol] ){\n      char *zNewCol = iCol>=0 ? pVtab->aCol[iCol] : \"rowid\";\n      char *zOp = 0;\n      useIdx = 1;\n      switch( pConstraint->op ){\n        case SQLITE_INDEX_CONSTRAINT_EQ:\n          zOp = \"=\"; break;\n        case SQLITE_INDEX_CONSTRAINT_LT:\n          zOp = \"<\"; break;\n        case SQLITE_INDEX_CONSTRAINT_GT:\n          zOp = \">\"; break;\n        case SQLITE_INDEX_CONSTRAINT_LE:\n          zOp = \"<=\"; break;\n        case SQLITE_INDEX_CONSTRAINT_GE:\n          zOp = \">=\"; break;\n        case SQLITE_INDEX_CONSTRAINT_MATCH:\n          /* Purposely translate the MATCH operator into a LIKE, which\n          ** will be used by the next block of code to construct a new\n          ** query.  It should also be noted here that the next block\n          ** of code requires the first letter of this operator to be\n          ** in upper-case to trigger the special MATCH handling (i.e.\n          ** wrapping the bound parameter with literal '%'s).\n          */\n          zOp = \"LIKE\"; break;\n        case SQLITE_INDEX_CONSTRAINT_LIKE:\n          zOp = \"like\"; break;\n        case SQLITE_INDEX_CONSTRAINT_GLOB:\n          zOp = \"glob\"; break;\n        case SQLITE_INDEX_CONSTRAINT_REGEXP:\n          zOp = \"regexp\"; break;\n      }\n      if( zOp ){\n        if( zOp[0]=='L' ){\n          zNew = sqlite3_mprintf(\" %s %s LIKE (SELECT '%%'||?||'%%')\", \n              zSep, zNewCol);\n        } else {\n          zNew = sqlite3_mprintf(\" %s %s %s ?\", zSep, zNewCol, zOp);\n        }\n        string_concat(&zQuery, zNew, 1, &rc);\n        zSep = \"AND\";\n        pUsage->argvIndex = ++nArg;\n        pUsage->omit = 1;\n      }\n    }\n  }\n\n  /* If there is only one term in the ORDER BY clause, and it is\n  ** on a column that this virtual table has an index for, then consume \n  ** the ORDER BY clause.\n  */\n  if( pIdxInfo->nOrderBy==1 && (\n        pIdxInfo->aOrderBy->iColumn<0 ||\n        pVtab->aIndex[pIdxInfo->aOrderBy->iColumn]) ){\n    int iCol = pIdxInfo->aOrderBy->iColumn;\n    char *zNewCol = iCol>=0 ? pVtab->aCol[iCol] : \"rowid\";\n    char *zDir = pIdxInfo->aOrderBy->desc?\"DESC\":\"ASC\";\n    zNew = sqlite3_mprintf(\" ORDER BY %s %s\", zNewCol, zDir);\n    string_concat(&zQuery, zNew, 1, &rc);\n    pIdxInfo->orderByConsumed = 1;\n  }\n\n  appendToEchoModule(pVtab->interp, \"xBestIndex\");;\n  appendToEchoModule(pVtab->interp, zQuery);\n\n  if( !zQuery ){\n    return rc;\n  }\n  pIdxInfo->idxNum = hashString(zQuery);\n  pIdxInfo->idxStr = zQuery;\n  pIdxInfo->needToFreeIdxStr = 1;\n  if( useCost ){\n    pIdxInfo->estimatedCost = cost;\n  }else if( useIdx ){\n    /* Approximation of log2(nRow). */\n    for( ii=0; ii<(sizeof(int)*8)-1; ii++ ){\n      if( nRow & (1<<ii) ){\n        pIdxInfo->estimatedCost = (double)ii;\n      }\n    }\n  }else{\n    pIdxInfo->estimatedCost = (double)nRow;\n  }\n  return rc;\n}\n\n/*\n** The xUpdate method for echo module virtual tables.\n** \n**    apData[0]  apData[1]  apData[2..]\n**\n**    INTEGER                              DELETE            \n**\n**    INTEGER    NULL       (nCol args)    UPDATE (do not set rowid)\n**    INTEGER    INTEGER    (nCol args)    UPDATE (with SET rowid = <arg1>)\n**\n**    NULL       NULL       (nCol args)    INSERT INTO (automatic rowid value)\n**    NULL       INTEGER    (nCol args)    INSERT (incl. rowid value)\n**\n*/\nint echoUpdate(\n  sqlite3_vtab *tab, \n  int nData, \n  sqlite3_value **apData, \n  sqlite_int64 *pRowid\n){\n  echo_vtab *pVtab = (echo_vtab *)tab;\n  sqlite3 *db = pVtab->db;\n  int rc = SQLITE_OK;\n\n  sqlite3_stmt *pStmt = 0;\n  char *z = 0;               /* SQL statement to execute */\n  int bindArgZero = 0;       /* True to bind apData[0] to sql var no. nData */\n  int bindArgOne = 0;        /* True to bind apData[1] to sql var no. 1 */\n  int i;                     /* Counter variable used by for loops */\n\n  assert( nData==pVtab->nCol+2 || nData==1 );\n\n  /* Ticket #3083 - make sure we always start a transaction prior to\n  ** making any changes to a virtual table */\n  assert( pVtab->inTransaction );\n\n  if( simulateVtabError(pVtab, \"xUpdate\") ){\n    return SQLITE_ERROR;\n  }\n\n  /* If apData[0] is an integer and nData>1 then do an UPDATE */\n  if( nData>1 && sqlite3_value_type(apData[0])==SQLITE_INTEGER ){\n    char *zSep = \" SET\";\n    z = sqlite3_mprintf(\"UPDATE %Q\", pVtab->zTableName);\n    if( !z ){\n      rc = SQLITE_NOMEM;\n    }\n\n    bindArgOne = (apData[1] && sqlite3_value_type(apData[1])==SQLITE_INTEGER);\n    bindArgZero = 1;\n\n    if( bindArgOne ){\n       string_concat(&z, \" SET rowid=?1 \", 0, &rc);\n       zSep = \",\";\n    }\n    for(i=2; i<nData; i++){\n      if( apData[i]==0 ) continue;\n      string_concat(&z, sqlite3_mprintf(\n          \"%s %Q=?%d\", zSep, pVtab->aCol[i-2], i), 1, &rc);\n      zSep = \",\";\n    }\n    string_concat(&z, sqlite3_mprintf(\" WHERE rowid=?%d\", nData), 1, &rc);\n  }\n\n  /* If apData[0] is an integer and nData==1 then do a DELETE */\n  else if( nData==1 && sqlite3_value_type(apData[0])==SQLITE_INTEGER ){\n    z = sqlite3_mprintf(\"DELETE FROM %Q WHERE rowid = ?1\", pVtab->zTableName);\n    if( !z ){\n      rc = SQLITE_NOMEM;\n    }\n    bindArgZero = 1;\n  }\n\n  /* If the first argument is NULL and there are more than two args, INSERT */\n  else if( nData>2 && sqlite3_value_type(apData[0])==SQLITE_NULL ){\n    int ii;\n    char *zInsert = 0;\n    char *zValues = 0;\n  \n    zInsert = sqlite3_mprintf(\"INSERT INTO %Q (\", pVtab->zTableName);\n    if( !zInsert ){\n      rc = SQLITE_NOMEM;\n    }\n    if( sqlite3_value_type(apData[1])==SQLITE_INTEGER ){\n      bindArgOne = 1;\n      zValues = sqlite3_mprintf(\"?\");\n      string_concat(&zInsert, \"rowid\", 0, &rc);\n    }\n\n    assert((pVtab->nCol+2)==nData);\n    for(ii=2; ii<nData; ii++){\n      string_concat(&zInsert, \n          sqlite3_mprintf(\"%s%Q\", zValues?\", \":\"\", pVtab->aCol[ii-2]), 1, &rc);\n      string_concat(&zValues, \n          sqlite3_mprintf(\"%s?%d\", zValues?\", \":\"\", ii), 1, &rc);\n    }\n\n    string_concat(&z, zInsert, 1, &rc);\n    string_concat(&z, \") VALUES(\", 0, &rc);\n    string_concat(&z, zValues, 1, &rc);\n    string_concat(&z, \")\", 0, &rc);\n  }\n\n  /* Anything else is an error */\n  else{\n    assert(0);\n    return SQLITE_ERROR;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_prepare(db, z, -1, &pStmt, 0);\n  }\n  assert( rc!=SQLITE_OK || pStmt );\n  sqlite3_free(z);\n  if( rc==SQLITE_OK ) {\n    if( bindArgZero ){\n      sqlite3_bind_value(pStmt, nData, apData[0]);\n    }\n    if( bindArgOne ){\n      sqlite3_bind_value(pStmt, 1, apData[1]);\n    }\n    for(i=2; i<nData && rc==SQLITE_OK; i++){\n      if( apData[i] ) rc = sqlite3_bind_value(pStmt, i, apData[i]);\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_step(pStmt);\n      rc = sqlite3_finalize(pStmt);\n    }else{\n      sqlite3_finalize(pStmt);\n    }\n  }\n\n  if( pRowid && rc==SQLITE_OK ){\n    *pRowid = sqlite3_last_insert_rowid(db);\n  }\n  if( rc!=SQLITE_OK ){\n    tab->zErrMsg = sqlite3_mprintf(\"echo-vtab-error: %s\", sqlite3_errmsg(db));\n  }\n\n  return rc;\n}\n\n/*\n** xBegin, xSync, xCommit and xRollback callbacks for echo module\n** virtual tables. Do nothing other than add the name of the callback\n** to the $::echo_module Tcl variable.\n*/\nstatic int echoTransactionCall(sqlite3_vtab *tab, const char *zCall){\n  char *z;\n  echo_vtab *pVtab = (echo_vtab *)tab;\n  z = sqlite3_mprintf(\"echo(%s)\", pVtab->zTableName);\n  if( z==0 ) return SQLITE_NOMEM;\n  appendToEchoModule(pVtab->interp, zCall);\n  appendToEchoModule(pVtab->interp, z);\n  sqlite3_free(z);\n  return SQLITE_OK;\n}\nstatic int echoBegin(sqlite3_vtab *tab){\n  int rc;\n  echo_vtab *pVtab = (echo_vtab *)tab;\n  Tcl_Interp *interp = pVtab->interp;\n  const char *zVal; \n\n  /* Ticket #3083 - do not start a transaction if we are already in\n  ** a transaction */\n  assert( !pVtab->inTransaction );\n\n  if( simulateVtabError(pVtab, \"xBegin\") ){\n    return SQLITE_ERROR;\n  }\n\n  rc = echoTransactionCall(tab, \"xBegin\");\n\n  if( rc==SQLITE_OK ){\n    /* Check if the $::echo_module_begin_fail variable is defined. If it is,\n    ** and it is set to the name of the real table underlying this virtual\n    ** echo module table, then cause this xSync operation to fail.\n    */\n    zVal = Tcl_GetVar(interp, \"echo_module_begin_fail\", TCL_GLOBAL_ONLY);\n    if( zVal && 0==strcmp(zVal, pVtab->zTableName) ){\n      rc = SQLITE_ERROR;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    pVtab->inTransaction = 1;\n  }\n  return rc;\n}\nstatic int echoSync(sqlite3_vtab *tab){\n  int rc;\n  echo_vtab *pVtab = (echo_vtab *)tab;\n  Tcl_Interp *interp = pVtab->interp;\n  const char *zVal; \n\n  /* Ticket #3083 - Only call xSync if we have previously started a\n  ** transaction */\n  assert( pVtab->inTransaction );\n\n  if( simulateVtabError(pVtab, \"xSync\") ){\n    return SQLITE_ERROR;\n  }\n\n  rc = echoTransactionCall(tab, \"xSync\");\n\n  if( rc==SQLITE_OK ){\n    /* Check if the $::echo_module_sync_fail variable is defined. If it is,\n    ** and it is set to the name of the real table underlying this virtual\n    ** echo module table, then cause this xSync operation to fail.\n    */\n    zVal = Tcl_GetVar(interp, \"echo_module_sync_fail\", TCL_GLOBAL_ONLY);\n    if( zVal && 0==strcmp(zVal, pVtab->zTableName) ){\n      rc = -1;\n    }\n  }\n  return rc;\n}\nstatic int echoCommit(sqlite3_vtab *tab){\n  echo_vtab *pVtab = (echo_vtab*)tab;\n  int rc;\n\n  /* Ticket #3083 - Only call xCommit if we have previously started\n  ** a transaction */\n  assert( pVtab->inTransaction );\n\n  if( simulateVtabError(pVtab, \"xCommit\") ){\n    return SQLITE_ERROR;\n  }\n\n  sqlite3BeginBenignMalloc();\n  rc = echoTransactionCall(tab, \"xCommit\");\n  sqlite3EndBenignMalloc();\n  pVtab->inTransaction = 0;\n  return rc;\n}\nstatic int echoRollback(sqlite3_vtab *tab){\n  int rc;\n  echo_vtab *pVtab = (echo_vtab*)tab;\n\n  /* Ticket #3083 - Only call xRollback if we have previously started\n  ** a transaction */\n  assert( pVtab->inTransaction );\n\n  rc = echoTransactionCall(tab, \"xRollback\");\n  pVtab->inTransaction = 0;\n  return rc;\n}\n\n/*\n** Implementation of \"GLOB\" function on the echo module.  Pass\n** all arguments to the ::echo_glob_overload procedure of TCL\n** and return the result of that procedure as a string.\n*/\nstatic void overloadedGlobFunction(\n  sqlite3_context *pContext,\n  int nArg,\n  sqlite3_value **apArg\n){\n  Tcl_Interp *interp = sqlite3_user_data(pContext);\n  Tcl_DString str;\n  int i;\n  int rc;\n  Tcl_DStringInit(&str);\n  Tcl_DStringAppendElement(&str, \"::echo_glob_overload\");\n  for(i=0; i<nArg; i++){\n    Tcl_DStringAppendElement(&str, (char*)sqlite3_value_text(apArg[i]));\n  }\n  rc = Tcl_Eval(interp, Tcl_DStringValue(&str));\n  Tcl_DStringFree(&str);\n  if( rc ){\n    sqlite3_result_error(pContext, Tcl_GetStringResult(interp), -1);\n  }else{\n    sqlite3_result_text(pContext, Tcl_GetStringResult(interp),\n                        -1, SQLITE_TRANSIENT);\n  }\n  Tcl_ResetResult(interp);\n}\n\n/*\n** This is the xFindFunction implementation for the echo module.\n** SQLite calls this routine when the first argument of a function\n** is a column of an echo virtual table.  This routine can optionally\n** override the implementation of that function.  It will choose to\n** do so if the function is named \"glob\", and a TCL command named\n** ::echo_glob_overload exists.\n*/\nstatic int echoFindFunction(\n  sqlite3_vtab *vtab,\n  int nArg,\n  const char *zFuncName,\n  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),\n  void **ppArg\n){\n  echo_vtab *pVtab = (echo_vtab *)vtab;\n  Tcl_Interp *interp = pVtab->interp;\n  Tcl_CmdInfo info;\n  if( strcmp(zFuncName,\"glob\")!=0 ){\n    return 0;\n  }\n  if( Tcl_GetCommandInfo(interp, \"::echo_glob_overload\", &info)==0 ){\n    return 0;\n  }\n  *pxFunc = overloadedGlobFunction;\n  *ppArg = interp;\n  return 1;\n}\n\nstatic int echoRename(sqlite3_vtab *vtab, const char *zNewName){\n  int rc = SQLITE_OK;\n  echo_vtab *p = (echo_vtab *)vtab;\n\n  if( simulateVtabError(p, \"xRename\") ){\n    return SQLITE_ERROR;\n  }\n\n  if( p->isPattern ){\n    int nThis = (int)strlen(p->zThis);\n    char *zSql = sqlite3_mprintf(\"ALTER TABLE %s RENAME TO %s%s\", \n        p->zTableName, zNewName, &p->zTableName[nThis]\n    );\n    rc = sqlite3_exec(p->db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n\n  return rc;\n}\n\nstatic int echoSavepoint(sqlite3_vtab *pVTab, int iSavepoint){\n  assert( pVTab );\n  return SQLITE_OK;\n}\n\nstatic int echoRelease(sqlite3_vtab *pVTab, int iSavepoint){\n  assert( pVTab );\n  return SQLITE_OK;\n}\n\nstatic int echoRollbackTo(sqlite3_vtab *pVTab, int iSavepoint){\n  assert( pVTab );\n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that merely \"echos\" the contents of another\n** table (like an SQL VIEW).\n*/\nstatic sqlite3_module echoModule = {\n  1,                         /* iVersion */\n  echoCreate,\n  echoConnect,\n  echoBestIndex,\n  echoDisconnect, \n  echoDestroy,\n  echoOpen,                  /* xOpen - open a cursor */\n  echoClose,                 /* xClose - close a cursor */\n  echoFilter,                /* xFilter - configure scan constraints */\n  echoNext,                  /* xNext - advance a cursor */\n  echoEof,                   /* xEof */\n  echoColumn,                /* xColumn - read data */\n  echoRowid,                 /* xRowid - read data */\n  echoUpdate,                /* xUpdate - write data */\n  echoBegin,                 /* xBegin - begin transaction */\n  echoSync,                  /* xSync - sync transaction */\n  echoCommit,                /* xCommit - commit transaction */\n  echoRollback,              /* xRollback - rollback transaction */\n  echoFindFunction,          /* xFindFunction - function overloading */\n  echoRename                 /* xRename - rename the table */\n};\n\nstatic sqlite3_module echoModuleV2 = {\n  2,                         /* iVersion */\n  echoCreate,\n  echoConnect,\n  echoBestIndex,\n  echoDisconnect, \n  echoDestroy,\n  echoOpen,                  /* xOpen - open a cursor */\n  echoClose,                 /* xClose - close a cursor */\n  echoFilter,                /* xFilter - configure scan constraints */\n  echoNext,                  /* xNext - advance a cursor */\n  echoEof,                   /* xEof */\n  echoColumn,                /* xColumn - read data */\n  echoRowid,                 /* xRowid - read data */\n  echoUpdate,                /* xUpdate - write data */\n  echoBegin,                 /* xBegin - begin transaction */\n  echoSync,                  /* xSync - sync transaction */\n  echoCommit,                /* xCommit - commit transaction */\n  echoRollback,              /* xRollback - rollback transaction */\n  echoFindFunction,          /* xFindFunction - function overloading */\n  echoRename,                /* xRename - rename the table */\n  echoSavepoint,\n  echoRelease,\n  echoRollbackTo\n};\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\nextern const char *sqlite3ErrName(int);\n\nstatic void moduleDestroy(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** Register the echo virtual table module.\n*/\nstatic int SQLITE_TCLAPI register_echo_module(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int rc;\n  sqlite3 *db;\n  EchoModule *pMod;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  /* Virtual table module \"echo\" */\n  pMod = sqlite3_malloc(sizeof(EchoModule));\n  pMod->interp = interp;\n  rc = sqlite3_create_module_v2(\n      db, \"echo\", &echoModule, (void*)pMod, moduleDestroy\n  );\n\n  /* Virtual table module \"echo_v2\" */\n  if( rc==SQLITE_OK ){\n    pMod = sqlite3_malloc(sizeof(EchoModule));\n    pMod->interp = interp;\n    rc = sqlite3_create_module_v2(db, \"echo_v2\", \n        &echoModuleV2, (void*)pMod, moduleDestroy\n    );\n  }\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl:\n**\n** sqlite3_declare_vtab DB SQL\n*/\nstatic int SQLITE_TCLAPI declare_vtab(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  int rc;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB SQL\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_declare_vtab(db, Tcl_GetString(objv[2]));\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char *)sqlite3_errmsg(db), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest8_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"register_echo_module\",       register_echo_module, 0 },\n     { \"sqlite3_declare_vtab\",       declare_vtab, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test9.c",
    "content": "/*\n** 2007 March 29\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains obscure tests of the C-interface required\n** for completeness. Test code is written in C for these cases\n** as there is not much point in binding to Tcl.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** c_collation_test\n*/\nstatic int SQLITE_TCLAPI c_collation_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  const char *zErrFunction = \"N/A\";\n  sqlite3 *db;\n\n  int rc;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  /* Open a database. */\n  rc = sqlite3_open(\":memory:\", &db);\n  if( rc!=SQLITE_OK ){\n    zErrFunction = \"sqlite3_open\";\n    goto error_out;\n  }\n\n  rc = sqlite3_create_collation(db, \"collate\", 456, 0, 0);\n  if( rc!=SQLITE_MISUSE ){\n    sqlite3_close(db);\n    zErrFunction = \"sqlite3_create_collation\";\n    goto error_out;\n  }\n\n  sqlite3_close(db);\n  return TCL_OK;\n\nerror_out:\n  Tcl_ResetResult(interp);\n  Tcl_AppendResult(interp, \"Error testing function: \", zErrFunction, 0);\n  return TCL_ERROR;\n}\n\n/*\n** c_realloc_test\n*/\nstatic int SQLITE_TCLAPI c_realloc_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  void *p;\n  const char *zErrFunction = \"N/A\";\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  p = sqlite3_malloc(5);\n  if( !p ){\n    zErrFunction = \"sqlite3_malloc\";\n    goto error_out;\n  }\n\n  /* Test that realloc()ing a block of memory to a negative size is\n  ** the same as free()ing that memory.\n  */\n  p = sqlite3_realloc(p, -1);\n  if( p ){\n    zErrFunction = \"sqlite3_realloc\";\n    goto error_out;\n  }\n\n  return TCL_OK;\n\nerror_out:\n  Tcl_ResetResult(interp);\n  Tcl_AppendResult(interp, \"Error testing function: \", zErrFunction, 0);\n  return TCL_ERROR;\n}\n\n\n/*\n** c_misuse_test\n*/\nstatic int SQLITE_TCLAPI c_misuse_test(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  const char *zErrFunction = \"N/A\";\n  sqlite3 *db = 0;\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  /* Open a database. Then close it again. We need to do this so that\n  ** we have a \"closed database handle\" to pass to various API functions.\n  */\n  rc = sqlite3_open(\":memory:\", &db);\n  if( rc!=SQLITE_OK ){\n    zErrFunction = \"sqlite3_open\";\n    goto error_out;\n  }\n  sqlite3_close(db);\n\n\n  rc = sqlite3_errcode(db);\n  if( rc!=SQLITE_MISUSE ){\n    zErrFunction = \"sqlite3_errcode\";\n    goto error_out;\n  }\n\n  pStmt = (sqlite3_stmt*)1234;\n  rc = sqlite3_prepare(db, 0, 0, &pStmt, 0);\n  if( rc!=SQLITE_MISUSE ){\n    zErrFunction = \"sqlite3_prepare\";\n    goto error_out;\n  }\n  assert( pStmt==0 ); /* Verify that pStmt is zeroed even on a MISUSE error */\n\n  pStmt = (sqlite3_stmt*)1234;\n  rc = sqlite3_prepare_v2(db, 0, 0, &pStmt, 0);\n  if( rc!=SQLITE_MISUSE ){\n    zErrFunction = \"sqlite3_prepare_v2\";\n    goto error_out;\n  }\n  assert( pStmt==0 );\n\n#ifndef SQLITE_OMIT_UTF16\n  pStmt = (sqlite3_stmt*)1234;\n  rc = sqlite3_prepare16(db, 0, 0, &pStmt, 0);\n  if( rc!=SQLITE_MISUSE ){\n    zErrFunction = \"sqlite3_prepare16\";\n    goto error_out;\n  }\n  assert( pStmt==0 );\n  pStmt = (sqlite3_stmt*)1234;\n  rc = sqlite3_prepare16_v2(db, 0, 0, &pStmt, 0);\n  if( rc!=SQLITE_MISUSE ){\n    zErrFunction = \"sqlite3_prepare16_v2\";\n    goto error_out;\n  }\n  assert( pStmt==0 );\n#endif\n\n  return TCL_OK;\n\nerror_out:\n  Tcl_ResetResult(interp);\n  Tcl_AppendResult(interp, \"Error testing function: \", zErrFunction, 0);\n  return TCL_ERROR;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest9_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"c_misuse_test\",    c_misuse_test, 0 },\n     { \"c_realloc_test\",   c_realloc_test, 0 },\n     { \"c_collation_test\", c_collation_test, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_async.c",
    "content": "/*\n** 2005 December 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a binding of the asynchronous IO extension interface\n** (defined in ext/async/sqlite3async.h) to Tcl.\n*/\n\n#define TCL_THREADS \n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\n#ifdef SQLITE_ENABLE_ASYNCIO\n\n#include \"sqlite3async.h\"\n#include \"sqlite3.h\"\n#include <assert.h>\n\n/* From main.c */\nextern const char *sqlite3ErrName(int);\n\n\nstruct TestAsyncGlobal {\n  int isInstalled;                     /* True when async VFS is installed */\n} testasync_g = { 0 };\n\nTCL_DECLARE_MUTEX(testasync_g_writerMutex);\n\n/*\n** sqlite3async_initialize PARENT-VFS ISDEFAULT\n*/\nstatic int SQLITE_TCLAPI testAsyncInit(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zParent;\n  int isDefault;\n  int rc;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PARENT-VFS ISDEFAULT\");\n    return TCL_ERROR;\n  }\n  zParent = Tcl_GetString(objv[1]);\n  if( !*zParent ) {\n    zParent = 0;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3async_initialize(zParent, isDefault);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n/*\n** sqlite3async_shutdown\n*/\nstatic int SQLITE_TCLAPI testAsyncShutdown(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3async_shutdown();\n  return TCL_OK;\n}\n\nstatic Tcl_ThreadCreateType tclWriterThread(ClientData pIsStarted){\n  Tcl_MutexLock(&testasync_g_writerMutex);\n  *((int *)pIsStarted) = 1;\n  sqlite3async_run();\n  Tcl_MutexUnlock(&testasync_g_writerMutex);\n  Tcl_ExitThread(0);\n  TCL_THREAD_CREATE_RETURN;\n}\n\n/*\n** sqlite3async_start\n**\n** Start a new writer thread.\n*/\nstatic int SQLITE_TCLAPI testAsyncStart(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  volatile int isStarted = 0;\n  ClientData threadData = (ClientData)&isStarted;\n\n  Tcl_ThreadId x;\n  const int nStack = TCL_THREAD_STACK_DEFAULT;\n  const int flags = TCL_THREAD_NOFLAGS;\n  int rc;\n\n  rc = Tcl_CreateThread(&x, tclWriterThread, threadData, nStack, flags);\n  if( rc!=TCL_OK ){\n    Tcl_AppendResult(interp, \"Tcl_CreateThread() failed\", 0);\n    return TCL_ERROR;\n  }\n\n  while( isStarted==0 ) { /* Busy loop */ }\n  return TCL_OK;\n}\n\n/*\n** sqlite3async_wait\n**\n** Wait for the current writer thread to terminate.\n**\n** If the current writer thread is set to run forever then this\n** command would block forever.  To prevent that, an error is returned. \n*/\nstatic int SQLITE_TCLAPI testAsyncWait(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int eCond;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  sqlite3async_control(SQLITEASYNC_GET_HALT, &eCond);\n  if( eCond==SQLITEASYNC_HALT_NEVER ){\n    Tcl_AppendResult(interp, \"would block forever\", (char*)0);\n    return TCL_ERROR;\n  }\n\n  Tcl_MutexLock(&testasync_g_writerMutex);\n  Tcl_MutexUnlock(&testasync_g_writerMutex);\n  return TCL_OK;\n}\n\n/*\n** sqlite3async_control OPTION ?VALUE?\n*/\nstatic int SQLITE_TCLAPI testAsyncControl(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = SQLITE_OK;\n  int aeOpt[] = { SQLITEASYNC_HALT, SQLITEASYNC_DELAY, SQLITEASYNC_LOCKFILES };\n  const char *azOpt[] = { \"halt\", \"delay\", \"lockfiles\", 0 };\n  const char *az[] = { \"never\", \"now\", \"idle\", 0 };\n  int iVal;\n  int eOpt;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"OPTION ?VALUE?\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIndexFromObj(interp, objv[1], azOpt, \"option\", 0, &eOpt) ){\n    return TCL_ERROR;\n  }\n  eOpt = aeOpt[eOpt];\n\n  if( objc==3 ){\n    switch( eOpt ){\n      case SQLITEASYNC_HALT: {\n        assert( SQLITEASYNC_HALT_NEVER==0 );\n        assert( SQLITEASYNC_HALT_NOW==1 );\n        assert( SQLITEASYNC_HALT_IDLE==2 );\n        if( Tcl_GetIndexFromObj(interp, objv[2], az, \"value\", 0, &iVal) ){\n          return TCL_ERROR;\n        }\n        break;\n      }\n      case SQLITEASYNC_DELAY:\n        if( Tcl_GetIntFromObj(interp, objv[2], &iVal) ){\n          return TCL_ERROR;\n        }\n        break;\n\n      case SQLITEASYNC_LOCKFILES:\n        if( Tcl_GetBooleanFromObj(interp, objv[2], &iVal) ){\n          return TCL_ERROR;\n        }\n        break;\n    }\n\n    rc = sqlite3async_control(eOpt, iVal);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3async_control(\n        eOpt==SQLITEASYNC_HALT ? SQLITEASYNC_GET_HALT :\n        eOpt==SQLITEASYNC_DELAY ? SQLITEASYNC_GET_DELAY :\n        SQLITEASYNC_GET_LOCKFILES, &iVal);\n  }\n\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }\n\n  if( eOpt==SQLITEASYNC_HALT ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(az[iVal], -1));\n  }else{\n    Tcl_SetObjResult(interp, Tcl_NewIntObj(iVal));\n  }\n\n  return TCL_OK;\n}\n\n#endif  /* SQLITE_ENABLE_ASYNCIO */\n\n/*\n** This routine registers the custom TCL commands defined in this\n** module.  This should be the only procedure visible from outside\n** of this module.\n*/\nint Sqlitetestasync_Init(Tcl_Interp *interp){\n#ifdef SQLITE_ENABLE_ASYNCIO\n  Tcl_CreateObjCommand(interp,\"sqlite3async_start\",testAsyncStart,0,0);\n  Tcl_CreateObjCommand(interp,\"sqlite3async_wait\",testAsyncWait,0,0);\n\n  Tcl_CreateObjCommand(interp,\"sqlite3async_control\",testAsyncControl,0,0);\n  Tcl_CreateObjCommand(interp,\"sqlite3async_initialize\",testAsyncInit,0,0);\n  Tcl_CreateObjCommand(interp,\"sqlite3async_shutdown\",testAsyncShutdown,0,0);\n#endif  /* SQLITE_ENABLE_ASYNCIO */\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_autoext.c",
    "content": "/*\n** 2006 August 23\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Test extension for testing the sqlite3_auto_extension() function.\n*/\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n#include \"sqlite3ext.h\"\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nSQLITE_EXTENSION_INIT1\n\n/*\n** The sqr() SQL function returns the square of its input value.\n*/\nstatic void sqrFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  double r = sqlite3_value_double(argv[0]);\n  sqlite3_result_double(context, r*r);\n}\n\n/*\n** This is the entry point to register the extension for the sqr() function.\n*/\nstatic int sqr_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  sqlite3_create_function(db, \"sqr\", 1, SQLITE_ANY, 0, sqrFunc, 0, 0);\n  return 0;\n}\n\n/*\n** The cube() SQL function returns the cube of its input value.\n*/\nstatic void cubeFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  double r = sqlite3_value_double(argv[0]);\n  sqlite3_result_double(context, r*r*r);\n}\n\n/*\n** This is the entry point to register the extension for the cube() function.\n*/\nstatic int cube_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n  sqlite3_create_function(db, \"cube\", 1, SQLITE_ANY, 0, cubeFunc, 0, 0);\n  return 0;\n}\n\n/*\n** This is a broken extension entry point\n*/\nstatic int broken_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  char *zErr;\n  SQLITE_EXTENSION_INIT2(pApi);\n  zErr = sqlite3_mprintf(\"broken autoext!\");\n  *pzErrMsg = zErr;\n  return 1;\n}\n\n/*\n** tclcmd:   sqlite3_auto_extension_sqr\n**\n** Register the \"sqr\" extension to be loaded automatically.\n*/\nstatic int SQLITE_TCLAPI autoExtSqrObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_auto_extension((void(*)(void))sqr_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** tclcmd:   sqlite3_cancel_auto_extension_sqr\n**\n** Unregister the \"sqr\" extension.\n*/\nstatic int SQLITE_TCLAPI cancelAutoExtSqrObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_cancel_auto_extension((void(*)(void))sqr_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** tclcmd:   sqlite3_auto_extension_cube\n**\n** Register the \"cube\" extension to be loaded automatically.\n*/\nstatic int SQLITE_TCLAPI autoExtCubeObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_auto_extension((void(*)(void))cube_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** tclcmd:   sqlite3_cancel_auto_extension_cube\n**\n** Unregister the \"cube\" extension.\n*/\nstatic int SQLITE_TCLAPI cancelAutoExtCubeObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_cancel_auto_extension((void(*)(void))cube_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** tclcmd:   sqlite3_auto_extension_broken\n**\n** Register the broken extension to be loaded automatically.\n*/\nstatic int SQLITE_TCLAPI autoExtBrokenObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_auto_extension((void(*)(void))broken_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n/*\n** tclcmd:   sqlite3_cancel_auto_extension_broken\n**\n** Unregister the broken extension.\n*/\nstatic int SQLITE_TCLAPI cancelAutoExtBrokenObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = sqlite3_cancel_auto_extension((void(*)(void))broken_init);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return SQLITE_OK;\n}\n\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n\n/*\n** tclcmd:   sqlite3_reset_auto_extension\n**\n** Reset all auto-extensions\n*/\nstatic int SQLITE_TCLAPI resetAutoExtObjCmd(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_reset_auto_extension();\n  return SQLITE_OK;\n}\n\n\n/*\n** This procedure registers the TCL procs defined in this file.\n*/\nint Sqlitetest_autoext_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  Tcl_CreateObjCommand(interp, \"sqlite3_auto_extension_sqr\",\n          autoExtSqrObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_auto_extension_cube\",\n          autoExtCubeObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_auto_extension_broken\",\n          autoExtBrokenObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_cancel_auto_extension_sqr\",\n          cancelAutoExtSqrObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_cancel_auto_extension_cube\",\n          cancelAutoExtCubeObjCmd, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlite3_cancel_auto_extension_broken\",\n          cancelAutoExtBrokenObjCmd, 0, 0);\n#endif\n  Tcl_CreateObjCommand(interp, \"sqlite3_reset_auto_extension\",\n          resetAutoExtObjCmd, 0, 0);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_backup.c",
    "content": "/*\n** 2009 January 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains test logic for the sqlite3_backup() interface.\n**\n*/\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n#include \"sqlite3.h\"\n#include <assert.h>\n\n/* These functions are implemented in main.c. */\nextern const char *sqlite3ErrName(int);\n\n/* These functions are implemented in test1.c. */\nextern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);\n\nstatic int SQLITE_TCLAPI backupTestCmd(\n  ClientData clientData, \n  Tcl_Interp *interp, \n  int objc,\n  Tcl_Obj *const*objv\n){\n  enum BackupSubCommandEnum {\n    BACKUP_STEP, BACKUP_FINISH, BACKUP_REMAINING, BACKUP_PAGECOUNT\n  };\n  struct BackupSubCommand {\n    const char *zCmd;\n    enum BackupSubCommandEnum eCmd;\n    int nArg;\n    const char *zArg;\n  } aSub[] = {\n    {\"step\",      BACKUP_STEP      , 1, \"npage\" },\n    {\"finish\",    BACKUP_FINISH    , 0, \"\"      },\n    {\"remaining\", BACKUP_REMAINING , 0, \"\"      },\n    {\"pagecount\", BACKUP_PAGECOUNT , 0, \"\"      },\n    {0, 0, 0, 0}\n  };\n\n  sqlite3_backup *p = (sqlite3_backup *)clientData;\n  int iCmd;\n  int rc;\n\n  rc = Tcl_GetIndexFromObjStruct(\n      interp, objv[1], aSub, sizeof(aSub[0]), \"option\", 0, &iCmd\n  );\n  if( rc!=TCL_OK ){\n    return rc;\n  }\n  if( objc!=(2 + aSub[iCmd].nArg) ){\n    Tcl_WrongNumArgs(interp, 2, objv, aSub[iCmd].zArg);\n    return TCL_ERROR;\n  }\n\n  switch( aSub[iCmd].eCmd ){\n\n    case BACKUP_FINISH: {\n      const char *zCmdName;\n      Tcl_CmdInfo cmdInfo;\n      zCmdName = Tcl_GetString(objv[0]);\n      Tcl_GetCommandInfo(interp, zCmdName, &cmdInfo);\n      cmdInfo.deleteProc = 0;\n      Tcl_SetCommandInfo(interp, zCmdName, &cmdInfo);\n      Tcl_DeleteCommand(interp, zCmdName);\n\n      rc = sqlite3_backup_finish(p);\n      Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n      break;\n    }\n\n    case BACKUP_STEP: {\n      int nPage;\n      if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &nPage) ){\n        return TCL_ERROR;\n      }\n      rc = sqlite3_backup_step(p, nPage);\n      Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n      break;\n    }\n\n    case BACKUP_REMAINING:\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_remaining(p)));\n      break;\n\n    case BACKUP_PAGECOUNT:\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_backup_pagecount(p)));\n      break;\n  }\n\n  return TCL_OK;\n}\n\nstatic void SQLITE_TCLAPI backupTestFinish(ClientData clientData){\n  sqlite3_backup *pBackup = (sqlite3_backup *)clientData;\n  sqlite3_backup_finish(pBackup);\n}\n\n/*\n**     sqlite3_backup CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME\n**\n*/\nstatic int SQLITE_TCLAPI backupTestInit(\n  ClientData clientData, \n  Tcl_Interp *interp, \n  int objc,\n  Tcl_Obj *const*objv\n){\n  sqlite3_backup *pBackup;\n  sqlite3 *pDestDb;\n  sqlite3 *pSrcDb;\n  const char *zDestName;\n  const char *zSrcName;\n  const char *zCmd;\n\n  if( objc!=6 ){\n    Tcl_WrongNumArgs(\n      interp, 1, objv, \"CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME\"\n    );\n    return TCL_ERROR;\n  }\n\n  zCmd = Tcl_GetString(objv[1]);\n  getDbPointer(interp, Tcl_GetString(objv[2]), &pDestDb);\n  zDestName = Tcl_GetString(objv[3]);\n  getDbPointer(interp, Tcl_GetString(objv[4]), &pSrcDb);\n  zSrcName = Tcl_GetString(objv[5]);\n\n  pBackup = sqlite3_backup_init(pDestDb, zDestName, pSrcDb, zSrcName);\n  if( !pBackup ){\n    Tcl_AppendResult(interp, \"sqlite3_backup_init() failed\", 0);\n    return TCL_ERROR;\n  }\n\n  Tcl_CreateObjCommand(interp, zCmd, backupTestCmd, pBackup, backupTestFinish);\n  Tcl_SetObjResult(interp, objv[1]);\n  return TCL_OK;\n}\n\nint Sqlitetestbackup_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"sqlite3_backup\", backupTestInit, 0, 0);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_bestindex.c",
    "content": "/*\n** 2016-03-01\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the virtual table xBestIndex method and the query\n** planner.\n*/\n\n\n/*\n** INSTRUCTIONS\n**\n** This module exports a single tcl command - [register_tcl_module]. When\n** invoked, it registers a special virtual table module with a database\n** connection.\n**\n** The virtual table is currently read-only. And always returns zero rows.\n** It is created with a single argument - the name of a Tcl command - as\n** follows:\n**\n**   CREATE VIRTUAL TABLE x1 USING tcl(tcl_command);\n**\n** The command [tcl_command] is invoked when the table is first created (or\n** connected), when the xBestIndex() method is invoked and when the xFilter()\n** method is called. When it is created (or connected), it is invoked as\n** follows:\n**\n**   tcl_command xConnect\n**\n** In this case the return value of the script is passed to the\n** sqlite3_declare_vtab() function to create the virtual table schema.\n**\n** When the xBestIndex() method is called by SQLite, the Tcl command is\n** invoked as:\n**\n**   tcl_command xBestIndex CONSTRAINTS ORDERBY MASK\n**\n** where CONSTRAINTS is a tcl representation of the aConstraints[] array,\n** ORDERBY is a representation of the contents of the aOrderBy[] array and\n** MASK is a copy of sqlite3_index_info.colUsed. For example if the virtual\n** table is declared as:\n**\n**   CREATE TABLE x1(a, b, c)\n**\n** and the query is:\n**\n**   SELECT * FROM x1 WHERE a=? AND c<? ORDER BY b, c;\n**\n** then the Tcl command is:\n**\n**   tcl_command xBestIndex                                  \\\n**     {{op eq column 0 usable 1} {op lt column 2 usable 1}} \\\n**     {{column 1 desc 0} {column 2 desc 0}}                 \\\n**     7\n**\n** The return value of the script is a list of key-value pairs used to\n** populate the output fields of the sqlite3_index_info structure. Possible\n** keys and the usage of the accompanying values are:\n** \n**   \"orderby\"          (value of orderByConsumed flag)\n**   \"cost\"             (value of estimatedCost field)\n**   \"rows\"             (value of estimatedRows field)\n**   \"use\"              (index of used constraint in aConstraint[])\n**   \"omit\"             (like \"use\", but also sets omit flag)\n**   \"idxnum\"           (value of idxNum field)\n**   \"idxstr\"           (value of idxStr field)\n**\n** Refer to code below for further details.\n**\n** When SQLite calls the xFilter() method, this module invokes the following\n** Tcl script:\n**\n**   tcl_command xFilter IDXNUM IDXSTR ARGLIST\n**\n** IDXNUM and IDXSTR are the values of the idxNum and idxStr parameters\n** passed to xFilter. ARGLIST is a Tcl list containing each of the arguments\n** passed to xFilter in text form.\n**\n** As with xBestIndex(), the return value of the script is interpreted as a\n** list of key-value pairs. There is currently only one key defined - \"sql\".\n** The value must be the full text of an SQL statement that returns the data\n** for the current scan. The leftmost column returned by the SELECT is assumed\n** to contain the rowid. Other columns must follow, in order from left to\n** right.\n*/\n\n\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\ntypedef struct tcl_vtab tcl_vtab;\ntypedef struct tcl_cursor tcl_cursor;\n\n/* \n** A fs virtual-table object \n*/\nstruct tcl_vtab {\n  sqlite3_vtab base;\n  Tcl_Interp *interp;\n  Tcl_Obj *pCmd;\n  sqlite3 *db;\n};\n\n/* A tcl cursor object */\nstruct tcl_cursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Read data from here */\n};\n\n/*\n** Dequote string z in place.\n*/\nstatic void tclDequote(char *z){\n  char q = z[0];\n\n  /* Set stack variable q to the close-quote character */\n  if( q=='[' || q=='\\'' || q=='\"' || q=='`' ){\n    int iIn = 1;\n    int iOut = 0;\n    if( q=='[' ) q = ']';  \n\n    while( ALWAYS(z[iIn]) ){\n      if( z[iIn]==q ){\n        if( z[iIn+1]!=q ){\n          /* Character iIn was the close quote. */\n          iIn++;\n          break;\n        }else{\n          /* Character iIn and iIn+1 form an escaped quote character. Skip\n          ** the input cursor past both and copy a single quote character \n          ** to the output buffer. */\n          iIn += 2;\n          z[iOut++] = q;\n        }\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n\n    z[iOut] = '\\0';\n  }\n}\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the fs virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fs\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> other module argument fields.\n*/\nstatic int tclConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  Tcl_Interp *interp = (Tcl_Interp*)pAux;\n  tcl_vtab *pTab = 0;\n  char *zCmd = 0;\n  Tcl_Obj *pScript = 0;\n  int rc = SQLITE_OK;\n\n  if( argc!=4 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of arguments\");\n    return SQLITE_ERROR;\n  }\n\n  zCmd = sqlite3_malloc64(strlen(argv[3])+1);\n  pTab = (tcl_vtab*)sqlite3_malloc64(sizeof(tcl_vtab));\n  if( zCmd && pTab ){\n    memcpy(zCmd, argv[3], strlen(argv[3])+1);\n    tclDequote(zCmd);\n    memset(pTab, 0, sizeof(tcl_vtab));\n\n    pTab->pCmd = Tcl_NewStringObj(zCmd, -1);\n    pTab->interp = interp;\n    pTab->db = db;\n    Tcl_IncrRefCount(pTab->pCmd);\n\n    pScript = Tcl_DuplicateObj(pTab->pCmd);\n    Tcl_IncrRefCount(pScript);\n    Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(\"xConnect\", -1));\n\n    rc = Tcl_EvalObjEx(interp, pScript, TCL_EVAL_GLOBAL);\n    if( rc!=TCL_OK ){\n      *pzErr = sqlite3_mprintf(\"%s\", Tcl_GetStringResult(interp));\n      rc = SQLITE_ERROR;\n    }else{\n      rc = sqlite3_declare_vtab(db, Tcl_GetStringResult(interp));\n    }\n\n    if( rc!=SQLITE_OK ){\n      sqlite3_free(pTab);\n      pTab = 0;\n    }\n  }else{\n    rc = SQLITE_NOMEM;\n  }\n\n  sqlite3_free(zCmd);\n  *ppVtab = &pTab->base;\n  return rc;\n}\n\n/* The xDisconnect and xDestroy methods are also the same */\nstatic int tclDisconnect(sqlite3_vtab *pVtab){\n  tcl_vtab *pTab = (tcl_vtab*)pVtab;\n  Tcl_DecrRefCount(pTab->pCmd);\n  sqlite3_free(pTab);\n  return SQLITE_OK;\n}\n\n/*\n** Open a new tcl cursor.\n*/\nstatic int tclOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  tcl_cursor *pCur;\n  pCur = sqlite3_malloc(sizeof(tcl_cursor));\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(tcl_cursor));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tcl cursor.\n*/\nstatic int tclClose(sqlite3_vtab_cursor *cur){\n  tcl_cursor *pCur = (tcl_cursor *)cur;\n  if( pCur ){\n    sqlite3_finalize(pCur->pStmt);\n    sqlite3_free(pCur);\n  }\n  return SQLITE_OK;\n}\n\nstatic int tclNext(sqlite3_vtab_cursor *pVtabCursor){\n  tcl_cursor *pCsr = (tcl_cursor*)pVtabCursor;\n  if( pCsr->pStmt ){\n    tcl_vtab *pTab = (tcl_vtab*)(pVtabCursor->pVtab);\n    int rc = sqlite3_step(pCsr->pStmt);\n    if( rc!=SQLITE_ROW ){\n      const char *zErr;\n      rc = sqlite3_finalize(pCsr->pStmt);\n      pCsr->pStmt = 0;\n      if( rc!=SQLITE_OK ){\n        zErr = sqlite3_errmsg(pTab->db);\n        pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n      }\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int tclFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  tcl_cursor *pCsr = (tcl_cursor*)pVtabCursor;\n  tcl_vtab *pTab = (tcl_vtab*)(pVtabCursor->pVtab);\n  Tcl_Interp *interp = pTab->interp;\n  Tcl_Obj *pScript;\n  Tcl_Obj *pArg;\n  int ii;\n  int rc;\n\n  pScript = Tcl_DuplicateObj(pTab->pCmd);\n  Tcl_IncrRefCount(pScript);\n  Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(\"xFilter\", -1));\n  Tcl_ListObjAppendElement(interp, pScript, Tcl_NewIntObj(idxNum));\n  if( idxStr ){\n    Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(idxStr, -1));\n  }else{\n    Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(\"\", -1));\n  }\n\n  pArg = Tcl_NewObj();\n  Tcl_IncrRefCount(pArg);\n  for(ii=0; ii<argc; ii++){\n    const char *zVal = (const char*)sqlite3_value_text(argv[ii]);\n    Tcl_Obj *pVal;\n    if( zVal==0 ){\n      pVal = Tcl_NewObj();\n    }else{\n      pVal = Tcl_NewStringObj(zVal, -1);\n    }\n    Tcl_ListObjAppendElement(interp, pArg, pVal);\n  }\n  Tcl_ListObjAppendElement(interp, pScript, pArg);\n  Tcl_DecrRefCount(pArg);\n\n  rc = Tcl_EvalObjEx(interp, pScript, TCL_EVAL_GLOBAL);\n  if( rc!=TCL_OK ){\n    const char *zErr = Tcl_GetStringResult(interp);\n    rc = SQLITE_ERROR;\n    pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n  }else{\n    /* Analyze the scripts return value. The return value should be a tcl \n    ** list object with an even number of elements. The first element of each\n    ** pair must be one of:\n    ** \n    **   \"sql\"          (SQL statement to return data)\n    */\n    Tcl_Obj *pRes = Tcl_GetObjResult(interp);\n    Tcl_Obj **apElem = 0;\n    int nElem;\n    rc = Tcl_ListObjGetElements(interp, pRes, &nElem, &apElem);\n    if( rc!=TCL_OK ){\n      const char *zErr = Tcl_GetStringResult(interp);\n      rc = SQLITE_ERROR;\n      pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n    }else{\n      for(ii=0; rc==SQLITE_OK && ii<nElem; ii+=2){\n        const char *zCmd = Tcl_GetString(apElem[ii]);\n        Tcl_Obj *p = apElem[ii+1];\n        if( sqlite3_stricmp(\"sql\", zCmd)==0 ){\n          const char *zSql = Tcl_GetString(p);\n          rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);\n          if( rc!=SQLITE_OK ){\n            const char *zErr = sqlite3_errmsg(pTab->db);\n            pTab->base.zErrMsg = sqlite3_mprintf(\"unexpected: %s\", zErr);\n          }\n        }else{\n          rc = SQLITE_ERROR;\n          pTab->base.zErrMsg = sqlite3_mprintf(\"unexpected: %s\", zCmd);\n        }\n      }\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = tclNext(pVtabCursor);\n  }\n  return rc;\n}\n\nstatic int tclColumn(\n  sqlite3_vtab_cursor *pVtabCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  tcl_cursor *pCsr = (tcl_cursor*)pVtabCursor;\n  sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pStmt, i+1));\n  return SQLITE_OK;\n}\n\nstatic int tclRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){\n  tcl_cursor *pCsr = (tcl_cursor*)pVtabCursor;\n  *pRowid = sqlite3_column_int64(pCsr->pStmt, 0);\n  return SQLITE_OK;\n}\n\nstatic int tclEof(sqlite3_vtab_cursor *pVtabCursor){\n  tcl_cursor *pCsr = (tcl_cursor*)pVtabCursor;\n  return (pCsr->pStmt==0);\n}\n\nstatic int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  tcl_vtab *pTab = (tcl_vtab*)tab;\n  Tcl_Interp *interp = pTab->interp;\n  Tcl_Obj *pArg;\n  Tcl_Obj *pScript;\n  int ii;\n  int rc = SQLITE_OK;\n\n  pScript = Tcl_DuplicateObj(pTab->pCmd);\n  Tcl_IncrRefCount(pScript);\n  Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(\"xBestIndex\", -1));\n\n  pArg = Tcl_NewObj();\n  Tcl_IncrRefCount(pArg);\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii];\n    Tcl_Obj *pElem = Tcl_NewObj();\n    const char *zOp = \"?\";\n\n    Tcl_IncrRefCount(pElem);\n\n    switch( pCons->op ){\n      case SQLITE_INDEX_CONSTRAINT_EQ:\n        zOp = \"eq\"; break;\n      case SQLITE_INDEX_CONSTRAINT_GT:\n        zOp = \"gt\"; break;\n      case SQLITE_INDEX_CONSTRAINT_LE:\n        zOp = \"le\"; break;\n      case SQLITE_INDEX_CONSTRAINT_LT:\n        zOp = \"lt\"; break;\n      case SQLITE_INDEX_CONSTRAINT_GE:\n        zOp = \"ge\"; break;\n      case SQLITE_INDEX_CONSTRAINT_MATCH:\n        zOp = \"match\"; break;\n      case SQLITE_INDEX_CONSTRAINT_LIKE:\n        zOp = \"like\"; break;\n      case SQLITE_INDEX_CONSTRAINT_GLOB:\n        zOp = \"glob\"; break;\n      case SQLITE_INDEX_CONSTRAINT_REGEXP:\n        zOp = \"regexp\"; break;\n      case SQLITE_INDEX_CONSTRAINT_NE:\n        zOp = \"ne\"; break;\n      case SQLITE_INDEX_CONSTRAINT_ISNOT:\n        zOp = \"isnot\"; break;\n      case SQLITE_INDEX_CONSTRAINT_ISNOTNULL:\n        zOp = \"isnotnull\"; break;\n      case SQLITE_INDEX_CONSTRAINT_ISNULL:\n        zOp = \"isnull\"; break;\n      case SQLITE_INDEX_CONSTRAINT_IS:\n        zOp = \"is\"; break;\n    }\n\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(\"op\", -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(zOp, -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(\"column\", -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pCons->iColumn));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(\"usable\", -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pCons->usable));\n\n    Tcl_ListObjAppendElement(0, pArg, pElem);\n    Tcl_DecrRefCount(pElem);\n  }\n\n  Tcl_ListObjAppendElement(0, pScript, pArg);\n  Tcl_DecrRefCount(pArg);\n\n  pArg = Tcl_NewObj();\n  Tcl_IncrRefCount(pArg);\n  for(ii=0; ii<pIdxInfo->nOrderBy; ii++){\n    struct sqlite3_index_orderby const *pOrder = &pIdxInfo->aOrderBy[ii];\n    Tcl_Obj *pElem = Tcl_NewObj();\n    Tcl_IncrRefCount(pElem);\n\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(\"column\", -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pOrder->iColumn));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj(\"desc\", -1));\n    Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pOrder->desc));\n\n    Tcl_ListObjAppendElement(0, pArg, pElem);\n    Tcl_DecrRefCount(pElem);\n  }\n\n  Tcl_ListObjAppendElement(0, pScript, pArg);\n  Tcl_DecrRefCount(pArg);\n\n  Tcl_ListObjAppendElement(0, pScript, Tcl_NewWideIntObj(pIdxInfo->colUsed));\n\n  rc = Tcl_EvalObjEx(interp, pScript, TCL_EVAL_GLOBAL);\n  Tcl_DecrRefCount(pScript);\n  if( rc!=TCL_OK ){\n    const char *zErr = Tcl_GetStringResult(interp);\n    rc = SQLITE_ERROR;\n    pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n  }else{\n    /* Analyze the scripts return value. The return value should be a tcl \n    ** list object with an even number of elements. The first element of each\n    ** pair must be one of:\n    ** \n    **   \"orderby\"          (value of orderByConsumed flag)\n    **   \"cost\"             (value of estimatedCost field)\n    **   \"rows\"             (value of estimatedRows field)\n    **   \"use\"              (index of used constraint in aConstraint[])\n    **   \"idxnum\"           (value of idxNum field)\n    **   \"idxstr\"           (value of idxStr field)\n    **   \"omit\"             (index of omitted constraint in aConstraint[])\n    */\n    Tcl_Obj *pRes = Tcl_GetObjResult(interp);\n    Tcl_Obj **apElem = 0;\n    int nElem;\n    rc = Tcl_ListObjGetElements(interp, pRes, &nElem, &apElem);\n    if( rc!=TCL_OK ){\n      const char *zErr = Tcl_GetStringResult(interp);\n      rc = SQLITE_ERROR;\n      pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n    }else{\n      int iArgv = 1;\n      for(ii=0; rc==SQLITE_OK && ii<nElem; ii+=2){\n        const char *zCmd = Tcl_GetString(apElem[ii]);\n        Tcl_Obj *p = apElem[ii+1];\n        if( sqlite3_stricmp(\"cost\", zCmd)==0 ){\n          rc = Tcl_GetDoubleFromObj(interp, p, &pIdxInfo->estimatedCost);\n        }else\n        if( sqlite3_stricmp(\"orderby\", zCmd)==0 ){\n          rc = Tcl_GetIntFromObj(interp, p, &pIdxInfo->orderByConsumed);\n        }else\n        if( sqlite3_stricmp(\"idxnum\", zCmd)==0 ){\n          rc = Tcl_GetIntFromObj(interp, p, &pIdxInfo->idxNum);\n        }else\n        if( sqlite3_stricmp(\"idxstr\", zCmd)==0 ){\n          sqlite3_free(pIdxInfo->idxStr);\n          pIdxInfo->idxStr = sqlite3_mprintf(\"%s\", Tcl_GetString(p));\n          pIdxInfo->needToFreeIdxStr = 1;\n        }else\n        if( sqlite3_stricmp(\"rows\", zCmd)==0 ){\n          Tcl_WideInt x = 0;\n          rc = Tcl_GetWideIntFromObj(interp, p, &x);\n          pIdxInfo->estimatedRows = (tRowcnt)x;\n        }else\n        if( sqlite3_stricmp(\"use\", zCmd)==0 \n         || sqlite3_stricmp(\"omit\", zCmd)==0 \n        ){\n          int iCons;\n          rc = Tcl_GetIntFromObj(interp, p, &iCons);\n          if( rc==SQLITE_OK ){\n            if( iCons<0 || iCons>=pIdxInfo->nConstraint ){\n              rc = SQLITE_ERROR;\n              pTab->base.zErrMsg = sqlite3_mprintf(\"unexpected: %d\", iCons);\n            }else{\n              int bOmit = (zCmd[0]=='o' || zCmd[0]=='O');\n              pIdxInfo->aConstraintUsage[iCons].argvIndex = iArgv++;\n              pIdxInfo->aConstraintUsage[iCons].omit = bOmit;\n            }\n          }\n        }else{\n          rc = SQLITE_ERROR;\n          pTab->base.zErrMsg = sqlite3_mprintf(\"unexpected: %s\", zCmd);\n        }\n        if( rc!=SQLITE_OK && pTab->base.zErrMsg==0 ){\n          const char *zErr = Tcl_GetStringResult(interp);\n          pTab->base.zErrMsg = sqlite3_mprintf(\"%s\", zErr);\n        }\n      }\n    }\n  }\n\n  return rc;\n}\n\n/*\n** A virtual table module that provides read-only access to a\n** Tcl global variable namespace.\n*/\nstatic sqlite3_module tclModule = {\n  0,                         /* iVersion */\n  tclConnect,\n  tclConnect,\n  tclBestIndex,\n  tclDisconnect, \n  tclDisconnect,\n  tclOpen,                      /* xOpen - open a cursor */\n  tclClose,                     /* xClose - close a cursor */\n  tclFilter,                    /* xFilter - configure scan constraints */\n  tclNext,                      /* xNext - advance a cursor */\n  tclEof,                       /* xEof - check for end of scan */\n  tclColumn,                    /* xColumn - read data */\n  tclRowid,                     /* xRowid - read data */\n  0,                           /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\n\n/*\n** Register the echo virtual table module.\n*/\nstatic int SQLITE_TCLAPI register_tcl_module(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_create_module(db, \"tcl\", &tclModule, (void *)interp);\n#endif\n  return TCL_OK;\n}\n\n#endif\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetesttcl_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"register_tcl_module\",   register_tcl_module, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_blob.c",
    "content": "/*\n** 2014 October 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n#ifndef SQLITE_OMIT_INCRBLOB\n\n/* These functions are implemented in main.c. */\nextern const char *sqlite3ErrName(int);\n\n/* From test1.c: */\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\nextern void *sqlite3TestTextToPtr(const char *z);\n\n/*\n** Return a pointer to a buffer containing a text representation of the\n** pointer passed as the only argument. The original pointer may be extracted\n** from the text using sqlite3TestTextToPtr().\n*/\nstatic char *ptrToText(void *p){\n  static char buf[100];\n  sqlite3_snprintf(sizeof(buf)-1, buf, \"%p\", p);\n  return buf;\n}\n\n/*\n** Attempt to extract a blob handle (type sqlite3_blob*) from the Tcl\n** object passed as the second argument. If successful, set *ppBlob to\n** point to the blob handle and return TCL_OK. Otherwise, store an error\n** message in the tcl interpreter and return TCL_ERROR. The final value\n** of *ppBlob is undefined in this case.\n**\n** If the object contains a string that begins with \"incrblob_\", then it\n** is assumed to be the name of a Tcl channel opened using the [db incrblob] \n** command (see tclsqlite.c). Otherwise, it is assumed to be a pointer \n** encoded using the ptrToText() routine or similar.\n*/\nstatic int blobHandleFromObj(\n  Tcl_Interp *interp, \n  Tcl_Obj *pObj,\n  sqlite3_blob **ppBlob\n){\n  char *z;\n  int n;\n\n  z = Tcl_GetStringFromObj(pObj, &n);\n  if( n==0 ){\n    *ppBlob = 0;\n  }else if( n>9 && 0==memcmp(\"incrblob_\", z, 9) ){\n    int notUsed;\n    Tcl_Channel channel;\n    ClientData instanceData;\n    \n    channel = Tcl_GetChannel(interp, z, &notUsed);\n    if( !channel ) return TCL_ERROR;\n\n    Tcl_Flush(channel);\n    Tcl_Seek(channel, 0, SEEK_SET);\n\n    instanceData = Tcl_GetChannelInstanceData(channel);\n    *ppBlob = *((sqlite3_blob **)instanceData);\n  }else{\n    *ppBlob = (sqlite3_blob*)sqlite3TestTextToPtr(z);\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Like Tcl_GetString(), except that if the string is 0 bytes in size, a\n** NULL Pointer is returned.\n*/\nstatic char *blobStringFromObj(Tcl_Obj *pObj){\n  int n;\n  char *z;\n  z = Tcl_GetStringFromObj(pObj, &n);\n  return (n ? z : 0);\n}\n\n/*\n** sqlite3_blob_open DB DATABASE TABLE COLUMN ROWID FLAGS VARNAME\n**\n** Tcl test harness for the sqlite3_blob_open() function.\n*/\nstatic int SQLITE_TCLAPI test_blob_open(\n  ClientData clientData,          /* Not used */\n  Tcl_Interp *interp,             /* Calling TCL interpreter */\n  int objc,                       /* Number of arguments */\n  Tcl_Obj *CONST objv[]           /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zDb;\n  const char *zTable;\n  const char *zColumn;\n  Tcl_WideInt iRowid;\n  int flags;\n  const char *zVarname;\n  int nVarname;\n\n  sqlite3_blob *pBlob = (sqlite3_blob*)&flags;   /* Non-zero initialization */\n  int rc;\n\n  if( objc!=8 ){\n    const char *zUsage = \"DB DATABASE TABLE COLUMN ROWID FLAGS VARNAME\";\n    Tcl_WrongNumArgs(interp, 1, objv, zUsage);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zDb = Tcl_GetString(objv[2]);\n  zTable = blobStringFromObj(objv[3]);\n  zColumn = Tcl_GetString(objv[4]);\n  if( Tcl_GetWideIntFromObj(interp, objv[5], &iRowid) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[6], &flags) ) return TCL_ERROR;\n  zVarname = Tcl_GetStringFromObj(objv[7], &nVarname);\n\n  if( nVarname>0 ){\n    rc = sqlite3_blob_open(db, zDb, zTable, zColumn, iRowid, flags, &pBlob);\n    Tcl_SetVar(interp, zVarname, ptrToText(pBlob), 0);\n  }else{\n    rc = sqlite3_blob_open(db, zDb, zTable, zColumn, iRowid, flags, 0);\n  }\n\n  if( rc==SQLITE_OK ){\n    Tcl_ResetResult(interp);\n  }else{\n    Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n    return TCL_ERROR;\n  }\n  return TCL_OK;\n}\n\n\n/*\n** sqlite3_blob_close  HANDLE\n*/\nstatic int SQLITE_TCLAPI test_blob_close(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_blob *pBlob;\n  int rc;\n  \n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n\n  if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;\n  rc = sqlite3_blob_close(pBlob);\n\n  if( rc ){\n    Tcl_SetResult(interp, (char*)sqlite3ErrName(rc), TCL_VOLATILE);\n  }else{\n    Tcl_ResetResult(interp);\n  }\n  return TCL_OK;\n}\n\n/*\n** sqlite3_blob_bytes  HANDLE\n*/\nstatic int SQLITE_TCLAPI test_blob_bytes(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_blob *pBlob;\n  int nByte;\n  \n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n\n  if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;\n  nByte = sqlite3_blob_bytes(pBlob);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(nByte));\n\n  return TCL_OK;\n}\n\n/*\n** sqlite3_blob_read  CHANNEL OFFSET N\n**\n**   This command is used to test the sqlite3_blob_read() in ways that\n**   the Tcl channel interface does not. The first argument should\n**   be the name of a valid channel created by the [incrblob] method\n**   of a database handle. This function calls sqlite3_blob_read()\n**   to read N bytes from offset OFFSET from the underlying SQLite\n**   blob handle.\n**\n**   On success, a byte-array object containing the read data is \n**   returned. On failure, the interpreter result is set to the\n**   text representation of the returned error code (i.e. \"SQLITE_NOMEM\")\n**   and a Tcl exception is thrown.\n*/\nstatic int SQLITE_TCLAPI test_blob_read(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_blob *pBlob;\n  int nByte;\n  int iOffset;\n  unsigned char *zBuf = 0;\n  int rc;\n  \n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"CHANNEL OFFSET N\");\n    return TCL_ERROR;\n  }\n\n  if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;\n  if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset)\n   || TCL_OK!=Tcl_GetIntFromObj(interp, objv[3], &nByte)\n  ){ \n    return TCL_ERROR;\n  }\n\n  if( nByte>0 ){\n    zBuf = (unsigned char *)Tcl_AttemptAlloc(nByte);\n    if( zBuf==0 ){\n      Tcl_AppendResult(interp, \"out of memory in \" __FILE__, 0);\n      return TCL_ERROR;\n    }\n  }\n  rc = sqlite3_blob_read(pBlob, zBuf, nByte, iOffset);\n  if( rc==SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zBuf, nByte));\n  }else{\n    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  }\n  Tcl_Free((char *)zBuf);\n\n  return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);\n}\n\n/*\n** sqlite3_blob_write HANDLE OFFSET DATA ?NDATA?\n**\n**   This command is used to test the sqlite3_blob_write() in ways that\n**   the Tcl channel interface does not. The first argument should\n**   be the name of a valid channel created by the [incrblob] method\n**   of a database handle. This function calls sqlite3_blob_write()\n**   to write the DATA byte-array to the underlying SQLite blob handle.\n**   at offset OFFSET.\n**\n**   On success, an empty string is returned. On failure, the interpreter\n**   result is set to the text representation of the returned error code \n**   (i.e. \"SQLITE_NOMEM\") and a Tcl exception is thrown.\n*/\nstatic int SQLITE_TCLAPI test_blob_write(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_blob *pBlob;\n  int iOffset;\n  int rc;\n\n  unsigned char *zBuf;\n  int nBuf;\n  \n  if( objc!=4 && objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE OFFSET DATA ?NDATA?\");\n    return TCL_ERROR;\n  }\n\n  if( blobHandleFromObj(interp, objv[1], &pBlob) ) return TCL_ERROR;\n  if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){ \n    return TCL_ERROR;\n  }\n\n  zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf);\n  if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){\n    return TCL_ERROR;\n  }\n  rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset);\n  if( rc!=SQLITE_OK ){\n    Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  }\n\n  return (rc==SQLITE_OK ? TCL_OK : TCL_ERROR);\n}\n#endif /* SQLITE_OMIT_INCRBLOB */\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest_blob_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_INCRBLOB\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aObjCmd[] = {\n     { \"sqlite3_blob_open\",            test_blob_open        },\n     { \"sqlite3_blob_close\",           test_blob_close       },\n     { \"sqlite3_blob_bytes\",           test_blob_bytes       },\n     { \"sqlite3_blob_read\",            test_blob_read        },\n     { \"sqlite3_blob_write\",           test_blob_write       },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);\n  }\n#endif /* SQLITE_OMIT_INCRBLOB */\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_btree.c",
    "content": "/*\n** 2007 May 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the btree.c module in SQLite.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n#include \"btreeInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n/*\n** Usage: sqlite3_shared_cache_report\n**\n** Return a list of file that are shared and the number of\n** references to each file.\n*/\nint SQLITE_TCLAPI sqlite3BtreeSharedCacheReport(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  extern BtShared *sqlite3SharedCacheList;\n  BtShared *pBt;\n  Tcl_Obj *pRet = Tcl_NewObj();\n  for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){\n    const char *zFile = sqlite3PagerFilename(pBt->pPager, 1);\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(zFile, -1));\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(pBt->nRef));\n  }\n  Tcl_SetObjResult(interp, pRet);\n#endif\n  return TCL_OK;\n}\n\n/*\n** Print debugging information about all cursors to standard output.\n*/\nvoid sqlite3BtreeCursorList(Btree *p){\n#ifdef SQLITE_DEBUG\n  BtCursor *pCur;\n  BtShared *pBt = p->pBt;\n  for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){\n    MemPage *pPage = pCur->apPage[pCur->iPage];\n    char *zMode = (pCur->curFlags & BTCF_WriteFlag) ? \"rw\" : \"ro\";\n    sqlite3DebugPrintf(\"CURSOR %p rooted at %4d(%s) currently at %d.%d%s\\n\",\n       pCur, pCur->pgnoRoot, zMode,\n       pPage ? pPage->pgno : 0, pCur->aiIdx[pCur->iPage],\n       (pCur->eState==CURSOR_VALID) ? \"\" : \" eof\"\n    );\n  }\n#endif\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_config.c",
    "content": "/*\n** 2007 May 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file contains code used for testing the SQLite system.\n** None of the code in this file goes into a deliverable build.\n** \n** The focus of this file is providing the TCL testing layer\n** access to compile-time constants.\n*/\n\n#include \"sqliteLimit.h\"\n\n#include \"sqliteInt.h\"\n#if SQLITE_OS_WIN\n#  include \"os_win.h\"\n#endif\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n/*\n** Macro to stringify the results of the evaluation a pre-processor\n** macro. i.e. so that STRINGVALUE(SQLITE_NOMEM) -> \"7\".\n*/\n#define STRINGVALUE2(x) #x\n#define STRINGVALUE(x) STRINGVALUE2(x)\n\n/*\n** This routine sets entries in the global ::sqlite_options() array variable\n** according to the compile-time configuration of the database.  Test\n** procedures use this to determine when tests should be omitted.\n*/\nstatic void set_options(Tcl_Interp *interp){\n#if HAVE_MALLOC_USABLE_SIZE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"malloc_usable_size\", \"1\",\n              TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"malloc_usable_size\", \"0\",\n              TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_32BIT_ROWID\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rowid32\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rowid32\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_CASE_SENSITIVE_LIKE\n  Tcl_SetVar2(interp, \"sqlite_options\",\"casesensitivelike\",\"1\",TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\",\"casesensitivelike\",\"0\",TCL_GLOBAL_ONLY);\n#endif\n\n#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"curdir\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"curdir\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_WIN32_MALLOC\n  Tcl_SetVar2(interp, \"sqlite_options\", \"win32malloc\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"win32malloc\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DEBUG\n  Tcl_SetVar2(interp, \"sqlite_options\", \"debug\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"debug\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DEFAULT_CKPTFULLFSYNC\n  Tcl_SetVar2(interp, \"sqlite_options\", \"default_ckptfullfsync\", \n              SQLITE_DEFAULT_CKPTFULLFSYNC ? \"1\" : \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"default_ckptfullfsync\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DIRECT_OVERFLOW_READ\n  Tcl_SetVar2(interp, \"sqlite_options\", \"direct_read\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"direct_read\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DISABLE_DIRSYNC\n  Tcl_SetVar2(interp, \"sqlite_options\", \"dirsync\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"dirsync\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DISABLE_LFS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"lfs\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"lfs\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pagecache_overflow_stats\",\"0\",TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pagecache_overflow_stats\",\"1\",TCL_GLOBAL_ONLY);\n#endif\n\n#if SQLITE_MAX_MMAP_SIZE>0\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mmap\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mmap\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n  Tcl_SetVar2(interp, \"sqlite_options\", \"worker_threads\", \n      STRINGVALUE(SQLITE_MAX_WORKER_THREADS), TCL_GLOBAL_ONLY\n  );\n\n#if 1 /* def SQLITE_MEMDEBUG */\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memdebug\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memdebug\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n  Tcl_SetVar2(interp, \"sqlite_options\", \"8_3_names\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"8_3_names\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cursorhints\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cursorhints\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"hiddencolumns\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"hiddencolumns\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_MEMSYS3\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mem3\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mem3\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_MEMSYS5\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mem5\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mem5\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  Tcl_SetVar2(interp, \"sqlite_options\", \"preupdate\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"preupdate\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"snapshot\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"snapshot\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_MUTEX_OMIT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mutex\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mutex\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_MUTEX_NOOP\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mutex_noop\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"mutex_noop\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_ALTERTABLE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"altertable\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"altertable\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_ANALYZE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"analyze\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"analyze\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  Tcl_SetVar2(interp, \"sqlite_options\", \"api_armor\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"api_armor\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_ATOMIC_WRITE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"atomicwrite\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"atomicwrite\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_JSON1\n  Tcl_SetVar2(interp, \"sqlite_options\", \"json1\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"json1\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_HAS_CODEC\n  Tcl_SetVar2(interp, \"sqlite_options\", \"has_codec\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"has_codec\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"like_match_blobs\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"like_match_blobs\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_ATTACH\n  Tcl_SetVar2(interp, \"sqlite_options\", \"attach\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"attach\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_AUTHORIZATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"auth\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"auth\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_AUTOINCREMENT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoinc\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoinc\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_AUTOMATIC_INDEX\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoindex\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoindex\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_AUTORESET\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoreset\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autoreset\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_AUTOVACUUM\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autovacuum\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"autovacuum\", \"1\", TCL_GLOBAL_ONLY);\n#endif /* SQLITE_OMIT_AUTOVACUUM */\n#if !defined(SQLITE_DEFAULT_AUTOVACUUM)\n  Tcl_SetVar2(interp,\"sqlite_options\",\"default_autovacuum\",\"0\",TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"default_autovacuum\", \n      STRINGVALUE(SQLITE_DEFAULT_AUTOVACUUM), TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"between_opt\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"between_opt\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_UNTESTABLE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"builtin_test\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"builtin_test\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_BLOB_LITERAL\n  Tcl_SetVar2(interp, \"sqlite_options\", \"bloblit\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"bloblit\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_CAST\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cast\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cast\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_CHECK\n  Tcl_SetVar2(interp, \"sqlite_options\", \"check\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"check\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_CTE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cte\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"cte\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n  Tcl_SetVar2(interp, \"sqlite_options\", \"columnmetadata\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"columnmetadata\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK\n  Tcl_SetVar2(interp, \"sqlite_options\", \"oversize_cell_check\", \"1\",\n              TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"oversize_cell_check\", \"0\",\n              TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"compileoption_diags\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"compileoption_diags\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_COMPLETE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"complete\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"complete\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_COMPOUND_SELECT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"compound\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"compound\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n  Tcl_SetVar2(interp, \"sqlite_options\", \"conflict\", \"1\", TCL_GLOBAL_ONLY);\n  Tcl_SetVar2(interp, \"sqlite_options\", \"crashtest\", \"1\", TCL_GLOBAL_ONLY);\n\n#ifdef SQLITE_OMIT_DATETIME_FUNCS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"datetime\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"datetime\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_DECLTYPE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"decltype\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"decltype\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_DEPRECATED\n  Tcl_SetVar2(interp, \"sqlite_options\", \"deprecated\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"deprecated\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_DISKIO\n  Tcl_SetVar2(interp, \"sqlite_options\", \"diskio\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"diskio\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_EXPLAIN\n  Tcl_SetVar2(interp, \"sqlite_options\", \"explain\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"explain\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"floatingpoint\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"floatingpoint\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_FOREIGN_KEY\n  Tcl_SetVar2(interp, \"sqlite_options\", \"foreignkey\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"foreignkey\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_FTS1\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts1\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts1\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_FTS2\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts2\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts2\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_FTS3\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts3\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts3\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_FTS5\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts5\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts5\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_DISABLE_FTS3_UNICODE)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts3_unicode\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts3_unicode\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_DISABLE_FTS4_DEFERRED\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts4_deferred\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"fts4_deferred\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_GET_TABLE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"gettable\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"gettable\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_ICU\n  Tcl_SetVar2(interp, \"sqlite_options\", \"icu\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"icu\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_INCRBLOB\n  Tcl_SetVar2(interp, \"sqlite_options\", \"incrblob\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"incrblob\", \"1\", TCL_GLOBAL_ONLY);\n#endif /* SQLITE_OMIT_AUTOVACUUM */\n\n#ifdef SQLITE_OMIT_INTEGRITY_CHECK\n  Tcl_SetVar2(interp, \"sqlite_options\", \"integrityck\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"integrityck\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_DEFAULT_FILE_FORMAT) && SQLITE_DEFAULT_FILE_FORMAT==1\n  Tcl_SetVar2(interp, \"sqlite_options\", \"legacyformat\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"legacyformat\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"like_opt\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"like_opt\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_LOAD_EXTENSION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"load_ext\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"load_ext\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_LOCALTIME\n  Tcl_SetVar2(interp, \"sqlite_options\", \"localtime\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"localtime\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_LOOKASIDE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"lookaside\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"lookaside\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\nTcl_SetVar2(interp, \"sqlite_options\", \"long_double\",\n              sizeof(LONGDOUBLE_TYPE)>sizeof(double) ? \"1\" : \"0\",\n              TCL_GLOBAL_ONLY);\n\n#ifdef SQLITE_OMIT_MEMORYDB\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memorydb\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memorydb\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memorymanage\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"memorymanage\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\nTcl_SetVar2(interp, \"sqlite_options\", \"mergesort\", \"1\", TCL_GLOBAL_ONLY);\n\n#ifdef SQLITE_OMIT_OR_OPTIMIZATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"or_opt\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"or_opt\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_RBU\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rbu\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rbu\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_PAGER_PRAGMAS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pager_pragmas\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pager_pragmas\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_OMIT_PRAGMA) || defined(SQLITE_OMIT_FLAG_PRAGMAS)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pragma\", \"0\", TCL_GLOBAL_ONLY);\n  Tcl_SetVar2(interp, \"sqlite_options\", \"integrityck\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"pragma\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_PROGRESS_CALLBACK\n  Tcl_SetVar2(interp, \"sqlite_options\", \"progress\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"progress\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_REINDEX\n  Tcl_SetVar2(interp, \"sqlite_options\", \"reindex\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"reindex\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rtree\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rtree\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_RTREE_INT_ONLY\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rtree_int_only\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"rtree_int_only\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"schema_pragmas\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"schema_pragmas\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"schema_version\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"schema_version\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_SESSION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"session\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"session\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_STAT4\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stat4\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stat4\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stat3\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stat3\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_ENABLE_STMTVTAB) && !defined(SQLITE_OMIT_VIRTUALTABLE)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stmtvtab\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"stmtvtab\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  Tcl_SetVar2(interp, \"sqlite_options\", \"scanstatus\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"scanstatus\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#if !defined(SQLITE_ENABLE_LOCKING_STYLE)\n#  if defined(__APPLE__)\n#    define SQLITE_ENABLE_LOCKING_STYLE 1\n#  else\n#    define SQLITE_ENABLE_LOCKING_STYLE 0\n#  endif\n#endif\n#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)\n  Tcl_SetVar2(interp,\"sqlite_options\",\"lock_proxy_pragmas\",\"1\",TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp,\"sqlite_options\",\"lock_proxy_pragmas\",\"0\",TCL_GLOBAL_ONLY);\n#endif\n#if defined(SQLITE_PREFER_PROXY_LOCKING) && defined(__APPLE__)\n  Tcl_SetVar2(interp,\"sqlite_options\",\"prefer_proxy_locking\",\"1\",TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp,\"sqlite_options\",\"prefer_proxy_locking\",\"0\",TCL_GLOBAL_ONLY);\n#endif\n    \n    \n#ifdef SQLITE_OMIT_SHARED_CACHE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"shared_cache\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"shared_cache\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_SUBQUERY\n  Tcl_SetVar2(interp, \"sqlite_options\", \"subquery\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"subquery\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_TCL_VARIABLE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"tclvar\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"tclvar\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n  Tcl_SetVar2(interp, \"sqlite_options\", \"threadsafe\", \n      SQLITE_THREADSAFE ? \"1\" : \"0\", TCL_GLOBAL_ONLY);\n  Tcl_SetVar2(interp, \"sqlite_options\", \"threadsafe1\", \n      SQLITE_THREADSAFE==1 ? \"1\" : \"0\", TCL_GLOBAL_ONLY);\n  Tcl_SetVar2(interp, \"sqlite_options\", \"threadsafe2\", \n      SQLITE_THREADSAFE==2 ? \"1\" : \"0\", TCL_GLOBAL_ONLY);\n  assert( sqlite3_threadsafe()==SQLITE_THREADSAFE );\n\n#ifdef SQLITE_OMIT_TEMPDB\n  Tcl_SetVar2(interp, \"sqlite_options\", \"tempdb\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"tempdb\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_TRACE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"trace\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"trace\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_TRIGGER\n  Tcl_SetVar2(interp, \"sqlite_options\", \"trigger\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"trigger\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"truncate_opt\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"truncate_opt\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_UTF16\n  Tcl_SetVar2(interp, \"sqlite_options\", \"utf16\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"utf16\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_OMIT_VACUUM) || defined(SQLITE_OMIT_ATTACH)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"vacuum\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"vacuum\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_VIEW\n  Tcl_SetVar2(interp, \"sqlite_options\", \"view\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"view\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"vtab\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"vtab\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_WAL\n  Tcl_SetVar2(interp, \"sqlite_options\", \"wal\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"wal\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_OMIT_WSD\n  Tcl_SetVar2(interp, \"sqlite_options\", \"wsd\", \"0\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"wsd\", \"1\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"update_delete_limit\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"update_delete_limit\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#if defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\n  Tcl_SetVar2(interp, \"sqlite_options\", \"unlock_notify\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"unlock_notify\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_SECURE_DELETE\n  Tcl_SetVar2(interp, \"sqlite_options\", \"secure_delete\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"secure_delete\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_USER_AUTHENTICATION\n  Tcl_SetVar2(interp, \"sqlite_options\", \"userauth\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"userauth\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_MULTIPLEX_EXT_OVWR\n  Tcl_SetVar2(interp, \"sqlite_options\", \"multiplex_ext_overwrite\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"multiplex_ext_overwrite\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef YYTRACKMAXSTACKDEPTH\n  Tcl_SetVar2(interp, \"sqlite_options\", \"yytrackmaxstackdepth\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"yytrackmaxstackdepth\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_SQLLOG\n  Tcl_SetVar2(interp, \"sqlite_options\", \"sqllog\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"sqllog\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#ifdef SQLITE_ENABLE_URI_00_ERROR\n  Tcl_SetVar2(interp, \"sqlite_options\", \"uri_00_error\", \"1\", TCL_GLOBAL_ONLY);\n#else\n  Tcl_SetVar2(interp, \"sqlite_options\", \"uri_00_error\", \"0\", TCL_GLOBAL_ONLY);\n#endif\n\n#define LINKVAR(x) { \\\n    static const int cv_ ## x = SQLITE_ ## x; \\\n    Tcl_LinkVar(interp, \"SQLITE_\" #x, (char *)&(cv_ ## x), \\\n                TCL_LINK_INT | TCL_LINK_READ_ONLY); }\n\n  LINKVAR( MAX_LENGTH );\n  LINKVAR( MAX_COLUMN );\n  LINKVAR( MAX_SQL_LENGTH );\n  LINKVAR( MAX_EXPR_DEPTH );\n  LINKVAR( MAX_COMPOUND_SELECT );\n  LINKVAR( MAX_VDBE_OP );\n  LINKVAR( MAX_FUNCTION_ARG );\n  LINKVAR( MAX_VARIABLE_NUMBER );\n  LINKVAR( MAX_PAGE_SIZE );\n  LINKVAR( MAX_PAGE_COUNT );\n  LINKVAR( MAX_LIKE_PATTERN_LENGTH );\n  LINKVAR( MAX_TRIGGER_DEPTH );\n  LINKVAR( DEFAULT_CACHE_SIZE );\n  LINKVAR( DEFAULT_PAGE_SIZE );\n  LINKVAR( DEFAULT_FILE_FORMAT );\n  LINKVAR( DEFAULT_SYNCHRONOUS );\n  LINKVAR( DEFAULT_WAL_SYNCHRONOUS );\n  LINKVAR( MAX_ATTACHED );\n  LINKVAR( MAX_DEFAULT_PAGE_SIZE );\n  LINKVAR( MAX_WORKER_THREADS );\n\n  {\n    static const int cv_TEMP_STORE = SQLITE_TEMP_STORE;\n    Tcl_LinkVar(interp, \"TEMP_STORE\", (char *)&(cv_TEMP_STORE),\n                TCL_LINK_INT | TCL_LINK_READ_ONLY);\n  }\n\n#ifdef _MSC_VER\n  {\n    static const int cv__MSC_VER = 1;\n    Tcl_LinkVar(interp, \"_MSC_VER\", (char *)&(cv__MSC_VER),\n                TCL_LINK_INT | TCL_LINK_READ_ONLY);\n  }\n#endif\n#ifdef __GNUC__\n  {\n    static const int cv___GNUC__ = 1;\n    Tcl_LinkVar(interp, \"__GNUC__\", (char *)&(cv___GNUC__),\n                TCL_LINK_INT | TCL_LINK_READ_ONLY);\n  }\n#endif\n}\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqliteconfig_Init(Tcl_Interp *interp){\n  set_options(interp);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_delete.c",
    "content": "/*\n** 2016 September 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains test code to delete an SQLite database and all\n** of its associated files. Associated files include:\n**\n**   * The journal file.\n**   * The wal file.\n**   * The SQLITE_ENABLE_8_3_NAMES version of the db, journal or wal files.\n**   * Files created by the test_multiplex.c module to extend any of the \n**     above.\n*/\n\n#ifndef SQLITE_OS_WIN\n#  include <unistd.h>\n#  include <errno.h>\n#endif\n#include <string.h>\n#include <assert.h>\n#include \"sqlite3.h\"\n\n/* The following #defines are copied from test_multiplex.c */\n#ifndef MX_CHUNK_NUMBER \n# define MX_CHUNK_NUMBER 299\n#endif\n#ifndef SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET\n# define SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET 400\n#endif\n#ifndef SQLITE_MULTIPLEX_WAL_8_3_OFFSET\n# define SQLITE_MULTIPLEX_WAL_8_3_OFFSET 700\n#endif\n\n/*\n** This routine is a copy of (most of) the code from SQLite function\n** sqlite3FileSuffix3(). It modifies the filename in buffer z in the\n** same way as SQLite does when in 8.3 filenames mode.\n*/\nstatic void sqlite3Delete83Name(char *z){\n  int i, sz;\n  sz = (int)strlen(z);\n  for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n  if( z[i]=='.' && (sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);\n}\n\n/*\n** zFile is a filename. Assuming no error occurs, if this file exists, \n** set *pbExists to true and unlink it. Or, if the file does not exist,\n** set *pbExists to false before returning.\n**\n** If an error occurs, non-zero is returned. Or, if no error occurs, zero.\n*/\nstatic int sqlite3DeleteUnlinkIfExists(\n  sqlite3_vfs *pVfs,\n  const char *zFile, \n  int *pbExists\n){\n  int rc = SQLITE_ERROR;\n#if SQLITE_OS_WIN\n  if( pVfs ){\n    if( pbExists ) *pbExists = 1;\n    rc = pVfs->xDelete(pVfs, zFile, 0);\n    if( rc==SQLITE_IOERR_DELETE_NOENT ){\n      if( pbExists ) *pbExists = 0;\n      rc = SQLITE_OK;\n    }\n  }\n#else\n  assert( pVfs==0 );\n  rc = access(zFile, F_OK);\n  if( rc ){\n    if( errno==ENOENT ){ \n      if( pbExists ) *pbExists = 0;\n      rc = SQLITE_OK; \n    }\n  }else{\n    if( pbExists ) *pbExists = 1;\n    rc = unlink(zFile);\n  }\n#endif\n  return rc;\n}\n\n/*\n** Delete the database file identified by the string argument passed to this\n** function. The string must contain a filename, not an SQLite URI.\n*/\nSQLITE_API int sqlite3_delete_database(\n  const char *zFile               /* File to delete */\n){\n  char *zBuf;                     /* Buffer to sprintf() filenames to */\n  int nBuf;                       /* Size of buffer in bytes */\n  int rc = 0;                     /* System error code */\n  int i;                          /* Iterate through azFmt[] and aMFile[] */\n\n  const char *azFmt[] = { \"%s\", \"%s-journal\", \"%s-wal\", \"%s-shm\" };\n\n  struct MFile {\n    const char *zFmt;\n    int iOffset;\n    int b83;\n  } aMFile[] = {\n    { \"%s%03d\",         0,   0 },\n    { \"%s-journal%03d\", 0,   0 },\n    { \"%s-wal%03d\",     0,   0 },\n    { \"%s%03d\",         0,   1 },\n    { \"%s-journal%03d\", SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, 1 },\n    { \"%s-wal%03d\",     SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 },\n  };\n\n#ifdef SQLITE_OS_WIN\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(\"win32\");\n#else\n  sqlite3_vfs *pVfs = 0;\n#endif\n\n  /* Allocate a buffer large enough for any of the files that need to be\n  ** deleted.  */\n  nBuf = (int)strlen(zFile) + 100;\n  zBuf = (char*)sqlite3_malloc(nBuf);\n  if( zBuf==0 ) return SQLITE_NOMEM;\n\n  /* Delete both the regular and 8.3 filenames versions of the database,\n  ** journal, wal and shm files.  */\n  for(i=0; rc==0 && i<sizeof(azFmt)/sizeof(azFmt[0]); i++){\n    sqlite3_snprintf(nBuf, zBuf, azFmt[i], zFile);\n    rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);\n    if( rc==0 && i!=0 ){\n      sqlite3Delete83Name(zBuf);\n      rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);\n    }\n  }\n\n  /* Delete any multiplexor files */\n  for(i=0; rc==0 && i<sizeof(aMFile)/sizeof(aMFile[0]); i++){\n    struct MFile *p = &aMFile[i];\n    int iChunk;\n    for(iChunk=1; iChunk<=MX_CHUNK_NUMBER; iChunk++){\n      int bExists;\n      sqlite3_snprintf(nBuf, zBuf, p->zFmt, zFile, iChunk+p->iOffset);\n      if( p->b83 ) sqlite3Delete83Name(zBuf);\n      rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, &bExists);\n      if( bExists==0 || rc!=0 ) break;\n    }\n  }\n\n  sqlite3_free(zBuf);\n  return (rc ? SQLITE_ERROR : SQLITE_OK);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_demovfs.c",
    "content": "/*\n** 2010 April 7\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements an example of a simple VFS implementation that \n** omits complex features often not required or not possible on embedded\n** platforms.  Code is included to buffer writes to the journal file, \n** which can be a significant performance improvement on some embedded\n** platforms.\n**\n** OVERVIEW\n**\n**   The code in this file implements a minimal SQLite VFS that can be \n**   used on Linux and other posix-like operating systems. The following \n**   system calls are used:\n**\n**    File-system: access(), unlink(), getcwd()\n**    File IO:     open(), read(), write(), fsync(), close(), fstat()\n**    Other:       sleep(), usleep(), time()\n**\n**   The following VFS features are omitted:\n**\n**     1. File locking. The user must ensure that there is at most one\n**        connection to each database when using this VFS. Multiple\n**        connections to a single shared-cache count as a single connection\n**        for the purposes of the previous statement.\n**\n**     2. The loading of dynamic extensions (shared libraries).\n**\n**     3. Temporary files. The user must configure SQLite to use in-memory\n**        temp files when using this VFS. The easiest way to do this is to\n**        compile with:\n**\n**          -DSQLITE_TEMP_STORE=3\n**\n**     4. File truncation. As of version 3.6.24, SQLite may run without\n**        a working xTruncate() call, providing the user does not configure\n**        SQLite to use \"journal_mode=truncate\", or use both\n**        \"journal_mode=persist\" and ATTACHed databases.\n**\n**   It is assumed that the system uses UNIX-like path-names. Specifically,\n**   that '/' characters are used to separate path components and that\n**   a path-name is a relative path unless it begins with a '/'. And that\n**   no UTF-8 encoded paths are greater than 512 bytes in length.\n**\n** JOURNAL WRITE-BUFFERING\n**\n**   To commit a transaction to the database, SQLite first writes rollback\n**   information into the journal file. This usually consists of 4 steps:\n**\n**     1. The rollback information is sequentially written into the journal\n**        file, starting at the start of the file.\n**     2. The journal file is synced to disk.\n**     3. A modification is made to the first few bytes of the journal file.\n**     4. The journal file is synced to disk again.\n**\n**   Most of the data is written in step 1 using a series of calls to the\n**   VFS xWrite() method. The buffers passed to the xWrite() calls are of\n**   various sizes. For example, as of version 3.6.24, when committing a \n**   transaction that modifies 3 pages of a database file that uses 4096 \n**   byte pages residing on a media with 512 byte sectors, SQLite makes \n**   eleven calls to the xWrite() method to create the rollback journal, \n**   as follows:\n**\n**             Write offset | Bytes written\n**             ----------------------------\n**                        0            512\n**                      512              4\n**                      516           4096\n**                     4612              4\n**                     4616              4\n**                     4620           4096\n**                     8716              4\n**                     8720              4\n**                     8724           4096\n**                    12820              4\n**             ++++++++++++SYNC+++++++++++\n**                        0             12\n**             ++++++++++++SYNC+++++++++++\n**\n**   On many operating systems, this is an efficient way to write to a file.\n**   However, on some embedded systems that do not cache writes in OS \n**   buffers it is much more efficient to write data in blocks that are\n**   an integer multiple of the sector-size in size and aligned at the\n**   start of a sector.\n**\n**   To work around this, the code in this file allocates a fixed size\n**   buffer of SQLITE_DEMOVFS_BUFFERSZ using sqlite3_malloc() whenever a \n**   journal file is opened. It uses the buffer to coalesce sequential\n**   writes into aligned SQLITE_DEMOVFS_BUFFERSZ blocks. When SQLite\n**   invokes the xSync() method to sync the contents of the file to disk,\n**   all accumulated data is written out, even if it does not constitute\n**   a complete block. This means the actual IO to create the rollback \n**   journal for the example transaction above is this:\n**\n**             Write offset | Bytes written\n**             ----------------------------\n**                        0           8192\n**                     8192           4632\n**             ++++++++++++SYNC+++++++++++\n**                        0             12\n**             ++++++++++++SYNC+++++++++++\n**\n**   Much more efficient if the underlying OS is not caching write \n**   operations.\n*/\n\n#if !defined(SQLITE_TEST) || SQLITE_OS_UNIX\n\n#include \"sqlite3.h\"\n\n#include <assert.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <sys/file.h>\n#include <sys/param.h>\n#include <unistd.h>\n#include <time.h>\n#include <errno.h>\n#include <fcntl.h>\n\n/*\n** Size of the write buffer used by journal files in bytes.\n*/\n#ifndef SQLITE_DEMOVFS_BUFFERSZ\n# define SQLITE_DEMOVFS_BUFFERSZ 8192\n#endif\n\n/*\n** The maximum pathname length supported by this VFS.\n*/\n#define MAXPATHNAME 512\n\n/*\n** When using this VFS, the sqlite3_file* handles that SQLite uses are\n** actually pointers to instances of type DemoFile.\n*/\ntypedef struct DemoFile DemoFile;\nstruct DemoFile {\n  sqlite3_file base;              /* Base class. Must be first. */\n  int fd;                         /* File descriptor */\n\n  char *aBuffer;                  /* Pointer to malloc'd buffer */\n  int nBuffer;                    /* Valid bytes of data in zBuffer */\n  sqlite3_int64 iBufferOfst;      /* Offset in file of zBuffer[0] */\n};\n\n/*\n** Write directly to the file passed as the first argument. Even if the\n** file has a write-buffer (DemoFile.aBuffer), ignore it.\n*/\nstatic int demoDirectWrite(\n  DemoFile *p,                    /* File handle */\n  const void *zBuf,               /* Buffer containing data to write */\n  int iAmt,                       /* Size of data to write in bytes */\n  sqlite_int64 iOfst              /* File offset to write to */\n){\n  off_t ofst;                     /* Return value from lseek() */\n  size_t nWrite;                  /* Return value from write() */\n\n  ofst = lseek(p->fd, iOfst, SEEK_SET);\n  if( ofst!=iOfst ){\n    return SQLITE_IOERR_WRITE;\n  }\n\n  nWrite = write(p->fd, zBuf, iAmt);\n  if( nWrite!=iAmt ){\n    return SQLITE_IOERR_WRITE;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Flush the contents of the DemoFile.aBuffer buffer to disk. This is a\n** no-op if this particular file does not have a buffer (i.e. it is not\n** a journal file) or if the buffer is currently empty.\n*/\nstatic int demoFlushBuffer(DemoFile *p){\n  int rc = SQLITE_OK;\n  if( p->nBuffer ){\n    rc = demoDirectWrite(p, p->aBuffer, p->nBuffer, p->iBufferOfst);\n    p->nBuffer = 0;\n  }\n  return rc;\n}\n\n/*\n** Close a file.\n*/\nstatic int demoClose(sqlite3_file *pFile){\n  int rc;\n  DemoFile *p = (DemoFile*)pFile;\n  rc = demoFlushBuffer(p);\n  sqlite3_free(p->aBuffer);\n  close(p->fd);\n  return rc;\n}\n\n/*\n** Read data from a file.\n*/\nstatic int demoRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  DemoFile *p = (DemoFile*)pFile;\n  off_t ofst;                     /* Return value from lseek() */\n  int nRead;                      /* Return value from read() */\n  int rc;                         /* Return code from demoFlushBuffer() */\n\n  /* Flush any data in the write buffer to disk in case this operation\n  ** is trying to read data the file-region currently cached in the buffer.\n  ** It would be possible to detect this case and possibly save an \n  ** unnecessary write here, but in practice SQLite will rarely read from\n  ** a journal file when there is data cached in the write-buffer.\n  */\n  rc = demoFlushBuffer(p);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  ofst = lseek(p->fd, iOfst, SEEK_SET);\n  if( ofst!=iOfst ){\n    return SQLITE_IOERR_READ;\n  }\n  nRead = read(p->fd, zBuf, iAmt);\n\n  if( nRead==iAmt ){\n    return SQLITE_OK;\n  }else if( nRead>=0 ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n\n  return SQLITE_IOERR_READ;\n}\n\n/*\n** Write data to a crash-file.\n*/\nstatic int demoWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  DemoFile *p = (DemoFile*)pFile;\n  \n  if( p->aBuffer ){\n    char *z = (char *)zBuf;       /* Pointer to remaining data to write */\n    int n = iAmt;                 /* Number of bytes at z */\n    sqlite3_int64 i = iOfst;      /* File offset to write to */\n\n    while( n>0 ){\n      int nCopy;                  /* Number of bytes to copy into buffer */\n\n      /* If the buffer is full, or if this data is not being written directly\n      ** following the data already buffered, flush the buffer. Flushing\n      ** the buffer is a no-op if it is empty.  \n      */\n      if( p->nBuffer==SQLITE_DEMOVFS_BUFFERSZ || p->iBufferOfst+p->nBuffer!=i ){\n        int rc = demoFlushBuffer(p);\n        if( rc!=SQLITE_OK ){\n          return rc;\n        }\n      }\n      assert( p->nBuffer==0 || p->iBufferOfst+p->nBuffer==i );\n      p->iBufferOfst = i - p->nBuffer;\n\n      /* Copy as much data as possible into the buffer. */\n      nCopy = SQLITE_DEMOVFS_BUFFERSZ - p->nBuffer;\n      if( nCopy>n ){\n        nCopy = n;\n      }\n      memcpy(&p->aBuffer[p->nBuffer], z, nCopy);\n      p->nBuffer += nCopy;\n\n      n -= nCopy;\n      i += nCopy;\n      z += nCopy;\n    }\n  }else{\n    return demoDirectWrite(p, zBuf, iAmt, iOfst);\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Truncate a file. This is a no-op for this VFS (see header comments at\n** the top of the file).\n*/\nstatic int demoTruncate(sqlite3_file *pFile, sqlite_int64 size){\n#if 0\n  if( ftruncate(((DemoFile *)pFile)->fd, size) ) return SQLITE_IOERR_TRUNCATE;\n#endif\n  return SQLITE_OK;\n}\n\n/*\n** Sync the contents of the file to the persistent media.\n*/\nstatic int demoSync(sqlite3_file *pFile, int flags){\n  DemoFile *p = (DemoFile*)pFile;\n  int rc;\n\n  rc = demoFlushBuffer(p);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  rc = fsync(p->fd);\n  return (rc==0 ? SQLITE_OK : SQLITE_IOERR_FSYNC);\n}\n\n/*\n** Write the size of the file in bytes to *pSize.\n*/\nstatic int demoFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  DemoFile *p = (DemoFile*)pFile;\n  int rc;                         /* Return code from fstat() call */\n  struct stat sStat;              /* Output of fstat() call */\n\n  /* Flush the contents of the buffer to disk. As with the flush in the\n  ** demoRead() method, it would be possible to avoid this and save a write\n  ** here and there. But in practice this comes up so infrequently it is\n  ** not worth the trouble.\n  */\n  rc = demoFlushBuffer(p);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  rc = fstat(p->fd, &sStat);\n  if( rc!=0 ) return SQLITE_IOERR_FSTAT;\n  *pSize = sStat.st_size;\n  return SQLITE_OK;\n}\n\n/*\n** Locking functions. The xLock() and xUnlock() methods are both no-ops.\n** The xCheckReservedLock() always indicates that no other process holds\n** a reserved lock on the database file. This ensures that if a hot-journal\n** file is found in the file-system it is rolled back.\n*/\nstatic int demoLock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\nstatic int demoUnlock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\nstatic int demoCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n\n/*\n** No xFileControl() verbs are implemented by this VFS.\n*/\nstatic int demoFileControl(sqlite3_file *pFile, int op, void *pArg){\n  return SQLITE_OK;\n}\n\n/*\n** The xSectorSize() and xDeviceCharacteristics() methods. These two\n** may return special values allowing SQLite to optimize file-system \n** access to some extent. But it is also safe to simply return 0.\n*/\nstatic int demoSectorSize(sqlite3_file *pFile){\n  return 0;\n}\nstatic int demoDeviceCharacteristics(sqlite3_file *pFile){\n  return 0;\n}\n\n/*\n** Open a file handle.\n*/\nstatic int demoOpen(\n  sqlite3_vfs *pVfs,              /* VFS */\n  const char *zName,              /* File to open, or 0 for a temp file */\n  sqlite3_file *pFile,            /* Pointer to DemoFile struct to populate */\n  int flags,                      /* Input SQLITE_OPEN_XXX flags */\n  int *pOutFlags                  /* Output SQLITE_OPEN_XXX flags (or NULL) */\n){\n  static const sqlite3_io_methods demoio = {\n    1,                            /* iVersion */\n    demoClose,                    /* xClose */\n    demoRead,                     /* xRead */\n    demoWrite,                    /* xWrite */\n    demoTruncate,                 /* xTruncate */\n    demoSync,                     /* xSync */\n    demoFileSize,                 /* xFileSize */\n    demoLock,                     /* xLock */\n    demoUnlock,                   /* xUnlock */\n    demoCheckReservedLock,        /* xCheckReservedLock */\n    demoFileControl,              /* xFileControl */\n    demoSectorSize,               /* xSectorSize */\n    demoDeviceCharacteristics     /* xDeviceCharacteristics */\n  };\n\n  DemoFile *p = (DemoFile*)pFile; /* Populate this structure */\n  int oflags = 0;                 /* flags to pass to open() call */\n  char *aBuf = 0;\n\n  if( zName==0 ){\n    return SQLITE_IOERR;\n  }\n\n  if( flags&SQLITE_OPEN_MAIN_JOURNAL ){\n    aBuf = (char *)sqlite3_malloc(SQLITE_DEMOVFS_BUFFERSZ);\n    if( !aBuf ){\n      return SQLITE_NOMEM;\n    }\n  }\n\n  if( flags&SQLITE_OPEN_EXCLUSIVE ) oflags |= O_EXCL;\n  if( flags&SQLITE_OPEN_CREATE )    oflags |= O_CREAT;\n  if( flags&SQLITE_OPEN_READONLY )  oflags |= O_RDONLY;\n  if( flags&SQLITE_OPEN_READWRITE ) oflags |= O_RDWR;\n\n  memset(p, 0, sizeof(DemoFile));\n  p->fd = open(zName, oflags, 0600);\n  if( p->fd<0 ){\n    sqlite3_free(aBuf);\n    return SQLITE_CANTOPEN;\n  }\n  p->aBuffer = aBuf;\n\n  if( pOutFlags ){\n    *pOutFlags = flags;\n  }\n  p->base.pMethods = &demoio;\n  return SQLITE_OK;\n}\n\n/*\n** Delete the file identified by argument zPath. If the dirSync parameter\n** is non-zero, then ensure the file-system modification to delete the\n** file has been synced to disk before returning.\n*/\nstatic int demoDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc;                         /* Return code */\n\n  rc = unlink(zPath);\n  if( rc!=0 && errno==ENOENT ) return SQLITE_OK;\n\n  if( rc==0 && dirSync ){\n    int dfd;                      /* File descriptor open on directory */\n    int i;                        /* Iterator variable */\n    char zDir[MAXPATHNAME+1];     /* Name of directory containing file zPath */\n\n    /* Figure out the directory name from the path of the file deleted. */\n    sqlite3_snprintf(MAXPATHNAME, zDir, \"%s\", zPath);\n    zDir[MAXPATHNAME] = '\\0';\n    for(i=strlen(zDir); i>1 && zDir[i]!='/'; i++);\n    zDir[i] = '\\0';\n\n    /* Open a file-descriptor on the directory. Sync. Close. */\n    dfd = open(zDir, O_RDONLY, 0);\n    if( dfd<0 ){\n      rc = -1;\n    }else{\n      rc = fsync(dfd);\n      close(dfd);\n    }\n  }\n  return (rc==0 ? SQLITE_OK : SQLITE_IOERR_DELETE);\n}\n\n#ifndef F_OK\n# define F_OK 0\n#endif\n#ifndef R_OK\n# define R_OK 4\n#endif\n#ifndef W_OK\n# define W_OK 2\n#endif\n\n/*\n** Query the file-system to see if the named file exists, is readable or\n** is both readable and writable.\n*/\nstatic int demoAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  int rc;                         /* access() return code */\n  int eAccess = F_OK;             /* Second argument to access() */\n\n  assert( flags==SQLITE_ACCESS_EXISTS       /* access(zPath, F_OK) */\n       || flags==SQLITE_ACCESS_READ         /* access(zPath, R_OK) */\n       || flags==SQLITE_ACCESS_READWRITE    /* access(zPath, R_OK|W_OK) */\n  );\n\n  if( flags==SQLITE_ACCESS_READWRITE ) eAccess = R_OK|W_OK;\n  if( flags==SQLITE_ACCESS_READ )      eAccess = R_OK;\n\n  rc = access(zPath, eAccess);\n  *pResOut = (rc==0);\n  return SQLITE_OK;\n}\n\n/*\n** Argument zPath points to a nul-terminated string containing a file path.\n** If zPath is an absolute path, then it is copied as is into the output \n** buffer. Otherwise, if it is a relative path, then the equivalent full\n** path is written to the output buffer.\n**\n** This function assumes that paths are UNIX style. Specifically, that:\n**\n**   1. Path components are separated by a '/'. and \n**   2. Full paths begin with a '/' character.\n*/\nstatic int demoFullPathname(\n  sqlite3_vfs *pVfs,              /* VFS */\n  const char *zPath,              /* Input path (possibly a relative path) */\n  int nPathOut,                   /* Size of output buffer in bytes */\n  char *zPathOut                  /* Pointer to output buffer */\n){\n  char zDir[MAXPATHNAME+1];\n  if( zPath[0]=='/' ){\n    zDir[0] = '\\0';\n  }else{\n    if( getcwd(zDir, sizeof(zDir))==0 ) return SQLITE_IOERR;\n  }\n  zDir[MAXPATHNAME] = '\\0';\n\n  sqlite3_snprintf(nPathOut, zPathOut, \"%s/%s\", zDir, zPath);\n  zPathOut[nPathOut-1] = '\\0';\n\n  return SQLITE_OK;\n}\n\n/*\n** The following four VFS methods:\n**\n**   xDlOpen\n**   xDlError\n**   xDlSym\n**   xDlClose\n**\n** are supposed to implement the functionality needed by SQLite to load\n** extensions compiled as shared objects. This simple VFS does not support\n** this functionality, so the following functions are no-ops.\n*/\nstatic void *demoDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return 0;\n}\nstatic void demoDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3_snprintf(nByte, zErrMsg, \"Loadable extensions are not supported\");\n  zErrMsg[nByte-1] = '\\0';\n}\nstatic void (*demoDlSym(sqlite3_vfs *pVfs, void *pH, const char *z))(void){\n  return 0;\n}\nstatic void demoDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  return;\n}\n\n/*\n** Parameter zByte points to a buffer nByte bytes in size. Populate this\n** buffer with pseudo-random data.\n*/\nstatic int demoRandomness(sqlite3_vfs *pVfs, int nByte, char *zByte){\n  return SQLITE_OK;\n}\n\n/*\n** Sleep for at least nMicro microseconds. Return the (approximate) number \n** of microseconds slept for.\n*/\nstatic int demoSleep(sqlite3_vfs *pVfs, int nMicro){\n  sleep(nMicro / 1000000);\n  usleep(nMicro % 1000000);\n  return nMicro;\n}\n\n/*\n** Set *pTime to the current UTC time expressed as a Julian day. Return\n** SQLITE_OK if successful, or an error code otherwise.\n**\n**   http://en.wikipedia.org/wiki/Julian_day\n**\n** This implementation is not very good. The current time is rounded to\n** an integer number of seconds. Also, assuming time_t is a signed 32-bit \n** value, it will stop working some time in the year 2038 AD (the so-called\n** \"year 2038\" problem that afflicts systems that store time this way). \n*/\nstatic int demoCurrentTime(sqlite3_vfs *pVfs, double *pTime){\n  time_t t = time(0);\n  *pTime = t/86400.0 + 2440587.5; \n  return SQLITE_OK;\n}\n\n/*\n** This function returns a pointer to the VFS implemented in this file.\n** To make the VFS available to SQLite:\n**\n**   sqlite3_vfs_register(sqlite3_demovfs(), 0);\n*/\nsqlite3_vfs *sqlite3_demovfs(void){\n  static sqlite3_vfs demovfs = {\n    1,                            /* iVersion */\n    sizeof(DemoFile),             /* szOsFile */\n    MAXPATHNAME,                  /* mxPathname */\n    0,                            /* pNext */\n    \"demo\",                       /* zName */\n    0,                            /* pAppData */\n    demoOpen,                     /* xOpen */\n    demoDelete,                   /* xDelete */\n    demoAccess,                   /* xAccess */\n    demoFullPathname,             /* xFullPathname */\n    demoDlOpen,                   /* xDlOpen */\n    demoDlError,                  /* xDlError */\n    demoDlSym,                    /* xDlSym */\n    demoDlClose,                  /* xDlClose */\n    demoRandomness,               /* xRandomness */\n    demoSleep,                    /* xSleep */\n    demoCurrentTime,              /* xCurrentTime */\n  };\n  return &demovfs;\n}\n\n#endif /* !defined(SQLITE_TEST) || SQLITE_OS_UNIX */\n\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\n#if SQLITE_OS_UNIX\nstatic int SQLITE_TCLAPI register_demovfs(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_vfs_register(sqlite3_demovfs(), 1);\n  return TCL_OK;\n}\nstatic int SQLITE_TCLAPI unregister_demovfs(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_vfs_unregister(sqlite3_demovfs());\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest_demovfs_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"register_demovfs\", register_demovfs, 0, 0);\n  Tcl_CreateObjCommand(interp, \"unregister_demovfs\", unregister_demovfs, 0, 0);\n  return TCL_OK;\n}\n\n#else\nint Sqlitetest_demovfs_Init(Tcl_Interp *interp){ return TCL_OK; }\n#endif\n\n#endif /* SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_devsym.c",
    "content": "/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that modified the OS layer in order to simulate\n** different device types (by overriding the return values of the \n** xDeviceCharacteristics() and xSectorSize() methods).\n*/\n#if SQLITE_TEST          /* This file is used for testing only */\n\n#include \"sqlite3.h\"\n#include \"sqliteInt.h\"\n\n/*\n** Maximum pathname length supported by the devsym backend.\n*/\n#define DEVSYM_MAX_PATHNAME 512\n\n/*\n** Name used to identify this VFS.\n*/\n#define DEVSYM_VFS_NAME \"devsym\"\n#define WRITECRASH_NAME \"writecrash\"\n\ntypedef struct devsym_file devsym_file;\nstruct devsym_file {\n  sqlite3_file base;\n  sqlite3_file *pReal;\n};\n\n/*\n** Method declarations for devsym_file.\n*/\nstatic int devsymClose(sqlite3_file*);\nstatic int devsymRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int devsymWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int devsymTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int devsymSync(sqlite3_file*, int flags);\nstatic int devsymFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int devsymLock(sqlite3_file*, int);\nstatic int devsymUnlock(sqlite3_file*, int);\nstatic int devsymCheckReservedLock(sqlite3_file*, int *);\nstatic int devsymFileControl(sqlite3_file*, int op, void *pArg);\nstatic int devsymSectorSize(sqlite3_file*);\nstatic int devsymDeviceCharacteristics(sqlite3_file*);\nstatic int devsymShmLock(sqlite3_file*,int,int,int);\nstatic int devsymShmMap(sqlite3_file*,int,int,int, void volatile **);\nstatic void devsymShmBarrier(sqlite3_file*);\nstatic int devsymShmUnmap(sqlite3_file*,int);\n\n/*\n** Method declarations for devsym_vfs.\n*/\nstatic int devsymOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int devsymDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int devsymAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int devsymFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nstatic void *devsymDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void devsymDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*devsymDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);\nstatic void devsymDlClose(sqlite3_vfs*, void*);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nstatic int devsymRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int devsymSleep(sqlite3_vfs*, int microseconds);\nstatic int devsymCurrentTime(sqlite3_vfs*, double*);\n\nstruct DevsymGlobal {\n  sqlite3_vfs *pVfs;\n  int iDeviceChar;\n  int iSectorSize;\n  int nWriteCrash;\n};\nstruct DevsymGlobal g = {0, 0, 512, 0};\n\n/*\n** Close an devsym-file.\n*/\nstatic int devsymClose(sqlite3_file *pFile){\n  devsym_file *p = (devsym_file *)pFile;\n  sqlite3OsClose(p->pReal);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from an devsym-file.\n*/\nstatic int devsymRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);\n}\n\n/*\n** Write data to an devsym-file.\n*/\nstatic int devsymWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);\n}\n\n/*\n** Truncate an devsym-file.\n*/\nstatic int devsymTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsTruncate(p->pReal, size);\n}\n\n/*\n** Sync an devsym-file.\n*/\nstatic int devsymSync(sqlite3_file *pFile, int flags){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsSync(p->pReal, flags);\n}\n\n/*\n** Return the current file-size of an devsym-file.\n*/\nstatic int devsymFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsFileSize(p->pReal, pSize);\n}\n\n/*\n** Lock an devsym-file.\n*/\nstatic int devsymLock(sqlite3_file *pFile, int eLock){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsLock(p->pReal, eLock);\n}\n\n/*\n** Unlock an devsym-file.\n*/\nstatic int devsymUnlock(sqlite3_file *pFile, int eLock){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsUnlock(p->pReal, eLock);\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an devsym-file.\n*/\nstatic int devsymCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsCheckReservedLock(p->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an devsym-file.\n*/\nstatic int devsymFileControl(sqlite3_file *pFile, int op, void *pArg){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsFileControl(p->pReal, op, pArg);\n}\n\n/*\n** Return the sector-size in bytes for an devsym-file.\n*/\nstatic int devsymSectorSize(sqlite3_file *pFile){\n  return g.iSectorSize;\n}\n\n/*\n** Return the device characteristic flags supported by an devsym-file.\n*/\nstatic int devsymDeviceCharacteristics(sqlite3_file *pFile){\n  return g.iDeviceChar;\n}\n\n/*\n** Shared-memory methods are all pass-thrus.\n*/\nstatic int devsymShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsShmLock(p->pReal, ofst, n, flags);\n}\nstatic int devsymShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  void volatile **pp\n){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n}\nstatic void devsymShmBarrier(sqlite3_file *pFile){\n  devsym_file *p = (devsym_file *)pFile;\n  sqlite3OsShmBarrier(p->pReal);\n}\nstatic int devsymShmUnmap(sqlite3_file *pFile, int delFlag){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsShmUnmap(p->pReal, delFlag);\n}\n\n\n\n/*\n** Open an devsym file handle.\n*/\nstatic int devsymOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\nstatic sqlite3_io_methods devsym_io_methods = {\n  2,                                /* iVersion */\n  devsymClose,                      /* xClose */\n  devsymRead,                       /* xRead */\n  devsymWrite,                      /* xWrite */\n  devsymTruncate,                   /* xTruncate */\n  devsymSync,                       /* xSync */\n  devsymFileSize,                   /* xFileSize */\n  devsymLock,                       /* xLock */\n  devsymUnlock,                     /* xUnlock */\n  devsymCheckReservedLock,          /* xCheckReservedLock */\n  devsymFileControl,                /* xFileControl */\n  devsymSectorSize,                 /* xSectorSize */\n  devsymDeviceCharacteristics,      /* xDeviceCharacteristics */\n  devsymShmMap,                     /* xShmMap */\n  devsymShmLock,                    /* xShmLock */\n  devsymShmBarrier,                 /* xShmBarrier */\n  devsymShmUnmap                    /* xShmUnmap */\n};\n\n  int rc;\n  devsym_file *p = (devsym_file *)pFile;\n  p->pReal = (sqlite3_file *)&p[1];\n  rc = sqlite3OsOpen(g.pVfs, zName, p->pReal, flags, pOutFlags);\n  if( p->pReal->pMethods ){\n    pFile->pMethods = &devsym_io_methods;\n  }\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int devsymDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  return sqlite3OsDelete(g.pVfs, zPath, dirSync);\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int devsymAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  return sqlite3OsAccess(g.pVfs, zPath, flags, pResOut);\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int devsymFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  return sqlite3OsFullPathname(g.pVfs, zPath, nOut, zOut);\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *devsymDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return sqlite3OsDlOpen(g.pVfs, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void devsymDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3OsDlError(g.pVfs, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*devsymDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return sqlite3OsDlSym(g.pVfs, p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void devsymDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3OsDlClose(g.pVfs, pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int devsymRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return sqlite3OsRandomness(g.pVfs, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int devsymSleep(sqlite3_vfs *pVfs, int nMicro){\n  return sqlite3OsSleep(g.pVfs, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return g.pVfs->xCurrentTime(g.pVfs, pTimeOut);\n}\n\n/*\n** Return the sector-size in bytes for an writecrash-file.\n*/\nstatic int writecrashSectorSize(sqlite3_file *pFile){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsSectorSize(p->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an writecrash-file.\n*/\nstatic int writecrashDeviceCharacteristics(sqlite3_file *pFile){\n  devsym_file *p = (devsym_file *)pFile;\n  return sqlite3OsDeviceCharacteristics(p->pReal);\n}\n\n/*\n** Write data to an writecrash-file.\n*/\nstatic int writecrashWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  devsym_file *p = (devsym_file *)pFile;\n  if( g.nWriteCrash>0 ){\n    g.nWriteCrash--;\n    if( g.nWriteCrash==0 ) abort();\n  }\n  return sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);\n}\n\n/*\n** Open an writecrash file handle.\n*/\nstatic int writecrashOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\nstatic sqlite3_io_methods writecrash_io_methods = {\n  2,                                /* iVersion */\n  devsymClose,                      /* xClose */\n  devsymRead,                       /* xRead */\n  writecrashWrite,                  /* xWrite */\n  devsymTruncate,                   /* xTruncate */\n  devsymSync,                       /* xSync */\n  devsymFileSize,                   /* xFileSize */\n  devsymLock,                       /* xLock */\n  devsymUnlock,                     /* xUnlock */\n  devsymCheckReservedLock,          /* xCheckReservedLock */\n  devsymFileControl,                /* xFileControl */\n  writecrashSectorSize,             /* xSectorSize */\n  writecrashDeviceCharacteristics,  /* xDeviceCharacteristics */\n  devsymShmMap,                     /* xShmMap */\n  devsymShmLock,                    /* xShmLock */\n  devsymShmBarrier,                 /* xShmBarrier */\n  devsymShmUnmap                    /* xShmUnmap */\n};\n\n  int rc;\n  devsym_file *p = (devsym_file *)pFile;\n  p->pReal = (sqlite3_file *)&p[1];\n  rc = sqlite3OsOpen(g.pVfs, zName, p->pReal, flags, pOutFlags);\n  if( p->pReal->pMethods ){\n    pFile->pMethods = &writecrash_io_methods;\n  }\n  return rc;\n}\n\nstatic sqlite3_vfs devsym_vfs = {\n  2,                     /* iVersion */\n  sizeof(devsym_file),      /* szOsFile */\n  DEVSYM_MAX_PATHNAME,      /* mxPathname */\n  0,                     /* pNext */\n  DEVSYM_VFS_NAME,          /* zName */\n  0,                     /* pAppData */\n  devsymOpen,               /* xOpen */\n  devsymDelete,             /* xDelete */\n  devsymAccess,             /* xAccess */\n  devsymFullPathname,       /* xFullPathname */\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  devsymDlOpen,             /* xDlOpen */\n  devsymDlError,            /* xDlError */\n  devsymDlSym,              /* xDlSym */\n  devsymDlClose,            /* xDlClose */\n#else\n  0,                        /* xDlOpen */\n  0,                        /* xDlError */\n  0,                        /* xDlSym */\n  0,                        /* xDlClose */\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n  devsymRandomness,         /* xRandomness */\n  devsymSleep,              /* xSleep */\n  devsymCurrentTime,        /* xCurrentTime */\n  0,                        /* xGetLastError */\n  0                         /* xCurrentTimeInt64 */\n};\n\nstatic sqlite3_vfs writecrash_vfs = {\n  2,                     /* iVersion */\n  sizeof(devsym_file),      /* szOsFile */\n  DEVSYM_MAX_PATHNAME,      /* mxPathname */\n  0,                     /* pNext */\n  WRITECRASH_NAME,          /* zName */\n  0,                     /* pAppData */\n  writecrashOpen,           /* xOpen */\n  devsymDelete,             /* xDelete */\n  devsymAccess,             /* xAccess */\n  devsymFullPathname,       /* xFullPathname */\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n  devsymDlOpen,             /* xDlOpen */\n  devsymDlError,            /* xDlError */\n  devsymDlSym,              /* xDlSym */\n  devsymDlClose,            /* xDlClose */\n#else\n  0,                        /* xDlOpen */\n  0,                        /* xDlError */\n  0,                        /* xDlSym */\n  0,                        /* xDlClose */\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n  devsymRandomness,         /* xRandomness */\n  devsymSleep,              /* xSleep */\n  devsymCurrentTime,        /* xCurrentTime */\n  0,                        /* xGetLastError */\n  0                         /* xCurrentTimeInt64 */\n};\n\n\n/*\n** This procedure registers the devsym vfs with SQLite. If the argument is\n** true, the devsym vfs becomes the new default vfs. It is the only publicly\n** available function in this file.\n*/\nvoid devsym_register(int iDeviceChar, int iSectorSize){\n\n  if( g.pVfs==0 ){\n    g.pVfs = sqlite3_vfs_find(0);\n    devsym_vfs.szOsFile += g.pVfs->szOsFile;\n    writecrash_vfs.szOsFile += g.pVfs->szOsFile;\n    sqlite3_vfs_register(&devsym_vfs, 0);\n    sqlite3_vfs_register(&writecrash_vfs, 0);\n  }\n  if( iDeviceChar>=0 ){\n    g.iDeviceChar = iDeviceChar;\n  }else{\n    g.iDeviceChar = 0;\n  }\n  if( iSectorSize>=0 ){\n    g.iSectorSize = iSectorSize;\n  }else{\n    g.iSectorSize = 512;\n  }\n}\n\nvoid devsym_unregister(){\n  sqlite3_vfs_unregister(&devsym_vfs);\n  g.pVfs = 0;\n  g.iDeviceChar = 0;\n  g.iSectorSize = 0;\n}\n\nvoid devsym_crash_on_write(int nWrite){\n  if( g.pVfs==0 ){\n    g.pVfs = sqlite3_vfs_find(0);\n    devsym_vfs.szOsFile += g.pVfs->szOsFile;\n    writecrash_vfs.szOsFile += g.pVfs->szOsFile;\n    sqlite3_vfs_register(&devsym_vfs, 0);\n    sqlite3_vfs_register(&writecrash_vfs, 0);\n  }\n  g.nWriteCrash = nWrite;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_fs.c",
    "content": "/*\n** 2013 Jan 11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the virtual table interfaces.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n**\n** The FS virtual table is created as follows:\n**\n**   CREATE VIRTUAL TABLE tbl USING fs(idx);\n**\n** where idx is the name of a table in the db with 2 columns.  The virtual\n** table also has two columns - file path and file contents.\n**\n** The first column of table idx must be an IPK, and the second contains file\n** paths. For example:\n**\n**   CREATE TABLE idx(id INTEGER PRIMARY KEY, path TEXT);\n**   INSERT INTO idx VALUES(4, '/etc/passwd');\n**\n** Adding the row to the idx table automatically creates a row in the \n** virtual table with rowid=4, path=/etc/passwd and a text field that \n** contains data read from file /etc/passwd on disk.\n**\n*************************************************************************\n** Virtual table module \"fsdir\"\n**\n** This module is designed to be used as a read-only eponymous virtual table.\n** Its schema is as follows:\n**\n**   CREATE TABLE fsdir(dir TEXT, name TEXT);\n**\n** When queried, a WHERE term of the form \"dir = $dir\" must be provided. The\n** virtual table then appears to have one row for each entry in file-system\n** directory $dir. Column dir contains a copy of $dir, and column \"name\"\n** contains the name of the directory entry.\n**\n** If the specified $dir cannot be opened or is not a directory, it is not\n** an error. The virtual table appears to be empty in this case.\n**\n*************************************************************************\n** Virtual table module \"fstree\"\n**\n** This module is also a read-only eponymous virtual table with the \n** following schema:\n**\n**   CREATE TABLE fstree(path TEXT, size INT, data BLOB);\n**\n** Running a \"SELECT * FROM fstree\" query on this table returns the entire\n** contents of the file-system, starting at \"/\". To restrict the search\n** space, the virtual table supports LIKE and GLOB constraints on the\n** 'path' column. For example:\n**\n**   SELECT * FROM fstree WHERE path LIKE '/home/dan/sqlite/%'\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n\n#if SQLITE_OS_UNIX || defined(__MINGW_H)\n# include <unistd.h>\n# include <dirent.h>\n# ifndef DIRENT\n#  define DIRENT dirent\n# endif\n#endif\n#if SQLITE_OS_WIN\n# include <io.h>\n# if !defined(__MINGW_H)\n#  include \"test_windirent.h\"\n# endif\n# ifndef S_ISREG\n#  define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)\n# endif\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\ntypedef struct fs_vtab fs_vtab;\ntypedef struct fs_cursor fs_cursor;\n\n/* \n** A fs virtual-table object \n*/\nstruct fs_vtab {\n  sqlite3_vtab base;\n  sqlite3 *db;\n  char *zDb;                      /* Name of db containing zTbl */\n  char *zTbl;                     /* Name of docid->file map table */\n};\n\n/* A fs cursor object */\nstruct fs_cursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;\n  char *zBuf;\n  int nBuf;\n  int nAlloc;\n};\n\n/*************************************************************************\n** Start of fsdir implementation.\n*/\ntypedef struct FsdirVtab FsdirVtab;\ntypedef struct FsdirCsr FsdirCsr;\nstruct FsdirVtab {\n  sqlite3_vtab base;\n};\n\nstruct FsdirCsr {\n  sqlite3_vtab_cursor base;\n  char *zDir;                     /* Buffer containing directory scanned */\n  DIR *pDir;                      /* Open directory */\n  sqlite3_int64 iRowid;\n  struct DIRENT entry;            /* Current entry */\n};\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the fsdir virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fs\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> other module argument fields.\n*/\nstatic int fsdirConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  FsdirVtab *pTab;\n\n  if( argc!=3 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of arguments\");\n    return SQLITE_ERROR;\n  }\n\n  pTab = (FsdirVtab *)sqlite3_malloc(sizeof(FsdirVtab));\n  if( !pTab ) return SQLITE_NOMEM;\n  memset(pTab, 0, sizeof(FsdirVtab));\n\n  *ppVtab = &pTab->base;\n  sqlite3_declare_vtab(db, \"CREATE TABLE xyz(dir, name);\");\n\n  return SQLITE_OK;\n}\n\n/*\n** xDestroy/xDisconnect implementation.\n*/\nstatic int fsdirDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex implementation. The only constraint supported is:\n**\n**   (dir = ?)\n*/\nstatic int fsdirBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int ii;\n\n  pIdxInfo->estimatedCost = 1000000000.0;\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint const *p = &pIdxInfo->aConstraint[ii];\n    if( p->iColumn==0 && p->usable && p->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      struct sqlite3_index_constraint_usage *pUsage;\n      pUsage = &pIdxInfo->aConstraintUsage[ii];\n      pUsage->omit = 1;\n      pUsage->argvIndex = 1;\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->estimatedCost = 1.0;\n      break;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xOpen implementation.\n**\n** Open a new fsdir cursor.\n*/\nstatic int fsdirOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  FsdirCsr *pCur;\n  /* Allocate an extra 256 bytes because it is undefined how big dirent.d_name\n  ** is and we need enough space.  Linux provides plenty already, but\n  ** Solaris only provides one byte. */\n  pCur = (FsdirCsr*)sqlite3_malloc(sizeof(FsdirCsr)+256);\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(FsdirCsr));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a fsdir cursor.\n*/\nstatic int fsdirClose(sqlite3_vtab_cursor *cur){\n  FsdirCsr *pCur = (FsdirCsr*)cur;\n  if( pCur->pDir ) closedir(pCur->pDir);\n  sqlite3_free(pCur->zDir);\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Skip the cursor to the next entry.\n*/\nstatic int fsdirNext(sqlite3_vtab_cursor *cur){\n  FsdirCsr *pCsr = (FsdirCsr*)cur;\n\n  if( pCsr->pDir ){\n    struct DIRENT *pRes = 0;\n#if defined(__MINGW_H)\n    pRes = readdir(pCsr->pDir);\n    if( pRes!=0 ){\n      memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT));\n    }\n#else\n    readdir_r(pCsr->pDir, &pCsr->entry, &pRes);\n#endif\n    if( pRes==0 ){\n      closedir(pCsr->pDir);\n      pCsr->pDir = 0;\n    }\n    pCsr->iRowid++;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xFilter method implementation.\n*/\nstatic int fsdirFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  FsdirCsr *pCsr = (FsdirCsr*)pVtabCursor;\n  const char *zDir;\n  int nDir;\n\n\n  if( idxNum!=1 || argc!=1 ){\n    return SQLITE_ERROR;\n  }\n\n  pCsr->iRowid = 0;\n  sqlite3_free(pCsr->zDir);\n  if( pCsr->pDir ){\n    closedir(pCsr->pDir);\n    pCsr->pDir = 0;\n  }\n\n  zDir = (const char*)sqlite3_value_text(argv[0]);\n  nDir = sqlite3_value_bytes(argv[0]);\n  pCsr->zDir = sqlite3_malloc(nDir+1);\n  if( pCsr->zDir==0 ) return SQLITE_NOMEM;\n  memcpy(pCsr->zDir, zDir, nDir+1);\n\n  pCsr->pDir = opendir(pCsr->zDir);\n  return fsdirNext(pVtabCursor); \n}\n\n/*\n** xEof method implementation.\n*/\nstatic int fsdirEof(sqlite3_vtab_cursor *cur){\n  FsdirCsr *pCsr = (FsdirCsr*)cur;\n  return pCsr->pDir==0;\n}\n\n/*\n** xColumn method implementation.\n*/\nstatic int fsdirColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  FsdirCsr *pCsr = (FsdirCsr*)cur;\n  switch( i ){\n    case 0: /* dir */\n      sqlite3_result_text(ctx, pCsr->zDir, -1, SQLITE_STATIC);\n      break;\n\n    case 1: /* name */\n      sqlite3_result_text(ctx, pCsr->entry.d_name, -1, SQLITE_TRANSIENT);\n      break;\n\n    default:\n      assert( 0 );\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid method implementation.\n*/\nstatic int fsdirRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  FsdirCsr *pCsr = (FsdirCsr*)cur;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n/*\n** End of fsdir implementation.\n*************************************************************************/\n\n/*************************************************************************\n** Start of fstree implementation.\n*/\ntypedef struct FstreeVtab FstreeVtab;\ntypedef struct FstreeCsr FstreeCsr;\nstruct FstreeVtab {\n  sqlite3_vtab base;\n  sqlite3 *db;\n};\n\nstruct FstreeCsr {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pStmt;            /* Statement to list paths */\n  int fd;                         /* File descriptor open on current path */\n};\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the fstree virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fs\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> other module argument fields.\n*/\nstatic int fstreeConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  FstreeVtab *pTab;\n\n  if( argc!=3 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of arguments\");\n    return SQLITE_ERROR;\n  }\n\n  pTab = (FstreeVtab *)sqlite3_malloc(sizeof(FstreeVtab));\n  if( !pTab ) return SQLITE_NOMEM;\n  memset(pTab, 0, sizeof(FstreeVtab));\n  pTab->db = db;\n\n  *ppVtab = &pTab->base;\n  sqlite3_declare_vtab(db, \"CREATE TABLE xyz(path, size, data);\");\n\n  return SQLITE_OK;\n}\n\n/*\n** xDestroy/xDisconnect implementation.\n*/\nstatic int fstreeDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n\n/*\n** xBestIndex implementation. The only constraint supported is:\n**\n**   (dir = ?)\n*/\nstatic int fstreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int ii;\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint const *p = &pIdxInfo->aConstraint[ii];\n    if( p->iColumn==0 && p->usable && (\n          p->op==SQLITE_INDEX_CONSTRAINT_GLOB\n       || p->op==SQLITE_INDEX_CONSTRAINT_LIKE\n       || p->op==SQLITE_INDEX_CONSTRAINT_EQ\n    )){\n      struct sqlite3_index_constraint_usage *pUsage;\n      pUsage = &pIdxInfo->aConstraintUsage[ii];\n      pIdxInfo->idxNum = p->op;\n      pUsage->argvIndex = 1;\n      pIdxInfo->estimatedCost = 100000.0;\n      return SQLITE_OK;\n    }\n  }\n\n  pIdxInfo->estimatedCost = 1000000000.0;\n  return SQLITE_OK;\n}\n\n/*\n** xOpen implementation.\n**\n** Open a new fstree cursor.\n*/\nstatic int fstreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  FstreeCsr *pCur;\n  pCur = (FstreeCsr*)sqlite3_malloc(sizeof(FstreeCsr));\n  if( pCur==0 ) return SQLITE_NOMEM;\n  memset(pCur, 0, sizeof(FstreeCsr));\n  pCur->fd = -1;\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\nstatic void fstreeCloseFd(FstreeCsr *pCsr){\n  if( pCsr->fd>=0 ){\n    close(pCsr->fd);\n    pCsr->fd = -1;\n  }\n}\n\n/*\n** Close a fstree cursor.\n*/\nstatic int fstreeClose(sqlite3_vtab_cursor *cur){\n  FstreeCsr *pCsr = (FstreeCsr*)cur;\n  sqlite3_finalize(pCsr->pStmt);\n  fstreeCloseFd(pCsr);\n  sqlite3_free(pCsr);\n  return SQLITE_OK;\n}\n\n/*\n** Skip the cursor to the next entry.\n*/\nstatic int fstreeNext(sqlite3_vtab_cursor *cur){\n  FstreeCsr *pCsr = (FstreeCsr*)cur;\n  int rc;\n\n  fstreeCloseFd(pCsr);\n  rc = sqlite3_step(pCsr->pStmt);\n  if( rc!=SQLITE_ROW ){\n    rc = sqlite3_finalize(pCsr->pStmt);\n    pCsr->pStmt = 0;\n  }else{\n    rc = SQLITE_OK;\n    pCsr->fd = open((const char*)sqlite3_column_text(pCsr->pStmt, 0), O_RDONLY);\n  }\n\n  return rc;\n}\n\n/*\n** xFilter method implementation.\n*/\nstatic int fstreeFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  FstreeCsr *pCsr = (FstreeCsr*)pVtabCursor;\n  FstreeVtab *pTab = (FstreeVtab*)(pCsr->base.pVtab);\n  int rc;\n  const char *zSql = \n\"WITH r(d) AS (\"\n\"  SELECT CASE WHEN dir=?2 THEN ?3 ELSE dir END || '/' || name \"\n\"    FROM fsdir WHERE dir=?1 AND name NOT LIKE '.%'\"\n\"  UNION ALL\"\n\"  SELECT dir || '/' || name FROM r, fsdir WHERE dir=d AND name NOT LIKE '.%'\"\n\") SELECT d FROM r;\";\n\n  char *zRoot;\n  int nRoot;\n  char *zPrefix;\n  int nPrefix;\n  const char *zDir;\n  int nDir;\n  char aWild[2] = { '\\0', '\\0' };\n\n#if SQLITE_OS_WIN\n  const char *zDrive = windirent_getenv(\"fstreeDrive\");\n  if( zDrive==0 ){\n    zDrive = windirent_getenv(\"SystemDrive\");\n  }\n  zRoot = sqlite3_mprintf(\"%s%c\", zDrive, '/');\n  nRoot = sqlite3Strlen30(zRoot);\n  zPrefix = sqlite3_mprintf(\"%s\", zDrive);\n  nPrefix = sqlite3Strlen30(zPrefix);\n#else\n  zRoot = \"/\";\n  nRoot = 1;\n  zPrefix = \"\";\n  nPrefix = 0;\n#endif\n\n  zDir = zRoot;\n  nDir = nRoot;\n\n  fstreeCloseFd(pCsr);\n  sqlite3_finalize(pCsr->pStmt);\n  pCsr->pStmt = 0;\n  rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  if( idxNum ){\n    const char *zQuery = (const char*)sqlite3_value_text(argv[0]);\n    switch( idxNum ){\n      case SQLITE_INDEX_CONSTRAINT_GLOB:\n        aWild[0] = '*';\n        aWild[1] = '?';\n        break;\n      case SQLITE_INDEX_CONSTRAINT_LIKE:\n        aWild[0] = '_';\n        aWild[1] = '%';\n        break;\n    }\n\n    if( sqlite3_strnicmp(zQuery, zPrefix, nPrefix)==0 ){\n      int i;\n      for(i=nPrefix; zQuery[i]; i++){\n        if( zQuery[i]==aWild[0] || zQuery[i]==aWild[1] ) break;\n        if( zQuery[i]=='/' ) nDir = i;\n      }\n      zDir = zQuery;\n    }\n  }\n  if( nDir==0 ) nDir = 1;\n\n  sqlite3_bind_text(pCsr->pStmt, 1, zDir, nDir, SQLITE_TRANSIENT);\n  sqlite3_bind_text(pCsr->pStmt, 2, zRoot, nRoot, SQLITE_TRANSIENT);\n  sqlite3_bind_text(pCsr->pStmt, 3, zPrefix, nPrefix, SQLITE_TRANSIENT);\n\n#if SQLITE_OS_WIN\n  sqlite3_free(zPrefix);\n  sqlite3_free(zRoot);\n#endif\n\n  return fstreeNext(pVtabCursor); \n}\n\n/*\n** xEof method implementation.\n*/\nstatic int fstreeEof(sqlite3_vtab_cursor *cur){\n  FstreeCsr *pCsr = (FstreeCsr*)cur;\n  return pCsr->pStmt==0;\n}\n\n/*\n** xColumn method implementation.\n*/\nstatic int fstreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  FstreeCsr *pCsr = (FstreeCsr*)cur;\n  if( i==0 ){      /* path */\n    sqlite3_result_value(ctx, sqlite3_column_value(pCsr->pStmt, 0));\n  }else{\n    struct stat sBuf;\n    fstat(pCsr->fd, &sBuf);\n\n    if( S_ISREG(sBuf.st_mode) ){\n      if( i==1 ){\n        sqlite3_result_int64(ctx, sBuf.st_size);\n      }else{\n        int nRead;\n        char *aBuf = sqlite3_malloc(sBuf.st_mode+1);\n        if( !aBuf ) return SQLITE_NOMEM;\n        nRead = read(pCsr->fd, aBuf, sBuf.st_mode);\n        if( nRead!=sBuf.st_mode ){\n          return SQLITE_IOERR;\n        }\n        sqlite3_result_blob(ctx, aBuf, nRead, SQLITE_TRANSIENT);\n        sqlite3_free(aBuf);\n      }\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** xRowid method implementation.\n*/\nstatic int fstreeRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  *pRowid = 0;\n  return SQLITE_OK;\n}\n/*\n** End of fstree implementation.\n*************************************************************************/\n\n\n\n\n/*\n** This function is the implementation of both the xConnect and xCreate\n** methods of the fs virtual table.\n**\n** The argv[] array contains the following:\n**\n**   argv[0]   -> module name  (\"fs\")\n**   argv[1]   -> database name\n**   argv[2]   -> table name\n**   argv[...] -> other module argument fields.\n*/\nstatic int fsConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  fs_vtab *pVtab;\n  int nByte;\n  const char *zTbl;\n  const char *zDb = argv[1];\n\n  if( argc!=4 ){\n    *pzErr = sqlite3_mprintf(\"wrong number of arguments\");\n    return SQLITE_ERROR;\n  }\n  zTbl = argv[3];\n\n  nByte = sizeof(fs_vtab) + (int)strlen(zTbl) + 1 + (int)strlen(zDb) + 1;\n  pVtab = (fs_vtab *)sqlite3MallocZero( nByte );\n  if( !pVtab ) return SQLITE_NOMEM;\n\n  pVtab->zTbl = (char *)&pVtab[1];\n  pVtab->zDb = &pVtab->zTbl[strlen(zTbl)+1];\n  pVtab->db = db;\n  memcpy(pVtab->zTbl, zTbl, strlen(zTbl));\n  memcpy(pVtab->zDb, zDb, strlen(zDb));\n  *ppVtab = &pVtab->base;\n  sqlite3_declare_vtab(db, \"CREATE TABLE x(path TEXT, data TEXT)\");\n\n  return SQLITE_OK;\n}\n/* Note that for this virtual table, the xCreate and xConnect\n** methods are identical. */\n\nstatic int fsDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n/* The xDisconnect and xDestroy methods are also the same */\n\n/*\n** Open a new fs cursor.\n*/\nstatic int fsOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  fs_cursor *pCur;\n  pCur = sqlite3MallocZero(sizeof(fs_cursor));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a fs cursor.\n*/\nstatic int fsClose(sqlite3_vtab_cursor *cur){\n  fs_cursor *pCur = (fs_cursor *)cur;\n  sqlite3_finalize(pCur->pStmt);\n  sqlite3_free(pCur->zBuf);\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\nstatic int fsNext(sqlite3_vtab_cursor *cur){\n  fs_cursor *pCur = (fs_cursor *)cur;\n  int rc;\n\n  rc = sqlite3_step(pCur->pStmt);\n  if( rc==SQLITE_ROW || rc==SQLITE_DONE ) rc = SQLITE_OK;\n\n  return rc;\n}\n\nstatic int fsFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  int rc;\n  fs_cursor *pCur = (fs_cursor *)pVtabCursor;\n  fs_vtab *p = (fs_vtab *)(pVtabCursor->pVtab);\n\n  assert( (idxNum==0 && argc==0) || (idxNum==1 && argc==1) );\n  if( idxNum==1 ){\n    char *zStmt = sqlite3_mprintf(\n        \"SELECT * FROM %Q.%Q WHERE rowid=?\", p->zDb, p->zTbl);\n    if( !zStmt ) return SQLITE_NOMEM;\n    rc = sqlite3_prepare_v2(p->db, zStmt, -1, &pCur->pStmt, 0);\n    sqlite3_free(zStmt);\n    if( rc==SQLITE_OK ){\n      sqlite3_bind_value(pCur->pStmt, 1, argv[0]);\n    }\n  }else{\n    char *zStmt = sqlite3_mprintf(\"SELECT * FROM %Q.%Q\", p->zDb, p->zTbl);\n    if( !zStmt ) return SQLITE_NOMEM;\n    rc = sqlite3_prepare_v2(p->db, zStmt, -1, &pCur->pStmt, 0);\n    sqlite3_free(zStmt);\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = fsNext(pVtabCursor); \n  }\n  return rc;\n}\n\nstatic int fsColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  fs_cursor *pCur = (fs_cursor*)cur;\n\n  assert( i==0 || i==1 || i==2 );\n  if( i==0 ){\n    sqlite3_result_value(ctx, sqlite3_column_value(pCur->pStmt, 0));\n  }else{\n    const char *zFile = (const char *)sqlite3_column_text(pCur->pStmt, 1);\n    struct stat sbuf;\n    int fd;\n\n    int n;\n    fd = open(zFile, O_RDONLY);\n    if( fd<0 ) return SQLITE_IOERR;\n    fstat(fd, &sbuf);\n\n    if( sbuf.st_size>=pCur->nAlloc ){\n      int nNew = sbuf.st_size*2;\n      char *zNew;\n      if( nNew<1024 ) nNew = 1024;\n\n      zNew = sqlite3Realloc(pCur->zBuf, nNew);\n      if( zNew==0 ){\n        close(fd);\n        return SQLITE_NOMEM;\n      }\n      pCur->zBuf = zNew;\n      pCur->nAlloc = nNew;\n    }\n\n    n = (int)read(fd, pCur->zBuf, sbuf.st_size);\n    close(fd);\n    if( n!=sbuf.st_size ) return SQLITE_ERROR;\n    pCur->nBuf = sbuf.st_size;\n    pCur->zBuf[pCur->nBuf] = '\\0';\n\n    sqlite3_result_text(ctx, pCur->zBuf, -1, SQLITE_TRANSIENT);\n  }\n  return SQLITE_OK;\n}\n\nstatic int fsRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  fs_cursor *pCur = (fs_cursor*)cur;\n  *pRowid = sqlite3_column_int64(pCur->pStmt, 0);\n  return SQLITE_OK;\n}\n\nstatic int fsEof(sqlite3_vtab_cursor *cur){\n  fs_cursor *pCur = (fs_cursor*)cur;\n  return (sqlite3_data_count(pCur->pStmt)==0);\n}\n\nstatic int fsBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  int ii;\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii];\n    if( pCons->iColumn<0 && pCons->usable\n           && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ ){\n      struct sqlite3_index_constraint_usage *pUsage;\n      pUsage = &pIdxInfo->aConstraintUsage[ii];\n      pUsage->omit = 0;\n      pUsage->argvIndex = 1;\n      pIdxInfo->idxNum = 1;\n      pIdxInfo->estimatedCost = 1.0;\n      break;\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that provides read-only access to a\n** Tcl global variable namespace.\n*/\nstatic sqlite3_module fsModule = {\n  0,                         /* iVersion */\n  fsConnect,\n  fsConnect,\n  fsBestIndex,\n  fsDisconnect, \n  fsDisconnect,\n  fsOpen,                      /* xOpen - open a cursor */\n  fsClose,                     /* xClose - close a cursor */\n  fsFilter,                    /* xFilter - configure scan constraints */\n  fsNext,                      /* xNext - advance a cursor */\n  fsEof,                       /* xEof - check for end of scan */\n  fsColumn,                    /* xColumn - read data */\n  fsRowid,                     /* xRowid - read data */\n  0,                           /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\nstatic sqlite3_module fsdirModule = {\n  0,                              /* iVersion */\n  fsdirConnect,                   /* xCreate */\n  fsdirConnect,                   /* xConnect */\n  fsdirBestIndex,                 /* xBestIndex */\n  fsdirDisconnect,                /* xDisconnect */\n  fsdirDisconnect,                /* xDestroy */\n  fsdirOpen,                      /* xOpen - open a cursor */\n  fsdirClose,                     /* xClose - close a cursor */\n  fsdirFilter,                    /* xFilter - configure scan constraints */\n  fsdirNext,                      /* xNext - advance a cursor */\n  fsdirEof,                       /* xEof - check for end of scan */\n  fsdirColumn,                    /* xColumn - read data */\n  fsdirRowid,                     /* xRowid - read data */\n  0,                              /* xUpdate */\n  0,                              /* xBegin */\n  0,                              /* xSync */\n  0,                              /* xCommit */\n  0,                              /* xRollback */\n  0,                              /* xFindMethod */\n  0,                              /* xRename */\n};\n\nstatic sqlite3_module fstreeModule = {\n  0,                              /* iVersion */\n  fstreeConnect,                  /* xCreate */\n  fstreeConnect,                  /* xConnect */\n  fstreeBestIndex,                /* xBestIndex */\n  fstreeDisconnect,               /* xDisconnect */\n  fstreeDisconnect,               /* xDestroy */\n  fstreeOpen,                     /* xOpen - open a cursor */\n  fstreeClose,                    /* xClose - close a cursor */\n  fstreeFilter,                   /* xFilter - configure scan constraints */\n  fstreeNext,                     /* xNext - advance a cursor */\n  fstreeEof,                      /* xEof - check for end of scan */\n  fstreeColumn,                   /* xColumn - read data */\n  fstreeRowid,                    /* xRowid - read data */\n  0,                              /* xUpdate */\n  0,                              /* xBegin */\n  0,                              /* xSync */\n  0,                              /* xCommit */\n  0,                              /* xRollback */\n  0,                              /* xFindMethod */\n  0,                              /* xRename */\n};\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\n\n/*\n** Register the echo virtual table module.\n*/\nstatic int SQLITE_TCLAPI register_fs_module(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_create_module(db, \"fs\", &fsModule, (void *)interp);\n  sqlite3_create_module(db, \"fsdir\", &fsdirModule, 0);\n  sqlite3_create_module(db, \"fstree\", &fstreeModule, 0);\n#endif\n  return TCL_OK;\n}\n\n#endif\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetestfs_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"register_fs_module\",   register_fs_module, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_func.c",
    "content": "/*\n** 2008 March 19\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing all sorts of SQLite interfaces.  This code\n** implements new SQL functions used by the test scripts.\n*/\n#include \"sqlite3.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n/*\n** Allocate nByte bytes of space using sqlite3_malloc(). If the\n** allocation fails, call sqlite3_result_error_nomem() to notify\n** the database handle that malloc() has failed.\n*/\nstatic void *testContextMalloc(sqlite3_context *context, int nByte){\n  char *z = sqlite3_malloc(nByte);\n  if( !z && nByte>0 ){\n    sqlite3_result_error_nomem(context);\n  }\n  return z;\n}\n\n/*\n** This function generates a string of random characters.  Used for\n** generating test data.\n*/\nstatic void randStr(sqlite3_context *context, int argc, sqlite3_value **argv){\n  static const unsigned char zSrc[] = \n     \"abcdefghijklmnopqrstuvwxyz\"\n     \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n     \"0123456789\"\n     \".-!,:*^+=_|?/<> \";\n  int iMin, iMax, n, r, i;\n  unsigned char zBuf[1000];\n\n  /* It used to be possible to call randstr() with any number of arguments,\n  ** but now it is registered with SQLite as requiring exactly 2.\n  */\n  assert(argc==2);\n\n  iMin = sqlite3_value_int(argv[0]);\n  if( iMin<0 ) iMin = 0;\n  if( iMin>=sizeof(zBuf) ) iMin = sizeof(zBuf)-1;\n  iMax = sqlite3_value_int(argv[1]);\n  if( iMax<iMin ) iMax = iMin;\n  if( iMax>=sizeof(zBuf) ) iMax = sizeof(zBuf)-1;\n  n = iMin;\n  if( iMax>iMin ){\n    sqlite3_randomness(sizeof(r), &r);\n    r &= 0x7fffffff;\n    n += r%(iMax + 1 - iMin);\n  }\n  assert( n<sizeof(zBuf) );\n  sqlite3_randomness(n, zBuf);\n  for(i=0; i<n; i++){\n    zBuf[i] = zSrc[zBuf[i]%(sizeof(zSrc)-1)];\n  }\n  zBuf[n] = 0;\n  sqlite3_result_text(context, (char*)zBuf, n, SQLITE_TRANSIENT);\n}\n\n/*\n** The following two SQL functions are used to test returning a text\n** result with a destructor. Function 'test_destructor' takes one argument\n** and returns the same argument interpreted as TEXT. A destructor is\n** passed with the sqlite3_result_text() call.\n**\n** SQL function 'test_destructor_count' returns the number of outstanding \n** allocations made by 'test_destructor';\n**\n** WARNING: Not threadsafe.\n*/\nstatic int test_destructor_count_var = 0;\nstatic void destructor(void *p){\n  char *zVal = (char *)p;\n  assert(zVal);\n  zVal--;\n  sqlite3_free(zVal);\n  test_destructor_count_var--;\n}\nstatic void test_destructor(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  char *zVal;\n  int len;\n  \n  test_destructor_count_var++;\n  assert( nArg==1 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  len = sqlite3_value_bytes(argv[0]); \n  zVal = testContextMalloc(pCtx, len+3);\n  if( !zVal ){\n    return;\n  }\n  zVal[len+1] = 0;\n  zVal[len+2] = 0;\n  zVal++;\n  memcpy(zVal, sqlite3_value_text(argv[0]), len);\n  sqlite3_result_text(pCtx, zVal, -1, destructor);\n}\n#ifndef SQLITE_OMIT_UTF16\nstatic void test_destructor16(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  char *zVal;\n  int len;\n  \n  test_destructor_count_var++;\n  assert( nArg==1 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  len = sqlite3_value_bytes16(argv[0]); \n  zVal = testContextMalloc(pCtx, len+3);\n  if( !zVal ){\n    return;\n  }\n  zVal[len+1] = 0;\n  zVal[len+2] = 0;\n  zVal++;\n  memcpy(zVal, sqlite3_value_text16(argv[0]), len);\n  sqlite3_result_text16(pCtx, zVal, -1, destructor);\n}\n#endif\nstatic void test_destructor_count(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  sqlite3_result_int(pCtx, test_destructor_count_var);\n}\n\n/*\n** The following aggregate function, test_agg_errmsg16(), takes zero \n** arguments. It returns the text value returned by the sqlite3_errmsg16()\n** API function.\n*/\n#ifndef SQLITE_UNTESTABLE\nvoid sqlite3BeginBenignMalloc(void);\nvoid sqlite3EndBenignMalloc(void);\n#else\n  #define sqlite3BeginBenignMalloc()\n  #define sqlite3EndBenignMalloc()\n#endif\nstatic void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){\n}\nstatic void test_agg_errmsg16_final(sqlite3_context *ctx){\n#ifndef SQLITE_OMIT_UTF16\n  const void *z;\n  sqlite3 * db = sqlite3_context_db_handle(ctx);\n  sqlite3_aggregate_context(ctx, 2048);\n  z = sqlite3_errmsg16(db);\n  sqlite3_result_text16(ctx, z, -1, SQLITE_TRANSIENT);\n#endif\n}\n\n/*\n** Routines for testing the sqlite3_get_auxdata() and sqlite3_set_auxdata()\n** interface.\n**\n** The test_auxdata() SQL function attempts to register each of its arguments\n** as auxiliary data.  If there are no prior registrations of aux data for\n** that argument (meaning the argument is not a constant or this is its first\n** call) then the result for that argument is 0.  If there is a prior\n** registration, the result for that argument is 1.  The overall result\n** is the individual argument results separated by spaces.\n*/\nstatic void free_test_auxdata(void *p) {sqlite3_free(p);}\nstatic void test_auxdata(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  int i;\n  char *zRet = testContextMalloc(pCtx, nArg*2);\n  if( !zRet ) return;\n  memset(zRet, 0, nArg*2);\n  for(i=0; i<nArg; i++){\n    char const *z = (char*)sqlite3_value_text(argv[i]);\n    if( z ){\n      int n;\n      char *zAux = sqlite3_get_auxdata(pCtx, i);\n      if( zAux ){\n        zRet[i*2] = '1';\n        assert( strcmp(zAux,z)==0 );\n      }else {\n        zRet[i*2] = '0';\n      }\n      n = (int)strlen(z) + 1;\n      zAux = testContextMalloc(pCtx, n);\n      if( zAux ){\n        memcpy(zAux, z, n);\n        sqlite3_set_auxdata(pCtx, i, zAux, free_test_auxdata);\n      }\n      zRet[i*2+1] = ' ';\n    }\n  }\n  sqlite3_result_text(pCtx, zRet, 2*nArg-1, free_test_auxdata);\n}\n\n/*\n** A function to test error reporting from user functions. This function\n** returns a copy of its first argument as the error message.  If the\n** second argument exists, it becomes the error code.\n*/\nstatic void test_error(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  sqlite3_result_error(pCtx, (char*)sqlite3_value_text(argv[0]), -1);\n  if( nArg==2 ){\n    sqlite3_result_error_code(pCtx, sqlite3_value_int(argv[1]));\n  }\n}\n\n/*\n** Implementation of the counter(X) function.  If X is an integer\n** constant, then the first invocation will return X.  The second X+1.\n** and so forth.  Can be used (for example) to provide a sequence number\n** in a result set.\n*/\nstatic void counterFunc(\n  sqlite3_context *pCtx,   /* Function context */\n  int nArg,                /* Number of function arguments */\n  sqlite3_value **argv     /* Values for all function arguments */\n){\n  int *pCounter = (int*)sqlite3_get_auxdata(pCtx, 0);\n  if( pCounter==0 ){\n    pCounter = sqlite3_malloc( sizeof(*pCounter) );\n    if( pCounter==0 ){\n      sqlite3_result_error_nomem(pCtx);\n      return;\n    }\n    *pCounter = sqlite3_value_int(argv[0]);\n    sqlite3_set_auxdata(pCtx, 0, pCounter, sqlite3_free);\n  }else{\n    ++*pCounter;\n  }\n  sqlite3_result_int(pCtx, *pCounter);\n}\n\n\n/*\n** This function takes two arguments.  It performance UTF-8/16 type\n** conversions on the first argument then returns a copy of the second\n** argument.\n**\n** This function is used in cases such as the following:\n**\n**      SELECT test_isolation(x,x) FROM t1;\n**\n** We want to verify that the type conversions that occur on the\n** first argument do not invalidate the second argument.\n*/\nstatic void test_isolation(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n#ifndef SQLITE_OMIT_UTF16\n  sqlite3_value_text16(argv[0]);\n  sqlite3_value_text(argv[0]);\n  sqlite3_value_text16(argv[0]);\n  sqlite3_value_text(argv[0]);\n#endif\n  sqlite3_result_value(pCtx, argv[1]);\n}\n\n/*\n** Invoke an SQL statement recursively.  The function result is the \n** first column of the first row of the result set.\n*/\nstatic void test_eval(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n  sqlite3 *db = sqlite3_context_db_handle(pCtx);\n  const char *zSql;\n\n  zSql = (char*)sqlite3_value_text(argv[0]);\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_step(pStmt);\n    if( rc==SQLITE_ROW ){\n      sqlite3_result_value(pCtx, sqlite3_column_value(pStmt, 0));\n    }\n    rc = sqlite3_finalize(pStmt);\n  }\n  if( rc ){\n    char *zErr;\n    assert( pStmt==0 );\n    zErr = sqlite3_mprintf(\"sqlite3_prepare_v2() error: %s\",sqlite3_errmsg(db));\n    sqlite3_result_text(pCtx, zErr, -1, sqlite3_free);\n    sqlite3_result_error_code(pCtx, rc);\n  }\n}\n\n\n/*\n** convert one character from hex to binary\n*/\nstatic int testHexChar(char c){\n  if( c>='0' && c<='9' ){\n    return c - '0';\n  }else if( c>='a' && c<='f' ){\n    return c - 'a' + 10;\n  }else if( c>='A' && c<='F' ){\n    return c - 'A' + 10;\n  }\n  return 0;\n}\n\n/*\n** Convert hex to binary.\n*/\nstatic void testHexToBin(const char *zIn, char *zOut){\n  while( zIn[0] && zIn[1] ){\n    *(zOut++) = (testHexChar(zIn[0])<<4) + testHexChar(zIn[1]);\n    zIn += 2;\n  }\n}\n\n/*\n**      hex_to_utf16be(HEX)\n**\n** Convert the input string from HEX into binary.  Then return the\n** result using sqlite3_result_text16le().\n*/\n#ifndef SQLITE_OMIT_UTF16\nstatic void testHexToUtf16be(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  int n;\n  const char *zIn;\n  char *zOut;\n  assert( nArg==1 );\n  n = sqlite3_value_bytes(argv[0]);\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  zOut = sqlite3_malloc( n/2 );\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(pCtx);\n  }else{\n    testHexToBin(zIn, zOut);\n    sqlite3_result_text16be(pCtx, zOut, n/2, sqlite3_free);\n  }\n}\n#endif\n\n/*\n**      hex_to_utf8(HEX)\n**\n** Convert the input string from HEX into binary.  Then return the\n** result using sqlite3_result_text16le().\n*/\nstatic void testHexToUtf8(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  int n;\n  const char *zIn;\n  char *zOut;\n  assert( nArg==1 );\n  n = sqlite3_value_bytes(argv[0]);\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  zOut = sqlite3_malloc( n/2 );\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(pCtx);\n  }else{\n    testHexToBin(zIn, zOut);\n    sqlite3_result_text(pCtx, zOut, n/2, sqlite3_free);\n  }\n}\n\n/*\n**      hex_to_utf16le(HEX)\n**\n** Convert the input string from HEX into binary.  Then return the\n** result using sqlite3_result_text16le().\n*/\n#ifndef SQLITE_OMIT_UTF16\nstatic void testHexToUtf16le(\n  sqlite3_context *pCtx, \n  int nArg,\n  sqlite3_value **argv\n){\n  int n;\n  const char *zIn;\n  char *zOut;\n  assert( nArg==1 );\n  n = sqlite3_value_bytes(argv[0]);\n  zIn = (const char*)sqlite3_value_text(argv[0]);\n  zOut = sqlite3_malloc( n/2 );\n  if( zOut==0 ){\n    sqlite3_result_error_nomem(pCtx);\n  }else{\n    testHexToBin(zIn, zOut);\n    sqlite3_result_text16le(pCtx, zOut, n/2, sqlite3_free);\n  }\n}\n#endif\n\n/*\n** SQL function:   real2hex(X)\n**\n** If argument X is a real number, then convert it into a string which is\n** the big-endian hexadecimal representation of the ieee754 encoding of\n** that number.  If X is not a real number, return NULL.\n*/\nstatic void real2hex(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  union {\n    sqlite3_uint64 i;\n    double r;\n    unsigned char x[8];\n  } v;\n  char zOut[20];\n  int i;\n  int bigEndian;\n  v.i = 1;\n  bigEndian = v.x[0]==0;\n  v.r = sqlite3_value_double(argv[0]);\n  for(i=0; i<8; i++){\n    if( bigEndian ){\n      zOut[i*2]   = \"0123456789abcdef\"[v.x[i]>>4];\n      zOut[i*2+1] = \"0123456789abcdef\"[v.x[i]&0xf];\n    }else{\n      zOut[14-i*2]   = \"0123456789abcdef\"[v.x[i]>>4];\n      zOut[14-i*2+1] = \"0123456789abcdef\"[v.x[i]&0xf];\n    }\n  }\n  zOut[16] = 0;\n  sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT);\n}\n\n/*\n**     test_extract(record, field)\n**\n** This function implements an SQL user-function that accepts a blob\n** containing a formatted database record as the first argument. The\n** second argument is the index of the field within that record to\n** extract and return.\n*/\nstatic void test_extract(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  u8 *pRec;\n  u8 *pEndHdr;                    /* Points to one byte past record header */\n  u8 *pHdr;                       /* Current point in record header */\n  u8 *pBody;                      /* Current point in record data */\n  u64 nHdr;                       /* Bytes in record header */\n  int iIdx;                       /* Required field */\n  int iCurrent = 0;               /* Current field */\n\n  assert( argc==2 );\n  pRec = (u8*)sqlite3_value_blob(argv[0]);\n  iIdx = sqlite3_value_int(argv[1]);\n\n  pHdr = pRec + sqlite3GetVarint(pRec, &nHdr);\n  pBody = pEndHdr = &pRec[nHdr];\n\n  for(iCurrent=0; pHdr<pEndHdr && iCurrent<=iIdx; iCurrent++){\n    u64 iSerialType;\n    Mem mem;\n\n    memset(&mem, 0, sizeof(mem));\n    mem.db = db;\n    mem.enc = ENC(db);\n    pHdr += sqlite3GetVarint(pHdr, &iSerialType);\n    pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);\n\n    if( iCurrent==iIdx ){\n      sqlite3_result_value(context, &mem);\n    }\n\n    if( mem.szMalloc ) sqlite3DbFree(db, mem.zMalloc);\n  }\n}\n\n/*\n**      test_decode(record)\n**\n** This function implements an SQL user-function that accepts a blob\n** containing a formatted database record as its only argument. It returns\n** a tcl list (type SQLITE_TEXT) containing each of the values stored\n** in the record.\n*/\nstatic void test_decode(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  u8 *pRec;\n  u8 *pEndHdr;                    /* Points to one byte past record header */\n  u8 *pHdr;                       /* Current point in record header */\n  u8 *pBody;                      /* Current point in record data */\n  u64 nHdr;                       /* Bytes in record header */\n  Tcl_Obj *pRet;                  /* Return value */\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n\n  assert( argc==1 );\n  pRec = (u8*)sqlite3_value_blob(argv[0]);\n\n  pHdr = pRec + sqlite3GetVarint(pRec, &nHdr);\n  pBody = pEndHdr = &pRec[nHdr];\n  while( pHdr<pEndHdr ){\n    Tcl_Obj *pVal = 0;\n    u64 iSerialType;\n    Mem mem;\n\n    memset(&mem, 0, sizeof(mem));\n    mem.db = db;\n    mem.enc = ENC(db);\n    pHdr += sqlite3GetVarint(pHdr, &iSerialType);\n    pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);\n\n    switch( sqlite3_value_type(&mem) ){\n      case SQLITE_TEXT:\n        pVal = Tcl_NewStringObj((const char*)sqlite3_value_text(&mem), -1);\n        break;\n\n      case SQLITE_BLOB: {\n        char hexdigit[] = {\n          '0', '1', '2', '3', '4', '5', '6', '7',\n          '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'\n        };\n        int n = sqlite3_value_bytes(&mem);\n        u8 *z = (u8*)sqlite3_value_blob(&mem);\n        int i;\n        pVal = Tcl_NewStringObj(\"x'\", -1);\n        for(i=0; i<n; i++){\n          char hex[3];\n          hex[0] = hexdigit[((z[i] >> 4) & 0x0F)];\n          hex[1] = hexdigit[(z[i] & 0x0F)];\n          hex[2] = '\\0';\n          Tcl_AppendStringsToObj(pVal, hex, 0);\n        }\n        Tcl_AppendStringsToObj(pVal, \"'\", 0);\n        break;\n      }\n\n      case SQLITE_FLOAT:\n        pVal = Tcl_NewDoubleObj(sqlite3_value_double(&mem));\n        break;\n\n      case SQLITE_INTEGER:\n        pVal = Tcl_NewWideIntObj(sqlite3_value_int64(&mem));\n        break;\n\n      case SQLITE_NULL:\n        pVal = Tcl_NewStringObj(\"NULL\", -1);\n        break;\n\n      default:\n        assert( 0 );\n    }\n\n    Tcl_ListObjAppendElement(0, pRet, pVal);\n\n    if( mem.szMalloc ){\n      sqlite3DbFree(db, mem.zMalloc);\n    }\n  }\n\n  sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);\n  Tcl_DecrRefCount(pRet);\n}\n\n/*\n**       test_zeroblob(N)\n**\n** The implementation of scalar SQL function \"test_zeroblob()\". This is\n** similar to the built-in zeroblob() function, except that it does not\n** check that the integer parameter is within range before passing it\n** to sqlite3_result_zeroblob().\n*/\nstatic void test_zeroblob(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int nZero = sqlite3_value_int(argv[0]);\n  sqlite3_result_zeroblob(context, nZero);\n}\n\n/*         test_getsubtype(V)\n**\n** Return the subtype for value V.\n*/\nstatic void test_getsubtype(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_result_int(context, (int)sqlite3_value_subtype(argv[0]));\n}\n\n/*         test_setsubtype(V, T)\n**\n** Return the value V with its subtype changed to T\n*/\nstatic void test_setsubtype(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_result_value(context, argv[0]);\n  sqlite3_result_subtype(context, (unsigned int)sqlite3_value_int(argv[1]));\n}\n\nstatic int registerTestFunctions(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pThunk\n){\n  static const struct {\n     char *zName;\n     signed char nArg;\n     unsigned int eTextRep; /* 1: UTF-16.  0: UTF-8 */\n     void (*xFunc)(sqlite3_context*,int,sqlite3_value **);\n  } aFuncs[] = {\n    { \"randstr\",               2, SQLITE_UTF8, randStr    },\n    { \"test_destructor\",       1, SQLITE_UTF8, test_destructor},\n#ifndef SQLITE_OMIT_UTF16\n    { \"test_destructor16\",     1, SQLITE_UTF8, test_destructor16},\n    { \"hex_to_utf16be\",        1, SQLITE_UTF8, testHexToUtf16be},\n    { \"hex_to_utf16le\",        1, SQLITE_UTF8, testHexToUtf16le},\n#endif\n    { \"hex_to_utf8\",           1, SQLITE_UTF8, testHexToUtf8},\n    { \"test_destructor_count\", 0, SQLITE_UTF8, test_destructor_count},\n    { \"test_auxdata\",         -1, SQLITE_UTF8, test_auxdata},\n    { \"test_error\",            1, SQLITE_UTF8, test_error},\n    { \"test_error\",            2, SQLITE_UTF8, test_error},\n    { \"test_eval\",             1, SQLITE_UTF8, test_eval},\n    { \"test_isolation\",        2, SQLITE_UTF8, test_isolation},\n    { \"test_counter\",          1, SQLITE_UTF8, counterFunc},\n    { \"real2hex\",              1, SQLITE_UTF8, real2hex},\n    { \"test_decode\",           1, SQLITE_UTF8, test_decode},\n    { \"test_extract\",          2, SQLITE_UTF8, test_extract},\n    { \"test_zeroblob\",  1, SQLITE_UTF8|SQLITE_DETERMINISTIC, test_zeroblob},\n    { \"test_getsubtype\",       1, SQLITE_UTF8, test_getsubtype},\n    { \"test_setsubtype\",       2, SQLITE_UTF8, test_setsubtype},\n  };\n  int i;\n\n  for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){\n    sqlite3_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,\n        aFuncs[i].eTextRep, 0, aFuncs[i].xFunc, 0, 0);\n  }\n\n  sqlite3_create_function(db, \"test_agg_errmsg16\", 0, SQLITE_ANY, 0, 0, \n      test_agg_errmsg16_step, test_agg_errmsg16_final);\n      \n  return SQLITE_OK;\n}\n\n/*\n** TCLCMD:  autoinstall_test_functions\n**\n** Invoke this TCL command to use sqlite3_auto_extension() to cause\n** the standard set of test functions to be loaded into each new\n** database connection.\n*/\nstatic int SQLITE_TCLAPI autoinstall_test_funcs(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);\n  int rc = sqlite3_auto_extension((void(*)(void))registerTestFunctions);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_auto_extension((void(*)(void))Md5_Register);\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** A bogus step function and finalizer function.\n*/\nstatic void tStep(sqlite3_context *a, int b, sqlite3_value **c){}\nstatic void tFinal(sqlite3_context *a){}\n\n\n/*\n** tclcmd:  abuse_create_function\n**\n** Make various calls to sqlite3_create_function that do not have valid\n** parameters.  Verify that the error condition is detected and reported.\n*/\nstatic int SQLITE_TCLAPI abuse_create_function(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  sqlite3 *db;\n  int rc;\n  int mxArg;\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n\n  rc = sqlite3_create_function(db, \"tx\", 1, SQLITE_UTF8, 0, tStep,tStep,tFinal);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", 1, SQLITE_UTF8, 0, tStep, tStep, 0);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", 1, SQLITE_UTF8, 0, tStep, 0, tFinal);\n  if( rc!=SQLITE_MISUSE) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", 1, SQLITE_UTF8, 0, 0, 0, tFinal);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", 1, SQLITE_UTF8, 0, 0, tStep, 0);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", -2, SQLITE_UTF8, 0, tStep, 0, 0);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"tx\", 128, SQLITE_UTF8, 0, tStep, 0, 0);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  rc = sqlite3_create_function(db, \"funcxx\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\",\n       1, SQLITE_UTF8, 0, tStep, 0, 0);\n  if( rc!=SQLITE_MISUSE ) goto abuse_err;\n\n  /* This last function registration should actually work.  Generate\n  ** a no-op function (that always returns NULL) and which has the\n  ** maximum-length function name and the maximum number of parameters.\n  */\n  sqlite3_limit(db, SQLITE_LIMIT_FUNCTION_ARG, 10000);\n  mxArg = sqlite3_limit(db, SQLITE_LIMIT_FUNCTION_ARG, -1);\n  rc = sqlite3_create_function(db, \"nullx\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\"\n       \"_123456789_123456789_123456789_123456789_123456789\",\n       mxArg, SQLITE_UTF8, 0, tStep, 0, 0);\n  if( rc!=SQLITE_OK ) goto abuse_err;\n                                \n  return TCL_OK;\n\nabuse_err:\n  Tcl_AppendResult(interp, \"sqlite3_create_function abused test failed\", \n                   (char*)0);\n  return TCL_ERROR;\n}\n\n\n/*\n** SQLite user defined function to use with matchinfo() to calculate the\n** relevancy of an FTS match. The value returned is the relevancy score\n** (a real value greater than or equal to zero). A larger value indicates \n** a more relevant document.\n**\n** The overall relevancy returned is the sum of the relevancies of each \n** column value in the FTS table. The relevancy of a column value is the\n** sum of the following for each reportable phrase in the FTS query:\n**\n**   (<hit count> / <global hit count>) * <column weight>\n**\n** where <hit count> is the number of instances of the phrase in the\n** column value of the current row and <global hit count> is the number\n** of instances of the phrase in the same column of all rows in the FTS\n** table. The <column weight> is a weighting factor assigned to each\n** column by the caller (see below).\n**\n** The first argument to this function must be the return value of the FTS \n** matchinfo() function. Following this must be one argument for each column \n** of the FTS table containing a numeric weight factor for the corresponding \n** column. Example:\n**\n**     CREATE VIRTUAL TABLE documents USING fts3(title, content)\n**\n** The following query returns the docids of documents that match the full-text\n** query <query> sorted from most to least relevant. When calculating\n** relevance, query term instances in the 'title' column are given twice the\n** weighting of those in the 'content' column.\n**\n**     SELECT docid FROM documents \n**     WHERE documents MATCH <query> \n**     ORDER BY rank(matchinfo(documents), 1.0, 0.5) DESC\n*/\nstatic void rankfunc(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){\n  int *aMatchinfo;                /* Return value of matchinfo() */\n  int nMatchinfo;                 /* Number of elements in aMatchinfo[] */\n  int nCol = 0;                   /* Number of columns in the table */\n  int nPhrase = 0;                /* Number of phrases in the query */\n  int iPhrase;                    /* Current phrase */\n  double score = 0.0;             /* Value to return */\n\n  assert( sizeof(int)==4 );\n\n  /* Check that the number of arguments passed to this function is correct.\n  ** If not, jump to wrong_number_args. Set aMatchinfo to point to the array\n  ** of unsigned integer values returned by FTS function matchinfo. Set\n  ** nPhrase to contain the number of reportable phrases in the users full-text\n  ** query, and nCol to the number of columns in the table. Then check that the\n  ** size of the matchinfo blob is as expected. Return an error if it is not.\n  */\n  if( nVal<1 ) goto wrong_number_args;\n  aMatchinfo = (int*)sqlite3_value_blob(apVal[0]);\n  nMatchinfo = sqlite3_value_bytes(apVal[0]) / sizeof(int);\n  if( nMatchinfo>=2 ){\n    nPhrase = aMatchinfo[0];\n    nCol = aMatchinfo[1];\n  }\n  if( nMatchinfo!=(2+3*nCol*nPhrase) ){\n    sqlite3_result_error(pCtx,\n        \"invalid matchinfo blob passed to function rank()\", -1);\n    return;\n  }\n  if( nVal!=(1+nCol) ) goto wrong_number_args;\n\n  /* Iterate through each phrase in the users query. */\n  for(iPhrase=0; iPhrase<nPhrase; iPhrase++){\n    int iCol;                     /* Current column */\n\n    /* Now iterate through each column in the users query. For each column,\n    ** increment the relevancy score by:\n    **\n    **   (<hit count> / <global hit count>) * <column weight>\n    **\n    ** aPhraseinfo[] points to the start of the data for phrase iPhrase. So\n    ** the hit count and global hit counts for each column are found in \n    ** aPhraseinfo[iCol*3] and aPhraseinfo[iCol*3+1], respectively.\n    */\n    int *aPhraseinfo = &aMatchinfo[2 + iPhrase*nCol*3];\n    for(iCol=0; iCol<nCol; iCol++){\n      int nHitCount = aPhraseinfo[3*iCol];\n      int nGlobalHitCount = aPhraseinfo[3*iCol+1];\n      double weight = sqlite3_value_double(apVal[iCol+1]);\n      if( nHitCount>0 ){\n        score += ((double)nHitCount / (double)nGlobalHitCount) * weight;\n      }\n    }\n  }\n\n  sqlite3_result_double(pCtx, score);\n  return;\n\n  /* Jump here if the wrong number of arguments are passed to this function */\nwrong_number_args:\n  sqlite3_result_error(pCtx, \"wrong number of arguments to function rank()\", -1);\n}\n\nstatic int SQLITE_TCLAPI install_fts3_rank_function(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  sqlite3 *db;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  sqlite3_create_function(db, \"rank\", -1, SQLITE_UTF8, 0, rankfunc, 0, 0);\n  return TCL_OK;\n}\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest_func_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aObjCmd[] = {\n     { \"autoinstall_test_functions\",    autoinstall_test_funcs },\n     { \"abuse_create_function\",         abuse_create_function  },\n     { \"install_fts3_rank_function\",    install_fts3_rank_function  },\n  };\n  int i;\n  extern int Md5_Register(sqlite3 *, char **, const sqlite3_api_routines *);\n\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);\n  }\n  sqlite3_initialize();\n  sqlite3_auto_extension((void(*)(void))registerTestFunctions);\n  sqlite3_auto_extension((void(*)(void))Md5_Register);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_hexio.c",
    "content": "/*\n** 2007 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing all sorts of SQLite interfaces.  This code\n** implements TCL commands for reading and writing the binary\n** database files and displaying the content of those files as\n** hexadecimal.  We could, in theory, use the built-in \"binary\"\n** command of TCL to do a lot of this, but there are some issues\n** with historical versions of the \"binary\" command.  So it seems\n** easier and safer to build our own mechanism.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\n\n/*\n** Convert binary to hex.  The input zBuf[] contains N bytes of\n** binary data.  zBuf[] is 2*n+1 bytes long.  Overwrite zBuf[]\n** with a hexadecimal representation of its original binary input.\n*/\nvoid sqlite3TestBinToHex(unsigned char *zBuf, int N){\n  const unsigned char zHex[] = \"0123456789ABCDEF\";\n  int i, j;\n  unsigned char c;\n  i = N*2;\n  zBuf[i--] = 0;\n  for(j=N-1; j>=0; j--){\n    c = zBuf[j];\n    zBuf[i--] = zHex[c&0xf];\n    zBuf[i--] = zHex[c>>4];\n  }\n  assert( i==-1 );\n}\n\n/*\n** Convert hex to binary.  The input zIn[] contains N bytes of\n** hexadecimal.  Convert this into binary and write aOut[] with\n** the binary data.  Spaces in the original input are ignored.\n** Return the number of bytes of binary rendered.\n*/\nint sqlite3TestHexToBin(const unsigned char *zIn, int N, unsigned char *aOut){\n  const unsigned char aMap[] = {\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     1, 2, 3, 4, 5, 6, 7, 8,  9,10, 0, 0, 0, 0, 0, 0,\n     0,11,12,13,14,15,16, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0,11,12,13,14,15,16, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n     0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n  };\n  int i, j;\n  int hi=1;\n  unsigned char c;\n\n  for(i=j=0; i<N; i++){\n    c = aMap[zIn[i]];\n    if( c==0 ) continue;\n    if( hi ){\n      aOut[j] = (c-1)<<4;\n      hi = 0;\n    }else{\n      aOut[j++] |= c-1;\n      hi = 1;\n    }\n  }\n  return j;\n}\n\n\n/*\n** Usage:   hexio_read  FILENAME  OFFSET  AMT\n**\n** Read AMT bytes from file FILENAME beginning at OFFSET from the\n** beginning of the file.  Convert that information to hexadecimal\n** and return the resulting HEX string.\n*/\nstatic int SQLITE_TCLAPI hexio_read(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int offset;\n  int amt, got;\n  const char *zFile;\n  unsigned char *zBuf;\n  FILE *in;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME OFFSET AMT\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &amt) ) return TCL_ERROR;\n  zFile = Tcl_GetString(objv[1]);\n  zBuf = sqlite3_malloc( amt*2+1 );\n  if( zBuf==0 ){\n    return TCL_ERROR;\n  }\n  in = fopen(zFile, \"rb\");\n  if( in==0 ){\n    in = fopen(zFile, \"r\");\n  }\n  if( in==0 ){\n    Tcl_AppendResult(interp, \"cannot open input file \", zFile, 0);\n    return TCL_ERROR;\n  }\n  fseek(in, offset, SEEK_SET);\n  got = (int)fread(zBuf, 1, amt, in);\n  fclose(in);\n  if( got<0 ){\n    got = 0;\n  }\n  sqlite3TestBinToHex(zBuf, got);\n  Tcl_AppendResult(interp, zBuf, 0);\n  sqlite3_free(zBuf);\n  return TCL_OK;\n}\n\n\n/*\n** Usage:   hexio_write  FILENAME  OFFSET  DATA\n**\n** Write DATA into file FILENAME beginning at OFFSET from the\n** beginning of the file.  DATA is expressed in hexadecimal.\n*/\nstatic int SQLITE_TCLAPI hexio_write(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int offset;\n  int nIn, nOut, written;\n  const char *zFile;\n  const unsigned char *zIn;\n  unsigned char *aOut;\n  FILE *out;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME OFFSET HEXDATA\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR;\n  zFile = Tcl_GetString(objv[1]);\n  zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[3], &nIn);\n  aOut = sqlite3_malloc( nIn/2 );\n  if( aOut==0 ){\n    return TCL_ERROR;\n  }\n  nOut = sqlite3TestHexToBin(zIn, nIn, aOut);\n  out = fopen(zFile, \"r+b\");\n  if( out==0 ){\n    out = fopen(zFile, \"r+\");\n  }\n  if( out==0 ){\n    Tcl_AppendResult(interp, \"cannot open output file \", zFile, 0);\n    return TCL_ERROR;\n  }\n  fseek(out, offset, SEEK_SET);\n  written = (int)fwrite(aOut, 1, nOut, out);\n  sqlite3_free(aOut);\n  fclose(out);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(written));\n  return TCL_OK;\n}\n\n/*\n** USAGE:   hexio_get_int   HEXDATA\n**\n** Interpret the HEXDATA argument as a big-endian integer.  Return\n** the value of that integer.  HEXDATA can contain between 2 and 8\n** hexadecimal digits.\n*/\nstatic int SQLITE_TCLAPI hexio_get_int(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int val;\n  int nIn, nOut;\n  const unsigned char *zIn;\n  unsigned char *aOut;\n  unsigned char aNum[4];\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HEXDATA\");\n    return TCL_ERROR;\n  }\n  zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &nIn);\n  aOut = sqlite3_malloc( nIn/2 );\n  if( aOut==0 ){\n    return TCL_ERROR;\n  }\n  nOut = sqlite3TestHexToBin(zIn, nIn, aOut);\n  if( nOut>=4 ){\n    memcpy(aNum, aOut, 4);\n  }else{\n    memset(aNum, 0, sizeof(aNum));\n    memcpy(&aNum[4-nOut], aOut, nOut);\n  }\n  sqlite3_free(aOut);\n  val = (aNum[0]<<24) | (aNum[1]<<16) | (aNum[2]<<8) | aNum[3];\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(val));\n  return TCL_OK;\n}\n\n\n/*\n** USAGE:   hexio_render_int16   INTEGER\n**\n** Render INTEGER has a 16-bit big-endian integer in hexadecimal.\n*/\nstatic int SQLITE_TCLAPI hexio_render_int16(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int val;\n  unsigned char aNum[10];\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"INTEGER\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &val) ) return TCL_ERROR;\n  aNum[0] = val>>8;\n  aNum[1] = val;\n  sqlite3TestBinToHex(aNum, 2);\n  Tcl_SetObjResult(interp, Tcl_NewStringObj((char*)aNum, 4));\n  return TCL_OK;\n}\n\n\n/*\n** USAGE:   hexio_render_int32   INTEGER\n**\n** Render INTEGER has a 32-bit big-endian integer in hexadecimal.\n*/\nstatic int SQLITE_TCLAPI hexio_render_int32(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int val;\n  unsigned char aNum[10];\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"INTEGER\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &val) ) return TCL_ERROR;\n  aNum[0] = val>>24;\n  aNum[1] = val>>16;\n  aNum[2] = val>>8;\n  aNum[3] = val;\n  sqlite3TestBinToHex(aNum, 4);\n  Tcl_SetObjResult(interp, Tcl_NewStringObj((char*)aNum, 8));\n  return TCL_OK;\n}\n\n/*\n** USAGE:  utf8_to_utf8  HEX\n**\n** The argument is a UTF8 string represented in hexadecimal.\n** The UTF8 might not be well-formed.  Run this string through\n** sqlite3Utf8to8() convert it back to hex and return the result.\n*/\nstatic int SQLITE_TCLAPI utf8_to_utf8(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifdef SQLITE_DEBUG\n  int n;\n  int nOut;\n  const unsigned char *zOrig;\n  unsigned char *z;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HEX\");\n    return TCL_ERROR;\n  }\n  zOrig = (unsigned char *)Tcl_GetStringFromObj(objv[1], &n);\n  z = sqlite3_malloc( n+3 );\n  n = sqlite3TestHexToBin(zOrig, n, z);\n  z[n] = 0;\n  nOut = sqlite3Utf8To8(z);\n  sqlite3TestBinToHex(z,nOut);\n  Tcl_AppendResult(interp, (char*)z, 0);\n  sqlite3_free(z);\n  return TCL_OK;\n#else\n  Tcl_AppendResult(interp, \n      \"[utf8_to_utf8] unavailable - SQLITE_DEBUG not defined\", 0\n  );\n  return TCL_ERROR;\n#endif\n}\n\nstatic int getFts3Varint(const char *p, sqlite_int64 *v){\n  const unsigned char *q = (const unsigned char *) p;\n  sqlite_uint64 x = 0, y = 1;\n  while( (*q & 0x80) == 0x80 ){\n    x += y * (*q++ & 0x7f);\n    y <<= 7;\n  }\n  x += y * (*q++);\n  *v = (sqlite_int64) x;\n  return (int) (q - (unsigned char *)p);\n}\n\n\n/*\n** USAGE:  read_fts3varint BLOB VARNAME\n**\n** Read a varint from the start of BLOB. Set variable VARNAME to contain\n** the interpreted value. Return the number of bytes of BLOB consumed.\n*/\nstatic int SQLITE_TCLAPI read_fts3varint(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nBlob;\n  unsigned char *zBlob;\n  sqlite3_int64 iVal;\n  int nVal;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BLOB VARNAME\");\n    return TCL_ERROR;\n  }\n  zBlob = Tcl_GetByteArrayFromObj(objv[1], &nBlob);\n\n  nVal = getFts3Varint((char*)zBlob, (sqlite3_int64 *)(&iVal));\n  Tcl_ObjSetVar2(interp, objv[2], 0, Tcl_NewWideIntObj(iVal), 0);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(nVal));\n  return TCL_OK;\n}\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest_hexio_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aObjCmd[] = {\n     { \"hexio_read\",                   hexio_read            },\n     { \"hexio_write\",                  hexio_write           },\n     { \"hexio_get_int\",                hexio_get_int         },\n     { \"hexio_render_int16\",           hexio_render_int16    },\n     { \"hexio_render_int32\",           hexio_render_int32    },\n     { \"utf8_to_utf8\",                 utf8_to_utf8          },\n     { \"read_fts3varint\",              read_fts3varint       },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);\n  }\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_init.c",
    "content": "/*\n** 2009 August 17\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** The code in this file is used for testing SQLite. It is not part of\n** the source code used in production systems.\n**\n** Specifically, this file tests the effect of errors while initializing\n** the various pluggable sub-systems from within sqlite3_initialize().\n** If an error occurs in sqlite3_initialize() the following should be\n** true:\n**\n**   1) An error code is returned to the user, and\n**   2) A subsequent call to sqlite3_shutdown() calls the shutdown method\n**      of those subsystems that were initialized, and\n**   3) A subsequent call to sqlite3_initialize() attempts to initialize\n**      the remaining, uninitialized, subsystems.\n*/\n\n#include \"sqliteInt.h\"\n#include <string.h>\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\nstatic struct Wrapped {\n  sqlite3_pcache_methods2 pcache;\n  sqlite3_mem_methods     mem;\n  sqlite3_mutex_methods   mutex;\n\n  int mem_init;                /* True if mem subsystem is initalized */\n  int mem_fail;                /* True to fail mem subsystem inialization */\n  int mutex_init;              /* True if mutex subsystem is initalized */\n  int mutex_fail;              /* True to fail mutex subsystem inialization */\n  int pcache_init;             /* True if pcache subsystem is initalized */\n  int pcache_fail;             /* True to fail pcache subsystem inialization */\n} wrapped;\n\nstatic int wrMemInit(void *pAppData){\n  int rc;\n  if( wrapped.mem_fail ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = wrapped.mem.xInit(wrapped.mem.pAppData);\n  }\n  if( rc==SQLITE_OK ){\n    wrapped.mem_init = 1;\n  }\n  return rc;\n}\nstatic void wrMemShutdown(void *pAppData){\n  wrapped.mem.xShutdown(wrapped.mem.pAppData);\n  wrapped.mem_init = 0;\n}\nstatic void *wrMemMalloc(int n)           {return wrapped.mem.xMalloc(n);}\nstatic void wrMemFree(void *p)            {wrapped.mem.xFree(p);}\nstatic void *wrMemRealloc(void *p, int n) {return wrapped.mem.xRealloc(p, n);}\nstatic int wrMemSize(void *p)             {return wrapped.mem.xSize(p);}\nstatic int wrMemRoundup(int n)            {return wrapped.mem.xRoundup(n);}\n\n\nstatic int wrMutexInit(void){\n  int rc;\n  if( wrapped.mutex_fail ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = wrapped.mutex.xMutexInit();\n  }\n  if( rc==SQLITE_OK ){\n    wrapped.mutex_init = 1;\n  }\n  return rc;\n}\nstatic int wrMutexEnd(void){\n  wrapped.mutex.xMutexEnd();\n  wrapped.mutex_init = 0;\n  return SQLITE_OK;\n}\nstatic sqlite3_mutex *wrMutexAlloc(int e){\n  return wrapped.mutex.xMutexAlloc(e);\n}\nstatic void wrMutexFree(sqlite3_mutex *p){\n  wrapped.mutex.xMutexFree(p);\n}\nstatic void wrMutexEnter(sqlite3_mutex *p){\n  wrapped.mutex.xMutexEnter(p);\n}\nstatic int wrMutexTry(sqlite3_mutex *p){\n  return wrapped.mutex.xMutexTry(p);\n}\nstatic void wrMutexLeave(sqlite3_mutex *p){\n  wrapped.mutex.xMutexLeave(p);\n}\nstatic int wrMutexHeld(sqlite3_mutex *p){\n  return wrapped.mutex.xMutexHeld(p);\n}\nstatic int wrMutexNotheld(sqlite3_mutex *p){\n  return wrapped.mutex.xMutexNotheld(p);\n}\n\n\n\nstatic int wrPCacheInit(void *pArg){\n  int rc;\n  if( wrapped.pcache_fail ){\n    rc = SQLITE_ERROR;\n  }else{\n    rc = wrapped.pcache.xInit(wrapped.pcache.pArg);\n  }\n  if( rc==SQLITE_OK ){\n    wrapped.pcache_init = 1;\n  }\n  return rc;\n}\nstatic void wrPCacheShutdown(void *pArg){\n  wrapped.pcache.xShutdown(wrapped.pcache.pArg);\n  wrapped.pcache_init = 0;\n}\n\nstatic sqlite3_pcache *wrPCacheCreate(int a, int b, int c){\n  return wrapped.pcache.xCreate(a, b, c);\n}  \nstatic void wrPCacheCachesize(sqlite3_pcache *p, int n){\n  wrapped.pcache.xCachesize(p, n);\n}  \nstatic int wrPCachePagecount(sqlite3_pcache *p){\n  return wrapped.pcache.xPagecount(p);\n}  \nstatic sqlite3_pcache_page *wrPCacheFetch(sqlite3_pcache *p, unsigned a, int b){\n  return wrapped.pcache.xFetch(p, a, b);\n}  \nstatic void wrPCacheUnpin(sqlite3_pcache *p, sqlite3_pcache_page *a, int b){\n  wrapped.pcache.xUnpin(p, a, b);\n}  \nstatic void wrPCacheRekey(\n  sqlite3_pcache *p, \n  sqlite3_pcache_page *a, \n  unsigned b, \n  unsigned c\n){\n  wrapped.pcache.xRekey(p, a, b, c);\n}  \nstatic void wrPCacheTruncate(sqlite3_pcache *p, unsigned a){\n  wrapped.pcache.xTruncate(p, a);\n}  \nstatic void wrPCacheDestroy(sqlite3_pcache *p){\n  wrapped.pcache.xDestroy(p);\n}  \n\nstatic void installInitWrappers(void){\n  sqlite3_mutex_methods mutexmethods = {\n    wrMutexInit,  wrMutexEnd,   wrMutexAlloc,\n    wrMutexFree,  wrMutexEnter, wrMutexTry,\n    wrMutexLeave, wrMutexHeld,  wrMutexNotheld\n  };\n  sqlite3_pcache_methods2 pcachemethods = {\n    1, 0,\n    wrPCacheInit,      wrPCacheShutdown,  wrPCacheCreate, \n    wrPCacheCachesize, wrPCachePagecount, wrPCacheFetch,\n    wrPCacheUnpin,     wrPCacheRekey,     wrPCacheTruncate,  \n    wrPCacheDestroy\n  };\n  sqlite3_mem_methods memmethods = {\n    wrMemMalloc,   wrMemFree,    wrMemRealloc,\n    wrMemSize,     wrMemRoundup, wrMemInit,\n    wrMemShutdown,\n    0\n  };\n\n  memset(&wrapped, 0, sizeof(wrapped));\n\n  sqlite3_shutdown();\n  sqlite3_config(SQLITE_CONFIG_GETMUTEX, &wrapped.mutex);\n  sqlite3_config(SQLITE_CONFIG_GETMALLOC, &wrapped.mem);\n  sqlite3_config(SQLITE_CONFIG_GETPCACHE2, &wrapped.pcache);\n  sqlite3_config(SQLITE_CONFIG_MUTEX, &mutexmethods);\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &memmethods);\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &pcachemethods);\n}\n\nstatic int SQLITE_TCLAPI init_wrapper_install(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int i;\n  installInitWrappers();\n  for(i=1; i<objc; i++){\n    char *z = Tcl_GetString(objv[i]);\n    if( strcmp(z, \"mem\")==0 ){\n      wrapped.mem_fail = 1;\n    }else if( strcmp(z, \"mutex\")==0 ){\n      wrapped.mutex_fail = 1;\n    }else if( strcmp(z, \"pcache\")==0 ){\n      wrapped.pcache_fail = 1;\n    }else{\n      Tcl_AppendResult(interp, \"Unknown argument: \\\"\", z, \"\\\"\");\n      return TCL_ERROR;\n    }\n  }\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI init_wrapper_uninstall(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  sqlite3_shutdown();\n  sqlite3_config(SQLITE_CONFIG_MUTEX, &wrapped.mutex);\n  sqlite3_config(SQLITE_CONFIG_MALLOC, &wrapped.mem);\n  sqlite3_config(SQLITE_CONFIG_PCACHE2, &wrapped.pcache);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI init_wrapper_clear(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  wrapped.mem_fail = 0;\n  wrapped.mutex_fail = 0;\n  wrapped.pcache_fail = 0;\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI init_wrapper_query(\n  ClientData clientData, /* Unused */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  Tcl_Obj *pRet;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  if( wrapped.mutex_init ){\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"mutex\", -1));\n  }\n  if( wrapped.mem_init ){\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"mem\", -1));\n  }\n  if( wrapped.pcache_init ){\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(\"pcache\", -1));\n  }\n\n  Tcl_SetObjResult(interp, pRet);\n  return TCL_OK;\n}\n\nint Sqlitetest_init_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aObjCmd[] = {\n    {\"init_wrapper_install\",   init_wrapper_install},\n    {\"init_wrapper_query\",     init_wrapper_query  },\n    {\"init_wrapper_uninstall\", init_wrapper_uninstall},\n    {\"init_wrapper_clear\",     init_wrapper_clear}\n  };\n  int i;\n\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);\n  }\n\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_intarray.c",
    "content": "/*\n** 2009 November 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements a read-only VIRTUAL TABLE that contains the\n** content of a C-language array of integer values.  See the corresponding\n** header file for full details.\n*/\n#include \"test_intarray.h\"\n#include <string.h>\n#include <assert.h>\n\n\n/*\n** Definition of the sqlite3_intarray object.\n**\n** The internal representation of an intarray object is subject\n** to change, is not externally visible, and should be used by\n** the implementation of intarray only.  This object is opaque\n** to users.\n*/\nstruct sqlite3_intarray {\n  int n;                    /* Number of elements in the array */\n  sqlite3_int64 *a;         /* Contents of the array */\n  void (*xFree)(void*);     /* Function used to free a[] */\n};\n\n/* Objects used internally by the virtual table implementation */\ntypedef struct intarray_vtab intarray_vtab;\ntypedef struct intarray_cursor intarray_cursor;\n\n/* An intarray table object */\nstruct intarray_vtab {\n  sqlite3_vtab base;            /* Base class */\n  sqlite3_intarray *pContent;   /* Content of the integer array */\n};\n\n/* An intarray cursor object */\nstruct intarray_cursor {\n  sqlite3_vtab_cursor base;    /* Base class */\n  int i;                       /* Current cursor position */\n};\n\n/*\n** None of this works unless we have virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Free an sqlite3_intarray object.\n*/\nstatic void intarrayFree(sqlite3_intarray *p){\n  if( p->xFree ){\n    p->xFree(p->a);\n  }\n  sqlite3_free(p);\n}\n\n/*\n** Table destructor for the intarray module.\n*/\nstatic int intarrayDestroy(sqlite3_vtab *p){\n  intarray_vtab *pVtab = (intarray_vtab*)p;\n  sqlite3_free(pVtab);\n  return 0;\n}\n\n/*\n** Table constructor for the intarray module.\n*/\nstatic int intarrayCreate(\n  sqlite3 *db,              /* Database where module is created */\n  void *pAux,               /* clientdata for the module */\n  int argc,                 /* Number of arguments */\n  const char *const*argv,   /* Value for all arguments */\n  sqlite3_vtab **ppVtab,    /* Write the new virtual table object here */\n  char **pzErr              /* Put error message text here */\n){\n  int rc = SQLITE_NOMEM;\n  intarray_vtab *pVtab = sqlite3_malloc64(sizeof(intarray_vtab));\n\n  if( pVtab ){\n    memset(pVtab, 0, sizeof(intarray_vtab));\n    pVtab->pContent = (sqlite3_intarray*)pAux;\n    rc = sqlite3_declare_vtab(db, \"CREATE TABLE x(value INTEGER PRIMARY KEY)\");\n  }\n  *ppVtab = (sqlite3_vtab *)pVtab;\n  return rc;\n}\n\n/*\n** Open a new cursor on the intarray table.\n*/\nstatic int intarrayOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  intarray_cursor *pCur;\n  pCur = sqlite3_malloc64(sizeof(intarray_cursor));\n  if( pCur ){\n    memset(pCur, 0, sizeof(intarray_cursor));\n    *ppCursor = (sqlite3_vtab_cursor *)pCur;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Close a intarray table cursor.\n*/\nstatic int intarrayClose(sqlite3_vtab_cursor *cur){\n  intarray_cursor *pCur = (intarray_cursor *)cur;\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a column of data.\n*/\nstatic int intarrayColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  intarray_cursor *pCur = (intarray_cursor*)cur;\n  intarray_vtab *pVtab = (intarray_vtab*)cur->pVtab;\n  if( pCur->i>=0 && pCur->i<pVtab->pContent->n ){\n    sqlite3_result_int64(ctx, pVtab->pContent->a[pCur->i]);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve the current rowid.\n*/\nstatic int intarrayRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  intarray_cursor *pCur = (intarray_cursor *)cur;\n  *pRowid = pCur->i;\n  return SQLITE_OK;\n}\n\nstatic int intarrayEof(sqlite3_vtab_cursor *cur){\n  intarray_cursor *pCur = (intarray_cursor *)cur;\n  intarray_vtab *pVtab = (intarray_vtab *)cur->pVtab;\n  return pCur->i>=pVtab->pContent->n;\n}\n\n/*\n** Advance the cursor to the next row.\n*/\nstatic int intarrayNext(sqlite3_vtab_cursor *cur){\n  intarray_cursor *pCur = (intarray_cursor *)cur;\n  pCur->i++;\n  return SQLITE_OK;\n}\n\n/*\n** Reset a intarray table cursor.\n*/\nstatic int intarrayFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  intarray_cursor *pCur = (intarray_cursor *)pVtabCursor;\n  pCur->i = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Analyse the WHERE condition.\n*/\nstatic int intarrayBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that merely echos method calls into TCL\n** variables.\n*/\nstatic sqlite3_module intarrayModule = {\n  0,                           /* iVersion */\n  intarrayCreate,              /* xCreate - create a new virtual table */\n  intarrayCreate,              /* xConnect - connect to an existing vtab */\n  intarrayBestIndex,           /* xBestIndex - find the best query index */\n  intarrayDestroy,             /* xDisconnect - disconnect a vtab */\n  intarrayDestroy,             /* xDestroy - destroy a vtab */\n  intarrayOpen,                /* xOpen - open a cursor */\n  intarrayClose,               /* xClose - close a cursor */\n  intarrayFilter,              /* xFilter - configure scan constraints */\n  intarrayNext,                /* xNext - advance a cursor */\n  intarrayEof,                 /* xEof */\n  intarrayColumn,              /* xColumn - read data */\n  intarrayRowid,               /* xRowid - read data */\n  0,                           /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n/*\n** Invoke this routine to create a specific instance of an intarray object.\n** The new intarray object is returned by the 3rd parameter.\n**\n** Each intarray object corresponds to a virtual table in the TEMP table\n** with a name of zName.\n**\n** Destroy the intarray object by dropping the virtual table.  If not done\n** explicitly by the application, the virtual table will be dropped implicitly\n** by the system when the database connection is closed.\n*/\nSQLITE_API int sqlite3_intarray_create(\n  sqlite3 *db,\n  const char *zName,\n  sqlite3_intarray **ppReturn\n){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_intarray *p;\n\n  *ppReturn = p = sqlite3_malloc64( sizeof(*p) );\n  if( p==0 ){\n    return SQLITE_NOMEM;\n  }\n  memset(p, 0, sizeof(*p));\n  rc = sqlite3_create_module_v2(db, zName, &intarrayModule, p,\n                                (void(*)(void*))intarrayFree);\n  if( rc==SQLITE_OK ){\n    char *zSql;\n    zSql = sqlite3_mprintf(\"CREATE VIRTUAL TABLE temp.%Q USING %Q\",\n                           zName, zName);\n    rc = sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n#endif\n  return rc;\n}\n\n/*\n** Bind a new array array of integers to a specific intarray object.\n**\n** The array of integers bound must be unchanged for the duration of\n** any query against the corresponding virtual table.  If the integer\n** array does change or is deallocated undefined behavior will result.\n*/\nSQLITE_API int sqlite3_intarray_bind(\n  sqlite3_intarray *pIntArray,   /* The intarray object to bind to */\n  int nElements,                 /* Number of elements in the intarray */\n  sqlite3_int64 *aElements,      /* Content of the intarray */\n  void (*xFree)(void*)           /* How to dispose of the intarray when done */\n){\n  if( pIntArray->xFree ){\n    pIntArray->xFree(pIntArray->a);\n  }\n  pIntArray->n = nElements;\n  pIntArray->a = aElements;\n  pIntArray->xFree = xFree;\n  return SQLITE_OK;\n}\n\n\n/*****************************************************************************\n** Everything below is interface for testing this module.\n*/\n#ifdef SQLITE_TEST\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\n/*\n** Routines to encode and decode pointers\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\nextern void *sqlite3TestTextToPtr(const char*);\nextern int sqlite3TestMakePointerStr(Tcl_Interp*, char *zPtr, void*);\nextern const char *sqlite3ErrName(int);\n\n/*\n**    sqlite3_intarray_create  DB  NAME\n**\n** Invoke the sqlite3_intarray_create interface.  A string that becomes\n** the first parameter to sqlite3_intarray_bind.\n*/\nstatic int SQLITE_TCLAPI test_intarray_create(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  const char *zName;\n  sqlite3_intarray *pArray;\n  int rc = SQLITE_OK;\n  char zPtr[100];\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zName = Tcl_GetString(objv[2]);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  rc = sqlite3_intarray_create(db, zName, &pArray);\n#endif\n  if( rc!=SQLITE_OK ){\n    assert( pArray==0 );\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), (char*)0);\n    return TCL_ERROR;\n  }\n  sqlite3TestMakePointerStr(interp, zPtr, pArray);\n  Tcl_AppendResult(interp, zPtr, (char*)0);\n  return TCL_OK;\n}\n\n/*\n**    sqlite3_intarray_bind  INTARRAY  ?VALUE ...?\n**\n** Invoke the sqlite3_intarray_bind interface on the given array of integers.\n*/\nstatic int SQLITE_TCLAPI test_intarray_bind(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3_intarray *pArray;\n  int rc = SQLITE_OK;\n  int i, n;\n  sqlite3_int64 *a;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"INTARRAY\");\n    return TCL_ERROR;\n  }\n  pArray = (sqlite3_intarray*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  n = objc - 2;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  a = sqlite3_malloc64( sizeof(a[0])*n );\n  if( a==0 ){\n    Tcl_AppendResult(interp, \"SQLITE_NOMEM\", (char*)0);\n    return TCL_ERROR;\n  }\n  for(i=0; i<n; i++){\n    Tcl_WideInt x = 0;\n    Tcl_GetWideIntFromObj(0, objv[i+2], &x);\n    a[i] = x;\n  }\n  rc = sqlite3_intarray_bind(pArray, n, a, sqlite3_free);\n  if( rc!=SQLITE_OK ){\n    Tcl_AppendResult(interp, sqlite3ErrName(rc), (char*)0);\n    return TCL_ERROR;\n  }\n#endif\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetestintarray_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"sqlite3_intarray_create\", test_intarray_create, 0 },\n     { \"sqlite3_intarray_bind\", test_intarray_bind, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n  return TCL_OK;\n}\n\n#endif /* SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_intarray.h",
    "content": "/*\n** 2009 November 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This is the C-language interface definition for the \"intarray\" or\n** integer array virtual table for SQLite.\n**\n** The intarray virtual table is designed to facilitate using an\n** array of integers as the right-hand side of an IN operator.  So\n** instead of doing a prepared statement like this:\n**\n**     SELECT * FROM table WHERE x IN (?,?,?,...,?);\n**\n** And then binding indivdual integers to each of ? slots, a C-language\n** application can create an intarray object (named \"ex1\" in the following\n** example), prepare a statement like this:\n**\n**     SELECT * FROM table WHERE x IN ex1;\n**\n** Then bind an ordinary C/C++ array of integer values to the ex1 object\n** to run the statement.\n**\n** USAGE:\n**\n** One or more intarray objects can be created as follows:\n**\n**      sqlite3_intarray *p1, *p2, *p3;\n**      sqlite3_intarray_create(db, \"ex1\", &p1);\n**      sqlite3_intarray_create(db, \"ex2\", &p2);\n**      sqlite3_intarray_create(db, \"ex3\", &p3);\n**\n** Each call to sqlite3_intarray_create() generates a new virtual table\n** module and a singleton of that virtual table module in the TEMP\n** database.  Both the module and the virtual table instance use the\n** name given by the second parameter.  The virtual tables can then be\n** used in prepared statements:\n**\n**      SELECT * FROM t1, t2, t3\n**       WHERE t1.x IN ex1\n**         AND t2.y IN ex2\n**         AND t3.z IN ex3;\n**\n** Each integer array is initially empty.  New arrays can be bound to\n** an integer array as follows:\n**\n**     sqlite3_int64 a1[] = { 1, 2, 3, 4 };\n**     sqlite3_int64 a2[] = { 5, 6, 7, 8, 9, 10, 11 };\n**     sqlite3_int64 *a3 = sqlite3_malloc( 100*sizeof(sqlite3_int64) );\n**     // Fill in content of a3[]\n**     sqlite3_intarray_bind(p1, 4, a1, 0);\n**     sqlite3_intarray_bind(p2, 7, a2, 0);\n**     sqlite3_intarray_bind(p3, 100, a3, sqlite3_free);\n**\n** A single intarray object can be rebound multiple times.  But do not\n** attempt to change the bindings of an intarray while it is in the middle\n** of a query.\n**\n** The array that holds the integers is automatically freed by the function\n** in the fourth parameter to sqlite3_intarray_bind() when the array is no\n** longer needed.  The application must not change the intarray values\n** while an intarray is in the middle of a query.\n**\n** The intarray object is automatically destroyed when its corresponding\n** virtual table is dropped.  Since the virtual tables are created in the\n** TEMP database, they are automatically dropped when the database connection\n** closes so the application does not normally need to take any special\n** action to free the intarray objects.\n*/\n#include \"sqlite3.h\"\n#ifndef SQLITE_INTARRAY_H\n#define SQLITE_INTARRAY_H\n\n/*\n** Make sure we can call this stuff from C++.\n*/\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** An sqlite3_intarray is an abstract type to stores an instance of\n** an integer array.\n*/\ntypedef struct sqlite3_intarray sqlite3_intarray;\n\n/*\n** Invoke this routine to create a specific instance of an intarray object.\n** The new intarray object is returned by the 3rd parameter.\n**\n** Each intarray object corresponds to a virtual table in the TEMP table\n** with a name of zName.\n**\n** Destroy the intarray object by dropping the virtual table.  If not done\n** explicitly by the application, the virtual table will be dropped implicitly\n** by the system when the database connection is closed.\n*/\nSQLITE_API int sqlite3_intarray_create(\n  sqlite3 *db,\n  const char *zName,\n  sqlite3_intarray **ppReturn\n);\n\n/*\n** Bind a new array array of integers to a specific intarray object.\n**\n** The array of integers bound must be unchanged for the duration of\n** any query against the corresponding virtual table.  If the integer\n** array does change or is deallocated undefined behavior will result.\n*/\nSQLITE_API int sqlite3_intarray_bind(\n  sqlite3_intarray *pIntArray,   /* The intarray object to bind to */\n  int nElements,                 /* Number of elements in the intarray */\n  sqlite3_int64 *aElements,      /* Content of the intarray */\n  void (*xFree)(void*)           /* How to dispose of the intarray when done */\n);\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n#endif /* SQLITE_INTARRAY_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_journal.c",
    "content": "/*\n** 2008 Jan 22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code for a VFS layer that acts as a wrapper around\n** an existing VFS. The code in this file attempts to verify that SQLite\n** correctly populates and syncs a journal file before writing to a\n** corresponding database file.\n**\n** INTERFACE\n**\n**   The public interface to this wrapper VFS is two functions:\n**\n**     jt_register()\n**     jt_unregister()\n**\n**   See header comments associated with those two functions below for \n**   details.\n**\n** LIMITATIONS\n**\n**   This wrapper will not work if \"PRAGMA synchronous = off\" is used.\n**\n** OPERATION\n**\n**  Starting a Transaction:\n**\n**   When a write-transaction is started, the contents of the database is\n**   inspected and the following data stored as part of the database file \n**   handle (type struct jt_file):\n**\n**     a) The page-size of the database file.\n**     b) The number of pages that are in the database file.\n**     c) The set of page numbers corresponding to free-list leaf pages.\n**     d) A check-sum for every page in the database file.\n**\n**   The start of a write-transaction is deemed to have occurred when a \n**   28-byte journal header is written to byte offset 0 of the journal \n**   file.\n**\n**  Syncing the Journal File:\n**\n**   Whenever the xSync method is invoked to sync a journal-file, the\n**   contents of the journal file are read. For each page written to\n**   the journal file, a check-sum is calculated and compared to the  \n**   check-sum calculated for the corresponding database page when the\n**   write-transaction was initialized. The success of the comparison\n**   is assert()ed. So if SQLite has written something other than the\n**   original content to the database file, an assert() will fail.\n**\n**   Additionally, the set of page numbers for which records exist in\n**   the journal file is added to (unioned with) the set of page numbers\n**   corresponding to free-list leaf pages collected when the \n**   write-transaction was initialized. This set comprises the page-numbers \n**   corresponding to those pages that SQLite may now safely modify.\n**\n**  Writing to the Database File:\n**\n**   When a block of data is written to a database file, the following\n**   invariants are asserted:\n**\n**     a) That the block of data is an aligned block of page-size bytes.\n**\n**     b) That if the page being written did not exist when the \n**        transaction was started (i.e. the database file is growing), then\n**        the journal-file must have been synced at least once since\n**        the start of the transaction.\n**\n**     c) That if the page being written did exist when the transaction \n**        was started, then the page must have either been a free-list\n**        leaf page at the start of the transaction, or else must have\n**        been stored in the journal file prior to the most recent sync.\n**\n**  Closing a Transaction:\n**\n**   When a transaction is closed, all data collected at the start of\n**   the transaction, or following an xSync of a journal-file, is \n**   discarded. The end of a transaction is recognized when any one \n**   of the following occur:\n**\n**     a) A block of zeroes (or anything else that is not a valid \n**        journal-header) is written to the start of the journal file.\n**\n**     b) A journal file is truncated to zero bytes in size using xTruncate.\n**\n**     c) The journal file is deleted using xDelete.\n*/\n#if SQLITE_TEST          /* This file is used for testing only */\n\n#include \"sqlite3.h\"\n#include \"sqliteInt.h\"\n\n/*\n** Maximum pathname length supported by the jt backend.\n*/\n#define JT_MAX_PATHNAME 512\n\n/*\n** Name used to identify this VFS.\n*/\n#define JT_VFS_NAME \"jt\"\n\ntypedef struct jt_file jt_file;\nstruct jt_file {\n  sqlite3_file base;\n  const char *zName;       /* Name of open file */\n  int flags;               /* Flags the file was opened with */\n\n  /* The following are only used by database file file handles */\n  int eLock;               /* Current lock held on the file */\n  u32 nPage;               /* Size of file in pages when transaction started */\n  u32 nPagesize;           /* Page size when transaction started */\n  Bitvec *pWritable;       /* Bitvec of pages that may be written to the file */\n  u32 *aCksum;             /* Checksum for first nPage pages */\n  int nSync;               /* Number of times journal file has been synced */\n\n  /* Only used by journal file-handles */\n  sqlite3_int64 iMaxOff;   /* Maximum offset written to this transaction */\n\n  jt_file *pNext;          /* All files are stored in a linked list */\n  sqlite3_file *pReal;     /* The file handle for the underlying vfs */\n};\n\n/*\n** Method declarations for jt_file.\n*/\nstatic int jtClose(sqlite3_file*);\nstatic int jtRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int jtWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int jtTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int jtSync(sqlite3_file*, int flags);\nstatic int jtFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int jtLock(sqlite3_file*, int);\nstatic int jtUnlock(sqlite3_file*, int);\nstatic int jtCheckReservedLock(sqlite3_file*, int *);\nstatic int jtFileControl(sqlite3_file*, int op, void *pArg);\nstatic int jtSectorSize(sqlite3_file*);\nstatic int jtDeviceCharacteristics(sqlite3_file*);\n\n/*\n** Method declarations for jt_vfs.\n*/\nstatic int jtOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int jtDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int jtAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int jtFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *jtDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void jtDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*jtDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);\nstatic void jtDlClose(sqlite3_vfs*, void*);\nstatic int jtRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int jtSleep(sqlite3_vfs*, int microseconds);\nstatic int jtCurrentTime(sqlite3_vfs*, double*);\nstatic int jtCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\nstatic int jtGetLastError(sqlite3_vfs*, int, char*);\n\nstatic sqlite3_vfs jt_vfs = {\n  2,                             /* iVersion */\n  sizeof(jt_file),               /* szOsFile */\n  JT_MAX_PATHNAME,               /* mxPathname */\n  0,                             /* pNext */\n  JT_VFS_NAME,                   /* zName */\n  0,                             /* pAppData */\n  jtOpen,                        /* xOpen */\n  jtDelete,                      /* xDelete */\n  jtAccess,                      /* xAccess */\n  jtFullPathname,                /* xFullPathname */\n  jtDlOpen,                      /* xDlOpen */\n  jtDlError,                     /* xDlError */\n  jtDlSym,                       /* xDlSym */\n  jtDlClose,                     /* xDlClose */\n  jtRandomness,                  /* xRandomness */\n  jtSleep,                       /* xSleep */\n  jtCurrentTime,                 /* xCurrentTime */\n  jtGetLastError,                /* xGetLastError */\n  jtCurrentTimeInt64             /* xCurrentTimeInt64 */\n};\n\nstatic sqlite3_io_methods jt_io_methods = {\n  1,                             /* iVersion */\n  jtClose,                       /* xClose */\n  jtRead,                        /* xRead */\n  jtWrite,                       /* xWrite */\n  jtTruncate,                    /* xTruncate */\n  jtSync,                        /* xSync */\n  jtFileSize,                    /* xFileSize */\n  jtLock,                        /* xLock */\n  jtUnlock,                      /* xUnlock */\n  jtCheckReservedLock,           /* xCheckReservedLock */\n  jtFileControl,                 /* xFileControl */\n  jtSectorSize,                  /* xSectorSize */\n  jtDeviceCharacteristics        /* xDeviceCharacteristics */\n};\n\nstruct JtGlobal {\n  sqlite3_vfs *pVfs;             /* Parent VFS */\n  jt_file *pList;                /* List of all open files */\n};\nstatic struct JtGlobal g = {0, 0};\n\n/*\n** Functions to obtain and relinquish a mutex to protect g.pList. The\n** STATIC_PRNG mutex is reused, purely for the sake of convenience.\n*/\nstatic void enterJtMutex(void){\n  sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG));\n}\nstatic void leaveJtMutex(void){\n  sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG));\n}\n\nextern int sqlite3_io_error_pending;\nextern int sqlite3_io_error_hit;\nstatic void stop_ioerr_simulation(int *piSave, int *piSave2){\n  *piSave = sqlite3_io_error_pending;\n  *piSave2 = sqlite3_io_error_hit;\n  sqlite3_io_error_pending = -1;\n  sqlite3_io_error_hit = 0;\n}\nstatic void start_ioerr_simulation(int iSave, int iSave2){\n  sqlite3_io_error_pending = iSave;\n  sqlite3_io_error_hit = iSave2;\n}\n\n/*\n** The jt_file pointed to by the argument may or may not be a file-handle\n** open on a main database file. If it is, and a transaction is currently\n** opened on the file, then discard all transaction related data.\n*/\nstatic void closeTransaction(jt_file *p){\n  sqlite3BitvecDestroy(p->pWritable);\n  sqlite3_free(p->aCksum);\n  p->pWritable = 0;\n  p->aCksum = 0;\n  p->nSync = 0;\n}\n\n/*\n** Close an jt-file.\n*/\nstatic int jtClose(sqlite3_file *pFile){\n  jt_file **pp;\n  jt_file *p = (jt_file *)pFile;\n\n  closeTransaction(p);\n  enterJtMutex();\n  if( p->zName ){\n    for(pp=&g.pList; *pp!=p; pp=&(*pp)->pNext);\n    *pp = p->pNext;\n  }\n  leaveJtMutex();\n  sqlite3OsClose(p->pReal);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from an jt-file.\n*/\nstatic int jtRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  jt_file *p = (jt_file *)pFile;\n  return sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);\n}\n\n/*\n** Parameter zJournal is the name of a journal file that is currently \n** open. This function locates and returns the handle opened on the\n** corresponding database file by the pager that currently has the\n** journal file opened. This file-handle is identified by the \n** following properties:\n**\n**   a) SQLITE_OPEN_MAIN_DB was specified when the file was opened.\n**\n**   b) The file-name specified when the file was opened matches\n**      all but the final 8 characters of the journal file name.\n**\n**   c) There is currently a reserved lock on the file. This \n**      condition is waived if the noLock argument is non-zero.\n**/\nstatic jt_file *locateDatabaseHandle(const char *zJournal, int noLock){\n  jt_file *pMain = 0;\n  enterJtMutex();\n  for(pMain=g.pList; pMain; pMain=pMain->pNext){\n    int nName = (int)(strlen(zJournal) - strlen(\"-journal\"));\n    if( (pMain->flags&SQLITE_OPEN_MAIN_DB)\n     && ((int)strlen(pMain->zName)==nName)\n     && 0==memcmp(pMain->zName, zJournal, nName)\n     && ((pMain->eLock>=SQLITE_LOCK_RESERVED) || noLock)\n    ){\n      break;\n    }\n  }\n  leaveJtMutex();\n  return pMain;\n}\n\n/*\n** Parameter z points to a buffer of 4 bytes in size containing a \n** unsigned 32-bit integer stored in big-endian format. Decode the \n** integer and return its value.\n*/\nstatic u32 decodeUint32(const unsigned char *z){\n  return (z[0]<<24) + (z[1]<<16) + (z[2]<<8) + z[3];\n}\n\n/*\n** Calculate a checksum from the buffer of length n bytes pointed to\n** by parameter z.\n*/\nstatic u32 genCksum(const unsigned char *z, int n){\n  int i;\n  u32 cksum = 0;\n  for(i=0; i<n; i++){\n    cksum = cksum + z[i] + (cksum<<3);\n  }\n  return cksum;\n}\n\n/*\n** The first argument, zBuf, points to a buffer containing a 28 byte\n** serialized journal header. This function deserializes four of the\n** integer fields contained in the journal header and writes their\n** values to the output variables.\n**\n** SQLITE_OK is returned if the journal-header is successfully \n** decoded. Otherwise, SQLITE_ERROR.\n*/\nstatic int decodeJournalHdr(\n  const unsigned char *zBuf,         /* Input: 28 byte journal header */\n  u32 *pnRec,                        /* Out: Number of journalled records */\n  u32 *pnPage,                       /* Out: Original database page count */\n  u32 *pnSector,                     /* Out: Sector size in bytes */\n  u32 *pnPagesize                    /* Out: Page size in bytes */\n){\n  unsigned char aMagic[] = { 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63, 0xd7 };\n  if( memcmp(aMagic, zBuf, 8) ) return SQLITE_ERROR;\n  if( pnRec ) *pnRec = decodeUint32(&zBuf[8]);\n  if( pnPage ) *pnPage = decodeUint32(&zBuf[16]);\n  if( pnSector ) *pnSector = decodeUint32(&zBuf[20]);\n  if( pnPagesize ) *pnPagesize = decodeUint32(&zBuf[24]);\n  return SQLITE_OK;\n}\n\n/*\n** This function is called when a new transaction is opened, just after\n** the first journal-header is written to the journal file.\n*/\nstatic int openTransaction(jt_file *pMain, jt_file *pJournal){\n  unsigned char *aData;\n  sqlite3_file *p = pMain->pReal;\n  int rc = SQLITE_OK;\n\n  closeTransaction(pMain);\n  aData = sqlite3_malloc(pMain->nPagesize);\n  pMain->pWritable = sqlite3BitvecCreate(pMain->nPage);\n  pMain->aCksum = sqlite3_malloc(sizeof(u32) * (pMain->nPage + 1));\n  pJournal->iMaxOff = 0;\n\n  if( !pMain->pWritable || !pMain->aCksum || !aData ){\n    rc = SQLITE_IOERR_NOMEM;\n  }else if( pMain->nPage>0 ){\n    u32 iTrunk;\n    int iSave;\n    int iSave2;\n\n    stop_ioerr_simulation(&iSave, &iSave2);\n\n    /* Read the database free-list. Add the page-number for each free-list\n    ** leaf to the jt_file.pWritable bitvec.\n    */\n    rc = sqlite3OsRead(p, aData, pMain->nPagesize, 0);\n    if( rc==SQLITE_OK ){\n      u32 nDbsize = decodeUint32(&aData[28]);\n      if( nDbsize>0 && memcmp(&aData[24], &aData[92], 4)==0 ){\n        u32 iPg;\n        for(iPg=nDbsize+1; iPg<=pMain->nPage; iPg++){\n          sqlite3BitvecSet(pMain->pWritable, iPg);\n        }\n      }\n    }\n    iTrunk = decodeUint32(&aData[32]);\n    while( rc==SQLITE_OK && iTrunk>0 ){\n      u32 nLeaf;\n      u32 iLeaf;\n      sqlite3_int64 iOff = (i64)(iTrunk-1)*pMain->nPagesize;\n      rc = sqlite3OsRead(p, aData, pMain->nPagesize, iOff);\n      nLeaf = decodeUint32(&aData[4]);\n      for(iLeaf=0; rc==SQLITE_OK && iLeaf<nLeaf; iLeaf++){\n        u32 pgno = decodeUint32(&aData[8+4*iLeaf]);\n        sqlite3BitvecSet(pMain->pWritable, pgno);\n      }\n      iTrunk = decodeUint32(aData);\n    }\n\n    /* Calculate and store a checksum for each page in the database file. */\n    if( rc==SQLITE_OK ){\n      int ii;\n      for(ii=0; rc==SQLITE_OK && ii<(int)pMain->nPage; ii++){\n        i64 iOff = (i64)(pMain->nPagesize) * (i64)ii;\n        if( iOff==PENDING_BYTE ) continue;\n        rc = sqlite3OsRead(pMain->pReal, aData, pMain->nPagesize, iOff);\n        pMain->aCksum[ii] = genCksum(aData, pMain->nPagesize);\n        if( ii+1==(int)pMain->nPage && rc==SQLITE_IOERR_SHORT_READ ){\n          rc = SQLITE_OK;\n        }\n      }\n    }\n\n    start_ioerr_simulation(iSave, iSave2);\n  }\n\n  sqlite3_free(aData);\n  return rc;\n}\n\n/*\n** The first argument to this function is a handle open on a journal file.\n** This function reads the journal file and adds the page number for each\n** page in the journal to the Bitvec object passed as the second argument.\n*/\nstatic int readJournalFile(jt_file *p, jt_file *pMain){\n  int rc = SQLITE_OK;\n  unsigned char zBuf[28];\n  sqlite3_file *pReal = p->pReal;\n  sqlite3_int64 iOff = 0;\n  sqlite3_int64 iSize = p->iMaxOff;\n  unsigned char *aPage;\n  int iSave;\n  int iSave2;\n\n  aPage = sqlite3_malloc(pMain->nPagesize);\n  if( !aPage ){\n    return SQLITE_IOERR_NOMEM;\n  }\n\n  stop_ioerr_simulation(&iSave, &iSave2);\n\n  while( rc==SQLITE_OK && iOff<iSize ){\n    u32 nRec, nPage, nSector, nPagesize;\n    u32 ii;\n\n    /* Read and decode the next journal-header from the journal file. */\n    rc = sqlite3OsRead(pReal, zBuf, 28, iOff);\n    if( rc!=SQLITE_OK \n     || decodeJournalHdr(zBuf, &nRec, &nPage, &nSector, &nPagesize) \n    ){\n      goto finish_rjf;\n    }\n    iOff += nSector;\n\n    if( nRec==0 ){\n      /* A trick. There might be another journal-header immediately \n      ** following this one. In this case, 0 records means 0 records, \n      ** not \"read until the end of the file\". See also ticket #2565.\n      */\n      if( iSize>=(iOff+nSector) ){\n        rc = sqlite3OsRead(pReal, zBuf, 28, iOff);\n        if( rc!=SQLITE_OK || 0==decodeJournalHdr(zBuf, 0, 0, 0, 0) ){\n          continue;\n        }\n      }\n      nRec = (u32)((iSize-iOff) / (pMain->nPagesize+8));\n    }\n\n    /* Read all the records that follow the journal-header just read. */\n    for(ii=0; rc==SQLITE_OK && ii<nRec && iOff<iSize; ii++){\n      u32 pgno;\n      rc = sqlite3OsRead(pReal, zBuf, 4, iOff);\n      if( rc==SQLITE_OK ){\n        pgno = decodeUint32(zBuf);\n        if( pgno>0 && pgno<=pMain->nPage ){\n          if( 0==sqlite3BitvecTest(pMain->pWritable, pgno) ){\n            rc = sqlite3OsRead(pReal, aPage, pMain->nPagesize, iOff+4);\n            if( rc==SQLITE_OK ){\n              u32 cksum = genCksum(aPage, pMain->nPagesize);\n              assert( cksum==pMain->aCksum[pgno-1] );\n            }\n          }\n          sqlite3BitvecSet(pMain->pWritable, pgno);\n        }\n        iOff += (8 + pMain->nPagesize);\n      }\n    }\n\n    iOff = ((iOff + (nSector-1)) / nSector) * nSector;\n  }\n\nfinish_rjf:\n  start_ioerr_simulation(iSave, iSave2);\n  sqlite3_free(aPage);\n  if( rc==SQLITE_IOERR_SHORT_READ ){\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Write data to an jt-file.\n*/\nstatic int jtWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc;\n  jt_file *p = (jt_file *)pFile;\n  if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){\n    if( iOfst==0 ){\n      jt_file *pMain = locateDatabaseHandle(p->zName, 0);\n      assert( pMain );\n  \n      if( iAmt==28 ){\n        /* Zeroing the first journal-file header. This is the end of a\n        ** transaction. */\n        closeTransaction(pMain);\n      }else if( iAmt!=12 ){\n        /* Writing the first journal header to a journal file. This happens\n        ** when a transaction is first started.  */\n        u8 *z = (u8 *)zBuf;\n        pMain->nPage = decodeUint32(&z[16]);\n        pMain->nPagesize = decodeUint32(&z[24]);\n        if( SQLITE_OK!=(rc=openTransaction(pMain, p)) ){\n          return rc;\n        }\n      }\n    }\n    if( p->iMaxOff<(iOfst + iAmt) ){\n      p->iMaxOff = iOfst + iAmt;\n    }\n  }\n\n  if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){\n    if( iAmt<(int)p->nPagesize \n     && p->nPagesize%iAmt==0 \n     && iOfst>=(PENDING_BYTE+512) \n     && iOfst+iAmt<=PENDING_BYTE+p->nPagesize\n    ){\n      /* No-op. This special case is hit when the backup code is copying a\n      ** to a database with a larger page-size than the source database and\n      ** it needs to fill in the non-locking-region part of the original\n      ** pending-byte page.\n      */\n    }else{\n      u32 pgno = (u32)(iOfst/p->nPagesize + 1);\n      assert( (iAmt==1||iAmt==(int)p->nPagesize) &&\n              ((iOfst+iAmt)%p->nPagesize)==0 );\n      /* The following assert() statements may fail if this layer is used\n      ** with a connection in \"PRAGMA synchronous=off\" mode. If they\n      ** fail with sync=normal or sync=full, this may indicate problem.  */\n      assert( pgno<=p->nPage || p->nSync>0 );\n      assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) );\n    }\n  }\n\n  rc = sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst);\n  if( (p->flags&SQLITE_OPEN_MAIN_JOURNAL) && iAmt==12 ){\n    jt_file *pMain = locateDatabaseHandle(p->zName, 0);\n    int rc2 = readJournalFile(p, pMain);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  return rc;\n}\n\n/*\n** Truncate an jt-file.\n*/\nstatic int jtTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  jt_file *p = (jt_file *)pFile;\n  if( p->flags&SQLITE_OPEN_MAIN_JOURNAL && size==0 ){\n    /* Truncating a journal file. This is the end of a transaction. */\n    jt_file *pMain = locateDatabaseHandle(p->zName, 0);\n    closeTransaction(pMain);\n  }\n  if( p->flags&SQLITE_OPEN_MAIN_DB && p->pWritable ){\n    u32 pgno;\n    u32 locking_page = (u32)(PENDING_BYTE/p->nPagesize+1);\n    for(pgno=(u32)(size/p->nPagesize+1); pgno<=p->nPage; pgno++){\n      assert( pgno==locking_page || sqlite3BitvecTest(p->pWritable, pgno) );\n    }\n  }\n  return sqlite3OsTruncate(p->pReal, size);\n}\n\n/*\n** Sync an jt-file.\n*/\nstatic int jtSync(sqlite3_file *pFile, int flags){\n  jt_file *p = (jt_file *)pFile;\n\n  if( p->flags&SQLITE_OPEN_MAIN_JOURNAL ){\n    int rc;\n    jt_file *pMain;                   /* The associated database file */\n\n    /* The journal file is being synced. At this point, we inspect the \n    ** contents of the file up to this point and set each bit in the \n    ** jt_file.pWritable bitvec of the main database file associated with\n    ** this journal file.\n    */\n    pMain = locateDatabaseHandle(p->zName, 0);\n\n    /* Set the bitvec values */\n    if( pMain && pMain->pWritable ){\n      pMain->nSync++;\n      rc = readJournalFile(p, pMain);\n      if( rc!=SQLITE_OK ){\n        return rc;\n      }\n    }\n  }\n\n  return sqlite3OsSync(p->pReal, flags);\n}\n\n/*\n** Return the current file-size of an jt-file.\n*/\nstatic int jtFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  jt_file *p = (jt_file *)pFile;\n  return sqlite3OsFileSize(p->pReal, pSize);\n}\n\n/*\n** Lock an jt-file.\n*/\nstatic int jtLock(sqlite3_file *pFile, int eLock){\n  int rc;\n  jt_file *p = (jt_file *)pFile;\n  rc = sqlite3OsLock(p->pReal, eLock);\n  if( rc==SQLITE_OK && eLock>p->eLock ){\n    p->eLock = eLock;\n  }\n  return rc;\n}\n\n/*\n** Unlock an jt-file.\n*/\nstatic int jtUnlock(sqlite3_file *pFile, int eLock){\n  int rc;\n  jt_file *p = (jt_file *)pFile;\n  rc = sqlite3OsUnlock(p->pReal, eLock);\n  if( rc==SQLITE_OK && eLock<p->eLock ){\n    p->eLock = eLock;\n  }\n  return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an jt-file.\n*/\nstatic int jtCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  jt_file *p = (jt_file *)pFile;\n  return sqlite3OsCheckReservedLock(p->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an jt-file.\n*/\nstatic int jtFileControl(sqlite3_file *pFile, int op, void *pArg){\n  jt_file *p = (jt_file *)pFile;\n  return p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n}\n\n/*\n** Return the sector-size in bytes for an jt-file.\n*/\nstatic int jtSectorSize(sqlite3_file *pFile){\n  jt_file *p = (jt_file *)pFile;\n  return sqlite3OsSectorSize(p->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an jt-file.\n*/\nstatic int jtDeviceCharacteristics(sqlite3_file *pFile){\n  jt_file *p = (jt_file *)pFile;\n  return sqlite3OsDeviceCharacteristics(p->pReal);\n}\n\n/*\n** Open an jt file handle.\n*/\nstatic int jtOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  jt_file *p = (jt_file *)pFile;\n  pFile->pMethods = 0;\n  p->pReal = (sqlite3_file *)&p[1];\n  p->pReal->pMethods = 0;\n  rc = sqlite3OsOpen(g.pVfs, zName, p->pReal, flags, pOutFlags);\n  assert( rc==SQLITE_OK || p->pReal->pMethods==0 );\n  if( rc==SQLITE_OK ){\n    pFile->pMethods = &jt_io_methods;\n    p->eLock = 0;\n    p->zName = zName;\n    p->flags = flags;\n    p->pNext = 0;\n    p->pWritable = 0;\n    p->aCksum = 0;\n    enterJtMutex();\n    if( zName ){\n      p->pNext = g.pList;\n      g.pList = p;\n    }\n    leaveJtMutex();\n  }\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int jtDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int nPath = (int)strlen(zPath);\n  if( nPath>8 && 0==strcmp(\"-journal\", &zPath[nPath-8]) ){\n    /* Deleting a journal file. The end of a transaction. */\n    jt_file *pMain = locateDatabaseHandle(zPath, 0);\n    if( pMain ){\n      closeTransaction(pMain);\n    }\n  }\n\n  return sqlite3OsDelete(g.pVfs, zPath, dirSync);\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int jtAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  return sqlite3OsAccess(g.pVfs, zPath, flags, pResOut);\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (JT_MAX_PATHNAME+1) bytes.\n*/\nstatic int jtFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  return sqlite3OsFullPathname(g.pVfs, zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *jtDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return g.pVfs->xDlOpen(g.pVfs, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void jtDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  g.pVfs->xDlError(g.pVfs, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*jtDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return g.pVfs->xDlSym(g.pVfs, p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void jtDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  g.pVfs->xDlClose(g.pVfs, pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int jtRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return sqlite3OsRandomness(g.pVfs, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int jtSleep(sqlite3_vfs *pVfs, int nMicro){\n  return sqlite3OsSleep(g.pVfs, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int jtCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return g.pVfs->xCurrentTime(g.pVfs, pTimeOut);\n}\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int jtCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  return g.pVfs->xCurrentTimeInt64(g.pVfs, pTimeOut);\n}\n\nstatic int jtGetLastError(sqlite3_vfs *pVfs, int n, char *z){\n  return g.pVfs->xGetLastError(g.pVfs, n, z);\n}\n\n/**************************************************************************\n** Start of public API.\n*/\n\n/*\n** Configure the jt VFS as a wrapper around the VFS named by parameter \n** zWrap. If the isDefault parameter is true, then the jt VFS is installed\n** as the new default VFS for SQLite connections. If isDefault is not\n** true, then the jt VFS is installed as non-default. In this case it\n** is available via its name, \"jt\".\n*/\nint jt_register(char *zWrap, int isDefault){\n  g.pVfs = sqlite3_vfs_find(zWrap);\n  if( g.pVfs==0 ){\n    return SQLITE_ERROR;\n  }\n  jt_vfs.szOsFile = sizeof(jt_file) + g.pVfs->szOsFile;\n  if( g.pVfs->iVersion==1 ){\n    jt_vfs.iVersion = 1;\n  }else if( g.pVfs->xCurrentTimeInt64==0 ){\n    jt_vfs.xCurrentTimeInt64 = 0;\n  }\n  sqlite3_vfs_register(&jt_vfs, isDefault);\n  return SQLITE_OK;\n}\n\n/*\n** Uninstall the jt VFS, if it is installed.\n*/\nvoid jt_unregister(void){\n  sqlite3_vfs_unregister(&jt_vfs);\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_loadext.c",
    "content": "/*\n** 2006 June 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Test extension for testing the sqlite3_load_extension() function.\n*/\n#include <string.h>\n#include \"sqlite3ext.h\"\nSQLITE_EXTENSION_INIT1\n\n/*\n** The half() SQL function returns half of its input value.\n*/\nstatic void halfFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_result_double(context, 0.5*sqlite3_value_double(argv[0]));\n}\n\n/*\n** SQL functions to call the sqlite3_status function and return results.\n*/\nstatic void statusFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int op = 0, mx, cur, resetFlag, rc;\n  if( sqlite3_value_type(argv[0])==SQLITE_INTEGER ){\n    op = sqlite3_value_int(argv[0]);\n  }else if( sqlite3_value_type(argv[0])==SQLITE_TEXT ){\n    int i;\n    const char *zName;\n    static const struct {\n      const char *zName;\n      int op;\n    } aOp[] = {\n      { \"MEMORY_USED\",         SQLITE_STATUS_MEMORY_USED         },\n      { \"PAGECACHE_USED\",      SQLITE_STATUS_PAGECACHE_USED      },\n      { \"PAGECACHE_OVERFLOW\",  SQLITE_STATUS_PAGECACHE_OVERFLOW  },\n      { \"SCRATCH_USED\",        SQLITE_STATUS_SCRATCH_USED        },\n      { \"SCRATCH_OVERFLOW\",    SQLITE_STATUS_SCRATCH_OVERFLOW    },\n      { \"MALLOC_SIZE\",         SQLITE_STATUS_MALLOC_SIZE         },\n    };\n    int nOp = sizeof(aOp)/sizeof(aOp[0]);\n    zName = (const char*)sqlite3_value_text(argv[0]);\n    for(i=0; i<nOp; i++){\n      if( strcmp(aOp[i].zName, zName)==0 ){\n        op = aOp[i].op;\n        break;\n      }\n    }\n    if( i>=nOp ){\n      char *zMsg = sqlite3_mprintf(\"unknown status property: %s\", zName);\n      sqlite3_result_error(context, zMsg, -1);\n      sqlite3_free(zMsg);\n      return;\n    }\n  }else{\n    sqlite3_result_error(context, \"unknown status type\", -1);\n    return;\n  }\n  if( argc==2 ){\n    resetFlag = sqlite3_value_int(argv[1]);\n  }else{\n    resetFlag = 0;\n  }\n  rc = sqlite3_status(op, &cur, &mx, resetFlag);\n  if( rc!=SQLITE_OK ){\n    char *zMsg = sqlite3_mprintf(\"sqlite3_status(%d,...) returns %d\", op, rc);\n    sqlite3_result_error(context, zMsg, -1);\n    sqlite3_free(zMsg);\n    return;\n  } \n  if( argc==2 ){\n    sqlite3_result_int(context, mx);\n  }else{\n    sqlite3_result_int(context, cur);\n  }\n}\n\n/*\n** Extension load function.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint testloadext_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int nErr = 0;\n  SQLITE_EXTENSION_INIT2(pApi);\n  nErr |= sqlite3_create_function(db, \"half\", 1, SQLITE_ANY, 0, halfFunc, 0, 0);\n  nErr |= sqlite3_create_function(db, \"sqlite3_status\", 1, SQLITE_ANY, 0,\n                          statusFunc, 0, 0);\n  nErr |= sqlite3_create_function(db, \"sqlite3_status\", 2, SQLITE_ANY, 0,\n                          statusFunc, 0, 0);\n  return nErr ? SQLITE_ERROR : SQLITE_OK;\n}\n\n/*\n** Another extension entry point. This one always fails.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint testbrokenext_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  char *zErr;\n  SQLITE_EXTENSION_INIT2(pApi);\n  zErr = sqlite3_mprintf(\"broken!\");\n  *pzErrMsg = zErr;\n  return 1;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_malloc.c",
    "content": "/*\n** 2007 August 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement test interfaces to the\n** memory allocation subsystem.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\n/*\n** This structure is used to encapsulate the global state variables used \n** by malloc() fault simulation.\n*/\nstatic struct MemFault {\n  int iCountdown;         /* Number of pending successes before a failure */\n  int nRepeat;            /* Number of times to repeat the failure */\n  int nBenign;            /* Number of benign failures seen since last config */\n  int nFail;              /* Number of failures seen since last config */\n  u8 enable;              /* True if enabled */\n  int isInstalled;        /* True if the fault simulation layer is installed */\n  int isBenignMode;       /* True if malloc failures are considered benign */\n  sqlite3_mem_methods m;  /* 'Real' malloc implementation */\n} memfault;\n\n/*\n** This routine exists as a place to set a breakpoint that will\n** fire on any simulated malloc() failure.\n*/\nstatic void sqlite3Fault(void){\n  static int cnt = 0;\n  cnt++;\n}\n\n/*\n** Check to see if a fault should be simulated.  Return true to simulate\n** the fault.  Return false if the fault should not be simulated.\n*/\nstatic int faultsimStep(void){\n  if( likely(!memfault.enable) ){\n    return 0;\n  }\n  if( memfault.iCountdown>0 ){\n    memfault.iCountdown--;\n    return 0;\n  }\n  sqlite3Fault();\n  memfault.nFail++;\n  if( memfault.isBenignMode>0 ){\n    memfault.nBenign++;\n  }\n  memfault.nRepeat--;\n  if( memfault.nRepeat<=0 ){\n    memfault.enable = 0;\n  }\n  return 1;  \n}\n\n/*\n** A version of sqlite3_mem_methods.xMalloc() that includes fault simulation\n** logic.\n*/\nstatic void *faultsimMalloc(int n){\n  void *p = 0;\n  if( !faultsimStep() ){\n    p = memfault.m.xMalloc(n);\n  }\n  return p;\n}\n\n\n/*\n** A version of sqlite3_mem_methods.xRealloc() that includes fault simulation\n** logic.\n*/\nstatic void *faultsimRealloc(void *pOld, int n){\n  void *p = 0;\n  if( !faultsimStep() ){\n    p = memfault.m.xRealloc(pOld, n);\n  }\n  return p;\n}\n\n/* \n** The following method calls are passed directly through to the underlying\n** malloc system:\n**\n**     xFree\n**     xSize\n**     xRoundup\n**     xInit\n**     xShutdown\n*/\nstatic void faultsimFree(void *p){\n  memfault.m.xFree(p);\n}\nstatic int faultsimSize(void *p){\n  return memfault.m.xSize(p);\n}\nstatic int faultsimRoundup(int n){\n  return memfault.m.xRoundup(n);\n}\nstatic int faultsimInit(void *p){\n  return memfault.m.xInit(memfault.m.pAppData);\n}\nstatic void faultsimShutdown(void *p){\n  memfault.m.xShutdown(memfault.m.pAppData);\n}\n\n/*\n** This routine configures the malloc failure simulation.  After\n** calling this routine, the next nDelay mallocs will succeed, followed\n** by a block of nRepeat failures, after which malloc() calls will begin\n** to succeed again.\n*/\nstatic void faultsimConfig(int nDelay, int nRepeat){\n  memfault.iCountdown = nDelay;\n  memfault.nRepeat = nRepeat;\n  memfault.nBenign = 0;\n  memfault.nFail = 0;\n  memfault.enable = nDelay>=0;\n\n  /* Sometimes, when running multi-threaded tests, the isBenignMode \n  ** variable is not properly incremented/decremented so that it is\n  ** 0 when not inside a benign malloc block. This doesn't affect\n  ** the multi-threaded tests, as they do not use this system. But\n  ** it does affect OOM tests run later in the same process. So\n  ** zero the variable here, just to be sure.\n  */\n  memfault.isBenignMode = 0;\n}\n\n/*\n** Return the number of faults (both hard and benign faults) that have\n** occurred since the injector was last configured.\n*/\nstatic int faultsimFailures(void){\n  return memfault.nFail;\n}\n\n/*\n** Return the number of benign faults that have occurred since the\n** injector was last configured.\n*/\nstatic int faultsimBenignFailures(void){\n  return memfault.nBenign;\n}\n\n/*\n** Return the number of successes that will occur before the next failure.\n** If no failures are scheduled, return -1.\n*/\nstatic int faultsimPending(void){\n  if( memfault.enable ){\n    return memfault.iCountdown;\n  }else{\n    return -1;\n  }\n}\n\n\nstatic void faultsimBeginBenign(void){\n  memfault.isBenignMode++;\n}\nstatic void faultsimEndBenign(void){\n  memfault.isBenignMode--;\n}\n\n/*\n** Add or remove the fault-simulation layer using sqlite3_config(). If\n** the argument is non-zero, the \n*/\nstatic int faultsimInstall(int install){\n  static struct sqlite3_mem_methods m = {\n    faultsimMalloc,                   /* xMalloc */\n    faultsimFree,                     /* xFree */\n    faultsimRealloc,                  /* xRealloc */\n    faultsimSize,                     /* xSize */\n    faultsimRoundup,                  /* xRoundup */\n    faultsimInit,                     /* xInit */\n    faultsimShutdown,                 /* xShutdown */\n    0                                 /* pAppData */\n  };\n  int rc;\n\n  install = (install ? 1 : 0);\n  assert(memfault.isInstalled==1 || memfault.isInstalled==0);\n\n  if( install==memfault.isInstalled ){\n    return SQLITE_ERROR;\n  }\n\n  if( install ){\n    rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memfault.m);\n    assert(memfault.m.xMalloc);\n    if( rc==SQLITE_OK ){\n      rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &m);\n    }\n    sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, \n        faultsimBeginBenign, faultsimEndBenign\n    );\n  }else{\n    sqlite3_mem_methods m2;\n    assert(memfault.m.xMalloc);\n\n    /* One should be able to reset the default memory allocator by storing\n    ** a zeroed allocator then calling GETMALLOC. */\n    memset(&m2, 0, sizeof(m2));\n    sqlite3_config(SQLITE_CONFIG_MALLOC, &m2);\n    sqlite3_config(SQLITE_CONFIG_GETMALLOC, &m2);\n    assert( memcmp(&m2, &memfault.m, sizeof(m2))==0 );\n\n    rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memfault.m);\n    sqlite3_test_control(SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,\n        (void*)0, (void*)0);\n  }\n\n  if( rc==SQLITE_OK ){\n    memfault.isInstalled = 1;\n  }\n  return rc;\n}\n\n#ifdef SQLITE_TEST\n\n/*\n** This function is implemented in main.c. Returns a pointer to a static\n** buffer containing the symbolic SQLite error code that corresponds to\n** the least-significant 8-bits of the integer passed as an argument.\n** For example:\n**\n**   sqlite3ErrName(1) -> \"SQLITE_ERROR\"\n*/\nextern const char *sqlite3ErrName(int);\n\n/*\n** Transform pointers to text and back again\n*/\nstatic void pointerToText(void *p, char *z){\n  static const char zHex[] = \"0123456789abcdef\";\n  int i, k;\n  unsigned int u;\n  sqlite3_uint64 n;\n  if( p==0 ){\n    strcpy(z, \"0\");\n    return;\n  }\n  if( sizeof(n)==sizeof(p) ){\n    memcpy(&n, &p, sizeof(p));\n  }else if( sizeof(u)==sizeof(p) ){\n    memcpy(&u, &p, sizeof(u));\n    n = u;\n  }else{\n    assert( 0 );\n  }\n  for(i=0, k=sizeof(p)*2-1; i<sizeof(p)*2; i++, k--){\n    z[k] = zHex[n&0xf];\n    n >>= 4;\n  }\n  z[sizeof(p)*2] = 0;\n}\nstatic int hexToInt(int h){\n  if( h>='0' && h<='9' ){\n    return h - '0';\n  }else if( h>='a' && h<='f' ){\n    return h - 'a' + 10;\n  }else{\n    return -1;\n  }\n}\nstatic int textToPointer(const char *z, void **pp){\n  sqlite3_uint64 n = 0;\n  int i;\n  unsigned int u;\n  for(i=0; i<sizeof(void*)*2 && z[0]; i++){\n    int v;\n    v = hexToInt(*z++);\n    if( v<0 ) return TCL_ERROR;\n    n = n*16 + v;\n  }\n  if( *z!=0 ) return TCL_ERROR;\n  if( sizeof(n)==sizeof(*pp) ){\n    memcpy(pp, &n, sizeof(n));\n  }else if( sizeof(u)==sizeof(*pp) ){\n    u = (unsigned int)n;\n    memcpy(pp, &u, sizeof(u));\n  }else{\n    assert( 0 );\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_malloc  NBYTES\n**\n** Raw test interface for sqlite3_malloc().\n*/\nstatic int SQLITE_TCLAPI test_malloc(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nByte;\n  void *p;\n  char zOut[100];\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NBYTES\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &nByte) ) return TCL_ERROR;\n  p = sqlite3_malloc((unsigned)nByte);\n  pointerToText(p, zOut);\n  Tcl_AppendResult(interp, zOut, NULL);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_realloc  PRIOR  NBYTES\n**\n** Raw test interface for sqlite3_realloc().\n*/\nstatic int SQLITE_TCLAPI test_realloc(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nByte;\n  void *pPrior, *p;\n  char zOut[100];\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PRIOR NBYTES\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &nByte) ) return TCL_ERROR;\n  if( textToPointer(Tcl_GetString(objv[1]), &pPrior) ){\n    Tcl_AppendResult(interp, \"bad pointer: \", Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  p = sqlite3_realloc(pPrior, (unsigned)nByte);\n  pointerToText(p, zOut);\n  Tcl_AppendResult(interp, zOut, NULL);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_free  PRIOR\n**\n** Raw test interface for sqlite3_free().\n*/\nstatic int SQLITE_TCLAPI test_free(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void *pPrior;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PRIOR\");\n    return TCL_ERROR;\n  }\n  if( textToPointer(Tcl_GetString(objv[1]), &pPrior) ){\n    Tcl_AppendResult(interp, \"bad pointer: \", Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  sqlite3_free(pPrior);\n  return TCL_OK;\n}\n\n/*\n** These routines are in test_hexio.c\n*/\nint sqlite3TestHexToBin(const char *, int, char *);\nint sqlite3TestBinToHex(char*,int);\n\n/*\n** Usage:    memset  ADDRESS  SIZE  HEX\n**\n** Set a chunk of memory (obtained from malloc, probably) to a\n** specified hex pattern.\n*/\nstatic int SQLITE_TCLAPI test_memset(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void *p;\n  int size, n, i;\n  char *zHex;\n  char *zOut;\n  char zBin[100];\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"ADDRESS SIZE HEX\");\n    return TCL_ERROR;\n  }\n  if( textToPointer(Tcl_GetString(objv[1]), &p) ){\n    Tcl_AppendResult(interp, \"bad pointer: \", Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &size) ){\n    return TCL_ERROR;\n  }\n  if( size<=0 ){\n    Tcl_AppendResult(interp, \"size must be positive\", (char*)0);\n    return TCL_ERROR;\n  }\n  zHex = Tcl_GetStringFromObj(objv[3], &n);\n  if( n>sizeof(zBin)*2 ) n = sizeof(zBin)*2;\n  n = sqlite3TestHexToBin(zHex, n, zBin);\n  if( n==0 ){\n    Tcl_AppendResult(interp, \"no data\", (char*)0);\n    return TCL_ERROR;\n  }\n  zOut = p;\n  for(i=0; i<size; i++){\n    zOut[i] = zBin[i%n];\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    memget  ADDRESS  SIZE\n**\n** Return memory as hexadecimal text.\n*/\nstatic int SQLITE_TCLAPI test_memget(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void *p;\n  int size, n;\n  char *zBin;\n  char zHex[100];\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"ADDRESS SIZE\");\n    return TCL_ERROR;\n  }\n  if( textToPointer(Tcl_GetString(objv[1]), &p) ){\n    Tcl_AppendResult(interp, \"bad pointer: \", Tcl_GetString(objv[1]), (char*)0);\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &size) ){\n    return TCL_ERROR;\n  }\n  if( size<=0 ){\n    Tcl_AppendResult(interp, \"size must be positive\", (char*)0);\n    return TCL_ERROR;\n  }\n  zBin = p;\n  while( size>0 ){\n    if( size>(sizeof(zHex)-1)/2 ){\n      n = (sizeof(zHex)-1)/2;\n    }else{\n      n = size;\n    }\n    memcpy(zHex, zBin, n);\n    zBin += n;\n    size -= n;\n    sqlite3TestBinToHex(zHex, n);\n    Tcl_AppendResult(interp, zHex, (char*)0);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memory_used\n**\n** Raw test interface for sqlite3_memory_used().\n*/\nstatic int SQLITE_TCLAPI test_memory_used(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(sqlite3_memory_used()));\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memory_highwater ?RESETFLAG?\n**\n** Raw test interface for sqlite3_memory_highwater().\n*/\nstatic int SQLITE_TCLAPI test_memory_highwater(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int resetFlag = 0;\n  if( objc!=1 && objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?RESET?\");\n    return TCL_ERROR;\n  }\n  if( objc==2 ){\n    if( Tcl_GetBooleanFromObj(interp, objv[1], &resetFlag) ) return TCL_ERROR;\n  } \n  Tcl_SetObjResult(interp, \n     Tcl_NewWideIntObj(sqlite3_memory_highwater(resetFlag)));\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memdebug_backtrace DEPTH\n**\n** Set the depth of backtracing.  If SQLITE_MEMDEBUG is not defined\n** then this routine is a no-op.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_backtrace(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int depth;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DEPT\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &depth) ) return TCL_ERROR;\n#ifdef SQLITE_MEMDEBUG\n  {\n    extern void sqlite3MemdebugBacktrace(int);\n    sqlite3MemdebugBacktrace(depth);\n  }\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memdebug_dump  FILENAME\n**\n** Write a summary of unfreed memory to FILENAME.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_dump(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME\");\n    return TCL_ERROR;\n  }\n#if defined(SQLITE_MEMDEBUG) || defined(SQLITE_MEMORY_SIZE) \\\n     || defined(SQLITE_POW2_MEMORY_SIZE)\n  {\n    extern void sqlite3MemdebugDump(const char*);\n    sqlite3MemdebugDump(Tcl_GetString(objv[1]));\n  }\n#endif\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memdebug_malloc_count\n**\n** Return the total number of times malloc() has been called.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_malloc_count(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nMalloc = -1;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n#if defined(SQLITE_MEMDEBUG)\n  {\n    extern int sqlite3MemdebugMallocCount();\n    nMalloc = sqlite3MemdebugMallocCount();\n  }\n#endif\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(nMalloc));\n  return TCL_OK;\n}\n\n\n/*\n** Usage:    sqlite3_memdebug_fail  COUNTER  ?OPTIONS?\n**\n** where options are:\n**\n**     -repeat    <count>\n**     -benigncnt <varname>\n**\n** Arrange for a simulated malloc() failure after COUNTER successes.\n** If a repeat count is specified, the fault is repeated that many\n** times.\n**\n** Each call to this routine overrides the prior counter value.\n** This routine returns the number of simulated failures that have\n** happened since the previous call to this routine.\n**\n** To disable simulated failures, use a COUNTER of -1.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_fail(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int ii;\n  int iFail;\n  int nRepeat = 1;\n  Tcl_Obj *pBenignCnt = 0;\n  int nBenign;\n  int nFail = 0;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"COUNTER ?OPTIONS?\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &iFail) ) return TCL_ERROR;\n\n  for(ii=2; ii<objc; ii+=2){\n    int nOption;\n    char *zOption = Tcl_GetStringFromObj(objv[ii], &nOption);\n    char *zErr = 0;\n\n    if( nOption>1 && strncmp(zOption, \"-repeat\", nOption)==0 ){\n      if( ii==(objc-1) ){\n        zErr = \"option requires an argument: \";\n      }else{\n        if( Tcl_GetIntFromObj(interp, objv[ii+1], &nRepeat) ){\n          return TCL_ERROR;\n        }\n      }\n    }else if( nOption>1 && strncmp(zOption, \"-benigncnt\", nOption)==0 ){\n      if( ii==(objc-1) ){\n        zErr = \"option requires an argument: \";\n      }else{\n        pBenignCnt = objv[ii+1];\n      }\n    }else{\n      zErr = \"unknown option: \";\n    }\n\n    if( zErr ){\n      Tcl_AppendResult(interp, zErr, zOption, 0);\n      return TCL_ERROR;\n    }\n  }\n  \n  nBenign = faultsimBenignFailures();\n  nFail = faultsimFailures();\n  faultsimConfig(iFail, nRepeat);\n\n  if( pBenignCnt ){\n    Tcl_ObjSetVar2(interp, pBenignCnt, 0, Tcl_NewIntObj(nBenign), 0);\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(nFail));\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_memdebug_pending\n**\n** Return the number of malloc() calls that will succeed before a \n** simulated failure occurs. A negative return value indicates that\n** no malloc() failure is scheduled.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_pending(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nPending;\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  nPending = faultsimPending();\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(nPending));\n  return TCL_OK;\n}\n\n/*\n** The following global variable keeps track of the number of tests\n** that have run.  This variable is only useful when running in the\n** debugger.\n*/\nstatic int sqlite3_memdebug_title_count = 0;\n\n/*\n** Usage:    sqlite3_memdebug_settitle TITLE\n**\n** Set a title string stored with each allocation.  The TITLE is\n** typically the name of the test that was running when the\n** allocation occurred.  The TITLE is stored with the allocation\n** and can be used to figure out which tests are leaking memory.\n**\n** Each title overwrite the previous.\n*/\nstatic int SQLITE_TCLAPI test_memdebug_settitle(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_memdebug_title_count++;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"TITLE\");\n    return TCL_ERROR;\n  }\n#ifdef SQLITE_MEMDEBUG\n  {\n    const char *zTitle;\n    extern int sqlite3MemdebugSettitle(const char*);\n    zTitle = Tcl_GetString(objv[1]);\n    sqlite3MemdebugSettitle(zTitle);\n  }\n#endif\n  return TCL_OK;\n}\n\n#define MALLOC_LOG_FRAMES  10 \n#define MALLOC_LOG_KEYINTS (                                              \\\n    10 * ((sizeof(int)>=sizeof(void*)) ? 1 : sizeof(void*)/sizeof(int))   \\\n)\nstatic Tcl_HashTable aMallocLog;\nstatic int mallocLogEnabled = 0;\n\ntypedef struct MallocLog MallocLog;\nstruct MallocLog {\n  int nCall;\n  int nByte;\n};\n\n#ifdef SQLITE_MEMDEBUG\nstatic void test_memdebug_callback(int nByte, int nFrame, void **aFrame){\n  if( mallocLogEnabled ){\n    MallocLog *pLog;\n    Tcl_HashEntry *pEntry;\n    int isNew;\n\n    int aKey[MALLOC_LOG_KEYINTS];\n    unsigned int nKey = sizeof(int)*MALLOC_LOG_KEYINTS;\n\n    memset(aKey, 0, nKey);\n    if( (sizeof(void*)*nFrame)<nKey ){\n      nKey = nFrame*sizeof(void*);\n    }\n    memcpy(aKey, aFrame, nKey);\n\n    pEntry = Tcl_CreateHashEntry(&aMallocLog, (const char *)aKey, &isNew);\n    if( isNew ){\n      pLog = (MallocLog *)Tcl_Alloc(sizeof(MallocLog));\n      memset(pLog, 0, sizeof(MallocLog));\n      Tcl_SetHashValue(pEntry, (ClientData)pLog);\n    }else{\n      pLog = (MallocLog *)Tcl_GetHashValue(pEntry);\n    }\n\n    pLog->nCall++;\n    pLog->nByte += nByte;\n  }\n}\n#endif /* SQLITE_MEMDEBUG */\n\nstatic void test_memdebug_log_clear(void){\n  Tcl_HashSearch search;\n  Tcl_HashEntry *pEntry;\n  for(\n    pEntry=Tcl_FirstHashEntry(&aMallocLog, &search);\n    pEntry;\n    pEntry=Tcl_NextHashEntry(&search)\n  ){\n    MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry);\n    Tcl_Free((char *)pLog);\n  }\n  Tcl_DeleteHashTable(&aMallocLog);\n  Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);\n}\n\nstatic int SQLITE_TCLAPI test_memdebug_log(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  static int isInit = 0;\n  int iSub;\n\n  static const char *MB_strs[] = { \"start\", \"stop\", \"dump\", \"clear\", \"sync\" };\n  enum MB_enum { \n      MB_LOG_START, MB_LOG_STOP, MB_LOG_DUMP, MB_LOG_CLEAR, MB_LOG_SYNC \n  };\n\n  if( !isInit ){\n#ifdef SQLITE_MEMDEBUG\n    extern void sqlite3MemdebugBacktraceCallback(\n        void (*xBacktrace)(int, int, void **));\n    sqlite3MemdebugBacktraceCallback(test_memdebug_callback);\n#endif\n    Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);\n    isInit = 1;\n  }\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUB-COMMAND ...\");\n  }\n  if( Tcl_GetIndexFromObj(interp, objv[1], MB_strs, \"sub-command\", 0, &iSub) ){\n    return TCL_ERROR;\n  }\n\n  switch( (enum MB_enum)iSub ){\n    case MB_LOG_START:\n      mallocLogEnabled = 1;\n      break;\n    case MB_LOG_STOP:\n      mallocLogEnabled = 0;\n      break;\n    case MB_LOG_DUMP: {\n      Tcl_HashSearch search;\n      Tcl_HashEntry *pEntry;\n      Tcl_Obj *pRet = Tcl_NewObj();\n\n      assert(sizeof(Tcl_WideInt)>=sizeof(void*));\n\n      for(\n        pEntry=Tcl_FirstHashEntry(&aMallocLog, &search);\n        pEntry;\n        pEntry=Tcl_NextHashEntry(&search)\n      ){\n        Tcl_Obj *apElem[MALLOC_LOG_FRAMES+2];\n        MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry);\n        Tcl_WideInt *aKey = (Tcl_WideInt *)Tcl_GetHashKey(&aMallocLog, pEntry);\n        int ii;\n  \n        apElem[0] = Tcl_NewIntObj(pLog->nCall);\n        apElem[1] = Tcl_NewIntObj(pLog->nByte);\n        for(ii=0; ii<MALLOC_LOG_FRAMES; ii++){\n          apElem[ii+2] = Tcl_NewWideIntObj(aKey[ii]);\n        }\n\n        Tcl_ListObjAppendElement(interp, pRet,\n            Tcl_NewListObj(MALLOC_LOG_FRAMES+2, apElem)\n        );\n      }\n\n      Tcl_SetObjResult(interp, pRet);\n      break;\n    }\n    case MB_LOG_CLEAR: {\n      test_memdebug_log_clear();\n      break;\n    }\n\n    case MB_LOG_SYNC: {\n#ifdef SQLITE_MEMDEBUG\n      extern void sqlite3MemdebugSync();\n      test_memdebug_log_clear();\n      mallocLogEnabled = 1;\n      sqlite3MemdebugSync();\n#endif\n      break;\n    }\n  }\n\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_pagecache SIZE N\n**\n** Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE.\n** The buffer is static and is of limited size.  N might be\n** adjusted downward as needed to accommodate the requested size.\n** The revised value of N is returned.\n**\n** A negative SIZE causes the buffer pointer to be NULL.\n*/\nstatic int SQLITE_TCLAPI test_config_pagecache(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int sz, N;\n  Tcl_Obj *pRes;\n  static char *buf = 0;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SIZE N\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &sz) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &N) ) return TCL_ERROR;\n  free(buf);\n  buf = 0;\n\n  /* Set the return value */\n  pRes = Tcl_NewObj();\n  Tcl_ListObjAppendElement(0, pRes, Tcl_NewIntObj(sqlite3GlobalConfig.szPage));\n  Tcl_ListObjAppendElement(0, pRes, Tcl_NewIntObj(sqlite3GlobalConfig.nPage));\n  Tcl_SetObjResult(interp, pRes);\n\n  if( sz<0 ){\n    sqlite3_config(SQLITE_CONFIG_PAGECACHE, (void*)0, 0, 0);\n  }else{\n    buf = malloc( sz*N );\n    sqlite3_config(SQLITE_CONFIG_PAGECACHE, buf, sz, N);\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_alt_pcache INSTALL_FLAG DISCARD_CHANCE PRNG_SEED\n**\n** Set up the alternative test page cache.  Install if INSTALL_FLAG is\n** true and uninstall (reverting to the default page cache) if INSTALL_FLAG\n** is false.  DISCARD_CHANGE is an integer between 0 and 100 inclusive\n** which determines the chance of discarding a page when unpinned.  100\n** is certainty.  0 is never.  PRNG_SEED is the pseudo-random number generator\n** seed.\n*/\nstatic int SQLITE_TCLAPI test_alt_pcache(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int installFlag;\n  int discardChance = 0;\n  int prngSeed = 0;\n  int highStress = 0;\n  extern void installTestPCache(int,unsigned,unsigned,unsigned);\n  if( objc<2 || objc>5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \n        \"INSTALLFLAG DISCARDCHANCE PRNGSEEED HIGHSTRESS\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &installFlag) ) return TCL_ERROR;\n  if( objc>=3 && Tcl_GetIntFromObj(interp, objv[2], &discardChance) ){\n     return TCL_ERROR;\n  }\n  if( objc>=4 && Tcl_GetIntFromObj(interp, objv[3], &prngSeed) ){\n     return TCL_ERROR;\n  }\n  if( objc>=5 && Tcl_GetIntFromObj(interp, objv[4], &highStress) ){\n    return TCL_ERROR;\n  }\n  if( discardChance<0 || discardChance>100 ){\n    Tcl_AppendResult(interp, \"discard-chance should be between 0 and 100\",\n                     (char*)0);\n    return TCL_ERROR;\n  }\n  installTestPCache(installFlag, (unsigned)discardChance, (unsigned)prngSeed,\n                    (unsigned)highStress);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_memstatus BOOLEAN\n**\n** Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS.\n*/\nstatic int SQLITE_TCLAPI test_config_memstatus(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int enable, rc;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOLEAN\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[1], &enable) ) return TCL_ERROR;\n  rc = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, enable);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_lookaside  SIZE  COUNT\n**\n*/\nstatic int SQLITE_TCLAPI test_config_lookaside(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int sz, cnt;\n  Tcl_Obj *pRet;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SIZE COUNT\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &sz) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &cnt) ) return TCL_ERROR;\n  pRet = Tcl_NewObj();\n  Tcl_ListObjAppendElement(\n      interp, pRet, Tcl_NewIntObj(sqlite3GlobalConfig.szLookaside)\n  );\n  Tcl_ListObjAppendElement(\n      interp, pRet, Tcl_NewIntObj(sqlite3GlobalConfig.nLookaside)\n  );\n  sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, cnt);\n  Tcl_SetObjResult(interp, pRet);\n  return TCL_OK;\n}\n\n\n/*\n** Usage:    sqlite3_db_config_lookaside  CONNECTION  BUFID  SIZE  COUNT\n**\n** There are two static buffers with BUFID 1 and 2.   Each static buffer\n** is 10KB in size.  A BUFID of 0 indicates that the buffer should be NULL\n** which will cause sqlite3_db_config() to allocate space on its own.\n*/\nstatic int SQLITE_TCLAPI test_db_config_lookaside(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  int sz, cnt;\n  sqlite3 *db;\n  int bufid;\n  static char azBuf[2][10000];\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BUFID SIZE COUNT\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[4], &cnt) ) return TCL_ERROR;\n  if( bufid==0 ){\n    rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, (void*)0, sz, cnt);\n  }else if( bufid>=1 && bufid<=2 && sz*cnt<=sizeof(azBuf[0]) ){\n    rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, azBuf[bufid], sz,cnt);\n  }else{\n    Tcl_AppendResult(interp, \"illegal arguments - see documentation\", (char*)0);\n    return TCL_ERROR;\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_heap NBYTE NMINALLOC\n*/\nstatic int SQLITE_TCLAPI test_config_heap(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  static char *zBuf; /* Use this memory */\n  int nByte;         /* Size of buffer to pass to sqlite3_config() */\n  int nMinAlloc;     /* Size of minimum allocation */\n  int rc;            /* Return code of sqlite3_config() */\n\n  Tcl_Obj * CONST *aArg = &objv[1];\n  int nArg = objc-1;\n\n  if( nArg!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NBYTE NMINALLOC\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, aArg[0], &nByte) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, aArg[1], &nMinAlloc) ) return TCL_ERROR;\n\n  if( nByte==0 ){\n    free( zBuf );\n    zBuf = 0;\n    rc = sqlite3_config(SQLITE_CONFIG_HEAP, (void*)0, 0, 0);\n  }else{\n    zBuf = realloc(zBuf, nByte);\n    rc = sqlite3_config(SQLITE_CONFIG_HEAP, zBuf, nByte, nMinAlloc);\n  }\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_heap_size NBYTE\n*/\nstatic int SQLITE_TCLAPI test_config_heap_size(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nByte;         /* Size to pass to sqlite3_config() */\n  int rc;            /* Return code of sqlite3_config() */\n\n  Tcl_Obj * CONST *aArg = &objv[1];\n  int nArg = objc-1;\n\n  if( nArg!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NBYTE\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, aArg[0], &nByte) ) return TCL_ERROR;\n\n  rc = sqlite3_config(SQLITE_CONFIG_WIN32_HEAPSIZE, nByte);\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_error  [DB]\n**\n** Invoke sqlite3_config() or sqlite3_db_config() with invalid\n** opcodes and verify that they return errors.\n*/\nstatic int SQLITE_TCLAPI test_config_error(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n\n  if( objc!=2 && objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"[DB]\");\n    return TCL_ERROR;\n  }\n  if( objc==2 ){\n    if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n    if( sqlite3_db_config(db, 99999)!=SQLITE_ERROR ){\n      Tcl_AppendResult(interp, \n            \"sqlite3_db_config(db, 99999) does not return SQLITE_ERROR\",\n            (char*)0);\n      return TCL_ERROR;\n    }\n  }else{\n    if( sqlite3_config(99999)!=SQLITE_ERROR ){\n      Tcl_AppendResult(interp, \n          \"sqlite3_config(99999) does not return SQLITE_ERROR\",\n          (char*)0);\n      return TCL_ERROR;\n    }\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_uri  BOOLEAN\n**\n** Enables or disables interpretation of URI parameters by default using\n** SQLITE_CONFIG_URI.\n*/\nstatic int SQLITE_TCLAPI test_config_uri(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  int bOpenUri;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOL\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[1], &bOpenUri) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_config(SQLITE_CONFIG_URI, bOpenUri);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_cis  BOOLEAN\n**\n** Enables or disables the use of the covering-index scan optimization.\n** SQLITE_CONFIG_COVERING_INDEX_SCAN.\n*/\nstatic int SQLITE_TCLAPI test_config_cis(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  int bUseCis;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOL\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[1], &bUseCis) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_config(SQLITE_CONFIG_COVERING_INDEX_SCAN, bUseCis);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_config_pmasz  INTEGER\n**\n** Set the minimum PMA size.\n*/\nstatic int SQLITE_TCLAPI test_config_pmasz(\n  void * clientData, \n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  int iPmaSz;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOL\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[1], &iPmaSz) ){\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_config(SQLITE_CONFIG_PMASZ, iPmaSz);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n\n  return TCL_OK;\n}\n\n\n/*\n** Usage:    sqlite3_dump_memsys3  FILENAME\n**           sqlite3_dump_memsys5  FILENAME\n**\n** Write a summary of unfreed memsys3 allocations to FILENAME.\n*/\nstatic int SQLITE_TCLAPI test_dump_memsys3(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME\");\n    return TCL_ERROR;\n  }\n\n  switch( SQLITE_PTR_TO_INT(clientData) ){\n    case 3: {\n#ifdef SQLITE_ENABLE_MEMSYS3\n      extern void sqlite3Memsys3Dump(const char*);\n      sqlite3Memsys3Dump(Tcl_GetString(objv[1]));\n      break;\n#endif\n    }\n    case 5: {\n#ifdef SQLITE_ENABLE_MEMSYS5\n      extern void sqlite3Memsys5Dump(const char*);\n      sqlite3Memsys5Dump(Tcl_GetString(objv[1]));\n      break;\n#endif\n    }\n  }\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_status  OPCODE  RESETFLAG\n**\n** Return a list of three elements which are the sqlite3_status() return\n** code, the current value, and the high-water mark value.\n*/\nstatic int SQLITE_TCLAPI test_status(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc, iValue, mxValue;\n  int i, op = 0, resetFlag;\n  const char *zOpName;\n  static const struct {\n    const char *zName;\n    int op;\n  } aOp[] = {\n    { \"SQLITE_STATUS_MEMORY_USED\",         SQLITE_STATUS_MEMORY_USED         },\n    { \"SQLITE_STATUS_MALLOC_SIZE\",         SQLITE_STATUS_MALLOC_SIZE         },\n    { \"SQLITE_STATUS_PAGECACHE_USED\",      SQLITE_STATUS_PAGECACHE_USED      },\n    { \"SQLITE_STATUS_PAGECACHE_OVERFLOW\",  SQLITE_STATUS_PAGECACHE_OVERFLOW  },\n    { \"SQLITE_STATUS_PAGECACHE_SIZE\",      SQLITE_STATUS_PAGECACHE_SIZE      },\n    { \"SQLITE_STATUS_SCRATCH_USED\",        SQLITE_STATUS_SCRATCH_USED        },\n    { \"SQLITE_STATUS_SCRATCH_OVERFLOW\",    SQLITE_STATUS_SCRATCH_OVERFLOW    },\n    { \"SQLITE_STATUS_SCRATCH_SIZE\",        SQLITE_STATUS_SCRATCH_SIZE        },\n    { \"SQLITE_STATUS_PARSER_STACK\",        SQLITE_STATUS_PARSER_STACK        },\n    { \"SQLITE_STATUS_MALLOC_COUNT\",        SQLITE_STATUS_MALLOC_COUNT        },\n  };\n  Tcl_Obj *pResult;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PARAMETER RESETFLAG\");\n    return TCL_ERROR;\n  }\n  zOpName = Tcl_GetString(objv[1]);\n  for(i=0; i<ArraySize(aOp); i++){\n    if( strcmp(aOp[i].zName, zOpName)==0 ){\n      op = aOp[i].op;\n      break;\n    }\n  }\n  if( i>=ArraySize(aOp) ){\n    if( Tcl_GetIntFromObj(interp, objv[1], &op) ) return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &resetFlag) ) return TCL_ERROR;\n  iValue = 0;\n  mxValue = 0;\n  rc = sqlite3_status(op, &iValue, &mxValue, resetFlag);\n  pResult = Tcl_NewObj();\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc));\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(iValue));\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(mxValue));\n  Tcl_SetObjResult(interp, pResult);\n  return TCL_OK;\n}\n\n/*\n** Usage:    sqlite3_db_status  DATABASE  OPCODE  RESETFLAG\n**\n** Return a list of three elements which are the sqlite3_db_status() return\n** code, the current value, and the high-water mark value.\n*/\nstatic int SQLITE_TCLAPI test_db_status(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc, iValue, mxValue;\n  int i, op = 0, resetFlag;\n  const char *zOpName;\n  sqlite3 *db;\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  static const struct {\n    const char *zName;\n    int op;\n  } aOp[] = {\n    { \"LOOKASIDE_USED\",      SQLITE_DBSTATUS_LOOKASIDE_USED      },\n    { \"CACHE_USED\",          SQLITE_DBSTATUS_CACHE_USED          },\n    { \"SCHEMA_USED\",         SQLITE_DBSTATUS_SCHEMA_USED         },\n    { \"STMT_USED\",           SQLITE_DBSTATUS_STMT_USED           },\n    { \"LOOKASIDE_HIT\",       SQLITE_DBSTATUS_LOOKASIDE_HIT       },\n    { \"LOOKASIDE_MISS_SIZE\", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE },\n    { \"LOOKASIDE_MISS_FULL\", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL },\n    { \"CACHE_HIT\",           SQLITE_DBSTATUS_CACHE_HIT           },\n    { \"CACHE_MISS\",          SQLITE_DBSTATUS_CACHE_MISS          },\n    { \"CACHE_WRITE\",         SQLITE_DBSTATUS_CACHE_WRITE         },\n    { \"DEFERRED_FKS\",        SQLITE_DBSTATUS_DEFERRED_FKS        },\n    { \"CACHE_USED_SHARED\",   SQLITE_DBSTATUS_CACHE_USED_SHARED   },\n  };\n  Tcl_Obj *pResult;\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB PARAMETER RESETFLAG\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zOpName = Tcl_GetString(objv[2]);\n  if( memcmp(zOpName, \"SQLITE_\", 7)==0 ) zOpName += 7;\n  if( memcmp(zOpName, \"DBSTATUS_\", 9)==0 ) zOpName += 9;\n  for(i=0; i<ArraySize(aOp); i++){\n    if( strcmp(aOp[i].zName, zOpName)==0 ){\n      op = aOp[i].op;\n      break;\n    }\n  }\n  if( i>=ArraySize(aOp) ){\n    if( Tcl_GetIntFromObj(interp, objv[2], &op) ) return TCL_ERROR;\n  }\n  if( Tcl_GetBooleanFromObj(interp, objv[3], &resetFlag) ) return TCL_ERROR;\n  iValue = 0;\n  mxValue = 0;\n  rc = sqlite3_db_status(db, op, &iValue, &mxValue, resetFlag);\n  pResult = Tcl_NewObj();\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc));\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(iValue));\n  Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(mxValue));\n  Tcl_SetObjResult(interp, pResult);\n  return TCL_OK;\n}\n\n/*\n** install_malloc_faultsim BOOLEAN\n*/\nstatic int SQLITE_TCLAPI test_install_malloc_faultsim(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n  int isInstall;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOLEAN\");\n    return TCL_ERROR;\n  }\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){\n    return TCL_ERROR;\n  }\n  rc = faultsimInstall(isInstall);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** sqlite3_install_memsys3\n*/\nstatic int SQLITE_TCLAPI test_install_memsys3(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = SQLITE_MISUSE;\n#ifdef SQLITE_ENABLE_MEMSYS3\n  const sqlite3_mem_methods *sqlite3MemGetMemsys3(void);\n  rc = sqlite3_config(SQLITE_CONFIG_MALLOC, sqlite3MemGetMemsys3());\n#endif\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_vfs_oom_test(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  extern int sqlite3_memdebug_vfs_oom_test;\n  if( objc>2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?INTEGER?\");\n    return TCL_ERROR;\n  }else if( objc==2 ){\n    int iNew;\n    if( Tcl_GetIntFromObj(interp, objv[1], &iNew) ) return TCL_ERROR;\n    sqlite3_memdebug_vfs_oom_test = iNew;\n  }\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_memdebug_vfs_oom_test));\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetest_malloc_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     int clientData;\n  } aObjCmd[] = {\n     { \"sqlite3_malloc\",             test_malloc                   ,0 },\n     { \"sqlite3_realloc\",            test_realloc                  ,0 },\n     { \"sqlite3_free\",               test_free                     ,0 },\n     { \"memset\",                     test_memset                   ,0 },\n     { \"memget\",                     test_memget                   ,0 },\n     { \"sqlite3_memory_used\",        test_memory_used              ,0 },\n     { \"sqlite3_memory_highwater\",   test_memory_highwater         ,0 },\n     { \"sqlite3_memdebug_backtrace\", test_memdebug_backtrace       ,0 },\n     { \"sqlite3_memdebug_dump\",      test_memdebug_dump            ,0 },\n     { \"sqlite3_memdebug_fail\",      test_memdebug_fail            ,0 },\n     { \"sqlite3_memdebug_pending\",   test_memdebug_pending         ,0 },\n     { \"sqlite3_memdebug_settitle\",  test_memdebug_settitle        ,0 },\n     { \"sqlite3_memdebug_malloc_count\", test_memdebug_malloc_count ,0 },\n     { \"sqlite3_memdebug_log\",       test_memdebug_log             ,0 },\n     { \"sqlite3_config_pagecache\",   test_config_pagecache         ,0 },\n     { \"sqlite3_config_alt_pcache\",  test_alt_pcache               ,0 },\n     { \"sqlite3_status\",             test_status                   ,0 },\n     { \"sqlite3_db_status\",          test_db_status                ,0 },\n     { \"install_malloc_faultsim\",    test_install_malloc_faultsim  ,0 },\n     { \"sqlite3_config_heap\",        test_config_heap              ,0 },\n     { \"sqlite3_config_heap_size\",   test_config_heap_size         ,0 },\n     { \"sqlite3_config_memstatus\",   test_config_memstatus         ,0 },\n     { \"sqlite3_config_lookaside\",   test_config_lookaside         ,0 },\n     { \"sqlite3_config_error\",       test_config_error             ,0 },\n     { \"sqlite3_config_uri\",         test_config_uri               ,0 },\n     { \"sqlite3_config_cis\",         test_config_cis               ,0 },\n     { \"sqlite3_config_pmasz\",       test_config_pmasz             ,0 },\n     { \"sqlite3_db_config_lookaside\",test_db_config_lookaside      ,0 },\n     { \"sqlite3_dump_memsys3\",       test_dump_memsys3             ,3 },\n     { \"sqlite3_dump_memsys5\",       test_dump_memsys3             ,5 },\n     { \"sqlite3_install_memsys3\",    test_install_memsys3          ,0 },\n     { \"sqlite3_memdebug_vfs_oom_test\", test_vfs_oom_test          ,0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    ClientData c = (ClientData)SQLITE_INT_TO_PTR(aObjCmd[i].clientData);\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, c, 0);\n  }\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_md5.c",
    "content": "/*\n** 2017-10-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code to implement an MD5 extension to TCL.\n*/\n#include \"sqlite3.h\"\n#include <stdlib.h>\n#include <string.h>\n#include \"sqlite3.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n# include \"sqlite_tcl.h\"\n#else\n# include \"tcl.h\"\n# ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n# endif\n#endif\n\n/*\n * This code implements the MD5 message-digest algorithm.\n * The algorithm is due to Ron Rivest.  This code was\n * written by Colin Plumb in 1993, no copyright is claimed.\n * This code is in the public domain; do with it what you wish.\n *\n * Equivalent code is available from RSA Data Security, Inc.\n * This code has been tested against that, and is equivalent,\n * except that you don't need to include two pages of legalese\n * with every copy.\n *\n * To compute the message digest of a chunk of bytes, declare an\n * MD5Context structure, pass it to MD5Init, call MD5Update as\n * needed on buffers full of bytes, and then call MD5Final, which\n * will fill a supplied 16-byte array with the digest.\n */\n\n/*\n * If compiled on a machine that doesn't have a 32-bit integer,\n * you just set \"uint32\" to the appropriate datatype for an\n * unsigned 32-bit integer.  For example:\n *\n *       cc -Duint32='unsigned long' md5.c\n *\n */\n#ifndef uint32\n#  define uint32 unsigned int\n#endif\n\nstruct MD5Context {\n  int isInit;\n  uint32 buf[4];\n  uint32 bits[2];\n  unsigned char in[64];\n};\ntypedef struct MD5Context MD5Context;\n\n/*\n * Note: this code is harmless on little-endian machines.\n */\nstatic void byteReverse (unsigned char *buf, unsigned longs){\n        uint32 t;\n        do {\n                t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |\n                            ((unsigned)buf[1]<<8 | buf[0]);\n                *(uint32 *)buf = t;\n                buf += 4;\n        } while (--longs);\n}\n/* The four core functions - F1 is optimized somewhat */\n\n/* #define F1(x, y, z) (x & y | ~x & z) */\n#define F1(x, y, z) (z ^ (x & (y ^ z)))\n#define F2(x, y, z) F1(z, x, y)\n#define F3(x, y, z) (x ^ y ^ z)\n#define F4(x, y, z) (y ^ (x | ~z))\n\n/* This is the central step in the MD5 algorithm. */\n#define MD5STEP(f, w, x, y, z, data, s) \\\n        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )\n\n/*\n * The core of the MD5 algorithm, this alters an existing MD5 hash to\n * reflect the addition of 16 longwords of new data.  MD5Update blocks\n * the data and converts bytes into longwords for this routine.\n */\nstatic void MD5Transform(uint32 buf[4], const uint32 in[16]){\n        register uint32 a, b, c, d;\n\n        a = buf[0];\n        b = buf[1];\n        c = buf[2];\n        d = buf[3];\n\n        MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478,  7);\n        MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);\n        MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);\n        MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);\n        MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf,  7);\n        MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);\n        MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);\n        MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);\n        MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8,  7);\n        MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);\n        MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);\n        MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);\n        MD5STEP(F1, a, b, c, d, in[12]+0x6b901122,  7);\n        MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);\n        MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);\n        MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);\n\n        MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562,  5);\n        MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340,  9);\n        MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);\n        MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);\n        MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d,  5);\n        MD5STEP(F2, d, a, b, c, in[10]+0x02441453,  9);\n        MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);\n        MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);\n        MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6,  5);\n        MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6,  9);\n        MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);\n        MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);\n        MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905,  5);\n        MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8,  9);\n        MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);\n        MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);\n\n        MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942,  4);\n        MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);\n        MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);\n        MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);\n        MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44,  4);\n        MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);\n        MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);\n        MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);\n        MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6,  4);\n        MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);\n        MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);\n        MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);\n        MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039,  4);\n        MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);\n        MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);\n        MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);\n\n        MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244,  6);\n        MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);\n        MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);\n        MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);\n        MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3,  6);\n        MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);\n        MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);\n        MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);\n        MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f,  6);\n        MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);\n        MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);\n        MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);\n        MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82,  6);\n        MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);\n        MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);\n        MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);\n\n        buf[0] += a;\n        buf[1] += b;\n        buf[2] += c;\n        buf[3] += d;\n}\n\n/*\n * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious\n * initialization constants.\n */\nstatic void MD5Init(MD5Context *ctx){\n        ctx->isInit = 1;\n        ctx->buf[0] = 0x67452301;\n        ctx->buf[1] = 0xefcdab89;\n        ctx->buf[2] = 0x98badcfe;\n        ctx->buf[3] = 0x10325476;\n        ctx->bits[0] = 0;\n        ctx->bits[1] = 0;\n}\n\n/*\n * Update context to reflect the concatenation of another buffer full\n * of bytes.\n */\nstatic\nvoid MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){\n        uint32 t;\n\n        /* Update bitcount */\n\n        t = ctx->bits[0];\n        if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)\n                ctx->bits[1]++; /* Carry from low to high */\n        ctx->bits[1] += len >> 29;\n\n        t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */\n\n        /* Handle any leading odd-sized chunks */\n\n        if ( t ) {\n                unsigned char *p = (unsigned char *)ctx->in + t;\n\n                t = 64-t;\n                if (len < t) {\n                        memcpy(p, buf, len);\n                        return;\n                }\n                memcpy(p, buf, t);\n                byteReverse(ctx->in, 16);\n                MD5Transform(ctx->buf, (uint32 *)ctx->in);\n                buf += t;\n                len -= t;\n        }\n\n        /* Process data in 64-byte chunks */\n\n        while (len >= 64) {\n                memcpy(ctx->in, buf, 64);\n                byteReverse(ctx->in, 16);\n                MD5Transform(ctx->buf, (uint32 *)ctx->in);\n                buf += 64;\n                len -= 64;\n        }\n\n        /* Handle any remaining bytes of data. */\n\n        memcpy(ctx->in, buf, len);\n}\n\n/*\n * Final wrapup - pad to 64-byte boundary with the bit pattern\n * 1 0* (64-bit count of bits processed, MSB-first)\n */\nstatic void MD5Final(unsigned char digest[16], MD5Context *ctx){\n        unsigned count;\n        unsigned char *p;\n\n        /* Compute number of bytes mod 64 */\n        count = (ctx->bits[0] >> 3) & 0x3F;\n\n        /* Set the first char of padding to 0x80.  This is safe since there is\n           always at least one byte free */\n        p = ctx->in + count;\n        *p++ = 0x80;\n\n        /* Bytes of padding needed to make 64 bytes */\n        count = 64 - 1 - count;\n\n        /* Pad out to 56 mod 64 */\n        if (count < 8) {\n                /* Two lots of padding:  Pad the first block to 64 bytes */\n                memset(p, 0, count);\n                byteReverse(ctx->in, 16);\n                MD5Transform(ctx->buf, (uint32 *)ctx->in);\n\n                /* Now fill the next block with 56 bytes */\n                memset(ctx->in, 0, 56);\n        } else {\n                /* Pad block to 56 bytes */\n                memset(p, 0, count-8);\n        }\n        byteReverse(ctx->in, 14);\n\n        /* Append length in bits and transform */\n        memcpy(ctx->in + 14*4, ctx->bits, 8);\n\n        MD5Transform(ctx->buf, (uint32 *)ctx->in);\n        byteReverse((unsigned char *)ctx->buf, 4);\n        memcpy(digest, ctx->buf, 16);\n}\n\n/*\n** Convert a 128-bit MD5 digest into a 32-digit base-16 number.\n*/\nstatic void MD5DigestToBase16(unsigned char *digest, char *zBuf){\n  static char const zEncode[] = \"0123456789abcdef\";\n  int i, j;\n\n  for(j=i=0; i<16; i++){\n    int a = digest[i];\n    zBuf[j++] = zEncode[(a>>4)&0xf];\n    zBuf[j++] = zEncode[a & 0xf];\n  }\n  zBuf[j] = 0;\n}\n\n\n/*\n** Convert a 128-bit MD5 digest into sequency of eight 5-digit integers\n** each representing 16 bits of the digest and separated from each\n** other by a \"-\" character.\n*/\nstatic void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){\n  int i, j;\n  unsigned int x;\n  for(i=j=0; i<16; i+=2){\n    x = digest[i]*256 + digest[i+1];\n    if( i>0 ) zDigest[j++] = '-';\n    sqlite3_snprintf(50-j, &zDigest[j], \"%05u\", x);\n    j += 5;\n  }\n  zDigest[j] = 0;\n}\n\n/*\n** A TCL command for md5.  The argument is the text to be hashed.  The\n** Result is the hash in base64.\n*/\nstatic int SQLITE_TCLAPI md5_cmd(\n  void*cd,\n  Tcl_Interp *interp,\n  int argc,\n  const char **argv\n){\n  MD5Context ctx;\n  unsigned char digest[16];\n  char zBuf[50];\n  void (*converter)(unsigned char*, char*);\n\n  if( argc!=2 ){\n    Tcl_AppendResult(interp,\"wrong # args: should be \\\"\", argv[0],\n        \" TEXT\\\"\", (char*)0);\n    return TCL_ERROR;\n  }\n  MD5Init(&ctx);\n  MD5Update(&ctx, (unsigned char*)argv[1], (unsigned)strlen(argv[1]));\n  MD5Final(digest, &ctx);\n  converter = (void(*)(unsigned char*,char*))cd;\n  converter(digest, zBuf);\n  Tcl_AppendResult(interp, zBuf, (char*)0);\n  return TCL_OK;\n}\n\n/*\n** A TCL command to take the md5 hash of a file.  The argument is the\n** name of the file.\n*/\nstatic int SQLITE_TCLAPI md5file_cmd(\n  void*cd,\n  Tcl_Interp *interp,\n  int argc,\n  const char **argv\n){\n  FILE *in;\n  int ofst;\n  int amt;\n  MD5Context ctx;\n  void (*converter)(unsigned char*, char*);\n  unsigned char digest[16];\n  char zBuf[10240];\n\n  if( argc!=2 && argc!=4 ){\n    Tcl_AppendResult(interp,\"wrong # args: should be \\\"\", argv[0],\n        \" FILENAME [OFFSET AMT]\\\"\", (char*)0);\n    return TCL_ERROR;\n  }\n  if( argc==4 ){\n    ofst = atoi(argv[2]);\n    amt = atoi(argv[3]);\n  }else{\n    ofst = 0;\n    amt = 2147483647;\n  }\n  in = fopen(argv[1],\"rb\");\n  if( in==0 ){\n    Tcl_AppendResult(interp,\"unable to open file \\\"\", argv[1],\n         \"\\\" for reading\", (char*)0);\n    return TCL_ERROR;\n  }\n  fseek(in, ofst, SEEK_SET);\n  MD5Init(&ctx);\n  while( amt>0 ){\n    int n;\n    n = (int)fread(zBuf, 1, sizeof(zBuf)<=amt ? sizeof(zBuf) : amt, in);\n    if( n<=0 ) break;\n    MD5Update(&ctx, (unsigned char*)zBuf, (unsigned)n);\n    amt -= n;\n  }\n  fclose(in);\n  MD5Final(digest, &ctx);\n  converter = (void(*)(unsigned char*,char*))cd;\n  converter(digest, zBuf);\n  Tcl_AppendResult(interp, zBuf, (char*)0);\n  return TCL_OK;\n}\n\n/*\n** Register the four new TCL commands for generating MD5 checksums\n** with the TCL interpreter.\n*/\nint Md5_Init(Tcl_Interp *interp){\n  Tcl_CreateCommand(interp, \"md5\", (Tcl_CmdProc*)md5_cmd,\n                    MD5DigestToBase16, 0);\n  Tcl_CreateCommand(interp, \"md5-10x8\", (Tcl_CmdProc*)md5_cmd,\n                    MD5DigestToBase10x8, 0);\n  Tcl_CreateCommand(interp, \"md5file\", (Tcl_CmdProc*)md5file_cmd,\n                    MD5DigestToBase16, 0);\n  Tcl_CreateCommand(interp, \"md5file-10x8\", (Tcl_CmdProc*)md5file_cmd,\n                    MD5DigestToBase10x8, 0);\n  return TCL_OK;\n}\n\n/*\n** During testing, the special md5sum() aggregate function is available.\n** inside SQLite.  The following routines implement that function.\n*/\nstatic void md5step(sqlite3_context *context, int argc, sqlite3_value **argv){\n  MD5Context *p;\n  int i;\n  if( argc<1 ) return;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( p==0 ) return;\n  if( !p->isInit ){\n    MD5Init(p);\n  }\n  for(i=0; i<argc; i++){\n    const char *zData = (char*)sqlite3_value_text(argv[i]);\n    if( zData ){\n      MD5Update(p, (unsigned char*)zData, (int)strlen(zData));\n    }\n  }\n}\nstatic void md5finalize(sqlite3_context *context){\n  MD5Context *p;\n  unsigned char digest[16];\n  char zBuf[33];\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  MD5Final(digest,p);\n  MD5DigestToBase16(digest, zBuf);\n  sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n}\nint Md5_Register(\n  sqlite3 *db,\n  char **pzErrMsg,\n  const sqlite3_api_routines *pThunk\n){\n  int rc = sqlite3_create_function(db, \"md5sum\", -1, SQLITE_UTF8, 0, 0,\n                                 md5step, md5finalize);\n  sqlite3_overload_function(db, \"md5sum\", -1);  /* To exercise this API */\n  return rc;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_multiplex.c",
    "content": "/*\n** 2010 October 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a VFS \"shim\" - a layer that sits in between the\n** pager and the real VFS - that breaks up a very large database file\n** into two or more smaller files on disk.  This is useful, for example,\n** in order to support large, multi-gigabyte databases on older filesystems\n** that limit the maximum file size to 2 GiB.\n**\n** USAGE:\n**\n** Compile this source file and link it with your application.  Then\n** at start-time, invoke the following procedure:\n**\n**   int sqlite3_multiplex_initialize(\n**      const char *zOrigVfsName,    // The underlying real VFS\n**      int makeDefault              // True to make multiplex the default VFS\n**   );\n**\n** The procedure call above will create and register a new VFS shim named\n** \"multiplex\".  The multiplex VFS will use the VFS named by zOrigVfsName to\n** do the actual disk I/O.  (The zOrigVfsName parameter may be NULL, in \n** which case the default VFS at the moment sqlite3_multiplex_initialize()\n** is called will be used as the underlying real VFS.)  \n**\n** If the makeDefault parameter is TRUE then multiplex becomes the new\n** default VFS.  Otherwise, you can use the multiplex VFS by specifying\n** \"multiplex\" as the 4th parameter to sqlite3_open_v2() or by employing\n** URI filenames and adding \"vfs=multiplex\" as a parameter to the filename\n** URI.\n**\n** The multiplex VFS allows databases up to 32 GiB in size.  But it splits\n** the files up into smaller pieces, so that they will work even on \n** filesystems that do not support large files.  The default chunk size\n** is 2147418112 bytes (which is 64KiB less than 2GiB) but this can be\n** changed at compile-time by defining the SQLITE_MULTIPLEX_CHUNK_SIZE\n** macro.  Use the \"chunksize=NNNN\" query parameter with a URI filename\n** in order to select an alternative chunk size for individual connections\n** at run-time.\n*/\n#include \"sqlite3.h\"\n#include <string.h>\n#include <assert.h>\n#include <stdlib.h>\n#include \"test_multiplex.h\"\n\n#ifndef SQLITE_CORE\n  #define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */\n#endif\n#include \"sqlite3ext.h\"\n\n/* \n** These should be defined to be the same as the values in \n** sqliteInt.h.  They are defined separately here so that\n** the multiplex VFS shim can be built as a loadable \n** module.\n*/\n#define UNUSED_PARAMETER(x) (void)(x)\n#define MAX_PAGE_SIZE       0x10000\n#define DEFAULT_SECTOR_SIZE 0x1000\n\n/* Maximum chunk number */\n#define MX_CHUNK_NUMBER 299\n\n/* First chunk for rollback journal files */\n#define SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET 400\n#define SQLITE_MULTIPLEX_WAL_8_3_OFFSET 700\n\n\n/************************ Shim Definitions ******************************/\n\n#ifndef SQLITE_MULTIPLEX_VFS_NAME\n# define SQLITE_MULTIPLEX_VFS_NAME \"multiplex\"\n#endif\n\n/* This is the limit on the chunk size.  It may be changed by calling\n** the xFileControl() interface.  It will be rounded up to a \n** multiple of MAX_PAGE_SIZE.  We default it here to 2GiB less 64KiB.\n*/\n#ifndef SQLITE_MULTIPLEX_CHUNK_SIZE\n# define SQLITE_MULTIPLEX_CHUNK_SIZE 2147418112\n#endif\n\n/* This used to be the default limit on number of chunks, but\n** it is no longer enforced. There is currently no limit to the\n** number of chunks.\n**\n** May be changed by calling the xFileControl() interface.\n*/\n#ifndef SQLITE_MULTIPLEX_MAX_CHUNKS\n# define SQLITE_MULTIPLEX_MAX_CHUNKS 12\n#endif\n\n/************************ Object Definitions ******************************/\n\n/* Forward declaration of all object types */\ntypedef struct multiplexGroup multiplexGroup;\ntypedef struct multiplexConn multiplexConn;\n\n/*\n** A \"multiplex group\" is a collection of files that collectively\n** makeup a single SQLite DB file.  This allows the size of the DB\n** to exceed the limits imposed by the file system.\n**\n** There is an instance of the following object for each defined multiplex\n** group.\n*/\nstruct multiplexGroup {\n  struct multiplexReal {           /* For each chunk */\n    sqlite3_file *p;                  /* Handle for the chunk */\n    char *z;                          /* Name of this chunk */\n  } *aReal;                        /* list of all chunks */\n  int nReal;                       /* Number of chunks */\n  char *zName;                     /* Base filename of this group */\n  int nName;                       /* Length of base filename */\n  int flags;                       /* Flags used for original opening */\n  unsigned int szChunk;            /* Chunk size used for this group */\n  unsigned char bEnabled;          /* TRUE to use Multiplex VFS for this file */\n  unsigned char bTruncate;         /* TRUE to enable truncation of databases */\n};\n\n/*\n** An instance of the following object represents each open connection\n** to a file that is multiplex'ed.  This object is a \n** subclass of sqlite3_file.  The sqlite3_file object for the underlying\n** VFS is appended to this structure.\n*/\nstruct multiplexConn {\n  sqlite3_file base;              /* Base class - must be first */\n  multiplexGroup *pGroup;         /* The underlying group of files */\n};\n\n/************************* Global Variables **********************************/\n/*\n** All global variables used by this file are containing within the following\n** gMultiplex structure.\n*/\nstatic struct {\n  /* The pOrigVfs is the real, original underlying VFS implementation.\n  ** Most operations pass-through to the real VFS.  This value is read-only\n  ** during operation.  It is only modified at start-time and thus does not\n  ** require a mutex.\n  */\n  sqlite3_vfs *pOrigVfs;\n\n  /* The sThisVfs is the VFS structure used by this shim.  It is initialized\n  ** at start-time and thus does not require a mutex\n  */\n  sqlite3_vfs sThisVfs;\n\n  /* The sIoMethods defines the methods used by sqlite3_file objects \n  ** associated with this shim.  It is initialized at start-time and does\n  ** not require a mutex.\n  **\n  ** When the underlying VFS is called to open a file, it might return \n  ** either a version 1 or a version 2 sqlite3_file object.  This shim\n  ** has to create a wrapper sqlite3_file of the same version.  Hence\n  ** there are two I/O method structures, one for version 1 and the other\n  ** for version 2.\n  */\n  sqlite3_io_methods sIoMethodsV1;\n  sqlite3_io_methods sIoMethodsV2;\n\n  /* True when this shim has been initialized.\n  */\n  int isInitialized;\n} gMultiplex;\n\n/************************* Utility Routines *********************************/\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n**\n** The value returned will never be negative.  Nor will it ever be greater\n** than the actual length of the string.  For very long strings (greater\n** than 1GiB) the value returned might be less than the true string length.\n*/\nstatic int multiplexStrlen30(const char *z){\n  const char *z2 = z;\n  if( z==0 ) return 0;\n  while( *z2 ){ z2++; }\n  return 0x3fffffff & (int)(z2 - z);\n}\n\n/*\n** Generate the file-name for chunk iChunk of the group with base name\n** zBase. The file-name is written to buffer zOut before returning. Buffer\n** zOut must be allocated by the caller so that it is at least (nBase+5)\n** bytes in size, where nBase is the length of zBase, not including the\n** nul-terminator.\n**\n** If iChunk is 0 (or 400 - the number for the first journal file chunk),\n** the output is a copy of the input string. Otherwise, if \n** SQLITE_ENABLE_8_3_NAMES is not defined or the input buffer does not contain\n** a \".\" character, then the output is a copy of the input string with the \n** three-digit zero-padded decimal representation if iChunk appended to it. \n** For example:\n**\n**   zBase=\"test.db\", iChunk=4  ->  zOut=\"test.db004\"\n**\n** Or, if SQLITE_ENABLE_8_3_NAMES is defined and the input buffer contains\n** a \".\" character, then everything after the \".\" is replaced by the \n** three-digit representation of iChunk.\n**\n**   zBase=\"test.db\", iChunk=4  ->  zOut=\"test.004\"\n**\n** The output buffer string is terminated by 2 0x00 bytes. This makes it safe\n** to pass to sqlite3_uri_parameter() and similar.\n*/\nstatic void multiplexFilename(\n  const char *zBase,              /* Filename for chunk 0 */\n  int nBase,                      /* Size of zBase in bytes (without \\0) */\n  int flags,                      /* Flags used to open file */\n  int iChunk,                     /* Chunk to generate filename for */\n  char *zOut                      /* Buffer to write generated name to */\n){\n  int n = nBase;\n  memcpy(zOut, zBase, n+1);\n  if( iChunk!=0 && iChunk<=MX_CHUNK_NUMBER ){\n#ifdef SQLITE_ENABLE_8_3_NAMES\n    int i;\n    for(i=n-1; i>0 && i>=n-4 && zOut[i]!='.'; i--){}\n    if( i>=n-4 ) n = i+1;\n    if( flags & SQLITE_OPEN_MAIN_JOURNAL ){\n      /* The extensions on overflow files for main databases are 001, 002,\n      ** 003 and so forth.  To avoid name collisions, add 400 to the \n      ** extensions of journal files so that they are 401, 402, 403, ....\n      */\n      iChunk += SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET;\n    }else if( flags & SQLITE_OPEN_WAL ){\n      /* To avoid name collisions, add 700 to the \n      ** extensions of WAL files so that they are 701, 702, 703, ....\n      */\n      iChunk += SQLITE_MULTIPLEX_WAL_8_3_OFFSET;\n    }\n#endif\n    sqlite3_snprintf(4,&zOut[n],\"%03d\",iChunk);\n    n += 3;\n  }\n\n  assert( zOut[n]=='\\0' );\n  zOut[n+1] = '\\0';\n}\n\n/* Compute the filename for the iChunk-th chunk\n*/\nstatic int multiplexSubFilename(multiplexGroup *pGroup, int iChunk){\n  if( iChunk>=pGroup->nReal ){\n    struct multiplexReal *p;\n    p = sqlite3_realloc64(pGroup->aReal, (iChunk+1)*sizeof(*p));\n    if( p==0 ){\n      return SQLITE_NOMEM;\n    }\n    memset(&p[pGroup->nReal], 0, sizeof(p[0])*(iChunk+1-pGroup->nReal));\n    pGroup->aReal = p;\n    pGroup->nReal = iChunk+1;\n  }\n  if( pGroup->zName && pGroup->aReal[iChunk].z==0 ){\n    char *z;\n    int n = pGroup->nName;\n    pGroup->aReal[iChunk].z = z = sqlite3_malloc64( n+5 );\n    if( z==0 ){\n      return SQLITE_NOMEM;\n    }\n    multiplexFilename(pGroup->zName, pGroup->nName, pGroup->flags, iChunk, z);\n  }\n  return SQLITE_OK;\n}\n\n/* Translate an sqlite3_file* that is really a multiplexGroup* into\n** the sqlite3_file* for the underlying original VFS.\n**\n** For chunk 0, the pGroup->flags determines whether or not a new file\n** is created if it does not already exist.  For chunks 1 and higher, the\n** file is created only if createFlag is 1.\n*/\nstatic sqlite3_file *multiplexSubOpen(\n  multiplexGroup *pGroup,    /* The multiplexor group */\n  int iChunk,                /* Which chunk to open.  0==original file */\n  int *rc,                   /* Result code in and out */\n  int *pOutFlags,            /* Output flags */\n  int createFlag             /* True to create if iChunk>0 */\n){\n  sqlite3_file *pSubOpen = 0;\n  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;        /* Real VFS */\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n  /* If JOURNAL_8_3_OFFSET is set to (say) 400, then any overflow files are \n  ** part of a database journal are named db.401, db.402, and so on. A \n  ** database may therefore not grow to larger than 400 chunks. Attempting\n  ** to open chunk 401 indicates the database is full. */\n  if( iChunk>=SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET ){\n    sqlite3_log(SQLITE_FULL, \"multiplexed chunk overflow: %s\", pGroup->zName);\n    *rc = SQLITE_FULL;\n    return 0;\n  }\n#endif\n\n  *rc = multiplexSubFilename(pGroup, iChunk);\n  if( (*rc)==SQLITE_OK && (pSubOpen = pGroup->aReal[iChunk].p)==0 ){\n    int flags, bExists;\n    flags = pGroup->flags;\n    if( createFlag ){\n      flags |= SQLITE_OPEN_CREATE;\n    }else if( iChunk==0 ){\n      /* Fall through */\n    }else if( pGroup->aReal[iChunk].z==0 ){\n      return 0;\n    }else{\n      *rc = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[iChunk].z,\n                              SQLITE_ACCESS_EXISTS, &bExists);\n     if( *rc || !bExists ){\n        if( *rc ){\n          sqlite3_log(*rc, \"multiplexor.xAccess failure on %s\",\n                      pGroup->aReal[iChunk].z);\n        }\n        return 0;\n      }\n      flags &= ~SQLITE_OPEN_CREATE;\n    }\n    pSubOpen = sqlite3_malloc64( pOrigVfs->szOsFile );\n    if( pSubOpen==0 ){\n      *rc = SQLITE_IOERR_NOMEM;\n      return 0;\n    }\n    pGroup->aReal[iChunk].p = pSubOpen;\n    *rc = pOrigVfs->xOpen(pOrigVfs, pGroup->aReal[iChunk].z, pSubOpen,\n                          flags, pOutFlags);\n    if( (*rc)!=SQLITE_OK ){\n      sqlite3_log(*rc, \"multiplexor.xOpen failure on %s\",\n                  pGroup->aReal[iChunk].z);\n      sqlite3_free(pSubOpen);\n      pGroup->aReal[iChunk].p = 0;\n      return 0;\n    }\n  }\n  return pSubOpen;\n}\n\n/*\n** Return the size, in bytes, of chunk number iChunk.  If that chunk\n** does not exist, then return 0.  This function does not distingish between\n** non-existant files and zero-length files.\n*/\nstatic sqlite3_int64 multiplexSubSize(\n  multiplexGroup *pGroup,    /* The multiplexor group */\n  int iChunk,                /* Which chunk to open.  0==original file */\n  int *rc                    /* Result code in and out */\n){\n  sqlite3_file *pSub;\n  sqlite3_int64 sz = 0;\n\n  if( *rc ) return 0;\n  pSub = multiplexSubOpen(pGroup, iChunk, rc, NULL, 0);\n  if( pSub==0 ) return 0;\n  *rc = pSub->pMethods->xFileSize(pSub, &sz);\n  return sz;\n}    \n\n/*\n** This is the implementation of the multiplex_control() SQL function.\n*/\nstatic void multiplexControlFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  int rc = SQLITE_OK;\n  sqlite3 *db = sqlite3_context_db_handle(context);\n  int op = 0;\n  int iVal;\n\n  if( !db || argc!=2 ){ \n    rc = SQLITE_ERROR; \n  }else{\n    /* extract params */\n    op = sqlite3_value_int(argv[0]);\n    iVal = sqlite3_value_int(argv[1]);\n    /* map function op to file_control op */\n    switch( op ){\n      case 1: \n        op = MULTIPLEX_CTRL_ENABLE; \n        break;\n      case 2: \n        op = MULTIPLEX_CTRL_SET_CHUNK_SIZE; \n        break;\n      case 3: \n        op = MULTIPLEX_CTRL_SET_MAX_CHUNKS; \n        break;\n      default:\n        rc = SQLITE_NOTFOUND;\n        break;\n    }\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_file_control(db, 0, op, &iVal);\n  }\n  sqlite3_result_error_code(context, rc);\n}\n\n/*\n** This is the entry point to register the auto-extension for the \n** multiplex_control() function.\n*/\nstatic int multiplexFuncInit(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  int rc;\n  rc = sqlite3_create_function(db, \"multiplex_control\", 2, SQLITE_ANY, \n      0, multiplexControlFunc, 0, 0);\n  return rc;\n}\n\n/*\n** Close a single sub-file in the connection group.\n*/\nstatic void multiplexSubClose(\n  multiplexGroup *pGroup,\n  int iChunk,\n  sqlite3_vfs *pOrigVfs\n){\n  sqlite3_file *pSubOpen = pGroup->aReal[iChunk].p;\n  if( pSubOpen ){\n    pSubOpen->pMethods->xClose(pSubOpen);\n    if( pOrigVfs && pGroup->aReal[iChunk].z ){\n      pOrigVfs->xDelete(pOrigVfs, pGroup->aReal[iChunk].z, 0);\n    }\n    sqlite3_free(pGroup->aReal[iChunk].p);\n  }\n  sqlite3_free(pGroup->aReal[iChunk].z);\n  memset(&pGroup->aReal[iChunk], 0, sizeof(pGroup->aReal[iChunk]));\n}\n\n/*\n** Deallocate memory held by a multiplexGroup\n*/\nstatic void multiplexFreeComponents(multiplexGroup *pGroup){\n  int i;\n  for(i=0; i<pGroup->nReal; i++){ multiplexSubClose(pGroup, i, 0); }\n  sqlite3_free(pGroup->aReal);\n  pGroup->aReal = 0;\n  pGroup->nReal = 0;\n}\n\n\n/************************* VFS Method Wrappers *****************************/\n\n/*\n** This is the xOpen method used for the \"multiplex\" VFS.\n**\n** Most of the work is done by the underlying original VFS.  This method\n** simply links the new file into the appropriate multiplex group if it is a\n** file that needs to be tracked.\n*/\nstatic int multiplexOpen(\n  sqlite3_vfs *pVfs,         /* The multiplex VFS */\n  const char *zName,         /* Name of file to be opened */\n  sqlite3_file *pConn,       /* Fill in this file descriptor */\n  int flags,                 /* Flags to control the opening */\n  int *pOutFlags             /* Flags showing results of opening */\n){\n  int rc = SQLITE_OK;                  /* Result code */\n  multiplexConn *pMultiplexOpen;       /* The new multiplex file descriptor */\n  multiplexGroup *pGroup = 0;          /* Corresponding multiplexGroup object */\n  sqlite3_file *pSubOpen = 0;                    /* Real file descriptor */\n  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */\n  int nName = 0;\n  int sz = 0;\n  char *zToFree = 0;\n\n  UNUSED_PARAMETER(pVfs);\n  memset(pConn, 0, pVfs->szOsFile);\n  assert( zName || (flags & SQLITE_OPEN_DELETEONCLOSE) );\n\n  /* We need to create a group structure and manage\n  ** access to this group of files.\n  */\n  pMultiplexOpen = (multiplexConn*)pConn;\n\n  if( rc==SQLITE_OK ){\n    /* allocate space for group */\n    nName = zName ? multiplexStrlen30(zName) : 0;\n    sz = sizeof(multiplexGroup)                             /* multiplexGroup */\n       + nName + 1;                                         /* zName */\n    pGroup = sqlite3_malloc64( sz );\n    if( pGroup==0 ){\n      rc = SQLITE_NOMEM;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    const char *zUri = (flags & SQLITE_OPEN_URI) ? zName : 0;\n    /* assign pointers to extra space allocated */\n    memset(pGroup, 0, sz);\n    pMultiplexOpen->pGroup = pGroup;\n    pGroup->bEnabled = (unsigned char)-1;\n    pGroup->bTruncate = (unsigned char)sqlite3_uri_boolean(zUri, \"truncate\", \n                                   (flags & SQLITE_OPEN_MAIN_DB)==0);\n    pGroup->szChunk = (int)sqlite3_uri_int64(zUri, \"chunksize\",\n                                        SQLITE_MULTIPLEX_CHUNK_SIZE);\n    pGroup->szChunk = (pGroup->szChunk+0xffff)&~0xffff;\n    if( zName ){\n      char *p = (char *)&pGroup[1];\n      pGroup->zName = p;\n      memcpy(pGroup->zName, zName, nName+1);\n      pGroup->nName = nName;\n    }\n    if( pGroup->bEnabled ){\n      /* Make sure that the chunksize is such that the pending byte does not\n      ** falls at the end of a chunk.  A region of up to 64K following\n      ** the pending byte is never written, so if the pending byte occurs\n      ** near the end of a chunk, that chunk will be too small. */\n#ifndef SQLITE_OMIT_WSD\n      extern int sqlite3PendingByte;\n#else\n      int sqlite3PendingByte = 0x40000000;\n#endif\n      while( (sqlite3PendingByte % pGroup->szChunk)>=(pGroup->szChunk-65536) ){\n        pGroup->szChunk += 65536;\n      }\n    }\n    pGroup->flags = flags;\n    rc = multiplexSubFilename(pGroup, 1);\n    if( rc==SQLITE_OK ){\n      pSubOpen = multiplexSubOpen(pGroup, 0, &rc, pOutFlags, 0);\n      if( pSubOpen==0 && rc==SQLITE_OK ) rc = SQLITE_CANTOPEN;\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3_int64 sz64;\n\n      rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz64);\n      if( rc==SQLITE_OK && zName ){\n        int bExists;\n        if( flags & SQLITE_OPEN_MASTER_JOURNAL ){\n          pGroup->bEnabled = 0;\n        }else\n        if( sz64==0 ){\n          if( flags & SQLITE_OPEN_MAIN_JOURNAL ){\n            /* If opening a main journal file and the first chunk is zero\n            ** bytes in size, delete any subsequent chunks from the \n            ** file-system. */\n            int iChunk = 1;\n            do {\n              rc = pOrigVfs->xAccess(pOrigVfs, \n                  pGroup->aReal[iChunk].z, SQLITE_ACCESS_EXISTS, &bExists\n              );\n              if( rc==SQLITE_OK && bExists ){\n                rc = pOrigVfs->xDelete(pOrigVfs, pGroup->aReal[iChunk].z, 0);\n                if( rc==SQLITE_OK ){\n                  rc = multiplexSubFilename(pGroup, ++iChunk);\n                }\n              }\n            }while( rc==SQLITE_OK && bExists );\n          }\n        }else{\n          /* If the first overflow file exists and if the size of the main file\n          ** is different from the chunk size, that means the chunk size is set\n          ** set incorrectly.  So fix it.\n          **\n          ** Or, if the first overflow file does not exist and the main file is\n          ** larger than the chunk size, that means the chunk size is too small.\n          ** But we have no way of determining the intended chunk size, so \n          ** just disable the multiplexor all togethre.\n          */\n          rc = pOrigVfs->xAccess(pOrigVfs, pGroup->aReal[1].z,\n              SQLITE_ACCESS_EXISTS, &bExists);\n          bExists = multiplexSubSize(pGroup, 1, &rc)>0;\n          if( rc==SQLITE_OK && bExists && sz64==(sz64&0xffff0000) && sz64>0\n              && sz64!=pGroup->szChunk ){\n            pGroup->szChunk = (int)sz64;\n          }else if( rc==SQLITE_OK && !bExists && sz64>pGroup->szChunk ){\n            pGroup->bEnabled = 0;\n          }\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pSubOpen->pMethods->iVersion==1 ){\n        pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV1;\n      }else{\n        pMultiplexOpen->base.pMethods = &gMultiplex.sIoMethodsV2;\n      }\n    }else{\n      multiplexFreeComponents(pGroup);\n      sqlite3_free(pGroup);\n    }\n  }\n  sqlite3_free(zToFree);\n  return rc;\n}\n\n/*\n** This is the xDelete method used for the \"multiplex\" VFS.\n** It attempts to delete the filename specified.\n*/\nstatic int multiplexDelete(\n  sqlite3_vfs *pVfs,         /* The multiplex VFS */\n  const char *zName,         /* Name of file to delete */\n  int syncDir\n){\n  int rc;\n  sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */\n  rc = pOrigVfs->xDelete(pOrigVfs, zName, syncDir);\n  if( rc==SQLITE_OK ){\n    /* If the main chunk was deleted successfully, also delete any subsequent\n    ** chunks - starting with the last (highest numbered). \n    */\n    int nName = (int)strlen(zName);\n    char *z;\n    z = sqlite3_malloc64(nName + 5);\n    if( z==0 ){\n      rc = SQLITE_IOERR_NOMEM;\n    }else{\n      int iChunk = 0;\n      int bExists;\n      do{\n        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, ++iChunk, z);\n        rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);\n      }while( rc==SQLITE_OK && bExists );\n      while( rc==SQLITE_OK && iChunk>1 ){\n        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, --iChunk, z);\n        rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);\n      }\n      if( rc==SQLITE_OK ){\n        iChunk = 0;\n        do{\n          multiplexFilename(zName, nName, SQLITE_OPEN_WAL, ++iChunk, z);\n          rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);\n        }while( rc==SQLITE_OK && bExists );\n        while( rc==SQLITE_OK && iChunk>1 ){\n          multiplexFilename(zName, nName, SQLITE_OPEN_WAL, --iChunk, z);\n          rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);\n        }\n      }\n    }\n    sqlite3_free(z);\n  }\n  return rc;\n}\n\nstatic int multiplexAccess(sqlite3_vfs *a, const char *b, int c, int *d){\n  return gMultiplex.pOrigVfs->xAccess(gMultiplex.pOrigVfs, b, c, d);\n}\nstatic int multiplexFullPathname(sqlite3_vfs *a, const char *b, int c, char *d){\n  return gMultiplex.pOrigVfs->xFullPathname(gMultiplex.pOrigVfs, b, c, d);\n}\nstatic void *multiplexDlOpen(sqlite3_vfs *a, const char *b){\n  return gMultiplex.pOrigVfs->xDlOpen(gMultiplex.pOrigVfs, b);\n}\nstatic void multiplexDlError(sqlite3_vfs *a, int b, char *c){\n  gMultiplex.pOrigVfs->xDlError(gMultiplex.pOrigVfs, b, c);\n}\nstatic void (*multiplexDlSym(sqlite3_vfs *a, void *b, const char *c))(void){\n  return gMultiplex.pOrigVfs->xDlSym(gMultiplex.pOrigVfs, b, c);\n}\nstatic void multiplexDlClose(sqlite3_vfs *a, void *b){\n  gMultiplex.pOrigVfs->xDlClose(gMultiplex.pOrigVfs, b);\n}\nstatic int multiplexRandomness(sqlite3_vfs *a, int b, char *c){\n  return gMultiplex.pOrigVfs->xRandomness(gMultiplex.pOrigVfs, b, c);\n}\nstatic int multiplexSleep(sqlite3_vfs *a, int b){\n  return gMultiplex.pOrigVfs->xSleep(gMultiplex.pOrigVfs, b);\n}\nstatic int multiplexCurrentTime(sqlite3_vfs *a, double *b){\n  return gMultiplex.pOrigVfs->xCurrentTime(gMultiplex.pOrigVfs, b);\n}\nstatic int multiplexGetLastError(sqlite3_vfs *a, int b, char *c){\n  if( gMultiplex.pOrigVfs->xGetLastError ){\n    return gMultiplex.pOrigVfs->xGetLastError(gMultiplex.pOrigVfs, b, c);\n  }else{\n    return 0;\n  }\n}\nstatic int multiplexCurrentTimeInt64(sqlite3_vfs *a, sqlite3_int64 *b){\n  return gMultiplex.pOrigVfs->xCurrentTimeInt64(gMultiplex.pOrigVfs, b);\n}\n\n/************************ I/O Method Wrappers *******************************/\n\n/* xClose requests get passed through to the original VFS.\n** We loop over all open chunk handles and close them.\n** The group structure for this file is unlinked from \n** our list of groups and freed.\n*/\nstatic int multiplexClose(sqlite3_file *pConn){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  multiplexFreeComponents(pGroup);\n  sqlite3_free(pGroup);\n  return rc;\n}\n\n/* Pass xRead requests thru to the original VFS after\n** determining the correct chunk to operate on.\n** Break up reads across chunk boundaries.\n*/\nstatic int multiplexRead(\n  sqlite3_file *pConn,\n  void *pBuf,\n  int iAmt,\n  sqlite3_int64 iOfst\n){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  if( !pGroup->bEnabled ){\n    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);\n    if( pSubOpen==0 ){\n      rc = SQLITE_IOERR_READ;\n    }else{\n      rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst);\n    }\n  }else{\n    while( iAmt > 0 ){\n      int i = (int)(iOfst / pGroup->szChunk);\n      sqlite3_file *pSubOpen;\n      pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1);\n      if( pSubOpen ){\n        int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) - pGroup->szChunk;\n        if( extra<0 ) extra = 0;\n        iAmt -= extra;\n        rc = pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt,\n                                       iOfst % pGroup->szChunk);\n        if( rc!=SQLITE_OK ) break;\n        pBuf = (char *)pBuf + iAmt;\n        iOfst += iAmt;\n        iAmt = extra;\n      }else{\n        rc = SQLITE_IOERR_READ;\n        break;\n      }\n    }\n  }\n\n  return rc;\n}\n\n/* Pass xWrite requests thru to the original VFS after\n** determining the correct chunk to operate on.\n** Break up writes across chunk boundaries.\n*/\nstatic int multiplexWrite(\n  sqlite3_file *pConn,\n  const void *pBuf,\n  int iAmt,\n  sqlite3_int64 iOfst\n){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  if( !pGroup->bEnabled ){\n    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);\n    if( pSubOpen==0 ){\n      rc = SQLITE_IOERR_WRITE;\n    }else{\n      rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst);\n    }\n  }else{\n    while( rc==SQLITE_OK && iAmt>0 ){\n      int i = (int)(iOfst / pGroup->szChunk);\n      sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, i, &rc, NULL, 1);\n      if( pSubOpen ){\n        int extra = ((int)(iOfst % pGroup->szChunk) + iAmt) -\n                    pGroup->szChunk;\n        if( extra<0 ) extra = 0;\n        iAmt -= extra;\n        rc = pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt,\n                                        iOfst % pGroup->szChunk);\n        pBuf = (char *)pBuf + iAmt;\n        iOfst += iAmt;\n        iAmt = extra;\n      }\n    }\n  }\n  return rc;\n}\n\n/* Pass xTruncate requests thru to the original VFS after\n** determining the correct chunk to operate on.  Delete any\n** chunks above the truncate mark.\n*/\nstatic int multiplexTruncate(sqlite3_file *pConn, sqlite3_int64 size){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  if( !pGroup->bEnabled ){\n    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);\n    if( pSubOpen==0 ){\n      rc = SQLITE_IOERR_TRUNCATE;\n    }else{\n      rc = pSubOpen->pMethods->xTruncate(pSubOpen, size);\n    }\n  }else{\n    int i;\n    int iBaseGroup = (int)(size / pGroup->szChunk);\n    sqlite3_file *pSubOpen;\n    sqlite3_vfs *pOrigVfs = gMultiplex.pOrigVfs;   /* Real VFS */\n    /* delete the chunks above the truncate limit */\n    for(i = pGroup->nReal-1; i>iBaseGroup && rc==SQLITE_OK; i--){\n      if( pGroup->bTruncate ){\n        multiplexSubClose(pGroup, i, pOrigVfs);\n      }else{\n        pSubOpen = multiplexSubOpen(pGroup, i, &rc, 0, 0);\n        if( pSubOpen ){\n          rc = pSubOpen->pMethods->xTruncate(pSubOpen, 0);\n        }\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pSubOpen = multiplexSubOpen(pGroup, iBaseGroup, &rc, 0, 0);\n      if( pSubOpen ){\n        rc = pSubOpen->pMethods->xTruncate(pSubOpen, size % pGroup->szChunk);\n      }\n    }\n    if( rc ) rc = SQLITE_IOERR_TRUNCATE;\n  }\n  return rc;\n}\n\n/* Pass xSync requests through to the original VFS without change\n*/\nstatic int multiplexSync(sqlite3_file *pConn, int flags){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  int i;\n  for(i=0; i<pGroup->nReal; i++){\n    sqlite3_file *pSubOpen = pGroup->aReal[i].p;\n    if( pSubOpen ){\n      int rc2 = pSubOpen->pMethods->xSync(pSubOpen, flags);\n      if( rc2!=SQLITE_OK ) rc = rc2;\n    }\n  }\n  return rc;\n}\n\n/* Pass xFileSize requests through to the original VFS.\n** Aggregate the size of all the chunks before returning.\n*/\nstatic int multiplexFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_OK;\n  int i;\n  if( !pGroup->bEnabled ){\n    sqlite3_file *pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);\n    if( pSubOpen==0 ){\n      rc = SQLITE_IOERR_FSTAT;\n    }else{\n      rc = pSubOpen->pMethods->xFileSize(pSubOpen, pSize);\n    }\n  }else{\n    *pSize = 0;\n    for(i=0; rc==SQLITE_OK; i++){\n      sqlite3_int64 sz = multiplexSubSize(pGroup, i, &rc);\n      if( sz==0 ) break;\n      *pSize = i*(sqlite3_int64)pGroup->szChunk + sz;\n    }\n  }\n  return rc;\n}\n\n/* Pass xLock requests through to the original VFS unchanged.\n*/\nstatic int multiplexLock(sqlite3_file *pConn, int lock){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xLock(pSubOpen, lock);\n  }\n  return SQLITE_BUSY;\n}\n\n/* Pass xUnlock requests through to the original VFS unchanged.\n*/\nstatic int multiplexUnlock(sqlite3_file *pConn, int lock){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xUnlock(pSubOpen, lock);\n  }\n  return SQLITE_IOERR_UNLOCK;\n}\n\n/* Pass xCheckReservedLock requests through to the original VFS unchanged.\n*/\nstatic int multiplexCheckReservedLock(sqlite3_file *pConn, int *pResOut){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xCheckReservedLock(pSubOpen, pResOut);\n  }\n  return SQLITE_IOERR_CHECKRESERVEDLOCK;\n}\n\n/* Pass xFileControl requests through to the original VFS unchanged,\n** except for any MULTIPLEX_CTRL_* requests here.\n*/\nstatic int multiplexFileControl(sqlite3_file *pConn, int op, void *pArg){\n  multiplexConn *p = (multiplexConn*)pConn;\n  multiplexGroup *pGroup = p->pGroup;\n  int rc = SQLITE_ERROR;\n  sqlite3_file *pSubOpen;\n\n  if( !gMultiplex.isInitialized ) return SQLITE_MISUSE;\n  switch( op ){\n    case MULTIPLEX_CTRL_ENABLE:\n      if( pArg ) {\n        int bEnabled = *(int *)pArg;\n        pGroup->bEnabled = (unsigned char)bEnabled;\n        rc = SQLITE_OK;\n      }\n      break;\n    case MULTIPLEX_CTRL_SET_CHUNK_SIZE:\n      if( pArg ) {\n        unsigned int szChunk = *(unsigned*)pArg;\n        if( szChunk<1 ){\n          rc = SQLITE_MISUSE;\n        }else{\n          /* Round up to nearest multiple of MAX_PAGE_SIZE. */\n          szChunk = (szChunk + (MAX_PAGE_SIZE-1));\n          szChunk &= ~(MAX_PAGE_SIZE-1);\n          pGroup->szChunk = szChunk;\n          rc = SQLITE_OK;\n        }\n      }\n      break;\n    case MULTIPLEX_CTRL_SET_MAX_CHUNKS:\n      rc = SQLITE_OK;\n      break;\n    case SQLITE_FCNTL_SIZE_HINT:\n    case SQLITE_FCNTL_CHUNK_SIZE:\n      /* no-op these */\n      rc = SQLITE_OK;\n      break;\n    case SQLITE_FCNTL_PRAGMA: {\n      char **aFcntl = (char**)pArg;\n      /*\n      ** EVIDENCE-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA\n      ** file control is an array of pointers to strings (char**) in which the\n      ** second element of the array is the name of the pragma and the third\n      ** element is the argument to the pragma or NULL if the pragma has no\n      ** argument.\n      */\n      if( aFcntl[1] && sqlite3_stricmp(aFcntl[1],\"multiplex_truncate\")==0 ){\n        if( aFcntl[2] && aFcntl[2][0] ){\n          if( sqlite3_stricmp(aFcntl[2], \"on\")==0\n           || sqlite3_stricmp(aFcntl[2], \"1\")==0 ){\n            pGroup->bTruncate = 1;\n          }else\n          if( sqlite3_stricmp(aFcntl[2], \"off\")==0\n           || sqlite3_stricmp(aFcntl[2], \"0\")==0 ){\n            pGroup->bTruncate = 0;\n          }\n        }\n        /* EVIDENCE-OF: R-27806-26076 The handler for an SQLITE_FCNTL_PRAGMA\n        ** file control can optionally make the first element of the char**\n        ** argument point to a string obtained from sqlite3_mprintf() or the\n        ** equivalent and that string will become the result of the pragma\n        ** or the error message if the pragma fails.\n        */\n        aFcntl[0] = sqlite3_mprintf(pGroup->bTruncate ? \"on\" : \"off\");\n        rc = SQLITE_OK;\n        break;\n      }\n      /* If the multiplexor does not handle the pragma, pass it through\n      ** into the default case. */\n    }\n    default:\n      pSubOpen = multiplexSubOpen(pGroup, 0, &rc, NULL, 0);\n      if( pSubOpen ){\n        rc = pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg);\n        if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n         *(char**)pArg = sqlite3_mprintf(\"multiplex/%z\", *(char**)pArg);\n        }\n      }\n      break;\n  }\n  return rc;\n}\n\n/* Pass xSectorSize requests through to the original VFS unchanged.\n*/\nstatic int multiplexSectorSize(sqlite3_file *pConn){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen && pSubOpen->pMethods->xSectorSize ){\n    return pSubOpen->pMethods->xSectorSize(pSubOpen);\n  }\n  return DEFAULT_SECTOR_SIZE;\n}\n\n/* Pass xDeviceCharacteristics requests through to the original VFS unchanged.\n*/\nstatic int multiplexDeviceCharacteristics(sqlite3_file *pConn){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xDeviceCharacteristics(pSubOpen);\n  }\n  return 0;\n}\n\n/* Pass xShmMap requests through to the original VFS unchanged.\n*/\nstatic int multiplexShmMap(\n  sqlite3_file *pConn,            /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xShmMap(pSubOpen, iRegion, szRegion, bExtend,pp);\n  }\n  return SQLITE_IOERR;\n}\n\n/* Pass xShmLock requests through to the original VFS unchanged.\n*/\nstatic int multiplexShmLock(\n  sqlite3_file *pConn,       /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xShmLock(pSubOpen, ofst, n, flags);\n  }\n  return SQLITE_BUSY;\n}\n\n/* Pass xShmBarrier requests through to the original VFS unchanged.\n*/\nstatic void multiplexShmBarrier(sqlite3_file *pConn){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    pSubOpen->pMethods->xShmBarrier(pSubOpen);\n  }\n}\n\n/* Pass xShmUnmap requests through to the original VFS unchanged.\n*/\nstatic int multiplexShmUnmap(sqlite3_file *pConn, int deleteFlag){\n  multiplexConn *p = (multiplexConn*)pConn;\n  int rc;\n  sqlite3_file *pSubOpen = multiplexSubOpen(p->pGroup, 0, &rc, NULL, 0);\n  if( pSubOpen ){\n    return pSubOpen->pMethods->xShmUnmap(pSubOpen, deleteFlag);\n  }\n  return SQLITE_OK;\n}\n\n/************************** Public Interfaces *****************************/\n/*\n** CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize()\n**\n** Use the VFS named zOrigVfsName as the VFS that does the actual work.  \n** Use the default if zOrigVfsName==NULL.  \n**\n** The multiplex VFS shim is named \"multiplex\".  It will become the default\n** VFS if makeDefault is non-zero.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once\n** during start-up.\n*/\nint sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault){\n  sqlite3_vfs *pOrigVfs;\n  if( gMultiplex.isInitialized ) return SQLITE_MISUSE;\n  pOrigVfs = sqlite3_vfs_find(zOrigVfsName);\n  if( pOrigVfs==0 ) return SQLITE_ERROR;\n  assert( pOrigVfs!=&gMultiplex.sThisVfs );\n  gMultiplex.isInitialized = 1;\n  gMultiplex.pOrigVfs = pOrigVfs;\n  gMultiplex.sThisVfs = *pOrigVfs;\n  gMultiplex.sThisVfs.szOsFile += sizeof(multiplexConn);\n  gMultiplex.sThisVfs.zName = SQLITE_MULTIPLEX_VFS_NAME;\n  gMultiplex.sThisVfs.xOpen = multiplexOpen;\n  gMultiplex.sThisVfs.xDelete = multiplexDelete;\n  gMultiplex.sThisVfs.xAccess = multiplexAccess;\n  gMultiplex.sThisVfs.xFullPathname = multiplexFullPathname;\n  gMultiplex.sThisVfs.xDlOpen = multiplexDlOpen;\n  gMultiplex.sThisVfs.xDlError = multiplexDlError;\n  gMultiplex.sThisVfs.xDlSym = multiplexDlSym;\n  gMultiplex.sThisVfs.xDlClose = multiplexDlClose;\n  gMultiplex.sThisVfs.xRandomness = multiplexRandomness;\n  gMultiplex.sThisVfs.xSleep = multiplexSleep;\n  gMultiplex.sThisVfs.xCurrentTime = multiplexCurrentTime;\n  gMultiplex.sThisVfs.xGetLastError = multiplexGetLastError;\n  gMultiplex.sThisVfs.xCurrentTimeInt64 = multiplexCurrentTimeInt64;\n\n  gMultiplex.sIoMethodsV1.iVersion = 1;\n  gMultiplex.sIoMethodsV1.xClose = multiplexClose;\n  gMultiplex.sIoMethodsV1.xRead = multiplexRead;\n  gMultiplex.sIoMethodsV1.xWrite = multiplexWrite;\n  gMultiplex.sIoMethodsV1.xTruncate = multiplexTruncate;\n  gMultiplex.sIoMethodsV1.xSync = multiplexSync;\n  gMultiplex.sIoMethodsV1.xFileSize = multiplexFileSize;\n  gMultiplex.sIoMethodsV1.xLock = multiplexLock;\n  gMultiplex.sIoMethodsV1.xUnlock = multiplexUnlock;\n  gMultiplex.sIoMethodsV1.xCheckReservedLock = multiplexCheckReservedLock;\n  gMultiplex.sIoMethodsV1.xFileControl = multiplexFileControl;\n  gMultiplex.sIoMethodsV1.xSectorSize = multiplexSectorSize;\n  gMultiplex.sIoMethodsV1.xDeviceCharacteristics =\n                                            multiplexDeviceCharacteristics;\n  gMultiplex.sIoMethodsV2 = gMultiplex.sIoMethodsV1;\n  gMultiplex.sIoMethodsV2.iVersion = 2;\n  gMultiplex.sIoMethodsV2.xShmMap = multiplexShmMap;\n  gMultiplex.sIoMethodsV2.xShmLock = multiplexShmLock;\n  gMultiplex.sIoMethodsV2.xShmBarrier = multiplexShmBarrier;\n  gMultiplex.sIoMethodsV2.xShmUnmap = multiplexShmUnmap;\n  sqlite3_vfs_register(&gMultiplex.sThisVfs, makeDefault);\n\n  sqlite3_auto_extension((void(*)(void))multiplexFuncInit);\n\n  return SQLITE_OK;\n}\n\n/*\n** CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown()\n**\n** All SQLite database connections must be closed before calling this\n** routine.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while\n** shutting down in order to free all remaining multiplex groups.\n*/\nint sqlite3_multiplex_shutdown(int eForce){\n  int rc = SQLITE_OK;\n  if( gMultiplex.isInitialized==0 ) return SQLITE_MISUSE;\n  gMultiplex.isInitialized = 0;\n  sqlite3_vfs_unregister(&gMultiplex.sThisVfs);\n  memset(&gMultiplex, 0, sizeof(gMultiplex));\n  return rc;\n}\n\n/***************************** Test Code ***********************************/\n#ifdef SQLITE_TEST\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\nextern const char *sqlite3ErrName(int);\n\n\n/*\n** tclcmd: sqlite3_multiplex_initialize NAME MAKEDEFAULT\n*/\nstatic int SQLITE_TCLAPI test_multiplex_initialize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zName;              /* Name of new multiplex VFS */\n  int makeDefault;                /* True to make the new VFS the default */\n  int rc;                         /* Value returned by multiplex_initialize() */\n\n  UNUSED_PARAMETER(clientData);\n\n  /* Process arguments */\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME MAKEDEFAULT\");\n    return TCL_ERROR;\n  }\n  zName = Tcl_GetString(objv[1]);\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &makeDefault) ) return TCL_ERROR;\n  if( zName[0]=='\\0' ) zName = 0;\n\n  /* Call sqlite3_multiplex_initialize() */\n  rc = sqlite3_multiplex_initialize(zName, makeDefault);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_multiplex_shutdown\n*/\nstatic int SQLITE_TCLAPI test_multiplex_shutdown(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;                         /* Value returned by multiplex_shutdown() */\n\n  UNUSED_PARAMETER(clientData);\n\n  if( objc==2 && strcmp(Tcl_GetString(objv[1]),\"-force\")!=0 ){\n    objc = 3;\n  }\n  if( (objc!=1 && objc!=2) ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"?-force?\");\n    return TCL_ERROR;\n  }\n\n  /* Call sqlite3_multiplex_shutdown() */\n  rc = sqlite3_multiplex_shutdown(objc==2);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n\n  return TCL_OK;\n}\n\n/*\n** Tclcmd: test_multiplex_control HANDLE DBNAME SUB-COMMAND ?INT-VALUE?\n*/\nstatic int SQLITE_TCLAPI test_multiplex_control(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;                         /* Return code from file_control() */\n  int idx;                        /* Index in aSub[] */\n  Tcl_CmdInfo cmdInfo;            /* Command info structure for HANDLE */\n  sqlite3 *db;                    /* Underlying db handle for HANDLE */\n  int iValue = 0;\n  void *pArg = 0;\n\n  struct SubCommand {\n    const char *zName;\n    int op;\n    int argtype;\n  } aSub[] = {\n    { \"enable\",       MULTIPLEX_CTRL_ENABLE,           1 },\n    { \"chunk_size\",   MULTIPLEX_CTRL_SET_CHUNK_SIZE,   1 },\n    { \"max_chunks\",   MULTIPLEX_CTRL_SET_MAX_CHUNKS,   1 },\n    { 0, 0, 0 }\n  };\n\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE DBNAME SUB-COMMAND INT-VALUE\");\n    return TCL_ERROR;\n  }\n\n  if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){\n    Tcl_AppendResult(interp, \"expected database handle, got \\\"\", 0);\n    Tcl_AppendResult(interp, Tcl_GetString(objv[1]), \"\\\"\", 0);\n    return TCL_ERROR;\n  }else{\n    db = *(sqlite3 **)cmdInfo.objClientData;\n  }\n\n  rc = Tcl_GetIndexFromObjStruct(\n      interp, objv[3], aSub, sizeof(aSub[0]), \"sub-command\", 0, &idx\n  );\n  if( rc!=TCL_OK ) return rc;\n\n  switch( aSub[idx].argtype ){\n    case 1:\n      if( Tcl_GetIntFromObj(interp, objv[4], &iValue) ){\n        return TCL_ERROR;\n      }\n      pArg = (void *)&iValue;\n      break;\n    default:\n      Tcl_WrongNumArgs(interp, 4, objv, \"SUB-COMMAND\");\n      return TCL_ERROR;\n  }\n\n  rc = sqlite3_file_control(db, Tcl_GetString(objv[2]), aSub[idx].op, pArg);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n  return (rc==SQLITE_OK) ? TCL_OK : TCL_ERROR;\n}\n\n/*\n** This routine registers the custom TCL commands defined in this\n** module.  This should be the only procedure visible from outside\n** of this module.\n*/\nint Sqlitemultiplex_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aCmd[] = {\n    { \"sqlite3_multiplex_initialize\", test_multiplex_initialize },\n    { \"sqlite3_multiplex_shutdown\", test_multiplex_shutdown },\n    { \"sqlite3_multiplex_control\", test_multiplex_control },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_multiplex.h",
    "content": "/*\n** 2011 March 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a VFS \"shim\" - a layer that sits in between the\n** pager and the real VFS.\n**\n** This particular shim enforces a multiplex system on DB files.  \n** This shim shards/partitions a single DB file into smaller \n** \"chunks\" such that the total DB file size may exceed the maximum\n** file size of the underlying file system.\n**\n*/\n\n#ifndef SQLITE_TEST_MULTIPLEX_H\n#define SQLITE_TEST_MULTIPLEX_H\n\n/*\n** CAPI: File-control Operations Supported by Multiplex VFS\n**\n** Values interpreted by the xFileControl method of a Multiplex VFS db file-handle.\n**\n** MULTIPLEX_CTRL_ENABLE:\n**   This file control is used to enable or disable the multiplex\n**   shim.\n**\n** MULTIPLEX_CTRL_SET_CHUNK_SIZE:\n**   This file control is used to set the maximum allowed chunk \n**   size for a multiplex file set.  The chunk size should be \n**   a multiple of SQLITE_MAX_PAGE_SIZE, and will be rounded up\n**   if not.\n**\n** MULTIPLEX_CTRL_SET_MAX_CHUNKS:\n**   This file control is used to set the maximum number of chunks\n**   allowed to be used for a mutliplex file set.\n*/\n#define MULTIPLEX_CTRL_ENABLE          214014\n#define MULTIPLEX_CTRL_SET_CHUNK_SIZE  214015\n#define MULTIPLEX_CTRL_SET_MAX_CHUNKS  214016\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize()\n**\n** Use the VFS named zOrigVfsName as the VFS that does the actual work.  \n** Use the default if zOrigVfsName==NULL.  \n**\n** The multiplex VFS shim is named \"multiplex\".  It will become the default\n** VFS if makeDefault is non-zero.\n**\n** An auto-extension is registered which will make the function \n** multiplex_control() available to database connections.  This\n** function gives access to the xFileControl interface of the \n** multiplex VFS shim.\n**\n** SELECT multiplex_control(<op>,<val>);\n** \n**   <op>=1 MULTIPLEX_CTRL_ENABLE\n**   <val>=0 disable\n**   <val>=1 enable\n** \n**   <op>=2 MULTIPLEX_CTRL_SET_CHUNK_SIZE\n**   <val> int, chunk size\n** \n**   <op>=3 MULTIPLEX_CTRL_SET_MAX_CHUNKS\n**   <val> int, max chunks\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once\n** during start-up.\n*/\nextern int sqlite3_multiplex_initialize(const char *zOrigVfsName, int makeDefault);\n\n/*\n** CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown()\n**\n** All SQLite database connections must be closed before calling this\n** routine.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while\n** shutting down in order to free all remaining multiplex groups.\n*/\nextern int sqlite3_multiplex_shutdown(int eForce);\n\n#ifdef __cplusplus\n}  /* End of the 'extern \"C\"' block */\n#endif\n\n#endif /* SQLITE_TEST_MULTIPLEX_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_mutex.c",
    "content": "/*\n** 2008 June 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains test logic for the sqlite3_mutex interfaces.\n*/\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include \"sqlite3.h\"\n#include \"sqliteInt.h\"\n#include <stdlib.h>\n#include <assert.h>\n#include <string.h>\n\n#define MAX_MUTEXES        (SQLITE_MUTEX_STATIC_VFS3+1)\n#define STATIC_MUTEXES     (MAX_MUTEXES-(SQLITE_MUTEX_RECURSIVE+1))\n\n/* defined in main.c */\nextern const char *sqlite3ErrName(int);\n\nstatic const char *aName[MAX_MUTEXES+1] = {\n  \"fast\",        \"recursive\",   \"static_master\", \"static_mem\",\n  \"static_open\", \"static_prng\", \"static_lru\",    \"static_pmem\",\n  \"static_app1\", \"static_app2\", \"static_app3\",   \"static_vfs1\",\n  \"static_vfs2\", \"static_vfs3\", 0\n};\n\n/* A countable mutex */\nstruct sqlite3_mutex {\n  sqlite3_mutex *pReal;\n  int eType;\n};\n\n/* State variables */\nstatic struct test_mutex_globals {\n  int isInstalled;           /* True if installed */\n  int disableInit;           /* True to cause sqlite3_initalize() to fail */\n  int disableTry;            /* True to force sqlite3_mutex_try() to fail */\n  int isInit;                /* True if initialized */\n  sqlite3_mutex_methods m;   /* Interface to \"real\" mutex system */\n  int aCounter[MAX_MUTEXES]; /* Number of grabs of each type of mutex */\n  sqlite3_mutex aStatic[STATIC_MUTEXES]; /* The static mutexes */\n} g = {0};\n\n/* Return true if the countable mutex is currently held */\nstatic int counterMutexHeld(sqlite3_mutex *p){\n  return g.m.xMutexHeld(p->pReal);\n}\n\n/* Return true if the countable mutex is not currently held */\nstatic int counterMutexNotheld(sqlite3_mutex *p){\n  return g.m.xMutexNotheld(p->pReal);\n}\n\n/* Initialize the countable mutex interface\n** Or, if g.disableInit is non-zero, then do not initialize but instead\n** return the value of g.disableInit as the result code.  This can be used\n** to simulate an initialization failure.\n*/\nstatic int counterMutexInit(void){ \n  int rc;\n  if( g.disableInit ) return g.disableInit;\n  rc = g.m.xMutexInit();\n  g.isInit = 1;\n  return rc;\n}\n\n/*\n** Uninitialize the mutex subsystem\n*/\nstatic int counterMutexEnd(void){ \n  g.isInit = 0;\n  return g.m.xMutexEnd();\n}\n\n/*\n** Allocate a countable mutex\n*/\nstatic sqlite3_mutex *counterMutexAlloc(int eType){\n  sqlite3_mutex *pReal;\n  sqlite3_mutex *pRet = 0;\n\n  assert( g.isInit );\n  assert( eType>=SQLITE_MUTEX_FAST );\n  assert( eType<=SQLITE_MUTEX_STATIC_VFS3 );\n\n  pReal = g.m.xMutexAlloc(eType);\n  if( !pReal ) return 0;\n\n  if( eType==SQLITE_MUTEX_FAST || eType==SQLITE_MUTEX_RECURSIVE ){\n    pRet = (sqlite3_mutex *)malloc(sizeof(sqlite3_mutex));\n  }else{\n    int eStaticType = eType - (MAX_MUTEXES - STATIC_MUTEXES);\n    assert( eStaticType>=0 );\n    assert( eStaticType<STATIC_MUTEXES );\n    pRet = &g.aStatic[eStaticType];\n  }\n\n  pRet->eType = eType;\n  pRet->pReal = pReal;\n  return pRet;\n}\n\n/*\n** Free a countable mutex\n*/\nstatic void counterMutexFree(sqlite3_mutex *p){\n  assert( g.isInit );\n  g.m.xMutexFree(p->pReal);\n  if( p->eType==SQLITE_MUTEX_FAST || p->eType==SQLITE_MUTEX_RECURSIVE ){\n    free(p);\n  }\n}\n\n/*\n** Enter a countable mutex.  Block until entry is safe.\n*/\nstatic void counterMutexEnter(sqlite3_mutex *p){\n  assert( g.isInit );\n  assert( p->eType>=0 );\n  assert( p->eType<MAX_MUTEXES );\n  g.aCounter[p->eType]++;\n  g.m.xMutexEnter(p->pReal);\n}\n\n/*\n** Try to enter a mutex.  Return true on success.\n*/\nstatic int counterMutexTry(sqlite3_mutex *p){\n  assert( g.isInit );\n  assert( p->eType>=0 );\n  assert( p->eType<MAX_MUTEXES );\n  g.aCounter[p->eType]++;\n  if( g.disableTry ) return SQLITE_BUSY;\n  return g.m.xMutexTry(p->pReal);\n}\n\n/* Leave a mutex\n*/\nstatic void counterMutexLeave(sqlite3_mutex *p){\n  assert( g.isInit );\n  g.m.xMutexLeave(p->pReal);\n}\n\n/*\n** sqlite3_shutdown\n*/\nstatic int SQLITE_TCLAPI test_shutdown(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_shutdown();\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** sqlite3_initialize\n*/\nstatic int SQLITE_TCLAPI test_initialize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  rc = sqlite3_initialize();\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** install_mutex_counters BOOLEAN\n*/\nstatic int SQLITE_TCLAPI test_install_mutex_counters(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc = SQLITE_OK;\n  int isInstall;\n\n  sqlite3_mutex_methods counter_methods = {\n    counterMutexInit,\n    counterMutexEnd,\n    counterMutexAlloc,\n    counterMutexFree,\n    counterMutexEnter,\n    counterMutexTry,\n    counterMutexLeave,\n    counterMutexHeld,\n    counterMutexNotheld\n  };\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"BOOLEAN\");\n    return TCL_ERROR;\n  }\n  if( TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[1], &isInstall) ){\n    return TCL_ERROR;\n  }\n\n  assert(isInstall==0 || isInstall==1);\n  assert(g.isInstalled==0 || g.isInstalled==1);\n  if( isInstall==g.isInstalled ){\n    Tcl_AppendResult(interp, \"mutex counters are \", 0);\n    Tcl_AppendResult(interp, isInstall?\"already installed\":\"not installed\", 0);\n    return TCL_ERROR;\n  }\n\n  if( isInstall ){\n    assert( g.m.xMutexAlloc==0 );\n    rc = sqlite3_config(SQLITE_CONFIG_GETMUTEX, &g.m);\n    if( rc==SQLITE_OK ){\n      sqlite3_config(SQLITE_CONFIG_MUTEX, &counter_methods);\n    }\n    g.disableTry = 0;\n  }else{\n    assert( g.m.xMutexAlloc );\n    rc = sqlite3_config(SQLITE_CONFIG_MUTEX, &g.m);\n    memset(&g.m, 0, sizeof(sqlite3_mutex_methods));\n  }\n\n  if( rc==SQLITE_OK ){\n    g.isInstalled = isInstall;\n  }\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/*\n** read_mutex_counters\n*/\nstatic int SQLITE_TCLAPI test_read_mutex_counters(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_Obj *pRet;\n  int ii;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pRet = Tcl_NewObj();\n  Tcl_IncrRefCount(pRet);\n  for(ii=0; ii<MAX_MUTEXES; ii++){\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(aName[ii], -1));\n    Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(g.aCounter[ii]));\n  }\n  Tcl_SetObjResult(interp, pRet);\n  Tcl_DecrRefCount(pRet);\n\n  return TCL_OK;\n}\n\n/*\n** clear_mutex_counters\n*/\nstatic int SQLITE_TCLAPI test_clear_mutex_counters(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int ii;\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  for(ii=0; ii<MAX_MUTEXES; ii++){\n    g.aCounter[ii] = 0;\n  }\n  return TCL_OK;\n}\n\n/*\n** Create and free a mutex.  Return the mutex pointer.  The pointer\n** will be invalid since the mutex has already been freed.  The\n** return pointer just checks to see if the mutex really was allocated.\n*/\nstatic int SQLITE_TCLAPI test_alloc_mutex(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *p = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n  char zBuf[100];\n  sqlite3_mutex_free(p);\n  sqlite3_snprintf(sizeof(zBuf), zBuf, \"%p\", p);\n  Tcl_AppendResult(interp, zBuf, (char*)0);\n#endif\n  return TCL_OK;\n}\n\n/*\n** sqlite3_config OPTION\n**\n** OPTION can be either one of the keywords:\n**\n**            SQLITE_CONFIG_SINGLETHREAD\n**            SQLITE_CONFIG_MULTITHREAD\n**            SQLITE_CONFIG_SERIALIZED\n**\n** Or OPTION can be an raw integer.\n*/\nstatic int SQLITE_TCLAPI test_config(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct ConfigOption {\n    const char *zName;\n    int iValue;\n  } aOpt[] = {\n    {\"singlethread\", SQLITE_CONFIG_SINGLETHREAD},\n    {\"multithread\",  SQLITE_CONFIG_MULTITHREAD},\n    {\"serialized\",   SQLITE_CONFIG_SERIALIZED},\n    {0, 0}\n  };\n  int s = sizeof(struct ConfigOption);\n  int i;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  if( Tcl_GetIndexFromObjStruct(interp, objv[1], aOpt, s, \"flag\", 0, &i) ){\n    if( Tcl_GetIntFromObj(interp, objv[1], &i) ){\n      return TCL_ERROR;\n    }\n  }else{\n    i = aOpt[i].iValue;\n  }\n\n  rc = sqlite3_config(i);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);\n  return TCL_OK;\n}\n\nstatic sqlite3 *getDbPointer(Tcl_Interp *pInterp, Tcl_Obj *pObj){\n  sqlite3 *db;\n  Tcl_CmdInfo info;\n  char *zCmd = Tcl_GetString(pObj);\n  if( Tcl_GetCommandInfo(pInterp, zCmd, &info) ){\n    db = *((sqlite3 **)info.objClientData);\n  }else{\n    db = (sqlite3*)sqlite3TestTextToPtr(zCmd);\n  }\n  assert( db );\n  return db;\n}\n\nstatic sqlite3_mutex *getStaticMutexPointer(\n  Tcl_Interp *pInterp,\n  Tcl_Obj *pObj\n){\n  int iMutex;\n  if( Tcl_GetIndexFromObj(pInterp, pObj, aName, \"mutex name\", 0, &iMutex) ){\n    return 0;\n  }\n  assert( iMutex!=SQLITE_MUTEX_FAST && iMutex!=SQLITE_MUTEX_RECURSIVE );\n  return counterMutexAlloc(iMutex);\n}\n\nstatic int SQLITE_TCLAPI test_enter_static_mutex(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_mutex *pMutex;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME\");\n    return TCL_ERROR;\n  }\n  pMutex = getStaticMutexPointer(interp, objv[1]);\n  if( !pMutex ){\n    return TCL_ERROR;\n  }\n  sqlite3_mutex_enter(pMutex);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_leave_static_mutex(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_mutex *pMutex;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME\");\n    return TCL_ERROR;\n  }\n  pMutex = getStaticMutexPointer(interp, objv[1]);\n  if( !pMutex ){\n    return TCL_ERROR;\n  }\n  sqlite3_mutex_leave(pMutex);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_enter_db_mutex(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  db = getDbPointer(interp, objv[1]);\n  if( !db ){\n    return TCL_ERROR;\n  }\n  sqlite3_mutex_enter(sqlite3_db_mutex(db));\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_leave_db_mutex(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  db = getDbPointer(interp, objv[1]);\n  if( !db ){\n    return TCL_ERROR;\n  }\n  sqlite3_mutex_leave(sqlite3_db_mutex(db));\n  return TCL_OK;\n}\n\nint Sqlitetest_mutex_Init(Tcl_Interp *interp){\n  static struct {\n    char *zName;\n    Tcl_ObjCmdProc *xProc;\n  } aCmd[] = {\n    { \"sqlite3_shutdown\",        (Tcl_ObjCmdProc*)test_shutdown },\n    { \"sqlite3_initialize\",      (Tcl_ObjCmdProc*)test_initialize },\n    { \"sqlite3_config\",          (Tcl_ObjCmdProc*)test_config },\n\n    { \"enter_static_mutex\",      (Tcl_ObjCmdProc*)test_enter_static_mutex },\n    { \"leave_static_mutex\",      (Tcl_ObjCmdProc*)test_leave_static_mutex },\n\n    { \"enter_db_mutex\",          (Tcl_ObjCmdProc*)test_enter_db_mutex },\n    { \"leave_db_mutex\",          (Tcl_ObjCmdProc*)test_leave_db_mutex },\n\n    { \"alloc_dealloc_mutex\",     (Tcl_ObjCmdProc*)test_alloc_mutex },\n    { \"install_mutex_counters\",  (Tcl_ObjCmdProc*)test_install_mutex_counters },\n    { \"read_mutex_counters\",     (Tcl_ObjCmdProc*)test_read_mutex_counters },\n    { \"clear_mutex_counters\",    (Tcl_ObjCmdProc*)test_clear_mutex_counters },\n  };\n  int i;\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n\n  Tcl_LinkVar(interp, \"disable_mutex_init\", \n              (char*)&g.disableInit, TCL_LINK_INT);\n  Tcl_LinkVar(interp, \"disable_mutex_try\", \n              (char*)&g.disableTry, TCL_LINK_INT);\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_onefile.c",
    "content": "/*\n** 2007 September 14\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** OVERVIEW:\n**\n**   This file contains some example code demonstrating how the SQLite \n**   vfs feature can be used to have SQLite operate directly on an \n**   embedded media, without using an intermediate file system.\n**\n**   Because this is only a demo designed to run on a workstation, the\n**   underlying media is simulated using a regular file-system file. The\n**   size of the file is fixed when it is first created (default size 10 MB).\n**   From SQLite's point of view, this space is used to store a single\n**   database file and the journal file. \n**\n**   Any statement journal created is stored in volatile memory obtained \n**   from sqlite3_malloc(). Any attempt to create a temporary database file \n**   will fail (SQLITE_IOERR). To prevent SQLite from attempting this,\n**   it should be configured to store all temporary database files in \n**   main memory (see pragma \"temp_store\" or the SQLITE_TEMP_STORE compile \n**   time option).\n**\n** ASSUMPTIONS:\n**\n**   After it has been created, the blob file is accessed using the\n**   following three functions only:\n**\n**       mediaRead();            - Read a 512 byte block from the file.\n**       mediaWrite();           - Write a 512 byte block to the file.\n**       mediaSync();            - Tell the media hardware to sync.\n**\n**   It is assumed that these can be easily implemented by any \"real\"\n**   media vfs driver adapting this code.\n**\n** FILE FORMAT:\n**\n**   The basic principle is that the \"database file\" is stored at the\n**   beginning of the 10 MB blob and grows in a forward direction. The \n**   \"journal file\" is stored at the end of the 10MB blob and grows\n**   in the reverse direction. If, during a transaction, insufficient\n**   space is available to expand either the journal or database file,\n**   an SQLITE_FULL error is returned. The database file is never allowed\n**   to consume more than 90% of the blob space. If SQLite tries to\n**   create a file larger than this, SQLITE_FULL is returned.\n**\n**   No allowance is made for \"wear-leveling\", as is required by.\n**   embedded devices in the absence of equivalent hardware features.\n**\n**   The first 512 block byte of the file is reserved for storing the\n**   size of the \"database file\". It is updated as part of the sync()\n**   operation. On startup, it can only be trusted if no journal file\n**   exists. If a journal-file does exist, then it stores the real size\n**   of the database region. The second and subsequent blocks store the \n**   actual database content.\n**\n**   The size of the \"journal file\" is not stored persistently in the \n**   file. When the system is running, the size of the journal file is\n**   stored in volatile memory. When recovering from a crash, this vfs\n**   reports a very large size for the journal file. The normal journal\n**   header and checksum mechanisms serve to prevent SQLite from \n**   processing any data that lies past the logical end of the journal.\n**\n**   When SQLite calls OsDelete() to delete the journal file, the final\n**   512 bytes of the blob (the area containing the first journal header)\n**   are zeroed.\n**\n** LOCKING:\n**\n**   File locking is a no-op. Only one connection may be open at any one\n**   time using this demo vfs.\n*/\n\n#include \"sqlite3.h\"\n#include <assert.h>\n#include <string.h>\n\n/*\n** Maximum pathname length supported by the fs backend.\n*/\n#define BLOCKSIZE 512\n#define BLOBSIZE 10485760\n\n/*\n** Name used to identify this VFS.\n*/\n#define FS_VFS_NAME \"fs\"\n\ntypedef struct fs_real_file fs_real_file;\nstruct fs_real_file {\n  sqlite3_file *pFile;\n  const char *zName;\n  int nDatabase;              /* Current size of database region */\n  int nJournal;               /* Current size of journal region */\n  int nBlob;                  /* Total size of allocated blob */\n  int nRef;                   /* Number of pointers to this structure */\n  fs_real_file *pNext;\n  fs_real_file **ppThis;\n};\n\ntypedef struct fs_file fs_file;\nstruct fs_file {\n  sqlite3_file base;\n  int eType;\n  fs_real_file *pReal;\n};\n\ntypedef struct tmp_file tmp_file;\nstruct tmp_file {\n  sqlite3_file base;\n  int nSize;\n  int nAlloc;\n  char *zAlloc;\n};\n\n/* Values for fs_file.eType. */\n#define DATABASE_FILE   1\n#define JOURNAL_FILE    2\n\n/*\n** Method declarations for fs_file.\n*/\nstatic int fsClose(sqlite3_file*);\nstatic int fsRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int fsWrite(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\nstatic int fsTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int fsSync(sqlite3_file*, int flags);\nstatic int fsFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int fsLock(sqlite3_file*, int);\nstatic int fsUnlock(sqlite3_file*, int);\nstatic int fsCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int fsFileControl(sqlite3_file*, int op, void *pArg);\nstatic int fsSectorSize(sqlite3_file*);\nstatic int fsDeviceCharacteristics(sqlite3_file*);\n\n/*\n** Method declarations for tmp_file.\n*/\nstatic int tmpClose(sqlite3_file*);\nstatic int tmpRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int tmpWrite(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);\nstatic int tmpTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int tmpSync(sqlite3_file*, int flags);\nstatic int tmpFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int tmpLock(sqlite3_file*, int);\nstatic int tmpUnlock(sqlite3_file*, int);\nstatic int tmpCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int tmpFileControl(sqlite3_file*, int op, void *pArg);\nstatic int tmpSectorSize(sqlite3_file*);\nstatic int tmpDeviceCharacteristics(sqlite3_file*);\n\n/*\n** Method declarations for fs_vfs.\n*/\nstatic int fsOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int fsDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int fsAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int fsFullPathname(sqlite3_vfs*, const char *zName, int nOut,char *zOut);\nstatic void *fsDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void fsDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*fsDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);\nstatic void fsDlClose(sqlite3_vfs*, void*);\nstatic int fsRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int fsSleep(sqlite3_vfs*, int microseconds);\nstatic int fsCurrentTime(sqlite3_vfs*, double*);\n\n\ntypedef struct fs_vfs_t fs_vfs_t;\nstruct fs_vfs_t {\n  sqlite3_vfs base;\n  fs_real_file *pFileList;\n  sqlite3_vfs *pParent;\n};\n\nstatic fs_vfs_t fs_vfs = {\n  {\n    1,                                          /* iVersion */\n    0,                                          /* szOsFile */\n    0,                                          /* mxPathname */\n    0,                                          /* pNext */\n    FS_VFS_NAME,                                /* zName */\n    0,                                          /* pAppData */\n    fsOpen,                                     /* xOpen */\n    fsDelete,                                   /* xDelete */\n    fsAccess,                                   /* xAccess */\n    fsFullPathname,                             /* xFullPathname */\n    fsDlOpen,                                   /* xDlOpen */\n    fsDlError,                                  /* xDlError */\n    fsDlSym,                                    /* xDlSym */\n    fsDlClose,                                  /* xDlClose */\n    fsRandomness,                               /* xRandomness */\n    fsSleep,                                    /* xSleep */\n    fsCurrentTime,                              /* xCurrentTime */\n    0                                           /* xCurrentTimeInt64 */\n  }, \n  0,                                            /* pFileList */\n  0                                             /* pParent */\n};\n\nstatic sqlite3_io_methods fs_io_methods = {\n  1,                            /* iVersion */\n  fsClose,                      /* xClose */\n  fsRead,                       /* xRead */\n  fsWrite,                      /* xWrite */\n  fsTruncate,                   /* xTruncate */\n  fsSync,                       /* xSync */\n  fsFileSize,                   /* xFileSize */\n  fsLock,                       /* xLock */\n  fsUnlock,                     /* xUnlock */\n  fsCheckReservedLock,          /* xCheckReservedLock */\n  fsFileControl,                /* xFileControl */\n  fsSectorSize,                 /* xSectorSize */\n  fsDeviceCharacteristics,      /* xDeviceCharacteristics */\n  0,                            /* xShmMap */\n  0,                            /* xShmLock */\n  0,                            /* xShmBarrier */\n  0                             /* xShmUnmap */\n};\n\n\nstatic sqlite3_io_methods tmp_io_methods = {\n  1,                            /* iVersion */\n  tmpClose,                     /* xClose */\n  tmpRead,                      /* xRead */\n  tmpWrite,                     /* xWrite */\n  tmpTruncate,                  /* xTruncate */\n  tmpSync,                      /* xSync */\n  tmpFileSize,                  /* xFileSize */\n  tmpLock,                      /* xLock */\n  tmpUnlock,                    /* xUnlock */\n  tmpCheckReservedLock,         /* xCheckReservedLock */\n  tmpFileControl,               /* xFileControl */\n  tmpSectorSize,                /* xSectorSize */\n  tmpDeviceCharacteristics,     /* xDeviceCharacteristics */\n  0,                            /* xShmMap */\n  0,                            /* xShmLock */\n  0,                            /* xShmBarrier */\n  0                             /* xShmUnmap */\n};\n\n/* Useful macros used in several places */\n#define MIN(x,y) ((x)<(y)?(x):(y))\n#define MAX(x,y) ((x)>(y)?(x):(y))\n\n\n/*\n** Close a tmp-file.\n*/\nstatic int tmpClose(sqlite3_file *pFile){\n  tmp_file *pTmp = (tmp_file *)pFile;\n  sqlite3_free(pTmp->zAlloc);\n  return SQLITE_OK;\n}\n\n/*\n** Read data from a tmp-file.\n*/\nstatic int tmpRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  tmp_file *pTmp = (tmp_file *)pFile;\n  if( (iAmt+iOfst)>pTmp->nSize ){\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  memcpy(zBuf, &pTmp->zAlloc[iOfst], iAmt);\n  return SQLITE_OK;\n}\n\n/*\n** Write data to a tmp-file.\n*/\nstatic int tmpWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  tmp_file *pTmp = (tmp_file *)pFile;\n  if( (iAmt+iOfst)>pTmp->nAlloc ){\n    int nNew = (int)(2*(iAmt+iOfst+pTmp->nAlloc));\n    char *zNew = sqlite3_realloc(pTmp->zAlloc, nNew);\n    if( !zNew ){\n      return SQLITE_NOMEM;\n    }\n    pTmp->zAlloc = zNew;\n    pTmp->nAlloc = nNew;\n  }\n  memcpy(&pTmp->zAlloc[iOfst], zBuf, iAmt);\n  pTmp->nSize = (int)MAX(pTmp->nSize, iOfst+iAmt);\n  return SQLITE_OK;\n}\n\n/*\n** Truncate a tmp-file.\n*/\nstatic int tmpTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  tmp_file *pTmp = (tmp_file *)pFile;\n  pTmp->nSize = (int)MIN(pTmp->nSize, size);\n  return SQLITE_OK;\n}\n\n/*\n** Sync a tmp-file.\n*/\nstatic int tmpSync(sqlite3_file *pFile, int flags){\n  return SQLITE_OK;\n}\n\n/*\n** Return the current file-size of a tmp-file.\n*/\nstatic int tmpFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  tmp_file *pTmp = (tmp_file *)pFile;\n  *pSize = pTmp->nSize;\n  return SQLITE_OK;\n}\n\n/*\n** Lock a tmp-file.\n*/\nstatic int tmpLock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\n\n/*\n** Unlock a tmp-file.\n*/\nstatic int tmpUnlock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on a tmp-file.\n*/\nstatic int tmpCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n\n/*\n** File control method. For custom operations on a tmp-file.\n*/\nstatic int tmpFileControl(sqlite3_file *pFile, int op, void *pArg){\n  return SQLITE_OK;\n}\n\n/*\n** Return the sector-size in bytes for a tmp-file.\n*/\nstatic int tmpSectorSize(sqlite3_file *pFile){\n  return 0;\n}\n\n/*\n** Return the device characteristic flags supported by a tmp-file.\n*/\nstatic int tmpDeviceCharacteristics(sqlite3_file *pFile){\n  return 0;\n}\n\n/*\n** Close an fs-file.\n*/\nstatic int fsClose(sqlite3_file *pFile){\n  int rc = SQLITE_OK;\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n\n  /* Decrement the real_file ref-count. */\n  pReal->nRef--;\n  assert(pReal->nRef>=0);\n\n  /* When the ref-count reaches 0, destroy the structure */\n  if( pReal->nRef==0 ){\n    *pReal->ppThis = pReal->pNext;\n    if( pReal->pNext ){\n      pReal->pNext->ppThis = pReal->ppThis;\n    }\n    rc = pReal->pFile->pMethods->xClose(pReal->pFile);\n    sqlite3_free(pReal);\n  }\n\n  return rc;\n}\n\n/*\n** Read data from an fs-file.\n*/\nstatic int fsRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc = SQLITE_OK;\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n  sqlite3_file *pF = pReal->pFile;\n\n  if( (p->eType==DATABASE_FILE && (iAmt+iOfst)>pReal->nDatabase)\n   || (p->eType==JOURNAL_FILE && (iAmt+iOfst)>pReal->nJournal)\n  ){\n    rc = SQLITE_IOERR_SHORT_READ;\n  }else if( p->eType==DATABASE_FILE ){\n    rc = pF->pMethods->xRead(pF, zBuf, iAmt, iOfst+BLOCKSIZE);\n  }else{\n    /* Journal file. */\n    int iRem = iAmt;\n    int iBuf = 0;\n    int ii = (int)iOfst;\n    while( iRem>0 && rc==SQLITE_OK ){\n      int iRealOff = pReal->nBlob - BLOCKSIZE*((ii/BLOCKSIZE)+1) + ii%BLOCKSIZE;\n      int iRealAmt = MIN(iRem, BLOCKSIZE - (iRealOff%BLOCKSIZE));\n\n      rc = pF->pMethods->xRead(pF, &((char *)zBuf)[iBuf], iRealAmt, iRealOff);\n      ii += iRealAmt;\n      iBuf += iRealAmt;\n      iRem -= iRealAmt;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Write data to an fs-file.\n*/\nstatic int fsWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc = SQLITE_OK;\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n  sqlite3_file *pF = pReal->pFile;\n\n  if( p->eType==DATABASE_FILE ){\n    if( (iAmt+iOfst+BLOCKSIZE)>(pReal->nBlob-pReal->nJournal) ){\n      rc = SQLITE_FULL;\n    }else{\n      rc = pF->pMethods->xWrite(pF, zBuf, iAmt, iOfst+BLOCKSIZE);\n      if( rc==SQLITE_OK ){\n        pReal->nDatabase = (int)MAX(pReal->nDatabase, iAmt+iOfst);\n      }\n    }\n  }else{\n    /* Journal file. */\n    int iRem = iAmt;\n    int iBuf = 0;\n    int ii = (int)iOfst;\n    while( iRem>0 && rc==SQLITE_OK ){\n      int iRealOff = pReal->nBlob - BLOCKSIZE*((ii/BLOCKSIZE)+1) + ii%BLOCKSIZE;\n      int iRealAmt = MIN(iRem, BLOCKSIZE - (iRealOff%BLOCKSIZE));\n\n      if( iRealOff<(pReal->nDatabase+BLOCKSIZE) ){\n        rc = SQLITE_FULL;\n      }else{\n        rc = pF->pMethods->xWrite(pF, &((char *)zBuf)[iBuf], iRealAmt,iRealOff);\n        ii += iRealAmt;\n        iBuf += iRealAmt;\n        iRem -= iRealAmt;\n      }\n    }\n    if( rc==SQLITE_OK ){\n      pReal->nJournal = (int)MAX(pReal->nJournal, iAmt+iOfst);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Truncate an fs-file.\n*/\nstatic int fsTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n  if( p->eType==DATABASE_FILE ){\n    pReal->nDatabase = (int)MIN(pReal->nDatabase, size);\n  }else{\n    pReal->nJournal = (int)MIN(pReal->nJournal, size);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Sync an fs-file.\n*/\nstatic int fsSync(sqlite3_file *pFile, int flags){\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n  sqlite3_file *pRealFile = pReal->pFile;\n  int rc = SQLITE_OK;\n\n  if( p->eType==DATABASE_FILE ){\n    unsigned char zSize[4];\n    zSize[0] = (pReal->nDatabase&0xFF000000)>>24;\n    zSize[1] = (unsigned char)((pReal->nDatabase&0x00FF0000)>>16);\n    zSize[2] = (pReal->nDatabase&0x0000FF00)>>8;\n    zSize[3] = (pReal->nDatabase&0x000000FF);\n    rc = pRealFile->pMethods->xWrite(pRealFile, zSize, 4, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = pRealFile->pMethods->xSync(pRealFile, flags&(~SQLITE_SYNC_DATAONLY));\n  }\n\n  return rc;\n}\n\n/*\n** Return the current file-size of an fs-file.\n*/\nstatic int fsFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = p->pReal;\n  if( p->eType==DATABASE_FILE ){\n    *pSize = pReal->nDatabase;\n  }else{\n    *pSize = pReal->nJournal;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Lock an fs-file.\n*/\nstatic int fsLock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\n\n/*\n** Unlock an fs-file.\n*/\nstatic int fsUnlock(sqlite3_file *pFile, int eLock){\n  return SQLITE_OK;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an fs-file.\n*/\nstatic int fsCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  *pResOut = 0;\n  return SQLITE_OK;\n}\n\n/*\n** File control method. For custom operations on an fs-file.\n*/\nstatic int fsFileControl(sqlite3_file *pFile, int op, void *pArg){\n  return SQLITE_OK;\n}\n\n/*\n** Return the sector-size in bytes for an fs-file.\n*/\nstatic int fsSectorSize(sqlite3_file *pFile){\n  return BLOCKSIZE;\n}\n\n/*\n** Return the device characteristic flags supported by an fs-file.\n*/\nstatic int fsDeviceCharacteristics(sqlite3_file *pFile){\n  return 0;\n}\n\n/*\n** Open an fs file handle.\n*/\nstatic int fsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  fs_vfs_t *pFsVfs = (fs_vfs_t *)pVfs;\n  fs_file *p = (fs_file *)pFile;\n  fs_real_file *pReal = 0;\n  int eType;\n  int nName;\n  int rc = SQLITE_OK;\n\n  if( 0==(flags&(SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_MAIN_JOURNAL)) ){\n    tmp_file *p2 = (tmp_file *)pFile;\n    memset(p2, 0, sizeof(*p2));\n    p2->base.pMethods = &tmp_io_methods;\n    return SQLITE_OK;\n  }\n\n  eType = ((flags&(SQLITE_OPEN_MAIN_DB))?DATABASE_FILE:JOURNAL_FILE);\n  p->base.pMethods = &fs_io_methods;\n  p->eType = eType;\n\n  assert(strlen(\"-journal\")==8);\n  nName = (int)strlen(zName)-((eType==JOURNAL_FILE)?8:0);\n  pReal=pFsVfs->pFileList; \n  for(; pReal && strncmp(pReal->zName, zName, nName); pReal=pReal->pNext);\n\n  if( !pReal ){\n    int real_flags = (flags&~(SQLITE_OPEN_MAIN_DB))|SQLITE_OPEN_TEMP_DB;\n    sqlite3_int64 size;\n    sqlite3_file *pRealFile;\n    sqlite3_vfs *pParent = pFsVfs->pParent;\n    assert(eType==DATABASE_FILE);\n\n    pReal = (fs_real_file *)sqlite3_malloc(sizeof(*pReal)+pParent->szOsFile);\n    if( !pReal ){\n      rc = SQLITE_NOMEM;\n      goto open_out;\n    }\n    memset(pReal, 0, sizeof(*pReal)+pParent->szOsFile);\n    pReal->zName = zName;\n    pReal->pFile = (sqlite3_file *)(&pReal[1]);\n\n    rc = pParent->xOpen(pParent, zName, pReal->pFile, real_flags, pOutFlags);\n    if( rc!=SQLITE_OK ){\n      goto open_out;\n    }\n    pRealFile = pReal->pFile;\n\n    rc = pRealFile->pMethods->xFileSize(pRealFile, &size);\n    if( rc!=SQLITE_OK ){\n      goto open_out;\n    }\n    if( size==0 ){\n      rc = pRealFile->pMethods->xWrite(pRealFile, \"\\0\", 1, BLOBSIZE-1);\n      pReal->nBlob = BLOBSIZE;\n    }else{\n      unsigned char zS[4];\n      pReal->nBlob = (int)size;\n      rc = pRealFile->pMethods->xRead(pRealFile, zS, 4, 0);\n      pReal->nDatabase = (zS[0]<<24)+(zS[1]<<16)+(zS[2]<<8)+zS[3];\n      if( rc==SQLITE_OK ){\n        rc = pRealFile->pMethods->xRead(pRealFile, zS, 4, pReal->nBlob-4);\n        if( zS[0] || zS[1] || zS[2] || zS[3] ){\n          pReal->nJournal = pReal->nBlob;\n        }\n      }\n    }\n\n    if( rc==SQLITE_OK ){\n      pReal->pNext = pFsVfs->pFileList;\n      if( pReal->pNext ){\n        pReal->pNext->ppThis = &pReal->pNext;\n      }\n      pReal->ppThis = &pFsVfs->pFileList;\n      pFsVfs->pFileList = pReal;\n    }\n  }\n\nopen_out:\n  if( pReal ){\n    if( rc==SQLITE_OK ){\n      p->pReal = pReal;\n      pReal->nRef++;\n    }else{\n      if( pReal->pFile->pMethods ){\n        pReal->pFile->pMethods->xClose(pReal->pFile);\n      }\n      sqlite3_free(pReal);\n    }\n  }\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int fsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc = SQLITE_OK;\n  fs_vfs_t *pFsVfs = (fs_vfs_t *)pVfs;\n  fs_real_file *pReal;\n  sqlite3_file *pF;\n  int nName = (int)strlen(zPath) - 8;\n\n  assert(strlen(\"-journal\")==8);\n  assert(strcmp(\"-journal\", &zPath[nName])==0);\n\n  pReal = pFsVfs->pFileList; \n  for(; pReal && strncmp(pReal->zName, zPath, nName); pReal=pReal->pNext);\n  if( pReal ){\n    pF = pReal->pFile;\n    rc = pF->pMethods->xWrite(pF, \"\\0\\0\\0\\0\", 4, pReal->nBlob-BLOCKSIZE);\n    if( rc==SQLITE_OK ){\n      pReal->nJournal = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int fsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  fs_vfs_t *pFsVfs = (fs_vfs_t *)pVfs;\n  fs_real_file *pReal;\n  int isJournal = 0;\n  int nName = (int)strlen(zPath);\n\n  if( flags!=SQLITE_ACCESS_EXISTS ){\n    sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n    return pParent->xAccess(pParent, zPath, flags, pResOut);\n  }\n\n  assert(strlen(\"-journal\")==8);\n  if( nName>8 && strcmp(\"-journal\", &zPath[nName-8])==0 ){\n    nName -= 8;\n    isJournal = 1;\n  }\n\n  pReal = pFsVfs->pFileList; \n  for(; pReal && strncmp(pReal->zName, zPath, nName); pReal=pReal->pNext);\n\n  *pResOut = (pReal && (!isJournal || pReal->nJournal>0));\n  return SQLITE_OK;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (FS_MAX_PATHNAME+1) bytes.\n*/\nstatic int fsFullPathname(\n  sqlite3_vfs *pVfs,            /* Pointer to vfs object */\n  const char *zPath,            /* Possibly relative input path */\n  int nOut,                     /* Size of output buffer in bytes */\n  char *zOut                    /* Output buffer */\n){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xFullPathname(pParent, zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *fsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xDlOpen(pParent, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void fsDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  pParent->xDlError(pParent, nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*fsDlSym(sqlite3_vfs *pVfs, void *pH, const char *zSym))(void){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xDlSym(pParent, pH, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void fsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  pParent->xDlClose(pParent, pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int fsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xRandomness(pParent, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int fsSleep(sqlite3_vfs *pVfs, int nMicro){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xSleep(pParent, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int fsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  sqlite3_vfs *pParent = ((fs_vfs_t *)pVfs)->pParent;\n  return pParent->xCurrentTime(pParent, pTimeOut);\n}\n\n/*\n** This procedure registers the fs vfs with SQLite. If the argument is\n** true, the fs vfs becomes the new default vfs. It is the only publicly\n** available function in this file.\n*/\nint fs_register(void){\n  if( fs_vfs.pParent ) return SQLITE_OK;\n  fs_vfs.pParent = sqlite3_vfs_find(0);\n  fs_vfs.base.mxPathname = fs_vfs.pParent->mxPathname;\n  fs_vfs.base.szOsFile = MAX(sizeof(tmp_file), sizeof(fs_file));\n  return sqlite3_vfs_register(&fs_vfs.base, 0);\n}\n\n#ifdef SQLITE_TEST\n  int SqlitetestOnefile_Init() {return fs_register();}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_osinst.c",
    "content": "/*\n** 2008 April 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of an SQLite vfs wrapper that\n** adds instrumentation to all vfs and file methods. C and Tcl interfaces\n** are provided to control the instrumentation.\n*/\n\n/*\n** This module contains code for a wrapper VFS that causes a log of\n** most VFS calls to be written into a nominated file on disk. The log \n** is stored in a compressed binary format to reduce the amount of IO \n** overhead introduced into the application by logging.\n**\n** All calls on sqlite3_file objects except xFileControl() are logged.\n** Additionally, calls to the xAccess(), xOpen(), and xDelete()\n** methods are logged. The other sqlite3_vfs object methods (xDlXXX,\n** xRandomness, xSleep, xCurrentTime, xGetLastError and xCurrentTimeInt64) \n** are not logged.\n**\n** The binary log files are read using a virtual table implementation\n** also contained in this file. \n**\n** CREATING LOG FILES:\n**\n**       int sqlite3_vfslog_new(\n**         const char *zVfs,          // Name of new VFS\n**         const char *zParentVfs,    // Name of parent VFS (or NULL)\n**         const char *zLog           // Name of log file to write to\n**       );\n**\n**       int sqlite3_vfslog_finalize(const char *zVfs);\n**\n** ANNOTATING LOG FILES:\n**\n**   To write an arbitrary message into a log file:\n**\n**       int sqlite3_vfslog_annotate(const char *zVfs, const char *zMsg);\n**\n** READING LOG FILES:\n**\n**   Log files are read using the \"vfslog\" virtual table implementation\n**   in this file. To register the virtual table with SQLite, use:\n**\n**       int sqlite3_vfslog_register(sqlite3 *db);\n**\n**   Then, if the log file is named \"vfs.log\", the following SQL command:\n**\n**       CREATE VIRTUAL TABLE v USING vfslog('vfs.log');\n**\n**   creates a virtual table with 6 columns, as follows:\n**\n**       CREATE TABLE v(\n**         event    TEXT,             // \"xOpen\", \"xRead\" etc.\n**         file     TEXT,             // Name of file this call applies to\n**         clicks   INTEGER,          // Time spent in call\n**         rc       INTEGER,          // Return value\n**         size     INTEGER,          // Bytes read or written\n**         offset   INTEGER           // File offset read or written\n**       );\n*/\n\n#include \"sqlite3.h\"\n\n#include \"os_setup.h\"\n#if SQLITE_OS_WIN\n#  include \"os_win.h\"\n#endif\n\n#include <string.h>\n#include <assert.h>\n\n\n/*\n** Maximum pathname length supported by the vfslog backend.\n*/\n#define INST_MAX_PATHNAME 512\n\n#define OS_ACCESS            1\n#define OS_CHECKRESERVEDLOCK 2\n#define OS_CLOSE             3\n#define OS_CURRENTTIME       4\n#define OS_DELETE            5\n#define OS_DEVCHAR           6\n#define OS_FILECONTROL       7\n#define OS_FILESIZE          8\n#define OS_FULLPATHNAME      9\n#define OS_LOCK              11\n#define OS_OPEN              12\n#define OS_RANDOMNESS        13\n#define OS_READ              14 \n#define OS_SECTORSIZE        15\n#define OS_SLEEP             16\n#define OS_SYNC              17\n#define OS_TRUNCATE          18\n#define OS_UNLOCK            19\n#define OS_WRITE             20\n#define OS_SHMUNMAP          22\n#define OS_SHMMAP            23\n#define OS_SHMLOCK           25\n#define OS_SHMBARRIER        26\n#define OS_ANNOTATE          28\n\n#define OS_NUMEVENTS         29\n\n#define VFSLOG_BUFFERSIZE 8192\n\ntypedef struct VfslogVfs VfslogVfs;\ntypedef struct VfslogFile VfslogFile;\n\nstruct VfslogVfs {\n  sqlite3_vfs base;               /* VFS methods */\n  sqlite3_vfs *pVfs;              /* Parent VFS */\n  int iNextFileId;                /* Next file id */\n  sqlite3_file *pLog;             /* Log file handle */\n  sqlite3_int64 iOffset;          /* Log file offset of start of write buffer */\n  int nBuf;                       /* Number of valid bytes in aBuf[] */\n  char aBuf[VFSLOG_BUFFERSIZE];   /* Write buffer */\n};\n\nstruct VfslogFile {\n  sqlite3_file base;              /* IO methods */\n  sqlite3_file *pReal;            /* Underlying file handle */\n  sqlite3_vfs *pVfslog;           /* Associated VsflogVfs object */\n  int iFileId;                    /* File id number */\n};\n\n#define REALVFS(p) (((VfslogVfs *)(p))->pVfs)\n\n\n\n/*\n** Method declarations for vfslog_file.\n*/\nstatic int vfslogClose(sqlite3_file*);\nstatic int vfslogRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int vfslogWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int vfslogTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int vfslogSync(sqlite3_file*, int flags);\nstatic int vfslogFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int vfslogLock(sqlite3_file*, int);\nstatic int vfslogUnlock(sqlite3_file*, int);\nstatic int vfslogCheckReservedLock(sqlite3_file*, int *pResOut);\nstatic int vfslogFileControl(sqlite3_file*, int op, void *pArg);\nstatic int vfslogSectorSize(sqlite3_file*);\nstatic int vfslogDeviceCharacteristics(sqlite3_file*);\n\nstatic int vfslogShmLock(sqlite3_file *pFile, int ofst, int n, int flags);\nstatic int vfslogShmMap(sqlite3_file *pFile,int,int,int,volatile void **);\nstatic void vfslogShmBarrier(sqlite3_file*);\nstatic int vfslogShmUnmap(sqlite3_file *pFile, int deleteFlag);\n\n/*\n** Method declarations for vfslog_vfs.\n*/\nstatic int vfslogOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int vfslogDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int vfslogAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int vfslogFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\nstatic void *vfslogDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void vfslogDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*vfslogDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void);\nstatic void vfslogDlClose(sqlite3_vfs*, void*);\nstatic int vfslogRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int vfslogSleep(sqlite3_vfs*, int microseconds);\nstatic int vfslogCurrentTime(sqlite3_vfs*, double*);\n\nstatic int vfslogGetLastError(sqlite3_vfs*, int, char *);\nstatic int vfslogCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\n\nstatic sqlite3_vfs vfslog_vfs = {\n  1,                              /* iVersion */\n  sizeof(VfslogFile),             /* szOsFile */\n  INST_MAX_PATHNAME,              /* mxPathname */\n  0,                              /* pNext */\n  0,                              /* zName */\n  0,                              /* pAppData */\n  vfslogOpen,                     /* xOpen */\n  vfslogDelete,                   /* xDelete */\n  vfslogAccess,                   /* xAccess */\n  vfslogFullPathname,             /* xFullPathname */\n  vfslogDlOpen,                   /* xDlOpen */\n  vfslogDlError,                  /* xDlError */\n  vfslogDlSym,                    /* xDlSym */\n  vfslogDlClose,                  /* xDlClose */\n  vfslogRandomness,               /* xRandomness */\n  vfslogSleep,                    /* xSleep */\n  vfslogCurrentTime,              /* xCurrentTime */\n  vfslogGetLastError,             /* xGetLastError */\n  vfslogCurrentTimeInt64          /* xCurrentTime */\n};\n\nstatic sqlite3_io_methods vfslog_io_methods = {\n  2,                              /* iVersion */\n  vfslogClose,                    /* xClose */\n  vfslogRead,                     /* xRead */\n  vfslogWrite,                    /* xWrite */\n  vfslogTruncate,                 /* xTruncate */\n  vfslogSync,                     /* xSync */\n  vfslogFileSize,                 /* xFileSize */\n  vfslogLock,                     /* xLock */\n  vfslogUnlock,                   /* xUnlock */\n  vfslogCheckReservedLock,        /* xCheckReservedLock */\n  vfslogFileControl,              /* xFileControl */\n  vfslogSectorSize,               /* xSectorSize */\n  vfslogDeviceCharacteristics,    /* xDeviceCharacteristics */\n  vfslogShmMap,                   /* xShmMap */\n  vfslogShmLock,                  /* xShmLock */\n  vfslogShmBarrier,               /* xShmBarrier */\n  vfslogShmUnmap                  /* xShmUnmap */\n};\n\n#if SQLITE_OS_UNIX && !defined(NO_GETTOD)\n#include <sys/time.h>\nstatic sqlite3_uint64 vfslog_time(){\n  struct timeval sTime;\n  gettimeofday(&sTime, 0);\n  return sTime.tv_usec + (sqlite3_uint64)sTime.tv_sec * 1000000;\n}\n#elif SQLITE_OS_WIN\n#include <time.h>\nstatic sqlite3_uint64 vfslog_time(){\n  FILETIME ft;\n  sqlite3_uint64 u64time = 0;\n \n  GetSystemTimeAsFileTime(&ft);\n\n  u64time |= ft.dwHighDateTime;\n  u64time <<= 32;\n  u64time |= ft.dwLowDateTime;\n\n  /* ft is 100-nanosecond intervals, we want microseconds */\n  return u64time /(sqlite3_uint64)10;\n}\n#else\nstatic sqlite3_uint64 vfslog_time(){\n  return 0;\n}\n#endif\n\nstatic void vfslog_call(sqlite3_vfs *, int, int, sqlite3_int64, int, int, int);\nstatic void vfslog_string(sqlite3_vfs *, const char *);\n\n/*\n** Close an vfslog-file.\n*/\nstatic int vfslogClose(sqlite3_file *pFile){\n  sqlite3_uint64 t;\n  int rc = SQLITE_OK;\n  VfslogFile *p = (VfslogFile *)pFile;\n\n  t = vfslog_time();\n  if( p->pReal->pMethods ){\n    rc = p->pReal->pMethods->xClose(p->pReal);\n  }\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_CLOSE, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\n\n/*\n** Read data from an vfslog-file.\n*/\nstatic int vfslogRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_READ, p->iFileId, t, rc, iAmt, (int)iOfst);\n  return rc;\n}\n\n/*\n** Write data to an vfslog-file.\n*/\nstatic int vfslogWrite(\n  sqlite3_file *pFile,\n  const void *z,\n  int iAmt,\n  sqlite_int64 iOfst\n){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_WRITE, p->iFileId, t, rc, iAmt, (int)iOfst);\n  return rc;\n}\n\n/*\n** Truncate an vfslog-file.\n*/\nstatic int vfslogTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xTruncate(p->pReal, size);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_TRUNCATE, p->iFileId, t, rc, 0, (int)size);\n  return rc;\n}\n\n/*\n** Sync an vfslog-file.\n*/\nstatic int vfslogSync(sqlite3_file *pFile, int flags){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xSync(p->pReal, flags);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SYNC, p->iFileId, t, rc, flags, 0);\n  return rc;\n}\n\n/*\n** Return the current file-size of an vfslog-file.\n*/\nstatic int vfslogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_FILESIZE, p->iFileId, t, rc, 0, (int)*pSize);\n  return rc;\n}\n\n/*\n** Lock an vfslog-file.\n*/\nstatic int vfslogLock(sqlite3_file *pFile, int eLock){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_LOCK, p->iFileId, t, rc, eLock, 0);\n  return rc;\n}\n\n/*\n** Unlock an vfslog-file.\n*/\nstatic int vfslogUnlock(sqlite3_file *pFile, int eLock){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_UNLOCK, p->iFileId, t, rc, eLock, 0);\n  return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an vfslog-file.\n*/\nstatic int vfslogCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_CHECKRESERVEDLOCK, p->iFileId, t, rc, *pResOut, 0);\n  return rc;\n}\n\n/*\n** File control method. For custom operations on an vfslog-file.\n*/\nstatic int vfslogFileControl(sqlite3_file *pFile, int op, void *pArg){\n  VfslogFile *p = (VfslogFile *)pFile;\n  int rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n  if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n    *(char**)pArg = sqlite3_mprintf(\"vfslog/%z\", *(char**)pArg);\n  }\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an vfslog-file.\n*/\nstatic int vfslogSectorSize(sqlite3_file *pFile){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xSectorSize(p->pReal);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SECTORSIZE, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\n\n/*\n** Return the device characteristic flags supported by an vfslog-file.\n*/\nstatic int vfslogDeviceCharacteristics(sqlite3_file *pFile){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_DEVCHAR, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\n\nstatic int vfslogShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SHMLOCK, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\nstatic int vfslogShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  volatile void **pp\n){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SHMMAP, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\nstatic void vfslogShmBarrier(sqlite3_file *pFile){\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SHMBARRIER, p->iFileId, t, SQLITE_OK, 0, 0);\n}\nstatic int vfslogShmUnmap(sqlite3_file *pFile, int deleteFlag){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  t = vfslog_time();\n  rc = p->pReal->pMethods->xShmUnmap(p->pReal, deleteFlag);\n  t = vfslog_time() - t;\n  vfslog_call(p->pVfslog, OS_SHMUNMAP, p->iFileId, t, rc, 0, 0);\n  return rc;\n}\n\n\n/*\n** Open an vfslog file handle.\n*/\nstatic int vfslogOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  sqlite3_uint64 t;\n  VfslogFile *p = (VfslogFile *)pFile;\n  VfslogVfs *pLog = (VfslogVfs *)pVfs;\n\n  pFile->pMethods = &vfslog_io_methods;\n  p->pReal = (sqlite3_file *)&p[1];\n  p->pVfslog = pVfs;\n  p->iFileId = ++pLog->iNextFileId;\n\n  t = vfslog_time();\n  rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags);\n  t = vfslog_time() - t;\n\n  vfslog_call(pVfs, OS_OPEN, p->iFileId, t, rc, 0, 0);\n  vfslog_string(pVfs, zName);\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int vfslogDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc;\n  sqlite3_uint64 t;\n  t = vfslog_time();\n  rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync);\n  t = vfslog_time() - t;\n  vfslog_call(pVfs, OS_DELETE, 0, t, rc, dirSync, 0);\n  vfslog_string(pVfs, zPath);\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int vfslogAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  int rc;\n  sqlite3_uint64 t;\n  t = vfslog_time();\n  rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut);\n  t = vfslog_time() - t;\n  vfslog_call(pVfs, OS_ACCESS, 0, t, rc, flags, *pResOut);\n  vfslog_string(pVfs, zPath);\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (INST_MAX_PATHNAME+1) bytes.\n*/\nstatic int vfslogFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut);\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *vfslogDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void vfslogDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*vfslogDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void vfslogDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int vfslogRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int vfslogSleep(sqlite3_vfs *pVfs, int nMicro){\n  return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int vfslogCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut);\n}\n\nstatic int vfslogGetLastError(sqlite3_vfs *pVfs, int a, char *b){\n  return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b);\n}\nstatic int vfslogCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){\n  return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p);\n}\n\nstatic void vfslog_flush(VfslogVfs *p){\n#ifdef SQLITE_TEST\n  extern int sqlite3_io_error_pending;\n  extern int sqlite3_io_error_persist;\n  extern int sqlite3_diskfull_pending;\n\n  int pending = sqlite3_io_error_pending;\n  int persist = sqlite3_io_error_persist;\n  int diskfull = sqlite3_diskfull_pending;\n\n  sqlite3_io_error_pending = 0;\n  sqlite3_io_error_persist = 0;\n  sqlite3_diskfull_pending = 0;\n#endif\n\n  if( p->nBuf ){\n    p->pLog->pMethods->xWrite(p->pLog, p->aBuf, p->nBuf, p->iOffset);\n    p->iOffset += p->nBuf;\n    p->nBuf = 0;\n  }\n\n#ifdef SQLITE_TEST\n  sqlite3_io_error_pending = pending;\n  sqlite3_io_error_persist = persist;\n  sqlite3_diskfull_pending = diskfull;\n#endif\n}\n\nstatic void put32bits(unsigned char *p, unsigned int v){\n  p[0] = v>>24;\n  p[1] = (unsigned char)(v>>16);\n  p[2] = (unsigned char)(v>>8);\n  p[3] = (unsigned char)v;\n}\n\nstatic void vfslog_call(\n  sqlite3_vfs *pVfs,\n  int eEvent,\n  int iFileid,\n  sqlite3_int64 nClick,\n  int return_code,\n  int size,\n  int offset\n){\n  VfslogVfs *p = (VfslogVfs *)pVfs;\n  unsigned char *zRec;\n  if( (24+p->nBuf)>sizeof(p->aBuf) ){\n    vfslog_flush(p);\n  }\n  zRec = (unsigned char *)&p->aBuf[p->nBuf];\n  put32bits(&zRec[0], eEvent);\n  put32bits(&zRec[4], iFileid);\n  put32bits(&zRec[8], (unsigned int)(nClick&0xffff));\n  put32bits(&zRec[12], return_code);\n  put32bits(&zRec[16], size);\n  put32bits(&zRec[20], offset);\n  p->nBuf += 24;\n}\n\nstatic void vfslog_string(sqlite3_vfs *pVfs, const char *zStr){\n  VfslogVfs *p = (VfslogVfs *)pVfs;\n  unsigned char *zRec;\n  int nStr = zStr ? (int)strlen(zStr) : 0;\n  if( (4+nStr+p->nBuf)>sizeof(p->aBuf) ){\n    vfslog_flush(p);\n  }\n  zRec = (unsigned char *)&p->aBuf[p->nBuf];\n  put32bits(&zRec[0], nStr);\n  if( zStr ){\n    memcpy(&zRec[4], zStr, nStr);\n  }\n  p->nBuf += (4 + nStr);\n}\n\nstatic void vfslog_finalize(VfslogVfs *p){\n  if( p->pLog->pMethods ){\n    vfslog_flush(p);\n    p->pLog->pMethods->xClose(p->pLog);\n  }\n  sqlite3_free(p);\n}\n\nint sqlite3_vfslog_finalize(const char *zVfs){\n  sqlite3_vfs *pVfs;\n  pVfs = sqlite3_vfs_find(zVfs);\n  if( !pVfs || pVfs->xOpen!=vfslogOpen ){\n    return SQLITE_ERROR;\n  } \n  sqlite3_vfs_unregister(pVfs);\n  vfslog_finalize((VfslogVfs *)pVfs);\n  return SQLITE_OK;\n}\n\nint sqlite3_vfslog_new(\n  const char *zVfs,               /* New VFS name */\n  const char *zParentVfs,         /* Parent VFS name (or NULL) */\n  const char *zLog                /* Log file name */\n){\n  VfslogVfs *p;\n  sqlite3_vfs *pParent;\n  int nByte;\n  int flags;\n  int rc;\n  char *zFile;\n  int nVfs;\n\n  pParent = sqlite3_vfs_find(zParentVfs);\n  if( !pParent ){\n    return SQLITE_ERROR;\n  }\n\n  nVfs = (int)strlen(zVfs);\n  nByte = sizeof(VfslogVfs) + pParent->szOsFile + nVfs+1+pParent->mxPathname+1;\n  p = (VfslogVfs *)sqlite3_malloc(nByte);\n  memset(p, 0, nByte);\n\n  p->pVfs = pParent;\n  p->pLog = (sqlite3_file *)&p[1];\n  memcpy(&p->base, &vfslog_vfs, sizeof(sqlite3_vfs));\n  p->base.zName = &((char *)p->pLog)[pParent->szOsFile];\n  p->base.szOsFile += pParent->szOsFile;\n  memcpy((char *)p->base.zName, zVfs, nVfs);\n\n  zFile = (char *)&p->base.zName[nVfs+1];\n  pParent->xFullPathname(pParent, zLog, pParent->mxPathname, zFile);\n\n  flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MASTER_JOURNAL;\n  pParent->xDelete(pParent, zFile, 0);\n  rc = pParent->xOpen(pParent, zFile, p->pLog, flags, &flags);\n  if( rc==SQLITE_OK ){\n    memcpy(p->aBuf, \"sqlite_ostrace1.....\", 20);\n    p->iOffset = 0;\n    p->nBuf = 20;\n    rc = sqlite3_vfs_register((sqlite3_vfs *)p, 1);\n  }\n  if( rc ){\n    vfslog_finalize(p);\n  }\n  return rc;\n}\n\nint sqlite3_vfslog_annotate(const char *zVfs, const char *zMsg){\n  sqlite3_vfs *pVfs;\n  pVfs = sqlite3_vfs_find(zVfs);\n  if( !pVfs || pVfs->xOpen!=vfslogOpen ){\n    return SQLITE_ERROR;\n  } \n  vfslog_call(pVfs, OS_ANNOTATE, 0, 0, 0, 0, 0);\n  vfslog_string(pVfs, zMsg);\n  return SQLITE_OK;\n}\n\nstatic const char *vfslog_eventname(int eEvent){\n  const char *zEvent = 0;\n\n  switch( eEvent ){\n    case OS_CLOSE:             zEvent = \"xClose\"; break;\n    case OS_READ:              zEvent = \"xRead\"; break;\n    case OS_WRITE:             zEvent = \"xWrite\"; break;\n    case OS_TRUNCATE:          zEvent = \"xTruncate\"; break;\n    case OS_SYNC:              zEvent = \"xSync\"; break;\n    case OS_FILESIZE:          zEvent = \"xFilesize\"; break;\n    case OS_LOCK:              zEvent = \"xLock\"; break;\n    case OS_UNLOCK:            zEvent = \"xUnlock\"; break;\n    case OS_CHECKRESERVEDLOCK: zEvent = \"xCheckResLock\"; break;\n    case OS_FILECONTROL:       zEvent = \"xFileControl\"; break;\n    case OS_SECTORSIZE:        zEvent = \"xSectorSize\"; break;\n    case OS_DEVCHAR:           zEvent = \"xDeviceChar\"; break;\n    case OS_OPEN:              zEvent = \"xOpen\"; break;\n    case OS_DELETE:            zEvent = \"xDelete\"; break;\n    case OS_ACCESS:            zEvent = \"xAccess\"; break;\n    case OS_FULLPATHNAME:      zEvent = \"xFullPathname\"; break;\n    case OS_RANDOMNESS:        zEvent = \"xRandomness\"; break;\n    case OS_SLEEP:             zEvent = \"xSleep\"; break;\n    case OS_CURRENTTIME:       zEvent = \"xCurrentTime\"; break;\n\n    case OS_SHMUNMAP:          zEvent = \"xShmUnmap\"; break;\n    case OS_SHMLOCK:           zEvent = \"xShmLock\"; break;\n    case OS_SHMBARRIER:        zEvent = \"xShmBarrier\"; break;\n    case OS_SHMMAP:            zEvent = \"xShmMap\"; break;\n\n    case OS_ANNOTATE:          zEvent = \"annotation\"; break;\n  }\n\n  return zEvent;\n}\n\ntypedef struct VfslogVtab VfslogVtab;\ntypedef struct VfslogCsr VfslogCsr;\n\n/*\n** Virtual table type for the vfslog reader module.\n*/\nstruct VfslogVtab {\n  sqlite3_vtab base;              /* Base class */\n  sqlite3_file *pFd;              /* File descriptor open on vfslog file */\n  sqlite3_int64 nByte;            /* Size of file in bytes */\n  char *zFile;                    /* File name for pFd */\n};\n\n/*\n** Virtual table cursor type for the vfslog reader module.\n*/\nstruct VfslogCsr {\n  sqlite3_vtab_cursor base;       /* Base class */\n  sqlite3_int64 iRowid;           /* Current rowid. */\n  sqlite3_int64 iOffset;          /* Offset of next record in file */\n  char *zTransient;               /* Transient 'file' string */\n  int nFile;                      /* Size of array azFile[] */\n  char **azFile;                  /* File strings */\n  unsigned char aBuf[1024];       /* Current vfs log entry (read from file) */\n};\n\nstatic unsigned int get32bits(unsigned char *p){\n  return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3];\n}\n\n/*\n** The argument must point to a buffer containing a nul-terminated string.\n** If the string begins with an SQL quote character it is overwritten by\n** the dequoted version. Otherwise the buffer is left unmodified.\n*/\nstatic void dequote(char *z){\n  char quote;                     /* Quote character (if any ) */\n  quote = z[0];\n  if( quote=='[' || quote=='\\'' || quote=='\"' || quote=='`' ){\n    int iIn = 1;                  /* Index of next byte to read from input */\n    int iOut = 0;                 /* Index of next byte to write to output */\n    if( quote=='[' ) quote = ']';  \n    while( z[iIn] ){\n      if( z[iIn]==quote ){\n        if( z[iIn+1]!=quote ) break;\n        z[iOut++] = quote;\n        iIn += 2;\n      }else{\n        z[iOut++] = z[iIn++];\n      }\n    }\n    z[iOut] = '\\0';\n  }\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Connect to or create a vfslog virtual table.\n*/\nstatic int vlogConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  sqlite3_vfs *pVfs;              /* VFS used to read log file */\n  int flags;                      /* flags passed to pVfs->xOpen() */\n  VfslogVtab *p;\n  int rc;\n  int nByte;\n  char *zFile;\n\n  *ppVtab = 0;\n  pVfs = sqlite3_vfs_find(0);\n  nByte = sizeof(VfslogVtab) + pVfs->szOsFile + pVfs->mxPathname;\n  p = sqlite3_malloc(nByte);\n  if( p==0 ) return SQLITE_NOMEM;\n  memset(p, 0, nByte);\n\n  p->pFd = (sqlite3_file *)&p[1];\n  p->zFile = &((char *)p->pFd)[pVfs->szOsFile];\n\n  zFile = sqlite3_mprintf(\"%s\", argv[3]);\n  if( !zFile ){\n    sqlite3_free(p);\n    return SQLITE_NOMEM;\n  }\n  dequote(zFile);\n  pVfs->xFullPathname(pVfs, zFile, pVfs->mxPathname, p->zFile);\n  sqlite3_free(zFile);\n\n  flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_MASTER_JOURNAL;\n  rc = pVfs->xOpen(pVfs, p->zFile, p->pFd, flags, &flags);\n\n  if( rc==SQLITE_OK ){\n    p->pFd->pMethods->xFileSize(p->pFd, &p->nByte);\n    sqlite3_declare_vtab(db, \n        \"CREATE TABLE xxx(event, file, click, rc, size, offset)\"\n    );\n    *ppVtab = &p->base;\n  }else{\n    sqlite3_free(p);\n  }\n\n  return rc;\n}\n\n/*\n** There is no \"best-index\". This virtual table always does a linear\n** scan of the binary VFS log file.\n*/\nstatic int vlogBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  pIdxInfo->estimatedCost = 10.0;\n  return SQLITE_OK;\n}\n\n/*\n** Disconnect from or destroy a vfslog virtual table.\n*/\nstatic int vlogDisconnect(sqlite3_vtab *pVtab){\n  VfslogVtab *p = (VfslogVtab *)pVtab;\n  if( p->pFd->pMethods ){\n    p->pFd->pMethods->xClose(p->pFd);\n    p->pFd->pMethods = 0;\n  }\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Open a new vfslog cursor.\n*/\nstatic int vlogOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  VfslogCsr *pCsr;                /* Newly allocated cursor object */\n\n  pCsr = sqlite3_malloc(sizeof(VfslogCsr));\n  if( !pCsr ) return SQLITE_NOMEM;\n  memset(pCsr, 0, sizeof(VfslogCsr));\n  *ppCursor = &pCsr->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a vfslog cursor.\n*/\nstatic int vlogClose(sqlite3_vtab_cursor *pCursor){\n  VfslogCsr *p = (VfslogCsr *)pCursor;\n  int i;\n  for(i=0; i<p->nFile; i++){\n    sqlite3_free(p->azFile[i]);\n  }\n  sqlite3_free(p->azFile);\n  sqlite3_free(p->zTransient);\n  sqlite3_free(p);\n  return SQLITE_OK;\n}\n\n/*\n** Move a vfslog cursor to the next entry in the file.\n*/\nstatic int vlogNext(sqlite3_vtab_cursor *pCursor){\n  VfslogCsr *pCsr = (VfslogCsr *)pCursor;\n  VfslogVtab *p = (VfslogVtab *)pCursor->pVtab;\n  int rc = SQLITE_OK;\n  int nRead;\n\n  sqlite3_free(pCsr->zTransient);\n  pCsr->zTransient = 0;\n\n  nRead = 24;\n  if( pCsr->iOffset+nRead<=p->nByte ){\n    int eEvent;\n    rc = p->pFd->pMethods->xRead(p->pFd, pCsr->aBuf, nRead, pCsr->iOffset);\n\n    eEvent = get32bits(pCsr->aBuf);\n    if( (rc==SQLITE_OK)\n     && (eEvent==OS_OPEN || eEvent==OS_DELETE || eEvent==OS_ACCESS) \n    ){\n      char buf[4];\n      rc = p->pFd->pMethods->xRead(p->pFd, buf, 4, pCsr->iOffset+nRead);\n      nRead += 4;\n      if( rc==SQLITE_OK ){\n        int nStr = get32bits((unsigned char *)buf);\n        char *zStr = sqlite3_malloc(nStr+1);\n        rc = p->pFd->pMethods->xRead(p->pFd, zStr, nStr, pCsr->iOffset+nRead);\n        zStr[nStr] = '\\0';\n        nRead += nStr;\n\n        if( eEvent==OS_OPEN ){\n          int iFileid = get32bits(&pCsr->aBuf[4]);\n          if( iFileid>=pCsr->nFile ){\n            int nNew = sizeof(pCsr->azFile[0])*(iFileid+1);\n            pCsr->azFile = (char **)sqlite3_realloc(pCsr->azFile, nNew);\n            nNew -= sizeof(pCsr->azFile[0])*pCsr->nFile;\n            memset(&pCsr->azFile[pCsr->nFile], 0, nNew);\n            pCsr->nFile = iFileid+1;\n          }\n          sqlite3_free(pCsr->azFile[iFileid]);\n          pCsr->azFile[iFileid] = zStr;\n        }else{\n          pCsr->zTransient = zStr;\n        }\n      }\n    }\n  }\n\n  pCsr->iRowid += 1;\n  pCsr->iOffset += nRead;\n  return rc;\n}\n\nstatic int vlogEof(sqlite3_vtab_cursor *pCursor){\n  VfslogCsr *pCsr = (VfslogCsr *)pCursor;\n  VfslogVtab *p = (VfslogVtab *)pCursor->pVtab;\n  return (pCsr->iOffset>=p->nByte);\n}\n\nstatic int vlogFilter(\n  sqlite3_vtab_cursor *pCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  VfslogCsr *pCsr = (VfslogCsr *)pCursor;\n  pCsr->iRowid = 0;\n  pCsr->iOffset = 20;\n  return vlogNext(pCursor);\n}\n\nstatic int vlogColumn(\n  sqlite3_vtab_cursor *pCursor, \n  sqlite3_context *ctx, \n  int i\n){\n  unsigned int val;\n  VfslogCsr *pCsr = (VfslogCsr *)pCursor;\n\n  assert( i<7 );\n  val = get32bits(&pCsr->aBuf[4*i]);\n\n  switch( i ){\n    case 0: {\n      sqlite3_result_text(ctx, vfslog_eventname(val), -1, SQLITE_STATIC);\n      break;\n    }\n    case 1: {\n      char *zStr = pCsr->zTransient;\n      if( val!=0 && val<(unsigned)pCsr->nFile ){\n        zStr = pCsr->azFile[val];\n      }\n      sqlite3_result_text(ctx, zStr, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    default:\n      sqlite3_result_int(ctx, val);\n      break;\n  }\n\n  return SQLITE_OK;\n}\n\nstatic int vlogRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){\n  VfslogCsr *pCsr = (VfslogCsr *)pCursor;\n  *pRowid = pCsr->iRowid;\n  return SQLITE_OK;\n}\n\nint sqlite3_vfslog_register(sqlite3 *db){\n  static sqlite3_module vfslog_module = {\n    0,                            /* iVersion */\n    vlogConnect,                /* xCreate */\n    vlogConnect,                /* xConnect */\n    vlogBestIndex,              /* xBestIndex */\n    vlogDisconnect,             /* xDisconnect */\n    vlogDisconnect,             /* xDestroy */\n    vlogOpen,                   /* xOpen - open a cursor */\n    vlogClose,                  /* xClose - close a cursor */\n    vlogFilter,                 /* xFilter - configure scan constraints */\n    vlogNext,                   /* xNext - advance a cursor */\n    vlogEof,                    /* xEof - check for end of scan */\n    vlogColumn,                 /* xColumn - read data */\n    vlogRowid,                  /* xRowid - read data */\n    0,                            /* xUpdate */\n    0,                            /* xBegin */\n    0,                            /* xSync */\n    0,                            /* xCommit */\n    0,                            /* xRollback */\n    0,                            /* xFindMethod */\n    0,                            /* xRename */\n  };\n\n  sqlite3_create_module(db, \"vfslog\", &vfslog_module, 0);\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/**************************************************************************\n***************************************************************************\n** Tcl interface starts here.\n*/\n\n#if defined(SQLITE_TEST) || defined(TCLSH)\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\nstatic int SQLITE_TCLAPI test_vfslog(\n  void *clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct SqliteDb { sqlite3 *db; };\n  sqlite3 *db;\n  Tcl_CmdInfo cmdInfo;\n  int rc = SQLITE_ERROR;\n\n  static const char *strs[] = { \"annotate\", \"finalize\", \"new\",  \"register\", 0 };\n  enum VL_enum { VL_ANNOTATE, VL_FINALIZE, VL_NEW, VL_REGISTER };\n  int iSub;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUB-COMMAND ...\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIndexFromObj(interp, objv[1], strs, \"sub-command\", 0, &iSub) ){\n    return TCL_ERROR;\n  }\n\n  switch( (enum VL_enum)iSub ){\n    case VL_ANNOTATE: {\n      char *zVfs;\n      char *zMsg;\n      if( objc!=4 ){\n        Tcl_WrongNumArgs(interp, 3, objv, \"VFS\");\n        return TCL_ERROR;\n      }\n      zVfs = Tcl_GetString(objv[2]);\n      zMsg = Tcl_GetString(objv[3]);\n      rc = sqlite3_vfslog_annotate(zVfs, zMsg);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, \"failed\", 0);\n        return TCL_ERROR;\n      }\n      break;\n    }\n    case VL_FINALIZE: {\n      char *zVfs;\n      if( objc!=3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"VFS\");\n        return TCL_ERROR;\n      }\n      zVfs = Tcl_GetString(objv[2]);\n      rc = sqlite3_vfslog_finalize(zVfs);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, \"failed\", 0);\n        return TCL_ERROR;\n      }\n      break;\n    };\n\n    case VL_NEW: {\n      char *zVfs;\n      char *zParent;\n      char *zLog;\n      if( objc!=5 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"VFS PARENT LOGFILE\");\n        return TCL_ERROR;\n      }\n      zVfs = Tcl_GetString(objv[2]);\n      zParent = Tcl_GetString(objv[3]);\n      zLog = Tcl_GetString(objv[4]);\n      if( *zParent=='\\0' ) zParent = 0;\n      rc = sqlite3_vfslog_new(zVfs, zParent, zLog);\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, \"failed\", 0);\n        return TCL_ERROR;\n      }\n      break;\n    };\n\n    case VL_REGISTER: {\n      char *zDb;\n      if( objc!=3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"DB\");\n        return TCL_ERROR;\n      }\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n      Tcl_AppendResult(interp, \"vfslog not available because of \"\n                               \"SQLITE_OMIT_VIRTUALTABLE\", (void*)0);\n      return TCL_ERROR;\n#else\n      zDb = Tcl_GetString(objv[2]);\n      if( Tcl_GetCommandInfo(interp, zDb, &cmdInfo) ){\n        db = ((struct SqliteDb*)cmdInfo.objClientData)->db;\n        rc = sqlite3_vfslog_register(db);\n      }\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, \"bad sqlite3 handle: \", zDb, (void*)0);\n        return TCL_ERROR;\n      }\n      break;\n#endif\n    }\n  }\n\n  return TCL_OK;\n}\n\nint SqlitetestOsinst_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"vfslog\", test_vfslog, 0, 0);\n  return TCL_OK;\n}\n\n#endif /* SQLITE_TEST */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_pcache.c",
    "content": "/*\n** 2008 November 18\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** \n** This file contains code used for testing the SQLite system.\n** None of the code in this file goes into a deliverable build.\n** \n** This file contains an application-defined pager cache\n** implementation that can be plugged in in place of the\n** default pcache.  This alternative pager cache will throw\n** some errors that the default cache does not.\n**\n** This pagecache implementation is designed for simplicity\n** not speed.  \n*/\n#include \"sqlite3.h\"\n#include <string.h>\n#include <assert.h>\n\n/*\n** Global data used by this test implementation.  There is no\n** mutexing, which means this page cache will not work in a\n** multi-threaded test.\n*/\ntypedef struct testpcacheGlobalType testpcacheGlobalType;\nstruct testpcacheGlobalType {\n  void *pDummy;             /* Dummy allocation to simulate failures */\n  int nInstance;            /* Number of current instances */\n  unsigned discardChance;   /* Chance of discarding on an unpin (0-100) */\n  unsigned prngSeed;        /* Seed for the PRNG */\n  unsigned highStress;      /* Call xStress agressively */\n};\nstatic testpcacheGlobalType testpcacheGlobal;\n\n/*\n** Initializer.\n**\n** Verify that the initializer is only called when the system is\n** uninitialized.  Allocate some memory and report SQLITE_NOMEM if\n** the allocation fails.  This provides a means to test the recovery\n** from a failed initialization attempt.  It also verifies that the\n** the destructor always gets call - otherwise there would be a\n** memory leak.\n*/\nstatic int testpcacheInit(void *pArg){\n  assert( pArg==(void*)&testpcacheGlobal );\n  assert( testpcacheGlobal.pDummy==0 );\n  assert( testpcacheGlobal.nInstance==0 );\n  testpcacheGlobal.pDummy = sqlite3_malloc(10);\n  return testpcacheGlobal.pDummy==0 ? SQLITE_NOMEM : SQLITE_OK;\n}\n\n/*\n** Destructor\n**\n** Verify that this is only called after initialization.\n** Free the memory allocated by the initializer.\n*/\nstatic void testpcacheShutdown(void *pArg){\n  assert( pArg==(void*)&testpcacheGlobal );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance==0 );\n  sqlite3_free( testpcacheGlobal.pDummy );\n  testpcacheGlobal.pDummy = 0;\n}\n\n/*\n** Number of pages in a cache.\n**\n** The number of pages is a hard upper bound in this test module.\n** If more pages are requested, sqlite3PcacheFetch() returns NULL.\n**\n** If testing with in-memory temp tables, provide a larger pcache.\n** Some of the test cases need this.\n*/\n#if defined(SQLITE_TEMP_STORE) && SQLITE_TEMP_STORE>=2\n# define TESTPCACHE_NPAGE    499\n#else\n# define TESTPCACHE_NPAGE    217\n#endif\n#define TESTPCACHE_RESERVE   17\n\n/*\n** Magic numbers used to determine validity of the page cache.\n*/\n#define TESTPCACHE_VALID  0x364585fd\n#define TESTPCACHE_CLEAR  0xd42670d4\n\n/*\n** Private implementation of a page cache.\n*/\ntypedef struct testpcache testpcache;\nstruct testpcache {\n  int szPage;               /* Size of each page.  Multiple of 8. */\n  int szExtra;              /* Size of extra data that accompanies each page */\n  int bPurgeable;           /* True if the page cache is purgeable */\n  int nFree;                /* Number of unused slots in a[] */\n  int nPinned;              /* Number of pinned slots in a[] */\n  unsigned iRand;           /* State of the PRNG */\n  unsigned iMagic;          /* Magic number for sanity checking */\n  struct testpcachePage {\n    sqlite3_pcache_page page;  /* Base class */\n    unsigned key;              /* The key for this page. 0 means unallocated */\n    int isPinned;              /* True if the page is pinned */\n  } a[TESTPCACHE_NPAGE];    /* All pages in the cache */\n};\n\n/*\n** Get a random number using the PRNG in the given page cache.\n*/\nstatic unsigned testpcacheRandom(testpcache *p){\n  unsigned x = 0;\n  int i;\n  for(i=0; i<4; i++){\n    p->iRand = (p->iRand*69069 + 5);\n    x = (x<<8) | ((p->iRand>>16)&0xff);\n  }\n  return x;\n}\n\n\n/*\n** Allocate a new page cache instance.\n*/\nstatic sqlite3_pcache *testpcacheCreate(\n  int szPage, \n  int szExtra, \n  int bPurgeable\n){\n  int nMem;\n  char *x;\n  testpcache *p;\n  int i;\n  assert( testpcacheGlobal.pDummy!=0 );\n  szPage = (szPage+7)&~7;\n  nMem = sizeof(testpcache) + TESTPCACHE_NPAGE*(szPage+szExtra);\n  p = sqlite3_malloc( nMem );\n  if( p==0 ) return 0;\n  x = (char*)&p[1];\n  p->szPage = szPage;\n  p->szExtra = szExtra;\n  p->nFree = TESTPCACHE_NPAGE;\n  p->nPinned = 0;\n  p->iRand = testpcacheGlobal.prngSeed;\n  p->bPurgeable = bPurgeable;\n  p->iMagic = TESTPCACHE_VALID;\n  for(i=0; i<TESTPCACHE_NPAGE; i++, x += (szPage+szExtra)){\n    p->a[i].key = 0;\n    p->a[i].isPinned = 0;\n    p->a[i].page.pBuf = (void*)x;\n    p->a[i].page.pExtra = (void*)&x[szPage];\n  }\n  testpcacheGlobal.nInstance++;\n  return (sqlite3_pcache*)p;\n}\n\n/*\n** Set the cache size\n*/\nstatic void testpcacheCachesize(sqlite3_pcache *pCache, int newSize){\n  testpcache *p = (testpcache*)pCache;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n}\n\n/*\n** Return the number of pages in the cache that are being used.\n** This includes both pinned and unpinned pages.\n*/\nstatic int testpcachePagecount(sqlite3_pcache *pCache){\n  testpcache *p = (testpcache*)pCache;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n  return TESTPCACHE_NPAGE - p->nFree;\n}\n\n/*\n** Fetch a page.\n*/\nstatic sqlite3_pcache_page *testpcacheFetch(\n  sqlite3_pcache *pCache,\n  unsigned key,\n  int createFlag\n){\n  testpcache *p = (testpcache*)pCache;\n  int i, j;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n\n  /* See if the page is already in cache.  Return immediately if it is */\n  for(i=0; i<TESTPCACHE_NPAGE; i++){\n    if( p->a[i].key==key ){\n      if( !p->a[i].isPinned ){\n        p->nPinned++;\n        assert( p->nPinned <= TESTPCACHE_NPAGE - p->nFree );\n        p->a[i].isPinned = 1;\n      }\n      return &p->a[i].page;\n    }\n  }\n\n  /* If createFlag is 0, never allocate a new page */\n  if( createFlag==0 ){\n    return 0;\n  }\n\n  /* If no pages are available, always fail */\n  if( p->nPinned==TESTPCACHE_NPAGE ){\n    return 0;\n  }\n\n  /* Do not allocate the last TESTPCACHE_RESERVE pages unless createFlag is 2 */\n  if( p->nPinned>=TESTPCACHE_NPAGE-TESTPCACHE_RESERVE && createFlag<2 ){\n    return 0;\n  }\n\n  /* Do not allocate if highStress is enabled and createFlag is not 2.  \n  **\n  ** The highStress setting causes pagerStress() to be called much more\n  ** often, which exercises the pager logic more intensely.\n  */\n  if( testpcacheGlobal.highStress && createFlag<2 ){\n    return 0;\n  }\n\n  /* Find a free page to allocate if there are any free pages.\n  ** Withhold TESTPCACHE_RESERVE free pages until createFlag is 2.\n  */\n  if( p->nFree>TESTPCACHE_RESERVE || (createFlag==2 && p->nFree>0) ){\n    j = testpcacheRandom(p) % TESTPCACHE_NPAGE;\n    for(i=0; i<TESTPCACHE_NPAGE; i++, j = (j+1)%TESTPCACHE_NPAGE){\n      if( p->a[j].key==0 ){\n        p->a[j].key = key;\n        p->a[j].isPinned = 1;\n        memset(p->a[j].page.pBuf, 0, p->szPage);\n        memset(p->a[j].page.pExtra, 0, p->szExtra);\n        p->nPinned++;\n        p->nFree--;\n        assert( p->nPinned <= TESTPCACHE_NPAGE - p->nFree );\n        return &p->a[j].page;\n      }\n    }\n\n    /* The prior loop always finds a freepage to allocate */\n    assert( 0 );\n  }\n\n  /* If this cache is not purgeable then we have to fail.\n  */\n  if( p->bPurgeable==0 ){\n    return 0;\n  }\n\n  /* If there are no free pages, recycle a page.  The page to\n  ** recycle is selected at random from all unpinned pages.\n  */\n  j = testpcacheRandom(p) % TESTPCACHE_NPAGE;\n  for(i=0; i<TESTPCACHE_NPAGE; i++, j = (j+1)%TESTPCACHE_NPAGE){\n    if( p->a[j].key>0 && p->a[j].isPinned==0 ){\n      p->a[j].key = key;\n      p->a[j].isPinned = 1;\n      memset(p->a[j].page.pBuf, 0, p->szPage);\n      memset(p->a[j].page.pExtra, 0, p->szExtra);\n      p->nPinned++;\n      assert( p->nPinned <= TESTPCACHE_NPAGE - p->nFree );\n      return &p->a[j].page;\n    }\n  }\n\n  /* The previous loop always finds a page to recycle. */\n  assert(0);\n  return 0;\n}\n\n/*\n** Unpin a page.\n*/\nstatic void testpcacheUnpin(\n  sqlite3_pcache *pCache,\n  sqlite3_pcache_page *pOldPage,\n  int discard\n){\n  testpcache *p = (testpcache*)pCache;\n  int i;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n\n  /* Randomly discard pages as they are unpinned according to the\n  ** discardChance setting.  If discardChance is 0, the random discard\n  ** never happens.  If discardChance is 100, it always happens.\n  */\n  if( p->bPurgeable\n  && (100-testpcacheGlobal.discardChance) <= (testpcacheRandom(p)%100)\n  ){\n    discard = 1;\n  }\n\n  for(i=0; i<TESTPCACHE_NPAGE; i++){\n    if( &p->a[i].page==pOldPage ){\n      /* The pOldPage pointer always points to a pinned page */\n      assert( p->a[i].isPinned );\n      p->a[i].isPinned = 0;\n      p->nPinned--;\n      assert( p->nPinned>=0 );\n      if( discard ){\n        p->a[i].key = 0;\n        p->nFree++;\n        assert( p->nFree<=TESTPCACHE_NPAGE );\n      }\n      return;\n    }\n  }\n\n  /* The pOldPage pointer always points to a valid page */\n  assert( 0 );\n}\n\n\n/*\n** Rekey a single page.\n*/\nstatic void testpcacheRekey(\n  sqlite3_pcache *pCache,\n  sqlite3_pcache_page *pOldPage,\n  unsigned oldKey,\n  unsigned newKey\n){\n  testpcache *p = (testpcache*)pCache;\n  int i;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n\n  /* If there already exists another page at newKey, verify that\n  ** the other page is unpinned and discard it.\n  */\n  for(i=0; i<TESTPCACHE_NPAGE; i++){\n    if( p->a[i].key==newKey ){\n      /* The new key is never a page that is already pinned */\n      assert( p->a[i].isPinned==0 );\n      p->a[i].key = 0;\n      p->nFree++;\n      assert( p->nFree<=TESTPCACHE_NPAGE );\n      break;\n    }\n  }\n\n  /* Find the page to be rekeyed and rekey it.\n  */\n  for(i=0; i<TESTPCACHE_NPAGE; i++){\n    if( p->a[i].key==oldKey ){\n      /* The oldKey and pOldPage parameters match */\n      assert( &p->a[i].page==pOldPage );\n      /* Page to be rekeyed must be pinned */\n      assert( p->a[i].isPinned );\n      p->a[i].key = newKey;\n      return;\n    }\n  }\n\n  /* Rekey is always given a valid page to work with */\n  assert( 0 );\n}\n\n\n/*\n** Truncate the page cache.  Every page with a key of iLimit or larger\n** is discarded.\n*/\nstatic void testpcacheTruncate(sqlite3_pcache *pCache, unsigned iLimit){\n  testpcache *p = (testpcache*)pCache;\n  unsigned int i;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n  for(i=0; i<TESTPCACHE_NPAGE; i++){\n    if( p->a[i].key>=iLimit ){\n      p->a[i].key = 0;\n      if( p->a[i].isPinned ){\n        p->nPinned--;\n        assert( p->nPinned>=0 );\n      }\n      p->nFree++;\n      assert( p->nFree<=TESTPCACHE_NPAGE );\n    }\n  }\n}\n\n/*\n** Destroy a page cache.\n*/\nstatic void testpcacheDestroy(sqlite3_pcache *pCache){\n  testpcache *p = (testpcache*)pCache;\n  assert( p->iMagic==TESTPCACHE_VALID );\n  assert( testpcacheGlobal.pDummy!=0 );\n  assert( testpcacheGlobal.nInstance>0 );\n  p->iMagic = TESTPCACHE_CLEAR;\n  sqlite3_free(p);\n  testpcacheGlobal.nInstance--;\n}\n\n\n/*\n** Invoke this routine to register or unregister the testing pager cache\n** implemented by this file.\n**\n** Install the test pager cache if installFlag is 1 and uninstall it if\n** installFlag is 0.\n**\n** When installing, discardChance is a number between 0 and 100 that\n** indicates the probability of discarding a page when unpinning the\n** page.  0 means never discard (unless the discard flag is set).\n** 100 means always discard.\n*/\nvoid installTestPCache(\n  int installFlag,            /* True to install.  False to uninstall. */\n  unsigned discardChance,     /* 0-100.  Chance to discard on unpin */\n  unsigned prngSeed,          /* Seed for the PRNG */\n  unsigned highStress         /* Call xStress agressively */\n){\n  static const sqlite3_pcache_methods2 testPcache = {\n    1,\n    (void*)&testpcacheGlobal,\n    testpcacheInit,\n    testpcacheShutdown,\n    testpcacheCreate,\n    testpcacheCachesize,\n    testpcachePagecount,\n    testpcacheFetch,\n    testpcacheUnpin,\n    testpcacheRekey,\n    testpcacheTruncate,\n    testpcacheDestroy,\n  };\n  static sqlite3_pcache_methods2 defaultPcache;\n  static int isInstalled = 0;\n\n  assert( testpcacheGlobal.nInstance==0 );\n  assert( testpcacheGlobal.pDummy==0 );\n  assert( discardChance<=100 );\n  testpcacheGlobal.discardChance = discardChance;\n  testpcacheGlobal.prngSeed = prngSeed ^ (prngSeed<<16);\n  testpcacheGlobal.highStress = highStress;\n  if( installFlag!=isInstalled ){\n    if( installFlag ){\n      sqlite3_config(SQLITE_CONFIG_GETPCACHE2, &defaultPcache);\n      assert( defaultPcache.xCreate!=testpcacheCreate );\n      sqlite3_config(SQLITE_CONFIG_PCACHE2, &testPcache);\n    }else{\n      assert( defaultPcache.xCreate!=0 );\n      sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultPcache);\n    }\n    isInstalled = installFlag;\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_quota.c",
    "content": "/*\n** 2010 September 31\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains a VFS \"shim\" - a layer that sits in between the\n** pager and the real VFS.\n**\n** This particular shim enforces a quota system on files.  One or more\n** database files are in a \"quota group\" that is defined by a GLOB\n** pattern.  A quota is set for the combined size of all files in the\n** the group.  A quota of zero means \"no limit\".  If the total size\n** of all files in the quota group is greater than the limit, then\n** write requests that attempt to enlarge a file fail with SQLITE_FULL.\n**\n** However, before returning SQLITE_FULL, the write requests invoke\n** a callback function that is configurable for each quota group.\n** This callback has the opportunity to enlarge the quota.  If the\n** callback does enlarge the quota such that the total size of all\n** files within the group is less than the new quota, then the write\n** continues as if nothing had happened.\n*/\n#include \"test_quota.h\"\n#include <string.h>\n#include <assert.h>\n\n/*\n** For an build without mutexes, no-op the mutex calls.\n*/\n#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE==0\n#define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)\n#define sqlite3_mutex_free(X)\n#define sqlite3_mutex_enter(X)\n#define sqlite3_mutex_try(X)      SQLITE_OK\n#define sqlite3_mutex_leave(X)\n#define sqlite3_mutex_held(X)     ((void)(X),1)\n#define sqlite3_mutex_notheld(X)  ((void)(X),1)\n#endif /* SQLITE_THREADSAFE==0 */\n\n#include \"os_setup.h\"\n\n#if SQLITE_OS_UNIX\n# include <unistd.h>\n#endif\n#if SQLITE_OS_WIN\n# include \"os_win.h\"\n# include <io.h>\n#endif\n\n\n/************************ Object Definitions ******************************/\n\n/* Forward declaration of all object types */\ntypedef struct quotaGroup quotaGroup;\ntypedef struct quotaConn quotaConn;\ntypedef struct quotaFile quotaFile;\n\n/*\n** A \"quota group\" is a collection of files whose collective size we want\n** to limit.  Each quota group is defined by a GLOB pattern.\n**\n** There is an instance of the following object for each defined quota\n** group.  This object records the GLOB pattern that defines which files\n** belong to the quota group.  The object also remembers the size limit\n** for the group (the quota) and the callback to be invoked when the\n** sum of the sizes of the files within the group goes over the limit.\n**\n** A quota group must be established (using sqlite3_quota_set(...))\n** prior to opening any of the database connections that access files\n** within the quota group.\n*/\nstruct quotaGroup {\n  const char *zPattern;          /* Filename pattern to be quotaed */\n  sqlite3_int64 iLimit;          /* Upper bound on total file size */\n  sqlite3_int64 iSize;           /* Current size of all files */\n  void (*xCallback)(             /* Callback invoked when going over quota */\n     const char *zFilename,         /* Name of file whose size increases */\n     sqlite3_int64 *piLimit,        /* IN/OUT: The current limit */\n     sqlite3_int64 iSize,           /* Total size of all files in the group */\n     void *pArg                     /* Client data */\n  );\n  void *pArg;                    /* Third argument to the xCallback() */\n  void (*xDestroy)(void*);       /* Optional destructor for pArg */\n  quotaGroup *pNext, **ppPrev;   /* Doubly linked list of all quota objects */\n  quotaFile *pFiles;             /* Files within this group */\n};\n\n/*\n** An instance of this structure represents a single file that is part\n** of a quota group.  A single file can be opened multiple times.  In\n** order keep multiple openings of the same file from causing the size\n** of the file to count against the quota multiple times, each file\n** has a unique instance of this object and multiple open connections\n** to the same file each point to a single instance of this object.\n*/\nstruct quotaFile {\n  char *zFilename;                /* Name of this file */\n  quotaGroup *pGroup;             /* Quota group to which this file belongs */\n  sqlite3_int64 iSize;            /* Current size of this file */\n  int nRef;                       /* Number of times this file is open */\n  int deleteOnClose;              /* True to delete this file when it closes */\n  quotaFile *pNext, **ppPrev;     /* Linked list of files in the same group */\n};\n\n/*\n** An instance of the following object represents each open connection\n** to a file that participates in quota tracking.  This object is a\n** subclass of sqlite3_file.  The sqlite3_file object for the underlying\n** VFS is appended to this structure.\n*/\nstruct quotaConn {\n  sqlite3_file base;              /* Base class - must be first */\n  quotaFile *pFile;               /* The underlying file */\n  /* The underlying VFS sqlite3_file is appended to this object */\n};\n\n/*\n** An instance of the following object records the state of an\n** open file.  This object is opaque to all users - the internal\n** structure is only visible to the functions below.\n*/\nstruct quota_FILE {\n  FILE *f;                /* Open stdio file pointer */\n  sqlite3_int64 iOfst;    /* Current offset into the file */\n  quotaFile *pFile;       /* The file record in the quota system */\n#if SQLITE_OS_WIN\n  char *zMbcsName;        /* Full MBCS pathname of the file */\n#endif\n};\n\n\n/************************* Global Variables **********************************/\n/*\n** All global variables used by this file are containing within the following\n** gQuota structure.\n*/\nstatic struct {\n  /* The pOrigVfs is the real, original underlying VFS implementation.\n  ** Most operations pass-through to the real VFS.  This value is read-only\n  ** during operation.  It is only modified at start-time and thus does not\n  ** require a mutex.\n  */\n  sqlite3_vfs *pOrigVfs;\n\n  /* The sThisVfs is the VFS structure used by this shim.  It is initialized\n  ** at start-time and thus does not require a mutex\n  */\n  sqlite3_vfs sThisVfs;\n\n  /* The sIoMethods defines the methods used by sqlite3_file objects\n  ** associated with this shim.  It is initialized at start-time and does\n  ** not require a mutex.\n  **\n  ** When the underlying VFS is called to open a file, it might return\n  ** either a version 1 or a version 2 sqlite3_file object.  This shim\n  ** has to create a wrapper sqlite3_file of the same version.  Hence\n  ** there are two I/O method structures, one for version 1 and the other\n  ** for version 2.\n  */\n  sqlite3_io_methods sIoMethodsV1;\n  sqlite3_io_methods sIoMethodsV2;\n\n  /* True when this shim as been initialized.\n  */\n  int isInitialized;\n\n  /* For run-time access any of the other global data structures in this\n  ** shim, the following mutex must be held.\n  */\n  sqlite3_mutex *pMutex;\n\n  /* List of quotaGroup objects.\n  */\n  quotaGroup *pGroup;\n\n} gQuota;\n\n/************************* Utility Routines *********************************/\n/*\n** Acquire and release the mutex used to serialize access to the\n** list of quotaGroups.\n*/\nstatic void quotaEnter(void){ sqlite3_mutex_enter(gQuota.pMutex); }\nstatic void quotaLeave(void){ sqlite3_mutex_leave(gQuota.pMutex); }\n\n/* Count the number of open files in a quotaGroup\n*/\nstatic int quotaGroupOpenFileCount(quotaGroup *pGroup){\n  int N = 0;\n  quotaFile *pFile = pGroup->pFiles;\n  while( pFile ){\n    if( pFile->nRef ) N++;\n    pFile = pFile->pNext;\n  }\n  return N;\n}\n\n/* Remove a file from a quota group.\n*/\nstatic void quotaRemoveFile(quotaFile *pFile){\n  quotaGroup *pGroup = pFile->pGroup;\n  pGroup->iSize -= pFile->iSize;\n  *pFile->ppPrev = pFile->pNext;\n  if( pFile->pNext ) pFile->pNext->ppPrev = pFile->ppPrev;\n  sqlite3_free(pFile);\n}\n\n/* Remove all files from a quota group.  It is always the case that\n** all files will be closed when this routine is called.\n*/\nstatic void quotaRemoveAllFiles(quotaGroup *pGroup){\n  while( pGroup->pFiles ){\n    assert( pGroup->pFiles->nRef==0 );\n    quotaRemoveFile(pGroup->pFiles);\n  }\n}\n\n\n/* If the reference count and threshold for a quotaGroup are both\n** zero, then destroy the quotaGroup.\n*/\nstatic void quotaGroupDeref(quotaGroup *pGroup){\n  if( pGroup->iLimit==0 && quotaGroupOpenFileCount(pGroup)==0 ){\n    quotaRemoveAllFiles(pGroup);\n    *pGroup->ppPrev = pGroup->pNext;\n    if( pGroup->pNext ) pGroup->pNext->ppPrev = pGroup->ppPrev;\n    if( pGroup->xDestroy ) pGroup->xDestroy(pGroup->pArg);\n    sqlite3_free(pGroup);\n  }\n}\n\n/*\n** Return TRUE if string z matches glob pattern zGlob.\n**\n** Globbing rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n**     /          Matches \"/\" or \"\\\\\"\n**\n*/\nstatic int quotaStrglob(const char *zGlob, const char *z){\n  int c, c2, cx;\n  int invert;\n  int seen;\n\n  while( (c = (*(zGlob++)))!=0 ){\n    if( c=='*' ){\n      while( (c=(*(zGlob++))) == '*' || c=='?' ){\n        if( c=='?' && (*(z++))==0 ) return 0;\n      }\n      if( c==0 ){\n        return 1;\n      }else if( c=='[' ){\n        while( *z && quotaStrglob(zGlob-1,z)==0 ){\n          z++;\n        }\n        return (*z)!=0;\n      }\n      cx = (c=='/') ? '\\\\' : c;\n      while( (c2 = (*(z++)))!=0 ){\n        while( c2!=c && c2!=cx ){\n          c2 = *(z++);\n          if( c2==0 ) return 0;\n        }\n        if( quotaStrglob(zGlob,z) ) return 1;\n      }\n      return 0;\n    }else if( c=='?' ){\n      if( (*(z++))==0 ) return 0;\n    }else if( c=='[' ){\n      int prior_c = 0;\n      seen = 0;\n      invert = 0;\n      c = *(z++);\n      if( c==0 ) return 0;\n      c2 = *(zGlob++);\n      if( c2=='^' ){\n        invert = 1;\n        c2 = *(zGlob++);\n      }\n      if( c2==']' ){\n        if( c==']' ) seen = 1;\n        c2 = *(zGlob++);\n      }\n      while( c2 && c2!=']' ){\n        if( c2=='-' && zGlob[0]!=']' && zGlob[0]!=0 && prior_c>0 ){\n          c2 = *(zGlob++);\n          if( c>=prior_c && c<=c2 ) seen = 1;\n          prior_c = 0;\n        }else{\n          if( c==c2 ){\n            seen = 1;\n          }\n          prior_c = c2;\n        }\n        c2 = *(zGlob++);\n      }\n      if( c2==0 || (seen ^ invert)==0 ) return 0;\n    }else if( c=='/' ){\n      if( z[0]!='/' && z[0]!='\\\\' ) return 0;\n      z++;\n    }else{\n      if( c!=(*(z++)) ) return 0;\n    }\n  }\n  return *z==0;\n}\n\n\n/* Find a quotaGroup given the filename.\n**\n** Return a pointer to the quotaGroup object. Return NULL if not found.\n*/\nstatic quotaGroup *quotaGroupFind(const char *zFilename){\n  quotaGroup *p;\n  for(p=gQuota.pGroup; p && quotaStrglob(p->zPattern, zFilename)==0;\n      p=p->pNext){}\n  return p;\n}\n\n/* Translate an sqlite3_file* that is really a quotaConn* into\n** the sqlite3_file* for the underlying original VFS.\n*/\nstatic sqlite3_file *quotaSubOpen(sqlite3_file *pConn){\n  quotaConn *p = (quotaConn*)pConn;\n  return (sqlite3_file*)&p[1];\n}\n\n/* Find a file in a quota group and return a pointer to that file.\n** Return NULL if the file is not in the group.\n*/\nstatic quotaFile *quotaFindFile(\n  quotaGroup *pGroup,     /* Group in which to look for the file */\n  const char *zName,      /* Full pathname of the file */\n  int createFlag          /* Try to create the file if not found */\n){\n  quotaFile *pFile = pGroup->pFiles;\n  while( pFile && strcmp(pFile->zFilename, zName)!=0 ){\n    pFile = pFile->pNext;\n  }\n  if( pFile==0 && createFlag ){\n    int nName = (int)(strlen(zName) & 0x3fffffff);\n    pFile = (quotaFile *)sqlite3_malloc( sizeof(*pFile) + nName + 1 );\n    if( pFile ){\n      memset(pFile, 0, sizeof(*pFile));\n      pFile->zFilename = (char*)&pFile[1];\n      memcpy(pFile->zFilename, zName, nName+1);\n      pFile->pNext = pGroup->pFiles;\n      if( pGroup->pFiles ) pGroup->pFiles->ppPrev = &pFile->pNext;\n      pFile->ppPrev = &pGroup->pFiles;\n      pGroup->pFiles = pFile;\n      pFile->pGroup = pGroup;\n    }\n  }\n  return pFile;\n}\n/*\n** Translate UTF8 to MBCS for use in fopen() calls.  Return a pointer to the\n** translated text..  Call quota_mbcs_free() to deallocate any memory\n** used to store the returned pointer when done.\n*/\nstatic char *quota_utf8_to_mbcs(const char *zUtf8){\n#if SQLITE_OS_WIN\n  size_t n;          /* Bytes in zUtf8 */\n  int nWide;         /* number of UTF-16 characters */\n  int nMbcs;         /* Bytes of MBCS */\n  LPWSTR zTmpWide;   /* The UTF16 text */\n  char *zMbcs;       /* The MBCS text */\n  int codepage;      /* Code page used by fopen() */\n\n  n = strlen(zUtf8);\n  nWide = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);\n  if( nWide==0 ) return 0;\n  zTmpWide = (LPWSTR)sqlite3_malloc( (nWide+1)*sizeof(zTmpWide[0]) );\n  if( zTmpWide==0 ) return 0;\n  MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zTmpWide, nWide);\n  codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;\n  nMbcs = WideCharToMultiByte(codepage, 0, zTmpWide, nWide, 0, 0, 0, 0);\n  zMbcs = nMbcs ? (char*)sqlite3_malloc( nMbcs+1 ) : 0;\n  if( zMbcs ){\n    WideCharToMultiByte(codepage, 0, zTmpWide, nWide, zMbcs, nMbcs, 0, 0);\n  }\n  sqlite3_free(zTmpWide);\n  return zMbcs;\n#else\n  return (char*)zUtf8;  /* No-op on unix */\n#endif\n}\n\n/*\n** Deallocate any memory allocated by quota_utf8_to_mbcs().\n*/\nstatic void quota_mbcs_free(char *zOld){\n#if SQLITE_OS_WIN\n  sqlite3_free(zOld);\n#else\n  /* No-op on unix */\n#endif\n}\n\n/************************* VFS Method Wrappers *****************************/\n/*\n** This is the xOpen method used for the \"quota\" VFS.\n**\n** Most of the work is done by the underlying original VFS.  This method\n** simply links the new file into the appropriate quota group if it is a\n** file that needs to be tracked.\n*/\nstatic int quotaOpen(\n  sqlite3_vfs *pVfs,          /* The quota VFS */\n  const char *zName,          /* Name of file to be opened */\n  sqlite3_file *pConn,        /* Fill in this file descriptor */\n  int flags,                  /* Flags to control the opening */\n  int *pOutFlags              /* Flags showing results of opening */\n){\n  int rc;                                    /* Result code */\n  quotaConn *pQuotaOpen;                     /* The new quota file descriptor */\n  quotaFile *pFile;                          /* Corresponding quotaFile obj */\n  quotaGroup *pGroup;                        /* The group file belongs to */\n  sqlite3_file *pSubOpen;                    /* Real file descriptor */\n  sqlite3_vfs *pOrigVfs = gQuota.pOrigVfs;   /* Real VFS */\n\n  /* If the file is not a main database file or a WAL, then use the\n  ** normal xOpen method.\n  */\n  if( (flags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_WAL))==0 ){\n    return pOrigVfs->xOpen(pOrigVfs, zName, pConn, flags, pOutFlags);\n  }\n\n  /* If the name of the file does not match any quota group, then\n  ** use the normal xOpen method.\n  */\n  quotaEnter();\n  pGroup = quotaGroupFind(zName);\n  if( pGroup==0 ){\n    rc = pOrigVfs->xOpen(pOrigVfs, zName, pConn, flags, pOutFlags);\n  }else{\n    /* If we get to this point, it means the file needs to be quota tracked.\n    */\n    pQuotaOpen = (quotaConn*)pConn;\n    pSubOpen = quotaSubOpen(pConn);\n    rc = pOrigVfs->xOpen(pOrigVfs, zName, pSubOpen, flags, pOutFlags);\n    if( rc==SQLITE_OK ){\n      pFile = quotaFindFile(pGroup, zName, 1);\n      if( pFile==0 ){\n        quotaLeave();\n        pSubOpen->pMethods->xClose(pSubOpen);\n        return SQLITE_NOMEM;\n      }\n      pFile->deleteOnClose = (flags & SQLITE_OPEN_DELETEONCLOSE)!=0;\n      pFile->nRef++;\n      pQuotaOpen->pFile = pFile;\n      if( pSubOpen->pMethods->iVersion==1 ){\n        pQuotaOpen->base.pMethods = &gQuota.sIoMethodsV1;\n      }else{\n        pQuotaOpen->base.pMethods = &gQuota.sIoMethodsV2;\n      }\n    }\n  }\n  quotaLeave();\n  return rc;\n}\n\n/*\n** This is the xDelete method used for the \"quota\" VFS.\n**\n** If the file being deleted is part of the quota group, then reduce\n** the size of the quota group accordingly.  And remove the file from\n** the set of files in the quota group.\n*/\nstatic int quotaDelete(\n  sqlite3_vfs *pVfs,          /* The quota VFS */\n  const char *zName,          /* Name of file to be deleted */\n  int syncDir                 /* Do a directory sync after deleting */\n){\n  int rc;                                    /* Result code */\n  quotaFile *pFile;                          /* Files in the quota */\n  quotaGroup *pGroup;                        /* The group file belongs to */\n  sqlite3_vfs *pOrigVfs = gQuota.pOrigVfs;   /* Real VFS */\n\n  /* Do the actual file delete */\n  rc = pOrigVfs->xDelete(pOrigVfs, zName, syncDir);\n\n  /* If the file just deleted is a member of a quota group, then remove\n  ** it from that quota group.\n  */\n  if( rc==SQLITE_OK ){\n    quotaEnter();\n    pGroup = quotaGroupFind(zName);\n    if( pGroup ){\n      pFile = quotaFindFile(pGroup, zName, 0);\n      if( pFile ){\n        if( pFile->nRef ){\n          pFile->deleteOnClose = 1;\n        }else{\n          quotaRemoveFile(pFile);\n          quotaGroupDeref(pGroup);\n        }\n      }\n    }\n    quotaLeave();\n  }\n  return rc;\n}\n\n\n/************************ I/O Method Wrappers *******************************/\n\n/* xClose requests get passed through to the original VFS.  But we\n** also have to unlink the quotaConn from the quotaFile and quotaGroup.\n** The quotaFile and/or quotaGroup are freed if they are no longer in use.\n*/\nstatic int quotaClose(sqlite3_file *pConn){\n  quotaConn *p = (quotaConn*)pConn;\n  quotaFile *pFile = p->pFile;\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  int rc;\n  rc = pSubOpen->pMethods->xClose(pSubOpen);\n  quotaEnter();\n  pFile->nRef--;\n  if( pFile->nRef==0 ){\n    quotaGroup *pGroup = pFile->pGroup;\n    if( pFile->deleteOnClose ){\n      gQuota.pOrigVfs->xDelete(gQuota.pOrigVfs, pFile->zFilename, 0);\n      quotaRemoveFile(pFile);\n    }\n    quotaGroupDeref(pGroup);\n  }\n  quotaLeave();\n  return rc;\n}\n\n/* Pass xRead requests directory thru to the original VFS without\n** further processing.\n*/\nstatic int quotaRead(\n  sqlite3_file *pConn,\n  void *pBuf,\n  int iAmt,\n  sqlite3_int64 iOfst\n){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xRead(pSubOpen, pBuf, iAmt, iOfst);\n}\n\n/* Check xWrite requests to see if they expand the file.  If they do,\n** the perform a quota check before passing them through to the\n** original VFS.\n*/\nstatic int quotaWrite(\n  sqlite3_file *pConn,\n  const void *pBuf,\n  int iAmt,\n  sqlite3_int64 iOfst\n){\n  quotaConn *p = (quotaConn*)pConn;\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  sqlite3_int64 iEnd = iOfst+iAmt;\n  quotaGroup *pGroup;\n  quotaFile *pFile = p->pFile;\n  sqlite3_int64 szNew;\n\n  if( pFile->iSize<iEnd ){\n    pGroup = pFile->pGroup;\n    quotaEnter();\n    szNew = pGroup->iSize - pFile->iSize + iEnd;\n    if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){\n      if( pGroup->xCallback ){\n        pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew,\n                          pGroup->pArg);\n      }\n      if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){\n        quotaLeave();\n        return SQLITE_FULL;\n      }\n    }\n    pGroup->iSize = szNew;\n    pFile->iSize = iEnd;\n    quotaLeave();\n  }\n  return pSubOpen->pMethods->xWrite(pSubOpen, pBuf, iAmt, iOfst);\n}\n\n/* Pass xTruncate requests thru to the original VFS.  If the\n** success, update the file size.\n*/\nstatic int quotaTruncate(sqlite3_file *pConn, sqlite3_int64 size){\n  quotaConn *p = (quotaConn*)pConn;\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  int rc = pSubOpen->pMethods->xTruncate(pSubOpen, size);\n  quotaFile *pFile = p->pFile;\n  quotaGroup *pGroup;\n  if( rc==SQLITE_OK ){\n    quotaEnter();\n    pGroup = pFile->pGroup;\n    pGroup->iSize -= pFile->iSize;\n    pFile->iSize = size;\n    pGroup->iSize += size;\n    quotaLeave();\n  }\n  return rc;\n}\n\n/* Pass xSync requests through to the original VFS without change\n*/\nstatic int quotaSync(sqlite3_file *pConn, int flags){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xSync(pSubOpen, flags);\n}\n\n/* Pass xFileSize requests through to the original VFS but then\n** update the quotaGroup with the new size before returning.\n*/\nstatic int quotaFileSize(sqlite3_file *pConn, sqlite3_int64 *pSize){\n  quotaConn *p = (quotaConn*)pConn;\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  quotaFile *pFile = p->pFile;\n  quotaGroup *pGroup;\n  sqlite3_int64 sz;\n  int rc;\n\n  rc = pSubOpen->pMethods->xFileSize(pSubOpen, &sz);\n  if( rc==SQLITE_OK ){\n    quotaEnter();\n    pGroup = pFile->pGroup;\n    pGroup->iSize -= pFile->iSize;\n    pFile->iSize = sz;\n    pGroup->iSize += sz;\n    quotaLeave();\n    *pSize = sz;\n  }\n  return rc;\n}\n\n/* Pass xLock requests through to the original VFS unchanged.\n*/\nstatic int quotaLock(sqlite3_file *pConn, int lock){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xLock(pSubOpen, lock);\n}\n\n/* Pass xUnlock requests through to the original VFS unchanged.\n*/\nstatic int quotaUnlock(sqlite3_file *pConn, int lock){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xUnlock(pSubOpen, lock);\n}\n\n/* Pass xCheckReservedLock requests through to the original VFS unchanged.\n*/\nstatic int quotaCheckReservedLock(sqlite3_file *pConn, int *pResOut){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xCheckReservedLock(pSubOpen, pResOut);\n}\n\n/* Pass xFileControl requests through to the original VFS unchanged.\n*/\nstatic int quotaFileControl(sqlite3_file *pConn, int op, void *pArg){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  int rc = pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg);\n#if defined(SQLITE_FCNTL_VFSNAME)\n  if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n    *(char**)pArg = sqlite3_mprintf(\"quota/%z\", *(char**)pArg);\n  }\n#endif\n  return rc;\n}\n\n/* Pass xSectorSize requests through to the original VFS unchanged.\n*/\nstatic int quotaSectorSize(sqlite3_file *pConn){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xSectorSize(pSubOpen);\n}\n\n/* Pass xDeviceCharacteristics requests through to the original VFS unchanged.\n*/\nstatic int quotaDeviceCharacteristics(sqlite3_file *pConn){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xDeviceCharacteristics(pSubOpen);\n}\n\n/* Pass xShmMap requests through to the original VFS unchanged.\n*/\nstatic int quotaShmMap(\n  sqlite3_file *pConn,            /* Handle open on database file */\n  int iRegion,                    /* Region to retrieve */\n  int szRegion,                   /* Size of regions */\n  int bExtend,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xShmMap(pSubOpen, iRegion, szRegion, bExtend, pp);\n}\n\n/* Pass xShmLock requests through to the original VFS unchanged.\n*/\nstatic int quotaShmLock(\n  sqlite3_file *pConn,       /* Database file holding the shared memory */\n  int ofst,                  /* First lock to acquire or release */\n  int n,                     /* Number of locks to acquire or release */\n  int flags                  /* What to do with the lock */\n){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xShmLock(pSubOpen, ofst, n, flags);\n}\n\n/* Pass xShmBarrier requests through to the original VFS unchanged.\n*/\nstatic void quotaShmBarrier(sqlite3_file *pConn){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  pSubOpen->pMethods->xShmBarrier(pSubOpen);\n}\n\n/* Pass xShmUnmap requests through to the original VFS unchanged.\n*/\nstatic int quotaShmUnmap(sqlite3_file *pConn, int deleteFlag){\n  sqlite3_file *pSubOpen = quotaSubOpen(pConn);\n  return pSubOpen->pMethods->xShmUnmap(pSubOpen, deleteFlag);\n}\n\n/************************** Public Interfaces *****************************/\n/*\n** Initialize the quota VFS shim.  Use the VFS named zOrigVfsName\n** as the VFS that does the actual work.  Use the default if\n** zOrigVfsName==NULL.\n**\n** The quota VFS shim is named \"quota\".  It will become the default\n** VFS if makeDefault is non-zero.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once\n** during start-up.\n*/\nint sqlite3_quota_initialize(const char *zOrigVfsName, int makeDefault){\n  sqlite3_vfs *pOrigVfs;\n  if( gQuota.isInitialized ) return SQLITE_MISUSE;\n  pOrigVfs = sqlite3_vfs_find(zOrigVfsName);\n  if( pOrigVfs==0 ) return SQLITE_ERROR;\n  assert( pOrigVfs!=&gQuota.sThisVfs );\n  gQuota.pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST);\n  if( !gQuota.pMutex ){\n    return SQLITE_NOMEM;\n  }\n  gQuota.isInitialized = 1;\n  gQuota.pOrigVfs = pOrigVfs;\n  gQuota.sThisVfs = *pOrigVfs;\n  gQuota.sThisVfs.xOpen = quotaOpen;\n  gQuota.sThisVfs.xDelete = quotaDelete;\n  gQuota.sThisVfs.szOsFile += sizeof(quotaConn);\n  gQuota.sThisVfs.zName = \"quota\";\n  gQuota.sIoMethodsV1.iVersion = 1;\n  gQuota.sIoMethodsV1.xClose = quotaClose;\n  gQuota.sIoMethodsV1.xRead = quotaRead;\n  gQuota.sIoMethodsV1.xWrite = quotaWrite;\n  gQuota.sIoMethodsV1.xTruncate = quotaTruncate;\n  gQuota.sIoMethodsV1.xSync = quotaSync;\n  gQuota.sIoMethodsV1.xFileSize = quotaFileSize;\n  gQuota.sIoMethodsV1.xLock = quotaLock;\n  gQuota.sIoMethodsV1.xUnlock = quotaUnlock;\n  gQuota.sIoMethodsV1.xCheckReservedLock = quotaCheckReservedLock;\n  gQuota.sIoMethodsV1.xFileControl = quotaFileControl;\n  gQuota.sIoMethodsV1.xSectorSize = quotaSectorSize;\n  gQuota.sIoMethodsV1.xDeviceCharacteristics = quotaDeviceCharacteristics;\n  gQuota.sIoMethodsV2 = gQuota.sIoMethodsV1;\n  gQuota.sIoMethodsV2.iVersion = 2;\n  gQuota.sIoMethodsV2.xShmMap = quotaShmMap;\n  gQuota.sIoMethodsV2.xShmLock = quotaShmLock;\n  gQuota.sIoMethodsV2.xShmBarrier = quotaShmBarrier;\n  gQuota.sIoMethodsV2.xShmUnmap = quotaShmUnmap;\n  sqlite3_vfs_register(&gQuota.sThisVfs, makeDefault);\n  return SQLITE_OK;\n}\n\n/*\n** Shutdown the quota system.\n**\n** All SQLite database connections must be closed before calling this\n** routine.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while\n** shutting down in order to free all remaining quota groups.\n*/\nint sqlite3_quota_shutdown(void){\n  quotaGroup *pGroup;\n  if( gQuota.isInitialized==0 ) return SQLITE_MISUSE;\n  for(pGroup=gQuota.pGroup; pGroup; pGroup=pGroup->pNext){\n    if( quotaGroupOpenFileCount(pGroup)>0 ) return SQLITE_MISUSE;\n  }\n  while( gQuota.pGroup ){\n    pGroup = gQuota.pGroup;\n    gQuota.pGroup = pGroup->pNext;\n    pGroup->iLimit = 0;\n    assert( quotaGroupOpenFileCount(pGroup)==0 );\n    quotaGroupDeref(pGroup);\n  }\n  gQuota.isInitialized = 0;\n  sqlite3_mutex_free(gQuota.pMutex);\n  sqlite3_vfs_unregister(&gQuota.sThisVfs);\n  memset(&gQuota, 0, sizeof(gQuota));\n  return SQLITE_OK;\n}\n\n/*\n** Create or destroy a quota group.\n**\n** The quota group is defined by the zPattern.  When calling this routine\n** with a zPattern for a quota group that already exists, this routine\n** merely updates the iLimit, xCallback, and pArg values for that quota\n** group.  If zPattern is new, then a new quota group is created.\n**\n** If the iLimit for a quota group is set to zero, then the quota group\n** is disabled and will be deleted when the last database connection using\n** the quota group is closed.\n**\n** Calling this routine on a zPattern that does not exist and with a\n** zero iLimit is a no-op.\n**\n** A quota group must exist with a non-zero iLimit prior to opening\n** database connections if those connections are to participate in the\n** quota group.  Creating a quota group does not affect database connections\n** that are already open.\n*/\nint sqlite3_quota_set(\n  const char *zPattern,           /* The filename pattern */\n  sqlite3_int64 iLimit,           /* New quota to set for this quota group */\n  void (*xCallback)(              /* Callback invoked when going over quota */\n     const char *zFilename,         /* Name of file whose size increases */\n     sqlite3_int64 *piLimit,        /* IN/OUT: The current limit */\n     sqlite3_int64 iSize,           /* Total size of all files in the group */\n     void *pArg                     /* Client data */\n  ),\n  void *pArg,                     /* client data passed thru to callback */\n  void (*xDestroy)(void*)         /* Optional destructor for pArg */\n){\n  quotaGroup *pGroup;\n  quotaEnter();\n  pGroup = gQuota.pGroup;\n  while( pGroup && strcmp(pGroup->zPattern, zPattern)!=0 ){\n    pGroup = pGroup->pNext;\n  }\n  if( pGroup==0 ){\n    int nPattern = (int)(strlen(zPattern) & 0x3fffffff);\n    if( iLimit<=0 ){\n      quotaLeave();\n      return SQLITE_OK;\n    }\n    pGroup = (quotaGroup *)sqlite3_malloc( sizeof(*pGroup) + nPattern + 1 );\n    if( pGroup==0 ){\n      quotaLeave();\n      return SQLITE_NOMEM;\n    }\n    memset(pGroup, 0, sizeof(*pGroup));\n    pGroup->zPattern = (char*)&pGroup[1];\n    memcpy((char *)pGroup->zPattern, zPattern, nPattern+1);\n    if( gQuota.pGroup ) gQuota.pGroup->ppPrev = &pGroup->pNext;\n    pGroup->pNext = gQuota.pGroup;\n    pGroup->ppPrev = &gQuota.pGroup;\n    gQuota.pGroup = pGroup;\n  }\n  pGroup->iLimit = iLimit;\n  pGroup->xCallback = xCallback;\n  if( pGroup->xDestroy && pGroup->pArg!=pArg ){\n    pGroup->xDestroy(pGroup->pArg);\n  }\n  pGroup->pArg = pArg;\n  pGroup->xDestroy = xDestroy;\n  quotaGroupDeref(pGroup);\n  quotaLeave();\n  return SQLITE_OK;\n}\n\n/*\n** Bring the named file under quota management.  Or if it is already under\n** management, update its size.\n*/\nint sqlite3_quota_file(const char *zFilename){\n  char *zFull = 0;\n  sqlite3_file *fd;\n  int rc;\n  int outFlags = 0;\n  sqlite3_int64 iSize;\n  int nAlloc = gQuota.sThisVfs.szOsFile + gQuota.sThisVfs.mxPathname+2;\n\n  /* Allocate space for a file-handle and the full path for file zFilename */\n  fd = (sqlite3_file *)sqlite3_malloc(nAlloc);\n  if( fd==0 ){\n    rc = SQLITE_NOMEM;\n  }else{\n    zFull = &((char *)fd)[gQuota.sThisVfs.szOsFile];\n    rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,\n        gQuota.sThisVfs.mxPathname+1, zFull);\n  }\n\n  if( rc==SQLITE_OK ){\n    zFull[strlen(zFull)+1] = '\\0';\n    rc = quotaOpen(&gQuota.sThisVfs, zFull, fd,\n                   SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB, &outFlags);\n    if( rc==SQLITE_OK ){\n      fd->pMethods->xFileSize(fd, &iSize);\n      fd->pMethods->xClose(fd);\n    }else if( rc==SQLITE_CANTOPEN ){\n      quotaGroup *pGroup;\n      quotaFile *pFile;\n      quotaEnter();\n      pGroup = quotaGroupFind(zFull);\n      if( pGroup ){\n        pFile = quotaFindFile(pGroup, zFull, 0);\n        if( pFile ) quotaRemoveFile(pFile);\n      }\n      quotaLeave();\n    }\n  }\n\n  sqlite3_free(fd);\n  return rc;\n}\n\n/*\n** Open a potentially quotaed file for I/O.\n*/\nquota_FILE *sqlite3_quota_fopen(const char *zFilename, const char *zMode){\n  quota_FILE *p = 0;\n  char *zFull = 0;\n  char *zFullTranslated = 0;\n  int rc;\n  quotaGroup *pGroup;\n  quotaFile *pFile;\n\n  zFull = (char*)sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);\n  if( zFull==0 ) return 0;\n  rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,\n                                      gQuota.sThisVfs.mxPathname+1, zFull);\n  if( rc ) goto quota_fopen_error;\n  p = (quota_FILE*)sqlite3_malloc(sizeof(*p));\n  if( p==0 ) goto quota_fopen_error;\n  memset(p, 0, sizeof(*p));\n  zFullTranslated = quota_utf8_to_mbcs(zFull);\n  if( zFullTranslated==0 ) goto quota_fopen_error;\n  p->f = fopen(zFullTranslated, zMode);\n  if( p->f==0 ) goto quota_fopen_error;\n  quotaEnter();\n  pGroup = quotaGroupFind(zFull);\n  if( pGroup ){\n    pFile = quotaFindFile(pGroup, zFull, 1);\n    if( pFile==0 ){\n      quotaLeave();\n      goto quota_fopen_error;\n    }\n    pFile->nRef++;\n    p->pFile = pFile;\n  }\n  quotaLeave();\n  sqlite3_free(zFull);\n#if SQLITE_OS_WIN\n  p->zMbcsName = zFullTranslated;\n#endif\n  return p;\n\nquota_fopen_error:\n  quota_mbcs_free(zFullTranslated);\n  sqlite3_free(zFull);\n  if( p && p->f ) fclose(p->f);\n  sqlite3_free(p);\n  return 0;\n}\n\n/*\n** Read content from a quota_FILE\n*/\nsize_t sqlite3_quota_fread(\n  void *pBuf,            /* Store the content here */\n  size_t size,           /* Size of each element */\n  size_t nmemb,          /* Number of elements to read */\n  quota_FILE *p          /* Read from this quota_FILE object */\n){\n  return fread(pBuf, size, nmemb, p->f);\n}\n\n/*\n** Write content into a quota_FILE.  Invoke the quota callback and block\n** the write if we exceed quota.\n*/\nsize_t sqlite3_quota_fwrite(\n  const void *pBuf,      /* Take content to write from here */\n  size_t size,           /* Size of each element */\n  size_t nmemb,          /* Number of elements */\n  quota_FILE *p          /* Write to this quota_FILE objecct */\n){\n  sqlite3_int64 iOfst;\n  sqlite3_int64 iEnd;\n  sqlite3_int64 szNew;\n  quotaFile *pFile;\n  size_t rc;\n\n  iOfst = ftell(p->f);\n  iEnd = iOfst + size*nmemb;\n  pFile = p->pFile;\n  if( pFile && pFile->iSize<iEnd ){\n    quotaGroup *pGroup = pFile->pGroup;\n    quotaEnter();\n    szNew = pGroup->iSize - pFile->iSize + iEnd;\n    if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){\n      if( pGroup->xCallback ){\n        pGroup->xCallback(pFile->zFilename, &pGroup->iLimit, szNew,\n                          pGroup->pArg);\n      }\n      if( szNew>pGroup->iLimit && pGroup->iLimit>0 ){\n        iEnd = pGroup->iLimit - pGroup->iSize + pFile->iSize;\n        nmemb = (size_t)((iEnd - iOfst)/size);\n        iEnd = iOfst + size*nmemb;\n        szNew = pGroup->iSize - pFile->iSize + iEnd;\n      }\n    }\n    pGroup->iSize = szNew;\n    pFile->iSize = iEnd;\n    quotaLeave();\n  }else{\n    pFile = 0;\n  }\n  rc = fwrite(pBuf, size, nmemb, p->f);\n\n  /* If the write was incomplete, adjust the file size and group size\n  ** downward */\n  if( rc<nmemb && pFile ){\n    size_t nWritten = rc;\n    sqlite3_int64 iNewEnd = iOfst + size*nWritten;\n    if( iNewEnd<iEnd ) iNewEnd = iEnd;\n    quotaEnter();\n    pFile->pGroup->iSize += iNewEnd - pFile->iSize;\n    pFile->iSize = iNewEnd;\n    quotaLeave();\n  }\n  return rc;\n}\n\n/*\n** Close an open quota_FILE stream.\n*/\nint sqlite3_quota_fclose(quota_FILE *p){\n  int rc;\n  quotaFile *pFile;\n  rc = fclose(p->f);\n  pFile = p->pFile;\n  if( pFile ){\n    quotaEnter();\n    pFile->nRef--;\n    if( pFile->nRef==0 ){\n      quotaGroup *pGroup = pFile->pGroup;\n      if( pFile->deleteOnClose ){\n        gQuota.pOrigVfs->xDelete(gQuota.pOrigVfs, pFile->zFilename, 0);\n        quotaRemoveFile(pFile);\n      }\n      quotaGroupDeref(pGroup);\n    }\n    quotaLeave();\n  }\n#if SQLITE_OS_WIN\n  quota_mbcs_free(p->zMbcsName);\n#endif\n  sqlite3_free(p);\n  return rc;\n}\n\n/*\n** Flush memory buffers for a quota_FILE to disk.\n*/\nint sqlite3_quota_fflush(quota_FILE *p, int doFsync){\n  int rc;\n  rc = fflush(p->f);\n  if( rc==0 && doFsync ){\n#if SQLITE_OS_UNIX\n    rc = fsync(fileno(p->f));\n#endif\n#if SQLITE_OS_WIN\n    rc = _commit(_fileno(p->f));\n#endif\n  }\n  return rc!=0;\n}\n\n/*\n** Seek on a quota_FILE stream.\n*/\nint sqlite3_quota_fseek(quota_FILE *p, long offset, int whence){\n  return fseek(p->f, offset, whence);\n}\n\n/*\n** rewind a quota_FILE stream.\n*/\nvoid sqlite3_quota_rewind(quota_FILE *p){\n  rewind(p->f);\n}\n\n/*\n** Tell the current location of a quota_FILE stream.\n*/\nlong sqlite3_quota_ftell(quota_FILE *p){\n  return ftell(p->f);\n}\n\n/*\n** Test the error indicator for the given file.\n*/\nint sqlite3_quota_ferror(quota_FILE *p){\n  return ferror(p->f);\n}\n\n/*\n** Truncate a file to szNew bytes.\n*/\nint sqlite3_quota_ftruncate(quota_FILE *p, sqlite3_int64 szNew){\n  quotaFile *pFile = p->pFile;\n  int rc;\n  if( (pFile = p->pFile)!=0 && pFile->iSize<szNew ){\n    quotaGroup *pGroup;\n    if( pFile->iSize<szNew ){\n      /* This routine cannot be used to extend a file that is under\n      ** quota management.  Only true truncation is allowed. */\n      return -1;\n    }\n    pGroup = pFile->pGroup;\n    quotaEnter();\n    pGroup->iSize += szNew - pFile->iSize;\n    quotaLeave();\n  }\n#if SQLITE_OS_UNIX\n  rc = ftruncate(fileno(p->f), szNew);\n#endif\n#if SQLITE_OS_WIN\n#  if defined(__MINGW32__) && defined(SQLITE_TEST)\n     /* _chsize_s() is missing from MingW (as of 2012-11-06).  Use\n     ** _chsize() as a work-around for testing purposes. */\n     rc = _chsize(_fileno(p->f), (long)szNew);\n#  else\n     rc = _chsize_s(_fileno(p->f), szNew);\n#  endif\n#endif\n  if( pFile && rc==0 ){\n    quotaGroup *pGroup = pFile->pGroup;\n    quotaEnter();\n    pGroup->iSize += szNew - pFile->iSize;\n    pFile->iSize = szNew;\n    quotaLeave();\n  }\n  return rc;\n}\n\n/*\n** Determine the time that the given file was last modified, in\n** seconds size 1970.  Write the result into *pTime.  Return 0 on\n** success and non-zero on any kind of error.\n*/\nint sqlite3_quota_file_mtime(quota_FILE *p, time_t *pTime){\n  int rc;\n#if SQLITE_OS_UNIX\n  struct stat buf;\n  rc = fstat(fileno(p->f), &buf);\n#endif\n#if SQLITE_OS_WIN\n  struct _stati64 buf;\n  rc = _stati64(p->zMbcsName, &buf);\n#endif\n  if( rc==0 ) *pTime = buf.st_mtime;\n  return rc;\n}\n\n/*\n** Return the true size of the file, as reported by the operating\n** system.\n*/\nsqlite3_int64 sqlite3_quota_file_truesize(quota_FILE *p){\n  int rc;\n#if SQLITE_OS_UNIX\n  struct stat buf;\n  rc = fstat(fileno(p->f), &buf);\n#endif\n#if SQLITE_OS_WIN\n  struct _stati64 buf;\n  rc = _stati64(p->zMbcsName, &buf);\n#endif\n  return rc==0 ? buf.st_size : -1;\n}\n\n/*\n** Return the size of the file, as it is known to the quota subsystem.\n*/\nsqlite3_int64 sqlite3_quota_file_size(quota_FILE *p){\n  return p->pFile ? p->pFile->iSize : -1;\n}\n\n/*\n** Determine the amount of data in bytes available for reading\n** in the given file.\n*/\nlong sqlite3_quota_file_available(quota_FILE *p){\n  FILE* f = p->f;\n  long pos1, pos2;\n  int rc;\n  pos1 = ftell(f);\n  if ( pos1 < 0 ) return -1;\n  rc = fseek(f, 0, SEEK_END);\n  if ( rc != 0 ) return -1;\n  pos2 = ftell(f);\n  if ( pos2 < 0 ) return -1;\n  rc = fseek(f, pos1, SEEK_SET);\n  if ( rc != 0 ) return -1;\n  return pos2 - pos1;\n}\n\n/*\n** Remove a managed file.  Update quotas accordingly.\n*/\nint sqlite3_quota_remove(const char *zFilename){\n  char *zFull;            /* Full pathname for zFilename */\n  size_t nFull;           /* Number of bytes in zFilename */\n  int rc;                 /* Result code */\n  quotaGroup *pGroup;     /* Group containing zFilename */\n  quotaFile *pFile;       /* A file in the group */\n  quotaFile *pNextFile;   /* next file in the group */\n  int diff;               /* Difference between filenames */\n  char c;                 /* First character past end of pattern */\n\n  zFull = (char*)sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);\n  if( zFull==0 ) return SQLITE_NOMEM;\n  rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,\n                                      gQuota.sThisVfs.mxPathname+1, zFull);\n  if( rc ){\n    sqlite3_free(zFull);\n    return rc;\n  }\n\n  /* Figure out the length of the full pathname.  If the name ends with\n  ** / (or \\ on windows) then remove the trailing /.\n  */\n  nFull = strlen(zFull);\n  if( nFull>0 && (zFull[nFull-1]=='/' || zFull[nFull-1]=='\\\\') ){\n    nFull--;\n    zFull[nFull] = 0;\n  }\n\n  quotaEnter();\n  pGroup = quotaGroupFind(zFull);\n  if( pGroup ){\n    for(pFile=pGroup->pFiles; pFile && rc==SQLITE_OK; pFile=pNextFile){\n      pNextFile = pFile->pNext;\n      diff = strncmp(zFull, pFile->zFilename, nFull);\n      if( diff==0 && ((c = pFile->zFilename[nFull])==0 || c=='/' || c=='\\\\') ){\n        if( pFile->nRef ){\n          pFile->deleteOnClose = 1;\n        }else{\n          rc = gQuota.pOrigVfs->xDelete(gQuota.pOrigVfs, pFile->zFilename, 0);\n          quotaRemoveFile(pFile);\n          quotaGroupDeref(pGroup);\n        }\n      }\n    }\n  }\n  quotaLeave();\n  sqlite3_free(zFull);\n  return rc;\n}\n\n/***************************** Test Code ***********************************/\n#ifdef SQLITE_TEST\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\n/*\n** Argument passed to a TCL quota-over-limit callback.\n*/\ntypedef struct TclQuotaCallback TclQuotaCallback;\nstruct TclQuotaCallback {\n  Tcl_Interp *interp;    /* Interpreter in which to run the script */\n  Tcl_Obj *pScript;      /* Script to be run */\n};\n\nextern const char *sqlite3ErrName(int);\n\n\n/*\n** This is the callback from a quota-over-limit.\n*/\nstatic void tclQuotaCallback(\n  const char *zFilename,          /* Name of file whose size increases */\n  sqlite3_int64 *piLimit,         /* IN/OUT: The current limit */\n  sqlite3_int64 iSize,            /* Total size of all files in the group */\n  void *pArg                      /* Client data */\n){\n  TclQuotaCallback *p;            /* Callback script object */\n  Tcl_Obj *pEval;                 /* Script to evaluate */\n  Tcl_Obj *pVarname;              /* Name of variable to pass as 2nd arg */\n  unsigned int rnd;               /* Random part of pVarname */\n  int rc;                         /* Tcl error code */\n\n  p = (TclQuotaCallback *)pArg;\n  if( p==0 ) return;\n\n  pVarname = Tcl_NewStringObj(\"::piLimit_\", -1);\n  Tcl_IncrRefCount(pVarname);\n  sqlite3_randomness(sizeof(rnd), (void *)&rnd);\n  Tcl_AppendObjToObj(pVarname, Tcl_NewIntObj((int)(rnd&0x7FFFFFFF)));\n  Tcl_ObjSetVar2(p->interp, pVarname, 0, Tcl_NewWideIntObj(*piLimit), 0);\n\n  pEval = Tcl_DuplicateObj(p->pScript);\n  Tcl_IncrRefCount(pEval);\n  Tcl_ListObjAppendElement(0, pEval, Tcl_NewStringObj(zFilename, -1));\n  Tcl_ListObjAppendElement(0, pEval, pVarname);\n  Tcl_ListObjAppendElement(0, pEval, Tcl_NewWideIntObj(iSize));\n  rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);\n\n  if( rc==TCL_OK ){\n    Tcl_WideInt x;\n    Tcl_Obj *pLimit = Tcl_ObjGetVar2(p->interp, pVarname, 0, 0);\n    rc = Tcl_GetWideIntFromObj(p->interp, pLimit, &x);\n    *piLimit = x;\n    Tcl_UnsetVar(p->interp, Tcl_GetString(pVarname), 0);\n  }\n\n  Tcl_DecrRefCount(pEval);\n  Tcl_DecrRefCount(pVarname);\n  if( rc!=TCL_OK ) Tcl_BackgroundError(p->interp);\n}\n\n/*\n** Destructor for a TCL quota-over-limit callback.\n*/\nstatic void tclCallbackDestructor(void *pObj){\n  TclQuotaCallback *p = (TclQuotaCallback*)pObj;\n  if( p ){\n    Tcl_DecrRefCount(p->pScript);\n    sqlite3_free((char *)p);\n  }\n}\n\n/*\n** tclcmd: sqlite3_quota_initialize NAME MAKEDEFAULT\n*/\nstatic int SQLITE_TCLAPI test_quota_initialize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zName;              /* Name of new quota VFS */\n  int makeDefault;                /* True to make the new VFS the default */\n  int rc;                         /* Value returned by quota_initialize() */\n\n  /* Process arguments */\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"NAME MAKEDEFAULT\");\n    return TCL_ERROR;\n  }\n  zName = Tcl_GetString(objv[1]);\n  if( Tcl_GetBooleanFromObj(interp, objv[2], &makeDefault) ) return TCL_ERROR;\n  if( zName[0]=='\\0' ) zName = 0;\n\n  /* Call sqlite3_quota_initialize() */\n  rc = sqlite3_quota_initialize(zName, makeDefault);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_shutdown\n*/\nstatic int SQLITE_TCLAPI test_quota_shutdown(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int rc;                         /* Value returned by quota_shutdown() */\n\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  /* Call sqlite3_quota_shutdown() */\n  rc = sqlite3_quota_shutdown();\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_set PATTERN LIMIT SCRIPT\n*/\nstatic int SQLITE_TCLAPI test_quota_set(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zPattern;           /* File pattern to configure */\n  Tcl_WideInt iLimit;             /* Initial quota in bytes */\n  Tcl_Obj *pScript;               /* Tcl script to invoke to increase quota */\n  int rc;                         /* Value returned by quota_set() */\n  TclQuotaCallback *p;            /* Callback object */\n  int nScript;                    /* Length of callback script */\n  void (*xDestroy)(void*);        /* Optional destructor for pArg */\n  void (*xCallback)(const char *, sqlite3_int64 *, sqlite3_int64, void *);\n\n  /* Process arguments */\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PATTERN LIMIT SCRIPT\");\n    return TCL_ERROR;\n  }\n  zPattern = Tcl_GetString(objv[1]);\n  if( Tcl_GetWideIntFromObj(interp, objv[2], &iLimit) ) return TCL_ERROR;\n  pScript = objv[3];\n  Tcl_GetStringFromObj(pScript, &nScript);\n\n  if( nScript>0 ){\n    /* Allocate a TclQuotaCallback object */\n    p = (TclQuotaCallback *)sqlite3_malloc(sizeof(TclQuotaCallback));\n    if( !p ){\n      Tcl_SetResult(interp, (char *)\"SQLITE_NOMEM\", TCL_STATIC);\n      return TCL_OK;\n    }\n    memset(p, 0, sizeof(TclQuotaCallback));\n    p->interp = interp;\n    Tcl_IncrRefCount(pScript);\n    p->pScript = pScript;\n    xDestroy = tclCallbackDestructor;\n    xCallback = tclQuotaCallback;\n  }else{\n    p = 0;\n    xDestroy = 0;\n    xCallback = 0;\n  }\n\n  /* Invoke sqlite3_quota_set() */\n  rc = sqlite3_quota_set(zPattern, iLimit, xCallback, (void*)p, xDestroy);\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_file FILENAME\n*/\nstatic int SQLITE_TCLAPI test_quota_file(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zFilename;          /* File pattern to configure */\n  int rc;                         /* Value returned by quota_file() */\n\n  /* Process arguments */\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME\");\n    return TCL_ERROR;\n  }\n  zFilename = Tcl_GetString(objv[1]);\n\n  /* Invoke sqlite3_quota_file() */\n  rc = sqlite3_quota_file(zFilename);\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n  return TCL_OK;\n}\n\n/*\n** tclcmd:  sqlite3_quota_dump\n*/\nstatic int SQLITE_TCLAPI test_quota_dump(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_Obj *pResult;\n  Tcl_Obj *pGroupTerm;\n  Tcl_Obj *pFileTerm;\n  quotaGroup *pGroup;\n  quotaFile *pFile;\n\n  pResult = Tcl_NewObj();\n  quotaEnter();\n  for(pGroup=gQuota.pGroup; pGroup; pGroup=pGroup->pNext){\n    pGroupTerm = Tcl_NewObj();\n    Tcl_ListObjAppendElement(interp, pGroupTerm,\n          Tcl_NewStringObj(pGroup->zPattern, -1));\n    Tcl_ListObjAppendElement(interp, pGroupTerm,\n          Tcl_NewWideIntObj(pGroup->iLimit));\n    Tcl_ListObjAppendElement(interp, pGroupTerm,\n          Tcl_NewWideIntObj(pGroup->iSize));\n    for(pFile=pGroup->pFiles; pFile; pFile=pFile->pNext){\n      int i;\n      char zTemp[1000];\n      pFileTerm = Tcl_NewObj();\n      sqlite3_snprintf(sizeof(zTemp), zTemp, \"%s\", pFile->zFilename);\n      for(i=0; zTemp[i]; i++){ if( zTemp[i]=='\\\\' ) zTemp[i] = '/'; }\n      Tcl_ListObjAppendElement(interp, pFileTerm,\n            Tcl_NewStringObj(zTemp, -1));\n      Tcl_ListObjAppendElement(interp, pFileTerm,\n            Tcl_NewWideIntObj(pFile->iSize));\n      Tcl_ListObjAppendElement(interp, pFileTerm,\n            Tcl_NewWideIntObj(pFile->nRef));\n      Tcl_ListObjAppendElement(interp, pFileTerm,\n            Tcl_NewWideIntObj(pFile->deleteOnClose));\n      Tcl_ListObjAppendElement(interp, pGroupTerm, pFileTerm);\n    }\n    Tcl_ListObjAppendElement(interp, pResult, pGroupTerm);\n  }\n  quotaLeave();\n  Tcl_SetObjResult(interp, pResult);\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_fopen FILENAME MODE\n*/\nstatic int SQLITE_TCLAPI test_quota_fopen(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zFilename;          /* File pattern to configure */\n  const char *zMode;              /* Mode string */\n  quota_FILE *p;                  /* Open string object */\n  char zReturn[50];               /* Name of pointer to return */\n\n  /* Process arguments */\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME MODE\");\n    return TCL_ERROR;\n  }\n  zFilename = Tcl_GetString(objv[1]);\n  zMode = Tcl_GetString(objv[2]);\n  p = sqlite3_quota_fopen(zFilename, zMode);\n  sqlite3_snprintf(sizeof(zReturn), zReturn, \"%p\", p);\n  Tcl_SetResult(interp, zReturn, TCL_VOLATILE);\n  return TCL_OK;\n}\n\n/* Defined in test1.c */\nextern void *sqlite3TestTextToPtr(const char*);\n\n/*\n** tclcmd: sqlite3_quota_fread HANDLE SIZE NELEM\n*/\nstatic int SQLITE_TCLAPI test_quota_fread(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  char *zBuf;\n  int sz;\n  int nElem;\n  size_t got;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE SIZE NELEM\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  if( Tcl_GetIntFromObj(interp, objv[2], &sz) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &nElem) ) return TCL_ERROR;\n  zBuf = (char*)sqlite3_malloc( sz*nElem + 1 );\n  if( zBuf==0 ){\n    Tcl_SetResult(interp, \"out of memory\", TCL_STATIC);\n    return TCL_ERROR;\n  }\n  got = sqlite3_quota_fread(zBuf, sz, nElem, p);\n  zBuf[got*sz] = 0;\n  Tcl_SetResult(interp, zBuf, TCL_VOLATILE);\n  sqlite3_free(zBuf);\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_fwrite HANDLE SIZE NELEM CONTENT\n*/\nstatic int SQLITE_TCLAPI test_quota_fwrite(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  char *zBuf;\n  int sz;\n  int nElem;\n  size_t got;\n\n  if( objc!=5 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE SIZE NELEM CONTENT\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  if( Tcl_GetIntFromObj(interp, objv[2], &sz) ) return TCL_ERROR;\n  if( Tcl_GetIntFromObj(interp, objv[3], &nElem) ) return TCL_ERROR;\n  zBuf = Tcl_GetString(objv[4]);\n  got = sqlite3_quota_fwrite(zBuf, sz, nElem, p);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(got));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_fclose HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_fclose(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  rc = sqlite3_quota_fclose(p);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_fflush HANDLE ?HARDSYNC?\n*/\nstatic int SQLITE_TCLAPI test_quota_fflush(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  int rc;\n  int doSync = 0;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE ?HARDSYNC?\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  if( objc==3 ){\n    if( Tcl_GetBooleanFromObj(interp, objv[2], &doSync) ) return TCL_ERROR;\n  }\n  rc = sqlite3_quota_fflush(p, doSync);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_fseek HANDLE OFFSET WHENCE\n*/\nstatic int SQLITE_TCLAPI test_quota_fseek(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  int ofst;\n  const char *zWhence;\n  int whence;\n  int rc;\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE OFFSET WHENCE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  if( Tcl_GetIntFromObj(interp, objv[2], &ofst) ) return TCL_ERROR;\n  zWhence = Tcl_GetString(objv[3]);\n  if( strcmp(zWhence, \"SEEK_SET\")==0 ){\n    whence = SEEK_SET;\n  }else if( strcmp(zWhence, \"SEEK_CUR\")==0 ){\n    whence = SEEK_CUR;\n  }else if( strcmp(zWhence, \"SEEK_END\")==0 ){\n    whence = SEEK_END;\n  }else{\n    Tcl_AppendResult(interp,\n           \"WHENCE should be SEEK_SET, SEEK_CUR, or SEEK_END\", (char*)0);\n    return TCL_ERROR;\n  }\n  rc = sqlite3_quota_fseek(p, ofst, whence);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_rewind HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_rewind(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  sqlite3_quota_rewind(p);\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_ftell HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_ftell(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  sqlite3_int64 x;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  x = sqlite3_quota_ftell(p);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_ftruncate HANDLE SIZE\n*/\nstatic int SQLITE_TCLAPI test_quota_ftruncate(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  sqlite3_int64 x;\n  Tcl_WideInt w;\n  int rc;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE SIZE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  if( Tcl_GetWideIntFromObj(interp, objv[2], &w) ) return TCL_ERROR;\n  x = (sqlite3_int64)w;\n  rc = sqlite3_quota_ftruncate(p, x);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_file_size HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_file_size(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  sqlite3_int64 x;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  x = sqlite3_quota_file_size(p);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_file_truesize HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_file_truesize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  sqlite3_int64 x;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  x = sqlite3_quota_file_truesize(p);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_file_mtime HANDLE\n*/\nstatic int SQLITE_TCLAPI test_quota_file_mtime(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  time_t t;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  t = 0;\n  sqlite3_quota_file_mtime(p, &t);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(t));\n  return TCL_OK;\n}\n\n\n/*\n** tclcmd: sqlite3_quota_remove FILENAME\n*/\nstatic int SQLITE_TCLAPI test_quota_remove(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zFilename;          /* File pattern to configure */\n  int rc;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"FILENAME\");\n    return TCL_ERROR;\n  }\n  zFilename = Tcl_GetString(objv[1]);\n  rc = sqlite3_quota_remove(zFilename);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_glob PATTERN TEXT\n**\n** Test the glob pattern matching.  Return 1 if TEXT matches PATTERN\n** and return 0 if it does not.\n*/\nstatic int SQLITE_TCLAPI test_quota_glob(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zPattern;          /* The glob pattern */\n  const char *zText;             /* Text to compare agains the pattern */\n  int rc;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"PATTERN TEXT\");\n    return TCL_ERROR;\n  }\n  zPattern = Tcl_GetString(objv[1]);\n  zText = Tcl_GetString(objv[2]);\n  rc = quotaStrglob(zPattern, zText);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_file_available HANDLE\n**\n** Return the number of bytes from the current file point to the end of\n** the file.\n*/\nstatic int SQLITE_TCLAPI test_quota_file_available(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  sqlite3_int64 x;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  x = sqlite3_quota_file_available(p);\n  Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));\n  return TCL_OK;\n}\n\n/*\n** tclcmd: sqlite3_quota_ferror HANDLE\n**\n** Return true if the file handle is in the error state.\n*/\nstatic int SQLITE_TCLAPI test_quota_ferror(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  quota_FILE *p;\n  int x;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"HANDLE\");\n    return TCL_ERROR;\n  }\n  p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  x = sqlite3_quota_ferror(p);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(x));\n  return TCL_OK;\n}\n\n/*\n** This routine registers the custom TCL commands defined in this\n** module.  This should be the only procedure visible from outside\n** of this module.\n*/\nint Sqlitequota_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n  } aCmd[] = {\n    { \"sqlite3_quota_initialize\",    test_quota_initialize },\n    { \"sqlite3_quota_shutdown\",      test_quota_shutdown },\n    { \"sqlite3_quota_set\",           test_quota_set },\n    { \"sqlite3_quota_file\",          test_quota_file },\n    { \"sqlite3_quota_dump\",          test_quota_dump },\n    { \"sqlite3_quota_fopen\",         test_quota_fopen },\n    { \"sqlite3_quota_fread\",         test_quota_fread },\n    { \"sqlite3_quota_fwrite\",        test_quota_fwrite },\n    { \"sqlite3_quota_fclose\",        test_quota_fclose },\n    { \"sqlite3_quota_fflush\",        test_quota_fflush },\n    { \"sqlite3_quota_fseek\",         test_quota_fseek },\n    { \"sqlite3_quota_rewind\",        test_quota_rewind },\n    { \"sqlite3_quota_ftell\",         test_quota_ftell },\n    { \"sqlite3_quota_ftruncate\",     test_quota_ftruncate },\n    { \"sqlite3_quota_file_size\",     test_quota_file_size },\n    { \"sqlite3_quota_file_truesize\", test_quota_file_truesize },\n    { \"sqlite3_quota_file_mtime\",    test_quota_file_mtime },\n    { \"sqlite3_quota_remove\",        test_quota_remove },\n    { \"sqlite3_quota_glob\",          test_quota_glob },\n    { \"sqlite3_quota_file_available\",test_quota_file_available },\n    { \"sqlite3_quota_ferror\",        test_quota_ferror },\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);\n  }\n\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_quota.h",
    "content": "/*\n** 2011 December 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the interface definition for the quota a VFS shim.\n**\n** This particular shim enforces a quota system on files.  One or more\n** database files are in a \"quota group\" that is defined by a GLOB\n** pattern.  A quota is set for the combined size of all files in the\n** the group.  A quota of zero means \"no limit\".  If the total size\n** of all files in the quota group is greater than the limit, then\n** write requests that attempt to enlarge a file fail with SQLITE_FULL.\n**\n** However, before returning SQLITE_FULL, the write requests invoke\n** a callback function that is configurable for each quota group.\n** This callback has the opportunity to enlarge the quota.  If the\n** callback does enlarge the quota such that the total size of all\n** files within the group is less than the new quota, then the write\n** continues as if nothing had happened.\n*/\n#ifndef _QUOTA_H_\n#include \"sqlite3.h\"\n#include <stdio.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n\n/* Make this callable from C++ */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n** Initialize the quota VFS shim.  Use the VFS named zOrigVfsName\n** as the VFS that does the actual work.  Use the default if\n** zOrigVfsName==NULL.  \n**\n** The quota VFS shim is named \"quota\".  It will become the default\n** VFS if makeDefault is non-zero.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once\n** during start-up.\n*/\nint sqlite3_quota_initialize(const char *zOrigVfsName, int makeDefault);\n\n/*\n** Shutdown the quota system.\n**\n** All SQLite database connections must be closed before calling this\n** routine.\n**\n** THIS ROUTINE IS NOT THREADSAFE.  Call this routine exactly once while\n** shutting down in order to free all remaining quota groups.\n*/\nint sqlite3_quota_shutdown(void);\n\n/*\n** Create or destroy a quota group.\n**\n** The quota group is defined by the zPattern.  When calling this routine\n** with a zPattern for a quota group that already exists, this routine\n** merely updates the iLimit, xCallback, and pArg values for that quota\n** group.  If zPattern is new, then a new quota group is created.\n**\n** The zPattern is always compared against the full pathname of the file.\n** Even if APIs are called with relative pathnames, SQLite converts the\n** name to a full pathname before comparing it against zPattern.  zPattern\n** is a glob pattern with the following matching rules:\n**\n**      '*'       Matches any sequence of zero or more characters.\n**\n**      '?'       Matches exactly one character.\n**\n**     [...]      Matches one character from the enclosed list of\n**                characters.  \"]\" can be part of the list if it is\n**                the first character.  Within the list \"X-Y\" matches\n**                characters X or Y or any character in between the\n**                two.  Ex:  \"[0-9]\" matches any digit.\n**\n**     [^...]     Matches one character not in the enclosed list.\n**\n**     /          Matches either / or \\.  This allows glob patterns\n**                containing / to work on both unix and windows.\n**\n** Note that, unlike unix shell globbing, the directory separator \"/\"\n** can match a wildcard.  So, for example, the pattern \"/abc/xyz/\" \"*\"\n** matches any files anywhere in the directory hierarchy beneath\n** /abc/xyz.\n**\n** The glob algorithm works on bytes.  Multi-byte UTF8 characters are\n** matched as if each byte were a separate character.\n**\n** If the iLimit for a quota group is set to zero, then the quota group\n** is disabled and will be deleted when the last database connection using\n** the quota group is closed.\n**\n** Calling this routine on a zPattern that does not exist and with a\n** zero iLimit is a no-op.\n**\n** A quota group must exist with a non-zero iLimit prior to opening\n** database connections if those connections are to participate in the\n** quota group.  Creating a quota group does not affect database connections\n** that are already open.\n**\n** The patterns that define the various quota groups should be distinct.\n** If the same filename matches more than one quota group pattern, then\n** the behavior of this package is undefined.\n*/\nint sqlite3_quota_set(\n  const char *zPattern,           /* The filename pattern */\n  sqlite3_int64 iLimit,           /* New quota to set for this quota group */\n  void (*xCallback)(              /* Callback invoked when going over quota */\n     const char *zFilename,         /* Name of file whose size increases */\n     sqlite3_int64 *piLimit,        /* IN/OUT: The current limit */\n     sqlite3_int64 iSize,           /* Total size of all files in the group */\n     void *pArg                     /* Client data */\n  ),\n  void *pArg,                     /* client data passed thru to callback */\n  void (*xDestroy)(void*)         /* Optional destructor for pArg */\n);\n\n/*\n** Bring the named file under quota management, assuming its name matches\n** the glob pattern of some quota group.  Or if it is already under\n** management, update its size.  If zFilename does not match the glob\n** pattern of any quota group, this routine is a no-op.\n*/\nint sqlite3_quota_file(const char *zFilename);\n\n/*\n** The following object serves the same role as FILE in the standard C\n** library.  It represents an open connection to a file on disk for I/O.\n**\n** A single quota_FILE should not be used by two or more threads at the\n** same time.  Multiple threads can be using different quota_FILE objects\n** simultaneously, but not the same quota_FILE object.\n*/\ntypedef struct quota_FILE quota_FILE;\n\n/*\n** Create a new quota_FILE object used to read and/or write to the\n** file zFilename.  The zMode parameter is as with standard library zMode.\n*/\nquota_FILE *sqlite3_quota_fopen(const char *zFilename, const char *zMode);\n\n/*\n** Perform I/O against a quota_FILE object.  When doing writes, the\n** quota mechanism may result in a short write, in order to prevent\n** the sum of sizes of all files from going over quota.\n*/\nsize_t sqlite3_quota_fread(void*, size_t, size_t, quota_FILE*);\nsize_t sqlite3_quota_fwrite(const void*, size_t, size_t, quota_FILE*);\n\n/*\n** Flush all written content held in memory buffers out to disk.\n** This is the equivalent of fflush() in the standard library.\n**\n** If the hardSync parameter is true (non-zero) then this routine\n** also forces OS buffers to disk - the equivalent of fsync().\n**\n** This routine return zero on success and non-zero if something goes\n** wrong.\n*/\nint sqlite3_quota_fflush(quota_FILE*, int hardSync);\n\n/*\n** Close a quota_FILE object and free all associated resources.  The\n** file remains under quota management.\n*/\nint sqlite3_quota_fclose(quota_FILE*);\n\n/*\n** Move the read/write pointer for a quota_FILE object.  Or tell the\n** current location of the read/write pointer.\n*/\nint sqlite3_quota_fseek(quota_FILE*, long, int);\nvoid sqlite3_quota_rewind(quota_FILE*);\nlong sqlite3_quota_ftell(quota_FILE*);\n\n/*\n** Test the error indicator for the given file.\n**\n** Return non-zero if the error indicator is set.\n*/\nint sqlite3_quota_ferror(quota_FILE*);\n\n/*\n** Truncate a file previously opened by sqlite3_quota_fopen().  Return\n** zero on success and non-zero on any kind of failure.\n**\n** The newSize argument must be less than or equal to the current file size.\n** Any attempt to \"truncate\" a file to a larger size results in \n** undefined behavior.\n*/\nint sqlite3_quota_ftruncate(quota_FILE*, sqlite3_int64 newSize);\n\n/*\n** Return the last modification time of the opened file, in seconds\n** since 1970.\n*/\nint sqlite3_quota_file_mtime(quota_FILE*, time_t *pTime);\n\n/*\n** Return the size of the file as it is known to the quota system.\n**\n** This size might be different from the true size of the file on\n** disk if some outside process has modified the file without using the\n** quota mechanism, or if calls to sqlite3_quota_fwrite() have occurred\n** which have increased the file size, but those writes have not yet been\n** forced to disk using sqlite3_quota_fflush().\n**\n** Return -1 if the file is not participating in quota management.\n*/\nsqlite3_int64 sqlite3_quota_file_size(quota_FILE*);\n\n/*\n** Return the true size of the file.\n**\n** The true size should be the same as the size of the file as known\n** to the quota system, however the sizes might be different if the\n** file has been extended or truncated via some outside process or if\n** pending writes have not yet been flushed to disk.\n**\n** Return -1 if the file does not exist or if the size of the file\n** cannot be determined for some reason.\n*/\nsqlite3_int64 sqlite3_quota_file_truesize(quota_FILE*);\n\n/*\n** Determine the amount of data in bytes available for reading\n** in the given file.\n**\n** Return -1 if the amount cannot be determined for some reason.\n*/\nlong sqlite3_quota_file_available(quota_FILE*);\n\n/*\n** Delete a file from the disk, if that file is under quota management.\n** Adjust quotas accordingly.\n**\n** If zFilename is the name of a directory that matches one of the\n** quota glob patterns, then all files under quota management that\n** are contained within that directory are deleted.\n**\n** A standard SQLite result code is returned (SQLITE_OK, SQLITE_NOMEM, etc.)\n** When deleting a directory of files, if the deletion of any one\n** file fails (for example due to an I/O error), then this routine\n** returns immediately, with the error code, and does not try to \n** delete any of the other files in the specified directory.\n**\n** All files are removed from quota management and deleted from disk.\n** However, no attempt is made to remove empty directories.\n**\n** This routine is a no-op for files that are not under quota management.\n*/\nint sqlite3_quota_remove(const char *zFilename);\n\n#ifdef __cplusplus\n}  /* end of the 'extern \"C\"' block */\n#endif\n#endif /* _QUOTA_H_ */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_rtree.c",
    "content": "/*\n** 2010 August 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing all sorts of SQLite interfaces. This code\n** is not included in the SQLite library. \n*/\n\n#include \"sqlite3.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n/* Solely for the UNUSED_PARAMETER() macro. */\n#include \"sqliteInt.h\"\n\n#ifdef SQLITE_ENABLE_RTREE\n/* \n** Type used to cache parameter information for the \"circle\" r-tree geometry\n** callback.\n*/\ntypedef struct Circle Circle;\nstruct Circle {\n  struct Box {\n    double xmin;\n    double xmax;\n    double ymin;\n    double ymax;\n  } aBox[2];\n  double centerx;\n  double centery;\n  double radius;\n  double mxArea;\n  int eScoreType;\n};\n\n/*\n** Destructor function for Circle objects allocated by circle_geom().\n*/\nstatic void circle_del(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** Implementation of \"circle\" r-tree geometry callback.\n*/\nstatic int circle_geom(\n  sqlite3_rtree_geometry *p,\n  int nCoord, \n  sqlite3_rtree_dbl *aCoord,\n  int *pRes\n){\n  int i;                          /* Iterator variable */\n  Circle *pCircle;                /* Structure defining circular region */\n  double xmin, xmax;              /* X dimensions of box being tested */\n  double ymin, ymax;              /* X dimensions of box being tested */\n\n  xmin = aCoord[0];\n  xmax = aCoord[1];\n  ymin = aCoord[2];\n  ymax = aCoord[3];\n  pCircle = (Circle *)p->pUser;\n  if( pCircle==0 ){\n    /* If pUser is still 0, then the parameter values have not been tested\n    ** for correctness or stored into a Circle structure yet. Do this now. */\n\n    /* This geometry callback is for use with a 2-dimensional r-tree table.\n    ** Return an error if the table does not have exactly 2 dimensions. */\n    if( nCoord!=4 ) return SQLITE_ERROR;\n\n    /* Test that the correct number of parameters (3) have been supplied,\n    ** and that the parameters are in range (that the radius of the circle \n    ** radius is greater than zero). */\n    if( p->nParam!=3 || p->aParam[2]<0.0 ) return SQLITE_ERROR;\n\n    /* Allocate a structure to cache parameter data in. Return SQLITE_NOMEM\n    ** if the allocation fails. */\n    pCircle = (Circle *)(p->pUser = sqlite3_malloc(sizeof(Circle)));\n    if( !pCircle ) return SQLITE_NOMEM;\n    p->xDelUser = circle_del;\n\n    /* Record the center and radius of the circular region. One way that\n    ** tested bounding boxes that intersect the circular region are detected\n    ** is by testing if each corner of the bounding box lies within radius\n    ** units of the center of the circle. */\n    pCircle->centerx = p->aParam[0];\n    pCircle->centery = p->aParam[1];\n    pCircle->radius = p->aParam[2];\n\n    /* Define two bounding box regions. The first, aBox[0], extends to\n    ** infinity in the X dimension. It covers the same range of the Y dimension\n    ** as the circular region. The second, aBox[1], extends to infinity in\n    ** the Y dimension and is constrained to the range of the circle in the\n    ** X dimension.\n    **\n    ** Then imagine each box is split in half along its short axis by a line\n    ** that intersects the center of the circular region. A bounding box\n    ** being tested can be said to intersect the circular region if it contains\n    ** points from each half of either of the two infinite bounding boxes.\n    */\n    pCircle->aBox[0].xmin = pCircle->centerx;\n    pCircle->aBox[0].xmax = pCircle->centerx;\n    pCircle->aBox[0].ymin = pCircle->centery + pCircle->radius;\n    pCircle->aBox[0].ymax = pCircle->centery - pCircle->radius;\n    pCircle->aBox[1].xmin = pCircle->centerx + pCircle->radius;\n    pCircle->aBox[1].xmax = pCircle->centerx - pCircle->radius;\n    pCircle->aBox[1].ymin = pCircle->centery;\n    pCircle->aBox[1].ymax = pCircle->centery;\n    pCircle->mxArea = (xmax - xmin)*(ymax - ymin) + 1.0;\n  }\n\n  /* Check if any of the 4 corners of the bounding-box being tested lie \n  ** inside the circular region. If they do, then the bounding-box does\n  ** intersect the region of interest. Set the output variable to true and\n  ** return SQLITE_OK in this case. */\n  for(i=0; i<4; i++){\n    double x = (i&0x01) ? xmax : xmin;\n    double y = (i&0x02) ? ymax : ymin;\n    double d2;\n    \n    d2  = (x-pCircle->centerx)*(x-pCircle->centerx);\n    d2 += (y-pCircle->centery)*(y-pCircle->centery);\n    if( d2<(pCircle->radius*pCircle->radius) ){\n      *pRes = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  /* Check if the bounding box covers any other part of the circular region.\n  ** See comments above for a description of how this test works. If it does\n  ** cover part of the circular region, set the output variable to true\n  ** and return SQLITE_OK. */\n  for(i=0; i<2; i++){\n    if( xmin<=pCircle->aBox[i].xmin \n     && xmax>=pCircle->aBox[i].xmax \n     && ymin<=pCircle->aBox[i].ymin \n     && ymax>=pCircle->aBox[i].ymax \n    ){\n      *pRes = 1;\n      return SQLITE_OK;\n    }\n  }\n\n  /* The specified bounding box does not intersect the circular region. Set\n  ** the output variable to zero and return SQLITE_OK. */\n  *pRes = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Implementation of \"circle\" r-tree geometry callback using the \n** 2nd-generation interface that allows scoring.\n**\n** Two calling forms:\n**\n**          Qcircle(X,Y,Radius,eType)        -- All values are doubles\n**          Qcircle('x:X y:Y r:R e:ETYPE')   -- Single string parameter\n*/\nstatic int circle_query_func(sqlite3_rtree_query_info *p){\n  int i;                          /* Iterator variable */\n  Circle *pCircle;                /* Structure defining circular region */\n  double xmin, xmax;              /* X dimensions of box being tested */\n  double ymin, ymax;              /* X dimensions of box being tested */\n  int nWithin = 0;                /* Number of corners inside the circle */\n\n  xmin = p->aCoord[0];\n  xmax = p->aCoord[1];\n  ymin = p->aCoord[2];\n  ymax = p->aCoord[3];\n  pCircle = (Circle *)p->pUser;\n  if( pCircle==0 ){\n    /* If pUser is still 0, then the parameter values have not been tested\n    ** for correctness or stored into a Circle structure yet. Do this now. */\n\n    /* This geometry callback is for use with a 2-dimensional r-tree table.\n    ** Return an error if the table does not have exactly 2 dimensions. */\n    if( p->nCoord!=4 ) return SQLITE_ERROR;\n\n    /* Test that the correct number of parameters (1 or 4) have been supplied.\n    */\n    if( p->nParam!=4 && p->nParam!=1 ) return SQLITE_ERROR;\n\n    /* Allocate a structure to cache parameter data in. Return SQLITE_NOMEM\n    ** if the allocation fails. */\n    pCircle = (Circle *)(p->pUser = sqlite3_malloc(sizeof(Circle)));\n    if( !pCircle ) return SQLITE_NOMEM;\n    p->xDelUser = circle_del;\n\n    /* Record the center and radius of the circular region. One way that\n    ** tested bounding boxes that intersect the circular region are detected\n    ** is by testing if each corner of the bounding box lies within radius\n    ** units of the center of the circle. */\n    if( p->nParam==4 ){\n      pCircle->centerx = p->aParam[0];\n      pCircle->centery = p->aParam[1];\n      pCircle->radius = p->aParam[2];\n      pCircle->eScoreType = (int)p->aParam[3];\n    }else{\n      const char *z = (const char*)sqlite3_value_text(p->apSqlParam[0]);\n      pCircle->centerx = 0.0;\n      pCircle->centery = 0.0;\n      pCircle->radius = 0.0;\n      pCircle->eScoreType = 0;\n      while( z && z[0] ){\n        if( z[0]=='r' && z[1]==':' ){\n          pCircle->radius = atof(&z[2]);\n        }else if( z[0]=='x' && z[1]==':' ){\n          pCircle->centerx = atof(&z[2]);\n        }else if( z[0]=='y' && z[1]==':' ){\n          pCircle->centery = atof(&z[2]);\n        }else if( z[0]=='e' && z[1]==':' ){\n          pCircle->eScoreType = (int)atof(&z[2]);\n        }else if( z[0]==' ' ){\n          z++;\n          continue;\n        }\n        while( z[0]!=0 && z[0]!=' ' ) z++;\n        while( z[0]==' ' ) z++;\n      }\n    }\n    if( pCircle->radius<0.0 ){\n      sqlite3_free(pCircle);\n      return SQLITE_NOMEM;\n    }\n\n    /* Define two bounding box regions. The first, aBox[0], extends to\n    ** infinity in the X dimension. It covers the same range of the Y dimension\n    ** as the circular region. The second, aBox[1], extends to infinity in\n    ** the Y dimension and is constrained to the range of the circle in the\n    ** X dimension.\n    **\n    ** Then imagine each box is split in half along its short axis by a line\n    ** that intersects the center of the circular region. A bounding box\n    ** being tested can be said to intersect the circular region if it contains\n    ** points from each half of either of the two infinite bounding boxes.\n    */\n    pCircle->aBox[0].xmin = pCircle->centerx;\n    pCircle->aBox[0].xmax = pCircle->centerx;\n    pCircle->aBox[0].ymin = pCircle->centery + pCircle->radius;\n    pCircle->aBox[0].ymax = pCircle->centery - pCircle->radius;\n    pCircle->aBox[1].xmin = pCircle->centerx + pCircle->radius;\n    pCircle->aBox[1].xmax = pCircle->centerx - pCircle->radius;\n    pCircle->aBox[1].ymin = pCircle->centery;\n    pCircle->aBox[1].ymax = pCircle->centery;\n    pCircle->mxArea = 200.0*200.0;\n  }\n\n  /* Check if any of the 4 corners of the bounding-box being tested lie \n  ** inside the circular region. If they do, then the bounding-box does\n  ** intersect the region of interest. Set the output variable to true and\n  ** return SQLITE_OK in this case. */\n  for(i=0; i<4; i++){\n    double x = (i&0x01) ? xmax : xmin;\n    double y = (i&0x02) ? ymax : ymin;\n    double d2;\n    \n    d2  = (x-pCircle->centerx)*(x-pCircle->centerx);\n    d2 += (y-pCircle->centery)*(y-pCircle->centery);\n    if( d2<(pCircle->radius*pCircle->radius) ) nWithin++;\n  }\n\n  /* Check if the bounding box covers any other part of the circular region.\n  ** See comments above for a description of how this test works. If it does\n  ** cover part of the circular region, set the output variable to true\n  ** and return SQLITE_OK. */\n  if( nWithin==0 ){\n    for(i=0; i<2; i++){\n      if( xmin<=pCircle->aBox[i].xmin \n       && xmax>=pCircle->aBox[i].xmax \n       && ymin<=pCircle->aBox[i].ymin \n       && ymax>=pCircle->aBox[i].ymax \n      ){\n        nWithin = 1;\n        break;\n      }\n    }\n  }\n\n  if( pCircle->eScoreType==1 ){\n    /* Depth first search */\n    p->rScore = p->iLevel;\n  }else if( pCircle->eScoreType==2 ){\n    /* Breadth first search */\n    p->rScore = 100 - p->iLevel;\n  }else if( pCircle->eScoreType==3 ){\n    /* Depth-first search, except sort the leaf nodes by area with\n    ** the largest area first */\n    if( p->iLevel==1 ){\n      p->rScore = 1.0 - (xmax-xmin)*(ymax-ymin)/pCircle->mxArea;\n      if( p->rScore<0.01 ) p->rScore = 0.01;\n    }else{\n      p->rScore = 0.0;\n    }\n  }else if( pCircle->eScoreType==4 ){\n    /* Depth-first search, except exclude odd rowids */\n    p->rScore = p->iLevel;\n    if( p->iRowid&1 ) nWithin = 0;\n  }else{\n    /* Breadth-first search, except exclude odd rowids */\n    p->rScore = 100 - p->iLevel;\n    if( p->iRowid&1 ) nWithin = 0;\n  }\n  if( nWithin==0 ){\n    p->eWithin = NOT_WITHIN;\n  }else if( nWithin>=4 ){\n    p->eWithin = FULLY_WITHIN;\n  }else{\n    p->eWithin = PARTLY_WITHIN;\n  }\n  return SQLITE_OK;\n}\n/*\n** Implementation of \"breadthfirstsearch\" r-tree geometry callback using the \n** 2nd-generation interface that allows scoring.\n**\n**     ... WHERE id MATCH breadthfirstsearch($x0,$x1,$y0,$y1) ...\n**\n** It returns all entries whose bounding boxes overlap with $x0,$x1,$y0,$y1.\n*/\nstatic int bfs_query_func(sqlite3_rtree_query_info *p){\n  double x0,x1,y0,y1;        /* Dimensions of box being tested */\n  double bx0,bx1,by0,by1;    /* Boundary of the query function */\n\n  if( p->nParam!=4 ) return SQLITE_ERROR;\n  x0 = p->aCoord[0];\n  x1 = p->aCoord[1];\n  y0 = p->aCoord[2];\n  y1 = p->aCoord[3];\n  bx0 = p->aParam[0];\n  bx1 = p->aParam[1];\n  by0 = p->aParam[2];\n  by1 = p->aParam[3];\n  p->rScore = 100 - p->iLevel;\n  if( p->eParentWithin==FULLY_WITHIN ){\n    p->eWithin = FULLY_WITHIN;\n  }else if( x0>=bx0 && x1<=bx1 && y0>=by0 && y1<=by1 ){\n    p->eWithin = FULLY_WITHIN;\n  }else if( x1>=bx0 && x0<=bx1 && y1>=by0 && y0<=by1 ){\n    p->eWithin = PARTLY_WITHIN;\n  }else{\n    p->eWithin = NOT_WITHIN;\n  }\n  return SQLITE_OK;\n}\n\n/* END of implementation of \"circle\" geometry callback.\n**************************************************************************\n*************************************************************************/\n\n#include <assert.h>\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\ntypedef struct Cube Cube;\nstruct Cube {\n  double x;\n  double y;\n  double z;\n  double width;\n  double height;\n  double depth;\n};\n\nstatic void cube_context_free(void *p){\n  sqlite3_free(p);\n}\n\n/*\n** The context pointer registered along with the 'cube' callback is\n** always ((void *)&gHere). This is just to facilitate testing, it is not\n** actually used for anything.\n*/\nstatic int gHere = 42;\n\n/*\n** Implementation of a simple r-tree geom callback to test for intersection\n** of r-tree rows with a \"cube\" shape. Cubes are defined by six scalar\n** coordinates as follows:\n**\n**   cube(x, y, z, width, height, depth)\n**\n** The width, height and depth parameters must all be greater than zero.\n*/\nstatic int cube_geom(\n  sqlite3_rtree_geometry *p,\n  int nCoord,\n  sqlite3_rtree_dbl *aCoord,\n  int *piRes\n){\n  Cube *pCube = (Cube *)p->pUser;\n\n  assert( p->pContext==(void *)&gHere );\n\n  if( pCube==0 ){\n    if( p->nParam!=6 || nCoord!=6\n     || p->aParam[3]<=0.0 || p->aParam[4]<=0.0 || p->aParam[5]<=0.0\n    ){\n      return SQLITE_ERROR;\n    }\n    pCube = (Cube *)sqlite3_malloc(sizeof(Cube));\n    if( !pCube ){\n      return SQLITE_NOMEM;\n    }\n    pCube->x = p->aParam[0];\n    pCube->y = p->aParam[1];\n    pCube->z = p->aParam[2];\n    pCube->width = p->aParam[3];\n    pCube->height = p->aParam[4];\n    pCube->depth = p->aParam[5];\n\n    p->pUser = (void *)pCube;\n    p->xDelUser = cube_context_free;\n  }\n\n  assert( nCoord==6 );\n  *piRes = 0;\n  if( aCoord[0]<=(pCube->x+pCube->width)\n   && aCoord[1]>=pCube->x\n   && aCoord[2]<=(pCube->y+pCube->height)\n   && aCoord[3]>=pCube->y\n   && aCoord[4]<=(pCube->z+pCube->depth)\n   && aCoord[5]>=pCube->z\n  ){\n    *piRes = 1;\n  }\n\n  return SQLITE_OK;\n}\n#endif /* SQLITE_ENABLE_RTREE */\n\nstatic int SQLITE_TCLAPI register_cube_geom(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_ENABLE_RTREE\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(interp);\n  UNUSED_PARAMETER(objc);\n  UNUSED_PARAMETER(objv);\n#else\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  extern const char *sqlite3ErrName(int);\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_rtree_geometry_callback(db, \"cube\", cube_geom, (void *)&gHere);\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n#endif\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI register_circle_geom(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n#ifndef SQLITE_ENABLE_RTREE\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(interp);\n  UNUSED_PARAMETER(objc);\n  UNUSED_PARAMETER(objv);\n#else\n  extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);\n  extern const char *sqlite3ErrName(int);\n  sqlite3 *db;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  rc = sqlite3_rtree_geometry_callback(db, \"circle\", circle_geom, 0);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_rtree_query_callback(db, \"Qcircle\",\n                                      circle_query_func, 0, 0);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3_rtree_query_callback(db, \"breadthfirstsearch\",\n                                      bfs_query_func, 0, 0);\n  }\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_STATIC);\n#endif\n  return TCL_OK;\n}\n\nint Sqlitetestrtree_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"register_cube_geom\", register_cube_geom, 0, 0);\n  Tcl_CreateObjCommand(interp, \"register_circle_geom\",register_circle_geom,0,0);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_schema.c",
    "content": "/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the virtual table interfaces.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n*/\n\n/* The code in this file defines a sqlite3 virtual-table module that\n** provides a read-only view of the current database schema. There is one\n** row in the schema table for each column in the database schema.\n*/\n#define SCHEMA \\\n\"CREATE TABLE x(\"                                                            \\\n  \"database,\"          /* Name of database (i.e. main, temp etc.) */         \\\n  \"tablename,\"         /* Name of table */                                   \\\n  \"cid,\"               /* Column number (from left-to-right, 0 upward) */    \\\n  \"name,\"              /* Column name */                                     \\\n  \"type,\"              /* Specified type (i.e. VARCHAR(32)) */               \\\n  \"not_null,\"          /* Boolean. True if NOT NULL was specified */         \\\n  \"dflt_value,\"        /* Default value for this column */                   \\\n  \"pk\"                 /* True if this column is part of the primary key */  \\\n\")\"\n\n/* If SQLITE_TEST is defined this code is preprocessed for use as part\n** of the sqlite test binary \"testfixture\". Otherwise it is preprocessed\n** to be compiled into an sqlite dynamic extension.\n*/\n#ifdef SQLITE_TEST\n#  include \"sqliteInt.h\"\n#  if defined(INCLUDE_SQLITE_TCL_H)\n#    include \"sqlite_tcl.h\"\n#  else\n#    include \"tcl.h\"\n#  endif\n#else\n#  include \"sqlite3ext.h\"\n  SQLITE_EXTENSION_INIT1\n#endif\n\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\ntypedef struct schema_vtab schema_vtab;\ntypedef struct schema_cursor schema_cursor;\n\n/* A schema table object */\nstruct schema_vtab {\n  sqlite3_vtab base;\n  sqlite3 *db;\n};\n\n/* A schema table cursor object */\nstruct schema_cursor {\n  sqlite3_vtab_cursor base;\n  sqlite3_stmt *pDbList;\n  sqlite3_stmt *pTableList;\n  sqlite3_stmt *pColumnList;\n  int rowid;\n};\n\n/*\n** None of this works unless we have virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Table destructor for the schema module.\n*/\nstatic int schemaDestroy(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return 0;\n}\n\n/*\n** Table constructor for the schema module.\n*/\nstatic int schemaCreate(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  int rc = SQLITE_NOMEM;\n  schema_vtab *pVtab = sqlite3_malloc(sizeof(schema_vtab));\n  if( pVtab ){\n    memset(pVtab, 0, sizeof(schema_vtab));\n    pVtab->db = db;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    rc = sqlite3_declare_vtab(db, SCHEMA);\n#endif\n  }\n  *ppVtab = (sqlite3_vtab *)pVtab;\n  return rc;\n}\n\n/*\n** Open a new cursor on the schema table.\n*/\nstatic int schemaOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  int rc = SQLITE_NOMEM;\n  schema_cursor *pCur;\n  pCur = sqlite3_malloc(sizeof(schema_cursor));\n  if( pCur ){\n    memset(pCur, 0, sizeof(schema_cursor));\n    *ppCursor = (sqlite3_vtab_cursor *)pCur;\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Close a schema table cursor.\n*/\nstatic int schemaClose(sqlite3_vtab_cursor *cur){\n  schema_cursor *pCur = (schema_cursor *)cur;\n  sqlite3_finalize(pCur->pDbList);\n  sqlite3_finalize(pCur->pTableList);\n  sqlite3_finalize(pCur->pColumnList);\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve a column of data.\n*/\nstatic int schemaColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  schema_cursor *pCur = (schema_cursor *)cur;\n  switch( i ){\n    case 0:\n      sqlite3_result_value(ctx, sqlite3_column_value(pCur->pDbList, 1));\n      break;\n    case 1:\n      sqlite3_result_value(ctx, sqlite3_column_value(pCur->pTableList, 0));\n      break;\n    default:\n      sqlite3_result_value(ctx, sqlite3_column_value(pCur->pColumnList, i-2));\n      break;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Retrieve the current rowid.\n*/\nstatic int schemaRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  schema_cursor *pCur = (schema_cursor *)cur;\n  *pRowid = pCur->rowid;\n  return SQLITE_OK;\n}\n\nstatic int finalize(sqlite3_stmt **ppStmt){\n  int rc = sqlite3_finalize(*ppStmt);\n  *ppStmt = 0;\n  return rc;\n}\n\nstatic int schemaEof(sqlite3_vtab_cursor *cur){\n  schema_cursor *pCur = (schema_cursor *)cur;\n  return (pCur->pDbList ? 0 : 1);\n}\n\n/*\n** Advance the cursor to the next row.\n*/\nstatic int schemaNext(sqlite3_vtab_cursor *cur){\n  int rc = SQLITE_OK;\n  schema_cursor *pCur = (schema_cursor *)cur;\n  schema_vtab *pVtab = (schema_vtab *)(cur->pVtab);\n  char *zSql = 0;\n\n  while( !pCur->pColumnList || SQLITE_ROW!=sqlite3_step(pCur->pColumnList) ){\n    if( SQLITE_OK!=(rc = finalize(&pCur->pColumnList)) ) goto next_exit;\n\n    while( !pCur->pTableList || SQLITE_ROW!=sqlite3_step(pCur->pTableList) ){\n      if( SQLITE_OK!=(rc = finalize(&pCur->pTableList)) ) goto next_exit;\n\n      assert(pCur->pDbList);\n      while( SQLITE_ROW!=sqlite3_step(pCur->pDbList) ){\n        rc = finalize(&pCur->pDbList);\n        goto next_exit;\n      }\n\n      /* Set zSql to the SQL to pull the list of tables from the \n      ** sqlite_master (or sqlite_temp_master) table of the database\n      ** identified by the row pointed to by the SQL statement pCur->pDbList\n      ** (iterating through a \"PRAGMA database_list;\" statement).\n      */\n      if( sqlite3_column_int(pCur->pDbList, 0)==1 ){\n        zSql = sqlite3_mprintf(\n            \"SELECT name FROM sqlite_temp_master WHERE type='table'\"\n        );\n      }else{\n        sqlite3_stmt *pDbList = pCur->pDbList;\n        zSql = sqlite3_mprintf(\n            \"SELECT name FROM %Q.sqlite_master WHERE type='table'\",\n             sqlite3_column_text(pDbList, 1)\n        );\n      }\n      if( !zSql ){\n        rc = SQLITE_NOMEM;\n        goto next_exit;\n      }\n\n      rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pTableList, 0);\n      sqlite3_free(zSql);\n      if( rc!=SQLITE_OK ) goto next_exit;\n    }\n\n    /* Set zSql to the SQL to the table_info pragma for the table currently\n    ** identified by the rows pointed to by statements pCur->pDbList and\n    ** pCur->pTableList.\n    */\n    zSql = sqlite3_mprintf(\"PRAGMA %Q.table_info(%Q)\", \n        sqlite3_column_text(pCur->pDbList, 1),\n        sqlite3_column_text(pCur->pTableList, 0)\n    );\n\n    if( !zSql ){\n      rc = SQLITE_NOMEM;\n      goto next_exit;\n    }\n    rc = sqlite3_prepare(pVtab->db, zSql, -1, &pCur->pColumnList, 0);\n    sqlite3_free(zSql);\n    if( rc!=SQLITE_OK ) goto next_exit;\n  }\n  pCur->rowid++;\n\nnext_exit:\n  /* TODO: Handle rc */\n  return rc;\n}\n\n/*\n** Reset a schema table cursor.\n*/\nstatic int schemaFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  int rc;\n  schema_vtab *pVtab = (schema_vtab *)(pVtabCursor->pVtab);\n  schema_cursor *pCur = (schema_cursor *)pVtabCursor;\n  pCur->rowid = 0;\n  finalize(&pCur->pTableList);\n  finalize(&pCur->pColumnList);\n  finalize(&pCur->pDbList);\n  rc = sqlite3_prepare(pVtab->db,\"PRAGMA database_list\", -1, &pCur->pDbList, 0);\n  return (rc==SQLITE_OK ? schemaNext(pVtabCursor) : rc);\n}\n\n/*\n** Analyse the WHERE condition.\n*/\nstatic int schemaBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  return SQLITE_OK;\n}\n\n/*\n** A virtual table module that merely echos method calls into TCL\n** variables.\n*/\nstatic sqlite3_module schemaModule = {\n  0,                           /* iVersion */\n  schemaCreate,\n  schemaCreate,\n  schemaBestIndex,\n  schemaDestroy,\n  schemaDestroy,\n  schemaOpen,                  /* xOpen - open a cursor */\n  schemaClose,                 /* xClose - close a cursor */\n  schemaFilter,                /* xFilter - configure scan constraints */\n  schemaNext,                  /* xNext - advance a cursor */\n  schemaEof,                   /* xEof */\n  schemaColumn,                /* xColumn - read data */\n  schemaRowid,                 /* xRowid - read data */\n  0,                           /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifdef SQLITE_TEST\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\n\n/*\n** Register the schema virtual table module.\n*/\nstatic int SQLITE_TCLAPI register_schema_module(\n  ClientData clientData, /* Not used */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_create_module(db, \"schema\", &schemaModule, 0);\n#endif\n  return TCL_OK;\n}\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetestschema_Init(Tcl_Interp *interp){\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"register_schema_module\", register_schema_module, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n  return TCL_OK;\n}\n\n#else\n\n/*\n** Extension load function.\n*/\n#ifdef _WIN32\n__declspec(dllexport)\n#endif\nint sqlite3_schema_init(\n  sqlite3 *db, \n  char **pzErrMsg, \n  const sqlite3_api_routines *pApi\n){\n  SQLITE_EXTENSION_INIT2(pApi);\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_create_module(db, \"schema\", &schemaModule, 0);\n#endif\n  return 0;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_server.c",
    "content": "/*\n** 2006 January 07\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains demonstration code.  Nothing in this file gets compiled\n** or linked into the SQLite library unless you use a non-standard option:\n**\n**      -DSQLITE_SERVER=1\n**\n** The configure script will never generate a Makefile with the option\n** above.  You will need to manually modify the Makefile if you want to\n** include any of the code from this file in your project.  Or, at your\n** option, you may copy and paste the code from this file and\n** thereby avoiding a recompile of SQLite.\n**\n**\n** This source file demonstrates how to use SQLite to create an SQL database \n** server thread in a multiple-threaded program.  One or more client threads\n** send messages to the server thread and the server thread processes those\n** messages in the order received and returns the results to the client.\n**\n** One might ask:  \"Why bother?  Why not just let each thread connect\n** to the database directly?\"  There are a several of reasons to\n** prefer the client/server approach.\n**\n**    (1)  Some systems (ex: Redhat9) have broken threading implementations\n**         that prevent SQLite database connections from being used in\n**         a thread different from the one where they were created.  With\n**         the client/server approach, all database connections are created\n**         and used within the server thread.  Client calls to the database\n**         can be made from multiple threads (though not at the same time!)\n**\n**    (2)  Beginning with SQLite version 3.3.0, when two or more \n**         connections to the same database occur within the same thread,\n**         they can optionally share their database cache.  This reduces\n**         I/O and memory requirements.  Cache shared is controlled using\n**         the sqlite3_enable_shared_cache() API.\n**\n**    (3)  Database connections on a shared cache use table-level locking\n**         instead of file-level locking for improved concurrency.\n**\n**    (4)  Database connections on a shared cache can by optionally\n**         set to READ UNCOMMITTED isolation.  (The default isolation for\n**         SQLite is SERIALIZABLE.)  When this occurs, readers will\n**         never be blocked by a writer and writers will not be\n**         blocked by readers.  There can still only be a single writer\n**         at a time, but multiple readers can simultaneously exist with\n**         that writer.  This is a huge increase in concurrency.\n**\n** To summarize the rational for using a client/server approach: prior\n** to SQLite version 3.3.0 it probably was not worth the trouble.  But\n** with SQLite version 3.3.0 and beyond you can get significant performance\n** and concurrency improvements and memory usage reductions by going\n** client/server.\n**\n** Note:  The extra features of version 3.3.0 described by points (2)\n** through (4) above are only available if you compile without the\n** option -DSQLITE_OMIT_SHARED_CACHE. \n**\n** Here is how the client/server approach works:  The database server\n** thread is started on this procedure:\n**\n**       void *sqlite3_server(void *NotUsed);\n**\n** The sqlite_server procedure runs as long as the g.serverHalt variable\n** is false.  A mutex is used to make sure no more than one server runs\n** at a time.  The server waits for messages to arrive on a message\n** queue and processes the messages in order.\n**\n** Two convenience routines are provided for starting and stopping the\n** server thread:\n**\n**       void sqlite3_server_start(void);\n**       void sqlite3_server_stop(void);\n**\n** Both of the convenience routines return immediately.  Neither will\n** ever give an error.  If a server is already started or already halted,\n** then the routines are effectively no-ops.\n**\n** Clients use the following interfaces:\n**\n**       sqlite3_client_open\n**       sqlite3_client_prepare\n**       sqlite3_client_step\n**       sqlite3_client_reset\n**       sqlite3_client_finalize\n**       sqlite3_client_close\n**\n** These interfaces work exactly like the standard core SQLite interfaces\n** having the same names without the \"_client_\" infix.  Many other SQLite\n** interfaces can be used directly without having to send messages to the\n** server as long as SQLITE_ENABLE_MEMORY_MANAGEMENT is not defined.\n** The following interfaces fall into this second category:\n**\n**       sqlite3_bind_*\n**       sqlite3_changes\n**       sqlite3_clear_bindings\n**       sqlite3_column_*\n**       sqlite3_complete\n**       sqlite3_create_collation\n**       sqlite3_create_function\n**       sqlite3_data_count\n**       sqlite3_db_handle\n**       sqlite3_errcode\n**       sqlite3_errmsg\n**       sqlite3_last_insert_rowid\n**       sqlite3_total_changes\n**       sqlite3_transfer_bindings\n**\n** A single SQLite connection (an sqlite3* object) or an SQLite statement\n** (an sqlite3_stmt* object) should only be passed to a single interface\n** function at a time.  The connections and statements can be passed from\n** any thread to any of the functions listed in the second group above as\n** long as the same connection is not in use by two threads at once and\n** as long as SQLITE_ENABLE_MEMORY_MANAGEMENT is not defined.  Additional\n** information about the SQLITE_ENABLE_MEMORY_MANAGEMENT constraint is\n** below.\n**\n** The busy handler for all database connections should remain turned\n** off.  That means that any lock contention will cause the associated\n** sqlite3_client_step() call to return immediately with an SQLITE_BUSY\n** error code.  If a busy handler is enabled and lock contention occurs,\n** then the entire server thread will block.  This will cause not only\n** the requesting client to block but every other database client as\n** well.  It is possible to enhance the code below so that lock\n** contention will cause the message to be placed back on the top of\n** the queue to be tried again later.  But such enhanced processing is\n** not included here, in order to keep the example simple.\n**\n** This example code assumes the use of pthreads.  Pthreads\n** implementations are available for windows.  (See, for example\n** http://sourceware.org/pthreads-win32/announcement.html.)  Or, you\n** can translate the locking and thread synchronization code to use\n** windows primitives easily enough.  The details are left as an\n** exercise to the reader.\n**\n**** Restrictions Associated With SQLITE_ENABLE_MEMORY_MANAGEMENT ****\n**\n** If you compile with SQLITE_ENABLE_MEMORY_MANAGEMENT defined, then\n** SQLite includes code that tracks how much memory is being used by\n** each thread.  These memory counts can become confused if memory\n** is allocated by one thread and then freed by another.  For that\n** reason, when SQLITE_ENABLE_MEMORY_MANAGEMENT is used, all operations\n** that might allocate or free memory should be performanced in the same\n** thread that originally created the database connection.  In that case,\n** many of the operations that are listed above as safe to be performed\n** in separate threads would need to be sent over to the server to be\n** done there.  If SQLITE_ENABLE_MEMORY_MANAGEMENT is defined, then\n** the following functions can be used safely from different threads\n** without messing up the allocation counts:\n**\n**       sqlite3_bind_parameter_name\n**       sqlite3_bind_parameter_index\n**       sqlite3_changes\n**       sqlite3_column_blob\n**       sqlite3_column_count\n**       sqlite3_complete\n**       sqlite3_data_count\n**       sqlite3_db_handle\n**       sqlite3_errcode\n**       sqlite3_errmsg\n**       sqlite3_last_insert_rowid\n**       sqlite3_total_changes\n**\n** The remaining functions are not thread-safe when memory management\n** is enabled.  So one would have to define some new interface routines\n** along the following lines:\n**\n**       sqlite3_client_bind_*\n**       sqlite3_client_clear_bindings\n**       sqlite3_client_column_*\n**       sqlite3_client_create_collation\n**       sqlite3_client_create_function\n**       sqlite3_client_transfer_bindings\n**\n** The example code in this file is intended for use with memory\n** management turned off.  So the implementation of these additional\n** client interfaces is left as an exercise to the reader.\n**\n** It may seem surprising to the reader that the list of safe functions\n** above does not include things like sqlite3_bind_int() or\n** sqlite3_column_int().  But those routines might, in fact, allocate\n** or deallocate memory.  In the case of sqlite3_bind_int(), if the\n** parameter was previously bound to a string that string might need\n** to be deallocated before the new integer value is inserted.  In\n** the case of sqlite3_column_int(), the value of the column might be\n** a UTF-16 string which will need to be converted to UTF-8 then into\n** an integer.\n*/\n\n/* Include this to get the definition of SQLITE_THREADSAFE, in the\n** case that default values are used.\n*/\n#include \"sqliteInt.h\"\n\n/*\n** Only compile the code in this file on UNIX with a SQLITE_THREADSAFE build\n** and only if the SQLITE_SERVER macro is defined.\n*/\n#if defined(SQLITE_SERVER) && !defined(SQLITE_OMIT_SHARED_CACHE)\n#if SQLITE_OS_UNIX && SQLITE_THREADSAFE\n\n/*\n** We require only pthreads and the public interface of SQLite.\n*/\n#include <pthread.h>\n#include \"sqlite3.h\"\n\n/*\n** Messages are passed from client to server and back again as \n** instances of the following structure.\n*/\ntypedef struct SqlMessage SqlMessage;\nstruct SqlMessage {\n  int op;                      /* Opcode for the message */\n  sqlite3 *pDb;                /* The SQLite connection */\n  sqlite3_stmt *pStmt;         /* A specific statement */\n  int errCode;                 /* Error code returned */\n  const char *zIn;             /* Input filename or SQL statement */\n  int nByte;                   /* Size of the zIn parameter for prepare() */\n  const char *zOut;            /* Tail of the SQL statement */\n  SqlMessage *pNext;           /* Next message in the queue */\n  SqlMessage *pPrev;           /* Previous message in the queue */\n  pthread_mutex_t clientMutex; /* Hold this mutex to access the message */\n  pthread_cond_t clientWakeup; /* Signal to wake up the client */\n};\n\n/*\n** Legal values for SqlMessage.op\n*/\n#define MSG_Open       1  /* sqlite3_open(zIn, &pDb) */\n#define MSG_Prepare    2  /* sqlite3_prepare(pDb, zIn, nByte, &pStmt, &zOut) */\n#define MSG_Step       3  /* sqlite3_step(pStmt) */\n#define MSG_Reset      4  /* sqlite3_reset(pStmt) */\n#define MSG_Finalize   5  /* sqlite3_finalize(pStmt) */\n#define MSG_Close      6  /* sqlite3_close(pDb) */\n#define MSG_Done       7  /* Server has finished with this message */\n\n\n/*\n** State information about the server is stored in a static variable\n** named \"g\" as follows:\n*/\nstatic struct ServerState {\n  pthread_mutex_t queueMutex;   /* Hold this mutex to access the msg queue */\n  pthread_mutex_t serverMutex;  /* Held by the server while it is running */\n  pthread_cond_t serverWakeup;  /* Signal this condvar to wake up the server */\n  volatile int serverHalt;      /* Server halts itself when true */\n  SqlMessage *pQueueHead;       /* Head of the message queue */\n  SqlMessage *pQueueTail;       /* Tail of the message queue */\n} g = {\n  PTHREAD_MUTEX_INITIALIZER,\n  PTHREAD_MUTEX_INITIALIZER,\n  PTHREAD_COND_INITIALIZER,\n};\n\n/*\n** Send a message to the server.  Block until we get a reply.\n**\n** The mutex and condition variable in the message are uninitialized\n** when this routine is called.  This routine takes care of \n** initializing them and destroying them when it has finished.\n*/\nstatic void sendToServer(SqlMessage *pMsg){\n  /* Initialize the mutex and condition variable on the message\n  */\n  pthread_mutex_init(&pMsg->clientMutex, 0);\n  pthread_cond_init(&pMsg->clientWakeup, 0);\n\n  /* Add the message to the head of the server's message queue.\n  */\n  pthread_mutex_lock(&g.queueMutex);\n  pMsg->pNext = g.pQueueHead;\n  if( g.pQueueHead==0 ){\n    g.pQueueTail = pMsg;\n  }else{\n    g.pQueueHead->pPrev = pMsg;\n  }\n  pMsg->pPrev = 0;\n  g.pQueueHead = pMsg;\n  pthread_mutex_unlock(&g.queueMutex);\n\n  /* Signal the server that the new message has be queued, then\n  ** block waiting for the server to process the message.\n  */\n  pthread_mutex_lock(&pMsg->clientMutex);\n  pthread_cond_signal(&g.serverWakeup);\n  while( pMsg->op!=MSG_Done ){\n    pthread_cond_wait(&pMsg->clientWakeup, &pMsg->clientMutex);\n  }\n  pthread_mutex_unlock(&pMsg->clientMutex);\n\n  /* Destroy the mutex and condition variable of the message.\n  */\n  pthread_mutex_destroy(&pMsg->clientMutex);\n  pthread_cond_destroy(&pMsg->clientWakeup);\n}\n\n/*\n** The following 6 routines are client-side implementations of the\n** core SQLite interfaces:\n**\n**        sqlite3_open\n**        sqlite3_prepare\n**        sqlite3_step\n**        sqlite3_reset\n**        sqlite3_finalize\n**        sqlite3_close\n**\n** Clients should use the following client-side routines instead of \n** the core routines above.\n**\n**        sqlite3_client_open\n**        sqlite3_client_prepare\n**        sqlite3_client_step\n**        sqlite3_client_reset\n**        sqlite3_client_finalize\n**        sqlite3_client_close\n**\n** Each of these routines creates a message for the desired operation,\n** sends that message to the server, waits for the server to process\n** then message and return a response.\n*/\nint sqlite3_client_open(const char *zDatabaseName, sqlite3 **ppDb){\n  SqlMessage msg;\n  msg.op = MSG_Open;\n  msg.zIn = zDatabaseName;\n  sendToServer(&msg);\n  *ppDb = msg.pDb;\n  return msg.errCode;\n}\nint sqlite3_client_prepare(\n  sqlite3 *pDb,\n  const char *zSql,\n  int nByte,\n  sqlite3_stmt **ppStmt,\n  const char **pzTail\n){\n  SqlMessage msg;\n  msg.op = MSG_Prepare;\n  msg.pDb = pDb;\n  msg.zIn = zSql;\n  msg.nByte = nByte;\n  sendToServer(&msg);\n  *ppStmt = msg.pStmt;\n  if( pzTail ) *pzTail = msg.zOut;\n  return msg.errCode;\n}\nint sqlite3_client_step(sqlite3_stmt *pStmt){\n  SqlMessage msg;\n  msg.op = MSG_Step;\n  msg.pStmt = pStmt;\n  sendToServer(&msg);\n  return msg.errCode;\n}\nint sqlite3_client_reset(sqlite3_stmt *pStmt){\n  SqlMessage msg;\n  msg.op = MSG_Reset;\n  msg.pStmt = pStmt;\n  sendToServer(&msg);\n  return msg.errCode;\n}\nint sqlite3_client_finalize(sqlite3_stmt *pStmt){\n  SqlMessage msg;\n  msg.op = MSG_Finalize;\n  msg.pStmt = pStmt;\n  sendToServer(&msg);\n  return msg.errCode;\n}\nint sqlite3_client_close(sqlite3 *pDb){\n  SqlMessage msg;\n  msg.op = MSG_Close;\n  msg.pDb = pDb;\n  sendToServer(&msg);\n  return msg.errCode;\n}\n\n/*\n** This routine implements the server.  To start the server, first\n** make sure g.serverHalt is false, then create a new detached thread\n** on this procedure.  See the sqlite3_server_start() routine below\n** for an example.  This procedure loops until g.serverHalt becomes\n** true.\n*/\nvoid *sqlite3_server(void *NotUsed){\n  if( pthread_mutex_trylock(&g.serverMutex) ){\n    return 0;  /* Another server is already running */\n  }\n  sqlite3_enable_shared_cache(1);\n  while( !g.serverHalt ){\n    SqlMessage *pMsg;\n\n    /* Remove the last message from the message queue.\n    */\n    pthread_mutex_lock(&g.queueMutex);\n    while( g.pQueueTail==0 && g.serverHalt==0 ){\n      pthread_cond_wait(&g.serverWakeup, &g.queueMutex);\n    }\n    pMsg = g.pQueueTail;\n    if( pMsg ){\n      if( pMsg->pPrev ){\n        pMsg->pPrev->pNext = 0;\n      }else{\n        g.pQueueHead = 0;\n      }\n      g.pQueueTail = pMsg->pPrev;\n    }\n    pthread_mutex_unlock(&g.queueMutex);\n    if( pMsg==0 ) break;\n\n    /* Process the message just removed\n    */\n    pthread_mutex_lock(&pMsg->clientMutex);\n    switch( pMsg->op ){\n      case MSG_Open: {\n        pMsg->errCode = sqlite3_open(pMsg->zIn, &pMsg->pDb);\n        break;\n      }\n      case MSG_Prepare: {\n        pMsg->errCode = sqlite3_prepare(pMsg->pDb, pMsg->zIn, pMsg->nByte,\n                                        &pMsg->pStmt, &pMsg->zOut);\n        break;\n      }\n      case MSG_Step: {\n        pMsg->errCode = sqlite3_step(pMsg->pStmt);\n        break;\n      }\n      case MSG_Reset: {\n        pMsg->errCode = sqlite3_reset(pMsg->pStmt);\n        break;\n      }\n      case MSG_Finalize: {\n        pMsg->errCode = sqlite3_finalize(pMsg->pStmt);\n        break;\n      }\n      case MSG_Close: {\n        pMsg->errCode = sqlite3_close(pMsg->pDb);\n        break;\n      }\n    }\n\n    /* Signal the client that the message has been processed.\n    */\n    pMsg->op = MSG_Done;\n    pthread_mutex_unlock(&pMsg->clientMutex);\n    pthread_cond_signal(&pMsg->clientWakeup);\n  }\n  pthread_mutex_unlock(&g.serverMutex);\n  return 0;\n}\n\n/*\n** Start a server thread if one is not already running.  If there\n** is aleady a server thread running, the new thread will quickly\n** die and this routine is effectively a no-op.\n*/\nvoid sqlite3_server_start(void){\n  pthread_t x;\n  int rc;\n  g.serverHalt = 0;\n  rc = pthread_create(&x, 0, sqlite3_server, 0);\n  if( rc==0 ){\n    pthread_detach(x);\n  }\n}\n\n/*\n** A wrapper around sqlite3_server() that decrements the int variable\n** pointed to by the first argument after the sqlite3_server() call\n** returns.\n*/\nstatic void *serverWrapper(void *pnDecr){\n  void *p = sqlite3_server(0);\n  (*(int*)pnDecr)--;\n  return p;\n}\n\n/*\n** This function is the similar to sqlite3_server_start(), except that\n** the integer pointed to by the first argument is decremented when\n** the server thread exits. \n*/\nvoid sqlite3_server_start2(int *pnDecr){\n  pthread_t x;\n  int rc;\n  g.serverHalt = 0;\n  rc = pthread_create(&x, 0, serverWrapper, (void*)pnDecr);\n  if( rc==0 ){\n    pthread_detach(x);\n  }\n}\n\n/*\n** If a server thread is running, then stop it.  If no server is\n** running, this routine is effectively a no-op.\n**\n** This routine waits until the server has actually stopped before\n** returning.\n*/\nvoid sqlite3_server_stop(void){\n  g.serverHalt = 1;\n  pthread_cond_broadcast(&g.serverWakeup);\n  pthread_mutex_lock(&g.serverMutex);\n  pthread_mutex_unlock(&g.serverMutex);\n}\n\n#endif /* SQLITE_OS_UNIX && SQLITE_THREADSAFE */\n#endif /* defined(SQLITE_SERVER) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_sqllog.c",
    "content": "/*\n** 2012 November 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** OVERVIEW\n**\n**   This file contains experimental code used to record data from live\n**   SQLite applications that may be useful for offline analysis. \n**   Specifically, this module can be used to capture the following\n**   information:\n**\n**     1) The initial contents of all database files opened by the \n**        application, and\n**\n**     2) All SQL statements executed by the application.\n**\n**   The captured information can then be used to run (for example)\n**   performance analysis looking for slow queries or to look for\n**   optimization opportunities in either the application or in SQLite\n**   itself.\n**\n** USAGE\n**\n**   To use this module, SQLite must be compiled with the SQLITE_ENABLE_SQLLOG\n**   pre-processor symbol defined and this file linked into the application.\n**   One way to link this file into the application is to append the content\n**   of this file onto the end of the \"sqlite3.c\" amalgamation and then \n**   recompile the application as normal except with the addition  of the\n**   -DSQLITE_ENABLE_SQLLOG option.\n**\n**   At runtime, logging is enabled by setting environment variable\n**   SQLITE_SQLLOG_DIR to the name of a directory in which to store logged \n**   data. The logging directory must already exist.\n**\n**   Usually, if the application opens the same database file more than once\n**   (either by attaching it or by using more than one database handle), only\n**   a single copy is made. This behavior may be overridden (so that a \n**   separate copy is taken each time the database file is opened or attached)\n**   by setting the environment variable SQLITE_SQLLOG_REUSE_FILES to 0.\n**\n**   If the environment variable SQLITE_SQLLOG_CONDITIONAL is defined, then\n**   logging is only done for database connections if a file named\n**   \"<database>-sqllog\" exists in the same directly as the main database\n**   file when it is first opened (\"<database>\" is replaced by the actual \n**   name of the main database file).\n**\n** OUTPUT:\n**\n**   The SQLITE_SQLLOG_DIR is populated with three types of files:\n**\n**      sqllog_N.db   - Copies of database files. N may be any integer.\n**\n**      sqllog_N.sql  - A list of SQL statements executed by a single\n**                      connection. N may be any integer.\n**\n**      sqllog.idx    - An index mapping from integer N to a database\n**                      file name - indicating the full path of the\n**                      database from which sqllog_N.db was copied.\n**\n** ERROR HANDLING:\n**\n**   This module attempts to make a best effort to continue logging if an\n**   IO or other error is encountered. For example, if a log file cannot \n**   be opened logs are not collected for that connection, but other\n**   logging proceeds as expected. Errors are logged by calling sqlite3_log().\n*/\n\n#ifndef _SQLITE3_H_\n#include \"sqlite3.h\"\n#endif\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\n#include <sys/types.h>\n#include <unistd.h>\nstatic int getProcessId(void){\n#if SQLITE_OS_WIN\n  return (int)_getpid();\n#else\n  return (int)getpid();\n#endif\n}\n\n/* Names of environment variables to be used */\n#define ENVIRONMENT_VARIABLE1_NAME \"SQLITE_SQLLOG_DIR\"\n#define ENVIRONMENT_VARIABLE2_NAME \"SQLITE_SQLLOG_REUSE_FILES\"\n#define ENVIRONMENT_VARIABLE3_NAME \"SQLITE_SQLLOG_CONDITIONAL\"\n\n/* Assume that all database and database file names are shorted than this. */\n#define SQLLOG_NAMESZ 512\n\n/* Maximum number of simultaneous database connections the process may\n** open (if any more are opened an error is logged using sqlite3_log()\n** and processing is halted).\n*/\n#define MAX_CONNECTIONS 256\n\n/* There is one instance of this object for each SQLite database connection\n** that is being logged.\n*/\nstruct SLConn {\n  int isErr;                      /* True if an error has occurred */\n  sqlite3 *db;                    /* Connection handle */\n  int iLog;                       /* First integer value used in file names */\n  FILE *fd;                       /* File descriptor for log file */\n};\n\n/* This object is a singleton that keeps track of all data loggers.\n*/\nstatic struct SLGlobal {\n  /* Protected by MUTEX_STATIC_MASTER */\n  sqlite3_mutex *mutex;           /* Recursive mutex */\n  int nConn;                      /* Size of aConn[] array */\n\n  /* Protected by SLGlobal.mutex */\n  int bConditional;               /* Only trace if *-sqllog file is present */\n  int bReuse;                     /* True to avoid extra copies of db files */\n  char zPrefix[SQLLOG_NAMESZ];    /* Prefix for all created files */\n  char zIdx[SQLLOG_NAMESZ];       /* Full path to *.idx file */\n  int iNextLog;                   /* Used to allocate file names */\n  int iNextDb;                    /* Used to allocate database file names */\n  int bRec;                       /* True if testSqllog() is called rec. */\n  int iClock;                     /* Clock value */\n  struct SLConn aConn[MAX_CONNECTIONS];\n} sqllogglobal;\n\n/*\n** Return true if c is an ASCII whitespace character.\n*/\nstatic int sqllog_isspace(char c){\n  return (c==' ' || c=='\\t' || c=='\\n' || c=='\\v' || c=='\\f' || c=='\\r');\n}\n\n/*\n** The first argument points to a nul-terminated string containing an SQL\n** command. Before returning, this function sets *pz to point to the start\n** of the first token in this command, and *pn to the number of bytes in \n** the token. This is used to check if the SQL command is an \"ATTACH\" or \n** not.\n*/\nstatic void sqllogTokenize(const char *z, const char **pz, int *pn){\n  const char *p = z;\n  int n;\n\n  /* Skip past any whitespace */\n  while( sqllog_isspace(*p) ){\n    p++;\n  }\n\n  /* Figure out how long the first token is */\n  *pz = p;\n  n = 0;\n  while( (p[n]>='a' && p[n]<='z') || (p[n]>='A' && p[n]<='Z') ) n++;\n  *pn = n;\n}\n\n/*\n** Check if the logs directory already contains a copy of database file \n** zFile. If so, return a pointer to the full path of the copy. Otherwise,\n** return NULL.\n**\n** If a non-NULL value is returned, then the caller must arrange to \n** eventually free it using sqlite3_free().\n*/\nstatic char *sqllogFindFile(const char *zFile){\n  char *zRet = 0;\n  FILE *fd = 0;\n\n  /* Open the index file for reading */\n  fd = fopen(sqllogglobal.zIdx, \"r\");\n  if( fd==0 ){\n    sqlite3_log(SQLITE_IOERR, \"sqllogFindFile(): error in fopen()\");\n    return 0;\n  }\n\n  /* Loop through each entry in the index file. If zFile is not NULL and the\n  ** entry is a match, then set zRet to point to the filename of the existing\n  ** copy and break out of the loop.  */\n  while( feof(fd)==0 ){\n    char zLine[SQLLOG_NAMESZ*2+5];\n    if( fgets(zLine, sizeof(zLine), fd) ){\n      int n;\n      char *z;\n\n      zLine[sizeof(zLine)-1] = '\\0';\n      z = zLine;\n      while( *z>='0' && *z<='9' ) z++;\n      while( *z==' ' ) z++;\n\n      n = strlen(z);\n      while( n>0 && sqllog_isspace(z[n-1]) ) n--;\n\n      if( n==strlen(zFile) && 0==memcmp(zFile, z, n) ){\n        char zBuf[16];\n        memset(zBuf, 0, sizeof(zBuf));\n        z = zLine;\n        while( *z>='0' && *z<='9' ){\n          zBuf[z-zLine] = *z;\n          z++;\n        }\n        zRet = sqlite3_mprintf(\"%s_%s.db\", sqllogglobal.zPrefix, zBuf);\n        break;\n      }\n    }\n  }\n\n  if( ferror(fd) ){\n    sqlite3_log(SQLITE_IOERR, \"sqllogFindFile(): error reading index file\");\n  }\n\n  fclose(fd);\n  return zRet;\n}\n\nstatic int sqllogFindAttached(\n  sqlite3 *db,                    /* Database connection */\n  const char *zSearch,            /* Name to search for (or NULL) */\n  char *zName,                    /* OUT: Name of attached database */\n  char *zFile                     /* OUT: Name of attached file */\n){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  /* The \"PRAGMA database_list\" command returns a list of databases in the\n  ** order that they were attached. So a newly attached database is \n  ** described by the last row returned.  */\n  assert( sqllogglobal.bRec==0 );\n  sqllogglobal.bRec = 1;\n  rc = sqlite3_prepare_v2(db, \"PRAGMA database_list\", -1, &pStmt, 0);\n  if( rc==SQLITE_OK ){\n    while( SQLITE_ROW==sqlite3_step(pStmt) ){\n      const char *zVal1; int nVal1;\n      const char *zVal2; int nVal2;\n\n      zVal1 = (const char*)sqlite3_column_text(pStmt, 1);\n      nVal1 = sqlite3_column_bytes(pStmt, 1);\n      if( zName ){\n        memcpy(zName, zVal1, nVal1+1);\n      }\n\n      zVal2 = (const char*)sqlite3_column_text(pStmt, 2);\n      nVal2 = sqlite3_column_bytes(pStmt, 2);\n      memcpy(zFile, zVal2, nVal2+1);\n\n      if( zSearch && strlen(zSearch)==nVal1 \n       && 0==sqlite3_strnicmp(zSearch, zVal1, nVal1)\n      ){\n        break;\n      }\n    }\n    rc = sqlite3_finalize(pStmt);\n  }\n  sqllogglobal.bRec = 0;\n\n  if( rc!=SQLITE_OK ){\n    sqlite3_log(rc, \"sqllogFindAttached(): error in \\\"PRAGMA database_list\\\"\");\n  }\n  return rc;\n}\n\n\n/*\n** Parameter zSearch is the name of a database attached to the database \n** connection associated with the first argument. This function creates\n** a backup of this database in the logs directory.\n**\n** The name used for the backup file is automatically generated. Call\n** it zFile.\n**\n** If the bLog parameter is true, then a statement of the following form\n** is written to the log file associated with *p:\n**\n**    ATTACH 'zFile' AS 'zName';\n**\n** Otherwise, if bLog is false, a comment is added to the log file:\n**\n**    -- Main database file is 'zFile'\n**\n** The SLGlobal.mutex mutex is always held when this function is called.\n*/\nstatic void sqllogCopydb(struct SLConn *p, const char *zSearch, int bLog){\n  char zName[SQLLOG_NAMESZ];      /* Attached database name */\n  char zFile[SQLLOG_NAMESZ];      /* Database file name */\n  char *zFree;\n  char *zInit = 0;\n  int rc;\n\n  rc = sqllogFindAttached(p->db, zSearch, zName, zFile);\n  if( rc!=SQLITE_OK ) return;\n\n  if( zFile[0]=='\\0' ){\n    zInit = sqlite3_mprintf(\"\");\n  }else{\n    if( sqllogglobal.bReuse ){\n      zInit = sqllogFindFile(zFile);\n    }else{\n      zInit = 0;\n    }\n    if( zInit==0 ){\n      int rc;\n      sqlite3 *copy = 0;\n      int iDb;\n\n      /* Generate a file-name to use for the copy of this database */\n      iDb = sqllogglobal.iNextDb++;\n      zInit = sqlite3_mprintf(\"%s_%02d.db\", sqllogglobal.zPrefix, iDb);\n\n      /* Create the backup */\n      assert( sqllogglobal.bRec==0 );\n      sqllogglobal.bRec = 1;\n      rc = sqlite3_open(zInit, &copy);\n      if( rc==SQLITE_OK ){\n        sqlite3_backup *pBak;\n        sqlite3_exec(copy, \"PRAGMA synchronous = 0\", 0, 0, 0);\n        pBak = sqlite3_backup_init(copy, \"main\", p->db, zName);\n        if( pBak ){\n          sqlite3_backup_step(pBak, -1);\n          rc = sqlite3_backup_finish(pBak);\n        }else{\n          rc = sqlite3_errcode(copy);\n        }\n        sqlite3_close(copy);\n      }\n      sqllogglobal.bRec = 0;\n\n      if( rc==SQLITE_OK ){\n        /* Write an entry into the database index file */\n        FILE *fd = fopen(sqllogglobal.zIdx, \"a\");\n        if( fd ){\n          fprintf(fd, \"%d %s\\n\", iDb, zFile);\n          fclose(fd);\n        }\n      }else{\n        sqlite3_log(rc, \"sqllogCopydb(): error backing up database\");\n      }\n    }\n  }\n\n  if( bLog ){\n    zFree = sqlite3_mprintf(\"ATTACH '%q' AS '%q'; -- clock=%d\\n\", \n        zInit, zName, sqllogglobal.iClock++\n    );\n  }else{\n    zFree = sqlite3_mprintf(\"-- Main database is '%q'\\n\", zInit);\n  }\n  fprintf(p->fd, \"%s\", zFree);\n  sqlite3_free(zFree);\n\n  sqlite3_free(zInit);\n}\n\n/*\n** If it is not already open, open the log file for connection *p. \n**\n** The SLGlobal.mutex mutex is always held when this function is called.\n*/\nstatic void sqllogOpenlog(struct SLConn *p){\n  /* If the log file has not yet been opened, open it now. */\n  if( p->fd==0 ){\n    char *zLog;\n\n    /* If it is still NULL, have global.zPrefix point to a copy of \n    ** environment variable $ENVIRONMENT_VARIABLE1_NAME.  */\n    if( sqllogglobal.zPrefix[0]==0 ){\n      FILE *fd;\n      char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME);\n      if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return;\n      sqlite3_snprintf(sizeof(sqllogglobal.zPrefix), sqllogglobal.zPrefix,\n                        \"%s/sqllog_%05d\", zVar, getProcessId());\n      sqlite3_snprintf(sizeof(sqllogglobal.zIdx), sqllogglobal.zIdx,\n                        \"%s.idx\", sqllogglobal.zPrefix);\n      if( getenv(ENVIRONMENT_VARIABLE2_NAME) ){\n        sqllogglobal.bReuse = atoi(getenv(ENVIRONMENT_VARIABLE2_NAME));\n      }\n      fd = fopen(sqllogglobal.zIdx, \"w\");\n      if( fd ) fclose(fd);\n    }\n\n    /* Open the log file */\n    zLog = sqlite3_mprintf(\"%s_%05d.sql\", sqllogglobal.zPrefix, p->iLog);\n    p->fd = fopen(zLog, \"w\");\n    sqlite3_free(zLog);\n    if( p->fd==0 ){\n      sqlite3_log(SQLITE_IOERR, \"sqllogOpenlog(): Failed to open log file\");\n    }\n  }\n}\n\n/*\n** This function is called if the SQLLOG callback is invoked to report\n** execution of an SQL statement. Parameter p is the connection the statement\n** was executed by and parameter zSql is the text of the statement itself.\n*/\nstatic void testSqllogStmt(struct SLConn *p, const char *zSql){\n  const char *zFirst;             /* Pointer to first token in zSql */\n  int nFirst;                     /* Size of token zFirst in bytes */\n\n  sqllogTokenize(zSql, &zFirst, &nFirst);\n  if( nFirst!=6 || 0!=sqlite3_strnicmp(\"ATTACH\", zFirst, 6) ){\n    /* Not an ATTACH statement. Write this directly to the log. */\n    fprintf(p->fd, \"%s; -- clock=%d\\n\", zSql, sqllogglobal.iClock++);\n  }else{\n    /* This is an ATTACH statement. Copy the database. */\n    sqllogCopydb(p, 0, 1);\n  }\n}\n\n/*\n** The database handle passed as the only argument has just been opened.\n** Return true if this module should log initial databases and SQL \n** statements for this connection, or false otherwise.\n**\n** If an error occurs, sqlite3_log() is invoked to report it to the user\n** and zero returned.\n*/\nstatic int sqllogTraceDb(sqlite3 *db){\n  int bRet = 1;\n  if( sqllogglobal.bConditional ){\n    char zFile[SQLLOG_NAMESZ];      /* Attached database name */\n    int rc = sqllogFindAttached(db, \"main\", 0, zFile);\n    if( rc==SQLITE_OK ){\n      int nFile = strlen(zFile);\n      if( (SQLLOG_NAMESZ-nFile)<8 ){\n        sqlite3_log(SQLITE_IOERR, \n            \"sqllogTraceDb(): database name too long (%d bytes)\", nFile\n        );\n        bRet = 0;\n      }else{\n        memcpy(&zFile[nFile], \"-sqllog\", 8);\n        bRet = !access(zFile, F_OK);\n      }\n    }\n  }\n  return bRet;\n}\n\n/*\n** The SQLITE_CONFIG_SQLLOG callback registered by sqlite3_init_sqllog().\n**\n** The eType parameter has the following values:\n**\n**    0:  Opening a new database connection.  zSql is the name of the\n**        file being opened.  db is a pointer to the newly created database\n**        connection.\n**\n**    1:  An SQL statement has run to completion.  zSql is the text of the\n**        SQL statement with all parameters expanded to their actual values.\n**\n**    2:  Closing a database connection.  zSql is NULL.  The db pointer to\n**        the database connection being closed has already been shut down\n**        and cannot be used for any further SQL.\n**\n** The pCtx parameter is a copy of the pointer that was originally passed\n** into the sqlite3_config(SQLITE_CONFIG_SQLLOG) statement.  In this\n** particular implementation, pCtx is always a pointer to the \n** sqllogglobal global variable define above.\n*/\nstatic void testSqllog(void *pCtx, sqlite3 *db, const char *zSql, int eType){\n  struct SLConn *p = 0;\n  sqlite3_mutex *master = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);\n\n  assert( eType==0 || eType==1 || eType==2 );\n  assert( (eType==2)==(zSql==0) );\n\n  /* This is a database open command. */\n  if( eType==0 ){\n    sqlite3_mutex_enter(master);\n    if( sqllogglobal.mutex==0 ){\n      sqllogglobal.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE);\n    }\n    sqlite3_mutex_leave(master);\n\n    sqlite3_mutex_enter(sqllogglobal.mutex);\n    if( sqllogglobal.bRec==0 && sqllogTraceDb(db) ){\n\n      sqlite3_mutex_enter(master);\n      p = &sqllogglobal.aConn[sqllogglobal.nConn++];\n      p->fd = 0;\n      p->db = db;\n      p->iLog = sqllogglobal.iNextLog++;\n      sqlite3_mutex_leave(master);\n\n      /* Open the log and take a copy of the main database file */\n      sqllogOpenlog(p);\n      if( p->fd ) sqllogCopydb(p, \"main\", 0);\n    }\n    sqlite3_mutex_leave(sqllogglobal.mutex);\n  }\n\n  else{\n\n    int i;\n    for(i=0; i<sqllogglobal.nConn; i++){\n      p = &sqllogglobal.aConn[i];\n      if( p->db==db ) break;\n    }\n\n    /* A database handle close command */\n    if( eType==2 ){\n      sqlite3_mutex_enter(master);\n      if( i<sqllogglobal.nConn ){\n        if( p->fd ) fclose(p->fd);\n        p->db = 0;\n        p->fd = 0;\n        sqllogglobal.nConn--;\n      }\n\n      if( sqllogglobal.nConn==0 ){\n        sqlite3_mutex_free(sqllogglobal.mutex);\n        sqllogglobal.mutex = 0;\n      }else if( i<sqllogglobal.nConn ){\n        int nShift = &sqllogglobal.aConn[sqllogglobal.nConn] - p;\n        if( nShift>0 ){\n          memmove(p, &p[1], nShift*sizeof(struct SLConn));\n        }\n      }\n      sqlite3_mutex_leave(master);\n\n    /* An ordinary SQL command. */\n    }else if( i<sqllogglobal.nConn && p->fd ){\n      sqlite3_mutex_enter(sqllogglobal.mutex);\n      if( sqllogglobal.bRec==0 ){\n        testSqllogStmt(p, zSql);\n      }\n      sqlite3_mutex_leave(sqllogglobal.mutex);\n    }\n  }\n}\n\n/*\n** This function is called either before sqlite3_initialized() or by it.\n** It checks if the SQLITE_SQLLOG_DIR variable is defined, and if so \n** registers an SQLITE_CONFIG_SQLLOG callback to record the applications\n** database activity.\n*/\nvoid sqlite3_init_sqllog(void){\n  if( getenv(ENVIRONMENT_VARIABLE1_NAME) ){\n    if( SQLITE_OK==sqlite3_config(SQLITE_CONFIG_SQLLOG, testSqllog, 0) ){\n      memset(&sqllogglobal, 0, sizeof(sqllogglobal));\n      sqllogglobal.bReuse = 1;\n      if( getenv(ENVIRONMENT_VARIABLE3_NAME) ){\n        sqllogglobal.bConditional = 1;\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_superlock.c",
    "content": "/*\n** 2010 November 19\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Example code for obtaining an exclusive lock on an SQLite database\n** file. This method is complicated, but works for both WAL and rollback\n** mode database files. The interface to the example code in this file \n** consists of the following two functions:\n**\n**   sqlite3demo_superlock()\n**   sqlite3demo_superunlock()\n*/\n\n#include \"sqlite3.h\"\n#include <string.h>               /* memset(), strlen() */\n#include <assert.h>               /* assert() */\n\n/*\n** A structure to collect a busy-handler callback and argument and a count\n** of the number of times it has been invoked.\n*/\nstruct SuperlockBusy {\n  int (*xBusy)(void*,int);        /* Pointer to busy-handler function */\n  void *pBusyArg;                 /* First arg to pass to xBusy */\n  int nBusy;                      /* Number of times xBusy has been invoked */\n};\ntypedef struct SuperlockBusy SuperlockBusy;\n\n/*\n** An instance of the following structure is allocated for each active\n** superlock. The opaque handle returned by sqlite3demo_superlock() is\n** actually a pointer to an instance of this structure.\n*/\nstruct Superlock {\n  sqlite3 *db;                    /* Database handle used to lock db */\n  int bWal;                       /* True if db is a WAL database */\n};\ntypedef struct Superlock Superlock;\n\n/*\n** The pCtx pointer passed to this function is actually a pointer to a\n** SuperlockBusy structure. Invoke the busy-handler function encapsulated\n** by the structure and return the result.\n*/\nstatic int superlockBusyHandler(void *pCtx, int UNUSED){\n  SuperlockBusy *pBusy = (SuperlockBusy *)pCtx;\n  if( pBusy->xBusy==0 ) return 0;\n  return pBusy->xBusy(pBusy->pBusyArg, pBusy->nBusy++);\n}\n\n/*\n** This function is used to determine if the main database file for \n** connection db is open in WAL mode or not. If no error occurs and the\n** database file is in WAL mode, set *pbWal to true and return SQLITE_OK.\n** If it is not in WAL mode, set *pbWal to false.\n**\n** If an error occurs, return an SQLite error code. The value of *pbWal\n** is undefined in this case.\n*/\nstatic int superlockIsWal(Superlock *pLock){\n  int rc;                         /* Return Code */\n  sqlite3_stmt *pStmt;            /* Compiled PRAGMA journal_mode statement */\n\n  rc = sqlite3_prepare(pLock->db, \"PRAGMA main.journal_mode\", -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n\n  pLock->bWal = 0;\n  if( SQLITE_ROW==sqlite3_step(pStmt) ){\n    const char *zMode = (const char *)sqlite3_column_text(pStmt, 0);\n    if( zMode && strlen(zMode)==3 && sqlite3_strnicmp(\"wal\", zMode, 3)==0 ){\n      pLock->bWal = 1;\n    }\n  }\n\n  return sqlite3_finalize(pStmt);\n}\n\n/*\n** Obtain an exclusive shm-lock on nByte bytes starting at offset idx\n** of the file fd. If the lock cannot be obtained immediately, invoke\n** the busy-handler until either it is obtained or the busy-handler\n** callback returns 0.\n*/\nstatic int superlockShmLock(\n  sqlite3_file *fd,               /* Database file handle */\n  int idx,                        /* Offset of shm-lock to obtain */\n  int nByte,                      /* Number of consective bytes to lock */\n  SuperlockBusy *pBusy            /* Busy-handler wrapper object */\n){\n  int rc;\n  int (*xShmLock)(sqlite3_file*, int, int, int) = fd->pMethods->xShmLock;\n  do {\n    rc = xShmLock(fd, idx, nByte, SQLITE_SHM_LOCK|SQLITE_SHM_EXCLUSIVE);\n  }while( rc==SQLITE_BUSY && superlockBusyHandler((void *)pBusy, 0) );\n  return rc;\n}\n\n/*\n** Obtain the extra locks on the database file required for WAL databases.\n** Invoke the supplied busy-handler as required.\n*/\nstatic int superlockWalLock(\n  sqlite3 *db,                    /* Database handle open on WAL database */\n  SuperlockBusy *pBusy            /* Busy handler wrapper object */\n){\n  int rc;                         /* Return code */\n  sqlite3_file *fd = 0;           /* Main database file handle */\n  void volatile *p = 0;           /* Pointer to first page of shared memory */\n\n  /* Obtain a pointer to the sqlite3_file object open on the main db file. */\n  rc = sqlite3_file_control(db, \"main\", SQLITE_FCNTL_FILE_POINTER, (void *)&fd);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Obtain the \"recovery\" lock. Normally, this lock is only obtained by\n  ** clients running database recovery.  \n  */\n  rc = superlockShmLock(fd, 2, 1, pBusy);\n  if( rc!=SQLITE_OK ) return rc;\n\n  /* Zero the start of the first shared-memory page. This means that any\n  ** clients that open read or write transactions from this point on will\n  ** have to run recovery before proceeding. Since they need the \"recovery\"\n  ** lock that this process is holding to do that, no new read or write\n  ** transactions may now be opened. Nor can a checkpoint be run, for the\n  ** same reason.\n  */\n  rc = fd->pMethods->xShmMap(fd, 0, 32*1024, 1, &p);\n  if( rc!=SQLITE_OK ) return rc;\n  memset((void *)p, 0, 32);\n\n  /* Obtain exclusive locks on all the \"read-lock\" slots. Once these locks\n  ** are held, it is guaranteed that there are no active reader, writer or \n  ** checkpointer clients.\n  */\n  rc = superlockShmLock(fd, 3, SQLITE_SHM_NLOCK-3, pBusy);\n  return rc;\n}\n\n/*\n** Release a superlock held on a database file. The argument passed to \n** this function must have been obtained from a successful call to\n** sqlite3demo_superlock().\n*/\nvoid sqlite3demo_superunlock(void *pLock){\n  Superlock *p = (Superlock *)pLock;\n  if( p->bWal ){\n    int rc;                         /* Return code */\n    int flags = SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE;\n    sqlite3_file *fd = 0;\n    rc = sqlite3_file_control(p->db, \"main\", SQLITE_FCNTL_FILE_POINTER, (void *)&fd);\n    if( rc==SQLITE_OK ){\n      fd->pMethods->xShmLock(fd, 2, 1, flags);\n      fd->pMethods->xShmLock(fd, 3, SQLITE_SHM_NLOCK-3, flags);\n    }\n  }\n  sqlite3_close(p->db);\n  sqlite3_free(p);\n}\n\n/*\n** Obtain a superlock on the database file identified by zPath, using the\n** locking primitives provided by VFS zVfs. If successful, SQLITE_OK is\n** returned and output variable *ppLock is populated with an opaque handle\n** that may be used with sqlite3demo_superunlock() to release the lock.\n**\n** If an error occurs, *ppLock is set to 0 and an SQLite error code \n** (e.g. SQLITE_BUSY) is returned.\n**\n** If a required lock cannot be obtained immediately and the xBusy parameter\n** to this function is not NULL, then xBusy is invoked in the same way\n** as a busy-handler registered with SQLite (using sqlite3_busy_handler())\n** until either the lock can be obtained or the busy-handler function returns\n** 0 (indicating \"give up\").\n*/\nint sqlite3demo_superlock(\n  const char *zPath,              /* Path to database file to lock */\n  const char *zVfs,               /* VFS to use to access database file */\n  int (*xBusy)(void*,int),        /* Busy handler callback */\n  void *pBusyArg,                 /* Context arg for busy handler */\n  void **ppLock                   /* OUT: Context to pass to superunlock() */\n){\n  SuperlockBusy busy = {0, 0, 0}; /* Busy handler wrapper object */\n  int rc;                         /* Return code */\n  Superlock *pLock;\n\n  pLock = sqlite3_malloc(sizeof(Superlock));\n  if( !pLock ) return SQLITE_NOMEM;\n  memset(pLock, 0, sizeof(Superlock));\n\n  /* Open a database handle on the file to superlock. */\n  rc = sqlite3_open_v2(\n      zPath, &pLock->db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, zVfs\n  );\n\n  /* Install a busy-handler and execute a BEGIN EXCLUSIVE. If this is not\n  ** a WAL database, this is all we need to do.  \n  **\n  ** A wrapper function is used to invoke the busy-handler instead of\n  ** registering the busy-handler function supplied by the user directly\n  ** with SQLite. This is because the same busy-handler function may be\n  ** invoked directly later on when attempting to obtain the extra locks\n  ** required in WAL mode. By using the wrapper, we are able to guarantee\n  ** that the \"nBusy\" integer parameter passed to the users busy-handler\n  ** represents the total number of busy-handler invocations made within\n  ** this call to sqlite3demo_superlock(), including any made during the\n  ** \"BEGIN EXCLUSIVE\".\n  */\n  if( rc==SQLITE_OK ){\n    busy.xBusy = xBusy;\n    busy.pBusyArg = pBusyArg;\n    sqlite3_busy_handler(pLock->db, superlockBusyHandler, (void *)&busy);\n    rc = sqlite3_exec(pLock->db, \"BEGIN EXCLUSIVE\", 0, 0, 0);\n  }\n\n  /* If the BEGIN EXCLUSIVE was executed successfully and this is a WAL\n  ** database, call superlockWalLock() to obtain the extra locks required\n  ** to prevent readers, writers and/or checkpointers from accessing the\n  ** db while this process is holding the superlock.\n  **\n  ** Before attempting any WAL locks, commit the transaction started above\n  ** to drop the WAL read and write locks currently held. Otherwise, the\n  ** new WAL locks may conflict with the old.\n  */\n  if( rc==SQLITE_OK ){\n    if( SQLITE_OK==(rc = superlockIsWal(pLock)) && pLock->bWal ){\n      rc = sqlite3_exec(pLock->db, \"COMMIT\", 0, 0, 0);\n      if( rc==SQLITE_OK ){\n        rc = superlockWalLock(pLock->db, &busy);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    sqlite3demo_superunlock(pLock);\n    *ppLock = 0;\n  }else{\n    *ppLock = pLock;\n  }\n\n  return rc;\n}\n\n/*\n** End of example code. Everything below here is the test harness.\n**************************************************************************\n**************************************************************************\n*************************************************************************/\n\n\n#ifdef SQLITE_TEST\n\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#  ifndef SQLITE_TCLAPI\n#    define SQLITE_TCLAPI\n#  endif\n#endif\n\nstruct InterpAndScript {\n  Tcl_Interp *interp;\n  Tcl_Obj *pScript;\n};\ntypedef struct InterpAndScript InterpAndScript;\n\nstatic void SQLITE_TCLAPI superunlock_del(ClientData cd){\n  sqlite3demo_superunlock((void *)cd);\n}\n\nstatic int SQLITE_TCLAPI superunlock_cmd(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  if( objc!=1 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"\");\n    return TCL_ERROR;\n  }\n  Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));\n  return TCL_OK;\n}\n\nstatic int superlock_busy(void *pCtx, int nBusy){\n  InterpAndScript *p = (InterpAndScript *)pCtx;\n  Tcl_Obj *pEval;                 /* Script to evaluate */\n  int iVal = 0;                   /* Value to return */\n\n  pEval = Tcl_DuplicateObj(p->pScript);\n  Tcl_IncrRefCount(pEval);\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewIntObj(nBusy));\n  Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);\n  Tcl_GetIntFromObj(p->interp, Tcl_GetObjResult(p->interp), &iVal);\n  Tcl_DecrRefCount(pEval);\n\n  return iVal;\n}\n\n/*\n** Tclcmd: sqlite3demo_superlock CMDNAME PATH VFS BUSY-HANDLER-SCRIPT\n*/\nstatic int SQLITE_TCLAPI superlock_cmd(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  void *pLock;                    /* Lock context */\n  char *zPath;\n  char *zVfs = 0;\n  InterpAndScript busy = {0, 0};\n  int (*xBusy)(void*,int) = 0;    /* Busy handler callback */\n  int rc;                         /* Return code from sqlite3demo_superlock() */\n\n  if( objc<3 || objc>5 ){\n    Tcl_WrongNumArgs(\n        interp, 1, objv, \"CMDNAME PATH ?VFS? ?BUSY-HANDLER-SCRIPT?\");\n    return TCL_ERROR;\n  }\n\n  zPath = Tcl_GetString(objv[2]);\n\n  if( objc>3 ){\n    zVfs = Tcl_GetString(objv[3]);\n    if( strlen(zVfs)==0 ) zVfs = 0;\n  }\n  if( objc>4 ){\n    busy.interp = interp;\n    busy.pScript = objv[4];\n    xBusy = superlock_busy;\n  }\n\n  rc = sqlite3demo_superlock(zPath, zVfs, xBusy, &busy, &pLock);\n  assert( rc==SQLITE_OK || pLock==0 );\n  assert( rc!=SQLITE_OK || pLock!=0 );\n\n  if( rc!=SQLITE_OK ){\n    extern const char *sqlite3ErrStr(int);\n    Tcl_ResetResult(interp);\n    Tcl_AppendResult(interp, sqlite3ErrStr(rc), 0);\n    return TCL_ERROR;\n  }\n\n  Tcl_CreateObjCommand(\n      interp, Tcl_GetString(objv[1]), superunlock_cmd, pLock, superunlock_del\n  );\n  Tcl_SetObjResult(interp, objv[1]);\n  return TCL_OK;\n}\n\nint SqliteSuperlock_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"sqlite3demo_superlock\", superlock_cmd, 0, 0);\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_syscall.c",
    "content": "/*\n** 2011 March 28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** The code in this file implements a Tcl interface used to test error\n** handling in the os_unix.c module. Wrapper functions that support fault\n** injection are registered as the low-level OS functions using the \n** xSetSystemCall() method of the VFS. The Tcl interface is as follows:\n**\n**\n**   test_syscall install LIST\n**     Install wrapper functions for all system calls in argument LIST.\n**     LIST must be a list consisting of zero or more of the following\n**     literal values:\n**\n**         open        close      access   getcwd   stat      fstat    \n**         ftruncate   fcntl      read     pread    pread64   write\n**         pwrite      pwrite64   fchmod   fallocate mmap\n**\n**   test_syscall uninstall\n**     Uninstall all wrapper functions.\n**\n**   test_syscall fault ?COUNT PERSIST?\n**     If [test_syscall fault] is invoked without the two arguments, fault\n**     injection is disabled. Otherwise, fault injection is configured to\n**     cause a failure on the COUNT'th next call to a system call with a\n**     wrapper function installed. A COUNT value of 1 means fail the next\n**     system call. \n** \n**     Argument PERSIST is interpreted as a boolean. If true, the all\n**     system calls following the initial failure also fail. Otherwise, only\n**     the single transient failure is injected.\n**\n**   test_syscall errno CALL ERRNO\n**     Set the value that the global \"errno\" is set to following a fault\n**     in call CALL. Argument CALL must be one of the system call names\n**     listed above (under [test_syscall install]). ERRNO is a symbolic\n**     name (i.e. \"EACCES\"). Not all errno codes are supported. Add extra\n**     to the aErrno table in function test_syscall_errno() below as \n**     required.\n**\n**   test_syscall reset ?SYSTEM-CALL?\n**     With no argument, this is an alias for the [uninstall] command. However,\n**     this command uses a VFS call of the form:\n**\n**       xSetSystemCall(pVfs, 0, 0);\n**\n**     To restore the default system calls. The [uninstall] command restores\n**     each system call individually by calling (i.e.):\n**\n**       xSetSystemCall(pVfs, \"open\", 0);\n**\n**     With an argument, this command attempts to reset the system call named\n**     by the parameter using the same method as [uninstall].\n**\n**   test_syscall exists SYSTEM-CALL\n**     Return true if the named system call exists. Or false otherwise.\n**\n**   test_syscall list\n**     Return a list of all system calls. The list is constructed using\n**     the xNextSystemCall() VFS method.\n**\n**   test_syscall pagesize PGSZ\n**     If PGSZ is a power of two greater than 256, install a wrapper around\n**     OS function getpagesize() that reports the system page size as PGSZ.\n**     Or, if PGSZ is less than zero, remove any wrapper already installed.\n*/\n\n#include \"sqliteInt.h\"\n#include \"sqlite3.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n#include <assert.h>\n\n#if SQLITE_OS_UNIX\n\n/* From main.c */\nextern const char *sqlite3ErrName(int);\n\n#include <sys/mman.h>\n#include <sys/types.h>\n#include <errno.h>\n\nstatic struct TestSyscallGlobal {\n  int bPersist;                   /* 1 for persistent errors, 0 for transient */\n  int nCount;                     /* Fail after this many more calls */\n  int nFail;                      /* Number of failures that have occurred */\n  int pgsz;\n  sqlite3_syscall_ptr orig_getpagesize;\n} gSyscall = { 0, 0, 0, 0, 0 };\n\nstatic int ts_open(const char *, int, int);\nstatic int ts_close(int fd);\nstatic int ts_access(const char *zPath, int mode);\nstatic char *ts_getcwd(char *zPath, size_t nPath);\nstatic int ts_stat(const char *zPath, struct stat *p);\nstatic int ts_fstat(int fd, struct stat *p);\nstatic int ts_ftruncate(int fd, off_t n);\nstatic int ts_fcntl(int fd, int cmd, ... );\nstatic int ts_read(int fd, void *aBuf, size_t nBuf);\nstatic int ts_pread(int fd, void *aBuf, size_t nBuf, off_t off);\n/* Note:  pread64() and pwrite64() actually use off64_t as the type on their\n** last parameter.  But that datatype is not defined on many systems \n** (ex: Mac, OpenBSD).  So substitute a likely equivalent: sqlite3_uint64 */\nstatic int ts_pread64(int fd, void *aBuf, size_t nBuf, sqlite3_uint64 off);\nstatic int ts_write(int fd, const void *aBuf, size_t nBuf);\nstatic int ts_pwrite(int fd, const void *aBuf, size_t nBuf, off_t off);\nstatic int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, sqlite3_uint64 off);\nstatic int ts_fchmod(int fd, mode_t mode);\nstatic int ts_fallocate(int fd, off_t off, off_t len);\nstatic void *ts_mmap(void *, size_t, int, int, int, off_t);\nstatic void *ts_mremap(void*, size_t, size_t, int, ...);\n\nstruct TestSyscallArray {\n  const char *zName;\n  sqlite3_syscall_ptr xTest;\n  sqlite3_syscall_ptr xOrig;\n  int default_errno;              /* Default value for errno following errors */\n  int custom_errno;               /* Current value for errno if error */\n} aSyscall[] = {\n  /*  0 */ { \"open\",      (sqlite3_syscall_ptr)ts_open,      0, EACCES, 0 },\n  /*  1 */ { \"close\",     (sqlite3_syscall_ptr)ts_close,     0, 0, 0 },\n  /*  2 */ { \"access\",    (sqlite3_syscall_ptr)ts_access,    0, 0, 0 },\n  /*  3 */ { \"getcwd\",    (sqlite3_syscall_ptr)ts_getcwd,    0, 0, 0 },\n  /*  4 */ { \"stat\",      (sqlite3_syscall_ptr)ts_stat,      0, 0, 0 },\n  /*  5 */ { \"fstat\",     (sqlite3_syscall_ptr)ts_fstat,     0, 0, 0 },\n  /*  6 */ { \"ftruncate\", (sqlite3_syscall_ptr)ts_ftruncate, 0, EIO, 0 },\n  /*  7 */ { \"fcntl\",     (sqlite3_syscall_ptr)ts_fcntl,     0, EACCES, 0 },\n  /*  8 */ { \"read\",      (sqlite3_syscall_ptr)ts_read,      0, 0, 0 },\n  /*  9 */ { \"pread\",     (sqlite3_syscall_ptr)ts_pread,     0, 0, 0 },\n  /* 10 */ { \"pread64\",   (sqlite3_syscall_ptr)ts_pread64,   0, 0, 0 },\n  /* 11 */ { \"write\",     (sqlite3_syscall_ptr)ts_write,     0, 0, 0 },\n  /* 12 */ { \"pwrite\",    (sqlite3_syscall_ptr)ts_pwrite,    0, 0, 0 },\n  /* 13 */ { \"pwrite64\",  (sqlite3_syscall_ptr)ts_pwrite64,  0, 0, 0 },\n  /* 14 */ { \"fchmod\",    (sqlite3_syscall_ptr)ts_fchmod,    0, 0, 0 },\n  /* 15 */ { \"fallocate\", (sqlite3_syscall_ptr)ts_fallocate, 0, 0, 0 },\n  /* 16 */ { \"mmap\",      (sqlite3_syscall_ptr)ts_mmap,      0, 0, 0 },\n  /* 17 */ { \"mremap\",    (sqlite3_syscall_ptr)ts_mremap,    0, 0, 0 },\n           { 0, 0, 0, 0, 0 }\n};\n\n#define orig_open      ((int(*)(const char *, int, int))aSyscall[0].xOrig)\n#define orig_close     ((int(*)(int))aSyscall[1].xOrig)\n#define orig_access    ((int(*)(const char*,int))aSyscall[2].xOrig)\n#define orig_getcwd    ((char*(*)(char*,size_t))aSyscall[3].xOrig)\n#define orig_stat      ((int(*)(const char*,struct stat*))aSyscall[4].xOrig)\n#define orig_fstat     ((int(*)(int,struct stat*))aSyscall[5].xOrig)\n#define orig_ftruncate ((int(*)(int,off_t))aSyscall[6].xOrig)\n#define orig_fcntl     ((int(*)(int,int,...))aSyscall[7].xOrig)\n#define orig_read      ((ssize_t(*)(int,void*,size_t))aSyscall[8].xOrig)\n#define orig_pread     ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].xOrig)\n#define orig_pread64   ((ssize_t(*)(int,void*,size_t,sqlite3_uint64))aSyscall[10].xOrig)\n#define orig_write     ((ssize_t(*)(int,const void*,size_t))aSyscall[11].xOrig)\n#define orig_pwrite    ((ssize_t(*)(int,const void*,size_t,off_t))\\\n                       aSyscall[12].xOrig)\n#define orig_pwrite64  ((ssize_t(*)(int,const void*,size_t,sqlite3_uint64))\\\n                       aSyscall[13].xOrig)\n#define orig_fchmod    ((int(*)(int,mode_t))aSyscall[14].xOrig)\n#define orig_fallocate ((int(*)(int,off_t,off_t))aSyscall[15].xOrig)\n#define orig_mmap      ((void*(*)(void*,size_t,int,int,int,off_t))aSyscall[16].xOrig)\n#define orig_mremap    ((void*(*)(void*,size_t,size_t,int,...))aSyscall[17].xOrig)\n\n/*\n** This function is called exactly once from within each invocation of a\n** system call wrapper in this file. It returns 1 if the function should\n** fail, or 0 if it should succeed.\n*/\nstatic int tsIsFail(void){\n  gSyscall.nCount--;\n  if( gSyscall.nCount==0 || (gSyscall.nFail && gSyscall.bPersist) ){\n    gSyscall.nFail++;\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Return the current error-number value for function zFunc. zFunc must be\n** the name of a system call in the aSyscall[] table.\n**\n** Usually, the current error-number is the value that errno should be set\n** to if the named system call fails. The exception is \"fallocate\". See \n** comments above the implementation of ts_fallocate() for details.\n*/\nstatic int tsErrno(const char *zFunc){\n  int i;\n  int nFunc = strlen(zFunc);\n  for(i=0; aSyscall[i].zName; i++){\n    if( strlen(aSyscall[i].zName)!=nFunc ) continue;\n    if( memcmp(aSyscall[i].zName, zFunc, nFunc) ) continue;\n    return aSyscall[i].custom_errno;\n  }\n\n  assert(0);\n  return 0;\n}\n\n/*\n** A wrapper around tsIsFail(). If tsIsFail() returns non-zero, set the\n** value of errno before returning.\n*/ \nstatic int tsIsFailErrno(const char *zFunc){\n  if( tsIsFail() ){\n    errno = tsErrno(zFunc);\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** A wrapper around open().\n*/\nstatic int ts_open(const char *zFile, int flags, int mode){\n  if( tsIsFailErrno(\"open\") ){\n    return -1;\n  }\n  return orig_open(zFile, flags, mode);\n}\n\n/*\n** A wrapper around close().\n*/\nstatic int ts_close(int fd){\n  if( tsIsFail() ){\n    /* Even if simulating an error, close the original file-descriptor. \n    ** This is to stop the test process from running out of file-descriptors\n    ** when running a long test. If a call to close() appears to fail, SQLite\n    ** never attempts to use the file-descriptor afterwards (or even to close\n    ** it a second time).  */\n    orig_close(fd);\n    return -1;\n  }\n  return orig_close(fd);\n}\n\n/*\n** A wrapper around access().\n*/\nstatic int ts_access(const char *zPath, int mode){\n  if( tsIsFail() ){\n    return -1;\n  }\n  return orig_access(zPath, mode);\n}\n\n/*\n** A wrapper around getcwd().\n*/\nstatic char *ts_getcwd(char *zPath, size_t nPath){\n  if( tsIsFail() ){\n    return NULL;\n  }\n  return orig_getcwd(zPath, nPath);\n}\n\n/*\n** A wrapper around stat().\n*/\nstatic int ts_stat(const char *zPath, struct stat *p){\n  if( tsIsFail() ){\n    return -1;\n  }\n  return orig_stat(zPath, p);\n}\n\n/*\n** A wrapper around fstat().\n*/\nstatic int ts_fstat(int fd, struct stat *p){\n  if( tsIsFailErrno(\"fstat\") ){\n    return -1;\n  }\n  return orig_fstat(fd, p);\n}\n\n/*\n** A wrapper around ftruncate().\n*/\nstatic int ts_ftruncate(int fd, off_t n){\n  if( tsIsFailErrno(\"ftruncate\") ){\n    return -1;\n  }\n  return orig_ftruncate(fd, n);\n}\n\n/*\n** A wrapper around fcntl().\n*/\nstatic int ts_fcntl(int fd, int cmd, ... ){\n  va_list ap;\n  void *pArg;\n  if( tsIsFailErrno(\"fcntl\") ){\n    return -1;\n  }\n  va_start(ap, cmd);\n  pArg = va_arg(ap, void *);\n  return orig_fcntl(fd, cmd, pArg);\n}\n\n/*\n** A wrapper around read().\n*/\nstatic int ts_read(int fd, void *aBuf, size_t nBuf){\n  if( tsIsFailErrno(\"read\") ){\n    return -1;\n  }\n  return orig_read(fd, aBuf, nBuf);\n}\n\n/*\n** A wrapper around pread().\n*/\nstatic int ts_pread(int fd, void *aBuf, size_t nBuf, off_t off){\n  if( tsIsFailErrno(\"pread\") ){\n    return -1;\n  }\n  return orig_pread(fd, aBuf, nBuf, off);\n}\n\n/*\n** A wrapper around pread64().\n*/\nstatic int ts_pread64(int fd, void *aBuf, size_t nBuf, sqlite3_uint64 off){\n  if( tsIsFailErrno(\"pread64\") ){\n    return -1;\n  }\n  return orig_pread64(fd, aBuf, nBuf, off);\n}\n\n/*\n** A wrapper around write().\n*/\nstatic int ts_write(int fd, const void *aBuf, size_t nBuf){\n  if( tsIsFailErrno(\"write\") ){\n    if( tsErrno(\"write\")==EINTR ) orig_write(fd, aBuf, nBuf/2);\n    return -1;\n  }\n  return orig_write(fd, aBuf, nBuf);\n}\n\n/*\n** A wrapper around pwrite().\n*/\nstatic int ts_pwrite(int fd, const void *aBuf, size_t nBuf, off_t off){\n  if( tsIsFailErrno(\"pwrite\") ){\n    return -1;\n  }\n  return orig_pwrite(fd, aBuf, nBuf, off);\n}\n\n/*\n** A wrapper around pwrite64().\n*/\nstatic int ts_pwrite64(int fd, const void *aBuf, size_t nBuf, sqlite3_uint64 off){\n  if( tsIsFailErrno(\"pwrite64\") ){\n    return -1;\n  }\n  return orig_pwrite64(fd, aBuf, nBuf, off);\n}\n\n/*\n** A wrapper around fchmod().\n*/\nstatic int ts_fchmod(int fd, mode_t mode){\n  if( tsIsFail() ){\n    return -1;\n  }\n  return orig_fchmod(fd, mode);\n}\n\n/*\n** A wrapper around fallocate().\n**\n** SQLite assumes that the fallocate() function is compatible with\n** posix_fallocate(). According to the Linux man page (2009-09-30):\n**\n**   posix_fallocate() returns  zero on success, or an error number on\n**   failure. Note that errno is not set.\n*/\nstatic int ts_fallocate(int fd, off_t off, off_t len){\n  if( tsIsFail() ){\n    return tsErrno(\"fallocate\");\n  }\n  return orig_fallocate(fd, off, len);\n}\n\nstatic void *ts_mmap(\n  void *pAddr, \n  size_t nByte, \n  int prot, \n  int flags, \n  int fd, \n  off_t iOff\n){\n  if( tsIsFailErrno(\"mmap\") ){\n    return MAP_FAILED;\n  }\n  return orig_mmap(pAddr, nByte, prot, flags, fd, iOff);\n}\n\nstatic void *ts_mremap(void *a, size_t b, size_t c, int d, ...){\n  va_list ap;\n  void *pArg;\n  if( tsIsFailErrno(\"mremap\") ){\n    return MAP_FAILED;\n  }\n  va_start(ap, d);\n  pArg = va_arg(ap, void *);\n  return orig_mremap(a, b, c, d, pArg);\n}\n\nstatic int SQLITE_TCLAPI test_syscall_install(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs; \n  int nElem;\n  int i;\n  Tcl_Obj **apElem;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"SYSCALL-LIST\");\n    return TCL_ERROR;\n  }\n  if( Tcl_ListObjGetElements(interp, objv[2], &nElem, &apElem) ){\n    return TCL_ERROR;\n  }\n  pVfs = sqlite3_vfs_find(0);\n\n  for(i=0; i<nElem; i++){\n    int iCall;\n    int rc = Tcl_GetIndexFromObjStruct(interp, \n        apElem[i], aSyscall, sizeof(aSyscall[0]), \"system-call\", 0, &iCall\n    );\n    if( rc ) return rc;\n    if( aSyscall[iCall].xOrig==0 ){\n      aSyscall[iCall].xOrig = pVfs->xGetSystemCall(pVfs, aSyscall[iCall].zName);\n      pVfs->xSetSystemCall(pVfs, aSyscall[iCall].zName, aSyscall[iCall].xTest);\n    }\n    aSyscall[iCall].custom_errno = aSyscall[iCall].default_errno;\n  }\n\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_uninstall(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs; \n  int i;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pVfs = sqlite3_vfs_find(0);\n  for(i=0; aSyscall[i].zName; i++){\n    if( aSyscall[i].xOrig ){\n      pVfs->xSetSystemCall(pVfs, aSyscall[i].zName, 0);\n      aSyscall[i].xOrig = 0;\n    }\n  }\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_reset(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs; \n  int i;\n  int rc;\n\n  if( objc!=2 && objc!=3 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pVfs = sqlite3_vfs_find(0);\n  if( objc==2 ){\n    rc = pVfs->xSetSystemCall(pVfs, 0, 0);\n    for(i=0; aSyscall[i].zName; i++) aSyscall[i].xOrig = 0;\n  }else{\n    int nFunc;\n    char *zFunc = Tcl_GetStringFromObj(objv[2], &nFunc);\n    rc = pVfs->xSetSystemCall(pVfs, Tcl_GetString(objv[2]), 0);\n    for(i=0; rc==SQLITE_OK && aSyscall[i].zName; i++){\n      if( strlen(aSyscall[i].zName)!=nFunc ) continue;\n      if( memcmp(aSyscall[i].zName, zFunc, nFunc) ) continue;\n      aSyscall[i].xOrig = 0;\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));\n    return TCL_ERROR;\n  }\n\n  Tcl_ResetResult(interp);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_exists(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs; \n  sqlite3_syscall_ptr x;\n\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pVfs = sqlite3_vfs_find(0);\n  x = pVfs->xGetSystemCall(pVfs, Tcl_GetString(objv[2]));\n\n  Tcl_SetObjResult(interp, Tcl_NewBooleanObj(x!=0));\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_fault(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int nCount = 0;\n  int bPersist = 0;\n\n  if( objc!=2 && objc!=4 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"?COUNT PERSIST?\");\n    return TCL_ERROR;\n  }\n\n  if( objc==4 ){\n    if( Tcl_GetIntFromObj(interp, objv[2], &nCount)\n     || Tcl_GetBooleanFromObj(interp, objv[3], &bPersist)\n    ){\n      return TCL_ERROR;\n    }\n  }\n\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(gSyscall.nFail));\n  gSyscall.nCount = nCount;\n  gSyscall.bPersist = bPersist;\n  gSyscall.nFail = 0;\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_errno(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int iCall;\n  int iErrno;\n  int rc;\n\n  struct Errno {\n    const char *z;\n    int i;\n  } aErrno[] = {\n    { \"EACCES\",    EACCES },\n    { \"EINTR\",     EINTR },\n    { \"EIO\",       EIO },\n    { \"EOVERFLOW\", EOVERFLOW },\n    { \"ENOMEM\",    ENOMEM },\n    { \"EAGAIN\",    EAGAIN },\n    { \"ETIMEDOUT\", ETIMEDOUT },\n    { \"EBUSY\",     EBUSY },\n    { \"EPERM\",     EPERM },\n    { \"EDEADLK\",   EDEADLK },\n    { \"ENOLCK\",    ENOLCK },\n    { 0, 0 }\n  };\n\n  if( objc!=4 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"SYSCALL ERRNO\");\n    return TCL_ERROR;\n  }\n\n  rc = Tcl_GetIndexFromObjStruct(interp, \n      objv[2], aSyscall, sizeof(aSyscall[0]), \"system-call\", 0, &iCall\n  );\n  if( rc!=TCL_OK ) return rc;\n  rc = Tcl_GetIndexFromObjStruct(interp, \n      objv[3], aErrno, sizeof(aErrno[0]), \"errno\", 0, &iErrno\n  );\n  if( rc!=TCL_OK ) return rc;\n\n  aSyscall[iCall].custom_errno = aErrno[iErrno].i;\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_list(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  const char *zSys;\n  sqlite3_vfs *pVfs; \n  Tcl_Obj *pList;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pVfs = sqlite3_vfs_find(0);\n  pList = Tcl_NewObj();\n  Tcl_IncrRefCount(pList);\n  for(zSys = pVfs->xNextSystemCall(pVfs, 0); \n      zSys!=0;\n      zSys = pVfs->xNextSystemCall(pVfs, zSys)\n  ){\n    Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(zSys, -1));\n  }\n\n  Tcl_SetObjResult(interp, pList);\n  Tcl_DecrRefCount(pList);\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_defaultvfs(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs; \n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"\");\n    return TCL_ERROR;\n  }\n\n  pVfs = sqlite3_vfs_find(0);\n  Tcl_SetObjResult(interp, Tcl_NewStringObj(pVfs->zName, -1));\n  return TCL_OK;\n}\n\nstatic int ts_getpagesize(void){\n  return gSyscall.pgsz;\n}\n\nstatic int SQLITE_TCLAPI test_syscall_pagesize(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n  int pgsz;\n  if( objc!=3 ){\n    Tcl_WrongNumArgs(interp, 2, objv, \"PGSZ\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIntFromObj(interp, objv[2], &pgsz) ){\n    return TCL_ERROR;\n  }\n\n  if( pgsz<0 ){\n    if( gSyscall.orig_getpagesize ){\n      pVfs->xSetSystemCall(pVfs, \"getpagesize\", gSyscall.orig_getpagesize);\n    }\n  }else{\n    if( pgsz<512 || (pgsz & (pgsz-1)) ){\n      Tcl_AppendResult(interp, \"pgsz out of range\", 0);\n      return TCL_ERROR;\n    }\n    gSyscall.orig_getpagesize = pVfs->xGetSystemCall(pVfs, \"getpagesize\");\n    gSyscall.pgsz = pgsz;\n    pVfs->xSetSystemCall(\n        pVfs, \"getpagesize\", (sqlite3_syscall_ptr)ts_getpagesize\n    );\n  }\n\n  return TCL_OK;\n}\n\nstatic int SQLITE_TCLAPI test_syscall(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct SyscallCmd {\n    const char *zName;\n    Tcl_ObjCmdProc *xCmd;\n  } aCmd[] = {\n    { \"fault\",      test_syscall_fault },\n    { \"install\",    test_syscall_install },\n    { \"uninstall\",  test_syscall_uninstall },\n    { \"reset\",      test_syscall_reset },\n    { \"errno\",      test_syscall_errno },\n    { \"exists\",     test_syscall_exists },\n    { \"list\",       test_syscall_list },\n    { \"defaultvfs\", test_syscall_defaultvfs },\n    { \"pagesize\",   test_syscall_pagesize },\n    { 0, 0 }\n  };\n  int iCmd;\n  int rc;\n  sqlite3_vfs *pVfs = sqlite3_vfs_find(0);\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUB-COMMAND ...\");\n    return TCL_ERROR;\n  }\n  if( pVfs->iVersion<3 || pVfs->xSetSystemCall==0 ){\n    Tcl_AppendResult(interp, \"VFS does not support xSetSystemCall\", 0);\n    rc = TCL_ERROR;\n  }else{\n    rc = Tcl_GetIndexFromObjStruct(interp, \n        objv[1], aCmd, sizeof(aCmd[0]), \"sub-command\", 0, &iCmd\n    );\n  }\n  if( rc!=TCL_OK ) return rc;\n  return aCmd[iCmd].xCmd(clientData, interp, objc, objv);\n}\n\nint SqlitetestSyscall_Init(Tcl_Interp *interp){\n  struct SyscallCmd {\n    const char *zName;\n    Tcl_ObjCmdProc *xCmd;\n  } aCmd[] = {\n    { \"test_syscall\",     test_syscall},\n  };\n  int i;\n\n  for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aCmd[i].zName, aCmd[i].xCmd, 0, 0);\n  }\n  return TCL_OK;\n}\n#else\nint SqlitetestSyscall_Init(Tcl_Interp *interp){\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_tclsh.c",
    "content": "/*\n** 2017-10-13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains extensions to the the \"tclsqlite.c\" module used for\n** testing.  Basically, all of the other \"test_*.c\" modules are linked\n** into the enhanced tclsh used for testing (and named \"testfixture\" or\n** \"testfixture.exe\") using logic encoded by this file.\n**\n** The code in this file used to be found in tclsqlite3.c, contained within\n** #if SQLITE_TEST ... #endif.  It is factored out into this separate module\n** in an effort to keep the tclsqlite.c file pure.\n*/\n#include \"sqlite3.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n# include \"sqlite_tcl.h\"\n#else\n# include \"tcl.h\"\n# ifndef SQLITE_TCLAPI\n#  define SQLITE_TCLAPI\n# endif\n#endif\n\n/* Needed for the setrlimit() system call on unix */\n#if defined(unix)\n#include <sys/resource.h>\n#endif\n\n/* Forward declaration */\nstatic int SQLITE_TCLAPI load_testfixture_extensions(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n);\n\n/*\n** This routine is the primary export of this file.\n**\n** Configure the interpreter passed as the first argument to have access\n** to the commands and linked variables that make up:\n**\n**   * the [sqlite3] extension itself,\n**\n**   * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and\n**\n**   * If SQLITE_TEST is set, the various test interfaces used by the Tcl\n**     test suite.\n*/\nconst char *sqlite3TestInit(Tcl_Interp *interp){\n  extern int Sqlite3_Init(Tcl_Interp*);\n  extern int Sqliteconfig_Init(Tcl_Interp*);\n  extern int Sqlitetest1_Init(Tcl_Interp*);\n  extern int Sqlitetest2_Init(Tcl_Interp*);\n  extern int Sqlitetest3_Init(Tcl_Interp*);\n  extern int Sqlitetest4_Init(Tcl_Interp*);\n  extern int Sqlitetest5_Init(Tcl_Interp*);\n  extern int Sqlitetest6_Init(Tcl_Interp*);\n  extern int Sqlitetest7_Init(Tcl_Interp*);\n  extern int Sqlitetest8_Init(Tcl_Interp*);\n  extern int Sqlitetest9_Init(Tcl_Interp*);\n  extern int Sqlitetestasync_Init(Tcl_Interp*);\n  extern int Sqlitetest_autoext_Init(Tcl_Interp*);\n  extern int Sqlitetest_blob_Init(Tcl_Interp*);\n  extern int Sqlitetest_demovfs_Init(Tcl_Interp *);\n  extern int Sqlitetest_func_Init(Tcl_Interp*);\n  extern int Sqlitetest_hexio_Init(Tcl_Interp*);\n  extern int Sqlitetest_init_Init(Tcl_Interp*);\n  extern int Sqlitetest_malloc_Init(Tcl_Interp*);\n  extern int Sqlitetest_mutex_Init(Tcl_Interp*);\n  extern int Sqlitetestschema_Init(Tcl_Interp*);\n  extern int Sqlitetestsse_Init(Tcl_Interp*);\n  extern int Sqlitetesttclvar_Init(Tcl_Interp*);\n  extern int Sqlitetestfs_Init(Tcl_Interp*);\n  extern int SqlitetestThread_Init(Tcl_Interp*);\n  extern int SqlitetestOnefile_Init();\n  extern int SqlitetestOsinst_Init(Tcl_Interp*);\n  extern int Sqlitetestbackup_Init(Tcl_Interp*);\n  extern int Sqlitetestintarray_Init(Tcl_Interp*);\n  extern int Sqlitetestvfs_Init(Tcl_Interp *);\n  extern int Sqlitetestrtree_Init(Tcl_Interp*);\n  extern int Sqlitequota_Init(Tcl_Interp*);\n  extern int Sqlitemultiplex_Init(Tcl_Interp*);\n  extern int SqliteSuperlock_Init(Tcl_Interp*);\n  extern int SqlitetestSyscall_Init(Tcl_Interp*);\n#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n  extern int TestSession_Init(Tcl_Interp*);\n#endif\n  extern int Md5_Init(Tcl_Interp*);\n  extern int Fts5tcl_Init(Tcl_Interp *);\n  extern int SqliteRbu_Init(Tcl_Interp*);\n  extern int Sqlitetesttcl_Init(Tcl_Interp*);\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n  extern int Sqlitetestfts3_Init(Tcl_Interp *interp);\n#endif\n#ifdef SQLITE_ENABLE_ZIPVFS\n  extern int Zipvfs_Init(Tcl_Interp*);\n#endif\n  Tcl_CmdInfo cmdInfo;\n\n  /* Since the primary use case for this binary is testing of SQLite,\n  ** be sure to generate core files if we crash */\n#if defined(unix)\n  { struct rlimit x;\n    getrlimit(RLIMIT_CORE, &x);\n    x.rlim_cur = x.rlim_max;\n    setrlimit(RLIMIT_CORE, &x);\n  }\n#endif /* unix */\n\n  if( Tcl_GetCommandInfo(interp, \"sqlite3\", &cmdInfo)==0 ){\n    Sqlite3_Init(interp);\n  }\n#ifdef SQLITE_ENABLE_ZIPVFS\n  Zipvfs_Init(interp);\n#endif\n  Md5_Init(interp);\n  Sqliteconfig_Init(interp);\n  Sqlitetest1_Init(interp);\n  Sqlitetest2_Init(interp);\n  Sqlitetest3_Init(interp);\n  Sqlitetest4_Init(interp);\n  Sqlitetest5_Init(interp);\n  Sqlitetest6_Init(interp);\n  Sqlitetest7_Init(interp);\n  Sqlitetest8_Init(interp);\n  Sqlitetest9_Init(interp);\n  Sqlitetestasync_Init(interp);\n  Sqlitetest_autoext_Init(interp);\n  Sqlitetest_blob_Init(interp);\n  Sqlitetest_demovfs_Init(interp);\n  Sqlitetest_func_Init(interp);\n  Sqlitetest_hexio_Init(interp);\n  Sqlitetest_init_Init(interp);\n  Sqlitetest_malloc_Init(interp);\n  Sqlitetest_mutex_Init(interp);\n  Sqlitetestschema_Init(interp);\n  Sqlitetesttclvar_Init(interp);\n  Sqlitetestfs_Init(interp);\n  SqlitetestThread_Init(interp);\n  SqlitetestOnefile_Init();\n  SqlitetestOsinst_Init(interp);\n  Sqlitetestbackup_Init(interp);\n  Sqlitetestintarray_Init(interp);\n  Sqlitetestvfs_Init(interp);\n  Sqlitetestrtree_Init(interp);\n  Sqlitequota_Init(interp);\n  Sqlitemultiplex_Init(interp);\n  SqliteSuperlock_Init(interp);\n  SqlitetestSyscall_Init(interp);\n#if defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK)\n  TestSession_Init(interp);\n#endif\n  Fts5tcl_Init(interp);\n  SqliteRbu_Init(interp);\n  Sqlitetesttcl_Init(interp);\n\n#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)\n  Sqlitetestfts3_Init(interp);\n#endif\n\n  Tcl_CreateObjCommand(\n      interp, \"load_testfixture_extensions\", load_testfixture_extensions,0,0\n  );\n  return 0;\n}\n\n/* tclcmd:   load_testfixture_extensions\n*/\nstatic int SQLITE_TCLAPI load_testfixture_extensions(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n\n  Tcl_Interp *slave;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SLAVE\");\n    return TCL_ERROR;\n  }\n\n  slave = Tcl_GetSlave(interp, Tcl_GetString(objv[1]));\n  if( !slave ){\n    return TCL_ERROR;\n  }\n\n  (void)sqlite3TestInit(slave);\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_tclvar.c",
    "content": "/*\n** 2006 June 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Code for testing the virtual table interfaces.  This code\n** is not included in the SQLite library.  It is used for automated\n** testing of the SQLite library.\n**\n** The emphasis of this file is a virtual table that provides\n** access to TCL variables.\n**\n** The TCLVAR eponymous virtual table has a schema like this:\n**\n**    CREATE TABLE tclvar(\n**       name TEXT,       -- base name of the variable:  \"x\" in \"$x(y)\"\n**       arrayname TEXT,  -- array index name: \"y\" in \"$x(y)\"\n**       value TEXT,      -- the value of the variable \n**       fullname TEXT,   -- the full name of the variable\n**       PRIMARY KEY(fullname)\n**    ) WITHOUT ROWID;\n**\n** DELETE, INSERT, and UPDATE operations use the \"fullname\" field to\n** determine the variable to be modified.  Changing \"value\" to NULL\n** deletes the variable.\n**\n** For SELECT operations, the \"name\" and \"arrayname\" fields will always\n** match the \"fullname\" field.  For DELETE, INSERT, and UPDATE, the\n** \"name\" and \"arrayname\" fields are ignored and the variable is modified\n** according to \"fullname\" and \"value\" only.\n*/\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n#include <stdlib.h>\n#include <string.h>\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Characters that make up the idxStr created by xBestIndex for xFilter.\n*/\n#define TCLVAR_NAME_EQ      'e'\n#define TCLVAR_NAME_MATCH   'm'\n#define TCLVAR_VALUE_GLOB   'g'\n#define TCLVAR_VALUE_REGEXP 'r'\n#define TCLVAR_VALUE_LIKE   'l'\n\ntypedef struct tclvar_vtab tclvar_vtab;\ntypedef struct tclvar_cursor tclvar_cursor;\n\n/* \n** A tclvar virtual-table object \n*/\nstruct tclvar_vtab {\n  sqlite3_vtab base;\n  Tcl_Interp *interp;\n};\n\n/* A tclvar cursor object */\nstruct tclvar_cursor {\n  sqlite3_vtab_cursor base;\n\n  Tcl_Obj *pList1;     /* Result of [info vars ?pattern?] */\n  Tcl_Obj *pList2;     /* Result of [array names [lindex $pList1 $i1]] */\n  int i1;              /* Current item in pList1 */\n  int i2;              /* Current item (if any) in pList2 */\n};\n\n/* Methods for the tclvar module */\nstatic int tclvarConnect(\n  sqlite3 *db,\n  void *pAux,\n  int argc, const char *const*argv,\n  sqlite3_vtab **ppVtab,\n  char **pzErr\n){\n  tclvar_vtab *pVtab;\n  static const char zSchema[] = \n     \"CREATE TABLE x(\"\n     \"  name TEXT,\"                       /* Base name */\n     \"  arrayname TEXT,\"                  /* Array index */\n     \"  value TEXT,\"                      /* Value */\n     \"  fullname TEXT PRIMARY KEY\"        /* base(index) name */\n     \") WITHOUT ROWID\";\n  pVtab = sqlite3MallocZero( sizeof(*pVtab) );\n  if( pVtab==0 ) return SQLITE_NOMEM;\n  *ppVtab = &pVtab->base;\n  pVtab->interp = (Tcl_Interp *)pAux;\n  sqlite3_declare_vtab(db, zSchema);\n  return SQLITE_OK;\n}\n/* Note that for this virtual table, the xCreate and xConnect\n** methods are identical. */\n\nstatic int tclvarDisconnect(sqlite3_vtab *pVtab){\n  sqlite3_free(pVtab);\n  return SQLITE_OK;\n}\n/* The xDisconnect and xDestroy methods are also the same */\n\n/*\n** Open a new tclvar cursor.\n*/\nstatic int tclvarOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){\n  tclvar_cursor *pCur;\n  pCur = sqlite3MallocZero(sizeof(tclvar_cursor));\n  *ppCursor = &pCur->base;\n  return SQLITE_OK;\n}\n\n/*\n** Close a tclvar cursor.\n*/\nstatic int tclvarClose(sqlite3_vtab_cursor *cur){\n  tclvar_cursor *pCur = (tclvar_cursor *)cur;\n  if( pCur->pList1 ){\n    Tcl_DecrRefCount(pCur->pList1);\n  }\n  if( pCur->pList2 ){\n    Tcl_DecrRefCount(pCur->pList2);\n  }\n  sqlite3_free(pCur);\n  return SQLITE_OK;\n}\n\n/*\n** Returns 1 if data is ready, or 0 if not.\n*/\nstatic int next2(Tcl_Interp *interp, tclvar_cursor *pCur, Tcl_Obj *pObj){\n  Tcl_Obj *p;\n\n  if( pObj ){\n    if( !pCur->pList2 ){\n      p = Tcl_NewStringObj(\"array names\", -1);\n      Tcl_IncrRefCount(p);\n      Tcl_ListObjAppendElement(0, p, pObj);\n      Tcl_EvalObjEx(interp, p, TCL_EVAL_GLOBAL);\n      Tcl_DecrRefCount(p);\n      pCur->pList2 = Tcl_GetObjResult(interp);\n      Tcl_IncrRefCount(pCur->pList2);\n      assert( pCur->i2==0 );\n    }else{\n      int n = 0;\n      pCur->i2++;\n      Tcl_ListObjLength(0, pCur->pList2, &n);\n      if( pCur->i2>=n ){\n        Tcl_DecrRefCount(pCur->pList2);\n        pCur->pList2 = 0;\n        pCur->i2 = 0;\n        return 0;\n      }\n    }\n  }\n\n  return 1;\n}\n\nstatic int tclvarNext(sqlite3_vtab_cursor *cur){\n  Tcl_Obj *pObj;\n  int n = 0;\n  int ok = 0;\n\n  tclvar_cursor *pCur = (tclvar_cursor *)cur;\n  Tcl_Interp *interp = ((tclvar_vtab *)(cur->pVtab))->interp;\n\n  Tcl_ListObjLength(0, pCur->pList1, &n);\n  while( !ok && pCur->i1<n ){\n    Tcl_ListObjIndex(0, pCur->pList1, pCur->i1, &pObj);\n    ok = next2(interp, pCur, pObj);\n    if( !ok ){\n      pCur->i1++;\n    }\n  }\n\n  return 0;\n}\n\nstatic int tclvarFilter(\n  sqlite3_vtab_cursor *pVtabCursor, \n  int idxNum, const char *idxStr,\n  int argc, sqlite3_value **argv\n){\n  tclvar_cursor *pCur = (tclvar_cursor *)pVtabCursor;\n  Tcl_Interp *interp = ((tclvar_vtab *)(pVtabCursor->pVtab))->interp;\n  Tcl_Obj *p = Tcl_NewStringObj(\"tclvar_filter_cmd\", -1);\n\n  const char *zEq = \"\";\n  const char *zMatch = \"\";\n  const char *zGlob = \"\";\n  const char *zRegexp = \"\";\n  const char *zLike = \"\";\n  int i;\n\n  for(i=0; idxStr[i]; i++){\n    switch( idxStr[i] ){\n      case TCLVAR_NAME_EQ:\n        zEq = (const char*)sqlite3_value_text(argv[i]);\n        break;\n      case TCLVAR_NAME_MATCH:\n        zMatch = (const char*)sqlite3_value_text(argv[i]);\n        break;\n      case TCLVAR_VALUE_GLOB:\n        zGlob = (const char*)sqlite3_value_text(argv[i]);\n        break;\n      case TCLVAR_VALUE_REGEXP:\n        zRegexp = (const char*)sqlite3_value_text(argv[i]);\n        break;\n      case TCLVAR_VALUE_LIKE:\n        zLike = (const char*)sqlite3_value_text(argv[i]);\n        break;\n      default:\n        assert( 0 );\n    }\n  }\n\n  Tcl_IncrRefCount(p);\n  Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zEq, -1));\n  Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zMatch, -1));\n  Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zGlob, -1));\n  Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zRegexp, -1));\n  Tcl_ListObjAppendElement(0, p, Tcl_NewStringObj(zLike, -1));\n\n  Tcl_EvalObjEx(interp, p, TCL_EVAL_GLOBAL);\n  if( pCur->pList1 ){\n    Tcl_DecrRefCount(pCur->pList1);\n  }\n  if( pCur->pList2 ){\n    Tcl_DecrRefCount(pCur->pList2);\n    pCur->pList2 = 0;\n  }\n  pCur->i1 = 0;\n  pCur->i2 = 0;\n  pCur->pList1 = Tcl_GetObjResult(interp);\n  Tcl_IncrRefCount(pCur->pList1);\n\n  Tcl_DecrRefCount(p);\n  return tclvarNext(pVtabCursor);\n}\n\nstatic int tclvarColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){\n  Tcl_Obj *p1;\n  Tcl_Obj *p2;\n  const char *z1; \n  const char *z2 = \"\";\n  tclvar_cursor *pCur = (tclvar_cursor*)cur;\n  Tcl_Interp *interp = ((tclvar_vtab *)cur->pVtab)->interp;\n\n  Tcl_ListObjIndex(interp, pCur->pList1, pCur->i1, &p1);\n  Tcl_ListObjIndex(interp, pCur->pList2, pCur->i2, &p2);\n  z1 = Tcl_GetString(p1);\n  if( p2 ){\n    z2 = Tcl_GetString(p2);\n  }\n  switch (i) {\n    case 0: {\n      sqlite3_result_text(ctx, z1, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case 1: {\n      sqlite3_result_text(ctx, z2, -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case 2: {\n      Tcl_Obj *pVal = Tcl_GetVar2Ex(interp, z1, *z2?z2:0, TCL_GLOBAL_ONLY);\n      sqlite3_result_text(ctx, Tcl_GetString(pVal), -1, SQLITE_TRANSIENT);\n      break;\n    }\n    case 3: {\n      char *z3;\n      if( p2 ){\n        z3 = sqlite3_mprintf(\"%s(%s)\", z1, z2);\n        sqlite3_result_text(ctx, z3, -1, sqlite3_free);\n      }else{\n        sqlite3_result_text(ctx, z1, -1, SQLITE_TRANSIENT);\n      }\n      break;\n    }\n  }\n  return SQLITE_OK;\n}\n\nstatic int tclvarRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){\n  *pRowid = 0;\n  return SQLITE_OK;\n}\n\nstatic int tclvarEof(sqlite3_vtab_cursor *cur){\n  tclvar_cursor *pCur = (tclvar_cursor*)cur;\n  return (pCur->pList2?0:1);\n}\n\n/*\n** If nul-terminated string zStr does not already contain the character \n** passed as the second argument, append it and return 0. Or, if there is\n** already an instance of x in zStr, do nothing return 1;\n**\n** There is guaranteed to be enough room in the buffer pointed to by zStr\n** for the new character and nul-terminator.\n*/\nstatic int tclvarAddToIdxstr(char *zStr, char x){\n  int i;\n  for(i=0; zStr[i]; i++){\n    if( zStr[i]==x ) return 1;\n  }\n  zStr[i] = x;\n  zStr[i+1] = '\\0';\n  return 0;\n}\n\n/*\n** Return true if variable $::tclvar_set_omit exists and is set to true.\n** False otherwise.\n*/\nstatic int tclvarSetOmit(Tcl_Interp *interp){\n  int rc;\n  int res = 0;\n  Tcl_Obj *pRes;\n  rc = Tcl_Eval(interp,\n    \"expr {[info exists ::tclvar_set_omit] && $::tclvar_set_omit}\"\n  );\n  if( rc==TCL_OK ){\n    pRes = Tcl_GetObjResult(interp);\n    rc = Tcl_GetBooleanFromObj(0, pRes, &res);\n  }\n  return (rc==TCL_OK && res);\n}\n\n/*\n** The xBestIndex() method. This virtual table supports the following\n** operators:\n**\n**     name = ?                    (omit flag clear)\n**     name MATCH ?                (omit flag set)\n**     value GLOB ?                (omit flag set iff $::tclvar_set_omit)\n**     value REGEXP ?              (omit flag set iff $::tclvar_set_omit)\n**     value LIKE ?                (omit flag set iff $::tclvar_set_omit)\n**\n** For each constraint present, the corresponding TCLVAR_XXX character is\n** appended to the idxStr value. \n*/\nstatic int tclvarBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){\n  tclvar_vtab *pTab = (tclvar_vtab*)tab;\n  int ii;\n  char *zStr = sqlite3_malloc(32);\n  int iStr = 0;\n\n  if( zStr==0 ) return SQLITE_NOMEM;\n  zStr[0] = '\\0';\n\n  for(ii=0; ii<pIdxInfo->nConstraint; ii++){\n    struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii];\n    struct sqlite3_index_constraint_usage *pUsage;\n    \n    pUsage = &pIdxInfo->aConstraintUsage[ii];\n    if( pCons->usable ){\n      /* name = ? */\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ && pCons->iColumn==0 ){\n        if( 0==tclvarAddToIdxstr(zStr, TCLVAR_NAME_EQ) ){\n          pUsage->argvIndex = ++iStr;\n          pUsage->omit = 0;\n        }\n      }\n\n      /* name MATCH ? */\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH && pCons->iColumn==0 ){\n        if( 0==tclvarAddToIdxstr(zStr, TCLVAR_NAME_MATCH) ){\n          pUsage->argvIndex = ++iStr;\n          pUsage->omit = 1;\n        }\n      }\n\n      /* value GLOB ? */\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_GLOB && pCons->iColumn==2 ){\n        if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_GLOB) ){\n          pUsage->argvIndex = ++iStr;\n          pUsage->omit = tclvarSetOmit(pTab->interp);\n        }\n      }\n\n      /* value REGEXP ? */\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_REGEXP && pCons->iColumn==2 ){\n        if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_REGEXP) ){\n          pUsage->argvIndex = ++iStr;\n          pUsage->omit = tclvarSetOmit(pTab->interp);\n        }\n      }\n\n      /* value LIKE ? */\n      if( pCons->op==SQLITE_INDEX_CONSTRAINT_LIKE && pCons->iColumn==2 ){\n        if( 0==tclvarAddToIdxstr(zStr, TCLVAR_VALUE_LIKE) ){\n          pUsage->argvIndex = ++iStr;\n          pUsage->omit = tclvarSetOmit(pTab->interp);\n        }\n      }\n    }\n  }\n  pIdxInfo->idxStr = zStr;\n  pIdxInfo->needToFreeIdxStr = 1;\n\n  return SQLITE_OK;\n}\n\n/*\n** Invoked for any UPDATE, INSERT, or DELETE against a tclvar table\n*/\nstatic int tclvarUpdate(\n  sqlite3_vtab *tab,\n  int argc,\n  sqlite3_value **argv,\n  sqlite_int64 *pRowid\n){\n  tclvar_vtab *pTab = (tclvar_vtab*)tab;\n  if( argc==1 ){\n    /* A DELETE operation.  The variable to be deleted is stored in argv[0] */\n    const char *zVar = (const char*)sqlite3_value_text(argv[0]);\n    Tcl_UnsetVar(pTab->interp, zVar, TCL_GLOBAL_ONLY);\n    return SQLITE_OK;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ){\n    /* An INSERT operation */\n    const char *zValue = (const char*)sqlite3_value_text(argv[4]);\n    const char *zName;\n    if( sqlite3_value_type(argv[5])!=SQLITE_TEXT ){\n      tab->zErrMsg = sqlite3_mprintf(\"the 'fullname' column must be TEXT\");\n      return SQLITE_ERROR;\n    }\n    zName = (const char*)sqlite3_value_text(argv[5]);\n    if( zValue ){\n      Tcl_SetVar(pTab->interp, zName, zValue, TCL_GLOBAL_ONLY);\n    }else{\n      Tcl_UnsetVar(pTab->interp, zName, TCL_GLOBAL_ONLY);\n    }\n    return SQLITE_OK;\n  }\n  if( sqlite3_value_type(argv[0])==SQLITE_TEXT\n   && sqlite3_value_type(argv[1])==SQLITE_TEXT\n  ){\n    /* An UPDATE operation */\n    const char *zOldName = (const char*)sqlite3_value_text(argv[0]);\n    const char *zNewName = (const char*)sqlite3_value_text(argv[1]);\n    const char *zValue = (const char*)sqlite3_value_text(argv[4]);\n\n    if( strcmp(zOldName, zNewName)!=0 || zValue==0 ){\n      Tcl_UnsetVar(pTab->interp, zOldName, TCL_GLOBAL_ONLY);\n    }\n    if( zValue!=0 ){\n      Tcl_SetVar(pTab->interp, zNewName, zValue, TCL_GLOBAL_ONLY);\n    }\n    return SQLITE_OK;\n  }\n  tab->zErrMsg = sqlite3_mprintf(\"prohibited TCL variable change\");\n  return SQLITE_ERROR;\n}\n\n/*\n** A virtual table module that provides read-only access to a\n** Tcl global variable namespace.\n*/\nstatic sqlite3_module tclvarModule = {\n  0,                         /* iVersion */\n  tclvarConnect,\n  tclvarConnect,\n  tclvarBestIndex,\n  tclvarDisconnect, \n  tclvarDisconnect,\n  tclvarOpen,                  /* xOpen - open a cursor */\n  tclvarClose,                 /* xClose - close a cursor */\n  tclvarFilter,                /* xFilter - configure scan constraints */\n  tclvarNext,                  /* xNext - advance a cursor */\n  tclvarEof,                   /* xEof - check for end of scan */\n  tclvarColumn,                /* xColumn - read data */\n  tclvarRowid,                 /* xRowid - read data */\n  tclvarUpdate,                /* xUpdate */\n  0,                           /* xBegin */\n  0,                           /* xSync */\n  0,                           /* xCommit */\n  0,                           /* xRollback */\n  0,                           /* xFindMethod */\n  0,                           /* xRename */\n};\n\n/*\n** Decode a pointer to an sqlite3 object.\n*/\nextern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);\n\n/*\n** Register the echo virtual table module.\n*/\nstatic int SQLITE_TCLAPI register_tclvar_module(\n  ClientData clientData, /* Pointer to sqlite3_enable_XXX function */\n  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */\n  int objc,              /* Number of arguments */\n  Tcl_Obj *CONST objv[]  /* Command arguments */\n){\n  int rc = TCL_OK;\n  sqlite3 *db;\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"DB\");\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_create_module(db, \"tclvar\", &tclvarModule, (void*)interp);\n  rc = Tcl_Eval(interp, \n      \"proc like {pattern str} {\\n\"\n      \"  set p [string map {% * _ ?} $pattern]\\n\"\n      \"  string match $p $str\\n\"\n      \"}\\n\"\n      \"proc tclvar_filter_cmd {eq match glob regexp like} {\\n\"\n      \"  set res {}\\n\"\n      \"  set pattern $eq\\n\"\n      \"  if {$pattern=={}} { set pattern $match }\\n\"\n      \"  if {$pattern=={}} { set pattern * }\\n\"\n      \"  foreach v [uplevel #0 info vars $pattern] {\\n\"\n      \"    if {($glob=={} || [string match $glob [uplevel #0 set $v]])\\n\"\n      \"     && ($like=={} || [like $like [uplevel #0 set $v]])\\n\"\n      \"     && ($regexp=={} || [regexp $regexp [uplevel #0 set $v]])\\n\"\n      \"    } {\\n\"\n      \"      lappend res $v\\n\"\n      \"    }\\n\"\n      \"  }\\n\"\n      \"  set res\\n\"\n      \"}\\n\"\n  );\n#endif\n  return rc;\n}\n\n#endif\n\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint Sqlitetesttclvar_Init(Tcl_Interp *interp){\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  static struct {\n     char *zName;\n     Tcl_ObjCmdProc *xProc;\n     void *clientData;\n  } aObjCmd[] = {\n     { \"register_tclvar_module\",   register_tclvar_module, 0 },\n  };\n  int i;\n  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){\n    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, \n        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);\n  }\n#endif\n  return TCL_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_thread.c",
    "content": "/*\n** 2007 September 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of some Tcl commands used to\n** test that sqlite3 database handles may be concurrently accessed by \n** multiple threads. Right now this only works on unix.\n*/\n\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\n#if SQLITE_THREADSAFE\n\n#include <errno.h>\n\n#if !defined(_MSC_VER)\n#include <unistd.h>\n#endif\n\n/*\n** One of these is allocated for each thread created by [sqlthread spawn].\n*/\ntypedef struct SqlThread SqlThread;\nstruct SqlThread {\n  Tcl_ThreadId parent;     /* Thread id of parent thread */\n  Tcl_Interp *interp;      /* Parent interpreter */\n  char *zScript;           /* The script to execute. */\n  char *zVarname;          /* Varname in parent script */\n};\n\n/*\n** A custom Tcl_Event type used by this module. When the event is\n** handled, script zScript is evaluated in interpreter interp. If\n** the evaluation throws an exception (returns TCL_ERROR), then the\n** error is handled by Tcl_BackgroundError(). If no error occurs,\n** the result is simply discarded.\n*/\ntypedef struct EvalEvent EvalEvent;\nstruct EvalEvent {\n  Tcl_Event base;          /* Base class of type Tcl_Event */\n  char *zScript;           /* The script to execute. */\n  Tcl_Interp *interp;      /* The interpreter to execute it in. */\n};\n\nstatic Tcl_ObjCmdProc sqlthread_proc;\nstatic Tcl_ObjCmdProc clock_seconds_proc;\n#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\nstatic Tcl_ObjCmdProc blocking_step_proc;\nstatic Tcl_ObjCmdProc blocking_prepare_v2_proc;\n#endif\nint Sqlitetest1_Init(Tcl_Interp *);\nint Sqlite3_Init(Tcl_Interp *);\n\n/* Functions from main.c */\nextern const char *sqlite3ErrName(int);\n\n/* Functions from test1.c */\nextern void *sqlite3TestTextToPtr(const char *);\nextern int getDbPointer(Tcl_Interp *, const char *, sqlite3 **);\nextern int sqlite3TestMakePointerStr(Tcl_Interp *, char *, void *);\nextern int sqlite3TestErrCode(Tcl_Interp *, sqlite3 *, int);\n\n/*\n** Handler for events of type EvalEvent.\n*/\nstatic int SQLITE_TCLAPI tclScriptEvent(Tcl_Event *evPtr, int flags){\n  int rc;\n  EvalEvent *p = (EvalEvent *)evPtr;\n  rc = Tcl_Eval(p->interp, p->zScript);\n  if( rc!=TCL_OK ){\n    Tcl_BackgroundError(p->interp);\n  }\n  UNUSED_PARAMETER(flags);\n  return 1;\n}\n\n/*\n** Register an EvalEvent to evaluate the script pScript in the\n** parent interpreter/thread of SqlThread p.\n*/\nstatic void postToParent(SqlThread *p, Tcl_Obj *pScript){\n  EvalEvent *pEvent;\n  char *zMsg;\n  int nMsg;\n\n  zMsg = Tcl_GetStringFromObj(pScript, &nMsg); \n  pEvent = (EvalEvent *)ckalloc(sizeof(EvalEvent)+nMsg+1);\n  pEvent->base.nextPtr = 0;\n  pEvent->base.proc = tclScriptEvent;\n  pEvent->zScript = (char *)&pEvent[1];\n  memcpy(pEvent->zScript, zMsg, nMsg+1);\n  pEvent->interp = p->interp;\n\n  Tcl_ThreadQueueEvent(p->parent, (Tcl_Event *)pEvent, TCL_QUEUE_TAIL);\n  Tcl_ThreadAlert(p->parent);\n}\n\n/*\n** The main function for threads created with [sqlthread spawn].\n*/\nstatic Tcl_ThreadCreateType tclScriptThread(ClientData pSqlThread){\n  Tcl_Interp *interp;\n  Tcl_Obj *pRes;\n  Tcl_Obj *pList;\n  int rc;\n  SqlThread *p = (SqlThread *)pSqlThread;\n  extern int Sqlitetest_mutex_Init(Tcl_Interp*);\n\n  interp = Tcl_CreateInterp();\n  Tcl_CreateObjCommand(interp, \"clock_seconds\", clock_seconds_proc, 0, 0);\n  Tcl_CreateObjCommand(interp, \"sqlthread\", sqlthread_proc, pSqlThread, 0);\n#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\n  Tcl_CreateObjCommand(interp, \"sqlite3_blocking_step\", blocking_step_proc,0,0);\n  Tcl_CreateObjCommand(interp, \n      \"sqlite3_blocking_prepare_v2\", blocking_prepare_v2_proc, (void *)1, 0);\n  Tcl_CreateObjCommand(interp, \n      \"sqlite3_nonblocking_prepare_v2\", blocking_prepare_v2_proc, 0, 0);\n#endif\n  Sqlitetest1_Init(interp);\n  Sqlitetest_mutex_Init(interp);\n  Sqlite3_Init(interp);\n\n  rc = Tcl_Eval(interp, p->zScript);\n  pRes = Tcl_GetObjResult(interp);\n  pList = Tcl_NewObj();\n  Tcl_IncrRefCount(pList);\n  Tcl_IncrRefCount(pRes);\n\n  if( rc!=TCL_OK ){\n    Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(\"error\", -1));\n    Tcl_ListObjAppendElement(interp, pList, pRes);\n    postToParent(p, pList);\n    Tcl_DecrRefCount(pList);\n    pList = Tcl_NewObj();\n  }\n\n  Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(\"set\", -1));\n  Tcl_ListObjAppendElement(interp, pList, Tcl_NewStringObj(p->zVarname, -1));\n  Tcl_ListObjAppendElement(interp, pList, pRes);\n  postToParent(p, pList);\n\n  ckfree((void *)p);\n  Tcl_DecrRefCount(pList);\n  Tcl_DecrRefCount(pRes);\n  Tcl_DeleteInterp(interp);\n  while( Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT) );\n  Tcl_ExitThread(0);\n  TCL_THREAD_CREATE_RETURN;\n}\n\n/*\n** sqlthread spawn VARNAME SCRIPT\n**\n**     Spawn a new thread with its own Tcl interpreter and run the\n**     specified SCRIPT(s) in it. The thread terminates after running\n**     the script. The result of the script is stored in the variable\n**     VARNAME.\n**\n**     The caller can wait for the script to terminate using [vwait VARNAME].\n*/\nstatic int SQLITE_TCLAPI sqlthread_spawn(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_ThreadId x;\n  SqlThread *pNew;\n  int rc;\n\n  int nVarname; char *zVarname;\n  int nScript; char *zScript;\n\n  /* Parameters for thread creation */\n  const int nStack = TCL_THREAD_STACK_DEFAULT;\n  const int flags = TCL_THREAD_NOFLAGS;\n\n  assert(objc==4);\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(objc);\n\n  zVarname = Tcl_GetStringFromObj(objv[2], &nVarname);\n  zScript = Tcl_GetStringFromObj(objv[3], &nScript);\n\n  pNew = (SqlThread *)ckalloc(sizeof(SqlThread)+nVarname+nScript+2);\n  pNew->zVarname = (char *)&pNew[1];\n  pNew->zScript = (char *)&pNew->zVarname[nVarname+1];\n  memcpy(pNew->zVarname, zVarname, nVarname+1);\n  memcpy(pNew->zScript, zScript, nScript+1);\n  pNew->parent = Tcl_GetCurrentThread();\n  pNew->interp = interp;\n\n  rc = Tcl_CreateThread(&x, tclScriptThread, (void *)pNew, nStack, flags);\n  if( rc!=TCL_OK ){\n    Tcl_AppendResult(interp, \"Error in Tcl_CreateThread()\", 0);\n    ckfree((char *)pNew);\n    return TCL_ERROR;\n  }\n\n  return TCL_OK;\n}\n\n/*\n** sqlthread parent SCRIPT\n**\n**     This can be called by spawned threads only. It sends the specified\n**     script back to the parent thread for execution. The result of\n**     evaluating the SCRIPT is returned. The parent thread must enter\n**     the event loop for this to work - otherwise the caller will\n**     block indefinitely.\n**\n**     NOTE: At the moment, this doesn't work. FIXME.\n*/\nstatic int SQLITE_TCLAPI sqlthread_parent(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  EvalEvent *pEvent;\n  char *zMsg;\n  int nMsg;\n  SqlThread *p = (SqlThread *)clientData;\n\n  assert(objc==3);\n  UNUSED_PARAMETER(objc);\n\n  if( p==0 ){\n    Tcl_AppendResult(interp, \"no parent thread\", 0);\n    return TCL_ERROR;\n  }\n\n  zMsg = Tcl_GetStringFromObj(objv[2], &nMsg);\n  pEvent = (EvalEvent *)ckalloc(sizeof(EvalEvent)+nMsg+1);\n  pEvent->base.nextPtr = 0;\n  pEvent->base.proc = tclScriptEvent;\n  pEvent->zScript = (char *)&pEvent[1];\n  memcpy(pEvent->zScript, zMsg, nMsg+1);\n  pEvent->interp = p->interp;\n  Tcl_ThreadQueueEvent(p->parent, (Tcl_Event *)pEvent, TCL_QUEUE_TAIL);\n  Tcl_ThreadAlert(p->parent);\n\n  return TCL_OK;\n}\n\nstatic int xBusy(void *pArg, int nBusy){\n  UNUSED_PARAMETER(pArg);\n  UNUSED_PARAMETER(nBusy);\n  sqlite3_sleep(50);\n  return 1;             /* Try again... */\n}\n\n/*\n** sqlthread open\n**\n**     Open a database handle and return the string representation of\n**     the pointer value.\n*/\nstatic int SQLITE_TCLAPI sqlthread_open(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  int sqlite3TestMakePointerStr(Tcl_Interp *interp, char *zPtr, void *p);\n\n  const char *zFilename;\n  sqlite3 *db;\n  char zBuf[100];\n  extern int Md5_Register(sqlite3*,char**,const sqlite3_api_routines*);\n\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(objc);\n\n  zFilename = Tcl_GetString(objv[2]);\n  sqlite3_open(zFilename, &db);\n#ifdef SQLITE_HAS_CODEC\n  if( db && objc>=4 ){\n    const char *zKey;\n    int nKey;\n    int rc;\n    zKey = Tcl_GetStringFromObj(objv[3], &nKey);\n    rc = sqlite3_key(db, zKey, nKey);\n    if( rc!=SQLITE_OK ){\n      char *zErrMsg = sqlite3_mprintf(\"error %d: %s\", rc, sqlite3_errmsg(db));\n      sqlite3_close(db);\n      Tcl_AppendResult(interp, zErrMsg, (char*)0);\n      sqlite3_free(zErrMsg);\n      return TCL_ERROR;\n    }\n  }\n#endif\n  Md5_Register(db, 0, 0);\n  sqlite3_busy_handler(db, xBusy, 0);\n  \n  if( sqlite3TestMakePointerStr(interp, zBuf, db) ) return TCL_ERROR;\n  Tcl_AppendResult(interp, zBuf, 0);\n\n  return TCL_OK;\n}\n\n\n/*\n** sqlthread open\n**\n**     Return the current thread-id (Tcl_GetCurrentThread()) cast to\n**     an integer.\n*/\nstatic int SQLITE_TCLAPI sqlthread_id(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_ThreadId id = Tcl_GetCurrentThread();\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(SQLITE_PTR_TO_INT(id)));\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(objc);\n  UNUSED_PARAMETER(objv);\n  return TCL_OK;\n}\n\n\n/*\n** Dispatch routine for the sub-commands of [sqlthread].\n*/\nstatic int SQLITE_TCLAPI sqlthread_proc(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  struct SubCommand {\n    char *zName;\n    Tcl_ObjCmdProc *xProc;\n    int nArg;\n    char *zUsage;\n  } aSub[] = {\n    {\"parent\", sqlthread_parent, 1, \"SCRIPT\"},\n    {\"spawn\",  sqlthread_spawn,  2, \"VARNAME SCRIPT\"},\n    {\"open\",   sqlthread_open,   1, \"DBNAME\"},\n    {\"id\",     sqlthread_id,     0, \"\"},\n    {0, 0, 0}\n  };\n  struct SubCommand *pSub;\n  int rc;\n  int iIndex;\n\n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUB-COMMAND\");\n    return TCL_ERROR;\n  }\n\n  rc = Tcl_GetIndexFromObjStruct(\n      interp, objv[1], aSub, sizeof(aSub[0]), \"sub-command\", 0, &iIndex\n  );\n  if( rc!=TCL_OK ) return rc;\n  pSub = &aSub[iIndex];\n\n  if( objc<(pSub->nArg+2) ){\n    Tcl_WrongNumArgs(interp, 2, objv, pSub->zUsage);\n    return TCL_ERROR;\n  }\n\n  return pSub->xProc(clientData, interp, objc, objv);\n}\n\n/*\n** The [clock_seconds] command. This is more or less the same as the\n** regular tcl [clock seconds], except that it is available in testfixture\n** when linked against both Tcl 8.4 and 8.5. Because [clock seconds] is\n** implemented as a script in Tcl 8.5, it is not usually available to\n** testfixture.\n*/ \nstatic int SQLITE_TCLAPI clock_seconds_proc(\n  ClientData clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Tcl_Time now;\n  Tcl_GetTime(&now);\n  Tcl_SetObjResult(interp, Tcl_NewIntObj(now.sec));\n  UNUSED_PARAMETER(clientData);\n  UNUSED_PARAMETER(objc);\n  UNUSED_PARAMETER(objv);\n  return TCL_OK;\n}\n\n/*************************************************************************\n** This block contains the implementation of the [sqlite3_blocking_step]\n** command available to threads created by [sqlthread spawn] commands. It\n** is only available on UNIX for now. This is because pthread condition\n** variables are used.\n**\n** The source code for the C functions sqlite3_blocking_step(),\n** blocking_step_notify() and the structure UnlockNotification is\n** automatically extracted from this file and used as part of the\n** documentation for the sqlite3_unlock_notify() API function. This\n** should be considered if these functions are to be extended (i.e. to \n** support windows) in the future.\n*/ \n#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\n\n/* BEGIN_SQLITE_BLOCKING_STEP */\n/* This example uses the pthreads API */\n#include <pthread.h>\n\n/*\n** A pointer to an instance of this structure is passed as the user-context\n** pointer when registering for an unlock-notify callback.\n*/\ntypedef struct UnlockNotification UnlockNotification;\nstruct UnlockNotification {\n  int fired;                         /* True after unlock event has occurred */\n  pthread_cond_t cond;               /* Condition variable to wait on */\n  pthread_mutex_t mutex;             /* Mutex to protect structure */\n};\n\n/*\n** This function is an unlock-notify callback registered with SQLite.\n*/\nstatic void unlock_notify_cb(void **apArg, int nArg){\n  int i;\n  for(i=0; i<nArg; i++){\n    UnlockNotification *p = (UnlockNotification *)apArg[i];\n    pthread_mutex_lock(&p->mutex);\n    p->fired = 1;\n    pthread_cond_signal(&p->cond);\n    pthread_mutex_unlock(&p->mutex);\n  }\n}\n\n/*\n** This function assumes that an SQLite API call (either sqlite3_prepare_v2() \n** or sqlite3_step()) has just returned SQLITE_LOCKED. The argument is the\n** associated database connection.\n**\n** This function calls sqlite3_unlock_notify() to register for an \n** unlock-notify callback, then blocks until that callback is delivered \n** and returns SQLITE_OK. The caller should then retry the failed operation.\n**\n** Or, if sqlite3_unlock_notify() indicates that to block would deadlock \n** the system, then this function returns SQLITE_LOCKED immediately. In \n** this case the caller should not retry the operation and should roll \n** back the current transaction (if any).\n*/\nstatic int wait_for_unlock_notify(sqlite3 *db){\n  int rc;\n  UnlockNotification un;\n\n  /* Initialize the UnlockNotification structure. */\n  un.fired = 0;\n  pthread_mutex_init(&un.mutex, 0);\n  pthread_cond_init(&un.cond, 0);\n\n  /* Register for an unlock-notify callback. */\n  rc = sqlite3_unlock_notify(db, unlock_notify_cb, (void *)&un);\n  assert( rc==SQLITE_LOCKED || rc==SQLITE_OK );\n\n  /* The call to sqlite3_unlock_notify() always returns either SQLITE_LOCKED \n  ** or SQLITE_OK. \n  **\n  ** If SQLITE_LOCKED was returned, then the system is deadlocked. In this\n  ** case this function needs to return SQLITE_LOCKED to the caller so \n  ** that the current transaction can be rolled back. Otherwise, block\n  ** until the unlock-notify callback is invoked, then return SQLITE_OK.\n  */\n  if( rc==SQLITE_OK ){\n    pthread_mutex_lock(&un.mutex);\n    if( !un.fired ){\n      pthread_cond_wait(&un.cond, &un.mutex);\n    }\n    pthread_mutex_unlock(&un.mutex);\n  }\n\n  /* Destroy the mutex and condition variables. */\n  pthread_cond_destroy(&un.cond);\n  pthread_mutex_destroy(&un.mutex);\n\n  return rc;\n}\n\n/*\n** This function is a wrapper around the SQLite function sqlite3_step().\n** It functions in the same way as step(), except that if a required\n** shared-cache lock cannot be obtained, this function may block waiting for\n** the lock to become available. In this scenario the normal API step()\n** function always returns SQLITE_LOCKED.\n**\n** If this function returns SQLITE_LOCKED, the caller should rollback\n** the current transaction (if any) and try again later. Otherwise, the\n** system may become deadlocked.\n*/\nint sqlite3_blocking_step(sqlite3_stmt *pStmt){\n  int rc;\n  while( SQLITE_LOCKED==(rc = sqlite3_step(pStmt)) ){\n    rc = wait_for_unlock_notify(sqlite3_db_handle(pStmt));\n    if( rc!=SQLITE_OK ) break;\n    sqlite3_reset(pStmt);\n  }\n  return rc;\n}\n\n/*\n** This function is a wrapper around the SQLite function sqlite3_prepare_v2().\n** It functions in the same way as prepare_v2(), except that if a required\n** shared-cache lock cannot be obtained, this function may block waiting for\n** the lock to become available. In this scenario the normal API prepare_v2()\n** function always returns SQLITE_LOCKED.\n**\n** If this function returns SQLITE_LOCKED, the caller should rollback\n** the current transaction (if any) and try again later. Otherwise, the\n** system may become deadlocked.\n*/\nint sqlite3_blocking_prepare_v2(\n  sqlite3 *db,              /* Database handle. */\n  const char *zSql,         /* UTF-8 encoded SQL statement. */\n  int nSql,                 /* Length of zSql in bytes. */\n  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */\n  const char **pz           /* OUT: End of parsed string */\n){\n  int rc;\n  while( SQLITE_LOCKED==(rc = sqlite3_prepare_v2(db, zSql, nSql, ppStmt, pz)) ){\n    rc = wait_for_unlock_notify(db);\n    if( rc!=SQLITE_OK ) break;\n  }\n  return rc;\n}\n/* END_SQLITE_BLOCKING_STEP */\n\n/*\n** Usage: sqlite3_blocking_step STMT\n**\n** Advance the statement to the next row.\n*/\nstatic int SQLITE_TCLAPI blocking_step_proc(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  if( objc!=2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"STMT\");\n    return TCL_ERROR;\n  }\n\n  pStmt = (sqlite3_stmt*)sqlite3TestTextToPtr(Tcl_GetString(objv[1]));\n  rc = sqlite3_blocking_step(pStmt);\n\n  Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), 0);\n  return TCL_OK;\n}\n\n/*\n** Usage: sqlite3_blocking_prepare_v2 DB sql bytes ?tailvar?\n** Usage: sqlite3_nonblocking_prepare_v2 DB sql bytes ?tailvar?\n*/\nstatic int SQLITE_TCLAPI blocking_prepare_v2_proc(\n  void * clientData,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  sqlite3 *db;\n  const char *zSql;\n  int bytes;\n  const char *zTail = 0;\n  sqlite3_stmt *pStmt = 0;\n  char zBuf[50];\n  int rc;\n  int isBlocking = !(clientData==0);\n\n  if( objc!=5 && objc!=4 ){\n    Tcl_AppendResult(interp, \"wrong # args: should be \\\"\", \n       Tcl_GetString(objv[0]), \" DB sql bytes tailvar\", 0);\n    return TCL_ERROR;\n  }\n  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;\n  zSql = Tcl_GetString(objv[2]);\n  if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;\n\n  if( isBlocking ){\n    rc = sqlite3_blocking_prepare_v2(db, zSql, bytes, &pStmt, &zTail);\n  }else{\n    rc = sqlite3_prepare_v2(db, zSql, bytes, &pStmt, &zTail);\n  }\n\n  assert(rc==SQLITE_OK || pStmt==0);\n  if( zTail && objc>=5 ){\n    if( bytes>=0 ){\n      bytes = bytes - (zTail-zSql);\n    }\n    Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0);\n  }\n  if( rc!=SQLITE_OK ){\n    assert( pStmt==0 );\n    sqlite3_snprintf(sizeof(zBuf), zBuf, \"%s \", (char *)sqlite3ErrName(rc));\n    Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0);\n    return TCL_ERROR;\n  }\n\n  if( pStmt ){\n    if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR;\n    Tcl_AppendResult(interp, zBuf, 0);\n  }\n  return TCL_OK;\n}\n\n#endif /* SQLITE_OS_UNIX && SQLITE_ENABLE_UNLOCK_NOTIFY */\n/*\n** End of implementation of [sqlite3_blocking_step].\n************************************************************************/\n\n/*\n** Register commands with the TCL interpreter.\n*/\nint SqlitetestThread_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"sqlthread\", sqlthread_proc, 0, 0);\n  Tcl_CreateObjCommand(interp, \"clock_seconds\", clock_seconds_proc, 0, 0);\n#if SQLITE_OS_UNIX && defined(SQLITE_ENABLE_UNLOCK_NOTIFY)\n  Tcl_CreateObjCommand(interp, \"sqlite3_blocking_step\", blocking_step_proc,0,0);\n  Tcl_CreateObjCommand(interp, \n      \"sqlite3_blocking_prepare_v2\", blocking_prepare_v2_proc, (void *)1, 0);\n  Tcl_CreateObjCommand(interp, \n      \"sqlite3_nonblocking_prepare_v2\", blocking_prepare_v2_proc, 0, 0);\n#endif\n  return TCL_OK;\n}\n#else\nint SqlitetestThread_Init(Tcl_Interp *interp){\n  return TCL_OK;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_vfs.c",
    "content": "/*\n** 2010 May 05\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains the implementation of the Tcl [testvfs] command,\n** used to create SQLite VFS implementations with various properties and\n** instrumentation to support testing SQLite.\n**\n**   testvfs VFSNAME ?OPTIONS?\n**\n** Available options are:\n**\n**   -noshm      BOOLEAN        (True to omit shm methods. Default false)\n**   -default    BOOLEAN        (True to make the vfs default. Default false)\n**   -szosfile   INTEGER        (Value for sqlite3_vfs.szOsFile)\n**   -mxpathname INTEGER        (Value for sqlite3_vfs.mxPathname)\n**   -iversion   INTEGER        (Value for sqlite3_vfs.iVersion)\n*/\n#if SQLITE_TEST          /* This file is used for testing only */\n\n#include \"sqlite3.h\"\n#include \"sqliteInt.h\"\n#if defined(INCLUDE_SQLITE_TCL_H)\n#  include \"sqlite_tcl.h\"\n#else\n#  include \"tcl.h\"\n#endif\n\ntypedef struct Testvfs Testvfs;\ntypedef struct TestvfsShm TestvfsShm;\ntypedef struct TestvfsBuffer TestvfsBuffer;\ntypedef struct TestvfsFile TestvfsFile;\ntypedef struct TestvfsFd TestvfsFd;\n\n/*\n** An open file handle.\n*/\nstruct TestvfsFile {\n  sqlite3_file base;              /* Base class.  Must be first */\n  TestvfsFd *pFd;                 /* File data */\n};\n#define tvfsGetFd(pFile) (((TestvfsFile *)pFile)->pFd)\n\nstruct TestvfsFd {\n  sqlite3_vfs *pVfs;              /* The VFS */\n  const char *zFilename;          /* Filename as passed to xOpen() */\n  sqlite3_file *pReal;            /* The real, underlying file descriptor */\n  Tcl_Obj *pShmId;                /* Shared memory id for Tcl callbacks */\n\n  TestvfsBuffer *pShm;            /* Shared memory buffer */\n  u32 excllock;                   /* Mask of exclusive locks */\n  u32 sharedlock;                 /* Mask of shared locks */\n  TestvfsFd *pNext;               /* Next handle opened on the same file */\n};\n\n\n#define FAULT_INJECT_NONE       0\n#define FAULT_INJECT_TRANSIENT  1\n#define FAULT_INJECT_PERSISTENT 2\n\ntypedef struct TestFaultInject TestFaultInject;\nstruct TestFaultInject {\n  int iCnt;                       /* Remaining calls before fault injection */\n  int eFault;                     /* A FAULT_INJECT_* value */\n  int nFail;                      /* Number of faults injected */\n};\n\n/*\n** An instance of this structure is allocated for each VFS created. The\n** sqlite3_vfs.pAppData field of the VFS structure registered with SQLite\n** is set to point to it.\n*/\nstruct Testvfs {\n  char *zName;                    /* Name of this VFS */\n  sqlite3_vfs *pParent;           /* The VFS to use for file IO */\n  sqlite3_vfs *pVfs;              /* The testvfs registered with SQLite */\n  Tcl_Interp *interp;             /* Interpreter to run script in */\n  Tcl_Obj *pScript;               /* Script to execute */\n  TestvfsBuffer *pBuffer;         /* List of shared buffers */\n  int isNoshm;\n  int isFullshm;\n\n  int mask;                       /* Mask controlling [script] and [ioerr] */\n\n  TestFaultInject ioerr_err;\n  TestFaultInject full_err;\n  TestFaultInject cantopen_err;\n\n#if 0\n  int iIoerrCnt;\n  int ioerr;\n  int nIoerrFail;\n  int iFullCnt;\n  int fullerr;\n  int nFullFail;\n#endif\n\n  int iDevchar;\n  int iSectorsize;\n};\n\n/*\n** The Testvfs.mask variable is set to a combination of the following.\n** If a bit is clear in Testvfs.mask, then calls made by SQLite to the \n** corresponding VFS method is ignored for purposes of:\n**\n**   + Simulating IO errors, and\n**   + Invoking the Tcl callback script.\n*/\n#define TESTVFS_SHMOPEN_MASK      0x00000001\n#define TESTVFS_SHMLOCK_MASK      0x00000010\n#define TESTVFS_SHMMAP_MASK       0x00000020\n#define TESTVFS_SHMBARRIER_MASK   0x00000040\n#define TESTVFS_SHMCLOSE_MASK     0x00000080\n\n#define TESTVFS_OPEN_MASK         0x00000100\n#define TESTVFS_SYNC_MASK         0x00000200\n#define TESTVFS_DELETE_MASK       0x00000400\n#define TESTVFS_CLOSE_MASK        0x00000800\n#define TESTVFS_WRITE_MASK        0x00001000\n#define TESTVFS_TRUNCATE_MASK     0x00002000\n#define TESTVFS_ACCESS_MASK       0x00004000\n#define TESTVFS_FULLPATHNAME_MASK 0x00008000\n#define TESTVFS_READ_MASK         0x00010000\n#define TESTVFS_UNLOCK_MASK       0x00020000\n#define TESTVFS_LOCK_MASK         0x00040000\n#define TESTVFS_CKLOCK_MASK       0x00080000\n\n#define TESTVFS_ALL_MASK          0x000FFFFF\n\n\n#define TESTVFS_MAX_PAGES 1024\n\n/*\n** A shared-memory buffer. There is one of these objects for each shared\n** memory region opened by clients. If two clients open the same file,\n** there are two TestvfsFile structures but only one TestvfsBuffer structure.\n*/\nstruct TestvfsBuffer {\n  char *zFile;                    /* Associated file name */\n  int pgsz;                       /* Page size */\n  u8 *aPage[TESTVFS_MAX_PAGES];   /* Array of ckalloc'd pages */\n  TestvfsFd *pFile;               /* List of open handles */\n  TestvfsBuffer *pNext;           /* Next in linked list of all buffers */\n};\n\n\n#define PARENTVFS(x) (((Testvfs *)((x)->pAppData))->pParent)\n\n#define TESTVFS_MAX_ARGS 12\n\n\n/*\n** Method declarations for TestvfsFile.\n*/\nstatic int tvfsClose(sqlite3_file*);\nstatic int tvfsRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int tvfsWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst);\nstatic int tvfsTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int tvfsSync(sqlite3_file*, int flags);\nstatic int tvfsFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int tvfsLock(sqlite3_file*, int);\nstatic int tvfsUnlock(sqlite3_file*, int);\nstatic int tvfsCheckReservedLock(sqlite3_file*, int *);\nstatic int tvfsFileControl(sqlite3_file*, int op, void *pArg);\nstatic int tvfsSectorSize(sqlite3_file*);\nstatic int tvfsDeviceCharacteristics(sqlite3_file*);\n\n/*\n** Method declarations for tvfs_vfs.\n*/\nstatic int tvfsOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int tvfsDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int tvfsAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int tvfsFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut);\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\nstatic void *tvfsDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void tvfsDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*tvfsDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);\nstatic void tvfsDlClose(sqlite3_vfs*, void*);\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\nstatic int tvfsRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int tvfsSleep(sqlite3_vfs*, int microseconds);\nstatic int tvfsCurrentTime(sqlite3_vfs*, double*);\n\nstatic int tvfsShmOpen(sqlite3_file*);\nstatic int tvfsShmLock(sqlite3_file*, int , int, int);\nstatic int tvfsShmMap(sqlite3_file*,int,int,int, void volatile **);\nstatic void tvfsShmBarrier(sqlite3_file*);\nstatic int tvfsShmUnmap(sqlite3_file*, int);\n\nstatic int tvfsFetch(sqlite3_file*, sqlite3_int64, int, void**);\nstatic int tvfsUnfetch(sqlite3_file*, sqlite3_int64, void*);\n\nstatic sqlite3_io_methods tvfs_io_methods = {\n  3,                              /* iVersion */\n  tvfsClose,                      /* xClose */\n  tvfsRead,                       /* xRead */\n  tvfsWrite,                      /* xWrite */\n  tvfsTruncate,                   /* xTruncate */\n  tvfsSync,                       /* xSync */\n  tvfsFileSize,                   /* xFileSize */\n  tvfsLock,                       /* xLock */\n  tvfsUnlock,                     /* xUnlock */\n  tvfsCheckReservedLock,          /* xCheckReservedLock */\n  tvfsFileControl,                /* xFileControl */\n  tvfsSectorSize,                 /* xSectorSize */\n  tvfsDeviceCharacteristics,      /* xDeviceCharacteristics */\n  tvfsShmMap,                     /* xShmMap */\n  tvfsShmLock,                    /* xShmLock */\n  tvfsShmBarrier,                 /* xShmBarrier */\n  tvfsShmUnmap,                   /* xShmUnmap */\n  tvfsFetch,\n  tvfsUnfetch\n};\n\nstatic int tvfsResultCode(Testvfs *p, int *pRc){\n  struct errcode {\n    int eCode;\n    const char *zCode;\n  } aCode[] = {\n    { SQLITE_OK,     \"SQLITE_OK\"     },\n    { SQLITE_ERROR,  \"SQLITE_ERROR\"  },\n    { SQLITE_IOERR,  \"SQLITE_IOERR\"  },\n    { SQLITE_LOCKED, \"SQLITE_LOCKED\" },\n    { SQLITE_BUSY,   \"SQLITE_BUSY\"   },\n  };\n\n  const char *z;\n  int i;\n\n  z = Tcl_GetStringResult(p->interp);\n  for(i=0; i<ArraySize(aCode); i++){\n    if( 0==strcmp(z, aCode[i].zCode) ){\n      *pRc = aCode[i].eCode;\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\nstatic int tvfsInjectFault(TestFaultInject *p){\n  int ret = 0;\n  if( p->eFault ){\n    p->iCnt--;\n    if( p->iCnt==0 || (p->iCnt<0 && p->eFault==FAULT_INJECT_PERSISTENT ) ){\n      ret = 1;\n      p->nFail++;\n    }\n  }\n  return ret;\n}\n\n\nstatic int tvfsInjectIoerr(Testvfs *p){\n  return tvfsInjectFault(&p->ioerr_err);\n}\n\nstatic int tvfsInjectFullerr(Testvfs *p){\n  return tvfsInjectFault(&p->full_err);\n}\nstatic int tvfsInjectCantopenerr(Testvfs *p){\n  return tvfsInjectFault(&p->cantopen_err);\n}\n\n\nstatic void tvfsExecTcl(\n  Testvfs *p, \n  const char *zMethod,\n  Tcl_Obj *arg1,\n  Tcl_Obj *arg2,\n  Tcl_Obj *arg3,\n  Tcl_Obj *arg4\n){\n  int rc;                         /* Return code from Tcl_EvalObj() */\n  Tcl_Obj *pEval;\n  assert( p->pScript );\n\n  assert( zMethod );\n  assert( p );\n  assert( arg2==0 || arg1!=0 );\n  assert( arg3==0 || arg2!=0 );\n\n  pEval = Tcl_DuplicateObj(p->pScript);\n  Tcl_IncrRefCount(p->pScript);\n  Tcl_ListObjAppendElement(p->interp, pEval, Tcl_NewStringObj(zMethod, -1));\n  if( arg1 ) Tcl_ListObjAppendElement(p->interp, pEval, arg1);\n  if( arg2 ) Tcl_ListObjAppendElement(p->interp, pEval, arg2);\n  if( arg3 ) Tcl_ListObjAppendElement(p->interp, pEval, arg3);\n  if( arg4 ) Tcl_ListObjAppendElement(p->interp, pEval, arg4);\n\n  rc = Tcl_EvalObjEx(p->interp, pEval, TCL_EVAL_GLOBAL);\n  if( rc!=TCL_OK ){\n    Tcl_BackgroundError(p->interp);\n    Tcl_ResetResult(p->interp);\n  }\n}\n\n\n/*\n** Close an tvfs-file.\n*/\nstatic int tvfsClose(sqlite3_file *pFile){\n  TestvfsFile *pTestfile = (TestvfsFile *)pFile;\n  TestvfsFd *pFd = pTestfile->pFd;\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n\n  if( p->pScript && p->mask&TESTVFS_CLOSE_MASK ){\n    tvfsExecTcl(p, \"xClose\", \n        Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0\n    );\n  }\n\n  if( pFd->pShmId ){\n    Tcl_DecrRefCount(pFd->pShmId);\n    pFd->pShmId = 0;\n  }\n  if( pFile->pMethods ){\n    ckfree((char *)pFile->pMethods);\n  }\n  sqlite3OsClose(pFd->pReal);\n  ckfree((char *)pFd);\n  pTestfile->pFd = 0;\n  return SQLITE_OK;\n}\n\n/*\n** Read data from an tvfs-file.\n*/\nstatic int tvfsRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_READ_MASK ){\n    tvfsExecTcl(p, \"xRead\", \n        Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n  if( rc==SQLITE_OK && p->mask&TESTVFS_READ_MASK && tvfsInjectIoerr(p) ){\n    rc = SQLITE_IOERR;\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsRead(pFd->pReal, zBuf, iAmt, iOfst);\n  }\n  return rc;\n}\n\n/*\n** Write data to an tvfs-file.\n*/\nstatic int tvfsWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n\n  if( p->pScript && p->mask&TESTVFS_WRITE_MASK ){\n    tvfsExecTcl(p, \"xWrite\", \n        Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, \n        Tcl_NewWideIntObj(iOfst), Tcl_NewIntObj(iAmt)\n    );\n    tvfsResultCode(p, &rc);\n  }\n\n  if( rc==SQLITE_OK && tvfsInjectFullerr(p) ){\n    rc = SQLITE_FULL;\n  }\n  if( rc==SQLITE_OK && p->mask&TESTVFS_WRITE_MASK && tvfsInjectIoerr(p) ){\n    rc = SQLITE_IOERR;\n  }\n  \n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsWrite(pFd->pReal, zBuf, iAmt, iOfst);\n  }\n  return rc;\n}\n\n/*\n** Truncate an tvfs-file.\n*/\nstatic int tvfsTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n\n  if( p->pScript && p->mask&TESTVFS_TRUNCATE_MASK ){\n    tvfsExecTcl(p, \"xTruncate\", \n        Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0, 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n  \n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsTruncate(pFd->pReal, size);\n  }\n  return rc;\n}\n\n/*\n** Sync an tvfs-file.\n*/\nstatic int tvfsSync(sqlite3_file *pFile, int flags){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n\n  if( p->pScript && p->mask&TESTVFS_SYNC_MASK ){\n    char *zFlags = 0;\n\n    switch( flags ){\n      case SQLITE_SYNC_NORMAL:\n        zFlags = \"normal\";\n        break;\n      case SQLITE_SYNC_FULL:\n        zFlags = \"full\";\n        break;\n      case SQLITE_SYNC_NORMAL|SQLITE_SYNC_DATAONLY:\n        zFlags = \"normal|dataonly\";\n        break;\n      case SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY:\n        zFlags = \"full|dataonly\";\n        break;\n      default:\n        assert(0);\n    }\n\n    tvfsExecTcl(p, \"xSync\", \n        Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId,\n        Tcl_NewStringObj(zFlags, -1), 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n\n  if( rc==SQLITE_OK && tvfsInjectFullerr(p) ) rc = SQLITE_FULL;\n\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsSync(pFd->pReal, flags);\n  }\n\n  return rc;\n}\n\n/*\n** Return the current file-size of an tvfs-file.\n*/\nstatic int tvfsFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  TestvfsFd *p = tvfsGetFd(pFile);\n  return sqlite3OsFileSize(p->pReal, pSize);\n}\n\n/*\n** Lock an tvfs-file.\n*/\nstatic int tvfsLock(sqlite3_file *pFile, int eLock){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_LOCK_MASK ){\n    char zLock[30];\n    sqlite3_snprintf(sizeof(zLock),zLock,\"%d\",eLock);\n    tvfsExecTcl(p, \"xLock\", Tcl_NewStringObj(pFd->zFilename, -1), \n                   Tcl_NewStringObj(zLock, -1), 0, 0);\n  }\n  return sqlite3OsLock(pFd->pReal, eLock);\n}\n\n/*\n** Unlock an tvfs-file.\n*/\nstatic int tvfsUnlock(sqlite3_file *pFile, int eLock){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_UNLOCK_MASK ){\n    char zLock[30];\n    sqlite3_snprintf(sizeof(zLock),zLock,\"%d\",eLock);\n    tvfsExecTcl(p, \"xUnlock\", Tcl_NewStringObj(pFd->zFilename, -1), \n                   Tcl_NewStringObj(zLock, -1), 0, 0);\n  }\n  if( p->mask&TESTVFS_WRITE_MASK && tvfsInjectIoerr(p) ){\n    return SQLITE_IOERR_UNLOCK;\n  }\n  return sqlite3OsUnlock(pFd->pReal, eLock);\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an tvfs-file.\n*/\nstatic int tvfsCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_CKLOCK_MASK ){\n    tvfsExecTcl(p, \"xCheckReservedLock\", Tcl_NewStringObj(pFd->zFilename, -1),\n                   0, 0, 0);\n  }\n  return sqlite3OsCheckReservedLock(pFd->pReal, pResOut);\n}\n\n/*\n** File control method. For custom operations on an tvfs-file.\n*/\nstatic int tvfsFileControl(sqlite3_file *pFile, int op, void *pArg){\n  TestvfsFd *p = tvfsGetFd(pFile);\n  if( op==SQLITE_FCNTL_PRAGMA ){\n    char **argv = (char**)pArg;\n    if( sqlite3_stricmp(argv[1],\"error\")==0 ){\n      int rc = SQLITE_ERROR;\n      if( argv[2] ){\n        const char *z = argv[2];\n        int x = atoi(z);\n        if( x ){\n          rc = x;\n          while( sqlite3Isdigit(z[0]) ){ z++; }\n          while( sqlite3Isspace(z[0]) ){ z++; }\n        }\n        if( z[0] ) argv[0] = sqlite3_mprintf(\"%s\", z);\n      }\n      return rc;\n    }\n    if( sqlite3_stricmp(argv[1], \"filename\")==0 ){\n      argv[0] = sqlite3_mprintf(\"%s\", p->zFilename);\n      return SQLITE_OK;\n    }\n  }\n  return sqlite3OsFileControl(p->pReal, op, pArg);\n}\n\n/*\n** Return the sector-size in bytes for an tvfs-file.\n*/\nstatic int tvfsSectorSize(sqlite3_file *pFile){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->iSectorsize>=0 ){\n    return p->iSectorsize;\n  }\n  return sqlite3OsSectorSize(pFd->pReal);\n}\n\n/*\n** Return the device characteristic flags supported by an tvfs-file.\n*/\nstatic int tvfsDeviceCharacteristics(sqlite3_file *pFile){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)pFd->pVfs->pAppData;\n  if( p->iDevchar>=0 ){\n    return p->iDevchar;\n  }\n  return sqlite3OsDeviceCharacteristics(pFd->pReal);\n}\n\n/*\n** Open an tvfs file handle.\n*/\nstatic int tvfsOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  TestvfsFile *pTestfile = (TestvfsFile *)pFile;\n  TestvfsFd *pFd;\n  Tcl_Obj *pId = 0;\n  Testvfs *p = (Testvfs *)pVfs->pAppData;\n\n  pFd = (TestvfsFd *)ckalloc(sizeof(TestvfsFd) + PARENTVFS(pVfs)->szOsFile);\n  memset(pFd, 0, sizeof(TestvfsFd) + PARENTVFS(pVfs)->szOsFile);\n  pFd->pShm = 0;\n  pFd->pShmId = 0;\n  pFd->zFilename = zName;\n  pFd->pVfs = pVfs;\n  pFd->pReal = (sqlite3_file *)&pFd[1];\n  memset(pTestfile, 0, sizeof(TestvfsFile));\n  pTestfile->pFd = pFd;\n\n  /* Evaluate the Tcl script: \n  **\n  **   SCRIPT xOpen FILENAME KEY-VALUE-ARGS\n  **\n  ** If the script returns an SQLite error code other than SQLITE_OK, an\n  ** error is returned to the caller. If it returns SQLITE_OK, the new\n  ** connection is named \"anon\". Otherwise, the value returned by the\n  ** script is used as the connection name.\n  */\n  Tcl_ResetResult(p->interp);\n  if( p->pScript && p->mask&TESTVFS_OPEN_MASK ){\n    Tcl_Obj *pArg = Tcl_NewObj();\n    Tcl_IncrRefCount(pArg);\n    if( flags&SQLITE_OPEN_MAIN_DB ){\n      const char *z = &zName[strlen(zName)+1];\n      while( *z ){\n        Tcl_ListObjAppendElement(0, pArg, Tcl_NewStringObj(z, -1));\n        z += strlen(z) + 1;\n        Tcl_ListObjAppendElement(0, pArg, Tcl_NewStringObj(z, -1));\n        z += strlen(z) + 1;\n      }\n    }\n    tvfsExecTcl(p, \"xOpen\", Tcl_NewStringObj(pFd->zFilename, -1), pArg, 0, 0);\n    Tcl_DecrRefCount(pArg);\n    if( tvfsResultCode(p, &rc) ){\n      if( rc!=SQLITE_OK ) return rc;\n    }else{\n      pId = Tcl_GetObjResult(p->interp);\n    }\n  }\n\n  if( (p->mask&TESTVFS_OPEN_MASK) &&  tvfsInjectIoerr(p) ) return SQLITE_IOERR;\n  if( tvfsInjectCantopenerr(p) ) return SQLITE_CANTOPEN;\n  if( tvfsInjectFullerr(p) ) return SQLITE_FULL;\n\n  if( !pId ){\n    pId = Tcl_NewStringObj(\"anon\", -1);\n  }\n  Tcl_IncrRefCount(pId);\n  pFd->pShmId = pId;\n  Tcl_ResetResult(p->interp);\n\n  rc = sqlite3OsOpen(PARENTVFS(pVfs), zName, pFd->pReal, flags, pOutFlags);\n  if( pFd->pReal->pMethods ){\n    sqlite3_io_methods *pMethods;\n    int nByte;\n\n    if( pVfs->iVersion>1 ){\n      nByte = sizeof(sqlite3_io_methods);\n    }else{\n      nByte = offsetof(sqlite3_io_methods, xShmMap);\n    }\n\n    pMethods = (sqlite3_io_methods *)ckalloc(nByte);\n    memcpy(pMethods, &tvfs_io_methods, nByte);\n    pMethods->iVersion = pFd->pReal->pMethods->iVersion;\n    if( pMethods->iVersion>pVfs->iVersion ){\n      pMethods->iVersion = pVfs->iVersion;\n    }\n    if( pVfs->iVersion>1 && ((Testvfs *)pVfs->pAppData)->isNoshm ){\n      pMethods->xShmUnmap = 0;\n      pMethods->xShmLock = 0;\n      pMethods->xShmBarrier = 0;\n      pMethods->xShmMap = 0;\n    }\n    pFile->pMethods = pMethods;\n  }\n\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int tvfsDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  int rc = SQLITE_OK;\n  Testvfs *p = (Testvfs *)pVfs->pAppData;\n\n  if( p->pScript && p->mask&TESTVFS_DELETE_MASK ){\n    tvfsExecTcl(p, \"xDelete\", \n        Tcl_NewStringObj(zPath, -1), Tcl_NewIntObj(dirSync), 0, 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n  if( rc==SQLITE_OK ){\n    rc = sqlite3OsDelete(PARENTVFS(pVfs), zPath, dirSync);\n  }\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int tvfsAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  Testvfs *p = (Testvfs *)pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_ACCESS_MASK ){\n    int rc;\n    char *zArg = 0;\n    if( flags==SQLITE_ACCESS_EXISTS ) zArg = \"SQLITE_ACCESS_EXISTS\";\n    if( flags==SQLITE_ACCESS_READWRITE ) zArg = \"SQLITE_ACCESS_READWRITE\";\n    if( flags==SQLITE_ACCESS_READ ) zArg = \"SQLITE_ACCESS_READ\";\n    tvfsExecTcl(p, \"xAccess\", \n        Tcl_NewStringObj(zPath, -1), Tcl_NewStringObj(zArg, -1), 0, 0\n    );\n    if( tvfsResultCode(p, &rc) ){\n      if( rc!=SQLITE_OK ) return rc;\n    }else{\n      Tcl_Interp *interp = p->interp;\n      if( TCL_OK==Tcl_GetBooleanFromObj(0, Tcl_GetObjResult(interp), pResOut) ){\n        return SQLITE_OK;\n      }\n    }\n  }\n  return sqlite3OsAccess(PARENTVFS(pVfs), zPath, flags, pResOut);\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int tvfsFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  Testvfs *p = (Testvfs *)pVfs->pAppData;\n  if( p->pScript && p->mask&TESTVFS_FULLPATHNAME_MASK ){\n    int rc;\n    tvfsExecTcl(p, \"xFullPathname\", Tcl_NewStringObj(zPath, -1), 0, 0, 0);\n    if( tvfsResultCode(p, &rc) ){\n      if( rc!=SQLITE_OK ) return rc;\n    }\n  }\n  return sqlite3OsFullPathname(PARENTVFS(pVfs), zPath, nOut, zOut);\n}\n\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *tvfsDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  return sqlite3OsDlOpen(PARENTVFS(pVfs), zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void tvfsDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  sqlite3OsDlError(PARENTVFS(pVfs), nByte, zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*tvfsDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){\n  return sqlite3OsDlSym(PARENTVFS(pVfs), p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void tvfsDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  sqlite3OsDlClose(PARENTVFS(pVfs), pHandle);\n}\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int tvfsRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  return sqlite3OsRandomness(PARENTVFS(pVfs), nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int tvfsSleep(sqlite3_vfs *pVfs, int nMicro){\n  return sqlite3OsSleep(PARENTVFS(pVfs), nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int tvfsCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  return PARENTVFS(pVfs)->xCurrentTime(PARENTVFS(pVfs), pTimeOut);\n}\n\nstatic int tvfsShmOpen(sqlite3_file *pFile){\n  Testvfs *p;\n  int rc = SQLITE_OK;             /* Return code */\n  TestvfsBuffer *pBuffer;         /* Buffer to open connection to */\n  TestvfsFd *pFd;                 /* The testvfs file structure */\n\n  pFd = tvfsGetFd(pFile);\n  p = (Testvfs *)pFd->pVfs->pAppData;\n  assert( 0==p->isFullshm );\n  assert( pFd->pShmId && pFd->pShm==0 && pFd->pNext==0 );\n\n  /* Evaluate the Tcl script: \n  **\n  **   SCRIPT xShmOpen FILENAME\n  */\n  Tcl_ResetResult(p->interp);\n  if( p->pScript && p->mask&TESTVFS_SHMOPEN_MASK ){\n    tvfsExecTcl(p, \"xShmOpen\", Tcl_NewStringObj(pFd->zFilename, -1), 0, 0, 0);\n    if( tvfsResultCode(p, &rc) ){\n      if( rc!=SQLITE_OK ) return rc;\n    }\n  }\n\n  assert( rc==SQLITE_OK );\n  if( p->mask&TESTVFS_SHMOPEN_MASK && tvfsInjectIoerr(p) ){\n    return SQLITE_IOERR;\n  }\n\n  /* Search for a TestvfsBuffer. Create a new one if required. */\n  for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){\n    if( 0==strcmp(pFd->zFilename, pBuffer->zFile) ) break;\n  }\n  if( !pBuffer ){\n    int szName = (int)strlen(pFd->zFilename);\n    int nByte = sizeof(TestvfsBuffer) + szName + 1;\n    pBuffer = (TestvfsBuffer *)ckalloc(nByte);\n    memset(pBuffer, 0, nByte);\n    pBuffer->zFile = (char *)&pBuffer[1];\n    memcpy(pBuffer->zFile, pFd->zFilename, szName+1);\n    pBuffer->pNext = p->pBuffer;\n    p->pBuffer = pBuffer;\n  }\n\n  /* Connect the TestvfsBuffer to the new TestvfsShm handle and return. */\n  pFd->pNext = pBuffer->pFile;\n  pBuffer->pFile = pFd;\n  pFd->pShm = pBuffer;\n  return SQLITE_OK;\n}\n\nstatic void tvfsAllocPage(TestvfsBuffer *p, int iPage, int pgsz){\n  assert( iPage<TESTVFS_MAX_PAGES );\n  if( p->aPage[iPage]==0 ){\n    p->aPage[iPage] = (u8 *)ckalloc(pgsz);\n    memset(p->aPage[iPage], 0, pgsz);\n    p->pgsz = pgsz;\n  }\n}\n\nstatic int tvfsShmMap(\n  sqlite3_file *pFile,            /* Handle open on database file */\n  int iPage,                      /* Page to retrieve */\n  int pgsz,                       /* Size of pages */\n  int isWrite,                    /* True to extend file if necessary */\n  void volatile **pp              /* OUT: Mapped memory */\n){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);\n\n  if( p->isFullshm ){\n    return sqlite3OsShmMap(pFd->pReal, iPage, pgsz, isWrite, pp);\n  }\n\n  if( 0==pFd->pShm ){\n    rc = tvfsShmOpen(pFile);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  if( p->pScript && p->mask&TESTVFS_SHMMAP_MASK ){\n    Tcl_Obj *pArg = Tcl_NewObj();\n    Tcl_IncrRefCount(pArg);\n    Tcl_ListObjAppendElement(p->interp, pArg, Tcl_NewIntObj(iPage));\n    Tcl_ListObjAppendElement(p->interp, pArg, Tcl_NewIntObj(pgsz));\n    Tcl_ListObjAppendElement(p->interp, pArg, Tcl_NewIntObj(isWrite));\n    tvfsExecTcl(p, \"xShmMap\", \n        Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, pArg, 0\n    );\n    tvfsResultCode(p, &rc);\n    Tcl_DecrRefCount(pArg);\n  }\n  if( rc==SQLITE_OK && p->mask&TESTVFS_SHMMAP_MASK && tvfsInjectIoerr(p) ){\n    rc = SQLITE_IOERR;\n  }\n\n  if( rc==SQLITE_OK && isWrite && !pFd->pShm->aPage[iPage] ){\n    tvfsAllocPage(pFd->pShm, iPage, pgsz);\n  }\n  *pp = (void volatile *)pFd->pShm->aPage[iPage];\n\n  return rc;\n}\n\n\nstatic int tvfsShmLock(\n  sqlite3_file *pFile,\n  int ofst,\n  int n,\n  int flags\n){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);\n  int nLock;\n  char zLock[80];\n\n  if( p->isFullshm ){\n    return sqlite3OsShmLock(pFd->pReal, ofst, n, flags);\n  }\n\n  if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){\n    sqlite3_snprintf(sizeof(zLock), zLock, \"%d %d\", ofst, n);\n    nLock = (int)strlen(zLock);\n    if( flags & SQLITE_SHM_LOCK ){\n      strcpy(&zLock[nLock], \" lock\");\n    }else{\n      strcpy(&zLock[nLock], \" unlock\");\n    }\n    nLock += (int)strlen(&zLock[nLock]);\n    if( flags & SQLITE_SHM_SHARED ){\n      strcpy(&zLock[nLock], \" shared\");\n    }else{\n      strcpy(&zLock[nLock], \" exclusive\");\n    }\n    tvfsExecTcl(p, \"xShmLock\", \n        Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId,\n        Tcl_NewStringObj(zLock, -1), 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n\n  if( rc==SQLITE_OK && p->mask&TESTVFS_SHMLOCK_MASK && tvfsInjectIoerr(p) ){\n    rc = SQLITE_IOERR;\n  }\n\n  if( rc==SQLITE_OK ){\n    int isLock = (flags & SQLITE_SHM_LOCK);\n    int isExcl = (flags & SQLITE_SHM_EXCLUSIVE);\n    u32 mask = (((1<<n)-1) << ofst);\n    if( isLock ){\n      TestvfsFd *p2;\n      for(p2=pFd->pShm->pFile; p2; p2=p2->pNext){\n        if( p2==pFd ) continue;\n        if( (p2->excllock&mask) || (isExcl && p2->sharedlock&mask) ){\n          rc = SQLITE_BUSY;\n          break;\n        }\n      }\n      if( rc==SQLITE_OK ){\n        if( isExcl )  pFd->excllock |= mask;\n        if( !isExcl ) pFd->sharedlock |= mask;\n      }\n    }else{\n      if( isExcl )  pFd->excllock &= (~mask);\n      if( !isExcl ) pFd->sharedlock &= (~mask);\n    }\n  }\n\n  return rc;\n}\n\nstatic void tvfsShmBarrier(sqlite3_file *pFile){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);\n\n  if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){\n    const char *z = pFd->pShm ? pFd->pShm->zFile : \"\";\n    tvfsExecTcl(p, \"xShmBarrier\", Tcl_NewStringObj(z, -1), pFd->pShmId, 0, 0);\n  }\n\n  if( p->isFullshm ){\n    sqlite3OsShmBarrier(pFd->pReal);\n    return;\n  }\n}\n\nstatic int tvfsShmUnmap(\n  sqlite3_file *pFile,\n  int deleteFlag\n){\n  int rc = SQLITE_OK;\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData);\n  TestvfsBuffer *pBuffer = pFd->pShm;\n  TestvfsFd **ppFd;\n\n  if( p->isFullshm ){\n    return sqlite3OsShmUnmap(pFd->pReal, deleteFlag);\n  }\n\n  if( !pBuffer ) return SQLITE_OK;\n  assert( pFd->pShmId && pFd->pShm );\n\n  if( p->pScript && p->mask&TESTVFS_SHMCLOSE_MASK ){\n    tvfsExecTcl(p, \"xShmUnmap\", \n        Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0, 0\n    );\n    tvfsResultCode(p, &rc);\n  }\n\n  for(ppFd=&pBuffer->pFile; *ppFd!=pFd; ppFd=&((*ppFd)->pNext));\n  assert( (*ppFd)==pFd );\n  *ppFd = pFd->pNext;\n  pFd->pNext = 0;\n\n  if( pBuffer->pFile==0 ){\n    int i;\n    TestvfsBuffer **pp;\n    for(pp=&p->pBuffer; *pp!=pBuffer; pp=&((*pp)->pNext));\n    *pp = (*pp)->pNext;\n    for(i=0; pBuffer->aPage[i]; i++){\n      ckfree((char *)pBuffer->aPage[i]);\n    }\n    ckfree((char *)pBuffer);\n  }\n  pFd->pShm = 0;\n\n  return rc;\n}\n\nstatic int tvfsFetch(\n    sqlite3_file *pFile, \n    sqlite3_int64 iOfst, \n    int iAmt, \n    void **pp\n){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  return sqlite3OsFetch(pFd->pReal, iOfst, iAmt, pp);\n}\n\nstatic int tvfsUnfetch(sqlite3_file *pFile, sqlite3_int64 iOfst, void *p){\n  TestvfsFd *pFd = tvfsGetFd(pFile);\n  return sqlite3OsUnfetch(pFd->pReal, iOfst, p);\n}\n\nstatic int SQLITE_TCLAPI testvfs_obj_cmd(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  Testvfs *p = (Testvfs *)cd;\n\n  enum DB_enum { \n    CMD_SHM, CMD_DELETE, CMD_FILTER, CMD_IOERR, CMD_SCRIPT, \n    CMD_DEVCHAR, CMD_SECTORSIZE, CMD_FULLERR, CMD_CANTOPENERR\n  };\n  struct TestvfsSubcmd {\n    char *zName;\n    enum DB_enum eCmd;\n  } aSubcmd[] = {\n    { \"shm\",         CMD_SHM         },\n    { \"delete\",      CMD_DELETE      },\n    { \"filter\",      CMD_FILTER      },\n    { \"ioerr\",       CMD_IOERR       },\n    { \"fullerr\",     CMD_FULLERR     },\n    { \"cantopenerr\", CMD_CANTOPENERR },\n    { \"script\",      CMD_SCRIPT      },\n    { \"devchar\",     CMD_DEVCHAR     },\n    { \"sectorsize\",  CMD_SECTORSIZE  },\n    { 0, 0 }\n  };\n  int i;\n  \n  if( objc<2 ){\n    Tcl_WrongNumArgs(interp, 1, objv, \"SUBCOMMAND ...\");\n    return TCL_ERROR;\n  }\n  if( Tcl_GetIndexFromObjStruct(\n        interp, objv[1], aSubcmd, sizeof(aSubcmd[0]), \"subcommand\", 0, &i) \n  ){\n    return TCL_ERROR;\n  }\n  Tcl_ResetResult(interp);\n\n  switch( aSubcmd[i].eCmd ){\n    case CMD_SHM: {\n      Tcl_Obj *pObj;\n      int rc;\n      TestvfsBuffer *pBuffer;\n      char *zName;\n      if( objc!=3 && objc!=4 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"FILE ?VALUE?\");\n        return TCL_ERROR;\n      }\n      zName = ckalloc(p->pParent->mxPathname);\n      rc = p->pParent->xFullPathname(\n          p->pParent, Tcl_GetString(objv[2]), \n          p->pParent->mxPathname, zName\n      );\n      if( rc!=SQLITE_OK ){\n        Tcl_AppendResult(interp, \"failed to get full path: \",\n                         Tcl_GetString(objv[2]), 0);\n        ckfree(zName);\n        return TCL_ERROR;\n      }\n      for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){\n        if( 0==strcmp(pBuffer->zFile, zName) ) break;\n      }\n      ckfree(zName);\n      if( !pBuffer ){\n        Tcl_AppendResult(interp, \"no such file: \", Tcl_GetString(objv[2]), 0);\n        return TCL_ERROR;\n      }\n      if( objc==4 ){\n        int n;\n        u8 *a = Tcl_GetByteArrayFromObj(objv[3], &n);\n        int pgsz = pBuffer->pgsz;\n        if( pgsz==0 ) pgsz = 65536;\n        for(i=0; i*pgsz<n; i++){\n          int nByte = pgsz;\n          tvfsAllocPage(pBuffer, i, pgsz);\n          if( n-i*pgsz<pgsz ){\n            nByte = n;\n          }\n          memcpy(pBuffer->aPage[i], &a[i*pgsz], nByte);\n        }\n      }\n\n      pObj = Tcl_NewObj();\n      for(i=0; pBuffer->aPage[i]; i++){\n        int pgsz = pBuffer->pgsz;\n        if( pgsz==0 ) pgsz = 65536;\n        Tcl_AppendObjToObj(pObj, Tcl_NewByteArrayObj(pBuffer->aPage[i], pgsz));\n      }\n      Tcl_SetObjResult(interp, pObj);\n      break;\n    }\n\n    /*  TESTVFS filter METHOD-LIST\n    **\n    **     Activate special processing for those methods contained in the list\n    */\n    case CMD_FILTER: {\n      static struct VfsMethod {\n        char *zName;\n        int mask;\n      } vfsmethod [] = {\n        { \"xShmOpen\",           TESTVFS_SHMOPEN_MASK },\n        { \"xShmLock\",           TESTVFS_SHMLOCK_MASK },\n        { \"xShmBarrier\",        TESTVFS_SHMBARRIER_MASK },\n        { \"xShmUnmap\",          TESTVFS_SHMCLOSE_MASK },\n        { \"xShmMap\",            TESTVFS_SHMMAP_MASK },\n        { \"xSync\",              TESTVFS_SYNC_MASK },\n        { \"xDelete\",            TESTVFS_DELETE_MASK },\n        { \"xWrite\",             TESTVFS_WRITE_MASK },\n        { \"xRead\",              TESTVFS_READ_MASK },\n        { \"xTruncate\",          TESTVFS_TRUNCATE_MASK },\n        { \"xOpen\",              TESTVFS_OPEN_MASK },\n        { \"xClose\",             TESTVFS_CLOSE_MASK },\n        { \"xAccess\",            TESTVFS_ACCESS_MASK },\n        { \"xFullPathname\",      TESTVFS_FULLPATHNAME_MASK },\n        { \"xUnlock\",            TESTVFS_UNLOCK_MASK },\n        { \"xLock\",              TESTVFS_LOCK_MASK },\n        { \"xCheckReservedLock\", TESTVFS_CKLOCK_MASK },\n      };\n      Tcl_Obj **apElem = 0;\n      int nElem = 0;\n      int mask = 0;\n      if( objc!=3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"LIST\");\n        return TCL_ERROR;\n      }\n      if( Tcl_ListObjGetElements(interp, objv[2], &nElem, &apElem) ){\n        return TCL_ERROR;\n      }\n      Tcl_ResetResult(interp);\n      for(i=0; i<nElem; i++){\n        int iMethod;\n        char *zElem = Tcl_GetString(apElem[i]);\n        for(iMethod=0; iMethod<ArraySize(vfsmethod); iMethod++){\n          if( strcmp(zElem, vfsmethod[iMethod].zName)==0 ){\n            mask |= vfsmethod[iMethod].mask;\n            break;\n          }\n        }\n        if( iMethod==ArraySize(vfsmethod) ){\n          Tcl_AppendResult(interp, \"unknown method: \", zElem, 0);\n          return TCL_ERROR;\n        }\n      }\n      p->mask = mask;\n      break;\n    }\n\n    /*\n    **  TESTVFS script ?SCRIPT?\n    **\n    **  Query or set the script to be run when filtered VFS events\n    **  occur.\n    */\n    case CMD_SCRIPT: {\n      if( objc==3 ){\n        int nByte;\n        if( p->pScript ){\n          Tcl_DecrRefCount(p->pScript);\n          p->pScript = 0;\n        }\n        Tcl_GetStringFromObj(objv[2], &nByte);\n        if( nByte>0 ){\n          p->pScript = Tcl_DuplicateObj(objv[2]);\n          Tcl_IncrRefCount(p->pScript);\n        }\n      }else if( objc!=2 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"?SCRIPT?\");\n        return TCL_ERROR;\n      }\n\n      Tcl_ResetResult(interp);\n      if( p->pScript ) Tcl_SetObjResult(interp, p->pScript);\n\n      break;\n    }\n\n    /*\n    ** TESTVFS ioerr ?IFAIL PERSIST?\n    **\n    **   Where IFAIL is an integer and PERSIST is boolean.\n    */\n    case CMD_CANTOPENERR:\n    case CMD_IOERR:\n    case CMD_FULLERR: {\n      TestFaultInject *pTest = 0;\n      int iRet;\n\n      switch( aSubcmd[i].eCmd ){\n        case CMD_IOERR: pTest = &p->ioerr_err; break;\n        case CMD_FULLERR: pTest = &p->full_err; break;\n        case CMD_CANTOPENERR: pTest = &p->cantopen_err; break;\n        default: assert(0);\n      }\n      iRet = pTest->nFail;\n      pTest->nFail = 0;\n      pTest->eFault = 0;\n      pTest->iCnt = 0;\n\n      if( objc==4 ){\n        int iCnt, iPersist;\n        if( TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iCnt)\n         || TCL_OK!=Tcl_GetBooleanFromObj(interp, objv[3], &iPersist)\n        ){\n          return TCL_ERROR;\n        }\n        pTest->eFault = iPersist?FAULT_INJECT_PERSISTENT:FAULT_INJECT_TRANSIENT;\n        pTest->iCnt = iCnt;\n      }else if( objc!=2 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"?CNT PERSIST?\");\n        return TCL_ERROR;\n      }\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(iRet));\n      break;\n    }\n\n    case CMD_DELETE: {\n      Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));\n      break;\n    }\n\n    case CMD_DEVCHAR: {\n      struct DeviceFlag {\n        char *zName;\n        int iValue;\n      } aFlag[] = {\n        { \"default\",               -1 },\n        { \"atomic\",                SQLITE_IOCAP_ATOMIC                },\n        { \"atomic512\",             SQLITE_IOCAP_ATOMIC512             },\n        { \"atomic1k\",              SQLITE_IOCAP_ATOMIC1K              },\n        { \"atomic2k\",              SQLITE_IOCAP_ATOMIC2K              },\n        { \"atomic4k\",              SQLITE_IOCAP_ATOMIC4K              },\n        { \"atomic8k\",              SQLITE_IOCAP_ATOMIC8K              },\n        { \"atomic16k\",             SQLITE_IOCAP_ATOMIC16K             },\n        { \"atomic32k\",             SQLITE_IOCAP_ATOMIC32K             },\n        { \"atomic64k\",             SQLITE_IOCAP_ATOMIC64K             },\n        { \"sequential\",            SQLITE_IOCAP_SEQUENTIAL            },\n        { \"safe_append\",           SQLITE_IOCAP_SAFE_APPEND           },\n        { \"undeletable_when_open\", SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN },\n        { \"powersafe_overwrite\",   SQLITE_IOCAP_POWERSAFE_OVERWRITE   },\n        { \"immutable\",             SQLITE_IOCAP_IMMUTABLE             },\n        { 0, 0 }\n      };\n      Tcl_Obj *pRet;\n      int iFlag;\n\n      if( objc>3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"?ATTR-LIST?\");\n        return TCL_ERROR;\n      }\n      if( objc==3 ){\n        int j;\n        int iNew = 0;\n        Tcl_Obj **flags = 0;\n        int nFlags = 0;\n\n        if( Tcl_ListObjGetElements(interp, objv[2], &nFlags, &flags) ){\n          return TCL_ERROR;\n        }\n\n        for(j=0; j<nFlags; j++){\n          int idx = 0;\n          if( Tcl_GetIndexFromObjStruct(interp, flags[j], aFlag, \n                sizeof(aFlag[0]), \"flag\", 0, &idx) \n          ){\n            return TCL_ERROR;\n          }\n          if( aFlag[idx].iValue<0 && nFlags>1 ){\n            Tcl_AppendResult(interp, \"bad flags: \", Tcl_GetString(objv[2]), 0);\n            return TCL_ERROR;\n          }\n          iNew |= aFlag[idx].iValue;\n        }\n\n        p->iDevchar = iNew| 0x10000000;\n      }\n\n      pRet = Tcl_NewObj();\n      for(iFlag=0; iFlag<sizeof(aFlag)/sizeof(aFlag[0]); iFlag++){\n        if( p->iDevchar & aFlag[iFlag].iValue ){\n          Tcl_ListObjAppendElement(\n              interp, pRet, Tcl_NewStringObj(aFlag[iFlag].zName, -1)\n          );\n        }\n      }\n      Tcl_SetObjResult(interp, pRet);\n\n      break;\n    }\n\n    case CMD_SECTORSIZE: {\n      if( objc>3 ){\n        Tcl_WrongNumArgs(interp, 2, objv, \"?VALUE?\");\n        return TCL_ERROR;\n      }\n      if( objc==3 ){\n        int iNew = 0;\n        if( Tcl_GetIntFromObj(interp, objv[2], &iNew) ){\n          return TCL_ERROR;\n        }\n        p->iSectorsize = iNew;\n      }\n      Tcl_SetObjResult(interp, Tcl_NewIntObj(p->iSectorsize));\n      break;\n    }\n  }\n\n  return TCL_OK;\n}\n\nstatic void SQLITE_TCLAPI testvfs_obj_del(ClientData cd){\n  Testvfs *p = (Testvfs *)cd;\n  if( p->pScript ) Tcl_DecrRefCount(p->pScript);\n  sqlite3_vfs_unregister(p->pVfs);\n  ckfree((char *)p->pVfs);\n  ckfree((char *)p);\n}\n\n/*\n** Usage:  testvfs VFSNAME ?SWITCHES?\n**\n** Switches are:\n**\n**   -noshm   BOOLEAN             (True to omit shm methods. Default false)\n**   -default BOOLEAN             (True to make the vfs default. Default false)\n**\n** This command creates two things when it is invoked: an SQLite VFS, and\n** a Tcl command. Both are named VFSNAME. The VFS is installed. It is not\n** installed as the default VFS.\n**\n** The VFS passes all file I/O calls through to the underlying VFS.\n**\n** Whenever the xShmMap method of the VFS\n** is invoked, the SCRIPT is executed as follows:\n**\n**   SCRIPT xShmMap    FILENAME ID\n**\n** The value returned by the invocation of SCRIPT above is interpreted as\n** an SQLite error code and returned to SQLite. Either a symbolic \n** \"SQLITE_OK\" or numeric \"0\" value may be returned.\n**\n** The contents of the shared-memory buffer associated with a given file\n** may be read and set using the following command:\n**\n**   VFSNAME shm FILENAME ?NEWVALUE?\n**\n** When the xShmLock method is invoked by SQLite, the following script is\n** run:\n**\n**   SCRIPT xShmLock    FILENAME ID LOCK\n**\n** where LOCK is of the form \"OFFSET NBYTE lock/unlock shared/exclusive\"\n*/\nstatic int SQLITE_TCLAPI testvfs_cmd(\n  ClientData cd,\n  Tcl_Interp *interp,\n  int objc,\n  Tcl_Obj *CONST objv[]\n){\n  static sqlite3_vfs tvfs_vfs = {\n    3,                            /* iVersion */\n    0,                            /* szOsFile */\n    0,                            /* mxPathname */\n    0,                            /* pNext */\n    0,                            /* zName */\n    0,                            /* pAppData */\n    tvfsOpen,                     /* xOpen */\n    tvfsDelete,                   /* xDelete */\n    tvfsAccess,                   /* xAccess */\n    tvfsFullPathname,             /* xFullPathname */\n#ifndef SQLITE_OMIT_LOAD_EXTENSION\n    tvfsDlOpen,                   /* xDlOpen */\n    tvfsDlError,                  /* xDlError */\n    tvfsDlSym,                    /* xDlSym */\n    tvfsDlClose,                  /* xDlClose */\n#else\n    0,                            /* xDlOpen */\n    0,                            /* xDlError */\n    0,                            /* xDlSym */\n    0,                            /* xDlClose */\n#endif /* SQLITE_OMIT_LOAD_EXTENSION */\n    tvfsRandomness,               /* xRandomness */\n    tvfsSleep,                    /* xSleep */\n    tvfsCurrentTime,              /* xCurrentTime */\n    0,                            /* xGetLastError */\n    0,                            /* xCurrentTimeInt64 */\n    0,                            /* xSetSystemCall */\n    0,                            /* xGetSystemCall */\n    0,                            /* xNextSystemCall */\n  };\n\n  Testvfs *p;                     /* New object */\n  sqlite3_vfs *pVfs;              /* New VFS */\n  char *zVfs;\n  int nByte;                      /* Bytes of space to allocate at p */\n\n  int i;\n  int isNoshm = 0;                /* True if -noshm is passed */\n  int isFullshm = 0;              /* True if -fullshm is passed */\n  int isDefault = 0;              /* True if -default is passed */\n  int szOsFile = 0;               /* Value passed to -szosfile */\n  int mxPathname = -1;            /* Value passed to -mxpathname */\n  int iVersion = 3;               /* Value passed to -iversion */\n\n  if( objc<2 || 0!=(objc%2) ) goto bad_args;\n  for(i=2; i<objc; i += 2){\n    int nSwitch;\n    char *zSwitch;\n    zSwitch = Tcl_GetStringFromObj(objv[i], &nSwitch); \n\n    if( nSwitch>2 && 0==strncmp(\"-noshm\", zSwitch, nSwitch) ){\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isNoshm) ){\n        return TCL_ERROR;\n      }\n      if( isNoshm ) isFullshm = 0;\n    }\n    else if( nSwitch>2 && 0==strncmp(\"-default\", zSwitch, nSwitch) ){\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isDefault) ){\n        return TCL_ERROR;\n      }\n    }\n    else if( nSwitch>2 && 0==strncmp(\"-szosfile\", zSwitch, nSwitch) ){\n      if( Tcl_GetIntFromObj(interp, objv[i+1], &szOsFile) ){\n        return TCL_ERROR;\n      }\n    }\n    else if( nSwitch>2 && 0==strncmp(\"-mxpathname\", zSwitch, nSwitch) ){\n      if( Tcl_GetIntFromObj(interp, objv[i+1], &mxPathname) ){\n        return TCL_ERROR;\n      }\n    }\n    else if( nSwitch>2 && 0==strncmp(\"-iversion\", zSwitch, nSwitch) ){\n      if( Tcl_GetIntFromObj(interp, objv[i+1], &iVersion) ){\n        return TCL_ERROR;\n      }\n    }\n    else if( nSwitch>2 && 0==strncmp(\"-fullshm\", zSwitch, nSwitch) ){\n      if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isFullshm) ){\n        return TCL_ERROR;\n      }\n      if( isFullshm ) isNoshm = 0;\n    }\n    else{\n      goto bad_args;\n    }\n  }\n\n  if( szOsFile<sizeof(TestvfsFile) ){\n    szOsFile = sizeof(TestvfsFile);\n  }\n\n  zVfs = Tcl_GetString(objv[1]);\n  nByte = sizeof(Testvfs) + (int)strlen(zVfs)+1;\n  p = (Testvfs *)ckalloc(nByte);\n  memset(p, 0, nByte);\n  p->iDevchar = -1;\n  p->iSectorsize = -1;\n\n  /* Create the new object command before querying SQLite for a default VFS\n  ** to use for 'real' IO operations. This is because creating the new VFS\n  ** may delete an existing [testvfs] VFS of the same name. If such a VFS\n  ** is currently the default, the new [testvfs] may end up calling the \n  ** methods of a deleted object.\n  */\n  Tcl_CreateObjCommand(interp, zVfs, testvfs_obj_cmd, p, testvfs_obj_del);\n  p->pParent = sqlite3_vfs_find(0);\n  p->interp = interp;\n\n  p->zName = (char *)&p[1];\n  memcpy(p->zName, zVfs, strlen(zVfs)+1);\n\n  pVfs = (sqlite3_vfs *)ckalloc(sizeof(sqlite3_vfs));\n  memcpy(pVfs, &tvfs_vfs, sizeof(sqlite3_vfs));\n  pVfs->pAppData = (void *)p;\n  pVfs->iVersion = iVersion;\n  pVfs->zName = p->zName;\n  pVfs->mxPathname = p->pParent->mxPathname;\n  if( mxPathname>=0 && mxPathname<pVfs->mxPathname ){\n    pVfs->mxPathname = mxPathname;\n  }\n  pVfs->szOsFile = szOsFile;\n  p->pVfs = pVfs;\n  p->isNoshm = isNoshm;\n  p->isFullshm = isFullshm;\n  p->mask = TESTVFS_ALL_MASK;\n\n  sqlite3_vfs_register(pVfs, isDefault);\n\n  return TCL_OK;\n\n bad_args:\n  Tcl_WrongNumArgs(interp, 1, objv, \"VFSNAME ?-noshm BOOL? ?-fullshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?\");\n  return TCL_ERROR;\n}\n\nint Sqlitetestvfs_Init(Tcl_Interp *interp){\n  Tcl_CreateObjCommand(interp, \"testvfs\", testvfs_cmd, 0, 0);\n  return TCL_OK;\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_vfstrace.c",
    "content": "/*\n** 2011 March 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code implements a VFS shim that writes diagnostic\n** output for each VFS call, similar to \"strace\".\n**\n** USAGE:\n**\n** This source file exports a single symbol which is the name of a\n** function:\n**\n**   int vfstrace_register(\n**     const char *zTraceName,         // Name of the newly constructed VFS\n**     const char *zOldVfsName,        // Name of the underlying VFS\n**     int (*xOut)(const char*,void*), // Output routine.  ex: fputs\n**     void *pOutArg,                  // 2nd argument to xOut.  ex: stderr\n**     int makeDefault                 // Make the new VFS the default\n**   );\n**\n** Applications that want to trace their VFS usage must provide a callback\n** function with this prototype:\n**\n**   int traceOutput(const char *zMessage, void *pAppData);\n**\n** This function will \"output\" the trace messages, where \"output\" can\n** mean different things to different applications.  The traceOutput function\n** for the command-line shell (see shell.c) is \"fputs\" from the standard\n** library, which means that all trace output is written on the stream\n** specified by the second argument.  In the case of the command-line shell\n** the second argument is stderr.  Other applications might choose to output\n** trace information to a file, over a socket, or write it into a buffer.\n**\n** The vfstrace_register() function creates a new \"shim\" VFS named by\n** the zTraceName parameter.  A \"shim\" VFS is an SQLite backend that does\n** not really perform the duties of a true backend, but simply filters or\n** interprets VFS calls before passing them off to another VFS which does\n** the actual work.  In this case the other VFS - the one that does the\n** real work - is identified by the second parameter, zOldVfsName.  If\n** the 2nd parameter is NULL then the default VFS is used.  The common\n** case is for the 2nd parameter to be NULL.\n**\n** The third and fourth parameters are the pointer to the output function\n** and the second argument to the output function.  For the SQLite\n** command-line shell, when the -vfstrace option is used, these parameters\n** are fputs and stderr, respectively.\n**\n** The fifth argument is true (non-zero) to cause the newly created VFS\n** to become the default VFS.  The common case is for the fifth parameter\n** to be true.\n**\n** The call to vfstrace_register() simply creates the shim VFS that does\n** tracing.  The application must also arrange to use the new VFS for\n** all database connections that are created and for which tracing is \n** desired.  This can be done by specifying the trace VFS using URI filename\n** notation, or by specifying the trace VFS as the 4th parameter to\n** sqlite3_open_v2() or by making the trace VFS be the default (by setting\n** the 5th parameter of vfstrace_register() to 1).\n**\n**\n** ENABLING VFSTRACE IN A COMMAND-LINE SHELL\n**\n** The SQLite command line shell implemented by the shell.c source file\n** can be used with this module.  To compile in -vfstrace support, first\n** gather this file (test_vfstrace.c), the shell source file (shell.c),\n** and the SQLite amalgamation source files (sqlite3.c, sqlite3.h) into\n** the working directory.  Then compile using a command like the following:\n**\n**    gcc -o sqlite3 -Os -I. -DSQLITE_ENABLE_VFSTRACE \\\n**        -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE \\\n**        -DHAVE_READLINE -DHAVE_USLEEP=1 \\\n**        shell.c test_vfstrace.c sqlite3.c -ldl -lreadline -lncurses\n**\n** The gcc command above works on Linux and provides (in addition to the\n** -vfstrace option) support for FTS3 and FTS4, RTREE, and command-line\n** editing using the readline library.  The command-line shell does not\n** use threads so we added -DSQLITE_THREADSAFE=0 just to make the code\n** run a little faster.   For compiling on a Mac, you'll probably need\n** to omit the -DHAVE_READLINE, the -lreadline, and the -lncurses options.\n** The compilation could be simplified to just this:\n**\n**    gcc -DSQLITE_ENABLE_VFSTRACE \\\n**         shell.c test_vfstrace.c sqlite3.c -ldl -lpthread\n**\n** In this second example, all unnecessary options have been removed\n** Note that since the code is now threadsafe, we had to add the -lpthread\n** option to pull in the pthreads library.\n**\n** To cross-compile for windows using MinGW, a command like this might\n** work:\n**\n**    /opt/mingw/bin/i386-mingw32msvc-gcc -o sqlite3.exe -Os -I \\\n**         -DSQLITE_THREADSAFE=0 -DSQLITE_ENABLE_VFSTRACE \\\n**         shell.c test_vfstrace.c sqlite3.c\n**\n** Similar compiler commands will work on different systems.  The key\n** invariants are (1) you must have -DSQLITE_ENABLE_VFSTRACE so that\n** the shell.c source file will know to include the -vfstrace command-line\n** option and (2) you must compile and link the three source files\n** shell,c, test_vfstrace.c, and sqlite3.c.  \n*/\n#include <stdlib.h>\n#include <string.h>\n#include \"sqlite3.h\"\n\n/*\n** An instance of this structure is attached to the each trace VFS to\n** provide auxiliary information.\n*/\ntypedef struct vfstrace_info vfstrace_info;\nstruct vfstrace_info {\n  sqlite3_vfs *pRootVfs;              /* The underlying real VFS */\n  int (*xOut)(const char*, void*);    /* Send output here */\n  void *pOutArg;                      /* First argument to xOut */\n  const char *zVfsName;               /* Name of this trace-VFS */\n  sqlite3_vfs *pTraceVfs;             /* Pointer back to the trace VFS */\n};\n\n/*\n** The sqlite3_file object for the trace VFS\n*/\ntypedef struct vfstrace_file vfstrace_file;\nstruct vfstrace_file {\n  sqlite3_file base;        /* Base class.  Must be first */\n  vfstrace_info *pInfo;     /* The trace-VFS to which this file belongs */\n  const char *zFName;       /* Base name of the file */\n  sqlite3_file *pReal;      /* The real underlying file */\n};\n\n/*\n** Method declarations for vfstrace_file.\n*/\nstatic int vfstraceClose(sqlite3_file*);\nstatic int vfstraceRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);\nstatic int vfstraceWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64);\nstatic int vfstraceTruncate(sqlite3_file*, sqlite3_int64 size);\nstatic int vfstraceSync(sqlite3_file*, int flags);\nstatic int vfstraceFileSize(sqlite3_file*, sqlite3_int64 *pSize);\nstatic int vfstraceLock(sqlite3_file*, int);\nstatic int vfstraceUnlock(sqlite3_file*, int);\nstatic int vfstraceCheckReservedLock(sqlite3_file*, int *);\nstatic int vfstraceFileControl(sqlite3_file*, int op, void *pArg);\nstatic int vfstraceSectorSize(sqlite3_file*);\nstatic int vfstraceDeviceCharacteristics(sqlite3_file*);\nstatic int vfstraceShmLock(sqlite3_file*,int,int,int);\nstatic int vfstraceShmMap(sqlite3_file*,int,int,int, void volatile **);\nstatic void vfstraceShmBarrier(sqlite3_file*);\nstatic int vfstraceShmUnmap(sqlite3_file*,int);\n\n/*\n** Method declarations for vfstrace_vfs.\n*/\nstatic int vfstraceOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *);\nstatic int vfstraceDelete(sqlite3_vfs*, const char *zName, int syncDir);\nstatic int vfstraceAccess(sqlite3_vfs*, const char *zName, int flags, int *);\nstatic int vfstraceFullPathname(sqlite3_vfs*, const char *zName, int, char *);\nstatic void *vfstraceDlOpen(sqlite3_vfs*, const char *zFilename);\nstatic void vfstraceDlError(sqlite3_vfs*, int nByte, char *zErrMsg);\nstatic void (*vfstraceDlSym(sqlite3_vfs*,void*, const char *zSymbol))(void);\nstatic void vfstraceDlClose(sqlite3_vfs*, void*);\nstatic int vfstraceRandomness(sqlite3_vfs*, int nByte, char *zOut);\nstatic int vfstraceSleep(sqlite3_vfs*, int microseconds);\nstatic int vfstraceCurrentTime(sqlite3_vfs*, double*);\nstatic int vfstraceGetLastError(sqlite3_vfs*, int, char*);\nstatic int vfstraceCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);\nstatic int vfstraceSetSystemCall(sqlite3_vfs*,const char*, sqlite3_syscall_ptr);\nstatic sqlite3_syscall_ptr vfstraceGetSystemCall(sqlite3_vfs*, const char *);\nstatic const char *vfstraceNextSystemCall(sqlite3_vfs*, const char *zName);\n\n/*\n** Return a pointer to the tail of the pathname.  Examples:\n**\n**     /home/drh/xyzzy.txt -> xyzzy.txt\n**     xyzzy.txt           -> xyzzy.txt\n*/\nstatic const char *fileTail(const char *z){\n  int i;\n  if( z==0 ) return 0;\n  i = strlen(z)-1;\n  while( i>0 && z[i-1]!='/' ){ i--; }\n  return &z[i];\n}\n\n/*\n** Send trace output defined by zFormat and subsequent arguments.\n*/\nstatic void vfstrace_printf(\n  vfstrace_info *pInfo,\n  const char *zFormat,\n  ...\n){\n  va_list ap;\n  char *zMsg;\n  va_start(ap, zFormat);\n  zMsg = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  pInfo->xOut(zMsg, pInfo->pOutArg);\n  sqlite3_free(zMsg);\n}\n\n/*\n** Convert value rc into a string and print it using zFormat.  zFormat\n** should have exactly one %s\n*/\nstatic void vfstrace_print_errcode(\n  vfstrace_info *pInfo,\n  const char *zFormat,\n  int rc\n){\n  char zBuf[50];\n  char *zVal;\n  switch( rc ){\n    case SQLITE_OK:         zVal = \"SQLITE_OK\";          break;\n    case SQLITE_ERROR:      zVal = \"SQLITE_ERROR\";       break;\n    case SQLITE_PERM:       zVal = \"SQLITE_PERM\";        break;\n    case SQLITE_ABORT:      zVal = \"SQLITE_ABORT\";       break;\n    case SQLITE_BUSY:       zVal = \"SQLITE_BUSY\";        break;\n    case SQLITE_NOMEM:      zVal = \"SQLITE_NOMEM\";       break;\n    case SQLITE_READONLY:   zVal = \"SQLITE_READONLY\";    break;\n    case SQLITE_INTERRUPT:  zVal = \"SQLITE_INTERRUPT\";   break;\n    case SQLITE_IOERR:      zVal = \"SQLITE_IOERR\";       break;\n    case SQLITE_CORRUPT:    zVal = \"SQLITE_CORRUPT\";     break;\n    case SQLITE_FULL:       zVal = \"SQLITE_FULL\";        break;\n    case SQLITE_CANTOPEN:   zVal = \"SQLITE_CANTOPEN\";    break;\n    case SQLITE_PROTOCOL:   zVal = \"SQLITE_PROTOCOL\";    break;\n    case SQLITE_EMPTY:      zVal = \"SQLITE_EMPTY\";       break;\n    case SQLITE_SCHEMA:     zVal = \"SQLITE_SCHEMA\";      break;\n    case SQLITE_CONSTRAINT: zVal = \"SQLITE_CONSTRAINT\";  break;\n    case SQLITE_MISMATCH:   zVal = \"SQLITE_MISMATCH\";    break;\n    case SQLITE_MISUSE:     zVal = \"SQLITE_MISUSE\";      break;\n    case SQLITE_NOLFS:      zVal = \"SQLITE_NOLFS\";       break;\n    case SQLITE_IOERR_READ:         zVal = \"SQLITE_IOERR_READ\";         break;\n    case SQLITE_IOERR_SHORT_READ:   zVal = \"SQLITE_IOERR_SHORT_READ\";   break;\n    case SQLITE_IOERR_WRITE:        zVal = \"SQLITE_IOERR_WRITE\";        break;\n    case SQLITE_IOERR_FSYNC:        zVal = \"SQLITE_IOERR_FSYNC\";        break;\n    case SQLITE_IOERR_DIR_FSYNC:    zVal = \"SQLITE_IOERR_DIR_FSYNC\";    break;\n    case SQLITE_IOERR_TRUNCATE:     zVal = \"SQLITE_IOERR_TRUNCATE\";     break;\n    case SQLITE_IOERR_FSTAT:        zVal = \"SQLITE_IOERR_FSTAT\";        break;\n    case SQLITE_IOERR_UNLOCK:       zVal = \"SQLITE_IOERR_UNLOCK\";       break;\n    case SQLITE_IOERR_RDLOCK:       zVal = \"SQLITE_IOERR_RDLOCK\";       break;\n    case SQLITE_IOERR_DELETE:       zVal = \"SQLITE_IOERR_DELETE\";       break;\n    case SQLITE_IOERR_BLOCKED:      zVal = \"SQLITE_IOERR_BLOCKED\";      break;\n    case SQLITE_IOERR_NOMEM:        zVal = \"SQLITE_IOERR_NOMEM\";        break;\n    case SQLITE_IOERR_ACCESS:       zVal = \"SQLITE_IOERR_ACCESS\";       break;\n    case SQLITE_IOERR_CHECKRESERVEDLOCK:\n                               zVal = \"SQLITE_IOERR_CHECKRESERVEDLOCK\"; break;\n    case SQLITE_IOERR_LOCK:         zVal = \"SQLITE_IOERR_LOCK\";         break;\n    case SQLITE_IOERR_CLOSE:        zVal = \"SQLITE_IOERR_CLOSE\";        break;\n    case SQLITE_IOERR_DIR_CLOSE:    zVal = \"SQLITE_IOERR_DIR_CLOSE\";    break;\n    case SQLITE_IOERR_SHMOPEN:      zVal = \"SQLITE_IOERR_SHMOPEN\";      break;\n    case SQLITE_IOERR_SHMSIZE:      zVal = \"SQLITE_IOERR_SHMSIZE\";      break;\n    case SQLITE_IOERR_SHMLOCK:      zVal = \"SQLITE_IOERR_SHMLOCK\";      break;\n    case SQLITE_IOERR_SHMMAP:       zVal = \"SQLITE_IOERR_SHMMAP\";       break;\n    case SQLITE_IOERR_SEEK:         zVal = \"SQLITE_IOERR_SEEK\";         break;\n    case SQLITE_IOERR_GETTEMPPATH:  zVal = \"SQLITE_IOERR_GETTEMPPATH\";  break;\n    case SQLITE_IOERR_CONVPATH:     zVal = \"SQLITE_IOERR_CONVPATH\";     break;\n    case SQLITE_READONLY_DBMOVED:   zVal = \"SQLITE_READONLY_DBMOVED\";   break;\n    case SQLITE_LOCKED_SHAREDCACHE: zVal = \"SQLITE_LOCKED_SHAREDCACHE\"; break;\n    case SQLITE_BUSY_RECOVERY:      zVal = \"SQLITE_BUSY_RECOVERY\";      break;\n    case SQLITE_CANTOPEN_NOTEMPDIR: zVal = \"SQLITE_CANTOPEN_NOTEMPDIR\"; break;\n    default: {\n       sqlite3_snprintf(sizeof(zBuf), zBuf, \"%d\", rc);\n       zVal = zBuf;\n       break;\n    }\n  }\n  vfstrace_printf(pInfo, zFormat, zVal);\n}\n\n/*\n** Append to a buffer.\n*/\nstatic void strappend(char *z, int *pI, const char *zAppend){\n  int i = *pI;\n  while( zAppend[0] ){ z[i++] = *(zAppend++); }\n  z[i] = 0;\n  *pI = i;\n}\n\n/*\n** Close an vfstrace-file.\n*/\nstatic int vfstraceClose(sqlite3_file *pFile){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xClose(%s)\", pInfo->zVfsName, p->zFName);\n  rc = p->pReal->pMethods->xClose(p->pReal);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  if( rc==SQLITE_OK ){\n    sqlite3_free((void*)p->base.pMethods);\n    p->base.pMethods = 0;\n  }\n  return rc;\n}\n\n/*\n** Read data from an vfstrace-file.\n*/\nstatic int vfstraceRead(\n  sqlite3_file *pFile, \n  void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xRead(%s,n=%d,ofst=%lld)\",\n                  pInfo->zVfsName, p->zFName, iAmt, iOfst);\n  rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n/*\n** Write data to an vfstrace-file.\n*/\nstatic int vfstraceWrite(\n  sqlite3_file *pFile, \n  const void *zBuf, \n  int iAmt, \n  sqlite_int64 iOfst\n){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xWrite(%s,n=%d,ofst=%lld)\",\n                  pInfo->zVfsName, p->zFName, iAmt, iOfst);\n  rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n/*\n** Truncate an vfstrace-file.\n*/\nstatic int vfstraceTruncate(sqlite3_file *pFile, sqlite_int64 size){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xTruncate(%s,%lld)\", pInfo->zVfsName, p->zFName,\n                  size);\n  rc = p->pReal->pMethods->xTruncate(p->pReal, size);\n  vfstrace_printf(pInfo, \" -> %d\\n\", rc);\n  return rc;\n}\n\n/*\n** Sync an vfstrace-file.\n*/\nstatic int vfstraceSync(sqlite3_file *pFile, int flags){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  int i;\n  char zBuf[100];\n  memcpy(zBuf, \"|0\", 3);\n  i = 0;\n  if( flags & SQLITE_SYNC_FULL )        strappend(zBuf, &i, \"|FULL\");\n  else if( flags & SQLITE_SYNC_NORMAL ) strappend(zBuf, &i, \"|NORMAL\");\n  if( flags & SQLITE_SYNC_DATAONLY )    strappend(zBuf, &i, \"|DATAONLY\");\n  if( flags & ~(SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY) ){\n    sqlite3_snprintf(sizeof(zBuf)-i, &zBuf[i], \"|0x%x\", flags);\n  }\n  vfstrace_printf(pInfo, \"%s.xSync(%s,%s)\", pInfo->zVfsName, p->zFName,\n                  &zBuf[1]);\n  rc = p->pReal->pMethods->xSync(p->pReal, flags);\n  vfstrace_printf(pInfo, \" -> %d\\n\", rc);\n  return rc;\n}\n\n/*\n** Return the current file-size of an vfstrace-file.\n*/\nstatic int vfstraceFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xFileSize(%s)\", pInfo->zVfsName, p->zFName);\n  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);\n  vfstrace_print_errcode(pInfo, \" -> %s,\", rc);\n  vfstrace_printf(pInfo, \" size=%lld\\n\", *pSize);\n  return rc;\n}\n\n/*\n** Return the name of a lock.\n*/\nstatic const char *lockName(int eLock){\n  const char *azLockNames[] = {\n     \"NONE\", \"SHARED\", \"RESERVED\", \"PENDING\", \"EXCLUSIVE\"\n  };\n  if( eLock<0 || eLock>=sizeof(azLockNames)/sizeof(azLockNames[0]) ){\n    return \"???\";\n  }else{\n    return azLockNames[eLock];\n  }\n}\n\n/*\n** Lock an vfstrace-file.\n*/\nstatic int vfstraceLock(sqlite3_file *pFile, int eLock){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xLock(%s,%s)\", pInfo->zVfsName, p->zFName,\n                  lockName(eLock));\n  rc = p->pReal->pMethods->xLock(p->pReal, eLock);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n/*\n** Unlock an vfstrace-file.\n*/\nstatic int vfstraceUnlock(sqlite3_file *pFile, int eLock){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xUnlock(%s,%s)\", pInfo->zVfsName, p->zFName,\n                  lockName(eLock));\n  rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n/*\n** Check if another file-handle holds a RESERVED lock on an vfstrace-file.\n*/\nstatic int vfstraceCheckReservedLock(sqlite3_file *pFile, int *pResOut){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xCheckReservedLock(%s,%d)\", \n                  pInfo->zVfsName, p->zFName);\n  rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);\n  vfstrace_print_errcode(pInfo, \" -> %s\", rc);\n  vfstrace_printf(pInfo, \", out=%d\\n\", *pResOut);\n  return rc;\n}\n\n/*\n** File control method. For custom operations on an vfstrace-file.\n*/\nstatic int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  char zBuf[100];\n  char *zOp;\n  switch( op ){\n    case SQLITE_FCNTL_LOCKSTATE:    zOp = \"LOCKSTATE\";          break;\n    case SQLITE_GET_LOCKPROXYFILE:  zOp = \"GET_LOCKPROXYFILE\";  break;\n    case SQLITE_SET_LOCKPROXYFILE:  zOp = \"SET_LOCKPROXYFILE\";  break;\n    case SQLITE_LAST_ERRNO:         zOp = \"LAST_ERRNO\";         break;\n    case SQLITE_FCNTL_SIZE_HINT: {\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"SIZE_HINT,%lld\",\n                       *(sqlite3_int64*)pArg);\n      zOp = zBuf;\n      break;\n    }\n    case SQLITE_FCNTL_CHUNK_SIZE: {\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"CHUNK_SIZE,%d\", *(int*)pArg);\n      zOp = zBuf;\n      break;\n    }\n    case SQLITE_FCNTL_FILE_POINTER: zOp = \"FILE_POINTER\";       break;\n    case SQLITE_FCNTL_SYNC_OMITTED: zOp = \"SYNC_OMITTED\";       break;\n    case SQLITE_FCNTL_WIN32_AV_RETRY: zOp = \"WIN32_AV_RETRY\";   break;\n    case SQLITE_FCNTL_PERSIST_WAL:  zOp = \"PERSIST_WAL\";        break;\n    case SQLITE_FCNTL_OVERWRITE:    zOp = \"OVERWRITE\";          break;\n    case SQLITE_FCNTL_VFSNAME:      zOp = \"VFSNAME\";            break;\n    case SQLITE_FCNTL_TEMPFILENAME: zOp = \"TEMPFILENAME\";       break;\n    case 0xca093fa0:                zOp = \"DB_UNCHANGED\";       break;\n    case SQLITE_FCNTL_PRAGMA: {\n      const char *const* a = (const char*const*)pArg;\n      sqlite3_snprintf(sizeof(zBuf), zBuf, \"PRAGMA,[%s,%s]\",a[1],a[2]);\n      zOp = zBuf;\n      break;\n    }\n    default: {\n      sqlite3_snprintf(sizeof zBuf, zBuf, \"%d\", op);\n      zOp = zBuf;\n      break;\n    }\n  }\n  vfstrace_printf(pInfo, \"%s.xFileControl(%s,%s)\",\n                  pInfo->zVfsName, p->zFName, zOp);\n  rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){\n    *(char**)pArg = sqlite3_mprintf(\"vfstrace.%s/%z\",\n                                    pInfo->zVfsName, *(char**)pArg);\n  }\n  if( (op==SQLITE_FCNTL_PRAGMA || op==SQLITE_FCNTL_TEMPFILENAME)\n   && rc==SQLITE_OK && *(char**)pArg ){\n    vfstrace_printf(pInfo, \"%s.xFileControl(%s,%s) returns %s\",\n                    pInfo->zVfsName, p->zFName, zOp, *(char**)pArg);\n  }\n  return rc;\n}\n\n/*\n** Return the sector-size in bytes for an vfstrace-file.\n*/\nstatic int vfstraceSectorSize(sqlite3_file *pFile){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xSectorSize(%s)\", pInfo->zVfsName, p->zFName);\n  rc = p->pReal->pMethods->xSectorSize(p->pReal);\n  vfstrace_printf(pInfo, \" -> %d\\n\", rc);\n  return rc;\n}\n\n/*\n** Return the device characteristic flags supported by an vfstrace-file.\n*/\nstatic int vfstraceDeviceCharacteristics(sqlite3_file *pFile){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xDeviceCharacteristics(%s)\",\n                  pInfo->zVfsName, p->zFName);\n  rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);\n  vfstrace_printf(pInfo, \" -> 0x%08x\\n\", rc);\n  return rc;\n}\n\n/*\n** Shared-memory operations.\n*/\nstatic int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  char zLck[100];\n  int i = 0;\n  memcpy(zLck, \"|0\", 3);\n  if( flags & SQLITE_SHM_UNLOCK )    strappend(zLck, &i, \"|UNLOCK\");\n  if( flags & SQLITE_SHM_LOCK )      strappend(zLck, &i, \"|LOCK\");\n  if( flags & SQLITE_SHM_SHARED )    strappend(zLck, &i, \"|SHARED\");\n  if( flags & SQLITE_SHM_EXCLUSIVE ) strappend(zLck, &i, \"|EXCLUSIVE\");\n  if( flags & ~(0xf) ){\n     sqlite3_snprintf(sizeof(zLck)-i, &zLck[i], \"|0x%x\", flags);\n  }\n  vfstrace_printf(pInfo, \"%s.xShmLock(%s,ofst=%d,n=%d,%s)\",\n                  pInfo->zVfsName, p->zFName, ofst, n, &zLck[1]);\n  rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\nstatic int vfstraceShmMap(\n  sqlite3_file *pFile, \n  int iRegion, \n  int szRegion, \n  int isWrite, \n  void volatile **pp\n){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xShmMap(%s,iRegion=%d,szRegion=%d,isWrite=%d,*)\",\n                  pInfo->zVfsName, p->zFName, iRegion, szRegion, isWrite);\n  rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\nstatic void vfstraceShmBarrier(sqlite3_file *pFile){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  vfstrace_printf(pInfo, \"%s.xShmBarrier(%s)\\n\", pInfo->zVfsName, p->zFName);\n  p->pReal->pMethods->xShmBarrier(p->pReal);\n}\nstatic int vfstraceShmUnmap(sqlite3_file *pFile, int delFlag){\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = p->pInfo;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xShmUnmap(%s,delFlag=%d)\",\n                  pInfo->zVfsName, p->zFName, delFlag);\n  rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n\n\n/*\n** Open an vfstrace file handle.\n*/\nstatic int vfstraceOpen(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_file *pFile,\n  int flags,\n  int *pOutFlags\n){\n  int rc;\n  vfstrace_file *p = (vfstrace_file *)pFile;\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  p->pInfo = pInfo;\n  p->zFName = zName ? fileTail(zName) : \"<temp>\";\n  p->pReal = (sqlite3_file *)&p[1];\n  rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);\n  vfstrace_printf(pInfo, \"%s.xOpen(%s,flags=0x%x)\",\n                  pInfo->zVfsName, p->zFName, flags);\n  if( p->pReal->pMethods ){\n    sqlite3_io_methods *pNew = sqlite3_malloc( sizeof(*pNew) );\n    const sqlite3_io_methods *pSub = p->pReal->pMethods;\n    memset(pNew, 0, sizeof(*pNew));\n    pNew->iVersion = pSub->iVersion;\n    pNew->xClose = vfstraceClose;\n    pNew->xRead = vfstraceRead;\n    pNew->xWrite = vfstraceWrite;\n    pNew->xTruncate = vfstraceTruncate;\n    pNew->xSync = vfstraceSync;\n    pNew->xFileSize = vfstraceFileSize;\n    pNew->xLock = vfstraceLock;\n    pNew->xUnlock = vfstraceUnlock;\n    pNew->xCheckReservedLock = vfstraceCheckReservedLock;\n    pNew->xFileControl = vfstraceFileControl;\n    pNew->xSectorSize = vfstraceSectorSize;\n    pNew->xDeviceCharacteristics = vfstraceDeviceCharacteristics;\n    if( pNew->iVersion>=2 ){\n      pNew->xShmMap = pSub->xShmMap ? vfstraceShmMap : 0;\n      pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0;\n      pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;\n      pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;\n    }\n    pFile->pMethods = pNew;\n  }\n  vfstrace_print_errcode(pInfo, \" -> %s\", rc);\n  if( pOutFlags ){\n    vfstrace_printf(pInfo, \", outFlags=0x%x\\n\", *pOutFlags);\n  }else{\n    vfstrace_printf(pInfo, \"\\n\");\n  }\n  return rc;\n}\n\n/*\n** Delete the file located at zPath. If the dirSync argument is true,\n** ensure the file-system modifications are synced to disk before\n** returning.\n*/\nstatic int vfstraceDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xDelete(\\\"%s\\\",%d)\",\n                  pInfo->zVfsName, zPath, dirSync);\n  rc = pRoot->xDelete(pRoot, zPath, dirSync);\n  vfstrace_print_errcode(pInfo, \" -> %s\\n\", rc);\n  return rc;\n}\n\n/*\n** Test for access permissions. Return true if the requested permission\n** is available, or false otherwise.\n*/\nstatic int vfstraceAccess(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int flags, \n  int *pResOut\n){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xAccess(\\\"%s\\\",%d)\",\n                  pInfo->zVfsName, zPath, flags);\n  rc = pRoot->xAccess(pRoot, zPath, flags, pResOut);\n  vfstrace_print_errcode(pInfo, \" -> %s\", rc);\n  vfstrace_printf(pInfo, \", out=%d\\n\", *pResOut);\n  return rc;\n}\n\n/*\n** Populate buffer zOut with the full canonical pathname corresponding\n** to the pathname in zPath. zOut is guaranteed to point to a buffer\n** of at least (DEVSYM_MAX_PATHNAME+1) bytes.\n*/\nstatic int vfstraceFullPathname(\n  sqlite3_vfs *pVfs, \n  const char *zPath, \n  int nOut, \n  char *zOut\n){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  int rc;\n  vfstrace_printf(pInfo, \"%s.xFullPathname(\\\"%s\\\")\",\n                  pInfo->zVfsName, zPath);\n  rc = pRoot->xFullPathname(pRoot, zPath, nOut, zOut);\n  vfstrace_print_errcode(pInfo, \" -> %s\", rc);\n  vfstrace_printf(pInfo, \", out=\\\"%.*s\\\"\\n\", nOut, zOut);\n  return rc;\n}\n\n/*\n** Open the dynamic library located at zPath and return a handle.\n*/\nstatic void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  vfstrace_printf(pInfo, \"%s.xDlOpen(\\\"%s\\\")\\n\", pInfo->zVfsName, zPath);\n  return pRoot->xDlOpen(pRoot, zPath);\n}\n\n/*\n** Populate the buffer zErrMsg (size nByte bytes) with a human readable\n** utf-8 string describing the most recent error encountered associated \n** with dynamic libraries.\n*/\nstatic void vfstraceDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  vfstrace_printf(pInfo, \"%s.xDlError(%d)\", pInfo->zVfsName, nByte);\n  pRoot->xDlError(pRoot, nByte, zErrMsg);\n  vfstrace_printf(pInfo, \" -> \\\"%s\\\"\", zErrMsg);\n}\n\n/*\n** Return a pointer to the symbol zSymbol in the dynamic library pHandle.\n*/\nstatic void (*vfstraceDlSym(sqlite3_vfs *pVfs,void *p,const char *zSym))(void){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  vfstrace_printf(pInfo, \"%s.xDlSym(\\\"%s\\\")\\n\", pInfo->zVfsName, zSym);\n  return pRoot->xDlSym(pRoot, p, zSym);\n}\n\n/*\n** Close the dynamic library handle pHandle.\n*/\nstatic void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  vfstrace_printf(pInfo, \"%s.xDlOpen()\\n\", pInfo->zVfsName);\n  pRoot->xDlClose(pRoot, pHandle);\n}\n\n/*\n** Populate the buffer pointed to by zBufOut with nByte bytes of \n** random data.\n*/\nstatic int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  vfstrace_printf(pInfo, \"%s.xRandomness(%d)\\n\", pInfo->zVfsName, nByte);\n  return pRoot->xRandomness(pRoot, nByte, zBufOut);\n}\n\n/*\n** Sleep for nMicro microseconds. Return the number of microseconds \n** actually slept.\n*/\nstatic int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xSleep(pRoot, nMicro);\n}\n\n/*\n** Return the current time as a Julian Day number in *pTimeOut.\n*/\nstatic int vfstraceCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xCurrentTime(pRoot, pTimeOut);\n}\nstatic int vfstraceCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xCurrentTimeInt64(pRoot, pTimeOut);\n}\n\n/*\n** Return th3 emost recent error code and message\n*/\nstatic int vfstraceGetLastError(sqlite3_vfs *pVfs, int iErr, char *zErr){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xGetLastError(pRoot, iErr, zErr);\n}\n\n/*\n** Override system calls.\n*/\nstatic int vfstraceSetSystemCall(\n  sqlite3_vfs *pVfs,\n  const char *zName,\n  sqlite3_syscall_ptr pFunc\n){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xSetSystemCall(pRoot, zName, pFunc);\n}\nstatic sqlite3_syscall_ptr vfstraceGetSystemCall(\n  sqlite3_vfs *pVfs,\n  const char *zName\n){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xGetSystemCall(pRoot, zName);\n}\nstatic const char *vfstraceNextSystemCall(sqlite3_vfs *pVfs, const char *zName){\n  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;\n  sqlite3_vfs *pRoot = pInfo->pRootVfs;\n  return pRoot->xNextSystemCall(pRoot, zName);\n}\n\n\n/*\n** Clients invoke this routine to construct a new trace-vfs shim.\n**\n** Return SQLITE_OK on success.  \n**\n** SQLITE_NOMEM is returned in the case of a memory allocation error.\n** SQLITE_NOTFOUND is returned if zOldVfsName does not exist.\n*/\nint vfstrace_register(\n   const char *zTraceName,           /* Name of the newly constructed VFS */\n   const char *zOldVfsName,          /* Name of the underlying VFS */\n   int (*xOut)(const char*,void*),   /* Output routine.  ex: fputs */\n   void *pOutArg,                    /* 2nd argument to xOut.  ex: stderr */\n   int makeDefault                   /* True to make the new VFS the default */\n){\n  sqlite3_vfs *pNew;\n  sqlite3_vfs *pRoot;\n  vfstrace_info *pInfo;\n  int nName;\n  int nByte;\n\n  pRoot = sqlite3_vfs_find(zOldVfsName);\n  if( pRoot==0 ) return SQLITE_NOTFOUND;\n  nName = strlen(zTraceName);\n  nByte = sizeof(*pNew) + sizeof(*pInfo) + nName + 1;\n  pNew = sqlite3_malloc( nByte );\n  if( pNew==0 ) return SQLITE_NOMEM;\n  memset(pNew, 0, nByte);\n  pInfo = (vfstrace_info*)&pNew[1];\n  pNew->iVersion = pRoot->iVersion;\n  pNew->szOsFile = pRoot->szOsFile + sizeof(vfstrace_file);\n  pNew->mxPathname = pRoot->mxPathname;\n  pNew->zName = (char*)&pInfo[1];\n  memcpy((char*)&pInfo[1], zTraceName, nName+1);\n  pNew->pAppData = pInfo;\n  pNew->xOpen = vfstraceOpen;\n  pNew->xDelete = vfstraceDelete;\n  pNew->xAccess = vfstraceAccess;\n  pNew->xFullPathname = vfstraceFullPathname;\n  pNew->xDlOpen = pRoot->xDlOpen==0 ? 0 : vfstraceDlOpen;\n  pNew->xDlError = pRoot->xDlError==0 ? 0 : vfstraceDlError;\n  pNew->xDlSym = pRoot->xDlSym==0 ? 0 : vfstraceDlSym;\n  pNew->xDlClose = pRoot->xDlClose==0 ? 0 : vfstraceDlClose;\n  pNew->xRandomness = vfstraceRandomness;\n  pNew->xSleep = vfstraceSleep;\n  pNew->xCurrentTime = vfstraceCurrentTime;\n  pNew->xGetLastError = pRoot->xGetLastError==0 ? 0 : vfstraceGetLastError;\n  if( pNew->iVersion>=2 ){\n    pNew->xCurrentTimeInt64 = pRoot->xCurrentTimeInt64==0 ? 0 :\n                                   vfstraceCurrentTimeInt64;\n    if( pNew->iVersion>=3 ){\n      pNew->xSetSystemCall = pRoot->xSetSystemCall==0 ? 0 : \n                                   vfstraceSetSystemCall;\n      pNew->xGetSystemCall = pRoot->xGetSystemCall==0 ? 0 : \n                                   vfstraceGetSystemCall;\n      pNew->xNextSystemCall = pRoot->xNextSystemCall==0 ? 0 : \n                                   vfstraceNextSystemCall;\n    }\n  }\n  pInfo->pRootVfs = pRoot;\n  pInfo->xOut = xOut;\n  pInfo->pOutArg = pOutArg;\n  pInfo->zVfsName = pNew->zName;\n  pInfo->pTraceVfs = pNew;\n  vfstrace_printf(pInfo, \"%s.enabled_for(\\\"%s\\\")\\n\",\n       pInfo->zVfsName, pRoot->zName);\n  return sqlite3_vfs_register(pNew, makeDefault);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_windirent.c",
    "content": "/*\n** 2015 November 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code to implement most of the opendir() family of\n** POSIX functions on Win32 using the MSVCRT.\n*/\n\n#if defined(_WIN32) && defined(_MSC_VER)\n\n#include \"test_windirent.h\"\n\n/*\n** Implementation of the POSIX getenv() function using the Win32 API.\n** This function is not thread-safe.\n*/\nconst char *windirent_getenv(\n  const char *name\n){\n  static char value[32768]; /* Maximum length, per MSDN */\n  DWORD dwSize = sizeof(value) / sizeof(char); /* Size in chars */\n  DWORD dwRet; /* Value returned by GetEnvironmentVariableA() */\n\n  memset(value, 0, sizeof(value));\n  dwRet = GetEnvironmentVariableA(name, value, dwSize);\n  if( dwRet==0 || dwRet>dwSize ){\n    /*\n    ** The function call to GetEnvironmentVariableA() failed -OR-\n    ** the buffer is not large enough.  Either way, return NULL.\n    */\n    return 0;\n  }else{\n    /*\n    ** The function call to GetEnvironmentVariableA() succeeded\n    ** -AND- the buffer contains the entire value.\n    */\n    return value;\n  }\n}\n\n/*\n** Implementation of the POSIX opendir() function using the MSVCRT.\n*/\nLPDIR opendir(\n  const char *dirname\n){\n  struct _finddata_t data;\n  LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));\n  SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);\n\n  if( dirp==NULL ) return NULL;\n  memset(dirp, 0, sizeof(DIR));\n\n  /* TODO: Remove this if Unix-style root paths are not used. */\n  if( sqlite3_stricmp(dirname, \"/\")==0 ){\n    dirname = windirent_getenv(\"SystemDrive\");\n  }\n\n  memset(&data, 0, sizeof(struct _finddata_t));\n  _snprintf(data.name, namesize, \"%s\\\\*\", dirname);\n  dirp->d_handle = _findfirst(data.name, &data);\n\n  if( dirp->d_handle==BAD_INTPTR_T ){\n    closedir(dirp);\n    return NULL;\n  }\n\n  /* TODO: Remove this block to allow hidden and/or system files. */\n  if( is_filtered(data) ){\nnext:\n\n    memset(&data, 0, sizeof(struct _finddata_t));\n    if( _findnext(dirp->d_handle, &data)==-1 ){\n      closedir(dirp);\n      return NULL;\n    }\n\n    /* TODO: Remove this block to allow hidden and/or system files. */\n    if( is_filtered(data) ) goto next;\n  }\n\n  dirp->d_first.d_attributes = data.attrib;\n  strncpy(dirp->d_first.d_name, data.name, NAME_MAX);\n  dirp->d_first.d_name[NAME_MAX] = '\\0';\n\n  return dirp;\n}\n\n/*\n** Implementation of the POSIX readdir() function using the MSVCRT.\n*/\nLPDIRENT readdir(\n  LPDIR dirp\n){\n  struct _finddata_t data;\n\n  if( dirp==NULL ) return NULL;\n\n  if( dirp->d_first.d_ino==0 ){\n    dirp->d_first.d_ino++;\n    dirp->d_next.d_ino++;\n\n    return &dirp->d_first;\n  }\n\nnext:\n\n  memset(&data, 0, sizeof(struct _finddata_t));\n  if( _findnext(dirp->d_handle, &data)==-1 ) return NULL;\n\n  /* TODO: Remove this block to allow hidden and/or system files. */\n  if( is_filtered(data) ) goto next;\n\n  dirp->d_next.d_ino++;\n  dirp->d_next.d_attributes = data.attrib;\n  strncpy(dirp->d_next.d_name, data.name, NAME_MAX);\n  dirp->d_next.d_name[NAME_MAX] = '\\0';\n\n  return &dirp->d_next;\n}\n\n/*\n** Implementation of the POSIX readdir_r() function using the MSVCRT.\n*/\nINT readdir_r(\n  LPDIR dirp,\n  LPDIRENT entry,\n  LPDIRENT *result\n){\n  struct _finddata_t data;\n\n  if( dirp==NULL ) return EBADF;\n\n  if( dirp->d_first.d_ino==0 ){\n    dirp->d_first.d_ino++;\n    dirp->d_next.d_ino++;\n\n    entry->d_ino = dirp->d_first.d_ino;\n    entry->d_attributes = dirp->d_first.d_attributes;\n    strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX);\n    entry->d_name[NAME_MAX] = '\\0';\n\n    *result = entry;\n    return 0;\n  }\n\nnext:\n\n  memset(&data, 0, sizeof(struct _finddata_t));\n  if( _findnext(dirp->d_handle, &data)==-1 ){\n    *result = NULL;\n    return ENOENT;\n  }\n\n  /* TODO: Remove this block to allow hidden and/or system files. */\n  if( is_filtered(data) ) goto next;\n\n  entry->d_ino = (ino_t)-1; /* not available */\n  entry->d_attributes = data.attrib;\n  strncpy(entry->d_name, data.name, NAME_MAX);\n  entry->d_name[NAME_MAX] = '\\0';\n\n  *result = entry;\n  return 0;\n}\n\n/*\n** Implementation of the POSIX closedir() function using the MSVCRT.\n*/\nINT closedir(\n  LPDIR dirp\n){\n  INT result = 0;\n\n  if( dirp==NULL ) return EINVAL;\n\n  if( dirp->d_handle!=NULL_INTPTR_T && dirp->d_handle!=BAD_INTPTR_T ){\n    result = _findclose(dirp->d_handle);\n  }\n\n  sqlite3_free(dirp);\n  return result;\n}\n\n#endif /* defined(WIN32) && defined(_MSC_VER) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_windirent.h",
    "content": "/*\n** 2015 November 30\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains declarations for most of the opendir() family of\n** POSIX functions on Win32 using the MSVCRT.\n*/\n\n#if defined(_WIN32) && defined(_MSC_VER)\n\n/*\n** We need several data types from the Windows SDK header.\n*/\n\n#define WIN32_LEAN_AND_MEAN\n#include \"windows.h\"\n\n/*\n** We need several support functions from the SQLite core.\n*/\n\n#include \"sqlite3.h\"\n\n/*\n** We need several things from the ANSI and MSVCRT headers.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\n#include <io.h>\n#include <limits.h>\n\n/*\n** We may need to provide the \"ino_t\" type.\n*/\n\n#ifndef INO_T_DEFINED\n  #define INO_T_DEFINED\n  typedef unsigned short ino_t;\n#endif\n\n/*\n** We need to define \"NAME_MAX\" if it was not present in \"limits.h\".\n*/\n\n#ifndef NAME_MAX\n#  ifdef FILENAME_MAX\n#    define NAME_MAX (FILENAME_MAX)\n#  else\n#    define NAME_MAX (260)\n#  endif\n#endif\n\n/*\n** We need to define \"NULL_INTPTR_T\" and \"BAD_INTPTR_T\".\n*/\n\n#ifndef NULL_INTPTR_T\n#  define NULL_INTPTR_T ((intptr_t)(0))\n#endif\n\n#ifndef BAD_INTPTR_T\n#  define BAD_INTPTR_T ((intptr_t)(-1))\n#endif\n\n/*\n** We need to provide the necessary structures and related types.\n*/\n\ntypedef struct DIRENT DIRENT;\ntypedef struct DIR DIR;\ntypedef DIRENT *LPDIRENT;\ntypedef DIR *LPDIR;\n\nstruct DIRENT {\n  ino_t d_ino;               /* Sequence number, do not use. */\n  unsigned d_attributes;     /* Win32 file attributes. */\n  char d_name[NAME_MAX + 1]; /* Name within the directory. */\n};\n\nstruct DIR {\n  intptr_t d_handle; /* Value returned by \"_findfirst\". */\n  DIRENT d_first;    /* DIRENT constructed based on \"_findfirst\". */\n  DIRENT d_next;     /* DIRENT constructed based on \"_findnext\". */\n};\n\n/*\n** Provide a macro, for use by the implementation, to determine if a\n** particular directory entry should be skipped over when searching for\n** the next directory entry that should be returned by the readdir() or\n** readdir_r() functions.\n*/\n\n#ifndef is_filtered\n#  define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))\n#endif\n\n/*\n** Provide the function prototype for the POSIX compatiable getenv()\n** function.  This function is not thread-safe.\n*/\n\nextern const char *windirent_getenv(const char *name);\n\n/*\n** Finally, we can provide the function prototypes for the opendir(),\n** readdir(), readdir_r(), and closedir() POSIX functions.\n*/\n\nextern LPDIR opendir(const char *dirname);\nextern LPDIRENT readdir(LPDIR dirp);\nextern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);\nextern INT closedir(LPDIR dirp);\n\n#endif /* defined(WIN32) && defined(_MSC_VER) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/test_wsd.c",
    "content": "/*\n** 2008 September 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** The code in this file contains sample implementations of the \n** sqlite3_wsd_init() and sqlite3_wsd_find() functions required if the\n** SQLITE_OMIT_WSD symbol is defined at build time.\n*/\n\n#if defined(SQLITE_OMIT_WSD) && defined(SQLITE_TEST)\n\n#include \"sqliteInt.h\"\n\n#define PLS_HASHSIZE 43\n\ntypedef struct ProcessLocalStorage ProcessLocalStorage;\ntypedef struct ProcessLocalVar ProcessLocalVar;\n\nstruct ProcessLocalStorage {\n  ProcessLocalVar *aData[PLS_HASHSIZE];\n  int nFree;\n  u8 *pFree;\n};\n\nstruct ProcessLocalVar {\n  void *pKey;\n  ProcessLocalVar *pNext;\n};\n\nstatic ProcessLocalStorage *pGlobal = 0;\n\nint sqlite3_wsd_init(int N, int J){\n  if( !pGlobal ){\n    int nMalloc = N + sizeof(ProcessLocalStorage) + J*sizeof(ProcessLocalVar);\n    pGlobal = (ProcessLocalStorage *)malloc(nMalloc);\n    if( pGlobal ){\n      memset(pGlobal, 0, sizeof(ProcessLocalStorage));\n      pGlobal->nFree = nMalloc - sizeof(ProcessLocalStorage);\n      pGlobal->pFree = (u8 *)&pGlobal[1];\n    }\n  }\n\n  return pGlobal ? SQLITE_OK : SQLITE_NOMEM;\n}\n\nvoid *sqlite3_wsd_find(void *K, int L){\n  int i;\n  int iHash = 0;\n  ProcessLocalVar *pVar;\n\n  /* Calculate a hash of K */\n  for(i=0; i<sizeof(void*); i++){\n    iHash = (iHash<<3) + ((unsigned char *)&K)[i];\n  }\n  iHash = iHash%PLS_HASHSIZE;\n\n  /* Search the hash table for K. */\n  for(pVar=pGlobal->aData[iHash]; pVar && pVar->pKey!=K; pVar=pVar->pNext);\n\n  /* If no entry for K was found, create and populate a new one. */\n  if( !pVar ){\n    int nByte = ROUND8(sizeof(ProcessLocalVar) + L);\n    assert( pGlobal->nFree>=nByte );\n    pVar = (ProcessLocalVar *)pGlobal->pFree;\n    pVar->pKey = K;\n    pVar->pNext = pGlobal->aData[iHash];\n    pGlobal->aData[iHash] = pVar;\n    pGlobal->nFree -= nByte;\n    pGlobal->pFree += nByte;\n    memcpy(&pVar[1], K, L);\n  }\n\n  return (void *)&pVar[1];\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/threads.c",
    "content": "/*\n** 2012 July 21\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file presents a simple cross-platform threading interface for\n** use internally by SQLite.\n**\n** A \"thread\" can be created using sqlite3ThreadCreate().  This thread\n** runs independently of its creator until it is joined using\n** sqlite3ThreadJoin(), at which point it terminates.\n**\n** Threads do not have to be real.  It could be that the work of the\n** \"thread\" is done by the main thread at either the sqlite3ThreadCreate()\n** or sqlite3ThreadJoin() call.  This is, in fact, what happens in\n** single threaded systems.  Nothing in SQLite requires multiple threads.\n** This interface exists so that applications that want to take advantage\n** of multiple cores can do so, while also allowing applications to stay\n** single-threaded if desired.\n*/\n#include \"sqliteInt.h\"\n#if SQLITE_OS_WIN\n#  include \"os_win.h\"\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n\n/********************************* Unix Pthreads ****************************/\n#if SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) && SQLITE_THREADSAFE>0\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n#include <pthread.h>\n\n/* A running thread */\nstruct SQLiteThread {\n  pthread_t tid;                 /* Thread ID */\n  int done;                      /* Set to true when thread finishes */\n  void *pOut;                    /* Result returned by the thread */\n  void *(*xTask)(void*);         /* The thread routine */\n  void *pIn;                     /* Argument to the thread */\n};\n\n/* Create a new thread */\nint sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n  int rc;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  /* This routine is never used in single-threaded mode */\n  assert( sqlite3GlobalConfig.bCoreMutex!=0 );\n\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  memset(p, 0, sizeof(*p));\n  p->xTask = xTask;\n  p->pIn = pIn;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** for testing purposes. */\n  if( sqlite3FaultSim(200) ){\n    rc = 1;\n  }else{    \n    rc = pthread_create(&p->tid, 0, xTask, pIn);\n  }\n  if( rc ){\n    p->done = 1;\n    p->pOut = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nint sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  int rc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->done ){\n    *ppOut = p->pOut;\n    rc = SQLITE_OK;\n  }else{\n    rc = pthread_join(p->tid, ppOut) ? SQLITE_ERROR : SQLITE_OK;\n  }\n  sqlite3_free(p);\n  return rc;\n}\n\n#endif /* SQLITE_OS_UNIX && defined(SQLITE_MUTEX_PTHREADS) */\n/******************************** End Unix Pthreads *************************/\n\n\n/********************************* Win32 Threads ****************************/\n#if SQLITE_OS_WIN_THREADS\n\n#define SQLITE_THREADS_IMPLEMENTED 1  /* Prevent the single-thread code below */\n#include <process.h>\n\n/* A running thread */\nstruct SQLiteThread {\n  void *tid;               /* The thread handle */\n  unsigned id;             /* The thread identifier */\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Thread procedure Win32 compatibility shim */\nstatic unsigned __stdcall sqlite3ThreadProc(\n  void *pArg  /* IN: Pointer to the SQLiteThread structure */\n){\n  SQLiteThread *p = (SQLiteThread *)pArg;\n\n  assert( p!=0 );\n#if 0\n  /*\n  ** This assert appears to trigger spuriously on certain\n  ** versions of Windows, possibly due to _beginthreadex()\n  ** and/or CreateThread() not fully setting their thread\n  ** ID parameter before starting the thread.\n  */\n  assert( p->id==GetCurrentThreadId() );\n#endif\n  assert( p->xTask!=0 );\n  p->pResult = p->xTask(p->pIn);\n\n  _endthreadex(0);\n  return 0; /* NOT REACHED */\n}\n\n/* Create a new thread */\nint sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  /* If the SQLITE_TESTCTRL_FAULT_INSTALL callback is registered to a \n  ** function that returns SQLITE_ERROR when passed the argument 200, that\n  ** forces worker threads to run sequentially and deterministically \n  ** (via the sqlite3FaultSim() term of the conditional) for testing\n  ** purposes. */\n  if( sqlite3GlobalConfig.bCoreMutex==0 || sqlite3FaultSim(200) ){\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->xTask = xTask;\n    p->pIn = pIn;\n    p->tid = (void*)_beginthreadex(0, 0, sqlite3ThreadProc, p, 0, &p->id);\n    if( p->tid==0 ){\n      memset(p, 0, sizeof(*p));\n    }\n  }\n  if( p->xTask==0 ){\n    p->id = GetCurrentThreadId();\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\nDWORD sqlite3Win32Wait(HANDLE hObject); /* os_win.c */\n\n/* Get the results of the thread */\nint sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n  DWORD rc;\n  BOOL bRc;\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask==0 ){\n    /* assert( p->id==GetCurrentThreadId() ); */\n    rc = WAIT_OBJECT_0;\n    assert( p->tid==0 );\n  }else{\n    assert( p->id!=0 && p->id!=GetCurrentThreadId() );\n    rc = sqlite3Win32Wait((HANDLE)p->tid);\n    assert( rc!=WAIT_IO_COMPLETION );\n    bRc = CloseHandle((HANDLE)p->tid);\n    assert( bRc );\n  }\n  if( rc==WAIT_OBJECT_0 ) *ppOut = p->pResult;\n  sqlite3_free(p);\n  return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;\n}\n\n#endif /* SQLITE_OS_WIN_THREADS */\n/******************************** End Win32 Threads *************************/\n\n\n/********************************* Single-Threaded **************************/\n#ifndef SQLITE_THREADS_IMPLEMENTED\n/*\n** This implementation does not actually create a new thread.  It does the\n** work of the thread in the main thread, when either the thread is created\n** or when it is joined\n*/\n\n/* A running thread */\nstruct SQLiteThread {\n  void *(*xTask)(void*);   /* The routine to run as a thread */\n  void *pIn;               /* Argument to xTask */\n  void *pResult;           /* Result of xTask */\n};\n\n/* Create a new thread */\nint sqlite3ThreadCreate(\n  SQLiteThread **ppThread,  /* OUT: Write the thread object here */\n  void *(*xTask)(void*),    /* Routine to run in a separate thread */\n  void *pIn                 /* Argument passed into xTask() */\n){\n  SQLiteThread *p;\n\n  assert( ppThread!=0 );\n  assert( xTask!=0 );\n  *ppThread = 0;\n  p = sqlite3Malloc(sizeof(*p));\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  if( (SQLITE_PTR_TO_INT(p)/17)&1 ){\n    p->xTask = xTask;\n    p->pIn = pIn;\n  }else{\n    p->xTask = 0;\n    p->pResult = xTask(pIn);\n  }\n  *ppThread = p;\n  return SQLITE_OK;\n}\n\n/* Get the results of the thread */\nint sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){\n\n  assert( ppOut!=0 );\n  if( NEVER(p==0) ) return SQLITE_NOMEM_BKPT;\n  if( p->xTask ){\n    *ppOut = p->xTask(p->pIn);\n  }else{\n    *ppOut = p->pResult;\n  }\n  sqlite3_free(p);\n\n#if defined(SQLITE_TEST)\n  {\n    void *pTstAlloc = sqlite3Malloc(10);\n    if (!pTstAlloc) return SQLITE_NOMEM_BKPT;\n    sqlite3_free(pTstAlloc);\n  }\n#endif\n\n  return SQLITE_OK;\n}\n\n#endif /* !defined(SQLITE_THREADS_IMPLEMENTED) */\n/****************************** End Single-Threaded *************************/\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/tokenize.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** An tokenizer for SQL\n**\n** This file contains C code that splits an SQL input string up into\n** individual tokens and sends those tokens one-by-one over to the\n** parser for analysis.\n*/\n#include \"sqliteInt.h\"\n#include <stdlib.h>\n\n/* Character classes for tokenizing\n**\n** In the sqlite3GetToken() function, a switch() on aiClass[c] is implemented\n** using a lookup table, whereas a switch() directly on c uses a binary search.\n** The lookup table is much faster.  To maximize speed, and to ensure that\n** a lookup table is used, all of the classes need to be small integers and\n** all of them need to be used within the switch.\n*/\n#define CC_X          0    /* The letter 'x', or start of BLOB literal */\n#define CC_KYWD       1    /* Alphabetics or '_'.  Usable in a keyword */\n#define CC_ID         2    /* unicode characters usable in IDs */\n#define CC_DIGIT      3    /* Digits */\n#define CC_DOLLAR     4    /* '$' */\n#define CC_VARALPHA   5    /* '@', '#', ':'.  Alphabetic SQL variables */\n#define CC_VARNUM     6    /* '?'.  Numeric SQL variables */\n#define CC_SPACE      7    /* Space characters */\n#define CC_QUOTE      8    /* '\"', '\\'', or '`'.  String literals, quoted ids */\n#define CC_QUOTE2     9    /* '['.   [...] style quoted ids */\n#define CC_PIPE      10    /* '|'.   Bitwise OR or concatenate */\n#define CC_MINUS     11    /* '-'.  Minus or SQL-style comment */\n#define CC_LT        12    /* '<'.  Part of < or <= or <> */\n#define CC_GT        13    /* '>'.  Part of > or >= */\n#define CC_EQ        14    /* '='.  Part of = or == */\n#define CC_BANG      15    /* '!'.  Part of != */\n#define CC_SLASH     16    /* '/'.  / or c-style comment */\n#define CC_LP        17    /* '(' */\n#define CC_RP        18    /* ')' */\n#define CC_SEMI      19    /* ';' */\n#define CC_PLUS      20    /* '+' */\n#define CC_STAR      21    /* '*' */\n#define CC_PERCENT   22    /* '%' */\n#define CC_COMMA     23    /* ',' */\n#define CC_AND       24    /* '&' */\n#define CC_TILDA     25    /* '~' */\n#define CC_DOT       26    /* '.' */\n#define CC_ILLEGAL   27    /* Illegal character */\n\nstatic const unsigned char aiClass[] = {\n#ifdef SQLITE_ASCII\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   27, 27, 27, 27, 27, 27, 27, 27, 27,  7,  7, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */    7, 15,  8,  5,  4, 22, 24,  8, 17, 18, 21, 20, 23, 11, 26, 16,\n/* 3x */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  5, 19, 12, 14, 13,  6,\n/* 4x */    5,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 5x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1,  9, 27, 27, 27,  1,\n/* 6x */    8,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,\n/* 7x */    1,  1,  1,  1,  1,  1,  1,  1,  0,  1,  1, 27, 10, 27, 25, 27,\n/* 8x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* 9x */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ax */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Bx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Cx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Dx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Ex */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,\n/* Fx */    2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2\n#endif\n#ifdef SQLITE_EBCDIC\n/*         x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xa  xb  xc  xd  xe  xf */\n/* 0x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27,  7,  7, 27, 27,\n/* 1x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 2x */   27, 27, 27, 27, 27,  7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 3x */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n/* 4x */    7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 12, 17, 20, 10,\n/* 5x */   24, 27, 27, 27, 27, 27, 27, 27, 27, 27, 15,  4, 21, 18, 19, 27,\n/* 6x */   11, 16, 27, 27, 27, 27, 27, 27, 27, 27, 27, 23, 22,  1, 13,  6,\n/* 7x */   27, 27, 27, 27, 27, 27, 27, 27, 27,  8,  5,  5,  5,  8, 14,  8,\n/* 8x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* 9x */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ax */   27, 25,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Bx */   27, 27, 27, 27, 27, 27, 27, 27, 27, 27,  9, 27, 27, 27, 27, 27,\n/* Cx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Dx */   27,  1,  1,  1,  1,  1,  1,  1,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Ex */   27, 27,  1,  1,  1,  1,  1,  0,  1,  1, 27, 27, 27, 27, 27, 27,\n/* Fx */    3,  3,  3,  3,  3,  3,  3,  3,  3,  3, 27, 27, 27, 27, 27, 27,\n#endif\n};\n\n/*\n** The charMap() macro maps alphabetic characters (only) into their\n** lower-case ASCII equivalent.  On ASCII machines, this is just\n** an upper-to-lower case map.  On EBCDIC machines we also need\n** to adjust the encoding.  The mapping is only valid for alphabetics\n** which are the only characters for which this feature is used. \n**\n** Used by keywordhash.h\n*/\n#ifdef SQLITE_ASCII\n# define charMap(X) sqlite3UpperToLower[(unsigned char)X]\n#endif\n#ifdef SQLITE_EBCDIC\n# define charMap(X) ebcdicToAscii[(unsigned char)X]\nconst unsigned char ebcdicToAscii[] = {\n/* 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 0x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 1x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 2x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 3x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 4x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 5x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 95,  0,  0,  /* 6x */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* 7x */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* 8x */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* 9x */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ax */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Bx */\n   0, 97, 98, 99,100,101,102,103,104,105,  0,  0,  0,  0,  0,  0,  /* Cx */\n   0,106,107,108,109,110,111,112,113,114,  0,  0,  0,  0,  0,  0,  /* Dx */\n   0,  0,115,116,117,118,119,120,121,122,  0,  0,  0,  0,  0,  0,  /* Ex */\n   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  /* Fx */\n};\n#endif\n\n/*\n** The sqlite3KeywordCode function looks up an identifier to determine if\n** it is a keyword.  If it is a keyword, the token code of that keyword is \n** returned.  If the input is not a keyword, TK_ID is returned.\n**\n** The implementation of this routine was generated by a program,\n** mkkeywordhash.c, located in the tool subdirectory of the distribution.\n** The output of the mkkeywordhash.c program is written into a file\n** named keywordhash.h and then included into this source file by\n** the #include below.\n*/\n#include \"keywordhash.h\"\n\n\n/*\n** If X is a character that can be used in an identifier then\n** IdChar(X) will be true.  Otherwise it is false.\n**\n** For ASCII, any character with the high-order bit set is\n** allowed in an identifier.  For 7-bit characters, \n** sqlite3IsIdChar[X] must be 1.\n**\n** For EBCDIC, the rules are more complex but have the same\n** end result.\n**\n** Ticket #1066.  the SQL standard does not allow '$' in the\n** middle of identifiers.  But many SQL implementations do. \n** SQLite will allow '$' in identifiers for compatibility.\n** But the feature is undocumented.\n*/\n#ifdef SQLITE_ASCII\n#define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)\n#endif\n#ifdef SQLITE_EBCDIC\nconst char sqlite3IsEbcdicIdChar[] = {\n/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  /* 4x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0,  /* 5x */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0,  /* 6x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,  /* 7x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0,  /* 8x */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0,  /* 9x */\n    1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,  /* Ax */\n    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  /* Bx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Cx */\n    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Dx */\n    0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1,  /* Ex */\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0,  /* Fx */\n};\n#define IdChar(C)  (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))\n#endif\n\n/* Make the IdChar function accessible from ctime.c */\n#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS\nint sqlite3IsIdChar(u8 c){ return IdChar(c); }\n#endif\n\n\n/*\n** Return the length (in bytes) of the token that begins at z[0]. \n** Store the token type in *tokenType before returning.\n*/\nint sqlite3GetToken(const unsigned char *z, int *tokenType){\n  int i, c;\n  switch( aiClass[*z] ){  /* Switch on the character-class of the first byte\n                          ** of the token. See the comment on the CC_ defines\n                          ** above. */\n    case CC_SPACE: {\n      testcase( z[0]==' ' );\n      testcase( z[0]=='\\t' );\n      testcase( z[0]=='\\n' );\n      testcase( z[0]=='\\f' );\n      testcase( z[0]=='\\r' );\n      for(i=1; sqlite3Isspace(z[i]); i++){}\n      *tokenType = TK_SPACE;\n      return i;\n    }\n    case CC_MINUS: {\n      if( z[1]=='-' ){\n        for(i=2; (c=z[i])!=0 && c!='\\n'; i++){}\n        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n        return i;\n      }\n      *tokenType = TK_MINUS;\n      return 1;\n    }\n    case CC_LP: {\n      *tokenType = TK_LP;\n      return 1;\n    }\n    case CC_RP: {\n      *tokenType = TK_RP;\n      return 1;\n    }\n    case CC_SEMI: {\n      *tokenType = TK_SEMI;\n      return 1;\n    }\n    case CC_PLUS: {\n      *tokenType = TK_PLUS;\n      return 1;\n    }\n    case CC_STAR: {\n      *tokenType = TK_STAR;\n      return 1;\n    }\n    case CC_SLASH: {\n      if( z[1]!='*' || z[2]==0 ){\n        *tokenType = TK_SLASH;\n        return 1;\n      }\n      for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}\n      if( c ) i++;\n      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */\n      return i;\n    }\n    case CC_PERCENT: {\n      *tokenType = TK_REM;\n      return 1;\n    }\n    case CC_EQ: {\n      *tokenType = TK_EQ;\n      return 1 + (z[1]=='=');\n    }\n    case CC_LT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_LE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_NE;\n        return 2;\n      }else if( c=='<' ){\n        *tokenType = TK_LSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_LT;\n        return 1;\n      }\n    }\n    case CC_GT: {\n      if( (c=z[1])=='=' ){\n        *tokenType = TK_GE;\n        return 2;\n      }else if( c=='>' ){\n        *tokenType = TK_RSHIFT;\n        return 2;\n      }else{\n        *tokenType = TK_GT;\n        return 1;\n      }\n    }\n    case CC_BANG: {\n      if( z[1]!='=' ){\n        *tokenType = TK_ILLEGAL;\n        return 1;\n      }else{\n        *tokenType = TK_NE;\n        return 2;\n      }\n    }\n    case CC_PIPE: {\n      if( z[1]!='|' ){\n        *tokenType = TK_BITOR;\n        return 1;\n      }else{\n        *tokenType = TK_CONCAT;\n        return 2;\n      }\n    }\n    case CC_COMMA: {\n      *tokenType = TK_COMMA;\n      return 1;\n    }\n    case CC_AND: {\n      *tokenType = TK_BITAND;\n      return 1;\n    }\n    case CC_TILDA: {\n      *tokenType = TK_BITNOT;\n      return 1;\n    }\n    case CC_QUOTE: {\n      int delim = z[0];\n      testcase( delim=='`' );\n      testcase( delim=='\\'' );\n      testcase( delim=='\"' );\n      for(i=1; (c=z[i])!=0; i++){\n        if( c==delim ){\n          if( z[i+1]==delim ){\n            i++;\n          }else{\n            break;\n          }\n        }\n      }\n      if( c=='\\'' ){\n        *tokenType = TK_STRING;\n        return i+1;\n      }else if( c!=0 ){\n        *tokenType = TK_ID;\n        return i+1;\n      }else{\n        *tokenType = TK_ILLEGAL;\n        return i;\n      }\n    }\n    case CC_DOT: {\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( !sqlite3Isdigit(z[1]) )\n#endif\n      {\n        *tokenType = TK_DOT;\n        return 1;\n      }\n      /* If the next character is a digit, this is a floating point\n      ** number that begins with \".\".  Fall thru into the next case */\n    }\n    case CC_DIGIT: {\n      testcase( z[0]=='0' );  testcase( z[0]=='1' );  testcase( z[0]=='2' );\n      testcase( z[0]=='3' );  testcase( z[0]=='4' );  testcase( z[0]=='5' );\n      testcase( z[0]=='6' );  testcase( z[0]=='7' );  testcase( z[0]=='8' );\n      testcase( z[0]=='9' );\n      *tokenType = TK_INTEGER;\n#ifndef SQLITE_OMIT_HEX_INTEGER\n      if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){\n        for(i=3; sqlite3Isxdigit(z[i]); i++){}\n        return i;\n      }\n#endif\n      for(i=0; sqlite3Isdigit(z[i]); i++){}\n#ifndef SQLITE_OMIT_FLOATING_POINT\n      if( z[i]=='.' ){\n        i++;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n      if( (z[i]=='e' || z[i]=='E') &&\n           ( sqlite3Isdigit(z[i+1]) \n            || ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))\n           )\n      ){\n        i += 2;\n        while( sqlite3Isdigit(z[i]) ){ i++; }\n        *tokenType = TK_FLOAT;\n      }\n#endif\n      while( IdChar(z[i]) ){\n        *tokenType = TK_ILLEGAL;\n        i++;\n      }\n      return i;\n    }\n    case CC_QUOTE2: {\n      for(i=1, c=z[0]; c!=']' && (c=z[i])!=0; i++){}\n      *tokenType = c==']' ? TK_ID : TK_ILLEGAL;\n      return i;\n    }\n    case CC_VARNUM: {\n      *tokenType = TK_VARIABLE;\n      for(i=1; sqlite3Isdigit(z[i]); i++){}\n      return i;\n    }\n    case CC_DOLLAR:\n    case CC_VARALPHA: {\n      int n = 0;\n      testcase( z[0]=='$' );  testcase( z[0]=='@' );\n      testcase( z[0]==':' );  testcase( z[0]=='#' );\n      *tokenType = TK_VARIABLE;\n      for(i=1; (c=z[i])!=0; i++){\n        if( IdChar(c) ){\n          n++;\n#ifndef SQLITE_OMIT_TCL_VARIABLE\n        }else if( c=='(' && n>0 ){\n          do{\n            i++;\n          }while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );\n          if( c==')' ){\n            i++;\n          }else{\n            *tokenType = TK_ILLEGAL;\n          }\n          break;\n        }else if( c==':' && z[i+1]==':' ){\n          i++;\n#endif\n        }else{\n          break;\n        }\n      }\n      if( n==0 ) *tokenType = TK_ILLEGAL;\n      return i;\n    }\n    case CC_KYWD: {\n      for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}\n      if( IdChar(z[i]) ){\n        /* This token started out using characters that can appear in keywords,\n        ** but z[i] is a character not allowed within keywords, so this must\n        ** be an identifier instead */\n        i++;\n        break;\n      }\n      *tokenType = TK_ID;\n      return keywordCode((char*)z, i, tokenType);\n    }\n    case CC_X: {\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n      testcase( z[0]=='x' ); testcase( z[0]=='X' );\n      if( z[1]=='\\'' ){\n        *tokenType = TK_BLOB;\n        for(i=2; sqlite3Isxdigit(z[i]); i++){}\n        if( z[i]!='\\'' || i%2 ){\n          *tokenType = TK_ILLEGAL;\n          while( z[i] && z[i]!='\\'' ){ i++; }\n        }\n        if( z[i] ) i++;\n        return i;\n      }\n#endif\n      /* If it is not a BLOB literal, then it must be an ID, since no\n      ** SQL keywords start with the letter 'x'.  Fall through */\n    }\n    case CC_ID: {\n      i = 1;\n      break;\n    }\n    default: {\n      *tokenType = TK_ILLEGAL;\n      return 1;\n    }\n  }\n  while( IdChar(z[i]) ){ i++; }\n  *tokenType = TK_ID;\n  return i;\n}\n\n/*\n** Run the parser on the given SQL string.  The parser structure is\n** passed in.  An SQLITE_ status code is returned.  If an error occurs\n** then an and attempt is made to write an error message into \n** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that\n** error message.\n*/\nint sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){\n  int nErr = 0;                   /* Number of errors encountered */\n  void *pEngine;                  /* The LEMON-generated LALR(1) parser */\n  int n = 0;                      /* Length of the next token token */\n  int tokenType;                  /* type of the next token */\n  int lastTokenParsed = -1;       /* type of the previous token */\n  sqlite3 *db = pParse->db;       /* The database connection */\n  int mxSqlLen;                   /* Max length of an SQL string */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  yyParser sEngine;    /* Space to hold the Lemon-generated Parser object */\n#endif\n\n  assert( zSql!=0 );\n  mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];\n  if( db->nVdbeActive==0 ){\n    db->u1.isInterrupted = 0;\n  }\n  pParse->rc = SQLITE_OK;\n  pParse->zTail = zSql;\n  assert( pzErrMsg!=0 );\n  /* sqlite3ParserTrace(stdout, \"parser: \"); */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  pEngine = &sEngine;\n  sqlite3ParserInit(pEngine);\n#else\n  pEngine = sqlite3ParserAlloc(sqlite3Malloc);\n  if( pEngine==0 ){\n    sqlite3OomFault(db);\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n  assert( pParse->pNewTable==0 );\n  assert( pParse->pNewTrigger==0 );\n  assert( pParse->nVar==0 );\n  assert( pParse->pVList==0 );\n  while( 1 ){\n    if( zSql[0]!=0 ){\n      n = sqlite3GetToken((u8*)zSql, &tokenType);\n      mxSqlLen -= n;\n      if( mxSqlLen<0 ){\n        pParse->rc = SQLITE_TOOBIG;\n        break;\n      }\n    }else{\n      /* Upon reaching the end of input, call the parser two more times\n      ** with tokens TK_SEMI and 0, in that order. */\n      if( lastTokenParsed==TK_SEMI ){\n        tokenType = 0;\n      }else if( lastTokenParsed==0 ){\n        break;\n      }else{\n        tokenType = TK_SEMI;\n      }\n      zSql -= n;\n    }\n    if( tokenType>=TK_SPACE ){\n      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL );\n      if( db->u1.isInterrupted ){\n        pParse->rc = SQLITE_INTERRUPT;\n        break;\n      }\n      if( tokenType==TK_ILLEGAL ){\n        sqlite3ErrorMsg(pParse, \"unrecognized token: \\\"%.*s\\\"\", n, zSql);\n        break;\n      }\n      zSql += n;\n    }else{\n      pParse->sLastToken.z = zSql;\n      pParse->sLastToken.n = n;\n      sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse);\n      lastTokenParsed = tokenType;\n      zSql += n;\n      if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break;\n    }\n  }\n  assert( nErr==0 );\n  pParse->zTail = zSql;\n#ifdef YYTRACKMAXSTACKDEPTH\n  sqlite3_mutex_enter(sqlite3MallocMutex());\n  sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK,\n      sqlite3ParserStackPeak(pEngine)\n  );\n  sqlite3_mutex_leave(sqlite3MallocMutex());\n#endif /* YYDEBUG */\n#ifdef sqlite3Parser_ENGINEALWAYSONSTACK\n  sqlite3ParserFinalize(pEngine);\n#else\n  sqlite3ParserFree(pEngine, sqlite3_free);\n#endif\n  if( db->mallocFailed ){\n    pParse->rc = SQLITE_NOMEM_BKPT;\n  }\n  if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){\n    pParse->zErrMsg = sqlite3MPrintf(db, \"%s\", sqlite3ErrStr(pParse->rc));\n  }\n  assert( pzErrMsg!=0 );\n  if( pParse->zErrMsg ){\n    *pzErrMsg = pParse->zErrMsg;\n    sqlite3_log(pParse->rc, \"%s\", *pzErrMsg);\n    pParse->zErrMsg = 0;\n    nErr++;\n  }\n  if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){\n    sqlite3VdbeDelete(pParse->pVdbe);\n    pParse->pVdbe = 0;\n  }\n#ifndef SQLITE_OMIT_SHARED_CACHE\n  if( pParse->nested==0 ){\n    sqlite3DbFree(db, pParse->aTableLock);\n    pParse->aTableLock = 0;\n    pParse->nTableLock = 0;\n  }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  sqlite3_free(pParse->apVtabLock);\n#endif\n\n  if( !IN_DECLARE_VTAB ){\n    /* If the pParse->declareVtab flag is set, do not delete any table \n    ** structure built up in pParse->pNewTable. The calling code (see vtab.c)\n    ** will take responsibility for freeing the Table structure.\n    */\n    sqlite3DeleteTable(db, pParse->pNewTable);\n  }\n\n  if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree);\n  sqlite3DeleteTrigger(db, pParse->pNewTrigger);\n  sqlite3DbFree(db, pParse->pVList);\n  while( pParse->pAinc ){\n    AutoincInfo *p = pParse->pAinc;\n    pParse->pAinc = p->pNext;\n    sqlite3DbFreeNN(db, p);\n  }\n  while( pParse->pZombieTab ){\n    Table *p = pParse->pZombieTab;\n    pParse->pZombieTab = p->pNextZombie;\n    sqlite3DeleteTable(db, p);\n  }\n  assert( nErr==0 || pParse->rc!=SQLITE_OK );\n  return nErr;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/treeview.c",
    "content": "/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains C code to implement the TreeView debugging routines.\n** These routines print a parse tree to standard output for debugging and\n** analysis. \n**\n** The interfaces in this file is only available when compiling\n** with SQLITE_DEBUG.\n*/\n#include \"sqliteInt.h\"\n#ifdef SQLITE_DEBUG\n\n/*\n** Add a new subitem to the tree.  The moreToFollow flag indicates that this\n** is not the last item in the tree.\n*/\nstatic TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){\n  if( p==0 ){\n    p = sqlite3_malloc64( sizeof(*p) );\n    if( p==0 ) return 0;\n    memset(p, 0, sizeof(*p));\n  }else{\n    p->iLevel++;\n  }\n  assert( moreToFollow==0 || moreToFollow==1 );\n  if( p->iLevel<sizeof(p->bLine) ) p->bLine[p->iLevel] = moreToFollow;\n  return p;\n}\n\n/*\n** Finished with one layer of the tree\n*/\nstatic void sqlite3TreeViewPop(TreeView *p){\n  if( p==0 ) return;\n  p->iLevel--;\n  if( p->iLevel<0 ) sqlite3_free(p);\n}\n\n/*\n** Generate a single line of output for the tree, with a prefix that contains\n** all the appropriate tree lines\n*/\nstatic void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){\n  va_list ap;\n  int i;\n  StrAccum acc;\n  char zBuf[500];\n  sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);\n  if( p ){\n    for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){\n      sqlite3StrAccumAppend(&acc, p->bLine[i] ? \"|   \" : \"    \", 4);\n    }\n    sqlite3StrAccumAppend(&acc, p->bLine[i] ? \"|-- \" : \"'-- \", 4);\n  }\n  va_start(ap, zFormat);\n  sqlite3VXPrintf(&acc, zFormat, ap);\n  va_end(ap);\n  assert( acc.nChar>0 );\n  if( zBuf[acc.nChar-1]!='\\n' ) sqlite3StrAccumAppend(&acc, \"\\n\", 1);\n  sqlite3StrAccumFinish(&acc);\n  fprintf(stdout,\"%s\", zBuf);\n  fflush(stdout);\n}\n\n/*\n** Shorthand for starting a new tree item that consists of a single label\n*/\nstatic void sqlite3TreeViewItem(TreeView *p, const char *zLabel,u8 moreFollows){\n  p = sqlite3TreeViewPush(p, moreFollows);\n  sqlite3TreeViewLine(p, \"%s\", zLabel);\n}\n\n/*\n** Generate a human-readable description of a WITH clause.\n*/\nvoid sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 moreToFollow){\n  int i;\n  if( pWith==0 ) return;\n  if( pWith->nCte==0 ) return;\n  if( pWith->pOuter ){\n    sqlite3TreeViewLine(pView, \"WITH (0x%p, pOuter=0x%p)\",pWith,pWith->pOuter);\n  }else{\n    sqlite3TreeViewLine(pView, \"WITH (0x%p)\", pWith);\n  }\n  if( pWith->nCte>0 ){\n    pView = sqlite3TreeViewPush(pView, 1);\n    for(i=0; i<pWith->nCte; i++){\n      StrAccum x;\n      char zLine[1000];\n      const struct Cte *pCte = &pWith->a[i];\n      sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n      sqlite3XPrintf(&x, \"%s\", pCte->zName);\n      if( pCte->pCols && pCte->pCols->nExpr>0 ){\n        char cSep = '(';\n        int j;\n        for(j=0; j<pCte->pCols->nExpr; j++){\n          sqlite3XPrintf(&x, \"%c%s\", cSep, pCte->pCols->a[j].zName);\n          cSep = ',';\n        }\n        sqlite3XPrintf(&x, \")\");\n      }\n      sqlite3XPrintf(&x, \" AS\");\n      sqlite3StrAccumFinish(&x);\n      sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1);\n      sqlite3TreeViewSelect(pView, pCte->pSelect, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    sqlite3TreeViewPop(pView);\n  }\n}\n\n\n/*\n** Generate a human-readable description of a Select object.\n*/\nvoid sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){\n  int n = 0;\n  int cnt = 0;\n  if( p==0 ){\n    sqlite3TreeViewLine(pView, \"nil-SELECT\");\n    return;\n  } \n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( p->pWith ){\n    sqlite3TreeViewWith(pView, p->pWith, 1);\n    cnt = 1;\n    sqlite3TreeViewPush(pView, 1);\n  }\n  do{\n    sqlite3TreeViewLine(pView, \"SELECT%s%s (0x%p) selFlags=0x%x nSelectRow=%d\",\n      ((p->selFlags & SF_Distinct) ? \" DISTINCT\" : \"\"),\n      ((p->selFlags & SF_Aggregate) ? \" agg_flag\" : \"\"), p, p->selFlags,\n      (int)p->nSelectRow\n    );\n    if( cnt++ ) sqlite3TreeViewPop(pView);\n    if( p->pPrior ){\n      n = 1000;\n    }else{\n      n = 0;\n      if( p->pSrc && p->pSrc->nSrc ) n++;\n      if( p->pWhere ) n++;\n      if( p->pGroupBy ) n++;\n      if( p->pHaving ) n++;\n      if( p->pOrderBy ) n++;\n      if( p->pLimit ) n++;\n      if( p->pOffset ) n++;\n    }\n    sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, \"result-set\");\n    if( p->pSrc && p->pSrc->nSrc ){\n      int i;\n      pView = sqlite3TreeViewPush(pView, (n--)>0);\n      sqlite3TreeViewLine(pView, \"FROM\");\n      for(i=0; i<p->pSrc->nSrc; i++){\n        struct SrcList_item *pItem = &p->pSrc->a[i];\n        StrAccum x;\n        char zLine[100];\n        sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);\n        sqlite3XPrintf(&x, \"{%d,*}\", pItem->iCursor);\n        if( pItem->zDatabase ){\n          sqlite3XPrintf(&x, \" %s.%s\", pItem->zDatabase, pItem->zName);\n        }else if( pItem->zName ){\n          sqlite3XPrintf(&x, \" %s\", pItem->zName);\n        }\n        if( pItem->pTab ){\n          sqlite3XPrintf(&x, \" tabname=%Q\", pItem->pTab->zName);\n        }\n        if( pItem->zAlias ){\n          sqlite3XPrintf(&x, \" (AS %s)\", pItem->zAlias);\n        }\n        if( pItem->fg.jointype & JT_LEFT ){\n          sqlite3XPrintf(&x, \" LEFT-JOIN\");\n        }\n        sqlite3StrAccumFinish(&x);\n        sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1); \n        if( pItem->pSelect ){\n          sqlite3TreeViewSelect(pView, pItem->pSelect, 0);\n        }\n        if( pItem->fg.isTabFunc ){\n          sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, \"func-args:\");\n        }\n        sqlite3TreeViewPop(pView);\n      }\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pWhere ){\n      sqlite3TreeViewItem(pView, \"WHERE\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pWhere, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pGroupBy ){\n      sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, \"GROUPBY\");\n    }\n    if( p->pHaving ){\n      sqlite3TreeViewItem(pView, \"HAVING\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pHaving, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pOrderBy ){\n      sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, \"ORDERBY\");\n    }\n    if( p->pLimit ){\n      sqlite3TreeViewItem(pView, \"LIMIT\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pLimit, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pOffset ){\n      sqlite3TreeViewItem(pView, \"OFFSET\", (n--)>0);\n      sqlite3TreeViewExpr(pView, p->pOffset, 0);\n      sqlite3TreeViewPop(pView);\n    }\n    if( p->pPrior ){\n      const char *zOp = \"UNION\";\n      switch( p->op ){\n        case TK_ALL:         zOp = \"UNION ALL\";  break;\n        case TK_INTERSECT:   zOp = \"INTERSECT\";  break;\n        case TK_EXCEPT:      zOp = \"EXCEPT\";     break;\n      }\n      sqlite3TreeViewItem(pView, zOp, 1);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  sqlite3TreeViewPop(pView);\n}\n\n/*\n** Generate a human-readable explanation of an expression tree.\n*/\nvoid sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){\n  const char *zBinOp = 0;   /* Binary operator */\n  const char *zUniOp = 0;   /* Unary operator */\n  char zFlgs[60];\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  if( pExpr==0 ){\n    sqlite3TreeViewLine(pView, \"nil\");\n    sqlite3TreeViewPop(pView);\n    return;\n  }\n  if( pExpr->flags ){\n    if( ExprHasProperty(pExpr, EP_FromJoin) ){\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x iRJT=%d\",\n                       pExpr->flags, pExpr->iRightJoinTable);\n    }else{\n      sqlite3_snprintf(sizeof(zFlgs),zFlgs,\"  flags=0x%x\",pExpr->flags);\n    }\n  }else{\n    zFlgs[0] = 0;\n  }\n  switch( pExpr->op ){\n    case TK_AGG_COLUMN: {\n      sqlite3TreeViewLine(pView, \"AGG{%d:%d}%s\",\n            pExpr->iTable, pExpr->iColumn, zFlgs);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iTable<0 ){\n        /* This only happens when coding check constraints */\n        sqlite3TreeViewLine(pView, \"COLUMN(%d)%s\", pExpr->iColumn, zFlgs);\n      }else{\n        sqlite3TreeViewLine(pView, \"{%d:%d}%s\",\n                             pExpr->iTable, pExpr->iColumn, zFlgs);\n      }\n      break;\n    }\n    case TK_INTEGER: {\n      if( pExpr->flags & EP_IntValue ){\n        sqlite3TreeViewLine(pView, \"%d\", pExpr->u.iValue);\n      }else{\n        sqlite3TreeViewLine(pView, \"%s\", pExpr->u.zToken);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n    case TK_FLOAT: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_STRING: {\n      sqlite3TreeViewLine(pView,\"%Q\", pExpr->u.zToken);\n      break;\n    }\n    case TK_NULL: {\n      sqlite3TreeViewLine(pView,\"NULL\");\n      break;\n    }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n    case TK_BLOB: {\n      sqlite3TreeViewLine(pView,\"%s\", pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_VARIABLE: {\n      sqlite3TreeViewLine(pView,\"VARIABLE(%s,%d)\",\n                          pExpr->u.zToken, pExpr->iColumn);\n      break;\n    }\n    case TK_REGISTER: {\n      sqlite3TreeViewLine(pView,\"REGISTER(%d)\", pExpr->iTable);\n      break;\n    }\n    case TK_ID: {\n      sqlite3TreeViewLine(pView,\"ID \\\"%w\\\"\", pExpr->u.zToken);\n      break;\n    }\n#ifndef SQLITE_OMIT_CAST\n    case TK_CAST: {\n      /* Expressions of the form:   CAST(pLeft AS token) */\n      sqlite3TreeViewLine(pView,\"CAST %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n#endif /* SQLITE_OMIT_CAST */\n    case TK_LT:      zBinOp = \"LT\";     break;\n    case TK_LE:      zBinOp = \"LE\";     break;\n    case TK_GT:      zBinOp = \"GT\";     break;\n    case TK_GE:      zBinOp = \"GE\";     break;\n    case TK_NE:      zBinOp = \"NE\";     break;\n    case TK_EQ:      zBinOp = \"EQ\";     break;\n    case TK_IS:      zBinOp = \"IS\";     break;\n    case TK_ISNOT:   zBinOp = \"ISNOT\";  break;\n    case TK_AND:     zBinOp = \"AND\";    break;\n    case TK_OR:      zBinOp = \"OR\";     break;\n    case TK_PLUS:    zBinOp = \"ADD\";    break;\n    case TK_STAR:    zBinOp = \"MUL\";    break;\n    case TK_MINUS:   zBinOp = \"SUB\";    break;\n    case TK_REM:     zBinOp = \"REM\";    break;\n    case TK_BITAND:  zBinOp = \"BITAND\"; break;\n    case TK_BITOR:   zBinOp = \"BITOR\";  break;\n    case TK_SLASH:   zBinOp = \"DIV\";    break;\n    case TK_LSHIFT:  zBinOp = \"LSHIFT\"; break;\n    case TK_RSHIFT:  zBinOp = \"RSHIFT\"; break;\n    case TK_CONCAT:  zBinOp = \"CONCAT\"; break;\n    case TK_DOT:     zBinOp = \"DOT\";    break;\n\n    case TK_UMINUS:  zUniOp = \"UMINUS\"; break;\n    case TK_UPLUS:   zUniOp = \"UPLUS\";  break;\n    case TK_BITNOT:  zUniOp = \"BITNOT\"; break;\n    case TK_NOT:     zUniOp = \"NOT\";    break;\n    case TK_ISNULL:  zUniOp = \"ISNULL\"; break;\n    case TK_NOTNULL: zUniOp = \"NOTNULL\"; break;\n\n    case TK_SPAN: {\n      sqlite3TreeViewLine(pView, \"SPAN %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_COLLATE: {\n      sqlite3TreeViewLine(pView, \"COLLATE %Q\", pExpr->u.zToken);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n\n    case TK_AGG_FUNCTION:\n    case TK_FUNCTION: {\n      ExprList *pFarg;       /* List of function arguments */\n      if( ExprHasProperty(pExpr, EP_TokenOnly) ){\n        pFarg = 0;\n      }else{\n        pFarg = pExpr->x.pList;\n      }\n      if( pExpr->op==TK_AGG_FUNCTION ){\n        sqlite3TreeViewLine(pView, \"AGG_FUNCTION%d %Q\",\n                             pExpr->op2, pExpr->u.zToken);\n      }else{\n        sqlite3TreeViewLine(pView, \"FUNCTION %Q\", pExpr->u.zToken);\n      }\n      if( pFarg ){\n        sqlite3TreeViewExprList(pView, pFarg, 0, 0);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_SUBQUERY\n    case TK_EXISTS: {\n      sqlite3TreeViewLine(pView, \"EXISTS-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_SELECT: {\n      sqlite3TreeViewLine(pView, \"SELECT-expr flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      break;\n    }\n    case TK_IN: {\n      sqlite3TreeViewLine(pView, \"IN flags=0x%x\", pExpr->flags);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0);\n      }else{\n        sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      }\n      break;\n    }\n#endif /* SQLITE_OMIT_SUBQUERY */\n\n    /*\n    **    x BETWEEN y AND z\n    **\n    ** This is equivalent to\n    **\n    **    x>=y AND x<=z\n    **\n    ** X is stored in pExpr->pLeft.\n    ** Y is stored in pExpr->pList->a[0].pExpr.\n    ** Z is stored in pExpr->pList->a[1].pExpr.\n    */\n    case TK_BETWEEN: {\n      Expr *pX = pExpr->pLeft;\n      Expr *pY = pExpr->x.pList->a[0].pExpr;\n      Expr *pZ = pExpr->x.pList->a[1].pExpr;\n      sqlite3TreeViewLine(pView, \"BETWEEN\");\n      sqlite3TreeViewExpr(pView, pX, 1);\n      sqlite3TreeViewExpr(pView, pY, 1);\n      sqlite3TreeViewExpr(pView, pZ, 0);\n      break;\n    }\n    case TK_TRIGGER: {\n      /* If the opcode is TK_TRIGGER, then the expression is a reference\n      ** to a column in the new.* or old.* pseudo-tables available to\n      ** trigger programs. In this case Expr.iTable is set to 1 for the\n      ** new.* pseudo-table, or 0 for the old.* pseudo-table. Expr.iColumn\n      ** is set to the column of the pseudo-table to read, or to -1 to\n      ** read the rowid field.\n      */\n      sqlite3TreeViewLine(pView, \"%s(%d)\", \n          pExpr->iTable ? \"NEW\" : \"OLD\", pExpr->iColumn);\n      break;\n    }\n    case TK_CASE: {\n      sqlite3TreeViewLine(pView, \"CASE\");\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n      sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0);\n      break;\n    }\n#ifndef SQLITE_OMIT_TRIGGER\n    case TK_RAISE: {\n      const char *zType = \"unk\";\n      switch( pExpr->affinity ){\n        case OE_Rollback:   zType = \"rollback\";  break;\n        case OE_Abort:      zType = \"abort\";     break;\n        case OE_Fail:       zType = \"fail\";      break;\n        case OE_Ignore:     zType = \"ignore\";    break;\n      }\n      sqlite3TreeViewLine(pView, \"RAISE %s(%Q)\", zType, pExpr->u.zToken);\n      break;\n    }\n#endif\n    case TK_MATCH: {\n      sqlite3TreeViewLine(pView, \"MATCH {%d:%d}%s\",\n                          pExpr->iTable, pExpr->iColumn, zFlgs);\n      sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n      break;\n    }\n    case TK_VECTOR: {\n      sqlite3TreeViewBareExprList(pView, pExpr->x.pList, \"VECTOR\");\n      break;\n    }\n    case TK_SELECT_COLUMN: {\n      sqlite3TreeViewLine(pView, \"SELECT-COLUMN %d\", pExpr->iColumn);\n      sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);\n      break;\n    }\n    case TK_IF_NULL_ROW: {\n      sqlite3TreeViewLine(pView, \"IF-NULL-ROW %d\", pExpr->iTable);\n      sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n      break;\n    }\n    default: {\n      sqlite3TreeViewLine(pView, \"op=%d\", pExpr->op);\n      break;\n    }\n  }\n  if( zBinOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zBinOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 1);\n    sqlite3TreeViewExpr(pView, pExpr->pRight, 0);\n  }else if( zUniOp ){\n    sqlite3TreeViewLine(pView, \"%s%s\", zUniOp, zFlgs);\n    sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);\n  }\n  sqlite3TreeViewPop(pView);\n}\n\n\n/*\n** Generate a human-readable explanation of an expression list.\n*/\nvoid sqlite3TreeViewBareExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  const char *zLabel\n){\n  if( zLabel==0 || zLabel[0]==0 ) zLabel = \"LIST\";\n  if( pList==0 ){\n    sqlite3TreeViewLine(pView, \"%s (empty)\", zLabel);\n  }else{\n    int i;\n    sqlite3TreeViewLine(pView, \"%s\", zLabel);\n    for(i=0; i<pList->nExpr; i++){\n      int j = pList->a[i].u.x.iOrderByCol;\n      if( j ){\n        sqlite3TreeViewPush(pView, 0);\n        sqlite3TreeViewLine(pView, \"iOrderByCol=%d\", j);\n      }\n      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);\n      if( j ) sqlite3TreeViewPop(pView);\n    }\n  }\n}\nvoid sqlite3TreeViewExprList(\n  TreeView *pView,\n  const ExprList *pList,\n  u8 moreToFollow,\n  const char *zLabel\n){\n  pView = sqlite3TreeViewPush(pView, moreToFollow);\n  sqlite3TreeViewBareExprList(pView, pList, zLabel);\n  sqlite3TreeViewPop(pView);\n}\n\n#endif /* SQLITE_DEBUG */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/trigger.c",
    "content": "/*\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains the implementation for TRIGGERs\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_TRIGGER\n/*\n** Delete a linked list of TriggerStep structures.\n*/\nvoid sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){\n  while( pTriggerStep ){\n    TriggerStep * pTmp = pTriggerStep;\n    pTriggerStep = pTriggerStep->pNext;\n\n    sqlite3ExprDelete(db, pTmp->pWhere);\n    sqlite3ExprListDelete(db, pTmp->pExprList);\n    sqlite3SelectDelete(db, pTmp->pSelect);\n    sqlite3IdListDelete(db, pTmp->pIdList);\n\n    sqlite3DbFree(db, pTmp);\n  }\n}\n\n/*\n** Given table pTab, return a list of all the triggers attached to \n** the table. The list is connected by Trigger.pNext pointers.\n**\n** All of the triggers on pTab that are in the same database as pTab\n** are already attached to pTab->pTrigger.  But there might be additional\n** triggers on pTab in the TEMP schema.  This routine prepends all\n** TEMP triggers on pTab to the beginning of the pTab->pTrigger list\n** and returns the combined list.\n**\n** To state it another way:  This routine returns a list of all triggers\n** that fire off of pTab.  The list will include any TEMP triggers on\n** pTab as well as the triggers lised in pTab->pTrigger.\n*/\nTrigger *sqlite3TriggerList(Parse *pParse, Table *pTab){\n  Schema * const pTmpSchema = pParse->db->aDb[1].pSchema;\n  Trigger *pList = 0;                  /* List of triggers to return */\n\n  if( pParse->disableTriggers ){\n    return 0;\n  }\n\n  if( pTmpSchema!=pTab->pSchema ){\n    HashElem *p;\n    assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) );\n    for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){\n      Trigger *pTrig = (Trigger *)sqliteHashData(p);\n      if( pTrig->pTabSchema==pTab->pSchema\n       && 0==sqlite3StrICmp(pTrig->table, pTab->zName) \n      ){\n        pTrig->pNext = (pList ? pList : pTab->pTrigger);\n        pList = pTrig;\n      }\n    }\n  }\n\n  return (pList ? pList : pTab->pTrigger);\n}\n\n/*\n** This is called by the parser when it sees a CREATE TRIGGER statement\n** up to the point of the BEGIN before the trigger actions.  A Trigger\n** structure is generated based on the information available and stored\n** in pParse->pNewTrigger.  After the trigger actions have been parsed, the\n** sqlite3FinishTrigger() function is called to complete the trigger\n** construction process.\n*/\nvoid sqlite3BeginTrigger(\n  Parse *pParse,      /* The parse context of the CREATE TRIGGER statement */\n  Token *pName1,      /* The name of the trigger */\n  Token *pName2,      /* The name of the trigger */\n  int tr_tm,          /* One of TK_BEFORE, TK_AFTER, TK_INSTEAD */\n  int op,             /* One of TK_INSERT, TK_UPDATE, TK_DELETE */\n  IdList *pColumns,   /* column list if this is an UPDATE OF trigger */\n  SrcList *pTableName,/* The name of the table/view the trigger applies to */\n  Expr *pWhen,        /* WHEN clause */\n  int isTemp,         /* True if the TEMPORARY keyword is present */\n  int noErr           /* Suppress errors if the trigger already exists */\n){\n  Trigger *pTrigger = 0;  /* The new trigger */\n  Table *pTab;            /* Table that the trigger fires off of */\n  char *zName = 0;        /* Name of the trigger */\n  sqlite3 *db = pParse->db;  /* The database connection */\n  int iDb;                /* The database to store the trigger in */\n  Token *pName;           /* The unqualified db name */\n  DbFixer sFix;           /* State vector for the DB fixer */\n\n  assert( pName1!=0 );   /* pName1->z might be NULL, but not pName1 itself */\n  assert( pName2!=0 );\n  assert( op==TK_INSERT || op==TK_UPDATE || op==TK_DELETE );\n  assert( op>0 && op<0xff );\n  if( isTemp ){\n    /* If TEMP was specified, then the trigger name may not be qualified. */\n    if( pName2->n>0 ){\n      sqlite3ErrorMsg(pParse, \"temporary trigger may not have qualified name\");\n      goto trigger_cleanup;\n    }\n    iDb = 1;\n    pName = pName1;\n  }else{\n    /* Figure out the db that the trigger will be created in */\n    iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);\n    if( iDb<0 ){\n      goto trigger_cleanup;\n    }\n  }\n  if( !pTableName || db->mallocFailed ){\n    goto trigger_cleanup;\n  }\n\n  /* A long-standing parser bug is that this syntax was allowed:\n  **\n  **    CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....\n  **                                                 ^^^^^^^^\n  **\n  ** To maintain backwards compatibility, ignore the database\n  ** name on pTableName if we are reparsing out of SQLITE_MASTER.\n  */\n  if( db->init.busy && iDb!=1 ){\n    sqlite3DbFree(db, pTableName->a[0].zDatabase);\n    pTableName->a[0].zDatabase = 0;\n  }\n\n  /* If the trigger name was unqualified, and the table is a temp table,\n  ** then set iDb to 1 to create the trigger in the temporary database.\n  ** If sqlite3SrcListLookup() returns 0, indicating the table does not\n  ** exist, the error is caught by the block below.\n  */\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( db->init.busy==0 && pName2->n==0 && pTab\n        && pTab->pSchema==db->aDb[1].pSchema ){\n    iDb = 1;\n  }\n\n  /* Ensure the table name matches database name and that the table exists */\n  if( db->mallocFailed ) goto trigger_cleanup;\n  assert( pTableName->nSrc==1 );\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", pName);\n  if( sqlite3FixSrcList(&sFix, pTableName) ){\n    goto trigger_cleanup;\n  }\n  pTab = sqlite3SrcListLookup(pParse, pTableName);\n  if( !pTab ){\n    /* The table does not exist. */\n    if( db->init.iDb==1 ){\n      /* Ticket #3810.\n      ** Normally, whenever a table is dropped, all associated triggers are\n      ** dropped too.  But if a TEMP trigger is created on a non-TEMP table\n      ** and the table is dropped by a different database connection, the\n      ** trigger is not visible to the database connection that does the\n      ** drop so the trigger cannot be dropped.  This results in an\n      ** \"orphaned trigger\" - a trigger whose associated table is missing.\n      */\n      db->init.orphanTrigger = 1;\n    }\n    goto trigger_cleanup;\n  }\n  if( IsVirtual(pTab) ){\n    sqlite3ErrorMsg(pParse, \"cannot create triggers on virtual tables\");\n    goto trigger_cleanup;\n  }\n\n  /* Check that the trigger name is not reserved and that no trigger of the\n  ** specified name exists */\n  zName = sqlite3NameFromToken(db, pName);\n  if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){\n    goto trigger_cleanup;\n  }\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash),zName) ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"trigger %T already exists\", pName);\n    }else{\n      assert( !db->init.busy );\n      sqlite3CodeVerifySchema(pParse, iDb);\n    }\n    goto trigger_cleanup;\n  }\n\n  /* Do not create a trigger on a system table */\n  if( sqlite3StrNICmp(pTab->zName, \"sqlite_\", 7)==0 ){\n    sqlite3ErrorMsg(pParse, \"cannot create trigger on system table\");\n    goto trigger_cleanup;\n  }\n\n  /* INSTEAD of triggers are only for views and views only support INSTEAD\n  ** of triggers.\n  */\n  if( pTab->pSelect && tr_tm!=TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create %s trigger on view: %S\", \n        (tr_tm == TK_BEFORE)?\"BEFORE\":\"AFTER\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n  if( !pTab->pSelect && tr_tm==TK_INSTEAD ){\n    sqlite3ErrorMsg(pParse, \"cannot create INSTEAD OF\"\n        \" trigger on table: %S\", pTableName, 0);\n    goto trigger_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    int code = SQLITE_CREATE_TRIGGER;\n    const char *zDb = db->aDb[iTabDb].zDbSName;\n    const char *zDbTrig = isTemp ? db->aDb[1].zDbSName : zDb;\n    if( iTabDb==1 || isTemp ) code = SQLITE_CREATE_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, zName, pTab->zName, zDbTrig) ){\n      goto trigger_cleanup;\n    }\n    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iTabDb),0,zDb)){\n      goto trigger_cleanup;\n    }\n  }\n#endif\n\n  /* INSTEAD OF triggers can only appear on views and BEFORE triggers\n  ** cannot appear on views.  So we might as well translate every\n  ** INSTEAD OF trigger into a BEFORE trigger.  It simplifies code\n  ** elsewhere.\n  */\n  if (tr_tm == TK_INSTEAD){\n    tr_tm = TK_BEFORE;\n  }\n\n  /* Build the Trigger object */\n  pTrigger = (Trigger*)sqlite3DbMallocZero(db, sizeof(Trigger));\n  if( pTrigger==0 ) goto trigger_cleanup;\n  pTrigger->zName = zName;\n  zName = 0;\n  pTrigger->table = sqlite3DbStrDup(db, pTableName->a[0].zName);\n  pTrigger->pSchema = db->aDb[iDb].pSchema;\n  pTrigger->pTabSchema = pTab->pSchema;\n  pTrigger->op = (u8)op;\n  pTrigger->tr_tm = tr_tm==TK_BEFORE ? TRIGGER_BEFORE : TRIGGER_AFTER;\n  pTrigger->pWhen = sqlite3ExprDup(db, pWhen, EXPRDUP_REDUCE);\n  pTrigger->pColumns = sqlite3IdListDup(db, pColumns);\n  assert( pParse->pNewTrigger==0 );\n  pParse->pNewTrigger = pTrigger;\n\ntrigger_cleanup:\n  sqlite3DbFree(db, zName);\n  sqlite3SrcListDelete(db, pTableName);\n  sqlite3IdListDelete(db, pColumns);\n  sqlite3ExprDelete(db, pWhen);\n  if( !pParse->pNewTrigger ){\n    sqlite3DeleteTrigger(db, pTrigger);\n  }else{\n    assert( pParse->pNewTrigger==pTrigger );\n  }\n}\n\n/*\n** This routine is called after all of the trigger actions have been parsed\n** in order to complete the process of building the trigger.\n*/\nvoid sqlite3FinishTrigger(\n  Parse *pParse,          /* Parser context */\n  TriggerStep *pStepList, /* The triggered program */\n  Token *pAll             /* Token that describes the complete CREATE TRIGGER */\n){\n  Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */\n  char *zName;                            /* Name of trigger */\n  sqlite3 *db = pParse->db;               /* The database */\n  DbFixer sFix;                           /* Fixer object */\n  int iDb;                                /* Database containing the trigger */\n  Token nameToken;                        /* Trigger name for error reporting */\n\n  pParse->pNewTrigger = 0;\n  if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;\n  zName = pTrig->zName;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);\n  pTrig->step_list = pStepList;\n  while( pStepList ){\n    pStepList->pTrig = pTrig;\n    pStepList = pStepList->pNext;\n  }\n  sqlite3TokenInit(&nameToken, pTrig->zName);\n  sqlite3FixInit(&sFix, pParse, iDb, \"trigger\", &nameToken);\n  if( sqlite3FixTriggerStep(&sFix, pTrig->step_list) \n   || sqlite3FixExpr(&sFix, pTrig->pWhen) \n  ){\n    goto triggerfinish_cleanup;\n  }\n\n  /* if we are not initializing,\n  ** build the sqlite_master entry\n  */\n  if( !db->init.busy ){\n    Vdbe *v;\n    char *z;\n\n    /* Make an entry in the sqlite_master table */\n    v = sqlite3GetVdbe(pParse);\n    if( v==0 ) goto triggerfinish_cleanup;\n    sqlite3BeginWriteOperation(pParse, 0, iDb);\n    z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n);\n    testcase( z==0 );\n    sqlite3NestedParse(pParse,\n       \"INSERT INTO %Q.%s VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, zName,\n       pTrig->table, z);\n    sqlite3DbFree(db, z);\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddParseSchemaOp(v, iDb,\n        sqlite3MPrintf(db, \"type='trigger' AND name='%q'\", zName));\n  }\n\n  if( db->init.busy ){\n    Trigger *pLink = pTrig;\n    Hash *pHash = &db->aDb[iDb].pSchema->trigHash;\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    pTrig = sqlite3HashInsert(pHash, zName, pTrig);\n    if( pTrig ){\n      sqlite3OomFault(db);\n    }else if( pLink->pSchema==pLink->pTabSchema ){\n      Table *pTab;\n      pTab = sqlite3HashFind(&pLink->pTabSchema->tblHash, pLink->table);\n      assert( pTab!=0 );\n      pLink->pNext = pTab->pTrigger;\n      pTab->pTrigger = pLink;\n    }\n  }\n\ntriggerfinish_cleanup:\n  sqlite3DeleteTrigger(db, pTrig);\n  assert( !pParse->pNewTrigger );\n  sqlite3DeleteTriggerStep(db, pStepList);\n}\n\n/*\n** Turn a SELECT statement (that the pSelect parameter points to) into\n** a trigger step.  Return a pointer to a TriggerStep structure.\n**\n** The parser calls this routine when it finds a SELECT statement in\n** body of a TRIGGER.  \n*/\nTriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){\n  TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));\n  if( pTriggerStep==0 ) {\n    sqlite3SelectDelete(db, pSelect);\n    return 0;\n  }\n  pTriggerStep->op = TK_SELECT;\n  pTriggerStep->pSelect = pSelect;\n  pTriggerStep->orconf = OE_Default;\n  return pTriggerStep;\n}\n\n/*\n** Allocate space to hold a new trigger step.  The allocated space\n** holds both the TriggerStep object and the TriggerStep.target.z string.\n**\n** If an OOM error occurs, NULL is returned and db->mallocFailed is set.\n*/\nstatic TriggerStep *triggerStepAllocate(\n  sqlite3 *db,                /* Database connection */\n  u8 op,                      /* Trigger opcode */\n  Token *pName                /* The target name */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);\n  if( pTriggerStep ){\n    char *z = (char*)&pTriggerStep[1];\n    memcpy(z, pName->z, pName->n);\n    sqlite3Dequote(z);\n    pTriggerStep->zTarget = z;\n    pTriggerStep->op = op;\n  }\n  return pTriggerStep;\n}\n\n/*\n** Build a trigger step out of an INSERT statement.  Return a pointer\n** to the new trigger step.\n**\n** The parser calls this routine when it sees an INSERT inside the\n** body of a trigger.\n*/\nTriggerStep *sqlite3TriggerInsertStep(\n  sqlite3 *db,        /* The database connection */\n  Token *pTableName,  /* Name of the table into which we insert */\n  IdList *pColumn,    /* List of columns in pTableName to insert into */\n  Select *pSelect,    /* A SELECT statement that supplies values */\n  u8 orconf           /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */\n){\n  TriggerStep *pTriggerStep;\n\n  assert(pSelect != 0 || db->mallocFailed);\n\n  pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);\n    pTriggerStep->pIdList = pColumn;\n    pTriggerStep->orconf = orconf;\n  }else{\n    sqlite3IdListDelete(db, pColumn);\n  }\n  sqlite3SelectDelete(db, pSelect);\n\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements an UPDATE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees an UPDATE statement inside the body of a CREATE TRIGGER.\n*/\nTriggerStep *sqlite3TriggerUpdateStep(\n  sqlite3 *db,         /* The database connection */\n  Token *pTableName,   /* Name of the table to be updated */\n  ExprList *pEList,    /* The SET clause: list of column and new values */\n  Expr *pWhere,        /* The WHERE clause */\n  u8 orconf            /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = orconf;\n  }\n  sqlite3ExprListDelete(db, pEList);\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/*\n** Construct a trigger step that implements a DELETE statement and return\n** a pointer to that trigger step.  The parser calls this routine when it\n** sees a DELETE statement inside the body of a CREATE TRIGGER.\n*/\nTriggerStep *sqlite3TriggerDeleteStep(\n  sqlite3 *db,            /* Database connection */\n  Token *pTableName,      /* The table from which rows are deleted */\n  Expr *pWhere            /* The WHERE clause */\n){\n  TriggerStep *pTriggerStep;\n\n  pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName);\n  if( pTriggerStep ){\n    pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);\n    pTriggerStep->orconf = OE_Default;\n  }\n  sqlite3ExprDelete(db, pWhere);\n  return pTriggerStep;\n}\n\n/* \n** Recursively delete a Trigger structure\n*/\nvoid sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){\n  if( pTrigger==0 ) return;\n  sqlite3DeleteTriggerStep(db, pTrigger->step_list);\n  sqlite3DbFree(db, pTrigger->zName);\n  sqlite3DbFree(db, pTrigger->table);\n  sqlite3ExprDelete(db, pTrigger->pWhen);\n  sqlite3IdListDelete(db, pTrigger->pColumns);\n  sqlite3DbFree(db, pTrigger);\n}\n\n/*\n** This function is called to drop a trigger from the database schema. \n**\n** This may be called directly from the parser and therefore identifies\n** the trigger by name.  The sqlite3DropTriggerPtr() routine does the\n** same job as this routine except it takes a pointer to the trigger\n** instead of the trigger name.\n**/\nvoid sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){\n  Trigger *pTrigger = 0;\n  int i;\n  const char *zDb;\n  const char *zName;\n  sqlite3 *db = pParse->db;\n\n  if( db->mallocFailed ) goto drop_trigger_cleanup;\n  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){\n    goto drop_trigger_cleanup;\n  }\n\n  assert( pName->nSrc==1 );\n  zDb = pName->a[0].zDatabase;\n  zName = pName->a[0].zName;\n  assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );\n  for(i=OMIT_TEMPDB; i<db->nDb; i++){\n    int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */\n    if( zDb && sqlite3StrICmp(db->aDb[j].zDbSName, zDb) ) continue;\n    assert( sqlite3SchemaMutexHeld(db, j, 0) );\n    pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName);\n    if( pTrigger ) break;\n  }\n  if( !pTrigger ){\n    if( !noErr ){\n      sqlite3ErrorMsg(pParse, \"no such trigger: %S\", pName, 0);\n    }else{\n      sqlite3CodeVerifyNamedSchema(pParse, zDb);\n    }\n    pParse->checkSchema = 1;\n    goto drop_trigger_cleanup;\n  }\n  sqlite3DropTriggerPtr(pParse, pTrigger);\n\ndrop_trigger_cleanup:\n  sqlite3SrcListDelete(db, pName);\n}\n\n/*\n** Return a pointer to the Table structure for the table that a trigger\n** is set on.\n*/\nstatic Table *tableOfTrigger(Trigger *pTrigger){\n  return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table);\n}\n\n\n/*\n** Drop a trigger given a pointer to that trigger. \n*/\nvoid sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){\n  Table   *pTable;\n  Vdbe *v;\n  sqlite3 *db = pParse->db;\n  int iDb;\n\n  iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);\n  assert( iDb>=0 && iDb<db->nDb );\n  pTable = tableOfTrigger(pTrigger);\n  assert( pTable );\n  assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  {\n    int code = SQLITE_DROP_TRIGGER;\n    const char *zDb = db->aDb[iDb].zDbSName;\n    const char *zTab = SCHEMA_TABLE(iDb);\n    if( iDb==1 ) code = SQLITE_DROP_TEMP_TRIGGER;\n    if( sqlite3AuthCheck(pParse, code, pTrigger->zName, pTable->zName, zDb) ||\n      sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){\n      return;\n    }\n  }\n#endif\n\n  /* Generate code to destroy the database record of the trigger.\n  */\n  assert( pTable!=0 );\n  if( (v = sqlite3GetVdbe(pParse))!=0 ){\n    sqlite3NestedParse(pParse,\n       \"DELETE FROM %Q.%s WHERE name=%Q AND type='trigger'\",\n       db->aDb[iDb].zDbSName, MASTER_NAME, pTrigger->zName\n    );\n    sqlite3ChangeCookie(pParse, iDb);\n    sqlite3VdbeAddOp4(v, OP_DropTrigger, iDb, 0, 0, pTrigger->zName, 0);\n  }\n}\n\n/*\n** Remove a trigger from the hash tables of the sqlite* pointer.\n*/\nvoid sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){\n  Trigger *pTrigger;\n  Hash *pHash;\n\n  assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n  pHash = &(db->aDb[iDb].pSchema->trigHash);\n  pTrigger = sqlite3HashInsert(pHash, zName, 0);\n  if( ALWAYS(pTrigger) ){\n    if( pTrigger->pSchema==pTrigger->pTabSchema ){\n      Table *pTab = tableOfTrigger(pTrigger);\n      Trigger **pp;\n      for(pp=&pTab->pTrigger; *pp!=pTrigger; pp=&((*pp)->pNext));\n      *pp = (*pp)->pNext;\n    }\n    sqlite3DeleteTrigger(db, pTrigger);\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }\n}\n\n/*\n** pEList is the SET clause of an UPDATE statement.  Each entry\n** in pEList is of the format <id>=<expr>.  If any of the entries\n** in pEList have an <id> which matches an identifier in pIdList,\n** then return TRUE.  If pIdList==NULL, then it is considered a\n** wildcard that matches anything.  Likewise if pEList==NULL then\n** it matches anything so always return true.  Return false only\n** if there is no match.\n*/\nstatic int checkColumnOverlap(IdList *pIdList, ExprList *pEList){\n  int e;\n  if( pIdList==0 || NEVER(pEList==0) ) return 1;\n  for(e=0; e<pEList->nExpr; e++){\n    if( sqlite3IdListIndex(pIdList, pEList->a[e].zName)>=0 ) return 1;\n  }\n  return 0; \n}\n\n/*\n** Return a list of all triggers on table pTab if there exists at least\n** one trigger that must be fired when an operation of type 'op' is \n** performed on the table, and, if that operation is an UPDATE, if at\n** least one of the columns in pChanges is being modified.\n*/\nTrigger *sqlite3TriggersExist(\n  Parse *pParse,          /* Parse context */\n  Table *pTab,            /* The table the contains the triggers */\n  int op,                 /* one of TK_DELETE, TK_INSERT, TK_UPDATE */\n  ExprList *pChanges,     /* Columns that change in an UPDATE statement */\n  int *pMask              /* OUT: Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n){\n  int mask = 0;\n  Trigger *pList = 0;\n  Trigger *p;\n\n  if( (pParse->db->flags & SQLITE_EnableTrigger)!=0 ){\n    pList = sqlite3TriggerList(pParse, pTab);\n  }\n  assert( pList==0 || IsVirtual(pTab)==0 );\n  for(p=pList; p; p=p->pNext){\n    if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){\n      mask |= p->tr_tm;\n    }\n  }\n  if( pMask ){\n    *pMask = mask;\n  }\n  return (mask ? pList : 0);\n}\n\n/*\n** Convert the pStep->zTarget string into a SrcList and return a pointer\n** to that SrcList.\n**\n** This routine adds a specific database name, if needed, to the target when\n** forming the SrcList.  This prevents a trigger in one database from\n** referring to a target in another database.  An exception is when the\n** trigger is in TEMP in which case it can refer to any other database it\n** wants.\n*/\nstatic SrcList *targetSrcList(\n  Parse *pParse,       /* The parsing context */\n  TriggerStep *pStep   /* The trigger containing the target token */\n){\n  sqlite3 *db = pParse->db;\n  int iDb;             /* Index of the database to use */\n  SrcList *pSrc;       /* SrcList to be returned */\n\n  pSrc = sqlite3SrcListAppend(db, 0, 0, 0);\n  if( pSrc ){\n    assert( pSrc->nSrc>0 );\n    pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);\n    iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema);\n    if( iDb==0 || iDb>=2 ){\n      const char *zDb;\n      assert( iDb<db->nDb );\n      zDb = db->aDb[iDb].zDbSName;\n      pSrc->a[pSrc->nSrc-1].zDatabase =  sqlite3DbStrDup(db, zDb);\n    }\n  }\n  return pSrc;\n}\n\n/*\n** Generate VDBE code for the statements inside the body of a single \n** trigger.\n*/\nstatic int codeTriggerProgram(\n  Parse *pParse,            /* The parser context */\n  TriggerStep *pStepList,   /* List of statements inside the trigger body */\n  int orconf                /* Conflict algorithm. (OE_Abort, etc) */  \n){\n  TriggerStep *pStep;\n  Vdbe *v = pParse->pVdbe;\n  sqlite3 *db = pParse->db;\n\n  assert( pParse->pTriggerTab && pParse->pToplevel );\n  assert( pStepList );\n  assert( v!=0 );\n  for(pStep=pStepList; pStep; pStep=pStep->pNext){\n    /* Figure out the ON CONFLICT policy that will be used for this step\n    ** of the trigger program. If the statement that caused this trigger\n    ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use\n    ** the ON CONFLICT policy that was specified as part of the trigger\n    ** step statement. Example:\n    **\n    **   CREATE TRIGGER AFTER INSERT ON t1 BEGIN;\n    **     INSERT OR REPLACE INTO t2 VALUES(new.a, new.b);\n    **   END;\n    **\n    **   INSERT INTO t1 ... ;            -- insert into t2 uses REPLACE policy\n    **   INSERT OR IGNORE INTO t1 ... ;  -- insert into t2 uses IGNORE policy\n    */\n    pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;\n    assert( pParse->okConstFactor==0 );\n\n    switch( pStep->op ){\n      case TK_UPDATE: {\n        sqlite3Update(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprListDup(db, pStep->pExprList, 0), \n          sqlite3ExprDup(db, pStep->pWhere, 0), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_INSERT: {\n        sqlite3Insert(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3SelectDup(db, pStep->pSelect, 0), \n          sqlite3IdListDup(db, pStep->pIdList), \n          pParse->eOrconf\n        );\n        break;\n      }\n      case TK_DELETE: {\n        sqlite3DeleteFrom(pParse, \n          targetSrcList(pParse, pStep),\n          sqlite3ExprDup(db, pStep->pWhere, 0)\n        );\n        break;\n      }\n      default: assert( pStep->op==TK_SELECT ); {\n        SelectDest sDest;\n        Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);\n        sqlite3SelectDestInit(&sDest, SRT_Discard, 0);\n        sqlite3Select(pParse, pSelect, &sDest);\n        sqlite3SelectDelete(db, pSelect);\n        break;\n      }\n    } \n    if( pStep->op!=TK_SELECT ){\n      sqlite3VdbeAddOp0(v, OP_ResetCount);\n    }\n  }\n\n  return 0;\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** This function is used to add VdbeComment() annotations to a VDBE\n** program. It is not used in production code, only for debugging.\n*/\nstatic const char *onErrorText(int onError){\n  switch( onError ){\n    case OE_Abort:    return \"abort\";\n    case OE_Rollback: return \"rollback\";\n    case OE_Fail:     return \"fail\";\n    case OE_Replace:  return \"replace\";\n    case OE_Ignore:   return \"ignore\";\n    case OE_Default:  return \"default\";\n  }\n  return \"n/a\";\n}\n#endif\n\n/*\n** Parse context structure pFrom has just been used to create a sub-vdbe\n** (trigger program). If an error has occurred, transfer error information\n** from pFrom to pTo.\n*/\nstatic void transferParseError(Parse *pTo, Parse *pFrom){\n  assert( pFrom->zErrMsg==0 || pFrom->nErr );\n  assert( pTo->zErrMsg==0 || pTo->nErr );\n  if( pTo->nErr==0 ){\n    pTo->zErrMsg = pFrom->zErrMsg;\n    pTo->nErr = pFrom->nErr;\n    pTo->rc = pFrom->rc;\n  }else{\n    sqlite3DbFree(pFrom->db, pFrom->zErrMsg);\n  }\n}\n\n/*\n** Create and populate a new TriggerPrg object with a sub-program \n** implementing trigger pTrigger with ON CONFLICT policy orconf.\n*/\nstatic TriggerPrg *codeRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table pTrigger is attached to */\n  int orconf           /* ON CONFLICT policy to code trigger program with */\n){\n  Parse *pTop = sqlite3ParseToplevel(pParse);\n  sqlite3 *db = pParse->db;   /* Database handle */\n  TriggerPrg *pPrg;           /* Value to return */\n  Expr *pWhen = 0;            /* Duplicate of trigger WHEN expression */\n  Vdbe *v;                    /* Temporary VM */\n  NameContext sNC;            /* Name context for sub-vdbe */\n  SubProgram *pProgram = 0;   /* Sub-vdbe for trigger program */\n  Parse *pSubParse;           /* Parse context for sub-vdbe */\n  int iEndTrigger = 0;        /* Label to jump to if WHEN is false */\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n  assert( pTop->pVdbe );\n\n  /* Allocate the TriggerPrg and SubProgram objects. To ensure that they\n  ** are freed if an error occurs, link them into the Parse.pTriggerPrg \n  ** list of the top-level Parse object sooner rather than later.  */\n  pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));\n  if( !pPrg ) return 0;\n  pPrg->pNext = pTop->pTriggerPrg;\n  pTop->pTriggerPrg = pPrg;\n  pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));\n  if( !pProgram ) return 0;\n  sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);\n  pPrg->pTrigger = pTrigger;\n  pPrg->orconf = orconf;\n  pPrg->aColmask[0] = 0xffffffff;\n  pPrg->aColmask[1] = 0xffffffff;\n\n  /* Allocate and populate a new Parse context to use for coding the \n  ** trigger sub-program.  */\n  pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));\n  if( !pSubParse ) return 0;\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pSubParse;\n  pSubParse->db = db;\n  pSubParse->pTriggerTab = pTab;\n  pSubParse->pToplevel = pTop;\n  pSubParse->zAuthContext = pTrigger->zName;\n  pSubParse->eTriggerOp = pTrigger->op;\n  pSubParse->nQueryLoop = pParse->nQueryLoop;\n\n  v = sqlite3GetVdbe(pSubParse);\n  if( v ){\n    VdbeComment((v, \"Start: %s.%s (%s %s%s%s ON %s)\", \n      pTrigger->zName, onErrorText(orconf),\n      (pTrigger->tr_tm==TRIGGER_BEFORE ? \"BEFORE\" : \"AFTER\"),\n        (pTrigger->op==TK_UPDATE ? \"UPDATE\" : \"\"),\n        (pTrigger->op==TK_INSERT ? \"INSERT\" : \"\"),\n        (pTrigger->op==TK_DELETE ? \"DELETE\" : \"\"),\n      pTab->zName\n    ));\n#ifndef SQLITE_OMIT_TRACE\n    sqlite3VdbeChangeP4(v, -1, \n      sqlite3MPrintf(db, \"-- TRIGGER %s\", pTrigger->zName), P4_DYNAMIC\n    );\n#endif\n\n    /* If one was specified, code the WHEN clause. If it evaluates to false\n    ** (or NULL) the sub-vdbe is immediately halted by jumping to the \n    ** OP_Halt inserted at the end of the program.  */\n    if( pTrigger->pWhen ){\n      pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);\n      if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) \n       && db->mallocFailed==0 \n      ){\n        iEndTrigger = sqlite3VdbeMakeLabel(v);\n        sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);\n      }\n      sqlite3ExprDelete(db, pWhen);\n    }\n\n    /* Code the trigger program into the sub-vdbe. */\n    codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);\n\n    /* Insert an OP_Halt at the end of the sub-program. */\n    if( iEndTrigger ){\n      sqlite3VdbeResolveLabel(v, iEndTrigger);\n    }\n    sqlite3VdbeAddOp0(v, OP_Halt);\n    VdbeComment((v, \"End: %s.%s\", pTrigger->zName, onErrorText(orconf)));\n\n    transferParseError(pParse, pSubParse);\n    if( db->mallocFailed==0 ){\n      pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);\n    }\n    pProgram->nMem = pSubParse->nMem;\n    pProgram->nCsr = pSubParse->nTab;\n    pProgram->token = (void *)pTrigger;\n    pPrg->aColmask[0] = pSubParse->oldmask;\n    pPrg->aColmask[1] = pSubParse->newmask;\n    sqlite3VdbeDelete(v);\n  }\n\n  assert( !pSubParse->pAinc       && !pSubParse->pZombieTab );\n  assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );\n  sqlite3ParserReset(pSubParse);\n  sqlite3StackFree(db, pSubParse);\n\n  return pPrg;\n}\n    \n/*\n** Return a pointer to a TriggerPrg object containing the sub-program for\n** trigger pTrigger with default ON CONFLICT algorithm orconf. If no such\n** TriggerPrg object exists, a new object is allocated and populated before\n** being returned.\n*/\nstatic TriggerPrg *getRowTrigger(\n  Parse *pParse,       /* Current parse context */\n  Trigger *pTrigger,   /* Trigger to code */\n  Table *pTab,         /* The table trigger pTrigger is attached to */\n  int orconf           /* ON CONFLICT algorithm. */\n){\n  Parse *pRoot = sqlite3ParseToplevel(pParse);\n  TriggerPrg *pPrg;\n\n  assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );\n\n  /* It may be that this trigger has already been coded (or is in the\n  ** process of being coded). If this is the case, then an entry with\n  ** a matching TriggerPrg.pTrigger field will be present somewhere\n  ** in the Parse.pTriggerPrg list. Search for such an entry.  */\n  for(pPrg=pRoot->pTriggerPrg; \n      pPrg && (pPrg->pTrigger!=pTrigger || pPrg->orconf!=orconf); \n      pPrg=pPrg->pNext\n  );\n\n  /* If an existing TriggerPrg could not be located, create a new one. */\n  if( !pPrg ){\n    pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);\n  }\n\n  return pPrg;\n}\n\n/*\n** Generate code for the trigger program associated with trigger p on \n** table pTab. The reg, orconf and ignoreJump parameters passed to this\n** function are the same as those described in the header function for\n** sqlite3CodeRowTrigger()\n*/\nvoid sqlite3CodeRowTriggerDirect(\n  Parse *pParse,       /* Parse context */\n  Trigger *p,          /* Trigger to code */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* Reg array containing OLD.* and NEW.* values */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */\n  TriggerPrg *pPrg;\n  pPrg = getRowTrigger(pParse, p, pTab, orconf);\n  assert( pPrg || pParse->nErr || pParse->db->mallocFailed );\n\n  /* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program \n  ** is a pointer to the sub-vdbe containing the trigger program.  */\n  if( pPrg ){\n    int bRecursive = (p->zName && 0==(pParse->db->flags&SQLITE_RecTriggers));\n\n    sqlite3VdbeAddOp4(v, OP_Program, reg, ignoreJump, ++pParse->nMem,\n                      (const char *)pPrg->pProgram, P4_SUBPROGRAM);\n    VdbeComment(\n        (v, \"Call: %s.%s\", (p->zName?p->zName:\"fkey\"), onErrorText(orconf)));\n\n    /* Set the P5 operand of the OP_Program instruction to non-zero if\n    ** recursive invocation of this trigger program is disallowed. Recursive\n    ** invocation is disallowed if (a) the sub-program is really a trigger,\n    ** not a foreign key action, and (b) the flag to enable recursive triggers\n    ** is clear.  */\n    sqlite3VdbeChangeP5(v, (u8)bRecursive);\n  }\n}\n\n/*\n** This is called to code the required FOR EACH ROW triggers for an operation\n** on table pTab. The operation to code triggers for (INSERT, UPDATE or DELETE)\n** is given by the op parameter. The tr_tm parameter determines whether the\n** BEFORE or AFTER triggers are coded. If the operation is an UPDATE, then\n** parameter pChanges is passed the list of columns being modified.\n**\n** If there are no triggers that fire at the specified time for the specified\n** operation on pTab, this function is a no-op.\n**\n** The reg argument is the address of the first in an array of registers \n** that contain the values substituted for the new.* and old.* references\n** in the trigger program. If N is the number of columns in table pTab\n** (a copy of pTab->nCol), then registers are populated as follows:\n**\n**   Register       Contains\n**   ------------------------------------------------------\n**   reg+0          OLD.rowid\n**   reg+1          OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N          OLD.* value of right-most column of pTab\n**   reg+N+1        NEW.rowid\n**   reg+N+2        OLD.* value of left-most column of pTab\n**   ...            ...\n**   reg+N+N+1      NEW.* value of right-most column of pTab\n**\n** For ON DELETE triggers, the registers containing the NEW.* values will\n** never be accessed by the trigger program, so they are not allocated or \n** populated by the caller (there is no data to populate them with anyway). \n** Similarly, for ON INSERT triggers the values stored in the OLD.* registers\n** are never accessed, and so are not allocated by the caller. So, for an\n** ON INSERT trigger, the value passed to this function as parameter reg\n** is not a readable register, although registers (reg+N) through \n** (reg+N+N+1) are.\n**\n** Parameter orconf is the default conflict resolution algorithm for the\n** trigger program to use (REPLACE, IGNORE etc.). Parameter ignoreJump\n** is the instruction that control should jump to if a trigger program\n** raises an IGNORE exception.\n*/\nvoid sqlite3CodeRowTrigger(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  int op,              /* One of TK_UPDATE, TK_INSERT, TK_DELETE */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int tr_tm,           /* One of TRIGGER_BEFORE, TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int reg,             /* The first in an array of registers (see above) */\n  int orconf,          /* ON CONFLICT policy */\n  int ignoreJump       /* Instruction to jump to for RAISE(IGNORE) */\n){\n  Trigger *p;          /* Used to iterate through pTrigger list */\n\n  assert( op==TK_UPDATE || op==TK_INSERT || op==TK_DELETE );\n  assert( tr_tm==TRIGGER_BEFORE || tr_tm==TRIGGER_AFTER );\n  assert( (op==TK_UPDATE)==(pChanges!=0) );\n\n  for(p=pTrigger; p; p=p->pNext){\n\n    /* Sanity checking:  The schema for the trigger and for the table are\n    ** always defined.  The trigger must be in the same schema as the table\n    ** or else it must be a TEMP trigger. */\n    assert( p->pSchema!=0 );\n    assert( p->pTabSchema!=0 );\n    assert( p->pSchema==p->pTabSchema \n         || p->pSchema==pParse->db->aDb[1].pSchema );\n\n    /* Determine whether we should code this trigger */\n    if( p->op==op \n     && p->tr_tm==tr_tm \n     && checkColumnOverlap(p->pColumns, pChanges)\n    ){\n      sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump);\n    }\n  }\n}\n\n/*\n** Triggers may access values stored in the old.* or new.* pseudo-table. \n** This function returns a 32-bit bitmask indicating which columns of the \n** old.* or new.* tables actually are used by triggers. This information \n** may be used by the caller, for example, to avoid having to load the entire\n** old.* record into memory when executing an UPDATE or DELETE command.\n**\n** Bit 0 of the returned mask is set if the left-most column of the\n** table may be accessed using an [old|new].<col> reference. Bit 1 is set if\n** the second leftmost column value is required, and so on. If there\n** are more than 32 columns in the table, and at least one of the columns\n** with an index greater than 32 may be accessed, 0xffffffff is returned.\n**\n** It is not possible to determine if the old.rowid or new.rowid column is \n** accessed by triggers. The caller must always assume that it is.\n**\n** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned\n** applies to the old.* table. If 1, the new.* table.\n**\n** Parameter tr_tm must be a mask with one or both of the TRIGGER_BEFORE\n** and TRIGGER_AFTER bits set. Values accessed by BEFORE triggers are only\n** included in the returned mask if the TRIGGER_BEFORE bit is set in the\n** tr_tm parameter. Similarly, values accessed by AFTER triggers are only\n** included in the returned mask if the TRIGGER_AFTER bit is set in tr_tm.\n*/\nu32 sqlite3TriggerColmask(\n  Parse *pParse,       /* Parse context */\n  Trigger *pTrigger,   /* List of triggers on table pTab */\n  ExprList *pChanges,  /* Changes list for any UPDATE OF triggers */\n  int isNew,           /* 1 for new.* ref mask, 0 for old.* ref mask */\n  int tr_tm,           /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n  Table *pTab,         /* The table to code triggers from */\n  int orconf           /* Default ON CONFLICT policy for trigger steps */\n){\n  const int op = pChanges ? TK_UPDATE : TK_DELETE;\n  u32 mask = 0;\n  Trigger *p;\n\n  assert( isNew==1 || isNew==0 );\n  for(p=pTrigger; p; p=p->pNext){\n    if( p->op==op && (tr_tm&p->tr_tm)\n     && checkColumnOverlap(p->pColumns,pChanges)\n    ){\n      TriggerPrg *pPrg;\n      pPrg = getRowTrigger(pParse, p, pTab, orconf);\n      if( pPrg ){\n        mask |= pPrg->aColmask[isNew];\n      }\n    }\n  }\n\n  return mask;\n}\n\n#endif /* !defined(SQLITE_OMIT_TRIGGER) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/update.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains C code routines that are called by the parser\n** to handle UPDATE statements.\n*/\n#include \"sqliteInt.h\"\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Forward declaration */\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowidExpr,    /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n);\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** The most recently coded instruction was an OP_Column to retrieve the\n** i-th column of table pTab. This routine sets the P4 parameter of the \n** OP_Column to the default value, if any.\n**\n** The default value of a column is specified by a DEFAULT clause in the \n** column definition. This was either supplied by the user when the table\n** was created, or added later to the table definition by an ALTER TABLE\n** command. If the latter, then the row-records in the table btree on disk\n** may not contain a value for the column and the default value, taken\n** from the P4 parameter of the OP_Column instruction, is returned instead.\n** If the former, then all row-records are guaranteed to include a value\n** for the column and the P4 value is not required.\n**\n** Column definitions created by an ALTER TABLE command may only have \n** literal default values specified: a number, null or a string. (If a more\n** complicated default expression value was provided, it is evaluated \n** when the ALTER TABLE is executed and one of the literal values written\n** into the sqlite_master table.)\n**\n** Therefore, the P4 parameter is only required if the default value for\n** the column is a literal number, string or null. The sqlite3ValueFromExpr()\n** function is capable of transforming these types of expressions into\n** sqlite3_value objects.\n**\n** If parameter iReg is not negative, code an OP_RealAffinity instruction\n** on register iReg. This is used when an equivalent integer value is \n** stored in place of an 8-byte floating point value in order to save \n** space.\n*/\nvoid sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){\n  assert( pTab!=0 );\n  if( !pTab->pSelect ){\n    sqlite3_value *pValue = 0;\n    u8 enc = ENC(sqlite3VdbeDb(v));\n    Column *pCol = &pTab->aCol[i];\n    VdbeComment((v, \"%s.%s\", pTab->zName, pCol->zName));\n    assert( i<pTab->nCol );\n    sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, \n                         pCol->affinity, &pValue);\n    if( pValue ){\n      sqlite3VdbeAppendP4(v, pValue, P4_MEM);\n    }\n  }\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){\n    sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);\n  }\n#endif\n}\n\n/*\n** Process an UPDATE statement.\n**\n**   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;\n**          \\_______/ \\________/     \\______/       \\________________/\n*            onError   pTabList      pChanges             pWhere\n*/\nvoid sqlite3Update(\n  Parse *pParse,         /* The parser context */\n  SrcList *pTabList,     /* The table in which we should change things */\n  ExprList *pChanges,    /* Things to be changed */\n  Expr *pWhere,          /* The WHERE clause.  May be null */\n  int onError            /* How to handle constraint errors */\n){\n  int i, j;              /* Loop counters */\n  Table *pTab;           /* The table to be updated */\n  int addrTop = 0;       /* VDBE instruction address of the start of the loop */\n  WhereInfo *pWInfo;     /* Information about the WHERE clause */\n  Vdbe *v;               /* The virtual database engine */\n  Index *pIdx;           /* For looping over indices */\n  Index *pPk;            /* The PRIMARY KEY index for WITHOUT ROWID tables */\n  int nIdx;              /* Number of indices that need updating */\n  int iBaseCur;          /* Base cursor number */\n  int iDataCur;          /* Cursor for the canonical data btree */\n  int iIdxCur;           /* Cursor for the first index */\n  sqlite3 *db;           /* The database structure */\n  int *aRegIdx = 0;      /* First register in array assigned to each index */\n  int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the\n                         ** an expression for the i-th column of the table.\n                         ** aXRef[i]==-1 if the i-th column is not changed. */\n  u8 *aToOpen;           /* 1 for tables and indices to be opened */\n  u8 chngPk;             /* PRIMARY KEY changed in a WITHOUT ROWID table */\n  u8 chngRowid;          /* Rowid changed in a normal table */\n  u8 chngKey;            /* Either chngPk or chngRowid */\n  Expr *pRowidExpr = 0;  /* Expression defining the new record number */\n  AuthContext sContext;  /* The authorization context */\n  NameContext sNC;       /* The name-context to resolve expressions in */\n  int iDb;               /* Database containing the table being updated */\n  int eOnePass;          /* ONEPASS_XXX value from where.c */\n  int hasFK;             /* True if foreign key processing is required */\n  int labelBreak;        /* Jump here to break out of UPDATE loop */\n  int labelContinue;     /* Jump here to continue next step of UPDATE loop */\n  int flags;             /* Flags for sqlite3WhereBegin() */\n\n#ifndef SQLITE_OMIT_TRIGGER\n  int isView;            /* True when updating a view (INSTEAD OF trigger) */\n  Trigger *pTrigger;     /* List of triggers on pTab, if required */\n  int tmask;             /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */\n#endif\n  int newmask;           /* Mask of NEW.* columns accessed by BEFORE triggers */\n  int iEph = 0;          /* Ephemeral table holding all primary key values */\n  int nKey = 0;          /* Number of elements in regKey for WITHOUT ROWID */\n  int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */\n  int addrOpen = 0;      /* Address of OP_OpenEphemeral */\n  int iPk = 0;           /* First of nPk cells holding PRIMARY KEY value */\n  i16 nPk = 0;           /* Number of components of the PRIMARY KEY */\n  int bReplace = 0;      /* True if REPLACE conflict resolution might happen */\n\n  /* Register Allocations */\n  int regRowCount = 0;   /* A count of rows changed */\n  int regOldRowid = 0;   /* The old rowid */\n  int regNewRowid = 0;   /* The new rowid */\n  int regNew = 0;        /* Content of the NEW.* table in triggers */\n  int regOld = 0;        /* Content of OLD.* table in triggers */\n  int regRowSet = 0;     /* Rowset of rows to be updated */\n  int regKey = 0;        /* composite PRIMARY KEY value */\n\n  memset(&sContext, 0, sizeof(sContext));\n  db = pParse->db;\n  if( pParse->nErr || db->mallocFailed ){\n    goto update_cleanup;\n  }\n  assert( pTabList->nSrc==1 );\n\n  /* Locate the table which we want to update. \n  */\n  pTab = sqlite3SrcListLookup(pParse, pTabList);\n  if( pTab==0 ) goto update_cleanup;\n  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);\n\n  /* Figure out if we have any triggers and if the table being\n  ** updated is a view.\n  */\n#ifndef SQLITE_OMIT_TRIGGER\n  pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask);\n  isView = pTab->pSelect!=0;\n  assert( pTrigger || tmask==0 );\n#else\n# define pTrigger 0\n# define isView 0\n# define tmask 0\n#endif\n#ifdef SQLITE_OMIT_VIEW\n# undef isView\n# define isView 0\n#endif\n\n  if( sqlite3ViewGetColumnNames(pParse, pTab) ){\n    goto update_cleanup;\n  }\n  if( sqlite3IsReadOnly(pParse, pTab, tmask) ){\n    goto update_cleanup;\n  }\n\n  /* Allocate a cursors for the main database table and for all indices.\n  ** The index cursors might not be used, but if they are used they\n  ** need to occur right after the database cursor.  So go ahead and\n  ** allocate enough space, just in case.\n  */\n  pTabList->a[0].iCursor = iBaseCur = iDataCur = pParse->nTab++;\n  iIdxCur = iDataCur+1;\n  pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);\n  for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){\n    if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){\n      iDataCur = pParse->nTab;\n      pTabList->a[0].iCursor = iDataCur;\n    }\n    pParse->nTab++;\n  }\n\n  /* Allocate space for aXRef[], aRegIdx[], and aToOpen[].  \n  ** Initialize aXRef[] and aToOpen[] to their default values.\n  */\n  aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 );\n  if( aXRef==0 ) goto update_cleanup;\n  aRegIdx = aXRef+pTab->nCol;\n  aToOpen = (u8*)(aRegIdx+nIdx);\n  memset(aToOpen, 1, nIdx+1);\n  aToOpen[nIdx+1] = 0;\n  for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;\n\n  /* Initialize the name-context */\n  memset(&sNC, 0, sizeof(sNC));\n  sNC.pParse = pParse;\n  sNC.pSrcList = pTabList;\n\n  /* Resolve the column names in all the expressions of the\n  ** of the UPDATE statement.  Also find the column index\n  ** for each column to be updated in the pChanges array.  For each\n  ** column to be updated, make sure we have authorization to change\n  ** that column.\n  */\n  chngRowid = chngPk = 0;\n  for(i=0; i<pChanges->nExpr; i++){\n    if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){\n      goto update_cleanup;\n    }\n    for(j=0; j<pTab->nCol; j++){\n      if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){\n        if( j==pTab->iPKey ){\n          chngRowid = 1;\n          pRowidExpr = pChanges->a[i].pExpr;\n        }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){\n          chngPk = 1;\n        }\n        aXRef[j] = i;\n        break;\n      }\n    }\n    if( j>=pTab->nCol ){\n      if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){\n        j = -1;\n        chngRowid = 1;\n        pRowidExpr = pChanges->a[i].pExpr;\n      }else{\n        sqlite3ErrorMsg(pParse, \"no such column: %s\", pChanges->a[i].zName);\n        pParse->checkSchema = 1;\n        goto update_cleanup;\n      }\n    }\n#ifndef SQLITE_OMIT_AUTHORIZATION\n    {\n      int rc;\n      rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName,\n                            j<0 ? \"ROWID\" : pTab->aCol[j].zName,\n                            db->aDb[iDb].zDbSName);\n      if( rc==SQLITE_DENY ){\n        goto update_cleanup;\n      }else if( rc==SQLITE_IGNORE ){\n        aXRef[j] = -1;\n      }\n    }\n#endif\n  }\n  assert( (chngRowid & chngPk)==0 );\n  assert( chngRowid==0 || chngRowid==1 );\n  assert( chngPk==0 || chngPk==1 );\n  chngKey = chngRowid + chngPk;\n\n  /* The SET expressions are not actually used inside the WHERE loop.  \n  ** So reset the colUsed mask. Unless this is a virtual table. In that\n  ** case, set all bits of the colUsed mask (to ensure that the virtual\n  ** table implementation makes all columns available).\n  */\n  pTabList->a[0].colUsed = IsVirtual(pTab) ? ALLBITS : 0;\n\n  hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey);\n\n  /* There is one entry in the aRegIdx[] array for each index on the table\n  ** being updated.  Fill in aRegIdx[] with a register number that will hold\n  ** the key for accessing each index.\n  **\n  ** FIXME:  Be smarter about omitting indexes that use expressions.\n  */\n  for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){\n    int reg;\n    if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){\n      reg = ++pParse->nMem;\n      pParse->nMem += pIdx->nColumn;\n    }else{\n      reg = 0;\n      for(i=0; i<pIdx->nKeyCol; i++){\n        i16 iIdxCol = pIdx->aiColumn[i];\n        if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){\n          reg = ++pParse->nMem;\n          pParse->nMem += pIdx->nColumn;\n          if( (onError==OE_Replace)\n           || (onError==OE_Default && pIdx->onError==OE_Replace) \n          ){\n            bReplace = 1;\n          }\n          break;\n        }\n      }\n    }\n    if( reg==0 ) aToOpen[j+1] = 0;\n    aRegIdx[j] = reg;\n  }\n  if( bReplace ){\n    /* If REPLACE conflict resolution might be invoked, open cursors on all \n    ** indexes in case they are needed to delete records.  */\n    memset(aToOpen, 1, nIdx+1);\n  }\n\n  /* Begin generating code. */\n  v = sqlite3GetVdbe(pParse);\n  if( v==0 ) goto update_cleanup;\n  if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);\n  sqlite3BeginWriteOperation(pParse, 1, iDb);\n\n  /* Allocate required registers. */\n  if( !IsVirtual(pTab) ){\n    regRowSet = ++pParse->nMem;\n    regOldRowid = regNewRowid = ++pParse->nMem;\n    if( chngPk || pTrigger || hasFK ){\n      regOld = pParse->nMem + 1;\n      pParse->nMem += pTab->nCol;\n    }\n    if( chngKey || pTrigger || hasFK ){\n      regNewRowid = ++pParse->nMem;\n    }\n    regNew = pParse->nMem + 1;\n    pParse->nMem += pTab->nCol;\n  }\n\n  /* Start the view context. */\n  if( isView ){\n    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);\n  }\n\n  /* If we are trying to update a view, realize that view into\n  ** an ephemeral table.\n  */\n#if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)\n  if( isView ){\n    sqlite3MaterializeView(pParse, pTab, pWhere, iDataCur);\n  }\n#endif\n\n  /* Resolve the column names in all the expressions in the\n  ** WHERE clause.\n  */\n  if( sqlite3ResolveExprNames(&sNC, pWhere) ){\n    goto update_cleanup;\n  }\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Virtual tables must be handled separately */\n  if( IsVirtual(pTab) ){\n    updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,\n                       pWhere, onError);\n    goto update_cleanup;\n  }\n#endif\n\n  /* Initialize the count of updated rows */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){\n    regRowCount = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);\n  }\n\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);\n  }else{\n    assert( pPk!=0 );\n    nPk = pPk->nKeyCol;\n    iPk = pParse->nMem+1;\n    pParse->nMem += nPk;\n    regKey = ++pParse->nMem;\n    iEph = pParse->nTab++;\n\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iPk);\n    addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);\n    sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n  }\n\n  /* Begin the database scan. \n  **\n  ** Do not consider a single-pass strategy for a multi-row update if\n  ** there are any triggers or foreign keys to process, or rows may\n  ** be deleted as a result of REPLACE conflict handling. Any of these\n  ** things might disturb a cursor being used to scan through the table\n  ** or index, causing a single-pass approach to malfunction.  */\n  flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;\n  if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){\n    flags |= WHERE_ONEPASS_MULTIROW;\n  }\n  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);\n  if( pWInfo==0 ) goto update_cleanup;\n\n  /* A one-pass strategy that might update more than one row may not\n  ** be used if any column of the index used for the scan is being\n  ** updated. Otherwise, if there is an index on \"b\", statements like\n  ** the following could create an infinite loop:\n  **\n  **   UPDATE t1 SET b=b+1 WHERE b>?\n  **\n  ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI\n  ** strategy that uses an index for which one or more columns are being\n  ** updated.  */\n  eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);\n  if( eOnePass==ONEPASS_MULTI ){\n    int iCur = aiCurOnePass[1];\n    if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){\n      eOnePass = ONEPASS_OFF;\n    }\n    assert( iCur!=iDataCur || !HasRowid(pTab) );\n  }\n  \n  if( HasRowid(pTab) ){\n    /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF\n    ** mode, write the rowid into the FIFO. In either of the one-pass modes,\n    ** leave it in register regOldRowid.  */\n    sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid);\n    if( eOnePass==ONEPASS_OFF ){\n      sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);\n    }\n  }else{\n    /* Read the PK of the current row into an array of registers. In\n    ** ONEPASS_OFF mode, serialize the array into a record and store it in\n    ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change\n    ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table \n    ** is not required) and leave the PK fields in the array of registers.  */\n    for(i=0; i<nPk; i++){\n      assert( pPk->aiColumn[i]>=0 );\n      sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);\n    }\n    if( eOnePass ){\n      sqlite3VdbeChangeToNoop(v, addrOpen);\n      nKey = nPk;\n      regKey = iPk;\n    }else{\n      sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey,\n                        sqlite3IndexAffinityStr(db, pPk), nPk);\n      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk);\n    }\n  }\n\n  if( eOnePass!=ONEPASS_MULTI ){\n    sqlite3WhereEnd(pWInfo);\n  }\n\n  labelBreak = sqlite3VdbeMakeLabel(v);\n  if( !isView ){\n    int addrOnce = 0;\n\n    /* Open every index that needs updating. */\n    if( eOnePass!=ONEPASS_OFF ){\n      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;\n      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;\n    }\n\n    if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){\n      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n    }\n    sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen,\n                               0, 0);\n    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);\n  }\n\n  /* Top of the update loop */\n  if( eOnePass!=ONEPASS_OFF ){\n    if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){\n      assert( pPk );\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey, nKey);\n      VdbeCoverageNeverTaken(v);\n    }\n    if( eOnePass==ONEPASS_SINGLE ){\n      labelContinue = labelBreak;\n    }else{\n      labelContinue = sqlite3VdbeMakeLabel(v);\n    }\n    sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);\n    VdbeCoverageIf(v, pPk==0);\n    VdbeCoverageIf(v, pPk!=0);\n  }else if( pPk ){\n    labelContinue = sqlite3VdbeMakeLabel(v);\n    sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);\n    addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);\n    sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);\n    VdbeCoverage(v);\n  }else{\n    labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,\n                             regOldRowid);\n    VdbeCoverage(v);\n    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n    VdbeCoverage(v);\n  }\n\n  /* If the record number will change, set register regNewRowid to\n  ** contain the new value. If the record number is not being modified,\n  ** then regNewRowid is the same register as regOldRowid, which is\n  ** already populated.  */\n  assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );\n  if( chngRowid ){\n    sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);\n    sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v);\n  }\n\n  /* Compute the old pre-UPDATE content of the row being changed, if that\n  ** information is needed */\n  if( chngPk || hasFK || pTrigger ){\n    u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0);\n    oldmask |= sqlite3TriggerColmask(pParse, \n        pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError\n    );\n    for(i=0; i<pTab->nCol; i++){\n      if( oldmask==0xffffffff\n       || (i<32 && (oldmask & MASKBIT32(i))!=0)\n       || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0\n      ){\n        testcase(  oldmask!=0xffffffff && i==31 );\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i);\n      }\n    }\n    if( chngRowid==0 && pPk==0 ){\n      sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);\n    }\n  }\n\n  /* Populate the array of registers beginning at regNew with the new\n  ** row data. This array is used to check constants, create the new\n  ** table and index records, and as the values for any new.* references\n  ** made by triggers.\n  **\n  ** If there are one or more BEFORE triggers, then do not populate the\n  ** registers associated with columns that are (a) not modified by\n  ** this UPDATE statement and (b) not accessed by new.* references. The\n  ** values for registers not modified by the UPDATE must be reloaded from \n  ** the database after the BEFORE triggers are fired anyway (as the trigger \n  ** may have modified them). So not loading those that are not going to\n  ** be used eliminates some redundant opcodes.\n  */\n  newmask = sqlite3TriggerColmask(\n      pParse, pTrigger, pChanges, 1, TRIGGER_BEFORE, pTab, onError\n  );\n  for(i=0; i<pTab->nCol; i++){\n    if( i==pTab->iPKey ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n    }else{\n      j = aXRef[i];\n      if( j>=0 ){\n        sqlite3ExprCode(pParse, pChanges->a[j].pExpr, regNew+i);\n      }else if( 0==(tmask&TRIGGER_BEFORE) || i>31 || (newmask & MASKBIT32(i)) ){\n        /* This branch loads the value of a column that will not be changed \n        ** into a register. This is done if there are no BEFORE triggers, or\n        ** if there are one or more BEFORE triggers that use this value via\n        ** a new.* reference in a trigger program.\n        */\n        testcase( i==31 );\n        testcase( i==32 );\n        sqlite3ExprCodeGetColumnToReg(pParse, pTab, i, iDataCur, regNew+i);\n      }else{\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regNew+i);\n      }\n    }\n  }\n\n  /* Fire any BEFORE UPDATE triggers. This happens before constraints are\n  ** verified. One could argue that this is wrong.\n  */\n  if( tmask&TRIGGER_BEFORE ){\n    sqlite3TableAffinity(v, pTab, regNew);\n    sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n        TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue);\n\n    /* The row-trigger may have deleted the row being updated. In this\n    ** case, jump to the next row. No updates or AFTER triggers are \n    ** required. This behavior - what happens when the row being updated\n    ** is deleted or renamed by a BEFORE trigger - is left undefined in the\n    ** documentation.\n    */\n    if( pPk ){\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue,regKey,nKey);\n      VdbeCoverage(v);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);\n      VdbeCoverage(v);\n    }\n\n    /* If it did not delete it, the row-trigger may still have modified \n    ** some of the columns of the row being updated. Load the values for \n    ** all columns not modified by the update statement into their \n    ** registers in case this has happened.\n    */\n    for(i=0; i<pTab->nCol; i++){\n      if( aXRef[i]<0 && i!=pTab->iPKey ){\n        sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i);\n      }\n    }\n  }\n\n  if( !isView ){\n    int addr1 = 0;        /* Address of jump instruction */\n\n    /* Do constraint checks. */\n    assert( regOldRowid>0 );\n    sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,\n        regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,\n        aXRef);\n\n    /* Do FK constraint checks. */\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);\n    }\n\n    /* Delete the index entries associated with the current record.  */\n    if( bReplace || chngKey ){\n      if( pPk ){\n        addr1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey);\n      }else{\n        addr1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid);\n      }\n      VdbeCoverageNeverTaken(v);\n    }\n    sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx, -1);\n\n    /* If changing the rowid value, or if there are foreign key constraints\n    ** to process, delete the old record. Otherwise, add a noop OP_Delete\n    ** to invoke the pre-update hook.\n    **\n    ** That (regNew==regnewRowid+1) is true is also important for the \n    ** pre-update hook. If the caller invokes preupdate_new(), the returned\n    ** value is copied from memory cell (regNewRowid+1+iCol), where iCol\n    ** is the column index supplied by the user.\n    */\n    assert( regNew==regNewRowid+1 );\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    sqlite3VdbeAddOp3(v, OP_Delete, iDataCur,\n        OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP),\n        regNewRowid\n    );\n    if( eOnePass==ONEPASS_MULTI ){\n      assert( hasFK==0 && chngKey==0 );\n      sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);\n    }\n    if( !pParse->nested ){\n      sqlite3VdbeAppendP4(v, pTab, P4_TABLE);\n    }\n#else\n    if( hasFK>1 || chngKey ){\n      sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0);\n    }\n#endif\n    if( bReplace || chngKey ){\n      sqlite3VdbeJumpHere(v, addr1);\n    }\n\n    if( hasFK ){\n      sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey);\n    }\n  \n    /* Insert the new index entries and the new record. */\n    sqlite3CompleteInsertion(\n        pParse, pTab, iDataCur, iIdxCur, regNewRowid, aRegIdx, \n        OPFLAG_ISUPDATE | (eOnePass==ONEPASS_MULTI ? OPFLAG_SAVEPOSITION : 0), \n        0, 0\n    );\n\n    /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to\n    ** handle rows (possibly in other tables) that refer via a foreign key\n    ** to the row just updated. */ \n    if( hasFK ){\n      sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);\n    }\n  }\n\n  /* Increment the row counter \n  */\n  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){\n    sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);\n  }\n\n  sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, \n      TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);\n\n  /* Repeat the above with the next record to be updated, until\n  ** all record selected by the WHERE clause have been updated.\n  */\n  if( eOnePass==ONEPASS_SINGLE ){\n    /* Nothing to do at end-of-loop for a single-pass */\n  }else if( eOnePass==ONEPASS_MULTI ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3WhereEnd(pWInfo);\n  }else if( pPk ){\n    sqlite3VdbeResolveLabel(v, labelContinue);\n    sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v);\n  }else{\n    sqlite3VdbeGoto(v, labelContinue);\n  }\n  sqlite3VdbeResolveLabel(v, labelBreak);\n\n  /* Update the sqlite_sequence table by storing the content of the\n  ** maximum rowid counter values recorded while inserting into\n  ** autoincrement tables.\n  */\n  if( pParse->nested==0 && pParse->pTriggerTab==0 ){\n    sqlite3AutoincrementEnd(pParse);\n  }\n\n  /*\n  ** Return the number of rows that were changed. If this routine is \n  ** generating code because of a call to sqlite3NestedParse(), do not\n  ** invoke the callback function.\n  */\n  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){\n    sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);\n    sqlite3VdbeSetNumCols(v, 1);\n    sqlite3VdbeSetColName(v, 0, COLNAME_NAME, \"rows updated\", SQLITE_STATIC);\n  }\n\nupdate_cleanup:\n  sqlite3AuthContextPop(&sContext);\n  sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */\n  sqlite3SrcListDelete(db, pTabList);\n  sqlite3ExprListDelete(db, pChanges);\n  sqlite3ExprDelete(db, pWhere);\n  return;\n}\n/* Make sure \"isView\" and other macros defined above are undefined. Otherwise\n** they may interfere with compilation of other functions in this file\n** (or in another file, if this file becomes part of the amalgamation).  */\n#ifdef isView\n #undef isView\n#endif\n#ifdef pTrigger\n #undef pTrigger\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Generate code for an UPDATE of a virtual table.\n**\n** There are two possible strategies - the default and the special \n** \"onepass\" strategy. Onepass is only used if the virtual table \n** implementation indicates that pWhere may match at most one row.\n**\n** The default strategy is to create an ephemeral table that contains\n** for each row to be changed:\n**\n**   (A)  The original rowid of that row.\n**   (B)  The revised rowid for the row.\n**   (C)  The content of every column in the row.\n**\n** Then loop through the contents of this ephemeral table executing a\n** VUpdate for each row. When finished, drop the ephemeral table.\n**\n** The \"onepass\" strategy does not use an ephemeral table. Instead, it\n** stores the same values (A, B and C above) in a register array and\n** makes a single invocation of VUpdate.\n*/\nstatic void updateVirtualTable(\n  Parse *pParse,       /* The parsing context */\n  SrcList *pSrc,       /* The virtual table to be modified */\n  Table *pTab,         /* The virtual table */\n  ExprList *pChanges,  /* The columns to change in the UPDATE statement */\n  Expr *pRowid,        /* Expression used to recompute the rowid */\n  int *aXRef,          /* Mapping from columns of pTab to entries in pChanges */\n  Expr *pWhere,        /* WHERE clause of the UPDATE statement */\n  int onError          /* ON CONFLICT strategy */\n){\n  Vdbe *v = pParse->pVdbe;  /* Virtual machine under construction */\n  int ephemTab;             /* Table holding the result of the SELECT */\n  int i;                    /* Loop counter */\n  sqlite3 *db = pParse->db; /* Database connection */\n  const char *pVTab = (const char*)sqlite3GetVTable(db, pTab);\n  WhereInfo *pWInfo;\n  int nArg = 2 + pTab->nCol;      /* Number of arguments to VUpdate */\n  int regArg;                     /* First register in VUpdate arg array */\n  int regRec;                     /* Register in which to assemble record */\n  int regRowid;                   /* Register for ephem table rowid */\n  int iCsr = pSrc->a[0].iCursor;  /* Cursor used for virtual table scan */\n  int aDummy[2];                  /* Unused arg for sqlite3WhereOkOnePass() */\n  int bOnePass;                   /* True to use onepass strategy */\n  int addr;                       /* Address of OP_OpenEphemeral */\n\n  /* Allocate nArg registers to martial the arguments to VUpdate. Then\n  ** create and open the ephemeral table in which the records created from\n  ** these arguments will be temporarily stored. */\n  assert( v );\n  ephemTab = pParse->nTab++;\n  addr= sqlite3VdbeAddOp2(v, OP_OpenEphemeral, ephemTab, nArg);\n  regArg = pParse->nMem + 1;\n  pParse->nMem += nArg;\n  regRec = ++pParse->nMem;\n  regRowid = ++pParse->nMem;\n\n  /* Start scanning the virtual table */\n  pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0,0,WHERE_ONEPASS_DESIRED,0);\n  if( pWInfo==0 ) return;\n\n  /* Populate the argument registers. */\n  for(i=0; i<pTab->nCol; i++){\n    if( aXRef[i]>=0 ){\n      sqlite3ExprCode(pParse, pChanges->a[aXRef[i]].pExpr, regArg+2+i);\n    }else{\n      sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, i, regArg+2+i);\n    }\n  }\n  if( HasRowid(pTab) ){\n    sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg);\n    if( pRowid ){\n      sqlite3ExprCode(pParse, pRowid, regArg+1);\n    }else{\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCsr, regArg+1);\n    }\n  }else{\n    Index *pPk;   /* PRIMARY KEY index */\n    i16 iPk;      /* PRIMARY KEY column */\n    pPk = sqlite3PrimaryKeyIndex(pTab);\n    assert( pPk!=0 );\n    assert( pPk->nKeyCol==1 );\n    iPk = pPk->aiColumn[0];\n    sqlite3VdbeAddOp3(v, OP_VColumn, iCsr, iPk, regArg);\n    sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);\n  }\n\n  bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);\n\n  if( bOnePass ){\n    /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded\n    ** above. Also, if this is a top-level parse (not a trigger), clear the\n    ** multi-write flag so that the VM does not open a statement journal */\n    sqlite3VdbeChangeToNoop(v, addr);\n    if( sqlite3IsToplevel(pParse) ){\n      pParse->isMultiWrite = 0;\n    }\n  }else{\n    /* Create a record from the argument register contents and insert it into\n    ** the ephemeral table. */\n    sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);\n    sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);\n    sqlite3VdbeAddOp3(v, OP_Insert, ephemTab, regRec, regRowid);\n  }\n\n\n  if( bOnePass==0 ){\n    /* End the virtual table scan */\n    sqlite3WhereEnd(pWInfo);\n\n    /* Begin scannning through the ephemeral table. */\n    addr = sqlite3VdbeAddOp1(v, OP_Rewind, ephemTab); VdbeCoverage(v);\n\n    /* Extract arguments from the current row of the ephemeral table and \n    ** invoke the VUpdate method.  */\n    for(i=0; i<nArg; i++){\n      sqlite3VdbeAddOp3(v, OP_Column, ephemTab, i, regArg+i);\n    }\n  }\n  sqlite3VtabMakeWritable(pParse, pTab);\n  sqlite3VdbeAddOp4(v, OP_VUpdate, 0, nArg, regArg, pVTab, P4_VTAB);\n  sqlite3VdbeChangeP5(v, onError==OE_Default ? OE_Abort : onError);\n  sqlite3MayAbort(pParse);\n\n  /* End of the ephemeral table scan. Or, if using the onepass strategy,\n  ** jump to here if the scan visited zero rows. */\n  if( bOnePass==0 ){\n    sqlite3VdbeAddOp2(v, OP_Next, ephemTab, addr+1); VdbeCoverage(v);\n    sqlite3VdbeJumpHere(v, addr);\n    sqlite3VdbeAddOp2(v, OP_Close, ephemTab, 0);\n  }else{\n    sqlite3WhereEnd(pWInfo);\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/utf.c",
    "content": "/*\n** 2004 April 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used to translate between UTF-8, \n** UTF-16, UTF-16BE, and UTF-16LE.\n**\n** Notes on UTF-8:\n**\n**   Byte-0    Byte-1    Byte-2    Byte-3    Value\n**  0xxxxxxx                                 00000000 00000000 0xxxxxxx\n**  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx\n**  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx\n**  11110uuu  10uuzzzz  10yyyyyy  10xxxxxx   000uuuuu zzzzyyyy yyxxxxxx\n**\n**\n** Notes on UTF-16:  (with wwww+1==uuuuu)\n**\n**      Word-0               Word-1          Value\n**  110110ww wwzzzzyy   110111yy yyxxxxxx    000uuuuu zzzzyyyy yyxxxxxx\n**  zzzzyyyy yyxxxxxx                        00000000 zzzzyyyy yyxxxxxx\n**\n**\n** BOM or Byte Order Mark:\n**     0xff 0xfe   little-endian utf-16 follows\n**     0xfe 0xff   big-endian utf-16 follows\n**\n*/\n#include \"sqliteInt.h\"\n#include <assert.h>\n#include \"vdbeInt.h\"\n\n#if !defined(SQLITE_AMALGAMATION) && SQLITE_BYTEORDER==0\n/*\n** The following constant value is used by the SQLITE_BIGENDIAN and\n** SQLITE_LITTLEENDIAN macros.\n*/\nconst int sqlite3one = 1;\n#endif /* SQLITE_AMALGAMATION && SQLITE_BYTEORDER==0 */\n\n/*\n** This lookup table is used to help decode the first byte of\n** a multi-byte UTF8 character.\n*/\nstatic const unsigned char sqlite3Utf8Trans1[] = {\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n  0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00,\n};\n\n\n#define WRITE_UTF8(zOut, c) {                          \\\n  if( c<0x00080 ){                                     \\\n    *zOut++ = (u8)(c&0xFF);                            \\\n  }                                                    \\\n  else if( c<0x00800 ){                                \\\n    *zOut++ = 0xC0 + (u8)((c>>6)&0x1F);                \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n  else if( c<0x10000 ){                                \\\n    *zOut++ = 0xE0 + (u8)((c>>12)&0x0F);               \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }else{                                               \\\n    *zOut++ = 0xF0 + (u8)((c>>18) & 0x07);             \\\n    *zOut++ = 0x80 + (u8)((c>>12) & 0x3F);             \\\n    *zOut++ = 0x80 + (u8)((c>>6) & 0x3F);              \\\n    *zOut++ = 0x80 + (u8)(c & 0x3F);                   \\\n  }                                                    \\\n}\n\n#define WRITE_UTF16LE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n  }else{                                                            \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n  }                                                                 \\\n}\n\n#define WRITE_UTF16BE(zOut, c) {                                    \\\n  if( c<=0xFFFF ){                                                  \\\n    *zOut++ = (u8)((c>>8)&0x00FF);                                  \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }else{                                                            \\\n    *zOut++ = (u8)(0x00D8 + (((c-0x10000)>>18)&0x03));              \\\n    *zOut++ = (u8)(((c>>10)&0x003F) + (((c-0x10000)>>10)&0x00C0));  \\\n    *zOut++ = (u8)(0x00DC + ((c>>8)&0x03));                         \\\n    *zOut++ = (u8)(c&0x00FF);                                       \\\n  }                                                                 \\\n}\n\n#define READ_UTF16LE(zIn, TERM, c){                                   \\\n  c = (*zIn++);                                                       \\\n  c += ((*zIn++)<<8);                                                 \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = (*zIn++);                                                \\\n    c2 += ((*zIn++)<<8);                                              \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n#define READ_UTF16BE(zIn, TERM, c){                                   \\\n  c = ((*zIn++)<<8);                                                  \\\n  c += (*zIn++);                                                      \\\n  if( c>=0xD800 && c<0xE000 && TERM ){                                \\\n    int c2 = ((*zIn++)<<8);                                           \\\n    c2 += (*zIn++);                                                   \\\n    c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);   \\\n  }                                                                   \\\n}\n\n/*\n** Translate a single UTF-8 character.  Return the unicode value.\n**\n** During translation, assume that the byte that zTerm points\n** is a 0x00.\n**\n** Write a pointer to the next unread byte back into *pzNext.\n**\n** Notes On Invalid UTF-8:\n**\n**  *  This routine never allows a 7-bit character (0x00 through 0x7f) to\n**     be encoded as a multi-byte character.  Any multi-byte character that\n**     attempts to encode a value between 0x00 and 0x7f is rendered as 0xfffd.\n**\n**  *  This routine never allows a UTF16 surrogate value to be encoded.\n**     If a multi-byte character attempts to encode a value between\n**     0xd800 and 0xe000 then it is rendered as 0xfffd.\n**\n**  *  Bytes in the range of 0x80 through 0xbf which occur as the first\n**     byte of a character are interpreted as single-byte characters\n**     and rendered as themselves even though they are technically\n**     invalid characters.\n**\n**  *  This routine accepts over-length UTF8 encodings\n**     for unicode values 0x80 and greater.  It does not change over-length\n**     encodings to 0xfffd as some systems recommend.\n*/\n#define READ_UTF8(zIn, zTerm, c)                           \\\n  c = *(zIn++);                                            \\\n  if( c>=0xc0 ){                                           \\\n    c = sqlite3Utf8Trans1[c-0xc0];                         \\\n    while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \\\n      c = (c<<6) + (0x3f & *(zIn++));                      \\\n    }                                                      \\\n    if( c<0x80                                             \\\n        || (c&0xFFFFF800)==0xD800                          \\\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }        \\\n  }\nu32 sqlite3Utf8Read(\n  const unsigned char **pz    /* Pointer to string from which to read char */\n){\n  unsigned int c;\n\n  /* Same as READ_UTF8() above but without the zTerm parameter.\n  ** For this routine, we assume the UTF8 string is always zero-terminated.\n  */\n  c = *((*pz)++);\n  if( c>=0xc0 ){\n    c = sqlite3Utf8Trans1[c-0xc0];\n    while( (*(*pz) & 0xc0)==0x80 ){\n      c = (c<<6) + (0x3f & *((*pz)++));\n    }\n    if( c<0x80\n        || (c&0xFFFFF800)==0xD800\n        || (c&0xFFFFFFFE)==0xFFFE ){  c = 0xFFFD; }\n  }\n  return c;\n}\n\n\n\n\n/*\n** If the TRANSLATE_TRACE macro is defined, the value of each Mem is\n** printed on stderr on the way into and out of sqlite3VdbeMemTranslate().\n*/ \n/* #define TRANSLATE_TRACE 1 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine transforms the internal text encoding used by pMem to\n** desiredEnc. It is an error if the string is already of the desired\n** encoding, or if *pMem does not contain a string value.\n*/\nSQLITE_NOINLINE int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){\n  int len;                    /* Maximum length of output string in bytes */\n  unsigned char *zOut;                  /* Output buffer */\n  unsigned char *zIn;                   /* Input iterator */\n  unsigned char *zTerm;                 /* End of input */\n  unsigned char *z;                     /* Output iterator */\n  unsigned int c;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( pMem->flags&MEM_Str );\n  assert( pMem->enc!=desiredEnc );\n  assert( pMem->enc!=0 );\n  assert( pMem->n>=0 );\n\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"INPUT:  %s\\n\", zBuf);\n  }\n#endif\n\n  /* If the translation is between UTF-16 little and big endian, then \n  ** all that is required is to swap the byte order. This case is handled\n  ** differently from the others.\n  */\n  if( pMem->enc!=SQLITE_UTF8 && desiredEnc!=SQLITE_UTF8 ){\n    u8 temp;\n    int rc;\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc!=SQLITE_OK ){\n      assert( rc==SQLITE_NOMEM );\n      return SQLITE_NOMEM_BKPT;\n    }\n    zIn = (u8*)pMem->z;\n    zTerm = &zIn[pMem->n&~1];\n    while( zIn<zTerm ){\n      temp = *zIn;\n      *zIn = *(zIn+1);\n      zIn++;\n      *zIn++ = temp;\n    }\n    pMem->enc = desiredEnc;\n    goto translate_out;\n  }\n\n  /* Set len to the maximum number of bytes required in the output buffer. */\n  if( desiredEnc==SQLITE_UTF8 ){\n    /* When converting from UTF-16, the maximum growth results from\n    ** translating a 2-byte character to a 4-byte UTF-8 character.\n    ** A single byte is required for the output string\n    ** nul-terminator.\n    */\n    pMem->n &= ~1;\n    len = pMem->n * 2 + 1;\n  }else{\n    /* When converting from UTF-8 to UTF-16 the maximum growth is caused\n    ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16\n    ** character. Two bytes are required in the output buffer for the\n    ** nul-terminator.\n    */\n    len = pMem->n * 2 + 2;\n  }\n\n  /* Set zIn to point at the start of the input buffer and zTerm to point 1\n  ** byte past the end.\n  **\n  ** Variable zOut is set to point at the output buffer, space obtained\n  ** from sqlite3_malloc().\n  */\n  zIn = (u8*)pMem->z;\n  zTerm = &zIn[pMem->n];\n  zOut = sqlite3DbMallocRaw(pMem->db, len);\n  if( !zOut ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  z = zOut;\n\n  if( pMem->enc==SQLITE_UTF8 ){\n    if( desiredEnc==SQLITE_UTF16LE ){\n      /* UTF-8 -> UTF-16 Little-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16LE(z, c);\n      }\n    }else{\n      assert( desiredEnc==SQLITE_UTF16BE );\n      /* UTF-8 -> UTF-16 Big-endian */\n      while( zIn<zTerm ){\n        READ_UTF8(zIn, zTerm, c);\n        WRITE_UTF16BE(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n    *z++ = 0;\n  }else{\n    assert( desiredEnc==SQLITE_UTF8 );\n    if( pMem->enc==SQLITE_UTF16LE ){\n      /* UTF-16 Little-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16LE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }else{\n      /* UTF-16 Big-endian -> UTF-8 */\n      while( zIn<zTerm ){\n        READ_UTF16BE(zIn, zIn<zTerm, c); \n        WRITE_UTF8(z, c);\n      }\n    }\n    pMem->n = (int)(z - zOut);\n  }\n  *z = 0;\n  assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );\n\n  c = pMem->flags;\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Str|MEM_Term|(c&(MEM_AffMask|MEM_Subtype));\n  pMem->enc = desiredEnc;\n  pMem->z = (char*)zOut;\n  pMem->zMalloc = pMem->z;\n  pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->z);\n\ntranslate_out:\n#if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG)\n  {\n    char zBuf[100];\n    sqlite3VdbeMemPrettyPrint(pMem, zBuf);\n    fprintf(stderr, \"OUTPUT: %s\\n\", zBuf);\n  }\n#endif\n  return SQLITE_OK;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** This routine checks for a byte-order mark at the beginning of the \n** UTF-16 string stored in *pMem. If one is present, it is removed and\n** the encoding of the Mem adjusted. This routine does not do any\n** byte-swapping, it just sets Mem.enc appropriately.\n**\n** The allocation (static, dynamic etc.) and encoding of the Mem may be\n** changed by this function.\n*/\nint sqlite3VdbeMemHandleBom(Mem *pMem){\n  int rc = SQLITE_OK;\n  u8 bom = 0;\n\n  assert( pMem->n>=0 );\n  if( pMem->n>1 ){\n    u8 b1 = *(u8 *)pMem->z;\n    u8 b2 = *(((u8 *)pMem->z) + 1);\n    if( b1==0xFE && b2==0xFF ){\n      bom = SQLITE_UTF16BE;\n    }\n    if( b1==0xFF && b2==0xFE ){\n      bom = SQLITE_UTF16LE;\n    }\n  }\n  \n  if( bom ){\n    rc = sqlite3VdbeMemMakeWriteable(pMem);\n    if( rc==SQLITE_OK ){\n      pMem->n -= 2;\n      memmove(pMem->z, &pMem->z[2], pMem->n);\n      pMem->z[pMem->n] = '\\0';\n      pMem->z[pMem->n+1] = '\\0';\n      pMem->flags |= MEM_Term;\n      pMem->enc = bom;\n    }\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,\n** return the number of unicode characters in pZ up to (but not including)\n** the first 0x00 byte. If nByte is not less than zero, return the\n** number of unicode characters in the first nByte of pZ (or up to \n** the first 0x00, whichever comes first).\n*/\nint sqlite3Utf8CharLen(const char *zIn, int nByte){\n  int r = 0;\n  const u8 *z = (const u8*)zIn;\n  const u8 *zTerm;\n  if( nByte>=0 ){\n    zTerm = &z[nByte];\n  }else{\n    zTerm = (const u8*)(-1);\n  }\n  assert( z<=zTerm );\n  while( *z!=0 && z<zTerm ){\n    SQLITE_SKIP_UTF8(z);\n    r++;\n  }\n  return r;\n}\n\n/* This test function is not currently used by the automated test-suite. \n** Hence it is only available in debug builds.\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Translate UTF-8 to UTF-8.\n**\n** This has the effect of making sure that the string is well-formed\n** UTF-8.  Miscoded characters are removed.\n**\n** The translation is done in-place and aborted if the output\n** overruns the input.\n*/\nint sqlite3Utf8To8(unsigned char *zIn){\n  unsigned char *zOut = zIn;\n  unsigned char *zStart = zIn;\n  u32 c;\n\n  while( zIn[0] && zOut<=zIn ){\n    c = sqlite3Utf8Read((const u8**)&zIn);\n    if( c!=0xfffd ){\n      WRITE_UTF8(zOut, c);\n    }\n  }\n  *zOut = 0;\n  return (int)(zOut - zStart);\n}\n#endif\n\n#ifndef SQLITE_OMIT_UTF16\n/*\n** Convert a UTF-16 string in the native encoding into a UTF-8 string.\n** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must\n** be freed by the calling function.\n**\n** NULL is returned if there is an allocation error.\n*/\nchar *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){\n  Mem m;\n  memset(&m, 0, sizeof(m));\n  m.db = db;\n  sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);\n  sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);\n  if( db->mallocFailed ){\n    sqlite3VdbeMemRelease(&m);\n    m.z = 0;\n  }\n  assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );\n  assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );\n  assert( m.z || db->mallocFailed );\n  return m.z;\n}\n\n/*\n** zIn is a UTF-16 encoded unicode string at least nChar characters long.\n** Return the number of bytes in the first nChar unicode characters\n** in pZ.  nChar must be non-negative.\n*/\nint sqlite3Utf16ByteLen(const void *zIn, int nChar){\n  int c;\n  unsigned char const *z = zIn;\n  int n = 0;\n  \n  if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){\n    while( n<nChar ){\n      READ_UTF16BE(z, 1, c);\n      n++;\n    }\n  }else{\n    while( n<nChar ){\n      READ_UTF16LE(z, 1, c);\n      n++;\n    }\n  }\n  return (int)(z-(unsigned char const *)zIn);\n}\n\n#if defined(SQLITE_TEST)\n/*\n** This routine is called from the TCL test function \"translate_selftest\".\n** It checks that the primitives for serializing and deserializing\n** characters in each encoding are inverses of each other.\n*/\nvoid sqlite3UtfSelfTest(void){\n  unsigned int i, t;\n  unsigned char zBuf[20];\n  unsigned char *z;\n  int n;\n  unsigned int c;\n\n  for(i=0; i<0x00110000; i++){\n    z = zBuf;\n    WRITE_UTF8(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    c = sqlite3Utf8Read((const u8**)&z);\n    t = i;\n    if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD;\n    if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD;\n    assert( c==t );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16LE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16LE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n  for(i=0; i<0x00110000; i++){\n    if( i>=0xD800 && i<0xE000 ) continue;\n    z = zBuf;\n    WRITE_UTF16BE(z, i);\n    n = (int)(z-zBuf);\n    assert( n>0 && n<=4 );\n    z[0] = 0;\n    z = zBuf;\n    READ_UTF16BE(z, 1, c);\n    assert( c==i );\n    assert( (z-zBuf)==n );\n  }\n}\n#endif /* SQLITE_TEST */\n#endif /* SQLITE_OMIT_UTF16 */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/util.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Utility functions used throughout sqlite.\n**\n** This file contains functions for allocating memory, comparing\n** strings, and stuff like that.\n**\n*/\n#include \"sqliteInt.h\"\n#include <stdarg.h>\n#if HAVE_ISNAN || SQLITE_HAVE_ISNAN\n# include <math.h>\n#endif\n\n/*\n** Routine needed to support the testcase() macro.\n*/\n#ifdef SQLITE_COVERAGE_TEST\nvoid sqlite3Coverage(int x){\n  static unsigned dummy = 0;\n  dummy += (unsigned)x;\n}\n#endif\n\n/*\n** Give a callback to the test harness that can be used to simulate faults\n** in places where it is difficult or expensive to do so purely by means\n** of inputs.\n**\n** The intent of the integer argument is to let the fault simulator know\n** which of multiple sqlite3FaultSim() calls has been hit.\n**\n** Return whatever integer value the test callback returns, or return\n** SQLITE_OK if no test callback is installed.\n*/\n#ifndef SQLITE_UNTESTABLE\nint sqlite3FaultSim(int iTest){\n  int (*xCallback)(int) = sqlite3GlobalConfig.xTestCallback;\n  return xCallback ? xCallback(iTest) : SQLITE_OK;\n}\n#endif\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Return true if the floating point value is Not a Number (NaN).\n**\n** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.\n** Otherwise, we have our own implementation that works on most systems.\n*/\nint sqlite3IsNaN(double x){\n  int rc;   /* The value return */\n#if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN\n  /*\n  ** Systems that support the isnan() library function should probably\n  ** make use of it by compiling with -DSQLITE_HAVE_ISNAN.  But we have\n  ** found that many systems do not have a working isnan() function so\n  ** this implementation is provided as an alternative.\n  **\n  ** This NaN test sometimes fails if compiled on GCC with -ffast-math.\n  ** On the other hand, the use of -ffast-math comes with the following\n  ** warning:\n  **\n  **      This option [-ffast-math] should never be turned on by any\n  **      -O option since it can result in incorrect output for programs\n  **      which depend on an exact implementation of IEEE or ISO \n  **      rules/specifications for math functions.\n  **\n  ** Under MSVC, this NaN test may fail if compiled with a floating-\n  ** point precision mode other than /fp:precise.  From the MSDN \n  ** documentation:\n  **\n  **      The compiler [with /fp:precise] will properly handle comparisons \n  **      involving NaN. For example, x != x evaluates to true if x is NaN \n  **      ...\n  */\n#ifdef __FAST_MATH__\n# error SQLite will not work correctly with the -ffast-math option of GCC.\n#endif\n  volatile double y = x;\n  volatile double z = y;\n  rc = (y!=z);\n#else  /* if HAVE_ISNAN */\n  rc = isnan(x);\n#endif /* HAVE_ISNAN */\n  testcase( rc );\n  return rc;\n}\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n\n/*\n** Compute a string length that is limited to what can be stored in\n** lower 30 bits of a 32-bit signed integer.\n**\n** The value returned will never be negative.  Nor will it ever be greater\n** than the actual length of the string.  For very long strings (greater\n** than 1GiB) the value returned might be less than the true string length.\n*/\nint sqlite3Strlen30(const char *z){\n  if( z==0 ) return 0;\n  return 0x3fffffff & (int)strlen(z);\n}\n\n/*\n** Return the declared type of a column.  Or return zDflt if the column \n** has no declared type.\n**\n** The column type is an extra string stored after the zero-terminator on\n** the column name if and only if the COLFLAG_HASTYPE flag is set.\n*/\nchar *sqlite3ColumnType(Column *pCol, char *zDflt){\n  if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt;\n  return pCol->zName + strlen(pCol->zName) + 1;\n}\n\n/*\n** Helper function for sqlite3Error() - called rarely.  Broken out into\n** a separate routine to avoid unnecessary register saves on entry to\n** sqlite3Error().\n*/\nstatic SQLITE_NOINLINE void  sqlite3ErrorFinish(sqlite3 *db, int err_code){\n  if( db->pErr ) sqlite3ValueSetNull(db->pErr);\n  sqlite3SystemError(db, err_code);\n}\n\n/*\n** Set the current error code to err_code and clear any prior error message.\n** Also set iSysErrno (by calling sqlite3System) if the err_code indicates\n** that would be appropriate.\n*/\nvoid sqlite3Error(sqlite3 *db, int err_code){\n  assert( db!=0 );\n  db->errCode = err_code;\n  if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);\n}\n\n/*\n** Load the sqlite3.iSysErrno field if that is an appropriate thing\n** to do based on the SQLite error code in rc.\n*/\nvoid sqlite3SystemError(sqlite3 *db, int rc){\n  if( rc==SQLITE_IOERR_NOMEM ) return;\n  rc &= 0xff;\n  if( rc==SQLITE_CANTOPEN || rc==SQLITE_IOERR ){\n    db->iSysErrno = sqlite3OsGetLastError(db->pVfs);\n  }\n}\n\n/*\n** Set the most recent error code and error string for the sqlite\n** handle \"db\". The error code is set to \"err_code\".\n**\n** If it is not NULL, string zFormat specifies the format of the\n** error string in the style of the printf functions: The following\n** format characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** zFormat and any string tokens that follow it are assumed to be\n** encoded in UTF-8.\n**\n** To clear the most recent error for sqlite handle \"db\", sqlite3Error\n** should be called with err_code set to SQLITE_OK and zFormat set\n** to NULL.\n*/\nvoid sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *zFormat, ...){\n  assert( db!=0 );\n  db->errCode = err_code;\n  sqlite3SystemError(db, err_code);\n  if( zFormat==0 ){\n    sqlite3Error(db, err_code);\n  }else if( db->pErr || (db->pErr = sqlite3ValueNew(db))!=0 ){\n    char *z;\n    va_list ap;\n    va_start(ap, zFormat);\n    z = sqlite3VMPrintf(db, zFormat, ap);\n    va_end(ap);\n    sqlite3ValueSetStr(db->pErr, -1, z, SQLITE_UTF8, SQLITE_DYNAMIC);\n  }\n}\n\n/*\n** Add an error message to pParse->zErrMsg and increment pParse->nErr.\n** The following formatting characters are allowed:\n**\n**      %s      Insert a string\n**      %z      A string that should be freed after use\n**      %d      Insert an integer\n**      %T      Insert a token\n**      %S      Insert the first element of a SrcList\n**\n** This function should be used to report any error that occurs while\n** compiling an SQL statement (i.e. within sqlite3_prepare()). The\n** last thing the sqlite3_prepare() function does is copy the error\n** stored by this function into the database handle using sqlite3Error().\n** Functions sqlite3Error() or sqlite3ErrorWithMsg() should be used\n** during statement execution (sqlite3_step() etc.).\n*/\nvoid sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){\n  char *zMsg;\n  va_list ap;\n  sqlite3 *db = pParse->db;\n  va_start(ap, zFormat);\n  zMsg = sqlite3VMPrintf(db, zFormat, ap);\n  va_end(ap);\n  if( db->suppressErr ){\n    sqlite3DbFree(db, zMsg);\n  }else{\n    pParse->nErr++;\n    sqlite3DbFree(db, pParse->zErrMsg);\n    pParse->zErrMsg = zMsg;\n    pParse->rc = SQLITE_ERROR;\n  }\n}\n\n/*\n** Convert an SQL-style quoted string into a normal string by removing\n** the quote characters.  The conversion is done in-place.  If the\n** input does not begin with a quote character, then this routine\n** is a no-op.\n**\n** The input string must be zero-terminated.  A new zero-terminator\n** is added to the dequoted string.\n**\n** The return value is -1 if no dequoting occurs or the length of the\n** dequoted string, exclusive of the zero terminator, if dequoting does\n** occur.\n**\n** 2002-Feb-14: This routine is extended to remove MS-Access style\n** brackets from around identifiers.  For example:  \"[a-b-c]\" becomes\n** \"a-b-c\".\n*/\nvoid sqlite3Dequote(char *z){\n  char quote;\n  int i, j;\n  if( z==0 ) return;\n  quote = z[0];\n  if( !sqlite3Isquote(quote) ) return;\n  if( quote=='[' ) quote = ']';\n  for(i=1, j=0;; i++){\n    assert( z[i] );\n    if( z[i]==quote ){\n      if( z[i+1]==quote ){\n        z[j++] = quote;\n        i++;\n      }else{\n        break;\n      }\n    }else{\n      z[j++] = z[i];\n    }\n  }\n  z[j] = 0;\n}\n\n/*\n** Generate a Token object from a string\n*/\nvoid sqlite3TokenInit(Token *p, char *z){\n  p->z = z;\n  p->n = sqlite3Strlen30(z);\n}\n\n/* Convenient short-hand */\n#define UpperToLower sqlite3UpperToLower\n\n/*\n** Some systems have stricmp().  Others have strcasecmp().  Because\n** there is no consistency, we will define our own.\n**\n** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and\n** sqlite3_strnicmp() APIs allow applications and extensions to compare\n** the contents of two buffers containing UTF-8 strings in a\n** case-independent fashion, using the same definition of \"case\n** independence\" that SQLite uses internally when comparing identifiers.\n*/\nint sqlite3_stricmp(const char *zLeft, const char *zRight){\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  return sqlite3StrICmp(zLeft, zRight);\n}\nint sqlite3StrICmp(const char *zLeft, const char *zRight){\n  unsigned char *a, *b;\n  int c;\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  for(;;){\n    c = (int)UpperToLower[*a] - (int)UpperToLower[*b];\n    if( c || *a==0 ) break;\n    a++;\n    b++;\n  }\n  return c;\n}\nint sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){\n  register unsigned char *a, *b;\n  if( zLeft==0 ){\n    return zRight ? -1 : 0;\n  }else if( zRight==0 ){\n    return 1;\n  }\n  a = (unsigned char *)zLeft;\n  b = (unsigned char *)zRight;\n  while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }\n  return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];\n}\n\n/*\n** The string z[] is an text representation of a real number.\n** Convert this string to a double and write it into *pResult.\n**\n** The string z[] is length bytes in length (bytes, not characters) and\n** uses the encoding enc.  The string is not necessarily zero-terminated.\n**\n** Return TRUE if the result is a valid real number (or integer) and FALSE\n** if the string is empty or contains extraneous text.  Valid numbers\n** are in one of these formats:\n**\n**    [+-]digits[E[+-]digits]\n**    [+-]digits.[digits][E[+-]digits]\n**    [+-].digits[E[+-]digits]\n**\n** Leading and trailing whitespace is ignored for the purpose of determining\n** validity.\n**\n** If some prefix of the input string is a valid number, this routine\n** returns FALSE but it still converts the prefix and writes the result\n** into *pResult.\n*/\nint sqlite3AtoF(const char *z, double *pResult, int length, u8 enc){\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  int incr;\n  const char *zEnd = z + length;\n  /* sign * significand * (10 ^ (esign * exponent)) */\n  int sign = 1;    /* sign of significand */\n  i64 s = 0;       /* significand */\n  int d = 0;       /* adjust exponent for shifting decimal point */\n  int esign = 1;   /* sign of exponent */\n  int e = 0;       /* exponent */\n  int eValid = 1;  /* True exponent is either not used or is well-formed */\n  double result;\n  int nDigits = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  *pResult = 0.0;   /* Default return value, in case of an error */\n\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    int i;\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && z[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &z[i^1];\n    z += (enc&1);\n  }\n\n  /* skip leading spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n  if( z>=zEnd ) return 0;\n\n  /* get sign of significand */\n  if( *z=='-' ){\n    sign = -1;\n    z+=incr;\n  }else if( *z=='+' ){\n    z+=incr;\n  }\n\n  /* copy max significant digits to significand */\n  while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){\n    s = s*10 + (*z - '0');\n    z+=incr, nDigits++;\n  }\n\n  /* skip non-significant significand digits\n  ** (increase exponent by d to shift decimal left) */\n  while( z<zEnd && sqlite3Isdigit(*z) ) z+=incr, nDigits++, d++;\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if decimal point is present */\n  if( *z=='.' ){\n    z+=incr;\n    /* copy digits from after decimal to significand\n    ** (decrease exponent by d to shift decimal right) */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      if( s<((LARGEST_INT64-9)/10) ){\n        s = s*10 + (*z - '0');\n        d--;\n      }\n      z+=incr, nDigits++;\n    }\n  }\n  if( z>=zEnd ) goto do_atof_calc;\n\n  /* if exponent is present */\n  if( *z=='e' || *z=='E' ){\n    z+=incr;\n    eValid = 0;\n\n    /* This branch is needed to avoid a (harmless) buffer overread.  The \n    ** special comment alerts the mutation tester that the correct answer\n    ** is obtained even if the branch is omitted */\n    if( z>=zEnd ) goto do_atof_calc;              /*PREVENTS-HARMLESS-OVERREAD*/\n\n    /* get sign of exponent */\n    if( *z=='-' ){\n      esign = -1;\n      z+=incr;\n    }else if( *z=='+' ){\n      z+=incr;\n    }\n    /* copy digits to exponent */\n    while( z<zEnd && sqlite3Isdigit(*z) ){\n      e = e<10000 ? (e*10 + (*z - '0')) : 10000;\n      z+=incr;\n      eValid = 1;\n    }\n  }\n\n  /* skip trailing spaces */\n  while( z<zEnd && sqlite3Isspace(*z) ) z+=incr;\n\ndo_atof_calc:\n  /* adjust exponent by d, and update sign */\n  e = (e*esign) + d;\n  if( e<0 ) {\n    esign = -1;\n    e *= -1;\n  } else {\n    esign = 1;\n  }\n\n  if( s==0 ) {\n    /* In the IEEE 754 standard, zero is signed. */\n    result = sign<0 ? -(double)0 : (double)0;\n  } else {\n    /* Attempt to reduce exponent.\n    **\n    ** Branches that are not required for the correct answer but which only\n    ** help to obtain the correct answer faster are marked with special\n    ** comments, as a hint to the mutation tester.\n    */\n    while( e>0 ){                                       /*OPTIMIZATION-IF-TRUE*/\n      if( esign>0 ){\n        if( s>=(LARGEST_INT64/10) ) break;             /*OPTIMIZATION-IF-FALSE*/\n        s *= 10;\n      }else{\n        if( s%10!=0 ) break;                           /*OPTIMIZATION-IF-FALSE*/\n        s /= 10;\n      }\n      e--;\n    }\n\n    /* adjust the sign of significand */\n    s = sign<0 ? -s : s;\n\n    if( e==0 ){                                         /*OPTIMIZATION-IF-TRUE*/\n      result = (double)s;\n    }else{\n      LONGDOUBLE_TYPE scale = 1.0;\n      /* attempt to handle extremely small/large numbers better */\n      if( e>307 ){                                      /*OPTIMIZATION-IF-TRUE*/\n        if( e<342 ){                                    /*OPTIMIZATION-IF-TRUE*/\n          while( e%308 ) { scale *= 1.0e+1; e -= 1; }\n          if( esign<0 ){\n            result = s / scale;\n            result /= 1.0e+308;\n          }else{\n            result = s * scale;\n            result *= 1.0e+308;\n          }\n        }else{ assert( e>=342 );\n          if( esign<0 ){\n            result = 0.0*s;\n          }else{\n#ifdef INFINITY\n            result = INFINITY*s;\n#else\n            result = 1e308*1e308*s;  /* Infinity */\n#endif\n          }\n        }\n      }else{\n        /* 1.0e+22 is the largest power of 10 than can be \n        ** represented exactly. */\n        while( e%22 ) { scale *= 1.0e+1; e -= 1; }\n        while( e>0 ) { scale *= 1.0e+22; e -= 22; }\n        if( esign<0 ){\n          result = s / scale;\n        }else{\n          result = s * scale;\n        }\n      }\n    }\n  }\n\n  /* store the result */\n  *pResult = result;\n\n  /* return true if number and no extra non-whitespace chracters after */\n  return z==zEnd && nDigits>0 && eValid && nonNum==0;\n#else\n  return !sqlite3Atoi64(z, pResult, length, enc);\n#endif /* SQLITE_OMIT_FLOATING_POINT */\n}\n\n/*\n** Compare the 19-character string zNum against the text representation\n** value 2^63:  9223372036854775808.  Return negative, zero, or positive\n** if zNum is less than, equal to, or greater than the string.\n** Note that zNum must contain exactly 19 characters.\n**\n** Unlike memcmp() this routine is guaranteed to return the difference\n** in the values of the last digit if the only difference is in the\n** last digit.  So, for example,\n**\n**      compare2pow63(\"9223372036854775800\", 1)\n**\n** will return -8.\n*/\nstatic int compare2pow63(const char *zNum, int incr){\n  int c = 0;\n  int i;\n                    /* 012345678901234567 */\n  const char *pow63 = \"922337203685477580\";\n  for(i=0; c==0 && i<18; i++){\n    c = (zNum[i*incr]-pow63[i])*10;\n  }\n  if( c==0 ){\n    c = zNum[18*incr] - '8';\n    testcase( c==(-1) );\n    testcase( c==0 );\n    testcase( c==(+1) );\n  }\n  return c;\n}\n\n/*\n** Convert zNum to a 64-bit signed integer.  zNum must be decimal. This\n** routine does *not* accept hexadecimal notation.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n**\n** length is the number of bytes in the string (bytes, not characters).\n** The string is not necessarily zero-terminated.  The encoding is\n** given by enc.\n*/\nint sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){\n  int incr;\n  u64 u = 0;\n  int neg = 0; /* assume positive */\n  int i;\n  int c = 0;\n  int nonNum = 0;  /* True if input contains UTF16 with high byte non-zero */\n  int rc;          /* Baseline return code */\n  const char *zStart;\n  const char *zEnd = zNum + length;\n  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );\n  if( enc==SQLITE_UTF8 ){\n    incr = 1;\n  }else{\n    incr = 2;\n    assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );\n    for(i=3-enc; i<length && zNum[i]==0; i+=2){}\n    nonNum = i<length;\n    zEnd = &zNum[i^1];\n    zNum += (enc&1);\n  }\n  while( zNum<zEnd && sqlite3Isspace(*zNum) ) zNum+=incr;\n  if( zNum<zEnd ){\n    if( *zNum=='-' ){\n      neg = 1;\n      zNum+=incr;\n    }else if( *zNum=='+' ){\n      zNum+=incr;\n    }\n  }\n  zStart = zNum;\n  while( zNum<zEnd && zNum[0]=='0' ){ zNum+=incr; } /* Skip leading zeros. */\n  for(i=0; &zNum[i]<zEnd && (c=zNum[i])>='0' && c<='9'; i+=incr){\n    u = u*10 + c - '0';\n  }\n  if( u>LARGEST_INT64 ){\n    *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64;\n  }else if( neg ){\n    *pNum = -(i64)u;\n  }else{\n    *pNum = (i64)u;\n  }\n  testcase( i==18 );\n  testcase( i==19 );\n  testcase( i==20 );\n  if( &zNum[i]<zEnd              /* Extra bytes at the end */\n   || (i==0 && zStart==zNum)     /* No digits */\n   || nonNum                     /* UTF16 with high-order bytes non-zero */\n  ){\n    rc = 1;\n  }else{\n    rc = 0;\n  }\n  if( i>19*incr ){                /* Too many digits */\n    /* zNum is empty or contains non-numeric text or is longer\n    ** than 19 digits (thus guaranteeing that it is too large) */\n    return 2;\n  }else if( i<19*incr ){\n    /* Less than 19 digits, so we know that it fits in 64 bits */\n    assert( u<=LARGEST_INT64 );\n    return rc;\n  }else{\n    /* zNum is a 19-digit numbers.  Compare it against 9223372036854775808. */\n    c = compare2pow63(zNum, incr);\n    if( c<0 ){\n      /* zNum is less than 9223372036854775808 so it fits */\n      assert( u<=LARGEST_INT64 );\n      return rc;\n    }else if( c>0 ){\n      /* zNum is greater than 9223372036854775808 so it overflows */\n      return 2;\n    }else{\n      /* zNum is exactly 9223372036854775808.  Fits if negative.  The\n      ** special case 2 overflow if positive */\n      assert( u-1==LARGEST_INT64 );\n      return neg ? rc : 3;\n    }\n  }\n}\n\n/*\n** Transform a UTF-8 integer literal, in either decimal or hexadecimal,\n** into a 64-bit signed integer.  This routine accepts hexadecimal literals,\n** whereas sqlite3Atoi64() does not.\n**\n** Returns:\n**\n**     0    Successful transformation.  Fits in a 64-bit signed integer.\n**     1    Excess text after the integer value\n**     2    Integer too large for a 64-bit signed integer or is malformed\n**     3    Special case of 9223372036854775808\n*/\nint sqlite3DecOrHexToI64(const char *z, i64 *pOut){\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  if( z[0]=='0'\n   && (z[1]=='x' || z[1]=='X')\n  ){\n    u64 u = 0;\n    int i, k;\n    for(i=2; z[i]=='0'; i++){}\n    for(k=i; sqlite3Isxdigit(z[k]); k++){\n      u = u*16 + sqlite3HexToInt(z[k]);\n    }\n    memcpy(pOut, &u, 8);\n    return (z[k]==0 && k-i<=16) ? 0 : 2;\n  }else\n#endif /* SQLITE_OMIT_HEX_INTEGER */\n  {\n    return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8);\n  }\n}\n\n/*\n** If zNum represents an integer that will fit in 32-bits, then set\n** *pValue to that integer and return true.  Otherwise return false.\n**\n** This routine accepts both decimal and hexadecimal notation for integers.\n**\n** Any non-numeric characters that following zNum are ignored.\n** This is different from sqlite3Atoi64() which requires the\n** input number to be zero-terminated.\n*/\nint sqlite3GetInt32(const char *zNum, int *pValue){\n  sqlite_int64 v = 0;\n  int i, c;\n  int neg = 0;\n  if( zNum[0]=='-' ){\n    neg = 1;\n    zNum++;\n  }else if( zNum[0]=='+' ){\n    zNum++;\n  }\n#ifndef SQLITE_OMIT_HEX_INTEGER\n  else if( zNum[0]=='0'\n        && (zNum[1]=='x' || zNum[1]=='X')\n        && sqlite3Isxdigit(zNum[2])\n  ){\n    u32 u = 0;\n    zNum += 2;\n    while( zNum[0]=='0' ) zNum++;\n    for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){\n      u = u*16 + sqlite3HexToInt(zNum[i]);\n    }\n    if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){\n      memcpy(pValue, &u, 4);\n      return 1;\n    }else{\n      return 0;\n    }\n  }\n#endif\n  if( !sqlite3Isdigit(zNum[0]) ) return 0;\n  while( zNum[0]=='0' ) zNum++;\n  for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){\n    v = v*10 + c;\n  }\n\n  /* The longest decimal representation of a 32 bit integer is 10 digits:\n  **\n  **             1234567890\n  **     2^31 -> 2147483648\n  */\n  testcase( i==10 );\n  if( i>10 ){\n    return 0;\n  }\n  testcase( v-neg==2147483647 );\n  if( v-neg>2147483647 ){\n    return 0;\n  }\n  if( neg ){\n    v = -v;\n  }\n  *pValue = (int)v;\n  return 1;\n}\n\n/*\n** Return a 32-bit integer value extracted from a string.  If the\n** string is not an integer, just return 0.\n*/\nint sqlite3Atoi(const char *z){\n  int x = 0;\n  if( z ) sqlite3GetInt32(z, &x);\n  return x;\n}\n\n/*\n** The variable-length integer encoding is as follows:\n**\n** KEY:\n**         A = 0xxxxxxx    7 bits of data and one flag bit\n**         B = 1xxxxxxx    7 bits of data and one flag bit\n**         C = xxxxxxxx    8 bits of data\n**\n**  7 bits - A\n** 14 bits - BA\n** 21 bits - BBA\n** 28 bits - BBBA\n** 35 bits - BBBBA\n** 42 bits - BBBBBA\n** 49 bits - BBBBBBA\n** 56 bits - BBBBBBBA\n** 64 bits - BBBBBBBBC\n*/\n\n/*\n** Write a 64-bit variable-length integer to memory starting at p[0].\n** The length of data write will be between 1 and 9 bytes.  The number\n** of bytes written is returned.\n**\n** A variable-length integer consists of the lower 7 bits of each byte\n** for all bytes that have the 8th bit set and one byte with the 8th\n** bit clear.  Except, if we get to the 9th byte, it stores the full\n** 8 bits and is the last byte.\n*/\nstatic int SQLITE_NOINLINE putVarint64(unsigned char *p, u64 v){\n  int i, j, n;\n  u8 buf[10];\n  if( v & (((u64)0xff000000)<<32) ){\n    p[8] = (u8)v;\n    v >>= 8;\n    for(i=7; i>=0; i--){\n      p[i] = (u8)((v & 0x7f) | 0x80);\n      v >>= 7;\n    }\n    return 9;\n  }    \n  n = 0;\n  do{\n    buf[n++] = (u8)((v & 0x7f) | 0x80);\n    v >>= 7;\n  }while( v!=0 );\n  buf[0] &= 0x7f;\n  assert( n<=9 );\n  for(i=0, j=n-1; j>=0; j--, i++){\n    p[i] = buf[j];\n  }\n  return n;\n}\nint sqlite3PutVarint(unsigned char *p, u64 v){\n  if( v<=0x7f ){\n    p[0] = v&0x7f;\n    return 1;\n  }\n  if( v<=0x3fff ){\n    p[0] = ((v>>7)&0x7f)|0x80;\n    p[1] = v&0x7f;\n    return 2;\n  }\n  return putVarint64(p,v);\n}\n\n/*\n** Bitmasks used by sqlite3GetVarint().  These precomputed constants\n** are defined here rather than simply putting the constant expressions\n** inline in order to work around bugs in the RVT compiler.\n**\n** SLOT_2_0     A mask for  (0x7f<<14) | 0x7f\n**\n** SLOT_4_2_0   A mask for  (0x7f<<28) | SLOT_2_0\n*/\n#define SLOT_2_0     0x001fc07f\n#define SLOT_4_2_0   0xf01fc07f\n\n\n/*\n** Read a 64-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n*/\nu8 sqlite3GetVarint(const unsigned char *p, u64 *v){\n  u32 a,b,s;\n\n  a = *p;\n  /* a: p0 (unmasked) */\n  if (!(a&0x80))\n  {\n    *v = a;\n    return 1;\n  }\n\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    a &= 0x7f;\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 2;\n  }\n\n  /* Verify that constants are precomputed correctly */\n  assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );\n  assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_2_0;\n    b &= 0x7f;\n    b = b<<7;\n    a |= b;\n    *v = a;\n    return 3;\n  }\n\n  /* CSE1 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_2_0;\n    /* moved CSE1 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    *v = a;\n    return 4;\n  }\n\n  /* a: p0<<14 | p2 (masked) */\n  /* b: p1<<14 | p3 (unmasked) */\n  /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  /* moved CSE1 up */\n  /* a &= (0x7f<<14)|(0x7f); */\n  b &= SLOT_2_0;\n  s = a;\n  /* s: p0<<14 | p2 (masked) */\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* we can skip these cause they were (effectively) done above\n    ** while calculating s */\n    /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    /* b &= (0x7f<<14)|(0x7f); */\n    b = b<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 5;\n  }\n\n  /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n  s = s<<7;\n  s |= b;\n  /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */\n\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<28 | p3<<14 | p5 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* we can skip this cause it was (effectively) done above in calc'ing s */\n    /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */\n    a &= SLOT_2_0;\n    a = a<<7;\n    a |= b;\n    s = s>>18;\n    *v = ((u64)s)<<32 | a;\n    return 6;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p2<<28 | p4<<14 | p6 (unmasked) */\n  if (!(a&0x80))\n  {\n    a &= SLOT_4_2_0;\n    b &= SLOT_2_0;\n    b = b<<7;\n    a |= b;\n    s = s>>11;\n    *v = ((u64)s)<<32 | a;\n    return 7;\n  }\n\n  /* CSE2 from below */\n  a &= SLOT_2_0;\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p3<<28 | p5<<14 | p7 (unmasked) */\n  if (!(b&0x80))\n  {\n    b &= SLOT_4_2_0;\n    /* moved CSE2 up */\n    /* a &= (0x7f<<14)|(0x7f); */\n    a = a<<7;\n    a |= b;\n    s = s>>4;\n    *v = ((u64)s)<<32 | a;\n    return 8;\n  }\n\n  p++;\n  a = a<<15;\n  a |= *p;\n  /* a: p4<<29 | p6<<15 | p8 (unmasked) */\n\n  /* moved CSE2 up */\n  /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */\n  b &= SLOT_2_0;\n  b = b<<8;\n  a |= b;\n\n  s = s<<4;\n  b = p[-4];\n  b &= 0x7f;\n  b = b>>3;\n  s |= b;\n\n  *v = ((u64)s)<<32 | a;\n\n  return 9;\n}\n\n/*\n** Read a 32-bit variable-length integer from memory starting at p[0].\n** Return the number of bytes read.  The value is stored in *v.\n**\n** If the varint stored in p[0] is larger than can fit in a 32-bit unsigned\n** integer, then set *v to 0xffffffff.\n**\n** A MACRO version, getVarint32, is provided which inlines the \n** single-byte case.  All code should use the MACRO version as \n** this function assumes the single-byte case has already been handled.\n*/\nu8 sqlite3GetVarint32(const unsigned char *p, u32 *v){\n  u32 a,b;\n\n  /* The 1-byte case.  Overwhelmingly the most common.  Handled inline\n  ** by the getVarin32() macro */\n  a = *p;\n  /* a: p0 (unmasked) */\n#ifndef getVarint32\n  if (!(a&0x80))\n  {\n    /* Values between 0 and 127 */\n    *v = a;\n    return 1;\n  }\n#endif\n\n  /* The 2-byte case */\n  p++;\n  b = *p;\n  /* b: p1 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 128 and 16383 */\n    a &= 0x7f;\n    a = a<<7;\n    *v = a | b;\n    return 2;\n  }\n\n  /* The 3-byte case */\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<14 | p2 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values between 16384 and 2097151 */\n    a &= (0x7f<<14)|(0x7f);\n    b &= 0x7f;\n    b = b<<7;\n    *v = a | b;\n    return 3;\n  }\n\n  /* A 32-bit varint is used to store size information in btrees.\n  ** Objects are rarely larger than 2MiB limit of a 3-byte varint.\n  ** A 3-byte varint is sufficient, for example, to record the size\n  ** of a 1048569-byte BLOB or string.\n  **\n  ** We only unroll the first 1-, 2-, and 3- byte cases.  The very\n  ** rare larger cases can be handled by the slower 64-bit varint\n  ** routine.\n  */\n#if 1\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 2;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>3 && n<=9 );\n    if( (v64 & SQLITE_MAX_U32)!=v64 ){\n      *v = 0xffffffff;\n    }else{\n      *v = (u32)v64;\n    }\n    return n;\n  }\n\n#else\n  /* For following code (kept for historical record only) shows an\n  ** unrolling for the 3- and 4-byte varint cases.  This code is\n  ** slightly faster, but it is also larger and much harder to test.\n  */\n  p++;\n  b = b<<14;\n  b |= *p;\n  /* b: p1<<14 | p3 (unmasked) */\n  if (!(b&0x80))\n  {\n    /* Values between 2097152 and 268435455 */\n    b &= (0x7f<<14)|(0x7f);\n    a &= (0x7f<<14)|(0x7f);\n    a = a<<7;\n    *v = a | b;\n    return 4;\n  }\n\n  p++;\n  a = a<<14;\n  a |= *p;\n  /* a: p0<<28 | p2<<14 | p4 (unmasked) */\n  if (!(a&0x80))\n  {\n    /* Values  between 268435456 and 34359738367 */\n    a &= SLOT_4_2_0;\n    b &= SLOT_4_2_0;\n    b = b<<7;\n    *v = a | b;\n    return 5;\n  }\n\n  /* We can only reach this point when reading a corrupt database\n  ** file.  In that case we are not in any hurry.  Use the (relatively\n  ** slow) general-purpose sqlite3GetVarint() routine to extract the\n  ** value. */\n  {\n    u64 v64;\n    u8 n;\n\n    p -= 4;\n    n = sqlite3GetVarint(p, &v64);\n    assert( n>5 && n<=9 );\n    *v = (u32)v64;\n    return n;\n  }\n#endif\n}\n\n/*\n** Return the number of bytes that will be needed to store the given\n** 64-bit integer.\n*/\nint sqlite3VarintLen(u64 v){\n  int i;\n  for(i=1; (v >>= 7)!=0; i++){ assert( i<10 ); }\n  return i;\n}\n\n\n/*\n** Read or write a four-byte big-endian integer value.\n*/\nu32 sqlite3Get4byte(const u8 *p){\n#if SQLITE_BYTEORDER==4321\n  u32 x;\n  memcpy(&x,p,4);\n  return x;\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x;\n  memcpy(&x,p,4);\n  return __builtin_bswap32(x);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x;\n  memcpy(&x,p,4);\n  return _byteswap_ulong(x);\n#else\n  testcase( p[0]&0x80 );\n  return ((unsigned)p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];\n#endif\n}\nvoid sqlite3Put4byte(unsigned char *p, u32 v){\n#if SQLITE_BYTEORDER==4321\n  memcpy(p,&v,4);\n#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4003000\n  u32 x = __builtin_bswap32(v);\n  memcpy(p,&x,4);\n#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300\n  u32 x = _byteswap_ulong(v);\n  memcpy(p,&x,4);\n#else\n  p[0] = (u8)(v>>24);\n  p[1] = (u8)(v>>16);\n  p[2] = (u8)(v>>8);\n  p[3] = (u8)v;\n#endif\n}\n\n\n\n/*\n** Translate a single byte of Hex into an integer.\n** This routine only works if h really is a valid hexadecimal\n** character:  0..9a..fA..F\n*/\nu8 sqlite3HexToInt(int h){\n  assert( (h>='0' && h<='9') ||  (h>='a' && h<='f') ||  (h>='A' && h<='F') );\n#ifdef SQLITE_ASCII\n  h += 9*(1&(h>>6));\n#endif\n#ifdef SQLITE_EBCDIC\n  h += 9*(1&~(h>>4));\n#endif\n  return (u8)(h & 0xf);\n}\n\n#if !defined(SQLITE_OMIT_BLOB_LITERAL) || defined(SQLITE_HAS_CODEC)\n/*\n** Convert a BLOB literal of the form \"x'hhhhhh'\" into its binary\n** value.  Return a pointer to its binary value.  Space to hold the\n** binary value has been obtained from malloc and must be freed by\n** the calling routine.\n*/\nvoid *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){\n  char *zBlob;\n  int i;\n\n  zBlob = (char *)sqlite3DbMallocRawNN(db, n/2 + 1);\n  n--;\n  if( zBlob ){\n    for(i=0; i<n; i+=2){\n      zBlob[i/2] = (sqlite3HexToInt(z[i])<<4) | sqlite3HexToInt(z[i+1]);\n    }\n    zBlob[i/2] = 0;\n  }\n  return zBlob;\n}\n#endif /* !SQLITE_OMIT_BLOB_LITERAL || SQLITE_HAS_CODEC */\n\n/*\n** Log an error that is an API call on a connection pointer that should\n** not have been used.  The \"type\" of connection pointer is given as the\n** argument.  The zType is a word like \"NULL\" or \"closed\" or \"invalid\".\n*/\nstatic void logBadConnection(const char *zType){\n  sqlite3_log(SQLITE_MISUSE, \n     \"API call with %s database connection pointer\",\n     zType\n  );\n}\n\n/*\n** Check to make sure we have a valid db pointer.  This test is not\n** foolproof but it does provide some measure of protection against\n** misuse of the interface such as passing in db pointers that are\n** NULL or which have been previously closed.  If this routine returns\n** 1 it means that the db pointer is valid and 0 if it should not be\n** dereferenced for any reason.  The calling function should invoke\n** SQLITE_MISUSE immediately.\n**\n** sqlite3SafetyCheckOk() requires that the db pointer be valid for\n** use.  sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to\n** open properly and is not fit for general use but which can be\n** used as an argument to sqlite3_errmsg() or sqlite3_close().\n*/\nint sqlite3SafetyCheckOk(sqlite3 *db){\n  u32 magic;\n  if( db==0 ){\n    logBadConnection(\"NULL\");\n    return 0;\n  }\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_OPEN ){\n    if( sqlite3SafetyCheckSickOrOk(db) ){\n      testcase( sqlite3GlobalConfig.xLog!=0 );\n      logBadConnection(\"unopened\");\n    }\n    return 0;\n  }else{\n    return 1;\n  }\n}\nint sqlite3SafetyCheckSickOrOk(sqlite3 *db){\n  u32 magic;\n  magic = db->magic;\n  if( magic!=SQLITE_MAGIC_SICK &&\n      magic!=SQLITE_MAGIC_OPEN &&\n      magic!=SQLITE_MAGIC_BUSY ){\n    testcase( sqlite3GlobalConfig.xLog!=0 );\n    logBadConnection(\"invalid\");\n    return 0;\n  }else{\n    return 1;\n  }\n}\n\n/*\n** Attempt to add, substract, or multiply the 64-bit signed value iB against\n** the other 64-bit signed integer at *pA and store the result in *pA.\n** Return 0 on success.  Or if the operation would have resulted in an\n** overflow, leave *pA unchanged and return 1.\n*/\nint sqlite3AddInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_add_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  testcase( iA==0 ); testcase( iA==1 );\n  testcase( iB==-1 ); testcase( iB==0 );\n  if( iB>=0 ){\n    testcase( iA>0 && LARGEST_INT64 - iA == iB );\n    testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 );\n    if( iA>0 && LARGEST_INT64 - iA < iB ) return 1;\n  }else{\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 );\n    testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 );\n    if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1;\n  }\n  *pA += iB;\n  return 0; \n#endif\n}\nint sqlite3SubInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_sub_overflow(*pA, iB, pA);\n#else\n  testcase( iB==SMALLEST_INT64+1 );\n  if( iB==SMALLEST_INT64 ){\n    testcase( (*pA)==(-1) ); testcase( (*pA)==0 );\n    if( (*pA)>=0 ) return 1;\n    *pA -= iB;\n    return 0;\n  }else{\n    return sqlite3AddInt64(pA, -iB);\n  }\n#endif\n}\nint sqlite3MulInt64(i64 *pA, i64 iB){\n#if GCC_VERSION>=5004000 && !defined(__INTEL_COMPILER)\n  return __builtin_mul_overflow(*pA, iB, pA);\n#else\n  i64 iA = *pA;\n  if( iB>0 ){\n    if( iA>LARGEST_INT64/iB ) return 1;\n    if( iA<SMALLEST_INT64/iB ) return 1;\n  }else if( iB<0 ){\n    if( iA>0 ){\n      if( iB<SMALLEST_INT64/iA ) return 1;\n    }else if( iA<0 ){\n      if( iB==SMALLEST_INT64 ) return 1;\n      if( iA==SMALLEST_INT64 ) return 1;\n      if( -iA>LARGEST_INT64/-iB ) return 1;\n    }\n  }\n  *pA = iA*iB;\n  return 0;\n#endif\n}\n\n/*\n** Compute the absolute value of a 32-bit signed integer, of possible.  Or \n** if the integer has a value of -2147483648, return +2147483647\n*/\nint sqlite3AbsInt32(int x){\n  if( x>=0 ) return x;\n  if( x==(int)0x80000000 ) return 0x7fffffff;\n  return -x;\n}\n\n#ifdef SQLITE_ENABLE_8_3_NAMES\n/*\n** If SQLITE_ENABLE_8_3_NAMES is set at compile-time and if the database\n** filename in zBaseFilename is a URI with the \"8_3_names=1\" parameter and\n** if filename in z[] has a suffix (a.k.a. \"extension\") that is longer than\n** three characters, then shorten the suffix on z[] to be the last three\n** characters of the original suffix.\n**\n** If SQLITE_ENABLE_8_3_NAMES is set to 2 at compile-time, then always\n** do the suffix shortening regardless of URI parameter.\n**\n** Examples:\n**\n**     test.db-journal    =>   test.nal\n**     test.db-wal        =>   test.wal\n**     test.db-shm        =>   test.shm\n**     test.db-mj7f3319fa =>   test.9fa\n*/\nvoid sqlite3FileSuffix3(const char *zBaseFilename, char *z){\n#if SQLITE_ENABLE_8_3_NAMES<2\n  if( sqlite3_uri_boolean(zBaseFilename, \"8_3_names\", 0) )\n#endif\n  {\n    int i, sz;\n    sz = sqlite3Strlen30(z);\n    for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}\n    if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);\n  }\n}\n#endif\n\n/* \n** Find (an approximate) sum of two LogEst values.  This computation is\n** not a simple \"+\" operator because LogEst is stored as a logarithmic\n** value.\n** \n*/\nLogEst sqlite3LogEstAdd(LogEst a, LogEst b){\n  static const unsigned char x[] = {\n     10, 10,                         /* 0,1 */\n      9, 9,                          /* 2,3 */\n      8, 8,                          /* 4,5 */\n      7, 7, 7,                       /* 6,7,8 */\n      6, 6, 6,                       /* 9,10,11 */\n      5, 5, 5,                       /* 12-14 */\n      4, 4, 4, 4,                    /* 15-18 */\n      3, 3, 3, 3, 3, 3,              /* 19-24 */\n      2, 2, 2, 2, 2, 2, 2,           /* 25-31 */\n  };\n  if( a>=b ){\n    if( a>b+49 ) return a;\n    if( a>b+31 ) return a+1;\n    return a+x[a-b];\n  }else{\n    if( b>a+49 ) return b;\n    if( b>a+31 ) return b+1;\n    return b+x[b-a];\n  }\n}\n\n/*\n** Convert an integer into a LogEst.  In other words, compute an\n** approximation for 10*log2(x).\n*/\nLogEst sqlite3LogEst(u64 x){\n  static LogEst a[] = { 0, 2, 3, 5, 6, 7, 8, 9 };\n  LogEst y = 40;\n  if( x<8 ){\n    if( x<2 ) return 0;\n    while( x<8 ){  y -= 10; x <<= 1; }\n  }else{\n#if GCC_VERSION>=5004000\n    int i = 60 - __builtin_clzll(x);\n    y += i*10;\n    x >>= i;\n#else\n    while( x>255 ){ y += 40; x >>= 4; }  /*OPTIMIZATION-IF-TRUE*/\n    while( x>15 ){  y += 10; x >>= 1; }\n#endif\n  }\n  return a[x&7] + y - 10;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Convert a double into a LogEst\n** In other words, compute an approximation for 10*log2(x).\n*/\nLogEst sqlite3LogEstFromDouble(double x){\n  u64 a;\n  LogEst e;\n  assert( sizeof(x)==8 && sizeof(a)==8 );\n  if( x<=1 ) return 0;\n  if( x<=2000000000 ) return sqlite3LogEst((u64)x);\n  memcpy(&a, &x, 8);\n  e = (a>>52) - 1022;\n  return e*10;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_ENABLE_STAT3_OR_STAT4) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n/*\n** Convert a LogEst into an integer.\n**\n** Note that this routine is only used when one or more of various\n** non-standard compile-time options is enabled.\n*/\nu64 sqlite3LogEstToInt(LogEst x){\n  u64 n;\n  n = x%10;\n  x /= 10;\n  if( n>=5 ) n -= 2;\n  else if( n>=1 ) n -= 1;\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \\\n    defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)\n  if( x>60 ) return (u64)LARGEST_INT64;\n#else\n  /* If only SQLITE_ENABLE_STAT3_OR_STAT4 is on, then the largest input\n  ** possible to this routine is 310, resulting in a maximum x of 31 */\n  assert( x<=60 );\n#endif\n  return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);\n}\n#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */\n\n/*\n** Add a new name/number pair to a VList.  This might require that the\n** VList object be reallocated, so return the new VList.  If an OOM\n** error occurs, the original VList returned and the\n** db->mallocFailed flag is set.\n**\n** A VList is really just an array of integers.  To destroy a VList,\n** simply pass it to sqlite3DbFree().\n**\n** The first integer is the number of integers allocated for the whole\n** VList.  The second integer is the number of integers actually used.\n** Each name/number pair is encoded by subsequent groups of 3 or more\n** integers.\n**\n** Each name/number pair starts with two integers which are the numeric\n** value for the pair and the size of the name/number pair, respectively.\n** The text name overlays one or more following integers.  The text name\n** is always zero-terminated.\n**\n** Conceptually:\n**\n**    struct VList {\n**      int nAlloc;   // Number of allocated slots \n**      int nUsed;    // Number of used slots \n**      struct VListEntry {\n**        int iValue;    // Value for this entry\n**        int nSlot;     // Slots used by this entry\n**        // ... variable name goes here\n**      } a[0];\n**    }\n**\n** During code generation, pointers to the variable names within the\n** VList are taken.  When that happens, nAlloc is set to zero as an \n** indication that the VList may never again be enlarged, since the\n** accompanying realloc() would invalidate the pointers.\n*/\nVList *sqlite3VListAdd(\n  sqlite3 *db,           /* The database connection used for malloc() */\n  VList *pIn,            /* The input VList.  Might be NULL */\n  const char *zName,     /* Name of symbol to add */\n  int nName,             /* Bytes of text in zName */\n  int iVal               /* Value to associate with zName */\n){\n  int nInt;              /* number of sizeof(int) objects needed for zName */\n  char *z;               /* Pointer to where zName will be stored */\n  int i;                 /* Index in pIn[] where zName is stored */\n\n  nInt = nName/4 + 3;\n  assert( pIn==0 || pIn[0]>=3 );  /* Verify ok to add new elements */\n  if( pIn==0 || pIn[1]+nInt > pIn[0] ){\n    /* Enlarge the allocation */\n    int nAlloc = (pIn ? pIn[0]*2 : 10) + nInt;\n    VList *pOut = sqlite3DbRealloc(db, pIn, nAlloc*sizeof(int));\n    if( pOut==0 ) return pIn;\n    if( pIn==0 ) pOut[1] = 2;\n    pIn = pOut;\n    pIn[0] = nAlloc;\n  }\n  i = pIn[1];\n  pIn[i] = iVal;\n  pIn[i+1] = nInt;\n  z = (char*)&pIn[i+2];\n  pIn[1] = i+nInt;\n  assert( pIn[1]<=pIn[0] );\n  memcpy(z, zName, nName);\n  z[nName] = 0;\n  return pIn;\n}\n\n/*\n** Return a pointer to the name of a variable in the given VList that\n** has the value iVal.  Or return a NULL if there is no such variable in\n** the list\n*/\nconst char *sqlite3VListNumToName(VList *pIn, int iVal){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    if( pIn[i]==iVal ) return (char*)&pIn[i+2];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n\n/*\n** Return the number of the variable named zName, if it is in VList.\n** or return 0 if there is no such variable.\n*/\nint sqlite3VListNameToNum(VList *pIn, const char *zName, int nName){\n  int i, mx;\n  if( pIn==0 ) return 0;\n  mx = pIn[1];\n  i = 2;\n  do{\n    const char *z = (const char*)&pIn[i+2];\n    if( strncmp(z,zName,nName)==0 && z[nName]==0 ) return pIn[i];\n    i += pIn[i+1];\n  }while( i<mx );\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vacuum.c",
    "content": "/*\n** 2003 April 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to implement the VACUUM command.\n**\n** Most of the code in this file may be omitted by defining the\n** SQLITE_OMIT_VACUUM macro.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n\n/*\n** Execute zSql on database db.\n**\n** If zSql returns rows, then each row will have exactly one\n** column.  (This will only happen if zSql begins with \"SELECT\".)\n** Take each row of result and call execSql() again recursively.\n**\n** The execSqlF() routine does the same thing, except it accepts\n** a format string as its third argument\n*/\nstatic int execSql(sqlite3 *db, char **pzErrMsg, const char *zSql){\n  sqlite3_stmt *pStmt;\n  int rc;\n\n  /* printf(\"SQL: [%s]\\n\", zSql); fflush(stdout); */\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ) return rc;\n  while( SQLITE_ROW==(rc = sqlite3_step(pStmt)) ){\n    const char *zSubSql = (const char*)sqlite3_column_text(pStmt,0);\n    assert( sqlite3_strnicmp(zSql,\"SELECT\",6)==0 );\n    if( zSubSql ){\n      assert( zSubSql[0]!='S' );\n      rc = execSql(db, pzErrMsg, zSubSql);\n      if( rc!=SQLITE_OK ) break;\n    }\n  }\n  assert( rc!=SQLITE_ROW );\n  if( rc==SQLITE_DONE ) rc = SQLITE_OK;\n  if( rc ){\n    sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db));\n  }\n  (void)sqlite3_finalize(pStmt);\n  return rc;\n}\nstatic int execSqlF(sqlite3 *db, char **pzErrMsg, const char *zSql, ...){\n  char *z;\n  va_list ap;\n  int rc;\n  va_start(ap, zSql);\n  z = sqlite3VMPrintf(db, zSql, ap);\n  va_end(ap);\n  if( z==0 ) return SQLITE_NOMEM;\n  rc = execSql(db, pzErrMsg, z);\n  sqlite3DbFree(db, z);\n  return rc;\n}\n\n/*\n** The VACUUM command is used to clean up the database,\n** collapse free space, etc.  It is modelled after the VACUUM command\n** in PostgreSQL.  The VACUUM command works as follows:\n**\n**   (1)  Create a new transient database file\n**   (2)  Copy all content from the database being vacuumed into\n**        the new transient database file\n**   (3)  Copy content from the transient database back into the\n**        original database.\n**\n** The transient database requires temporary disk space approximately\n** equal to the size of the original database.  The copy operation of\n** step (3) requires additional temporary disk space approximately equal\n** to the size of the original database for the rollback journal.\n** Hence, temporary disk space that is approximately 2x the size of the\n** original database is required.  Every page of the database is written\n** approximately 3 times:  Once for step (2) and twice for step (3).\n** Two writes per page are required in step (3) because the original\n** database content must be written into the rollback journal prior to\n** overwriting the database with the vacuumed content.\n**\n** Only 1x temporary space and only 1x writes would be required if\n** the copy of step (3) were replaced by deleting the original database\n** and renaming the transient database as the original.  But that will\n** not work if other processes are attached to the original database.\n** And a power loss in between deleting the original and renaming the\n** transient would cause the database file to appear to be deleted\n** following reboot.\n*/\nvoid sqlite3Vacuum(Parse *pParse, Token *pNm){\n  Vdbe *v = sqlite3GetVdbe(pParse);\n  int iDb = 0;\n  if( v==0 ) return;\n  if( pNm ){\n#ifndef SQLITE_BUG_COMPATIBLE_20160819\n    /* Default behavior:  Report an error if the argument to VACUUM is\n    ** not recognized */\n    iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);\n    if( iDb<0 ) return;\n#else\n    /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments\n    ** to VACUUM are silently ignored.  This is a back-out of a bug fix that\n    ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).\n    ** The buggy behavior is required for binary compatibility with some\n    ** legacy applications. */\n    iDb = sqlite3FindDb(pParse->db, pNm);\n    if( iDb<0 ) iDb = 0;\n#endif\n  }\n  if( iDb!=1 ){\n    sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);\n    sqlite3VdbeUsesBtree(v, iDb);\n  }\n  return;\n}\n\n/*\n** This routine implements the OP_Vacuum opcode of the VDBE.\n*/\nint sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){\n  int rc = SQLITE_OK;     /* Return code from service routines */\n  Btree *pMain;           /* The database being vacuumed */\n  Btree *pTemp;           /* The temporary database we vacuum into */\n  u16 saved_mDbFlags;     /* Saved value of db->mDbFlags */\n  u32 saved_flags;        /* Saved value of db->flags */\n  int saved_nChange;      /* Saved value of db->nChange */\n  int saved_nTotalChange; /* Saved value of db->nTotalChange */\n  u8 saved_mTrace;        /* Saved trace settings */\n  Db *pDb = 0;            /* Database to detach at end of vacuum */\n  int isMemDb;            /* True if vacuuming a :memory: database */\n  int nRes;               /* Bytes of reserved space at the end of each page */\n  int nDb;                /* Number of attached databases */\n  const char *zDbMain;    /* Schema name of database to vacuum */\n\n  if( !db->autoCommit ){\n    sqlite3SetString(pzErrMsg, db, \"cannot VACUUM from within a transaction\");\n    return SQLITE_ERROR;\n  }\n  if( db->nVdbeActive>1 ){\n    sqlite3SetString(pzErrMsg, db,\"cannot VACUUM - SQL statements in progress\");\n    return SQLITE_ERROR;\n  }\n\n  /* Save the current value of the database flags so that it can be \n  ** restored before returning. Then set the writable-schema flag, and\n  ** disable CHECK and foreign key constraints.  */\n  saved_flags = db->flags;\n  saved_mDbFlags = db->mDbFlags;\n  saved_nChange = db->nChange;\n  saved_nTotalChange = db->nTotalChange;\n  saved_mTrace = db->mTrace;\n  db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;\n  db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;\n  db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder | SQLITE_CountRows);\n  db->mTrace = 0;\n\n  zDbMain = db->aDb[iDb].zDbSName;\n  pMain = db->aDb[iDb].pBt;\n  isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));\n\n  /* Attach the temporary database as 'vacuum_db'. The synchronous pragma\n  ** can be set to 'off' for this file, as it is not recovered if a crash\n  ** occurs anyway. The integrity of the database is maintained by a\n  ** (possibly synchronous) transaction opened on the main database before\n  ** sqlite3BtreeCopyFile() is called.\n  **\n  ** An optimisation would be to use a non-journaled pager.\n  ** (Later:) I tried setting \"PRAGMA vacuum_db.journal_mode=OFF\" but\n  ** that actually made the VACUUM run slower.  Very little journalling\n  ** actually occurs when doing a vacuum since the vacuum_db is initially\n  ** empty.  Only the journal header is written.  Apparently it takes more\n  ** time to parse and run the PRAGMA to turn journalling off than it does\n  ** to write the journal header file.\n  */\n  nDb = db->nDb;\n  rc = execSql(db, pzErrMsg, \"ATTACH''AS vacuum_db\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  assert( (db->nDb-1)==nDb );\n  pDb = &db->aDb[nDb];\n  assert( strcmp(pDb->zDbSName,\"vacuum_db\")==0 );\n  pTemp = pDb->pBt;\n\n  /* The call to execSql() to attach the temp database has left the file\n  ** locked (as there was more than one active statement when the transaction\n  ** to read the schema was concluded. Unlock it here so that this doesn't\n  ** cause problems for the call to BtreeSetPageSize() below.  */\n  sqlite3BtreeCommit(pTemp);\n\n  nRes = sqlite3BtreeGetOptimalReserve(pMain);\n\n  /* A VACUUM cannot change the pagesize of an encrypted database. */\n#ifdef SQLITE_HAS_CODEC\n  if( db->nextPagesize ){\n    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);\n    int nKey;\n    char *zKey;\n    sqlite3CodecGetKey(db, iDb, (void**)&zKey, &nKey);\n    if( nKey ) db->nextPagesize = 0;\n  }\n#endif\n\n  sqlite3BtreeSetCacheSize(pTemp, db->aDb[iDb].pSchema->cache_size);\n  sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0));\n  sqlite3BtreeSetPagerFlags(pTemp, PAGER_SYNCHRONOUS_OFF|PAGER_CACHESPILL);\n\n  /* Begin a transaction and take an exclusive lock on the main database\n  ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below,\n  ** to ensure that we do not try to change the page-size on a WAL database.\n  */\n  rc = execSql(db, pzErrMsg, \"BEGIN\");\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = sqlite3BtreeBeginTrans(pMain, 2);\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Do not attempt to change the page size for a WAL database */\n  if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain))\n                                               ==PAGER_JOURNALMODE_WAL ){\n    db->nextPagesize = 0;\n  }\n\n  if( sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), nRes, 0)\n   || (!isMemDb && sqlite3BtreeSetPageSize(pTemp, db->nextPagesize, nRes, 0))\n   || NEVER(db->mallocFailed)\n  ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto end_of_vacuum;\n  }\n\n#ifndef SQLITE_OMIT_AUTOVACUUM\n  sqlite3BtreeSetAutoVacuum(pTemp, db->nextAutovac>=0 ? db->nextAutovac :\n                                           sqlite3BtreeGetAutoVacuum(pMain));\n#endif\n\n  /* Query the schema of the main database. Create a mirror schema\n  ** in the temporary database.\n  */\n  db->init.iDb = nDb; /* force new CREATE statements into vacuum_db */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='table'AND name<>'sqlite_sequence'\"\n      \" AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT sql FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type='index' AND length(sql)>10\",\n      zDbMain\n  );\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n  db->init.iDb = 0;\n\n  /* Loop through the tables in the main database. For each, do\n  ** an \"INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;\" to copy\n  ** the contents to the temporary database.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"SELECT'INSERT INTO vacuum_db.'||quote(name)\"\n      \"||' SELECT*FROM\\\"%w\\\".'||quote(name)\"\n      \"FROM vacuum_db.sqlite_master \"\n      \"WHERE type='table'AND coalesce(rootpage,1)>0\",\n      zDbMain\n  );\n  assert( (db->mDbFlags & DBFLAG_Vacuum)!=0 );\n  db->mDbFlags &= ~DBFLAG_Vacuum;\n  if( rc!=SQLITE_OK ) goto end_of_vacuum;\n\n  /* Copy the triggers, views, and virtual tables from the main database\n  ** over to the temporary database.  None of these objects has any\n  ** associated storage, so all we have to do is copy their entries\n  ** from the SQLITE_MASTER table.\n  */\n  rc = execSqlF(db, pzErrMsg,\n      \"INSERT INTO vacuum_db.sqlite_master\"\n      \" SELECT*FROM \\\"%w\\\".sqlite_master\"\n      \" WHERE type IN('view','trigger')\"\n      \" OR(type='table'AND rootpage=0)\",\n      zDbMain\n  );\n  if( rc ) goto end_of_vacuum;\n\n  /* At this point, there is a write transaction open on both the \n  ** vacuum database and the main database. Assuming no error occurs,\n  ** both transactions are closed by this block - the main database\n  ** transaction by sqlite3BtreeCopyFile() and the other by an explicit\n  ** call to sqlite3BtreeCommit().\n  */\n  {\n    u32 meta;\n    int i;\n\n    /* This array determines which meta meta values are preserved in the\n    ** vacuum.  Even entries are the meta value number and odd entries\n    ** are an increment to apply to the meta value after the vacuum.\n    ** The increment is used to increase the schema cookie so that other\n    ** connections to the same database will know to reread the schema.\n    */\n    static const unsigned char aCopy[] = {\n       BTREE_SCHEMA_VERSION,     1,  /* Add one to the old schema cookie */\n       BTREE_DEFAULT_CACHE_SIZE, 0,  /* Preserve the default page cache size */\n       BTREE_TEXT_ENCODING,      0,  /* Preserve the text encoding */\n       BTREE_USER_VERSION,       0,  /* Preserve the user version */\n       BTREE_APPLICATION_ID,     0,  /* Preserve the application id */\n    };\n\n    assert( 1==sqlite3BtreeIsInTrans(pTemp) );\n    assert( 1==sqlite3BtreeIsInTrans(pMain) );\n\n    /* Copy Btree meta values */\n    for(i=0; i<ArraySize(aCopy); i+=2){\n      /* GetMeta() and UpdateMeta() cannot fail in this context because\n      ** we already have page 1 loaded into cache and marked dirty. */\n      sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);\n      rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);\n      if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;\n    }\n\n    rc = sqlite3BtreeCopyFile(pMain, pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n    rc = sqlite3BtreeCommit(pTemp);\n    if( rc!=SQLITE_OK ) goto end_of_vacuum;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));\n#endif\n  }\n\n  assert( rc==SQLITE_OK );\n  rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);\n\nend_of_vacuum:\n  /* Restore the original value of db->flags */\n  db->init.iDb = 0;\n  db->mDbFlags = saved_mDbFlags;\n  db->flags = saved_flags;\n  db->nChange = saved_nChange;\n  db->nTotalChange = saved_nTotalChange;\n  db->mTrace = saved_mTrace;\n  sqlite3BtreeSetPageSize(pMain, -1, -1, 1);\n\n  /* Currently there is an SQL level transaction open on the vacuum\n  ** database. No locks are held on any other files (since the main file\n  ** was committed at the btree level). So it safe to end the transaction\n  ** by manually setting the autoCommit flag to true and detaching the\n  ** vacuum database. The vacuum_db journal file is deleted when the pager\n  ** is closed by the DETACH.\n  */\n  db->autoCommit = 1;\n\n  if( pDb ){\n    sqlite3BtreeClose(pDb->pBt);\n    pDb->pBt = 0;\n    pDb->pSchema = 0;\n  }\n\n  /* This both clears the schemas and reduces the size of the db->aDb[]\n  ** array. */ \n  sqlite3ResetAllSchemasOfConnection(db);\n\n  return rc;\n}\n\n#endif  /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbe.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** The code in this file implements the function that runs the\n** bytecode of a prepared statement.\n**\n** Various scripts scan this source file in order to generate HTML\n** documentation, headers files, or other derived files.  The formatting\n** of the code in this file is, therefore, important.  See other comments\n** in this file for details.  If in doubt, do not deviate from existing\n** commenting and indentation practices when changing or adding code.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n/*\n** Invoke this macro on memory cells just prior to changing the\n** value of the cell.  This macro verifies that shallow copies are\n** not misused.  A shallow copy of a string or blob just copies a\n** pointer to the string or blob, not the content.  If the original\n** is changed while the copy is still in use, the string or blob might\n** be changed out from under the copy.  This macro verifies that nothing\n** like that ever happens.\n*/\n#ifdef SQLITE_DEBUG\n# define memAboutToChange(P,M) sqlite3VdbeMemAboutToChange(P,M)\n#else\n# define memAboutToChange(P,M)\n#endif\n\n/*\n** The following global variable is incremented every time a cursor\n** moves, either by the OP_SeekXX, OP_Next, or OP_Prev opcodes.  The test\n** procedures use this information to make sure that indices are\n** working correctly.  This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_search_count = 0;\n#endif\n\n/*\n** When this global variable is positive, it gets decremented once before\n** each instruction in the VDBE.  When it reaches zero, the u1.isInterrupted\n** field of the sqlite3 structure is set in order to simulate an interrupt.\n**\n** This facility is used for testing purposes only.  It does not function\n** in an ordinary build.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_interrupt_count = 0;\n#endif\n\n/*\n** The next global variable is incremented each type the OP_Sort opcode\n** is executed.  The test procedures use this information to make sure that\n** sorting is occurring or not occurring at appropriate times.   This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_sort_count = 0;\n#endif\n\n/*\n** The next global variable records the size of the largest MEM_Blob\n** or MEM_Str that has been used by a VDBE opcode.  The test procedures\n** use this information to make sure that the zero-blob functionality\n** is working correctly.   This variable has no function other than to\n** help verify the correct operation of the library.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_max_blobsize = 0;\nstatic void updateMaxBlobsize(Mem *p){\n  if( (p->flags & (MEM_Str|MEM_Blob))!=0 && p->n>sqlite3_max_blobsize ){\n    sqlite3_max_blobsize = p->n;\n  }\n}\n#endif\n\n/*\n** This macro evaluates to true if either the update hook or the preupdate\n** hook are enabled for database connect DB.\n*/\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n# define HAS_UPDATE_HOOK(DB) ((DB)->xPreUpdateCallback||(DB)->xUpdateCallback)\n#else\n# define HAS_UPDATE_HOOK(DB) ((DB)->xUpdateCallback)\n#endif\n\n/*\n** The next global variable is incremented each time the OP_Found opcode\n** is executed. This is used to test whether or not the foreign key\n** operation implemented using OP_FkIsZero is working. This variable\n** has no function other than to help verify the correct operation of the\n** library.\n*/\n#ifdef SQLITE_TEST\nint sqlite3_found_count = 0;\n#endif\n\n/*\n** Test a register to see if it exceeds the current maximum blob size.\n** If it does, record the new maximum blob size.\n*/\n#if defined(SQLITE_TEST) && !defined(SQLITE_UNTESTABLE)\n# define UPDATE_MAX_BLOBSIZE(P)  updateMaxBlobsize(P)\n#else\n# define UPDATE_MAX_BLOBSIZE(P)\n#endif\n\n/*\n** Invoke the VDBE coverage callback, if that callback is defined.  This\n** feature is used for test suite validation only and does not appear an\n** production builds.\n**\n** M is an integer, 2 or 3, that indices how many different ways the\n** branch can go.  It is usually 2.  \"I\" is the direction the branch\n** goes.  0 means falls through.  1 means branch is taken.  2 means the\n** second alternative branch is taken.\n**\n** iSrcLine is the source code line (from the __LINE__ macro) that\n** generated the VDBE instruction.  This instrumentation assumes that all\n** source code is in a single file (the amalgamation).  Special values 1\n** and 2 for the iSrcLine parameter mean that this particular branch is\n** always taken or never taken, respectively.\n*/\n#if !defined(SQLITE_VDBE_COVERAGE)\n# define VdbeBranchTaken(I,M)\n#else\n# define VdbeBranchTaken(I,M) vdbeTakeBranch(pOp->iSrcLine,I,M)\n  static void vdbeTakeBranch(int iSrcLine, u8 I, u8 M){\n    if( iSrcLine<=2 && ALWAYS(iSrcLine>0) ){\n      M = iSrcLine;\n      /* Assert the truth of VdbeCoverageAlwaysTaken() and \n      ** VdbeCoverageNeverTaken() */\n      assert( (M & I)==I );\n    }else{\n      if( sqlite3GlobalConfig.xVdbeBranch==0 ) return;  /*NO_TEST*/\n      sqlite3GlobalConfig.xVdbeBranch(sqlite3GlobalConfig.pVdbeBranchArg,\n                                      iSrcLine,I,M);\n    }\n  }\n#endif\n\n/*\n** Convert the given register into a string if it isn't one\n** already. Return non-zero if a malloc() fails.\n*/\n#define Stringify(P, enc) \\\n   if(((P)->flags&(MEM_Str|MEM_Blob))==0 && sqlite3VdbeMemStringify(P,enc,0)) \\\n     { goto no_mem; }\n\n/*\n** An ephemeral string value (signified by the MEM_Ephem flag) contains\n** a pointer to a dynamically allocated string where some other entity\n** is responsible for deallocating that string.  Because the register\n** does not control the string, it might be deleted without the register\n** knowing it.\n**\n** This routine converts an ephemeral string into a dynamically allocated\n** string that the register itself controls.  In other words, it\n** converts an MEM_Ephem string into a string with P.z==P.zMalloc.\n*/\n#define Deephemeralize(P) \\\n   if( ((P)->flags&MEM_Ephem)!=0 \\\n       && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;}\n\n/* Return true if the cursor was opened using the OP_OpenSorter opcode. */\n#define isSorter(x) ((x)->eCurType==CURTYPE_SORTER)\n\n/*\n** Allocate VdbeCursor number iCur.  Return a pointer to it.  Return NULL\n** if we run out of memory.\n*/\nstatic VdbeCursor *allocateCursor(\n  Vdbe *p,              /* The virtual machine */\n  int iCur,             /* Index of the new VdbeCursor */\n  int nField,           /* Number of fields in the table or index */\n  int iDb,              /* Database the cursor belongs to, or -1 */\n  u8 eCurType           /* Type of the new cursor */\n){\n  /* Find the memory cell that will be used to store the blob of memory\n  ** required for this VdbeCursor structure. It is convenient to use a \n  ** vdbe memory cell to manage the memory allocation required for a\n  ** VdbeCursor structure for the following reasons:\n  **\n  **   * Sometimes cursor numbers are used for a couple of different\n  **     purposes in a vdbe program. The different uses might require\n  **     different sized allocations. Memory cells provide growable\n  **     allocations.\n  **\n  **   * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can\n  **     be freed lazily via the sqlite3_release_memory() API. This\n  **     minimizes the number of malloc calls made by the system.\n  **\n  ** The memory cell for cursor 0 is aMem[0]. The rest are allocated from\n  ** the top of the register space.  Cursor 1 is at Mem[p->nMem-1].\n  ** Cursor 2 is at Mem[p->nMem-2]. And so forth.\n  */\n  Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;\n\n  int nByte;\n  VdbeCursor *pCx = 0;\n  nByte = \n      ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + \n      (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);\n\n  assert( iCur>=0 && iCur<p->nCursor );\n  if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/\n    sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);\n    p->apCsr[iCur] = 0;\n  }\n  if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;\n    memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));\n    pCx->eCurType = eCurType;\n    pCx->iDb = iDb;\n    pCx->nField = nField;\n    pCx->aOffset = &pCx->aType[nField];\n    if( eCurType==CURTYPE_BTREE ){\n      pCx->uc.pCursor = (BtCursor*)\n          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];\n      sqlite3BtreeCursorZero(pCx->uc.pCursor);\n    }\n  }\n  return pCx;\n}\n\n/*\n** Try to convert a value into a numeric representation if we can\n** do so without loss of information.  In other words, if the string\n** looks like a number, convert it into a number.  If it does not\n** look like a number, leave it alone.\n**\n** If the bTryForInt flag is true, then extra effort is made to give\n** an integer representation.  Strings that look like floating point\n** values but which have no fractional component (example: '48.00')\n** will have a MEM_Int representation when bTryForInt is true.\n**\n** If bTryForInt is false, then if the input string contains a decimal\n** point or exponential notation, the result is only MEM_Real, even\n** if there is an exact integer representation of the quantity.\n*/\nstatic void applyNumericAffinity(Mem *pRec, int bTryForInt){\n  double rValue;\n  i64 iValue;\n  u8 enc = pRec->enc;\n  assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real))==MEM_Str );\n  if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;\n  if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){\n    pRec->u.i = iValue;\n    pRec->flags |= MEM_Int;\n  }else{\n    pRec->u.r = rValue;\n    pRec->flags |= MEM_Real;\n    if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);\n  }\n}\n\n/*\n** Processing is determine by the affinity parameter:\n**\n** SQLITE_AFF_INTEGER:\n** SQLITE_AFF_REAL:\n** SQLITE_AFF_NUMERIC:\n**    Try to convert pRec to an integer representation or a \n**    floating-point representation if an integer representation\n**    is not possible.  Note that the integer representation is\n**    always preferred, even if the affinity is REAL, because\n**    an integer representation is more space efficient on disk.\n**\n** SQLITE_AFF_TEXT:\n**    Convert pRec to a text representation.\n**\n** SQLITE_AFF_BLOB:\n**    No-op.  pRec is unchanged.\n*/\nstatic void applyAffinity(\n  Mem *pRec,          /* The value to apply affinity to */\n  char affinity,      /* The affinity to be applied */\n  u8 enc              /* Use this text encoding */\n){\n  if( affinity>=SQLITE_AFF_NUMERIC ){\n    assert( affinity==SQLITE_AFF_INTEGER || affinity==SQLITE_AFF_REAL\n             || affinity==SQLITE_AFF_NUMERIC );\n    if( (pRec->flags & MEM_Int)==0 ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags & MEM_Real)==0 ){\n        if( pRec->flags & MEM_Str ) applyNumericAffinity(pRec,1);\n      }else{\n        sqlite3VdbeIntegerAffinity(pRec);\n      }\n    }\n  }else if( affinity==SQLITE_AFF_TEXT ){\n    /* Only attempt the conversion to TEXT if there is an integer or real\n    ** representation (blob and NULL do not get converted) but no string\n    ** representation.  It would be harmless to repeat the conversion if \n    ** there is already a string rep, but it is pointless to waste those\n    ** CPU cycles. */\n    if( 0==(pRec->flags&MEM_Str) ){ /*OPTIMIZATION-IF-FALSE*/\n      if( (pRec->flags&(MEM_Real|MEM_Int)) ){\n        sqlite3VdbeMemStringify(pRec, enc, 1);\n      }\n    }\n    pRec->flags &= ~(MEM_Real|MEM_Int);\n  }\n}\n\n/*\n** Try to convert the type of a function argument or a result column\n** into a numeric representation.  Use either INTEGER or REAL whichever\n** is appropriate.  But only do the conversion if it is possible without\n** loss of information and return the revised type of the argument.\n*/\nint sqlite3_value_numeric_type(sqlite3_value *pVal){\n  int eType = sqlite3_value_type(pVal);\n  if( eType==SQLITE_TEXT ){\n    Mem *pMem = (Mem*)pVal;\n    applyNumericAffinity(pMem, 0);\n    eType = sqlite3_value_type(pVal);\n  }\n  return eType;\n}\n\n/*\n** Exported version of applyAffinity(). This one works on sqlite3_value*, \n** not the internal Mem* type.\n*/\nvoid sqlite3ValueApplyAffinity(\n  sqlite3_value *pVal, \n  u8 affinity, \n  u8 enc\n){\n  applyAffinity((Mem *)pVal, affinity, enc);\n}\n\n/*\n** pMem currently only holds a string type (or maybe a BLOB that we can\n** interpret as a string if we want to).  Compute its corresponding\n** numeric type, if has one.  Set the pMem->u.r and pMem->u.i fields\n** accordingly.\n*/\nstatic u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){\n  assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );\n  assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );\n  if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){\n    return 0;\n  }\n  if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){\n    return MEM_Int;\n  }\n  return MEM_Real;\n}\n\n/*\n** Return the numeric type for pMem, either MEM_Int or MEM_Real or both or\n** none.  \n**\n** Unlike applyNumericAffinity(), this routine does not modify pMem->flags.\n** But it does set pMem->u.r and pMem->u.i appropriately.\n*/\nstatic u16 numericType(Mem *pMem){\n  if( pMem->flags & (MEM_Int|MEM_Real) ){\n    return pMem->flags & (MEM_Int|MEM_Real);\n  }\n  if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return computeNumericType(pMem);\n  }\n  return 0;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** Write a nice string representation of the contents of cell pMem\n** into buffer zBuf, length nBuf.\n*/\nvoid sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){\n  char *zCsr = zBuf;\n  int f = pMem->flags;\n\n  static const char *const encnames[] = {\"(X)\", \"(8)\", \"(16LE)\", \"(16BE)\"};\n\n  if( f&MEM_Blob ){\n    int i;\n    char c;\n    if( f & MEM_Dyn ){\n      c = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      c = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      c = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      c = 's';\n    }\n    *(zCsr++) = c;\n    sqlite3_snprintf(100, zCsr, \"%d[\", pMem->n);\n    zCsr += sqlite3Strlen30(zCsr);\n    for(i=0; i<16 && i<pMem->n; i++){\n      sqlite3_snprintf(100, zCsr, \"%02X\", ((int)pMem->z[i] & 0xFF));\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    for(i=0; i<16 && i<pMem->n; i++){\n      char z = pMem->z[i];\n      if( z<32 || z>126 ) *zCsr++ = '.';\n      else *zCsr++ = z;\n    }\n    *(zCsr++) = ']';\n    if( f & MEM_Zero ){\n      sqlite3_snprintf(100, zCsr,\"+%dz\",pMem->u.nZero);\n      zCsr += sqlite3Strlen30(zCsr);\n    }\n    *zCsr = '\\0';\n  }else if( f & MEM_Str ){\n    int j, k;\n    zBuf[0] = ' ';\n    if( f & MEM_Dyn ){\n      zBuf[1] = 'z';\n      assert( (f & (MEM_Static|MEM_Ephem))==0 );\n    }else if( f & MEM_Static ){\n      zBuf[1] = 't';\n      assert( (f & (MEM_Dyn|MEM_Ephem))==0 );\n    }else if( f & MEM_Ephem ){\n      zBuf[1] = 'e';\n      assert( (f & (MEM_Static|MEM_Dyn))==0 );\n    }else{\n      zBuf[1] = 's';\n    }\n    k = 2;\n    sqlite3_snprintf(100, &zBuf[k], \"%d\", pMem->n);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = '[';\n    for(j=0; j<15 && j<pMem->n; j++){\n      u8 c = pMem->z[j];\n      if( c>=0x20 && c<0x7f ){\n        zBuf[k++] = c;\n      }else{\n        zBuf[k++] = '.';\n      }\n    }\n    zBuf[k++] = ']';\n    sqlite3_snprintf(100,&zBuf[k], encnames[pMem->enc]);\n    k += sqlite3Strlen30(&zBuf[k]);\n    zBuf[k++] = 0;\n  }\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the value of a register for tracing purposes:\n*/\nstatic void memTracePrint(Mem *p){\n  if( p->flags & MEM_Undefined ){\n    printf(\" undefined\");\n  }else if( p->flags & MEM_Null ){\n    printf(\" NULL\");\n  }else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){\n    printf(\" si:%lld\", p->u.i);\n  }else if( p->flags & MEM_Int ){\n    printf(\" i:%lld\", p->u.i);\n#ifndef SQLITE_OMIT_FLOATING_POINT\n  }else if( p->flags & MEM_Real ){\n    printf(\" r:%g\", p->u.r);\n#endif\n  }else if( p->flags & MEM_RowSet ){\n    printf(\" (rowset)\");\n  }else{\n    char zBuf[200];\n    sqlite3VdbeMemPrettyPrint(p, zBuf);\n    printf(\" %s\", zBuf);\n  }\n  if( p->flags & MEM_Subtype ) printf(\" subtype=0x%02x\", p->eSubtype);\n}\nstatic void registerTrace(int iReg, Mem *p){\n  printf(\"REG[%d] = \", iReg);\n  memTracePrint(p);\n  printf(\"\\n\");\n  sqlite3VdbeCheckMemInvariants(p);\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n#  define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M)\n#else\n#  define REGISTER_TRACE(R,M)\n#endif\n\n\n#ifdef VDBE_PROFILE\n\n/* \n** hwtime.h contains inline assembler code for implementing \n** high-performance timing routines.\n*/\n#include \"hwtime.h\"\n\n#endif\n\n#ifndef NDEBUG\n/*\n** This function is only called from within an assert() expression. It\n** checks that the sqlite3.nTransaction variable is correctly set to\n** the number of non-transaction savepoints currently in the \n** linked list starting at sqlite3.pSavepoint.\n** \n** Usage:\n**\n**     assert( checkSavepointCount(db) );\n*/\nstatic int checkSavepointCount(sqlite3 *db){\n  int n = 0;\n  Savepoint *p;\n  for(p=db->pSavepoint; p; p=p->pNext) n++;\n  assert( n==(db->nSavepoint + db->isTransactionSavepoint) );\n  return 1;\n}\n#endif\n\n/*\n** Return the register of pOp->p2 after first preparing it to be\n** overwritten with an integer value.\n*/\nstatic SQLITE_NOINLINE Mem *out2PrereleaseWithClear(Mem *pOut){\n  sqlite3VdbeMemSetNull(pOut);\n  pOut->flags = MEM_Int;\n  return pOut;\n}\nstatic Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){\n  Mem *pOut;\n  assert( pOp->p2>0 );\n  assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n  pOut = &p->aMem[pOp->p2];\n  memAboutToChange(p, pOut);\n  if( VdbeMemDynamic(pOut) ){ /*OPTIMIZATION-IF-FALSE*/\n    return out2PrereleaseWithClear(pOut);\n  }else{\n    pOut->flags = MEM_Int;\n    return pOut;\n  }\n}\n\n\n/*\n** Execute as much of a VDBE program as we can.\n** This is the core of sqlite3_step().  \n*/\nint sqlite3VdbeExec(\n  Vdbe *p                    /* The VDBE */\n){\n  Op *aOp = p->aOp;          /* Copy of p->aOp */\n  Op *pOp = aOp;             /* Current operation */\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  Op *pOrigOp;               /* Value of pOp at the top of the loop */\n#endif\n#ifdef SQLITE_DEBUG\n  int nExtraDelete = 0;      /* Verifies FORDELETE and AUXDELETE flags */\n#endif\n  int rc = SQLITE_OK;        /* Value to return */\n  sqlite3 *db = p->db;       /* The database */\n  u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */\n  u8 encoding = ENC(db);     /* The database encoding */\n  int iCompare = 0;          /* Result of last comparison */\n  unsigned nVmStep = 0;      /* Number of virtual machine steps */\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  unsigned nProgressLimit;   /* Invoke xProgress() when nVmStep reaches this */\n#endif\n  Mem *aMem = p->aMem;       /* Copy of p->aMem */\n  Mem *pIn1 = 0;             /* 1st input operand */\n  Mem *pIn2 = 0;             /* 2nd input operand */\n  Mem *pIn3 = 0;             /* 3rd input operand */\n  Mem *pOut = 0;             /* Output operand */\n#ifdef VDBE_PROFILE\n  u64 start;                 /* CPU clock count at start of opcode */\n#endif\n  /*** INSERT STACK UNION HERE ***/\n\n  assert( p->magic==VDBE_MAGIC_RUN );  /* sqlite3_step() verifies this */\n  sqlite3VdbeEnter(p);\n  if( p->rc==SQLITE_NOMEM ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    goto no_mem;\n  }\n  assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY );\n  assert( p->bIsReader || p->readOnly!=0 );\n  p->iCurrentTime = 0;\n  assert( p->explain==0 );\n  p->pResultSet = 0;\n  db->busyHandler.nBusy = 0;\n  if( db->u1.isInterrupted ) goto abort_due_to_interrupt;\n  sqlite3VdbeIOTraceSql(p);\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  if( db->xProgress ){\n    u32 iPrior = p->aCounter[SQLITE_STMTSTATUS_VM_STEP];\n    assert( 0 < db->nProgressOps );\n    nProgressLimit = db->nProgressOps - (iPrior % db->nProgressOps);\n  }else{\n    nProgressLimit = 0xffffffff;\n  }\n#endif\n#ifdef SQLITE_DEBUG\n  sqlite3BeginBenignMalloc();\n  if( p->pc==0\n   && (p->db->flags & (SQLITE_VdbeListing|SQLITE_VdbeEQP|SQLITE_VdbeTrace))!=0\n  ){\n    int i;\n    int once = 1;\n    sqlite3VdbePrintSql(p);\n    if( p->db->flags & SQLITE_VdbeListing ){\n      printf(\"VDBE Program Listing:\\n\");\n      for(i=0; i<p->nOp; i++){\n        sqlite3VdbePrintOp(stdout, i, &aOp[i]);\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeEQP ){\n      for(i=0; i<p->nOp; i++){\n        if( aOp[i].opcode==OP_Explain ){\n          if( once ) printf(\"VDBE Query Plan:\\n\");\n          printf(\"%s\\n\", aOp[i].p4.z);\n          once = 0;\n        }\n      }\n    }\n    if( p->db->flags & SQLITE_VdbeTrace )  printf(\"VDBE Trace:\\n\");\n  }\n  sqlite3EndBenignMalloc();\n#endif\n  for(pOp=&aOp[p->pc]; 1; pOp++){\n    /* Errors are detected by individual opcodes, with an immediate\n    ** jumps to abort_due_to_error. */\n    assert( rc==SQLITE_OK );\n\n    assert( pOp>=aOp && pOp<&aOp[p->nOp]);\n#ifdef VDBE_PROFILE\n    start = sqlite3Hwtime();\n#endif\n    nVmStep++;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    if( p->anExec ) p->anExec[(int)(pOp-aOp)]++;\n#endif\n\n    /* Only allow tracing if SQLITE_DEBUG is defined.\n    */\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);\n    }\n#endif\n      \n\n    /* Check to see if we need to simulate an interrupt.  This only happens\n    ** if we have a special test build.\n    */\n#ifdef SQLITE_TEST\n    if( sqlite3_interrupt_count>0 ){\n      sqlite3_interrupt_count--;\n      if( sqlite3_interrupt_count==0 ){\n        sqlite3_interrupt(db);\n      }\n    }\n#endif\n\n    /* Sanity checking on other operands */\n#ifdef SQLITE_DEBUG\n    {\n      u8 opProperty = sqlite3OpcodeProperty[pOp->opcode];\n      if( (opProperty & OPFLG_IN1)!=0 ){\n        assert( pOp->p1>0 );\n        assert( pOp->p1<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p1]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );\n        REGISTER_TRACE(pOp->p1, &aMem[pOp->p1]);\n      }\n      if( (opProperty & OPFLG_IN2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p2]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p2]) );\n        REGISTER_TRACE(pOp->p2, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_IN3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        assert( memIsValid(&aMem[pOp->p3]) );\n        assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p3]) );\n        REGISTER_TRACE(pOp->p3, &aMem[pOp->p3]);\n      }\n      if( (opProperty & OPFLG_OUT2)!=0 ){\n        assert( pOp->p2>0 );\n        assert( pOp->p2<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p2]);\n      }\n      if( (opProperty & OPFLG_OUT3)!=0 ){\n        assert( pOp->p3>0 );\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        memAboutToChange(p, &aMem[pOp->p3]);\n      }\n    }\n#endif\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    pOrigOp = pOp;\n#endif\n  \n    switch( pOp->opcode ){\n\n/*****************************************************************************\n** What follows is a massive switch statement where each case implements a\n** separate instruction in the virtual machine.  If we follow the usual\n** indentation conventions, each case should be indented by 6 spaces.  But\n** that is a lot of wasted space on the left margin.  So the code within\n** the switch statement will break with convention and be flush-left. Another\n** big comment (similar to this one) will mark the point in the code where\n** we transition back to normal indentation.\n**\n** The formatting of each case is important.  The makefile for SQLite\n** generates two C files \"opcodes.h\" and \"opcodes.c\" by scanning this\n** file looking for lines that begin with \"case OP_\".  The opcodes.h files\n** will be filled with #defines that give unique integer values to each\n** opcode and the opcodes.c file is filled with an array of strings where\n** each string is the symbolic name for the corresponding opcode.  If the\n** case statement is followed by a comment of the form \"/# same as ... #/\"\n** that comment is used to determine the particular value of the opcode.\n**\n** Other keywords in the comment that follows each case are used to\n** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].\n** Keywords include: in1, in2, in3, out2, out3.  See\n** the mkopcodeh.awk script for additional information.\n**\n** Documentation about VDBE opcodes is generated by scanning this file\n** for lines of that contain \"Opcode:\".  That line and all subsequent\n** comment lines are used in the generation of the opcode.html documentation\n** file.\n**\n** SUMMARY:\n**\n**     Formatting is important to scripts that scan this file.\n**     Do not deviate from the formatting style currently in use.\n**\n*****************************************************************************/\n\n/* Opcode:  Goto * P2 * * *\n**\n** An unconditional jump to address P2.\n** The next instruction executed will be \n** the one at index P2 from the beginning of\n** the program.\n**\n** The P1 parameter is not actually used by this opcode.  However, it\n** is sometimes set to 1 instead of 0 as a hint to the command-line shell\n** that this Goto is the bottom of a loop and that the lines from P2 down\n** to the current line should be indented for EXPLAIN output.\n*/\ncase OP_Goto: {             /* jump */\njump_to_p2_and_check_for_interrupt:\n  pOp = &aOp[pOp->p2 - 1];\n\n  /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,\n  ** OP_VNext, or OP_SorterNext) all jump here upon\n  ** completion.  Check to see if sqlite3_interrupt() has been called\n  ** or if the progress callback needs to be invoked. \n  **\n  ** This code uses unstructured \"goto\" statements and does not look clean.\n  ** But that is not due to sloppy coding habits. The code is written this\n  ** way for performance, to avoid having to run the interrupt and progress\n  ** checks on every opcode.  This helps sqlite3_step() to run about 1.5%\n  ** faster according to \"valgrind --tool=cachegrind\" */\ncheck_for_interrupt:\n  if( db->u1.isInterrupted ) goto abort_due_to_interrupt;\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Call the progress callback if it is configured and the required number\n  ** of VDBE ops have been executed (either since this invocation of\n  ** sqlite3VdbeExec() or since last time the progress callback was called).\n  ** If the progress callback returns non-zero, exit the virtual machine with\n  ** a return code SQLITE_ABORT.\n  */\n  if( nVmStep>=nProgressLimit && db->xProgress!=0 ){\n    assert( db->nProgressOps!=0 );\n    nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);\n    if( db->xProgress(db->pProgressArg) ){\n      rc = SQLITE_INTERRUPT;\n      goto abort_due_to_error;\n    }\n  }\n#endif\n  \n  break;\n}\n\n/* Opcode:  Gosub P1 P2 * * *\n**\n** Write the current address onto register P1\n** and then jump to address P2.\n*/\ncase OP_Gosub: {            /* jump */\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  memAboutToChange(p, pIn1);\n  pIn1->flags = MEM_Int;\n  pIn1->u.i = (int)(pOp-aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n\n  /* Most jump operations do a goto to this spot in order to update\n  ** the pOp pointer. */\njump_to_p2:\n  pOp = &aOp[pOp->p2 - 1];\n  break;\n}\n\n/* Opcode:  Return P1 * * * *\n**\n** Jump to the next instruction after the address in register P1.  After\n** the jump, register P1 becomes undefined.\n*/\ncase OP_Return: {           /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  pOp = &aOp[pIn1->u.i];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode: InitCoroutine P1 P2 P3 * *\n**\n** Set up register P1 so that it will Yield to the coroutine\n** located at address P3.\n**\n** If P2!=0 then the coroutine implementation immediately follows\n** this opcode.  So jump over the coroutine implementation to\n** address P2.\n**\n** See also: EndCoroutine\n*/\ncase OP_InitCoroutine: {     /* jump */\n  assert( pOp->p1>0 &&  pOp->p1<=(p->nMem+1 - p->nCursor) );\n  assert( pOp->p2>=0 && pOp->p2<p->nOp );\n  assert( pOp->p3>=0 && pOp->p3<p->nOp );\n  pOut = &aMem[pOp->p1];\n  assert( !VdbeMemDynamic(pOut) );\n  pOut->u.i = pOp->p3 - 1;\n  pOut->flags = MEM_Int;\n  if( pOp->p2 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode:  EndCoroutine P1 * * * *\n**\n** The instruction at the address in register P1 is a Yield.\n** Jump to the P2 parameter of that Yield.\n** After the jump, register P1 becomes undefined.\n**\n** See also: InitCoroutine\n*/\ncase OP_EndCoroutine: {           /* in1 */\n  VdbeOp *pCaller;\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags==MEM_Int );\n  assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );\n  pCaller = &aOp[pIn1->u.i];\n  assert( pCaller->opcode==OP_Yield );\n  assert( pCaller->p2>=0 && pCaller->p2<p->nOp );\n  pOp = &aOp[pCaller->p2 - 1];\n  pIn1->flags = MEM_Undefined;\n  break;\n}\n\n/* Opcode:  Yield P1 P2 * * *\n**\n** Swap the program counter with the value in register P1.  This\n** has the effect of yielding to a coroutine.\n**\n** If the coroutine that is launched by this instruction ends with\n** Yield or Return then continue to the next instruction.  But if\n** the coroutine launched by this instruction ends with\n** EndCoroutine, then jump to P2 rather than continuing with the\n** next instruction.\n**\n** See also: InitCoroutine\n*/\ncase OP_Yield: {            /* in1, jump */\n  int pcDest;\n  pIn1 = &aMem[pOp->p1];\n  assert( VdbeMemDynamic(pIn1)==0 );\n  pIn1->flags = MEM_Int;\n  pcDest = (int)pIn1->u.i;\n  pIn1->u.i = (int)(pOp - aOp);\n  REGISTER_TRACE(pOp->p1, pIn1);\n  pOp = &aOp[pcDest];\n  break;\n}\n\n/* Opcode:  HaltIfNull  P1 P2 P3 P4 P5\n** Synopsis: if r[P3]=null halt\n**\n** Check the value in register P3.  If it is NULL then Halt using\n** parameter P1, P2, and P4 as if this were a Halt instruction.  If the\n** value in register P3 is not NULL, then this routine is a no-op.\n** The P5 parameter should be 1.\n*/\ncase OP_HaltIfNull: {      /* in3 */\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Null)==0 ) break;\n  /* Fall through into OP_Halt */\n}\n\n/* Opcode:  Halt P1 P2 * P4 P5\n**\n** Exit immediately.  All open cursors, etc are closed\n** automatically.\n**\n** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),\n** or sqlite3_finalize().  For a normal halt, this should be SQLITE_OK (0).\n** For errors, it can be some other value.  If P1!=0 then P2 will determine\n** whether or not to rollback the current transaction.  Do not rollback\n** if P2==OE_Fail. Do the rollback if P2==OE_Rollback.  If P2==OE_Abort,\n** then back out all changes that have occurred during this execution of the\n** VDBE, but do not rollback the transaction. \n**\n** If P4 is not null then it is an error message string.\n**\n** P5 is a value between 0 and 4, inclusive, that modifies the P4 string.\n**\n**    0:  (no change)\n**    1:  NOT NULL contraint failed: P4\n**    2:  UNIQUE constraint failed: P4\n**    3:  CHECK constraint failed: P4\n**    4:  FOREIGN KEY constraint failed: P4\n**\n** If P5 is not zero and P4 is NULL, then everything after the \":\" is\n** omitted.\n**\n** There is an implied \"Halt 0 0 0\" instruction inserted at the very end of\n** every program.  So a jump past the last instruction of the program\n** is the same as executing Halt.\n*/\ncase OP_Halt: {\n  VdbeFrame *pFrame;\n  int pcx;\n\n  pcx = (int)(pOp - aOp);\n  if( pOp->p1==SQLITE_OK && p->pFrame ){\n    /* Halt the sub-program. Return control to the parent frame. */\n    pFrame = p->pFrame;\n    p->pFrame = pFrame->pParent;\n    p->nFrame--;\n    sqlite3VdbeSetChanges(db, p->nChange);\n    pcx = sqlite3VdbeFrameRestore(pFrame);\n    if( pOp->p2==OE_Ignore ){\n      /* Instruction pcx is the OP_Program that invoked the sub-program \n      ** currently being halted. If the p2 instruction of this OP_Halt\n      ** instruction is set to OE_Ignore, then the sub-program is throwing\n      ** an IGNORE exception. In this case jump to the address specified\n      ** as the p2 of the calling OP_Program.  */\n      pcx = p->aOp[pcx].p2-1;\n    }\n    aOp = p->aOp;\n    aMem = p->aMem;\n    pOp = &aOp[pcx];\n    break;\n  }\n  p->rc = pOp->p1;\n  p->errorAction = (u8)pOp->p2;\n  p->pc = pcx;\n  assert( pOp->p5<=4 );\n  if( p->rc ){\n    if( pOp->p5 ){\n      static const char * const azType[] = { \"NOT NULL\", \"UNIQUE\", \"CHECK\",\n                                             \"FOREIGN KEY\" };\n      testcase( pOp->p5==1 );\n      testcase( pOp->p5==2 );\n      testcase( pOp->p5==3 );\n      testcase( pOp->p5==4 );\n      sqlite3VdbeError(p, \"%s constraint failed\", azType[pOp->p5-1]);\n      if( pOp->p4.z ){\n        p->zErrMsg = sqlite3MPrintf(db, \"%z: %s\", p->zErrMsg, pOp->p4.z);\n      }\n    }else{\n      sqlite3VdbeError(p, \"%s\", pOp->p4.z);\n    }\n    sqlite3_log(pOp->p1, \"abort at %d in [%s]: %s\", pcx, p->zSql, p->zErrMsg);\n  }\n  rc = sqlite3VdbeHalt(p);\n  assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );\n  if( rc==SQLITE_BUSY ){\n    p->rc = SQLITE_BUSY;\n  }else{\n    assert( rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT );\n    assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );\n    rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;\n  }\n  goto vdbe_return;\n}\n\n/* Opcode: Integer P1 P2 * * *\n** Synopsis: r[P2]=P1\n**\n** The 32-bit integer value P1 is written into register P2.\n*/\ncase OP_Integer: {         /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = pOp->p1;\n  break;\n}\n\n/* Opcode: Int64 * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit integer value.\n** Write that value into register P2.\n*/\ncase OP_Int64: {           /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p4.pI64!=0 );\n  pOut->u.i = *pOp->p4.pI64;\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: Real * P2 * P4 *\n** Synopsis: r[P2]=P4\n**\n** P4 is a pointer to a 64-bit floating point value.\n** Write that value into register P2.\n*/\ncase OP_Real: {            /* same as TK_FLOAT, out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Real;\n  assert( !sqlite3IsNaN(*pOp->p4.pReal) );\n  pOut->u.r = *pOp->p4.pReal;\n  break;\n}\n#endif\n\n/* Opcode: String8 * P2 * P4 *\n** Synopsis: r[P2]='P4'\n**\n** P4 points to a nul terminated UTF-8 string. This opcode is transformed \n** into a String opcode before it is executed for the first time.  During\n** this transformation, the length of string P4 is computed and stored\n** as the P1 parameter.\n*/\ncase OP_String8: {         /* same as TK_STRING, out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOp->opcode = OP_String;\n  pOp->p1 = sqlite3Strlen30(pOp->p4.z);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( encoding!=SQLITE_UTF8 ){\n    rc = sqlite3VdbeMemSetStr(pOut, pOp->p4.z, -1, SQLITE_UTF8, SQLITE_STATIC);\n    assert( rc==SQLITE_OK || rc==SQLITE_TOOBIG );\n    if( SQLITE_OK!=sqlite3VdbeChangeEncoding(pOut, encoding) ) goto no_mem;\n    assert( pOut->szMalloc>0 && pOut->zMalloc==pOut->z );\n    assert( VdbeMemDynamic(pOut)==0 );\n    pOut->szMalloc = 0;\n    pOut->flags |= MEM_Static;\n    if( pOp->p4type==P4_DYNAMIC ){\n      sqlite3DbFree(db, pOp->p4.z);\n    }\n    pOp->p4type = P4_DYNAMIC;\n    pOp->p4.z = pOut->z;\n    pOp->p1 = pOut->n;\n  }\n  testcase( rc==SQLITE_TOOBIG );\n#endif\n  if( pOp->p1>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  assert( rc==SQLITE_OK );\n  /* Fall through to the next case, OP_String */\n}\n  \n/* Opcode: String P1 P2 P3 P4 P5\n** Synopsis: r[P2]='P4' (len=P1)\n**\n** The string value P4 of length P1 (bytes) is stored in register P2.\n**\n** If P3 is not zero and the content of register P3 is equal to P5, then\n** the datatype of the register P2 is converted to BLOB.  The content is\n** the same sequence of bytes, it is merely interpreted as a BLOB instead\n** of a string, as if it had been CAST.  In other words:\n**\n** if( P3!=0 and reg[P3]==P5 ) reg[P2] := CAST(reg[P2] as BLOB)\n*/\ncase OP_String: {          /* out2 */\n  assert( pOp->p4.z!=0 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = pOp->p4.z;\n  pOut->n = pOp->p1;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  if( pOp->p3>0 ){\n    assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n    pIn3 = &aMem[pOp->p3];\n    assert( pIn3->flags & MEM_Int );\n    if( pIn3->u.i==pOp->p5 ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;\n  }\n#endif\n  break;\n}\n\n/* Opcode: Null P1 P2 P3 * *\n** Synopsis: r[P2..P3]=NULL\n**\n** Write a NULL into registers P2.  If P3 greater than P2, then also write\n** NULL into register P3 and every register in between P2 and P3.  If P3\n** is less than P2 (typically P3 is zero) then only register P2 is\n** set to NULL.\n**\n** If the P1 value is non-zero, then also set the MEM_Cleared flag so that\n** NULL values will not compare equal even if SQLITE_NULLEQ is set on\n** OP_Ne or OP_Eq.\n*/\ncase OP_Null: {           /* out2 */\n  int cnt;\n  u16 nullFlag;\n  pOut = out2Prerelease(p, pOp);\n  cnt = pOp->p3-pOp->p2;\n  assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;\n  pOut->n = 0;\n  while( cnt>0 ){\n    pOut++;\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemSetNull(pOut);\n    pOut->flags = nullFlag;\n    pOut->n = 0;\n    cnt--;\n  }\n  break;\n}\n\n/* Opcode: SoftNull P1 * * * *\n** Synopsis: r[P1]=NULL\n**\n** Set register P1 to have the value NULL as seen by the OP_MakeRecord\n** instruction, but do not free any string or blob memory associated with\n** the register, so that if the value was a string or blob that was\n** previously copied using OP_SCopy, the copies will continue to be valid.\n*/\ncase OP_SoftNull: {\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pOut = &aMem[pOp->p1];\n  pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null;\n  break;\n}\n\n/* Opcode: Blob P1 P2 * P4 *\n** Synopsis: r[P2]=P4 (len=P1)\n**\n** P4 points to a blob of data P1 bytes long.  Store this\n** blob in register P2.\n*/\ncase OP_Blob: {                /* out2 */\n  assert( pOp->p1 <= SQLITE_MAX_LENGTH );\n  pOut = out2Prerelease(p, pOp);\n  sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Variable P1 P2 * P4 *\n** Synopsis: r[P2]=parameter(P1,P4)\n**\n** Transfer the values of bound parameter P1 into register P2\n**\n** If the parameter is named, then its name appears in P4.\n** The P4 value is used by sqlite3_bind_parameter_name().\n*/\ncase OP_Variable: {            /* out2 */\n  Mem *pVar;       /* Value being transferred */\n\n  assert( pOp->p1>0 && pOp->p1<=p->nVar );\n  assert( pOp->p4.z==0 || pOp->p4.z==sqlite3VListNumToName(p->pVList,pOp->p1) );\n  pVar = &p->aVar[pOp->p1 - 1];\n  if( sqlite3VdbeMemTooBig(pVar) ){\n    goto too_big;\n  }\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Move P1 P2 P3 * *\n** Synopsis: r[P2@P3]=r[P1@P3]\n**\n** Move the P3 values in register P1..P1+P3-1 over into\n** registers P2..P2+P3-1.  Registers P1..P1+P3-1 are\n** left holding a NULL.  It is an error for register ranges\n** P1..P1+P3-1 and P2..P2+P3-1 to overlap.  It is an error\n** for P3 to be less than 1.\n*/\ncase OP_Move: {\n  int n;           /* Number of registers left to copy */\n  int p1;          /* Register to copy from */\n  int p2;          /* Register to copy to */\n\n  n = pOp->p3;\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n  assert( n>0 && p1>0 && p2>0 );\n  assert( p1+n<=p2 || p2+n<=p1 );\n\n  pIn1 = &aMem[p1];\n  pOut = &aMem[p2];\n  do{\n    assert( pOut<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( pIn1<=&aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    memAboutToChange(p, pOut);\n    sqlite3VdbeMemMove(pOut, pIn1);\n#ifdef SQLITE_DEBUG\n    if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<pOut ){\n      pOut->pScopyFrom += pOp->p2 - p1;\n    }\n#endif\n    Deephemeralize(pOut);\n    REGISTER_TRACE(p2++, pOut);\n    pIn1++;\n    pOut++;\n  }while( --n );\n  break;\n}\n\n/* Opcode: Copy P1 P2 P3 * *\n** Synopsis: r[P2@P3+1]=r[P1@P3+1]\n**\n** Make a copy of registers P1..P1+P3 into registers P2..P2+P3.\n**\n** This instruction makes a deep copy of the value.  A duplicate\n** is made of any string or blob constant.  See also OP_SCopy.\n*/\ncase OP_Copy: {\n  int n;\n\n  n = pOp->p3;\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  while( 1 ){\n    sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n    Deephemeralize(pOut);\n#ifdef SQLITE_DEBUG\n    pOut->pScopyFrom = 0;\n#endif\n    REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);\n    if( (n--)==0 ) break;\n    pOut++;\n    pIn1++;\n  }\n  break;\n}\n\n/* Opcode: SCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Make a shallow copy of register P1 into register P2.\n**\n** This instruction makes a shallow copy of the value.  If the value\n** is a string or blob, then the copy is only a pointer to the\n** original and hence if the original changes so will the copy.\n** Worse, if the original is deallocated, the copy becomes invalid.\n** Thus the program must guarantee that the original will not change\n** during the lifetime of the copy.  Use OP_Copy to make a complete\n** copy.\n*/\ncase OP_SCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  assert( pOut!=pIn1 );\n  sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);\n#ifdef SQLITE_DEBUG\n  if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1;\n#endif\n  break;\n}\n\n/* Opcode: IntCopy P1 P2 * * *\n** Synopsis: r[P2]=r[P1]\n**\n** Transfer the integer value held in register P1 into register P2.\n**\n** This is an optimized version of SCopy that works only for integer\n** values.\n*/\ncase OP_IntCopy: {            /* out2 */\n  pIn1 = &aMem[pOp->p1];\n  assert( (pIn1->flags & MEM_Int)!=0 );\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetInt64(pOut, pIn1->u.i);\n  break;\n}\n\n/* Opcode: ResultRow P1 P2 * * *\n** Synopsis: output=r[P1@P2]\n**\n** The registers P1 through P1+P2-1 contain a single row of\n** results. This opcode causes the sqlite3_step() call to terminate\n** with an SQLITE_ROW return code and it sets up the sqlite3_stmt\n** structure to provide access to the r(P1)..r(P1+P2-1) values as\n** the result row.\n*/\ncase OP_ResultRow: {\n  Mem *pMem;\n  int i;\n  assert( p->nResColumn==pOp->p2 );\n  assert( pOp->p1>0 );\n  assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 );\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Run the progress counter just before returning.\n  */\n  if( db->xProgress!=0\n   && nVmStep>=nProgressLimit \n   && db->xProgress(db->pProgressArg)!=0\n  ){\n    rc = SQLITE_INTERRUPT;\n    goto abort_due_to_error;\n  }\n#endif\n\n  /* If this statement has violated immediate foreign key constraints, do\n  ** not return the number of rows modified. And do not RELEASE the statement\n  ** transaction. It needs to be rolled back.  */\n  if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){\n    assert( db->flags&SQLITE_CountRows );\n    assert( p->usesStmtJournal );\n    goto abort_due_to_error;\n  }\n\n  /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then \n  ** DML statements invoke this opcode to return the number of rows \n  ** modified to the user. This is the only way that a VM that\n  ** opens a statement transaction may invoke this opcode.\n  **\n  ** In case this is such a statement, close any statement transaction\n  ** opened by this VM before returning control to the user. This is to\n  ** ensure that statement-transactions are always nested, not overlapping.\n  ** If the open statement-transaction is not closed here, then the user\n  ** may step another VM that opens its own statement transaction. This\n  ** may lead to overlapping statement transactions.\n  **\n  ** The statement transaction is never a top-level transaction.  Hence\n  ** the RELEASE call below can never fail.\n  */\n  assert( p->iStatement==0 || db->flags&SQLITE_CountRows );\n  rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE);\n  assert( rc==SQLITE_OK );\n\n  /* Invalidate all ephemeral cursor row caches */\n  p->cacheCtr = (p->cacheCtr + 2)|1;\n\n  /* Make sure the results of the current row are \\000 terminated\n  ** and have an assigned type.  The results are de-ephemeralized as\n  ** a side effect.\n  */\n  pMem = p->pResultSet = &aMem[pOp->p1];\n  for(i=0; i<pOp->p2; i++){\n    assert( memIsValid(&pMem[i]) );\n    Deephemeralize(&pMem[i]);\n    assert( (pMem[i].flags & MEM_Ephem)==0\n            || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 );\n    sqlite3VdbeMemNulTerminate(&pMem[i]);\n    REGISTER_TRACE(pOp->p1+i, &pMem[i]);\n  }\n  if( db->mallocFailed ) goto no_mem;\n\n  if( db->mTrace & SQLITE_TRACE_ROW ){\n    db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0);\n  }\n\n  /* Return SQLITE_ROW\n  */\n  p->pc = (int)(pOp - aOp) + 1;\n  rc = SQLITE_ROW;\n  goto vdbe_return;\n}\n\n/* Opcode: Concat P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]+r[P1]\n**\n** Add the text in register P1 onto the end of the text in\n** register P2 and store the result in register P3.\n** If either the P1 or P2 text are NULL then store NULL in P3.\n**\n**   P3 = P2 || P1\n**\n** It is illegal for P1 and P3 to be the same register. Sometimes,\n** if P3 is the same register as P2, the implementation is able\n** to avoid a memcpy().\n*/\ncase OP_Concat: {           /* same as TK_CONCAT, in1, in2, out3 */\n  i64 nByte;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  assert( pIn1!=pOut );\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  if( ExpandBlob(pIn1) || ExpandBlob(pIn2) ) goto no_mem;\n  Stringify(pIn1, encoding);\n  Stringify(pIn2, encoding);\n  nByte = pIn1->n + pIn2->n;\n  if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){\n    goto no_mem;\n  }\n  MemSetTypeFlag(pOut, MEM_Str);\n  if( pOut!=pIn2 ){\n    memcpy(pOut->z, pIn2->z, pIn2->n);\n  }\n  memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n);\n  pOut->z[nByte]=0;\n  pOut->z[nByte+1] = 0;\n  pOut->flags |= MEM_Term;\n  pOut->n = (int)nByte;\n  pOut->enc = encoding;\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Add P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]+r[P2]\n**\n** Add the value in register P1 to the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Multiply P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]*r[P2]\n**\n**\n** Multiply the value in register P1 by the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Subtract P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]-r[P1]\n**\n** Subtract the value in register P1 from the value in register P2\n** and store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: Divide P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]/r[P1]\n**\n** Divide the value in register P1 by the value in register P2\n** and store the result in register P3 (P3=P2/P1). If the value in \n** register P1 is zero, then the result is NULL. If either input is \n** NULL, the result is NULL.\n*/\n/* Opcode: Remainder P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]%r[P1]\n**\n** Compute the remainder after integer register P2 is divided by \n** register P1 and store the result in register P3. \n** If the value in register P1 is zero the result is NULL.\n** If either operand is NULL, the result is NULL.\n*/\ncase OP_Add:                   /* same as TK_PLUS, in1, in2, out3 */\ncase OP_Subtract:              /* same as TK_MINUS, in1, in2, out3 */\ncase OP_Multiply:              /* same as TK_STAR, in1, in2, out3 */\ncase OP_Divide:                /* same as TK_SLASH, in1, in2, out3 */\ncase OP_Remainder: {           /* same as TK_REM, in1, in2, out3 */\n  char bIntint;   /* Started out as two integer operands */\n  u16 flags;      /* Combined MEM_* flags from both inputs */\n  u16 type1;      /* Numeric type of left operand */\n  u16 type2;      /* Numeric type of right operand */\n  i64 iA;         /* Integer value of left operand */\n  i64 iB;         /* Integer value of right operand */\n  double rA;      /* Real value of left operand */\n  double rB;      /* Real value of right operand */\n\n  pIn1 = &aMem[pOp->p1];\n  type1 = numericType(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  type2 = numericType(pIn2);\n  pOut = &aMem[pOp->p3];\n  flags = pIn1->flags | pIn2->flags;\n  if( (type1 & type2 & MEM_Int)!=0 ){\n    iA = pIn1->u.i;\n    iB = pIn2->u.i;\n    bIntint = 1;\n    switch( pOp->opcode ){\n      case OP_Add:       if( sqlite3AddInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Subtract:  if( sqlite3SubInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Multiply:  if( sqlite3MulInt64(&iB,iA) ) goto fp_math;  break;\n      case OP_Divide: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 && iB==SMALLEST_INT64 ) goto fp_math;\n        iB /= iA;\n        break;\n      }\n      default: {\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        iB %= iA;\n        break;\n      }\n    }\n    pOut->u.i = iB;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }else if( (flags & MEM_Null)!=0 ){\n    goto arithmetic_result_is_null;\n  }else{\n    bIntint = 0;\nfp_math:\n    rA = sqlite3VdbeRealValue(pIn1);\n    rB = sqlite3VdbeRealValue(pIn2);\n    switch( pOp->opcode ){\n      case OP_Add:         rB += rA;       break;\n      case OP_Subtract:    rB -= rA;       break;\n      case OP_Multiply:    rB *= rA;       break;\n      case OP_Divide: {\n        /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n        if( rA==(double)0 ) goto arithmetic_result_is_null;\n        rB /= rA;\n        break;\n      }\n      default: {\n        iA = (i64)rA;\n        iB = (i64)rB;\n        if( iA==0 ) goto arithmetic_result_is_null;\n        if( iA==-1 ) iA = 1;\n        rB = (double)(iB % iA);\n        break;\n      }\n    }\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    pOut->u.i = rB;\n    MemSetTypeFlag(pOut, MEM_Int);\n#else\n    if( sqlite3IsNaN(rB) ){\n      goto arithmetic_result_is_null;\n    }\n    pOut->u.r = rB;\n    MemSetTypeFlag(pOut, MEM_Real);\n    if( ((type1|type2)&MEM_Real)==0 && !bIntint ){\n      sqlite3VdbeIntegerAffinity(pOut);\n    }\n#endif\n  }\n  break;\n\narithmetic_result_is_null:\n  sqlite3VdbeMemSetNull(pOut);\n  break;\n}\n\n/* Opcode: CollSeq P1 * * P4\n**\n** P4 is a pointer to a CollSeq object. If the next call to a user function\n** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will\n** be returned. This is used by the built-in min(), max() and nullif()\n** functions.\n**\n** If P1 is not zero, then it is a register that a subsequent min() or\n** max() aggregate will set to 1 if the current row is not the minimum or\n** maximum.  The P1 register is initialized to 0 by this instruction.\n**\n** The interface used by the implementation of the aforementioned functions\n** to retrieve the collation sequence set by this opcode is not available\n** publicly.  Only built-in functions have access to this feature.\n*/\ncase OP_CollSeq: {\n  assert( pOp->p4type==P4_COLLSEQ );\n  if( pOp->p1 ){\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p1], 0);\n  }\n  break;\n}\n\n/* Opcode: BitAnd P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]&r[P2]\n**\n** Take the bit-wise AND of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: BitOr P1 P2 P3 * *\n** Synopsis: r[P3]=r[P1]|r[P2]\n**\n** Take the bit-wise OR of the values in register P1 and P2 and\n** store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftLeft P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]<<r[P1]\n**\n** Shift the integer value in register P2 to the left by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\n/* Opcode: ShiftRight P1 P2 P3 * *\n** Synopsis: r[P3]=r[P2]>>r[P1]\n**\n** Shift the integer value in register P2 to the right by the\n** number of bits specified by the integer in register P1.\n** Store the result in register P3.\n** If either input is NULL, the result is NULL.\n*/\ncase OP_BitAnd:                 /* same as TK_BITAND, in1, in2, out3 */\ncase OP_BitOr:                  /* same as TK_BITOR, in1, in2, out3 */\ncase OP_ShiftLeft:              /* same as TK_LSHIFT, in1, in2, out3 */\ncase OP_ShiftRight: {           /* same as TK_RSHIFT, in1, in2, out3 */\n  i64 iA;\n  u64 uA;\n  i64 iB;\n  u8 op;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  pOut = &aMem[pOp->p3];\n  if( (pIn1->flags | pIn2->flags) & MEM_Null ){\n    sqlite3VdbeMemSetNull(pOut);\n    break;\n  }\n  iA = sqlite3VdbeIntValue(pIn2);\n  iB = sqlite3VdbeIntValue(pIn1);\n  op = pOp->opcode;\n  if( op==OP_BitAnd ){\n    iA &= iB;\n  }else if( op==OP_BitOr ){\n    iA |= iB;\n  }else if( iB!=0 ){\n    assert( op==OP_ShiftRight || op==OP_ShiftLeft );\n\n    /* If shifting by a negative amount, shift in the other direction */\n    if( iB<0 ){\n      assert( OP_ShiftRight==OP_ShiftLeft+1 );\n      op = 2*OP_ShiftLeft + 1 - op;\n      iB = iB>(-64) ? -iB : 64;\n    }\n\n    if( iB>=64 ){\n      iA = (iA>=0 || op==OP_ShiftLeft) ? 0 : -1;\n    }else{\n      memcpy(&uA, &iA, sizeof(uA));\n      if( op==OP_ShiftLeft ){\n        uA <<= iB;\n      }else{\n        uA >>= iB;\n        /* Sign-extend on a right shift of a negative number */\n        if( iA<0 ) uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-iB);\n      }\n      memcpy(&iA, &uA, sizeof(iA));\n    }\n  }\n  pOut->u.i = iA;\n  MemSetTypeFlag(pOut, MEM_Int);\n  break;\n}\n\n/* Opcode: AddImm  P1 P2 * * *\n** Synopsis: r[P1]=r[P1]+P2\n** \n** Add the constant P2 to the value in register P1.\n** The result is always an integer.\n**\n** To force any register to be an integer, just add 0.\n*/\ncase OP_AddImm: {            /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn1->u.i += pOp->p2;\n  break;\n}\n\n/* Opcode: MustBeInt P1 P2 * * *\n** \n** Force the value in register P1 to be an integer.  If the value\n** in P1 is not an integer and cannot be converted into an integer\n** without data loss, then jump immediately to P2, or if P2==0\n** raise an SQLITE_MISMATCH exception.\n*/\ncase OP_MustBeInt: {            /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_Int)==0 ){\n    applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);\n    VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2);\n    if( (pIn1->flags & MEM_Int)==0 ){\n      if( pOp->p2==0 ){\n        rc = SQLITE_MISMATCH;\n        goto abort_due_to_error;\n      }else{\n        goto jump_to_p2;\n      }\n    }\n  }\n  MemSetTypeFlag(pIn1, MEM_Int);\n  break;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/* Opcode: RealAffinity P1 * * * *\n**\n** If register P1 holds an integer convert it to a real value.\n**\n** This opcode is used when extracting information from a column that\n** has REAL affinity.  Such column values may still be stored as\n** integers, for space efficiency, but after extraction we want them\n** to have only a real value.\n*/\ncase OP_RealAffinity: {                  /* in1 */\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Int ){\n    sqlite3VdbeMemRealify(pIn1);\n  }\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_CAST\n/* Opcode: Cast P1 P2 * * *\n** Synopsis: affinity(r[P1])\n**\n** Force the value in register P1 to be the type defined by P2.\n** \n** <ul>\n** <li> P2=='A' &rarr; BLOB\n** <li> P2=='B' &rarr; TEXT\n** <li> P2=='C' &rarr; NUMERIC\n** <li> P2=='D' &rarr; INTEGER\n** <li> P2=='E' &rarr; REAL\n** </ul>\n**\n** A NULL value is not changed by this routine.  It remains NULL.\n*/\ncase OP_Cast: {                  /* in1 */\n  assert( pOp->p2>=SQLITE_AFF_BLOB && pOp->p2<=SQLITE_AFF_REAL );\n  testcase( pOp->p2==SQLITE_AFF_TEXT );\n  testcase( pOp->p2==SQLITE_AFF_BLOB );\n  testcase( pOp->p2==SQLITE_AFF_NUMERIC );\n  testcase( pOp->p2==SQLITE_AFF_INTEGER );\n  testcase( pOp->p2==SQLITE_AFF_REAL );\n  pIn1 = &aMem[pOp->p1];\n  memAboutToChange(p, pIn1);\n  rc = ExpandBlob(pIn1);\n  sqlite3VdbeMemCast(pIn1, pOp->p2, encoding);\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_CAST */\n\n/* Opcode: Eq P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]==r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)==reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5, then\n** store the result of comparison in register P2.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n**\n** If SQLITE_NULLEQ is set in P5 then the result of comparison is always either\n** true or false and is never NULL.  If both operands are NULL then the result\n** of comparison is true.  If either operand is NULL then the result is false.\n** If neither operand is NULL the result is the same as it would be if\n** the SQLITE_NULLEQ flag were omitted from P5.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 0 (false).\n** In other words, a prior r[P2] value will not be overwritten by 1 (true).\n*/\n/* Opcode: Ne P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]!=r[P1]\n**\n** This works just like the Eq opcode except that the jump is taken if\n** the operands in registers P1 and P3 are not equal.  See the Eq opcode for\n** additional information.\n**\n** If both SQLITE_STOREP2 and SQLITE_KEEPNULL flags are set then the\n** content of r[P2] is only changed if the new value is NULL or 1 (true).\n** In other words, a prior r[P2] value will not be overwritten by 0 (false).\n*/\n/* Opcode: Lt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<r[P1]\n**\n** Compare the values in register P1 and P3.  If reg(P3)<reg(P1) then\n** jump to address P2.  Or if the SQLITE_STOREP2 flag is set in P5 store\n** the result of comparison (0 or 1 or NULL) into register P2.\n**\n** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or\n** reg(P3) is NULL then the take the jump.  If the SQLITE_JUMPIFNULL \n** bit is clear then fall through if either operand is NULL.\n**\n** The SQLITE_AFF_MASK portion of P5 must be an affinity character -\n** SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made \n** to coerce both inputs according to this affinity before the\n** comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric\n** affinity is used. Note that the affinity conversions are stored\n** back into the input registers P1 and P3.  So this opcode can cause\n** persistent changes to registers P1 and P3.\n**\n** Once any conversions have taken place, and neither value is NULL, \n** the values are compared. If both values are blobs then memcmp() is\n** used to determine the results of the comparison.  If both values\n** are text, then the appropriate collating function specified in\n** P4 is  used to do the comparison.  If P4 is not specified then\n** memcmp() is used to compare text string.  If both values are\n** numeric, then a numeric comparison is used. If the two values\n** are of different types, then numbers are considered less than\n** strings and strings are considered less than blobs.\n*/\n/* Opcode: Le P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]<=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is less than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Gt P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than the content of\n** register P1.  See the Lt opcode for additional information.\n*/\n/* Opcode: Ge P1 P2 P3 P4 P5\n** Synopsis: IF r[P3]>=r[P1]\n**\n** This works just like the Lt opcode except that the jump is taken if\n** the content of register P3 is greater than or equal to the content of\n** register P1.  See the Lt opcode for additional information.\n*/\ncase OP_Eq:               /* same as TK_EQ, jump, in1, in3 */\ncase OP_Ne:               /* same as TK_NE, jump, in1, in3 */\ncase OP_Lt:               /* same as TK_LT, jump, in1, in3 */\ncase OP_Le:               /* same as TK_LE, jump, in1, in3 */\ncase OP_Gt:               /* same as TK_GT, jump, in1, in3 */\ncase OP_Ge: {             /* same as TK_GE, jump, in1, in3 */\n  int res, res2;      /* Result of the comparison of pIn1 against pIn3 */\n  char affinity;      /* Affinity to use for comparison */\n  u16 flags1;         /* Copy of initial value of pIn1->flags */\n  u16 flags3;         /* Copy of initial value of pIn3->flags */\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  flags1 = pIn1->flags;\n  flags3 = pIn3->flags;\n  if( (flags1 | flags3)&MEM_Null ){\n    /* One or both operands are NULL */\n    if( pOp->p5 & SQLITE_NULLEQ ){\n      /* If SQLITE_NULLEQ is set (which will only happen if the operator is\n      ** OP_Eq or OP_Ne) then take the jump or not depending on whether\n      ** or not both operands are null.\n      */\n      assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );\n      assert( (flags1 & MEM_Cleared)==0 );\n      assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );\n      if( (flags1&flags3&MEM_Null)!=0\n       && (flags3&MEM_Cleared)==0\n      ){\n        res = 0;  /* Operands are equal */\n      }else{\n        res = 1;  /* Operands are not equal */\n      }\n    }else{\n      /* SQLITE_NULLEQ is clear and at least one operand is NULL,\n      ** then the result is always NULL.\n      ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.\n      */\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        pOut = &aMem[pOp->p2];\n        iCompare = 1;    /* Operands are not equal */\n        memAboutToChange(p, pOut);\n        MemSetTypeFlag(pOut, MEM_Null);\n        REGISTER_TRACE(pOp->p2, pOut);\n      }else{\n        VdbeBranchTaken(2,3);\n        if( pOp->p5 & SQLITE_JUMPIFNULL ){\n          goto jump_to_p2;\n        }\n      }\n      break;\n    }\n  }else{\n    /* Neither operand is NULL.  Do a comparison. */\n    affinity = pOp->p5 & SQLITE_AFF_MASK;\n    if( affinity>=SQLITE_AFF_NUMERIC ){\n      if( (flags1 | flags3)&MEM_Str ){\n        if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn1,0);\n          testcase( flags3!=pIn3->flags ); /* Possible if pIn1==pIn3 */\n          flags3 = pIn3->flags;\n        }\n        if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n          applyNumericAffinity(pIn3,0);\n        }\n      }\n      /* Handle the common case of integer comparison here, as an\n      ** optimization, to avoid a call to sqlite3MemCompare() */\n      if( (pIn1->flags & pIn3->flags & MEM_Int)!=0 ){\n        if( pIn3->u.i > pIn1->u.i ){ res = +1; goto compare_op; }\n        if( pIn3->u.i < pIn1->u.i ){ res = -1; goto compare_op; }\n        res = 0;\n        goto compare_op;\n      }\n    }else if( affinity==SQLITE_AFF_TEXT ){\n      if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn1->flags & MEM_Int );\n        testcase( pIn1->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn1, encoding, 1);\n        testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );\n        flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);\n        assert( pIn1!=pIn3 );\n      }\n      if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){\n        testcase( pIn3->flags & MEM_Int );\n        testcase( pIn3->flags & MEM_Real );\n        sqlite3VdbeMemStringify(pIn3, encoding, 1);\n        testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );\n        flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);\n      }\n    }\n    assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );\n    res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);\n  }\ncompare_op:\n  /* At this point, res is negative, zero, or positive if reg[P1] is\n  ** less than, equal to, or greater than reg[P3], respectively.  Compute\n  ** the answer to this operator in res2, depending on what the comparison\n  ** operator actually is.  The next block of code depends on the fact\n  ** that the 6 comparison operators are consecutive integers in this\n  ** order:  NE, EQ, GT, LE, LT, GE */\n  assert( OP_Eq==OP_Ne+1 ); assert( OP_Gt==OP_Ne+2 ); assert( OP_Le==OP_Ne+3 );\n  assert( OP_Lt==OP_Ne+4 ); assert( OP_Ge==OP_Ne+5 );\n  if( res<0 ){                        /* ne, eq, gt, le, lt, ge */\n    static const unsigned char aLTb[] = { 1,  0,  0,  1,  1,  0 };\n    res2 = aLTb[pOp->opcode - OP_Ne];\n  }else if( res==0 ){\n    static const unsigned char aEQb[] = { 0,  1,  0,  1,  0,  1 };\n    res2 = aEQb[pOp->opcode - OP_Ne];\n  }else{\n    static const unsigned char aGTb[] = { 1,  0,  1,  0,  0,  1 };\n    res2 = aGTb[pOp->opcode - OP_Ne];\n  }\n\n  /* Undo any changes made by applyAffinity() to the input registers. */\n  assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );\n  pIn1->flags = flags1;\n  assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );\n  pIn3->flags = flags3;\n\n  if( pOp->p5 & SQLITE_STOREP2 ){\n    pOut = &aMem[pOp->p2];\n    iCompare = res;\n    if( (pOp->p5 & SQLITE_KEEPNULL)!=0 ){\n      /* The KEEPNULL flag prevents OP_Eq from overwriting a NULL with 1\n      ** and prevents OP_Ne from overwriting NULL with 0.  This flag\n      ** is only used in contexts where either:\n      **   (1) op==OP_Eq && (r[P2]==NULL || r[P2]==0)\n      **   (2) op==OP_Ne && (r[P2]==NULL || r[P2]==1)\n      ** Therefore it is not necessary to check the content of r[P2] for\n      ** NULL. */\n      assert( pOp->opcode==OP_Ne || pOp->opcode==OP_Eq );\n      assert( res2==0 || res2==1 );\n      testcase( res2==0 && pOp->opcode==OP_Eq );\n      testcase( res2==1 && pOp->opcode==OP_Eq );\n      testcase( res2==0 && pOp->opcode==OP_Ne );\n      testcase( res2==1 && pOp->opcode==OP_Ne );\n      if( (pOp->opcode==OP_Eq)==res2 ) break;\n    }\n    memAboutToChange(p, pOut);\n    MemSetTypeFlag(pOut, MEM_Int);\n    pOut->u.i = res2;\n    REGISTER_TRACE(pOp->p2, pOut);\n  }else{\n    VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);\n    if( res2 ){\n      goto jump_to_p2;\n    }\n  }\n  break;\n}\n\n/* Opcode: ElseNotEq * P2 * * *\n**\n** This opcode must immediately follow an OP_Lt or OP_Gt comparison operator.\n** If result of an OP_Eq comparison on the same two operands\n** would have be NULL or false (0), then then jump to P2. \n** If the result of an OP_Eq comparison on the two previous operands\n** would have been true (1), then fall through.\n*/\ncase OP_ElseNotEq: {       /* same as TK_ESCAPE, jump */\n  assert( pOp>aOp );\n  assert( pOp[-1].opcode==OP_Lt || pOp[-1].opcode==OP_Gt );\n  assert( pOp[-1].p5 & SQLITE_STOREP2 );\n  VdbeBranchTaken(iCompare!=0, 2);\n  if( iCompare!=0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: Permutation * * * P4 *\n**\n** Set the permutation used by the OP_Compare operator in the next\n** instruction.  The permutation is stored in the P4 operand.\n**\n** The permutation is only valid until the next OP_Compare that has\n** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should \n** occur immediately prior to the OP_Compare.\n**\n** The first integer in the P4 integer array is the length of the array\n** and does not become part of the permutation.\n*/\ncase OP_Permutation: {\n  assert( pOp->p4type==P4_INTARRAY );\n  assert( pOp->p4.ai );\n  assert( pOp[1].opcode==OP_Compare );\n  assert( pOp[1].p5 & OPFLAG_PERMUTE );\n  break;\n}\n\n/* Opcode: Compare P1 P2 P3 P4 P5\n** Synopsis: r[P1@P3] <-> r[P2@P3]\n**\n** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this\n** vector \"A\") and in reg(P2)..reg(P2+P3-1) (\"B\").  Save the result of\n** the comparison for use by the next OP_Jump instruct.\n**\n** If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is\n** determined by the most recent OP_Permutation operator.  If the\n** OPFLAG_PERMUTE bit is clear, then register are compared in sequential\n** order.\n**\n** P4 is a KeyInfo structure that defines collating sequences and sort\n** orders for the comparison.  The permutation applies to registers\n** only.  The KeyInfo elements are used sequentially.\n**\n** The comparison is a sort comparison, so NULLs compare equal,\n** NULLs are less than numbers, numbers are less than strings,\n** and strings are less than blobs.\n*/\ncase OP_Compare: {\n  int n;\n  int i;\n  int p1;\n  int p2;\n  const KeyInfo *pKeyInfo;\n  int idx;\n  CollSeq *pColl;    /* Collating sequence to use on this term */\n  int bRev;          /* True for DESCENDING sort order */\n  int *aPermute;     /* The permutation */\n\n  if( (pOp->p5 & OPFLAG_PERMUTE)==0 ){\n    aPermute = 0;\n  }else{\n    assert( pOp>aOp );\n    assert( pOp[-1].opcode==OP_Permutation );\n    assert( pOp[-1].p4type==P4_INTARRAY );\n    aPermute = pOp[-1].p4.ai + 1;\n    assert( aPermute!=0 );\n  }\n  n = pOp->p3;\n  pKeyInfo = pOp->p4.pKeyInfo;\n  assert( n>0 );\n  assert( pKeyInfo!=0 );\n  p1 = pOp->p1;\n  p2 = pOp->p2;\n#ifdef SQLITE_DEBUG\n  if( aPermute ){\n    int k, mx = 0;\n    for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];\n    assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );\n  }else{\n    assert( p1>0 && p1+n<=(p->nMem+1 - p->nCursor)+1 );\n    assert( p2>0 && p2+n<=(p->nMem+1 - p->nCursor)+1 );\n  }\n#endif /* SQLITE_DEBUG */\n  for(i=0; i<n; i++){\n    idx = aPermute ? aPermute[i] : i;\n    assert( memIsValid(&aMem[p1+idx]) );\n    assert( memIsValid(&aMem[p2+idx]) );\n    REGISTER_TRACE(p1+idx, &aMem[p1+idx]);\n    REGISTER_TRACE(p2+idx, &aMem[p2+idx]);\n    assert( i<pKeyInfo->nKeyField );\n    pColl = pKeyInfo->aColl[i];\n    bRev = pKeyInfo->aSortOrder[i];\n    iCompare = sqlite3MemCompare(&aMem[p1+idx], &aMem[p2+idx], pColl);\n    if( iCompare ){\n      if( bRev ) iCompare = -iCompare;\n      break;\n    }\n  }\n  break;\n}\n\n/* Opcode: Jump P1 P2 P3 * *\n**\n** Jump to the instruction at address P1, P2, or P3 depending on whether\n** in the most recent OP_Compare instruction the P1 vector was less than\n** equal to, or greater than the P2 vector, respectively.\n*/\ncase OP_Jump: {             /* jump */\n  if( iCompare<0 ){\n    VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];\n  }else if( iCompare==0 ){\n    VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];\n  }else{\n    VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];\n  }\n  break;\n}\n\n/* Opcode: And P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] && r[P2])\n**\n** Take the logical AND of the values in registers P1 and P2 and\n** write the result into register P3.\n**\n** If either P1 or P2 is 0 (false) then the result is 0 even if\n** the other input is NULL.  A NULL and true or two NULLs give\n** a NULL output.\n*/\n/* Opcode: Or P1 P2 P3 * *\n** Synopsis: r[P3]=(r[P1] || r[P2])\n**\n** Take the logical OR of the values in register P1 and P2 and\n** store the answer in register P3.\n**\n** If either P1 or P2 is nonzero (true) then the result is 1 (true)\n** even if the other input is NULL.  A NULL and false or two NULLs\n** give a NULL output.\n*/\ncase OP_And:              /* same as TK_AND, in1, in2, out3 */\ncase OP_Or: {             /* same as TK_OR, in1, in2, out3 */\n  int v1;    /* Left operand:  0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n  int v2;    /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */\n\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    v1 = 2;\n  }else{\n    v1 = sqlite3VdbeIntValue(pIn1)!=0;\n  }\n  pIn2 = &aMem[pOp->p2];\n  if( pIn2->flags & MEM_Null ){\n    v2 = 2;\n  }else{\n    v2 = sqlite3VdbeIntValue(pIn2)!=0;\n  }\n  if( pOp->opcode==OP_And ){\n    static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 };\n    v1 = and_logic[v1*3+v2];\n  }else{\n    static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 };\n    v1 = or_logic[v1*3+v2];\n  }\n  pOut = &aMem[pOp->p3];\n  if( v1==2 ){\n    MemSetTypeFlag(pOut, MEM_Null);\n  }else{\n    pOut->u.i = v1;\n    MemSetTypeFlag(pOut, MEM_Int);\n  }\n  break;\n}\n\n/* Opcode: Not P1 P2 * * *\n** Synopsis: r[P2]= !r[P1]\n**\n** Interpret the value in register P1 as a boolean value.  Store the\n** boolean complement in register P2.  If the value in register P1 is \n** NULL, then a NULL is stored in P2.\n*/\ncase OP_Not: {                /* same as TK_NOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetNull(pOut);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pOut->flags = MEM_Int;\n    pOut->u.i = !sqlite3VdbeIntValue(pIn1);\n  }\n  break;\n}\n\n/* Opcode: BitNot P1 P2 * * *\n** Synopsis: r[P1]= ~r[P1]\n**\n** Interpret the content of register P1 as an integer.  Store the\n** ones-complement of the P1 value into register P2.  If P1 holds\n** a NULL then store a NULL in P2.\n*/\ncase OP_BitNot: {             /* same as TK_BITNOT, in1, out2 */\n  pIn1 = &aMem[pOp->p1];\n  pOut = &aMem[pOp->p2];\n  sqlite3VdbeMemSetNull(pOut);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    pOut->flags = MEM_Int;\n    pOut->u.i = ~sqlite3VdbeIntValue(pIn1);\n  }\n  break;\n}\n\n/* Opcode: Once P1 P2 * * *\n**\n** Fall through to the next instruction the first time this opcode is\n** encountered on each invocation of the byte-code program.  Jump to P2\n** on the second and all subsequent encounters during the same invocation.\n**\n** Top-level programs determine first invocation by comparing the P1\n** operand against the P1 operand on the OP_Init opcode at the beginning\n** of the program.  If the P1 values differ, then fall through and make\n** the P1 of this opcode equal to the P1 of OP_Init.  If P1 values are\n** the same then take the jump.\n**\n** For subprograms, there is a bitmask in the VdbeFrame that determines\n** whether or not the jump should be taken.  The bitmask is necessary\n** because the self-altering code trick does not work for recursive\n** triggers.\n*/\ncase OP_Once: {             /* jump */\n  u32 iAddr;                /* Address of this instruction */\n  assert( p->aOp[0].opcode==OP_Init );\n  if( p->pFrame ){\n    iAddr = (int)(pOp - p->aOp);\n    if( (p->pFrame->aOnce[iAddr/8] & (1<<(iAddr & 7)))!=0 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n    p->pFrame->aOnce[iAddr/8] |= 1<<(iAddr & 7);\n  }else{\n    if( p->aOp[0].p1==pOp->p1 ){\n      VdbeBranchTaken(1, 2);\n      goto jump_to_p2;\n    }\n  }\n  VdbeBranchTaken(0, 2);\n  pOp->p1 = p->aOp[0].p1;\n  break;\n}\n\n/* Opcode: If P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is true.  The value\n** is considered true if it is numeric and non-zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\n/* Opcode: IfNot P1 P2 P3 * *\n**\n** Jump to P2 if the value in register P1 is False.  The value\n** is considered false if it has a numeric value of zero.  If the value\n** in P1 is NULL then take the jump if and only if P3 is non-zero.\n*/\ncase OP_If:                 /* jump, in1 */\ncase OP_IfNot: {            /* jump, in1 */\n  int c;\n  pIn1 = &aMem[pOp->p1];\n  if( pIn1->flags & MEM_Null ){\n    c = pOp->p3;\n  }else{\n#ifdef SQLITE_OMIT_FLOATING_POINT\n    c = sqlite3VdbeIntValue(pIn1)!=0;\n#else\n    c = sqlite3VdbeRealValue(pIn1)!=0.0;\n#endif\n    if( pOp->opcode==OP_IfNot ) c = !c;\n  }\n  VdbeBranchTaken(c!=0, 2);\n  if( c ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IsNull P1 P2 * * *\n** Synopsis: if r[P1]==NULL goto P2\n**\n** Jump to P2 if the value in register P1 is NULL.\n*/\ncase OP_IsNull: {            /* same as TK_ISNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);\n  if( (pIn1->flags & MEM_Null)!=0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: NotNull P1 P2 * * *\n** Synopsis: if r[P1]!=NULL goto P2\n**\n** Jump to P2 if the value in register P1 is not NULL.  \n*/\ncase OP_NotNull: {            /* same as TK_NOTNULL, jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);\n  if( (pIn1->flags & MEM_Null)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfNullRow P1 P2 P3 * *\n** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2\n**\n** Check the cursor P1 to see if it is currently pointing at a NULL row.\n** If it is, then set register P3 to NULL and jump immediately to P2.\n** If P1 is not on a NULL row, then fall through without making any\n** changes.\n*/\ncase OP_IfNullRow: {         /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  if( p->apCsr[pOp->p1]->nullRow ){\n    sqlite3VdbeMemSetNull(aMem + pOp->p3);\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: Column P1 P2 P3 P4 P5\n** Synopsis: r[P3]=PX\n**\n** Interpret the data that cursor P1 points to as a structure built using\n** the MakeRecord instruction.  (See the MakeRecord opcode for additional\n** information about the format of the data.)  Extract the P2-th column\n** from this record.  If there are less that (P2+1) \n** values in the record, extract a NULL.\n**\n** The value extracted is stored in register P3.\n**\n** If the record contains fewer than P2 fields, then extract a NULL.  Or,\n** if the P4 argument is a P4_MEM use the value of the P4 argument as\n** the result.\n**\n** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,\n** then the cache of the cursor is reset prior to extracting the column.\n** The first OP_Column against a pseudo-table after the value of the content\n** register has changed should have this bit set.\n**\n** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then\n** the result is guaranteed to only be used as the argument of a length()\n** or typeof() function, respectively.  The loading of large blobs can be\n** skipped for length() and all content loading can be skipped for typeof().\n*/\ncase OP_Column: {\n  int p2;            /* column number to retrieve */\n  VdbeCursor *pC;    /* The VDBE cursor */\n  BtCursor *pCrsr;   /* The BTree cursor */\n  u32 *aOffset;      /* aOffset[i] is offset to start of data for i-th column */\n  int len;           /* The length of the serialized data for the column */\n  int i;             /* Loop counter */\n  Mem *pDest;        /* Where to write the extracted value */\n  Mem sMem;          /* For storing the record being decoded */\n  const u8 *zData;   /* Part of the record being decoded */\n  const u8 *zHdr;    /* Next unparsed byte of the header */\n  const u8 *zEndHdr; /* Pointer to first byte after the header */\n  u64 offset64;      /* 64-bit offset */\n  u32 t;             /* A type code from the record header */\n  Mem *pReg;         /* PseudoTable input register */\n\n  pC = p->apCsr[pOp->p1];\n  p2 = pOp->p2;\n\n  /* If the cursor cache is stale (meaning it is not currently point at\n  ** the correct row) then bring it up-to-date by doing the necessary \n  ** B-Tree seek. */\n  rc = sqlite3VdbeCursorMoveto(&pC, &p2);\n  if( rc ) goto abort_due_to_error;\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pC!=0 );\n  assert( p2<pC->nField );\n  aOffset = pC->aOffset;\n  assert( pC->eCurType!=CURTYPE_VTAB );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  assert( pC->eCurType!=CURTYPE_SORTER );\n\n  if( pC->cacheStatus!=p->cacheCtr ){                /*OPTIMIZATION-IF-FALSE*/\n    if( pC->nullRow ){\n      if( pC->eCurType==CURTYPE_PSEUDO ){\n        /* For the special case of as pseudo-cursor, the seekResult field\n        ** identifies the register that holds the record */\n        assert( pC->seekResult>0 );\n        pReg = &aMem[pC->seekResult];\n        assert( pReg->flags & MEM_Blob );\n        assert( memIsValid(pReg) );\n        pC->payloadSize = pC->szRow = pReg->n;\n        pC->aRow = (u8*)pReg->z;\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n        goto op_column_out;\n      }\n    }else{\n      pCrsr = pC->uc.pCursor;\n      assert( pC->eCurType==CURTYPE_BTREE );\n      assert( pCrsr );\n      assert( sqlite3BtreeCursorIsValid(pCrsr) );\n      pC->payloadSize = sqlite3BtreePayloadSize(pCrsr);\n      pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &pC->szRow);\n      assert( pC->szRow<=pC->payloadSize );\n      assert( pC->szRow<=65536 );  /* Maximum page size is 64KiB */\n      if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n        goto too_big;\n      }\n    }\n    pC->cacheStatus = p->cacheCtr;\n    pC->iHdrOffset = getVarint32(pC->aRow, aOffset[0]);\n    pC->nHdrParsed = 0;\n\n\n    if( pC->szRow<aOffset[0] ){      /*OPTIMIZATION-IF-FALSE*/\n      /* pC->aRow does not have to hold the entire row, but it does at least\n      ** need to cover the header of the record.  If pC->aRow does not contain\n      ** the complete header, then set it to zero, forcing the header to be\n      ** dynamically allocated. */\n      pC->aRow = 0;\n      pC->szRow = 0;\n\n      /* Make sure a corrupt database has not given us an oversize header.\n      ** Do this now to avoid an oversize memory allocation.\n      **\n      ** Type entries can be between 1 and 5 bytes each.  But 4 and 5 byte\n      ** types use so much data space that there can only be 4096 and 32 of\n      ** them, respectively.  So the maximum header length results from a\n      ** 3-byte type for each of the maximum of 32768 columns plus three\n      ** extra bytes for the header length itself.  32768*3 + 3 = 98307.\n      */\n      if( aOffset[0] > 98307 || aOffset[0] > pC->payloadSize ){\n        goto op_column_corrupt;\n      }\n    }else{\n      /* This is an optimization.  By skipping over the first few tests\n      ** (ex: pC->nHdrParsed<=p2) in the next section, we achieve a\n      ** measurable performance gain.\n      **\n      ** This branch is taken even if aOffset[0]==0.  Such a record is never\n      ** generated by SQLite, and could be considered corruption, but we\n      ** accept it for historical reasons.  When aOffset[0]==0, the code this\n      ** branch jumps to reads past the end of the record, but never more\n      ** than a few bytes.  Even if the record occurs at the end of the page\n      ** content area, the \"page header\" comes after the page content and so\n      ** this overread is harmless.  Similar overreads can occur for a corrupt\n      ** database file.\n      */\n      zData = pC->aRow;\n      assert( pC->nHdrParsed<=p2 );         /* Conditional skipped */\n      testcase( aOffset[0]==0 );\n      goto op_column_read_header;\n    }\n  }\n\n  /* Make sure at least the first p2+1 entries of the header have been\n  ** parsed and valid information is in aOffset[] and pC->aType[].\n  */\n  if( pC->nHdrParsed<=p2 ){\n    /* If there is more header available for parsing in the record, try\n    ** to extract additional fields up through the p2+1-th field \n    */\n    if( pC->iHdrOffset<aOffset[0] ){\n      /* Make sure zData points to enough of the record to cover the header. */\n      if( pC->aRow==0 ){\n        memset(&sMem, 0, sizeof(sMem));\n        rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, 0, aOffset[0], &sMem);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n        zData = (u8*)sMem.z;\n      }else{\n        zData = pC->aRow;\n      }\n  \n      /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */\n    op_column_read_header:\n      i = pC->nHdrParsed;\n      offset64 = aOffset[i];\n      zHdr = zData + pC->iHdrOffset;\n      zEndHdr = zData + aOffset[0];\n      testcase( zHdr>=zEndHdr );\n      do{\n        if( (t = zHdr[0])<0x80 ){\n          zHdr++;\n          offset64 += sqlite3VdbeOneByteSerialTypeLen(t);\n        }else{\n          zHdr += sqlite3GetVarint32(zHdr, &t);\n          offset64 += sqlite3VdbeSerialTypeLen(t);\n        }\n        pC->aType[i++] = t;\n        aOffset[i] = (u32)(offset64 & 0xffffffff);\n      }while( i<=p2 && zHdr<zEndHdr );\n\n      /* The record is corrupt if any of the following are true:\n      ** (1) the bytes of the header extend past the declared header size\n      ** (2) the entire header was used but not all data was used\n      ** (3) the end of the data extends beyond the end of the record.\n      */\n      if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize))\n       || (offset64 > pC->payloadSize)\n      ){\n        if( aOffset[0]==0 ){\n          i = 0;\n          zHdr = zEndHdr;\n        }else{\n          if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n          goto op_column_corrupt;\n        }\n      }\n\n      pC->nHdrParsed = i;\n      pC->iHdrOffset = (u32)(zHdr - zData);\n      if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem);\n    }else{\n      t = 0;\n    }\n\n    /* If after trying to extract new entries from the header, nHdrParsed is\n    ** still not up to p2, that means that the record has fewer than p2\n    ** columns.  So the result will be either the default value or a NULL.\n    */\n    if( pC->nHdrParsed<=p2 ){\n      if( pOp->p4type==P4_MEM ){\n        sqlite3VdbeMemShallowCopy(pDest, pOp->p4.pMem, MEM_Static);\n      }else{\n        sqlite3VdbeMemSetNull(pDest);\n      }\n      goto op_column_out;\n    }\n  }else{\n    t = pC->aType[p2];\n  }\n\n  /* Extract the content for the p2+1-th column.  Control can only\n  ** reach this point if aOffset[p2], aOffset[p2+1], and pC->aType[p2] are\n  ** all valid.\n  */\n  assert( p2<pC->nHdrParsed );\n  assert( rc==SQLITE_OK );\n  assert( sqlite3VdbeCheckMemInvariants(pDest) );\n  if( VdbeMemDynamic(pDest) ){\n    sqlite3VdbeMemSetNull(pDest);\n  }\n  assert( t==pC->aType[p2] );\n  if( pC->szRow>=aOffset[p2+1] ){\n    /* This is the common case where the desired content fits on the original\n    ** page - where the content is not on an overflow page */\n    zData = pC->aRow + aOffset[p2];\n    if( t<12 ){\n      sqlite3VdbeSerialGet(zData, t, pDest);\n    }else{\n      /* If the column value is a string, we need a persistent value, not\n      ** a MEM_Ephem value.  This branch is a fast short-cut that is equivalent\n      ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize().\n      */\n      static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term };\n      pDest->n = len = (t-12)/2;\n      pDest->enc = encoding;\n      if( pDest->szMalloc < len+2 ){\n        pDest->flags = MEM_Null;\n        if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem;\n      }else{\n        pDest->z = pDest->zMalloc;\n      }\n      memcpy(pDest->z, zData, len);\n      pDest->z[len] = 0;\n      pDest->z[len+1] = 0;\n      pDest->flags = aFlag[t&1];\n    }\n  }else{\n    pDest->enc = encoding;\n    /* This branch happens only when content is on overflow pages */\n    if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0\n          && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0))\n     || (len = sqlite3VdbeSerialTypeLen(t))==0\n    ){\n      /* Content is irrelevant for\n      **    1. the typeof() function,\n      **    2. the length(X) function if X is a blob, and\n      **    3. if the content length is zero.\n      ** So we might as well use bogus content rather than reading\n      ** content from disk. \n      **\n      ** Although sqlite3VdbeSerialGet() may read at most 8 bytes from the\n      ** buffer passed to it, debugging function VdbeMemPrettyPrint() may\n      ** read up to 16. So 16 bytes of bogus content is supplied.\n      */\n      static u8 aZero[16];  /* This is the bogus content */\n      sqlite3VdbeSerialGet(aZero, t, pDest);\n    }else{\n      rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest);\n      pDest->flags &= ~MEM_Ephem;\n    }\n  }\n\nop_column_out:\n  UPDATE_MAX_BLOBSIZE(pDest);\n  REGISTER_TRACE(pOp->p3, pDest);\n  break;\n\nop_column_corrupt:\n  if( aOp[0].p3>0 ){\n    pOp = &aOp[aOp[0].p3-1];\n    break;\n  }else{\n    rc = SQLITE_CORRUPT_BKPT;\n    goto abort_due_to_error;\n  }\n}\n\n/* Opcode: Affinity P1 P2 * P4 *\n** Synopsis: affinity(r[P1@P2])\n**\n** Apply affinities to a range of P2 registers starting with P1.\n**\n** P4 is a string that is P2 characters long. The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** memory cell in the range.\n*/\ncase OP_Affinity: {\n  const char *zAffinity;   /* The affinity to be applied */\n\n  zAffinity = pOp->p4.z;\n  assert( zAffinity!=0 );\n  assert( pOp->p2>0 );\n  assert( zAffinity[pOp->p2]==0 );\n  pIn1 = &aMem[pOp->p1];\n  do{\n    assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] );\n    assert( memIsValid(pIn1) );\n    applyAffinity(pIn1, *(zAffinity++), encoding);\n    pIn1++;\n  }while( zAffinity[0] );\n  break;\n}\n\n/* Opcode: MakeRecord P1 P2 P3 P4 *\n** Synopsis: r[P3]=mkrec(r[P1@P2])\n**\n** Convert P2 registers beginning with P1 into the [record format]\n** use as a data record in a database table or as a key\n** in an index.  The OP_Column opcode can decode the record later.\n**\n** P4 may be a string that is P2 characters long.  The N-th character of the\n** string indicates the column affinity that should be used for the N-th\n** field of the index key.\n**\n** The mapping from character to affinity is given by the SQLITE_AFF_\n** macros defined in sqliteInt.h.\n**\n** If P4 is NULL then all index fields have the affinity BLOB.\n*/\ncase OP_MakeRecord: {\n  u8 *zNewRecord;        /* A buffer to hold the data for the new record */\n  Mem *pRec;             /* The new record */\n  u64 nData;             /* Number of bytes of data space */\n  int nHdr;              /* Number of bytes of header space */\n  i64 nByte;             /* Data space required for this record */\n  i64 nZero;             /* Number of zero bytes at the end of the record */\n  int nVarint;           /* Number of bytes in a varint */\n  u32 serial_type;       /* Type field */\n  Mem *pData0;           /* First field to be combined into the record */\n  Mem *pLast;            /* Last field of the record */\n  int nField;            /* Number of fields in the record */\n  char *zAffinity;       /* The affinity string for the record */\n  int file_format;       /* File format to use for encoding */\n  int i;                 /* Space used in zNewRecord[] header */\n  int j;                 /* Space used in zNewRecord[] content */\n  u32 len;               /* Length of a field */\n\n  /* Assuming the record contains N fields, the record format looks\n  ** like this:\n  **\n  ** ------------------------------------------------------------------------\n  ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | \n  ** ------------------------------------------------------------------------\n  **\n  ** Data(0) is taken from register P1.  Data(1) comes from register P1+1\n  ** and so forth.\n  **\n  ** Each type field is a varint representing the serial type of the \n  ** corresponding data element (see sqlite3VdbeSerialType()). The\n  ** hdr-size field is also a varint which is the offset from the beginning\n  ** of the record to data0.\n  */\n  nData = 0;         /* Number of bytes of data space */\n  nHdr = 0;          /* Number of bytes of header space */\n  nZero = 0;         /* Number of zero bytes at the end of the record */\n  nField = pOp->p1;\n  zAffinity = pOp->p4.z;\n  assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1 );\n  pData0 = &aMem[nField];\n  nField = pOp->p2;\n  pLast = &pData0[nField-1];\n  file_format = p->minWriteFileFormat;\n\n  /* Identify the output register */\n  assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 );\n  pOut = &aMem[pOp->p3];\n  memAboutToChange(p, pOut);\n\n  /* Apply the requested affinity to all inputs\n  */\n  assert( pData0<=pLast );\n  if( zAffinity ){\n    pRec = pData0;\n    do{\n      applyAffinity(pRec++, *(zAffinity++), encoding);\n      assert( zAffinity[0]==0 || pRec<=pLast );\n    }while( zAffinity[0] );\n  }\n\n#ifdef SQLITE_ENABLE_NULL_TRIM\n  /* NULLs can be safely trimmed from the end of the record, as long as\n  ** as the schema format is 2 or more and none of the omitted columns\n  ** have a non-NULL default value.  Also, the record must be left with\n  ** at least one field.  If P5>0 then it will be one more than the\n  ** index of the right-most column with a non-NULL default value */\n  if( pOp->p5 ){\n    while( (pLast->flags & MEM_Null)!=0 && nField>pOp->p5 ){\n      pLast--;\n      nField--;\n    }\n  }\n#endif\n\n  /* Loop through the elements that will make up the record to figure\n  ** out how much space is required for the new record.\n  */\n  pRec = pLast;\n  do{\n    assert( memIsValid(pRec) );\n    pRec->uTemp = serial_type = sqlite3VdbeSerialType(pRec, file_format, &len);\n    if( pRec->flags & MEM_Zero ){\n      if( nData ){\n        if( sqlite3VdbeMemExpandBlob(pRec) ) goto no_mem;\n      }else{\n        nZero += pRec->u.nZero;\n        len -= pRec->u.nZero;\n      }\n    }\n    nData += len;\n    testcase( serial_type==127 );\n    testcase( serial_type==128 );\n    nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);\n    if( pRec==pData0 ) break;\n    pRec--;\n  }while(1);\n\n  /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint\n  ** which determines the total number of bytes in the header. The varint\n  ** value is the size of the header in bytes including the size varint\n  ** itself. */\n  testcase( nHdr==126 );\n  testcase( nHdr==127 );\n  if( nHdr<=126 ){\n    /* The common case */\n    nHdr += 1;\n  }else{\n    /* Rare case of a really large header */\n    nVarint = sqlite3VarintLen(nHdr);\n    nHdr += nVarint;\n    if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;\n  }\n  nByte = nHdr+nData;\n  if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n\n  /* Make sure the output register has a buffer large enough to store \n  ** the new record. The output register (pOp->p3) is not allowed to\n  ** be one of the input registers (because the following call to\n  ** sqlite3VdbeMemClearAndResize() could clobber the value before it is used).\n  */\n  if( sqlite3VdbeMemClearAndResize(pOut, (int)nByte) ){\n    goto no_mem;\n  }\n  zNewRecord = (u8 *)pOut->z;\n\n  /* Write the record */\n  i = putVarint32(zNewRecord, nHdr);\n  j = nHdr;\n  assert( pData0<=pLast );\n  pRec = pData0;\n  do{\n    serial_type = pRec->uTemp;\n    /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more\n    ** additional varints, one per column. */\n    i += putVarint32(&zNewRecord[i], serial_type);            /* serial type */\n    /* EVIDENCE-OF: R-64536-51728 The values for each column in the record\n    ** immediately follow the header. */\n    j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, serial_type); /* content */\n  }while( (++pRec)<=pLast );\n  assert( i==nHdr );\n  assert( j==nByte );\n\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pOut->n = (int)nByte;\n  pOut->flags = MEM_Blob;\n  if( nZero ){\n    pOut->u.nZero = nZero;\n    pOut->flags |= MEM_Zero;\n  }\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n/* Opcode: Count P1 P2 * * *\n** Synopsis: r[P2]=count()\n**\n** Store the number of entries (an integer value) in the table or index \n** opened by cursor P1 in register P2\n*/\n#ifndef SQLITE_OMIT_BTREECOUNT\ncase OP_Count: {         /* out2 */\n  i64 nEntry;\n  BtCursor *pCrsr;\n\n  assert( p->apCsr[pOp->p1]->eCurType==CURTYPE_BTREE );\n  pCrsr = p->apCsr[pOp->p1]->uc.pCursor;\n  assert( pCrsr );\n  nEntry = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3BtreeCount(pCrsr, &nEntry);\n  if( rc ) goto abort_due_to_error;\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = nEntry;\n  break;\n}\n#endif\n\n/* Opcode: Savepoint P1 * * P4 *\n**\n** Open, release or rollback the savepoint named by parameter P4, depending\n** on the value of P1. To open a new savepoint, P1==0. To release (commit) an\n** existing savepoint, P1==1, or to rollback an existing savepoint P1==2.\n*/\ncase OP_Savepoint: {\n  int p1;                         /* Value of P1 operand */\n  char *zName;                    /* Name of savepoint */\n  int nName;\n  Savepoint *pNew;\n  Savepoint *pSavepoint;\n  Savepoint *pTmp;\n  int iSavepoint;\n  int ii;\n\n  p1 = pOp->p1;\n  zName = pOp->p4.z;\n\n  /* Assert that the p1 parameter is valid. Also that if there is no open\n  ** transaction, then there cannot be any savepoints. \n  */\n  assert( db->pSavepoint==0 || db->autoCommit==0 );\n  assert( p1==SAVEPOINT_BEGIN||p1==SAVEPOINT_RELEASE||p1==SAVEPOINT_ROLLBACK );\n  assert( db->pSavepoint || db->isTransactionSavepoint==0 );\n  assert( checkSavepointCount(db) );\n  assert( p->bIsReader );\n\n  if( p1==SAVEPOINT_BEGIN ){\n    if( db->nVdbeWrite>0 ){\n      /* A new savepoint cannot be created if there are active write \n      ** statements (i.e. open read/write incremental blob handles).\n      */\n      sqlite3VdbeError(p, \"cannot open savepoint - SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n      nName = sqlite3Strlen30(zName);\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n      /* This call is Ok even if this savepoint is actually a transaction\n      ** savepoint (and therefore should not prompt xSavepoint()) callbacks.\n      ** If this is a transaction savepoint being opened, it is guaranteed\n      ** that the db->aVTrans[] array is empty.  */\n      assert( db->autoCommit==0 || db->nVTrans==0 );\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN,\n                                db->nStatement+db->nSavepoint);\n      if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n      /* Create a new savepoint structure. */\n      pNew = sqlite3DbMallocRawNN(db, sizeof(Savepoint)+nName+1);\n      if( pNew ){\n        pNew->zName = (char *)&pNew[1];\n        memcpy(pNew->zName, zName, nName+1);\n    \n        /* If there is no open transaction, then mark this as a special\n        ** \"transaction savepoint\". */\n        if( db->autoCommit ){\n          db->autoCommit = 0;\n          db->isTransactionSavepoint = 1;\n        }else{\n          db->nSavepoint++;\n        }\n\n        /* Link the new savepoint into the database handle's list. */\n        pNew->pNext = db->pSavepoint;\n        db->pSavepoint = pNew;\n        pNew->nDeferredCons = db->nDeferredCons;\n        pNew->nDeferredImmCons = db->nDeferredImmCons;\n      }\n    }\n  }else{\n    iSavepoint = 0;\n\n    /* Find the named savepoint. If there is no such savepoint, then an\n    ** an error is returned to the user.  */\n    for(\n      pSavepoint = db->pSavepoint; \n      pSavepoint && sqlite3StrICmp(pSavepoint->zName, zName);\n      pSavepoint = pSavepoint->pNext\n    ){\n      iSavepoint++;\n    }\n    if( !pSavepoint ){\n      sqlite3VdbeError(p, \"no such savepoint: %s\", zName);\n      rc = SQLITE_ERROR;\n    }else if( db->nVdbeWrite>0 && p1==SAVEPOINT_RELEASE ){\n      /* It is not possible to release (commit) a savepoint if there are \n      ** active write statements.\n      */\n      sqlite3VdbeError(p, \"cannot release savepoint - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n    }else{\n\n      /* Determine whether or not this is a transaction savepoint. If so,\n      ** and this is a RELEASE command, then the current transaction \n      ** is committed. \n      */\n      int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;\n      if( isTransaction && p1==SAVEPOINT_RELEASE ){\n        if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n          goto vdbe_return;\n        }\n        db->autoCommit = 1;\n        if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n          p->pc = (int)(pOp - aOp);\n          db->autoCommit = 0;\n          p->rc = rc = SQLITE_BUSY;\n          goto vdbe_return;\n        }\n        db->isTransactionSavepoint = 0;\n        rc = p->rc;\n      }else{\n        int isSchemaChange;\n        iSavepoint = db->nSavepoint - iSavepoint - 1;\n        if( p1==SAVEPOINT_ROLLBACK ){\n          isSchemaChange = (db->mDbFlags & DBFLAG_SchemaChange)!=0;\n          for(ii=0; ii<db->nDb; ii++){\n            rc = sqlite3BtreeTripAllCursors(db->aDb[ii].pBt,\n                                       SQLITE_ABORT_ROLLBACK,\n                                       isSchemaChange==0);\n            if( rc!=SQLITE_OK ) goto abort_due_to_error;\n          }\n        }else{\n          isSchemaChange = 0;\n        }\n        for(ii=0; ii<db->nDb; ii++){\n          rc = sqlite3BtreeSavepoint(db->aDb[ii].pBt, p1, iSavepoint);\n          if( rc!=SQLITE_OK ){\n            goto abort_due_to_error;\n          }\n        }\n        if( isSchemaChange ){\n          sqlite3ExpirePreparedStatements(db);\n          sqlite3ResetAllSchemasOfConnection(db);\n          db->mDbFlags |= DBFLAG_SchemaChange;\n        }\n      }\n  \n      /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all \n      ** savepoints nested inside of the savepoint being operated on. */\n      while( db->pSavepoint!=pSavepoint ){\n        pTmp = db->pSavepoint;\n        db->pSavepoint = pTmp->pNext;\n        sqlite3DbFree(db, pTmp);\n        db->nSavepoint--;\n      }\n\n      /* If it is a RELEASE, then destroy the savepoint being operated on \n      ** too. If it is a ROLLBACK TO, then set the number of deferred \n      ** constraint violations present in the database to the value stored\n      ** when the savepoint was created.  */\n      if( p1==SAVEPOINT_RELEASE ){\n        assert( pSavepoint==db->pSavepoint );\n        db->pSavepoint = pSavepoint->pNext;\n        sqlite3DbFree(db, pSavepoint);\n        if( !isTransaction ){\n          db->nSavepoint--;\n        }\n      }else{\n        db->nDeferredCons = pSavepoint->nDeferredCons;\n        db->nDeferredImmCons = pSavepoint->nDeferredImmCons;\n      }\n\n      if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){\n        rc = sqlite3VtabSavepoint(db, p1, iSavepoint);\n        if( rc!=SQLITE_OK ) goto abort_due_to_error;\n      }\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n\n  break;\n}\n\n/* Opcode: AutoCommit P1 P2 * * *\n**\n** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll\n** back any currently active btree transactions. If there are any active\n** VMs (apart from this one), then a ROLLBACK fails.  A COMMIT fails if\n** there are active writing VMs or active VMs that use shared cache.\n**\n** This instruction causes the VM to halt.\n*/\ncase OP_AutoCommit: {\n  int desiredAutoCommit;\n  int iRollback;\n\n  desiredAutoCommit = pOp->p1;\n  iRollback = pOp->p2;\n  assert( desiredAutoCommit==1 || desiredAutoCommit==0 );\n  assert( desiredAutoCommit==1 || iRollback==0 );\n  assert( db->nVdbeActive>0 );  /* At least this one VM is active */\n  assert( p->bIsReader );\n\n  if( desiredAutoCommit!=db->autoCommit ){\n    if( iRollback ){\n      assert( desiredAutoCommit==1 );\n      sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n      db->autoCommit = 1;\n    }else if( desiredAutoCommit && db->nVdbeWrite>0 ){\n      /* If this instruction implements a COMMIT and other VMs are writing\n      ** return an error indicating that the other VMs must complete first. \n      */\n      sqlite3VdbeError(p, \"cannot commit transaction - \"\n                          \"SQL statements in progress\");\n      rc = SQLITE_BUSY;\n      goto abort_due_to_error;\n    }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){\n      goto vdbe_return;\n    }else{\n      db->autoCommit = (u8)desiredAutoCommit;\n    }\n    if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){\n      p->pc = (int)(pOp - aOp);\n      db->autoCommit = (u8)(1-desiredAutoCommit);\n      p->rc = rc = SQLITE_BUSY;\n      goto vdbe_return;\n    }\n    assert( db->nStatement==0 );\n    sqlite3CloseSavepoints(db);\n    if( p->rc==SQLITE_OK ){\n      rc = SQLITE_DONE;\n    }else{\n      rc = SQLITE_ERROR;\n    }\n    goto vdbe_return;\n  }else{\n    sqlite3VdbeError(p,\n        (!desiredAutoCommit)?\"cannot start a transaction within a transaction\":(\n        (iRollback)?\"cannot rollback - no transaction is active\":\n                   \"cannot commit - no transaction is active\"));\n         \n    rc = SQLITE_ERROR;\n    goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: Transaction P1 P2 P3 P4 P5\n**\n** Begin a transaction on database P1 if a transaction is not already\n** active.\n** If P2 is non-zero, then a write-transaction is started, or if a \n** read-transaction is already active, it is upgraded to a write-transaction.\n** If P2 is zero, then a read-transaction is started.\n**\n** P1 is the index of the database file on which the transaction is\n** started.  Index 0 is the main database file and index 1 is the\n** file used for temporary tables.  Indices of 2 or more are used for\n** attached databases.\n**\n** If a write-transaction is started and the Vdbe.usesStmtJournal flag is\n** true (this flag is set if the Vdbe may modify more than one row and may\n** throw an ABORT exception), a statement transaction may also be opened.\n** More specifically, a statement transaction is opened iff the database\n** connection is currently not in autocommit mode, or if there are other\n** active statements. A statement transaction allows the changes made by this\n** VDBE to be rolled back after an error without having to roll back the\n** entire transaction. If no error is encountered, the statement transaction\n** will automatically commit when the VDBE halts.\n**\n** If P5!=0 then this opcode also checks the schema cookie against P3\n** and the schema generation counter against P4.\n** The cookie changes its value whenever the database schema changes.\n** This operation is used to detect when that the cookie has changed\n** and that the current process needs to reread the schema.  If the schema\n** cookie in P3 differs from the schema cookie in the database header or\n** if the schema generation counter in P4 differs from the current\n** generation counter, then an SQLITE_SCHEMA error is raised and execution\n** halts.  The sqlite3_step() wrapper function might then reprepare the\n** statement and rerun it from the beginning.\n*/\ncase OP_Transaction: {\n  Btree *pBt;\n  int iMeta;\n  int iGen;\n\n  assert( p->bIsReader );\n  assert( p->readOnly==0 || pOp->p2==0 );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){\n    rc = SQLITE_READONLY;\n    goto abort_due_to_error;\n  }\n  pBt = db->aDb[pOp->p1].pBt;\n\n  if( pBt ){\n    rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);\n    testcase( rc==SQLITE_BUSY_SNAPSHOT );\n    testcase( rc==SQLITE_BUSY_RECOVERY );\n    if( rc!=SQLITE_OK ){\n      if( (rc&0xff)==SQLITE_BUSY ){\n        p->pc = (int)(pOp - aOp);\n        p->rc = rc;\n        goto vdbe_return;\n      }\n      goto abort_due_to_error;\n    }\n\n    if( pOp->p2 && p->usesStmtJournal \n     && (db->autoCommit==0 || db->nVdbeRead>1) \n    ){\n      assert( sqlite3BtreeIsInTrans(pBt) );\n      if( p->iStatement==0 ){\n        assert( db->nStatement>=0 && db->nSavepoint>=0 );\n        db->nStatement++; \n        p->iStatement = db->nSavepoint + db->nStatement;\n      }\n\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1);\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeBeginStmt(pBt, p->iStatement);\n      }\n\n      /* Store the current value of the database handles deferred constraint\n      ** counter. If the statement transaction needs to be rolled back,\n      ** the value of this counter needs to be restored too.  */\n      p->nStmtDefCons = db->nDeferredCons;\n      p->nStmtDefImmCons = db->nDeferredImmCons;\n    }\n\n    /* Gather the schema version number for checking:\n    ** IMPLEMENTATION-OF: R-03189-51135 As each SQL statement runs, the schema\n    ** version is checked to ensure that the schema has not changed since the\n    ** SQL statement was prepared.\n    */\n    sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);\n    iGen = db->aDb[pOp->p1].pSchema->iGeneration;\n  }else{\n    iGen = iMeta = 0;\n  }\n  assert( pOp->p5==0 || pOp->p4type==P4_INT32 );\n  if( pOp->p5 && (iMeta!=pOp->p3 || iGen!=pOp->p4.i) ){\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, \"database schema has changed\");\n    /* If the schema-cookie from the database file matches the cookie \n    ** stored with the in-memory representation of the schema, do\n    ** not reload the schema from the database file.\n    **\n    ** If virtual-tables are in use, this is not just an optimization.\n    ** Often, v-tables store their data in other SQLite tables, which\n    ** are queried from within xNext() and other v-table methods using\n    ** prepared queries. If such a query is out-of-date, we do not want to\n    ** discard the database schema, as the user code implementing the\n    ** v-table would have to be ready for the sqlite3_vtab structure itself\n    ** to be invalidated whenever sqlite3_step() is called from within \n    ** a v-table method.\n    */\n    if( db->aDb[pOp->p1].pSchema->schema_cookie!=iMeta ){\n      sqlite3ResetOneSchema(db, pOp->p1);\n    }\n    p->expired = 1;\n    rc = SQLITE_SCHEMA;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ReadCookie P1 P2 P3 * *\n**\n** Read cookie number P3 from database P1 and write it into register P2.\n** P3==1 is the schema version.  P3==2 is the database format.\n** P3==3 is the recommended pager cache size, and so forth.  P1==0 is\n** the main database file and P1==1 is the database file used to store\n** temporary tables.\n**\n** There must be a read-lock on the database (either a transaction\n** must be started or there must be an open cursor) before\n** executing this instruction.\n*/\ncase OP_ReadCookie: {               /* out2 */\n  int iMeta;\n  int iDb;\n  int iCookie;\n\n  assert( p->bIsReader );\n  iDb = pOp->p1;\n  iCookie = pOp->p3;\n  assert( pOp->p3<SQLITE_N_BTREE_META );\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( db->aDb[iDb].pBt!=0 );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n\n  sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = iMeta;\n  break;\n}\n\n/* Opcode: SetCookie P1 P2 P3 * *\n**\n** Write the integer value P3 into cookie number P2 of database P1.\n** P2==1 is the schema version.  P2==2 is the database format.\n** P2==3 is the recommended pager cache \n** size, and so forth.  P1==0 is the main database file and P1==1 is the \n** database file used to store temporary tables.\n**\n** A transaction must be started before executing this opcode.\n*/\ncase OP_SetCookie: {\n  Db *pDb;\n  assert( pOp->p2<SQLITE_N_BTREE_META );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );\n  /* See note about index shifting on OP_ReadCookie */\n  rc = sqlite3BtreeUpdateMeta(pDb->pBt, pOp->p2, pOp->p3);\n  if( pOp->p2==BTREE_SCHEMA_VERSION ){\n    /* When the schema cookie changes, record the new cookie internally */\n    pDb->pSchema->schema_cookie = pOp->p3;\n    db->mDbFlags |= DBFLAG_SchemaChange;\n  }else if( pOp->p2==BTREE_FILE_FORMAT ){\n    /* Record changes in the file format */\n    pDb->pSchema->file_format = pOp->p3;\n  }\n  if( pOp->p1==1 ){\n    /* Invalidate all prepared statements whenever the TEMP database\n    ** schema is changed.  Ticket #1644 */\n    sqlite3ExpirePreparedStatements(db);\n    p->expired = 0;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenRead P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read-only cursor for the database table whose root page is\n** P2 in a database file.  The database file is determined by P3. \n** P3==0 means the main database, P3==1 means the database used for \n** temporary tables, and P3>1 means used the corresponding attached\n** database.  Give the new cursor an identifier of P1.  The P1\n** values need not be contiguous but all P1 values should be small integers.\n** It is an error for P1 to be negative.\n**\n** If P5!=0 then use the content of register P2 as the root page, not\n** the value of P2 itself.\n**\n** There will be a read lock on the database whenever there is an\n** open cursor.  If the database was unlocked prior to this instruction\n** then a read lock is acquired as part of this instruction.  A read\n** lock allows other processes to read the database but prohibits\n** any other process from modifying the database.  The read lock is\n** released when all cursors are closed.  If this instruction attempts\n** to get a read lock but fails, the script terminates with an\n** SQLITE_BUSY error code.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table.\n**\n** See also: OpenWrite, ReopenIdx\n*/\n/* Opcode: ReopenIdx P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** The ReopenIdx opcode works exactly like ReadOpen except that it first\n** checks to see if the cursor on P1 is already open with a root page\n** number of P2 and if it is this opcode becomes a no-op.  In other words,\n** if the cursor is already open, do not reopen it.\n**\n** The ReopenIdx opcode may only be used with P5==0 and with P4 being\n** a P4_KEYINFO object.  Furthermore, the P3 value must be the same as\n** every other ReopenIdx or OpenRead for the same cursor number.\n**\n** See the OpenRead opcode documentation for additional information.\n*/\n/* Opcode: OpenWrite P1 P2 P3 P4 P5\n** Synopsis: root=P2 iDb=P3\n**\n** Open a read/write cursor named P1 on the table or index whose root\n** page is P2.  Or if P5!=0 use the content of register P2 to find the\n** root page.\n**\n** The P4 value may be either an integer (P4_INT32) or a pointer to\n** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo \n** structure, then said structure defines the content and collating \n** sequence of the index being opened. Otherwise, if P4 is an integer \n** value, it is set to the number of columns in the table, or to the\n** largest index of any column of the table that is actually used.\n**\n** This instruction works just like OpenRead except that it opens the cursor\n** in read/write mode.  For a given table, there can be one or more read-only\n** cursors or a single read/write cursor but not both.\n**\n** See also OpenRead.\n*/\ncase OP_ReopenIdx: {\n  int nField;\n  KeyInfo *pKeyInfo;\n  int p2;\n  int iDb;\n  int wrFlag;\n  Btree *pX;\n  VdbeCursor *pCur;\n  Db *pDb;\n\n  assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( pOp->p4type==P4_KEYINFO );\n  pCur = p->apCsr[pOp->p1];\n  if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){\n    assert( pCur->iDb==pOp->p3 );      /* Guaranteed by the code generator */\n    goto open_cursor_set_hints;\n  }\n  /* If the cursor is not currently open or is open on a different\n  ** index, then fall through into OP_OpenRead to force a reopen */\ncase OP_OpenRead:\ncase OP_OpenWrite:\n\n  assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );\n  assert( p->bIsReader );\n  assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx\n          || p->readOnly==0 );\n\n  if( p->expired ){\n    rc = SQLITE_ABORT_ROLLBACK;\n    goto abort_due_to_error;\n  }\n\n  nField = 0;\n  pKeyInfo = 0;\n  p2 = pOp->p2;\n  iDb = pOp->p3;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbMaskTest(p->btreeMask, iDb) );\n  pDb = &db->aDb[iDb];\n  pX = pDb->pBt;\n  assert( pX!=0 );\n  if( pOp->opcode==OP_OpenWrite ){\n    assert( OPFLAG_FORDELETE==BTREE_FORDELETE );\n    wrFlag = BTREE_WRCSR | (pOp->p5 & OPFLAG_FORDELETE);\n    assert( sqlite3SchemaMutexHeld(db, iDb, 0) );\n    if( pDb->pSchema->file_format < p->minWriteFileFormat ){\n      p->minWriteFileFormat = pDb->pSchema->file_format;\n    }\n  }else{\n    wrFlag = 0;\n  }\n  if( pOp->p5 & OPFLAG_P2ISREG ){\n    assert( p2>0 );\n    assert( p2<=(p->nMem+1 - p->nCursor) );\n    pIn2 = &aMem[p2];\n    assert( memIsValid(pIn2) );\n    assert( (pIn2->flags & MEM_Int)!=0 );\n    sqlite3VdbeMemIntegerify(pIn2);\n    p2 = (int)pIn2->u.i;\n    /* The p2 value always comes from a prior OP_CreateBtree opcode and\n    ** that opcode will always set the p2 value to 2 or more or else fail.\n    ** If there were a failure, the prepared statement would have halted\n    ** before reaching this instruction. */\n    assert( p2>=2 );\n  }\n  if( pOp->p4type==P4_KEYINFO ){\n    pKeyInfo = pOp->p4.pKeyInfo;\n    assert( pKeyInfo->enc==ENC(db) );\n    assert( pKeyInfo->db==db );\n    nField = pKeyInfo->nAllField;\n  }else if( pOp->p4type==P4_INT32 ){\n    nField = pOp->p4.i;\n  }\n  assert( pOp->p1>=0 );\n  assert( nField>=0 );\n  testcase( nField==0 );  /* Table with INTEGER PRIMARY KEY and nothing else */\n  pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);\n  if( pCur==0 ) goto no_mem;\n  pCur->nullRow = 1;\n  pCur->isOrdered = 1;\n  pCur->pgnoRoot = p2;\n#ifdef SQLITE_DEBUG\n  pCur->wrFlag = wrFlag;\n#endif\n  rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->uc.pCursor);\n  pCur->pKeyInfo = pKeyInfo;\n  /* Set the VdbeCursor.isTable variable. Previous versions of\n  ** SQLite used to check if the root-page flags were sane at this point\n  ** and report database corruption if they were not, but this check has\n  ** since moved into the btree layer.  */  \n  pCur->isTable = pOp->p4type!=P4_KEYINFO;\n\nopen_cursor_set_hints:\n  assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );\n  assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );\n  testcase( pOp->p5 & OPFLAG_BULKCSR );\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n  testcase( pOp->p2 & OPFLAG_SEEKEQ );\n#endif\n  sqlite3BtreeCursorHintFlags(pCur->uc.pCursor,\n                               (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: OpenDup P1 P2 * * *\n**\n** Open a new cursor P1 that points to the same ephemeral table as\n** cursor P2.  The P2 cursor must have been opened by a prior OP_OpenEphemeral\n** opcode.  Only ephemeral cursors may be duplicated.\n**\n** Duplicate ephemeral cursors are used for self-joins of materialized views.\n*/\ncase OP_OpenDup: {\n  VdbeCursor *pOrig;    /* The original cursor to be duplicated */\n  VdbeCursor *pCx;      /* The new cursor */\n\n  pOrig = p->apCsr[pOp->p2];\n  assert( pOrig->pBtx!=0 );  /* Only ephemeral cursors can be duplicated */\n\n  pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->isEphemeral = 1;\n  pCx->pKeyInfo = pOrig->pKeyInfo;\n  pCx->isTable = pOrig->isTable;\n  rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR,\n                          pCx->pKeyInfo, pCx->uc.pCursor);\n  /* The sqlite3BtreeCursor() routine can only fail for the first cursor\n  ** opened for a database.  Since there is already an open cursor when this\n  ** opcode is run, the sqlite3BtreeCursor() cannot fail */\n  assert( rc==SQLITE_OK );\n  break;\n}\n\n\n/* Opcode: OpenEphemeral P1 P2 * P4 P5\n** Synopsis: nColumn=P2\n**\n** Open a new cursor P1 to a transient table.\n** The cursor is always opened read/write even if \n** the main database is read-only.  The ephemeral\n** table is deleted automatically when the cursor is closed.\n**\n** P2 is the number of columns in the ephemeral table.\n** The cursor points to a BTree table if P4==0 and to a BTree index\n** if P4 is not 0.  If P4 is not NULL, it points to a KeyInfo structure\n** that defines the format of keys in the index.\n**\n** The P5 parameter can be a mask of the BTREE_* flags defined\n** in btree.h.  These flags control aspects of the operation of\n** the btree.  The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are\n** added automatically.\n*/\n/* Opcode: OpenAutoindex P1 P2 * P4 *\n** Synopsis: nColumn=P2\n**\n** This opcode works the same as OP_OpenEphemeral.  It has a\n** different name to distinguish its use.  Tables created using\n** by this opcode will be used for automatically created transient\n** indices in joins.\n*/\ncase OP_OpenAutoindex: \ncase OP_OpenEphemeral: {\n  VdbeCursor *pCx;\n  KeyInfo *pKeyInfo;\n\n  static const int vfsFlags = \n      SQLITE_OPEN_READWRITE |\n      SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE |\n      SQLITE_OPEN_DELETEONCLOSE |\n      SQLITE_OPEN_TRANSIENT_DB;\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->isEphemeral = 1;\n  rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx, \n                        BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);\n  if( rc==SQLITE_OK ){\n    rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1);\n  }\n  if( rc==SQLITE_OK ){\n    /* If a transient index is required, create it by calling\n    ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before\n    ** opening it. If a transient table is required, just use the\n    ** automatically created table with root-page 1 (an BLOB_INTKEY table).\n    */\n    if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){\n      int pgno;\n      assert( pOp->p4type==P4_KEYINFO );\n      rc = sqlite3BtreeCreateTable(pCx->pBtx, &pgno, BTREE_BLOBKEY | pOp->p5); \n      if( rc==SQLITE_OK ){\n        assert( pgno==MASTER_ROOT+1 );\n        assert( pKeyInfo->db==db );\n        assert( pKeyInfo->enc==ENC(db) );\n        rc = sqlite3BtreeCursor(pCx->pBtx, pgno, BTREE_WRCSR,\n                                pKeyInfo, pCx->uc.pCursor);\n      }\n      pCx->isTable = 0;\n    }else{\n      rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,\n                              0, pCx->uc.pCursor);\n      pCx->isTable = 1;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);\n  break;\n}\n\n/* Opcode: SorterOpen P1 P2 P3 P4 *\n**\n** This opcode works like OP_OpenEphemeral except that it opens\n** a transient index that is specifically designed to sort large\n** tables using an external merge-sort algorithm.\n**\n** If argument P3 is non-zero, then it indicates that the sorter may\n** assume that a stable sort considering the first P3 fields of each\n** key is sufficient to produce the required results.\n*/\ncase OP_SorterOpen: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p2>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);\n  if( pCx==0 ) goto no_mem;\n  pCx->pKeyInfo = pOp->p4.pKeyInfo;\n  assert( pCx->pKeyInfo->db==db );\n  assert( pCx->pKeyInfo->enc==ENC(db) );\n  rc = sqlite3VdbeSorterInit(db, pOp->p3, pCx);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: SequenceTest P1 P2 * * *\n** Synopsis: if( cursor[P1].ctr++ ) pc = P2\n**\n** P1 is a sorter cursor. If the sequence counter is currently zero, jump\n** to P2. Regardless of whether or not the jump is taken, increment the\n** the sequence value.\n*/\ncase OP_SequenceTest: {\n  VdbeCursor *pC;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  if( (pC->seqCount++)==0 ){\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OpenPseudo P1 P2 P3 * *\n** Synopsis: P3 columns in r[P2]\n**\n** Open a new cursor that points to a fake table that contains a single\n** row of data.  The content of that one row is the content of memory\n** register P2.  In other words, cursor P1 becomes an alias for the \n** MEM_Blob content contained in register P2.\n**\n** A pseudo-table created by this opcode is used to hold a single\n** row output from the sorter so that the row can be decomposed into\n** individual columns using the OP_Column opcode.  The OP_Column opcode\n** is the only cursor opcode that works with a pseudo-table.\n**\n** P3 is the number of fields in the records that will be stored by\n** the pseudo-table.\n*/\ncase OP_OpenPseudo: {\n  VdbeCursor *pCx;\n\n  assert( pOp->p1>=0 );\n  assert( pOp->p3>=0 );\n  pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);\n  if( pCx==0 ) goto no_mem;\n  pCx->nullRow = 1;\n  pCx->seekResult = pOp->p2;\n  pCx->isTable = 1;\n  /* Give this pseudo-cursor a fake BtCursor pointer so that pCx\n  ** can be safely passed to sqlite3VdbeCursorMoveto().  This avoids a test\n  ** for pCx->eCurType==CURTYPE_BTREE inside of sqlite3VdbeCursorMoveto()\n  ** which is a performance optimization */\n  pCx->uc.pCursor = sqlite3BtreeFakeValidCursor();\n  assert( pOp->p5==0 );\n  break;\n}\n\n/* Opcode: Close P1 * * * *\n**\n** Close a cursor previously opened as P1.  If P1 is not\n** currently open, this instruction is a no-op.\n*/\ncase OP_Close: {\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  sqlite3VdbeFreeCursor(p, p->apCsr[pOp->p1]);\n  p->apCsr[pOp->p1] = 0;\n  break;\n}\n\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n/* Opcode: ColumnsUsed P1 * * P4 *\n**\n** This opcode (which only exists if SQLite was compiled with\n** SQLITE_ENABLE_COLUMN_USED_MASK) identifies which columns of the\n** table or index for cursor P1 are used.  P4 is a 64-bit integer\n** (P4_INT64) in which the first 63 bits are one for each of the\n** first 63 columns of the table or index that are actually used\n** by the cursor.  The high-order bit is set if any column after\n** the 64th is used.\n*/\ncase OP_ColumnsUsed: {\n  VdbeCursor *pC;\n  pC = p->apCsr[pOp->p1];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pC->maskUsed = *(u64*)pOp->p4.pI64;\n  break;\n}\n#endif\n\n/* Opcode: SeekGE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as the key.  If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than or equal to the key value. If there are no records \n** greater than or equal to the key and P2 is not zero, then jump to P2.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxLE opcode with the same arguments.\n** The IdxLE opcode will be skipped if this opcode succeeds, but the\n** IdxLE opcode will be used on subsequent loop iterations.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGt, SeekLe\n*/\n/* Opcode: SeekGT P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the smallest entry that \n** is greater than the key value. If there are no records greater than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n**\n** See also: Found, NotFound, SeekLt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLT P1 P2 P3 P4 * \n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that  it points to the largest entry that \n** is less than the key value. If there are no records less than \n** the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLe\n*/\n/* Opcode: SeekLE P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), \n** use the value in register P3 as a key. If cursor P1 refers \n** to an SQL index, then P3 is the first in an array of P4 registers \n** that are used as an unpacked index key. \n**\n** Reposition cursor P1 so that it points to the largest entry that \n** is less than or equal to the key value. If there are no records \n** less than or equal to the key and P2 is not zero, then jump to P2.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n**\n** If the cursor P1 was opened using the OPFLAG_SEEKEQ flag, then this\n** opcode will always land on a record that equally equals the key, or\n** else jump immediately to P2.  When the cursor is OPFLAG_SEEKEQ, this\n** opcode must be followed by an IdxGE opcode with the same arguments.\n** The IdxGE opcode will be skipped if this opcode succeeds, but the\n** IdxGE opcode will be used on subsequent loop iterations.\n**\n** See also: Found, NotFound, SeekGt, SeekGe, SeekLt\n*/\ncase OP_SeekLT:         /* jump, in3 */\ncase OP_SeekLE:         /* jump, in3 */\ncase OP_SeekGE:         /* jump, in3 */\ncase OP_SeekGT: {       /* jump, in3 */\n  int res;           /* Comparison result */\n  int oc;            /* Opcode */\n  VdbeCursor *pC;    /* The cursor to seek */\n  UnpackedRecord r;  /* The key to seek for */\n  int nField;        /* Number of columns or fields in the key */\n  i64 iKey;          /* The rowid we are to seek to */\n  int eqOnly;        /* Only interested in == results */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p2!=0 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( OP_SeekLE == OP_SeekLT+1 );\n  assert( OP_SeekGE == OP_SeekLT+2 );\n  assert( OP_SeekGT == OP_SeekLT+3 );\n  assert( pC->isOrdered );\n  assert( pC->uc.pCursor!=0 );\n  oc = pOp->opcode;\n  eqOnly = 0;\n  pC->nullRow = 0;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n\n  if( pC->isTable ){\n    /* The BTREE_SEEK_EQ flag is only set on index cursors */\n    assert( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ)==0\n              || CORRUPT_DB );\n\n    /* The input value in P3 might be of any type: integer, real, string,\n    ** blob, or NULL.  But it needs to be an integer before we can do\n    ** the seek, so convert it. */\n    pIn3 = &aMem[pOp->p3];\n    if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){\n      applyNumericAffinity(pIn3, 0);\n    }\n    iKey = sqlite3VdbeIntValue(pIn3);\n\n    /* If the P3 value could not be converted into an integer without\n    ** loss of information, then special processing is required... */\n    if( (pIn3->flags & MEM_Int)==0 ){\n      if( (pIn3->flags & MEM_Real)==0 ){\n        /* If the P3 value cannot be converted into any kind of a number,\n        ** then the seek is not possible, so jump to P2 */\n        VdbeBranchTaken(1,2); goto jump_to_p2;\n        break;\n      }\n\n      /* If the approximation iKey is larger than the actual real search\n      ** term, substitute >= for > and < for <=. e.g. if the search term\n      ** is 4.9 and the integer approximation 5:\n      **\n      **        (x >  4.9)    ->     (x >= 5)\n      **        (x <= 4.9)    ->     (x <  5)\n      */\n      if( pIn3->u.r<(double)iKey ){\n        assert( OP_SeekGE==(OP_SeekGT-1) );\n        assert( OP_SeekLT==(OP_SeekLE-1) );\n        assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;\n      }\n\n      /* If the approximation iKey is smaller than the actual real search\n      ** term, substitute <= for < and > for >=.  */\n      else if( pIn3->u.r>(double)iKey ){\n        assert( OP_SeekLE==(OP_SeekLT+1) );\n        assert( OP_SeekGT==(OP_SeekGE+1) );\n        assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );\n        if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;\n      }\n    } \n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);\n    pC->movetoTarget = iKey;  /* Used by OP_Delete */\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n  }else{\n    /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and\n    ** OP_SeekLE opcodes are allowed, and these must be immediately followed\n    ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.\n    */\n    if( sqlite3BtreeCursorHasHint(pC->uc.pCursor, BTREE_SEEK_EQ) ){\n      eqOnly = 1;\n      assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );\n      assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n      assert( pOp[1].p1==pOp[0].p1 );\n      assert( pOp[1].p2==pOp[0].p2 );\n      assert( pOp[1].p3==pOp[0].p3 );\n      assert( pOp[1].p4.i==pOp[0].p4.i );\n    }\n\n    nField = pOp->p4.i;\n    assert( pOp->p4type==P4_INT32 );\n    assert( nField>0 );\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)nField;\n\n    /* The next line of code computes as follows, only faster:\n    **   if( oc==OP_SeekGT || oc==OP_SeekLE ){\n    **     r.default_rc = -1;\n    **   }else{\n    **     r.default_rc = +1;\n    **   }\n    */\n    r.default_rc = ((1 & (oc - OP_SeekLT)) ? -1 : +1);\n    assert( oc!=OP_SeekGT || r.default_rc==-1 );\n    assert( oc!=OP_SeekLE || r.default_rc==-1 );\n    assert( oc!=OP_SeekGE || r.default_rc==+1 );\n    assert( oc!=OP_SeekLT || r.default_rc==+1 );\n\n    r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n    { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }\n#endif\n    r.eqSeen = 0;\n    rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( eqOnly && r.eqSeen==0 ){\n      assert( res!=0 );\n      goto seek_not_found;\n    }\n  }\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  if( oc>=OP_SeekGE ){  assert( oc==OP_SeekGE || oc==OP_SeekGT );\n    if( res<0 || (res==0 && oc==OP_SeekGT) ){\n      res = 0;\n      rc = sqlite3BtreeNext(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      res = 0;\n    }\n  }else{\n    assert( oc==OP_SeekLT || oc==OP_SeekLE );\n    if( res>0 || (res==0 && oc==OP_SeekLT) ){\n      res = 0;\n      rc = sqlite3BtreePrevious(pC->uc.pCursor, 0);\n      if( rc!=SQLITE_OK ){\n        if( rc==SQLITE_DONE ){\n          rc = SQLITE_OK;\n          res = 1;\n        }else{\n          goto abort_due_to_error;\n        }\n      }\n    }else{\n      /* res might be negative because the table is empty.  Check to\n      ** see if this is the case.\n      */\n      res = sqlite3BtreeEof(pC->uc.pCursor);\n    }\n  }\nseek_not_found:\n  assert( pOp->p2>0 );\n  VdbeBranchTaken(res!=0,2);\n  if( res ){\n    goto jump_to_p2;\n  }else if( eqOnly ){\n    assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );\n    pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */\n  }\n  break;\n}\n\n/* Opcode: Found P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n**\n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is a prefix of any entry in P1 then a jump is made to P2 and\n** P1 is left pointing at the matching entry.\n**\n** This operation leaves the cursor in a state where it can be\n** advanced in the forward direction.  The Next instruction will work,\n** but not the Prev instruction.\n**\n** See also: NotFound, NoConflict, NotExists. SeekGe\n*/\n/* Opcode: NotFound P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** is not the prefix of any entry in P1 then a jump is made to P2.  If P1 \n** does contain an entry whose prefix matches the P3/P4 record then control\n** falls through to the next instruction and P1 is left pointing at the\n** matching entry.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: Found, NotExists, NoConflict\n*/\n/* Opcode: NoConflict P1 P2 P3 P4 *\n** Synopsis: key=r[P3@P4]\n**\n** If P4==0 then register P3 holds a blob constructed by MakeRecord.  If\n** P4>0 then register P3 is the first of P4 registers that form an unpacked\n** record.\n** \n** Cursor P1 is on an index btree.  If the record identified by P3 and P4\n** contains any NULL value, jump immediately to P2.  If all terms of the\n** record are not-NULL then a check is done to determine if any row in the\n** P1 index btree has a matching key prefix.  If there are no matches, jump\n** immediately to P2.  If there is a match, fall through and leave the P1\n** cursor pointing to the matching row.\n**\n** This opcode is similar to OP_NotFound with the exceptions that the\n** branch is always taken if any part of the search key input is NULL.\n**\n** This operation leaves the cursor in a state where it cannot be\n** advanced in either direction.  In other words, the Next and Prev\n** opcodes do not work after this operation.\n**\n** See also: NotFound, Found, NotExists\n*/\ncase OP_NoConflict:     /* jump, in3 */\ncase OP_NotFound:       /* jump, in3 */\ncase OP_Found: {        /* jump, in3 */\n  int alreadyExists;\n  int takeJump;\n  int ii;\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord *pFree;\n  UnpackedRecord *pIdxKey;\n  UnpackedRecord r;\n\n#ifdef SQLITE_TEST\n  if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++;\n#endif\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_INT32 );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  pIn3 = &aMem[pOp->p3];\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  if( pOp->p4.i>0 ){\n    r.pKeyInfo = pC->pKeyInfo;\n    r.nField = (u16)pOp->p4.i;\n    r.aMem = pIn3;\n#ifdef SQLITE_DEBUG\n    for(ii=0; ii<r.nField; ii++){\n      assert( memIsValid(&r.aMem[ii]) );\n      assert( (r.aMem[ii].flags & MEM_Zero)==0 || r.aMem[ii].n==0 );\n      if( ii ) REGISTER_TRACE(pOp->p3+ii, &r.aMem[ii]);\n    }\n#endif\n    pIdxKey = &r;\n    pFree = 0;\n  }else{\n    assert( pIn3->flags & MEM_Blob );\n    rc = ExpandBlob(pIn3);\n    assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );\n    if( rc ) goto no_mem;\n    pFree = pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo);\n    if( pIdxKey==0 ) goto no_mem;\n    sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);\n  }\n  pIdxKey->default_rc = 0;\n  takeJump = 0;\n  if( pOp->opcode==OP_NoConflict ){\n    /* For the OP_NoConflict opcode, take the jump if any of the\n    ** input fields are NULL, since any key with a NULL will not\n    ** conflict */\n    for(ii=0; ii<pIdxKey->nField; ii++){\n      if( pIdxKey->aMem[ii].flags & MEM_Null ){\n        takeJump = 1;\n        break;\n      }\n    }\n  }\n  rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);\n  if( pFree ) sqlite3DbFreeNN(db, pFree);\n  if( rc!=SQLITE_OK ){\n    goto abort_due_to_error;\n  }\n  pC->seekResult = res;\n  alreadyExists = (res==0);\n  pC->nullRow = 1-alreadyExists;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( pOp->opcode==OP_Found ){\n    VdbeBranchTaken(alreadyExists!=0,2);\n    if( alreadyExists ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(takeJump||alreadyExists==0,2);\n    if( takeJump || !alreadyExists ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: SeekRowid P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  If register P3 does not contain an integer or if P1 does not\n** contain a record with rowid P3 then jump immediately to P2.  \n** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain\n** a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_NotExists opcode performs the same operation, but with OP_NotExists\n** the P3 register must be guaranteed to contain an integer value.  With this\n** opcode, register P3 might not contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\n/* Opcode: NotExists P1 P2 P3 * *\n** Synopsis: intkey=r[P3]\n**\n** P1 is the index of a cursor open on an SQL table btree (with integer\n** keys).  P3 is an integer rowid.  If P1 does not contain a record with\n** rowid P3 then jump immediately to P2.  Or, if P2 is 0, raise an\n** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then \n** leave the cursor pointing at that record and fall through to the next\n** instruction.\n**\n** The OP_SeekRowid opcode performs the same operation but also allows the\n** P3 register to contain a non-integer value, in which case the jump is\n** always taken.  This opcode requires that P3 always contain an integer.\n**\n** The OP_NotFound opcode performs the same operation on index btrees\n** (with arbitrary multi-value keys).\n**\n** This opcode leaves the cursor in a state where it cannot be advanced\n** in either direction.  In other words, the Next and Prev opcodes will\n** not work following this opcode.\n**\n** See also: Found, NotFound, NoConflict, SeekRowid\n*/\ncase OP_SeekRowid: {        /* jump, in3 */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  u64 iKey;\n\n  pIn3 = &aMem[pOp->p3];\n  if( (pIn3->flags & MEM_Int)==0 ){\n    applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding);\n    if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2;\n  }\n  /* Fall through into OP_NotExists */\ncase OP_NotExists:          /* jump, in3 */\n  pIn3 = &aMem[pOp->p3];\n  assert( pIn3->flags & MEM_Int );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = 0;\n#endif\n  assert( pC->isTable );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  res = 0;\n  iKey = pIn3->u.i;\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);\n  assert( rc==SQLITE_OK || res==0 );\n  pC->movetoTarget = iKey;  /* Used by OP_Delete */\n  pC->nullRow = 0;\n  pC->cacheStatus = CACHE_STALE;\n  pC->deferredMoveto = 0;\n  VdbeBranchTaken(res!=0,2);\n  pC->seekResult = res;\n  if( res!=0 ){\n    assert( rc==SQLITE_OK );\n    if( pOp->p2==0 ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      goto jump_to_p2;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: Sequence P1 P2 * * *\n** Synopsis: r[P2]=cursor[P1].ctr++\n**\n** Find the next available sequence number for cursor P1.\n** Write the sequence number into register P2.\n** The sequence number on the cursor is incremented after this\n** instruction.  \n*/\ncase OP_Sequence: {           /* out2 */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( p->apCsr[pOp->p1]!=0 );\n  assert( p->apCsr[pOp->p1]->eCurType!=CURTYPE_VTAB );\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = p->apCsr[pOp->p1]->seqCount++;\n  break;\n}\n\n\n/* Opcode: NewRowid P1 P2 P3 * *\n** Synopsis: r[P2]=rowid\n**\n** Get a new integer record number (a.k.a \"rowid\") used as the key to a table.\n** The record number is not previously used as a key in the database\n** table that cursor P1 points to.  The new record number is written\n** written to register P2.\n**\n** If P3>0 then P3 is a register in the root frame of this VDBE that holds \n** the largest previously generated record number. No new record numbers are\n** allowed to be less than this value. When this value reaches its maximum, \n** an SQLITE_FULL error is generated. The P3 register is updated with the '\n** generated record number. This P3 mechanism is used to help implement the\n** AUTOINCREMENT feature.\n*/\ncase OP_NewRowid: {           /* out2 */\n  i64 v;                 /* The new rowid */\n  VdbeCursor *pC;        /* Cursor of table to get the new rowid */\n  int res;               /* Result of an sqlite3BtreeLast() */\n  int cnt;               /* Counter to limit the number of searches */\n  Mem *pMem;             /* Register holding largest rowid for AUTOINCREMENT */\n  VdbeFrame *pFrame;     /* Root frame of VDBE */\n\n  v = 0;\n  res = 0;\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  {\n    /* The next rowid or record number (different terms for the same\n    ** thing) is obtained in a two-step algorithm.\n    **\n    ** First we attempt to find the largest existing rowid and add one\n    ** to that.  But if the largest existing rowid is already the maximum\n    ** positive integer, we have to fall through to the second\n    ** probabilistic algorithm\n    **\n    ** The second algorithm is to select a rowid at random and see if\n    ** it already exists in the table.  If it does not exist, we have\n    ** succeeded.  If the random rowid does exist, we select a new one\n    ** and try again, up to 100 times.\n    */\n    assert( pC->isTable );\n\n#ifdef SQLITE_32BIT_ROWID\n#   define MAX_ROWID 0x7fffffff\n#else\n    /* Some compilers complain about constants of the form 0x7fffffffffffffff.\n    ** Others complain about 0x7ffffffffffffffffLL.  The following macro seems\n    ** to provide the constant while making all compilers happy.\n    */\n#   define MAX_ROWID  (i64)( (((u64)0x7fffffff)<<32) | (u64)0xffffffff )\n#endif\n\n    if( !pC->useRandomRowid ){\n      rc = sqlite3BtreeLast(pC->uc.pCursor, &res);\n      if( rc!=SQLITE_OK ){\n        goto abort_due_to_error;\n      }\n      if( res ){\n        v = 1;   /* IMP: R-61914-48074 */\n      }else{\n        assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) );\n        v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n        if( v>=MAX_ROWID ){\n          pC->useRandomRowid = 1;\n        }else{\n          v++;   /* IMP: R-29538-34987 */\n        }\n      }\n    }\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n    if( pOp->p3 ){\n      /* Assert that P3 is a valid memory cell. */\n      assert( pOp->p3>0 );\n      if( p->pFrame ){\n        for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=pFrame->nMem );\n        pMem = &pFrame->aMem[pOp->p3];\n      }else{\n        /* Assert that P3 is a valid memory cell. */\n        assert( pOp->p3<=(p->nMem+1 - p->nCursor) );\n        pMem = &aMem[pOp->p3];\n        memAboutToChange(p, pMem);\n      }\n      assert( memIsValid(pMem) );\n\n      REGISTER_TRACE(pOp->p3, pMem);\n      sqlite3VdbeMemIntegerify(pMem);\n      assert( (pMem->flags & MEM_Int)!=0 );  /* mem(P3) holds an integer */\n      if( pMem->u.i==MAX_ROWID || pC->useRandomRowid ){\n        rc = SQLITE_FULL;   /* IMP: R-17817-00630 */\n        goto abort_due_to_error;\n      }\n      if( v<pMem->u.i+1 ){\n        v = pMem->u.i + 1;\n      }\n      pMem->u.i = v;\n    }\n#endif\n    if( pC->useRandomRowid ){\n      /* IMPLEMENTATION-OF: R-07677-41881 If the largest ROWID is equal to the\n      ** largest possible integer (9223372036854775807) then the database\n      ** engine starts picking positive candidate ROWIDs at random until\n      ** it finds one that is not previously used. */\n      assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is\n                             ** an AUTOINCREMENT table. */\n      cnt = 0;\n      do{\n        sqlite3_randomness(sizeof(v), &v);\n        v &= (MAX_ROWID>>1); v++;  /* Ensure that v is greater than zero */\n      }while(  ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,\n                                                 0, &res))==SQLITE_OK)\n            && (res==0)\n            && (++cnt<100));\n      if( rc ) goto abort_due_to_error;\n      if( res==0 ){\n        rc = SQLITE_FULL;   /* IMP: R-38219-53002 */\n        goto abort_due_to_error;\n      }\n      assert( v>0 );  /* EV: R-40812-03570 */\n    }\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: Insert P1 P2 P3 P4 P5\n** Synopsis: intkey=r[P3] data=r[P2]\n**\n** Write an entry into the table of cursor P1.  A new entry is\n** created if it doesn't already exist or the data for an existing\n** entry is overwritten.  The data is the value MEM_Blob stored in register\n** number P2. The key is stored in register P3. The key must\n** be a MEM_Int.\n**\n** If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is\n** incremented (otherwise not).  If the OPFLAG_LASTROWID flag of P5 is set,\n** then rowid is stored for subsequent return by the\n** sqlite3_last_insert_rowid() function (otherwise it is unmodified).\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equal to P3.\n**\n** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an\n** UPDATE operation.  Otherwise (if the flag is clear) then this opcode\n** is part of an INSERT operation.  The difference is only important to\n** the update hook.\n**\n** Parameter P4 may point to a Table structure, or may be NULL. If it is \n** not NULL, then the update-hook (sqlite3.xUpdateCallback) is invoked \n** following a successful insert.\n**\n** (WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically\n** allocated, then ownership of P2 is transferred to the pseudo-cursor\n** and register P2 becomes ephemeral.  If the cursor is changed, the\n** value of register P2 will then change.  Make sure this does not\n** cause any problems.)\n**\n** This instruction only works on tables.  The equivalent instruction\n** for indices is OP_IdxInsert.\n*/\n/* Opcode: InsertInt P1 P2 P3 P4 P5\n** Synopsis: intkey=P3 data=r[P2]\n**\n** This works exactly like OP_Insert except that the key is the\n** integer value P3, not the value of the integer stored in register P3.\n*/\ncase OP_Insert: \ncase OP_InsertInt: {\n  Mem *pData;       /* MEM cell holding data for the record to be inserted */\n  Mem *pKey;        /* MEM cell holding key  for the record */\n  VdbeCursor *pC;   /* Cursor to table into which insert is written */\n  int seekResult;   /* Result of prior seek or 0 if no USESEEKRESULT flag */\n  const char *zDb;  /* database name - used by the update hook */\n  Table *pTab;      /* Table structure - used by update and pre-update hooks */\n  int op;           /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */\n  BtreePayload x;   /* Payload to be inserted */\n\n  op = 0;\n  pData = &aMem[pOp->p2];\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( memIsValid(pData) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( (pOp->p5 & OPFLAG_ISNOOP) || pC->isTable );\n  assert( pOp->p4type==P4_TABLE || pOp->p4type>=P4_STATIC );\n  REGISTER_TRACE(pOp->p2, pData);\n\n  if( pOp->opcode==OP_Insert ){\n    pKey = &aMem[pOp->p3];\n    assert( pKey->flags & MEM_Int );\n    assert( memIsValid(pKey) );\n    REGISTER_TRACE(pOp->p3, pKey);\n    x.nKey = pKey->u.i;\n  }else{\n    assert( pOp->opcode==OP_InsertInt );\n    x.nKey = pOp->p3;\n  }\n\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) );\n    op = ((pOp->p5 & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_INSERT);\n  }else{\n    pTab = 0; /* Not needed.  Silence a compiler warning. */\n    zDb = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update hook, if any */\n  if( db->xPreUpdateCallback \n   && pOp->p4type==P4_TABLE\n   && !(pOp->p5 & OPFLAG_ISUPDATE)\n  ){\n    sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2);\n  }\n  if( pOp->p5 & OPFLAG_ISNOOP ) break;\n#endif\n\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = x.nKey;\n  assert( pData->flags & (MEM_Blob|MEM_Str) );\n  x.pData = pData->z;\n  x.nData = pData->n;\n  seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0);\n  if( pData->flags & MEM_Zero ){\n    x.nZero = pData->u.nZero;\n  }else{\n    x.nZero = 0;\n  }\n  x.pKey = 0;\n  rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n      (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), seekResult\n  );\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n\n  /* Invoke the update-hook if required. */\n  if( rc ) goto abort_due_to_error;\n  if( db->xUpdateCallback && op ){\n    db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey);\n  }\n  break;\n}\n\n/* Opcode: Delete P1 P2 P3 P4 P5\n**\n** Delete the record at which the P1 cursor is currently pointing.\n**\n** If the OPFLAG_SAVEPOSITION bit of the P5 parameter is set, then\n** the cursor will be left pointing at  either the next or the previous\n** record in the table. If it is left pointing at the next record, then\n** the next Next instruction will be a no-op. As a result, in this case\n** it is ok to delete a record from within a Next loop. If \n** OPFLAG_SAVEPOSITION bit of P5 is clear, then the cursor will be\n** left in an undefined state.\n**\n** If the OPFLAG_AUXDELETE bit is set on P5, that indicates that this\n** delete one of several associated with deleting a table row and all its\n** associated index entries.  Exactly one of those deletes is the \"primary\"\n** delete.  The others are all on OPFLAG_FORDELETE cursors or else are\n** marked with the AUXDELETE flag.\n**\n** If the OPFLAG_NCHANGE flag of P2 (NB: P2 not P5) is set, then the row\n** change count is incremented (otherwise not).\n**\n** P1 must not be pseudo-table.  It has to be a real table with\n** multiple rows.\n**\n** If P4 is not NULL then it points to a Table object. In this case either \n** the update or pre-update hook, or both, may be invoked. The P1 cursor must\n** have been positioned using OP_NotFound prior to invoking this opcode in \n** this case. Specifically, if one is configured, the pre-update hook is \n** invoked if P4 is not NULL. The update-hook is invoked if one is configured, \n** P4 is not NULL, and the OPFLAG_NCHANGE flag is set in P2.\n**\n** If the OPFLAG_ISUPDATE flag is set in P2, then P3 contains the address\n** of the memory cell that contains the value that the rowid of the row will\n** be set to by the update.\n*/\ncase OP_Delete: {\n  VdbeCursor *pC;\n  const char *zDb;\n  Table *pTab;\n  int opflags;\n\n  opflags = pOp->p2;\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->deferredMoveto==0 );\n\n#ifdef SQLITE_DEBUG\n  if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){\n    /* If p5 is zero, the seek operation that positioned the cursor prior to\n    ** OP_Delete will have also set the pC->movetoTarget field to the rowid of\n    ** the row that is being deleted */\n    i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    assert( pC->movetoTarget==iKey );\n  }\n#endif\n\n  /* If the update-hook or pre-update-hook will be invoked, set zDb to\n  ** the name of the db to pass as to it. Also set local pTab to a copy\n  ** of p4.pTab. Finally, if p5 is true, indicating that this cursor was\n  ** last moved with OP_Next or OP_Prev, not Seek or NotFound, set \n  ** VdbeCursor.movetoTarget to the current rowid.  */\n  if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){\n    assert( pC->iDb>=0 );\n    assert( pOp->p4.pTab!=0 );\n    zDb = db->aDb[pC->iDb].zDbSName;\n    pTab = pOp->p4.pTab;\n    if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){\n      pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n    }\n  }else{\n    zDb = 0;   /* Not needed.  Silence a compiler warning. */\n    pTab = 0;  /* Not needed.  Silence a compiler warning. */\n  }\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n  /* Invoke the pre-update-hook if required. */\n  if( db->xPreUpdateCallback && pOp->p4.pTab ){\n    assert( !(opflags & OPFLAG_ISUPDATE) \n         || HasRowid(pTab)==0 \n         || (aMem[pOp->p3].flags & MEM_Int) \n    );\n    sqlite3VdbePreUpdateHook(p, pC,\n        (opflags & OPFLAG_ISUPDATE) ? SQLITE_UPDATE : SQLITE_DELETE, \n        zDb, pTab, pC->movetoTarget,\n        pOp->p3\n    );\n  }\n  if( opflags & OPFLAG_ISNOOP ) break;\n#endif\n \n  /* Only flags that can be set are SAVEPOISTION and AUXDELETE */ \n  assert( (pOp->p5 & ~(OPFLAG_SAVEPOSITION|OPFLAG_AUXDELETE))==0 );\n  assert( OPFLAG_SAVEPOSITION==BTREE_SAVEPOSITION );\n  assert( OPFLAG_AUXDELETE==BTREE_AUXDELETE );\n\n#ifdef SQLITE_DEBUG\n  if( p->pFrame==0 ){\n    if( pC->isEphemeral==0\n        && (pOp->p5 & OPFLAG_AUXDELETE)==0\n        && (pC->wrFlag & OPFLAG_FORDELETE)==0\n      ){\n      nExtraDelete++;\n    }\n    if( pOp->p2 & OPFLAG_NCHANGE ){\n      nExtraDelete--;\n    }\n  }\n#endif\n\n  rc = sqlite3BtreeDelete(pC->uc.pCursor, pOp->p5);\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  if( rc ) goto abort_due_to_error;\n\n  /* Invoke the update-hook if required. */\n  if( opflags & OPFLAG_NCHANGE ){\n    p->nChange++;\n    if( db->xUpdateCallback && HasRowid(pTab) ){\n      db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName,\n          pC->movetoTarget);\n      assert( pC->iDb>=0 );\n    }\n  }\n\n  break;\n}\n/* Opcode: ResetCount * * * * *\n**\n** The value of the change counter is copied to the database handle\n** change counter (returned by subsequent calls to sqlite3_changes()).\n** Then the VMs internal change counter resets to 0.\n** This is used by trigger programs.\n*/\ncase OP_ResetCount: {\n  sqlite3VdbeSetChanges(db, p->nChange);\n  p->nChange = 0;\n  break;\n}\n\n/* Opcode: SorterCompare P1 P2 P3 P4\n** Synopsis: if key(P1)!=trim(r[P3],P4) goto P2\n**\n** P1 is a sorter cursor. This instruction compares a prefix of the\n** record blob in register P3 against a prefix of the entry that \n** the sorter cursor currently points to.  Only the first P4 fields\n** of r[P3] and the sorter record are compared.\n**\n** If either P3 or the sorter contains a NULL in one of their significant\n** fields (not counting the P4 fields at the end which are ignored) then\n** the comparison is assumed to be equal.\n**\n** Fall through to next instruction if the two records compare equal to\n** each other.  Jump to P2 if they are different.\n*/\ncase OP_SorterCompare: {\n  VdbeCursor *pC;\n  int res;\n  int nKeyCol;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  assert( pOp->p4type==P4_INT32 );\n  pIn3 = &aMem[pOp->p3];\n  nKeyCol = pOp->p4.i;\n  res = 0;\n  rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);\n  VdbeBranchTaken(res!=0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res ) goto jump_to_p2;\n  break;\n};\n\n/* Opcode: SorterData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the current sorter data for sorter cursor P1.\n** Then clear the column header cache on cursor P3.\n**\n** This opcode is normally use to move a record out of the sorter and into\n** a register that is the source for a pseudo-table cursor created using\n** OpenPseudo.  That pseudo-table cursor is the one that is identified by\n** parameter P3.  Clearing the P3 column cache as part of this opcode saves\n** us from having to issue a separate NullRow instruction to clear that cache.\n*/\ncase OP_SorterData: {\n  VdbeCursor *pC;\n\n  pOut = &aMem[pOp->p2];\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterRowkey(pC, pOut);\n  assert( rc!=SQLITE_OK || (pOut->flags & MEM_Blob) );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  if( rc ) goto abort_due_to_error;\n  p->apCsr[pOp->p3]->cacheStatus = CACHE_STALE;\n  break;\n}\n\n/* Opcode: RowData P1 P2 P3 * *\n** Synopsis: r[P2]=data\n**\n** Write into register P2 the complete row content for the row at \n** which cursor P1 is currently pointing.\n** There is no interpretation of the data.  \n** It is just copied onto the P2 register exactly as \n** it is found in the database file.\n**\n** If cursor P1 is an index, then the content is the key of the row.\n** If cursor P2 is a table, then the content extracted is the data.\n**\n** If the P1 cursor must be pointing to a valid row (not a NULL row)\n** of a real table, not a pseudo-table.\n**\n** If P3!=0 then this opcode is allowed to make an ephermeral pointer\n** into the database page.  That means that the content of the output\n** register will be invalidated as soon as the cursor moves - including\n** moves caused by other cursors that \"save\" the the current cursors\n** position in order that they can write to the same table.  If P3==0\n** then a copy of the data is made into memory.  P3!=0 is faster, but\n** P3==0 is safer.\n**\n** If P3!=0 then the content of the P2 register is unsuitable for use\n** in OP_Result and any OP_Result will invalidate the P2 register content.\n** The P2 register content is invalidated by opcodes like OP_Function or\n** by any use of another cursor pointing to the same table.\n*/\ncase OP_RowData: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  u32 n;\n\n  pOut = out2Prerelease(p, pOp);\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( isSorter(pC)==0 );\n  assert( pC->nullRow==0 );\n  assert( pC->uc.pCursor!=0 );\n  pCrsr = pC->uc.pCursor;\n\n  /* The OP_RowData opcodes always follow OP_NotExists or\n  ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions\n  ** that might invalidate the cursor.\n  ** If this where not the case, on of the following assert()s\n  ** would fail.  Should this ever change (because of changes in the code\n  ** generator) then the fix would be to insert a call to\n  ** sqlite3VdbeCursorMoveto().\n  */\n  assert( pC->deferredMoveto==0 );\n  assert( sqlite3BtreeCursorIsValid(pCrsr) );\n#if 0  /* Not required due to the previous to assert() statements */\n  rc = sqlite3VdbeCursorMoveto(pC);\n  if( rc!=SQLITE_OK ) goto abort_due_to_error;\n#endif\n\n  n = sqlite3BtreePayloadSize(pCrsr);\n  if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    goto too_big;\n  }\n  testcase( n==0 );\n  rc = sqlite3VdbeMemFromBtree(pCrsr, 0, n, pOut);\n  if( rc ) goto abort_due_to_error;\n  if( !pOp->p3 ) Deephemeralize(pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  REGISTER_TRACE(pOp->p2, pOut);\n  break;\n}\n\n/* Opcode: Rowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Store in register P2 an integer which is the key of the table entry that\n** P1 is currently point to.\n**\n** P1 can be either an ordinary table or a virtual table.  There used to\n** be a separate OP_VRowid opcode for use with virtual tables, but this\n** one opcode now works for both table types.\n*/\ncase OP_Rowid: {                 /* out2 */\n  VdbeCursor *pC;\n  i64 v;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  pOut = out2Prerelease(p, pOp);\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );\n  if( pC->nullRow ){\n    pOut->flags = MEM_Null;\n    break;\n  }else if( pC->deferredMoveto ){\n    v = pC->movetoTarget;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  }else if( pC->eCurType==CURTYPE_VTAB ){\n    assert( pC->uc.pVCur!=0 );\n    pVtab = pC->uc.pVCur->pVtab;\n    pModule = pVtab->pModule;\n    assert( pModule->xRowid );\n    rc = pModule->xRowid(pC->uc.pVCur, &v);\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc ) goto abort_due_to_error;\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->uc.pCursor!=0 );\n    rc = sqlite3VdbeCursorRestore(pC);\n    if( rc ) goto abort_due_to_error;\n    if( pC->nullRow ){\n      pOut->flags = MEM_Null;\n      break;\n    }\n    v = sqlite3BtreeIntegerKey(pC->uc.pCursor);\n  }\n  pOut->u.i = v;\n  break;\n}\n\n/* Opcode: NullRow P1 * * * *\n**\n** Move the cursor P1 to a null row.  Any OP_Column operations\n** that occur while the cursor is on the null row will always\n** write a NULL.\n*/\ncase OP_NullRow: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pC->nullRow = 1;\n  pC->cacheStatus = CACHE_STALE;\n  if( pC->eCurType==CURTYPE_BTREE ){\n    assert( pC->uc.pCursor!=0 );\n    sqlite3BtreeClearCursor(pC->uc.pCursor);\n  }\n  break;\n}\n\n/* Opcode: SeekEnd P1 * * * *\n**\n** Position cursor P1 at the end of the btree for the purpose of\n** appending a new entry onto the btree.\n**\n** It is assumed that the cursor is used only for appending and so\n** if the cursor is valid, then the cursor must already be pointing\n** at the end of the btree and so no changes are made to\n** the cursor.\n*/\n/* Opcode: Last P1 P2 * * *\n**\n** The next use of the Rowid or Column or Prev instruction for P1 \n** will refer to the last entry in the database table or index.\n** If the table or index is empty and P2>0, then jump immediately to P2.\n** If P2 is 0 or if the table or index is not empty, fall through\n** to the following instruction.\n**\n** This opcode leaves the cursor configured to move in reverse order,\n** from the end toward the beginning.  In other words, the cursor is\n** configured to use Prev, not Next.\n*/\ncase OP_SeekEnd:\ncase OP_Last: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  res = 0;\n  assert( pCrsr!=0 );\n#ifdef SQLITE_DEBUG\n  pC->seekOp = pOp->opcode;\n#endif\n  if( pOp->opcode==OP_SeekEnd ){\n    assert( pOp->p2==0 );\n    pC->seekResult = -1;\n    if( sqlite3BtreeCursorIsValidNN(pCrsr) ){\n      break;\n    }\n  }\n  rc = sqlite3BtreeLast(pCrsr, &res);\n  pC->nullRow = (u8)res;\n  pC->deferredMoveto = 0;\n  pC->cacheStatus = CACHE_STALE;\n  if( rc ) goto abort_due_to_error;\n  if( pOp->p2>0 ){\n    VdbeBranchTaken(res!=0,2);\n    if( res ) goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: IfSmaller P1 P2 P3 * *\n**\n** Estimate the number of rows in the table P1.  Jump to P2 if that\n** estimate is less than approximately 2**(0.1*P3).\n*/\ncase OP_IfSmaller: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  i64 sz;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr );\n  rc = sqlite3BtreeFirst(pCrsr, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    sz = sqlite3BtreeRowCountEst(pCrsr);\n    if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;\n  }\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: SorterSort P1 P2 * * *\n**\n** After all records have been inserted into the Sorter object\n** identified by P1, invoke this opcode to actually do the sorting.\n** Jump to P2 if there are no records to be sorted.\n**\n** This opcode is an alias for OP_Sort and OP_Rewind that is used\n** for Sorter objects.\n*/\n/* Opcode: Sort P1 P2 * * *\n**\n** This opcode does exactly the same thing as OP_Rewind except that\n** it increments an undocumented global variable used for testing.\n**\n** Sorting is accomplished by writing records into a sorting index,\n** then rewinding that index and playing it back from beginning to\n** end.  We use the OP_Sort opcode instead of OP_Rewind to do the\n** rewinding so that the global variable will be incremented and\n** regression tests can determine whether or not the optimizer is\n** correctly optimizing out sorts.\n*/\ncase OP_SorterSort:    /* jump */\ncase OP_Sort: {        /* jump */\n#ifdef SQLITE_TEST\n  sqlite3_sort_count++;\n  sqlite3_search_count--;\n#endif\n  p->aCounter[SQLITE_STMTSTATUS_SORT]++;\n  /* Fall through into OP_Rewind */\n}\n/* Opcode: Rewind P1 P2 * * *\n**\n** The next use of the Rowid or Column or Next instruction for P1 \n** will refer to the first entry in the database table or index.\n** If the table or index is empty, jump immediately to P2.\n** If the table or index is not empty, fall through to the following \n** instruction.\n**\n** This opcode leaves the cursor configured to move in forward order,\n** from the beginning toward the end.  In other words, the cursor is\n** configured to use Next, not Prev.\n*/\ncase OP_Rewind: {        /* jump */\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );\n  res = 1;\n#ifdef SQLITE_DEBUG\n  pC->seekOp = OP_Rewind;\n#endif\n  if( isSorter(pC) ){\n    rc = sqlite3VdbeSorterRewind(pC, &res);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    pCrsr = pC->uc.pCursor;\n    assert( pCrsr );\n    rc = sqlite3BtreeFirst(pCrsr, &res);\n    pC->deferredMoveto = 0;\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc ) goto abort_due_to_error;\n  pC->nullRow = (u8)res;\n  assert( pOp->p2>0 && pOp->p2<p->nOp );\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Next P1 P2 P3 P4 P5\n**\n** Advance cursor P1 so that it points to the next key/data pair in its\n** table or index.  If there are no more key/value pairs then fall through\n** to the following instruction.  But if the cursor advance was successful,\n** jump immediately to P2.\n**\n** The Next opcode is only valid following an SeekGT, SeekGE, or\n** OP_Rewind opcode used to position the cursor.  Next is not allowed\n** to follow SeekLT, SeekLE, or OP_Last.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  P1 must have\n** been opened prior to this opcode or the program will segfault.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreeNext().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n**\n** See also: Prev, NextIfOpen\n*/\n/* Opcode: NextIfOpen P1 P2 P3 P4 P5\n**\n** This opcode works just like Next except that if cursor P1 is not\n** open it behaves a no-op.\n*/\n/* Opcode: Prev P1 P2 P3 P4 P5\n**\n** Back up cursor P1 so that it points to the previous key/data pair in its\n** table or index.  If there is no previous key/value pairs then fall through\n** to the following instruction.  But if the cursor backup was successful,\n** jump immediately to P2.\n**\n**\n** The Prev opcode is only valid following an SeekLT, SeekLE, or\n** OP_Last opcode used to position the cursor.  Prev is not allowed\n** to follow SeekGT, SeekGE, or OP_Rewind.\n**\n** The P1 cursor must be for a real table, not a pseudo-table.  If P1 is\n** not open then the behavior is undefined.\n**\n** The P3 value is a hint to the btree implementation. If P3==1, that\n** means P1 is an SQL index and that this instruction could have been\n** omitted if that index had been unique.  P3 is usually 0.  P3 is\n** always either 0 or 1.\n**\n** P4 is always of type P4_ADVANCE. The function pointer points to\n** sqlite3BtreePrevious().\n**\n** If P5 is positive and the jump is taken, then event counter\n** number P5-1 in the prepared statement is incremented.\n*/\n/* Opcode: PrevIfOpen P1 P2 P3 P4 P5\n**\n** This opcode works just like Prev except that if cursor P1 is not\n** open it behaves a no-op.\n*/\n/* Opcode: SorterNext P1 P2 * * P5\n**\n** This opcode works just like OP_Next except that P1 must be a\n** sorter object for which the OP_SorterSort opcode has been\n** invoked.  This opcode advances the cursor to the next sorted\n** record, or jumps to P2 if there are no more sorted records.\n*/\ncase OP_SorterNext: {  /* jump */\n  VdbeCursor *pC;\n\n  pC = p->apCsr[pOp->p1];\n  assert( isSorter(pC) );\n  rc = sqlite3VdbeSorterNext(db, pC);\n  goto next_tail;\ncase OP_PrevIfOpen:    /* jump */\ncase OP_NextIfOpen:    /* jump */\n  if( p->apCsr[pOp->p1]==0 ) break;\n  /* Fall through */\ncase OP_Prev:          /* jump */\ncase OP_Next:          /* jump */\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p5<ArraySize(p->aCounter) );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->deferredMoveto==0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext );\n  assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious );\n  assert( pOp->opcode!=OP_NextIfOpen || pOp->p4.xAdvance==sqlite3BtreeNext );\n  assert( pOp->opcode!=OP_PrevIfOpen || pOp->p4.xAdvance==sqlite3BtreePrevious);\n\n  /* The Next opcode is only used after SeekGT, SeekGE, and Rewind.\n  ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */\n  assert( pOp->opcode!=OP_Next || pOp->opcode!=OP_NextIfOpen\n       || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE\n       || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found);\n  assert( pOp->opcode!=OP_Prev || pOp->opcode!=OP_PrevIfOpen\n       || pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE\n       || pC->seekOp==OP_Last );\n\n  rc = pOp->p4.xAdvance(pC->uc.pCursor, pOp->p3);\nnext_tail:\n  pC->cacheStatus = CACHE_STALE;\n  VdbeBranchTaken(rc==SQLITE_OK,2);\n  if( rc==SQLITE_OK ){\n    pC->nullRow = 0;\n    p->aCounter[pOp->p5]++;\n#ifdef SQLITE_TEST\n    sqlite3_search_count++;\n#endif\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n  rc = SQLITE_OK;\n  pC->nullRow = 1;\n  goto check_for_interrupt;\n}\n\n/* Opcode: IdxInsert P1 P2 P3 P4 P5\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the index P1.  Data for the entry is nil.\n**\n** If P4 is not zero, then it is the number of values in the unpacked\n** key of reg(P2).  In that case, P3 is the index of the first register\n** for the unpacked key.  The availability of the unpacked key can sometimes\n** be an optimization.\n**\n** If P5 has the OPFLAG_APPEND bit set, that is a hint to the b-tree layer\n** that this insert is likely to be an append.\n**\n** If P5 has the OPFLAG_NCHANGE bit set, then the change counter is\n** incremented by this instruction.  If the OPFLAG_NCHANGE bit is clear,\n** then the change counter is unchanged.\n**\n** If the OPFLAG_USESEEKRESULT flag of P5 is set, the implementation might\n** run faster by avoiding an unnecessary seek on cursor P1.  However,\n** the OPFLAG_USESEEKRESULT flag must only be set if there have been no prior\n** seeks on the cursor or if the most recent seek used a key equivalent\n** to P2. \n**\n** This instruction only works for indices.  The equivalent instruction\n** for tables is OP_Insert.\n*/\n/* Opcode: SorterInsert P1 P2 * * *\n** Synopsis: key=r[P2]\n**\n** Register P2 holds an SQL index key made using the\n** MakeRecord instructions.  This opcode writes that key\n** into the sorter P1.  Data for the entry is nil.\n*/\ncase OP_SorterInsert:       /* in2 */\ncase OP_IdxInsert: {        /* in2 */\n  VdbeCursor *pC;\n  BtreePayload x;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) );\n  pIn2 = &aMem[pOp->p2];\n  assert( pIn2->flags & MEM_Blob );\n  if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++;\n  assert( pC->eCurType==CURTYPE_BTREE || pOp->opcode==OP_SorterInsert );\n  assert( pC->isTable==0 );\n  rc = ExpandBlob(pIn2);\n  if( rc ) goto abort_due_to_error;\n  if( pOp->opcode==OP_SorterInsert ){\n    rc = sqlite3VdbeSorterWrite(pC, pIn2);\n  }else{\n    x.nKey = pIn2->n;\n    x.pKey = pIn2->z;\n    x.aMem = aMem + pOp->p3;\n    x.nMem = (u16)pOp->p4.i;\n    rc = sqlite3BtreeInsert(pC->uc.pCursor, &x,\n         (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), \n        ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0)\n        );\n    assert( pC->deferredMoveto==0 );\n    pC->cacheStatus = CACHE_STALE;\n  }\n  if( rc) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: IdxDelete P1 P2 P3 * *\n** Synopsis: key=r[P2@P3]\n**\n** The content of P3 registers starting at register P2 form\n** an unpacked index key. This opcode removes that entry from the \n** index opened by cursor P1.\n*/\ncase OP_IdxDelete: {\n  VdbeCursor *pC;\n  BtCursor *pCrsr;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p3>0 );\n  assert( pOp->p2>0 && pOp->p2+pOp->p3<=(p->nMem+1 - p->nCursor)+1 );\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCrsr = pC->uc.pCursor;\n  assert( pCrsr!=0 );\n  assert( pOp->p5==0 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p3;\n  r.default_rc = 0;\n  r.aMem = &aMem[pOp->p2];\n  rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);\n  if( rc ) goto abort_due_to_error;\n  if( res==0 ){\n    rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);\n    if( rc ) goto abort_due_to_error;\n  }\n  assert( pC->deferredMoveto==0 );\n  pC->cacheStatus = CACHE_STALE;\n  pC->seekResult = 0;\n  break;\n}\n\n/* Opcode: DeferredSeek P1 * P3 P4 *\n** Synopsis: Move P3 to P1.rowid if needed\n**\n** P1 is an open index cursor and P3 is a cursor on the corresponding\n** table.  This opcode does a deferred seek of the P3 table cursor\n** to the row that corresponds to the current row of P1.\n**\n** This is a deferred seek.  Nothing actually happens until\n** the cursor is used to read a record.  That way, if no reads\n** occur, no unnecessary I/O happens.\n**\n** P4 may be an array of integers (type P4_INTARRAY) containing\n** one entry for each column in the P3 table.  If array entry a(i)\n** is non-zero, then reading column a(i)-1 from cursor P3 is \n** equivalent to performing the deferred seek and then reading column i \n** from P1.  This information is stored in P3 and used to redirect\n** reads against P3 over to P1, thus possibly avoiding the need to\n** seek and read cursor P3.\n*/\n/* Opcode: IdxRowid P1 P2 * * *\n** Synopsis: r[P2]=rowid\n**\n** Write into register P2 an integer which is the last entry in the record at\n** the end of the index key pointed to by cursor P1.  This integer should be\n** the rowid of the table entry to which this index entry points.\n**\n** See also: Rowid, MakeRecord.\n*/\ncase OP_DeferredSeek:\ncase OP_IdxRowid: {           /* out2 */\n  VdbeCursor *pC;             /* The P1 index cursor */\n  VdbeCursor *pTabCur;        /* The P2 table cursor (OP_DeferredSeek only) */\n  i64 rowid;                  /* Rowid that P1 current points to */\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0 );\n  assert( pC->isTable==0 );\n  assert( pC->deferredMoveto==0 );\n  assert( !pC->nullRow || pOp->opcode==OP_IdxRowid );\n\n  /* The IdxRowid and Seek opcodes are combined because of the commonality\n  ** of sqlite3VdbeCursorRestore() and sqlite3VdbeIdxRowid(). */\n  rc = sqlite3VdbeCursorRestore(pC);\n\n  /* sqlite3VbeCursorRestore() can only fail if the record has been deleted\n  ** out from under the cursor.  That will never happens for an IdxRowid\n  ** or Seek opcode */\n  if( NEVER(rc!=SQLITE_OK) ) goto abort_due_to_error;\n\n  if( !pC->nullRow ){\n    rowid = 0;  /* Not needed.  Only used to silence a warning. */\n    rc = sqlite3VdbeIdxRowid(db, pC->uc.pCursor, &rowid);\n    if( rc!=SQLITE_OK ){\n      goto abort_due_to_error;\n    }\n    if( pOp->opcode==OP_DeferredSeek ){\n      assert( pOp->p3>=0 && pOp->p3<p->nCursor );\n      pTabCur = p->apCsr[pOp->p3];\n      assert( pTabCur!=0 );\n      assert( pTabCur->eCurType==CURTYPE_BTREE );\n      assert( pTabCur->uc.pCursor!=0 );\n      assert( pTabCur->isTable );\n      pTabCur->nullRow = 0;\n      pTabCur->movetoTarget = rowid;\n      pTabCur->deferredMoveto = 1;\n      assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );\n      pTabCur->aAltMap = pOp->p4.ai;\n      pTabCur->pAltCursor = pC;\n    }else{\n      pOut = out2Prerelease(p, pOp);\n      pOut->u.i = rowid;\n    }\n  }else{\n    assert( pOp->opcode==OP_IdxRowid );\n    sqlite3VdbeMemSetNull(&aMem[pOp->p2]);\n  }\n  break;\n}\n\n/* Opcode: IdxGE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than or equal to the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxGT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY.  Compare this key value against the index \n** that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID \n** fields at the end.\n**\n** If the P1 index entry is greater than the key value\n** then jump to P2.  Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLT P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than the key value then jump to P2.\n** Otherwise fall through to the next instruction.\n*/\n/* Opcode: IdxLE P1 P2 P3 P4 P5\n** Synopsis: key=r[P3@P4]\n**\n** The P4 register values beginning with P3 form an unpacked index \n** key that omits the PRIMARY KEY or ROWID.  Compare this key value against\n** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or\n** ROWID on the P1 index.\n**\n** If the P1 index entry is less than or equal to the key value then jump\n** to P2. Otherwise fall through to the next instruction.\n*/\ncase OP_IdxLE:          /* jump */\ncase OP_IdxGT:          /* jump */\ncase OP_IdxLT:          /* jump */\ncase OP_IdxGE:  {       /* jump */\n  VdbeCursor *pC;\n  int res;\n  UnpackedRecord r;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  assert( pC->isOrdered );\n  assert( pC->eCurType==CURTYPE_BTREE );\n  assert( pC->uc.pCursor!=0);\n  assert( pC->deferredMoveto==0 );\n  assert( pOp->p5==0 || pOp->p5==1 );\n  assert( pOp->p4type==P4_INT32 );\n  r.pKeyInfo = pC->pKeyInfo;\n  r.nField = (u16)pOp->p4.i;\n  if( pOp->opcode<OP_IdxLT ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxGT );\n    r.default_rc = -1;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxLT );\n    r.default_rc = 0;\n  }\n  r.aMem = &aMem[pOp->p3];\n#ifdef SQLITE_DEBUG\n  { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }\n#endif\n  res = 0;  /* Not needed.  Only used to silence a warning. */\n  rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);\n  assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );\n  if( (pOp->opcode&1)==(OP_IdxLT&1) ){\n    assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );\n    res = -res;\n  }else{\n    assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );\n    res++;\n  }\n  VdbeBranchTaken(res>0,2);\n  if( rc ) goto abort_due_to_error;\n  if( res>0 ) goto jump_to_p2;\n  break;\n}\n\n/* Opcode: Destroy P1 P2 P3 * *\n**\n** Delete an entire database table or index whose root page in the database\n** file is given by P1.\n**\n** The table being destroyed is in the main database file if P3==0.  If\n** P3==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If AUTOVACUUM is enabled then it is possible that another root page\n** might be moved into the newly deleted root page in order to keep all\n** root pages contiguous at the beginning of the database.  The former\n** value of the root page that moved - its value before the move occurred -\n** is stored in register P2. If no page movement was required (because the\n** table being dropped was already the last one in the database) then a \n** zero is stored in register P2.  If AUTOVACUUM is disabled then a zero \n** is stored in register P2.\n**\n** This opcode throws an error if there are any active reader VMs when\n** it is invoked. This is done to avoid the difficulty associated with \n** updating existing cursors when a root page is moved in an AUTOVACUUM \n** database. This error is thrown even if the database is not an AUTOVACUUM \n** db in order to avoid introducing an incompatibility between autovacuum \n** and non-autovacuum modes.\n**\n** See also: Clear\n*/\ncase OP_Destroy: {     /* out2 */\n  int iMoved;\n  int iDb;\n\n  assert( p->readOnly==0 );\n  assert( pOp->p1>1 );\n  pOut = out2Prerelease(p, pOp);\n  pOut->flags = MEM_Null;\n  if( db->nVdbeRead > db->nVDestroy+1 ){\n    rc = SQLITE_LOCKED;\n    p->errorAction = OE_Abort;\n    goto abort_due_to_error;\n  }else{\n    iDb = pOp->p3;\n    assert( DbMaskTest(p->btreeMask, iDb) );\n    iMoved = 0;  /* Not needed.  Only to silence a warning. */\n    rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);\n    pOut->flags = MEM_Int;\n    pOut->u.i = iMoved;\n    if( rc ) goto abort_due_to_error;\n#ifndef SQLITE_OMIT_AUTOVACUUM\n    if( iMoved!=0 ){\n      sqlite3RootPageMoved(db, iDb, iMoved, pOp->p1);\n      /* All OP_Destroy operations occur on the same btree */\n      assert( resetSchemaOnFault==0 || resetSchemaOnFault==iDb+1 );\n      resetSchemaOnFault = iDb+1;\n    }\n#endif\n  }\n  break;\n}\n\n/* Opcode: Clear P1 P2 P3\n**\n** Delete all contents of the database table or index whose root page\n** in the database file is given by P1.  But, unlike Destroy, do not\n** remove the table or index from the database file.\n**\n** The table being clear is in the main database file if P2==0.  If\n** P2==1 then the table to be clear is in the auxiliary database file\n** that is used to store tables create using CREATE TEMPORARY TABLE.\n**\n** If the P3 value is non-zero, then the table referred to must be an\n** intkey table (an SQL table, not an index). In this case the row change \n** count is incremented by the number of rows in the table being cleared. \n** If P3 is greater than zero, then the value stored in register P3 is\n** also incremented by the number of rows in the table being cleared.\n**\n** See also: Destroy\n*/\ncase OP_Clear: {\n  int nChange;\n \n  nChange = 0;\n  assert( p->readOnly==0 );\n  assert( DbMaskTest(p->btreeMask, pOp->p2) );\n  rc = sqlite3BtreeClearTable(\n      db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0)\n  );\n  if( pOp->p3 ){\n    p->nChange += nChange;\n    if( pOp->p3>0 ){\n      assert( memIsValid(&aMem[pOp->p3]) );\n      memAboutToChange(p, &aMem[pOp->p3]);\n      aMem[pOp->p3].u.i += nChange;\n    }\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ResetSorter P1 * * * *\n**\n** Delete all contents from the ephemeral table or sorter\n** that is open on cursor P1.\n**\n** This opcode only works for cursors used for sorting and\n** opened with OP_OpenEphemeral or OP_SorterOpen.\n*/\ncase OP_ResetSorter: {\n  VdbeCursor *pC;\n \n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  pC = p->apCsr[pOp->p1];\n  assert( pC!=0 );\n  if( isSorter(pC) ){\n    sqlite3VdbeSorterReset(db, pC->uc.pSorter);\n  }else{\n    assert( pC->eCurType==CURTYPE_BTREE );\n    assert( pC->isEphemeral );\n    rc = sqlite3BtreeClearTableOfCursor(pC->uc.pCursor);\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n\n/* Opcode: CreateBtree P1 P2 P3 * *\n** Synopsis: r[P2]=root iDb=P1 flags=P3\n**\n** Allocate a new b-tree in the main database file if P1==0 or in the\n** TEMP database file if P1==1 or in an attached database if\n** P1>1.  The P3 argument must be 1 (BTREE_INTKEY) for a rowid table\n** it must be 2 (BTREE_BLOBKEY) for a index or WITHOUT ROWID table.\n** The root page number of the new b-tree is stored in register P2.\n*/\ncase OP_CreateBtree: {          /* out2 */\n  int pgno;\n  Db *pDb;\n\n  pOut = out2Prerelease(p, pOp);\n  pgno = 0;\n  assert( pOp->p3==BTREE_INTKEY || pOp->p3==BTREE_BLOBKEY );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pDb = &db->aDb[pOp->p1];\n  assert( pDb->pBt!=0 );\n  rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, pOp->p3);\n  if( rc ) goto abort_due_to_error;\n  pOut->u.i = pgno;\n  break;\n}\n\n/* Opcode: SqlExec * * * P4 *\n**\n** Run the SQL statement or statements specified in the P4 string.\n*/\ncase OP_SqlExec: {\n  db->nSqlExec++;\n  rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);\n  db->nSqlExec--;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n\n/* Opcode: ParseSchema P1 * * P4 *\n**\n** Read and parse all entries from the SQLITE_MASTER table of database P1\n** that match the WHERE clause P4. \n**\n** This opcode invokes the parser to create a new virtual machine,\n** then runs the new virtual machine.  It is thus a re-entrant opcode.\n*/\ncase OP_ParseSchema: {\n  int iDb;\n  const char *zMaster;\n  char *zSql;\n  InitData initData;\n\n  /* Any prepared statement that invokes this opcode will hold mutexes\n  ** on every btree.  This is a prerequisite for invoking \n  ** sqlite3InitCallback().\n  */\n#ifdef SQLITE_DEBUG\n  for(iDb=0; iDb<db->nDb; iDb++){\n    assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );\n  }\n#endif\n\n  iDb = pOp->p1;\n  assert( iDb>=0 && iDb<db->nDb );\n  assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );\n  /* Used to be a conditional */ {\n    zMaster = MASTER_NAME;\n    initData.db = db;\n    initData.iDb = pOp->p1;\n    initData.pzErrMsg = &p->zErrMsg;\n    zSql = sqlite3MPrintf(db,\n       \"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid\",\n       db->aDb[iDb].zDbSName, zMaster, pOp->p4.z);\n    if( zSql==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n    }else{\n      assert( db->init.busy==0 );\n      db->init.busy = 1;\n      initData.rc = SQLITE_OK;\n      assert( !db->mallocFailed );\n      rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);\n      if( rc==SQLITE_OK ) rc = initData.rc;\n      sqlite3DbFreeNN(db, zSql);\n      db->init.busy = 0;\n    }\n  }\n  if( rc ){\n    sqlite3ResetAllSchemasOfConnection(db);\n    if( rc==SQLITE_NOMEM ){\n      goto no_mem;\n    }\n    goto abort_due_to_error;\n  }\n  break;  \n}\n\n#if !defined(SQLITE_OMIT_ANALYZE)\n/* Opcode: LoadAnalysis P1 * * * *\n**\n** Read the sqlite_stat1 table for database P1 and load the content\n** of that table into the internal index hash table.  This will cause\n** the analysis to be used when preparing all subsequent queries.\n*/\ncase OP_LoadAnalysis: {\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  rc = sqlite3AnalysisLoad(db, pOp->p1);\n  if( rc ) goto abort_due_to_error;\n  break;  \n}\n#endif /* !defined(SQLITE_OMIT_ANALYZE) */\n\n/* Opcode: DropTable P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the table named P4 in database P1.  This is called after a table\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTable: {\n  sqlite3UnlinkAndDeleteTable(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropIndex P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the index named P4 in database P1.  This is called after an index\n** is dropped from disk (using the Destroy opcode)\n** in order to keep the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropIndex: {\n  sqlite3UnlinkAndDeleteIndex(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n/* Opcode: DropTrigger P1 * * P4 *\n**\n** Remove the internal (in-memory) data structures that describe\n** the trigger named P4 in database P1.  This is called after a trigger\n** is dropped from disk (using the Destroy opcode) in order to keep \n** the internal representation of the\n** schema consistent with what is on disk.\n*/\ncase OP_DropTrigger: {\n  sqlite3UnlinkAndDeleteTrigger(db, pOp->p1, pOp->p4.z);\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_INTEGRITY_CHECK\n/* Opcode: IntegrityCk P1 P2 P3 P4 P5\n**\n** Do an analysis of the currently open database.  Store in\n** register P1 the text of an error message describing any problems.\n** If no problems are found, store a NULL in register P1.\n**\n** The register P3 contains one less than the maximum number of allowed errors.\n** At most reg(P3) errors will be reported.\n** In other words, the analysis stops as soon as reg(P1) errors are \n** seen.  Reg(P1) is updated with the number of errors remaining.\n**\n** The root page numbers of all tables in the database are integers\n** stored in P4_INTARRAY argument.\n**\n** If P5 is not zero, the check is done on the auxiliary database\n** file, not the main database file.\n**\n** This opcode is used to implement the integrity_check pragma.\n*/\ncase OP_IntegrityCk: {\n  int nRoot;      /* Number of tables to check.  (Number of root pages.) */\n  int *aRoot;     /* Array of rootpage numbers for tables to be checked */\n  int nErr;       /* Number of errors reported */\n  char *z;        /* Text of the error report */\n  Mem *pnErr;     /* Register keeping track of errors remaining */\n\n  assert( p->bIsReader );\n  nRoot = pOp->p2;\n  aRoot = pOp->p4.ai;\n  assert( nRoot>0 );\n  assert( aRoot[0]==nRoot );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pnErr = &aMem[pOp->p3];\n  assert( (pnErr->flags & MEM_Int)!=0 );\n  assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );\n  pIn1 = &aMem[pOp->p1];\n  assert( pOp->p5<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p5) );\n  z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, &aRoot[1], nRoot,\n                                 (int)pnErr->u.i+1, &nErr);\n  sqlite3VdbeMemSetNull(pIn1);\n  if( nErr==0 ){\n    assert( z==0 );\n  }else if( z==0 ){\n    goto no_mem;\n  }else{\n    pnErr->u.i -= nErr-1;\n    sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);\n  }\n  UPDATE_MAX_BLOBSIZE(pIn1);\n  sqlite3VdbeChangeEncoding(pIn1, encoding);\n  break;\n}\n#endif /* SQLITE_OMIT_INTEGRITY_CHECK */\n\n/* Opcode: RowSetAdd P1 P2 * * *\n** Synopsis: rowset(P1)=r[P2]\n**\n** Insert the integer value held by register P2 into a RowSet object\n** held in register P1.\n**\n** An assertion fails if P2 is not an integer.\n*/\ncase OP_RowSetAdd: {       /* in1, in2 */\n  pIn1 = &aMem[pOp->p1];\n  pIn2 = &aMem[pOp->p2];\n  assert( (pIn2->flags & MEM_Int)!=0 );\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n  sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i);\n  break;\n}\n\n/* Opcode: RowSetRead P1 P2 P3 * *\n** Synopsis: r[P3]=rowset(P1)\n**\n** Extract the smallest value from the RowSet object in P1\n** and put that value into register P3.\n** Or, if RowSet object P1 is initially empty, leave P3\n** unchanged and jump to instruction P2.\n*/\ncase OP_RowSetRead: {       /* jump, in1, out3 */\n  i64 val;\n\n  pIn1 = &aMem[pOp->p1];\n  if( (pIn1->flags & MEM_RowSet)==0 \n   || sqlite3RowSetNext(pIn1->u.pRowSet, &val)==0\n  ){\n    /* The boolean index is empty */\n    sqlite3VdbeMemSetNull(pIn1);\n    VdbeBranchTaken(1,2);\n    goto jump_to_p2_and_check_for_interrupt;\n  }else{\n    /* A value was pulled from the index */\n    VdbeBranchTaken(0,2);\n    sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);\n  }\n  goto check_for_interrupt;\n}\n\n/* Opcode: RowSetTest P1 P2 P3 P4\n** Synopsis: if r[P3] in rowset(P1) goto P2\n**\n** Register P3 is assumed to hold a 64-bit integer value. If register P1\n** contains a RowSet object and that RowSet object contains\n** the value held in P3, jump to register P2. Otherwise, insert the\n** integer in P3 into the RowSet and continue on to the\n** next opcode.\n**\n** The RowSet object is optimized for the case where sets of integers\n** are inserted in distinct phases, which each set contains no duplicates.\n** Each set is identified by a unique P4 value. The first set\n** must have P4==0, the final set must have P4==-1, and for all other sets\n** must have P4>0.\n**\n** This allows optimizations: (a) when P4==0 there is no need to test\n** the RowSet object for P3, as it is guaranteed not to contain it,\n** (b) when P4==-1 there is no need to insert the value, as it will\n** never be tested for, and (c) when a value that is part of set X is\n** inserted, there is no need to search to see if the same value was\n** previously inserted as part of set X (only if it was previously\n** inserted as part of some other set).\n*/\ncase OP_RowSetTest: {                     /* jump, in1, in3 */\n  int iSet;\n  int exists;\n\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  iSet = pOp->p4.i;\n  assert( pIn3->flags&MEM_Int );\n\n  /* If there is anything other than a rowset object in memory cell P1,\n  ** delete it now and initialize P1 with an empty rowset\n  */\n  if( (pIn1->flags & MEM_RowSet)==0 ){\n    sqlite3VdbeMemSetRowSet(pIn1);\n    if( (pIn1->flags & MEM_RowSet)==0 ) goto no_mem;\n  }\n\n  assert( pOp->p4type==P4_INT32 );\n  assert( iSet==-1 || iSet>=0 );\n  if( iSet ){\n    exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i);\n    VdbeBranchTaken(exists!=0,2);\n    if( exists ) goto jump_to_p2;\n  }\n  if( iSet>=0 ){\n    sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);\n  }\n  break;\n}\n\n\n#ifndef SQLITE_OMIT_TRIGGER\n\n/* Opcode: Program P1 P2 P3 P4 P5\n**\n** Execute the trigger program passed as P4 (type P4_SUBPROGRAM). \n**\n** P1 contains the address of the memory cell that contains the first memory \n** cell in an array of values used as arguments to the sub-program. P2 \n** contains the address to jump to if the sub-program throws an IGNORE \n** exception using the RAISE() function. Register P3 contains the address \n** of a memory cell in this (the parent) VM that is used to allocate the \n** memory required by the sub-vdbe at runtime.\n**\n** P4 is a pointer to the VM containing the trigger program.\n**\n** If P5 is non-zero, then recursive program invocation is enabled.\n*/\ncase OP_Program: {        /* jump */\n  int nMem;               /* Number of memory registers for sub-program */\n  int nByte;              /* Bytes of runtime space required for sub-program */\n  Mem *pRt;               /* Register to allocate runtime space */\n  Mem *pMem;              /* Used to iterate through memory cells */\n  Mem *pEnd;              /* Last memory cell in new array */\n  VdbeFrame *pFrame;      /* New vdbe frame to execute in */\n  SubProgram *pProgram;   /* Sub-program to execute */\n  void *t;                /* Token identifying trigger */\n\n  pProgram = pOp->p4.pProgram;\n  pRt = &aMem[pOp->p3];\n  assert( pProgram->nOp>0 );\n  \n  /* If the p5 flag is clear, then recursive invocation of triggers is \n  ** disabled for backwards compatibility (p5 is set if this sub-program\n  ** is really a trigger, not a foreign key action, and the flag set\n  ** and cleared by the \"PRAGMA recursive_triggers\" command is clear).\n  ** \n  ** It is recursive invocation of triggers, at the SQL level, that is \n  ** disabled. In some cases a single trigger may generate more than one \n  ** SubProgram (if the trigger may be executed with more than one different \n  ** ON CONFLICT algorithm). SubProgram structures associated with a\n  ** single trigger all have the same value for the SubProgram.token \n  ** variable.  */\n  if( pOp->p5 ){\n    t = pProgram->token;\n    for(pFrame=p->pFrame; pFrame && pFrame->token!=t; pFrame=pFrame->pParent);\n    if( pFrame ) break;\n  }\n\n  if( p->nFrame>=db->aLimit[SQLITE_LIMIT_TRIGGER_DEPTH] ){\n    rc = SQLITE_ERROR;\n    sqlite3VdbeError(p, \"too many levels of trigger recursion\");\n    goto abort_due_to_error;\n  }\n\n  /* Register pRt is used to store the memory required to save the state\n  ** of the current program, and the memory required at runtime to execute\n  ** the trigger program. If this trigger has been fired before, then pRt \n  ** is already allocated. Otherwise, it must be initialized.  */\n  if( (pRt->flags&MEM_Frame)==0 ){\n    /* SubProgram.nMem is set to the number of memory cells used by the \n    ** program stored in SubProgram.aOp. As well as these, one memory\n    ** cell is required for each cursor used by the program. Set local\n    ** variable nMem (and later, VdbeFrame.nChildMem) to this value.\n    */\n    nMem = pProgram->nMem + pProgram->nCsr;\n    assert( nMem>0 );\n    if( pProgram->nCsr==0 ) nMem++;\n    nByte = ROUND8(sizeof(VdbeFrame))\n              + nMem * sizeof(Mem)\n              + pProgram->nCsr * sizeof(VdbeCursor*)\n              + (pProgram->nOp + 7)/8;\n    pFrame = sqlite3DbMallocZero(db, nByte);\n    if( !pFrame ){\n      goto no_mem;\n    }\n    sqlite3VdbeMemRelease(pRt);\n    pRt->flags = MEM_Frame;\n    pRt->u.pFrame = pFrame;\n\n    pFrame->v = p;\n    pFrame->nChildMem = nMem;\n    pFrame->nChildCsr = pProgram->nCsr;\n    pFrame->pc = (int)(pOp - aOp);\n    pFrame->aMem = p->aMem;\n    pFrame->nMem = p->nMem;\n    pFrame->apCsr = p->apCsr;\n    pFrame->nCursor = p->nCursor;\n    pFrame->aOp = p->aOp;\n    pFrame->nOp = p->nOp;\n    pFrame->token = pProgram->token;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    pFrame->anExec = p->anExec;\n#endif\n\n    pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];\n    for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){\n      pMem->flags = MEM_Undefined;\n      pMem->db = db;\n    }\n  }else{\n    pFrame = pRt->u.pFrame;\n    assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem \n        || (pProgram->nCsr==0 && pProgram->nMem+1==pFrame->nChildMem) );\n    assert( pProgram->nCsr==pFrame->nChildCsr );\n    assert( (int)(pOp - aOp)==pFrame->pc );\n  }\n\n  p->nFrame++;\n  pFrame->pParent = p->pFrame;\n  pFrame->lastRowid = db->lastRowid;\n  pFrame->nChange = p->nChange;\n  pFrame->nDbChange = p->db->nChange;\n  assert( pFrame->pAuxData==0 );\n  pFrame->pAuxData = p->pAuxData;\n  p->pAuxData = 0;\n  p->nChange = 0;\n  p->pFrame = pFrame;\n  p->aMem = aMem = VdbeFrameMem(pFrame);\n  p->nMem = pFrame->nChildMem;\n  p->nCursor = (u16)pFrame->nChildCsr;\n  p->apCsr = (VdbeCursor **)&aMem[p->nMem];\n  pFrame->aOnce = (u8*)&p->apCsr[pProgram->nCsr];\n  memset(pFrame->aOnce, 0, (pProgram->nOp + 7)/8);\n  p->aOp = aOp = pProgram->aOp;\n  p->nOp = pProgram->nOp;\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  p->anExec = 0;\n#endif\n  pOp = &aOp[-1];\n\n  break;\n}\n\n/* Opcode: Param P1 P2 * * *\n**\n** This opcode is only ever present in sub-programs called via the \n** OP_Program instruction. Copy a value currently stored in a memory \n** cell of the calling (parent) frame to cell P2 in the current frames \n** address space. This is used by trigger programs to access the new.* \n** and old.* values.\n**\n** The address of the cell in the parent frame is determined by adding\n** the value of the P1 argument to the value of the P1 argument to the\n** calling OP_Program instruction.\n*/\ncase OP_Param: {           /* out2 */\n  VdbeFrame *pFrame;\n  Mem *pIn;\n  pOut = out2Prerelease(p, pOp);\n  pFrame = p->pFrame;\n  pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];   \n  sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);\n  break;\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRIGGER */\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n/* Opcode: FkCounter P1 P2 * * *\n** Synopsis: fkctr[P1]+=P2\n**\n** Increment a \"constraint counter\" by P2 (P2 may be negative or positive).\n** If P1 is non-zero, the database constraint counter is incremented \n** (deferred foreign key constraints). Otherwise, if P1 is zero, the \n** statement counter is incremented (immediate foreign key constraints).\n*/\ncase OP_FkCounter: {\n  if( db->flags & SQLITE_DeferFKs ){\n    db->nDeferredImmCons += pOp->p2;\n  }else if( pOp->p1 ){\n    db->nDeferredCons += pOp->p2;\n  }else{\n    p->nFkConstraint += pOp->p2;\n  }\n  break;\n}\n\n/* Opcode: FkIfZero P1 P2 * * *\n** Synopsis: if fkctr[P1]==0 goto P2\n**\n** This opcode tests if a foreign key constraint-counter is currently zero.\n** If so, jump to instruction P2. Otherwise, fall through to the next \n** instruction.\n**\n** If P1 is non-zero, then the jump is taken if the database constraint-counter\n** is zero (the one that counts deferred constraint violations). If P1 is\n** zero, the jump is taken if the statement constraint-counter is zero\n** (immediate foreign key constraint violations).\n*/\ncase OP_FkIfZero: {         /* jump */\n  if( pOp->p1 ){\n    VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);\n    if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }else{\n    VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);\n    if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;\n  }\n  break;\n}\n#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */\n\n#ifndef SQLITE_OMIT_AUTOINCREMENT\n/* Opcode: MemMax P1 P2 * * *\n** Synopsis: r[P1]=max(r[P1],r[P2])\n**\n** P1 is a register in the root frame of this VM (the root frame is\n** different from the current frame if this instruction is being executed\n** within a sub-program). Set the value of register P1 to the maximum of \n** its current value and the value in register P2.\n**\n** This instruction throws an error if the memory cell is not initially\n** an integer.\n*/\ncase OP_MemMax: {        /* in2 */\n  VdbeFrame *pFrame;\n  if( p->pFrame ){\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    pIn1 = &pFrame->aMem[pOp->p1];\n  }else{\n    pIn1 = &aMem[pOp->p1];\n  }\n  assert( memIsValid(pIn1) );\n  sqlite3VdbeMemIntegerify(pIn1);\n  pIn2 = &aMem[pOp->p2];\n  sqlite3VdbeMemIntegerify(pIn2);\n  if( pIn1->u.i<pIn2->u.i){\n    pIn1->u.i = pIn2->u.i;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_AUTOINCREMENT */\n\n/* Opcode: IfPos P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P1]-=P3, goto P2\n**\n** Register P1 must contain an integer.\n** If the value of register P1 is 1 or greater, subtract P3 from the\n** value in P1 and jump to P2.\n**\n** If the initial value of register P1 is less than 1, then the\n** value is unchanged and control passes through to the next instruction.\n*/\ncase OP_IfPos: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken( pIn1->u.i>0, 2);\n  if( pIn1->u.i>0 ){\n    pIn1->u.i -= pOp->p3;\n    goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: OffsetLimit P1 P2 P3 * *\n** Synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)\n**\n** This opcode performs a commonly used computation associated with\n** LIMIT and OFFSET process.  r[P1] holds the limit counter.  r[P3]\n** holds the offset counter.  The opcode computes the combined value\n** of the LIMIT and OFFSET and stores that value in r[P2].  The r[P2]\n** value computed is the total number of rows that will need to be\n** visited in order to complete the query.\n**\n** If r[P3] is zero or negative, that means there is no OFFSET\n** and r[P2] is set to be the value of the LIMIT, r[P1].\n**\n** if r[P1] is zero or negative, that means there is no LIMIT\n** and r[P2] is set to -1. \n**\n** Otherwise, r[P2] is set to the sum of r[P1] and r[P3].\n*/\ncase OP_OffsetLimit: {    /* in1, out2, in3 */\n  i64 x;\n  pIn1 = &aMem[pOp->p1];\n  pIn3 = &aMem[pOp->p3];\n  pOut = out2Prerelease(p, pOp);\n  assert( pIn1->flags & MEM_Int );\n  assert( pIn3->flags & MEM_Int );\n  x = pIn1->u.i;\n  if( x<=0 || sqlite3AddInt64(&x, pIn3->u.i>0?pIn3->u.i:0) ){\n    /* If the LIMIT is less than or equal to zero, loop forever.  This\n    ** is documented.  But also, if the LIMIT+OFFSET exceeds 2^63 then\n    ** also loop forever.  This is undocumented.  In fact, one could argue\n    ** that the loop should terminate.  But assuming 1 billion iterations\n    ** per second (far exceeding the capabilities of any current hardware)\n    ** it would take nearly 300 years to actually reach the limit.  So\n    ** looping forever is a reasonable approximation. */\n    pOut->u.i = -1;\n  }else{\n    pOut->u.i = x;\n  }\n  break;\n}\n\n/* Opcode: IfNotZero P1 P2 * * *\n** Synopsis: if r[P1]!=0 then r[P1]--, goto P2\n**\n** Register P1 must contain an integer.  If the content of register P1 is\n** initially greater than zero, then decrement the value in register P1.\n** If it is non-zero (negative or positive) and then also jump to P2.  \n** If register P1 is initially zero, leave it unchanged and fall through.\n*/\ncase OP_IfNotZero: {        /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  VdbeBranchTaken(pIn1->u.i<0, 2);\n  if( pIn1->u.i ){\n     if( pIn1->u.i>0 ) pIn1->u.i--;\n     goto jump_to_p2;\n  }\n  break;\n}\n\n/* Opcode: DecrJumpZero P1 P2 * * *\n** Synopsis: if (--r[P1])==0 goto P2\n**\n** Register P1 must hold an integer.  Decrement the value in P1\n** and jump to P2 if the new value is exactly zero.\n*/\ncase OP_DecrJumpZero: {      /* jump, in1 */\n  pIn1 = &aMem[pOp->p1];\n  assert( pIn1->flags&MEM_Int );\n  if( pIn1->u.i>SMALLEST_INT64 ) pIn1->u.i--;\n  VdbeBranchTaken(pIn1->u.i==0, 2);\n  if( pIn1->u.i==0 ) goto jump_to_p2;\n  break;\n}\n\n\n/* Opcode: AggStep0 * P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the step function for an aggregate.  The\n** function has P5 arguments.   P4 is a pointer to the FuncDef\n** structure that specifies the function.  Register P3 is the\n** accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n*/\n/* Opcode: AggStep * P2 P3 P4 P5\n** Synopsis: accum=r[P3] step(r[P2@P5])\n**\n** Execute the step function for an aggregate.  The\n** function has P5 arguments.   P4 is a pointer to an sqlite3_context\n** object that is used to run the function.  Register P3 is\n** as the accumulator.\n**\n** The P5 arguments are taken from register P2 and its\n** successors.\n**\n** This opcode is initially coded as OP_AggStep0.  On first evaluation,\n** the FuncDef stored in P4 is converted into an sqlite3_context and\n** the opcode is changed.  In this way, the initialization of the\n** sqlite3_context only happens once, instead of on each call to the\n** step function.\n*/\ncase OP_AggStep0: {\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pMem = 0;\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n  pOp->opcode = OP_AggStep;\n  /* Fall through into OP_AggStep */\n}\ncase OP_AggStep: {\n  int i;\n  sqlite3_context *pCtx;\n  Mem *pMem;\n  Mem t;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n  pMem = &aMem[pOp->p3];\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  if( pCtx->pMem != pMem ){\n    pCtx->pMem = pMem;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n\n  pMem->n++;\n  sqlite3VdbeMemInit(&t, db, MEM_Null);\n  pCtx->pOut = &t;\n  pCtx->fErrorOrAux = 0;\n  pCtx->skipFlag = 0;\n  (pCtx->pFunc->xSFunc)(pCtx,pCtx->argc,pCtx->argv); /* IMP: R-24505-23230 */\n  if( pCtx->fErrorOrAux ){\n    if( pCtx->isError ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(&t));\n      rc = pCtx->isError;\n    }\n    sqlite3VdbeMemRelease(&t);\n    if( rc ) goto abort_due_to_error;\n  }else{\n    assert( t.flags==MEM_Null );\n  }\n  if( pCtx->skipFlag ){\n    assert( pOp[-1].opcode==OP_CollSeq );\n    i = pOp[-1].p1;\n    if( i ) sqlite3VdbeMemSetInt64(&aMem[i], 1);\n  }\n  break;\n}\n\n/* Opcode: AggFinal P1 P2 * P4 *\n** Synopsis: accum=r[P1] N=P2\n**\n** Execute the finalizer function for an aggregate.  P1 is\n** the memory location that is the accumulator for the aggregate.\n**\n** P2 is the number of arguments that the step function takes and\n** P4 is a pointer to the FuncDef for this function.  The P2\n** argument is not used by this opcode.  It is only there to disambiguate\n** functions that can take varying numbers of arguments.  The\n** P4 argument is only needed for the degenerate case where\n** the step function was not previously called.\n*/\ncase OP_AggFinal: {\n  Mem *pMem;\n  assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );\n  pMem = &aMem[pOp->p1];\n  assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );\n  rc = sqlite3VdbeMemFinalize(pMem, pOp->p4.pFunc);\n  if( rc ){\n    sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pMem));\n    goto abort_due_to_error;\n  }\n  sqlite3VdbeChangeEncoding(pMem, encoding);\n  UPDATE_MAX_BLOBSIZE(pMem);\n  if( sqlite3VdbeMemTooBig(pMem) ){\n    goto too_big;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_WAL\n/* Opcode: Checkpoint P1 P2 P3 * *\n**\n** Checkpoint database P1. This is a no-op if P1 is not currently in\n** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL,\n** RESTART, or TRUNCATE.  Write 1 or 0 into mem[P3] if the checkpoint returns\n** SQLITE_BUSY or not, respectively.  Write the number of pages in the\n** WAL after the checkpoint into mem[P3+1] and the number of pages\n** in the WAL that have been checkpointed after the checkpoint\n** completes into mem[P3+2].  However on an error, mem[P3+1] and\n** mem[P3+2] are initialized to -1.\n*/\ncase OP_Checkpoint: {\n  int i;                          /* Loop counter */\n  int aRes[3];                    /* Results */\n  Mem *pMem;                      /* Write results here */\n\n  assert( p->readOnly==0 );\n  aRes[0] = 0;\n  aRes[1] = aRes[2] = -1;\n  assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE\n       || pOp->p2==SQLITE_CHECKPOINT_FULL\n       || pOp->p2==SQLITE_CHECKPOINT_RESTART\n       || pOp->p2==SQLITE_CHECKPOINT_TRUNCATE\n  );\n  rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);\n  if( rc ){\n    if( rc!=SQLITE_BUSY ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    aRes[0] = 1;\n  }\n  for(i=0, pMem = &aMem[pOp->p3]; i<3; i++, pMem++){\n    sqlite3VdbeMemSetInt64(pMem, (i64)aRes[i]);\n  }    \n  break;\n};  \n#endif\n\n#ifndef SQLITE_OMIT_PRAGMA\n/* Opcode: JournalMode P1 P2 P3 * *\n**\n** Change the journal mode of database P1 to P3. P3 must be one of the\n** PAGER_JOURNALMODE_XXX values. If changing between the various rollback\n** modes (delete, truncate, persist, off and memory), this is a simple\n** operation. No IO is required.\n**\n** If changing into or out of WAL mode the procedure is more complicated.\n**\n** Write a string containing the final journal-mode to register P2.\n*/\ncase OP_JournalMode: {    /* out2 */\n  Btree *pBt;                     /* Btree to change journal mode of */\n  Pager *pPager;                  /* Pager associated with pBt */\n  int eNew;                       /* New journal mode */\n  int eOld;                       /* The old journal mode */\n#ifndef SQLITE_OMIT_WAL\n  const char *zFilename;          /* Name of database file for pPager */\n#endif\n\n  pOut = out2Prerelease(p, pOp);\n  eNew = pOp->p3;\n  assert( eNew==PAGER_JOURNALMODE_DELETE \n       || eNew==PAGER_JOURNALMODE_TRUNCATE \n       || eNew==PAGER_JOURNALMODE_PERSIST \n       || eNew==PAGER_JOURNALMODE_OFF\n       || eNew==PAGER_JOURNALMODE_MEMORY\n       || eNew==PAGER_JOURNALMODE_WAL\n       || eNew==PAGER_JOURNALMODE_QUERY\n  );\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( p->readOnly==0 );\n\n  pBt = db->aDb[pOp->p1].pBt;\n  pPager = sqlite3BtreePager(pBt);\n  eOld = sqlite3PagerGetJournalMode(pPager);\n  if( eNew==PAGER_JOURNALMODE_QUERY ) eNew = eOld;\n  if( !sqlite3PagerOkToChangeJournalMode(pPager) ) eNew = eOld;\n\n#ifndef SQLITE_OMIT_WAL\n  zFilename = sqlite3PagerFilename(pPager, 1);\n\n  /* Do not allow a transition to journal_mode=WAL for a database\n  ** in temporary storage or if the VFS does not support shared memory \n  */\n  if( eNew==PAGER_JOURNALMODE_WAL\n   && (sqlite3Strlen30(zFilename)==0           /* Temp file */\n       || !sqlite3PagerWalSupported(pPager))   /* No shared-memory support */\n  ){\n    eNew = eOld;\n  }\n\n  if( (eNew!=eOld)\n   && (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)\n  ){\n    if( !db->autoCommit || db->nVdbeRead>1 ){\n      rc = SQLITE_ERROR;\n      sqlite3VdbeError(p,\n          \"cannot change %s wal mode from within a transaction\",\n          (eNew==PAGER_JOURNALMODE_WAL ? \"into\" : \"out of\")\n      );\n      goto abort_due_to_error;\n    }else{\n \n      if( eOld==PAGER_JOURNALMODE_WAL ){\n        /* If leaving WAL mode, close the log file. If successful, the call\n        ** to PagerCloseWal() checkpoints and deletes the write-ahead-log \n        ** file. An EXCLUSIVE lock may still be held on the database file \n        ** after a successful return. \n        */\n        rc = sqlite3PagerCloseWal(pPager, db);\n        if( rc==SQLITE_OK ){\n          sqlite3PagerSetJournalMode(pPager, eNew);\n        }\n      }else if( eOld==PAGER_JOURNALMODE_MEMORY ){\n        /* Cannot transition directly from MEMORY to WAL.  Use mode OFF\n        ** as an intermediate */\n        sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF);\n      }\n  \n      /* Open a transaction on the database file. Regardless of the journal\n      ** mode, this transaction always uses a rollback journal.\n      */\n      assert( sqlite3BtreeIsInTrans(pBt)==0 );\n      if( rc==SQLITE_OK ){\n        rc = sqlite3BtreeSetVersion(pBt, (eNew==PAGER_JOURNALMODE_WAL ? 2 : 1));\n      }\n    }\n  }\n#endif /* ifndef SQLITE_OMIT_WAL */\n\n  if( rc ) eNew = eOld;\n  eNew = sqlite3PagerSetJournalMode(pPager, eNew);\n\n  pOut->flags = MEM_Str|MEM_Static|MEM_Term;\n  pOut->z = (char *)sqlite3JournalModename(eNew);\n  pOut->n = sqlite3Strlen30(pOut->z);\n  pOut->enc = SQLITE_UTF8;\n  sqlite3VdbeChangeEncoding(pOut, encoding);\n  if( rc ) goto abort_due_to_error;\n  break;\n};\n#endif /* SQLITE_OMIT_PRAGMA */\n\n#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)\n/* Opcode: Vacuum P1 * * * *\n**\n** Vacuum the entire database P1.  P1 is 0 for \"main\", and 2 or more\n** for an attached database.  The \"temp\" database may not be vacuumed.\n*/\ncase OP_Vacuum: {\n  assert( p->readOnly==0 );\n  rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#if !defined(SQLITE_OMIT_AUTOVACUUM)\n/* Opcode: IncrVacuum P1 P2 * * *\n**\n** Perform a single step of the incremental vacuum procedure on\n** the P1 database. If the vacuum has finished, jump to instruction\n** P2. Otherwise, fall through to the next instruction.\n*/\ncase OP_IncrVacuum: {        /* jump */\n  Btree *pBt;\n\n  assert( pOp->p1>=0 && pOp->p1<db->nDb );\n  assert( DbMaskTest(p->btreeMask, pOp->p1) );\n  assert( p->readOnly==0 );\n  pBt = db->aDb[pOp->p1].pBt;\n  rc = sqlite3BtreeIncrVacuum(pBt);\n  VdbeBranchTaken(rc==SQLITE_DONE,2);\n  if( rc ){\n    if( rc!=SQLITE_DONE ) goto abort_due_to_error;\n    rc = SQLITE_OK;\n    goto jump_to_p2;\n  }\n  break;\n}\n#endif\n\n/* Opcode: Expire P1 * * * *\n**\n** Cause precompiled statements to expire.  When an expired statement\n** is executed using sqlite3_step() it will either automatically\n** reprepare itself (if it was originally created using sqlite3_prepare_v2())\n** or it will fail with SQLITE_SCHEMA.\n** \n** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,\n** then only the currently executing statement is expired.\n*/\ncase OP_Expire: {\n  if( !pOp->p1 ){\n    sqlite3ExpirePreparedStatements(db);\n  }else{\n    p->expired = 1;\n  }\n  break;\n}\n\n#ifndef SQLITE_OMIT_SHARED_CACHE\n/* Opcode: TableLock P1 P2 P3 P4 *\n** Synopsis: iDb=P1 root=P2 write=P3\n**\n** Obtain a lock on a particular table. This instruction is only used when\n** the shared-cache feature is enabled. \n**\n** P1 is the index of the database in sqlite3.aDb[] of the database\n** on which the lock is acquired.  A readlock is obtained if P3==0 or\n** a write lock if P3==1.\n**\n** P2 contains the root-page of the table to lock.\n**\n** P4 contains a pointer to the name of the table being locked. This is only\n** used to generate an error message if the lock cannot be obtained.\n*/\ncase OP_TableLock: {\n  u8 isWriteLock = (u8)pOp->p3;\n  if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){\n    int p1 = pOp->p1; \n    assert( p1>=0 && p1<db->nDb );\n    assert( DbMaskTest(p->btreeMask, p1) );\n    assert( isWriteLock==0 || isWriteLock==1 );\n    rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock);\n    if( rc ){\n      if( (rc&0xFF)==SQLITE_LOCKED ){\n        const char *z = pOp->p4.z;\n        sqlite3VdbeError(p, \"database table is locked: %s\", z);\n      }\n      goto abort_due_to_error;\n    }\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_SHARED_CACHE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VBegin * * * P4 *\n**\n** P4 may be a pointer to an sqlite3_vtab structure. If so, call the \n** xBegin method for that table.\n**\n** Also, whether or not P4 is set, check that this is not being called from\n** within a callback to a virtual table xSync() method. If it is, the error\n** code will be set to SQLITE_LOCKED.\n*/\ncase OP_VBegin: {\n  VTable *pVTab;\n  pVTab = pOp->p4.pVtab;\n  rc = sqlite3VtabBegin(db, pVTab);\n  if( pVTab ) sqlite3VtabImportErrmsg(p, pVTab->pVtab);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VCreate P1 P2 * * *\n**\n** P2 is a register that holds the name of a virtual table in database \n** P1. Call the xCreate method for that table.\n*/\ncase OP_VCreate: {\n  Mem sMem;          /* For storing the record being decoded */\n  const char *zTab;  /* Name of the virtual table */\n\n  memset(&sMem, 0, sizeof(sMem));\n  sMem.db = db;\n  /* Because P2 is always a static string, it is impossible for the\n  ** sqlite3VdbeMemCopy() to fail */\n  assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );\n  assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );\n  rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);\n  assert( rc==SQLITE_OK );\n  zTab = (const char*)sqlite3_value_text(&sMem);\n  assert( zTab || db->mallocFailed );\n  if( zTab ){\n    rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);\n  }\n  sqlite3VdbeMemRelease(&sMem);\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VDestroy P1 * * P4 *\n**\n** P4 is the name of a virtual table in database P1.  Call the xDestroy method\n** of that table.\n*/\ncase OP_VDestroy: {\n  db->nVDestroy++;\n  rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);\n  db->nVDestroy--;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VOpen P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** P1 is a cursor number.  This opcode opens a cursor to the virtual\n** table and stores that cursor in P1.\n*/\ncase OP_VOpen: {\n  VdbeCursor *pCur;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n\n  assert( p->bIsReader );\n  pCur = 0;\n  pVCur = 0;\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  rc = pModule->xOpen(pVtab, &pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n\n  /* Initialize sqlite3_vtab_cursor base class */\n  pVCur->pVtab = pVtab;\n\n  /* Initialize vdbe cursor object */\n  pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);\n  if( pCur ){\n    pCur->uc.pVCur = pVCur;\n    pVtab->nRef++;\n  }else{\n    assert( db->mallocFailed );\n    pModule->xClose(pVCur);\n    goto no_mem;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VFilter P1 P2 P3 P4 *\n** Synopsis: iplan=r[P3] zplan='P4'\n**\n** P1 is a cursor opened using VOpen.  P2 is an address to jump to if\n** the filtered result set is empty.\n**\n** P4 is either NULL or a string that was generated by the xBestIndex\n** method of the module.  The interpretation of the P4 string is left\n** to the module implementation.\n**\n** This opcode invokes the xFilter method on the virtual table specified\n** by P1.  The integer query plan parameter to xFilter is stored in register\n** P3. Register P3+1 stores the argc parameter to be passed to the\n** xFilter method. Registers P3+2..P3+1+argc are the argc\n** additional parameters which are passed to\n** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter.\n**\n** A jump is made to P2 if the result set after filtering would be empty.\n*/\ncase OP_VFilter: {   /* jump */\n  int nArg;\n  int iQuery;\n  const sqlite3_module *pModule;\n  Mem *pQuery;\n  Mem *pArgc;\n  sqlite3_vtab_cursor *pVCur;\n  sqlite3_vtab *pVtab;\n  VdbeCursor *pCur;\n  int res;\n  int i;\n  Mem **apArg;\n\n  pQuery = &aMem[pOp->p3];\n  pArgc = &pQuery[1];\n  pCur = p->apCsr[pOp->p1];\n  assert( memIsValid(pQuery) );\n  REGISTER_TRACE(pOp->p3, pQuery);\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  pVCur = pCur->uc.pVCur;\n  pVtab = pVCur->pVtab;\n  pModule = pVtab->pModule;\n\n  /* Grab the index number and argc parameters */\n  assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );\n  nArg = (int)pArgc->u.i;\n  iQuery = (int)pQuery->u.i;\n\n  /* Invoke the xFilter method */\n  res = 0;\n  apArg = p->apArg;\n  for(i = 0; i<nArg; i++){\n    apArg[i] = &pArgc[i+1];\n  }\n  rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pVCur);\n  pCur->nullRow = 0;\n  VdbeBranchTaken(res!=0,2);\n  if( res ) goto jump_to_p2;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VColumn P1 P2 P3 * *\n** Synopsis: r[P3]=vcolumn(P2)\n**\n** Store the value of the P2-th column of\n** the row of the virtual-table that the \n** P1 cursor is pointing to into register P3.\n*/\ncase OP_VColumn: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  Mem *pDest;\n  sqlite3_context sContext;\n\n  VdbeCursor *pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  pDest = &aMem[pOp->p3];\n  memAboutToChange(p, pDest);\n  if( pCur->nullRow ){\n    sqlite3VdbeMemSetNull(pDest);\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xColumn );\n  memset(&sContext, 0, sizeof(sContext));\n  sContext.pOut = pDest;\n  MemSetTypeFlag(pDest, MEM_Null);\n  rc = pModule->xColumn(pCur->uc.pVCur, &sContext, pOp->p2);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( sContext.isError ){\n    rc = sContext.isError;\n  }\n  sqlite3VdbeChangeEncoding(pDest, encoding);\n  REGISTER_TRACE(pOp->p3, pDest);\n  UPDATE_MAX_BLOBSIZE(pDest);\n\n  if( sqlite3VdbeMemTooBig(pDest) ){\n    goto too_big;\n  }\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VNext P1 P2 * * *\n**\n** Advance virtual table P1 to the next row in its result set and\n** jump to instruction P2.  Or, if the virtual table has reached\n** the end of its result set, then fall through to the next instruction.\n*/\ncase OP_VNext: {   /* jump */\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int res;\n  VdbeCursor *pCur;\n\n  res = 0;\n  pCur = p->apCsr[pOp->p1];\n  assert( pCur->eCurType==CURTYPE_VTAB );\n  if( pCur->nullRow ){\n    break;\n  }\n  pVtab = pCur->uc.pVCur->pVtab;\n  pModule = pVtab->pModule;\n  assert( pModule->xNext );\n\n  /* Invoke the xNext() method of the module. There is no way for the\n  ** underlying implementation to return an error if one occurs during\n  ** xNext(). Instead, if an error occurs, true is returned (indicating that \n  ** data is available) and the error code returned when xColumn or\n  ** some other method is next invoked on the save virtual table cursor.\n  */\n  rc = pModule->xNext(pCur->uc.pVCur);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  if( rc ) goto abort_due_to_error;\n  res = pModule->xEof(pCur->uc.pVCur);\n  VdbeBranchTaken(!res,2);\n  if( !res ){\n    /* If there is data, jump to P2 */\n    goto jump_to_p2_and_check_for_interrupt;\n  }\n  goto check_for_interrupt;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VRename P1 * * P4 *\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xRename method. The value\n** in register P1 is passed as the zName argument to the xRename method.\n*/\ncase OP_VRename: {\n  sqlite3_vtab *pVtab;\n  Mem *pName;\n\n  pVtab = pOp->p4.pVtab->pVtab;\n  pName = &aMem[pOp->p1];\n  assert( pVtab->pModule->xRename );\n  assert( memIsValid(pName) );\n  assert( p->readOnly==0 );\n  REGISTER_TRACE(pOp->p1, pName);\n  assert( pName->flags & MEM_Str );\n  testcase( pName->enc==SQLITE_UTF8 );\n  testcase( pName->enc==SQLITE_UTF16BE );\n  testcase( pName->enc==SQLITE_UTF16LE );\n  rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);\n  if( rc ) goto abort_due_to_error;\n  rc = pVtab->pModule->xRename(pVtab, pName->z);\n  sqlite3VtabImportErrmsg(p, pVtab);\n  p->expired = 0;\n  if( rc ) goto abort_due_to_error;\n  break;\n}\n#endif\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/* Opcode: VUpdate P1 P2 P3 P4 P5\n** Synopsis: data=r[P3@P2]\n**\n** P4 is a pointer to a virtual table object, an sqlite3_vtab structure.\n** This opcode invokes the corresponding xUpdate method. P2 values\n** are contiguous memory cells starting at P3 to pass to the xUpdate \n** invocation. The value in register (P3+P2-1) corresponds to the \n** p2th element of the argv array passed to xUpdate.\n**\n** The xUpdate method will do a DELETE or an INSERT or both.\n** The argv[0] element (which corresponds to memory cell P3)\n** is the rowid of a row to delete.  If argv[0] is NULL then no \n** deletion occurs.  The argv[1] element is the rowid of the new \n** row.  This can be NULL to have the virtual table select the new \n** rowid for itself.  The subsequent elements in the array are \n** the values of columns in the new row.\n**\n** If P2==1 then no insert is performed.  argv[0] is the rowid of\n** a row to delete.\n**\n** P1 is a boolean flag. If it is set to true and the xUpdate call\n** is successful, then the value returned by sqlite3_last_insert_rowid() \n** is set to the value of the rowid for the row just inserted.\n**\n** P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to\n** apply in the case of a constraint failure on an insert or update.\n*/\ncase OP_VUpdate: {\n  sqlite3_vtab *pVtab;\n  const sqlite3_module *pModule;\n  int nArg;\n  int i;\n  sqlite_int64 rowid;\n  Mem **apArg;\n  Mem *pX;\n\n  assert( pOp->p2==1        || pOp->p5==OE_Fail   || pOp->p5==OE_Rollback \n       || pOp->p5==OE_Abort || pOp->p5==OE_Ignore || pOp->p5==OE_Replace\n  );\n  assert( p->readOnly==0 );\n  pVtab = pOp->p4.pVtab->pVtab;\n  if( pVtab==0 || NEVER(pVtab->pModule==0) ){\n    rc = SQLITE_LOCKED;\n    goto abort_due_to_error;\n  }\n  pModule = pVtab->pModule;\n  nArg = pOp->p2;\n  assert( pOp->p4type==P4_VTAB );\n  if( ALWAYS(pModule->xUpdate) ){\n    u8 vtabOnConflict = db->vtabOnConflict;\n    apArg = p->apArg;\n    pX = &aMem[pOp->p3];\n    for(i=0; i<nArg; i++){\n      assert( memIsValid(pX) );\n      memAboutToChange(p, pX);\n      apArg[i] = pX;\n      pX++;\n    }\n    db->vtabOnConflict = pOp->p5;\n    rc = pModule->xUpdate(pVtab, nArg, apArg, &rowid);\n    db->vtabOnConflict = vtabOnConflict;\n    sqlite3VtabImportErrmsg(p, pVtab);\n    if( rc==SQLITE_OK && pOp->p1 ){\n      assert( nArg>1 && apArg[0] && (apArg[0]->flags&MEM_Null) );\n      db->lastRowid = rowid;\n    }\n    if( (rc&0xff)==SQLITE_CONSTRAINT && pOp->p4.pVtab->bConstraint ){\n      if( pOp->p5==OE_Ignore ){\n        rc = SQLITE_OK;\n      }else{\n        p->errorAction = ((pOp->p5==OE_Replace) ? OE_Abort : pOp->p5);\n      }\n    }else{\n      p->nChange++;\n    }\n    if( rc ) goto abort_due_to_error;\n  }\n  break;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: Pagecount P1 P2 * * *\n**\n** Write the current number of pages in database P1 to memory cell P2.\n*/\ncase OP_Pagecount: {            /* out2 */\n  pOut = out2Prerelease(p, pOp);\n  pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);\n  break;\n}\n#endif\n\n\n#ifndef  SQLITE_OMIT_PAGER_PRAGMAS\n/* Opcode: MaxPgcnt P1 P2 P3 * *\n**\n** Try to set the maximum page count for database P1 to the value in P3.\n** Do not let the maximum page count fall below the current page count and\n** do not change the maximum page count value if P3==0.\n**\n** Store the maximum page count after the change in register P2.\n*/\ncase OP_MaxPgcnt: {            /* out2 */\n  unsigned int newMax;\n  Btree *pBt;\n\n  pOut = out2Prerelease(p, pOp);\n  pBt = db->aDb[pOp->p1].pBt;\n  newMax = 0;\n  if( pOp->p3 ){\n    newMax = sqlite3BtreeLastPage(pBt);\n    if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;\n  }\n  pOut->u.i = sqlite3BtreeMaxPageCount(pBt, newMax);\n  break;\n}\n#endif\n\n/* Opcode: Function0 P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to a FuncDef object that\n** defines the function) with P5 arguments taken from register P2 and\n** successors.  The result of the function is stored in register P3.\n** Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** See also: Function, AggStep, AggFinal\n*/\n/* Opcode: Function P1 P2 P3 P4 P5\n** Synopsis: r[P3]=func(r[P2@P5])\n**\n** Invoke a user function (P4 is a pointer to an sqlite3_context object that\n** contains a pointer to the function to be run) with P5 arguments taken\n** from register P2 and successors.  The result of the function is stored\n** in register P3.  Register P3 must not be one of the function inputs.\n**\n** P1 is a 32-bit bitmask indicating whether or not each argument to the \n** function was determined to be constant at compile time. If the first\n** argument was constant then bit 0 of P1 is set. This is used to determine\n** whether meta data associated with a user function argument using the\n** sqlite3_set_auxdata() API may be safely retained until the next\n** invocation of this opcode.\n**\n** SQL functions are initially coded as OP_Function0 with P4 pointing\n** to a FuncDef object.  But on first evaluation, the P4 operand is\n** automatically converted into an sqlite3_context object and the operation\n** changed to this OP_Function opcode.  In this way, the initialization of\n** the sqlite3_context object occurs only once, rather than once for each\n** evaluation of the function.\n**\n** See also: Function0, AggStep, AggFinal\n*/\ncase OP_PureFunc0:\ncase OP_Function0: {\n  int n;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCDEF );\n  n = pOp->p5;\n  assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );\n  assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );\n  assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );\n  pCtx = sqlite3DbMallocRawNN(db, sizeof(*pCtx) + (n-1)*sizeof(sqlite3_value*));\n  if( pCtx==0 ) goto no_mem;\n  pCtx->pOut = 0;\n  pCtx->pFunc = pOp->p4.pFunc;\n  pCtx->iOp = (int)(pOp - aOp);\n  pCtx->pVdbe = p;\n  pCtx->argc = n;\n  pOp->p4type = P4_FUNCCTX;\n  pOp->p4.pCtx = pCtx;\n  assert( OP_PureFunc == OP_PureFunc0+2 );\n  assert( OP_Function == OP_Function0+2 );\n  pOp->opcode += 2;\n  /* Fall through into OP_Function */\n}\ncase OP_PureFunc:\ncase OP_Function: {\n  int i;\n  sqlite3_context *pCtx;\n\n  assert( pOp->p4type==P4_FUNCCTX );\n  pCtx = pOp->p4.pCtx;\n\n  /* If this function is inside of a trigger, the register array in aMem[]\n  ** might change from one evaluation to the next.  The next block of code\n  ** checks to see if the register array has changed, and if so it\n  ** reinitializes the relavant parts of the sqlite3_context object */\n  pOut = &aMem[pOp->p3];\n  if( pCtx->pOut != pOut ){\n    pCtx->pOut = pOut;\n    for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];\n  }\n\n  memAboutToChange(p, pOut);\n#ifdef SQLITE_DEBUG\n  for(i=0; i<pCtx->argc; i++){\n    assert( memIsValid(pCtx->argv[i]) );\n    REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);\n  }\n#endif\n  MemSetTypeFlag(pOut, MEM_Null);\n  pCtx->fErrorOrAux = 0;\n  (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */\n\n  /* If the function returned an error, throw an exception */\n  if( pCtx->fErrorOrAux ){\n    if( pCtx->isError ){\n      sqlite3VdbeError(p, \"%s\", sqlite3_value_text(pOut));\n      rc = pCtx->isError;\n    }\n    sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);\n    if( rc ) goto abort_due_to_error;\n  }\n\n  /* Copy the result of the function into register P3 */\n  if( pOut->flags & (MEM_Str|MEM_Blob) ){\n    sqlite3VdbeChangeEncoding(pOut, encoding);\n    if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;\n  }\n\n  REGISTER_TRACE(pOp->p3, pOut);\n  UPDATE_MAX_BLOBSIZE(pOut);\n  break;\n}\n\n\n/* Opcode: Init P1 P2 P3 P4 *\n** Synopsis: Start at P2\n**\n** Programs contain a single instance of this opcode as the very first\n** opcode.\n**\n** If tracing is enabled (by the sqlite3_trace()) interface, then\n** the UTF-8 string contained in P4 is emitted on the trace callback.\n** Or if P4 is blank, use the string returned by sqlite3_sql().\n**\n** If P2 is not zero, jump to instruction P2.\n**\n** Increment the value of P1 so that OP_Once opcodes will jump the\n** first time they are evaluated for this run.\n**\n** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT\n** error is encountered.\n*/\ncase OP_Init: {          /* jump */\n  char *zTrace;\n  int i;\n\n  /* If the P4 argument is not NULL, then it must be an SQL comment string.\n  ** The \"--\" string is broken up to prevent false-positives with srcck1.c.\n  **\n  ** This assert() provides evidence for:\n  ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that\n  ** would have been returned by the legacy sqlite3_trace() interface by\n  ** using the X argument when X begins with \"--\" and invoking\n  ** sqlite3_expanded_sql(P) otherwise.\n  */\n  assert( pOp->p4.z==0 || strncmp(pOp->p4.z, \"-\" \"- \", 3)==0 );\n  assert( pOp==p->aOp );  /* Always instruction 0 */\n\n#ifndef SQLITE_OMIT_TRACE\n  if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0\n   && !p->doingRerun\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n#ifndef SQLITE_OMIT_DEPRECATED\n    if( db->mTrace & SQLITE_TRACE_LEGACY ){\n      void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace;\n      char *z = sqlite3VdbeExpandSql(p, zTrace);\n      x(db->pTraceArg, z);\n      sqlite3_free(z);\n    }else\n#endif\n    if( db->nVdbeExec>1 ){\n      char *z = sqlite3MPrintf(db, \"-- %s\", zTrace);\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, z);\n      sqlite3DbFree(db, z);\n    }else{\n      (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace);\n    }\n  }\n#ifdef SQLITE_USE_FCNTL_TRACE\n  zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql);\n  if( zTrace ){\n    int j;\n    for(j=0; j<db->nDb; j++){\n      if( DbMaskTest(p->btreeMask, j)==0 ) continue;\n      sqlite3_file_control(db, db->aDb[j].zDbSName, SQLITE_FCNTL_TRACE, zTrace);\n    }\n  }\n#endif /* SQLITE_USE_FCNTL_TRACE */\n#ifdef SQLITE_DEBUG\n  if( (db->flags & SQLITE_SqlTrace)!=0\n   && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0\n  ){\n    sqlite3DebugPrintf(\"SQL-trace: %s\\n\", zTrace);\n  }\n#endif /* SQLITE_DEBUG */\n#endif /* SQLITE_OMIT_TRACE */\n  assert( pOp->p2>0 );\n  if( pOp->p1>=sqlite3GlobalConfig.iOnceResetThreshold ){\n    for(i=1; i<p->nOp; i++){\n      if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;\n    }\n    pOp->p1 = 0;\n  }\n  pOp->p1++;\n  p->aCounter[SQLITE_STMTSTATUS_RUN]++;\n  goto jump_to_p2;\n}\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/* Opcode: CursorHint P1 * * P4 *\n**\n** Provide a hint to cursor P1 that it only needs to return rows that\n** satisfy the Expr in P4.  TK_REGISTER terms in the P4 expression refer\n** to values currently held in registers.  TK_COLUMN terms in the P4\n** expression refer to columns in the b-tree to which cursor P1 is pointing.\n*/\ncase OP_CursorHint: {\n  VdbeCursor *pC;\n\n  assert( pOp->p1>=0 && pOp->p1<p->nCursor );\n  assert( pOp->p4type==P4_EXPR );\n  pC = p->apCsr[pOp->p1];\n  if( pC ){\n    assert( pC->eCurType==CURTYPE_BTREE );\n    sqlite3BtreeCursorHint(pC->uc.pCursor, BTREE_HINT_RANGE,\n                           pOp->p4.pExpr, aMem);\n  }\n  break;\n}\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n/* Opcode: Noop * * * * *\n**\n** Do nothing.  This instruction is often useful as a jump\n** destination.\n*/\n/*\n** The magic Explain opcode are only inserted when explain==2 (which\n** is to say when the EXPLAIN QUERY PLAN syntax is used.)\n** This opcode records information from the optimizer.  It is the\n** the same as a no-op.  This opcodesnever appears in a real VM program.\n*/\ndefault: {          /* This is really OP_Noop and OP_Explain */\n  assert( pOp->opcode==OP_Noop || pOp->opcode==OP_Explain );\n  break;\n}\n\n/*****************************************************************************\n** The cases of the switch statement above this line should all be indented\n** by 6 spaces.  But the left-most 6 spaces have been removed to improve the\n** readability.  From this point on down, the normal indentation rules are\n** restored.\n*****************************************************************************/\n    }\n\n#ifdef VDBE_PROFILE\n    {\n      u64 endTime = sqlite3Hwtime();\n      if( endTime>start ) pOrigOp->cycles += endTime - start;\n      pOrigOp->cnt++;\n    }\n#endif\n\n    /* The following code adds nothing to the actual functionality\n    ** of the program.  It is only here for testing and debugging.\n    ** On the other hand, it does burn CPU cycles every time through\n    ** the evaluator loop.  So we can leave it out when NDEBUG is defined.\n    */\n#ifndef NDEBUG\n    assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] );\n\n#ifdef SQLITE_DEBUG\n    if( db->flags & SQLITE_VdbeTrace ){\n      u8 opProperty = sqlite3OpcodeProperty[pOrigOp->opcode];\n      if( rc!=0 ) printf(\"rc=%d\\n\",rc);\n      if( opProperty & (OPFLG_OUT2) ){\n        registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);\n      }\n      if( opProperty & OPFLG_OUT3 ){\n        registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);\n      }\n    }\n#endif  /* SQLITE_DEBUG */\n#endif  /* NDEBUG */\n  }  /* The end of the for(;;) loop the loops through opcodes */\n\n  /* If we reach this point, it means that execution is finished with\n  ** an error of some kind.\n  */\nabort_due_to_error:\n  if( db->mallocFailed ) rc = SQLITE_NOMEM_BKPT;\n  assert( rc );\n  if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){\n    sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  }\n  p->rc = rc;\n  sqlite3SystemError(db, rc);\n  testcase( sqlite3GlobalConfig.xLog!=0 );\n  sqlite3_log(rc, \"statement aborts at %d: [%s] %s\", \n                   (int)(pOp - aOp), p->zSql, p->zErrMsg);\n  sqlite3VdbeHalt(p);\n  if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db);\n  rc = SQLITE_ERROR;\n  if( resetSchemaOnFault>0 ){\n    sqlite3ResetOneSchema(db, resetSchemaOnFault-1);\n  }\n\n  /* This is the only way out of this procedure.  We have to\n  ** release the mutexes on btrees that were acquired at the\n  ** top. */\nvdbe_return:\n  testcase( nVmStep>0 );\n  p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep;\n  sqlite3VdbeLeave(p);\n  assert( rc!=SQLITE_OK || nExtraDelete==0 \n       || sqlite3_strlike(\"DELETE%\",p->zSql,0)!=0 \n  );\n  return rc;\n\n  /* Jump to here if a string or blob larger than SQLITE_MAX_LENGTH\n  ** is encountered.\n  */\ntoo_big:\n  sqlite3VdbeError(p, \"string or blob too big\");\n  rc = SQLITE_TOOBIG;\n  goto abort_due_to_error;\n\n  /* Jump to here if a malloc() fails.\n  */\nno_mem:\n  sqlite3OomFault(db);\n  sqlite3VdbeError(p, \"out of memory\");\n  rc = SQLITE_NOMEM_BKPT;\n  goto abort_due_to_error;\n\n  /* Jump to here if the sqlite3_interrupt() API sets the interrupt\n  ** flag.\n  */\nabort_due_to_interrupt:\n  assert( db->u1.isInterrupted );\n  rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n  p->rc = rc;\n  sqlite3VdbeError(p, \"%s\", sqlite3ErrStr(rc));\n  goto abort_due_to_error;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbe.h",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** Header file for the Virtual DataBase Engine (VDBE)\n**\n** This header defines the interface to the virtual database engine\n** or VDBE.  The VDBE implements an abstract machine that runs a\n** simple program to access and modify the underlying database.\n*/\n#ifndef SQLITE_VDBE_H\n#define SQLITE_VDBE_H\n#include <stdio.h>\n\n/*\n** A single VDBE is an opaque structure named \"Vdbe\".  Only routines\n** in the source file sqliteVdbe.c are allowed to see the insides\n** of this structure.\n*/\ntypedef struct Vdbe Vdbe;\n\n/*\n** The names of the following types declared in vdbeInt.h are required\n** for the VdbeOp definition.\n*/\ntypedef struct sqlite3_value Mem;\ntypedef struct SubProgram SubProgram;\n\n/*\n** A single instruction of the virtual machine has an opcode\n** and as many as three operands.  The instruction is recorded\n** as an instance of the following structure:\n*/\nstruct VdbeOp {\n  u8 opcode;          /* What operation to perform */\n  signed char p4type; /* One of the P4_xxx constants for p4 */\n  u16 p5;             /* Fifth parameter is an unsigned 16-bit integer */\n  int p1;             /* First operand */\n  int p2;             /* Second parameter (often the jump destination) */\n  int p3;             /* The third parameter */\n  union p4union {     /* fourth parameter */\n    int i;                 /* Integer value if p4type==P4_INT32 */\n    void *p;               /* Generic pointer */\n    char *z;               /* Pointer to data for string (char array) types */\n    i64 *pI64;             /* Used when p4type is P4_INT64 */\n    double *pReal;         /* Used when p4type is P4_REAL */\n    FuncDef *pFunc;        /* Used when p4type is P4_FUNCDEF */\n    sqlite3_context *pCtx; /* Used when p4type is P4_FUNCCTX */\n    CollSeq *pColl;        /* Used when p4type is P4_COLLSEQ */\n    Mem *pMem;             /* Used when p4type is P4_MEM */\n    VTable *pVtab;         /* Used when p4type is P4_VTAB */\n    KeyInfo *pKeyInfo;     /* Used when p4type is P4_KEYINFO */\n    int *ai;               /* Used when p4type is P4_INTARRAY */\n    SubProgram *pProgram;  /* Used when p4type is P4_SUBPROGRAM */\n    Table *pTab;           /* Used when p4type is P4_TABLE */\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    Expr *pExpr;           /* Used when p4type is P4_EXPR */\n#endif\n    int (*xAdvance)(BtCursor *, int);\n  } p4;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  char *zComment;          /* Comment to improve readability */\n#endif\n#ifdef VDBE_PROFILE\n  u32 cnt;                 /* Number of times this instruction was executed */\n  u64 cycles;              /* Total time spent executing this instruction */\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  int iSrcLine;            /* Source-code line that generated this opcode */\n#endif\n};\ntypedef struct VdbeOp VdbeOp;\n\n\n/*\n** A sub-routine used to implement a trigger program.\n*/\nstruct SubProgram {\n  VdbeOp *aOp;                  /* Array of opcodes for sub-program */\n  int nOp;                      /* Elements in aOp[] */\n  int nMem;                     /* Number of memory cells required */\n  int nCsr;                     /* Number of cursors required */\n  u8 *aOnce;                    /* Array of OP_Once flags */\n  void *token;                  /* id that may be used to recursive triggers */\n  SubProgram *pNext;            /* Next sub-program already visited */\n};\n\n/*\n** A smaller version of VdbeOp used for the VdbeAddOpList() function because\n** it takes up less space.\n*/\nstruct VdbeOpList {\n  u8 opcode;          /* What operation to perform */\n  signed char p1;     /* First operand */\n  signed char p2;     /* Second parameter (often the jump destination) */\n  signed char p3;     /* Third parameter */\n};\ntypedef struct VdbeOpList VdbeOpList;\n\n/*\n** Allowed values of VdbeOp.p4type\n*/\n#define P4_NOTUSED      0   /* The P4 parameter is not used */\n#define P4_TRANSIENT    0   /* P4 is a pointer to a transient string */\n#define P4_STATIC     (-1)  /* Pointer to a static string */\n#define P4_COLLSEQ    (-2)  /* P4 is a pointer to a CollSeq structure */\n#define P4_INT32      (-3)  /* P4 is a 32-bit signed integer */\n#define P4_SUBPROGRAM (-4)  /* P4 is a pointer to a SubProgram structure */\n#define P4_ADVANCE    (-5)  /* P4 is a pointer to BtreeNext() or BtreePrev() */\n#define P4_TABLE      (-6)  /* P4 is a pointer to a Table structure */\n/* Above do not own any resources.  Must free those below */\n#define P4_FREE_IF_LE (-7)\n#define P4_DYNAMIC    (-7)  /* Pointer to memory from sqliteMalloc() */\n#define P4_FUNCDEF    (-8)  /* P4 is a pointer to a FuncDef structure */\n#define P4_KEYINFO    (-9)  /* P4 is a pointer to a KeyInfo structure */\n#define P4_EXPR       (-10) /* P4 is a pointer to an Expr tree */\n#define P4_MEM        (-11) /* P4 is a pointer to a Mem*    structure */\n#define P4_VTAB       (-12) /* P4 is a pointer to an sqlite3_vtab structure */\n#define P4_REAL       (-13) /* P4 is a 64-bit floating point value */\n#define P4_INT64      (-14) /* P4 is a 64-bit signed integer */\n#define P4_INTARRAY   (-15) /* P4 is a vector of 32-bit integers */\n#define P4_FUNCCTX    (-16) /* P4 is a pointer to an sqlite3_context object */\n\n/* Error message codes for OP_Halt */\n#define P5_ConstraintNotNull 1\n#define P5_ConstraintUnique  2\n#define P5_ConstraintCheck   3\n#define P5_ConstraintFK      4\n\n/*\n** The Vdbe.aColName array contains 5n Mem structures, where n is the \n** number of columns of data returned by the statement.\n*/\n#define COLNAME_NAME     0\n#define COLNAME_DECLTYPE 1\n#define COLNAME_DATABASE 2\n#define COLNAME_TABLE    3\n#define COLNAME_COLUMN   4\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n# define COLNAME_N        5      /* Number of COLNAME_xxx symbols */\n#else\n# ifdef SQLITE_OMIT_DECLTYPE\n#   define COLNAME_N      1      /* Store only the name */\n# else\n#   define COLNAME_N      2      /* Store the name and decltype */\n# endif\n#endif\n\n/*\n** The following macro converts a relative address in the p2 field\n** of a VdbeOp structure into a negative number so that \n** sqlite3VdbeAddOpList() knows that the address is relative.  Calling\n** the macro again restores the address.\n*/\n#define ADDR(X)  (-1-(X))\n\n/*\n** The makefile scans the vdbe.c source file and creates the \"opcodes.h\"\n** header file that defines a number for each opcode used by the VDBE.\n*/\n#include \"opcodes.h\"\n\n/*\n** Additional non-public SQLITE_PREPARE_* flags\n*/\n#define SQLITE_PREPARE_SAVESQL  0x80  /* Preserve SQL text */\n#define SQLITE_PREPARE_MASK     0x0f  /* Mask of public flags */\n\n/*\n** Prototypes for the VDBE interface.  See comments on the implementation\n** for a description of what each of these routines does.\n*/\nVdbe *sqlite3VdbeCreate(Parse*);\nint sqlite3VdbeAddOp0(Vdbe*,int);\nint sqlite3VdbeAddOp1(Vdbe*,int,int);\nint sqlite3VdbeAddOp2(Vdbe*,int,int,int);\nint sqlite3VdbeGoto(Vdbe*,int);\nint sqlite3VdbeLoadString(Vdbe*,int,const char*);\nvoid sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...);\nint sqlite3VdbeAddOp3(Vdbe*,int,int,int,int);\nint sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int);\nint sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int);\nint sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int);\nvoid sqlite3VdbeEndCoroutine(Vdbe*,int);\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\n  void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N);\n  void sqlite3VdbeVerifyNoResultRow(Vdbe *p);\n#else\n# define sqlite3VdbeVerifyNoMallocRequired(A,B)\n# define sqlite3VdbeVerifyNoResultRow(A)\n#endif\nVdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno);\nvoid sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);\nvoid sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);\nvoid sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);\nvoid sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);\nvoid sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);\nvoid sqlite3VdbeChangeP5(Vdbe*, u16 P5);\nvoid sqlite3VdbeJumpHere(Vdbe*, int addr);\nint sqlite3VdbeChangeToNoop(Vdbe*, int addr);\nint sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);\nvoid sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N);\nvoid sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);\nvoid sqlite3VdbeSetP4KeyInfo(Parse*, Index*);\nvoid sqlite3VdbeUsesBtree(Vdbe*, int);\nVdbeOp *sqlite3VdbeGetOp(Vdbe*, int);\nint sqlite3VdbeMakeLabel(Vdbe*);\nvoid sqlite3VdbeRunOnlyOnce(Vdbe*);\nvoid sqlite3VdbeReusable(Vdbe*);\nvoid sqlite3VdbeDelete(Vdbe*);\nvoid sqlite3VdbeClearObject(sqlite3*,Vdbe*);\nvoid sqlite3VdbeMakeReady(Vdbe*,Parse*);\nint sqlite3VdbeFinalize(Vdbe*);\nvoid sqlite3VdbeResolveLabel(Vdbe*, int);\nint sqlite3VdbeCurrentAddr(Vdbe*);\n#ifdef SQLITE_DEBUG\n  int sqlite3VdbeAssertMayAbort(Vdbe *, int);\n#endif\nvoid sqlite3VdbeResetStepResult(Vdbe*);\nvoid sqlite3VdbeRewind(Vdbe*);\nint sqlite3VdbeReset(Vdbe*);\nvoid sqlite3VdbeSetNumCols(Vdbe*,int);\nint sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*));\nvoid sqlite3VdbeCountChanges(Vdbe*);\nsqlite3 *sqlite3VdbeDb(Vdbe*);\nu8 sqlite3VdbePrepareFlags(Vdbe*);\nvoid sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);\nvoid sqlite3VdbeSwap(Vdbe*,Vdbe*);\nVdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);\nsqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);\nvoid sqlite3VdbeSetVarmask(Vdbe*, int);\n#ifndef SQLITE_OMIT_TRACE\n  char *sqlite3VdbeExpandSql(Vdbe*, const char*);\n#endif\nint sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);\n\nvoid sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);\nint sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);\nint sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);\nUnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*);\n\ntypedef int (*RecordCompare)(int,const void*,UnpackedRecord*);\nRecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);\n\n#ifndef SQLITE_OMIT_TRIGGER\nvoid sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);\n#endif\n\nint sqlite3NotPureFunc(sqlite3_context*);\n\n/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on\n** each VDBE opcode.\n**\n** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op\n** comments in VDBE programs that show key decision points in the code\n** generator.\n*/\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  void sqlite3VdbeComment(Vdbe*, const char*, ...);\n# define VdbeComment(X)  sqlite3VdbeComment X\n  void sqlite3VdbeNoopComment(Vdbe*, const char*, ...);\n# define VdbeNoopComment(X)  sqlite3VdbeNoopComment X\n# ifdef SQLITE_ENABLE_MODULE_COMMENTS\n#   define VdbeModuleComment(X)  sqlite3VdbeNoopComment X\n# else\n#   define VdbeModuleComment(X)\n# endif\n#else\n# define VdbeComment(X)\n# define VdbeNoopComment(X)\n# define VdbeModuleComment(X)\n#endif\n\n/*\n** The VdbeCoverage macros are used to set a coverage testing point\n** for VDBE branch instructions.  The coverage testing points are line\n** numbers in the sqlite3.c source file.  VDBE branch coverage testing\n** only works with an amalagmation build.  That's ok since a VDBE branch\n** coverage build designed for testing the test suite only.  No application\n** should ever ship with VDBE branch coverage measuring turned on.\n**\n**    VdbeCoverage(v)                  // Mark the previously coded instruction\n**                                     // as a branch\n**\n**    VdbeCoverageIf(v, conditional)   // Mark previous if conditional true\n**\n**    VdbeCoverageAlwaysTaken(v)       // Previous branch is always taken\n**\n**    VdbeCoverageNeverTaken(v)        // Previous branch is never taken\n**\n** Every VDBE branch operation must be tagged with one of the macros above.\n** If not, then when \"make test\" is run with -DSQLITE_VDBE_COVERAGE and\n** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()\n** routine in vdbe.c, alerting the developer to the missed tag.\n*/\n#ifdef SQLITE_VDBE_COVERAGE\n  void sqlite3VdbeSetLineNumber(Vdbe*,int);\n# define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)\n# define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);\n# define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);\n# define VDBE_OFFSET_LINENO(x) (__LINE__+x)\n#else\n# define VdbeCoverage(v)\n# define VdbeCoverageIf(v,x)\n# define VdbeCoverageAlwaysTaken(v)\n# define VdbeCoverageNeverTaken(v)\n# define VDBE_OFFSET_LINENO(x) 0\n#endif\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nvoid sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);\n#else\n# define sqlite3VdbeScanStatus(a,b,c,d,e)\n#endif\n\n#endif /* SQLITE_VDBE_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbeInt.h",
    "content": "/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This is the header file for information that is private to the\n** VDBE.  This information used to all be at the top of the single\n** source code file \"vdbe.c\".  When that file became too big (over\n** 6000 lines long) it was split up into several smaller files and\n** this header information was factored out.\n*/\n#ifndef SQLITE_VDBEINT_H\n#define SQLITE_VDBEINT_H\n\n/*\n** The maximum number of times that a statement will try to reparse\n** itself before giving up and returning SQLITE_SCHEMA.\n*/\n#ifndef SQLITE_MAX_SCHEMA_RETRY\n# define SQLITE_MAX_SCHEMA_RETRY 50\n#endif\n\n/*\n** VDBE_DISPLAY_P4 is true or false depending on whether or not the\n** \"explain\" P4 display logic is enabled.\n*/\n#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \\\n     || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n# define VDBE_DISPLAY_P4 1\n#else\n# define VDBE_DISPLAY_P4 0\n#endif\n\n/*\n** SQL is translated into a sequence of instructions to be\n** executed by a virtual machine.  Each instruction is an instance\n** of the following structure.\n*/\ntypedef struct VdbeOp Op;\n\n/*\n** Boolean values\n*/\ntypedef unsigned Bool;\n\n/* Opaque type used by code in vdbesort.c */\ntypedef struct VdbeSorter VdbeSorter;\n\n/* Elements of the linked list at Vdbe.pAuxData */\ntypedef struct AuxData AuxData;\n\n/* Types of VDBE cursors */\n#define CURTYPE_BTREE       0\n#define CURTYPE_SORTER      1\n#define CURTYPE_VTAB        2\n#define CURTYPE_PSEUDO      3\n\n/*\n** A VdbeCursor is an superclass (a wrapper) for various cursor objects:\n**\n**      * A b-tree cursor\n**          -  In the main database or in an ephemeral database\n**          -  On either an index or a table\n**      * A sorter\n**      * A virtual table\n**      * A one-row \"pseudotable\" stored in a single register\n*/\ntypedef struct VdbeCursor VdbeCursor;\nstruct VdbeCursor {\n  u8 eCurType;            /* One of the CURTYPE_* values above */\n  i8 iDb;                 /* Index of cursor database in db->aDb[] (or -1) */\n  u8 nullRow;             /* True if pointing to a row with no data */\n  u8 deferredMoveto;      /* A call to sqlite3BtreeMoveto() is needed */\n  u8 isTable;             /* True for rowid tables.  False for indexes */\n#ifdef SQLITE_DEBUG\n  u8 seekOp;              /* Most recent seek operation on this cursor */\n  u8 wrFlag;              /* The wrFlag argument to sqlite3BtreeCursor() */\n#endif\n  Bool isEphemeral:1;     /* True for an ephemeral table */\n  Bool useRandomRowid:1;  /* Generate new record numbers semi-randomly */\n  Bool isOrdered:1;       /* True if the table is not BTREE_UNORDERED */\n  Btree *pBtx;            /* Separate file holding temporary table */\n  i64 seqCount;           /* Sequence counter */\n  int *aAltMap;           /* Mapping from table to index column numbers */\n\n  /* Cached OP_Column parse information is only valid if cacheStatus matches\n  ** Vdbe.cacheCtr.  Vdbe.cacheCtr will never take on the value of\n  ** CACHE_STALE (0) and so setting cacheStatus=CACHE_STALE guarantees that\n  ** the cache is out of date. */\n  u32 cacheStatus;        /* Cache is valid if this matches Vdbe.cacheCtr */\n  int seekResult;         /* Result of previous sqlite3BtreeMoveto() or 0\n                          ** if there have been no prior seeks on the cursor. */\n  /* seekResult does not distinguish between \"no seeks have ever occurred\n  ** on this cursor\" and \"the most recent seek was an exact match\".\n  ** For CURTYPE_PSEUDO, seekResult is the register holding the record */\n\n  /* When a new VdbeCursor is allocated, only the fields above are zeroed.\n  ** The fields that follow are uninitialized, and must be individually\n  ** initialized prior to first use. */\n  VdbeCursor *pAltCursor; /* Associated index cursor from which to read */\n  union {\n    BtCursor *pCursor;          /* CURTYPE_BTREE or _PSEUDO.  Btree cursor */\n    sqlite3_vtab_cursor *pVCur; /* CURTYPE_VTAB.              Vtab cursor */\n    VdbeSorter *pSorter;        /* CURTYPE_SORTER.            Sorter object */\n  } uc;\n  KeyInfo *pKeyInfo;      /* Info about index keys needed by index cursors */\n  u32 iHdrOffset;         /* Offset to next unparsed byte of the header */\n  Pgno pgnoRoot;          /* Root page of the open btree cursor */\n  i16 nField;             /* Number of fields in the header */\n  u16 nHdrParsed;         /* Number of header fields parsed so far */\n  i64 movetoTarget;       /* Argument to the deferred sqlite3BtreeMoveto() */\n  u32 *aOffset;           /* Pointer to aType[nField] */\n  const u8 *aRow;         /* Data for the current row, if all on one page */\n  u32 payloadSize;        /* Total number of bytes in the record */\n  u32 szRow;              /* Byte available in aRow */\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n  u64 maskUsed;           /* Mask of columns used by this cursor */\n#endif\n\n  /* 2*nField extra array elements allocated for aType[], beyond the one\n  ** static element declared in the structure.  nField total array slots for\n  ** aType[] and nField+1 array slots for aOffset[] */\n  u32 aType[1];           /* Type values record decode.  MUST BE LAST */\n};\n\n\n/*\n** A value for VdbeCursor.cacheStatus that means the cache is always invalid.\n*/\n#define CACHE_STALE 0\n\n/*\n** When a sub-program is executed (OP_Program), a structure of this type\n** is allocated to store the current value of the program counter, as\n** well as the current memory cell array and various other frame specific\n** values stored in the Vdbe struct. When the sub-program is finished, \n** these values are copied back to the Vdbe from the VdbeFrame structure,\n** restoring the state of the VM to as it was before the sub-program\n** began executing.\n**\n** The memory for a VdbeFrame object is allocated and managed by a memory\n** cell in the parent (calling) frame. When the memory cell is deleted or\n** overwritten, the VdbeFrame object is not freed immediately. Instead, it\n** is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame\n** list is deleted when the VM is reset in VdbeHalt(). The reason for doing\n** this instead of deleting the VdbeFrame immediately is to avoid recursive\n** calls to sqlite3VdbeMemRelease() when the memory cells belonging to the\n** child frame are released.\n**\n** The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is\n** set to NULL if the currently executing frame is the main program.\n*/\ntypedef struct VdbeFrame VdbeFrame;\nstruct VdbeFrame {\n  Vdbe *v;                /* VM this frame belongs to */\n  VdbeFrame *pParent;     /* Parent of this frame, or NULL if parent is main */\n  Op *aOp;                /* Program instructions for parent frame */\n  i64 *anExec;            /* Event counters from parent frame */\n  Mem *aMem;              /* Array of memory cells for parent frame */\n  VdbeCursor **apCsr;     /* Array of Vdbe cursors for parent frame */\n  u8 *aOnce;              /* Bitmask used by OP_Once */\n  void *token;            /* Copy of SubProgram.token */\n  i64 lastRowid;          /* Last insert rowid (sqlite3.lastRowid) */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n  int nCursor;            /* Number of entries in apCsr */\n  int pc;                 /* Program Counter in parent (calling) frame */\n  int nOp;                /* Size of aOp array */\n  int nMem;               /* Number of entries in aMem */\n  int nChildMem;          /* Number of memory cells for child frame */\n  int nChildCsr;          /* Number of cursors for child frame */\n  int nChange;            /* Statement changes (Vdbe.nChange)     */\n  int nDbChange;          /* Value of db->nChange */\n};\n\n#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])\n\n/*\n** Internally, the vdbe manipulates nearly all SQL values as Mem\n** structures. Each Mem struct may cache multiple representations (string,\n** integer etc.) of the same value.\n*/\nstruct sqlite3_value {\n  union MemValue {\n    double r;           /* Real value used when MEM_Real is set in flags */\n    i64 i;              /* Integer value used when MEM_Int is set in flags */\n    int nZero;          /* Extra zero bytes when MEM_Zero and MEM_Blob set */\n    const char *zPType; /* Pointer type when MEM_Term|MEM_Subtype|MEM_Null */\n    FuncDef *pDef;      /* Used only when flags==MEM_Agg */\n    RowSet *pRowSet;    /* Used only when flags==MEM_RowSet */\n    VdbeFrame *pFrame;  /* Used when flags==MEM_Frame */\n  } u;\n  u16 flags;          /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */\n  u8  enc;            /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */\n  u8  eSubtype;       /* Subtype for this value */\n  int n;              /* Number of characters in string value, excluding '\\0' */\n  char *z;            /* String or BLOB value */\n  /* ShallowCopy only needs to copy the information above */\n  char *zMalloc;      /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */\n  int szMalloc;       /* Size of the zMalloc allocation */\n  u32 uTemp;          /* Transient storage for serial_type in OP_MakeRecord */\n  sqlite3 *db;        /* The associated database connection */\n  void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */\n#ifdef SQLITE_DEBUG\n  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */\n  void *pFiller;      /* So that sizeof(Mem) is a multiple of 8 */\n#endif\n};\n\n/*\n** Size of struct Mem not including the Mem.zMalloc member or anything that\n** follows.\n*/\n#define MEMCELLSIZE offsetof(Mem,zMalloc)\n\n/* One or more of the following flags are set to indicate the validOK\n** representations of the value stored in the Mem struct.\n**\n** If the MEM_Null flag is set, then the value is an SQL NULL value.\n** For a pointer type created using sqlite3_bind_pointer() or\n** sqlite3_result_pointer() the MEM_Term and MEM_Subtype flags are also set.\n**\n** If the MEM_Str flag is set then Mem.z points at a string representation.\n** Usually this is encoded in the same unicode encoding as the main\n** database (see below for exceptions). If the MEM_Term flag is also\n** set, then the string is nul terminated. The MEM_Int and MEM_Real \n** flags may coexist with the MEM_Str flag.\n*/\n#define MEM_Null      0x0001   /* Value is NULL (or a pointer) */\n#define MEM_Str       0x0002   /* Value is a string */\n#define MEM_Int       0x0004   /* Value is an integer */\n#define MEM_Real      0x0008   /* Value is a real number */\n#define MEM_Blob      0x0010   /* Value is a BLOB */\n#define MEM_AffMask   0x001f   /* Mask of affinity bits */\n#define MEM_RowSet    0x0020   /* Value is a RowSet object */\n#define MEM_Frame     0x0040   /* Value is a VdbeFrame object */\n#define MEM_Undefined 0x0080   /* Value is undefined */\n#define MEM_Cleared   0x0100   /* NULL set by OP_Null, not from data */\n#define MEM_TypeMask  0xc1ff   /* Mask of type bits */\n\n\n/* Whenever Mem contains a valid string or blob representation, one of\n** the following flags must be set to determine the memory management\n** policy for Mem.z.  The MEM_Term flag tells us whether or not the\n** string is \\000 or \\u0000 terminated\n*/\n#define MEM_Term      0x0200   /* String in Mem.z is zero terminated */\n#define MEM_Dyn       0x0400   /* Need to call Mem.xDel() on Mem.z */\n#define MEM_Static    0x0800   /* Mem.z points to a static string */\n#define MEM_Ephem     0x1000   /* Mem.z points to an ephemeral string */\n#define MEM_Agg       0x2000   /* Mem.z points to an agg function context */\n#define MEM_Zero      0x4000   /* Mem.i contains count of 0s appended to blob */\n#define MEM_Subtype   0x8000   /* Mem.eSubtype is valid */\n#ifdef SQLITE_OMIT_INCRBLOB\n  #undef MEM_Zero\n  #define MEM_Zero 0x0000\n#endif\n\n/* Return TRUE if Mem X contains dynamically allocated content - anything\n** that needs to be deallocated to avoid a leak.\n*/\n#define VdbeMemDynamic(X)  \\\n  (((X)->flags&(MEM_Agg|MEM_Dyn|MEM_RowSet|MEM_Frame))!=0)\n\n/*\n** Clear any existing type flags from a Mem and replace them with f\n*/\n#define MemSetTypeFlag(p, f) \\\n   ((p)->flags = ((p)->flags&~(MEM_TypeMask|MEM_Zero))|f)\n\n/*\n** Return true if a memory cell is not marked as invalid.  This macro\n** is for use inside assert() statements only.\n*/\n#ifdef SQLITE_DEBUG\n#define memIsValid(M)  ((M)->flags & MEM_Undefined)==0\n#endif\n\n/*\n** Each auxiliary data pointer stored by a user defined function \n** implementation calling sqlite3_set_auxdata() is stored in an instance\n** of this structure. All such structures associated with a single VM\n** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed\n** when the VM is halted (if not before).\n*/\nstruct AuxData {\n  int iAuxOp;                     /* Instruction number of OP_Function opcode */\n  int iAuxArg;                    /* Index of function argument. */\n  void *pAux;                     /* Aux data pointer */\n  void (*xDeleteAux)(void*);      /* Destructor for the aux data */\n  AuxData *pNextAux;              /* Next element in list */\n};\n\n/*\n** The \"context\" argument for an installable function.  A pointer to an\n** instance of this structure is the first argument to the routines used\n** implement the SQL functions.\n**\n** There is a typedef for this structure in sqlite.h.  So all routines,\n** even the public interface to SQLite, can use a pointer to this structure.\n** But this file is the only place where the internal details of this\n** structure are known.\n**\n** This structure is defined inside of vdbeInt.h because it uses substructures\n** (Mem) which are only defined there.\n*/\nstruct sqlite3_context {\n  Mem *pOut;              /* The return value is stored here */\n  FuncDef *pFunc;         /* Pointer to function information */\n  Mem *pMem;              /* Memory cell used to store aggregate context */\n  Vdbe *pVdbe;            /* The VM that owns this context */\n  int iOp;                /* Instruction number of OP_Function */\n  int isError;            /* Error code returned by the function. */\n  u8 skipFlag;            /* Skip accumulator loading if true */\n  u8 fErrorOrAux;         /* isError!=0 or pVdbe->pAuxData modified */\n  u8 argc;                /* Number of arguments */\n  sqlite3_value *argv[1]; /* Argument set */\n};\n\n/* A bitfield type for use inside of structures.  Always follow with :N where\n** N is the number of bits.\n*/\ntypedef unsigned bft;  /* Bit Field Type */\n\ntypedef struct ScanStatus ScanStatus;\nstruct ScanStatus {\n  int addrExplain;                /* OP_Explain for loop */\n  int addrLoop;                   /* Address of \"loops\" counter */\n  int addrVisit;                  /* Address of \"rows visited\" counter */\n  int iSelectID;                  /* The \"Select-ID\" for this loop */\n  LogEst nEst;                    /* Estimated output rows per loop */\n  char *zName;                    /* Name of table or index */\n};\n\n/*\n** An instance of the virtual machine.  This structure contains the complete\n** state of the virtual machine.\n**\n** The \"sqlite3_stmt\" structure pointer that is returned by sqlite3_prepare()\n** is really a pointer to an instance of this structure.\n*/\nstruct Vdbe {\n  sqlite3 *db;            /* The database connection that owns this statement */\n  Vdbe *pPrev,*pNext;     /* Linked list of VDBEs with the same Vdbe.db */\n  Parse *pParse;          /* Parsing context used to create this Vdbe */\n  ynVar nVar;             /* Number of entries in aVar[] */\n  u32 magic;              /* Magic number for sanity checking */\n  int nMem;               /* Number of memory locations currently allocated */\n  int nCursor;            /* Number of slots in apCsr[] */\n  u32 cacheCtr;           /* VdbeCursor row cache generation counter */\n  int pc;                 /* The program counter */\n  int rc;                 /* Value to return */\n  int nChange;            /* Number of db changes made since last reset */\n  int iStatement;         /* Statement number (or 0 if has not opened stmt) */\n  i64 iCurrentTime;       /* Value of julianday('now') for this statement */\n  i64 nFkConstraint;      /* Number of imm. FK constraints this VM */\n  i64 nStmtDefCons;       /* Number of def. constraints when stmt started */\n  i64 nStmtDefImmCons;    /* Number of def. imm constraints when stmt started */\n\n  /* When allocating a new Vdbe object, all of the fields below should be\n  ** initialized to zero or NULL */\n\n  Op *aOp;                /* Space to hold the virtual machine's program */\n  Mem *aMem;              /* The memory locations */\n  Mem **apArg;            /* Arguments to currently executing user function */\n  Mem *aColName;          /* Column names to return */\n  Mem *pResultSet;        /* Pointer to an array of results */\n  char *zErrMsg;          /* Error message written here */\n  VdbeCursor **apCsr;     /* One element of this array for each open cursor */\n  Mem *aVar;              /* Values for the OP_Variable opcode. */\n  VList *pVList;          /* Name of variables */\n#ifndef SQLITE_OMIT_TRACE\n  i64 startTime;          /* Time when query started - used for profiling */\n#endif\n  int nOp;                /* Number of instructions in the program */\n#ifdef SQLITE_DEBUG\n  int rcApp;              /* errcode set by sqlite3_result_error_code() */\n#endif\n  u16 nResColumn;         /* Number of columns in one row of the result set */\n  u8 errorAction;         /* Recovery action to do in case of an error */\n  u8 minWriteFileFormat;  /* Minimum file format for writable database files */\n  u8 prepFlags;           /* SQLITE_PREPARE_* flags */\n  bft expired:1;          /* True if the VM needs to be recompiled */\n  bft doingRerun:1;       /* True if rerunning after an auto-reprepare */\n  bft explain:2;          /* True if EXPLAIN present on SQL command */\n  bft changeCntOn:1;      /* True to update the change-counter */\n  bft runOnlyOnce:1;      /* Automatically expire on reset */\n  bft usesStmtJournal:1;  /* True if uses a statement journal */\n  bft readOnly:1;         /* True for statements that do not write */\n  bft bIsReader:1;        /* True for statements that read */\n  yDbMask btreeMask;      /* Bitmask of db->aDb[] entries referenced */\n  yDbMask lockMask;       /* Subset of btreeMask that requires a lock */\n  u32 aCounter[7];        /* Counters used by sqlite3_stmt_status() */\n  char *zSql;             /* Text of the SQL statement that generated this */\n  void *pFree;            /* Free this when deleting the vdbe */\n  VdbeFrame *pFrame;      /* Parent frame */\n  VdbeFrame *pDelFrame;   /* List of frame objects to free on VM reset */\n  int nFrame;             /* Number of frames in pFrame list */\n  u32 expmask;            /* Binding to these vars invalidates VM */\n  SubProgram *pProgram;   /* Linked list of all sub-programs used by VM */\n  AuxData *pAuxData;      /* Linked list of auxdata allocations */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  i64 *anExec;            /* Number of times each op has been executed */\n  int nScan;              /* Entries in aScan[] */\n  ScanStatus *aScan;      /* Scan definitions for sqlite3_stmt_scanstatus() */\n#endif\n};\n\n/*\n** The following are allowed values for Vdbe.magic\n*/\n#define VDBE_MAGIC_INIT     0x16bceaa5    /* Building a VDBE program */\n#define VDBE_MAGIC_RUN      0x2df20da3    /* VDBE is ready to execute */\n#define VDBE_MAGIC_HALT     0x319c2973    /* VDBE has completed execution */\n#define VDBE_MAGIC_RESET    0x48fa9f76    /* Reset and ready to run again */\n#define VDBE_MAGIC_DEAD     0x5606c3c8    /* The VDBE has been deallocated */\n\n/*\n** Structure used to store the context required by the \n** sqlite3_preupdate_*() API functions.\n*/\nstruct PreUpdate {\n  Vdbe *v;\n  VdbeCursor *pCsr;               /* Cursor to read old values from */\n  int op;                         /* One of SQLITE_INSERT, UPDATE, DELETE */\n  u8 *aRecord;                    /* old.* database record */\n  KeyInfo keyinfo;\n  UnpackedRecord *pUnpacked;      /* Unpacked version of aRecord[] */\n  UnpackedRecord *pNewUnpacked;   /* Unpacked version of new.* record */\n  int iNewReg;                    /* Register for new.* values */\n  i64 iKey1;                      /* First key value passed to hook */\n  i64 iKey2;                      /* Second key value passed to hook */\n  Mem *aNew;                      /* Array of new.* values */\n  Table *pTab;                    /* Schema object being upated */          \n  Index *pPk;                     /* PK index if pTab is WITHOUT ROWID */\n};\n\n/*\n** Function prototypes\n*/\nvoid sqlite3VdbeError(Vdbe*, const char *, ...);\nvoid sqlite3VdbeFreeCursor(Vdbe *, VdbeCursor*);\nvoid sqliteVdbePopStack(Vdbe*,int);\nint sqlite3VdbeCursorMoveto(VdbeCursor**, int*);\nint sqlite3VdbeCursorRestore(VdbeCursor*);\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\nvoid sqlite3VdbePrintOp(FILE*, int, Op*);\n#endif\nu32 sqlite3VdbeSerialTypeLen(u32);\nu8 sqlite3VdbeOneByteSerialTypeLen(u8);\nu32 sqlite3VdbeSerialType(Mem*, int, u32*);\nu32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);\nu32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);\nvoid sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);\n\nint sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);\nint sqlite3VdbeIdxKeyCompare(sqlite3*,VdbeCursor*,UnpackedRecord*,int*);\nint sqlite3VdbeIdxRowid(sqlite3*, BtCursor*, i64*);\nint sqlite3VdbeExec(Vdbe*);\nint sqlite3VdbeList(Vdbe*);\nint sqlite3VdbeHalt(Vdbe*);\nint sqlite3VdbeChangeEncoding(Mem *, int);\nint sqlite3VdbeMemTooBig(Mem*);\nint sqlite3VdbeMemCopy(Mem*, const Mem*);\nvoid sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);\nvoid sqlite3VdbeMemMove(Mem*, Mem*);\nint sqlite3VdbeMemNulTerminate(Mem*);\nint sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));\nvoid sqlite3VdbeMemSetInt64(Mem*, i64);\n#ifdef SQLITE_OMIT_FLOATING_POINT\n# define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64\n#else\n  void sqlite3VdbeMemSetDouble(Mem*, double);\n#endif\nvoid sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*));\nvoid sqlite3VdbeMemInit(Mem*,sqlite3*,u16);\nvoid sqlite3VdbeMemSetNull(Mem*);\nvoid sqlite3VdbeMemSetZeroBlob(Mem*,int);\nvoid sqlite3VdbeMemSetRowSet(Mem*);\nint sqlite3VdbeMemMakeWriteable(Mem*);\nint sqlite3VdbeMemStringify(Mem*, u8, u8);\ni64 sqlite3VdbeIntValue(Mem*);\nint sqlite3VdbeMemIntegerify(Mem*);\ndouble sqlite3VdbeRealValue(Mem*);\nvoid sqlite3VdbeIntegerAffinity(Mem*);\nint sqlite3VdbeMemRealify(Mem*);\nint sqlite3VdbeMemNumerify(Mem*);\nvoid sqlite3VdbeMemCast(Mem*,u8,u8);\nint sqlite3VdbeMemFromBtree(BtCursor*,u32,u32,Mem*);\nvoid sqlite3VdbeMemRelease(Mem *p);\nint sqlite3VdbeMemFinalize(Mem*, FuncDef*);\nconst char *sqlite3OpcodeName(int);\nint sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);\nint sqlite3VdbeMemClearAndResize(Mem *pMem, int n);\nint sqlite3VdbeCloseStatement(Vdbe *, int);\nvoid sqlite3VdbeFrameDelete(VdbeFrame*);\nint sqlite3VdbeFrameRestore(VdbeFrame *);\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\nvoid sqlite3VdbePreUpdateHook(Vdbe*,VdbeCursor*,int,const char*,Table*,i64,int);\n#endif\nint sqlite3VdbeTransferError(Vdbe *p);\n\nint sqlite3VdbeSorterInit(sqlite3 *, int, VdbeCursor *);\nvoid sqlite3VdbeSorterReset(sqlite3 *, VdbeSorter *);\nvoid sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *);\nint sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *);\nint sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *);\nint sqlite3VdbeSorterRewind(const VdbeCursor *, int *);\nint sqlite3VdbeSorterWrite(const VdbeCursor *, Mem *);\nint sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *);\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) \n  void sqlite3VdbeEnter(Vdbe*);\n#else\n# define sqlite3VdbeEnter(X)\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n  void sqlite3VdbeLeave(Vdbe*);\n#else\n# define sqlite3VdbeLeave(X)\n#endif\n\n#ifdef SQLITE_DEBUG\nvoid sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);\nint sqlite3VdbeCheckMemInvariants(Mem*);\n#endif\n\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nint sqlite3VdbeCheckFk(Vdbe *, int);\n#else\n# define sqlite3VdbeCheckFk(p,i) 0\n#endif\n\n#ifdef SQLITE_DEBUG\n  void sqlite3VdbePrintSql(Vdbe*);\n  void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf);\n#endif\n#ifndef SQLITE_OMIT_UTF16\n  int sqlite3VdbeMemTranslate(Mem*, u8);\n  int sqlite3VdbeMemHandleBom(Mem *pMem);\n#endif\n\n#ifndef SQLITE_OMIT_INCRBLOB\n  int sqlite3VdbeMemExpandBlob(Mem *);\n  #define ExpandBlob(P) (((P)->flags&MEM_Zero)?sqlite3VdbeMemExpandBlob(P):0)\n#else\n  #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK\n  #define ExpandBlob(P) SQLITE_OK\n#endif\n\n#endif /* !defined(SQLITE_VDBEINT_H) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbeapi.c",
    "content": "/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to implement APIs that are part of the\n** VDBE.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return TRUE (non-zero) of the statement supplied as an argument needs\n** to be recompiled.  A statement needs to be recompiled whenever the\n** execution environment changes in a way that would alter the program\n** that sqlite3_prepare() generates.  For example, if new functions or\n** collating sequences are registered or if an authorizer function is\n** added or changed.\n*/\nint sqlite3_expired(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p==0 || p->expired;\n}\n#endif\n\n/*\n** Check on a Vdbe to make sure it has not been finalized.  Log\n** an error and return true if it has been finalized (or is otherwise\n** invalid).  Return false if it is ok.\n*/\nstatic int vdbeSafety(Vdbe *p){\n  if( p->db==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with finalized prepared statement\");\n    return 1;\n  }else{\n    return 0;\n  }\n}\nstatic int vdbeSafetyNotNull(Vdbe *p){\n  if( p==0 ){\n    sqlite3_log(SQLITE_MISUSE, \"API called with NULL prepared statement\");\n    return 1;\n  }else{\n    return vdbeSafety(p);\n  }\n}\n\n#ifndef SQLITE_OMIT_TRACE\n/*\n** Invoke the profile callback.  This routine is only called if we already\n** know that the profile callback is defined and needs to be invoked.\n*/\nstatic SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){\n  sqlite3_int64 iNow;\n  sqlite3_int64 iElapse;\n  assert( p->startTime>0 );\n  assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );\n  assert( db->init.busy==0 );\n  assert( p->zSql!=0 );\n  sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);\n  iElapse = (iNow - p->startTime)*1000000;\n  if( db->xProfile ){\n    db->xProfile(db->pProfileArg, p->zSql, iElapse);\n  }\n  if( db->mTrace & SQLITE_TRACE_PROFILE ){\n    db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);\n  }\n  p->startTime = 0;\n}\n/*\n** The checkProfileCallback(DB,P) macro checks to see if a profile callback\n** is needed, and it invokes the callback if it is needed.\n*/\n# define checkProfileCallback(DB,P) \\\n   if( ((P)->startTime)>0 ){ invokeProfileCallback(DB,P); }\n#else\n# define checkProfileCallback(DB,P)  /*no-op*/\n#endif\n\n/*\n** The following routine destroys a virtual machine that is created by\n** the sqlite3_compile() routine. The integer returned is an SQLITE_\n** success/failure code that describes the result of executing the virtual\n** machine.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nint sqlite3_finalize(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL\n    ** pointer is a harmless no-op. */\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeFinalize(v);\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3LeaveMutexAndCloseZombie(db);\n  }\n  return rc;\n}\n\n/*\n** Terminate the current execution of an SQL statement and reset it\n** back to its starting state so that it can be reused. A success code from\n** the prior execution is returned.\n**\n** This routine sets the error code and string returned by\n** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().\n*/\nint sqlite3_reset(sqlite3_stmt *pStmt){\n  int rc;\n  if( pStmt==0 ){\n    rc = SQLITE_OK;\n  }else{\n    Vdbe *v = (Vdbe*)pStmt;\n    sqlite3 *db = v->db;\n    sqlite3_mutex_enter(db->mutex);\n    checkProfileCallback(db, v);\n    rc = sqlite3VdbeReset(v);\n    sqlite3VdbeRewind(v);\n    assert( (rc & (db->errMask))==rc );\n    rc = sqlite3ApiExit(db, rc);\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return rc;\n}\n\n/*\n** Set all the parameters in the compiled SQL statement to NULL.\n*/\nint sqlite3_clear_bindings(sqlite3_stmt *pStmt){\n  int i;\n  int rc = SQLITE_OK;\n  Vdbe *p = (Vdbe*)pStmt;\n#if SQLITE_THREADSAFE\n  sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;\n#endif\n  sqlite3_mutex_enter(mutex);\n  for(i=0; i<p->nVar; i++){\n    sqlite3VdbeMemRelease(&p->aVar[i]);\n    p->aVar[i].flags = MEM_Null;\n  }\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask ){\n    p->expired = 1;\n  }\n  sqlite3_mutex_leave(mutex);\n  return rc;\n}\n\n\n/**************************** sqlite3_value_  *******************************\n** The following routines extract information from a Mem or sqlite3_value\n** structure.\n*/\nconst void *sqlite3_value_blob(sqlite3_value *pVal){\n  Mem *p = (Mem*)pVal;\n  if( p->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(p)!=SQLITE_OK ){\n      assert( p->flags==MEM_Null && p->z==0 );\n      return 0;\n    }\n    p->flags |= MEM_Blob;\n    return p->n ? p->z : 0;\n  }else{\n    return sqlite3_value_text(pVal);\n  }\n}\nint sqlite3_value_bytes(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF8);\n}\nint sqlite3_value_bytes16(sqlite3_value *pVal){\n  return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);\n}\ndouble sqlite3_value_double(sqlite3_value *pVal){\n  return sqlite3VdbeRealValue((Mem*)pVal);\n}\nint sqlite3_value_int(sqlite3_value *pVal){\n  return (int)sqlite3VdbeIntValue((Mem*)pVal);\n}\nsqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){\n  return sqlite3VdbeIntValue((Mem*)pVal);\n}\nunsigned int sqlite3_value_subtype(sqlite3_value *pVal){\n  Mem *pMem = (Mem*)pVal;\n  return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);\n}\nvoid *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){\n  Mem *p = (Mem*)pVal;\n  if( (p->flags&(MEM_TypeMask|MEM_Term|MEM_Subtype)) ==\n                 (MEM_Null|MEM_Term|MEM_Subtype)\n   && zPType!=0\n   && p->eSubtype=='p'\n   && strcmp(p->u.zPType, zPType)==0\n  ){\n    return (void*)p->z;\n  }else{\n    return 0;\n  }\n}\nconst unsigned char *sqlite3_value_text(sqlite3_value *pVal){\n  return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_value_text16(sqlite3_value* pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);\n}\nconst void *sqlite3_value_text16be(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16BE);\n}\nconst void *sqlite3_value_text16le(sqlite3_value *pVal){\n  return sqlite3ValueText(pVal, SQLITE_UTF16LE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five\n** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating\n** point number string BLOB NULL\n*/\nint sqlite3_value_type(sqlite3_value* pVal){\n  static const u8 aType[] = {\n     SQLITE_BLOB,     /* 0x00 */\n     SQLITE_NULL,     /* 0x01 */\n     SQLITE_TEXT,     /* 0x02 */\n     SQLITE_NULL,     /* 0x03 */\n     SQLITE_INTEGER,  /* 0x04 */\n     SQLITE_NULL,     /* 0x05 */\n     SQLITE_INTEGER,  /* 0x06 */\n     SQLITE_NULL,     /* 0x07 */\n     SQLITE_FLOAT,    /* 0x08 */\n     SQLITE_NULL,     /* 0x09 */\n     SQLITE_FLOAT,    /* 0x0a */\n     SQLITE_NULL,     /* 0x0b */\n     SQLITE_INTEGER,  /* 0x0c */\n     SQLITE_NULL,     /* 0x0d */\n     SQLITE_INTEGER,  /* 0x0e */\n     SQLITE_NULL,     /* 0x0f */\n     SQLITE_BLOB,     /* 0x10 */\n     SQLITE_NULL,     /* 0x11 */\n     SQLITE_TEXT,     /* 0x12 */\n     SQLITE_NULL,     /* 0x13 */\n     SQLITE_INTEGER,  /* 0x14 */\n     SQLITE_NULL,     /* 0x15 */\n     SQLITE_INTEGER,  /* 0x16 */\n     SQLITE_NULL,     /* 0x17 */\n     SQLITE_FLOAT,    /* 0x18 */\n     SQLITE_NULL,     /* 0x19 */\n     SQLITE_FLOAT,    /* 0x1a */\n     SQLITE_NULL,     /* 0x1b */\n     SQLITE_INTEGER,  /* 0x1c */\n     SQLITE_NULL,     /* 0x1d */\n     SQLITE_INTEGER,  /* 0x1e */\n     SQLITE_NULL,     /* 0x1f */\n  };\n  return aType[pVal->flags&MEM_AffMask];\n}\n\n/* Make a copy of an sqlite3_value object\n*/\nsqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){\n  sqlite3_value *pNew;\n  if( pOrig==0 ) return 0;\n  pNew = sqlite3_malloc( sizeof(*pNew) );\n  if( pNew==0 ) return 0;\n  memset(pNew, 0, sizeof(*pNew));\n  memcpy(pNew, pOrig, MEMCELLSIZE);\n  pNew->flags &= ~MEM_Dyn;\n  pNew->db = 0;\n  if( pNew->flags&(MEM_Str|MEM_Blob) ){\n    pNew->flags &= ~(MEM_Static|MEM_Dyn);\n    pNew->flags |= MEM_Ephem;\n    if( sqlite3VdbeMemMakeWriteable(pNew)!=SQLITE_OK ){\n      sqlite3ValueFree(pNew);\n      pNew = 0;\n    }\n  }\n  return pNew;\n}\n\n/* Destroy an sqlite3_value object previously obtained from\n** sqlite3_value_dup().\n*/\nvoid sqlite3_value_free(sqlite3_value *pOld){\n  sqlite3ValueFree(pOld);\n}\n  \n\n/**************************** sqlite3_result_  *******************************\n** The following routines are used by user-defined functions to specify\n** the function result.\n**\n** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the\n** result as a string or blob but if the string or blob is too large, it\n** then sets the error code to SQLITE_TOOBIG\n**\n** The invokeValueDestructor(P,X) routine invokes destructor function X()\n** on value P is not going to be used and need to be destroyed.\n*/\nstatic void setResultStrOrError(\n  sqlite3_context *pCtx,  /* Function context */\n  const char *z,          /* String pointer */\n  int n,                  /* Bytes in string, or negative */\n  u8 enc,                 /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*)     /* Destructor function */\n){\n  if( sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel)==SQLITE_TOOBIG ){\n    sqlite3_result_error_toobig(pCtx);\n  }\n}\nstatic int invokeValueDestructor(\n  const void *p,             /* Value to destroy */\n  void (*xDel)(void*),       /* The destructor */\n  sqlite3_context *pCtx      /* Set a SQLITE_TOOBIG error if no NULL */\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( xDel==0 ){\n    /* noop */\n  }else if( xDel==SQLITE_TRANSIENT ){\n    /* noop */\n  }else{\n    xDel((void*)p);\n  }\n  if( pCtx ) sqlite3_result_error_toobig(pCtx);\n  return SQLITE_TOOBIG;\n}\nvoid sqlite3_result_blob(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( n>=0 );\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, 0, xDel);\n}\nvoid sqlite3_result_blob64(\n  sqlite3_context *pCtx, \n  const void *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, 0, xDel);\n  }\n}\nvoid sqlite3_result_double(sqlite3_context *pCtx, double rVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);\n}\nvoid sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);\n}\n#ifndef SQLITE_OMIT_UTF16\nvoid sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_ERROR;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);\n}\n#endif\nvoid sqlite3_result_int(sqlite3_context *pCtx, int iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);\n}\nvoid sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);\n}\nvoid sqlite3_result_null(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n}\nvoid sqlite3_result_pointer(\n  sqlite3_context *pCtx,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  sqlite3VdbeMemRelease(pOut);\n  pOut->flags = MEM_Null;\n  sqlite3VdbeMemSetPointer(pOut, pPtr, zPType, xDestructor);\n}\nvoid sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  pOut->eSubtype = eSubtype & 0xff;\n  pOut->flags |= MEM_Subtype;\n}\nvoid sqlite3_result_text(\n  sqlite3_context *pCtx, \n  const char *z, \n  int n,\n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);\n}\nvoid sqlite3_result_text64(\n  sqlite3_context *pCtx, \n  const char *z, \n  sqlite3_uint64 n,\n  void (*xDel)(void *),\n  unsigned char enc\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n  if( n>0x7fffffff ){\n    (void)invokeValueDestructor(z, xDel, pCtx);\n  }else{\n    setResultStrOrError(pCtx, z, (int)n, enc, xDel);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nvoid sqlite3_result_text16(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);\n}\nvoid sqlite3_result_text16be(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);\n}\nvoid sqlite3_result_text16le(\n  sqlite3_context *pCtx, \n  const void *z, \n  int n, \n  void (*xDel)(void *)\n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nvoid sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemCopy(pCtx->pOut, pValue);\n}\nvoid sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);\n}\nint sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){\n  Mem *pOut = pCtx->pOut;\n  assert( sqlite3_mutex_held(pOut->db->mutex) );\n  if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    return SQLITE_TOOBIG;\n  }\n  sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n);\n  return SQLITE_OK;\n}\nvoid sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){\n  pCtx->isError = errCode;\n  pCtx->fErrorOrAux = 1;\n#ifdef SQLITE_DEBUG\n  if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;\n#endif\n  if( pCtx->pOut->flags & MEM_Null ){\n    sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1, \n                         SQLITE_UTF8, SQLITE_STATIC);\n  }\n}\n\n/* Force an SQLITE_TOOBIG error. */\nvoid sqlite3_result_error_toobig(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  pCtx->isError = SQLITE_TOOBIG;\n  pCtx->fErrorOrAux = 1;\n  sqlite3VdbeMemSetStr(pCtx->pOut, \"string or blob too big\", -1, \n                       SQLITE_UTF8, SQLITE_STATIC);\n}\n\n/* An SQLITE_NOMEM error. */\nvoid sqlite3_result_error_nomem(sqlite3_context *pCtx){\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n  sqlite3VdbeMemSetNull(pCtx->pOut);\n  pCtx->isError = SQLITE_NOMEM_BKPT;\n  pCtx->fErrorOrAux = 1;\n  sqlite3OomFault(pCtx->pOut->db);\n}\n\n/*\n** This function is called after a transaction has been committed. It \n** invokes callbacks registered with sqlite3_wal_hook() as required.\n*/\nstatic int doWalCallbacks(sqlite3 *db){\n  int rc = SQLITE_OK;\n#ifndef SQLITE_OMIT_WAL\n  int i;\n  for(i=0; i<db->nDb; i++){\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      int nEntry;\n      sqlite3BtreeEnter(pBt);\n      nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));\n      sqlite3BtreeLeave(pBt);\n      if( nEntry>0 && db->xWalCallback && rc==SQLITE_OK ){\n        rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zDbSName, nEntry);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n\n/*\n** Execute the statement pStmt, either until a row of data is ready, the\n** statement is completely executed or an error occurs.\n**\n** This routine implements the bulk of the logic behind the sqlite_step()\n** API.  The only thing omitted is the automatic recompile if a \n** schema change has occurred.  That detail is handled by the\n** outer sqlite3_step() wrapper procedure.\n*/\nstatic int sqlite3Step(Vdbe *p){\n  sqlite3 *db;\n  int rc;\n\n  assert(p);\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    /* We used to require that sqlite3_reset() be called before retrying\n    ** sqlite3_step() after any error or after SQLITE_DONE.  But beginning\n    ** with version 3.7.0, we changed this so that sqlite3_reset() would\n    ** be called automatically instead of throwing the SQLITE_MISUSE error.\n    ** This \"automatic-reset\" change is not technically an incompatibility, \n    ** since any application that receives an SQLITE_MISUSE is broken by\n    ** definition.\n    **\n    ** Nevertheless, some published applications that were originally written\n    ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE \n    ** returns, and those were broken by the automatic-reset change.  As a\n    ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the\n    ** legacy behavior of returning SQLITE_MISUSE for cases where the \n    ** previous sqlite3_step() returned something other than a SQLITE_LOCKED\n    ** or SQLITE_BUSY error.\n    */\n#ifdef SQLITE_OMIT_AUTORESET\n    if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){\n      sqlite3_reset((sqlite3_stmt*)p);\n    }else{\n      return SQLITE_MISUSE_BKPT;\n    }\n#else\n    sqlite3_reset((sqlite3_stmt*)p);\n#endif\n  }\n\n  /* Check that malloc() has not failed. If it has, return early. */\n  db = p->db;\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  if( p->pc<=0 && p->expired ){\n    p->rc = SQLITE_SCHEMA;\n    rc = SQLITE_ERROR;\n    goto end_of_step;\n  }\n  if( p->pc<0 ){\n    /* If there are no other statements currently running, then\n    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt\n    ** from interrupting a statement that has not yet started.\n    */\n    if( db->nVdbeActive==0 ){\n      db->u1.isInterrupted = 0;\n    }\n\n    assert( db->nVdbeWrite>0 || db->autoCommit==0 \n        || (db->nDeferredCons==0 && db->nDeferredImmCons==0)\n    );\n\n#ifndef SQLITE_OMIT_TRACE\n    if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)\n        && !db->init.busy && p->zSql ){\n      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);\n    }else{\n      assert( p->startTime==0 );\n    }\n#endif\n\n    db->nVdbeActive++;\n    if( p->readOnly==0 ) db->nVdbeWrite++;\n    if( p->bIsReader ) db->nVdbeRead++;\n    p->pc = 0;\n  }\n#ifdef SQLITE_DEBUG\n  p->rcApp = SQLITE_OK;\n#endif\n#ifndef SQLITE_OMIT_EXPLAIN\n  if( p->explain ){\n    rc = sqlite3VdbeList(p);\n  }else\n#endif /* SQLITE_OMIT_EXPLAIN */\n  {\n    db->nVdbeExec++;\n    rc = sqlite3VdbeExec(p);\n    db->nVdbeExec--;\n  }\n\n#ifndef SQLITE_OMIT_TRACE\n  /* If the statement completed successfully, invoke the profile callback */\n  if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);\n#endif\n\n  if( rc==SQLITE_DONE && db->autoCommit ){\n    assert( p->rc==SQLITE_OK );\n    p->rc = doWalCallbacks(db);\n    if( p->rc!=SQLITE_OK ){\n      rc = SQLITE_ERROR;\n    }\n  }\n\n  db->errCode = rc;\n  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\nend_of_step:\n  /* At this point local variable rc holds the value that should be \n  ** returned if this statement was compiled using the legacy \n  ** sqlite3_prepare() interface. According to the docs, this can only\n  ** be one of the values in the first assert() below. Variable p->rc \n  ** contains the value that would be returned if sqlite3_finalize() \n  ** were called on statement p.\n  */\n  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR \n       || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE\n  );\n  assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );\n  if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 \n   && rc!=SQLITE_ROW \n   && rc!=SQLITE_DONE \n  ){\n    /* If this statement was prepared using saved SQL and an \n    ** error has occurred, then return the error code in p->rc to the\n    ** caller. Set the error code in the database handle to the same value.\n    */ \n    rc = sqlite3VdbeTransferError(p);\n  }\n  return (rc&db->errMask);\n}\n\n/*\n** This is the top-level implementation of sqlite3_step().  Call\n** sqlite3Step() to do most of the work.  If a schema error occurs,\n** call sqlite3Reprepare() and try again.\n*/\nint sqlite3_step(sqlite3_stmt *pStmt){\n  int rc = SQLITE_OK;      /* Result from sqlite3Step() */\n  Vdbe *v = (Vdbe*)pStmt;  /* the prepared statement */\n  int cnt = 0;             /* Counter to prevent infinite loop of reprepares */\n  sqlite3 *db;             /* The database connection */\n\n  if( vdbeSafetyNotNull(v) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  db = v->db;\n  sqlite3_mutex_enter(db->mutex);\n  v->doingRerun = 0;\n  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA\n         && cnt++ < SQLITE_MAX_SCHEMA_RETRY ){\n    int savedPc = v->pc;\n    rc = sqlite3Reprepare(v);\n    if( rc!=SQLITE_OK ){\n      /* This case occurs after failing to recompile an sql statement. \n      ** The error message from the SQL compiler has already been loaded \n      ** into the database handle. This block copies the error message \n      ** from the database handle into the statement and sets the statement\n      ** program counter to 0 to ensure that when the statement is \n      ** finalized or reset the parser error message is available via\n      ** sqlite3_errmsg() and sqlite3_errcode().\n      */\n      const char *zErr = (const char *)sqlite3_value_text(db->pErr); \n      sqlite3DbFree(db, v->zErrMsg);\n      if( !db->mallocFailed ){\n        v->zErrMsg = sqlite3DbStrDup(db, zErr);\n        v->rc = rc = sqlite3ApiExit(db, rc);\n      } else {\n        v->zErrMsg = 0;\n        v->rc = rc = SQLITE_NOMEM_BKPT;\n      }\n      break;\n    }\n    sqlite3_reset(pStmt);\n    if( savedPc>=0 ) v->doingRerun = 1;\n    assert( v->expired==0 );\n  }\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n*/\nvoid *sqlite3_user_data(sqlite3_context *p){\n  assert( p && p->pFunc );\n  return p->pFunc->pUserData;\n}\n\n/*\n** Extract the user data from a sqlite3_context structure and return a\n** pointer to it.\n**\n** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface\n** returns a copy of the pointer to the database connection (the 1st\n** parameter) of the sqlite3_create_function() and\n** sqlite3_create_function16() routines that originally registered the\n** application defined function.\n*/\nsqlite3 *sqlite3_context_db_handle(sqlite3_context *p){\n  assert( p && p->pOut );\n  return p->pOut->db;\n}\n\n/*\n** Return the current time for a statement.  If the current time\n** is requested more than once within the same run of a single prepared\n** statement, the exact same time is returned for each invocation regardless\n** of the amount of time that elapses between invocations.  In other words,\n** the time returned is always the time of the first call.\n*/\nsqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){\n  int rc;\n#ifndef SQLITE_ENABLE_STAT3_OR_STAT4\n  sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;\n  assert( p->pVdbe!=0 );\n#else\n  sqlite3_int64 iTime = 0;\n  sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;\n#endif\n  if( *piTime==0 ){\n    rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);\n    if( rc ) *piTime = 0;\n  }\n  return *piTime;\n}\n\n/*\n** The following is the implementation of an SQL function that always\n** fails with an error message stating that the function is used in the\n** wrong context.  The sqlite3_overload_function() API might construct\n** SQL function that use this routine so that the functions will exist\n** for name resolution but are actually overloaded by the xFindFunction\n** method of virtual tables.\n*/\nvoid sqlite3InvalidFunction(\n  sqlite3_context *context,  /* The function calling context */\n  int NotUsed,               /* Number of arguments to the function */\n  sqlite3_value **NotUsed2   /* Value of each argument */\n){\n  const char *zName = context->pFunc->zName;\n  char *zErr;\n  UNUSED_PARAMETER2(NotUsed, NotUsed2);\n  zErr = sqlite3_mprintf(\n      \"unable to use function %s in the requested context\", zName);\n  sqlite3_result_error(context, zErr, -1);\n  sqlite3_free(zErr);\n}\n\n/*\n** Create a new aggregate context for p and return a pointer to\n** its pMem->z element.\n*/\nstatic SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){\n  Mem *pMem = p->pMem;\n  assert( (pMem->flags & MEM_Agg)==0 );\n  if( nByte<=0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n  }else{\n    sqlite3VdbeMemClearAndResize(pMem, nByte);\n    pMem->flags = MEM_Agg;\n    pMem->u.pDef = p->pFunc;\n    if( pMem->z ){\n      memset(pMem->z, 0, nByte);\n    }\n  }\n  return (void*)pMem->z;\n}\n\n/*\n** Allocate or return the aggregate context for a user function.  A new\n** context is allocated on the first call.  Subsequent calls return the\n** same context that was returned on prior calls.\n*/\nvoid *sqlite3_aggregate_context(sqlite3_context *p, int nByte){\n  assert( p && p->pFunc && p->pFunc->xFinalize );\n  assert( sqlite3_mutex_held(p->pOut->db->mutex) );\n  testcase( nByte<0 );\n  if( (p->pMem->flags & MEM_Agg)==0 ){\n    return createAggContext(p, nByte);\n  }else{\n    return (void*)p->pMem->z;\n  }\n}\n\n/*\n** Return the auxiliary data pointer, if any, for the iArg'th argument to\n** the user-function defined by pCtx.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then access a cache of\n** auxiliary data pointers that is available to all functions within a\n** single prepared statement.  The iArg values must match.\n*/\nvoid *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){\n  AuxData *pAuxData;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#if SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 0;\n#else\n  assert( pCtx->pVdbe!=0 );\n#endif\n  for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if(  pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      return pAuxData->pAux;\n    }\n  }\n  return 0;\n}\n\n/*\n** Set the auxiliary data pointer and delete function, for the iArg'th\n** argument to the user-function defined by pCtx. Any previous value is\n** deleted by calling the delete function specified when it was set.\n**\n** The left-most argument is 0.\n**\n** Undocumented behavior:  If iArg is negative then make the data available\n** to all functions within the current prepared statement using iArg as an\n** access code.\n*/\nvoid sqlite3_set_auxdata(\n  sqlite3_context *pCtx, \n  int iArg, \n  void *pAux, \n  void (*xDelete)(void*)\n){\n  AuxData *pAuxData;\n  Vdbe *pVdbe = pCtx->pVdbe;\n\n  assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pVdbe==0 ) goto failed;\n#else\n  assert( pVdbe!=0 );\n#endif\n\n  for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNextAux){\n    if( pAuxData->iAuxArg==iArg && (pAuxData->iAuxOp==pCtx->iOp || iArg<0) ){\n      break;\n    }\n  }\n  if( pAuxData==0 ){\n    pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData));\n    if( !pAuxData ) goto failed;\n    pAuxData->iAuxOp = pCtx->iOp;\n    pAuxData->iAuxArg = iArg;\n    pAuxData->pNextAux = pVdbe->pAuxData;\n    pVdbe->pAuxData = pAuxData;\n    if( pCtx->fErrorOrAux==0 ){\n      pCtx->isError = 0;\n      pCtx->fErrorOrAux = 1;\n    }\n  }else if( pAuxData->xDeleteAux ){\n    pAuxData->xDeleteAux(pAuxData->pAux);\n  }\n\n  pAuxData->pAux = pAux;\n  pAuxData->xDeleteAux = xDelete;\n  return;\n\nfailed:\n  if( xDelete ){\n    xDelete(pAux);\n  }\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Return the number of times the Step function of an aggregate has been \n** called.\n**\n** This function is deprecated.  Do not use it for new code.  It is\n** provide only to avoid breaking legacy code.  New aggregate function\n** implementations should keep their own counts within their aggregate\n** context.\n*/\nint sqlite3_aggregate_count(sqlite3_context *p){\n  assert( p && p->pMem && p->pFunc && p->pFunc->xFinalize );\n  return p->pMem->n;\n}\n#endif\n\n/*\n** Return the number of columns in the result set for the statement pStmt.\n*/\nint sqlite3_column_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  return pVm ? pVm->nResColumn : 0;\n}\n\n/*\n** Return the number of values available from the current row of the\n** currently executing statement pStmt.\n*/\nint sqlite3_data_count(sqlite3_stmt *pStmt){\n  Vdbe *pVm = (Vdbe *)pStmt;\n  if( pVm==0 || pVm->pResultSet==0 ) return 0;\n  return pVm->nResColumn;\n}\n\n/*\n** Return a pointer to static memory containing an SQL NULL value.\n*/\nstatic const Mem *columnNullValue(void){\n  /* Even though the Mem structure contains an element\n  ** of type i64, on certain architectures (x86) with certain compiler\n  ** switches (-Os), gcc may align this Mem object on a 4-byte boundary\n  ** instead of an 8-byte one. This all works fine, except that when\n  ** running with SQLITE_DEBUG defined the SQLite code sometimes assert()s\n  ** that a Mem structure is located on an 8-byte boundary. To prevent\n  ** these assert()s from failing, when building with SQLITE_DEBUG defined\n  ** using gcc, we force nullMem to be 8-byte aligned using the magical\n  ** __attribute__((aligned(8))) macro.  */\n  static const Mem nullMem \n#if defined(SQLITE_DEBUG) && defined(__GNUC__)\n    __attribute__((aligned(8))) \n#endif\n    = {\n        /* .u          = */ {0},\n        /* .flags      = */ (u16)MEM_Null,\n        /* .enc        = */ (u8)0,\n        /* .eSubtype   = */ (u8)0,\n        /* .n          = */ (int)0,\n        /* .z          = */ (char*)0,\n        /* .zMalloc    = */ (char*)0,\n        /* .szMalloc   = */ (int)0,\n        /* .uTemp      = */ (u32)0,\n        /* .db         = */ (sqlite3*)0,\n        /* .xDel       = */ (void(*)(void*))0,\n#ifdef SQLITE_DEBUG\n        /* .pScopyFrom = */ (Mem*)0,\n        /* .pFiller    = */ (void*)0,\n#endif\n      };\n  return &nullMem;\n}\n\n/*\n** Check to see if column iCol of the given statement is valid.  If\n** it is, return a pointer to the Mem for the value of that column.\n** If iCol is not valid, return a pointer to a Mem which has a value\n** of NULL.\n*/\nstatic Mem *columnMem(sqlite3_stmt *pStmt, int i){\n  Vdbe *pVm;\n  Mem *pOut;\n\n  pVm = (Vdbe *)pStmt;\n  if( pVm==0 ) return (Mem*)columnNullValue();\n  assert( pVm->db );\n  sqlite3_mutex_enter(pVm->db->mutex);\n  if( pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){\n    pOut = &pVm->pResultSet[i];\n  }else{\n    sqlite3Error(pVm->db, SQLITE_RANGE);\n    pOut = (Mem*)columnNullValue();\n  }\n  return pOut;\n}\n\n/*\n** This function is called after invoking an sqlite3_value_XXX function on a \n** column value (i.e. a value returned by evaluating an SQL expression in the\n** select list of a SELECT statement) that may cause a malloc() failure. If \n** malloc() has failed, the threads mallocFailed flag is cleared and the result\n** code of statement pStmt set to SQLITE_NOMEM.\n**\n** Specifically, this is called from within:\n**\n**     sqlite3_column_int()\n**     sqlite3_column_int64()\n**     sqlite3_column_text()\n**     sqlite3_column_text16()\n**     sqlite3_column_real()\n**     sqlite3_column_bytes()\n**     sqlite3_column_bytes16()\n**     sqiite3_column_blob()\n*/\nstatic void columnMallocFailure(sqlite3_stmt *pStmt)\n{\n  /* If malloc() failed during an encoding conversion within an\n  ** sqlite3_column_XXX API, then set the return code of the statement to\n  ** SQLITE_NOMEM. The next call to _step() (if any) will return SQLITE_ERROR\n  ** and _finalize() will return NOMEM.\n  */\n  Vdbe *p = (Vdbe *)pStmt;\n  if( p ){\n    assert( p->db!=0 );\n    assert( sqlite3_mutex_held(p->db->mutex) );\n    p->rc = sqlite3ApiExit(p->db, p->rc);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n}\n\n/**************************** sqlite3_column_  *******************************\n** The following routines are used to access elements of the current row\n** in the result set.\n*/\nconst void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){\n  const void *val;\n  val = sqlite3_value_blob( columnMem(pStmt,i) );\n  /* Even though there is no encoding conversion, value_blob() might\n  ** need to call malloc() to expand the result of a zeroblob() \n  ** expression. \n  */\n  columnMallocFailure(pStmt);\n  return val;\n}\nint sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nint sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_bytes16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\ndouble sqlite3_column_double(sqlite3_stmt *pStmt, int i){\n  double val = sqlite3_value_double( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nint sqlite3_column_int(sqlite3_stmt *pStmt, int i){\n  int val = sqlite3_value_int( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nsqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){\n  sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nconst unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){\n  const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\nsqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){\n  Mem *pOut = columnMem(pStmt, i);\n  if( pOut->flags&MEM_Static ){\n    pOut->flags &= ~MEM_Static;\n    pOut->flags |= MEM_Ephem;\n  }\n  columnMallocFailure(pStmt);\n  return (sqlite3_value *)pOut;\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){\n  const void *val = sqlite3_value_text16( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return val;\n}\n#endif /* SQLITE_OMIT_UTF16 */\nint sqlite3_column_type(sqlite3_stmt *pStmt, int i){\n  int iType = sqlite3_value_type( columnMem(pStmt,i) );\n  columnMallocFailure(pStmt);\n  return iType;\n}\n\n/*\n** Convert the N-th element of pStmt->pColName[] into a string using\n** xFunc() then return that string.  If N is out of range, return 0.\n**\n** There are up to 5 names for each column.  useType determines which\n** name is returned.  Here are the names:\n**\n**    0      The column name as it should be displayed for output\n**    1      The datatype name for the column\n**    2      The name of the database that the column derives from\n**    3      The name of the table that the column derives from\n**    4      The name of the table column that the result column derives from\n**\n** If the result is not a simple column reference (if it is an expression\n** or a constant) then useTypes 2, 3, and 4 return NULL.\n*/\nstatic const void *columnName(\n  sqlite3_stmt *pStmt,\n  int N,\n  const void *(*xFunc)(Mem*),\n  int useType\n){\n  const void *ret;\n  Vdbe *p;\n  int n;\n  sqlite3 *db;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( pStmt==0 ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  ret = 0;\n  p = (Vdbe *)pStmt;\n  db = p->db;\n  assert( db!=0 );\n  n = sqlite3_column_count(pStmt);\n  if( N<n && N>=0 ){\n    N += useType*n;\n    sqlite3_mutex_enter(db->mutex);\n    assert( db->mallocFailed==0 );\n    ret = xFunc(&p->aColName[N]);\n     /* A malloc may have failed inside of the xFunc() call. If this\n    ** is the case, clear the mallocFailed flag and return NULL.\n    */\n    if( db->mallocFailed ){\n      sqlite3OomClear(db);\n      ret = 0;\n    }\n    sqlite3_mutex_leave(db->mutex);\n  }\n  return ret;\n}\n\n/*\n** Return the name of the Nth column of the result set returned by SQL\n** statement pStmt.\n*/\nconst char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);\n}\n#endif\n\n/*\n** Constraint:  If you have ENABLE_COLUMN_METADATA then you must\n** not define OMIT_DECLTYPE.\n*/\n#if defined(SQLITE_OMIT_DECLTYPE) && defined(SQLITE_ENABLE_COLUMN_METADATA)\n# error \"Must not define both SQLITE_OMIT_DECLTYPE \\\n         and SQLITE_ENABLE_COLUMN_METADATA\"\n#endif\n\n#ifndef SQLITE_OMIT_DECLTYPE\n/*\n** Return the column declaration type (if applicable) of the 'i'th column\n** of the result set of SQL statement pStmt.\n*/\nconst char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_OMIT_DECLTYPE */\n\n#ifdef SQLITE_ENABLE_COLUMN_METADATA\n/*\n** Return the name of the database from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nconst char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nconst char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n\n/*\n** Return the name of the table column from which a result column derives.\n** NULL is returned if the result column is an expression or constant or\n** anything else which is not an unambiguous reference to a database column.\n*/\nconst char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);\n}\n#ifndef SQLITE_OMIT_UTF16\nconst void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){\n  return columnName(\n      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);\n}\n#endif /* SQLITE_OMIT_UTF16 */\n#endif /* SQLITE_ENABLE_COLUMN_METADATA */\n\n\n/******************************* sqlite3_bind_  ***************************\n** \n** Routines used to attach values to wildcards in a compiled SQL statement.\n*/\n/*\n** Unbind the value bound to variable i in virtual machine p. This is the \n** the same as binding a NULL value to the column. If the \"i\" parameter is\n** out of range, then SQLITE_RANGE is returned. Othewise SQLITE_OK.\n**\n** A successful evaluation of this routine acquires the mutex on p.\n** the mutex is released if any kind of error occurs.\n**\n** The error code stored in database p->db is overwritten with the return\n** value in any case.\n*/\nstatic int vdbeUnbind(Vdbe *p, int i){\n  Mem *pVar;\n  if( vdbeSafetyNotNull(p) ){\n    return SQLITE_MISUSE_BKPT;\n  }\n  sqlite3_mutex_enter(p->db->mutex);\n  if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){\n    sqlite3Error(p->db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(p->db->mutex);\n    sqlite3_log(SQLITE_MISUSE, \n        \"bind on a busy prepared statement: [%s]\", p->zSql);\n    return SQLITE_MISUSE_BKPT;\n  }\n  if( i<1 || i>p->nVar ){\n    sqlite3Error(p->db, SQLITE_RANGE);\n    sqlite3_mutex_leave(p->db->mutex);\n    return SQLITE_RANGE;\n  }\n  i--;\n  pVar = &p->aVar[i];\n  sqlite3VdbeMemRelease(pVar);\n  pVar->flags = MEM_Null;\n  sqlite3Error(p->db, SQLITE_OK);\n\n  /* If the bit corresponding to this variable in Vdbe.expmask is set, then \n  ** binding a new value to this variable invalidates the current query plan.\n  **\n  ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host\n  ** parameter in the WHERE clause might influence the choice of query plan\n  ** for a statement, then the statement will be automatically recompiled,\n  ** as if there had been a schema change, on the first sqlite3_step() call\n  ** following any change to the bindings of that parameter.\n  */\n  assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || p->expmask==0 );\n  if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){\n    p->expired = 1;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Bind a text or BLOB value.\n*/\nstatic int bindText(\n  sqlite3_stmt *pStmt,   /* The statement to bind against */\n  int i,                 /* Index of the parameter to bind */\n  const void *zData,     /* Pointer to the data to be bound */\n  int nData,             /* Number of bytes of data to be bound */\n  void (*xDel)(void*),   /* Destructor for the data */\n  u8 encoding            /* Encoding for the data */\n){\n  Vdbe *p = (Vdbe *)pStmt;\n  Mem *pVar;\n  int rc;\n\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    if( zData!=0 ){\n      pVar = &p->aVar[i-1];\n      rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);\n      if( rc==SQLITE_OK && encoding!=0 ){\n        rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));\n      }\n      if( rc ){\n        sqlite3Error(p->db, rc);\n        rc = sqlite3ApiExit(p->db, rc);\n      }\n    }\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){\n    xDel((void*)zData);\n  }\n  return rc;\n}\n\n\n/*\n** Bind a blob value to an SQL statement variable.\n*/\nint sqlite3_bind_blob(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( nData<0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return bindText(pStmt, i, zData, nData, xDel, 0);\n}\nint sqlite3_bind_blob64(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*)\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    return bindText(pStmt, i, zData, (int)nData, xDel, 0);\n  }\n}\nint sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nint sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){\n  return sqlite3_bind_int64(p, i, (i64)iValue);\n}\nint sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nint sqlite3_bind_null(sqlite3_stmt *pStmt, int i){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nint sqlite3_bind_pointer(\n  sqlite3_stmt *pStmt,\n  int i,\n  void *pPtr,\n  const char *zPTtype,\n  void (*xDestructor)(void*)\n){\n  int rc;\n  Vdbe *p = (Vdbe*)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zPTtype, xDestructor);\n    sqlite3_mutex_leave(p->db->mutex);\n  }else if( xDestructor ){\n    xDestructor(pPtr);\n  }\n  return rc;\n}\nint sqlite3_bind_text( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);\n}\nint sqlite3_bind_text64( \n  sqlite3_stmt *pStmt, \n  int i, \n  const char *zData, \n  sqlite3_uint64 nData, \n  void (*xDel)(void*),\n  unsigned char enc\n){\n  assert( xDel!=SQLITE_DYNAMIC );\n  if( nData>0x7fffffff ){\n    return invokeValueDestructor(zData, xDel, 0);\n  }else{\n    if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;\n    return bindText(pStmt, i, zData, (int)nData, xDel, enc);\n  }\n}\n#ifndef SQLITE_OMIT_UTF16\nint sqlite3_bind_text16(\n  sqlite3_stmt *pStmt, \n  int i, \n  const void *zData, \n  int nData, \n  void (*xDel)(void*)\n){\n  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);\n}\n#endif /* SQLITE_OMIT_UTF16 */\nint sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){\n  int rc;\n  switch( sqlite3_value_type((sqlite3_value*)pValue) ){\n    case SQLITE_INTEGER: {\n      rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);\n      break;\n    }\n    case SQLITE_FLOAT: {\n      rc = sqlite3_bind_double(pStmt, i, pValue->u.r);\n      break;\n    }\n    case SQLITE_BLOB: {\n      if( pValue->flags & MEM_Zero ){\n        rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);\n      }else{\n        rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);\n      }\n      break;\n    }\n    case SQLITE_TEXT: {\n      rc = bindText(pStmt,i,  pValue->z, pValue->n, SQLITE_TRANSIENT,\n                              pValue->enc);\n      break;\n    }\n    default: {\n      rc = sqlite3_bind_null(pStmt, i);\n      break;\n    }\n  }\n  return rc;\n}\nint sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  rc = vdbeUnbind(p, i);\n  if( rc==SQLITE_OK ){\n    sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return rc;\n}\nint sqlite3_bind_zeroblob64(sqlite3_stmt *pStmt, int i, sqlite3_uint64 n){\n  int rc;\n  Vdbe *p = (Vdbe *)pStmt;\n  sqlite3_mutex_enter(p->db->mutex);\n  if( n>(u64)p->db->aLimit[SQLITE_LIMIT_LENGTH] ){\n    rc = SQLITE_TOOBIG;\n  }else{\n    assert( (n & 0x7FFFFFFF)==n );\n    rc = sqlite3_bind_zeroblob(pStmt, i, n);\n  }\n  rc = sqlite3ApiExit(p->db, rc);\n  sqlite3_mutex_leave(p->db->mutex);\n  return rc;\n}\n\n/*\n** Return the number of wildcards that can be potentially bound to.\n** This routine is added to support DBD::SQLite.  \n*/\nint sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  return p ? p->nVar : 0;\n}\n\n/*\n** Return the name of a wildcard parameter.  Return NULL if the index\n** is out of range or if the wildcard is unnamed.\n**\n** The result is always UTF-8.\n*/\nconst char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){\n  Vdbe *p = (Vdbe*)pStmt;\n  if( p==0 ) return 0;\n  return sqlite3VListNumToName(p->pVList, i);\n}\n\n/*\n** Given a wildcard parameter name, return the index of the variable\n** with that name.  If there is no variable with the given name,\n** return 0.\n*/\nint sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){\n  if( p==0 || zName==0 ) return 0;\n  return sqlite3VListNameToNum(p->pVList, zName, nName);\n}\nint sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){\n  return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));\n}\n\n/*\n** Transfer all bindings from the first statement over to the second.\n*/\nint sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  int i;\n  assert( pTo->db==pFrom->db );\n  assert( pTo->nVar==pFrom->nVar );\n  sqlite3_mutex_enter(pTo->db->mutex);\n  for(i=0; i<pFrom->nVar; i++){\n    sqlite3VdbeMemMove(&pTo->aVar[i], &pFrom->aVar[i]);\n  }\n  sqlite3_mutex_leave(pTo->db->mutex);\n  return SQLITE_OK;\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/*\n** Deprecated external interface.  Internal/core SQLite code\n** should call sqlite3TransferBindings.\n**\n** It is misuse to call this routine with statements from different\n** database connections.  But as this is a deprecated interface, we\n** will not bother to check for that condition.\n**\n** If the two statements contain a different number of bindings, then\n** an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise\n** SQLITE_OK is returned.\n*/\nint sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){\n  Vdbe *pFrom = (Vdbe*)pFromStmt;\n  Vdbe *pTo = (Vdbe*)pToStmt;\n  if( pFrom->nVar!=pTo->nVar ){\n    return SQLITE_ERROR;\n  }\n  assert( (pTo->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pTo->expmask==0 );\n  if( pTo->expmask ){\n    pTo->expired = 1;\n  }\n  assert( (pFrom->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 || pFrom->expmask==0 );\n  if( pFrom->expmask ){\n    pFrom->expired = 1;\n  }\n  return sqlite3TransferBindings(pFromStmt, pToStmt);\n}\n#endif\n\n/*\n** Return the sqlite3* database handle to which the prepared statement given\n** in the argument belongs.  This is the same database handle that was\n** the first argument to the sqlite3_prepare() that was used to create\n** the statement in the first place.\n*/\nsqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->db : 0;\n}\n\n/*\n** Return true if the prepared statement is guaranteed to not modify the\n** database.\n*/\nint sqlite3_stmt_readonly(sqlite3_stmt *pStmt){\n  return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;\n}\n\n/*\n** Return true if the prepared statement is in need of being reset.\n*/\nint sqlite3_stmt_busy(sqlite3_stmt *pStmt){\n  Vdbe *v = (Vdbe*)pStmt;\n  return v!=0 && v->magic==VDBE_MAGIC_RUN && v->pc>=0;\n}\n\n/*\n** Return a pointer to the next prepared statement after pStmt associated\n** with database connection pDb.  If pStmt is NULL, return the first\n** prepared statement for the database connection.  Return NULL if there\n** are no more.\n*/\nsqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){\n  sqlite3_stmt *pNext;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(pDb) ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  sqlite3_mutex_enter(pDb->mutex);\n  if( pStmt==0 ){\n    pNext = (sqlite3_stmt*)pDb->pVdbe;\n  }else{\n    pNext = (sqlite3_stmt*)((Vdbe*)pStmt)->pNext;\n  }\n  sqlite3_mutex_leave(pDb->mutex);\n  return pNext;\n}\n\n/*\n** Return the value of a status counter for a prepared statement\n*/\nint sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){\n  Vdbe *pVdbe = (Vdbe*)pStmt;\n  u32 v;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !pStmt ){\n    (void)SQLITE_MISUSE_BKPT;\n    return 0;\n  }\n#endif\n  if( op==SQLITE_STMTSTATUS_MEMUSED ){\n    sqlite3 *db = pVdbe->db;\n    sqlite3_mutex_enter(db->mutex);\n    v = 0;\n    db->pnBytesFreed = (int*)&v;\n    sqlite3VdbeClearObject(db, pVdbe);\n    sqlite3DbFree(db, pVdbe);\n    db->pnBytesFreed = 0;\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    v = pVdbe->aCounter[op];\n    if( resetFlag ) pVdbe->aCounter[op] = 0;\n  }\n  return (int)v;\n}\n\n/*\n** Return the SQL associated with a prepared statement\n*/\nconst char *sqlite3_sql(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe *)pStmt;\n  return p ? p->zSql : 0;\n}\n\n/*\n** Return the SQL associated with a prepared statement with\n** bound parameters expanded.  Space to hold the returned string is\n** obtained from sqlite3_malloc().  The caller is responsible for\n** freeing the returned string by passing it to sqlite3_free().\n**\n** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of\n** expanded bound parameters.\n*/\nchar *sqlite3_expanded_sql(sqlite3_stmt *pStmt){\n#ifdef SQLITE_OMIT_TRACE\n  return 0;\n#else\n  char *z = 0;\n  const char *zSql = sqlite3_sql(pStmt);\n  if( zSql ){\n    Vdbe *p = (Vdbe *)pStmt;\n    sqlite3_mutex_enter(p->db->mutex);\n    z = sqlite3VdbeExpandSql(p, zSql);\n    sqlite3_mutex_leave(p->db->mutex);\n  }\n  return z;\n#endif\n}\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Allocate and populate an UnpackedRecord structure based on the serialized\n** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure\n** if successful, or a NULL pointer if an OOM error is encountered.\n*/\nstatic UnpackedRecord *vdbeUnpackRecord(\n  KeyInfo *pKeyInfo, \n  int nKey, \n  const void *pKey\n){\n  UnpackedRecord *pRet;           /* Return value */\n\n  pRet = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n  if( pRet ){\n    memset(pRet->aMem, 0, sizeof(Mem)*(pKeyInfo->nKeyField+1));\n    sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, pRet);\n  }\n  return pRet;\n}\n\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or deleted.\n*/\nint sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  Mem *pMem;\n  int rc = SQLITE_OK;\n\n  /* Test that this call is being made from within an SQLITE_DELETE or\n  ** SQLITE_UPDATE pre-update callback, and that iIdx is within range. */\n  if( !p || p->op==SQLITE_INSERT ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_old_out;\n  }\n  if( p->pPk ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_old_out;\n  }\n\n  /* If the old.* record has not yet been loaded into memory, do so now. */\n  if( p->pUnpacked==0 ){\n    u32 nRec;\n    u8 *aRec;\n\n    nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);\n    aRec = sqlite3DbMallocRaw(db, nRec);\n    if( !aRec ) goto preupdate_old_out;\n    rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);\n    if( rc==SQLITE_OK ){\n      p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);\n      if( !p->pUnpacked ) rc = SQLITE_NOMEM;\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, aRec);\n      goto preupdate_old_out;\n    }\n    p->aRecord = aRec;\n  }\n\n  pMem = *ppValue = &p->pUnpacked->aMem[iIdx];\n  if( iIdx==p->pTab->iPKey ){\n    sqlite3VdbeMemSetInt64(pMem, p->iKey1);\n  }else if( iIdx>=p->pUnpacked->nField ){\n    *ppValue = (sqlite3_value *)columnNullValue();\n  }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){\n    if( pMem->flags & MEM_Int ){\n      sqlite3VdbeMemRealify(pMem);\n    }\n  }\n\n preupdate_old_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** the number of columns in the row being updated, deleted or inserted.\n*/\nint sqlite3_preupdate_count(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->keyinfo.nKeyField : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is designed to be called from within a pre-update callback\n** only. It returns zero if the change that caused the callback was made\n** immediately by a user SQL statement. Or, if the change was made by a\n** trigger program, it returns the number of trigger programs currently\n** on the stack (1 for a top-level trigger, 2 for a trigger fired by a \n** top-level trigger etc.).\n**\n** For the purposes of the previous paragraph, a foreign key CASCADE, SET NULL\n** or SET DEFAULT action is considered a trigger.\n*/\nint sqlite3_preupdate_depth(sqlite3 *db){\n  PreUpdate *p = db->pPreUpdate;\n  return (p ? p->v->nFrame : 0);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** This function is called from within a pre-update callback to retrieve\n** a field of the row currently being updated or inserted.\n*/\nint sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){\n  PreUpdate *p = db->pPreUpdate;\n  int rc = SQLITE_OK;\n  Mem *pMem;\n\n  if( !p || p->op==SQLITE_DELETE ){\n    rc = SQLITE_MISUSE_BKPT;\n    goto preupdate_new_out;\n  }\n  if( p->pPk && p->op!=SQLITE_UPDATE ){\n    iIdx = sqlite3ColumnOfIndex(p->pPk, iIdx);\n  }\n  if( iIdx>=p->pCsr->nField || iIdx<0 ){\n    rc = SQLITE_RANGE;\n    goto preupdate_new_out;\n  }\n\n  if( p->op==SQLITE_INSERT ){\n    /* For an INSERT, memory cell p->iNewReg contains the serialized record\n    ** that is being inserted. Deserialize it. */\n    UnpackedRecord *pUnpack = p->pNewUnpacked;\n    if( !pUnpack ){\n      Mem *pData = &p->v->aMem[p->iNewReg];\n      rc = ExpandBlob(pData);\n      if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      pUnpack = vdbeUnpackRecord(&p->keyinfo, pData->n, pData->z);\n      if( !pUnpack ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n      p->pNewUnpacked = pUnpack;\n    }\n    pMem = &pUnpack->aMem[iIdx];\n    if( iIdx==p->pTab->iPKey ){\n      sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n    }else if( iIdx>=pUnpack->nField ){\n      pMem = (sqlite3_value *)columnNullValue();\n    }\n  }else{\n    /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required\n    ** value. Make a copy of the cell contents and return a pointer to it.\n    ** It is not safe to return a pointer to the memory cell itself as the\n    ** caller may modify the value text encoding.\n    */\n    assert( p->op==SQLITE_UPDATE );\n    if( !p->aNew ){\n      p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);\n      if( !p->aNew ){\n        rc = SQLITE_NOMEM;\n        goto preupdate_new_out;\n      }\n    }\n    assert( iIdx>=0 && iIdx<p->pCsr->nField );\n    pMem = &p->aNew[iIdx];\n    if( pMem->flags==0 ){\n      if( iIdx==p->pTab->iPKey ){\n        sqlite3VdbeMemSetInt64(pMem, p->iKey2);\n      }else{\n        rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);\n        if( rc!=SQLITE_OK ) goto preupdate_new_out;\n      }\n    }\n  }\n  *ppValue = pMem;\n\n preupdate_new_out:\n  sqlite3Error(db, rc);\n  return sqlite3ApiExit(db, rc);\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Return status data for a single loop within query pStmt.\n*/\nint sqlite3_stmt_scanstatus(\n  sqlite3_stmt *pStmt,            /* Prepared statement being queried */\n  int idx,                        /* Index of loop to report on */\n  int iScanStatusOp,              /* Which metric to return */\n  void *pOut                      /* OUT: Write the answer here */\n){\n  Vdbe *p = (Vdbe*)pStmt;\n  ScanStatus *pScan;\n  if( idx<0 || idx>=p->nScan ) return 1;\n  pScan = &p->aScan[idx];\n  switch( iScanStatusOp ){\n    case SQLITE_SCANSTAT_NLOOP: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrLoop];\n      break;\n    }\n    case SQLITE_SCANSTAT_NVISIT: {\n      *(sqlite3_int64*)pOut = p->anExec[pScan->addrVisit];\n      break;\n    }\n    case SQLITE_SCANSTAT_EST: {\n      double r = 1.0;\n      LogEst x = pScan->nEst;\n      while( x<100 ){\n        x += 10;\n        r *= 0.5;\n      }\n      *(double*)pOut = r*sqlite3LogEstToInt(x);\n      break;\n    }\n    case SQLITE_SCANSTAT_NAME: {\n      *(const char**)pOut = pScan->zName;\n      break;\n    }\n    case SQLITE_SCANSTAT_EXPLAIN: {\n      if( pScan->addrExplain ){\n        *(const char**)pOut = p->aOp[ pScan->addrExplain ].p4.z;\n      }else{\n        *(const char**)pOut = 0;\n      }\n      break;\n    }\n    case SQLITE_SCANSTAT_SELECTID: {\n      if( pScan->addrExplain ){\n        *(int*)pOut = p->aOp[ pScan->addrExplain ].p1;\n      }else{\n        *(int*)pOut = -1;\n      }\n      break;\n    }\n    default: {\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Zero all counters associated with the sqlite3_stmt_scanstatus() data.\n*/\nvoid sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){\n  Vdbe *p = (Vdbe*)pStmt;\n  memset(p->anExec, 0, p->nOp * sizeof(i64));\n}\n#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbeaux.c",
    "content": "/*\n** 2003 September 6\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used for creating, destroying, and populating\n** a VDBE (or an \"sqlite3_stmt\" as it is known to the outside world.) \n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n/*\n** Create a new virtual database engine.\n*/\nVdbe *sqlite3VdbeCreate(Parse *pParse){\n  sqlite3 *db = pParse->db;\n  Vdbe *p;\n  p = sqlite3DbMallocRawNN(db, sizeof(Vdbe) );\n  if( p==0 ) return 0;\n  memset(&p->aOp, 0, sizeof(Vdbe)-offsetof(Vdbe,aOp));\n  p->db = db;\n  if( db->pVdbe ){\n    db->pVdbe->pPrev = p;\n  }\n  p->pNext = db->pVdbe;\n  p->pPrev = 0;\n  db->pVdbe = p;\n  p->magic = VDBE_MAGIC_INIT;\n  p->pParse = pParse;\n  pParse->pVdbe = p;\n  assert( pParse->aLabel==0 );\n  assert( pParse->nLabel==0 );\n  assert( pParse->nOpAlloc==0 );\n  assert( pParse->szOpAlloc==0 );\n  sqlite3VdbeAddOp2(p, OP_Init, 0, 1);\n  return p;\n}\n\n/*\n** Change the error string stored in Vdbe.zErrMsg\n*/\nvoid sqlite3VdbeError(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  sqlite3DbFree(p->db, p->zErrMsg);\n  va_start(ap, zFormat);\n  p->zErrMsg = sqlite3VMPrintf(p->db, zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Remember the SQL string for a prepared statement.\n*/\nvoid sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){\n  if( p==0 ) return;\n  p->prepFlags = prepFlags;\n  if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){\n    p->expmask = 0;\n  }\n  assert( p->zSql==0 );\n  p->zSql = sqlite3DbStrNDup(p->db, z, n);\n}\n\n/*\n** Swap all content between two VDBE structures.\n*/\nvoid sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){\n  Vdbe tmp, *pTmp;\n  char *zTmp;\n  assert( pA->db==pB->db );\n  tmp = *pA;\n  *pA = *pB;\n  *pB = tmp;\n  pTmp = pA->pNext;\n  pA->pNext = pB->pNext;\n  pB->pNext = pTmp;\n  pTmp = pA->pPrev;\n  pA->pPrev = pB->pPrev;\n  pB->pPrev = pTmp;\n  zTmp = pA->zSql;\n  pA->zSql = pB->zSql;\n  pB->zSql = zTmp;\n  pB->expmask = pA->expmask;\n  pB->prepFlags = pA->prepFlags;\n  memcpy(pB->aCounter, pA->aCounter, sizeof(pB->aCounter));\n  pB->aCounter[SQLITE_STMTSTATUS_REPREPARE]++;\n}\n\n/*\n** Resize the Vdbe.aOp array so that it is at least nOp elements larger \n** than its current size. nOp is guaranteed to be less than or equal\n** to 1024/sizeof(Op).\n**\n** If an out-of-memory error occurs while resizing the array, return\n** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain \n** unchanged (this is so that any opcodes already allocated can be \n** correctly deallocated along with the rest of the Vdbe).\n*/\nstatic int growOpArray(Vdbe *v, int nOp){\n  VdbeOp *pNew;\n  Parse *p = v->pParse;\n\n  /* The SQLITE_TEST_REALLOC_STRESS compile-time option is designed to force\n  ** more frequent reallocs and hence provide more opportunities for \n  ** simulated OOM faults.  SQLITE_TEST_REALLOC_STRESS is generally used\n  ** during testing only.  With SQLITE_TEST_REALLOC_STRESS grow the op array\n  ** by the minimum* amount required until the size reaches 512.  Normal\n  ** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current\n  ** size of the op array or add 1KB of space, whichever is smaller. */\n#ifdef SQLITE_TEST_REALLOC_STRESS\n  int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);\n#else\n  int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));\n  UNUSED_PARAMETER(nOp);\n#endif\n\n  /* Ensure that the size of a VDBE does not grow too large */\n  if( nNew > p->db->aLimit[SQLITE_LIMIT_VDBE_OP] ){\n    sqlite3OomFault(p->db);\n    return SQLITE_NOMEM;\n  }\n\n  assert( nOp<=(1024/sizeof(Op)) );\n  assert( nNew>=(p->nOpAlloc+nOp) );\n  pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));\n  if( pNew ){\n    p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);\n    p->nOpAlloc = p->szOpAlloc/sizeof(Op);\n    v->aOp = pNew;\n  }\n  return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);\n}\n\n#ifdef SQLITE_DEBUG\n/* This routine is just a convenient place to set a breakpoint that will\n** fire after each opcode is inserted and displayed using\n** \"PRAGMA vdbe_addoptrace=on\".\n*/\nstatic void test_addop_breakpoint(void){\n  static int n = 0;\n  n++;\n}\n#endif\n\n/*\n** Add a new instruction to the list of instructions current in the\n** VDBE.  Return the address of the new instruction.\n**\n** Parameters:\n**\n**    p               Pointer to the VDBE\n**\n**    op              The opcode for this instruction\n**\n**    p1, p2, p3      Operands\n**\n** Use the sqlite3VdbeResolveLabel() function to fix an address and\n** the sqlite3VdbeChangeP4() function to change the value of the P4\n** operand.\n*/\nstatic SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  assert( p->pParse->nOpAlloc<=p->nOp );\n  if( growOpArray(p, 1) ) return 1;\n  assert( p->pParse->nOpAlloc>p->nOp );\n  return sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n}\nint sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){\n  int i;\n  VdbeOp *pOp;\n\n  i = p->nOp;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( op>=0 && op<0xff );\n  if( p->pParse->nOpAlloc<=i ){\n    return growOp3(p, op, p1, p2, p3);\n  }\n  p->nOp++;\n  pOp = &p->aOp[i];\n  pOp->opcode = (u8)op;\n  pOp->p5 = 0;\n  pOp->p1 = p1;\n  pOp->p2 = p2;\n  pOp->p3 = p3;\n  pOp->p4.p = 0;\n  pOp->p4type = P4_NOTUSED;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  pOp->zComment = 0;\n#endif\n#ifdef SQLITE_DEBUG\n  if( p->db->flags & SQLITE_VdbeAddopTrace ){\n    int jj, kk;\n    Parse *pParse = p->pParse;\n    for(jj=kk=0; jj<pParse->nColCache; jj++){\n      struct yColCache *x = pParse->aColCache + jj;\n      printf(\" r[%d]={%d:%d}\", x->iReg, x->iTable, x->iColumn);\n      kk++;\n    }\n    if( kk ) printf(\"\\n\");\n    sqlite3VdbePrintOp(0, i, &p->aOp[i]);\n    test_addop_breakpoint();\n  }\n#endif\n#ifdef VDBE_PROFILE\n  pOp->cycles = 0;\n  pOp->cnt = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n  pOp->iSrcLine = 0;\n#endif\n  return i;\n}\nint sqlite3VdbeAddOp0(Vdbe *p, int op){\n  return sqlite3VdbeAddOp3(p, op, 0, 0, 0);\n}\nint sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){\n  return sqlite3VdbeAddOp3(p, op, p1, 0, 0);\n}\nint sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){\n  return sqlite3VdbeAddOp3(p, op, p1, p2, 0);\n}\n\n/* Generate code for an unconditional jump to instruction iDest\n*/\nint sqlite3VdbeGoto(Vdbe *p, int iDest){\n  return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0);\n}\n\n/* Generate code to cause the string zStr to be loaded into\n** register iDest\n*/\nint sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){\n  return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0);\n}\n\n/*\n** Generate code that initializes multiple registers to string or integer\n** constants.  The registers begin with iDest and increase consecutively.\n** One register is initialized for each characgter in zTypes[].  For each\n** \"s\" character in zTypes[], the register is a string if the argument is\n** not NULL, or OP_Null if the value is a null pointer.  For each \"i\" character\n** in zTypes[], the register is initialized to an integer.\n**\n** If the input string does not end with \"X\" then an OP_ResultRow instruction\n** is generated for the values inserted.\n*/\nvoid sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){\n  va_list ap;\n  int i;\n  char c;\n  va_start(ap, zTypes);\n  for(i=0; (c = zTypes[i])!=0; i++){\n    if( c=='s' ){\n      const char *z = va_arg(ap, const char*);\n      sqlite3VdbeAddOp4(p, z==0 ? OP_Null : OP_String8, 0, iDest+i, 0, z, 0);\n    }else if( c=='i' ){\n      sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest+i);\n    }else{\n      goto skip_op_resultrow;\n    }\n  }\n  sqlite3VdbeAddOp2(p, OP_ResultRow, iDest, i);\nskip_op_resultrow:\n  va_end(ap);\n}\n\n/*\n** Add an opcode that includes the p4 value as a pointer.\n*/\nint sqlite3VdbeAddOp4(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const char *zP4,    /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  sqlite3VdbeChangeP4(p, addr, zP4, p4type);\n  return addr;\n}\n\n/*\n** Add an opcode that includes the p4 value with a P4_INT64 or\n** P4_REAL type.\n*/\nint sqlite3VdbeAddOp4Dup8(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  const u8 *zP4,      /* The P4 operand */\n  int p4type          /* P4 operand type */\n){\n  char *p4copy = sqlite3DbMallocRawNN(sqlite3VdbeDb(p), 8);\n  if( p4copy ) memcpy(p4copy, zP4, 8);\n  return sqlite3VdbeAddOp4(p, op, p1, p2, p3, p4copy, p4type);\n}\n\n/*\n** Add an OP_ParseSchema opcode.  This routine is broken out from\n** sqlite3VdbeAddOp4() since it needs to also needs to mark all btrees\n** as having been used.\n**\n** The zWhere string must have been obtained from sqlite3_malloc().\n** This routine will take ownership of the allocated memory.\n*/\nvoid sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){\n  int j;\n  sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC);\n  for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j);\n}\n\n/*\n** Add an opcode that includes the p4 value as an integer.\n*/\nint sqlite3VdbeAddOp4Int(\n  Vdbe *p,            /* Add the opcode to this VM */\n  int op,             /* The new opcode */\n  int p1,             /* The P1 operand */\n  int p2,             /* The P2 operand */\n  int p3,             /* The P3 operand */\n  int p4              /* The P4 operand as an integer */\n){\n  int addr = sqlite3VdbeAddOp3(p, op, p1, p2, p3);\n  if( p->db->mallocFailed==0 ){\n    VdbeOp *pOp = &p->aOp[addr];\n    pOp->p4type = P4_INT32;\n    pOp->p4.i = p4;\n  }\n  return addr;\n}\n\n/* Insert the end of a co-routine\n*/\nvoid sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){\n  sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);\n\n  /* Clear the temporary register cache, thereby ensuring that each\n  ** co-routine has its own independent set of registers, because co-routines\n  ** might expect their registers to be preserved across an OP_Yield, and\n  ** that could cause problems if two or more co-routines are using the same\n  ** temporary register.\n  */\n  v->pParse->nTempReg = 0;\n  v->pParse->nRangeReg = 0;\n}\n\n/*\n** Create a new symbolic label for an instruction that has yet to be\n** coded.  The symbolic label is really just a negative number.  The\n** label can be used as the P2 value of an operation.  Later, when\n** the label is resolved to a specific address, the VDBE will scan\n** through its operation list and change all values of P2 which match\n** the label into the resolved address.\n**\n** The VDBE knows that a P2 value is a label because labels are\n** always negative and P2 values are suppose to be non-negative.\n** Hence, a negative P2 value is a label that has yet to be resolved.\n**\n** Zero is returned if a malloc() fails.\n*/\nint sqlite3VdbeMakeLabel(Vdbe *v){\n  Parse *p = v->pParse;\n  int i = p->nLabel++;\n  assert( v->magic==VDBE_MAGIC_INIT );\n  if( (i & (i-1))==0 ){\n    p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel, \n                                       (i*2+1)*sizeof(p->aLabel[0]));\n  }\n  if( p->aLabel ){\n    p->aLabel[i] = -1;\n  }\n  return ADDR(i);\n}\n\n/*\n** Resolve label \"x\" to be the address of the next instruction to\n** be inserted.  The parameter \"x\" must have been obtained from\n** a prior call to sqlite3VdbeMakeLabel().\n*/\nvoid sqlite3VdbeResolveLabel(Vdbe *v, int x){\n  Parse *p = v->pParse;\n  int j = ADDR(x);\n  assert( v->magic==VDBE_MAGIC_INIT );\n  assert( j<p->nLabel );\n  assert( j>=0 );\n  if( p->aLabel ){\n    p->aLabel[j] = v->nOp;\n  }\n}\n\n/*\n** Mark the VDBE as one that can only be run one time.\n*/\nvoid sqlite3VdbeRunOnlyOnce(Vdbe *p){\n  p->runOnlyOnce = 1;\n}\n\n/*\n** Mark the VDBE as one that can only be run multiple times.\n*/\nvoid sqlite3VdbeReusable(Vdbe *p){\n  p->runOnlyOnce = 0;\n}\n\n#ifdef SQLITE_DEBUG /* sqlite3AssertMayAbort() logic */\n\n/*\n** The following type and function are used to iterate through all opcodes\n** in a Vdbe main program and each of the sub-programs (triggers) it may \n** invoke directly or indirectly. It should be used as follows:\n**\n**   Op *pOp;\n**   VdbeOpIter sIter;\n**\n**   memset(&sIter, 0, sizeof(sIter));\n**   sIter.v = v;                            // v is of type Vdbe* \n**   while( (pOp = opIterNext(&sIter)) ){\n**     // Do something with pOp\n**   }\n**   sqlite3DbFree(v->db, sIter.apSub);\n** \n*/\ntypedef struct VdbeOpIter VdbeOpIter;\nstruct VdbeOpIter {\n  Vdbe *v;                   /* Vdbe to iterate through the opcodes of */\n  SubProgram **apSub;        /* Array of subprograms */\n  int nSub;                  /* Number of entries in apSub */\n  int iAddr;                 /* Address of next instruction to return */\n  int iSub;                  /* 0 = main program, 1 = first sub-program etc. */\n};\nstatic Op *opIterNext(VdbeOpIter *p){\n  Vdbe *v = p->v;\n  Op *pRet = 0;\n  Op *aOp;\n  int nOp;\n\n  if( p->iSub<=p->nSub ){\n\n    if( p->iSub==0 ){\n      aOp = v->aOp;\n      nOp = v->nOp;\n    }else{\n      aOp = p->apSub[p->iSub-1]->aOp;\n      nOp = p->apSub[p->iSub-1]->nOp;\n    }\n    assert( p->iAddr<nOp );\n\n    pRet = &aOp[p->iAddr];\n    p->iAddr++;\n    if( p->iAddr==nOp ){\n      p->iSub++;\n      p->iAddr = 0;\n    }\n  \n    if( pRet->p4type==P4_SUBPROGRAM ){\n      int nByte = (p->nSub+1)*sizeof(SubProgram*);\n      int j;\n      for(j=0; j<p->nSub; j++){\n        if( p->apSub[j]==pRet->p4.pProgram ) break;\n      }\n      if( j==p->nSub ){\n        p->apSub = sqlite3DbReallocOrFree(v->db, p->apSub, nByte);\n        if( !p->apSub ){\n          pRet = 0;\n        }else{\n          p->apSub[p->nSub++] = pRet->p4.pProgram;\n        }\n      }\n    }\n  }\n\n  return pRet;\n}\n\n/*\n** Check if the program stored in the VM associated with pParse may\n** throw an ABORT exception (causing the statement, but not entire transaction\n** to be rolled back). This condition is true if the main program or any\n** sub-programs contains any of the following:\n**\n**   *  OP_Halt with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_HaltIfNull with P1=SQLITE_CONSTRAINT and P2=OE_Abort.\n**   *  OP_Destroy\n**   *  OP_VUpdate\n**   *  OP_VRename\n**   *  OP_FkCounter with P2==0 (immediate foreign key constraint)\n**   *  OP_CreateBtree/BTREE_INTKEY and OP_InitCoroutine \n**      (for CREATE TABLE AS SELECT ...)\n**\n** Then check that the value of Parse.mayAbort is true if an\n** ABORT may be thrown, or false otherwise. Return true if it does\n** match, or false otherwise. This function is intended to be used as\n** part of an assert statement in the compiler. Similar to:\n**\n**   assert( sqlite3VdbeAssertMayAbort(pParse->pVdbe, pParse->mayAbort) );\n*/\nint sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){\n  int hasAbort = 0;\n  int hasFkCounter = 0;\n  int hasCreateTable = 0;\n  int hasInitCoroutine = 0;\n  Op *pOp;\n  VdbeOpIter sIter;\n  memset(&sIter, 0, sizeof(sIter));\n  sIter.v = v;\n\n  while( (pOp = opIterNext(&sIter))!=0 ){\n    int opcode = pOp->opcode;\n    if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename \n     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) \n      && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))\n    ){\n      hasAbort = 1;\n      break;\n    }\n    if( opcode==OP_CreateBtree && pOp->p3==BTREE_INTKEY ) hasCreateTable = 1;\n    if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n    if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){\n      hasFkCounter = 1;\n    }\n#endif\n  }\n  sqlite3DbFree(v->db, sIter.apSub);\n\n  /* Return true if hasAbort==mayAbort. Or if a malloc failure occurred.\n  ** If malloc failed, then the while() loop above may not have iterated\n  ** through all opcodes and hasAbort may be set incorrectly. Return\n  ** true for this case to prevent the assert() in the callers frame\n  ** from failing.  */\n  return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter\n              || (hasCreateTable && hasInitCoroutine) );\n}\n#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */\n\n/*\n** This routine is called after all opcodes have been inserted.  It loops\n** through all the opcodes and fixes up some details.\n**\n** (1) For each jump instruction with a negative P2 value (a label)\n**     resolve the P2 value to an actual address.\n**\n** (2) Compute the maximum number of arguments used by any SQL function\n**     and store that value in *pMaxFuncArgs.\n**\n** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately\n**     indicate what the prepared statement actually does.\n**\n** (4) Initialize the p4.xAdvance pointer on opcodes that use it.\n**\n** (5) Reclaim the memory allocated for storing labels.\n**\n** This routine will only function correctly if the mkopcodeh.tcl generator\n** script numbers the opcodes correctly.  Changes to this routine must be\n** coordinated with changes to mkopcodeh.tcl.\n*/\nstatic void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){\n  int nMaxArgs = *pMaxFuncArgs;\n  Op *pOp;\n  Parse *pParse = p->pParse;\n  int *aLabel = pParse->aLabel;\n  p->readOnly = 1;\n  p->bIsReader = 0;\n  pOp = &p->aOp[p->nOp-1];\n  while(1){\n\n    /* Only JUMP opcodes and the short list of special opcodes in the switch\n    ** below need to be considered.  The mkopcodeh.tcl generator script groups\n    ** all these opcodes together near the front of the opcode list.  Skip\n    ** any opcode that does not need processing by virtual of the fact that\n    ** it is larger than SQLITE_MX_JUMP_OPCODE, as a performance optimization.\n    */\n    if( pOp->opcode<=SQLITE_MX_JUMP_OPCODE ){\n      /* NOTE: Be sure to update mkopcodeh.tcl when adding or removing\n      ** cases from this switch! */\n      switch( pOp->opcode ){\n        case OP_Transaction: {\n          if( pOp->p2!=0 ) p->readOnly = 0;\n          /* fall thru */\n        }\n        case OP_AutoCommit:\n        case OP_Savepoint: {\n          p->bIsReader = 1;\n          break;\n        }\n#ifndef SQLITE_OMIT_WAL\n        case OP_Checkpoint:\n#endif\n        case OP_Vacuum:\n        case OP_JournalMode: {\n          p->readOnly = 0;\n          p->bIsReader = 1;\n          break;\n        }\n        case OP_Next:\n        case OP_NextIfOpen:\n        case OP_SorterNext: {\n          pOp->p4.xAdvance = sqlite3BtreeNext;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n        case OP_Prev:\n        case OP_PrevIfOpen: {\n          pOp->p4.xAdvance = sqlite3BtreePrevious;\n          pOp->p4type = P4_ADVANCE;\n          /* The code generator never codes any of these opcodes as a jump\n          ** to a label.  They are always coded as a jump backwards to a \n          ** known address */\n          assert( pOp->p2>=0 );\n          break;\n        }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        case OP_VUpdate: {\n          if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;\n          break;\n        }\n        case OP_VFilter: {\n          int n;\n          assert( (pOp - p->aOp) >= 3 );\n          assert( pOp[-1].opcode==OP_Integer );\n          n = pOp[-1].p1;\n          if( n>nMaxArgs ) nMaxArgs = n;\n          /* Fall through into the default case */\n        }\n#endif\n        default: {\n          if( pOp->p2<0 ){\n            /* The mkopcodeh.tcl script has so arranged things that the only\n            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n            ** have non-negative values for P2. */\n            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );\n            assert( ADDR(pOp->p2)<pParse->nLabel );\n            pOp->p2 = aLabel[ADDR(pOp->p2)];\n          }\n          break;\n        }\n      }\n      /* The mkopcodeh.tcl script has so arranged things that the only\n      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to\n      ** have non-negative values for P2. */\n      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);\n    }\n    if( pOp==p->aOp ) break;\n    pOp--;\n  }\n  sqlite3DbFree(p->db, pParse->aLabel);\n  pParse->aLabel = 0;\n  pParse->nLabel = 0;\n  *pMaxFuncArgs = nMaxArgs;\n  assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );\n}\n\n/*\n** Return the address of the next instruction to be inserted.\n*/\nint sqlite3VdbeCurrentAddr(Vdbe *p){\n  assert( p->magic==VDBE_MAGIC_INIT );\n  return p->nOp;\n}\n\n/*\n** Verify that at least N opcode slots are available in p without\n** having to malloc for more space (except when compiled using\n** SQLITE_TEST_REALLOC_STRESS).  This interface is used during testing\n** to verify that certain calls to sqlite3VdbeAddOpList() can never\n** fail due to a OOM fault and hence that the return value from\n** sqlite3VdbeAddOpList() will always be non-NULL.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nvoid sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){\n  assert( p->nOp + N <= p->pParse->nOpAlloc );\n}\n#endif\n\n/*\n** Verify that the VM passed as the only argument does not contain\n** an OP_ResultRow opcode. Fail an assert() if it does. This is used\n** by code in pragma.c to ensure that the implementation of certain\n** pragmas comports with the flags specified in the mkpragmatab.tcl\n** script.\n*/\n#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)\nvoid sqlite3VdbeVerifyNoResultRow(Vdbe *p){\n  int i;\n  for(i=0; i<p->nOp; i++){\n    assert( p->aOp[i].opcode!=OP_ResultRow );\n  }\n}\n#endif\n\n/*\n** This function returns a pointer to the array of opcodes associated with\n** the Vdbe passed as the first argument. It is the callers responsibility\n** to arrange for the returned array to be eventually freed using the \n** vdbeFreeOpArray() function.\n**\n** Before returning, *pnOp is set to the number of entries in the returned\n** array. Also, *pnMaxArg is set to the larger of its current value and \n** the number of entries in the Vdbe.apArg[] array required to execute the \n** returned program.\n*/\nVdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){\n  VdbeOp *aOp = p->aOp;\n  assert( aOp && !p->db->mallocFailed );\n\n  /* Check that sqlite3VdbeUsesBtree() was not called on this VM */\n  assert( DbMaskAllZero(p->btreeMask) );\n\n  resolveP2Values(p, pnMaxArg);\n  *pnOp = p->nOp;\n  p->aOp = 0;\n  return aOp;\n}\n\n/*\n** Add a whole list of operations to the operation stack.  Return a\n** pointer to the first operation inserted.\n**\n** Non-zero P2 arguments to jump instructions are automatically adjusted\n** so that the jump target is relative to the first operation inserted.\n*/\nVdbeOp *sqlite3VdbeAddOpList(\n  Vdbe *p,                     /* Add opcodes to the prepared statement */\n  int nOp,                     /* Number of opcodes to add */\n  VdbeOpList const *aOp,       /* The opcodes to be added */\n  int iLineno                  /* Source-file line number of first opcode */\n){\n  int i;\n  VdbeOp *pOut, *pFirst;\n  assert( nOp>0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){\n    return 0;\n  }\n  pFirst = pOut = &p->aOp[p->nOp];\n  for(i=0; i<nOp; i++, aOp++, pOut++){\n    pOut->opcode = aOp->opcode;\n    pOut->p1 = aOp->p1;\n    pOut->p2 = aOp->p2;\n    assert( aOp->p2>=0 );\n    if( (sqlite3OpcodeProperty[aOp->opcode] & OPFLG_JUMP)!=0 && aOp->p2>0 ){\n      pOut->p2 += p->nOp;\n    }\n    pOut->p3 = aOp->p3;\n    pOut->p4type = P4_NOTUSED;\n    pOut->p4.p = 0;\n    pOut->p5 = 0;\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n    pOut->zComment = 0;\n#endif\n#ifdef SQLITE_VDBE_COVERAGE\n    pOut->iSrcLine = iLineno+i;\n#else\n    (void)iLineno;\n#endif\n#ifdef SQLITE_DEBUG\n    if( p->db->flags & SQLITE_VdbeAddopTrace ){\n      sqlite3VdbePrintOp(0, i+p->nOp, &p->aOp[i+p->nOp]);\n    }\n#endif\n  }\n  p->nOp += nOp;\n  return pFirst;\n}\n\n#if defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n/*\n** Add an entry to the array of counters managed by sqlite3_stmt_scanstatus().\n*/\nvoid sqlite3VdbeScanStatus(\n  Vdbe *p,                        /* VM to add scanstatus() to */\n  int addrExplain,                /* Address of OP_Explain (or 0) */\n  int addrLoop,                   /* Address of loop counter */ \n  int addrVisit,                  /* Address of rows visited counter */\n  LogEst nEst,                    /* Estimated number of output rows */\n  const char *zName               /* Name of table or index being scanned */\n){\n  int nByte = (p->nScan+1) * sizeof(ScanStatus);\n  ScanStatus *aNew;\n  aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);\n  if( aNew ){\n    ScanStatus *pNew = &aNew[p->nScan++];\n    pNew->addrExplain = addrExplain;\n    pNew->addrLoop = addrLoop;\n    pNew->addrVisit = addrVisit;\n    pNew->nEst = nEst;\n    pNew->zName = sqlite3DbStrDup(p->db, zName);\n    p->aScan = aNew;\n  }\n}\n#endif\n\n\n/*\n** Change the value of the opcode, or P1, P2, P3, or P5 operands\n** for a specific instruction.\n*/\nvoid sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){\n  sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode;\n}\nvoid sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p1 = val;\n}\nvoid sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p2 = val;\n}\nvoid sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){\n  sqlite3VdbeGetOp(p,addr)->p3 = val;\n}\nvoid sqlite3VdbeChangeP5(Vdbe *p, u16 p5){\n  assert( p->nOp>0 || p->db->mallocFailed );\n  if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;\n}\n\n/*\n** Change the P2 operand of instruction addr so that it points to\n** the address of the next instruction to be coded.\n*/\nvoid sqlite3VdbeJumpHere(Vdbe *p, int addr){\n  sqlite3VdbeChangeP2(p, addr, p->nOp);\n}\n\n\n/*\n** If the input FuncDef structure is ephemeral, then free it.  If\n** the FuncDef is not ephermal, then do nothing.\n*/\nstatic void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){\n  if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){\n    sqlite3DbFreeNN(db, pDef);\n  }\n}\n\nstatic void vdbeFreeOpArray(sqlite3 *, Op *, int);\n\n/*\n** Delete a P4 value if necessary.\n*/\nstatic SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){\n  if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n  sqlite3DbFreeNN(db, p);\n}\nstatic SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){\n  freeEphemeralFunction(db, p->pFunc);\n sqlite3DbFreeNN(db, p);\n}\nstatic void freeP4(sqlite3 *db, int p4type, void *p4){\n  assert( db );\n  switch( p4type ){\n    case P4_FUNCCTX: {\n      freeP4FuncCtx(db, (sqlite3_context*)p4);\n      break;\n    }\n    case P4_REAL:\n    case P4_INT64:\n    case P4_DYNAMIC:\n    case P4_INTARRAY: {\n      sqlite3DbFree(db, p4);\n      break;\n    }\n    case P4_KEYINFO: {\n      if( db->pnBytesFreed==0 ) sqlite3KeyInfoUnref((KeyInfo*)p4);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      sqlite3ExprDelete(db, (Expr*)p4);\n      break;\n    }\n#endif\n    case P4_FUNCDEF: {\n      freeEphemeralFunction(db, (FuncDef*)p4);\n      break;\n    }\n    case P4_MEM: {\n      if( db->pnBytesFreed==0 ){\n        sqlite3ValueFree((sqlite3_value*)p4);\n      }else{\n        freeP4Mem(db, (Mem*)p4);\n      }\n      break;\n    }\n    case P4_VTAB : {\n      if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4);\n      break;\n    }\n  }\n}\n\n/*\n** Free the space allocated for aOp and any p4 values allocated for the\n** opcodes contained within. If aOp is not NULL it is assumed to contain \n** nOp entries. \n*/\nstatic void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){\n  if( aOp ){\n    Op *pOp;\n    for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){\n      if( pOp->p4type <= P4_FREE_IF_LE ) freeP4(db, pOp->p4type, pOp->p4.p);\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n      sqlite3DbFree(db, pOp->zComment);\n#endif     \n    }\n    sqlite3DbFreeNN(db, aOp);\n  }\n}\n\n/*\n** Link the SubProgram object passed as the second argument into the linked\n** list at Vdbe.pSubProgram. This list is used to delete all sub-program\n** objects when the VM is no longer required.\n*/\nvoid sqlite3VdbeLinkSubProgram(Vdbe *pVdbe, SubProgram *p){\n  p->pNext = pVdbe->pProgram;\n  pVdbe->pProgram = p;\n}\n\n/*\n** Change the opcode at addr into OP_Noop\n*/\nint sqlite3VdbeChangeToNoop(Vdbe *p, int addr){\n  VdbeOp *pOp;\n  if( p->db->mallocFailed ) return 0;\n  assert( addr>=0 && addr<p->nOp );\n  pOp = &p->aOp[addr];\n  freeP4(p->db, pOp->p4type, pOp->p4.p);\n  pOp->p4type = P4_NOTUSED;\n  pOp->p4.z = 0;\n  pOp->opcode = OP_Noop;\n  return 1;\n}\n\n/*\n** If the last opcode is \"op\" and it is not a jump destination,\n** then remove it.  Return true if and only if an opcode was removed.\n*/\nint sqlite3VdbeDeletePriorOpcode(Vdbe *p, u8 op){\n  if( p->nOp>0 && p->aOp[p->nOp-1].opcode==op ){\n    return sqlite3VdbeChangeToNoop(p, p->nOp-1);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Change the value of the P4 operand for a specific instruction.\n** This routine is useful when a large program is loaded from a\n** static array using sqlite3VdbeAddOpList but we want to make a\n** few minor changes to the program.\n**\n** If n>=0 then the P4 operand is dynamic, meaning that a copy of\n** the string is made into memory obtained from sqlite3_malloc().\n** A value of n==0 means copy bytes of zP4 up to and including the\n** first null byte.  If n>0 then copy n+1 bytes of zP4.\n** \n** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points\n** to a string or structure that is guaranteed to exist for the lifetime of\n** the Vdbe. In these cases we can just copy the pointer.\n**\n** If addr<0 then change P4 on the most recently inserted instruction.\n*/\nstatic void SQLITE_NOINLINE vdbeChangeP4Full(\n  Vdbe *p,\n  Op *pOp,\n  const char *zP4,\n  int n\n){\n  if( pOp->p4type ){\n    freeP4(p->db, pOp->p4type, pOp->p4.p);\n    pOp->p4type = 0;\n    pOp->p4.p = 0;\n  }\n  if( n<0 ){\n    sqlite3VdbeChangeP4(p, (int)(pOp - p->aOp), zP4, n);\n  }else{\n    if( n==0 ) n = sqlite3Strlen30(zP4);\n    pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n);\n    pOp->p4type = P4_DYNAMIC;\n  }\n}\nvoid sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){\n  Op *pOp;\n  sqlite3 *db;\n  assert( p!=0 );\n  db = p->db;\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( p->aOp!=0 || db->mallocFailed );\n  if( db->mallocFailed ){\n    if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4);\n    return;\n  }\n  assert( p->nOp>0 );\n  assert( addr<p->nOp );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  pOp = &p->aOp[addr];\n  if( n>=0 || pOp->p4type ){\n    vdbeChangeP4Full(p, pOp, zP4, n);\n    return;\n  }\n  if( n==P4_INT32 ){\n    /* Note: this cast is safe, because the origin data point was an int\n    ** that was cast to a (const char *). */\n    pOp->p4.i = SQLITE_PTR_TO_INT(zP4);\n    pOp->p4type = P4_INT32;\n  }else if( zP4!=0 ){\n    assert( n<0 );\n    pOp->p4.p = (void*)zP4;\n    pOp->p4type = (signed char)n;\n    if( n==P4_VTAB ) sqlite3VtabLock((VTable*)zP4);\n  }\n}\n\n/*\n** Change the P4 operand of the most recently coded instruction \n** to the value defined by the arguments.  This is a high-speed\n** version of sqlite3VdbeChangeP4().\n**\n** The P4 operand must not have been previously defined.  And the new\n** P4 must not be P4_INT32.  Use sqlite3VdbeChangeP4() in either of\n** those cases.\n*/\nvoid sqlite3VdbeAppendP4(Vdbe *p, void *pP4, int n){\n  VdbeOp *pOp;\n  assert( n!=P4_INT32 && n!=P4_VTAB );\n  assert( n<=0 );\n  if( p->db->mallocFailed ){\n    freeP4(p->db, n, pP4);\n  }else{\n    assert( pP4!=0 );\n    assert( p->nOp>0 );\n    pOp = &p->aOp[p->nOp-1];\n    assert( pOp->p4type==P4_NOTUSED );\n    pOp->p4type = n;\n    pOp->p4.p = pP4;\n  }\n}\n\n/*\n** Set the P4 on the most recently added opcode to the KeyInfo for the\n** index given.\n*/\nvoid sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){\n  Vdbe *v = pParse->pVdbe;\n  KeyInfo *pKeyInfo;\n  assert( v!=0 );\n  assert( pIdx!=0 );\n  pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pIdx);\n  if( pKeyInfo ) sqlite3VdbeAppendP4(v, pKeyInfo, P4_KEYINFO);\n}\n\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n/*\n** Change the comment on the most recently coded instruction.  Or\n** insert a No-op and add the comment to that new instruction.  This\n** makes the code easier to read during debugging.  None of this happens\n** in a production build.\n*/\nstatic void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){\n  assert( p->nOp>0 || p->aOp==0 );\n  assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );\n  if( p->nOp ){\n    assert( p->aOp );\n    sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);\n    p->aOp[p->nOp-1].zComment = sqlite3VMPrintf(p->db, zFormat, ap);\n  }\n}\nvoid sqlite3VdbeComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\nvoid sqlite3VdbeNoopComment(Vdbe *p, const char *zFormat, ...){\n  va_list ap;\n  if( p ){\n    sqlite3VdbeAddOp0(p, OP_Noop);\n    va_start(ap, zFormat);\n    vdbeVComment(p, zFormat, ap);\n    va_end(ap);\n  }\n}\n#endif  /* NDEBUG */\n\n#ifdef SQLITE_VDBE_COVERAGE\n/*\n** Set the value if the iSrcLine field for the previously coded instruction.\n*/\nvoid sqlite3VdbeSetLineNumber(Vdbe *v, int iLine){\n  sqlite3VdbeGetOp(v,-1)->iSrcLine = iLine;\n}\n#endif /* SQLITE_VDBE_COVERAGE */\n\n/*\n** Return the opcode for a given address.  If the address is -1, then\n** return the most recently inserted opcode.\n**\n** If a memory allocation error has occurred prior to the calling of this\n** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode\n** is readable but not writable, though it is cast to a writable value.\n** The return of a dummy opcode allows the call to continue functioning\n** after an OOM fault without having to check to see if the return from \n** this routine is a valid pointer.  But because the dummy.opcode is 0,\n** dummy will never be written to.  This is verified by code inspection and\n** by running with Valgrind.\n*/\nVdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){\n  /* C89 specifies that the constant \"dummy\" will be initialized to all\n  ** zeros, which is correct.  MSVC generates a warning, nevertheless. */\n  static VdbeOp dummy;  /* Ignore the MSVC warning about no initializer */\n  assert( p->magic==VDBE_MAGIC_INIT );\n  if( addr<0 ){\n    addr = p->nOp - 1;\n  }\n  assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );\n  if( p->db->mallocFailed ){\n    return (VdbeOp*)&dummy;\n  }else{\n    return &p->aOp[addr];\n  }\n}\n\n#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS)\n/*\n** Return an integer value for one of the parameters to the opcode pOp\n** determined by character c.\n*/\nstatic int translateP(char c, const Op *pOp){\n  if( c=='1' ) return pOp->p1;\n  if( c=='2' ) return pOp->p2;\n  if( c=='3' ) return pOp->p3;\n  if( c=='4' ) return pOp->p4.i;\n  return pOp->p5;\n}\n\n/*\n** Compute a string for the \"comment\" field of a VDBE opcode listing.\n**\n** The Synopsis: field in comments in the vdbe.c source file gets converted\n** to an extra string that is appended to the sqlite3OpcodeName().  In the\n** absence of other comments, this synopsis becomes the comment on the opcode.\n** Some translation occurs:\n**\n**       \"PX\"      ->  \"r[X]\"\n**       \"PX@PY\"   ->  \"r[X..X+Y-1]\"  or \"r[x]\" if y is 0 or 1\n**       \"PX@PY+1\" ->  \"r[X..X+Y]\"    or \"r[x]\" if y is 0\n**       \"PY..PY\"  ->  \"r[X..Y]\"      or \"r[x]\" if y<=x\n*/\nstatic int displayComment(\n  const Op *pOp,     /* The opcode to be commented */\n  const char *zP4,   /* Previously obtained value for P4 */\n  char *zTemp,       /* Write result here */\n  int nTemp          /* Space available in zTemp[] */\n){\n  const char *zOpName;\n  const char *zSynopsis;\n  int nOpName;\n  int ii, jj;\n  char zAlt[50];\n  zOpName = sqlite3OpcodeName(pOp->opcode);\n  nOpName = sqlite3Strlen30(zOpName);\n  if( zOpName[nOpName+1] ){\n    int seenCom = 0;\n    char c;\n    zSynopsis = zOpName += nOpName + 1;\n    if( strncmp(zSynopsis,\"IF \",3)==0 ){\n      if( pOp->p5 & SQLITE_STOREP2 ){\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"r[P2] = (%s)\", zSynopsis+3);\n      }else{\n        sqlite3_snprintf(sizeof(zAlt), zAlt, \"if %s goto P2\", zSynopsis+3);\n      }\n      zSynopsis = zAlt;\n    }\n    for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){\n      if( c=='P' ){\n        c = zSynopsis[++ii];\n        if( c=='4' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", zP4);\n        }else if( c=='X' ){\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%s\", pOp->zComment);\n          seenCom = 1;\n        }else{\n          int v1 = translateP(c, pOp);\n          int v2;\n          sqlite3_snprintf(nTemp-jj, zTemp+jj, \"%d\", v1);\n          if( strncmp(zSynopsis+ii+1, \"@P\", 2)==0 ){\n            ii += 3;\n            jj += sqlite3Strlen30(zTemp+jj);\n            v2 = translateP(zSynopsis[ii], pOp);\n            if( strncmp(zSynopsis+ii+1,\"+1\",2)==0 ){\n              ii += 2;\n              v2++;\n            }\n            if( v2>1 ){\n              sqlite3_snprintf(nTemp-jj, zTemp+jj, \"..%d\", v1+v2-1);\n            }\n          }else if( strncmp(zSynopsis+ii+1, \"..P3\", 4)==0 && pOp->p3==0 ){\n            ii += 4;\n          }\n        }\n        jj += sqlite3Strlen30(zTemp+jj);\n      }else{\n        zTemp[jj++] = c;\n      }\n    }\n    if( !seenCom && jj<nTemp-5 && pOp->zComment ){\n      sqlite3_snprintf(nTemp-jj, zTemp+jj, \"; %s\", pOp->zComment);\n      jj += sqlite3Strlen30(zTemp+jj);\n    }\n    if( jj<nTemp ) zTemp[jj] = 0;\n  }else if( pOp->zComment ){\n    sqlite3_snprintf(nTemp, zTemp, \"%s\", pOp->zComment);\n    jj = sqlite3Strlen30(zTemp);\n  }else{\n    zTemp[0] = 0;\n    jj = 0;\n  }\n  return jj;\n}\n#endif /* SQLITE_DEBUG */\n\n#if VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS)\n/*\n** Translate the P4.pExpr value for an OP_CursorHint opcode into text\n** that can be displayed in the P4 column of EXPLAIN output.\n*/\nstatic void displayP4Expr(StrAccum *p, Expr *pExpr){\n  const char *zOp = 0;\n  switch( pExpr->op ){\n    case TK_STRING:\n      sqlite3XPrintf(p, \"%Q\", pExpr->u.zToken);\n      break;\n    case TK_INTEGER:\n      sqlite3XPrintf(p, \"%d\", pExpr->u.iValue);\n      break;\n    case TK_NULL:\n      sqlite3XPrintf(p, \"NULL\");\n      break;\n    case TK_REGISTER: {\n      sqlite3XPrintf(p, \"r[%d]\", pExpr->iTable);\n      break;\n    }\n    case TK_COLUMN: {\n      if( pExpr->iColumn<0 ){\n        sqlite3XPrintf(p, \"rowid\");\n      }else{\n        sqlite3XPrintf(p, \"c%d\", (int)pExpr->iColumn);\n      }\n      break;\n    }\n    case TK_LT:      zOp = \"LT\";      break;\n    case TK_LE:      zOp = \"LE\";      break;\n    case TK_GT:      zOp = \"GT\";      break;\n    case TK_GE:      zOp = \"GE\";      break;\n    case TK_NE:      zOp = \"NE\";      break;\n    case TK_EQ:      zOp = \"EQ\";      break;\n    case TK_IS:      zOp = \"IS\";      break;\n    case TK_ISNOT:   zOp = \"ISNOT\";   break;\n    case TK_AND:     zOp = \"AND\";     break;\n    case TK_OR:      zOp = \"OR\";      break;\n    case TK_PLUS:    zOp = \"ADD\";     break;\n    case TK_STAR:    zOp = \"MUL\";     break;\n    case TK_MINUS:   zOp = \"SUB\";     break;\n    case TK_REM:     zOp = \"REM\";     break;\n    case TK_BITAND:  zOp = \"BITAND\";  break;\n    case TK_BITOR:   zOp = \"BITOR\";   break;\n    case TK_SLASH:   zOp = \"DIV\";     break;\n    case TK_LSHIFT:  zOp = \"LSHIFT\";  break;\n    case TK_RSHIFT:  zOp = \"RSHIFT\";  break;\n    case TK_CONCAT:  zOp = \"CONCAT\";  break;\n    case TK_UMINUS:  zOp = \"MINUS\";   break;\n    case TK_UPLUS:   zOp = \"PLUS\";    break;\n    case TK_BITNOT:  zOp = \"BITNOT\";  break;\n    case TK_NOT:     zOp = \"NOT\";     break;\n    case TK_ISNULL:  zOp = \"ISNULL\";  break;\n    case TK_NOTNULL: zOp = \"NOTNULL\"; break;\n\n    default:\n      sqlite3XPrintf(p, \"%s\", \"expr\");\n      break;\n  }\n\n  if( zOp ){\n    sqlite3XPrintf(p, \"%s(\", zOp);\n    displayP4Expr(p, pExpr->pLeft);\n    if( pExpr->pRight ){\n      sqlite3StrAccumAppend(p, \",\", 1);\n      displayP4Expr(p, pExpr->pRight);\n    }\n    sqlite3StrAccumAppend(p, \")\", 1);\n  }\n}\n#endif /* VDBE_DISPLAY_P4 && defined(SQLITE_ENABLE_CURSOR_HINTS) */\n\n\n#if VDBE_DISPLAY_P4\n/*\n** Compute a string that describes the P4 parameter for an opcode.\n** Use zTemp for any required temporary buffer space.\n*/\nstatic char *displayP4(Op *pOp, char *zTemp, int nTemp){\n  char *zP4 = zTemp;\n  StrAccum x;\n  assert( nTemp>=20 );\n  sqlite3StrAccumInit(&x, 0, zTemp, nTemp, 0);\n  switch( pOp->p4type ){\n    case P4_KEYINFO: {\n      int j;\n      KeyInfo *pKeyInfo = pOp->p4.pKeyInfo;\n      assert( pKeyInfo->aSortOrder!=0 );\n      sqlite3XPrintf(&x, \"k(%d\", pKeyInfo->nKeyField);\n      for(j=0; j<pKeyInfo->nKeyField; j++){\n        CollSeq *pColl = pKeyInfo->aColl[j];\n        const char *zColl = pColl ? pColl->zName : \"\";\n        if( strcmp(zColl, \"BINARY\")==0 ) zColl = \"B\";\n        sqlite3XPrintf(&x, \",%s%s\", pKeyInfo->aSortOrder[j] ? \"-\" : \"\", zColl);\n      }\n      sqlite3StrAccumAppend(&x, \")\", 1);\n      break;\n    }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n    case P4_EXPR: {\n      displayP4Expr(&x, pOp->p4.pExpr);\n      break;\n    }\n#endif\n    case P4_COLLSEQ: {\n      CollSeq *pColl = pOp->p4.pColl;\n      sqlite3XPrintf(&x, \"(%.20s)\", pColl->zName);\n      break;\n    }\n    case P4_FUNCDEF: {\n      FuncDef *pDef = pOp->p4.pFunc;\n      sqlite3XPrintf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n    case P4_FUNCCTX: {\n      FuncDef *pDef = pOp->p4.pCtx->pFunc;\n      sqlite3XPrintf(&x, \"%s(%d)\", pDef->zName, pDef->nArg);\n      break;\n    }\n#endif\n    case P4_INT64: {\n      sqlite3XPrintf(&x, \"%lld\", *pOp->p4.pI64);\n      break;\n    }\n    case P4_INT32: {\n      sqlite3XPrintf(&x, \"%d\", pOp->p4.i);\n      break;\n    }\n    case P4_REAL: {\n      sqlite3XPrintf(&x, \"%.16g\", *pOp->p4.pReal);\n      break;\n    }\n    case P4_MEM: {\n      Mem *pMem = pOp->p4.pMem;\n      if( pMem->flags & MEM_Str ){\n        zP4 = pMem->z;\n      }else if( pMem->flags & MEM_Int ){\n        sqlite3XPrintf(&x, \"%lld\", pMem->u.i);\n      }else if( pMem->flags & MEM_Real ){\n        sqlite3XPrintf(&x, \"%.16g\", pMem->u.r);\n      }else if( pMem->flags & MEM_Null ){\n        zP4 = \"NULL\";\n      }else{\n        assert( pMem->flags & MEM_Blob );\n        zP4 = \"(blob)\";\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case P4_VTAB: {\n      sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;\n      sqlite3XPrintf(&x, \"vtab:%p\", pVtab);\n      break;\n    }\n#endif\n    case P4_INTARRAY: {\n      int i;\n      int *ai = pOp->p4.ai;\n      int n = ai[0];   /* The first element of an INTARRAY is always the\n                       ** count of the number of elements to follow */\n      for(i=1; i<=n; i++){\n        sqlite3XPrintf(&x, \",%d\", ai[i]);\n      }\n      zTemp[0] = '[';\n      sqlite3StrAccumAppend(&x, \"]\", 1);\n      break;\n    }\n    case P4_SUBPROGRAM: {\n      sqlite3XPrintf(&x, \"program\");\n      break;\n    }\n    case P4_ADVANCE: {\n      zTemp[0] = 0;\n      break;\n    }\n    case P4_TABLE: {\n      sqlite3XPrintf(&x, \"%s\", pOp->p4.pTab->zName);\n      break;\n    }\n    default: {\n      zP4 = pOp->p4.z;\n      if( zP4==0 ){\n        zP4 = zTemp;\n        zTemp[0] = 0;\n      }\n    }\n  }\n  sqlite3StrAccumFinish(&x);\n  assert( zP4!=0 );\n  return zP4;\n}\n#endif /* VDBE_DISPLAY_P4 */\n\n/*\n** Declare to the Vdbe that the BTree object at db->aDb[i] is used.\n**\n** The prepared statements need to know in advance the complete set of\n** attached databases that will be use.  A mask of these databases\n** is maintained in p->btreeMask.  The p->lockMask value is the subset of\n** p->btreeMask of databases that will require a lock.\n*/\nvoid sqlite3VdbeUsesBtree(Vdbe *p, int i){\n  assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 );\n  assert( i<(int)sizeof(p->btreeMask)*8 );\n  DbMaskSet(p->btreeMask, i);\n  if( i!=1 && sqlite3BtreeSharable(p->db->aDb[i].pBt) ){\n    DbMaskSet(p->lockMask, i);\n  }\n}\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE)\n/*\n** If SQLite is compiled to support shared-cache mode and to be threadsafe,\n** this routine obtains the mutex associated with each BtShared structure\n** that may be accessed by the VM passed as an argument. In doing so it also\n** sets the BtShared.db member of each of the BtShared structures, ensuring\n** that the correct busy-handler callback is invoked if required.\n**\n** If SQLite is not threadsafe but does support shared-cache mode, then\n** sqlite3BtreeEnter() is invoked to set the BtShared.db variables\n** of all of BtShared structures accessible via the database handle \n** associated with the VM.\n**\n** If SQLite is not threadsafe and does not support shared-cache mode, this\n** function is a no-op.\n**\n** The p->btreeMask field is a bitmask of all btrees that the prepared \n** statement p will ever use.  Let N be the number of bits in p->btreeMask\n** corresponding to btrees that use shared cache.  Then the runtime of\n** this routine is N*N.  But as N is rarely more than 1, this should not\n** be a problem.\n*/\nvoid sqlite3VdbeEnter(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeEnter(aDb[i].pBt);\n    }\n  }\n}\n#endif\n\n#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0\n/*\n** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter().\n*/\nstatic SQLITE_NOINLINE void vdbeLeave(Vdbe *p){\n  int i;\n  sqlite3 *db;\n  Db *aDb;\n  int nDb;\n  db = p->db;\n  aDb = db->aDb;\n  nDb = db->nDb;\n  for(i=0; i<nDb; i++){\n    if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){\n      sqlite3BtreeLeave(aDb[i].pBt);\n    }\n  }\n}\nvoid sqlite3VdbeLeave(Vdbe *p){\n  if( DbMaskAllZero(p->lockMask) ) return;  /* The common case */\n  vdbeLeave(p);\n}\n#endif\n\n#if defined(VDBE_PROFILE) || defined(SQLITE_DEBUG)\n/*\n** Print a single opcode.  This routine is used for debugging only.\n*/\nvoid sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){\n  char *zP4;\n  char zPtr[50];\n  char zCom[100];\n  static const char *zFormat1 = \"%4d %-13s %4d %4d %4d %-13s %.2X %s\\n\";\n  if( pOut==0 ) pOut = stdout;\n  zP4 = displayP4(pOp, zPtr, sizeof(zPtr));\n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n  displayComment(pOp, zP4, zCom, sizeof(zCom));\n#else\n  zCom[0] = 0;\n#endif\n  /* NB:  The sqlite3OpcodeName() function is implemented by code created\n  ** by the mkopcodeh.awk and mkopcodec.awk scripts which extract the\n  ** information from the vdbe.c source text */\n  fprintf(pOut, zFormat1, pc, \n      sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5,\n      zCom\n  );\n  fflush(pOut);\n}\n#endif\n\n/*\n** Initialize an array of N Mem element.\n*/\nstatic void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){\n  while( (N--)>0 ){\n    p->db = db;\n    p->flags = flags;\n    p->szMalloc = 0;\n#ifdef SQLITE_DEBUG\n    p->pScopyFrom = 0;\n#endif\n    p++;\n  }\n}\n\n/*\n** Release an array of N Mem elements\n*/\nstatic void releaseMemArray(Mem *p, int N){\n  if( p && N ){\n    Mem *pEnd = &p[N];\n    sqlite3 *db = p->db;\n    if( db->pnBytesFreed ){\n      do{\n        if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);\n      }while( (++p)<pEnd );\n      return;\n    }\n    do{\n      assert( (&p[1])==pEnd || p[0].db==p[1].db );\n      assert( sqlite3VdbeCheckMemInvariants(p) );\n\n      /* This block is really an inlined version of sqlite3VdbeMemRelease()\n      ** that takes advantage of the fact that the memory cell value is \n      ** being set to NULL after releasing any dynamic resources.\n      **\n      ** The justification for duplicating code is that according to \n      ** callgrind, this causes a certain test case to hit the CPU 4.7 \n      ** percent less (x86 linux, gcc version 4.1.2, -O6) than if \n      ** sqlite3MemRelease() were called from here. With -O2, this jumps\n      ** to 6.6 percent. The test case is inserting 1000 rows into a table \n      ** with no indexes using a single prepared INSERT statement, bind() \n      ** and reset(). Inserts are grouped into a transaction.\n      */\n      testcase( p->flags & MEM_Agg );\n      testcase( p->flags & MEM_Dyn );\n      testcase( p->flags & MEM_Frame );\n      testcase( p->flags & MEM_RowSet );\n      if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){\n        sqlite3VdbeMemRelease(p);\n      }else if( p->szMalloc ){\n        sqlite3DbFreeNN(db, p->zMalloc);\n        p->szMalloc = 0;\n      }\n\n      p->flags = MEM_Undefined;\n    }while( (++p)<pEnd );\n  }\n}\n\n/*\n** Delete a VdbeFrame object and its contents. VdbeFrame objects are\n** allocated by the OP_Program opcode in sqlite3VdbeExec().\n*/\nvoid sqlite3VdbeFrameDelete(VdbeFrame *p){\n  int i;\n  Mem *aMem = VdbeFrameMem(p);\n  VdbeCursor **apCsr = (VdbeCursor **)&aMem[p->nChildMem];\n  for(i=0; i<p->nChildCsr; i++){\n    sqlite3VdbeFreeCursor(p->v, apCsr[i]);\n  }\n  releaseMemArray(aMem, p->nChildMem);\n  sqlite3VdbeDeleteAuxData(p->v->db, &p->pAuxData, -1, 0);\n  sqlite3DbFree(p->v->db, p);\n}\n\n#ifndef SQLITE_OMIT_EXPLAIN\n/*\n** Give a listing of the program in the virtual machine.\n**\n** The interface is the same as sqlite3VdbeExec().  But instead of\n** running the code, it invokes the callback once for each instruction.\n** This feature is used to implement \"EXPLAIN\".\n**\n** When p->explain==1, each instruction is listed.  When\n** p->explain==2, only OP_Explain instructions are listed and these\n** are shown in a different format.  p->explain==2 is used to implement\n** EXPLAIN QUERY PLAN.\n**\n** When p->explain==1, first the main program is listed, then each of\n** the trigger subprograms are listed one by one.\n*/\nint sqlite3VdbeList(\n  Vdbe *p                   /* The VDBE */\n){\n  int nRow;                            /* Stop when row count reaches this */\n  int nSub = 0;                        /* Number of sub-vdbes seen so far */\n  SubProgram **apSub = 0;              /* Array of sub-vdbes */\n  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */\n  sqlite3 *db = p->db;                 /* The database connection */\n  int i;                               /* Loop counter */\n  int rc = SQLITE_OK;                  /* Return code */\n  Mem *pMem = &p->aMem[1];             /* First Mem of result set */\n\n  assert( p->explain );\n  assert( p->magic==VDBE_MAGIC_RUN );\n  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );\n\n  /* Even though this opcode does not use dynamic strings for\n  ** the result, result columns may become dynamic if the user calls\n  ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.\n  */\n  releaseMemArray(pMem, 8);\n  p->pResultSet = 0;\n\n  if( p->rc==SQLITE_NOMEM_BKPT ){\n    /* This happens if a malloc() inside a call to sqlite3_column_text() or\n    ** sqlite3_column_text16() failed.  */\n    sqlite3OomFault(db);\n    return SQLITE_ERROR;\n  }\n\n  /* When the number of output rows reaches nRow, that means the\n  ** listing has finished and sqlite3_step() should return SQLITE_DONE.\n  ** nRow is the sum of the number of rows in the main program, plus\n  ** the sum of the number of rows in all trigger subprograms encountered\n  ** so far.  The nRow value will increase as new trigger subprograms are\n  ** encountered, but p->pc will eventually catch up to nRow.\n  */\n  nRow = p->nOp;\n  if( p->explain==1 ){\n    /* The first 8 memory cells are used for the result set.  So we will\n    ** commandeer the 9th cell to use as storage for an array of pointers\n    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9\n    ** cells.  */\n    assert( p->nMem>9 );\n    pSub = &p->aMem[9];\n    if( pSub->flags&MEM_Blob ){\n      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is\n      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */\n      nSub = pSub->n/sizeof(Vdbe*);\n      apSub = (SubProgram **)pSub->z;\n    }\n    for(i=0; i<nSub; i++){\n      nRow += apSub[i]->nOp;\n    }\n  }\n\n  do{\n    i = p->pc++;\n  }while( i<nRow && p->explain==2 && p->aOp[i].opcode!=OP_Explain );\n  if( i>=nRow ){\n    p->rc = SQLITE_OK;\n    rc = SQLITE_DONE;\n  }else if( db->u1.isInterrupted ){\n    p->rc = SQLITE_INTERRUPT;\n    rc = SQLITE_ERROR;\n    sqlite3VdbeError(p, sqlite3ErrStr(p->rc));\n  }else{\n    char *zP4;\n    Op *pOp;\n    if( i<p->nOp ){\n      /* The output line number is small enough that we are still in the\n      ** main program. */\n      pOp = &p->aOp[i];\n    }else{\n      /* We are currently listing subprograms.  Figure out which one and\n      ** pick up the appropriate opcode. */\n      int j;\n      i -= p->nOp;\n      for(j=0; i>=apSub[j]->nOp; j++){\n        i -= apSub[j]->nOp;\n      }\n      pOp = &apSub[j]->aOp[i];\n    }\n    if( p->explain==1 ){\n      pMem->flags = MEM_Int;\n      pMem->u.i = i;                                /* Program counter */\n      pMem++;\n  \n      pMem->flags = MEM_Static|MEM_Str|MEM_Term;\n      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n\n      /* When an OP_Program opcode is encounter (the only opcode that has\n      ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms\n      ** kept in p->aMem[9].z to hold the new program - assuming this subprogram\n      ** has not already been seen.\n      */\n      if( pOp->p4type==P4_SUBPROGRAM ){\n        int nByte = (nSub+1)*sizeof(SubProgram*);\n        int j;\n        for(j=0; j<nSub; j++){\n          if( apSub[j]==pOp->p4.pProgram ) break;\n        }\n        if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){\n          apSub = (SubProgram **)pSub->z;\n          apSub[nSub++] = pOp->p4.pProgram;\n          pSub->flags |= MEM_Blob;\n          pSub->n = nSub*sizeof(SubProgram*);\n        }\n      }\n    }\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p1;                          /* P1 */\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p2;                          /* P2 */\n    pMem++;\n\n    pMem->flags = MEM_Int;\n    pMem->u.i = pOp->p3;                          /* P3 */\n    pMem++;\n\n    if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */\n      assert( p->db->mallocFailed );\n      return SQLITE_ERROR;\n    }\n    pMem->flags = MEM_Str|MEM_Term;\n    zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);\n    if( zP4!=pMem->z ){\n      pMem->n = 0;\n      sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);\n    }else{\n      assert( pMem->z!=0 );\n      pMem->n = sqlite3Strlen30(pMem->z);\n      pMem->enc = SQLITE_UTF8;\n    }\n    pMem++;\n\n    if( p->explain==1 ){\n      if( sqlite3VdbeMemClearAndResize(pMem, 4) ){\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Str|MEM_Term;\n      pMem->n = 2;\n      sqlite3_snprintf(3, pMem->z, \"%.2x\", pOp->p5);   /* P5 */\n      pMem->enc = SQLITE_UTF8;\n      pMem++;\n  \n#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS\n      if( sqlite3VdbeMemClearAndResize(pMem, 500) ){\n        assert( p->db->mallocFailed );\n        return SQLITE_ERROR;\n      }\n      pMem->flags = MEM_Str|MEM_Term;\n      pMem->n = displayComment(pOp, zP4, pMem->z, 500);\n      pMem->enc = SQLITE_UTF8;\n#else\n      pMem->flags = MEM_Null;                       /* Comment */\n#endif\n    }\n\n    p->nResColumn = 8 - 4*(p->explain-1);\n    p->pResultSet = &p->aMem[1];\n    p->rc = SQLITE_OK;\n    rc = SQLITE_ROW;\n  }\n  return rc;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_DEBUG\n/*\n** Print the SQL that was used to generate a VDBE program.\n*/\nvoid sqlite3VdbePrintSql(Vdbe *p){\n  const char *z = 0;\n  if( p->zSql ){\n    z = p->zSql;\n  }else if( p->nOp>=1 ){\n    const VdbeOp *pOp = &p->aOp[0];\n    if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n      z = pOp->p4.z;\n      while( sqlite3Isspace(*z) ) z++;\n    }\n  }\n  if( z ) printf(\"SQL: [%s]\\n\", z);\n}\n#endif\n\n#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)\n/*\n** Print an IOTRACE message showing SQL content.\n*/\nvoid sqlite3VdbeIOTraceSql(Vdbe *p){\n  int nOp = p->nOp;\n  VdbeOp *pOp;\n  if( sqlite3IoTrace==0 ) return;\n  if( nOp<1 ) return;\n  pOp = &p->aOp[0];\n  if( pOp->opcode==OP_Init && pOp->p4.z!=0 ){\n    int i, j;\n    char z[1000];\n    sqlite3_snprintf(sizeof(z), z, \"%s\", pOp->p4.z);\n    for(i=0; sqlite3Isspace(z[i]); i++){}\n    for(j=0; z[i]; i++){\n      if( sqlite3Isspace(z[i]) ){\n        if( z[i-1]!=' ' ){\n          z[j++] = ' ';\n        }\n      }else{\n        z[j++] = z[i];\n      }\n    }\n    z[j] = 0;\n    sqlite3IoTrace(\"SQL %s\\n\", z);\n  }\n}\n#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */\n\n/* An instance of this object describes bulk memory available for use\n** by subcomponents of a prepared statement.  Space is allocated out\n** of a ReusableSpace object by the allocSpace() routine below.\n*/\nstruct ReusableSpace {\n  u8 *pSpace;          /* Available memory */\n  int nFree;           /* Bytes of available memory */\n  int nNeeded;         /* Total bytes that could not be allocated */\n};\n\n/* Try to allocate nByte bytes of 8-byte aligned bulk memory for pBuf\n** from the ReusableSpace object.  Return a pointer to the allocated\n** memory on success.  If insufficient memory is available in the\n** ReusableSpace object, increase the ReusableSpace.nNeeded\n** value by the amount needed and return NULL.\n**\n** If pBuf is not initially NULL, that means that the memory has already\n** been allocated by a prior call to this routine, so just return a copy\n** of pBuf and leave ReusableSpace unchanged.\n**\n** This allocator is employed to repurpose unused slots at the end of the\n** opcode array of prepared state for other memory needs of the prepared\n** statement.\n*/\nstatic void *allocSpace(\n  struct ReusableSpace *p,  /* Bulk memory available for allocation */\n  void *pBuf,               /* Pointer to a prior allocation */\n  int nByte                 /* Bytes of memory needed */\n){\n  assert( EIGHT_BYTE_ALIGNMENT(p->pSpace) );\n  if( pBuf==0 ){\n    nByte = ROUND8(nByte);\n    if( nByte <= p->nFree ){\n      p->nFree -= nByte;\n      pBuf = &p->pSpace[p->nFree];\n    }else{\n      p->nNeeded += nByte;\n    }\n  }\n  assert( EIGHT_BYTE_ALIGNMENT(pBuf) );\n  return pBuf;\n}\n\n/*\n** Rewind the VDBE back to the beginning in preparation for\n** running it.\n*/\nvoid sqlite3VdbeRewind(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n  assert( p!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET );\n\n  /* There should be at least one opcode.\n  */\n  assert( p->nOp>0 );\n\n  /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */\n  p->magic = VDBE_MAGIC_RUN;\n\n#ifdef SQLITE_DEBUG\n  for(i=0; i<p->nMem; i++){\n    assert( p->aMem[i].db==p->db );\n  }\n#endif\n  p->pc = -1;\n  p->rc = SQLITE_OK;\n  p->errorAction = OE_Abort;\n  p->nChange = 0;\n  p->cacheCtr = 1;\n  p->minWriteFileFormat = 255;\n  p->iStatement = 0;\n  p->nFkConstraint = 0;\n#ifdef VDBE_PROFILE\n  for(i=0; i<p->nOp; i++){\n    p->aOp[i].cnt = 0;\n    p->aOp[i].cycles = 0;\n  }\n#endif\n}\n\n/*\n** Prepare a virtual machine for execution for the first time after\n** creating the virtual machine.  This involves things such\n** as allocating registers and initializing the program counter.\n** After the VDBE has be prepped, it can be executed by one or more\n** calls to sqlite3VdbeExec().  \n**\n** This function may be called exactly once on each virtual machine.\n** After this routine is called the VM has been \"packaged\" and is ready\n** to run.  After this routine is called, further calls to \n** sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects\n** the Vdbe from the Parse object that helped generate it so that the\n** the Vdbe becomes an independent entity and the Parse object can be\n** destroyed.\n**\n** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back\n** to its initial state after it has been run.\n*/\nvoid sqlite3VdbeMakeReady(\n  Vdbe *p,                       /* The VDBE */\n  Parse *pParse                  /* Parsing context */\n){\n  sqlite3 *db;                   /* The database connection */\n  int nVar;                      /* Number of parameters */\n  int nMem;                      /* Number of VM memory registers */\n  int nCursor;                   /* Number of cursors required */\n  int nArg;                      /* Number of arguments in subprograms */\n  int n;                         /* Loop counter */\n  struct ReusableSpace x;        /* Reusable bulk memory */\n\n  assert( p!=0 );\n  assert( p->nOp>0 );\n  assert( pParse!=0 );\n  assert( p->magic==VDBE_MAGIC_INIT );\n  assert( pParse==p->pParse );\n  db = p->db;\n  assert( db->mallocFailed==0 );\n  nVar = pParse->nVar;\n  nMem = pParse->nMem;\n  nCursor = pParse->nTab;\n  nArg = pParse->nMaxArg;\n  \n  /* Each cursor uses a memory cell.  The first cursor (cursor 0) can\n  ** use aMem[0] which is not otherwise used by the VDBE program.  Allocate\n  ** space at the end of aMem[] for cursors 1 and greater.\n  ** See also: allocateCursor().\n  */\n  nMem += nCursor;\n  if( nCursor==0 && nMem>0 ) nMem++;  /* Space for aMem[0] even if not used */\n\n  /* Figure out how much reusable memory is available at the end of the\n  ** opcode array.  This extra memory will be reallocated for other elements\n  ** of the prepared statement.\n  */\n  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */\n  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */\n  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );\n  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */\n  assert( x.nFree>=0 );\n  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );\n\n  resolveP2Values(p, &nArg);\n  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);\n  if( pParse->explain && nMem<10 ){\n    nMem = 10;\n  }\n  p->expired = 0;\n\n  /* Memory for registers, parameters, cursor, etc, is allocated in one or two\n  ** passes.  On the first pass, we try to reuse unused memory at the \n  ** end of the opcode array.  If we are unable to satisfy all memory\n  ** requirements by reusing the opcode array tail, then the second\n  ** pass will fill in the remainder using a fresh memory allocation.  \n  **\n  ** This two-pass approach that reuses as much memory as possible from\n  ** the leftover memory at the end of the opcode array.  This can significantly\n  ** reduce the amount of memory held by a prepared statement.\n  */\n  do {\n    x.nNeeded = 0;\n    p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));\n    p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));\n    p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));\n    p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));\n#endif\n    if( x.nNeeded==0 ) break;\n    x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);\n    x.nFree = x.nNeeded;\n  }while( !db->mallocFailed );\n\n  p->pVList = pParse->pVList;\n  pParse->pVList =  0;\n  p->explain = pParse->explain;\n  if( db->mallocFailed ){\n    p->nVar = 0;\n    p->nCursor = 0;\n    p->nMem = 0;\n  }else{\n    p->nCursor = nCursor;\n    p->nVar = (ynVar)nVar;\n    initMemArray(p->aVar, nVar, db, MEM_Null);\n    p->nMem = nMem;\n    initMemArray(p->aMem, nMem, db, MEM_Undefined);\n    memset(p->apCsr, 0, nCursor*sizeof(VdbeCursor*));\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n    memset(p->anExec, 0, p->nOp*sizeof(i64));\n#endif\n  }\n  sqlite3VdbeRewind(p);\n}\n\n/*\n** Close a VDBE cursor and release all the resources that cursor \n** happens to hold.\n*/\nvoid sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){\n  if( pCx==0 ){\n    return;\n  }\n  assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );\n  switch( pCx->eCurType ){\n    case CURTYPE_SORTER: {\n      sqlite3VdbeSorterClose(p->db, pCx);\n      break;\n    }\n    case CURTYPE_BTREE: {\n      if( pCx->isEphemeral ){\n        if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx);\n        /* The pCx->pCursor will be close automatically, if it exists, by\n        ** the call above. */\n      }else{\n        assert( pCx->uc.pCursor!=0 );\n        sqlite3BtreeCloseCursor(pCx->uc.pCursor);\n      }\n      break;\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    case CURTYPE_VTAB: {\n      sqlite3_vtab_cursor *pVCur = pCx->uc.pVCur;\n      const sqlite3_module *pModule = pVCur->pVtab->pModule;\n      assert( pVCur->pVtab->nRef>0 );\n      pVCur->pVtab->nRef--;\n      pModule->xClose(pVCur);\n      break;\n    }\n#endif\n  }\n}\n\n/*\n** Close all cursors in the current frame.\n*/\nstatic void closeCursorsInFrame(Vdbe *p){\n  if( p->apCsr ){\n    int i;\n    for(i=0; i<p->nCursor; i++){\n      VdbeCursor *pC = p->apCsr[i];\n      if( pC ){\n        sqlite3VdbeFreeCursor(p, pC);\n        p->apCsr[i] = 0;\n      }\n    }\n  }\n}\n\n/*\n** Copy the values stored in the VdbeFrame structure to its Vdbe. This\n** is used, for example, when a trigger sub-program is halted to restore\n** control to the main program.\n*/\nint sqlite3VdbeFrameRestore(VdbeFrame *pFrame){\n  Vdbe *v = pFrame->v;\n  closeCursorsInFrame(v);\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  v->anExec = pFrame->anExec;\n#endif\n  v->aOp = pFrame->aOp;\n  v->nOp = pFrame->nOp;\n  v->aMem = pFrame->aMem;\n  v->nMem = pFrame->nMem;\n  v->apCsr = pFrame->apCsr;\n  v->nCursor = pFrame->nCursor;\n  v->db->lastRowid = pFrame->lastRowid;\n  v->nChange = pFrame->nChange;\n  v->db->nChange = pFrame->nDbChange;\n  sqlite3VdbeDeleteAuxData(v->db, &v->pAuxData, -1, 0);\n  v->pAuxData = pFrame->pAuxData;\n  pFrame->pAuxData = 0;\n  return pFrame->pc;\n}\n\n/*\n** Close all cursors.\n**\n** Also release any dynamic memory held by the VM in the Vdbe.aMem memory \n** cell array. This is necessary as the memory cell array may contain\n** pointers to VdbeFrame objects, which may in turn contain pointers to\n** open cursors.\n*/\nstatic void closeAllCursors(Vdbe *p){\n  if( p->pFrame ){\n    VdbeFrame *pFrame;\n    for(pFrame=p->pFrame; pFrame->pParent; pFrame=pFrame->pParent);\n    sqlite3VdbeFrameRestore(pFrame);\n    p->pFrame = 0;\n    p->nFrame = 0;\n  }\n  assert( p->nFrame==0 );\n  closeCursorsInFrame(p);\n  if( p->aMem ){\n    releaseMemArray(p->aMem, p->nMem);\n  }\n  while( p->pDelFrame ){\n    VdbeFrame *pDel = p->pDelFrame;\n    p->pDelFrame = pDel->pParent;\n    sqlite3VdbeFrameDelete(pDel);\n  }\n\n  /* Delete any auxdata allocations made by the VM */\n  if( p->pAuxData ) sqlite3VdbeDeleteAuxData(p->db, &p->pAuxData, -1, 0);\n  assert( p->pAuxData==0 );\n}\n\n/*\n** Set the number of result columns that will be returned by this SQL\n** statement. This is now set at compile time, rather than during\n** execution of the vdbe program so that sqlite3_column_count() can\n** be called on an SQL statement before sqlite3_step().\n*/\nvoid sqlite3VdbeSetNumCols(Vdbe *p, int nResColumn){\n  int n;\n  sqlite3 *db = p->db;\n\n  if( p->nResColumn ){\n    releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n    sqlite3DbFree(db, p->aColName);\n  }\n  n = nResColumn*COLNAME_N;\n  p->nResColumn = (u16)nResColumn;\n  p->aColName = (Mem*)sqlite3DbMallocRawNN(db, sizeof(Mem)*n );\n  if( p->aColName==0 ) return;\n  initMemArray(p->aColName, n, db, MEM_Null);\n}\n\n/*\n** Set the name of the idx'th column to be returned by the SQL statement.\n** zName must be a pointer to a nul terminated string.\n**\n** This call must be made after a call to sqlite3VdbeSetNumCols().\n**\n** The final parameter, xDel, must be one of SQLITE_DYNAMIC, SQLITE_STATIC\n** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed\n** to by zName will be freed by sqlite3DbFree() when the vdbe is destroyed.\n*/\nint sqlite3VdbeSetColName(\n  Vdbe *p,                         /* Vdbe being configured */\n  int idx,                         /* Index of column zName applies to */\n  int var,                         /* One of the COLNAME_* constants */\n  const char *zName,               /* Pointer to buffer containing name */\n  void (*xDel)(void*)              /* Memory management strategy for zName */\n){\n  int rc;\n  Mem *pColName;\n  assert( idx<p->nResColumn );\n  assert( var<COLNAME_N );\n  if( p->db->mallocFailed ){\n    assert( !zName || xDel!=SQLITE_DYNAMIC );\n    return SQLITE_NOMEM_BKPT;\n  }\n  assert( p->aColName!=0 );\n  pColName = &(p->aColName[idx+var*p->nResColumn]);\n  rc = sqlite3VdbeMemSetStr(pColName, zName, -1, SQLITE_UTF8, xDel);\n  assert( rc!=0 || !zName || (pColName->flags&MEM_Term)!=0 );\n  return rc;\n}\n\n/*\n** A read or write transaction may or may not be active on database handle\n** db. If a transaction is active, commit it. If there is a\n** write-transaction spanning more than one database file, this routine\n** takes care of the master journal trickery.\n*/\nstatic int vdbeCommit(sqlite3 *db, Vdbe *p){\n  int i;\n  int nTrans = 0;  /* Number of databases with an active write-transaction\n                   ** that are candidates for a two-phase commit using a\n                   ** master-journal */\n  int rc = SQLITE_OK;\n  int needXcommit = 0;\n\n#ifdef SQLITE_OMIT_VIRTUALTABLE\n  /* With this option, sqlite3VtabSync() is defined to be simply \n  ** SQLITE_OK so p is not used. \n  */\n  UNUSED_PARAMETER(p);\n#endif\n\n  /* Before doing anything else, call the xSync() callback for any\n  ** virtual module tables written in this transaction. This has to\n  ** be done before determining whether a master journal file is \n  ** required, as an xSync() callback may add an attached database\n  ** to the transaction.\n  */\n  rc = sqlite3VtabSync(db, p);\n\n  /* This loop determines (a) if the commit hook should be invoked and\n  ** (b) how many database files have open write transactions, not \n  ** including the temp database. (b) is important because if more than \n  ** one database file has an open write transaction, a master journal\n  ** file is required for an atomic commit.\n  */ \n  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n    Btree *pBt = db->aDb[i].pBt;\n    if( sqlite3BtreeIsInTrans(pBt) ){\n      /* Whether or not a database might need a master journal depends upon\n      ** its journal mode (among other things).  This matrix determines which\n      ** journal modes use a master journal and which do not */\n      static const u8 aMJNeeded[] = {\n        /* DELETE   */  1,\n        /* PERSIST   */ 1,\n        /* OFF       */ 0,\n        /* TRUNCATE  */ 1,\n        /* MEMORY    */ 0,\n        /* WAL       */ 0\n      };\n      Pager *pPager;   /* Pager associated with pBt */\n      needXcommit = 1;\n      sqlite3BtreeEnter(pBt);\n      pPager = sqlite3BtreePager(pBt);\n      if( db->aDb[i].safety_level!=PAGER_SYNCHRONOUS_OFF\n       && aMJNeeded[sqlite3PagerGetJournalMode(pPager)]\n      ){ \n        assert( i!=1 );\n        nTrans++;\n      }\n      rc = sqlite3PagerExclusiveLock(pPager);\n      sqlite3BtreeLeave(pBt);\n    }\n  }\n  if( rc!=SQLITE_OK ){\n    return rc;\n  }\n\n  /* If there are any write-transactions at all, invoke the commit hook */\n  if( needXcommit && db->xCommitCallback ){\n    rc = db->xCommitCallback(db->pCommitArg);\n    if( rc ){\n      return SQLITE_CONSTRAINT_COMMITHOOK;\n    }\n  }\n\n  /* The simple case - no more than one database file (not counting the\n  ** TEMP database) has a transaction active.   There is no need for the\n  ** master-journal.\n  **\n  ** If the return value of sqlite3BtreeGetFilename() is a zero length\n  ** string, it means the main database is :memory: or a temp file.  In \n  ** that case we do not support atomic multi-file commits, so use the \n  ** simple case then too.\n  */\n  if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))\n   || nTrans<=1\n  ){\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, 0);\n      }\n    }\n\n    /* Do the commit only if all databases successfully complete phase 1. \n    ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an\n    ** IO error while deleting or truncating a journal file. It is unlikely,\n    ** but could happen. In this case abandon processing and return the error.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      sqlite3VtabCommit(db);\n    }\n  }\n\n  /* The complex case - There is a multi-file write-transaction active.\n  ** This requires a master journal file to ensure the transaction is\n  ** committed atomically.\n  */\n#ifndef SQLITE_OMIT_DISKIO\n  else{\n    sqlite3_vfs *pVfs = db->pVfs;\n    char *zMaster = 0;   /* File-name for the master journal */\n    char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);\n    sqlite3_file *pMaster = 0;\n    i64 offset = 0;\n    int res;\n    int retryCount = 0;\n    int nMainFile;\n\n    /* Select a master journal file name */\n    nMainFile = sqlite3Strlen30(zMainFile);\n    zMaster = sqlite3MPrintf(db, \"%s-mjXXXXXX9XXz\", zMainFile);\n    if( zMaster==0 ) return SQLITE_NOMEM_BKPT;\n    do {\n      u32 iRandom;\n      if( retryCount ){\n        if( retryCount>100 ){\n          sqlite3_log(SQLITE_FULL, \"MJ delete: %s\", zMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          break;\n        }else if( retryCount==1 ){\n          sqlite3_log(SQLITE_FULL, \"MJ collide: %s\", zMaster);\n        }\n      }\n      retryCount++;\n      sqlite3_randomness(sizeof(iRandom), &iRandom);\n      sqlite3_snprintf(13, &zMaster[nMainFile], \"-mj%06X9%02X\",\n                               (iRandom>>8)&0xffffff, iRandom&0xff);\n      /* The antipenultimate character of the master journal name must\n      ** be \"9\" to avoid name collisions when using 8+3 filenames. */\n      assert( zMaster[sqlite3Strlen30(zMaster)-3]=='9' );\n      sqlite3FileSuffix3(zMainFile, zMaster);\n      rc = sqlite3OsAccess(pVfs, zMaster, SQLITE_ACCESS_EXISTS, &res);\n    }while( rc==SQLITE_OK && res );\n    if( rc==SQLITE_OK ){\n      /* Open the master journal. */\n      rc = sqlite3OsOpenMalloc(pVfs, zMaster, &pMaster, \n          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|\n          SQLITE_OPEN_EXCLUSIVE|SQLITE_OPEN_MASTER_JOURNAL, 0\n      );\n    }\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n \n    /* Write the name of each database file in the transaction into the new\n    ** master journal file. If an error occurs at this point close\n    ** and delete the master journal file. All the individual journal files\n    ** still have 'null' as the master journal pointer, so they will roll\n    ** back independently if a failure occurs.\n    */\n    for(i=0; i<db->nDb; i++){\n      Btree *pBt = db->aDb[i].pBt;\n      if( sqlite3BtreeIsInTrans(pBt) ){\n        char const *zFile = sqlite3BtreeGetJournalname(pBt);\n        if( zFile==0 ){\n          continue;  /* Ignore TEMP and :memory: databases */\n        }\n        assert( zFile[0]!=0 );\n        rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);\n        offset += sqlite3Strlen30(zFile)+1;\n        if( rc!=SQLITE_OK ){\n          sqlite3OsCloseFree(pMaster);\n          sqlite3OsDelete(pVfs, zMaster, 0);\n          sqlite3DbFree(db, zMaster);\n          return rc;\n        }\n      }\n    }\n\n    /* Sync the master journal file. If the IOCAP_SEQUENTIAL device\n    ** flag is set this is not required.\n    */\n    if( 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)\n     && SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))\n    ){\n      sqlite3OsCloseFree(pMaster);\n      sqlite3OsDelete(pVfs, zMaster, 0);\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Sync all the db files involved in the transaction. The same call\n    ** sets the master journal pointer in each individual journal. If\n    ** an error occurs here, do not delete the master journal file.\n    **\n    ** If the error occurs during the first call to\n    ** sqlite3BtreeCommitPhaseOne(), then there is a chance that the\n    ** master journal file will be orphaned. But we cannot delete it,\n    ** in case the master journal file name was written into the journal\n    ** file before the failure occurred.\n    */\n    for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        rc = sqlite3BtreeCommitPhaseOne(pBt, zMaster);\n      }\n    }\n    sqlite3OsCloseFree(pMaster);\n    assert( rc!=SQLITE_BUSY );\n    if( rc!=SQLITE_OK ){\n      sqlite3DbFree(db, zMaster);\n      return rc;\n    }\n\n    /* Delete the master journal file. This commits the transaction. After\n    ** doing this the directory is synced again before any individual\n    ** transaction files are deleted.\n    */\n    rc = sqlite3OsDelete(pVfs, zMaster, 1);\n    sqlite3DbFree(db, zMaster);\n    zMaster = 0;\n    if( rc ){\n      return rc;\n    }\n\n    /* All files and directories have already been synced, so the following\n    ** calls to sqlite3BtreeCommitPhaseTwo() are only closing files and\n    ** deleting or truncating journals. If something goes wrong while\n    ** this is happening we don't really care. The integrity of the\n    ** transaction is already guaranteed, but some stray 'cold' journals\n    ** may be lying around. Returning an error code won't help matters.\n    */\n    disable_simulated_io_errors();\n    sqlite3BeginBenignMalloc();\n    for(i=0; i<db->nDb; i++){ \n      Btree *pBt = db->aDb[i].pBt;\n      if( pBt ){\n        sqlite3BtreeCommitPhaseTwo(pBt, 1);\n      }\n    }\n    sqlite3EndBenignMalloc();\n    enable_simulated_io_errors();\n\n    sqlite3VtabCommit(db);\n  }\n#endif\n\n  return rc;\n}\n\n/* \n** This routine checks that the sqlite3.nVdbeActive count variable\n** matches the number of vdbe's in the list sqlite3.pVdbe that are\n** currently active. An assertion fails if the two counts do not match.\n** This is an internal self-check only - it is not an essential processing\n** step.\n**\n** This is a no-op if NDEBUG is defined.\n*/\n#ifndef NDEBUG\nstatic void checkActiveVdbeCnt(sqlite3 *db){\n  Vdbe *p;\n  int cnt = 0;\n  int nWrite = 0;\n  int nRead = 0;\n  p = db->pVdbe;\n  while( p ){\n    if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){\n      cnt++;\n      if( p->readOnly==0 ) nWrite++;\n      if( p->bIsReader ) nRead++;\n    }\n    p = p->pNext;\n  }\n  assert( cnt==db->nVdbeActive );\n  assert( nWrite==db->nVdbeWrite );\n  assert( nRead==db->nVdbeRead );\n}\n#else\n#define checkActiveVdbeCnt(x)\n#endif\n\n/*\n** If the Vdbe passed as the first argument opened a statement-transaction,\n** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or\n** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement\n** transaction is rolled back. If eOp is SAVEPOINT_RELEASE, then the \n** statement transaction is committed.\n**\n** If an IO error occurs, an SQLITE_IOERR_XXX error code is returned. \n** Otherwise SQLITE_OK.\n*/\nstatic SQLITE_NOINLINE int vdbeCloseStatement(Vdbe *p, int eOp){\n  sqlite3 *const db = p->db;\n  int rc = SQLITE_OK;\n  int i;\n  const int iSavepoint = p->iStatement-1;\n\n  assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);\n  assert( db->nStatement>0 );\n  assert( p->iStatement==(db->nStatement+db->nSavepoint) );\n\n  for(i=0; i<db->nDb; i++){ \n    int rc2 = SQLITE_OK;\n    Btree *pBt = db->aDb[i].pBt;\n    if( pBt ){\n      if( eOp==SAVEPOINT_ROLLBACK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);\n      }\n      if( rc2==SQLITE_OK ){\n        rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);\n      }\n      if( rc==SQLITE_OK ){\n        rc = rc2;\n      }\n    }\n  }\n  db->nStatement--;\n  p->iStatement = 0;\n\n  if( rc==SQLITE_OK ){\n    if( eOp==SAVEPOINT_ROLLBACK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);\n    }\n    if( rc==SQLITE_OK ){\n      rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);\n    }\n  }\n\n  /* If the statement transaction is being rolled back, also restore the \n  ** database handles deferred constraint counter to the value it had when \n  ** the statement transaction was opened.  */\n  if( eOp==SAVEPOINT_ROLLBACK ){\n    db->nDeferredCons = p->nStmtDefCons;\n    db->nDeferredImmCons = p->nStmtDefImmCons;\n  }\n  return rc;\n}\nint sqlite3VdbeCloseStatement(Vdbe *p, int eOp){\n  if( p->db->nStatement && p->iStatement ){\n    return vdbeCloseStatement(p, eOp);\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** This function is called when a transaction opened by the database \n** handle associated with the VM passed as an argument is about to be \n** committed. If there are outstanding deferred foreign key constraint\n** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.\n**\n** If there are outstanding FK violations and this function returns \n** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY\n** and write an error message to it. Then return SQLITE_ERROR.\n*/\n#ifndef SQLITE_OMIT_FOREIGN_KEY\nint sqlite3VdbeCheckFk(Vdbe *p, int deferred){\n  sqlite3 *db = p->db;\n  if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) \n   || (!deferred && p->nFkConstraint>0) \n  ){\n    p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n    p->errorAction = OE_Abort;\n    sqlite3VdbeError(p, \"FOREIGN KEY constraint failed\");\n    return SQLITE_ERROR;\n  }\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** This routine is called the when a VDBE tries to halt.  If the VDBE\n** has made changes and is in autocommit mode, then commit those\n** changes.  If a rollback is needed, then do the rollback.\n**\n** This routine is the only way to move the state of a VM from\n** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT.  It is harmless to\n** call this on a VM that is in the SQLITE_MAGIC_HALT state.\n**\n** Return an error code.  If the commit could not complete because of\n** lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it\n** means the close did not happen and needs to be repeated.\n*/\nint sqlite3VdbeHalt(Vdbe *p){\n  int rc;                         /* Used to store transient return codes */\n  sqlite3 *db = p->db;\n\n  /* This function contains the logic that determines if a statement or\n  ** transaction will be committed or rolled back as a result of the\n  ** execution of this virtual machine. \n  **\n  ** If any of the following errors occur:\n  **\n  **     SQLITE_NOMEM\n  **     SQLITE_IOERR\n  **     SQLITE_FULL\n  **     SQLITE_INTERRUPT\n  **\n  ** Then the internal cache might have been left in an inconsistent\n  ** state.  We need to rollback the statement transaction, if there is\n  ** one, or the complete transaction if there is no statement transaction.\n  */\n\n  if( p->magic!=VDBE_MAGIC_RUN ){\n    return SQLITE_OK;\n  }\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n  closeAllCursors(p);\n  checkActiveVdbeCnt(db);\n\n  /* No commit or rollback needed if the program never started or if the\n  ** SQL statement does not read or write a database file.  */\n  if( p->pc>=0 && p->bIsReader ){\n    int mrc;   /* Primary error code from p->rc */\n    int eStatementOp = 0;\n    int isSpecialError;            /* Set to true if a 'special' error */\n\n    /* Lock all btrees used by the statement */\n    sqlite3VdbeEnter(p);\n\n    /* Check for one of the special errors */\n    mrc = p->rc & 0xff;\n    isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR\n                     || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL;\n    if( isSpecialError ){\n      /* If the query was read-only and the error code is SQLITE_INTERRUPT, \n      ** no rollback is necessary. Otherwise, at least a savepoint \n      ** transaction must be rolled back to restore the database to a \n      ** consistent state.\n      **\n      ** Even if the statement is read-only, it is important to perform\n      ** a statement or transaction rollback operation. If the error \n      ** occurred while writing to the journal, sub-journal or database\n      ** file as part of an effort to free up cache space (see function\n      ** pagerStress() in pager.c), the rollback is required to restore \n      ** the pager to a consistent state.\n      */\n      if( !p->readOnly || mrc!=SQLITE_INTERRUPT ){\n        if( (mrc==SQLITE_NOMEM || mrc==SQLITE_FULL) && p->usesStmtJournal ){\n          eStatementOp = SAVEPOINT_ROLLBACK;\n        }else{\n          /* We are forced to roll back the active transaction. Before doing\n          ** so, abort any other statements this handle currently has active.\n          */\n          sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n          sqlite3CloseSavepoints(db);\n          db->autoCommit = 1;\n          p->nChange = 0;\n        }\n      }\n    }\n\n    /* Check for immediate foreign key violations. */\n    if( p->rc==SQLITE_OK ){\n      sqlite3VdbeCheckFk(p, 0);\n    }\n  \n    /* If the auto-commit flag is set and this is the only active writer \n    ** VM, then we do either a commit or rollback of the current transaction. \n    **\n    ** Note: This block also runs if one of the special errors handled \n    ** above has occurred. \n    */\n    if( !sqlite3VtabInSync(db) \n     && db->autoCommit \n     && db->nVdbeWrite==(p->readOnly==0) \n    ){\n      if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){\n        rc = sqlite3VdbeCheckFk(p, 1);\n        if( rc!=SQLITE_OK ){\n          if( NEVER(p->readOnly) ){\n            sqlite3VdbeLeave(p);\n            return SQLITE_ERROR;\n          }\n          rc = SQLITE_CONSTRAINT_FOREIGNKEY;\n        }else{ \n          /* The auto-commit flag is true, the vdbe program was successful \n          ** or hit an 'OR FAIL' constraint and there are no deferred foreign\n          ** key constraints to hold up the transaction. This means a commit \n          ** is required. */\n          rc = vdbeCommit(db, p);\n        }\n        if( rc==SQLITE_BUSY && p->readOnly ){\n          sqlite3VdbeLeave(p);\n          return SQLITE_BUSY;\n        }else if( rc!=SQLITE_OK ){\n          p->rc = rc;\n          sqlite3RollbackAll(db, SQLITE_OK);\n          p->nChange = 0;\n        }else{\n          db->nDeferredCons = 0;\n          db->nDeferredImmCons = 0;\n          db->flags &= ~SQLITE_DeferFKs;\n          sqlite3CommitInternalChanges(db);\n        }\n      }else{\n        sqlite3RollbackAll(db, SQLITE_OK);\n        p->nChange = 0;\n      }\n      db->nStatement = 0;\n    }else if( eStatementOp==0 ){\n      if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){\n        eStatementOp = SAVEPOINT_RELEASE;\n      }else if( p->errorAction==OE_Abort ){\n        eStatementOp = SAVEPOINT_ROLLBACK;\n      }else{\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If eStatementOp is non-zero, then a statement transaction needs to\n    ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to\n    ** do so. If this operation returns an error, and the current statement\n    ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the\n    ** current statement error code.\n    */\n    if( eStatementOp ){\n      rc = sqlite3VdbeCloseStatement(p, eStatementOp);\n      if( rc ){\n        if( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_CONSTRAINT ){\n          p->rc = rc;\n          sqlite3DbFree(db, p->zErrMsg);\n          p->zErrMsg = 0;\n        }\n        sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);\n        sqlite3CloseSavepoints(db);\n        db->autoCommit = 1;\n        p->nChange = 0;\n      }\n    }\n  \n    /* If this was an INSERT, UPDATE or DELETE and no statement transaction\n    ** has been rolled back, update the database connection change-counter. \n    */\n    if( p->changeCntOn ){\n      if( eStatementOp!=SAVEPOINT_ROLLBACK ){\n        sqlite3VdbeSetChanges(db, p->nChange);\n      }else{\n        sqlite3VdbeSetChanges(db, 0);\n      }\n      p->nChange = 0;\n    }\n\n    /* Release the locks */\n    sqlite3VdbeLeave(p);\n  }\n\n  /* We have successfully halted and closed the VM.  Record this fact. */\n  if( p->pc>=0 ){\n    db->nVdbeActive--;\n    if( !p->readOnly ) db->nVdbeWrite--;\n    if( p->bIsReader ) db->nVdbeRead--;\n    assert( db->nVdbeActive>=db->nVdbeRead );\n    assert( db->nVdbeRead>=db->nVdbeWrite );\n    assert( db->nVdbeWrite>=0 );\n  }\n  p->magic = VDBE_MAGIC_HALT;\n  checkActiveVdbeCnt(db);\n  if( db->mallocFailed ){\n    p->rc = SQLITE_NOMEM_BKPT;\n  }\n\n  /* If the auto-commit flag is set to true, then any locks that were held\n  ** by connection db have now been released. Call sqlite3ConnectionUnlocked() \n  ** to invoke any required unlock-notify callbacks.\n  */\n  if( db->autoCommit ){\n    sqlite3ConnectionUnlocked(db);\n  }\n\n  assert( db->nVdbeActive>0 || db->autoCommit==0 || db->nStatement==0 );\n  return (p->rc==SQLITE_BUSY ? SQLITE_BUSY : SQLITE_OK);\n}\n\n\n/*\n** Each VDBE holds the result of the most recent sqlite3_step() call\n** in p->rc.  This routine sets that result back to SQLITE_OK.\n*/\nvoid sqlite3VdbeResetStepResult(Vdbe *p){\n  p->rc = SQLITE_OK;\n}\n\n/*\n** Copy the error code and error message belonging to the VDBE passed\n** as the first argument to its database handle (so that they will be \n** returned by calls to sqlite3_errcode() and sqlite3_errmsg()).\n**\n** This function does not clear the VDBE error code or message, just\n** copies them to the database handle.\n*/\nint sqlite3VdbeTransferError(Vdbe *p){\n  sqlite3 *db = p->db;\n  int rc = p->rc;\n  if( p->zErrMsg ){\n    db->bBenignMalloc++;\n    sqlite3BeginBenignMalloc();\n    if( db->pErr==0 ) db->pErr = sqlite3ValueNew(db);\n    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);\n    sqlite3EndBenignMalloc();\n    db->bBenignMalloc--;\n  }else if( db->pErr ){\n    sqlite3ValueSetNull(db->pErr);\n  }\n  db->errCode = rc;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SQLLOG\n/*\n** If an SQLITE_CONFIG_SQLLOG hook is registered and the VM has been run, \n** invoke it.\n*/\nstatic void vdbeInvokeSqllog(Vdbe *v){\n  if( sqlite3GlobalConfig.xSqllog && v->rc==SQLITE_OK && v->zSql && v->pc>=0 ){\n    char *zExpanded = sqlite3VdbeExpandSql(v, v->zSql);\n    assert( v->db->init.busy==0 );\n    if( zExpanded ){\n      sqlite3GlobalConfig.xSqllog(\n          sqlite3GlobalConfig.pSqllogArg, v->db, zExpanded, 1\n      );\n      sqlite3DbFree(v->db, zExpanded);\n    }\n  }\n}\n#else\n# define vdbeInvokeSqllog(x)\n#endif\n\n/*\n** Clean up a VDBE after execution but do not delete the VDBE just yet.\n** Write any error messages into *pzErrMsg.  Return the result code.\n**\n** After this routine is run, the VDBE should be ready to be executed\n** again.\n**\n** To look at it another way, this routine resets the state of the\n** virtual machine from VDBE_MAGIC_RUN or VDBE_MAGIC_HALT back to\n** VDBE_MAGIC_INIT.\n*/\nint sqlite3VdbeReset(Vdbe *p){\n#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)\n  int i;\n#endif\n\n  sqlite3 *db;\n  db = p->db;\n\n  /* If the VM did not run to completion or if it encountered an\n  ** error, then it might not have been halted properly.  So halt\n  ** it now.\n  */\n  sqlite3VdbeHalt(p);\n\n  /* If the VDBE has be run even partially, then transfer the error code\n  ** and error message from the VDBE into the main database structure.  But\n  ** if the VDBE has just been set to run but has not actually executed any\n  ** instructions yet, leave the main database error information unchanged.\n  */\n  if( p->pc>=0 ){\n    vdbeInvokeSqllog(p);\n    sqlite3VdbeTransferError(p);\n    if( p->runOnlyOnce ) p->expired = 1;\n  }else if( p->rc && p->expired ){\n    /* The expired flag was set on the VDBE before the first call\n    ** to sqlite3_step(). For consistency (since sqlite3_step() was\n    ** called), set the database error in this case as well.\n    */\n    sqlite3ErrorWithMsg(db, p->rc, p->zErrMsg ? \"%s\" : 0, p->zErrMsg);\n  }\n\n  /* Reset register contents and reclaim error message memory.\n  */\n#ifdef SQLITE_DEBUG\n  /* Execute assert() statements to ensure that the Vdbe.apCsr[] and \n  ** Vdbe.aMem[] arrays have already been cleaned up.  */\n  if( p->apCsr ) for(i=0; i<p->nCursor; i++) assert( p->apCsr[i]==0 );\n  if( p->aMem ){\n    for(i=0; i<p->nMem; i++) assert( p->aMem[i].flags==MEM_Undefined );\n  }\n#endif\n  sqlite3DbFree(db, p->zErrMsg);\n  p->zErrMsg = 0;\n  p->pResultSet = 0;\n\n  /* Save profiling information from this VDBE run.\n  */\n#ifdef VDBE_PROFILE\n  {\n    FILE *out = fopen(\"vdbe_profile.out\", \"a\");\n    if( out ){\n      fprintf(out, \"---- \");\n      for(i=0; i<p->nOp; i++){\n        fprintf(out, \"%02x\", p->aOp[i].opcode);\n      }\n      fprintf(out, \"\\n\");\n      if( p->zSql ){\n        char c, pc = 0;\n        fprintf(out, \"-- \");\n        for(i=0; (c = p->zSql[i])!=0; i++){\n          if( pc=='\\n' ) fprintf(out, \"-- \");\n          putc(c, out);\n          pc = c;\n        }\n        if( pc!='\\n' ) fprintf(out, \"\\n\");\n      }\n      for(i=0; i<p->nOp; i++){\n        char zHdr[100];\n        sqlite3_snprintf(sizeof(zHdr), zHdr, \"%6u %12llu %8llu \",\n           p->aOp[i].cnt,\n           p->aOp[i].cycles,\n           p->aOp[i].cnt>0 ? p->aOp[i].cycles/p->aOp[i].cnt : 0\n        );\n        fprintf(out, \"%s\", zHdr);\n        sqlite3VdbePrintOp(out, i, &p->aOp[i]);\n      }\n      fclose(out);\n    }\n  }\n#endif\n  p->magic = VDBE_MAGIC_RESET;\n  return p->rc & db->errMask;\n}\n \n/*\n** Clean up and delete a VDBE after execution.  Return an integer which is\n** the result code.  Write any error message text into *pzErrMsg.\n*/\nint sqlite3VdbeFinalize(Vdbe *p){\n  int rc = SQLITE_OK;\n  if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){\n    rc = sqlite3VdbeReset(p);\n    assert( (rc & p->db->errMask)==rc );\n  }\n  sqlite3VdbeDelete(p);\n  return rc;\n}\n\n/*\n** If parameter iOp is less than zero, then invoke the destructor for\n** all auxiliary data pointers currently cached by the VM passed as\n** the first argument.\n**\n** Or, if iOp is greater than or equal to zero, then the destructor is\n** only invoked for those auxiliary data pointers created by the user \n** function invoked by the OP_Function opcode at instruction iOp of \n** VM pVdbe, and only then if:\n**\n**    * the associated function parameter is the 32nd or later (counting\n**      from left to right), or\n**\n**    * the corresponding bit in argument mask is clear (where the first\n**      function parameter corresponds to bit 0 etc.).\n*/\nvoid sqlite3VdbeDeleteAuxData(sqlite3 *db, AuxData **pp, int iOp, int mask){\n  while( *pp ){\n    AuxData *pAux = *pp;\n    if( (iOp<0)\n     || (pAux->iAuxOp==iOp\n          && pAux->iAuxArg>=0\n          && (pAux->iAuxArg>31 || !(mask & MASKBIT32(pAux->iAuxArg))))\n    ){\n      testcase( pAux->iAuxArg==31 );\n      if( pAux->xDeleteAux ){\n        pAux->xDeleteAux(pAux->pAux);\n      }\n      *pp = pAux->pNextAux;\n      sqlite3DbFree(db, pAux);\n    }else{\n      pp= &pAux->pNextAux;\n    }\n  }\n}\n\n/*\n** Free all memory associated with the Vdbe passed as the second argument,\n** except for object itself, which is preserved.\n**\n** The difference between this function and sqlite3VdbeDelete() is that\n** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with\n** the database connection and frees the object itself.\n*/\nvoid sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){\n  SubProgram *pSub, *pNext;\n  assert( p->db==0 || p->db==db );\n  releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);\n  for(pSub=p->pProgram; pSub; pSub=pNext){\n    pNext = pSub->pNext;\n    vdbeFreeOpArray(db, pSub->aOp, pSub->nOp);\n    sqlite3DbFree(db, pSub);\n  }\n  if( p->magic!=VDBE_MAGIC_INIT ){\n    releaseMemArray(p->aVar, p->nVar);\n    sqlite3DbFree(db, p->pVList);\n    sqlite3DbFree(db, p->pFree);\n  }\n  vdbeFreeOpArray(db, p->aOp, p->nOp);\n  sqlite3DbFree(db, p->aColName);\n  sqlite3DbFree(db, p->zSql);\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  {\n    int i;\n    for(i=0; i<p->nScan; i++){\n      sqlite3DbFree(db, p->aScan[i].zName);\n    }\n    sqlite3DbFree(db, p->aScan);\n  }\n#endif\n}\n\n/*\n** Delete an entire VDBE.\n*/\nvoid sqlite3VdbeDelete(Vdbe *p){\n  sqlite3 *db;\n\n  if( NEVER(p==0) ) return;\n  db = p->db;\n  assert( sqlite3_mutex_held(db->mutex) );\n  sqlite3VdbeClearObject(db, p);\n  if( p->pPrev ){\n    p->pPrev->pNext = p->pNext;\n  }else{\n    assert( db->pVdbe==p );\n    db->pVdbe = p->pNext;\n  }\n  if( p->pNext ){\n    p->pNext->pPrev = p->pPrev;\n  }\n  p->magic = VDBE_MAGIC_DEAD;\n  p->db = 0;\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** The cursor \"p\" has a pending seek operation that has not yet been\n** carried out.  Seek the cursor now.  If an error occurs, return\n** the appropriate error code.\n*/\nstatic int SQLITE_NOINLINE handleDeferredMoveto(VdbeCursor *p){\n  int res, rc;\n#ifdef SQLITE_TEST\n  extern int sqlite3_search_count;\n#endif\n  assert( p->deferredMoveto );\n  assert( p->isTable );\n  assert( p->eCurType==CURTYPE_BTREE );\n  rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);\n  if( rc ) return rc;\n  if( res!=0 ) return SQLITE_CORRUPT_BKPT;\n#ifdef SQLITE_TEST\n  sqlite3_search_count++;\n#endif\n  p->deferredMoveto = 0;\n  p->cacheStatus = CACHE_STALE;\n  return SQLITE_OK;\n}\n\n/*\n** Something has moved cursor \"p\" out of place.  Maybe the row it was\n** pointed to was deleted out from under it.  Or maybe the btree was\n** rebalanced.  Whatever the cause, try to restore \"p\" to the place it\n** is supposed to be pointing.  If the row was deleted out from under the\n** cursor, set the cursor to point to a NULL row.\n*/\nstatic int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){\n  int isDifferentRow, rc;\n  assert( p->eCurType==CURTYPE_BTREE );\n  assert( p->uc.pCursor!=0 );\n  assert( sqlite3BtreeCursorHasMoved(p->uc.pCursor) );\n  rc = sqlite3BtreeCursorRestore(p->uc.pCursor, &isDifferentRow);\n  p->cacheStatus = CACHE_STALE;\n  if( isDifferentRow ) p->nullRow = 1;\n  return rc;\n}\n\n/*\n** Check to ensure that the cursor is valid.  Restore the cursor\n** if need be.  Return any I/O error from the restore operation.\n*/\nint sqlite3VdbeCursorRestore(VdbeCursor *p){\n  assert( p->eCurType==CURTYPE_BTREE );\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Make sure the cursor p is ready to read or write the row to which it\n** was last positioned.  Return an error code if an OOM fault or I/O error\n** prevents us from positioning the cursor to its correct position.\n**\n** If a MoveTo operation is pending on the given cursor, then do that\n** MoveTo now.  If no move is pending, check to see if the row has been\n** deleted out from under the cursor and if it has, mark the row as\n** a NULL row.\n**\n** If the cursor is already pointing to the correct row and that row has\n** not been deleted out from under the cursor, then this routine is a no-op.\n*/\nint sqlite3VdbeCursorMoveto(VdbeCursor **pp, int *piCol){\n  VdbeCursor *p = *pp;\n  assert( p->eCurType==CURTYPE_BTREE || p->eCurType==CURTYPE_PSEUDO );\n  if( p->deferredMoveto ){\n    int iMap;\n    if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 ){\n      *pp = p->pAltCursor;\n      *piCol = iMap - 1;\n      return SQLITE_OK;\n    }\n    return handleDeferredMoveto(p);\n  }\n  if( sqlite3BtreeCursorHasMoved(p->uc.pCursor) ){\n    return handleMovedCursor(p);\n  }\n  return SQLITE_OK;\n}\n\n/*\n** The following functions:\n**\n** sqlite3VdbeSerialType()\n** sqlite3VdbeSerialTypeLen()\n** sqlite3VdbeSerialLen()\n** sqlite3VdbeSerialPut()\n** sqlite3VdbeSerialGet()\n**\n** encapsulate the code that serializes values for storage in SQLite\n** data and index records. Each serialized value consists of a\n** 'serial-type' and a blob of data. The serial type is an 8-byte unsigned\n** integer, stored as a varint.\n**\n** In an SQLite index record, the serial type is stored directly before\n** the blob of data that it corresponds to. In a table record, all serial\n** types are stored at the start of the record, and the blobs of data at\n** the end. Hence these functions allow the caller to handle the\n** serial-type and data blob separately.\n**\n** The following table describes the various storage classes for data:\n**\n**   serial type        bytes of data      type\n**   --------------     ---------------    ---------------\n**      0                     0            NULL\n**      1                     1            signed integer\n**      2                     2            signed integer\n**      3                     3            signed integer\n**      4                     4            signed integer\n**      5                     6            signed integer\n**      6                     8            signed integer\n**      7                     8            IEEE float\n**      8                     0            Integer constant 0\n**      9                     0            Integer constant 1\n**     10,11                               reserved for expansion\n**    N>=12 and even       (N-12)/2        BLOB\n**    N>=13 and odd        (N-13)/2        text\n**\n** The 8 and 9 types were added in 3.3.0, file format 4.  Prior versions\n** of SQLite will not understand those serial types.\n*/\n\n/*\n** Return the serial-type for the value stored in pMem.\n*/\nu32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){\n  int flags = pMem->flags;\n  u32 n;\n\n  assert( pLen!=0 );\n  if( flags&MEM_Null ){\n    *pLen = 0;\n    return 0;\n  }\n  if( flags&MEM_Int ){\n    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */\n#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)\n    i64 i = pMem->u.i;\n    u64 u;\n    if( i<0 ){\n      u = ~i;\n    }else{\n      u = i;\n    }\n    if( u<=127 ){\n      if( (i&1)==i && file_format>=4 ){\n        *pLen = 0;\n        return 8+(u32)u;\n      }else{\n        *pLen = 1;\n        return 1;\n      }\n    }\n    if( u<=32767 ){ *pLen = 2; return 2; }\n    if( u<=8388607 ){ *pLen = 3; return 3; }\n    if( u<=2147483647 ){ *pLen = 4; return 4; }\n    if( u<=MAX_6BYTE ){ *pLen = 6; return 5; }\n    *pLen = 8;\n    return 6;\n  }\n  if( flags&MEM_Real ){\n    *pLen = 8;\n    return 7;\n  }\n  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );\n  assert( pMem->n>=0 );\n  n = (u32)pMem->n;\n  if( flags & MEM_Zero ){\n    n += pMem->u.nZero;\n  }\n  *pLen = n;\n  return ((n*2) + 12 + ((flags&MEM_Str)!=0));\n}\n\n/*\n** The sizes for serial types less than 128\n*/\nstatic const u8 sqlite3SmallTypeSizes[] = {\n        /*  0   1   2   3   4   5   6   7   8   9 */   \n/*   0 */   0,  1,  2,  3,  4,  6,  8,  8,  0,  0,\n/*  10 */   0,  0,  0,  0,  1,  1,  2,  2,  3,  3,\n/*  20 */   4,  4,  5,  5,  6,  6,  7,  7,  8,  8,\n/*  30 */   9,  9, 10, 10, 11, 11, 12, 12, 13, 13,\n/*  40 */  14, 14, 15, 15, 16, 16, 17, 17, 18, 18,\n/*  50 */  19, 19, 20, 20, 21, 21, 22, 22, 23, 23,\n/*  60 */  24, 24, 25, 25, 26, 26, 27, 27, 28, 28,\n/*  70 */  29, 29, 30, 30, 31, 31, 32, 32, 33, 33,\n/*  80 */  34, 34, 35, 35, 36, 36, 37, 37, 38, 38,\n/*  90 */  39, 39, 40, 40, 41, 41, 42, 42, 43, 43,\n/* 100 */  44, 44, 45, 45, 46, 46, 47, 47, 48, 48,\n/* 110 */  49, 49, 50, 50, 51, 51, 52, 52, 53, 53,\n/* 120 */  54, 54, 55, 55, 56, 56, 57, 57\n};\n\n/*\n** Return the length of the data corresponding to the supplied serial-type.\n*/\nu32 sqlite3VdbeSerialTypeLen(u32 serial_type){\n  if( serial_type>=128 ){\n    return (serial_type-12)/2;\n  }else{\n    assert( serial_type<12 \n            || sqlite3SmallTypeSizes[serial_type]==(serial_type - 12)/2 );\n    return sqlite3SmallTypeSizes[serial_type];\n  }\n}\nu8 sqlite3VdbeOneByteSerialTypeLen(u8 serial_type){\n  assert( serial_type<128 );\n  return sqlite3SmallTypeSizes[serial_type];  \n}\n\n/*\n** If we are on an architecture with mixed-endian floating \n** points (ex: ARM7) then swap the lower 4 bytes with the \n** upper 4 bytes.  Return the result.\n**\n** For most architectures, this is a no-op.\n**\n** (later):  It is reported to me that the mixed-endian problem\n** on ARM7 is an issue with GCC, not with the ARM7 chip.  It seems\n** that early versions of GCC stored the two words of a 64-bit\n** float in the wrong order.  And that error has been propagated\n** ever since.  The blame is not necessarily with GCC, though.\n** GCC might have just copying the problem from a prior compiler.\n** I am also told that newer versions of GCC that follow a different\n** ABI get the byte order right.\n**\n** Developers using SQLite on an ARM7 should compile and run their\n** application using -DSQLITE_DEBUG=1 at least once.  With DEBUG\n** enabled, some asserts below will ensure that the byte order of\n** floating point values is correct.\n**\n** (2007-08-30)  Frank van Vugt has studied this problem closely\n** and has send his findings to the SQLite developers.  Frank\n** writes that some Linux kernels offer floating point hardware\n** emulation that uses only 32-bit mantissas instead of a full \n** 48-bits as required by the IEEE standard.  (This is the\n** CONFIG_FPE_FASTFPE option.)  On such systems, floating point\n** byte swapping becomes very complicated.  To avoid problems,\n** the necessary byte swapping is carried out using a 64-bit integer\n** rather than a 64-bit float.  Frank assures us that the code here\n** works for him.  We, the developers, have no way to independently\n** verify this, but Frank seems to know what he is talking about\n** so we trust him.\n*/\n#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT\nstatic u64 floatSwap(u64 in){\n  union {\n    u64 r;\n    u32 i[2];\n  } u;\n  u32 t;\n\n  u.r = in;\n  t = u.i[0];\n  u.i[0] = u.i[1];\n  u.i[1] = t;\n  return u.r;\n}\n# define swapMixedEndianFloat(X)  X = floatSwap(X)\n#else\n# define swapMixedEndianFloat(X)\n#endif\n\n/*\n** Write the serialized data blob for the value stored in pMem into \n** buf. It is assumed that the caller has allocated sufficient space.\n** Return the number of bytes written.\n**\n** nBuf is the amount of space left in buf[].  The caller is responsible\n** for allocating enough space to buf[] to hold the entire field, exclusive\n** of the pMem->u.nZero bytes for a MEM_Zero value.\n**\n** Return the number of bytes actually written into buf[].  The number\n** of bytes in the zero-filled tail is included in the return value only\n** if those bytes were zeroed in buf[].\n*/ \nu32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){\n  u32 len;\n\n  /* Integer and Real */\n  if( serial_type<=7 && serial_type>0 ){\n    u64 v;\n    u32 i;\n    if( serial_type==7 ){\n      assert( sizeof(v)==sizeof(pMem->u.r) );\n      memcpy(&v, &pMem->u.r, sizeof(v));\n      swapMixedEndianFloat(v);\n    }else{\n      v = pMem->u.i;\n    }\n    len = i = sqlite3SmallTypeSizes[serial_type];\n    assert( i>0 );\n    do{\n      buf[--i] = (u8)(v&0xFF);\n      v >>= 8;\n    }while( i );\n    return len;\n  }\n\n  /* String or blob */\n  if( serial_type>=12 ){\n    assert( pMem->n + ((pMem->flags & MEM_Zero)?pMem->u.nZero:0)\n             == (int)sqlite3VdbeSerialTypeLen(serial_type) );\n    len = pMem->n;\n    if( len>0 ) memcpy(buf, pMem->z, len);\n    return len;\n  }\n\n  /* NULL or constants 0 or 1 */\n  return 0;\n}\n\n/* Input \"x\" is a sequence of unsigned characters that represent a\n** big-endian integer.  Return the equivalent native integer\n*/\n#define ONE_BYTE_INT(x)    ((i8)(x)[0])\n#define TWO_BYTE_INT(x)    (256*(i8)((x)[0])|(x)[1])\n#define THREE_BYTE_INT(x)  (65536*(i8)((x)[0])|((x)[1]<<8)|(x)[2])\n#define FOUR_BYTE_UINT(x)  (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n#define FOUR_BYTE_INT(x) (16777216*(i8)((x)[0])|((x)[1]<<16)|((x)[2]<<8)|(x)[3])\n\n/*\n** Deserialize the data blob pointed to by buf as serial type serial_type\n** and store the result in pMem.  Return the number of bytes read.\n**\n** This function is implemented as two separate routines for performance.\n** The few cases that require local variables are broken out into a separate\n** routine so that in most cases the overhead of moving the stack pointer\n** is avoided.\n*/ \nstatic u32 SQLITE_NOINLINE serialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  u64 x = FOUR_BYTE_UINT(buf);\n  u32 y = FOUR_BYTE_UINT(buf+4);\n  x = (x<<32) + y;\n  if( serial_type==6 ){\n    /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit\n    ** twos-complement integer. */\n    pMem->u.i = *(i64*)&x;\n    pMem->flags = MEM_Int;\n    testcase( pMem->u.i<0 );\n  }else{\n    /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit\n    ** floating point number. */\n#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)\n    /* Verify that integers and floating point values use the same\n    ** byte order.  Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is\n    ** defined that 64-bit floating point values really are mixed\n    ** endian.\n    */\n    static const u64 t1 = ((u64)0x3ff00000)<<32;\n    static const double r1 = 1.0;\n    u64 t2 = t1;\n    swapMixedEndianFloat(t2);\n    assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );\n#endif\n    assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );\n    swapMixedEndianFloat(x);\n    memcpy(&pMem->u.r, &x, sizeof(x));\n    pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;\n  }\n  return 8;\n}\nu32 sqlite3VdbeSerialGet(\n  const unsigned char *buf,     /* Buffer to deserialize from */\n  u32 serial_type,              /* Serial type to deserialize */\n  Mem *pMem                     /* Memory cell to write value into */\n){\n  switch( serial_type ){\n    case 10:   /* Reserved for future use */\n    case 11:   /* Reserved for future use */\n    case 0: {  /* Null */\n      /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */\n      pMem->flags = MEM_Null;\n      break;\n    }\n    case 1: {\n      /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement\n      ** integer. */\n      pMem->u.i = ONE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 1;\n    }\n    case 2: { /* 2-byte signed integer */\n      /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit\n      ** twos-complement integer. */\n      pMem->u.i = TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 2;\n    }\n    case 3: { /* 3-byte signed integer */\n      /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit\n      ** twos-complement integer. */\n      pMem->u.i = THREE_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 3;\n    }\n    case 4: { /* 4-byte signed integer */\n      /* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_INT(buf);\n#ifdef __HP_cc \n      /* Work around a sign-extension bug in the HP compiler for HP/UX */\n      if( buf[0]&0x80 ) pMem->u.i |= 0xffffffff80000000LL;\n#endif\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 4;\n    }\n    case 5: { /* 6-byte signed integer */\n      /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit\n      ** twos-complement integer. */\n      pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);\n      pMem->flags = MEM_Int;\n      testcase( pMem->u.i<0 );\n      return 6;\n    }\n    case 6:   /* 8-byte signed integer */\n    case 7: { /* IEEE floating point */\n      /* These use local variables, so do them in a separate routine\n      ** to avoid having to move the frame pointer in the common case */\n      return serialGet(buf,serial_type,pMem);\n    }\n    case 8:    /* Integer 0 */\n    case 9: {  /* Integer 1 */\n      /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */\n      /* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */\n      pMem->u.i = serial_type-8;\n      pMem->flags = MEM_Int;\n      return 0;\n    }\n    default: {\n      /* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in\n      ** length.\n      ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and\n      ** (N-13)/2 bytes in length. */\n      static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };\n      pMem->z = (char *)buf;\n      pMem->n = (serial_type-12)/2;\n      pMem->flags = aFlag[serial_type&1];\n      return pMem->n;\n    }\n  }\n  return 0;\n}\n/*\n** This routine is used to allocate sufficient space for an UnpackedRecord\n** structure large enough to be used with sqlite3VdbeRecordUnpack() if\n** the first argument is a pointer to KeyInfo structure pKeyInfo.\n**\n** The space is either allocated using sqlite3DbMallocRaw() or from within\n** the unaligned buffer passed via the second and third arguments (presumably\n** stack space). If the former, then *ppFree is set to a pointer that should\n** be eventually freed by the caller using sqlite3DbFree(). Or, if the \n** allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL\n** before returning.\n**\n** If an OOM error occurs, NULL is returned.\n*/\nUnpackedRecord *sqlite3VdbeAllocUnpackedRecord(\n  KeyInfo *pKeyInfo               /* Description of the record */\n){\n  UnpackedRecord *p;              /* Unpacked record to return */\n  int nByte;                      /* Number of bytes required for *p */\n  nByte = ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);\n  p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);\n  if( !p ) return 0;\n  p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))];\n  assert( pKeyInfo->aSortOrder!=0 );\n  p->pKeyInfo = pKeyInfo;\n  p->nField = pKeyInfo->nKeyField + 1;\n  return p;\n}\n\n/*\n** Given the nKey-byte encoding of a record in pKey[], populate the \n** UnpackedRecord structure indicated by the fourth argument with the\n** contents of the decoded record.\n*/ \nvoid sqlite3VdbeRecordUnpack(\n  KeyInfo *pKeyInfo,     /* Information about the record format */\n  int nKey,              /* Size of the binary record */\n  const void *pKey,      /* The binary record */\n  UnpackedRecord *p      /* Populate this structure before returning. */\n){\n  const unsigned char *aKey = (const unsigned char *)pKey;\n  int d; \n  u32 idx;                        /* Offset in aKey[] to read from */\n  u16 u;                          /* Unsigned loop counter */\n  u32 szHdr;\n  Mem *pMem = p->aMem;\n\n  p->default_rc = 0;\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  idx = getVarint32(aKey, szHdr);\n  d = szHdr;\n  u = 0;\n  while( idx<szHdr && d<=nKey ){\n    u32 serial_type;\n\n    idx += getVarint32(&aKey[idx], serial_type);\n    pMem->enc = pKeyInfo->enc;\n    pMem->db = pKeyInfo->db;\n    /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */\n    pMem->szMalloc = 0;\n    pMem->z = 0;\n    d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);\n    pMem++;\n    if( (++u)>=p->nField ) break;\n  }\n  assert( u<=pKeyInfo->nKeyField + 1 );\n  p->nField = u;\n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This function compares two index or table record keys in the same way\n** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),\n** this function deserializes and compares values using the\n** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used\n** in assert() statements to ensure that the optimized code in\n** sqlite3VdbeRecordCompare() returns results with these two primitives.\n**\n** Return true if the result of comparison is equivalent to desiredResult.\n** Return false if there is a disagreement.\n*/\nstatic int vdbeRecordCompareDebug(\n  int nKey1, const void *pKey1, /* Left key */\n  const UnpackedRecord *pPKey2, /* Right key */\n  int desiredResult             /* Correct answer */\n){\n  u32 d1;            /* Offset into aKey[] of next data element */\n  u32 idx1;          /* Offset into aKey[] of next header element */\n  u32 szHdr1;        /* Number of bytes in header */\n  int i = 0;\n  int rc = 0;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  KeyInfo *pKeyInfo;\n  Mem mem1;\n\n  pKeyInfo = pPKey2->pKeyInfo;\n  if( pKeyInfo->db==0 ) return 1;\n  mem1.enc = pKeyInfo->enc;\n  mem1.db = pKeyInfo->db;\n  /* mem1.flags = 0;  // Will be initialized by sqlite3VdbeSerialGet() */\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n\n  /* Compilers may complain that mem1.u.i is potentially uninitialized.\n  ** We could initialize it, as shown here, to silence those complaints.\n  ** But in fact, mem1.u.i will never actually be used uninitialized, and doing \n  ** the unnecessary initialization has a measurable negative performance\n  ** impact, since this routine is a very high runner.  And so, we choose\n  ** to ignore the compiler warnings and leave this variable uninitialized.\n  */\n  /*  mem1.u.i = 0;  // not needed, here to silence compiler warning */\n  \n  idx1 = getVarint32(aKey1, szHdr1);\n  if( szHdr1>98307 ) return SQLITE_CORRUPT;\n  d1 = szHdr1;\n  assert( pKeyInfo->nAllField>=pPKey2->nField || CORRUPT_DB );\n  assert( pKeyInfo->aSortOrder!=0 );\n  assert( pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type1;\n\n    /* Read the serial types for the next element in each key. */\n    idx1 += getVarint32( aKey1+idx1, serial_type1 );\n\n    /* Verify that there is enough key space remaining to avoid\n    ** a buffer overread.  The \"d1+serial_type1+2\" subexpression will\n    ** always be greater than or equal to the amount of required key space.\n    ** Use that approximation to avoid the more expensive call to\n    ** sqlite3VdbeSerialTypeLen() in the common case.\n    */\n    if( d1+serial_type1+2>(u32)nKey1\n     && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 \n    ){\n      break;\n    }\n\n    /* Extract the values to be compared.\n    */\n    d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);\n\n    /* Do the comparison\n    */\n    rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);\n    if( rc!=0 ){\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      if( pKeyInfo->aSortOrder[i] ){\n        rc = -rc;  /* Invert the result for DESC sort order. */\n      }\n      goto debugCompareEnd;\n    }\n    i++;\n  }while( idx1<szHdr1 && i<pPKey2->nField );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).\n  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  rc = pPKey2->default_rc;\n\ndebugCompareEnd:\n  if( desiredResult==0 && rc==0 ) return 1;\n  if( desiredResult<0 && rc<0 ) return 1;\n  if( desiredResult>0 && rc>0 ) return 1;\n  if( CORRUPT_DB ) return 1;\n  if( pKeyInfo->db->mallocFailed ) return 1;\n  return 0;\n}\n#endif\n\n#ifdef SQLITE_DEBUG\n/*\n** Count the number of fields (a.k.a. columns) in the record given by\n** pKey,nKey.  The verify that this count is less than or equal to the\n** limit given by pKeyInfo->nAllField.\n**\n** If this constraint is not satisfied, it means that the high-speed\n** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will\n** not work correctly.  If this assert() ever fires, it probably means\n** that the KeyInfo.nKeyField or KeyInfo.nAllField values were computed\n** incorrectly.\n*/\nstatic void vdbeAssertFieldCountWithinLimits(\n  int nKey, const void *pKey,   /* The record to verify */ \n  const KeyInfo *pKeyInfo       /* Compare size with this KeyInfo */\n){\n  int nField = 0;\n  u32 szHdr;\n  u32 idx;\n  u32 notUsed;\n  const unsigned char *aKey = (const unsigned char*)pKey;\n\n  if( CORRUPT_DB ) return;\n  idx = getVarint32(aKey, szHdr);\n  assert( nKey>=0 );\n  assert( szHdr<=(u32)nKey );\n  while( idx<szHdr ){\n    idx += getVarint32(aKey+idx, notUsed);\n    nField++;\n  }\n  assert( nField <= pKeyInfo->nAllField );\n}\n#else\n# define vdbeAssertFieldCountWithinLimits(A,B,C)\n#endif\n\n/*\n** Both *pMem1 and *pMem2 contain string values. Compare the two values\n** using the collation sequence pColl. As usual, return a negative , zero\n** or positive value if *pMem1 is less than, equal to or greater than \n** *pMem2, respectively. Similar in spirit to \"rc = (*pMem1) - (*pMem2);\".\n*/\nstatic int vdbeCompareMemString(\n  const Mem *pMem1,\n  const Mem *pMem2,\n  const CollSeq *pColl,\n  u8 *prcErr                      /* If an OOM occurs, set to SQLITE_NOMEM */\n){\n  if( pMem1->enc==pColl->enc ){\n    /* The strings are already in the correct encoding.  Call the\n     ** comparison function directly */\n    return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);\n  }else{\n    int rc;\n    const void *v1, *v2;\n    Mem c1;\n    Mem c2;\n    sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);\n    sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);\n    sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);\n    sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);\n    v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);\n    v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);\n    if( (v1==0 || v2==0) ){\n      if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;\n      rc = 0;\n    }else{\n      rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);\n    }\n    sqlite3VdbeMemRelease(&c1);\n    sqlite3VdbeMemRelease(&c2);\n    return rc;\n  }\n}\n\n/*\n** The input pBlob is guaranteed to be a Blob that is not marked\n** with MEM_Zero.  Return true if it could be a zero-blob.\n*/\nstatic int isAllZero(const char *z, int n){\n  int i;\n  for(i=0; i<n; i++){\n    if( z[i] ) return 0;\n  }\n  return 1;\n}\n\n/*\n** Compare two blobs.  Return negative, zero, or positive if the first\n** is less than, equal to, or greater than the second, respectively.\n** If one blob is a prefix of the other, then the shorter is the lessor.\n*/\nstatic SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem *pB2){\n  int c;\n  int n1 = pB1->n;\n  int n2 = pB2->n;\n\n  /* It is possible to have a Blob value that has some non-zero content\n  ** followed by zero content.  But that only comes up for Blobs formed\n  ** by the OP_MakeRecord opcode, and such Blobs never get passed into\n  ** sqlite3MemCompare(). */\n  assert( (pB1->flags & MEM_Zero)==0 || n1==0 );\n  assert( (pB2->flags & MEM_Zero)==0 || n2==0 );\n\n  if( (pB1->flags|pB2->flags) & MEM_Zero ){\n    if( pB1->flags & pB2->flags & MEM_Zero ){\n      return pB1->u.nZero - pB2->u.nZero;\n    }else if( pB1->flags & MEM_Zero ){\n      if( !isAllZero(pB2->z, pB2->n) ) return -1;\n      return pB1->u.nZero - n2;\n    }else{\n      if( !isAllZero(pB1->z, pB1->n) ) return +1;\n      return n1 - pB2->u.nZero;\n    }\n  }\n  c = memcmp(pB1->z, pB2->z, n1>n2 ? n2 : n1);\n  if( c ) return c;\n  return n1 - n2;\n}\n\n/*\n** Do a comparison between a 64-bit signed integer and a 64-bit floating-point\n** number.  Return negative, zero, or positive if the first (i64) is less than,\n** equal to, or greater than the second (double).\n*/\nstatic int sqlite3IntFloatCompare(i64 i, double r){\n  if( sizeof(LONGDOUBLE_TYPE)>8 ){\n    LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;\n    if( x<r ) return -1;\n    if( x>r ) return +1;\n    return 0;\n  }else{\n    i64 y;\n    double s;\n    if( r<-9223372036854775808.0 ) return +1;\n    if( r>9223372036854775807.0 ) return -1;\n    y = (i64)r;\n    if( i<y ) return -1;\n    if( i>y ){\n      if( y==SMALLEST_INT64 && r>0.0 ) return -1;\n      return +1;\n    }\n    s = (double)i;\n    if( s<r ) return -1;\n    if( s>r ) return +1;\n    return 0;\n  }\n}\n\n/*\n** Compare the values contained by the two memory cells, returning\n** negative, zero or positive if pMem1 is less than, equal to, or greater\n** than pMem2. Sorting order is NULL's first, followed by numbers (integers\n** and reals) sorted numerically, followed by text ordered by the collating\n** sequence pColl and finally blob's ordered by memcmp().\n**\n** Two NULL values are considered equal by this function.\n*/\nint sqlite3MemCompare(const Mem *pMem1, const Mem *pMem2, const CollSeq *pColl){\n  int f1, f2;\n  int combined_flags;\n\n  f1 = pMem1->flags;\n  f2 = pMem2->flags;\n  combined_flags = f1|f2;\n  assert( (combined_flags & MEM_RowSet)==0 );\n \n  /* If one value is NULL, it is less than the other. If both values\n  ** are NULL, return 0.\n  */\n  if( combined_flags&MEM_Null ){\n    return (f2&MEM_Null) - (f1&MEM_Null);\n  }\n\n  /* At least one of the two values is a number\n  */\n  if( combined_flags&(MEM_Int|MEM_Real) ){\n    if( (f1 & f2 & MEM_Int)!=0 ){\n      if( pMem1->u.i < pMem2->u.i ) return -1;\n      if( pMem1->u.i > pMem2->u.i ) return +1;\n      return 0;\n    }\n    if( (f1 & f2 & MEM_Real)!=0 ){\n      if( pMem1->u.r < pMem2->u.r ) return -1;\n      if( pMem1->u.r > pMem2->u.r ) return +1;\n      return 0;\n    }\n    if( (f1&MEM_Int)!=0 ){\n      if( (f2&MEM_Real)!=0 ){\n        return sqlite3IntFloatCompare(pMem1->u.i, pMem2->u.r);\n      }else{\n        return -1;\n      }\n    }\n    if( (f1&MEM_Real)!=0 ){\n      if( (f2&MEM_Int)!=0 ){\n        return -sqlite3IntFloatCompare(pMem2->u.i, pMem1->u.r);\n      }else{\n        return -1;\n      }\n    }\n    return +1;\n  }\n\n  /* If one value is a string and the other is a blob, the string is less.\n  ** If both are strings, compare using the collating functions.\n  */\n  if( combined_flags&MEM_Str ){\n    if( (f1 & MEM_Str)==0 ){\n      return 1;\n    }\n    if( (f2 & MEM_Str)==0 ){\n      return -1;\n    }\n\n    assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );\n    assert( pMem1->enc==SQLITE_UTF8 || \n            pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );\n\n    /* The collation sequence must be defined at this point, even if\n    ** the user deletes the collation sequence after the vdbe program is\n    ** compiled (this was not always the case).\n    */\n    assert( !pColl || pColl->xCmp );\n\n    if( pColl ){\n      return vdbeCompareMemString(pMem1, pMem2, pColl, 0);\n    }\n    /* If a NULL pointer was passed as the collate function, fall through\n    ** to the blob case and use memcmp().  */\n  }\n \n  /* Both values must be blobs.  Compare using memcmp().  */\n  return sqlite3BlobCompare(pMem1, pMem2);\n}\n\n\n/*\n** The first argument passed to this function is a serial-type that\n** corresponds to an integer - all values between 1 and 9 inclusive \n** except 7. The second points to a buffer containing an integer value\n** serialized according to serial_type. This function deserializes\n** and returns the value.\n*/\nstatic i64 vdbeRecordDecodeInt(u32 serial_type, const u8 *aKey){\n  u32 y;\n  assert( CORRUPT_DB || (serial_type>=1 && serial_type<=9 && serial_type!=7) );\n  switch( serial_type ){\n    case 0:\n    case 1:\n      testcase( aKey[0]&0x80 );\n      return ONE_BYTE_INT(aKey);\n    case 2:\n      testcase( aKey[0]&0x80 );\n      return TWO_BYTE_INT(aKey);\n    case 3:\n      testcase( aKey[0]&0x80 );\n      return THREE_BYTE_INT(aKey);\n    case 4: {\n      testcase( aKey[0]&0x80 );\n      y = FOUR_BYTE_UINT(aKey);\n      return (i64)*(int*)&y;\n    }\n    case 5: {\n      testcase( aKey[0]&0x80 );\n      return FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n    }\n    case 6: {\n      u64 x = FOUR_BYTE_UINT(aKey);\n      testcase( aKey[0]&0x80 );\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      return (i64)*(i64*)&x;\n    }\n  }\n\n  return (serial_type - 8);\n}\n\n/*\n** This function compares the two table rows or index records\n** specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero\n** or positive integer if key1 is less than, equal to or \n** greater than key2.  The {nKey1, pKey1} key must be a blob\n** created by the OP_MakeRecord opcode of the VDBE.  The pPKey2\n** key must be a parsed key such as obtained from\n** sqlite3VdbeParseRecord.\n**\n** If argument bSkip is non-zero, it is assumed that the caller has already\n** determined that the first fields of the keys are equal.\n**\n** Key1 and Key2 do not have to contain the same number of fields. If all \n** fields that appear in both keys are equal, then pPKey2->default_rc is \n** returned.\n**\n** If database corruption is discovered, set pPKey2->errCode to \n** SQLITE_CORRUPT and return 0. If an OOM error is encountered, \n** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the\n** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).\n*/\nint sqlite3VdbeRecordCompareWithSkip(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2,         /* Right key */\n  int bSkip                       /* If true, skip the first field */\n){\n  u32 d1;                         /* Offset into aKey[] of next data element */\n  int i;                          /* Index of next field to compare */\n  u32 szHdr1;                     /* Size of record header in bytes */\n  u32 idx1;                       /* Offset of first type in header */\n  int rc = 0;                     /* Return value */\n  Mem *pRhs = pPKey2->aMem;       /* Next field of pPKey2 to compare */\n  KeyInfo *pKeyInfo = pPKey2->pKeyInfo;\n  const unsigned char *aKey1 = (const unsigned char *)pKey1;\n  Mem mem1;\n\n  /* If bSkip is true, then the caller has already determined that the first\n  ** two elements in the keys are equal. Fix the various stack variables so\n  ** that this routine begins comparing at the second field. */\n  if( bSkip ){\n    u32 s1;\n    idx1 = 1 + getVarint32(&aKey1[1], s1);\n    szHdr1 = aKey1[0];\n    d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1);\n    i = 1;\n    pRhs++;\n  }else{\n    idx1 = getVarint32(aKey1, szHdr1);\n    d1 = szHdr1;\n    if( d1>(unsigned)nKey1 ){ \n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;  /* Corruption */\n    }\n    i = 0;\n  }\n\n  VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */\n  assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField \n       || CORRUPT_DB );\n  assert( pPKey2->pKeyInfo->aSortOrder!=0 );\n  assert( pPKey2->pKeyInfo->nKeyField>0 );\n  assert( idx1<=szHdr1 || CORRUPT_DB );\n  do{\n    u32 serial_type;\n\n    /* RHS is an integer */\n    if( pRhs->flags & MEM_Int ){\n      serial_type = aKey1[idx1];\n      testcase( serial_type==12 );\n      if( serial_type>=10 ){\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else if( serial_type==7 ){\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        rc = -sqlite3IntFloatCompare(pRhs->u.i, mem1.u.r);\n      }else{\n        i64 lhs = vdbeRecordDecodeInt(serial_type, &aKey1[d1]);\n        i64 rhs = pRhs->u.i;\n        if( lhs<rhs ){\n          rc = -1;\n        }else if( lhs>rhs ){\n          rc = +1;\n        }\n      }\n    }\n\n    /* RHS is real */\n    else if( pRhs->flags & MEM_Real ){\n      serial_type = aKey1[idx1];\n      if( serial_type>=10 ){\n        /* Serial types 12 or greater are strings and blobs (greater than\n        ** numbers). Types 10 and 11 are currently \"reserved for future \n        ** use\", so it doesn't really matter what the results of comparing\n        ** them to numberic values are.  */\n        rc = +1;\n      }else if( serial_type==0 ){\n        rc = -1;\n      }else{\n        sqlite3VdbeSerialGet(&aKey1[d1], serial_type, &mem1);\n        if( serial_type==7 ){\n          if( mem1.u.r<pRhs->u.r ){\n            rc = -1;\n          }else if( mem1.u.r>pRhs->u.r ){\n            rc = +1;\n          }\n        }else{\n          rc = sqlite3IntFloatCompare(mem1.u.i, pRhs->u.r);\n        }\n      }\n    }\n\n    /* RHS is a string */\n    else if( pRhs->flags & MEM_Str ){\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 ){\n        rc = -1;\n      }else if( !(serial_type & 0x01) ){\n        rc = +1;\n      }else{\n        mem1.n = (serial_type - 12) / 2;\n        testcase( (d1+mem1.n)==(unsigned)nKey1 );\n        testcase( (d1+mem1.n+1)==(unsigned)nKey1 );\n        if( (d1+mem1.n) > (unsigned)nKey1 ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pKeyInfo->aColl[i] ){\n          mem1.enc = pKeyInfo->enc;\n          mem1.db = pKeyInfo->db;\n          mem1.flags = MEM_Str;\n          mem1.z = (char*)&aKey1[d1];\n          rc = vdbeCompareMemString(\n              &mem1, pRhs, pKeyInfo->aColl[i], &pPKey2->errCode\n          );\n        }else{\n          int nCmp = MIN(mem1.n, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = mem1.n - pRhs->n; \n        }\n      }\n    }\n\n    /* RHS is a blob */\n    else if( pRhs->flags & MEM_Blob ){\n      assert( (pRhs->flags & MEM_Zero)==0 || pRhs->n==0 );\n      getVarint32(&aKey1[idx1], serial_type);\n      testcase( serial_type==12 );\n      if( serial_type<12 || (serial_type & 0x01) ){\n        rc = -1;\n      }else{\n        int nStr = (serial_type - 12) / 2;\n        testcase( (d1+nStr)==(unsigned)nKey1 );\n        testcase( (d1+nStr+1)==(unsigned)nKey1 );\n        if( (d1+nStr) > (unsigned)nKey1 ){\n          pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n          return 0;                /* Corruption */\n        }else if( pRhs->flags & MEM_Zero ){\n          if( !isAllZero((const char*)&aKey1[d1],nStr) ){\n            rc = 1;\n          }else{\n            rc = nStr - pRhs->u.nZero;\n          }\n        }else{\n          int nCmp = MIN(nStr, pRhs->n);\n          rc = memcmp(&aKey1[d1], pRhs->z, nCmp);\n          if( rc==0 ) rc = nStr - pRhs->n;\n        }\n      }\n    }\n\n    /* RHS is null */\n    else{\n      serial_type = aKey1[idx1];\n      rc = (serial_type!=0);\n    }\n\n    if( rc!=0 ){\n      if( pKeyInfo->aSortOrder[i] ){\n        rc = -rc;\n      }\n      assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, rc) );\n      assert( mem1.szMalloc==0 );  /* See comment below */\n      return rc;\n    }\n\n    i++;\n    pRhs++;\n    d1 += sqlite3VdbeSerialTypeLen(serial_type);\n    idx1 += sqlite3VarintLen(serial_type);\n  }while( idx1<(unsigned)szHdr1 && i<pPKey2->nField && d1<=(unsigned)nKey1 );\n\n  /* No memory allocation is ever used on mem1.  Prove this using\n  ** the following assert().  If the assert() fails, it indicates a\n  ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).  */\n  assert( mem1.szMalloc==0 );\n\n  /* rc==0 here means that one or both of the keys ran out of fields and\n  ** all the fields up to that point were equal. Return the default_rc\n  ** value.  */\n  assert( CORRUPT_DB \n       || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc) \n       || pKeyInfo->db->mallocFailed\n  );\n  pPKey2->eqSeen = 1;\n  return pPKey2->default_rc;\n}\nint sqlite3VdbeRecordCompare(\n  int nKey1, const void *pKey1,   /* Left key */\n  UnpackedRecord *pPKey2          /* Right key */\n){\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);\n}\n\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is an integer, and (b) the \n** size-of-header varint at the start of (pKey1/nKey1) fits in a single\n** byte (i.e. is less than 128).\n**\n** To avoid concerns about buffer overreads, this routine is only used\n** on schemas where the maximum valid header size is 63 bytes or less.\n*/\nstatic int vdbeRecordCompareInt(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey = &((const u8*)pKey1)[*(const u8*)pKey1 & 0x3F];\n  int serial_type = ((const u8*)pKey1)[1];\n  int res;\n  u32 y;\n  u64 x;\n  i64 v;\n  i64 lhs;\n\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );\n  switch( serial_type ){\n    case 1: { /* 1-byte signed integer */\n      lhs = ONE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 2: { /* 2-byte signed integer */\n      lhs = TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 3: { /* 3-byte signed integer */\n      lhs = THREE_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 4: { /* 4-byte signed integer */\n      y = FOUR_BYTE_UINT(aKey);\n      lhs = (i64)*(int*)&y;\n      testcase( lhs<0 );\n      break;\n    }\n    case 5: { /* 6-byte signed integer */\n      lhs = FOUR_BYTE_UINT(aKey+2) + (((i64)1)<<32)*TWO_BYTE_INT(aKey);\n      testcase( lhs<0 );\n      break;\n    }\n    case 6: { /* 8-byte signed integer */\n      x = FOUR_BYTE_UINT(aKey);\n      x = (x<<32) | FOUR_BYTE_UINT(aKey+4);\n      lhs = *(i64*)&x;\n      testcase( lhs<0 );\n      break;\n    }\n    case 8: \n      lhs = 0;\n      break;\n    case 9:\n      lhs = 1;\n      break;\n\n    /* This case could be removed without changing the results of running\n    ** this code. Including it causes gcc to generate a faster switch \n    ** statement (since the range of switch targets now starts at zero and\n    ** is contiguous) but does not cause any duplicate code to be generated\n    ** (as gcc is clever enough to combine the two like cases). Other \n    ** compilers might be similar.  */ \n    case 0: case 7:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n\n    default:\n      return sqlite3VdbeRecordCompare(nKey1, pKey1, pPKey2);\n  }\n\n  v = pPKey2->aMem[0].u.i;\n  if( v>lhs ){\n    res = pPKey2->r1;\n  }else if( v<lhs ){\n    res = pPKey2->r2;\n  }else if( pPKey2->nField>1 ){\n    /* The first fields of the two keys are equal. Compare the trailing \n    ** fields.  */\n    res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n  }else{\n    /* The first fields of the two keys are equal and there are no trailing\n    ** fields. Return pPKey2->default_rc in this case. */\n    res = pPKey2->default_rc;\n    pPKey2->eqSeen = 1;\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res) );\n  return res;\n}\n\n/*\n** This function is an optimized version of sqlite3VdbeRecordCompare() \n** that (a) the first field of pPKey2 is a string, that (b) the first field\n** uses the collation sequence BINARY and (c) that the size-of-header varint \n** at the start of (pKey1/nKey1) fits in a single byte.\n*/\nstatic int vdbeRecordCompareString(\n  int nKey1, const void *pKey1, /* Left key */\n  UnpackedRecord *pPKey2        /* Right key */\n){\n  const u8 *aKey1 = (const u8*)pKey1;\n  int serial_type;\n  int res;\n\n  assert( pPKey2->aMem[0].flags & MEM_Str );\n  vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);\n  getVarint32(&aKey1[1], serial_type);\n  if( serial_type<12 ){\n    res = pPKey2->r1;      /* (pKey1/nKey1) is a number or a null */\n  }else if( !(serial_type & 0x01) ){ \n    res = pPKey2->r2;      /* (pKey1/nKey1) is a blob */\n  }else{\n    int nCmp;\n    int nStr;\n    int szHdr = aKey1[0];\n\n    nStr = (serial_type-12) / 2;\n    if( (szHdr + nStr) > nKey1 ){\n      pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;\n      return 0;    /* Corruption */\n    }\n    nCmp = MIN( pPKey2->aMem[0].n, nStr );\n    res = memcmp(&aKey1[szHdr], pPKey2->aMem[0].z, nCmp);\n\n    if( res==0 ){\n      res = nStr - pPKey2->aMem[0].n;\n      if( res==0 ){\n        if( pPKey2->nField>1 ){\n          res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);\n        }else{\n          res = pPKey2->default_rc;\n          pPKey2->eqSeen = 1;\n        }\n      }else if( res>0 ){\n        res = pPKey2->r2;\n      }else{\n        res = pPKey2->r1;\n      }\n    }else if( res>0 ){\n      res = pPKey2->r2;\n    }else{\n      res = pPKey2->r1;\n    }\n  }\n\n  assert( vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, res)\n       || CORRUPT_DB\n       || pPKey2->pKeyInfo->db->mallocFailed\n  );\n  return res;\n}\n\n/*\n** Return a pointer to an sqlite3VdbeRecordCompare() compatible function\n** suitable for comparing serialized records to the unpacked record passed\n** as the only argument.\n*/\nRecordCompare sqlite3VdbeFindCompare(UnpackedRecord *p){\n  /* varintRecordCompareInt() and varintRecordCompareString() both assume\n  ** that the size-of-header varint that occurs at the start of each record\n  ** fits in a single byte (i.e. is 127 or less). varintRecordCompareInt()\n  ** also assumes that it is safe to overread a buffer by at least the \n  ** maximum possible legal header size plus 8 bytes. Because there is\n  ** guaranteed to be at least 74 (but not 136) bytes of padding following each\n  ** buffer passed to varintRecordCompareInt() this makes it convenient to\n  ** limit the size of the header to 64 bytes in cases where the first field\n  ** is an integer.\n  **\n  ** The easiest way to enforce this limit is to consider only records with\n  ** 13 fields or less. If the first field is an integer, the maximum legal\n  ** header size is (12*5 + 1 + 1) bytes.  */\n  if( p->pKeyInfo->nAllField<=13 ){\n    int flags = p->aMem[0].flags;\n    if( p->pKeyInfo->aSortOrder[0] ){\n      p->r1 = 1;\n      p->r2 = -1;\n    }else{\n      p->r1 = -1;\n      p->r2 = 1;\n    }\n    if( (flags & MEM_Int) ){\n      return vdbeRecordCompareInt;\n    }\n    testcase( flags & MEM_Real );\n    testcase( flags & MEM_Null );\n    testcase( flags & MEM_Blob );\n    if( (flags & (MEM_Real|MEM_Null|MEM_Blob))==0 && p->pKeyInfo->aColl[0]==0 ){\n      assert( flags & MEM_Str );\n      return vdbeRecordCompareString;\n    }\n  }\n\n  return sqlite3VdbeRecordCompare;\n}\n\n/*\n** pCur points at an index entry created using the OP_MakeRecord opcode.\n** Read the rowid (the last field in the record) and store it in *rowid.\n** Return SQLITE_OK if everything works, or an error code otherwise.\n**\n** pCur might be pointing to text obtained from a corrupt database file.\n** So the content cannot be trusted.  Do appropriate checks on the content.\n*/\nint sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){\n  i64 nCellKey = 0;\n  int rc;\n  u32 szHdr;        /* Size of the header */\n  u32 typeRowid;    /* Serial type of the rowid */\n  u32 lenRowid;     /* Size of the rowid */\n  Mem m, v;\n\n  /* Get the size of the index entry.  Only indices entries of less\n  ** than 2GiB are support - anything large must be database corruption.\n  ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so\n  ** this code can safely assume that nCellKey is 32-bits  \n  */\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey );\n\n  /* Read in the complete content of the index entry */\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n\n  /* The index entry must begin with a header size */\n  (void)getVarint32((u8*)m.z, szHdr);\n  testcase( szHdr==3 );\n  testcase( szHdr==m.n );\n  if( unlikely(szHdr<3 || (int)szHdr>m.n) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* The last field of the index should be an integer - the ROWID.\n  ** Verify that the last entry really is an integer. */\n  (void)getVarint32((u8*)&m.z[szHdr-1], typeRowid);\n  testcase( typeRowid==1 );\n  testcase( typeRowid==2 );\n  testcase( typeRowid==3 );\n  testcase( typeRowid==4 );\n  testcase( typeRowid==5 );\n  testcase( typeRowid==6 );\n  testcase( typeRowid==8 );\n  testcase( typeRowid==9 );\n  if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){\n    goto idx_rowid_corruption;\n  }\n  lenRowid = sqlite3SmallTypeSizes[typeRowid];\n  testcase( (u32)m.n==szHdr+lenRowid );\n  if( unlikely((u32)m.n<szHdr+lenRowid) ){\n    goto idx_rowid_corruption;\n  }\n\n  /* Fetch the integer off the end of the index record */\n  sqlite3VdbeSerialGet((u8*)&m.z[m.n-lenRowid], typeRowid, &v);\n  *rowid = v.u.i;\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n\n  /* Jump here if database corruption is detected after m has been\n  ** allocated.  Free the m object and return SQLITE_CORRUPT. */\nidx_rowid_corruption:\n  testcase( m.szMalloc!=0 );\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_CORRUPT_BKPT;\n}\n\n/*\n** Compare the key of the index entry that cursor pC is pointing to against\n** the key string in pUnpacked.  Write into *pRes a number\n** that is negative, zero, or positive if pC is less than, equal to,\n** or greater than pUnpacked.  Return SQLITE_OK on success.\n**\n** pUnpacked is either created without a rowid or is truncated so that it\n** omits the rowid at the end.  The rowid at the end of the index entry\n** is ignored as well.  Hence, this routine only compares the prefixes \n** of the keys prior to the final rowid, not the entire key.\n*/\nint sqlite3VdbeIdxKeyCompare(\n  sqlite3 *db,                     /* Database connection */\n  VdbeCursor *pC,                  /* The cursor to compare against */\n  UnpackedRecord *pUnpacked,       /* Unpacked version of key */\n  int *res                         /* Write the comparison result here */\n){\n  i64 nCellKey = 0;\n  int rc;\n  BtCursor *pCur;\n  Mem m;\n\n  assert( pC->eCurType==CURTYPE_BTREE );\n  pCur = pC->uc.pCursor;\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  nCellKey = sqlite3BtreePayloadSize(pCur);\n  /* nCellKey will always be between 0 and 0xffffffff because of the way\n  ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */\n  if( nCellKey<=0 || nCellKey>0x7fffffff ){\n    *res = 0;\n    return SQLITE_CORRUPT_BKPT;\n  }\n  sqlite3VdbeMemInit(&m, db, 0);\n  rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, &m);\n  if( rc ){\n    return rc;\n  }\n  *res = sqlite3VdbeRecordCompare(m.n, m.z, pUnpacked);\n  sqlite3VdbeMemRelease(&m);\n  return SQLITE_OK;\n}\n\n/*\n** This routine sets the value to be returned by subsequent calls to\n** sqlite3_changes() on the database handle 'db'. \n*/\nvoid sqlite3VdbeSetChanges(sqlite3 *db, int nChange){\n  assert( sqlite3_mutex_held(db->mutex) );\n  db->nChange = nChange;\n  db->nTotalChange += nChange;\n}\n\n/*\n** Set a flag in the vdbe to update the change counter when it is finalised\n** or reset.\n*/\nvoid sqlite3VdbeCountChanges(Vdbe *v){\n  v->changeCntOn = 1;\n}\n\n/*\n** Mark every prepared statement associated with a database connection\n** as expired.\n**\n** An expired statement means that recompilation of the statement is\n** recommend.  Statements expire when things happen that make their\n** programs obsolete.  Removing user-defined functions or collating\n** sequences, or changing an authorization function are the types of\n** things that make prepared statements obsolete.\n*/\nvoid sqlite3ExpirePreparedStatements(sqlite3 *db){\n  Vdbe *p;\n  for(p = db->pVdbe; p; p=p->pNext){\n    p->expired = 1;\n  }\n}\n\n/*\n** Return the database associated with the Vdbe.\n*/\nsqlite3 *sqlite3VdbeDb(Vdbe *v){\n  return v->db;\n}\n\n/*\n** Return the SQLITE_PREPARE flags for a Vdbe.\n*/\nu8 sqlite3VdbePrepareFlags(Vdbe *v){\n  return v->prepFlags;\n}\n\n/*\n** Return a pointer to an sqlite3_value structure containing the value bound\n** parameter iVar of VM v. Except, if the value is an SQL NULL, return \n** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*\n** constants) to the value before returning it.\n**\n** The returned value must be freed by the caller using sqlite3ValueFree().\n*/\nsqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){\n  assert( iVar>0 );\n  if( v ){\n    Mem *pMem = &v->aVar[iVar-1];\n    assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n    if( 0==(pMem->flags & MEM_Null) ){\n      sqlite3_value *pRet = sqlite3ValueNew(v->db);\n      if( pRet ){\n        sqlite3VdbeMemCopy((Mem *)pRet, pMem);\n        sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);\n      }\n      return pRet;\n    }\n  }\n  return 0;\n}\n\n/*\n** Configure SQL variable iVar so that binding a new value to it signals\n** to sqlite3_reoptimize() that re-preparing the statement may result\n** in a better query plan.\n*/\nvoid sqlite3VdbeSetVarmask(Vdbe *v, int iVar){\n  assert( iVar>0 );\n  assert( (v->db->flags & SQLITE_EnableQPSG)==0 );\n  if( iVar>=32 ){\n    v->expmask |= 0x80000000;\n  }else{\n    v->expmask |= ((u32)1 << (iVar-1));\n  }\n}\n\n/*\n** Cause a function to throw an error if it was call from OP_PureFunc\n** rather than OP_Function.\n**\n** OP_PureFunc means that the function must be deterministic, and should\n** throw an error if it is given inputs that would make it non-deterministic.\n** This routine is invoked by date/time functions that use non-deterministic\n** features such as 'now'.\n*/\nint sqlite3NotPureFunc(sqlite3_context *pCtx){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx->pVdbe==0 ) return 1;\n#endif\n  if( pCtx->pVdbe->aOp[pCtx->iOp].opcode==OP_PureFunc ){\n    sqlite3_result_error(pCtx, \n       \"non-deterministic function in index expression or CHECK constraint\",\n       -1);\n    return 0;\n  }\n  return 1;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Transfer error message text from an sqlite3_vtab.zErrMsg (text stored\n** in memory obtained from sqlite3_malloc) into a Vdbe.zErrMsg (text stored\n** in memory obtained from sqlite3DbMalloc).\n*/\nvoid sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){\n  if( pVtab->zErrMsg ){\n    sqlite3 *db = p->db;\n    sqlite3DbFree(db, p->zErrMsg);\n    p->zErrMsg = sqlite3DbStrDup(db, pVtab->zErrMsg);\n    sqlite3_free(pVtab->zErrMsg);\n    pVtab->zErrMsg = 0;\n  }\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n\n/*\n** If the second argument is not NULL, release any allocations associated \n** with the memory cells in the p->aMem[] array. Also free the UnpackedRecord\n** structure itself, using sqlite3DbFree().\n**\n** This function is used to free UnpackedRecord structures allocated by\n** the vdbeUnpackRecord() function found in vdbeapi.c.\n*/\nstatic void vdbeFreeUnpacked(sqlite3 *db, int nField, UnpackedRecord *p){\n  if( p ){\n    int i;\n    for(i=0; i<nField; i++){\n      Mem *pMem = &p->aMem[i];\n      if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem);\n    }\n    sqlite3DbFreeNN(db, p);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n/*\n** Invoke the pre-update hook. If this is an UPDATE or DELETE pre-update call,\n** then cursor passed as the second argument should point to the row about\n** to be update or deleted. If the application calls sqlite3_preupdate_old(),\n** the required value will be read from the row the cursor points to.\n*/\nvoid sqlite3VdbePreUpdateHook(\n  Vdbe *v,                        /* Vdbe pre-update hook is invoked by */\n  VdbeCursor *pCsr,               /* Cursor to grab old.* values from */\n  int op,                         /* SQLITE_INSERT, UPDATE or DELETE */\n  const char *zDb,                /* Database name */\n  Table *pTab,                    /* Modified table */\n  i64 iKey1,                      /* Initial key value */\n  int iReg                        /* Register for new.* record */\n){\n  sqlite3 *db = v->db;\n  i64 iKey2;\n  PreUpdate preupdate;\n  const char *zTbl = pTab->zName;\n  static const u8 fakeSortOrder = 0;\n\n  assert( db->pPreUpdate==0 );\n  memset(&preupdate, 0, sizeof(PreUpdate));\n  if( HasRowid(pTab)==0 ){\n    iKey1 = iKey2 = 0;\n    preupdate.pPk = sqlite3PrimaryKeyIndex(pTab);\n  }else{\n    if( op==SQLITE_UPDATE ){\n      iKey2 = v->aMem[iReg].u.i;\n    }else{\n      iKey2 = iKey1;\n    }\n  }\n\n  assert( pCsr->nField==pTab->nCol \n       || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1)\n  );\n\n  preupdate.v = v;\n  preupdate.pCsr = pCsr;\n  preupdate.op = op;\n  preupdate.iNewReg = iReg;\n  preupdate.keyinfo.db = db;\n  preupdate.keyinfo.enc = ENC(db);\n  preupdate.keyinfo.nKeyField = pTab->nCol;\n  preupdate.keyinfo.aSortOrder = (u8*)&fakeSortOrder;\n  preupdate.iKey1 = iKey1;\n  preupdate.iKey2 = iKey2;\n  preupdate.pTab = pTab;\n\n  db->pPreUpdate = &preupdate;\n  db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2);\n  db->pPreUpdate = 0;\n  sqlite3DbFree(db, preupdate.aRecord);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pUnpacked);\n  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pNewUnpacked);\n  if( preupdate.aNew ){\n    int i;\n    for(i=0; i<pCsr->nField; i++){\n      sqlite3VdbeMemRelease(&preupdate.aNew[i]);\n    }\n    sqlite3DbFreeNN(db, preupdate.aNew);\n  }\n}\n#endif /* SQLITE_ENABLE_PREUPDATE_HOOK */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbeblob.c",
    "content": "/*\n** 2007 May 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to implement incremental BLOB I/O.\n*/\n\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n#ifndef SQLITE_OMIT_INCRBLOB\n\n/*\n** Valid sqlite3_blob* handles point to Incrblob structures.\n*/\ntypedef struct Incrblob Incrblob;\nstruct Incrblob {\n  int nByte;              /* Size of open blob, in bytes */\n  int iOffset;            /* Byte offset of blob in cursor data */\n  u16 iCol;               /* Table column this handle is open on */\n  BtCursor *pCsr;         /* Cursor pointing at blob row */\n  sqlite3_stmt *pStmt;    /* Statement holding cursor open */\n  sqlite3 *db;            /* The associated database */\n  char *zDb;              /* Database name */\n  Table *pTab;            /* Table object */\n};\n\n\n/*\n** This function is used by both blob_open() and blob_reopen(). It seeks\n** the b-tree cursor associated with blob handle p to point to row iRow.\n** If successful, SQLITE_OK is returned and subsequent calls to\n** sqlite3_blob_read() or sqlite3_blob_write() access the specified row.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a value of type TEXT or BLOB in the column nominated when the\n** blob handle was opened, then an error code is returned and *pzErr may\n** be set to point to a buffer containing an error message. It is the\n** responsibility of the caller to free the error message buffer using\n** sqlite3DbFree().\n**\n** If an error does occur, then the b-tree cursor is closed. All subsequent\n** calls to sqlite3_blob_read(), blob_write() or blob_reopen() will \n** immediately return SQLITE_ABORT.\n*/\nstatic int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){\n  int rc;                         /* Error code */\n  char *zErr = 0;                 /* Error message */\n  Vdbe *v = (Vdbe *)p->pStmt;\n\n  /* Set the value of register r[1] in the SQL statement to integer iRow. \n  ** This is done directly as a performance optimization\n  */\n  v->aMem[1].flags = MEM_Int;\n  v->aMem[1].u.i = iRow;\n\n  /* If the statement has been run before (and is paused at the OP_ResultRow)\n  ** then back it up to the point where it does the OP_NotExists.  This could\n  ** have been down with an extra OP_Goto, but simply setting the program\n  ** counter is faster. */\n  if( v->pc>4 ){\n    v->pc = 4;\n    assert( v->aOp[v->pc].opcode==OP_NotExists );\n    rc = sqlite3VdbeExec(v);\n  }else{\n    rc = sqlite3_step(p->pStmt);\n  }\n  if( rc==SQLITE_ROW ){\n    VdbeCursor *pC = v->apCsr[0];\n    u32 type = pC->nHdrParsed>p->iCol ? pC->aType[p->iCol] : 0;\n    testcase( pC->nHdrParsed==p->iCol );\n    testcase( pC->nHdrParsed==p->iCol+1 );\n    if( type<12 ){\n      zErr = sqlite3MPrintf(p->db, \"cannot open value of type %s\",\n          type==0?\"null\": type==7?\"real\": \"integer\"\n      );\n      rc = SQLITE_ERROR;\n      sqlite3_finalize(p->pStmt);\n      p->pStmt = 0;\n    }else{\n      p->iOffset = pC->aType[p->iCol + pC->nField];\n      p->nByte = sqlite3VdbeSerialTypeLen(type);\n      p->pCsr =  pC->uc.pCursor;\n      sqlite3BtreeIncrblobCursor(p->pCsr);\n    }\n  }\n\n  if( rc==SQLITE_ROW ){\n    rc = SQLITE_OK;\n  }else if( p->pStmt ){\n    rc = sqlite3_finalize(p->pStmt);\n    p->pStmt = 0;\n    if( rc==SQLITE_OK ){\n      zErr = sqlite3MPrintf(p->db, \"no such rowid: %lld\", iRow);\n      rc = SQLITE_ERROR;\n    }else{\n      zErr = sqlite3MPrintf(p->db, \"%s\", sqlite3_errmsg(p->db));\n    }\n  }\n\n  assert( rc!=SQLITE_OK || zErr==0 );\n  assert( rc!=SQLITE_ROW && rc!=SQLITE_DONE );\n\n  *pzErr = zErr;\n  return rc;\n}\n\n/*\n** Open a blob handle.\n*/\nint sqlite3_blob_open(\n  sqlite3* db,            /* The database connection */\n  const char *zDb,        /* The attached database containing the blob */\n  const char *zTable,     /* The table containing the blob */\n  const char *zColumn,    /* The column containing the blob */\n  sqlite_int64 iRow,      /* The row containing the glob */\n  int wrFlag,             /* True -> read/write access, false -> read-only */\n  sqlite3_blob **ppBlob   /* Handle for accessing the blob returned here */\n){\n  int nAttempt = 0;\n  int iCol;               /* Index of zColumn in row-record */\n  int rc = SQLITE_OK;\n  char *zErr = 0;\n  Table *pTab;\n  Incrblob *pBlob = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( ppBlob==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  *ppBlob = 0;\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  wrFlag = !!wrFlag;                /* wrFlag = (wrFlag ? 1 : 0); */\n\n  sqlite3_mutex_enter(db->mutex);\n\n  pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));\n  do {\n    memset(&sParse, 0, sizeof(Parse));\n    if( !pBlob ) goto blob_open_out;\n    sParse.db = db;\n    sqlite3DbFree(db, zErr);\n    zErr = 0;\n\n    sqlite3BtreeEnterAll(db);\n    pTab = sqlite3LocateTable(&sParse, 0, zTable, zDb);\n    if( pTab && IsVirtual(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open virtual table: %s\", zTable);\n    }\n    if( pTab && !HasRowid(pTab) ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open table without rowid: %s\", zTable);\n    }\n#ifndef SQLITE_OMIT_VIEW\n    if( pTab && pTab->pSelect ){\n      pTab = 0;\n      sqlite3ErrorMsg(&sParse, \"cannot open view: %s\", zTable);\n    }\n#endif\n    if( !pTab ){\n      if( sParse.zErrMsg ){\n        sqlite3DbFree(db, zErr);\n        zErr = sParse.zErrMsg;\n        sParse.zErrMsg = 0;\n      }\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n    pBlob->pTab = pTab;\n    pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;\n\n    /* Now search pTab for the exact column. */\n    for(iCol=0; iCol<pTab->nCol; iCol++) {\n      if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){\n        break;\n      }\n    }\n    if( iCol==pTab->nCol ){\n      sqlite3DbFree(db, zErr);\n      zErr = sqlite3MPrintf(db, \"no such column: \\\"%s\\\"\", zColumn);\n      rc = SQLITE_ERROR;\n      sqlite3BtreeLeaveAll(db);\n      goto blob_open_out;\n    }\n\n    /* If the value is being opened for writing, check that the\n    ** column is not indexed, and that it is not part of a foreign key. \n    */\n    if( wrFlag ){\n      const char *zFault = 0;\n      Index *pIdx;\n#ifndef SQLITE_OMIT_FOREIGN_KEY\n      if( db->flags&SQLITE_ForeignKeys ){\n        /* Check that the column is not part of an FK child key definition. It\n        ** is not necessary to check if it is part of a parent key, as parent\n        ** key columns must be indexed. The check below will pick up this \n        ** case.  */\n        FKey *pFKey;\n        for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){\n          int j;\n          for(j=0; j<pFKey->nCol; j++){\n            if( pFKey->aCol[j].iFrom==iCol ){\n              zFault = \"foreign key\";\n            }\n          }\n        }\n      }\n#endif\n      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n        int j;\n        for(j=0; j<pIdx->nKeyCol; j++){\n          /* FIXME: Be smarter about indexes that use expressions */\n          if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==XN_EXPR ){\n            zFault = \"indexed\";\n          }\n        }\n      }\n      if( zFault ){\n        sqlite3DbFree(db, zErr);\n        zErr = sqlite3MPrintf(db, \"cannot open %s column for writing\", zFault);\n        rc = SQLITE_ERROR;\n        sqlite3BtreeLeaveAll(db);\n        goto blob_open_out;\n      }\n    }\n\n    pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(&sParse);\n    assert( pBlob->pStmt || db->mallocFailed );\n    if( pBlob->pStmt ){\n      \n      /* This VDBE program seeks a btree cursor to the identified \n      ** db/table/row entry. The reason for using a vdbe program instead\n      ** of writing code to use the b-tree layer directly is that the\n      ** vdbe program will take advantage of the various transaction,\n      ** locking and error handling infrastructure built into the vdbe.\n      **\n      ** After seeking the cursor, the vdbe executes an OP_ResultRow.\n      ** Code external to the Vdbe then \"borrows\" the b-tree cursor and\n      ** uses it to implement the blob_read(), blob_write() and \n      ** blob_bytes() functions.\n      **\n      ** The sqlite3_blob_close() function finalizes the vdbe program,\n      ** which closes the b-tree cursor and (possibly) commits the \n      ** transaction.\n      */\n      static const int iLn = VDBE_OFFSET_LINENO(2);\n      static const VdbeOpList openBlob[] = {\n        {OP_TableLock,      0, 0, 0},  /* 0: Acquire a read or write lock */\n        {OP_OpenRead,       0, 0, 0},  /* 1: Open a cursor */\n        /* blobSeekToRow() will initialize r[1] to the desired rowid */\n        {OP_NotExists,      0, 5, 1},  /* 2: Seek the cursor to rowid=r[1] */\n        {OP_Column,         0, 0, 1},  /* 3  */\n        {OP_ResultRow,      1, 0, 0},  /* 4  */\n        {OP_Halt,           0, 0, 0},  /* 5  */\n      };\n      Vdbe *v = (Vdbe *)pBlob->pStmt;\n      int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n      VdbeOp *aOp;\n\n      sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, wrFlag, \n                           pTab->pSchema->schema_cookie,\n                           pTab->pSchema->iGeneration);\n      sqlite3VdbeChangeP5(v, 1);\n      assert( sqlite3VdbeCurrentAddr(v)==2 || db->mallocFailed );\n      aOp = sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn);\n\n      /* Make sure a mutex is held on the table to be accessed */\n      sqlite3VdbeUsesBtree(v, iDb); \n\n      if( db->mallocFailed==0 ){\n        assert( aOp!=0 );\n        /* Configure the OP_TableLock instruction */\n#ifdef SQLITE_OMIT_SHARED_CACHE\n        aOp[0].opcode = OP_Noop;\n#else\n        aOp[0].p1 = iDb;\n        aOp[0].p2 = pTab->tnum;\n        aOp[0].p3 = wrFlag;\n        sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);\n      }\n      if( db->mallocFailed==0 ){\n#endif\n\n        /* Remove either the OP_OpenWrite or OpenRead. Set the P2 \n        ** parameter of the other to pTab->tnum.  */\n        if( wrFlag ) aOp[1].opcode = OP_OpenWrite;\n        aOp[1].p2 = pTab->tnum;\n        aOp[1].p3 = iDb;   \n\n        /* Configure the number of columns. Configure the cursor to\n        ** think that the table has one more column than it really\n        ** does. An OP_Column to retrieve this imaginary column will\n        ** always return an SQL NULL. This is useful because it means\n        ** we can invoke OP_Column to fill in the vdbe cursors type \n        ** and offset cache without causing any IO.\n        */\n        aOp[1].p4type = P4_INT32;\n        aOp[1].p4.i = pTab->nCol+1;\n        aOp[3].p2 = pTab->nCol;\n\n        sParse.nVar = 0;\n        sParse.nMem = 1;\n        sParse.nTab = 1;\n        sqlite3VdbeMakeReady(v, &sParse);\n      }\n    }\n   \n    pBlob->iCol = iCol;\n    pBlob->db = db;\n    sqlite3BtreeLeaveAll(db);\n    if( db->mallocFailed ){\n      goto blob_open_out;\n    }\n    rc = blobSeekToRow(pBlob, iRow, &zErr);\n  } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );\n\nblob_open_out:\n  if( rc==SQLITE_OK && db->mallocFailed==0 ){\n    *ppBlob = (sqlite3_blob *)pBlob;\n  }else{\n    if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);\n    sqlite3DbFree(db, pBlob);\n  }\n  sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n  sqlite3DbFree(db, zErr);\n  sqlite3ParserReset(&sParse);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Close a blob handle that was previously created using\n** sqlite3_blob_open().\n*/\nint sqlite3_blob_close(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  int rc;\n  sqlite3 *db;\n\n  if( p ){\n    db = p->db;\n    sqlite3_mutex_enter(db->mutex);\n    rc = sqlite3_finalize(p->pStmt);\n    sqlite3DbFree(db, p);\n    sqlite3_mutex_leave(db->mutex);\n  }else{\n    rc = SQLITE_OK;\n  }\n  return rc;\n}\n\n/*\n** Perform a read or write operation on a blob\n*/\nstatic int blobReadWrite(\n  sqlite3_blob *pBlob, \n  void *z, \n  int n, \n  int iOffset, \n  int (*xCall)(BtCursor*, u32, u32, void*)\n){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  Vdbe *v;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n  v = (Vdbe*)p->pStmt;\n\n  if( n<0 || iOffset<0 || ((sqlite3_int64)iOffset+n)>p->nByte ){\n    /* Request is out of range. Return a transient error. */\n    rc = SQLITE_ERROR;\n  }else if( v==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is\n    ** returned, clean-up the statement handle.\n    */\n    assert( db == v->db );\n    sqlite3BtreeEnterCursor(p->pCsr);\n\n#ifdef SQLITE_ENABLE_PREUPDATE_HOOK\n    if( xCall==sqlite3BtreePutData && db->xPreUpdateCallback ){\n      /* If a pre-update hook is registered and this is a write cursor, \n      ** invoke it here. \n      ** \n      ** TODO: The preupdate-hook is passed SQLITE_DELETE, even though this\n      ** operation should really be an SQLITE_UPDATE. This is probably\n      ** incorrect, but is convenient because at this point the new.* values \n      ** are not easily obtainable. And for the sessions module, an \n      ** SQLITE_UPDATE where the PK columns do not change is handled in the \n      ** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually\n      ** slightly more efficient). Since you cannot write to a PK column\n      ** using the incremental-blob API, this works. For the sessions module\n      ** anyhow.\n      */\n      sqlite3_int64 iKey;\n      iKey = sqlite3BtreeIntegerKey(p->pCsr);\n      sqlite3VdbePreUpdateHook(\n          v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1\n      );\n    }\n#endif\n\n    rc = xCall(p->pCsr, iOffset+p->iOffset, n, z);\n    sqlite3BtreeLeaveCursor(p->pCsr);\n    if( rc==SQLITE_ABORT ){\n      sqlite3VdbeFinalize(v);\n      p->pStmt = 0;\n    }else{\n      v->rc = rc;\n    }\n  }\n  sqlite3Error(db, rc);\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** Read data from a blob handle.\n*/\nint sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreePayloadChecked);\n}\n\n/*\n** Write data to a blob handle.\n*/\nint sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){\n  return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);\n}\n\n/*\n** Query a blob handle for the size of the data.\n**\n** The Incrblob.nByte field is fixed for the lifetime of the Incrblob\n** so no mutex is required for access.\n*/\nint sqlite3_blob_bytes(sqlite3_blob *pBlob){\n  Incrblob *p = (Incrblob *)pBlob;\n  return (p && p->pStmt) ? p->nByte : 0;\n}\n\n/*\n** Move an existing blob handle to point to a different row of the same\n** database table.\n**\n** If an error occurs, or if the specified row does not exist or does not\n** contain a blob or text value, then an error code is returned and the\n** database handle error code and message set. If this happens, then all \n** subsequent calls to sqlite3_blob_xxx() functions (except blob_close()) \n** immediately return SQLITE_ABORT.\n*/\nint sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){\n  int rc;\n  Incrblob *p = (Incrblob *)pBlob;\n  sqlite3 *db;\n\n  if( p==0 ) return SQLITE_MISUSE_BKPT;\n  db = p->db;\n  sqlite3_mutex_enter(db->mutex);\n\n  if( p->pStmt==0 ){\n    /* If there is no statement handle, then the blob-handle has\n    ** already been invalidated. Return SQLITE_ABORT in this case.\n    */\n    rc = SQLITE_ABORT;\n  }else{\n    char *zErr;\n    rc = blobSeekToRow(p, iRow, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorWithMsg(db, rc, (zErr ? \"%s\" : 0), zErr);\n      sqlite3DbFree(db, zErr);\n    }\n    assert( rc!=SQLITE_SCHEMA );\n  }\n\n  rc = sqlite3ApiExit(db, rc);\n  assert( rc==SQLITE_OK || p->pStmt==0 );\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* #ifndef SQLITE_OMIT_INCRBLOB */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbemem.c",
    "content": "/*\n** 2004 May 26\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code use to manipulate \"Mem\" structure.  A \"Mem\"\n** stores a single value in the VDBE.  Mem is an opaque structure visible\n** only within the VDBE.  Interface routines refer to a Mem using the\n** name sqlite_value\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n#ifdef SQLITE_DEBUG\n/*\n** Check invariants on a Mem object.\n**\n** This routine is intended for use inside of assert() statements, like\n** this:    assert( sqlite3VdbeCheckMemInvariants(pMem) );\n*/\nint sqlite3VdbeCheckMemInvariants(Mem *p){\n  /* If MEM_Dyn is set then Mem.xDel!=0.  \n  ** Mem.xDel might not be initialized if MEM_Dyn is clear.\n  */\n  assert( (p->flags & MEM_Dyn)==0 || p->xDel!=0 );\n\n  /* MEM_Dyn may only be set if Mem.szMalloc==0.  In this way we\n  ** ensure that if Mem.szMalloc>0 then it is safe to do\n  ** Mem.z = Mem.zMalloc without having to check Mem.flags&MEM_Dyn.\n  ** That saves a few cycles in inner loops. */\n  assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 );\n\n  /* Cannot be both MEM_Int and MEM_Real at the same time */\n  assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) );\n\n  if( p->flags & MEM_Null ){\n    /* Cannot be both MEM_Null and some other type */\n    assert( (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob\n                         |MEM_RowSet|MEM_Frame|MEM_Agg|MEM_Zero))==0 );\n\n    /* If MEM_Null is set, then either the value is a pure NULL (the usual\n    ** case) or it is a pointer set using sqlite3_bind_pointer() or\n    ** sqlite3_result_pointer().  If a pointer, then MEM_Term must also be\n    ** set.\n    */\n    if( (p->flags & (MEM_Term|MEM_Subtype))==(MEM_Term|MEM_Subtype) ){\n      /* This is a pointer type.  There may be a flag to indicate what to\n      ** do with the pointer. */\n      assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n              ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );\n\n      /* No other bits set */\n      assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype\n                           |MEM_Dyn|MEM_Ephem|MEM_Static))==0 );\n    }else{\n      /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,\n      ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */\n    }\n  }else{\n    /* The MEM_Cleared bit is only allowed on NULLs */\n    assert( (p->flags & MEM_Cleared)==0 );\n  }\n\n  /* The szMalloc field holds the correct memory allocation size */\n  assert( p->szMalloc==0\n       || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) );\n\n  /* If p holds a string or blob, the Mem.z must point to exactly\n  ** one of the following:\n  **\n  **   (1) Memory in Mem.zMalloc and managed by the Mem object\n  **   (2) Memory to be freed using Mem.xDel\n  **   (3) An ephemeral string or blob\n  **   (4) A static string or blob\n  */\n  if( (p->flags & (MEM_Str|MEM_Blob)) && p->n>0 ){\n    assert( \n      ((p->szMalloc>0 && p->z==p->zMalloc)? 1 : 0) +\n      ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +\n      ((p->flags&MEM_Static)!=0 ? 1 : 0) == 1\n    );\n  }\n  return 1;\n}\n#endif\n\n\n/*\n** If pMem is an object with a valid string representation, this routine\n** ensures the internal encoding for the string representation is\n** 'desiredEnc', one of SQLITE_UTF8, SQLITE_UTF16LE or SQLITE_UTF16BE.\n**\n** If pMem is not a string object, or the encoding of the string\n** representation is already stored using the requested encoding, then this\n** routine is a no-op.\n**\n** SQLITE_OK is returned if the conversion is successful (or not required).\n** SQLITE_NOMEM may be returned if a malloc() fails during conversion\n** between formats.\n*/\nint sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){\n#ifndef SQLITE_OMIT_UTF16\n  int rc;\n#endif\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE\n           || desiredEnc==SQLITE_UTF16BE );\n  if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){\n    return SQLITE_OK;\n  }\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n#ifdef SQLITE_OMIT_UTF16\n  return SQLITE_ERROR;\n#else\n\n  /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned,\n  ** then the encoding of the value may not have changed.\n  */\n  rc = sqlite3VdbeMemTranslate(pMem, (u8)desiredEnc);\n  assert(rc==SQLITE_OK    || rc==SQLITE_NOMEM);\n  assert(rc==SQLITE_OK    || pMem->enc!=desiredEnc);\n  assert(rc==SQLITE_NOMEM || pMem->enc==desiredEnc);\n  return rc;\n#endif\n}\n\n/*\n** Make sure pMem->z points to a writable allocation of at least \n** min(n,32) bytes.\n**\n** If the bPreserve argument is true, then copy of the content of\n** pMem->z into the new allocation.  pMem must be either a string or\n** blob if bPreserve is true.  If bPreserve is false, any prior content\n** in pMem->z is discarded.\n*/\nSQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){\n  assert( sqlite3VdbeCheckMemInvariants(pMem) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  testcase( pMem->db==0 );\n\n  /* If the bPreserve flag is set to true, then the memory cell must already\n  ** contain a valid string or blob value.  */\n  assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );\n  testcase( bPreserve && pMem->z==0 );\n\n  assert( pMem->szMalloc==0\n       || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );\n  if( n<32 ) n = 32;\n  if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){\n    pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);\n    bPreserve = 0;\n  }else{\n    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n    pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);\n  }\n  if( pMem->zMalloc==0 ){\n    sqlite3VdbeMemSetNull(pMem);\n    pMem->z = 0;\n    pMem->szMalloc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }else{\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }\n\n  if( bPreserve && pMem->z ){\n    assert( pMem->z!=pMem->zMalloc );\n    memcpy(pMem->zMalloc, pMem->z, pMem->n);\n  }\n  if( (pMem->flags&MEM_Dyn)!=0 ){\n    assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );\n    pMem->xDel((void *)(pMem->z));\n  }\n\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);\n  return SQLITE_OK;\n}\n\n/*\n** Change the pMem->zMalloc allocation to be at least szNew bytes.\n** If pMem->zMalloc already meets or exceeds the requested size, this\n** routine is a no-op.\n**\n** Any prior string or blob content in the pMem object may be discarded.\n** The pMem->xDel destructor is called, if it exists.  Though MEM_Str\n** and MEM_Blob values may be discarded, MEM_Int, MEM_Real, and MEM_Null\n** values are preserved.\n**\n** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM)\n** if unable to complete the resizing.\n*/\nint sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){\n  assert( szNew>0 );\n  assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );\n  if( pMem->szMalloc<szNew ){\n    return sqlite3VdbeMemGrow(pMem, szNew, 0);\n  }\n  assert( (pMem->flags & MEM_Dyn)==0 );\n  pMem->z = pMem->zMalloc;\n  pMem->flags &= (MEM_Null|MEM_Int|MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** It is already known that pMem contains an unterminated string.\n** Add the zero terminator.\n*/\nstatic SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){\n  if( sqlite3VdbeMemGrow(pMem, pMem->n+2, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pMem->z[pMem->n] = 0;\n  pMem->z[pMem->n+1] = 0;\n  pMem->flags |= MEM_Term;\n  return SQLITE_OK;\n}\n\n/*\n** Change pMem so that its MEM_Str or MEM_Blob value is stored in\n** MEM.zMalloc, where it can be safely written.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails.\n*/\nint sqlite3VdbeMemMakeWriteable(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){\n    if( ExpandBlob(pMem) ) return SQLITE_NOMEM;\n    if( pMem->szMalloc==0 || pMem->z!=pMem->zMalloc ){\n      int rc = vdbeMemAddTerminator(pMem);\n      if( rc ) return rc;\n    }\n  }\n  pMem->flags &= ~MEM_Ephem;\n#ifdef SQLITE_DEBUG\n  pMem->pScopyFrom = 0;\n#endif\n\n  return SQLITE_OK;\n}\n\n/*\n** If the given Mem* has a zero-filled tail, turn it into an ordinary\n** blob stored in dynamically allocated space.\n*/\n#ifndef SQLITE_OMIT_INCRBLOB\nint sqlite3VdbeMemExpandBlob(Mem *pMem){\n  int nByte;\n  assert( pMem->flags & MEM_Zero );\n  assert( pMem->flags&MEM_Blob );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n\n  /* Set nByte to the number of bytes required to store the expanded blob. */\n  nByte = pMem->n + pMem->u.nZero;\n  if( nByte<=0 ){\n    nByte = 1;\n  }\n  if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  memset(&pMem->z[pMem->n], 0, pMem->u.nZero);\n  pMem->n += pMem->u.nZero;\n  pMem->flags &= ~(MEM_Zero|MEM_Term);\n  return SQLITE_OK;\n}\n#endif\n\n/*\n** Make sure the given Mem is \\u0000 terminated.\n*/\nint sqlite3VdbeMemNulTerminate(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) );\n  testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 );\n  if( (pMem->flags & (MEM_Term|MEM_Str))!=MEM_Str ){\n    return SQLITE_OK;   /* Nothing to do */\n  }else{\n    return vdbeMemAddTerminator(pMem);\n  }\n}\n\n/*\n** Add MEM_Str to the set of representations for the given Mem.  Numbers\n** are converted using sqlite3_snprintf().  Converting a BLOB to a string\n** is a no-op.\n**\n** Existing representations MEM_Int and MEM_Real are invalidated if\n** bForce is true but are retained if bForce is false.\n**\n** A MEM_Null value will never be passed to this function. This function is\n** used for converting values to text for returning to the user (i.e. via\n** sqlite3_value_text()), or for ensuring that values to be used as btree\n** keys are strings. In the former case a NULL pointer is returned the\n** user and the latter is an internal programming error.\n*/\nint sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){\n  int fg = pMem->flags;\n  const int nByte = 32;\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( !(fg&MEM_Zero) );\n  assert( !(fg&(MEM_Str|MEM_Blob)) );\n  assert( fg&(MEM_Int|MEM_Real) );\n  assert( (pMem->flags&MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n\n  if( sqlite3VdbeMemClearAndResize(pMem, nByte) ){\n    pMem->enc = 0;\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8\n  ** string representation of the value. Then, if the required encoding\n  ** is UTF-16le or UTF-16be do a translation.\n  ** \n  ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.\n  */\n  if( fg & MEM_Int ){\n    sqlite3_snprintf(nByte, pMem->z, \"%lld\", pMem->u.i);\n  }else{\n    assert( fg & MEM_Real );\n    sqlite3_snprintf(nByte, pMem->z, \"%!.15g\", pMem->u.r);\n  }\n  pMem->n = sqlite3Strlen30(pMem->z);\n  pMem->enc = SQLITE_UTF8;\n  pMem->flags |= MEM_Str|MEM_Term;\n  if( bForce ) pMem->flags &= ~(MEM_Int|MEM_Real);\n  sqlite3VdbeChangeEncoding(pMem, enc);\n  return SQLITE_OK;\n}\n\n/*\n** Memory cell pMem contains the context of an aggregate function.\n** This routine calls the finalize method for that function.  The\n** result of the aggregate is stored back into pMem.\n**\n** Return SQLITE_ERROR if the finalizer reports an error.  SQLITE_OK\n** otherwise.\n*/\nint sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pFunc && pFunc->xFinalize) ){\n    sqlite3_context ctx;\n    Mem t;\n    assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    memset(&ctx, 0, sizeof(ctx));\n    memset(&t, 0, sizeof(t));\n    t.flags = MEM_Null;\n    t.db = pMem->db;\n    ctx.pOut = &t;\n    ctx.pMem = pMem;\n    ctx.pFunc = pFunc;\n    pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */\n    assert( (pMem->flags & MEM_Dyn)==0 );\n    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);\n    memcpy(pMem, &t, sizeof(t));\n    rc = ctx.isError;\n  }\n  return rc;\n}\n\n/*\n** If the memory cell contains a value that must be freed by\n** invoking the external callback in Mem.xDel, then this routine\n** will free that value.  It also sets Mem.flags to MEM_Null.\n**\n** This is a helper routine for sqlite3VdbeMemSetNull() and\n** for sqlite3VdbeMemRelease().  Use those other routines as the\n** entry point for releasing Mem resources.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClearExternAndSetNull(Mem *p){\n  assert( p->db==0 || sqlite3_mutex_held(p->db->mutex) );\n  assert( VdbeMemDynamic(p) );\n  if( p->flags&MEM_Agg ){\n    sqlite3VdbeMemFinalize(p, p->u.pDef);\n    assert( (p->flags & MEM_Agg)==0 );\n    testcase( p->flags & MEM_Dyn );\n  }\n  if( p->flags&MEM_Dyn ){\n    assert( (p->flags&MEM_RowSet)==0 );\n    assert( p->xDel!=SQLITE_DYNAMIC && p->xDel!=0 );\n    p->xDel((void *)p->z);\n  }else if( p->flags&MEM_RowSet ){\n    sqlite3RowSetClear(p->u.pRowSet);\n  }else if( p->flags&MEM_Frame ){\n    VdbeFrame *pFrame = p->u.pFrame;\n    pFrame->pParent = pFrame->v->pDelFrame;\n    pFrame->v->pDelFrame = pFrame;\n  }\n  p->flags = MEM_Null;\n}\n\n/*\n** Release memory held by the Mem p, both external memory cleared\n** by p->xDel and memory in p->zMalloc.\n**\n** This is a helper routine invoked by sqlite3VdbeMemRelease() in\n** the unusual case where there really is memory in p that needs\n** to be freed.\n*/\nstatic SQLITE_NOINLINE void vdbeMemClear(Mem *p){\n  if( VdbeMemDynamic(p) ){\n    vdbeMemClearExternAndSetNull(p);\n  }\n  if( p->szMalloc ){\n    sqlite3DbFreeNN(p->db, p->zMalloc);\n    p->szMalloc = 0;\n  }\n  p->z = 0;\n}\n\n/*\n** Release any memory resources held by the Mem.  Both the memory that is\n** free by Mem.xDel and the Mem.zMalloc allocation are freed.\n**\n** Use this routine prior to clean up prior to abandoning a Mem, or to\n** reset a Mem back to its minimum memory utilization.\n**\n** Use sqlite3VdbeMemSetNull() to release just the Mem.xDel space\n** prior to inserting new content into the Mem.\n*/\nvoid sqlite3VdbeMemRelease(Mem *p){\n  assert( sqlite3VdbeCheckMemInvariants(p) );\n  if( VdbeMemDynamic(p) || p->szMalloc ){\n    vdbeMemClear(p);\n  }\n}\n\n/*\n** Convert a 64-bit IEEE double into a 64-bit signed integer.\n** If the double is out of range of a 64-bit signed integer then\n** return the closest available 64-bit signed integer.\n*/\nstatic SQLITE_NOINLINE i64 doubleToInt64(double r){\n#ifdef SQLITE_OMIT_FLOATING_POINT\n  /* When floating-point is omitted, double and int64 are the same thing */\n  return r;\n#else\n  /*\n  ** Many compilers we encounter do not define constants for the\n  ** minimum and maximum 64-bit integers, or they define them\n  ** inconsistently.  And many do not understand the \"LL\" notation.\n  ** So we define our own static constants here using nothing\n  ** larger than a 32-bit integer constant.\n  */\n  static const i64 maxInt = LARGEST_INT64;\n  static const i64 minInt = SMALLEST_INT64;\n\n  if( r<=(double)minInt ){\n    return minInt;\n  }else if( r>=(double)maxInt ){\n    return maxInt;\n  }else{\n    return (i64)r;\n  }\n#endif\n}\n\n/*\n** Return some kind of integer value which is the best we can do\n** at representing the value that *pMem describes as an integer.\n** If pMem is an integer, then the value is exact.  If pMem is\n** a floating-point then the value returned is the integer part.\n** If pMem is a string or blob, then we make an attempt to convert\n** it into an integer and return that.  If pMem represents an\n** an SQL-NULL value, return 0.\n**\n** If pMem represents a string value, its encoding might be changed.\n*/\nstatic SQLITE_NOINLINE i64 memIntValue(Mem *pMem){\n  i64 value = 0;\n  sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);\n  return value;\n}\ni64 sqlite3VdbeIntValue(Mem *pMem){\n  int flags;\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  flags = pMem->flags;\n  if( flags & MEM_Int ){\n    return pMem->u.i;\n  }else if( flags & MEM_Real ){\n    return doubleToInt64(pMem->u.r);\n  }else if( flags & (MEM_Str|MEM_Blob) ){\n    assert( pMem->z || pMem->n==0 );\n    return memIntValue(pMem);\n  }else{\n    return 0;\n  }\n}\n\n/*\n** Return the best representation of pMem that we can get into a\n** double.  If pMem is already a double or an integer, return its\n** value.  If it is a string or blob, try to convert it to a double.\n** If it is a NULL, return 0.0.\n*/\nstatic SQLITE_NOINLINE double memRealValue(Mem *pMem){\n  /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n  double val = (double)0;\n  sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);\n  return val;\n}\ndouble sqlite3VdbeRealValue(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n  if( pMem->flags & MEM_Real ){\n    return pMem->u.r;\n  }else if( pMem->flags & MEM_Int ){\n    return (double)pMem->u.i;\n  }else if( pMem->flags & (MEM_Str|MEM_Blob) ){\n    return memRealValue(pMem);\n  }else{\n    /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */\n    return (double)0;\n  }\n}\n\n/*\n** The MEM structure is already a MEM_Real.  Try to also make it a\n** MEM_Int if we can.\n*/\nvoid sqlite3VdbeIntegerAffinity(Mem *pMem){\n  i64 ix;\n  assert( pMem->flags & MEM_Real );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  ix = doubleToInt64(pMem->u.r);\n\n  /* Only mark the value as an integer if\n  **\n  **    (1) the round-trip conversion real->int->real is a no-op, and\n  **    (2) The integer is neither the largest nor the smallest\n  **        possible integer (ticket #3922)\n  **\n  ** The second and third terms in the following conditional enforces\n  ** the second condition under the assumption that addition overflow causes\n  ** values to wrap around.\n  */\n  if( pMem->u.r==ix && ix>SMALLEST_INT64 && ix<LARGEST_INT64 ){\n    pMem->u.i = ix;\n    MemSetTypeFlag(pMem, MEM_Int);\n  }\n}\n\n/*\n** Convert pMem to type integer.  Invalidate any prior representations.\n*/\nint sqlite3VdbeMemIntegerify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.i = sqlite3VdbeIntValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Int);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it is of type MEM_Real.\n** Invalidate any prior representations.\n*/\nint sqlite3VdbeMemRealify(Mem *pMem){\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( EIGHT_BYTE_ALIGNMENT(pMem) );\n\n  pMem->u.r = sqlite3VdbeRealValue(pMem);\n  MemSetTypeFlag(pMem, MEM_Real);\n  return SQLITE_OK;\n}\n\n/*\n** Convert pMem so that it has types MEM_Real or MEM_Int or both.\n** Invalidate any prior representations.\n**\n** Every effort is made to force the conversion, even if the input\n** is a string that does not look completely like a number.  Convert\n** as much of the string as we can and ignore the rest.\n*/\nint sqlite3VdbeMemNumerify(Mem *pMem){\n  if( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))==0 ){\n    int rc;\n    assert( (pMem->flags & (MEM_Blob|MEM_Str))!=0 );\n    assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n    rc = sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc);\n    if( rc==0 ){\n      MemSetTypeFlag(pMem, MEM_Int);\n    }else{\n      i64 i = pMem->u.i;\n      sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc);\n      if( rc==1 && pMem->u.r==(double)i ){\n        pMem->u.i = i;\n        MemSetTypeFlag(pMem, MEM_Int);\n      }else{\n        MemSetTypeFlag(pMem, MEM_Real);\n      }\n    }\n  }\n  assert( (pMem->flags & (MEM_Int|MEM_Real|MEM_Null))!=0 );\n  pMem->flags &= ~(MEM_Str|MEM_Blob|MEM_Zero);\n  return SQLITE_OK;\n}\n\n/*\n** Cast the datatype of the value in pMem according to the affinity\n** \"aff\".  Casting is different from applying affinity in that a cast\n** is forced.  In other words, the value is converted into the desired\n** affinity even if that results in loss of data.  This routine is\n** used (for example) to implement the SQL \"cast()\" operator.\n*/\nvoid sqlite3VdbeMemCast(Mem *pMem, u8 aff, u8 encoding){\n  if( pMem->flags & MEM_Null ) return;\n  switch( aff ){\n    case SQLITE_AFF_BLOB: {   /* Really a cast to BLOB */\n      if( (pMem->flags & MEM_Blob)==0 ){\n        sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n        assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n        if( pMem->flags & MEM_Str ) MemSetTypeFlag(pMem, MEM_Blob);\n      }else{\n        pMem->flags &= ~(MEM_TypeMask&~MEM_Blob);\n      }\n      break;\n    }\n    case SQLITE_AFF_NUMERIC: {\n      sqlite3VdbeMemNumerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_INTEGER: {\n      sqlite3VdbeMemIntegerify(pMem);\n      break;\n    }\n    case SQLITE_AFF_REAL: {\n      sqlite3VdbeMemRealify(pMem);\n      break;\n    }\n    default: {\n      assert( aff==SQLITE_AFF_TEXT );\n      assert( MEM_Str==(MEM_Blob>>3) );\n      pMem->flags |= (pMem->flags&MEM_Blob)>>3;\n      sqlite3ValueApplyAffinity(pMem, SQLITE_AFF_TEXT, encoding);\n      assert( pMem->flags & MEM_Str || pMem->db->mallocFailed );\n      pMem->flags &= ~(MEM_Int|MEM_Real|MEM_Blob|MEM_Zero);\n      break;\n    }\n  }\n}\n\n/*\n** Initialize bulk memory to be a consistent Mem object.\n**\n** The minimum amount of initialization feasible is performed.\n*/\nvoid sqlite3VdbeMemInit(Mem *pMem, sqlite3 *db, u16 flags){\n  assert( (flags & ~MEM_TypeMask)==0 );\n  pMem->flags = flags;\n  pMem->db = db;\n  pMem->szMalloc = 0;\n}\n\n\n/*\n** Delete any previous value and set the value stored in *pMem to NULL.\n**\n** This routine calls the Mem.xDel destructor to dispose of values that\n** require the destructor.  But it preserves the Mem.zMalloc memory allocation.\n** To free all resources, use sqlite3VdbeMemRelease(), which both calls this\n** routine to invoke the destructor and deallocates Mem.zMalloc.\n**\n** Use this routine to reset the Mem prior to insert a new value.\n**\n** Use sqlite3VdbeMemRelease() to complete erase the Mem prior to abandoning it.\n*/\nvoid sqlite3VdbeMemSetNull(Mem *pMem){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeMemClearExternAndSetNull(pMem);\n  }else{\n    pMem->flags = MEM_Null;\n  }\n}\nvoid sqlite3ValueSetNull(sqlite3_value *p){\n  sqlite3VdbeMemSetNull((Mem*)p); \n}\n\n/*\n** Delete any previous value and set the value to be a BLOB of length\n** n containing all zeros.\n*/\nvoid sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){\n  sqlite3VdbeMemRelease(pMem);\n  pMem->flags = MEM_Blob|MEM_Zero;\n  pMem->n = 0;\n  if( n<0 ) n = 0;\n  pMem->u.nZero = n;\n  pMem->enc = SQLITE_UTF8;\n  pMem->z = 0;\n}\n\n/*\n** The pMem is known to contain content that needs to be destroyed prior\n** to a value change.  So invoke the destructor, then set the value to\n** a 64-bit integer.\n*/\nstatic SQLITE_NOINLINE void vdbeReleaseAndSetInt64(Mem *pMem, i64 val){\n  sqlite3VdbeMemSetNull(pMem);\n  pMem->u.i = val;\n  pMem->flags = MEM_Int;\n}\n\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type INTEGER.\n*/\nvoid sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){\n  if( VdbeMemDynamic(pMem) ){\n    vdbeReleaseAndSetInt64(pMem, val);\n  }else{\n    pMem->u.i = val;\n    pMem->flags = MEM_Int;\n  }\n}\n\n/* A no-op destructor */\nstatic void sqlite3NoopDestructor(void *p){ UNUSED_PARAMETER(p); }\n\n/*\n** Set the value stored in *pMem should already be a NULL.\n** Also store a pointer to go with it.\n*/\nvoid sqlite3VdbeMemSetPointer(\n  Mem *pMem,\n  void *pPtr,\n  const char *zPType,\n  void (*xDestructor)(void*)\n){\n  assert( pMem->flags==MEM_Null );\n  pMem->u.zPType = zPType ? zPType : \"\";\n  pMem->z = pPtr;\n  pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;\n  pMem->eSubtype = 'p';\n  pMem->xDel = xDestructor ? xDestructor : sqlite3NoopDestructor;\n}\n\n#ifndef SQLITE_OMIT_FLOATING_POINT\n/*\n** Delete any previous value and set the value stored in *pMem to val,\n** manifest type REAL.\n*/\nvoid sqlite3VdbeMemSetDouble(Mem *pMem, double val){\n  sqlite3VdbeMemSetNull(pMem);\n  if( !sqlite3IsNaN(val) ){\n    pMem->u.r = val;\n    pMem->flags = MEM_Real;\n  }\n}\n#endif\n\n/*\n** Delete any previous value and set the value of pMem to be an\n** empty boolean index.\n*/\nvoid sqlite3VdbeMemSetRowSet(Mem *pMem){\n  sqlite3 *db = pMem->db;\n  assert( db!=0 );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  sqlite3VdbeMemRelease(pMem);\n  pMem->zMalloc = sqlite3DbMallocRawNN(db, 64);\n  if( db->mallocFailed ){\n    pMem->flags = MEM_Null;\n    pMem->szMalloc = 0;\n  }else{\n    assert( pMem->zMalloc );\n    pMem->szMalloc = sqlite3DbMallocSize(db, pMem->zMalloc);\n    pMem->u.pRowSet = sqlite3RowSetInit(db, pMem->zMalloc, pMem->szMalloc);\n    assert( pMem->u.pRowSet!=0 );\n    pMem->flags = MEM_RowSet;\n  }\n}\n\n/*\n** Return true if the Mem object contains a TEXT or BLOB that is\n** too large - whose size exceeds SQLITE_MAX_LENGTH.\n*/\nint sqlite3VdbeMemTooBig(Mem *p){\n  assert( p->db!=0 );\n  if( p->flags & (MEM_Str|MEM_Blob) ){\n    int n = p->n;\n    if( p->flags & MEM_Zero ){\n      n += p->u.nZero;\n    }\n    return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }\n  return 0; \n}\n\n#ifdef SQLITE_DEBUG\n/*\n** This routine prepares a memory cell for modification by breaking\n** its link to a shallow copy and by marking any current shallow\n** copies of this cell as invalid.\n**\n** This is used for testing and debugging only - to make sure shallow\n** copies are not misused.\n*/\nvoid sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){\n  int i;\n  Mem *pX;\n  for(i=0, pX=pVdbe->aMem; i<pVdbe->nMem; i++, pX++){\n    if( pX->pScopyFrom==pMem ){\n      pX->flags |= MEM_Undefined;\n      pX->pScopyFrom = 0;\n    }\n  }\n  pMem->pScopyFrom = 0;\n}\n#endif /* SQLITE_DEBUG */\n\n\n/*\n** Make an shallow copy of pFrom into pTo.  Prior contents of\n** pTo are freed.  The pFrom->z field is not duplicated.  If\n** pFrom->z is used, then pTo->z points to the same thing as pFrom->z\n** and flags gets srcType (either MEM_Ephem or MEM_Static).\n*/\nstatic SQLITE_NOINLINE void vdbeClrCopy(Mem *pTo, const Mem *pFrom, int eType){\n  vdbeMemClearExternAndSetNull(pTo);\n  assert( !VdbeMemDynamic(pTo) );\n  sqlite3VdbeMemShallowCopy(pTo, pFrom, eType);\n}\nvoid sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  assert( pTo->db==pFrom->db );\n  if( VdbeMemDynamic(pTo) ){ vdbeClrCopy(pTo,pFrom,srcType); return; }\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  if( (pFrom->flags&MEM_Static)==0 ){\n    pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);\n    assert( srcType==MEM_Ephem || srcType==MEM_Static );\n    pTo->flags |= srcType;\n  }\n}\n\n/*\n** Make a full copy of pFrom into pTo.  Prior contents of pTo are\n** freed before the copy is made.\n*/\nint sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){\n  int rc = SQLITE_OK;\n\n  assert( (pFrom->flags & MEM_RowSet)==0 );\n  if( VdbeMemDynamic(pTo) ) vdbeMemClearExternAndSetNull(pTo);\n  memcpy(pTo, pFrom, MEMCELLSIZE);\n  pTo->flags &= ~MEM_Dyn;\n  if( pTo->flags&(MEM_Str|MEM_Blob) ){\n    if( 0==(pFrom->flags&MEM_Static) ){\n      pTo->flags |= MEM_Ephem;\n      rc = sqlite3VdbeMemMakeWriteable(pTo);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Transfer the contents of pFrom to pTo. Any existing value in pTo is\n** freed. If pFrom contains ephemeral data, a copy is made.\n**\n** pFrom contains an SQL NULL when this routine returns.\n*/\nvoid sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){\n  assert( pFrom->db==0 || sqlite3_mutex_held(pFrom->db->mutex) );\n  assert( pTo->db==0 || sqlite3_mutex_held(pTo->db->mutex) );\n  assert( pFrom->db==0 || pTo->db==0 || pFrom->db==pTo->db );\n\n  sqlite3VdbeMemRelease(pTo);\n  memcpy(pTo, pFrom, sizeof(Mem));\n  pFrom->flags = MEM_Null;\n  pFrom->szMalloc = 0;\n}\n\n/*\n** Change the value of a Mem to be a string or a BLOB.\n**\n** The memory management strategy depends on the value of the xDel\n** parameter. If the value passed is SQLITE_TRANSIENT, then the \n** string is copied into a (possibly existing) buffer managed by the \n** Mem structure. Otherwise, any existing buffer is freed and the\n** pointer copied.\n**\n** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH\n** size limit) then no memory allocation occurs.  If the string can be\n** stored without allocating memory, then it is.  If a memory allocation\n** is required to store the string, then value of pMem is unchanged.  In\n** either case, SQLITE_TOOBIG is returned.\n*/\nint sqlite3VdbeMemSetStr(\n  Mem *pMem,          /* Memory cell to set to string value */\n  const char *z,      /* String pointer */\n  int n,              /* Bytes in string, or negative */\n  u8 enc,             /* Encoding of z.  0 for BLOBs */\n  void (*xDel)(void*) /* Destructor function */\n){\n  int nByte = n;      /* New value for pMem->n */\n  int iLimit;         /* Maximum allowed string or blob size */\n  u16 flags = 0;      /* New value for pMem->flags */\n\n  assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );\n  assert( (pMem->flags & MEM_RowSet)==0 );\n\n  /* If z is a NULL pointer, set pMem to contain an SQL NULL. */\n  if( !z ){\n    sqlite3VdbeMemSetNull(pMem);\n    return SQLITE_OK;\n  }\n\n  if( pMem->db ){\n    iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH];\n  }else{\n    iLimit = SQLITE_MAX_LENGTH;\n  }\n  flags = (enc==0?MEM_Blob:MEM_Str);\n  if( nByte<0 ){\n    assert( enc!=0 );\n    if( enc==SQLITE_UTF8 ){\n      nByte = 0x7fffffff & (int)strlen(z);\n      if( nByte>iLimit ) nByte = iLimit+1;\n    }else{\n      for(nByte=0; nByte<=iLimit && (z[nByte] | z[nByte+1]); nByte+=2){}\n    }\n    flags |= MEM_Term;\n  }\n\n  /* The following block sets the new values of Mem.z and Mem.xDel. It\n  ** also sets a flag in local variable \"flags\" to indicate the memory\n  ** management (one of MEM_Dyn or MEM_Static).\n  */\n  if( xDel==SQLITE_TRANSIENT ){\n    int nAlloc = nByte;\n    if( flags&MEM_Term ){\n      nAlloc += (enc==SQLITE_UTF8?1:2);\n    }\n    if( nByte>iLimit ){\n      return SQLITE_TOOBIG;\n    }\n    testcase( nAlloc==0 );\n    testcase( nAlloc==31 );\n    testcase( nAlloc==32 );\n    if( sqlite3VdbeMemClearAndResize(pMem, MAX(nAlloc,32)) ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memcpy(pMem->z, z, nAlloc);\n  }else if( xDel==SQLITE_DYNAMIC ){\n    sqlite3VdbeMemRelease(pMem);\n    pMem->zMalloc = pMem->z = (char *)z;\n    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);\n  }else{\n    sqlite3VdbeMemRelease(pMem);\n    pMem->z = (char *)z;\n    pMem->xDel = xDel;\n    flags |= ((xDel==SQLITE_STATIC)?MEM_Static:MEM_Dyn);\n  }\n\n  pMem->n = nByte;\n  pMem->flags = flags;\n  pMem->enc = (enc==0 ? SQLITE_UTF8 : enc);\n\n#ifndef SQLITE_OMIT_UTF16\n  if( pMem->enc!=SQLITE_UTF8 && sqlite3VdbeMemHandleBom(pMem) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  if( nByte>iLimit ){\n    return SQLITE_TOOBIG;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Move data out of a btree key or data field and into a Mem structure.\n** The data is payload from the entry that pCur is currently pointing\n** to.  offset and amt determine what portion of the data or key to retrieve.\n** The result is written into the pMem element.\n**\n** The pMem object must have been initialized.  This routine will use\n** pMem->zMalloc to hold the content from the btree, if possible.  New\n** pMem->zMalloc space will be allocated if necessary.  The calling routine\n** is responsible for making sure that the pMem object is eventually\n** destroyed.\n**\n** If this routine fails for any reason (malloc returns NULL or unable\n** to read from the disk) then the pMem is left in an inconsistent state.\n*/\nstatic SQLITE_NOINLINE int vdbeMemFromBtreeResize(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  int rc;\n  pMem->flags = MEM_Null;\n  if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){\n    rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);\n    if( rc==SQLITE_OK ){\n      pMem->z[amt] = 0;   /* Overrun area used when reading malformed records */\n      pMem->flags = MEM_Blob;\n      pMem->n = (int)amt;\n    }else{\n      sqlite3VdbeMemRelease(pMem);\n    }\n  }\n  return rc;\n}\nint sqlite3VdbeMemFromBtree(\n  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */\n  u32 offset,       /* Offset from the start of data to return bytes from. */\n  u32 amt,          /* Number of bytes to return. */\n  Mem *pMem         /* OUT: Return data in this Mem structure. */\n){\n  char *zData;        /* Data from the btree layer */\n  u32 available = 0;  /* Number of bytes available on the local btree page */\n  int rc = SQLITE_OK; /* Return code */\n\n  assert( sqlite3BtreeCursorIsValid(pCur) );\n  assert( !VdbeMemDynamic(pMem) );\n\n  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() \n  ** that both the BtShared and database handle mutexes are held. */\n  assert( (pMem->flags & MEM_RowSet)==0 );\n  zData = (char *)sqlite3BtreePayloadFetch(pCur, &available);\n  assert( zData!=0 );\n\n  if( offset+amt<=available ){\n    pMem->z = &zData[offset];\n    pMem->flags = MEM_Blob|MEM_Ephem;\n    pMem->n = (int)amt;\n  }else{\n    rc = vdbeMemFromBtreeResize(pCur, offset, amt, pMem);\n  }\n\n  return rc;\n}\n\n/*\n** The pVal argument is known to be a value other than NULL.\n** Convert it into a string with encoding enc and return a pointer\n** to a zero-terminated version of that string.\n*/\nstatic SQLITE_NOINLINE const void *valueToText(sqlite3_value* pVal, u8 enc){\n  assert( pVal!=0 );\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( (pVal->flags & MEM_RowSet)==0 );\n  assert( (pVal->flags & (MEM_Null))==0 );\n  if( pVal->flags & (MEM_Blob|MEM_Str) ){\n    if( ExpandBlob(pVal) ) return 0;\n    pVal->flags |= MEM_Str;\n    if( pVal->enc != (enc & ~SQLITE_UTF16_ALIGNED) ){\n      sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);\n    }\n    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&SQLITE_PTR_TO_INT(pVal->z)) ){\n      assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );\n      if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){\n        return 0;\n      }\n    }\n    sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-31275-44060 */\n  }else{\n    sqlite3VdbeMemStringify(pVal, enc, 0);\n    assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );\n  }\n  assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0\n              || pVal->db->mallocFailed );\n  if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){\n    return pVal->z;\n  }else{\n    return 0;\n  }\n}\n\n/* This function is only available internally, it is not part of the\n** external API. It works in a similar way to sqlite3_value_text(),\n** except the data returned is in the encoding specified by the second\n** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or\n** SQLITE_UTF8.\n**\n** (2006-02-16:)  The enc value can be or-ed with SQLITE_UTF16_ALIGNED.\n** If that is the case, then the result must be aligned on an even byte\n** boundary.\n*/\nconst void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){\n  if( !pVal ) return 0;\n  assert( pVal->db==0 || sqlite3_mutex_held(pVal->db->mutex) );\n  assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) );\n  assert( (pVal->flags & MEM_RowSet)==0 );\n  if( (pVal->flags&(MEM_Str|MEM_Term))==(MEM_Str|MEM_Term) && pVal->enc==enc ){\n    return pVal->z;\n  }\n  if( pVal->flags&MEM_Null ){\n    return 0;\n  }\n  return valueToText(pVal, enc);\n}\n\n/*\n** Create a new sqlite3_value object.\n*/\nsqlite3_value *sqlite3ValueNew(sqlite3 *db){\n  Mem *p = sqlite3DbMallocZero(db, sizeof(*p));\n  if( p ){\n    p->flags = MEM_Null;\n    p->db = db;\n  }\n  return p;\n}\n\n/*\n** Context object passed by sqlite3Stat4ProbeSetValue() through to \n** valueNew(). See comments above valueNew() for details.\n*/\nstruct ValueNewStat4Ctx {\n  Parse *pParse;\n  Index *pIdx;\n  UnpackedRecord **ppRec;\n  int iVal;\n};\n\n/*\n** Allocate and return a pointer to a new sqlite3_value object. If\n** the second argument to this function is NULL, the object is allocated\n** by calling sqlite3ValueNew().\n**\n** Otherwise, if the second argument is non-zero, then this function is \n** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not\n** already been allocated, allocate the UnpackedRecord structure that \n** that function will return to its caller here. Then return a pointer to\n** an sqlite3_value within the UnpackedRecord.a[] array.\n*/\nstatic sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( p ){\n    UnpackedRecord *pRec = p->ppRec[0];\n\n    if( pRec==0 ){\n      Index *pIdx = p->pIdx;      /* Index being probed */\n      int nByte;                  /* Bytes of space to allocate */\n      int i;                      /* Counter variable */\n      int nCol = pIdx->nColumn;   /* Number of index columns including rowid */\n  \n      nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));\n      pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);\n      if( pRec ){\n        pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx);\n        if( pRec->pKeyInfo ){\n          assert( pRec->pKeyInfo->nAllField==nCol );\n          assert( pRec->pKeyInfo->enc==ENC(db) );\n          pRec->aMem = (Mem *)((u8*)pRec + ROUND8(sizeof(UnpackedRecord)));\n          for(i=0; i<nCol; i++){\n            pRec->aMem[i].flags = MEM_Null;\n            pRec->aMem[i].db = db;\n          }\n        }else{\n          sqlite3DbFreeNN(db, pRec);\n          pRec = 0;\n        }\n      }\n      if( pRec==0 ) return 0;\n      p->ppRec[0] = pRec;\n    }\n  \n    pRec->nField = p->iVal+1;\n    return &pRec->aMem[p->iVal];\n  }\n#else\n  UNUSED_PARAMETER(p);\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n  return sqlite3ValueNew(db);\n}\n\n/*\n** The expression object indicated by the second argument is guaranteed\n** to be a scalar SQL function. If\n**\n**   * all function arguments are SQL literals,\n**   * one of the SQLITE_FUNC_CONSTANT or _SLOCHNG function flags is set, and\n**   * the SQLITE_FUNC_NEEDCOLL function flag is not set,\n**\n** then this routine attempts to invoke the SQL function. Assuming no\n** error occurs, output parameter (*ppVal) is set to point to a value \n** object containing the result before returning SQLITE_OK.\n**\n** Affinity aff is applied to the result of the function before returning.\n** If the result is a text value, the sqlite3_value object uses encoding \n** enc.\n**\n** If the conditions above are not met, this function returns SQLITE_OK\n** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to\n** NULL and an SQLite error code returned.\n*/\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\nstatic int valueFromFunction(\n  sqlite3 *db,                    /* The database connection */\n  Expr *p,                        /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 aff,                         /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  sqlite3_context ctx;            /* Context object for function invocation */\n  sqlite3_value **apVal = 0;      /* Function arguments */\n  int nVal = 0;                   /* Size of apVal[] array */\n  FuncDef *pFunc = 0;             /* Function definition */\n  sqlite3_value *pVal = 0;        /* New value */\n  int rc = SQLITE_OK;             /* Return code */\n  ExprList *pList = 0;            /* Function arguments */\n  int i;                          /* Iterator variable */\n\n  assert( pCtx!=0 );\n  assert( (p->flags & EP_TokenOnly)==0 );\n  pList = p->x.pList;\n  if( pList ) nVal = pList->nExpr;\n  pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0);\n  assert( pFunc );\n  if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 \n   || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)\n  ){\n    return SQLITE_OK;\n  }\n\n  if( pList ){\n    apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);\n    if( apVal==0 ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto value_from_function_out;\n    }\n    for(i=0; i<nVal; i++){\n      rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);\n      if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;\n    }\n  }\n\n  pVal = valueNew(db, pCtx);\n  if( pVal==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n    goto value_from_function_out;\n  }\n\n  assert( pCtx->pParse->rc==SQLITE_OK );\n  memset(&ctx, 0, sizeof(ctx));\n  ctx.pOut = pVal;\n  ctx.pFunc = pFunc;\n  pFunc->xSFunc(&ctx, nVal, apVal);\n  if( ctx.isError ){\n    rc = ctx.isError;\n    sqlite3ErrorMsg(pCtx->pParse, \"%s\", sqlite3_value_text(pVal));\n  }else{\n    sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);\n    assert( rc==SQLITE_OK );\n    rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){\n      rc = SQLITE_TOOBIG;\n      pCtx->pParse->nErr++;\n    }\n  }\n  pCtx->pParse->rc = rc;\n\n value_from_function_out:\n  if( rc!=SQLITE_OK ){\n    pVal = 0;\n  }\n  if( apVal ){\n    for(i=0; i<nVal; i++){\n      sqlite3ValueFree(apVal[i]);\n    }\n    sqlite3DbFreeNN(db, apVal);\n  }\n\n  *ppVal = pVal;\n  return rc;\n}\n#else\n# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK\n#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */\n\n/*\n** Extract a value from the supplied expression in the manner described\n** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object\n** using valueNew().\n**\n** If pCtx is NULL and an error occurs after the sqlite3_value object\n** has been allocated, it is freed before returning. Or, if pCtx is not\n** NULL, it is assumed that the caller will free any allocated object\n** in all cases.\n*/\nstatic int valueFromExpr(\n  sqlite3 *db,                    /* The database connection */\n  Expr *pExpr,                    /* The expression to evaluate */\n  u8 enc,                         /* Encoding to use */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal,          /* Write the new value here */\n  struct ValueNewStat4Ctx *pCtx   /* Second argument for valueNew() */\n){\n  int op;\n  char *zVal = 0;\n  sqlite3_value *pVal = 0;\n  int negInt = 1;\n  const char *zNeg = \"\";\n  int rc = SQLITE_OK;\n\n  assert( pExpr!=0 );\n  while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;\n  if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;\n\n  /* Compressed expressions only appear when parsing the DEFAULT clause\n  ** on a table column definition, and hence only when pCtx==0.  This\n  ** check ensures that an EP_TokenOnly expression is never passed down\n  ** into valueFromFunction(). */\n  assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );\n\n  if( op==TK_CAST ){\n    u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);\n    rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);\n    testcase( rc!=SQLITE_OK );\n    if( *ppVal ){\n      sqlite3VdbeMemCast(*ppVal, aff, SQLITE_UTF8);\n      sqlite3ValueApplyAffinity(*ppVal, affinity, SQLITE_UTF8);\n    }\n    return rc;\n  }\n\n  /* Handle negative integers in a single step.  This is needed in the\n  ** case when the value is -9223372036854775808.\n  */\n  if( op==TK_UMINUS\n   && (pExpr->pLeft->op==TK_INTEGER || pExpr->pLeft->op==TK_FLOAT) ){\n    pExpr = pExpr->pLeft;\n    op = pExpr->op;\n    negInt = -1;\n    zNeg = \"-\";\n  }\n\n  if( op==TK_STRING || op==TK_FLOAT || op==TK_INTEGER ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    if( ExprHasProperty(pExpr, EP_IntValue) ){\n      sqlite3VdbeMemSetInt64(pVal, (i64)pExpr->u.iValue*negInt);\n    }else{\n      zVal = sqlite3MPrintf(db, \"%s%s\", zNeg, pExpr->u.zToken);\n      if( zVal==0 ) goto no_mem;\n      sqlite3ValueSetStr(pVal, -1, zVal, SQLITE_UTF8, SQLITE_DYNAMIC);\n    }\n    if( (op==TK_INTEGER || op==TK_FLOAT ) && affinity==SQLITE_AFF_BLOB ){\n      sqlite3ValueApplyAffinity(pVal, SQLITE_AFF_NUMERIC, SQLITE_UTF8);\n    }else{\n      sqlite3ValueApplyAffinity(pVal, affinity, SQLITE_UTF8);\n    }\n    if( pVal->flags & (MEM_Int|MEM_Real) ) pVal->flags &= ~MEM_Str;\n    if( enc!=SQLITE_UTF8 ){\n      rc = sqlite3VdbeChangeEncoding(pVal, enc);\n    }\n  }else if( op==TK_UMINUS ) {\n    /* This branch happens for multiple negative signs.  Ex: -(-5) */\n    if( SQLITE_OK==valueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal,pCtx) \n     && pVal!=0\n    ){\n      sqlite3VdbeMemNumerify(pVal);\n      if( pVal->flags & MEM_Real ){\n        pVal->u.r = -pVal->u.r;\n      }else if( pVal->u.i==SMALLEST_INT64 ){\n        pVal->u.r = -(double)SMALLEST_INT64;\n        MemSetTypeFlag(pVal, MEM_Real);\n      }else{\n        pVal->u.i = -pVal->u.i;\n      }\n      sqlite3ValueApplyAffinity(pVal, affinity, enc);\n    }\n  }else if( op==TK_NULL ){\n    pVal = valueNew(db, pCtx);\n    if( pVal==0 ) goto no_mem;\n    sqlite3VdbeMemNumerify(pVal);\n  }\n#ifndef SQLITE_OMIT_BLOB_LITERAL\n  else if( op==TK_BLOB ){\n    int nVal;\n    assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' );\n    assert( pExpr->u.zToken[1]=='\\'' );\n    pVal = valueNew(db, pCtx);\n    if( !pVal ) goto no_mem;\n    zVal = &pExpr->u.zToken[2];\n    nVal = sqlite3Strlen30(zVal)-1;\n    assert( zVal[nVal]=='\\'' );\n    sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,\n                         0, SQLITE_DYNAMIC);\n  }\n#endif\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  else if( op==TK_FUNCTION && pCtx!=0 ){\n    rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);\n  }\n#endif\n\n  *ppVal = pVal;\n  return rc;\n\nno_mem:\n  sqlite3OomFault(db);\n  sqlite3DbFree(db, zVal);\n  assert( *ppVal==0 );\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  if( pCtx==0 ) sqlite3ValueFree(pVal);\n#else\n  assert( pCtx==0 ); sqlite3ValueFree(pVal);\n#endif\n  return SQLITE_NOMEM_BKPT;\n}\n\n/*\n** Create a new sqlite3_value object, containing the value of pExpr.\n**\n** This only works for very simple expressions that consist of one constant\n** token (i.e. \"5\", \"5.1\", \"'a string'\"). If the expression can\n** be converted directly into a value, then the value is allocated and\n** a pointer written to *ppVal. The caller is responsible for deallocating\n** the value by passing it to sqlite3ValueFree() later on. If the expression\n** cannot be converted to a value, then *ppVal is set to NULL.\n*/\nint sqlite3ValueFromExpr(\n  sqlite3 *db,              /* The database connection */\n  Expr *pExpr,              /* The expression to evaluate */\n  u8 enc,                   /* Encoding to use */\n  u8 affinity,              /* Affinity to use */\n  sqlite3_value **ppVal     /* Write the new value here */\n){\n  return pExpr ? valueFromExpr(db, pExpr, enc, affinity, ppVal, 0) : 0;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** The implementation of the sqlite_record() function. This function accepts\n** a single argument of any type. The return value is a formatted database \n** record (a blob) containing the argument value.\n**\n** This is used to convert the value stored in the 'sample' column of the\n** sqlite_stat3 table to the record format SQLite uses internally.\n*/\nstatic void recordFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const int file_format = 1;\n  u32 iSerial;                    /* Serial type */\n  int nSerial;                    /* Bytes of space for iSerial as varint */\n  u32 nVal;                       /* Bytes of space required for argv[0] */\n  int nRet;\n  sqlite3 *db;\n  u8 *aRet;\n\n  UNUSED_PARAMETER( argc );\n  iSerial = sqlite3VdbeSerialType(argv[0], file_format, &nVal);\n  nSerial = sqlite3VarintLen(iSerial);\n  db = sqlite3_context_db_handle(context);\n\n  nRet = 1 + nSerial + nVal;\n  aRet = sqlite3DbMallocRawNN(db, nRet);\n  if( aRet==0 ){\n    sqlite3_result_error_nomem(context);\n  }else{\n    aRet[0] = nSerial+1;\n    putVarint32(&aRet[1], iSerial);\n    sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);\n    sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);\n    sqlite3DbFreeNN(db, aRet);\n  }\n}\n\n/*\n** Register built-in functions used to help read ANALYZE data.\n*/\nvoid sqlite3AnalyzeFunctions(void){\n  static FuncDef aAnalyzeTableFuncs[] = {\n    FUNCTION(sqlite_record,   1, 0, 0, recordFunc),\n  };\n  sqlite3InsertBuiltinFuncs(aAnalyzeTableFuncs, ArraySize(aAnalyzeTableFuncs));\n}\n\n/*\n** Attempt to extract a value from pExpr and use it to construct *ppVal.\n**\n** If pAlloc is not NULL, then an UnpackedRecord object is created for\n** pAlloc if one does not exist and the new value is added to the\n** UnpackedRecord object.\n**\n** A value is extracted in the following cases:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The expression is a literal value.\n**\n** On success, *ppVal is made to point to the extracted value.  The caller\n** is responsible for ensuring that the value is eventually freed.\n*/\nstatic int stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  struct ValueNewStat4Ctx *pAlloc,/* How to allocate space.  Or NULL */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  int rc = SQLITE_OK;\n  sqlite3_value *pVal = 0;\n  sqlite3 *db = pParse->db;\n\n  /* Skip over any TK_COLLATE nodes */\n  pExpr = sqlite3ExprSkipCollate(pExpr);\n\n  assert( pExpr==0 || pExpr->op!=TK_REGISTER || pExpr->op2!=TK_VARIABLE );\n  if( !pExpr ){\n    pVal = valueNew(db, pAlloc);\n    if( pVal ){\n      sqlite3VdbeMemSetNull((Mem*)pVal);\n    }\n  }else if( pExpr->op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *v;\n    int iBindVar = pExpr->iColumn;\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);\n    if( (v = pParse->pReprepare)!=0 ){\n      pVal = valueNew(db, pAlloc);\n      if( pVal ){\n        rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);\n        sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));\n        pVal->db = pParse->db;\n      }\n    }\n  }else{\n    rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);\n  }\n\n  assert( pVal==0 || pVal->db==db );\n  *ppVal = pVal;\n  return rc;\n}\n\n/*\n** This function is used to allocate and populate UnpackedRecord \n** structures intended to be compared against sample index keys stored \n** in the sqlite_stat4 table.\n**\n** A single call to this function populates zero or more fields of the\n** record starting with field iVal (fields are numbered from left to\n** right starting with 0). A single field is populated if:\n**\n**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,\n**\n**  * The expression is a bound variable, and this is a reprepare, or\n**\n**  * The sqlite3ValueFromExpr() function is able to extract a value \n**    from the expression (i.e. the expression is a literal value).\n**\n** Or, if pExpr is a TK_VECTOR, one field is populated for each of the\n** vector components that match either of the two latter criteria listed\n** above.\n**\n** Before any value is appended to the record, the affinity of the \n** corresponding column within index pIdx is applied to it. Before\n** this function returns, output parameter *pnExtract is set to the\n** number of values appended to the record.\n**\n** When this function is called, *ppRec must either point to an object\n** allocated by an earlier call to this function, or must be NULL. If it\n** is NULL and a value can be successfully extracted, a new UnpackedRecord\n** is allocated (and *ppRec set to point to it) before returning.\n**\n** Unless an error is encountered, SQLITE_OK is returned. It is not an\n** error if a value cannot be extracted from pExpr. If an error does\n** occur, an SQLite error code is returned.\n*/\nint sqlite3Stat4ProbeSetValue(\n  Parse *pParse,                  /* Parse context */\n  Index *pIdx,                    /* Index being probed */\n  UnpackedRecord **ppRec,         /* IN/OUT: Probe record */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  int nElem,                      /* Maximum number of values to append */\n  int iVal,                       /* Array element to populate */\n  int *pnExtract                  /* OUT: Values appended to the record */\n){\n  int rc = SQLITE_OK;\n  int nExtract = 0;\n\n  if( pExpr==0 || pExpr->op!=TK_SELECT ){\n    int i;\n    struct ValueNewStat4Ctx alloc;\n\n    alloc.pParse = pParse;\n    alloc.pIdx = pIdx;\n    alloc.ppRec = ppRec;\n\n    for(i=0; i<nElem; i++){\n      sqlite3_value *pVal = 0;\n      Expr *pElem = (pExpr ? sqlite3VectorFieldSubexpr(pExpr, i) : 0);\n      u8 aff = sqlite3IndexColumnAffinity(pParse->db, pIdx, iVal+i);\n      alloc.iVal = iVal+i;\n      rc = stat4ValueFromExpr(pParse, pElem, aff, &alloc, &pVal);\n      if( !pVal ) break;\n      nExtract++;\n    }\n  }\n\n  *pnExtract = nExtract;\n  return rc;\n}\n\n/*\n** Attempt to extract a value from expression pExpr using the methods\n** as described for sqlite3Stat4ProbeSetValue() above. \n**\n** If successful, set *ppVal to point to a new value object and return \n** SQLITE_OK. If no value can be extracted, but no other error occurs\n** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error\n** does occur, return an SQLite error code. The final value of *ppVal\n** is undefined in this case.\n*/\nint sqlite3Stat4ValueFromExpr(\n  Parse *pParse,                  /* Parse context */\n  Expr *pExpr,                    /* The expression to extract a value from */\n  u8 affinity,                    /* Affinity to use */\n  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */\n){\n  return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal);\n}\n\n/*\n** Extract the iCol-th column from the nRec-byte record in pRec.  Write\n** the column value into *ppVal.  If *ppVal is initially NULL then a new\n** sqlite3_value object is allocated.\n**\n** If *ppVal is initially NULL then the caller is responsible for \n** ensuring that the value written into *ppVal is eventually freed.\n*/\nint sqlite3Stat4Column(\n  sqlite3 *db,                    /* Database handle */\n  const void *pRec,               /* Pointer to buffer containing record */\n  int nRec,                       /* Size of buffer pRec in bytes */\n  int iCol,                       /* Column to extract */\n  sqlite3_value **ppVal           /* OUT: Extracted value */\n){\n  u32 t;                          /* a column type code */\n  int nHdr;                       /* Size of the header in the record */\n  int iHdr;                       /* Next unread header byte */\n  int iField;                     /* Next unread data byte */\n  int szField;                    /* Size of the current data field */\n  int i;                          /* Column index */\n  u8 *a = (u8*)pRec;              /* Typecast byte array */\n  Mem *pMem = *ppVal;             /* Write result into this Mem object */\n\n  assert( iCol>0 );\n  iHdr = getVarint32(a, nHdr);\n  if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;\n  iField = nHdr;\n  for(i=0; i<=iCol; i++){\n    iHdr += getVarint32(&a[iHdr], t);\n    testcase( iHdr==nHdr );\n    testcase( iHdr==nHdr+1 );\n    if( iHdr>nHdr ) return SQLITE_CORRUPT_BKPT;\n    szField = sqlite3VdbeSerialTypeLen(t);\n    iField += szField;\n  }\n  testcase( iField==nRec );\n  testcase( iField==nRec+1 );\n  if( iField>nRec ) return SQLITE_CORRUPT_BKPT;\n  if( pMem==0 ){\n    pMem = *ppVal = sqlite3ValueNew(db);\n    if( pMem==0 ) return SQLITE_NOMEM_BKPT;\n  }\n  sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);\n  pMem->enc = ENC(db);\n  return SQLITE_OK;\n}\n\n/*\n** Unless it is NULL, the argument must be an UnpackedRecord object returned\n** by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes\n** the object.\n*/\nvoid sqlite3Stat4ProbeFree(UnpackedRecord *pRec){\n  if( pRec ){\n    int i;\n    int nCol = pRec->pKeyInfo->nAllField;\n    Mem *aMem = pRec->aMem;\n    sqlite3 *db = aMem[0].db;\n    for(i=0; i<nCol; i++){\n      sqlite3VdbeMemRelease(&aMem[i]);\n    }\n    sqlite3KeyInfoUnref(pRec->pKeyInfo);\n    sqlite3DbFreeNN(db, pRec);\n  }\n}\n#endif /* ifdef SQLITE_ENABLE_STAT4 */\n\n/*\n** Change the string value of an sqlite3_value object\n*/\nvoid sqlite3ValueSetStr(\n  sqlite3_value *v,     /* Value to be set */\n  int n,                /* Length of string z */\n  const void *z,        /* Text of the new string */\n  u8 enc,               /* Encoding to use */\n  void (*xDel)(void*)   /* Destructor for the string */\n){\n  if( v ) sqlite3VdbeMemSetStr((Mem *)v, z, n, enc, xDel);\n}\n\n/*\n** Free an sqlite3_value object\n*/\nvoid sqlite3ValueFree(sqlite3_value *v){\n  if( !v ) return;\n  sqlite3VdbeMemRelease((Mem *)v);\n  sqlite3DbFreeNN(((Mem*)v)->db, v);\n}\n\n/*\n** The sqlite3ValueBytes() routine returns the number of bytes in the\n** sqlite3_value object assuming that it uses the encoding \"enc\".\n** The valueBytes() routine is a helper function.\n*/\nstatic SQLITE_NOINLINE int valueBytes(sqlite3_value *pVal, u8 enc){\n  return valueToText(pVal, enc)!=0 ? pVal->n : 0;\n}\nint sqlite3ValueBytes(sqlite3_value *pVal, u8 enc){\n  Mem *p = (Mem*)pVal;\n  assert( (p->flags & MEM_Null)==0 || (p->flags & (MEM_Str|MEM_Blob))==0 );\n  if( (p->flags & MEM_Str)!=0 && pVal->enc==enc ){\n    return p->n;\n  }\n  if( (p->flags & MEM_Blob)!=0 ){\n    if( p->flags & MEM_Zero ){\n      return p->n + p->u.nZero;\n    }else{\n      return p->n;\n    }\n  }\n  if( p->flags & MEM_Null ) return 0;\n  return valueBytes(pVal, enc);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbesort.c",
    "content": "/*\n** 2011-07-09\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code for the VdbeSorter object, used in concert with\n** a VdbeCursor to sort large numbers of keys for CREATE INDEX statements\n** or by SELECT statements with ORDER BY clauses that cannot be satisfied\n** using indexes and without LIMIT clauses.\n**\n** The VdbeSorter object implements a multi-threaded external merge sort\n** algorithm that is efficient even if the number of elements being sorted\n** exceeds the available memory.\n**\n** Here is the (internal, non-API) interface between this module and the\n** rest of the SQLite system:\n**\n**    sqlite3VdbeSorterInit()       Create a new VdbeSorter object.\n**\n**    sqlite3VdbeSorterWrite()      Add a single new row to the VdbeSorter\n**                                  object.  The row is a binary blob in the\n**                                  OP_MakeRecord format that contains both\n**                                  the ORDER BY key columns and result columns\n**                                  in the case of a SELECT w/ ORDER BY, or\n**                                  the complete record for an index entry\n**                                  in the case of a CREATE INDEX.\n**\n**    sqlite3VdbeSorterRewind()     Sort all content previously added.\n**                                  Position the read cursor on the\n**                                  first sorted element.\n**\n**    sqlite3VdbeSorterNext()       Advance the read cursor to the next sorted\n**                                  element.\n**\n**    sqlite3VdbeSorterRowkey()     Return the complete binary blob for the\n**                                  row currently under the read cursor.\n**\n**    sqlite3VdbeSorterCompare()    Compare the binary blob for the row\n**                                  currently under the read cursor against\n**                                  another binary blob X and report if\n**                                  X is strictly less than the read cursor.\n**                                  Used to enforce uniqueness in a\n**                                  CREATE UNIQUE INDEX statement.\n**\n**    sqlite3VdbeSorterClose()      Close the VdbeSorter object and reclaim\n**                                  all resources.\n**\n**    sqlite3VdbeSorterReset()      Refurbish the VdbeSorter for reuse.  This\n**                                  is like Close() followed by Init() only\n**                                  much faster.\n**\n** The interfaces above must be called in a particular order.  Write() can \n** only occur in between Init()/Reset() and Rewind().  Next(), Rowkey(), and\n** Compare() can only occur in between Rewind() and Close()/Reset(). i.e.\n**\n**   Init()\n**   for each record: Write()\n**   Rewind()\n**     Rowkey()/Compare()\n**   Next() \n**   Close()\n**\n** Algorithm:\n**\n** Records passed to the sorter via calls to Write() are initially held \n** unsorted in main memory. Assuming the amount of memory used never exceeds\n** a threshold, when Rewind() is called the set of records is sorted using\n** an in-memory merge sort. In this case, no temporary files are required\n** and subsequent calls to Rowkey(), Next() and Compare() read records \n** directly from main memory.\n**\n** If the amount of space used to store records in main memory exceeds the\n** threshold, then the set of records currently in memory are sorted and\n** written to a temporary file in \"Packed Memory Array\" (PMA) format.\n** A PMA created at this point is known as a \"level-0 PMA\". Higher levels\n** of PMAs may be created by merging existing PMAs together - for example\n** merging two or more level-0 PMAs together creates a level-1 PMA.\n**\n** The threshold for the amount of main memory to use before flushing \n** records to a PMA is roughly the same as the limit configured for the\n** page-cache of the main database. Specifically, the threshold is set to \n** the value returned by \"PRAGMA main.page_size\" multipled by \n** that returned by \"PRAGMA main.cache_size\", in bytes.\n**\n** If the sorter is running in single-threaded mode, then all PMAs generated\n** are appended to a single temporary file. Or, if the sorter is running in\n** multi-threaded mode then up to (N+1) temporary files may be opened, where\n** N is the configured number of worker threads. In this case, instead of\n** sorting the records and writing the PMA to a temporary file itself, the\n** calling thread usually launches a worker thread to do so. Except, if\n** there are already N worker threads running, the main thread does the work\n** itself.\n**\n** The sorter is running in multi-threaded mode if (a) the library was built\n** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater\n** than zero, and (b) worker threads have been enabled at runtime by calling\n** \"PRAGMA threads=N\" with some value of N greater than 0.\n**\n** When Rewind() is called, any data remaining in memory is flushed to a \n** final PMA. So at this point the data is stored in some number of sorted\n** PMAs within temporary files on disk.\n**\n** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the\n** sorter is running in single-threaded mode, then these PMAs are merged\n** incrementally as keys are retreived from the sorter by the VDBE.  The\n** MergeEngine object, described in further detail below, performs this\n** merge.\n**\n** Or, if running in multi-threaded mode, then a background thread is\n** launched to merge the existing PMAs. Once the background thread has\n** merged T bytes of data into a single sorted PMA, the main thread \n** begins reading keys from that PMA while the background thread proceeds\n** with merging the next T bytes of data. And so on.\n**\n** Parameter T is set to half the value of the memory threshold used \n** by Write() above to determine when to create a new PMA.\n**\n** If there are more than SORTER_MAX_MERGE_COUNT PMAs in total when \n** Rewind() is called, then a hierarchy of incremental-merges is used. \n** First, T bytes of data from the first SORTER_MAX_MERGE_COUNT PMAs on \n** disk are merged together. Then T bytes of data from the second set, and\n** so on, such that no operation ever merges more than SORTER_MAX_MERGE_COUNT\n** PMAs at a time. This done is to improve locality.\n**\n** If running in multi-threaded mode and there are more than\n** SORTER_MAX_MERGE_COUNT PMAs on disk when Rewind() is called, then more\n** than one background thread may be created. Specifically, there may be\n** one background thread for each temporary file on disk, and one background\n** thread to merge the output of each of the others to a single PMA for\n** the main thread to read from.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n/* \n** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various\n** messages to stderr that may be helpful in understanding the performance\n** characteristics of the sorter in multi-threaded mode.\n*/\n#if 0\n# define SQLITE_DEBUG_SORTER_THREADS 1\n#endif\n\n/*\n** Hard-coded maximum amount of data to accumulate in memory before flushing\n** to a level 0 PMA. The purpose of this limit is to prevent various integer\n** overflows. 512MiB.\n*/\n#define SQLITE_MAX_PMASZ    (1<<29)\n\n/*\n** Private objects used by the sorter\n*/\ntypedef struct MergeEngine MergeEngine;     /* Merge PMAs together */\ntypedef struct PmaReader PmaReader;         /* Incrementally read one PMA */\ntypedef struct PmaWriter PmaWriter;         /* Incrementally write one PMA */\ntypedef struct SorterRecord SorterRecord;   /* A record being sorted */\ntypedef struct SortSubtask SortSubtask;     /* A sub-task in the sort process */\ntypedef struct SorterFile SorterFile;       /* Temporary file object wrapper */\ntypedef struct SorterList SorterList;       /* In-memory list of records */\ntypedef struct IncrMerger IncrMerger;       /* Read & merge multiple PMAs */\n\n/*\n** A container for a temp file handle and the current amount of data \n** stored in the file.\n*/\nstruct SorterFile {\n  sqlite3_file *pFd;              /* File handle */\n  i64 iEof;                       /* Bytes of data stored in pFd */\n};\n\n/*\n** An in-memory list of objects to be sorted.\n**\n** If aMemory==0 then each object is allocated separately and the objects\n** are connected using SorterRecord.u.pNext.  If aMemory!=0 then all objects\n** are stored in the aMemory[] bulk memory, one right after the other, and\n** are connected using SorterRecord.u.iNext.\n*/\nstruct SorterList {\n  SorterRecord *pList;            /* Linked list of records */\n  u8 *aMemory;                    /* If non-NULL, bulk memory to hold pList */\n  int szPMA;                      /* Size of pList as PMA in bytes */\n};\n\n/*\n** The MergeEngine object is used to combine two or more smaller PMAs into\n** one big PMA using a merge operation.  Separate PMAs all need to be\n** combined into one big PMA in order to be able to step through the sorted\n** records in order.\n**\n** The aReadr[] array contains a PmaReader object for each of the PMAs being\n** merged.  An aReadr[] object either points to a valid key or else is at EOF.\n** (\"EOF\" means \"End Of File\".  When aReadr[] is at EOF there is no more data.)\n** For the purposes of the paragraphs below, we assume that the array is\n** actually N elements in size, where N is the smallest power of 2 greater\n** to or equal to the number of PMAs being merged. The extra aReadr[] elements\n** are treated as if they are empty (always at EOF).\n**\n** The aTree[] array is also N elements in size. The value of N is stored in\n** the MergeEngine.nTree variable.\n**\n** The final (N/2) elements of aTree[] contain the results of comparing\n** pairs of PMA keys together. Element i contains the result of \n** comparing aReadr[2*i-N] and aReadr[2*i-N+1]. Whichever key is smaller, the\n** aTree element is set to the index of it. \n**\n** For the purposes of this comparison, EOF is considered greater than any\n** other key value. If the keys are equal (only possible with two EOF\n** values), it doesn't matter which index is stored.\n**\n** The (N/4) elements of aTree[] that precede the final (N/2) described \n** above contains the index of the smallest of each block of 4 PmaReaders\n** And so on. So that aTree[1] contains the index of the PmaReader that \n** currently points to the smallest key value. aTree[0] is unused.\n**\n** Example:\n**\n**     aReadr[0] -> Banana\n**     aReadr[1] -> Feijoa\n**     aReadr[2] -> Elderberry\n**     aReadr[3] -> Currant\n**     aReadr[4] -> Grapefruit\n**     aReadr[5] -> Apple\n**     aReadr[6] -> Durian\n**     aReadr[7] -> EOF\n**\n**     aTree[] = { X, 5   0, 5    0, 3, 5, 6 }\n**\n** The current element is \"Apple\" (the value of the key indicated by \n** PmaReader 5). When the Next() operation is invoked, PmaReader 5 will\n** be advanced to the next key in its segment. Say the next key is\n** \"Eggplant\":\n**\n**     aReadr[5] -> Eggplant\n**\n** The contents of aTree[] are updated first by comparing the new PmaReader\n** 5 key to the current key of PmaReader 4 (still \"Grapefruit\"). The PmaReader\n** 5 value is still smaller, so aTree[6] is set to 5. And so on up the tree.\n** The value of PmaReader 6 - \"Durian\" - is now smaller than that of PmaReader\n** 5, so aTree[3] is set to 6. Key 0 is smaller than key 6 (Banana<Durian),\n** so the value written into element 1 of the array is 0. As follows:\n**\n**     aTree[] = { X, 0   0, 6    0, 3, 5, 6 }\n**\n** In other words, each time we advance to the next sorter element, log2(N)\n** key comparison operations are required, where N is the number of segments\n** being merged (rounded up to the next power of 2).\n*/\nstruct MergeEngine {\n  int nTree;                 /* Used size of aTree/aReadr (power of 2) */\n  SortSubtask *pTask;        /* Used by this thread only */\n  int *aTree;                /* Current state of incremental merge */\n  PmaReader *aReadr;         /* Array of PmaReaders to merge data from */\n};\n\n/*\n** This object represents a single thread of control in a sort operation.\n** Exactly VdbeSorter.nTask instances of this object are allocated\n** as part of each VdbeSorter object. Instances are never allocated any\n** other way. VdbeSorter.nTask is set to the number of worker threads allowed\n** (see SQLITE_CONFIG_WORKER_THREADS) plus one (the main thread).  Thus for\n** single-threaded operation, there is exactly one instance of this object\n** and for multi-threaded operation there are two or more instances.\n**\n** Essentially, this structure contains all those fields of the VdbeSorter\n** structure for which each thread requires a separate instance. For example,\n** each thread requries its own UnpackedRecord object to unpack records in\n** as part of comparison operations.\n**\n** Before a background thread is launched, variable bDone is set to 0. Then, \n** right before it exits, the thread itself sets bDone to 1. This is used for \n** two purposes:\n**\n**   1. When flushing the contents of memory to a level-0 PMA on disk, to\n**      attempt to select a SortSubtask for which there is not already an\n**      active background thread (since doing so causes the main thread\n**      to block until it finishes).\n**\n**   2. If SQLITE_DEBUG_SORTER_THREADS is defined, to determine if a call\n**      to sqlite3ThreadJoin() is likely to block. Cases that are likely to\n**      block provoke debugging output.\n**\n** In both cases, the effects of the main thread seeing (bDone==0) even\n** after the thread has finished are not dire. So we don't worry about\n** memory barriers and such here.\n*/\ntypedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);\nstruct SortSubtask {\n  SQLiteThread *pThread;          /* Background thread, if any */\n  int bDone;                      /* Set if thread is finished but not joined */\n  VdbeSorter *pSorter;            /* Sorter that owns this sub-task */\n  UnpackedRecord *pUnpacked;      /* Space to unpack a record */\n  SorterList list;                /* List for thread to write to a PMA */\n  int nPMA;                       /* Number of PMAs currently in file */\n  SorterCompare xCompare;         /* Compare function to use */\n  SorterFile file;                /* Temp file for level-0 PMAs */\n  SorterFile file2;               /* Space for other PMAs */\n};\n\n\n/*\n** Main sorter structure. A single instance of this is allocated for each \n** sorter cursor created by the VDBE.\n**\n** mxKeysize:\n**   As records are added to the sorter by calls to sqlite3VdbeSorterWrite(),\n**   this variable is updated so as to be set to the size on disk of the\n**   largest record in the sorter.\n*/\nstruct VdbeSorter {\n  int mnPmaSize;                  /* Minimum PMA size, in bytes */\n  int mxPmaSize;                  /* Maximum PMA size, in bytes.  0==no limit */\n  int mxKeysize;                  /* Largest serialized key seen so far */\n  int pgsz;                       /* Main database page size */\n  PmaReader *pReader;             /* Readr data from here after Rewind() */\n  MergeEngine *pMerger;           /* Or here, if bUseThreads==0 */\n  sqlite3 *db;                    /* Database connection */\n  KeyInfo *pKeyInfo;              /* How to compare records */\n  UnpackedRecord *pUnpacked;      /* Used by VdbeSorterCompare() */\n  SorterList list;                /* List of in-memory records */\n  int iMemory;                    /* Offset of free space in list.aMemory */\n  int nMemory;                    /* Size of list.aMemory allocation in bytes */\n  u8 bUsePMA;                     /* True if one or more PMAs created */\n  u8 bUseThreads;                 /* True to use background threads */\n  u8 iPrev;                       /* Previous thread used to flush PMA */\n  u8 nTask;                       /* Size of aTask[] array */\n  u8 typeMask;\n  SortSubtask aTask[1];           /* One or more subtasks */\n};\n\n#define SORTER_TYPE_INTEGER 0x01\n#define SORTER_TYPE_TEXT    0x02\n\n/*\n** An instance of the following object is used to read records out of a\n** PMA, in sorted order.  The next key to be read is cached in nKey/aKey.\n** aKey might point into aMap or into aBuffer.  If neither of those locations\n** contain a contiguous representation of the key, then aAlloc is allocated\n** and the key is copied into aAlloc and aKey is made to poitn to aAlloc.\n**\n** pFd==0 at EOF.\n*/\nstruct PmaReader {\n  i64 iReadOff;               /* Current read offset */\n  i64 iEof;                   /* 1 byte past EOF for this PmaReader */\n  int nAlloc;                 /* Bytes of space at aAlloc */\n  int nKey;                   /* Number of bytes in key */\n  sqlite3_file *pFd;          /* File handle we are reading from */\n  u8 *aAlloc;                 /* Space for aKey if aBuffer and pMap wont work */\n  u8 *aKey;                   /* Pointer to current key */\n  u8 *aBuffer;                /* Current read buffer */\n  int nBuffer;                /* Size of read buffer in bytes */\n  u8 *aMap;                   /* Pointer to mapping of entire file */\n  IncrMerger *pIncr;          /* Incremental merger */\n};\n\n/*\n** Normally, a PmaReader object iterates through an existing PMA stored \n** within a temp file. However, if the PmaReader.pIncr variable points to\n** an object of the following type, it may be used to iterate/merge through\n** multiple PMAs simultaneously.\n**\n** There are two types of IncrMerger object - single (bUseThread==0) and \n** multi-threaded (bUseThread==1). \n**\n** A multi-threaded IncrMerger object uses two temporary files - aFile[0] \n** and aFile[1]. Neither file is allowed to grow to more than mxSz bytes in \n** size. When the IncrMerger is initialized, it reads enough data from \n** pMerger to populate aFile[0]. It then sets variables within the \n** corresponding PmaReader object to read from that file and kicks off \n** a background thread to populate aFile[1] with the next mxSz bytes of \n** sorted record data from pMerger. \n**\n** When the PmaReader reaches the end of aFile[0], it blocks until the\n** background thread has finished populating aFile[1]. It then exchanges\n** the contents of the aFile[0] and aFile[1] variables within this structure,\n** sets the PmaReader fields to read from the new aFile[0] and kicks off\n** another background thread to populate the new aFile[1]. And so on, until\n** the contents of pMerger are exhausted.\n**\n** A single-threaded IncrMerger does not open any temporary files of its\n** own. Instead, it has exclusive access to mxSz bytes of space beginning\n** at offset iStartOff of file pTask->file2. And instead of using a \n** background thread to prepare data for the PmaReader, with a single\n** threaded IncrMerger the allocate part of pTask->file2 is \"refilled\" with\n** keys from pMerger by the calling thread whenever the PmaReader runs out\n** of data.\n*/\nstruct IncrMerger {\n  SortSubtask *pTask;             /* Task that owns this merger */\n  MergeEngine *pMerger;           /* Merge engine thread reads data from */\n  i64 iStartOff;                  /* Offset to start writing file at */\n  int mxSz;                       /* Maximum bytes of data to store */\n  int bEof;                       /* Set to true when merge is finished */\n  int bUseThread;                 /* True to use a bg thread for this object */\n  SorterFile aFile[2];            /* aFile[0] for reading, [1] for writing */\n};\n\n/*\n** An instance of this object is used for writing a PMA.\n**\n** The PMA is written one record at a time.  Each record is of an arbitrary\n** size.  But I/O is more efficient if it occurs in page-sized blocks where\n** each block is aligned on a page boundary.  This object caches writes to\n** the PMA so that aligned, page-size blocks are written.\n*/\nstruct PmaWriter {\n  int eFWErr;                     /* Non-zero if in an error state */\n  u8 *aBuffer;                    /* Pointer to write buffer */\n  int nBuffer;                    /* Size of write buffer in bytes */\n  int iBufStart;                  /* First byte of buffer to write */\n  int iBufEnd;                    /* Last byte of buffer to write */\n  i64 iWriteOff;                  /* Offset of start of buffer in file */\n  sqlite3_file *pFd;              /* File handle to write to */\n};\n\n/*\n** This object is the header on a single record while that record is being\n** held in memory and prior to being written out as part of a PMA.\n**\n** How the linked list is connected depends on how memory is being managed\n** by this module. If using a separate allocation for each in-memory record\n** (VdbeSorter.list.aMemory==0), then the list is always connected using the\n** SorterRecord.u.pNext pointers.\n**\n** Or, if using the single large allocation method (VdbeSorter.list.aMemory!=0),\n** then while records are being accumulated the list is linked using the\n** SorterRecord.u.iNext offset. This is because the aMemory[] array may\n** be sqlite3Realloc()ed while records are being accumulated. Once the VM\n** has finished passing records to the sorter, or when the in-memory buffer\n** is full, the list is sorted. As part of the sorting process, it is\n** converted to use the SorterRecord.u.pNext pointers. See function\n** vdbeSorterSort() for details.\n*/\nstruct SorterRecord {\n  int nVal;                       /* Size of the record in bytes */\n  union {\n    SorterRecord *pNext;          /* Pointer to next record in list */\n    int iNext;                    /* Offset within aMemory of next record */\n  } u;\n  /* The data for the record immediately follows this header */\n};\n\n/* Return a pointer to the buffer containing the record data for SorterRecord\n** object p. Should be used as if:\n**\n**   void *SRVAL(SorterRecord *p) { return (void*)&p[1]; }\n*/\n#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))\n\n\n/* Maximum number of PMAs that a single MergeEngine can merge */\n#define SORTER_MAX_MERGE_COUNT 16\n\nstatic int vdbeIncrSwap(IncrMerger*);\nstatic void vdbeIncrFree(IncrMerger *);\n\n/*\n** Free all memory belonging to the PmaReader object passed as the\n** argument. All structure fields are set to zero before returning.\n*/\nstatic void vdbePmaReaderClear(PmaReader *pReadr){\n  sqlite3_free(pReadr->aAlloc);\n  sqlite3_free(pReadr->aBuffer);\n  if( pReadr->aMap ) sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n  vdbeIncrFree(pReadr->pIncr);\n  memset(pReadr, 0, sizeof(PmaReader));\n}\n\n/*\n** Read the next nByte bytes of data from the PMA p.\n** If successful, set *ppOut to point to a buffer containing the data\n** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite\n** error code.\n**\n** The buffer returned in *ppOut is only valid until the\n** next call to this function.\n*/\nstatic int vdbePmaReadBlob(\n  PmaReader *p,                   /* PmaReader from which to take the blob */\n  int nByte,                      /* Bytes of data to read */\n  u8 **ppOut                      /* OUT: Pointer to buffer containing data */\n){\n  int iBuf;                       /* Offset within buffer to read from */\n  int nAvail;                     /* Bytes of data available in buffer */\n\n  if( p->aMap ){\n    *ppOut = &p->aMap[p->iReadOff];\n    p->iReadOff += nByte;\n    return SQLITE_OK;\n  }\n\n  assert( p->aBuffer );\n\n  /* If there is no more data to be read from the buffer, read the next \n  ** p->nBuffer bytes of data from the file into it. Or, if there are less\n  ** than p->nBuffer bytes remaining in the PMA, read all remaining data.  */\n  iBuf = p->iReadOff % p->nBuffer;\n  if( iBuf==0 ){\n    int nRead;                    /* Bytes to read from disk */\n    int rc;                       /* sqlite3OsRead() return code */\n\n    /* Determine how many bytes of data to read. */\n    if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){\n      nRead = p->nBuffer;\n    }else{\n      nRead = (int)(p->iEof - p->iReadOff);\n    }\n    assert( nRead>0 );\n\n    /* Readr data from the file. Return early if an error occurs. */\n    rc = sqlite3OsRead(p->pFd, p->aBuffer, nRead, p->iReadOff);\n    assert( rc!=SQLITE_IOERR_SHORT_READ );\n    if( rc!=SQLITE_OK ) return rc;\n  }\n  nAvail = p->nBuffer - iBuf; \n\n  if( nByte<=nAvail ){\n    /* The requested data is available in the in-memory buffer. In this\n    ** case there is no need to make a copy of the data, just return a \n    ** pointer into the buffer to the caller.  */\n    *ppOut = &p->aBuffer[iBuf];\n    p->iReadOff += nByte;\n  }else{\n    /* The requested data is not all available in the in-memory buffer.\n    ** In this case, allocate space at p->aAlloc[] to copy the requested\n    ** range into. Then return a copy of pointer p->aAlloc to the caller.  */\n    int nRem;                     /* Bytes remaining to copy */\n\n    /* Extend the p->aAlloc[] allocation if required. */\n    if( p->nAlloc<nByte ){\n      u8 *aNew;\n      int nNew = MAX(128, p->nAlloc*2);\n      while( nByte>nNew ) nNew = nNew*2;\n      aNew = sqlite3Realloc(p->aAlloc, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      p->nAlloc = nNew;\n      p->aAlloc = aNew;\n    }\n\n    /* Copy as much data as is available in the buffer into the start of\n    ** p->aAlloc[].  */\n    memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail);\n    p->iReadOff += nAvail;\n    nRem = nByte - nAvail;\n\n    /* The following loop copies up to p->nBuffer bytes per iteration into\n    ** the p->aAlloc[] buffer.  */\n    while( nRem>0 ){\n      int rc;                     /* vdbePmaReadBlob() return code */\n      int nCopy;                  /* Number of bytes to copy */\n      u8 *aNext;                  /* Pointer to buffer to copy data from */\n\n      nCopy = nRem;\n      if( nRem>p->nBuffer ) nCopy = p->nBuffer;\n      rc = vdbePmaReadBlob(p, nCopy, &aNext);\n      if( rc!=SQLITE_OK ) return rc;\n      assert( aNext!=p->aAlloc );\n      memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy);\n      nRem -= nCopy;\n    }\n\n    *ppOut = p->aAlloc;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Read a varint from the stream of data accessed by p. Set *pnOut to\n** the value read.\n*/\nstatic int vdbePmaReadVarint(PmaReader *p, u64 *pnOut){\n  int iBuf;\n\n  if( p->aMap ){\n    p->iReadOff += sqlite3GetVarint(&p->aMap[p->iReadOff], pnOut);\n  }else{\n    iBuf = p->iReadOff % p->nBuffer;\n    if( iBuf && (p->nBuffer-iBuf)>=9 ){\n      p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut);\n    }else{\n      u8 aVarint[16], *a;\n      int i = 0, rc;\n      do{\n        rc = vdbePmaReadBlob(p, 1, &a);\n        if( rc ) return rc;\n        aVarint[(i++)&0xf] = a[0];\n      }while( (a[0]&0x80)!=0 );\n      sqlite3GetVarint(aVarint, pnOut);\n    }\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Attempt to memory map file pFile. If successful, set *pp to point to the\n** new mapping and return SQLITE_OK. If the mapping is not attempted \n** (because the file is too large or the VFS layer is configured not to use\n** mmap), return SQLITE_OK and set *pp to NULL.\n**\n** Or, if an error occurs, return an SQLite error code. The final value of\n** *pp is undefined in this case.\n*/\nstatic int vdbeSorterMapFile(SortSubtask *pTask, SorterFile *pFile, u8 **pp){\n  int rc = SQLITE_OK;\n  if( pFile->iEof<=(i64)(pTask->pSorter->db->nMaxSorterMmap) ){\n    sqlite3_file *pFd = pFile->pFd;\n    if( pFd->pMethods->iVersion>=3 ){\n      rc = sqlite3OsFetch(pFd, 0, (int)pFile->iEof, (void**)pp);\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n  return rc;\n}\n\n/*\n** Attach PmaReader pReadr to file pFile (if it is not already attached to\n** that file) and seek it to offset iOff within the file.  Return SQLITE_OK \n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic int vdbePmaReaderSeek(\n  SortSubtask *pTask,             /* Task context */\n  PmaReader *pReadr,              /* Reader whose cursor is to be moved */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iOff                        /* Offset in pFile */\n){\n  int rc = SQLITE_OK;\n\n  assert( pReadr->pIncr==0 || pReadr->pIncr->bEof==0 );\n\n  if( sqlite3FaultSim(201) ) return SQLITE_IOERR_READ;\n  if( pReadr->aMap ){\n    sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);\n    pReadr->aMap = 0;\n  }\n  pReadr->iReadOff = iOff;\n  pReadr->iEof = pFile->iEof;\n  pReadr->pFd = pFile->pFd;\n\n  rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap);\n  if( rc==SQLITE_OK && pReadr->aMap==0 ){\n    int pgsz = pTask->pSorter->pgsz;\n    int iBuf = pReadr->iReadOff % pgsz;\n    if( pReadr->aBuffer==0 ){\n      pReadr->aBuffer = (u8*)sqlite3Malloc(pgsz);\n      if( pReadr->aBuffer==0 ) rc = SQLITE_NOMEM_BKPT;\n      pReadr->nBuffer = pgsz;\n    }\n    if( rc==SQLITE_OK && iBuf ){\n      int nRead = pgsz - iBuf;\n      if( (pReadr->iReadOff + nRead) > pReadr->iEof ){\n        nRead = (int)(pReadr->iEof - pReadr->iReadOff);\n      }\n      rc = sqlite3OsRead(\n          pReadr->pFd, &pReadr->aBuffer[iBuf], nRead, pReadr->iReadOff\n      );\n      testcase( rc!=SQLITE_OK );\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Advance PmaReader pReadr to the next key in its PMA. Return SQLITE_OK if\n** no error occurs, or an SQLite error code if one does.\n*/\nstatic int vdbePmaReaderNext(PmaReader *pReadr){\n  int rc = SQLITE_OK;             /* Return Code */\n  u64 nRec = 0;                   /* Size of record in bytes */\n\n\n  if( pReadr->iReadOff>=pReadr->iEof ){\n    IncrMerger *pIncr = pReadr->pIncr;\n    int bEof = 1;\n    if( pIncr ){\n      rc = vdbeIncrSwap(pIncr);\n      if( rc==SQLITE_OK && pIncr->bEof==0 ){\n        rc = vdbePmaReaderSeek(\n            pIncr->pTask, pReadr, &pIncr->aFile[0], pIncr->iStartOff\n        );\n        bEof = 0;\n      }\n    }\n\n    if( bEof ){\n      /* This is an EOF condition */\n      vdbePmaReaderClear(pReadr);\n      testcase( rc!=SQLITE_OK );\n      return rc;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReadVarint(pReadr, &nRec);\n  }\n  if( rc==SQLITE_OK ){\n    pReadr->nKey = (int)nRec;\n    rc = vdbePmaReadBlob(pReadr, (int)nRec, &pReadr->aKey);\n    testcase( rc!=SQLITE_OK );\n  }\n\n  return rc;\n}\n\n/*\n** Initialize PmaReader pReadr to scan through the PMA stored in file pFile\n** starting at offset iStart and ending at offset iEof-1. This function \n** leaves the PmaReader pointing to the first key in the PMA (or EOF if the \n** PMA is empty).\n**\n** If the pnByte parameter is NULL, then it is assumed that the file \n** contains a single PMA, and that that PMA omits the initial length varint.\n*/\nstatic int vdbePmaReaderInit(\n  SortSubtask *pTask,             /* Task context */\n  SorterFile *pFile,              /* Sorter file to read from */\n  i64 iStart,                     /* Start offset in pFile */\n  PmaReader *pReadr,              /* PmaReader to populate */\n  i64 *pnByte                     /* IN/OUT: Increment this value by PMA size */\n){\n  int rc;\n\n  assert( pFile->iEof>iStart );\n  assert( pReadr->aAlloc==0 && pReadr->nAlloc==0 );\n  assert( pReadr->aBuffer==0 );\n  assert( pReadr->aMap==0 );\n\n  rc = vdbePmaReaderSeek(pTask, pReadr, pFile, iStart);\n  if( rc==SQLITE_OK ){\n    u64 nByte = 0;                 /* Size of PMA in bytes */\n    rc = vdbePmaReadVarint(pReadr, &nByte);\n    pReadr->iEof = pReadr->iReadOff + nByte;\n    *pnByte += nByte;\n  }\n\n  if( rc==SQLITE_OK ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n  return rc;\n}\n\n/*\n** A version of vdbeSorterCompare() that assumes that it has already been\n** determined that the first field of key1 is equal to the first field of \n** key2.\n*/\nstatic int vdbeSorterCompareTail(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( *pbKey2Cached==0 ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1);\n}\n\n/*\n** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2, \n** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences\n** used by the comparison. Return the result of the comparison.\n**\n** If IN/OUT parameter *pbKey2Cached is true when this function is called,\n** it is assumed that (pTask->pUnpacked) contains the unpacked version\n** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked\n** version of key2 and *pbKey2Cached set to true before returning.\n**\n** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set\n** to SQLITE_NOMEM.\n*/\nstatic int vdbeSorterCompare(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  UnpackedRecord *r2 = pTask->pUnpacked;\n  if( !*pbKey2Cached ){\n    sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);\n    *pbKey2Cached = 1;\n  }\n  return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is a TEXT value and that the collation\n** sequence to compare them with is BINARY.\n*/\nstatic int vdbeSorterCompareText(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n\n  int n1;\n  int n2;\n  int res;\n\n  getVarint32(&p1[1], n1);\n  getVarint32(&p2[1], n2);\n  res = memcmp(v1, v2, (MIN(n1, n2) - 13)/2);\n  if( res==0 ){\n    res = n1 - n2;\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else{\n    if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n      res = res * -1;\n    }\n  }\n\n  return res;\n}\n\n/*\n** A specially optimized version of vdbeSorterCompare() that assumes that\n** the first field of each key is an INTEGER value.\n*/\nstatic int vdbeSorterCompareInt(\n  SortSubtask *pTask,             /* Subtask context (for pKeyInfo) */\n  int *pbKey2Cached,              /* True if pTask->pUnpacked is pKey2 */\n  const void *pKey1, int nKey1,   /* Left side of comparison */\n  const void *pKey2, int nKey2    /* Right side of comparison */\n){\n  const u8 * const p1 = (const u8 * const)pKey1;\n  const u8 * const p2 = (const u8 * const)pKey2;\n  const int s1 = p1[1];                 /* Left hand serial type */\n  const int s2 = p2[1];                 /* Right hand serial type */\n  const u8 * const v1 = &p1[ p1[0] ];   /* Pointer to value 1 */\n  const u8 * const v2 = &p2[ p2[0] ];   /* Pointer to value 2 */\n  int res;                              /* Return value */\n\n  assert( (s1>0 && s1<7) || s1==8 || s1==9 );\n  assert( (s2>0 && s2<7) || s2==8 || s2==9 );\n\n  if( s1==s2 ){\n    /* The two values have the same sign. Compare using memcmp(). */\n    static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 };\n    const u8 n = aLen[s1];\n    int i;\n    res = 0;\n    for(i=0; i<n; i++){\n      if( (res = v1[i] - v2[i])!=0 ){\n        if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){\n          res = v1[0] & 0x80 ? -1 : +1;\n        }\n        break;\n      }\n    }\n  }else if( s1>7 && s2>7 ){\n    res = s1 - s2;\n  }else{\n    if( s2>7 ){\n      res = +1;\n    }else if( s1>7 ){\n      res = -1;\n    }else{\n      res = s1 - s2;\n    }\n    assert( res!=0 );\n\n    if( res>0 ){\n      if( *v1 & 0x80 ) res = -1;\n    }else{\n      if( *v2 & 0x80 ) res = +1;\n    }\n  }\n\n  if( res==0 ){\n    if( pTask->pSorter->pKeyInfo->nKeyField>1 ){\n      res = vdbeSorterCompareTail(\n          pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2\n      );\n    }\n  }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){\n    res = res * -1;\n  }\n\n  return res;\n}\n\n/*\n** Initialize the temporary index cursor just opened as a sorter cursor.\n**\n** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nKeyField)\n** to determine the number of fields that should be compared from the\n** records being sorted. However, if the value passed as argument nField\n** is non-zero and the sorter is able to guarantee a stable sort, nField\n** is used instead. This is used when sorting records for a CREATE INDEX\n** statement. In this case, keys are always delivered to the sorter in\n** order of the primary key, which happens to be make up the final part \n** of the records being sorted. So if the sort is stable, there is never\n** any reason to compare PK fields and they can be ignored for a small\n** performance boost.\n**\n** The sorter can guarantee a stable sort when running in single-threaded\n** mode, but not in multi-threaded mode.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nint sqlite3VdbeSorterInit(\n  sqlite3 *db,                    /* Database connection (for malloc()) */\n  int nField,                     /* Number of key fields in each record */\n  VdbeCursor *pCsr                /* Cursor that holds the new sorter */\n){\n  int pgsz;                       /* Page size of main database */\n  int i;                          /* Used to iterate through aTask[] */\n  VdbeSorter *pSorter;            /* The new sorter */\n  KeyInfo *pKeyInfo;              /* Copy of pCsr->pKeyInfo with db==0 */\n  int szKeyInfo;                  /* Size of pCsr->pKeyInfo in bytes */\n  int sz;                         /* Size of pSorter in bytes */\n  int rc = SQLITE_OK;\n#if SQLITE_MAX_WORKER_THREADS==0\n# define nWorker 0\n#else\n  int nWorker;\n#endif\n\n  /* Initialize the upper limit on the number of worker threads */\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( sqlite3TempInMemory(db) || sqlite3GlobalConfig.bCoreMutex==0 ){\n    nWorker = 0;\n  }else{\n    nWorker = db->aLimit[SQLITE_LIMIT_WORKER_THREADS];\n  }\n#endif\n\n  /* Do not allow the total number of threads (main thread + all workers)\n  ** to exceed the maximum merge count */\n#if SQLITE_MAX_WORKER_THREADS>=SORTER_MAX_MERGE_COUNT\n  if( nWorker>=SORTER_MAX_MERGE_COUNT ){\n    nWorker = SORTER_MAX_MERGE_COUNT-1;\n  }\n#endif\n\n  assert( pCsr->pKeyInfo && pCsr->pBtx==0 );\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);\n  sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);\n\n  pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);\n  pCsr->uc.pSorter = pSorter;\n  if( pSorter==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);\n    memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);\n    pKeyInfo->db = 0;\n    if( nField && nWorker==0 ){\n      pKeyInfo->nKeyField = nField;\n    }\n    pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);\n    pSorter->nTask = nWorker + 1;\n    pSorter->iPrev = (u8)(nWorker - 1);\n    pSorter->bUseThreads = (pSorter->nTask>1);\n    pSorter->db = db;\n    for(i=0; i<pSorter->nTask; i++){\n      SortSubtask *pTask = &pSorter->aTask[i];\n      pTask->pSorter = pSorter;\n    }\n\n    if( !sqlite3TempInMemory(db) ){\n      i64 mxCache;                /* Cache size in bytes*/\n      u32 szPma = sqlite3GlobalConfig.szPma;\n      pSorter->mnPmaSize = szPma * pgsz;\n\n      mxCache = db->aDb[0].pSchema->cache_size;\n      if( mxCache<0 ){\n        /* A negative cache-size value C indicates that the cache is abs(C)\n        ** KiB in size.  */\n        mxCache = mxCache * -1024;\n      }else{\n        mxCache = mxCache * pgsz;\n      }\n      mxCache = MIN(mxCache, SQLITE_MAX_PMASZ);\n      pSorter->mxPmaSize = MAX(pSorter->mnPmaSize, (int)mxCache);\n\n      /* Avoid large memory allocations if the application has requested\n      ** SQLITE_CONFIG_SMALL_MALLOC. */\n      if( sqlite3GlobalConfig.bSmallMalloc==0 ){\n        assert( pSorter->iMemory==0 );\n        pSorter->nMemory = pgsz;\n        pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);\n        if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM_BKPT;\n      }\n    }\n\n    if( pKeyInfo->nAllField<13 \n     && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)\n    ){\n      pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;\n    }\n  }\n\n  return rc;\n}\n#undef nWorker   /* Defined at the top of this function */\n\n/*\n** Free the list of sorted records starting at pRecord.\n*/\nstatic void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){\n  SorterRecord *p;\n  SorterRecord *pNext;\n  for(p=pRecord; p; p=pNext){\n    pNext = p->u.pNext;\n    sqlite3DbFree(db, p);\n  }\n}\n\n/*\n** Free all resources owned by the object indicated by argument pTask. All \n** fields of *pTask are zeroed before returning.\n*/\nstatic void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){\n  sqlite3DbFree(db, pTask->pUnpacked);\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* pTask->list.aMemory can only be non-zero if it was handed memory\n  ** from the main thread.  That only occurs SQLITE_MAX_WORKER_THREADS>0 */\n  if( pTask->list.aMemory ){\n    sqlite3_free(pTask->list.aMemory);\n  }else\n#endif\n  {\n    assert( pTask->list.aMemory==0 );\n    vdbeSorterRecordFree(0, pTask->list.pList);\n  }\n  if( pTask->file.pFd ){\n    sqlite3OsCloseFree(pTask->file.pFd);\n  }\n  if( pTask->file2.pFd ){\n    sqlite3OsCloseFree(pTask->file2.pFd);\n  }\n  memset(pTask, 0, sizeof(SortSubtask));\n}\n\n#ifdef SQLITE_DEBUG_SORTER_THREADS\nstatic void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterRewindDebug(const char *zEvent){\n  i64 t;\n  sqlite3OsCurrentTimeInt64(sqlite3_vfs_find(0), &t);\n  fprintf(stderr, \"%lld:X %s\\n\", t, zEvent);\n}\nstatic void vdbeSorterPopulateDebug(\n  SortSubtask *pTask,\n  const char *zEvent\n){\n  i64 t;\n  int iTask = (pTask - pTask->pSorter->aTask);\n  sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n  fprintf(stderr, \"%lld:bg%d %s\\n\", t, iTask, zEvent);\n}\nstatic void vdbeSorterBlockDebug(\n  SortSubtask *pTask,\n  int bBlocked,\n  const char *zEvent\n){\n  if( bBlocked ){\n    i64 t;\n    sqlite3OsCurrentTimeInt64(pTask->pSorter->db->pVfs, &t);\n    fprintf(stderr, \"%lld:main %s\\n\", t, zEvent);\n  }\n}\n#else\n# define vdbeSorterWorkDebug(x,y)\n# define vdbeSorterRewindDebug(y)\n# define vdbeSorterPopulateDebug(x,y)\n# define vdbeSorterBlockDebug(x,y,z)\n#endif\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Join thread pTask->thread.\n*/\nstatic int vdbeSorterJoinThread(SortSubtask *pTask){\n  int rc = SQLITE_OK;\n  if( pTask->pThread ){\n#ifdef SQLITE_DEBUG_SORTER_THREADS\n    int bDone = pTask->bDone;\n#endif\n    void *pRet = SQLITE_INT_TO_PTR(SQLITE_ERROR);\n    vdbeSorterBlockDebug(pTask, !bDone, \"enter\");\n    (void)sqlite3ThreadJoin(pTask->pThread, &pRet);\n    vdbeSorterBlockDebug(pTask, !bDone, \"exit\");\n    rc = SQLITE_PTR_TO_INT(pRet);\n    assert( pTask->bDone==1 );\n    pTask->bDone = 0;\n    pTask->pThread = 0;\n  }\n  return rc;\n}\n\n/*\n** Launch a background thread to run xTask(pIn).\n*/\nstatic int vdbeSorterCreateThread(\n  SortSubtask *pTask,             /* Thread will use this task object */\n  void *(*xTask)(void*),          /* Routine to run in a separate thread */\n  void *pIn                       /* Argument passed into xTask() */\n){\n  assert( pTask->pThread==0 && pTask->bDone==0 );\n  return sqlite3ThreadCreate(&pTask->pThread, xTask, pIn);\n}\n\n/*\n** Join all outstanding threads launched by SorterWrite() to create \n** level-0 PMAs.\n*/\nstatic int vdbeSorterJoinAll(VdbeSorter *pSorter, int rcin){\n  int rc = rcin;\n  int i;\n\n  /* This function is always called by the main user thread.\n  **\n  ** If this function is being called after SorterRewind() has been called, \n  ** it is possible that thread pSorter->aTask[pSorter->nTask-1].pThread\n  ** is currently attempt to join one of the other threads. To avoid a race\n  ** condition where this thread also attempts to join the same object, join \n  ** thread pSorter->aTask[pSorter->nTask-1].pThread first. */\n  for(i=pSorter->nTask-1; i>=0; i--){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    int rc2 = vdbeSorterJoinThread(pTask);\n    if( rc==SQLITE_OK ) rc = rc2;\n  }\n  return rc;\n}\n#else\n# define vdbeSorterJoinAll(x,rcin) (rcin)\n# define vdbeSorterJoinThread(pTask) SQLITE_OK\n#endif\n\n/*\n** Allocate a new MergeEngine object capable of handling up to\n** nReader PmaReader inputs.\n**\n** nReader is automatically rounded up to the next power of two.\n** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.\n*/\nstatic MergeEngine *vdbeMergeEngineNew(int nReader){\n  int N = 2;                      /* Smallest power of two >= nReader */\n  int nByte;                      /* Total bytes of space to allocate */\n  MergeEngine *pNew;              /* Pointer to allocated object to return */\n\n  assert( nReader<=SORTER_MAX_MERGE_COUNT );\n\n  while( N<nReader ) N += N;\n  nByte = sizeof(MergeEngine) + N * (sizeof(int) + sizeof(PmaReader));\n\n  pNew = sqlite3FaultSim(100) ? 0 : (MergeEngine*)sqlite3MallocZero(nByte);\n  if( pNew ){\n    pNew->nTree = N;\n    pNew->pTask = 0;\n    pNew->aReadr = (PmaReader*)&pNew[1];\n    pNew->aTree = (int*)&pNew->aReadr[N];\n  }\n  return pNew;\n}\n\n/*\n** Free the MergeEngine object passed as the only argument.\n*/\nstatic void vdbeMergeEngineFree(MergeEngine *pMerger){\n  int i;\n  if( pMerger ){\n    for(i=0; i<pMerger->nTree; i++){\n      vdbePmaReaderClear(&pMerger->aReadr[i]);\n    }\n  }\n  sqlite3_free(pMerger);\n}\n\n/*\n** Free all resources associated with the IncrMerger object indicated by\n** the first argument.\n*/\nstatic void vdbeIncrFree(IncrMerger *pIncr){\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      vdbeSorterJoinThread(pIncr->pTask);\n      if( pIncr->aFile[0].pFd ) sqlite3OsCloseFree(pIncr->aFile[0].pFd);\n      if( pIncr->aFile[1].pFd ) sqlite3OsCloseFree(pIncr->aFile[1].pFd);\n    }\n#endif\n    vdbeMergeEngineFree(pIncr->pMerger);\n    sqlite3_free(pIncr);\n  }\n}\n\n/*\n** Reset a sorting cursor back to its original empty state.\n*/\nvoid sqlite3VdbeSorterReset(sqlite3 *db, VdbeSorter *pSorter){\n  int i;\n  (void)vdbeSorterJoinAll(pSorter, SQLITE_OK);\n  assert( pSorter->bUseThreads || pSorter->pReader==0 );\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pSorter->pReader ){\n    vdbePmaReaderClear(pSorter->pReader);\n    sqlite3DbFree(db, pSorter->pReader);\n    pSorter->pReader = 0;\n  }\n#endif\n  vdbeMergeEngineFree(pSorter->pMerger);\n  pSorter->pMerger = 0;\n  for(i=0; i<pSorter->nTask; i++){\n    SortSubtask *pTask = &pSorter->aTask[i];\n    vdbeSortSubtaskCleanup(db, pTask);\n    pTask->pSorter = pSorter;\n  }\n  if( pSorter->list.aMemory==0 ){\n    vdbeSorterRecordFree(0, pSorter->list.pList);\n  }\n  pSorter->list.pList = 0;\n  pSorter->list.szPMA = 0;\n  pSorter->bUsePMA = 0;\n  pSorter->iMemory = 0;\n  pSorter->mxKeysize = 0;\n  sqlite3DbFree(db, pSorter->pUnpacked);\n  pSorter->pUnpacked = 0;\n}\n\n/*\n** Free any cursor components allocated by sqlite3VdbeSorterXXX routines.\n*/\nvoid sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  if( pSorter ){\n    sqlite3VdbeSorterReset(db, pSorter);\n    sqlite3_free(pSorter->list.aMemory);\n    sqlite3DbFree(db, pSorter);\n    pCsr->uc.pSorter = 0;\n  }\n}\n\n#if SQLITE_MAX_MMAP_SIZE>0\n/*\n** The first argument is a file-handle open on a temporary file. The file\n** is guaranteed to be nByte bytes or smaller in size. This function\n** attempts to extend the file to nByte bytes in size and to ensure that\n** the VFS has memory mapped it.\n**\n** Whether or not the file does end up memory mapped of course depends on\n** the specific VFS implementation.\n*/\nstatic void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){\n  if( nByte<=(i64)(db->nMaxSorterMmap) && pFd->pMethods->iVersion>=3 ){\n    void *p = 0;\n    int chunksize = 4*1024;\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize);\n    sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte);\n    sqlite3OsFetch(pFd, 0, (int)nByte, &p);\n    sqlite3OsUnfetch(pFd, 0, p);\n  }\n}\n#else\n# define vdbeSorterExtendFile(x,y,z)\n#endif\n\n/*\n** Allocate space for a file-handle and open a temporary file. If successful,\n** set *ppFd to point to the malloc'd file-handle and return SQLITE_OK.\n** Otherwise, set *ppFd to 0 and return an SQLite error code.\n*/\nstatic int vdbeSorterOpenTempFile(\n  sqlite3 *db,                    /* Database handle doing sort */\n  i64 nExtend,                    /* Attempt to extend file to this size */\n  sqlite3_file **ppFd\n){\n  int rc;\n  if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;\n  rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,\n      SQLITE_OPEN_TEMP_JOURNAL |\n      SQLITE_OPEN_READWRITE    | SQLITE_OPEN_CREATE |\n      SQLITE_OPEN_EXCLUSIVE    | SQLITE_OPEN_DELETEONCLOSE, &rc\n  );\n  if( rc==SQLITE_OK ){\n    i64 max = SQLITE_MAX_MMAP_SIZE;\n    sqlite3OsFileControlHint(*ppFd, SQLITE_FCNTL_MMAP_SIZE, (void*)&max);\n    if( nExtend>0 ){\n      vdbeSorterExtendFile(db, *ppFd, nExtend);\n    }\n  }\n  return rc;\n}\n\n/*\n** If it has not already been allocated, allocate the UnpackedRecord \n** structure at pTask->pUnpacked. Return SQLITE_OK if successful (or \n** if no allocation was required), or SQLITE_NOMEM otherwise.\n*/\nstatic int vdbeSortAllocUnpacked(SortSubtask *pTask){\n  if( pTask->pUnpacked==0 ){\n    pTask->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pTask->pSorter->pKeyInfo);\n    if( pTask->pUnpacked==0 ) return SQLITE_NOMEM_BKPT;\n    pTask->pUnpacked->nField = pTask->pSorter->pKeyInfo->nKeyField;\n    pTask->pUnpacked->errCode = 0;\n  }\n  return SQLITE_OK;\n}\n\n\n/*\n** Merge the two sorted lists p1 and p2 into a single list.\n*/\nstatic SorterRecord *vdbeSorterMerge(\n  SortSubtask *pTask,             /* Calling thread context */\n  SorterRecord *p1,               /* First list to merge */\n  SorterRecord *p2                /* Second list to merge */\n){\n  SorterRecord *pFinal = 0;\n  SorterRecord **pp = &pFinal;\n  int bCached = 0;\n\n  assert( p1!=0 && p2!=0 );\n  for(;;){\n    int res;\n    res = pTask->xCompare(\n        pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal\n    );\n\n    if( res<=0 ){\n      *pp = p1;\n      pp = &p1->u.pNext;\n      p1 = p1->u.pNext;\n      if( p1==0 ){\n        *pp = p2;\n        break;\n      }\n    }else{\n      *pp = p2;\n      pp = &p2->u.pNext;\n      p2 = p2->u.pNext;\n      bCached = 0;\n      if( p2==0 ){\n        *pp = p1;\n        break;\n      }\n    }\n  }\n  return pFinal;\n}\n\n/*\n** Return the SorterCompare function to compare values collected by the\n** sorter object passed as the only argument.\n*/\nstatic SorterCompare vdbeSorterGetCompare(VdbeSorter *p){\n  if( p->typeMask==SORTER_TYPE_INTEGER ){\n    return vdbeSorterCompareInt;\n  }else if( p->typeMask==SORTER_TYPE_TEXT ){\n    return vdbeSorterCompareText; \n  }\n  return vdbeSorterCompare;\n}\n\n/*\n** Sort the linked list of records headed at pTask->pList. Return \n** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if \n** an error occurs.\n*/\nstatic int vdbeSorterSort(SortSubtask *pTask, SorterList *pList){\n  int i;\n  SorterRecord **aSlot;\n  SorterRecord *p;\n  int rc;\n\n  rc = vdbeSortAllocUnpacked(pTask);\n  if( rc!=SQLITE_OK ) return rc;\n\n  p = pList->pList;\n  pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);\n\n  aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));\n  if( !aSlot ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  while( p ){\n    SorterRecord *pNext;\n    if( pList->aMemory ){\n      if( (u8*)p==pList->aMemory ){\n        pNext = 0;\n      }else{\n        assert( p->u.iNext<sqlite3MallocSize(pList->aMemory) );\n        pNext = (SorterRecord*)&pList->aMemory[p->u.iNext];\n      }\n    }else{\n      pNext = p->u.pNext;\n    }\n\n    p->u.pNext = 0;\n    for(i=0; aSlot[i]; i++){\n      p = vdbeSorterMerge(pTask, p, aSlot[i]);\n      aSlot[i] = 0;\n    }\n    aSlot[i] = p;\n    p = pNext;\n  }\n\n  p = 0;\n  for(i=0; i<64; i++){\n    if( aSlot[i]==0 ) continue;\n    p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i];\n  }\n  pList->pList = p;\n\n  sqlite3_free(aSlot);\n  assert( pTask->pUnpacked->errCode==SQLITE_OK \n       || pTask->pUnpacked->errCode==SQLITE_NOMEM \n  );\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** Initialize a PMA-writer object.\n*/\nstatic void vdbePmaWriterInit(\n  sqlite3_file *pFd,              /* File handle to write to */\n  PmaWriter *p,                   /* Object to populate */\n  int nBuf,                       /* Buffer size */\n  i64 iStart                      /* Offset of pFd to begin writing at */\n){\n  memset(p, 0, sizeof(PmaWriter));\n  p->aBuffer = (u8*)sqlite3Malloc(nBuf);\n  if( !p->aBuffer ){\n    p->eFWErr = SQLITE_NOMEM_BKPT;\n  }else{\n    p->iBufEnd = p->iBufStart = (iStart % nBuf);\n    p->iWriteOff = iStart - p->iBufStart;\n    p->nBuffer = nBuf;\n    p->pFd = pFd;\n  }\n}\n\n/*\n** Write nData bytes of data to the PMA. Return SQLITE_OK\n** if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteBlob(PmaWriter *p, u8 *pData, int nData){\n  int nRem = nData;\n  while( nRem>0 && p->eFWErr==0 ){\n    int nCopy = nRem;\n    if( nCopy>(p->nBuffer - p->iBufEnd) ){\n      nCopy = p->nBuffer - p->iBufEnd;\n    }\n\n    memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy);\n    p->iBufEnd += nCopy;\n    if( p->iBufEnd==p->nBuffer ){\n      p->eFWErr = sqlite3OsWrite(p->pFd, \n          &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n          p->iWriteOff + p->iBufStart\n      );\n      p->iBufStart = p->iBufEnd = 0;\n      p->iWriteOff += p->nBuffer;\n    }\n    assert( p->iBufEnd<p->nBuffer );\n\n    nRem -= nCopy;\n  }\n}\n\n/*\n** Flush any buffered data to disk and clean up the PMA-writer object.\n** The results of using the PMA-writer after this call are undefined.\n** Return SQLITE_OK if flushing the buffered data succeeds or is not \n** required. Otherwise, return an SQLite error code.\n**\n** Before returning, set *piEof to the offset immediately following the\n** last byte written to the file.\n*/\nstatic int vdbePmaWriterFinish(PmaWriter *p, i64 *piEof){\n  int rc;\n  if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){\n    p->eFWErr = sqlite3OsWrite(p->pFd, \n        &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, \n        p->iWriteOff + p->iBufStart\n    );\n  }\n  *piEof = (p->iWriteOff + p->iBufEnd);\n  sqlite3_free(p->aBuffer);\n  rc = p->eFWErr;\n  memset(p, 0, sizeof(PmaWriter));\n  return rc;\n}\n\n/*\n** Write value iVal encoded as a varint to the PMA. Return \n** SQLITE_OK if successful, or an SQLite error code if an error occurs.\n*/\nstatic void vdbePmaWriteVarint(PmaWriter *p, u64 iVal){\n  int nByte; \n  u8 aByte[10];\n  nByte = sqlite3PutVarint(aByte, iVal);\n  vdbePmaWriteBlob(p, aByte, nByte);\n}\n\n/*\n** Write the current contents of in-memory linked-list pList to a level-0\n** PMA in the temp file belonging to sub-task pTask. Return SQLITE_OK if \n** successful, or an SQLite error code otherwise.\n**\n** The format of a PMA is:\n**\n**     * A varint. This varint contains the total number of bytes of content\n**       in the PMA (not including the varint itself).\n**\n**     * One or more records packed end-to-end in order of ascending keys. \n**       Each record consists of a varint followed by a blob of data (the \n**       key). The varint is the number of bytes in the blob of data.\n*/\nstatic int vdbeSorterListToPMA(SortSubtask *pTask, SorterList *pList){\n  sqlite3 *db = pTask->pSorter->db;\n  int rc = SQLITE_OK;             /* Return code */\n  PmaWriter writer;               /* Object used to write to the file */\n\n#ifdef SQLITE_DEBUG\n  /* Set iSz to the expected size of file pTask->file after writing the PMA. \n  ** This is used by an assert() statement at the end of this function.  */\n  i64 iSz = pList->szPMA + sqlite3VarintLen(pList->szPMA) + pTask->file.iEof;\n#endif\n\n  vdbeSorterWorkDebug(pTask, \"enter\");\n  memset(&writer, 0, sizeof(PmaWriter));\n  assert( pList->szPMA>0 );\n\n  /* If the first temporary PMA file has not been opened, open it now. */\n  if( pTask->file.pFd==0 ){\n    rc = vdbeSorterOpenTempFile(db, 0, &pTask->file.pFd);\n    assert( rc!=SQLITE_OK || pTask->file.pFd );\n    assert( pTask->file.iEof==0 );\n    assert( pTask->nPMA==0 );\n  }\n\n  /* Try to get the file to memory map */\n  if( rc==SQLITE_OK ){\n    vdbeSorterExtendFile(db, pTask->file.pFd, pTask->file.iEof+pList->szPMA+9);\n  }\n\n  /* Sort the list */\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSort(pTask, pList);\n  }\n\n  if( rc==SQLITE_OK ){\n    SorterRecord *p;\n    SorterRecord *pNext = 0;\n\n    vdbePmaWriterInit(pTask->file.pFd, &writer, pTask->pSorter->pgsz,\n                      pTask->file.iEof);\n    pTask->nPMA++;\n    vdbePmaWriteVarint(&writer, pList->szPMA);\n    for(p=pList->pList; p; p=pNext){\n      pNext = p->u.pNext;\n      vdbePmaWriteVarint(&writer, p->nVal);\n      vdbePmaWriteBlob(&writer, SRVAL(p), p->nVal);\n      if( pList->aMemory==0 ) sqlite3_free(p);\n    }\n    pList->pList = p;\n    rc = vdbePmaWriterFinish(&writer, &pTask->file.iEof);\n  }\n\n  vdbeSorterWorkDebug(pTask, \"exit\");\n  assert( rc!=SQLITE_OK || pList->pList==0 );\n  assert( rc!=SQLITE_OK || pTask->file.iEof==iSz );\n  return rc;\n}\n\n/*\n** Advance the MergeEngine to its next entry.\n** Set *pbEof to true there is no next entry because\n** the MergeEngine has reached the end of all its inputs.\n**\n** Return SQLITE_OK if successful or an error code if an error occurs.\n*/\nstatic int vdbeMergeEngineStep(\n  MergeEngine *pMerger,      /* The merge engine to advance to the next row */\n  int *pbEof                 /* Set TRUE at EOF.  Set false for more content */\n){\n  int rc;\n  int iPrev = pMerger->aTree[1];/* Index of PmaReader to advance */\n  SortSubtask *pTask = pMerger->pTask;\n\n  /* Advance the current PmaReader */\n  rc = vdbePmaReaderNext(&pMerger->aReadr[iPrev]);\n\n  /* Update contents of aTree[] */\n  if( rc==SQLITE_OK ){\n    int i;                      /* Index of aTree[] to recalculate */\n    PmaReader *pReadr1;         /* First PmaReader to compare */\n    PmaReader *pReadr2;         /* Second PmaReader to compare */\n    int bCached = 0;\n\n    /* Find the first two PmaReaders to compare. The one that was just\n    ** advanced (iPrev) and the one next to it in the array.  */\n    pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];\n    pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];\n\n    for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){\n      /* Compare pReadr1 and pReadr2. Store the result in variable iRes. */\n      int iRes;\n      if( pReadr1->pFd==0 ){\n        iRes = +1;\n      }else if( pReadr2->pFd==0 ){\n        iRes = -1;\n      }else{\n        iRes = pTask->xCompare(pTask, &bCached,\n            pReadr1->aKey, pReadr1->nKey, pReadr2->aKey, pReadr2->nKey\n        );\n      }\n\n      /* If pReadr1 contained the smaller value, set aTree[i] to its index.\n      ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this\n      ** case there is no cache of pReadr2 in pTask->pUnpacked, so set\n      ** pKey2 to point to the record belonging to pReadr2.\n      **\n      ** Alternatively, if pReadr2 contains the smaller of the two values,\n      ** set aTree[i] to its index and update pReadr1. If vdbeSorterCompare()\n      ** was actually called above, then pTask->pUnpacked now contains\n      ** a value equivalent to pReadr2. So set pKey2 to NULL to prevent\n      ** vdbeSorterCompare() from decoding pReadr2 again.\n      **\n      ** If the two values were equal, then the value from the oldest\n      ** PMA should be considered smaller. The VdbeSorter.aReadr[] array\n      ** is sorted from oldest to newest, so pReadr1 contains older values\n      ** than pReadr2 iff (pReadr1<pReadr2).  */\n      if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){\n        pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);\n        pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n        bCached = 0;\n      }else{\n        if( pReadr1->pFd ) bCached = 0;\n        pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);\n        pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];\n      }\n    }\n    *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);\n  }\n\n  return (rc==SQLITE_OK ? pTask->pUnpacked->errCode : rc);\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that write level-0 PMAs.\n*/\nstatic void *vdbeSorterFlushThread(void *pCtx){\n  SortSubtask *pTask = (SortSubtask*)pCtx;\n  int rc;                         /* Return code */\n  assert( pTask->bDone==0 );\n  rc = vdbeSorterListToPMA(pTask, &pTask->list);\n  pTask->bDone = 1;\n  return SQLITE_INT_TO_PTR(rc);\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n/*\n** Flush the current contents of VdbeSorter.list to a new PMA, possibly\n** using a background thread.\n*/\nstatic int vdbeSorterFlushPMA(VdbeSorter *pSorter){\n#if SQLITE_MAX_WORKER_THREADS==0\n  pSorter->bUsePMA = 1;\n  return vdbeSorterListToPMA(&pSorter->aTask[0], &pSorter->list);\n#else\n  int rc = SQLITE_OK;\n  int i;\n  SortSubtask *pTask = 0;    /* Thread context used to create new PMA */\n  int nWorker = (pSorter->nTask-1);\n\n  /* Set the flag to indicate that at least one PMA has been written. \n  ** Or will be, anyhow.  */\n  pSorter->bUsePMA = 1;\n\n  /* Select a sub-task to sort and flush the current list of in-memory\n  ** records to disk. If the sorter is running in multi-threaded mode,\n  ** round-robin between the first (pSorter->nTask-1) tasks. Except, if\n  ** the background thread from a sub-tasks previous turn is still running,\n  ** skip it. If the first (pSorter->nTask-1) sub-tasks are all still busy,\n  ** fall back to using the final sub-task. The first (pSorter->nTask-1)\n  ** sub-tasks are prefered as they use background threads - the final \n  ** sub-task uses the main thread. */\n  for(i=0; i<nWorker; i++){\n    int iTest = (pSorter->iPrev + i + 1) % nWorker;\n    pTask = &pSorter->aTask[iTest];\n    if( pTask->bDone ){\n      rc = vdbeSorterJoinThread(pTask);\n    }\n    if( rc!=SQLITE_OK || pTask->pThread==0 ) break;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( i==nWorker ){\n      /* Use the foreground thread for this operation */\n      rc = vdbeSorterListToPMA(&pSorter->aTask[nWorker], &pSorter->list);\n    }else{\n      /* Launch a background thread for this operation */\n      u8 *aMem = pTask->list.aMemory;\n      void *pCtx = (void*)pTask;\n\n      assert( pTask->pThread==0 && pTask->bDone==0 );\n      assert( pTask->list.pList==0 );\n      assert( pTask->list.aMemory==0 || pSorter->list.aMemory!=0 );\n\n      pSorter->iPrev = (u8)(pTask - pSorter->aTask);\n      pTask->list = pSorter->list;\n      pSorter->list.pList = 0;\n      pSorter->list.szPMA = 0;\n      if( aMem ){\n        pSorter->list.aMemory = aMem;\n        pSorter->nMemory = sqlite3MallocSize(aMem);\n      }else if( pSorter->list.aMemory ){\n        pSorter->list.aMemory = sqlite3Malloc(pSorter->nMemory);\n        if( !pSorter->list.aMemory ) return SQLITE_NOMEM_BKPT;\n      }\n\n      rc = vdbeSorterCreateThread(pTask, vdbeSorterFlushThread, pCtx);\n    }\n  }\n\n  return rc;\n#endif /* SQLITE_MAX_WORKER_THREADS!=0 */\n}\n\n/*\n** Add a record to the sorter.\n*/\nint sqlite3VdbeSorterWrite(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal                       /* Memory cell containing record */\n){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return Code */\n  SorterRecord *pNew;             /* New list element */\n  int bFlush;                     /* True to flush contents of memory to PMA */\n  int nReq;                       /* Bytes of memory required */\n  int nPMA;                       /* Bytes of PMA space required */\n  int t;                          /* serial type of first record field */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  getVarint32((const u8*)&pVal->z[1], t);\n  if( t>0 && t<10 && t!=7 ){\n    pSorter->typeMask &= SORTER_TYPE_INTEGER;\n  }else if( t>10 && (t & 0x01) ){\n    pSorter->typeMask &= SORTER_TYPE_TEXT;\n  }else{\n    pSorter->typeMask = 0;\n  }\n\n  assert( pSorter );\n\n  /* Figure out whether or not the current contents of memory should be\n  ** flushed to a PMA before continuing. If so, do so.\n  **\n  ** If using the single large allocation mode (pSorter->aMemory!=0), then\n  ** flush the contents of memory to a new PMA if (a) at least one value is\n  ** already in memory and (b) the new value will not fit in memory.\n  ** \n  ** Or, if using separate allocations for each record, flush the contents\n  ** of memory to a PMA if either of the following are true:\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * cache-size), or\n  **\n  **   * The total memory allocated for the in-memory list is greater \n  **     than (page-size * 10) and sqlite3HeapNearlyFull() returns true.\n  */\n  nReq = pVal->n + sizeof(SorterRecord);\n  nPMA = pVal->n + sqlite3VarintLen(pVal->n);\n  if( pSorter->mxPmaSize ){\n    if( pSorter->list.aMemory ){\n      bFlush = pSorter->iMemory && (pSorter->iMemory+nReq) > pSorter->mxPmaSize;\n    }else{\n      bFlush = (\n          (pSorter->list.szPMA > pSorter->mxPmaSize)\n       || (pSorter->list.szPMA > pSorter->mnPmaSize && sqlite3HeapNearlyFull())\n      );\n    }\n    if( bFlush ){\n      rc = vdbeSorterFlushPMA(pSorter);\n      pSorter->list.szPMA = 0;\n      pSorter->iMemory = 0;\n      assert( rc!=SQLITE_OK || pSorter->list.pList==0 );\n    }\n  }\n\n  pSorter->list.szPMA += nPMA;\n  if( nPMA>pSorter->mxKeysize ){\n    pSorter->mxKeysize = nPMA;\n  }\n\n  if( pSorter->list.aMemory ){\n    int nMin = pSorter->iMemory + nReq;\n\n    if( nMin>pSorter->nMemory ){\n      u8 *aNew;\n      int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;\n      int nNew = pSorter->nMemory * 2;\n      while( nNew < nMin ) nNew = nNew*2;\n      if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize;\n      if( nNew < nMin ) nNew = nMin;\n\n      aNew = sqlite3Realloc(pSorter->list.aMemory, nNew);\n      if( !aNew ) return SQLITE_NOMEM_BKPT;\n      pSorter->list.pList = (SorterRecord*)&aNew[iListOff];\n      pSorter->list.aMemory = aNew;\n      pSorter->nMemory = nNew;\n    }\n\n    pNew = (SorterRecord*)&pSorter->list.aMemory[pSorter->iMemory];\n    pSorter->iMemory += ROUND8(nReq);\n    if( pSorter->list.pList ){\n      pNew->u.iNext = (int)((u8*)(pSorter->list.pList) - pSorter->list.aMemory);\n    }\n  }else{\n    pNew = (SorterRecord *)sqlite3Malloc(nReq);\n    if( pNew==0 ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    pNew->u.pNext = pSorter->list.pList;\n  }\n\n  memcpy(SRVAL(pNew), pVal->z, pVal->n);\n  pNew->nVal = pVal->n;\n  pSorter->list.pList = pNew;\n\n  return rc;\n}\n\n/*\n** Read keys from pIncr->pMerger and populate pIncr->aFile[1]. The format\n** of the data stored in aFile[1] is the same as that used by regular PMAs,\n** except that the number-of-bytes varint is omitted from the start.\n*/\nstatic int vdbeIncrPopulate(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n  int rc2;\n  i64 iStart = pIncr->iStartOff;\n  SorterFile *pOut = &pIncr->aFile[1];\n  SortSubtask *pTask = pIncr->pTask;\n  MergeEngine *pMerger = pIncr->pMerger;\n  PmaWriter writer;\n  assert( pIncr->bEof==0 );\n\n  vdbeSorterPopulateDebug(pTask, \"enter\");\n\n  vdbePmaWriterInit(pOut->pFd, &writer, pTask->pSorter->pgsz, iStart);\n  while( rc==SQLITE_OK ){\n    int dummy;\n    PmaReader *pReader = &pMerger->aReadr[ pMerger->aTree[1] ];\n    int nKey = pReader->nKey;\n    i64 iEof = writer.iWriteOff + writer.iBufEnd;\n\n    /* Check if the output file is full or if the input has been exhausted.\n    ** In either case exit the loop. */\n    if( pReader->pFd==0 ) break;\n    if( (iEof + nKey + sqlite3VarintLen(nKey))>(iStart + pIncr->mxSz) ) break;\n\n    /* Write the next key to the output. */\n    vdbePmaWriteVarint(&writer, nKey);\n    vdbePmaWriteBlob(&writer, pReader->aKey, nKey);\n    assert( pIncr->pMerger->pTask==pTask );\n    rc = vdbeMergeEngineStep(pIncr->pMerger, &dummy);\n  }\n\n  rc2 = vdbePmaWriterFinish(&writer, &pOut->iEof);\n  if( rc==SQLITE_OK ) rc = rc2;\n  vdbeSorterPopulateDebug(pTask, \"exit\");\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for background threads that populate aFile[1] of\n** multi-threaded IncrMerger objects.\n*/\nstatic void *vdbeIncrPopulateThread(void *pCtx){\n  IncrMerger *pIncr = (IncrMerger*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR( vdbeIncrPopulate(pIncr) );\n  pIncr->pTask->bDone = 1;\n  return pRet;\n}\n\n/*\n** Launch a background thread to populate aFile[1] of pIncr.\n*/\nstatic int vdbeIncrBgPopulate(IncrMerger *pIncr){\n  void *p = (void*)pIncr;\n  assert( pIncr->bUseThread );\n  return vdbeSorterCreateThread(pIncr->pTask, vdbeIncrPopulateThread, p);\n}\n#endif\n\n/*\n** This function is called when the PmaReader corresponding to pIncr has\n** finished reading the contents of aFile[0]. Its purpose is to \"refill\"\n** aFile[0] such that the PmaReader should start rereading it from the\n** beginning.\n**\n** For single-threaded objects, this is accomplished by literally reading \n** keys from pIncr->pMerger and repopulating aFile[0]. \n**\n** For multi-threaded objects, all that is required is to wait until the \n** background thread is finished (if it is not already) and then swap \n** aFile[0] and aFile[1] in place. If the contents of pMerger have not\n** been exhausted, this function also launches a new background thread\n** to populate the new aFile[1].\n**\n** SQLITE_OK is returned on success, or an SQLite error code otherwise.\n*/\nstatic int vdbeIncrSwap(IncrMerger *pIncr){\n  int rc = SQLITE_OK;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( pIncr->bUseThread ){\n    rc = vdbeSorterJoinThread(pIncr->pTask);\n\n    if( rc==SQLITE_OK ){\n      SorterFile f0 = pIncr->aFile[0];\n      pIncr->aFile[0] = pIncr->aFile[1];\n      pIncr->aFile[1] = f0;\n    }\n\n    if( rc==SQLITE_OK ){\n      if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n        pIncr->bEof = 1;\n      }else{\n        rc = vdbeIncrBgPopulate(pIncr);\n      }\n    }\n  }else\n#endif\n  {\n    rc = vdbeIncrPopulate(pIncr);\n    pIncr->aFile[0] = pIncr->aFile[1];\n    if( pIncr->aFile[0].iEof==pIncr->iStartOff ){\n      pIncr->bEof = 1;\n    }\n  }\n\n  return rc;\n}\n\n/*\n** Allocate and return a new IncrMerger object to read data from pMerger.\n**\n** If an OOM condition is encountered, return NULL. In this case free the\n** pMerger argument before returning.\n*/\nstatic int vdbeIncrMergerNew(\n  SortSubtask *pTask,     /* The thread that will be using the new IncrMerger */\n  MergeEngine *pMerger,   /* The MergeEngine that the IncrMerger will control */\n  IncrMerger **ppOut      /* Write the new IncrMerger here */\n){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = *ppOut = (IncrMerger*)\n       (sqlite3FaultSim(100) ? 0 : sqlite3MallocZero(sizeof(*pIncr)));\n  if( pIncr ){\n    pIncr->pMerger = pMerger;\n    pIncr->pTask = pTask;\n    pIncr->mxSz = MAX(pTask->pSorter->mxKeysize+9,pTask->pSorter->mxPmaSize/2);\n    pTask->file2.iEof += pIncr->mxSz;\n  }else{\n    vdbeMergeEngineFree(pMerger);\n    rc = SQLITE_NOMEM_BKPT;\n  }\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** Set the \"use-threads\" flag on object pIncr.\n*/\nstatic void vdbeIncrMergerSetThreads(IncrMerger *pIncr){\n  pIncr->bUseThread = 1;\n  pIncr->pTask->file2.iEof -= pIncr->mxSz;\n}\n#endif /* SQLITE_MAX_WORKER_THREADS>0 */\n\n\n\n/*\n** Recompute pMerger->aTree[iOut] by comparing the next keys on the\n** two PmaReaders that feed that entry.  Neither of the PmaReaders\n** are advanced.  This routine merely does the comparison.\n*/\nstatic void vdbeMergeEngineCompare(\n  MergeEngine *pMerger,  /* Merge engine containing PmaReaders to compare */\n  int iOut               /* Store the result in pMerger->aTree[iOut] */\n){\n  int i1;\n  int i2;\n  int iRes;\n  PmaReader *p1;\n  PmaReader *p2;\n\n  assert( iOut<pMerger->nTree && iOut>0 );\n\n  if( iOut>=(pMerger->nTree/2) ){\n    i1 = (iOut - pMerger->nTree/2) * 2;\n    i2 = i1 + 1;\n  }else{\n    i1 = pMerger->aTree[iOut*2];\n    i2 = pMerger->aTree[iOut*2+1];\n  }\n\n  p1 = &pMerger->aReadr[i1];\n  p2 = &pMerger->aReadr[i2];\n\n  if( p1->pFd==0 ){\n    iRes = i2;\n  }else if( p2->pFd==0 ){\n    iRes = i1;\n  }else{\n    SortSubtask *pTask = pMerger->pTask;\n    int bCached = 0;\n    int res;\n    assert( pTask->pUnpacked!=0 );  /* from vdbeSortSubtaskMain() */\n    res = pTask->xCompare(\n        pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey\n    );\n    if( res<=0 ){\n      iRes = i1;\n    }else{\n      iRes = i2;\n    }\n  }\n\n  pMerger->aTree[iOut] = iRes;\n}\n\n/*\n** Allowed values for the eMode parameter to vdbeMergeEngineInit()\n** and vdbePmaReaderIncrMergeInit().\n**\n** Only INCRINIT_NORMAL is valid in single-threaded builds (when\n** SQLITE_MAX_WORKER_THREADS==0).  The other values are only used\n** when there exists one or more separate worker threads.\n*/\n#define INCRINIT_NORMAL 0\n#define INCRINIT_TASK   1\n#define INCRINIT_ROOT   2\n\n/* \n** Forward reference required as the vdbeIncrMergeInit() and\n** vdbePmaReaderIncrInit() routines are called mutually recursively when\n** building a merge tree.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode);\n\n/*\n** Initialize the MergeEngine object passed as the second argument. Once this\n** function returns, the first key of merged data may be read from the \n** MergeEngine object in the usual fashion.\n**\n** If argument eMode is INCRINIT_ROOT, then it is assumed that any IncrMerge\n** objects attached to the PmaReader objects that the merger reads from have\n** already been populated, but that they have not yet populated aFile[0] and\n** set the PmaReader objects up to read from it. In this case all that is\n** required is to call vdbePmaReaderNext() on each PmaReader to point it at\n** its first key.\n**\n** Otherwise, if eMode is any value other than INCRINIT_ROOT, then use \n** vdbePmaReaderIncrMergeInit() to initialize each PmaReader that feeds data \n** to pMerger.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeMergeEngineInit(\n  SortSubtask *pTask,             /* Thread that will run pMerger */\n  MergeEngine *pMerger,           /* MergeEngine to initialize */\n  int eMode                       /* One of the INCRINIT_XXX constants */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int i;                          /* For looping over PmaReader objects */\n  int nTree = pMerger->nTree;\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  /* Verify that the MergeEngine is assigned to a single thread */\n  assert( pMerger->pTask==0 );\n  pMerger->pTask = pTask;\n\n  for(i=0; i<nTree; i++){\n    if( SQLITE_MAX_WORKER_THREADS>0 && eMode==INCRINIT_ROOT ){\n      /* PmaReaders should be normally initialized in order, as if they are\n      ** reading from the same temp file this makes for more linear file IO.\n      ** However, in the INCRINIT_ROOT case, if PmaReader aReadr[nTask-1] is\n      ** in use it will block the vdbePmaReaderNext() call while it uses\n      ** the main thread to fill its buffer. So calling PmaReaderNext()\n      ** on this PmaReader before any of the multi-threaded PmaReaders takes\n      ** better advantage of multi-processor hardware. */\n      rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);\n    }else{\n      rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);\n    }\n    if( rc!=SQLITE_OK ) return rc;\n  }\n\n  for(i=pMerger->nTree-1; i>0; i--){\n    vdbeMergeEngineCompare(pMerger, i);\n  }\n  return pTask->pUnpacked->errCode;\n}\n\n/*\n** The PmaReader passed as the first argument is guaranteed to be an\n** incremental-reader (pReadr->pIncr!=0). This function serves to open\n** and/or initialize the temp file related fields of the IncrMerge\n** object at (pReadr->pIncr).\n**\n** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders\n** in the sub-tree headed by pReadr are also initialized. Data is then \n** loaded into the buffers belonging to pReadr and it is set to point to \n** the first key in its range.\n**\n** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed\n** to be a multi-threaded PmaReader and this function is being called in a\n** background thread. In this case all PmaReaders in the sub-tree are \n** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to\n** pReadr is populated. However, pReadr itself is not set up to point\n** to its first key. A call to vdbePmaReaderNext() is still required to do\n** that. \n**\n** The reason this function does not call vdbePmaReaderNext() immediately \n** in the INCRINIT_TASK case is that vdbePmaReaderNext() assumes that it has\n** to block on thread (pTask->thread) before accessing aFile[1]. But, since\n** this entire function is being run by thread (pTask->thread), that will\n** lead to the current background thread attempting to join itself.\n**\n** Finally, if argument eMode is set to INCRINIT_ROOT, it may be assumed\n** that pReadr->pIncr is a multi-threaded IncrMerge objects, and that all\n** child-trees have already been initialized using IncrInit(INCRINIT_TASK).\n** In this case vdbePmaReaderNext() is called on all child PmaReaders and\n** the current PmaReader set to point to the first key in its range.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){\n  int rc = SQLITE_OK;\n  IncrMerger *pIncr = pReadr->pIncr;\n  SortSubtask *pTask = pIncr->pTask;\n  sqlite3 *db = pTask->pSorter->db;\n\n  /* eMode is always INCRINIT_NORMAL in single-threaded mode */\n  assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );\n\n  rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);\n\n  /* Set up the required files for pIncr. A multi-theaded IncrMerge object\n  ** requires two temp files to itself, whereas a single-threaded object\n  ** only requires a region of pTask->file2. */\n  if( rc==SQLITE_OK ){\n    int mxSz = pIncr->mxSz;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pIncr->bUseThread ){\n      rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);\n      if( rc==SQLITE_OK ){\n        rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);\n      }\n    }else\n#endif\n    /*if( !pIncr->bUseThread )*/{\n      if( pTask->file2.pFd==0 ){\n        assert( pTask->file2.iEof>0 );\n        rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);\n        pTask->file2.iEof = 0;\n      }\n      if( rc==SQLITE_OK ){\n        pIncr->aFile[1].pFd = pTask->file2.pFd;\n        pIncr->iStartOff = pTask->file2.iEof;\n        pTask->file2.iEof += mxSz;\n      }\n    }\n  }\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  if( rc==SQLITE_OK && pIncr->bUseThread ){\n    /* Use the current thread to populate aFile[1], even though this\n    ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,\n    ** then this function is already running in background thread \n    ** pIncr->pTask->thread. \n    **\n    ** If this is the INCRINIT_ROOT object, then it is running in the \n    ** main VDBE thread. But that is Ok, as that thread cannot return\n    ** control to the VDBE or proceed with anything useful until the \n    ** first results are ready from this merger object anyway.\n    */\n    assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );\n    rc = vdbeIncrPopulate(pIncr);\n  }\n#endif\n\n  if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){\n    rc = vdbePmaReaderNext(pReadr);\n  }\n\n  return rc;\n}\n\n#if SQLITE_MAX_WORKER_THREADS>0\n/*\n** The main routine for vdbePmaReaderIncrMergeInit() operations run in \n** background threads.\n*/\nstatic void *vdbePmaReaderBgIncrInit(void *pCtx){\n  PmaReader *pReader = (PmaReader*)pCtx;\n  void *pRet = SQLITE_INT_TO_PTR(\n                  vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)\n               );\n  pReader->pIncr->pTask->bDone = 1;\n  return pRet;\n}\n#endif\n\n/*\n** If the PmaReader passed as the first argument is not an incremental-reader\n** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes\n** the vdbePmaReaderIncrMergeInit() function with the parameters passed to\n** this routine to initialize the incremental merge.\n** \n** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1), \n** then a background thread is launched to call vdbePmaReaderIncrMergeInit().\n** Or, if the IncrMerger is single threaded, the same function is called\n** using the current thread.\n*/\nstatic int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){\n  IncrMerger *pIncr = pReadr->pIncr;   /* Incremental merger */\n  int rc = SQLITE_OK;                  /* Return code */\n  if( pIncr ){\n#if SQLITE_MAX_WORKER_THREADS>0\n    assert( pIncr->bUseThread==0 || eMode==INCRINIT_TASK );\n    if( pIncr->bUseThread ){\n      void *pCtx = (void*)pReadr;\n      rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);\n    }else\n#endif\n    {\n      rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);\n    }\n  }\n  return rc;\n}\n\n/*\n** Allocate a new MergeEngine object to merge the contents of nPMA level-0\n** PMAs from pTask->file. If no error occurs, set *ppOut to point to\n** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut\n** to NULL and return an SQLite error code.\n**\n** When this function is called, *piOffset is set to the offset of the\n** first PMA to read from pTask->file. Assuming no error occurs, it is \n** set to the offset immediately following the last byte of the last\n** PMA before returning. If an error does occur, then the final value of\n** *piOffset is undefined.\n*/\nstatic int vdbeMergeEngineLevel0(\n  SortSubtask *pTask,             /* Sorter task to read from */\n  int nPMA,                       /* Number of PMAs to read */\n  i64 *piOffset,                  /* IN/OUT: Readr offset in pTask->file */\n  MergeEngine **ppOut             /* OUT: New merge-engine */\n){\n  MergeEngine *pNew;              /* Merge engine to return */\n  i64 iOff = *piOffset;\n  int i;\n  int rc = SQLITE_OK;\n\n  *ppOut = pNew = vdbeMergeEngineNew(nPMA);\n  if( pNew==0 ) rc = SQLITE_NOMEM_BKPT;\n\n  for(i=0; i<nPMA && rc==SQLITE_OK; i++){\n    i64 nDummy = 0;\n    PmaReader *pReadr = &pNew->aReadr[i];\n    rc = vdbePmaReaderInit(pTask, &pTask->file, iOff, pReadr, &nDummy);\n    iOff = pReadr->iEof;\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pNew);\n    *ppOut = 0;\n  }\n  *piOffset = iOff;\n  return rc;\n}\n\n/*\n** Return the depth of a tree comprising nPMA PMAs, assuming a fanout of\n** SORTER_MAX_MERGE_COUNT. The returned value does not include leaf nodes.\n**\n** i.e.\n**\n**   nPMA<=16    -> TreeDepth() == 0\n**   nPMA<=256   -> TreeDepth() == 1\n**   nPMA<=65536 -> TreeDepth() == 2\n*/\nstatic int vdbeSorterTreeDepth(int nPMA){\n  int nDepth = 0;\n  i64 nDiv = SORTER_MAX_MERGE_COUNT;\n  while( nDiv < (i64)nPMA ){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n    nDepth++;\n  }\n  return nDepth;\n}\n\n/*\n** pRoot is the root of an incremental merge-tree with depth nDepth (according\n** to vdbeSorterTreeDepth()). pLeaf is the iSeq'th leaf to be added to the\n** tree, counting from zero. This function adds pLeaf to the tree.\n**\n** If successful, SQLITE_OK is returned. If an error occurs, an SQLite error\n** code is returned and pLeaf is freed.\n*/\nstatic int vdbeSorterAddToTree(\n  SortSubtask *pTask,             /* Task context */\n  int nDepth,                     /* Depth of tree according to TreeDepth() */\n  int iSeq,                       /* Sequence number of leaf within tree */\n  MergeEngine *pRoot,             /* Root of tree */\n  MergeEngine *pLeaf              /* Leaf to add to tree */\n){\n  int rc = SQLITE_OK;\n  int nDiv = 1;\n  int i;\n  MergeEngine *p = pRoot;\n  IncrMerger *pIncr;\n\n  rc = vdbeIncrMergerNew(pTask, pLeaf, &pIncr);\n\n  for(i=1; i<nDepth; i++){\n    nDiv = nDiv * SORTER_MAX_MERGE_COUNT;\n  }\n\n  for(i=1; i<nDepth && rc==SQLITE_OK; i++){\n    int iIter = (iSeq / nDiv) % SORTER_MAX_MERGE_COUNT;\n    PmaReader *pReadr = &p->aReadr[iIter];\n\n    if( pReadr->pIncr==0 ){\n      MergeEngine *pNew = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n      if( pNew==0 ){\n        rc = SQLITE_NOMEM_BKPT;\n      }else{\n        rc = vdbeIncrMergerNew(pTask, pNew, &pReadr->pIncr);\n      }\n    }\n    if( rc==SQLITE_OK ){\n      p = pReadr->pIncr->pMerger;\n      nDiv = nDiv / SORTER_MAX_MERGE_COUNT;\n    }\n  }\n\n  if( rc==SQLITE_OK ){\n    p->aReadr[iSeq % SORTER_MAX_MERGE_COUNT].pIncr = pIncr;\n  }else{\n    vdbeIncrFree(pIncr);\n  }\n  return rc;\n}\n\n/*\n** This function is called as part of a SorterRewind() operation on a sorter\n** that has already written two or more level-0 PMAs to one or more temp\n** files. It builds a tree of MergeEngine/IncrMerger/PmaReader objects that \n** can be used to incrementally merge all PMAs on disk.\n**\n** If successful, SQLITE_OK is returned and *ppOut set to point to the\n** MergeEngine object at the root of the tree before returning. Or, if an\n** error occurs, an SQLite error code is returned and the final value \n** of *ppOut is undefined.\n*/\nstatic int vdbeSorterMergeTreeBuild(\n  VdbeSorter *pSorter,       /* The VDBE cursor that implements the sort */\n  MergeEngine **ppOut        /* Write the MergeEngine here */\n){\n  MergeEngine *pMain = 0;\n  int rc = SQLITE_OK;\n  int iTask;\n\n#if SQLITE_MAX_WORKER_THREADS>0\n  /* If the sorter uses more than one task, then create the top-level \n  ** MergeEngine here. This MergeEngine will read data from exactly \n  ** one PmaReader per sub-task.  */\n  assert( pSorter->bUseThreads || pSorter->nTask==1 );\n  if( pSorter->nTask>1 ){\n    pMain = vdbeMergeEngineNew(pSorter->nTask);\n    if( pMain==0 ) rc = SQLITE_NOMEM_BKPT;\n  }\n#endif\n\n  for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n    SortSubtask *pTask = &pSorter->aTask[iTask];\n    assert( pTask->nPMA>0 || SQLITE_MAX_WORKER_THREADS>0 );\n    if( SQLITE_MAX_WORKER_THREADS==0 || pTask->nPMA ){\n      MergeEngine *pRoot = 0;     /* Root node of tree for this task */\n      int nDepth = vdbeSorterTreeDepth(pTask->nPMA);\n      i64 iReadOff = 0;\n\n      if( pTask->nPMA<=SORTER_MAX_MERGE_COUNT ){\n        rc = vdbeMergeEngineLevel0(pTask, pTask->nPMA, &iReadOff, &pRoot);\n      }else{\n        int i;\n        int iSeq = 0;\n        pRoot = vdbeMergeEngineNew(SORTER_MAX_MERGE_COUNT);\n        if( pRoot==0 ) rc = SQLITE_NOMEM_BKPT;\n        for(i=0; i<pTask->nPMA && rc==SQLITE_OK; i += SORTER_MAX_MERGE_COUNT){\n          MergeEngine *pMerger = 0; /* New level-0 PMA merger */\n          int nReader;              /* Number of level-0 PMAs to merge */\n\n          nReader = MIN(pTask->nPMA - i, SORTER_MAX_MERGE_COUNT);\n          rc = vdbeMergeEngineLevel0(pTask, nReader, &iReadOff, &pMerger);\n          if( rc==SQLITE_OK ){\n            rc = vdbeSorterAddToTree(pTask, nDepth, iSeq++, pRoot, pMerger);\n          }\n        }\n      }\n\n      if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS>0\n        if( pMain!=0 ){\n          rc = vdbeIncrMergerNew(pTask, pRoot, &pMain->aReadr[iTask].pIncr);\n        }else\n#endif\n        {\n          assert( pMain==0 );\n          pMain = pRoot;\n        }\n      }else{\n        vdbeMergeEngineFree(pRoot);\n      }\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n    pMain = 0;\n  }\n  *ppOut = pMain;\n  return rc;\n}\n\n/*\n** This function is called as part of an sqlite3VdbeSorterRewind() operation\n** on a sorter that has written two or more PMAs to temporary files. It sets\n** up either VdbeSorter.pMerger (for single threaded sorters) or pReader\n** (for multi-threaded sorters) so that it can be used to iterate through\n** all records stored in the sorter.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int vdbeSorterSetupMerge(VdbeSorter *pSorter){\n  int rc;                         /* Return code */\n  SortSubtask *pTask0 = &pSorter->aTask[0];\n  MergeEngine *pMain = 0;\n#if SQLITE_MAX_WORKER_THREADS\n  sqlite3 *db = pTask0->pSorter->db;\n  int i;\n  SorterCompare xCompare = vdbeSorterGetCompare(pSorter);\n  for(i=0; i<pSorter->nTask; i++){\n    pSorter->aTask[i].xCompare = xCompare;\n  }\n#endif\n\n  rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);\n  if( rc==SQLITE_OK ){\n#if SQLITE_MAX_WORKER_THREADS\n    assert( pSorter->bUseThreads==0 || pSorter->nTask>1 );\n    if( pSorter->bUseThreads ){\n      int iTask;\n      PmaReader *pReadr = 0;\n      SortSubtask *pLast = &pSorter->aTask[pSorter->nTask-1];\n      rc = vdbeSortAllocUnpacked(pLast);\n      if( rc==SQLITE_OK ){\n        pReadr = (PmaReader*)sqlite3DbMallocZero(db, sizeof(PmaReader));\n        pSorter->pReader = pReadr;\n        if( pReadr==0 ) rc = SQLITE_NOMEM_BKPT;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbeIncrMergerNew(pLast, pMain, &pReadr->pIncr);\n        if( rc==SQLITE_OK ){\n          vdbeIncrMergerSetThreads(pReadr->pIncr);\n          for(iTask=0; iTask<(pSorter->nTask-1); iTask++){\n            IncrMerger *pIncr;\n            if( (pIncr = pMain->aReadr[iTask].pIncr) ){\n              vdbeIncrMergerSetThreads(pIncr);\n              assert( pIncr->pTask!=pLast );\n            }\n          }\n          for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){\n            /* Check that:\n            **   \n            **   a) The incremental merge object is configured to use the\n            **      right task, and\n            **   b) If it is using task (nTask-1), it is configured to run\n            **      in single-threaded mode. This is important, as the\n            **      root merge (INCRINIT_ROOT) will be using the same task\n            **      object.\n            */\n            PmaReader *p = &pMain->aReadr[iTask];\n            assert( p->pIncr==0 || (\n                (p->pIncr->pTask==&pSorter->aTask[iTask])             /* a */\n             && (iTask!=pSorter->nTask-1 || p->pIncr->bUseThread==0)  /* b */\n            ));\n            rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);\n          }\n        }\n        pMain = 0;\n      }\n      if( rc==SQLITE_OK ){\n        rc = vdbePmaReaderIncrMergeInit(pReadr, INCRINIT_ROOT);\n      }\n    }else\n#endif\n    {\n      rc = vdbeMergeEngineInit(pTask0, pMain, INCRINIT_NORMAL);\n      pSorter->pMerger = pMain;\n      pMain = 0;\n    }\n  }\n\n  if( rc!=SQLITE_OK ){\n    vdbeMergeEngineFree(pMain);\n  }\n  return rc;\n}\n\n\n/*\n** Once the sorter has been populated by calls to sqlite3VdbeSorterWrite,\n** this function is called to prepare for iterating through the records\n** in sorted order.\n*/\nint sqlite3VdbeSorterRewind(const VdbeCursor *pCsr, int *pbEof){\n  VdbeSorter *pSorter;\n  int rc = SQLITE_OK;             /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter );\n\n  /* If no data has been written to disk, then do not do so now. Instead,\n  ** sort the VdbeSorter.pRecord list. The vdbe layer will read data directly\n  ** from the in-memory list.  */\n  if( pSorter->bUsePMA==0 ){\n    if( pSorter->list.pList ){\n      *pbEof = 0;\n      rc = vdbeSorterSort(&pSorter->aTask[0], &pSorter->list);\n    }else{\n      *pbEof = 1;\n    }\n    return rc;\n  }\n\n  /* Write the current in-memory list to a PMA. When the VdbeSorterWrite() \n  ** function flushes the contents of memory to disk, it immediately always\n  ** creates a new list consisting of a single key immediately afterwards.\n  ** So the list is never empty at this point.  */\n  assert( pSorter->list.pList );\n  rc = vdbeSorterFlushPMA(pSorter);\n\n  /* Join all threads */\n  rc = vdbeSorterJoinAll(pSorter, rc);\n\n  vdbeSorterRewindDebug(\"rewind\");\n\n  /* Assuming no errors have occurred, set up a merger structure to \n  ** incrementally read and merge all remaining PMAs.  */\n  assert( pSorter->pReader==0 );\n  if( rc==SQLITE_OK ){\n    rc = vdbeSorterSetupMerge(pSorter);\n    *pbEof = 0;\n  }\n\n  vdbeSorterRewindDebug(\"rewinddone\");\n  return rc;\n}\n\n/*\n** Advance to the next element in the sorter.  Return value:\n**\n**    SQLITE_OK     success\n**    SQLITE_DONE   end of data\n**    otherwise     some kind of error.\n*/\nint sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr){\n  VdbeSorter *pSorter;\n  int rc;                         /* Return code */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  assert( pSorter->bUsePMA || (pSorter->pReader==0 && pSorter->pMerger==0) );\n  if( pSorter->bUsePMA ){\n    assert( pSorter->pReader==0 || pSorter->pMerger==0 );\n    assert( pSorter->bUseThreads==0 || pSorter->pReader );\n    assert( pSorter->bUseThreads==1 || pSorter->pMerger );\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      rc = vdbePmaReaderNext(pSorter->pReader);\n      if( rc==SQLITE_OK && pSorter->pReader->pFd==0 ) rc = SQLITE_DONE;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/ {\n      int res = 0;\n      assert( pSorter->pMerger!=0 );\n      assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );\n      rc = vdbeMergeEngineStep(pSorter->pMerger, &res);\n      if( rc==SQLITE_OK && res ) rc = SQLITE_DONE;\n    }\n  }else{\n    SorterRecord *pFree = pSorter->list.pList;\n    pSorter->list.pList = pFree->u.pNext;\n    pFree->u.pNext = 0;\n    if( pSorter->list.aMemory==0 ) vdbeSorterRecordFree(db, pFree);\n    rc = pSorter->list.pList ? SQLITE_OK : SQLITE_DONE;\n  }\n  return rc;\n}\n\n/*\n** Return a pointer to a buffer owned by the sorter that contains the \n** current key.\n*/\nstatic void *vdbeSorterRowkey(\n  const VdbeSorter *pSorter,      /* Sorter object */\n  int *pnKey                      /* OUT: Size of current key in bytes */\n){\n  void *pKey;\n  if( pSorter->bUsePMA ){\n    PmaReader *pReader;\n#if SQLITE_MAX_WORKER_THREADS>0\n    if( pSorter->bUseThreads ){\n      pReader = pSorter->pReader;\n    }else\n#endif\n    /*if( !pSorter->bUseThreads )*/{\n      pReader = &pSorter->pMerger->aReadr[pSorter->pMerger->aTree[1]];\n    }\n    *pnKey = pReader->nKey;\n    pKey = pReader->aKey;\n  }else{\n    *pnKey = pSorter->list.pList->nVal;\n    pKey = SRVAL(pSorter->list.pList);\n  }\n  return pKey;\n}\n\n/*\n** Copy the current sorter key into the memory cell pOut.\n*/\nint sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *pOut){\n  VdbeSorter *pSorter;\n  void *pKey; int nKey;           /* Sorter key to copy into pOut */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  if( sqlite3VdbeMemClearAndResize(pOut, nKey) ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  pOut->n = nKey;\n  MemSetTypeFlag(pOut, MEM_Blob);\n  memcpy(pOut->z, pKey, nKey);\n\n  return SQLITE_OK;\n}\n\n/*\n** Compare the key in memory cell pVal with the key that the sorter cursor\n** passed as the first argument currently points to. For the purposes of\n** the comparison, ignore the rowid field at the end of each record.\n**\n** If the sorter cursor key contains any NULL values, consider it to be\n** less than pVal. Even if pVal also contains NULL values.\n**\n** If an error occurs, return an SQLite error code (i.e. SQLITE_NOMEM).\n** Otherwise, set *pRes to a negative, zero or positive value if the\n** key in pVal is smaller than, equal to or larger than the current sorter\n** key.\n**\n** This routine forms the core of the OP_SorterCompare opcode, which in\n** turn is used to verify uniqueness when constructing a UNIQUE INDEX.\n*/\nint sqlite3VdbeSorterCompare(\n  const VdbeCursor *pCsr,         /* Sorter cursor */\n  Mem *pVal,                      /* Value to compare to current sorter key */\n  int nKeyCol,                    /* Compare this many columns */\n  int *pRes                       /* OUT: Result of comparison */\n){\n  VdbeSorter *pSorter;\n  UnpackedRecord *r2;\n  KeyInfo *pKeyInfo;\n  int i;\n  void *pKey; int nKey;           /* Sorter key to compare pVal with */\n\n  assert( pCsr->eCurType==CURTYPE_SORTER );\n  pSorter = pCsr->uc.pSorter;\n  r2 = pSorter->pUnpacked;\n  pKeyInfo = pCsr->pKeyInfo;\n  if( r2==0 ){\n    r2 = pSorter->pUnpacked = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);\n    if( r2==0 ) return SQLITE_NOMEM_BKPT;\n    r2->nField = nKeyCol;\n  }\n  assert( r2->nField==nKeyCol );\n\n  pKey = vdbeSorterRowkey(pSorter, &nKey);\n  sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, r2);\n  for(i=0; i<nKeyCol; i++){\n    if( r2->aMem[i].flags & MEM_Null ){\n      *pRes = -1;\n      return SQLITE_OK;\n    }\n  }\n\n  *pRes = sqlite3VdbeRecordCompare(pVal->n, pVal->z, r2);\n  return SQLITE_OK;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vdbetrace.c",
    "content": "/*\n** 2009 November 25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains code used to insert the values of host parameters\n** (aka \"wildcards\") into the SQL text output by sqlite3_trace().\n**\n** The Vdbe parse-tree explainer is also found here.\n*/\n#include \"sqliteInt.h\"\n#include \"vdbeInt.h\"\n\n#ifndef SQLITE_OMIT_TRACE\n\n/*\n** zSql is a zero-terminated string of UTF-8 SQL text.  Return the number of\n** bytes in this text up to but excluding the first character in\n** a host parameter.  If the text contains no host parameters, return\n** the total number of bytes in the text.\n*/\nstatic int findNextHostParameter(const char *zSql, int *pnToken){\n  int tokenType;\n  int nTotal = 0;\n  int n;\n\n  *pnToken = 0;\n  while( zSql[0] ){\n    n = sqlite3GetToken((u8*)zSql, &tokenType);\n    assert( n>0 && tokenType!=TK_ILLEGAL );\n    if( tokenType==TK_VARIABLE ){\n      *pnToken = n;\n      break;\n    }\n    nTotal += n;\n    zSql += n;\n  }\n  return nTotal;\n}\n\n/*\n** This function returns a pointer to a nul-terminated string in memory\n** obtained from sqlite3DbMalloc(). If sqlite3.nVdbeExec is 1, then the\n** string contains a copy of zRawSql but with host parameters expanded to \n** their current bindings. Or, if sqlite3.nVdbeExec is greater than 1, \n** then the returned string holds a copy of zRawSql with \"-- \" prepended\n** to each line of text.\n**\n** If the SQLITE_TRACE_SIZE_LIMIT macro is defined to an integer, then\n** then long strings and blobs are truncated to that many bytes.  This\n** can be used to prevent unreasonably large trace strings when dealing\n** with large (multi-megabyte) strings and blobs.\n**\n** The calling function is responsible for making sure the memory returned\n** is eventually freed.\n**\n** ALGORITHM:  Scan the input string looking for host parameters in any of\n** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within\n** string literals, quoted identifier names, and comments.  For text forms,\n** the host parameter index is found by scanning the prepared\n** statement for the corresponding OP_Variable opcode.  Once the host\n** parameter index is known, locate the value in p->aVar[].  Then render\n** the value as a literal in place of the host parameter name.\n*/\nchar *sqlite3VdbeExpandSql(\n  Vdbe *p,                 /* The prepared statement being evaluated */\n  const char *zRawSql      /* Raw text of the SQL statement */\n){\n  sqlite3 *db;             /* The database connection */\n  int idx = 0;             /* Index of a host parameter */\n  int nextIndex = 1;       /* Index of next ? host parameter */\n  int n;                   /* Length of a token prefix */\n  int nToken;              /* Length of the parameter token */\n  int i;                   /* Loop counter */\n  Mem *pVar;               /* Value of a host parameter */\n  StrAccum out;            /* Accumulate the output here */\n#ifndef SQLITE_OMIT_UTF16\n  Mem utf8;                /* Used to convert UTF16 into UTF8 for display */\n#endif\n  char zBase[100];         /* Initial working space */\n\n  db = p->db;\n  sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), \n                      db->aLimit[SQLITE_LIMIT_LENGTH]);\n  if( db->nVdbeExec>1 ){\n    while( *zRawSql ){\n      const char *zStart = zRawSql;\n      while( *(zRawSql++)!='\\n' && *zRawSql );\n      sqlite3StrAccumAppend(&out, \"-- \", 3);\n      assert( (zRawSql - zStart) > 0 );\n      sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));\n    }\n  }else if( p->nVar==0 ){\n    sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));\n  }else{\n    while( zRawSql[0] ){\n      n = findNextHostParameter(zRawSql, &nToken);\n      assert( n>0 );\n      sqlite3StrAccumAppend(&out, zRawSql, n);\n      zRawSql += n;\n      assert( zRawSql[0] || nToken==0 );\n      if( nToken==0 ) break;\n      if( zRawSql[0]=='?' ){\n        if( nToken>1 ){\n          assert( sqlite3Isdigit(zRawSql[1]) );\n          sqlite3GetInt32(&zRawSql[1], &idx);\n        }else{\n          idx = nextIndex;\n        }\n      }else{\n        assert( zRawSql[0]==':' || zRawSql[0]=='$' ||\n                zRawSql[0]=='@' || zRawSql[0]=='#' );\n        testcase( zRawSql[0]==':' );\n        testcase( zRawSql[0]=='$' );\n        testcase( zRawSql[0]=='@' );\n        testcase( zRawSql[0]=='#' );\n        idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);\n        assert( idx>0 );\n      }\n      zRawSql += nToken;\n      nextIndex = idx + 1;\n      assert( idx>0 && idx<=p->nVar );\n      pVar = &p->aVar[idx-1];\n      if( pVar->flags & MEM_Null ){\n        sqlite3StrAccumAppend(&out, \"NULL\", 4);\n      }else if( pVar->flags & MEM_Int ){\n        sqlite3XPrintf(&out, \"%lld\", pVar->u.i);\n      }else if( pVar->flags & MEM_Real ){\n        sqlite3XPrintf(&out, \"%!.15g\", pVar->u.r);\n      }else if( pVar->flags & MEM_Str ){\n        int nOut;  /* Number of bytes of the string text to include in output */\n#ifndef SQLITE_OMIT_UTF16\n        u8 enc = ENC(db);\n        if( enc!=SQLITE_UTF8 ){\n          memset(&utf8, 0, sizeof(utf8));\n          utf8.db = db;\n          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);\n          if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){\n            out.accError = STRACCUM_NOMEM;\n            out.nAlloc = 0;\n          }\n          pVar = &utf8;\n        }\n#endif\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){\n          nOut = SQLITE_TRACE_SIZE_LIMIT;\n          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }\n        }\n#endif    \n        sqlite3XPrintf(&out, \"'%.*q'\", nOut, pVar->z);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n#ifndef SQLITE_OMIT_UTF16\n        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);\n#endif\n      }else if( pVar->flags & MEM_Zero ){\n        sqlite3XPrintf(&out, \"zeroblob(%d)\", pVar->u.nZero);\n      }else{\n        int nOut;  /* Number of bytes of the blob to include in output */\n        assert( pVar->flags & MEM_Blob );\n        sqlite3StrAccumAppend(&out, \"x'\", 2);\n        nOut = pVar->n;\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;\n#endif\n        for(i=0; i<nOut; i++){\n          sqlite3XPrintf(&out, \"%02x\", pVar->z[i]&0xff);\n        }\n        sqlite3StrAccumAppend(&out, \"'\", 1);\n#ifdef SQLITE_TRACE_SIZE_LIMIT\n        if( nOut<pVar->n ){\n          sqlite3XPrintf(&out, \"/*+%d bytes*/\", pVar->n-nOut);\n        }\n#endif\n      }\n    }\n  }\n  if( out.accError ) sqlite3StrAccumReset(&out);\n  return sqlite3StrAccumFinish(&out);\n}\n\n#endif /* #ifndef SQLITE_OMIT_TRACE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vtab.c",
    "content": "/*\n** 2006 June 10\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains code used to help implement virtual tables.\n*/\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n#include \"sqliteInt.h\"\n\n/*\n** Before a virtual table xCreate() or xConnect() method is invoked, the\n** sqlite3.pVtabCtx member variable is set to point to an instance of\n** this struct allocated on the stack. It is used by the implementation of \n** the sqlite3_declare_vtab() and sqlite3_vtab_config() APIs, both of which\n** are invoked only from within xCreate and xConnect methods.\n*/\nstruct VtabCtx {\n  VTable *pVTable;    /* The virtual table being constructed */\n  Table *pTab;        /* The Table object to which the virtual table belongs */\n  VtabCtx *pPrior;    /* Parent context (if any) */\n  int bDeclared;      /* True after sqlite3_declare_vtab() is called */\n};\n\n/*\n** Construct and install a Module object for a virtual table.  When this\n** routine is called, it is guaranteed that all appropriate locks are held\n** and the module is not already part of the connection.\n*/\nModule *sqlite3VtabCreateModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  Module *pMod;\n  int nName = sqlite3Strlen30(zName);\n  pMod = (Module *)sqlite3Malloc(sizeof(Module) + nName + 1);\n  if( pMod==0 ){\n    sqlite3OomFault(db);\n  }else{\n    Module *pDel;\n    char *zCopy = (char *)(&pMod[1]);\n    memcpy(zCopy, zName, nName+1);\n    pMod->zName = zCopy;\n    pMod->pModule = pModule;\n    pMod->pAux = pAux;\n    pMod->xDestroy = xDestroy;\n    pMod->pEpoTab = 0;\n    pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod);\n    assert( pDel==0 || pDel==pMod );\n    if( pDel ){\n      sqlite3OomFault(db);\n      sqlite3DbFree(db, pDel);\n      pMod = 0;\n    }\n  }\n  return pMod;\n}\n\n/*\n** The actual function that does the work of creating a new module.\n** This function implements the sqlite3_create_module() and\n** sqlite3_create_module_v2() interfaces.\n*/\nstatic int createModule(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n  int rc = SQLITE_OK;\n\n  sqlite3_mutex_enter(db->mutex);\n  if( sqlite3HashFind(&db->aModule, zName) ){\n    rc = SQLITE_MISUSE_BKPT;\n  }else{\n    (void)sqlite3VtabCreateModule(db, zName, pModule, pAux, xDestroy);\n  }\n  rc = sqlite3ApiExit(db, rc);\n  if( rc!=SQLITE_OK && xDestroy ) xDestroy(pAux);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nint sqlite3_create_module(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux                      /* Context pointer for xCreate/xConnect */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, 0);\n}\n\n/*\n** External API function used to create a new virtual-table module.\n*/\nint sqlite3_create_module_v2(\n  sqlite3 *db,                    /* Database in which module is registered */\n  const char *zName,              /* Name assigned to this module */\n  const sqlite3_module *pModule,  /* The definition of the module */\n  void *pAux,                     /* Context pointer for xCreate/xConnect */\n  void (*xDestroy)(void *)        /* Module destructor function */\n){\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;\n#endif\n  return createModule(db, zName, pModule, pAux, xDestroy);\n}\n\n/*\n** Lock the virtual table so that it cannot be disconnected.\n** Locks nest.  Every lock should have a corresponding unlock.\n** If an unlock is omitted, resources leaks will occur.  \n**\n** If a disconnect is attempted while a virtual table is locked,\n** the disconnect is deferred until all locks have been removed.\n*/\nvoid sqlite3VtabLock(VTable *pVTab){\n  pVTab->nRef++;\n}\n\n\n/*\n** pTab is a pointer to a Table structure representing a virtual-table.\n** Return a pointer to the VTable object used by connection db to access \n** this virtual-table, if one has been created, or NULL otherwise.\n*/\nVTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){\n  VTable *pVtab;\n  assert( IsVirtual(pTab) );\n  for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext);\n  return pVtab;\n}\n\n/*\n** Decrement the ref-count on a virtual table object. When the ref-count\n** reaches zero, call the xDisconnect() method to delete the object.\n*/\nvoid sqlite3VtabUnlock(VTable *pVTab){\n  sqlite3 *db = pVTab->db;\n\n  assert( db );\n  assert( pVTab->nRef>0 );\n  assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE );\n\n  pVTab->nRef--;\n  if( pVTab->nRef==0 ){\n    sqlite3_vtab *p = pVTab->pVtab;\n    if( p ){\n      p->pModule->xDisconnect(p);\n    }\n    sqlite3DbFree(db, pVTab);\n  }\n}\n\n/*\n** Table p is a virtual table. This function moves all elements in the\n** p->pVTable list to the sqlite3.pDisconnect lists of their associated\n** database connections to be disconnected at the next opportunity. \n** Except, if argument db is not NULL, then the entry associated with\n** connection db is left in the p->pVTable list.\n*/\nstatic VTable *vtabDisconnectAll(sqlite3 *db, Table *p){\n  VTable *pRet = 0;\n  VTable *pVTable = p->pVTable;\n  p->pVTable = 0;\n\n  /* Assert that the mutex (if any) associated with the BtShared database \n  ** that contains table p is held by the caller. See header comments \n  ** above function sqlite3VtabUnlockList() for an explanation of why\n  ** this makes it safe to access the sqlite3.pDisconnect list of any\n  ** database connection that may have an entry in the p->pVTable list.\n  */\n  assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) );\n\n  while( pVTable ){\n    sqlite3 *db2 = pVTable->db;\n    VTable *pNext = pVTable->pNext;\n    assert( db2 );\n    if( db2==db ){\n      pRet = pVTable;\n      p->pVTable = pRet;\n      pRet->pNext = 0;\n    }else{\n      pVTable->pNext = db2->pDisconnect;\n      db2->pDisconnect = pVTable;\n    }\n    pVTable = pNext;\n  }\n\n  assert( !db || pRet );\n  return pRet;\n}\n\n/*\n** Table *p is a virtual table. This function removes the VTable object\n** for table *p associated with database connection db from the linked\n** list in p->pVTab. It also decrements the VTable ref count. This is\n** used when closing database connection db to free all of its VTable\n** objects without disturbing the rest of the Schema object (which may\n** be being used by other shared-cache connections).\n*/\nvoid sqlite3VtabDisconnect(sqlite3 *db, Table *p){\n  VTable **ppVTab;\n\n  assert( IsVirtual(p) );\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){\n    if( (*ppVTab)->db==db  ){\n      VTable *pVTab = *ppVTab;\n      *ppVTab = pVTab->pNext;\n      sqlite3VtabUnlock(pVTab);\n      break;\n    }\n  }\n}\n\n\n/*\n** Disconnect all the virtual table objects in the sqlite3.pDisconnect list.\n**\n** This function may only be called when the mutexes associated with all\n** shared b-tree databases opened using connection db are held by the \n** caller. This is done to protect the sqlite3.pDisconnect list. The\n** sqlite3.pDisconnect list is accessed only as follows:\n**\n**   1) By this function. In this case, all BtShared mutexes and the mutex\n**      associated with the database handle itself must be held.\n**\n**   2) By function vtabDisconnectAll(), when it adds a VTable entry to\n**      the sqlite3.pDisconnect list. In this case either the BtShared mutex\n**      associated with the database the virtual table is stored in is held\n**      or, if the virtual table is stored in a non-sharable database, then\n**      the database handle mutex is held.\n**\n** As a result, a sqlite3.pDisconnect cannot be accessed simultaneously \n** by multiple threads. It is thread-safe.\n*/\nvoid sqlite3VtabUnlockList(sqlite3 *db){\n  VTable *p = db->pDisconnect;\n  db->pDisconnect = 0;\n\n  assert( sqlite3BtreeHoldsAllMutexes(db) );\n  assert( sqlite3_mutex_held(db->mutex) );\n\n  if( p ){\n    sqlite3ExpirePreparedStatements(db);\n    do {\n      VTable *pNext = p->pNext;\n      sqlite3VtabUnlock(p);\n      p = pNext;\n    }while( p );\n  }\n}\n\n/*\n** Clear any and all virtual-table information from the Table record.\n** This routine is called, for example, just before deleting the Table\n** record.\n**\n** Since it is a virtual-table, the Table structure contains a pointer\n** to the head of a linked list of VTable structures. Each VTable \n** structure is associated with a single sqlite3* user of the schema.\n** The reference count of the VTable structure associated with database \n** connection db is decremented immediately (which may lead to the \n** structure being xDisconnected and free). Any other VTable structures\n** in the list are moved to the sqlite3.pDisconnect list of the associated \n** database connection.\n*/\nvoid sqlite3VtabClear(sqlite3 *db, Table *p){\n  if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);\n  if( p->azModuleArg ){\n    int i;\n    for(i=0; i<p->nModuleArg; i++){\n      if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);\n    }\n    sqlite3DbFree(db, p->azModuleArg);\n  }\n}\n\n/*\n** Add a new module argument to pTable->azModuleArg[].\n** The string is not copied - the pointer is stored.  The\n** string will be freed automatically when the table is\n** deleted.\n*/\nstatic void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){\n  int nBytes = sizeof(char *)*(2+pTable->nModuleArg);\n  char **azModuleArg;\n  azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes);\n  if( azModuleArg==0 ){\n    sqlite3DbFree(db, zArg);\n  }else{\n    int i = pTable->nModuleArg++;\n    azModuleArg[i] = zArg;\n    azModuleArg[i+1] = 0;\n    pTable->azModuleArg = azModuleArg;\n  }\n}\n\n/*\n** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE\n** statement.  The module name has been parsed, but the optional list\n** of parameters that follow the module name are still pending.\n*/\nvoid sqlite3VtabBeginParse(\n  Parse *pParse,        /* Parsing context */\n  Token *pName1,        /* Name of new table, or database name */\n  Token *pName2,        /* Name of new table or NULL */\n  Token *pModuleName,   /* Name of the module for the virtual table */\n  int ifNotExists       /* No error if the table already exists */\n){\n  int iDb;              /* The database the table is being created in */\n  Table *pTable;        /* The new virtual table */\n  sqlite3 *db;          /* Database connection */\n\n  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);\n  pTable = pParse->pNewTable;\n  if( pTable==0 ) return;\n  assert( 0==pTable->pIndex );\n\n  db = pParse->db;\n  iDb = sqlite3SchemaToIndex(db, pTable->pSchema);\n  assert( iDb>=0 );\n\n  assert( pTable->nModuleArg==0 );\n  addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));\n  addModuleArgument(db, pTable, 0);\n  addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));\n  assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)\n       || (pParse->sNameToken.z==pName1->z && pName2->z==0)\n  );\n  pParse->sNameToken.n = (int)(\n      &pModuleName->z[pModuleName->n] - pParse->sNameToken.z\n  );\n\n#ifndef SQLITE_OMIT_AUTHORIZATION\n  /* Creating a virtual table invokes the authorization callback twice.\n  ** The first invocation, to obtain permission to INSERT a row into the\n  ** sqlite_master table, has already been made by sqlite3StartTable().\n  ** The second call, to obtain permission to create the table, is made now.\n  */\n  if( pTable->azModuleArg ){\n    sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, \n            pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName);\n  }\n#endif\n}\n\n/*\n** This routine takes the module argument that has been accumulating\n** in pParse->zArg[] and appends it to the list of arguments on the\n** virtual table currently under construction in pParse->pTable.\n*/\nstatic void addArgumentToVtab(Parse *pParse){\n  if( pParse->sArg.z && pParse->pNewTable ){\n    const char *z = (const char*)pParse->sArg.z;\n    int n = pParse->sArg.n;\n    sqlite3 *db = pParse->db;\n    addModuleArgument(db, pParse->pNewTable, sqlite3DbStrNDup(db, z, n));\n  }\n}\n\n/*\n** The parser calls this routine after the CREATE VIRTUAL TABLE statement\n** has been completely parsed.\n*/\nvoid sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){\n  Table *pTab = pParse->pNewTable;  /* The table being constructed */\n  sqlite3 *db = pParse->db;         /* The database connection */\n\n  if( pTab==0 ) return;\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  if( pTab->nModuleArg<1 ) return;\n  \n  /* If the CREATE VIRTUAL TABLE statement is being entered for the\n  ** first time (in other words if the virtual table is actually being\n  ** created now instead of just being read out of sqlite_master) then\n  ** do additional initialization work and store the statement text\n  ** in the sqlite_master table.\n  */\n  if( !db->init.busy ){\n    char *zStmt;\n    char *zWhere;\n    int iDb;\n    int iReg;\n    Vdbe *v;\n\n    /* Compute the complete text of the CREATE VIRTUAL TABLE statement */\n    if( pEnd ){\n      pParse->sNameToken.n = (int)(pEnd->z - pParse->sNameToken.z) + pEnd->n;\n    }\n    zStmt = sqlite3MPrintf(db, \"CREATE VIRTUAL TABLE %T\", &pParse->sNameToken);\n\n    /* A slot for the record has already been allocated in the \n    ** SQLITE_MASTER table.  We just need to update that slot with all\n    ** the information we've collected.  \n    **\n    ** The VM register number pParse->regRowid holds the rowid of an\n    ** entry in the sqlite_master table tht was created for this vtab\n    ** by sqlite3StartTable().\n    */\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    sqlite3NestedParse(pParse,\n      \"UPDATE %Q.%s \"\n         \"SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q \"\n       \"WHERE rowid=#%d\",\n      db->aDb[iDb].zDbSName, MASTER_NAME,\n      pTab->zName,\n      pTab->zName,\n      zStmt,\n      pParse->regRowid\n    );\n    sqlite3DbFree(db, zStmt);\n    v = sqlite3GetVdbe(pParse);\n    sqlite3ChangeCookie(pParse, iDb);\n\n    sqlite3VdbeAddOp0(v, OP_Expire);\n    zWhere = sqlite3MPrintf(db, \"name='%q' AND type='table'\", pTab->zName);\n    sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);\n\n    iReg = ++pParse->nMem;\n    sqlite3VdbeLoadString(v, iReg, pTab->zName);\n    sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);\n  }\n\n  /* If we are rereading the sqlite_master table create the in-memory\n  ** record of the table. The xConnect() method is not called until\n  ** the first time the virtual table is used in an SQL statement. This\n  ** allows a schema that contains virtual tables to be loaded before\n  ** the required virtual table implementations are registered.  */\n  else {\n    Table *pOld;\n    Schema *pSchema = pTab->pSchema;\n    const char *zName = pTab->zName;\n    assert( sqlite3SchemaMutexHeld(db, 0, pSchema) );\n    pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab);\n    if( pOld ){\n      sqlite3OomFault(db);\n      assert( pTab==pOld );  /* Malloc must have failed inside HashInsert() */\n      return;\n    }\n    pParse->pNewTable = 0;\n  }\n}\n\n/*\n** The parser calls this routine when it sees the first token\n** of an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nvoid sqlite3VtabArgInit(Parse *pParse){\n  addArgumentToVtab(pParse);\n  pParse->sArg.z = 0;\n  pParse->sArg.n = 0;\n}\n\n/*\n** The parser calls this routine for each token after the first token\n** in an argument to the module name in a CREATE VIRTUAL TABLE statement.\n*/\nvoid sqlite3VtabArgExtend(Parse *pParse, Token *p){\n  Token *pArg = &pParse->sArg;\n  if( pArg->z==0 ){\n    pArg->z = p->z;\n    pArg->n = p->n;\n  }else{\n    assert(pArg->z <= p->z);\n    pArg->n = (int)(&p->z[p->n] - pArg->z);\n  }\n}\n\n/*\n** Invoke a virtual table constructor (either xCreate or xConnect). The\n** pointer to the function to invoke is passed as the fourth parameter\n** to this procedure.\n*/\nstatic int vtabCallConstructor(\n  sqlite3 *db, \n  Table *pTab,\n  Module *pMod,\n  int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),\n  char **pzErr\n){\n  VtabCtx sCtx;\n  VTable *pVTable;\n  int rc;\n  const char *const*azArg = (const char *const*)pTab->azModuleArg;\n  int nArg = pTab->nModuleArg;\n  char *zErr = 0;\n  char *zModuleName;\n  int iDb;\n  VtabCtx *pCtx;\n\n  /* Check that the virtual-table is not already being initialized */\n  for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){\n    if( pCtx->pTab==pTab ){\n      *pzErr = sqlite3MPrintf(db, \n          \"vtable constructor called recursively: %s\", pTab->zName\n      );\n      return SQLITE_LOCKED;\n    }\n  }\n\n  zModuleName = sqlite3DbStrDup(db, pTab->zName);\n  if( !zModuleName ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pVTable = sqlite3MallocZero(sizeof(VTable));\n  if( !pVTable ){\n    sqlite3OomFault(db);\n    sqlite3DbFree(db, zModuleName);\n    return SQLITE_NOMEM_BKPT;\n  }\n  pVTable->db = db;\n  pVTable->pMod = pMod;\n\n  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n  pTab->azModuleArg[1] = db->aDb[iDb].zDbSName;\n\n  /* Invoke the virtual table constructor */\n  assert( &db->pVtabCtx );\n  assert( xConstruct );\n  sCtx.pTab = pTab;\n  sCtx.pVTable = pVTable;\n  sCtx.pPrior = db->pVtabCtx;\n  sCtx.bDeclared = 0;\n  db->pVtabCtx = &sCtx;\n  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);\n  db->pVtabCtx = sCtx.pPrior;\n  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);\n  assert( sCtx.pTab==pTab );\n\n  if( SQLITE_OK!=rc ){\n    if( zErr==0 ){\n      *pzErr = sqlite3MPrintf(db, \"vtable constructor failed: %s\", zModuleName);\n    }else {\n      *pzErr = sqlite3MPrintf(db, \"%s\", zErr);\n      sqlite3_free(zErr);\n    }\n    sqlite3DbFree(db, pVTable);\n  }else if( ALWAYS(pVTable->pVtab) ){\n    /* Justification of ALWAYS():  A correct vtab constructor must allocate\n    ** the sqlite3_vtab object if successful.  */\n    memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));\n    pVTable->pVtab->pModule = pMod->pModule;\n    pVTable->nRef = 1;\n    if( sCtx.bDeclared==0 ){\n      const char *zFormat = \"vtable constructor did not declare schema: %s\";\n      *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);\n      sqlite3VtabUnlock(pVTable);\n      rc = SQLITE_ERROR;\n    }else{\n      int iCol;\n      u8 oooHidden = 0;\n      /* If everything went according to plan, link the new VTable structure\n      ** into the linked list headed by pTab->pVTable. Then loop through the \n      ** columns of the table to see if any of them contain the token \"hidden\".\n      ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from\n      ** the type string.  */\n      pVTable->pNext = pTab->pVTable;\n      pTab->pVTable = pVTable;\n\n      for(iCol=0; iCol<pTab->nCol; iCol++){\n        char *zType = sqlite3ColumnType(&pTab->aCol[iCol], \"\");\n        int nType;\n        int i = 0;\n        nType = sqlite3Strlen30(zType);\n        for(i=0; i<nType; i++){\n          if( 0==sqlite3StrNICmp(\"hidden\", &zType[i], 6)\n           && (i==0 || zType[i-1]==' ')\n           && (zType[i+6]=='\\0' || zType[i+6]==' ')\n          ){\n            break;\n          }\n        }\n        if( i<nType ){\n          int j;\n          int nDel = 6 + (zType[i+6] ? 1 : 0);\n          for(j=i; (j+nDel)<=nType; j++){\n            zType[j] = zType[j+nDel];\n          }\n          if( zType[i]=='\\0' && i>0 ){\n            assert(zType[i-1]==' ');\n            zType[i-1] = '\\0';\n          }\n          pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;\n          oooHidden = TF_OOOHidden;\n        }else{\n          pTab->tabFlags |= oooHidden;\n        }\n      }\n    }\n  }\n\n  sqlite3DbFree(db, zModuleName);\n  return rc;\n}\n\n/*\n** This function is invoked by the parser to call the xConnect() method\n** of the virtual table pTab. If an error occurs, an error code is returned \n** and an error left in pParse.\n**\n** This call is a no-op if table pTab is not a virtual table.\n*/\nint sqlite3VtabCallConnect(Parse *pParse, Table *pTab){\n  sqlite3 *db = pParse->db;\n  const char *zMod;\n  Module *pMod;\n  int rc;\n\n  assert( pTab );\n  if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){\n    return SQLITE_OK;\n  }\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  if( !pMod ){\n    const char *zModule = pTab->azModuleArg[0];\n    sqlite3ErrorMsg(pParse, \"no such module: %s\", zModule);\n    rc = SQLITE_ERROR;\n  }else{\n    char *zErr = 0;\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xConnect, &zErr);\n    if( rc!=SQLITE_OK ){\n      sqlite3ErrorMsg(pParse, \"%s\", zErr);\n      pParse->rc = rc;\n    }\n    sqlite3DbFree(db, zErr);\n  }\n\n  return rc;\n}\n/*\n** Grow the db->aVTrans[] array so that there is room for at least one\n** more v-table. Return SQLITE_NOMEM if a malloc fails, or SQLITE_OK otherwise.\n*/\nstatic int growVTrans(sqlite3 *db){\n  const int ARRAY_INCR = 5;\n\n  /* Grow the sqlite3.aVTrans array if required */\n  if( (db->nVTrans%ARRAY_INCR)==0 ){\n    VTable **aVTrans;\n    int nBytes = sizeof(sqlite3_vtab *) * (db->nVTrans + ARRAY_INCR);\n    aVTrans = sqlite3DbRealloc(db, (void *)db->aVTrans, nBytes);\n    if( !aVTrans ){\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset(&aVTrans[db->nVTrans], 0, sizeof(sqlite3_vtab *)*ARRAY_INCR);\n    db->aVTrans = aVTrans;\n  }\n\n  return SQLITE_OK;\n}\n\n/*\n** Add the virtual table pVTab to the array sqlite3.aVTrans[]. Space should\n** have already been reserved using growVTrans().\n*/\nstatic void addToVTrans(sqlite3 *db, VTable *pVTab){\n  /* Add pVtab to the end of sqlite3.aVTrans */\n  db->aVTrans[db->nVTrans++] = pVTab;\n  sqlite3VtabLock(pVTab);\n}\n\n/*\n** This function is invoked by the vdbe to call the xCreate method\n** of the virtual table named zTab in database iDb. \n**\n** If an error occurs, *pzErr is set to point to an English language\n** description of the error and an SQLITE_XXX error code is returned.\n** In this case the caller must call sqlite3DbFree(db, ) on *pzErr.\n*/\nint sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, char **pzErr){\n  int rc = SQLITE_OK;\n  Table *pTab;\n  Module *pMod;\n  const char *zMod;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  assert( pTab && IsVirtual(pTab) && !pTab->pVTable );\n\n  /* Locate the required virtual table module */\n  zMod = pTab->azModuleArg[0];\n  pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);\n\n  /* If the module has been registered and includes a Create method, \n  ** invoke it now. If the module has not been registered, return an \n  ** error. Otherwise, do nothing.\n  */\n  if( pMod==0 || pMod->pModule->xCreate==0 || pMod->pModule->xDestroy==0 ){\n    *pzErr = sqlite3MPrintf(db, \"no such module: %s\", zMod);\n    rc = SQLITE_ERROR;\n  }else{\n    rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr);\n  }\n\n  /* Justification of ALWAYS():  The xConstructor method is required to\n  ** create a valid sqlite3_vtab if it returns SQLITE_OK. */\n  if( rc==SQLITE_OK && ALWAYS(sqlite3GetVTable(db, pTab)) ){\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      addToVTrans(db, sqlite3GetVTable(db, pTab));\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function is used to set the schema of a virtual table.  It is only\n** valid to call this function from within the xCreate() or xConnect() of a\n** virtual table module.\n*/\nint sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){\n  VtabCtx *pCtx;\n  int rc = SQLITE_OK;\n  Table *pTab;\n  char *zErr = 0;\n  Parse sParse;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){\n    return SQLITE_MISUSE_BKPT;\n  }\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  pCtx = db->pVtabCtx;\n  if( !pCtx || pCtx->bDeclared ){\n    sqlite3Error(db, SQLITE_MISUSE);\n    sqlite3_mutex_leave(db->mutex);\n    return SQLITE_MISUSE_BKPT;\n  }\n  pTab = pCtx->pTab;\n  assert( IsVirtual(pTab) );\n\n  memset(&sParse, 0, sizeof(sParse));\n  sParse.declareVtab = 1;\n  sParse.db = db;\n  sParse.nQueryLoop = 1;\n  if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr) \n   && sParse.pNewTable\n   && !db->mallocFailed\n   && !sParse.pNewTable->pSelect\n   && !IsVirtual(sParse.pNewTable)\n  ){\n    if( !pTab->aCol ){\n      Table *pNew = sParse.pNewTable;\n      Index *pIdx;\n      pTab->aCol = pNew->aCol;\n      pTab->nCol = pNew->nCol;\n      pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid);\n      pNew->nCol = 0;\n      pNew->aCol = 0;\n      assert( pTab->pIndex==0 );\n      assert( HasRowid(pNew) || sqlite3PrimaryKeyIndex(pNew)!=0 );\n      if( !HasRowid(pNew)\n       && pCtx->pVTable->pMod->pModule->xUpdate!=0\n       && sqlite3PrimaryKeyIndex(pNew)->nKeyCol!=1\n      ){\n        /* WITHOUT ROWID virtual tables must either be read-only (xUpdate==0)\n        ** or else must have a single-column PRIMARY KEY */\n        rc = SQLITE_ERROR;\n      }\n      pIdx = pNew->pIndex;\n      if( pIdx ){\n        assert( pIdx->pNext==0 );\n        pTab->pIndex = pIdx;\n        pNew->pIndex = 0;\n        pIdx->pTable = pTab;\n      }\n    }\n    pCtx->bDeclared = 1;\n  }else{\n    sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? \"%s\" : 0), zErr);\n    sqlite3DbFree(db, zErr);\n    rc = SQLITE_ERROR;\n  }\n  sParse.declareVtab = 0;\n\n  if( sParse.pVdbe ){\n    sqlite3VdbeFinalize(sParse.pVdbe);\n  }\n  sqlite3DeleteTable(db, sParse.pNewTable);\n  sqlite3ParserReset(&sParse);\n\n  assert( (rc&0xff)==rc );\n  rc = sqlite3ApiExit(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n/*\n** This function is invoked by the vdbe to call the xDestroy method\n** of the virtual table named zTab in database iDb. This occurs\n** when a DROP TABLE is mentioned.\n**\n** This call is a no-op if zTab is not a virtual table.\n*/\nint sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){\n  int rc = SQLITE_OK;\n  Table *pTab;\n\n  pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);\n  if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){\n    VTable *p;\n    int (*xDestroy)(sqlite3_vtab *);\n    for(p=pTab->pVTable; p; p=p->pNext){\n      assert( p->pVtab );\n      if( p->pVtab->nRef>0 ){\n        return SQLITE_LOCKED;\n      }\n    }\n    p = vtabDisconnectAll(db, pTab);\n    xDestroy = p->pMod->pModule->xDestroy;\n    assert( xDestroy!=0 );  /* Checked before the virtual table is created */\n    rc = xDestroy(p->pVtab);\n    /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */\n    if( rc==SQLITE_OK ){\n      assert( pTab->pVTable==p && p->pNext==0 );\n      p->pVtab = 0;\n      pTab->pVTable = 0;\n      sqlite3VtabUnlock(p);\n    }\n  }\n\n  return rc;\n}\n\n/*\n** This function invokes either the xRollback or xCommit method\n** of each of the virtual tables in the sqlite3.aVTrans array. The method\n** called is identified by the second argument, \"offset\", which is\n** the offset of the method to call in the sqlite3_module structure.\n**\n** The array is cleared after invoking the callbacks. \n*/\nstatic void callFinaliser(sqlite3 *db, int offset){\n  int i;\n  if( db->aVTrans ){\n    VTable **aVTrans = db->aVTrans;\n    db->aVTrans = 0;\n    for(i=0; i<db->nVTrans; i++){\n      VTable *pVTab = aVTrans[i];\n      sqlite3_vtab *p = pVTab->pVtab;\n      if( p ){\n        int (*x)(sqlite3_vtab *);\n        x = *(int (**)(sqlite3_vtab *))((char *)p->pModule + offset);\n        if( x ) x(p);\n      }\n      pVTab->iSavepoint = 0;\n      sqlite3VtabUnlock(pVTab);\n    }\n    sqlite3DbFree(db, aVTrans);\n    db->nVTrans = 0;\n  }\n}\n\n/*\n** Invoke the xSync method of all virtual tables in the sqlite3.aVTrans\n** array. Return the error code for the first error that occurs, or\n** SQLITE_OK if all xSync operations are successful.\n**\n** If an error message is available, leave it in p->zErrMsg.\n*/\nint sqlite3VtabSync(sqlite3 *db, Vdbe *p){\n  int i;\n  int rc = SQLITE_OK;\n  VTable **aVTrans = db->aVTrans;\n\n  db->aVTrans = 0;\n  for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n    int (*x)(sqlite3_vtab *);\n    sqlite3_vtab *pVtab = aVTrans[i]->pVtab;\n    if( pVtab && (x = pVtab->pModule->xSync)!=0 ){\n      rc = x(pVtab);\n      sqlite3VtabImportErrmsg(p, pVtab);\n    }\n  }\n  db->aVTrans = aVTrans;\n  return rc;\n}\n\n/*\n** Invoke the xRollback method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nint sqlite3VtabRollback(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xRollback));\n  return SQLITE_OK;\n}\n\n/*\n** Invoke the xCommit method of all virtual tables in the \n** sqlite3.aVTrans array. Then clear the array itself.\n*/\nint sqlite3VtabCommit(sqlite3 *db){\n  callFinaliser(db, offsetof(sqlite3_module,xCommit));\n  return SQLITE_OK;\n}\n\n/*\n** If the virtual table pVtab supports the transaction interface\n** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is\n** not currently open, invoke the xBegin method now.\n**\n** If the xBegin call is successful, place the sqlite3_vtab pointer\n** in the sqlite3.aVTrans array.\n*/\nint sqlite3VtabBegin(sqlite3 *db, VTable *pVTab){\n  int rc = SQLITE_OK;\n  const sqlite3_module *pModule;\n\n  /* Special case: If db->aVTrans is NULL and db->nVTrans is greater\n  ** than zero, then this function is being called from within a\n  ** virtual module xSync() callback. It is illegal to write to \n  ** virtual module tables in this case, so return SQLITE_LOCKED.\n  */\n  if( sqlite3VtabInSync(db) ){\n    return SQLITE_LOCKED;\n  }\n  if( !pVTab ){\n    return SQLITE_OK;\n  } \n  pModule = pVTab->pVtab->pModule;\n\n  if( pModule->xBegin ){\n    int i;\n\n    /* If pVtab is already in the aVTrans array, return early */\n    for(i=0; i<db->nVTrans; i++){\n      if( db->aVTrans[i]==pVTab ){\n        return SQLITE_OK;\n      }\n    }\n\n    /* Invoke the xBegin method. If successful, add the vtab to the \n    ** sqlite3.aVTrans[] array. */\n    rc = growVTrans(db);\n    if( rc==SQLITE_OK ){\n      rc = pModule->xBegin(pVTab->pVtab);\n      if( rc==SQLITE_OK ){\n        int iSvpt = db->nStatement + db->nSavepoint;\n        addToVTrans(db, pVTab);\n        if( iSvpt && pModule->xSavepoint ){\n          pVTab->iSavepoint = iSvpt;\n          rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** Invoke either the xSavepoint, xRollbackTo or xRelease method of all\n** virtual tables that currently have an open transaction. Pass iSavepoint\n** as the second argument to the virtual table method invoked.\n**\n** If op is SAVEPOINT_BEGIN, the xSavepoint method is invoked. If it is\n** SAVEPOINT_ROLLBACK, the xRollbackTo method. Otherwise, if op is \n** SAVEPOINT_RELEASE, then the xRelease method of each virtual table with\n** an open transaction is invoked.\n**\n** If any virtual table method returns an error code other than SQLITE_OK, \n** processing is abandoned and the error returned to the caller of this\n** function immediately. If all calls to virtual table methods are successful,\n** SQLITE_OK is returned.\n*/\nint sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){\n  int rc = SQLITE_OK;\n\n  assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );\n  assert( iSavepoint>=-1 );\n  if( db->aVTrans ){\n    int i;\n    for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){\n      VTable *pVTab = db->aVTrans[i];\n      const sqlite3_module *pMod = pVTab->pMod->pModule;\n      if( pVTab->pVtab && pMod->iVersion>=2 ){\n        int (*xMethod)(sqlite3_vtab *, int);\n        switch( op ){\n          case SAVEPOINT_BEGIN:\n            xMethod = pMod->xSavepoint;\n            pVTab->iSavepoint = iSavepoint+1;\n            break;\n          case SAVEPOINT_ROLLBACK:\n            xMethod = pMod->xRollbackTo;\n            break;\n          default:\n            xMethod = pMod->xRelease;\n            break;\n        }\n        if( xMethod && pVTab->iSavepoint>iSavepoint ){\n          rc = xMethod(pVTab->pVtab, iSavepoint);\n        }\n      }\n    }\n  }\n  return rc;\n}\n\n/*\n** The first parameter (pDef) is a function implementation.  The\n** second parameter (pExpr) is the first argument to this function.\n** If pExpr is a column in a virtual table, then let the virtual\n** table implementation have an opportunity to overload the function.\n**\n** This routine is used to allow virtual table implementations to\n** overload MATCH, LIKE, GLOB, and REGEXP operators.\n**\n** Return either the pDef argument (indicating no change) or a \n** new FuncDef structure that is marked as ephemeral using the\n** SQLITE_FUNC_EPHEM flag.\n*/\nFuncDef *sqlite3VtabOverloadFunction(\n  sqlite3 *db,    /* Database connection for reporting malloc problems */\n  FuncDef *pDef,  /* Function to possibly overload */\n  int nArg,       /* Number of arguments to the function */\n  Expr *pExpr     /* First argument to the function */\n){\n  Table *pTab;\n  sqlite3_vtab *pVtab;\n  sqlite3_module *pMod;\n  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**) = 0;\n  void *pArg = 0;\n  FuncDef *pNew;\n  int rc = 0;\n  char *zLowerName;\n  unsigned char *z;\n\n\n  /* Check to see the left operand is a column in a virtual table */\n  if( NEVER(pExpr==0) ) return pDef;\n  if( pExpr->op!=TK_COLUMN ) return pDef;\n  pTab = pExpr->pTab;\n  if( pTab==0 ) return pDef;\n  if( !IsVirtual(pTab) ) return pDef;\n  pVtab = sqlite3GetVTable(db, pTab)->pVtab;\n  assert( pVtab!=0 );\n  assert( pVtab->pModule!=0 );\n  pMod = (sqlite3_module *)pVtab->pModule;\n  if( pMod->xFindFunction==0 ) return pDef;\n \n  /* Call the xFindFunction method on the virtual table implementation\n  ** to see if the implementation wants to overload this function \n  */\n  zLowerName = sqlite3DbStrDup(db, pDef->zName);\n  if( zLowerName ){\n    for(z=(unsigned char*)zLowerName; *z; z++){\n      *z = sqlite3UpperToLower[*z];\n    }\n    rc = pMod->xFindFunction(pVtab, nArg, zLowerName, &xSFunc, &pArg);\n    sqlite3DbFree(db, zLowerName);\n  }\n  if( rc==0 ){\n    return pDef;\n  }\n\n  /* Create a new ephemeral function definition for the overloaded\n  ** function */\n  pNew = sqlite3DbMallocZero(db, sizeof(*pNew)\n                             + sqlite3Strlen30(pDef->zName) + 1);\n  if( pNew==0 ){\n    return pDef;\n  }\n  *pNew = *pDef;\n  pNew->zName = (const char*)&pNew[1];\n  memcpy((char*)&pNew[1], pDef->zName, sqlite3Strlen30(pDef->zName)+1);\n  pNew->xSFunc = xSFunc;\n  pNew->pUserData = pArg;\n  pNew->funcFlags |= SQLITE_FUNC_EPHEM;\n  return pNew;\n}\n\n/*\n** Make sure virtual table pTab is contained in the pParse->apVirtualLock[]\n** array so that an OP_VBegin will get generated for it.  Add pTab to the\n** array if it is missing.  If pTab is already in the array, this routine\n** is a no-op.\n*/\nvoid sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){\n  Parse *pToplevel = sqlite3ParseToplevel(pParse);\n  int i, n;\n  Table **apVtabLock;\n\n  assert( IsVirtual(pTab) );\n  for(i=0; i<pToplevel->nVtabLock; i++){\n    if( pTab==pToplevel->apVtabLock[i] ) return;\n  }\n  n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);\n  apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);\n  if( apVtabLock ){\n    pToplevel->apVtabLock = apVtabLock;\n    pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;\n  }else{\n    sqlite3OomFault(pToplevel->db);\n  }\n}\n\n/*\n** Check to see if virtual table module pMod can be have an eponymous\n** virtual table instance.  If it can, create one if one does not already\n** exist. Return non-zero if the eponymous virtual table instance exists\n** when this routine returns, and return zero if it does not exist.\n**\n** An eponymous virtual table instance is one that is named after its\n** module, and more importantly, does not require a CREATE VIRTUAL TABLE\n** statement in order to come into existance.  Eponymous virtual table\n** instances always exist.  They cannot be DROP-ed.\n**\n** Any virtual table module for which xConnect and xCreate are the same\n** method can have an eponymous virtual table instance.\n*/\nint sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){\n  const sqlite3_module *pModule = pMod->pModule;\n  Table *pTab;\n  char *zErr = 0;\n  int rc;\n  sqlite3 *db = pParse->db;\n  if( pMod->pEpoTab ) return 1;\n  if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0;\n  pTab = sqlite3DbMallocZero(db, sizeof(Table));\n  if( pTab==0 ) return 0;\n  pTab->zName = sqlite3DbStrDup(db, pMod->zName);\n  if( pTab->zName==0 ){\n    sqlite3DbFree(db, pTab);\n    return 0;\n  }\n  pMod->pEpoTab = pTab;\n  pTab->nTabRef = 1;\n  pTab->pSchema = db->aDb[0].pSchema;\n  assert( pTab->nModuleArg==0 );\n  pTab->iPKey = -1;\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  addModuleArgument(db, pTab, 0);\n  addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));\n  rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);\n  if( rc ){\n    sqlite3ErrorMsg(pParse, \"%s\", zErr);\n    sqlite3DbFree(db, zErr);\n    sqlite3VtabEponymousTableClear(db, pMod);\n    return 0;\n  }\n  return 1;\n}\n\n/*\n** Erase the eponymous virtual table instance associated with\n** virtual table module pMod, if it exists.\n*/\nvoid sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){\n  Table *pTab = pMod->pEpoTab;\n  if( pTab!=0 ){\n    /* Mark the table as Ephemeral prior to deleting it, so that the\n    ** sqlite3DeleteTable() routine will know that it is not stored in \n    ** the schema. */\n    pTab->tabFlags |= TF_Ephemeral;\n    sqlite3DeleteTable(db, pTab);\n    pMod->pEpoTab = 0;\n  }\n}\n\n/*\n** Return the ON CONFLICT resolution mode in effect for the virtual\n** table update operation currently in progress.\n**\n** The results of this routine are undefined unless it is called from\n** within an xUpdate method.\n*/\nint sqlite3_vtab_on_conflict(sqlite3 *db){\n  static const unsigned char aMap[] = { \n    SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE \n  };\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 );\n  assert( OE_Ignore==4 && OE_Replace==5 );\n  assert( db->vtabOnConflict>=1 && db->vtabOnConflict<=5 );\n  return (int)aMap[db->vtabOnConflict-1];\n}\n\n/*\n** Call from within the xCreate() or xConnect() methods to provide \n** the SQLite core with additional information about the behavior\n** of the virtual table being implemented.\n*/\nint sqlite3_vtab_config(sqlite3 *db, int op, ...){\n  va_list ap;\n  int rc = SQLITE_OK;\n\n#ifdef SQLITE_ENABLE_API_ARMOR\n  if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;\n#endif\n  sqlite3_mutex_enter(db->mutex);\n  va_start(ap, op);\n  switch( op ){\n    case SQLITE_VTAB_CONSTRAINT_SUPPORT: {\n      VtabCtx *p = db->pVtabCtx;\n      if( !p ){\n        rc = SQLITE_MISUSE_BKPT;\n      }else{\n        assert( p->pTab==0 || IsVirtual(p->pTab) );\n        p->pVTable->bConstraint = (u8)va_arg(ap, int);\n      }\n      break;\n    }\n    default:\n      rc = SQLITE_MISUSE_BKPT;\n      break;\n  }\n  va_end(ap);\n\n  if( rc!=SQLITE_OK ) sqlite3Error(db, rc);\n  sqlite3_mutex_leave(db->mutex);\n  return rc;\n}\n\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/vxworks.h",
    "content": "/*\n** 2015-03-02\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n******************************************************************************\n**\n** This file contains code that is specific to Wind River's VxWorks\n*/\n#if defined(__RTP__) || defined(_WRS_KERNEL)\n/* This is VxWorks.  Set up things specially for that OS\n*/\n#include <vxWorks.h>\n#include <pthread.h>  /* amalgamator: dontcache */\n#define OS_VXWORKS 1\n#define SQLITE_OS_OTHER 0\n#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1\n#define SQLITE_OMIT_LOAD_EXTENSION 1\n#define SQLITE_ENABLE_LOCKING_STYLE 0\n#define HAVE_UTIME 1\n#else\n/* This is not VxWorks. */\n#define OS_VXWORKS 0\n#define HAVE_FCHOWN 1\n#define HAVE_READLINK 1\n#define HAVE_LSTAT 1\n#endif /* defined(_WRS_KERNEL) */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/wal.c",
    "content": "/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains the implementation of a write-ahead log (WAL) used in \n** \"journal_mode=WAL\" mode.\n**\n** WRITE-AHEAD LOG (WAL) FILE FORMAT\n**\n** A WAL file consists of a header followed by zero or more \"frames\".\n** Each frame records the revised content of a single page from the\n** database file.  All changes to the database are recorded by writing\n** frames into the WAL.  Transactions commit when a frame is written that\n** contains a commit marker.  A single WAL can and usually does record \n** multiple transactions.  Periodically, the content of the WAL is\n** transferred back into the database file in an operation called a\n** \"checkpoint\".\n**\n** A single WAL file can be used multiple times.  In other words, the\n** WAL can fill up with frames and then be checkpointed and then new\n** frames can overwrite the old ones.  A WAL always grows from beginning\n** toward the end.  Checksums and counters attached to each frame are\n** used to determine which frames within the WAL are valid and which\n** are leftovers from prior checkpoints.\n**\n** The WAL header is 32 bytes in size and consists of the following eight\n** big-endian 32-bit unsigned integer values:\n**\n**     0: Magic number.  0x377f0682 or 0x377f0683\n**     4: File format version.  Currently 3007000\n**     8: Database page size.  Example: 1024\n**    12: Checkpoint sequence number\n**    16: Salt-1, random integer incremented with each checkpoint\n**    20: Salt-2, a different random integer changing with each ckpt\n**    24: Checksum-1 (first part of checksum for first 24 bytes of header).\n**    28: Checksum-2 (second part of checksum for first 24 bytes of header).\n**\n** Immediately following the wal-header are zero or more frames. Each\n** frame consists of a 24-byte frame-header followed by a <page-size> bytes\n** of page data. The frame-header is six big-endian 32-bit unsigned \n** integer values, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the header)\n**    12: Salt-2 (copied from the header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n**\n** A frame is considered valid if and only if the following conditions are\n** true:\n**\n**    (1) The salt-1 and salt-2 values in the frame-header match\n**        salt values in the wal-header\n**\n**    (2) The checksum values in the final 8 bytes of the frame-header\n**        exactly match the checksum computed consecutively on the\n**        WAL header and the first 8 bytes and the content of all frames\n**        up to and including the current frame.\n**\n** The checksum is computed using 32-bit big-endian integers if the\n** magic number in the first 4 bytes of the WAL is 0x377f0683 and it\n** is computed using little-endian if the magic number is 0x377f0682.\n** The checksum values are always stored in the frame header in a\n** big-endian format regardless of which byte order is used to compute\n** the checksum.  The checksum is computed by interpreting the input as\n** an even number of unsigned 32-bit integers: x[0] through x[N].  The\n** algorithm used for the checksum is as follows:\n** \n**   for i from 0 to n-1 step 2:\n**     s0 += x[i] + s1;\n**     s1 += x[i+1] + s0;\n**   endfor\n**\n** Note that s0 and s1 are both weighted checksums using fibonacci weights\n** in reverse order (the largest fibonacci weight occurs on the first element\n** of the sequence being summed.)  The s1 value spans all 32-bit \n** terms of the sequence whereas s0 omits the final term.\n**\n** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the\n** WAL is transferred into the database, then the database is VFS.xSync-ed.\n** The VFS.xSync operations serve as write barriers - all writes launched\n** before the xSync must complete before any write that launches after the\n** xSync begins.\n**\n** After each checkpoint, the salt-1 value is incremented and the salt-2\n** value is randomized.  This prevents old and new frames in the WAL from\n** being considered valid at the same time and being checkpointing together\n** following a crash.\n**\n** READER ALGORITHM\n**\n** To read a page from the database (call it page number P), a reader\n** first checks the WAL to see if it contains page P.  If so, then the\n** last valid instance of page P that is a followed by a commit frame\n** or is a commit frame itself becomes the value read.  If the WAL\n** contains no copies of page P that are valid and which are a commit\n** frame or are followed by a commit frame, then page P is read from\n** the database file.\n**\n** To start a read transaction, the reader records the index of the last\n** valid frame in the WAL.  The reader uses this recorded \"mxFrame\" value\n** for all subsequent read operations.  New transactions can be appended\n** to the WAL, but as long as the reader uses its original mxFrame value\n** and ignores the newly appended content, it will see a consistent snapshot\n** of the database from a single point in time.  This technique allows\n** multiple concurrent readers to view different versions of the database\n** content simultaneously.\n**\n** The reader algorithm in the previous paragraphs works correctly, but \n** because frames for page P can appear anywhere within the WAL, the\n** reader has to scan the entire WAL looking for page P frames.  If the\n** WAL is large (multiple megabytes is typical) that scan can be slow,\n** and read performance suffers.  To overcome this problem, a separate\n** data structure called the wal-index is maintained to expedite the\n** search for frames of a particular page.\n** \n** WAL-INDEX FORMAT\n**\n** Conceptually, the wal-index is shared memory, though VFS implementations\n** might choose to implement the wal-index using a mmapped file.  Because\n** the wal-index is shared memory, SQLite does not support journal_mode=WAL \n** on a network filesystem.  All users of the database must be able to\n** share memory.\n**\n** The wal-index is transient.  After a crash, the wal-index can (and should\n** be) reconstructed from the original WAL file.  In fact, the VFS is required\n** to either truncate or zero the header of the wal-index when the last\n** connection to it closes.  Because the wal-index is transient, it can\n** use an architecture-specific format; it does not have to be cross-platform.\n** Hence, unlike the database and WAL file formats which store all values\n** as big endian, the wal-index can store multi-byte values in the native\n** byte order of the host computer.\n**\n** The purpose of the wal-index is to answer this question quickly:  Given\n** a page number P and a maximum frame index M, return the index of the \n** last frame in the wal before frame M for page P in the WAL, or return\n** NULL if there are no frames for page P in the WAL prior to M.\n**\n** The wal-index consists of a header region, followed by an one or\n** more index blocks.  \n**\n** The wal-index header contains the total number of frames within the WAL\n** in the mxFrame field.\n**\n** Each index block except for the first contains information on \n** HASHTABLE_NPAGE frames. The first index block contains information on\n** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and \n** HASHTABLE_NPAGE are selected so that together the wal-index header and\n** first index block are the same size as all other index blocks in the\n** wal-index.\n**\n** Each index block contains two sections, a page-mapping that contains the\n** database page number associated with each wal frame, and a hash-table \n** that allows readers to query an index block for a specific page number.\n** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE\n** for the first index block) 32-bit page numbers. The first entry in the \n** first index-block contains the database page number corresponding to the\n** first frame in the WAL file. The first entry in the second index block\n** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in\n** the log, and so on.\n**\n** The last index block in a wal-index usually contains less than the full\n** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,\n** depending on the contents of the WAL file. This does not change the\n** allocated size of the page-mapping array - the page-mapping array merely\n** contains unused entries.\n**\n** Even without using the hash table, the last frame for page P\n** can be found by scanning the page-mapping sections of each index block\n** starting with the last index block and moving toward the first, and\n** within each index block, starting at the end and moving toward the\n** beginning.  The first entry that equals P corresponds to the frame\n** holding the content for that page.\n**\n** The hash table consists of HASHTABLE_NSLOT 16-bit unsigned integers.\n** HASHTABLE_NSLOT = 2*HASHTABLE_NPAGE, and there is one entry in the\n** hash table for each page number in the mapping section, so the hash \n** table is never more than half full.  The expected number of collisions \n** prior to finding a match is 1.  Each entry of the hash table is an\n** 1-based index of an entry in the mapping section of the same\n** index block.   Let K be the 1-based index of the largest entry in\n** the mapping section.  (For index blocks other than the last, K will\n** always be exactly HASHTABLE_NPAGE (4096) and for the last index block\n** K will be (mxFrame%HASHTABLE_NPAGE).)  Unused slots of the hash table\n** contain a value of 0.\n**\n** To look for page P in the hash table, first compute a hash iKey on\n** P as follows:\n**\n**      iKey = (P * 383) % HASHTABLE_NSLOT\n**\n** Then start scanning entries of the hash table, starting with iKey\n** (wrapping around to the beginning when the end of the hash table is\n** reached) until an unused hash slot is found. Let the first unused slot\n** be at index iUnused.  (iUnused might be less than iKey if there was\n** wrap-around.) Because the hash table is never more than half full,\n** the search is guaranteed to eventually hit an unused entry.  Let \n** iMax be the value between iKey and iUnused, closest to iUnused,\n** where aHash[iMax]==P.  If there is no iMax entry (if there exists\n** no hash slot such that aHash[i]==p) then page P is not in the\n** current index block.  Otherwise the iMax-th mapping entry of the\n** current index block corresponds to the last entry that references \n** page P.\n**\n** A hash search begins with the last index block and moves toward the\n** first index block, looking for entries corresponding to page P.  On\n** average, only two or three slots in each index block need to be\n** examined in order to either find the last entry for page P, or to\n** establish that no such entry exists in the block.  Each index block\n** holds over 4000 entries.  So two or three index blocks are sufficient\n** to cover a typical 10 megabyte WAL file, assuming 1K pages.  8 or 10\n** comparisons (on average) suffice to either locate a frame in the\n** WAL or to establish that the frame does not exist in the WAL.  This\n** is much faster than scanning the entire 10MB WAL.\n**\n** Note that entries are added in order of increasing K.  Hence, one\n** reader might be using some value K0 and a second reader that started\n** at a later time (after additional transactions were added to the WAL\n** and to the wal-index) might be using a different value K1, where K1>K0.\n** Both readers can use the same hash table and mapping section to get\n** the correct result.  There may be entries in the hash table with\n** K>K0 but to the first reader, those entries will appear to be unused\n** slots in the hash table and so the first reader will get an answer as\n** if no values greater than K0 had ever been inserted into the hash table\n** in the first place - which is what reader one wants.  Meanwhile, the\n** second reader using K1 will see additional values that were inserted\n** later, which is exactly what reader two wants.  \n**\n** When a rollback occurs, the value of K is decreased. Hash table entries\n** that correspond to frames greater than the new K value are removed\n** from the hash table at this point.\n*/\n#ifndef SQLITE_OMIT_WAL\n\n#include \"wal.h\"\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\nint sqlite3WalTrace = 0;\n# define WALTRACE(X)  if(sqlite3WalTrace) sqlite3DebugPrintf X\n#else\n# define WALTRACE(X)\n#endif\n\n/*\n** The maximum (and only) versions of the wal and wal-index formats\n** that may be interpreted by this version of SQLite.\n**\n** If a client begins recovering a WAL file and finds that (a) the checksum\n** values in the wal-header are correct and (b) the version field is not\n** WAL_MAX_VERSION, recovery fails and SQLite returns SQLITE_CANTOPEN.\n**\n** Similarly, if a client successfully reads a wal-index header (i.e. the \n** checksum test is successful) and finds that the version field is not\n** WALINDEX_MAX_VERSION, then no read-transaction is opened and SQLite\n** returns SQLITE_CANTOPEN.\n*/\n#define WAL_MAX_VERSION      3007000\n#define WALINDEX_MAX_VERSION 3007000\n\n/*\n** Indices of various locking bytes.   WAL_NREADER is the number\n** of available reader locks and should be at least 3.  The default\n** is SQLITE_SHM_NLOCK==8 and  WAL_NREADER==5.\n*/\n#define WAL_WRITE_LOCK         0\n#define WAL_ALL_BUT_WRITE      1\n#define WAL_CKPT_LOCK          1\n#define WAL_RECOVER_LOCK       2\n#define WAL_READ_LOCK(I)       (3+(I))\n#define WAL_NREADER            (SQLITE_SHM_NLOCK-3)\n\n\n/* Object declarations */\ntypedef struct WalIndexHdr WalIndexHdr;\ntypedef struct WalIterator WalIterator;\ntypedef struct WalCkptInfo WalCkptInfo;\n\n\n/*\n** The following object holds a copy of the wal-index header content.\n**\n** The actual header in the wal-index consists of two copies of this\n** object followed by one instance of the WalCkptInfo object.\n** For all versions of SQLite through 3.10.0 and probably beyond,\n** the locking bytes (WalCkptInfo.aLock) start at offset 120 and\n** the total header size is 136 bytes.\n**\n** The szPage value can be any power of 2 between 512 and 32768, inclusive.\n** Or it can be 1 to represent a 65536-byte page.  The latter case was\n** added in 3.7.1 when support for 64K pages was added.  \n*/\nstruct WalIndexHdr {\n  u32 iVersion;                   /* Wal-index version */\n  u32 unused;                     /* Unused (padding) field */\n  u32 iChange;                    /* Counter incremented each transaction */\n  u8 isInit;                      /* 1 when initialized */\n  u8 bigEndCksum;                 /* True if checksums in WAL are big-endian */\n  u16 szPage;                     /* Database page size in bytes. 1==64K */\n  u32 mxFrame;                    /* Index of last valid frame in the WAL */\n  u32 nPage;                      /* Size of database in pages */\n  u32 aFrameCksum[2];             /* Checksum of last frame in log */\n  u32 aSalt[2];                   /* Two salt values copied from WAL header */\n  u32 aCksum[2];                  /* Checksum over all prior fields */\n};\n\n/*\n** A copy of the following object occurs in the wal-index immediately\n** following the second copy of the WalIndexHdr.  This object stores\n** information used by checkpoint.\n**\n** nBackfill is the number of frames in the WAL that have been written\n** back into the database. (We call the act of moving content from WAL to\n** database \"backfilling\".)  The nBackfill number is never greater than\n** WalIndexHdr.mxFrame.  nBackfill can only be increased by threads\n** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).\n** However, a WAL_WRITE_LOCK thread can move the value of nBackfill from\n** mxFrame back to zero when the WAL is reset.\n**\n** nBackfillAttempted is the largest value of nBackfill that a checkpoint\n** has attempted to achieve.  Normally nBackfill==nBackfillAtempted, however\n** the nBackfillAttempted is set before any backfilling is done and the\n** nBackfill is only set after all backfilling completes.  So if a checkpoint\n** crashes, nBackfillAttempted might be larger than nBackfill.  The\n** WalIndexHdr.mxFrame must never be less than nBackfillAttempted.\n**\n** The aLock[] field is a set of bytes used for locking.  These bytes should\n** never be read or written.\n**\n** There is one entry in aReadMark[] for each reader lock.  If a reader\n** holds read-lock K, then the value in aReadMark[K] is no greater than\n** the mxFrame for that reader.  The value READMARK_NOT_USED (0xffffffff)\n** for any aReadMark[] means that entry is unused.  aReadMark[0] is \n** a special case; its value is never used and it exists as a place-holder\n** to avoid having to offset aReadMark[] indexs by one.  Readers holding\n** WAL_READ_LOCK(0) always ignore the entire WAL and read all content\n** directly from the database.\n**\n** The value of aReadMark[K] may only be changed by a thread that\n** is holding an exclusive lock on WAL_READ_LOCK(K).  Thus, the value of\n** aReadMark[K] cannot changed while there is a reader is using that mark\n** since the reader will be holding a shared lock on WAL_READ_LOCK(K).\n**\n** The checkpointer may only transfer frames from WAL to database where\n** the frame numbers are less than or equal to every aReadMark[] that is\n** in use (that is, every aReadMark[j] for which there is a corresponding\n** WAL_READ_LOCK(j)).  New readers (usually) pick the aReadMark[] with the\n** largest value and will increase an unused aReadMark[] to mxFrame if there\n** is not already an aReadMark[] equal to mxFrame.  The exception to the\n** previous sentence is when nBackfill equals mxFrame (meaning that everything\n** in the WAL has been backfilled into the database) then new readers\n** will choose aReadMark[0] which has value 0 and hence such reader will\n** get all their all content directly from the database file and ignore \n** the WAL.\n**\n** Writers normally append new frames to the end of the WAL.  However,\n** if nBackfill equals mxFrame (meaning that all WAL content has been\n** written back into the database) and if no readers are using the WAL\n** (in other words, if there are no WAL_READ_LOCK(i) where i>0) then\n** the writer will first \"reset\" the WAL back to the beginning and start\n** writing new content beginning at frame 1.\n**\n** We assume that 32-bit loads are atomic and so no locks are needed in\n** order to read from any aReadMark[] entries.\n*/\nstruct WalCkptInfo {\n  u32 nBackfill;                  /* Number of WAL frames backfilled into DB */\n  u32 aReadMark[WAL_NREADER];     /* Reader marks */\n  u8 aLock[SQLITE_SHM_NLOCK];     /* Reserved space for locks */\n  u32 nBackfillAttempted;         /* WAL frames perhaps written, or maybe not */\n  u32 notUsed0;                   /* Available for future enhancements */\n};\n#define READMARK_NOT_USED  0xffffffff\n\n\n/* A block of WALINDEX_LOCK_RESERVED bytes beginning at\n** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems\n** only support mandatory file-locks, we do not read or write data\n** from the region of the file on which locks are applied.\n*/\n#define WALINDEX_LOCK_OFFSET (sizeof(WalIndexHdr)*2+offsetof(WalCkptInfo,aLock))\n#define WALINDEX_HDR_SIZE    (sizeof(WalIndexHdr)*2+sizeof(WalCkptInfo))\n\n/* Size of header before each frame in wal */\n#define WAL_FRAME_HDRSIZE 24\n\n/* Size of write ahead log header, including checksum. */\n/* #define WAL_HDRSIZE 24 */\n#define WAL_HDRSIZE 32\n\n/* WAL magic value. Either this value, or the same value with the least\n** significant bit also set (WAL_MAGIC | 0x00000001) is stored in 32-bit\n** big-endian format in the first 4 bytes of a WAL file.\n**\n** If the LSB is set, then the checksums for each frame within the WAL\n** file are calculated by treating all data as an array of 32-bit \n** big-endian words. Otherwise, they are calculated by interpreting \n** all data as 32-bit little-endian words.\n*/\n#define WAL_MAGIC 0x377f0682\n\n/*\n** Return the offset of frame iFrame in the write-ahead log file, \n** assuming a database page size of szPage bytes. The offset returned\n** is to the start of the write-ahead log frame-header.\n*/\n#define walFrameOffset(iFrame, szPage) (                               \\\n  WAL_HDRSIZE + ((iFrame)-1)*(i64)((szPage)+WAL_FRAME_HDRSIZE)         \\\n)\n\n/*\n** An open write-ahead log file is represented by an instance of the\n** following object.\n*/\nstruct Wal {\n  sqlite3_vfs *pVfs;         /* The VFS used to create pDbFd */\n  sqlite3_file *pDbFd;       /* File handle for the database file */\n  sqlite3_file *pWalFd;      /* File handle for WAL file */\n  u32 iCallback;             /* Value to pass to log callback (or 0) */\n  i64 mxWalSize;             /* Truncate WAL to this size upon reset */\n  int nWiData;               /* Size of array apWiData */\n  int szFirstBlock;          /* Size of first block written to WAL file */\n  volatile u32 **apWiData;   /* Pointer to wal-index content in memory */\n  u32 szPage;                /* Database page size */\n  i16 readLock;              /* Which read lock is being held.  -1 for none */\n  u8 syncFlags;              /* Flags to use to sync header writes */\n  u8 exclusiveMode;          /* Non-zero if connection is in exclusive mode */\n  u8 writeLock;              /* True if in a write transaction */\n  u8 ckptLock;               /* True if holding a checkpoint lock */\n  u8 readOnly;               /* WAL_RDWR, WAL_RDONLY, or WAL_SHM_RDONLY */\n  u8 truncateOnCommit;       /* True to truncate WAL file on commit */\n  u8 syncHeader;             /* Fsync the WAL header if true */\n  u8 padToSectorBoundary;    /* Pad transactions out to the next sector */\n  WalIndexHdr hdr;           /* Wal-index header for current transaction */\n  u32 minFrame;              /* Ignore wal frames before this one */\n  u32 iReCksum;              /* On commit, recalculate checksums from here */\n  const char *zWalName;      /* Name of WAL file */\n  u32 nCkpt;                 /* Checkpoint sequence counter in the wal-header */\n#ifdef SQLITE_DEBUG\n  u8 lockError;              /* True if a locking error has occurred */\n#endif\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  WalIndexHdr *pSnapshot;    /* Start transaction here if not NULL */\n#endif\n};\n\n/*\n** Candidate values for Wal.exclusiveMode.\n*/\n#define WAL_NORMAL_MODE     0\n#define WAL_EXCLUSIVE_MODE  1     \n#define WAL_HEAPMEMORY_MODE 2\n\n/*\n** Possible values for WAL.readOnly\n*/\n#define WAL_RDWR        0    /* Normal read/write connection */\n#define WAL_RDONLY      1    /* The WAL file is readonly */\n#define WAL_SHM_RDONLY  2    /* The SHM file is readonly */\n\n/*\n** Each page of the wal-index mapping contains a hash-table made up of\n** an array of HASHTABLE_NSLOT elements of the following type.\n*/\ntypedef u16 ht_slot;\n\n/*\n** This structure is used to implement an iterator that loops through\n** all frames in the WAL in database page order. Where two or more frames\n** correspond to the same database page, the iterator visits only the \n** frame most recently written to the WAL (in other words, the frame with\n** the largest index).\n**\n** The internals of this structure are only accessed by:\n**\n**   walIteratorInit() - Create a new iterator,\n**   walIteratorNext() - Step an iterator,\n**   walIteratorFree() - Free an iterator.\n**\n** This functionality is used by the checkpoint code (see walCheckpoint()).\n*/\nstruct WalIterator {\n  int iPrior;                     /* Last result returned from the iterator */\n  int nSegment;                   /* Number of entries in aSegment[] */\n  struct WalSegment {\n    int iNext;                    /* Next slot in aIndex[] not yet returned */\n    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */\n    u32 *aPgno;                   /* Array of page numbers. */\n    int nEntry;                   /* Nr. of entries in aPgno[] and aIndex[] */\n    int iZero;                    /* Frame number associated with aPgno[0] */\n  } aSegment[1];                  /* One for every 32KB page in the wal-index */\n};\n\n/*\n** Define the parameters of the hash tables in the wal-index file. There\n** is a hash-table following every HASHTABLE_NPAGE page numbers in the\n** wal-index.\n**\n** Changing any of these constants will alter the wal-index format and\n** create incompatibilities.\n*/\n#define HASHTABLE_NPAGE      4096                 /* Must be power of 2 */\n#define HASHTABLE_HASH_1     383                  /* Should be prime */\n#define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */\n\n/* \n** The block of page numbers associated with the first hash-table in a\n** wal-index is smaller than usual. This is so that there is a complete\n** hash-table on each aligned 32KB page of the wal-index.\n*/\n#define HASHTABLE_NPAGE_ONE  (HASHTABLE_NPAGE - (WALINDEX_HDR_SIZE/sizeof(u32)))\n\n/* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */\n#define WALINDEX_PGSZ   (                                         \\\n    sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \\\n)\n\n/*\n** Obtain a pointer to the iPage'th page of the wal-index. The wal-index\n** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are\n** numbered from zero.\n**\n** If this call is successful, *ppPage is set to point to the wal-index\n** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs,\n** then an SQLite error code is returned and *ppPage is set to 0.\n*/\nstatic int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){\n  int rc = SQLITE_OK;\n\n  /* Enlarge the pWal->apWiData[] array if required */\n  if( pWal->nWiData<=iPage ){\n    int nByte = sizeof(u32*)*(iPage+1);\n    volatile u32 **apNew;\n    apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);\n    if( !apNew ){\n      *ppPage = 0;\n      return SQLITE_NOMEM_BKPT;\n    }\n    memset((void*)&apNew[pWal->nWiData], 0,\n           sizeof(u32*)*(iPage+1-pWal->nWiData));\n    pWal->apWiData = apNew;\n    pWal->nWiData = iPage+1;\n  }\n\n  /* Request a pointer to the required page from the VFS */\n  if( pWal->apWiData[iPage]==0 ){\n    if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n      pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);\n      if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM_BKPT;\n    }else{\n      rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, \n          pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]\n      );\n      if( rc==SQLITE_READONLY ){\n        pWal->readOnly |= WAL_SHM_RDONLY;\n        rc = SQLITE_OK;\n      }\n    }\n  }\n\n  *ppPage = pWal->apWiData[iPage];\n  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );\n  return rc;\n}\n\n/*\n** Return a pointer to the WalCkptInfo structure in the wal-index.\n*/\nstatic volatile WalCkptInfo *walCkptInfo(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalCkptInfo*)&(pWal->apWiData[0][sizeof(WalIndexHdr)/2]);\n}\n\n/*\n** Return a pointer to the WalIndexHdr structure in the wal-index.\n*/\nstatic volatile WalIndexHdr *walIndexHdr(Wal *pWal){\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n  return (volatile WalIndexHdr*)pWal->apWiData[0];\n}\n\n/*\n** The argument to this macro must be of type u32. On a little-endian\n** architecture, it returns the u32 value that results from interpreting\n** the 4 bytes as a big-endian value. On a big-endian architecture, it\n** returns the value that would be produced by interpreting the 4 bytes\n** of the input value as a little-endian integer.\n*/\n#define BYTESWAP32(x) ( \\\n    (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \\\n  + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \\\n)\n\n/*\n** Generate or extend an 8 byte checksum based on the data in \n** array aByte[] and the initial values of aIn[0] and aIn[1] (or\n** initial values of 0 and 0 if aIn==NULL).\n**\n** The checksum is written back into aOut[] before returning.\n**\n** nByte must be a positive multiple of 8.\n*/\nstatic void walChecksumBytes(\n  int nativeCksum, /* True for native byte-order, false for non-native */\n  u8 *a,           /* Content to be checksummed */\n  int nByte,       /* Bytes of content in a[].  Must be a multiple of 8. */\n  const u32 *aIn,  /* Initial checksum value input */\n  u32 *aOut        /* OUT: Final checksum value output */\n){\n  u32 s1, s2;\n  u32 *aData = (u32 *)a;\n  u32 *aEnd = (u32 *)&a[nByte];\n\n  if( aIn ){\n    s1 = aIn[0];\n    s2 = aIn[1];\n  }else{\n    s1 = s2 = 0;\n  }\n\n  assert( nByte>=8 );\n  assert( (nByte&0x00000007)==0 );\n\n  if( nativeCksum ){\n    do {\n      s1 += *aData++ + s2;\n      s2 += *aData++ + s1;\n    }while( aData<aEnd );\n  }else{\n    do {\n      s1 += BYTESWAP32(aData[0]) + s2;\n      s2 += BYTESWAP32(aData[1]) + s1;\n      aData += 2;\n    }while( aData<aEnd );\n  }\n\n  aOut[0] = s1;\n  aOut[1] = s2;\n}\n\nstatic void walShmBarrier(Wal *pWal){\n  if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){\n    sqlite3OsShmBarrier(pWal->pDbFd);\n  }\n}\n\n/*\n** Write the header information in pWal->hdr into the wal-index.\n**\n** The checksum on pWal->hdr is updated before it is written.\n*/\nstatic void walIndexWriteHdr(Wal *pWal){\n  volatile WalIndexHdr *aHdr = walIndexHdr(pWal);\n  const int nCksum = offsetof(WalIndexHdr, aCksum);\n\n  assert( pWal->writeLock );\n  pWal->hdr.isInit = 1;\n  pWal->hdr.iVersion = WALINDEX_MAX_VERSION;\n  walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);\n  memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n  walShmBarrier(pWal);\n  memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));\n}\n\n/*\n** This function encodes a single frame header and writes it to a buffer\n** supplied by the caller. A frame-header is made up of a series of \n** 4-byte big-endian integers, as follows:\n**\n**     0: Page number.\n**     4: For commit records, the size of the database image in pages \n**        after the commit. For all other records, zero.\n**     8: Salt-1 (copied from the wal-header)\n**    12: Salt-2 (copied from the wal-header)\n**    16: Checksum-1.\n**    20: Checksum-2.\n*/\nstatic void walEncodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 iPage,                      /* Database page number for frame */\n  u32 nTruncate,                  /* New db size (or 0 for non-commit frames) */\n  u8 *aData,                      /* Pointer to page data */\n  u8 *aFrame                      /* OUT: Write encoded frame here */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  assert( WAL_FRAME_HDRSIZE==24 );\n  sqlite3Put4byte(&aFrame[0], iPage);\n  sqlite3Put4byte(&aFrame[4], nTruncate);\n  if( pWal->iReCksum==0 ){\n    memcpy(&aFrame[8], pWal->hdr.aSalt, 8);\n\n    nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n    walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n    walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n\n    sqlite3Put4byte(&aFrame[16], aCksum[0]);\n    sqlite3Put4byte(&aFrame[20], aCksum[1]);\n  }else{\n    memset(&aFrame[8], 0, 16);\n  }\n}\n\n/*\n** Check to see if the frame with header in aFrame[] and content\n** in aData[] is valid.  If it is a valid frame, fill *piPage and\n** *pnTruncate and return true.  Return if the frame is not valid.\n*/\nstatic int walDecodeFrame(\n  Wal *pWal,                      /* The write-ahead log */\n  u32 *piPage,                    /* OUT: Database page number for frame */\n  u32 *pnTruncate,                /* OUT: New db size (or 0 if not commit) */\n  u8 *aData,                      /* Pointer to page data (for checksum) */\n  u8 *aFrame                      /* Frame data */\n){\n  int nativeCksum;                /* True for native byte-order checksums */\n  u32 *aCksum = pWal->hdr.aFrameCksum;\n  u32 pgno;                       /* Page number of the frame */\n  assert( WAL_FRAME_HDRSIZE==24 );\n\n  /* A frame is only valid if the salt values in the frame-header\n  ** match the salt values in the wal-header. \n  */\n  if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if the page number is creater than zero.\n  */\n  pgno = sqlite3Get4byte(&aFrame[0]);\n  if( pgno==0 ){\n    return 0;\n  }\n\n  /* A frame is only valid if a checksum of the WAL header,\n  ** all prior frams, the first 16 bytes of this frame-header, \n  ** and the frame-data matches the checksum in the last 8 \n  ** bytes of this frame-header.\n  */\n  nativeCksum = (pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN);\n  walChecksumBytes(nativeCksum, aFrame, 8, aCksum, aCksum);\n  walChecksumBytes(nativeCksum, aData, pWal->szPage, aCksum, aCksum);\n  if( aCksum[0]!=sqlite3Get4byte(&aFrame[16]) \n   || aCksum[1]!=sqlite3Get4byte(&aFrame[20]) \n  ){\n    /* Checksum failed. */\n    return 0;\n  }\n\n  /* If we reach this point, the frame is valid.  Return the page number\n  ** and the new database size.\n  */\n  *piPage = pgno;\n  *pnTruncate = sqlite3Get4byte(&aFrame[4]);\n  return 1;\n}\n\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n/*\n** Names of locks.  This routine is used to provide debugging output and is not\n** a part of an ordinary build.\n*/\nstatic const char *walLockName(int lockIdx){\n  if( lockIdx==WAL_WRITE_LOCK ){\n    return \"WRITE-LOCK\";\n  }else if( lockIdx==WAL_CKPT_LOCK ){\n    return \"CKPT-LOCK\";\n  }else if( lockIdx==WAL_RECOVER_LOCK ){\n    return \"RECOVER-LOCK\";\n  }else{\n    static char zName[15];\n    sqlite3_snprintf(sizeof(zName), zName, \"READ-LOCK[%d]\",\n                     lockIdx-WAL_READ_LOCK(0));\n    return zName;\n  }\n}\n#endif /*defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */\n    \n\n/*\n** Set or release locks on the WAL.  Locks are either shared or exclusive.\n** A lock cannot be moved directly between shared and exclusive - it must go\n** through the unlocked state first.\n**\n** In locking_mode=EXCLUSIVE, all of these routines become no-ops.\n*/\nstatic int walLockShared(Wal *pWal, int lockIdx){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: acquire SHARED-%s %s\\n\", pWal,\n            walLockName(lockIdx), rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockShared(Wal *pWal, int lockIdx){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, 1,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);\n  WALTRACE((\"WAL%p: release SHARED-%s\\n\", pWal, walLockName(lockIdx)));\n}\nstatic int walLockExclusive(Wal *pWal, int lockIdx, int n){\n  int rc;\n  if( pWal->exclusiveMode ) return SQLITE_OK;\n  rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                        SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\\n\", pWal,\n            walLockName(lockIdx), n, rc ? \"failed\" : \"ok\"));\n  VVA_ONLY( pWal->lockError = (u8)(rc!=SQLITE_OK && rc!=SQLITE_BUSY); )\n  return rc;\n}\nstatic void walUnlockExclusive(Wal *pWal, int lockIdx, int n){\n  if( pWal->exclusiveMode ) return;\n  (void)sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,\n                         SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE);\n  WALTRACE((\"WAL%p: release EXCLUSIVE-%s cnt=%d\\n\", pWal,\n             walLockName(lockIdx), n));\n}\n\n/*\n** Compute a hash on a page number.  The resulting hash value must land\n** between 0 and (HASHTABLE_NSLOT-1).  The walHashNext() function advances\n** the hash to the next value in the event of a collision.\n*/\nstatic int walHash(u32 iPage){\n  assert( iPage>0 );\n  assert( (HASHTABLE_NSLOT & (HASHTABLE_NSLOT-1))==0 );\n  return (iPage*HASHTABLE_HASH_1) & (HASHTABLE_NSLOT-1);\n}\nstatic int walNextHash(int iPriorHash){\n  return (iPriorHash+1)&(HASHTABLE_NSLOT-1);\n}\n\n/* \n** Return pointers to the hash table and page number array stored on\n** page iHash of the wal-index. The wal-index is broken into 32KB pages\n** numbered starting from 0.\n**\n** Set output variable *paHash to point to the start of the hash table\n** in the wal-index file. Set *piZero to one less than the frame \n** number of the first frame indexed by this hash table. If a\n** slot in the hash table is set to N, it refers to frame number \n** (*piZero+N) in the log.\n**\n** Finally, set *paPgno so that *paPgno[1] is the page number of the\n** first frame indexed by the hash table, frame (*piZero+1).\n*/\nstatic int walHashGet(\n  Wal *pWal,                      /* WAL handle */\n  int iHash,                      /* Find the iHash'th table */\n  volatile ht_slot **paHash,      /* OUT: Pointer to hash index */\n  volatile u32 **paPgno,          /* OUT: Pointer to page number array */\n  u32 *piZero                     /* OUT: Frame associated with *paPgno[0] */\n){\n  int rc;                         /* Return code */\n  volatile u32 *aPgno;\n\n  rc = walIndexPage(pWal, iHash, &aPgno);\n  assert( rc==SQLITE_OK || iHash>0 );\n\n  if( rc==SQLITE_OK ){\n    u32 iZero;\n    volatile ht_slot *aHash;\n\n    aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];\n    if( iHash==0 ){\n      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];\n      iZero = 0;\n    }else{\n      iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;\n    }\n  \n    *paPgno = &aPgno[-1];\n    *paHash = aHash;\n    *piZero = iZero;\n  }\n  return rc;\n}\n\n/*\n** Return the number of the wal-index page that contains the hash-table\n** and page-number array that contain entries corresponding to WAL frame\n** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages \n** are numbered starting from 0.\n*/\nstatic int walFramePage(u32 iFrame){\n  int iHash = (iFrame+HASHTABLE_NPAGE-HASHTABLE_NPAGE_ONE-1) / HASHTABLE_NPAGE;\n  assert( (iHash==0 || iFrame>HASHTABLE_NPAGE_ONE)\n       && (iHash>=1 || iFrame<=HASHTABLE_NPAGE_ONE)\n       && (iHash<=1 || iFrame>(HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE))\n       && (iHash>=2 || iFrame<=HASHTABLE_NPAGE_ONE+HASHTABLE_NPAGE)\n       && (iHash<=2 || iFrame>(HASHTABLE_NPAGE_ONE+2*HASHTABLE_NPAGE))\n  );\n  return iHash;\n}\n\n/*\n** Return the page number associated with frame iFrame in this WAL.\n*/\nstatic u32 walFramePgno(Wal *pWal, u32 iFrame){\n  int iHash = walFramePage(iFrame);\n  if( iHash==0 ){\n    return pWal->apWiData[0][WALINDEX_HDR_SIZE/sizeof(u32) + iFrame - 1];\n  }\n  return pWal->apWiData[iHash][(iFrame-1-HASHTABLE_NPAGE_ONE)%HASHTABLE_NPAGE];\n}\n\n/*\n** Remove entries from the hash table that point to WAL slots greater\n** than pWal->hdr.mxFrame.\n**\n** This function is called whenever pWal->hdr.mxFrame is decreased due\n** to a rollback or savepoint.\n**\n** At most only the hash table containing pWal->hdr.mxFrame needs to be\n** updated.  Any later hash tables will be automatically cleared when\n** pWal->hdr.mxFrame advances to the point where those hash tables are\n** actually needed.\n*/\nstatic void walCleanupHash(Wal *pWal){\n  volatile ht_slot *aHash = 0;    /* Pointer to hash table to clear */\n  volatile u32 *aPgno = 0;        /* Page number array for hash table */\n  u32 iZero = 0;                  /* frame == (aHash[x]+iZero) */\n  int iLimit = 0;                 /* Zero values greater than this */\n  int nByte;                      /* Number of bytes to zero in aPgno[] */\n  int i;                          /* Used to iterate through aHash[] */\n\n  assert( pWal->writeLock );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );\n  testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );\n\n  if( pWal->hdr.mxFrame==0 ) return;\n\n  /* Obtain pointers to the hash-table and page-number array containing \n  ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed\n  ** that the page said hash-table and array reside on is already mapped.\n  */\n  assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );\n  assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );\n  walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &aHash, &aPgno, &iZero);\n\n  /* Zero all hash-table entries that correspond to frame numbers greater\n  ** than pWal->hdr.mxFrame.\n  */\n  iLimit = pWal->hdr.mxFrame - iZero;\n  assert( iLimit>0 );\n  for(i=0; i<HASHTABLE_NSLOT; i++){\n    if( aHash[i]>iLimit ){\n      aHash[i] = 0;\n    }\n  }\n  \n  /* Zero the entries in the aPgno array that correspond to frames with\n  ** frame numbers greater than pWal->hdr.mxFrame. \n  */\n  nByte = (int)((char *)aHash - (char *)&aPgno[iLimit+1]);\n  memset((void *)&aPgno[iLimit+1], 0, nByte);\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* Verify that the every entry in the mapping region is still reachable\n  ** via the hash table even after the cleanup.\n  */\n  if( iLimit ){\n    int j;           /* Loop counter */\n    int iKey;        /* Hash key */\n    for(j=1; j<=iLimit; j++){\n      for(iKey=walHash(aPgno[j]); aHash[iKey]; iKey=walNextHash(iKey)){\n        if( aHash[iKey]==j ) break;\n      }\n      assert( aHash[iKey]==j );\n    }\n  }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n}\n\n\n/*\n** Set an entry in the wal-index that will map database page number\n** pPage into WAL frame iFrame.\n*/\nstatic int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){\n  int rc;                         /* Return code */\n  u32 iZero = 0;                  /* One less than frame number of aPgno[1] */\n  volatile u32 *aPgno = 0;        /* Page number array */\n  volatile ht_slot *aHash = 0;    /* Hash table */\n\n  rc = walHashGet(pWal, walFramePage(iFrame), &aHash, &aPgno, &iZero);\n\n  /* Assuming the wal-index file was successfully mapped, populate the\n  ** page number array and hash table entry.\n  */\n  if( rc==SQLITE_OK ){\n    int iKey;                     /* Hash table key */\n    int idx;                      /* Value to write to hash-table slot */\n    int nCollide;                 /* Number of hash collisions */\n\n    idx = iFrame - iZero;\n    assert( idx <= HASHTABLE_NSLOT/2 + 1 );\n    \n    /* If this is the first entry to be added to this hash-table, zero the\n    ** entire hash table and aPgno[] array before proceeding. \n    */\n    if( idx==1 ){\n      int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);\n      memset((void*)&aPgno[1], 0, nByte);\n    }\n\n    /* If the entry in aPgno[] is already set, then the previous writer\n    ** must have exited unexpectedly in the middle of a transaction (after\n    ** writing one or more dirty pages to the WAL to free up memory). \n    ** Remove the remnants of that writers uncommitted transaction from \n    ** the hash-table before writing any new entries.\n    */\n    if( aPgno[idx] ){\n      walCleanupHash(pWal);\n      assert( !aPgno[idx] );\n    }\n\n    /* Write the aPgno[] array entry and the hash-table slot. */\n    nCollide = idx;\n    for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){\n      if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT;\n    }\n    aPgno[idx] = iPage;\n    aHash[iKey] = (ht_slot)idx;\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n    /* Verify that the number of entries in the hash table exactly equals\n    ** the number of entries in the mapping region.\n    */\n    {\n      int i;           /* Loop counter */\n      int nEntry = 0;  /* Number of entries in the hash table */\n      for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i] ) nEntry++; }\n      assert( nEntry==idx );\n    }\n\n    /* Verify that the every entry in the mapping region is reachable\n    ** via the hash table.  This turns out to be a really, really expensive\n    ** thing to check, so only do this occasionally - not on every\n    ** iteration.\n    */\n    if( (idx&0x3ff)==0 ){\n      int i;           /* Loop counter */\n      for(i=1; i<=idx; i++){\n        for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){\n          if( aHash[iKey]==i ) break;\n        }\n        assert( aHash[iKey]==i );\n      }\n    }\n#endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */\n  }\n\n\n  return rc;\n}\n\n\n/*\n** Recover the wal-index by reading the write-ahead log file. \n**\n** This routine first tries to establish an exclusive lock on the\n** wal-index to prevent other threads/processes from doing anything\n** with the WAL or wal-index while recovery is running.  The\n** WAL_RECOVER_LOCK is also held so that other threads will know\n** that this thread is running recovery.  If unable to establish\n** the necessary locks, this routine returns SQLITE_BUSY.\n*/\nstatic int walIndexRecover(Wal *pWal){\n  int rc;                         /* Return Code */\n  i64 nSize;                      /* Size of log file */\n  u32 aFrameCksum[2] = {0, 0};\n  int iLock;                      /* Lock offset to lock for checkpoint */\n  int nLock;                      /* Number of locks to hold */\n\n  /* Obtain an exclusive lock on all byte in the locking range not already\n  ** locked by the caller. The caller is guaranteed to have locked the\n  ** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.\n  ** If successful, the same bytes that are locked here are unlocked before\n  ** this function returns.\n  */\n  assert( pWal->ckptLock==1 || pWal->ckptLock==0 );\n  assert( WAL_ALL_BUT_WRITE==WAL_WRITE_LOCK+1 );\n  assert( WAL_CKPT_LOCK==WAL_ALL_BUT_WRITE );\n  assert( pWal->writeLock );\n  iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;\n  nLock = SQLITE_SHM_NLOCK - iLock;\n  rc = walLockExclusive(pWal, iLock, nLock);\n  if( rc ){\n    return rc;\n  }\n  WALTRACE((\"WAL%p: recovery begin...\\n\", pWal));\n\n  memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n\n  rc = sqlite3OsFileSize(pWal->pWalFd, &nSize);\n  if( rc!=SQLITE_OK ){\n    goto recovery_error;\n  }\n\n  if( nSize>WAL_HDRSIZE ){\n    u8 aBuf[WAL_HDRSIZE];         /* Buffer to load WAL header into */\n    u8 *aFrame = 0;               /* Malloc'd buffer to load entire frame */\n    int szFrame;                  /* Number of bytes in buffer aFrame[] */\n    u8 *aData;                    /* Pointer to data part of aFrame buffer */\n    int iFrame;                   /* Index of last frame read */\n    i64 iOffset;                  /* Next offset to read from log file */\n    int szPage;                   /* Page size according to the log */\n    u32 magic;                    /* Magic value read from WAL header */\n    u32 version;                  /* Magic value read from WAL header */\n    int isValid;                  /* True if this frame is valid */\n\n    /* Read in the WAL header. */\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, WAL_HDRSIZE, 0);\n    if( rc!=SQLITE_OK ){\n      goto recovery_error;\n    }\n\n    /* If the database page size is not a power of two, or is greater than\n    ** SQLITE_MAX_PAGE_SIZE, conclude that the WAL file contains no valid \n    ** data. Similarly, if the 'magic' value is invalid, ignore the whole\n    ** WAL file.\n    */\n    magic = sqlite3Get4byte(&aBuf[0]);\n    szPage = sqlite3Get4byte(&aBuf[8]);\n    if( (magic&0xFFFFFFFE)!=WAL_MAGIC \n     || szPage&(szPage-1) \n     || szPage>SQLITE_MAX_PAGE_SIZE \n     || szPage<512 \n    ){\n      goto finished;\n    }\n    pWal->hdr.bigEndCksum = (u8)(magic&0x00000001);\n    pWal->szPage = szPage;\n    pWal->nCkpt = sqlite3Get4byte(&aBuf[12]);\n    memcpy(&pWal->hdr.aSalt, &aBuf[16], 8);\n\n    /* Verify that the WAL header checksum is correct */\n    walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, \n        aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum\n    );\n    if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24])\n     || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28])\n    ){\n      goto finished;\n    }\n\n    /* Verify that the version number on the WAL format is one that\n    ** are able to understand */\n    version = sqlite3Get4byte(&aBuf[4]);\n    if( version!=WAL_MAX_VERSION ){\n      rc = SQLITE_CANTOPEN_BKPT;\n      goto finished;\n    }\n\n    /* Malloc a buffer to read frames into. */\n    szFrame = szPage + WAL_FRAME_HDRSIZE;\n    aFrame = (u8 *)sqlite3_malloc64(szFrame);\n    if( !aFrame ){\n      rc = SQLITE_NOMEM_BKPT;\n      goto recovery_error;\n    }\n    aData = &aFrame[WAL_FRAME_HDRSIZE];\n\n    /* Read all frames from the log file. */\n    iFrame = 0;\n    for(iOffset=WAL_HDRSIZE; (iOffset+szFrame)<=nSize; iOffset+=szFrame){\n      u32 pgno;                   /* Database page number for frame */\n      u32 nTruncate;              /* dbsize field from frame header */\n\n      /* Read and decode the next log frame. */\n      iFrame++;\n      rc = sqlite3OsRead(pWal->pWalFd, aFrame, szFrame, iOffset);\n      if( rc!=SQLITE_OK ) break;\n      isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);\n      if( !isValid ) break;\n      rc = walIndexAppend(pWal, iFrame, pgno);\n      if( rc!=SQLITE_OK ) break;\n\n      /* If nTruncate is non-zero, this is a commit record. */\n      if( nTruncate ){\n        pWal->hdr.mxFrame = iFrame;\n        pWal->hdr.nPage = nTruncate;\n        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n        testcase( szPage<=32768 );\n        testcase( szPage>=65536 );\n        aFrameCksum[0] = pWal->hdr.aFrameCksum[0];\n        aFrameCksum[1] = pWal->hdr.aFrameCksum[1];\n      }\n    }\n\n    sqlite3_free(aFrame);\n  }\n\nfinished:\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo;\n    int i;\n    pWal->hdr.aFrameCksum[0] = aFrameCksum[0];\n    pWal->hdr.aFrameCksum[1] = aFrameCksum[1];\n    walIndexWriteHdr(pWal);\n\n    /* Reset the checkpoint-header. This is safe because this thread is \n    ** currently holding locks that exclude all other readers, writers and\n    ** checkpointers.\n    */\n    pInfo = walCkptInfo(pWal);\n    pInfo->nBackfill = 0;\n    pInfo->nBackfillAttempted = pWal->hdr.mxFrame;\n    pInfo->aReadMark[0] = 0;\n    for(i=1; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n    if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame;\n\n    /* If more than one frame was recovered from the log file, report an\n    ** event via sqlite3_log(). This is to help with identifying performance\n    ** problems caused by applications routinely shutting down without\n    ** checkpointing the log file.\n    */\n    if( pWal->hdr.nPage ){\n      sqlite3_log(SQLITE_NOTICE_RECOVER_WAL,\n          \"recovered %d frames from WAL file %s\",\n          pWal->hdr.mxFrame, pWal->zWalName\n      );\n    }\n  }\n\nrecovery_error:\n  WALTRACE((\"WAL%p: recovery %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  walUnlockExclusive(pWal, iLock, nLock);\n  return rc;\n}\n\n/*\n** Close an open wal-index.\n*/\nstatic void walIndexClose(Wal *pWal, int isDelete){\n  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){\n    int i;\n    for(i=0; i<pWal->nWiData; i++){\n      sqlite3_free((void *)pWal->apWiData[i]);\n      pWal->apWiData[i] = 0;\n    }\n  }else{\n    sqlite3OsShmUnmap(pWal->pDbFd, isDelete);\n  }\n}\n\n/* \n** Open a connection to the WAL file zWalName. The database file must \n** already be opened on connection pDbFd. The buffer that zWalName points\n** to must remain valid for the lifetime of the returned Wal* handle.\n**\n** A SHARED lock should be held on the database file when this function\n** is called. The purpose of this SHARED lock is to prevent any other\n** client from unlinking the WAL or wal-index file. If another process\n** were to do this just after this client opened one of these files, the\n** system would be badly broken.\n**\n** If the log file is successfully opened, SQLITE_OK is returned and \n** *ppWal is set to point to a new WAL handle. If an error occurs,\n** an SQLite error code is returned and *ppWal is left unmodified.\n*/\nint sqlite3WalOpen(\n  sqlite3_vfs *pVfs,              /* vfs module to open wal and wal-index */\n  sqlite3_file *pDbFd,            /* The open database file */\n  const char *zWalName,           /* Name of the WAL file */\n  int bNoShm,                     /* True to run in heap-memory mode */\n  i64 mxWalSize,                  /* Truncate WAL to this size on reset */\n  Wal **ppWal                     /* OUT: Allocated Wal handle */\n){\n  int rc;                         /* Return Code */\n  Wal *pRet;                      /* Object to allocate and return */\n  int flags;                      /* Flags passed to OsOpen() */\n\n  assert( zWalName && zWalName[0] );\n  assert( pDbFd );\n\n  /* In the amalgamation, the os_unix.c and os_win.c source files come before\n  ** this source file.  Verify that the #defines of the locking byte offsets\n  ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.\n  ** For that matter, if the lock offset ever changes from its initial design\n  ** value of 120, we need to know that so there is an assert() to check it.\n  */\n  assert( 120==WALINDEX_LOCK_OFFSET );\n  assert( 136==WALINDEX_HDR_SIZE );\n#ifdef WIN_SHM_BASE\n  assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n#ifdef UNIX_SHM_BASE\n  assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );\n#endif\n\n\n  /* Allocate an instance of struct Wal to return. */\n  *ppWal = 0;\n  pRet = (Wal*)sqlite3MallocZero(sizeof(Wal) + pVfs->szOsFile);\n  if( !pRet ){\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  pRet->pVfs = pVfs;\n  pRet->pWalFd = (sqlite3_file *)&pRet[1];\n  pRet->pDbFd = pDbFd;\n  pRet->readLock = -1;\n  pRet->mxWalSize = mxWalSize;\n  pRet->zWalName = zWalName;\n  pRet->syncHeader = 1;\n  pRet->padToSectorBoundary = 1;\n  pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);\n\n  /* Open file handle on the write-ahead log file. */\n  flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);\n  rc = sqlite3OsOpen(pVfs, zWalName, pRet->pWalFd, flags, &flags);\n  if( rc==SQLITE_OK && flags&SQLITE_OPEN_READONLY ){\n    pRet->readOnly = WAL_RDONLY;\n  }\n\n  if( rc!=SQLITE_OK ){\n    walIndexClose(pRet, 0);\n    sqlite3OsClose(pRet->pWalFd);\n    sqlite3_free(pRet);\n  }else{\n    int iDC = sqlite3OsDeviceCharacteristics(pDbFd);\n    if( iDC & SQLITE_IOCAP_SEQUENTIAL ){ pRet->syncHeader = 0; }\n    if( iDC & SQLITE_IOCAP_POWERSAFE_OVERWRITE ){\n      pRet->padToSectorBoundary = 0;\n    }\n    *ppWal = pRet;\n    WALTRACE((\"WAL%d: opened\\n\", pRet));\n  }\n  return rc;\n}\n\n/*\n** Change the size to which the WAL file is trucated on each reset.\n*/\nvoid sqlite3WalLimit(Wal *pWal, i64 iLimit){\n  if( pWal ) pWal->mxWalSize = iLimit;\n}\n\n/*\n** Find the smallest page number out of all pages held in the WAL that\n** has not been returned by any prior invocation of this method on the\n** same WalIterator object.   Write into *piFrame the frame index where\n** that page was last written into the WAL.  Write into *piPage the page\n** number.\n**\n** Return 0 on success.  If there are no pages in the WAL with a page\n** number larger than *piPage, then return 1.\n*/\nstatic int walIteratorNext(\n  WalIterator *p,               /* Iterator */\n  u32 *piPage,                  /* OUT: The page number of the next page */\n  u32 *piFrame                  /* OUT: Wal frame index of next page */\n){\n  u32 iMin;                     /* Result pgno must be greater than iMin */\n  u32 iRet = 0xFFFFFFFF;        /* 0xffffffff is never a valid page number */\n  int i;                        /* For looping through segments */\n\n  iMin = p->iPrior;\n  assert( iMin<0xffffffff );\n  for(i=p->nSegment-1; i>=0; i--){\n    struct WalSegment *pSegment = &p->aSegment[i];\n    while( pSegment->iNext<pSegment->nEntry ){\n      u32 iPg = pSegment->aPgno[pSegment->aIndex[pSegment->iNext]];\n      if( iPg>iMin ){\n        if( iPg<iRet ){\n          iRet = iPg;\n          *piFrame = pSegment->iZero + pSegment->aIndex[pSegment->iNext];\n        }\n        break;\n      }\n      pSegment->iNext++;\n    }\n  }\n\n  *piPage = p->iPrior = iRet;\n  return (iRet==0xFFFFFFFF);\n}\n\n/*\n** This function merges two sorted lists into a single sorted list.\n**\n** aLeft[] and aRight[] are arrays of indices.  The sort key is\n** aContent[aLeft[]] and aContent[aRight[]].  Upon entry, the following\n** is guaranteed for all J<K:\n**\n**        aContent[aLeft[J]] < aContent[aLeft[K]]\n**        aContent[aRight[J]] < aContent[aRight[K]]\n**\n** This routine overwrites aRight[] with a new (probably longer) sequence\n** of indices such that the aRight[] contains every index that appears in\n** either aLeft[] or the old aRight[] and such that the second condition\n** above is still met.\n**\n** The aContent[aLeft[X]] values will be unique for all X.  And the\n** aContent[aRight[X]] values will be unique too.  But there might be\n** one or more combinations of X and Y such that\n**\n**      aLeft[X]!=aRight[Y]  &&  aContent[aLeft[X]] == aContent[aRight[Y]]\n**\n** When that happens, omit the aLeft[X] and use the aRight[Y] index.\n*/\nstatic void walMerge(\n  const u32 *aContent,            /* Pages in wal - keys for the sort */\n  ht_slot *aLeft,                 /* IN: Left hand input list */\n  int nLeft,                      /* IN: Elements in array *paLeft */\n  ht_slot **paRight,              /* IN/OUT: Right hand input list */\n  int *pnRight,                   /* IN/OUT: Elements in *paRight */\n  ht_slot *aTmp                   /* Temporary buffer */\n){\n  int iLeft = 0;                  /* Current index in aLeft */\n  int iRight = 0;                 /* Current index in aRight */\n  int iOut = 0;                   /* Current index in output buffer */\n  int nRight = *pnRight;\n  ht_slot *aRight = *paRight;\n\n  assert( nLeft>0 && nRight>0 );\n  while( iRight<nRight || iLeft<nLeft ){\n    ht_slot logpage;\n    Pgno dbpage;\n\n    if( (iLeft<nLeft) \n     && (iRight>=nRight || aContent[aLeft[iLeft]]<aContent[aRight[iRight]])\n    ){\n      logpage = aLeft[iLeft++];\n    }else{\n      logpage = aRight[iRight++];\n    }\n    dbpage = aContent[logpage];\n\n    aTmp[iOut++] = logpage;\n    if( iLeft<nLeft && aContent[aLeft[iLeft]]==dbpage ) iLeft++;\n\n    assert( iLeft>=nLeft || aContent[aLeft[iLeft]]>dbpage );\n    assert( iRight>=nRight || aContent[aRight[iRight]]>dbpage );\n  }\n\n  *paRight = aLeft;\n  *pnRight = iOut;\n  memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut);\n}\n\n/*\n** Sort the elements in list aList using aContent[] as the sort key.\n** Remove elements with duplicate keys, preferring to keep the\n** larger aList[] values.\n**\n** The aList[] entries are indices into aContent[].  The values in\n** aList[] are to be sorted so that for all J<K:\n**\n**      aContent[aList[J]] < aContent[aList[K]]\n**\n** For any X and Y such that\n**\n**      aContent[aList[X]] == aContent[aList[Y]]\n**\n** Keep the larger of the two values aList[X] and aList[Y] and discard\n** the smaller.\n*/\nstatic void walMergesort(\n  const u32 *aContent,            /* Pages in wal */\n  ht_slot *aBuffer,               /* Buffer of at least *pnList items to use */\n  ht_slot *aList,                 /* IN/OUT: List to sort */\n  int *pnList                     /* IN/OUT: Number of elements in aList[] */\n){\n  struct Sublist {\n    int nList;                    /* Number of elements in aList */\n    ht_slot *aList;               /* Pointer to sub-list content */\n  };\n\n  const int nList = *pnList;      /* Size of input list */\n  int nMerge = 0;                 /* Number of elements in list aMerge */\n  ht_slot *aMerge = 0;            /* List to be merged */\n  int iList;                      /* Index into input list */\n  u32 iSub = 0;                   /* Index into aSub array */\n  struct Sublist aSub[13];        /* Array of sub-lists */\n\n  memset(aSub, 0, sizeof(aSub));\n  assert( nList<=HASHTABLE_NPAGE && nList>0 );\n  assert( HASHTABLE_NPAGE==(1<<(ArraySize(aSub)-1)) );\n\n  for(iList=0; iList<nList; iList++){\n    nMerge = 1;\n    aMerge = &aList[iList];\n    for(iSub=0; iList & (1<<iSub); iSub++){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->aList && p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[iList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n    aSub[iSub].aList = aMerge;\n    aSub[iSub].nList = nMerge;\n  }\n\n  for(iSub++; iSub<ArraySize(aSub); iSub++){\n    if( nList & (1<<iSub) ){\n      struct Sublist *p;\n      assert( iSub<ArraySize(aSub) );\n      p = &aSub[iSub];\n      assert( p->nList<=(1<<iSub) );\n      assert( p->aList==&aList[nList&~((2<<iSub)-1)] );\n      walMerge(aContent, p->aList, p->nList, &aMerge, &nMerge, aBuffer);\n    }\n  }\n  assert( aMerge==aList );\n  *pnList = nMerge;\n\n#ifdef SQLITE_DEBUG\n  {\n    int i;\n    for(i=1; i<*pnList; i++){\n      assert( aContent[aList[i]] > aContent[aList[i-1]] );\n    }\n  }\n#endif\n}\n\n/* \n** Free an iterator allocated by walIteratorInit().\n*/\nstatic void walIteratorFree(WalIterator *p){\n  sqlite3_free(p);\n}\n\n/*\n** Construct a WalInterator object that can be used to loop over all \n** pages in the WAL in ascending order. The caller must hold the checkpoint\n** lock.\n**\n** On success, make *pp point to the newly allocated WalInterator object\n** return SQLITE_OK. Otherwise, return an error code. If this routine\n** returns an error, the value of *pp is undefined.\n**\n** The calling routine should invoke walIteratorFree() to destroy the\n** WalIterator object when it has finished with it.\n*/\nstatic int walIteratorInit(Wal *pWal, WalIterator **pp){\n  WalIterator *p;                 /* Return value */\n  int nSegment;                   /* Number of segments to merge */\n  u32 iLast;                      /* Last frame in log */\n  int nByte;                      /* Number of bytes to allocate */\n  int i;                          /* Iterator variable */\n  ht_slot *aTmp;                  /* Temp space used by merge-sort */\n  int rc = SQLITE_OK;             /* Return Code */\n\n  /* This routine only runs while holding the checkpoint lock. And\n  ** it only runs if there is actually content in the log (mxFrame>0).\n  */\n  assert( pWal->ckptLock && pWal->hdr.mxFrame>0 );\n  iLast = pWal->hdr.mxFrame;\n\n  /* Allocate space for the WalIterator object. */\n  nSegment = walFramePage(iLast) + 1;\n  nByte = sizeof(WalIterator) \n        + (nSegment-1)*sizeof(struct WalSegment)\n        + iLast*sizeof(ht_slot);\n  p = (WalIterator *)sqlite3_malloc64(nByte);\n  if( !p ){\n    return SQLITE_NOMEM_BKPT;\n  }\n  memset(p, 0, nByte);\n  p->nSegment = nSegment;\n\n  /* Allocate temporary space used by the merge-sort routine. This block\n  ** of memory will be freed before this function returns.\n  */\n  aTmp = (ht_slot *)sqlite3_malloc64(\n      sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)\n  );\n  if( !aTmp ){\n    rc = SQLITE_NOMEM_BKPT;\n  }\n\n  for(i=0; rc==SQLITE_OK && i<nSegment; i++){\n    volatile ht_slot *aHash;\n    u32 iZero;\n    volatile u32 *aPgno;\n\n    rc = walHashGet(pWal, i, &aHash, &aPgno, &iZero);\n    if( rc==SQLITE_OK ){\n      int j;                      /* Counter variable */\n      int nEntry;                 /* Number of entries in this segment */\n      ht_slot *aIndex;            /* Sorted index for this segment */\n\n      aPgno++;\n      if( (i+1)==nSegment ){\n        nEntry = (int)(iLast - iZero);\n      }else{\n        nEntry = (int)((u32*)aHash - (u32*)aPgno);\n      }\n      aIndex = &((ht_slot *)&p->aSegment[p->nSegment])[iZero];\n      iZero++;\n  \n      for(j=0; j<nEntry; j++){\n        aIndex[j] = (ht_slot)j;\n      }\n      walMergesort((u32 *)aPgno, aTmp, aIndex, &nEntry);\n      p->aSegment[i].iZero = iZero;\n      p->aSegment[i].nEntry = nEntry;\n      p->aSegment[i].aIndex = aIndex;\n      p->aSegment[i].aPgno = (u32 *)aPgno;\n    }\n  }\n  sqlite3_free(aTmp);\n\n  if( rc!=SQLITE_OK ){\n    walIteratorFree(p);\n  }\n  *pp = p;\n  return rc;\n}\n\n/*\n** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and\n** n. If the attempt fails and parameter xBusy is not NULL, then it is a\n** busy-handler function. Invoke it and retry the lock until either the\n** lock is successfully obtained or the busy-handler returns 0.\n*/\nstatic int walBusyLock(\n  Wal *pWal,                      /* WAL connection */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int lockIdx,                    /* Offset of first byte to lock */\n  int n                           /* Number of bytes to lock */\n){\n  int rc;\n  do {\n    rc = walLockExclusive(pWal, lockIdx, n);\n  }while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );\n  return rc;\n}\n\n/*\n** The cache of the wal-index header must be valid to call this function.\n** Return the page-size in bytes used by the database.\n*/\nstatic int walPagesize(Wal *pWal){\n  return (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n}\n\n/*\n** The following is guaranteed when this function is called:\n**\n**   a) the WRITER lock is held,\n**   b) the entire log file has been checkpointed, and\n**   c) any existing readers are reading exclusively from the database\n**      file - there are no readers that may attempt to read a frame from\n**      the log file.\n**\n** This function updates the shared-memory structures so that the next\n** client to write to the database (which may be this one) does so by\n** writing frames into the start of the log file.\n**\n** The value of parameter salt1 is used as the aSalt[1] value in the \n** new wal-index header. It should be passed a pseudo-random value (i.e. \n** one obtained from sqlite3_randomness()).\n*/\nstatic void walRestartHdr(Wal *pWal, u32 salt1){\n  volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n  int i;                          /* Loop counter */\n  u32 *aSalt = pWal->hdr.aSalt;   /* Big-endian salt values */\n  pWal->nCkpt++;\n  pWal->hdr.mxFrame = 0;\n  sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));\n  memcpy(&pWal->hdr.aSalt[1], &salt1, 4);\n  walIndexWriteHdr(pWal);\n  pInfo->nBackfill = 0;\n  pInfo->nBackfillAttempted = 0;\n  pInfo->aReadMark[1] = 0;\n  for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;\n  assert( pInfo->aReadMark[0]==0 );\n}\n\n/*\n** Copy as much content as we can from the WAL back into the database file\n** in response to an sqlite3_wal_checkpoint() request or the equivalent.\n**\n** The amount of information copies from WAL to database might be limited\n** by active readers.  This routine will never overwrite a database page\n** that a concurrent reader might be using.\n**\n** All I/O barrier operations (a.k.a fsyncs) occur in this routine when\n** SQLite is in WAL-mode in synchronous=NORMAL.  That means that if \n** checkpoints are always run by a background thread or background \n** process, foreground threads will never block on a lengthy fsync call.\n**\n** Fsync is called on the WAL before writing content out of the WAL and\n** into the database.  This ensures that if the new content is persistent\n** in the WAL and can be recovered following a power-loss or hard reset.\n**\n** Fsync is also called on the database file if (and only if) the entire\n** WAL content is copied into the database file.  This second fsync makes\n** it safe to delete the WAL since the new content will persist in the\n** database file.\n**\n** This routine uses and updates the nBackfill field of the wal-index header.\n** This is the only routine that will increase the value of nBackfill.  \n** (A WAL reset or recovery will revert nBackfill to zero, but not increase\n** its value.)\n**\n** The caller must be holding sufficient locks to ensure that no other\n** checkpoint is running (in any other thread or process) at the same\n** time.\n*/\nstatic int walCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check for interrupts on this handle */\n  int eMode,                      /* One of PASSIVE, FULL or RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags for OsSync() (or 0) */\n  u8 *zBuf                        /* Temporary buffer to use */\n){\n  int rc = SQLITE_OK;             /* Return code */\n  int szPage;                     /* Database page-size */\n  WalIterator *pIter = 0;         /* Wal iterator context */\n  u32 iDbpage = 0;                /* Next database page to write */\n  u32 iFrame = 0;                 /* Wal frame containing data for iDbpage */\n  u32 mxSafeFrame;                /* Max frame that can be backfilled */\n  u32 mxPage;                     /* Max database page to write */\n  int i;                          /* Loop counter */\n  volatile WalCkptInfo *pInfo;    /* The checkpoint status information */\n\n  szPage = walPagesize(pWal);\n  testcase( szPage<=32768 );\n  testcase( szPage>=65536 );\n  pInfo = walCkptInfo(pWal);\n  if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n\n    /* Allocate the iterator */\n    rc = walIteratorInit(pWal, &pIter);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    assert( pIter );\n\n    /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n    ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n    assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n    /* Compute in mxSafeFrame the index of the last frame of the WAL that is\n    ** safe to write into the database.  Frames beyond mxSafeFrame might\n    ** overwrite database pages that are in use by active readers and thus\n    ** cannot be backfilled from the WAL.\n    */\n    mxSafeFrame = pWal->hdr.mxFrame;\n    mxPage = pWal->hdr.nPage;\n    for(i=1; i<WAL_NREADER; i++){\n      /* Thread-sanitizer reports that the following is an unsafe read,\n      ** as some other thread may be in the process of updating the value\n      ** of the aReadMark[] slot. The assumption here is that if that is\n      ** happening, the other client may only be increasing the value,\n      ** not decreasing it. So assuming either that either the \"old\" or\n      ** \"new\" version of the value is read, and not some arbitrary value\n      ** that would never be written by a real client, things are still \n      ** safe.  */\n      u32 y = pInfo->aReadMark[i];\n      if( mxSafeFrame>y ){\n        assert( y<=pWal->hdr.mxFrame );\n        rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);\n        if( rc==SQLITE_OK ){\n          pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);\n          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        }else if( rc==SQLITE_BUSY ){\n          mxSafeFrame = y;\n          xBusy = 0;\n        }else{\n          goto walcheckpoint_out;\n        }\n      }\n    }\n\n    if( pInfo->nBackfill<mxSafeFrame\n     && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK\n    ){\n      i64 nSize;                    /* Current size of database file */\n      u32 nBackfill = pInfo->nBackfill;\n\n      pInfo->nBackfillAttempted = mxSafeFrame;\n\n      /* Sync the WAL to disk */\n      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n\n      /* If the database may grow as a result of this checkpoint, hint\n      ** about the eventual size of the db file to the VFS layer.\n      */\n      if( rc==SQLITE_OK ){\n        i64 nReq = ((i64)mxPage * szPage);\n        rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);\n        if( rc==SQLITE_OK && nSize<nReq ){\n          sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);\n        }\n      }\n\n\n      /* Iterate through the contents of the WAL, copying data to the db file */\n      while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){\n        i64 iOffset;\n        assert( walFramePgno(pWal, iFrame)==iDbpage );\n        if( db->u1.isInterrupted ){\n          rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;\n          break;\n        }\n        if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){\n          continue;\n        }\n        iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;\n        /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */\n        rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n        iOffset = (iDbpage-1)*(i64)szPage;\n        testcase( IS_BIG_INT(iOffset) );\n        rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);\n        if( rc!=SQLITE_OK ) break;\n      }\n\n      /* If work was actually accomplished... */\n      if( rc==SQLITE_OK ){\n        if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){\n          i64 szDb = pWal->hdr.nPage*(i64)szPage;\n          testcase( IS_BIG_INT(szDb) );\n          rc = sqlite3OsTruncate(pWal->pDbFd, szDb);\n          if( rc==SQLITE_OK ){\n            rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));\n          }\n        }\n        if( rc==SQLITE_OK ){\n          pInfo->nBackfill = mxSafeFrame;\n        }\n      }\n\n      /* Release the reader lock held while backfilling */\n      walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);\n    }\n\n    if( rc==SQLITE_BUSY ){\n      /* Reset the return code so as not to report a checkpoint failure\n      ** just because there are active readers.  */\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the\n  ** entire wal file has been copied into the database file, then block \n  ** until all readers have finished using the wal file. This ensures that \n  ** the next process to write to the database restarts the wal file.\n  */\n  if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    assert( pWal->writeLock );\n    if( pInfo->nBackfill<pWal->hdr.mxFrame ){\n      rc = SQLITE_BUSY;\n    }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n      rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){\n          /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as\n          ** SQLITE_CHECKPOINT_RESTART with the addition that it also\n          ** truncates the log file to zero bytes just prior to a\n          ** successful return.\n          **\n          ** In theory, it might be safe to do this without updating the\n          ** wal-index header in shared memory, as all subsequent reader or\n          ** writer clients should see that the entire log file has been\n          ** checkpointed and behave accordingly. This seems unsafe though,\n          ** as it would leave the system in a state where the contents of\n          ** the wal-index header do not match the contents of the \n          ** file-system. To avoid this, update the wal-index header to\n          ** indicate that the log file contains zero valid frames.  */\n          walRestartHdr(pWal, salt1);\n          rc = sqlite3OsTruncate(pWal->pWalFd, 0);\n        }\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }\n    }\n  }\n\n walcheckpoint_out:\n  walIteratorFree(pIter);\n  return rc;\n}\n\n/*\n** If the WAL file is currently larger than nMax bytes in size, truncate\n** it to exactly nMax bytes. If an error occurs while doing so, ignore it.\n*/\nstatic void walLimitSize(Wal *pWal, i64 nMax){\n  i64 sz;\n  int rx;\n  sqlite3BeginBenignMalloc();\n  rx = sqlite3OsFileSize(pWal->pWalFd, &sz);\n  if( rx==SQLITE_OK && (sz > nMax ) ){\n    rx = sqlite3OsTruncate(pWal->pWalFd, nMax);\n  }\n  sqlite3EndBenignMalloc();\n  if( rx ){\n    sqlite3_log(rx, \"cannot limit WAL size: %s\", pWal->zWalName);\n  }\n}\n\n/*\n** Close a connection to a log file.\n*/\nint sqlite3WalClose(\n  Wal *pWal,                      /* Wal to close */\n  sqlite3 *db,                    /* For interrupt flag */\n  int sync_flags,                 /* Flags to pass to OsSync() (or 0) */\n  int nBuf,\n  u8 *zBuf                        /* Buffer of at least nBuf bytes */\n){\n  int rc = SQLITE_OK;\n  if( pWal ){\n    int isDelete = 0;             /* True to unlink wal and wal-index files */\n\n    /* If an EXCLUSIVE lock can be obtained on the database file (using the\n    ** ordinary, rollback-mode locking methods, this guarantees that the\n    ** connection associated with this log file is the only connection to\n    ** the database. In this case checkpoint the database and unlink both\n    ** the wal and wal-index files.\n    **\n    ** The EXCLUSIVE lock is not released before returning.\n    */\n    if( zBuf!=0\n     && SQLITE_OK==(rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE))\n    ){\n      if( pWal->exclusiveMode==WAL_NORMAL_MODE ){\n        pWal->exclusiveMode = WAL_EXCLUSIVE_MODE;\n      }\n      rc = sqlite3WalCheckpoint(pWal, db, \n          SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0\n      );\n      if( rc==SQLITE_OK ){\n        int bPersist = -1;\n        sqlite3OsFileControlHint(\n            pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist\n        );\n        if( bPersist!=1 ){\n          /* Try to delete the WAL file if the checkpoint completed and\n          ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal\n          ** mode (!bPersist) */\n          isDelete = 1;\n        }else if( pWal->mxWalSize>=0 ){\n          /* Try to truncate the WAL file to zero bytes if the checkpoint\n          ** completed and fsynced (rc==SQLITE_OK) and we are in persistent\n          ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a\n          ** non-negative value (pWal->mxWalSize>=0).  Note that we truncate\n          ** to zero bytes as truncating to the journal_size_limit might\n          ** leave a corrupt WAL file on disk. */\n          walLimitSize(pWal, 0);\n        }\n      }\n    }\n\n    walIndexClose(pWal, isDelete);\n    sqlite3OsClose(pWal->pWalFd);\n    if( isDelete ){\n      sqlite3BeginBenignMalloc();\n      sqlite3OsDelete(pWal->pVfs, pWal->zWalName, 0);\n      sqlite3EndBenignMalloc();\n    }\n    WALTRACE((\"WAL%p: closed\\n\", pWal));\n    sqlite3_free((void *)pWal->apWiData);\n    sqlite3_free(pWal);\n  }\n  return rc;\n}\n\n/*\n** Try to read the wal-index header.  Return 0 on success and 1 if\n** there is a problem.\n**\n** The wal-index is in shared memory.  Another thread or process might\n** be writing the header at the same time this procedure is trying to\n** read it, which might result in inconsistency.  A dirty read is detected\n** by verifying that both copies of the header are the same and also by\n** a checksum on the header.\n**\n** If and only if the read is consistent and the header is different from\n** pWal->hdr, then pWal->hdr is updated to the content of the new header\n** and *pChanged is set to 1.\n**\n** If the checksum cannot be verified return non-zero. If the header\n** is read successfully and the checksum verified, return zero.\n*/\nstatic int walIndexTryHdr(Wal *pWal, int *pChanged){\n  u32 aCksum[2];                  /* Checksum on the header content */\n  WalIndexHdr h1, h2;             /* Two copies of the header content */\n  WalIndexHdr volatile *aHdr;     /* Header in shared memory */\n\n  /* The first page of the wal-index must be mapped at this point. */\n  assert( pWal->nWiData>0 && pWal->apWiData[0] );\n\n  /* Read the header. This might happen concurrently with a write to the\n  ** same area of shared memory on a different CPU in a SMP,\n  ** meaning it is possible that an inconsistent snapshot is read\n  ** from the file. If this happens, return non-zero.\n  **\n  ** There are two copies of the header at the beginning of the wal-index.\n  ** When reading, read [0] first then [1].  Writes are in the reverse order.\n  ** Memory barriers are used to prevent the compiler or the hardware from\n  ** reordering the reads and writes.\n  */\n  aHdr = walIndexHdr(pWal);\n  memcpy(&h1, (void *)&aHdr[0], sizeof(h1));\n  walShmBarrier(pWal);\n  memcpy(&h2, (void *)&aHdr[1], sizeof(h2));\n\n  if( memcmp(&h1, &h2, sizeof(h1))!=0 ){\n    return 1;   /* Dirty read */\n  }  \n  if( h1.isInit==0 ){\n    return 1;   /* Malformed header - probably all zeros */\n  }\n  walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);\n  if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){\n    return 1;   /* Checksum does not match */\n  }\n\n  if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){\n    *pChanged = 1;\n    memcpy(&pWal->hdr, &h1, sizeof(WalIndexHdr));\n    pWal->szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);\n    testcase( pWal->szPage<=32768 );\n    testcase( pWal->szPage>=65536 );\n  }\n\n  /* The header was successfully read. Return zero. */\n  return 0;\n}\n\n/*\n** Read the wal-index header from the wal-index and into pWal->hdr.\n** If the wal-header appears to be corrupt, try to reconstruct the\n** wal-index from the WAL before returning.\n**\n** Set *pChanged to 1 if the wal-index header value in pWal->hdr is\n** changed by this operation.  If pWal->hdr is unchanged, set *pChanged\n** to 0.\n**\n** If the wal-index header is successfully read, return SQLITE_OK. \n** Otherwise an SQLite error code.\n*/\nstatic int walIndexReadHdr(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int badHdr;                     /* True if a header read failed */\n  volatile u32 *page0;            /* Chunk of wal-index containing header */\n\n  /* Ensure that page 0 of the wal-index (the page that contains the \n  ** wal-index header) is mapped. Return early if an error occurs here.\n  */\n  assert( pChanged );\n  rc = walIndexPage(pWal, 0, &page0);\n  if( rc!=SQLITE_OK ){\n    return rc;\n  };\n  assert( page0 || pWal->writeLock==0 );\n\n  /* If the first page of the wal-index has been mapped, try to read the\n  ** wal-index header immediately, without holding any lock. This usually\n  ** works, but may fail if the wal-index header is corrupt or currently \n  ** being modified by another thread or process.\n  */\n  badHdr = (page0 ? walIndexTryHdr(pWal, pChanged) : 1);\n\n  /* If the first attempt failed, it might have been due to a race\n  ** with a writer.  So get a WRITE lock and try again.\n  */\n  assert( badHdr==0 || pWal->writeLock==0 );\n  if( badHdr ){\n    if( pWal->readOnly & WAL_SHM_RDONLY ){\n      if( SQLITE_OK==(rc = walLockShared(pWal, WAL_WRITE_LOCK)) ){\n        walUnlockShared(pWal, WAL_WRITE_LOCK);\n        rc = SQLITE_READONLY_RECOVERY;\n      }\n    }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){\n      pWal->writeLock = 1;\n      if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){\n        badHdr = walIndexTryHdr(pWal, pChanged);\n        if( badHdr ){\n          /* If the wal-index header is still malformed even while holding\n          ** a WRITE lock, it can only mean that the header is corrupted and\n          ** needs to be reconstructed.  So run recovery to do exactly that.\n          */\n          rc = walIndexRecover(pWal);\n          *pChanged = 1;\n        }\n      }\n      pWal->writeLock = 0;\n      walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    }\n  }\n\n  /* If the header is read successfully, check the version number to make\n  ** sure the wal-index was not constructed with some future format that\n  ** this version of SQLite cannot understand.\n  */\n  if( badHdr==0 && pWal->hdr.iVersion!=WALINDEX_MAX_VERSION ){\n    rc = SQLITE_CANTOPEN_BKPT;\n  }\n\n  return rc;\n}\n\n/*\n** This is the value that walTryBeginRead returns when it needs to\n** be retried.\n*/\n#define WAL_RETRY  (-1)\n\n/*\n** Attempt to start a read transaction.  This might fail due to a race or\n** other transient condition.  When that happens, it returns WAL_RETRY to\n** indicate to the caller that it is safe to retry immediately.\n**\n** On success return SQLITE_OK.  On a permanent failure (such an\n** I/O error or an SQLITE_BUSY because another process is running\n** recovery) return a positive error code.\n**\n** The useWal parameter is true to force the use of the WAL and disable\n** the case where the WAL is bypassed because it has been completely\n** checkpointed.  If useWal==0 then this routine calls walIndexReadHdr() \n** to make a copy of the wal-index header into pWal->hdr.  If the \n** wal-index header has changed, *pChanged is set to 1 (as an indication \n** to the caller that the local paget cache is obsolete and needs to be \n** flushed.)  When useWal==1, the wal-index header is assumed to already\n** be loaded and the pChanged parameter is unused.\n**\n** The caller must set the cnt parameter to the number of prior calls to\n** this routine during the current read attempt that returned WAL_RETRY.\n** This routine will start taking more aggressive measures to clear the\n** race conditions after multiple WAL_RETRY returns, and after an excessive\n** number of errors will ultimately return SQLITE_PROTOCOL.  The\n** SQLITE_PROTOCOL return indicates that some other process has gone rogue\n** and is not honoring the locking protocol.  There is a vanishingly small\n** chance that SQLITE_PROTOCOL could be returned because of a run of really\n** bad luck when there is lots of contention for the wal-index, but that\n** possibility is so small that it can be safely neglected, we believe.\n**\n** On success, this routine obtains a read lock on \n** WAL_READ_LOCK(pWal->readLock).  The pWal->readLock integer is\n** in the range 0 <= pWal->readLock < WAL_NREADER.  If pWal->readLock==(-1)\n** that means the Wal does not hold any read lock.  The reader must not\n** access any database page that is modified by a WAL frame up to and\n** including frame number aReadMark[pWal->readLock].  The reader will\n** use WAL frames up to and including pWal->hdr.mxFrame if pWal->readLock>0\n** Or if pWal->readLock==0, then the reader will ignore the WAL\n** completely and get all content directly from the database file.\n** If the useWal parameter is 1 then the WAL will never be ignored and\n** this routine will always set pWal->readLock>0 on success.\n** When the read transaction is completed, the caller must release the\n** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.\n**\n** This routine uses the nBackfill and aReadMark[] fields of the header\n** to select a particular WAL_READ_LOCK() that strives to let the\n** checkpoint process do as much work as possible.  This routine might\n** update values of the aReadMark[] array in the header, but if it does\n** so it takes care to hold an exclusive lock on the corresponding\n** WAL_READ_LOCK() while changing values.\n*/\nstatic int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){\n  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */\n  u32 mxReadMark;                 /* Largest aReadMark[] value */\n  int mxI;                        /* Index of largest aReadMark[] value */\n  int i;                          /* Loop counter */\n  int rc = SQLITE_OK;             /* Return code  */\n  u32 mxFrame;                    /* Wal frame to lock to */\n\n  assert( pWal->readLock<0 );     /* Not currently locked */\n\n  /* Take steps to avoid spinning forever if there is a protocol error.\n  **\n  ** Circumstances that cause a RETRY should only last for the briefest\n  ** instances of time.  No I/O or other system calls are done while the\n  ** locks are held, so the locks should not be held for very long. But \n  ** if we are unlucky, another process that is holding a lock might get\n  ** paged out or take a page-fault that is time-consuming to resolve, \n  ** during the few nanoseconds that it is holding the lock.  In that case,\n  ** it might take longer than normal for the lock to free.\n  **\n  ** After 5 RETRYs, we begin calling sqlite3OsSleep().  The first few\n  ** calls to sqlite3OsSleep() have a delay of 1 microsecond.  Really this\n  ** is more of a scheduler yield than an actual delay.  But on the 10th\n  ** an subsequent retries, the delays start becoming longer and longer, \n  ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.\n  ** The total delay time before giving up is less than 10 seconds.\n  */\n  if( cnt>5 ){\n    int nDelay = 1;                      /* Pause time in microseconds */\n    if( cnt>100 ){\n      VVA_ONLY( pWal->lockError = 1; )\n      return SQLITE_PROTOCOL;\n    }\n    if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;\n    sqlite3OsSleep(pWal->pVfs, nDelay);\n  }\n\n  if( !useWal ){\n    rc = walIndexReadHdr(pWal, pChanged);\n    if( rc==SQLITE_BUSY ){\n      /* If there is not a recovery running in another thread or process\n      ** then convert BUSY errors to WAL_RETRY.  If recovery is known to\n      ** be running, convert BUSY to BUSY_RECOVERY.  There is a race here\n      ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY\n      ** would be technically correct.  But the race is benign since with\n      ** WAL_RETRY this routine will be called again and will probably be\n      ** right on the second iteration.\n      */\n      if( pWal->apWiData[0]==0 ){\n        /* This branch is taken when the xShmMap() method returns SQLITE_BUSY.\n        ** We assume this is a transient condition, so return WAL_RETRY. The\n        ** xShmMap() implementation used by the default unix and win32 VFS \n        ** modules may return SQLITE_BUSY due to a race condition in the \n        ** code that determines whether or not the shared-memory region \n        ** must be zeroed before the requested page is returned.\n        */\n        rc = WAL_RETRY;\n      }else if( SQLITE_OK==(rc = walLockShared(pWal, WAL_RECOVER_LOCK)) ){\n        walUnlockShared(pWal, WAL_RECOVER_LOCK);\n        rc = WAL_RETRY;\n      }else if( rc==SQLITE_BUSY ){\n        rc = SQLITE_BUSY_RECOVERY;\n      }\n    }\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n  }\n\n  pInfo = walCkptInfo(pWal);\n  if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame \n#ifdef SQLITE_ENABLE_SNAPSHOT\n   && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0\n     || 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr)))\n#endif\n  ){\n    /* The WAL has been completely backfilled (or it is empty).\n    ** and can be safely ignored.\n    */\n    rc = walLockShared(pWal, WAL_READ_LOCK(0));\n    walShmBarrier(pWal);\n    if( rc==SQLITE_OK ){\n      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){\n        /* It is not safe to allow the reader to continue here if frames\n        ** may have been appended to the log before READ_LOCK(0) was obtained.\n        ** When holding READ_LOCK(0), the reader ignores the entire log file,\n        ** which implies that the database file contains a trustworthy\n        ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from\n        ** happening, this is usually correct.\n        **\n        ** However, if frames have been appended to the log (or if the log \n        ** is wrapped and written for that matter) before the READ_LOCK(0)\n        ** is obtained, that is not necessarily true. A checkpointer may\n        ** have started to backfill the appended frames but crashed before\n        ** it finished. Leaving a corrupt image in the database file.\n        */\n        walUnlockShared(pWal, WAL_READ_LOCK(0));\n        return WAL_RETRY;\n      }\n      pWal->readLock = 0;\n      return SQLITE_OK;\n    }else if( rc!=SQLITE_BUSY ){\n      return rc;\n    }\n  }\n\n  /* If we get this far, it means that the reader will want to use\n  ** the WAL to get at content from recent commits.  The job now is\n  ** to select one of the aReadMark[] entries that is closest to\n  ** but not exceeding pWal->hdr.mxFrame and lock that entry.\n  */\n  mxReadMark = 0;\n  mxI = 0;\n  mxFrame = pWal->hdr.mxFrame;\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){\n    mxFrame = pWal->pSnapshot->mxFrame;\n  }\n#endif\n  for(i=1; i<WAL_NREADER; i++){\n    u32 thisMark = pInfo->aReadMark[i];\n    if( mxReadMark<=thisMark && thisMark<=mxFrame ){\n      assert( thisMark!=READMARK_NOT_USED );\n      mxReadMark = thisMark;\n      mxI = i;\n    }\n  }\n  if( (pWal->readOnly & WAL_SHM_RDONLY)==0\n   && (mxReadMark<mxFrame || mxI==0)\n  ){\n    for(i=1; i<WAL_NREADER; i++){\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);\n      if( rc==SQLITE_OK ){\n        mxReadMark = pInfo->aReadMark[i] = mxFrame;\n        mxI = i;\n        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);\n        break;\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n  }\n  if( mxI==0 ){\n    assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );\n    return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTLOCK;\n  }\n\n  rc = walLockShared(pWal, WAL_READ_LOCK(mxI));\n  if( rc ){\n    return rc==SQLITE_BUSY ? WAL_RETRY : rc;\n  }\n  /* Now that the read-lock has been obtained, check that neither the\n  ** value in the aReadMark[] array or the contents of the wal-index\n  ** header have changed.\n  **\n  ** It is necessary to check that the wal-index header did not change\n  ** between the time it was read and when the shared-lock was obtained\n  ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility\n  ** that the log file may have been wrapped by a writer, or that frames\n  ** that occur later in the log than pWal->hdr.mxFrame may have been\n  ** copied into the database by a checkpointer. If either of these things\n  ** happened, then reading the database with the current value of\n  ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry\n  ** instead.\n  **\n  ** Before checking that the live wal-index header has not changed\n  ** since it was read, set Wal.minFrame to the first frame in the wal\n  ** file that has not yet been checkpointed. This client will not need\n  ** to read any frames earlier than minFrame from the wal file - they\n  ** can be safely read directly from the database file.\n  **\n  ** Because a ShmBarrier() call is made between taking the copy of \n  ** nBackfill and checking that the wal-header in shared-memory still\n  ** matches the one cached in pWal->hdr, it is guaranteed that the \n  ** checkpointer that set nBackfill was not working with a wal-index\n  ** header newer than that cached in pWal->hdr. If it were, that could\n  ** cause a problem. The checkpointer could omit to checkpoint\n  ** a version of page X that lies before pWal->minFrame (call that version\n  ** A) on the basis that there is a newer version (version B) of the same\n  ** page later in the wal file. But if version B happens to like past\n  ** frame pWal->hdr.mxFrame - then the client would incorrectly assume\n  ** that it can read version A from the database file. However, since\n  ** we can guarantee that the checkpointer that set nBackfill could not\n  ** see any pages past pWal->hdr.mxFrame, this problem does not come up.\n  */\n  pWal->minFrame = pInfo->nBackfill+1;\n  walShmBarrier(pWal);\n  if( pInfo->aReadMark[mxI]!=mxReadMark\n   || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))\n  ){\n    walUnlockShared(pWal, WAL_READ_LOCK(mxI));\n    return WAL_RETRY;\n  }else{\n    assert( mxReadMark<=pWal->hdr.mxFrame );\n    pWal->readLock = (i16)mxI;\n  }\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/*\n** Attempt to reduce the value of the WalCkptInfo.nBackfillAttempted \n** variable so that older snapshots can be accessed. To do this, loop\n** through all wal frames from nBackfillAttempted to (nBackfill+1), \n** comparing their content to the corresponding page with the database\n** file, if any. Set nBackfillAttempted to the frame number of the\n** first frame for which the wal file content matches the db file.\n**\n** This is only really safe if the file-system is such that any page \n** writes made by earlier checkpointers were atomic operations, which \n** is not always true. It is also possible that nBackfillAttempted\n** may be left set to a value larger than expected, if a wal frame\n** contains content that duplicate of an earlier version of the same\n** page.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code if an\n** error occurs. It is not an error if nBackfillAttempted cannot be\n** decreased at all.\n*/\nint sqlite3WalSnapshotRecover(Wal *pWal){\n  int rc;\n\n  assert( pWal->readLock>=0 );\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc==SQLITE_OK ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    int szPage = (int)pWal->szPage;\n    i64 szDb;                   /* Size of db file in bytes */\n\n    rc = sqlite3OsFileSize(pWal->pDbFd, &szDb);\n    if( rc==SQLITE_OK ){\n      void *pBuf1 = sqlite3_malloc(szPage);\n      void *pBuf2 = sqlite3_malloc(szPage);\n      if( pBuf1==0 || pBuf2==0 ){\n        rc = SQLITE_NOMEM;\n      }else{\n        u32 i = pInfo->nBackfillAttempted;\n        for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){\n          volatile ht_slot *dummy;\n          volatile u32 *aPgno;      /* Array of page numbers */\n          u32 iZero;                /* Frame corresponding to aPgno[0] */\n          u32 pgno;                 /* Page number in db file */\n          i64 iDbOff;               /* Offset of db file entry */\n          i64 iWalOff;              /* Offset of wal file entry */\n\n          rc = walHashGet(pWal, walFramePage(i), &dummy, &aPgno, &iZero);\n          if( rc!=SQLITE_OK ) break;\n          pgno = aPgno[i-iZero];\n          iDbOff = (i64)(pgno-1) * szPage;\n\n          if( iDbOff+szPage<=szDb ){\n            iWalOff = walFrameOffset(i, szPage) + WAL_FRAME_HDRSIZE;\n            rc = sqlite3OsRead(pWal->pWalFd, pBuf1, szPage, iWalOff);\n\n            if( rc==SQLITE_OK ){\n              rc = sqlite3OsRead(pWal->pDbFd, pBuf2, szPage, iDbOff);\n            }\n\n            if( rc!=SQLITE_OK || 0==memcmp(pBuf1, pBuf2, szPage) ){\n              break;\n            }\n          }\n\n          pInfo->nBackfillAttempted = i-1;\n        }\n      }\n\n      sqlite3_free(pBuf1);\n      sqlite3_free(pBuf2);\n    }\n    walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  }\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n/*\n** Begin a read transaction on the database.\n**\n** This routine used to be called sqlite3OpenSnapshot() and with good reason:\n** it takes a snapshot of the state of the WAL and wal-index for the current\n** instant in time.  The current thread will continue to use this snapshot.\n** Other threads might append new content to the WAL and wal-index but\n** that extra content is ignored by the current thread.\n**\n** If the database contents have changes since the previous read\n** transaction, then *pChanged is set to 1 before returning.  The\n** Pager layer will use this to know that is cache is stale and\n** needs to be flushed.\n*/\nint sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){\n  int rc;                         /* Return code */\n  int cnt = 0;                    /* Number of TryBeginRead attempts */\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  int bChanged = 0;\n  WalIndexHdr *pSnapshot = pWal->pSnapshot;\n  if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n    bChanged = 1;\n  }\n#endif\n\n  do{\n    rc = walTryBeginRead(pWal, pChanged, 0, ++cnt);\n  }while( rc==WAL_RETRY );\n  testcase( (rc&0xff)==SQLITE_BUSY );\n  testcase( (rc&0xff)==SQLITE_IOERR );\n  testcase( rc==SQLITE_PROTOCOL );\n  testcase( rc==SQLITE_OK );\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n  if( rc==SQLITE_OK ){\n    if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){\n      /* At this point the client has a lock on an aReadMark[] slot holding\n      ** a value equal to or smaller than pSnapshot->mxFrame, but pWal->hdr\n      ** is populated with the wal-index header corresponding to the head\n      ** of the wal file. Verify that pSnapshot is still valid before\n      ** continuing.  Reasons why pSnapshot might no longer be valid:\n      **\n      **    (1)  The WAL file has been reset since the snapshot was taken.\n      **         In this case, the salt will have changed.\n      **\n      **    (2)  A checkpoint as been attempted that wrote frames past\n      **         pSnapshot->mxFrame into the database file.  Note that the\n      **         checkpoint need not have completed for this to cause problems.\n      */\n      volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n\n      assert( pWal->readLock>0 || pWal->hdr.mxFrame==0 );\n      assert( pInfo->aReadMark[pWal->readLock]<=pSnapshot->mxFrame );\n\n      /* It is possible that there is a checkpointer thread running \n      ** concurrent with this code. If this is the case, it may be that the\n      ** checkpointer has already determined that it will checkpoint \n      ** snapshot X, where X is later in the wal file than pSnapshot, but \n      ** has not yet set the pInfo->nBackfillAttempted variable to indicate \n      ** its intent. To avoid the race condition this leads to, ensure that\n      ** there is no checkpointer process by taking a shared CKPT lock \n      ** before checking pInfo->nBackfillAttempted.  \n      **\n      ** TODO: Does the aReadMark[] lock prevent a checkpointer from doing\n      **       this already?\n      */\n      rc = walLockShared(pWal, WAL_CKPT_LOCK);\n\n      if( rc==SQLITE_OK ){\n        /* Check that the wal file has not been wrapped. Assuming that it has\n        ** not, also check that no checkpointer has attempted to checkpoint any\n        ** frames beyond pSnapshot->mxFrame. If either of these conditions are\n        ** true, return SQLITE_BUSY_SNAPSHOT. Otherwise, overwrite pWal->hdr\n        ** with *pSnapshot and set *pChanged as appropriate for opening the\n        ** snapshot.  */\n        if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))\n         && pSnapshot->mxFrame>=pInfo->nBackfillAttempted\n        ){\n          assert( pWal->readLock>0 );\n          memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));\n          *pChanged = bChanged;\n        }else{\n          rc = SQLITE_BUSY_SNAPSHOT;\n        }\n\n        /* Release the shared CKPT lock obtained above. */\n        walUnlockShared(pWal, WAL_CKPT_LOCK);\n      }\n\n\n      if( rc!=SQLITE_OK ){\n        sqlite3WalEndReadTransaction(pWal);\n      }\n    }\n  }\n#endif\n  return rc;\n}\n\n/*\n** Finish with a read transaction.  All this does is release the\n** read-lock.\n*/\nvoid sqlite3WalEndReadTransaction(Wal *pWal){\n  sqlite3WalEndWriteTransaction(pWal);\n  if( pWal->readLock>=0 ){\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->readLock = -1;\n  }\n}\n\n/*\n** Search the wal file for page pgno. If found, set *piRead to the frame that\n** contains the page. Otherwise, if pgno is not in the wal file, set *piRead\n** to zero.\n**\n** Return SQLITE_OK if successful, or an error code if an error occurs. If an\n** error does occur, the final value of *piRead is undefined.\n*/\nint sqlite3WalFindFrame(\n  Wal *pWal,                      /* WAL handle */\n  Pgno pgno,                      /* Database page number to read data for */\n  u32 *piRead                     /* OUT: Frame number (or zero) */\n){\n  u32 iRead = 0;                  /* If !=0, WAL frame to return data from */\n  u32 iLast = pWal->hdr.mxFrame;  /* Last page in WAL for this reader */\n  int iHash;                      /* Used to loop through N hash tables */\n  int iMinHash;\n\n  /* This routine is only be called from within a read transaction. */\n  assert( pWal->readLock>=0 || pWal->lockError );\n\n  /* If the \"last page\" field of the wal-index header snapshot is 0, then\n  ** no data will be read from the wal under any circumstances. Return early\n  ** in this case as an optimization.  Likewise, if pWal->readLock==0, \n  ** then the WAL is ignored by the reader so return early, as if the \n  ** WAL were empty.\n  */\n  if( iLast==0 || pWal->readLock==0 ){\n    *piRead = 0;\n    return SQLITE_OK;\n  }\n\n  /* Search the hash table or tables for an entry matching page number\n  ** pgno. Each iteration of the following for() loop searches one\n  ** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).\n  **\n  ** This code might run concurrently to the code in walIndexAppend()\n  ** that adds entries to the wal-index (and possibly to this hash \n  ** table). This means the value just read from the hash \n  ** slot (aHash[iKey]) may have been added before or after the \n  ** current read transaction was opened. Values added after the\n  ** read transaction was opened may have been written incorrectly -\n  ** i.e. these slots may contain garbage data. However, we assume\n  ** that any slots written before the current read transaction was\n  ** opened remain unmodified.\n  **\n  ** For the reasons above, the if(...) condition featured in the inner\n  ** loop of the following block is more stringent that would be required \n  ** if we had exclusive access to the hash-table:\n  **\n  **   (aPgno[iFrame]==pgno): \n  **     This condition filters out normal hash-table collisions.\n  **\n  **   (iFrame<=iLast): \n  **     This condition filters out entries that were added to the hash\n  **     table after the current read-transaction had started.\n  */\n  iMinHash = walFramePage(pWal->minFrame);\n  for(iHash=walFramePage(iLast); iHash>=iMinHash && iRead==0; iHash--){\n    volatile ht_slot *aHash;      /* Pointer to hash table */\n    volatile u32 *aPgno;          /* Pointer to array of page numbers */\n    u32 iZero;                    /* Frame number corresponding to aPgno[0] */\n    int iKey;                     /* Hash slot index */\n    int nCollide;                 /* Number of hash collisions remaining */\n    int rc;                       /* Error code */\n\n    rc = walHashGet(pWal, iHash, &aHash, &aPgno, &iZero);\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n    nCollide = HASHTABLE_NSLOT;\n    for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){\n      u32 iFrame = aHash[iKey] + iZero;\n      if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){\n        assert( iFrame>iRead || CORRUPT_DB );\n        iRead = iFrame;\n      }\n      if( (nCollide--)==0 ){\n        return SQLITE_CORRUPT_BKPT;\n      }\n    }\n  }\n\n#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT\n  /* If expensive assert() statements are available, do a linear search\n  ** of the wal-index file content. Make sure the results agree with the\n  ** result obtained using the hash indexes above.  */\n  {\n    u32 iRead2 = 0;\n    u32 iTest;\n    assert( pWal->minFrame>0 );\n    for(iTest=iLast; iTest>=pWal->minFrame; iTest--){\n      if( walFramePgno(pWal, iTest)==pgno ){\n        iRead2 = iTest;\n        break;\n      }\n    }\n    assert( iRead==iRead2 );\n  }\n#endif\n\n  *piRead = iRead;\n  return SQLITE_OK;\n}\n\n/*\n** Read the contents of frame iRead from the wal file into buffer pOut\n** (which is nOut bytes in size). Return SQLITE_OK if successful, or an\n** error code otherwise.\n*/\nint sqlite3WalReadFrame(\n  Wal *pWal,                      /* WAL handle */\n  u32 iRead,                      /* Frame to read */\n  int nOut,                       /* Size of buffer pOut in bytes */\n  u8 *pOut                        /* Buffer to write page data to */\n){\n  int sz;\n  i64 iOffset;\n  sz = pWal->hdr.szPage;\n  sz = (sz&0xfe00) + ((sz&0x0001)<<16);\n  testcase( sz<=32768 );\n  testcase( sz>=65536 );\n  iOffset = walFrameOffset(iRead, sz) + WAL_FRAME_HDRSIZE;\n  /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL */\n  return sqlite3OsRead(pWal->pWalFd, pOut, (nOut>sz ? sz : nOut), iOffset);\n}\n\n/* \n** Return the size of the database in pages (or zero, if unknown).\n*/\nPgno sqlite3WalDbsize(Wal *pWal){\n  if( pWal && ALWAYS(pWal->readLock>=0) ){\n    return pWal->hdr.nPage;\n  }\n  return 0;\n}\n\n\n/* \n** This function starts a write transaction on the WAL.\n**\n** A read transaction must have already been started by a prior call\n** to sqlite3WalBeginReadTransaction().\n**\n** If another thread or process has written into the database since\n** the read transaction was started, then it is not possible for this\n** thread to write as doing so would cause a fork.  So this routine\n** returns SQLITE_BUSY in that case and no write transaction is started.\n**\n** There can only be a single writer active at a time.\n*/\nint sqlite3WalBeginWriteTransaction(Wal *pWal){\n  int rc;\n\n  /* Cannot start a write transaction without first holding a read\n  ** transaction. */\n  assert( pWal->readLock>=0 );\n  assert( pWal->writeLock==0 && pWal->iReCksum==0 );\n\n  if( pWal->readOnly ){\n    return SQLITE_READONLY;\n  }\n\n  /* Only one writer allowed at a time.  Get the write lock.  Return\n  ** SQLITE_BUSY if unable.\n  */\n  rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);\n  if( rc ){\n    return rc;\n  }\n  pWal->writeLock = 1;\n\n  /* If another connection has written to the database file since the\n  ** time the read transaction on this connection was started, then\n  ** the write is disallowed.\n  */\n  if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    rc = SQLITE_BUSY_SNAPSHOT;\n  }\n\n  return rc;\n}\n\n/*\n** End a write transaction.  The commit has already been done.  This\n** routine merely releases the lock.\n*/\nint sqlite3WalEndWriteTransaction(Wal *pWal){\n  if( pWal->writeLock ){\n    walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);\n    pWal->writeLock = 0;\n    pWal->iReCksum = 0;\n    pWal->truncateOnCommit = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** If any data has been written (but not committed) to the log file, this\n** function moves the write-pointer back to the start of the transaction.\n**\n** Additionally, the callback function is invoked for each frame written\n** to the WAL since the start of the transaction. If the callback returns\n** other than SQLITE_OK, it is not invoked again and the error code is\n** returned to the caller.\n**\n** Otherwise, if the callback function does not return an error, this\n** function returns SQLITE_OK.\n*/\nint sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){\n  int rc = SQLITE_OK;\n  if( ALWAYS(pWal->writeLock) ){\n    Pgno iMax = pWal->hdr.mxFrame;\n    Pgno iFrame;\n  \n    /* Restore the clients cache of the wal-index header to the state it\n    ** was in before the client began writing to the database. \n    */\n    memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));\n\n    for(iFrame=pWal->hdr.mxFrame+1; \n        ALWAYS(rc==SQLITE_OK) && iFrame<=iMax; \n        iFrame++\n    ){\n      /* This call cannot fail. Unless the page for which the page number\n      ** is passed as the second argument is (a) in the cache and \n      ** (b) has an outstanding reference, then xUndo is either a no-op\n      ** (if (a) is false) or simply expels the page from the cache (if (b)\n      ** is false).\n      **\n      ** If the upper layer is doing a rollback, it is guaranteed that there\n      ** are no outstanding references to any page other than page 1. And\n      ** page 1 is never written to the log until the transaction is\n      ** committed. As a result, the call to xUndo may not fail.\n      */\n      assert( walFramePgno(pWal, iFrame)!=1 );\n      rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));\n    }\n    if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);\n  }\n  return rc;\n}\n\n/* \n** Argument aWalData must point to an array of WAL_SAVEPOINT_NDATA u32 \n** values. This function populates the array with values required to \n** \"rollback\" the write position of the WAL handle back to the current \n** point in the event of a savepoint rollback (via WalSavepointUndo()).\n*/\nvoid sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){\n  assert( pWal->writeLock );\n  aWalData[0] = pWal->hdr.mxFrame;\n  aWalData[1] = pWal->hdr.aFrameCksum[0];\n  aWalData[2] = pWal->hdr.aFrameCksum[1];\n  aWalData[3] = pWal->nCkpt;\n}\n\n/* \n** Move the write position of the WAL back to the point identified by\n** the values in the aWalData[] array. aWalData must point to an array\n** of WAL_SAVEPOINT_NDATA u32 values that has been previously populated\n** by a call to WalSavepoint().\n*/\nint sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){\n  int rc = SQLITE_OK;\n\n  assert( pWal->writeLock );\n  assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );\n\n  if( aWalData[3]!=pWal->nCkpt ){\n    /* This savepoint was opened immediately after the write-transaction\n    ** was started. Right after that, the writer decided to wrap around\n    ** to the start of the log. Update the savepoint values to match.\n    */\n    aWalData[0] = 0;\n    aWalData[3] = pWal->nCkpt;\n  }\n\n  if( aWalData[0]<pWal->hdr.mxFrame ){\n    pWal->hdr.mxFrame = aWalData[0];\n    pWal->hdr.aFrameCksum[0] = aWalData[1];\n    pWal->hdr.aFrameCksum[1] = aWalData[2];\n    walCleanupHash(pWal);\n  }\n\n  return rc;\n}\n\n/*\n** This function is called just before writing a set of frames to the log\n** file (see sqlite3WalFrames()). It checks to see if, instead of appending\n** to the current log file, it is possible to overwrite the start of the\n** existing log file with the new frames (i.e. \"reset\" the log). If so,\n** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left\n** unchanged.\n**\n** SQLITE_OK is returned if no error is encountered (regardless of whether\n** or not pWal->hdr.mxFrame is modified). An SQLite error code is returned\n** if an error occurs.\n*/\nstatic int walRestartLog(Wal *pWal){\n  int rc = SQLITE_OK;\n  int cnt;\n\n  if( pWal->readLock==0 ){\n    volatile WalCkptInfo *pInfo = walCkptInfo(pWal);\n    assert( pInfo->nBackfill==pWal->hdr.mxFrame );\n    if( pInfo->nBackfill>0 ){\n      u32 salt1;\n      sqlite3_randomness(4, &salt1);\n      rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      if( rc==SQLITE_OK ){\n        /* If all readers are using WAL_READ_LOCK(0) (in other words if no\n        ** readers are currently using the WAL), then the transactions\n        ** frames will overwrite the start of the existing log. Update the\n        ** wal-index header to reflect this.\n        **\n        ** In theory it would be Ok to update the cache of the header only\n        ** at this point. But updating the actual wal-index header is also\n        ** safe and means there is no special case for sqlite3WalUndo()\n        ** to handle if this transaction is rolled back.  */\n        walRestartHdr(pWal, salt1);\n        walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);\n      }else if( rc!=SQLITE_BUSY ){\n        return rc;\n      }\n    }\n    walUnlockShared(pWal, WAL_READ_LOCK(0));\n    pWal->readLock = -1;\n    cnt = 0;\n    do{\n      int notUsed;\n      rc = walTryBeginRead(pWal, &notUsed, 1, ++cnt);\n    }while( rc==WAL_RETRY );\n    assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */\n    testcase( (rc&0xff)==SQLITE_IOERR );\n    testcase( rc==SQLITE_PROTOCOL );\n    testcase( rc==SQLITE_OK );\n  }\n  return rc;\n}\n\n/*\n** Information about the current state of the WAL file and where\n** the next fsync should occur - passed from sqlite3WalFrames() into\n** walWriteToLog().\n*/\ntypedef struct WalWriter {\n  Wal *pWal;                   /* The complete WAL information */\n  sqlite3_file *pFd;           /* The WAL file to which we write */\n  sqlite3_int64 iSyncPoint;    /* Fsync at this offset */\n  int syncFlags;               /* Flags for the fsync */\n  int szPage;                  /* Size of one page */\n} WalWriter;\n\n/*\n** Write iAmt bytes of content into the WAL file beginning at iOffset.\n** Do a sync when crossing the p->iSyncPoint boundary.\n**\n** In other words, if iSyncPoint is in between iOffset and iOffset+iAmt,\n** first write the part before iSyncPoint, then sync, then write the\n** rest.\n*/\nstatic int walWriteToLog(\n  WalWriter *p,              /* WAL to write to */\n  void *pContent,            /* Content to be written */\n  int iAmt,                  /* Number of bytes to write */\n  sqlite3_int64 iOffset      /* Start writing at this offset */\n){\n  int rc;\n  if( iOffset<p->iSyncPoint && iOffset+iAmt>=p->iSyncPoint ){\n    int iFirstAmt = (int)(p->iSyncPoint - iOffset);\n    rc = sqlite3OsWrite(p->pFd, pContent, iFirstAmt, iOffset);\n    if( rc ) return rc;\n    iOffset += iFirstAmt;\n    iAmt -= iFirstAmt;\n    pContent = (void*)(iFirstAmt + (char*)pContent);\n    assert( WAL_SYNC_FLAGS(p->syncFlags)!=0 );\n    rc = sqlite3OsSync(p->pFd, WAL_SYNC_FLAGS(p->syncFlags));\n    if( iAmt==0 || rc ) return rc;\n  }\n  rc = sqlite3OsWrite(p->pFd, pContent, iAmt, iOffset);\n  return rc;\n}\n\n/*\n** Write out a single frame of the WAL\n*/\nstatic int walWriteOneFrame(\n  WalWriter *p,               /* Where to write the frame */\n  PgHdr *pPage,               /* The page of the frame to be written */\n  int nTruncate,              /* The commit flag.  Usually 0.  >0 for commit */\n  sqlite3_int64 iOffset       /* Byte offset at which to write */\n){\n  int rc;                         /* Result code from subfunctions */\n  void *pData;                    /* Data actually written */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-header in */\n#if defined(SQLITE_HAS_CODEC)\n  if( (pData = sqlite3PagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;\n#else\n  pData = pPage->pData;\n#endif\n  walEncodeFrame(p->pWal, pPage->pgno, nTruncate, pData, aFrame);\n  rc = walWriteToLog(p, aFrame, sizeof(aFrame), iOffset);\n  if( rc ) return rc;\n  /* Write the page data */\n  rc = walWriteToLog(p, pData, p->szPage, iOffset+sizeof(aFrame));\n  return rc;\n}\n\n/*\n** This function is called as part of committing a transaction within which\n** one or more frames have been overwritten. It updates the checksums for\n** all frames written to the wal file by the current transaction starting\n** with the earliest to have been overwritten.\n**\n** SQLITE_OK is returned if successful, or an SQLite error code otherwise.\n*/\nstatic int walRewriteChecksums(Wal *pWal, u32 iLast){\n  const int szPage = pWal->szPage;/* Database page size */\n  int rc = SQLITE_OK;             /* Return code */\n  u8 *aBuf;                       /* Buffer to load data from wal file into */\n  u8 aFrame[WAL_FRAME_HDRSIZE];   /* Buffer to assemble frame-headers in */\n  u32 iRead;                      /* Next frame to read from wal file */\n  i64 iCksumOff;\n\n  aBuf = sqlite3_malloc(szPage + WAL_FRAME_HDRSIZE);\n  if( aBuf==0 ) return SQLITE_NOMEM_BKPT;\n\n  /* Find the checksum values to use as input for the recalculating the\n  ** first checksum. If the first frame is frame 1 (implying that the current\n  ** transaction restarted the wal file), these values must be read from the\n  ** wal-file header. Otherwise, read them from the frame header of the\n  ** previous frame.  */\n  assert( pWal->iReCksum>0 );\n  if( pWal->iReCksum==1 ){\n    iCksumOff = 24;\n  }else{\n    iCksumOff = walFrameOffset(pWal->iReCksum-1, szPage) + 16;\n  }\n  rc = sqlite3OsRead(pWal->pWalFd, aBuf, sizeof(u32)*2, iCksumOff);\n  pWal->hdr.aFrameCksum[0] = sqlite3Get4byte(aBuf);\n  pWal->hdr.aFrameCksum[1] = sqlite3Get4byte(&aBuf[sizeof(u32)]);\n\n  iRead = pWal->iReCksum;\n  pWal->iReCksum = 0;\n  for(; rc==SQLITE_OK && iRead<=iLast; iRead++){\n    i64 iOff = walFrameOffset(iRead, szPage);\n    rc = sqlite3OsRead(pWal->pWalFd, aBuf, szPage+WAL_FRAME_HDRSIZE, iOff);\n    if( rc==SQLITE_OK ){\n      u32 iPgno, nDbSize;\n      iPgno = sqlite3Get4byte(aBuf);\n      nDbSize = sqlite3Get4byte(&aBuf[4]);\n\n      walEncodeFrame(pWal, iPgno, nDbSize, &aBuf[WAL_FRAME_HDRSIZE], aFrame);\n      rc = sqlite3OsWrite(pWal->pWalFd, aFrame, sizeof(aFrame), iOff);\n    }\n  }\n\n  sqlite3_free(aBuf);\n  return rc;\n}\n\n/* \n** Write a set of frames to the log. The caller must hold the write-lock\n** on the log file (obtained using sqlite3WalBeginWriteTransaction()).\n*/\nint sqlite3WalFrames(\n  Wal *pWal,                      /* Wal handle to write to */\n  int szPage,                     /* Database page-size in bytes */\n  PgHdr *pList,                   /* List of dirty pages to write */\n  Pgno nTruncate,                 /* Database size after this commit */\n  int isCommit,                   /* True if this is a commit */\n  int sync_flags                  /* Flags to pass to OsSync() (or 0) */\n){\n  int rc;                         /* Used to catch return codes */\n  u32 iFrame;                     /* Next frame address */\n  PgHdr *p;                       /* Iterator to run through pList with. */\n  PgHdr *pLast = 0;               /* Last frame in list */\n  int nExtra = 0;                 /* Number of extra copies of last page */\n  int szFrame;                    /* The size of a single frame */\n  i64 iOffset;                    /* Next byte to write in WAL file */\n  WalWriter w;                    /* The writer */\n  u32 iFirst = 0;                 /* First frame that may be overwritten */\n  WalIndexHdr *pLive;             /* Pointer to shared header */\n\n  assert( pList );\n  assert( pWal->writeLock );\n\n  /* If this frame set completes a transaction, then nTruncate>0.  If\n  ** nTruncate==0 then this frame set does not complete the transaction. */\n  assert( (isCommit!=0)==(nTruncate!=0) );\n\n#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)\n  { int cnt; for(cnt=0, p=pList; p; p=p->pDirty, cnt++){}\n    WALTRACE((\"WAL%p: frame write begin. %d frames. mxFrame=%d. %s\\n\",\n              pWal, cnt, pWal->hdr.mxFrame, isCommit ? \"Commit\" : \"Spill\"));\n  }\n#endif\n\n  pLive = (WalIndexHdr*)walIndexHdr(pWal);\n  if( memcmp(&pWal->hdr, (void *)pLive, sizeof(WalIndexHdr))!=0 ){\n    iFirst = pLive->mxFrame+1;\n  }\n\n  /* See if it is possible to write these frames into the start of the\n  ** log file, instead of appending to it at pWal->hdr.mxFrame.\n  */\n  if( SQLITE_OK!=(rc = walRestartLog(pWal)) ){\n    return rc;\n  }\n\n  /* If this is the first frame written into the log, write the WAL\n  ** header to the start of the WAL file. See comments at the top of\n  ** this source file for a description of the WAL header format.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  if( iFrame==0 ){\n    u8 aWalHdr[WAL_HDRSIZE];      /* Buffer to assemble wal-header in */\n    u32 aCksum[2];                /* Checksum for wal-header */\n\n    sqlite3Put4byte(&aWalHdr[0], (WAL_MAGIC | SQLITE_BIGENDIAN));\n    sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);\n    sqlite3Put4byte(&aWalHdr[8], szPage);\n    sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);\n    if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);\n    memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);\n    walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);\n    sqlite3Put4byte(&aWalHdr[24], aCksum[0]);\n    sqlite3Put4byte(&aWalHdr[28], aCksum[1]);\n    \n    pWal->szPage = szPage;\n    pWal->hdr.bigEndCksum = SQLITE_BIGENDIAN;\n    pWal->hdr.aFrameCksum[0] = aCksum[0];\n    pWal->hdr.aFrameCksum[1] = aCksum[1];\n    pWal->truncateOnCommit = 1;\n\n    rc = sqlite3OsWrite(pWal->pWalFd, aWalHdr, sizeof(aWalHdr), 0);\n    WALTRACE((\"WAL%p: wal-header write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n    if( rc!=SQLITE_OK ){\n      return rc;\n    }\n\n    /* Sync the header (unless SQLITE_IOCAP_SEQUENTIAL is true or unless\n    ** all syncing is turned off by PRAGMA synchronous=OFF).  Otherwise\n    ** an out-of-order write following a WAL restart could result in\n    ** database corruption.  See the ticket:\n    **\n    **     https://sqlite.org/src/info/ff5be73dee\n    */\n    if( pWal->syncHeader ){\n      rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));\n      if( rc ) return rc;\n    }\n  }\n  assert( (int)pWal->szPage==szPage );\n\n  /* Setup information needed to write frames into the WAL */\n  w.pWal = pWal;\n  w.pFd = pWal->pWalFd;\n  w.iSyncPoint = 0;\n  w.syncFlags = sync_flags;\n  w.szPage = szPage;\n  iOffset = walFrameOffset(iFrame+1, szPage);\n  szFrame = szPage + WAL_FRAME_HDRSIZE;\n\n  /* Write all frames into the log file exactly once */\n  for(p=pList; p; p=p->pDirty){\n    int nDbSize;   /* 0 normally.  Positive == commit flag */\n\n    /* Check if this page has already been written into the wal file by\n    ** the current transaction. If so, overwrite the existing frame and\n    ** set Wal.writeLock to WAL_WRITELOCK_RECKSUM - indicating that \n    ** checksums must be recomputed when the transaction is committed.  */\n    if( iFirst && (p->pDirty || isCommit==0) ){\n      u32 iWrite = 0;\n      VVA_ONLY(rc =) sqlite3WalFindFrame(pWal, p->pgno, &iWrite);\n      assert( rc==SQLITE_OK || iWrite==0 );\n      if( iWrite>=iFirst ){\n        i64 iOff = walFrameOffset(iWrite, szPage) + WAL_FRAME_HDRSIZE;\n        void *pData;\n        if( pWal->iReCksum==0 || iWrite<pWal->iReCksum ){\n          pWal->iReCksum = iWrite;\n        }\n#if defined(SQLITE_HAS_CODEC)\n        if( (pData = sqlite3PagerCodec(p))==0 ) return SQLITE_NOMEM;\n#else\n        pData = p->pData;\n#endif\n        rc = sqlite3OsWrite(pWal->pWalFd, pData, szPage, iOff);\n        if( rc ) return rc;\n        p->flags &= ~PGHDR_WAL_APPEND;\n        continue;\n      }\n    }\n\n    iFrame++;\n    assert( iOffset==walFrameOffset(iFrame, szPage) );\n    nDbSize = (isCommit && p->pDirty==0) ? nTruncate : 0;\n    rc = walWriteOneFrame(&w, p, nDbSize, iOffset);\n    if( rc ) return rc;\n    pLast = p;\n    iOffset += szFrame;\n    p->flags |= PGHDR_WAL_APPEND;\n  }\n\n  /* Recalculate checksums within the wal file if required. */\n  if( isCommit && pWal->iReCksum ){\n    rc = walRewriteChecksums(pWal, iFrame);\n    if( rc ) return rc;\n  }\n\n  /* If this is the end of a transaction, then we might need to pad\n  ** the transaction and/or sync the WAL file.\n  **\n  ** Padding and syncing only occur if this set of frames complete a\n  ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL\n  ** or synchronous==OFF, then no padding or syncing are needed.\n  **\n  ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not\n  ** needed and only the sync is done.  If padding is needed, then the\n  ** final frame is repeated (with its commit mark) until the next sector\n  ** boundary is crossed.  Only the part of the WAL prior to the last\n  ** sector boundary is synced; the part of the last frame that extends\n  ** past the sector boundary is written after the sync.\n  */\n  if( isCommit && WAL_SYNC_FLAGS(sync_flags)!=0 ){\n    int bSync = 1;\n    if( pWal->padToSectorBoundary ){\n      int sectorSize = sqlite3SectorSize(pWal->pWalFd);\n      w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize;\n      bSync = (w.iSyncPoint==iOffset);\n      testcase( bSync );\n      while( iOffset<w.iSyncPoint ){\n        rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset);\n        if( rc ) return rc;\n        iOffset += szFrame;\n        nExtra++;\n      }\n    }\n    if( bSync ){\n      assert( rc==SQLITE_OK );\n      rc = sqlite3OsSync(w.pFd, WAL_SYNC_FLAGS(sync_flags));\n    }\n  }\n\n  /* If this frame set completes the first transaction in the WAL and\n  ** if PRAGMA journal_size_limit is set, then truncate the WAL to the\n  ** journal size limit, if possible.\n  */\n  if( isCommit && pWal->truncateOnCommit && pWal->mxWalSize>=0 ){\n    i64 sz = pWal->mxWalSize;\n    if( walFrameOffset(iFrame+nExtra+1, szPage)>pWal->mxWalSize ){\n      sz = walFrameOffset(iFrame+nExtra+1, szPage);\n    }\n    walLimitSize(pWal, sz);\n    pWal->truncateOnCommit = 0;\n  }\n\n  /* Append data to the wal-index. It is not necessary to lock the \n  ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index\n  ** guarantees that there are no other writers, and no data that may\n  ** be in use by existing readers is being overwritten.\n  */\n  iFrame = pWal->hdr.mxFrame;\n  for(p=pList; p && rc==SQLITE_OK; p=p->pDirty){\n    if( (p->flags & PGHDR_WAL_APPEND)==0 ) continue;\n    iFrame++;\n    rc = walIndexAppend(pWal, iFrame, p->pgno);\n  }\n  while( rc==SQLITE_OK && nExtra>0 ){\n    iFrame++;\n    nExtra--;\n    rc = walIndexAppend(pWal, iFrame, pLast->pgno);\n  }\n\n  if( rc==SQLITE_OK ){\n    /* Update the private copy of the header. */\n    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));\n    testcase( szPage<=32768 );\n    testcase( szPage>=65536 );\n    pWal->hdr.mxFrame = iFrame;\n    if( isCommit ){\n      pWal->hdr.iChange++;\n      pWal->hdr.nPage = nTruncate;\n    }\n    /* If this is a commit, update the wal-index header too. */\n    if( isCommit ){\n      walIndexWriteHdr(pWal);\n      pWal->iCallback = iFrame;\n    }\n  }\n\n  WALTRACE((\"WAL%p: frame write %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return rc;\n}\n\n/* \n** This routine is called to implement sqlite3_wal_checkpoint() and\n** related interfaces.\n**\n** Obtain a CHECKPOINT lock and then backfill as much information as\n** we can from WAL into the database.\n**\n** If parameter xBusy is not NULL, it is a pointer to a busy-handler\n** callback. In this case this function runs a blocking checkpoint.\n*/\nint sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Wal connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* PASSIVE, FULL, RESTART, or TRUNCATE */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of temporary buffer */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n){\n  int rc;                         /* Return code */\n  int isChanged = 0;              /* True if a new wal-index header is loaded */\n  int eMode2 = eMode;             /* Mode to pass to walCheckpoint() */\n  int (*xBusy2)(void*) = xBusy;   /* Busy handler for eMode2 */\n\n  assert( pWal->ckptLock==0 );\n  assert( pWal->writeLock==0 );\n\n  /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n  ** in the SQLITE_CHECKPOINT_PASSIVE mode. */\n  assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );\n\n  if( pWal->readOnly ) return SQLITE_READONLY;\n  WALTRACE((\"WAL%p: checkpoint begins\\n\", pWal));\n\n  /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive \n  ** \"checkpoint\" lock on the database file. */\n  rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  if( rc ){\n    /* EVIDENCE-OF: R-10421-19736 If any other process is running a\n    ** checkpoint operation at the same time, the lock cannot be obtained and\n    ** SQLITE_BUSY is returned.\n    ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,\n    ** it will not be invoked in this case.\n    */\n    testcase( rc==SQLITE_BUSY );\n    testcase( xBusy!=0 );\n    return rc;\n  }\n  pWal->ckptLock = 1;\n\n  /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and\n  ** TRUNCATE modes also obtain the exclusive \"writer\" lock on the database\n  ** file.\n  **\n  ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained\n  ** immediately, and a busy-handler is configured, it is invoked and the\n  ** writer lock retried until either the busy-handler returns 0 or the\n  ** lock is successfully obtained.\n  */\n  if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){\n    rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);\n    if( rc==SQLITE_OK ){\n      pWal->writeLock = 1;\n    }else if( rc==SQLITE_BUSY ){\n      eMode2 = SQLITE_CHECKPOINT_PASSIVE;\n      xBusy2 = 0;\n      rc = SQLITE_OK;\n    }\n  }\n\n  /* Read the wal-index header. */\n  if( rc==SQLITE_OK ){\n    rc = walIndexReadHdr(pWal, &isChanged);\n    if( isChanged && pWal->pDbFd->pMethods->iVersion>=3 ){\n      sqlite3OsUnfetch(pWal->pDbFd, 0, 0);\n    }\n  }\n\n  /* Copy data from the log to the database file. */\n  if( rc==SQLITE_OK ){\n\n    if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){\n      rc = SQLITE_CORRUPT_BKPT;\n    }else{\n      rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);\n    }\n\n    /* If no error occurred, set the output variables. */\n    if( rc==SQLITE_OK || rc==SQLITE_BUSY ){\n      if( pnLog ) *pnLog = (int)pWal->hdr.mxFrame;\n      if( pnCkpt ) *pnCkpt = (int)(walCkptInfo(pWal)->nBackfill);\n    }\n  }\n\n  if( isChanged ){\n    /* If a new wal-index header was loaded before the checkpoint was \n    ** performed, then the pager-cache associated with pWal is now\n    ** out of date. So zero the cached wal-index header to ensure that\n    ** next time the pager opens a snapshot on this database it knows that\n    ** the cache needs to be reset.\n    */\n    memset(&pWal->hdr, 0, sizeof(WalIndexHdr));\n  }\n\n  /* Release the locks. */\n  sqlite3WalEndWriteTransaction(pWal);\n  walUnlockExclusive(pWal, WAL_CKPT_LOCK, 1);\n  pWal->ckptLock = 0;\n  WALTRACE((\"WAL%p: checkpoint %s\\n\", pWal, rc ? \"failed\" : \"ok\"));\n  return (rc==SQLITE_OK && eMode!=eMode2 ? SQLITE_BUSY : rc);\n}\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nint sqlite3WalCallback(Wal *pWal){\n  u32 ret = 0;\n  if( pWal ){\n    ret = pWal->iCallback;\n    pWal->iCallback = 0;\n  }\n  return (int)ret;\n}\n\n/*\n** This function is called to change the WAL subsystem into or out\n** of locking_mode=EXCLUSIVE.\n**\n** If op is zero, then attempt to change from locking_mode=EXCLUSIVE\n** into locking_mode=NORMAL.  This means that we must acquire a lock\n** on the pWal->readLock byte.  If the WAL is already in locking_mode=NORMAL\n** or if the acquisition of the lock fails, then return 0.  If the\n** transition out of exclusive-mode is successful, return 1.  This\n** operation must occur while the pager is still holding the exclusive\n** lock on the main database file.\n**\n** If op is one, then change from locking_mode=NORMAL into \n** locking_mode=EXCLUSIVE.  This means that the pWal->readLock must\n** be released.  Return 1 if the transition is made and 0 if the\n** WAL is already in exclusive-locking mode - meaning that this\n** routine is a no-op.  The pager must already hold the exclusive lock\n** on the main database file before invoking this operation.\n**\n** If op is negative, then do a dry-run of the op==1 case but do\n** not actually change anything. The pager uses this to see if it\n** should acquire the database exclusive lock prior to invoking\n** the op==1 case.\n*/\nint sqlite3WalExclusiveMode(Wal *pWal, int op){\n  int rc;\n  assert( pWal->writeLock==0 );\n  assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 );\n\n  /* pWal->readLock is usually set, but might be -1 if there was a \n  ** prior error while attempting to acquire are read-lock. This cannot \n  ** happen if the connection is actually in exclusive mode (as no xShmLock\n  ** locks are taken in this case). Nor should the pager attempt to\n  ** upgrade to exclusive-mode following such an error.\n  */\n  assert( pWal->readLock>=0 || pWal->lockError );\n  assert( pWal->readLock>=0 || (op<=0 && pWal->exclusiveMode==0) );\n\n  if( op==0 ){\n    if( pWal->exclusiveMode ){\n      pWal->exclusiveMode = 0;\n      if( walLockShared(pWal, WAL_READ_LOCK(pWal->readLock))!=SQLITE_OK ){\n        pWal->exclusiveMode = 1;\n      }\n      rc = pWal->exclusiveMode==0;\n    }else{\n      /* Already in locking_mode=NORMAL */\n      rc = 0;\n    }\n  }else if( op>0 ){\n    assert( pWal->exclusiveMode==0 );\n    assert( pWal->readLock>=0 );\n    walUnlockShared(pWal, WAL_READ_LOCK(pWal->readLock));\n    pWal->exclusiveMode = 1;\n    rc = 1;\n  }else{\n    rc = pWal->exclusiveMode==0;\n  }\n  return rc;\n}\n\n/* \n** Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nint sqlite3WalHeapMemory(Wal *pWal){\n  return (pWal && pWal->exclusiveMode==WAL_HEAPMEMORY_MODE );\n}\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\n/* Create a snapshot object.  The content of a snapshot is opaque to\n** every other subsystem, so the WAL module can put whatever it needs\n** in the object.\n*/\nint sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){\n  int rc = SQLITE_OK;\n  WalIndexHdr *pRet;\n  static const u32 aZero[4] = { 0, 0, 0, 0 };\n\n  assert( pWal->readLock>=0 && pWal->writeLock==0 );\n\n  if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){\n    *ppSnapshot = 0;\n    return SQLITE_ERROR;\n  }\n  pRet = (WalIndexHdr*)sqlite3_malloc(sizeof(WalIndexHdr));\n  if( pRet==0 ){\n    rc = SQLITE_NOMEM_BKPT;\n  }else{\n    memcpy(pRet, &pWal->hdr, sizeof(WalIndexHdr));\n    *ppSnapshot = (sqlite3_snapshot*)pRet;\n  }\n\n  return rc;\n}\n\n/* Try to open on pSnapshot when the next read-transaction starts\n*/\nvoid sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot){\n  pWal->pSnapshot = (WalIndexHdr*)pSnapshot;\n}\n\n/* \n** Return a +ve value if snapshot p1 is newer than p2. A -ve value if\n** p1 is older than p2 and zero if p1 and p2 are the same snapshot.\n*/\nint sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){\n  WalIndexHdr *pHdr1 = (WalIndexHdr*)p1;\n  WalIndexHdr *pHdr2 = (WalIndexHdr*)p2;\n\n  /* aSalt[0] is a copy of the value stored in the wal file header. It\n  ** is incremented each time the wal file is restarted.  */\n  if( pHdr1->aSalt[0]<pHdr2->aSalt[0] ) return -1;\n  if( pHdr1->aSalt[0]>pHdr2->aSalt[0] ) return +1;\n  if( pHdr1->mxFrame<pHdr2->mxFrame ) return -1;\n  if( pHdr1->mxFrame>pHdr2->mxFrame ) return +1;\n  return 0;\n}\n#endif /* SQLITE_ENABLE_SNAPSHOT */\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/*\n** If the argument is not NULL, it points to a Wal object that holds a\n** read-lock. This function returns the database page-size if it is known,\n** or zero if it is not (or if pWal is NULL).\n*/\nint sqlite3WalFramesize(Wal *pWal){\n  assert( pWal==0 || pWal->readLock>=0 );\n  return (pWal ? pWal->szPage : 0);\n}\n#endif\n\n/* Return the sqlite3_file object for the WAL file\n*/\nsqlite3_file *sqlite3WalFile(Wal *pWal){\n  return pWal->pWalFd;\n}\n\n#endif /* #ifndef SQLITE_OMIT_WAL */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/wal.h",
    "content": "/*\n** 2010 February 1\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This header file defines the interface to the write-ahead logging \n** system. Refer to the comments below and the header comment attached to \n** the implementation of each function in log.c for further details.\n*/\n\n#ifndef SQLITE_WAL_H\n#define SQLITE_WAL_H\n\n#include \"sqliteInt.h\"\n\n/* Macros for extracting appropriate sync flags for either transaction\n** commits (WAL_SYNC_FLAGS(X)) or for checkpoint ops (CKPT_SYNC_FLAGS(X)):\n*/\n#define WAL_SYNC_FLAGS(X)   ((X)&0x03)\n#define CKPT_SYNC_FLAGS(X)  (((X)>>2)&0x03)\n\n#ifdef SQLITE_OMIT_WAL\n# define sqlite3WalOpen(x,y,z)                   0\n# define sqlite3WalLimit(x,y)\n# define sqlite3WalClose(v,w,x,y,z)              0\n# define sqlite3WalBeginReadTransaction(y,z)     0\n# define sqlite3WalEndReadTransaction(z)\n# define sqlite3WalDbsize(y)                     0\n# define sqlite3WalBeginWriteTransaction(y)      0\n# define sqlite3WalEndWriteTransaction(x)        0\n# define sqlite3WalUndo(x,y,z)                   0\n# define sqlite3WalSavepoint(y,z)\n# define sqlite3WalSavepointUndo(y,z)            0\n# define sqlite3WalFrames(u,v,w,x,y,z)           0\n# define sqlite3WalCheckpoint(q,r,s,t,u,v,w,x,y,z) 0\n# define sqlite3WalCallback(z)                   0\n# define sqlite3WalExclusiveMode(y,z)            0\n# define sqlite3WalHeapMemory(z)                 0\n# define sqlite3WalFramesize(z)                  0\n# define sqlite3WalFindFrame(x,y,z)              0\n# define sqlite3WalFile(x)                       0\n#else\n\n#define WAL_SAVEPOINT_NDATA 4\n\n/* Connection to a write-ahead log (WAL) file. \n** There is one object of this type for each pager. \n*/\ntypedef struct Wal Wal;\n\n/* Open and close a connection to a write-ahead log. */\nint sqlite3WalOpen(sqlite3_vfs*, sqlite3_file*, const char *, int, i64, Wal**);\nint sqlite3WalClose(Wal *pWal, sqlite3*, int sync_flags, int, u8 *);\n\n/* Set the limiting size of a WAL file. */\nvoid sqlite3WalLimit(Wal*, i64);\n\n/* Used by readers to open (lock) and close (unlock) a snapshot.  A \n** snapshot is like a read-transaction.  It is the state of the database\n** at an instant in time.  sqlite3WalOpenSnapshot gets a read lock and\n** preserves the current state even if the other threads or processes\n** write to or checkpoint the WAL.  sqlite3WalCloseSnapshot() closes the\n** transaction and releases the lock.\n*/\nint sqlite3WalBeginReadTransaction(Wal *pWal, int *);\nvoid sqlite3WalEndReadTransaction(Wal *pWal);\n\n/* Read a page from the write-ahead log, if it is present. */\nint sqlite3WalFindFrame(Wal *, Pgno, u32 *);\nint sqlite3WalReadFrame(Wal *, u32, int, u8 *);\n\n/* If the WAL is not empty, return the size of the database. */\nPgno sqlite3WalDbsize(Wal *pWal);\n\n/* Obtain or release the WRITER lock. */\nint sqlite3WalBeginWriteTransaction(Wal *pWal);\nint sqlite3WalEndWriteTransaction(Wal *pWal);\n\n/* Undo any frames written (but not committed) to the log */\nint sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);\n\n/* Return an integer that records the current (uncommitted) write\n** position in the WAL */\nvoid sqlite3WalSavepoint(Wal *pWal, u32 *aWalData);\n\n/* Move the write position of the WAL back to iFrame.  Called in\n** response to a ROLLBACK TO command. */\nint sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData);\n\n/* Write a frame or frames to the log. */\nint sqlite3WalFrames(Wal *pWal, int, PgHdr *, Pgno, int, int);\n\n/* Copy pages from the log to the database file */ \nint sqlite3WalCheckpoint(\n  Wal *pWal,                      /* Write-ahead log connection */\n  sqlite3 *db,                    /* Check this handle's interrupt flag */\n  int eMode,                      /* One of PASSIVE, FULL and RESTART */\n  int (*xBusy)(void*),            /* Function to call when busy */\n  void *pBusyArg,                 /* Context argument for xBusyHandler */\n  int sync_flags,                 /* Flags to sync db file with (or 0) */\n  int nBuf,                       /* Size of buffer nBuf */\n  u8 *zBuf,                       /* Temporary buffer to use */\n  int *pnLog,                     /* OUT: Number of frames in WAL */\n  int *pnCkpt                     /* OUT: Number of backfilled frames in WAL */\n);\n\n/* Return the value to pass to a sqlite3_wal_hook callback, the\n** number of frames in the WAL at the point of the last commit since\n** sqlite3WalCallback() was called.  If no commits have occurred since\n** the last call, then return 0.\n*/\nint sqlite3WalCallback(Wal *pWal);\n\n/* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)\n** by the pager layer on the database file.\n*/\nint sqlite3WalExclusiveMode(Wal *pWal, int op);\n\n/* Return true if the argument is non-NULL and the WAL module is using\n** heap-memory for the wal-index. Otherwise, if the argument is NULL or the\n** WAL module is using shared-memory, return false. \n*/\nint sqlite3WalHeapMemory(Wal *pWal);\n\n#ifdef SQLITE_ENABLE_SNAPSHOT\nint sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot);\nvoid sqlite3WalSnapshotOpen(Wal *pWal, sqlite3_snapshot *pSnapshot);\nint sqlite3WalSnapshotRecover(Wal *pWal);\n#endif\n\n#ifdef SQLITE_ENABLE_ZIPVFS\n/* If the WAL file is not empty, return the number of bytes of content\n** stored in each frame (i.e. the db page-size when the WAL was created).\n*/\nint sqlite3WalFramesize(Wal *pWal);\n#endif\n\n/* Return the sqlite3_file object for the WAL file */\nsqlite3_file *sqlite3WalFile(Wal *pWal);\n\n#endif /* ifndef SQLITE_OMIT_WAL */\n#endif /* SQLITE_WAL_H */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/walker.c",
    "content": "/*\n** 2008 August 16\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file contains routines used for walking the parser tree for\n** an SQL statement.\n*/\n#include \"sqliteInt.h\"\n#include <stdlib.h>\n#include <string.h>\n\n\n/*\n** Walk an expression tree.  Invoke the callback once for each node\n** of the expression, while descending.  (In other words, the callback\n** is invoked before visiting children.)\n**\n** The return value from the callback should be one of the WRC_*\n** constants to specify how to proceed with the walk.\n**\n**    WRC_Continue      Continue descending down the tree.\n**\n**    WRC_Prune         Do not descend into child nodes, but allow\n**                      the walk to continue with sibling nodes.\n**\n**    WRC_Abort         Do no more callbacks.  Unwind the stack and\n**                      return from the top-level walk call.\n**\n** The return value from this routine is WRC_Abort to abandon the tree walk\n** and WRC_Continue to continue.\n*/\nstatic SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){\n  int rc;\n  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );\n  testcase( ExprHasProperty(pExpr, EP_Reduced) );\n  while(1){\n    rc = pWalker->xExprCallback(pWalker, pExpr);\n    if( rc ) return rc & WRC_Abort;\n    if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){\n      if( pExpr->pLeft && walkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;\n       assert( pExpr->x.pList==0 || pExpr->pRight==0 );\n      if( pExpr->pRight ){\n        pExpr = pExpr->pRight;\n        continue;\n      }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;\n      }else if( pExpr->x.pList ){\n        if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;\n      }\n    }\n    break;\n  }\n  return WRC_Continue;\n}\nint sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){\n  return pExpr ? walkExpr(pWalker,pExpr) : WRC_Continue;\n}\n\n/*\n** Call sqlite3WalkExpr() for every expression in list p or until\n** an abort request is seen.\n*/\nint sqlite3WalkExprList(Walker *pWalker, ExprList *p){\n  int i;\n  struct ExprList_item *pItem;\n  if( p ){\n    for(i=p->nExpr, pItem=p->a; i>0; i--, pItem++){\n      if( sqlite3WalkExpr(pWalker, pItem->pExpr) ) return WRC_Abort;\n    }\n  }\n  return WRC_Continue;\n}\n\n/*\n** Walk all expressions associated with SELECT statement p.  Do\n** not invoke the SELECT callback on p, but do (of course) invoke\n** any expr callbacks and SELECT callbacks that come from subqueries.\n** Return WRC_Abort or WRC_Continue.\n*/\nint sqlite3WalkSelectExpr(Walker *pWalker, Select *p){\n  if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;\n  if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;\n  if( sqlite3WalkExpr(pWalker, p->pOffset) ) return WRC_Abort;\n  return WRC_Continue;\n}\n\n/*\n** Walk the parse trees associated with all subqueries in the\n** FROM clause of SELECT statement p.  Do not invoke the select\n** callback on p, but do invoke it on each FROM clause subquery\n** and on any subqueries further down in the tree.  Return \n** WRC_Abort or WRC_Continue;\n*/\nint sqlite3WalkSelectFrom(Walker *pWalker, Select *p){\n  SrcList *pSrc;\n  int i;\n  struct SrcList_item *pItem;\n\n  pSrc = p->pSrc;\n  if( ALWAYS(pSrc) ){\n    for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){\n      if( pItem->pSelect && sqlite3WalkSelect(pWalker, pItem->pSelect) ){\n        return WRC_Abort;\n      }\n      if( pItem->fg.isTabFunc\n       && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg)\n      ){\n        return WRC_Abort;\n      }\n    }\n  }\n  return WRC_Continue;\n} \n\n/*\n** Call sqlite3WalkExpr() for every expression in Select statement p.\n** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and\n** on the compound select chain, p->pPrior. \n**\n** If it is not NULL, the xSelectCallback() callback is invoked before\n** the walk of the expressions and FROM clause. The xSelectCallback2()\n** method is invoked following the walk of the expressions and FROM clause,\n** but only if both xSelectCallback and xSelectCallback2 are both non-NULL\n** and if the expressions and FROM clause both return WRC_Continue;\n**\n** Return WRC_Continue under normal conditions.  Return WRC_Abort if\n** there is an abort request.\n**\n** If the Walker does not have an xSelectCallback() then this routine\n** is a no-op returning WRC_Continue.\n*/\nint sqlite3WalkSelect(Walker *pWalker, Select *p){\n  int rc;\n  if( p==0 ) return WRC_Continue;\n  if( pWalker->xSelectCallback==0 ) return WRC_Continue;\n  do{\n    rc = pWalker->xSelectCallback(pWalker, p);\n    if( rc ) return rc & WRC_Abort;\n    if( sqlite3WalkSelectExpr(pWalker, p)\n     || sqlite3WalkSelectFrom(pWalker, p)\n    ){\n      return WRC_Abort;\n    }\n    if( pWalker->xSelectCallback2 ){\n      pWalker->xSelectCallback2(pWalker, p);\n    }\n    p = p->pPrior;\n  }while( p!=0 );\n  return WRC_Continue;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/where.c",
    "content": "/*\n** 2001 September 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.  This module is responsible for\n** generating the code that loops through a table looking for applicable\n** rows.  Indices are selected and used to speed the search when doing\n** so is applicable.  Because this module is responsible for selecting\n** indices, you might also think of this module as the \"query optimizer\".\n*/\n#include \"sqliteInt.h\"\n#include \"whereInt.h\"\n\n/* Forward declaration of methods */\nstatic int whereLoopResize(sqlite3*, WhereLoop*, int);\n\n/* Test variable that can be set to enable WHERE tracing */\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace = 0;\n#endif\n\n\n/*\n** Return the estimated number of output rows from a WHERE clause\n*/\nLogEst sqlite3WhereOutputRowCount(WhereInfo *pWInfo){\n  return pWInfo->nRowOut;\n}\n\n/*\n** Return one of the WHERE_DISTINCT_xxxxx values to indicate how this\n** WHERE clause returns outputs for DISTINCT processing.\n*/\nint sqlite3WhereIsDistinct(WhereInfo *pWInfo){\n  return pWInfo->eDistinct;\n}\n\n/*\n** Return TRUE if the WHERE clause returns rows in ORDER BY order.\n** Return FALSE if the output needs to be sorted.\n*/\nint sqlite3WhereIsOrdered(WhereInfo *pWInfo){\n  return pWInfo->nOBSat;\n}\n\n/*\n** Return TRUE if the innermost loop of the WHERE clause implementation\n** returns rows in ORDER BY order for complete run of the inner loop.\n**\n** Across multiple iterations of outer loops, the output rows need not be\n** sorted.  As long as rows are sorted for just the innermost loop, this\n** routine can return TRUE.\n*/\nint sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){\n  return pWInfo->bOrderedInnerLoop;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to continue\n** immediately with the next row of a WHERE clause.\n*/\nint sqlite3WhereContinueLabel(WhereInfo *pWInfo){\n  assert( pWInfo->iContinue!=0 );\n  return pWInfo->iContinue;\n}\n\n/*\n** Return the VDBE address or label to jump to in order to break\n** out of a WHERE loop.\n*/\nint sqlite3WhereBreakLabel(WhereInfo *pWInfo){\n  return pWInfo->iBreak;\n}\n\n/*\n** Return ONEPASS_OFF (0) if an UPDATE or DELETE statement is unable to\n** operate directly on the rowis returned by a WHERE clause.  Return\n** ONEPASS_SINGLE (1) if the statement can operation directly because only\n** a single row is to be changed.  Return ONEPASS_MULTI (2) if the one-pass\n** optimization can be used on multiple \n**\n** If the ONEPASS optimization is used (if this routine returns true)\n** then also write the indices of open cursors used by ONEPASS\n** into aiCur[0] and aiCur[1].  iaCur[0] gets the cursor of the data\n** table and iaCur[1] gets the cursor used by an auxiliary index.\n** Either value may be -1, indicating that cursor is not used.\n** Any cursors returned will have been opened for writing.\n**\n** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is\n** unable to use the ONEPASS optimization.\n*/\nint sqlite3WhereOkOnePass(WhereInfo *pWInfo, int *aiCur){\n  memcpy(aiCur, pWInfo->aiCurOnePass, sizeof(int)*2);\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace && pWInfo->eOnePass!=ONEPASS_OFF ){\n    sqlite3DebugPrintf(\"%s cursors: %d %d\\n\",\n         pWInfo->eOnePass==ONEPASS_SINGLE ? \"ONEPASS_SINGLE\" : \"ONEPASS_MULTI\",\n         aiCur[0], aiCur[1]);\n  }\n#endif\n  return pWInfo->eOnePass;\n}\n\n/*\n** Move the content of pSrc into pDest\n*/\nstatic void whereOrMove(WhereOrSet *pDest, WhereOrSet *pSrc){\n  pDest->n = pSrc->n;\n  memcpy(pDest->a, pSrc->a, pDest->n*sizeof(pDest->a[0]));\n}\n\n/*\n** Try to insert a new prerequisite/cost entry into the WhereOrSet pSet.\n**\n** The new entry might overwrite an existing entry, or it might be\n** appended, or it might be discarded.  Do whatever is the right thing\n** so that pSet keeps the N_OR_COST best entries seen so far.\n*/\nstatic int whereOrInsert(\n  WhereOrSet *pSet,      /* The WhereOrSet to be updated */\n  Bitmask prereq,        /* Prerequisites of the new entry */\n  LogEst rRun,           /* Run-cost of the new entry */\n  LogEst nOut            /* Number of outputs for the new entry */\n){\n  u16 i;\n  WhereOrCost *p;\n  for(i=pSet->n, p=pSet->a; i>0; i--, p++){\n    if( rRun<=p->rRun && (prereq & p->prereq)==prereq ){\n      goto whereOrInsert_done;\n    }\n    if( p->rRun<=rRun && (p->prereq & prereq)==p->prereq ){\n      return 0;\n    }\n  }\n  if( pSet->n<N_OR_COST ){\n    p = &pSet->a[pSet->n++];\n    p->nOut = nOut;\n  }else{\n    p = pSet->a;\n    for(i=1; i<pSet->n; i++){\n      if( p->rRun>pSet->a[i].rRun ) p = pSet->a + i;\n    }\n    if( p->rRun<=rRun ) return 0;\n  }\nwhereOrInsert_done:\n  p->prereq = prereq;\n  p->rRun = rRun;\n  if( p->nOut>nOut ) p->nOut = nOut;\n  return 1;\n}\n\n/*\n** Return the bitmask for the given cursor number.  Return 0 if\n** iCursor is not in the set.\n*/\nBitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){\n  int i;\n  assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );\n  for(i=0; i<pMaskSet->n; i++){\n    if( pMaskSet->ix[i]==iCursor ){\n      return MASKBIT(i);\n    }\n  }\n  return 0;\n}\n\n/*\n** Create a new mask for cursor iCursor.\n**\n** There is one cursor per table in the FROM clause.  The number of\n** tables in the FROM clause is limited by a test early in the\n** sqlite3WhereBegin() routine.  So we know that the pMaskSet->ix[]\n** array will never overflow.\n*/\nstatic void createMask(WhereMaskSet *pMaskSet, int iCursor){\n  assert( pMaskSet->n < ArraySize(pMaskSet->ix) );\n  pMaskSet->ix[pMaskSet->n++] = iCursor;\n}\n\n/*\n** Advance to the next WhereTerm that matches according to the criteria\n** established when the pScan object was initialized by whereScanInit().\n** Return NULL if there are no more matching WhereTerms.\n*/\nstatic WhereTerm *whereScanNext(WhereScan *pScan){\n  int iCur;            /* The cursor on the LHS of the term */\n  i16 iColumn;         /* The column on the LHS of the term.  -1 for IPK */\n  Expr *pX;            /* An expression being tested */\n  WhereClause *pWC;    /* Shorthand for pScan->pWC */\n  WhereTerm *pTerm;    /* The term being tested */\n  int k = pScan->k;    /* Where to start scanning */\n\n  assert( pScan->iEquiv<=pScan->nEquiv );\n  pWC = pScan->pWC;\n  while(1){\n    iColumn = pScan->aiColumn[pScan->iEquiv-1];\n    iCur = pScan->aiCur[pScan->iEquiv-1];\n    assert( pWC!=0 );\n    do{\n      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){\n        if( pTerm->leftCursor==iCur\n         && pTerm->u.leftColumn==iColumn\n         && (iColumn!=XN_EXPR\n             || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,\n                                       pScan->pIdxExpr,iCur)==0)\n         && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n        ){\n          if( (pTerm->eOperator & WO_EQUIV)!=0\n           && pScan->nEquiv<ArraySize(pScan->aiCur)\n           && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN\n          ){\n            int j;\n            for(j=0; j<pScan->nEquiv; j++){\n              if( pScan->aiCur[j]==pX->iTable\n               && pScan->aiColumn[j]==pX->iColumn ){\n                  break;\n              }\n            }\n            if( j==pScan->nEquiv ){\n              pScan->aiCur[j] = pX->iTable;\n              pScan->aiColumn[j] = pX->iColumn;\n              pScan->nEquiv++;\n            }\n          }\n          if( (pTerm->eOperator & pScan->opMask)!=0 ){\n            /* Verify the affinity and collating sequence match */\n            if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){\n              CollSeq *pColl;\n              Parse *pParse = pWC->pWInfo->pParse;\n              pX = pTerm->pExpr;\n              if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){\n                continue;\n              }\n              assert(pX->pLeft);\n              pColl = sqlite3BinaryCompareCollSeq(pParse,\n                                                  pX->pLeft, pX->pRight);\n              if( pColl==0 ) pColl = pParse->db->pDfltColl;\n              if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){\n                continue;\n              }\n            }\n            if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0\n             && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN\n             && pX->iTable==pScan->aiCur[0]\n             && pX->iColumn==pScan->aiColumn[0]\n            ){\n              testcase( pTerm->eOperator & WO_IS );\n              continue;\n            }\n            pScan->pWC = pWC;\n            pScan->k = k+1;\n            return pTerm;\n          }\n        }\n      }\n      pWC = pWC->pOuter;\n      k = 0;\n    }while( pWC!=0 );\n    if( pScan->iEquiv>=pScan->nEquiv ) break;\n    pWC = pScan->pOrigWC;\n    k = 0;\n    pScan->iEquiv++;\n  }\n  return 0;\n}\n\n/*\n** Initialize a WHERE clause scanner object.  Return a pointer to the\n** first match.  Return NULL if there are no matches.\n**\n** The scanner will be searching the WHERE clause pWC.  It will look\n** for terms of the form \"X <op> <expr>\" where X is column iColumn of table\n** iCur.   Or if pIdx!=0 then X is column iColumn of index pIdx.  pIdx\n** must be one of the indexes of table iCur.\n**\n** The <op> must be one of the operators described by opMask.\n**\n** If the search is for X and the WHERE clause contains terms of the\n** form X=Y then this routine might also return terms of the form\n** \"Y <op> <expr>\".  The number of levels of transitivity is limited,\n** but is enough to handle most commonly occurring SQL statements.\n**\n** If X is not the INTEGER PRIMARY KEY then X must be compatible with\n** index pIdx.\n*/\nstatic WhereTerm *whereScanInit(\n  WhereScan *pScan,       /* The WhereScan object being initialized */\n  WhereClause *pWC,       /* The WHERE clause to be scanned */\n  int iCur,               /* Cursor to scan for */\n  int iColumn,            /* Column to scan for */\n  u32 opMask,             /* Operator(s) to scan for */\n  Index *pIdx             /* Must be compatible with this index */\n){\n  pScan->pOrigWC = pWC;\n  pScan->pWC = pWC;\n  pScan->pIdxExpr = 0;\n  pScan->idxaff = 0;\n  pScan->zCollName = 0;\n  if( pIdx ){\n    int j = iColumn;\n    iColumn = pIdx->aiColumn[j];\n    if( iColumn==XN_EXPR ){\n      pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;\n      pScan->zCollName = pIdx->azColl[j];\n    }else if( iColumn==pIdx->pTable->iPKey ){\n      iColumn = XN_ROWID;\n    }else if( iColumn>=0 ){\n      pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;\n      pScan->zCollName = pIdx->azColl[j];\n    }\n  }else if( iColumn==XN_EXPR ){\n    return 0;\n  }\n  pScan->opMask = opMask;\n  pScan->k = 0;\n  pScan->aiCur[0] = iCur;\n  pScan->aiColumn[0] = iColumn;\n  pScan->nEquiv = 1;\n  pScan->iEquiv = 1;\n  return whereScanNext(pScan);\n}\n\n/*\n** Search for a term in the WHERE clause that is of the form \"X <op> <expr>\"\n** where X is a reference to the iColumn of table iCur or of index pIdx\n** if pIdx!=0 and <op> is one of the WO_xx operator codes specified by\n** the op parameter.  Return a pointer to the term.  Return 0 if not found.\n**\n** If pIdx!=0 then it must be one of the indexes of table iCur.  \n** Search for terms matching the iColumn-th column of pIdx\n** rather than the iColumn-th column of table iCur.\n**\n** The term returned might by Y=<expr> if there is another constraint in\n** the WHERE clause that specifies that X=Y.  Any such constraints will be\n** identified by the WO_EQUIV bit in the pTerm->eOperator field.  The\n** aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11\n** slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10\n** other equivalent values.  Hence a search for X will return <expr> if X=A1\n** and A1=A2 and A2=A3 and ... and A9=A10 and A10=<expr>.\n**\n** If there are multiple terms in the WHERE clause of the form \"X <op> <expr>\"\n** then try for the one with no dependencies on <expr> - in other words where\n** <expr> is a constant expression of some kind.  Only return entries of\n** the form \"X <op> Y\" where Y is a column in another table if no terms of\n** the form \"X <op> <const-expr>\" exist.   If no terms with a constant RHS\n** exist, try to return a term that does not use WO_EQUIV.\n*/\nWhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n){\n  WhereTerm *pResult = 0;\n  WhereTerm *p;\n  WhereScan scan;\n\n  p = whereScanInit(&scan, pWC, iCur, iColumn, op, pIdx);\n  op &= WO_EQ|WO_IS;\n  while( p ){\n    if( (p->prereqRight & notReady)==0 ){\n      if( p->prereqRight==0 && (p->eOperator&op)!=0 ){\n        testcase( p->eOperator & WO_IS );\n        return p;\n      }\n      if( pResult==0 ) pResult = p;\n    }\n    p = whereScanNext(&scan);\n  }\n  return pResult;\n}\n\n/*\n** This function searches pList for an entry that matches the iCol-th column\n** of index pIdx.\n**\n** If such an expression is found, its index in pList->a[] is returned. If\n** no expression is found, -1 is returned.\n*/\nstatic int findIndexCol(\n  Parse *pParse,                  /* Parse context */\n  ExprList *pList,                /* Expression list to search */\n  int iBase,                      /* Cursor for table associated with pIdx */\n  Index *pIdx,                    /* Index to match column of */\n  int iCol                        /* Column of index to match */\n){\n  int i;\n  const char *zColl = pIdx->azColl[iCol];\n\n  for(i=0; i<pList->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pList->a[i].pExpr);\n    if( p->op==TK_COLUMN\n     && p->iColumn==pIdx->aiColumn[iCol]\n     && p->iTable==iBase\n    ){\n      CollSeq *pColl = sqlite3ExprNNCollSeq(pParse, pList->a[i].pExpr);\n      if( 0==sqlite3StrICmp(pColl->zName, zColl) ){\n        return i;\n      }\n    }\n  }\n\n  return -1;\n}\n\n/*\n** Return TRUE if the iCol-th column of index pIdx is NOT NULL\n*/\nstatic int indexColumnNotNull(Index *pIdx, int iCol){\n  int j;\n  assert( pIdx!=0 );\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  j = pIdx->aiColumn[iCol];\n  if( j>=0 ){\n    return pIdx->pTable->aCol[j].notNull;\n  }else if( j==(-1) ){\n    return 1;\n  }else{\n    assert( j==(-2) );\n    return 0;  /* Assume an indexed expression can always yield a NULL */\n\n  }\n}\n\n/*\n** Return true if the DISTINCT expression-list passed as the third argument\n** is redundant.\n**\n** A DISTINCT list is redundant if any subset of the columns in the\n** DISTINCT list are collectively unique and individually non-null.\n*/\nstatic int isDistinctRedundant(\n  Parse *pParse,            /* Parsing context */\n  SrcList *pTabList,        /* The FROM clause */\n  WhereClause *pWC,         /* The WHERE clause */\n  ExprList *pDistinct       /* The result set that needs to be DISTINCT */\n){\n  Table *pTab;\n  Index *pIdx;\n  int i;                          \n  int iBase;\n\n  /* If there is more than one table or sub-select in the FROM clause of\n  ** this query, then it will not be possible to show that the DISTINCT \n  ** clause is redundant. */\n  if( pTabList->nSrc!=1 ) return 0;\n  iBase = pTabList->a[0].iCursor;\n  pTab = pTabList->a[0].pTab;\n\n  /* If any of the expressions is an IPK column on table iBase, then return \n  ** true. Note: The (p->iTable==iBase) part of this test may be false if the\n  ** current SELECT is a correlated sub-query.\n  */\n  for(i=0; i<pDistinct->nExpr; i++){\n    Expr *p = sqlite3ExprSkipCollate(pDistinct->a[i].pExpr);\n    if( p->op==TK_COLUMN && p->iTable==iBase && p->iColumn<0 ) return 1;\n  }\n\n  /* Loop through all indices on the table, checking each to see if it makes\n  ** the DISTINCT qualifier redundant. It does so if:\n  **\n  **   1. The index is itself UNIQUE, and\n  **\n  **   2. All of the columns in the index are either part of the pDistinct\n  **      list, or else the WHERE clause contains a term of the form \"col=X\",\n  **      where X is a constant value. The collation sequences of the\n  **      comparison and select-list expressions must match those of the index.\n  **\n  **   3. All of those index columns for which the WHERE clause does not\n  **      contain a \"col=X\" term are subject to a NOT NULL constraint.\n  */\n  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( !IsUniqueIndex(pIdx) ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){\n        if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break;\n        if( indexColumnNotNull(pIdx, i)==0 ) break;\n      }\n    }\n    if( i==pIdx->nKeyCol ){\n      /* This index implies that the DISTINCT qualifier is redundant. */\n      return 1;\n    }\n  }\n\n  return 0;\n}\n\n\n/*\n** Estimate the logarithm of the input value to base 2.\n*/\nstatic LogEst estLog(LogEst N){\n  return N<=10 ? 0 : sqlite3LogEst(N) - 33;\n}\n\n/*\n** Convert OP_Column opcodes to OP_Copy in previously generated code.\n**\n** This routine runs over generated VDBE code and translates OP_Column\n** opcodes into OP_Copy when the table is being accessed via co-routine \n** instead of via table lookup.\n**\n** If the bIncrRowid parameter is 0, then any OP_Rowid instructions on\n** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,\n** then each OP_Rowid is transformed into an instruction to increment the\n** value stored in its output register.\n*/\nstatic void translateColumnToCopy(\n  Parse *pParse,      /* Parsing context */\n  int iStart,         /* Translate from this opcode to the end */\n  int iTabCur,        /* OP_Column/OP_Rowid references to this table */\n  int iRegister,      /* The first column is in this register */\n  int bIncrRowid      /* If non-zero, transform OP_rowid to OP_AddImm(1) */\n){\n  Vdbe *v = pParse->pVdbe;\n  VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);\n  int iEnd = sqlite3VdbeCurrentAddr(v);\n  if( pParse->db->mallocFailed ) return;\n  for(; iStart<iEnd; iStart++, pOp++){\n    if( pOp->p1!=iTabCur ) continue;\n    if( pOp->opcode==OP_Column ){\n      pOp->opcode = OP_Copy;\n      pOp->p1 = pOp->p2 + iRegister;\n      pOp->p2 = pOp->p3;\n      pOp->p3 = 0;\n    }else if( pOp->opcode==OP_Rowid ){\n      if( bIncrRowid ){\n        /* Increment the value stored in the P2 operand of the OP_Rowid. */\n        pOp->opcode = OP_AddImm;\n        pOp->p1 = pOp->p2;\n        pOp->p2 = 1;\n      }else{\n        pOp->opcode = OP_Null;\n        pOp->p1 = 0;\n        pOp->p3 = 0;\n      }\n    }\n  }\n}\n\n/*\n** Two routines for printing the content of an sqlite3_index_info\n** structure.  Used for testing and debugging only.  If neither\n** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines\n** are no-ops.\n*/\n#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(WHERETRACE_ENABLED)\nstatic void TRACE_IDX_INPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  constraint[%d]: col=%d termid=%d op=%d usabled=%d\\n\",\n       i,\n       p->aConstraint[i].iColumn,\n       p->aConstraint[i].iTermOffset,\n       p->aConstraint[i].op,\n       p->aConstraint[i].usable);\n  }\n  for(i=0; i<p->nOrderBy; i++){\n    sqlite3DebugPrintf(\"  orderby[%d]: col=%d desc=%d\\n\",\n       i,\n       p->aOrderBy[i].iColumn,\n       p->aOrderBy[i].desc);\n  }\n}\nstatic void TRACE_IDX_OUTPUTS(sqlite3_index_info *p){\n  int i;\n  if( !sqlite3WhereTrace ) return;\n  for(i=0; i<p->nConstraint; i++){\n    sqlite3DebugPrintf(\"  usage[%d]: argvIdx=%d omit=%d\\n\",\n       i,\n       p->aConstraintUsage[i].argvIndex,\n       p->aConstraintUsage[i].omit);\n  }\n  sqlite3DebugPrintf(\"  idxNum=%d\\n\", p->idxNum);\n  sqlite3DebugPrintf(\"  idxStr=%s\\n\", p->idxStr);\n  sqlite3DebugPrintf(\"  orderByConsumed=%d\\n\", p->orderByConsumed);\n  sqlite3DebugPrintf(\"  estimatedCost=%g\\n\", p->estimatedCost);\n  sqlite3DebugPrintf(\"  estimatedRows=%lld\\n\", p->estimatedRows);\n}\n#else\n#define TRACE_IDX_INPUTS(A)\n#define TRACE_IDX_OUTPUTS(A)\n#endif\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Return TRUE if the WHERE clause term pTerm is of a form where it\n** could be used with an index to access pSrc, assuming an appropriate\n** index existed.\n*/\nstatic int termCanDriveIndex(\n  WhereTerm *pTerm,              /* WHERE clause term to check */\n  struct SrcList_item *pSrc,     /* Table we are trying to access */\n  Bitmask notReady               /* Tables in outer loops of the join */\n){\n  char aff;\n  if( pTerm->leftCursor!=pSrc->iCursor ) return 0;\n  if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) return 0;\n  if( (pSrc->fg.jointype & JT_LEFT) \n   && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n   && (pTerm->eOperator & WO_IS)\n  ){\n    /* Cannot use an IS term from the WHERE clause as an index driver for\n    ** the RHS of a LEFT JOIN. Such a term can only be used if it is from\n    ** the ON clause.  */\n    return 0;\n  }\n  if( (pTerm->prereqRight & notReady)!=0 ) return 0;\n  if( pTerm->u.leftColumn<0 ) return 0;\n  aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;\n  if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;\n  testcase( pTerm->pExpr->op==TK_IS );\n  return 1;\n}\n#endif\n\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n/*\n** Generate code to construct the Index object for an automatic index\n** and to set up the WhereLevel object pLevel so that the code generator\n** makes use of the automatic index.\n*/\nstatic void constructAutomaticIndex(\n  Parse *pParse,              /* The parsing context */\n  WhereClause *pWC,           /* The WHERE clause */\n  struct SrcList_item *pSrc,  /* The FROM clause term to get the next index */\n  Bitmask notReady,           /* Mask of cursors that are not available */\n  WhereLevel *pLevel          /* Write new index here */\n){\n  int nKeyCol;                /* Number of columns in the constructed index */\n  WhereTerm *pTerm;           /* A single term of the WHERE clause */\n  WhereTerm *pWCEnd;          /* End of pWC->a[] */\n  Index *pIdx;                /* Object describing the transient index */\n  Vdbe *v;                    /* Prepared statement under construction */\n  int addrInit;               /* Address of the initialization bypass jump */\n  Table *pTable;              /* The table being indexed */\n  int addrTop;                /* Top of the index fill loop */\n  int regRecord;              /* Register holding an index record */\n  int n;                      /* Column counter */\n  int i;                      /* Loop counter */\n  int mxBitCol;               /* Maximum column in pSrc->colUsed */\n  CollSeq *pColl;             /* Collating sequence to on a column */\n  WhereLoop *pLoop;           /* The Loop object */\n  char *zNotUsed;             /* Extra space on the end of pIdx */\n  Bitmask idxCols;            /* Bitmap of columns used for indexing */\n  Bitmask extraCols;          /* Bitmap of additional columns */\n  u8 sentWarning = 0;         /* True if a warnning has been issued */\n  Expr *pPartial = 0;         /* Partial Index Expression */\n  int iContinue = 0;          /* Jump here to skip excluded rows */\n  struct SrcList_item *pTabItem;  /* FROM clause term being indexed */\n  int addrCounter = 0;        /* Address where integer counter is initialized */\n  int regBase;                /* Array of registers where record is assembled */\n\n  /* Generate code to skip over the creation and initialization of the\n  ** transient index on 2nd and subsequent iterations of the loop. */\n  v = pParse->pVdbe;\n  assert( v!=0 );\n  addrInit = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);\n\n  /* Count the number of columns that will be added to the index\n  ** and used to match WHERE clause constraints */\n  nKeyCol = 0;\n  pTable = pSrc->pTab;\n  pWCEnd = &pWC->a[pWC->nTerm];\n  pLoop = pLevel->pWLoop;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    assert( !ExprHasProperty(pExpr, EP_FromJoin)    /* prereq always non-zero */\n         || pExpr->iRightJoinTable!=pSrc->iCursor   /*   for the right-hand   */\n         || pLoop->prereq!=0 );                     /*   table of a LEFT JOIN */\n    if( pLoop->prereq==0\n     && (pTerm->wtFlags & TERM_VIRTUAL)==0\n     && !ExprHasProperty(pExpr, EP_FromJoin)\n     && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){\n      pPartial = sqlite3ExprAnd(pParse->db, pPartial,\n                                sqlite3ExprDup(pParse->db, pExpr, 0));\n    }\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS );\n      testcase( iCol==BMS-1 );\n      if( !sentWarning ){\n        sqlite3_log(SQLITE_WARNING_AUTOINDEX,\n            \"automatic index on %s(%s)\", pTable->zName,\n            pTable->aCol[iCol].zName);\n        sentWarning = 1;\n      }\n      if( (idxCols & cMask)==0 ){\n        if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ){\n          goto end_auto_index_create;\n        }\n        pLoop->aLTerm[nKeyCol++] = pTerm;\n        idxCols |= cMask;\n      }\n    }\n  }\n  assert( nKeyCol>0 );\n  pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol;\n  pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED\n                     | WHERE_AUTO_INDEX;\n\n  /* Count the number of additional columns needed to create a\n  ** covering index.  A \"covering index\" is an index that contains all\n  ** columns that are needed by the query.  With a covering index, the\n  ** original table never needs to be accessed.  Automatic indices must\n  ** be a covering index because the index will not be updated if the\n  ** original table changes and the index and table cannot both be used\n  ** if they go out of sync.\n  */\n  extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));\n  mxBitCol = MIN(BMS-1,pTable->nCol);\n  testcase( pTable->nCol==BMS-1 );\n  testcase( pTable->nCol==BMS-2 );\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ) nKeyCol++;\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    nKeyCol += pTable->nCol - BMS + 1;\n  }\n\n  /* Construct the Index object to describe this index */\n  pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);\n  if( pIdx==0 ) goto end_auto_index_create;\n  pLoop->u.btree.pIndex = pIdx;\n  pIdx->zName = \"auto-index\";\n  pIdx->pTable = pTable;\n  n = 0;\n  idxCols = 0;\n  for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){\n    if( termCanDriveIndex(pTerm, pSrc, notReady) ){\n      int iCol = pTerm->u.leftColumn;\n      Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);\n      testcase( iCol==BMS-1 );\n      testcase( iCol==BMS );\n      if( (idxCols & cMask)==0 ){\n        Expr *pX = pTerm->pExpr;\n        idxCols |= cMask;\n        pIdx->aiColumn[n] = pTerm->u.leftColumn;\n        pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);\n        pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;\n        n++;\n      }\n    }\n  }\n  assert( (u32)n==pLoop->u.btree.nEq );\n\n  /* Add additional columns needed to make the automatic index into\n  ** a covering index */\n  for(i=0; i<mxBitCol; i++){\n    if( extraCols & MASKBIT(i) ){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  if( pSrc->colUsed & MASKBIT(BMS-1) ){\n    for(i=BMS-1; i<pTable->nCol; i++){\n      pIdx->aiColumn[n] = i;\n      pIdx->azColl[n] = sqlite3StrBINARY;\n      n++;\n    }\n  }\n  assert( n==nKeyCol );\n  pIdx->aiColumn[n] = XN_ROWID;\n  pIdx->azColl[n] = sqlite3StrBINARY;\n\n  /* Create the automatic index */\n  assert( pLevel->iIdxCur>=0 );\n  pLevel->iIdxCur = pParse->nTab++;\n  sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);\n  sqlite3VdbeSetP4KeyInfo(pParse, pIdx);\n  VdbeComment((v, \"for %s\", pTable->zName));\n\n  /* Fill the automatic index with content */\n  sqlite3ExprCachePush(pParse);\n  pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    addrCounter = sqlite3VdbeAddOp2(v, OP_Integer, 0, 0);\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    addrTop =  sqlite3VdbeAddOp1(v, OP_Yield, regYield);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of \\\"%s\\\"\", pTabItem->pTab->zName));\n  }else{\n    addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);\n  }\n  if( pPartial ){\n    iContinue = sqlite3VdbeMakeLabel(v);\n    sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);\n    pLoop->wsFlags |= WHERE_PARTIALIDX;\n  }\n  regRecord = sqlite3GetTempReg(pParse);\n  regBase = sqlite3GenerateIndexKey(\n      pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0\n  );\n  sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);\n  sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n  if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);\n  if( pTabItem->fg.viaCoroutine ){\n    sqlite3VdbeChangeP2(v, addrCounter, regBase+n);\n    testcase( pParse->db->mallocFailed );\n    translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,\n                          pTabItem->regResult, 1);\n    sqlite3VdbeGoto(v, addrTop);\n    pTabItem->fg.viaCoroutine = 0;\n  }else{\n    sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);\n  }\n  sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);\n  sqlite3VdbeJumpHere(v, addrTop);\n  sqlite3ReleaseTempReg(pParse, regRecord);\n  sqlite3ExprCachePop(pParse);\n  \n  /* Jump here when skipping the initialization */\n  sqlite3VdbeJumpHere(v, addrInit);\n\nend_auto_index_create:\n  sqlite3ExprDelete(pParse->db, pPartial);\n}\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Allocate and populate an sqlite3_index_info structure. It is the \n** responsibility of the caller to eventually release the structure\n** by passing the pointer returned by this function to sqlite3_free().\n*/\nstatic sqlite3_index_info *allocateIndexInfo(\n  Parse *pParse,\n  WhereClause *pWC,\n  Bitmask mUnusable,              /* Ignore terms with these prereqs */\n  struct SrcList_item *pSrc,\n  ExprList *pOrderBy,\n  u16 *pmNoOmit                   /* Mask of terms not to omit */\n){\n  int i, j;\n  int nTerm;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_orderby *pIdxOrderBy;\n  struct sqlite3_index_constraint_usage *pUsage;\n  WhereTerm *pTerm;\n  int nOrderBy;\n  sqlite3_index_info *pIdxInfo;\n  u16 mNoOmit = 0;\n\n  /* Count the number of possible WHERE clause constraints referring\n  ** to this virtual table */\n  for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    assert( pTerm->u.leftColumn>=(-1) );\n    nTerm++;\n  }\n\n  /* If the ORDER BY clause contains only columns in the current \n  ** virtual table then allocate space for the aOrderBy part of\n  ** the sqlite3_index_info structure.\n  */\n  nOrderBy = 0;\n  if( pOrderBy ){\n    int n = pOrderBy->nExpr;\n    for(i=0; i<n; i++){\n      Expr *pExpr = pOrderBy->a[i].pExpr;\n      if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;\n    }\n    if( i==n){\n      nOrderBy = n;\n    }\n  }\n\n  /* Allocate the sqlite3_index_info structure\n  */\n  pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)\n                           + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm\n                           + sizeof(*pIdxOrderBy)*nOrderBy );\n  if( pIdxInfo==0 ){\n    sqlite3ErrorMsg(pParse, \"out of memory\");\n    return 0;\n  }\n\n  /* Initialize the structure.  The sqlite3_index_info structure contains\n  ** many fields that are declared \"const\" to prevent xBestIndex from\n  ** changing them.  We have to do some funky casting in order to\n  ** initialize those fields.\n  */\n  pIdxCons = (struct sqlite3_index_constraint*)&pIdxInfo[1];\n  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];\n  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];\n  *(int*)&pIdxInfo->nConstraint = nTerm;\n  *(int*)&pIdxInfo->nOrderBy = nOrderBy;\n  *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons;\n  *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy;\n  *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =\n                                                                   pUsage;\n\n  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    u16 op;\n    if( pTerm->leftCursor != pSrc->iCursor ) continue;\n    if( pTerm->prereqRight & mUnusable ) continue;\n    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );\n    testcase( pTerm->eOperator & WO_IN );\n    testcase( pTerm->eOperator & WO_IS );\n    testcase( pTerm->eOperator & WO_ISNULL );\n    testcase( pTerm->eOperator & WO_ALL );\n    if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;\n    if( pTerm->wtFlags & TERM_VNULL ) continue;\n    assert( pTerm->u.leftColumn>=(-1) );\n    pIdxCons[j].iColumn = pTerm->u.leftColumn;\n    pIdxCons[j].iTermOffset = i;\n    op = pTerm->eOperator & WO_ALL;\n    if( op==WO_IN ) op = WO_EQ;\n    if( op==WO_AUX ){\n      pIdxCons[j].op = pTerm->eMatchOp;\n    }else if( op & (WO_ISNULL|WO_IS) ){\n      if( op==WO_ISNULL ){\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL;\n      }else{\n        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS;\n      }\n    }else{\n      pIdxCons[j].op = (u8)op;\n      /* The direct assignment in the previous line is possible only because\n      ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The\n      ** following asserts verify this fact. */\n      assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );\n      assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT );\n      assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );\n      assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );\n      assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );\n      assert( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );\n\n      if( op & (WO_LT|WO_LE|WO_GT|WO_GE)\n       && sqlite3ExprIsVector(pTerm->pExpr->pRight) \n      ){\n        if( i<16 ) mNoOmit |= (1 << i);\n        if( op==WO_LT ) pIdxCons[j].op = WO_LE;\n        if( op==WO_GT ) pIdxCons[j].op = WO_GE;\n      }\n    }\n\n    j++;\n  }\n  for(i=0; i<nOrderBy; i++){\n    Expr *pExpr = pOrderBy->a[i].pExpr;\n    pIdxOrderBy[i].iColumn = pExpr->iColumn;\n    pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;\n  }\n\n  *pmNoOmit = mNoOmit;\n  return pIdxInfo;\n}\n\n/*\n** The table object reference passed as the second argument to this function\n** must represent a virtual table. This function invokes the xBestIndex()\n** method of the virtual table with the sqlite3_index_info object that\n** comes in as the 3rd argument to this function.\n**\n** If an error occurs, pParse is populated with an error message and a\n** non-zero value is returned. Otherwise, 0 is returned and the output\n** part of the sqlite3_index_info structure is left populated.\n**\n** Whether or not an error is returned, it is the responsibility of the\n** caller to eventually free p->idxStr if p->needToFreeIdxStr indicates\n** that this is required.\n*/\nstatic int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){\n  sqlite3_vtab *pVtab = sqlite3GetVTable(pParse->db, pTab)->pVtab;\n  int rc;\n\n  TRACE_IDX_INPUTS(p);\n  rc = pVtab->pModule->xBestIndex(pVtab, p);\n  TRACE_IDX_OUTPUTS(p);\n\n  if( rc!=SQLITE_OK ){\n    if( rc==SQLITE_NOMEM ){\n      sqlite3OomFault(pParse->db);\n    }else if( !pVtab->zErrMsg ){\n      sqlite3ErrorMsg(pParse, \"%s\", sqlite3ErrStr(rc));\n    }else{\n      sqlite3ErrorMsg(pParse, \"%s\", pVtab->zErrMsg);\n    }\n  }\n  sqlite3_free(pVtab->zErrMsg);\n  pVtab->zErrMsg = 0;\n\n#if 0\n  /* This error is now caught by the caller.\n  ** Search for \"xBestIndex malfunction\" below */\n  for(i=0; i<p->nConstraint; i++){\n    if( !p->aConstraint[i].usable && p->aConstraintUsage[i].argvIndex>0 ){\n      sqlite3ErrorMsg(pParse, \n          \"table %s: xBestIndex returned an invalid plan\", pTab->zName);\n    }\n  }\n#endif\n\n  return pParse->nErr;\n}\n#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the location of a particular key among all keys in an\n** index.  Store the results in aStat as follows:\n**\n**    aStat[0]      Est. number of rows less than pRec\n**    aStat[1]      Est. number of rows equal to pRec\n**\n** Return the index of the sample that is the smallest sample that\n** is greater than or equal to pRec. Note that this index is not an index\n** into the aSample[] array - it is an index into a virtual set of samples\n** based on the contents of aSample[] and the number of fields in record \n** pRec. \n*/\nstatic int whereKeyStats(\n  Parse *pParse,              /* Database connection */\n  Index *pIdx,                /* Index to consider domain of */\n  UnpackedRecord *pRec,       /* Vector of values to consider */\n  int roundUp,                /* Round up if true.  Round down if false */\n  tRowcnt *aStat              /* OUT: stats written here */\n){\n  IndexSample *aSample = pIdx->aSample;\n  int iCol;                   /* Index of required stats in anEq[] etc. */\n  int i;                      /* Index of first sample >= pRec */\n  int iSample;                /* Smallest sample larger than or equal to pRec */\n  int iMin = 0;               /* Smallest sample not yet tested */\n  int iTest;                  /* Next sample to test */\n  int res;                    /* Result of comparison operation */\n  int nField;                 /* Number of fields in pRec */\n  tRowcnt iLower = 0;         /* anLt[] + anEq[] of largest sample pRec is > */\n\n#ifndef SQLITE_DEBUG\n  UNUSED_PARAMETER( pParse );\n#endif\n  assert( pRec!=0 );\n  assert( pIdx->nSample>0 );\n  assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );\n\n  /* Do a binary search to find the first sample greater than or equal\n  ** to pRec. If pRec contains a single field, the set of samples to search\n  ** is simply the aSample[] array. If the samples in aSample[] contain more\n  ** than one fields, all fields following the first are ignored.\n  **\n  ** If pRec contains N fields, where N is more than one, then as well as the\n  ** samples in aSample[] (truncated to N fields), the search also has to\n  ** consider prefixes of those samples. For example, if the set of samples\n  ** in aSample is:\n  **\n  **     aSample[0] = (a, 5) \n  **     aSample[1] = (a, 10) \n  **     aSample[2] = (b, 5) \n  **     aSample[3] = (c, 100) \n  **     aSample[4] = (c, 105)\n  **\n  ** Then the search space should ideally be the samples above and the \n  ** unique prefixes [a], [b] and [c]. But since that is hard to organize, \n  ** the code actually searches this set:\n  **\n  **     0: (a) \n  **     1: (a, 5) \n  **     2: (a, 10) \n  **     3: (a, 10) \n  **     4: (b) \n  **     5: (b, 5) \n  **     6: (c) \n  **     7: (c, 100) \n  **     8: (c, 105)\n  **     9: (c, 105)\n  **\n  ** For each sample in the aSample[] array, N samples are present in the\n  ** effective sample array. In the above, samples 0 and 1 are based on \n  ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.\n  **\n  ** Often, sample i of each block of N effective samples has (i+1) fields.\n  ** Except, each sample may be extended to ensure that it is greater than or\n  ** equal to the previous sample in the array. For example, in the above, \n  ** sample 2 is the first sample of a block of N samples, so at first it \n  ** appears that it should be 1 field in size. However, that would make it \n  ** smaller than sample 1, so the binary search would not work. As a result, \n  ** it is extended to two fields. The duplicates that this creates do not \n  ** cause any problems.\n  */\n  nField = pRec->nField;\n  iCol = 0;\n  iSample = pIdx->nSample * nField;\n  do{\n    int iSamp;                    /* Index in aSample[] of test sample */\n    int n;                        /* Number of fields in test sample */\n\n    iTest = (iMin+iSample)/2;\n    iSamp = iTest / nField;\n    if( iSamp>0 ){\n      /* The proposed effective sample is a prefix of sample aSample[iSamp].\n      ** Specifically, the shortest prefix of at least (1 + iTest%nField) \n      ** fields that is greater than the previous effective sample.  */\n      for(n=(iTest % nField) + 1; n<nField; n++){\n        if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;\n      }\n    }else{\n      n = iTest + 1;\n    }\n\n    pRec->nField = n;\n    res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);\n    if( res<0 ){\n      iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];\n      iMin = iTest+1;\n    }else if( res==0 && n<nField ){\n      iLower = aSample[iSamp].anLt[n-1];\n      iMin = iTest+1;\n      res = -1;\n    }else{\n      iSample = iTest;\n      iCol = n-1;\n    }\n  }while( res && iMin<iSample );\n  i = iSample / nField;\n\n#ifdef SQLITE_DEBUG\n  /* The following assert statements check that the binary search code\n  ** above found the right answer. This block serves no purpose other\n  ** than to invoke the asserts.  */\n  if( pParse->db->mallocFailed==0 ){\n    if( res==0 ){\n      /* If (res==0) is true, then pRec must be equal to sample i. */\n      assert( i<pIdx->nSample );\n      assert( iCol==nField-1 );\n      pRec->nField = nField;\n      assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec) \n           || pParse->db->mallocFailed \n      );\n    }else{\n      /* Unless i==pIdx->nSample, indicating that pRec is larger than\n      ** all samples in the aSample[] array, pRec must be smaller than the\n      ** (iCol+1) field prefix of sample i.  */\n      assert( i<=pIdx->nSample && i>=0 );\n      pRec->nField = iCol+1;\n      assert( i==pIdx->nSample \n           || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0\n           || pParse->db->mallocFailed );\n\n      /* if i==0 and iCol==0, then record pRec is smaller than all samples\n      ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must\n      ** be greater than or equal to the (iCol) field prefix of sample i.\n      ** If (i>0), then pRec must also be greater than sample (i-1).  */\n      if( iCol>0 ){\n        pRec->nField = iCol;\n        assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0\n             || pParse->db->mallocFailed );\n      }\n      if( i>0 ){\n        pRec->nField = nField;\n        assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0\n             || pParse->db->mallocFailed );\n      }\n    }\n  }\n#endif /* ifdef SQLITE_DEBUG */\n\n  if( res==0 ){\n    /* Record pRec is equal to sample i */\n    assert( iCol==nField-1 );\n    aStat[0] = aSample[i].anLt[iCol];\n    aStat[1] = aSample[i].anEq[iCol];\n  }else{\n    /* At this point, the (iCol+1) field prefix of aSample[i] is the first \n    ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec\n    ** is larger than all samples in the array. */\n    tRowcnt iUpper, iGap;\n    if( i>=pIdx->nSample ){\n      iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);\n    }else{\n      iUpper = aSample[i].anLt[iCol];\n    }\n\n    if( iLower>=iUpper ){\n      iGap = 0;\n    }else{\n      iGap = iUpper - iLower;\n    }\n    if( roundUp ){\n      iGap = (iGap*2)/3;\n    }else{\n      iGap = iGap/3;\n    }\n    aStat[0] = iLower + iGap;\n    aStat[1] = pIdx->aAvgEq[nField-1];\n  }\n\n  /* Restore the pRec->nField value before returning.  */\n  pRec->nField = nField;\n  return i;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** If it is not NULL, pTerm is a term that provides an upper or lower\n** bound on a range scan. Without considering pTerm, it is estimated \n** that the scan will visit nNew rows. This function returns the number\n** estimated to be visited after taking pTerm into account.\n**\n** If the user explicitly specified a likelihood() value for this term,\n** then the return value is the likelihood multiplied by the number of\n** input rows. Otherwise, this function assumes that an \"IS NOT NULL\" term\n** has a likelihood of 0.50, and any other term a likelihood of 0.25.\n*/\nstatic LogEst whereRangeAdjust(WhereTerm *pTerm, LogEst nNew){\n  LogEst nRet = nNew;\n  if( pTerm ){\n    if( pTerm->truthProb<=0 ){\n      nRet += pTerm->truthProb;\n    }else if( (pTerm->wtFlags & TERM_VNULL)==0 ){\n      nRet -= 20;        assert( 20==sqlite3LogEst(4) );\n    }\n  }\n  return nRet;\n}\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Return the affinity for a single column of an index.\n*/\nchar sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){\n  assert( iCol>=0 && iCol<pIdx->nColumn );\n  if( !pIdx->zColAff ){\n    if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB;\n  }\n  return pIdx->zColAff[iCol];\n}\n#endif\n\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/* \n** This function is called to estimate the number of rows visited by a\n** range-scan on a skip-scan index. For example:\n**\n**   CREATE INDEX i1 ON t1(a, b, c);\n**   SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?;\n**\n** Value pLoop->nOut is currently set to the estimated number of rows \n** visited for scanning (a=? AND b=?). This function reduces that estimate \n** by some factor to account for the (c BETWEEN ? AND ?) expression based\n** on the stat4 data for the index. this scan will be peformed multiple \n** times (once for each (a,b) combination that matches a=?) is dealt with \n** by the caller.\n**\n** It does this by scanning through all stat4 samples, comparing values\n** extracted from pLower and pUpper with the corresponding column in each\n** sample. If L and U are the number of samples found to be less than or\n** equal to the values extracted from pLower and pUpper respectively, and\n** N is the total number of samples, the pLoop->nOut value is adjusted\n** as follows:\n**\n**   nOut = nOut * ( min(U - L, 1) / N )\n**\n** If pLower is NULL, or a value cannot be extracted from the term, L is\n** set to zero. If pUpper is NULL, or a value cannot be extracted from it,\n** U is set to N.\n**\n** Normally, this function sets *pbDone to 1 before returning. However,\n** if no value can be extracted from either pLower or pUpper (and so the\n** estimate of the number of rows delivered remains unchanged), *pbDone\n** is left as is.\n**\n** If an error occurs, an SQLite error code is returned. Otherwise, \n** SQLITE_OK.\n*/\nstatic int whereRangeSkipScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop,    /* Update the .nOut value of this loop */\n  int *pbDone          /* Set to true if at least one expr. value extracted */\n){\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n  sqlite3 *db = pParse->db;\n  int nLower = -1;\n  int nUpper = p->nSample+1;\n  int rc = SQLITE_OK;\n  u8 aff = sqlite3IndexColumnAffinity(db, p, nEq);\n  CollSeq *pColl;\n  \n  sqlite3_value *p1 = 0;          /* Value extracted from pLower */\n  sqlite3_value *p2 = 0;          /* Value extracted from pUpper */\n  sqlite3_value *pVal = 0;        /* Value extracted from record */\n\n  pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]);\n  if( pLower ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);\n    nLower = 0;\n  }\n  if( pUpper && rc==SQLITE_OK ){\n    rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);\n    nUpper = p2 ? 0 : p->nSample;\n  }\n\n  if( p1 || p2 ){\n    int i;\n    int nDiff;\n    for(i=0; rc==SQLITE_OK && i<p->nSample; i++){\n      rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal);\n      if( rc==SQLITE_OK && p1 ){\n        int res = sqlite3MemCompare(p1, pVal, pColl);\n        if( res>=0 ) nLower++;\n      }\n      if( rc==SQLITE_OK && p2 ){\n        int res = sqlite3MemCompare(p2, pVal, pColl);\n        if( res>=0 ) nUpper++;\n      }\n    }\n    nDiff = (nUpper - nLower);\n    if( nDiff<=0 ) nDiff = 1;\n\n    /* If there is both an upper and lower bound specified, and the \n    ** comparisons indicate that they are close together, use the fallback\n    ** method (assume that the scan visits 1/64 of the rows) for estimating\n    ** the number of rows visited. Otherwise, estimate the number of rows\n    ** using the method described in the header comment for this function. */\n    if( nDiff!=1 || pUpper==0 || pLower==0 ){\n      int nAdjust = (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff));\n      pLoop->nOut -= nAdjust;\n      *pbDone = 1;\n      WHERETRACE(0x10, (\"range skip-scan regions: %u..%u  adjust=%d est=%d\\n\",\n                           nLower, nUpper, nAdjust*-1, pLoop->nOut));\n    }\n\n  }else{\n    assert( *pbDone==0 );\n  }\n\n  sqlite3ValueFree(p1);\n  sqlite3ValueFree(p2);\n  sqlite3ValueFree(pVal);\n\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n/*\n** This function is used to estimate the number of rows that will be visited\n** by scanning an index for a range of values. The range may have an upper\n** bound, a lower bound, or both. The WHERE clause terms that set the upper\n** and lower bounds are represented by pLower and pUpper respectively. For\n** example, assuming that index p is on t1(a):\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**                    |_____|   |_____|\n**                       |         |\n**                     pLower    pUpper\n**\n** If either of the upper or lower bound is not present, then NULL is passed in\n** place of the corresponding WhereTerm.\n**\n** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index\n** column subject to the range constraint. Or, equivalently, the number of\n** equality constraints optimized by the proposed index scan. For example,\n** assuming index p is on t1(a, b), and the SQL query is:\n**\n**   ... FROM t1 WHERE a = ? AND b > ? AND b < ? ...\n**\n** then nEq is set to 1 (as the range restricted column, b, is the second \n** left-most column of the index). Or, if the query is:\n**\n**   ... FROM t1 WHERE a > ? AND a < ? ...\n**\n** then nEq is set to 0.\n**\n** When this function is called, *pnOut is set to the sqlite3LogEst() of the\n** number of rows that the index scan is expected to visit without \n** considering the range constraints. If nEq is 0, then *pnOut is the number of \n** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)\n** to account for the range constraints pLower and pUpper.\n** \n** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be\n** used, a single range inequality reduces the search space by a factor of 4. \n** and a pair of constraints (x>? AND x<?) reduces the expected number of\n** rows visited by a factor of 64.\n*/\nstatic int whereRangeScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  WhereTerm *pLower,   /* Lower bound on the range. ex: \"x>123\" Might be NULL */\n  WhereTerm *pUpper,   /* Upper bound on the range. ex: \"x<455\" Might be NULL */\n  WhereLoop *pLoop     /* Modify the .nOut and maybe .rRun fields */\n){\n  int rc = SQLITE_OK;\n  int nOut = pLoop->nOut;\n  LogEst nNew;\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  Index *p = pLoop->u.btree.pIndex;\n  int nEq = pLoop->u.btree.nEq;\n\n  if( p->nSample>0 && nEq<p->nSampleCol ){\n    if( nEq==pBuilder->nRecValid ){\n      UnpackedRecord *pRec = pBuilder->pRec;\n      tRowcnt a[2];\n      int nBtm = pLoop->u.btree.nBtm;\n      int nTop = pLoop->u.btree.nTop;\n\n      /* Variable iLower will be set to the estimate of the number of rows in \n      ** the index that are less than the lower bound of the range query. The\n      ** lower bound being the concatenation of $P and $L, where $P is the\n      ** key-prefix formed by the nEq values matched against the nEq left-most\n      ** columns of the index, and $L is the value in pLower.\n      **\n      ** Or, if pLower is NULL or $L cannot be extracted from it (because it\n      ** is not a simple variable or literal value), the lower bound of the\n      ** range is $P. Due to a quirk in the way whereKeyStats() works, even\n      ** if $L is available, whereKeyStats() is called for both ($P) and \n      ** ($P:$L) and the larger of the two returned values is used.\n      **\n      ** Similarly, iUpper is to be set to the estimate of the number of rows\n      ** less than the upper bound of the range query. Where the upper bound\n      ** is either ($P) or ($P:$U). Again, even if $U is available, both values\n      ** of iUpper are requested of whereKeyStats() and the smaller used.\n      **\n      ** The number of rows between the two bounds is then just iUpper-iLower.\n      */\n      tRowcnt iLower;     /* Rows less than the lower bound */\n      tRowcnt iUpper;     /* Rows less than the upper bound */\n      int iLwrIdx = -2;   /* aSample[] for the lower bound */\n      int iUprIdx = -1;   /* aSample[] for the upper bound */\n\n      if( pRec ){\n        testcase( pRec->nField!=pBuilder->nRecValid );\n        pRec->nField = pBuilder->nRecValid;\n      }\n      /* Determine iLower and iUpper using ($P) only. */\n      if( nEq==0 ){\n        iLower = 0;\n        iUpper = p->nRowEst0;\n      }else{\n        /* Note: this call could be optimized away - since the same values must \n        ** have been requested when testing key $P in whereEqualScanEst().  */\n        whereKeyStats(pParse, p, pRec, 0, a);\n        iLower = a[0];\n        iUpper = a[0] + a[1];\n      }\n\n      assert( pLower==0 || (pLower->eOperator & (WO_GT|WO_GE))!=0 );\n      assert( pUpper==0 || (pUpper->eOperator & (WO_LT|WO_LE))!=0 );\n      assert( p->aSortOrder!=0 );\n      if( p->aSortOrder[nEq] ){\n        /* The roles of pLower and pUpper are swapped for a DESC index */\n        SWAP(WhereTerm*, pLower, pUpper);\n        SWAP(int, nBtm, nTop);\n      }\n\n      /* If possible, improve on the iLower estimate using ($P:$L). */\n      if( pLower ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pLower->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nBtm, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);\n          iNew = a[0] + ((pLower->eOperator & mask) ? a[1] : 0);\n          if( iNew>iLower ) iLower = iNew;\n          nOut--;\n          pLower = 0;\n        }\n      }\n\n      /* If possible, improve on the iUpper estimate using ($P:$U). */\n      if( pUpper ){\n        int n;                    /* Values extracted from pExpr */\n        Expr *pExpr = pUpper->pExpr->pRight;\n        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, nTop, nEq, &n);\n        if( rc==SQLITE_OK && n ){\n          tRowcnt iNew;\n          u16 mask = WO_GT|WO_LE;\n          if( sqlite3ExprVectorSize(pExpr)>n ) mask = (WO_LE|WO_LT);\n          iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);\n          iNew = a[0] + ((pUpper->eOperator & mask) ? a[1] : 0);\n          if( iNew<iUpper ) iUpper = iNew;\n          nOut--;\n          pUpper = 0;\n        }\n      }\n\n      pBuilder->pRec = pRec;\n      if( rc==SQLITE_OK ){\n        if( iUpper>iLower ){\n          nNew = sqlite3LogEst(iUpper - iLower);\n          /* TUNING:  If both iUpper and iLower are derived from the same\n          ** sample, then assume they are 4x more selective.  This brings\n          ** the estimated selectivity more in line with what it would be\n          ** if estimated without the use of STAT3/4 tables. */\n          if( iLwrIdx==iUprIdx ) nNew -= 20;  assert( 20==sqlite3LogEst(4) );\n        }else{\n          nNew = 10;        assert( 10==sqlite3LogEst(2) );\n        }\n        if( nNew<nOut ){\n          nOut = nNew;\n        }\n        WHERETRACE(0x10, (\"STAT4 range scan: %u..%u  est=%d\\n\",\n                           (u32)iLower, (u32)iUpper, nOut));\n      }\n    }else{\n      int bDone = 0;\n      rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone);\n      if( bDone ) return rc;\n    }\n  }\n#else\n  UNUSED_PARAMETER(pParse);\n  UNUSED_PARAMETER(pBuilder);\n  assert( pLower || pUpper );\n#endif\n  assert( pUpper==0 || (pUpper->wtFlags & TERM_VNULL)==0 );\n  nNew = whereRangeAdjust(pLower, nOut);\n  nNew = whereRangeAdjust(pUpper, nNew);\n\n  /* TUNING: If there is both an upper and lower limit and neither limit\n  ** has an application-defined likelihood(), assume the range is\n  ** reduced by an additional 75%. This means that, by default, an open-ended\n  ** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the\n  ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to\n  ** match 1/64 of the index. */ \n  if( pLower && pLower->truthProb>0 && pUpper && pUpper->truthProb>0 ){\n    nNew -= 20;\n  }\n\n  nOut -= (pLower!=0) + (pUpper!=0);\n  if( nNew<10 ) nNew = 10;\n  if( nNew<nOut ) nOut = nNew;\n#if defined(WHERETRACE_ENABLED)\n  if( pLoop->nOut>nOut ){\n    WHERETRACE(0x10,(\"Range scan lowers nOut from %d to %d\\n\",\n                    pLoop->nOut, nOut));\n  }\n#endif\n  pLoop->nOut = (LogEst)nOut;\n  return rc;\n}\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an equality constraint x=VALUE and where that VALUE occurs in\n** the histogram data.  This only works when x is the left-most\n** column of an index and sqlite_stat3 histogram data is available\n** for that index.  When pExpr==NULL that means the constraint is\n** \"x IS NULL\" instead of \"x=VALUE\".\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereEqualScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  Expr *pExpr,         /* Expression for VALUE in the x=VALUE constraint */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  int nEq = pBuilder->pNew->u.btree.nEq;\n  UnpackedRecord *pRec = pBuilder->pRec;\n  int rc;                   /* Subfunction return code */\n  tRowcnt a[2];             /* Statistics */\n  int bOk;\n\n  assert( nEq>=1 );\n  assert( nEq<=p->nColumn );\n  assert( p->aSample!=0 );\n  assert( p->nSample>0 );\n  assert( pBuilder->nRecValid<nEq );\n\n  /* If values are not available for all fields of the index to the left\n  ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */\n  if( pBuilder->nRecValid<(nEq-1) ){\n    return SQLITE_NOTFOUND;\n  }\n\n  /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue()\n  ** below would return the same value.  */\n  if( nEq>=p->nColumn ){\n    *pnRow = 1;\n    return SQLITE_OK;\n  }\n\n  rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, 1, nEq-1, &bOk);\n  pBuilder->pRec = pRec;\n  if( rc!=SQLITE_OK ) return rc;\n  if( bOk==0 ) return SQLITE_NOTFOUND;\n  pBuilder->nRecValid = nEq;\n\n  whereKeyStats(pParse, p, pRec, 0, a);\n  WHERETRACE(0x10,(\"equality scan regions %s(%d): %d\\n\",\n                   p->zName, nEq-1, (int)a[1]));\n  *pnRow = a[1];\n  \n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n/*\n** Estimate the number of rows that will be returned based on\n** an IN constraint where the right-hand side of the IN operator\n** is a list of values.  Example:\n**\n**        WHERE x IN (1,2,3,4)\n**\n** Write the estimated row count into *pnRow and return SQLITE_OK. \n** If unable to make an estimate, leave *pnRow unchanged and return\n** non-zero.\n**\n** This routine can fail if it is unable to load a collating sequence\n** required for string comparison, or if unable to allocate memory\n** for a UTF conversion required for comparison.  The error is stored\n** in the pParse structure.\n*/\nstatic int whereInScanEst(\n  Parse *pParse,       /* Parsing & code generating context */\n  WhereLoopBuilder *pBuilder,\n  ExprList *pList,     /* The value list on the RHS of \"x IN (v1,v2,v3,...)\" */\n  tRowcnt *pnRow       /* Write the revised row estimate here */\n){\n  Index *p = pBuilder->pNew->u.btree.pIndex;\n  i64 nRow0 = sqlite3LogEstToInt(p->aiRowLogEst[0]);\n  int nRecValid = pBuilder->nRecValid;\n  int rc = SQLITE_OK;     /* Subfunction return code */\n  tRowcnt nEst;           /* Number of rows for a single term */\n  tRowcnt nRowEst = 0;    /* New estimate of the number of rows */\n  int i;                  /* Loop counter */\n\n  assert( p->aSample!=0 );\n  for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){\n    nEst = nRow0;\n    rc = whereEqualScanEst(pParse, pBuilder, pList->a[i].pExpr, &nEst);\n    nRowEst += nEst;\n    pBuilder->nRecValid = nRecValid;\n  }\n\n  if( rc==SQLITE_OK ){\n    if( nRowEst > nRow0 ) nRowEst = nRow0;\n    *pnRow = nRowEst;\n    WHERETRACE(0x10,(\"IN row estimate: est=%d\\n\", nRowEst));\n  }\n  assert( pBuilder->nRecValid==nRecValid );\n  return rc;\n}\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print the content of a WhereTerm object\n*/\nstatic void whereTermPrint(WhereTerm *pTerm, int iTerm){\n  if( pTerm==0 ){\n    sqlite3DebugPrintf(\"TERM-%-3d NULL\\n\", iTerm);\n  }else{\n    char zType[4];\n    char zLeft[50];\n    memcpy(zType, \"...\", 4);\n    if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V';\n    if( pTerm->eOperator & WO_EQUIV  ) zType[1] = 'E';\n    if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';\n    if( pTerm->eOperator & WO_SINGLE ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left={%d:%d}\",\n                       pTerm->leftCursor, pTerm->u.leftColumn);\n    }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"indexable=0x%lld\", \n                       pTerm->u.pOrInfo->indexable);\n    }else{\n      sqlite3_snprintf(sizeof(zLeft),zLeft,\"left=%d\", pTerm->leftCursor);\n    }\n    sqlite3DebugPrintf(\n       \"TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\",\n       iTerm, pTerm, zType, zLeft, pTerm->truthProb,\n       pTerm->eOperator, pTerm->wtFlags);\n    if( pTerm->iField ){\n      sqlite3DebugPrintf(\" iField=%d\\n\", pTerm->iField);\n    }else{\n      sqlite3DebugPrintf(\"\\n\");\n    }\n    sqlite3TreeViewExpr(0, pTerm->pExpr, 0);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Show the complete content of a WhereClause\n*/\nvoid sqlite3WhereClausePrint(WhereClause *pWC){\n  int i;\n  for(i=0; i<pWC->nTerm; i++){\n    whereTermPrint(&pWC->a[i], i);\n  }\n}\n#endif\n\n#ifdef WHERETRACE_ENABLED\n/*\n** Print a WhereLoop object for debugging purposes\n*/\nstatic void whereLoopPrint(WhereLoop *p, WhereClause *pWC){\n  WhereInfo *pWInfo = pWC->pWInfo;\n  int nb = 1+(pWInfo->pTabList->nSrc+3)/4;\n  struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab;\n  Table *pTab = pItem->pTab;\n  Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;\n  sqlite3DebugPrintf(\"%c%2d.%0*llx.%0*llx\", p->cId,\n                     p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);\n  sqlite3DebugPrintf(\" %12s\",\n                     pItem->zAlias ? pItem->zAlias : pTab->zName);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    const char *zName;\n    if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){\n      if( strncmp(zName, \"sqlite_autoindex_\", 17)==0 ){\n        int i = sqlite3Strlen30(zName) - 1;\n        while( zName[i]!='_' ) i--;\n        zName += i;\n      }\n      sqlite3DebugPrintf(\".%-16s %2d\", zName, p->u.btree.nEq);\n    }else{\n      sqlite3DebugPrintf(\"%20s\",\"\");\n    }\n  }else{\n    char *z;\n    if( p->u.vtab.idxStr ){\n      z = sqlite3_mprintf(\"(%d,\\\"%s\\\",%x)\",\n                p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);\n    }else{\n      z = sqlite3_mprintf(\"(%d,%x)\", p->u.vtab.idxNum, p->u.vtab.omitMask);\n    }\n    sqlite3DebugPrintf(\" %-19s\", z);\n    sqlite3_free(z);\n  }\n  if( p->wsFlags & WHERE_SKIPSCAN ){\n    sqlite3DebugPrintf(\" f %05x %d-%d\", p->wsFlags, p->nLTerm,p->nSkip);\n  }else{\n    sqlite3DebugPrintf(\" f %05x N %d\", p->wsFlags, p->nLTerm);\n  }\n  sqlite3DebugPrintf(\" cost %d,%d,%d\\n\", p->rSetup, p->rRun, p->nOut);\n  if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){\n    int i;\n    for(i=0; i<p->nLTerm; i++){\n      whereTermPrint(p->aLTerm[i], i);\n    }\n  }\n}\n#endif\n\n/*\n** Convert bulk memory into a valid WhereLoop that can be passed\n** to whereLoopClear harmlessly.\n*/\nstatic void whereLoopInit(WhereLoop *p){\n  p->aLTerm = p->aLTermSpace;\n  p->nLTerm = 0;\n  p->nLSlot = ArraySize(p->aLTermSpace);\n  p->wsFlags = 0;\n}\n\n/*\n** Clear the WhereLoop.u union.  Leave WhereLoop.pLTerm intact.\n*/\nstatic void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){\n  if( p->wsFlags & (WHERE_VIRTUALTABLE|WHERE_AUTO_INDEX) ){\n    if( (p->wsFlags & WHERE_VIRTUALTABLE)!=0 && p->u.vtab.needFree ){\n      sqlite3_free(p->u.vtab.idxStr);\n      p->u.vtab.needFree = 0;\n      p->u.vtab.idxStr = 0;\n    }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){\n      sqlite3DbFree(db, p->u.btree.pIndex->zColAff);\n      sqlite3DbFreeNN(db, p->u.btree.pIndex);\n      p->u.btree.pIndex = 0;\n    }\n  }\n}\n\n/*\n** Deallocate internal memory used by a WhereLoop object\n*/\nstatic void whereLoopClear(sqlite3 *db, WhereLoop *p){\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  whereLoopClearUnion(db, p);\n  whereLoopInit(p);\n}\n\n/*\n** Increase the memory allocation for pLoop->aLTerm[] to be at least n.\n*/\nstatic int whereLoopResize(sqlite3 *db, WhereLoop *p, int n){\n  WhereTerm **paNew;\n  if( p->nLSlot>=n ) return SQLITE_OK;\n  n = (n+7)&~7;\n  paNew = sqlite3DbMallocRawNN(db, sizeof(p->aLTerm[0])*n);\n  if( paNew==0 ) return SQLITE_NOMEM_BKPT;\n  memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0])*p->nLSlot);\n  if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm);\n  p->aLTerm = paNew;\n  p->nLSlot = n;\n  return SQLITE_OK;\n}\n\n/*\n** Transfer content from the second pLoop into the first.\n*/\nstatic int whereLoopXfer(sqlite3 *db, WhereLoop *pTo, WhereLoop *pFrom){\n  whereLoopClearUnion(db, pTo);\n  if( whereLoopResize(db, pTo, pFrom->nLTerm) ){\n    memset(&pTo->u, 0, sizeof(pTo->u));\n    return SQLITE_NOMEM_BKPT;\n  }\n  memcpy(pTo, pFrom, WHERE_LOOP_XFER_SZ);\n  memcpy(pTo->aLTerm, pFrom->aLTerm, pTo->nLTerm*sizeof(pTo->aLTerm[0]));\n  if( pFrom->wsFlags & WHERE_VIRTUALTABLE ){\n    pFrom->u.vtab.needFree = 0;\n  }else if( (pFrom->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n    pFrom->u.btree.pIndex = 0;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Delete a WhereLoop object\n*/\nstatic void whereLoopDelete(sqlite3 *db, WhereLoop *p){\n  whereLoopClear(db, p);\n  sqlite3DbFreeNN(db, p);\n}\n\n/*\n** Free a WhereInfo structure\n*/\nstatic void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){\n  if( ALWAYS(pWInfo) ){\n    int i;\n    for(i=0; i<pWInfo->nLevel; i++){\n      WhereLevel *pLevel = &pWInfo->a[i];\n      if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){\n        sqlite3DbFree(db, pLevel->u.in.aInLoop);\n      }\n    }\n    sqlite3WhereClauseClear(&pWInfo->sWC);\n    while( pWInfo->pLoops ){\n      WhereLoop *p = pWInfo->pLoops;\n      pWInfo->pLoops = p->pNextLoop;\n      whereLoopDelete(db, p);\n    }\n    sqlite3DbFreeNN(db, pWInfo);\n  }\n}\n\n/*\n** Return TRUE if all of the following are true:\n**\n**   (1)  X has the same or lower cost that Y\n**   (2)  X uses fewer WHERE clause terms than Y\n**   (3)  Every WHERE clause term used by X is also used by Y\n**   (4)  X skips at least as many columns as Y\n**   (5)  If X is a covering index, than Y is too\n**\n** Conditions (2) and (3) mean that X is a \"proper subset\" of Y.\n** If X is a proper subset of Y then Y is a better choice and ought\n** to have a lower cost.  This routine returns TRUE when that cost \n** relationship is inverted and needs to be adjusted.  Constraint (4)\n** was added because if X uses skip-scan less than Y it still might\n** deserve a lower cost even if it is a proper subset of Y.  Constraint (5)\n** was added because a covering index probably deserves to have a lower cost\n** than a non-covering index even if it is a proper subset.\n*/\nstatic int whereLoopCheaperProperSubset(\n  const WhereLoop *pX,       /* First WhereLoop to compare */\n  const WhereLoop *pY        /* Compare against this WhereLoop */\n){\n  int i, j;\n  if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){\n    return 0; /* X is not a subset of Y */\n  }\n  if( pY->nSkip > pX->nSkip ) return 0;\n  if( pX->rRun >= pY->rRun ){\n    if( pX->rRun > pY->rRun ) return 0;    /* X costs more than Y */\n    if( pX->nOut > pY->nOut ) return 0;    /* X costs more than Y */\n  }\n  for(i=pX->nLTerm-1; i>=0; i--){\n    if( pX->aLTerm[i]==0 ) continue;\n    for(j=pY->nLTerm-1; j>=0; j--){\n      if( pY->aLTerm[j]==pX->aLTerm[i] ) break;\n    }\n    if( j<0 ) return 0;  /* X not a subset of Y since term X[i] not used by Y */\n  }\n  if( (pX->wsFlags&WHERE_IDX_ONLY)!=0 \n   && (pY->wsFlags&WHERE_IDX_ONLY)==0 ){\n    return 0;  /* Constraint (5) */\n  }\n  return 1;  /* All conditions meet */\n}\n\n/*\n** Try to adjust the cost of WhereLoop pTemplate upwards or downwards so\n** that:\n**\n**   (1) pTemplate costs less than any other WhereLoops that are a proper\n**       subset of pTemplate\n**\n**   (2) pTemplate costs more than any other WhereLoops for which pTemplate\n**       is a proper subset.\n**\n** To say \"WhereLoop X is a proper subset of Y\" means that X uses fewer\n** WHERE clause terms than Y and that every WHERE clause term used by X is\n** also used by Y.\n*/\nstatic void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){\n  if( (pTemplate->wsFlags & WHERE_INDEXED)==0 ) return;\n  for(; p; p=p->pNextLoop){\n    if( p->iTab!=pTemplate->iTab ) continue;\n    if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;\n    if( whereLoopCheaperProperSubset(p, pTemplate) ){\n      /* Adjust pTemplate cost downward so that it is cheaper than its \n      ** subset p. */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut - 1;\n    }else if( whereLoopCheaperProperSubset(pTemplate, p) ){\n      /* Adjust pTemplate cost upward so that it is costlier than p since\n      ** pTemplate is a proper subset of p */\n      WHERETRACE(0x80,(\"subset cost adjustment %d,%d to %d,%d\\n\",\n                       pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut+1));\n      pTemplate->rRun = p->rRun;\n      pTemplate->nOut = p->nOut + 1;\n    }\n  }\n}\n\n/*\n** Search the list of WhereLoops in *ppPrev looking for one that can be\n** replaced by pTemplate.\n**\n** Return NULL if pTemplate does not belong on the WhereLoop list.\n** In other words if pTemplate ought to be dropped from further consideration.\n**\n** If pX is a WhereLoop that pTemplate can replace, then return the\n** link that points to pX.\n**\n** If pTemplate cannot replace any existing element of the list but needs\n** to be added to the list as a new entry, then return a pointer to the\n** tail of the list.\n*/\nstatic WhereLoop **whereLoopFindLesser(\n  WhereLoop **ppPrev,\n  const WhereLoop *pTemplate\n){\n  WhereLoop *p;\n  for(p=(*ppPrev); p; ppPrev=&p->pNextLoop, p=*ppPrev){\n    if( p->iTab!=pTemplate->iTab || p->iSortIdx!=pTemplate->iSortIdx ){\n      /* If either the iTab or iSortIdx values for two WhereLoop are different\n      ** then those WhereLoops need to be considered separately.  Neither is\n      ** a candidate to replace the other. */\n      continue;\n    }\n    /* In the current implementation, the rSetup value is either zero\n    ** or the cost of building an automatic index (NlogN) and the NlogN\n    ** is the same for compatible WhereLoops. */\n    assert( p->rSetup==0 || pTemplate->rSetup==0 \n                 || p->rSetup==pTemplate->rSetup );\n\n    /* whereLoopAddBtree() always generates and inserts the automatic index\n    ** case first.  Hence compatible candidate WhereLoops never have a larger\n    ** rSetup. Call this SETUP-INVARIANT */\n    assert( p->rSetup>=pTemplate->rSetup );\n\n    /* Any loop using an appliation-defined index (or PRIMARY KEY or\n    ** UNIQUE constraint) with one or more == constraints is better\n    ** than an automatic index. Unless it is a skip-scan. */\n    if( (p->wsFlags & WHERE_AUTO_INDEX)!=0\n     && (pTemplate->nSkip)==0\n     && (pTemplate->wsFlags & WHERE_INDEXED)!=0\n     && (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0\n     && (p->prereq & pTemplate->prereq)==pTemplate->prereq\n    ){\n      break;\n    }\n\n    /* If existing WhereLoop p is better than pTemplate, pTemplate can be\n    ** discarded.  WhereLoop p is better if:\n    **   (1)  p has no more dependencies than pTemplate, and\n    **   (2)  p has an equal or lower cost than pTemplate\n    */\n    if( (p->prereq & pTemplate->prereq)==p->prereq    /* (1)  */\n     && p->rSetup<=pTemplate->rSetup                  /* (2a) */\n     && p->rRun<=pTemplate->rRun                      /* (2b) */\n     && p->nOut<=pTemplate->nOut                      /* (2c) */\n    ){\n      return 0;  /* Discard pTemplate */\n    }\n\n    /* If pTemplate is always better than p, then cause p to be overwritten\n    ** with pTemplate.  pTemplate is better than p if:\n    **   (1)  pTemplate has no more dependences than p, and\n    **   (2)  pTemplate has an equal or lower cost than p.\n    */\n    if( (p->prereq & pTemplate->prereq)==pTemplate->prereq   /* (1)  */\n     && p->rRun>=pTemplate->rRun                             /* (2a) */\n     && p->nOut>=pTemplate->nOut                             /* (2b) */\n    ){\n      assert( p->rSetup>=pTemplate->rSetup ); /* SETUP-INVARIANT above */\n      break;   /* Cause p to be overwritten by pTemplate */\n    }\n  }\n  return ppPrev;\n}\n\n/*\n** Insert or replace a WhereLoop entry using the template supplied.\n**\n** An existing WhereLoop entry might be overwritten if the new template\n** is better and has fewer dependencies.  Or the template will be ignored\n** and no insert will occur if an existing WhereLoop is faster and has\n** fewer dependencies than the template.  Otherwise a new WhereLoop is\n** added based on the template.\n**\n** If pBuilder->pOrSet is not NULL then we care about only the\n** prerequisites and rRun and nOut costs of the N best loops.  That\n** information is gathered in the pBuilder->pOrSet object.  This special\n** processing mode is used only for OR clause processing.\n**\n** When accumulating multiple loops (when pBuilder->pOrSet is NULL) we\n** still might overwrite similar loops with the new template if the\n** new template is better.  Loops may be overwritten if the following \n** conditions are met:\n**\n**    (1)  They have the same iTab.\n**    (2)  They have the same iSortIdx.\n**    (3)  The template has same or fewer dependencies than the current loop\n**    (4)  The template has the same or lower cost than the current loop\n*/\nstatic int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){\n  WhereLoop **ppPrev, *p;\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc;\n\n  /* If pBuilder->pOrSet is defined, then only keep track of the costs\n  ** and prereqs.\n  */\n  if( pBuilder->pOrSet!=0 ){\n    if( pTemplate->nLTerm ){\n#if WHERETRACE_ENABLED\n      u16 n = pBuilder->pOrSet->n;\n      int x =\n#endif\n      whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun,\n                                    pTemplate->nOut);\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(x?\"   or-%d:  \":\"   or-X:  \", n);\n        whereLoopPrint(pTemplate, pBuilder->pWC);\n      }\n#endif\n    }\n    return SQLITE_OK;\n  }\n\n  /* Look for an existing WhereLoop to replace with pTemplate\n  */\n  whereLoopAdjustCost(pWInfo->pLoops, pTemplate);\n  ppPrev = whereLoopFindLesser(&pWInfo->pLoops, pTemplate);\n\n  if( ppPrev==0 ){\n    /* There already exists a WhereLoop on the list that is better\n    ** than pTemplate, so just ignore pTemplate */\n#if WHERETRACE_ENABLED /* 0x8 */\n    if( sqlite3WhereTrace & 0x8 ){\n      sqlite3DebugPrintf(\"   skip: \");\n      whereLoopPrint(pTemplate, pBuilder->pWC);\n    }\n#endif\n    return SQLITE_OK;  \n  }else{\n    p = *ppPrev;\n  }\n\n  /* If we reach this point it means that either p[] should be overwritten\n  ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new\n  ** WhereLoop and insert it.\n  */\n#if WHERETRACE_ENABLED /* 0x8 */\n  if( sqlite3WhereTrace & 0x8 ){\n    if( p!=0 ){\n      sqlite3DebugPrintf(\"replace: \");\n      whereLoopPrint(p, pBuilder->pWC);\n      sqlite3DebugPrintf(\"   with: \");\n    }else{\n      sqlite3DebugPrintf(\"    add: \");\n    }\n    whereLoopPrint(pTemplate, pBuilder->pWC);\n  }\n#endif\n  if( p==0 ){\n    /* Allocate a new WhereLoop to add to the end of the list */\n    *ppPrev = p = sqlite3DbMallocRawNN(db, sizeof(WhereLoop));\n    if( p==0 ) return SQLITE_NOMEM_BKPT;\n    whereLoopInit(p);\n    p->pNextLoop = 0;\n  }else{\n    /* We will be overwriting WhereLoop p[].  But before we do, first\n    ** go through the rest of the list and delete any other entries besides\n    ** p[] that are also supplated by pTemplate */\n    WhereLoop **ppTail = &p->pNextLoop;\n    WhereLoop *pToDel;\n    while( *ppTail ){\n      ppTail = whereLoopFindLesser(ppTail, pTemplate);\n      if( ppTail==0 ) break;\n      pToDel = *ppTail;\n      if( pToDel==0 ) break;\n      *ppTail = pToDel->pNextLoop;\n#if WHERETRACE_ENABLED /* 0x8 */\n      if( sqlite3WhereTrace & 0x8 ){\n        sqlite3DebugPrintf(\" delete: \");\n        whereLoopPrint(pToDel, pBuilder->pWC);\n      }\n#endif\n      whereLoopDelete(db, pToDel);\n    }\n  }\n  rc = whereLoopXfer(db, p, pTemplate);\n  if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){\n    Index *pIndex = p->u.btree.pIndex;\n    if( pIndex && pIndex->tnum==0 ){\n      p->u.btree.pIndex = 0;\n    }\n  }\n  return rc;\n}\n\n/*\n** Adjust the WhereLoop.nOut value downward to account for terms of the\n** WHERE clause that reference the loop but which are not used by an\n** index.\n*\n** For every WHERE clause term that is not used by the index\n** and which has a truth probability assigned by one of the likelihood(),\n** likely(), or unlikely() SQL functions, reduce the estimated number\n** of output rows by the probability specified.\n**\n** TUNING:  For every WHERE clause term that is not used by the index\n** and which does not have an assigned truth probability, heuristics\n** described below are used to try to estimate the truth probability.\n** TODO --> Perhaps this is something that could be improved by better\n** table statistics.\n**\n** Heuristic 1:  Estimate the truth probability as 93.75%.  The 93.75%\n** value corresponds to -1 in LogEst notation, so this means decrement\n** the WhereLoop.nOut field for every such WHERE clause term.\n**\n** Heuristic 2:  If there exists one or more WHERE clause terms of the\n** form \"x==EXPR\" and EXPR is not a constant 0 or 1, then make sure the\n** final output row estimate is no greater than 1/4 of the total number\n** of rows in the table.  In other words, assume that x==EXPR will filter\n** out at least 3 out of 4 rows.  If EXPR is -1 or 0 or 1, then maybe the\n** \"x\" column is boolean or else -1 or 0 or 1 is a common default value\n** on the \"x\" column and so in that case only cap the output row estimate\n** at 1/2 instead of 1/4.\n*/\nstatic void whereLoopOutputAdjust(\n  WhereClause *pWC,      /* The WHERE clause */\n  WhereLoop *pLoop,      /* The loop to adjust downward */\n  LogEst nRow            /* Number of rows in the entire table */\n){\n  WhereTerm *pTerm, *pX;\n  Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);\n  int i, j, k;\n  LogEst iReduce = 0;    /* pLoop->nOut should not exceed nRow-iReduce */\n\n  assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n  for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){\n    if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;\n    if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;\n    if( (pTerm->prereqAll & notAllowed)!=0 ) continue;\n    for(j=pLoop->nLTerm-1; j>=0; j--){\n      pX = pLoop->aLTerm[j];\n      if( pX==0 ) continue;\n      if( pX==pTerm ) break;\n      if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;\n    }\n    if( j<0 ){\n      if( pTerm->truthProb<=0 ){\n        /* If a truth probability is specified using the likelihood() hints,\n        ** then use the probability provided by the application. */\n        pLoop->nOut += pTerm->truthProb;\n      }else{\n        /* In the absence of explicit truth probabilities, use heuristics to\n        ** guess a reasonable truth probability. */\n        pLoop->nOut--;\n        if( pTerm->eOperator&(WO_EQ|WO_IS) ){\n          Expr *pRight = pTerm->pExpr->pRight;\n          testcase( pTerm->pExpr->op==TK_IS );\n          if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){\n            k = 10;\n          }else{\n            k = 20;\n          }\n          if( iReduce<k ) iReduce = k;\n        }\n      }\n    }\n  }\n  if( pLoop->nOut > nRow-iReduce )  pLoop->nOut = nRow - iReduce;\n}\n\n/* \n** Term pTerm is a vector range comparison operation. The first comparison\n** in the vector can be optimized using column nEq of the index. This\n** function returns the total number of vector elements that can be used\n** as part of the range comparison.\n**\n** For example, if the query is:\n**\n**   WHERE a = ? AND (b, c, d) > (?, ?, ?)\n**\n** and the index:\n**\n**   CREATE INDEX ... ON (a, b, c, d, e)\n**\n** then this function would be invoked with nEq=1. The value returned in\n** this case is 3.\n*/\nstatic int whereRangeVectorLen(\n  Parse *pParse,       /* Parsing context */\n  int iCur,            /* Cursor open on pIdx */\n  Index *pIdx,         /* The index to be used for a inequality constraint */\n  int nEq,             /* Number of prior equality constraints on same index */\n  WhereTerm *pTerm     /* The vector inequality constraint */\n){\n  int nCmp = sqlite3ExprVectorSize(pTerm->pExpr->pLeft);\n  int i;\n\n  nCmp = MIN(nCmp, (pIdx->nColumn - nEq));\n  for(i=1; i<nCmp; i++){\n    /* Test if comparison i of pTerm is compatible with column (i+nEq) \n    ** of the index. If not, exit the loop.  */\n    char aff;                     /* Comparison affinity */\n    char idxaff = 0;              /* Indexed columns affinity */\n    CollSeq *pColl;               /* Comparison collation sequence */\n    Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr;\n    Expr *pRhs = pTerm->pExpr->pRight;\n    if( pRhs->flags & EP_xIsSelect ){\n      pRhs = pRhs->x.pSelect->pEList->a[i].pExpr;\n    }else{\n      pRhs = pRhs->x.pList->a[i].pExpr;\n    }\n\n    /* Check that the LHS of the comparison is a column reference to\n    ** the right column of the right source table. And that the sort\n    ** order of the index column is the same as the sort order of the\n    ** leftmost index column.  */\n    if( pLhs->op!=TK_COLUMN \n     || pLhs->iTable!=iCur \n     || pLhs->iColumn!=pIdx->aiColumn[i+nEq] \n     || pIdx->aSortOrder[i+nEq]!=pIdx->aSortOrder[nEq]\n    ){\n      break;\n    }\n\n    testcase( pLhs->iColumn==XN_ROWID );\n    aff = sqlite3CompareAffinity(pRhs, sqlite3ExprAffinity(pLhs));\n    idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);\n    if( aff!=idxaff ) break;\n\n    pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);\n    if( pColl==0 ) break;\n    if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;\n  }\n  return i;\n}\n\n/*\n** Adjust the cost C by the costMult facter T.  This only occurs if\n** compiled with -DSQLITE_ENABLE_COSTMULT\n*/\n#ifdef SQLITE_ENABLE_COSTMULT\n# define ApplyCostMultiplier(C,T)  C += T\n#else\n# define ApplyCostMultiplier(C,T)\n#endif\n\n/*\n** We have so far matched pBuilder->pNew->u.btree.nEq terms of the \n** index pIndex. Try to match one more.\n**\n** When this function is called, pBuilder->pNew->nOut contains the \n** number of rows expected to be visited by filtering using the nEq \n** terms only. If it is modified, this value is restored before this \n** function returns.\n**\n** If pProbe->tnum==0, that means pIndex is a fake index used for the\n** INTEGER PRIMARY KEY.\n*/\nstatic int whereLoopAddBtreeIndex(\n  WhereLoopBuilder *pBuilder,     /* The WhereLoop factory */\n  struct SrcList_item *pSrc,      /* FROM clause term being analyzed */\n  Index *pProbe,                  /* An index on pSrc */\n  LogEst nInMul                   /* log(Number of iterations due to IN) */\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;  /* WHERE analyse context */\n  Parse *pParse = pWInfo->pParse;        /* Parsing context */\n  sqlite3 *db = pParse->db;       /* Database connection malloc context */\n  WhereLoop *pNew;                /* Template WhereLoop under construction */\n  WhereTerm *pTerm;               /* A WhereTerm under consideration */\n  int opMask;                     /* Valid operators for constraints */\n  WhereScan scan;                 /* Iterator for WHERE terms */\n  Bitmask saved_prereq;           /* Original value of pNew->prereq */\n  u16 saved_nLTerm;               /* Original value of pNew->nLTerm */\n  u16 saved_nEq;                  /* Original value of pNew->u.btree.nEq */\n  u16 saved_nBtm;                 /* Original value of pNew->u.btree.nBtm */\n  u16 saved_nTop;                 /* Original value of pNew->u.btree.nTop */\n  u16 saved_nSkip;                /* Original value of pNew->nSkip */\n  u32 saved_wsFlags;              /* Original value of pNew->wsFlags */\n  LogEst saved_nOut;              /* Original value of pNew->nOut */\n  int rc = SQLITE_OK;             /* Return code */\n  LogEst rSize;                   /* Number of rows in the table */\n  LogEst rLogSize;                /* Logarithm of table size */\n  WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */\n\n  pNew = pBuilder->pNew;\n  if( db->mallocFailed ) return SQLITE_NOMEM_BKPT;\n  WHERETRACE(0x800, (\"BEGIN addBtreeIdx(%s), nEq=%d\\n\",\n                     pProbe->zName, pNew->u.btree.nEq));\n\n  assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 );\n  if( pNew->wsFlags & WHERE_BTM_LIMIT ){\n    opMask = WO_LT|WO_LE;\n  }else{\n    assert( pNew->u.btree.nBtm==0 );\n    opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;\n  }\n  if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);\n\n  assert( pNew->u.btree.nEq<pProbe->nColumn );\n\n  saved_nEq = pNew->u.btree.nEq;\n  saved_nBtm = pNew->u.btree.nBtm;\n  saved_nTop = pNew->u.btree.nTop;\n  saved_nSkip = pNew->nSkip;\n  saved_nLTerm = pNew->nLTerm;\n  saved_wsFlags = pNew->wsFlags;\n  saved_prereq = pNew->prereq;\n  saved_nOut = pNew->nOut;\n  pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, saved_nEq,\n                        opMask, pProbe);\n  pNew->rSetup = 0;\n  rSize = pProbe->aiRowLogEst[0];\n  rLogSize = estLog(rSize);\n  for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){\n    u16 eOp = pTerm->eOperator;   /* Shorthand for pTerm->eOperator */\n    LogEst rCostIdx;\n    LogEst nOutUnadjusted;        /* nOut before IN() and WHERE adjustments */\n    int nIn = 0;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    int nRecValid = pBuilder->nRecValid;\n#endif\n    if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0)\n     && indexColumnNotNull(pProbe, saved_nEq)\n    ){\n      continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */\n    }\n    if( pTerm->prereqRight & pNew->maskSelf ) continue;\n\n    /* Do not allow the upper bound of a LIKE optimization range constraint\n    ** to mix with a lower range bound from some other source */\n    if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;\n\n    /* Do not allow IS constraints from the WHERE clause to be used by the\n    ** right table of a LEFT JOIN.  Only constraints in the ON clause are\n    ** allowed */\n    if( (pSrc->fg.jointype & JT_LEFT)!=0\n     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n     && (eOp & (WO_IS|WO_ISNULL))!=0\n    ){\n      testcase( eOp & WO_IS );\n      testcase( eOp & WO_ISNULL );\n      continue;\n    }\n\n    if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){\n      pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;\n    }else{\n      pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;\n    }\n    pNew->wsFlags = saved_wsFlags;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->u.btree.nBtm = saved_nBtm;\n    pNew->u.btree.nTop = saved_nTop;\n    pNew->nLTerm = saved_nLTerm;\n    if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n    pNew->aLTerm[pNew->nLTerm++] = pTerm;\n    pNew->prereq = (saved_prereq | pTerm->prereqRight) & ~pNew->maskSelf;\n\n    assert( nInMul==0\n        || (pNew->wsFlags & WHERE_COLUMN_NULL)!=0 \n        || (pNew->wsFlags & WHERE_COLUMN_IN)!=0 \n        || (pNew->wsFlags & WHERE_SKIPSCAN)!=0 \n    );\n\n    if( eOp & WO_IN ){\n      Expr *pExpr = pTerm->pExpr;\n      pNew->wsFlags |= WHERE_COLUMN_IN;\n      if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n        /* \"x IN (SELECT ...)\":  TUNING: the SELECT returns 25 rows */\n        int i;\n        nIn = 46;  assert( 46==sqlite3LogEst(25) );\n\n        /* The expression may actually be of the form (x, y) IN (SELECT...).\n        ** In this case there is a separate term for each of (x) and (y).\n        ** However, the nIn multiplier should only be applied once, not once\n        ** for each such term. The following loop checks that pTerm is the\n        ** first such term in use, and sets nIn back to 0 if it is not. */\n        for(i=0; i<pNew->nLTerm-1; i++){\n          if( pNew->aLTerm[i] && pNew->aLTerm[i]->pExpr==pExpr ) nIn = 0;\n        }\n      }else if( ALWAYS(pExpr->x.pList && pExpr->x.pList->nExpr) ){\n        /* \"x IN (value, value, ...)\" */\n        nIn = sqlite3LogEst(pExpr->x.pList->nExpr);\n        assert( nIn>0 );  /* RHS always has 2 or more terms...  The parser\n                          ** changes \"x IN (?)\" into \"x=?\". */\n      }\n    }else if( eOp & (WO_EQ|WO_IS) ){\n      int iCol = pProbe->aiColumn[saved_nEq];\n      pNew->wsFlags |= WHERE_COLUMN_EQ;\n      assert( saved_nEq==pNew->u.btree.nEq );\n      if( iCol==XN_ROWID \n       || (iCol>0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1)\n      ){\n        if( iCol>=0 && pProbe->uniqNotNull==0 ){\n          pNew->wsFlags |= WHERE_UNQ_WANTED;\n        }else{\n          pNew->wsFlags |= WHERE_ONEROW;\n        }\n      }\n    }else if( eOp & WO_ISNULL ){\n      pNew->wsFlags |= WHERE_COLUMN_NULL;\n    }else if( eOp & (WO_GT|WO_GE) ){\n      testcase( eOp & WO_GT );\n      testcase( eOp & WO_GE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;\n      pNew->u.btree.nBtm = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pBtm = pTerm;\n      pTop = 0;\n      if( pTerm->wtFlags & TERM_LIKEOPT ){\n        /* Range contraints that come from the LIKE optimization are\n        ** always used in pairs. */\n        pTop = &pTerm[1];\n        assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );\n        assert( pTop->wtFlags & TERM_LIKEOPT );\n        assert( pTop->eOperator==WO_LT );\n        if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */\n        pNew->aLTerm[pNew->nLTerm++] = pTop;\n        pNew->wsFlags |= WHERE_TOP_LIMIT;\n        pNew->u.btree.nTop = 1;\n      }\n    }else{\n      assert( eOp & (WO_LT|WO_LE) );\n      testcase( eOp & WO_LT );\n      testcase( eOp & WO_LE );\n      pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_TOP_LIMIT;\n      pNew->u.btree.nTop = whereRangeVectorLen(\n          pParse, pSrc->iCursor, pProbe, saved_nEq, pTerm\n      );\n      pTop = pTerm;\n      pBtm = (pNew->wsFlags & WHERE_BTM_LIMIT)!=0 ?\n                     pNew->aLTerm[pNew->nLTerm-2] : 0;\n    }\n\n    /* At this point pNew->nOut is set to the number of rows expected to\n    ** be visited by the index scan before considering term pTerm, or the\n    ** values of nIn and nInMul. In other words, assuming that all \n    ** \"x IN(...)\" terms are replaced with \"x = ?\". This block updates\n    ** the value of pNew->nOut to account for pTerm (but not nIn/nInMul).  */\n    assert( pNew->nOut==saved_nOut );\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      /* Adjust nOut using stat3/stat4 data. Or, if there is no stat3/stat4\n      ** data, using some other estimate.  */\n      whereRangeScanEst(pParse, pBuilder, pBtm, pTop, pNew);\n    }else{\n      int nEq = ++pNew->u.btree.nEq;\n      assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) );\n\n      assert( pNew->nOut==saved_nOut );\n      if( pTerm->truthProb<=0 && pProbe->aiColumn[saved_nEq]>=0 ){\n        assert( (eOp & WO_IN) || nIn==0 );\n        testcase( eOp & WO_IN );\n        pNew->nOut += pTerm->truthProb;\n        pNew->nOut -= nIn;\n      }else{\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n        tRowcnt nOut = 0;\n        if( nInMul==0 \n         && pProbe->nSample \n         && pNew->u.btree.nEq<=pProbe->nSampleCol\n         && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))\n        ){\n          Expr *pExpr = pTerm->pExpr;\n          if( (eOp & (WO_EQ|WO_ISNULL|WO_IS))!=0 ){\n            testcase( eOp & WO_EQ );\n            testcase( eOp & WO_IS );\n            testcase( eOp & WO_ISNULL );\n            rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut);\n          }else{\n            rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);\n          }\n          if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK;\n          if( rc!=SQLITE_OK ) break;          /* Jump out of the pTerm loop */\n          if( nOut ){\n            pNew->nOut = sqlite3LogEst(nOut);\n            if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;\n            pNew->nOut -= nIn;\n          }\n        }\n        if( nOut==0 )\n#endif\n        {\n          pNew->nOut += (pProbe->aiRowLogEst[nEq] - pProbe->aiRowLogEst[nEq-1]);\n          if( eOp & WO_ISNULL ){\n            /* TUNING: If there is no likelihood() value, assume that a \n            ** \"col IS NULL\" expression matches twice as many rows \n            ** as (col=?). */\n            pNew->nOut += 10;\n          }\n        }\n      }\n    }\n\n    /* Set rCostIdx to the cost of visiting selected rows in index. Add\n    ** it to pNew->rRun, which is currently set to the cost of the index\n    ** seek only. Then, if this is a non-covering index, add the cost of\n    ** visiting the rows in the main table.  */\n    rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow;\n    pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx);\n    if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){\n      pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);\n    }\n    ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult);\n\n    nOutUnadjusted = pNew->nOut;\n    pNew->rRun += nInMul + nIn;\n    pNew->nOut += nInMul + nIn;\n    whereLoopOutputAdjust(pBuilder->pWC, pNew, rSize);\n    rc = whereLoopInsert(pBuilder, pNew);\n\n    if( pNew->wsFlags & WHERE_COLUMN_RANGE ){\n      pNew->nOut = saved_nOut;\n    }else{\n      pNew->nOut = nOutUnadjusted;\n    }\n\n    if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0\n     && pNew->u.btree.nEq<pProbe->nColumn\n    ){\n      whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);\n    }\n    pNew->nOut = saved_nOut;\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    pBuilder->nRecValid = nRecValid;\n#endif\n  }\n  pNew->prereq = saved_prereq;\n  pNew->u.btree.nEq = saved_nEq;\n  pNew->u.btree.nBtm = saved_nBtm;\n  pNew->u.btree.nTop = saved_nTop;\n  pNew->nSkip = saved_nSkip;\n  pNew->wsFlags = saved_wsFlags;\n  pNew->nOut = saved_nOut;\n  pNew->nLTerm = saved_nLTerm;\n\n  /* Consider using a skip-scan if there are no WHERE clause constraints\n  ** available for the left-most terms of the index, and if the average\n  ** number of repeats in the left-most terms is at least 18. \n  **\n  ** The magic number 18 is selected on the basis that scanning 17 rows\n  ** is almost always quicker than an index seek (even though if the index\n  ** contains fewer than 2^17 rows we assume otherwise in other parts of\n  ** the code). And, even if it is not, it should not be too much slower. \n  ** On the other hand, the extra seeks could end up being significantly\n  ** more expensive.  */\n  assert( 42==sqlite3LogEst(18) );\n  if( saved_nEq==saved_nSkip\n   && saved_nEq+1<pProbe->nKeyCol\n   && pProbe->noSkipScan==0\n   && pProbe->aiRowLogEst[saved_nEq+1]>=42  /* TUNING: Minimum for skip-scan */\n   && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK\n  ){\n    LogEst nIter;\n    pNew->u.btree.nEq++;\n    pNew->nSkip++;\n    pNew->aLTerm[pNew->nLTerm++] = 0;\n    pNew->wsFlags |= WHERE_SKIPSCAN;\n    nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];\n    pNew->nOut -= nIter;\n    /* TUNING:  Because uncertainties in the estimates for skip-scan queries,\n    ** add a 1.375 fudge factor to make skip-scan slightly less likely. */\n    nIter += 5;\n    whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);\n    pNew->nOut = saved_nOut;\n    pNew->u.btree.nEq = saved_nEq;\n    pNew->nSkip = saved_nSkip;\n    pNew->wsFlags = saved_wsFlags;\n  }\n\n  WHERETRACE(0x800, (\"END addBtreeIdx(%s), nEq=%d, rc=%d\\n\",\n                      pProbe->zName, saved_nEq, rc));\n  return rc;\n}\n\n/*\n** Return True if it is possible that pIndex might be useful in\n** implementing the ORDER BY clause in pBuilder.\n**\n** Return False if pBuilder does not contain an ORDER BY clause or\n** if there is no way for pIndex to be useful in implementing that\n** ORDER BY clause.\n*/\nstatic int indexMightHelpWithOrderBy(\n  WhereLoopBuilder *pBuilder,\n  Index *pIndex,\n  int iCursor\n){\n  ExprList *pOB;\n  ExprList *aColExpr;\n  int ii, jj;\n\n  if( pIndex->bUnordered ) return 0;\n  if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0;\n  for(ii=0; ii<pOB->nExpr; ii++){\n    Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);\n    if( pExpr->op==TK_COLUMN && pExpr->iTable==iCursor ){\n      if( pExpr->iColumn<0 ) return 1;\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1;\n      }\n    }else if( (aColExpr = pIndex->aColExpr)!=0 ){\n      for(jj=0; jj<pIndex->nKeyCol; jj++){\n        if( pIndex->aiColumn[jj]!=XN_EXPR ) continue;\n        if( sqlite3ExprCompareSkip(pExpr,aColExpr->a[jj].pExpr,iCursor)==0 ){\n          return 1;\n        }\n      }\n    }\n  }\n  return 0;\n}\n\n/*\n** Return a bitmask where 1s indicate that the corresponding column of\n** the table is used by an index.  Only the first 63 columns are considered.\n*/\nstatic Bitmask columnsInIndex(Index *pIdx){\n  Bitmask m = 0;\n  int j;\n  for(j=pIdx->nColumn-1; j>=0; j--){\n    int x = pIdx->aiColumn[j];\n    if( x>=0 ){\n      testcase( x==BMS-1 );\n      testcase( x==BMS-2 );\n      if( x<BMS-1 ) m |= MASKBIT(x);\n    }\n  }\n  return m;\n}\n\n/* Check to see if a partial index with pPartIndexWhere can be used\n** in the current query.  Return true if it can be and false if not.\n*/\nstatic int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){\n  int i;\n  WhereTerm *pTerm;\n  Parse *pParse = pWC->pWInfo->pParse;\n  while( pWhere->op==TK_AND ){\n    if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0;\n    pWhere = pWhere->pRight;\n  }\n  if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;\n  for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){\n    Expr *pExpr = pTerm->pExpr;\n    if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)\n     && sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab) \n    ){\n      return 1;\n    }\n  }\n  return 0;\n}\n\n/*\n** Add all WhereLoop objects for a single table of the join where the table\n** is identified by pBuilder->pNew->iTab.  That table is guaranteed to be\n** a b-tree table, not a virtual table.\n**\n** The costs (WhereLoop.rRun) of the b-tree loops added by this function\n** are calculated as follows:\n**\n** For a full scan, assuming the table (or index) contains nRow rows:\n**\n**     cost = nRow * 3.0                    // full-table scan\n**     cost = nRow * K                      // scan of covering index\n**     cost = nRow * (K+3.0)                // scan of non-covering index\n**\n** where K is a value between 1.1 and 3.0 set based on the relative \n** estimated average size of the index and table records.\n**\n** For an index scan, where nVisit is the number of index rows visited\n** by the scan, and nSeek is the number of seek operations required on \n** the index b-tree:\n**\n**     cost = nSeek * (log(nRow) + K * nVisit)          // covering index\n**     cost = nSeek * (log(nRow) + (K+3.0) * nVisit)    // non-covering index\n**\n** Normally, nSeek is 1. nSeek values greater than 1 come about if the \n** WHERE clause includes \"x IN (....)\" terms used in place of \"x=?\". Or when \n** implicit \"x IN (SELECT x FROM tbl)\" terms are added for skip-scans.\n**\n** The estimated values (nRow, nVisit, nSeek) often contain a large amount\n** of uncertainty.  For this reason, scoring is designed to pick plans that\n** \"do the least harm\" if the estimates are inaccurate.  For example, a\n** log(nRow) factor is omitted from a non-covering index scan in order to\n** bias the scoring in favor of using an index, since the worst-case\n** performance of using an index is far better than the worst-case performance\n** of a full table scan.\n*/\nstatic int whereLoopAddBtree(\n  WhereLoopBuilder *pBuilder, /* WHERE clause information */\n  Bitmask mPrereq             /* Extra prerequesites for using this table */\n){\n  WhereInfo *pWInfo;          /* WHERE analysis context */\n  Index *pProbe;              /* An index we are evaluating */\n  Index sPk;                  /* A fake index object for the primary key */\n  LogEst aiRowEstPk[2];       /* The aiRowLogEst[] value for the sPk index */\n  i16 aiColumnPk = -1;        /* The aColumn[] value for the sPk index */\n  SrcList *pTabList;          /* The FROM clause */\n  struct SrcList_item *pSrc;  /* The FROM clause btree term to add */\n  WhereLoop *pNew;            /* Template WhereLoop object */\n  int rc = SQLITE_OK;         /* Return code */\n  int iSortIdx = 1;           /* Index number */\n  int b;                      /* A boolean value */\n  LogEst rSize;               /* number of rows in the table */\n  LogEst rLogSize;            /* Logarithm of the number of rows in the table */\n  WhereClause *pWC;           /* The parsed WHERE clause */\n  Table *pTab;                /* Table being queried */\n  \n  pNew = pBuilder->pNew;\n  pWInfo = pBuilder->pWInfo;\n  pTabList = pWInfo->pTabList;\n  pSrc = pTabList->a + pNew->iTab;\n  pTab = pSrc->pTab;\n  pWC = pBuilder->pWC;\n  assert( !IsVirtual(pSrc->pTab) );\n\n  if( pSrc->pIBIndex ){\n    /* An INDEXED BY clause specifies a particular index to use */\n    pProbe = pSrc->pIBIndex;\n  }else if( !HasRowid(pTab) ){\n    pProbe = pTab->pIndex;\n  }else{\n    /* There is no INDEXED BY clause.  Create a fake Index object in local\n    ** variable sPk to represent the rowid primary key index.  Make this\n    ** fake index the first in a chain of Index objects with all of the real\n    ** indices to follow */\n    Index *pFirst;                  /* First of real indices on the table */\n    memset(&sPk, 0, sizeof(Index));\n    sPk.nKeyCol = 1;\n    sPk.nColumn = 1;\n    sPk.aiColumn = &aiColumnPk;\n    sPk.aiRowLogEst = aiRowEstPk;\n    sPk.onError = OE_Replace;\n    sPk.pTable = pTab;\n    sPk.szIdxRow = pTab->szTabRow;\n    aiRowEstPk[0] = pTab->nRowLogEst;\n    aiRowEstPk[1] = 0;\n    pFirst = pSrc->pTab->pIndex;\n    if( pSrc->fg.notIndexed==0 ){\n      /* The real indices of the table are only considered if the\n      ** NOT INDEXED qualifier is omitted from the FROM clause */\n      sPk.pNext = pFirst;\n    }\n    pProbe = &sPk;\n  }\n  rSize = pTab->nRowLogEst;\n  rLogSize = estLog(rSize);\n\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n  /* Automatic indexes */\n  if( !pBuilder->pOrSet      /* Not part of an OR optimization */\n   && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n   && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0\n   && pSrc->pIBIndex==0      /* Has no INDEXED BY clause */\n   && !pSrc->fg.notIndexed   /* Has no NOT INDEXED clause */\n   && HasRowid(pTab)         /* Not WITHOUT ROWID table. (FIXME: Why not?) */\n   && !pSrc->fg.isCorrelated /* Not a correlated subquery */\n   && !pSrc->fg.isRecursive  /* Not a recursive common table expression. */\n  ){\n    /* Generate auto-index WhereLoops */\n    WhereTerm *pTerm;\n    WhereTerm *pWCEnd = pWC->a + pWC->nTerm;\n    for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){\n      if( pTerm->prereqRight & pNew->maskSelf ) continue;\n      if( termCanDriveIndex(pTerm, pSrc, 0) ){\n        pNew->u.btree.nEq = 1;\n        pNew->nSkip = 0;\n        pNew->u.btree.pIndex = 0;\n        pNew->nLTerm = 1;\n        pNew->aLTerm[0] = pTerm;\n        /* TUNING: One-time cost for computing the automatic index is\n        ** estimated to be X*N*log2(N) where N is the number of rows in\n        ** the table being indexed and where X is 7 (LogEst=28) for normal\n        ** tables or 1.375 (LogEst=4) for views and subqueries.  The value\n        ** of X is smaller for views and subqueries so that the query planner\n        ** will be more aggressive about generating automatic indexes for\n        ** those objects, since there is no opportunity to add schema\n        ** indexes on subqueries and views. */\n        pNew->rSetup = rLogSize + rSize + 4;\n        if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){\n          pNew->rSetup += 24;\n        }\n        ApplyCostMultiplier(pNew->rSetup, pTab->costMult);\n        if( pNew->rSetup<0 ) pNew->rSetup = 0;\n        /* TUNING: Each index lookup yields 20 rows in the table.  This\n        ** is more than the usual guess of 10 rows, since we have no way\n        ** of knowing how selective the index will ultimately be.  It would\n        ** not be unreasonable to make this value much larger. */\n        pNew->nOut = 43;  assert( 43==sqlite3LogEst(20) );\n        pNew->rRun = sqlite3LogEstAdd(rLogSize,pNew->nOut);\n        pNew->wsFlags = WHERE_AUTO_INDEX;\n        pNew->prereq = mPrereq | pTerm->prereqRight;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n    }\n  }\n#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */\n\n  /* Loop over all indices\n  */\n  for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){\n    if( pProbe->pPartIdxWhere!=0\n     && !whereUsablePartialIndex(pSrc->iCursor, pWC, pProbe->pPartIdxWhere) ){\n      testcase( pNew->iTab!=pSrc->iCursor );  /* See ticket [98d973b8f5] */\n      continue;  /* Partial index inappropriate for this query */\n    }\n    rSize = pProbe->aiRowLogEst[0];\n    pNew->u.btree.nEq = 0;\n    pNew->u.btree.nBtm = 0;\n    pNew->u.btree.nTop = 0;\n    pNew->nSkip = 0;\n    pNew->nLTerm = 0;\n    pNew->iSortIdx = 0;\n    pNew->rSetup = 0;\n    pNew->prereq = mPrereq;\n    pNew->nOut = rSize;\n    pNew->u.btree.pIndex = pProbe;\n    b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);\n    /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */\n    assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );\n    if( pProbe->tnum<=0 ){\n      /* Integer primary key index */\n      pNew->wsFlags = WHERE_IPK;\n\n      /* Full table scan */\n      pNew->iSortIdx = b ? iSortIdx : 0;\n      /* TUNING: Cost of full table scan is (N*3.0). */\n      pNew->rRun = rSize + 16;\n      ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n      whereLoopOutputAdjust(pWC, pNew, rSize);\n      rc = whereLoopInsert(pBuilder, pNew);\n      pNew->nOut = rSize;\n      if( rc ) break;\n    }else{\n      Bitmask m;\n      if( pProbe->isCovering ){\n        pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;\n        m = 0;\n      }else{\n        m = pSrc->colUsed & ~columnsInIndex(pProbe);\n        pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED;\n      }\n\n      /* Full scan via index */\n      if( b\n       || !HasRowid(pTab)\n       || pProbe->pPartIdxWhere!=0\n       || ( m==0\n         && pProbe->bUnordered==0\n         && (pProbe->szIdxRow<pTab->szTabRow)\n         && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0\n         && sqlite3GlobalConfig.bUseCis\n         && OptimizationEnabled(pWInfo->pParse->db, SQLITE_CoverIdxScan)\n          )\n      ){\n        pNew->iSortIdx = b ? iSortIdx : 0;\n\n        /* The cost of visiting the index rows is N*K, where K is\n        ** between 1.1 and 3.0, depending on the relative sizes of the\n        ** index and table rows. */\n        pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;\n        if( m!=0 ){\n          /* If this is a non-covering index scan, add in the cost of\n          ** doing table lookups.  The cost will be 3x the number of\n          ** lookups.  Take into account WHERE clause terms that can be\n          ** satisfied using just the index, and that do not require a\n          ** table lookup. */\n          LogEst nLookup = rSize + 16;  /* Base cost:  N*3 */\n          int ii;\n          int iCur = pSrc->iCursor;\n          WhereClause *pWC2 = &pWInfo->sWC;\n          for(ii=0; ii<pWC2->nTerm; ii++){\n            WhereTerm *pTerm = &pWC2->a[ii];\n            if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){\n              break;\n            }\n            /* pTerm can be evaluated using just the index.  So reduce\n            ** the expected number of table lookups accordingly */\n            if( pTerm->truthProb<=0 ){\n              nLookup += pTerm->truthProb;\n            }else{\n              nLookup--;\n              if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19;\n            }\n          }\n          \n          pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup);\n        }\n        ApplyCostMultiplier(pNew->rRun, pTab->costMult);\n        whereLoopOutputAdjust(pWC, pNew, rSize);\n        rc = whereLoopInsert(pBuilder, pNew);\n        pNew->nOut = rSize;\n        if( rc ) break;\n      }\n    }\n\n    pBuilder->bldFlags = 0;\n    rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);\n    if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){\n      /* If a non-unique index is used, or if a prefix of the key for\n      ** unique index is used (making the index functionally non-unique)\n      ** then the sqlite_stat1 data becomes important for scoring the\n      ** plan */\n      pTab->tabFlags |= TF_StatsUsed;\n    }\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n    sqlite3Stat4ProbeFree(pBuilder->pRec);\n    pBuilder->nRecValid = 0;\n    pBuilder->pRec = 0;\n#endif\n\n    /* If there was an INDEXED BY clause, then only that one index is\n    ** considered. */\n    if( pSrc->pIBIndex ) break;\n  }\n  return rc;\n}\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n\n/*\n** Argument pIdxInfo is already populated with all constraints that may\n** be used by the virtual table identified by pBuilder->pNew->iTab. This\n** function marks a subset of those constraints usable, invokes the\n** xBestIndex method and adds the returned plan to pBuilder.\n**\n** A constraint is marked usable if:\n**\n**   * Argument mUsable indicates that its prerequisites are available, and\n**\n**   * It is not one of the operators specified in the mExclude mask passed\n**     as the fourth argument (which in practice is either WO_IN or 0).\n**\n** Argument mPrereq is a mask of tables that must be scanned before the\n** virtual table in question. These are added to the plans prerequisites\n** before it is added to pBuilder.\n**\n** Output parameter *pbIn is set to true if the plan added to pBuilder\n** uses one or more WO_IN terms, or false otherwise.\n*/\nstatic int whereLoopAddVirtualOne(\n  WhereLoopBuilder *pBuilder,\n  Bitmask mPrereq,                /* Mask of tables that must be used. */\n  Bitmask mUsable,                /* Mask of usable tables */\n  u16 mExclude,                   /* Exclude terms using these operators */\n  sqlite3_index_info *pIdxInfo,   /* Populated object for xBestIndex */\n  u16 mNoOmit,                    /* Do not omit these constraints */\n  int *pbIn                       /* OUT: True if plan uses an IN(...) op */\n){\n  WhereClause *pWC = pBuilder->pWC;\n  struct sqlite3_index_constraint *pIdxCons;\n  struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;\n  int i;\n  int mxTerm;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew = pBuilder->pNew;\n  Parse *pParse = pBuilder->pWInfo->pParse;\n  struct SrcList_item *pSrc = &pBuilder->pWInfo->pTabList->a[pNew->iTab];\n  int nConstraint = pIdxInfo->nConstraint;\n\n  assert( (mUsable & mPrereq)==mPrereq );\n  *pbIn = 0;\n  pNew->prereq = mPrereq;\n\n  /* Set the usable flag on the subset of constraints identified by \n  ** arguments mUsable and mExclude. */\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    WhereTerm *pTerm = &pWC->a[pIdxCons->iTermOffset];\n    pIdxCons->usable = 0;\n    if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight \n     && (pTerm->eOperator & mExclude)==0\n    ){\n      pIdxCons->usable = 1;\n    }\n  }\n\n  /* Initialize the output fields of the sqlite3_index_info structure */\n  memset(pUsage, 0, sizeof(pUsage[0])*nConstraint);\n  assert( pIdxInfo->needToFreeIdxStr==0 );\n  pIdxInfo->idxStr = 0;\n  pIdxInfo->idxNum = 0;\n  pIdxInfo->orderByConsumed = 0;\n  pIdxInfo->estimatedCost = SQLITE_BIG_DBL / (double)2;\n  pIdxInfo->estimatedRows = 25;\n  pIdxInfo->idxFlags = 0;\n  pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;\n\n  /* Invoke the virtual table xBestIndex() method */\n  rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);\n  if( rc ) return rc;\n\n  mxTerm = -1;\n  assert( pNew->nLSlot>=nConstraint );\n  for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;\n  pNew->u.vtab.omitMask = 0;\n  pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;\n  for(i=0; i<nConstraint; i++, pIdxCons++){\n    int iTerm;\n    if( (iTerm = pUsage[i].argvIndex - 1)>=0 ){\n      WhereTerm *pTerm;\n      int j = pIdxCons->iTermOffset;\n      if( iTerm>=nConstraint\n       || j<0\n       || j>=pWC->nTerm\n       || pNew->aLTerm[iTerm]!=0\n       || pIdxCons->usable==0\n      ){\n        rc = SQLITE_ERROR;\n        sqlite3ErrorMsg(pParse,\"%s.xBestIndex malfunction\",pSrc->pTab->zName);\n        return rc;\n      }\n      testcase( iTerm==nConstraint-1 );\n      testcase( j==0 );\n      testcase( j==pWC->nTerm-1 );\n      pTerm = &pWC->a[j];\n      pNew->prereq |= pTerm->prereqRight;\n      assert( iTerm<pNew->nLSlot );\n      pNew->aLTerm[iTerm] = pTerm;\n      if( iTerm>mxTerm ) mxTerm = iTerm;\n      testcase( iTerm==15 );\n      testcase( iTerm==16 );\n      if( iTerm<16 && pUsage[i].omit ) pNew->u.vtab.omitMask |= 1<<iTerm;\n      if( (pTerm->eOperator & WO_IN)!=0 ){\n        /* A virtual table that is constrained by an IN clause may not\n        ** consume the ORDER BY clause because (1) the order of IN terms\n        ** is not necessarily related to the order of output terms and\n        ** (2) Multiple outputs from a single IN value will not merge\n        ** together.  */\n        pIdxInfo->orderByConsumed = 0;\n        pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;\n        *pbIn = 1; assert( (mExclude & WO_IN)==0 );\n      }\n    }\n  }\n  pNew->u.vtab.omitMask &= ~mNoOmit;\n\n  pNew->nLTerm = mxTerm+1;\n  assert( pNew->nLTerm<=pNew->nLSlot );\n  pNew->u.vtab.idxNum = pIdxInfo->idxNum;\n  pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;\n  pIdxInfo->needToFreeIdxStr = 0;\n  pNew->u.vtab.idxStr = pIdxInfo->idxStr;\n  pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ?\n      pIdxInfo->nOrderBy : 0);\n  pNew->rSetup = 0;\n  pNew->rRun = sqlite3LogEstFromDouble(pIdxInfo->estimatedCost);\n  pNew->nOut = sqlite3LogEst(pIdxInfo->estimatedRows);\n\n  /* Set the WHERE_ONEROW flag if the xBestIndex() method indicated\n  ** that the scan will visit at most one row. Clear it otherwise. */\n  if( pIdxInfo->idxFlags & SQLITE_INDEX_SCAN_UNIQUE ){\n    pNew->wsFlags |= WHERE_ONEROW;\n  }else{\n    pNew->wsFlags &= ~WHERE_ONEROW;\n  }\n  rc = whereLoopInsert(pBuilder, pNew);\n  if( pNew->u.vtab.needFree ){\n    sqlite3_free(pNew->u.vtab.idxStr);\n    pNew->u.vtab.needFree = 0;\n  }\n  WHERETRACE(0xffff, (\"  bIn=%d prereqIn=%04llx prereqOut=%04llx\\n\",\n                      *pbIn, (sqlite3_uint64)mPrereq,\n                      (sqlite3_uint64)(pNew->prereq & ~mPrereq)));\n\n  return rc;\n}\n\n\n/*\n** Add all WhereLoop objects for a table of the join identified by\n** pBuilder->pNew->iTab.  That table is guaranteed to be a virtual table.\n**\n** If there are no LEFT or CROSS JOIN joins in the query, both mPrereq and\n** mUnusable are set to 0. Otherwise, mPrereq is a mask of all FROM clause\n** entries that occur before the virtual table in the FROM clause and are\n** separated from it by at least one LEFT or CROSS JOIN. Similarly, the\n** mUnusable mask contains all FROM clause entries that occur after the\n** virtual table and are separated from it by at least one LEFT or \n** CROSS JOIN. \n**\n** For example, if the query were:\n**\n**   ... FROM t1, t2 LEFT JOIN t3, t4, vt CROSS JOIN t5, t6;\n**\n** then mPrereq corresponds to (t1, t2) and mUnusable to (t5, t6).\n**\n** All the tables in mPrereq must be scanned before the current virtual \n** table. So any terms for which all prerequisites are satisfied by \n** mPrereq may be specified as \"usable\" in all calls to xBestIndex. \n** Conversely, all tables in mUnusable must be scanned after the current\n** virtual table, so any terms for which the prerequisites overlap with\n** mUnusable should always be configured as \"not-usable\" for xBestIndex.\n*/\nstatic int whereLoopAddVirtual(\n  WhereLoopBuilder *pBuilder,  /* WHERE clause information */\n  Bitmask mPrereq,             /* Tables that must be scanned before this one */\n  Bitmask mUnusable            /* Tables that must be scanned after this one */\n){\n  int rc = SQLITE_OK;          /* Return code */\n  WhereInfo *pWInfo;           /* WHERE analysis context */\n  Parse *pParse;               /* The parsing context */\n  WhereClause *pWC;            /* The WHERE clause */\n  struct SrcList_item *pSrc;   /* The FROM clause term to search */\n  sqlite3_index_info *p;       /* Object to pass to xBestIndex() */\n  int nConstraint;             /* Number of constraints in p */\n  int bIn;                     /* True if plan uses IN(...) operator */\n  WhereLoop *pNew;\n  Bitmask mBest;               /* Tables used by best possible plan */\n  u16 mNoOmit;\n\n  assert( (mPrereq & mUnusable)==0 );\n  pWInfo = pBuilder->pWInfo;\n  pParse = pWInfo->pParse;\n  pWC = pBuilder->pWC;\n  pNew = pBuilder->pNew;\n  pSrc = &pWInfo->pTabList->a[pNew->iTab];\n  assert( IsVirtual(pSrc->pTab) );\n  p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy, \n      &mNoOmit);\n  if( p==0 ) return SQLITE_NOMEM_BKPT;\n  pNew->rSetup = 0;\n  pNew->wsFlags = WHERE_VIRTUALTABLE;\n  pNew->nLTerm = 0;\n  pNew->u.vtab.needFree = 0;\n  nConstraint = p->nConstraint;\n  if( whereLoopResize(pParse->db, pNew, nConstraint) ){\n    sqlite3DbFree(pParse->db, p);\n    return SQLITE_NOMEM_BKPT;\n  }\n\n  /* First call xBestIndex() with all constraints usable. */\n  WHERETRACE(0x40, (\"  VirtualOne: all usable\\n\"));\n  rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);\n\n  /* If the call to xBestIndex() with all terms enabled produced a plan\n  ** that does not require any source tables (IOW: a plan with mBest==0),\n  ** then there is no point in making any further calls to xBestIndex() \n  ** since they will all return the same result (if the xBestIndex()\n  ** implementation is sane). */\n  if( rc==SQLITE_OK && (mBest = (pNew->prereq & ~mPrereq))!=0 ){\n    int seenZero = 0;             /* True if a plan with no prereqs seen */\n    int seenZeroNoIN = 0;         /* Plan with no prereqs and no IN(...) seen */\n    Bitmask mPrev = 0;\n    Bitmask mBestNoIn = 0;\n\n    /* If the plan produced by the earlier call uses an IN(...) term, call\n    ** xBestIndex again, this time with IN(...) terms disabled. */\n    if( bIn ){\n      WHERETRACE(0x40, (\"  VirtualOne: all usable w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);\n      assert( bIn==0 );\n      mBestNoIn = pNew->prereq & ~mPrereq;\n      if( mBestNoIn==0 ){\n        seenZero = 1;\n        seenZeroNoIN = 1;\n      }\n    }\n\n    /* Call xBestIndex once for each distinct value of (prereqRight & ~mPrereq) \n    ** in the set of terms that apply to the current virtual table.  */\n    while( rc==SQLITE_OK ){\n      int i;\n      Bitmask mNext = ALLBITS;\n      assert( mNext>0 );\n      for(i=0; i<nConstraint; i++){\n        Bitmask mThis = (\n            pWC->a[p->aConstraint[i].iTermOffset].prereqRight & ~mPrereq\n        );\n        if( mThis>mPrev && mThis<mNext ) mNext = mThis;\n      }\n      mPrev = mNext;\n      if( mNext==ALLBITS ) break;\n      if( mNext==mBest || mNext==mBestNoIn ) continue;\n      WHERETRACE(0x40, (\"  VirtualOne: mPrev=%04llx mNext=%04llx\\n\",\n                       (sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);\n      if( pNew->prereq==mPrereq ){\n        seenZero = 1;\n        if( bIn==0 ) seenZeroNoIN = 1;\n      }\n    }\n\n    /* If the calls to xBestIndex() in the above loop did not find a plan\n    ** that requires no source tables at all (i.e. one guaranteed to be\n    ** usable), make a call here with all source tables disabled */\n    if( rc==SQLITE_OK && seenZero==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);\n      if( bIn==0 ) seenZeroNoIN = 1;\n    }\n\n    /* If the calls to xBestIndex() have so far failed to find a plan\n    ** that requires no source tables at all and does not use an IN(...)\n    ** operator, make a final call to obtain one here.  */\n    if( rc==SQLITE_OK && seenZeroNoIN==0 ){\n      WHERETRACE(0x40, (\"  VirtualOne: all disabled and w/o IN\\n\"));\n      rc = whereLoopAddVirtualOne(\n          pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);\n    }\n  }\n\n  if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);\n  sqlite3DbFreeNN(pParse->db, p);\n  return rc;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** Add WhereLoop entries to handle OR terms.  This works for either\n** btrees or virtual tables.\n*/\nstatic int whereLoopAddOr(\n  WhereLoopBuilder *pBuilder, \n  Bitmask mPrereq, \n  Bitmask mUnusable\n){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  WhereClause *pWC;\n  WhereLoop *pNew;\n  WhereTerm *pTerm, *pWCEnd;\n  int rc = SQLITE_OK;\n  int iCur;\n  WhereClause tempWC;\n  WhereLoopBuilder sSubBuild;\n  WhereOrSet sSum, sCur;\n  struct SrcList_item *pItem;\n  \n  pWC = pBuilder->pWC;\n  pWCEnd = pWC->a + pWC->nTerm;\n  pNew = pBuilder->pNew;\n  memset(&sSum, 0, sizeof(sSum));\n  pItem = pWInfo->pTabList->a + pNew->iTab;\n  iCur = pItem->iCursor;\n\n  for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){\n    if( (pTerm->eOperator & WO_OR)!=0\n     && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 \n    ){\n      WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;\n      WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];\n      WhereTerm *pOrTerm;\n      int once = 1;\n      int i, j;\n    \n      sSubBuild = *pBuilder;\n      sSubBuild.pOrderBy = 0;\n      sSubBuild.pOrSet = &sCur;\n\n      WHERETRACE(0x200, (\"Begin processing OR-clause %p\\n\", pTerm));\n      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){\n        if( (pOrTerm->eOperator & WO_AND)!=0 ){\n          sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;\n        }else if( pOrTerm->leftCursor==iCur ){\n          tempWC.pWInfo = pWC->pWInfo;\n          tempWC.pOuter = pWC;\n          tempWC.op = TK_AND;\n          tempWC.nTerm = 1;\n          tempWC.a = pOrTerm;\n          sSubBuild.pWC = &tempWC;\n        }else{\n          continue;\n        }\n        sCur.n = 0;\n#ifdef WHERETRACE_ENABLED\n        WHERETRACE(0x200, (\"OR-term %d of %p has %d subterms:\\n\", \n                   (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));\n        if( sqlite3WhereTrace & 0x400 ){\n          sqlite3WhereClausePrint(sSubBuild.pWC);\n        }\n#endif\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n        if( IsVirtual(pItem->pTab) ){\n          rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);\n        }else\n#endif\n        {\n          rc = whereLoopAddBtree(&sSubBuild, mPrereq);\n        }\n        if( rc==SQLITE_OK ){\n          rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);\n        }\n        assert( rc==SQLITE_OK || sCur.n==0 );\n        if( sCur.n==0 ){\n          sSum.n = 0;\n          break;\n        }else if( once ){\n          whereOrMove(&sSum, &sCur);\n          once = 0;\n        }else{\n          WhereOrSet sPrev;\n          whereOrMove(&sPrev, &sSum);\n          sSum.n = 0;\n          for(i=0; i<sPrev.n; i++){\n            for(j=0; j<sCur.n; j++){\n              whereOrInsert(&sSum, sPrev.a[i].prereq | sCur.a[j].prereq,\n                            sqlite3LogEstAdd(sPrev.a[i].rRun, sCur.a[j].rRun),\n                            sqlite3LogEstAdd(sPrev.a[i].nOut, sCur.a[j].nOut));\n            }\n          }\n        }\n      }\n      pNew->nLTerm = 1;\n      pNew->aLTerm[0] = pTerm;\n      pNew->wsFlags = WHERE_MULTI_OR;\n      pNew->rSetup = 0;\n      pNew->iSortIdx = 0;\n      memset(&pNew->u, 0, sizeof(pNew->u));\n      for(i=0; rc==SQLITE_OK && i<sSum.n; i++){\n        /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs\n        ** of all sub-scans required by the OR-scan. However, due to rounding\n        ** errors, it may be that the cost of the OR-scan is equal to its\n        ** most expensive sub-scan. Add the smallest possible penalty \n        ** (equivalent to multiplying the cost by 1.07) to ensure that \n        ** this does not happen. Otherwise, for WHERE clauses such as the\n        ** following where there is an index on \"y\":\n        **\n        **     WHERE likelihood(x=?, 0.99) OR y=?\n        **\n        ** the planner may elect to \"OR\" together a full-table scan and an\n        ** index lookup. And other similarly odd results.  */\n        pNew->rRun = sSum.a[i].rRun + 1;\n        pNew->nOut = sSum.a[i].nOut;\n        pNew->prereq = sSum.a[i].prereq;\n        rc = whereLoopInsert(pBuilder, pNew);\n      }\n      WHERETRACE(0x200, (\"End processing OR-clause %p\\n\", pTerm));\n    }\n  }\n  return rc;\n}\n\n/*\n** Add all WhereLoop objects for all tables \n*/\nstatic int whereLoopAddAll(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo = pBuilder->pWInfo;\n  Bitmask mPrereq = 0;\n  Bitmask mPrior = 0;\n  int iTab;\n  SrcList *pTabList = pWInfo->pTabList;\n  struct SrcList_item *pItem;\n  struct SrcList_item *pEnd = &pTabList->a[pWInfo->nLevel];\n  sqlite3 *db = pWInfo->pParse->db;\n  int rc = SQLITE_OK;\n  WhereLoop *pNew;\n  u8 priorJointype = 0;\n\n  /* Loop over the tables in the join, from left to right */\n  pNew = pBuilder->pNew;\n  whereLoopInit(pNew);\n  for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){\n    Bitmask mUnusable = 0;\n    pNew->iTab = iTab;\n    pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor);\n    if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){\n      /* This condition is true when pItem is the FROM clause term on the\n      ** right-hand-side of a LEFT or CROSS JOIN.  */\n      mPrereq = mPrior;\n    }\n    priorJointype = pItem->fg.jointype;\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( IsVirtual(pItem->pTab) ){\n      struct SrcList_item *p;\n      for(p=&pItem[1]; p<pEnd; p++){\n        if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){\n          mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor);\n        }\n      }\n      rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable);\n    }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n    {\n      rc = whereLoopAddBtree(pBuilder, mPrereq);\n    }\n    if( rc==SQLITE_OK ){\n      rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable);\n    }\n    mPrior |= pNew->maskSelf;\n    if( rc || db->mallocFailed ) break;\n  }\n\n  whereLoopClear(db, pNew);\n  return rc;\n}\n\n/*\n** Examine a WherePath (with the addition of the extra WhereLoop of the 6th\n** parameters) to see if it outputs rows in the requested ORDER BY\n** (or GROUP BY) without requiring a separate sort operation.  Return N:\n** \n**   N>0:   N terms of the ORDER BY clause are satisfied\n**   N==0:  No terms of the ORDER BY clause are satisfied\n**   N<0:   Unknown yet how many terms of ORDER BY might be satisfied.   \n**\n** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as\n** strict.  With GROUP BY and DISTINCT the only requirement is that\n** equivalent rows appear immediately adjacent to one another.  GROUP BY\n** and DISTINCT do not require rows to appear in any particular order as long\n** as equivalent rows are grouped together.  Thus for GROUP BY and DISTINCT\n** the pOrderBy terms can be matched in any order.  With ORDER BY, the \n** pOrderBy terms must be matched in strict left-to-right order.\n*/\nstatic i8 wherePathSatisfiesOrderBy(\n  WhereInfo *pWInfo,    /* The WHERE clause */\n  ExprList *pOrderBy,   /* ORDER BY or GROUP BY or DISTINCT clause to check */\n  WherePath *pPath,     /* The WherePath to check */\n  u16 wctrlFlags,       /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */\n  u16 nLoop,            /* Number of entries in pPath->aLoop[] */\n  WhereLoop *pLast,     /* Add this WhereLoop to the end of pPath->aLoop[] */\n  Bitmask *pRevMask     /* OUT: Mask of WhereLoops to run in reverse order */\n){\n  u8 revSet;            /* True if rev is known */\n  u8 rev;               /* Composite sort order */\n  u8 revIdx;            /* Index sort order */\n  u8 isOrderDistinct;   /* All prior WhereLoops are order-distinct */\n  u8 distinctColumns;   /* True if the loop has UNIQUE NOT NULL columns */\n  u8 isMatch;           /* iColumn matches a term of the ORDER BY clause */\n  u16 eqOpMask;         /* Allowed equality operators */\n  u16 nKeyCol;          /* Number of key columns in pIndex */\n  u16 nColumn;          /* Total number of ordered columns in the index */\n  u16 nOrderBy;         /* Number terms in the ORDER BY clause */\n  int iLoop;            /* Index of WhereLoop in pPath being processed */\n  int i, j;             /* Loop counters */\n  int iCur;             /* Cursor number for current WhereLoop */\n  int iColumn;          /* A column number within table iCur */\n  WhereLoop *pLoop = 0; /* Current WhereLoop being processed. */\n  WhereTerm *pTerm;     /* A single term of the WHERE clause */\n  Expr *pOBExpr;        /* An expression from the ORDER BY clause */\n  CollSeq *pColl;       /* COLLATE function from an ORDER BY clause term */\n  Index *pIndex;        /* The index associated with pLoop */\n  sqlite3 *db = pWInfo->pParse->db;  /* Database connection */\n  Bitmask obSat = 0;    /* Mask of ORDER BY terms satisfied so far */\n  Bitmask obDone;       /* Mask of all ORDER BY terms */\n  Bitmask orderDistinctMask;  /* Mask of all well-ordered loops */\n  Bitmask ready;              /* Mask of inner loops */\n\n  /*\n  ** We say the WhereLoop is \"one-row\" if it generates no more than one\n  ** row of output.  A WhereLoop is one-row if all of the following are true:\n  **  (a) All index columns match with WHERE_COLUMN_EQ.\n  **  (b) The index is unique\n  ** Any WhereLoop with an WHERE_COLUMN_EQ constraint on the rowid is one-row.\n  ** Every one-row WhereLoop will have the WHERE_ONEROW bit set in wsFlags.\n  **\n  ** We say the WhereLoop is \"order-distinct\" if the set of columns from\n  ** that WhereLoop that are in the ORDER BY clause are different for every\n  ** row of the WhereLoop.  Every one-row WhereLoop is automatically\n  ** order-distinct.   A WhereLoop that has no columns in the ORDER BY clause\n  ** is not order-distinct. To be order-distinct is not quite the same as being\n  ** UNIQUE since a UNIQUE column or index can have multiple rows that \n  ** are NULL and NULL values are equivalent for the purpose of order-distinct.\n  ** To be order-distinct, the columns must be UNIQUE and NOT NULL.\n  **\n  ** The rowid for a table is always UNIQUE and NOT NULL so whenever the\n  ** rowid appears in the ORDER BY clause, the corresponding WhereLoop is\n  ** automatically order-distinct.\n  */\n\n  assert( pOrderBy!=0 );\n  if( nLoop && OptimizationDisabled(db, SQLITE_OrderByIdxJoin) ) return 0;\n\n  nOrderBy = pOrderBy->nExpr;\n  testcase( nOrderBy==BMS-1 );\n  if( nOrderBy>BMS-1 ) return 0;  /* Cannot optimize overly large ORDER BYs */\n  isOrderDistinct = 1;\n  obDone = MASKBIT(nOrderBy)-1;\n  orderDistinctMask = 0;\n  ready = 0;\n  eqOpMask = WO_EQ | WO_IS | WO_ISNULL;\n  if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN;\n  for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){\n    if( iLoop>0 ) ready |= pLoop->maskSelf;\n    if( iLoop<nLoop ){\n      pLoop = pPath->aLoop[iLoop];\n      if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue;\n    }else{\n      pLoop = pLast;\n    }\n    if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){\n      if( pLoop->u.vtab.isOrdered ) obSat = obDone;\n      break;\n    }else{\n      pLoop->u.btree.nIdxCol = 0;\n    }\n    iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;\n\n    /* Mark off any ORDER BY term X that is a column in the table of\n    ** the current loop for which there is term in the WHERE\n    ** clause of the form X IS NULL or X=? that reference only outer\n    ** loops.\n    */\n    for(i=0; i<nOrderBy; i++){\n      if( MASKBIT(i) & obSat ) continue;\n      pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n      if( pOBExpr->op!=TK_COLUMN ) continue;\n      if( pOBExpr->iTable!=iCur ) continue;\n      pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn,\n                       ~ready, eqOpMask, 0);\n      if( pTerm==0 ) continue;\n      if( pTerm->eOperator==WO_IN ){\n        /* IN terms are only valid for sorting in the ORDER BY LIMIT \n        ** optimization, and then only if they are actually used\n        ** by the query plan */\n        assert( wctrlFlags & WHERE_ORDERBY_LIMIT );\n        for(j=0; j<pLoop->nLTerm && pTerm!=pLoop->aLTerm[j]; j++){}\n        if( j>=pLoop->nLTerm ) continue;\n      }\n      if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){\n        if( sqlite3ExprCollSeqMatch(pWInfo->pParse, \n                  pOrderBy->a[i].pExpr, pTerm->pExpr)==0 ){\n          continue;\n        }\n        testcase( pTerm->pExpr->op==TK_IS );\n      }\n      obSat |= MASKBIT(i);\n    }\n\n    if( (pLoop->wsFlags & WHERE_ONEROW)==0 ){\n      if( pLoop->wsFlags & WHERE_IPK ){\n        pIndex = 0;\n        nKeyCol = 0;\n        nColumn = 1;\n      }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){\n        return 0;\n      }else{\n        nKeyCol = pIndex->nKeyCol;\n        nColumn = pIndex->nColumn;\n        assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) );\n        assert( pIndex->aiColumn[nColumn-1]==XN_ROWID\n                          || !HasRowid(pIndex->pTable));\n        isOrderDistinct = IsUniqueIndex(pIndex);\n      }\n\n      /* Loop through all columns of the index and deal with the ones\n      ** that are not constrained by == or IN.\n      */\n      rev = revSet = 0;\n      distinctColumns = 0;\n      for(j=0; j<nColumn; j++){\n        u8 bOnce = 1; /* True to run the ORDER BY search loop */\n\n        assert( j>=pLoop->u.btree.nEq \n            || (pLoop->aLTerm[j]==0)==(j<pLoop->nSkip)\n        );\n        if( j<pLoop->u.btree.nEq && j>=pLoop->nSkip ){\n          u16 eOp = pLoop->aLTerm[j]->eOperator;\n\n          /* Skip over == and IS and ISNULL terms.  (Also skip IN terms when\n          ** doing WHERE_ORDERBY_LIMIT processing). \n          **\n          ** If the current term is a column of an ((?,?) IN (SELECT...)) \n          ** expression for which the SELECT returns more than one column,\n          ** check that it is the only column used by this loop. Otherwise,\n          ** if it is one of two or more, none of the columns can be\n          ** considered to match an ORDER BY term.  */\n          if( (eOp & eqOpMask)!=0 ){\n            if( eOp & WO_ISNULL ){\n              testcase( isOrderDistinct );\n              isOrderDistinct = 0;\n            }\n            continue;  \n          }else if( ALWAYS(eOp & WO_IN) ){\n            /* ALWAYS() justification: eOp is an equality operator due to the\n            ** j<pLoop->u.btree.nEq constraint above.  Any equality other\n            ** than WO_IN is captured by the previous \"if\".  So this one\n            ** always has to be WO_IN. */\n            Expr *pX = pLoop->aLTerm[j]->pExpr;\n            for(i=j+1; i<pLoop->u.btree.nEq; i++){\n              if( pLoop->aLTerm[i]->pExpr==pX ){\n                assert( (pLoop->aLTerm[i]->eOperator & WO_IN) );\n                bOnce = 0;\n                break;\n              }\n            }\n          }\n        }\n\n        /* Get the column number in the table (iColumn) and sort order\n        ** (revIdx) for the j-th column of the index.\n        */\n        if( pIndex ){\n          iColumn = pIndex->aiColumn[j];\n          revIdx = pIndex->aSortOrder[j];\n          if( iColumn==pIndex->pTable->iPKey ) iColumn = XN_ROWID;\n        }else{\n          iColumn = XN_ROWID;\n          revIdx = 0;\n        }\n\n        /* An unconstrained column that might be NULL means that this\n        ** WhereLoop is not well-ordered\n        */\n        if( isOrderDistinct\n         && iColumn>=0\n         && j>=pLoop->u.btree.nEq\n         && pIndex->pTable->aCol[iColumn].notNull==0\n        ){\n          isOrderDistinct = 0;\n        }\n\n        /* Find the ORDER BY term that corresponds to the j-th column\n        ** of the index and mark that ORDER BY term off \n        */\n        isMatch = 0;\n        for(i=0; bOnce && i<nOrderBy; i++){\n          if( MASKBIT(i) & obSat ) continue;\n          pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr);\n          testcase( wctrlFlags & WHERE_GROUPBY );\n          testcase( wctrlFlags & WHERE_DISTINCTBY );\n          if( (wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY))==0 ) bOnce = 0;\n          if( iColumn>=XN_ROWID ){\n            if( pOBExpr->op!=TK_COLUMN ) continue;\n            if( pOBExpr->iTable!=iCur ) continue;\n            if( pOBExpr->iColumn!=iColumn ) continue;\n          }else{\n            Expr *pIdxExpr = pIndex->aColExpr->a[j].pExpr;\n            if( sqlite3ExprCompareSkip(pOBExpr, pIdxExpr, iCur) ){\n              continue;\n            }\n          }\n          if( iColumn!=XN_ROWID ){\n            pColl = sqlite3ExprNNCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr);\n            if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue;\n          }\n          pLoop->u.btree.nIdxCol = j+1;\n          isMatch = 1;\n          break;\n        }\n        if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){\n          /* Make sure the sort order is compatible in an ORDER BY clause.\n          ** Sort order is irrelevant for a GROUP BY clause. */\n          if( revSet ){\n            if( (rev ^ revIdx)!=pOrderBy->a[i].sortOrder ) isMatch = 0;\n          }else{\n            rev = revIdx ^ pOrderBy->a[i].sortOrder;\n            if( rev ) *pRevMask |= MASKBIT(iLoop);\n            revSet = 1;\n          }\n        }\n        if( isMatch ){\n          if( iColumn==XN_ROWID ){\n            testcase( distinctColumns==0 );\n            distinctColumns = 1;\n          }\n          obSat |= MASKBIT(i);\n        }else{\n          /* No match found */\n          if( j==0 || j<nKeyCol ){\n            testcase( isOrderDistinct!=0 );\n            isOrderDistinct = 0;\n          }\n          break;\n        }\n      } /* end Loop over all index columns */\n      if( distinctColumns ){\n        testcase( isOrderDistinct==0 );\n        isOrderDistinct = 1;\n      }\n    } /* end-if not one-row */\n\n    /* Mark off any other ORDER BY terms that reference pLoop */\n    if( isOrderDistinct ){\n      orderDistinctMask |= pLoop->maskSelf;\n      for(i=0; i<nOrderBy; i++){\n        Expr *p;\n        Bitmask mTerm;\n        if( MASKBIT(i) & obSat ) continue;\n        p = pOrderBy->a[i].pExpr;\n        mTerm = sqlite3WhereExprUsage(&pWInfo->sMaskSet,p);\n        if( mTerm==0 && !sqlite3ExprIsConstant(p) ) continue;\n        if( (mTerm&~orderDistinctMask)==0 ){\n          obSat |= MASKBIT(i);\n        }\n      }\n    }\n  } /* End the loop over all WhereLoops from outer-most down to inner-most */\n  if( obSat==obDone ) return (i8)nOrderBy;\n  if( !isOrderDistinct ){\n    for(i=nOrderBy-1; i>0; i--){\n      Bitmask m = MASKBIT(i) - 1;\n      if( (obSat&m)==m ) return i;\n    }\n    return 0;\n  }\n  return -1;\n}\n\n\n/*\n** If the WHERE_GROUPBY flag is set in the mask passed to sqlite3WhereBegin(),\n** the planner assumes that the specified pOrderBy list is actually a GROUP\n** BY clause - and so any order that groups rows as required satisfies the\n** request.\n**\n** Normally, in this case it is not possible for the caller to determine\n** whether or not the rows are really being delivered in sorted order, or\n** just in some other order that provides the required grouping. However,\n** if the WHERE_SORTBYGROUP flag is also passed to sqlite3WhereBegin(), then\n** this function may be called on the returned WhereInfo object. It returns\n** true if the rows really will be sorted in the specified order, or false\n** otherwise.\n**\n** For example, assuming:\n**\n**   CREATE INDEX i1 ON t1(x, Y);\n**\n** then\n**\n**   SELECT * FROM t1 GROUP BY x,y ORDER BY x,y;   -- IsSorted()==1\n**   SELECT * FROM t1 GROUP BY y,x ORDER BY y,x;   -- IsSorted()==0\n*/\nint sqlite3WhereIsSorted(WhereInfo *pWInfo){\n  assert( pWInfo->wctrlFlags & WHERE_GROUPBY );\n  assert( pWInfo->wctrlFlags & WHERE_SORTBYGROUP );\n  return pWInfo->sorted;\n}\n\n#ifdef WHERETRACE_ENABLED\n/* For debugging use only: */\nstatic const char *wherePathName(WherePath *pPath, int nLoop, WhereLoop *pLast){\n  static char zName[65];\n  int i;\n  for(i=0; i<nLoop; i++){ zName[i] = pPath->aLoop[i]->cId; }\n  if( pLast ) zName[i++] = pLast->cId;\n  zName[i] = 0;\n  return zName;\n}\n#endif\n\n/*\n** Return the cost of sorting nRow rows, assuming that the keys have \n** nOrderby columns and that the first nSorted columns are already in\n** order.\n*/\nstatic LogEst whereSortingCost(\n  WhereInfo *pWInfo,\n  LogEst nRow,\n  int nOrderBy,\n  int nSorted\n){\n  /* TUNING: Estimated cost of a full external sort, where N is \n  ** the number of rows to sort is:\n  **\n  **   cost = (3.0 * N * log(N)).\n  ** \n  ** Or, if the order-by clause has X terms but only the last Y \n  ** terms are out of order, then block-sorting will reduce the \n  ** sorting cost to:\n  **\n  **   cost = (3.0 * N * log(N)) * (Y/X)\n  **\n  ** The (Y/X) term is implemented using stack variable rScale\n  ** below.  */\n  LogEst rScale, rSortCost;\n  assert( nOrderBy>0 && 66==sqlite3LogEst(100) );\n  rScale = sqlite3LogEst((nOrderBy-nSorted)*100/nOrderBy) - 66;\n  rSortCost = nRow + rScale + 16;\n\n  /* Multiple by log(M) where M is the number of output rows.\n  ** Use the LIMIT for M if it is smaller */\n  if( (pWInfo->wctrlFlags & WHERE_USE_LIMIT)!=0 && pWInfo->iLimit<nRow ){\n    nRow = pWInfo->iLimit;\n  }\n  rSortCost += estLog(nRow);\n  return rSortCost;\n}\n\n/*\n** Given the list of WhereLoop objects at pWInfo->pLoops, this routine\n** attempts to find the lowest cost path that visits each WhereLoop\n** once.  This path is then loaded into the pWInfo->a[].pWLoop fields.\n**\n** Assume that the total number of output rows that will need to be sorted\n** will be nRowEst (in the 10*log2 representation).  Or, ignore sorting\n** costs if nRowEst==0.\n**\n** Return SQLITE_OK on success or SQLITE_NOMEM of a memory allocation\n** error occurs.\n*/\nstatic int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){\n  int mxChoice;             /* Maximum number of simultaneous paths tracked */\n  int nLoop;                /* Number of terms in the join */\n  Parse *pParse;            /* Parsing context */\n  sqlite3 *db;              /* The database connection */\n  int iLoop;                /* Loop counter over the terms of the join */\n  int ii, jj;               /* Loop counters */\n  int mxI = 0;              /* Index of next entry to replace */\n  int nOrderBy;             /* Number of ORDER BY clause terms */\n  LogEst mxCost = 0;        /* Maximum cost of a set of paths */\n  LogEst mxUnsorted = 0;    /* Maximum unsorted cost of a set of path */\n  int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */\n  WherePath *aFrom;         /* All nFrom paths at the previous level */\n  WherePath *aTo;           /* The nTo best paths at the current level */\n  WherePath *pFrom;         /* An element of aFrom[] that we are working on */\n  WherePath *pTo;           /* An element of aTo[] that we are working on */\n  WhereLoop *pWLoop;        /* One of the WhereLoop objects */\n  WhereLoop **pX;           /* Used to divy up the pSpace memory */\n  LogEst *aSortCost = 0;    /* Sorting and partial sorting costs */\n  char *pSpace;             /* Temporary memory used by this routine */\n  int nSpace;               /* Bytes of space allocated at pSpace */\n\n  pParse = pWInfo->pParse;\n  db = pParse->db;\n  nLoop = pWInfo->nLevel;\n  /* TUNING: For simple queries, only the best path is tracked.\n  ** For 2-way joins, the 5 best paths are followed.\n  ** For joins of 3 or more tables, track the 10 best paths */\n  mxChoice = (nLoop<=1) ? 1 : (nLoop==2 ? 5 : 10);\n  assert( nLoop<=pWInfo->pTabList->nSrc );\n  WHERETRACE(0x002, (\"---- begin solver.  (nRowEst=%d)\\n\", nRowEst));\n\n  /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this\n  ** case the purpose of this call is to estimate the number of rows returned\n  ** by the overall query. Once this estimate has been obtained, the caller\n  ** will invoke this function a second time, passing the estimate as the\n  ** nRowEst parameter.  */\n  if( pWInfo->pOrderBy==0 || nRowEst==0 ){\n    nOrderBy = 0;\n  }else{\n    nOrderBy = pWInfo->pOrderBy->nExpr;\n  }\n\n  /* Allocate and initialize space for aTo, aFrom and aSortCost[] */\n  nSpace = (sizeof(WherePath)+sizeof(WhereLoop*)*nLoop)*mxChoice*2;\n  nSpace += sizeof(LogEst) * nOrderBy;\n  pSpace = sqlite3DbMallocRawNN(db, nSpace);\n  if( pSpace==0 ) return SQLITE_NOMEM_BKPT;\n  aTo = (WherePath*)pSpace;\n  aFrom = aTo+mxChoice;\n  memset(aFrom, 0, sizeof(aFrom[0]));\n  pX = (WhereLoop**)(aFrom+mxChoice);\n  for(ii=mxChoice*2, pFrom=aTo; ii>0; ii--, pFrom++, pX += nLoop){\n    pFrom->aLoop = pX;\n  }\n  if( nOrderBy ){\n    /* If there is an ORDER BY clause and it is not being ignored, set up\n    ** space for the aSortCost[] array. Each element of the aSortCost array\n    ** is either zero - meaning it has not yet been initialized - or the\n    ** cost of sorting nRowEst rows of data where the first X terms of\n    ** the ORDER BY clause are already in order, where X is the array \n    ** index.  */\n    aSortCost = (LogEst*)pX;\n    memset(aSortCost, 0, sizeof(LogEst) * nOrderBy);\n  }\n  assert( aSortCost==0 || &pSpace[nSpace]==(char*)&aSortCost[nOrderBy] );\n  assert( aSortCost!=0 || &pSpace[nSpace]==(char*)pX );\n\n  /* Seed the search with a single WherePath containing zero WhereLoops.\n  **\n  ** TUNING: Do not let the number of iterations go above 28.  If the cost\n  ** of computing an automatic index is not paid back within the first 28\n  ** rows, then do not use the automatic index. */\n  aFrom[0].nRow = MIN(pParse->nQueryLoop, 48);  assert( 48==sqlite3LogEst(28) );\n  nFrom = 1;\n  assert( aFrom[0].isOrdered==0 );\n  if( nOrderBy ){\n    /* If nLoop is zero, then there are no FROM terms in the query. Since\n    ** in this case the query may return a maximum of one row, the results\n    ** are already in the requested order. Set isOrdered to nOrderBy to\n    ** indicate this. Or, if nLoop is greater than zero, set isOrdered to\n    ** -1, indicating that the result set may or may not be ordered, \n    ** depending on the loops added to the current plan.  */\n    aFrom[0].isOrdered = nLoop>0 ? -1 : nOrderBy;\n  }\n\n  /* Compute successively longer WherePaths using the previous generation\n  ** of WherePaths as the basis for the next.  Keep track of the mxChoice\n  ** best paths at each generation */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    nTo = 0;\n    for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){\n      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){\n        LogEst nOut;                      /* Rows visited by (pFrom+pWLoop) */\n        LogEst rCost;                     /* Cost of path (pFrom+pWLoop) */\n        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */\n        i8 isOrdered = pFrom->isOrdered;  /* isOrdered for (pFrom+pWLoop) */\n        Bitmask maskNew;                  /* Mask of src visited by (..) */\n        Bitmask revMask = 0;              /* Mask of rev-order loops for (..) */\n\n        if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->maskSelf & pFrom->maskLoop)!=0 ) continue;\n        if( (pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 && pFrom->nRow<10 ){\n          /* Do not use an automatic index if the this loop is expected\n          ** to run less than 2 times. */\n          assert( 10==sqlite3LogEst(2) );\n          continue;\n        }\n        /* At this point, pWLoop is a candidate to be the next loop. \n        ** Compute its cost */\n        rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup,pWLoop->rRun + pFrom->nRow);\n        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);\n        nOut = pFrom->nRow + pWLoop->nOut;\n        maskNew = pFrom->maskLoop | pWLoop->maskSelf;\n        if( isOrdered<0 ){\n          isOrdered = wherePathSatisfiesOrderBy(pWInfo,\n                       pWInfo->pOrderBy, pFrom, pWInfo->wctrlFlags,\n                       iLoop, pWLoop, &revMask);\n        }else{\n          revMask = pFrom->revLoop;\n        }\n        if( isOrdered>=0 && isOrdered<nOrderBy ){\n          if( aSortCost[isOrdered]==0 ){\n            aSortCost[isOrdered] = whereSortingCost(\n                pWInfo, nRowEst, nOrderBy, isOrdered\n            );\n          }\n          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]);\n\n          WHERETRACE(0x002,\n              (\"---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\\n\",\n               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy, \n               rUnsorted, rCost));\n        }else{\n          rCost = rUnsorted;\n          rUnsorted -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */\n        }\n\n        /* Check to see if pWLoop should be added to the set of\n        ** mxChoice best-so-far paths.\n        **\n        ** First look for an existing path among best-so-far paths\n        ** that covers the same set of loops and has the same isOrdered\n        ** setting as the current path candidate.\n        **\n        ** The term \"((pTo->isOrdered^isOrdered)&0x80)==0\" is equivalent\n        ** to (pTo->isOrdered==(-1))==(isOrdered==(-1))\" for the range\n        ** of legal values for isOrdered, -1..64.\n        */\n        for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){\n          if( pTo->maskLoop==maskNew\n           && ((pTo->isOrdered^isOrdered)&0x80)==0\n          ){\n            testcase( jj==nTo-1 );\n            break;\n          }\n        }\n        if( jj>=nTo ){\n          /* None of the existing best-so-far paths match the candidate. */\n          if( nTo>=mxChoice\n           && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))\n          ){\n            /* The current candidate is no better than any of the mxChoice\n            ** paths currently in the best-so-far buffer.  So discard\n            ** this candidate as not viable. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\"Skip   %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n            }\n#endif\n            continue;\n          }\n          /* If we reach this points it means that the new candidate path\n          ** needs to be added to the set of best-so-far paths. */\n          if( nTo<mxChoice ){\n            /* Increase the size of the aTo set by one */\n            jj = nTo++;\n          }else{\n            /* New path replaces the prior worst to keep count below mxChoice */\n            jj = mxI;\n          }\n          pTo = &aTo[jj];\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\"New    %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n          }\n#endif\n        }else{\n          /* Control reaches here if best-so-far path pTo=aTo[jj] covers the\n          ** same set of loops and has the same isOrdered setting as the\n          ** candidate path.  Check to see if the candidate should replace\n          ** pTo or if the candidate should be skipped.\n          ** \n          ** The conditional is an expanded vector comparison equivalent to:\n          **   (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)\n          */\n          if( pTo->rCost<rCost \n           || (pTo->rCost==rCost\n               && (pTo->nRow<nOut\n                   || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)\n                  )\n              )\n          ){\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n            if( sqlite3WhereTrace&0x4 ){\n              sqlite3DebugPrintf(\n                  \"Skip   %s cost=%-3d,%3d,%3d order=%c\",\n                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                  isOrdered>=0 ? isOrdered+'0' : '?');\n              sqlite3DebugPrintf(\"   vs %s cost=%-3d,%3d,%3d order=%c\\n\",\n                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                  pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n            }\n#endif\n            /* Discard the candidate path from further consideration */\n            testcase( pTo->rCost==rCost );\n            continue;\n          }\n          testcase( pTo->rCost==rCost+1 );\n          /* Control reaches here if the candidate path is better than the\n          ** pTo path.  Replace pTo with the candidate. */\n#ifdef WHERETRACE_ENABLED /* 0x4 */\n          if( sqlite3WhereTrace&0x4 ){\n            sqlite3DebugPrintf(\n                \"Update %s cost=%-3d,%3d,%3d order=%c\",\n                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,\n                isOrdered>=0 ? isOrdered+'0' : '?');\n            sqlite3DebugPrintf(\"  was %s cost=%-3d,%3d,%3d order=%c\\n\",\n                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n                pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');\n          }\n#endif\n        }\n        /* pWLoop is a winner.  Add it to the set of best so far */\n        pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;\n        pTo->revLoop = revMask;\n        pTo->nRow = nOut;\n        pTo->rCost = rCost;\n        pTo->rUnsorted = rUnsorted;\n        pTo->isOrdered = isOrdered;\n        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);\n        pTo->aLoop[iLoop] = pWLoop;\n        if( nTo>=mxChoice ){\n          mxI = 0;\n          mxCost = aTo[0].rCost;\n          mxUnsorted = aTo[0].nRow;\n          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){\n            if( pTo->rCost>mxCost \n             || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted) \n            ){\n              mxCost = pTo->rCost;\n              mxUnsorted = pTo->rUnsorted;\n              mxI = jj;\n            }\n          }\n        }\n      }\n    }\n\n#ifdef WHERETRACE_ENABLED  /* >=2 */\n    if( sqlite3WhereTrace & 0x02 ){\n      sqlite3DebugPrintf(\"---- after round %d ----\\n\", iLoop);\n      for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){\n        sqlite3DebugPrintf(\" %s cost=%-3d nrow=%-3d order=%c\",\n           wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,\n           pTo->isOrdered>=0 ? (pTo->isOrdered+'0') : '?');\n        if( pTo->isOrdered>0 ){\n          sqlite3DebugPrintf(\" rev=0x%llx\\n\", pTo->revLoop);\n        }else{\n          sqlite3DebugPrintf(\"\\n\");\n        }\n      }\n    }\n#endif\n\n    /* Swap the roles of aFrom and aTo for the next generation */\n    pFrom = aTo;\n    aTo = aFrom;\n    aFrom = pFrom;\n    nFrom = nTo;\n  }\n\n  if( nFrom==0 ){\n    sqlite3ErrorMsg(pParse, \"no query solution\");\n    sqlite3DbFreeNN(db, pSpace);\n    return SQLITE_ERROR;\n  }\n  \n  /* Find the lowest cost path.  pFrom will be left pointing to that path */\n  pFrom = aFrom;\n  for(ii=1; ii<nFrom; ii++){\n    if( pFrom->rCost>aFrom[ii].rCost ) pFrom = &aFrom[ii];\n  }\n  assert( pWInfo->nLevel==nLoop );\n  /* Load the lowest cost path into pWInfo */\n  for(iLoop=0; iLoop<nLoop; iLoop++){\n    WhereLevel *pLevel = pWInfo->a + iLoop;\n    pLevel->pWLoop = pWLoop = pFrom->aLoop[iLoop];\n    pLevel->iFrom = pWLoop->iTab;\n    pLevel->iTabCur = pWInfo->pTabList->a[pLevel->iFrom].iCursor;\n  }\n  if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)!=0\n   && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0\n   && pWInfo->eDistinct==WHERE_DISTINCT_NOOP\n   && nRowEst\n  ){\n    Bitmask notUsed;\n    int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,\n                 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);\n    if( rc==pWInfo->pResultSet->nExpr ){\n      pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n    }\n  }\n  if( pWInfo->pOrderBy ){\n    if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){\n      if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){\n        pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;\n      }\n    }else{\n      pWInfo->nOBSat = pFrom->isOrdered;\n      pWInfo->revMask = pFrom->revLoop;\n      if( pWInfo->nOBSat<=0 ){\n        pWInfo->nOBSat = 0;\n        if( nLoop>0 ){\n          u32 wsFlags = pFrom->aLoop[nLoop-1]->wsFlags;\n          if( (wsFlags & WHERE_ONEROW)==0 \n           && (wsFlags&(WHERE_IPK|WHERE_COLUMN_IN))!=(WHERE_IPK|WHERE_COLUMN_IN)\n          ){\n            Bitmask m = 0;\n            int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom,\n                      WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m);\n            testcase( wsFlags & WHERE_IPK );\n            testcase( wsFlags & WHERE_COLUMN_IN );\n            if( rc==pWInfo->pOrderBy->nExpr ){\n              pWInfo->bOrderedInnerLoop = 1;\n              pWInfo->revMask = m;\n            }\n          }\n        }\n      }\n    }\n    if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)\n        && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0\n    ){\n      Bitmask revMask = 0;\n      int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, \n          pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask\n      );\n      assert( pWInfo->sorted==0 );\n      if( nOrder==pWInfo->pOrderBy->nExpr ){\n        pWInfo->sorted = 1;\n        pWInfo->revMask = revMask;\n      }\n    }\n  }\n\n\n  pWInfo->nRowOut = pFrom->nRow;\n\n  /* Free temporary memory and return success */\n  sqlite3DbFreeNN(db, pSpace);\n  return SQLITE_OK;\n}\n\n/*\n** Most queries use only a single table (they are not joins) and have\n** simple == constraints against indexed fields.  This routine attempts\n** to plan those simple cases using much less ceremony than the\n** general-purpose query planner, and thereby yield faster sqlite3_prepare()\n** times for the common case.\n**\n** Return non-zero on success, if this query can be handled by this\n** no-frills query planner.  Return zero if this query needs the \n** general-purpose query planner.\n*/\nstatic int whereShortCut(WhereLoopBuilder *pBuilder){\n  WhereInfo *pWInfo;\n  struct SrcList_item *pItem;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  WhereLoop *pLoop;\n  int iCur;\n  int j;\n  Table *pTab;\n  Index *pIdx;\n\n  pWInfo = pBuilder->pWInfo;\n  if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;\n  assert( pWInfo->pTabList->nSrc>=1 );\n  pItem = pWInfo->pTabList->a;\n  pTab = pItem->pTab;\n  if( IsVirtual(pTab) ) return 0;\n  if( pItem->fg.isIndexedBy ) return 0;\n  iCur = pItem->iCursor;\n  pWC = &pWInfo->sWC;\n  pLoop = pBuilder->pNew;\n  pLoop->wsFlags = 0;\n  pLoop->nSkip = 0;\n  pTerm = sqlite3WhereFindTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0);\n  if( pTerm ){\n    testcase( pTerm->eOperator & WO_IS );\n    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;\n    pLoop->aLTerm[0] = pTerm;\n    pLoop->nLTerm = 1;\n    pLoop->u.btree.nEq = 1;\n    /* TUNING: Cost of a rowid lookup is 10 */\n    pLoop->rRun = 33;  /* 33==sqlite3LogEst(10) */\n  }else{\n    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n      int opMask;\n      assert( pLoop->aLTermSpace==pLoop->aLTerm );\n      if( !IsUniqueIndex(pIdx)\n       || pIdx->pPartIdxWhere!=0 \n       || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) \n      ) continue;\n      opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;\n      for(j=0; j<pIdx->nKeyCol; j++){\n        pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);\n        if( pTerm==0 ) break;\n        testcase( pTerm->eOperator & WO_IS );\n        pLoop->aLTerm[j] = pTerm;\n      }\n      if( j!=pIdx->nKeyCol ) continue;\n      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;\n      if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){\n        pLoop->wsFlags |= WHERE_IDX_ONLY;\n      }\n      pLoop->nLTerm = j;\n      pLoop->u.btree.nEq = j;\n      pLoop->u.btree.pIndex = pIdx;\n      /* TUNING: Cost of a unique index lookup is 15 */\n      pLoop->rRun = 39;  /* 39==sqlite3LogEst(15) */\n      break;\n    }\n  }\n  if( pLoop->wsFlags ){\n    pLoop->nOut = (LogEst)1;\n    pWInfo->a[0].pWLoop = pLoop;\n    assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] );\n    pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */\n    pWInfo->a[0].iTabCur = iCur;\n    pWInfo->nRowOut = 1;\n    if( pWInfo->pOrderBy ) pWInfo->nOBSat =  pWInfo->pOrderBy->nExpr;\n    if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n#ifdef SQLITE_DEBUG\n    pLoop->cId = '0';\n#endif\n    return 1;\n  }\n  return 0;\n}\n\n/*\n** Helper function for exprIsDeterministic().\n*/\nstatic int exprNodeIsDeterministic(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_FUNCTION && ExprHasProperty(pExpr, EP_ConstFunc)==0 ){\n    pWalker->eCode = 0;\n    return WRC_Abort;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Return true if the expression contains no non-deterministic SQL \n** functions. Do not consider non-deterministic SQL functions that are \n** part of sub-select statements.\n*/\nstatic int exprIsDeterministic(Expr *p){\n  Walker w;\n  memset(&w, 0, sizeof(w));\n  w.eCode = 1;\n  w.xExprCallback = exprNodeIsDeterministic;\n  w.xSelectCallback = sqlite3SelectWalkFail;\n  sqlite3WalkExpr(&w, p);\n  return w.eCode;\n}\n\n/*\n** Generate the beginning of the loop used for WHERE clause processing.\n** The return value is a pointer to an opaque structure that contains\n** information needed to terminate the loop.  Later, the calling routine\n** should invoke sqlite3WhereEnd() with the return value of this function\n** in order to complete the WHERE clause processing.\n**\n** If an error occurs, this routine returns NULL.\n**\n** The basic idea is to do a nested loop, one loop for each table in\n** the FROM clause of a select.  (INSERT and UPDATE statements are the\n** same as a SELECT with only a single table in the FROM clause.)  For\n** example, if the SQL is this:\n**\n**       SELECT * FROM t1, t2, t3 WHERE ...;\n**\n** Then the code generated is conceptually like the following:\n**\n**      foreach row1 in t1 do       \\    Code generated\n**        foreach row2 in t2 do      |-- by sqlite3WhereBegin()\n**          foreach row3 in t3 do   /\n**            ...\n**          end                     \\    Code generated\n**        end                        |-- by sqlite3WhereEnd()\n**      end                         /\n**\n** Note that the loops might not be nested in the order in which they\n** appear in the FROM clause if a different order is better able to make\n** use of indices.  Note also that when the IN operator appears in\n** the WHERE clause, it might result in additional nested loops for\n** scanning through all values on the right-hand side of the IN.\n**\n** There are Btree cursors associated with each table.  t1 uses cursor\n** number pTabList->a[0].iCursor.  t2 uses the cursor pTabList->a[1].iCursor.\n** And so forth.  This routine generates code to open those VDBE cursors\n** and sqlite3WhereEnd() generates the code to close them.\n**\n** The code that sqlite3WhereBegin() generates leaves the cursors named\n** in pTabList pointing at their appropriate entries.  The [...] code\n** can use OP_Column and OP_Rowid opcodes on these cursors to extract\n** data from the various tables of the loop.\n**\n** If the WHERE clause is empty, the foreach loops must each scan their\n** entire tables.  Thus a three-way join is an O(N^3) operation.  But if\n** the tables have indices and there are terms in the WHERE clause that\n** refer to those indices, a complete table scan can be avoided and the\n** code will run much faster.  Most of the work of this routine is checking\n** to see if there are indices that can be used to speed up the loop.\n**\n** Terms of the WHERE clause are also used to limit which rows actually\n** make it to the \"...\" in the middle of the loop.  After each \"foreach\",\n** terms of the WHERE clause that use only terms in that loop and outer\n** loops are evaluated and if false a jump is made around all subsequent\n** inner loops (or around the \"...\" if the test occurs within the inner-\n** most loop)\n**\n** OUTER JOINS\n**\n** An outer join of tables t1 and t2 is conceptally coded as follows:\n**\n**    foreach row1 in t1 do\n**      flag = 0\n**      foreach row2 in t2 do\n**        start:\n**          ...\n**          flag = 1\n**      end\n**      if flag==0 then\n**        move the row2 cursor to a null row\n**        goto start\n**      fi\n**    end\n**\n** ORDER BY CLAUSE PROCESSING\n**\n** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause\n** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement\n** if there is one.  If there is no ORDER BY clause or if this routine\n** is called from an UPDATE or DELETE statement, then pOrderBy is NULL.\n**\n** The iIdxCur parameter is the cursor number of an index.  If \n** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index\n** to use for OR clause processing.  The WHERE clause should use this\n** specific cursor.  If WHERE_ONEPASS_DESIRED is set, then iIdxCur is\n** the first cursor in an array of cursors for all indices.  iIdxCur should\n** be used to compute the appropriate cursor depending on which index is\n** used.\n*/\nWhereInfo *sqlite3WhereBegin(\n  Parse *pParse,          /* The parser context */\n  SrcList *pTabList,      /* FROM clause: A list of all tables to be scanned */\n  Expr *pWhere,           /* The WHERE clause */\n  ExprList *pOrderBy,     /* An ORDER BY (or GROUP BY) clause, or NULL */\n  ExprList *pResultSet,   /* Query result set.  Req'd for DISTINCT */\n  u16 wctrlFlags,         /* The WHERE_* flags defined in sqliteInt.h */\n  int iAuxArg             /* If WHERE_OR_SUBCLAUSE is set, index cursor number\n                          ** If WHERE_USE_LIMIT, then the limit amount */\n){\n  int nByteWInfo;            /* Num. bytes allocated for WhereInfo struct */\n  int nTabList;              /* Number of elements in pTabList */\n  WhereInfo *pWInfo;         /* Will become the return value of this function */\n  Vdbe *v = pParse->pVdbe;   /* The virtual database engine */\n  Bitmask notReady;          /* Cursors that are not yet positioned */\n  WhereLoopBuilder sWLB;     /* The WhereLoop builder */\n  WhereMaskSet *pMaskSet;    /* The expression mask set */\n  WhereLevel *pLevel;        /* A single level in pWInfo->a[] */\n  WhereLoop *pLoop;          /* Pointer to a single WhereLoop object */\n  int ii;                    /* Loop counter */\n  sqlite3 *db;               /* Database connection */\n  int rc;                    /* Return code */\n  u8 bFordelete = 0;         /* OPFLAG_FORDELETE or zero, as appropriate */\n\n  assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || (\n        (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 \n     && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 \n  ));\n\n  /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */\n  assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0\n            || (wctrlFlags & WHERE_USE_LIMIT)==0 );\n\n  /* Variable initialization */\n  db = pParse->db;\n  memset(&sWLB, 0, sizeof(sWLB));\n\n  /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */\n  testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );\n  if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;\n  sWLB.pOrderBy = pOrderBy;\n\n  /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via\n  ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */\n  if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){\n    wctrlFlags &= ~WHERE_WANT_DISTINCT;\n  }\n\n  /* The number of tables in the FROM clause is limited by the number of\n  ** bits in a Bitmask \n  */\n  testcase( pTabList->nSrc==BMS );\n  if( pTabList->nSrc>BMS ){\n    sqlite3ErrorMsg(pParse, \"at most %d tables in a join\", BMS);\n    return 0;\n  }\n\n  /* This function normally generates a nested loop for all tables in \n  ** pTabList.  But if the WHERE_OR_SUBCLAUSE flag is set, then we should\n  ** only generate code for the first table in pTabList and assume that\n  ** any cursors associated with subsequent tables are uninitialized.\n  */\n  nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc;\n\n  /* Allocate and initialize the WhereInfo structure that will become the\n  ** return value. A single allocation is used to store the WhereInfo\n  ** struct, the contents of WhereInfo.a[], the WhereClause structure\n  ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte\n  ** field (type Bitmask) it must be aligned on an 8-byte boundary on\n  ** some architectures. Hence the ROUND8() below.\n  */\n  nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));\n  pWInfo = sqlite3DbMallocRawNN(db, nByteWInfo + sizeof(WhereLoop));\n  if( db->mallocFailed ){\n    sqlite3DbFree(db, pWInfo);\n    pWInfo = 0;\n    goto whereBeginError;\n  }\n  pWInfo->pParse = pParse;\n  pWInfo->pTabList = pTabList;\n  pWInfo->pOrderBy = pOrderBy;\n  pWInfo->pWhere = pWhere;\n  pWInfo->pResultSet = pResultSet;\n  pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;\n  pWInfo->nLevel = nTabList;\n  pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);\n  pWInfo->wctrlFlags = wctrlFlags;\n  pWInfo->iLimit = iAuxArg;\n  pWInfo->savedNQueryLoop = pParse->nQueryLoop;\n  memset(&pWInfo->nOBSat, 0, \n         offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));\n  memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));\n  assert( pWInfo->eOnePass==ONEPASS_OFF );  /* ONEPASS defaults to OFF */\n  pMaskSet = &pWInfo->sMaskSet;\n  sWLB.pWInfo = pWInfo;\n  sWLB.pWC = &pWInfo->sWC;\n  sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);\n  assert( EIGHT_BYTE_ALIGNMENT(sWLB.pNew) );\n  whereLoopInit(sWLB.pNew);\n#ifdef SQLITE_DEBUG\n  sWLB.pNew->cId = '*';\n#endif\n\n  /* Split the WHERE clause into separate subexpressions where each\n  ** subexpression is separated by an AND operator.\n  */\n  initMaskSet(pMaskSet);\n  sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);\n  sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);\n    \n  /* Special case: No FROM clause\n  */\n  if( nTabList==0 ){\n    if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;\n    if( wctrlFlags & WHERE_WANT_DISTINCT ){\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }\n  }else{\n    /* Assign a bit from the bitmask to every term in the FROM clause.\n    **\n    ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.\n    **\n    ** The rule of the previous sentence ensures thta if X is the bitmask for\n    ** a table T, then X-1 is the bitmask for all other tables to the left of T.\n    ** Knowing the bitmask for all tables to the left of a left join is\n    ** important.  Ticket #3015.\n    **\n    ** Note that bitmasks are created for all pTabList->nSrc tables in\n    ** pTabList, not just the first nTabList tables.  nTabList is normally\n    ** equal to pTabList->nSrc but might be shortened to 1 if the\n    ** WHERE_OR_SUBCLAUSE flag is set.\n    */\n    ii = 0;\n    do{\n      createMask(pMaskSet, pTabList->a[ii].iCursor);\n      sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);\n    }while( (++ii)<pTabList->nSrc );\n  #ifdef SQLITE_DEBUG\n    {\n      Bitmask mx = 0;\n      for(ii=0; ii<pTabList->nSrc; ii++){\n        Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor);\n        assert( m>=mx );\n        mx = m;\n      }\n    }\n  #endif\n  }\n  \n  /* Analyze all of the subexpressions. */\n  sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Special case: WHERE terms that do not refer to any tables in the join\n  ** (constant expressions). Evaluate each such term, and jump over all the\n  ** generated code if the result is not true.  \n  **\n  ** Do not do this if the expression contains non-deterministic functions\n  ** that are not within a sub-select. This is not strictly required, but\n  ** preserves SQLite's legacy behaviour in the following two cases:\n  **\n  **   FROM ... WHERE random()>0;           -- eval random() once per row\n  **   FROM ... WHERE (SELECT random())>0;  -- eval random() once overall\n  */\n  for(ii=0; ii<sWLB.pWC->nTerm; ii++){\n    WhereTerm *pT = &sWLB.pWC->a[ii];\n    if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){\n      sqlite3ExprIfFalse(pParse, pT->pExpr, pWInfo->iBreak, SQLITE_JUMPIFNULL);\n      pT->wtFlags |= TERM_CODED;\n    }\n  }\n\n  if( wctrlFlags & WHERE_WANT_DISTINCT ){\n    if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){\n      /* The DISTINCT marking is pointless.  Ignore it. */\n      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;\n    }else if( pOrderBy==0 ){\n      /* Try to ORDER BY the result set to make distinct processing easier */\n      pWInfo->wctrlFlags |= WHERE_DISTINCTBY;\n      pWInfo->pOrderBy = pResultSet;\n    }\n  }\n\n  /* Construct the WhereLoop objects */\n#if defined(WHERETRACE_ENABLED)\n  if( sqlite3WhereTrace & 0xffff ){\n    sqlite3DebugPrintf(\"*** Optimizer Start *** (wctrlFlags: 0x%x\",wctrlFlags);\n    if( wctrlFlags & WHERE_USE_LIMIT ){\n      sqlite3DebugPrintf(\", limit: %d\", iAuxArg);\n    }\n    sqlite3DebugPrintf(\")\\n\");\n  }\n  if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */\n    sqlite3WhereClausePrint(sWLB.pWC);\n  }\n#endif\n\n  if( nTabList!=1 || whereShortCut(&sWLB)==0 ){\n    rc = whereLoopAddAll(&sWLB);\n    if( rc ) goto whereBeginError;\n  \n#ifdef WHERETRACE_ENABLED\n    if( sqlite3WhereTrace ){    /* Display all of the WhereLoop objects */\n      WhereLoop *p;\n      int i;\n      static const char zLabel[] = \"0123456789abcdefghijklmnopqrstuvwyxz\"\n                                             \"ABCDEFGHIJKLMNOPQRSTUVWYXZ\";\n      for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){\n        p->cId = zLabel[i%(sizeof(zLabel)-1)];\n        whereLoopPrint(p, sWLB.pWC);\n      }\n    }\n#endif\n  \n    wherePathSolver(pWInfo, 0);\n    if( db->mallocFailed ) goto whereBeginError;\n    if( pWInfo->pOrderBy ){\n       wherePathSolver(pWInfo, pWInfo->nRowOut+1);\n       if( db->mallocFailed ) goto whereBeginError;\n    }\n  }\n  if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){\n     pWInfo->revMask = ALLBITS;\n  }\n  if( pParse->nErr || NEVER(db->mallocFailed) ){\n    goto whereBeginError;\n  }\n#ifdef WHERETRACE_ENABLED\n  if( sqlite3WhereTrace ){\n    sqlite3DebugPrintf(\"---- Solution nRow=%d\", pWInfo->nRowOut);\n    if( pWInfo->nOBSat>0 ){\n      sqlite3DebugPrintf(\" ORDERBY=%d,0x%llx\", pWInfo->nOBSat, pWInfo->revMask);\n    }\n    switch( pWInfo->eDistinct ){\n      case WHERE_DISTINCT_UNIQUE: {\n        sqlite3DebugPrintf(\"  DISTINCT=unique\");\n        break;\n      }\n      case WHERE_DISTINCT_ORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=ordered\");\n        break;\n      }\n      case WHERE_DISTINCT_UNORDERED: {\n        sqlite3DebugPrintf(\"  DISTINCT=unordered\");\n        break;\n      }\n    }\n    sqlite3DebugPrintf(\"\\n\");\n    for(ii=0; ii<pWInfo->nLevel; ii++){\n      whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC);\n    }\n  }\n#endif\n  /* Attempt to omit tables from the join that do not effect the result */\n  if( pWInfo->nLevel>=2\n   && pResultSet!=0\n   && OptimizationEnabled(db, SQLITE_OmitNoopJoin)\n  ){\n    Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);\n    if( sWLB.pOrderBy ){\n      tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);\n    }\n    while( pWInfo->nLevel>=2 ){\n      WhereTerm *pTerm, *pEnd;\n      pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;\n      if( (pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 ) break;\n      if( (wctrlFlags & WHERE_WANT_DISTINCT)==0\n       && (pLoop->wsFlags & WHERE_ONEROW)==0\n      ){\n        break;\n      }\n      if( (tabUsed & pLoop->maskSelf)!=0 ) break;\n      pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;\n      for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){\n        if( (pTerm->prereqAll & pLoop->maskSelf)!=0\n         && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)\n        ){\n          break;\n        }\n      }\n      if( pTerm<pEnd ) break;\n      WHERETRACE(0xffff, (\"-> drop loop %c not used\\n\", pLoop->cId));\n      pWInfo->nLevel--;\n      nTabList--;\n    }\n  }\n  WHERETRACE(0xffff,(\"*** Optimizer Finished ***\\n\"));\n  pWInfo->pParse->nQueryLoop += pWInfo->nRowOut;\n\n  /* If the caller is an UPDATE or DELETE statement that is requesting\n  ** to use a one-pass algorithm, determine if this is appropriate.\n  */\n  assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 );\n  if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){\n    int wsFlags = pWInfo->a[0].pWLoop->wsFlags;\n    int bOnerow = (wsFlags & WHERE_ONEROW)!=0;\n    if( bOnerow\n     || ((wctrlFlags & WHERE_ONEPASS_MULTIROW)!=0\n           && 0==(wsFlags & WHERE_VIRTUALTABLE))\n    ){\n      pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;\n      if( HasRowid(pTabList->a[0].pTab) && (wsFlags & WHERE_IDX_ONLY) ){\n        if( wctrlFlags & WHERE_ONEPASS_MULTIROW ){\n          bFordelete = OPFLAG_FORDELETE;\n        }\n        pWInfo->a[0].pWLoop->wsFlags = (wsFlags & ~WHERE_IDX_ONLY);\n      }\n    }\n  }\n\n  /* Open all tables in the pTabList and any indices selected for\n  ** searching those tables.\n  */\n  for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){\n    Table *pTab;     /* Table to open */\n    int iDb;         /* Index of database containing table/index */\n    struct SrcList_item *pTabItem;\n\n    pTabItem = &pTabList->a[pLevel->iFrom];\n    pTab = pTabItem->pTab;\n    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);\n    pLoop = pLevel->pWLoop;\n    if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){\n      /* Do nothing */\n    }else\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n      const char *pVTab = (const char *)sqlite3GetVTable(db, pTab);\n      int iCur = pTabItem->iCursor;\n      sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB);\n    }else if( IsVirtual(pTab) ){\n      /* noop */\n    }else\n#endif\n    if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0\n         && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){\n      int op = OP_OpenRead;\n      if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[0] = pTabItem->iCursor;\n      };\n      sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op);\n      assert( pTabItem->iCursor==pLevel->iTabCur );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS-1 );\n      testcase( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol==BMS );\n      if( pWInfo->eOnePass==ONEPASS_OFF && pTab->nCol<BMS && HasRowid(pTab) ){\n        Bitmask b = pTabItem->colUsed;\n        int n = 0;\n        for(; b; b=b>>1, n++){}\n        sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(n), P4_INT32);\n        assert( n<=pTab->nCol );\n      }\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n      if( pLoop->u.btree.pIndex!=0 ){\n        sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ|bFordelete);\n      }else\n#endif\n      {\n        sqlite3VdbeChangeP5(v, bFordelete);\n      }\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n      sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, pTabItem->iCursor, 0, 0,\n                            (const u8*)&pTabItem->colUsed, P4_INT64);\n#endif\n    }else{\n      sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);\n    }\n    if( pLoop->wsFlags & WHERE_INDEXED ){\n      Index *pIx = pLoop->u.btree.pIndex;\n      int iIndexCur;\n      int op = OP_OpenRead;\n      /* iAuxArg is always set to a positive value if ONEPASS is possible */\n      assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 );\n      if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx)\n       && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0\n      ){\n        /* This is one term of an OR-optimization using the PRIMARY KEY of a\n        ** WITHOUT ROWID table.  No need for a separate index */\n        iIndexCur = pLevel->iTabCur;\n        op = 0;\n      }else if( pWInfo->eOnePass!=ONEPASS_OFF ){\n        Index *pJ = pTabItem->pTab->pIndex;\n        iIndexCur = iAuxArg;\n        assert( wctrlFlags & WHERE_ONEPASS_DESIRED );\n        while( ALWAYS(pJ) && pJ!=pIx ){\n          iIndexCur++;\n          pJ = pJ->pNext;\n        }\n        op = OP_OpenWrite;\n        pWInfo->aiCurOnePass[1] = iIndexCur;\n      }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){\n        iIndexCur = iAuxArg;\n        op = OP_ReopenIdx;\n      }else{\n        iIndexCur = pParse->nTab++;\n      }\n      pLevel->iIdxCur = iIndexCur;\n      assert( pIx->pSchema==pTab->pSchema );\n      assert( iIndexCur>=0 );\n      if( op ){\n        sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);\n        sqlite3VdbeSetP4KeyInfo(pParse, pIx);\n        if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0\n         && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0\n         && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0\n         && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED\n        ){\n          sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */\n        }\n        VdbeComment((v, \"%s\", pIx->zName));\n#ifdef SQLITE_ENABLE_COLUMN_USED_MASK\n        {\n          u64 colUsed = 0;\n          int ii, jj;\n          for(ii=0; ii<pIx->nColumn; ii++){\n            jj = pIx->aiColumn[ii];\n            if( jj<0 ) continue;\n            if( jj>63 ) jj = 63;\n            if( (pTabItem->colUsed & MASKBIT(jj))==0 ) continue;\n            colUsed |= ((u64)1)<<(ii<63 ? ii : 63);\n          }\n          sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, iIndexCur, 0, 0,\n                                (u8*)&colUsed, P4_INT64);\n        }\n#endif /* SQLITE_ENABLE_COLUMN_USED_MASK */\n      }\n    }\n    if( iDb>=0 ) sqlite3CodeVerifySchema(pParse, iDb);\n  }\n  pWInfo->iTop = sqlite3VdbeCurrentAddr(v);\n  if( db->mallocFailed ) goto whereBeginError;\n\n  /* Generate the code to do the search.  Each iteration of the for\n  ** loop below generates code for a single nested loop of the VM\n  ** program.\n  */\n  notReady = ~(Bitmask)0;\n  for(ii=0; ii<nTabList; ii++){\n    int addrExplain;\n    int wsFlags;\n    pLevel = &pWInfo->a[ii];\n    wsFlags = pLevel->pWLoop->wsFlags;\n#ifndef SQLITE_OMIT_AUTOMATIC_INDEX\n    if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){\n      constructAutomaticIndex(pParse, &pWInfo->sWC,\n                &pTabList->a[pLevel->iFrom], notReady, pLevel);\n      if( db->mallocFailed ) goto whereBeginError;\n    }\n#endif\n    addrExplain = sqlite3WhereExplainOneScan(\n        pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags\n    );\n    pLevel->addrBody = sqlite3VdbeCurrentAddr(v);\n    notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);\n    pWInfo->iContinue = pLevel->addrCont;\n    if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){\n      sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);\n    }\n  }\n\n  /* Done. */\n  VdbeModuleComment((v, \"Begin WHERE-core\"));\n  return pWInfo;\n\n  /* Jump here if malloc fails */\nwhereBeginError:\n  if( pWInfo ){\n    pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n    whereInfoFree(db, pWInfo);\n  }\n  return 0;\n}\n\n/*\n** Generate the end of the WHERE loop.  See comments on \n** sqlite3WhereBegin() for additional information.\n*/\nvoid sqlite3WhereEnd(WhereInfo *pWInfo){\n  Parse *pParse = pWInfo->pParse;\n  Vdbe *v = pParse->pVdbe;\n  int i;\n  WhereLevel *pLevel;\n  WhereLoop *pLoop;\n  SrcList *pTabList = pWInfo->pTabList;\n  sqlite3 *db = pParse->db;\n\n  /* Generate loop termination code.\n  */\n  VdbeModuleComment((v, \"End WHERE-core\"));\n  sqlite3ExprCacheClear(pParse);\n  for(i=pWInfo->nLevel-1; i>=0; i--){\n    int addr;\n    pLevel = &pWInfo->a[i];\n    pLoop = pLevel->pWLoop;\n    if( pLevel->op!=OP_Noop ){\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      int addrSeek = 0;\n      Index *pIdx;\n      int n;\n      if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED\n       && (pLoop->wsFlags & WHERE_INDEXED)!=0\n       && (pIdx = pLoop->u.btree.pIndex)->hasStat1\n       && (n = pLoop->u.btree.nIdxCol)>0\n       && pIdx->aiRowLogEst[n]>=36\n      ){\n        int r1 = pParse->nMem+1;\n        int j, op;\n        for(j=0; j<n; j++){\n          sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j);\n        }\n        pParse->nMem += n+1;\n        op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT;\n        addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n);\n        VdbeCoverageIf(v, op==OP_SeekLT);\n        VdbeCoverageIf(v, op==OP_SeekGT);\n        sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2);\n      }\n#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */\n      /* The common case: Advance to the next row */\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n      sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);\n      sqlite3VdbeChangeP5(v, pLevel->p5);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, pLevel->op==OP_Next);\n      VdbeCoverageIf(v, pLevel->op==OP_Prev);\n      VdbeCoverageIf(v, pLevel->op==OP_VNext);\n#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT\n      if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek);\n#endif\n    }else{\n      sqlite3VdbeResolveLabel(v, pLevel->addrCont);\n    }\n    if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){\n      struct InLoop *pIn;\n      int j;\n      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);\n      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){\n        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);\n        if( pIn->eEndLoopOp!=OP_Noop ){\n          sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);\n          VdbeCoverage(v);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);\n          VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);\n        }\n        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);\n      }\n    }\n    sqlite3VdbeResolveLabel(v, pLevel->addrBrk);\n    if( pLevel->addrSkip ){\n      sqlite3VdbeGoto(v, pLevel->addrSkip);\n      VdbeComment((v, \"next skip-scan on %s\", pLoop->u.btree.pIndex->zName));\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip);\n      sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);\n    }\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n    if( pLevel->addrLikeRep ){\n      sqlite3VdbeAddOp2(v, OP_DecrJumpZero, (int)(pLevel->iLikeRepCntr>>1),\n                        pLevel->addrLikeRep);\n      VdbeCoverage(v);\n    }\n#endif\n    if( pLevel->iLeftJoin ){\n      int ws = pLoop->wsFlags;\n      addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);\n      assert( (ws & WHERE_IDX_ONLY)==0 || (ws & WHERE_INDEXED)!=0 );\n      if( (ws & WHERE_IDX_ONLY)==0 ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);\n      }\n      if( (ws & WHERE_INDEXED) \n       || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx) \n      ){\n        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);\n      }\n      if( pLevel->op==OP_Return ){\n        sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);\n      }else{\n        sqlite3VdbeGoto(v, pLevel->addrFirst);\n      }\n      sqlite3VdbeJumpHere(v, addr);\n    }\n    VdbeModuleComment((v, \"End WHERE-loop%d: %s\", i,\n                     pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));\n  }\n\n  /* The \"break\" point is here, just past the end of the outer loop.\n  ** Set it.\n  */\n  sqlite3VdbeResolveLabel(v, pWInfo->iBreak);\n\n  assert( pWInfo->nLevel<=pTabList->nSrc );\n  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){\n    int k, last;\n    VdbeOp *pOp;\n    Index *pIdx = 0;\n    struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];\n    Table *pTab = pTabItem->pTab;\n    assert( pTab!=0 );\n    pLoop = pLevel->pWLoop;\n\n    /* For a co-routine, change all OP_Column references to the table of\n    ** the co-routine into OP_Copy of result contained in a register.\n    ** OP_Rowid becomes OP_Null.\n    */\n    if( pTabItem->fg.viaCoroutine ){\n      testcase( pParse->db->mallocFailed );\n      translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur,\n                            pTabItem->regResult, 0);\n      continue;\n    }\n\n    /* If this scan uses an index, make VDBE code substitutions to read data\n    ** from the index instead of from the table where possible.  In some cases\n    ** this optimization prevents the table from ever being read, which can\n    ** yield a significant performance boost.\n    ** \n    ** Calls to the code generator in between sqlite3WhereBegin and\n    ** sqlite3WhereEnd will have created code that references the table\n    ** directly.  This loop scans all that code looking for opcodes\n    ** that reference the table and converts them into opcodes that\n    ** reference the index.\n    */\n    if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){\n      pIdx = pLoop->u.btree.pIndex;\n    }else if( pLoop->wsFlags & WHERE_MULTI_OR ){\n      pIdx = pLevel->u.pCovidx;\n    }\n    if( pIdx\n     && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))\n     && !db->mallocFailed\n    ){\n      last = sqlite3VdbeCurrentAddr(v);\n      k = pLevel->addrBody;\n      pOp = sqlite3VdbeGetOp(v, k);\n      for(; k<last; k++, pOp++){\n        if( pOp->p1!=pLevel->iTabCur ) continue;\n        if( pOp->opcode==OP_Column ){\n          int x = pOp->p2;\n          assert( pIdx->pTable==pTab );\n          if( !HasRowid(pTab) ){\n            Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n            x = pPk->aiColumn[x];\n            assert( x>=0 );\n          }\n          x = sqlite3ColumnOfIndex(pIdx, x);\n          if( x>=0 ){\n            pOp->p2 = x;\n            pOp->p1 = pLevel->iIdxCur;\n          }\n          assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 \n              || pWInfo->eOnePass );\n        }else if( pOp->opcode==OP_Rowid ){\n          pOp->p1 = pLevel->iIdxCur;\n          pOp->opcode = OP_IdxRowid;\n        }else if( pOp->opcode==OP_IfNullRow ){\n          pOp->p1 = pLevel->iIdxCur;\n        }\n      }\n    }\n  }\n\n  /* Final cleanup\n  */\n  pParse->nQueryLoop = pWInfo->savedNQueryLoop;\n  whereInfoFree(db, pWInfo);\n  return;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/whereInt.h",
    "content": "/*\n** 2013-11-12\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains structure and macro definitions for the query\n** planner logic in \"where.c\".  These definitions are broken out into\n** a separate source file for easier editing.\n*/\n\n/*\n** Trace output macros\n*/\n#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)\n/***/ int sqlite3WhereTrace;\n#endif\n#if defined(SQLITE_DEBUG) \\\n    && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE))\n# define WHERETRACE(K,X)  if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X\n# define WHERETRACE_ENABLED 1\n#else\n# define WHERETRACE(K,X)\n#endif\n\n/* Forward references\n*/\ntypedef struct WhereClause WhereClause;\ntypedef struct WhereMaskSet WhereMaskSet;\ntypedef struct WhereOrInfo WhereOrInfo;\ntypedef struct WhereAndInfo WhereAndInfo;\ntypedef struct WhereLevel WhereLevel;\ntypedef struct WhereLoop WhereLoop;\ntypedef struct WherePath WherePath;\ntypedef struct WhereTerm WhereTerm;\ntypedef struct WhereLoopBuilder WhereLoopBuilder;\ntypedef struct WhereScan WhereScan;\ntypedef struct WhereOrCost WhereOrCost;\ntypedef struct WhereOrSet WhereOrSet;\n\n/*\n** This object contains information needed to implement a single nested\n** loop in WHERE clause.\n**\n** Contrast this object with WhereLoop.  This object describes the\n** implementation of the loop.  WhereLoop describes the algorithm.\n** This object contains a pointer to the WhereLoop algorithm as one of\n** its elements.\n**\n** The WhereInfo object contains a single instance of this object for\n** each term in the FROM clause (which is to say, for each of the\n** nested loops as implemented).  The order of WhereLevel objects determines\n** the loop nested order, with WhereInfo.a[0] being the outer loop and\n** WhereInfo.a[WhereInfo.nLevel-1] being the inner loop.\n*/\nstruct WhereLevel {\n  int iLeftJoin;        /* Memory cell used to implement LEFT OUTER JOIN */\n  int iTabCur;          /* The VDBE cursor used to access the table */\n  int iIdxCur;          /* The VDBE cursor used to access pIdx */\n  int addrBrk;          /* Jump here to break out of the loop */\n  int addrNxt;          /* Jump here to start the next IN combination */\n  int addrSkip;         /* Jump here for next iteration of skip-scan */\n  int addrCont;         /* Jump here to continue with the next loop cycle */\n  int addrFirst;        /* First instruction of interior of the loop */\n  int addrBody;         /* Beginning of the body of this loop */\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n  u32 iLikeRepCntr;     /* LIKE range processing counter register (times 2) */\n  int addrLikeRep;      /* LIKE range processing address */\n#endif\n  u8 iFrom;             /* Which entry in the FROM clause */\n  u8 op, p3, p5;        /* Opcode, P3 & P5 of the opcode that ends the loop */\n  int p1, p2;           /* Operands of the opcode used to ends the loop */\n  union {               /* Information that depends on pWLoop->wsFlags */\n    struct {\n      int nIn;              /* Number of entries in aInLoop[] */\n      struct InLoop {\n        int iCur;              /* The VDBE cursor used by this IN operator */\n        int addrInTop;         /* Top of the IN loop */\n        u8 eEndLoopOp;         /* IN Loop terminator. OP_Next or OP_Prev */\n      } *aInLoop;           /* Information about each nested IN operator */\n    } in;                 /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */\n    Index *pCovidx;       /* Possible covering index for WHERE_MULTI_OR */\n  } u;\n  struct WhereLoop *pWLoop;  /* The selected WhereLoop object */\n  Bitmask notReady;          /* FROM entries not usable at this level */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  int addrVisit;        /* Address at which row is visited */\n#endif\n};\n\n/*\n** Each instance of this object represents an algorithm for evaluating one\n** term of a join.  Every term of the FROM clause will have at least\n** one corresponding WhereLoop object (unless INDEXED BY constraints\n** prevent a query solution - which is an error) and many terms of the\n** FROM clause will have multiple WhereLoop objects, each describing a\n** potential way of implementing that FROM-clause term, together with\n** dependencies and cost estimates for using the chosen algorithm.\n**\n** Query planning consists of building up a collection of these WhereLoop\n** objects, then computing a particular sequence of WhereLoop objects, with\n** one WhereLoop object per FROM clause term, that satisfy all dependencies\n** and that minimize the overall cost.\n*/\nstruct WhereLoop {\n  Bitmask prereq;       /* Bitmask of other loops that must run first */\n  Bitmask maskSelf;     /* Bitmask identifying table iTab */\n#ifdef SQLITE_DEBUG\n  char cId;             /* Symbolic ID of this loop for debugging use */\n#endif\n  u8 iTab;              /* Position in FROM clause of table for this loop */\n  u8 iSortIdx;          /* Sorting index number.  0==None */\n  LogEst rSetup;        /* One-time setup cost (ex: create transient index) */\n  LogEst rRun;          /* Cost of running each loop */\n  LogEst nOut;          /* Estimated number of output rows */\n  union {\n    struct {               /* Information for internal btree tables */\n      u16 nEq;               /* Number of equality constraints */\n      u16 nBtm;              /* Size of BTM vector */\n      u16 nTop;              /* Size of TOP vector */\n      u16 nIdxCol;           /* Index column used for ORDER BY */\n      Index *pIndex;         /* Index used, or NULL */\n    } btree;\n    struct {               /* Information for virtual tables */\n      int idxNum;            /* Index number */\n      u8 needFree;           /* True if sqlite3_free(idxStr) is needed */\n      i8 isOrdered;          /* True if satisfies ORDER BY */\n      u16 omitMask;          /* Terms that may be omitted */\n      char *idxStr;          /* Index identifier string */\n    } vtab;\n  } u;\n  u32 wsFlags;          /* WHERE_* flags describing the plan */\n  u16 nLTerm;           /* Number of entries in aLTerm[] */\n  u16 nSkip;            /* Number of NULL aLTerm[] entries */\n  /**** whereLoopXfer() copies fields above ***********************/\n# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)\n  u16 nLSlot;           /* Number of slots allocated for aLTerm[] */\n  WhereTerm **aLTerm;   /* WhereTerms used */\n  WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */\n  WhereTerm *aLTermSpace[3];  /* Initial aLTerm[] space */\n};\n\n/* This object holds the prerequisites and the cost of running a\n** subquery on one operand of an OR operator in the WHERE clause.\n** See WhereOrSet for additional information \n*/\nstruct WhereOrCost {\n  Bitmask prereq;     /* Prerequisites */\n  LogEst rRun;        /* Cost of running this subquery */\n  LogEst nOut;        /* Number of outputs for this subquery */\n};\n\n/* The WhereOrSet object holds a set of possible WhereOrCosts that\n** correspond to the subquery(s) of OR-clause processing.  Only the\n** best N_OR_COST elements are retained.\n*/\n#define N_OR_COST 3\nstruct WhereOrSet {\n  u16 n;                      /* Number of valid a[] entries */\n  WhereOrCost a[N_OR_COST];   /* Set of best costs */\n};\n\n/*\n** Each instance of this object holds a sequence of WhereLoop objects\n** that implement some or all of a query plan.\n**\n** Think of each WhereLoop object as a node in a graph with arcs\n** showing dependencies and costs for travelling between nodes.  (That is\n** not a completely accurate description because WhereLoop costs are a\n** vector, not a scalar, and because dependencies are many-to-one, not\n** one-to-one as are graph nodes.  But it is a useful visualization aid.)\n** Then a WherePath object is a path through the graph that visits some\n** or all of the WhereLoop objects once.\n**\n** The \"solver\" works by creating the N best WherePath objects of length\n** 1.  Then using those as a basis to compute the N best WherePath objects\n** of length 2.  And so forth until the length of WherePaths equals the\n** number of nodes in the FROM clause.  The best (lowest cost) WherePath\n** at the end is the chosen query plan.\n*/\nstruct WherePath {\n  Bitmask maskLoop;     /* Bitmask of all WhereLoop objects in this path */\n  Bitmask revLoop;      /* aLoop[]s that should be reversed for ORDER BY */\n  LogEst nRow;          /* Estimated number of rows generated by this path */\n  LogEst rCost;         /* Total cost of this path */\n  LogEst rUnsorted;     /* Total cost of this path ignoring sorting costs */\n  i8 isOrdered;         /* No. of ORDER BY terms satisfied. -1 for unknown */\n  WhereLoop **aLoop;    /* Array of WhereLoop objects implementing this path */\n};\n\n/*\n** The query generator uses an array of instances of this structure to\n** help it analyze the subexpressions of the WHERE clause.  Each WHERE\n** clause subexpression is separated from the others by AND operators,\n** usually, or sometimes subexpressions separated by OR.\n**\n** All WhereTerms are collected into a single WhereClause structure.  \n** The following identity holds:\n**\n**        WhereTerm.pWC->a[WhereTerm.idx] == WhereTerm\n**\n** When a term is of the form:\n**\n**              X <op> <expr>\n**\n** where X is a column name and <op> is one of certain operators,\n** then WhereTerm.leftCursor and WhereTerm.u.leftColumn record the\n** cursor number and column number for X.  WhereTerm.eOperator records\n** the <op> using a bitmask encoding defined by WO_xxx below.  The\n** use of a bitmask encoding for the operator allows us to search\n** quickly for terms that match any of several different operators.\n**\n** A WhereTerm might also be two or more subterms connected by OR:\n**\n**         (t1.X <op> <expr>) OR (t1.Y <op> <expr>) OR ....\n**\n** In this second case, wtFlag has the TERM_ORINFO bit set and eOperator==WO_OR\n** and the WhereTerm.u.pOrInfo field points to auxiliary information that\n** is collected about the OR clause.\n**\n** If a term in the WHERE clause does not match either of the two previous\n** categories, then eOperator==0.  The WhereTerm.pExpr field is still set\n** to the original subexpression content and wtFlags is set up appropriately\n** but no other fields in the WhereTerm object are meaningful.\n**\n** When eOperator!=0, prereqRight and prereqAll record sets of cursor numbers,\n** but they do so indirectly.  A single WhereMaskSet structure translates\n** cursor number into bits and the translated bit is stored in the prereq\n** fields.  The translation is used in order to maximize the number of\n** bits that will fit in a Bitmask.  The VDBE cursor numbers might be\n** spread out over the non-negative integers.  For example, the cursor\n** numbers might be 3, 8, 9, 10, 20, 23, 41, and 45.  The WhereMaskSet\n** translates these sparse cursor numbers into consecutive integers\n** beginning with 0 in order to make the best possible use of the available\n** bits in the Bitmask.  So, in the example above, the cursor numbers\n** would be mapped into integers 0 through 7.\n**\n** The number of terms in a join is limited by the number of bits\n** in prereqRight and prereqAll.  The default is 64 bits, hence SQLite\n** is only able to process joins with 64 or fewer tables.\n*/\nstruct WhereTerm {\n  Expr *pExpr;            /* Pointer to the subexpression that is this term */\n  WhereClause *pWC;       /* The clause this term is part of */\n  LogEst truthProb;       /* Probability of truth for this expression */\n  u16 wtFlags;            /* TERM_xxx bit flags.  See below */\n  u16 eOperator;          /* A WO_xx value describing <op> */\n  u8 nChild;              /* Number of children that must disable us */\n  u8 eMatchOp;            /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */\n  int iParent;            /* Disable pWC->a[iParent] when this term disabled */\n  int leftCursor;         /* Cursor number of X in \"X <op> <expr>\" */\n  int iField;             /* Field in (?,?,?) IN (SELECT...) vector */\n  union {\n    int leftColumn;         /* Column number of X in \"X <op> <expr>\" */\n    WhereOrInfo *pOrInfo;   /* Extra information if (eOperator & WO_OR)!=0 */\n    WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */\n  } u;\n  Bitmask prereqRight;    /* Bitmask of tables used by pExpr->pRight */\n  Bitmask prereqAll;      /* Bitmask of tables referenced by pExpr */\n};\n\n/*\n** Allowed values of WhereTerm.wtFlags\n*/\n#define TERM_DYNAMIC    0x01   /* Need to call sqlite3ExprDelete(db, pExpr) */\n#define TERM_VIRTUAL    0x02   /* Added by the optimizer.  Do not code */\n#define TERM_CODED      0x04   /* This term is already coded */\n#define TERM_COPIED     0x08   /* Has a child */\n#define TERM_ORINFO     0x10   /* Need to free the WhereTerm.u.pOrInfo object */\n#define TERM_ANDINFO    0x20   /* Need to free the WhereTerm.u.pAndInfo obj */\n#define TERM_OR_OK      0x40   /* Used during OR-clause processing */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n#  define TERM_VNULL    0x80   /* Manufactured x>NULL or x<=NULL term */\n#else\n#  define TERM_VNULL    0x00   /* Disabled if not using stat3 */\n#endif\n#define TERM_LIKEOPT    0x100  /* Virtual terms from the LIKE optimization */\n#define TERM_LIKECOND   0x200  /* Conditionally this LIKE operator term */\n#define TERM_LIKE       0x400  /* The original LIKE operator */\n#define TERM_IS         0x800  /* Term.pExpr is an IS operator */\n#define TERM_VARSELECT  0x1000 /* Term.pExpr contains a correlated sub-query */\n\n/*\n** An instance of the WhereScan object is used as an iterator for locating\n** terms in the WHERE clause that are useful to the query planner.\n*/\nstruct WhereScan {\n  WhereClause *pOrigWC;      /* Original, innermost WhereClause */\n  WhereClause *pWC;          /* WhereClause currently being scanned */\n  const char *zCollName;     /* Required collating sequence, if not NULL */\n  Expr *pIdxExpr;            /* Search for this index expression */\n  char idxaff;               /* Must match this affinity, if zCollName!=NULL */\n  unsigned char nEquiv;      /* Number of entries in aEquiv[] */\n  unsigned char iEquiv;      /* Next unused slot in aEquiv[] */\n  u32 opMask;                /* Acceptable operators */\n  int k;                     /* Resume scanning at this->pWC->a[this->k] */\n  int aiCur[11];             /* Cursors in the equivalence class */\n  i16 aiColumn[11];          /* Corresponding column number in the eq-class */\n};\n\n/*\n** An instance of the following structure holds all information about a\n** WHERE clause.  Mostly this is a container for one or more WhereTerms.\n**\n** Explanation of pOuter:  For a WHERE clause of the form\n**\n**           a AND ((b AND c) OR (d AND e)) AND f\n**\n** There are separate WhereClause objects for the whole clause and for\n** the subclauses \"(b AND c)\" and \"(d AND e)\".  The pOuter field of the\n** subclauses points to the WhereClause object for the whole clause.\n*/\nstruct WhereClause {\n  WhereInfo *pWInfo;       /* WHERE clause processing context */\n  WhereClause *pOuter;     /* Outer conjunction */\n  u8 op;                   /* Split operator.  TK_AND or TK_OR */\n  int nTerm;               /* Number of terms */\n  int nSlot;               /* Number of entries in a[] */\n  WhereTerm *a;            /* Each a[] describes a term of the WHERE cluase */\n#if defined(SQLITE_SMALL_STACK)\n  WhereTerm aStatic[1];    /* Initial static space for a[] */\n#else\n  WhereTerm aStatic[8];    /* Initial static space for a[] */\n#endif\n};\n\n/*\n** A WhereTerm with eOperator==WO_OR has its u.pOrInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereOrInfo {\n  WhereClause wc;          /* Decomposition into subterms */\n  Bitmask indexable;       /* Bitmask of all indexable tables in the clause */\n};\n\n/*\n** A WhereTerm with eOperator==WO_AND has its u.pAndInfo pointer set to\n** a dynamically allocated instance of the following structure.\n*/\nstruct WhereAndInfo {\n  WhereClause wc;          /* The subexpression broken out */\n};\n\n/*\n** An instance of the following structure keeps track of a mapping\n** between VDBE cursor numbers and bits of the bitmasks in WhereTerm.\n**\n** The VDBE cursor numbers are small integers contained in \n** SrcList_item.iCursor and Expr.iTable fields.  For any given WHERE \n** clause, the cursor numbers might not begin with 0 and they might\n** contain gaps in the numbering sequence.  But we want to make maximum\n** use of the bits in our bitmasks.  This structure provides a mapping\n** from the sparse cursor numbers into consecutive integers beginning\n** with 0.\n**\n** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask\n** corresponds VDBE cursor number B.  The A-th bit of a bitmask is 1<<A.\n**\n** For example, if the WHERE clause expression used these VDBE\n** cursors:  4, 5, 8, 29, 57, 73.  Then the  WhereMaskSet structure\n** would map those cursor numbers into bits 0 through 5.\n**\n** Note that the mapping is not necessarily ordered.  In the example\n** above, the mapping might go like this:  4->3, 5->1, 8->2, 29->0,\n** 57->5, 73->4.  Or one of 719 other combinations might be used. It\n** does not really matter.  What is important is that sparse cursor\n** numbers all get mapped into bit numbers that begin with 0 and contain\n** no gaps.\n*/\nstruct WhereMaskSet {\n  int bVarSelect;               /* Used by sqlite3WhereExprUsage() */\n  int n;                        /* Number of assigned cursor values */\n  int ix[BMS];                  /* Cursor assigned to each bit */\n};\n\n/*\n** Initialize a WhereMaskSet object\n*/\n#define initMaskSet(P)  (P)->n=0\n\n/*\n** This object is a convenience wrapper holding all information needed\n** to construct WhereLoop objects for a particular query.\n*/\nstruct WhereLoopBuilder {\n  WhereInfo *pWInfo;        /* Information about this WHERE */\n  WhereClause *pWC;         /* WHERE clause terms */\n  ExprList *pOrderBy;       /* ORDER BY clause */\n  WhereLoop *pNew;          /* Template WhereLoop */\n  WhereOrSet *pOrSet;       /* Record best loops here, if not NULL */\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  UnpackedRecord *pRec;     /* Probe for stat4 (if required) */\n  int nRecValid;            /* Number of valid fields currently in pRec */\n#endif\n  unsigned int bldFlags;    /* SQLITE_BLDF_* flags */\n};\n\n/* Allowed values for WhereLoopBuider.bldFlags */\n#define SQLITE_BLDF_INDEXED  0x0001   /* An index is used */\n#define SQLITE_BLDF_UNIQUE   0x0002   /* All keys of a UNIQUE index used */\n\n/*\n** The WHERE clause processing routine has two halves.  The\n** first part does the start of the WHERE loop and the second\n** half does the tail of the WHERE loop.  An instance of\n** this structure is returned by the first half and passed\n** into the second half to give some continuity.\n**\n** An instance of this object holds the complete state of the query\n** planner.\n*/\nstruct WhereInfo {\n  Parse *pParse;            /* Parsing and code generating context */\n  SrcList *pTabList;        /* List of tables in the join */\n  ExprList *pOrderBy;       /* The ORDER BY clause or NULL */\n  ExprList *pResultSet;     /* Result set of the query */\n  Expr *pWhere;             /* The complete WHERE clause */\n  LogEst iLimit;            /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */\n  int aiCurOnePass[2];      /* OP_OpenWrite cursors for the ONEPASS opt */\n  int iContinue;            /* Jump here to continue with next record */\n  int iBreak;               /* Jump here to break out of the loop */\n  int savedNQueryLoop;      /* pParse->nQueryLoop outside the WHERE loop */\n  u16 wctrlFlags;           /* Flags originally passed to sqlite3WhereBegin() */\n  u8 nLevel;                /* Number of nested loop */\n  i8 nOBSat;                /* Number of ORDER BY terms satisfied by indices */\n  u8 sorted;                /* True if really sorted (not just grouped) */\n  u8 eOnePass;              /* ONEPASS_OFF, or _SINGLE, or _MULTI */\n  u8 untestedTerms;         /* Not all WHERE terms resolved by outer loop */\n  u8 eDistinct;             /* One of the WHERE_DISTINCT_* values */\n  u8 bOrderedInnerLoop;     /* True if only the inner-most loop is ordered */\n  int iTop;                 /* The very beginning of the WHERE loop */\n  WhereLoop *pLoops;        /* List of all WhereLoop objects */\n  Bitmask revMask;          /* Mask of ORDER BY terms that need reversing */\n  LogEst nRowOut;           /* Estimated number of output rows */\n  WhereClause sWC;          /* Decomposition of the WHERE clause */\n  WhereMaskSet sMaskSet;    /* Map cursor numbers to bitmasks */\n  WhereLevel a[1];          /* Information about each nest loop in WHERE */\n};\n\n/*\n** Private interfaces - callable only by other where.c routines.\n**\n** where.c:\n*/\nBitmask sqlite3WhereGetMask(WhereMaskSet*,int);\n#ifdef WHERETRACE_ENABLED\nvoid sqlite3WhereClausePrint(WhereClause *pWC);\n#endif\nWhereTerm *sqlite3WhereFindTerm(\n  WhereClause *pWC,     /* The WHERE clause to be searched */\n  int iCur,             /* Cursor number of LHS */\n  int iColumn,          /* Column number of LHS */\n  Bitmask notReady,     /* RHS must not overlap with this mask */\n  u32 op,               /* Mask of WO_xx values describing operator */\n  Index *pIdx           /* Must be compatible with this index, if not NULL */\n);\n\n/* wherecode.c: */\n#ifndef SQLITE_OMIT_EXPLAIN\nint sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  int iLevel,                     /* Value for \"level\" column of output */\n  int iFrom,                      /* Value for \"from\" column of output */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n);\n#else\n# define sqlite3WhereExplainOneScan(u,v,w,x,y,z) 0\n#endif /* SQLITE_OMIT_EXPLAIN */\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\nvoid sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n);\n#else\n# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)\n#endif\nBitmask sqlite3WhereCodeOneLoopStart(\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  Bitmask notReady     /* Which tables are currently available */\n);\n\n/* whereexpr.c: */\nvoid sqlite3WhereClauseInit(WhereClause*,WhereInfo*);\nvoid sqlite3WhereClauseClear(WhereClause*);\nvoid sqlite3WhereSplit(WhereClause*,Expr*,u8);\nBitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);\nBitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);\nvoid sqlite3WhereExprAnalyze(SrcList*, WhereClause*);\nvoid sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*);\n\n\n\n\n\n/*\n** Bitmasks for the operators on WhereTerm objects.  These are all\n** operators that are of interest to the query planner.  An\n** OR-ed combination of these values can be used when searching for\n** particular WhereTerms within a WhereClause.\n**\n** Value constraints:\n**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ\n**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT\n**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE\n**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT\n**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE\n*/\n#define WO_IN     0x0001\n#define WO_EQ     0x0002\n#define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))\n#define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))\n#define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))\n#define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))\n#define WO_AUX    0x0040       /* Op useful to virtual tables only */\n#define WO_IS     0x0080\n#define WO_ISNULL 0x0100\n#define WO_OR     0x0200       /* Two or more OR-connected terms */\n#define WO_AND    0x0400       /* Two or more AND-connected terms */\n#define WO_EQUIV  0x0800       /* Of the form A==B, both columns */\n#define WO_NOOP   0x1000       /* This term does not restrict search space */\n\n#define WO_ALL    0x1fff       /* Mask of all possible WO_* values */\n#define WO_SINGLE 0x01ff       /* Mask of all non-compound WO_* values */\n\n/*\n** These are definitions of bits in the WhereLoop.wsFlags field.\n** The particular combination of bits in each WhereLoop help to\n** determine the algorithm that WhereLoop represents.\n*/\n#define WHERE_COLUMN_EQ    0x00000001  /* x=EXPR */\n#define WHERE_COLUMN_RANGE 0x00000002  /* x<EXPR and/or x>EXPR */\n#define WHERE_COLUMN_IN    0x00000004  /* x IN (...) */\n#define WHERE_COLUMN_NULL  0x00000008  /* x IS NULL */\n#define WHERE_CONSTRAINT   0x0000000f  /* Any of the WHERE_COLUMN_xxx values */\n#define WHERE_TOP_LIMIT    0x00000010  /* x<EXPR or x<=EXPR constraint */\n#define WHERE_BTM_LIMIT    0x00000020  /* x>EXPR or x>=EXPR constraint */\n#define WHERE_BOTH_LIMIT   0x00000030  /* Both x>EXPR and x<EXPR */\n#define WHERE_IDX_ONLY     0x00000040  /* Use index only - omit table */\n#define WHERE_IPK          0x00000100  /* x is the INTEGER PRIMARY KEY */\n#define WHERE_INDEXED      0x00000200  /* WhereLoop.u.btree.pIndex is valid */\n#define WHERE_VIRTUALTABLE 0x00000400  /* WhereLoop.u.vtab is valid */\n#define WHERE_IN_ABLE      0x00000800  /* Able to support an IN operator */\n#define WHERE_ONEROW       0x00001000  /* Selects no more than one row */\n#define WHERE_MULTI_OR     0x00002000  /* OR using multiple indices */\n#define WHERE_AUTO_INDEX   0x00004000  /* Uses an ephemeral index */\n#define WHERE_SKIPSCAN     0x00008000  /* Uses the skip-scan algorithm */\n#define WHERE_UNQ_WANTED   0x00010000  /* WHERE_ONEROW would have been helpful*/\n#define WHERE_PARTIALIDX   0x00020000  /* The automatic index is partial */\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/wherecode.c",
    "content": "/*\n** 2015-06-06\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was split off from where.c on 2015-06-06 in order to reduce the\n** size of where.c and make it easier to edit.  This file contains the routines\n** that actually generate the bulk of the WHERE loop code.  The original where.c\n** file retains the code that does query planning and analysis.\n*/\n#include \"sqliteInt.h\"\n#include \"whereInt.h\"\n\n#ifndef SQLITE_OMIT_EXPLAIN\n\n/*\n** Return the name of the i-th column of the pIdx index.\n*/\nstatic const char *explainIndexColumnName(Index *pIdx, int i){\n  i = pIdx->aiColumn[i];\n  if( i==XN_EXPR ) return \"<expr>\";\n  if( i==XN_ROWID ) return \"rowid\";\n  return pIdx->pTable->aCol[i].zName;\n}\n\n/*\n** This routine is a helper for explainIndexRange() below\n**\n** pStr holds the text of an expression that we are building up one term\n** at a time.  This routine adds a new term to the end of the expression.\n** Terms are separated by AND so add the \"AND\" text for second and subsequent\n** terms only.\n*/\nstatic void explainAppendTerm(\n  StrAccum *pStr,             /* The text expression being built */\n  Index *pIdx,                /* Index to read column names from */\n  int nTerm,                  /* Number of terms */\n  int iTerm,                  /* Zero-based index of first term. */\n  int bAnd,                   /* Non-zero to append \" AND \" */\n  const char *zOp             /* Name of the operator */\n){\n  int i;\n\n  assert( nTerm>=1 );\n  if( bAnd ) sqlite3StrAccumAppend(pStr, \" AND \", 5);\n\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3StrAccumAppend(pStr, \",\", 1);\n    sqlite3StrAccumAppendAll(pStr, explainIndexColumnName(pIdx, iTerm+i));\n  }\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \")\", 1);\n\n  sqlite3StrAccumAppend(pStr, zOp, 1);\n\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \"(\", 1);\n  for(i=0; i<nTerm; i++){\n    if( i ) sqlite3StrAccumAppend(pStr, \",\", 1);\n    sqlite3StrAccumAppend(pStr, \"?\", 1);\n  }\n  if( nTerm>1 ) sqlite3StrAccumAppend(pStr, \")\", 1);\n}\n\n/*\n** Argument pLevel describes a strategy for scanning table pTab. This \n** function appends text to pStr that describes the subset of table\n** rows scanned by the strategy in the form of an SQL expression.\n**\n** For example, if the query:\n**\n**   SELECT * FROM t1 WHERE a=1 AND b>2;\n**\n** is run and there is an index on (a, b), then this function returns a\n** string similar to:\n**\n**   \"a=? AND b>?\"\n*/\nstatic void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){\n  Index *pIndex = pLoop->u.btree.pIndex;\n  u16 nEq = pLoop->u.btree.nEq;\n  u16 nSkip = pLoop->nSkip;\n  int i, j;\n\n  if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return;\n  sqlite3StrAccumAppend(pStr, \" (\", 2);\n  for(i=0; i<nEq; i++){\n    const char *z = explainIndexColumnName(pIndex, i);\n    if( i ) sqlite3StrAccumAppend(pStr, \" AND \", 5);\n    sqlite3XPrintf(pStr, i>=nSkip ? \"%s=?\" : \"ANY(%s)\", z);\n  }\n\n  j = i;\n  if( pLoop->wsFlags&WHERE_BTM_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nBtm, j, i, \">\");\n    i = 1;\n  }\n  if( pLoop->wsFlags&WHERE_TOP_LIMIT ){\n    explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, \"<\");\n  }\n  sqlite3StrAccumAppend(pStr, \")\", 1);\n}\n\n/*\n** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN\n** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was\n** defined at compile-time. If it is not a no-op, a single OP_Explain opcode \n** is added to the output to describe the table scan strategy in pLevel.\n**\n** If an OP_Explain opcode is added to the VM, its address is returned.\n** Otherwise, if no OP_Explain is coded, zero is returned.\n*/\nint sqlite3WhereExplainOneScan(\n  Parse *pParse,                  /* Parse context */\n  SrcList *pTabList,              /* Table list this loop refers to */\n  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */\n  int iLevel,                     /* Value for \"level\" column of output */\n  int iFrom,                      /* Value for \"from\" column of output */\n  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */\n){\n  int ret = 0;\n#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)\n  if( pParse->explain==2 )\n#endif\n  {\n    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];\n    Vdbe *v = pParse->pVdbe;      /* VM being constructed */\n    sqlite3 *db = pParse->db;     /* Database handle */\n    int iId = pParse->iSelectId;  /* Select id (left-most output column) */\n    int isSearch;                 /* True for a SEARCH. False for SCAN. */\n    WhereLoop *pLoop;             /* The controlling WhereLoop object */\n    u32 flags;                    /* Flags that describe this loop */\n    char *zMsg;                   /* Text to add to EQP output */\n    StrAccum str;                 /* EQP output string */\n    char zBuf[100];               /* Initial space for EQP output string */\n\n    pLoop = pLevel->pWLoop;\n    flags = pLoop->wsFlags;\n    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;\n\n    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0\n            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))\n            || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));\n\n    sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);\n    sqlite3StrAccumAppendAll(&str, isSearch ? \"SEARCH\" : \"SCAN\");\n    if( pItem->pSelect ){\n      sqlite3XPrintf(&str, \" SUBQUERY %d\", pItem->iSelectId);\n    }else{\n      sqlite3XPrintf(&str, \" TABLE %s\", pItem->zName);\n    }\n\n    if( pItem->zAlias ){\n      sqlite3XPrintf(&str, \" AS %s\", pItem->zAlias);\n    }\n    if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){\n      const char *zFmt = 0;\n      Index *pIdx;\n\n      assert( pLoop->u.btree.pIndex!=0 );\n      pIdx = pLoop->u.btree.pIndex;\n      assert( !(flags&WHERE_AUTO_INDEX) || (flags&WHERE_IDX_ONLY) );\n      if( !HasRowid(pItem->pTab) && IsPrimaryKeyIndex(pIdx) ){\n        if( isSearch ){\n          zFmt = \"PRIMARY KEY\";\n        }\n      }else if( flags & WHERE_PARTIALIDX ){\n        zFmt = \"AUTOMATIC PARTIAL COVERING INDEX\";\n      }else if( flags & WHERE_AUTO_INDEX ){\n        zFmt = \"AUTOMATIC COVERING INDEX\";\n      }else if( flags & WHERE_IDX_ONLY ){\n        zFmt = \"COVERING INDEX %s\";\n      }else{\n        zFmt = \"INDEX %s\";\n      }\n      if( zFmt ){\n        sqlite3StrAccumAppend(&str, \" USING \", 7);\n        sqlite3XPrintf(&str, zFmt, pIdx->zName);\n        explainIndexRange(&str, pLoop);\n      }\n    }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){\n      const char *zRangeOp;\n      if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){\n        zRangeOp = \"=\";\n      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){\n        zRangeOp = \">? AND rowid<\";\n      }else if( flags&WHERE_BTM_LIMIT ){\n        zRangeOp = \">\";\n      }else{\n        assert( flags&WHERE_TOP_LIMIT);\n        zRangeOp = \"<\";\n      }\n      sqlite3XPrintf(&str, \" USING INTEGER PRIMARY KEY (rowid%s?)\",zRangeOp);\n    }\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){\n      sqlite3XPrintf(&str, \" VIRTUAL TABLE INDEX %d:%s\",\n                  pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);\n    }\n#endif\n#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS\n    if( pLoop->nOut>=10 ){\n      sqlite3XPrintf(&str, \" (~%llu rows)\", sqlite3LogEstToInt(pLoop->nOut));\n    }else{\n      sqlite3StrAccumAppend(&str, \" (~1 row)\", 9);\n    }\n#endif\n    zMsg = sqlite3StrAccumFinish(&str);\n    ret = sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,P4_DYNAMIC);\n  }\n  return ret;\n}\n#endif /* SQLITE_OMIT_EXPLAIN */\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n/*\n** Configure the VM passed as the first argument with an\n** sqlite3_stmt_scanstatus() entry corresponding to the scan used to \n** implement level pLvl. Argument pSrclist is a pointer to the FROM \n** clause that the scan reads data from.\n**\n** If argument addrExplain is not 0, it must be the address of an \n** OP_Explain instruction that describes the same loop.\n*/\nvoid sqlite3WhereAddScanStatus(\n  Vdbe *v,                        /* Vdbe to add scanstatus entry to */\n  SrcList *pSrclist,              /* FROM clause pLvl reads data from */\n  WhereLevel *pLvl,               /* Level to add scanstatus() entry for */\n  int addrExplain                 /* Address of OP_Explain (or 0) */\n){\n  const char *zObj = 0;\n  WhereLoop *pLoop = pLvl->pWLoop;\n  if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0  &&  pLoop->u.btree.pIndex!=0 ){\n    zObj = pLoop->u.btree.pIndex->zName;\n  }else{\n    zObj = pSrclist->a[pLvl->iFrom].zName;\n  }\n  sqlite3VdbeScanStatus(\n      v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj\n  );\n}\n#endif\n\n\n/*\n** Disable a term in the WHERE clause.  Except, do not disable the term\n** if it controls a LEFT OUTER JOIN and it did not originate in the ON\n** or USING clause of that join.\n**\n** Consider the term t2.z='ok' in the following queries:\n**\n**   (1)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'\n**   (2)  SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'\n**   (3)  SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'\n**\n** The t2.z='ok' is disabled in the in (2) because it originates\n** in the ON clause.  The term is disabled in (3) because it is not part\n** of a LEFT OUTER JOIN.  In (1), the term is not disabled.\n**\n** Disabling a term causes that term to not be tested in the inner loop\n** of the join.  Disabling is an optimization.  When terms are satisfied\n** by indices, we disable them to prevent redundant tests in the inner\n** loop.  We would get the correct results if nothing were ever disabled,\n** but joins might run a little slower.  The trick is to disable as much\n** as we can without disabling too much.  If we disabled in (1), we'd get\n** the wrong answer.  See ticket #813.\n**\n** If all the children of a term are disabled, then that term is also\n** automatically disabled.  In this way, terms get disabled if derived\n** virtual terms are tested first.  For example:\n**\n**      x GLOB 'abc*' AND x>='abc' AND x<'acd'\n**      \\___________/     \\______/     \\_____/\n**         parent          child1       child2\n**\n** Only the parent term was in the original WHERE clause.  The child1\n** and child2 terms were added by the LIKE optimization.  If both of\n** the virtual child terms are valid, then testing of the parent can be \n** skipped.\n**\n** Usually the parent term is marked as TERM_CODED.  But if the parent\n** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.\n** The TERM_LIKECOND marking indicates that the term should be coded inside\n** a conditional such that is only evaluated on the second pass of a\n** LIKE-optimization loop, when scanning BLOBs instead of strings.\n*/\nstatic void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){\n  int nLoop = 0;\n  while( ALWAYS(pTerm!=0)\n      && (pTerm->wtFlags & TERM_CODED)==0\n      && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))\n      && (pLevel->notReady & pTerm->prereqAll)==0\n  ){\n    if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){\n      pTerm->wtFlags |= TERM_LIKECOND;\n    }else{\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    if( pTerm->iParent<0 ) break;\n    pTerm = &pTerm->pWC->a[pTerm->iParent];\n    pTerm->nChild--;\n    if( pTerm->nChild!=0 ) break;\n    nLoop++;\n  }\n}\n\n/*\n** Code an OP_Affinity opcode to apply the column affinity string zAff\n** to the n registers starting at base. \n**\n** As an optimization, SQLITE_AFF_BLOB entries (which are no-ops) at the\n** beginning and end of zAff are ignored.  If all entries in zAff are\n** SQLITE_AFF_BLOB, then no code gets generated.\n**\n** This routine makes its own copy of zAff so that the caller is free\n** to modify zAff after this routine returns.\n*/\nstatic void codeApplyAffinity(Parse *pParse, int base, int n, char *zAff){\n  Vdbe *v = pParse->pVdbe;\n  if( zAff==0 ){\n    assert( pParse->db->mallocFailed );\n    return;\n  }\n  assert( v!=0 );\n\n  /* Adjust base and n to skip over SQLITE_AFF_BLOB entries at the beginning\n  ** and end of the affinity string.\n  */\n  while( n>0 && zAff[0]==SQLITE_AFF_BLOB ){\n    n--;\n    base++;\n    zAff++;\n  }\n  while( n>1 && zAff[n-1]==SQLITE_AFF_BLOB ){\n    n--;\n  }\n\n  /* Code the OP_Affinity opcode if there is anything left to do. */\n  if( n>0 ){\n    sqlite3VdbeAddOp4(v, OP_Affinity, base, n, 0, zAff, n);\n    sqlite3ExprCacheAffinityChange(pParse, base, n);\n  }\n}\n\n/*\n** Expression pRight, which is the RHS of a comparison operation, is \n** either a vector of n elements or, if n==1, a scalar expression.\n** Before the comparison operation, affinity zAff is to be applied\n** to the pRight values. This function modifies characters within the\n** affinity string to SQLITE_AFF_BLOB if either:\n**\n**   * the comparison will be performed with no affinity, or\n**   * the affinity change in zAff is guaranteed not to change the value.\n*/\nstatic void updateRangeAffinityStr(\n  Expr *pRight,                   /* RHS of comparison */\n  int n,                          /* Number of vector elements in comparison */\n  char *zAff                      /* Affinity string to modify */\n){\n  int i;\n  for(i=0; i<n; i++){\n    Expr *p = sqlite3VectorFieldSubexpr(pRight, i);\n    if( sqlite3CompareAffinity(p, zAff[i])==SQLITE_AFF_BLOB\n     || sqlite3ExprNeedsNoAffinityChange(p, zAff[i])\n    ){\n      zAff[i] = SQLITE_AFF_BLOB;\n    }\n  }\n}\n\n/*\n** Generate code for a single equality term of the WHERE clause.  An equality\n** term can be either X=expr or X IN (...).   pTerm is the term to be \n** coded.\n**\n** The current value for the constraint is left in a register, the index\n** of which is returned.  An attempt is made store the result in iTarget but\n** this is only guaranteed for TK_ISNULL and TK_IN constraints.  If the\n** constraint is a TK_EQ or TK_IS, then the current value might be left in\n** some other register and it is the caller's responsibility to compensate.\n**\n** For a constraint of the form X=expr, the expression is evaluated in\n** straight-line code.  For constraints of the form X IN (...)\n** this routine sets up a loop that will iterate over all values of X.\n*/\nstatic int codeEqualityTerm(\n  Parse *pParse,      /* The parsing context */\n  WhereTerm *pTerm,   /* The term of the WHERE clause to be coded */\n  WhereLevel *pLevel, /* The level of the FROM clause we are working on */\n  int iEq,            /* Index of the equality term within this level */\n  int bRev,           /* True for reverse-order IN operations */\n  int iTarget         /* Attempt to leave results in this register */\n){\n  Expr *pX = pTerm->pExpr;\n  Vdbe *v = pParse->pVdbe;\n  int iReg;                  /* Register holding results */\n\n  assert( pLevel->pWLoop->aLTerm[iEq]==pTerm );\n  assert( iTarget>0 );\n  if( pX->op==TK_EQ || pX->op==TK_IS ){\n    iReg = sqlite3ExprCodeTarget(pParse, pX->pRight, iTarget);\n  }else if( pX->op==TK_ISNULL ){\n    iReg = iTarget;\n    sqlite3VdbeAddOp2(v, OP_Null, 0, iReg);\n#ifndef SQLITE_OMIT_SUBQUERY\n  }else{\n    int eType = IN_INDEX_NOOP;\n    int iTab;\n    struct InLoop *pIn;\n    WhereLoop *pLoop = pLevel->pWLoop;\n    int i;\n    int nEq = 0;\n    int *aiMap = 0;\n\n    if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0\n      && pLoop->u.btree.pIndex!=0\n      && pLoop->u.btree.pIndex->aSortOrder[iEq]\n    ){\n      testcase( iEq==0 );\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    assert( pX->op==TK_IN );\n    iReg = iTarget;\n\n    for(i=0; i<iEq; i++){\n      if( pLoop->aLTerm[i] && pLoop->aLTerm[i]->pExpr==pX ){\n        disableTerm(pLevel, pTerm);\n        return iTarget;\n      }\n    }\n    for(i=iEq;i<pLoop->nLTerm; i++){\n      if( ALWAYS(pLoop->aLTerm[i]) && pLoop->aLTerm[i]->pExpr==pX ) nEq++;\n    }\n\n    if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){\n      eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);\n    }else{\n      Select *pSelect = pX->x.pSelect;\n      sqlite3 *db = pParse->db;\n      u16 savedDbOptFlags = db->dbOptFlags;\n      ExprList *pOrigRhs = pSelect->pEList;\n      ExprList *pOrigLhs = pX->pLeft->x.pList;\n      ExprList *pRhs = 0;         /* New Select.pEList for RHS */\n      ExprList *pLhs = 0;         /* New pX->pLeft vector */\n\n      for(i=iEq;i<pLoop->nLTerm; i++){\n        if( pLoop->aLTerm[i]->pExpr==pX ){\n          int iField = pLoop->aLTerm[i]->iField - 1;\n          Expr *pNewRhs = sqlite3ExprDup(db, pOrigRhs->a[iField].pExpr, 0);\n          Expr *pNewLhs = sqlite3ExprDup(db, pOrigLhs->a[iField].pExpr, 0);\n\n          pRhs = sqlite3ExprListAppend(pParse, pRhs, pNewRhs);\n          pLhs = sqlite3ExprListAppend(pParse, pLhs, pNewLhs);\n        }\n      }\n      if( !db->mallocFailed ){\n        Expr *pLeft = pX->pLeft;\n\n        if( pSelect->pOrderBy ){\n          /* If the SELECT statement has an ORDER BY clause, zero the \n          ** iOrderByCol variables. These are set to non-zero when an \n          ** ORDER BY term exactly matches one of the terms of the \n          ** result-set. Since the result-set of the SELECT statement may\n          ** have been modified or reordered, these variables are no longer \n          ** set correctly.  Since setting them is just an optimization, \n          ** it's easiest just to zero them here.  */\n          ExprList *pOrderBy = pSelect->pOrderBy;\n          for(i=0; i<pOrderBy->nExpr; i++){\n            pOrderBy->a[i].u.x.iOrderByCol = 0;\n          }\n        }\n\n        /* Take care here not to generate a TK_VECTOR containing only a\n        ** single value. Since the parser never creates such a vector, some\n        ** of the subroutines do not handle this case.  */\n        if( pLhs->nExpr==1 ){\n          pX->pLeft = pLhs->a[0].pExpr;\n        }else{\n          pLeft->x.pList = pLhs;\n          aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * nEq);\n          testcase( aiMap==0 );\n        }\n        pSelect->pEList = pRhs;\n        db->dbOptFlags |= SQLITE_QueryFlattener;\n        eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);\n        db->dbOptFlags = savedDbOptFlags;\n        testcase( aiMap!=0 && aiMap[0]!=0 );\n        pSelect->pEList = pOrigRhs;\n        pLeft->x.pList = pOrigLhs;\n        pX->pLeft = pLeft;\n      }\n      sqlite3ExprListDelete(pParse->db, pLhs);\n      sqlite3ExprListDelete(pParse->db, pRhs);\n    }\n\n    if( eType==IN_INDEX_INDEX_DESC ){\n      testcase( bRev );\n      bRev = !bRev;\n    }\n    iTab = pX->iTable;\n    sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);\n    VdbeCoverageIf(v, bRev);\n    VdbeCoverageIf(v, !bRev);\n    assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );\n\n    pLoop->wsFlags |= WHERE_IN_ABLE;\n    if( pLevel->u.in.nIn==0 ){\n      pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n    }\n\n    i = pLevel->u.in.nIn;\n    pLevel->u.in.nIn += nEq;\n    pLevel->u.in.aInLoop =\n       sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,\n                              sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);\n    pIn = pLevel->u.in.aInLoop;\n    if( pIn ){\n      int iMap = 0;               /* Index in aiMap[] */\n      pIn += i;\n      for(i=iEq;i<pLoop->nLTerm; i++){\n        if( pLoop->aLTerm[i]->pExpr==pX ){\n          int iOut = iReg + i - iEq;\n          if( eType==IN_INDEX_ROWID ){\n            testcase( nEq>1 );  /* Happens with a UNIQUE index on ROWID */\n            pIn->addrInTop = sqlite3VdbeAddOp2(v, OP_Rowid, iTab, iOut);\n          }else{\n            int iCol = aiMap ? aiMap[iMap++] : 0;\n            pIn->addrInTop = sqlite3VdbeAddOp3(v,OP_Column,iTab, iCol, iOut);\n          }\n          sqlite3VdbeAddOp1(v, OP_IsNull, iOut); VdbeCoverage(v);\n          if( i==iEq ){\n            pIn->iCur = iTab;\n            pIn->eEndLoopOp = bRev ? OP_PrevIfOpen : OP_NextIfOpen;\n          }else{\n            pIn->eEndLoopOp = OP_Noop;\n          }\n          pIn++;\n        }\n      }\n    }else{\n      pLevel->u.in.nIn = 0;\n    }\n    sqlite3DbFree(pParse->db, aiMap);\n#endif\n  }\n  disableTerm(pLevel, pTerm);\n  return iReg;\n}\n\n/*\n** Generate code that will evaluate all == and IN constraints for an\n** index scan.\n**\n** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).\n** Suppose the WHERE clause is this:  a==5 AND b IN (1,2,3) AND c>5 AND c<10\n** The index has as many as three equality constraints, but in this\n** example, the third \"c\" value is an inequality.  So only two \n** constraints are coded.  This routine will generate code to evaluate\n** a==5 and b IN (1,2,3).  The current values for a and b will be stored\n** in consecutive registers and the index of the first register is returned.\n**\n** In the example above nEq==2.  But this subroutine works for any value\n** of nEq including 0.  If nEq==0, this routine is nearly a no-op.\n** The only thing it does is allocate the pLevel->iMem memory cell and\n** compute the affinity string.\n**\n** The nExtraReg parameter is 0 or 1.  It is 0 if all WHERE clause constraints\n** are == or IN and are covered by the nEq.  nExtraReg is 1 if there is\n** an inequality constraint (such as the \"c>=5 AND c<10\" in the example) that\n** occurs after the nEq quality constraints.\n**\n** This routine allocates a range of nEq+nExtraReg memory cells and returns\n** the index of the first memory cell in that range. The code that\n** calls this routine will use that memory range to store keys for\n** start and termination conditions of the loop.\n** key value of the loop.  If one or more IN operators appear, then\n** this routine allocates an additional nEq memory cells for internal\n** use.\n**\n** Before returning, *pzAff is set to point to a buffer containing a\n** copy of the column affinity string of the index allocated using\n** sqlite3DbMalloc(). Except, entries in the copy of the string associated\n** with equality constraints that use BLOB or NONE affinity are set to\n** SQLITE_AFF_BLOB. This is to deal with SQL such as the following:\n**\n**   CREATE TABLE t1(a TEXT PRIMARY KEY, b);\n**   SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;\n**\n** In the example above, the index on t1(a) has TEXT affinity. But since\n** the right hand side of the equality constraint (t2.b) has BLOB/NONE affinity,\n** no conversion should be attempted before using a t2.b value as part of\n** a key to search the index. Hence the first byte in the returned affinity\n** string in this example would be set to SQLITE_AFF_BLOB.\n*/\nstatic int codeAllEqualityTerms(\n  Parse *pParse,        /* Parsing context */\n  WhereLevel *pLevel,   /* Which nested loop of the FROM we are coding */\n  int bRev,             /* Reverse the order of IN operators */\n  int nExtraReg,        /* Number of extra registers to allocate */\n  char **pzAff          /* OUT: Set to point to affinity string */\n){\n  u16 nEq;                      /* The number of == or IN constraints to code */\n  u16 nSkip;                    /* Number of left-most columns to skip */\n  Vdbe *v = pParse->pVdbe;      /* The vm under construction */\n  Index *pIdx;                  /* The index being used for this loop */\n  WhereTerm *pTerm;             /* A single constraint term */\n  WhereLoop *pLoop;             /* The WhereLoop object */\n  int j;                        /* Loop counter */\n  int regBase;                  /* Base register */\n  int nReg;                     /* Number of registers to allocate */\n  char *zAff;                   /* Affinity string to return */\n\n  /* This module is only called on query plans that use an index. */\n  pLoop = pLevel->pWLoop;\n  assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );\n  nEq = pLoop->u.btree.nEq;\n  nSkip = pLoop->nSkip;\n  pIdx = pLoop->u.btree.pIndex;\n  assert( pIdx!=0 );\n\n  /* Figure out how many memory cells we will need then allocate them.\n  */\n  regBase = pParse->nMem + 1;\n  nReg = pLoop->u.btree.nEq + nExtraReg;\n  pParse->nMem += nReg;\n\n  zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx));\n  assert( zAff!=0 || pParse->db->mallocFailed );\n\n  if( nSkip ){\n    int iIdxCur = pLevel->iIdxCur;\n    sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    VdbeComment((v, \"begin skip-scan on %s\", pIdx->zName));\n    j = sqlite3VdbeAddOp0(v, OP_Goto);\n    pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),\n                            iIdxCur, 0, regBase, nSkip);\n    VdbeCoverageIf(v, bRev==0);\n    VdbeCoverageIf(v, bRev!=0);\n    sqlite3VdbeJumpHere(v, j);\n    for(j=0; j<nSkip; j++){\n      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);\n      testcase( pIdx->aiColumn[j]==XN_EXPR );\n      VdbeComment((v, \"%s\", explainIndexColumnName(pIdx, j)));\n    }\n  }    \n\n  /* Evaluate the equality constraints\n  */\n  assert( zAff==0 || (int)strlen(zAff)>=nEq );\n  for(j=nSkip; j<nEq; j++){\n    int r1;\n    pTerm = pLoop->aLTerm[j];\n    assert( pTerm!=0 );\n    /* The following testcase is true for indices with redundant columns. \n    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */\n    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);\n    if( r1!=regBase+j ){\n      if( nReg==1 ){\n        sqlite3ReleaseTempReg(pParse, regBase);\n        regBase = r1;\n      }else{\n        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);\n      }\n    }\n    if( pTerm->eOperator & WO_IN ){\n      if( pTerm->pExpr->flags & EP_xIsSelect ){\n        /* No affinity ever needs to be (or should be) applied to a value\n        ** from the RHS of an \"? IN (SELECT ...)\" expression. The \n        ** sqlite3FindInIndex() routine has already ensured that the \n        ** affinity of the comparison has been applied to the value.  */\n        if( zAff ) zAff[j] = SQLITE_AFF_BLOB;\n      }\n    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){\n      Expr *pRight = pTerm->pExpr->pRight;\n      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);\n        VdbeCoverage(v);\n      }\n      if( zAff ){\n        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){\n          zAff[j] = SQLITE_AFF_BLOB;\n        }\n      }\n    }\n  }\n  *pzAff = zAff;\n  return regBase;\n}\n\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n/*\n** If the most recently coded instruction is a constant range constraint\n** (a string literal) that originated from the LIKE optimization, then \n** set P3 and P5 on the OP_String opcode so that the string will be cast\n** to a BLOB at appropriate times.\n**\n** The LIKE optimization trys to evaluate \"x LIKE 'abc%'\" as a range\n** expression: \"x>='ABC' AND x<'abd'\".  But this requires that the range\n** scan loop run twice, once for strings and a second time for BLOBs.\n** The OP_String opcodes on the second pass convert the upper and lower\n** bound string constants to blobs.  This routine makes the necessary changes\n** to the OP_String opcodes for that to happen.\n**\n** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then\n** only the one pass through the string space is required, so this routine\n** becomes a no-op.\n*/\nstatic void whereLikeOptimizationStringFixup(\n  Vdbe *v,                /* prepared statement under construction */\n  WhereLevel *pLevel,     /* The loop that contains the LIKE operator */\n  WhereTerm *pTerm        /* The upper or lower bound just coded */\n){\n  if( pTerm->wtFlags & TERM_LIKEOPT ){\n    VdbeOp *pOp;\n    assert( pLevel->iLikeRepCntr>0 );\n    pOp = sqlite3VdbeGetOp(v, -1);\n    assert( pOp!=0 );\n    assert( pOp->opcode==OP_String8 \n            || pTerm->pWC->pWInfo->pParse->db->mallocFailed );\n    pOp->p3 = (int)(pLevel->iLikeRepCntr>>1);  /* Register holding counter */\n    pOp->p5 = (u8)(pLevel->iLikeRepCntr&1);    /* ASC or DESC */\n  }\n}\n#else\n# define whereLikeOptimizationStringFixup(A,B,C)\n#endif\n\n#ifdef SQLITE_ENABLE_CURSOR_HINTS\n/*\n** Information is passed from codeCursorHint() down to individual nodes of\n** the expression tree (by sqlite3WalkExpr()) using an instance of this\n** structure.\n*/\nstruct CCurHint {\n  int iTabCur;    /* Cursor for the main table */\n  int iIdxCur;    /* Cursor for the index, if pIdx!=0.  Unused otherwise */\n  Index *pIdx;    /* The index used to access the table */\n};\n\n/*\n** This function is called for every node of an expression that is a candidate\n** for a cursor hint on an index cursor.  For TK_COLUMN nodes that reference\n** the table CCurHint.iTabCur, verify that the same column can be\n** accessed through the index.  If it cannot, then set pWalker->eCode to 1.\n*/\nstatic int codeCursorHintCheckExpr(Walker *pWalker, Expr *pExpr){\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  assert( pHint->pIdx!=0 );\n  if( pExpr->op==TK_COLUMN\n   && pExpr->iTable==pHint->iTabCur\n   && sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn)<0\n  ){\n    pWalker->eCode = 1;\n  }\n  return WRC_Continue;\n}\n\n/*\n** Test whether or not expression pExpr, which was part of a WHERE clause,\n** should be included in the cursor-hint for a table that is on the rhs\n** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the \n** expression is not suitable.\n**\n** An expression is unsuitable if it might evaluate to non NULL even if\n** a TK_COLUMN node that does affect the value of the expression is set\n** to NULL. For example:\n**\n**   col IS NULL\n**   col IS NOT NULL\n**   coalesce(col, 1)\n**   CASE WHEN col THEN 0 ELSE 1 END\n*/\nstatic int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){\n  if( pExpr->op==TK_IS \n   || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT \n   || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE \n  ){\n    pWalker->eCode = 1;\n  }else if( pExpr->op==TK_FUNCTION ){\n    int d1;\n    char d2[4];\n    if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){\n      pWalker->eCode = 1;\n    }\n  }\n\n  return WRC_Continue;\n}\n\n\n/*\n** This function is called on every node of an expression tree used as an\n** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN\n** that accesses any table other than the one identified by\n** CCurHint.iTabCur, then do the following:\n**\n**   1) allocate a register and code an OP_Column instruction to read \n**      the specified column into the new register, and\n**\n**   2) transform the expression node to a TK_REGISTER node that reads \n**      from the newly populated register.\n**\n** Also, if the node is a TK_COLUMN that does access the table idenified\n** by pCCurHint.iTabCur, and an index is being used (which we will\n** know because CCurHint.pIdx!=0) then transform the TK_COLUMN into\n** an access of the index rather than the original table.\n*/\nstatic int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){\n  int rc = WRC_Continue;\n  struct CCurHint *pHint = pWalker->u.pCCurHint;\n  if( pExpr->op==TK_COLUMN ){\n    if( pExpr->iTable!=pHint->iTabCur ){\n      Vdbe *v = pWalker->pParse->pVdbe;\n      int reg = ++pWalker->pParse->nMem;   /* Register for column value */\n      sqlite3ExprCodeGetColumnOfTable(\n          v, pExpr->pTab, pExpr->iTable, pExpr->iColumn, reg\n      );\n      pExpr->op = TK_REGISTER;\n      pExpr->iTable = reg;\n    }else if( pHint->pIdx!=0 ){\n      pExpr->iTable = pHint->iIdxCur;\n      pExpr->iColumn = sqlite3ColumnOfIndex(pHint->pIdx, pExpr->iColumn);\n      assert( pExpr->iColumn>=0 );\n    }\n  }else if( pExpr->op==TK_AGG_FUNCTION ){\n    /* An aggregate function in the WHERE clause of a query means this must\n    ** be a correlated sub-query, and expression pExpr is an aggregate from\n    ** the parent context. Do not walk the function arguments in this case.\n    **\n    ** todo: It should be possible to replace this node with a TK_REGISTER\n    ** expression, as the result of the expression must be stored in a \n    ** register at this point. The same holds for TK_AGG_COLUMN nodes. */\n    rc = WRC_Prune;\n  }\n  return rc;\n}\n\n/*\n** Insert an OP_CursorHint instruction if it is appropriate to do so.\n*/\nstatic void codeCursorHint(\n  struct SrcList_item *pTabItem,  /* FROM clause item */\n  WhereInfo *pWInfo,    /* The where clause */\n  WhereLevel *pLevel,   /* Which loop to provide hints for */\n  WhereTerm *pEndRange  /* Hint this end-of-scan boundary term if not NULL */\n){\n  Parse *pParse = pWInfo->pParse;\n  sqlite3 *db = pParse->db;\n  Vdbe *v = pParse->pVdbe;\n  Expr *pExpr = 0;\n  WhereLoop *pLoop = pLevel->pWLoop;\n  int iCur;\n  WhereClause *pWC;\n  WhereTerm *pTerm;\n  int i, j;\n  struct CCurHint sHint;\n  Walker sWalker;\n\n  if( OptimizationDisabled(db, SQLITE_CursorHints) ) return;\n  iCur = pLevel->iTabCur;\n  assert( iCur==pWInfo->pTabList->a[pLevel->iFrom].iCursor );\n  sHint.iTabCur = iCur;\n  sHint.iIdxCur = pLevel->iIdxCur;\n  sHint.pIdx = pLoop->u.btree.pIndex;\n  memset(&sWalker, 0, sizeof(sWalker));\n  sWalker.pParse = pParse;\n  sWalker.u.pCCurHint = &sHint;\n  pWC = &pWInfo->sWC;\n  for(i=0; i<pWC->nTerm; i++){\n    pTerm = &pWC->a[i];\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( pTerm->prereqAll & pLevel->notReady ) continue;\n\n    /* Any terms specified as part of the ON(...) clause for any LEFT \n    ** JOIN for which the current table is not the rhs are omitted\n    ** from the cursor-hint. \n    **\n    ** If this table is the rhs of a LEFT JOIN, \"IS\" or \"IS NULL\" terms \n    ** that were specified as part of the WHERE clause must be excluded.\n    ** This is to address the following:\n    **\n    **   SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL;\n    **\n    ** Say there is a single row in t2 that matches (t1.a=t2.b), but its\n    ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is \n    ** pushed down to the cursor, this row is filtered out, causing\n    ** SQLite to synthesize a row of NULL values. Which does match the\n    ** WHERE clause, and so the query returns a row. Which is incorrect.\n    **\n    ** For the same reason, WHERE terms such as:\n    **\n    **   WHERE 1 = (t2.c IS NULL)\n    **\n    ** are also excluded. See codeCursorHintIsOrFunction() for details.\n    */\n    if( pTabItem->fg.jointype & JT_LEFT ){\n      Expr *pExpr = pTerm->pExpr;\n      if( !ExprHasProperty(pExpr, EP_FromJoin) \n       || pExpr->iRightJoinTable!=pTabItem->iCursor\n      ){\n        sWalker.eCode = 0;\n        sWalker.xExprCallback = codeCursorHintIsOrFunction;\n        sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n        if( sWalker.eCode ) continue;\n      }\n    }else{\n      if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue;\n    }\n\n    /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize\n    ** the cursor.  These terms are not needed as hints for a pure range\n    ** scan (that has no == terms) so omit them. */\n    if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){\n      for(j=0; j<pLoop->nLTerm && pLoop->aLTerm[j]!=pTerm; j++){}\n      if( j<pLoop->nLTerm ) continue;\n    }\n\n    /* No subqueries or non-deterministic functions allowed */\n    if( sqlite3ExprContainsSubquery(pTerm->pExpr) ) continue;\n\n    /* For an index scan, make sure referenced columns are actually in\n    ** the index. */\n    if( sHint.pIdx!=0 ){\n      sWalker.eCode = 0;\n      sWalker.xExprCallback = codeCursorHintCheckExpr;\n      sqlite3WalkExpr(&sWalker, pTerm->pExpr);\n      if( sWalker.eCode ) continue;\n    }\n\n    /* If we survive all prior tests, that means this term is worth hinting */\n    pExpr = sqlite3ExprAnd(db, pExpr, sqlite3ExprDup(db, pTerm->pExpr, 0));\n  }\n  if( pExpr!=0 ){\n    sWalker.xExprCallback = codeCursorHintFixExpr;\n    sqlite3WalkExpr(&sWalker, pExpr);\n    sqlite3VdbeAddOp4(v, OP_CursorHint, \n                      (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0,\n                      (const char*)pExpr, P4_EXPR);\n  }\n}\n#else\n# define codeCursorHint(A,B,C,D)  /* No-op */\n#endif /* SQLITE_ENABLE_CURSOR_HINTS */\n\n/*\n** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains\n** a rowid value just read from cursor iIdxCur, open on index pIdx. This\n** function generates code to do a deferred seek of cursor iCur to the \n** rowid stored in register iRowid.\n**\n** Normally, this is just:\n**\n**   OP_DeferredSeek $iCur $iRowid\n**\n** However, if the scan currently being coded is a branch of an OR-loop and\n** the statement currently being coded is a SELECT, then P3 of OP_DeferredSeek\n** is set to iIdxCur and P4 is set to point to an array of integers\n** containing one entry for each column of the table cursor iCur is open \n** on. For each table column, if the column is the i'th column of the \n** index, then the corresponding array entry is set to (i+1). If the column\n** does not appear in the index at all, the array entry is set to 0.\n*/\nstatic void codeDeferredSeek(\n  WhereInfo *pWInfo,              /* Where clause context */\n  Index *pIdx,                    /* Index scan is using */\n  int iCur,                       /* Cursor for IPK b-tree */\n  int iIdxCur                     /* Index cursor */\n){\n  Parse *pParse = pWInfo->pParse; /* Parse context */\n  Vdbe *v = pParse->pVdbe;        /* Vdbe to generate code within */\n\n  assert( iIdxCur>0 );\n  assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 );\n  \n  sqlite3VdbeAddOp3(v, OP_DeferredSeek, iIdxCur, 0, iCur);\n  if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)\n   && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask)\n  ){\n    int i;\n    Table *pTab = pIdx->pTable;\n    int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1));\n    if( ai ){\n      ai[0] = pTab->nCol;\n      for(i=0; i<pIdx->nColumn-1; i++){\n        assert( pIdx->aiColumn[i]<pTab->nCol );\n        if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1;\n      }\n      sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY);\n    }\n  }\n}\n\n/*\n** If the expression passed as the second argument is a vector, generate\n** code to write the first nReg elements of the vector into an array\n** of registers starting with iReg.\n**\n** If the expression is not a vector, then nReg must be passed 1. In\n** this case, generate code to evaluate the expression and leave the\n** result in register iReg.\n*/\nstatic void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){\n  assert( nReg>0 );\n  if( p && sqlite3ExprIsVector(p) ){\n#ifndef SQLITE_OMIT_SUBQUERY\n    if( (p->flags & EP_xIsSelect) ){\n      Vdbe *v = pParse->pVdbe;\n      int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);\n      sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);\n    }else\n#endif\n    {\n      int i;\n      ExprList *pList = p->x.pList;\n      assert( nReg<=pList->nExpr );\n      for(i=0; i<nReg; i++){\n        sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i);\n      }\n    }\n  }else{\n    assert( nReg==1 );\n    sqlite3ExprCode(pParse, p, iReg);\n  }\n}\n\n/* An instance of the IdxExprTrans object carries information about a\n** mapping from an expression on table columns into a column in an index\n** down through the Walker.\n*/\ntypedef struct IdxExprTrans {\n  Expr *pIdxExpr;    /* The index expression */\n  int iTabCur;       /* The cursor of the corresponding table */\n  int iIdxCur;       /* The cursor for the index */\n  int iIdxCol;       /* The column for the index */\n} IdxExprTrans;\n\n/* The walker node callback used to transform matching expressions into\n** a reference to an index column for an index on an expression.\n**\n** If pExpr matches, then transform it into a reference to the index column\n** that contains the value of pExpr.\n*/\nstatic int whereIndexExprTransNode(Walker *p, Expr *pExpr){\n  IdxExprTrans *pX = p->u.pIdxTrans;\n  if( sqlite3ExprCompare(0, pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){\n    pExpr->op = TK_COLUMN;\n    pExpr->iTable = pX->iIdxCur;\n    pExpr->iColumn = pX->iIdxCol;\n    pExpr->pTab = 0;\n    return WRC_Prune;\n  }else{\n    return WRC_Continue;\n  }\n}\n\n/*\n** For an indexes on expression X, locate every instance of expression X\n** in pExpr and change that subexpression into a reference to the appropriate\n** column of the index.\n*/\nstatic void whereIndexExprTrans(\n  Index *pIdx,      /* The Index */\n  int iTabCur,      /* Cursor of the table that is being indexed */\n  int iIdxCur,      /* Cursor of the index itself */\n  WhereInfo *pWInfo /* Transform expressions in this WHERE clause */\n){\n  int iIdxCol;               /* Column number of the index */\n  ExprList *aColExpr;        /* Expressions that are indexed */\n  Walker w;\n  IdxExprTrans x;\n  aColExpr = pIdx->aColExpr;\n  if( aColExpr==0 ) return;  /* Not an index on expressions */\n  memset(&w, 0, sizeof(w));\n  w.xExprCallback = whereIndexExprTransNode;\n  w.u.pIdxTrans = &x;\n  x.iTabCur = iTabCur;\n  x.iIdxCur = iIdxCur;\n  for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){\n    if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue;\n    assert( aColExpr->a[iIdxCol].pExpr!=0 );\n    x.iIdxCol = iIdxCol;\n    x.pIdxExpr = aColExpr->a[iIdxCol].pExpr;\n    sqlite3WalkExpr(&w, pWInfo->pWhere);\n    sqlite3WalkExprList(&w, pWInfo->pOrderBy);\n    sqlite3WalkExprList(&w, pWInfo->pResultSet);\n  }\n}\n\n/*\n** Generate code for the start of the iLevel-th loop in the WHERE clause\n** implementation described by pWInfo.\n*/\nBitmask sqlite3WhereCodeOneLoopStart(\n  WhereInfo *pWInfo,   /* Complete information about the WHERE clause */\n  int iLevel,          /* Which level of pWInfo->a[] should be coded */\n  Bitmask notReady     /* Which tables are currently available */\n){\n  int j, k;            /* Loop counters */\n  int iCur;            /* The VDBE cursor for the table */\n  int addrNxt;         /* Where to jump to continue with the next IN case */\n  int omitTable;       /* True if we use the index only */\n  int bRev;            /* True if we need to scan in reverse order */\n  WhereLevel *pLevel;  /* The where level to be coded */\n  WhereLoop *pLoop;    /* The WhereLoop object being coded */\n  WhereClause *pWC;    /* Decomposition of the entire WHERE clause */\n  WhereTerm *pTerm;               /* A WHERE clause term */\n  Parse *pParse;                  /* Parsing context */\n  sqlite3 *db;                    /* Database connection */\n  Vdbe *v;                        /* The prepared stmt under constructions */\n  struct SrcList_item *pTabItem;  /* FROM clause term being coded */\n  int addrBrk;                    /* Jump here to break out of the loop */\n  int addrHalt;                   /* addrBrk for the outermost loop */\n  int addrCont;                   /* Jump here to continue with next cycle */\n  int iRowidReg = 0;        /* Rowid is stored in this register, if not zero */\n  int iReleaseReg = 0;      /* Temp register to free before returning */\n  Index *pIdx = 0;          /* Index used by loop (if any) */\n  int iLoop;                /* Iteration of constraint generator loop */\n\n  pParse = pWInfo->pParse;\n  v = pParse->pVdbe;\n  pWC = &pWInfo->sWC;\n  db = pParse->db;\n  pLevel = &pWInfo->a[iLevel];\n  pLoop = pLevel->pWLoop;\n  pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];\n  iCur = pTabItem->iCursor;\n  pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);\n  bRev = (pWInfo->revMask>>iLevel)&1;\n  omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 \n           && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;\n  VdbeModuleComment((v, \"Begin WHERE-loop%d: %s\",iLevel,pTabItem->pTab->zName));\n\n  /* Create labels for the \"break\" and \"continue\" instructions\n  ** for the current loop.  Jump to addrBrk to break out of a loop.\n  ** Jump to cont to go immediately to the next iteration of the\n  ** loop.\n  **\n  ** When there is an IN operator, we also have a \"addrNxt\" label that\n  ** means to continue with the next IN value combination.  When\n  ** there are no IN operators in the constraints, the \"addrNxt\" label\n  ** is the same as \"addrBrk\".\n  */\n  addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);\n  addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);\n\n  /* If this is the right table of a LEFT OUTER JOIN, allocate and\n  ** initialize a memory cell that records if this table matches any\n  ** row of the left table of the join.\n  */\n  if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){\n    pLevel->iLeftJoin = ++pParse->nMem;\n    sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);\n    VdbeComment((v, \"init LEFT JOIN no-match flag\"));\n  }\n\n  /* Compute a safe address to jump to if we discover that the table for\n  ** this loop is empty and can never contribute content. */\n  for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}\n  addrHalt = pWInfo->a[j].addrBrk;\n\n  /* Special case of a FROM clause subquery implemented as a co-routine */\n  if( pTabItem->fg.viaCoroutine ){\n    int regYield = pTabItem->regReturn;\n    sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);\n    pLevel->p2 =  sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk);\n    VdbeCoverage(v);\n    VdbeComment((v, \"next row of \\\"%s\\\"\", pTabItem->pTab->zName));\n    pLevel->op = OP_Goto;\n  }else\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  if(  (pLoop->wsFlags & WHERE_VIRTUALTABLE)!=0 ){\n    /* Case 1:  The table is a virtual-table.  Use the VFilter and VNext\n    **          to access the data.\n    */\n    int iReg;   /* P3 Value for OP_VFilter */\n    int addrNotFound;\n    int nConstraint = pLoop->nLTerm;\n    int iIn;    /* Counter for IN constraints */\n\n    sqlite3ExprCachePush(pParse);\n    iReg = sqlite3GetTempRange(pParse, nConstraint+2);\n    addrNotFound = pLevel->addrBrk;\n    for(j=0; j<nConstraint; j++){\n      int iTarget = iReg+j+2;\n      pTerm = pLoop->aLTerm[j];\n      if( NEVER(pTerm==0) ) continue;\n      if( pTerm->eOperator & WO_IN ){\n        codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);\n        addrNotFound = pLevel->addrNxt;\n      }else{\n        Expr *pRight = pTerm->pExpr->pRight;\n        codeExprOrVector(pParse, pRight, iTarget, 1);\n      }\n    }\n    sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);\n    sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);\n    sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,\n                      pLoop->u.vtab.idxStr,\n                      pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);\n    VdbeCoverage(v);\n    pLoop->u.vtab.needFree = 0;\n    pLevel->p1 = iCur;\n    pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n    iIn = pLevel->u.in.nIn;\n    for(j=nConstraint-1; j>=0; j--){\n      pTerm = pLoop->aLTerm[j];\n      if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){\n        disableTerm(pLevel, pTerm);\n      }else if( (pTerm->eOperator & WO_IN)!=0 ){\n        Expr *pCompare;  /* The comparison operator */\n        Expr *pRight;    /* RHS of the comparison */\n        VdbeOp *pOp;     /* Opcode to access the value of the IN constraint */\n\n        /* Reload the constraint value into reg[iReg+j+2].  The same value\n        ** was loaded into the same register prior to the OP_VFilter, but\n        ** the xFilter implementation might have changed the datatype or\n        ** encoding of the value in the register, so it *must* be reloaded. */\n        assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );\n        if( !db->mallocFailed ){\n          assert( iIn>0 );\n          pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[--iIn].addrInTop);\n          assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );\n          assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );\n          assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );\n          testcase( pOp->opcode==OP_Rowid );\n          sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);\n        }\n\n        /* Generate code that will continue to the next row if \n        ** the IN constraint is not satisfied */\n        pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);\n        assert( pCompare!=0 || db->mallocFailed );\n        if( pCompare ){\n          pCompare->pLeft = pTerm->pExpr->pLeft;\n          pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);\n          if( pRight ){\n            pRight->iTable = iReg+j+2;\n            sqlite3ExprIfFalse(pParse, pCompare, pLevel->addrCont, 0);\n          }\n          pCompare->pLeft = 0;\n          sqlite3ExprDelete(db, pCompare);\n        }\n      }\n    }\n    /* These registers need to be preserved in case there is an IN operator\n    ** loop.  So we could deallocate the registers here (and potentially\n    ** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0.  But it seems\n    ** simpler and safer to simply not reuse the registers.\n    **\n    **    sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);\n    */\n    sqlite3ExprCachePop(pParse);\n  }else\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  if( (pLoop->wsFlags & WHERE_IPK)!=0\n   && (pLoop->wsFlags & (WHERE_COLUMN_IN|WHERE_COLUMN_EQ))!=0\n  ){\n    /* Case 2:  We can directly reference a single row using an\n    **          equality comparison against the ROWID field.  Or\n    **          we reference multiple rows using a \"rowid IN (...)\"\n    **          construct.\n    */\n    assert( pLoop->u.btree.nEq==1 );\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->pExpr!=0 );\n    assert( omitTable==0 );\n    testcase( pTerm->wtFlags & TERM_VIRTUAL );\n    iReleaseReg = ++pParse->nMem;\n    iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);\n    if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);\n    addrNxt = pLevel->addrNxt;\n    sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);\n    VdbeCoverage(v);\n    sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1);\n    sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n    VdbeComment((v, \"pk\"));\n    pLevel->op = OP_Noop;\n  }else if( (pLoop->wsFlags & WHERE_IPK)!=0\n         && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0\n  ){\n    /* Case 3:  We have an inequality comparison against the ROWID field.\n    */\n    int testOp = OP_Noop;\n    int start;\n    int memEndValue = 0;\n    WhereTerm *pStart, *pEnd;\n\n    assert( omitTable==0 );\n    j = 0;\n    pStart = pEnd = 0;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ) pStart = pLoop->aLTerm[j++];\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ) pEnd = pLoop->aLTerm[j++];\n    assert( pStart!=0 || pEnd!=0 );\n    if( bRev ){\n      pTerm = pStart;\n      pStart = pEnd;\n      pEnd = pTerm;\n    }\n    codeCursorHint(pTabItem, pWInfo, pLevel, pEnd);\n    if( pStart ){\n      Expr *pX;             /* The expression that defines the start bound */\n      int r1, rTemp;        /* Registers for holding the start boundary */\n      int op;               /* Cursor seek operation */\n\n      /* The following constant maps TK_xx codes into corresponding \n      ** seek opcodes.  It depends on a particular ordering of TK_xx\n      */\n      const u8 aMoveOp[] = {\n           /* TK_GT */  OP_SeekGT,\n           /* TK_LE */  OP_SeekLE,\n           /* TK_LT */  OP_SeekLT,\n           /* TK_GE */  OP_SeekGE\n      };\n      assert( TK_LE==TK_GT+1 );      /* Make sure the ordering.. */\n      assert( TK_LT==TK_GT+2 );      /*  ... of the TK_xx values... */\n      assert( TK_GE==TK_GT+3 );      /*  ... is correcct. */\n\n      assert( (pStart->wtFlags & TERM_VNULL)==0 );\n      testcase( pStart->wtFlags & TERM_VIRTUAL );\n      pX = pStart->pExpr;\n      assert( pX!=0 );\n      testcase( pStart->leftCursor!=iCur ); /* transitive constraints */\n      if( sqlite3ExprIsVector(pX->pRight) ){\n        r1 = rTemp = sqlite3GetTempReg(pParse);\n        codeExprOrVector(pParse, pX->pRight, r1, 1);\n        op = aMoveOp[(pX->op - TK_GT) | 0x0001];\n      }else{\n        r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp);\n        disableTerm(pLevel, pStart);\n        op = aMoveOp[(pX->op - TK_GT)];\n      }\n      sqlite3VdbeAddOp3(v, op, iCur, addrBrk, r1);\n      VdbeComment((v, \"pk\"));\n      VdbeCoverageIf(v, pX->op==TK_GT);\n      VdbeCoverageIf(v, pX->op==TK_LE);\n      VdbeCoverageIf(v, pX->op==TK_LT);\n      VdbeCoverageIf(v, pX->op==TK_GE);\n      sqlite3ExprCacheAffinityChange(pParse, r1, 1);\n      sqlite3ReleaseTempReg(pParse, rTemp);\n    }else{\n      sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n    }\n    if( pEnd ){\n      Expr *pX;\n      pX = pEnd->pExpr;\n      assert( pX!=0 );\n      assert( (pEnd->wtFlags & TERM_VNULL)==0 );\n      testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */\n      testcase( pEnd->wtFlags & TERM_VIRTUAL );\n      memEndValue = ++pParse->nMem;\n      codeExprOrVector(pParse, pX->pRight, memEndValue, 1);\n      if( 0==sqlite3ExprIsVector(pX->pRight) \n       && (pX->op==TK_LT || pX->op==TK_GT) \n      ){\n        testOp = bRev ? OP_Le : OP_Ge;\n      }else{\n        testOp = bRev ? OP_Lt : OP_Gt;\n      }\n      if( 0==sqlite3ExprIsVector(pX->pRight) ){\n        disableTerm(pLevel, pEnd);\n      }\n    }\n    start = sqlite3VdbeCurrentAddr(v);\n    pLevel->op = bRev ? OP_Prev : OP_Next;\n    pLevel->p1 = iCur;\n    pLevel->p2 = start;\n    assert( pLevel->p5==0 );\n    if( testOp!=OP_Noop ){\n      iRowidReg = ++pParse->nMem;\n      sqlite3VdbeAddOp2(v, OP_Rowid, iCur, iRowidReg);\n      sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n      sqlite3VdbeAddOp3(v, testOp, memEndValue, addrBrk, iRowidReg);\n      VdbeCoverageIf(v, testOp==OP_Le);\n      VdbeCoverageIf(v, testOp==OP_Lt);\n      VdbeCoverageIf(v, testOp==OP_Ge);\n      VdbeCoverageIf(v, testOp==OP_Gt);\n      sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC | SQLITE_JUMPIFNULL);\n    }\n  }else if( pLoop->wsFlags & WHERE_INDEXED ){\n    /* Case 4: A scan using an index.\n    **\n    **         The WHERE clause may contain zero or more equality \n    **         terms (\"==\" or \"IN\" operators) that refer to the N\n    **         left-most columns of the index. It may also contain\n    **         inequality constraints (>, <, >= or <=) on the indexed\n    **         column that immediately follows the N equalities. Only \n    **         the right-most column can be an inequality - the rest must\n    **         use the \"==\" and \"IN\" operators. For example, if the \n    **         index is on (x,y,z), then the following clauses are all \n    **         optimized:\n    **\n    **            x=5\n    **            x=5 AND y=10\n    **            x=5 AND y<10\n    **            x=5 AND y>5 AND y<10\n    **            x=5 AND y=5 AND z<=10\n    **\n    **         The z<10 term of the following cannot be used, only\n    **         the x=5 term:\n    **\n    **            x=5 AND z<10\n    **\n    **         N may be zero if there are inequality constraints.\n    **         If there are no inequality constraints, then N is at\n    **         least one.\n    **\n    **         This case is also used when there are no WHERE clause\n    **         constraints but an index is selected anyway, in order\n    **         to force the output order to conform to an ORDER BY.\n    */  \n    static const u8 aStartOp[] = {\n      0,\n      0,\n      OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */\n      OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */\n      OP_SeekGT,           /* 4: (start_constraints  && !startEq && !bRev) */\n      OP_SeekLT,           /* 5: (start_constraints  && !startEq &&  bRev) */\n      OP_SeekGE,           /* 6: (start_constraints  &&  startEq && !bRev) */\n      OP_SeekLE            /* 7: (start_constraints  &&  startEq &&  bRev) */\n    };\n    static const u8 aEndOp[] = {\n      OP_IdxGE,            /* 0: (end_constraints && !bRev && !endEq) */\n      OP_IdxGT,            /* 1: (end_constraints && !bRev &&  endEq) */\n      OP_IdxLE,            /* 2: (end_constraints &&  bRev && !endEq) */\n      OP_IdxLT,            /* 3: (end_constraints &&  bRev &&  endEq) */\n    };\n    u16 nEq = pLoop->u.btree.nEq;     /* Number of == or IN terms */\n    u16 nBtm = pLoop->u.btree.nBtm;   /* Length of BTM vector */\n    u16 nTop = pLoop->u.btree.nTop;   /* Length of TOP vector */\n    int regBase;                 /* Base register holding constraint values */\n    WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */\n    WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */\n    int startEq;                 /* True if range start uses ==, >= or <= */\n    int endEq;                   /* True if range end uses ==, >= or <= */\n    int start_constraints;       /* Start of range is constrained */\n    int nConstraint;             /* Number of constraint terms */\n    int iIdxCur;                 /* The VDBE cursor for the index */\n    int nExtraReg = 0;           /* Number of extra registers needed */\n    int op;                      /* Instruction opcode */\n    char *zStartAff;             /* Affinity for start of range constraint */\n    char *zEndAff = 0;           /* Affinity for end of range constraint */\n    u8 bSeekPastNull = 0;        /* True to seek past initial nulls */\n    u8 bStopAtNull = 0;          /* Add condition to terminate at NULLs */\n\n    pIdx = pLoop->u.btree.pIndex;\n    iIdxCur = pLevel->iIdxCur;\n    assert( nEq>=pLoop->nSkip );\n\n    /* If this loop satisfies a sort order (pOrderBy) request that \n    ** was passed to this function to implement a \"SELECT min(x) ...\" \n    ** query, then the caller will only allow the loop to run for\n    ** a single iteration. This means that the first row returned\n    ** should not have a NULL value stored in 'x'. If column 'x' is\n    ** the first one after the nEq equality constraints in the index,\n    ** this requires some special handling.\n    */\n    assert( pWInfo->pOrderBy==0\n         || pWInfo->pOrderBy->nExpr==1\n         || (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 );\n    if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0\n     && pWInfo->nOBSat>0\n     && (pIdx->nKeyCol>nEq)\n    ){\n      assert( pLoop->nSkip==0 );\n      bSeekPastNull = 1;\n      nExtraReg = 1;\n    }\n\n    /* Find any inequality constraint terms for the start and end \n    ** of the range. \n    */\n    j = nEq;\n    if( pLoop->wsFlags & WHERE_BTM_LIMIT ){\n      pRangeStart = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nBtm);\n      /* Like optimization range constraints always occur in pairs */\n      assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 || \n              (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );\n    }\n    if( pLoop->wsFlags & WHERE_TOP_LIMIT ){\n      pRangeEnd = pLoop->aLTerm[j++];\n      nExtraReg = MAX(nExtraReg, pLoop->u.btree.nTop);\n#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n      if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){\n        assert( pRangeStart!=0 );                     /* LIKE opt constraints */\n        assert( pRangeStart->wtFlags & TERM_LIKEOPT );   /* occur in pairs */\n        pLevel->iLikeRepCntr = (u32)++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Integer, 1, (int)pLevel->iLikeRepCntr);\n        VdbeComment((v, \"LIKE loop counter\"));\n        pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);\n        /* iLikeRepCntr actually stores 2x the counter register number.  The\n        ** bottom bit indicates whether the search order is ASC or DESC. */\n        testcase( bRev );\n        testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );\n        assert( (bRev & ~1)==0 );\n        pLevel->iLikeRepCntr <<=1;\n        pLevel->iLikeRepCntr |= bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC);\n      }\n#endif\n      if( pRangeStart==0 ){\n        j = pIdx->aiColumn[nEq];\n        if( (j>=0 && pIdx->pTable->aCol[j].notNull==0) || j==XN_EXPR ){\n          bSeekPastNull = 1;\n        }\n      }\n    }\n    assert( pRangeEnd==0 || (pRangeEnd->wtFlags & TERM_VNULL)==0 );\n\n    /* If we are doing a reverse order scan on an ascending index, or\n    ** a forward order scan on a descending index, interchange the \n    ** start and end terms (pRangeStart and pRangeEnd).\n    */\n    if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC))\n     || (bRev && pIdx->nKeyCol==nEq)\n    ){\n      SWAP(WhereTerm *, pRangeEnd, pRangeStart);\n      SWAP(u8, bSeekPastNull, bStopAtNull);\n      SWAP(u8, nBtm, nTop);\n    }\n\n    /* Generate code to evaluate all constraint terms using == or IN\n    ** and store the values of those terms in an array of registers\n    ** starting at regBase.\n    */\n    codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd);\n    regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);\n    assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq );\n    if( zStartAff && nTop ){\n      zEndAff = sqlite3DbStrDup(db, &zStartAff[nEq]);\n    }\n    addrNxt = pLevel->addrNxt;\n\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 );\n    testcase( pRangeStart && (pRangeStart->eOperator & WO_GE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_LE)!=0 );\n    testcase( pRangeEnd && (pRangeEnd->eOperator & WO_GE)!=0 );\n    startEq = !pRangeStart || pRangeStart->eOperator & (WO_LE|WO_GE);\n    endEq =   !pRangeEnd || pRangeEnd->eOperator & (WO_LE|WO_GE);\n    start_constraints = pRangeStart || nEq>0;\n\n    /* Seek the index cursor to the start of the range. */\n    nConstraint = nEq;\n    if( pRangeStart ){\n      Expr *pRight = pRangeStart->pExpr->pRight;\n      codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);\n      if( (pRangeStart->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zStartAff ){\n        updateRangeAffinityStr(pRight, nBtm, &zStartAff[nEq]);\n      }  \n      nConstraint += nBtm;\n      testcase( pRangeStart->wtFlags & TERM_VIRTUAL );\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeStart);\n      }else{\n        startEq = 1;\n      }\n      bSeekPastNull = 0;\n    }else if( bSeekPastNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      nConstraint++;\n      startEq = 0;\n      start_constraints = 1;\n    }\n    codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);\n    if( pLoop->nSkip>0 && nConstraint==pLoop->nSkip ){\n      /* The skip-scan logic inside the call to codeAllEqualityConstraints()\n      ** above has already left the cursor sitting on the correct row,\n      ** so no further seeking is needed */\n    }else{\n      op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];\n      assert( op!=0 );\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      VdbeCoverage(v);\n      VdbeCoverageIf(v, op==OP_Rewind);  testcase( op==OP_Rewind );\n      VdbeCoverageIf(v, op==OP_Last);    testcase( op==OP_Last );\n      VdbeCoverageIf(v, op==OP_SeekGT);  testcase( op==OP_SeekGT );\n      VdbeCoverageIf(v, op==OP_SeekGE);  testcase( op==OP_SeekGE );\n      VdbeCoverageIf(v, op==OP_SeekLE);  testcase( op==OP_SeekLE );\n      VdbeCoverageIf(v, op==OP_SeekLT);  testcase( op==OP_SeekLT );\n    }\n\n    /* Load the value for the inequality constraint at the end of the\n    ** range (if any).\n    */\n    nConstraint = nEq;\n    if( pRangeEnd ){\n      Expr *pRight = pRangeEnd->pExpr->pRight;\n      sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);\n      codeExprOrVector(pParse, pRight, regBase+nEq, nTop);\n      whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);\n      if( (pRangeEnd->wtFlags & TERM_VNULL)==0\n       && sqlite3ExprCanBeNull(pRight)\n      ){\n        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);\n        VdbeCoverage(v);\n      }\n      if( zEndAff ){\n        updateRangeAffinityStr(pRight, nTop, zEndAff);\n        codeApplyAffinity(pParse, regBase+nEq, nTop, zEndAff);\n      }else{\n        assert( pParse->db->mallocFailed );\n      }\n      nConstraint += nTop;\n      testcase( pRangeEnd->wtFlags & TERM_VIRTUAL );\n\n      if( sqlite3ExprIsVector(pRight)==0 ){\n        disableTerm(pLevel, pRangeEnd);\n      }else{\n        endEq = 1;\n      }\n    }else if( bStopAtNull ){\n      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);\n      endEq = 0;\n      nConstraint++;\n    }\n    sqlite3DbFree(db, zStartAff);\n    sqlite3DbFree(db, zEndAff);\n\n    /* Top of the loop body */\n    pLevel->p2 = sqlite3VdbeCurrentAddr(v);\n\n    /* Check if the index cursor is past the end of the range. */\n    if( nConstraint ){\n      op = aEndOp[bRev*2 + endEq];\n      sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);\n      testcase( op==OP_IdxGT );  VdbeCoverageIf(v, op==OP_IdxGT );\n      testcase( op==OP_IdxGE );  VdbeCoverageIf(v, op==OP_IdxGE );\n      testcase( op==OP_IdxLT );  VdbeCoverageIf(v, op==OP_IdxLT );\n      testcase( op==OP_IdxLE );  VdbeCoverageIf(v, op==OP_IdxLE );\n    }\n\n    /* Seek the table cursor, if required */\n    if( omitTable ){\n      /* pIdx is a covering index.  No need to access the main table. */\n    }else if( HasRowid(pIdx->pTable) ){\n      if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || (\n          (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) \n       && (pWInfo->eOnePass==ONEPASS_SINGLE)\n      )){\n        iRowidReg = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg);\n        sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg);\n        sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, iRowidReg);\n        VdbeCoverage(v);\n      }else{\n        codeDeferredSeek(pWInfo, pIdx, iCur, iIdxCur);\n      }\n    }else if( iCur!=iIdxCur ){\n      Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable);\n      iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol);\n      for(j=0; j<pPk->nKeyCol; j++){\n        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]);\n        sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j);\n      }\n      sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,\n                           iRowidReg, pPk->nKeyCol); VdbeCoverage(v);\n    }\n\n    /* If pIdx is an index on one or more expressions, then look through\n    ** all the expressions in pWInfo and try to transform matching expressions\n    ** into reference to index columns.\n    */\n    whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);\n\n\n    /* Record the instruction used to terminate the loop. */\n    if( pLoop->wsFlags & WHERE_ONEROW ){\n      pLevel->op = OP_Noop;\n    }else if( bRev ){\n      pLevel->op = OP_Prev;\n    }else{\n      pLevel->op = OP_Next;\n    }\n    pLevel->p1 = iIdxCur;\n    pLevel->p3 = (pLoop->wsFlags&WHERE_UNQ_WANTED)!=0 ? 1:0;\n    if( (pLoop->wsFlags & WHERE_CONSTRAINT)==0 ){\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }else{\n      assert( pLevel->p5==0 );\n    }\n    if( omitTable ) pIdx = 0;\n  }else\n\n#ifndef SQLITE_OMIT_OR_OPTIMIZATION\n  if( pLoop->wsFlags & WHERE_MULTI_OR ){\n    /* Case 5:  Two or more separately indexed terms connected by OR\n    **\n    ** Example:\n    **\n    **   CREATE TABLE t1(a,b,c,d);\n    **   CREATE INDEX i1 ON t1(a);\n    **   CREATE INDEX i2 ON t1(b);\n    **   CREATE INDEX i3 ON t1(c);\n    **\n    **   SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)\n    **\n    ** In the example, there are three indexed terms connected by OR.\n    ** The top of the loop looks like this:\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **\n    ** Then, for each indexed term, the following. The arguments to\n    ** RowSetTest are such that the rowid of the current row is inserted\n    ** into the RowSet. If it is already present, control skips the\n    ** Gosub opcode and jumps straight to the code generated by WhereEnd().\n    **\n    **        sqlite3WhereBegin(<term>)\n    **          RowSetTest                  # Insert rowid into rowset\n    **          Gosub      2 A\n    **        sqlite3WhereEnd()\n    **\n    ** Following the above, code to terminate the loop. Label A, the target\n    ** of the Gosub above, jumps to the instruction right after the Goto.\n    **\n    **          Null       1                # Zero the rowset in reg 1\n    **          Goto       B                # The loop is finished.\n    **\n    **       A: <loop body>                 # Return data, whatever.\n    **\n    **          Return     2                # Jump back to the Gosub\n    **\n    **       B: <after the loop>\n    **\n    ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then\n    ** use an ephemeral index instead of a RowSet to record the primary\n    ** keys of the rows we have already seen.\n    **\n    */\n    WhereClause *pOrWc;    /* The OR-clause broken out into subterms */\n    SrcList *pOrTab;       /* Shortened table list or OR-clause generation */\n    Index *pCov = 0;             /* Potential covering index (or NULL) */\n    int iCovCur = pParse->nTab++;  /* Cursor used for index scans (if any) */\n\n    int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */\n    int regRowset = 0;                        /* Register for RowSet object */\n    int regRowid = 0;                         /* Register holding rowid */\n    int iLoopBody = sqlite3VdbeMakeLabel(v);  /* Start of loop body */\n    int iRetInit;                             /* Address of regReturn init */\n    int untestedTerms = 0;             /* Some terms not completely tested */\n    int ii;                            /* Loop counter */\n    u16 wctrlFlags;                    /* Flags for sub-WHERE clause */\n    Expr *pAndExpr = 0;                /* An \".. AND (...)\" expression */\n    Table *pTab = pTabItem->pTab;\n\n    pTerm = pLoop->aLTerm[0];\n    assert( pTerm!=0 );\n    assert( pTerm->eOperator & WO_OR );\n    assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );\n    pOrWc = &pTerm->u.pOrInfo->wc;\n    pLevel->op = OP_Return;\n    pLevel->p1 = regReturn;\n\n    /* Set up a new SrcList in pOrTab containing the table being scanned\n    ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.\n    ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().\n    */\n    if( pWInfo->nLevel>1 ){\n      int nNotReady;                 /* The number of notReady tables */\n      struct SrcList_item *origSrc;     /* Original list of tables */\n      nNotReady = pWInfo->nLevel - iLevel - 1;\n      pOrTab = sqlite3StackAllocRaw(db,\n                            sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));\n      if( pOrTab==0 ) return notReady;\n      pOrTab->nAlloc = (u8)(nNotReady + 1);\n      pOrTab->nSrc = pOrTab->nAlloc;\n      memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));\n      origSrc = pWInfo->pTabList->a;\n      for(k=1; k<=nNotReady; k++){\n        memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));\n      }\n    }else{\n      pOrTab = pWInfo->pTabList;\n    }\n\n    /* Initialize the rowset register to contain NULL. An SQL NULL is \n    ** equivalent to an empty rowset.  Or, create an ephemeral index\n    ** capable of holding primary keys in the case of a WITHOUT ROWID.\n    **\n    ** Also initialize regReturn to contain the address of the instruction \n    ** immediately following the OP_Return at the bottom of the loop. This\n    ** is required in a few obscure LEFT JOIN cases where control jumps\n    ** over the top of the loop into the body of it. In this case the \n    ** correct response for the end-of-loop code (the OP_Return) is to \n    ** fall through to the next instruction, just as an OP_Next does if\n    ** called on an uninitialized cursor.\n    */\n    if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n      if( HasRowid(pTab) ){\n        regRowset = ++pParse->nMem;\n        sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset);\n      }else{\n        Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n        regRowset = pParse->nTab++;\n        sqlite3VdbeAddOp2(v, OP_OpenEphemeral, regRowset, pPk->nKeyCol);\n        sqlite3VdbeSetP4KeyInfo(pParse, pPk);\n      }\n      regRowid = ++pParse->nMem;\n    }\n    iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);\n\n    /* If the original WHERE clause is z of the form:  (x1 OR x2 OR ...) AND y\n    ** Then for every term xN, evaluate as the subexpression: xN AND z\n    ** That way, terms in y that are factored into the disjunction will\n    ** be picked up by the recursive calls to sqlite3WhereBegin() below.\n    **\n    ** Actually, each subexpression is converted to \"xN AND w\" where w is\n    ** the \"interesting\" terms of z - terms that did not originate in the\n    ** ON or USING clause of a LEFT JOIN, and terms that are usable as \n    ** indices.\n    **\n    ** This optimization also only applies if the (x1 OR x2 OR ...) term\n    ** is not contained in the ON clause of a LEFT JOIN.\n    ** See ticket http://www.sqlite.org/src/info/f2369304e4\n    */\n    if( pWC->nTerm>1 ){\n      int iTerm;\n      for(iTerm=0; iTerm<pWC->nTerm; iTerm++){\n        Expr *pExpr = pWC->a[iTerm].pExpr;\n        if( &pWC->a[iTerm] == pTerm ) continue;\n        if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );\n        testcase( pWC->a[iTerm].wtFlags & TERM_CODED );\n        if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;\n        if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;\n        testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );\n        pExpr = sqlite3ExprDup(db, pExpr, 0);\n        pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);\n      }\n      if( pAndExpr ){\n        pAndExpr = sqlite3PExpr(pParse, TK_AND|TKFLG_DONTFOLD, 0, pAndExpr);\n      }\n    }\n\n    /* Run a separate WHERE clause for each term of the OR clause.  After\n    ** eliminating duplicates from other WHERE clauses, the action for each\n    ** sub-WHERE clause is to to invoke the main loop body as a subroutine.\n    */\n    wctrlFlags =  WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);\n    for(ii=0; ii<pOrWc->nTerm; ii++){\n      WhereTerm *pOrTerm = &pOrWc->a[ii];\n      if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){\n        WhereInfo *pSubWInfo;           /* Info for single OR-term scan */\n        Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */\n        int jmp1 = 0;                   /* Address of jump operation */\n        if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){\n          pAndExpr->pLeft = pOrExpr;\n          pOrExpr = pAndExpr;\n        }\n        /* Loop through table entries that match term pOrTerm. */\n        WHERETRACE(0xffff, (\"Subplan for OR-clause:\\n\"));\n        pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,\n                                      wctrlFlags, iCovCur);\n        assert( pSubWInfo || pParse->nErr || db->mallocFailed );\n        if( pSubWInfo ){\n          WhereLoop *pSubLoop;\n          int addrExplain = sqlite3WhereExplainOneScan(\n              pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0\n          );\n          sqlite3WhereAddScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);\n\n          /* This is the sub-WHERE clause body.  First skip over\n          ** duplicate rows from prior sub-WHERE clauses, and record the\n          ** rowid (or PRIMARY KEY) for the current row so that the same\n          ** row will be skipped in subsequent sub-WHERE clauses.\n          */\n          if( (pWInfo->wctrlFlags & WHERE_DUPLICATES_OK)==0 ){\n            int r;\n            int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);\n            if( HasRowid(pTab) ){\n              r = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, regRowid, 0);\n              jmp1 = sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, 0,\n                                           r,iSet);\n              VdbeCoverage(v);\n            }else{\n              Index *pPk = sqlite3PrimaryKeyIndex(pTab);\n              int nPk = pPk->nKeyCol;\n              int iPk;\n\n              /* Read the PK into an array of temp registers. */\n              r = sqlite3GetTempRange(pParse, nPk);\n              for(iPk=0; iPk<nPk; iPk++){\n                int iCol = pPk->aiColumn[iPk];\n                sqlite3ExprCodeGetColumnToReg(pParse, pTab, iCol, iCur, r+iPk);\n              }\n\n              /* Check if the temp table already contains this key. If so,\n              ** the row has already been included in the result set and\n              ** can be ignored (by jumping past the Gosub below). Otherwise,\n              ** insert the key into the temp table and proceed with processing\n              ** the row.\n              **\n              ** Use some of the same optimizations as OP_RowSetTest: If iSet\n              ** is zero, assume that the key cannot already be present in\n              ** the temp table. And if iSet is -1, assume that there is no \n              ** need to insert the key into the temp table, as it will never \n              ** be tested for.  */ \n              if( iSet ){\n                jmp1 = sqlite3VdbeAddOp4Int(v, OP_Found, regRowset, 0, r, nPk);\n                VdbeCoverage(v);\n              }\n              if( iSet>=0 ){\n                sqlite3VdbeAddOp3(v, OP_MakeRecord, r, nPk, regRowid);\n                sqlite3VdbeAddOp4Int(v, OP_IdxInsert, regRowset, regRowid,\n                                     r, nPk);\n                if( iSet ) sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);\n              }\n\n              /* Release the array of temp registers */\n              sqlite3ReleaseTempRange(pParse, r, nPk);\n            }\n          }\n\n          /* Invoke the main loop body as a subroutine */\n          sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);\n\n          /* Jump here (skipping the main loop body subroutine) if the\n          ** current sub-WHERE row is a duplicate from prior sub-WHEREs. */\n          if( jmp1 ) sqlite3VdbeJumpHere(v, jmp1);\n\n          /* The pSubWInfo->untestedTerms flag means that this OR term\n          ** contained one or more AND term from a notReady table.  The\n          ** terms from the notReady table could not be tested and will\n          ** need to be tested later.\n          */\n          if( pSubWInfo->untestedTerms ) untestedTerms = 1;\n\n          /* If all of the OR-connected terms are optimized using the same\n          ** index, and the index is opened using the same cursor number\n          ** by each call to sqlite3WhereBegin() made by this loop, it may\n          ** be possible to use that index as a covering index.\n          **\n          ** If the call to sqlite3WhereBegin() above resulted in a scan that\n          ** uses an index, and this is either the first OR-connected term\n          ** processed or the index is the same as that used by all previous\n          ** terms, set pCov to the candidate covering index. Otherwise, set \n          ** pCov to NULL to indicate that no candidate covering index will \n          ** be available.\n          */\n          pSubLoop = pSubWInfo->a[0].pWLoop;\n          assert( (pSubLoop->wsFlags & WHERE_AUTO_INDEX)==0 );\n          if( (pSubLoop->wsFlags & WHERE_INDEXED)!=0\n           && (ii==0 || pSubLoop->u.btree.pIndex==pCov)\n           && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex))\n          ){\n            assert( pSubWInfo->a[0].iIdxCur==iCovCur );\n            pCov = pSubLoop->u.btree.pIndex;\n          }else{\n            pCov = 0;\n          }\n\n          /* Finish the loop through table entries that match term pOrTerm. */\n          sqlite3WhereEnd(pSubWInfo);\n        }\n      }\n    }\n    pLevel->u.pCovidx = pCov;\n    if( pCov ) pLevel->iIdxCur = iCovCur;\n    if( pAndExpr ){\n      pAndExpr->pLeft = 0;\n      sqlite3ExprDelete(db, pAndExpr);\n    }\n    sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));\n    sqlite3VdbeGoto(v, pLevel->addrBrk);\n    sqlite3VdbeResolveLabel(v, iLoopBody);\n\n    if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);\n    if( !untestedTerms ) disableTerm(pLevel, pTerm);\n  }else\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n  {\n    /* Case 6:  There is no usable index.  We must do a complete\n    **          scan of the entire table.\n    */\n    static const u8 aStep[] = { OP_Next, OP_Prev };\n    static const u8 aStart[] = { OP_Rewind, OP_Last };\n    assert( bRev==0 || bRev==1 );\n    if( pTabItem->fg.isRecursive ){\n      /* Tables marked isRecursive have only a single row that is stored in\n      ** a pseudo-cursor.  No need to Rewind or Next such cursors. */\n      pLevel->op = OP_Noop;\n    }else{\n      codeCursorHint(pTabItem, pWInfo, pLevel, 0);\n      pLevel->op = aStep[bRev];\n      pLevel->p1 = iCur;\n      pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);\n      VdbeCoverageIf(v, bRev==0);\n      VdbeCoverageIf(v, bRev!=0);\n      pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STMT_SCANSTATUS\n  pLevel->addrVisit = sqlite3VdbeCurrentAddr(v);\n#endif\n\n  /* Insert code to test every subexpression that can be completely\n  ** computed using the current set of tables.\n  **\n  ** This loop may run between one and three times, depending on the\n  ** constraints to be generated. The value of stack variable iLoop\n  ** determines the constraints coded by each iteration, as follows:\n  **\n  ** iLoop==1: Code only expressions that are entirely covered by pIdx.\n  ** iLoop==2: Code remaining expressions that do not contain correlated\n  **           sub-queries.  \n  ** iLoop==3: Code all remaining expressions.\n  **\n  ** An effort is made to skip unnecessary iterations of the loop.\n  */\n  iLoop = (pIdx ? 1 : 2);\n  do{\n    int iNext = 0;                /* Next value for iLoop */\n    for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n      Expr *pE;\n      int skipLikeAddr = 0;\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        testcase( pWInfo->untestedTerms==0\n            && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );\n        pWInfo->untestedTerms = 1;\n        continue;\n      }\n      pE = pTerm->pExpr;\n      assert( pE!=0 );\n      if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){\n        continue;\n      }\n      \n      if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){\n        iNext = 2;\n        continue;\n      }\n      if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){\n        if( iNext==0 ) iNext = 3;\n        continue;\n      }\n\n      if( pTerm->wtFlags & TERM_LIKECOND ){\n        /* If the TERM_LIKECOND flag is set, that means that the range search\n        ** is sufficient to guarantee that the LIKE operator is true, so we\n        ** can skip the call to the like(A,B) function.  But this only works\n        ** for strings.  So do not skip the call to the function on the pass\n        ** that compares BLOBs. */\n#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS\n        continue;\n#else\n        u32 x = pLevel->iLikeRepCntr;\n        assert( x>0 );\n        skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1));\n        VdbeCoverage(v);\n#endif\n      }\n#ifdef WHERETRACE_ENABLED /* 0xffff */\n      if( sqlite3WhereTrace ){\n        VdbeNoopComment((v, \"WhereTerm[%d] (%p) priority=%d\",\n                         pWC->nTerm-j, pTerm, iLoop));\n      }\n#endif\n      sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);\n      if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n    iLoop = iNext;\n  }while( iLoop>0 );\n\n  /* Insert code to test for implied constraints based on transitivity\n  ** of the \"==\" operator.\n  **\n  ** Example: If the WHERE clause contains \"t1.a=t2.b\" and \"t2.b=123\"\n  ** and we are coding the t1 loop and the t2 loop has not yet coded,\n  ** then we cannot use the \"t1.a=t2.b\" constraint, but we can code\n  ** the implied \"t1.a=123\" constraint.\n  */\n  for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){\n    Expr *pE, sEAlt;\n    WhereTerm *pAlt;\n    if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n    if( (pTerm->eOperator & (WO_EQ|WO_IS))==0 ) continue;\n    if( (pTerm->eOperator & WO_EQUIV)==0 ) continue;\n    if( pTerm->leftCursor!=iCur ) continue;\n    if( pLevel->iLeftJoin ) continue;\n    pE = pTerm->pExpr;\n    assert( !ExprHasProperty(pE, EP_FromJoin) );\n    assert( (pTerm->prereqRight & pLevel->notReady)!=0 );\n    pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,\n                    WO_EQ|WO_IN|WO_IS, 0);\n    if( pAlt==0 ) continue;\n    if( pAlt->wtFlags & (TERM_CODED) ) continue;\n    testcase( pAlt->eOperator & WO_EQ );\n    testcase( pAlt->eOperator & WO_IS );\n    testcase( pAlt->eOperator & WO_IN );\n    VdbeModuleComment((v, \"begin transitive constraint\"));\n    sEAlt = *pAlt->pExpr;\n    sEAlt.pLeft = pE->pLeft;\n    sqlite3ExprIfFalse(pParse, &sEAlt, addrCont, SQLITE_JUMPIFNULL);\n  }\n\n  /* For a LEFT OUTER JOIN, generate code that will record the fact that\n  ** at least one row of the right table has matched the left table.  \n  */\n  if( pLevel->iLeftJoin ){\n    pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);\n    sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);\n    VdbeComment((v, \"record LEFT JOIN hit\"));\n    sqlite3ExprCacheClear(pParse);\n    for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){\n      testcase( pTerm->wtFlags & TERM_VIRTUAL );\n      testcase( pTerm->wtFlags & TERM_CODED );\n      if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;\n      if( (pTerm->prereqAll & pLevel->notReady)!=0 ){\n        assert( pWInfo->untestedTerms );\n        continue;\n      }\n      assert( pTerm->pExpr );\n      sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);\n      pTerm->wtFlags |= TERM_CODED;\n    }\n  }\n\n  return pLevel->notReady;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/src/whereexpr.c",
    "content": "/*\n** 2015-06-08\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This module contains C code that generates VDBE code used to process\n** the WHERE clause of SQL statements.\n**\n** This file was originally part of where.c but was split out to improve\n** readability and editabiliity.  This file contains utility routines for\n** analyzing Expr objects in the WHERE clause.\n*/\n#include \"sqliteInt.h\"\n#include \"whereInt.h\"\n\n/* Forward declarations */\nstatic void exprAnalyze(SrcList*, WhereClause*, int);\n\n/*\n** Deallocate all memory associated with a WhereOrInfo object.\n*/\nstatic void whereOrInfoDelete(sqlite3 *db, WhereOrInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Deallocate all memory associated with a WhereAndInfo object.\n*/\nstatic void whereAndInfoDelete(sqlite3 *db, WhereAndInfo *p){\n  sqlite3WhereClauseClear(&p->wc);\n  sqlite3DbFree(db, p);\n}\n\n/*\n** Add a single new WhereTerm entry to the WhereClause object pWC.\n** The new WhereTerm object is constructed from Expr p and with wtFlags.\n** The index in pWC->a[] of the new WhereTerm is returned on success.\n** 0 is returned if the new WhereTerm could not be added due to a memory\n** allocation error.  The memory allocation failure will be recorded in\n** the db->mallocFailed flag so that higher-level functions can detect it.\n**\n** This routine will increase the size of the pWC->a[] array as necessary.\n**\n** If the wtFlags argument includes TERM_DYNAMIC, then responsibility\n** for freeing the expression p is assumed by the WhereClause object pWC.\n** This is true even if this routine fails to allocate a new WhereTerm.\n**\n** WARNING:  This routine might reallocate the space used to store\n** WhereTerms.  All pointers to WhereTerms should be invalidated after\n** calling this routine.  Such pointers may be reinitialized by referencing\n** the pWC->a[] array.\n*/\nstatic int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){\n  WhereTerm *pTerm;\n  int idx;\n  testcase( wtFlags & TERM_VIRTUAL );\n  if( pWC->nTerm>=pWC->nSlot ){\n    WhereTerm *pOld = pWC->a;\n    sqlite3 *db = pWC->pWInfo->pParse->db;\n    pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 );\n    if( pWC->a==0 ){\n      if( wtFlags & TERM_DYNAMIC ){\n        sqlite3ExprDelete(db, p);\n      }\n      pWC->a = pOld;\n      return 0;\n    }\n    memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);\n    if( pOld!=pWC->aStatic ){\n      sqlite3DbFree(db, pOld);\n    }\n    pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);\n  }\n  pTerm = &pWC->a[idx = pWC->nTerm++];\n  if( p && ExprHasProperty(p, EP_Unlikely) ){\n    pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;\n  }else{\n    pTerm->truthProb = 1;\n  }\n  pTerm->pExpr = sqlite3ExprSkipCollate(p);\n  pTerm->wtFlags = wtFlags;\n  pTerm->pWC = pWC;\n  pTerm->iParent = -1;\n  memset(&pTerm->eOperator, 0,\n         sizeof(WhereTerm) - offsetof(WhereTerm,eOperator));\n  return idx;\n}\n\n/*\n** Return TRUE if the given operator is one of the operators that is\n** allowed for an indexable WHERE clause term.  The allowed operators are\n** \"=\", \"<\", \">\", \"<=\", \">=\", \"IN\", \"IS\", and \"IS NULL\"\n*/\nstatic int allowedOp(int op){\n  assert( TK_GT>TK_EQ && TK_GT<TK_GE );\n  assert( TK_LT>TK_EQ && TK_LT<TK_GE );\n  assert( TK_LE>TK_EQ && TK_LE<TK_GE );\n  assert( TK_GE==TK_EQ+4 );\n  return op==TK_IN || (op>=TK_EQ && op<=TK_GE) || op==TK_ISNULL || op==TK_IS;\n}\n\n/*\n** Commute a comparison operator.  Expressions of the form \"X op Y\"\n** are converted into \"Y op X\".\n**\n** If left/right precedence rules come into play when determining the\n** collating sequence, then COLLATE operators are adjusted to ensure\n** that the collating sequence does not change.  For example:\n** \"Y collate NOCASE op X\" becomes \"X op Y\" because any collation sequence on\n** the left hand side of a comparison overrides any collation sequence \n** attached to the right. For the same reason the EP_Collate flag\n** is not commuted.\n*/\nstatic void exprCommute(Parse *pParse, Expr *pExpr){\n  u16 expRight = (pExpr->pRight->flags & EP_Collate);\n  u16 expLeft = (pExpr->pLeft->flags & EP_Collate);\n  assert( allowedOp(pExpr->op) && pExpr->op!=TK_IN );\n  if( expRight==expLeft ){\n    /* Either X and Y both have COLLATE operator or neither do */\n    if( expRight ){\n      /* Both X and Y have COLLATE operators.  Make sure X is always\n      ** used by clearing the EP_Collate flag from Y. */\n      pExpr->pRight->flags &= ~EP_Collate;\n    }else if( sqlite3ExprCollSeq(pParse, pExpr->pLeft)!=0 ){\n      /* Neither X nor Y have COLLATE operators, but X has a non-default\n      ** collating sequence.  So add the EP_Collate marker on X to cause\n      ** it to be searched first. */\n      pExpr->pLeft->flags |= EP_Collate;\n    }\n  }\n  SWAP(Expr*,pExpr->pRight,pExpr->pLeft);\n  if( pExpr->op>=TK_GT ){\n    assert( TK_LT==TK_GT+2 );\n    assert( TK_GE==TK_LE+2 );\n    assert( TK_GT>TK_EQ );\n    assert( TK_GT<TK_LE );\n    assert( pExpr->op>=TK_GT && pExpr->op<=TK_GE );\n    pExpr->op = ((pExpr->op-TK_GT)^2)+TK_GT;\n  }\n}\n\n/*\n** Translate from TK_xx operator to WO_xx bitmask.\n*/\nstatic u16 operatorMask(int op){\n  u16 c;\n  assert( allowedOp(op) );\n  if( op==TK_IN ){\n    c = WO_IN;\n  }else if( op==TK_ISNULL ){\n    c = WO_ISNULL;\n  }else if( op==TK_IS ){\n    c = WO_IS;\n  }else{\n    assert( (WO_EQ<<(op-TK_EQ)) < 0x7fff );\n    c = (u16)(WO_EQ<<(op-TK_EQ));\n  }\n  assert( op!=TK_ISNULL || c==WO_ISNULL );\n  assert( op!=TK_IN || c==WO_IN );\n  assert( op!=TK_EQ || c==WO_EQ );\n  assert( op!=TK_LT || c==WO_LT );\n  assert( op!=TK_LE || c==WO_LE );\n  assert( op!=TK_GT || c==WO_GT );\n  assert( op!=TK_GE || c==WO_GE );\n  assert( op!=TK_IS || c==WO_IS );\n  return c;\n}\n\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n/*\n** Check to see if the given expression is a LIKE or GLOB operator that\n** can be optimized using inequality constraints.  Return TRUE if it is\n** so and false if not.\n**\n** In order for the operator to be optimizible, the RHS must be a string\n** literal that does not begin with a wildcard.  The LHS must be a column\n** that may only be NULL, a string, or a BLOB, never a number. (This means\n** that virtual tables cannot participate in the LIKE optimization.)  The\n** collating sequence for the column on the LHS must be appropriate for\n** the operator.\n*/\nstatic int isLikeOrGlob(\n  Parse *pParse,    /* Parsing and code generating context */\n  Expr *pExpr,      /* Test this expression */\n  Expr **ppPrefix,  /* Pointer to TK_STRING expression with pattern prefix */\n  int *pisComplete, /* True if the only wildcard is % in the last character */\n  int *pnoCase      /* True if uppercase is equivalent to lowercase */\n){\n  const u8 *z = 0;         /* String on RHS of LIKE operator */\n  Expr *pRight, *pLeft;      /* Right and left size of LIKE operator */\n  ExprList *pList;           /* List of operands to the LIKE operator */\n  int c;                     /* One character in z[] */\n  int cnt;                   /* Number of non-wildcard prefix characters */\n  char wc[4];                /* Wildcard characters */\n  sqlite3 *db = pParse->db;  /* Database connection */\n  sqlite3_value *pVal = 0;\n  int op;                    /* Opcode of pRight */\n  int rc;                    /* Result code to return */\n\n  if( !sqlite3IsLikeFunction(db, pExpr, pnoCase, wc) ){\n    return 0;\n  }\n#ifdef SQLITE_EBCDIC\n  if( *pnoCase ) return 0;\n#endif\n  pList = pExpr->x.pList;\n  pLeft = pList->a[1].pExpr;\n\n  pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);\n  op = pRight->op;\n  if( op==TK_VARIABLE && (db->flags & SQLITE_EnableQPSG)==0 ){\n    Vdbe *pReprepare = pParse->pReprepare;\n    int iCol = pRight->iColumn;\n    pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_BLOB);\n    if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){\n      z = sqlite3_value_text(pVal);\n    }\n    sqlite3VdbeSetVarmask(pParse->pVdbe, iCol);\n    assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );\n  }else if( op==TK_STRING ){\n    z = (u8*)pRight->u.zToken;\n  }\n  if( z ){\n\n    /* If the RHS begins with a digit or a minus sign, then the LHS must\n    ** be an ordinary column (not a virtual table column) with TEXT affinity.\n    ** Otherwise the LHS might be numeric and \"lhs >= rhs\" would be false\n    ** even though \"lhs LIKE rhs\" is true.  But if the RHS does not start\n    ** with a digit or '-', then \"lhs LIKE rhs\" will always be false if\n    ** the LHS is numeric and so the optimization still works.\n    */\n    if( sqlite3Isdigit(z[0]) || z[0]=='-' ){\n      if( pLeft->op!=TK_COLUMN \n       || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT \n       || IsVirtual(pLeft->pTab)  /* Value might be numeric */\n      ){\n        sqlite3ValueFree(pVal);\n        return 0;\n      }\n    }\n\n    /* Count the number of prefix characters prior to the first wildcard */\n    cnt = 0;\n    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){\n      cnt++;\n      if( c==wc[3] && z[cnt]!=0 ) cnt++;\n    }\n\n    /* The optimization is possible only if (1) the pattern does not begin\n    ** with a wildcard and if (2) the non-wildcard prefix does not end with\n    ** an (illegal 0xff) character.  The second condition is necessary so\n    ** that we can increment the prefix key to find an upper bound for the\n    ** range search. \n    */\n    if( cnt!=0 && 255!=(u8)z[cnt-1] ){\n      Expr *pPrefix;\n\n      /* A \"complete\" match if the pattern ends with \"*\" or \"%\" */\n      *pisComplete = c==wc[0] && z[cnt+1]==0;\n\n      /* Get the pattern prefix.  Remove all escapes from the prefix. */\n      pPrefix = sqlite3Expr(db, TK_STRING, (char*)z);\n      if( pPrefix ){\n        int iFrom, iTo;\n        char *zNew = pPrefix->u.zToken;\n        zNew[cnt] = 0;\n        for(iFrom=iTo=0; iFrom<cnt; iFrom++){\n          if( zNew[iFrom]==wc[3] ) iFrom++;\n          zNew[iTo++] = zNew[iFrom];\n        }\n        zNew[iTo] = 0;\n      }\n      *ppPrefix = pPrefix;\n\n      /* If the RHS pattern is a bound parameter, make arrangements to\n      ** reprepare the statement when that parameter is rebound */\n      if( op==TK_VARIABLE ){\n        Vdbe *v = pParse->pVdbe;\n        sqlite3VdbeSetVarmask(v, pRight->iColumn);\n        if( *pisComplete && pRight->u.zToken[1] ){\n          /* If the rhs of the LIKE expression is a variable, and the current\n          ** value of the variable means there is no need to invoke the LIKE\n          ** function, then no OP_Variable will be added to the program.\n          ** This causes problems for the sqlite3_bind_parameter_name()\n          ** API. To work around them, add a dummy OP_Variable here.\n          */ \n          int r1 = sqlite3GetTempReg(pParse);\n          sqlite3ExprCodeTarget(pParse, pRight, r1);\n          sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);\n          sqlite3ReleaseTempReg(pParse, r1);\n        }\n      }\n    }else{\n      z = 0;\n    }\n  }\n\n  rc = (z!=0);\n  sqlite3ValueFree(pVal);\n  return rc;\n}\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n/*\n** Check to see if the pExpr expression is a form that needs to be passed\n** to the xBestIndex method of virtual tables.  Forms of interest include:\n**\n**          Expression                   Virtual Table Operator\n**          -----------------------      ---------------------------------\n**      1.  column MATCH expr            SQLITE_INDEX_CONSTRAINT_MATCH\n**      2.  column GLOB expr             SQLITE_INDEX_CONSTRAINT_GLOB\n**      3.  column LIKE expr             SQLITE_INDEX_CONSTRAINT_LIKE\n**      4.  column REGEXP expr           SQLITE_INDEX_CONSTRAINT_REGEXP\n**      5.  column != expr               SQLITE_INDEX_CONSTRAINT_NE\n**      6.  expr != column               SQLITE_INDEX_CONSTRAINT_NE\n**      7.  column IS NOT expr           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      8.  expr IS NOT column           SQLITE_INDEX_CONSTRAINT_ISNOT\n**      9.  column IS NOT NULL           SQLITE_INDEX_CONSTRAINT_ISNOTNULL\n**\n** In every case, \"column\" must be a column of a virtual table.  If there\n** is a match, set *ppLeft to the \"column\" expression, set *ppRight to the \n** \"expr\" expression (even though in forms (6) and (8) the column is on the\n** right and the expression is on the left).  Also set *peOp2 to the\n** appropriate virtual table operator.  The return value is 1 or 2 if there\n** is a match.  The usual return is 1, but if the RHS is also a column\n** of virtual table in forms (5) or (7) then return 2.\n**\n** If the expression matches none of the patterns above, return 0.\n*/\nstatic int isAuxiliaryVtabOperator(\n  Expr *pExpr,                    /* Test this expression */\n  unsigned char *peOp2,           /* OUT: 0 for MATCH, or else an op2 value */\n  Expr **ppLeft,                  /* Column expression to left of MATCH/op2 */\n  Expr **ppRight                  /* Expression to left of MATCH/op2 */\n){\n  if( pExpr->op==TK_FUNCTION ){\n    static const struct Op2 {\n      const char *zOp;\n      unsigned char eOp2;\n    } aOp[] = {\n      { \"match\",  SQLITE_INDEX_CONSTRAINT_MATCH },\n      { \"glob\",   SQLITE_INDEX_CONSTRAINT_GLOB },\n      { \"like\",   SQLITE_INDEX_CONSTRAINT_LIKE },\n      { \"regexp\", SQLITE_INDEX_CONSTRAINT_REGEXP }\n    };\n    ExprList *pList;\n    Expr *pCol;                     /* Column reference */\n    int i;\n\n    pList = pExpr->x.pList;\n    if( pList==0 || pList->nExpr!=2 ){\n      return 0;\n    }\n    pCol = pList->a[1].pExpr;\n    if( pCol->op!=TK_COLUMN || !IsVirtual(pCol->pTab) ){\n      return 0;\n    }\n    for(i=0; i<ArraySize(aOp); i++){\n      if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){\n        *peOp2 = aOp[i].eOp2;\n        *ppRight = pList->a[0].pExpr;\n        *ppLeft = pCol;\n        return 1;\n      }\n    }\n  }else if( pExpr->op==TK_NE || pExpr->op==TK_ISNOT || pExpr->op==TK_NOTNULL ){\n    int res = 0;\n    Expr *pLeft = pExpr->pLeft;\n    Expr *pRight = pExpr->pRight;\n    if( pLeft->op==TK_COLUMN && IsVirtual(pLeft->pTab) ){\n      res++;\n    }\n    if( pRight && pRight->op==TK_COLUMN && IsVirtual(pRight->pTab) ){\n      res++;\n      SWAP(Expr*, pLeft, pRight);\n    }\n    *ppLeft = pLeft;\n    *ppRight = pRight;\n    if( pExpr->op==TK_NE ) *peOp2 = SQLITE_INDEX_CONSTRAINT_NE;\n    if( pExpr->op==TK_ISNOT ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOT;\n    if( pExpr->op==TK_NOTNULL ) *peOp2 = SQLITE_INDEX_CONSTRAINT_ISNOTNULL;\n    return res;\n  }\n  return 0;\n}\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n/*\n** If the pBase expression originated in the ON or USING clause of\n** a join, then transfer the appropriate markings over to derived.\n*/\nstatic void transferJoinMarkings(Expr *pDerived, Expr *pBase){\n  if( pDerived ){\n    pDerived->flags |= pBase->flags & EP_FromJoin;\n    pDerived->iRightJoinTable = pBase->iRightJoinTable;\n  }\n}\n\n/*\n** Mark term iChild as being a child of term iParent\n*/\nstatic void markTermAsChild(WhereClause *pWC, int iChild, int iParent){\n  pWC->a[iChild].iParent = iParent;\n  pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;\n  pWC->a[iParent].nChild++;\n}\n\n/*\n** Return the N-th AND-connected subterm of pTerm.  Or if pTerm is not\n** a conjunction, then return just pTerm when N==0.  If N is exceeds\n** the number of available subterms, return NULL.\n*/\nstatic WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){\n  if( pTerm->eOperator!=WO_AND ){\n    return N==0 ? pTerm : 0;\n  }\n  if( N<pTerm->u.pAndInfo->wc.nTerm ){\n    return &pTerm->u.pAndInfo->wc.a[N];\n  }\n  return 0;\n}\n\n/*\n** Subterms pOne and pTwo are contained within WHERE clause pWC.  The\n** two subterms are in disjunction - they are OR-ed together.\n**\n** If these two terms are both of the form:  \"A op B\" with the same\n** A and B values but different operators and if the operators are\n** compatible (if one is = and the other is <, for example) then\n** add a new virtual AND term to pWC that is the combination of the\n** two.\n**\n** Some examples:\n**\n**    x<y OR x=y    -->     x<=y\n**    x=y OR x=y    -->     x=y\n**    x<=y OR x<y   -->     x<=y\n**\n** The following is NOT generated:\n**\n**    x<y OR x>y    -->     x!=y     \n*/\nstatic void whereCombineDisjuncts(\n  SrcList *pSrc,         /* the FROM clause */\n  WhereClause *pWC,      /* The complete WHERE clause */\n  WhereTerm *pOne,       /* First disjunct */\n  WhereTerm *pTwo        /* Second disjunct */\n){\n  u16 eOp = pOne->eOperator | pTwo->eOperator;\n  sqlite3 *db;           /* Database connection (for malloc) */\n  Expr *pNew;            /* New virtual expression */\n  int op;                /* Operator for the combined expression */\n  int idxNew;            /* Index in pWC of the next virtual term */\n\n  if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;\n  if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp\n   && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;\n  assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );\n  assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );\n  if( sqlite3ExprCompare(0,pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;\n  if( sqlite3ExprCompare(0,pOne->pExpr->pRight, pTwo->pExpr->pRight,-1) )return;\n  /* If we reach this point, it means the two subterms can be combined */\n  if( (eOp & (eOp-1))!=0 ){\n    if( eOp & (WO_LT|WO_LE) ){\n      eOp = WO_LE;\n    }else{\n      assert( eOp & (WO_GT|WO_GE) );\n      eOp = WO_GE;\n    }\n  }\n  db = pWC->pWInfo->pParse->db;\n  pNew = sqlite3ExprDup(db, pOne->pExpr, 0);\n  if( pNew==0 ) return;\n  for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }\n  pNew->op = op;\n  idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n  exprAnalyze(pSrc, pWC, idxNew);\n}\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n/*\n** Analyze a term that consists of two or more OR-connected\n** subterms.  So in:\n**\n**     ... WHERE  (a=5) AND (b=7 OR c=9 OR d=13) AND (d=13)\n**                          ^^^^^^^^^^^^^^^^^^^^\n**\n** This routine analyzes terms such as the middle term in the above example.\n** A WhereOrTerm object is computed and attached to the term under\n** analysis, regardless of the outcome of the analysis.  Hence:\n**\n**     WhereTerm.wtFlags   |=  TERM_ORINFO\n**     WhereTerm.u.pOrInfo  =  a dynamically allocated WhereOrTerm object\n**\n** The term being analyzed must have two or more of OR-connected subterms.\n** A single subterm might be a set of AND-connected sub-subterms.\n** Examples of terms under analysis:\n**\n**     (A)     t1.x=t2.y OR t1.x=t2.z OR t1.y=15 OR t1.z=t3.a+5\n**     (B)     x=expr1 OR expr2=x OR x=expr3\n**     (C)     t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)\n**     (D)     x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')\n**     (E)     (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)\n**     (F)     x>A OR (x=A AND y>=B)\n**\n** CASE 1:\n**\n** If all subterms are of the form T.C=expr for some single column of C and\n** a single table T (as shown in example B above) then create a new virtual\n** term that is an equivalent IN expression.  In other words, if the term\n** being analyzed is:\n**\n**      x = expr1  OR  expr2 = x  OR  x = expr3\n**\n** then create a new virtual term like this:\n**\n**      x IN (expr1,expr2,expr3)\n**\n** CASE 2:\n**\n** If there are exactly two disjuncts and one side has x>A and the other side\n** has x=A (for the same x and A) then add a new virtual conjunct term to the\n** WHERE clause of the form \"x>=A\".  Example:\n**\n**      x>A OR (x=A AND y>B)    adds:    x>=A\n**\n** The added conjunct can sometimes be helpful in query planning.\n**\n** CASE 3:\n**\n** If all subterms are indexable by a single table T, then set\n**\n**     WhereTerm.eOperator              =  WO_OR\n**     WhereTerm.u.pOrInfo->indexable  |=  the cursor number for table T\n**\n** A subterm is \"indexable\" if it is of the form\n** \"T.C <op> <expr>\" where C is any column of table T and \n** <op> is one of \"=\", \"<\", \"<=\", \">\", \">=\", \"IS NULL\", or \"IN\".\n** A subterm is also indexable if it is an AND of two or more\n** subsubterms at least one of which is indexable.  Indexable AND \n** subterms have their eOperator set to WO_AND and they have\n** u.pAndInfo set to a dynamically allocated WhereAndTerm object.\n**\n** From another point of view, \"indexable\" means that the subterm could\n** potentially be used with an index if an appropriate index exists.\n** This analysis does not consider whether or not the index exists; that\n** is decided elsewhere.  This analysis only looks at whether subterms\n** appropriate for indexing exist.\n**\n** All examples A through E above satisfy case 3.  But if a term\n** also satisfies case 1 (such as B) we know that the optimizer will\n** always prefer case 1, so in that case we pretend that case 3 is not\n** satisfied.\n**\n** It might be the case that multiple tables are indexable.  For example,\n** (E) above is indexable on tables P, Q, and R.\n**\n** Terms that satisfy case 3 are candidates for lookup by using\n** separate indices to find rowids for each subterm and composing\n** the union of all rowids using a RowSet object.  This is similar\n** to \"bitmap indices\" in other database engines.\n**\n** OTHERWISE:\n**\n** If none of cases 1, 2, or 3 apply, then leave the eOperator set to\n** zero.  This term is not useful for search.\n*/\nstatic void exprAnalyzeOrTerm(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the complete WHERE clause */\n  int idxTerm               /* Index of the OR-term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo;        /* WHERE clause processing context */\n  Parse *pParse = pWInfo->pParse;         /* Parser context */\n  sqlite3 *db = pParse->db;               /* Database connection */\n  WhereTerm *pTerm = &pWC->a[idxTerm];    /* The term to be analyzed */\n  Expr *pExpr = pTerm->pExpr;             /* The expression of the term */\n  int i;                                  /* Loop counters */\n  WhereClause *pOrWc;       /* Breakup of pTerm into subterms */\n  WhereTerm *pOrTerm;       /* A Sub-term within the pOrWc */\n  WhereOrInfo *pOrInfo;     /* Additional information associated with pTerm */\n  Bitmask chngToIN;         /* Tables that might satisfy case 1 */\n  Bitmask indexable;        /* Tables that are indexable, satisfying case 2 */\n\n  /*\n  ** Break the OR clause into its separate subterms.  The subterms are\n  ** stored in a WhereClause structure containing within the WhereOrInfo\n  ** object that is attached to the original OR clause term.\n  */\n  assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );\n  assert( pExpr->op==TK_OR );\n  pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));\n  if( pOrInfo==0 ) return;\n  pTerm->wtFlags |= TERM_ORINFO;\n  pOrWc = &pOrInfo->wc;\n  memset(pOrWc->aStatic, 0, sizeof(pOrWc->aStatic));\n  sqlite3WhereClauseInit(pOrWc, pWInfo);\n  sqlite3WhereSplit(pOrWc, pExpr, TK_OR);\n  sqlite3WhereExprAnalyze(pSrc, pOrWc);\n  if( db->mallocFailed ) return;\n  assert( pOrWc->nTerm>=2 );\n\n  /*\n  ** Compute the set of tables that might satisfy cases 1 or 3.\n  */\n  indexable = ~(Bitmask)0;\n  chngToIN = ~(Bitmask)0;\n  for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0 && indexable; i--, pOrTerm++){\n    if( (pOrTerm->eOperator & WO_SINGLE)==0 ){\n      WhereAndInfo *pAndInfo;\n      assert( (pOrTerm->wtFlags & (TERM_ANDINFO|TERM_ORINFO))==0 );\n      chngToIN = 0;\n      pAndInfo = sqlite3DbMallocRawNN(db, sizeof(*pAndInfo));\n      if( pAndInfo ){\n        WhereClause *pAndWC;\n        WhereTerm *pAndTerm;\n        int j;\n        Bitmask b = 0;\n        pOrTerm->u.pAndInfo = pAndInfo;\n        pOrTerm->wtFlags |= TERM_ANDINFO;\n        pOrTerm->eOperator = WO_AND;\n        pAndWC = &pAndInfo->wc;\n        memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));\n        sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);\n        sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);\n        sqlite3WhereExprAnalyze(pSrc, pAndWC);\n        pAndWC->pOuter = pWC;\n        if( !db->mallocFailed ){\n          for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){\n            assert( pAndTerm->pExpr );\n            if( allowedOp(pAndTerm->pExpr->op) \n             || pAndTerm->eOperator==WO_AUX\n            ){\n              b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor);\n            }\n          }\n        }\n        indexable &= b;\n      }\n    }else if( pOrTerm->wtFlags & TERM_COPIED ){\n      /* Skip this term for now.  We revisit it when we process the\n      ** corresponding TERM_VIRTUAL term */\n    }else{\n      Bitmask b;\n      b = sqlite3WhereGetMask(&pWInfo->sMaskSet, pOrTerm->leftCursor);\n      if( pOrTerm->wtFlags & TERM_VIRTUAL ){\n        WhereTerm *pOther = &pOrWc->a[pOrTerm->iParent];\n        b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pOther->leftCursor);\n      }\n      indexable &= b;\n      if( (pOrTerm->eOperator & WO_EQ)==0 ){\n        chngToIN = 0;\n      }else{\n        chngToIN &= b;\n      }\n    }\n  }\n\n  /*\n  ** Record the set of tables that satisfy case 3.  The set might be\n  ** empty.\n  */\n  pOrInfo->indexable = indexable;\n  pTerm->eOperator = indexable==0 ? 0 : WO_OR;\n\n  /* For a two-way OR, attempt to implementation case 2.\n  */\n  if( indexable && pOrWc->nTerm==2 ){\n    int iOne = 0;\n    WhereTerm *pOne;\n    while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){\n      int iTwo = 0;\n      WhereTerm *pTwo;\n      while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){\n        whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);\n      }\n    }\n  }\n\n  /*\n  ** chngToIN holds a set of tables that *might* satisfy case 1.  But\n  ** we have to do some additional checking to see if case 1 really\n  ** is satisfied.\n  **\n  ** chngToIN will hold either 0, 1, or 2 bits.  The 0-bit case means\n  ** that there is no possibility of transforming the OR clause into an\n  ** IN operator because one or more terms in the OR clause contain\n  ** something other than == on a column in the single table.  The 1-bit\n  ** case means that every term of the OR clause is of the form\n  ** \"table.column=expr\" for some single table.  The one bit that is set\n  ** will correspond to the common table.  We still need to check to make\n  ** sure the same column is used on all terms.  The 2-bit case is when\n  ** the all terms are of the form \"table1.column=table2.column\".  It\n  ** might be possible to form an IN operator with either table1.column\n  ** or table2.column as the LHS if either is common to every term of\n  ** the OR clause.\n  **\n  ** Note that terms of the form \"table.column1=table.column2\" (the\n  ** same table on both sizes of the ==) cannot be optimized.\n  */\n  if( chngToIN ){\n    int okToChngToIN = 0;     /* True if the conversion to IN is valid */\n    int iColumn = -1;         /* Column index on lhs of IN operator */\n    int iCursor = -1;         /* Table cursor common to all terms */\n    int j = 0;                /* Loop counter */\n\n    /* Search for a table and column that appears on one side or the\n    ** other of the == operator in every subterm.  That table and column\n    ** will be recorded in iCursor and iColumn.  There might not be any\n    ** such table and column.  Set okToChngToIN if an appropriate table\n    ** and column is found but leave okToChngToIN false if not found.\n    */\n    for(j=0; j<2 && !okToChngToIN; j++){\n      pOrTerm = pOrWc->a;\n      for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        pOrTerm->wtFlags &= ~TERM_OR_OK;\n        if( pOrTerm->leftCursor==iCursor ){\n          /* This is the 2-bit case and we are on the second iteration and\n          ** current term is from the first iteration.  So skip this term. */\n          assert( j==1 );\n          continue;\n        }\n        if( (chngToIN & sqlite3WhereGetMask(&pWInfo->sMaskSet,\n                                            pOrTerm->leftCursor))==0 ){\n          /* This term must be of the form t1.a==t2.b where t2 is in the\n          ** chngToIN set but t1 is not.  This term will be either preceded\n          ** or follwed by an inverted copy (t2.b==t1.a).  Skip this term \n          ** and use its inversion. */\n          testcase( pOrTerm->wtFlags & TERM_COPIED );\n          testcase( pOrTerm->wtFlags & TERM_VIRTUAL );\n          assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );\n          continue;\n        }\n        iColumn = pOrTerm->u.leftColumn;\n        iCursor = pOrTerm->leftCursor;\n        break;\n      }\n      if( i<0 ){\n        /* No candidate table+column was found.  This can only occur\n        ** on the second iteration */\n        assert( j==1 );\n        assert( IsPowerOfTwo(chngToIN) );\n        assert( chngToIN==sqlite3WhereGetMask(&pWInfo->sMaskSet, iCursor) );\n        break;\n      }\n      testcase( j==1 );\n\n      /* We have found a candidate table and column.  Check to see if that\n      ** table and column is common to every term in the OR clause */\n      okToChngToIN = 1;\n      for(; i>=0 && okToChngToIN; i--, pOrTerm++){\n        assert( pOrTerm->eOperator & WO_EQ );\n        if( pOrTerm->leftCursor!=iCursor ){\n          pOrTerm->wtFlags &= ~TERM_OR_OK;\n        }else if( pOrTerm->u.leftColumn!=iColumn ){\n          okToChngToIN = 0;\n        }else{\n          int affLeft, affRight;\n          /* If the right-hand side is also a column, then the affinities\n          ** of both right and left sides must be such that no type\n          ** conversions are required on the right.  (Ticket #2249)\n          */\n          affRight = sqlite3ExprAffinity(pOrTerm->pExpr->pRight);\n          affLeft = sqlite3ExprAffinity(pOrTerm->pExpr->pLeft);\n          if( affRight!=0 && affRight!=affLeft ){\n            okToChngToIN = 0;\n          }else{\n            pOrTerm->wtFlags |= TERM_OR_OK;\n          }\n        }\n      }\n    }\n\n    /* At this point, okToChngToIN is true if original pTerm satisfies\n    ** case 1.  In that case, construct a new virtual term that is \n    ** pTerm converted into an IN operator.\n    */\n    if( okToChngToIN ){\n      Expr *pDup;            /* A transient duplicate expression */\n      ExprList *pList = 0;   /* The RHS of the IN operator */\n      Expr *pLeft = 0;       /* The LHS of the IN operator */\n      Expr *pNew;            /* The complete IN operator */\n\n      for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){\n        if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;\n        assert( pOrTerm->eOperator & WO_EQ );\n        assert( pOrTerm->leftCursor==iCursor );\n        assert( pOrTerm->u.leftColumn==iColumn );\n        pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);\n        pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);\n        pLeft = pOrTerm->pExpr->pLeft;\n      }\n      assert( pLeft!=0 );\n      pDup = sqlite3ExprDup(db, pLeft, 0);\n      pNew = sqlite3PExpr(pParse, TK_IN, pDup, 0);\n      if( pNew ){\n        int idxNew;\n        transferJoinMarkings(pNew, pExpr);\n        assert( !ExprHasProperty(pNew, EP_xIsSelect) );\n        pNew->x.pList = pList;\n        idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        exprAnalyze(pSrc, pWC, idxNew);\n        pTerm = &pWC->a[idxTerm];\n        markTermAsChild(pWC, idxNew, idxTerm);\n      }else{\n        sqlite3ExprListDelete(db, pList);\n      }\n      pTerm->eOperator = WO_NOOP;  /* case 1 trumps case 3 */\n    }\n  }\n}\n#endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */\n\n/*\n** We already know that pExpr is a binary operator where both operands are\n** column references.  This routine checks to see if pExpr is an equivalence\n** relation:\n**   1.  The SQLITE_Transitive optimization must be enabled\n**   2.  Must be either an == or an IS operator\n**   3.  Not originating in the ON clause of an OUTER JOIN\n**   4.  The affinities of A and B must be compatible\n**   5a. Both operands use the same collating sequence OR\n**   5b. The overall collating sequence is BINARY\n** If this routine returns TRUE, that means that the RHS can be substituted\n** for the LHS anyplace else in the WHERE clause where the LHS column occurs.\n** This is an optimization.  No harm comes from returning 0.  But if 1 is\n** returned when it should not be, then incorrect answers might result.\n*/\nstatic int termIsEquivalence(Parse *pParse, Expr *pExpr){\n  char aff1, aff2;\n  CollSeq *pColl;\n  if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0;\n  if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ) return 0;\n  aff1 = sqlite3ExprAffinity(pExpr->pLeft);\n  aff2 = sqlite3ExprAffinity(pExpr->pRight);\n  if( aff1!=aff2\n   && (!sqlite3IsNumericAffinity(aff1) || !sqlite3IsNumericAffinity(aff2))\n  ){\n    return 0;\n  }\n  pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight);\n  if( pColl==0 || sqlite3StrICmp(pColl->zName, \"BINARY\")==0 ) return 1;\n  return sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight);\n}\n\n/*\n** Recursively walk the expressions of a SELECT statement and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nstatic Bitmask exprSelectUsage(WhereMaskSet *pMaskSet, Select *pS){\n  Bitmask mask = 0;\n  while( pS ){\n    SrcList *pSrc = pS->pSrc;\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pEList);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pGroupBy);\n    mask |= sqlite3WhereExprListUsage(pMaskSet, pS->pOrderBy);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pWhere);\n    mask |= sqlite3WhereExprUsage(pMaskSet, pS->pHaving);\n    if( ALWAYS(pSrc!=0) ){\n      int i;\n      for(i=0; i<pSrc->nSrc; i++){\n        mask |= exprSelectUsage(pMaskSet, pSrc->a[i].pSelect);\n        mask |= sqlite3WhereExprUsage(pMaskSet, pSrc->a[i].pOn);\n      }\n    }\n    pS = pS->pPrior;\n  }\n  return mask;\n}\n\n/*\n** Expression pExpr is one operand of a comparison operator that might\n** be useful for indexing.  This routine checks to see if pExpr appears\n** in any index.  Return TRUE (1) if pExpr is an indexed term and return\n** FALSE (0) if not.  If TRUE is returned, also set aiCurCol[0] to the cursor\n** number of the table that is indexed and aiCurCol[1] to the column number\n** of the column that is indexed, or XN_EXPR (-2) if an expression is being\n** indexed.\n**\n** If pExpr is a TK_COLUMN column reference, then this routine always returns\n** true even if that particular column is not indexed, because the column\n** might be added to an automatic index later.\n*/\nstatic SQLITE_NOINLINE int exprMightBeIndexed2(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor and column here */\n  Expr *pExpr            /* An operand of a comparison operator */\n){\n  Index *pIdx;\n  int i;\n  int iCur;\n  for(i=0; mPrereq>1; i++, mPrereq>>=1){}\n  iCur = pFrom->a[i].iCursor;\n  for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){\n    if( pIdx->aColExpr==0 ) continue;\n    for(i=0; i<pIdx->nKeyCol; i++){\n      if( pIdx->aiColumn[i]!=XN_EXPR ) continue;\n      if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){\n        aiCurCol[0] = iCur;\n        aiCurCol[1] = XN_EXPR;\n        return 1;\n      }\n    }\n  }\n  return 0;\n}\nstatic int exprMightBeIndexed(\n  SrcList *pFrom,        /* The FROM clause */\n  Bitmask mPrereq,       /* Bitmask of FROM clause terms referenced by pExpr */\n  int *aiCurCol,         /* Write the referenced table cursor & column here */\n  Expr *pExpr,           /* An operand of a comparison operator */\n  int op                 /* The specific comparison operator */\n){\n  /* If this expression is a vector to the left or right of a \n  ** inequality constraint (>, <, >= or <=), perform the processing \n  ** on the first element of the vector.  */\n  assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE );\n  assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE );\n  assert( op<=TK_GE );\n  if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){\n    pExpr = pExpr->x.pList->a[0].pExpr;\n  }\n\n  if( pExpr->op==TK_COLUMN ){\n    aiCurCol[0] = pExpr->iTable;\n    aiCurCol[1] = pExpr->iColumn;\n    return 1;\n  }\n  if( mPrereq==0 ) return 0;                 /* No table references */\n  if( (mPrereq&(mPrereq-1))!=0 ) return 0;   /* Refs more than one table */\n  return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr);\n}\n\n/*\n** The input to this routine is an WhereTerm structure with only the\n** \"pExpr\" field filled in.  The job of this routine is to analyze the\n** subexpression and populate all the other fields of the WhereTerm\n** structure.\n**\n** If the expression is of the form \"<expr> <op> X\" it gets commuted\n** to the standard form of \"X <op> <expr>\".\n**\n** If the expression is of the form \"X <op> Y\" where both X and Y are\n** columns, then the original expression is unchanged and a new virtual\n** term of the form \"Y <op> X\" is added to the WHERE clause and\n** analyzed separately.  The original term is marked with TERM_COPIED\n** and the new term is marked with TERM_DYNAMIC (because it's pExpr\n** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it\n** is a commuted copy of a prior term.)  The original term has nChild=1\n** and the copy has idxParent set to the index of the original term.\n*/\nstatic void exprAnalyze(\n  SrcList *pSrc,            /* the FROM clause */\n  WhereClause *pWC,         /* the WHERE clause */\n  int idxTerm               /* Index of the term to be analyzed */\n){\n  WhereInfo *pWInfo = pWC->pWInfo; /* WHERE clause processing context */\n  WhereTerm *pTerm;                /* The term to be analyzed */\n  WhereMaskSet *pMaskSet;          /* Set of table index masks */\n  Expr *pExpr;                     /* The expression to be analyzed */\n  Bitmask prereqLeft;              /* Prerequesites of the pExpr->pLeft */\n  Bitmask prereqAll;               /* Prerequesites of pExpr */\n  Bitmask extraRight = 0;          /* Extra dependencies on LEFT JOIN */\n  Expr *pStr1 = 0;                 /* RHS of LIKE/GLOB operator */\n  int isComplete = 0;              /* RHS of LIKE/GLOB ends with wildcard */\n  int noCase = 0;                  /* uppercase equivalent to lowercase */\n  int op;                          /* Top-level operator.  pExpr->op */\n  Parse *pParse = pWInfo->pParse;  /* Parsing context */\n  sqlite3 *db = pParse->db;        /* Database connection */\n  unsigned char eOp2;              /* op2 value for LIKE/REGEXP/GLOB */\n  int nLeft;                       /* Number of elements on left side vector */\n\n  if( db->mallocFailed ){\n    return;\n  }\n  pTerm = &pWC->a[idxTerm];\n  pMaskSet = &pWInfo->sMaskSet;\n  pExpr = pTerm->pExpr;\n  assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );\n  prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);\n  op = pExpr->op;\n  if( op==TK_IN ){\n    assert( pExpr->pRight==0 );\n    if( sqlite3ExprCheckIN(pParse, pExpr) ) return;\n    if( ExprHasProperty(pExpr, EP_xIsSelect) ){\n      pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect);\n    }else{\n      pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);\n    }\n  }else if( op==TK_ISNULL ){\n    pTerm->prereqRight = 0;\n  }else{\n    pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);\n  }\n  pMaskSet->bVarSelect = 0;\n  prereqAll = sqlite3WhereExprUsage(pMaskSet, pExpr);\n  if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;\n  if( ExprHasProperty(pExpr, EP_FromJoin) ){\n    Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);\n    prereqAll |= x;\n    extraRight = x-1;  /* ON clause terms may not be used with an index\n                       ** on left table of a LEFT JOIN.  Ticket #3015 */\n    if( (prereqAll>>1)>=x ){\n      sqlite3ErrorMsg(pParse, \"ON clause references tables to its right\");\n      return;\n    }\n  }\n  pTerm->prereqAll = prereqAll;\n  pTerm->leftCursor = -1;\n  pTerm->iParent = -1;\n  pTerm->eOperator = 0;\n  if( allowedOp(op) ){\n    int aiCurCol[2];\n    Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);\n    Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);\n    u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;\n\n    if( pTerm->iField>0 ){\n      assert( op==TK_IN );\n      assert( pLeft->op==TK_VECTOR );\n      pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;\n    }\n\n    if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){\n      pTerm->leftCursor = aiCurCol[0];\n      pTerm->u.leftColumn = aiCurCol[1];\n      pTerm->eOperator = operatorMask(op) & opMask;\n    }\n    if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;\n    if( pRight \n     && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)\n    ){\n      WhereTerm *pNew;\n      Expr *pDup;\n      u16 eExtraOp = 0;        /* Extra bits for pNew->eOperator */\n      assert( pTerm->iField==0 );\n      if( pTerm->leftCursor>=0 ){\n        int idxNew;\n        pDup = sqlite3ExprDup(db, pExpr, 0);\n        if( db->mallocFailed ){\n          sqlite3ExprDelete(db, pDup);\n          return;\n        }\n        idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);\n        if( idxNew==0 ) return;\n        pNew = &pWC->a[idxNew];\n        markTermAsChild(pWC, idxNew, idxTerm);\n        if( op==TK_IS ) pNew->wtFlags |= TERM_IS;\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n\n        if( termIsEquivalence(pParse, pDup) ){\n          pTerm->eOperator |= WO_EQUIV;\n          eExtraOp = WO_EQUIV;\n        }\n      }else{\n        pDup = pExpr;\n        pNew = pTerm;\n      }\n      exprCommute(pParse, pDup);\n      pNew->leftCursor = aiCurCol[0];\n      pNew->u.leftColumn = aiCurCol[1];\n      testcase( (prereqLeft | extraRight) != prereqLeft );\n      pNew->prereqRight = prereqLeft | extraRight;\n      pNew->prereqAll = prereqAll;\n      pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;\n    }\n  }\n\n#ifndef SQLITE_OMIT_BETWEEN_OPTIMIZATION\n  /* If a term is the BETWEEN operator, create two new virtual terms\n  ** that define the range that the BETWEEN implements.  For example:\n  **\n  **      a BETWEEN b AND c\n  **\n  ** is converted into:\n  **\n  **      (a BETWEEN b AND c) AND (a>=b) AND (a<=c)\n  **\n  ** The two new terms are added onto the end of the WhereClause object.\n  ** The new terms are \"dynamic\" and are children of the original BETWEEN\n  ** term.  That means that if the BETWEEN term is coded, the children are\n  ** skipped.  Or, if the children are satisfied by an index, the original\n  ** BETWEEN term is skipped.\n  */\n  else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){\n    ExprList *pList = pExpr->x.pList;\n    int i;\n    static const u8 ops[] = {TK_GE, TK_LE};\n    assert( pList!=0 );\n    assert( pList->nExpr==2 );\n    for(i=0; i<2; i++){\n      Expr *pNewExpr;\n      int idxNew;\n      pNewExpr = sqlite3PExpr(pParse, ops[i], \n                             sqlite3ExprDup(db, pExpr->pLeft, 0),\n                             sqlite3ExprDup(db, pList->a[i].pExpr, 0));\n      transferJoinMarkings(pNewExpr, pExpr);\n      idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n      testcase( idxNew==0 );\n      exprAnalyze(pSrc, pWC, idxNew);\n      pTerm = &pWC->a[idxTerm];\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */\n\n#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)\n  /* Analyze a term that is composed of two or more subterms connected by\n  ** an OR operator.\n  */\n  else if( pExpr->op==TK_OR ){\n    assert( pWC->op==TK_AND );\n    exprAnalyzeOrTerm(pSrc, pWC, idxTerm);\n    pTerm = &pWC->a[idxTerm];\n  }\n#endif /* SQLITE_OMIT_OR_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_LIKE_OPTIMIZATION\n  /* Add constraints to reduce the search space on a LIKE or GLOB\n  ** operator.\n  **\n  ** A like pattern of the form \"x LIKE 'aBc%'\" is changed into constraints\n  **\n  **          x>='ABC' AND x<'abd' AND x LIKE 'aBc%'\n  **\n  ** The last character of the prefix \"abc\" is incremented to form the\n  ** termination condition \"abd\".  If case is not significant (the default\n  ** for LIKE) then the lower-bound is made all uppercase and the upper-\n  ** bound is made all lowercase so that the bounds also work when comparing\n  ** BLOBs.\n  */\n  if( pWC->op==TK_AND \n   && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)\n  ){\n    Expr *pLeft;       /* LHS of LIKE/GLOB operator */\n    Expr *pStr2;       /* Copy of pStr1 - RHS of LIKE/GLOB operator */\n    Expr *pNewExpr1;\n    Expr *pNewExpr2;\n    int idxNew1;\n    int idxNew2;\n    const char *zCollSeqName;     /* Name of collating sequence */\n    const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;\n\n    pLeft = pExpr->x.pList->a[1].pExpr;\n    pStr2 = sqlite3ExprDup(db, pStr1, 0);\n\n    /* Convert the lower bound to upper-case and the upper bound to\n    ** lower-case (upper-case is less than lower-case in ASCII) so that\n    ** the range constraints also work for BLOBs\n    */\n    if( noCase && !pParse->db->mallocFailed ){\n      int i;\n      char c;\n      pTerm->wtFlags |= TERM_LIKE;\n      for(i=0; (c = pStr1->u.zToken[i])!=0; i++){\n        pStr1->u.zToken[i] = sqlite3Toupper(c);\n        pStr2->u.zToken[i] = sqlite3Tolower(c);\n      }\n    }\n\n    if( !db->mallocFailed ){\n      u8 c, *pC;       /* Last character before the first wildcard */\n      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];\n      c = *pC;\n      if( noCase ){\n        /* The point is to increment the last character before the first\n        ** wildcard.  But if we increment '@', that will push it into the\n        ** alphabetic range where case conversions will mess up the \n        ** inequality.  To avoid this, make sure to also run the full\n        ** LIKE on all candidate expressions by clearing the isComplete flag\n        */\n        if( c=='A'-1 ) isComplete = 0;\n        c = sqlite3UpperToLower[c];\n      }\n      *pC = c + 1;\n    }\n    zCollSeqName = noCase ? \"NOCASE\" : \"BINARY\";\n    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr1 = sqlite3PExpr(pParse, TK_GE,\n           sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),\n           pStr1);\n    transferJoinMarkings(pNewExpr1, pExpr);\n    idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);\n    testcase( idxNew1==0 );\n    exprAnalyze(pSrc, pWC, idxNew1);\n    pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);\n    pNewExpr2 = sqlite3PExpr(pParse, TK_LT,\n           sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),\n           pStr2);\n    transferJoinMarkings(pNewExpr2, pExpr);\n    idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);\n    testcase( idxNew2==0 );\n    exprAnalyze(pSrc, pWC, idxNew2);\n    pTerm = &pWC->a[idxTerm];\n    if( isComplete ){\n      markTermAsChild(pWC, idxNew1, idxTerm);\n      markTermAsChild(pWC, idxNew2, idxTerm);\n    }\n  }\n#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */\n\n#ifndef SQLITE_OMIT_VIRTUALTABLE\n  /* Add a WO_AUX auxiliary term to the constraint set if the\n  ** current expression is of the form \"column OP expr\" where OP\n  ** is an operator that gets passed into virtual tables but which is\n  ** not normally optimized for ordinary tables.  In other words, OP\n  ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL.\n  ** This information is used by the xBestIndex methods of\n  ** virtual tables.  The native query optimizer does not attempt\n  ** to do anything with MATCH functions.\n  */\n  if( pWC->op==TK_AND ){\n    Expr *pRight, *pLeft;\n    int res = isAuxiliaryVtabOperator(pExpr, &eOp2, &pLeft, &pRight);\n    while( res-- > 0 ){\n      int idxNew;\n      WhereTerm *pNewTerm;\n      Bitmask prereqColumn, prereqExpr;\n\n      prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight);\n      prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft);\n      if( (prereqExpr & prereqColumn)==0 ){\n        Expr *pNewExpr;\n        pNewExpr = sqlite3PExpr(pParse, TK_MATCH, \n            0, sqlite3ExprDup(db, pRight, 0));\n        if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){\n          ExprSetProperty(pNewExpr, EP_FromJoin);\n        }\n        idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);\n        testcase( idxNew==0 );\n        pNewTerm = &pWC->a[idxNew];\n        pNewTerm->prereqRight = prereqExpr;\n        pNewTerm->leftCursor = pLeft->iTable;\n        pNewTerm->u.leftColumn = pLeft->iColumn;\n        pNewTerm->eOperator = WO_AUX;\n        pNewTerm->eMatchOp = eOp2;\n        markTermAsChild(pWC, idxNew, idxTerm);\n        pTerm = &pWC->a[idxTerm];\n        pTerm->wtFlags |= TERM_COPIED;\n        pNewTerm->prereqAll = pTerm->prereqAll;\n      }\n      SWAP(Expr*, pLeft, pRight);\n    }\n  }\n#endif /* SQLITE_OMIT_VIRTUALTABLE */\n\n  /* If there is a vector == or IS term - e.g. \"(a, b) == (?, ?)\" - create\n  ** new terms for each component comparison - \"a = ?\" and \"b = ?\".  The\n  ** new terms completely replace the original vector comparison, which is\n  ** no longer used.\n  **\n  ** This is only required if at least one side of the comparison operation\n  ** is not a sub-select.  */\n  if( pWC->op==TK_AND \n  && (pExpr->op==TK_EQ || pExpr->op==TK_IS)\n  && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1\n  && sqlite3ExprVectorSize(pExpr->pRight)==nLeft\n  && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 \n    || (pExpr->pRight->flags & EP_xIsSelect)==0)\n  ){\n    int i;\n    for(i=0; i<nLeft; i++){\n      int idxNew;\n      Expr *pNew;\n      Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);\n      Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);\n\n      pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);\n      transferJoinMarkings(pNew, pExpr);\n      idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);\n      exprAnalyze(pSrc, pWC, idxNew);\n    }\n    pTerm = &pWC->a[idxTerm];\n    pTerm->wtFlags = TERM_CODED|TERM_VIRTUAL;  /* Disable the original */\n    pTerm->eOperator = 0;\n  }\n\n  /* If there is a vector IN term - e.g. \"(a, b) IN (SELECT ...)\" - create\n  ** a virtual term for each vector component. The expression object\n  ** used by each such virtual term is pExpr (the full vector IN(...) \n  ** expression). The WhereTerm.iField variable identifies the index within\n  ** the vector on the LHS that the virtual term represents.\n  **\n  ** This only works if the RHS is a simple SELECT, not a compound\n  */\n  if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0\n   && pExpr->pLeft->op==TK_VECTOR\n   && pExpr->x.pSelect->pPrior==0\n  ){\n    int i;\n    for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){\n      int idxNew;\n      idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);\n      pWC->a[idxNew].iField = i+1;\n      exprAnalyze(pSrc, pWC, idxNew);\n      markTermAsChild(pWC, idxNew, idxTerm);\n    }\n  }\n\n#ifdef SQLITE_ENABLE_STAT3_OR_STAT4\n  /* When sqlite_stat3 histogram data is available an operator of the\n  ** form \"x IS NOT NULL\" can sometimes be evaluated more efficiently\n  ** as \"x>NULL\" if x is not an INTEGER PRIMARY KEY.  So construct a\n  ** virtual term of that form.\n  **\n  ** Note that the virtual term must be tagged with TERM_VNULL.\n  */\n  if( pExpr->op==TK_NOTNULL\n   && pExpr->pLeft->op==TK_COLUMN\n   && pExpr->pLeft->iColumn>=0\n   && OptimizationEnabled(db, SQLITE_Stat34)\n  ){\n    Expr *pNewExpr;\n    Expr *pLeft = pExpr->pLeft;\n    int idxNew;\n    WhereTerm *pNewTerm;\n\n    pNewExpr = sqlite3PExpr(pParse, TK_GT,\n                            sqlite3ExprDup(db, pLeft, 0),\n                            sqlite3ExprAlloc(db, TK_NULL, 0, 0));\n\n    idxNew = whereClauseInsert(pWC, pNewExpr,\n                              TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);\n    if( idxNew ){\n      pNewTerm = &pWC->a[idxNew];\n      pNewTerm->prereqRight = 0;\n      pNewTerm->leftCursor = pLeft->iTable;\n      pNewTerm->u.leftColumn = pLeft->iColumn;\n      pNewTerm->eOperator = WO_GT;\n      markTermAsChild(pWC, idxNew, idxTerm);\n      pTerm = &pWC->a[idxTerm];\n      pTerm->wtFlags |= TERM_COPIED;\n      pNewTerm->prereqAll = pTerm->prereqAll;\n    }\n  }\n#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */\n\n  /* Prevent ON clause terms of a LEFT JOIN from being used to drive\n  ** an index for tables to the left of the join.\n  */\n  testcase( pTerm!=&pWC->a[idxTerm] );\n  pTerm = &pWC->a[idxTerm];\n  pTerm->prereqRight |= extraRight;\n}\n\n/***************************************************************************\n** Routines with file scope above.  Interface to the rest of the where.c\n** subsystem follows.\n***************************************************************************/\n\n/*\n** This routine identifies subexpressions in the WHERE clause where\n** each subexpression is separated by the AND operator or some other\n** operator specified in the op parameter.  The WhereClause structure\n** is filled with pointers to subexpressions.  For example:\n**\n**    WHERE  a=='hello' AND coalesce(b,11)<10 AND (c+12!=d OR c==22)\n**           \\________/     \\_______________/     \\________________/\n**            slot[0]            slot[1]               slot[2]\n**\n** The original WHERE clause in pExpr is unaltered.  All this routine\n** does is make slot[] entries point to substructure within pExpr.\n**\n** In the previous sentence and in the diagram, \"slot[]\" refers to\n** the WhereClause.a[] array.  The slot[] array grows as needed to contain\n** all terms of the WHERE clause.\n*/\nvoid sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){\n  Expr *pE2 = sqlite3ExprSkipCollate(pExpr);\n  pWC->op = op;\n  if( pE2==0 ) return;\n  if( pE2->op!=op ){\n    whereClauseInsert(pWC, pExpr, 0);\n  }else{\n    sqlite3WhereSplit(pWC, pE2->pLeft, op);\n    sqlite3WhereSplit(pWC, pE2->pRight, op);\n  }\n}\n\n/*\n** Initialize a preallocated WhereClause structure.\n*/\nvoid sqlite3WhereClauseInit(\n  WhereClause *pWC,        /* The WhereClause to be initialized */\n  WhereInfo *pWInfo        /* The WHERE processing context */\n){\n  pWC->pWInfo = pWInfo;\n  pWC->pOuter = 0;\n  pWC->nTerm = 0;\n  pWC->nSlot = ArraySize(pWC->aStatic);\n  pWC->a = pWC->aStatic;\n}\n\n/*\n** Deallocate a WhereClause structure.  The WhereClause structure\n** itself is not freed.  This routine is the inverse of\n** sqlite3WhereClauseInit().\n*/\nvoid sqlite3WhereClauseClear(WhereClause *pWC){\n  int i;\n  WhereTerm *a;\n  sqlite3 *db = pWC->pWInfo->pParse->db;\n  for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){\n    if( a->wtFlags & TERM_DYNAMIC ){\n      sqlite3ExprDelete(db, a->pExpr);\n    }\n    if( a->wtFlags & TERM_ORINFO ){\n      whereOrInfoDelete(db, a->u.pOrInfo);\n    }else if( a->wtFlags & TERM_ANDINFO ){\n      whereAndInfoDelete(db, a->u.pAndInfo);\n    }\n  }\n  if( pWC->a!=pWC->aStatic ){\n    sqlite3DbFree(db, pWC->a);\n  }\n}\n\n\n/*\n** These routines walk (recursively) an expression tree and generate\n** a bitmask indicating which tables are used in that expression\n** tree.\n*/\nBitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){\n  Bitmask mask;\n  if( p==0 ) return 0;\n  if( p->op==TK_COLUMN ){\n    return sqlite3WhereGetMask(pMaskSet, p->iTable);\n  }\n  mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;\n  assert( !ExprHasProperty(p, EP_TokenOnly) );\n  if( p->pLeft ) mask |= sqlite3WhereExprUsage(pMaskSet, p->pLeft);\n  if( p->pRight ){\n    mask |= sqlite3WhereExprUsage(pMaskSet, p->pRight);\n    assert( p->x.pList==0 );\n  }else if( ExprHasProperty(p, EP_xIsSelect) ){\n    if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1;\n    mask |= exprSelectUsage(pMaskSet, p->x.pSelect);\n  }else if( p->x.pList ){\n    mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList);\n  }\n  return mask;\n}\nBitmask sqlite3WhereExprListUsage(WhereMaskSet *pMaskSet, ExprList *pList){\n  int i;\n  Bitmask mask = 0;\n  if( pList ){\n    for(i=0; i<pList->nExpr; i++){\n      mask |= sqlite3WhereExprUsage(pMaskSet, pList->a[i].pExpr);\n    }\n  }\n  return mask;\n}\n\n\n/*\n** Call exprAnalyze on all terms in a WHERE clause.  \n**\n** Note that exprAnalyze() might add new virtual terms onto the\n** end of the WHERE clause.  We do not want to analyze these new\n** virtual terms, so start analyzing at the end and work forward\n** so that the added virtual terms are never processed.\n*/\nvoid sqlite3WhereExprAnalyze(\n  SrcList *pTabList,       /* the FROM clause */\n  WhereClause *pWC         /* the WHERE clause to be analyzed */\n){\n  int i;\n  for(i=pWC->nTerm-1; i>=0; i--){\n    exprAnalyze(pTabList, pWC, i);\n  }\n}\n\n/*\n** For table-valued-functions, transform the function arguments into\n** new WHERE clause terms.  \n**\n** Each function argument translates into an equality constraint against\n** a HIDDEN column in the table.\n*/\nvoid sqlite3WhereTabFuncArgs(\n  Parse *pParse,                    /* Parsing context */\n  struct SrcList_item *pItem,       /* The FROM clause term to process */\n  WhereClause *pWC                  /* Xfer function arguments to here */\n){\n  Table *pTab;\n  int j, k;\n  ExprList *pArgs;\n  Expr *pColRef;\n  Expr *pTerm;\n  if( pItem->fg.isTabFunc==0 ) return;\n  pTab = pItem->pTab;\n  assert( pTab!=0 );\n  pArgs = pItem->u1.pFuncArg;\n  if( pArgs==0 ) return;\n  for(j=k=0; j<pArgs->nExpr; j++){\n    while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){k++;}\n    if( k>=pTab->nCol ){\n      sqlite3ErrorMsg(pParse, \"too many arguments on %s() - max %d\",\n                      pTab->zName, j);\n      return;\n    }\n    pColRef = sqlite3ExprAlloc(pParse->db, TK_COLUMN, 0, 0);\n    if( pColRef==0 ) return;\n    pColRef->iTable = pItem->iCursor;\n    pColRef->iColumn = k++;\n    pColRef->pTab = pTab;\n    pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef,\n                         sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0));\n    whereClauseInsert(pWC, pTerm, TERM_DYNAMIC);\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/8_3_names.test",
    "content": "# 2011 May 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all\n# filename extensions to be limited to 3 characters.  Some embedded\n# systems need this to work around microsoft FAT patents, but this\n# feature should be disabled on most deployments.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !8_3_names {\n  finish_test\n  return\n}\n\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\ndo_test 8_3_names-1.0 {\n  forcedelete test.db test.nal test.db-journal\n  sqlite3 db test.db\n  db eval {\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(20000));\n    BEGIN;\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(randomblob(15000));\n  }\n  file exists test.db-journal\n} 1\ndo_test 8_3_names-1.1 {\n  file exists test.nal\n} 0\ndo_test 8_3_names-1.2 {\n  db eval {\n    ROLLBACK;\n    SELECT length(x) FROM t1\n  }\n} 20000\n\ndb close\ndo_test 8_3_names-2.0 {\n  forcedelete test.db test.nal test.db-journal\n  sqlite3 db file:./test.db?8_3_names=1\n  db eval {\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(20000));\n    BEGIN;\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(randomblob(15000));\n  }\n  file exists test.db-journal\n} 0\ndo_test 8_3_names-2.1 {\n  file exists test.nal\n} 1\nforcedelete test2.db test2.nal test2.db-journal\ncopy_file test.db test2.db\ncopy_file test.nal test2.nal\ndo_test 8_3_names-2.2 {\n  db eval {\n    COMMIT;\n    SELECT length(x) FROM t1\n  }\n} 15000\ndo_test 8_3_names-2.3 {\n  sqlite3 db2 file:./test2.db?8_3_names=1\n  db2 eval {\n    PRAGMA integrity_check;\n    SELECT length(x) FROM t1;\n  }\n} {ok 20000}\n\ndb close\ndo_test 8_3_names-3.0 {\n  forcedelete test.db test.nal test.db-journal\n  sqlite3 db file:./test.db?8_3_names=0\n  db eval {\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(20000));\n    BEGIN;\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(randomblob(15000));\n  }\n  file exists test.db-journal\n} 1\ndo_test 8_3_names-3.1 {\n  file exists test.nal\n} 0\nforcedelete test2.db test2.nal test2.db-journal\ncopy_file test.db test2.db\ncopy_file test.db-journal test2.db-journal\ndo_test 8_3_names-3.2 {\n  db eval {\n    COMMIT;\n    SELECT length(x) FROM t1\n  }\n} 15000\ndo_test 8_3_names-3.3 {\n  sqlite3 db2 file:./test2.db?8_3_names=0\n  db2 eval {\n    PRAGMA integrity_check;\n    SELECT length(x) FROM t1;\n  }\n} {ok 20000}\n\n##########################################################################\n# Master journals.\n#\ndb close\nforcedelete test.db test2.db\ndo_test 8_3_names-4.0 {\n  sqlite3 db file:./test.db?8_3_names=1\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    ATTACH 'file:./test2.db?8_3_names=1' AS db2;\n    CREATE TABLE db2.t2(y);\n    INSERT INTO t2 VALUES(2);\n    BEGIN;\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t2 VALUES(4);\n    COMMIT;\n    SELECT * FROM t1, t2 ORDER BY x, y\n  }\n} {1 2 1 4 3 2 3 4}\n    \n\n##########################################################################\n# WAL mode.\n#\nifcapable !wal {\n  finish_test\n  return\n}\ndb close\nforcedelete test.db\ndo_test 8_3_names-5.0 {\n  sqlite3 db file:./test.db?8_3_names=1\n  load_static_extension db wholenumber\n  db eval {\n    PRAGMA journal_mode=WAL;\n    CREATE TABLE t1(x);\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000;\n    BEGIN;\n    UPDATE t1 SET x=x*2;\n  }\n  sqlite3 db2 file:./test.db?8_3_names=1\n  load_static_extension db2 wholenumber\n  db2 eval {\n    BEGIN;\n    SELECT sum(x) FROM t1;\n  }\n} {500500}\n\ndo_test 8_3_names-5.1 {\n  file exists test.db-wal\n} 0\ndo_test 8_3_names-5.2 {\n  file exists test.wal\n} 1\ndo_test 8_3_names-5.3 {\n  file exists test.db-shm\n} 0\ndo_test 8_3_names-5.4 {\n  file exists test.shm\n} 1\n\n\ndo_test 8_3_names-5.5 {\n  db eval {\n    COMMIT;\n    SELECT sum(x) FROM t1;\n  }\n} {1001000}\ndo_test 8_3_names-5.6 {\n  db2 eval {\n    SELECT sum(x) FROM t1;\n  }\n} {500500}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/affinity2.test",
    "content": "# 2015-06-02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is type affinity in comparison operations.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test affinity2-100 {\n  CREATE TABLE t1(\n    xi INTEGER,\n    xr REAL,\n    xb BLOB,\n    xn NUMERIC,\n    xt TEXT\n  );\n  INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(1,1,1,1,1,1);\n  INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(2,'2','2','2','2','2');\n  INSERT INTO t1(rowid,xi,xr,xb,xn,xt) VALUES(3,'03','03','03','03','03');\n\n} {}\ndo_execsql_test affinity2-110 {\n  SELECT xi, typeof(xi) FROM t1 ORDER BY rowid;\n} {1 integer 2 integer 3 integer}\ndo_execsql_test affinity2-120 {\n  SELECT xr, typeof(xr) FROM t1 ORDER BY rowid;\n} {1.0 real 2.0 real 3.0 real}\ndo_execsql_test affinity2-130 {\n  SELECT xb, typeof(xb) FROM t1 ORDER BY rowid;\n} {1 integer 2 text 03 text}\ndo_execsql_test affinity2-140 {\n  SELECT xn, typeof(xn) FROM t1 ORDER BY rowid;\n} {1 integer 2 integer 3 integer}\ndo_execsql_test affinity2-150 {\n  SELECT xt, typeof(xt) FROM t1 ORDER BY rowid;\n} {1 text 2 text 03 text}\n\ndo_execsql_test affinity2-200 {\n  SELECT rowid, xi==xt, xi==xb, xi==+xt FROM t1 ORDER BY rowid;\n} {1 1 1 1 2 1 1 1 3 1 1 1}\ndo_execsql_test affinity2-210 {\n  SELECT rowid, xr==xt, xr==xb, xr==+xt FROM t1 ORDER BY rowid;\n} {1 1 1 1 2 1 1 1 3 1 1 1}\ndo_execsql_test affinity2-220 {\n  SELECT rowid, xn==xt, xn==xb, xn==+xt FROM t1 ORDER BY rowid;\n} {1 1 1 1 2 1 1 1 3 1 1 1}\n\ndo_execsql_test affinity2-300 {\n  SELECT rowid, xt==+xi, xt==xi, xt==xb FROM t1 ORDER BY rowid;\n} {1 1 1 0 2 1 1 1 3 0 1 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/affinity3.test",
    "content": "# 2017-01-16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases for bugs:\n#\n#    https://www.sqlite.org/src/info/91e2e8ba6ff2e2\n#    https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Ticket https://www.sqlite.org/src/info/91e2e8ba6ff2e2 (2011-09-19)\n# Automatic index causes undesired type conversions\n#\ndo_execsql_test affinity3-100 {\n  CREATE TABLE customer (id INT PRIMARY KEY);\n  CREATE TABLE apr (id INT PRIMARY KEY, apr REAL);\n  \n  CREATE VIEW v1 AS\n  SELECT c.id, i.apr\n  FROM customer c\n  LEFT JOIN apr i ON i.id=c.id;\n  \n  CREATE VIEW v2 AS\n  SELECT c.id, v1.apr\n  FROM customer c\n  LEFT JOIN v1 ON v1.id=c.id;\n  \n  INSERT INTO customer (id) VALUES (1);\n  INSERT INTO apr (id, apr) VALUES (1, 12);\n  INSERT INTO customer (id) VALUES (2);\n  INSERT INTO apr (id, apr) VALUES (2, 12.01);\n}\ndo_execsql_test affinity3-110 {\n  PRAGMA automatic_index=ON;\n  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v1;\n} {1 0.12 real 2 0.1201 real}\ndo_execsql_test affinity3-120 {\n  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v2;\n} {1 0.12 real 2 0.1201 real}\ndo_execsql_test affinity3-130 {\n  PRAGMA automatic_index=OFF;\n  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v1;\n} {1 0.12 real 2 0.1201 real}\ndo_execsql_test affinity3-140 {\n  SELECT id, (apr / 100), typeof(apr) apr_type  FROM v2;\n} {1 0.12 real 2 0.1201 real}\n\n# Ticket https://www.sqlite.org/src/info/7ffd1ca1d2ad4ecf  (2017-01-16)\n# Incorrect affinity when using automatic indexes \n#\ndo_execsql_test affinity3-200 {\n  CREATE TABLE map_integer (id INT, name);\n  INSERT INTO map_integer VALUES(1,'a');\n  CREATE TABLE map_text (id TEXT, name);\n  INSERT INTO map_text VALUES('4','e');\n  CREATE TABLE data (id TEXT, name);\n  INSERT INTO data VALUES(1,'abc');\n  INSERT INTO data VALUES('4','xyz');\n  CREATE VIEW idmap as\n      SELECT * FROM map_integer\n      UNION SELECT * FROM map_text;\n  CREATE TABLE mzed AS SELECT * FROM idmap;\n}\n\ndo_execsql_test affinity3-210 {\n  PRAGMA automatic_index=ON;\n  SELECT * FROM data JOIN idmap USING(id);\n} {1 abc a 4 xyz e}\ndo_execsql_test affinity3-220 {\n  SELECT * FROM data JOIN mzed USING(id);\n} {1 abc a 4 xyz e}\n\ndo_execsql_test affinity3-250 {\n  PRAGMA automatic_index=OFF;\n  SELECT * FROM data JOIN idmap USING(id);\n} {1 abc a 4 xyz e}\ndo_execsql_test affinity3-260 {\n  SELECT * FROM data JOIN mzed USING(id);\n} {1 abc a 4 xyz e}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/aggerror.test",
    "content": "# 2006 January 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for calling sqlite3_result_error()\n# from within an aggregate function implementation.\n#\n# $Id: aggerror.test,v 1.3 2006/05/03 23:34:06 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# Add the x_count aggregate function to the database handle.\n# x_count will error out if its input is 40 or 41 or if its\n# final results is 42.  Make sure that such errors are handled\n# appropriately.\n#\ndo_test aggerror-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  sqlite3_create_aggregate $DB\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT a+2 FROM t1;\n    INSERT INTO t1 SELECT a+4 FROM t1;\n    INSERT INTO t1 SELECT a+8 FROM t1;\n    INSERT INTO t1 SELECT a+16 FROM t1;\n    INSERT INTO t1 SELECT a+32 FROM t1 ORDER BY a LIMIT 7;\n    SELECT x_count(*) FROM t1;\n  }\n} {39}\ndo_test aggerror-1.2 {\n  execsql {\n    INSERT INTO t1 VALUES(40);\n    SELECT x_count(*) FROM t1;\n  }\n} {40}\ndo_test aggerror-1.3 {\n  catchsql {\n    SELECT x_count(a) FROM t1;\n  }\n} {1 {value of 40 handed to x_count}}\nifcapable utf16 {\n  do_test aggerror-1.4 {\n    execsql {\n      UPDATE t1 SET a=41 WHERE a=40\n    }\n    catchsql {\n      SELECT x_count(a) FROM t1;\n    }\n  } {1 abc}\n}\ndo_test aggerror-1.5 {\n  execsql {\n    SELECT x_count(*) FROM t1\n  }\n} 40\ndo_test aggerror-1.6 {\n  execsql {\n    INSERT INTO t1 VALUES(40);\n    INSERT INTO t1 VALUES(42);\n  }\n  catchsql {\n    SELECT x_count(*) FROM t1;\n  }\n} {1 {x_count totals to 42}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/aggnested.test",
    "content": "# 2012 August 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for processing aggregate queries with \n# subqueries in which the subqueries hold the aggregate functions\n# or in which the subqueries are themselves aggregate queries\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test aggnested-1.1 {\n  db eval {\n    CREATE TABLE t1(a1 INTEGER);\n    INSERT INTO t1 VALUES(1), (2), (3);\n    CREATE TABLE t2(b1 INTEGER);\n    INSERT INTO t2 VALUES(4), (5);\n    SELECT (SELECT group_concat(a1,'x') FROM t2) FROM t1;\n  }\n} {1x2x3}\ndo_test aggnested-1.2 {\n  db eval {\n    SELECT\n     (SELECT group_concat(a1,'x') || '-' || group_concat(b1,'y') FROM t2)\n    FROM t1;\n  }\n} {1x2x3-4y5}\ndo_test aggnested-1.3 {\n  db eval {\n    SELECT (SELECT group_concat(b1,a1) FROM t2) FROM t1;\n  }\n} {415 425 435}\ndo_test aggnested-1.4 {\n  db eval {\n    SELECT (SELECT group_concat(a1,b1) FROM t2) FROM t1;\n  }\n} {151 252 353}\n\n\n# This test case is a copy of the one in\n# http://www.mail-archive.com/sqlite-users@sqlite.org/msg70787.html\n#\ndo_test aggnested-2.0 {\n  sqlite3 db2 :memory:\n  db2 eval {\n    CREATE TABLE t1 (A1 INTEGER NOT NULL,A2 INTEGER NOT NULL,A3 INTEGER NOT \n    NULL,A4 INTEGER NOT NULL,PRIMARY KEY(A1));\n    REPLACE INTO t1 VALUES(1,11,111,1111);\n    REPLACE INTO t1 VALUES(2,22,222,2222);\n    REPLACE INTO t1 VALUES(3,33,333,3333);\n    CREATE TABLE t2 (B1 INTEGER NOT NULL,B2 INTEGER NOT NULL,B3 INTEGER NOT \n    NULL,B4 INTEGER NOT NULL,PRIMARY KEY(B1));\n    REPLACE INTO t2 VALUES(1,88,888,8888);\n    REPLACE INTO t2 VALUES(2,99,999,9999);\n    SELECT (SELECT GROUP_CONCAT(CASE WHEN a1=1 THEN'A' ELSE 'B' END) FROM t2),\n            t1.* \n    FROM t1;\n  }\n} {A,B,B 3 33 333 3333}\ndb2 close\n\n##################### Test cases for ticket [bfbf38e5e9956ac69f] ############\n#\n# This first test case is the original problem report:\ndo_test aggnested-3.0 {\n  db eval {\n    CREATE TABLE AAA (\n      aaa_id       INTEGER PRIMARY KEY AUTOINCREMENT\n    );\n    CREATE TABLE RRR (\n      rrr_id      INTEGER     PRIMARY KEY AUTOINCREMENT,\n      rrr_date    INTEGER     NOT NULL,\n      rrr_aaa     INTEGER\n    );\n    CREATE TABLE TTT (\n      ttt_id      INTEGER PRIMARY KEY AUTOINCREMENT,\n      target_aaa  INTEGER NOT NULL,\n      source_aaa  INTEGER NOT NULL\n    );\n    insert into AAA (aaa_id) values (2);\n    insert into TTT (ttt_id, target_aaa, source_aaa)\n    values (4469, 2, 2);\n    insert into TTT (ttt_id, target_aaa, source_aaa)\n    values (4476, 2, 1);\n    insert into RRR (rrr_id, rrr_date, rrr_aaa)\n    values (0, 0, NULL);\n    insert into RRR (rrr_id, rrr_date, rrr_aaa)\n    values (2, 4312, 2);\n    SELECT i.aaa_id,\n      (SELECT sum(CASE WHEN (t.source_aaa == i.aaa_id) THEN 1 ELSE 0 END)\n         FROM TTT t\n      ) AS segfault\n    FROM\n     (SELECT curr.rrr_aaa as aaa_id\n        FROM RRR curr\n          -- you also can comment out the next line\n          -- it causes segfault to happen after one row is outputted\n          INNER JOIN AAA a ON (curr.rrr_aaa = aaa_id)\n          LEFT JOIN RRR r ON (r.rrr_id <> 0 AND r.rrr_date < curr.rrr_date)\n       GROUP BY curr.rrr_id\n      HAVING r.rrr_date IS NULL\n    ) i;\n  }\n} {2 1}\n\n# Further variants of the test case, as found in the ticket\n#\ndo_test aggnested-3.1 {\n  db eval {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1 (\n      id1 INTEGER PRIMARY KEY AUTOINCREMENT,\n      value1 INTEGER\n    );\n    INSERT INTO t1 VALUES(4469,2),(4476,1);\n    CREATE TABLE t2 (\n      id2 INTEGER PRIMARY KEY AUTOINCREMENT,\n      value2 INTEGER\n    );\n    INSERT INTO t2 VALUES(0,1),(2,2);\n    SELECT\n     (SELECT sum(value2==xyz) FROM t2)\n    FROM\n     (SELECT curr.value1 as xyz\n        FROM t1 AS curr LEFT JOIN t1 AS other\n       GROUP BY curr.id1);\n  }\n} {1 1}\ndo_test aggnested-3.2 {\n  db eval {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1 (\n      id1 INTEGER,\n      value1 INTEGER,\n      x1 INTEGER\n    );\n    INSERT INTO t1 VALUES(4469,2,98),(4469,1,99),(4469,3,97);\n    CREATE TABLE t2 (\n      value2 INTEGER\n    );\n    INSERT INTO t2 VALUES(1);\n    SELECT\n     (SELECT sum(value2==xyz) FROM t2)\n    FROM\n     (SELECT value1 as xyz, max(x1) AS pqr\n        FROM t1\n       GROUP BY id1);\n    SELECT\n     (SELECT sum(value2<>xyz) FROM t2)\n    FROM\n     (SELECT value1 as xyz, max(x1) AS pqr\n        FROM t1\n       GROUP BY id1);\n  }\n} {1 0}\ndo_test aggnested-3.3 {\n  db eval {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(id1, value1);\n    INSERT INTO t1 VALUES(4469,2),(4469,1);\n    CREATE TABLE t2 (value2);\n    INSERT INTO t2 VALUES(1);\n    SELECT (SELECT sum(value2=value1) FROM t2), max(value1)\n      FROM t1\n     GROUP BY id1;\n  }\n} {0 2}\n\n# A batch of queries all doing approximately the same operation involving\n# two nested aggregate queries.\n#\ndo_test aggnested-3.11 {\n  db eval {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(id1, value1);\n    INSERT INTO t1 VALUES(4469,12),(4469,11),(4470,34);\n    CREATE INDEX t1id1 ON t1(id1);\n    CREATE TABLE t2 (value2);\n    INSERT INTO t2 VALUES(12),(34),(34);\n    INSERT INTO t2 SELECT value2 FROM t2;\n\n    SELECT max(value1), (SELECT count(*) FROM t2 WHERE value2=max(value1))\n      FROM t1\n     GROUP BY id1;\n  }\n} {12 2 34 4}\ndo_test aggnested-3.12 {\n  db eval {\n    SELECT max(value1), (SELECT count(*) FROM t2 WHERE value2=value1)\n      FROM t1\n     GROUP BY id1;\n  }\n} {12 2 34 4}\ndo_test aggnested-3.13 {\n  db eval {\n    SELECT value1, (SELECT sum(value2=value1) FROM t2)\n      FROM t1;\n  }\n} {12 2 11 0 34 4}\ndo_test aggnested-3.14 {\n  db eval {\n    SELECT value1, (SELECT sum(value2=value1) FROM t2)\n      FROM t1\n     WHERE value1 IN (SELECT max(value1) FROM t1 GROUP BY id1);\n  }\n} {12 2 34 4}\ndo_test aggnested-3.15 {\n  # FIXME:  If case 3.16 works, then this case really ought to work too...\n  catchsql {\n    SELECT max(value1), (SELECT sum(value2=max(value1)) FROM t2)\n      FROM t1\n     GROUP BY id1;\n  }\n} {1 {misuse of aggregate function max()}}\ndo_test aggnested-3.16 {\n  db eval {\n    SELECT max(value1), (SELECT sum(value2=value1) FROM t2)\n      FROM t1\n     GROUP BY id1;\n  }\n} {12 2 34 4}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/alias.test",
    "content": "# 2008 August 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is correct code generation of aliased result-set\n# values.  See ticket #3343.\n#\n# $Id: alias.test,v 1.3 2009/04/23 13:22:44 drh Exp $\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Aliases are currently evaluated twice.  We might try to change this\n# in the future.  But not now.\nreturn\n\n# A procedure to return a sequence of increasing integers.\n#\nnamespace eval ::seq {\n  variable counter 0\n  proc value {args} {\n    variable counter\n    incr counter\n    return $counter\n  }\n  proc reset {} {\n    variable counter\n    set counter 0\n  }\n}\n\n\ndo_test alias-1.1 {\n  db function sequence ::seq::value\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(9);\n    INSERT INTO t1 VALUES(8);\n    INSERT INTO t1 VALUES(7);\n    SELECT x, sequence() FROM t1;\n  }\n} {9 1 8 2 7 3}\ndo_test alias-1.2 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 WHERE y>0\n  }\n} {9 1 8 2 7 3}\ndo_test alias-1.3 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99\n  }\n} {9 1 8 2 7 3}\ndo_test alias-1.4 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99 AND y!=55\n  }\n} {9 1 8 2 7 3}\ndo_test alias-1.5 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1\n     WHERE y>0 AND y<99 AND y!=55 AND y NOT IN (56,57,58)\n       AND y NOT LIKE 'abc%' AND y%10==2\n  }\n} {8 2}\ndo_test alias-1.6 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99\n  }\n} {9 1 8 2 7 3}\n#do_test alias-1.7 {\n#  ::seq::reset\n#  db eval {\n#    SELECT x, sequence() AS y FROM t1 WHERE y IN (55,66,3)\n#  }\n#} {7 3}\ndo_test alias-1.8 {\n  ::seq::reset\n  db eval {\n    SELECT x, 1-sequence() AS y FROM t1 ORDER BY y\n  }\n} {7 -2 8 -1 9 0}\ndo_test alias-1.9 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 ORDER BY -y\n  }\n} {7 3 8 2 9 1}\ndo_test alias-1.10 {\n  ::seq::reset\n  db eval {\n    SELECT x, sequence() AS y FROM t1 ORDER BY x%2, y\n  }\n} {8 2 9 1 7 3}\n\nunset -nocomplain random_int_list\nset random_int_list [db eval {\n   SELECT random()&2147483647 AS r FROM t1, t1, t1, t1 ORDER BY r\n}]\ndo_test alias-1.11 {\n  lsort -integer $::random_int_list\n} $random_int_list\n\n\ndo_test alias-2.1 {\n  db eval {\n    SELECT 4 UNION SELECT 1 ORDER BY 1\n  }\n} {1 4}\ndo_test alias-2.2 {\n  db eval {\n    SELECT 4 UNION SELECT 1 UNION SELECT 9 ORDER BY 1\n  }\n} {1 4 9}\n\nif 0 {\n  # Aliases in the GROUP BY clause cause the expression to be evaluated\n  # twice in the current implementation.  This might change in the future.\n  #\n  do_test alias-3.1 {\n    ::seq::reset\n    db eval {\n      SELECT sequence(*) AS y, count(*) AS z FROM t1 GROUP BY y ORDER BY z, y\n    }\n  } {1 1 2 1 3 1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/all.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nrun_test_suite full\n\nrun_test_suite no_optimization \nrun_test_suite memsubsys1 \nrun_test_suite memsubsys2 \nrun_test_suite singlethread \nrun_test_suite multithread \nrun_test_suite onefile \nrun_test_suite utf16 \nrun_test_suite exclusive\nrun_test_suite persistent_journal \nrun_test_suite persistent_journal_error \nrun_test_suite no_journal \nrun_test_suite no_journal_error\nrun_test_suite autovacuum_ioerr \nrun_test_suite no_mutex_try \nrun_test_suite fullmutex \nrun_test_suite journaltest \nrun_test_suite inmemory_journal\nrun_test_suite pcache0 \nrun_test_suite pcache10 \nrun_test_suite pcache50 \nrun_test_suite pcache90 \nrun_test_suite pcache100\nrun_test_suite prepare\nrun_test_suite mmap\n\nif {$::tcl_platform(platform)==\"unix\"} {\n  ifcapable !default_autovacuum {\n    run_test_suite autovacuum_crash\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/alter.test",
    "content": "# 2004 November 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ALTER TABLE statement.\n#\n# $Id: alter.test,v 1.32 2009/03/24 15:08:10 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.\nifcapable !altertable {\n  finish_test\n  return\n}\n\n#----------------------------------------------------------------------\n# Test organization:\n#\n# alter-1.1.* - alter-1.7.*: Basic tests of ALTER TABLE, including tables\n#     with implicit and explicit indices. These tests came from an earlier\n#     fork of SQLite that also supported ALTER TABLE.\n# alter-1.8.*: Tests for ALTER TABLE when the table resides in an \n#     attached database.\n# alter-1.9.*: Tests for ALTER TABLE when their is whitespace between the\n#     table name and left parenthesis token. i.e: \n#     \"CREATE TABLE abc       (a, b, c);\"\n# alter-2.*: Test error conditions and messages.\n# alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them.\n# alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields.\n# ...\n# alter-12.*: Test ALTER TABLE on views.\n#\n\n# Create some tables to rename.  Be sure to include some TEMP tables\n# and some tables with odd names.\n#\ndo_test alter-1.1 {\n  ifcapable tempdb {\n    set ::temp TEMP\n  } else {\n    set ::temp {}\n  }\n  execsql [subst -nocommands {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    CREATE TABLE [t1'x1](c UNIQUE, b PRIMARY KEY);\n    INSERT INTO [t1'x1] VALUES(3,4);\n    CREATE INDEX t1i1 ON T1(B);\n    CREATE INDEX t1i2 ON t1(a,b);\n    CREATE INDEX i3 ON [t1'x1](b,c);\n    CREATE $::temp TABLE \"temp table\"(e,f,g UNIQUE);\n    CREATE INDEX i2 ON [temp table](f);\n    INSERT INTO [temp table] VALUES(5,6,7);\n  }]\n  execsql {\n    SELECT 't1', * FROM t1;\n    SELECT 't1''x1', * FROM \"t1'x1\";\n    SELECT * FROM [temp table];\n  }\n} {t1 1 2 t1'x1 3 4 5 6 7}\ndo_test alter-1.2 {\n  execsql [subst {\n    CREATE $::temp TABLE objlist(type, name, tbl_name);\n    INSERT INTO objlist SELECT type, name, tbl_name \n        FROM sqlite_master WHERE NAME!='objlist';\n  }]\n  ifcapable tempdb {\n    execsql {\n      INSERT INTO objlist SELECT type, name, tbl_name \n          FROM temp.sqlite_master WHERE NAME!='objlist';\n    }\n  }\n\n  execsql {\n    SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;\n  }\n} [list \\\n     table t1                              t1             \\\n     index t1i1                            t1             \\\n     index t1i2                            t1             \\\n     table t1'x1                           t1'x1          \\\n     index i3                              t1'x1          \\\n     index {sqlite_autoindex_t1'x1_1}      t1'x1          \\\n     index {sqlite_autoindex_t1'x1_2}      t1'x1          \\\n     table {temp table}                    {temp table}   \\\n     index i2                              {temp table}   \\\n     index {sqlite_autoindex_temp table_1} {temp table}   \\\n  ]\n\n# Make some changes\n#\nintegrity_check alter-1.3.0\ndo_test alter-1.3 {\n  execsql {\n    ALTER TABLE [T1] RENAME to [-t1-];\n    ALTER TABLE \"t1'x1\" RENAME TO T2;\n    ALTER TABLE [temp table] RENAME to TempTab;\n  }\n} {}\nintegrity_check alter-1.3.1\ndo_test alter-1.4 {\n  execsql {\n    SELECT 't1', * FROM [-t1-];\n    SELECT 't2', * FROM t2;\n    SELECT * FROM temptab;\n  }\n} {t1 1 2 t2 3 4 5 6 7}\ndo_test alter-1.5 {\n  execsql {\n    DELETE FROM objlist;\n    INSERT INTO objlist SELECT type, name, tbl_name\n        FROM sqlite_master WHERE NAME!='objlist';\n  }\n  catchsql {\n    INSERT INTO objlist SELECT type, name, tbl_name \n        FROM sqlite_temp_master WHERE NAME!='objlist';\n  }\n  execsql {\n    SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;\n  }\n} [list \\\n     table -t1-                         -t1-        \\\n     index t1i1                         -t1-        \\\n     index t1i2                         -t1-        \\\n     table T2                           T2          \\\n     index i3                           T2          \\\n     index {sqlite_autoindex_T2_1}      T2          \\\n     index {sqlite_autoindex_T2_2}      T2          \\\n     table {TempTab}                    {TempTab}   \\\n     index i2                           {TempTab}   \\\n     index {sqlite_autoindex_TempTab_1} {TempTab}   \\\n  ]\n\n# Make sure the changes persist after restarting the database.\n# (The TEMP table will not persist, of course.)\n#\nifcapable tempdb {\n  do_test alter-1.6 {\n    db close\n    sqlite3 db test.db\n    set DB [sqlite3_connection_pointer db]\n    execsql {\n      CREATE TEMP TABLE objlist(type, name, tbl_name);\n      INSERT INTO objlist SELECT type, name, tbl_name FROM sqlite_master;\n      INSERT INTO objlist \n          SELECT type, name, tbl_name FROM temp.sqlite_master \n          WHERE NAME!='objlist';\n      SELECT type, name, tbl_name FROM objlist \n          ORDER BY tbl_name, type desc, name;\n    }\n  } [list \\\n       table -t1-                         -t1-           \\\n       index t1i1                         -t1-           \\\n       index t1i2                         -t1-           \\\n       table T2                           T2          \\\n       index i3                           T2          \\\n       index {sqlite_autoindex_T2_1}      T2          \\\n       index {sqlite_autoindex_T2_2}      T2          \\\n    ]\n} else {\n  execsql {\n    DROP TABLE TempTab;\n  }\n}\n\n# Create bogus application-defined functions for functions used \n# internally by ALTER TABLE, to ensure that ALTER TABLE falls back\n# to the built-in functions.\n#\nproc failing_app_func {args} {error \"bad function\"}\ndo_test alter-1.7-prep {\n  db func substr failing_app_func\n  db func like failing_app_func\n  db func sqlite_rename_table failing_app_func\n  db func sqlite_rename_trigger failing_app_func\n  db func sqlite_rename_parent failing_app_func\n  catchsql {SELECT substr(name,1,3) FROM sqlite_master}\n} {1 {bad function}}\n\n# Make sure the ALTER TABLE statements work with the\n# non-callback API\n#\ndo_test alter-1.7 {\n  stepsql $DB {\n    ALTER TABLE [-t1-] RENAME to [*t1*];\n    ALTER TABLE T2 RENAME TO [<t2>];\n  }\n  execsql {\n    DELETE FROM objlist;\n    INSERT INTO objlist SELECT type, name, tbl_name\n        FROM sqlite_master WHERE NAME!='objlist';\n  }\n  catchsql {\n    INSERT INTO objlist SELECT type, name, tbl_name \n        FROM sqlite_temp_master WHERE NAME!='objlist';\n  }\n  execsql {\n    SELECT type, name, tbl_name FROM objlist ORDER BY tbl_name, type desc, name;\n  }\n} [list \\\n     table *t1*                         *t1*           \\\n     index t1i1                         *t1*           \\\n     index t1i2                         *t1*           \\\n     table <t2>                         <t2>          \\\n     index i3                           <t2>          \\\n     index {sqlite_autoindex_<t2>_1}    <t2>          \\\n     index {sqlite_autoindex_<t2>_2}    <t2>          \\\n  ]\n\n# Check that ALTER TABLE works on attached databases.\n#\nifcapable attach {\n  do_test alter-1.8.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' AS aux;\n    }\n  } {}\n  do_test alter-1.8.2 {\n    execsql {\n      CREATE TABLE t4(a PRIMARY KEY, b, c);\n      CREATE TABLE aux.t4(a PRIMARY KEY, b, c);\n      CREATE INDEX i4 ON t4(b);\n      CREATE INDEX aux.i4 ON t4(b);\n    }\n  } {}\n  do_test alter-1.8.3 {\n    execsql {\n      INSERT INTO t4 VALUES('main', 'main', 'main');\n      INSERT INTO aux.t4 VALUES('aux', 'aux', 'aux');\n      SELECT * FROM t4 WHERE a = 'main';\n    }\n  } {main main main}\n  do_test alter-1.8.4 {\n    execsql {\n      ALTER TABLE t4 RENAME TO t5;\n      SELECT * FROM t4 WHERE a = 'aux';\n    }\n  } {aux aux aux}\n  do_test alter-1.8.5 {\n    execsql {\n      SELECT * FROM t5;\n    }\n  } {main main main}\n  do_test alter-1.8.6 {\n    execsql {\n      SELECT * FROM t5 WHERE b = 'main';\n    }\n  } {main main main}\n  do_test alter-1.8.7 {\n    execsql {\n      ALTER TABLE aux.t4 RENAME TO t5;\n      SELECT * FROM aux.t5 WHERE b = 'aux';\n    }\n  } {aux aux aux}\n}\n\ndo_test alter-1.9.1 {\n  execsql {\n    CREATE TABLE tbl1   (a, b, c);\n    INSERT INTO tbl1 VALUES(1, 2, 3);\n  }\n} {}\ndo_test alter-1.9.2 {\n  execsql {\n    SELECT * FROM tbl1;\n  }\n} {1 2 3}\ndo_test alter-1.9.3 {\n  execsql {\n    ALTER TABLE tbl1 RENAME TO tbl2;\n    SELECT * FROM tbl2;\n  }\n} {1 2 3}\ndo_test alter-1.9.4 {\n  execsql {\n    DROP TABLE tbl2;\n  }\n} {}\n\n# Test error messages\n#\ndo_test alter-2.1 {\n  catchsql {\n    ALTER TABLE none RENAME TO hi;\n  }\n} {1 {no such table: none}}\ndo_test alter-2.2 {\n  execsql {\n    CREATE TABLE t3(p,q,r);\n  }\n  catchsql {\n    ALTER TABLE [<t2>] RENAME TO t3;\n  }\n} {1 {there is already another table or index with this name: t3}}\ndo_test alter-2.3 {\n  catchsql {\n    ALTER TABLE [<t2>] RENAME TO i3;\n  }\n} {1 {there is already another table or index with this name: i3}}\ndo_test alter-2.4 {\n  catchsql {\n    ALTER TABLE SqLiTe_master RENAME TO master;\n  }\n} {1 {table sqlite_master may not be altered}}\ndo_test alter-2.5 {\n  catchsql {\n    ALTER TABLE t3 RENAME TO sqlite_t3;\n  }\n} {1 {object name reserved for internal use: sqlite_t3}}\ndo_test alter-2.6 {\n  catchsql {\n    ALTER TABLE t3 ADD COLUMN (ALTER TABLE t3 ADD COLUMN);\n  }\n} {1 {near \"(\": syntax error}}\n\n# If this compilation does not include triggers, omit the alter-3.* tests.\nifcapable trigger {\n\n#-----------------------------------------------------------------------\n# Tests alter-3.* test ALTER TABLE on tables that have triggers.\n#\n# alter-3.1.*: ALTER TABLE with triggers.\n# alter-3.2.*: Test that the ON keyword cannot be used as a database,\n#     table or column name unquoted. This is done because part of the\n#     ALTER TABLE code (specifically the implementation of SQL function\n#     \"sqlite_alter_trigger\") will break in this case.\n# alter-3.3.*: ALTER TABLE with TEMP triggers (todo).\n#\n\n# An SQL user-function for triggers to fire, so that we know they\n# are working.\nproc trigfunc {args} {\n  set ::TRIGGER $args\n}\ndb func trigfunc trigfunc\n\ndo_test alter-3.1.0 {\n  execsql {\n    CREATE TABLE t6(a, b, c);\n    -- Different case for the table name in the trigger.\n    CREATE TRIGGER trig1 AFTER INSERT ON T6 BEGIN\n      SELECT trigfunc('trig1', new.a, new.b, new.c);\n    END;\n  }\n} {}\ndo_test alter-3.1.1 {\n  execsql {\n    INSERT INTO t6 VALUES(1, 2, 3);\n  }\n  set ::TRIGGER\n} {trig1 1 2 3}\ndo_test alter-3.1.2 {\n  execsql {\n    ALTER TABLE t6 RENAME TO t7;\n    INSERT INTO t7 VALUES(4, 5, 6);\n  }\n  set ::TRIGGER\n} {trig1 4 5 6}\ndo_test alter-3.1.3 {\n  execsql {\n    DROP TRIGGER trig1;\n  }\n} {}\ndo_test alter-3.1.4 {\n  execsql {\n    CREATE TRIGGER trig2 AFTER INSERT ON main.t7 BEGIN\n      SELECT trigfunc('trig2', new.a, new.b, new.c);\n    END;\n    INSERT INTO t7 VALUES(1, 2, 3);\n  }\n  set ::TRIGGER\n} {trig2 1 2 3}\ndo_test alter-3.1.5 {\n  execsql {\n    ALTER TABLE t7 RENAME TO t8;\n    INSERT INTO t8 VALUES(4, 5, 6);\n  }\n  set ::TRIGGER\n} {trig2 4 5 6}\ndo_test alter-3.1.6 {\n  execsql {\n    DROP TRIGGER trig2;\n  }\n} {}\ndo_test alter-3.1.7 {\n  execsql {\n    CREATE TRIGGER trig3 AFTER INSERT ON main.'t8'BEGIN\n      SELECT trigfunc('trig3', new.a, new.b, new.c);\n    END;\n    INSERT INTO t8 VALUES(1, 2, 3);\n  }\n  set ::TRIGGER\n} {trig3 1 2 3}\ndo_test alter-3.1.8 {\n  execsql {\n    ALTER TABLE t8 RENAME TO t9;\n    INSERT INTO t9 VALUES(4, 5, 6);\n  }\n  set ::TRIGGER\n} {trig3 4 5 6}\n\n# Make sure \"ON\" cannot be used as a database, table or column name without\n# quoting. Otherwise the sqlite_alter_trigger() function might not work.\nforcedelete test3.db\nforcedelete test3.db-journal\nifcapable attach {\n  do_test alter-3.2.1 {\n    catchsql {\n      ATTACH 'test3.db' AS ON;\n    }\n  } {1 {near \"ON\": syntax error}}\n  do_test alter-3.2.2 {\n    catchsql {\n      ATTACH 'test3.db' AS 'ON';\n    }\n  } {0 {}}\n  do_test alter-3.2.3 {\n    catchsql {\n      CREATE TABLE ON.t1(a, b, c); \n    }\n  } {1 {near \"ON\": syntax error}}\n  do_test alter-3.2.4 {\n    catchsql {\n      CREATE TABLE 'ON'.t1(a, b, c); \n    }\n  } {0 {}}\n  do_test alter-3.2.4 {\n    catchsql {\n      CREATE TABLE 'ON'.ON(a, b, c); \n    }\n  } {1 {near \"ON\": syntax error}}\n  do_test alter-3.2.5 {\n    catchsql {\n      CREATE TABLE 'ON'.'ON'(a, b, c); \n    }\n  } {0 {}}\n}\ndo_test alter-3.2.6 {\n  catchsql {\n    CREATE TABLE t10(a, ON, c);\n  }\n} {1 {near \"ON\": syntax error}}\ndo_test alter-3.2.7 {\n  catchsql {\n    CREATE TABLE t10(a, 'ON', c);\n  }\n} {0 {}}\ndo_test alter-3.2.8 {\n  catchsql {\n    CREATE TRIGGER trig4 AFTER INSERT ON ON BEGIN SELECT 1; END;\n  }\n} {1 {near \"ON\": syntax error}}\nifcapable attach {\n  do_test alter-3.2.9 {\n    catchsql {\n      CREATE TRIGGER 'on'.trig4 AFTER INSERT ON 'ON' BEGIN SELECT 1; END;\n    }\n  } {0 {}}\n}\ndo_test alter-3.2.10 {\n  execsql {\n    DROP TABLE t10;\n  }\n} {}\n\ndo_test alter-3.3.1 {\n  execsql [subst {\n    CREATE TABLE tbl1(a, b, c);\n    CREATE $::temp TRIGGER trig1 AFTER INSERT ON tbl1 BEGIN\n      SELECT trigfunc('trig1', new.a, new.b, new.c);\n    END;\n  }]\n} {}\ndo_test alter-3.3.2 {\n  execsql {\n    INSERT INTO tbl1 VALUES('a', 'b', 'c');\n  }\n  set ::TRIGGER\n} {trig1 a b c}\ndo_test alter-3.3.3 {\n  execsql {\n    ALTER TABLE tbl1 RENAME TO tbl2;\n    INSERT INTO tbl2 VALUES('d', 'e', 'f');\n  } \n  set ::TRIGGER\n} {trig1 d e f}\ndo_test alter-3.3.4 {\n  execsql [subst {\n    CREATE $::temp TRIGGER trig2 AFTER UPDATE ON tbl2 BEGIN\n      SELECT trigfunc('trig2', new.a, new.b, new.c);\n    END;\n  }] \n} {}\ndo_test alter-3.3.5 {\n  execsql {\n    ALTER TABLE tbl2 RENAME TO tbl3;\n    INSERT INTO tbl3 VALUES('g', 'h', 'i');\n  } \n  set ::TRIGGER\n} {trig1 g h i}\ndo_test alter-3.3.6 {\n  execsql {\n    UPDATE tbl3 SET a = 'G' where a = 'g';\n  } \n  set ::TRIGGER\n} {trig2 G h i}\ndo_test alter-3.3.7 {\n  execsql {\n    DROP TABLE tbl3;\n  }\n} {}\nifcapable tempdb {\n  do_test alter-3.3.8 {\n    execsql {\n      SELECT * FROM temp.sqlite_master WHERE type = 'trigger';\n    }\n  } {}\n}\n\n} ;# ifcapable trigger\n\n# If the build does not include AUTOINCREMENT fields, omit alter-4.*.\nifcapable autoinc {\n\ndo_test alter-4.1 {\n  execsql {\n    CREATE TABLE tbl1(a INTEGER PRIMARY KEY AUTOINCREMENT);\n    INSERT INTO tbl1 VALUES(10);\n  }\n} {}\ndo_test alter-4.2 {\n  execsql {\n    INSERT INTO tbl1 VALUES(NULL);\n    SELECT a FROM tbl1;\n  }\n} {10 11}\ndo_test alter-4.3 {\n  execsql {\n    ALTER TABLE tbl1 RENAME TO tbl2;\n    DELETE FROM tbl2;\n    INSERT INTO tbl2 VALUES(NULL);\n    SELECT a FROM tbl2;\n  }\n} {12}\ndo_test alter-4.4 {\n  execsql {\n    DROP TABLE tbl2;\n  }\n} {}\n\n} ;# ifcapable autoinc\n\n# Test that it is Ok to execute an ALTER TABLE immediately after\n# opening a database.\ndo_test alter-5.1 {\n  execsql {\n    CREATE TABLE tbl1(a, b, c);\n    INSERT INTO tbl1 VALUES('x', 'y', 'z');\n  }\n} {}\ndo_test alter-5.2 {\n  sqlite3 db2 test.db\n  execsql {\n    ALTER TABLE tbl1 RENAME TO tbl2;\n    SELECT * FROM tbl2;\n  } db2\n} {x y z}\ndo_test alter-5.3 {\n  db2 close\n} {}\n\nforeach tblname [execsql {\n  SELECT name FROM sqlite_master\n   WHERE type='table' AND name NOT GLOB 'sqlite*'\n}] {\n  execsql \"DROP TABLE \\\"$tblname\\\"\"\n}\n\nset ::tbl_name \"abc\\uABCDdef\"\ndo_test alter-6.1 {\n  string length $::tbl_name\n} {7}\ndo_test alter-6.2 {\n  execsql \"\n    CREATE TABLE ${tbl_name}(a, b, c);\n  \"\n  set ::oid [execsql {SELECT max(oid) FROM sqlite_master}]\n  execsql \"\n    SELECT sql FROM sqlite_master WHERE oid = $::oid;\n  \"\n} \"{CREATE TABLE ${::tbl_name}(a, b, c)}\"\nexecsql \"\n  SELECT * FROM ${::tbl_name}\n\"\nset ::tbl_name2 \"abcXdef\"\ndo_test alter-6.3 {\n  execsql \"\n    ALTER TABLE $::tbl_name RENAME TO $::tbl_name2 \n  \"\n  execsql \"\n    SELECT sql FROM sqlite_master WHERE oid = $::oid\n  \"\n} \"{CREATE TABLE \\\"${::tbl_name2}\\\"(a, b, c)}\"\ndo_test alter-6.4 {\n  execsql \"\n    ALTER TABLE $::tbl_name2 RENAME TO $::tbl_name\n  \"\n  execsql \"\n    SELECT sql FROM sqlite_master WHERE oid = $::oid\n  \"\n} \"{CREATE TABLE \\\"${::tbl_name}\\\"(a, b, c)}\"\nset ::col_name ghi\\1234\\jkl\ndo_test alter-6.5 {\n  execsql \"\n    ALTER TABLE $::tbl_name ADD COLUMN $::col_name VARCHAR\n  \"\n  execsql \"\n    SELECT sql FROM sqlite_master WHERE oid = $::oid\n  \"\n} \"{CREATE TABLE \\\"${::tbl_name}\\\"(a, b, c, $::col_name VARCHAR)}\"\nset ::col_name2 B\\3421\\A\ndo_test alter-6.6 {\n  db close\n  sqlite3 db test.db\n  execsql \"\n    ALTER TABLE $::tbl_name ADD COLUMN $::col_name2\n  \"\n  execsql \"\n    SELECT sql FROM sqlite_master WHERE oid = $::oid\n  \"\n} \"{CREATE TABLE \\\"${::tbl_name}\\\"(a, b, c, $::col_name VARCHAR, $::col_name2)}\"\ndo_test alter-6.7 {\n  execsql \"\n    INSERT INTO ${::tbl_name} VALUES(1, 2, 3, 4, 5);\n    SELECT $::col_name, $::col_name2 FROM $::tbl_name;\n  \"\n} {4 5}\n\n# Ticket #1665:  Make sure ALTER TABLE ADD COLUMN works on a table\n# that includes a COLLATE clause.\n#\ndo_realnum_test alter-7.1 {\n  execsql {\n    CREATE TABLE t1(a TEXT COLLATE BINARY);\n    ALTER TABLE t1 ADD COLUMN b INTEGER COLLATE NOCASE;\n    INSERT INTO t1 VALUES(1,'-2');\n    INSERT INTO t1 VALUES(5.4e-08,'5.4e-08');\n    SELECT typeof(a), a, typeof(b), b FROM t1;\n  }\n} {text 1 integer -2 text 5.4e-08 real 5.4e-08}\n\n# Make sure that when a column is added by ALTER TABLE ADD COLUMN and has\n# a default value that the default value is used by aggregate functions.\n#\ndo_test alter-8.1 {\n  execsql {\n    CREATE TABLE t2(a INTEGER);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    ALTER TABLE t2 ADD COLUMN b INTEGER DEFAULT 9;\n    SELECT sum(b) FROM t2;\n  }\n} {27}\ndo_test alter-8.2 {\n  execsql {\n    SELECT a, sum(b) FROM t2 GROUP BY a;\n  }\n} {1 18 2 9}\n\n#--------------------------------------------------------------------------\n# alter-9.X - Special test: Make sure the sqlite_rename_trigger() and\n# rename_table() functions do not crash when handed bad input.\n#\nifcapable trigger {\n  do_test alter-9.1 {\n    execsql {SELECT SQLITE_RENAME_TRIGGER(0,0)}\n  } {{}}\n}\ndo_test alter-9.2 {\n  execsql {\n    SELECT SQLITE_RENAME_TABLE(0,0);\n    SELECT SQLITE_RENAME_TABLE(10,20);\n    SELECT SQLITE_RENAME_TABLE('foo', 'foo');\n  }\n} {{} {} {}}\n\n#------------------------------------------------------------------------\n# alter-10.X - Make sure ALTER TABLE works with multi-byte UTF-8 characters \n# in the names.\n#\ndo_test alter-10.1 {\n  execsql \"CREATE TABLE xyz(x UNIQUE)\"\n  execsql \"ALTER TABLE xyz RENAME TO xyz\\u1234abc\"\n  execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}\n} [list xyz\\u1234abc]\ndo_test alter-10.2 {\n  execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}\n} [list sqlite_autoindex_xyz\\u1234abc_1]\ndo_test alter-10.3 {\n  execsql \"ALTER TABLE xyz\\u1234abc RENAME TO xyzabc\"\n  execsql {SELECT name FROM sqlite_master WHERE name GLOB 'xyz*'}\n} [list xyzabc]\ndo_test alter-10.4 {\n  execsql {SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_autoindex*'}\n} [list sqlite_autoindex_xyzabc_1]\n\ndo_test alter-11.1 {\n  sqlite3_exec db {CREATE TABLE t11(%c6%c6)}\n  execsql {\n    ALTER TABLE t11 ADD COLUMN abc;\n  }\n  catchsql {\n    ALTER TABLE t11 ADD COLUMN abc;\n  }\n} {1 {duplicate column name: abc}}\nset isutf16 [regexp 16 [db one {PRAGMA encoding}]]\nif {!$isutf16} {\n  do_test alter-11.2 {\n    execsql {INSERT INTO t11 VALUES(1,2)}\n    sqlite3_exec db {SELECT %c6%c6 AS xyz, abc FROM t11}\n  } {0 {xyz abc 1 2}}\n}\ndo_test alter-11.3 {\n  sqlite3_exec db {CREATE TABLE t11b(\"%81%82%83\" text)}\n  execsql {\n    ALTER TABLE t11b ADD COLUMN abc;\n  }\n  catchsql {\n    ALTER TABLE t11b ADD COLUMN abc;\n  }\n} {1 {duplicate column name: abc}}\nif {!$isutf16} {\n  do_test alter-11.4 {\n    execsql {INSERT INTO t11b VALUES(3,4)}\n    sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11b}\n  } {0 {xyz abc 3 4}}\n  do_test alter-11.5 {\n    sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11b}\n  } {0 {xyz abc 3 4}}\n  do_test alter-11.6 {\n    sqlite3_exec db {SELECT \"%81%82%83\" AS xyz, abc FROM t11b}\n  } {0 {xyz abc 3 4}}\n}\ndo_test alter-11.7 {\n  sqlite3_exec db {CREATE TABLE t11c(%81%82%83 text)}\n  execsql {\n    ALTER TABLE t11c ADD COLUMN abc;\n  }\n  catchsql {\n    ALTER TABLE t11c ADD COLUMN abc;\n  }\n} {1 {duplicate column name: abc}}\nif {!$isutf16} {\n  do_test alter-11.8 {\n    execsql {INSERT INTO t11c VALUES(5,6)}\n    sqlite3_exec db {SELECT %81%82%83 AS xyz, abc FROM t11c}\n  } {0 {xyz abc 5 6}}\n  do_test alter-11.9 {\n    sqlite3_exec db {SELECT [%81%82%83] AS xyz, abc FROM t11c}\n  } {0 {xyz abc 5 6}}\n  do_test alter-11.10 {\n    sqlite3_exec db {SELECT \"%81%82%83\" AS xyz, abc FROM t11c}\n  } {0 {xyz abc 5 6}}\n}\n\ndo_test alter-12.1 {\n  execsql {\n    CREATE TABLE t12(a, b, c);\n    CREATE VIEW v1 AS SELECT * FROM t12;\n  }\n} {}\ndo_test alter-12.2 {\n  catchsql {\n    ALTER TABLE v1 RENAME TO v2;\n  }\n} {1 {view v1 may not be altered}}\ndo_test alter-12.3 {\n  execsql { SELECT * FROM v1; }\n} {}\ndo_test alter-12.4 {\n  db close\n  sqlite3 db test.db\n  execsql { SELECT * FROM v1; }\n} {}\ndo_test alter-12.5 {\n  catchsql { \n    ALTER TABLE v1 ADD COLUMN new_column;\n  }\n} {1 {Cannot add a column to a view}}\n\n# Ticket #3102:\n# Verify that comments do not interfere with the table rename\n# algorithm.\n#\ndo_test alter-13.1 {\n  execsql {\n    CREATE TABLE /* hi */ t3102a(x);\n    CREATE TABLE t3102b -- comment\n    (y);\n    CREATE INDEX t3102c ON t3102a(x);\n    SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;\n  }\n} {t3102a t3102b t3102c}\ndo_test alter-13.2 {\n  execsql {\n    ALTER TABLE t3102a RENAME TO t3102a_rename;\n    SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;\n  }\n} {t3102a_rename t3102b t3102c}\ndo_test alter-13.3 {\n  execsql {\n    ALTER TABLE t3102b RENAME TO t3102b_rename;\n    SELECT name FROM sqlite_master WHERE name GLOB 't3102*' ORDER BY 1;\n  }\n} {t3102a_rename t3102b_rename t3102c}\n\n# Ticket #3651\ndo_test alter-14.1 {\n  catchsql {\n    CREATE TABLE t3651(a UNIQUE);\n    ALTER TABLE t3651 ADD COLUMN b UNIQUE;\n  }\n} {1 {Cannot add a UNIQUE column}}\ndo_test alter-14.2 {\n  catchsql {\n    ALTER TABLE t3651 ADD COLUMN b PRIMARY KEY;\n  }\n} {1 {Cannot add a PRIMARY KEY column}}\n\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to use ALTER TABLE on any system table.\n#\nset system_table_list {1 sqlite_master}\ncatchsql ANALYZE\nifcapable analyze { lappend system_table_list 2 sqlite_stat1 }\nifcapable stat3   { lappend system_table_list 3 sqlite_stat3 }\nifcapable stat4   { lappend system_table_list 4 sqlite_stat4 }\n\nforeach {tn tbl} $system_table_list {\n  do_test alter-15.$tn.1 {\n    catchsql \"ALTER TABLE $tbl RENAME TO xyz\"\n  } [list 1 \"table $tbl may not be altered\"]\n\n  do_test alter-15.$tn.2 {\n    catchsql \"ALTER TABLE $tbl ADD COLUMN xyz\"\n  } [list 1 \"table $tbl may not be altered\"]\n}\n\n#------------------------------------------------------------------------\n# Verify that ALTER TABLE works on tables with the WITHOUT rowid option.\n#\ndo_execsql_test alter-16.1 {\n  CREATE TABLE t16a(a TEXT, b REAL, c INT, PRIMARY KEY(a,b)) WITHOUT rowid;\n  INSERT INTO t16a VALUES('abc',1.25,99);\n  ALTER TABLE t16a ADD COLUMN d TEXT DEFAULT 'xyzzy';\n  INSERT INTO t16a VALUES('cba',5.5,98,'fizzle');\n  SELECT * FROM t16a ORDER BY a;\n} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}\ndo_execsql_test alter-16.2 {\n  ALTER TABLE t16a RENAME TO t16a_rn;\n  SELECT * FROM t16a_rn ORDER BY a;\n} {abc 1.25 99 xyzzy cba 5.5 98 fizzle}\n\n#-------------------------------------------------------------------------\n# Verify that NULL values into the internal-use-only sqlite_rename_*()\n# functions do not cause problems.\n#\ndo_execsql_test alter-17.1 {\n  SELECT sqlite_rename_table('CREATE TABLE xyz(a,b,c)','abc');\n} {{CREATE TABLE \"abc\"(a,b,c)}}\ndo_execsql_test alter-17.2 {\n  SELECT sqlite_rename_table('CREATE TABLE xyz(a,b,c)',NULL);\n} {{CREATE TABLE \"(NULL)\"(a,b,c)}}\ndo_execsql_test alter-17.3 {\n  SELECT sqlite_rename_table(NULL,'abc');\n} {{}}\ndo_execsql_test alter-17.4 {\n  SELECT sqlite_rename_trigger('CREATE TRIGGER r1 ON xyz WHEN','abc');\n} {{CREATE TRIGGER r1 ON \"abc\" WHEN}}\ndo_execsql_test alter-17.5 {\n  SELECT sqlite_rename_trigger('CREATE TRIGGER r1 ON xyz WHEN',NULL);\n} {{CREATE TRIGGER r1 ON \"(NULL)\" WHEN}}\ndo_execsql_test alter-17.6 {\n  SELECT sqlite_rename_trigger(NULL,'abc');\n} {{}}\ndo_execsql_test alter-17.7 {\n  SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES \"xyzzy\")',\n         'xyzzy','lmnop');\n} {{CREATE TABLE t1(a REFERENCES \"lmnop\")}}\ndo_execsql_test alter-17.8 {\n  SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES \"xyzzy\")',\n         'xyzzy',NULL);\n} {{CREATE TABLE t1(a REFERENCES \"(NULL)\")}}\ndo_execsql_test alter-17.9 {\n  SELECT sqlite_rename_parent('CREATE TABLE t1(a REFERENCES \"xyzzy\")',\n         NULL, 'lmnop');\n} {{}}\ndo_execsql_test alter-17.10 {\n  SELECT sqlite_rename_parent(NULL,'abc','xyz');\n} {{}}\ndo_execsql_test alter-17.11 {\n  SELECT sqlite_rename_parent('create references ''','abc','xyz');\n} {{create references '}}\ndo_execsql_test alter-17.12 {\n  SELECT sqlite_rename_parent('create references \"abc\"123\" ','abc','xyz');\n} {{create references \"xyz\"123\" }}\ndo_execsql_test alter-17.13 {\n  SELECT sqlite_rename_parent(\"references '''\",'abc','xyz');\n} {{references '''}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/alter2.test",
    "content": "# 2005 February 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing that SQLite can handle a subtle \n# file format change that may be used in the future to implement\n# \"ALTER TABLE ... ADD COLUMN\".\n#\n# $Id: alter2.test,v 1.14 2009/04/07 14:14:22 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# We have to have pragmas in order to do this test\nifcapable {!pragma} return\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts. See proc [set_file_format].\n#\ndo_not_use_codec\n\n# The file format change affects the way row-records stored in tables (but \n# not indices) are interpreted. Before version 3.1.3, a row-record for a \n# table with N columns was guaranteed to contain exactly N fields. As\n# of version 3.1.3, the record may contain up to N fields. In this case\n# the M fields that are present are the values for the left-most M \n# columns. The (N-M) rightmost columns contain NULL.\n#\n# If any records in the database contain less fields than their table\n# has columns, then the file-format meta value should be set to (at least) 2. \n#\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\n# This procedure sets the SQL statement stored for table $tbl in the\n# sqlite_master table of file 'test.db' to $sql. Also set the file format\n# to the supplied value. This is 2 if the added column has a default that is\n# NULL, or 3 otherwise. \n#\nproc alter_table {tbl sql {file_format 2}} {\n  sqlite3 dbat test.db\n  set s [string map {' ''} $sql]\n  set t [string map {' ''} $tbl]\n  dbat eval [subst {\n    PRAGMA writable_schema = 1;\n    UPDATE sqlite_master SET sql = '$s' WHERE name = '$t' AND type = 'table';\n    PRAGMA writable_schema = 0;\n  }]\n  dbat close\n  set_file_format 2\n}\n\n# Create bogus application-defined functions for functions used \n# internally by ALTER TABLE, to ensure that ALTER TABLE falls back\n# to the built-in functions.\n#\nproc failing_app_func {args} {error \"bad function\"}\ndo_test alter2-1.0 {\n  db func substr failing_app_func\n  db func like failing_app_func\n  db func sqlite_rename_table failing_app_func\n  db func sqlite_rename_trigger failing_app_func\n  db func sqlite_rename_parent failing_app_func\n  catchsql {SELECT substr('abcdefg',1,3)}\n} {1 {bad function}}\n\n\n#-----------------------------------------------------------------------\n# Some basic tests to make sure short rows are handled.\n#\ndo_test alter2-1.1 {\n  execsql {\n    CREATE TABLE abc(a, b);\n    INSERT INTO abc VALUES(1, 2);\n    INSERT INTO abc VALUES(3, 4);\n    INSERT INTO abc VALUES(5, 6);\n  }\n} {}\ndo_test alter2-1.2 {\n  # ALTER TABLE abc ADD COLUMN c;\n  alter_table abc {CREATE TABLE abc(a, b, c);}\n} {}\ndo_test alter2-1.3 {\n  execsql {\n    SELECT * FROM abc;\n  }\n} {1 2 {} 3 4 {} 5 6 {}}\ndo_test alter2-1.4 {\n  execsql {\n    UPDATE abc SET c = 10 WHERE a = 1;\n    SELECT * FROM abc;\n  }\n} {1 2 10 3 4 {} 5 6 {}}\ndo_test alter2-1.5 {\n  execsql {\n    CREATE INDEX abc_i ON abc(c);\n  }\n} {}\ndo_test alter2-1.6 {\n  execsql {\n    SELECT c FROM abc ORDER BY c;\n  }\n} {{} {} 10}\ndo_test alter2-1.7 {\n  execsql {\n    SELECT * FROM abc WHERE c = 10;\n  }\n} {1 2 10}\ndo_test alter2-1.8 {\n  execsql {\n    SELECT sum(a), c FROM abc GROUP BY c;\n  }\n} {8 {} 1 10}\ndo_test alter2-1.9 {\n  # ALTER TABLE abc ADD COLUMN d;\n  alter_table abc {CREATE TABLE abc(a, b, c, d);}\n  if {[permutation] == \"prepare\"} { db cache flush }\n  execsql { SELECT * FROM abc; }\n  execsql {\n    UPDATE abc SET d = 11 WHERE c IS NULL AND a<4;\n    SELECT * FROM abc;\n  }\n} {1 2 10 {} 3 4 {} 11 5 6 {} {}}\ndo_test alter2-1.10 {\n  execsql {\n    SELECT typeof(d) FROM abc;\n  }\n} {null integer null}\ndo_test alter2-1.99 {\n  execsql {\n    DROP TABLE abc;\n  }\n} {}\n\n#-----------------------------------------------------------------------\n# Test that views work when the underlying table structure is changed.\n#\nifcapable view {\n  do_test alter2-2.1 {\n    execsql {\n      CREATE TABLE abc2(a, b, c);\n      INSERT INTO abc2 VALUES(1, 2, 10);\n      INSERT INTO abc2 VALUES(3, 4, NULL);\n      INSERT INTO abc2 VALUES(5, 6, NULL);\n      CREATE VIEW abc2_v AS SELECT * FROM abc2;\n      SELECT * FROM abc2_v;\n    }\n  } {1 2 10 3 4 {} 5 6 {}}\n  do_test alter2-2.2 {\n    # ALTER TABLE abc ADD COLUMN d;\n    alter_table abc2 {CREATE TABLE abc2(a, b, c, d);}\n    execsql {\n      SELECT * FROM abc2_v;\n    }\n  } {1 2 10 {} 3 4 {} {} 5 6 {} {}}\n  do_test alter2-2.3 {\n    execsql {\n      DROP TABLE abc2;\n      DROP VIEW abc2_v;\n    }\n  } {}\n}\n\n#-----------------------------------------------------------------------\n# Test that triggers work when a short row is copied to the old.*\n# trigger pseudo-table.\n#\nifcapable trigger {\n  do_test alter2-3.1 {\n    execsql {\n      CREATE TABLE abc3(a, b);\n      CREATE TABLE blog(o, n);\n      CREATE TRIGGER abc3_t AFTER UPDATE OF b ON abc3 BEGIN\n        INSERT INTO blog VALUES(old.b, new.b);\n      END;\n    }\n  } {}\n  do_test alter2-3.2 {\n    execsql {\n      INSERT INTO abc3 VALUES(1, 4);\n      UPDATE abc3 SET b = 2 WHERE b = 4;\n      SELECT * FROM blog;\n    }\n  } {4 2}\n  do_test alter2-3.3 {\n    execsql {\n      INSERT INTO abc3 VALUES(3, 4);\n      INSERT INTO abc3 VALUES(5, 6);\n    }\n    alter_table abc3 {CREATE TABLE abc3(a, b, c);}\n    execsql {\n      SELECT * FROM abc3;\n    }\n  } {1 2 {} 3 4 {} 5 6 {}}\n  do_test alter2-3.4 {\n    execsql {\n      UPDATE abc3 SET b = b*2 WHERE a<4;\n      SELECT * FROM abc3;\n    }\n  } {1 4 {} 3 8 {} 5 6 {}}\n  do_test alter2-3.5 {\n    execsql {\n      SELECT * FROM blog;\n    }\n  } {4 2 2 4 4 8}\n\n  do_test alter2-3.6 {\n    execsql {\n      CREATE TABLE clog(o, n);\n      CREATE TRIGGER abc3_t2 AFTER UPDATE OF c ON abc3 BEGIN\n        INSERT INTO clog VALUES(old.c, new.c);\n      END;\n      UPDATE abc3 SET c = a*2;\n      SELECT * FROM clog;\n    }\n  } {{} 2 {} 6 {} 10}\n} else {\n  execsql { CREATE TABLE abc3(a, b); }\n}\n\n#---------------------------------------------------------------------\n# Check that an error occurs if the database is upgraded to a file\n# format that SQLite does not support (in this case 5). Note: The \n# file format is checked each time the schema is read, so changing the\n# file format requires incrementing the schema cookie.\n#\ndo_test alter2-4.1 {\n  db close\n  set_file_format 5\n  catch { sqlite3 db test.db }\n  set {} {}\n} {}\ndo_test alter2-4.2 {\n  # We have to run two queries here because the Tcl interface uses\n  # sqlite3_prepare_v2(). In this case, the first query encounters an \n  # SQLITE_SCHEMA error. Then, when trying to recompile the statement, the\n  # \"unsupported file format\" error is encountered. So the error code\n  # returned is SQLITE_SCHEMA, not SQLITE_ERROR as required by the following\n  # test case.\n  #\n  # When the query is attempted a second time, the same error message is\n  # returned but the error code is SQLITE_ERROR, because the unsupported\n  # file format was detected during a call to sqlite3_prepare(), not\n  # sqlite3_step().\n  #\n  catchsql { SELECT * FROM sqlite_master; }\n  catchsql { SELECT * FROM sqlite_master; }\n} {1 {unsupported file format}}\ndo_test alter2-4.3 {\n  sqlite3_errcode db\n} {SQLITE_ERROR}\ndo_test alter2-4.4 {\n  set ::DB [sqlite3_connection_pointer db]\n  catchsql {\n    SELECT * FROM sqlite_master;\n  }\n} {1 {unsupported file format}}\ndo_test alter2-4.5 {\n  sqlite3_errcode db\n} {SQLITE_ERROR}\n\n#---------------------------------------------------------------------\n# Check that executing VACUUM on a file with file-format version 2\n# resets the file format to 1.\n#\nset default_file_format [expr $SQLITE_DEFAULT_FILE_FORMAT==4 ? 4 : 1]\nifcapable vacuum {\n  do_test alter2-5.1 {\n    set_file_format 2\n    db close\n    sqlite3 db test.db\n    execsql {SELECT 1 FROM sqlite_master LIMIT 1;}\n    get_file_format\n  } {2}\n  do_test alter2-5.2 {\n    execsql { VACUUM }\n  } {}\n  do_test alter2-5.3 {\n    get_file_format\n  } $default_file_format\n}\n \n#---------------------------------------------------------------------\n# Test that when a database with file-format 2 is opened, new \n# databases are still created with file-format 1.\n#\ndo_test alter2-6.1 {\n  db close\n  set_file_format 2\n  sqlite3 db test.db\n  get_file_format\n} {2}\nifcapable attach {\n  do_test alter2-6.2 {\n    forcedelete test2.db-journal\n    forcedelete test2.db\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.t1(a, b);\n    }\n    get_file_format test2.db\n  } $default_file_format\n}\ndo_test alter2-6.3 {\n  execsql {\n    CREATE TABLE t1(a, b);\n  }\n  get_file_format \n} {2}\n\n#---------------------------------------------------------------------\n# Test that types and values for columns added with default values \n# other than NULL work with SELECT statements.\n#\ndo_test alter2-7.1 {\n  execsql {\n    DROP TABLE t1;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4}\ndo_test alter2-7.2 {\n  set sql {CREATE TABLE t1(a, b DEFAULT '123', c INTEGER DEFAULT '123')}\n  alter_table t1 $sql 3\n  execsql {\n    SELECT * FROM t1 LIMIT 1;\n  }\n} {1 123 123}\ndo_test alter2-7.3 {\n  execsql {\n    SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;\n  }\n} {1 integer 123 text 123 integer}\ndo_test alter2-7.4 {\n  execsql {\n    SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;\n  }\n} {1 integer 123 text 123 integer}\ndo_test alter2-7.5 {\n  set sql {CREATE TABLE t1(a, b DEFAULT -123.0, c VARCHAR(10) default 5)}\n  alter_table t1 $sql 3\n  execsql {\n    SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;\n  }\n} {1 integer -123 integer 5 text}\n\n#-----------------------------------------------------------------------\n# Test that UPDATE trigger tables work with default values, and that when\n# a row is updated the default values are correctly transfered to the \n# new row.\n# \nifcapable trigger {\ndb function set_val {set ::val}\n  do_test alter2-8.1 {\n    execsql {\n      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN\n      SELECT set_val(\n          old.b||' '||typeof(old.b)||' '||old.c||' '||typeof(old.c)||' '||\n          new.b||' '||typeof(new.b)||' '||new.c||' '||typeof(new.c) \n      );\n      END;\n    }\n    list\n  } {}\n}\ndo_test alter2-8.2 {\n  execsql {\n    UPDATE t1 SET c = 10 WHERE a = 1;\n    SELECT a, typeof(a), b, typeof(b), c, typeof(c) FROM t1 LIMIT 1;\n  }\n} {1 integer -123 integer 10 text}\nifcapable trigger {\n  do_test alter2-8.3 {\n    set ::val\n  } {-123 integer 5 text -123 integer 10 text}\n}\n\n#-----------------------------------------------------------------------\n# Test that DELETE trigger tables work with default values, and that when\n# a row is updated the default values are correctly transfered to the \n# new row.\n# \nifcapable trigger {\n  do_test alter2-9.1 {\n    execsql {\n      CREATE TRIGGER trig2 BEFORE DELETE ON t1 BEGIN\n      SELECT set_val(\n          old.b||' '||typeof(old.b)||' '||old.c||' '||typeof(old.c)\n      );\n      END;\n    }\n    list\n  } {}\n  do_test alter2-9.2 {\n    execsql {\n      DELETE FROM t1 WHERE a = 2;\n    }\n    set ::val\n  } {-123 integer 5 text}\n}\n\n#-----------------------------------------------------------------------\n# Test creating an index on a column added with a default value. \n#\nifcapable bloblit {\n  do_test alter2-10.1 {\n    execsql {\n      CREATE TABLE t2(a);\n      INSERT INTO t2 VALUES('a');\n      INSERT INTO t2 VALUES('b');\n      INSERT INTO t2 VALUES('c');\n      INSERT INTO t2 VALUES('d');\n    }\n    alter_table t2 {CREATE TABLE t2(a, b DEFAULT X'ABCD', c DEFAULT NULL);} 3\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n    execsql {\n      SELECT quote(a), quote(b), quote(c) FROM t2 LIMIT 1;\n    }\n  } {'a' X'ABCD' NULL}\n  do_test alter2-10.2 {\n    execsql {\n      CREATE INDEX i1 ON t2(b);\n      SELECT a FROM t2 WHERE b = X'ABCD';\n    }\n  } {a b c d}\n  do_test alter2-10.3 {\n    execsql {\n      DELETE FROM t2 WHERE a = 'c';\n      SELECT a FROM t2 WHERE b = X'ABCD';\n    }\n  } {a b d}\n  do_test alter2-10.4 {\n    execsql {\n      SELECT count(b) FROM t2 WHERE b = X'ABCD';\n    }\n  } {3}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/alter3.test",
    "content": "# 2005 February 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing that SQLite can handle a subtle \n# file format change that may be used in the future to implement\n# \"ALTER TABLE ... ADD COLUMN\".\n#\n# $Id: alter3.test,v 1.11 2008/03/19 00:21:31 drh Exp $\n#\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\n\n# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.\nifcapable !altertable {\n  finish_test\n  return\n}\n\n# Determine if there is a codec available on this test.\n#\nif {[catch {sqlite3 -has-codec} r] || $r} {\n  set has_codec 1\n} else {\n  set has_codec 0\n}\n\n\n# Test Organisation:\n# ------------------\n#\n# alter3-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.\n# alter3-2.*: Test error messages.\n# alter3-3.*: Test adding columns with default value NULL.\n# alter3-4.*: Test adding columns with default values other than NULL.\n# alter3-5.*: Test adding columns to tables in ATTACHed databases.\n# alter3-6.*: Test that temp triggers are not accidentally dropped.\n# alter3-7.*: Test that VACUUM resets the file-format.\n#\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\ndo_test alter3-1.1 {\n  execsql {\n    PRAGMA legacy_file_format=ON;\n    CREATE TABLE abc(a, b, c);\n    SELECT sql FROM sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c)}}\ndo_test alter3-1.2 {\n  execsql {ALTER TABLE abc ADD d INTEGER;}\n  execsql {\n    SELECT sql FROM sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER)}}\ndo_test alter3-1.3 {\n  execsql {ALTER TABLE abc ADD e}\n  execsql {\n    SELECT sql FROM sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}\ndo_test alter3-1.4 {\n  execsql {\n    CREATE TABLE main.t1(a, b);\n    ALTER TABLE t1 ADD c;\n    SELECT sql FROM sqlite_master WHERE tbl_name = 't1';\n  }\n} {{CREATE TABLE t1(a, b, c)}}\ndo_test alter3-1.5 {\n  execsql {\n    ALTER TABLE t1 ADD d CHECK (a>d);\n    SELECT sql FROM sqlite_master WHERE tbl_name = 't1';\n  }\n} {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}\nifcapable foreignkey {\n  do_test alter3-1.6 {\n    execsql {\n      CREATE TABLE t2(a, b, UNIQUE(a, b));\n      ALTER TABLE t2 ADD c REFERENCES t1(c)  ;\n      SELECT sql FROM sqlite_master WHERE tbl_name = 't2' AND type = 'table';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}\n}\ndo_test alter3-1.7 {\n  execsql {\n    CREATE TABLE t3(a, b, UNIQUE(a, b));\n    ALTER TABLE t3 ADD COLUMN c VARCHAR(10, 20);\n    SELECT sql FROM sqlite_master WHERE tbl_name = 't3' AND type = 'table';\n  }\n} {{CREATE TABLE t3(a, b, c VARCHAR(10, 20), UNIQUE(a, b))}}\ndo_test alter3-1.99 {\n  catchsql {\n    # May not exist if foriegn-keys are omitted at compile time.\n    DROP TABLE t2; \n  }\n  execsql {\n    DROP TABLE abc; \n    DROP TABLE t1; \n    DROP TABLE t3; \n  }\n} {}\n\ndo_test alter3-2.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n  }\n  catchsql {\n    ALTER TABLE t1 ADD c PRIMARY KEY;\n  }\n} {1 {Cannot add a PRIMARY KEY column}}\ndo_test alter3-2.2 {\n  catchsql {\n    ALTER TABLE t1 ADD c UNIQUE\n  }\n} {1 {Cannot add a UNIQUE column}}\ndo_test alter3-2.3 {\n  catchsql {\n    ALTER TABLE t1 ADD b VARCHAR(10)\n  }\n} {1 {duplicate column name: b}}\ndo_test alter3-2.3 {\n  catchsql {\n    ALTER TABLE t1 ADD c NOT NULL;\n  }\n} {1 {Cannot add a NOT NULL column with default value NULL}}\ndo_test alter3-2.4 {\n  catchsql {\n    ALTER TABLE t1 ADD c NOT NULL DEFAULT 10;\n  }\n} {0 {}}\nifcapable view {\n  do_test alter3-2.5 {\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM t1;\n    }\n    catchsql {\n      alter table v1 add column d;\n    }\n  } {1 {Cannot add a column to a view}}\n}\ndo_test alter3-2.6 {\n  catchsql {\n    alter table t1 add column d DEFAULT CURRENT_TIME;\n  }\n} {1 {Cannot add a column with non-constant default}}\ndo_test alter3-2.99 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\ndo_test alter3-3.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 300);\n    SELECT * FROM t1;\n  }\n} {1 100 2 300}\ndo_test alter3-3.1 {\n  execsql {\n    PRAGMA schema_version = 10;\n  }\n} {}\ndo_test alter3-3.2 {\n  execsql {\n    ALTER TABLE t1 ADD c;\n    SELECT * FROM t1;\n  }\n} {1 100 {} 2 300 {}}\nif {!$has_codec} {\n  do_test alter3-3.3 {\n    get_file_format\n  } {3}\n}\nifcapable schema_version {\n  do_test alter3-3.4 {\n    execsql {\n      PRAGMA schema_version;\n    }\n  } {11}\n}\n\ndo_test alter3-4.1 {\n  db close\n  forcedelete test.db\n  set ::DB [sqlite3 db test.db]\n  execsql {\n    PRAGMA legacy_file_format=ON;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 300);\n    SELECT * FROM t1;\n  }\n} {1 100 2 300}\ndo_test alter3-4.1 {\n  execsql {\n    PRAGMA schema_version = 20;\n  }\n} {}\ndo_test alter3-4.2 {\n  execsql {\n    ALTER TABLE t1 ADD c DEFAULT 'hello world';\n    SELECT * FROM t1;\n  }\n} {1 100 {hello world} 2 300 {hello world}}\nif {!$has_codec} {\n  do_test alter3-4.3 {\n    get_file_format\n  } {3}\n}\nifcapable schema_version {\n  do_test alter3-4.4 {\n    execsql {\n      PRAGMA schema_version;\n    }\n  } {21}\n}\ndo_test alter3-4.99 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\nifcapable attach {\n  do_test alter3-5.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 'one');\n      INSERT INTO t1 VALUES(2, 'two');\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.t1 AS SELECT * FROM t1;\n      PRAGMA aux.schema_version = 30;\n      SELECT sql FROM aux.sqlite_master;\n    } \n  } {{CREATE TABLE t1(a,b)}}\n  do_test alter3-5.2 {\n    execsql {\n      ALTER TABLE aux.t1 ADD COLUMN c VARCHAR(128);\n      SELECT sql FROM aux.sqlite_master;\n    }\n  } {{CREATE TABLE t1(a,b, c VARCHAR(128))}}\n  do_test alter3-5.3 {\n    execsql {\n      SELECT * FROM aux.t1;\n    }\n  } {1 one {} 2 two {}}\n  ifcapable schema_version {\n    do_test alter3-5.4 {\n      execsql {\n        PRAGMA aux.schema_version;\n      }\n    } {31}\n  }\n  if {!$has_codec} {\n    do_test alter3-5.5 {\n      list [get_file_format test2.db] [get_file_format]\n    } {3 3}\n  }\n  do_test alter3-5.6 {\n    execsql {\n      ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;\n      SELECT sql FROM aux.sqlite_master;\n    }\n  } {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}\n  do_test alter3-5.7 {\n    execsql {\n      SELECT * FROM aux.t1;\n    }\n  } {1 one {} 1000 2 two {} 1000}\n  ifcapable schema_version {\n    do_test alter3-5.8 {\n      execsql {\n        PRAGMA aux.schema_version;\n      }\n    } {32}\n  }\n  do_test alter3-5.9 {\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {1 one 2 two}\n  do_test alter3-5.99 {\n    execsql {\n      DROP TABLE aux.t1;\n      DROP TABLE t1;\n    }\n  } {}\n}\n\n#----------------------------------------------------------------\n# Test that the table schema is correctly reloaded when a column\n# is added to a table.\n#\nifcapable trigger&&tempdb {\n  do_test alter3-6.1 {\n    execsql {\n      CREATE TABLE t1(a, b);\n      CREATE TABLE log(trig, a, b);\n\n      CREATE TRIGGER t1_a AFTER INSERT ON t1 BEGIN\n        INSERT INTO log VALUES('a', new.a, new.b);\n      END;\n      CREATE TEMP TRIGGER t1_b AFTER INSERT ON t1 BEGIN\n        INSERT INTO log VALUES('b', new.a, new.b);\n      END;\n  \n      INSERT INTO t1 VALUES(1, 2);\n      SELECT * FROM log;\n    }\n  } {b 1 2 a 1 2}\n  do_test alter3-6.2 {\n    execsql {\n      ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';\n      INSERT INTO t1(a, b) VALUES(3, 4);\n      SELECT * FROM log;\n    }\n  } {b 1 2 a 1 2 b 3 4 a 3 4}\n}\n\nif {!$has_codec} {\n  ifcapable vacuum {\n    do_test alter3-7.1 {\n      execsql {\n        VACUUM;\n      }\n      get_file_format\n    } {1}\n    do_test alter3-7.2 {\n      execsql {\n        CREATE TABLE abc(a, b, c);\n        ALTER TABLE abc ADD d DEFAULT NULL;\n      }\n      get_file_format\n    } {3}\n    do_test alter3-7.3 {\n      execsql {\n        ALTER TABLE abc ADD e DEFAULT 10;\n      }\n      get_file_format\n    } {3}\n    do_test alter3-7.4 {\n      execsql {\n        ALTER TABLE abc ADD f DEFAULT NULL;\n      }\n      get_file_format\n    } {3}\n    do_test alter3-7.5 {\n      execsql {\n        VACUUM;\n      }\n      get_file_format\n    } {1}\n  }\n}\n\n# Ticket #1183 - Make sure adding columns to large tables does not cause\n# memory corruption (as was the case before this bug was fixed).\ndo_test alter3-8.1 {\n  execsql {\n    CREATE TABLE t4(c1);\n  }\n} {}\nset ::sql \"\"\ndo_test alter3-8.2 {\n  set cols c1\n  for {set i 2} {$i < 100} {incr i} {\n    execsql \"\n      ALTER TABLE t4 ADD c$i\n    \"\n    lappend cols c$i\n  }\n  set ::sql \"CREATE TABLE t4([join $cols {, }])\"\n  list \n} {}\ndo_test alter3-8.2 {\n  execsql {\n    SELECT sql FROM sqlite_master WHERE name = 't4';\n  }\n} [list $::sql]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/alter4.test",
    "content": "# 2009 February 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing that SQLite can handle a subtle \n# file format change that may be used in the future to implement\n# \"ALTER TABLE ... ADD COLUMN\".\n#\n# $Id: alter4.test,v 1.1 2009/02/02 18:03:22 drh Exp $\n#\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\n\n# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.\nifcapable !altertable {\n  finish_test\n  return\n}\n\n\n# Test Organisation:\n# ------------------\n#\n# alter4-1.*: Test that ALTER TABLE correctly modifies the CREATE TABLE sql.\n# alter4-2.*: Test error messages.\n# alter4-3.*: Test adding columns with default value NULL.\n# alter4-4.*: Test adding columns with default values other than NULL.\n# alter4-5.*: Test adding columns to tables in ATTACHed databases.\n# alter4-6.*: Test that temp triggers are not accidentally dropped.\n# alter4-7.*: Test that VACUUM resets the file-format.\n#\n\ndo_test alter4-1.1 {\n  execsql {\n    CREATE TEMP TABLE abc(a, b, c);\n    SELECT sql FROM sqlite_temp_master;\n  }\n} {{CREATE TABLE abc(a, b, c)}}\ndo_test alter4-1.1b {\n  execsql {\n    SELECT sql FROM temp.sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c)}}\ndo_test alter4-1.2 {\n  execsql {ALTER TABLE abc ADD d INTEGER;}\n  execsql {\n    SELECT sql FROM sqlite_temp_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER)}}\ndo_test alter4-1.2b {\n  execsql {\n    SELECT sql FROM temp.sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER)}}\ndo_test alter4-1.3 {\n  execsql {ALTER TABLE abc ADD e}\n  execsql {\n    SELECT sql FROM sqlite_temp_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}\ndo_test alter4-1.3b {\n  execsql {\n    SELECT sql FROM temp.sqlite_master;\n  }\n} {{CREATE TABLE abc(a, b, c, d INTEGER, e)}}\ndo_test alter4-1.4 {\n  execsql {\n    CREATE TABLE temp.t1(a, b);\n    ALTER TABLE t1 ADD c;\n    SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';\n  }\n} {{CREATE TABLE t1(a, b, c)}}\ndo_test alter4-1.4b {\n  execsql {\n    SELECT sql FROM temp.sqlite_master WHERE tbl_name = 't1';\n  }\n} {{CREATE TABLE t1(a, b, c)}}\ndo_test alter4-1.5 {\n  execsql {\n    ALTER TABLE t1 ADD d CHECK (a>d);\n    SELECT sql FROM sqlite_temp_master WHERE tbl_name = 't1';\n  }\n} {{CREATE TABLE t1(a, b, c, d CHECK (a>d))}}\nifcapable foreignkey {\n  do_test alter4-1.6 {\n    execsql {\n      CREATE TEMP TABLE t2(a, b, UNIQUE(a, b));\n      ALTER TABLE t2 ADD c REFERENCES t1(c)  ;\n      SELECT sql FROM sqlite_temp_master\n       WHERE tbl_name = 't2' AND type = 'table';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1(c), UNIQUE(a, b))}}\n}\ndo_test alter4-1.7 {\n  execsql {\n    CREATE TEMPORARY TABLE t3(a, b, UNIQUE(a, b));\n    ALTER TABLE t3 ADD COLUMN c VARCHAR(10, 20);\n    SELECT sql FROM sqlite_temp_master\n     WHERE tbl_name = 't3' AND type = 'table';\n  }\n} {{CREATE TABLE t3(a, b, c VARCHAR(10, 20), UNIQUE(a, b))}}\ndo_test alter4-1.99 {\n  catchsql {\n    # May not exist if foriegn-keys are omitted at compile time.\n    DROP TABLE t2; \n  }\n  execsql {\n    DROP TABLE abc; \n    DROP TABLE t1; \n    DROP TABLE t3; \n  }\n} {}\n\ndo_test alter4-2.1 {\n  execsql {\n    CREATE TABLE temp.t1(a, b);\n  }\n  catchsql {\n    ALTER TABLE t1 ADD c PRIMARY KEY;\n  }\n} {1 {Cannot add a PRIMARY KEY column}}\ndo_test alter4-2.2 {\n  catchsql {\n    ALTER TABLE t1 ADD c UNIQUE\n  }\n} {1 {Cannot add a UNIQUE column}}\ndo_test alter4-2.3 {\n  catchsql {\n    ALTER TABLE t1 ADD b VARCHAR(10)\n  }\n} {1 {duplicate column name: b}}\ndo_test alter4-2.3 {\n  catchsql {\n    ALTER TABLE t1 ADD c NOT NULL;\n  }\n} {1 {Cannot add a NOT NULL column with default value NULL}}\ndo_test alter4-2.4 {\n  catchsql {\n    ALTER TABLE t1 ADD c NOT NULL DEFAULT 10;\n  }\n} {0 {}}\nifcapable view {\n  do_test alter4-2.5 {\n    execsql {\n      CREATE TEMPORARY VIEW v1 AS SELECT * FROM t1;\n    }\n    catchsql {\n      alter table v1 add column d;\n    }\n  } {1 {Cannot add a column to a view}}\n}\ndo_test alter4-2.6 {\n  catchsql {\n    alter table t1 add column d DEFAULT CURRENT_TIME;\n  }\n} {1 {Cannot add a column with non-constant default}}\ndo_test alter4-2.7 {\n  catchsql {\n    alter table t1 add column d default (-5+1);\n  }\n} {1 {Cannot add a column with non-constant default}}\ndo_test alter4-2.99 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\ndo_test alter4-3.1 {\n  execsql {\n    CREATE TEMP TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 300);\n    SELECT * FROM t1;\n  }\n} {1 100 2 300}\ndo_test alter4-3.1 {\n  execsql {\n    PRAGMA schema_version = 10;\n  }\n} {}\ndo_test alter4-3.2 {\n  execsql {\n    ALTER TABLE t1 ADD c;\n    SELECT * FROM t1;\n  }\n} {1 100 {} 2 300 {}}\nifcapable schema_version {\n  do_test alter4-3.4 {\n    execsql {\n      PRAGMA schema_version;\n    }\n  } {10}\n}\n\ndo_test alter4-4.1 {\n  db close\n  forcedelete test.db\n  set ::DB [sqlite3 db test.db]\n  execsql {\n    CREATE TEMP TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 300);\n    SELECT * FROM t1;\n  }\n} {1 100 2 300}\ndo_test alter4-4.1 {\n  execsql {\n    PRAGMA schema_version = 20;\n  }\n} {}\ndo_test alter4-4.2 {\n  execsql {\n    ALTER TABLE t1 ADD c DEFAULT 'hello world';\n    SELECT * FROM t1;\n  }\n} {1 100 {hello world} 2 300 {hello world}}\nifcapable schema_version {\n  do_test alter4-4.4 {\n    execsql {\n      PRAGMA schema_version;\n    }\n  } {20}\n}\ndo_test alter4-4.99 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\nifcapable attach {\n  do_test alter4-5.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      CREATE TEMP TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 'one');\n      INSERT INTO t1 VALUES(2, 'two');\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.t1 AS SELECT * FROM t1;\n      PRAGMA aux.schema_version = 30;\n      SELECT sql FROM aux.sqlite_master;\n    } \n  } {{CREATE TABLE t1(a,b)}}\n  do_test alter4-5.2 {\n    execsql {\n      ALTER TABLE aux.t1 ADD COLUMN c VARCHAR(128);\n      SELECT sql FROM aux.sqlite_master;\n    }\n  } {{CREATE TABLE t1(a,b, c VARCHAR(128))}}\n  do_test alter4-5.3 {\n    execsql {\n      SELECT * FROM aux.t1;\n    }\n  } {1 one {} 2 two {}}\n  ifcapable schema_version {\n    do_test alter4-5.4 {\n      execsql {\n        PRAGMA aux.schema_version;\n      }\n    } {31}\n  }\n  do_test alter4-5.6 {\n    execsql {\n      ALTER TABLE aux.t1 ADD COLUMN d DEFAULT 1000;\n      SELECT sql FROM aux.sqlite_master;\n    }\n  } {{CREATE TABLE t1(a,b, c VARCHAR(128), d DEFAULT 1000)}}\n  do_test alter4-5.7 {\n    execsql {\n      SELECT * FROM aux.t1;\n    }\n  } {1 one {} 1000 2 two {} 1000}\n  ifcapable schema_version {\n    do_test alter4-5.8 {\n      execsql {\n        PRAGMA aux.schema_version;\n      }\n    } {32}\n  }\n  do_test alter4-5.9 {\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {1 one 2 two}\n  do_test alter4-5.99 {\n    execsql {\n      DROP TABLE aux.t1;\n      DROP TABLE t1;\n    }\n  } {}\n}\n\n#----------------------------------------------------------------\n# Test that the table schema is correctly reloaded when a column\n# is added to a table.\n#\nifcapable trigger&&tempdb {\n  do_test alter4-6.1 {\n    execsql {\n      CREATE TEMP TABLE t1(a, b);\n      CREATE TEMP TABLE log(trig, a, b);\n\n      CREATE TRIGGER t1_a AFTER INSERT ON t1 BEGIN\n        INSERT INTO log VALUES('a', new.a, new.b);\n      END;\n      CREATE TEMP TRIGGER t1_b AFTER INSERT ON t1 BEGIN\n        INSERT INTO log VALUES('b', new.a, new.b);\n      END;\n  \n      INSERT INTO t1 VALUES(1, 2);\n      SELECT * FROM log;\n    }\n  } {b 1 2 a 1 2}\n  do_test alter4-6.2 {\n    execsql {\n      ALTER TABLE t1 ADD COLUMN c DEFAULT 'c';\n      INSERT INTO t1(a, b) VALUES(3, 4);\n      SELECT * FROM log;\n    }\n  } {b 1 2 a 1 2 b 3 4 a 3 4}\n}\n\n# Ticket #1183 - Make sure adding columns to large tables does not cause\n# memory corruption (as was the case before this bug was fixed).\ndo_test alter4-8.1 {\n  execsql {\n    CREATE TEMP TABLE t4(c1);\n  }\n} {}\nset ::sql \"\"\ndo_test alter4-8.2 {\n  set cols c1\n  for {set i 2} {$i < 100} {incr i} {\n    execsql \"\n      ALTER TABLE t4 ADD c$i\n    \"\n    lappend cols c$i\n  }\n  set ::sql \"CREATE TABLE t4([join $cols {, }])\"\n  list \n} {}\ndo_test alter4-8.2 {\n  execsql {\n    SELECT sql FROM sqlite_temp_master WHERE name = 't4';\n  }\n} [list $::sql]\n\n\n# Test that a default value equal to -1 multipied by the smallest possible\n# 64-bit integer is correctly converted to a real.\ndo_execsql_test alter4-9.1 {\n  CREATE TABLE t5(\n    a INTEGER DEFAULT -9223372036854775808,\n    b INTEGER DEFAULT (-(-9223372036854775808))\n  );\n  INSERT INTO t5 DEFAULT VALUES;\n}\n\ndo_execsql_test alter4-9.2 { SELECT typeof(a), a, typeof(b), b FROM t5; } {\n  integer -9223372036854775808\n  real     9.22337203685478e+18\n}\n\ndo_execsql_test alter4-9.3 { \n  ALTER TABLE t5 ADD COLUMN c INTEGER DEFAULT (-(-9223372036854775808));\n  SELECT typeof(c), c FROM t5;\n} {real 9.22337203685478e+18}\n\n# Confirm that doing an ALTER TABLE on a legacy format database\n# does not corrupt DESC indexes.\n#\n# Ticket https://www.sqlite.org/src/tktview/f68bf68513a1c\n#\ndo_test alter4-10.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    PRAGMA legacy_file_format=on;\n    CREATE TABLE t1(a,b,c);\n    CREATE INDEX t1a ON t1(a DESC);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(2,3,4);\n    ALTER TABLE t1 ADD COLUMN d;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/altermalloc.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ALTER TABLE statement and\n# specifically out-of-memory conditions within that command.\n#\n# $Id: altermalloc.test,v 1.10 2008/10/30 17:21:13 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.\nifcapable !altertable||!memdebug {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\n\ndo_malloc_test altermalloc-1 -tclprep {\n  db close\n} -tclbody {\n  if {[catch {sqlite3 db test.db}]} {\n    error \"out of memory\"\n  }\n  sqlite3_db_config_lookaside db 0 0 0\n  sqlite3_extended_result_codes db 1\n} -sqlbody {\n  CREATE TABLE t1(a int);\n  ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT NULL;\n  ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT 'default-text';\n  ALTER TABLE t1 RENAME TO t2;\n  ALTER TABLE t2 ADD COLUMN d BLOB DEFAULT X'ABCD';\n}\n\n# Test malloc() failure on an ALTER TABLE on a virtual table.\n#\nifcapable vtab {\n  do_malloc_test altermalloc-vtab -tclprep {\n    sqlite3 db2 test.db \n    sqlite3_db_config_lookaside db2 0 0 0\n    sqlite3_extended_result_codes db2 1\n    register_echo_module [sqlite3_connection_pointer db2]\n    db2 eval {\n      CREATE TABLE t1(a, b VARCHAR, c INTEGER);\n      CREATE VIRTUAL TABLE t1echo USING echo(t1);\n    }\n    db2 close\n\n    register_echo_module [sqlite3_connection_pointer db]\n  } -tclbody {\n    set rc [catch {db eval { ALTER TABLE t1echo RENAME TO t1_echo }} msg]\n    if {$msg eq \"vtable constructor failed: t1echo\"} {\n      set msg \"out of memory\"\n    }\n    if {$rc} {\n      error $msg\n    }\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/amatch1.test",
    "content": "# 2013-09-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for \"approximate_match\" virtual\n# table that is in the \"amatch.c\" extension.\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS4 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Create the fts_kjv_genesis procedure which fills and FTS3/4 table with\n# the complete text of the Book of Genesis.\n#\nsource $testdir/genesis.tcl\n\n\n\ndo_test amatch1-1.0 {\n  db eval {\n    CREATE VIRTUAL TABLE t1 USING fts4(words); --, tokenize porter);\n  }\n  fts_kjv_genesis\n  db eval {\n    INSERT INTO t1(t1) VALUES('optimize');\n    CREATE VIRTUAL TABLE temp.t1aux USING fts4aux(main, t1);\n    SELECT term FROM t1aux WHERE col=0 ORDER BY 1 LIMIT 5\n  }\n} {a abated abel abelmizraim abidah}\ndo_test amatch1-1.1 {\n  db eval {\n    SELECT term FROM t1aux WHERE term>'b' AND col=0 ORDER BY 1 LIMIT 5\n  }\n} {baalhanan babel back backward bad}\ndo_test amatch1-1.2 {\n  db eval {\n    SELECT term FROM t1aux WHERE term>'b' AND col=0 LIMIT 5\n  }\n} {baalhanan babel back backward bad}\n\n# Load the amatch extension\nload_static_extension db amatch\n\ndo_execsql_test amatch1-2.0 {\n    CREATE TABLE costs(iLang, cFrom, cTo, Cost);\n    INSERT INTO costs VALUES(0, '', '?', 100);\n    INSERT INTO costs VALUES(0, '?', '', 100);\n    INSERT INTO costs VALUES(0, '?', '?', 150);\n    CREATE TABLE vocab(w TEXT UNIQUE);\n    INSERT OR IGNORE INTO vocab SELECT term FROM t1aux;\n    CREATE VIRTUAL TABLE t2 USING approximate_match(\n      vocabulary_table=t1aux,\n      vocabulary_word=term,\n      edit_distances=costs\n    );\n    CREATE VIRTUAL TABLE t3 USING approximate_match(\n      vocabulary_table=vocab,\n      vocabulary_word=w,\n      edit_distances=costs\n    );\n    CREATE VIRTUAL TABLE t4 USING approximate_match(\n        vocabulary_table=vtemp,\n        vocabulary_word=w,\n        edit_distances=costs\n      );\n} {}\nputs \"Query against fts4aux: [time {\n  do_execsql_test amatch1-2.1 {\n      SELECT word, distance FROM t2\n       WHERE word MATCH 'josxph' AND distance<300;\n  } {joseph 150}} 1]\"\nputs \"Query against ordinary table: [time {\n  do_execsql_test amatch1-2.2 {\n      SELECT word, distance FROM t3\n       WHERE word MATCH 'josxph' AND distance<300;\n  } {joseph 150}} 1]\"\nputs \"Temp table initialized from fts4aux: [time {\n  do_execsql_test amatch1-2.3a {\n      CREATE TEMP TABLE vtemp(w TEXT UNIQUE);\n      INSERT OR IGNORE INTO vtemp SELECT term FROM t1aux;\n  } {}} 1]\"\nputs \"Query against temp table: [time {\n  do_execsql_test amatch1-2.3b {\n      SELECT word, distance FROM t4\n       WHERE word MATCH 'josxph' AND distance<300;\n  } {joseph 150}} 1]\"\ndo_execsql_test amatch1-2.11 {\n    SELECT word, distance FROM t2\n     WHERE word MATCH 'joxxph' AND distance<=300;\n} {joseph 300}\ndo_execsql_test amatch1-2.12 {\n    SELECT word, distance FROM t3\n     WHERE word MATCH 'joxxph' AND distance<=300;\n} {joseph 300}\ndo_execsql_test amatch1-2.21 {\n    SELECT word, distance FROM t2\n     WHERE word MATCH 'joxxph' AND distance<300;\n} {}\ndo_execsql_test amatch1-2.22 {\n    SELECT word, distance FROM t3\n     WHERE word MATCH 'joxxph' AND distance<300;\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze.test",
    "content": "# 2005 July 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# This file implements tests for the ANALYZE command.\n#\n# $Id: analyze.test,v 1.9 2008/08/11 18:44:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# There is nothing to test if ANALYZE is disable for this build.\n#\nifcapable {!analyze} {\n  finish_test\n  return\n}\n\n# Basic sanity checks.\n#\ndo_test analyze-1.1 {\n  catchsql {\n    ANALYZE no_such_table\n  }\n} {1 {no such table: no_such_table}}\ndo_test analyze-1.2 {\n  execsql {\n    SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'\n  }\n} {0}\ndo_test analyze-1.3 {\n  catchsql {\n    ANALYZE no_such_db.no_such_table\n  }\n} {1 {unknown database no_such_db}}\ndo_test analyze-1.4 {\n  execsql {\n    SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'\n  }\n} {0}\ndo_test analyze-1.5.1 {\n  catchsql {\n    ANALYZE\n  }\n} {0 {}}\ndo_test analyze-1.5.2 {\n  catchsql {\n    PRAGMA empty_result_callbacks=1;\n    ANALYZE\n  }\n} {0 {}}\ndo_test analyze-1.6 {\n  execsql {\n    SELECT count(*) FROM sqlite_master WHERE name='sqlite_stat1'\n  }\n} {1}\ndo_test analyze-1.6.2 {\n  catchsql {\n    CREATE INDEX stat1idx ON sqlite_stat1(idx);\n  }\n} {1 {table sqlite_stat1 may not be indexed}}\ndo_test analyze-1.6.3 {\n  catchsql {\n    CREATE INDEX main.stat1idx ON SQLite_stat1(idx);\n  }\n} {1 {table sqlite_stat1 may not be indexed}}\ndo_test analyze-1.7 {\n  execsql {\n    SELECT * FROM sqlite_stat1 WHERE idx NOT NULL\n  }\n} {}\ndo_test analyze-1.8 {\n  catchsql {\n    ANALYZE main\n  }\n} {0 {}}\ndo_test analyze-1.9 {\n  execsql {\n    SELECT * FROM sqlite_stat1 WHERE idx NOT NULL\n  }\n} {}\ndo_test analyze-1.10 {\n  catchsql {\n    CREATE TABLE t1(a,b);\n    ANALYZE main.t1;\n  }\n} {0 {}}\ndo_test analyze-1.11 {\n  execsql {\n    SELECT * FROM sqlite_stat1\n  }\n} {}\ndo_test analyze-1.12 {\n  catchsql {\n    ANALYZE t1;\n  }\n} {0 {}}\ndo_test analyze-1.13 {\n  execsql {\n    SELECT * FROM sqlite_stat1\n  }\n} {}\n\n# Create some indices that can be analyzed.  But do not yet add\n# data.  Without data in the tables, no analysis is done.\n#\ndo_test analyze-2.1 {\n  execsql {\n    CREATE INDEX t1i1 ON t1(a);\n    ANALYZE main.t1;\n    SELECT * FROM sqlite_stat1 ORDER BY idx;\n  }\n} {}\ndo_test analyze-2.2 {\n  execsql {\n    CREATE INDEX t1i2 ON t1(b);\n    ANALYZE t1;\n    SELECT * FROM sqlite_stat1 ORDER BY idx;\n  }\n} {}\ndo_test analyze-2.3 {\n  execsql {\n    CREATE INDEX t1i3 ON t1(a,b);\n    ANALYZE main;\n    SELECT * FROM sqlite_stat1 ORDER BY idx;\n  }\n} {}\n\n# Start adding data to the table.  Verify that the analysis\n# is done correctly.\n#\ndo_test analyze-3.1 {\n  execsql {\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(1,3);\n    ANALYZE main.t1;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {2 2} t1i2 {2 1} t1i3 {2 2 1}}\ndo_test analyze-3.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1,4);\n    INSERT INTO t1 VALUES(1,5);\n    ANALYZE t1;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {4 4} t1i2 {4 1} t1i3 {4 4 1}}\ndo_test analyze-3.3 {\n  execsql {\n    INSERT INTO t1 VALUES(2,5);\n    ANALYZE main;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1}}\ndo_test analyze-3.4 {\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    CREATE INDEX t2i1 ON t2(a);\n    CREATE INDEX t2i2 ON t2(b);\n    CREATE INDEX t2i3 ON t2(a,b);\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2} t2i3 {5 3 1}}\ndo_test analyze-3.5 {\n  execsql {\n    DROP INDEX t2i3;\n    ANALYZE t1;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2}}\ndo_test analyze-3.6 {\n  execsql {\n    ANALYZE t2;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3} t2i2 {5 2}}\ndo_test analyze-3.7 {\n  execsql {\n    DROP INDEX t2i2;\n    ANALYZE t2;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t1i1 {5 3} t1i2 {5 2} t1i3 {5 3 1} t2i1 {5 3}}\ndo_test analyze-3.8 {\n  execsql {\n    CREATE TABLE t3 AS SELECT a, b, rowid AS c, 'hi' AS d FROM t1;\n    CREATE INDEX t3i1 ON t3(a);\n    CREATE INDEX t3i2 ON t3(a,b,c,d);\n    CREATE INDEX t3i3 ON t3(d,b,c,a);\n    DROP TABLE t1;\n    DROP TABLE t2;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {}\ndo_test analyze-3.9 {\n  execsql {\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}\n\ndo_test analyze-3.10 {\n  execsql {\n    CREATE TABLE [silly \" name](a, b, c);\n    CREATE INDEX 'foolish '' name' ON [silly \" name](a, b);\n    CREATE INDEX 'another foolish '' name' ON [silly \" name](c);\n    INSERT INTO [silly \" name] VALUES(1, 2, 3);\n    INSERT INTO [silly \" name] VALUES(4, 5, 6);\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {{another foolish ' name} {2 1} {foolish ' name} {2 1 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}\ndo_test analyze-3.11 {\n  execsql {\n    DROP INDEX \"foolish ' name\";\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {{another foolish ' name} {2 1} t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}\ndo_test analyze-3.11 {\n  execsql {\n    DROP TABLE \"silly \"\" name\";\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1}}\n\n# Try corrupting the sqlite_stat1 table and make sure the\n# database is still able to function.\n#\ndo_test analyze-4.0 {\n  sqlite3 db2 test.db\n  db2 eval {\n    CREATE TABLE t4(x,y,z);\n    CREATE INDEX t4i1 ON t4(x);\n    CREATE INDEX t4i2 ON t4(y);\n    INSERT INTO t4 SELECT a,b,c FROM t3;\n  }\n  db2 close\n  db close\n  sqlite3 db test.db\n  execsql {\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n  }\n} {t3i1 {5 3} t3i2 {5 3 1 1 1} t3i3 {5 5 2 1 1} t4i1 {5 3} t4i2 {5 2}}\ndo_test analyze-4.1 {\n  execsql {\n    PRAGMA writable_schema=on;\n    INSERT INTO sqlite_stat1 VALUES(null,null,null);\n    PRAGMA writable_schema=off;\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM t4 WHERE x=1234;\n  }\n} {}\ndo_test analyze-4.2 {\n  execsql {\n    PRAGMA writable_schema=on;\n    DELETE FROM sqlite_stat1;\n    INSERT INTO sqlite_stat1 VALUES('t4','t4i1','nonsense');\n    INSERT INTO sqlite_stat1 VALUES('t4','t4i2','120897349817238741092873198273409187234918720394817209384710928374109827172901827349871928741910');\n    PRAGMA writable_schema=off;\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM t4 WHERE x=1234;\n  }\n} {}\ndo_test analyze-4.3 {\n  execsql {\n    INSERT INTO sqlite_stat1 VALUES('t4','xyzzy','0 1 2 3');\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM t4 WHERE x=1234;\n  }\n} {}\n\n# Verify that DROP TABLE and DROP INDEX remove entries from the \n# sqlite_stat1, sqlite_stat3 and sqlite_stat4 tables.\n#\ndo_test analyze-5.0 {\n  execsql {\n    DELETE FROM t3;\n    DELETE FROM t4;\n    INSERT INTO t3 VALUES(1,2,3,4);\n    INSERT INTO t3 VALUES(5,6,7,8);\n    INSERT INTO t3 SELECT a+8, b+8, c+8, d+8 FROM t3;\n    INSERT INTO t3 SELECT a+16, b+16, c+16, d+16 FROM t3;\n    INSERT INTO t3 SELECT a+32, b+32, c+32, d+32 FROM t3;\n    INSERT INTO t3 SELECT a+64, b+64, c+64, d+64 FROM t3;\n    INSERT INTO t4 SELECT a, b, c FROM t3;\n    ANALYZE;\n    SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;\n    SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;\n  }\n} {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}\nifcapable stat4||stat3 {\n  ifcapable stat4 {set stat sqlite_stat4} else {set stat sqlite_stat3}\n  do_test analyze-5.1 {\n    execsql \"\n      SELECT DISTINCT idx FROM $stat ORDER BY 1;\n      SELECT DISTINCT tbl FROM $stat ORDER BY 1;\n    \"\n  } {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}\n}\ndo_test analyze-5.2 {\n  execsql {\n    DROP INDEX t3i2;\n    SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;\n    SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;\n  }\n} {t3i1 t3i3 t4i1 t4i2 t3 t4}\nifcapable stat4||stat3 {\n  do_test analyze-5.3 {\n    execsql \"\n      SELECT DISTINCT idx FROM $stat ORDER BY 1;\n      SELECT DISTINCT tbl FROM $stat ORDER BY 1;\n    \"\n  } {t3i1 t3i3 t4i1 t4i2 t3 t4}\n}\ndo_test analyze-5.4 {\n  execsql {\n    DROP TABLE t3;\n    SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;\n    SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;\n  }\n} {t4i1 t4i2 t4}\nifcapable stat4||stat3 {\n  do_test analyze-5.5 {\n    execsql \"\n      SELECT DISTINCT idx FROM $stat ORDER BY 1;\n      SELECT DISTINCT tbl FROM $stat ORDER BY 1;\n    \"\n  } {t4i1 t4i2 t4}\n}\n\n# This test corrupts the database file so it must be the last test\n# in the series.\n#\ndo_test analyze-99.1 {\n  execsql {\n    PRAGMA writable_schema=on;\n    UPDATE sqlite_master SET sql='nonsense' WHERE name='sqlite_stat1';\n  }\n  db close\n  catch { sqlite3 db test.db }\n  catchsql {\n    ANALYZE\n  }\n} {1 {malformed database schema (sqlite_stat1)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze3.test",
    "content": "# 2009 August 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. This file \n# implements tests for range and LIKE constraints that use bound variables\n# instead of literal constant arguments.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix analyze3\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\n#----------------------------------------------------------------------\n# Test Organization:\n#\n# analyze3-1.*: Test that the values of bound parameters are considered \n#               in the same way as constants when planning queries that\n#               use range constraints.\n#\n# analyze3-2.*: Test that the values of bound parameters are considered \n#               in the same way as constants when planning queries that\n#               use LIKE expressions in the WHERE clause.\n#\n# analyze3-3.*: Test that binding to a variable does not invalidate the \n#               query plan when there is no way in which replanning the\n#               query may produce a superior outcome.\n#\n# analyze3-4.*: Test that SQL or authorization callback errors occuring\n#               within sqlite3Reprepare() are handled correctly.\n#\n# analyze3-5.*: Check that the query plans of applicable statements are\n#               invalidated if the values of SQL parameter are modified\n#               using the clear_bindings() or transfer_bindings() APIs.\n# \n# analyze3-6.*: Test that the problem fixed by commit [127a5b776d] is fixed.\n#\n# analyze3-7.*: Test that some memory leaks discovered by fuzz testing \n#               have been fixed.\n#\n\nproc getvar {varname} { uplevel #0 set $varname }\ndb function var getvar\n\nproc eqp {sql {db db}} {\n  uplevel execsql [list \"EXPLAIN QUERY PLAN $sql\"] $db\n}\n\nproc sf_execsql {sql {db db}} {\n  set ::sqlite_search_count 0\n  set r [uplevel [list execsql $sql $db]]\n\n  concat $::sqlite_search_count [$db status step] $r\n}\n\n#-------------------------------------------------------------------------\n#\n# analyze3-1.1.1: \n#   Create a table with two columns. Populate the first column (affinity \n#   INTEGER) with integer values from 100 to 1100. Create an index on this \n#   column. ANALYZE the table.\n#\n# analyze3-1.1.2 - 3.1.3\n#   Show that there are two possible plans for querying the table with\n#   a range constraint on the indexed column - \"full table scan\" or \"use \n#   the index\". When the range is specified using literal values, SQLite\n#   is able to pick the best plan based on the samples in sqlite_stat3.\n#\n# analyze3-1.1.4 - 3.1.9\n#   Show that using SQL variables produces the same results as using\n#   literal values to constrain the range scan.\n#\n#   These tests also check that the compiler code considers column \n#   affinities when estimating the number of rows scanned by the \"use \n#   index strategy\".\n#\ndo_test analyze3-1.1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x INTEGER, y);\n    CREATE INDEX i1 ON t1(x);\n  }\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i+100, $i) }\n  }\n  execsql {\n    COMMIT;\n    ANALYZE;\n  }\n\n  ifcapable stat4 {\n    execsql { SELECT count(*)>0 FROM sqlite_stat4; }\n  } else {\n    execsql { SELECT count(*)>0 FROM sqlite_stat3; }\n  }\n} {1}\n\ndo_execsql_test analyze3-1.1.x {\n  SELECT count(*) FROM t1 WHERE x>200 AND x<300;\n  SELECT count(*) FROM t1 WHERE x>0 AND x<1100;\n} {99 1000}\n\n# The first of the following two SELECT statements visits 99 rows. So\n# it is better to use the index. But the second visits every row in \n# the table (1000 in total) so it is better to do a full-table scan.\n#\ndo_eqp_test analyze3-1.1.2 {\n  SELECT sum(y) FROM t1 WHERE x>200 AND x<300\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}\ndo_eqp_test analyze3-1.1.3 {\n  SELECT sum(y) FROM t1 WHERE x>0 AND x<1100 \n} {0 0 0 {SCAN TABLE t1}}\n\n# 2017-06-26:  Verify that the SQLITE_DBCONFIG_ENABLE_QPSG setting disables\n# the use of bound parameters by STAT4\n#\ndb cache flush\nunset -nocomplain l\nunset -nocomplain u\ndo_eqp_test analyze3-1.1.3.100 {\n  SELECT sum(y) FROM t1 WHERE x>$l AND x<$u\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}\nset l 200\nset u 300\ndo_eqp_test analyze3-1.1.3.101 {\n  SELECT sum(y) FROM t1 WHERE x>$l AND x<$u\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}\nset l 0\nset u 1100\ndo_eqp_test analyze3-1.1.3.102 {\n  SELECT sum(y) FROM t1 WHERE x>$l AND x<$u\n} {0 0 0 {SCAN TABLE t1}}\ndb cache flush\nsqlite3_db_config db ENABLE_QPSG 1\ndo_eqp_test analyze3-1.1.3.103 {\n  SELECT sum(y) FROM t1 WHERE x>$l AND x<$u\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x>? AND x<?)}}\ndb cache flush\nsqlite3_db_config db ENABLE_QPSG 0\ndo_eqp_test analyze3-1.1.3.104 {\n  SELECT sum(y) FROM t1 WHERE x>$l AND x<$u\n} {0 0 0 {SCAN TABLE t1}}\n\ndo_test analyze3-1.1.4 {\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>200 AND x<300 }\n} {199 0 14850}\ndo_test analyze3-1.1.5 {\n  set l [string range \"200\" 0 end]\n  set u [string range \"300\" 0 end]\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }\n} {199 0 14850}\ndo_test analyze3-1.1.6 {\n  set l [expr int(200)]\n  set u [expr int(300)]\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }\n} {199 0 14850}\ndo_test analyze3-1.1.7 {\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>0 AND x<1100 }\n} {999 999 499500}\ndo_test analyze3-1.1.8 {\n  set l [string range \"0\" 0 end]\n  set u [string range \"1100\" 0 end]\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }\n} {999 999 499500}\ndo_test analyze3-1.1.9 {\n  set l [expr int(0)]\n  set u [expr int(1100)]\n  sf_execsql { SELECT sum(y) FROM t1 WHERE x>$l AND x<$u }\n} {999 999 499500}\n\n\n# The following tests are similar to the block above. The difference is\n# that the indexed column has TEXT affinity in this case. In the tests\n# above the affinity is INTEGER.\n#\ndo_test analyze3-1.2.1 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t2(x TEXT, y);\n      INSERT INTO t2 SELECT * FROM t1;\n      CREATE INDEX i2 ON t2(x);\n    COMMIT;\n    ANALYZE;\n  }\n} {}\ndo_execsql_test analyze3-2.1.x {\n  SELECT count(*) FROM t2 WHERE x>1 AND x<2;\n  SELECT count(*) FROM t2 WHERE x>0 AND x<99;\n} {200 990}\ndo_eqp_test analyze3-1.2.2 {\n  SELECT sum(y) FROM t2 WHERE x>1 AND x<2\n} {0 0 0 {SEARCH TABLE t2 USING INDEX i2 (x>? AND x<?)}}\ndo_eqp_test analyze3-1.2.3 {\n  SELECT sum(y) FROM t2 WHERE x>0 AND x<99\n} {0 0 0 {SCAN TABLE t2}}\n\ndo_test analyze3-1.2.4 {\n  sf_execsql { SELECT sum(y) FROM t2 WHERE x>12 AND x<20 }\n} {161 0 4760}\ndo_test analyze3-1.2.5 {\n  set l [string range \"12\" 0 end]\n  set u [string range \"20\" 0 end]\n  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}\n} {161 0 text text 4760}\ndo_test analyze3-1.2.6 {\n  set l [expr int(12)]\n  set u [expr int(20)]\n  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}\n} {161 0 integer integer 4760}\ndo_test analyze3-1.2.7 {\n  sf_execsql { SELECT sum(y) FROM t2 WHERE x>0 AND x<99 }\n} {999 999 490555}\ndo_test analyze3-1.2.8 {\n  set l [string range \"0\" 0 end]\n  set u [string range \"99\" 0 end]\n  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}\n} {999 999 text text 490555}\ndo_test analyze3-1.2.9 {\n  set l [expr int(0)]\n  set u [expr int(99)]\n  sf_execsql {SELECT typeof($l), typeof($u), sum(y) FROM t2 WHERE x>$l AND x<$u}\n} {999 999 integer integer 490555}\n\n# Same tests a third time. This time, column x has INTEGER affinity and\n# is not the leftmost column of the table. This triggered a bug causing\n# SQLite to use sub-optimal query plans in 3.6.18 and earlier.\n#\ndo_test analyze3-1.3.1 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t3(y TEXT, x INTEGER);\n      INSERT INTO t3 SELECT y, x FROM t1;\n      CREATE INDEX i3 ON t3(x);\n    COMMIT;\n    ANALYZE;\n  }\n} {}\ndo_execsql_test analyze3-1.3.x {\n  SELECT count(*) FROM t3 WHERE x>200 AND x<300;\n  SELECT count(*) FROM t3 WHERE x>0 AND x<1100\n} {99 1000}\ndo_eqp_test analyze3-1.3.2 {\n  SELECT sum(y) FROM t3 WHERE x>200 AND x<300\n} {0 0 0 {SEARCH TABLE t3 USING INDEX i3 (x>? AND x<?)}}\ndo_eqp_test analyze3-1.3.3 {\n  SELECT sum(y) FROM t3 WHERE x>0 AND x<1100\n} {0 0 0 {SCAN TABLE t3}}\n\ndo_test analyze3-1.3.4 {\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>200 AND x<300 }\n} {199 0 14850}\ndo_test analyze3-1.3.5 {\n  set l [string range \"200\" 0 end]\n  set u [string range \"300\" 0 end]\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }\n} {199 0 14850}\ndo_test analyze3-1.3.6 {\n  set l [expr int(200)]\n  set u [expr int(300)]\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }\n} {199 0 14850}\ndo_test analyze3-1.3.7 {\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>0 AND x<1100 }\n} {999 999 499500}\ndo_test analyze3-1.3.8 {\n  set l [string range \"0\" 0 end]\n  set u [string range \"1100\" 0 end]\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }\n} {999 999 499500}\ndo_test analyze3-1.3.9 {\n  set l [expr int(0)]\n  set u [expr int(1100)]\n  sf_execsql { SELECT sum(y) FROM t3 WHERE x>$l AND x<$u }\n} {999 999 499500}\n\n#-------------------------------------------------------------------------\n# Test that the values of bound SQL variables may be used for the LIKE\n# optimization.\n#\ndrop_all_tables\ndo_test analyze3-2.1 {\n  execsql {\n    PRAGMA case_sensitive_like=off;\n    BEGIN;\n    CREATE TABLE t1(a, b TEXT COLLATE nocase);\n    CREATE INDEX i1 ON t1(b);\n  }\n  for {set i 0} {$i < 1000} {incr i} {\n    set t \"\"\n    append t [lindex {a b c d e f g h i j} [expr $i/100]]\n    append t [lindex {a b c d e f g h i j} [expr ($i/10)%10]]\n    append t [lindex {a b c d e f g h i j} [expr ($i%10)]]\n    execsql { INSERT INTO t1 VALUES($i, $t) }\n  }\n  execsql COMMIT\n} {}\ndo_eqp_test analyze3-2.2 {\n  SELECT count(a) FROM t1 WHERE b LIKE 'a%'\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b>? AND b<?)}}\ndo_eqp_test analyze3-2.3 {\n  SELECT count(a) FROM t1 WHERE b LIKE '%a'\n} {0 0 0 {SCAN TABLE t1}}\n\n# Return the first argument if like_match_blobs is true (the default)\n# or the second argument if not\n#\nproc ilmb {a b} {\n  ifcapable like_match_blobs {return $a}\n  return $b\n}\n\ndo_test analyze3-2.4 {\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE 'a%' }\n} [list [ilmb 102 101] 0 100]\ndo_test analyze3-2.5 {\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE '%a' }\n} {999 999 100}\n\ndo_test analyze3-2.6 {\n  set like \"a%\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} [list [ilmb 102 101] 0 100]\ndo_test analyze3-2.7 {\n  set like \"%a\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} {999 999 100}\ndo_test analyze3-2.8 {\n  set like \"a\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} [list [ilmb 102 101] 0 0]\ndo_test analyze3-2.9 {\n  set like \"ab\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} [list [ilmb 12 11] 0 0]\ndo_test analyze3-2.10 {\n  set like \"abc\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} [list [ilmb 3 2] 0 1]\ndo_test analyze3-2.11 {\n  set like \"a_c\"\n  sf_execsql { SELECT count(*) FROM t1 WHERE b LIKE $like }\n} [list [ilmb 102 101] 0 10]\n\n\n#-------------------------------------------------------------------------\n# This block of tests checks that statements are correctly marked as\n# expired when the values bound to any parameters that may affect the \n# query plan are modified.\n#\ndrop_all_tables\ndb auth auth\nproc auth {args} {\n  set ::auth 1\n  return SQLITE_OK\n}\n\ndo_test analyze3-3.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(b);\n  }\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i, $i) }\n  }\n  execsql COMMIT\n  execsql ANALYZE\n} {}\ndo_test analyze3-3.2.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE b>?\" -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.2.2 {\n  sqlite3_bind_text $S 1 \"abc\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.2.4 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.2.5 {\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE b=?\" -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.2.6 {\n  sqlite3_bind_text $S 1 \"abc\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.2.7 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.4.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE a=? AND b>?\" -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.4.2 {\n  sqlite3_bind_text $S 1 \"abc\" 3\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.4.3 {\n  sqlite3_bind_text $S 2 \"def\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.4.4 {\n  sqlite3_bind_text $S 2 \"ghi\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.4.5 {\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.4.6 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.5.1 {\n  set S [sqlite3_prepare_v2 db {\n    SELECT * FROM t1 WHERE a IN (\n      ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10,\n      ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,\n      ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31\n    ) AND b>?32;\n  } -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.5.2 {\n  sqlite3_bind_text $S 31 \"abc\" 3\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.5.3 {\n  sqlite3_bind_text $S 32 \"def\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.5.5 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.6.1 {\n  set S [sqlite3_prepare_v2 db {\n    SELECT * FROM t1 WHERE a IN (\n      ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10,\n      ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,\n      ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32\n    ) AND b>?33;\n  } -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.6.2 {\n  sqlite3_bind_text $S 32 \"abc\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.6.3 {\n  sqlite3_bind_text $S 33 \"def\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.6.5 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.7.1 {\n  set S [sqlite3_prepare_v2 db {\n    SELECT * FROM t1 WHERE a IN (\n      ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?33,\n      ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20,\n      ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32\n    ) AND b>?10;\n  } -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.7.2 {\n  sqlite3_bind_text $S 32 \"abc\" 3\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.7.3 {\n  sqlite3_bind_text $S 33 \"def\" 3\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.7.4 {\n  sqlite3_bind_text $S 10 \"def\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.7.6 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-3.8.1 {\n  execsql {\n    CREATE TABLE t4(x, y TEXT COLLATE NOCASE);\n    CREATE INDEX i4 ON t4(y);\n  }\n} {}\ndo_test analyze3-3.8.2 {\n  set S [sqlite3_prepare_v2 db {\n    SELECT * FROM t4 WHERE x != ? AND y LIKE ?\n  } -1 dummy]\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.8.3 {\n  sqlite3_bind_text $S 1 \"abc\" 3\n  sqlite3_expired $S\n} {0}\ndo_test analyze3-3.8.4 {\n  sqlite3_bind_text $S 2 \"def\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.7 {\n  sqlite3_bind_text $S 2 \"ghi%\" 4\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.8 {\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.9 {\n  sqlite3_bind_text $S 2 \"ghi%def\" 7\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.10 {\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.11 {\n  sqlite3_bind_text $S 2 \"%ab\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.12 {\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.12 {\n  sqlite3_bind_text $S 2 \"%de\" 3\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.13 {\n  sqlite3_expired $S\n} {1}\ndo_test analyze3-3.8.14 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# These tests check that errors encountered while repreparing an SQL\n# statement within sqlite3Reprepare() are handled correctly.\n#\n\n# Check a schema error.\n#\ndo_test analyze3-4.1.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE a=? AND b>?\" -1 dummy]\n  sqlite3_step $S\n} {SQLITE_DONE}\ndo_test analyze3-4.1.2 {\n  sqlite3_reset $S\n  sqlite3_bind_text $S 2 \"abc\" 3\n  execsql { DROP TABLE t1 }\n  sqlite3_step $S\n} {SQLITE_ERROR}\ndo_test analyze3-4.1.3 {\n  sqlite3_finalize $S\n} {SQLITE_ERROR}\n\n# Check an authorization error.\n#\ndo_test analyze3-4.2.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(b);\n  }\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i, $i) }\n  }\n  execsql COMMIT\n  execsql ANALYZE\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE a=? AND b>?\" -1 dummy]\n  sqlite3_step $S\n} {SQLITE_DONE}\ndb auth auth\nproc auth {args} {\n  if {[lindex $args 0] == \"SQLITE_READ\"} {return SQLITE_DENY}\n  return SQLITE_OK\n}\ndo_test analyze3-4.2.2 {\n  sqlite3_reset $S\n  sqlite3_bind_text $S 2 \"abc\" 3\n  sqlite3_step $S\n} {SQLITE_AUTH}\ndo_test analyze3-4.2.4 {\n  sqlite3_finalize $S\n} {SQLITE_AUTH}\n\n# Check the effect of an authorization error that occurs in a re-prepare\n# performed by sqlite3_step() is the same as one that occurs within\n# sqlite3Reprepare().\n#\ndo_test analyze3-4.3.1 {\n  db auth {}\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE a=? AND b>?\" -1 dummy]\n  execsql { CREATE TABLE t2(d, e, f) }\n  db auth auth\n  sqlite3_step $S\n} {SQLITE_AUTH}\ndo_test analyze3-4.3.2 {\n  sqlite3_finalize $S\n} {SQLITE_AUTH}\ndb auth {}\n\n#-------------------------------------------------------------------------\n# Test that modifying bound variables using the clear_bindings() or\n# transfer_bindings() APIs works.\n#\n#   analyze3-5.1.*: sqlite3_clear_bindings()\n#   analyze3-5.2.*: sqlite3_transfer_bindings()\n#\ndo_test analyze3-5.1.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(x TEXT COLLATE NOCASE);\n    CREATE INDEX i1 ON t1(x);\n    INSERT INTO t1 VALUES('aaa');\n    INSERT INTO t1 VALUES('abb');\n    INSERT INTO t1 VALUES('acc');\n    INSERT INTO t1 VALUES('baa');\n    INSERT INTO t1 VALUES('bbb');\n    INSERT INTO t1 VALUES('bcc');\n  }\n\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE x LIKE ?\" -1 dummy]\n  sqlite3_bind_text $S 1 \"a%\" 2\n  set R [list]\n  while { \"SQLITE_ROW\" == [sqlite3_step $S] } {\n    lappend R [sqlite3_column_text $S 0]\n  }\n  concat [sqlite3_reset $S] $R\n} {SQLITE_OK aaa abb acc}\ndo_test analyze3-5.1.2 {\n  sqlite3_clear_bindings $S\n  set R [list]\n  while { \"SQLITE_ROW\" == [sqlite3_step $S] } {\n    lappend R [sqlite3_column_text $S 0]\n  }\n  concat [sqlite3_reset $S] $R\n} {SQLITE_OK}\ndo_test analyze3-5.1.3 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test analyze3-5.1.1 {\n  set S1 [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE x LIKE ?\" -1 dummy]\n  sqlite3_bind_text $S1 1 \"b%\" 2\n  set R [list]\n  while { \"SQLITE_ROW\" == [sqlite3_step $S1] } {\n    lappend R [sqlite3_column_text $S1 0]\n  }\n  concat [sqlite3_reset $S1] $R\n} {SQLITE_OK baa bbb bcc}\n\ndo_test analyze3-5.1.2 {\n  set S2 [sqlite3_prepare_v2 db \"SELECT * FROM t1 WHERE x = ?\" -1 dummy]\n  sqlite3_bind_text $S2 1 \"a%\" 2\n  sqlite3_transfer_bindings $S2 $S1\n  set R [list]\n  while { \"SQLITE_ROW\" == [sqlite3_step $S1] } {\n    lappend R [sqlite3_column_text $S1 0]\n  }\n  concat [sqlite3_reset $S1] $R\n} {SQLITE_OK aaa abb acc}\ndo_test analyze3-5.1.3 {\n  sqlite3_finalize $S2\n  sqlite3_finalize $S1\n} {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n\ndo_test analyze3-6.1 {\n  execsql { DROP TABLE IF EXISTS t1 }\n  execsql BEGIN\n  execsql { CREATE TABLE t1(a, b, c) }\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql \"INSERT INTO t1 VALUES([expr $i/100], 'x', [expr $i/10])\"\n  }\n  execsql {\n    CREATE INDEX i1 ON t1(a, b);\n    CREATE INDEX i2 ON t1(c);\n  }\n  execsql COMMIT\n  execsql ANALYZE\n} {}\n\ndo_eqp_test analyze3-6-3 {\n  SELECT * FROM t1 WHERE a = 5 AND c = 13;\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}\n\ndo_eqp_test analyze3-6-2 {\n  SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13;\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}\n\n#-----------------------------------------------------------------------------\n# 2015-04-20.\n# Memory leak in sqlite3Stat4ProbeFree().  (Discovered while fuzzing.)\n#\ndo_execsql_test analyze-7.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1,1,'0000');\n  CREATE INDEX t0b ON t1(b);\n  ANALYZE;\n  SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1);\n} {}\n\n# At one point duplicate stat1 entries were causing a memory leak.\n#\nreset_db\ndo_execsql_test 7.2 {\n  CREATE TABLE t1(a,b,c);\n  CREATE INDEX t1a ON t1(a);\n  ANALYZE;\n  SELECT * FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');\n  INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1a','12000');\n  ANALYZE sqlite_master;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze4.test",
    "content": "# 2011 January 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. This file \n# implements tests for ANALYZE to verify that multiple rows containing\n# a NULL value count as distinct rows for the purposes of analyze \n# statistics.\n#\n# Also include test cases for collating sequences on indices.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test analyze4-1.0 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1b ON t1(b);\n    INSERT INTO t1 VALUES(1,NULL);\n    INSERT INTO t1 SELECT a+1, b FROM t1;\n    INSERT INTO t1 SELECT a+2, b FROM t1;\n    INSERT INTO t1 SELECT a+4, b FROM t1;\n    INSERT INTO t1 SELECT a+8, b FROM t1;\n    INSERT INTO t1 SELECT a+16, b FROM t1;\n    INSERT INTO t1 SELECT a+32, b FROM t1;\n    INSERT INTO t1 SELECT a+64, b FROM t1;\n    ANALYZE;\n  }\n\n  # Should choose the t1a index since it is more specific than t1b.\n  db eval {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=5 AND b IS NULL}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\n\n# Verify that the t1b index shows that it does not narrow down the\n# search any at all.\n#\ndo_test analyze4-1.1 {\n  db eval {\n    SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;\n  }\n} {t1a {128 1} t1b {128 128}}\n\n# Change half of the b values from NULL to a constant.  Verify\n# that the number of rows selected in stat1 is half the total \n# number of rows.\n#\ndo_test analyze4-1.2 {\n  db eval {\n    UPDATE t1 SET b='x' WHERE a%2;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;\n  }\n} {t1a {128 1} t1b {128 64}}\n\n# Change the t1.b values all back to NULL.  Add columns t1.c and t1.d.\n# Create a multi-column indices using t1.b and verify that ANALYZE \n# processes them correctly.\n#\ndo_test analyze4-1.3 {\n  db eval {\n    UPDATE t1 SET b=NULL;\n    ALTER TABLE t1 ADD COLUMN c;\n    ALTER TABLE t1 ADD COLUMN d;\n    UPDATE t1 SET c=a/4, d=a/2;\n    CREATE INDEX t1bcd ON t1(b,c,d);\n    CREATE INDEX t1cdb ON t1(c,d,b);\n    CREATE INDEX t1cbd ON t1(c,b,d);\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t1' ORDER BY idx;\n  }\n} {t1a {128 1} t1b {128 128} t1bcd {128 128 4 2} t1cbd {128 4 4 2} t1cdb {128 4 2 2}}\n\n# Verify that collating sequences are taken into account when computing\n# ANALYZE statistics.\n#\ndo_test analyze4-2.0 {\n  db eval {\n    CREATE TABLE t2(\n      x INTEGER PRIMARY KEY,\n      a TEXT COLLATE nocase,\n      b TEXT COLLATE rtrim,\n      c TEXT COLLATE binary\n    );\n    CREATE INDEX t2a ON t2(a);\n    CREATE INDEX t2b ON t2(b);\n    CREATE INDEX t2c ON t2(c);\n    CREATE INDEX t2c2 ON t2(c COLLATE nocase);\n    CREATE INDEX t2c3 ON t2(c COLLATE rtrim);\n    INSERT INTO t2 VALUES(1, 'abc', 'abc', 'abc');\n    INSERT INTO t2 VALUES(2, 'abC', 'abC', 'abC');\n    INSERT INTO t2 VALUES(3, 'abc ', 'abc ', 'abc ');\n    INSERT INTO t2 VALUES(4, 'abC ', 'abC ', 'abC ');\n    INSERT INTO t2 VALUES(5, 'aBc', 'aBc', 'aBc');\n    INSERT INTO t2 VALUES(6, 'aBC', 'aBC', 'aBC');\n    INSERT INTO t2 VALUES(7, 'aBc ', 'aBc ', 'aBc ');\n    INSERT INTO t2 VALUES(8, 'aBC ', 'aBC ', 'aBC ');\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 WHERE tbl='t2' ORDER BY idx;\n  }\n} {t2a {8 4} t2b {8 2} t2c {8 1} t2c2 {8 4} t2c3 {8 2}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze5.test",
    "content": "# 2011 January 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for SQLite library.  The focus of the tests\n# in this file is the use of the sqlite_stat4 histogram data on tables\n# with many repeated values and only a few distinct values.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\nset testprefix analyze5\n\nproc eqp {sql {db db}} {\n  uplevel execsql [list \"EXPLAIN QUERY PLAN $sql\"] $db\n}\n\nproc alpha {blob} {\n  set ret \"\"\n  foreach c [split $blob {}] {\n    if {[string is alpha $c]} {append ret $c}\n  }\n  return $ret\n}\ndb func alpha alpha\n\ndb func lindex lindex\n\nunset -nocomplain i t u v w x y z\ndo_test analyze5-1.0 {\n  db eval {CREATE TABLE t1(t,u,v TEXT COLLATE nocase,w,x,y,z)}\n  for {set i 0} {$i < 1000} {incr i} {\n    set y [expr {$i>=25 && $i<=50}]\n    set z [expr {($i>=400) + ($i>=700) + ($i>=875)}]\n    set x $z\n    set w $z\n    set t [expr {$z+0.5}]\n    switch $z {\n      0 {set u \"alpha\"; unset x}\n      1 {set u \"bravo\"}\n      2 {set u \"charlie\"}\n      3 {set u \"delta\"; unset w}\n    }\n    if {$i%2} {set v $u} {set v [string toupper $u]}\n    db eval {INSERT INTO t1 VALUES($t,$u,$v,$w,$x,$y,$z)}\n  }\n  db eval { \n    CREATE INDEX t1t ON t1(t);  -- 0.5, 1.5, 2.5, and 3.5\n    CREATE INDEX t1u ON t1(u);  -- text\n    CREATE INDEX t1v ON t1(v);  -- mixed case text\n    CREATE INDEX t1w ON t1(w);  -- integers 0, 1, 2 and a few NULLs\n    CREATE INDEX t1x ON t1(x);  -- integers 1, 2, 3 and many NULLs\n    CREATE INDEX t1y ON t1(y);  -- integers 0 and very few 1s\n    CREATE INDEX t1z ON t1(z);  -- integers 0, 1, 2, and 3\n    ANALYZE;\n  }\n  ifcapable stat4 {\n    db eval {\n      SELECT DISTINCT lindex(test_decode(sample),0) \n        FROM sqlite_stat4 WHERE idx='t1u' ORDER BY nlt;\n    }\n  } else {\n    db eval {\n      SELECT sample FROM sqlite_stat3 WHERE idx='t1u' ORDER BY nlt;\n    }\n  }\n} {alpha bravo charlie delta}\n\ndo_test analyze5-1.1 {\n  ifcapable stat4 {\n    db eval {\n      SELECT DISTINCT lower(lindex(test_decode(sample), 0)) \n        FROM sqlite_stat4 WHERE idx='t1v' ORDER BY 1\n    }\n  } else {\n    db eval {\n      SELECT lower(sample) FROM sqlite_stat3 WHERE idx='t1v' ORDER BY 1\n    }\n  }\n} {alpha bravo charlie delta}\nifcapable stat4 {\n  do_test analyze5-1.2 {\n    db eval {SELECT idx, count(*) FROM sqlite_stat4 GROUP BY 1 ORDER BY 1}\n  } {t1t 8 t1u 8 t1v 8 t1w 8 t1x 8 t1y 9 t1z 8}\n} else {\n  do_test analyze5-1.2 {\n    db eval {SELECT idx, count(*) FROM sqlite_stat3 GROUP BY 1 ORDER BY 1}\n  } {t1t 4 t1u 4 t1v 4 t1w 4 t1x 4 t1y 2 t1z 4}\n}\n\n# Verify that range queries generate the correct row count estimates\n#\nforeach {testid where index rows} {\n    1  {z>=0 AND z<=0}       t1z  400\n    2  {z>=1 AND z<=1}       t1z  300\n    3  {z>=2 AND z<=2}       t1z  175\n    4  {z>=3 AND z<=3}       t1z  125\n    5  {z>=4 AND z<=4}       t1z    1\n    6  {z>=-1 AND z<=-1}     t1z    1\n    7  {z>1 AND z<3}         t1z  175\n    8  {z>0 AND z<100}       t1z  600\n    9  {z>=1 AND z<100}      t1z  600\n   10  {z>1 AND z<100}       t1z  300\n   11  {z>=2 AND z<100}      t1z  300\n   12  {z>2 AND z<100}       t1z  125\n   13  {z>=3 AND z<100}      t1z  125\n   14  {z>3 AND z<100}       t1z    1\n   15  {z>=4 AND z<100}      t1z    1\n   16  {z>=-100 AND z<=-1}   t1z    1\n   17  {z>=-100 AND z<=0}    t1z  400\n   18  {z>=-100 AND z<0}     t1z    1\n   19  {z>=-100 AND z<=1}    t1z  700\n   20  {z>=-100 AND z<2}     t1z  700\n   21  {z>=-100 AND z<=2}    t1z  875\n   22  {z>=-100 AND z<3}     t1z  875\n  \n   31  {z>=0.0 AND z<=0.0}   t1z  400\n   32  {z>=1.0 AND z<=1.0}   t1z  300\n   33  {z>=2.0 AND z<=2.0}   t1z  175\n   34  {z>=3.0 AND z<=3.0}   t1z  125\n   35  {z>=4.0 AND z<=4.0}   t1z    1\n   36  {z>=-1.0 AND z<=-1.0} t1z    1\n   37  {z>1.5 AND z<3.0}     t1z  174\n   38  {z>0.5 AND z<100}     t1z  599\n   39  {z>=1.0 AND z<100}    t1z  600\n   40  {z>1.5 AND z<100}     t1z  299\n   41  {z>=2.0 AND z<100}    t1z  300\n   42  {z>2.1 AND z<100}     t1z  124\n   43  {z>=3.0 AND z<100}    t1z  125\n   44  {z>3.2 AND z<100}     t1z    1\n   45  {z>=4.0 AND z<100}    t1z    1\n   46  {z>=-100 AND z<=-1.0} t1z    1\n   47  {z>=-100 AND z<=0.0}  t1z  400\n   48  {z>=-100 AND z<0.0}   t1z    1\n   49  {z>=-100 AND z<=1.0}  t1z  700\n   50  {z>=-100 AND z<2.0}   t1z  700\n   51  {z>=-100 AND z<=2.0}  t1z  875\n   52  {z>=-100 AND z<3.0}   t1z  875\n  \n  101  {z=-1}                t1z    1\n  102  {z=0}                 t1z  400\n  103  {z=1}                 t1z  300\n  104  {z=2}                 t1z  175\n  105  {z=3}                 t1z  125\n  106  {z=4}                 t1z    1\n  107  {z=-10.0}             t1z    1\n  108  {z=0.0}               t1z  400\n  109  {z=1.0}               t1z  300\n  110  {z=2.0}               t1z  175\n  111  {z=3.0}               t1z  125\n  112  {z=4.0}               t1z    1\n  113  {z=1.5}               t1z    1\n  114  {z=2.5}               t1z    1\n  \n  201  {z IN (-1)}           t1z    1\n  202  {z IN (0)}            t1z  400\n  203  {z IN (1)}            t1z  300\n  204  {z IN (2)}            t1z  175\n  205  {z IN (3)}            t1z  125\n  206  {z IN (4)}            t1z    1\n  207  {z IN (0.5)}          t1z    1\n  208  {z IN (0,1)}          t1z  700\n  209  {z IN (0,1,2)}        t1z  875\n  210  {z IN (0,1,2,3)}      {}   100\n  211  {z IN (0,1,2,3,4,5)}  {}   100\n  212  {z IN (1,2)}          t1z  475\n  213  {z IN (2,3)}          t1z  300\n  214  {z=3 OR z=2}          t1z  300\n  215  {z IN (-1,3)}         t1z  126\n  216  {z=-1 OR z=3}         t1z  126\n\n  300  {y=0}                 t1y  974\n  301  {y=1}                 t1y   26\n  302  {y=0.1}               t1y    1\n\n  400  {x IS NULL}           t1x  400\n\n} {\n  # Verify that the expected index is used with the expected row count\n  # No longer valid due to an EXPLAIN QUERY PLAN output format change\n  # do_test analyze5-1.${testid}a {\n  #   set x [lindex [eqp \"SELECT * FROM t1 WHERE $where\"] 3]\n  #   set idx {}\n  #   regexp {INDEX (t1.) } $x all idx\n  #   regexp {~([0-9]+) rows} $x all nrow\n  #   list $idx $nrow\n  # } [list $index $rows]\n\n  # Verify that the same result is achieved regardless of whether or not\n  # the index is used\n  do_test analyze5-1.${testid}b {\n    set w2 [string map {y +y z +z} $where]\n    set a1 [db eval \"SELECT rowid FROM t1 NOT INDEXED WHERE $w2\\\n                     ORDER BY +rowid\"]\n    set a2 [db eval \"SELECT rowid FROM t1 WHERE $where ORDER BY +rowid\"]\n    if {$a1==$a2} {\n      set res ok\n    } else {\n      set res \"a1=\\[$a1\\] a2=\\[$a2\\]\"\n    }\n    set res\n  } {ok}\n}\n\n# Increase the number of NULLs in column x\n#\ndb eval {\n   UPDATE t1 SET x=NULL;\n   UPDATE t1 SET x=rowid\n    WHERE rowid IN (SELECT rowid FROM t1 ORDER BY random() LIMIT 5);\n   ANALYZE;\n}\n\n# Verify that range queries generate the correct row count estimates\n#\nforeach {testid where index rows} {\n  500  {x IS NULL AND u='charlie'}         t1u  17\n  501  {x=1 AND u='charlie'}               t1x   1\n  502  {x IS NULL}                         t1x 995\n  503  {x=1}                               t1x   1\n  504  {x IS NOT NULL}                     t1x   2\n  505  {+x IS NOT NULL}                     {} 500\n  506  {upper(x) IS NOT NULL}               {} 500\n\n} {\n  # Verify that the expected index is used with the expected row count\n  # No longer valid due to an EXPLAIN QUERY PLAN format change\n  # do_test analyze5-1.${testid}a {\n  #   set x [lindex [eqp \"SELECT * FROM t1 WHERE $where\"] 3]\n  #   set idx {}\n  #   regexp {INDEX (t1.) } $x all idx\n  #   regexp {~([0-9]+) rows} $x all nrow\n  #   list $idx $nrow\n  # } [list $index $rows]\n\n  # Verify that the same result is achieved regardless of whether or not\n  # the index is used\n  do_test analyze5-1.${testid}b {\n    set w2 [string map {y +y z +z} $where]\n    set a1 [db eval \"SELECT rowid FROM t1 NOT INDEXED WHERE $w2\\\n                     ORDER BY +rowid\"]\n    set a2 [db eval \"SELECT rowid FROM t1 WHERE $where ORDER BY +rowid\"]\n    if {$a1==$a2} {\n      set res ok\n    } else {\n      set res \"a1=\\[$a1\\] a2=\\[$a2\\]\"\n    }\n    set res\n  } {ok}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze6.test",
    "content": "# 2011 March 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for SQLite library.  The focus of the tests\n# in this file a corner-case query planner optimization involving the\n# join order of two tables of different sizes.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\nset testprefix analyze6\n\nproc eqp {sql {db db}} {\n  uplevel execsql [list \"EXPLAIN QUERY PLAN $sql\"] $db\n}\n\ndo_test analyze6-1.0 {\n  db eval {\n    CREATE TABLE cat(x INT, yz TEXT);\n    CREATE UNIQUE INDEX catx ON cat(x);\n    /* Give cat 16 unique integers */\n    INSERT INTO cat(x) VALUES(1);\n    INSERT INTO cat(x) VALUES(2);\n    INSERT INTO cat(x) SELECT x+2 FROM cat;\n    INSERT INTO cat(x) SELECT x+4 FROM cat;\n    INSERT INTO cat(x) SELECT x+8 FROM cat;\n\n    CREATE TABLE ev(y INT);\n    CREATE INDEX evy ON ev(y);\n    /* ev will hold 32 copies of 16 integers found in cat */\n    INSERT INTO ev SELECT x FROM cat;\n    INSERT INTO ev SELECT x FROM cat;\n    INSERT INTO ev SELECT y FROM ev;\n    INSERT INTO ev SELECT y FROM ev;\n    INSERT INTO ev SELECT y FROM ev;\n    INSERT INTO ev SELECT y FROM ev;\n    ANALYZE;\n    SELECT count(*) FROM cat;\n    SELECT count(*) FROM ev;\n  }\n} {16 512}\n\n# The lowest cost plan is to scan CAT and for each integer there, do a single\n# lookup of the first corresponding entry in EV then read off the equal values\n# in EV.  (Prior to the 2011-03-04 enhancement to where.c, this query would\n# have used EV for the outer loop instead of CAT - which was about 3x slower.)\n#\ndo_test analyze6-1.1 {\n  eqp {SELECT count(*) FROM ev, cat WHERE x=y}\n} {0 0 1 {SCAN TABLE cat USING COVERING INDEX catx} 0 1 0 {SEARCH TABLE ev USING COVERING INDEX evy (y=?)}}\n\n# The same plan is chosen regardless of the order of the tables in the\n# FROM clause.\n#\ndo_test analyze6-1.2 {\n  eqp {SELECT count(*) FROM cat, ev WHERE x=y}\n} {0 0 0 {SCAN TABLE cat USING COVERING INDEX catx} 0 1 1 {SEARCH TABLE ev USING COVERING INDEX evy (y=?)}}\n\n\n# Ticket [83ea97620bd3101645138b7b0e71c12c5498fe3d] 2011-03-30\n# If ANALYZE is run on an empty table, make sure indices are used\n# on the table.\n#\ndo_test analyze6-2.1 {\n  execsql {\n    CREATE TABLE t201(x INTEGER PRIMARY KEY, y UNIQUE, z);\n    CREATE INDEX t201z ON t201(z);\n    ANALYZE;\n  }\n  eqp {SELECT * FROM t201 WHERE z=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}\ndo_test analyze6-2.2 {\n  eqp {SELECT * FROM t201 WHERE y=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}\ndo_test analyze6-2.3 {\n  eqp {SELECT * FROM t201 WHERE x=5}\n} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}\ndo_test analyze6-2.4 {\n  execsql {\n    INSERT INTO t201 VALUES(1,2,3),(2,3,4),(3,4,5);\n    ANALYZE t201;\n  }\n  eqp {SELECT * FROM t201 WHERE z=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}\ndo_test analyze6-2.5 {\n  eqp {SELECT * FROM t201 WHERE y=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}\ndo_test analyze6-2.6 {\n  eqp {SELECT * FROM t201 WHERE x=5}\n} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}\ndo_test analyze6-2.7 {\n  execsql {\n    INSERT INTO t201 VALUES(4,5,7);\n    INSERT INTO t201 SELECT x+100, y+100, z+100 FROM t201;\n    INSERT INTO t201 SELECT x+200, y+200, z+200 FROM t201;\n    INSERT INTO t201 SELECT x+400, y+400, z+400 FROM t201;\n    ANALYZE t201;\n  }\n  eqp {SELECT * FROM t201 WHERE z=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX t201z (z=?)}}\ndo_test analyze6-2.8 {\n  eqp {SELECT * FROM t201 WHERE y=5}\n} {0 0 0 {SEARCH TABLE t201 USING INDEX sqlite_autoindex_t201_1 (y=?)}}\ndo_test analyze6-2.9 {\n  eqp {SELECT * FROM t201 WHERE x=5}\n} {0 0 0 {SEARCH TABLE t201 USING INTEGER PRIMARY KEY (rowid=?)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze7.test",
    "content": "# 2011 April 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# This file implements tests for the ANALYZE command when an idnex\n# name is given as the argument.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# There is nothing to test if ANALYZE is disable for this build.\n#\nifcapable {!analyze||!vtab} {\n  finish_test\n  return\n}\n\n# Generate some test data\n#\ndo_test analyze7-1.0 {\n  load_static_extension db wholenumber\n  execsql {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1b ON t1(b);\n    CREATE INDEX t1cd ON t1(c,d);\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    INSERT INTO t1 SELECT value, value, value/100, value FROM nums\n                    WHERE value BETWEEN 1 AND 256;\n    EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;\n  }\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test analyze7-1.1 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\ndo_test analyze7-1.2 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}\n\n# Run an analyze on one of the three indices.  Verify that this\n# effects the row-count estimate on the one query that uses that\n# one index.\n#\ndo_test analyze7-2.0 {\n  execsql {ANALYZE t1a;}\n  db cache flush\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test analyze7-2.1 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\ndo_test analyze7-2.2 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}\n\n# Verify that since the query planner now things that t1a is more\n# selective than t1b, it prefers to use t1a.\n#\ndo_test analyze7-2.3 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\n\n# Run an analysis on another of the three indices.  Verify  that this\n# new analysis works and does not disrupt the previous analysis.\n#\ndo_test analyze7-3.0 {\n  execsql {ANALYZE t1cd;}\n  db cache flush;\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test analyze7-3.1 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=123;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\ndo_test analyze7-3.2.1 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=?;}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}\nifcapable stat4||stat3 {\n  # If ENABLE_STAT4 is defined, SQLite comes up with a different estimated\n  # row count for (c=2) than it does for (c=?).\n  do_test analyze7-3.2.2 {\n    execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}\n} else {\n  # If ENABLE_STAT4 is not defined, the expected row count for (c=2) is the\n  # same as that for (c=?).\n  do_test analyze7-3.2.3 {\n    execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=2;}\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=?)}}\n}\ndo_test analyze7-3.3 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND b=123}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\n\nifcapable {!stat4 && !stat3} {\n  do_test analyze7-3.4 {\n    execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND b=123}\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\n  do_test analyze7-3.5 {\n    execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=123 AND c=123}\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\n}\ndo_test analyze7-3.6 {\n  execsql {EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE c=123 AND d=123 AND b=123}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1cd (c=? AND d=?)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze8.test",
    "content": "# 2011 August 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for SQLite library.  The focus of the tests\n# in this file is testing the capabilities of sqlite_stat3.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\nset testprefix analyze8\n\nproc eqp {sql {db db}} {\n  uplevel execsql [list \"EXPLAIN QUERY PLAN $sql\"] $db\n}\n\n# Scenario:\n#\n#    Two indices.  One has mostly singleton entries, but for a few\n#    values there are hundreds of entries.  The other has 10-20\n#    entries per value.\n#\n# Verify that the query planner chooses the first index for the singleton\n# entries and the second index for the others.\n#\ndo_test 1.0 {\n  db eval {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1b ON t1(b);\n    CREATE INDEX t1c ON t1(c);\n  }\n  for {set i 0} {$i<1000} {incr i} {\n    if {$i%2==0} {set a $i} {set a [expr {($i%8)*100}]}\n    set b [expr {$i/10}]\n    set c [expr {$i/8}]\n    set c [expr {$c*$c*$c}]\n    db eval {INSERT INTO t1 VALUES($a,$b,$c,$i)}\n  }\n  db eval {ANALYZE}\n} {}\n\n# The a==100 comparison is expensive because there are many rows\n# with a==100.  And so for those cases, choose the t1b index.\n#\n# Buf ro a==99 and a==101, there are far fewer rows so choose\n# the t1a index.\n#\ndo_test 1.1 {\n  eqp {SELECT * FROM t1 WHERE a=100 AND b=55}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\ndo_test 1.2 {\n  eqp {SELECT * FROM t1 WHERE a=99 AND b=55}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test 1.3 {\n  eqp {SELECT * FROM t1 WHERE a=101 AND b=55}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test 1.4 {\n  eqp {SELECT * FROM t1 WHERE a=100 AND b=56}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\ndo_test 1.5 {\n  eqp {SELECT * FROM t1 WHERE a=99 AND b=56}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test 1.6 {\n  eqp {SELECT * FROM t1 WHERE a=101 AND b=56}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test 2.1 {\n  eqp {SELECT * FROM t1 WHERE a=100 AND b BETWEEN 50 AND 54}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}\n\n# There are many more values of c between 0 and 100000 than there are\n# between 800000 and 900000.  So t1c is more selective for the latter\n# range.\n# \n# Test 3.2 is a little unstable. It depends on the planner estimating\n# that (b BETWEEN 30 AND 34) will match more rows than (c BETWEEN\n# 800000 AND 900000). Which is a pretty close call (50 vs. 32), so\n# the planner could get it wrong with an unlucky set of samples. This\n# case happens to work, but others (\"b BETWEEN 40 AND 44\" for example) \n# will fail.\n#\ndo_execsql_test 3.0 {\n  SELECT count(*) FROM t1 WHERE b BETWEEN 30 AND 34;\n  SELECT count(*) FROM t1 WHERE c BETWEEN 0 AND 100000;\n  SELECT count(*) FROM t1 WHERE c BETWEEN 800000 AND 900000;\n} {50 376 32}\ndo_test 3.1 {\n  eqp {SELECT * FROM t1 WHERE b BETWEEN 30 AND 34 AND c BETWEEN 0 AND 100000}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}\ndo_test 3.2 {\n  eqp {SELECT * FROM t1\n       WHERE b BETWEEN 30 AND 34 AND c BETWEEN 800000 AND 900000}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}\ndo_test 3.3 {\n  eqp {SELECT * FROM t1 WHERE a=100 AND c BETWEEN 0 AND 100000}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1a (a=?)}}\ndo_test 3.4 {\n  eqp {SELECT * FROM t1\n       WHERE a=100 AND c BETWEEN 800000 AND 900000}\n} {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyze9.test",
    "content": "# 2013 August 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains automated tests used to verify that the sqlite_stat4\n# functionality is working.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix analyze9\n\nifcapable !stat4 {\n  finish_test\n  return\n}\n\nproc s {blob} {\n  set ret \"\"\n  binary scan $blob c* bytes\n  foreach b $bytes {\n    set t [binary format c $b]\n    if {[string is print $t]} {\n      append ret $t\n    } else {\n      append ret .\n    }\n  }\n  return $ret\n}\ndb function s s\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a TEXT, b TEXT); \n  INSERT INTO t1 VALUES('(0)', '(0)');\n  INSERT INTO t1 VALUES('(1)', '(1)');\n  INSERT INTO t1 VALUES('(2)', '(2)');\n  INSERT INTO t1 VALUES('(3)', '(3)');\n  INSERT INTO t1 VALUES('(4)', '(4)');\n  CREATE INDEX i1 ON t1(a, b);\n} {}\n\n\ndo_execsql_test 1.1 {\n  ANALYZE;\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT tbl,idx,nEq,nLt,nDLt,test_decode(sample) FROM sqlite_stat4;\n} {\n  t1 i1 {1 1 1} {0 0 0} {0 0 0} {(0) (0) 1}\n  t1 i1 {1 1 1} {1 1 1} {1 1 1} {(1) (1) 2}\n  t1 i1 {1 1 1} {2 2 2} {2 2 2} {(2) (2) 3}\n  t1 i1 {1 1 1} {3 3 3} {3 3 3} {(3) (3) 4}\n  t1 i1 {1 1 1} {4 4 4} {4 4 4} {(4) (4) 5}\n}\n\nif {[permutation] != \"utf16\"} {\n  do_execsql_test 1.3 {\n    SELECT tbl,idx,nEq,nLt,nDLt,s(sample) FROM sqlite_stat4;\n  } {\n    t1 i1 {1 1 1} {0 0 0} {0 0 0} ....(0)(0)\n    t1 i1 {1 1 1} {1 1 1} {1 1 1} ....(1)(1).\n    t1 i1 {1 1 1} {2 2 2} {2 2 2} ....(2)(2).\n    t1 i1 {1 1 1} {3 3 3} {3 3 3} ....(3)(3).\n    t1 i1 {1 1 1} {4 4 4} {4 4 4} ....(4)(4).\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# This is really just to test SQL user function \"test_decode\".\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES('some text', 14, NULL);\n  INSERT INTO t1 VALUES(22.0, NULL, x'656667');\n  CREATE INDEX i1 ON t1(a, b, c);\n  ANALYZE;\n  SELECT test_decode(sample) FROM sqlite_stat4;\n} {\n  {22.0 NULL x'656667' 2} \n  {{some text} 14 NULL 1}\n}\n\n#-------------------------------------------------------------------------\n# \nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  BEGIN;\n}\n\ndo_test 3.2 {\n  for {set i 0} {$i < 1000} {incr i} {\n    set a [expr $i / 10]\n    set b [expr int(rand() * 15.0)]\n    execsql { INSERT INTO t2 VALUES($a, $b) }\n  }\n  execsql COMMIT\n} {}\n\ndb func lindex lindex\n\n# Each value of \"a\" occurs exactly 10 times in the table.\n#\ndo_execsql_test 3.3.1 {\n  SELECT count(*) FROM t2 GROUP BY a;\n} [lrange [string repeat \"10 \" 100] 0 99]\n\n# The first element in the \"nEq\" list of all samples should therefore be 10.\n#\ndo_execsql_test 3.3.2 {\n  ANALYZE;\n  SELECT lindex(nEq, 0) FROM sqlite_stat4;\n} [lrange [string repeat \"10 \" 100] 0 23]\n\n#-------------------------------------------------------------------------\n# \ndo_execsql_test 3.4 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1, 1, 'one-a');\n  INSERT INTO t1 VALUES(11, 1, 'one-b');\n  INSERT INTO t1 VALUES(21, 1, 'one-c');\n  INSERT INTO t1 VALUES(31, 1, 'one-d');\n  INSERT INTO t1 VALUES(41, 1, 'one-e');\n  INSERT INTO t1 VALUES(51, 1, 'one-f');\n  INSERT INTO t1 VALUES(61, 1, 'one-g');\n  INSERT INTO t1 VALUES(71, 1, 'one-h');\n  INSERT INTO t1 VALUES(81, 1, 'one-i');\n  INSERT INTO t1 VALUES(91, 1, 'one-j');\n  INSERT INTO t1 SELECT a+1,2,'two' || substr(c,4) FROM t1;\n  INSERT INTO t1 SELECT a+2,3,'three'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+3,4,'four'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+4,5,'five'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+5,6,'six'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\t\n  CREATE INDEX t1b ON t1(b);\n  ANALYZE;\n  SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND 60;\n} {three-d three-e three-f}\n\n\n#-------------------------------------------------------------------------\n# These tests verify that the sample selection for stat4 appears to be \n# working as designed.\n#\n\nreset_db\ndb func lindex lindex\ndb func lrange lrange\n\ndo_execsql_test 4.0 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(c, b, a);\n}\n\n\nproc insert_filler_rows_n {iStart args} {\n  set A(-ncopy) 1\n  set A(-nval) 1\n\n  foreach {k v} $args {\n    if {[info exists A($k)]==0} { error \"no such option: $k\" }\n    set A($k) $v\n  }\n  if {[llength $args] % 2} {\n    error \"option requires an argument: [lindex $args end]\"\n  }\n\n  for {set i 0} {$i < $A(-nval)} {incr i} {\n    set iVal [expr $iStart+$i]\n    for {set j 0} {$j < $A(-ncopy)} {incr j} {\n      execsql { INSERT INTO t1 VALUES($iVal, $iVal, $iVal) }\n    }\n  }\n}\n\ndo_test 4.1 {\n  execsql { BEGIN }\n  insert_filler_rows_n  0  -ncopy 10 -nval 19\n  insert_filler_rows_n 20  -ncopy  1 -nval 100\n\n  execsql {\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'a');\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'b');\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'c');\n\n    INSERT INTO t1(c, b, a) VALUES(200, 2, 'e');\n    INSERT INTO t1(c, b, a) VALUES(200, 2, 'f');\n\n    INSERT INTO t1(c, b, a) VALUES(201, 3, 'g');\n    INSERT INTO t1(c, b, a) VALUES(201, 4, 'h');\n\n    ANALYZE;\n    SELECT count(*) FROM sqlite_stat4;\n    SELECT count(*) FROM t1;\n  }\n} {24 297}\n\ndo_execsql_test 4.2 {\n  SELECT \n    neq,\n    lrange(nlt, 0, 2),\n    lrange(ndlt, 0, 2),\n    lrange(test_decode(sample), 0, 2)\n    FROM sqlite_stat4\n  ORDER BY rowid LIMIT 16;\n} {\n  {10 10 10 1} {0 0 0} {0 0 0} {0 0 0}\n  {10 10 10 1} {10 10 10} {1 1 1} {1 1 1}\n  {10 10 10 1} {20 20 20} {2 2 2} {2 2 2}\n  {10 10 10 1} {30 30 30} {3 3 3} {3 3 3}\n  {10 10 10 1} {40 40 40} {4 4 4} {4 4 4}\n  {10 10 10 1} {50 50 50} {5 5 5} {5 5 5}\n  {10 10 10 1} {60 60 60} {6 6 6} {6 6 6}\n  {10 10 10 1} {70 70 70} {7 7 7} {7 7 7}\n  {10 10 10 1} {80 80 80} {8 8 8} {8 8 8}\n  {10 10 10 1} {90 90 90} {9 9 9} {9 9 9}\n  {10 10 10 1} {100 100 100} {10 10 10} {10 10 10}\n  {10 10 10 1} {110 110 110} {11 11 11} {11 11 11}\n  {10 10 10 1} {120 120 120} {12 12 12} {12 12 12}\n  {10 10 10 1} {130 130 130} {13 13 13} {13 13 13}\n  {10 10 10 1} {140 140 140} {14 14 14} {14 14 14}\n  {10 10 10 1} {150 150 150} {15 15 15} {15 15 15}\n}\n\ndo_execsql_test 4.3 {\n  SELECT \n    neq,\n    lrange(nlt, 0, 2),\n    lrange(ndlt, 0, 2),\n    lrange(test_decode(sample), 0, 1)\n    FROM sqlite_stat4\n  ORDER BY rowid DESC LIMIT 2;\n} {\n  {2 1 1 1} {295 296 296} {120 122 125} {201 4} \n  {5 3 1 1} {290 290 290} {119 119 119} {200 1}\n}\n\ndo_execsql_test 4.4 { SELECT count(DISTINCT c) FROM t1 WHERE c<201 } 120\ndo_execsql_test 4.5 { SELECT count(DISTINCT c) FROM t1 WHERE c<200 } 119\n\n# Check that the perioidic samples are present.\ndo_execsql_test 4.6 {\n  SELECT count(*) FROM sqlite_stat4\n  WHERE lindex(test_decode(sample), 3) IN \n    ('34', '68', '102', '136', '170', '204', '238', '272')\n} {8}\n\nreset_db\ndo_test 4.7 {\n  execsql { \n    BEGIN;\n    CREATE TABLE t1(o,t INTEGER PRIMARY KEY);\n    CREATE INDEX i1 ON t1(o);\n  }\n  for {set i 0} {$i<10000} {incr i [expr (($i<1000)?1:10)]} {\n    execsql { INSERT INTO t1 VALUES('x', $i) }\n  }\n  execsql {\n    COMMIT;\n    ANALYZE;\n    SELECT count(*) FROM sqlite_stat4;\n  }\n} {8}\ndo_execsql_test 4.8 {\n  SELECT test_decode(sample) FROM sqlite_stat4;\n} {\n  {x 211} {x 423} {x 635} {x 847} \n  {x 1590} {x 3710} {x 5830} {x 7950}\n}\n\n\n#-------------------------------------------------------------------------\n# The following would cause a crash at one point.\n#\nreset_db\ndo_execsql_test 5.1 {\n  PRAGMA encoding = 'utf-16';\n  CREATE TABLE t0(v);\n  ANALYZE;\n}\n\n#-------------------------------------------------------------------------\n# This was also crashing (corrupt sqlite_stat4 table).\n#\nreset_db\ndo_execsql_test 6.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(3, 3);\n  INSERT INTO t1 VALUES(4, 4);\n  INSERT INTO t1 VALUES(5, 5);\n  ANALYZE;\n  PRAGMA writable_schema = 1;\n  CREATE TEMP TABLE x1 AS\n    SELECT tbl,idx,neq,nlt,ndlt,sample FROM sqlite_stat4\n    ORDER BY (rowid%5), rowid;\n  DELETE FROM sqlite_stat4;\n  INSERT INTO sqlite_stat4 SELECT * FROM x1;\n  PRAGMA writable_schema = 0;\n  ANALYZE sqlite_master;\n}\ndo_execsql_test 6.2 {\n  SELECT * FROM t1 WHERE a = 'abc';\n}\n\n#-------------------------------------------------------------------------\n# The following tests experiment with adding corrupted records to the\n# 'sample' column of the sqlite_stat4 table.\n#\nreset_db\nsqlite3_db_config_lookaside db 0 0 0\n\ndatabase_may_be_corrupt\ndo_execsql_test 7.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(3, 3);\n  INSERT INTO t1 VALUES(4, 4);\n  INSERT INTO t1 VALUES(5, 5);\n  ANALYZE;\n  UPDATE sqlite_stat4 SET sample = X'' WHERE rowid = 1;\n  ANALYZE sqlite_master;\n}\n\ndo_execsql_test 7.2 {\n  UPDATE sqlite_stat4 SET sample = X'FFFF';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 1;\n} {1 1}\n\ndo_execsql_test 7.3 {\n  ANALYZE;\n  UPDATE sqlite_stat4 SET neq = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 1;\n} {1 1}\n\ndo_execsql_test 7.4 {\n  ANALYZE;\n  UPDATE sqlite_stat4 SET ndlt = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 3;\n} {3 3}\n\ndo_execsql_test 7.5 {\n  ANALYZE;\n  UPDATE sqlite_stat4 SET nlt = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 5;\n} {5 5}\n\ndatabase_never_corrupt\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.1 {\n  CREATE TABLE t1(x TEXT);\n  CREATE INDEX i1 ON t1(x);\n  INSERT INTO t1 VALUES('1');\n  INSERT INTO t1 VALUES('2');\n  INSERT INTO t1 VALUES('3');\n  INSERT INTO t1 VALUES('4');\n  ANALYZE;\n}\ndo_execsql_test 8.2 {\n  SELECT * FROM t1 WHERE x = 3;\n} {3}\n\n#-------------------------------------------------------------------------\n# Check that the bug fixed by [91733bc485] really is fixed.\n#\nreset_db\ndo_execsql_test 9.1 {\n  CREATE TABLE t1(a, b, c, d, e);\n  CREATE INDEX i1 ON t1(a, b, c, d);\n  CREATE INDEX i2 ON t1(e);\n}\ndo_test 9.2 {\n  execsql BEGIN;\n  for {set i 0} {$i < 100} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])\"\n  }\n  for {set i 0} {$i < 20} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', 101, $i)\"\n  }\n  for {set i 102} {$i < 200} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])\"\n  }\n  execsql COMMIT\n  execsql ANALYZE\n} {}\n\ndo_eqp_test 9.3.1 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=101 AND e=5;\n} {/t1 USING INDEX i2/}\ndo_eqp_test 9.3.2 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=99 AND e=5;\n} {/t1 USING INDEX i1/}\n\nset value_d [expr 101]\ndo_eqp_test 9.4.1 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5\n} {/t1 USING INDEX i2/}\nset value_d [expr 99]\ndo_eqp_test 9.4.2 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5\n} {/t1 USING INDEX i1/}\n\n#-------------------------------------------------------------------------\n# Check that the planner takes stat4 data into account when considering\n# \"IS NULL\" and \"IS NOT NULL\" constraints.\n#\ndo_execsql_test 10.1.1 {\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE t3(a, b);\n  CREATE INDEX t3a ON t3(a);\n  CREATE INDEX t3b ON t3(b);\n}\ndo_test 10.1.2 {\n  for {set i 1} {$i < 100} {incr i} {\n    if {$i>90} { set a $i } else { set a NULL }\n    set b [expr $i % 5]\n    execsql \"INSERT INTO t3 VALUES($a, $b)\"\n  }\n  execsql ANALYZE\n} {}\ndo_eqp_test 10.1.3 {\n  SELECT * FROM t3 WHERE a IS NULL AND b = 2\n} {/t3 USING INDEX t3b/}\ndo_eqp_test 10.1.4 {\n  SELECT * FROM t3 WHERE a IS NOT NULL AND b = 2\n} {/t3 USING INDEX t3a/}\n\ndo_execsql_test 10.2.1 {\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE t3(x, a, b);\n  CREATE INDEX t3a ON t3(x, a);\n  CREATE INDEX t3b ON t3(x, b);\n}\ndo_test 10.2.2 {\n  for {set i 1} {$i < 100} {incr i} {\n    if {$i>90} { set a $i } else { set a NULL }\n    set b [expr $i % 5]\n    execsql \"INSERT INTO t3 VALUES('xyz', $a, $b)\"\n  }\n  execsql ANALYZE\n} {}\ndo_eqp_test 10.2.3 {\n  SELECT * FROM t3 WHERE x = 'xyz' AND a IS NULL AND b = 2\n} {/t3 USING INDEX t3b/}\ndo_eqp_test 10.2.4 {\n  SELECT * FROM t3 WHERE x = 'xyz' AND a IS NOT NULL AND b = 2\n} {/t3 USING INDEX t3a/}\n\n#-------------------------------------------------------------------------\n# Check that stat4 data is used correctly with non-default collation\n# sequences.\n#\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t4(a COLLATE nocase, b);\n    CREATE INDEX t4a ON t4(a);\n    CREATE INDEX t4b ON t4(b);\n  }\n  2 {\n    CREATE TABLE t4(a, b);\n    CREATE INDEX t4a ON t4(a COLLATE nocase);\n    CREATE INDEX t4b ON t4(b);\n  }\n} {\n  drop_all_tables\n  do_test 11.$tn.1 { execsql $schema } {}\n\n  do_test 11.$tn.2 {\n    for {set i 0} {$i < 100} {incr i} {\n      if { ($i % 10)==0 } { set a ABC } else { set a DEF }\n      set b [expr $i % 5]\n        execsql { INSERT INTO t4 VALUES($a, $b) }\n    }\n    execsql ANALYZE\n  } {}\n\n  do_eqp_test 11.$tn.3 {\n    SELECT * FROM t4 WHERE a = 'def' AND b = 3;\n  } {/t4 USING INDEX t4b/}\n\n  if {$tn==1} {\n    set sql \"SELECT * FROM t4 WHERE a = 'abc' AND b = 3;\"\n    do_eqp_test 11.$tn.4 $sql {/t4 USING INDEX t4a/}\n  } else {\n\n    set sql \"SELECT * FROM t4 WHERE a = 'abc' COLLATE nocase AND b = 3;\"\n    do_eqp_test 11.$tn.5 $sql {/t4 USING INDEX t4a/}\n\n    set sql \"SELECT * FROM t4 WHERE a COLLATE nocase = 'abc' AND b = 3;\"\n    do_eqp_test 11.$tn.6 $sql {/t4 USING INDEX t4a/}\n  }\n}\n\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t4(x, a COLLATE nocase, b);\n    CREATE INDEX t4a ON t4(x, a);\n    CREATE INDEX t4b ON t4(x, b);\n  }\n  2 {\n    CREATE TABLE t4(x, a, b);\n    CREATE INDEX t4a ON t4(x, a COLLATE nocase);\n    CREATE INDEX t4b ON t4(x, b);\n  }\n} {\n  drop_all_tables\n  do_test 12.$tn.1 { execsql $schema } {}\n\n  do_test 12.$tn.2 {\n    for {set i 0} {$i < 100} {incr i} {\n      if { ($i % 10)==0 } { set a ABC } else { set a DEF }\n      set b [expr $i % 5]\n        execsql { INSERT INTO t4 VALUES(X'abcdef', $a, $b) }\n    }\n    execsql ANALYZE\n  } {}\n\n  do_eqp_test 12.$tn.3 {\n    SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'def' AND b = 3;\n  } {/t4 USING INDEX t4b/}\n\n  if {$tn==1} {\n    set sql \"SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'abc' AND b = 3;\"\n    do_eqp_test 12.$tn.4 $sql {/t4 USING INDEX t4a/}\n  } else {\n    set sql {\n      SELECT * FROM t4 WHERE x=X'abcdef' AND a = 'abc' COLLATE nocase AND b = 3\n    }\n    do_eqp_test 12.$tn.5 $sql {/t4 USING INDEX t4a/}\n    set sql {\n      SELECT * FROM t4 WHERE x=X'abcdef' AND a COLLATE nocase = 'abc' AND b = 3\n    }\n    do_eqp_test 12.$tn.6 $sql {/t4 USING INDEX t4a/}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Check that affinities are taken into account when using stat4 data to\n# estimate the number of rows scanned by a rowid constraint.\n#\ndrop_all_tables\ndo_test 13.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c, d);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b, c);\n  }\n  for {set i 0} {$i<100} {incr i} {\n    if {$i %2} {set a abc} else {set a def}\n    execsql { INSERT INTO t1(rowid, a, b, c) VALUES($i, $a, $i, $i) }\n  }\n  execsql ANALYZE\n} {}\ndo_eqp_test 13.2.1 {\n  SELECT * FROM t1 WHERE a='abc' AND rowid<15 AND b<12\n} {/SEARCH TABLE t1 USING INDEX i1/}\ndo_eqp_test 13.2.2 {\n  SELECT * FROM t1 WHERE a='abc' AND rowid<'15' AND b<12\n} {/SEARCH TABLE t1 USING INDEX i1/}\ndo_eqp_test 13.3.1 {\n  SELECT * FROM t1 WHERE a='abc' AND rowid<100 AND b<12\n} {/SEARCH TABLE t1 USING INDEX i2/}\ndo_eqp_test 13.3.2 {\n  SELECT * FROM t1 WHERE a='abc' AND rowid<'100' AND b<12\n} {/SEARCH TABLE t1 USING INDEX i2/}\n\n#-------------------------------------------------------------------------\n# Check also that affinities are taken into account when using stat4 data \n# to estimate the number of rows scanned by any other constraint on a \n# column other than the leftmost.\n#\ndrop_all_tables\ndo_test 14.1 {\n  execsql { CREATE TABLE t1(a, b INTEGER, c) }\n  for {set i 0} {$i<100} {incr i} {\n    set c [expr $i % 3]\n    execsql { INSERT INTO t1 VALUES('ott', $i, $c) }\n  }\n  execsql {\n    CREATE INDEX i1 ON t1(a, b);\n    CREATE INDEX i2 ON t1(c);\n    ANALYZE;\n  }\n} {}\ndo_eqp_test 13.2.1 {\n  SELECT * FROM t1 WHERE a='ott' AND b<10 AND c=1\n} {/SEARCH TABLE t1 USING INDEX i1/}\ndo_eqp_test 13.2.2 {\n  SELECT * FROM t1 WHERE a='ott' AND b<'10' AND c=1\n} {/SEARCH TABLE t1 USING INDEX i1/}\n\n#-------------------------------------------------------------------------\n# By default, 16 non-periodic samples are collected for the stat4 table.\n# The following tests attempt to verify that the most common keys are\n# being collected.\n#\nproc check_stat4 {tn} {\n  db eval ANALYZE\n  db eval {SELECT a, b, c, d FROM t1} {\n    incr k($a)\n    incr k([list $a $b])\n    incr k([list $a $b $c])\n    if { [info exists k([list $a $b $c $d])]==0 } { incr nRow }\n    incr k([list $a $b $c $d])\n  }\n\n  set L [list]\n  foreach key [array names k] {\n    lappend L [list $k($key) $key]\n  }\n\n  set nSample $nRow\n  if {$nSample>16} {set nSample 16}\n\n  set nThreshold [lindex [lsort -decr -integer -index 0 $L] [expr $nSample-1] 0]\n  foreach key [array names k] {\n    if {$k($key)>$nThreshold} {\n      set expect($key) 1\n    }\n    if {$k($key)==$nThreshold} {\n      set possible($key) 1\n    }\n  }\n\n\n  set nPossible [expr $nSample - [llength [array names expect]]]\n\n  #puts \"EXPECT: [array names expect]\"\n  #puts \"POSSIBLE($nPossible/[array size possible]): [array names possible]\"\n  #puts \"HAVE: [db eval {SELECT test_decode(sample) FROM sqlite_stat4 WHERE idx='i1'}]\"\n\n  db eval {SELECT test_decode(sample) AS s FROM sqlite_stat4 WHERE idx='i1'} {\n    set seen 0\n    for {set i 0} {$i<4} {incr i} {\n      unset -nocomplain expect([lrange $s 0 $i])\n      if {[info exists possible([lrange $s 0 $i])]} {\n        set seen 1\n        unset -nocomplain possible([lrange $s 0 $i])\n      }\n    }\n    if {$seen} {incr nPossible -1}\n  }\n  if {$nPossible<0} {set nPossible 0}\n\n  set res [list [llength [array names expect]] $nPossible]\n  uplevel [list do_test $tn [list set {} $res] {0 0}]\n}\n\ndrop_all_tables\ndo_test 14.1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE INDEX i1 ON t1(a,b,c,d);\n  }\n  for {set i 0} {$i < 160} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i,$i,$i,$i) }\n    if {($i % 10)==0} { execsql { INSERT INTO t1 VALUES($i,$i,$i,$i) } }\n  }\n} {}\ncheck_stat4 14.1.2\n\ndo_test 14.2.1 {\n  execsql { DELETE FROM t1 }\n  for {set i 0} {$i < 1600} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i/10,$i/17,$i/27,$i/37) }\n  }\n} {}\ncheck_stat4 14.2.2\n\ndo_test 14.3.1 {\n  for {set i 0} {$i < 10} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n    execsql { INSERT INTO t1 VALUES($i*50,$i*50,$i*50,$i*50) }\n  }\n} {}\ncheck_stat4 14.3.2\n\ndo_test 14.4.1 {\n  execsql {DELETE FROM t1}\n  for {set i 1} {$i < 160} {incr i} {\n    set b [expr $i % 10]\n    if {$b==0 || $b==2} {set b 1}\n    execsql { INSERT INTO t1 VALUES($i/10,$b,$i,$i) }\n  }\n} {}\ncheck_stat4 14.4.2\ndb func lrange lrange\ndb func lindex lindex\ndo_execsql_test 14.4.3 {\n  SELECT lrange(test_decode(sample), 0, 1) AS s FROM sqlite_stat4\n  WHERE lindex(s, 1)=='1' ORDER BY rowid\n} {\n  {0 1} {1 1} {2 1} {3 1} \n  {4 1} {5 1} {6 1} {7 1} \n  {8 1} {9 1} {10 1} {11 1} \n  {12 1} {13 1} {14 1} {15 1}\n}\n\n#-------------------------------------------------------------------------\n# Test that nothing untoward happens if the stat4 table contains entries\n# for indexes that do not exist. Or NULL values in the idx column.\n# Or NULL values in any of the other columns.\n#\ndrop_all_tables\ndo_execsql_test 15.1 {\n  CREATE TABLE x1(a, b, UNIQUE(a, b));\n  INSERT INTO x1 VALUES(1, 2);\n  INSERT INTO x1 VALUES(3, 4);\n  INSERT INTO x1 VALUES(5, 6);\n  ANALYZE;\n  INSERT INTO sqlite_stat4 VALUES(NULL, NULL, NULL, NULL, NULL, NULL);\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.2 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.3 {\n  INSERT INTO sqlite_stat4 VALUES(42, 42, 42, 42, 42, 42);\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.4 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.5 {\n  UPDATE sqlite_stat1 SET stat = NULL;\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.6 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.7 {\n  ANALYZE;\n  UPDATE sqlite_stat1 SET tbl = 'no such tbl';\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.8 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.9 {\n  ANALYZE;\n  UPDATE sqlite_stat4 SET neq = NULL, nlt=NULL, ndlt=NULL;\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.10 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\n# This is just for coverage....\ndo_execsql_test 15.11 {\n  ANALYZE;\n  UPDATE sqlite_stat1 SET stat = stat || ' unordered';\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.12 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\n#-------------------------------------------------------------------------\n# Test that allocations used for sqlite_stat4 samples are included in\n# the quantity returned by SQLITE_DBSTATUS_SCHEMA_USED.\n#\nset one [string repeat x 1000]\nset two [string repeat x 2000]\ndo_test 16.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, UNIQUE(a));\n    INSERT INTO t1 VALUES($one);\n    ANALYZE;\n  }\n  set nByte [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]\n\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, UNIQUE(a));\n    INSERT INTO t1 VALUES($two);\n    ANALYZE;\n  }\n  set nByte2 [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]\n  puts -nonewline \" (nByte=$nByte nByte2=$nByte2)\"\n\n  expr {$nByte2 > $nByte+900 && $nByte2 < $nByte+1100}\n} {1}\n\n#-------------------------------------------------------------------------\n# Test that stat4 data may be used with partial indexes.\n#\ndo_test 17.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, b, c, d);\n    CREATE INDEX i1 ON t1(a, b) WHERE d IS NOT NULL;\n    INSERT INTO t1 VALUES(-1, -1, -1, NULL);\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n  }\n\n  for {set i 0} {$i < 32} {incr i} {\n    if {$i<8} {set b 0} else { set b $i }\n    execsql { INSERT INTO t1 VALUES($i%2, $b, $i/2, 'abc') }\n  }\n  execsql {ANALYZE main.t1}\n} {}\n\ndo_catchsql_test 17.1.2 {\n  ANALYZE temp.t1;\n} {1 {no such table: temp.t1}}\n\ndo_eqp_test 17.2 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=10 AND c=10;\n} {/USING INDEX i1/}\ndo_eqp_test 17.3 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=0 AND c=10;\n} {/USING INDEX i1/}\n\ndo_execsql_test 17.4 {\n  CREATE INDEX i2 ON t1(c, d);\n  ANALYZE main.i2;\n}\ndo_eqp_test 17.5 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=10 AND c=10;\n} {/USING INDEX i1/}\ndo_eqp_test 17.6 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=0 AND c=10;\n} {/USING INDEX i2/}\n\n#-------------------------------------------------------------------------\n#\ndo_test 18.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n  }\n  for {set i 0} {$i < 9} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n    }\n  }\n  execsql ANALYZE\n  execsql { SELECT count(*) FROM sqlite_stat4 }\n} {9}\n\n#-------------------------------------------------------------------------\n# For coverage.\n#\nifcapable view {\n  do_test 19.1 {\n    reset_db \n    execsql {\n      CREATE TABLE t1(x, y);\n      CREATE INDEX i1 ON t1(x, y);\n      CREATE VIEW v1 AS SELECT * FROM t1;\n      ANALYZE;\n    }\n  } {}\n}\nifcapable auth {\n  proc authproc {op args} {\n    if {$op == \"SQLITE_ANALYZE\"} { return \"SQLITE_DENY\" }\n    return \"SQLITE_OK\"\n  }\n  do_test 19.2 {\n    reset_db \n    db auth authproc\n    execsql {\n      CREATE TABLE t1(x, y);\n      CREATE VIEW v1 AS SELECT * FROM t1;\n    }\n    catchsql ANALYZE\n  } {1 {not authorized}}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nproc r {args} { expr rand() }\ndb func r r\ndb func lrange lrange\ndo_test 20.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE INDEX i1 ON t1(a,b,c,d);\n  }\n  for {set i 0} {$i < 16} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, r(), r(), r());\n      INSERT INTO t1 VALUES($i, $i,  r(), r());\n      INSERT INTO t1 VALUES($i, $i,  $i,  r());\n      INSERT INTO t1 VALUES($i, $i,  $i,  $i);\n      INSERT INTO t1 VALUES($i, $i,  $i,  $i);\n      INSERT INTO t1 VALUES($i, $i,  $i,  r());\n      INSERT INTO t1 VALUES($i, $i,  r(), r());\n      INSERT INTO t1 VALUES($i, r(), r(), r());\n    }\n  }\n} {}\ndo_execsql_test 20.2 { ANALYZE }\nfor {set i 0} {$i<16} {incr i} {\n    set val \"$i $i $i $i\"\n    do_execsql_test 20.3.$i {\n      SELECT count(*) FROM sqlite_stat4 \n      WHERE lrange(test_decode(sample), 0, 3)=$val\n    } {1}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\n\ndo_execsql_test 21.0 {\n  CREATE TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a);\n}\n\ndo_test 21.1 {\n  for {set i 1} {$i < 100} {incr i} {\n    execsql { \n      INSERT INTO t2 VALUES(CASE WHEN $i < 80 THEN 'one' ELSE 'two' END, $i) \n    }\n  }\n  execsql ANALYZE\n} {}\n\n# Condition (a='one') matches 80% of the table. (rowid<10) reduces this to\n# 10%, but (rowid<50) only reduces it to 50%. So in the first case below\n# the index is used. In the second, it is not. \n#\ndo_eqp_test 21.2 {\n  SELECT * FROM t2 WHERE a='one' AND rowid < 10\n} {/*USING INDEX i2 (a=? AND rowid<?)*/}\ndo_eqp_test 21.3 {\n  SELECT * FROM t2 WHERE a='one' AND rowid < 50\n} {/*USING INTEGER PRIMARY KEY*/}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 22.0 {\n  CREATE TABLE t3(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;\n}\ndo_execsql_test 22.1 {\n  WITH r(x) AS (\n    SELECT 1\n    UNION ALL\n    SELECT x+1 FROM r WHERE x<=100\n  )\n\n  INSERT INTO t3 SELECT\n    CASE WHEN (x>45 AND x<96) THEN 'B' ELSE 'A' END,  /* Column \"a\" */\n    x,                                                /* Column \"b\" */\n    CASE WHEN (x<51) THEN 'one' ELSE 'two' END,       /* Column \"c\" */\n    x                                                 /* Column \"d\" */\n  FROM r;\n\n  CREATE INDEX i3 ON t3(c);\n  CREATE INDEX i4 ON t3(d);\n  ANALYZE;\n}\n\n# Expression (c='one' AND a='B') matches 5 table rows. But (c='one' AND a=A')\n# matches 45. Expression (d<?) matches 20. Neither index is a covering index.\n#\n# Therefore, with stat4 data, SQLite prefers (c='one' AND a='B') over (d<20),\n# and (d<20) over (c='one' AND a='A').\nforeach {tn where res} {\n  1 \"c='one' AND a='B' AND d < 20\"   {/*INDEX i3 (c=? AND a=?)*/}\n  2 \"c='one' AND a='A' AND d < 20\"   {/*INDEX i4 (d<?)*/}\n} {\n  do_eqp_test 22.2.$tn \"SELECT * FROM t3 WHERE $where\" $res\n}\n\nproc int_to_char {i} {\n  set ret \"\"\n  set char [list a b c d e f g h i j]\n  foreach {div} {1000 100 10 1} {\n    append ret [lindex $char [expr ($i / $div) % 10]]\n  }\n  set ret\n}\ndb func int_to_char int_to_char\n\ndo_execsql_test 23.0 {\n  CREATE TABLE t4(\n    a COLLATE nocase, b, c, \n    d, e, f, \n    PRIMARY KEY(c, b, a)\n  ) WITHOUT ROWID;\n  CREATE INDEX i41 ON t4(e);\n  CREATE INDEX i42 ON t4(f);\n\n  WITH data(a, b, c, d, e, f) AS (\n    SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0\n    UNION ALL\n    SELECT \n      int_to_char(f+1), b, c, d, (e+1) % 2, f+1\n    FROM data WHERE f<1024\n  )\n  INSERT INTO t4 SELECT a, b, c, d, e, f FROM data;\n  ANALYZE;\n} {}\n\ndo_eqp_test 23.1 {\n  SELECT * FROM t4 WHERE \n    (e=1 AND b='xyz' AND c='zyx' AND a<'AEA') AND f<300\n  -- Formerly used index i41.  But i41 is not a covering index whereas\n  -- the PRIMARY KEY is a covering index, and so as of 2017-10-15, the\n  -- PRIMARY KEY is preferred.\n} {\n  0 0 0 {SEARCH TABLE t4 USING PRIMARY KEY (c=? AND b=? AND a<?)}\n}\ndo_eqp_test 23.2 {\n  SELECT * FROM t4 WHERE \n    (e=1 AND b='xyz' AND c='zyx' AND a<'JJJ') AND f<300\n} {\n  0 0 0 {SEARCH TABLE t4 USING INDEX i42 (f<?)}\n}\n\ndo_execsql_test 24.0 {\n  CREATE TABLE t5(c, d, b, e, a, PRIMARY KEY(a, b, c)) WITHOUT ROWID;\n  WITH data(a, b, c, d, e) AS (\n    SELECT 'z', 'y', 0, 0, 0\n    UNION ALL\n    SELECT \n      a, CASE WHEN b='y' THEN 'n' ELSE 'y' END, c+1, e/250, e+1 \n    FROM data\n    WHERE e<1000\n  )\n  INSERT INTO t5(a, b, c, d, e) SELECT * FROM data;\n  CREATE INDEX t5d ON t5(d);\n  CREATE INDEX t5e ON t5(e);\n  ANALYZE;\n}\n\nforeach {tn where eqp} {\n  1 \"d=0 AND a='z' AND b='n' AND e<200\" {/*t5d (d=? AND a=? AND b=?)*/}\n  2 \"d=0 AND a='z' AND b='n' AND e<100\" {/*t5e (e<?)*/}\n\n  3 \"d=0 AND e<300\"                     {/*t5d (d=?)*/}\n  4 \"d=0 AND e<200\"                     {/*t5e (e<?)*/}\n} {\n  do_eqp_test 24.$tn \"SeLeCt * FROM t5 WHERE $where\" $eqp\n}\n\n#-------------------------------------------------------------------------\n# Test that if stat4 data is available but cannot be used because the\n# rhs of a range constraint is a complex expression, the default estimates\n# are used instead.\nifcapable stat4&&cte {\n  do_execsql_test 25.1 {\n    CREATE TABLE t6(a, b);\n    WITH ints(i,j) AS (\n      SELECT 1,1 UNION ALL SELECT i+1,j+1 FROM ints WHERE i<100\n    ) INSERT INTO t6 SELECT * FROM ints;\n    CREATE INDEX aa ON t6(a);\n    CREATE INDEX bb ON t6(b);\n    ANALYZE;\n  }\n\n  # Term (b<?) is estimated at 25%. Better than (a<30) but not as\n  # good as (a<20).\n  do_eqp_test 25.2.1 { SELECT * FROM t6 WHERE a<30 AND b<? } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX bb (b<?)}\n  }\n  do_eqp_test 25.2.2 { SELECT * FROM t6 WHERE a<20 AND b<? } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX aa (a<?)}\n  }\n\n  # Term (b BETWEEN ? AND ?) is estimated at 1/64.\n  do_eqp_test 25.3.1 { \n    SELECT * FROM t6 WHERE a BETWEEN 5 AND 10 AND b BETWEEN ? AND ? \n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX bb (b>? AND b<?)}\n  }\n  \n  # Term (b BETWEEN ? AND 60) is estimated to return roughly 15 rows -\n  # 60 from (b<=60) multiplied by 0.25 for the b>=? term. Better than\n  # (a<20) but not as good as (a<10).\n  do_eqp_test 25.4.1 { \n    SELECT * FROM t6 WHERE a < 10 AND (b BETWEEN ? AND 60)\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX aa (a<?)}\n  }\n  do_eqp_test 25.4.2 { \n    SELECT * FROM t6 WHERE a < 20 AND (b BETWEEN ? AND 60)\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX bb (b>? AND b<?)}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Check that a problem in they way stat4 data is used has been \n# resolved (see below).\n#\nreset_db\ndo_test 26.1.1 {\n  db transaction {\n    execsql { \n      CREATE TABLE t1(x, y, z);\n      CREATE INDEX t1xy ON t1(x, y);\n      CREATE INDEX t1z ON t1(z);\n    }\n    for {set i 0} {$i < 10000} {incr i} {\n      execsql { INSERT INTO t1(x, y) VALUES($i, $i) }\n    }\n    for {set i 0} {$i < 10} {incr i} {\n      execsql {\n        WITH cnt(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM cnt WHERE x<100)\n        INSERT INTO t1(x, y) SELECT 10000+$i, x FROM cnt;\n        INSERT INTO t1(x, y) SELECT 10000+$i, 100;\n      }\n    }\n    execsql {\n      UPDATE t1 SET z = rowid / 20;\n      ANALYZE;\n    }\n  }\n} {}\n\ndo_execsql_test 26.1.2 {\n  SELECT count(*) FROM t1 WHERE x = 10000 AND y < 50;\n} {49}\ndo_execsql_test 26.1.3 {\n  SELECT count(*) FROM t1 WHERE z = 444;\n} {20}\n\n# The analyzer knows that any (z=?) expression matches 20 rows. So it\n# will use index \"t1z\" if the estimate of hits for (x=10000 AND y<50)\n# is greater than 20 rows.\n#\n# And it should be. The analyzer has a stat4 sample as follows:\n#\n#   sample=(x=10000, y=100) nLt=(10000 10099)\n#\n# There should be no other samples that start with (x=10000). So it knows \n# that (x=10000 AND y<50) must match somewhere between 0 and 99 rows, but\n# no more than that. Guessing less than 20 is therefore unreasonable.\n#\n# At one point though, due to a problem in whereKeyStats(), the planner was\n# estimating that (x=10000 AND y<50) would match only 2 rows.\n#\ndo_eqp_test 26.1.4 {\n  SELECT * FROM t1 WHERE x = 10000 AND y < 50 AND z = 444;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1z (z=?)}\n}\n\n\n# This test - 26.2.* - tests that another manifestation of the same problem\n# is no longer present in the library. Assuming:\n# \n#   CREATE INDEX t1xy ON t1(x, y)\n#\n# and that have samples for index t1xy as follows:\n#\n#\n#   sample=('A', 70)        nEq=(100, 2)        nLt=(900, 970)\n#   sample=('B', 70)        nEq=(100, 2)        nLt=(1000, 1070)    \n#\n# the planner should estimate that (x = 'B' AND y > 25) matches 76 rows\n# (70 * 2/3 + 30). Before, due to the problem, the planner was estimating \n# that this matched 100 rows.\n# \nreset_db\ndo_execsql_test 26.2.1 {\n  BEGIN;\n    CREATE TABLE t1(x, y, z);\n    CREATE INDEX i1 ON t1(x, y);\n    CREATE INDEX i2 ON t1(z);\n  \n    WITH \n    cnt(y) AS (SELECT 0 UNION ALL SELECT y+1 FROM cnt WHERE y<99),\n    letters(x) AS (\n      SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'\n    )\n    INSERT INTO t1(x, y) SELECT x, y FROM letters, cnt;\n  \n    WITH\n    letters(x) AS (\n      SELECT 'A' UNION SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'\n    )\n    INSERT INTO t1(x, y) SELECT x, 70 FROM letters;\n  \n    WITH\n    cnt(i) AS (SELECT 0 UNION ALL SELECT i+1 FROM cnt WHERE i<9999)\n    INSERT INTO t1(x, y) SELECT i, i FROM cnt;\n  \n    UPDATE t1 SET z = (rowid / 95);\n    ANALYZE;\n  COMMIT;\n}\n\ndo_eqp_test 26.2.2 {\n  SELECT * FROM t1 WHERE x='B' AND y>25 AND z=?;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX i1 (x=? AND y>?)}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeA.test",
    "content": "# 2013 August 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains automated tests used to verify that the current build\n# (which must be either ENABLE_STAT3 or ENABLE_STAT4) works with both stat3\n# and stat4 data.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix analyzeA\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\n# Populate the stat3 table according to the current contents of the db\n#\nproc populate_stat3 {{bDropTable 1}} {\n  # Open a second connection on database \"test.db\" and run ANALYZE. If this\n  # is an ENABLE_STAT3 build, this is all that is required to create and\n  # populate the sqlite_stat3 table. \n  # \n  sqlite3 db2 test.db\n  execsql { ANALYZE }\n\n  # Now, if this is an ENABLE_STAT4 build, create and populate the \n  # sqlite_stat3 table based on the stat4 data gathered by the ANALYZE\n  # above. Then drop the sqlite_stat4 table.\n  #\n  ifcapable stat4 {\n    db2 func lindex lindex\n    execsql {\n      PRAGMA writable_schema = on;\n      CREATE TABLE sqlite_stat3(tbl,idx,neq,nlt,ndlt,sample);\n      INSERT INTO sqlite_stat3 \n      SELECT DISTINCT tbl, idx, \n        lindex(neq,0), lindex(nlt,0), lindex(ndlt,0), test_extract(sample, 0)\n      FROM sqlite_stat4;\n    } db2\n    if {$bDropTable} { execsql {DROP TABLE sqlite_stat4} db2 }\n    execsql { PRAGMA writable_schema = off }\n  }\n\n  # Modify the database schema cookie to ensure that the other connection\n  # reloads the schema.\n  #\n  execsql {\n    CREATE TABLE obscure_tbl_nm(x);\n    DROP TABLE obscure_tbl_nm;\n  } db2\n  db2 close\n}\n\n# Populate the stat4 table according to the current contents of the db\n#\nproc populate_stat4 {{bDropTable 1}} {\n  sqlite3 db2 test.db\n  execsql { ANALYZE }\n\n  ifcapable stat3 {\n    execsql {\n      PRAGMA writable_schema = on;\n      CREATE TABLE sqlite_stat4(tbl,idx,neq,nlt,ndlt,sample);\n      INSERT INTO sqlite_stat4 \n      SELECT tbl, idx, neq, nlt, ndlt, sqlite_record(sample) \n      FROM sqlite_stat3;\n    } db2\n    if {$bDropTable} { execsql {DROP TABLE sqlite_stat3} db2 }\n    execsql { PRAGMA writable_schema = off }\n  }\n \n  # Modify the database schema cookie to ensure that the other connection\n  # reloads the schema.\n  #\n  execsql {\n    CREATE TABLE obscure_tbl_nm(x);\n    DROP TABLE obscure_tbl_nm;\n  } db2\n  db2 close\n}\n\n# Populate the stat4 table according to the current contents of the db.\n# Leave deceptive data in the stat3 table. This data should be ignored\n# in favour of that from the stat4 table.\n#\nproc populate_both {} {\n  ifcapable stat4 { populate_stat3 0 }\n  ifcapable stat3 { populate_stat4 0 }\n\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA writable_schema = on;\n    UPDATE sqlite_stat3 SET idx = \n      CASE idx WHEN 't1b' THEN 't1c' ELSE 't1b'\n    END;\n    PRAGMA writable_schema = off;\n    CREATE TABLE obscure_tbl_nm(x);\n    DROP TABLE obscure_tbl_nm;\n  } db2\n  db2 close\n}\n\nforeach {tn analyze_cmd} {\n  1 populate_stat4 \n  2 populate_stat3\n  3 populate_both\n} {\n  reset_db\n  do_test 1.$tn.1 {\n    execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT) }\n    for {set i 0} {$i < 100} {incr i} {\n      set c [expr int(pow(1.1,$i)/100)]\n      set b [expr 125 - int(pow(1.1,99-$i))/100]\n      execsql {INSERT INTO t1 VALUES($i, $b, $c)}\n    }\n  } {}\n\n  execsql { CREATE INDEX t1b ON t1(b) }\n  execsql { CREATE INDEX t1c ON t1(c) }\n  $analyze_cmd\n\n  do_execsql_test 1.$tn.2.1 { SELECT count(*) FROM t1 WHERE b=31 } 1\n  do_execsql_test 1.$tn.2.2 { SELECT count(*) FROM t1 WHERE c=0  } 49\n  do_execsql_test 1.$tn.2.3 { SELECT count(*) FROM t1 WHERE b=125  } 49\n  do_execsql_test 1.$tn.2.4 { SELECT count(*) FROM t1 WHERE c=16  } 1\n\n  do_eqp_test 1.$tn.2.5 {\n    SELECT * FROM t1 WHERE b = 31 AND c = 0;\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}}\n  do_eqp_test 1.$tn.2.6 {\n    SELECT * FROM t1 WHERE b = 125 AND c = 16;\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?)}}\n\n  do_execsql_test 1.$tn.3.1 { \n    SELECT count(*) FROM t1 WHERE b BETWEEN 0 AND 50\n  } {6}\n  do_execsql_test 1.$tn.3.2 { \n    SELECT count(*) FROM t1 WHERE c BETWEEN 0 AND 50\n  } {90}\n  do_execsql_test 1.$tn.3.3 { \n    SELECT count(*) FROM t1 WHERE b BETWEEN 75 AND 125\n  } {90}\n  do_execsql_test 1.$tn.3.4 { \n    SELECT count(*) FROM t1 WHERE c BETWEEN 75 AND 125\n  } {6}\n\n  do_eqp_test 1.$tn.3.5 {\n    SELECT * FROM t1 WHERE b BETWEEN 0 AND 50 AND c BETWEEN 0 AND 50\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}\n\n  do_eqp_test 1.$tn.3.6 {\n    SELECT * FROM t1 WHERE b BETWEEN 75 AND 125 AND c BETWEEN 75 AND 125\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}\n\n  do_eqp_test 1.$tn.3.7 {\n    SELECT * FROM t1 WHERE b BETWEEN +0 AND +50 AND c BETWEEN +0 AND +50\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}\n\n  do_eqp_test 1.$tn.3.8 {\n    SELECT * FROM t1\n     WHERE b BETWEEN cast('0' AS int) AND cast('50.0' AS real)\n       AND c BETWEEN cast('0' AS numeric) AND cast('50.0' AS real)\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)}}\n\n  do_eqp_test 1.$tn.3.9 {\n    SELECT * FROM t1 WHERE b BETWEEN +75 AND +125 AND c BETWEEN +75 AND +125\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}\n\n  do_eqp_test 1.$tn.3.10 {\n    SELECT * FROM t1\n     WHERE b BETWEEN cast('75' AS int) AND cast('125.0' AS real)\n       AND c BETWEEN cast('75' AS numeric) AND cast('125.0' AS real)\n  } {0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c>? AND c<?)}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeB.test",
    "content": "# 2013 August 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains automated tests used to verify that the sqlite_stat3\n# functionality is working. The tests in this file are based on a subset\n# of the sqlite_stat4 tests in analyze9.test.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix analyzeB\n\nifcapable !stat3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a TEXT, b TEXT); \n  INSERT INTO t1 VALUES('(0)', '(0)');\n  INSERT INTO t1 VALUES('(1)', '(1)');\n  INSERT INTO t1 VALUES('(2)', '(2)');\n  INSERT INTO t1 VALUES('(3)', '(3)');\n  INSERT INTO t1 VALUES('(4)', '(4)');\n  CREATE INDEX i1 ON t1(a, b);\n} {}\n\n\ndo_execsql_test 1.1 {\n  ANALYZE;\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT tbl,idx,nEq,nLt,nDLt,quote(sample) FROM sqlite_stat3;\n} {\n  t1 i1 1 0 0 '(0)'\n  t1 i1 1 1 1 '(1)'\n  t1 i1 1 2 2 '(2)'\n  t1 i1 1 3 3 '(3)'\n  t1 i1 1 4 4 '(4)'\n}\n\nif {[permutation] != \"utf16\"} {\n  do_execsql_test 1.3 {\n    SELECT tbl,idx,nEq,nLt,nDLt,quote(sample) FROM sqlite_stat3;\n  } {\n    t1 i1 1 0 0 '(0)'\n    t1 i1 1 1 1 '(1)'\n    t1 i1 1 2 2 '(2)'\n    t1 i1 1 3 3 '(3)'\n    t1 i1 1 4 4 '(4)'\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# This is really just to test SQL user function \"test_decode\".\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1(a) VALUES('some text');\n  INSERT INTO t1(a) VALUES(14);\n  INSERT INTO t1(a) VALUES(NULL);\n  INSERT INTO t1(a) VALUES(22.0);\n  INSERT INTO t1(a) VALUES(x'656667');\n  CREATE INDEX i1 ON t1(a, b, c);\n  ANALYZE;\n  SELECT quote(sample) FROM sqlite_stat3;\n} {\n  NULL 14 22.0 {'some text'} X'656667' \n}\n\n#-------------------------------------------------------------------------\n# \nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  BEGIN;\n}\n\ndo_test 3.2 {\n  for {set i 0} {$i < 1000} {incr i} {\n    set a [expr $i / 10]\n    set b [expr int(rand() * 15.0)]\n    execsql { INSERT INTO t2 VALUES($a, $b) }\n  }\n  execsql COMMIT\n} {}\n\ndb func lindex lindex\n\n# Each value of \"a\" occurs exactly 10 times in the table.\n#\ndo_execsql_test 3.3.1 {\n  SELECT count(*) FROM t2 GROUP BY a;\n} [lrange [string repeat \"10 \" 100] 0 99]\n\n# The first element in the \"nEq\" list of all samples should therefore be 10.\n#\ndo_execsql_test 3.3.2 {\n  ANALYZE;\n  SELECT nEq FROM sqlite_stat3;\n} [lrange [string repeat \"10 \" 100] 0 23]\n\n#-------------------------------------------------------------------------\n# \ndo_execsql_test 3.4 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(1, 1, 'one-a');\n  INSERT INTO t1 VALUES(11, 1, 'one-b');\n  INSERT INTO t1 VALUES(21, 1, 'one-c');\n  INSERT INTO t1 VALUES(31, 1, 'one-d');\n  INSERT INTO t1 VALUES(41, 1, 'one-e');\n  INSERT INTO t1 VALUES(51, 1, 'one-f');\n  INSERT INTO t1 VALUES(61, 1, 'one-g');\n  INSERT INTO t1 VALUES(71, 1, 'one-h');\n  INSERT INTO t1 VALUES(81, 1, 'one-i');\n  INSERT INTO t1 VALUES(91, 1, 'one-j');\n  INSERT INTO t1 SELECT a+1,2,'two' || substr(c,4) FROM t1;\n  INSERT INTO t1 SELECT a+2,3,'three'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+3,4,'four'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+4,5,'five'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\n  INSERT INTO t1 SELECT a+5,6,'six'||substr(c,4) FROM t1 WHERE c GLOB 'one-*';\t\n  CREATE INDEX t1b ON t1(b);\n  ANALYZE;\n  SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND 60;\n} {three-d three-e three-f}\n\n\n#-------------------------------------------------------------------------\n# These tests verify that the sample selection for stat3 appears to be \n# working as designed.\n#\n\nreset_db\ndb func lindex lindex\ndb func lrange lrange\n\ndo_execsql_test 4.0 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(c, b, a);\n}\n\n\nproc insert_filler_rows_n {iStart args} {\n  set A(-ncopy) 1\n  set A(-nval) 1\n\n  foreach {k v} $args {\n    if {[info exists A($k)]==0} { error \"no such option: $k\" }\n    set A($k) $v\n  }\n  if {[llength $args] % 2} {\n    error \"option requires an argument: [lindex $args end]\"\n  }\n\n  for {set i 0} {$i < $A(-nval)} {incr i} {\n    set iVal [expr $iStart+$i]\n    for {set j 0} {$j < $A(-ncopy)} {incr j} {\n      execsql { INSERT INTO t1 VALUES($iVal, $iVal, $iVal) }\n    }\n  }\n}\n\ndo_test 4.1 {\n  execsql { BEGIN }\n  insert_filler_rows_n  0  -ncopy 10 -nval 19\n  insert_filler_rows_n 20  -ncopy  1 -nval 100\n\n  execsql {\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'a');\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'b');\n    INSERT INTO t1(c, b, a) VALUES(200, 1, 'c');\n\n    INSERT INTO t1(c, b, a) VALUES(200, 2, 'e');\n    INSERT INTO t1(c, b, a) VALUES(200, 2, 'f');\n\n    INSERT INTO t1(c, b, a) VALUES(201, 3, 'g');\n    INSERT INTO t1(c, b, a) VALUES(201, 4, 'h');\n\n    ANALYZE;\n    SELECT count(*) FROM sqlite_stat3;\n    SELECT count(*) FROM t1;\n  }\n} {24 297}\n\ndo_execsql_test 4.2 {\n  SELECT neq, nlt, ndlt, sample FROM sqlite_stat3 ORDER BY rowid LIMIT 16;\n} {\n  10 0 0 0\n  10 10 1 1\n  10 20 2 2\n  10 30 3 3\n  10 40 4 4\n  10 50 5 5\n  10 60 6 6\n  10 70 7 7\n  10 80 8 8\n  10 90 9 9\n  10 100 10 10\n  10 110 11 11\n  10 120 12 12\n  10 130 13 13\n  10 140 14 14\n  10 150 15 15\n}\n\ndo_execsql_test 4.3 {\n  SELECT neq, nlt, ndlt, sample FROM sqlite_stat3\n  ORDER BY rowid DESC LIMIT 2;\n} {\n  2 295 120 201\n  5 290 119 200\n}\n\ndo_execsql_test 4.4 { SELECT count(DISTINCT c) FROM t1 WHERE c<201 } 120\ndo_execsql_test 4.5 { SELECT count(DISTINCT c) FROM t1 WHERE c<200 } 119\n\nreset_db\ndo_test 4.7 {\n  execsql { \n    BEGIN;\n    CREATE TABLE t1(o,t INTEGER PRIMARY KEY);\n    CREATE INDEX i1 ON t1(o);\n  }\n  for {set i 0} {$i<10000} {incr i [expr (($i<1000)?1:10)]} {\n    execsql { INSERT INTO t1 VALUES('x', $i) }\n  }\n  execsql {\n    COMMIT;\n    ANALYZE;\n    SELECT count(*) FROM sqlite_stat3;\n  }\n} {1}\ndo_execsql_test 4.8 {\n  SELECT sample FROM sqlite_stat3;\n} {x}\n\n\n#-------------------------------------------------------------------------\n# The following would cause a crash at one point.\n#\nreset_db\ndo_execsql_test 5.1 {\n  PRAGMA encoding = 'utf-16';\n  CREATE TABLE t0(v);\n  ANALYZE;\n}\n\n#-------------------------------------------------------------------------\n# This was also crashing (corrupt sqlite_stat3 table).\n#\nreset_db\ndo_execsql_test 6.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(3, 3);\n  INSERT INTO t1 VALUES(4, 4);\n  INSERT INTO t1 VALUES(5, 5);\n  ANALYZE;\n  PRAGMA writable_schema = 1;\n  CREATE TEMP TABLE x1 AS\n    SELECT tbl,idx,neq,nlt,ndlt,sample FROM sqlite_stat3\n    ORDER BY (rowid%5), rowid;\n  DELETE FROM sqlite_stat3;\n  INSERT INTO sqlite_stat3 SELECT * FROM x1;\n  PRAGMA writable_schema = 0;\n  ANALYZE sqlite_master;\n}\ndo_execsql_test 6.2 {\n  SELECT * FROM t1 WHERE a = 'abc';\n}\n\n#-------------------------------------------------------------------------\n# The following tests experiment with adding corrupted records to the\n# 'sample' column of the sqlite_stat3 table.\n#\nreset_db\nsqlite3_db_config_lookaside db 0 0 0\n\ndo_execsql_test 7.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(3, 3);\n  INSERT INTO t1 VALUES(4, 4);\n  INSERT INTO t1 VALUES(5, 5);\n  ANALYZE;\n  UPDATE sqlite_stat3 SET sample = X'' WHERE rowid = 1;\n  ANALYZE sqlite_master;\n}\n\ndo_execsql_test 7.2 {\n  UPDATE sqlite_stat3 SET sample = X'FFFF';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 1;\n} {1 1}\n\ndo_execsql_test 7.3 {\n  ANALYZE;\n  UPDATE sqlite_stat3 SET neq = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 1;\n} {1 1}\n\ndo_execsql_test 7.4 {\n  ANALYZE;\n  UPDATE sqlite_stat3 SET ndlt = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 3;\n} {3 3}\n\ndo_execsql_test 7.5 {\n  ANALYZE;\n  UPDATE sqlite_stat3 SET nlt = '0 0 0';\n  ANALYZE sqlite_master;\n  SELECT * FROM t1 WHERE a = 5;\n} {5 5}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.1 {\n  CREATE TABLE t1(x TEXT);\n  CREATE INDEX i1 ON t1(x);\n  INSERT INTO t1 VALUES('1');\n  INSERT INTO t1 VALUES('2');\n  INSERT INTO t1 VALUES('3');\n  INSERT INTO t1 VALUES('4');\n  ANALYZE;\n}\ndo_execsql_test 8.2 {\n  SELECT * FROM t1 WHERE x = 3;\n} {3}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 9.1 {\n  CREATE TABLE t1(a, b, c, d, e);\n  CREATE INDEX i1 ON t1(a, b, c, d);\n  CREATE INDEX i2 ON t1(e);\n}\ndo_test 9.2 {\n  execsql BEGIN;\n  for {set i 0} {$i < 100} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])\"\n  }\n  for {set i 0} {$i < 20} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', 101, $i)\"\n  }\n  for {set i 102} {$i < 200} {incr i} {\n    execsql \"INSERT INTO t1 VALUES('x', 'y', 'z', $i, [expr $i/2])\"\n  }\n  execsql COMMIT\n  execsql ANALYZE\n} {}\n\ndo_eqp_test 9.3.1 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=101 AND e=5;\n} {/t1 USING INDEX i1/}\ndo_eqp_test 9.3.2 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=99 AND e=5;\n} {/t1 USING INDEX i1/}\n\nset value_d [expr 101]\ndo_eqp_test 9.4.1 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5\n} {/t1 USING INDEX i1/}\nset value_d [expr 99]\ndo_eqp_test 9.4.2 {\n  SELECT * FROM t1 WHERE a='x' AND b='y' AND c='z' AND d=$value_d AND e=5\n} {/t1 USING INDEX i1/}\n\n#-------------------------------------------------------------------------\n# Check that the planner takes stat3 data into account when considering\n# \"IS NULL\" and \"IS NOT NULL\" constraints.\n#\ndo_execsql_test 10.1.1 {\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE t3(a, b);\n  CREATE INDEX t3a ON t3(a);\n  CREATE INDEX t3b ON t3(b);\n}\ndo_test 10.1.2 {\n  for {set i 1} {$i < 100} {incr i} {\n    if {$i>90} { set a $i } else { set a NULL }\n    set b [expr $i % 5]\n    execsql \"INSERT INTO t3 VALUES($a, $b)\"\n  }\n  execsql ANALYZE\n} {}\ndo_eqp_test 10.1.3 {\n  SELECT * FROM t3 WHERE a IS NULL AND b = 2\n} {/t3 USING INDEX t3b/}\ndo_eqp_test 10.1.4 {\n  SELECT * FROM t3 WHERE a IS NOT NULL AND b = 2\n} {/t3 USING INDEX t3a/}\n\n#-------------------------------------------------------------------------\n# Check that stat3 data is used correctly with non-default collation\n# sequences.\n#\nforeach {tn schema} {\n  1 {\n    CREATE TABLE t4(a COLLATE nocase, b);\n    CREATE INDEX t4a ON t4(a);\n    CREATE INDEX t4b ON t4(b);\n  }\n  2 {\n    CREATE TABLE t4(a, b);\n    CREATE INDEX t4a ON t4(a COLLATE nocase);\n    CREATE INDEX t4b ON t4(b);\n  }\n} {\n  drop_all_tables\n  do_test 11.$tn.1 { execsql $schema } {}\n\n  do_test 11.$tn.2 {\n    for {set i 0} {$i < 100} {incr i} {\n      if { ($i % 10)==0 } { set a ABC } else { set a DEF }\n      set b [expr $i % 5]\n        execsql { INSERT INTO t4 VALUES($a, $b) }\n    }\n    execsql ANALYZE\n  } {}\n\n  do_eqp_test 11.$tn.3 {\n    SELECT * FROM t4 WHERE a = 'def' AND b = 3;\n  } {/t4 USING INDEX t4b/}\n\n  if {$tn==1} {\n    set sql \"SELECT * FROM t4 WHERE a = 'abc' AND b = 3;\"\n    do_eqp_test 11.$tn.4 $sql {/t4 USING INDEX t4a/}\n  } else {\n\n    set sql \"SELECT * FROM t4 WHERE a = 'abc' COLLATE nocase AND b = 3;\"\n    do_eqp_test 11.$tn.5 $sql {/t4 USING INDEX t4a/}\n\n    set sql \"SELECT * FROM t4 WHERE a COLLATE nocase = 'abc' AND b = 3;\"\n    do_eqp_test 11.$tn.6 $sql {/t4 USING INDEX t4a/}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that nothing untoward happens if the stat3 table contains entries\n# for indexes that do not exist. Or NULL values in the idx column.\n# Or NULL values in any of the other columns.\n#\ndrop_all_tables\ndo_execsql_test 15.1 {\n  CREATE TABLE x1(a, b, UNIQUE(a, b));\n  INSERT INTO x1 VALUES(1, 2);\n  INSERT INTO x1 VALUES(3, 4);\n  INSERT INTO x1 VALUES(5, 6);\n  ANALYZE;\n  INSERT INTO sqlite_stat3 VALUES(NULL, NULL, NULL, NULL, NULL, NULL);\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.2 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.3 {\n  INSERT INTO sqlite_stat3 VALUES(42, 42, 42, 42, 42, 42);\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.4 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.5 {\n  UPDATE sqlite_stat1 SET stat = NULL;\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.6 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.7 {\n  ANALYZE;\n  UPDATE sqlite_stat1 SET tbl = 'no such tbl';\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.8 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\ndo_execsql_test 15.9 {\n  ANALYZE;\n  UPDATE sqlite_stat3 SET neq = NULL, nlt=NULL, ndlt=NULL;\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.10 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\n# This is just for coverage....\ndo_execsql_test 15.11 {\n  ANALYZE;\n  UPDATE sqlite_stat1 SET stat = stat || ' unordered';\n}\ndb close\nsqlite3 db test.db\ndo_execsql_test 15.12 { SELECT * FROM x1 } {1 2 3 4 5 6}\n\n#-------------------------------------------------------------------------\n# Test that allocations used for sqlite_stat3 samples are included in\n# the quantity returned by SQLITE_DBSTATUS_SCHEMA_USED.\n#\nset one [string repeat x 1000]\nset two [string repeat x 2000]\ndo_test 16.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, UNIQUE(a));\n    INSERT INTO t1 VALUES($one);\n    ANALYZE;\n  }\n  set nByte [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]\n\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, UNIQUE(a));\n    INSERT INTO t1 VALUES($two);\n    ANALYZE;\n  }\n  set nByte2 [lindex [sqlite3_db_status db SCHEMA_USED 0] 1]\n\n  expr {$nByte2 > $nByte+950 && $nByte2 < $nByte+1050}\n} {1}\n\n#-------------------------------------------------------------------------\n# Test that stat3 data may be used with partial indexes.\n#\ndo_test 17.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, b, c, d);\n    CREATE INDEX i1 ON t1(a, b) WHERE d IS NOT NULL;\n    INSERT INTO t1 VALUES(-1, -1, -1, NULL);\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n    INSERT INTO t1 SELECT 2*a,2*b,2*c,d FROM t1;\n  }\n\n  for {set i 0} {$i < 32} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i%2, $b, $i/2, 'abc') }\n  }\n  execsql {ANALYZE main.t1}\n} {}\n\ndo_catchsql_test 17.1.2 {\n  ANALYZE temp.t1;\n} {1 {no such table: temp.t1}}\n\ndo_eqp_test 17.2 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0;\n} {/USING INDEX i1/}\ndo_eqp_test 17.3 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0;\n} {/USING INDEX i1/}\n\ndo_execsql_test 17.4 {\n  CREATE INDEX i2 ON t1(c) WHERE d IS NOT NULL;\n  ANALYZE main.i2;\n}\ndo_eqp_test 17.5 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0;\n} {/USING INDEX i1/}\ndo_eqp_test 17.6 {\n  SELECT * FROM t1 WHERE d IS NOT NULL AND a=0 AND b=0 AND c=10;\n} {/USING INDEX i2/}\n\n#-------------------------------------------------------------------------\n#\ndo_test 18.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n  }\n  for {set i 0} {$i < 9} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n      INSERT INTO t1 VALUES($i, 0);\n    }\n  }\n  execsql ANALYZE\n  execsql { SELECT count(*) FROM sqlite_stat3 }\n} {9}\n\n#-------------------------------------------------------------------------\n# For coverage.\n#\nifcapable view {\n  do_test 19.1 {\n    reset_db \n    execsql {\n      CREATE TABLE t1(x, y);\n      CREATE INDEX i1 ON t1(x, y);\n      CREATE VIEW v1 AS SELECT * FROM t1;\n      ANALYZE;\n    }\n  } {}\n}\nifcapable auth {\n  proc authproc {op args} {\n    if {$op == \"SQLITE_ANALYZE\"} { return \"SQLITE_DENY\" }\n    return \"SQLITE_OK\"\n  }\n  do_test 19.2 {\n    reset_db \n    db auth authproc\n    execsql {\n      CREATE TABLE t1(x, y);\n      CREATE VIEW v1 AS SELECT * FROM t1;\n    }\n    catchsql ANALYZE\n  } {1 {not authorized}}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nproc r {args} { expr rand() }\ndb func r r\ndb func lrange lrange\ndo_test 20.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE INDEX i1 ON t1(a,b,c,d);\n  }\n  for {set i 0} {$i < 16} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, r(), r(), r());\n      INSERT INTO t1 VALUES($i, $i,  r(), r());\n      INSERT INTO t1 VALUES($i, $i,  $i,  r());\n      INSERT INTO t1 VALUES($i, $i,  $i,  $i);\n      INSERT INTO t1 VALUES($i, $i,  $i,  $i);\n      INSERT INTO t1 VALUES($i, $i,  $i,  r());\n      INSERT INTO t1 VALUES($i, $i,  r(), r());\n      INSERT INTO t1 VALUES($i, r(), r(), r());\n    }\n  }\n} {}\ndo_execsql_test 20.2 { ANALYZE }\nfor {set i 0} {$i<16} {incr i} {\n    set val $i\n    do_execsql_test 20.3.$i {\n      SELECT count(*) FROM sqlite_stat3 WHERE sample=$val\n    } {1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeC.test",
    "content": "# 2014-07-22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains automated tests used to verify that the text terms\n# at the end of sqlite_stat1.stat are processed correctly.\n#\n#  (1) \"unordered\" means that the index cannot be used for ORDER BY\n#      or for range queries\n#\n#  (2) \"sz=NNN\" sets the relative size of the index entries\n#\n#  (3) All other fields are silently ignored\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix analyzeC\n\n# Baseline case.  Range queries work OK.  Indexes can be used for\n# ORDER BY.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1(a,b,c)\n    VALUES(1,2,3),(7,8,9),(4,5,6),(10,11,12),(4,8,12),(1,11,111);\n  CREATE INDEX t1a ON t1(a);\n  CREATE INDEX t1b ON t1(b);\n  ANALYZE;\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat)\n    VALUES('t1','t1a','12345 2'),('t1','t1b','12345 4');\n  ANALYZE sqlite_master;\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {4 5 6 # 7 8 9 # 4 8 12 #}\ndo_execsql_test 1.1 {\n  EXPLAIN QUERY PLAN\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {/.* USING INDEX t1a .a>. AND a<...*/}\ndo_execsql_test 1.2 {\n  SELECT c FROM t1 ORDER BY a;\n} {3 111 6 12 9 12}\ndo_execsql_test 1.3 {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {/.*SCAN TABLE t1 USING INDEX t1a.*/}\ndo_execsql_test 1.3x {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {~/.*B-TREE FOR ORDER BY.*/}\n\n# Now mark the t1a index as \"unordered\".  Range queries and ORDER BY no\n# longer use the index, but equality queries do.\n#\ndo_execsql_test 2.0 {\n  UPDATE sqlite_stat1 SET stat='12345 2 unordered' WHERE idx='t1a';\n  ANALYZE sqlite_master;\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {4 5 6 # 7 8 9 # 4 8 12 #}\ndo_execsql_test 2.1 {\n  EXPLAIN QUERY PLAN\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {~/.*USING INDEX.*/}\ndo_execsql_test 2.2 {\n  SELECT c FROM t1 ORDER BY a;\n} {3 111 6 12 9 12}\ndo_execsql_test 2.3 {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {~/.*USING INDEX.*/}\ndo_execsql_test 2.3x {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {/.*B-TREE FOR ORDER BY.*/}\n\n# Ignore extraneous text parameters in the sqlite_stat1.stat field.\n#\ndo_execsql_test 3.0 {\n  UPDATE sqlite_stat1 SET stat='12345 2 whatever=5 unordered xyzzy=11'\n   WHERE idx='t1a';\n  ANALYZE sqlite_master;\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {4 5 6 # 7 8 9 # 4 8 12 #}\ndo_execsql_test 3.1 {\n  EXPLAIN QUERY PLAN\n  SELECT *, '#' FROM t1 WHERE a BETWEEN 3 AND 8 ORDER BY c;\n} {~/.*USING INDEX.*/}\ndo_execsql_test 3.2 {\n  SELECT c FROM t1 ORDER BY a;\n} {3 111 6 12 9 12}\ndo_execsql_test 3.3 {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {~/.*USING INDEX.*/}\ndo_execsql_test 3.3x {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 ORDER BY a;\n} {/.*B-TREE FOR ORDER BY.*/}\n\n# The sz=NNN parameter determines which index to scan\n#\ndo_execsql_test 4.0 {\n  DROP INDEX t1a;\n  CREATE INDEX t1ab ON t1(a,b);\n  CREATE INDEX t1ca ON t1(c,a);\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat)\n    VALUES('t1','t1ab','12345 3 2 sz=10'),('t1','t1ca','12345 3 2 sz=20');\n  ANALYZE sqlite_master;\n  SELECT count(a) FROM t1;\n} {6}\ndo_execsql_test 4.1 {\n  EXPLAIN QUERY PLAN\n  SELECT count(a) FROM t1;\n} {/.*INDEX t1ab.*/}\ndo_execsql_test 4.2 {\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat)\n    VALUES('t1','t1ab','12345 3 2 sz=20'),('t1','t1ca','12345 3 2 sz=10');\n  ANALYZE sqlite_master;\n  SELECT count(a) FROM t1;\n} {6}\ndo_execsql_test 4.3 {\n  EXPLAIN QUERY PLAN\n  SELECT count(a) FROM t1;\n} {/.*INDEX t1ca.*/}\n\n\n# The sz=NNN parameter works even if there is other extraneous text\n# in the sqlite_stat1.stat column.\n#\ndo_execsql_test 5.0 {\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat)\n    VALUES('t1','t1ab','12345 3 2 x=5 sz=10 y=10'),\n          ('t1','t1ca','12345 3 2 whatever sz=20 junk');\n  ANALYZE sqlite_master;\n  SELECT count(a) FROM t1;\n} {6}\ndo_execsql_test 5.1 {\n  EXPLAIN QUERY PLAN\n  SELECT count(a) FROM t1;\n} {/.*INDEX t1ab.*/}\ndo_execsql_test 5.2 {\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat)\n    VALUES('t1','t1ca','12345 3 2 x=5 sz=10 y=10'),\n          ('t1','t1ab','12345 3 2 whatever sz=20 junk');\n  ANALYZE sqlite_master;\n  SELECT count(a) FROM t1;\n} {6}\ndo_execsql_test 5.3 {\n  EXPLAIN QUERY PLAN\n  SELECT count(a) FROM t1;\n} {/.*INDEX t1ca.*/}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeD.test",
    "content": "# 2014-10-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# This file implements tests for the ANALYZE command.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix analyzeD\n\nifcapable {!stat4} {\n  finish_test\n  return\n}\n\n\n# Set up a table with the following properties:\n#\n#    * Contains 1000 rows.\n#    * Column a contains even integers between 0 and 18, inclusive (so that\n#      a=? for any such integer matches 100 rows).\n#    * Column b contains integers between 0 and 9, inclusive.\n#    * Column c contains integers between 0 and 199, inclusive (so that\n#      for any such integer, c=? matches 5 rows).\n#    * Then add 7 rows with a new value for \"a\" - 3001. The stat4 table will\n#      not contain any samples with a=3001.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n}\ndo_test 1.1 {\n  for {set i 1} {$i < 1000} {incr i} {\n    set c [expr $i % 200]\n    execsql { INSERT INTO t1(a, b, c) VALUES( 2*($i/100), $i%10, $c ) }\n  }\n\n  execsql {\n    INSERT INTO t1 VALUES(3001, 3001, 3001);\n    INSERT INTO t1 VALUES(3001, 3001, 3002);\n    INSERT INTO t1 VALUES(3001, 3001, 3003);\n    INSERT INTO t1 VALUES(3001, 3001, 3004);\n    INSERT INTO t1 VALUES(3001, 3001, 3005);\n    INSERT INTO t1 VALUES(3001, 3001, 3006);\n    INSERT INTO t1 VALUES(3001, 3001, 3007);\n\n    CREATE INDEX t1_ab ON t1(a, b);\n    CREATE INDEX t1_c ON t1(c);\n\n    ANALYZE;\n  }\n} {}\n\n# With full ANALYZE data, SQLite sees that c=150 (5 rows) is better than\n# a=3001 (7 rows).\n#\ndo_eqp_test 1.2 {\n  SELECT * FROM t1 WHERE a=3001 AND c=150;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1_c (c=?)}\n}\n\ndo_test 1.3 {\n  execsql { DELETE FROM sqlite_stat1 }\n  db close\n  sqlite3 db test.db\n} {}\n\n# Without stat1, because 3001 is larger than all samples in the stat4\n# table, SQLite thinks that a=3001 matches just 1 row. So it (incorrectly)\n# chooses it over the c=150 index (5 rows). Even with stat1 data, things\n# worked this way before commit [e6f7f97dbc].\n#\ndo_eqp_test 1.4 {\n  SELECT * FROM t1 WHERE a=3001 AND c=150;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1_ab (a=?)}\n}\n\ndo_test 1.5 {\n  execsql { \n    UPDATE t1 SET a=13 WHERE a = 3001;\n    ANALYZE;\n  }\n} {}\n\ndo_eqp_test 1.6 {\n  SELECT * FROM t1 WHERE a=13 AND c=150;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1_c (c=?)}\n}\n\ndo_test 1.7 {\n  execsql { DELETE FROM sqlite_stat1 }\n  db close\n  sqlite3 db test.db\n} {}\n\n# Same test as 1.4, except this time the 7 rows that match the a=? condition \n# do not feature larger values than all rows in the stat4 table. So SQLite\n# gets this right, even without stat1 data.\ndo_eqp_test 1.8 {\n  SELECT * FROM t1 WHERE a=13 AND c=150;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1_c (c=?)}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeE.test",
    "content": "# 2014-10-08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for using STAT4 information\n# on a descending index in a range query.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix analyzeE\n\nifcapable {!stat4} {\n  finish_test\n  return\n}\n\n# Verify that range queries on an ASCENDING index will use the\n# index only if the range covers only a small fraction of the\n# entries.\n#\ndo_execsql_test analyzeE-1.0 {\n  CREATE TABLE t1(a,b);\n  WITH RECURSIVE\n    cnt(x) AS (VALUES(1000) UNION ALL SELECT x+1 FROM cnt WHERE x<2000)\n  INSERT INTO t1(a,b) SELECT x, x FROM cnt;\n  CREATE INDEX t1a ON t1(a);\n  ANALYZE;\n} {}\ndo_execsql_test analyzeE-1.1 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500;\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-1.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000;\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.3 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750;\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1 AND 500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.5 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.6 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.7 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>2500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.8 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1900\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.9 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1100\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-1.10 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1100\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-1.11 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1900\n} {/SCAN TABLE t1/}\n\n# Verify that everything works the same on a DESCENDING index.\n#\ndo_execsql_test analyzeE-2.0 {\n  DROP INDEX t1a;\n  CREATE INDEX t1a ON t1(a DESC);\n  ANALYZE;\n} {}\ndo_execsql_test analyzeE-2.1 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500;\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000;\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.3 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750;\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1 AND 500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.5 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.6 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.7 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>2500\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.8 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1900\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.9 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1100\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-2.10 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1100\n} {/SEARCH TABLE t1 USING INDEX t1a/}\ndo_execsql_test analyzeE-2.11 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1900\n} {/SCAN TABLE t1/}\n\n# Now do a range query on the second term of an ASCENDING index\n# where the first term is constrained by equality.\n#\ndo_execsql_test analyzeE-3.0 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c);\n  WITH RECURSIVE\n    cnt(x) AS (VALUES(1000) UNION ALL SELECT x+1 FROM cnt WHERE x<2000)\n  INSERT INTO t1(a,b,c) SELECT x, x, 123 FROM cnt;\n  CREATE INDEX t1ca ON t1(c,a);\n  ANALYZE;\n} {}\ndo_execsql_test analyzeE-3.1 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500 AND c=123;\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-3.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000 AND c=123;\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.3 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750 AND c=123;\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1 AND 500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.5 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.6 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.7 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>2500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.8 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1900 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.9 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1100 AND c=123\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-3.10 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1100 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-3.11 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1900 AND c=123\n} {/SCAN TABLE t1/}\n\n# Repeat the 3.x tests using a DESCENDING index\n#\ndo_execsql_test analyzeE-4.0 {\n  DROP INDEX t1ca;\n  CREATE INDEX t1ca ON t1(c ASC,a DESC);\n  ANALYZE;\n} {}\ndo_execsql_test analyzeE-4.1 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 500 AND 2500 AND c=123;\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-4.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 2900 AND 3000 AND c=123;\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.3 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1700 AND 1750 AND c=123;\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 1 AND 500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.5 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a BETWEEN 3000 AND 3000000 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.6 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.7 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>2500 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.8 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1900 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.9 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a>1100 AND c=123\n} {/SCAN TABLE t1/}\ndo_execsql_test analyzeE-4.10 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1100 AND c=123\n} {/SEARCH TABLE t1 USING INDEX t1ca/}\ndo_execsql_test analyzeE-4.11 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a<1900 AND c=123\n} {/SCAN TABLE t1/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzeF.test",
    "content": "# 2015-03-12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that deterministic scalar functions passed constant arguments\n# are used with stat4 data.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix analyzeF\n\nifcapable {!stat4} {\n  finish_test\n  return\n}\n\nproc isqrt {i} { expr { int(sqrt($i)) } }\ndb func isqrt isqrt\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x INTEGER, y INTEGER);\n  WITH data(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM data\n  )\n  INSERT INTO t1 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;\n  CREATE INDEX t1x ON t1(x);\n  CREATE INDEX t1y ON t1(y);\n  ANALYZE;\n}\n\nproc str {a} { return $a }\ndb func str str\n\n# Note: tests 7 to 12 might be unstable - as they assume SQLite will\n# prefer the expression to the right of the AND clause. Which of\n# course could change.\n#\n# Note 2: tests 9 and 10 depend on the tcl interface creating functions\n# without the SQLITE_DETERMINISTIC flag set.\n#\nforeach {tn where idx} {\n  1 \"x = 4 AND y = 19\"     {t1x (x=?)}\n  2 \"x = 19 AND y = 4\"     {t1y (y=?)}\n  3 \"x = '4' AND y = '19'\" {t1x (x=?)}\n  4 \"x = '19' AND y = '4'\" {t1y (y=?)}\n  5 \"x = substr('5195', 2, 2) AND y = substr('145', 2, 1)\" {t1y (y=?)}\n  6 \"x = substr('145', 2, 1) AND y = substr('5195', 2, 2)\" {t1x (x=?)}\n\n  7  \"x = substr('5195', 2, 2+0) AND y = substr('145', 2, 1+0)\" {t1y (y=?)}\n  8  \"x = substr('145', 2, 1+0) AND y = substr('5195', 2, 2+0)\" {t1y (y=?)}\n\n  9  \"x = str('19') AND y = str('4')\" {t1y (y=?)}\n  10 \"x = str('4') AND y = str('19')\" {t1y (y=?)}\n\n  11 \"x = nullif('19', 0) AND y = nullif('4', 0)\" {t1y (y=?)}\n  12 \"x = nullif('4', 0) AND y = nullif('19', 0)\" {t1y (y=?)}\n} {\n  set res \"0 0 0 {SEARCH TABLE t1 USING INDEX $idx}\"\n  do_eqp_test 1.$tn \"SELECT * FROM t1 WHERE $where\" $res\n}\n\n# Test that functions that do not exist - \"func()\" - do not cause an error.\n#\ndo_catchsql_test 2.1 {\n  SELECT * FROM t1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)\n} {1 {no such function: func}}\ndo_catchsql_test 2.2 {\n  UPDATE t1 SET y=y+1 WHERE x = substr('145', 2, 1) AND y = func(1, 2, 3)\n} {1 {no such function: func}}\n\n\n# Check that functions that accept zero arguments do not cause problems.\n#\nproc ret {x} { return $x }\n\ndb func det4 -deterministic [list ret 4]\ndb func nondet4 [list ret 4]\ndb func det19 -deterministic [list ret 19]\ndb func nondet19 [list ret 19]\n\nforeach {tn where idx} {\n  1 \"x = det4() AND y = det19()\"     {t1x (x=?)}\n  2 \"x = det19() AND y = det4()\"     {t1y (y=?)}\n\n  3 \"x = nondet4() AND y = nondet19()\"     {t1y (y=?)}\n  4 \"x = nondet19() AND y = nondet4()\"     {t1y (y=?)}\n} {\n  set res \"0 0 0 {SEARCH TABLE t1 USING INDEX $idx}\"\n  do_eqp_test 3.$tn \"SELECT * FROM t1 WHERE $where\" $res\n}\n\n\nexecsql { DELETE FROM t1 }\n\nproc throw_error {err} { error $err }\ndb func error -deterministic throw_error\ndo_catchsql_test 4.1 {\n  SELECT * FROM t1 WHERE x = error('error one') AND y = 4;\n} {1 {error one}}\n\ndo_catchsql_test 4.2 {\n  SELECT * FROM t1 WHERE x = zeroblob(2200000000) AND y = 4;\n} {1 {string or blob too big}}\n\nsqlite3_limit db SQLITE_LIMIT_LENGTH 1000000\nproc dstr {} { return [string repeat x 1100000] }\ndb func dstr -deterministic dstr\ndo_catchsql_test 4.3 {\n  SELECT * FROM t1 WHERE x = dstr() AND y = 11;\n} {1 {string or blob too big}}\n\ndo_catchsql_test 4.4 {\n  SELECT * FROM t1 WHERE x = test_zeroblob(1100000) AND y = 4;\n} {1 {string or blob too big}}\n\n# 2016-12-08: Constraints of the form \"x=? AND x IS NOT NULL\" were being\n# mishandled.  The sqlite3Stat4ProbeSetValue() routine was assuming that\n# valueNew() was returning a Mem object that was preset to NULL, which is\n# not the case.  The consequence was the the \"x IS NOT NULL\" constraint\n# was used to drive the index (via the \"x>NULL\" pseudo-constraint) rather\n# than the \"x=?\" constraint.\n#\ndo_execsql_test 5.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c INT);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)\n    INSERT INTO t1(a, c) SELECT x, x FROM c;\n  UPDATE t1 SET b=printf('x%02x',a/500) WHERE a>4000;\n  UPDATE t1 SET b='xyz' where a>=9998;\n  CREATE INDEX t1b ON t1(b);\n  ANALYZE;\n  SELECT count(*), b FROM t1 GROUP BY 2 ORDER BY 2;\n} {4000 {} 499 x08 500 x09 500 x0a 500 x0b 500 x0c 500 x0d 500 x0e 500 x0f 500 x10 500 x11 500 x12 498 x13 3 xyz}\ndo_execsql_test 5.2 {\n  explain query plan\n  SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;\n  /*                  v---- Should be \"=\", not \">\"  */\n} {/USING INDEX t1b .b=/}\ndo_execsql_test 5.3 {\n  SELECT * FROM t1 WHERE b='xyz' AND b IS NOT NULL ORDER BY +a;\n} {9998 xyz 9998 9999 xyz 9999 10000 xyz 10000}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/analyzer1.test",
    "content": "# 2015-05-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Quick tests for the sqlite3_analyzer tool\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nif {$tcl_platform(platform)==\"windows\"} {\n  set PROG \"sqlite3_analyzer.exe\"\n} else {\n  set PROG \"./sqlite3_analyzer\"\n}\nif {![file exe $PROG]} {\n  set PROG [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $PROG]]\n  if {![file exe $PROG]} {\n    puts \"analyzer1 cannot run because $PROG is not available\"\n    finish_test\n    return\n  }\n}\ndb close\nforcedelete test.db test.db-journal test.db-wal\nsqlite3 db test.db\n\ndo_test analyzer1-1.0 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;\n    WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<250)\n    INSERT INTO t1(a,b) SELECT x, randomblob(200) FROM c;\n    INSERT INTO t2(a,b) SELECT a, b FROM t1;\n  }\n  set line \"exec $PROG test.db\"\n  unset -nocomplain ::MSG\n  catch {eval $line} ::MSG\n} {0}\ndo_test analyzer1-1.1 {\n  regexp {^/\\*\\* Disk-Space Utilization.*COMMIT;\\W*$} $::MSG\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/async.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n# $Id: async.test,v 1.21 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[info commands sqlite3async_initialize] eq \"\"} {\n  # The async logic is not built into this system\n  finish_test\n  return\n}\n\nrename finish_test async_really_finish_test\nproc finish_test {} {\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n}\nif {[info exists G(isquick)]} { set ASYNC_SAVE_ISQUICK $G(isquick) }\nset G(isquick) 1\n\nset ASYNC_INCLUDE {\n  insert.test\n  insert2.test\n  insert3.test\n  lock.test\n  lock2.test\n  lock3.test\n  select1.test\n  select2.test\n  select3.test\n  select4.test\n  trans.test\n}\n\n# Enable asynchronous IO.\nsqlite3async_initialize \"\" 1\n\n# This proc flushes the contents of the async-IO queue through to the \n# underlying VFS. A couple of the test scripts identified in $ASYNC_INCLUDE\n# above contain lines like \"catch flush_async_queue\" in places where \n# this is required for the tests to work in async mode.\n#\nproc flush_async_queue {} {\n  sqlite3async_control halt idle\n  sqlite3async_start\n  sqlite3async_wait\n  sqlite3async_control halt never\n}\n\nrename do_test async_really_do_test\nproc do_test {name args} {\n  uplevel async_really_do_test async_io-$name $args\n  flush_async_queue\n}\n\nforeach testfile [lsort -dictionary [glob $testdir/*.test]] {\n  set tail [file tail $testfile]\n  if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue\n  source $testfile\n\n  # Make sure everything is flushed through. This is because [source]ing \n  # the next test file will delete the database file on disk (using\n  # [delete_file]). If the asynchronous backend still has the file\n  # open, it will become confused.\n  #\n  flush_async_queue\n}\n\n# Flush the write-queue and disable asynchronous IO. This should ensure\n# all allocated memory is cleaned up.\nset sqlite3async_trace 1\nflush_async_queue\nsqlite3async_shutdown\nset sqlite3async_trace 0\n\nrename do_test {}\nrename async_really_do_test do_test\nrename finish_test {}\nrename async_really_finish_test finish_test\n\nif {[info exists ASYNC_SAVE_ISQUICK]} { set G(isquick) $ASYNC_SAVE_ISQUICK }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/async2.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: async2.test,v 1.12 2009/04/25 08:39:15 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {\n  [info commands sqlite3async_initialize]==\"\" ||\n  [info command sqlite3_memdebug_fail]==\"\"\n} {\n  # The async logic is not built into this system\n  puts \"Skipping async2 tests: not compiled with required features\"\n  finish_test\n  return\n}\n\n# Enable asynchronous IO.\n\nset setup_script {\n  CREATE TABLE counter(c);\n  INSERT INTO counter(c) VALUES (1);\n} \n\nset sql_script {\n  BEGIN;\n    UPDATE counter SET c = 2;\n    CREATE TABLE t1(a PRIMARY KEY, b, c);\n    CREATE TABLE t2(a PRIMARY KEY, b, c);\n  COMMIT;\n\n  BEGIN;\n    UPDATE counter SET c = 3;\n    INSERT INTO t1 VALUES('abcdefghij', 'four', 'score');\n    INSERT INTO t2 VALUES('klmnopqrst', 'and', 'seven');\n  COMMIT;\n\n  UPDATE counter SET c = 'FIN';\n}\n\ndb close\n\nforeach err [list ioerr malloc-transient malloc-persistent] {\n  set ::go 10\n  for {set n 1} {$::go} {incr n} {\n    set ::sqlite_io_error_pending 0\n    sqlite3_memdebug_fail -1\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql $::setup_script\n    db close\n  \n    sqlite3async_initialize \"\" 1\n    sqlite3 db test.db\n    sqlite3_db_config_lookaside db 0 0 0\n  \n    switch -- $err {\n      ioerr             { set ::sqlite_io_error_pending $n }\n      malloc-persistent { sqlite3_memdebug_fail $n -repeat 1 }\n      malloc-transient  { sqlite3_memdebug_fail $n -repeat 0 }\n    }\n\n    catchsql $::sql_script\n    db close\n\n    sqlite3async_control halt idle\n    sqlite3async_start\n    sqlite3async_wait\n    sqlite3async_control halt never\n    sqlite3async_shutdown\n\n    set ::sqlite_io_error_pending 0\n    sqlite3_memdebug_fail -1\n\n    sqlite3 db test.db\n    set c [db one {SELECT c FROM counter LIMIT 1}]\n    switch -- $c {\n      1 {\n        do_test async-$err-1.1.$n {\n          execsql {\n            SELECT name FROM sqlite_master;\n          }\n        } {counter}\n      }\n      2 {\n        do_test async-$err-1.2.$n.1 {\n          execsql {\n            SELECT * FROM t1;\n          }\n        } {}\n        do_test async-$err-1.2.$n.2 {\n          execsql {\n            SELECT * FROM t2;\n          }\n        } {}\n      }\n      3 {\n        do_test async-$err-1.3.$n.1 {\n          execsql {\n            SELECT * FROM t1;\n          }\n        } {abcdefghij four score}\n        do_test async-$err-1.3.$n.2 {\n          execsql {\n            SELECT * FROM t2;\n          }\n        } {klmnopqrst and seven}\n      }\n      FIN {\n        incr ::go -1\n      }\n    }\n  \n    db close\n  }\n}\n\ncatch {db close}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/async3.test",
    "content": "# 2007 September 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the code in test_async.c.\n# Specifically, it tests that the xFullPathname() method of\n# of the asynchronous vfs works correctly.\n#\n# $Id: async3.test,v 1.5 2009/04/25 08:39:15 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif { [info commands sqlite3async_initialize]==\"\"  } {\n  # The async logic is not built into this system\n  puts \"Skipping async3 tests: not compiled with required features\"\n  finish_test\n  return\n}\n\ndb close\nsqlite3async_initialize \"\" 1\n#set sqlite3async_trace 1\nsqlite3async_start\n\nset paths {\n  chocolate/banana/vanilla/file.db\n  chocolate//banana/vanilla/file.db\n  chocolate/./banana//vanilla/file.db\n  chocolate/banana/./vanilla/file.db\n  chocolate/banana/../banana/vanilla/file.db\n  chocolate/banana/./vanilla/extra_bit/../file.db\n}\n\ndo_test async3-1.0 {\n  file mkdir [file join chocolate banana vanilla]\n  forcedelete chocolate/banana/vanilla/file.db\n  forcedelete chocolate/banana/vanilla/file.db-journal\n} {}\n\ndo_test async3-1.1 {\n  sqlite3 db chocolate/banana/vanilla/file.db\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    BEGIN;\n    INSERT INTO abc VALUES(1, 2, 3);\n  }\n} {}\n\nset N 2\nforeach p $paths {\n  sqlite3 db2 $p\n  do_test async3-1.$N.1 {\n    execsql {SELECT * FROM abc} db2\n  } {}\n  do_test async3-1.$N.2 {\n    catchsql {INSERT INTO abc VALUES(4, 5, 6)} db2\n  } {1 {database is locked}}\n  db2 close\n  incr N\n}\n\ndb close\n\nsqlite3async_control halt idle\nsqlite3async_wait\nsqlite3async_control halt never\nsqlite3async_shutdown\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/async4.test",
    "content": "# 2009 April 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: async4.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests only work for Tcl version 8.5 and later on Windows (for now)\n#\nif {$tcl_platform(platform)==\"windows\"} {\n  scan $::tcl_version %f vx\n  if {$vx<8.5} {\n    finish_test\n    return\n  }\n}\n\nif {[info commands sqlite3async_initialize] eq \"\"} {\n  # The async logic is not built into this system\n  finish_test\n  return\n}\ndb close\n\n# Test layout:\n#\n#   async4.1.*: Test the lockfiles parameter.\n#   async4.2.*: Test the delay parameter.\n\ndo_test async4.1.1 {\n  sqlite3async_initialize {} 0\n  sqlite3async_control lockfiles\n} {1}\ndo_test async4.1.2 {\n  sqlite3async_control lockfiles false\n} {0}\ndo_test async4.1.3 {\n  sqlite3async_control lockfiles\n} {0}\ndo_test async4.1.4 {\n  sqlite3async_control lockfiles true\n} {1}\n\ndo_test async4.1.5 {\n  sqlite3 db test.db -vfs sqlite3async\n  execsql { CREATE TABLE t1(a, b, c) }\n} {}\ndo_test async4.1.6 {\n  list [file exists test.db] [file size test.db]\n} {1 0}\ndo_test async4.1.7 {\n  sqlite3 db2 test.db\n  catchsql { CREATE TABLE t2(a, b, c) } db2\n} {1 {database is locked}}\ndo_test async4.1.8 {\n  sqlite3async_control halt idle\n  sqlite3async_start\n  sqlite3async_wait\n} {}\ndo_test async4.1.9 {\n  catchsql { CREATE TABLE t2(a, b, c) } db2\n} {0 {}}\ndo_test async4.1.10 {\n  list [catch {sqlite3async_control lockfiles false} msg] $msg\n} {1 SQLITE_MISUSE}\ndo_test async4.1.11 {\n  db close\n  list [catch {sqlite3async_control lockfiles false} msg] $msg\n} {1 SQLITE_MISUSE}\ndo_test async4.1.12 {\n  sqlite3async_start\n  sqlite3async_wait\n  sqlite3async_control lockfiles false\n} {0}\ndo_test async4.1.13 {\n  sqlite3 db test.db -vfs sqlite3async\n  execsql { CREATE TABLE t3(a, b, c) } db\n} {}\ndo_test async4.1.14 {\n  execsql { \n    CREATE INDEX i1 ON t2(a);\n    CREATE INDEX i2 ON t1(a);\n  } db2\n} {}\ndo_test async4.1.15 {\n  sqlite3async_start\n  sqlite3async_wait\n  hexio_write test.db 28 00000000\n  execsql { pragma integrity_check } db2\n} {{*** in database main ***\nPage 5 is never used}}\ndo_test async4.1.16 {\n  db close\n  db2 close\n  sqlite3async_start\n  sqlite3async_wait\n} {}\ndo_test async4.1.17 {\n  sqlite3async_control lockfiles true\n} {1}\n\ndo_test async4.2.1 {\n  sqlite3async_control delay\n} {0}\ndo_test async4.2.2 {\n  sqlite3async_control delay 23\n} {23}\ndo_test async4.2.3 {\n  sqlite3async_control delay\n} {23}\ndo_test async4.2.4 {\n  sqlite3async_control delay 0\n} {0}\ndo_test async4.2.5 {\n  sqlite3 db test.db -vfs sqlite3async\n\n  execsql { CREATE TABLE t4(a, b) }\n  set T1 [lindex [time {\n    sqlite3async_start\n    sqlite3async_wait\n  }] 0]\n\n  sqlite3async_control delay 100\n  execsql { CREATE TABLE t5(a, b) }\n  set T2 [lindex [time {\n    sqlite3async_start\n    sqlite3async_wait\n  }] 0]\n\n  expr {($T1+1000000) < $T2}\n} {1}\n\ndo_test async4.2.6 {\n  sqlite3async_control delay 0\n  execsql { CREATE TABLE t6(a, b) }\n  set T1 [lindex [time {\n    sqlite3async_start\n    sqlite3async_wait\n  }] 0]\n\n  expr {($T1+1000000) < $T2}\n} {1}\n\ndo_test async4.2.7 {\n  list [catch { sqlite3async_control delay -1 } msg] $msg\n} {1 SQLITE_MISUSE}\n\ndo_test async4.2.8 {\n  db close\n  sqlite3async_start\n  sqlite3async_wait\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/async5.test",
    "content": "# 2009 July 19\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests that asynchronous IO is compatible with multi-file\n# transactions.\n#\n# $Id: async5.test,v 1.1 2009/07/18 11:52:04 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[info commands sqlite3async_initialize] eq \"\"} {\n  # The async logic is not built into this system\n  finish_test\n  return\n}\n\ndb close\nforcedelete test2.db\nsqlite3async_initialize \"\" 1\nsqlite3async_control halt never\nsqlite3 db test.db\n\ndo_test async5-1.1 {\n  execsql {\n    ATTACH 'test2.db' AS next;\n    CREATE TABLE main.t1(a, b);\n    CREATE TABLE next.t2(a, b);\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t2 VALUES(3, 4);\n    COMMIT;\n  }\n} {}\ndo_test async5-1.2 {\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test async5-1.3 {\n  execsql { SELECT * FROM t2 }\n} {3 4}\ndo_test async5-1.4 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES('a', 'b');\n      INSERT INTO t2 VALUES('c', 'd');\n    COMMIT;\n  }\n} {}\ndo_test async5-1.5 {\n  execsql { SELECT * FROM t1 }\n} {1 2 a b}\ndo_test async5-1.6 {\n  execsql { SELECT * FROM t2 }\n} {3 4 c d}\n\ndb close\n\nsqlite3async_control halt idle\nsqlite3async_start\nsqlite3async_wait\nsqlite3async_control halt never\nsqlite3async_shutdown\nset sqlite3async_trace 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/atof1.test",
    "content": "# 2012 June 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Tests of the sqlite3AtoF() function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {$::longdouble_size<=8} {\n  finish_test\n  return\n}\n\nexpr srand(1)\nfor {set i 1} {$i<20000} {incr i} {\n  set pow [expr {int((rand()-0.5)*100)}]\n  set x [expr {pow((rand()-0.5)*2*rand(),$pow)}]\n  set xf [format %.32e $x]\n\n  # Verify that text->real conversions get exactly same ieee754 floating-\n  # point value in SQLite as they do in TCL.\n  #\n  do_test atof1-1.$i.1 {\n    set y [db eval \"SELECT $xf=\\$x\"]\n    if {!$y} {\n      puts -nonewline \\173[db eval \"SELECT real2hex($xf), real2hex(\\$x)\"]\\175\n      db eval \"SELECT $xf+0.0 AS a, \\$x AS b\" {\n        puts [format \"\\n%.60e\\n%.60e\\n%.60e\" $x $a $b]\n      }\n    }\n    set y\n  } {1}\n\n  # Verify that round-trip real->text->real conversions using the quote()\n  # function preserve the bits of the numeric value exactly.\n  #\n  do_test atof1-1.$i.2 {\n    set y [db eval {SELECT $x=CAST(quote($x) AS real)}]\n    if {!$y} {\n      db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {}\n      puts \"\\nIN:    $a $xf\"\n      puts [format {QUOTE: %16s %s} {} [db eval {SELECT quote($x)}]]\n      db eval {SELECT CAST(quote($x) AS real) c} {}\n      puts \"OUT:   $b [format %.32e $c]\"\n    }\n    set y\n  } {1}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/atomic.test",
    "content": "# 2015-11-07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the WITH clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix atomic\n\ndb close\nif {[atomic_batch_write test.db]==0} {\n  puts \"No f2fs atomic-batch-write support. Skipping tests...\"\n  finish_test\n  return\n}\n\nreset_db\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y);\n  BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n}\n\ndo_test 1.1 { file exists test.db-journal } {0}\n\ndo_execsql_test 1.2 {\n  COMMIT;\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/attach.test",
    "content": "# 2003 April 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ATTACH and DETACH commands\n# and related functionality.\n#\n# $Id: attach.test,v 1.52 2009/05/29 14:39:08 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !attach {\n  finish_test\n  return\n}\n\nfor {set i 2} {$i<=15} {incr i} {\n  forcedelete test$i.db\n  forcedelete test$i.db-journal\n}\n\ndo_test attach-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4}\ndo_test attach-1.2 {\n  sqlite3 db2 test2.db\n  execsql {\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(1,'x');\n    INSERT INTO t2 VALUES(2,'y');\n    SELECT * FROM t2;\n  } db2\n} {1 x 2 y}\ndo_test attach-1.3 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    SELECT * FROM two.t2;\n  }\n} {1 x 2 y}\n\n# Tests for the sqlite3_db_filename interface\n#\ndo_test attach-1.3.1 {\n  file tail [sqlite3_db_filename db main]\n} {test.db}\ndo_test attach-1.3.2 {\n  file tail [sqlite3_db_filename db MAIN]\n} {test.db}\ndo_test attach-1.3.3 {\n  file tail [sqlite3_db_filename db temp]\n} {}\ndo_test attach-1.3.4 {\n  file tail [sqlite3_db_filename db two]\n} {test2.db}\ndo_test attach-1.3.5 {\n  file tail [sqlite3_db_filename db three]\n} {}\n\ndo_test attach-1.4 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 x 2 y}\ndo_test attach-1.5 {\n  execsql {\n    DETACH DATABASE two;\n    SELECT * FROM t1;\n  }\n} {1 2 3 4}\ndo_test attach-1.6 {\n  catchsql {\n    SELECT * FROM t2;\n  }\n} {1 {no such table: t2}}\ndo_test attach-1.7 {\n  catchsql {\n    SELECT * FROM two.t2;\n  }\n} {1 {no such table: two.t2}}\ndo_test attach-1.8 {\n  catchsql {\n    ATTACH DATABASE 'test3.db' AS three;\n  }\n} {0 {}}\ndo_test attach-1.9 {\n  catchsql {\n    SELECT * FROM three.sqlite_master;\n  }\n} {0 {}}\ndo_test attach-1.10 {\n  catchsql {\n    DETACH DATABASE [three];\n  }\n} {0 {}}\ndo_test attach-1.11 {\n  execsql {\n    ATTACH 'test.db' AS db2;\n    ATTACH 'test.db' AS db3;\n    ATTACH 'test.db' AS db4;\n    ATTACH 'test.db' AS db5;\n    ATTACH 'test.db' AS db6;\n    ATTACH 'test.db' AS db7;\n    ATTACH 'test.db' AS db8;\n    ATTACH 'test.db' AS db9;\n  }\n} {}\nproc db_list {db} {\n  set list {}\n  foreach {idx name file} [execsql {PRAGMA database_list} $db] {\n    lappend list $idx $name\n  }\n  return $list\n}\nifcapable schema_pragmas {\ndo_test attach-1.11b {\n  db_list db\n} {0 main 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}\n} ;# ifcapable schema_pragmas \ndo_test attach-1.12 {\n  catchsql {\n    ATTACH 'test.db' as db2;\n  }\n} {1 {database db2 is already in use}}\ndo_test attach-1.12.2 {\n  db errorcode\n} {1}\ndo_test attach-1.13 {\n  catchsql {\n    ATTACH 'test.db' as db5;\n  }\n} {1 {database db5 is already in use}}\ndo_test attach-1.14 {\n  catchsql {\n    ATTACH 'test.db' as db9;\n  }\n} {1 {database db9 is already in use}}\ndo_test attach-1.15 {\n  catchsql {\n    ATTACH 'test.db' as main;\n  }\n} {1 {database main is already in use}}\nifcapable tempdb {\n  do_test attach-1.16 {\n    catchsql {\n      ATTACH 'test.db' as temp;\n    }\n  } {1 {database temp is already in use}}\n}\ndo_test attach-1.17 {\n  catchsql {\n    ATTACH 'test.db' as MAIN;\n  }\n} {1 {database MAIN is already in use}}\ndo_test attach-1.18 {\n  catchsql {\n    ATTACH 'test.db' as db10;\n    ATTACH 'test.db' as db11;\n  }\n} {0 {}}\nif {$SQLITE_MAX_ATTACHED==10} {\n  do_test attach-1.19 {\n    catchsql {\n      ATTACH 'test.db' as db12;\n    }\n  } {1 {too many attached databases - max 10}}\n  do_test attach-1.19.1 {\n    db errorcode\n  } {1}\n}\ndo_test attach-1.20.1 {\n  execsql {\n    DETACH db5;\n  }\n} {}\nifcapable schema_pragmas {\ndo_test attach-1.20.2 {\n  db_list db\n} {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11}\n} ;# ifcapable schema_pragmas\nintegrity_check attach-1.20.3\nifcapable tempdb {\n  execsql {select * from temp.sqlite_master}\n}\ndo_test attach-1.21 {\n  catchsql {\n    ATTACH 'test.db' as db12;\n  }\n} {0 {}}\nif {$SQLITE_MAX_ATTACHED==10} {\n  do_test attach-1.22 {\n    catchsql {\n      ATTACH 'test.db' as db13;\n    }\n  } {1 {too many attached databases - max 10}}\n  do_test attach-1.22.1 {\n    db errorcode\n  } {1}\n}\ndo_test attach-1.23 {\n  catchsql {\n    DETACH \"db14\";\n  }\n} {1 {no such database: db14}}\ndo_test attach-1.24 {\n  catchsql {\n    DETACH db12;\n  }\n} {0 {}}\ndo_test attach-1.25 {\n  catchsql {\n    DETACH db12;\n  }\n} {1 {no such database: db12}}\ndo_test attach-1.26 {\n  catchsql {\n    DETACH main;\n  }\n} {1 {cannot detach database main}}\n\nifcapable tempdb {\n  do_test attach-1.27 {\n    catchsql {\n      DETACH Temp;\n    }\n  } {1 {cannot detach database Temp}}\n} else {\n  do_test attach-1.27 {\n    catchsql {\n      DETACH Temp;\n    }\n  } {1 {no such database: Temp}}\n}\n\ndo_test attach-1.28 {\n  catchsql {\n    DETACH db11;\n    DETACH db10;\n    DETACH db9;\n    DETACH db8;\n    DETACH db7;\n    DETACH db6;\n    DETACH db4;\n    DETACH db3;\n    DETACH db2;\n  }\n} {0 {}}\nifcapable schema_pragmas {\n  ifcapable tempdb {\n    do_test attach-1.29 {\n      db_list db\n    } {0 main 1 temp}\n  } else {\n    do_test attach-1.29 {\n      db_list db\n    } {0 main}\n  }\n} ;# ifcapable schema_pragmas\n\nifcapable {trigger} {  # Only do the following tests if triggers are enabled\ndo_test attach-2.1 {\n  execsql {\n    CREATE TABLE tx(x1,x2,y1,y2);\n    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN\n      INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);\n    END;\n    SELECT * FROM tx;\n  } db2;\n} {}\ndo_test attach-2.2 {\n  execsql {\n    UPDATE t2 SET x=x+10;\n    SELECT * FROM tx;\n  } db2;\n} {1 11 x x 2 12 y y}\ndo_test attach-2.3 {\n  execsql {\n    CREATE TABLE tx(x1,x2,y1,y2);\n    SELECT * FROM tx;\n  }\n} {}\ndo_test attach-2.4 {\n  execsql {\n    ATTACH 'test2.db' AS db2;\n  }\n} {}\ndo_test attach-2.5 {\n  execsql {\n    UPDATE db2.t2 SET x=x+10;\n    SELECT * FROM db2.tx;\n  }\n} {1 11 x x 2 12 y y 11 21 x x 12 22 y y}\ndo_test attach-2.6 {\n  execsql {\n    SELECT * FROM main.tx;\n  }\n} {}\ndo_test attach-2.7 {\n  execsql {\n    SELECT type, name, tbl_name FROM db2.sqlite_master;\n  }\n} {table t2 t2 table tx tx trigger r1 t2}\n\nifcapable schema_pragmas&&tempdb {\n  do_test attach-2.8 {\n    db_list db\n  } {0 main 1 temp 2 db2}\n} ;# ifcapable schema_pragmas&&tempdb\nifcapable schema_pragmas&&!tempdb {\n  do_test attach-2.8 {\n    db_list db\n  } {0 main 2 db2}\n} ;# ifcapable schema_pragmas&&!tempdb\n\ndo_test attach-2.9 {\n  execsql {\n    CREATE INDEX i2 ON t2(x);\n    SELECT * FROM t2 WHERE x>5;\n  } db2\n} {21 x 22 y}\ndo_test attach-2.10 {\n  execsql {\n    SELECT type, name, tbl_name FROM sqlite_master;\n  } db2\n} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}\n#do_test attach-2.11 {\n#  catchsql { \n#    SELECT * FROM t2 WHERE x>5;\n#  }\n#} {1 {database schema has changed}}\nifcapable schema_pragmas {\n  ifcapable tempdb {\n    do_test attach-2.12 {\n      db_list db\n    } {0 main 1 temp 2 db2}\n  } else {\n    do_test attach-2.12 {\n      db_list db\n    } {0 main 2 db2}\n  }\n} ;# ifcapable schema_pragmas\ndo_test attach-2.13 {\n  catchsql {\n    SELECT * FROM t2 WHERE x>5;\n  }\n} {0 {21 x 22 y}}\ndo_test attach-2.14 {\n  execsql {\n    SELECT type, name, tbl_name FROM sqlite_master;\n  }\n} {table t1 t1 table tx tx}\ndo_test attach-2.15 {\n  execsql {\n    SELECT type, name, tbl_name FROM db2.sqlite_master;\n  }\n} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}\ndo_test attach-2.16 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    ATTACH 'test2.db' AS db2;\n    SELECT type, name, tbl_name FROM db2.sqlite_master;\n  }\n} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}\n} ;# End of ifcapable {trigger}\n\ndo_test attach-3.1 {\n  db close\n  db2 close\n  sqlite3 db test.db\n  sqlite3 db2 test2.db\n  execsql {\n    SELECT * FROM t1\n  }\n} {1 2 3 4}\n\n# If we are testing a version of the code that lacks trigger support,\n# adjust the database contents so that they are the same if triggers\n# had been enabled.\nifcapable {!trigger} {\n  db2 eval {\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(21, 'x');\n    INSERT INTO t2 VALUES(22, 'y');\n    CREATE TABLE tx(x1,x2,y1,y2);\n    INSERT INTO tx VALUES(1, 11, 'x', 'x');\n    INSERT INTO tx VALUES(2, 12, 'y', 'y');\n    INSERT INTO tx VALUES(11, 21, 'x', 'x');\n    INSERT INTO tx VALUES(12, 22, 'y', 'y');\n    CREATE INDEX i2 ON t2(x);\n  }\n}\n\ndo_test attach-3.2 {\n  catchsql {\n    SELECT * FROM t2\n  }\n} {1 {no such table: t2}}\ndo_test attach-3.3 {\n  catchsql {\n    ATTACH DATABASE 'test2.db' AS db2;\n    SELECT * FROM t2\n  }\n} {0 {21 x 22 y}}\n\n# Even though 'db' has started a transaction, it should not yet have\n# a lock on test2.db so 'db2' should be readable.\ndo_test attach-3.4 {\n  execsql BEGIN\n  catchsql {\n    SELECT * FROM t2;\n  } db2;\n} {0 {21 x 22 y}}\n\n# Reading from test2.db from db within a transaction should not\n# prevent test2.db from being read by db2.\ndo_test attach-3.5 {\n  execsql {SELECT * FROM t2}\n  catchsql {\n    SELECT * FROM t2;\n  } db2;\n} {0 {21 x 22 y}}\n\n# Making a change to test2.db through db  causes test2.db to get\n# a reserved lock.  It should still be accessible through db2.\ndo_test attach-3.6 {\n  execsql {\n    UPDATE t2 SET x=x+1 WHERE x=50;\n  }\n  catchsql {\n    SELECT * FROM t2;\n  } db2;\n} {0 {21 x 22 y}}\n\ndo_test attach-3.7 {\n  execsql ROLLBACK\n  execsql {SELECT * FROM t2} db2\n} {21 x 22 y}\n\n# Start transactions on both db and db2.  Once again, just because\n# we make a change to test2.db using db2, only a RESERVED lock is\n# obtained, so test2.db should still be readable using db.\n#\ndo_test attach-3.8 {\n  execsql BEGIN\n  execsql BEGIN db2\n  execsql {UPDATE t2 SET x=0 WHERE 0} db2\n  catchsql {SELECT * FROM t2}\n} {0 {21 x 22 y}}\n\n# It is also still accessible from db2.\ndo_test attach-3.9 {\n  catchsql {SELECT * FROM t2} db2\n} {0 {21 x 22 y}}\n\ndo_test attach-3.10 {\n  execsql {SELECT * FROM t1}\n} {1 2 3 4}\n\ndo_test attach-3.11 {\n  catchsql {UPDATE t1 SET a=a+1}\n} {0 {}}\ndo_test attach-3.12 {\n  execsql {SELECT * FROM t1}\n} {2 2 4 4}\n\n# db2 has a RESERVED lock on test2.db, so db cannot write to any tables\n# in test2.db.\ndo_test attach-3.13 {\n  catchsql {UPDATE t2 SET x=x+1 WHERE x=50}\n} {1 {database is locked}}\n\n# Change for version 3. Transaction is no longer rolled back\n# for a locked database.\nexecsql {ROLLBACK}\n\n# db is able to reread its schema because db2 still only holds a\n# reserved lock.\ndo_test attach-3.14 {\n  catchsql {SELECT * FROM t1}\n} {0 {1 2 3 4}}\ndo_test attach-3.15 {\n  execsql COMMIT db2\n  execsql {SELECT * FROM t1}\n} {1 2 3 4}\n\n# Ticket #323\ndo_test attach-4.1 {\n  execsql {DETACH db2}\n  db2 close\n  sqlite3 db2 test2.db\n  execsql {\n    CREATE TABLE t3(x,y);\n    CREATE UNIQUE INDEX t3i1 ON t3(x);\n    INSERT INTO t3 VALUES(1,2);\n    SELECT * FROM t3;\n  } db2;\n} {1 2}\ndo_test attach-4.2 {\n  execsql {\n    CREATE TABLE t3(a,b);\n    CREATE UNIQUE INDEX t3i1b ON t3(a);\n    INSERT INTO t3 VALUES(9,10);\n    SELECT * FROM t3;\n  }\n} {9 10}\ndo_test attach-4.3 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS db2;\n    SELECT * FROM db2.t3;\n  }\n} {1 2}\ndo_test attach-4.4 {\n  execsql {\n    SELECT * FROM main.t3;\n  }\n} {9 10}\ndo_test attach-4.5 {\n  execsql {\n    INSERT INTO db2.t3 VALUES(9,10);\n    SELECT * FROM db2.t3;\n  }\n} {1 2 9 10}\nexecsql {\n  DETACH db2;\n}\nifcapable {trigger} {\n  do_test attach-4.6 {\n    execsql {\n      CREATE TABLE t4(x);\n      CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN\n        INSERT INTO t4 VALUES('db2.' || NEW.x);\n      END;\n      INSERT INTO t3 VALUES(6,7);\n      SELECT * FROM t4;\n    } db2\n  } {db2.6}\n  do_test attach-4.7 {\n    execsql {\n      CREATE TABLE t4(y);\n      CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN\n        INSERT INTO t4 VALUES('main.' || NEW.a);\n      END;\n      INSERT INTO main.t3 VALUES(11,12);\n      SELECT * FROM main.t4;\n    }\n  } {main.11}\n}\nifcapable {!trigger} {\n  # When we do not have trigger support, set up the table like they\n  # would have been had triggers been there.  The tests that follow need\n  # this setup.\n  execsql {\n    CREATE TABLE t4(x);\n    INSERT INTO t3 VALUES(6,7);\n    INSERT INTO t4 VALUES('db2.6');\n    INSERT INTO t4 VALUES('db2.13');\n  } db2\n  execsql {\n    CREATE TABLE t4(y);\n    INSERT INTO main.t3 VALUES(11,12);\n    INSERT INTO t4 VALUES('main.11');\n  }\n}\n\n\n# This one is tricky.  On the UNION ALL select, we have to make sure\n# the schema for both main and db2 is valid before starting to execute\n# the first query of the UNION ALL.  If we wait to test the validity of\n# the schema for main until after the first query has run, that test will\n# fail and the query will abort but we will have already output some\n# results.  When the query is retried, the results will be repeated.\n#\nifcapable compound {\ndo_test attach-4.8 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS db2;\n    INSERT INTO db2.t3 VALUES(13,14);\n    SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;\n  }\n} {db2.6 db2.13 main.11}\n\ndo_test attach-4.9 {\n  ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}}\n  execsql {\n    INSERT INTO main.t3 VALUES(15,16);\n    SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;\n  }\n} {db2.6 db2.13 main.11 main.15}\n} ;# ifcapable compound\n\nifcapable !compound {\n  ifcapable {!trigger} {execsql {INSERT INTO main.t4 VALUES('main.15')}}\n  execsql {\n    ATTACH DATABASE 'test2.db' AS db2;\n    INSERT INTO db2.t3 VALUES(13,14);\n    INSERT INTO main.t3 VALUES(15,16);\n  } \n} ;# ifcapable !compound\n\nifcapable view {\ndo_test attach-4.10 {\n  execsql {\n    DETACH DATABASE db2;\n  }\n  execsql {\n    CREATE VIEW v3 AS SELECT x*100+y FROM t3;\n    SELECT * FROM v3;\n  } db2\n} {102 910 607 1314}\ndo_test attach-4.11 {\n  execsql {\n    CREATE VIEW v3 AS SELECT a*100+b FROM t3;\n    SELECT * FROM v3;\n  }\n} {910 1112 1516}\ndo_test attach-4.12 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS db2;\n    SELECT * FROM db2.v3;\n  }\n} {102 910 607 1314}\ndo_test attach-4.13 {\n  execsql {\n    SELECT * FROM main.v3;\n  }\n} {910 1112 1516}\n} ;# ifcapable view\n\n# Tests for the sqliteFix...() routines in attach.c\n#\nifcapable {trigger} {\ndo_test attach-5.1 {\n  db close\n  sqlite3 db test.db\n  db2 close\n  forcedelete test2.db\n  sqlite3 db2 test2.db\n  catchsql {\n    ATTACH DATABASE 'test.db' AS orig;\n    CREATE TRIGGER r1 AFTER INSERT ON orig.t1 BEGIN\n      SELECT 'no-op';\n    END;\n  } db2\n} {1 {trigger r1 cannot reference objects in database orig}}\ndo_test attach-5.2 {\n  catchsql {\n    CREATE TABLE t5(x,y);\n    CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n      SELECT 'no-op';\n    END;\n  } db2\n} {0 {}}\ndo_test attach-5.3 {\n  catchsql {\n    DROP TRIGGER r5;\n    CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n      SELECT 'no-op' FROM orig.t1;\n    END;\n  } db2\n} {1 {trigger r5 cannot reference objects in database orig}}\nifcapable tempdb {\n  do_test attach-5.4 {\n    catchsql {\n      CREATE TEMP TABLE t6(p,q,r);\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        SELECT 'no-op' FROM temp.t6;\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n}\nifcapable subquery {\n  do_test attach-5.5 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        SELECT 'no-op' || (SELECT * FROM temp.t6);\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n  do_test attach-5.6 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        SELECT 'no-op' FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n  do_test attach-5.7 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        SELECT 'no-op' FROM t1 GROUP BY 1 HAVING x<(SELECT min(x) FROM temp.t6);\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n  do_test attach-5.7 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        SELECT max(1,x,(SELECT min(x) FROM temp.t6)) FROM t1;\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n  do_test attach-5.8 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        INSERT INTO t1 VALUES((SELECT min(x) FROM temp.t6),5);\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n  do_test attach-5.9 {\n    catchsql {\n      CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN\n        DELETE FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);\n      END;\n    } db2\n  } {1 {trigger r5 cannot reference objects in database temp}}\n} ;# endif subquery\n} ;# endif trigger\n\n# Check to make sure we get a sensible error if unable to open\n# the file that we are trying to attach.\n#\ndo_test attach-6.1 {\n  catchsql {\n    ATTACH DATABASE 'no-such-file' AS nosuch;\n  }\n} {0 {}}\nif {$tcl_platform(platform)==\"unix\"} {\n  do_test attach-6.2 {\n    sqlite3 dbx cannot-read\n    dbx eval {CREATE TABLE t1(a,b,c)}\n    dbx close\n    file attributes cannot-read -permission 0000\n    if {[file writable cannot-read]} {\n      puts \"\\n**** Tests do not work when run as root ****\"\n      forcedelete cannot-read\n      exit 1\n    }\n    catchsql {\n      ATTACH DATABASE 'cannot-read' AS noread;\n    }\n  } {1 {unable to open database: cannot-read}}\n  do_test attach-6.2.2 {\n    db errorcode\n  } {14}\n  forcedelete cannot-read\n}\n\n# Check the error message if we try to access a database that has\n# not been attached.\ndo_test attach-6.3 {\n  catchsql {\n    CREATE TABLE no_such_db.t1(a, b, c);\n  }\n} {1 {unknown database no_such_db}}\nfor {set i 2} {$i<=15} {incr i} {\n  catch {db$i close}\n}\ndb close\nforcedelete test2.db\nforcedelete no-such-file\n\nifcapable subquery {\n  do_test attach-7.1 {\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    catchsql {\n      DETACH RAISE ( IGNORE ) IN ( SELECT \"AAAAAA\" . * ORDER BY \n      REGISTER LIMIT \"AAAAAA\" . \"AAAAAA\" OFFSET RAISE ( IGNORE ) NOT NULL )\n    }\n  } {1 {no such table: AAAAAA}}\n}\n\n# Create a malformed file (a file that is not a valid database)\n# and try to attach it\n#\ndo_test attach-8.1 {\n  set fd [open test2.db w]\n  puts $fd \"This file is not a valid SQLite database\"\n  close $fd\n  catchsql {\n    ATTACH 'test2.db' AS t2;\n  }\n} {1 {file is not a database}}\ndo_test attach-8.2 {\n  db errorcode\n} {26}\nforcedelete test2.db\ndo_test attach-8.3 {\n  sqlite3 db2 test2.db\n  db2 eval {CREATE TABLE t1(x); BEGIN EXCLUSIVE}\n  catchsql {\n    ATTACH 'test2.db' AS t2;\n  }\n} {1 {database is locked}}\ndo_test attach-8.4 {\n  db errorcode\n} {5}\ndb2 close\nforcedelete test2.db\n\n# Test that it is possible to attach the same database more than\n# once when not in shared-cache mode. That this is not possible in\n# shared-cache mode is tested in shared7.test.\ndo_test attach-9.1 {\n  forcedelete test4.db\n  execsql {\n    ATTACH 'test4.db' AS aux1;\n    CREATE TABLE aux1.t1(a, b);\n    INSERT INTO aux1.t1 VALUES(1, 2);\n    ATTACH 'test4.db' AS aux2;\n    SELECT * FROM aux2.t1;\n  }\n} {1 2}\ndo_test attach-9.2 {\n  catchsql {\n    BEGIN;\n      INSERT INTO aux1.t1 VALUES(3, 4);\n      INSERT INTO aux2.t1 VALUES(5, 6);\n  }\n} {1 {database is locked}}\ndo_test attach-9.3 {\n  execsql {\n    COMMIT;\n    SELECT * FROM aux2.t1;\n  }\n} {1 2 3 4}\n\n# Ticket [abe728bbc311d81334dae9762f0db87c07a98f79].\n# Multi-database commit on an attached TEMP database.\n#\ndo_test attach-10.1 {\n  execsql {\n    ATTACH '' AS noname;\n    ATTACH ':memory:' AS inmem;\n    BEGIN;\n    CREATE TABLE noname.noname(x);\n    CREATE TABLE inmem.inmem(y);\n    CREATE TABLE main.main(z);\n    COMMIT;\n    SELECT name FROM noname.sqlite_master;\n    SELECT name FROM inmem.sqlite_master;\n  }\n} {noname inmem}\ndo_test attach-10.2 {\n  lrange [execsql {\n    PRAGMA database_list;\n  }] 9 end\n} {4 noname {} 5 inmem {}}\n\n# Attach with a very long URI filename.\n#\ndb close\nsqlite3 db test.db -uri 1\ndo_execsql_test attach-11.1 {\n  ATTACH printf('file:%09000x/x.db?mode=memory&cache=shared',1) AS aux1;\n  CREATE TABLE aux1.t1(x,y);\n  INSERT INTO aux1.t1(x,y) VALUES(1,2),(3,4);\n  SELECT * FROM aux1.t1;\n} {1 2 3 4}\n\n# Ticket https://sqlite.org/src/tktview/a4e06e75a9ab61a1  2017-07-15\n# False positive when running integrity_check on a connection with\n# attached databases.  \n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test attach-12.1 {\n  CREATE TABLE Table1 (col TEXT NOT NULL PRIMARY KEY);\n  ATTACH ':memory:' AS db2;\n  CREATE TABLE db2.Table2(col1 INTEGER, col2 INTEGER, col3 INTEGER, col4);\n  CREATE UNIQUE INDEX db2.idx_col1_unique ON Table2 (col1);\n  CREATE UNIQUE INDEX db2.idx_col23_unique ON Table2 (col2, col3);\n  CREATE INDEX db2.idx_col2 ON Table2 (col2);\n  INSERT INTO Table2 VALUES(1,2,3,4);\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/attach2.test",
    "content": "# 2003 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ATTACH and DETACH commands\n# and related functionality.\n#\n# $Id: attach2.test,v 1.38 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !attach {\n  finish_test\n  return\n}\n\n# Ticket #354\n#\n# Databases test.db and test2.db contain identical schemas.  Make\n# sure we can attach test2.db from test.db.\n#\ndo_test attach2-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    CREATE INDEX x1 ON t1(a);\n  }\n  forcedelete test2.db\n  forcedelete test2.db-journal\n  sqlite3 db2 test2.db\n  db2 eval {\n    CREATE TABLE t1(a,b);\n    CREATE INDEX x1 ON t1(a);\n  }\n  catchsql {\n    ATTACH 'test2.db' AS t2;\n  }\n} {0 {}}\n\n# Ticket #514\n#\nproc db_list {db} {\n  set list {}\n  foreach {idx name file} [execsql {PRAGMA database_list} $db] {\n    lappend list $idx $name\n  }\n  return $list\n}\ndb eval {DETACH t2}\ndo_test attach2-2.1 {\n  # lock test2.db then try to attach it.  This is no longer an error because\n  # db2 just RESERVES the database.  It does not obtain a write-lock until\n  # we COMMIT.\n  db2 eval {BEGIN}\n  db2 eval {UPDATE t1 SET a = 0 WHERE 0}\n  catchsql {\n    ATTACH 'test2.db' AS t2;\n  }\n} {0 {}}\nifcapable schema_pragmas {\ndo_test attach2-2.2 {\n  # make sure test2.db did get attached.\n  db_list db\n} {0 main 2 t2}\n} ;# ifcapable schema_pragmas\ndb2 eval {COMMIT}\n\ndo_test attach2-2.5 {\n  # Make sure we can read test2.db from db\n  catchsql {\n    SELECT name FROM t2.sqlite_master;\n  }\n} {0 {t1 x1}}\ndo_test attach2-2.6 {\n  # lock test2.db and try to read from it.  This should still work because\n  # the lock is only a RESERVED lock which does not prevent reading.\n  #\n  db2 eval BEGIN\n  db2 eval {UPDATE t1 SET a = 0 WHERE 0}\n  catchsql {\n    SELECT name FROM t2.sqlite_master;\n  }\n} {0 {t1 x1}}\ndo_test attach2-2.7 {\n  # but we can still read from test1.db even though test2.db is locked.\n  catchsql {\n    SELECT name FROM main.sqlite_master;\n  }\n} {0 {t1 x1}}\ndo_test attach2-2.8 {\n  # start a transaction on test.db even though test2.db is locked.\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(8,9);\n  }\n} {0 {}}\ndo_test attach2-2.9 {\n  execsql {\n    SELECT * FROM t1\n  }\n} {8 9}\ndo_test attach2-2.10 {\n  # now try to write to test2.db.  the write should fail\n  catchsql {\n    INSERT INTO t2.t1 VALUES(1,2);\n  }\n} {1 {database is locked}}\ndo_test attach2-2.11 {\n  # when the write failed in the previous test, the transaction should\n  # have rolled back.\n  # \n  # Update for version 3: A transaction is no longer rolled back if a\n  #                       database is found to be busy.\n  execsql {rollback}\n  db2 eval ROLLBACK\n  execsql {\n    SELECT * FROM t1\n  }\n} {}\ndo_test attach2-2.12 {\n  catchsql {\n    COMMIT\n  }\n} {1 {cannot commit - no transaction is active}}\n\n# Ticket #574:  Make sure it works using the non-callback API\n#\ndo_test attach2-3.1 {\n  set DB [sqlite3_connection_pointer db]\n  set rc [catch {sqlite3_prepare $DB \"ATTACH 'test2.db' AS t2\" -1 TAIL} VM]\n  if {$rc} {lappend rc $VM}\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  set rc\n} {0}\ndo_test attach2-3.2 {\n  set rc [catch {sqlite3_prepare $DB \"DETACH t2\" -1 TAIL} VM]\n  if {$rc} {lappend rc $VM}\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  set rc\n} {0}\n\ndb close\nfor {set i 2} {$i<=15} {incr i} {\n  catch {db$i close}\n}\n\n# A procedure to verify the status of locks on a database.\n#\nproc lock_status {testnum db expected_result} {\n  # If the database was compiled with OMIT_TEMPDB set, then \n  # the lock_status list will not contain an entry for the temp\n  # db. But the test code doesn't know this, so its easiest \n  # to filter it out of the $expected_result list here.\n  ifcapable !tempdb {\n    set expected_result [concat \\\n        [lrange $expected_result 0 1] \\\n        [lrange $expected_result 4 end] \\\n    ]\n  }\n  do_test attach2-$testnum [subst {\n    $db cache flush  ;# The lock_status pragma should not be cached\n    execsql {PRAGMA lock_status} $db\n  }] $expected_result\n}\nset sqlite_os_trace 0\n\n# Tests attach2-4.* test that read-locks work correctly with attached\n# databases.\ndo_test attach2-4.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {ATTACH 'test2.db' as file2}\n  execsql {ATTACH 'test2.db' as file2} db2\n} {}\n\nlock_status 4.1.1 db {main unlocked temp closed file2 unlocked}\nlock_status 4.1.2 db2 {main unlocked temp closed file2 unlocked}\n\ndo_test attach2-4.2 {\n  # Handle 'db' read-locks test.db\n  execsql {BEGIN}\n  execsql {SELECT * FROM t1}\n  # Lock status:\n  #    db  - shared(main)\n  #    db2 -\n} {}\n\nlock_status 4.2.1 db {main shared temp closed file2 unlocked}\nlock_status 4.2.2 db2 {main unlocked temp closed file2 unlocked}\n\ndo_test attach2-4.3 {\n  # The read lock held by db does not prevent db2 from reading test.db\n  execsql {SELECT * FROM t1} db2\n} {}\n\nlock_status 4.3.1 db {main shared temp closed file2 unlocked}\nlock_status 4.3.2 db2 {main unlocked temp closed file2 unlocked}\n\ndo_test attach2-4.4 {\n  # db is holding a read lock on test.db, so we should not be able\n  # to commit a write to test.db from db2\n  catchsql {\n    INSERT INTO t1 VALUES(1, 2)\n  } db2 \n} {1 {database is locked}}\n\nlock_status 4.4.1 db {main shared temp closed file2 unlocked}\nlock_status 4.4.2 db2 {main unlocked temp closed file2 unlocked}\n\n# We have to make sure that the cache_size and the soft_heap_limit\n# are large enough to hold the entire change in memory.  If either\n# is set too small, then changes will spill to the database, forcing\n# a reserved lock to promote to exclusive.  That will mess up our\n# test results. \n\nset soft_limit [sqlite3_soft_heap_limit 0]\n\n\ndo_test attach2-4.5 {\n  # Handle 'db2' reserves file2.\n  execsql {BEGIN} db2\n  execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2\n  # Lock status:\n  #    db  - shared(main)\n  #    db2 - reserved(file2)\n} {}\n\nlock_status 4.5.1 db {main shared temp closed file2 unlocked}\nlock_status 4.5.2 db2 {main unlocked temp closed file2 reserved}\n\ndo_test attach2-4.6.1 {\n  # Reads are allowed against a reserved database.\n  catchsql {\n    SELECT * FROM file2.t1;\n  }\n  # Lock status:\n  #    db  - shared(main), shared(file2)\n  #    db2 - reserved(file2)\n} {0 {}}\n\nlock_status 4.6.1.1 db {main shared temp closed file2 shared}\nlock_status 4.6.1.2 db2 {main unlocked temp closed file2 reserved}\n\ndo_test attach2-4.6.2 {\n  # Writes against a reserved database are not allowed.\n  catchsql {\n    UPDATE file2.t1 SET a=0;\n  }\n} {1 {database is locked}}\n\nlock_status 4.6.2.1 db {main shared temp closed file2 shared}\nlock_status 4.6.2.2 db2 {main unlocked temp closed file2 reserved}\n\ndo_test attach2-4.7 {\n  # Ensure handle 'db' retains the lock on the main file after\n  # failing to obtain a write-lock on file2.\n  catchsql {\n    INSERT INTO t1 VALUES(1, 2)\n  } db2 \n} {0 {}}\n\nlock_status 4.7.1 db {main shared temp closed file2 shared}\nlock_status 4.7.2 db2 {main reserved temp closed file2 reserved}\n\ndo_test attach2-4.8 {\n  # We should still be able to read test.db from db2\n  execsql {SELECT * FROM t1} db2\n} {1 2}\n\nlock_status 4.8.1 db {main shared temp closed file2 shared}\nlock_status 4.8.2 db2 {main reserved temp closed file2 reserved}\n\ndo_test attach2-4.9 {\n  # Try to upgrade the handle 'db' lock.\n  catchsql {\n    INSERT INTO t1 VALUES(1, 2)\n  }\n} {1 {database is locked}}\n\nlock_status 4.9.1 db {main shared temp closed file2 shared}\nlock_status 4.9.2 db2 {main reserved temp closed file2 reserved}\n\ndo_test attach2-4.10 {\n  # We cannot commit db2 while db is holding a read-lock\n  catchsql {COMMIT} db2\n} {1 {database is locked}}\n\nlock_status 4.10.1 db {main shared temp closed file2 shared}\nlock_status 4.10.2 db2 {main pending temp closed file2 reserved}\n\nset sqlite_os_trace 0\ndo_test attach2-4.11 {\n  # db is able to commit.\n  catchsql {COMMIT}\n} {0 {}}\n\nlock_status 4.11.1 db {main unlocked temp closed file2 unlocked}\nlock_status 4.11.2 db2 {main pending temp closed file2 reserved}\n\ndo_test attach2-4.12 {\n  # Now we can commit db2\n  catchsql {COMMIT} db2\n} {0 {}}\n\nlock_status 4.12.1 db {main unlocked temp closed file2 unlocked}\nlock_status 4.12.2 db2 {main unlocked temp closed file2 unlocked}\n\ndo_test attach2-4.13 {\n  execsql {SELECT * FROM file2.t1}\n} {1 2}\ndo_test attach2-4.14 {\n  execsql {INSERT INTO t1 VALUES(1, 2)}\n} {}\ndo_test attach2-4.15 {\n  execsql {SELECT * FROM t1} db2\n} {1 2 1 2}\n\ndb close\ndb2 close\nforcedelete test2.db\nsqlite3_soft_heap_limit $soft_limit\n\n# These tests - attach2-5.* - check that the master journal file is deleted\n# correctly when a multi-file transaction is committed or rolled back.\n#\n# Update: It's not actually created if a rollback occurs, so that test\n# doesn't really prove too much.\nforeach f [glob test.db*] {forcedelete $f}\ndo_test attach2-5.1 {\n  sqlite3 db test.db\n  execsql {\n    ATTACH 'test.db2' AS aux;\n  }\n} {}\ndo_test attach2-5.2 {\n  execsql {\n    BEGIN;\n    CREATE TABLE tbl(a, b, c);\n    CREATE TABLE aux.tbl(a, b, c);\n    COMMIT;\n  }\n} {}\ndo_test attach2-5.3 {\n  lsort [glob test.db*]\n} {test.db test.db2}\ndo_test attach2-5.4 {\n  execsql {\n    BEGIN;\n    DROP TABLE aux.tbl;\n    DROP TABLE tbl;\n    ROLLBACK;\n  }\n} {}\ndo_test attach2-5.5 {\n  lsort [glob test.db*]\n} {test.db test.db2}\n\n# Check that a database cannot be ATTACHed or DETACHed during a transaction.\ndo_test attach2-6.1 {\n  execsql {\n    BEGIN;\n  }\n} {}\ndo_test attach2-6.2 {\n  catchsql {\n    ATTACH 'test3.db' as aux2;\n    DETACH aux2;\n  }\n} {0 {}}\n\n# As of version 3.21.0: it is ok to DETACH from within a transaction\n#\ndo_test attach2-6.3 {\n  catchsql {\n    DETACH aux;\n  }\n} {0 {}}\n\ndb close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/attach3.test",
    "content": "# 2003 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ATTACH and DETACH commands\n# and schema changes to attached databases.\n#\n# $Id: attach3.test,v 1.18 2007/10/09 08:29:32 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !attach {\n  finish_test\n  return\n}\n\n# The tests in this file were written before SQLite supported recursive\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\n# Create tables t1 and t2 in the main database\nexecsql {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(c, d);\n}\n\n# Create tables t1 and t2 in database file test2.db\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db2 test2.db\nexecsql {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(c, d);\n} db2\ndb2 close\n\n# Create a table in the auxilary database.\ndo_test attach3-1.1 {\n  execsql {\n    ATTACH 'test2.db' AS aux;\n  }\n} {}\ndo_test attach3-1.2 {\n  execsql {\n    CREATE TABLE aux.t3(e, f);\n  }\n} {}\ndo_test attach3-1.3 {\n  execsql {\n    SELECT * FROM sqlite_master WHERE name = 't3';\n  }\n} {}\ndo_test attach3-1.4 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 't3';\n  }\n} \"table t3 t3 [expr $AUTOVACUUM?5:4] {CREATE TABLE t3(e, f)}\"\ndo_test attach3-1.5 {\n  execsql {\n    INSERT INTO t3 VALUES(1, 2);\n    SELECT * FROM t3;\n  }\n} {1 2}\n\n# Create an index on the auxilary database table.\ndo_test attach3-2.1 {\n  execsql {\n    CREATE INDEX aux.i1 on t3(e);\n  }\n} {}\ndo_test attach3-2.2 {\n  execsql {\n    SELECT * FROM sqlite_master WHERE name = 'i1';\n  }\n} {}\ndo_test attach3-2.3 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 'i1';\n  }\n} \"index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}\"\n\n# Drop the index on the aux database table.\ndo_test attach3-3.1 {\n  execsql {\n    DROP INDEX aux.i1;\n    SELECT * FROM aux.sqlite_master WHERE name = 'i1';\n  }\n} {}\ndo_test attach3-3.2 {\n  execsql {\n    CREATE INDEX aux.i1 on t3(e);\n    SELECT * FROM aux.sqlite_master WHERE name = 'i1';\n  }\n} \"index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}\"\ndo_test attach3-3.3 {\n  execsql {\n    DROP INDEX i1;\n    SELECT * FROM aux.sqlite_master WHERE name = 'i1';\n  }\n} {}\n\n# Drop tables t1 and t2 in the auxilary database.\ndo_test attach3-4.1 {\n  execsql {\n    DROP TABLE aux.t1;\n    SELECT name FROM aux.sqlite_master;\n  }\n} {t2 t3}\ndo_test attach3-4.2 {\n  # This will drop main.t2\n  execsql {\n    DROP TABLE t2;\n    SELECT name FROM aux.sqlite_master;\n  }\n} {t2 t3}\ndo_test attach3-4.3 {\n  execsql {\n    DROP TABLE t2;\n    SELECT name FROM aux.sqlite_master;\n  }\n} {t3}\n\n# Create a view in the auxilary database.\nifcapable view {\ndo_test attach3-5.1 {\n  execsql {\n    CREATE VIEW aux.v1 AS SELECT * FROM t3;\n  }\n} {}\ndo_test attach3-5.2 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 'v1';\n  }\n} {view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t3}}\ndo_test attach3-5.3 {\n  execsql {\n    INSERT INTO aux.t3 VALUES('hello', 'world');\n    SELECT * FROM v1;\n  }\n} {1 2 hello world}\n\n# Drop the view \ndo_test attach3-6.1 {\n  execsql {\n    DROP VIEW aux.v1;\n  }\n} {}\ndo_test attach3-6.2 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 'v1';\n  }\n} {}\n} ;# ifcapable view\n\nifcapable {trigger} {\n# Create a trigger in the auxilary database.\ndo_test attach3-7.1 {\n  execsql {\n    CREATE TRIGGER aux.tr1 AFTER INSERT ON t3 BEGIN\n      INSERT INTO t3 VALUES(new.e*2, new.f*2);\n    END;\n  }\n} {}\ndo_test attach3-7.2 {\n  execsql {\n    DELETE FROM t3;\n    INSERT INTO t3 VALUES(10, 20);\n    SELECT * FROM t3;\n  }\n} {10 20 20 40}\ndo_test attach3-5.3 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 'tr1';\n  }\n} {trigger tr1 t3 0 {CREATE TRIGGER tr1 AFTER INSERT ON t3 BEGIN\n      INSERT INTO t3 VALUES(new.e*2, new.f*2);\n    END}}\n\n# Drop the trigger \ndo_test attach3-8.1 {\n  execsql {\n    DROP TRIGGER aux.tr1;\n  }\n} {}\ndo_test attach3-8.2 {\n  execsql {\n    SELECT * FROM aux.sqlite_master WHERE name = 'tr1';\n  }\n} {}\n\nifcapable tempdb {\n  # Try to trick SQLite into dropping the wrong temp trigger.\n  do_test attach3-9.0 {\n    execsql {\n      CREATE TABLE main.t4(a, b, c);\n      CREATE TABLE aux.t4(a, b, c);\n      CREATE TEMP TRIGGER tst_trigger BEFORE INSERT ON aux.t4 BEGIN \n        SELECT 'hello world';\n      END;\n      SELECT count(*) FROM temp.sqlite_master;\n    }\n  } {1}\n  do_test attach3-9.1 {\n    execsql {\n      DROP TABLE main.t4;\n      SELECT count(*) FROM sqlite_temp_master;\n    }\n  } {1}\n  do_test attach3-9.2 {\n    execsql {\n      DROP TABLE aux.t4;\n      SELECT count(*) FROM temp.sqlite_master;\n    }\n  } {0}\n}\n} ;# endif trigger\n\n# Make sure the aux.sqlite_master table is read-only\ndo_test attach3-10.0 {\n  catchsql {\n    INSERT INTO aux.sqlite_master VALUES(1, 2, 3, 4, 5);\n  }\n} {1 {table sqlite_master may not be modified}}\n\n# Failure to attach leaves us in a workable state.\n# Ticket #811\n#\ndo_test attach3-11.0 {\n  catchsql {\n    ATTACH DATABASE '/nodir/nofile.x' AS notadb;\n  }\n} {1 {unable to open database: /nodir/nofile.x}}\ndo_test attach3-11.1 {\n  catchsql {\n    ATTACH DATABASE ':memory:' AS notadb;\n  }\n} {0 {}}\ndo_test attach3-11.2 {\n  catchsql {\n    DETACH DATABASE notadb;\n  }\n} {0 {}}\n\n# Return a list of attached databases\n#\nproc db_list {} {\n  set x [execsql {\n    PRAGMA database_list;\n  }]\n  set y {}\n  foreach {n id file} $x {lappend y $id}\n  return $y\n}\n\nifcapable schema_pragmas&&tempdb {\n\nifcapable !trigger {\n  execsql {create temp table dummy(dummy)}\n}\n\n# Ticket #1825\n#\ndo_test attach3-12.1 {\n  db_list\n} {main temp aux}\ndo_test attach3-12.2 {\n  execsql {\n    ATTACH DATABASE ? AS ?\n  }\n  db_list\n} {main temp aux {}}\ndo_test attach3-12.3 {\n  execsql {\n    DETACH aux\n  }\n  db_list\n} {main temp {}}\ndo_test attach3-12.4 {\n  execsql {\n    DETACH ?\n  }\n  db_list\n} {main temp}\ndo_test attach3-12.5 {\n  execsql {\n    ATTACH DATABASE '' AS ''\n  }\n  db_list\n} {main temp {}}\ndo_test attach3-12.6 {\n  execsql {\n    DETACH ''\n  }\n  db_list\n} {main temp}\ndo_test attach3-12.7 {\n  execsql {\n    ATTACH DATABASE '' AS ?\n  }\n  db_list\n} {main temp {}}\ndo_test attach3-12.8 {\n  execsql {\n    DETACH ''\n  }\n  db_list\n} {main temp}\ndo_test attach3-12.9 {\n  execsql {\n    ATTACH DATABASE '' AS NULL\n  }\n  db_list\n} {main temp {}}\ndo_test attach3-12.10 {\n  execsql {\n    DETACH ?\n  }\n  db_list\n} {main temp}\ndo_test attach3-12.11 {\n  catchsql {\n    DETACH NULL\n  }\n} {1 {no such database: }}\ndo_test attach3-12.12 {\n  catchsql {\n    ATTACH null AS null;\n    ATTACH '' AS '';\n  }\n} {1 {database  is already in use}}\ndo_test attach3-12.13 {\n  db_list\n} {main temp {}}\ndo_test attach3-12.14 {\n  execsql {\n    DETACH '';\n  }\n  db_list\n} {main temp}\n\n} ;# ifcapable pragma\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/attach4.test",
    "content": "# 200 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is attaching many database files to a single\n# connection.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix attach4\n\nifcapable !attach {\n  finish_test\n  return\n}\n\nputs \"Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED\"\n\nset files {main test.db}\nfor {set ii 0} {$ii < $SQLITE_MAX_ATTACHED} {incr ii} {\n  lappend files aux$ii \"test.db$ii\"\n}\n\ndo_test 1.1 {\n  sqlite3_limit db SQLITE_LIMIT_ATTACHED -1\n} $SQLITE_MAX_ATTACHED\n\ndo_test 1.2.1 {\n  db close\n  foreach {name f} $files { forcedelete $f }\n  sqlite3 db test.db\n  \n  foreach {name f} $files {\n    if {$name == \"main\"} continue\n    execsql \"ATTACH '$f' AS $name\"\n  }\n\n  db eval {PRAGMA database_list} {\n    lappend L $name [file tail $file]\n  }\n  set L\n} $files\n\ndo_catchsql_test 1.2.2 {\n  ATTACH 'x.db' AS next;\n} [list 1 \"too many attached databases - max $SQLITE_MAX_ATTACHED\"]\n\ndo_test 1.3 {\n  execsql BEGIN;\n  foreach {name f} $files {\n    execsql \"CREATE TABLE $name.tbl(x)\"\n    execsql \"INSERT INTO $name.tbl VALUES('$f')\"\n  }\n  execsql COMMIT;\n} {}\n\ndo_test 1.4 {\n  set L [list]\n  foreach {name f} $files {\n    lappend L $name [execsql \"SELECT x FROM $name.tbl\"]\n  }\n  set L\n} $files\n\nset L [list]\nset S \"\"\nforeach {name f} $files {\n  if {[permutation] == \"journaltest\"} {\n    set mode delete\n  } else {\n    set mode wal\n  }\n  ifcapable !wal { set mode delete }\n  lappend L $mode\n  append S \"\n    PRAGMA $name.journal_mode = WAL;\n    UPDATE $name.tbl SET x = '$name';\n  \"\n}\ndo_execsql_test 1.5 $S $L\n\ndo_test 1.6 {\n  set L [list]\n  foreach {name f} $files {\n    lappend L [execsql \"SELECT x FROM $name.tbl\"] $f\n  }\n  set L\n} $files\n\ndo_test 1.7 {\n  execsql BEGIN;\n  foreach {name f} $files {\n    execsql \"UPDATE $name.tbl SET x = '$f'\"\n  }\n  execsql COMMIT;\n} {}\n\ndo_test 1.8 {\n  set L [list]\n  foreach {name f} $files {\n    lappend L $name [execsql \"SELECT x FROM $name.tbl\"]\n  }\n  set L\n} $files\n\ndb close\nforeach {name f} $files { forcedelete $f }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/attachmalloc.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the ATTACH statement and\n# specifically out-of-memory conditions within that command.\n#\n# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !memdebug||!attach {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\n\ndo_malloc_test attachmalloc-1 -tclprep {\n  catch { db close }\n  for {set i 2} {$i<=4} {incr i} {\n    catch { db$i close }\n    forcedelete test$i.db\n    forcedelete test$i.db-journal\n  }\n} -tclbody {\n  if {[catch {sqlite3 db test.db}]} {\n    error \"out of memory\"\n  }\n  sqlite3_db_config_lookaside db 0 0 0\n  sqlite3_extended_result_codes db 1\n} -sqlbody {\n  ATTACH 'test2.db' AS two;\n  CREATE TABLE two.t1(x);\n  ATTACH 'test3.db' AS three;\n  CREATE TABLE three.t1(x);\n  ATTACH 'test4.db' AS four;\n  CREATE TABLE four.t1(x);\n}\n\ndo_malloc_test attachmalloc-2 -tclprep {\n  forcedelete test2.db\n  forcedelete test2.db-journal\n  sqlite3 db2 test2.db\n  db2 eval {\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(a, b);\n  }\n  db2 close\n} -sqlbody {\n  CREATE TABLE t1(d, e, f);\n  ATTACH 'test2.db' AS db1;\n}\n\nset enable_shared_cache [sqlite3_enable_shared_cache 1]\nsqlite3 dbaux test3.db\ndbaux eval {SELECT * FROM sqlite_master}\ndo_malloc_test attachmalloc-3 -sqlbody {\n  SELECT * FROM sqlite_master;\n  ATTACH 'test3.db' AS three;\n} -cleanup {\n  db eval { DETACH three }\n}\ndbaux close\nsqlite3_enable_shared_cache $enable_shared_cache\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/auth.test",
    "content": "# 2003 April 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the sqlite3_set_authorizer() API\n# and related functionality.\n#\n# $Id: auth.test,v 1.46 2009/07/02 18:40:35 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is\n# defined during compilation.\nif {[catch {db auth {}} msg]} {\n  finish_test\n  return\n}\n\nrename proc proc_real\nproc_real proc {name arguments script} {\n  proc_real $name $arguments $script\n  if {$name==\"auth\"} {\n    db authorizer ::auth\n  }\n}\n\ndo_test auth-1.1.1 {\n  db close\n  set ::DB [sqlite3 db test.db]\n  proc authx {code arg1 arg2 arg3 arg4 args} {return SQLITE_DENY}\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  db authorizer ::authx\n  # EVIDENCE-OF: R-03993-24285 Only a single authorizer can be in place on\n  # a database connection at a time. Each call to sqlite3_set_authorizer\n  # overrides the previous call.\n  #\n  # The authx authorizer above is overridden by the auth authorizer below\n  # authx is never invoked.\n  db authorizer ::auth\n  catchsql {CREATE TABLE t1(a,b,c)}\n} {1 {not authorized}}\ndo_test auth-1.1.2 {\n  db errorcode\n} {23}\ndo_test auth-1.1.3 {\n  db authorizer\n} {::auth}\ndo_test auth-1.1.4 {\n  # Ticket #896.\n  catchsql {\n    SELECT x;\n  }\n} {1 {no such column: x}}\ndo_test auth-1.2 {\n  execsql {SELECT name FROM sqlite_master}\n} {}\n# EVIDENCE-OF: R-04452-49349 When the callback returns SQLITE_DENY, the\n# sqlite3_prepare_v2() or equivalent call that triggered the authorizer\n# will fail with an error message explaining that access is denied.\ndo_test auth-1.3.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE TABLE t1(a,b,c)}\n} {1 {not authorized}}\ndo_test auth-1.3.2 {\n  db errorcode\n} {23}\ndo_test auth-1.3.3 {\n  set ::authargs\n} {t1 {} main {}}\ndo_test auth-1.4 {\n  execsql {SELECT name FROM sqlite_master}\n} {}\n\nifcapable tempdb {\n  do_test auth-1.5 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMP TABLE t1(a,b,c)}\n  } {1 {not authorized}}\n  do_test auth-1.6 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {}\n  do_test auth-1.7.1 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMP TABLE t1(a,b,c)}\n  } {1 {not authorized}}\n  do_test auth-1.7.2 {\n     set ::authargs\n  } {t1 {} temp {}}\n  do_test auth-1.8 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {}\n}\n\ndo_test auth-1.9 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE TABLE t1(a,b,c)}\n} {0 {}}\ndo_test auth-1.10 {\n  execsql {SELECT name FROM sqlite_master}\n} {}\ndo_test auth-1.11 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE TABLE t1(a,b,c)}\n} {0 {}}\ndo_test auth-1.12 {\n  execsql {SELECT name FROM sqlite_master}\n} {}\n\nifcapable tempdb {\n  do_test auth-1.13 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMP TABLE t1(a,b,c)}\n  } {0 {}}\n  do_test auth-1.14 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {}\n  do_test auth-1.15 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMP TABLE t1(a,b,c)}\n  } {0 {}}\n  do_test auth-1.16 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {}\n  \n  do_test auth-1.17 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMP TABLE t1(a,b,c)}\n  } {0 {}}\n  do_test auth-1.18 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n}\n\ndo_test auth-1.19.1 {\n  set ::authargs {}\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TEMP_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE TABLE t2(a,b,c)}\n} {0 {}}\ndo_test auth-1.19.2 {\n  set ::authargs\n} {}\ndo_test auth-1.20 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\ndo_test auth-1.21.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {1 {not authorized}}\ndo_test auth-1.21.2 {\n  set ::authargs\n} {t2 {} main {}}\ndo_test auth-1.22 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.23.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {0 {}}\ndo_test auth-1.23.2 {\n  set ::authargs\n} {t2 {} main {}}\ndo_test auth-1.24 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.25 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {1 {not authorized}}\n  do_test auth-1.26 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.27 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {0 {}}\n  do_test auth-1.28 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n}\n\ndo_test auth-1.29 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"t2\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {INSERT INTO t2 VALUES(1,2,3)}\n} {1 {not authorized}}\ndo_test auth-1.30 {\n  execsql {SELECT * FROM t2}\n} {}\ndo_test auth-1.31 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"t2\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {INSERT INTO t2 VALUES(1,2,3)}\n} {0 {}}\ndo_test auth-1.32 {\n  execsql {SELECT * FROM t2}\n} {}\ndo_test auth-1.33 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"t1\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {INSERT INTO t2 VALUES(1,2,3)}\n} {0 {}}\ndo_test auth-1.34 {\n  execsql {SELECT * FROM t2}\n} {1 2 3}\n\ndo_test auth-1.35.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2}\n} {1 {access to t2.b is prohibited}}\nifcapable attach {\n  do_test auth-1.35.2 {\n    execsql {ATTACH DATABASE 'test.db' AS two}\n    catchsql {SELECT * FROM two.t2}\n  } {1 {access to two.t2.b is prohibited}}\n  execsql {DETACH DATABASE two}\n}\n# EVIDENCE-OF: R-38392-49970 If the action code is SQLITE_READ and the\n# callback returns SQLITE_IGNORE then the prepared statement statement\n# is constructed to substitute a NULL value in place of the table column\n# that would have been read if SQLITE_OK had been returned.\ndo_test auth-1.36 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2}\n} {0 {1 {} 3}}\ndo_test auth-1.37 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2 WHERE b=2}\n} {0 {}}\ndo_test auth-1.38 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"a\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2 WHERE b=2}\n} {0 {{} 2 3}}\ndo_test auth-1.39 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2 WHERE b IS NULL}\n} {0 {1 {} 3}}\ndo_test auth-1.40 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT a,c FROM t2 WHERE b IS NULL}\n} {1 {access to t2.b is prohibited}}\n  \ndo_test auth-1.41 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_UPDATE\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {UPDATE t2 SET a=11}\n} {0 {}}\ndo_test auth-1.42 {\n  execsql {SELECT * FROM t2}\n} {11 2 3}\ndo_test auth-1.43 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_UPDATE\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {UPDATE t2 SET b=22, c=33}\n} {1 {not authorized}}\ndo_test auth-1.44 {\n  execsql {SELECT * FROM t2}\n} {11 2 3}\ndo_test auth-1.45 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_UPDATE\" && $arg1==\"t2\" && $arg2==\"b\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {UPDATE t2 SET b=22, c=33}\n} {0 {}}\ndo_test auth-1.46 {\n  execsql {SELECT * FROM t2}\n} {11 2 33}\n\ndo_test auth-1.47 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"t2\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DELETE FROM t2 WHERE a=11}\n} {1 {not authorized}}\ndo_test auth-1.48 {\n  execsql {SELECT * FROM t2}\n} {11 2 33}\ndo_test auth-1.49 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"t2\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DELETE FROM t2 WHERE a=11}\n} {0 {}}\ndo_test auth-1.50 {\n  execsql {SELECT * FROM t2}\n} {}\ndo_test auth-1.50.2 {\n  execsql {INSERT INTO t2 VALUES(11, 2, 33)}\n} {}\n\ndo_test auth-1.51 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_SELECT\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2}\n} {1 {not authorized}}\ndo_test auth-1.52 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_SELECT\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2}\n} {0 {}}\ndo_test auth-1.53 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_SELECT\"} {\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2}\n} {0 {11 2 33}}\n\n# Update for version 3: There used to be a handful of test here that\n# tested the authorisation callback with the COPY command. The following\n# test makes the same database modifications as they used to.\ndo_test auth-1.54 {\n  execsql {INSERT INTO t2 VALUES(7, 8, 9);}\n} {}\ndo_test auth-1.55 {\n  execsql {SELECT * FROM t2}\n} {11 2 33 7 8 9}\n\ndo_test auth-1.63 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n       return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {1 {not authorized}}\ndo_test auth-1.64 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.65 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"t2\"} {\n       return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {1 {not authorized}}\ndo_test auth-1.66 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.67 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n         return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {1 {not authorized}}\n  do_test auth-1.68 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.69 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"t1\"} {\n         return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {1 {not authorized}}\n  do_test auth-1.70 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n}\n\ndo_test auth-1.71 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n       return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {0 {}}\ndo_test auth-1.72 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.73 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"t2\"} {\n       return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TABLE t2}\n} {0 {}}\ndo_test auth-1.74 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.75 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n         return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {0 {}}\n  do_test auth-1.76 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.77 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"t1\"} {\n         return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP TABLE t1}\n  } {0 {}}\n  do_test auth-1.78 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1}\n}\n\n# Test cases auth-1.79 to auth-1.124 test creating and dropping views.\n# Omit these if the library was compiled with views omitted.\nifcapable view {\ndo_test auth-1.79 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_VIEW\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4] \n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}\n} {1 {not authorized}}\ndo_test auth-1.80 {\n  set ::authargs\n} {v1 {} main {}}\ndo_test auth-1.81 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.82 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_VIEW\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4] \n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}\n} {0 {}}\ndo_test auth-1.83 {\n  set ::authargs\n} {v1 {} main {}}\ndo_test auth-1.84 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.85 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_VIEW\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4] \n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}\n  } {1 {not authorized}}\n  do_test auth-1.86 {\n    set ::authargs\n  } {v1 {} temp {}}\n  do_test auth-1.87 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.88 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_VIEW\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4] \n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}\n  } {0 {}}\n  do_test auth-1.89 {\n    set ::authargs\n  } {v1 {} temp {}}\n  do_test auth-1.90 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1}\n}\n\ndo_test auth-1.91 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}\n} {1 {not authorized}}\ndo_test auth-1.92 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.93 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE VIEW v1 AS SELECT a+1,b+1 FROM t2}\n} {0 {}}\ndo_test auth-1.94 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.95 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}\n  } {1 {not authorized}}\n  do_test auth-1.96 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.97 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE TEMPORARY VIEW v1 AS SELECT a+1,b+1 FROM t2}\n  } {0 {}}\n  do_test auth-1.98 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n}\n\ndo_test auth-1.99 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE VIEW v2 AS SELECT a+1,b+1 FROM t2;\n    DROP VIEW v2\n  }\n} {1 {not authorized}}\ndo_test auth-1.100 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 v2}\ndo_test auth-1.101 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_VIEW\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP VIEW v2}\n} {1 {not authorized}}\ndo_test auth-1.102 {\n  set ::authargs\n} {v2 {} main {}}\ndo_test auth-1.103 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 v2}\ndo_test auth-1.104 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP VIEW v2}\n} {0 {}}\ndo_test auth-1.105 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 v2}\ndo_test auth-1.106 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_VIEW\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP VIEW v2}\n} {0 {}}\ndo_test auth-1.107 {\n  set ::authargs\n} {v2 {} main {}}\ndo_test auth-1.108 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 v2}\ndo_test auth-1.109 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_VIEW\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP VIEW v2}\n} {0 {}}\ndo_test auth-1.110 {\n  set ::authargs\n} {v2 {} main {}}\ndo_test auth-1.111 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\n\nifcapable tempdb {\n  do_test auth-1.112 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      CREATE TEMP VIEW v1 AS SELECT a+1,b+1 FROM t1;\n      DROP VIEW v1\n    }\n  } {1 {not authorized}}\n  do_test auth-1.113 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1 v1}\n  do_test auth-1.114 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_VIEW\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP VIEW v1}\n  } {1 {not authorized}}\n  do_test auth-1.115 {\n    set ::authargs\n  } {v1 {} temp {}}\n  do_test auth-1.116 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1 v1}\n  do_test auth-1.117 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP VIEW v1}\n  } {0 {}}\n  do_test auth-1.118 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1 v1}\n  do_test auth-1.119 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_VIEW\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP VIEW v1}\n  } {0 {}}\n  do_test auth-1.120 {\n    set ::authargs\n  } {v1 {} temp {}}\n  do_test auth-1.121 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1 v1}\n  do_test auth-1.122 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_VIEW\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_OK\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP VIEW v1}\n  } {0 {}}\n  do_test auth-1.123 {\n    set ::authargs\n  } {v1 {} temp {}}\n  do_test auth-1.124 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n}\n} ;# ifcapable view\n\n# Test cases auth-1.125 to auth-1.176 test creating and dropping triggers.\n# Omit these if the library was compiled with triggers omitted.\n#\nifcapable trigger&&tempdb {\ndo_test auth-1.125 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r2 DELETE on t2 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {1 {not authorized}}\ndo_test auth-1.126 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.127 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.128 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r2 DELETE on t2 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {1 {not authorized}}\ndo_test auth-1.129 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.130 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r2 DELETE on t2 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {0 {}}\ndo_test auth-1.131 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.132 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.133 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r2 DELETE on t2 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {0 {}}\ndo_test auth-1.134 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.135 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TABLE tx(id);\n    CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN\n       INSERT INTO tx VALUES(NEW.rowid);\n    END;\n  }\n} {0 {}}\ndo_test auth-1.136.1 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.136.2 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type='trigger'\n  }\n} {r2}\ndo_test auth-1.136.3 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    lappend ::authargs $code $arg1 $arg2 $arg3 $arg4\n    return SQLITE_OK\n  }\n  set ::authargs {}\n  execsql {\n    INSERT INTO t2 VALUES(1,2,3);\n  }\n  set ::authargs \n} {SQLITE_INSERT t2 {} main {} SQLITE_INSERT tx {} main r2 SQLITE_READ t2 ROWID main r2}\ndo_test auth-1.136.4 {\n  execsql {\n    SELECT * FROM tx;\n  }\n} {3}\ndo_test auth-1.137 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 tx r2}\ndo_test auth-1.138 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r1 DELETE on t1 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {1 {not authorized}}\ndo_test auth-1.139 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.140 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1}\ndo_test auth-1.141 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r1 DELETE on t1 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {1 {not authorized}}\ndo_test auth-1.142 {\n  execsql {SELECT name FROM sqlite_temp_master}\n} {t1}\ndo_test auth-1.143 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r1 DELETE on t1 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {0 {}}\ndo_test auth-1.144 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.145 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1}\ndo_test auth-1.146 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r1 DELETE on t1 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {0 {}}\ndo_test auth-1.147 {\n  execsql {SELECT name FROM sqlite_temp_master}\n} {t1}\ndo_test auth-1.148 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    CREATE TRIGGER r1 DELETE on t1 BEGIN\n        SELECT NULL;\n    END;\n  }\n} {0 {}}\ndo_test auth-1.149 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.150 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1 r1}\n\ndo_test auth-1.151 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r2}\n} {1 {not authorized}}\ndo_test auth-1.152 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 tx r2}\ndo_test auth-1.153 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r2}\n} {1 {not authorized}}\ndo_test auth-1.154 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.155 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 tx r2}\ndo_test auth-1.156 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r2}\n} {0 {}}\ndo_test auth-1.157 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 tx r2}\ndo_test auth-1.158 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r2}\n} {0 {}}\ndo_test auth-1.159 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.160 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 tx r2}\ndo_test auth-1.161 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r2}\n} {0 {}}\ndo_test auth-1.162 {\n  set ::authargs\n} {r2 t2 main {}}\ndo_test auth-1.163 {\n  execsql {\n    DROP TABLE tx;\n    DELETE FROM t2 WHERE a=1 AND b=2 AND c=3;\n    SELECT name FROM sqlite_master;\n  }\n} {t2}\n\ndo_test auth-1.164 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r1}\n} {1 {not authorized}}\ndo_test auth-1.165 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1 r1}\ndo_test auth-1.166 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r1}\n} {1 {not authorized}}\ndo_test auth-1.167 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.168 {\n  execsql {SELECT name FROM sqlite_temp_master}\n} {t1 r1}\ndo_test auth-1.169 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r1}\n} {0 {}}\ndo_test auth-1.170 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1 r1}\ndo_test auth-1.171 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r1}\n} {0 {}}\ndo_test auth-1.172 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.173 {\n  execsql {SELECT name FROM sqlite_temp_master}\n} {t1 r1}\ndo_test auth-1.174 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_TEMP_TRIGGER\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP TRIGGER r1}\n} {0 {}}\ndo_test auth-1.175 {\n  set ::authargs\n} {r1 t1 temp {}}\ndo_test auth-1.176 {\n  execsql {SELECT name FROM temp.sqlite_master}\n} {t1}\n} ;# ifcapable trigger\n\ndo_test auth-1.177 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE INDEX i2 ON t2(a)}\n} {1 {not authorized}}\ndo_test auth-1.178 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.179 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.180 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE INDEX i2 ON t2(a)}\n} {1 {not authorized}}\ndo_test auth-1.181 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.182 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE INDEX i2 ON t2(b)}\n} {0 {}}\ndo_test auth-1.183 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.184 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.185 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE INDEX i2 ON t2(b)}\n} {0 {}}\ndo_test auth-1.186 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\ndo_test auth-1.187 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_CREATE_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {CREATE INDEX i2 ON t2(a)}\n} {0 {}}\ndo_test auth-1.188 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.189 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 i2}\n\nifcapable tempdb {\n  do_test auth-1.190 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE INDEX i1 ON t1(a)}\n  } {1 {not authorized}}\n  do_test auth-1.191 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.192 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.193 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE INDEX i1 ON t1(b)}\n  } {1 {not authorized}}\n  do_test auth-1.194 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1}\n  do_test auth-1.195 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE INDEX i1 ON t1(b)}\n  } {0 {}}\n  do_test auth-1.196 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.197 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.198 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_INSERT\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE INDEX i1 ON t1(c)}\n  } {0 {}}\n  do_test auth-1.199 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1}\n  do_test auth-1.200 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_CREATE_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_OK\n      }\n      return SQLITE_OK\n    }\n    catchsql {CREATE INDEX i1 ON t1(a)}\n  } {0 {}}\n  do_test auth-1.201 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.202 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1 i1}\n}\n\ndo_test auth-1.203 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP INDEX i2}\n} {1 {not authorized}}\ndo_test auth-1.204 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 i2}\ndo_test auth-1.205 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP INDEX i2}\n} {1 {not authorized}}\ndo_test auth-1.206 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.207 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 i2}\ndo_test auth-1.208 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_master\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP INDEX i2}\n} {0 {}}\ndo_test auth-1.209 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 i2}\ndo_test auth-1.210 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP INDEX i2}\n} {0 {}}\ndo_test auth-1.211 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.212 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2 i2}\ndo_test auth-1.213 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_DROP_INDEX\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {DROP INDEX i2}\n} {0 {}}\ndo_test auth-1.214 {\n  set ::authargs\n} {i2 t2 main {}}\ndo_test auth-1.215 {\n  execsql {SELECT name FROM sqlite_master}\n} {t2}\n\nifcapable tempdb {\n  do_test auth-1.216 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP INDEX i1}\n  } {1 {not authorized}}\n  do_test auth-1.217 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1 i1}\n  do_test auth-1.218 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP INDEX i1}\n  } {1 {not authorized}}\n  do_test auth-1.219 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.220 {\n    execsql {SELECT name FROM sqlite_temp_master}\n  } {t1 i1}\n  do_test auth-1.221 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DELETE\" && $arg1==\"sqlite_temp_master\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP INDEX i1}\n  } {0 {}}\n  do_test auth-1.222 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1 i1}\n  do_test auth-1.223 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP INDEX i1}\n  } {0 {}}\n  do_test auth-1.224 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.225 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1 i1}\n  do_test auth-1.226 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DROP_TEMP_INDEX\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_OK\n      }\n      return SQLITE_OK\n    }\n    catchsql {DROP INDEX i1}\n  } {0 {}}\n  do_test auth-1.227 {\n    set ::authargs\n  } {i1 t1 temp {}}\n  do_test auth-1.228 {\n    execsql {SELECT name FROM temp.sqlite_master}\n  } {t1}\n}\n\ndo_test auth-1.229 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_PRAGMA\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {PRAGMA full_column_names=on}\n} {1 {not authorized}}\ndo_test auth-1.230 {\n  set ::authargs\n} {full_column_names on {} {}}\ndo_test auth-1.231 {\n  execsql2 {SELECT a FROM t2}\n} {a 11 a 7}\ndo_test auth-1.232 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_PRAGMA\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {PRAGMA full_column_names=on}\n} {0 {}}\ndo_test auth-1.233 {\n  set ::authargs\n} {full_column_names on {} {}}\ndo_test auth-1.234 {\n  execsql2 {SELECT a FROM t2}\n} {a 11 a 7}\ndo_test auth-1.235 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_PRAGMA\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {PRAGMA full_column_names=on}\n} {0 {}}\ndo_test auth-1.236 {\n  execsql2 {SELECT a FROM t2}\n} {t2.a 11 t2.a 7}\ndo_test auth-1.237 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_PRAGMA\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {PRAGMA full_column_names=OFF}\n} {0 {}}\ndo_test auth-1.238 {\n  set ::authargs\n} {full_column_names OFF {} {}}\ndo_test auth-1.239 {\n  execsql2 {SELECT a FROM t2}\n} {a 11 a 7}\n\ndo_test auth-1.240 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_TRANSACTION\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {BEGIN}\n} {1 {not authorized}}\ndo_test auth-1.241 {\n  set ::authargs\n} {BEGIN {} {} {}}\ndo_test auth-1.242 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_TRANSACTION\" && $arg1!=\"BEGIN\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {BEGIN; INSERT INTO t2 VALUES(44,55,66); COMMIT}\n} {1 {not authorized}}\ndo_test auth-1.243 {\n  set ::authargs\n} {COMMIT {} {} {}}\ndo_test auth-1.244 {\n  execsql {SELECT * FROM t2}\n} {11 2 33 7 8 9 44 55 66}\ndo_test auth-1.245 {\n  catchsql {ROLLBACK}\n} {1 {not authorized}}\ndo_test auth-1.246 {\n  set ::authargs\n} {ROLLBACK {} {} {}}\ndo_test auth-1.247 {\n  catchsql {END TRANSACTION}\n} {1 {not authorized}}\ndo_test auth-1.248 {\n  set ::authargs\n} {COMMIT {} {} {}}\ndo_test auth-1.249 {\n  # EVIDENCE-OF: R-52112-44167 Disable the authorizer by installing a NULL\n  # callback.\n  db authorizer {}\n  catchsql {ROLLBACK}\n} {0 {}}\ndo_test auth-1.250 {\n  execsql {SELECT * FROM t2}\n} {11 2 33 7 8 9}\n\n# ticket #340 - authorization for ATTACH and DETACH.\n#\nifcapable attach {\n  do_test auth-1.251 {\n    db authorizer ::auth\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ATTACH\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ATTACH DATABASE ':memory:' AS test1\n    }\n  } {0 {}}\n  do_test auth-1.252a {\n    set ::authargs\n  } {:memory: {} {} {}}\n  do_test auth-1.252b {\n    db eval {DETACH test1}\n    set ::attachfilename :memory:\n    db eval {ATTACH $::attachfilename AS test1}\n    set ::authargs\n  } {{} {} {} {}}\n  do_test auth-1.252c {\n    db eval {DETACH test1}\n    db eval {ATTACH ':mem' || 'ory:' AS test1}\n    set ::authargs\n  } {{} {} {} {}}\n  do_test auth-1.253 {\n    catchsql {DETACH DATABASE test1}\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ATTACH\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ATTACH DATABASE ':memory:' AS test1;\n    }\n  } {1 {not authorized}}\n  do_test auth-1.254 {\n    lindex [execsql {PRAGMA database_list}] 7\n  } {}\n  do_test auth-1.255 {\n    catchsql {DETACH DATABASE test1}\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ATTACH\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ATTACH DATABASE ':memory:' AS test1;\n    }\n  } {0 {}}\n  do_test auth-1.256 {\n    lindex [execsql {PRAGMA database_list}] 7\n  } {}\n  do_test auth-1.257 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DETACH\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_OK\n      }\n      return SQLITE_OK\n    }\n    execsql {ATTACH DATABASE ':memory:' AS test1}\n    catchsql {\n      DETACH DATABASE test1;\n    }\n  } {0 {}}\n  do_test auth-1.258 {\n    lindex [execsql {PRAGMA database_list}] 7\n  } {}\n  do_test auth-1.259 {\n    execsql {ATTACH DATABASE ':memory:' AS test1}\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_DETACH\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      DETACH DATABASE test1;\n    }\n  } {0 {}}\n  ifcapable tempdb {\n    ifcapable schema_pragmas {\n    do_test auth-1.260 {\n      lindex [execsql {PRAGMA database_list}] 7\n    } {test1}\n    } ;# ifcapable schema_pragmas\n    do_test auth-1.261 {\n      proc auth {code arg1 arg2 arg3 arg4 args} {\n        if {$code==\"SQLITE_DETACH\"} {\n          set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n          return SQLITE_DENY\n        }\n        return SQLITE_OK\n      }\n      catchsql {\n        DETACH DATABASE test1;\n      }\n    } {1 {not authorized}}\n    ifcapable schema_pragmas {\n    do_test auth-1.262 {\n      lindex [execsql {PRAGMA database_list}] 7\n    } {test1}\n    } ;# ifcapable schema_pragmas\n    db authorizer {}\n    execsql {DETACH DATABASE test1}\n    db authorizer ::auth\n    \n    # Authorization for ALTER TABLE. These tests are omitted if the library\n    # was built without ALTER TABLE support.\n    ifcapable altertable {\n    \n      do_test auth-1.263 {\n        proc auth {code arg1 arg2 arg3 arg4 args} {\n          if {$code==\"SQLITE_ALTER_TABLE\"} {\n            set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n            return SQLITE_OK\n          }\n          return SQLITE_OK\n        }\n        catchsql {\n          ALTER TABLE t1 RENAME TO t1x\n        }\n      } {0 {}}\n      do_test auth-1.264 {\n        execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}\n      } {t1x}\n      do_test auth-1.265 {\n        set authargs\n      } {temp t1 {} {}}\n      do_test auth-1.266 {\n        proc auth {code arg1 arg2 arg3 arg4 args} {\n          if {$code==\"SQLITE_ALTER_TABLE\"} {\n            set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n            return SQLITE_IGNORE\n          }\n          return SQLITE_OK\n        }\n        catchsql {\n          ALTER TABLE t1x RENAME TO t1\n        }\n      } {0 {}}\n      do_test auth-1.267 {\n        execsql {SELECT name FROM temp.sqlite_master WHERE type='table'}\n      } {t1x}\n      do_test auth-1.268 {\n        set authargs\n      } {temp t1x {} {}}\n      do_test auth-1.269 {\n        proc auth {code arg1 arg2 arg3 arg4 args} {\n          if {$code==\"SQLITE_ALTER_TABLE\"} {\n            set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n            return SQLITE_DENY\n          }\n          return SQLITE_OK\n        }\n        catchsql {\n          ALTER TABLE t1x RENAME TO t1\n        }\n      } {1 {not authorized}}\n      do_test auth-1.270 {\n        execsql {SELECT name FROM sqlite_temp_master WHERE type='table'}\n      } {t1x}\n  \n      do_test auth-1.271 {\n        set authargs\n      } {temp t1x {} {}}\n    } ;# ifcapable altertable\n  \n  } else {\n    db authorizer {}\n    db eval {\n      DETACH DATABASE test1;\n    }\n  }\n}\n\nifcapable  altertable {\ndb authorizer {}\ncatchsql {ALTER TABLE t1x RENAME TO t1}\ndb authorizer ::auth\ndo_test auth-1.272 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_ALTER_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_OK\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    ALTER TABLE t2 RENAME TO t2x\n  }\n} {0 {}}\ndo_test auth-1.273 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table'}\n} {t2x}\ndo_test auth-1.274 {\n  set authargs\n} {main t2 {} {}}\ndo_test auth-1.275 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_ALTER_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    ALTER TABLE t2x RENAME TO t2\n  }\n} {0 {}}\ndo_test auth-1.276 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table'}\n} {t2x}\ndo_test auth-1.277 {\n  set authargs\n} {main t2x {} {}}\ndo_test auth-1.278 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_ALTER_TABLE\"} {\n      set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  catchsql {\n    ALTER TABLE t2x RENAME TO t2\n  }\n} {1 {not authorized}}\ndo_test auth-1.279 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table'}\n} {t2x}\ndo_test auth-1.280 {\n  set authargs\n} {main t2x {} {}}\ndb authorizer {}\ncatchsql {ALTER TABLE t2x RENAME TO t2}\n\n} ;# ifcapable altertable\n\n# Test the authorization callbacks for the REINDEX command.\nifcapable reindex {\n\nproc auth {code args} {\n  if {$code==\"SQLITE_REINDEX\"} {\n    set ::authargs [concat $::authargs [lrange $args 0 3]]\n  }\n  return SQLITE_OK\n}\ndb authorizer auth\ndo_test auth-1.281 {\n  execsql {\n    CREATE TABLE t3(a PRIMARY KEY, b, c);\n    CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);\n    CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);\n  }\n} {}\ndo_test auth-1.282 {\n  set ::authargs {}\n  execsql {\n    REINDEX t3_idx1;\n  }\n  set ::authargs\n} {t3_idx1 {} main {}}\ndo_test auth-1.283 {\n  set ::authargs {}\n  execsql {\n    REINDEX BINARY;\n  }\n  set ::authargs\n} {t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}\ndo_test auth-1.284 {\n  set ::authargs {}\n  execsql {\n    REINDEX NOCASE;\n  }\n  set ::authargs\n} {t3_idx2 {} main {}}\ndo_test auth-1.285 {\n  set ::authargs {}\n  execsql {\n    REINDEX t3;\n  }\n  set ::authargs\n} {t3_idx2 {} main {} t3_idx1 {} main {} sqlite_autoindex_t3_1 {} main {}}\ndo_test auth-1.286 {\n  execsql {\n    DROP TABLE t3;\n  }\n} {}\nifcapable tempdb {\n  do_test auth-1.287 {\n    execsql {\n      CREATE TEMP TABLE t3(a PRIMARY KEY, b, c);\n      CREATE INDEX t3_idx1 ON t3(c COLLATE BINARY);\n      CREATE INDEX t3_idx2 ON t3(b COLLATE NOCASE);\n    }\n  } {}\n  do_test auth-1.288 {\n    set ::authargs {}\n    execsql {\n      REINDEX temp.t3_idx1;\n    }\n    set ::authargs\n  } {t3_idx1 {} temp {}}\n  do_test auth-1.289 {\n    set ::authargs {}\n    execsql {\n      REINDEX BINARY;\n    }\n    set ::authargs\n  } {t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}\n  do_test auth-1.290 {\n    set ::authargs {}\n    execsql {\n      REINDEX NOCASE;\n    }\n    set ::authargs\n  } {t3_idx2 {} temp {}}\n  do_test auth-1.291 {\n    set ::authargs {}\n    execsql {\n      REINDEX temp.t3;\n    }\n    set ::authargs\n  } {t3_idx2 {} temp {} t3_idx1 {} temp {} sqlite_autoindex_t3_1 {} temp {}}\n  proc auth {code args} {\n    if {$code==\"SQLITE_REINDEX\"} {\n      set ::authargs [concat $::authargs [lrange $args 0 3]]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  do_test auth-1.292 {\n    set ::authargs {}\n    catchsql {\n      REINDEX temp.t3;\n    }\n  } {1 {not authorized}}\n  do_test auth-1.293 {\n    execsql {\n      DROP TABLE t3;\n    }\n  } {}\n}\n\n} ;# ifcapable reindex \n\nifcapable analyze {\n  proc auth {code args} {\n    if {$code==\"SQLITE_ANALYZE\"} {\n      set ::authargs [concat $::authargs [lrange $args 0 3]]\n    }\n    return SQLITE_OK\n  }\n  do_test auth-1.294 {\n    set ::authargs {}\n    execsql {\n      CREATE TABLE t4(a,b,c);\n      CREATE INDEX t4i1 ON t4(a);\n      CREATE INDEX t4i2 ON t4(b,a,c);\n      INSERT INTO t4 VALUES(1,2,3);\n      ANALYZE;\n    }\n    set ::authargs\n  } {t4 {} main {} t2 {} main {}}\n  do_test auth-1.295 {\n    execsql {\n      SELECT count(*) FROM sqlite_stat1;\n    }\n  } 3\n  proc auth {code args} {\n    if {$code==\"SQLITE_ANALYZE\"} {\n      set ::authargs [concat $::authargs $args]\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  do_test auth-1.296 {\n    set ::authargs {}\n    catchsql {\n      ANALYZE;\n    }\n  } {1 {not authorized}}\n  do_test auth-1.297 {\n    execsql {\n      SELECT count(*) FROM sqlite_stat1;\n    }\n  } 3\n} ;# ifcapable analyze\n\n\n# Authorization for ALTER TABLE ADD COLUMN.\n# These tests are omitted if the library\n# was built without ALTER TABLE support.\nifcapable {altertable} {\n  do_test auth-1.300 {\n    execsql {CREATE TABLE t5(x)}\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ALTER_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_OK\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ALTER TABLE t5 ADD COLUMN new_col_1;\n    }\n  } {0 {}}\n  do_test auth-1.301 {\n    set x [execsql {SELECT sql FROM sqlite_master WHERE name='t5'}]\n    regexp new_col_1 $x\n  } {1}\n  do_test auth-1.302 {\n    set authargs\n  } {main t5 {} {}}\n  do_test auth-1.303 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ALTER_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ALTER TABLE t5 ADD COLUMN new_col_2;\n    }\n  } {0 {}}\n  do_test auth-1.304 {\n    set x [execsql {SELECT sql FROM sqlite_master WHERE name='t5'}]\n    regexp new_col_2 $x\n  } {0}\n  do_test auth-1.305 {\n    set authargs\n  } {main t5 {} {}}\n  do_test auth-1.306 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_ALTER_TABLE\"} {\n        set ::authargs [list $arg1 $arg2 $arg3 $arg4]\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    catchsql {\n      ALTER TABLE t5 ADD COLUMN new_col_3\n    }\n  } {1 {not authorized}}\n  do_test auth-1.307 {\n    set x [execsql {SELECT sql FROM temp.sqlite_master WHERE type='t5'}]\n    regexp new_col_3 $x\n  } {0}\n\n  do_test auth-1.308 {\n    set authargs\n  } {main t5 {} {}}\n  execsql {DROP TABLE t5}\n} ;# ifcapable altertable\n\nifcapable {cte} {\n  do_test auth-1.310 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_RECURSIVE\"} {\n        return SQLITE_DENY\n      }\n      return SQLITE_OK\n    }\n    db eval {\n       DROP TABLE IF EXISTS t1;\n       CREATE TABLE t1(a,b);\n       INSERT INTO t1 VALUES(1,2),(3,4),(5,6);\n    }\n  } {}\n  do_catchsql_test auth-1.311 {\n    WITH\n       auth1311(x,y) AS (SELECT a+b, b-a FROM t1)\n    SELECT * FROM auth1311 ORDER BY x;\n  } {0 {3 1 7 1 11 1}}\n  do_catchsql_test auth-1.312 {\n    WITH RECURSIVE\n       auth1312(x,y) AS (SELECT a+b, b-a FROM t1)\n    SELECT x, y FROM auth1312 ORDER BY x;\n  } {0 {3 1 7 1 11 1}}\n  do_catchsql_test auth-1.313 {\n    WITH RECURSIVE\n       auth1313(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM auth1313 WHERE x<5)\n    SELECT * FROM t1;\n  } {0 {1 2 3 4 5 6}}\n  do_catchsql_test auth-1.314 {\n    WITH RECURSIVE\n       auth1314(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM auth1314 WHERE x<5)\n    SELECT * FROM t1 LEFT JOIN auth1314;\n  } {1 {not authorized}}\n} ;# ifcapable cte\n\ndo_test auth-2.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t3\" && $arg2==\"x\"} {\n      return SQLITE_DENY\n    }\n    return SQLITE_OK\n  }\n  db authorizer ::auth\n  execsql {CREATE TABLE t3(x INTEGER PRIMARY KEY, y, z)}\n  catchsql {SELECT * FROM t3}\n} {1 {access to t3.x is prohibited}}\ndo_test auth-2.1 {\n  catchsql {SELECT y,z FROM t3}\n} {0 {}}\ndo_test auth-2.2 {\n  catchsql {SELECT ROWID,y,z FROM t3}\n} {1 {access to t3.x is prohibited}}\ndo_test auth-2.3 {\n  catchsql {SELECT OID,y,z FROM t3}\n} {1 {access to t3.x is prohibited}}\ndo_test auth-2.4 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t3\" && $arg2==\"x\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  execsql {INSERT INTO t3 VALUES(44,55,66)}\n  catchsql {SELECT * FROM t3}\n} {0 {{} 55 66}}\ndo_test auth-2.5 {\n  catchsql {SELECT rowid,y,z FROM t3}\n} {0 {{} 55 66}}\ndo_test auth-2.6 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t3\" && $arg2==\"ROWID\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t3}\n} {0 {44 55 66}}\ndo_test auth-2.7 {\n  catchsql {SELECT ROWID,y,z FROM t3}\n} {0 {44 55 66}}\ndo_test auth-2.8 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"ROWID\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT ROWID,b,c FROM t2}\n} {0 {{} 2 33 {} 8 9}}\ndo_test auth-2.9.1 {\n  # We have to flush the cache here in case the Tcl interface tries to\n  # reuse a statement compiled with sqlite3_prepare_v2(). In this case,\n  # the first error encountered is an SQLITE_SCHEMA error. Then, when\n  # trying to recompile the statement, the authorization error is encountered.\n  # If we do not flush the cache, the correct error message is returned, but\n  # the error code is SQLITE_SCHEMA, not SQLITE_ERROR as required by the test\n  # case after this one.\n  #\n  db cache flush\n\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"ROWID\"} {\n      return bogus\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT ROWID,b,c FROM t2}\n} {1 {authorizer malfunction}}\ndo_test auth-2.9.2 {\n  db errorcode\n} {1}\ndo_test auth-2.10 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_SELECT\"} {\n      return bogus\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT ROWID,b,c FROM t2}\n} {1 {authorizer malfunction}}\ndo_test auth-2.11.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg2==\"a\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2, t3}\n} {0 {{} 2 33 44 55 66 {} 8 9 44 55 66}}\ndo_test auth-2.11.2 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_READ\" && $arg2==\"x\"} {\n      return SQLITE_IGNORE\n    }\n    return SQLITE_OK\n  }\n  catchsql {SELECT * FROM t2, t3}\n} {0 {11 2 33 {} 55 66 7 8 9 {} 55 66}}\n\n# Make sure the OLD and NEW pseudo-tables of a trigger get authorized.\n#\nifcapable trigger {\n  do_test auth-3.1 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      return SQLITE_OK\n    }\n    execsql {\n      CREATE TABLE tx(a1,a2,b1,b2,c1,c2);\n      CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN\n        INSERT INTO tx VALUES(OLD.a,NEW.a,OLD.b,NEW.b,OLD.c,NEW.c);\n      END;\n      UPDATE t2 SET a=a+1;\n      SELECT * FROM tx;\n    }\n  } {11 12 2 2 33 33 7 8 8 8 9 9}\n  do_test auth-3.2 {\n    proc auth {code arg1 arg2 arg3 arg4 args} {\n      if {$code==\"SQLITE_READ\" && $arg1==\"t2\" && $arg2==\"c\"} {\n        return SQLITE_IGNORE\n      }\n      return SQLITE_OK\n    }\n    execsql {\n      DELETE FROM tx;\n      UPDATE t2 SET a=a+100;\n      SELECT * FROM tx;\n    }\n  } {12 112 2 2 {} {} 8 108 8 8 {} {}}\n} ;# ifcapable trigger\n\n# Make sure the names of views and triggers are passed on on arg4.\n#\nifcapable trigger {\ndo_test auth-4.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    lappend ::authargs $code $arg1 $arg2 $arg3 $arg4\n    return SQLITE_OK\n  }\n  set authargs {}\n  execsql {\n    UPDATE t2 SET a=a+1;\n  }\n  set authargs\n} [list \\\n  SQLITE_READ   t2 a  main {} \\\n  SQLITE_UPDATE t2 a  main {} \\\n  SQLITE_INSERT tx {} main r1 \\\n  SQLITE_READ   t2 a  main r1 \\\n  SQLITE_READ   t2 a  main r1 \\\n  SQLITE_READ   t2 b  main r1 \\\n  SQLITE_READ   t2 b  main r1 \\\n  SQLITE_READ   t2 c  main r1 \\\n  SQLITE_READ   t2 c  main r1]\n}\n\nifcapable {view && trigger} {\ndo_test auth-4.2 {\n  execsql {\n    CREATE VIEW v1 AS SELECT a+b AS x FROM t2;\n    CREATE TABLE v1chng(x1,x2);\n    CREATE TRIGGER r2 INSTEAD OF UPDATE ON v1 BEGIN\n      INSERT INTO v1chng VALUES(OLD.x,NEW.x);\n    END;\n    SELECT * FROM v1;\n  }\n} {115 117}\ndo_test auth-4.3 {\n  set authargs {}\n  execsql {\n    UPDATE v1 SET x=1 WHERE x=117\n  }\n  set authargs\n} [list \\\n  SQLITE_UPDATE v1     x  main {} \\\n  SQLITE_SELECT {}     {} {}   v1 \\\n  SQLITE_READ   t2     a  main v1 \\\n  SQLITE_READ   t2     b  main v1 \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_SELECT {}     {} {} v1   \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_INSERT v1chng {} main r2 \\\n  SQLITE_READ   v1     x  main r2 \\\n  SQLITE_READ   v1     x  main r2 \\\n]\n\ndo_test auth-4.4 {\n  execsql {\n    CREATE TRIGGER r3 INSTEAD OF DELETE ON v1 BEGIN\n      INSERT INTO v1chng VALUES(OLD.x,NULL);\n    END;\n    SELECT * FROM v1;\n  }\n} {115 117}\ndo_test auth-4.5 {\n  set authargs {}\n  execsql {\n    DELETE FROM v1 WHERE x=117\n  }\n  set authargs\n} [list \\\n  SQLITE_DELETE v1     {} main {} \\\n  SQLITE_SELECT {}     {} {}   v1 \\\n  SQLITE_READ   t2     a  main v1 \\\n  SQLITE_READ   t2     b  main v1 \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_SELECT {}     {} {} v1   \\\n  SQLITE_READ   v1     x  main v1 \\\n  SQLITE_INSERT v1chng {} main r3 \\\n  SQLITE_READ   v1     x  main r3 \\\n]\n\n} ;# ifcapable view && trigger\n\n# Ticket #1338:  Make sure authentication works in the presence of an AS\n# clause.\n#\ndo_test auth-5.1 {\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    return SQLITE_OK\n  }\n  execsql {\n    SELECT count(a) AS cnt FROM t4 ORDER BY cnt\n  }\n} {1}\n\n# Ticket #1607\n#\nifcapable compound&&subquery {\n  ifcapable trigger {\n    execsql {\n      DROP TABLE tx;\n    }\n    ifcapable view {\n      execsql {\n        DROP TABLE v1chng;\n      }\n    }\n  }\n  ifcapable stat4 {\n    set stat4 \"sqlite_stat4 \"\n  } else {\n    ifcapable stat3 {\n      set stat4 \"sqlite_stat3 \"\n    } else {\n      set stat4 \"\"\n    }\n  }\n  do_test auth-5.2 {\n    execsql {\n      SELECT name FROM (\n        SELECT * FROM sqlite_master UNION ALL SELECT * FROM temp.sqlite_master)\n      WHERE type='table'\n      ORDER BY name\n    }\n  } \"sqlite_stat1 ${stat4}t1 t2 t3 t4\"\n}\n\n# Ticket #3944\n#\nifcapable trigger {\n  do_test auth-5.3.1 {\n    execsql {\n      CREATE TABLE t5 ( x );\n      CREATE TRIGGER t5_tr1 AFTER INSERT ON t5 BEGIN \n        UPDATE t5 SET x = 1 WHERE NEW.x = 0;\n      END;\n    }\n  } {}\n  set ::authargs [list]\n  proc auth {args} {\n    eval lappend ::authargs [lrange $args 0 4]\n    return SQLITE_OK\n  }\n  do_test auth-5.3.2 {\n    execsql { INSERT INTO t5 (x) values(0) }\n    set ::authargs\n  } [list SQLITE_INSERT t5 {} main {}    \\\n          SQLITE_UPDATE t5 x main t5_tr1 \\\n          SQLITE_READ t5 x main t5_tr1   \\\n    ]\n  do_test auth-5.3.2 {\n    execsql { SELECT * FROM t5 }\n  } {1}\n}\n\n# Ticket [0eb70d77cb05bb22720]:  Invalid pointer passsed to the authorizer\n# callback when updating a ROWID.\n#\ndo_test auth-6.1 {\n  execsql {\n    CREATE TABLE t6(a,b,c,d,e,f,g,h);\n    INSERT INTO t6 VALUES(1,2,3,4,5,6,7,8);\n  }\n} {}\nset ::authargs [list]\nproc auth {args} {\n  eval lappend ::authargs [lrange $args 0 4]\n  return SQLITE_OK\n}\ndo_test auth-6.2 {\n  execsql {UPDATE t6 SET rowID=rowID+100}\n  set ::authargs\n} [list SQLITE_READ   t6 ROWID main {} \\\n        SQLITE_UPDATE t6 ROWID main {} \\\n]\ndo_test auth-6.3 {\n  execsql {SELECT rowid, * FROM t6}\n} {101 1 2 3 4 5 6 7 8}\n\n#-------------------------------------------------------------------------\n# Test that view names are included as zArg4.\n#\ndo_execsql_test auth-7.1 {\n  CREATE TABLE t7(a, b, c);\n  CREATE VIEW v7 AS SELECT * FROM t7;\n} {}\nset ::authargs [list]\nproc auth {args} {\n  eval lappend ::authargs [lrange $args 0 4]\n  return SQLITE_OK\n}\n\ndo_test auth-7.2 {\n  execsql {SELECT a, c FROM v7}\n  set ::authargs\n} [list                          \\\n  SQLITE_SELECT {} {} {} {}      \\\n  SQLITE_READ t7 a main v7       \\\n  SQLITE_READ t7 b main v7       \\\n  SQLITE_READ t7 c main v7       \\\n  SQLITE_READ v7 a main {}       \\\n  SQLITE_READ v7 c main {}       \\\n  SQLITE_SELECT {} {} {} v7      \\\n]\n\nset ::authargs [list]\ndo_test auth-7.3 {\n  execsql {SELECT a, c FROM t7}\n  set ::authargs\n} [list                          \\\n  SQLITE_SELECT {} {} {} {}      \\\n  SQLITE_READ t7 a main {}       \\\n  SQLITE_READ t7 c main {}       \\\n]\n\nset ::authargs [list]\ndo_test auth-7.4 {\n  execsql {SELECT a, c FROM t7 AS v7}\n  set ::authargs\n} [list                          \\\n  SQLITE_SELECT {} {} {} {}      \\\n  SQLITE_READ t7 a main {}       \\\n  SQLITE_READ t7 c main {}       \\\n]\n\n# If a table is referenced but no columns are read from the table,\n# that causes a single SQLITE_READ authorization with a NULL column\n# name.\n#\n# EVIDENCE-OF: R-31520-16302 When a table is referenced by a SELECT but\n# no column values are extracted from that table (for example in a query\n# like \"SELECT count(*) FROM tab\") then the SQLITE_READ authorizer\n# callback is invoked once for that table with a column name that is an\n# empty string.\n#\nset ::authargs [list]\ndo_test auth-8.1 {\n  execsql {SELECT count(*) FROM t7}\n  set ::authargs\n} [list \\\n  SQLITE_SELECT {} {} {} {}          \\\n  SQLITE_FUNCTION {} count {} {}     \\\n  SQLITE_READ t7 {} {} {}            \\\n  ]\nset ::authargs [list]\n\ndo_test auth-8.2 {\n  execsql {SELECT t6.a FROM t6, t7}\n  set ::authargs\n} [list \\\n  SQLITE_SELECT {} {} {} {}          \\\n  SQLITE_READ t6 a main {}           \\\n  SQLITE_READ t7 {} {} {}            \\\n  ]\n\n# Test also that if SQLITE_DENY is returned from an SQLITE_READ authorizer \n# invocation with no column name specified, compilation fails.\n#\nset ::authargs [list]\nproc auth {op a b c d} {\n  lappend ::authargs $op $a $b $c $d\n  if {$op == \"SQLITE_READ\"} { return \"SQLITE_DENY\" }\n  return \"SQLITE_OK\"\n}\nset ::authargs [list]\ndo_catchsql_test auth-8.3 {\n  SELECT count(*) FROM t7\n} {1 {not authorized}}\ndo_test auth-8.4 {\n  set ::authargs\n} [list \\\n  SQLITE_SELECT {} {} {} {}          \\\n  SQLITE_FUNCTION {} count {} {}     \\\n  SQLITE_READ t7 {} {} {}            \\\n]\n\n\nrename proc {}\nrename proc_real proc\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/auth2.test",
    "content": "# 2006 Aug 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the sqlite3_set_authorizer() API\n# and related functionality.\n#\n# $Id: auth2.test,v 1.3 2008/07/02 13:13:53 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is\n# defined during compilation.\nif {[catch {db auth {}} msg]} {\n  finish_test\n  return\n}\n\ndo_test auth2-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n  }\n  set ::flist {}\n  proc auth {code arg1 arg2 arg3 arg4 args} {\n    if {$code==\"SQLITE_FUNCTION\"} {\n      lappend ::flist $arg2\n      if {$arg2==\"max\"} {\n        return SQLITE_DENY\n      } elseif {$arg2==\"min\"} {\n        return SQLITE_IGNORE\n      } else {\n        return SQLITE_OK\n      }\n    }\n    return SQLITE_OK\n  }\n  db authorizer ::auth\n  catchsql {SELECT max(a,b,c) FROM t1}\n} {1 {not authorized to use function: max}}\ndo_test auth2-1.2 {\n  set ::flist\n} max\ndo_test auth2-1.3 {\n  set ::flist {}\n  catchsql {SELECT min(a,b,c) FROM t1}\n} {0 {{}}}\ndo_test auth2-1.4 {\n  set ::flist\n} min\ndo_test auth2-1.5 {\n  set ::flist {}\n  catchsql {SELECT coalesce(min(a,b,c),999) FROM t1}\n} {0 999}\ndo_test auth2-1.6 {\n  set ::flist\n} {coalesce min}\ndo_test auth2-1.7 {\n  set ::flist {}\n  catchsql {SELECT coalesce(a,b,c) FROM t1}\n} {0 1}\ndo_test auth2-1.8 {\n  set ::flist\n} coalesce\n\n# Make sure the authorizer is not called when parsing the schema\n# and when computing the result set of a view.\n#\ndb close\nsqlite3 db test.db\nsqlite3 db2 test.db\nproc auth {args} {\n  global authargs\n  append authargs [lrange $args 0 4]\\n\n  return SQLITE_OK\n}\ndb auth auth\ndo_test auth2-2.1 {\n  set ::authargs {}\n  db eval {\n    CREATE TABLE t2(x,y,z);\n  }\n  set ::authargs\n} {SQLITE_INSERT sqlite_master {} main {}\nSQLITE_CREATE_TABLE t2 {} main {}\nSQLITE_UPDATE sqlite_master type main {}\nSQLITE_UPDATE sqlite_master name main {}\nSQLITE_UPDATE sqlite_master tbl_name main {}\nSQLITE_UPDATE sqlite_master rootpage main {}\nSQLITE_UPDATE sqlite_master sql main {}\nSQLITE_READ sqlite_master ROWID main {}\n}\ndo_test auth2-2.2 {\n  set ::authargs {}\n  db eval {\n    CREATE VIEW v2 AS SELECT x+y AS a, y+z AS b from t2;\n  }\n  set ::authargs\n} {SQLITE_INSERT sqlite_master {} main {}\nSQLITE_CREATE_VIEW v2 {} main {}\nSQLITE_UPDATE sqlite_master type main {}\nSQLITE_UPDATE sqlite_master name main {}\nSQLITE_UPDATE sqlite_master tbl_name main {}\nSQLITE_UPDATE sqlite_master rootpage main {}\nSQLITE_UPDATE sqlite_master sql main {}\nSQLITE_READ sqlite_master ROWID main {}\n}\ndo_test auth2-2.3 {\n  set ::authargs {}\n  db eval {\n    SELECT a, b FROM v2;\n  }\n  set ::authargs\n} {SQLITE_SELECT {} {} {} {}\nSQLITE_READ t2 x main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 z main v2\nSQLITE_READ v2 a main {}\nSQLITE_READ v2 b main {}\nSQLITE_SELECT {} {} {} v2\n}\ndo_test auth2-2.4 {\n  db2 eval {\n    CREATE TABLE t3(p,q,r);\n  }\n  set ::authargs {}\n  db eval {\n    SELECT b, a FROM v2;\n  }\n  set ::authargs\n} {SQLITE_SELECT {} {} {} {}\nSQLITE_READ t2 x main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 z main v2\nSQLITE_READ v2 b main {}\nSQLITE_READ v2 a main {}\nSQLITE_SELECT {} {} {} v2\nSQLITE_SELECT {} {} {} {}\nSQLITE_READ t2 x main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 y main v2\nSQLITE_READ t2 z main v2\nSQLITE_READ v2 b main {}\nSQLITE_READ v2 a main {}\nSQLITE_SELECT {} {} {} v2\n}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/auth3.test",
    "content": "# 2008 October 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that the truncate optimization is disabled if the SQLITE_DELETE\n# authorization callback returns SQLITE_IGNORE.\n#\n# Test that authorizer is disabled during schema parsing.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is\n# defined during compilation.\nif {[catch {db auth {}} msg]} {\n  finish_test\n  return\n}\n\n# Disable the statement cache for these tests.\n# \ndb cache size 0\n\ndb authorizer ::auth\nproc auth {code arg1 arg2 arg3 arg4 args} {\n  if {$code==\"SQLITE_DELETE\"} {\n    return $::authcode\n  }\n  return SQLITE_OK\n}\n\n#--------------------------------------------------------------------------\n# The following tests - auth3-1.* - test that return values of SQLITE_DENY,\n# SQLITE_IGNORE, SQLITE_OK and <invalid> are correctly handled when returned\n# by an SQLITE_DELETE authorization callback triggered by a \n# \"DELETE FROM <table-name>\" statement.\n#\ndo_test auth3-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n} {}\ndo_test auth3.1.2 {\n  set ::authcode SQLITE_DENY\n  catchsql { DELETE FROM t1 }\n} {1 {not authorized}}\n# EVIDENCE-OF: R-64962-58611 If the authorizer callback returns any\n# value other than SQLITE_IGNORE, SQLITE_OK, or SQLITE_DENY then the\n# sqlite3_prepare_v2() or equivalent call that triggered the authorizer\n# will fail with an error message.\ndo_test auth3.1.3 {\n  set ::authcode SQLITE_INVALID\n  catchsql { DELETE FROM t1 }\n} {1 {authorizer malfunction}}\ndo_test auth3.1.4 {\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6}\ndo_test auth3-1.5 {\n  set ::authcode SQLITE_IGNORE\n  execsql { \n    DELETE FROM t1;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test auth3-1.6 {\n  set ::authcode SQLITE_OK\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    DELETE FROM t1;\n    SELECT * FROM t1;\n  }\n} {}\n\n#--------------------------------------------------------------------------\n# These tests - auth3-2.* - test that returning SQLITE_IGNORE really does\n# disable the truncate optimization.\n#\ndo_test auth3-2.1 {\n  set ::authcode SQLITE_OK\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n  set sqlite_search_count 0\n  execsql {\n    DELETE FROM t1;\n  }\n  set sqlite_search_count\n} {0}\n\ndo_test auth3-2.2 {\n  set ::authcode SQLITE_IGNORE\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n  set sqlite_search_count 0\n  execsql {\n    DELETE FROM t1;\n  }\n  set sqlite_search_count\n} {1}\n\n# 2016-07-28.  A problem report from a private client complaining about\n# an authorizer failure during an ALTER TABLE.  The solution (I think) is\n# to disable the authorizer during schema parsing.\n#\nproc auth {code args} {\n  if {$code==\"SQLITE_READ\" && [regexp {DoNotRead} $args]} {\n    return SQLITE_DENY\n  }\n  return SQLITE_OK\n}\ndo_execsql_test auth3-3.0 {\n  CREATE TEMPORARY TABLE TempTable (\n      key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,\n      value TEXT NOT NULL ON CONFLICT FAIL);\n  ALTER TABLE TempTable RENAME TO DoNotRead;\n  SELECT name FROM temp.sqlite_master;\n} {DoNotRead sqlite_autoindex_DoNotRead_1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoanalyze1.test",
    "content": "# 2017-02-17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for the logic used to estimate when\n# running ANALYZE would be beneficial.\n#\n# Note that this test uses some hard-coded bitmask values from sqliteInt.h.\n# If any of the following constants changes:\n#\n#    define TF_HasStat1   0x0010\n#    define TF_StatsUsed  0x0100\n#\n# then some of the magic numbers in test results below might need to be\n# adjusted.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# There is nothing to test if ANALYZE is disable for this build.\n# These tests also use \"PRAGMA stats\" which are only enabled for\n# debugging builds.\n#\nifcapable {!debug || !analyze || !vtab} {\n  finish_test\n  return\n}\n\ndo_execsql_test autoanalyze1-100 {\n  -- Build up a test table with some indexes\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n  CREATE UNIQUE INDEX t1bc ON t1(b,c);\n  CREATE INDEX t1d ON t1(d);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n    INSERT INTO t1(a,b,c,d) SELECT x, x, x, x FROM c;\n  -- Verify that the hasStat1 flag is clear on on indexes\n  SELECT idx, flgs FROM pragma_stats\n   WHERE idx IS NOT NULL\n   ORDER BY idx;\n  -- Verify that the TF_HasStat1 flag is clear on the table\n  SELECT tbl, (flgs & 0x10)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {t1bc 0 t1d 0 t1 0}\n\n# No use of stat1 recorded so far\ndo_execsql_test autoanalyze1-110 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}\n\n# Access using a unique index does not set the TF_StatsUsed flag.\n#\ndo_execsql_test autoanalyze1-200 {\n  SELECT * FROM t1 WHERE a=55;\n} {55 55 55 55}\ndo_execsql_test autoanalyze1-201 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}\n\ndo_execsql_test autoanalyze1-210 {\n  SELECT * FROM t1 WHERE a IN (55,199,299);\n} {55 55 55 55}\ndo_execsql_test autoanalyze1-211 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}\n\ndo_execsql_test autoanalyze1-220 {\n  SELECT * FROM t1 WHERE (b,c)=(45,45);\n} {45 45 45 45}\ndo_execsql_test autoanalyze1-221 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}\n\n# Any use of the non-unique t1d index triggers the use of stats.\n#\nsqlite3 db test.db\ndo_execsql_test autoanalyze1-300 {\n  SELECT * FROM t1 WHERE d=45;\n} {45 45 45 45}\ndo_execsql_test autoanalyze1-301 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {1}\n\nsqlite3 db test.db\ndo_execsql_test autoanalyze1-310 {\n  SELECT * FROM t1 WHERE d=45 AND a=45;\n} {45 45 45 45}\ndo_execsql_test autoanalyze1-311 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}  ;# The ROWID lookup short-circuits the d=45 constraint\n\nsqlite3 db test.db\ndo_execsql_test autoanalyze1-320 {\n  SELECT * FROM t1 WHERE d=45 AND a IN (45,46);\n} {45 45 45 45}\ndo_execsql_test autoanalyze1-321 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {1}\n\n# Any use of prefix of a unique index triggers the use of stats\n#\nsqlite3 db test.db\ndo_execsql_test autoanalyze1-400 {\n  SELECT * FROM t1 WHERE b=45;\n} {45 45 45 45}\ndo_execsql_test autoanalyze1-401 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {1}\n\n# The TF_StatsUsed flag is reset when the database is reopened\n#\nsqlite3 db test.db\ndo_execsql_test autoanalyze1-500 {\n  SELECT (flgs & 0x0100)!=0 FROM pragma_stats WHERE tbl='t1' AND idx IS NULL;\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoinc.test",
    "content": "# 2004 November 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the AUTOINCREMENT features.\n#\n# $Id: autoinc.test,v 1.14 2009/06/23 20:28:54 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the library is not compiled with autoincrement support then\n# skip all tests in this file.\n#\nifcapable {!autoinc} {\n  finish_test\n  return\n}\n\nsqlite3_db_config_lookaside db 0 0 0\n\n# The database is initially empty.\n#\ndo_test autoinc-1.1 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type='table';\n  }\n} {}\n\n# Add a table with the AUTOINCREMENT feature.  Verify that the\n# SQLITE_SEQUENCE table gets created.\n#\ndo_test autoinc-1.2 {\n  execsql {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);\n    SELECT name FROM sqlite_master WHERE type='table';\n  }\n} {t1 sqlite_sequence}\n\n# The SQLITE_SEQUENCE table is initially empty\n#\ndo_test autoinc-1.3 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {}\ndo_test autoinc-1.3.1 {\n  catchsql {\n    CREATE INDEX seqidx ON sqlite_sequence(name)\n  }\n} {1 {table sqlite_sequence may not be indexed}}\n\n# Close and reopen the database.  Verify that everything is still there.\n#\ndo_test autoinc-1.4 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {}\n\n# We are not allowed to drop the sqlite_sequence table.\n#\ndo_test autoinc-1.5 {\n  catchsql {DROP TABLE sqlite_sequence}\n} {1 {table sqlite_sequence may not be dropped}}\ndo_test autoinc-1.6 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table'}\n} {t1 sqlite_sequence}\n\n# Insert an entries into the t1 table and make sure the largest key\n# is always recorded in the sqlite_sequence table.\n#\ndo_test autoinc-2.1 {\n  execsql {\n    SELECT * FROM sqlite_sequence\n  }\n} {}\ndo_test autoinc-2.2 {\n  execsql {\n    INSERT INTO t1 VALUES(12,34);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 12}\ndo_test autoinc-2.3 {\n  execsql {\n    INSERT INTO t1 VALUES(1,23);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 12}\ndo_test autoinc-2.4 {\n  execsql {\n    INSERT INTO t1 VALUES(123,456);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 123}\ndo_test autoinc-2.5 {\n  execsql {\n    INSERT INTO t1 VALUES(NULL,567);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 124}\ndo_test autoinc-2.6 {\n  execsql {\n    DELETE FROM t1 WHERE y=567;\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 124}\ndo_test autoinc-2.7 {\n  execsql {\n    INSERT INTO t1 VALUES(NULL,567);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 125}\ndo_test autoinc-2.8 {\n  execsql {\n    DELETE FROM t1;\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 125}\ndo_test autoinc-2.9 {\n  execsql {\n    INSERT INTO t1 VALUES(12,34);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 125}\ndo_test autoinc-2.10 {\n  execsql {\n    INSERT INTO t1 VALUES(125,456);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 125}\ndo_test autoinc-2.11 {\n  execsql {\n    INSERT INTO t1 VALUES(-1234567,-1);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 125}\ndo_test autoinc-2.12 {\n  execsql {\n    INSERT INTO t1 VALUES(234,5678);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 234}\ndo_test autoinc-2.13 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(NULL,1);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 235}\ndo_test autoinc-2.14 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {235 1}\n\n# Manually change the autoincrement values in sqlite_sequence.\n#\ndo_test autoinc-2.20 {\n  execsql {\n    UPDATE sqlite_sequence SET seq=1234 WHERE name='t1';\n    INSERT INTO t1 VALUES(NULL,2);\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2}\ndo_test autoinc-2.21 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 1235}\ndo_test autoinc-2.22 {\n  execsql {\n    UPDATE sqlite_sequence SET seq=NULL WHERE name='t1';\n    INSERT INTO t1 VALUES(NULL,3);\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2 1236 3}\ndo_test autoinc-2.23 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 1236}\ndo_test autoinc-2.24 {\n  execsql {\n    UPDATE sqlite_sequence SET seq='a-string' WHERE name='t1';\n    INSERT INTO t1 VALUES(NULL,4);\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2 1236 3 1237 4}\ndo_test autoinc-2.25 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 1237}\ndo_test autoinc-2.26 {\n  execsql {\n    DELETE FROM sqlite_sequence WHERE name='t1';\n    INSERT INTO t1 VALUES(NULL,5);\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2 1236 3 1237 4 1238 5}\ndo_test autoinc-2.27 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 1238}\ndo_test autoinc-2.28 {\n  execsql {\n    UPDATE sqlite_sequence SET seq='-12345678901234567890'\n      WHERE name='t1';\n    INSERT INTO t1 VALUES(NULL,6);\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2 1236 3 1237 4 1238 5 1239 6}\ndo_test autoinc-2.29 {\n  execsql {\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 1239}\n\n# Test multi-row inserts\n#\ndo_test autoinc-2.50 {\n  execsql {\n    DELETE FROM t1 WHERE y>=3;\n    INSERT INTO t1 SELECT NULL, y+2 FROM t1;\n    SELECT * FROM t1;\n  }\n} {235 1 1235 2 1240 3 1241 4}\ndo_test autoinc-2.51 {\n  execsql {\n    SELECT * FROM sqlite_sequence\n  }\n} {t1 1241}\n\nifcapable tempdb {\n  do_test autoinc-2.52 {\n    execsql {\n      CREATE TEMP TABLE t2 AS SELECT y FROM t1;\n    }\n    execsql {\n      INSERT INTO t1 SELECT NULL, y+4 FROM t2;\n      SELECT * FROM t1;\n    }\n  } {235 1 1235 2 1240 3 1241 4 1242 5 1243 6 1244 7 1245 8}\n  do_test autoinc-2.53 {\n    execsql {\n      SELECT * FROM sqlite_sequence\n    }\n  } {t1 1245}\n  do_test autoinc-2.54 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 SELECT NULL, y FROM t2;\n      SELECT * FROM t1;\n    }\n  } {1246 1 1247 2 1248 3 1249 4}\n  do_test autoinc-2.55 {\n    execsql {\n      SELECT * FROM sqlite_sequence\n    }\n  } {t1 1249}\n}\n\n# Create multiple AUTOINCREMENT tables.  Make sure all sequences are\n# tracked separately and do not interfere with one another.\n#\ndo_test autoinc-2.70 {\n  catchsql {\n    DROP TABLE t2;\n  }\n  execsql {\n    CREATE TABLE t2(d, e INTEGER PRIMARY KEY AUTOINCREMENT, f);\n    INSERT INTO t2(d) VALUES(1);\n    SELECT * FROM sqlite_sequence;\n  }\n} [ifcapable tempdb {list t1 1249 t2 1} else {list t1 1241 t2 1}]\ndo_test autoinc-2.71 {\n  execsql {\n    INSERT INTO t2(d) VALUES(2);\n    SELECT * FROM sqlite_sequence;\n  }\n} [ifcapable tempdb {list t1 1249 t2 2} else {list t1 1241 t2 2}]\ndo_test autoinc-2.72 {\n  execsql {\n    INSERT INTO t1(x) VALUES(10000);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 10000 t2 2}\ndo_test autoinc-2.73 {\n  execsql {\n    CREATE TABLE t3(g INTEGER PRIMARY KEY AUTOINCREMENT, h);\n    INSERT INTO t3(h) VALUES(1);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 10000 t2 2 t3 1}\ndo_test autoinc-2.74 {\n  execsql {\n    INSERT INTO t2(d,e) VALUES(3,100);\n    SELECT * FROM sqlite_sequence;\n  }\n} {t1 10000 t2 100 t3 1}\n\n\n# When a table with an AUTOINCREMENT is deleted, the corresponding entry\n# in the SQLITE_SEQUENCE table should also be deleted.  But the SQLITE_SEQUENCE\n# table itself should remain behind.\n#\ndo_test autoinc-3.1 {\n  execsql {SELECT name FROM sqlite_sequence}\n} {t1 t2 t3}\ndo_test autoinc-3.2 {\n  execsql {\n    DROP TABLE t1;\n    SELECT name FROM sqlite_sequence;\n  }\n} {t2 t3}\ndo_test autoinc-3.3 {\n  execsql {\n    DROP TABLE t3;\n    SELECT name FROM sqlite_sequence;\n  }\n} {t2}\ndo_test autoinc-3.4 {\n  execsql {\n    DROP TABLE t2;\n    SELECT name FROM sqlite_sequence;\n  }\n} {}\n\n# AUTOINCREMENT on TEMP tables.\n#\nifcapable tempdb {\n  do_test autoinc-4.1 {\n    execsql {\n      SELECT 1, name FROM sqlite_master WHERE type='table';\n      SELECT 2, name FROM temp.sqlite_master WHERE type='table';\n    }\n  } {1 sqlite_sequence}\n  do_test autoinc-4.2 {\n    execsql {\n      CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);\n      CREATE TEMP TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n      SELECT 1, name FROM sqlite_master WHERE type='table';\n      SELECT 2, name FROM sqlite_temp_master WHERE type='table';\n    }\n  } {1 sqlite_sequence 1 t1 2 t3 2 sqlite_sequence}\n  do_test autoinc-4.3 {\n    execsql {\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {}\n  do_test autoinc-4.4 {\n    execsql {\n      INSERT INTO t1 VALUES(10,1);\n      INSERT INTO t3 VALUES(20,2);\n      INSERT INTO t1 VALUES(NULL,3);\n      INSERT INTO t3 VALUES(NULL,4);\n    }\n  } {}\n  \n  ifcapable compound {\n  do_test autoinc-4.4.1 {\n    execsql {\n      SELECT * FROM t1 UNION ALL SELECT * FROM t3;\n    }\n  } {10 1 11 3 20 2 21 4}\n  } ;# ifcapable compound\n  \n  do_test autoinc-4.5 {\n    execsql {\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {1 t1 11 2 t3 21}\n  do_test autoinc-4.6 {\n    execsql {\n      INSERT INTO t1 SELECT * FROM t3;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {1 t1 21 2 t3 21}\n  do_test autoinc-4.7 {\n    execsql {\n      INSERT INTO t3 SELECT x+100, y  FROM t1;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {1 t1 21 2 t3 121}\n  do_test autoinc-4.8 {\n    execsql {\n      DROP TABLE t3;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {1 t1 21}\n  do_test autoinc-4.9 {\n    execsql {\n      CREATE TEMP TABLE t2(p INTEGER PRIMARY KEY AUTOINCREMENT, q);\n      INSERT INTO t2 SELECT * FROM t1;\n      DROP TABLE t1;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {2 t2 21}\n  do_test autoinc-4.10 {\n    execsql {\n      DROP TABLE t2;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n    }\n  } {}\n}\n\n# Make sure AUTOINCREMENT works on ATTACH-ed tables.\n#\nifcapable tempdb&&attach {\n  do_test autoinc-5.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    sqlite3 db2 test2.db\n    execsql {\n      CREATE TABLE t4(m INTEGER PRIMARY KEY AUTOINCREMENT, n);\n      CREATE TABLE t5(o, p INTEGER PRIMARY KEY AUTOINCREMENT);\n    } db2;\n    execsql {\n      ATTACH 'test2.db' as aux;\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n      SELECT 3, * FROM aux.sqlite_sequence;\n    }\n  } {}\n  do_test autoinc-5.2 {\n    execsql {\n      INSERT INTO t4 VALUES(NULL,1);\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n      SELECT 3, * FROM aux.sqlite_sequence;\n    }\n  } {3 t4 1}\n  do_test autoinc-5.3 {\n    execsql {\n      INSERT INTO t5 VALUES(100,200);\n      SELECT * FROM sqlite_sequence\n    } db2\n  } {t4 1 t5 200}\n  do_test autoinc-5.4 {\n    execsql {\n      SELECT 1, * FROM main.sqlite_sequence;\n      SELECT 2, * FROM temp.sqlite_sequence;\n      SELECT 3, * FROM aux.sqlite_sequence;\n    }\n  } {3 t4 1 3 t5 200}\n}\n\n# Requirement REQ00310:  Make sure an insert fails if the sequence is\n# already at its maximum value.\n#\nifcapable {rowid32} {\n  do_test autoinc-6.1 {\n    execsql {\n      CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w);\n      INSERT INTO t6 VALUES(2147483647,1);\n      SELECT seq FROM main.sqlite_sequence WHERE name='t6';\n    }\n  } 2147483647\n}\nifcapable {!rowid32} {\n  do_test autoinc-6.1 {\n    execsql {\n      CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w);\n      INSERT INTO t6 VALUES(9223372036854775807,1);\n      SELECT seq FROM main.sqlite_sequence WHERE name='t6';\n    }\n  } 9223372036854775807\n}\ndo_test autoinc-6.2 {\n  catchsql {\n    INSERT INTO t6 VALUES(NULL,1);\n  }\n} {1 {database or disk is full}}\n\n# Allow the AUTOINCREMENT keyword inside the parentheses\n# on a separate PRIMARY KEY designation.\n#\ndo_test autoinc-7.1 {\n  execsql {\n    CREATE TABLE t7(x INTEGER, y REAL, PRIMARY KEY(x AUTOINCREMENT));\n    INSERT INTO t7(y) VALUES(123);\n    INSERT INTO t7(y) VALUES(234);\n    DELETE FROM t7;\n    INSERT INTO t7(y) VALUES(345);\n    SELECT * FROM t7;\n  }\n} {3 345.0}\n\n# Test that if the AUTOINCREMENT is applied to a non integer primary key\n# the error message is sensible.\ndo_test autoinc-7.2 {\n  catchsql {\n    CREATE TABLE t8(x TEXT PRIMARY KEY AUTOINCREMENT);\n  }\n} {1 {AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY}}\n\n\n# Ticket #1283.  Make sure that preparing but never running a statement\n# that creates the sqlite_sequence table does not mess up the database.\n#\ndo_test autoinc-8.1 {\n  catch {db2 close}\n  catch {db close}\n  forcedelete test.db\n  sqlite3 db test.db\n  set DB [sqlite3_connection_pointer db]\n  set STMT [sqlite3_prepare $DB {\n     CREATE TABLE t1(\n       x INTEGER PRIMARY KEY AUTOINCREMENT\n     )\n  } -1 TAIL]\n  sqlite3_finalize $STMT\n  set STMT [sqlite3_prepare $DB {\n     CREATE TABLE t1(\n       x INTEGER PRIMARY KEY AUTOINCREMENT\n     )\n  } -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {\n    INSERT INTO t1 VALUES(NULL);\n    SELECT * FROM t1;\n  }\n} {1}\n\n# Ticket #3148\n# Make sure the sqlite_sequence table is not damaged when doing\n# an empty insert - an INSERT INTO ... SELECT ... where the SELECT\n# clause returns an empty set.\n#\ndo_test autoinc-9.1 {\n  db eval {\n    CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y);\n    INSERT INTO t2 VALUES(NULL, 1);\n    CREATE TABLE t3(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    INSERT INTO t3 SELECT * FROM t2 WHERE y>1;\n\n    SELECT * FROM sqlite_sequence WHERE name='t3';\n  }\n} {t3 0}\n\nifcapable trigger {\n  catchsql { pragma recursive_triggers = off } \n  \n  # Ticket #3928.  Make sure that triggers to not make extra slots in\n  # the SQLITE_SEQUENCE table.\n  #\n  do_test autoinc-3928.1 {\n    db eval {\n      CREATE TABLE t3928(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n      CREATE TRIGGER t3928r1 BEFORE INSERT ON t3928 BEGIN\n        INSERT INTO t3928(b) VALUES('before1');\n        INSERT INTO t3928(b) VALUES('before2');\n      END;\n      CREATE TRIGGER t3928r2 AFTER INSERT ON t3928 BEGIN\n        INSERT INTO t3928(b) VALUES('after1');\n        INSERT INTO t3928(b) VALUES('after2');\n      END;\n      INSERT INTO t3928(b) VALUES('test');\n      SELECT * FROM t3928 ORDER BY a;\n    }\n  } {1 before1 2 after1 3 after2 4 before2 5 after1 6 after2 7 test 8 before1 9 before2 10 after1 11 before1 12 before2 13 after2}\n  do_test autoinc-3928.2 {\n    db eval {\n      SELECT * FROM sqlite_sequence WHERE name='t3928'\n    }\n  } {t3928 13}\n\n  do_test autoinc-3928.3 {\n    db eval {\n      DROP TRIGGER t3928r1;\n      DROP TRIGGER t3928r2;\n      CREATE TRIGGER t3928r3 BEFORE UPDATE ON t3928 \n        WHEN typeof(new.b)=='integer' BEGIN\n           INSERT INTO t3928(b) VALUES('before-int-' || new.b);\n      END;\n      CREATE TRIGGER t3928r4 AFTER UPDATE ON t3928 \n        WHEN typeof(new.b)=='integer' BEGIN\n           INSERT INTO t3928(b) VALUES('after-int-' || new.b);\n      END;\n      DELETE FROM t3928 WHERE a!=1;\n      UPDATE t3928 SET b=456 WHERE a=1;\n      SELECT * FROM t3928 ORDER BY a;\n    }\n  } {1 456 14 before-int-456 15 after-int-456}\n  do_test autoinc-3928.4 {\n    db eval {\n      SELECT * FROM sqlite_sequence WHERE name='t3928'\n    }\n  } {t3928 15}\n  \n  do_test autoinc-3928.5 {\n    db eval {\n      CREATE TABLE t3928b(x);\n      INSERT INTO t3928b VALUES(100);\n      INSERT INTO t3928b VALUES(200);\n      INSERT INTO t3928b VALUES(300);\n      DELETE FROM t3928;\n      CREATE TABLE t3928c(y INTEGER PRIMARY KEY AUTOINCREMENT, z);\n      CREATE TRIGGER t3928br1 BEFORE DELETE ON t3928b BEGIN\n        INSERT INTO t3928(b) VALUES('before-del-'||old.x);\n        INSERT INTO t3928c(z) VALUES('before-del-'||old.x);\n      END;\n      CREATE TRIGGER t3928br2 AFTER DELETE ON t3928b BEGIN\n        INSERT INTO t3928(b) VALUES('after-del-'||old.x);\n        INSERT INTO t3928c(z) VALUES('after-del-'||old.x);\n      END;\n      DELETE FROM t3928b;\n      SELECT * FROM t3928 ORDER BY a;\n    }\n  } {16 before-del-100 17 after-del-100 18 before-del-200 19 after-del-200 20 before-del-300 21 after-del-300}\n  do_test autoinc-3928.6 {\n    db eval {\n      SELECT * FROM t3928c ORDER BY y;\n    }\n  } {1 before-del-100 2 after-del-100 3 before-del-200 4 after-del-200 5 before-del-300 6 after-del-300}\n  do_test autoinc-3928.7 {\n    db eval {\n      SELECT * FROM sqlite_sequence WHERE name LIKE 't3928%' ORDER BY name;\n    }\n  } {t3928 21 t3928c 6}\n  \n  # Ticket [a696379c1f0886615541a48b35bd8181a80e88f8]\n  do_test autoinc-a69637.1 {\n    db eval {\n      CREATE TABLE ta69637_1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);\n      CREATE TABLE ta69637_2(z);\n      CREATE TRIGGER ra69637_1 AFTER INSERT ON ta69637_2 BEGIN\n        INSERT INTO ta69637_1(y) VALUES(new.z+1);\n      END;\n      INSERT INTO ta69637_2 VALUES(123);\n      SELECT * FROM ta69637_1;\n    }\n  } {1 124}\n  do_test autoinc-a69637.2 {\n    db eval {\n      CREATE VIEW va69637_2 AS SELECT * FROM ta69637_2;\n      CREATE TRIGGER ra69637_2 INSTEAD OF INSERT ON va69637_2 BEGIN\n        INSERT INTO ta69637_1(y) VALUES(new.z+10000);\n      END;\n      INSERT INTO va69637_2 VALUES(123);\n      SELECT * FROM ta69637_1;\n    }\n  } {1 124 2 10123}\n}\n\n# 2016-10-03 ticket https://www.sqlite.org/src/tktview/7b3328086a5c1\n# Make sure autoincrement plays nicely with the xfer optimization\n#\ndo_execsql_test autoinc-10.1 {\n  DELETE FROM sqlite_sequence;\n  CREATE TABLE t10a(a INTEGER PRIMARY KEY AUTOINCREMENT, b UNIQUE);\n  INSERT INTO t10a VALUES(888,9999);\n  CREATE TABLE t10b(x INTEGER PRIMARY KEY AUTOINCREMENT, y UNIQUE);\n  INSERT INTO t10b SELECT * FROM t10a;\n  SELECT * FROM sqlite_sequence;\n} {t10a 888 t10b 888}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoindex1.test",
    "content": "# 2010 April 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing automatic index creation logic.\n#\n# EVIDENCE-OF: R-34271-33106 PRAGMA automatic_index; PRAGMA\n# automatic_index = boolean; Query, set, or clear the automatic indexing\n# capability.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the library is not compiled with automatic index support then\n# skip all tests in this file.\n#\nifcapable {!autoindex} {\n  finish_test\n  return\n}\n\n# Setup for logging \ndb close\nsqlite3_shutdown\ntest_sqlite3_log [list lappend ::log]\nset ::log [list]\nsqlite3 db test.db\n\n\n# With automatic index turned off, we do a full scan of the T2 table\ndo_test autoindex1-100 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,11);\n    INSERT INTO t1 VALUES(2,22);\n    INSERT INTO t1 SELECT a+2, b+22 FROM t1;\n    INSERT INTO t1 SELECT a+4, b+44 FROM t1;\n    CREATE TABLE t2(c,d);\n    INSERT INTO t2 SELECT a, 900+b FROM t1;\n  }\n  db eval {\n    PRAGMA automatic_index=OFF;\n    SELECT b, d FROM t1 JOIN t2 ON a=c ORDER BY b;\n  }\n} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}\ndo_test autoindex1-101 {\n  db status step\n} {63}\ndo_test autoindex1-102 {\n  db status autoindex\n} {0}\n\n# With autoindex turned on, we build an index once and then use that index\n# to find T2 values.\ndo_test autoindex1-110 {\n  db eval {\n    PRAGMA automatic_index=ON;\n    SELECT b, d FROM t1 JOIN t2 ON a=c ORDER BY b;\n  }\n} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}\ndo_test autoindex1-111 {\n  db status step\n} {7}\ndo_test autoindex1-112 {\n  db status autoindex\n} {7}\ndo_test autoindex1-113 {\n  set ::log\n} {SQLITE_WARNING_AUTOINDEX {automatic index on t2(c)}}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log\nsqlite3_initialize\nsqlite3 db test.db\n\n# The same test as above, but this time the T2 query is a subquery rather\n# than a join.\ndo_test autoindex1-200 {\n  db eval {\n    PRAGMA automatic_index=OFF;\n    SELECT b, (SELECT d FROM t2 WHERE c=a) FROM t1;\n  }\n} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}\ndo_test autoindex1-201 {\n  db status step\n} {35}\ndo_test autoindex1-202 {\n  db status autoindex\n} {0}\ndo_test autoindex1-210 {\n  db eval {\n    PRAGMA automatic_index=ON;\n    ANALYZE;\n    UPDATE sqlite_stat1 SET stat='10000' WHERE tbl='t1';\n    -- Table t2 actually contains 8 rows.\n    UPDATE sqlite_stat1 SET stat='16' WHERE tbl='t2';\n    ANALYZE sqlite_master;\n    SELECT b, (SELECT d FROM t2 WHERE c=a) FROM t1;\n  }\n} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}\ndo_test autoindex1-211 {\n  db status step\n} {7}\ndo_test autoindex1-212 {\n  db status autoindex\n} {7}\n\n\n# Modify the second table of the join while the join is in progress\n#\ndo_execsql_test autoindex1-299 {\n  UPDATE sqlite_stat1 SET stat='10000' WHERE tbl='t2';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN\n  SELECT b, d FROM t1 CROSS JOIN t2 ON (c=a);\n} {/AUTOMATIC COVERING INDEX/}\ndo_test autoindex1-300 {\n  set r {}\n  db eval {SELECT b, d FROM t1 CROSS JOIN t2 ON (c=a)} {\n    lappend r $b $d\n    db eval {UPDATE t2 SET d=d+1}\n  }\n  set r\n} {11 911 22 922 33 933 44 944 55 955 66 966 77 977 88 988}\ndo_test autoindex1-310 {\n  db eval {SELECT d FROM t2 ORDER BY d}\n} {919 930 941 952 963 974 985 996}\n\n# The next test does a 10-way join on unindexed tables.  Without\n# automatic indices, the join will take a long time to complete.\n# With automatic indices, it should only take about a second.\n#\ndo_test autoindex1-400 {\n  db eval {\n    CREATE TABLE t4(a, b);\n    INSERT INTO t4 VALUES(1,2);\n    INSERT INTO t4 VALUES(2,3);\n  }\n  for {set n 2} {$n<4096} {set n [expr {$n+$n}]} {\n    db eval {INSERT INTO t4 SELECT a+$n, b+$n FROM t4}\n  }\n  db eval {\n    SELECT count(*) FROM t4;\n  }\n} {4096}\ndo_test autoindex1-401 {\n  db eval {\n    SELECT count(*)\n      FROM t4 AS x1\n      JOIN t4 AS x2 ON x2.a=x1.b\n      JOIN t4 AS x3 ON x3.a=x2.b\n      JOIN t4 AS x4 ON x4.a=x3.b\n      JOIN t4 AS x5 ON x5.a=x4.b\n      JOIN t4 AS x6 ON x6.a=x5.b\n      JOIN t4 AS x7 ON x7.a=x6.b\n      JOIN t4 AS x8 ON x8.a=x7.b\n      JOIN t4 AS x9 ON x9.a=x8.b\n      JOIN t4 AS x10 ON x10.a=x9.b;\n  }\n} {4087}\n\n# Ticket [8011086c85c6c404014c947fcf3eb9f42b184a0d] from 2010-07-08\n# Make sure automatic indices are not created for the RHS of an IN expression\n# that is not a correlated subquery.\n#\ndo_execsql_test autoindex1-500 {\n  CREATE TABLE t501(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t502(x INTEGER PRIMARY KEY, y);\n  INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t501',null,'1000000');\n  INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t502',null,'1000');\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t501\n   WHERE t501.a IN (SELECT x FROM t502 WHERE y=?);\n} {\n  0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {EXECUTE LIST SUBQUERY 1} \n  1 0 0 {SCAN TABLE t502}\n}\ndo_execsql_test autoindex1-501 {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t501\n   WHERE t501.a IN (SELECT x FROM t502 WHERE y=t501.b);\n} {\n  0 0 0 {SCAN TABLE t501} \n  0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1} \n  1 0 0 {SEARCH TABLE t502 USING AUTOMATIC COVERING INDEX (y=?)}\n}\ndo_execsql_test autoindex1-502 {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t501\n   WHERE t501.a=123\n     AND t501.a IN (SELECT x FROM t502 WHERE y=t501.b);\n} {\n  0 0 0 {SEARCH TABLE t501 USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1} \n  1 0 0 {SCAN TABLE t502}\n}\n\n\n# The following code checks a performance regression reported on the\n# mailing list on 2010-10-19.  The problem is that the nRowEst field\n# of ephermeral tables was not being initialized correctly and so no\n# automatic index was being created for the emphemeral table when it was\n# used as part of a join.\n#\ndo_execsql_test autoindex1-600 {\n  CREATE TABLE flock_owner(\n    owner_rec_id INTEGER CONSTRAINT flock_owner_key PRIMARY KEY,\n    flock_no VARCHAR(6) NOT NULL REFERENCES flock (flock_no),\n    owner_person_id INTEGER NOT NULL REFERENCES person (person_id),\n    owner_change_date TEXT, last_changed TEXT NOT NULL,\n    CONSTRAINT fo_owner_date UNIQUE (flock_no, owner_change_date)\n  );\n  CREATE TABLE sheep (\n    Sheep_No char(7) NOT NULL,\n    Date_of_Birth char(8),\n    Sort_DoB text,\n    Flock_Book_Vol char(2),\n    Breeder_No char(6),\n    Breeder_Person integer,\n    Originating_Flock char(6),\n    Registering_Flock char(6),\n    Tag_Prefix char(9),\n    Tag_No char(15),\n    Sort_Tag_No integer,\n    Breeders_Temp_Tag char(15),\n    Sex char(1),\n    Sheep_Name char(32),\n    Sire_No char(7),\n    Dam_No char(7),\n    Register_Code char(1),\n    Colour char(48),\n    Colour_Code char(2),\n    Pattern_Code char(8),\n    Horns char(1),\n    Litter_Size char(1),\n    Coeff_of_Inbreeding real,\n    Date_of_Registration text,\n    Date_Last_Changed text,\n    UNIQUE(Sheep_No));\n  CREATE INDEX fo_flock_no_index  \n              ON flock_owner (flock_no);\n  CREATE INDEX fo_owner_change_date_index  \n              ON flock_owner (owner_change_date);\n  CREATE INDEX fo_owner_person_id_index  \n              ON flock_owner (owner_person_id);\n  CREATE INDEX sheep_org_flock_index  \n           ON sheep (originating_flock);\n  CREATE INDEX sheep_reg_flock_index  \n           ON sheep (registering_flock);\n  EXPLAIN QUERY PLAN\n  SELECT x.sheep_no, x.registering_flock, x.date_of_registration\n   FROM sheep x LEFT JOIN\n       (SELECT s.sheep_no, prev.flock_no, prev.owner_person_id,\n       s.date_of_registration, prev.owner_change_date\n       FROM sheep s JOIN flock_owner prev ON s.registering_flock =\n   prev.flock_no\n       AND (prev.owner_change_date <= s.date_of_registration || ' 00:00:00')\n       WHERE NOT EXISTS\n           (SELECT 'x' FROM flock_owner later\n           WHERE prev.flock_no = later.flock_no\n           AND later.owner_change_date > prev.owner_change_date\n           AND later.owner_change_date <= s.date_of_registration||' 00:00:00')\n       ) y ON x.sheep_no = y.sheep_no\n   WHERE y.sheep_no IS NULL\n   ORDER BY x.registering_flock;\n} {\n  1 0 0 {SCAN TABLE sheep AS s} \n  1 1 1 {SEARCH TABLE flock_owner AS prev USING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?)} \n  1 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2} \n  2 0 0 {SEARCH TABLE flock_owner AS later USING COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?)} \n  0 0 0 {SCAN TABLE sheep AS x USING INDEX sheep_reg_flock_index} \n  0 1 1 {SEARCH SUBQUERY 1 AS y USING AUTOMATIC COVERING INDEX (sheep_no=?)}\n}\n\n\ndo_execsql_test autoindex1-700 {\n  CREATE TABLE t5(a, b, c);\n  EXPLAIN QUERY PLAN SELECT a FROM t5 WHERE b=10 ORDER BY c;\n} {\n  0 0 0 {SCAN TABLE t5} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n# The following checks a performance issue reported on the sqlite-dev\n# mailing list on 2013-01-10\n#\ndo_execsql_test autoindex1-800 {\n  CREATE TABLE accounts(\n    _id INTEGER PRIMARY KEY AUTOINCREMENT,\n    account_name TEXT,\n    account_type TEXT,\n    data_set TEXT\n  );\n  CREATE TABLE data(\n    _id INTEGER PRIMARY KEY AUTOINCREMENT,\n    package_id INTEGER REFERENCES package(_id),\n    mimetype_id INTEGER REFERENCES mimetype(_id) NOT NULL,\n    raw_contact_id INTEGER REFERENCES raw_contacts(_id) NOT NULL,\n    is_read_only INTEGER NOT NULL DEFAULT 0,\n    is_primary INTEGER NOT NULL DEFAULT 0,\n    is_super_primary INTEGER NOT NULL DEFAULT 0,\n    data_version INTEGER NOT NULL DEFAULT 0,\n    data1 TEXT,\n    data2 TEXT,\n    data3 TEXT,\n    data4 TEXT,\n    data5 TEXT,\n    data6 TEXT,\n    data7 TEXT,\n    data8 TEXT,\n    data9 TEXT,\n    data10 TEXT,\n    data11 TEXT,\n    data12 TEXT,\n    data13 TEXT,\n    data14 TEXT,\n    data15 TEXT,\n    data_sync1 TEXT,\n    data_sync2 TEXT,\n    data_sync3 TEXT,\n    data_sync4 TEXT \n  );\n  CREATE TABLE mimetypes(\n    _id INTEGER PRIMARY KEY AUTOINCREMENT,\n    mimetype TEXT NOT NULL\n  );\n  CREATE TABLE raw_contacts(\n    _id INTEGER PRIMARY KEY AUTOINCREMENT,\n    account_id INTEGER REFERENCES accounts(_id),\n    sourceid TEXT,\n    raw_contact_is_read_only INTEGER NOT NULL DEFAULT 0,\n    version INTEGER NOT NULL DEFAULT 1,\n    dirty INTEGER NOT NULL DEFAULT 0,\n    deleted INTEGER NOT NULL DEFAULT 0,\n    contact_id INTEGER REFERENCES contacts(_id),\n    aggregation_mode INTEGER NOT NULL DEFAULT 0,\n    aggregation_needed INTEGER NOT NULL DEFAULT 1,\n    custom_ringtone TEXT,\n    send_to_voicemail INTEGER NOT NULL DEFAULT 0,\n    times_contacted INTEGER NOT NULL DEFAULT 0,\n    last_time_contacted INTEGER,\n    starred INTEGER NOT NULL DEFAULT 0,\n    display_name TEXT,\n    display_name_alt TEXT,\n    display_name_source INTEGER NOT NULL DEFAULT 0,\n    phonetic_name TEXT,\n    phonetic_name_style TEXT,\n    sort_key TEXT,\n    sort_key_alt TEXT,\n    name_verified INTEGER NOT NULL DEFAULT 0,\n    sync1 TEXT,\n    sync2 TEXT,\n    sync3 TEXT,\n    sync4 TEXT,\n    sync_uid TEXT,\n    sync_version INTEGER NOT NULL DEFAULT 1,\n    has_calendar_event INTEGER NOT NULL DEFAULT 0,\n    modified_time INTEGER,\n    is_restricted INTEGER DEFAULT 0,\n    yp_source TEXT,\n    method_selected INTEGER DEFAULT 0,\n    custom_vibration_type INTEGER DEFAULT 0,\n    custom_ringtone_path TEXT,\n    message_notification TEXT,\n    message_notification_path TEXT\n  );\n  CREATE INDEX data_mimetype_data1_index ON data (mimetype_id,data1);\n  CREATE INDEX data_raw_contact_id ON data (raw_contact_id);\n  CREATE UNIQUE INDEX mime_type ON mimetypes (mimetype);\n  CREATE INDEX raw_contact_sort_key1_index ON raw_contacts (sort_key);\n  CREATE INDEX raw_contact_sort_key2_index ON raw_contacts (sort_key_alt);\n  CREATE INDEX raw_contacts_contact_id_index ON raw_contacts (contact_id);\n  CREATE INDEX raw_contacts_source_id_account_id_index\n      ON raw_contacts (sourceid, account_id);\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1\n     VALUES('raw_contacts','raw_contact_sort_key2_index','1600 4');\n  INSERT INTO sqlite_stat1\n     VALUES('raw_contacts','raw_contact_sort_key1_index','1600 4');\n  INSERT INTO sqlite_stat1\n     VALUES('raw_contacts','raw_contacts_source_id_account_id_index',\n            '1600 1600 1600');\n  INSERT INTO sqlite_stat1\n     VALUES('raw_contacts','raw_contacts_contact_id_index','1600 1');\n  INSERT INTO sqlite_stat1 VALUES('mimetypes','mime_type','12 1');\n  INSERT INTO sqlite_stat1\n     VALUES('data','data_mimetype_data1_index','9819 2455 3');\n  INSERT INTO sqlite_stat1 VALUES('data','data_raw_contact_id','9819 7');\n  INSERT INTO sqlite_stat1 VALUES('accounts',NULL,'1');\n  DROP TABLE IF EXISTS sqlite_stat3;\n  ANALYZE sqlite_master;\n  \n  EXPLAIN QUERY PLAN\n  SELECT * FROM \n        data JOIN mimetypes ON (data.mimetype_id=mimetypes._id) \n             JOIN raw_contacts ON (data.raw_contact_id=raw_contacts._id) \n             JOIN accounts ON (raw_contacts.account_id=accounts._id)\n   WHERE mimetype_id=10 AND data14 IS NOT NULL;\n} {/SEARCH TABLE data .*SEARCH TABLE raw_contacts/}\ndo_execsql_test autoindex1-801 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM \n        data JOIN mimetypes ON (data.mimetype_id=mimetypes._id) \n             JOIN raw_contacts ON (data.raw_contact_id=raw_contacts._id) \n             JOIN accounts ON (raw_contacts.account_id=accounts._id)\n   WHERE mimetypes._id=10 AND data14 IS NOT NULL;\n} {/SEARCH TABLE data .*SEARCH TABLE raw_contacts/}\n\n# Another test case from an important user of SQLite.  The key feature of\n# this test is that the \"aggindex\" subquery should make use of an\n# automatic index.  If it does, the query is fast.  If it does not, the\n# query is deathly slow.  It worked OK in 3.7.17 but started going slow\n# with version 3.8.0.  The problem was fixed for 3.8.7 by reducing the\n# cost estimate for automatic indexes on views and subqueries.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test autoindex1-900 {\n  CREATE TABLE messages (ROWID INTEGER PRIMARY KEY AUTOINCREMENT, message_id, document_id BLOB, in_reply_to, remote_id INTEGER, sender INTEGER, subject_prefix, subject INTEGER, date_sent INTEGER, date_received INTEGER, date_created INTEGER, date_last_viewed INTEGER, mailbox INTEGER, remote_mailbox INTEGER, original_mailbox INTEGER, flags INTEGER, read, flagged, size INTEGER, color, encoding, type INTEGER, pad, conversation_id INTEGER DEFAULT -1, snippet TEXT DEFAULT NULL, fuzzy_ancestor INTEGER DEFAULT NULL, automated_conversation INTEGER DEFAULT 0, root_status INTEGER DEFAULT -1, conversation_position INTEGER DEFAULT -1);\n  CREATE INDEX date_index ON messages(date_received);\n  CREATE INDEX date_last_viewed_index ON messages(date_last_viewed);\n  CREATE INDEX date_created_index ON messages(date_created);\n  CREATE INDEX message_message_id_mailbox_index ON messages(message_id, mailbox);\n  CREATE INDEX message_document_id_index ON messages(document_id);\n  CREATE INDEX message_read_index ON messages(read);\n  CREATE INDEX message_flagged_index ON messages(flagged);\n  CREATE INDEX message_mailbox_index ON messages(mailbox, date_received);\n  CREATE INDEX message_remote_mailbox_index ON messages(remote_mailbox, remote_id);\n  CREATE INDEX message_type_index ON messages(type);\n  CREATE INDEX message_conversation_id_conversation_position_index ON messages(conversation_id, conversation_position);\n  CREATE INDEX message_fuzzy_ancestor_index ON messages(fuzzy_ancestor);\n  CREATE INDEX message_subject_fuzzy_ancestor_index ON messages(subject, fuzzy_ancestor);\n  CREATE INDEX message_sender_subject_automated_conversation_index ON messages(sender, subject, automated_conversation);\n  CREATE INDEX message_sender_index ON messages(sender);\n  CREATE INDEX message_root_status ON messages(root_status);\n  CREATE TABLE subjects (ROWID INTEGER PRIMARY KEY, subject COLLATE RTRIM, normalized_subject COLLATE RTRIM);\n  CREATE INDEX subject_subject_index ON subjects(subject);\n  CREATE INDEX subject_normalized_subject_index ON subjects(normalized_subject);\n  CREATE TABLE addresses (ROWID INTEGER PRIMARY KEY, address COLLATE NOCASE, comment, UNIQUE(address, comment));\n  CREATE INDEX addresses_address_index ON addresses(address);\n  CREATE TABLE mailboxes (ROWID INTEGER PRIMARY KEY, url UNIQUE, total_count INTEGER DEFAULT 0, unread_count INTEGER DEFAULT 0, unseen_count INTEGER DEFAULT 0, deleted_count INTEGER DEFAULT 0, unread_count_adjusted_for_duplicates INTEGER DEFAULT 0, change_identifier, source INTEGER, alleged_change_identifier);\n  CREATE INDEX mailboxes_source_index ON mailboxes(source);\n  CREATE TABLE labels (ROWID INTEGER PRIMARY KEY, message_id INTEGER NOT NULL, mailbox_id INTEGER NOT NULL, UNIQUE(message_id, mailbox_id));\n  CREATE INDEX labels_message_id_mailbox_id_index ON labels(message_id, mailbox_id);\n  CREATE INDEX labels_mailbox_id_index ON labels(mailbox_id);\n  \n  explain query plan\n  SELECT messages.ROWID,\n         messages.message_id,\n         messages.remote_id,\n         messages.date_received,\n         messages.date_sent,\n         messages.flags,\n         messages.size,\n         messages.color,\n         messages.date_last_viewed,\n         messages.subject_prefix,\n         subjects.subject,\n         sender.comment,\n         sender.address,\n         NULL,\n         messages.mailbox,\n         messages.original_mailbox,\n         NULL,\n         NULL,\n         messages.type,\n         messages.document_id,\n         sender,\n         NULL,\n         messages.conversation_id,\n         messages.conversation_position,\n         agglabels.labels\n   FROM mailboxes AS mailbox\n        JOIN messages ON mailbox.ROWID = messages.mailbox\n        LEFT OUTER JOIN subjects ON messages.subject = subjects.ROWID\n        LEFT OUTER JOIN addresses AS sender ON messages.sender = sender.ROWID\n        LEFT OUTER JOIN (\n               SELECT message_id, group_concat(mailbox_id) as labels\n               FROM labels GROUP BY message_id\n             ) AS agglabels ON messages.ROWID = agglabels.message_id\n  WHERE (mailbox.url = 'imap://email.app@imap.gmail.com/%5BGmail%5D/All%20Mail')\n    AND (messages.ROWID IN (\n            SELECT labels.message_id\n              FROM labels JOIN mailboxes ON labels.mailbox_id = mailboxes.ROWID\n             WHERE mailboxes.url = 'imap://email.app@imap.gmail.com/INBOX'))\n    AND messages.mailbox in (6,12,18,24,30,36,42,1,7,13,19,25,31,37,43,2,8,\n                             14,20,26,32,38,3,9,15,21,27,33,39,4,10,16,22,28,\n                             34,40,5,11,17,23,35,41)\n   ORDER BY date_received DESC;\n} {/agglabels USING AUTOMATIC COVERING INDEX/}\n\n# A test case for VIEWs\n#\ndo_execsql_test autoindex1-901 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);\n  CREATE TABLE t2(a, b);\n  CREATE VIEW agg2 AS SELECT a, sum(b) AS m FROM t2 GROUP BY a;\n  EXPLAIN QUERY PLAN\n  SELECT t1.z, agg2.m\n    FROM t1 JOIN agg2 ON t1.y=agg2.m\n   WHERE t1.x IN (1,2,3);\n} {/USING AUTOMATIC COVERING INDEX/}\n\n# 2015-04-15:  A NULL CollSeq pointer in automatic index creation.\n#\ndo_execsql_test autoindex1-920 {\n  CREATE TABLE t920(x);\n  INSERT INTO t920 VALUES(3),(4),(5);\n  SELECT * FROM t920,(SELECT 0 FROM t920),(VALUES(9)) WHERE 5 IN (x);\n} {5 0 9 5 0 9 5 0 9}\n\n#-------------------------------------------------------------------------\n# An IS term from the WHERE clause of a LEFT JOIN cannot be used as an\n# index driver for the RHS of a LEFT JOIN. Prior to this being fixed,\n# the following SELECT count(*) would incorrectly return 1.\n#\ndo_execsql_test autoindex1-1010 {\n  CREATE TABLE t11(w);\n  CREATE TABLE t12(y);\n  INSERT INTO t11 VALUES(NULL);\n  INSERT INTO t12 VALUES('notnull');\n}\ndo_execsql_test autoindex1-1020 {\n  SELECT count(*) FROM t11 LEFT JOIN t12 WHERE t12.y IS t11.w;\n} 0\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoindex2.test",
    "content": "# 2014-06-17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing automatic index creation logic.\n#\n# This file contains a single real-world test case that was giving\n# suboptimal performance because of over-use of automatic indexes.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\ndo_execsql_test autoindex2-100 {\n  CREATE TABLE t1(\n    t1_id largeint,\n    did char(9),\n    ptime largeint,\n    exbyte char(4),\n    pe_id int,\n    field_id int,\n    mass float,\n    param10 float,\n    param11 float,\n    exmass float,\n    deviation float,\n    trange float,\n    vstatus int,\n    commit_status int,\n    formula char(329),\n    tier int DEFAULT 2,\n    ssid int DEFAULT 0,\n    last_operation largeint DEFAULT 0,\n    admin_uuid int DEFAULT 0,\n    previous_value float,\n    job_id largeint,\n    last_t1 largeint DEFAULT 0,\n    data_t1 int,\n    previous_date largeint DEFAULT 0,\n    flg8 int DEFAULT 1,\n    failed_fields char(100)\n  );\n  CREATE INDEX t1x0 on t1 (t1_id);\n  CREATE INDEX t1x1 on t1 (ptime, vstatus);\n  CREATE INDEX t1x2 on t1 (did, ssid, ptime, vstatus, exbyte, t1_id);\n  CREATE INDEX t1x3 on t1 (job_id);\n  \n  CREATE TABLE t2(\n    did char(9),\n    client_did char(30),\n    description char(49),\n    uid int,\n    tzid int,\n    privilege int,\n    param2 int,\n    type char(30),\n    subtype char(32),\n    dparam1 char(7) DEFAULT '',\n    param5 char(3) DEFAULT '',\n    notional float DEFAULT 0.000000,\n    create_time largeint,\n    sample_time largeint DEFAULT 0,\n    param6 largeint,\n    frequency int,\n    expiration largeint,\n    uw_status int,\n    next_sample largeint,\n    last_sample largeint,\n    reserve1 char(29) DEFAULT '',\n    reserve2 char(29) DEFAULT '',\n    reserve3 char(29) DEFAULT '',\n    bxcdr char(19) DEFAULT 'XY',\n    ssid int DEFAULT 1,\n    last_t1_id largeint,\n    reserve4 char(29) DEFAULT '',\n    reserve5 char(29) DEFAULT '',\n    param12 int DEFAULT 0,\n    long_did char(100) DEFAULT '',\n    gr_code int DEFAULT 0,\n    drx char(100) DEFAULT '',\n    parent_id char(9) DEFAULT '',\n    param13 int DEFAULT 0,\n    position float DEFAULT 1.000000,\n    client_did3 char(100) DEFAULT '',\n    client_did4 char(100) DEFAULT '',\n    dlib_id char(9) DEFAULT ''\n  );\n  CREATE INDEX t2x0 on t2 (did);\n  CREATE INDEX t2x1 on t2 (client_did);\n  CREATE INDEX t2x2 on t2 (long_did);\n  CREATE INDEX t2x3 on t2 (uid);\n  CREATE INDEX t2x4 on t2 (param2);\n  CREATE INDEX t2x5 on t2 (type);\n  CREATE INDEX t2x6 on t2 (subtype);\n  CREATE INDEX t2x7 on t2 (last_sample);\n  CREATE INDEX t2x8 on t2 (param6);\n  CREATE INDEX t2x9 on t2 (frequency);\n  CREATE INDEX t2x10 on t2 (privilege);\n  CREATE INDEX t2x11 on t2 (sample_time);\n  CREATE INDEX t2x12 on t2 (notional);\n  CREATE INDEX t2x13 on t2 (tzid);\n  CREATE INDEX t2x14 on t2 (gr_code);\n  CREATE INDEX t2x15 on t2 (parent_id);\n  \n  CREATE TABLE t3(\n    uid int,\n    param3 int,\n    uuid int,\n    acc_id int,\n    cust_num int,\n    numerix_id int,\n    pfy char(29),\n    param4 char(29),\n    param15 int DEFAULT 0,\n    flg7 int DEFAULT 0,\n    param21 int DEFAULT 0,\n    bxcdr char(2) DEFAULT 'PC',\n    c31 int DEFAULT 0,\n    c33 int DEFAULT 0,\n    c35 int DEFAULT 0,\n    c37 int,\n    mgr_uuid int,\n    back_up_uuid int,\n    priv_mars int DEFAULT 0,\n    is_qc int DEFAULT 0,\n    c41 int DEFAULT 0,\n    deleted int DEFAULT 0,\n    c47 int DEFAULT 1\n  );\n  CREATE INDEX t3x0 on t3 (uid);\n  CREATE INDEX t3x1 on t3 (param3);\n  CREATE INDEX t3x2 on t3 (uuid);\n  CREATE INDEX t3x3 on t3 (acc_id);\n  CREATE INDEX t3x4 on t3 (param4);\n  CREATE INDEX t3x5 on t3 (pfy);\n  CREATE INDEX t3x6 on t3 (is_qc);\n  SELECT count(*) FROM sqlite_master;\n} {30}\ndo_execsql_test autoindex2-110 {\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('t1','t1x3','10747267 260');\n  INSERT INTO sqlite_stat1 VALUES('t1','t1x2','10747267 121 113 2 2 2 1');\n  INSERT INTO sqlite_stat1 VALUES('t1','t1x1','10747267 50 40');\n  INSERT INTO sqlite_stat1 VALUES('t1','t1x0','10747267 1');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x15','39667 253');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x14','39667 19834');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x13','39667 13223');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x12','39667 7');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x11','39667 17');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x10','39667 19834');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x9','39667 7934');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x8','39667 11');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x7','39667 5');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x6','39667 242');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x5','39667 1984');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x4','39667 4408');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x3','39667 81');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x2','39667 551');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x1','39667 2');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2x0','39667 1');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x6','569 285');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x5','569 2');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x4','569 2');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x3','569 5');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x2','569 3');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x1','569 6');\n  INSERT INTO sqlite_stat1 VALUES('t3','t3x0','569 1');\n  ANALYZE sqlite_master;\n} {}\ndo_execsql_test autoindex2-120 {\n  EXPLAIN QUERY PLAN\n  SELECT\n     t1_id,\n     t1.did,\n     param2,\n     param3,\n     t1.ptime,\n     t1.trange,\n     t1.exmass,\n     t1.mass,\n     t1.vstatus,\n     type,\n     subtype,\n     t1.deviation,\n     t1.formula,\n     dparam1,\n     reserve1,\n     reserve2,\n     param4,\n     t1.last_operation,\n     t1.admin_uuid,\n     t1.previous_value,\n     t1.job_id,\n     client_did, \n     t1.last_t1,\n     t1.data_t1,\n     t1.previous_date,\n     param5,\n     param6,\n     mgr_uuid\n  FROM\n     t1,\n     t2,\n     t3\n  WHERE\n     t1.ptime > 1393520400\n     AND param3<>9001\n     AND t3.flg7 = 1\n     AND t1.did = t2.did\n     AND t2.uid = t3.uid\n  ORDER BY t1.ptime desc LIMIT 500;\n} {~/AUTO/}\n#\n# ^^^--- Before being fixed, the above was using an automatic covering\n# on t3 and reordering the tables so that t3 was in the outer loop and\n# implementing the ORDER BY clause using a B-Tree.\n#\n# This test is sanitized data received from a user.  The original unsanitized\n# data and STAT4 data is found in the th3private test repository.  See one of\n# the th3private check-ins on 2016-02-25.  The test is much more accurate when\n# STAT4 data is used.\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoindex3.test",
    "content": "# 2014-06-17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing automatic index creation logic,\n# and specifically that an automatic index will not be created that\n# shadows a declared index.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix autoindex3\n\n# The t1b and t2d indexes are not very selective.  It used to be that\n# the autoindex mechanism would create automatic indexes on t1(b) or\n# t2(d), make assumptions that they were reasonably selective, and use\n# them instead of t1b or t2d.  But that would be cheating, because the\n# automatic index cannot be any more selective than the real index.\n#\n# This test verifies that the cheat is no longer allowed.\n#\ndo_execsql_test autoindex3-100 {\n  CREATE TABLE t1(a,b,x);\n  CREATE TABLE t2(c,d,y);\n  CREATE INDEX t1b ON t1(b);\n  CREATE INDEX t2d ON t2(d);\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('t1','t1b','10000 500');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2d','10000 500');\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d=b;\n} {~/AUTO/}\n\n# Automatic indexes can still be used if existing indexes do not\n# participate in == constraints.\n#\ndo_execsql_test autoindex3-110 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d>b AND x=y;\n} {/AUTO/}\ndo_execsql_test autoindex3-120 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d<b AND x=y;\n} {/AUTO/}\ndo_execsql_test autoindex3-130 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IS NULL AND x=y;\n} {/AUTO/}\ndo_execsql_test autoindex3-140 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IN (5,b) AND x=y;\n} {/AUTO/}\n\nreset_db\ndo_execsql_test 210 {\n  CREATE TABLE v(b, d, e);\n  CREATE TABLE u(a, b, c);\n  ANALYZE sqlite_master;\n  INSERT INTO \"sqlite_stat1\" VALUES('u','uab','40000 400 1');\n  INSERT INTO \"sqlite_stat1\" VALUES('v','vbde','40000 400 1 1');\n  INSERT INTO \"sqlite_stat1\" VALUES('v','ve','40000 21');\n\n  CREATE INDEX uab on u(a, b);\n  CREATE INDEX ve on v(e);\n  CREATE INDEX vbde on v(b,d,e);\n\n  DROP TABLE IF EXISTS sqlite_stat4;\n  ANALYZE sqlite_master;\n}\n\n# At one point, SQLite was using the inferior plan:\n#\n#   0|0|1|SEARCH TABLE v USING INDEX ve (e>?)\n#   0|1|0|SEARCH TABLE u USING COVERING INDEX uab (ANY(a) AND b=?)\n#\n# on the basis that the real index \"uab\" must be better than the automatic\n# index. This is not right - a skip-scan is not necessarily better than an\n# automatic index scan.\n#\ndo_eqp_test 220 {\n  select count(*) from u, v where u.b = v.b and v.e > 34;\n} {\n  0 0 1 {SEARCH TABLE v USING INDEX ve (e>?)} \n  0 1 0 {SEARCH TABLE u USING AUTOMATIC COVERING INDEX (b=?)}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoindex4.test",
    "content": "# 2014-10-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing automatic index creation logic,\n# and specifically creation of automatic partial indexes.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test autoindex4-1.0 {\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(123,'abc'),(234,'def'),(234,'ghi'),(345,'jkl');\n  CREATE TABLE t2(x,y);\n  INSERT INTO t2 VALUES(987,'zyx'),(654,'wvu'),(987,'rqp');\n\n  SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=987 ORDER BY +b;\n} {234 def 987 rqp | 234 def 987 zyx | 234 ghi 987 rqp | 234 ghi 987 zyx |}\ndo_execsql_test autoindex4-1.1 {\n  SELECT *, '|' FROM t1, t2 WHERE a=234 AND x=555;\n} {}\n\ndo_execsql_test autoindex4-1.2 {\n  SELECT *, '|' FROM t1 LEFT JOIN t2 ON a=234 AND x=555;\n} {123 abc {} {} | 234 def {} {} | 234 ghi {} {} | 345 jkl {} {} |}\ndo_execsql_test autoindex4-1.3 {\n  SELECT *, '|' FROM t1 LEFT JOIN t2 ON x=555 WHERE a=234;\n} {234 def {} {} | 234 ghi {} {} |}\ndo_execsql_test autoindex4-1.4 {\n  SELECT *, '|' FROM t1 LEFT JOIN t2 WHERE a=234 AND x=555;\n} {}\n\n\ndo_execsql_test autoindex4-2.0 {\n  CREATE TABLE t3(e,f);\n  INSERT INTO t3 VALUES(123,654),(555,444),(234,987);\n\n  SELECT (SELECT count(*) FROM t1, t2 WHERE a=e AND x=f), e, f, '|'\n    FROM t3\n   ORDER BY rowid;\n} {1 123 654 | 0 555 444 | 4 234 987 |}\n\n# Ticket [2326c258d02ead33d]\n# Two joins, one with and the other without an ORDER BY clause.\n# The one without ORDER BY correctly returns two rows of result.\n# The one with ORDER BY returns no rows. \n#\ndo_execsql_test autoindex4-3.0 {\n  CREATE TABLE A(Name text);\n  CREATE TABLE Items(ItemName text , Name text);\n  INSERT INTO Items VALUES('Item1','Parent');\n  INSERT INTO Items VALUES('Item2','Parent');\n  CREATE TABLE B(Name text);\n  \n  SELECT Items.ItemName\n    FROM Items\n      LEFT JOIN A ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')\n      LEFT JOIN B ON (B.Name = Items.ItemName)\n    WHERE Items.Name = 'Parent'\n    ORDER BY Items.ItemName;\n} {Item1 Item2}\ndo_execsql_test autoindex4-3.1 {\n  CREATE INDEX Items_x1 ON Items(ItemName,Name) WHERE ItemName = 'dummy';\n  \n  SELECT Items.ItemName\n    FROM Items\n      LEFT JOIN A ON (A.Name = Items.ItemName and Items.ItemName = 'dummy')\n      LEFT JOIN B ON (B.Name = Items.ItemName)\n    WHERE Items.Name = 'Parent'\n    ORDER BY Items.ItemName;\n} {Item1 Item2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autoindex5.test",
    "content": "# 2014-10-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing automatic index creation logic,\n# and specifically ensuring that automatic indexes can be used with\n# co-routine subqueries.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix autoindex5\n\n# Schema is from the Debian security database\n#\ndo_execsql_test autoindex5-1.0 {\n  CREATE TABLE source_package_status\n          (bug_name TEXT NOT NULL,\n           package INTEGER NOT NULL,\n           vulnerable INTEGER NOT NULL,\n           urgency TEXT NOT NULL,\n           PRIMARY KEY (bug_name, package));\n  CREATE INDEX source_package_status_package\n              ON source_package_status(package);\n  \n  CREATE TABLE source_packages\n              (name TEXT NOT NULL,\n              release TEXT NOT NULL,\n              subrelease TEXT NOT NULL,\n              archive TEXT NOT NULL,\n              version TEXT NOT NULL,\n              version_id INTEGER NOT NULL DEFAULT 0,\n              PRIMARY KEY (name, release, subrelease, archive));\n  \n  CREATE TABLE bugs\n          (name TEXT NOT NULL PRIMARY KEY,\n           cve_status TEXT NOT NULL\n               CHECK (cve_status IN\n                      ('', 'CANDIDATE', 'ASSIGNED', 'RESERVED', 'REJECTED')),\n           not_for_us INTEGER NOT NULL CHECK (not_for_us IN (0, 1)),\n           description TEXT NOT NULL,\n           release_date TEXT NOT NULL,\n           source_file TEXT NOT NULL,\n           source_line INTEGER NOT NULL);\n  \n  CREATE TABLE package_notes\n          (id INTEGER NOT NULL PRIMARY KEY,\n           bug_name TEXT NOT NULL,\n           package TEXT NOT NULL,\n           fixed_version TEXT\n               CHECK (fixed_version IS NULL OR fixed_version <> ''),\n           fixed_version_id INTEGER NOT NULL DEFAULT 0,\n           release TEXT NOT NULL,\n           package_kind TEXT NOT NULL DEFAULT 'unknown',\n           urgency TEXT NOT NULL,\n           bug_origin TEXT NOT NULL DEFAULT '');\n  CREATE INDEX package_notes_package\n              ON package_notes(package);\n  CREATE UNIQUE INDEX package_notes_bug\n              ON package_notes(bug_name, package, release);\n  \n  CREATE TABLE debian_bugs\n          (bug INTEGER NOT NULL,\n           note INTEGER NOT NULL,\n           PRIMARY KEY (bug, note));\n  \n  \n  CREATE VIEW debian_cve AS\n              SELECT DISTINCT debian_bugs.bug, st.bug_name\n              FROM package_notes, debian_bugs, source_package_status AS st\n              WHERE package_notes.bug_name = st.bug_name\n              AND debian_bugs.note = package_notes.id\n              ORDER BY debian_bugs.bug;\n} {}\n\n# The following query should use an automatic index for the view\n# in FROM clause of the subquery of the second result column.\n#\ndo_execsql_test autoindex5-1.1 {\n  EXPLAIN QUERY PLAN\n  SELECT\n    st.bug_name,\n    (SELECT ALL debian_cve.bug FROM debian_cve\n      WHERE debian_cve.bug_name = st.bug_name\n      ORDER BY debian_cve.bug),\n    sp.release\n  FROM\n     source_package_status AS st,\n     source_packages AS sp,\n     bugs\n  WHERE\n     sp.rowid = st.package\n     AND st.bug_name = bugs.name\n     AND ( st.bug_name LIKE 'CVE-%' OR st.bug_name LIKE 'TEMP-%' )\n     AND ( sp.release = 'sid' OR sp.release = 'stretch' OR sp.release = 'jessie'\n            OR sp.release = 'wheezy' OR sp.release = 'squeeze' )\n  ORDER BY sp.name, st.bug_name, sp.release, sp.subrelease;\n} {/SEARCH SUBQUERY 2 USING AUTOMATIC COVERING INDEX .bug_name=/}\n\n#-------------------------------------------------------------------------\n# Test that ticket [8a2adec1] has been fixed.\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE one(o);\n  INSERT INTO one DEFAULT VALUES;\n\n  CREATE TABLE t1(x, z);\n  INSERT INTO t1 VALUES('aaa', 4.0);\n  INSERT INTO t1 VALUES('aaa', 4.0);\n  CREATE VIEW vvv AS\n    SELECT * FROM t1\n    UNION ALL\n    SELECT 0, 0 WHERE 0;\n\n  SELECT (\n      SELECT sum(z) FROM vvv WHERE x='aaa'\n  ) FROM one;\n} {8.0}\n    \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autovacuum.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n# $Id: autovacuum.test,v 1.29 2009/04/06 17:50:03 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum || !pragma} {\n  finish_test\n  return\n}\n\n# Return a string $len characters long. The returned string is $char repeated\n# over and over. For example, [make_str abc 8] returns \"abcabcab\".\nproc make_str {char len} {\n  set str [string repeat $char. $len]\n  return [string range $str 0 [expr $len-1]]\n}\n\n# Return the number of pages in the file test.db by looking at the file system.\nproc file_pages {} {\n  return [expr [file size test.db] / 1024]\n}\n\n#-------------------------------------------------------------------------\n# Test cases autovacuum-1.* work as follows:\n#\n# 1. A table with a single indexed field is created.\n# 2. Approximately 20 rows are inserted into the table. Each row is long \n#    enough such that it uses at least 2 overflow pages for both the table \n#    and index entry.\n# 3. The rows are deleted in a psuedo-random order. Sometimes only one row\n#    is deleted per transaction, sometimes more than one.\n# 4. After each transaction the table data is checked to ensure it is correct\n#    and a \"PRAGMA integrity_check\" is executed.\n# 5. Once all the rows are deleted the file is checked to make sure it \n#    consists of exactly 4 pages.\n#\n# Steps 2-5 are repeated for a few different psuedo-random delete patterns \n# (defined by the $delete_orders list).\nset delete_orders [list]\nlappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\nlappend delete_orders {20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1} \nlappend delete_orders {8 18 2 4 14 11 13 3 10 7 9 5 12 17 19 15 20 6 16 1}\nlappend delete_orders {10 3 11 17 19 20 7 4 13 6 1 14 16 12 9 18 8 15 5 2}\nlappend delete_orders {{1 2 3 4 5 6 7 8 9 10} {11 12 13 14 15 16 17 18 19 20}}\nlappend delete_orders {{19 8 17 15} {16 11 9 14} {18 5 3 1} {13 20 7 2} {6 12}}\n\n# The length of each table entry. \n# set ENTRY_LEN 3500\nset ENTRY_LEN 3500\n\ndo_test autovacuum-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE av1(a);\n    CREATE INDEX av1_idx ON av1(a);\n  }\n} {}\n\nset tn 0\nforeach delete_order $delete_orders {\n  incr tn\n\n  # Set up the table.\n  set ::tbl_data [list]\n  foreach i [lsort -integer [eval concat $delete_order]] {\n    execsql \"INSERT INTO av1 (oid, a) VALUES($i, '[make_str $i $ENTRY_LEN]')\"\n    lappend ::tbl_data [make_str $i $ENTRY_LEN]\n  }\n\n  # Make sure the integrity check passes with the initial data.\n  ifcapable {integrityck} {\n    do_test autovacuum-1.$tn.1 {\n      execsql {\n        pragma integrity_check\n      }\n    } {ok}\n  }\n\n  foreach delete $delete_order {\n    # Delete one set of rows from the table.\n    do_test autovacuum-1.$tn.($delete).1 {\n      execsql \"\n        DELETE FROM av1 WHERE oid = [join $delete \" OR oid = \"]\n      \"\n    } {}\n\n    # Do the integrity check.\n    ifcapable {integrityck} {\n      do_test autovacuum-1.$tn.($delete).2 {\n        execsql {\n          pragma integrity_check\n        }\n      } {ok}\n    }\n    # Ensure the data remaining in the table is what was expected.\n    foreach d $delete {\n      set idx [lsearch $::tbl_data [make_str $d $ENTRY_LEN]]\n      set ::tbl_data [lreplace $::tbl_data $idx $idx]\n    }\n    do_test autovacuum-1.$tn.($delete).3 {\n      execsql {\n        select a from av1 order by rowid\n      }\n    } $::tbl_data\n  }\n\n  # All rows have been deleted. Ensure the file has shrunk to 4 pages.\n  do_test autovacuum-1.$tn.3 {\n    file_pages\n  } {4}\n}\n\n#---------------------------------------------------------------------------\n# Tests cases autovacuum-2.* test that root pages are allocated \n# and deallocated correctly at the start of the file. Operation is roughly as\n# follows:\n#\n# autovacuum-2.1.*: Drop the tables that currently exist in the database.\n# autovacuum-2.2.*: Create some tables. Ensure that data pages can be\n#                   moved correctly to make space for new root-pages.\n# autovacuum-2.3.*: Drop one of the tables just created (not the last one),\n#                   and check that one of the other tables is moved to\n#                   the free root-page location.\n# autovacuum-2.4.*: Check that a table can be created correctly when the\n#                   root-page it requires is on the free-list.\n# autovacuum-2.5.*: Check that a table with indices can be dropped. This\n#                   is slightly tricky because dropping one of the\n#                   indices/table btrees could move the root-page of another.\n#                   The code-generation layer of SQLite overcomes this problem\n#                   by dropping the btrees in descending order of root-pages.\n#                   This test ensures that this actually happens.\n#\ndo_test autovacuum-2.1.1 {\n  execsql {\n    DROP TABLE av1;\n  }\n} {}\ndo_test autovacuum-2.1.2 {\n  file_pages\n} {1}\n\n# Create a table and put some data in it.\ndo_test autovacuum-2.2.1 {\n  execsql {\n    CREATE TABLE av1(x);\n    SELECT rootpage FROM sqlite_master ORDER BY rootpage;\n  }\n} {3}\ndo_test autovacuum-2.2.2 {\n  execsql \"\n    INSERT INTO av1 VALUES('[make_str abc 3000]');\n    INSERT INTO av1 VALUES('[make_str def 3000]');\n    INSERT INTO av1 VALUES('[make_str ghi 3000]');\n    INSERT INTO av1 VALUES('[make_str jkl 3000]');\n  \"\n  set ::av1_data [db eval {select * from av1}]\n  file_pages\n} {15}\n\n# Create another table. Check it is located immediately after the first.\n# This test case moves the second page in an over-flow chain.\ndo_test autovacuum-2.2.3 {\n  execsql {\n    CREATE TABLE av2(x);\n    SELECT rootpage FROM sqlite_master ORDER BY rootpage;\n  }\n} {3 4}\ndo_test autovacuum-2.2.4 {\n  file_pages\n} {16}\n\n# Create another table. Check it is located immediately after the second.\n# This test case moves the first page in an over-flow chain.\ndo_test autovacuum-2.2.5 {\n  execsql {\n    CREATE TABLE av3(x);\n    SELECT rootpage FROM sqlite_master ORDER BY rootpage;\n  }\n} {3 4 5}\ndo_test autovacuum-2.2.6 {\n  file_pages\n} {17}\n\n# Create another table. Check it is located immediately after the second.\n# This test case moves a btree leaf page.\ndo_test autovacuum-2.2.7 {\n  execsql {\n    CREATE TABLE av4(x);\n    SELECT rootpage FROM sqlite_master ORDER BY rootpage;\n  }\n} {3 4 5 6}\ndo_test autovacuum-2.2.8 {\n  file_pages\n} {18}\ndo_test autovacuum-2.2.9 {\n  execsql {\n    select * from av1\n  }\n} $av1_data\n\ndo_test autovacuum-2.3.1 {\n  execsql {\n    INSERT INTO av2 SELECT 'av1' || x FROM av1;\n    INSERT INTO av3 SELECT 'av2' || x FROM av1;\n    INSERT INTO av4 SELECT 'av3' || x FROM av1;\n  }\n  set ::av2_data [execsql {select x from av2}]\n  set ::av3_data [execsql {select x from av3}]\n  set ::av4_data [execsql {select x from av4}]\n  file_pages\n} {54}\ndo_test autovacuum-2.3.2 {\n  execsql {\n    DROP TABLE av2;\n    SELECT rootpage FROM sqlite_master ORDER BY rootpage;\n  }\n} {3 4 5}\ndo_test autovacuum-2.3.3 {\n  file_pages\n} {41}\ndo_test autovacuum-2.3.4 {\n  execsql {\n    SELECT x FROM av3;\n  }\n} $::av3_data\ndo_test autovacuum-2.3.5 {\n  execsql {\n    SELECT x FROM av4;\n  }\n} $::av4_data\n\n# Drop all the tables in the file. This puts all pages except the first 2\n# (the sqlite_master root-page and the first pointer map page) on the \n# free-list.\ndo_test autovacuum-2.4.1 {\n  execsql {\n    DROP TABLE av1;\n    DROP TABLE av3;\n    BEGIN;\n    DROP TABLE av4;\n  }\n  file_pages\n} {15}\ndo_test autovacuum-2.4.2 {\n  for {set i 3} {$i<=10} {incr i} {\n    execsql \"CREATE TABLE av$i (x)\"\n  }\n  file_pages\n} {15}\ndo_test autovacuum-2.4.3 {\n  execsql {\n    SELECT rootpage FROM sqlite_master ORDER by rootpage\n  }\n} {3 4 5 6 7 8 9 10}\n\n# Right now there are 5 free pages in the database. Consume and then free\n# all 520 pages. Then create 520 tables. This ensures that at least some of the\n# desired root-pages reside on the second free-list trunk page, and that the\n# trunk itself is required at some point.\ndo_test autovacuum-2.4.4 {\n  execsql \"\n    INSERT INTO av3 VALUES ('[make_str abcde [expr 1020*520 + 500]]');\n    DELETE FROM av3;\n  \"\n} {}\nset root_page_list [list]\nset pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1]\n\n# unusable_pages\n# These are either the pending_byte page or the pointer map pages\n#\nunset -nocomplain unusable_page\nif {[sqlite3 -has-codec]} {\n  array set unusable_page {205 1 408 1}\n} else {\n  array set unusable_page {207 1 412 1}\n}\nset unusable_page($pending_byte_page) 1\n\nfor {set i 3} {$i<=532} {incr i} {\n  if {![info exists unusable_page($i)]} {\n    lappend root_page_list $i\n  }\n}\nif {$i >= $pending_byte_page} {\n  lappend root_page_list $i\n}\ndo_test autovacuum-2.4.5 {\n  for {set i 11} {$i<=530} {incr i} {\n    execsql \"CREATE TABLE av$i (x)\"\n  }\n  execsql {\n    SELECT rootpage FROM sqlite_master ORDER by rootpage\n  }\n} $root_page_list\n\n# Just for fun, delete all those tables and see if the database is 1 page.\ndo_test autovacuum-2.4.6 {\n  execsql COMMIT;\n  file_pages\n} [expr 561 + (($i >= $pending_byte_page)?1:0)]\nintegrity_check autovacuum-2.4.6\ndo_test autovacuum-2.4.7 {\n  execsql BEGIN\n  for {set i 3} {$i<=530} {incr i} {\n    execsql \"DROP TABLE av$i\"\n  }\n  execsql COMMIT\n  file_pages\n} 1\n\n# Create some tables with indices to drop.\ndo_test autovacuum-2.5.1 {\n  execsql {\n    CREATE TABLE av1(a PRIMARY KEY, b, c);\n    INSERT INTO av1 VALUES('av1 a', 'av1 b', 'av1 c');\n\n    CREATE TABLE av2(a PRIMARY KEY, b, c);\n    CREATE INDEX av2_i1 ON av2(b);\n    CREATE INDEX av2_i2 ON av2(c);\n    INSERT INTO av2 VALUES('av2 a', 'av2 b', 'av2 c');\n\n    CREATE TABLE av3(a PRIMARY KEY, b, c);\n    CREATE INDEX av3_i1 ON av3(b);\n    INSERT INTO av3 VALUES('av3 a', 'av3 b', 'av3 c');\n\n    CREATE TABLE av4(a, b, c);\n    CREATE INDEX av4_i1 ON av4(a);\n    CREATE INDEX av4_i2 ON av4(b);\n    CREATE INDEX av4_i3 ON av4(c);\n    CREATE INDEX av4_i4 ON av4(a, b, c);\n    INSERT INTO av4 VALUES('av4 a', 'av4 b', 'av4 c');\n  }\n} {}\n\ndo_test autovacuum-2.5.2 {\n  execsql {\n    SELECT name, rootpage FROM sqlite_master;\n  }\n} [list av1 3  sqlite_autoindex_av1_1 4 \\\n        av2 5  sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \\\n        av3 9 sqlite_autoindex_av3_1 10 av3_i1 11 \\\n        av4 12 av4_i1 13 av4_i2 14 av4_i3 15 av4_i4 16 \\\n]\n\n# The following 4 tests are SELECT queries that use the indices created.\n# If the root-pages in the internal schema are not updated correctly when\n# a table or indice is moved, these queries will fail. They are repeated\n# after each table is dropped (i.e. as test cases 2.5.*.[1..4]).\ndo_test autovacuum-2.5.2.1 {\n  execsql {\n    SELECT * FROM av1 WHERE a = 'av1 a';\n  }\n} {{av1 a} {av1 b} {av1 c}}\ndo_test autovacuum-2.5.2.2 {\n  execsql {\n    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'\n  }\n} {{av2 a} {av2 b} {av2 c}}\ndo_test autovacuum-2.5.2.3 {\n  execsql {\n    SELECT * FROM av3 WHERE a = 'av3 a' AND b = 'av3 b';\n  }\n} {{av3 a} {av3 b} {av3 c}}\ndo_test autovacuum-2.5.2.4 {\n  execsql {\n    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';\n  }\n} {{av4 a} {av4 b} {av4 c}}\n\n# Drop table av3. Indices av4_i2, av4_i3 and av4_i4 are moved to fill the two\n# root pages vacated. The operation proceeds as:\n# Step 1: Delete av3_i1 (root-page 11). Move root-page of av4_i4 to page 11.\n# Step 2: Delete av3 (root-page 10). Move root-page of av4_i3 to page 10.\n# Step 3: Delete sqlite_autoindex_av1_3 (root-page 9). Move av4_i2 to page 9.\ndo_test autovacuum-2.5.3 {\n  execsql {\n    DROP TABLE av3;\n    SELECT name, rootpage FROM sqlite_master;\n  }\n} [list av1 3  sqlite_autoindex_av1_1 4 \\\n        av2 5  sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \\\n        av4 12 av4_i1 13 av4_i2 9 av4_i3 10 av4_i4 11 \\\n]\ndo_test autovacuum-2.5.3.1 {\n  execsql {\n    SELECT * FROM av1 WHERE a = 'av1 a';\n  }\n} {{av1 a} {av1 b} {av1 c}}\ndo_test autovacuum-2.5.3.2 {\n  execsql {\n    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'\n  }\n} {{av2 a} {av2 b} {av2 c}}\ndo_test autovacuum-2.5.3.3 {\n  execsql {\n    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';\n  }\n} {{av4 a} {av4 b} {av4 c}}\n\n# Drop table av1:\n# Step 1: Delete av1 (root page 4). Root-page of av4_i1 fills the gap.\n# Step 2: Delete sqlite_autoindex_av1_1 (root page 3). Move av4 to the gap.\ndo_test autovacuum-2.5.4 {\n  execsql {\n    DROP TABLE av1;\n    SELECT name, rootpage FROM sqlite_master;\n  }\n} [list av2 5  sqlite_autoindex_av2_1 6 av2_i1 7 av2_i2 8 \\\n        av4 3 av4_i1 4 av4_i2 9 av4_i3 10 av4_i4 11 \\\n]\ndo_test autovacuum-2.5.4.2 {\n  execsql {\n    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'\n  }\n} {{av2 a} {av2 b} {av2 c}}\ndo_test autovacuum-2.5.4.4 {\n  execsql {\n    SELECT * FROM av4 WHERE a = 'av4 a' AND b = 'av4 b' AND c = 'av4 c';\n  }\n} {{av4 a} {av4 b} {av4 c}}\n\n# Drop table av4:\n# Step 1: Delete av4_i4.\n# Step 2: Delete av4_i3.\n# Step 3: Delete av4_i2.\n# Step 4: Delete av4_i1. av2_i2 replaces it.\n# Step 5: Delete av4. av2_i1 replaces it.\ndo_test autovacuum-2.5.5 {\n  execsql {\n    DROP TABLE av4;\n    SELECT name, rootpage FROM sqlite_master;\n  }\n} [list av2 5 sqlite_autoindex_av2_1 6 av2_i1 3 av2_i2 4]\ndo_test autovacuum-2.5.5.2 {\n  execsql {\n    SELECT * FROM av2 WHERE a = 'av2 a' AND b = 'av2 b' AND c = 'av2 c'\n  }\n} {{av2 a} {av2 b} {av2 c}}\n\n#--------------------------------------------------------------------------\n# Test cases autovacuum-3.* test the operation of the \"PRAGMA auto_vacuum\"\n# command.\n#\ndo_test autovacuum-3.1 {\n  execsql {\n    PRAGMA auto_vacuum;\n  }\n} {1}\ndo_test autovacuum-3.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum;\n  }\n} {1}\ndo_test autovacuum-3.3 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA auto_vacuum;\n  }\n} {1}\n\ndo_test autovacuum-3.4 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum;\n  }\n} $AUTOVACUUM\ndo_test autovacuum-3.5 {\n  execsql {\n    CREATE TABLE av1(x);\n    PRAGMA auto_vacuum;\n  }\n} $AUTOVACUUM\ndo_test autovacuum-3.6 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA auto_vacuum;\n  }\n} [expr $AUTOVACUUM ? 1 : 0]\ndo_test autovacuum-3.7 {\n  execsql {\n    DROP TABLE av1;\n  }\n  file_pages\n} [expr $AUTOVACUUM?1:2]\n\n\n#-----------------------------------------------------------------------\n# Test that if a statement transaction around a CREATE INDEX statement is\n# rolled back no corruption occurs.\n#\ndo_test autovacuum-4.0 {\n  # The last round of tests may have left the db in non-autovacuum mode.\n  # Reset everything just in case.\n  #\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA auto_vacuum;\n  }\n} {1}\ndo_test autovacuum-4.1 {\n  execsql {\n    CREATE TABLE av1(a, b);\n    BEGIN;\n  }\n  for {set i 0} {$i<100} {incr i} {\n    execsql \"INSERT INTO av1 VALUES($i, '[string repeat X 200]');\"\n  }\n  execsql \"INSERT INTO av1 VALUES(99, '[string repeat X 200]');\"\n  execsql {\n    SELECT sum(a) FROM av1;\n  }\n} {5049}\ndo_test autovacuum-4.2 {\n  catchsql {\n    CREATE UNIQUE INDEX av1_i ON av1(a);\n  }\n} {1 {UNIQUE constraint failed: av1.a}}\ndo_test autovacuum-4.3 {\n  execsql {\n    SELECT sum(a) FROM av1;\n  }\n} {5049}\ndo_test autovacuum-4.4 {\n  execsql {\n    COMMIT;\n  }\n} {}\n\nifcapable integrityck {\n\n# Ticket #1727\ndo_test autovacuum-5.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    PRAGMA auto_vacuum=1;\n    CREATE TABLE t1(a);\n    CREATE TABLE t2(a);\n    DROP TABLE t1;\n    PRAGMA integrity_check;\n  }\n} ok\n\n}\n\n# Ticket #1728.\n#\n# In autovacuum mode, when tables or indices are deleted, the rootpage\n# values in the symbol table have to be updated.  There was a bug in this\n# logic so that if an index/table was moved twice, the second move might\n# not occur.  This would leave the internal symbol table in an inconsistent\n# state causing subsequent statements to fail.\n#\n# The problem is difficult to reproduce.  The sequence of statements in\n# the following test are carefully designed make it occur and thus to\n# verify that this very obscure bug has been resolved.\n# \nifcapable integrityck&&memorydb {\n\ndo_test autovacuum-6.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    PRAGMA auto_vacuum=1;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a);\n    CREATE TABLE t2(a);\n    CREATE INDEX i2 ON t2(a);\n    CREATE TABLE t3(a);\n    CREATE INDEX i3 ON t2(a);\n    CREATE INDEX x ON t1(b);\n    DROP TABLE t3;\n    PRAGMA integrity_check;\n    DROP TABLE t2;\n    PRAGMA integrity_check;\n    DROP TABLE t1;\n    PRAGMA integrity_check;\n  }\n} {ok ok ok}\n\n}\n\n#---------------------------------------------------------------------\n# Test cases autovacuum-7.X test the case where a page must be moved\n# and the destination location collides with at least one other\n# entry in the page hash-table (internal to the pager.c module. \n#\ndo_test autovacuum-7.1 {\n  db close\n  forcedelete test.db\n  forcedelete test.db-journal\n  sqlite3 db test.db\n\n  execsql {\n    PRAGMA auto_vacuum=1;\n    CREATE TABLE t1(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 32\n  }\n\n  expr {[file size test.db] / 1024}\n} {73}\n\ndo_test autovacuum-7.2 {\n  execsql {\n    CREATE TABLE t2(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t2 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n    CREATE TABLE t3(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t3 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n    CREATE TABLE t4(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t4 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n    CREATE TABLE t5(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t5 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n  }\n  expr {[file size test.db] / 1024}\n} {354}\n\ndo_test autovacuum-7.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    DELETE FROM t4;\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n  expr {[file size test.db] / 1024}\n} {286}\n\n#------------------------------------------------------------------------\n# Additional tests.\n#\n# Try to determine the autovacuum setting for a database that is locked.\n#\ndo_test autovacuum-8.1 {\n  db close\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  db eval {PRAGMA auto_vacuum}\n} {1}\nif {[permutation] == \"\"} {\n  do_test autovacuum-8.2 {\n    db eval {BEGIN EXCLUSIVE}\n    catchsql {PRAGMA auto_vacuum} db2\n  } {1 {database is locked}}\n  catch {db2 close}\n  catch {db eval {COMMIT}}\n}\n\ndo_test autovacuum-9.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n    DROP TABLE t4;\n    DROP TABLE t5;\n    PRAGMA page_count;\n  }\n} {1}\ndo_test autovacuum-9.2 {\n  file size test.db\n} 1024\ndo_test autovacuum-9.3 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(NULL, randstr(50,50));\n  }\n  for {set ii 0} {$ii < 10} {incr ii} {\n    db eval { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }\n  }\n  file size test.db\n} $::sqlite_pending_byte\ndo_test autovacuum-9.4 {\n  execsql { INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 }\n} {}\ndo_test autovacuum-9.5 {\n  execsql { DELETE FROM t1 WHERE rowid > (SELECT max(a)/2 FROM t1) }\n  file size test.db\n} $::sqlite_pending_byte\n \ndo_execsql_test autovacuum-10.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(25, randomblob(104));\n  REPLACE INTO t1 VALUES(25, randomblob(1117));\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/autovacuum_ioerr2.test",
    "content": "# 2001 October 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# such as writes failing because the disk is full.\n# \n# The tests in this file use special facilities that are only\n# available in the SQLite test fixture.\n#\n# $Id: autovacuum_ioerr2.test,v 1.7 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum} {\n  finish_test\n  return\n}\n\ndo_ioerr_test autovacuum-ioerr2-1 -sqlprep {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE abc(a);\n  INSERT INTO abc VALUES(randstr(1500,1500));\n} -sqlbody {\n  CREATE TABLE abc2(a);\n  BEGIN;\n  DELETE FROM abc;\n  INSERT INTO abc VALUES(randstr(1500,1500));\n  CREATE TABLE abc3(a);\n  COMMIT;\n}\n\ndo_ioerr_test autovacuum-ioerr2-2 -tclprep {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE abc(a);\n    INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow\n    INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow\n  }\n  for {set i 0} {$i<150} {incr i} {\n    execsql {\n      INSERT INTO abc VALUES(randstr(100,100)); \n    }\n  }\n  execsql COMMIT\n} -sqlbody {\n  BEGIN;\n  DELETE FROM abc WHERE length(a)>100;\n  UPDATE abc SET a = randstr(90,90);\n  CREATE TABLE abc3(a);\n  COMMIT;\n}\n\ndo_ioerr_test autovacuum-ioerr2-3 -sqlprep {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE abc(a);\n  CREATE TABLE abc2(b);\n} -sqlbody {\n  BEGIN;\n  INSERT INTO abc2 VALUES(10);\n  DROP TABLE abc;\n  COMMIT;\n  DROP TABLE abc2;\n}\n\nforcedelete backup.db\nifcapable subquery {\n  do_ioerr_test autovacuum-ioerr2-4 -tclprep {\n    if {![file exists backup.db]} {\n      sqlite3 dbb backup.db \n      execsql {\n        PRAGMA auto_vacuum = 1;\n        BEGIN;\n        CREATE TABLE abc(a);\n        INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow\n        INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow\n      } dbb\n      for {set i 0} {$i<2500} {incr i} {\n        execsql {\n          INSERT INTO abc VALUES(randstr(100,100)); \n        } dbb\n      }\n      execsql {\n        COMMIT;\n        PRAGMA cache_size = 10;\n      } dbb\n      dbb close\n    }\n    db close\n    forcedelete test.db\n    forcedelete test.db-journal\n    forcecopy backup.db test.db\n    set ::DB [sqlite3 db test.db]\n    execsql {\n      PRAGMA cache_size = 10;\n    }\n  } -sqlbody {\n    BEGIN;\n    DELETE FROM abc WHERE oid < 3;\n    UPDATE abc SET a = randstr(100,100) WHERE oid > 2300;\n    UPDATE abc SET a = randstr(1100,1100) WHERE oid = \n        (select max(oid) from abc);\n    COMMIT;\n  }\n}\n\ndo_ioerr_test autovacuum-ioerr2-1 -sqlprep {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE abc(a);\n  INSERT INTO abc VALUES(randstr(1500,1500));\n} -sqlbody {\n  CREATE TABLE abc2(a);\n  BEGIN;\n  DELETE FROM abc;\n  INSERT INTO abc VALUES(randstr(1500,1500));\n  CREATE TABLE abc3(a);\n  COMMIT;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/avtrans.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  This\n# file is a copy of \"trans.test\" modified to run under autovacuum mode.\n# the point is to stress the autovacuum logic and try to get it to fail.\n#\n# $Id: avtrans.test,v 1.6 2007/09/12 17:01:45 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# Create several tables to work with.\n#\ndo_test avtrans-1.0 {\n  execsql { PRAGMA auto_vacuum=ON }\n  wal_set_journal_mode\n  execsql { \n    CREATE TABLE one(a int PRIMARY KEY, b text);\n    INSERT INTO one VALUES(1,'one');\n    INSERT INTO one VALUES(2,'two');\n    INSERT INTO one VALUES(3,'three');\n    SELECT b FROM one ORDER BY a;\n  }\n} {one two three}\ndo_test avtrans-1.1 {\n  execsql {\n    CREATE TABLE two(a int PRIMARY KEY, b text);\n    INSERT INTO two VALUES(1,'I');\n    INSERT INTO two VALUES(5,'V');\n    INSERT INTO two VALUES(10,'X');\n    SELECT b FROM two ORDER BY a;\n  }\n} {I V X}\ndo_test avtrans-1.9 {\n  sqlite3 altdb test.db\n  execsql {SELECT b FROM one ORDER BY a} altdb\n} {one two three}\ndo_test avtrans-1.10 {\n  execsql {SELECT b FROM two ORDER BY a} altdb\n} {I V X}\nintegrity_check avtrans-1.11\nwal_check_journal_mode avtrans-1.12\n\n# Basic transactions\n#\ndo_test avtrans-2.1 {\n  set v [catch {execsql {BEGIN}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.2 {\n  set v [catch {execsql {END}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.3 {\n  set v [catch {execsql {BEGIN TRANSACTION}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.4 {\n  set v [catch {execsql {COMMIT TRANSACTION}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.5 {\n  set v [catch {execsql {BEGIN TRANSACTION 'foo'}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.6 {\n  set v [catch {execsql {ROLLBACK TRANSACTION 'foo'}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test avtrans-2.10 {\n  execsql {\n    BEGIN;\n    SELECT a FROM one ORDER BY a;\n    SELECT a FROM two ORDER BY a;\n    END;\n  }\n} {1 2 3 1 5 10}\nintegrity_check avtrans-2.11\nwal_check_journal_mode avtrans-2.12\n\n# Check the locking behavior\n#\nsqlite3_soft_heap_limit 0\ndo_test avtrans-3.1 {\n  execsql {\n    BEGIN;\n    UPDATE one SET a = 0 WHERE 0;\n    SELECT a FROM one ORDER BY a;\n  }\n} {1 2 3}\ndo_test avtrans-3.2 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\ndo_test avtrans-3.3 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test avtrans-3.4 {\n  catchsql {\n    INSERT INTO one VALUES(4,'four');\n  }\n} {0 {}}\ndo_test avtrans-3.5 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\ndo_test avtrans-3.6 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test avtrans-3.7 {\n  catchsql {\n    INSERT INTO two VALUES(4,'IV');\n  }\n} {0 {}}\ndo_test avtrans-3.8 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\ndo_test avtrans-3.9 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test avtrans-3.10 {\n  execsql {END TRANSACTION}\n} {}\ndo_test avtrans-3.11 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test avtrans-3.12 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\ndo_test avtrans-3.13 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test avtrans-3.14 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\nintegrity_check avtrans-3.15\n\ndo_test avtrans-4.1 {\n  set v [catch {execsql {\n    COMMIT;\n  } db} msg]\n  lappend v $msg\n} {1 {cannot commit - no transaction is active}}\ndo_test avtrans-4.2 {\n  set v [catch {execsql {\n    ROLLBACK;\n  } db} msg]\n  lappend v $msg\n} {1 {cannot rollback - no transaction is active}}\ndo_test avtrans-4.3 {\n  catchsql {\n    BEGIN TRANSACTION;\n    UPDATE two SET a = 0 WHERE 0;\n    SELECT a FROM two ORDER BY a;\n  } db\n} {0 {1 4 5 10}}\ndo_test avtrans-4.4 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 4 5 10}}\ndo_test avtrans-4.5 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3 4}}\ndo_test avtrans-4.6 {\n  catchsql {\n    BEGIN TRANSACTION;\n    SELECT a FROM one ORDER BY a;\n  } db\n} {1 {cannot start a transaction within a transaction}}\ndo_test avtrans-4.7 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 4 5 10}}\ndo_test avtrans-4.8 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3 4}}\ndo_test avtrans-4.9 {\n  set v [catch {execsql {\n    END TRANSACTION;\n    SELECT a FROM two ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test avtrans-4.10 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test avtrans-4.11 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\nintegrity_check avtrans-4.12\ndo_test avtrans-4.98 {\n  altdb close\n  execsql {\n    DROP TABLE one;\n    DROP TABLE two;\n  }\n} {}\nintegrity_check avtrans-4.99\n\n# Check out the commit/rollback behavior of the database\n#\ndo_test avtrans-5.1 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test avtrans-5.2 {\n  execsql {BEGIN TRANSACTION}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test avtrans-5.3 {\n  execsql {CREATE TABLE one(a text, b int)}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {one}\ndo_test avtrans-5.4 {\n  execsql {SELECT a,b FROM one ORDER BY b}\n} {}\ndo_test avtrans-5.5 {\n  execsql {INSERT INTO one(a,b) VALUES('hello', 1)}\n  execsql {SELECT a,b FROM one ORDER BY b}\n} {hello 1}\ndo_test avtrans-5.6 {\n  execsql {ROLLBACK}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test avtrans-5.7 {\n  set v [catch {\n    execsql {SELECT a,b FROM one ORDER BY b}\n  } msg]\n  lappend v $msg\n} {1 {no such table: one}}\n\n# Test commits and rollbacks of table CREATE TABLEs, CREATE INDEXs\n# DROP TABLEs and DROP INDEXs\n#\ndo_test avtrans-5.8 {\n  execsql {\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name\n  }\n} {}\ndo_test avtrans-5.9 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a int, b int, c int);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {t1}\ndo_test avtrans-5.10 {\n  execsql {\n    CREATE INDEX i1 ON t1(a);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test avtrans-5.11 {\n  execsql {\n    COMMIT;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test avtrans-5.12 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE t2(a int, b int, c int);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n    DROP TABLE t1;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2a i2b t2}\ndo_test avtrans-5.13 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test avtrans-5.14 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {t1}\ndo_test avtrans-5.15 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test avtrans-5.16 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE TABLE t2(x int, y int, z int);\n    CREATE INDEX i2x ON t2(x);\n    CREATE INDEX i2y ON t2(y);\n    INSERT INTO t2 VALUES(1,2,3);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test avtrans-5.17 {\n  execsql {\n    COMMIT;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test avtrans-5.18 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test avtrans-5.19 {\n  execsql {\n    SELECT x FROM t2 WHERE y=2;\n  }\n} {1}\ndo_test avtrans-5.20 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    DROP TABLE t2;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {}\ndo_test avtrans-5.21 {\n  set r [catch {execsql {\n    SELECT * FROM t2\n  }} msg]\n  lappend r $msg\n} {1 {no such table: t2}}\ndo_test avtrans-5.22 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test avtrans-5.23 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 3}\nintegrity_check avtrans-5.23\n\n\n# Try to DROP and CREATE tables and indices with the same name\n# within a transaction.  Make sure ROLLBACK works.\n#\ndo_test avtrans-6.1 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p,q,r);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {a 1 b 2 c 3}\ndo_test avtrans-6.2 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p,q,r);\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test avtrans-6.3 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test avtrans-6.4 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test avtrans-6.5 {\n  execsql2 {\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test avtrans-6.6 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test avtrans-6.7 {\n  catchsql {\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {1 {no such table: t1}}\n\n# Repeat on a table with an automatically generated index.\n#\ndo_test avtrans-6.10 {\n  execsql2 {\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p unique,q,r);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {a 1 b 2 c 3}\ndo_test avtrans-6.11 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p unique,q,r);\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test avtrans-6.12 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test avtrans-6.13 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test avtrans-6.14 {\n  execsql2 {\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test avtrans-6.15 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test avtrans-6.16 {\n  catchsql {\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {1 {no such table: t1}}\n\ndo_test avtrans-6.20 {\n  execsql {\n    CREATE TABLE t1(a integer primary key,b,c);\n    INSERT INTO t1 VALUES(1,-2,-3);\n    INSERT INTO t1 VALUES(4,-5,-6);\n    SELECT * FROM t1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.21 {\n  execsql {\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.22 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE b<1;\n    ROLLBACK;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.23 {\n  execsql {\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.24 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\n\ndo_test avtrans-6.25 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE INDEX i1 ON t1(c);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.26 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.27 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.28 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\n\n# The following repeats steps 6.20 through 6.28, but puts a \"unique\"\n# constraint the first field of the table in order to generate an\n# automatic index.\n#\ndo_test avtrans-6.30 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a int unique,b,c);\n    COMMIT;\n    INSERT INTO t1 VALUES(1,-2,-3);\n    INSERT INTO t1 VALUES(4,-5,-6);\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.31 {\n  execsql {\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.32 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE b<1;\n    ROLLBACK;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.33 {\n  execsql {\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.34 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\n\ndo_test avtrans-6.35 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE INDEX i1 ON t1(c);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.36 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.37 {\n  execsql {\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test avtrans-6.38 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test avtrans-6.39 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\nintegrity_check avtrans-6.40\n\nifcapable !floatingpoint {\n  finish_test\n  return\n}\n\n# Test to make sure rollback restores the database back to its original\n# state.\n#\ndo_test avtrans-7.1 {\n  execsql {BEGIN}\n  for {set i 0} {$i<1000} {incr i} {\n    set r1 [expr {rand()}]\n    set r2 [expr {rand()}]\n    set r3 [expr {rand()}]\n    execsql \"INSERT INTO t2 VALUES($r1,$r2,$r3)\"\n  }\n  execsql {COMMIT}\n  set ::checksum [execsql {SELECT md5sum(x,y,z) FROM t2}]\n  set ::checksum2 [\n    execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n  ]\n  execsql {SELECT count(*) FROM t2}\n} {1001}\ndo_test avtrans-7.2 {\n  execsql {SELECT md5sum(x,y,z) FROM t2}\n} $checksum\ndo_test avtrans-7.2.1 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\ndo_test avtrans-7.3 {\n  execsql {\n    BEGIN;\n    DELETE FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test avtrans-7.4 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT * FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test avtrans-7.5 {\n  execsql {\n    BEGIN;\n    DELETE FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test avtrans-7.6 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT * FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test avtrans-7.7 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3 AS SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t3;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test avtrans-7.8 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test avtrans-7.9 {\n    execsql {\n      BEGIN;\n      CREATE TEMP TABLE t3 AS SELECT * FROM t2;\n      INSERT INTO t2 SELECT * FROM t3;\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test avtrans-7.10 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test avtrans-7.11 {\n    execsql {\n      BEGIN;\n      CREATE TEMP TABLE t3 AS SELECT * FROM t2;\n      INSERT INTO t2 SELECT * FROM t3;\n      DROP INDEX i2x;\n      DROP INDEX i2y;\n      CREATE INDEX i3a ON t3(x);\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test avtrans-7.12 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test avtrans-7.13 {\n    execsql {\n      BEGIN;\n      DROP TABLE t2;\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test avtrans-7.14 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nintegrity_check avtrans-7.15\n\n# Arrange for another process to begin modifying the database but abort\n# and die in the middle of the modification.  Then have this process read\n# the database.  This process should detect the journal file and roll it\n# back.  Verify that this happens correctly.\n#\nset fd [open test.tcl w]\nputs $fd {\n  sqlite3 db test.db\n  db eval {\n    PRAGMA default_cache_size=20;\n    BEGIN;\n    CREATE TABLE t3 AS SELECT * FROM t2;\n    DELETE FROM t2;\n  }\n  sqlite_abort\n}\nclose $fd\ndo_test avtrans-8.1 {\n  catch {exec [info nameofexec] test.tcl}\n  execsql {SELECT md5sum(x,y,z) FROM t2}\n} $checksum\ndo_test avtrans-8.2 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nintegrity_check avtrans-8.3\n\n# In the following sequence of tests, compute the MD5 sum of the content\n# of a table, make lots of modifications to that table, then do a rollback.\n# Verify that after the rollback, the MD5 checksum is unchanged.\n#\ndo_test avtrans-9.1 {\n  execsql {\n    PRAGMA default_cache_size=10;\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(x TEXT);\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    COMMIT;\n    SELECT count(*) FROM t3;\n  }\n} {1024}\n\n# The following procedure computes a \"signature\" for table \"t3\".  If\n# T3 changes in any way, the signature should change.  \n#\n# This is used to test ROLLBACK.  We gather a signature for t3, then\n# make lots of changes to t3, then rollback and take another signature.\n# The two signatures should be the same.\n#\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(x) FROM t3}]\n}\n\n# Repeat the following group of tests 20 times for quick testing and\n# 40 times for full testing.  Each iteration of the test makes table\n# t3 a little larger, and thus takes a little longer, so doing 40 tests\n# is more than 2.0 times slower than doing 20 tests.  Considerably more.\n#\nif {[info exists G(isquick)]} {\n  set limit 20\n} else {\n  set limit 40\n}\n\n# Do rollbacks.  Make sure the signature does not change.\n#\nfor {set i 2} {$i<=$limit} {incr i} {\n  set ::sig [signature]\n  set cnt [lindex $::sig 0]\n  if {$i%2==0} {\n    execsql {PRAGMA fullfsync=ON}\n  } else {\n    execsql {PRAGMA fullfsync=OFF}\n  }\n  set sqlite_sync_count 0\n  set sqlite_fullsync_count 0\n  do_test avtrans-9.$i.1-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     signature\n  } $sig\n  do_test avtrans-9.$i.2-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     signature\n  } $sig\n  if {$i<$limit} {\n    do_test avtrans-9.$i.3-$cnt {\n       execsql {\n         INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;\n       }\n    } {}\n    if {$tcl_platform(platform)==\"unix\"} {\n      do_test avtrans-9.$i.4-$cnt {\n         expr {$sqlite_sync_count>0}\n      } 1\n      ifcapable pager_pragmas {\n        do_test avtrans-9.$i.5-$cnt {\n           expr {$sqlite_fullsync_count>0}\n        } [expr {$i%2==0}]\n      } else {\n        do_test avtrans-9.$i.5-$cnt {\n           expr {$sqlite_fullsync_count==0}\n        } {1}\n      }\n    }\n    wal_check_journal_mode avtrans-9.$i-6.$cnt\n  }\n  set ::pager_old_format 0\n}\nintegrity_check avtrans-10.1\nwal_check_journal_mode avtrans-10.2\n   \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backcompat.test",
    "content": "# 2010 August 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the current version of SQLite\n# is capable of reading and writing databases created by previous\n# versions, and vice-versa.\n#\n# To use this test, old versions of the testfixture process should be\n# copied into the working directory alongside the new version. The old\n# versions should be named \"testfixtureXXX\" (or testfixtureXXX.exe on\n# windows), where XXX can be any string.\n#\n# This test file uses the tcl code for controlling a second testfixture\n# process located in lock_common.tcl. See the commments in lock_common.tcl \n# for documentation of the available commands.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/bc_common.tcl\ndb close\n\nif {\"\" == [bc_find_binaries backcompat.test]} {\n  finish_test\n  return\n}\n\nproc do_backcompat_test {rv bin1 bin2 script} {\n\n  forcedelete test.db\n\n  if {$bin1 != \"\"} { set ::bc_chan1 [launch_testfixture $bin1] }\n  set ::bc_chan2 [launch_testfixture $bin2]\n\n  if { $rv } {\n    proc code2 {tcl} { uplevel #0 $tcl }\n    if {$bin1 != \"\"} { proc code2 {tcl} { testfixture $::bc_chan1 $tcl } }\n    proc code1 {tcl} { testfixture $::bc_chan2 $tcl }\n  } else {\n    proc code1 {tcl} { uplevel #0 $tcl }\n    if {$bin1 != \"\"} { proc code1 {tcl} { testfixture $::bc_chan1 $tcl } }\n    proc code2 {tcl} { testfixture $::bc_chan2 $tcl }\n  }\n\n  proc sql1 sql { code1 [list db eval $sql] }\n  proc sql2 sql { code2 [list db eval $sql] }\n\n  code1 { sqlite3 db test.db }\n  code2 { sqlite3 db test.db }\n\n  foreach c {code1 code2} {\n    $c {\n      set v [split [db version] .]\n      if {[llength $v]==3} {lappend v 0}\n      set ::sqlite_libversion [format \\\n        \"%d%.2d%.2d%.2d\" [lindex $v 0] [lindex $v 1] [lindex $v 2] [lindex $v 3]\n      ]\n    }\n  }\n\n  uplevel $script\n\n  catch { code1 { db close } }\n  catch { code2 { db close } }\n  catch { close $::bc_chan2 }\n  catch { close $::bc_chan1 }\n\n\n}\n\narray set ::incompatible [list]\nproc do_allbackcompat_test {script} {\n\n  foreach bin $::BC(binaries) {\n    set nErr [set_test_counter errors]\n    foreach dir {0 1} {\n\n      set bintag $bin\n      regsub {.*testfixture\\.} $bintag {} bintag\n      set bintag [string map {\\.exe {}} $bintag]\n      if {$bintag == \"\"} {set bintag self}\n      set ::bcname \".$bintag.$dir.\"\n\n      rename do_test _do_test\n      proc do_test {nm sql res} {\n        set nm [regsub {\\.} $nm $::bcname]\n        uplevel [list _do_test $nm $sql $res]\n      }\n\n      do_backcompat_test $dir {} $bin $script\n\n      rename do_test {}\n      rename _do_test do_test\n    }\n    if { $nErr < [set_test_counter errors] } {\n      set ::incompatible([get_version $bin]) 1\n    }\n  }\n}\n\nproc read_file {zFile} {\n  set zData {}\n  if {[file exists $zFile]} {\n    set fd [open $zFile]\n    fconfigure $fd -translation binary -encoding binary\n\n    if {[file size $zFile]<=$::sqlite_pending_byte || $zFile != \"test.db\"} {\n      set zData [read $fd]\n    } else {\n      set zData [read $fd $::sqlite_pending_byte]\n      append zData [string repeat x 512]\n      seek $fd [expr $::sqlite_pending_byte+512] start\n      append zData [read $fd]\n    }\n\n    close $fd\n  }\n  return $zData\n}\nproc write_file {zFile zData} {\n  set fd [open $zFile w]\n  fconfigure $fd -translation binary -encoding binary\n  puts -nonewline $fd $zData\n  close $fd\n}\nproc read_file_system {} {\n  set ret [list]\n  foreach f {test.db test.db-journal test.db-wal} { lappend ret [read_file $f] }\n  set ret\n}\nproc write_file_system {data} {\n  foreach f {test.db test.db-journal test.db-wal} d $data { \n    if {[string length $d] == 0} {\n      forcedelete $f\n    } else {\n      write_file $f $d\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Actual tests begin here.\n#\n# This first block of tests checks to see that the same database and \n# journal files can be used by old and new versions. WAL and wal-index\n# files are tested separately below.\n#\ndo_allbackcompat_test {\n\n  # Test that database files are backwards compatible.\n  #\n  do_test backcompat-1.1.1 { sql1 { \n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES('abc', 'def');\n  } } {}\n  do_test backcompat-1.1.2 { sql2 { SELECT * FROM t1; } } {abc def}\n  do_test backcompat-1.1.3 { sql2 { INSERT INTO t1 VALUES('ghi', 'jkl'); } } {}\n  do_test backcompat-1.1.4 { sql1 { SELECT * FROM t1; } } {abc def ghi jkl}\n  do_test backcompat-1.1.5 { sql1 { PRAGMA integrity_check } } {ok}\n  do_test backcompat-1.1.6 { sql2 { PRAGMA integrity_check } } {ok}\n\n  # Test that one version can roll back a hot-journal file left in the\n  # file-system by the other version.\n  #\n  # Each test case is named \"backcompat-1.X...\", where X is either 0 or\n  # 1. If it is 0, then the current version creates a journal file that\n  # the old versions try to read. Otherwise, if X is 1, then the old version\n  # creates the journal file and we try to read it with the current version.\n  #\n  do_test backcompat-1.2.1 { sql1 {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(400), randomblob(400));\n      INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n    COMMIT;\n  } } {}\n  set cksum1 [sql1 {SELECT md5sum(a), md5sum(b) FROM t1}]\n  set cksum2 [sql2 {SELECT md5sum(a), md5sum(b) FROM t1}]\n  do_test backcompat-1.2.2 [list string compare $cksum1 $cksum2] 0\n\n  do_test backcompat-1.2.3 { sql1 {\n    BEGIN;\n      UPDATE t1 SET a = randomblob(500);\n  } } {}\n  set data [read_file_system]\n\n  do_test backcompat-1.2.4 { sql1 { COMMIT } } {}\n\n  set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]\n  do_test backcompat-1.2.5 [list set {} $same] 0\n\n  code1 { db close }\n  code2 { db close }\n  write_file_system $data\n  code1 { sqlite3 db test.db }\n  code2 { sqlite3 db test.db }\n\n  set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]\n  do_test backcompat-1.2.6 [list set {} $same] 1\n\n  do_test backcompat-1.2.7 { sql1 { PRAGMA integrity_check } } {ok}\n  do_test backcompat-1.2.8 { sql2 { PRAGMA integrity_check } } {ok}\n\n  do_test backcompat-2.1 {\n    sql1 {\n      CREATE TABLE t2(a UNIQUE, b PRIMARY KEY, c UNIQUE);\n      INSERT INTO t2 VALUES(1,9,5);\n      INSERT INTO t2 VALUES(5,5,1);\n      INSERT INTO t2 VALUES(9,1,9);\n      SELECT * FROM t2 ORDER BY a;\n    }\n  } {1 9 5 5 5 1 9 1 9}\n  do_test backcompat-2.2 {\n    sql2 {\n      SELECT * FROM sqlite_master WHERE rootpage=-1;\n      SELECT * FROM t2 ORDER BY a;\n    }\n  } {1 9 5 5 5 1 9 1 9}\n  do_test backcompat-2.3 {\n    sql1 {\n      SELECT * FROM t2 ORDER BY b;\n    }\n  } {9 1 9 5 5 1 1 9 5}\n  do_test backcompat-2.4 {\n    sql2 {\n      SELECT * FROM t2 ORDER BY b;\n    }\n  } {9 1 9 5 5 1 1 9 5}\n  do_test backcompat-2.5 {\n    sql1 {\n      SELECT * FROM t2 ORDER BY c;\n    }\n  } {5 5 1 1 9 5 9 1 9}\n  do_test backcompat-2.6 {\n    sql2 {\n      SELECT * FROM t2 ORDER BY c;\n    }\n  } {5 5 1 1 9 5 9 1 9}\n}\nforeach k [lsort [array names ::incompatible]] {\n  puts \"ERROR: Detected journal incompatibility with version $k\"\n}\nunset ::incompatible\n\n\n#-------------------------------------------------------------------------\n# Test that WAL and wal-index files may be shared between different \n# SQLite versions.\n#\ndo_allbackcompat_test {\n  if {[code1 {sqlite3 -version}] >= \"3.7.0\"\n   && [code1 {set ::sqlite_options(wal)}]\n   && [code2 {sqlite3 -version}] >= \"3.7.0\"\n   && [code2 {set ::sqlite_options(wal)}]\n  } {\n\n    do_test backcompat-2.1.1 { sql1 {\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n      INSERT INTO t1 VALUES('I', 1);\n      INSERT INTO t1 VALUES('II', 2);\n      INSERT INTO t1 VALUES('III', 3);\n      SELECT * FROM t1;\n    } } {wal I 1 II 2 III 3}\n    do_test backcompat-2.1.2 { sql2 {\n      SELECT * FROM t1;\n    } } {I 1 II 2 III 3}\n\n    set data [read_file_system]\n    code1 {db close}\n    code2 {db close}\n    write_file_system $data\n    code1 {sqlite3 db test.db}\n    code2 {sqlite3 db test.db}\n\n    # The WAL file now in the file-system was created by the [code1]\n    # process. Check that the [code2] process can recover the log.\n    #\n    do_test backcompat-2.1.3 { sql2 {\n      SELECT * FROM t1;\n    } } {I 1 II 2 III 3}\n    do_test backcompat-2.1.4 { sql1 {\n      SELECT * FROM t1;\n    } } {I 1 II 2 III 3}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that FTS3 tables may be read/written by different versions of \n# SQLite. \n#\nifcapable fts3 {\n  set contents {\n    CREATE VIRTUAL TABLE t1 USING fts3(a, b);\n  }\n  foreach {num doc} {\n    one \"jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf\"\n    two \"jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh\"\n    three \"wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw\"\n    four \"gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh\"\n    five \"zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm\"\n    six \"sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju\"\n    seven \"vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj\"\n    eight \"zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk\"\n    nine  \"zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk\"\n  } {\n    append contents \"INSERT INTO t1 VALUES('$num', '$doc');\"\n  }\n  do_allbackcompat_test {\n    if {[code1 {set ::sqlite_options(fts3)}]\n     && [code2 {set ::sqlite_options(fts3)}]\n    } {\n  \n      do_test backcompat-3.1 { sql1 $contents } {}\n  \n      foreach {n q} {\n        1    \"SELECT * FROM t1 ORDER BY a, b\"\n        2    \"SELECT rowid FROM t1 WHERE a MATCH 'five'\"\n        3    \"SELECT * FROM t1 WHERE a MATCH 'five'\"\n        4    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'\"\n        5    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'\"\n      } {\n        do_test backcompat-3.2 [list sql1 $q] [sql2 $q]\n      }\n  \n      do_test backcompat-3.3 { sql1 {\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n        INSERT INTO t1 SELECT * FROM t1;\n      } } {}\n  \n      foreach {n q} {\n        1    \"SELECT * FROM t1 ORDER BY a, b\"\n        2    \"SELECT rowid FROM t1 WHERE a MATCH 'five'\"\n        3    \"SELECT * FROM t1 WHERE a MATCH 'five'\"\n        4    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'\"\n        5    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'\"\n      } {\n        do_test backcompat-3.4 [list sql1 $q] [sql2 $q]\n      }\n  \n      set alphabet \"a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4\"\n      for {set i 0} {$i < 900} {incr i} {\n        set term \"[lindex $alphabet [expr $i/30]][lindex $alphabet [expr $i%30]] \"\n        sql1 \"INSERT INTO t1 VALUES($i, '[string repeat $term 14]')\"\n      }\n  \n      foreach {n q} {\n        1    \"SELECT * FROM t1 ORDER BY a, b\"\n        2    \"SELECT rowid FROM t1 WHERE a MATCH 'five'\"\n        3    \"SELECT * FROM t1 WHERE a MATCH 'five'\"\n        4    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'\"\n        5    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'\"\n  \n        6    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'\"\n        7    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'\"\n        8    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'\"\n      } {\n        do_test backcompat-3.5 [list sql1 $q] [sql2 $q]\n      }\n  \n      do_test backcompat-3.6 { \n        sql1 \"SELECT optimize(t1) FROM t1 LIMIT 1\" \n      } {{Index optimized}}\n  \n      foreach {n q} {\n        1    \"SELECT * FROM t1 ORDER BY a, b\"\n        2    \"SELECT rowid FROM t1 WHERE a MATCH 'five'\"\n        3    \"SELECT * FROM t1 WHERE a MATCH 'five'\"\n        4    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'jk'\"\n        5    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'tug* OR eight'\"\n  \n        6    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'aa'\"\n        7    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH '44'\"\n        8    \"SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'a*'\"\n      } {\n        do_test backcompat-3.7 [list sql1 $q] [sql2 $q]\n      }\n\n      # Now test that an incremental merge can be started by one version\n      # and finished by another. And that the integrity-check still \n      # passes.\n      do_test backcompat-3.8 {\n        sql1 { \n          DROP TABLE IF EXISTS t1;\n          DROP TABLE IF EXISTS t2;\n          CREATE TABLE t1(docid, words);\n          CREATE VIRTUAL TABLE t2 USING fts3(words);\n        }\n        code1 [list source $testdir/genesis.tcl]\n        code1 { fts_kjv_genesis }\n        sql1 {\n          INSERT INTO t2 SELECT words FROM t1;\n          INSERT INTO t2 SELECT words FROM t1;\n          INSERT INTO t2 SELECT words FROM t1;\n          INSERT INTO t2 SELECT words FROM t1;\n          INSERT INTO t2 SELECT words FROM t1;\n          INSERT INTO t2 SELECT words FROM t1;\n          SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level;\n        }\n      } {0 {0 1 2 3 4 5}}\n\n      if {[code1 { set ::sqlite_libversion }] >=3071200 \n       && [code2 { set ::sqlite_libversion }] >=3071200 \n      } {\n        if {[code1 { set ::sqlite_libversion }]<3120000} {\n          set res {0 {0 1} 1 0}\n        } else {\n          set res {1 0}\n        }\n\n        do_test backcompat-3.9 {\n          sql1 { INSERT INTO t2(t2) VALUES('merge=100,4'); }\n          sql2 { INSERT INTO t2(t2) VALUES('merge=100,4'); }\n          sql1 { INSERT INTO t2(t2) VALUES('merge=100,4'); }\n          sql2 { INSERT INTO t2(t2) VALUES('merge=2500,4'); }\n          sql2 {\n            SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level;\n          }\n        } $res\n\n        do_test backcompat-3.10 {\n          sql1 { INSERT INTO t2(t2) VALUES('integrity-check') }\n          sql2 { INSERT INTO t2(t2) VALUES('integrity-check') }\n        } {}\n      }\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that Rtree tables may be read/written by different versions of \n# SQLite. \n#\nifcapable rtree {\n  set contents {\n    CREATE VIRTUAL TABLE t1 USING rtree(id, x1, x2, y1, y2);\n  }\n  foreach {id x1 x2 y1 y2} {\n    1    -47.64 43.87    33.86 34.42        2    -21.51 17.32    2.05 31.04\n    3    -43.67 -38.33    -19.79 3.43       4    32.41 35.16    9.12 19.82\n    5    33.28 34.87    14.78 28.26         6    49.31 116.59    -9.87 75.09\n    7    -14.93 34.51    -17.64 64.09       8    -43.05 23.43    -1.19 69.44\n    9    44.79 133.56    28.09 80.30        10    -2.66 81.47    -41.38 -10.46\n    11    -42.89 -3.54    15.76 71.63       12    -3.50 84.96    -11.64 64.95\n    13    -45.69 26.25    11.14 55.06       14    -44.09 11.23    17.52 44.45\n    15    36.23 133.49    -19.38 53.67      16    -17.89 81.54    14.64 50.61\n    17    -41.97 -24.04    -39.43 28.95     18    -5.85 7.76    -6.38 47.02\n    19    18.82 27.10    42.82 100.09       20    39.17 113.45    26.14 73.47\n    21    22.31 103.17    49.92 106.05      22    -43.06 40.38    -1.75 76.08\n    23    2.43 57.27    -14.19 -3.83        24    -47.57 -4.35    8.93 100.06\n    25    -37.47 49.14    -29.11 8.81       26    -7.86 75.72    49.34 107.42\n    27    1.53 45.49    20.36 49.74         28    -48.48 32.54    28.81 54.45\n    29    2.67 39.77    -4.05 13.67         30    4.11 62.88    -47.44 -5.72\n    31    -21.47 51.75    37.25 116.09      32    45.59 111.37    -6.43 43.64\n    33    35.23 48.29    23.54 113.33       34    16.61 68.35    -14.69 65.97\n    35    13.98 16.60    48.66 102.87       36    19.74 23.84    31.15 77.27\n    37    -27.61 24.43    7.96 94.91        38    -34.77 12.05    -22.60 -6.29\n    39    -25.83 8.71    -13.48 -12.53      40    -17.11 -1.01    18.06 67.89\n    41    14.13 71.72    -3.78 39.25        42    23.75 76.00    -16.30 8.23\n    43    -39.15 28.63    38.12 125.88      44    48.62 86.09    36.49 102.95\n    45    -31.39 -21.98    2.52 89.78       46    5.65 56.04    15.94 89.10\n    47    18.28 95.81    46.46 143.08       48    30.93 102.82    -20.08 37.36\n    49    -20.78 -3.48    -5.58 35.46       50    49.85 90.58    -24.48 46.29\n  } {\n  if {$x1 >= $x2 || $y1 >= $y2} { error \"$x1 $x2 $y1 $y2\" }\n    append contents \"INSERT INTO t1 VALUES($id, $x1, $x2, $y1, $y2);\"\n  }\n  set queries {\n    1    \"SELECT id FROM t1 WHERE x1>10 AND x2<44\"\n    2    \"SELECT id FROM t1 WHERE y1<100\"\n    3    \"SELECT id FROM t1 WHERE y1<100 AND x1>0\"\n    4    \"SELECT id FROM t1 WHERE y1>10 AND x1>0 AND x2<50 AND y2<550\"\n  }\n  do_allbackcompat_test {\n    if {[code1 {set ::sqlite_options(fts3)}]\n     && [code2 {set ::sqlite_options(fts3)}]\n    } {\n  \n      do_test backcompat-4.1 { sql1 $contents } {}\n  \n      foreach {n q} $::queries {\n        do_test backcompat-4.2.$n [list sql1 $q] [sql2 $q]\n      }\n  \n      do_test backcompat-4.3 { sql1 {\n        INSERT INTO t1 SELECT id+100, x1+10.0, x2+10.0, y1-10.0, y2-10.0 FROM t1;\n      } } {}\n  \n      foreach {n q} $::queries {\n        do_test backcompat-4.4.$n [list sql1 $q] [sql2 $q]\n      }\n  \n      do_test backcompat-4.5 { sql2 {\n        INSERT INTO t1 SELECT id+200, x1+20.0, x2+20.0, y1-20.0, y2-20.0 FROM t1;\n      } } {}\n  \n      foreach {n q} $::queries {\n        do_test backcompat-4.6.$n [list sql1 $q] [sql2 $q]\n      }\n  \n    }\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup.test",
    "content": "# 2009 January 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite3_backup_XXX API.\n#\n# $Id: backup.test,v 1.11 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_not_use_codec\n\n#---------------------------------------------------------------------\n# Test organization:\n#\n# backup-1.*: Warm-body tests.\n#\n# backup-2.*: Test backup under various conditions. To and from in-memory\n#             databases. To and from empty/populated databases. etc.\n#\n# backup-3.*: Verify that the locking-page (pending byte page) is handled.\n#\n# backup-4.*: Test various error conditions.\n#\n# backup-5.*: Test the source database being modified during a backup.\n#\n# backup-6.*: Test the backup_remaining() and backup_pagecount() APIs.\n#\n# backup-7.*: Test SQLITE_BUSY and SQLITE_LOCKED errors.\n#\n# backup-8.*: Test multiple simultaneous backup operations.\n#\n# backup-9.*: Test that passing a negative argument to backup_step() is\n#             interpreted as \"copy the whole file\".\n# \n# backup-10.*: Test writing the source database mid backup.\n#\n\nproc data_checksum {db file} { $db one \"SELECT md5sum(a, b) FROM ${file}.t1\" }\nproc test_contents {name db1 file1 db2 file2} {\n  $db2 eval {select * from sqlite_master}\n  $db1 eval {select * from sqlite_master}\n  set checksum [data_checksum $db2 $file2]\n  uplevel [list do_test $name [list data_checksum $db1 $file1] $checksum]\n}\n\ndo_test backup-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 VALUES(2, randstr(1000,1000));\n    INSERT INTO t1 VALUES(3, randstr(1000,1000));\n    INSERT INTO t1 VALUES(4, randstr(1000,1000));\n    INSERT INTO t1 VALUES(5, randstr(1000,1000));\n    COMMIT;\n  }\n} {}\n\n# Sanity check to verify that the [test_contents] proc works.\n#\ntest_contents backup-1.2 db main db main\n\n# Check that it is possible to create and finish backup operations.\n#\ndo_test backup-1.3.1 {\n  delete_file test2.db\n  sqlite3 db2 test2.db\n  sqlite3_backup B db2 main db main\n} {B}\ndo_test backup-1.3.2 {\n  B finish\n} {SQLITE_OK}\ndo_test backup-1.3.3 {\n  info commands B\n} {}\n\n# Simplest backup operation. Backup test.db to test2.db. test2.db is \n# initially empty. test.db uses the default page size.\n# \ndo_test backup-1.4.1 {\n  sqlite3_backup B db2 main db main\n} {B}\ndo_test backup-1.4.2 {\n  B step 200\n} {SQLITE_DONE}\ndo_test backup-1.4.3 {\n  B finish\n} {SQLITE_OK}\ndo_test backup-1.4.4 {\n  info commands B\n} {}\ntest_contents backup-1.4.5 db2 main db main\ndb close\ndb2 close\n#\n# End of backup-1.* tests.\n#---------------------------------------------------------------------\n\n\n#---------------------------------------------------------------------\n# The following tests, backup-2.*, are based on the following procedure:\n#\n#   1) Populate the source database.\n#   2) Populate the destination database.\n#   3) Run the backup to completion. (backup-2.*.1)\n#   4) Integrity check the destination db. (backup-2.*.2)\n#   5) Check that the contents of the destination db is the same as that\n#      of the source db. (backup-2.*.3)\n# \n# The test is run with all possible combinations of the following\n# input parameters, except that if the destination is an in-memory\n# database, the only page size tested is 1024 bytes (the same as the\n# source page-size).\n#\n#   * Source database is an in-memory database, OR\n#   * Source database is a file-backed database.\n#\n#   * Target database is an in-memory database, OR\n#   * Target database is a file-backed database.\n#\n#   * Destination database is a main file, OR\n#   * Destination database is an attached file, OR\n#   * Destination database is a temp database.\n#\n#   * Target database is empty (zero bytes), OR\n#   * Target database is larger than the source, OR\n#   * Target database is smaller than the source.\n#\n#   * Target database page-size is the same as the source, OR\n#   * Target database page-size is larger than the source, OR\n#   * Target database page-size is smaller than the source.\n#\n#   * Each call to step copies a single page, OR\n#   * A single call to step copies the entire source database.\n#\nset iTest 1\nforeach zSrcFile {test.db :memory:} {\nforeach zDestFile {test2.db :memory:} {\nforeach zOpenScript [list {\n  sqlite3 db $zSrcFile\n  sqlite3 db2 $zSrcFile\n  db2 eval \"ATTACH '$zDestFile' AS bak\"\n  set db_dest db2\n  set file_dest bak\n} {\n  sqlite3 db $zSrcFile\n  sqlite3 db2 $zDestFile\n  set db_dest db2\n  set file_dest main\n} {\n  sqlite3 db $zSrcFile\n  sqlite3 db2 $zDestFile\n  set db_dest db2\n  set file_dest temp\n}] {\nforeach rows_dest {0 3 10} {\nforeach pgsz_dest {512 1024 2048 4096} {\nforeach nPagePerStep {1 200} {\n\n  # Open the databases.\n  catch { delete_file test.db }\n  catch { delete_file test2.db }\n  eval $zOpenScript\n\n  # Set to true if copying to an in-memory destination. Copying to an \n  # in-memory destination is only possible if the initial destination\n  # page size is the same as the source page size (in this case 1024 bytes).\n  #\n  set isMemDest [expr { $zDestFile eq \":memory:\" || $file_dest eq \"temp\" }]\n\n  if 0 {\n    puts -nonewline \"Test $iTest: src=$zSrcFile dest=$zDestFile\"\n    puts -nonewline \" (as $db_dest.$file_dest)\"\n    puts -nonewline \" rows_dest=$rows_dest pgsz_dest=$pgsz_dest\"\n    puts \"\"\n  }\n\n  if { $isMemDest==0 || $pgsz_dest==1024 || $rows_dest==0 } {\n\n    # Set up the content of the source database.\n    execsql {\n      PRAGMA page_size = 1024;\n      BEGIN;\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n      INSERT INTO t1 VALUES(1, randstr(1000,1000));\n      INSERT INTO t1 VALUES(2, randstr(1000,1000));\n      INSERT INTO t1 VALUES(3, randstr(1000,1000));\n      INSERT INTO t1 VALUES(4, randstr(1000,1000));\n      INSERT INTO t1 VALUES(5, randstr(1000,1000));\n      COMMIT;\n    }\n    \n    \n\n    # Set up the content of the target database.\n    execsql \"PRAGMA ${file_dest}.page_size = ${pgsz_dest}\" $db_dest\n    if {$rows_dest != 0} {\n      execsql \"\n        BEGIN; \n        CREATE TABLE ${file_dest}.t1(a, b);\n        CREATE INDEX ${file_dest}.i1 ON t1(a, b);\n      \" $db_dest\n      for {set ii 0} {$ii < $rows_dest} {incr ii} {\n        execsql \"\n          INSERT INTO ${file_dest}.t1 VALUES(1, randstr(1000,1000))\n        \" $db_dest\n      }\n      execsql COMMIT $db_dest\n    }\n  \n    # Backup the source database.\n    do_test backup-2.$iTest.1 {\n      sqlite3_backup B $db_dest $file_dest db main\n      while {[B step $nPagePerStep]==\"SQLITE_OK\"} {}\n      B finish\n    } {SQLITE_OK}\n    \n    # Run integrity check on the backup.\n    do_test backup-2.$iTest.2 {\n      execsql \"PRAGMA ${file_dest}.integrity_check\" $db_dest\n    } {ok}\n  \n    test_contents backup-2.$iTest.3 db main $db_dest $file_dest\n  \n  }\n\n  db close\n  catch {db2 close}\n  incr iTest\n\n} } } } } }\n#\n# End of backup-2.* tests.\n#---------------------------------------------------------------------\n\n#---------------------------------------------------------------------\n# These tests, backup-3.*, ensure that nothing goes wrong if either \n# the source or destination database are large enough to include the\n# the locking-page (the page that contains the range of bytes that\n# the locks are applied to). These tests assume that the pending\n# byte is at offset 0x00010000 (64KB offset), as set by tester.tcl, \n# not at the 1GB offset as it usually is.\n#\n# The test procedure is as follows (same procedure as used for \n# the backup-2.* tests):\n#\n#   1) Populate the source database.\n#   2) Populate the destination database.\n#   3) Run the backup to completion. (backup-3.*.1)\n#   4) Integrity check the destination db. (backup-3.*.2)\n#   5) Check that the contents of the destination db is the same as that\n#      of the source db. (backup-3.*.3)\n#\n# The test procedure is run with the following parameters varied: \n#\n#   * Source database includes pending-byte page.\n#   * Source database does not include pending-byte page.\n#\n#   * Target database includes pending-byte page.\n#   * Target database does not include pending-byte page.\n#\n#   * Target database page-size is the same as the source, OR\n#   * Target database page-size is larger than the source, OR\n#   * Target database page-size is smaller than the source.\n#\nset iTest 1\nforeach nSrcPg {10 64 65 66 100} {\nforeach nDestRow {10 100} {\nforeach nDestPgsz {512 1024 2048 4096} {\n\n  catch { delete_file test.db }\n  catch { delete_file test2.db }\n  sqlite3 db test.db\n  sqlite3 db2 test2.db\n\n  # Set up the content of the two databases.\n  #\n  execsql { PRAGMA page_size = 1024 }\n  execsql \"PRAGMA page_size = $nDestPgsz\" db2\n  foreach db {db db2} {\n    execsql {\n      BEGIN; \n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n      COMMIT;\n    } $db\n  }\n  while {[file size test.db]/1024 < $nSrcPg} {\n    execsql { INSERT INTO t1 VALUES($ii, randstr(200,200)) }\n  }\n\n  for {set ii 0} {$ii < $nDestRow} {incr ii} {\n    execsql { INSERT INTO t1 VALUES($ii, randstr(1000,1000)) } db2\n  }\n\n  # Backup the source database.\n  do_test backup-3.$iTest.1 {\n    sqlite3_backup B db main db2 main\n    while {[B step 10]==\"SQLITE_OK\"} {}\n    B finish\n  } {SQLITE_OK}\n    \n  # Run integrity check on the backup.\n  do_test backup-3.$iTest.2 {\n    execsql \"PRAGMA integrity_check\" db2\n  } {ok}\n  \n  test_contents backup-3.$iTest.3 db main db2 main\n\n  db close\n  db2 close\n  incr iTest\n}\n}\n}\n\n#--------------------------------------------------------------------\ndo_test backup-3.$iTest.1 {\n  catch { forcedelete test.db }\n  catch { forcedelete test2.db }\n  sqlite3 db test.db\n  set iTab 1\n\n  db eval { PRAGMA page_size = 512 }\n  while {[file size test.db] <= $::sqlite_pending_byte} {\n    db eval \"CREATE TABLE t${iTab}(a, b, c)\"\n    incr iTab\n  }\n\n  sqlite3 db2 test2.db\n  db2 eval { PRAGMA page_size = 4096 }\n  while {[file size test2.db] < $::sqlite_pending_byte} {\n    db2 eval \"CREATE TABLE t${iTab}(a, b, c)\"\n    incr iTab\n  }\n\n  sqlite3_backup B db2 main db main\n  B step -1\n} {SQLITE_DONE}\n\ndo_test backup-3.$iTest.2 {\n  B finish\n} {SQLITE_OK}\n\n#\n# End of backup-3.* tests.\n#---------------------------------------------------------------------\n\n\n#---------------------------------------------------------------------\n# The following tests, backup-4.*, test various error conditions:\n# \n# backup-4.1.*: Test invalid database names.\n#\n# backup-4.2.*: Test that the source database cannot be detached while \n#               a backup is in progress.\n#\n# backup-4.3.*: Test that the source database handle cannot be closed\n#               while a backup is in progress.\n#\n# backup-4.4.*: Test an attempt to specify the same handle for the\n#               source and destination databases.\n#\n# backup-4.5.*: Test that an in-memory destination with a different\n#               page-size to the source database is an error.\n#\nsqlite3 db test.db\nsqlite3 db2 test2.db\n\ndo_test backup-4.1.1 {\n  catch { sqlite3_backup B db aux db2 main }\n} {1}\ndo_test backup-4.1.2 {\n  sqlite3_errmsg db\n} {unknown database aux}\ndo_test backup-4.1.3 {\n  catch { sqlite3_backup B db main db2 aux }\n} {1}\ndo_test backup-4.1.4 {\n  sqlite3_errmsg db\n} {unknown database aux}\n\ndo_test backup-4.2.1 {\n  catch { forcedelete test3.db }\n  catch { forcedelete test4.db }\n  execsql { \n    ATTACH 'test3.db' AS aux1;\n    CREATE TABLE aux1.t1(a, b);\n  }\n  execsql { \n    ATTACH 'test4.db' AS aux2;\n    CREATE TABLE aux2.t2(a, b);\n  } db2\n  sqlite3_backup B db aux1 db2 aux2\n} {B}\ndo_test backup-4.2.2 {\n  catchsql { DETACH aux2 } db2\n} {1 {database aux2 is locked}}\ndo_test backup-4.2.3 {\n  B step 50\n} {SQLITE_DONE}\ndo_test backup-4.2.4 {\n  B finish\n} {SQLITE_OK}\n\ndo_test backup-4.3.1 {\n  sqlite3_backup B db aux1 db2 aux2\n} {B}\ndo_test backup-4.3.2 {\n  db2 cache flush\n  sqlite3_close db2\n} {SQLITE_BUSY}\ndo_test backup-4.3.3 {\n  sqlite3_errmsg db2\n} {unable to close due to unfinalized statements or unfinished backups}\ndo_test backup-4.3.4 {\n  B step 50\n} {SQLITE_DONE}\ndo_test backup-4.3.5 {\n  B finish\n} {SQLITE_OK}\n\ndo_test backup-4.4.1 {\n  set rc [catch {sqlite3_backup B db main db aux1}]\n  list $rc [sqlite3_errcode db] [sqlite3_errmsg db]\n} {1 SQLITE_ERROR {source and destination must be distinct}}\ndb close\ndb2 close\n\ndo_test backup-4.5.1 {\n  catch { forcedelete test.db }\n  sqlite3 db test.db\n  sqlite3 db2 :memory:\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  execsql {\n    PRAGMA page_size = 4096;\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES(3, 4);\n  } db2\n  sqlite3_backup B db2 main db main\n} {B}\ndo_test backup-4.5.2 {\n  B step 5000\n} {SQLITE_READONLY}\ndo_test backup-4.5.3 {\n  B finish\n} {SQLITE_READONLY}\n\ndb close\ndb2 close\n#\n# End of backup-4.* tests.\n#---------------------------------------------------------------------\n\n#---------------------------------------------------------------------\n# The following tests, backup-5.*, test that the backup works properly\n# when the source database is modified during the backup. Test cases\n# are organized as follows:\n#\n# backup-5.x.1.*: Nothing special. Modify the database mid-backup.\n#\n# backup-5.x.2.*: Modify the database mid-backup so that one or more\n#                 pages are written out due to cache stress. Then \n#                 rollback the transaction.\n#\n# backup-5.x.3.*: Database is vacuumed.\n#\n# backup-5.x.4.*: Database is vacuumed and the page-size modified.\n#\n# backup-5.x.5.*: Database is shrunk via incr-vacuum.\n#\n# Each test is run three times, in the following configurations:\n#\n#   1) Backing up file-to-file. The writer writes via an external pager.\n#   2) Backing up file-to-file. The writer writes via the same pager as\n#      is used by the backup operation.\n#   3) Backing up memory-to-file. \n#\nset iTest 0\nforcedelete bak.db-wal\nforeach {writer file} {db test.db db3 test.db db :memory:} {\n  incr iTest\n  catch { delete_file bak.db }\n  sqlite3 db2 bak.db\n  catch { delete_file $file }\n  sqlite3 db $file\n  sqlite3 db3 $file\n\n  do_test backup-5.$iTest.1.1 {\n    execsql {\n      BEGIN;\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n      INSERT INTO t1 VALUES(1, randstr(1000,1000));\n      INSERT INTO t1 VALUES(2, randstr(1000,1000));\n      INSERT INTO t1 VALUES(3, randstr(1000,1000));\n      INSERT INTO t1 VALUES(4, randstr(1000,1000));\n      INSERT INTO t1 VALUES(5, randstr(1000,1000));\n      COMMIT;\n    }\n    expr {[execsql {PRAGMA page_count}] > 10}\n  } {1}\n  do_test backup-5.$iTest.1.2 {\n    sqlite3_backup B db2 main db main\n    B step 5\n  } {SQLITE_OK}\n  do_test backup-5.$iTest.1.3 {\n    execsql { UPDATE t1 SET a = a + 1 } $writer\n    B step 50\n  } {SQLITE_DONE}\n  do_test backup-5.$iTest.1.4 {\n    B finish\n  } {SQLITE_OK} \n  integrity_check backup-5.$iTest.1.5 db2\n  test_contents backup-5.$iTest.1.6 db main db2 main\n\n  do_test backup-5.$iTest.2.1 {\n    execsql {\n      PRAGMA cache_size = 10;\n      BEGIN;\n      INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;\n      INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;\n      INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;\n      INSERT INTO t1 SELECT '', randstr(1000,1000) FROM t1;\n      COMMIT;\n    }\n  } {}\n  do_test backup-5.$iTest.2.2 {\n    sqlite3_backup B db2 main db main\n    B step 50\n  } {SQLITE_OK}\n  do_test backup-5.$iTest.2.3 {\n    execsql { \n      BEGIN;\n      UPDATE t1 SET a = a + 1;\n      ROLLBACK;\n    } $writer\n    B step 5000\n  } {SQLITE_DONE}\n  do_test backup-5.$iTest.2.4 {\n    B finish\n  } {SQLITE_OK} \n  integrity_check backup-5.$iTest.2.5 db2\n  test_contents backup-5.$iTest.2.6 db main db2 main\n\n  do_test backup-5.$iTest.3.1 {\n    execsql { UPDATE t1 SET b = randstr(1000,1000) }\n  } {}\n  do_test backup-5.$iTest.3.2 {\n    sqlite3_backup B db2 main db main\n    B step 50\n  } {SQLITE_OK}\n  do_test backup-5.$iTest.3.3 {\n    execsql { VACUUM } $writer\n    B step 5000\n  } {SQLITE_DONE}\n  do_test backup-5.$iTest.3.4 {\n    B finish\n  } {SQLITE_OK} \n  integrity_check backup-5.$iTest.3.5 db2\n  test_contents backup-5.$iTest.3.6 db main db2 main\n\n  do_test backup-5.$iTest.4.1 {\n    execsql { UPDATE t1 SET b = randstr(1000,1000) }\n  } {}\n  do_test backup-5.$iTest.4.2 {\n    sqlite3_backup B db2 main db main\n    B step 50\n  } {SQLITE_OK}\n  do_test backup-5.$iTest.4.3 {\n    execsql { \n      PRAGMA page_size = 2048;\n      VACUUM;\n    } $writer\n    B step 5000\n  } {SQLITE_DONE}\n  do_test backup-5.$iTest.4.4 {\n    B finish\n  } {SQLITE_OK} \n  integrity_check backup-5.$iTest.4.5 db2\n  test_contents backup-5.$iTest.4.6 db main db2 main\n\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n  catch { delete_file bak.db }\n  sqlite3 db2 bak.db\n  catch { delete_file $file }\n  sqlite3 db $file\n  sqlite3 db3 $file\n  do_test backup-5.$iTest.5.1 {\n    execsql {\n      PRAGMA auto_vacuum = incremental;\n      BEGIN;\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n      INSERT INTO t1 VALUES(1, randstr(1000,1000));\n      INSERT INTO t1 VALUES(2, randstr(1000,1000));\n      INSERT INTO t1 VALUES(3, randstr(1000,1000));\n      INSERT INTO t1 VALUES(4, randstr(1000,1000));\n      INSERT INTO t1 VALUES(5, randstr(1000,1000));\n      COMMIT;\n    }\n  } {}\n  do_test backup-5.$iTest.5.2 {\n    sqlite3_backup B db2 main db main\n    B step 8\n  } {SQLITE_OK}\n  do_test backup-5.$iTest.5.3 {\n    execsql { \n      DELETE FROM t1;\n      PRAGMA incremental_vacuum;\n    } $writer\n    B step 50\n  } {SQLITE_DONE}\n  do_test backup-5.$iTest.5.4 {\n    B finish\n  } {SQLITE_OK} \n  integrity_check backup-5.$iTest.5.5 db2\n  test_contents backup-5.$iTest.5.6 db main db2 main\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n}\n#\n# End of backup-5.* tests.\n#---------------------------------------------------------------------\n\n#---------------------------------------------------------------------\n# Test the sqlite3_backup_remaining() and backup_pagecount() APIs.\n#\ndo_test backup-6.1 {\n  catch { forcedelete test.db }\n  catch { forcedelete test2.db }\n  sqlite3 db test.db\n  sqlite3 db2 test2.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 VALUES(2, randstr(1000,1000));\n    INSERT INTO t1 VALUES(3, randstr(1000,1000));\n    INSERT INTO t1 VALUES(4, randstr(1000,1000));\n    INSERT INTO t1 VALUES(5, randstr(1000,1000));\n    COMMIT;\n  }\n} {}\ndo_test backup-6.2 {\n  set nTotal [expr {[file size test.db]/1024}]\n  sqlite3_backup B db2 main db main\n  B step 1\n} {SQLITE_OK}\ndo_test backup-6.3 {\n  B pagecount\n} $nTotal\ndo_test backup-6.4 {\n  B remaining\n} [expr $nTotal-1]\ndo_test backup-6.5 {\n  B step 5\n  list [B remaining] [B pagecount]\n} [list [expr $nTotal-6] $nTotal]\ndo_test backup-6.6 {\n  execsql { CREATE TABLE t2(a PRIMARY KEY, b) }\n  B step 1\n  list [B remaining] [B pagecount]\n} [list [expr $nTotal-5] [expr $nTotal+2]]\n\ndo_test backup-6.X {\n  B finish\n} {SQLITE_OK}\n\ncatch {db close}\ncatch {db2 close}\n\n#---------------------------------------------------------------------\n# Test cases backup-7.* test that SQLITE_BUSY and SQLITE_LOCKED errors\n# are returned correctly:\n#\n# backup-7.1.*: Source database is externally locked (return SQLITE_BUSY).\n#\n# backup-7.2.*: Attempt to step the backup process while a \n#               write-transaction is underway on the source pager (return\n#               SQLITE_LOCKED).\n#\n# backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY).\n#\ndo_test backup-7.0 {\n  catch { forcedelete test.db }\n  catch { forcedelete test2.db }\n  sqlite3 db2 test2.db\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1;\n  }\n} {}\n\ndo_test backup-7.1.1 {\n  sqlite3_backup B db2 main db main\n  B step 5\n} {SQLITE_OK}\ndo_test backup-7.1.2 {\n  sqlite3 db3 test.db\n  execsql { BEGIN EXCLUSIVE } db3\n  B step 5\n} {SQLITE_BUSY}\ndo_test backup-7.1.3 {\n  execsql { ROLLBACK } db3\n  B step 5\n} {SQLITE_OK}\ndo_test backup-7.2.1 {\n  execsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(1, 4);\n  }\n} {}\ndo_test backup-7.2.2 {\n  B step 5000\n} {SQLITE_BUSY}\ndo_test backup-7.2.3 {\n  execsql { ROLLBACK }\n  B step 5000\n} {SQLITE_DONE}\ndo_test backup-7.2.4 {\n  B finish\n} {SQLITE_OK}\ntest_contents backup-7.2.5 db main db2 main\nintegrity_check backup-7.3.6 db2\n\ndo_test backup-7.3.1 {\n  db2 close\n  db3 close\n  forcedelete test2.db\n  sqlite3 db2 test2.db\n  sqlite3 db3 test2.db\n\n  sqlite3_backup B db2 main db main\n  execsql { BEGIN ; CREATE TABLE t2(a, b); } db3\n\n  B step 5\n} {SQLITE_BUSY}\ndo_test backup-7.3.2 {\n  execsql { COMMIT } db3\n  B step 5000\n} {SQLITE_DONE}\ndo_test backup-7.3.3 {\n  B finish\n} {SQLITE_OK}\ntest_contents backup-7.3.4 db main db2 main\nintegrity_check backup-7.3.5 db2\ncatch { db2 close }\ncatch { db3 close }\n\n#-----------------------------------------------------------------------\n# The following tests, backup-8.*, test attaching multiple backup\n# processes to the same source database. Also, reading from the source\n# database while a read transaction is active.\n#\n# These tests reuse the database \"test.db\" left over from backup-7.*.\n#\ndo_test backup-8.1 {\n  catch { forcedelete test2.db }\n  catch { forcedelete test3.db }\n  sqlite3 db2 test2.db\n  sqlite3 db3 test3.db\n\n  sqlite3_backup B2 db2 main db main\n  sqlite3_backup B3 db3 main db main\n  list [B2 finish] [B3 finish]\n} {SQLITE_OK SQLITE_OK}\ndo_test backup-8.2 {\n  sqlite3_backup B3 db3 main db main\n  sqlite3_backup B2 db2 main db main\n  list [B2 finish] [B3 finish]\n} {SQLITE_OK SQLITE_OK}\ndo_test backup-8.3 {\n  sqlite3_backup B2 db2 main db main\n  sqlite3_backup B3 db3 main db main\n  B2 step 5\n} {SQLITE_OK}\ndo_test backup-8.4 {\n  execsql {\n    BEGIN;\n    SELECT * FROM sqlite_master;\n  }\n  B3 step 5\n} {SQLITE_OK}\ndo_test backup-8.5 {\n  list [B3 step 5000] [B3 finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test backup-8.6 {\n  list [B2 step 5000] [B2 finish]\n} {SQLITE_DONE SQLITE_OK}\ntest_contents backup-8.7 db main db2 main\ntest_contents backup-8.8 db main db3 main\ndo_test backup-8.9 {\n  execsql { PRAGMA lock_status }\n} {main shared temp closed}\ndo_test backup-8.10 {\n  execsql COMMIT\n} {}\ncatch { db2 close }\ncatch { db3 close }\n\n#-----------------------------------------------------------------------\n# The following tests, backup-9.*, test that:\n# \n#   * Passing 0 as an argument to sqlite3_backup_step() means no pages\n#     are backed up (backup-9.1.*), and \n#   * Passing a negative value as an argument to sqlite3_backup_step() means \n#     all pages are backed up (backup-9.2.*).\n#\n# These tests reuse the database \"test.db\" left over from backup-7.*.\n# \ndo_test backup-9.1.1 {\n  sqlite3 db2 test2.db\n  sqlite3_backup B db2 main db main\n  B step 1\n} {SQLITE_OK}\ndo_test backup-9.1.2 {\n  set nRemaining [B remaining]\n  expr {$nRemaining>100}\n} {1}\ndo_test backup-9.1.3 {\n  B step 0\n} {SQLITE_OK}\ndo_test backup-9.1.4 {\n  B remaining\n} $nRemaining\n\ndo_test backup-9.2.1 {\n  B step -1\n} {SQLITE_DONE}\ndo_test backup-9.2.2 {\n  B remaining\n} {0}\ndo_test backup-9.2.3 {\n  B finish\n} {SQLITE_OK}\ncatch {db2 close}\n\nifcapable memorymanage {\n  db close\n  forcedelete test.db\n  forcedelete bak.db\n\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  sqlite3 db3 bak.db\n\n  do_test backup-10.1.1 {\n    execsql {\n      BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, randstr(1000,1000));\n      INSERT INTO t1 VALUES(2, randstr(1000,1000));\n      INSERT INTO t1 VALUES(3, randstr(1000,1000));\n      INSERT INTO t1 VALUES(4, randstr(1000,1000));\n      INSERT INTO t1 VALUES(5, randstr(1000,1000));\n      CREATE INDEX i1 ON t1(a, b);\n      COMMIT;\n    }\n  } {}\n  do_test backup-10.1.2 {\n    sqlite3_backup B db3 main db2 main\n    B step 5\n  } {SQLITE_OK}\n  do_test backup-10.1.3 {\n    execsql {\n      UPDATE t1 SET b = randstr(500,500);\n    }\n  } {}\n  sqlite3_release_memory [expr 1024*1024]\n  do_test backup-10.1.3 {\n    B step 50\n  } {SQLITE_DONE}\n  do_test backup-10.1.4 {\n    B finish\n  } {SQLITE_OK}\n  do_test backup-10.1.5 {\n    execsql { PRAGMA integrity_check } db3\n  } {ok}\n\n  db2 close\n  db3 close\n}\n\n\n#-----------------------------------------------------------------------\n# Test that if the database is written to via the same database handle being\n# used as the source by a backup operation:\n#\n#   10.1.*: If the db is in-memory, the backup is restarted.\n#   10.2.*: If the db is a file, the backup is not restarted.\n#\ndb close\nforcedelete test.db test.db-journal\nforeach {tn file rc} {\n  1 test.db  SQLITE_DONE\n  2 :memory: SQLITE_OK\n} {\n  do_test backup-10.$tn.1 {\n    sqlite3 db $file\n    execsql { \n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);\n      BEGIN;\n        INSERT INTO t1 VALUES(NULL, randomblob(200));\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n        INSERT INTO t1 SELECT NULL, randomblob(200) FROM t1;\n      COMMIT;\n      SELECT count(*) FROM t1;\n    }\n  } {256}\n\n  do_test backup-10.$tn.2 {\n    set pgs [execsql {pragma page_count}]\n    expr {$pgs > 50 && $pgs < 75}\n  } {1}\n\n  do_test backup-10.$tn.3 {\n    forcedelete bak.db bak.db-journal\n    sqlite3 db2 bak.db\n    sqlite3_backup B db2 main db main\n    B step 50\n  } {SQLITE_OK}\n\n  do_test backup-10.$tn.4 {\n    execsql { UPDATE t1 SET b = randomblob(200) WHERE a IN (1, 250) }\n  } {}\n\n  do_test backup-10.$tn.5 {\n    B step 50\n  } $rc\n\n  do_test backup-10.$tn.6 {\n    B finish\n  } {SQLITE_OK}\n\n  db2 close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup2.test",
    "content": "# 2009 February 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the \"backup\" and \"restore\" methods\n# of the TCL interface - methods which are based on the\n# sqlite3_backup_XXX API.\n#\n# $Id: backup2.test,v 1.4 2009/04/07 14:14:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_not_use_codec\n\nifcapable !trigger||!view { finish_test ; return }\n\n# Fill a database with test data.\n#\ndo_test backup2-1 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randstr(8000,8000));\n    INSERT INTO t1 VALUES(randstr(8000,8000));\n    INSERT INTO t1 VALUES(randstr(8000,8000));\n    INSERT INTO t1 VALUES(randstr(8000,8000));\n    INSERT INTO t1 VALUES(randstr(8000,8000));\n    CREATE VIEW v1 AS SELECT substr(x,10,10) FROM t1;\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 VALUES(1,2);\n    INSERT INTO t2 VALUES(2,4);\n    INSERT INTO t2 SELECT a+2, (a+2)*2 FROM t2;\n    INSERT INTO t2 SELECT a+4, (a+4)*2 FROM t2;\n    INSERT INTO t2 SELECT a+8, (a+8)*2 FROM t2;\n    INSERT INTO t2 SELECT a+16, (a+16)*2 FROM t2;\n    INSERT INTO t2 SELECT a+32, (a+32)*2 FROM t2;\n    INSERT INTO t2 SELECT a+64, (a+64)*2 FROM t2;\n    INSERT INTO t2 SELECT a+128, (a+128)*2 FROM t2;\n    CREATE INDEX t2i1 ON t2(a,b);\n    CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN\n      SELECT 'hello';\n    END;\n    ANALYZE;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\n# Remember a check-sum on the database file.\n#\nunset -nocomplain cksum\nset cksum [dbcksum db main]\n\n# Make a backup of the test data.  Verify that the backup copy\n# is identical to the original.\n#\ndo_test backup2-2 {\n  forcedelete bu1.db\n  db backup bu1.db\n  sqlite3 db2 bu1.db\n  dbcksum db2 main\n} $cksum\n\n# Delete the original.  Restore from backup.  Verify the content is\n# unchanged.\n#\ndo_test backup2-3.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db2 eval {BEGIN EXCLUSIVE}\n  set rc [catch {db restore bu1.db} res]\n  lappend rc $res\n  db2 eval {ROLLBACK}\n  set rc\n} {1 {restore failed: source database busy}}\ndo_test backup2-3.2 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db restore bu1.db\n  dbcksum db main\n} $cksum\n\n# Use alternative databases - other than \"main\".\n#\ndo_test backup2-4 {\n  db restore temp bu1.db\n  dbcksum db temp\n} $cksum\ndo_test backup2-5 {\n  db2 close\n  forcedelete bu1.db bu2.db\n  db backup temp bu2.db\n  sqlite3 db2 bu2.db\n  dbcksum db2 main\n} $cksum\n\n# Try to backup to a readonly file.\n#\ndo_test backup2-6 {\n  db2 close\n  catch {file attributes bu2.db -permissions r--------}\n  catch {file attributes bu2.db -readonly 1}\n  set rc [catch {db backup temp bu2.db} res]\n  lappend rc $res\n} {1 {backup failed: attempt to write a readonly database}}\n\n# Try to backup to something that is not a database file.\n#\ndo_test backup2-7 {\n  catch {file attributes bu2.db -readonly 0}\n  catch {file attributes bu2.db -permissions rw-------}\n  set out [open bu2.db w]\n  puts $out \"This is not a valid database file\"\n  close $out\n  set rc [catch {db backup temp bu2.db} res]\n  lappend rc $res\n} {1 {backup failed: file is not a database}}\n\n# Try to backup database that does not exist\n#\ndo_test backup2-8 {\n  forcedelete bu1.db\n  set rc [catch {db backup aux1 bu1.db} res]\n  lappend rc $res\n} {1 {backup failed: unknown database aux1}}\n\n# Invalid syntax on the backup method\n#\ndo_test backup2-9 {\n  set rc [catch {db backup} res]\n  lappend rc $res\n} {1 {wrong # args: should be \"db backup ?DATABASE? FILENAME\"}}\n\n# Try to restore from an unreadable file.\n#\nif {$tcl_platform(platform)==\"windows\"} {\n  set msg {cannot open source database: unable to open database file}\n} elseif {[string match *BSD $tcl_platform(os)]} {\n  set msg {restore failed: file is not a database}\n} else {\n  set msg {cannot open source database: disk I/O error}\n}\ndo_test backup2-10 {\n  forcedelete bu3.db\n  file mkdir bu3.db\n  set rc [catch {db restore temp bu3.db} res]\n  lappend rc $res\n} [list 1 $msg]\n\n# Try to restore from something that is not a database file.\n#\ndo_test backup2-11 {\n  set rc [catch {db restore temp bu2.db} res]\n  lappend rc $res\n} {1 {restore failed: file is not a database}}\n\n# Try to restore a database that does not exist\n#\ndo_test backup2-12 {\n  set rc [catch {db restore aux1 bu2.db} res]\n  lappend rc $res\n} {1 {restore failed: unknown database aux1}}\ndo_test backup2-13 {\n  forcedelete bu4.db\n  set rc [catch {db restore bu4.db} res]\n  lappend rc $res\n} {1 {cannot open source database: unable to open database file}}\n\n# Invalid syntax on the restore method\n#\ndo_test backup2-14 {\n  set rc [catch {db restore} res]\n  lappend rc $res\n} {1 {wrong # args: should be \"db restore ?DATABASE? FILENAME\"}}\n \nforcedelete bu1.db bu2.db bu3.db bu4.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup4.test",
    "content": "# 2012 October 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file verify that if an empty database (zero bytes in \n# size) is used as the source of a backup operation, the final destination\n# database is one page in size.\n#\n# The destination must consist of at least one page as truncating a \n# database file to zero bytes is equivalent to resetting the database\n# schema cookie and change counter. Doing that could cause other clients\n# to become confused and continue using out-of-date cache data.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix backup4\n\n# The codec logic does not work for zero-length database files.  A database\n# file must contain at least one page in order to be recognized as an\n# encrypted database.\ndo_not_use_codec\n\n#-------------------------------------------------------------------------\n# At one point this test was failing because [db] was using an out of\n# date schema in test case 1.2.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y, UNIQUE(x, y));\n  INSERT INTO t1 VALUES('one', 'two');\n  SELECT * FROM t1 WHERE x='one';\n  PRAGMA integrity_check;\n} {one two ok}\n\ndo_test 1.1 {\n  sqlite3 db1 :memory:\n  db1 backup test.db\n  sqlite3 db1 test.db\n  db1 eval {\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES('one', 'two');\n  }\n  db1 close\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1 WHERE x='one';\n  PRAGMA integrity_check;\n} {one two ok}\n\ndb close\nforcedelete test.db\nforcedelete test.db2\nsqlite3 db test.db\n\n#-------------------------------------------------------------------------\n# Test that if the source is zero bytes, the destination database \n# consists of a single page only.\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n}\ndo_test 2.2 { file size test.db } [expr $AUTOVACUUM ? 4096 : 3072]\n\ndo_test 2.3 {\n  sqlite3 db1 test.db2\n  db1 backup test.db\n  db1 close\n  file size test.db\n} {1024}\n\ndo_test 2.4 { file size test.db2 } 0\n\ndb close\nforcedelete test.db\nforcedelete test.db2\nsqlite3 db test.db\n\n#-------------------------------------------------------------------------\n# Test that if the destination has a page-size larger than the implicit\n# page-size of the source, the final destination database still consists\n# of a single page.\n#\ndo_execsql_test 3.1 {\n  PRAGMA page_size = 4096;\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n}\ndo_test 3.2 { file size test.db } [expr $AUTOVACUUM ? 16384 : 12288]\n\ndo_test 3.3 {\n  sqlite3 db1 test.db2\n  db1 backup test.db\n  db1 close\n  file size test.db\n} {1024}\n\ndo_test 3.4 { file size test.db2 } 0\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup5.test",
    "content": "# 2014 November 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix backup5\n\nforcedelete test2.db\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  INSERT INTO t2 VALUES(1, 1);\n  INSERT INTO t2 VALUES(2, 2);\n  INSERT INTO t2 VALUES(3, 3);\n}\n\ndo_test 1.1 {\n  forcecopy test.db test.db2\n  db eval {\n    DROP TABLE t2;\n    INSERT INTO t1 VALUES(zeroblob(1000), zeroblob(1000));\n    INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));\n  }\n} {}\n\ndo_test 1.2 {\n  sqlite3 db2 test.db2\n  set stmt [sqlite3_prepare_v2 db2 \"SELECT * FROM t2\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_ROW}\n\ndo_test 1.3 {\n  list [catch { sqlite3_backup B db2 main db main } msg] $msg\n} {1 {sqlite3_backup_init() failed}}\n\ndo_test 1.4 {\n  sqlite3_errmsg db2\n} {destination database is in use}\n\ndo_test 1.5 {\n  sqlite3_reset $stmt\n  sqlite3_backup B db2 main db main\n  B step 200\n  B finish\n} {SQLITE_OK}\n\ndo_test 1.6 {\n  list [sqlite3_step $stmt] [sqlite3_finalize $stmt]\n} {SQLITE_ERROR SQLITE_ERROR}\n\ndo_test 1.7 {\n  sqlite3_errmsg db2\n} {no such table: t2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup_ioerr.test",
    "content": "# 2009 January 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the handling of IO errors by the\n# sqlite3_backup_XXX APIs.\n#\n# $Id: backup_ioerr.test,v 1.3 2009/04/10 18:41:01 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc data_checksum {db file} { \n  $db one \"SELECT md5sum(a, b) FROM ${file}.t1\" \n}\nproc test_contents {name db1 file1 db2 file2} {\n  $db2 eval {select * from sqlite_master}\n  $db1 eval {select * from sqlite_master}\n  set checksum [data_checksum $db2 $file2]\n  uplevel [list do_test $name [list data_checksum $db1 $file1] $checksum]\n}\n\n#--------------------------------------------------------------------\n# This proc creates a database of approximately 290 pages. Depending\n# on whether or not auto-vacuum is configured. Test cases backup_ioerr-1.*\n# verify nothing more than this assumption.\n#\nproc populate_database {db {xtra_large 0}} {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;\n    CREATE INDEX i1 ON t1(b);\n    COMMIT;\n  } $db\n  if {$xtra_large} {\n    execsql { INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1 } $db\n  }\n}\ndo_test backup_ioerr-1.1 {\n  populate_database db\n  set nPage [expr {[file size test.db] / 1024}]\n  expr {$nPage>130 && $nPage<160}\n} {1}\ndo_test backup_ioerr-1.2 {\n  expr {[file size test.db] > $sqlite_pending_byte}\n} {1}\ndo_test backup_ioerr-1.3 {\n  db close\n  forcedelete test.db\n} {}\n\n# Turn off IO error simulation.\n#\nproc clear_ioerr_simulation {} {\n  set ::sqlite_io_error_hit 0\n  set ::sqlite_io_error_hardhit 0\n  set ::sqlite_io_error_pending 0\n  set ::sqlite_io_error_persist 0\n}\n\n#--------------------------------------------------------------------\n# The following procedure runs with SQLite's IO error simulation \n# enabled.\n#\n#   1) Start with a reasonably sized database. One that includes the\n#      pending-byte (locking) page.\n#\n#   2) Open a backup process. Set the cache-size for the destination\n#      database to 10 pages only.\n#\n#   3) Step the backup process N times to partially backup the database\n#      file. If an IO error is reported, then the backup process is\n#      concluded with a call to backup_finish().\n#\n#      If an IO error occurs, verify that:\n#\n#      * the call to backup_step() returns an SQLITE_IOERR_XXX error code.\n#\n#      * after the failed call to backup_step() but before the call to\n#        backup_finish() the destination database handle error code and \n#        error message remain unchanged.\n#\n#      * the call to backup_finish() returns an SQLITE_IOERR_XXX error code.\n#\n#      * following the call to backup_finish(), the destination database\n#        handle has been populated with an error code and error message.\n#\n#   4) Write to the database via the source database connection. Check \n#      that:\n#\n#      * If an IO error occurs while writing the source database, the\n#        write operation should report an IO error. The backup should \n#        proceed as normal.\n#\n#      * If an IO error occurs while updating the backup, the write \n#        operation should proceed normally. The error should be reported\n#        from the next call to backup_step() (in step 5 of this test\n#        procedure).\n#\n#   5) Step the backup process to finish the backup. If an IO error is \n#      reported, then the backup process is concluded with a call to \n#      backup_finish().\n#\n#      Test that if an IO error occurs, or if one occurred while updating\n#      the backup database during step 4, then the conditions listed\n#      under step 3 are all true.\n#\n#   6) Finish the backup process.\n#\n#   * If the backup succeeds (backup_finish() returns SQLITE_OK), then\n#     the contents of the backup database should match that of the\n#     source database.\n#\n#   * If the backup fails (backup_finish() returns other than SQLITE_OK), \n#     then the contents of the backup database should be as they were \n#     before the operation was started.\n#\n# The following factors are varied:\n#\n#   * Destination database is initially larger than the source database, OR\n#   * Destination database is initially smaller than the source database.\n#\n#   * IO errors are transient, OR\n#   * IO errors are persistent.\n#\n#   * Destination page-size is smaller than the source.\n#   * Destination page-size is the same as the source.\n#   * Destination page-size is larger than the source.\n#\n\nset iTest 1\nforeach bPersist {0 1} {\nforeach iDestPagesize {512 1024 4096} {\nforeach zSetupBak [list \"\" {populate_database ddb 1}] {\n\n  incr iTest\n  set bStop 0\nfor {set iError 1} {$bStop == 0} {incr iError} {\n  # Disable IO error simulation.\n  clear_ioerr_simulation\n\n  catch { ddb close }\n  catch { sdb close }\n  catch { forcedelete test.db }\n  catch { forcedelete bak.db }\n\n  # Open the source and destination databases.\n  sqlite3 sdb test.db\n  sqlite3 ddb bak.db\n\n  # Step 1: Populate the source and destination databases.\n  populate_database sdb\n  ddb eval \"PRAGMA page_size = $iDestPagesize\"\n  ddb eval \"PRAGMA cache_size = 10\"\n  eval $zSetupBak\n\n  # Step 2: Open the backup process.\n  sqlite3_backup B ddb main sdb main\n\n  # Enable IO error simulation.\n  set ::sqlite_io_error_pending $iError\n  set ::sqlite_io_error_persist $bPersist\n\n  # Step 3: Partially backup the database. If an IO error occurs, check\n  # a few things then skip to the next iteration of the loop.\n  #\n  set rc [B step 100]\n  if {$::sqlite_io_error_hardhit} {\n\n    do_test backup_ioerr-$iTest.$iError.1 {\n      string match SQLITE_IOERR* $rc\n    } {1}\n    do_test backup_ioerr-$iTest.$iError.2 {\n      list [sqlite3_errcode ddb] [sqlite3_errmsg ddb]\n    } {SQLITE_OK {not an error}}\n\n    set rc [B finish]\n    do_test backup_ioerr-$iTest.$iError.3 {\n      string match SQLITE_IOERR* $rc\n    } {1}\n\n    do_test backup_ioerr-$iTest.$iError.4 {\n      sqlite3_errmsg ddb\n    } {disk I/O error}\n\n    clear_ioerr_simulation\n    sqlite3 ddb bak.db\n    integrity_check backup_ioerr-$iTest.$iError.5 ddb\n\n    continue\n  }\n\n  # No IO error was encountered during step 3. Check that backup_step()\n  # returned SQLITE_OK before proceding.\n  do_test backup_ioerr-$iTest.$iError.6 {\n    expr {$rc eq \"SQLITE_OK\"}\n  } {1}\n\n  # Step 4: Write to the source database.\n  set rc [catchsql { UPDATE t1 SET b = randstr(1000,1000) WHERE a < 50 } sdb]\n\n  if {[lindex $rc 0] && $::sqlite_io_error_persist==0} {\n    # The IO error occurred while updating the source database. In this\n    # case the backup should be able to continue.\n    set rc [B step 5000]\n    if { $rc != \"SQLITE_IOERR_UNLOCK\" } {\n      do_test backup_ioerr-$iTest.$iError.7 {\n        list [B step 5000] [B finish]\n      } {SQLITE_DONE SQLITE_OK}\n\n      clear_ioerr_simulation\n      test_contents backup_ioerr-$iTest.$iError.8 ddb main sdb main\n      integrity_check backup_ioerr-$iTest.$iError.9 ddb\n    } else {\n      do_test backup_ioerr-$iTest.$iError.10 {\n        B finish\n      } {SQLITE_IOERR_UNLOCK}\n    }\n\n    clear_ioerr_simulation\n    sqlite3 ddb bak.db\n    integrity_check backup_ioerr-$iTest.$iError.11 ddb\n\n    continue\n  }\n\n  # Step 5: Finish the backup operation. If an IO error occurs, check that\n  # it is reported correctly and skip to the next iteration of the loop.\n  #\n  set rc [B step 5000]\n  if {$rc != \"SQLITE_DONE\"} {\n    do_test backup_ioerr-$iTest.$iError.12 {\n      string match SQLITE_IOERR* $rc\n    } {1}\n    do_test backup_ioerr-$iTest.$iError.13 {\n      list [sqlite3_errcode ddb] [sqlite3_errmsg ddb]\n    } {SQLITE_OK {not an error}}\n\n    set rc [B finish]\n    do_test backup_ioerr-$iTest.$iError.14 {\n      string match SQLITE_IOERR* $rc\n    } {1}\n    do_test backup_ioerr-$iTest.$iError.15 {\n      sqlite3_errmsg ddb\n    } {disk I/O error}\n\n    clear_ioerr_simulation\n    sqlite3 ddb bak.db\n    integrity_check backup_ioerr-$iTest.$iError.16 ddb\n\n    continue\n  }\n\n  # The backup was successfully completed.\n  #\n  do_test backup_ioerr-$iTest.$iError.17 {\n    list [set rc] [B finish]\n  } {SQLITE_DONE SQLITE_OK}\n\n  clear_ioerr_simulation\n  sqlite3 sdb test.db\n  sqlite3 ddb bak.db\n\n  test_contents backup_ioerr-$iTest.$iError.18 ddb main sdb main\n  integrity_check backup_ioerr-$iTest.$iError.19 ddb\n\n  set bStop [expr $::sqlite_io_error_pending<=0]\n}}}}\n\ncatch { sdb close }\ncatch { ddb close }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/backup_malloc.test",
    "content": "# 2009 January 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the handling of OOM errors by the\n# sqlite3_backup_XXX APIs.\n#\n# $Id: backup_malloc.test,v 1.2 2009/02/04 22:46:47 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nsource $testdir/malloc_common.tcl\n\ndo_malloc_test backup_malloc-1 -tclprep {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;\n    INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1;\n    CREATE INDEX i1 ON t1(b);\n    COMMIT;\n  }\n  sqlite3 db2 test2.db\n  execsql { PRAGMA cache_size = 10 } db2\n} -tclbody {\n\n  # Create a backup object.\n  #\n  set rc [catch {sqlite3_backup B db2 main db main}]\n  if {$rc && [sqlite3_errcode db2] == \"SQLITE_NOMEM\"} {\n    error \"out of memory\"\n  }\n\n  # Run the backup process some.\n  #\n  set rc [B step 50]\n  if {$rc == \"SQLITE_NOMEM\" || $rc == \"SQLITE_IOERR_NOMEM\"} {\n    error \"out of memory\"\n  }\n  \n  # Update the database.\n  #\n  execsql { UPDATE t1 SET a = a + 1 }\n  \n  # Finish doing the backup.\n  #\n  set rc [B step 5000]\n  if {$rc == \"SQLITE_NOMEM\" || $rc == \"SQLITE_IOERR_NOMEM\"} {\n    error \"out of memory\"\n  }\n \n  # Finalize the backup.\n  B finish\n} -cleanup {\n  catch { B finish }\n  catch { db2 close }\n}\n\ndo_malloc_test backup_malloc-2 -tclprep {\n  sqlite3 db2 test2.db\n} -tclbody {\n  set rc [catch {sqlite3_backup B db2 temp db main}]\n  set errcode [sqlite3_errcode db2]\n  if {$rc && ($errcode == \"SQLITE_NOMEM\" || $errcode == \"SQLITE_IOERR_NOMEM\")} {\n    error \"out of memory\"\n  }\n} -cleanup {\n  catch { B finish }\n  db2 close\n}\n\nreset_db\ndo_execsql_test 3.0 {\n  PRAGMA page_size = 16384;\n  BEGIN;\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  COMMIT;\n}\n\ndo_faultsim_test 3 -faults oom* -prep {\n  catch { db close }\n  catch { db2 close }\n\n  forcedelete test2.db\n  sqlite3 db2 test2.db\n  sqlite3 db test.db\n  sqlite3_backup B db2 main db main\n} -body {\n\n  set rc [B step 50]\n  if {$rc == \"SQLITE_NOMEM\" || $rc == \"SQLITE_IOERR_NOMEM\"} {\n    error \"out of memory\"\n  }\n\n} -test {\n  faultsim_test_result {0 {}} \n  faultsim_integrity_check\n  \n  # Finalize the backup.\n  catch { B finish }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/badutf.test",
    "content": "# 2007 May 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# This file checks to make sure SQLite is able to gracefully\n# handle malformed UTF-8.\n#\n# $Id: badutf.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test badutf-1.1 {\n  db eval {PRAGMA encoding=UTF8}\n  sqlite3_exec db {SELECT hex('%80') AS x}\n} {0 {x 80}}\ndo_test badutf-1.2 {\n  sqlite3_exec db {SELECT hex('%81') AS x}\n} {0 {x 81}}\ndo_test badutf-1.3 {\n  sqlite3_exec db {SELECT hex('%bf') AS x}\n} {0 {x BF}}\ndo_test badutf-1.4 {\n  sqlite3_exec db {SELECT hex('%c0') AS x}\n} {0 {x C0}}\ndo_test badutf-1.5 {\n  sqlite3_exec db {SELECT hex('%e0') AS x}\n} {0 {x E0}}\ndo_test badutf-1.6 {\n  sqlite3_exec db {SELECT hex('%f0') AS x}\n} {0 {x F0}}\ndo_test badutf-1.7 {\n  sqlite3_exec db {SELECT hex('%ff') AS x}\n} {0 {x FF}}\n\nsqlite3 db2 {}\nifcapable utf16 {\n  do_test badutf-1.10 {\n    db2 eval {PRAGMA encoding=UTF16be}\n    sqlite3_exec db2 {SELECT hex('%80') AS x}\n  } {0 {x 0080}}\n  do_test badutf-1.11 {\n    sqlite3_exec db2 {SELECT hex('%81') AS x}\n  } {0 {x 0081}}\n  do_test badutf-1.12 {\n    sqlite3_exec db2 {SELECT hex('%bf') AS x}\n  } {0 {x 00BF}}\n  do_test badutf-1.13 {\n    sqlite3_exec db2 {SELECT hex('%c0') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.14 {\n    sqlite3_exec db2 {SELECT hex('%c1') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.15 {\n    sqlite3_exec db2 {SELECT hex('%c0%bf') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.16 {\n    sqlite3_exec db2 {SELECT hex('%c1%bf') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.17 {\n    sqlite3_exec db2 {SELECT hex('%c3%bf') AS x}\n  } {0 {x 00FF}}\n  do_test badutf-1.18 {\n    sqlite3_exec db2 {SELECT hex('%e0') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.19 {\n    sqlite3_exec db2 {SELECT hex('%f0') AS x}\n  } {0 {x FFFD}}\n  do_test badutf-1.20 {\n    sqlite3_exec db2 {SELECT hex('%ff') AS x}\n  } {0 {x FFFD}}\n}\n\n\nifcapable bloblit {\n  do_test badutf-2.1 {\n    sqlite3_exec db {SELECT '%80'=CAST(x'80' AS text) AS x}\n  } {0 {x 1}}\n  do_test badutf-2.2 {\n    sqlite3_exec db {SELECT CAST('%80' AS blob)=x'80' AS x}\n  } {0 {x 1}}\n}\n\ndo_test badutf-3.1 {\n  sqlite3_exec db {SELECT length('%80') AS x}\n} {0 {x 1}}\ndo_test badutf-3.2 {\n  sqlite3_exec db {SELECT length('%61%62%63') AS x}\n} {0 {x 3}}\ndo_test badutf-3.3 {\n  sqlite3_exec db {SELECT length('%7f%80%81') AS x}\n} {0 {x 3}}\ndo_test badutf-3.4 {\n  sqlite3_exec db {SELECT length('%61%c0') AS x}\n} {0 {x 2}}\ndo_test badutf-3.5 {\n  sqlite3_exec db {SELECT length('%61%c0%80%80%80%80%80%80%80%80%80%80') AS x}\n} {0 {x 2}}\ndo_test badutf-3.6 {\n  sqlite3_exec db {SELECT length('%c0%80%80%80%80%80%80%80%80%80%80') AS x}\n} {0 {x 1}}\ndo_test badutf-3.7 {\n  sqlite3_exec db {SELECT length('%80%80%80%80%80%80%80%80%80%80') AS x}\n} {0 {x 10}}\ndo_test badutf-3.8 {\n  sqlite3_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%80') AS x}\n} {0 {x 6}}\ndo_test badutf-3.9 {\n  sqlite3_exec db {SELECT length('%80%80%80%80%80%f0%80%80%80%ff') AS x}\n} {0 {x 7}}\n\ndo_test badutf-4.1 {\n  sqlite3_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}\n} {0 {x F0}}\ndo_test badutf-4.2 {\n  sqlite3_exec db {SELECT hex(ltrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}\n} {0 {x F0808080FF}}\ndo_test badutf-4.3 {\n  sqlite3_exec db {SELECT hex(rtrim('%80%80%80%f0%80%80%80%ff','%80%ff')) AS x}\n} {0 {x 808080F0}}\ndo_test badutf-4.4 {\n  sqlite3_exec db {SELECT hex(trim('%80%80%80%f0%80%80%80%ff','%ff%80')) AS x}\n} {0 {x 808080F0808080FF}}\ndo_test badutf-4.5 {\n  sqlite3_exec db {SELECT hex(trim('%ff%80%80%f0%80%80%80%ff','%ff%80')) AS x}\n} {0 {x 80F0808080FF}}\ndo_test badutf-4.6 {\n  sqlite3_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80')) AS x}\n} {0 {x F0808080FF}}\ndo_test badutf-4.7 {\n  sqlite3_exec db {SELECT hex(trim('%ff%80%f0%80%80%80%ff','%ff%80%80')) AS x}\n} {0 {x FF80F0808080FF}}\n\ndb2 close\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/badutf2.test",
    "content": "# 2011 March 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# This file checks to make sure SQLite is able to gracEFully\n# handle malformed UTF-8.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc utf8_to_ustr2 {s} {\n  set r \"\"\n  foreach i [split $s \"\"] {\n    scan $i %c c\n    append r [format \\\\u%04.4X $c]\n  }\n  set r\n}\n\nproc utf8_to_hstr {in} {\n regsub -all -- {(..)} $in {%[format \"%s\" \\1]} out\n subst $out\n}\n\nproc utf8_to_xstr {in} {\n regsub -all -- {(..)} $in {\\\\\\\\x[format \"%s\" \\1]} out\n subst $out\n}\n\nproc utf8_to_ustr {in} {\n regsub -all -- {(..)} $in {\\\\\\\\u[format \"%04.4X\" 0x\\1]} out\n subst $out\n}\n\ndo_test badutf2-1.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval \"PRAGMA encoding = 'UTF-8'\"\n} {}\n\ndo_test badutf2-4.0 {\n  set S [sqlite3_prepare_v2 db \"SELECT ?\" -1 dummy]\n  sqlite3_expired $S\n} {0}\n        \nforeach { i len uval xstr ustr u2u } {\n1 1 00     \\x00         {}        {}\n2 1 01     \\x01         \"\\\\u0001\" 01\n3 1 3F     \\x3F         \"\\\\u003F\" 3F\n4 1 7F     \\x7F         \"\\\\u007F\" 7F\n5 1 80     \\x80         \"\\\\u0080\" C280\n6 1 C3BF   \\xFF         \"\\\\u00FF\" C3BF\n7 3 EFBFBD \\xEF\\xBF\\xBD \"\\\\uFFFD\" {}\n} {\n\n  set hstr [ utf8_to_hstr $uval ]\n\n  ifcapable bloblit {\n    if {$hstr != \"%00\"} {\n      do_test badutf2-2.1.$i {\n        set sql \"SELECT '$hstr'=CAST(x'$uval' AS text) AS x;\"\n        set res [ sqlite3_exec db $sql ]\n        lindex [ lindex $res 1] 1\n      } {1}\n      do_test badutf2-2.2.$i {\n        set sql \"SELECT CAST('$hstr' AS blob)=x'$uval' AS x;\"\n        set res [ sqlite3_exec db $sql ]\n        lindex [ lindex $res 1] 1\n      } {1}\n    }\n    do_test badutf2-2.3.$i {\n      set sql \"SELECT hex(CAST(x'$uval' AS text)) AS x;\"\n      set res [ sqlite3_exec db $sql ]\n      lindex [ lindex $res 1] 1\n    } $uval\n    do_test badutf2-2.4.$i {\n      set sql \"SELECT hex(CAST(x'$uval' AS text)) AS x;\"\n      set res [ sqlite3_exec db $sql ]\n      lindex [ lindex $res 1] 1\n    } $uval\n  }\n\n  if {$hstr != \"%00\"} {\n    do_test badutf2-3.1.$i {\n      set sql \"SELECT hex('$hstr') AS x;\"\n      set res [ sqlite3_exec db $sql ]\n      lindex [ lindex $res 1] 1\n    } $uval\n  }\n\n  do_test badutf2-4.1.$i {\n    sqlite3_reset $S\n    sqlite3_bind_text $S 1 $xstr $len\n    sqlite3_step $S\n    utf8_to_ustr2 [ sqlite3_column_text $S 0 ]\n  } $ustr\n\n  ifcapable debug {\n    do_test badutf2-5.1.$i {\n      utf8_to_utf8 $uval\n    } $u2u\n  }\n\n}\n\ndo_test badutf2-4.2 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bc_common.tcl",
    "content": "\n\n\nproc bc_find_binaries {zCaption} {\n  # Search for binaries to test against. Any executable files that match\n  # our naming convention are assumed to be testfixture binaries to test\n  # against.\n  #\n  set binaries [list]\n  set self [info nameofexec]\n  set pattern \"$self?*\"\n  if {$::tcl_platform(platform)==\"windows\"} {\n    set pattern [string map {\\.exe {}} $pattern]\n  }\n  foreach file [glob -nocomplain $pattern] {\n    if {$file==$self} continue\n    if {[file executable $file] && [file isfile $file]} {lappend binaries $file}\n  }\n\n  if {[llength $binaries]==0} {\n    puts \"WARNING: No historical binaries to test against.\"\n    puts \"WARNING: Omitting backwards-compatibility tests\"\n  }\n\n  foreach bin $binaries {\n    puts -nonewline \"Testing against $bin - \"\n    flush stdout\n    puts \"version [get_version $bin]\"\n  }\n\n  set ::BC(binaries) $binaries\n  return $binaries\n}\n\nproc get_version {binary} {\n  set chan [launch_testfixture $binary]\n  set v [testfixture $chan { sqlite3 -version }]\n  close $chan\n  set v\n}\n\nproc do_bc_test {bin script} {\n\n  forcedelete test.db\n  set ::bc_chan [launch_testfixture $bin]\n\n  proc code1 {tcl} { uplevel #0 $tcl }\n  proc code2 {tcl} { testfixture $::bc_chan $tcl }\n  proc sql1 sql { code1 [list db eval $sql] }\n  proc sql2 sql { code2 [list db eval $sql] }\n\n  code1 { sqlite3 db test.db }\n  code2 { sqlite3 db test.db }\n\n  set bintag $bin\n  regsub {.*testfixture\\.} $bintag {} bintag\n  set bintag [string map {\\.exe {}} $bintag]\n  if {$bintag == \"\"} {set bintag self}\n  set saved_prefix $::testprefix\n  append ::testprefix \".$bintag\"\n\n  uplevel $script\n\n  set ::testprefix $saved_prefix\n\n  catch { code1 { db close } }\n  catch { code2 { db close } }\n  catch { close $::bc_chan }\n}\n\nproc do_all_bc_test {script} {\n  foreach bin $::BC(binaries) {\n    uplevel [list do_bc_test $bin $script]\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bestindex1.test",
    "content": "# 2016-03-01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bestindex1\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_tcl_module db\n\nproc vtab_command {method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(a, b, c)\"\n    }\n\n    xBestIndex {\n      set clist [lindex $args 0]\n      if {[llength $clist]!=1} { error \"unexpected constraint list\" }\n      catch { array unset C }\n      array set C [lindex $clist 0]\n      if {$C(usable)} {\n        return \"omit 0 cost 0 rows 1 idxnum 555 idxstr eq!\"\n      } else {\n        return \"cost 1000000 rows 0 idxnum 0 idxstr scan...\"\n      }\n    }\n\n  }\n\n  return {}\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);\n} {}\n\ndo_eqp_test 1.1 {\n  SELECT * FROM x1 WHERE a = 'abc'\n} {\n  0 0 0 {SCAN TABLE x1 VIRTUAL TABLE INDEX 555:eq!}\n}\n\ndo_eqp_test 1.2 {\n  SELECT * FROM x1 WHERE a IN ('abc', 'def');\n} {\n  0 0 0 {SCAN TABLE x1 VIRTUAL TABLE INDEX 555:eq!}\n  0 0 0 {EXECUTE LIST SUBQUERY 1}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nregister_tcl_module db\n\n# Parameter $mode may be one of:\n#\n#   \"omit\" - Implement filtering. Set the omit flag.\n#   \"use\"  - Implement filtering. Use the constraint, but do not set omit.\n#   \"use2\" - Do not implement filtering. Use the constraint anyway.\n#\n#   \nproc t1_vtab {mode method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(a, b)\"\n    }\n\n    xBestIndex {\n      set SQL_FILTER {SELECT * FROM t1x WHERE a='%1%'}\n      set SQL_SCAN   {SELECT * FROM t1x}\n\n      set clist [lindex $args 0]\n      set idx 0\n      for {set idx 0} {$idx < [llength $clist]} {incr idx} {\n        array unset C\n        array set C [lindex $clist $idx]\n        if {$C(column)==0 && $C(op)==\"eq\" && $C(usable)} {\n          switch -- $mode {\n            \"omit\" {\n              return [list omit $idx rows 10 cost 10 idxstr $SQL_FILTER]\n            }\n            \"use\" {\n              return [list use $idx rows 10 cost 10 idxstr $SQL_FILTER]\n            }\n            \"use2\" {\n              return [list use $idx rows 10 cost 10 idxstr $SQL_SCAN]\n            }\n            default {\n              error \"Bad mode - $mode\"\n            }\n          }\n        }\n      }\n\n      return [list idxstr {SELECT * FROM t1x}]\n    }\n\n    xFilter {\n      set map [list %1% [lindex $args 2 0]]\n      set sql [string map $map [lindex $args 1]]\n      return [list sql $sql]\n    }\n  }\n\n  return {}\n}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t1x(i INTEGER PRIMARY KEY, a, b);\n  INSERT INTO t1x VALUES(1, 'one', 1);\n  INSERT INTO t1x VALUES(2, 'two', 2);\n  INSERT INTO t1x VALUES(3, 'three', 3);\n  INSERT INTO t1x VALUES(4, 'four', 4);\n}\n\nforeach {tn mode} {\n  1 use 2 omit 3 use2\n} {\n  do_execsql_test 2.2.$mode.1 \"\n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING tcl(t1_vtab $mode);\n  \"\n\n  do_execsql_test 2.2.$mode.2 {SELECT * FROM t1} {one 1 two 2 three 3 four 4}\n  do_execsql_test 2.2.$mode.3 {SELECT rowid FROM t1} {1 2 3 4}\n  do_execsql_test 2.2.$mode.4 {SELECT rowid FROM t1 WHERE a='two'} {2} \n\n  do_execsql_test 2.2.$mode.5 {\n    SELECT rowid FROM t1 WHERE a IN ('one', 'four') ORDER BY +rowid\n  } {1 4} \n\n  set plan(use) {\n    0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x WHERE a='%1%'}\n    0 0 0 {EXECUTE LIST SUBQUERY 1}\n    0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  }\n  set plan(omit) {\n    0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x WHERE a='%1%'}\n    0 0 0 {EXECUTE LIST SUBQUERY 1}\n    0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  }\n  set plan(use2) {\n    0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:SELECT * FROM t1x}\n    0 0 0 {EXECUTE LIST SUBQUERY 1}\n    0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  }\n\n  do_eqp_test 2.2.$mode.6 { \n    SELECT rowid FROM t1 WHERE a IN ('one', 'four') ORDER BY +rowid\n  } $plan($mode)\n}\n\n# 2016-04-09.\n# Demonstrate a register overwrite problem when using two virtual\n# tables where the outer loop uses the IN operator.\n#\nset G(collist) [list PrimaryKey flagA columnA]\nset G(cols) [join $G(collist) ,]\nset G(nulls) \"NULL\"\n\nproc vtab_command {method args} {\n  global G\n\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1($G(cols))\"\n    }\n\n    xBestIndex {\n      set clist [lindex $args 0]\n      #puts $clist\n      set W [list]\n      set U [list]\n\n      set i 0\n      for {set idx 0} {$idx < [llength $clist]} {incr idx} {\n        array set c [lindex $clist $idx]\n        if {$c(op)==\"eq\" && $c(usable)} {\n          lappend W \"[lindex $G(collist) $c(column)] = %$i%\"\n          lappend U use $idx\n          incr i\n        }\n      }\n\n      if {$W==\"\"} {\n        set sql \"SELECT rowid, * FROM t1\"\n      } else {\n        set sql \"SELECT rowid, * FROM t1 WHERE [join $W { AND }]\"\n      }\n\n      return [concat [list idxstr $sql] $U]\n    }\n\n    xFilter {\n      foreach {idxnum idxstr vals} $args {}\n\n      set map [list]\n      for {set i 0} {$i < [llength $vals]} {incr i} {\n        lappend map \"%$i%\" \n        set v [lindex $vals $i]\n        if {[string is integer $v]} { \n          lappend map $v \n        } else {\n          lappend map \"'$v'\"\n        }\n      }\n      set sql [string map $map $idxstr]\n\n      #puts \"SQL: $sql\"\n      return [list sql $sql]\n    }\n  }\n\n  return {}\n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\nregister_tcl_module db\n\ndo_execsql_test 3.1 \"\n  CREATE TABLE t1($G(cols));\n  INSERT INTO t1 VALUES(1, 0, 'ValueA');\n  INSERT INTO t1 VALUES(2, 0, 'ValueA');\n  INSERT INTO t1 VALUES(3, 0, 'ValueB');\n  INSERT INTO t1 VALUES(4, 0, 'ValueB');\n\"\n\ndo_execsql_test 3.2 {\n  CREATE VIRTUAL TABLE VirtualTableA USING tcl(vtab_command);\n  CREATE VIRTUAL TABLE VirtualTableB USING tcl(vtab_command);\n}\n\ndo_execsql_test 3.3 { SELECT primarykey FROM VirtualTableA } {1 2 3 4}\n\ndo_execsql_test 3.4 {\n  SELECT * FROM \n  VirtualTableA a CROSS JOIN VirtualTableB b ON b.PrimaryKey=a.PrimaryKey\n  WHERE a.ColumnA IN ('ValueA', 'ValueB') AND a.FlagA=0\n} {\n  1 0 ValueA 1 0 ValueA\n  2 0 ValueA 2 0 ValueA\n  3 0 ValueB 3 0 ValueB\n  4 0 ValueB 4 0 ValueB\n}\n\ndo_execsql_test 3.5 {\n  SELECT * FROM \n  VirtualTableA a CROSS JOIN VirtualTableB b ON b.PrimaryKey=a.PrimaryKey\n  WHERE a.FlagA=0 AND a.ColumnA IN ('ValueA', 'ValueB') \n} {\n  1 0 ValueA 1 0 ValueA\n  2 0 ValueA 2 0 ValueA\n  3 0 ValueB 3 0 ValueB\n  4 0 ValueB 4 0 ValueB\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bestindex2.test",
    "content": "# 2016 March 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bestindex2\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Virtual table callback for table named $tbl, with the columns specified\n# by list argument $cols. e.g. if the function is invoked as:\n#\n#   vtab_cmd t1 {a b c} ...\n#\n# The table created is:\n#\n#      \"CREATE TABLE t1 (a, b, c)\"\n#\n# The tables xBestIndex method behaves as if all possible combinations of\n# \"=\" constraints (but no others) may be optimized. The cost of a full table\n# scan is:\n#\n#      \"WHERE 1\"                \"cost 1000000 rows 1000000\"\n#\n# If one or more \"=\" constraints are in use, the cost and estimated number\n# of rows returned are both is (11 - nCons)*1000, where nCons is the number\n# of constraints used. e.g.\n#\n#   \"WHERE a=? AND b=?\"    ->   \"cost  900 rows  900\"\n#   \"WHERE c=? AND b<?\"    ->   \"cost 1000 rows 1000\"\n#  \nproc vtab_cmd {tbl cols method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE $tbl ([join $cols ,])\"\n    }\n    xBestIndex {\n      foreach {clist orderby mask} $args {}\n\n      set cons [list]\n      set used [list]\n\n      for {set i 0} {$i < [llength $clist]} {incr i} {\n        array unset C\n        array set C [lindex $clist $i]\n        if {$C(op)==\"eq\" && $C(usable) && [lsearch $cons $C(column)]<0} {\n          lappend used use $i\n          lappend cons $C(column)\n        }\n      }\n\n      set nCons [llength $cons]\n      if {$nCons==0} {\n        return \"cost 1000000 rows 1000000\"\n      } else {\n        set cost [expr (11-$nCons) * 1000]\n        set ret [concat $used \"cost $cost rows $cost\"]\n\n        set txt [list]\n        foreach c $cons { lappend txt \"[lindex $cols $c]=?\" }\n        lappend ret idxstr \"indexed([join $txt { AND }])\"\n\n        return $ret\n      }\n    }\n  }\n  return \"\"\n}\n\nregister_tcl_module db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING tcl(\"vtab_cmd t1 {a b}\");\n  CREATE VIRTUAL TABLE t2 USING tcl(\"vtab_cmd t2 {c d}\");\n  CREATE VIRTUAL TABLE t3 USING tcl(\"vtab_cmd t3 {e f}\");\n}\n\ndo_eqp_test 1.1 {\n  SELECT * FROM t1 WHERE a='abc'\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:indexed(a=?)}\n}\ndo_eqp_test 1.2 {\n  SELECT * FROM t1 WHERE a='abc' AND b='def'\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:indexed(a=? AND b=?)}\n}\ndo_eqp_test 1.3 {\n  SELECT * FROM t1 WHERE a='abc' AND a='def'\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:indexed(a=?)}\n}\ndo_eqp_test 1.4 {\n  SELECT * FROM t1,t2 WHERE c=a\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:} \n  0 1 1 {SCAN TABLE t2 VIRTUAL TABLE INDEX 0:indexed(c=?)}\n}\n\ndo_eqp_test 1.5 {\n  SELECT * FROM t1, t2 CROSS JOIN t3 WHERE t2.c = +t1.b AND t3.e=t2.d\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:} \n  0 1 1 {SCAN TABLE t2 VIRTUAL TABLE INDEX 0:indexed(c=?)} \n  0 2 2 {SCAN TABLE t3 VIRTUAL TABLE INDEX 0:indexed(e=?)}\n}\n\ndo_eqp_test 1.6 {\n  SELECT * FROM t1, t2, t3 WHERE t2.c = +t1.b AND t3.e = t2.d\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:} \n  0 1 1 {SCAN TABLE t2 VIRTUAL TABLE INDEX 0:indexed(c=?)} \n  0 2 2 {SCAN TABLE t3 VIRTUAL TABLE INDEX 0:indexed(e=?)}\n}\n\ndo_execsql_test 1.7.1 {\n  CREATE TABLE x1(a, b);\n}\ndo_eqp_test 1.7.2 {\n  SELECT * FROM x1 CROSS JOIN t1, t2, t3 \n    WHERE t1.a = t2.c AND t1.b = t3.e\n} {\n  0 0 0 {SCAN TABLE x1} \n  0 1 1 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:}\n  0 2 2 {SCAN TABLE t2 VIRTUAL TABLE INDEX 0:indexed(c=?)} \n  0 3 3 {SCAN TABLE t3 VIRTUAL TABLE INDEX 0:indexed(e=?)}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bestindex3.test",
    "content": "# 2016 May 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bestindex3\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Virtual table callback for a virtual table named $tbl.\n#\n# The table created is:\n#\n#      \"CREATE TABLE t1 (a, b, c)\"\n#\n# This virtual table supports both LIKE and = operators on all columns.\n#  \nproc vtab_cmd {bOmit method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(a, b, c)\"\n    }\n\n    xBestIndex {\n      foreach {clist orderby mask} $args {}\n\n      set ret [list]\n      set use use\n      if {$bOmit} {set use omit}\n\n      for {set i 0} {$i < [llength $clist]} {incr i} {\n        array unset C\n        array set C [lindex $clist $i]\n        if {$C(usable) && ($C(op)==\"like\" || $C(op)==\"eq\")} {\n          lappend ret $use $i\n          lappend ret idxstr \n          lappend ret \"[lindex {a b c} $C(column)] [string toupper $C(op)] ?\"\n          break\n        }\n      }\n\n      if {$ret==\"\"} {\n        lappend ret cost 1000000 rows 1000000\n      } else {\n        lappend ret cost 100 rows 10\n      }\n      return $ret\n    }\n\n    xFilter {\n      foreach {idxnum idxstr param} $args {}\n      set where \"\"\n      if {$bOmit && $idxstr != \"\"} {\n        set where \" WHERE [string map [list ? '$param' EQ =] $idxstr]\"\n      }\n      return [list sql \"SELECT rowid, * FROM ttt$where\"]\n    }\n  }\n  return \"\"\n}\n\nregister_tcl_module db\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING tcl(\"vtab_cmd 0\");\n}\n\ndo_eqp_test 1.1 {\n  SELECT * FROM t1 WHERE a LIKE 'abc';\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a LIKE ?}\n}\n\ndo_eqp_test 1.2 {\n  SELECT * FROM t1 WHERE a = 'abc';\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a EQ ?}\n}\n\ndo_eqp_test 1.3 {\n  SELECT * FROM t1 WHERE a = 'abc' OR b = 'def';\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a EQ ?}\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:b EQ ?}\n}\n\ndo_eqp_test 1.4 {\n  SELECT * FROM t1 WHERE a LIKE 'abc%' OR b = 'def';\n} {\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:a LIKE ?}\n  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 0:b EQ ?}\n}\n\ndo_execsql_test 1.5 {\n  CREATE TABLE ttt(a, b, c);\n\n  INSERT INTO ttt VALUES(1, 'two',   'three');\n  INSERT INTO ttt VALUES(2, 'one',   'two');\n  INSERT INTO ttt VALUES(3, 'three', 'one');\n  INSERT INTO ttt VALUES(4, 'y',     'one');\n  INSERT INTO ttt VALUES(5, 'x',     'two');\n  INSERT INTO ttt VALUES(6, 'y',     'three');\n}\n\nforeach omit {0 1} {\n  do_execsql_test 1.6.$omit.0 \"\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd $omit');\n  \"\n  do_execsql_test 1.6.$omit.1 { \n    SELECT rowid FROM t1 WHERE c LIKE 'o%'\n  } {3 4}\n\n  do_execsql_test 1.6.$omit.2 { \n    SELECT rowid FROM t1 WHERE c LIKE 'o%' OR b='y'\n  } {3 4 6}\n\n  do_execsql_test 1.6.$omit.3 { \n    SELECT rowid FROM t1 WHERE c = 'three' OR c LIKE 'o%'\n  } {1 6 3 4}\n}\n\n#-------------------------------------------------------------------------\n# Test the same pattern works with ordinary tables.\n#\n# This test does not work if the ICU extension is enabled. ICU overrides\n# LIKE - and this optimization only works with the built-in LIKE function.\n#\nifcapable !icu {\n  do_execsql_test 2.1 {\n    CREATE TABLE t2(x TEXT COLLATE nocase, y TEXT);\n    CREATE INDEX t2x ON t2(x COLLATE nocase);\n    CREATE INDEX t2y ON t2(y);\n  }\n\n  do_eqp_test 2.2 {\n    SELECT * FROM t2 WHERE x LIKE 'abc%' OR y = 'def'\n  } {\n    0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x>? AND x<?)}\n    0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?)}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that any PRIMARY KEY within a sqlite3_decl_vtab() CREATE TABLE \n# statement is currently ignored.\n#\nproc vvv_command {method args} {\n  switch -- $method {\n    xConnect { return \"CREATE TABLE t1(a PRIMARY KEY, b, c)\" }\n  }\n}\nproc yyy_command {method args} {\n  switch -- $method {\n    xConnect { return \"CREATE TABLE t1(a, b, c, PRIMARY KEY(a, b))\" }\n  }\n}\n\ndo_execsql_test 3.1 { CREATE VIRTUAL TABLE t3 USING tcl('vvv_command') }\ndo_execsql_test 3.2 { CREATE VIRTUAL TABLE t4 USING tcl('yyy_command') }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bestindex4.test",
    "content": "# 2016 November 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test the virtual table interface. In particular the xBestIndex\n# method.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bestindex4\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Virtual table callback for a virtual table named $tbl.\n#\n# The table created is:\n#\n#      \"CREATE TABLE t1 (id, host, class)\"\n#\n# The virtual table supports == operators on a subset of its columns. The\n# exact subset depends on the value of bitmask paramater $param.\n#\n#   0x01 - == on \"id\" supported\n#   0x02 - == on \"host\" supported\n#   0x04 - == on \"class\" supported\n#\n# $param also supports the following bits:\n#\n#   0x08 - ignore the \"usable\" flag (malfunction)\n#\n#\n#  \nproc vtab_cmd {param method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(id TEXT, host TEXT, class TEXT)\"\n    }\n\n    xBestIndex {\n      foreach {clist orderby mask} $args {}\n\n      set ret [list]\n\n      set use use\n\n\n      for {set i 0} {$i < [llength $clist]} {incr i} {\n        array unset C\n        array set C [lindex $clist $i]\n        if { ($C(usable) || ($param & 0x08)) \n          && $C(op)==\"eq\" && ($param & 1<<$C(column))\n        } {\n          lappend ret $use $i\n          break\n        }\n      }\n\n      set score 1000000\n      if {$ret!=\"\"} {\n        set score [expr $score / [llength $ret]]\n      }\n      lappend ret cost $score rows $score\n\n      return $ret\n    }\n\n    xFilter {\n    }\n  }\n  return \"\"\n}\n\nregister_tcl_module db\n\nfor {set param1 0} {$param1<16} {incr param1} {\n  for {set param2 0} {$param2<16} {incr param2} {\n    reset_db\n    register_tcl_module db\n    do_execsql_test 1.$param1.$param2.1 \"\n      CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd $param1');\n      CREATE VIRTUAL TABLE t2 USING tcl('vtab_cmd $param2');\n    \"\n\n    foreach {tn sql} {\n      2 \"select t1.id as ID from t1, t2 where t1.id=t2.host and t2.class='xx'\"\n      3 {\n        select t1.id as ID from t1, t2 where t2.class ='xx' and t2.id = t1.host\n      }\n      4 {\n        select t1.id as ID from t1, t2 where t1.host = t2.id and t2. class ='xx'\n      }\n    } {\n\n      if {($param1 & 0x08)==0 && ($param2 & 0x08)==0} {\n\n        do_execsql_test 1.$param1.$param2.$tn.a $sql {}\n\n      } else {\n        do_test 1.$param1.$param2.$tn.b {\n          catchsql $sql\n            set {} {}\n        } {}\n      }\n    }\n\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bestindex5.test",
    "content": "# 2017 September 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test the virtual table interface. In particular the xBestIndex\n# method.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bestindex4\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Virtual table callback for a virtual table named $tbl.\n#  \nproc vtab_cmd {method args} {\n\n  set binops(ne)    !=\n  set binops(eq)    =\n  set binops(isnot) \"IS NOT\"\n  set binops(is)    \"IS\"\n\n  set unops(isnotnull) \"IS NOT NULL\"\n  set unops(isnull)    \"IS NULL\"\n\n  set cols(0) a\n  set cols(1) b\n  set cols(2) c\n\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(a, b, c)\"\n    }\n\n    xBestIndex {\n      foreach {clist orderby mask} $args {}\n\n      set cost 1000000.0\n      set ret [list]\n      set str [list]\n\n      set v 0\n      for {set i 0} {$i < [llength $clist]} {incr i} {\n        array unset C\n        array set C [lindex $clist $i]\n        if {$C(usable)} {\n          if {[info exists binops($C(op))]} {\n            lappend ret omit $i\n            lappend str \"$cols($C(column)) $binops($C(op)) %$v%\"\n            incr v\n            set cost [expr $cost / 2]\n          }\n          if {[info exists unops($C(op))]} {\n            lappend ret omit $i\n            lappend str \"$cols($C(column)) $unops($C(op))\"\n            incr v\n            set cost [expr $cost / 2]\n          }\n        }\n      }\n\n      lappend ret idxstr [join $str \" AND \"]\n      lappend ret cost $cost\n      return $ret\n    }\n\n    xFilter {\n      set q [lindex $args 1]\n      set a [lindex $args 2]\n      for {set v 0} {$v < [llength $a]} {incr v} {\n        set val [lindex $a $v]\n        set q [string map [list %$v% '$val'] $q]\n      }\n      if {$q==\"\"} { set q 1 }\n      lappend ::xFilterQueries \"WHERE $q\"\n      return [list sql \"SELECT rowid, * FROM t1x WHERE $q\"]\n    }\n  }\n  return \"\"\n}\n\nproc vtab_simple {method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t2(x)\"\n    }\n    xBestIndex {\n      return [list cost 999999.0]\n    }\n    xFilter {\n      return [list sql \"SELECT rowid, * FROM t2x\"]\n    }\n  }\n  return \"\"\n}\n\nregister_tcl_module db\n\nproc do_vtab_query_test {tn query result} {\n  set ::xFilterQueries [list]\n  uplevel [list\n    do_test $tn [string map [list %QUERY% $query] {\n      set r [execsql {%QUERY%}]\n      set r [concat $::xFilterQueries $r]\n      set r\n    }] [list {*}$result]\n  ]\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING tcl('vtab_cmd');\n  CREATE TABLE t1x(a INTEGER, b TEXT, c REAL);\n  INSERT INTO t1x VALUES(1, 2, 3);\n  INSERT INTO t1x VALUES(4, 5, 6);\n  INSERT INTO t1x VALUES(7, 8, 9);\n\n  CREATE VIRTUAL TABLE t2 USING tcl('vtab_simple');\n  CREATE TABLE t2x(x INTEGER);\n  INSERT INTO t2x VALUES(1);\n}\n\ndo_vtab_query_test 1.1 { SELECT * FROM t1 WHERE a!='hello'; } {\n  \"WHERE a != 'hello'\"\n  1 2 3.0 4 5 6.0 7 8 9.0\n}\n\ndo_vtab_query_test 1.2.1 { SELECT * FROM t1 WHERE b!=8 } {\n  \"WHERE b != '8'\"\n  1 2 3.0 4 5 6.0\n}\ndo_vtab_query_test 1.2.2 { SELECT * FROM t1 WHERE 8!=b } {\n  \"WHERE b != '8'\"\n  1 2 3.0 4 5 6.0\n}\n\ndo_vtab_query_test 1.3 { SELECT * FROM t1 WHERE c IS NOT 3 } {\n  \"WHERE c IS NOT '3'\"\n  4 5 6.0 7 8 9.0\n}\ndo_vtab_query_test 1.3.2 { SELECT * FROM t1 WHERE 3 IS NOT c } {\n  \"WHERE c IS NOT '3'\"\n  4 5 6.0 7 8 9.0\n}\n\ndo_vtab_query_test 1.4.1 { SELECT * FROM t1, t2 WHERE x != a } {\n  \"WHERE a != '1'\"\n  4 5 6.0 1   7 8 9.0 1\n}\ndo_vtab_query_test 1.4.2 { SELECT * FROM t1, t2 WHERE a != x } {\n  \"WHERE a != '1'\"\n  4 5 6.0 1   7 8 9.0 1\n}\n\ndo_vtab_query_test 1.5.1 { SELECT * FROM t1 WHERE a IS NOT NULL } {\n  \"WHERE a IS NOT NULL\"\n  1 2 3.0 4 5 6.0 7 8 9.0\n}\ndo_vtab_query_test 1.5.2 { SELECT * FROM t1 WHERE NULL IS NOT a } {\n  \"WHERE a IS NOT ''\"\n  1 2 3.0 4 5 6.0 7 8 9.0\n}\n\ndo_vtab_query_test 1.6.1 { SELECT * FROM t1 WHERE a IS NULL } {\n  \"WHERE a IS NULL\"\n}\n\ndo_vtab_query_test 1.6.2 { SELECT * FROM t1 WHERE NULL IS a } {\n  \"WHERE a IS ''\"\n}\n\ndo_vtab_query_test 1.7.1 { SELECT * FROM t1 WHERE (a, b) IS (1, 2) } {\n  \"WHERE a IS '1' AND b IS '2'\"\n  1 2 3.0\n}\ndo_vtab_query_test 1.7.2 { SELECT * FROM t1 WHERE (5, 4) IS (b, a) } {\n  {WHERE b IS '5' AND a IS '4'} \n  4 5 6.0\n}\n\n#---------------------------------------------------------------------\ndo_execsql_test 2.0.0 {\n  DELETE FROM t1x;\n  INSERT INTO t1x VALUES('a', 'b', 'c');\n}\ndo_execsql_test 2.0.1 { SELECT * FROM t1 } {a b c}\ndo_execsql_test 2.0.2 { SELECT * FROM t1 WHERE (a, b) != ('a', 'b'); } {}\n\ndo_execsql_test 2.1.0 {\n  DELETE FROM t1x;\n  INSERT INTO t1x VALUES(7, 8, 9);\n}\ndo_execsql_test 2.1.1 { SELECT * FROM t1 } {7 8 9.0}\ndo_execsql_test 2.1.2 { SELECT * FROM t1 WHERE (a, b) != (7, '8') } {}\ndo_execsql_test 2.1.3 { SELECT * FROM t1 WHERE a!=7 OR b!='8' }\ndo_execsql_test 2.1.4 { SELECT * FROM t1 WHERE a!=7 OR b!='8' }\n\n\ndo_execsql_test 2.2.1 {\n  CREATE TABLE t3(a INTEGER, b TEXT);\n  INSERT INTO t3 VALUES(45, 46);\n}\ndo_execsql_test 2.2.2 { SELECT * FROM t3 WHERE (a, b) != (45, 46); }\ndo_execsql_test 2.2.3 { SELECT * FROM t3 WHERE (a, b) != ('45', '46'); }\ndo_execsql_test 2.2.4 { SELECT * FROM t3 WHERE (a, b) == (45, 46); } {45 46}\ndo_execsql_test 2.2.5 { SELECT * FROM t3 WHERE (a, b) == ('45', '46'); } {45 46}\n\n#---------------------------------------------------------------------\n# Test the != operator on a virtual table with column affinities.\n#\nproc vtab_simple_integer {method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t4(x INTEGER)\"\n    }\n    xBestIndex {\n      return [list cost 999999.0]\n    }\n    xFilter {\n      return [list sql \"SELECT rowid, * FROM t4x\"]\n    }\n  }\n  return \"\"\n}\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t4x(a INTEGER);\n  INSERT INTO t4x VALUES(245);\n  CREATE VIRTUAL TABLE t4 USING tcl('vtab_simple_integer');\n}\ndo_execsql_test 3.1 { SELECT rowid, * FROM t4 WHERE x=245; } {1 245}\ndo_execsql_test 3.2 { SELECT rowid, * FROM t4 WHERE x='245'; } {1 245}\ndo_execsql_test 3.3 { SELECT rowid, * FROM t4 WHERE x!=245; } {}\ndo_execsql_test 3.4 { SELECT rowid, * FROM t4 WHERE x!='245'; } {}\n\ndo_execsql_test 3.5 { SELECT rowid, * FROM t4 WHERE rowid!=1 OR x!='245'; } {}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/between.test",
    "content": "# 2005 July 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the use of indices in WHERE clauses\n# when the WHERE clause contains the BETWEEN operator.\n#\n# $Id: between.test,v 1.2 2006/01/17 09:35:02 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test between-1.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(w int, x int, y int, z int);\n  }\n  for {set i 1} {$i<=100} {incr i} {\n    set w $i\n    set x [expr {int(log($i)/log(2))}]\n    set y [expr {$i*$i + 2*$i + 1}]\n    set z [expr {$x+$y}]\n    ifcapable tclvar {\n      # Random unplanned test of the $varname variable syntax.\n      execsql {INSERT INTO t1 VALUES($::w,$::x,$::y,$::z)}\n    } else {\n      # If the $varname syntax is not available, use the regular variable\n      # declaration syntax.\n      execsql {INSERT INTO t1 VALUES(:w,:x,:y,:z)}\n    }\n  }\n  execsql {\n    CREATE UNIQUE INDEX i1w ON t1(w);\n    CREATE INDEX i1xy ON t1(x,y);\n    CREATE INDEX i1zyx ON t1(z,y,x);\n    COMMIT;\n  }\n} {}\n\n# This procedure executes the SQL.  Then it appends to the result the\n# \"sort\" or \"nosort\" keyword depending on whether or not any sorting\n# is done.  Then it appends the names of the table and index used.\n#\nproc queryplan {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  set eqp [execsql \"EXPLAIN QUERY PLAN $sql\"]\n  # puts eqp=$eqp\n  foreach {a b c x} $eqp {\n    if {[regexp { TABLE (\\w+ AS )?(\\w+) USING.* INDEX (\\w+)\\y} \\\n        $x all as tab idx]} {\n      lappend data $tab $idx\n    } elseif {[regexp { TABLE (\\w+ AS )?(\\w+)\\y} $x all as tab]} {\n      lappend data $tab *\n    }\n  }\n  return $data   \n}\n\ndo_test between-1.1.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w BETWEEN 5 AND 6 ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 i1w}\ndo_test between-1.1.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE +w BETWEEN 5 AND 6 ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 *}\ndo_test between-1.2.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w BETWEEN 5 AND 65-y ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 i1w}\ndo_test between-1.2.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE +w BETWEEN 5 AND 65-y ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 *}\ndo_test between-1.3.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w BETWEEN 41-y AND 6 ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 i1w}\ndo_test between-1.3.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE +w BETWEEN 41-y AND 6 ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 *}\ndo_test between-1.4 {\n  queryplan {\n    SELECT * FROM t1 WHERE w BETWEEN 41-y AND 65-y ORDER BY +w\n  }\n} {5 2 36 38 6 2 49 51 sort t1 *}\ndo_test between-1.5.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE 26 BETWEEN y AND z ORDER BY +w\n  }\n} {4 2 25 27 sort t1 i1zyx}\ndo_test between-1.5.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE 26 BETWEEN +y AND z ORDER BY +w\n  }\n} {4 2 25 27 sort t1 i1zyx}\ndo_test between-1.5.3 {\n  queryplan {\n    SELECT * FROM t1 WHERE 26 BETWEEN y AND +z ORDER BY +w\n  }\n} {4 2 25 27 sort t1 *}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bigfile.test",
    "content": "# 2002 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the ability of SQLite to handle database\n# files larger than 4GB.\n#\n# $Id: bigfile.test,v 1.12 2009/03/05 04:27:08 shane Exp $\n#\n\nif {[file exists skip-big-file]} return\nif {$tcl_platform(os)==\"Darwin\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for this file, as the database is manipulated using\n# external methods (the [fake_big_file] and [hexio_write] commands).\n#\ndo_not_use_codec\n\n# If SQLITE_DISABLE_LFS is defined, omit this file.\nifcapable !lfs {\n  finish_test\n  return\n}\n\n# These tests only work for Tcl version 8.4 and later.  Prior to 8.4,\n# Tcl was unable to handle large files.\n#\nscan $::tcl_version %f vx\nif {$vx<8.4} return\n\n# Mac OS X does not handle large files efficiently.  So skip this test\n# on that platform.\nif {$tcl_platform(os)==\"Darwin\"} return\n\n# This is the md5 checksum of all the data in table t1 as created\n# by the first test.  We will use this number to make sure that data\n# never changes.\n#\nset MAGIC_SUM {593f1efcfdbe698c28b4b1b693f7e4cf}\n\ndo_test bigfile-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    INSERT INTO t1 SELECT rowid || ' ' || x FROM t1;\n    COMMIT;\n  }\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\n\n# Try to create a large file - a file that is larger than 2^32 bytes.\n# If this fails, it means that the system being tested does not support\n# large files.  So skip all of the remaining tests in this file.\n#\ndb close\nif {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {\n  puts \"**** Unable to create a file larger than 4096 MB. *****\"\n  finish_test\n  return\n}\nhexio_write test.db 28 00000000\n\ndo_test bigfile-1.2 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\n\n# The previous test may fail on some systems because they are unable\n# to handle large files.  If that is so, then skip all of the following\n# tests.  We will know the above test failed because the \"db\" command\n# does not exist.\n#\nif {[llength [info command db]]<=0} {\n  puts \"**** Large file support appears to be broken. *****\"\n  finish_test\n  return\n}\n\ndo_test bigfile-1.3 {\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    SELECT md5sum(x) FROM t2;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.4 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\n\ndb close\nif {[catch {fake_big_file 8192 [get_pwd]/test.db}]} {\n  puts \"**** Unable to create a file larger than 8192 MB. *****\"\n  finish_test\n  return\n}\nhexio_write test.db 28 00000000\n\ndo_test bigfile-1.5 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.6 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t2;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.7 {\n  execsql {\n    CREATE TABLE t3 AS SELECT * FROM t1;\n    SELECT md5sum(x) FROM t3;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.8 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.9 {\n  execsql {\n    SELECT md5sum(x) FROM t2;\n  }\n} $::MAGIC_SUM\n\ndb close\nif {[catch {fake_big_file 16384 [get_pwd]/test.db}]} {\n  puts \"**** Unable to create a file larger than 16384 MB. *****\"\n  finish_test\n  return\n}\nhexio_write test.db 28 00000000\n\ndo_test bigfile-1.10 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.11 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t2;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.12 {\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t3;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.13 {\n  execsql {\n    CREATE TABLE t4 AS SELECT * FROM t1;\n    SELECT md5sum(x) FROM t4;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.14 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT md5sum(x) FROM t1;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.15 {\n  execsql {\n    SELECT md5sum(x) FROM t2;\n  }\n} $::MAGIC_SUM\ndo_test bigfile-1.16 {\n  execsql {\n    SELECT md5sum(x) FROM t3;\n  }\n} $::MAGIC_SUM\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bigfile2.test",
    "content": "# 2011 December 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the ability of SQLite to handle database\n# files larger than 4GB.\n#\n\nif {[file exists skip-big-file]} return\nif {$tcl_platform(os)==\"Darwin\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bigfile2\n\n# Create a small database.\n#\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n}\n\n# Pad the file out to 4GB in size. Then clear the file-size field in the\n# db header. This will cause SQLite to assume that the first 4GB of pages\n# are actually in use and new pages will be appended to the file.\n#\ndb close\nif {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {\n  puts \"**** Unable to create a file larger than 4096 MB. *****\"\n  finish_test\n  return\n}\nhexio_write test.db 28 00000000\n\ndo_test 1.2 {\n  file size test.db\n} [expr 14 + 4096 * (1<<20)]\n\n# Now insert a large row. The overflow pages will be located past the 4GB\n# boundary. Then, after opening and closing the database, test that the row\n# can be read back in. \n# \nset str [string repeat k 30000]\ndo_test 1.3 {\n  sqlite3 db test.db\n  execsql { INSERT INTO t1 VALUES(3, $str) }\n  db close\n  sqlite3 db test.db\n  db one { SELECT b FROM t1 WHERE a = 3 }\n} $str\n\ndb close\ndelete_file test.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bigmmap.test",
    "content": "# 2017 August 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the ability of SQLite to use mmap\n# to access files larger than 4GiB.\n#\n\nif {[file exists skip-big-file]} return\nif {$tcl_platform(os)==\"Darwin\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bigmmap\n\nifcapable !mmap||!vtab {\n  finish_test\n  return\n}\n\nset mmap_limit 0\ndb eval { \n  SELECT compile_options AS x FROM pragma_compile_options \n  WHERE x LIKE 'max_mmap_size=%' \n} {\n  regexp {MAX_MMAP_SIZE=([0-9]*)} $x -> mmap_limit\n}\nif {$mmap_limit < [expr 8 * 1<<30]} {\n  puts \"Skipping bigmmap.test - requires SQLITE_MAX_MMAP_SIZE >= 8G\"\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------------\n# Create the database file roughly 8GiB in size. Most pages are unused,\n# except that there is a table and index clustered around each 1GiB\n# boundary.\n#\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 4096;\n  CREATE TABLE t0(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));\n  WITH  s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )\n  INSERT INTO t0 SELECT i, 't0', randomblob(800) FROM s;\n}\n\nfor {set i 1} {$i < 8} {incr i} {\n  fake_big_file [expr $i*1024] [get_pwd]/test.db\n  hexio_write test.db 28 [format %.8x [expr ($i*1024*1024*1024/4096) - 5]]\n\n  do_execsql_test 1.$i \"\n    CREATE TABLE t$i (a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));\n    WITH  s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s LIMIT 100 )\n      INSERT INTO t$i SELECT i, 't$i', randomblob(800) FROM s;\n  \"\n}\n\n#-------------------------------------------------------------------------\n# Check that data can be retrieved from the db with a variety of \n# configured mmap size limits.\n#\nfor {set i 0} {$i < 9} {incr i} {\n\n  # Configure a memory mapping $i GB in size.\n  #\n  set val [expr $i*1024*1024*1024]\n  execsql \"PRAGMA main.mmap_size = $val\"\n  do_execsql_test 2.$i.0 {\n    PRAGMA main.mmap_size\n  } $val\n\n  for {set t 0} {$t < 8} {incr t} {\n    do_execsql_test 2.$i.$t.1 \"\n      SELECT count(*) FROM t$t;\n      SELECT count(b || c) FROM t$t GROUP BY b;\n    \" {100 100}\n  \n    do_execsql_test 2.$i.$t.2 \"\n      SELECT * FROM t$t AS o WHERE \n        NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )\n      ORDER BY b, c;\n    \" {}\n    \n    do_eqp_test 2.$i.$t.3 \"\n      SELECT * FROM t$t AS o WHERE \n        NOT EXISTS( SELECT * FROM t$t AS i WHERE a=o.a AND +b=o.b AND +c=o.c )\n      ORDER BY b, c;\n    \" \"\n      0 0 0 {SCAN TABLE t$t AS o USING COVERING INDEX sqlite_autoindex_t${t}_1}\n      0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 1}\n      1 0 0 {SEARCH TABLE t$t AS i USING INTEGER PRIMARY KEY (rowid=?)}\n    \"\n  }\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bigrow.test",
    "content": "# 2001 September 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is stressing the library by putting large amounts\n# of data in a single row of a table.\n#\n# $Id: bigrow.test,v 1.5 2004/08/07 23:54:48 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Make a big string that we can use for test data\n#\ndo_test bigrow-1.0 {\n  set ::bigstr {}\n  for {set i 1} {$i<=9999} {incr i} {\n    set sep [string index \"abcdefghijklmnopqrstuvwxyz\" [expr {$i%26}]]\n    append ::bigstr \"$sep [format %04d $i] \"\n  }\n  string length $::bigstr\n} {69993}\n\n# Make a table into which we can insert some but records.\n#\ndo_test bigrow-1.1 {\n  execsql {\n    CREATE TABLE t1(a text, b text, c text);\n    SELECT name FROM sqlite_master\n      WHERE type='table' OR type='index'\n      ORDER BY name\n  }\n} {t1}\n\ndo_test bigrow-1.2 {\n  set ::big1 [string range $::bigstr 0 65519]\n  set sql \"INSERT INTO t1 VALUES('abc',\"\n  append sql \"'$::big1', 'xyz');\"\n  execsql $sql\n  execsql {SELECT a, c FROM t1}\n} {abc xyz}\ndo_test bigrow-1.3 {\n  execsql {SELECT b FROM t1}\n} [list $::big1]\ndo_test bigrow-1.4 {\n  set ::big2 [string range $::bigstr 0 65520]\n  set sql \"INSERT INTO t1 VALUES('abc2',\"\n  append sql \"'$::big2', 'xyz2');\"\n  set r [catch {execsql $sql} msg]\n  lappend r $msg\n} {0 {}}\ndo_test bigrow-1.4.1 {\n  execsql {SELECT b FROM t1 ORDER BY c}\n} [list $::big1 $::big2]\ndo_test bigrow-1.4.2 {\n  execsql {SELECT c FROM t1 ORDER BY c}\n} {xyz xyz2}\ndo_test bigrow-1.4.3 {\n  execsql {DELETE FROM t1 WHERE a='abc2'}\n  execsql {SELECT c FROM t1}\n} {xyz}\n\ndo_test bigrow-1.5 {\n  execsql {\n    UPDATE t1 SET a=b, b=a;\n    SELECT b,c FROM t1\n  }\n} {abc xyz}\ndo_test bigrow-1.6 {\n  execsql {\n    SELECT * FROM t1\n  }\n} [list $::big1 abc xyz]\ndo_test bigrow-1.7 {\n  execsql {\n    INSERT INTO t1 VALUES('1','2','3');\n    INSERT INTO t1 VALUES('A','B','C');\n    SELECT b FROM t1 WHERE a=='1';\n  }\n} {2}\ndo_test bigrow-1.8 {\n  execsql \"SELECT b FROM t1 WHERE a=='$::big1'\"\n} {abc}\ndo_test bigrow-1.9 {\n  execsql \"SELECT b FROM t1 WHERE a!='$::big1' ORDER BY a\"\n} {2 B}\n\n# Try doing some indexing on big columns\n#\ndo_test bigrow-2.1 {\n  execsql {\n    CREATE INDEX i1 ON t1(a)\n  }\n  execsql \"SELECT b FROM t1 WHERE a=='$::big1'\"\n} {abc}\ndo_test bigrow-2.2 {\n  execsql {\n    UPDATE t1 SET a=b, b=a\n  }\n  execsql \"SELECT b FROM t1 WHERE a=='abc'\"\n} [list $::big1]\ndo_test bigrow-2.3 {\n  execsql {\n    UPDATE t1 SET a=b, b=a\n  }\n  execsql \"SELECT b FROM t1 WHERE a=='$::big1'\"\n} {abc}\ncatch {unset ::bigstr}\ncatch {unset ::big1}\ncatch {unset ::big2}\n\n# Mosts of the tests above were created back when rows were limited in\n# size to 64K.  Now rows can be much bigger.  Test that logic.  Also\n# make sure things work correctly at the transition boundries between\n# row sizes of 256 to 257 bytes and from 65536 to 65537 bytes.\n#\n# We begin by testing the 256..257 transition.\n#\ndo_test bigrow-3.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 30 hi}\ndo_test bigrow-3.2 {\n  execsql {\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 240 hi}\nfor {set i 1} {$i<10} {incr i} {\n  do_test bigrow-3.3.$i {\n    execsql \"UPDATE t1 SET b=b||'$i'\"\n    execsql {SELECT a,length(b),c FROM t1}\n  } \"one [expr {240+$i}] hi\"\n}\n\n# Now test the 65536..65537 row-size transition.\n#\ndo_test bigrow-4.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 30 hi}\ndo_test bigrow-4.2 {\n  execsql {\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n    UPDATE t1 SET b=b||b;\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 122880 hi}\ndo_test bigrow-4.3 {\n  execsql {\n    UPDATE t1 SET b=substr(b,1,65515)\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 65515 hi}\nfor {set i 1} {$i<10} {incr i} {\n  do_test bigrow-4.4.$i {\n    execsql \"UPDATE t1 SET b=b||'$i'\"\n    execsql {SELECT a,length(b),c FROM t1}\n  } \"one [expr {65515+$i}] hi\"\n}\n\n# Check to make sure the library recovers safely if a row contains\n# too much data.\n#\ndo_test bigrow-5.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c) VALUES('one','abcdefghijklmnopqrstuvwxyz0123','hi');\n  }\n  execsql {SELECT a,length(b),c FROM t1}\n} {one 30 hi}\nset i 1\nfor {set sz 60} {$sz<1048560} {incr sz $sz} {\n  do_test bigrow-5.2.$i {\n    execsql {\n      UPDATE t1 SET b=b||b;\n      SELECT a,length(b),c FROM t1;\n    }\n  } \"one $sz hi\"\n  incr i\n}\ndo_test bigrow-5.3 {\n  catchsql {UPDATE t1 SET b=b||b}\n} {0 {}}\ndo_test bigrow-5.4 {\n  execsql {SELECT length(b) FROM t1}\n} 1966080\ndo_test bigrow-5.5 {\n  catchsql {UPDATE t1 SET b=b||b}\n} {0 {}}\ndo_test bigrow-5.6 {\n  execsql {SELECT length(b) FROM t1}\n} 3932160\ndo_test bigrow-5.99 {\n  execsql {DROP TABLE t1}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bigsort.test",
    "content": "# 2014 November 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix bigsort\n\n#--------------------------------------------------------------------\n# At one point there was an overflow problem if the product of the \n# cache-size and page-size was larger than 2^31. Causing an infinite \n# loop if the product was also an integer multiple of 2^32, or \n# inefficiency otherwise.\n#\n# This test causes thrashing on machines with smaller amounts of\n# memory.  Make sure the host has at least 8GB available before running\n# this test.\n#\nif {[catch {exec free | grep Mem:} out] || [lindex $out 1]<8000000} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a, b);\n  BEGIN;\n  WITH data(x,y) AS (\n    SELECT 1, zeroblob(10000)\n    UNION ALL\n    SELECT x+1, y FROM data WHERE x < 300000\n  )\n  INSERT INTO t1 SELECT * FROM data;\n  COMMIT;\n}\ndo_execsql_test 1.1 {\n  PRAGMA cache_size = 4194304;\n  CREATE INDEX i1 ON t1(a, b);\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bind.test",
    "content": "# 2003 September 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the sqlite_bind API.\n#\n# $Id: bind.test,v 1.48 2009/07/22 07:27:57 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc sqlite_step {stmt N VALS COLS} {\n  upvar VALS vals\n  upvar COLS cols\n  set vals [list]\n  set cols [list]\n\n  set rc [sqlite3_step $stmt]\n  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {\n    lappend cols [sqlite3_column_name $stmt $i]\n  }\n  for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {\n    lappend vals [sqlite3_column_text $stmt $i]\n  }\n\n  return $rc\n}\n\ndo_test bind-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  execsql {CREATE TABLE t1(a,b,c);}\n  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL]\n  set TAIL\n} {}\ndo_test bind-1.1.1 {\n  sqlite3_bind_parameter_count $VM\n} 3\ndo_test bind-1.1.2 {\n  sqlite3_bind_parameter_name $VM 1\n} {:1}\ndo_test bind-1.1.3 {\n  sqlite3_bind_parameter_name $VM 2\n} {}\ndo_test bind-1.1.4 {\n  sqlite3_bind_parameter_name $VM 3\n} {:abc}\ndo_test bind-1.2 {\n  sqlite_step $VM N VALUES COLNAMES\n} {SQLITE_DONE}\ndo_test bind-1.3 {\n  execsql {SELECT rowid, * FROM t1}\n} {1 {} {} {}}\ndo_test bind-1.4 {\n  sqlite3_reset $VM\n  sqlite_bind $VM 1 {test value 1} normal\n  sqlite_step $VM N VALUES COLNAMES\n} SQLITE_DONE\ndo_test bind-1.5 {\n  execsql {SELECT rowid, * FROM t1}\n} {1 {} {} {} 2 {test value 1} {} {}}\ndo_test bind-1.6 {\n  sqlite3_reset $VM\n  sqlite_bind $VM 3 {'test value 2'} normal\n  sqlite_step $VM N VALUES COLNAMES\n} SQLITE_DONE\ndo_test bind-1.7 {\n  execsql {SELECT rowid, * FROM t1}\n} {1 {} {} {} 2 {test value 1} {} {} 3 {test value 1} {} {'test value 2'}}\ndo_test bind-1.8 {\n  sqlite3_reset $VM\n  set sqlite_static_bind_value 123\n  sqlite_bind $VM 1 {} static\n  sqlite_bind $VM 2 {abcdefg} normal\n  sqlite_bind $VM 3 {} null\n  execsql {DELETE FROM t1}\n  sqlite_step $VM N VALUES COLNAMES\n  execsql {SELECT rowid, * FROM t1}\n} {1 123 abcdefg {}}\ndo_test bind-1.9 {\n  sqlite3_reset $VM\n  sqlite_bind $VM 1 {456} normal\n  sqlite_step $VM N VALUES COLNAMES\n  execsql {SELECT rowid, * FROM t1}\n} {1 123 abcdefg {} 2 456 abcdefg {}}\n\ndo_test bind-1.10 {\n   set rc [catch {\n     sqlite3_prepare db {INSERT INTO t1 VALUES($abc:123,?,:abc)} -1 TAIL\n   } msg]\n   lappend rc $msg\n} {1 {(1) near \":123\": syntax error}}\ndo_test bind-1.11 {\n   set rc [catch {\n     sqlite3_prepare db {INSERT INTO t1 VALUES(@abc:xyz,?,:abc)} -1 TAIL\n   } msg]\n   lappend rc $msg\n} {1 {(1) near \":xyz\": syntax error}}\n\ndo_test bind-1.99 {\n  sqlite3_finalize $VM\n} SQLITE_OK\n\n# Prepare the statement in different ways depending on whether or not\n# the $var processing is compiled into the library.\n#\nifcapable {tclvar} {\n  do_test bind-2.1 {\n    execsql {\n      DELETE FROM t1;\n    }\n    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES($one,$::two,$x(-z-))}\\\n            -1 TX]\n    set TX\n  } {}\n  set v1 {$one}\n  set v2 {$::two}\n  set v3 {$x(-z-)}\n}\nifcapable {!tclvar} {\n  do_test bind-2.1 {\n    execsql {\n      DELETE FROM t1;\n    }\n    set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:one,:two,:_)} -1 TX]\n    set TX\n  } {}\n  set v1 {:one}\n  set v2 {:two}\n  set v3 {:_}\n}\n\ndo_test bind-2.1.1 {\n  sqlite3_bind_parameter_count $VM\n} 3\ndo_test bind-2.1.2 {\n  sqlite3_bind_parameter_name $VM 1\n} $v1\ndo_test bind-2.1.3 {\n  sqlite3_bind_parameter_name $VM 2\n} $v2\ndo_test bind-2.1.4 {\n  sqlite3_bind_parameter_name $VM 3\n} $v3\ndo_test bind-2.1.5 {\n  sqlite3_bind_parameter_index $VM $v1\n} 1\ndo_test bind-2.1.6 {\n  sqlite3_bind_parameter_index $VM $v2\n} 2\ndo_test bind-2.1.7 {\n  sqlite3_bind_parameter_index $VM $v3\n} 3\ndo_test bind-2.1.8 {\n  sqlite3_bind_parameter_index $VM {:hi}\n} 0\n\n# 32 bit Integers\ndo_test bind-2.2 {\n  sqlite3_bind_int $VM 1 123\n  sqlite3_bind_int $VM 2 456\n  sqlite3_bind_int $VM 3 789\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT rowid, * FROM t1}\n} {1 123 456 789}\ndo_test bind-2.3 {\n  sqlite3_bind_int $VM 2 -2000000000\n  sqlite3_bind_int $VM 3 2000000000\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT rowid, * FROM t1}\n} {1 123 456 789 2 123 -2000000000 2000000000}\ndo_test bind-2.4 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {integer integer integer integer integer integer}\ndo_test bind-2.5 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# 64 bit Integers\ndo_test bind-3.1 {\n  sqlite3_bind_int64 $VM 1 32\n  sqlite3_bind_int64 $VM 2 -2000000000000\n  sqlite3_bind_int64 $VM 3 2000000000000\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT rowid, * FROM t1}\n} {1 32 -2000000000000 2000000000000}\ndo_test bind-3.2 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {integer integer integer}\ndo_test bind-3.3 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# Doubles\ndo_test bind-4.1 {\n  sqlite3_bind_double $VM 1 1234.1234\n  sqlite3_bind_double $VM 2 0.00001\n  sqlite3_bind_double $VM 3 123456789\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  set x [execsql {SELECT rowid, * FROM t1}]\n  regsub {1e-005} $x {1e-05} y\n  set y\n} {1 1234.1234 1e-05 123456789.0}\ndo_test bind-4.2 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {real real real}\ndo_test bind-4.3 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\ndo_test bind-4.4 {\n  sqlite3_bind_double $VM 1 NaN\n  sqlite3_bind_double $VM 2 1e300\n  sqlite3_bind_double $VM 3 -1e-300\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  set x [execsql {SELECT rowid, * FROM t1}]\n  regsub {1e-005} $x {1e-05} y\n  set y\n} {1 {} 1e+300 -1e-300}\ndo_test bind-4.5 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {null real real}\ndo_test bind-4.6 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# NULL\ndo_test bind-5.1 {\n  sqlite3_bind_null $VM 1\n  sqlite3_bind_null $VM 2\n  sqlite3_bind_null $VM 3 \n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT rowid, * FROM t1}\n} {1 {} {} {}}\ndo_test bind-5.2 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {null null null}\ndo_test bind-5.3 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# UTF-8 text\ndo_test bind-6.1 {\n  sqlite3_bind_text $VM 1 hellothere 5\n  sqlite3_bind_text $VM 2 \"..\" 1\n  sqlite3_bind_text $VM 3 world\\000 -1\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT rowid, * FROM t1}\n} {1 hello . world}\ndo_test bind-6.2 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {text text text}\ndo_test bind-6.3 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# Make sure zeros in a string work.\n#\ndo_test bind-6.4 {\n  db eval {DELETE FROM t1}\n  sqlite3_bind_text $VM 1 hello\\000there\\000 12\n  sqlite3_bind_text $VM 2 hello\\000there\\000 11\n  sqlite3_bind_text $VM 3 hello\\000there\\000 -1\n  sqlite_step $VM N VALUES COLNAMES\n  sqlite3_reset $VM\n  execsql {SELECT * FROM t1}\n} {hello hello hello}\nset enc [db eval {PRAGMA encoding}]\nif {$enc==\"UTF-8\" || $enc==\"\"} {\n  do_test bind-6.5 {\n    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}\n  } {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}\n} elseif {$enc==\"UTF-16le\"} {\n  do_test bind-6.5 {\n    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}\n  } {680065006C006C006F000000740068006500720065000000 680065006C006C006F00000074006800650072006500 680065006C006C006F00}\n} elseif {$enc==\"UTF-16be\"} {\n  do_test bind-6.5 {\n    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}\n  } {00680065006C006C006F0000007400680065007200650000 00680065006C006C006F000000740068006500720065 00680065006C006C006F}\n} else {\n  do_test bind-6.5 {\n    set \"Unknown database encoding: $::enc\"\n  } {}\n}\ndo_test bind-6.6 {\n  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n} {text text text}\ndo_test bind-6.7 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\n\n# UTF-16 text\nifcapable {utf16} {\n  do_test bind-7.1 {\n    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hellothere] 10\n    sqlite3_bind_text16 $VM 2 [encoding convertto unicode \"\"] 0\n    sqlite3_bind_text16 $VM 3 [encoding convertto unicode world] 10\n    sqlite_step $VM N VALUES COLNAMES\n    sqlite3_reset $VM\n    execsql {SELECT rowid, * FROM t1}\n  } {1 hello {} world}\n  do_test bind-7.2 {\n    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n  } {text text text}\n  do_test bind-7.3 {\n    db eval {DELETE FROM t1}\n    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\\000yall\\000] 16\n    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\\000yall\\000] 14\n    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\\000yall\\000] -1\n    sqlite_step $VM N VALUES COLNAMES\n    sqlite3_reset $VM\n    execsql {SELECT * FROM t1}\n  } {hi hi hi}\n  if {$enc==\"UTF-8\"} {\n    do_test bind-7.4 {\n      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}\n    } {68690079616C6C00 68690079616C6C 6869}\n  } elseif {$enc==\"UTF-16le\"} {\n    do_test bind-7.4 {\n      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}\n    } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}\n  } elseif {$enc==\"UTF-16be\"} {\n    do_test bind-7.4 {\n      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}\n    } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}\n  }\n  do_test bind-7.5 {\n    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}\n  } {text text text}\n}\ndo_test bind-7.99 {\n  execsql {DELETE FROM t1;}\n} {}\n\n# Test that the 'out of range' error works.\ndo_test bind-8.1 {\n  catch { sqlite3_bind_null $VM 0 }\n} {1}\ndo_test bind-8.2 {\n  sqlite3_errmsg $DB\n} {column index out of range}\nifcapable {utf16} {\n  do_test bind-8.3 {\n    encoding convertfrom unicode [sqlite3_errmsg16 $DB]\n  } {column index out of range}\n}\ndo_test bind-8.4 {\n  sqlite3_bind_null $VM 1 \n  sqlite3_errmsg $DB\n} {not an error}\ndo_test bind-8.5 {\n  catch { sqlite3_bind_null $VM 4 }\n} {1}\ndo_test bind-8.6 {\n  sqlite3_errmsg $DB\n} {column index out of range}\nifcapable {utf16} {\n  do_test bind-8.7 {\n    encoding convertfrom unicode [sqlite3_errmsg16 $DB]\n  } {column index out of range}\n}\n\ndo_test bind-8.8 {\n  catch { sqlite3_bind_blob $VM 0 \"abc\" 3 }\n} {1}\ndo_test bind-8.9 {\n  catch { sqlite3_bind_blob $VM 4 \"abc\" 3 }\n} {1}\ndo_test bind-8.10 {\n  catch { sqlite3_bind_text $VM 0 \"abc\" 3 }\n} {1}\nifcapable {utf16} {\n  do_test bind-8.11 {\n    catch { sqlite3_bind_text16 $VM 4 \"abc\" 2 }\n  } {1}\n}\ndo_test bind-8.12 {\n  catch { sqlite3_bind_int $VM 0 5 }\n} {1}\ndo_test bind-8.13 {\n  catch { sqlite3_bind_int $VM 4 5 }\n} {1}\ndo_test bind-8.14 {\n  catch { sqlite3_bind_double $VM 0 5.0 }\n} {1}\ndo_test bind-8.15 {\n  catch { sqlite3_bind_double $VM 4 6.0 }\n} {1}\n\ndo_test bind-8.99 {\n  sqlite3_finalize $VM\n} SQLITE_OK\n\nset iMaxVar $SQLITE_MAX_VARIABLE_NUMBER\nset zError \"(1) variable number must be between ?1 and ?$iMaxVar\"\ndo_test bind-9.1 {\n  execsql {\n    CREATE TABLE t2(a,b,c,d,e,f);\n  }\n  set rc [catch {\n    sqlite3_prepare $DB {\n      INSERT INTO t2(a) VALUES(?0)\n    } -1 TAIL\n  } msg]\n  lappend rc $msg\n} [list 1 $zError]\ndo_test bind-9.2 {\n  set rc [catch {\n    sqlite3_prepare $DB \"INSERT INTO t2(a) VALUES(?[expr $iMaxVar+1])\" -1 TAIL\n  } msg]\n  lappend rc $msg\n} [list 1 $zError]\ndo_test bind-9.3.1 {\n  set VM [\n    sqlite3_prepare $DB \"\n      INSERT INTO t2(a,b) VALUES(?1,?$iMaxVar)\n    \" -1 TAIL\n  ]\n  sqlite3_bind_parameter_count $VM\n} $iMaxVar\ncatch {sqlite3_finalize $VM}\ndo_test bind-9.3.2 {\n  set VM [\n    sqlite3_prepare $DB \"\n      INSERT INTO t2(a,b) VALUES(?2,?[expr $iMaxVar - 1])\n    \" -1 TAIL\n  ]\n  sqlite3_bind_parameter_count $VM\n} [expr {$iMaxVar - 1}]\ncatch {sqlite3_finalize $VM}\ndo_test bind-9.4 {\n  set VM [\n    sqlite3_prepare $DB \"\n      INSERT INTO t2(a,b,c,d) VALUES(?1,?[expr $iMaxVar - 2],?,?)\n    \" -1 TAIL\n  ]\n  sqlite3_bind_parameter_count $VM\n} $iMaxVar\ndo_test bind-9.5 {\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM [expr $iMaxVar - 2] 999\n  sqlite3_bind_int $VM [expr $iMaxVar - 1] 1000\n  sqlite3_bind_int $VM $iMaxVar 1001\n  sqlite3_step $VM\n} SQLITE_DONE\ndo_test bind-9.6 {\n  sqlite3_finalize $VM\n} SQLITE_OK\ndo_test bind-9.7 {\n  execsql {SELECT * FROM t2}\n} {1 999 1000 1001 {} {}}\n\nifcapable {tclvar} {\n  do_test bind-10.1 {\n    set VM [\n      sqlite3_prepare $DB {\n        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,$abc,:abc,$ab,$abc,:abc)\n      } -1 TAIL\n    ]\n    sqlite3_bind_parameter_count $VM\n  } 3\n  set v1 {$abc}\n  set v2 {$ab}\n}\nifcapable {!tclvar} {\n  do_test bind-10.1 {\n    set VM [\n      sqlite3_prepare $DB {\n        INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,:xyz,:abc,:xy,:xyz,:abc)\n      } -1 TAIL\n    ]\n    sqlite3_bind_parameter_count $VM\n  } 3\n  set v1 {:xyz}\n  set v2 {:xy}\n}\ndo_test bind-10.2 {\n  sqlite3_bind_parameter_index $VM :abc\n} 1\ndo_test bind-10.3 {\n  sqlite3_bind_parameter_index $VM $v1\n} 2\ndo_test bind-10.4 {\n  sqlite3_bind_parameter_index $VM $v2\n} 3\ndo_test bind-10.5 {\n  sqlite3_bind_parameter_name $VM 1\n} :abc\ndo_test bind-10.6 {\n  sqlite3_bind_parameter_name $VM 2\n} $v1\ndo_test bind-10.7 {\n  sqlite3_bind_parameter_name $VM 3\n} $v2\ndo_test bind-10.7.1 {\n  sqlite3_bind_parameter_name 0 1   ;# Ignore if VM is NULL\n} {}\ndo_test bind-10.7.2 {\n  sqlite3_bind_parameter_name $VM 0 ;# Ignore if index too small\n} {}\ndo_test bind-10.7.3 {\n  sqlite3_bind_parameter_name $VM 4 ;# Ignore if index is too big\n} {}\ndo_test bind-10.8 {\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_step $VM\n} SQLITE_DONE\ndo_test bind-10.8.1 {\n  # Binding attempts after program start should fail\n  set rc [catch {\n    sqlite3_bind_int $VM 1 1\n  } msg]\n  lappend rc $msg\n} {1 {}}\ndo_test bind-10.9 {\n  sqlite3_finalize $VM\n} SQLITE_OK\ndo_test bind-10.10 {\n  execsql {SELECT * FROM t2}\n} {1 999 1000 1001 {} {} 1 2 1 3 2 1}\n\n# Ticket #918\n#\ndo_test bind-10.11 {\n  # catch {sqlite3_finalize $VM}\n  set VM [\n    sqlite3_prepare $DB {\n      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)\n    } -1 TAIL\n  ]\n  sqlite3_bind_parameter_count $VM\n} 5\ndo_test bind-10.11.1 {\n  sqlite3_bind_parameter_index 0 :xyz  ;# ignore NULL VM arguments\n} 0\ndo_test bind-10.12 {\n  sqlite3_bind_parameter_index $VM :xyz\n} 0\ndo_test bind-10.13 {\n  sqlite3_bind_parameter_index $VM {}\n} 0\ndo_test bind-10.14 {\n  sqlite3_bind_parameter_index $VM :pqr\n} 5\ndo_test bind-10.15 {\n  sqlite3_bind_parameter_index $VM ?4\n} 4\ndo_test bind-10.16 {\n  sqlite3_bind_parameter_name $VM 1\n} :abc\ndo_test bind-10.17 {\n  sqlite3_bind_parameter_name $VM 2\n} {}\ndo_test bind-10.18 {\n  sqlite3_bind_parameter_name $VM 3\n} {}\ndo_test bind-10.19 {\n  sqlite3_bind_parameter_name $VM 4\n} {?4}\ndo_test bind-10.20 {\n  sqlite3_bind_parameter_name $VM 5\n} :pqr\ncatch {sqlite3_finalize $VM}\n\n# Make sure we catch an unterminated \"(\" in a Tcl-style variable name\n#\nifcapable tclvar {\n  do_test bind-11.1 {\n    catchsql {SELECT * FROM sqlite_master WHERE name=$abc(123 and sql NOT NULL;}\n  } {1 {unrecognized token: \"$abc(123\"}}\n}\n\nif {[execsql {pragma encoding}]==\"UTF-8\"} {\n  # Test the ability to bind text that contains embedded '\\000' characters.\n  # Make sure we can recover the entire input string.\n  #\n  do_test bind-12.1 {\n    execsql {\n      CREATE TABLE t3(x BLOB);\n    }\n    set VM [sqlite3_prepare $DB {INSERT INTO t3 VALUES(?)} -1 TAIL]\n    sqlite_bind  $VM 1 not-used blob10\n    sqlite3_step $VM\n    sqlite3_finalize $VM\n    execsql {\n      SELECT typeof(x), length(x), quote(x),\n             length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3\n    }\n  } {text 3 'abc' 10 X'6162630078797A007071'}\n  do_test bind-12.2 {\n    sqlite3_create_function $DB\n    execsql {\n      SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3\n    }\n  } {X'6162630078797A007071'}\n}\n\n# Test the operation of sqlite3_clear_bindings\n#\ndo_test bind-13.1 {\n  set VM [sqlite3_prepare $DB {SELECT ?,?,?} -1 TAIL]\n  sqlite3_step $VM\n  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \\\n               [sqlite3_column_type $VM 2]\n} {NULL NULL NULL}\ndo_test bind-13.2 {\n  sqlite3_reset $VM\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_step $VM\n  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \\\n               [sqlite3_column_type $VM 2]\n} {INTEGER INTEGER INTEGER}\ndo_test bind-13.3 {\n  sqlite3_reset $VM\n  sqlite3_step $VM\n  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \\\n               [sqlite3_column_type $VM 2]\n} {INTEGER INTEGER INTEGER}\ndo_test bind-13.4 {\n  sqlite3_reset $VM\n  sqlite3_clear_bindings $VM\n  sqlite3_step $VM\n  list [sqlite3_column_type $VM 0] [sqlite3_column_type $VM 1] \\\n               [sqlite3_column_type $VM 2]\n} {NULL NULL NULL}\nsqlite3_finalize $VM\n\n#--------------------------------------------------------------------\n# These tests attempt to reproduce bug #3463.\n#\nproc param_names {db zSql} {\n  set ret [list]\n  set VM [sqlite3_prepare db $zSql -1 TAIL]\n  for {set ii 1} {$ii <= [sqlite3_bind_parameter_count $VM]} {incr ii} {\n    lappend ret [sqlite3_bind_parameter_name $VM $ii]\n  }\n  sqlite3_finalize $VM\n  set ret\n}\n\ndo_test bind-14.1 {\n  param_names db { SELECT @a, @b }\n} {@a @b}\ndo_test bind-14.2 {\n  param_names db { SELECT NULL FROM (SELECT NULL) WHERE @a = @b }\n} {@a @b}\ndo_test bind-14.3 {\n  param_names db { SELECT @a FROM (SELECT NULL) WHERE 1 = @b }\n} {@a @b}\ndo_test bind-14.4 {\n  param_names db { SELECT @a, @b FROM (SELECT NULL) }\n} {@a @b}\n\n#--------------------------------------------------------------------------\n# Tests of the OP_Variable opcode where P3>1\n#\ndo_test bind-15.1 {\n  db eval {CREATE TABLE t4(a,b,c,d,e,f,g,h);}\n  set VM [sqlite3_prepare db {\n       INSERT INTO t4(a,b,c,d,f,g,h,e) VALUES(?,?,?,?,?,?,?,?)\n  } -1 TAIL]\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_bind_int $VM 4 4\n  sqlite3_bind_int $VM 5 5\n  sqlite3_bind_int $VM 6 6\n  sqlite3_bind_int $VM 7 7\n  sqlite3_bind_int $VM 8 8\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  db eval {SELECT * FROM t4}\n} {1 2 3 4 8 5 6 7}\ndo_test bind-15.2 {\n  db eval {DELETE FROM t4}\n  set VM [sqlite3_prepare db {\n       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?,?,?,?,?)\n  } -1 TAIL]\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_bind_int $VM 4 4\n  sqlite3_bind_int $VM 5 5\n  sqlite3_bind_int $VM 6 6\n  sqlite3_bind_int $VM 7 7\n  sqlite3_bind_int $VM 8 8\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  db eval {SELECT * FROM t4}\n} {1 2 3 4 5 6 7 8}\ndo_test bind-15.3 {\n  db eval {DELETE FROM t4}\n  set VM [sqlite3_prepare db {\n       INSERT INTO t4(h,g,f,e,d,c,b,a) VALUES(?,?,?,?,?,?,?,?)\n  } -1 TAIL]\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_bind_int $VM 4 4\n  sqlite3_bind_int $VM 5 5\n  sqlite3_bind_int $VM 6 6\n  sqlite3_bind_int $VM 7 7\n  sqlite3_bind_int $VM 8 8\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  db eval {SELECT * FROM t4}\n} {8 7 6 5 4 3 2 1}\ndo_test bind-15.4 {\n  db eval {DELETE FROM t4}\n  set VM [sqlite3_prepare db {\n       INSERT INTO t4(a,b,c,d,e,f,g,h) VALUES(?,?,?,?4,?,?6,?,?)\n  } -1 TAIL]\n  sqlite3_bind_int $VM 1 1\n  sqlite3_bind_int $VM 2 2\n  sqlite3_bind_int $VM 3 3\n  sqlite3_bind_int $VM 4 4\n  sqlite3_bind_int $VM 5 5\n  sqlite3_bind_int $VM 6 6\n  sqlite3_bind_int $VM 7 7\n  sqlite3_bind_int $VM 8 8\n  sqlite3_step $VM\n  sqlite3_finalize $VM\n  db eval {SELECT * FROM t4}\n} {1 2 3 4 5 6 7 8}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bindxfer.test",
    "content": "# 2005 April 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the sqlite_transfer_bindings() API.\n#\n# $Id: bindxfer.test,v 1.9 2009/04/17 11:56:28 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc sqlite_step {stmt VALS COLS} {\n  upvar #0 $VALS vals\n  upvar #0 $COLS cols\n  set vals [list]\n  set cols [list]\n\n  set rc [sqlite3_step $stmt]\n  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {\n    lappend cols [sqlite3_column_name $stmt $i]\n  }\n  for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} {\n    lappend vals [sqlite3_column_text $stmt $i]\n  }\n\n  return $rc\n}\n\ndo_test bindxfer-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  execsql {CREATE TABLE t1(a,b,c);}\n  set VM1 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]\n  set TAIL\n} {}\ndo_test bindxfer-1.2 {\n  sqlite3_bind_parameter_count $VM1\n} 3\ndo_test bindxfer-1.3 {\n  set VM2 [sqlite3_prepare $DB {SELECT ?, ?, ?} -1 TAIL]\n  set TAIL\n} {}\ndo_test bindxfer-1.4 {\n  sqlite3_bind_parameter_count $VM2\n} 3\nifcapable deprecated {\n  do_test bindxfer-1.5 {\n    sqlite_bind $VM1 1 one normal\n    set sqlite_static_bind_value two\n    sqlite_bind $VM1 2 {} static\n    sqlite_bind $VM1 3 {} null\n    sqlite3_transfer_bindings $VM1 $VM2\n    sqlite_step $VM1 VALUES COLNAMES\n  } SQLITE_ROW\n  do_test bindxfer-1.6 {\n    set VALUES\n  } {{} {} {}}\n  do_test bindxfer-1.7 {\n    sqlite_step $VM2 VALUES COLNAMES\n  } SQLITE_ROW\n  do_test bindxfer-1.8 {\n    set VALUES\n  } {one two {}}\n}\ncatch {sqlite3_finalize $VM1}\ncatch {sqlite3_finalize $VM2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/bitvec.test",
    "content": "# 2008 February 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Unit testing of the Bitvec object.\n#\n# $Id: bitvec.test,v 1.4 2009/04/01 23:49:04 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The built-in test logic must be operational in order for\n# this test to work.\nifcapable !builtin_test {\n  finish_test\n  return\n}\n\n# Test that sqlite3BitvecBuiltinTest correctly reports errors\n# that are deliberately introduced.\n#\ndo_test bitvec-1.0.1 {\n  sqlite3BitvecBuiltinTest 400 {5 1 1 1 0}\n} 1\ndo_test bitvec-1.0.2 {\n  sqlite3BitvecBuiltinTest 400 {5 1 234 1 0}\n} 234\n\n# Run test cases that set every bit in vectors of various sizes.\n# for larger cases, this should cycle the bit vector representation\n# from hashing into subbitmaps.  The subbitmaps should start as\n# hashes then change to either subbitmaps or linear maps, depending\n# on their size.\n#\ndo_test bitvec-1.1 {\n  sqlite3BitvecBuiltinTest 400 {1 400 1 1 0}\n} 0\ndo_test bitvec-1.2 {\n  sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 0}\n} 0\ndo_test bitvec-1.3 {\n  sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 0}\n} 0\ndo_test bitvec-1.4 {\n  sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 0}\n} 0\n\n# By specifying a larger increments, we spread the load around.\n#\ndo_test bitvec-1.5 {\n  sqlite3BitvecBuiltinTest 400 {1 400 1 7 0}\n} 0\ndo_test bitvec-1.6 {\n  sqlite3BitvecBuiltinTest 4000 {1 4000 1 7 0}\n} 0\ndo_test bitvec-1.7 {\n  sqlite3BitvecBuiltinTest 40000 {1 40000 1 7 0}\n} 0\ndo_test bitvec-1.8 {\n  sqlite3BitvecBuiltinTest 400000 {1 400000 1 7 0}\n} 0\n\n# First fill up the bitmap with ones,  then go through and\n# clear all the bits.  This will stress the clearing mechanism.\n#\ndo_test bitvec-1.9 {\n  sqlite3BitvecBuiltinTest 400 {1 400 1 1 2 400 1 1 0}\n} 0\ndo_test bitvec-1.10 {\n  sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 2 4000 1 1 0}\n} 0\ndo_test bitvec-1.11 {\n  sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 2 40000 1 1 0}\n} 0\ndo_test bitvec-1.12 {\n  sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 2 400000 1 1 0}\n} 0\n\ndo_test bitvec-1.13 {\n  sqlite3BitvecBuiltinTest 400 {1 400 1 1 2 400 1 7 0}\n} 0\ndo_test bitvec-1.15 {\n  sqlite3BitvecBuiltinTest 4000 {1 4000 1 1 2 4000 1 7 0}\n} 0\ndo_test bitvec-1.16 {\n  sqlite3BitvecBuiltinTest 40000 {1 40000 1 1 2 40000 1 77 0}\n} 0\ndo_test bitvec-1.17 {\n  sqlite3BitvecBuiltinTest 400000 {1 400000 1 1 2 400000 1 777 0}\n} 0\n\ndo_test bitvec-1.18 {\n  sqlite3BitvecBuiltinTest 400000 {1 5000 100000 1 2 400000 1 37 0}\n} 0\n\n# Attempt to induce hash collisions.  \n#\nunset -nocomplain start\nunset -nocomplain incr\nforeach start {1 2 3 4 5 6 7 8} {\n  foreach incr {124 125} {\n    do_test bitvec-1.20.$start.$incr {\n      set prog [list 1 60 $::start $::incr 2 5000 1 1 0]\n      sqlite3BitvecBuiltinTest 5000 $prog\n    } 0\n  }\n}\n\ndo_test bitvec-1.30.big_and_slow {\n  sqlite3BitvecBuiltinTest 17000000 {1 17000000 1 1 2 17000000 1 1 0}\n} 0\n\n\n# Test setting and clearing a random subset of bits.\n#\ndo_test bitvec-2.1 {\n  sqlite3BitvecBuiltinTest 4000 {3 2000 4 2000 0}\n} 0\ndo_test bitvec-2.2 {\n  sqlite3BitvecBuiltinTest 4000 {3 1000 4 1000 3 1000 4 1000 3 1000 4 1000\n                                 3 1000 4 1000 3 1000 4 1000 3 1000 4 1000 0}\n} 0\ndo_test bitvec-2.3 {\n  sqlite3BitvecBuiltinTest 400000 {3 10 0}\n} 0\ndo_test bitvec-2.4 {\n  sqlite3BitvecBuiltinTest 4000 {3 10 2 4000 1 1 0}\n} 0\ndo_test bitvec-2.5 {\n  sqlite3BitvecBuiltinTest 5000 {3 20 2 5000 1 1 0}\n} 0\ndo_test bitvec-2.6 {\n  sqlite3BitvecBuiltinTest 50000 {3 60 2 50000 1 1 0}\n} 0\ndo_test bitvec-2.7 {\n  sqlite3BitvecBuiltinTest 5000 {\n          1 25 121 125\n          1 50 121 125\n          2 25 121 125\n          0\n  }\n} 0\n\n# This procedure runs sqlite3BitvecBuiltinTest with argments \"n\" and\n# \"program\".  But it also causes a malloc error to occur after the\n# \"failcnt\"-th malloc.  The result should be \"0\" if no malloc failure\n# occurs or \"-1\" if there is a malloc failure.\n#\nproc bitvec_malloc_test {label failcnt n program} {\n  do_test $label [subst {\n    sqlite3_memdebug_fail $failcnt\n    set x \\[sqlite3BitvecBuiltinTest $n [list $program]\\]\n    set nFail \\[sqlite3_memdebug_fail -1\\]\n    if {\\$nFail==0} {\n      set ::go 0\n      set x -1\n    }\n    set x\n  }] -1\n}\n\n# Make sure malloc failures are handled sanily.\n#\nunset -nocomplain n\nunset -nocomplain go\nset go 1\nsave_prng_state\nfor {set n 0} {$go} {incr n} {\n  restore_prng_state\n  bitvec_malloc_test bitvec-3.1.$n $n 5000 {\n      3 60 2 5000 1 1 3 60 2 5000 1 1 3 60 2 5000 1 1 0\n  }\n}\nset go 1\nfor {set n 0} {$go} {incr n} {\n  restore_prng_state\n  bitvec_malloc_test bitvec-3.2.$n $n 5000 {\n      3 600 2 5000 1 1 3 600 2 5000 1 1 3 600 2 5000 1 1 0\n  }\n}\nset go 1\nfor {set n 1} {$go} {incr n} {\n  bitvec_malloc_test bitvec-3.3.$n $n 50000 {1 50000 1 1 0}\n}\n\nfinish_test\nreturn\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/blob.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# $Id: blob.test,v 1.8 2009/04/28 18:00:27 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!bloblit} {\n  finish_test\n  return\n}\n\nproc bin_to_hex {blob} {\n  set bytes {}\n  binary scan $blob \\c* bytes\n  set bytes2 [list]\n  foreach b $bytes {lappend bytes2 [format %02X [expr $b & 0xFF]]}\n  join $bytes2 {}\n}\n\n# Simplest possible case. Specify a blob literal\ndo_test blob-1.0 {\n  set blob [execsql {SELECT X'01020304';}]\n  bin_to_hex [lindex $blob 0]\n} {01020304}\ndo_test blob-1.1 {\n  set blob [execsql {SELECT x'ABCDEF';}]\n  bin_to_hex [lindex $blob 0]\n} {ABCDEF}\ndo_test blob-1.2 {\n  set blob [execsql {SELECT x'';}]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test blob-1.3 {\n  set blob [execsql {SELECT x'abcdEF12';}]\n  bin_to_hex [lindex $blob 0]\n} {ABCDEF12}\ndo_test blob-1.3.2 {\n  set blob [execsql {SELECT x'0123456789abcdefABCDEF';}]\n  bin_to_hex [lindex $blob 0]\n} {0123456789ABCDEFABCDEF}\n\n# Try some syntax errors in blob literals.\ndo_test blob-1.4 {\n  catchsql {SELECT X'01020k304', 100}\n} {1 {unrecognized token: \"X'01020k304'\"}}\ndo_test blob-1.5 {\n  catchsql {SELECT X'01020, 100}\n} {1 {unrecognized token: \"X'01020, 100\"}}\ndo_test blob-1.6 {\n  catchsql {SELECT X'01020 100'}\n} {1 {unrecognized token: \"X'01020 100'\"}}\ndo_test blob-1.7 {\n  catchsql {SELECT X'01001'}\n} {1 {unrecognized token: \"X'01001'\"}}\ndo_test blob-1.8 {\n  catchsql {SELECT x'012/45'}\n} {1 {unrecognized token: \"x'012/45'\"}}\ndo_test blob-1.9 {\n  catchsql {SELECT x'012:45'}\n} {1 {unrecognized token: \"x'012:45'\"}}\ndo_test blob-1.10 {\n  catchsql {SELECT x'012@45'}\n} {1 {unrecognized token: \"x'012@45'\"}}\ndo_test blob-1.11 {\n  catchsql {SELECT x'012G45'}\n} {1 {unrecognized token: \"x'012G45'\"}}\ndo_test blob-1.12 {\n  catchsql {SELECT x'012`45'}\n} {1 {unrecognized token: \"x'012`45'\"}}\ndo_test blob-1.13 {\n  catchsql {SELECT x'012g45'}\n} {1 {unrecognized token: \"x'012g45'\"}}\n\n\n# Insert a blob into a table and retrieve it.\ndo_test blob-2.0 {\n  execsql {\n    CREATE TABLE t1(a BLOB, b BLOB);\n    INSERT INTO t1 VALUES(X'123456', x'7890ab');\n    INSERT INTO t1 VALUES(X'CDEF12', x'345678');\n  }\n  set blobs [execsql {SELECT * FROM t1}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {123456 7890AB CDEF12 345678}\n\n# An index on a blob column\ndo_test blob-2.1 {\n  execsql {\n    CREATE INDEX i1 ON t1(a);\n  }\n  set blobs [execsql {SELECT * FROM t1}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {123456 7890AB CDEF12 345678}\ndo_test blob-2.2 {\n  set blobs [execsql {SELECT * FROM t1 where a = X'123456'}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {123456 7890AB}\ndo_test blob-2.3 {\n  set blobs [execsql {SELECT * FROM t1 where a = X'CDEF12'}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {CDEF12 345678}\ndo_test blob-2.4 {\n  set blobs [execsql {SELECT * FROM t1 where a = X'CD12'}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {}\n\n# Try to bind a blob value to a prepared statement.\ndo_test blob-3.0 {\n  sqlite3 db2 test.db\n  set DB [sqlite3_connection_pointer db2]\n  set STMT [sqlite3_prepare $DB \"DELETE FROM t1 WHERE a = ?\" -1 DUMMY]\n  sqlite3_bind_blob $STMT 1 \"\\x12\\x34\\x56\" 3\n  sqlite3_step $STMT\n} {SQLITE_DONE}\ndo_test blob-3.1 {\n  sqlite3_finalize $STMT\n  db2 close\n} {}\ndo_test blob-3.2 {\n  set blobs [execsql {SELECT * FROM t1}]\n  set blobs2 [list]\n  foreach b $blobs {lappend blobs2 [bin_to_hex $b]}\n  set blobs2\n} {CDEF12 345678}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary1.tcl",
    "content": "puts {# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary1.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n}\n\nexpr srand(0)\n\n# Generate interesting boundary numbers\n#\nforeach x {\n  0\n  1\n  0x7f\n  0x7fff\n  0x7fffff\n  0x7fffffff\n  0x7fffffffff\n  0x7fffffffffff\n  0x7fffffffffffff\n  0x7fffffffffffffff\n} {\n  set x [expr {wide($x)}]\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set boundarynum([expr {-($x+1)}]) 1\n  set boundarynum([expr {-($x+2)}]) 1\n  set boundarynum([expr {$x+$x+1}]) 1\n  set boundarynum([expr {$x+$x+2}]) 1\n}\nset x [expr {wide(127)}]\nfor {set i 1} {$i<=9} {incr i} {\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set x [expr {wide($x*128 + 127)}]\n}\n\n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# A simple selection sort.  Not trying to be efficient.\n#\nproc sort {inlist} {\n  set outlist {}\n  set mn [lindex $inlist 0]\n  foreach x $inlist {\n    if {$x<$mn} {set mn $x}\n  }\n  set outlist $mn\n  set mx $mn\n  while {1} {\n    set valid 0\n    foreach x $inlist {\n      if {$x>$mx && (!$valid || $mn>$x)} {\n        set mn $x\n        set valid 1\n      }\n    }\n    if {!$valid} break\n    lappend outlist $mn\n    set mx $mn\n  }\n  return $outlist\n}\n\n# Reverse the order of a list\n#\nproc reverse {inlist} {\n  set i [llength $inlist]\n  set outlist {}\n  for {incr i -1} {$i>=0} {incr i -1} {\n    lappend outlist [lindex $inlist $i]\n  }\n  return $outlist\n}\n\nset nums1 [scramble [array names boundarynum]]\nset nums2 [scramble [array names boundarynum]]\n\nset tname boundary1\nputs \"do_test $tname-1.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t1(a,x);\"\nset a 0\nforeach r $nums1 {\n  incr a\n  set t1ra($r) $a\n  set t1ar($a) $r\n  set x [format %08x%08x [expr {wide($r)>>32}] $r]\n  set t1rx($r) $x\n  set t1xr($x) $r\n  puts \"    INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');\"\n}\nputs \"    CREATE INDEX t1i1 ON t1(a);\"\nputs \"    CREATE INDEX t1i2 ON t1(x);\"\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nputs \"do_test $tname-1.2 \\173\"\nputs \"  db eval \\173\"\nputs \"    SELECT count(*) FROM t1\"\nputs \"  \\175\"\nputs \"\\175 {64}\"\n\nset nums3 $nums2\nlappend nums3 9.22337303685477580800e+18\nlappend nums3 -9.22337303685477580800e+18\n\nset i 0\nforeach r $nums3 {\n  incr i\n\n  if {abs($r)<9.22337203685477580800e+18} {\n    set x $t1rx($r)\n    set a $t1ra($r)\n    set r5 $r.5\n    set r0 $r.0\n    puts \"do_test $tname-2.$i.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT * FROM t1 WHERE rowid=$r\"\n    puts \"  \\175\"\n    puts \"\\175 {$a $x}\"\n    puts \"do_test $tname-2.$i.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT rowid, a FROM t1 WHERE x='$x'\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a}\"\n    puts \"do_test $tname-2.$i.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT rowid, x FROM t1 WHERE a=$a\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $x}\"\n  }\n\n  foreach op {> >= < <=} subno {gt ge lt le} {\n\n    ################################################################ 2.x.y.1\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r\" {\n        lappend rset $rx\n        lappend aset $t1ra($rx)\n      }\n    }\n    puts \"do_test $tname-2.$i.$subno.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r ORDER BY a\"\n    puts \"  \\175\"\n    puts \"\\175 {[sort $aset]}\"\n  \n    ################################################################ 2.x.y.2\n    puts \"do_test $tname-2.$i.$subno.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r ORDER BY a DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {[reverse [sort $aset]]}\"\n  \n    ################################################################ 2.x.y.3\n    set aset {}\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r ORDER BY rowid\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.4\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.4 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r ORDER BY rowid DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.5\n    set aset {}\n    set xset {}\n    foreach rx $rset {\n      lappend xset $t1rx($rx)\n    }\n    foreach x [sort $xset] {\n      set rx $t1xr($x)\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.5 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r ORDER BY x\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.10\n    if {abs($r)>9223372036854775808 || [string length $r5]>15} continue\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r0\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.10 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r0 ORDER BY rowid\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.11\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.11 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r0 ORDER BY rowid DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n\n\n    ################################################################ 2.x.y.12\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r5\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.12 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r5 ORDER BY rowid\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.13\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.13 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE rowid $op $r5 ORDER BY rowid DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  }\n  \n}\n\n\nputs {finish_test}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary1.test",
    "content": "# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary1.test,v 1.2 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n\ndo_test boundary1-1.1 {\n  db eval {\n    CREATE TABLE t1(a,x);\n    INSERT INTO t1(oid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(127,4,'000000000000007f');\n    INSERT INTO t1(oid,a,x) VALUES(3,5,'0000000000000003');\n    INSERT INTO t1(oid,a,x) VALUES(16777216,6,'0000000001000000');\n    INSERT INTO t1(oid,a,x) VALUES(4398046511103,7,'000003ffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(16383,8,'0000000000003fff');\n    INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710655,10,'0000ffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483648,11,'ffffffff80000000');\n    INSERT INTO t1(oid,a,x) VALUES(268435455,12,'000000000fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(562949953421311,13,'0001ffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(4294967295,14,'00000000ffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(2097151,15,'00000000001fffff');\n    INSERT INTO t1(oid,a,x) VALUES(16384,16,'0000000000004000');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927935,17,'00ffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(8388607,18,'00000000007fffff');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627776,19,'0000010000000000');\n    INSERT INTO t1(oid,a,x) VALUES(2147483647,20,'000000007fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355329,21,'ffff7fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(34359738368,22,'0000000800000000');\n    INSERT INTO t1(oid,a,x) VALUES(32767,23,'0000000000007fff');\n    INSERT INTO t1(oid,a,x) VALUES(8388608,24,'0000000000800000');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355327,25,'00007fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710656,26,'0001000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963967,27,'007fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927936,28,'0100000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-32769,29,'ffffffffffff7fff');\n    INSERT INTO t1(oid,a,x) VALUES(255,30,'00000000000000ff');\n    INSERT INTO t1(oid,a,x) VALUES(4,31,'0000000000000004');\n    INSERT INTO t1(oid,a,x) VALUES(-32768,32,'ffffffffffff8000');\n    INSERT INTO t1(oid,a,x) VALUES(-2,33,'fffffffffffffffe');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');\n    INSERT INTO t1(oid,a,x) VALUES(4294967296,36,'0000000100000000');\n    INSERT INTO t1(oid,a,x) VALUES(-8388608,37,'ffffffffff800000');\n    INSERT INTO t1(oid,a,x) VALUES(-1,38,'ffffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(34359738367,39,'00000007ffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(268435456,40,'0000000010000000');\n    INSERT INTO t1(oid,a,x) VALUES(2,41,'0000000000000002');\n    INSERT INTO t1(oid,a,x) VALUES(2097152,42,'0000000000200000');\n    INSERT INTO t1(oid,a,x) VALUES(562949953421312,43,'0002000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355328,44,'ffff800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963968,45,'0080000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(549755813887,46,'0000007fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483649,47,'ffffffff7fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(65535,48,'000000000000ffff');\n    INSERT INTO t1(oid,a,x) VALUES(128,49,'0000000000000080');\n    INSERT INTO t1(oid,a,x) VALUES(32768,50,'0000000000008000');\n    INSERT INTO t1(oid,a,x) VALUES(2147483648,51,'0000000080000000');\n    INSERT INTO t1(oid,a,x) VALUES(-3,52,'fffffffffffffffd');\n    INSERT INTO t1(oid,a,x) VALUES(-128,53,'ffffffffffffff80');\n    INSERT INTO t1(oid,a,x) VALUES(-129,54,'ffffffffffffff7f');\n    INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,55,'8000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(4398046511104,56,'0000040000000000');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627775,57,'000000ffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813889,58,'ffffff7fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(0,59,'0000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(1,60,'0000000000000001');\n    INSERT INTO t1(oid,a,x) VALUES(256,61,'0000000000000100');\n    INSERT INTO t1(oid,a,x) VALUES(65536,62,'0000000000010000');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813888,63,'ffffff8000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,64,'ff80000000000000');\n    CREATE INDEX t1i1 ON t1(a);\n    CREATE INDEX t1i2 ON t1(x);\n  }\n} {}\ndo_test boundary1-1.2 {\n  db eval {\n    SELECT count(*) FROM t1\n  }\n} {64}\ndo_test boundary1-2.1.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=72057594037927935\n  }\n} {17 00ffffffffffffff}\ndo_test boundary1-2.1.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00ffffffffffffff'\n  }\n} {72057594037927935 17}\ndo_test boundary1-2.1.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=17\n  }\n} {72057594037927935 00ffffffffffffff}\ndo_test boundary1-2.1.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY a\n  }\n} {3 28}\ndo_test boundary1-2.1.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary1-2.1.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY rowid\n  }\n} {28 3}\ndo_test boundary1-2.1.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY rowid DESC\n  }\n} {3 28}\ndo_test boundary1-2.1.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927935 ORDER BY x\n  }\n} {28 3}\ndo_test boundary1-2.1.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary1-2.1.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary1-2.1.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY rowid\n  }\n} {17 28 3}\ndo_test boundary1-2.1.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY rowid DESC\n  }\n} {3 28 17}\ndo_test boundary1-2.1.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927935 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary1-2.1.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.1.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.1.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary1-2.1.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY rowid DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.1.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.1.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.1.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.1.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary1-2.1.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY rowid DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.1.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.2.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=16384\n  }\n} {16 0000000000004000}\ndo_test boundary1-2.2.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000004000'\n  }\n} {16384 16}\ndo_test boundary1-2.2.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=16\n  }\n} {16384 0000000000004000}\ndo_test boundary1-2.2.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.2.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.2.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16384 ORDER BY rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.2.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16384 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary1-2.2.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16384 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.2.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.2.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.2.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.2.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary1-2.2.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16384 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.2.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.2.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary1-2.2.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16384 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary1-2.2.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16384 ORDER BY rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.2.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.2.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.2.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.2.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary1-2.2.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.2.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.3.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=4294967296\n  }\n} {36 0000000100000000}\ndo_test boundary1-2.3.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000100000000'\n  }\n} {4294967296 36}\ndo_test boundary1-2.3.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=36\n  }\n} {4294967296 0000000100000000}\ndo_test boundary1-2.3.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary1-2.3.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.3.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.3.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary1-2.3.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967296 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.3.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary1-2.3.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.3.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.3.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary1-2.3.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967296 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.3.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.3.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.3.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary1-2.3.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.3.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.3.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.3.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.3.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary1-2.3.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.3.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.4.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=16777216\n  }\n} {6 0000000001000000}\ndo_test boundary1-2.4.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000001000000'\n  }\n} {16777216 6}\ndo_test boundary1-2.4.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=6\n  }\n} {16777216 0000000001000000}\ndo_test boundary1-2.4.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.4.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary1-2.4.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.4.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary1-2.4.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777216 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.4.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.4.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary1-2.4.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.4.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary1-2.4.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777216 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.4.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.4.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary1-2.4.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary1-2.4.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.4.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.4.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.4.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.4.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary1-2.4.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.4.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.5.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-32769\n  }\n} {29 ffffffffffff7fff}\ndo_test boundary1-2.5.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffffff7fff'\n  }\n} {-32769 29}\ndo_test boundary1-2.5.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=29\n  }\n} {-32769 ffffffffffff7fff}\ndo_test boundary1-2.5.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.5.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.5.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32769 ORDER BY rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.5.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32769 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary1-2.5.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary1-2.5.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.5.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.5.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.5.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary1-2.5.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary1-2.5.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32769 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary1-2.5.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary1-2.5.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32769 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary1-2.5.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32769 ORDER BY rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.5.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary1-2.5.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary1-2.5.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary1-2.5.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary1-2.5.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.5.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary1-2.6.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-140737488355329\n  }\n} {21 ffff7fffffffffff}\ndo_test boundary1-2.6.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffff7fffffffffff'\n  }\n} {-140737488355329 21}\ndo_test boundary1-2.6.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=21\n  }\n} {-140737488355329 ffff7fffffffffff}\ndo_test boundary1-2.6.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.6.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.6.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY rowid\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.6.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary1-2.6.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.6.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.6.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.6.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY rowid\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.6.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary1-2.6.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.6.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary1-2.6.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary1-2.6.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY rowid\n  }\n} {55 2 64}\ndo_test boundary1-2.6.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY rowid DESC\n  }\n} {64 2 55}\ndo_test boundary1-2.6.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355329 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary1-2.6.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary1-2.6.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary1-2.6.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY rowid\n  }\n} {55 2 64 21}\ndo_test boundary1-2.6.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY rowid DESC\n  }\n} {21 64 2 55}\ndo_test boundary1-2.6.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355329 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary1-2.7.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=2\n  }\n} {41 0000000000000002}\ndo_test boundary1-2.7.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000002'\n  }\n} {2 41}\ndo_test boundary1-2.7.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=41\n  }\n} {2 0000000000000002}\ndo_test boundary1-2.7.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.7.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.7.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2 ORDER BY rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.7.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary1-2.7.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.7.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.7.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.7.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2 ORDER BY rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.7.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary1-2.7.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.7.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.7.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.7.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary1-2.7.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2 ORDER BY rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.7.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.7.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.7.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.7.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary1-2.7.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2 ORDER BY rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.7.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.8.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=4\n  }\n} {31 0000000000000004}\ndo_test boundary1-2.8.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000004'\n  }\n} {4 31}\ndo_test boundary1-2.8.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=31\n  }\n} {4 0000000000000004}\ndo_test boundary1-2.8.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.8.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary1-2.8.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4 ORDER BY rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.8.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary1-2.8.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.8.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.8.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary1-2.8.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4 ORDER BY rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.8.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary1-2.8.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.8.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.8.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary1-2.8.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary1-2.8.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4 ORDER BY rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.8.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.8.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.8.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary1-2.8.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary1-2.8.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4 ORDER BY rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.8.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.9.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=562949953421311\n  }\n} {13 0001ffffffffffff}\ndo_test boundary1-2.9.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0001ffffffffffff'\n  }\n} {562949953421311 13}\ndo_test boundary1-2.9.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=13\n  }\n} {562949953421311 0001ffffffffffff}\ndo_test boundary1-2.9.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary1-2.9.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary1-2.9.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY rowid\n  }\n} {43 27 45 17 28 3}\ndo_test boundary1-2.9.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary1-2.9.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421311 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary1-2.9.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary1-2.9.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary1-2.9.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY rowid\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary1-2.9.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary1-2.9.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421311 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary1-2.9.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.9.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.9.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary1-2.9.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY rowid DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.9.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.9.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.9.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.9.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary1-2.9.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY rowid DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.9.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.10.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=256\n  }\n} {61 0000000000000100}\ndo_test boundary1-2.10.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000100'\n  }\n} {256 61}\ndo_test boundary1-2.10.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=61\n  }\n} {256 0000000000000100}\ndo_test boundary1-2.10.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.10.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 256 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.10.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 256 ORDER BY rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.10.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 256 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary1-2.10.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 256 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.10.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary1-2.10.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 256 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.10.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 256 ORDER BY rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.10.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 256 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary1-2.10.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 256 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.10.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.10.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 256 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary1-2.10.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 256 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary1-2.10.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 256 ORDER BY rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.10.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.10.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.10.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 256 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary1-2.10.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 256 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary1-2.10.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 256 ORDER BY rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.10.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.11.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=34359738368\n  }\n} {22 0000000800000000}\ndo_test boundary1-2.11.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000800000000'\n  }\n} {34359738368 22}\ndo_test boundary1-2.11.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=22\n  }\n} {34359738368 0000000800000000}\ndo_test boundary1-2.11.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary1-2.11.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.11.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.11.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary1-2.11.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738368 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.11.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary1-2.11.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.11.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.11.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary1-2.11.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738368 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.11.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.11.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.11.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary1-2.11.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.11.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.11.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.11.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.11.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary1-2.11.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.11.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.12.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=65536\n  }\n} {62 0000000000010000}\ndo_test boundary1-2.12.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000010000'\n  }\n} {65536 62}\ndo_test boundary1-2.12.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=62\n  }\n} {65536 0000000000010000}\ndo_test boundary1-2.12.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary1-2.12.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65536 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.12.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65536 ORDER BY rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.12.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65536 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary1-2.12.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65536 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.12.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary1-2.12.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.12.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.12.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary1-2.12.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65536 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.12.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.12.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65536 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.12.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65536 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary1-2.12.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65536 ORDER BY rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.12.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.12.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.12.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.12.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary1-2.12.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.12.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.13.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=268435456\n  }\n} {40 0000000010000000}\ndo_test boundary1-2.13.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000010000000'\n  }\n} {268435456 40}\ndo_test boundary1-2.13.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=40\n  }\n} {268435456 0000000010000000}\ndo_test boundary1-2.13.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary1-2.13.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary1-2.13.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.13.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary1-2.13.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435456 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.13.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.13.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary1-2.13.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.13.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary1-2.13.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435456 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.13.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.13.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.13.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary1-2.13.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.13.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.13.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.13.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.13.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary1-2.13.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.13.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.14.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-140737488355328\n  }\n} {44 ffff800000000000}\ndo_test boundary1-2.14.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffff800000000000'\n  }\n} {-140737488355328 44}\ndo_test boundary1-2.14.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=44\n  }\n} {-140737488355328 ffff800000000000}\ndo_test boundary1-2.14.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.14.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.14.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY rowid\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.14.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary1-2.14.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.14.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.14.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.14.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY rowid\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.14.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary1-2.14.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.14.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary1-2.14.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary1-2.14.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY rowid\n  }\n} {55 2 64 21}\ndo_test boundary1-2.14.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY rowid DESC\n  }\n} {21 64 2 55}\ndo_test boundary1-2.14.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -140737488355328 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary1-2.14.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary1-2.14.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary1-2.14.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY rowid\n  }\n} {55 2 64 21 44}\ndo_test boundary1-2.14.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY rowid DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary1-2.14.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -140737488355328 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary1-2.15.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=1099511627776\n  }\n} {19 0000010000000000}\ndo_test boundary1-2.15.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000010000000000'\n  }\n} {1099511627776 19}\ndo_test boundary1-2.15.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=19\n  }\n} {1099511627776 0000010000000000}\ndo_test boundary1-2.15.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.15.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary1-2.15.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.15.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary1-2.15.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627776 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.15.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.15.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.15.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.15.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary1-2.15.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627776 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.15.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.15.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.15.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary1-2.15.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.15.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.15.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.15.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.15.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary1-2.15.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.15.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.16.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.16.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.16.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.16.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.16.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9223372036854775807 ORDER BY x\n  }\n} {}\ndo_test boundary1-2.16.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY a\n  }\n} {3}\ndo_test boundary1-2.16.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary1-2.16.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY rowid\n  }\n} {3}\ndo_test boundary1-2.16.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY rowid DESC\n  }\n} {3}\ndo_test boundary1-2.16.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9223372036854775807 ORDER BY x\n  }\n} {3}\ndo_test boundary1-2.16.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.16.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.16.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary1-2.16.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY rowid DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.16.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.16.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.16.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.16.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.16.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.16.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.17.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=32768\n  }\n} {50 0000000000008000}\ndo_test boundary1-2.17.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000008000'\n  }\n} {32768 50}\ndo_test boundary1-2.17.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=50\n  }\n} {32768 0000000000008000}\ndo_test boundary1-2.17.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary1-2.17.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.17.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32768 ORDER BY rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.17.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32768 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary1-2.17.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32768 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.17.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.17.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.17.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.17.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary1-2.17.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32768 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.17.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.17.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.17.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32768 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary1-2.17.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32768 ORDER BY rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.17.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.17.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.17.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.17.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary1-2.17.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.17.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.18.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-36028797018963968\n  }\n} {64 ff80000000000000}\ndo_test boundary1-2.18.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ff80000000000000'\n  }\n} {-36028797018963968 64}\ndo_test boundary1-2.18.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=64\n  }\n} {-36028797018963968 ff80000000000000}\ndo_test boundary1-2.18.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.18.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.18.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY rowid\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.18.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary1-2.18.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.18.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.18.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.18.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY rowid\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.18.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary1-2.18.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.18.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY a\n  }\n} {2 55}\ndo_test boundary1-2.18.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary1-2.18.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY rowid\n  }\n} {55 2}\ndo_test boundary1-2.18.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY rowid DESC\n  }\n} {2 55}\ndo_test boundary1-2.18.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963968 ORDER BY x\n  }\n} {55 2}\ndo_test boundary1-2.18.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary1-2.18.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary1-2.18.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY rowid\n  }\n} {55 2 64}\ndo_test boundary1-2.18.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY rowid DESC\n  }\n} {64 2 55}\ndo_test boundary1-2.18.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963968 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary1-2.19.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=65535\n  }\n} {48 000000000000ffff}\ndo_test boundary1-2.19.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000000000000ffff'\n  }\n} {65535 48}\ndo_test boundary1-2.19.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=48\n  }\n} {65535 000000000000ffff}\ndo_test boundary1-2.19.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary1-2.19.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.19.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65535 ORDER BY rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.19.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65535 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary1-2.19.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 65535 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.19.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary1-2.19.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.19.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.19.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary1-2.19.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 65535 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.19.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.19.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.19.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65535 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary1-2.19.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65535 ORDER BY rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.19.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.19.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.19.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.19.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary1-2.19.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.19.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.20.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=4294967295\n  }\n} {14 00000000ffffffff}\ndo_test boundary1-2.20.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00000000ffffffff'\n  }\n} {4294967295 14}\ndo_test boundary1-2.20.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=14\n  }\n} {4294967295 00000000ffffffff}\ndo_test boundary1-2.20.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary1-2.20.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.20.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.20.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary1-2.20.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4294967295 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.20.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary1-2.20.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary1-2.20.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.20.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary1-2.20.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4294967295 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.20.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.20.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.20.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary1-2.20.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.20.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.20.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.20.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.20.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary1-2.20.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.20.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.21.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=1099511627775\n  }\n} {57 000000ffffffffff}\ndo_test boundary1-2.21.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000000ffffffffff'\n  }\n} {1099511627775 57}\ndo_test boundary1-2.21.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=57\n  }\n} {1099511627775 000000ffffffffff}\ndo_test boundary1-2.21.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.21.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.21.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.21.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary1-2.21.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1099511627775 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.21.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary1-2.21.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.21.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.21.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary1-2.21.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1099511627775 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.21.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.21.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.21.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary1-2.21.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.21.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.21.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.21.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.21.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary1-2.21.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.21.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.22.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-8388608\n  }\n} {37 ffffffffff800000}\ndo_test boundary1-2.22.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffff800000'\n  }\n} {-8388608 37}\ndo_test boundary1-2.22.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=37\n  }\n} {-8388608 ffffffffff800000}\ndo_test boundary1-2.22.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.22.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.22.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.22.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary1-2.22.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary1-2.22.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.22.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.22.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.22.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary1-2.22.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.22.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary1-2.22.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary1-2.22.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary1-2.22.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.22.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary1-2.22.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary1-2.22.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary1-2.22.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary1-2.22.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.22.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary1-2.23.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=549755813888\n  }\n} {35 0000008000000000}\ndo_test boundary1-2.23.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000008000000000'\n  }\n} {549755813888 35}\ndo_test boundary1-2.23.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=35\n  }\n} {549755813888 0000008000000000}\ndo_test boundary1-2.23.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary1-2.23.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.23.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.23.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary1-2.23.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813888 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.23.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary1-2.23.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.23.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.23.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary1-2.23.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813888 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.23.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.23.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.23.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary1-2.23.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.23.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.23.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.23.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.23.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary1-2.23.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.23.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.24.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=8388607\n  }\n} {18 00000000007fffff}\ndo_test boundary1-2.24.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00000000007fffff'\n  }\n} {8388607 18}\ndo_test boundary1-2.24.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=18\n  }\n} {8388607 00000000007fffff}\ndo_test boundary1-2.24.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.24.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.24.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.24.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary1-2.24.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388607 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.24.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.24.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.24.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.24.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary1-2.24.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388607 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.24.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.24.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.24.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary1-2.24.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.24.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.24.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.24.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.24.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary1-2.24.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.24.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.25.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-3\n  }\n} {52 fffffffffffffffd}\ndo_test boundary1-2.25.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='fffffffffffffffd'\n  }\n} {-3 52}\ndo_test boundary1-2.25.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=52\n  }\n} {-3 fffffffffffffffd}\ndo_test boundary1-2.25.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.25.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.25.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -3 ORDER BY rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.25.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -3 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary1-2.25.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary1-2.25.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary1-2.25.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.25.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -3 ORDER BY rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.25.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -3 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary1-2.25.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary1-2.25.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary1-2.25.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.25.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -3 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary1-2.25.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -3 ORDER BY rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.25.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary1-2.25.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.25.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.25.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -3 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary1-2.25.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -3 ORDER BY rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.25.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary1-2.26.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=0\n  }\n} {59 0000000000000000}\ndo_test boundary1-2.26.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000000'\n  }\n} {0 59}\ndo_test boundary1-2.26.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=59\n  }\n} {0 0000000000000000}\ndo_test boundary1-2.26.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary1-2.26.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 0 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.26.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 0 ORDER BY rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.26.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 0 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary1-2.26.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 0 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.26.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.26.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 0 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.26.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 0 ORDER BY rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.26.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 0 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary1-2.26.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 0 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.26.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.26.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 0 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.26.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 0 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.26.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 0 ORDER BY rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.26.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 0 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.26.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary1-2.26.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 0 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.26.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 0 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary1-2.26.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 0 ORDER BY rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.26.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 0 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.27.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-1\n  }\n} {38 ffffffffffffffff}\ndo_test boundary1-2.27.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffffffffff'\n  }\n} {-1 38}\ndo_test boundary1-2.27.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=38\n  }\n} {-1 ffffffffffffffff}\ndo_test boundary1-2.27.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.27.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.27.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -1 ORDER BY rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.27.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -1 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary1-2.27.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.27.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.27.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.27.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -1 ORDER BY rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.27.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -1 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary1-2.27.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary1-2.27.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.27.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.27.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -1 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary1-2.27.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -1 ORDER BY rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.27.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary1-2.27.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.27.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.27.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -1 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.27.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -1 ORDER BY rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.27.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.28.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-2\n  }\n} {33 fffffffffffffffe}\ndo_test boundary1-2.28.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='fffffffffffffffe'\n  }\n} {-2 33}\ndo_test boundary1-2.28.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=33\n  }\n} {-2 fffffffffffffffe}\ndo_test boundary1-2.28.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.28.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.28.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2 ORDER BY rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.28.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary1-2.28.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary1-2.28.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary1-2.28.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.28.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2 ORDER BY rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.28.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary1-2.28.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary1-2.28.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.28.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.28.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary1-2.28.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2 ORDER BY rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.28.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary1-2.28.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary1-2.28.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.28.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary1-2.28.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2 ORDER BY rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.28.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary1-2.29.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=2097152\n  }\n} {42 0000000000200000}\ndo_test boundary1-2.29.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000200000'\n  }\n} {2097152 42}\ndo_test boundary1-2.29.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=42\n  }\n} {2097152 0000000000200000}\ndo_test boundary1-2.29.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.29.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.29.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.29.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary1-2.29.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097152 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.29.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary1-2.29.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.29.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.29.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary1-2.29.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097152 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.29.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.29.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.29.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary1-2.29.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.29.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.29.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.29.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.29.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary1-2.29.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.29.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.30.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=128\n  }\n} {49 0000000000000080}\ndo_test boundary1-2.30.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000080'\n  }\n} {128 49}\ndo_test boundary1-2.30.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=49\n  }\n} {128 0000000000000080}\ndo_test boundary1-2.30.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary1-2.30.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.30.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 128 ORDER BY rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.30.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 128 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary1-2.30.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 128 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.30.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.30.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.30.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 128 ORDER BY rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.30.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 128 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary1-2.30.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 128 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.30.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.30.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary1-2.30.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 128 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary1-2.30.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 128 ORDER BY rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.30.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.30.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.30.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary1-2.30.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 128 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary1-2.30.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 128 ORDER BY rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.30.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.31.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=255\n  }\n} {30 00000000000000ff}\ndo_test boundary1-2.31.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00000000000000ff'\n  }\n} {255 30}\ndo_test boundary1-2.31.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=30\n  }\n} {255 00000000000000ff}\ndo_test boundary1-2.31.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary1-2.31.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.31.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 255 ORDER BY rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.31.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 255 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary1-2.31.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 255 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.31.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary1-2.31.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.31.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 255 ORDER BY rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.31.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 255 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary1-2.31.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 255 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.31.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.31.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary1-2.31.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 255 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary1-2.31.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 255 ORDER BY rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.31.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.31.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.31.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary1-2.31.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 255 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary1-2.31.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 255 ORDER BY rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.31.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.32.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-2147483648\n  }\n} {11 ffffffff80000000}\ndo_test boundary1-2.32.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffff80000000'\n  }\n} {-2147483648 11}\ndo_test boundary1-2.32.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=11\n  }\n} {-2147483648 ffffffff80000000}\ndo_test boundary1-2.32.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.32.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.32.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.32.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary1-2.32.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.32.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.32.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.32.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.32.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary1-2.32.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.32.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary1-2.32.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary1-2.32.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary1-2.32.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary1-2.32.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary1-2.32.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary1-2.32.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary1-2.32.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary1-2.32.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.32.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary1-2.33.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=34359738367\n  }\n} {39 00000007ffffffff}\ndo_test boundary1-2.33.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00000007ffffffff'\n  }\n} {34359738367 39}\ndo_test boundary1-2.33.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=39\n  }\n} {34359738367 00000007ffffffff}\ndo_test boundary1-2.33.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary1-2.33.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.33.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.33.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary1-2.33.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 34359738367 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.33.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary1-2.33.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary1-2.33.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.33.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary1-2.33.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 34359738367 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.33.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.33.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.33.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary1-2.33.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.33.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.33.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.33.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.33.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary1-2.33.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.33.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.34.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-549755813889\n  }\n} {58 ffffff7fffffffff}\ndo_test boundary1-2.34.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffff7fffffffff'\n  }\n} {-549755813889 58}\ndo_test boundary1-2.34.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=58\n  }\n} {-549755813889 ffffff7fffffffff}\ndo_test boundary1-2.34.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary1-2.34.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.34.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.34.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary1-2.34.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.34.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary1-2.34.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.34.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY rowid\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.34.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary1-2.34.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.34.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary1-2.34.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary1-2.34.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY rowid\n  }\n} {55 2 64 21 44}\ndo_test boundary1-2.34.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY rowid DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary1-2.34.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary1-2.34.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary1-2.34.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary1-2.34.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary1-2.34.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary1-2.34.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary1-2.35.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-32768\n  }\n} {32 ffffffffffff8000}\ndo_test boundary1-2.35.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffffff8000'\n  }\n} {-32768 32}\ndo_test boundary1-2.35.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=32\n  }\n} {-32768 ffffffffffff8000}\ndo_test boundary1-2.35.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.35.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.35.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32768 ORDER BY rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.35.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32768 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary1-2.35.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary1-2.35.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.35.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.35.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.35.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary1-2.35.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary1-2.35.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32768 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary1-2.35.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary1-2.35.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32768 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary1-2.35.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32768 ORDER BY rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.35.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary1-2.35.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary1-2.35.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.35.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary1-2.35.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.35.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary1-2.36.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=2147483647\n  }\n} {20 000000007fffffff}\ndo_test boundary1-2.36.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000000007fffffff'\n  }\n} {2147483647 20}\ndo_test boundary1-2.36.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=20\n  }\n} {2147483647 000000007fffffff}\ndo_test boundary1-2.36.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary1-2.36.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary1-2.36.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.36.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary1-2.36.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483647 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.36.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary1-2.36.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary1-2.36.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.36.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary1-2.36.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483647 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.36.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.36.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.36.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary1-2.36.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.36.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.36.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.36.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.36.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary1-2.36.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.36.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.37.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-129\n  }\n} {54 ffffffffffffff7f}\ndo_test boundary1-2.37.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffffffff7f'\n  }\n} {-129 54}\ndo_test boundary1-2.37.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=54\n  }\n} {-129 ffffffffffffff7f}\ndo_test boundary1-2.37.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary1-2.37.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.37.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -129 ORDER BY rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.37.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -129 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary1-2.37.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary1-2.37.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.37.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.37.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -129 ORDER BY rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.37.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -129 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary1-2.37.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary1-2.37.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary1-2.37.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -129 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.37.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -129 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary1-2.37.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -129 ORDER BY rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.37.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary1-2.37.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary1-2.37.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -129 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.37.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -129 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary1-2.37.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -129 ORDER BY rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.37.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary1-2.38.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-128\n  }\n} {53 ffffffffffffff80}\ndo_test boundary1-2.38.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffffffff80'\n  }\n} {-128 53}\ndo_test boundary1-2.38.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=53\n  }\n} {-128 ffffffffffffff80}\ndo_test boundary1-2.38.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary1-2.38.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.38.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -128 ORDER BY rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.38.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -128 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary1-2.38.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary1-2.38.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary1-2.38.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.38.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -128 ORDER BY rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.38.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -128 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary1-2.38.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary1-2.38.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary1-2.38.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.38.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -128 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary1-2.38.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -128 ORDER BY rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.38.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary1-2.38.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary1-2.38.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary1-2.38.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -128 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary1-2.38.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -128 ORDER BY rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.38.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary1-2.39.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=72057594037927936\n  }\n} {28 0100000000000000}\ndo_test boundary1-2.39.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0100000000000000'\n  }\n} {72057594037927936 28}\ndo_test boundary1-2.39.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=28\n  }\n} {72057594037927936 0100000000000000}\ndo_test boundary1-2.39.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY a\n  }\n} {3}\ndo_test boundary1-2.39.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary1-2.39.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY rowid\n  }\n} {3}\ndo_test boundary1-2.39.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY rowid DESC\n  }\n} {3}\ndo_test boundary1-2.39.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 72057594037927936 ORDER BY x\n  }\n} {3}\ndo_test boundary1-2.39.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY a\n  }\n} {3 28}\ndo_test boundary1-2.39.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary1-2.39.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY rowid\n  }\n} {28 3}\ndo_test boundary1-2.39.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY rowid DESC\n  }\n} {3 28}\ndo_test boundary1-2.39.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 72057594037927936 ORDER BY x\n  }\n} {28 3}\ndo_test boundary1-2.39.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.39.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.39.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary1-2.39.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY rowid DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.39.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.39.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.39.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.39.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary1-2.39.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY rowid DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.39.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.40.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=2147483648\n  }\n} {51 0000000080000000}\ndo_test boundary1-2.40.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000080000000'\n  }\n} {2147483648 51}\ndo_test boundary1-2.40.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=51\n  }\n} {2147483648 0000000080000000}\ndo_test boundary1-2.40.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary1-2.40.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary1-2.40.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.40.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary1-2.40.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2147483648 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.40.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary1-2.40.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary1-2.40.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.40.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary1-2.40.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2147483648 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.40.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.40.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.40.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary1-2.40.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.40.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.40.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.40.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.40.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary1-2.40.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.40.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.41.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=549755813887\n  }\n} {46 0000007fffffffff}\ndo_test boundary1-2.41.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000007fffffffff'\n  }\n} {549755813887 46}\ndo_test boundary1-2.41.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=46\n  }\n} {549755813887 0000007fffffffff}\ndo_test boundary1-2.41.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary1-2.41.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.41.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.41.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary1-2.41.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 549755813887 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.41.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary1-2.41.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary1-2.41.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.41.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary1-2.41.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 549755813887 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.41.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.41.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.41.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary1-2.41.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.41.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.41.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.41.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.41.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary1-2.41.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.41.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.42.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-549755813888\n  }\n} {63 ffffff8000000000}\ndo_test boundary1-2.42.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffff8000000000'\n  }\n} {-549755813888 63}\ndo_test boundary1-2.42.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=63\n  }\n} {-549755813888 ffffff8000000000}\ndo_test boundary1-2.42.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.42.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.42.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.42.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary1-2.42.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.42.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary1-2.42.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.42.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.42.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary1-2.42.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.42.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary1-2.42.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary1-2.42.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary1-2.42.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary1-2.42.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary1-2.42.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary1-2.42.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary1-2.42.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary1-2.42.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary1-2.42.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary1-2.43.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=281474976710655\n  }\n} {10 0000ffffffffffff}\ndo_test boundary1-2.43.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000ffffffffffff'\n  }\n} {281474976710655 10}\ndo_test boundary1-2.43.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=10\n  }\n} {281474976710655 0000ffffffffffff}\ndo_test boundary1-2.43.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary1-2.43.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary1-2.43.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY rowid\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary1-2.43.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary1-2.43.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710655 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary1-2.43.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary1-2.43.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary1-2.43.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY rowid\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.43.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary1-2.43.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710655 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.43.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.43.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.43.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary1-2.43.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY rowid DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.43.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.43.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.43.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.43.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary1-2.43.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY rowid DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.43.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.44.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=4398046511103\n  }\n} {7 000003ffffffffff}\ndo_test boundary1-2.44.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000003ffffffffff'\n  }\n} {4398046511103 7}\ndo_test boundary1-2.44.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=7\n  }\n} {4398046511103 000003ffffffffff}\ndo_test boundary1-2.44.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.44.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary1-2.44.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.44.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary1-2.44.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511103 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.44.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.44.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary1-2.44.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.44.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary1-2.44.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511103 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.44.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.44.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.44.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary1-2.44.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.44.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.44.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.44.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.44.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary1-2.44.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.44.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.45.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=268435455\n  }\n} {12 000000000fffffff}\ndo_test boundary1-2.45.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000000000fffffff'\n  }\n} {268435455 12}\ndo_test boundary1-2.45.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=12\n  }\n} {268435455 000000000fffffff}\ndo_test boundary1-2.45.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.45.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary1-2.45.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.45.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary1-2.45.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 268435455 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.45.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.45.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary1-2.45.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.45.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary1-2.45.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 268435455 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.45.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.45.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.45.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary1-2.45.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.45.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.45.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.45.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary1-2.45.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary1-2.45.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.45.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.46.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-9223372036854775808\n  }\n} {55 8000000000000000}\ndo_test boundary1-2.46.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='8000000000000000'\n  }\n} {-9223372036854775808 55}\ndo_test boundary1-2.46.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=55\n  }\n} {-9223372036854775808 8000000000000000}\ndo_test boundary1-2.46.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.46.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.46.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY rowid\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.46.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary1-2.46.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.46.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.46.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.46.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.46.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.46.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.46.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.46.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.46.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.46.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.46.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9223372036854775808 ORDER BY x\n  }\n} {}\ndo_test boundary1-2.46.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY a\n  }\n} {55}\ndo_test boundary1-2.46.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary1-2.46.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY rowid\n  }\n} {55}\ndo_test boundary1-2.46.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY rowid DESC\n  }\n} {55}\ndo_test boundary1-2.46.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9223372036854775808 ORDER BY x\n  }\n} {55}\ndo_test boundary1-2.47.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=562949953421312\n  }\n} {43 0002000000000000}\ndo_test boundary1-2.47.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0002000000000000'\n  }\n} {562949953421312 43}\ndo_test boundary1-2.47.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=43\n  }\n} {562949953421312 0002000000000000}\ndo_test boundary1-2.47.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary1-2.47.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary1-2.47.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY rowid\n  }\n} {27 45 17 28 3}\ndo_test boundary1-2.47.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary1-2.47.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 562949953421312 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary1-2.47.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary1-2.47.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary1-2.47.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY rowid\n  }\n} {43 27 45 17 28 3}\ndo_test boundary1-2.47.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary1-2.47.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 562949953421312 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary1-2.47.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.47.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.47.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary1-2.47.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY rowid DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.47.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.47.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.47.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.47.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary1-2.47.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY rowid DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.47.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.48.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-8388609\n  }\n} {1 ffffffffff7fffff}\ndo_test boundary1-2.48.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffffff7fffff'\n  }\n} {-8388609 1}\ndo_test boundary1-2.48.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=1\n  }\n} {-8388609 ffffffffff7fffff}\ndo_test boundary1-2.48.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.48.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.48.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.48.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary1-2.48.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.48.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.48.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.48.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.48.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary1-2.48.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.48.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary1-2.48.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary1-2.48.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary1-2.48.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.48.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary1-2.48.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary1-2.48.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary1-2.48.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary1-2.48.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.48.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary1-2.49.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=16777215\n  }\n} {9 0000000000ffffff}\ndo_test boundary1-2.49.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000ffffff'\n  }\n} {16777215 9}\ndo_test boundary1-2.49.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=9\n  }\n} {16777215 0000000000ffffff}\ndo_test boundary1-2.49.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.49.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary1-2.49.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.49.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary1-2.49.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16777215 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.49.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.49.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.49.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.49.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary1-2.49.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16777215 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.49.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.49.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.49.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary1-2.49.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.49.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.49.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.49.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary1-2.49.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary1-2.49.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.49.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.50.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=8388608\n  }\n} {24 0000000000800000}\ndo_test boundary1-2.50.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000800000'\n  }\n} {8388608 24}\ndo_test boundary1-2.50.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=24\n  }\n} {8388608 0000000000800000}\ndo_test boundary1-2.50.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.50.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.50.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.50.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary1-2.50.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 8388608 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.50.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary1-2.50.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.50.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.50.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary1-2.50.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 8388608 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.50.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.50.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.50.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary1-2.50.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.50.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.50.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.50.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.50.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary1-2.50.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.50.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.51.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=16383\n  }\n} {8 0000000000003fff}\ndo_test boundary1-2.51.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000003fff'\n  }\n} {16383 8}\ndo_test boundary1-2.51.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=8\n  }\n} {16383 0000000000003fff}\ndo_test boundary1-2.51.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16383 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.51.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.51.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16383 ORDER BY rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.51.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16383 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary1-2.51.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 16383 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.51.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.51.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.51.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.51.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary1-2.51.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 16383 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.51.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16383 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.51.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary1-2.51.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16383 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary1-2.51.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16383 ORDER BY rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.51.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.51.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.51.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary1-2.51.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary1-2.51.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.51.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.52.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=140737488355328\n  }\n} {34 0000800000000000}\ndo_test boundary1-2.52.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000800000000000'\n  }\n} {140737488355328 34}\ndo_test boundary1-2.52.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=34\n  }\n} {140737488355328 0000800000000000}\ndo_test boundary1-2.52.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary1-2.52.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary1-2.52.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY rowid\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.52.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary1-2.52.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355328 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.52.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary1-2.52.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary1-2.52.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY rowid\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.52.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary1-2.52.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355328 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.52.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.52.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.52.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary1-2.52.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY rowid DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.52.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.52.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.52.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.52.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary1-2.52.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY rowid DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.52.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.53.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=2097151\n  }\n} {15 00000000001fffff}\ndo_test boundary1-2.53.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00000000001fffff'\n  }\n} {2097151 15}\ndo_test boundary1-2.53.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=15\n  }\n} {2097151 00000000001fffff}\ndo_test boundary1-2.53.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary1-2.53.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.53.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.53.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary1-2.53.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 2097151 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.53.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary1-2.53.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.53.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.53.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary1-2.53.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 2097151 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.53.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.53.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.53.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary1-2.53.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.53.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.53.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary1-2.53.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary1-2.53.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary1-2.53.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.53.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.54.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=140737488355327\n  }\n} {25 00007fffffffffff}\ndo_test boundary1-2.54.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='00007fffffffffff'\n  }\n} {140737488355327 25}\ndo_test boundary1-2.54.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=25\n  }\n} {140737488355327 00007fffffffffff}\ndo_test boundary1-2.54.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary1-2.54.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary1-2.54.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY rowid\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.54.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary1-2.54.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 140737488355327 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.54.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary1-2.54.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary1-2.54.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY rowid\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.54.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary1-2.54.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 140737488355327 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.54.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.54.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.54.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary1-2.54.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY rowid DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.54.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.54.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.54.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.54.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary1-2.54.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY rowid DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.54.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.55.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=281474976710656\n  }\n} {26 0001000000000000}\ndo_test boundary1-2.55.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0001000000000000'\n  }\n} {281474976710656 26}\ndo_test boundary1-2.55.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=26\n  }\n} {281474976710656 0001000000000000}\ndo_test boundary1-2.55.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary1-2.55.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary1-2.55.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY rowid\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary1-2.55.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary1-2.55.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 281474976710656 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary1-2.55.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary1-2.55.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary1-2.55.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY rowid\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary1-2.55.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary1-2.55.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 281474976710656 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary1-2.55.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.55.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.55.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary1-2.55.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY rowid DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.55.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.55.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.55.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.55.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary1-2.55.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY rowid DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.55.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.56.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=32767\n  }\n} {23 0000000000007fff}\ndo_test boundary1-2.56.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000007fff'\n  }\n} {32767 23}\ndo_test boundary1-2.56.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=23\n  }\n} {32767 0000000000007fff}\ndo_test boundary1-2.56.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.56.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.56.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32767 ORDER BY rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.56.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32767 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary1-2.56.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 32767 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.56.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary1-2.56.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary1-2.56.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.56.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary1-2.56.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 32767 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.56.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.56.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.56.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32767 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary1-2.56.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32767 ORDER BY rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.56.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.56.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary1-2.56.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary1-2.56.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary1-2.56.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.56.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.57.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=127\n  }\n} {4 000000000000007f}\ndo_test boundary1-2.57.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='000000000000007f'\n  }\n} {127 4}\ndo_test boundary1-2.57.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=4\n  }\n} {127 000000000000007f}\ndo_test boundary1-2.57.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 127 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.57.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary1-2.57.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 127 ORDER BY rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.57.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 127 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary1-2.57.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 127 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.57.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 127 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.57.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary1-2.57.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 127 ORDER BY rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.57.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 127 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary1-2.57.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 127 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.57.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 127 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.57.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary1-2.57.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 127 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary1-2.57.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 127 ORDER BY rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.57.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 127 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.57.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 127 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.57.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary1-2.57.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 127 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary1-2.57.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 127 ORDER BY rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.57.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 127 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.58.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=36028797018963967\n  }\n} {27 007fffffffffffff}\ndo_test boundary1-2.58.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='007fffffffffffff'\n  }\n} {36028797018963967 27}\ndo_test boundary1-2.58.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=27\n  }\n} {36028797018963967 007fffffffffffff}\ndo_test boundary1-2.58.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary1-2.58.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary1-2.58.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY rowid\n  }\n} {45 17 28 3}\ndo_test boundary1-2.58.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY rowid DESC\n  }\n} {3 28 17 45}\ndo_test boundary1-2.58.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963967 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary1-2.58.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary1-2.58.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary1-2.58.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY rowid\n  }\n} {27 45 17 28 3}\ndo_test boundary1-2.58.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary1-2.58.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963967 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary1-2.58.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.58.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.58.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary1-2.58.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY rowid DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.58.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.58.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.58.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.58.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary1-2.58.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY rowid DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.58.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.59.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=4398046511104\n  }\n} {56 0000040000000000}\ndo_test boundary1-2.59.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000040000000000'\n  }\n} {4398046511104 56}\ndo_test boundary1-2.59.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=56\n  }\n} {4398046511104 0000040000000000}\ndo_test boundary1-2.59.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary1-2.59.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary1-2.59.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY rowid\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.59.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary1-2.59.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 4398046511104 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.59.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary1-2.59.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary1-2.59.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.59.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary1-2.59.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 4398046511104 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.59.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.59.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.59.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary1-2.59.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.59.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.59.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.59.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.59.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary1-2.59.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY rowid DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.59.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.60.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=1\n  }\n} {60 0000000000000001}\ndo_test boundary1-2.60.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000001'\n  }\n} {1 60}\ndo_test boundary1-2.60.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=60\n  }\n} {1 0000000000000001}\ndo_test boundary1-2.60.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.60.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.60.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1 ORDER BY rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.60.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary1-2.60.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 1 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.60.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary1-2.60.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.60.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1 ORDER BY rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.60.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary1-2.60.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 1 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.60.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary1-2.60.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.60.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary1-2.60.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1 ORDER BY rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.60.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 1 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.60.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.60.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.60.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary1-2.60.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1 ORDER BY rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.60.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 1 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.61.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=36028797018963968\n  }\n} {45 0080000000000000}\ndo_test boundary1-2.61.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0080000000000000'\n  }\n} {36028797018963968 45}\ndo_test boundary1-2.61.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=45\n  }\n} {36028797018963968 0080000000000000}\ndo_test boundary1-2.61.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary1-2.61.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary1-2.61.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY rowid\n  }\n} {17 28 3}\ndo_test boundary1-2.61.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY rowid DESC\n  }\n} {3 28 17}\ndo_test boundary1-2.61.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 36028797018963968 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary1-2.61.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary1-2.61.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary1-2.61.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY rowid\n  }\n} {45 17 28 3}\ndo_test boundary1-2.61.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY rowid DESC\n  }\n} {3 28 17 45}\ndo_test boundary1-2.61.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 36028797018963968 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary1-2.61.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.61.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.61.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary1-2.61.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY rowid DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.61.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.61.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.61.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary1-2.61.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary1-2.61.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY rowid DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.61.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.62.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-2147483649\n  }\n} {47 ffffffff7fffffff}\ndo_test boundary1-2.62.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ffffffff7fffffff'\n  }\n} {-2147483649 47}\ndo_test boundary1-2.62.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=47\n  }\n} {-2147483649 ffffffff7fffffff}\ndo_test boundary1-2.62.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.62.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.62.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.62.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary1-2.62.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.62.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary1-2.62.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.62.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.62.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary1-2.62.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.62.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary1-2.62.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary1-2.62.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary1-2.62.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary1-2.62.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary1-2.62.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary1-2.62.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary1-2.62.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary1-2.62.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary1-2.62.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary1-2.63.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=-36028797018963969\n  }\n} {2 ff7fffffffffffff}\ndo_test boundary1-2.63.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='ff7fffffffffffff'\n  }\n} {-36028797018963969 2}\ndo_test boundary1-2.63.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=2\n  }\n} {-36028797018963969 ff7fffffffffffff}\ndo_test boundary1-2.63.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.63.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary1-2.63.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY rowid\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.63.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary1-2.63.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.63.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.63.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.63.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY rowid\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.63.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary1-2.63.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.63.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY a\n  }\n} {55}\ndo_test boundary1-2.63.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary1-2.63.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY rowid\n  }\n} {55}\ndo_test boundary1-2.63.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY rowid DESC\n  }\n} {55}\ndo_test boundary1-2.63.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -36028797018963969 ORDER BY x\n  }\n} {55}\ndo_test boundary1-2.63.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY a\n  }\n} {2 55}\ndo_test boundary1-2.63.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary1-2.63.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY rowid\n  }\n} {55 2}\ndo_test boundary1-2.63.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY rowid DESC\n  }\n} {2 55}\ndo_test boundary1-2.63.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -36028797018963969 ORDER BY x\n  }\n} {55 2}\ndo_test boundary1-2.64.1 {\n  db eval {\n    SELECT * FROM t1 WHERE rowid=3\n  }\n} {5 0000000000000003}\ndo_test boundary1-2.64.2 {\n  db eval {\n    SELECT rowid, a FROM t1 WHERE x='0000000000000003'\n  }\n} {3 5}\ndo_test boundary1-2.64.3 {\n  db eval {\n    SELECT rowid, x FROM t1 WHERE a=5\n  }\n} {3 0000000000000003}\ndo_test boundary1-2.64.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 3 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.64.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary1-2.64.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 3 ORDER BY rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.64.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 3 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary1-2.64.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 3 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.64.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary1-2.64.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary1-2.64.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 3 ORDER BY rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.64.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 3 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary1-2.64.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 3 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.64.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 3 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.64.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary1-2.64.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 3 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary1-2.64.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 3 ORDER BY rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.64.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 3 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.64.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 3 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary1-2.64.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary1-2.64.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 3 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary1-2.64.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 3 ORDER BY rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.64.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 3 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.65.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.65.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.65.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.65.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.65.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary1-2.65.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.65.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.65.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.65.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.65.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary1-2.65.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.65.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.65.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.65.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.65.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.65.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.65.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.65.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.65.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.65.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.66.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.66.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.66.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.66.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.66.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid > -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.66.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary1-2.66.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary1-2.66.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary1-2.66.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary1-2.66.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid >= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary1-2.66.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.66.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.66.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.66.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.66.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid < -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary1-2.66.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary1-2.66.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary1-2.66.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY rowid\n  }\n} {}\ndo_test boundary1-2.66.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY rowid DESC\n  }\n} {}\ndo_test boundary1-2.66.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE rowid <= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary2.tcl",
    "content": "puts {# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary2.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n}\n\nexpr srand(0)\n\n# Generate interesting boundary numbers\n#\nforeach x {\n  0\n  1\n  0x7f\n  0x7fff\n  0x7fffff\n  0x7fffffff\n  0x7fffffffff\n  0x7fffffffffff\n  0x7fffffffffffff\n  0x7fffffffffffffff\n} {\n  set x [expr {wide($x)}]\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set boundarynum([expr {-($x+1)}]) 1\n  set boundarynum([expr {-($x+2)}]) 1\n  set boundarynum([expr {$x+$x+1}]) 1\n  set boundarynum([expr {$x+$x+2}]) 1\n}\nset x [expr {wide(127)}]\nfor {set i 1} {$i<=9} {incr i} {\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set x [expr {wide($x*128 + 127)}]\n}\n\n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# A simple selection sort.  Not trying to be efficient.\n#\nproc sort {inlist} {\n  set outlist {}\n  set mn [lindex $inlist 0]\n  foreach x $inlist {\n    if {$x<$mn} {set mn $x}\n  }\n  set outlist $mn\n  set mx $mn\n  while {1} {\n    set valid 0\n    foreach x $inlist {\n      if {$x>$mx && (!$valid || $mn>$x)} {\n        set mn $x\n        set valid 1\n      }\n    }\n    if {!$valid} break\n    lappend outlist $mn\n    set mx $mn\n  }\n  return $outlist\n}\n\n# Reverse the order of a list\n#\nproc reverse {inlist} {\n  set i [llength $inlist]\n  set outlist {}\n  for {incr i -1} {$i>=0} {incr i -1} {\n    lappend outlist [lindex $inlist $i]\n  }\n  return $outlist\n}\n\nset nums1 [scramble [array names boundarynum]]\nset nums2 [scramble [array names boundarynum]]\n\nset tname boundary2\nputs \"do_test $tname-1.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t1(r INTEGER, a INTEGER, x TEXT);\"\nset a 0\nforeach r $nums1 {\n  incr a\n  set t1ra($r) $a\n  set t1ar($a) $r\n  set x [format %08x%08x [expr {wide($r)>>32}] $r]\n  set t1rx($r) $x\n  set t1xr($x) $r\n  puts \"    INSERT INTO t1 VALUES($r,$a,'$x');\"\n}\nputs \"    CREATE INDEX t1i1 ON t1(r);\"\nputs \"    CREATE INDEX t1i2 ON t1(a);\"\nputs \"    CREATE INDEX t1i3 ON t1(x);\"\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nputs \"do_test $tname-1.2 \\173\"\nputs \"  db eval \\173\"\nputs \"    SELECT count(*) FROM t1\"\nputs \"  \\175\"\nputs \"\\175 {64}\"\n\nset nums3 $nums2\nlappend nums3 9.22337303685477580800e+18\nlappend nums3 -9.22337303685477580800e+18\n\nset i 0\nforeach r $nums3 {\n  incr i\n\n  if {abs($r)<9.22337203685477580800e+18} {\n    set x $t1rx($r)\n    set a $t1ra($r)\n    set r5 $r.5\n    set r0 $r.0\n    puts \"do_test $tname-2.$i.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT * FROM t1 WHERE r=$r\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a $x}\"\n    puts \"do_test $tname-2.$i.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT r, a FROM t1 WHERE x='$x'\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a}\"\n    puts \"do_test $tname-2.$i.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT r, x FROM t1 WHERE a=$a\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $x}\"\n  }\n\n  foreach op {> >= < <=} subno {gt ge lt le} {\n\n    ################################################################ 2.x.y.1\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r\" {\n        lappend rset $rx\n        lappend aset $t1ra($rx)\n      }\n    }\n    puts \"do_test $tname-2.$i.$subno.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY a\"\n    puts \"  \\175\"\n    puts \"\\175 {[sort $aset]}\"\n  \n    ################################################################ 2.x.y.2\n    puts \"do_test $tname-2.$i.$subno.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY a DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {[reverse [sort $aset]]}\"\n  \n    ################################################################ 2.x.y.3\n    set aset {}\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.4\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.4 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.5\n    set aset {}\n    set xset {}\n    foreach rx $rset {\n      lappend xset $t1rx($rx)\n    }\n    foreach x [sort $xset] {\n      set rx $t1xr($x)\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.5 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY x\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.10\n    if {abs($r)>9223372036854775808 || [string length $r5]>15} continue\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r0\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.10 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r0 ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.11\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.11 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r0 ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n\n\n    ################################################################ 2.x.y.12\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r5\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.12 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r5 ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.13\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.13 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r5 ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  }\n}\n\nputs \"do_test $tname-3.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    DROP INDEX t1i1;\"\nputs \"    DROP INDEX t1i2;\"\nputs \"    DROP INDEX t1i3;\"\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nset i 0\nforeach r $nums3 {\n  incr i\n\n  if {abs($r)<9.22337203685477580800e+18} {\n    set x $t1rx($r)\n    set a $t1ra($r)\n    set r5 $r.5\n    set r0 $r.0\n    puts \"do_test $tname-4.$i.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT * FROM t1 WHERE r=$r\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a $x}\"\n    puts \"do_test $tname-4.$i.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT r, a FROM t1 WHERE x='$x'\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a}\"\n    puts \"do_test $tname-4.$i.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT r, x FROM t1 WHERE a=$a\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $x}\"\n  }\n\n  foreach op {> >= < <=} subno {gt ge lt le} {\n\n    ################################################################ 2.x.y.1\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r\" {\n        lappend rset $rx\n        lappend aset $t1ra($rx)\n      }\n    }\n    puts \"do_test $tname-4.$i.$subno.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY a\"\n    puts \"  \\175\"\n    puts \"\\175 {[sort $aset]}\"\n  \n    ################################################################ 2.x.y.2\n    puts \"do_test $tname-4.$i.$subno.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY a DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {[reverse [sort $aset]]}\"\n  \n    ################################################################ 2.x.y.3\n    set aset {}\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.4\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.4 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.5\n    set aset {}\n    set xset {}\n    foreach rx $rset {\n      lappend xset $t1rx($rx)\n    }\n    foreach x [sort $xset] {\n      set rx $t1xr($x)\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.5 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r ORDER BY x\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.10\n    if {abs($r)>9223372036854775808 || [string length $r5]>15} continue\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r0\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.10 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r0 ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.11\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.11 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r0 ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n\n\n    ################################################################ 2.x.y.12\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r5\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.12 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r5 ORDER BY r\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.13\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-4.$i.$subno.13 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT a FROM t1 WHERE r $op $r5 ORDER BY r DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  }\n}\n\n\nputs {finish_test}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary2.test",
    "content": "# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary2.test,v 1.2 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n\ndo_test boundary2-1.1 {\n  db eval {\n    CREATE TABLE t1(r INTEGER, a INTEGER, x TEXT);\n    INSERT INTO t1 VALUES(-8388609,1,'ffffffffff7fffff');\n    INSERT INTO t1 VALUES(-36028797018963969,2,'ff7fffffffffffff');\n    INSERT INTO t1 VALUES(9223372036854775807,3,'7fffffffffffffff');\n    INSERT INTO t1 VALUES(127,4,'000000000000007f');\n    INSERT INTO t1 VALUES(3,5,'0000000000000003');\n    INSERT INTO t1 VALUES(16777216,6,'0000000001000000');\n    INSERT INTO t1 VALUES(4398046511103,7,'000003ffffffffff');\n    INSERT INTO t1 VALUES(16383,8,'0000000000003fff');\n    INSERT INTO t1 VALUES(16777215,9,'0000000000ffffff');\n    INSERT INTO t1 VALUES(281474976710655,10,'0000ffffffffffff');\n    INSERT INTO t1 VALUES(-2147483648,11,'ffffffff80000000');\n    INSERT INTO t1 VALUES(268435455,12,'000000000fffffff');\n    INSERT INTO t1 VALUES(562949953421311,13,'0001ffffffffffff');\n    INSERT INTO t1 VALUES(4294967295,14,'00000000ffffffff');\n    INSERT INTO t1 VALUES(2097151,15,'00000000001fffff');\n    INSERT INTO t1 VALUES(16384,16,'0000000000004000');\n    INSERT INTO t1 VALUES(72057594037927935,17,'00ffffffffffffff');\n    INSERT INTO t1 VALUES(8388607,18,'00000000007fffff');\n    INSERT INTO t1 VALUES(1099511627776,19,'0000010000000000');\n    INSERT INTO t1 VALUES(2147483647,20,'000000007fffffff');\n    INSERT INTO t1 VALUES(-140737488355329,21,'ffff7fffffffffff');\n    INSERT INTO t1 VALUES(34359738368,22,'0000000800000000');\n    INSERT INTO t1 VALUES(32767,23,'0000000000007fff');\n    INSERT INTO t1 VALUES(8388608,24,'0000000000800000');\n    INSERT INTO t1 VALUES(140737488355327,25,'00007fffffffffff');\n    INSERT INTO t1 VALUES(281474976710656,26,'0001000000000000');\n    INSERT INTO t1 VALUES(36028797018963967,27,'007fffffffffffff');\n    INSERT INTO t1 VALUES(72057594037927936,28,'0100000000000000');\n    INSERT INTO t1 VALUES(-32769,29,'ffffffffffff7fff');\n    INSERT INTO t1 VALUES(255,30,'00000000000000ff');\n    INSERT INTO t1 VALUES(4,31,'0000000000000004');\n    INSERT INTO t1 VALUES(-32768,32,'ffffffffffff8000');\n    INSERT INTO t1 VALUES(-2,33,'fffffffffffffffe');\n    INSERT INTO t1 VALUES(140737488355328,34,'0000800000000000');\n    INSERT INTO t1 VALUES(549755813888,35,'0000008000000000');\n    INSERT INTO t1 VALUES(4294967296,36,'0000000100000000');\n    INSERT INTO t1 VALUES(-8388608,37,'ffffffffff800000');\n    INSERT INTO t1 VALUES(-1,38,'ffffffffffffffff');\n    INSERT INTO t1 VALUES(34359738367,39,'00000007ffffffff');\n    INSERT INTO t1 VALUES(268435456,40,'0000000010000000');\n    INSERT INTO t1 VALUES(2,41,'0000000000000002');\n    INSERT INTO t1 VALUES(2097152,42,'0000000000200000');\n    INSERT INTO t1 VALUES(562949953421312,43,'0002000000000000');\n    INSERT INTO t1 VALUES(-140737488355328,44,'ffff800000000000');\n    INSERT INTO t1 VALUES(36028797018963968,45,'0080000000000000');\n    INSERT INTO t1 VALUES(549755813887,46,'0000007fffffffff');\n    INSERT INTO t1 VALUES(-2147483649,47,'ffffffff7fffffff');\n    INSERT INTO t1 VALUES(65535,48,'000000000000ffff');\n    INSERT INTO t1 VALUES(128,49,'0000000000000080');\n    INSERT INTO t1 VALUES(32768,50,'0000000000008000');\n    INSERT INTO t1 VALUES(2147483648,51,'0000000080000000');\n    INSERT INTO t1 VALUES(-3,52,'fffffffffffffffd');\n    INSERT INTO t1 VALUES(-128,53,'ffffffffffffff80');\n    INSERT INTO t1 VALUES(-129,54,'ffffffffffffff7f');\n    INSERT INTO t1 VALUES(-9223372036854775808,55,'8000000000000000');\n    INSERT INTO t1 VALUES(4398046511104,56,'0000040000000000');\n    INSERT INTO t1 VALUES(1099511627775,57,'000000ffffffffff');\n    INSERT INTO t1 VALUES(-549755813889,58,'ffffff7fffffffff');\n    INSERT INTO t1 VALUES(0,59,'0000000000000000');\n    INSERT INTO t1 VALUES(1,60,'0000000000000001');\n    INSERT INTO t1 VALUES(256,61,'0000000000000100');\n    INSERT INTO t1 VALUES(65536,62,'0000000000010000');\n    INSERT INTO t1 VALUES(-549755813888,63,'ffffff8000000000');\n    INSERT INTO t1 VALUES(-36028797018963968,64,'ff80000000000000');\n    CREATE INDEX t1i1 ON t1(r);\n    CREATE INDEX t1i2 ON t1(a);\n    CREATE INDEX t1i3 ON t1(x);\n  }\n} {}\ndo_test boundary2-1.2 {\n  db eval {\n    SELECT count(*) FROM t1\n  }\n} {64}\ndo_test boundary2-2.1.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=72057594037927935\n  }\n} {72057594037927935 17 00ffffffffffffff}\ndo_test boundary2-2.1.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00ffffffffffffff'\n  }\n} {72057594037927935 17}\ndo_test boundary2-2.1.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=17\n  }\n} {72057594037927935 00ffffffffffffff}\ndo_test boundary2-2.1.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a\n  }\n} {3 28}\ndo_test boundary2-2.1.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary2-2.1.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r\n  }\n} {28 3}\ndo_test boundary2-2.1.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r DESC\n  }\n} {3 28}\ndo_test boundary2-2.1.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY x\n  }\n} {28 3}\ndo_test boundary2-2.1.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary2-2.1.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary2-2.1.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r\n  }\n} {17 28 3}\ndo_test boundary2-2.1.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r DESC\n  }\n} {3 28 17}\ndo_test boundary2-2.1.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary2-2.1.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.1.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.1.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary2-2.1.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.1.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.1.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.1.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.1.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary2-2.1.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.1.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.2.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16384\n  }\n} {16384 16 0000000000004000}\ndo_test boundary2-2.2.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000004000'\n  }\n} {16384 16}\ndo_test boundary2-2.2.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=16\n  }\n} {16384 0000000000004000}\ndo_test boundary2-2.2.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.2.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.2.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY r\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.2.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary2-2.2.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.2.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.2.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.2.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY r\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.2.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary2-2.2.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.2.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.2.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary2-2.2.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary2-2.2.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY r DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.2.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.2.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.2.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.2.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary2-2.2.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY r DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.2.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.3.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4294967296\n  }\n} {4294967296 36 0000000100000000}\ndo_test boundary2-2.3.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000100000000'\n  }\n} {4294967296 36}\ndo_test boundary2-2.3.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=36\n  }\n} {4294967296 0000000100000000}\ndo_test boundary2-2.3.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary2-2.3.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.3.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.3.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary2-2.3.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.3.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-2.3.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.3.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.3.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary2-2.3.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.3.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.3.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.3.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary2-2.3.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.3.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.3.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.3.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.3.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary2-2.3.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.3.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.4.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16777216\n  }\n} {16777216 6 0000000001000000}\ndo_test boundary2-2.4.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000001000000'\n  }\n} {16777216 6}\ndo_test boundary2-2.4.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=6\n  }\n} {16777216 0000000001000000}\ndo_test boundary2-2.4.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.4.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary2-2.4.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY r\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.4.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary2-2.4.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.4.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.4.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary2-2.4.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.4.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary2-2.4.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.4.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.4.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary2-2.4.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary2-2.4.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY r DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.4.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.4.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.4.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.4.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary2-2.4.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.4.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.5.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-32769\n  }\n} {-32769 29 ffffffffffff7fff}\ndo_test boundary2-2.5.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffff7fff'\n  }\n} {-32769 29}\ndo_test boundary2-2.5.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=29\n  }\n} {-32769 ffffffffffff7fff}\ndo_test boundary2-2.5.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.5.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.5.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY r\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.5.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary2-2.5.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary2-2.5.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.5.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.5.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY r\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.5.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary2-2.5.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary2-2.5.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary2-2.5.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary2-2.5.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-2.5.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY r DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.5.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-2.5.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary2-2.5.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary2-2.5.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-2.5.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY r DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.5.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-2.6.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-140737488355329\n  }\n} {-140737488355329 21 ffff7fffffffffff}\ndo_test boundary2-2.6.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffff7fffffffffff'\n  }\n} {-140737488355329 21}\ndo_test boundary2-2.6.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=21\n  }\n} {-140737488355329 ffff7fffffffffff}\ndo_test boundary2-2.6.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.6.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.6.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.6.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary2-2.6.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.6.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.6.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.6.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.6.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary2-2.6.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.6.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary2-2.6.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary2-2.6.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r\n  }\n} {55 2 64}\ndo_test boundary2-2.6.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r DESC\n  }\n} {64 2 55}\ndo_test boundary2-2.6.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary2-2.6.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary2-2.6.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary2-2.6.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r\n  }\n} {55 2 64 21}\ndo_test boundary2-2.6.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r DESC\n  }\n} {21 64 2 55}\ndo_test boundary2-2.6.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary2-2.7.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2\n  }\n} {2 41 0000000000000002}\ndo_test boundary2-2.7.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000002'\n  }\n} {2 41}\ndo_test boundary2-2.7.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=41\n  }\n} {2 0000000000000002}\ndo_test boundary2-2.7.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.7.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.7.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY r\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.7.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary2-2.7.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.7.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.7.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.7.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY r\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.7.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary2-2.7.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.7.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.7.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.7.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary2-2.7.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY r DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.7.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.7.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.7.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.7.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary2-2.7.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY r DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.7.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.8.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4\n  }\n} {4 31 0000000000000004}\ndo_test boundary2-2.8.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000004'\n  }\n} {4 31}\ndo_test boundary2-2.8.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=31\n  }\n} {4 0000000000000004}\ndo_test boundary2-2.8.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.8.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-2.8.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY r\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.8.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary2-2.8.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.8.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.8.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-2.8.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY r\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.8.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary2-2.8.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.8.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.8.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary2-2.8.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary2-2.8.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY r DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.8.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.8.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.8.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary2-2.8.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary2-2.8.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY r DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.8.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.9.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=562949953421311\n  }\n} {562949953421311 13 0001ffffffffffff}\ndo_test boundary2-2.9.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0001ffffffffffff'\n  }\n} {562949953421311 13}\ndo_test boundary2-2.9.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=13\n  }\n} {562949953421311 0001ffffffffffff}\ndo_test boundary2-2.9.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary2-2.9.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary2-2.9.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-2.9.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary2-2.9.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-2.9.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary2-2.9.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary2-2.9.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-2.9.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary2-2.9.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-2.9.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.9.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.9.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary2-2.9.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.9.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.9.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.9.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.9.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary2-2.9.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.9.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.10.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=256\n  }\n} {256 61 0000000000000100}\ndo_test boundary2-2.10.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000100'\n  }\n} {256 61}\ndo_test boundary2-2.10.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=61\n  }\n} {256 0000000000000100}\ndo_test boundary2-2.10.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.10.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.10.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY r\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.10.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary2-2.10.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.10.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-2.10.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.10.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY r\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.10.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary2-2.10.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.10.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.10.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-2.10.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary2-2.10.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY r DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.10.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.10.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.10.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-2.10.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary2-2.10.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY r DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.10.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.11.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=34359738368\n  }\n} {34359738368 22 0000000800000000}\ndo_test boundary2-2.11.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000800000000'\n  }\n} {34359738368 22}\ndo_test boundary2-2.11.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=22\n  }\n} {34359738368 0000000800000000}\ndo_test boundary2-2.11.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-2.11.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.11.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.11.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary2-2.11.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.11.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-2.11.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.11.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.11.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary2-2.11.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.11.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.11.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.11.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary2-2.11.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.11.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.11.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.11.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.11.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary2-2.11.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.11.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.12.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=65536\n  }\n} {65536 62 0000000000010000}\ndo_test boundary2-2.12.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000010000'\n  }\n} {65536 62}\ndo_test boundary2-2.12.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=62\n  }\n} {65536 0000000000010000}\ndo_test boundary2-2.12.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-2.12.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.12.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY r\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.12.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary2-2.12.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.12.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary2-2.12.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.12.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY r\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.12.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary2-2.12.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.12.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.12.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.12.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary2-2.12.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY r DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.12.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.12.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.12.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.12.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary2-2.12.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY r DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.12.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.13.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=268435456\n  }\n} {268435456 40 0000000010000000}\ndo_test boundary2-2.13.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000010000000'\n  }\n} {268435456 40}\ndo_test boundary2-2.13.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=40\n  }\n} {268435456 0000000010000000}\ndo_test boundary2-2.13.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-2.13.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-2.13.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY r\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.13.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary2-2.13.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.13.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.13.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-2.13.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.13.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary2-2.13.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.13.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.13.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.13.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary2-2.13.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY r DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.13.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.13.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.13.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.13.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary2-2.13.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.13.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.14.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-140737488355328\n  }\n} {-140737488355328 44 ffff800000000000}\ndo_test boundary2-2.14.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffff800000000000'\n  }\n} {-140737488355328 44}\ndo_test boundary2-2.14.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=44\n  }\n} {-140737488355328 ffff800000000000}\ndo_test boundary2-2.14.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.14.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.14.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.14.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary2-2.14.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.14.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.14.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.14.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.14.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary2-2.14.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.14.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary2-2.14.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary2-2.14.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r\n  }\n} {55 2 64 21}\ndo_test boundary2-2.14.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r DESC\n  }\n} {21 64 2 55}\ndo_test boundary2-2.14.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary2-2.14.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary2-2.14.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary2-2.14.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44}\ndo_test boundary2-2.14.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary2-2.14.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary2-2.15.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1099511627776\n  }\n} {1099511627776 19 0000010000000000}\ndo_test boundary2-2.15.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000010000000000'\n  }\n} {1099511627776 19}\ndo_test boundary2-2.15.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=19\n  }\n} {1099511627776 0000010000000000}\ndo_test boundary2-2.15.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.15.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary2-2.15.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.15.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary2-2.15.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.15.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.15.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.15.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.15.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary2-2.15.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.15.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.15.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.15.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary2-2.15.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.15.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.15.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.15.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.15.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary2-2.15.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.15.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.16.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.16.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.16.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.16.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.16.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY x\n  }\n} {}\ndo_test boundary2-2.16.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a\n  }\n} {3}\ndo_test boundary2-2.16.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary2-2.16.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r\n  }\n} {3}\ndo_test boundary2-2.16.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r DESC\n  }\n} {3}\ndo_test boundary2-2.16.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY x\n  }\n} {3}\ndo_test boundary2-2.16.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.16.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.16.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary2-2.16.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.16.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.16.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.16.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.16.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.16.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.16.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.17.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=32768\n  }\n} {32768 50 0000000000008000}\ndo_test boundary2-2.17.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000008000'\n  }\n} {32768 50}\ndo_test boundary2-2.17.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=50\n  }\n} {32768 0000000000008000}\ndo_test boundary2-2.17.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary2-2.17.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.17.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY r\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.17.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary2-2.17.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.17.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.17.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.17.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY r\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.17.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary2-2.17.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.17.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.17.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.17.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary2-2.17.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY r DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.17.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.17.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.17.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.17.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary2-2.17.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY r DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.17.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.18.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-36028797018963968\n  }\n} {-36028797018963968 64 ff80000000000000}\ndo_test boundary2-2.18.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ff80000000000000'\n  }\n} {-36028797018963968 64}\ndo_test boundary2-2.18.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=64\n  }\n} {-36028797018963968 ff80000000000000}\ndo_test boundary2-2.18.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.18.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.18.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.18.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary2-2.18.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.18.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.18.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.18.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.18.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary2-2.18.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.18.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a\n  }\n} {2 55}\ndo_test boundary2-2.18.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary2-2.18.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r\n  }\n} {55 2}\ndo_test boundary2-2.18.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r DESC\n  }\n} {2 55}\ndo_test boundary2-2.18.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY x\n  }\n} {55 2}\ndo_test boundary2-2.18.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary2-2.18.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary2-2.18.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r\n  }\n} {55 2 64}\ndo_test boundary2-2.18.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r DESC\n  }\n} {64 2 55}\ndo_test boundary2-2.18.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary2-2.19.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=65535\n  }\n} {65535 48 000000000000ffff}\ndo_test boundary2-2.19.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000000ffff'\n  }\n} {65535 48}\ndo_test boundary2-2.19.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=48\n  }\n} {65535 000000000000ffff}\ndo_test boundary2-2.19.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary2-2.19.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.19.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY r\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.19.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary2-2.19.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.19.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary2-2.19.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.19.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY r\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.19.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary2-2.19.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.19.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.19.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.19.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary2-2.19.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY r DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.19.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.19.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.19.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.19.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary2-2.19.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY r DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.19.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.20.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4294967295\n  }\n} {4294967295 14 00000000ffffffff}\ndo_test boundary2-2.20.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000ffffffff'\n  }\n} {4294967295 14}\ndo_test boundary2-2.20.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=14\n  }\n} {4294967295 00000000ffffffff}\ndo_test boundary2-2.20.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-2.20.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.20.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.20.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary2-2.20.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.20.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-2.20.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-2.20.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.20.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary2-2.20.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.20.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.20.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.20.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary2-2.20.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.20.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.20.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.20.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.20.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary2-2.20.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.20.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.21.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1099511627775\n  }\n} {1099511627775 57 000000ffffffffff}\ndo_test boundary2-2.21.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000ffffffffff'\n  }\n} {1099511627775 57}\ndo_test boundary2-2.21.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=57\n  }\n} {1099511627775 000000ffffffffff}\ndo_test boundary2-2.21.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.21.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.21.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.21.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary2-2.21.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.21.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary2-2.21.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.21.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.21.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary2-2.21.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.21.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.21.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.21.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary2-2.21.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.21.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.21.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.21.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.21.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary2-2.21.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.21.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.22.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-8388608\n  }\n} {-8388608 37 ffffffffff800000}\ndo_test boundary2-2.22.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffff800000'\n  }\n} {-8388608 37}\ndo_test boundary2-2.22.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=37\n  }\n} {-8388608 ffffffffff800000}\ndo_test boundary2-2.22.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.22.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.22.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY r\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.22.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary2-2.22.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary2-2.22.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.22.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.22.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.22.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary2-2.22.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.22.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary2-2.22.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary2-2.22.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-2.22.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY r DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.22.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-2.22.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary2-2.22.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary2-2.22.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-2.22.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.22.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-2.23.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=549755813888\n  }\n} {549755813888 35 0000008000000000}\ndo_test boundary2-2.23.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000008000000000'\n  }\n} {549755813888 35}\ndo_test boundary2-2.23.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=35\n  }\n} {549755813888 0000008000000000}\ndo_test boundary2-2.23.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary2-2.23.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.23.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.23.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary2-2.23.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.23.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary2-2.23.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.23.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.23.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary2-2.23.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.23.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.23.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.23.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary2-2.23.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.23.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.23.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.23.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.23.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary2-2.23.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.23.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.24.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=8388607\n  }\n} {8388607 18 00000000007fffff}\ndo_test boundary2-2.24.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000007fffff'\n  }\n} {8388607 18}\ndo_test boundary2-2.24.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=18\n  }\n} {8388607 00000000007fffff}\ndo_test boundary2-2.24.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.24.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.24.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY r\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.24.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary2-2.24.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.24.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.24.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.24.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.24.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary2-2.24.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.24.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.24.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.24.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary2-2.24.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY r DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.24.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.24.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.24.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.24.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary2-2.24.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.24.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.25.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-3\n  }\n} {-3 52 fffffffffffffffd}\ndo_test boundary2-2.25.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='fffffffffffffffd'\n  }\n} {-3 52}\ndo_test boundary2-2.25.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=52\n  }\n} {-3 fffffffffffffffd}\ndo_test boundary2-2.25.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.25.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.25.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY r\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.25.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary2-2.25.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary2-2.25.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary2-2.25.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.25.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY r\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.25.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary2-2.25.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary2-2.25.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary2-2.25.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.25.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-2.25.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY r DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.25.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-2.25.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.25.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.25.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-2.25.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY r DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.25.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-2.26.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=0\n  }\n} {0 59 0000000000000000}\ndo_test boundary2-2.26.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000000'\n  }\n} {0 59}\ndo_test boundary2-2.26.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=59\n  }\n} {0 0000000000000000}\ndo_test boundary2-2.26.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary2-2.26.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.26.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY r\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.26.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary2-2.26.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.26.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.26.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.26.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY r\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.26.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary2-2.26.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.26.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.26.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.26.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.26.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY r DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.26.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.26.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary2-2.26.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.26.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary2-2.26.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY r DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.26.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.27.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-1\n  }\n} {-1 38 ffffffffffffffff}\ndo_test boundary2-2.27.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffffff'\n  }\n} {-1 38}\ndo_test boundary2-2.27.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=38\n  }\n} {-1 ffffffffffffffff}\ndo_test boundary2-2.27.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.27.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.27.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY r\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.27.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary2-2.27.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.27.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.27.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.27.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY r\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.27.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary2-2.27.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary2-2.27.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.27.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.27.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-2.27.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY r DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.27.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-2.27.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.27.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.27.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.27.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY r DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.27.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.28.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2\n  }\n} {-2 33 fffffffffffffffe}\ndo_test boundary2-2.28.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='fffffffffffffffe'\n  }\n} {-2 33}\ndo_test boundary2-2.28.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=33\n  }\n} {-2 fffffffffffffffe}\ndo_test boundary2-2.28.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.28.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.28.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY r\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.28.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary2-2.28.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary2-2.28.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-2.28.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.28.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY r\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.28.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary2-2.28.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary2-2.28.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.28.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.28.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-2.28.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY r DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.28.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-2.28.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-2.28.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.28.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-2.28.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY r DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.28.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-2.29.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2097152\n  }\n} {2097152 42 0000000000200000}\ndo_test boundary2-2.29.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000200000'\n  }\n} {2097152 42}\ndo_test boundary2-2.29.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=42\n  }\n} {2097152 0000000000200000}\ndo_test boundary2-2.29.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.29.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.29.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY r\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.29.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary2-2.29.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.29.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-2.29.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.29.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.29.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary2-2.29.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.29.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.29.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.29.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary2-2.29.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY r DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.29.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.29.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.29.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.29.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary2-2.29.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.29.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.30.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=128\n  }\n} {128 49 0000000000000080}\ndo_test boundary2-2.30.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000080'\n  }\n} {128 49}\ndo_test boundary2-2.30.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=49\n  }\n} {128 0000000000000080}\ndo_test boundary2-2.30.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-2.30.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.30.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY r\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.30.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary2-2.30.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.30.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.30.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.30.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY r\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.30.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary2-2.30.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.30.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.30.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-2.30.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary2-2.30.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY r DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.30.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.30.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.30.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-2.30.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary2-2.30.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY r DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.30.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.31.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=255\n  }\n} {255 30 00000000000000ff}\ndo_test boundary2-2.31.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000000000ff'\n  }\n} {255 30}\ndo_test boundary2-2.31.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=30\n  }\n} {255 00000000000000ff}\ndo_test boundary2-2.31.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-2.31.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.31.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY r\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.31.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary2-2.31.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.31.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-2.31.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.31.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY r\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.31.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary2-2.31.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.31.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.31.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-2.31.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary2-2.31.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY r DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.31.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.31.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.31.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-2.31.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary2-2.31.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY r DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.31.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.32.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2147483648\n  }\n} {-2147483648 11 ffffffff80000000}\ndo_test boundary2-2.32.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffff80000000'\n  }\n} {-2147483648 11}\ndo_test boundary2-2.32.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=11\n  }\n} {-2147483648 ffffffff80000000}\ndo_test boundary2-2.32.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.32.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.32.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.32.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary2-2.32.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.32.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.32.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.32.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.32.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary2-2.32.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.32.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary2-2.32.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary2-2.32.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-2.32.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary2-2.32.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-2.32.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary2-2.32.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary2-2.32.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-2.32.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.32.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-2.33.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=34359738367\n  }\n} {34359738367 39 00000007ffffffff}\ndo_test boundary2-2.33.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000007ffffffff'\n  }\n} {34359738367 39}\ndo_test boundary2-2.33.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=39\n  }\n} {34359738367 00000007ffffffff}\ndo_test boundary2-2.33.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-2.33.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.33.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.33.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary2-2.33.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.33.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary2-2.33.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-2.33.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.33.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary2-2.33.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.33.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.33.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.33.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary2-2.33.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.33.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.33.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.33.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.33.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary2-2.33.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.33.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.34.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-549755813889\n  }\n} {-549755813889 58 ffffff7fffffffff}\ndo_test boundary2-2.34.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffff7fffffffff'\n  }\n} {-549755813889 58}\ndo_test boundary2-2.34.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=58\n  }\n} {-549755813889 ffffff7fffffffff}\ndo_test boundary2-2.34.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary2-2.34.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.34.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.34.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary2-2.34.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.34.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-2.34.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.34.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.34.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary2-2.34.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.34.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary2-2.34.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary2-2.34.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r\n  }\n} {55 2 64 21 44}\ndo_test boundary2-2.34.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary2-2.34.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary2-2.34.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary2-2.34.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary2-2.34.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-2.34.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary2-2.34.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-2.35.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-32768\n  }\n} {-32768 32 ffffffffffff8000}\ndo_test boundary2-2.35.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffff8000'\n  }\n} {-32768 32}\ndo_test boundary2-2.35.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=32\n  }\n} {-32768 ffffffffffff8000}\ndo_test boundary2-2.35.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.35.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.35.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY r\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.35.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary2-2.35.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary2-2.35.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.35.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.35.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY r\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.35.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary2-2.35.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary2-2.35.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary2-2.35.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary2-2.35.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-2.35.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY r DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.35.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-2.35.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary2-2.35.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.35.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-2.35.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY r DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.35.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-2.36.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2147483647\n  }\n} {2147483647 20 000000007fffffff}\ndo_test boundary2-2.36.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000007fffffff'\n  }\n} {2147483647 20}\ndo_test boundary2-2.36.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=20\n  }\n} {2147483647 000000007fffffff}\ndo_test boundary2-2.36.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-2.36.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-2.36.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.36.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary2-2.36.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.36.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-2.36.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-2.36.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.36.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary2-2.36.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.36.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.36.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.36.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary2-2.36.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.36.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.36.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.36.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.36.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary2-2.36.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.36.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.37.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-129\n  }\n} {-129 54 ffffffffffffff7f}\ndo_test boundary2-2.37.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffff7f'\n  }\n} {-129 54}\ndo_test boundary2-2.37.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=54\n  }\n} {-129 ffffffffffffff7f}\ndo_test boundary2-2.37.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary2-2.37.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.37.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY r\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.37.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary2-2.37.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary2-2.37.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.37.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.37.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY r\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.37.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary2-2.37.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary2-2.37.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary2-2.37.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.37.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-2.37.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY r DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.37.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-2.37.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary2-2.37.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.37.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-2.37.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY r DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.37.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-2.38.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-128\n  }\n} {-128 53 ffffffffffffff80}\ndo_test boundary2-2.38.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffff80'\n  }\n} {-128 53}\ndo_test boundary2-2.38.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=53\n  }\n} {-128 ffffffffffffff80}\ndo_test boundary2-2.38.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary2-2.38.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.38.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY r\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.38.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary2-2.38.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary2-2.38.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary2-2.38.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.38.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY r\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.38.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary2-2.38.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary2-2.38.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary2-2.38.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.38.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-2.38.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY r DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.38.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-2.38.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary2-2.38.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-2.38.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-2.38.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY r DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.38.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-2.39.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=72057594037927936\n  }\n} {72057594037927936 28 0100000000000000}\ndo_test boundary2-2.39.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0100000000000000'\n  }\n} {72057594037927936 28}\ndo_test boundary2-2.39.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=28\n  }\n} {72057594037927936 0100000000000000}\ndo_test boundary2-2.39.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a\n  }\n} {3}\ndo_test boundary2-2.39.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary2-2.39.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r\n  }\n} {3}\ndo_test boundary2-2.39.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r DESC\n  }\n} {3}\ndo_test boundary2-2.39.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY x\n  }\n} {3}\ndo_test boundary2-2.39.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a\n  }\n} {3 28}\ndo_test boundary2-2.39.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary2-2.39.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r\n  }\n} {28 3}\ndo_test boundary2-2.39.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r DESC\n  }\n} {3 28}\ndo_test boundary2-2.39.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY x\n  }\n} {28 3}\ndo_test boundary2-2.39.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.39.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.39.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary2-2.39.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.39.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.39.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.39.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.39.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary2-2.39.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.39.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.40.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2147483648\n  }\n} {2147483648 51 0000000080000000}\ndo_test boundary2-2.40.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000080000000'\n  }\n} {2147483648 51}\ndo_test boundary2-2.40.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=51\n  }\n} {2147483648 0000000080000000}\ndo_test boundary2-2.40.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-2.40.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-2.40.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.40.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary2-2.40.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.40.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-2.40.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-2.40.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.40.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary2-2.40.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.40.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.40.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.40.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary2-2.40.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.40.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.40.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.40.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.40.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary2-2.40.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.40.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.41.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=549755813887\n  }\n} {549755813887 46 0000007fffffffff}\ndo_test boundary2-2.41.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000007fffffffff'\n  }\n} {549755813887 46}\ndo_test boundary2-2.41.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=46\n  }\n} {549755813887 0000007fffffffff}\ndo_test boundary2-2.41.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary2-2.41.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.41.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.41.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary2-2.41.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.41.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-2.41.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-2.41.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.41.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary2-2.41.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.41.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.41.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.41.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary2-2.41.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.41.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.41.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.41.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.41.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary2-2.41.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.41.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.42.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-549755813888\n  }\n} {-549755813888 63 ffffff8000000000}\ndo_test boundary2-2.42.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffff8000000000'\n  }\n} {-549755813888 63}\ndo_test boundary2-2.42.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=63\n  }\n} {-549755813888 ffffff8000000000}\ndo_test boundary2-2.42.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.42.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.42.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.42.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary2-2.42.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.42.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary2-2.42.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.42.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.42.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary2-2.42.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.42.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary2-2.42.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary2-2.42.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-2.42.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary2-2.42.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-2.42.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary2-2.42.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary2-2.42.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-2.42.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary2-2.42.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-2.43.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=281474976710655\n  }\n} {281474976710655 10 0000ffffffffffff}\ndo_test boundary2-2.43.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000ffffffffffff'\n  }\n} {281474976710655 10}\ndo_test boundary2-2.43.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=10\n  }\n} {281474976710655 0000ffffffffffff}\ndo_test boundary2-2.43.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary2-2.43.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary2-2.43.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-2.43.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary2-2.43.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-2.43.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary2-2.43.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary2-2.43.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.43.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary2-2.43.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.43.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.43.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.43.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary2-2.43.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.43.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.43.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.43.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.43.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary2-2.43.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.43.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.44.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4398046511103\n  }\n} {4398046511103 7 000003ffffffffff}\ndo_test boundary2-2.44.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000003ffffffffff'\n  }\n} {4398046511103 7}\ndo_test boundary2-2.44.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=7\n  }\n} {4398046511103 000003ffffffffff}\ndo_test boundary2-2.44.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.44.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-2.44.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.44.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary2-2.44.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.44.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.44.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary2-2.44.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.44.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary2-2.44.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.44.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.44.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.44.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary2-2.44.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.44.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.44.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.44.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.44.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary2-2.44.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.44.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.45.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=268435455\n  }\n} {268435455 12 000000000fffffff}\ndo_test boundary2-2.45.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000fffffff'\n  }\n} {268435455 12}\ndo_test boundary2-2.45.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=12\n  }\n} {268435455 000000000fffffff}\ndo_test boundary2-2.45.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.45.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-2.45.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY r\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.45.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary2-2.45.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.45.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.45.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary2-2.45.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.45.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary2-2.45.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.45.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.45.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.45.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary2-2.45.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY r DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.45.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.45.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.45.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-2.45.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary2-2.45.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.45.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.46.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-9223372036854775808\n  }\n} {-9223372036854775808 55 8000000000000000}\ndo_test boundary2-2.46.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='8000000000000000'\n  }\n} {-9223372036854775808 55}\ndo_test boundary2-2.46.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=55\n  }\n} {-9223372036854775808 8000000000000000}\ndo_test boundary2-2.46.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.46.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.46.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.46.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary2-2.46.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.46.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.46.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.46.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.46.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.46.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.46.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.46.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.46.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.46.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.46.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY x\n  }\n} {}\ndo_test boundary2-2.46.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a\n  }\n} {55}\ndo_test boundary2-2.46.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary2-2.46.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r\n  }\n} {55}\ndo_test boundary2-2.46.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r DESC\n  }\n} {55}\ndo_test boundary2-2.46.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY x\n  }\n} {55}\ndo_test boundary2-2.47.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=562949953421312\n  }\n} {562949953421312 43 0002000000000000}\ndo_test boundary2-2.47.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0002000000000000'\n  }\n} {562949953421312 43}\ndo_test boundary2-2.47.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=43\n  }\n} {562949953421312 0002000000000000}\ndo_test boundary2-2.47.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary2-2.47.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary2-2.47.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r\n  }\n} {27 45 17 28 3}\ndo_test boundary2-2.47.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary2-2.47.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary2-2.47.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary2-2.47.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary2-2.47.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-2.47.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary2-2.47.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-2.47.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.47.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.47.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary2-2.47.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.47.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.47.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.47.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.47.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary2-2.47.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.47.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.48.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-8388609\n  }\n} {-8388609 1 ffffffffff7fffff}\ndo_test boundary2-2.48.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffff7fffff'\n  }\n} {-8388609 1}\ndo_test boundary2-2.48.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=1\n  }\n} {-8388609 ffffffffff7fffff}\ndo_test boundary2-2.48.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.48.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.48.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY r\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.48.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary2-2.48.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.48.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.48.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.48.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.48.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary2-2.48.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.48.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary2-2.48.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary2-2.48.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-2.48.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY r DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.48.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-2.48.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary2-2.48.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary2-2.48.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-2.48.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.48.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-2.49.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16777215\n  }\n} {16777215 9 0000000000ffffff}\ndo_test boundary2-2.49.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000ffffff'\n  }\n} {16777215 9}\ndo_test boundary2-2.49.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=9\n  }\n} {16777215 0000000000ffffff}\ndo_test boundary2-2.49.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.49.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary2-2.49.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY r\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.49.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary2-2.49.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.49.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.49.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.49.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.49.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary2-2.49.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.49.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.49.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.49.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary2-2.49.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY r DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.49.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.49.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.49.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary2-2.49.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary2-2.49.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.49.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.50.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=8388608\n  }\n} {8388608 24 0000000000800000}\ndo_test boundary2-2.50.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000800000'\n  }\n} {8388608 24}\ndo_test boundary2-2.50.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=24\n  }\n} {8388608 0000000000800000}\ndo_test boundary2-2.50.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.50.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.50.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY r\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.50.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary2-2.50.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.50.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-2.50.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.50.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.50.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary2-2.50.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.50.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.50.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.50.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary2-2.50.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY r DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.50.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.50.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.50.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.50.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary2-2.50.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.50.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.51.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16383\n  }\n} {16383 8 0000000000003fff}\ndo_test boundary2-2.51.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000003fff'\n  }\n} {16383 8}\ndo_test boundary2-2.51.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=8\n  }\n} {16383 0000000000003fff}\ndo_test boundary2-2.51.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.51.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.51.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY r\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.51.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary2-2.51.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.51.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.51.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.51.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY r\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.51.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary2-2.51.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.51.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.51.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-2.51.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary2-2.51.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY r DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.51.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.51.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.51.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary2-2.51.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary2-2.51.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY r DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.51.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.52.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=140737488355328\n  }\n} {140737488355328 34 0000800000000000}\ndo_test boundary2-2.52.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000800000000000'\n  }\n} {140737488355328 34}\ndo_test boundary2-2.52.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=34\n  }\n} {140737488355328 0000800000000000}\ndo_test boundary2-2.52.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary2-2.52.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary2-2.52.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.52.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary2-2.52.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.52.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary2-2.52.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary2-2.52.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.52.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary2-2.52.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.52.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.52.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.52.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary2-2.52.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.52.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.52.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.52.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.52.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary2-2.52.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.52.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.53.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2097151\n  }\n} {2097151 15 00000000001fffff}\ndo_test boundary2-2.53.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000001fffff'\n  }\n} {2097151 15}\ndo_test boundary2-2.53.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=15\n  }\n} {2097151 00000000001fffff}\ndo_test boundary2-2.53.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-2.53.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.53.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY r\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.53.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary2-2.53.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.53.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-2.53.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.53.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.53.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary2-2.53.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.53.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.53.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.53.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary2-2.53.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY r DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.53.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.53.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-2.53.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-2.53.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary2-2.53.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.53.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.54.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=140737488355327\n  }\n} {140737488355327 25 00007fffffffffff}\ndo_test boundary2-2.54.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00007fffffffffff'\n  }\n} {140737488355327 25}\ndo_test boundary2-2.54.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=25\n  }\n} {140737488355327 00007fffffffffff}\ndo_test boundary2-2.54.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary2-2.54.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary2-2.54.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.54.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary2-2.54.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.54.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary2-2.54.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-2.54.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.54.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary2-2.54.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.54.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.54.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.54.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary2-2.54.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.54.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.54.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.54.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.54.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary2-2.54.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.54.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.55.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=281474976710656\n  }\n} {281474976710656 26 0001000000000000}\ndo_test boundary2-2.55.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0001000000000000'\n  }\n} {281474976710656 26}\ndo_test boundary2-2.55.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=26\n  }\n} {281474976710656 0001000000000000}\ndo_test boundary2-2.55.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary2-2.55.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary2-2.55.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-2.55.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary2-2.55.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-2.55.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary2-2.55.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary2-2.55.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-2.55.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary2-2.55.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-2.55.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.55.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.55.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary2-2.55.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.55.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.55.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.55.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.55.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary2-2.55.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.55.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.56.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=32767\n  }\n} {32767 23 0000000000007fff}\ndo_test boundary2-2.56.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000007fff'\n  }\n} {32767 23}\ndo_test boundary2-2.56.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=23\n  }\n} {32767 0000000000007fff}\ndo_test boundary2-2.56.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.56.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.56.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY r\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.56.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary2-2.56.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.56.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-2.56.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-2.56.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY r\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.56.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary2-2.56.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.56.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.56.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.56.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary2-2.56.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY r DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.56.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.56.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-2.56.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-2.56.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary2-2.56.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY r DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.56.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.57.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=127\n  }\n} {127 4 000000000000007f}\ndo_test boundary2-2.57.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000000007f'\n  }\n} {127 4}\ndo_test boundary2-2.57.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=4\n  }\n} {127 000000000000007f}\ndo_test boundary2-2.57.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.57.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-2.57.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY r\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.57.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary2-2.57.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.57.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.57.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-2.57.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY r\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.57.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary2-2.57.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.57.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.57.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary2-2.57.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary2-2.57.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY r DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.57.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.57.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.57.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-2.57.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary2-2.57.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY r DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.57.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.58.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=36028797018963967\n  }\n} {36028797018963967 27 007fffffffffffff}\ndo_test boundary2-2.58.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='007fffffffffffff'\n  }\n} {36028797018963967 27}\ndo_test boundary2-2.58.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=27\n  }\n} {36028797018963967 007fffffffffffff}\ndo_test boundary2-2.58.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary2-2.58.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary2-2.58.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r\n  }\n} {45 17 28 3}\ndo_test boundary2-2.58.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r DESC\n  }\n} {3 28 17 45}\ndo_test boundary2-2.58.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary2-2.58.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary2-2.58.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary2-2.58.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r\n  }\n} {27 45 17 28 3}\ndo_test boundary2-2.58.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary2-2.58.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary2-2.58.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.58.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.58.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary2-2.58.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.58.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.58.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.58.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.58.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary2-2.58.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.58.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.59.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4398046511104\n  }\n} {4398046511104 56 0000040000000000}\ndo_test boundary2-2.59.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000040000000000'\n  }\n} {4398046511104 56}\ndo_test boundary2-2.59.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=56\n  }\n} {4398046511104 0000040000000000}\ndo_test boundary2-2.59.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary2-2.59.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-2.59.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.59.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary2-2.59.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.59.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-2.59.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-2.59.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.59.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary2-2.59.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.59.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.59.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.59.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary2-2.59.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.59.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.59.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.59.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.59.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary2-2.59.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.59.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.60.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1\n  }\n} {1 60 0000000000000001}\ndo_test boundary2-2.60.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000001'\n  }\n} {1 60}\ndo_test boundary2-2.60.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=60\n  }\n} {1 0000000000000001}\ndo_test boundary2-2.60.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.60.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.60.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY r\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.60.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary2-2.60.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.60.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary2-2.60.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.60.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY r\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.60.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary2-2.60.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.60.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary2-2.60.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.60.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary2-2.60.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY r DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.60.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.60.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.60.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.60.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary2-2.60.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY r DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.60.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.61.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=36028797018963968\n  }\n} {36028797018963968 45 0080000000000000}\ndo_test boundary2-2.61.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0080000000000000'\n  }\n} {36028797018963968 45}\ndo_test boundary2-2.61.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=45\n  }\n} {36028797018963968 0080000000000000}\ndo_test boundary2-2.61.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary2-2.61.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary2-2.61.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r\n  }\n} {17 28 3}\ndo_test boundary2-2.61.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17}\ndo_test boundary2-2.61.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary2-2.61.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary2-2.61.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary2-2.61.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r\n  }\n} {45 17 28 3}\ndo_test boundary2-2.61.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45}\ndo_test boundary2-2.61.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary2-2.61.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.61.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.61.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary2-2.61.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.61.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.61.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.61.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-2.61.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary2-2.61.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.61.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.62.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2147483649\n  }\n} {-2147483649 47 ffffffff7fffffff}\ndo_test boundary2-2.62.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffff7fffffff'\n  }\n} {-2147483649 47}\ndo_test boundary2-2.62.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=47\n  }\n} {-2147483649 ffffffff7fffffff}\ndo_test boundary2-2.62.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.62.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.62.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.62.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary2-2.62.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.62.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-2.62.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.62.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.62.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary2-2.62.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.62.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary2-2.62.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary2-2.62.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-2.62.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary2-2.62.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-2.62.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary2-2.62.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary2-2.62.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-2.62.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary2-2.62.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-2.63.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-36028797018963969\n  }\n} {-36028797018963969 2 ff7fffffffffffff}\ndo_test boundary2-2.63.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ff7fffffffffffff'\n  }\n} {-36028797018963969 2}\ndo_test boundary2-2.63.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=2\n  }\n} {-36028797018963969 ff7fffffffffffff}\ndo_test boundary2-2.63.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.63.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-2.63.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.63.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary2-2.63.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.63.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.63.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.63.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.63.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary2-2.63.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.63.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a\n  }\n} {55}\ndo_test boundary2-2.63.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary2-2.63.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r\n  }\n} {55}\ndo_test boundary2-2.63.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r DESC\n  }\n} {55}\ndo_test boundary2-2.63.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY x\n  }\n} {55}\ndo_test boundary2-2.63.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a\n  }\n} {2 55}\ndo_test boundary2-2.63.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary2-2.63.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r\n  }\n} {55 2}\ndo_test boundary2-2.63.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r DESC\n  }\n} {2 55}\ndo_test boundary2-2.63.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY x\n  }\n} {55 2}\ndo_test boundary2-2.64.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=3\n  }\n} {3 5 0000000000000003}\ndo_test boundary2-2.64.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000003'\n  }\n} {3 5}\ndo_test boundary2-2.64.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=5\n  }\n} {3 0000000000000003}\ndo_test boundary2-2.64.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.64.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-2.64.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY r\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.64.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary2-2.64.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.64.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-2.64.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-2.64.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY r\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.64.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary2-2.64.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.64.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.64.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-2.64.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary2-2.64.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY r DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.64.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.64.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-2.64.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary2-2.64.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary2-2.64.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY r DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.64.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.65.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.65.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.65.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.65.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.65.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-2.65.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.65.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.65.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.65.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.65.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-2.65.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.65.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.65.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.65.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.65.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.65.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.65.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.65.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.65.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.65.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.66.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.66.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.66.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.66.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.66.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.66.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-2.66.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-2.66.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-2.66.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-2.66.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-2.66.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.66.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.66.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.66.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.66.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-2.66.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-2.66.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-2.66.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-2.66.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-2.66.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-3.1 {\n  db eval {\n    DROP INDEX t1i1;\n    DROP INDEX t1i2;\n    DROP INDEX t1i3;\n  }\n} {}\ndo_test boundary2-4.1.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=72057594037927935\n  }\n} {72057594037927935 17 00ffffffffffffff}\ndo_test boundary2-4.1.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00ffffffffffffff'\n  }\n} {72057594037927935 17}\ndo_test boundary2-4.1.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=17\n  }\n} {72057594037927935 00ffffffffffffff}\ndo_test boundary2-4.1.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a\n  }\n} {3 28}\ndo_test boundary2-4.1.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary2-4.1.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r\n  }\n} {28 3}\ndo_test boundary2-4.1.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY r DESC\n  }\n} {3 28}\ndo_test boundary2-4.1.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927935 ORDER BY x\n  }\n} {28 3}\ndo_test boundary2-4.1.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary2-4.1.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary2-4.1.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r\n  }\n} {17 28 3}\ndo_test boundary2-4.1.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY r DESC\n  }\n} {3 28 17}\ndo_test boundary2-4.1.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927935 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary2-4.1.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.1.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.1.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary2-4.1.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY r DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.1.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.1.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.1.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.1.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary2-4.1.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY r DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.1.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927935 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.2.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16384\n  }\n} {16384 16 0000000000004000}\ndo_test boundary2-4.2.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000004000'\n  }\n} {16384 16}\ndo_test boundary2-4.2.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=16\n  }\n} {16384 0000000000004000}\ndo_test boundary2-4.2.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.2.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.2.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY r\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.2.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary2-4.2.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16384 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.2.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.2.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.2.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY r\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.2.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary2-4.2.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16384 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.2.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.2.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary2-4.2.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary2-4.2.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY r DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.2.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.2.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.2.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.2.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary2-4.2.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY r DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.2.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16384 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.3.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4294967296\n  }\n} {4294967296 36 0000000100000000}\ndo_test boundary2-4.3.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000100000000'\n  }\n} {4294967296 36}\ndo_test boundary2-4.3.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=36\n  }\n} {4294967296 0000000100000000}\ndo_test boundary2-4.3.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary2-4.3.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.3.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.3.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary2-4.3.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967296 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.3.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-4.3.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.3.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.3.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary2-4.3.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967296 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.3.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.3.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.3.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary2-4.3.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY r DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.3.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.3.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.3.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.3.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary2-4.3.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY r DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.3.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967296 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.4.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16777216\n  }\n} {16777216 6 0000000001000000}\ndo_test boundary2-4.4.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000001000000'\n  }\n} {16777216 6}\ndo_test boundary2-4.4.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=6\n  }\n} {16777216 0000000001000000}\ndo_test boundary2-4.4.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.4.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary2-4.4.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY r\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.4.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary2-4.4.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777216 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.4.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.4.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary2-4.4.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.4.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary2-4.4.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777216 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.4.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.4.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary2-4.4.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary2-4.4.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY r DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.4.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.4.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.4.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.4.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary2-4.4.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY r DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.4.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777216 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.5.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-32769\n  }\n} {-32769 29 ffffffffffff7fff}\ndo_test boundary2-4.5.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffff7fff'\n  }\n} {-32769 29}\ndo_test boundary2-4.5.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=29\n  }\n} {-32769 ffffffffffff7fff}\ndo_test boundary2-4.5.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.5.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.5.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY r\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.5.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary2-4.5.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary2-4.5.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.5.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.5.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY r\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.5.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary2-4.5.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32769 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary2-4.5.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary2-4.5.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary2-4.5.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-4.5.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY r DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.5.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-4.5.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary2-4.5.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary2-4.5.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-4.5.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY r DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.5.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32769 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-4.6.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-140737488355329\n  }\n} {-140737488355329 21 ffff7fffffffffff}\ndo_test boundary2-4.6.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffff7fffffffffff'\n  }\n} {-140737488355329 21}\ndo_test boundary2-4.6.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=21\n  }\n} {-140737488355329 ffff7fffffffffff}\ndo_test boundary2-4.6.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.6.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.6.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.6.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary2-4.6.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.6.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.6.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.6.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.6.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary2-4.6.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355329 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.6.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary2-4.6.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary2-4.6.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r\n  }\n} {55 2 64}\ndo_test boundary2-4.6.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY r DESC\n  }\n} {64 2 55}\ndo_test boundary2-4.6.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355329 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary2-4.6.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary2-4.6.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary2-4.6.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r\n  }\n} {55 2 64 21}\ndo_test boundary2-4.6.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY r DESC\n  }\n} {21 64 2 55}\ndo_test boundary2-4.6.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355329 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary2-4.7.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2\n  }\n} {2 41 0000000000000002}\ndo_test boundary2-4.7.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000002'\n  }\n} {2 41}\ndo_test boundary2-4.7.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=41\n  }\n} {2 0000000000000002}\ndo_test boundary2-4.7.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.7.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.7.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY r\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.7.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary2-4.7.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.7.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.7.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.7.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY r\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.7.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary2-4.7.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.7.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.7.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.7.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary2-4.7.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY r DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.7.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.7.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.7.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.7.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary2-4.7.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY r DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.7.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.8.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4\n  }\n} {4 31 0000000000000004}\ndo_test boundary2-4.8.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000004'\n  }\n} {4 31}\ndo_test boundary2-4.8.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=31\n  }\n} {4 0000000000000004}\ndo_test boundary2-4.8.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.8.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-4.8.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY r\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.8.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary2-4.8.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.8.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.8.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-4.8.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY r\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.8.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary2-4.8.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.8.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.8.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary2-4.8.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary2-4.8.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY r DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.8.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.8.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.8.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary2-4.8.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary2-4.8.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY r DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.8.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.9.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=562949953421311\n  }\n} {562949953421311 13 0001ffffffffffff}\ndo_test boundary2-4.9.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0001ffffffffffff'\n  }\n} {562949953421311 13}\ndo_test boundary2-4.9.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=13\n  }\n} {562949953421311 0001ffffffffffff}\ndo_test boundary2-4.9.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary2-4.9.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary2-4.9.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-4.9.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary2-4.9.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421311 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-4.9.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary2-4.9.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary2-4.9.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-4.9.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary2-4.9.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421311 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-4.9.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.9.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.9.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary2-4.9.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY r DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.9.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.9.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.9.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.9.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary2-4.9.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY r DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.9.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421311 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.10.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=256\n  }\n} {256 61 0000000000000100}\ndo_test boundary2-4.10.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000100'\n  }\n} {256 61}\ndo_test boundary2-4.10.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=61\n  }\n} {256 0000000000000100}\ndo_test boundary2-4.10.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.10.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.10.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY r\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.10.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary2-4.10.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 256 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.10.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-4.10.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.10.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY r\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.10.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary2-4.10.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 256 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.10.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.10.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-4.10.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary2-4.10.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY r DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.10.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.10.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.10.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-4.10.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary2-4.10.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY r DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.10.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 256 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.11.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=34359738368\n  }\n} {34359738368 22 0000000800000000}\ndo_test boundary2-4.11.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000800000000'\n  }\n} {34359738368 22}\ndo_test boundary2-4.11.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=22\n  }\n} {34359738368 0000000800000000}\ndo_test boundary2-4.11.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-4.11.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.11.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.11.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary2-4.11.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738368 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.11.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-4.11.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.11.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.11.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary2-4.11.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738368 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.11.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.11.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.11.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary2-4.11.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY r DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.11.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.11.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.11.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.11.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary2-4.11.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY r DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.11.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738368 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.12.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=65536\n  }\n} {65536 62 0000000000010000}\ndo_test boundary2-4.12.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000010000'\n  }\n} {65536 62}\ndo_test boundary2-4.12.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=62\n  }\n} {65536 0000000000010000}\ndo_test boundary2-4.12.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-4.12.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.12.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY r\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.12.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary2-4.12.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65536 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.12.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary2-4.12.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.12.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY r\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.12.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary2-4.12.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65536 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.12.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.12.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.12.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary2-4.12.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY r DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.12.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.12.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.12.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.12.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary2-4.12.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY r DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.12.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65536 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.13.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=268435456\n  }\n} {268435456 40 0000000010000000}\ndo_test boundary2-4.13.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000010000000'\n  }\n} {268435456 40}\ndo_test boundary2-4.13.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=40\n  }\n} {268435456 0000000010000000}\ndo_test boundary2-4.13.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-4.13.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-4.13.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY r\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.13.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary2-4.13.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435456 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.13.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.13.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-4.13.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.13.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary2-4.13.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435456 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.13.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.13.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.13.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary2-4.13.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY r DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.13.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.13.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.13.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.13.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary2-4.13.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY r DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.13.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435456 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.14.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-140737488355328\n  }\n} {-140737488355328 44 ffff800000000000}\ndo_test boundary2-4.14.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffff800000000000'\n  }\n} {-140737488355328 44}\ndo_test boundary2-4.14.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=44\n  }\n} {-140737488355328 ffff800000000000}\ndo_test boundary2-4.14.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.14.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.14.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.14.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary2-4.14.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.14.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.14.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.14.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.14.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary2-4.14.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.14.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a\n  }\n} {2 21 55 64}\ndo_test boundary2-4.14.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY a DESC\n  }\n} {64 55 21 2}\ndo_test boundary2-4.14.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r\n  }\n} {55 2 64 21}\ndo_test boundary2-4.14.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY r DESC\n  }\n} {21 64 2 55}\ndo_test boundary2-4.14.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -140737488355328 ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary2-4.14.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary2-4.14.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary2-4.14.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44}\ndo_test boundary2-4.14.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY r DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary2-4.14.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -140737488355328 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary2-4.15.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1099511627776\n  }\n} {1099511627776 19 0000010000000000}\ndo_test boundary2-4.15.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000010000000000'\n  }\n} {1099511627776 19}\ndo_test boundary2-4.15.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=19\n  }\n} {1099511627776 0000010000000000}\ndo_test boundary2-4.15.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.15.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary2-4.15.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.15.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary2-4.15.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627776 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.15.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.15.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.15.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.15.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary2-4.15.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627776 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.15.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.15.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.15.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary2-4.15.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY r DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.15.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.15.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.15.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.15.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary2-4.15.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY r DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.15.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627776 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.16.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.16.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.16.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.16.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.16.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9223372036854775807 ORDER BY x\n  }\n} {}\ndo_test boundary2-4.16.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a\n  }\n} {3}\ndo_test boundary2-4.16.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary2-4.16.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r\n  }\n} {3}\ndo_test boundary2-4.16.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY r DESC\n  }\n} {3}\ndo_test boundary2-4.16.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9223372036854775807 ORDER BY x\n  }\n} {3}\ndo_test boundary2-4.16.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.16.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.16.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary2-4.16.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY r DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.16.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.16.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.16.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.16.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.16.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.16.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9223372036854775807 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.17.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=32768\n  }\n} {32768 50 0000000000008000}\ndo_test boundary2-4.17.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000008000'\n  }\n} {32768 50}\ndo_test boundary2-4.17.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=50\n  }\n} {32768 0000000000008000}\ndo_test boundary2-4.17.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary2-4.17.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.17.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY r\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.17.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary2-4.17.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32768 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.17.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.17.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.17.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY r\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.17.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary2-4.17.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32768 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.17.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.17.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.17.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary2-4.17.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY r DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.17.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.17.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.17.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.17.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary2-4.17.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY r DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.17.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.18.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-36028797018963968\n  }\n} {-36028797018963968 64 ff80000000000000}\ndo_test boundary2-4.18.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ff80000000000000'\n  }\n} {-36028797018963968 64}\ndo_test boundary2-4.18.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=64\n  }\n} {-36028797018963968 ff80000000000000}\ndo_test boundary2-4.18.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.18.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.18.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.18.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary2-4.18.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.18.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.18.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.18.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.18.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary2-4.18.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.18.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a\n  }\n} {2 55}\ndo_test boundary2-4.18.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary2-4.18.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r\n  }\n} {55 2}\ndo_test boundary2-4.18.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY r DESC\n  }\n} {2 55}\ndo_test boundary2-4.18.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963968 ORDER BY x\n  }\n} {55 2}\ndo_test boundary2-4.18.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a\n  }\n} {2 55 64}\ndo_test boundary2-4.18.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY a DESC\n  }\n} {64 55 2}\ndo_test boundary2-4.18.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r\n  }\n} {55 2 64}\ndo_test boundary2-4.18.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY r DESC\n  }\n} {64 2 55}\ndo_test boundary2-4.18.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963968 ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary2-4.19.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=65535\n  }\n} {65535 48 000000000000ffff}\ndo_test boundary2-4.19.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000000ffff'\n  }\n} {65535 48}\ndo_test boundary2-4.19.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=48\n  }\n} {65535 000000000000ffff}\ndo_test boundary2-4.19.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary2-4.19.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.19.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY r\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.19.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary2-4.19.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 65535 ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.19.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary2-4.19.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.19.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY r\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.19.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary2-4.19.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 65535 ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.19.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.19.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.19.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary2-4.19.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY r DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.19.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.19.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.19.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.19.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary2-4.19.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY r DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.19.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 65535 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.20.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4294967295\n  }\n} {4294967295 14 00000000ffffffff}\ndo_test boundary2-4.20.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000ffffffff'\n  }\n} {4294967295 14}\ndo_test boundary2-4.20.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=14\n  }\n} {4294967295 00000000ffffffff}\ndo_test boundary2-4.20.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-4.20.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.20.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.20.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary2-4.20.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4294967295 ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.20.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-4.20.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-4.20.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.20.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary2-4.20.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4294967295 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.20.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.20.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.20.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary2-4.20.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY r DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.20.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.20.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.20.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.20.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary2-4.20.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY r DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.20.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4294967295 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.21.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1099511627775\n  }\n} {1099511627775 57 000000ffffffffff}\ndo_test boundary2-4.21.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000ffffffffff'\n  }\n} {1099511627775 57}\ndo_test boundary2-4.21.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=57\n  }\n} {1099511627775 000000ffffffffff}\ndo_test boundary2-4.21.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.21.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.21.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.21.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary2-4.21.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1099511627775 ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.21.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary2-4.21.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.21.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.21.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary2-4.21.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1099511627775 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.21.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.21.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.21.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary2-4.21.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY r DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.21.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.21.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.21.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.21.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary2-4.21.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY r DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.21.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1099511627775 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.22.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-8388608\n  }\n} {-8388608 37 ffffffffff800000}\ndo_test boundary2-4.22.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffff800000'\n  }\n} {-8388608 37}\ndo_test boundary2-4.22.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=37\n  }\n} {-8388608 ffffffffff800000}\ndo_test boundary2-4.22.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.22.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.22.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY r\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.22.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary2-4.22.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary2-4.22.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.22.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.22.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.22.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary2-4.22.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.22.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary2-4.22.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary2-4.22.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-4.22.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY r DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.22.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-4.22.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary2-4.22.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary2-4.22.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-4.22.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY r DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.22.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388608 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary2-4.23.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=549755813888\n  }\n} {549755813888 35 0000008000000000}\ndo_test boundary2-4.23.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000008000000000'\n  }\n} {549755813888 35}\ndo_test boundary2-4.23.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=35\n  }\n} {549755813888 0000008000000000}\ndo_test boundary2-4.23.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary2-4.23.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.23.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.23.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary2-4.23.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813888 ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.23.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary2-4.23.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.23.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.23.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary2-4.23.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813888 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.23.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.23.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.23.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary2-4.23.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY r DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.23.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.23.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.23.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.23.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary2-4.23.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY r DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.23.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.24.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=8388607\n  }\n} {8388607 18 00000000007fffff}\ndo_test boundary2-4.24.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000007fffff'\n  }\n} {8388607 18}\ndo_test boundary2-4.24.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=18\n  }\n} {8388607 00000000007fffff}\ndo_test boundary2-4.24.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.24.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.24.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY r\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.24.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary2-4.24.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388607 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.24.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.24.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.24.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.24.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary2-4.24.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388607 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.24.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.24.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.24.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary2-4.24.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY r DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.24.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.24.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.24.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.24.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary2-4.24.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY r DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.24.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388607 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.25.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-3\n  }\n} {-3 52 fffffffffffffffd}\ndo_test boundary2-4.25.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='fffffffffffffffd'\n  }\n} {-3 52}\ndo_test boundary2-4.25.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=52\n  }\n} {-3 fffffffffffffffd}\ndo_test boundary2-4.25.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.25.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.25.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY r\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.25.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary2-4.25.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary2-4.25.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary2-4.25.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.25.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY r\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.25.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary2-4.25.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -3 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary2-4.25.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary2-4.25.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.25.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-4.25.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY r DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.25.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-4.25.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.25.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.25.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-4.25.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY r DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.25.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -3 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-4.26.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=0\n  }\n} {0 59 0000000000000000}\ndo_test boundary2-4.26.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000000'\n  }\n} {0 59}\ndo_test boundary2-4.26.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=59\n  }\n} {0 0000000000000000}\ndo_test boundary2-4.26.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary2-4.26.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.26.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY r\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.26.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary2-4.26.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 0 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.26.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.26.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.26.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY r\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.26.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary2-4.26.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 0 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.26.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.26.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.26.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.26.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY r DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.26.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 0 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.26.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary2-4.26.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.26.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary2-4.26.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY r DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.26.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 0 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.27.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-1\n  }\n} {-1 38 ffffffffffffffff}\ndo_test boundary2-4.27.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffffff'\n  }\n} {-1 38}\ndo_test boundary2-4.27.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=38\n  }\n} {-1 ffffffffffffffff}\ndo_test boundary2-4.27.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.27.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.27.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY r\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.27.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary2-4.27.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.27.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.27.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.27.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY r\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.27.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary2-4.27.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -1 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary2-4.27.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.27.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.27.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-4.27.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY r DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.27.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-4.27.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.27.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.27.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.27.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY r DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.27.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -1 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.28.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2\n  }\n} {-2 33 fffffffffffffffe}\ndo_test boundary2-4.28.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='fffffffffffffffe'\n  }\n} {-2 33}\ndo_test boundary2-4.28.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=33\n  }\n} {-2 fffffffffffffffe}\ndo_test boundary2-4.28.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.28.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.28.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY r\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.28.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary2-4.28.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary2-4.28.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary2-4.28.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.28.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY r\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.28.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary2-4.28.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary2-4.28.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.28.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.28.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-4.28.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY r DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.28.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary2-4.28.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary2-4.28.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.28.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-4.28.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY r DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.28.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary2-4.29.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2097152\n  }\n} {2097152 42 0000000000200000}\ndo_test boundary2-4.29.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000200000'\n  }\n} {2097152 42}\ndo_test boundary2-4.29.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=42\n  }\n} {2097152 0000000000200000}\ndo_test boundary2-4.29.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.29.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.29.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY r\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.29.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary2-4.29.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097152 ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.29.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-4.29.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.29.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.29.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary2-4.29.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097152 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.29.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.29.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.29.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary2-4.29.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY r DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.29.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.29.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.29.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.29.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary2-4.29.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY r DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.29.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097152 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.30.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=128\n  }\n} {128 49 0000000000000080}\ndo_test boundary2-4.30.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000080'\n  }\n} {128 49}\ndo_test boundary2-4.30.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=49\n  }\n} {128 0000000000000080}\ndo_test boundary2-4.30.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-4.30.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.30.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY r\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.30.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary2-4.30.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 128 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.30.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.30.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.30.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY r\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.30.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary2-4.30.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 128 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.30.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.30.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-4.30.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary2-4.30.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY r DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.30.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.30.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.30.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-4.30.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary2-4.30.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY r DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.30.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.31.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=255\n  }\n} {255 30 00000000000000ff}\ndo_test boundary2-4.31.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000000000ff'\n  }\n} {255 30}\ndo_test boundary2-4.31.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=30\n  }\n} {255 00000000000000ff}\ndo_test boundary2-4.31.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-4.31.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.31.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY r\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.31.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary2-4.31.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 255 ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.31.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary2-4.31.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.31.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY r\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.31.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary2-4.31.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 255 ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.31.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.31.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-4.31.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary2-4.31.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY r DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.31.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.31.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.31.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-4.31.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary2-4.31.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY r DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.31.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 255 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.32.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2147483648\n  }\n} {-2147483648 11 ffffffff80000000}\ndo_test boundary2-4.32.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffff80000000'\n  }\n} {-2147483648 11}\ndo_test boundary2-4.32.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=11\n  }\n} {-2147483648 ffffffff80000000}\ndo_test boundary2-4.32.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.32.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.32.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.32.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary2-4.32.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.32.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.32.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.32.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.32.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary2-4.32.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.32.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary2-4.32.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary2-4.32.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-4.32.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY r DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary2-4.32.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-4.32.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary2-4.32.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary2-4.32.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-4.32.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY r DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.32.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483648 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-4.33.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=34359738367\n  }\n} {34359738367 39 00000007ffffffff}\ndo_test boundary2-4.33.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000007ffffffff'\n  }\n} {34359738367 39}\ndo_test boundary2-4.33.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=39\n  }\n} {34359738367 00000007ffffffff}\ndo_test boundary2-4.33.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-4.33.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.33.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.33.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary2-4.33.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 34359738367 ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.33.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary2-4.33.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary2-4.33.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.33.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary2-4.33.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 34359738367 ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.33.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.33.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.33.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary2-4.33.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY r DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.33.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.33.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.33.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.33.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary2-4.33.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY r DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.33.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 34359738367 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.34.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-549755813889\n  }\n} {-549755813889 58 ffffff7fffffffff}\ndo_test boundary2-4.34.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffff7fffffffff'\n  }\n} {-549755813889 58}\ndo_test boundary2-4.34.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=58\n  }\n} {-549755813889 ffffff7fffffffff}\ndo_test boundary2-4.34.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary2-4.34.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.34.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.34.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary2-4.34.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.34.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary2-4.34.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.34.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.34.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary2-4.34.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813889 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.34.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a\n  }\n} {2 21 44 55 64}\ndo_test boundary2-4.34.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary2-4.34.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r\n  }\n} {55 2 64 21 44}\ndo_test boundary2-4.34.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY r DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary2-4.34.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary2-4.34.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary2-4.34.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary2-4.34.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-4.34.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY r DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary2-4.34.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813889 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-4.35.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-32768\n  }\n} {-32768 32 ffffffffffff8000}\ndo_test boundary2-4.35.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffff8000'\n  }\n} {-32768 32}\ndo_test boundary2-4.35.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=32\n  }\n} {-32768 ffffffffffff8000}\ndo_test boundary2-4.35.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.35.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.35.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY r\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.35.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary2-4.35.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary2-4.35.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.35.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.35.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY r\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.35.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary2-4.35.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -32768 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary2-4.35.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary2-4.35.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary2-4.35.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-4.35.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY r DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.35.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary2-4.35.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary2-4.35.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.35.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-4.35.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY r DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.35.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -32768 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-4.36.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2147483647\n  }\n} {2147483647 20 000000007fffffff}\ndo_test boundary2-4.36.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000007fffffff'\n  }\n} {2147483647 20}\ndo_test boundary2-4.36.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=20\n  }\n} {2147483647 000000007fffffff}\ndo_test boundary2-4.36.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-4.36.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-4.36.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.36.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary2-4.36.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483647 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.36.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-4.36.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-4.36.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.36.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary2-4.36.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483647 ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.36.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.36.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.36.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary2-4.36.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY r DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.36.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.36.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.36.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.36.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary2-4.36.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY r DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.36.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483647 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.37.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-129\n  }\n} {-129 54 ffffffffffffff7f}\ndo_test boundary2-4.37.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffff7f'\n  }\n} {-129 54}\ndo_test boundary2-4.37.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=54\n  }\n} {-129 ffffffffffffff7f}\ndo_test boundary2-4.37.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary2-4.37.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.37.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY r\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.37.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary2-4.37.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary2-4.37.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.37.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.37.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY r\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.37.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary2-4.37.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -129 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary2-4.37.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary2-4.37.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.37.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-4.37.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY r DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.37.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary2-4.37.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary2-4.37.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.37.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-4.37.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY r DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.37.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -129 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-4.38.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-128\n  }\n} {-128 53 ffffffffffffff80}\ndo_test boundary2-4.38.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffffffff80'\n  }\n} {-128 53}\ndo_test boundary2-4.38.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=53\n  }\n} {-128 ffffffffffffff80}\ndo_test boundary2-4.38.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary2-4.38.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.38.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY r\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.38.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary2-4.38.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary2-4.38.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary2-4.38.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.38.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY r\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.38.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary2-4.38.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -128 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary2-4.38.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary2-4.38.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.38.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-4.38.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY r DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.38.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary2-4.38.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary2-4.38.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary2-4.38.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-4.38.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY r DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.38.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -128 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary2-4.39.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=72057594037927936\n  }\n} {72057594037927936 28 0100000000000000}\ndo_test boundary2-4.39.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0100000000000000'\n  }\n} {72057594037927936 28}\ndo_test boundary2-4.39.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=28\n  }\n} {72057594037927936 0100000000000000}\ndo_test boundary2-4.39.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a\n  }\n} {3}\ndo_test boundary2-4.39.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY a DESC\n  }\n} {3}\ndo_test boundary2-4.39.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r\n  }\n} {3}\ndo_test boundary2-4.39.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY r DESC\n  }\n} {3}\ndo_test boundary2-4.39.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 72057594037927936 ORDER BY x\n  }\n} {3}\ndo_test boundary2-4.39.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a\n  }\n} {3 28}\ndo_test boundary2-4.39.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY a DESC\n  }\n} {28 3}\ndo_test boundary2-4.39.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r\n  }\n} {28 3}\ndo_test boundary2-4.39.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY r DESC\n  }\n} {3 28}\ndo_test boundary2-4.39.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 72057594037927936 ORDER BY x\n  }\n} {28 3}\ndo_test boundary2-4.39.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.39.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.39.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary2-4.39.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY r DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.39.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.39.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.39.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.39.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary2-4.39.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY r DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.39.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 72057594037927936 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.40.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2147483648\n  }\n} {2147483648 51 0000000080000000}\ndo_test boundary2-4.40.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000080000000'\n  }\n} {2147483648 51}\ndo_test boundary2-4.40.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=51\n  }\n} {2147483648 0000000080000000}\ndo_test boundary2-4.40.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary2-4.40.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-4.40.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.40.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary2-4.40.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2147483648 ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.40.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary2-4.40.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary2-4.40.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.40.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary2-4.40.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2147483648 ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.40.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.40.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.40.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary2-4.40.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY r DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.40.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.40.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.40.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.40.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary2-4.40.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY r DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.40.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2147483648 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.41.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=549755813887\n  }\n} {549755813887 46 0000007fffffffff}\ndo_test boundary2-4.41.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000007fffffffff'\n  }\n} {549755813887 46}\ndo_test boundary2-4.41.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=46\n  }\n} {549755813887 0000007fffffffff}\ndo_test boundary2-4.41.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary2-4.41.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.41.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.41.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary2-4.41.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 549755813887 ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.41.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary2-4.41.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary2-4.41.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.41.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary2-4.41.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 549755813887 ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.41.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.41.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.41.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary2-4.41.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY r DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.41.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.41.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.41.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.41.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary2-4.41.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY r DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.41.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 549755813887 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.42.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-549755813888\n  }\n} {-549755813888 63 ffffff8000000000}\ndo_test boundary2-4.42.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffff8000000000'\n  }\n} {-549755813888 63}\ndo_test boundary2-4.42.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=63\n  }\n} {-549755813888 ffffff8000000000}\ndo_test boundary2-4.42.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.42.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.42.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.42.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary2-4.42.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.42.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary2-4.42.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.42.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.42.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary2-4.42.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -549755813888 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.42.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary2-4.42.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary2-4.42.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-4.42.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY r DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary2-4.42.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary2-4.42.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary2-4.42.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary2-4.42.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-4.42.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY r DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary2-4.42.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -549755813888 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-4.43.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=281474976710655\n  }\n} {281474976710655 10 0000ffffffffffff}\ndo_test boundary2-4.43.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000ffffffffffff'\n  }\n} {281474976710655 10}\ndo_test boundary2-4.43.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=10\n  }\n} {281474976710655 0000ffffffffffff}\ndo_test boundary2-4.43.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary2-4.43.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary2-4.43.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-4.43.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary2-4.43.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710655 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-4.43.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary2-4.43.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary2-4.43.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.43.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary2-4.43.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710655 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.43.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.43.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.43.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary2-4.43.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY r DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.43.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.43.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.43.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.43.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary2-4.43.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY r DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.43.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710655 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.44.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4398046511103\n  }\n} {4398046511103 7 000003ffffffffff}\ndo_test boundary2-4.44.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000003ffffffffff'\n  }\n} {4398046511103 7}\ndo_test boundary2-4.44.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=7\n  }\n} {4398046511103 000003ffffffffff}\ndo_test boundary2-4.44.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.44.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-4.44.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.44.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary2-4.44.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511103 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.44.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.44.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary2-4.44.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.44.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary2-4.44.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511103 ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.44.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.44.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.44.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary2-4.44.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY r DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.44.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.44.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.44.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.44.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary2-4.44.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY r DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.44.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511103 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.45.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=268435455\n  }\n} {268435455 12 000000000fffffff}\ndo_test boundary2-4.45.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000fffffff'\n  }\n} {268435455 12}\ndo_test boundary2-4.45.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=12\n  }\n} {268435455 000000000fffffff}\ndo_test boundary2-4.45.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.45.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary2-4.45.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY r\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.45.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary2-4.45.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 268435455 ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.45.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.45.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary2-4.45.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.45.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary2-4.45.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 268435455 ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.45.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.45.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.45.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary2-4.45.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY r DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.45.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.45.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.45.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary2-4.45.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary2-4.45.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY r DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.45.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 268435455 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.46.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-9223372036854775808\n  }\n} {-9223372036854775808 55 8000000000000000}\ndo_test boundary2-4.46.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='8000000000000000'\n  }\n} {-9223372036854775808 55}\ndo_test boundary2-4.46.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=55\n  }\n} {-9223372036854775808 8000000000000000}\ndo_test boundary2-4.46.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.46.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.46.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.46.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary2-4.46.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.46.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.46.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.46.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.46.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.46.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9223372036854775808 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.46.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.46.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.46.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.46.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.46.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9223372036854775808 ORDER BY x\n  }\n} {}\ndo_test boundary2-4.46.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a\n  }\n} {55}\ndo_test boundary2-4.46.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary2-4.46.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r\n  }\n} {55}\ndo_test boundary2-4.46.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY r DESC\n  }\n} {55}\ndo_test boundary2-4.46.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9223372036854775808 ORDER BY x\n  }\n} {55}\ndo_test boundary2-4.47.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=562949953421312\n  }\n} {562949953421312 43 0002000000000000}\ndo_test boundary2-4.47.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0002000000000000'\n  }\n} {562949953421312 43}\ndo_test boundary2-4.47.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=43\n  }\n} {562949953421312 0002000000000000}\ndo_test boundary2-4.47.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary2-4.47.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary2-4.47.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r\n  }\n} {27 45 17 28 3}\ndo_test boundary2-4.47.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY r DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary2-4.47.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 562949953421312 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary2-4.47.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary2-4.47.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary2-4.47.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-4.47.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary2-4.47.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 562949953421312 ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary2-4.47.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.47.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.47.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary2-4.47.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY r DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.47.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.47.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.47.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.47.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary2-4.47.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY r DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.47.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 562949953421312 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.48.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-8388609\n  }\n} {-8388609 1 ffffffffff7fffff}\ndo_test boundary2-4.48.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffffff7fffff'\n  }\n} {-8388609 1}\ndo_test boundary2-4.48.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=1\n  }\n} {-8388609 ffffffffff7fffff}\ndo_test boundary2-4.48.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.48.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.48.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY r\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.48.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary2-4.48.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.48.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.48.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.48.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.48.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary2-4.48.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -8388609 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.48.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary2-4.48.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary2-4.48.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-4.48.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY r DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.48.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary2-4.48.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary2-4.48.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary2-4.48.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-4.48.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY r DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.48.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -8388609 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary2-4.49.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16777215\n  }\n} {16777215 9 0000000000ffffff}\ndo_test boundary2-4.49.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000ffffff'\n  }\n} {16777215 9}\ndo_test boundary2-4.49.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=9\n  }\n} {16777215 0000000000ffffff}\ndo_test boundary2-4.49.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.49.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary2-4.49.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY r\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.49.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary2-4.49.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16777215 ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.49.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.49.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.49.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.49.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary2-4.49.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16777215 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.49.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.49.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.49.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary2-4.49.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY r DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.49.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.49.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.49.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary2-4.49.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary2-4.49.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY r DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.49.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16777215 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.50.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=8388608\n  }\n} {8388608 24 0000000000800000}\ndo_test boundary2-4.50.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000800000'\n  }\n} {8388608 24}\ndo_test boundary2-4.50.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=24\n  }\n} {8388608 0000000000800000}\ndo_test boundary2-4.50.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.50.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.50.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY r\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.50.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary2-4.50.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 8388608 ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.50.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary2-4.50.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.50.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.50.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary2-4.50.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 8388608 ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.50.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.50.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.50.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary2-4.50.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY r DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.50.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.50.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.50.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.50.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary2-4.50.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY r DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.50.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 8388608 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.51.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=16383\n  }\n} {16383 8 0000000000003fff}\ndo_test boundary2-4.51.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000003fff'\n  }\n} {16383 8}\ndo_test boundary2-4.51.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=8\n  }\n} {16383 0000000000003fff}\ndo_test boundary2-4.51.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.51.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.51.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY r\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.51.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary2-4.51.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 16383 ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.51.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.51.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.51.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY r\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.51.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary2-4.51.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 16383 ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.51.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.51.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary2-4.51.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary2-4.51.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY r DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.51.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.51.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.51.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary2-4.51.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary2-4.51.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY r DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.51.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 16383 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.52.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=140737488355328\n  }\n} {140737488355328 34 0000800000000000}\ndo_test boundary2-4.52.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000800000000000'\n  }\n} {140737488355328 34}\ndo_test boundary2-4.52.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=34\n  }\n} {140737488355328 0000800000000000}\ndo_test boundary2-4.52.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary2-4.52.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary2-4.52.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.52.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary2-4.52.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355328 ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.52.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary2-4.52.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary2-4.52.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.52.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary2-4.52.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355328 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.52.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.52.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.52.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary2-4.52.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY r DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.52.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.52.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.52.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.52.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary2-4.52.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY r DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.52.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355328 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.53.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=2097151\n  }\n} {2097151 15 00000000001fffff}\ndo_test boundary2-4.53.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00000000001fffff'\n  }\n} {2097151 15}\ndo_test boundary2-4.53.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=15\n  }\n} {2097151 00000000001fffff}\ndo_test boundary2-4.53.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-4.53.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.53.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY r\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.53.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary2-4.53.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 2097151 ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.53.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary2-4.53.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.53.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.53.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary2-4.53.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 2097151 ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.53.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.53.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.53.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary2-4.53.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY r DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.53.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.53.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary2-4.53.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary2-4.53.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary2-4.53.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY r DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.53.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 2097151 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.54.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=140737488355327\n  }\n} {140737488355327 25 00007fffffffffff}\ndo_test boundary2-4.54.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='00007fffffffffff'\n  }\n} {140737488355327 25}\ndo_test boundary2-4.54.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=25\n  }\n} {140737488355327 00007fffffffffff}\ndo_test boundary2-4.54.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary2-4.54.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary2-4.54.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.54.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary2-4.54.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 140737488355327 ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.54.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary2-4.54.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-4.54.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.54.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary2-4.54.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 140737488355327 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.54.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.54.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.54.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary2-4.54.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY r DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.54.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.54.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.54.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.54.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary2-4.54.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY r DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.54.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 140737488355327 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.55.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=281474976710656\n  }\n} {281474976710656 26 0001000000000000}\ndo_test boundary2-4.55.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0001000000000000'\n  }\n} {281474976710656 26}\ndo_test boundary2-4.55.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=26\n  }\n} {281474976710656 0001000000000000}\ndo_test boundary2-4.55.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary2-4.55.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary2-4.55.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-4.55.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary2-4.55.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 281474976710656 ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary2-4.55.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary2-4.55.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary2-4.55.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-4.55.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary2-4.55.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 281474976710656 ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary2-4.55.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.55.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.55.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary2-4.55.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY r DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.55.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.55.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.55.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.55.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary2-4.55.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY r DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.55.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 281474976710656 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.56.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=32767\n  }\n} {32767 23 0000000000007fff}\ndo_test boundary2-4.56.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000007fff'\n  }\n} {32767 23}\ndo_test boundary2-4.56.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=23\n  }\n} {32767 0000000000007fff}\ndo_test boundary2-4.56.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.56.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.56.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY r\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.56.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary2-4.56.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 32767 ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.56.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary2-4.56.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary2-4.56.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY r\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.56.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary2-4.56.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 32767 ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.56.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.56.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.56.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary2-4.56.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY r DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.56.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.56.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary2-4.56.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary2-4.56.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary2-4.56.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY r DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.56.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 32767 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.57.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=127\n  }\n} {127 4 000000000000007f}\ndo_test boundary2-4.57.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='000000000000007f'\n  }\n} {127 4}\ndo_test boundary2-4.57.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=4\n  }\n} {127 000000000000007f}\ndo_test boundary2-4.57.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.57.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary2-4.57.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY r\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.57.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary2-4.57.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 127 ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.57.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.57.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-4.57.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY r\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.57.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary2-4.57.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 127 ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.57.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.57.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary2-4.57.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary2-4.57.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY r DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.57.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 127 ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.57.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.57.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary2-4.57.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary2-4.57.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY r DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.57.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 127 ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.58.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=36028797018963967\n  }\n} {36028797018963967 27 007fffffffffffff}\ndo_test boundary2-4.58.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='007fffffffffffff'\n  }\n} {36028797018963967 27}\ndo_test boundary2-4.58.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=27\n  }\n} {36028797018963967 007fffffffffffff}\ndo_test boundary2-4.58.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary2-4.58.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary2-4.58.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r\n  }\n} {45 17 28 3}\ndo_test boundary2-4.58.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY r DESC\n  }\n} {3 28 17 45}\ndo_test boundary2-4.58.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963967 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary2-4.58.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a\n  }\n} {3 17 27 28 45}\ndo_test boundary2-4.58.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary2-4.58.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r\n  }\n} {27 45 17 28 3}\ndo_test boundary2-4.58.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY r DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary2-4.58.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963967 ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary2-4.58.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.58.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.58.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary2-4.58.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY r DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.58.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.58.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.58.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.58.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary2-4.58.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY r DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.58.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963967 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.59.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=4398046511104\n  }\n} {4398046511104 56 0000040000000000}\ndo_test boundary2-4.59.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000040000000000'\n  }\n} {4398046511104 56}\ndo_test boundary2-4.59.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=56\n  }\n} {4398046511104 0000040000000000}\ndo_test boundary2-4.59.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary2-4.59.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-4.59.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.59.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary2-4.59.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 4398046511104 ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.59.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary2-4.59.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary2-4.59.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.59.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary2-4.59.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 4398046511104 ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.59.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.59.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.59.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary2-4.59.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY r DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.59.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.59.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.59.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.59.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary2-4.59.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY r DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.59.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 4398046511104 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.60.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=1\n  }\n} {1 60 0000000000000001}\ndo_test boundary2-4.60.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000001'\n  }\n} {1 60}\ndo_test boundary2-4.60.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=60\n  }\n} {1 0000000000000001}\ndo_test boundary2-4.60.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.60.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.60.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY r\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.60.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary2-4.60.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 1 ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.60.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary2-4.60.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.60.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY r\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.60.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary2-4.60.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 1 ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.60.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary2-4.60.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.60.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary2-4.60.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY r DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.60.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 1 ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.60.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.60.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.60.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary2-4.60.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY r DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.60.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 1 ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.61.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=36028797018963968\n  }\n} {36028797018963968 45 0080000000000000}\ndo_test boundary2-4.61.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0080000000000000'\n  }\n} {36028797018963968 45}\ndo_test boundary2-4.61.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=45\n  }\n} {36028797018963968 0080000000000000}\ndo_test boundary2-4.61.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a\n  }\n} {3 17 28}\ndo_test boundary2-4.61.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY a DESC\n  }\n} {28 17 3}\ndo_test boundary2-4.61.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r\n  }\n} {17 28 3}\ndo_test boundary2-4.61.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17}\ndo_test boundary2-4.61.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 36028797018963968 ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary2-4.61.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a\n  }\n} {3 17 28 45}\ndo_test boundary2-4.61.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY a DESC\n  }\n} {45 28 17 3}\ndo_test boundary2-4.61.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r\n  }\n} {45 17 28 3}\ndo_test boundary2-4.61.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY r DESC\n  }\n} {3 28 17 45}\ndo_test boundary2-4.61.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 36028797018963968 ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary2-4.61.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.61.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.61.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary2-4.61.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY r DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.61.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.61.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.61.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary2-4.61.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary2-4.61.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY r DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.61.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 36028797018963968 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.62.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-2147483649\n  }\n} {-2147483649 47 ffffffff7fffffff}\ndo_test boundary2-4.62.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ffffffff7fffffff'\n  }\n} {-2147483649 47}\ndo_test boundary2-4.62.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=47\n  }\n} {-2147483649 ffffffff7fffffff}\ndo_test boundary2-4.62.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.62.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.62.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.62.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary2-4.62.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.62.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary2-4.62.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.62.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.62.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary2-4.62.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -2147483649 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.62.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary2-4.62.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary2-4.62.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-4.62.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY r DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary2-4.62.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary2-4.62.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary2-4.62.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary2-4.62.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-4.62.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY r DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary2-4.62.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -2147483649 ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary2-4.63.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=-36028797018963969\n  }\n} {-36028797018963969 2 ff7fffffffffffff}\ndo_test boundary2-4.63.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='ff7fffffffffffff'\n  }\n} {-36028797018963969 2}\ndo_test boundary2-4.63.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=2\n  }\n} {-36028797018963969 ff7fffffffffffff}\ndo_test boundary2-4.63.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.63.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary2-4.63.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.63.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary2-4.63.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.63.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.63.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.63.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.63.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary2-4.63.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -36028797018963969 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.63.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a\n  }\n} {55}\ndo_test boundary2-4.63.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY a DESC\n  }\n} {55}\ndo_test boundary2-4.63.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r\n  }\n} {55}\ndo_test boundary2-4.63.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY r DESC\n  }\n} {55}\ndo_test boundary2-4.63.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -36028797018963969 ORDER BY x\n  }\n} {55}\ndo_test boundary2-4.63.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a\n  }\n} {2 55}\ndo_test boundary2-4.63.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY a DESC\n  }\n} {55 2}\ndo_test boundary2-4.63.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r\n  }\n} {55 2}\ndo_test boundary2-4.63.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY r DESC\n  }\n} {2 55}\ndo_test boundary2-4.63.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -36028797018963969 ORDER BY x\n  }\n} {55 2}\ndo_test boundary2-4.64.1 {\n  db eval {\n    SELECT * FROM t1 WHERE r=3\n  }\n} {3 5 0000000000000003}\ndo_test boundary2-4.64.2 {\n  db eval {\n    SELECT r, a FROM t1 WHERE x='0000000000000003'\n  }\n} {3 5}\ndo_test boundary2-4.64.3 {\n  db eval {\n    SELECT r, x FROM t1 WHERE a=5\n  }\n} {3 0000000000000003}\ndo_test boundary2-4.64.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.64.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary2-4.64.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY r\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.64.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary2-4.64.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 3 ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.64.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary2-4.64.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary2-4.64.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY r\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.64.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary2-4.64.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 3 ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.64.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.64.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary2-4.64.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary2-4.64.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY r DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.64.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 3 ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.64.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary2-4.64.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary2-4.64.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary2-4.64.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY r DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.64.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 3 ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.65.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.65.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.65.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.65.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.65.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-4.65.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.65.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.65.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.65.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.65.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-4.65.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.65.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.65.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.65.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.65.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.65.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.65.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.65.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.65.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.65.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= 9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.66.gt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.66.gt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.66.gt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.66.gt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.66.gt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r > -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.66.ge.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary2-4.66.ge.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary2-4.66.ge.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary2-4.66.ge.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary2-4.66.ge.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r >= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary2-4.66.lt.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.66.lt.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.66.lt.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.66.lt.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.66.lt.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r < -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\ndo_test boundary2-4.66.le.1 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a\n  }\n} {}\ndo_test boundary2-4.66.le.2 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY a DESC\n  }\n} {}\ndo_test boundary2-4.66.le.3 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r\n  }\n} {}\ndo_test boundary2-4.66.le.4 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY r DESC\n  }\n} {}\ndo_test boundary2-4.66.le.5 {\n  db eval {\n    SELECT a FROM t1 WHERE r <= -9.22337303685477580800e+18 ORDER BY x\n  }\n} {}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary3.tcl",
    "content": "puts {# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n}\n\nexpr srand(0)\n\n# Generate interesting boundary numbers\n#\nforeach x {\n  0\n  1\n  0x7f\n  0x7fff\n  0x7fffff\n  0x7fffffff\n  0x7fffffffff\n  0x7fffffffffff\n  0x7fffffffffffff\n  0x7fffffffffffffff\n} {\n  set x [expr {wide($x)}]\n  set boundarynum($x) 1\n  set boundarynum([expr {wide($x+1)}]) 1\n  set boundarynum([expr {wide(-($x+1))}]) 1\n  set boundarynum([expr {wide(-($x+2))}]) 1\n  set boundarynum([expr {wide($x+$x+1)}]) 1\n  set boundarynum([expr {wide($x+$x+2)}]) 1\n}\nset x [expr {wide(127)}]\nfor {set i 1} {$i<=9} {incr i} {\n  set boundarynum($x) 1\n  set boundarynum([expr {wide($x+1)}]) 1\n  set x [expr {wide($x*128 + 127)}]\n}\n\n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# A simple selection sort.  Not trying to be efficient.\n#\nproc sort {inlist} {\n  set outlist {}\n  set mn [lindex $inlist 0]\n  foreach x $inlist {\n    if {$x<$mn} {set mn $x}\n  }\n  set outlist $mn\n  set mx $mn\n  while {1} {\n    set valid 0\n    foreach x $inlist {\n      if {$x>$mx && (!$valid || $mn>$x)} {\n        set mn $x\n        set valid 1\n      }\n    }\n    if {!$valid} break\n    lappend outlist $mn\n    set mx $mn\n  }\n  return $outlist\n}\n\n# Reverse the order of a list\n#\nproc reverse {inlist} {\n  set i [llength $inlist]\n  set outlist {}\n  for {incr i -1} {$i>=0} {incr i -1} {\n    lappend outlist [lindex $inlist $i]\n  }\n  return $outlist\n}\n\nset nums1 [scramble [array names boundarynum]]\nset nums2 [scramble [array names boundarynum]]\n\nset tname boundary3\nputs \"do_test $tname-1.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t1(a,x);\"\nset a 0\nforeach r $nums1 {\n  incr a\n  set t1ra($r) $a\n  set t1ar($a) $r\n  set x [format %016x [expr {wide($r)}]]\n  set t1rx($r) $x\n  set t1xr($x) $r\n  puts \"    INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');\"\n}\nputs \"    CREATE INDEX t1i1 ON t1(a);\"\nputs \"    CREATE INDEX t1i2 ON t1(x);\"\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nputs \"do_test $tname-1.2 \\173\"\nputs \"  db eval \\173\"\nputs \"    SELECT count(*) FROM t1\"\nputs \"  \\175\"\nputs \"\\175 {64}\"\n\nputs \"do_test $tname-1.3 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t2(r,a);\"\nputs \"    INSERT INTO t2 SELECT rowid, a FROM t1;\"\nputs \"    CREATE INDEX t2i1 ON t2(r);\"\nputs \"    CREATE INDEX t2i2 ON t2(a);\"\nputs \"    INSERT INTO t2 VALUES(9.22337303685477580800e+18,65);\"\nset t1ra(9.22337303685477580800e+18) 65\nset t1ar(65) 9.22337303685477580800e+18)\nputs \"    INSERT INTO t2 VALUES(-9.22337303685477580800e+18,66);\"\nset t1ra(-9.22337303685477580800e+18) 66\nset t1ar(66) -9.22337303685477580800e+18)\nputs \"    SELECT count(*) FROM t2;\"\nputs \"  \\175\"\nputs \"\\175 {66}\"\n\nset nums3 $nums2\nlappend nums3 9.22337303685477580800e+18\nlappend nums3 -9.22337303685477580800e+18\n\nset i 0\nforeach r $nums3 {\n  incr i\n\n  set r5 $r.5\n  set r0 $r.0\n   if {abs($r)<0x7FFFFFFFFFFFFFFF || $r==-9223372036854775808} {\n    set x $t1rx($r)\n    set a $t1ra($r)\n    puts \"do_test $tname-2.$i.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.* FROM t1, t2 WHERE t1.rowid=$r AND t2.a=t1.a\"\n    puts \"  \\175\"\n    puts \"\\175 {$a $x}\"\n    puts \"do_test $tname-2.$i.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='$x'\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $a}\"\n    puts \"do_test $tname-2.$i.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=$a\"\n    puts \"  \\175\"\n    puts \"\\175 {$r $x}\"\n  }\n\n  foreach op {> >= < <=} subno {gt ge lt le} {\n\n    ################################################################ 2.x.y.1\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r\" {\n        lappend rset $rx\n        lappend aset $t1ra($rx)\n      }\n    }\n    puts \"do_test $tname-2.$i.$subno.1 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t2.a FROM t1 JOIN t2 USING(a)\"\n    puts \"     WHERE t1.rowid $op $r ORDER BY t2.a\"\n    puts \"  \\175\"\n    puts \"\\175 {[sort $aset]}\"\n  \n    ################################################################ 2.x.y.2\n    puts \"do_test $tname-2.$i.$subno.2 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t2.a FROM t2 NATURAL JOIN t1\"\n    puts \"     WHERE t1.rowid $op $r ORDER BY t1.a DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {[reverse [sort $aset]]}\"\n\n\n    ################################################################ 2.x.y.3\n    set ax $t1ra($r)\n    set aset {}\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.3 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r\"\n    puts \"     WHERE t2.a=$ax\"\n    puts \"     ORDER BY t1.rowid\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.4\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.4 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r\"\n    puts \"     WHERE t2.a=$ax\"\n    puts \"     ORDER BY t1.rowid DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.5\n    set aset {}\n    set xset {}\n    foreach rx $rset {\n      lappend xset $t1rx($rx)\n    }\n    foreach x [sort $xset] {\n      set rx $t1xr($x)\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.5 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op t2.r\"\n    puts \"     WHERE t2.a=$ax\"\n    puts \"     ORDER BY x\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.10\n    if {[string length $r5]>15} continue\n    set rset {}\n    set aset {}\n    foreach rx $nums2 {\n      if \"\\$rx $op \\$r0\" {\n        lappend rset $rx\n      }\n    }\n    foreach rx [sort $rset] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.10 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op CAST(t2.r AS real)\"\n    puts \"     WHERE t2.a=$ax\"\n    puts \"     ORDER BY t1.rowid\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  \n    ################################################################ 2.x.y.11\n    set aset {}\n    foreach rx [reverse [sort $rset]] {\n      lappend aset $t1ra($rx)\n    }\n    puts \"do_test $tname-2.$i.$subno.11 \\173\"\n    puts \"  db eval \\173\"\n    puts \"    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid $op CAST(t2.r AS real)\"\n    puts \"     WHERE t2.a=$ax\"\n    puts \"     ORDER BY t1.rowid DESC\"\n    puts \"  \\175\"\n    puts \"\\175 {$aset}\"\n  }\n  \n}\n\n\nputs {finish_test}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary3.test",
    "content": "# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary3.test,v 1.2 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\n\ndo_test boundary3-1.1 {\n  db eval {\n    CREATE TABLE t1(a,x);\n    INSERT INTO t1(oid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(127,4,'000000000000007f');\n    INSERT INTO t1(oid,a,x) VALUES(3,5,'0000000000000003');\n    INSERT INTO t1(oid,a,x) VALUES(16777216,6,'0000000001000000');\n    INSERT INTO t1(oid,a,x) VALUES(4398046511103,7,'000003ffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(16383,8,'0000000000003fff');\n    INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710655,10,'0000ffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483648,11,'ffffffff80000000');\n    INSERT INTO t1(oid,a,x) VALUES(268435455,12,'000000000fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(562949953421311,13,'0001ffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(4294967295,14,'00000000ffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(2097151,15,'00000000001fffff');\n    INSERT INTO t1(oid,a,x) VALUES(16384,16,'0000000000004000');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927935,17,'00ffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(8388607,18,'00000000007fffff');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627776,19,'0000010000000000');\n    INSERT INTO t1(oid,a,x) VALUES(2147483647,20,'000000007fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355329,21,'ffff7fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(34359738368,22,'0000000800000000');\n    INSERT INTO t1(oid,a,x) VALUES(32767,23,'0000000000007fff');\n    INSERT INTO t1(oid,a,x) VALUES(8388608,24,'0000000000800000');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355327,25,'00007fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710656,26,'0001000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963967,27,'007fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927936,28,'0100000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-32769,29,'ffffffffffff7fff');\n    INSERT INTO t1(oid,a,x) VALUES(255,30,'00000000000000ff');\n    INSERT INTO t1(oid,a,x) VALUES(4,31,'0000000000000004');\n    INSERT INTO t1(oid,a,x) VALUES(-32768,32,'ffffffffffff8000');\n    INSERT INTO t1(oid,a,x) VALUES(-2,33,'fffffffffffffffe');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');\n    INSERT INTO t1(oid,a,x) VALUES(4294967296,36,'0000000100000000');\n    INSERT INTO t1(oid,a,x) VALUES(-8388608,37,'ffffffffff800000');\n    INSERT INTO t1(oid,a,x) VALUES(-1,38,'ffffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(34359738367,39,'00000007ffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(268435456,40,'0000000010000000');\n    INSERT INTO t1(oid,a,x) VALUES(2,41,'0000000000000002');\n    INSERT INTO t1(oid,a,x) VALUES(2097152,42,'0000000000200000');\n    INSERT INTO t1(oid,a,x) VALUES(562949953421312,43,'0002000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355328,44,'ffff800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963968,45,'0080000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(549755813887,46,'0000007fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483649,47,'ffffffff7fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(65535,48,'000000000000ffff');\n    INSERT INTO t1(oid,a,x) VALUES(128,49,'0000000000000080');\n    INSERT INTO t1(oid,a,x) VALUES(32768,50,'0000000000008000');\n    INSERT INTO t1(oid,a,x) VALUES(2147483648,51,'0000000080000000');\n    INSERT INTO t1(oid,a,x) VALUES(-3,52,'fffffffffffffffd');\n    INSERT INTO t1(oid,a,x) VALUES(-128,53,'ffffffffffffff80');\n    INSERT INTO t1(oid,a,x) VALUES(-129,54,'ffffffffffffff7f');\n    INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,55,'8000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(4398046511104,56,'0000040000000000');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627775,57,'000000ffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813889,58,'ffffff7fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(0,59,'0000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(1,60,'0000000000000001');\n    INSERT INTO t1(oid,a,x) VALUES(256,61,'0000000000000100');\n    INSERT INTO t1(oid,a,x) VALUES(65536,62,'0000000000010000');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813888,63,'ffffff8000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,64,'ff80000000000000');\n    CREATE INDEX t1i1 ON t1(a);\n    CREATE INDEX t1i2 ON t1(x);\n  }\n} {}\ndo_test boundary3-1.2 {\n  db eval {\n    SELECT count(*) FROM t1\n  }\n} {64}\ndo_test boundary3-1.3 {\n  db eval {\n    CREATE TABLE t2(r,a);\n    INSERT INTO t2 SELECT rowid, a FROM t1;\n    CREATE INDEX t2i1 ON t2(r);\n    CREATE INDEX t2i2 ON t2(a);\n    INSERT INTO t2 VALUES(9.22337303685477580800e+18,65);\n    INSERT INTO t2 VALUES(-9.22337303685477580800e+18,66);\n    SELECT count(*) FROM t2;\n  }\n} {66}\ndo_test boundary3-2.1.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=72057594037927935 AND t2.a=t1.a\n  }\n} {17 00ffffffffffffff}\ndo_test boundary3-2.1.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00ffffffffffffff'\n  }\n} {72057594037927935 17}\ndo_test boundary3-2.1.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=17\n  }\n} {72057594037927935 00ffffffffffffff}\ndo_test boundary3-2.1.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 72057594037927935 ORDER BY t2.a\n  }\n} {3 28}\ndo_test boundary3-2.1.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 72057594037927935 ORDER BY t1.a DESC\n  }\n} {28 3}\ndo_test boundary3-2.1.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid\n  }\n} {28 3}\ndo_test boundary3-2.1.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid DESC\n  }\n} {3 28}\ndo_test boundary3-2.1.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=17\n     ORDER BY x\n  }\n} {28 3}\ndo_test boundary3-2.1.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 72057594037927935 ORDER BY t2.a\n  }\n} {3 17 28}\ndo_test boundary3-2.1.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 72057594037927935 ORDER BY t1.a DESC\n  }\n} {28 17 3}\ndo_test boundary3-2.1.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid\n  }\n} {17 28 3}\ndo_test boundary3-2.1.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17}\ndo_test boundary3-2.1.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=17\n     ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary3-2.1.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 72057594037927935 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.1.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 72057594037927935 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.1.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary3-2.1.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.1.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=17\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.1.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 72057594037927935 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.1.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 72057594037927935 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.1.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary3-2.1.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=17\n     ORDER BY t1.rowid DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.1.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=17\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.2.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=16384 AND t2.a=t1.a\n  }\n} {16 0000000000004000}\ndo_test boundary3-2.2.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000004000'\n  }\n} {16384 16}\ndo_test boundary3-2.2.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=16\n  }\n} {16384 0000000000004000}\ndo_test boundary3-2.2.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 16384 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.2.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 16384 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.2.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary3-2.2.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=16\n     ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary3-2.2.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 16384 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.2.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 16384 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.2.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary3-2.2.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=16\n     ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.2.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary3-2.2.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 16384 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.2.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 16384 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary3-2.2.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary3-2.2.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.2.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=16\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.2.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary3-2.2.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.2.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 16384 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.2.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 16384 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.2.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary3-2.2.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.2.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=16\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.2.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary3-2.2.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=16\n     ORDER BY t1.rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.3.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=4294967296 AND t2.a=t1.a\n  }\n} {36 0000000100000000}\ndo_test boundary3-2.3.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000100000000'\n  }\n} {4294967296 36}\ndo_test boundary3-2.3.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=36\n  }\n} {4294967296 0000000100000000}\ndo_test boundary3-2.3.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 4294967296 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary3-2.3.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 4294967296 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.3.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary3-2.3.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=36\n     ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary3-2.3.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 4294967296 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary3-2.3.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 4294967296 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.3.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary3-2.3.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=36\n     ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.3.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary3-2.3.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 4294967296 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.3.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 4294967296 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.3.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary3-2.3.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.3.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=36\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.3.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary3-2.3.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.3.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 4294967296 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.3.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 4294967296 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.3.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary3-2.3.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.3.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=36\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.3.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary3-2.3.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=36\n     ORDER BY t1.rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.4.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=16777216 AND t2.a=t1.a\n  }\n} {6 0000000001000000}\ndo_test boundary3-2.4.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000001000000'\n  }\n} {16777216 6}\ndo_test boundary3-2.4.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=6\n  }\n} {16777216 0000000001000000}\ndo_test boundary3-2.4.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 16777216 ORDER BY t2.a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.4.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 16777216 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary3-2.4.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary3-2.4.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=6\n     ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary3-2.4.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 16777216 ORDER BY t2.a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.4.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 16777216 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary3-2.4.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary3-2.4.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=6\n     ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.4.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary3-2.4.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 16777216 ORDER BY t2.a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.4.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 16777216 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary3-2.4.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary3-2.4.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.4.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=6\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.4.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary3-2.4.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.4.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 16777216 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.4.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 16777216 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.4.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary3-2.4.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.4.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=6\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.4.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary3-2.4.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=6\n     ORDER BY t1.rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.5.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-32769 AND t2.a=t1.a\n  }\n} {29 ffffffffffff7fff}\ndo_test boundary3-2.5.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffff7fff'\n  }\n} {-32769 29}\ndo_test boundary3-2.5.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=29\n  }\n} {-32769 ffffffffffff7fff}\ndo_test boundary3-2.5.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -32769 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.5.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -32769 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.5.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.5.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary3-2.5.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=29\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary3-2.5.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.5.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary3-2.5.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -32769 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.5.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -32769 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.5.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.5.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary3-2.5.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=29\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary3-2.5.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.5.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary3-2.5.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -32769 ORDER BY t2.a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary3-2.5.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -32769 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary3-2.5.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.5.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.5.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=29\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.5.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.5.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.5.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -32769 ORDER BY t2.a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary3-2.5.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -32769 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary3-2.5.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.5.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.5.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=29\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.5.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.5.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=29\n     ORDER BY t1.rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.6.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-140737488355329 AND t2.a=t1.a\n  }\n} {21 ffff7fffffffffff}\ndo_test boundary3-2.6.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffff7fffffffffff'\n  }\n} {-140737488355329 21}\ndo_test boundary3-2.6.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=21\n  }\n} {-140737488355329 ffff7fffffffffff}\ndo_test boundary3-2.6.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -140737488355329 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.6.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -140737488355329 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.6.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.6.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary3-2.6.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=21\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.6.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -140737488355329 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.6.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -140737488355329 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.6.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.6.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary3-2.6.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=21\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.6.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -140737488355329 ORDER BY t2.a\n  }\n} {2 55 64}\ndo_test boundary3-2.6.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -140737488355329 ORDER BY t1.a DESC\n  }\n} {64 55 2}\ndo_test boundary3-2.6.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid\n  }\n} {55 2 64}\ndo_test boundary3-2.6.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid DESC\n  }\n} {64 2 55}\ndo_test boundary3-2.6.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=21\n     ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary3-2.6.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -140737488355329 ORDER BY t2.a\n  }\n} {2 21 55 64}\ndo_test boundary3-2.6.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -140737488355329 ORDER BY t1.a DESC\n  }\n} {64 55 21 2}\ndo_test boundary3-2.6.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21}\ndo_test boundary3-2.6.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=21\n     ORDER BY t1.rowid DESC\n  }\n} {21 64 2 55}\ndo_test boundary3-2.6.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=21\n     ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary3-2.7.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=2 AND t2.a=t1.a\n  }\n} {41 0000000000000002}\ndo_test boundary3-2.7.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000002'\n  }\n} {2 41}\ndo_test boundary3-2.7.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=41\n  }\n} {2 0000000000000002}\ndo_test boundary3-2.7.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 2 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.7.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 2 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.7.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary3-2.7.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=41\n     ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary3-2.7.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 2 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.7.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 2 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.7.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary3-2.7.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=41\n     ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.7.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary3-2.7.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 2 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.7.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 2 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.7.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary3-2.7.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.7.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=41\n     ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.7.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary3-2.7.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.7.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 2 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.7.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 2 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.7.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary3-2.7.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.7.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=41\n     ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.7.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary3-2.7.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=41\n     ORDER BY t1.rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.8.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=4 AND t2.a=t1.a\n  }\n} {31 0000000000000004}\ndo_test boundary3-2.8.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000004'\n  }\n} {4 31}\ndo_test boundary3-2.8.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=31\n  }\n} {4 0000000000000004}\ndo_test boundary3-2.8.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 4 ORDER BY t2.a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.8.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 4 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary3-2.8.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary3-2.8.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=31\n     ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary3-2.8.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 4 ORDER BY t2.a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.8.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 4 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary3-2.8.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary3-2.8.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=31\n     ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.8.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary3-2.8.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 4 ORDER BY t2.a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.8.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 4 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary3-2.8.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary3-2.8.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.8.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=31\n     ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.8.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary3-2.8.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.8.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 4 ORDER BY t2.a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.8.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 4 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary3-2.8.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary3-2.8.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.8.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=31\n     ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.8.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary3-2.8.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=31\n     ORDER BY t1.rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.9.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=562949953421311 AND t2.a=t1.a\n  }\n} {13 0001ffffffffffff}\ndo_test boundary3-2.9.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0001ffffffffffff'\n  }\n} {562949953421311 13}\ndo_test boundary3-2.9.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=13\n  }\n} {562949953421311 0001ffffffffffff}\ndo_test boundary3-2.9.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 562949953421311 ORDER BY t2.a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary3-2.9.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 562949953421311 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary3-2.9.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid\n  }\n} {43 27 45 17 28 3}\ndo_test boundary3-2.9.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary3-2.9.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=13\n     ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary3-2.9.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 562949953421311 ORDER BY t2.a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary3-2.9.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 562949953421311 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary3-2.9.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary3-2.9.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary3-2.9.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=13\n     ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary3-2.9.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 562949953421311 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.9.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 562949953421311 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.9.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary3-2.9.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.9.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=13\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.9.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 562949953421311 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.9.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 562949953421311 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.9.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary3-2.9.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=13\n     ORDER BY t1.rowid DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.9.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=13\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.10.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=256 AND t2.a=t1.a\n  }\n} {61 0000000000000100}\ndo_test boundary3-2.10.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000100'\n  }\n} {256 61}\ndo_test boundary3-2.10.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=61\n  }\n} {256 0000000000000100}\ndo_test boundary3-2.10.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 256 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.10.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 256 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.10.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary3-2.10.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=61\n     ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary3-2.10.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 256 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary3-2.10.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 256 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.10.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary3-2.10.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=61\n     ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.10.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary3-2.10.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 256 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.10.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 256 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary3-2.10.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary3-2.10.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.10.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=61\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.10.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary3-2.10.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.10.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 256 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.10.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 256 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary3-2.10.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary3-2.10.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.10.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=61\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.10.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary3-2.10.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=61\n     ORDER BY t1.rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.11.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=34359738368 AND t2.a=t1.a\n  }\n} {22 0000000800000000}\ndo_test boundary3-2.11.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000800000000'\n  }\n} {34359738368 22}\ndo_test boundary3-2.11.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=22\n  }\n} {34359738368 0000000800000000}\ndo_test boundary3-2.11.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 34359738368 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary3-2.11.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 34359738368 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.11.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary3-2.11.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=22\n     ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary3-2.11.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 34359738368 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary3-2.11.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 34359738368 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.11.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary3-2.11.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=22\n     ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.11.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary3-2.11.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 34359738368 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.11.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 34359738368 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.11.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary3-2.11.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.11.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=22\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.11.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary3-2.11.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.11.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 34359738368 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.11.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 34359738368 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.11.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary3-2.11.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.11.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=22\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.11.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary3-2.11.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=22\n     ORDER BY t1.rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.12.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=65536 AND t2.a=t1.a\n  }\n} {62 0000000000010000}\ndo_test boundary3-2.12.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000010000'\n  }\n} {65536 62}\ndo_test boundary3-2.12.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=62\n  }\n} {65536 0000000000010000}\ndo_test boundary3-2.12.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 65536 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary3-2.12.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 65536 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.12.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary3-2.12.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=62\n     ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary3-2.12.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 65536 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary3-2.12.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 65536 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.12.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary3-2.12.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=62\n     ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.12.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary3-2.12.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 65536 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.12.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 65536 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.12.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary3-2.12.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.12.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=62\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.12.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary3-2.12.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.12.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 65536 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.12.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 65536 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.12.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary3-2.12.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.12.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=62\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.12.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary3-2.12.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=62\n     ORDER BY t1.rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.13.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=268435456 AND t2.a=t1.a\n  }\n} {40 0000000010000000}\ndo_test boundary3-2.13.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000010000000'\n  }\n} {268435456 40}\ndo_test boundary3-2.13.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=40\n  }\n} {268435456 0000000010000000}\ndo_test boundary3-2.13.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 268435456 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary3-2.13.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 268435456 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary3-2.13.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary3-2.13.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=40\n     ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary3-2.13.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 268435456 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.13.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 268435456 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary3-2.13.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary3-2.13.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=40\n     ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.13.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary3-2.13.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 268435456 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.13.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 268435456 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.13.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary3-2.13.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.13.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=40\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.13.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary3-2.13.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.13.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 268435456 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.13.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 268435456 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.13.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary3-2.13.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.13.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=40\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.13.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary3-2.13.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=40\n     ORDER BY t1.rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.14.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-140737488355328 AND t2.a=t1.a\n  }\n} {44 ffff800000000000}\ndo_test boundary3-2.14.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffff800000000000'\n  }\n} {-140737488355328 44}\ndo_test boundary3-2.14.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=44\n  }\n} {-140737488355328 ffff800000000000}\ndo_test boundary3-2.14.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -140737488355328 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.14.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -140737488355328 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.14.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.14.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary3-2.14.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=44\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.14.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -140737488355328 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.14.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -140737488355328 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.14.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid\n  }\n} {44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.14.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44}\ndo_test boundary3-2.14.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=44\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.14.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -140737488355328 ORDER BY t2.a\n  }\n} {2 21 55 64}\ndo_test boundary3-2.14.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -140737488355328 ORDER BY t1.a DESC\n  }\n} {64 55 21 2}\ndo_test boundary3-2.14.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21}\ndo_test boundary3-2.14.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid DESC\n  }\n} {21 64 2 55}\ndo_test boundary3-2.14.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=44\n     ORDER BY x\n  }\n} {55 2 64 21}\ndo_test boundary3-2.14.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -140737488355328 ORDER BY t2.a\n  }\n} {2 21 44 55 64}\ndo_test boundary3-2.14.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -140737488355328 ORDER BY t1.a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary3-2.14.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44}\ndo_test boundary3-2.14.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=44\n     ORDER BY t1.rowid DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary3-2.14.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=44\n     ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary3-2.15.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=1099511627776 AND t2.a=t1.a\n  }\n} {19 0000010000000000}\ndo_test boundary3-2.15.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000010000000000'\n  }\n} {1099511627776 19}\ndo_test boundary3-2.15.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=19\n  }\n} {1099511627776 0000010000000000}\ndo_test boundary3-2.15.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 1099511627776 ORDER BY t2.a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.15.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 1099511627776 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary3-2.15.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary3-2.15.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=19\n     ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary3-2.15.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 1099511627776 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.15.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 1099511627776 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.15.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary3-2.15.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=19\n     ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.15.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary3-2.15.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 1099511627776 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.15.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 1099511627776 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.15.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary3-2.15.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.15.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=19\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.15.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary3-2.15.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.15.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 1099511627776 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.15.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 1099511627776 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.15.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary3-2.15.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.15.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=19\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.15.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary3-2.15.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=19\n     ORDER BY t1.rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.16.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 9223372036854775807 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.16.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 9223372036854775807 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.16.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.16.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.16.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=3\n     ORDER BY x\n  }\n} {}\ndo_test boundary3-2.16.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 9223372036854775807 ORDER BY t2.a\n  }\n} {3}\ndo_test boundary3-2.16.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 9223372036854775807 ORDER BY t1.a DESC\n  }\n} {3}\ndo_test boundary3-2.16.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid\n  }\n} {3}\ndo_test boundary3-2.16.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid DESC\n  }\n} {3}\ndo_test boundary3-2.16.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=3\n     ORDER BY x\n  }\n} {3}\ndo_test boundary3-2.16.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 9223372036854775807 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.16.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 9223372036854775807 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.16.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary3-2.16.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.16.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=3\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.16.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 9223372036854775807 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.16.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 9223372036854775807 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.16.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.16.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=3\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.16.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=3\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.17.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=32768 AND t2.a=t1.a\n  }\n} {50 0000000000008000}\ndo_test boundary3-2.17.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000008000'\n  }\n} {32768 50}\ndo_test boundary3-2.17.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=50\n  }\n} {32768 0000000000008000}\ndo_test boundary3-2.17.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 32768 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary3-2.17.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 32768 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.17.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary3-2.17.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=50\n     ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary3-2.17.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 32768 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.17.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 32768 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.17.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary3-2.17.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=50\n     ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.17.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary3-2.17.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 32768 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.17.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 32768 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.17.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary3-2.17.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.17.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=50\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.17.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary3-2.17.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.17.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 32768 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.17.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 32768 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.17.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary3-2.17.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.17.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=50\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.17.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary3-2.17.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=50\n     ORDER BY t1.rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.18.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-36028797018963968 AND t2.a=t1.a\n  }\n} {64 ff80000000000000}\ndo_test boundary3-2.18.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ff80000000000000'\n  }\n} {-36028797018963968 64}\ndo_test boundary3-2.18.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=64\n  }\n} {-36028797018963968 ff80000000000000}\ndo_test boundary3-2.18.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -36028797018963968 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.18.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -36028797018963968 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.18.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid\n  }\n} {21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.18.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21}\ndo_test boundary3-2.18.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=64\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.18.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -36028797018963968 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.18.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -36028797018963968 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.18.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.18.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary3-2.18.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=64\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.18.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -36028797018963968 ORDER BY t2.a\n  }\n} {2 55}\ndo_test boundary3-2.18.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -36028797018963968 ORDER BY t1.a DESC\n  }\n} {55 2}\ndo_test boundary3-2.18.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid\n  }\n} {55 2}\ndo_test boundary3-2.18.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid DESC\n  }\n} {2 55}\ndo_test boundary3-2.18.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=64\n     ORDER BY x\n  }\n} {55 2}\ndo_test boundary3-2.18.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -36028797018963968 ORDER BY t2.a\n  }\n} {2 55 64}\ndo_test boundary3-2.18.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -36028797018963968 ORDER BY t1.a DESC\n  }\n} {64 55 2}\ndo_test boundary3-2.18.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid\n  }\n} {55 2 64}\ndo_test boundary3-2.18.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=64\n     ORDER BY t1.rowid DESC\n  }\n} {64 2 55}\ndo_test boundary3-2.18.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=64\n     ORDER BY x\n  }\n} {55 2 64}\ndo_test boundary3-2.19.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=65535 AND t2.a=t1.a\n  }\n} {48 000000000000ffff}\ndo_test boundary3-2.19.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000000ffff'\n  }\n} {65535 48}\ndo_test boundary3-2.19.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=48\n  }\n} {65535 000000000000ffff}\ndo_test boundary3-2.19.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 65535 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57 62}\ndo_test boundary3-2.19.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 65535 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.19.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary3-2.19.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=48\n     ORDER BY x\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62}\ndo_test boundary3-2.19.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 65535 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 51 56 57 62}\ndo_test boundary3-2.19.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 65535 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.19.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary3-2.19.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=48\n     ORDER BY x\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.19.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48}\ndo_test boundary3-2.19.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 65535 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.19.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 65535 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.19.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary3-2.19.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.19.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=48\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.19.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50}\ndo_test boundary3-2.19.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.19.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 65535 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.19.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 65535 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.19.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary3-2.19.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.19.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=48\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.19.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48}\ndo_test boundary3-2.19.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=48\n     ORDER BY t1.rowid DESC\n  }\n} {48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.20.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=4294967295 AND t2.a=t1.a\n  }\n} {14 00000000ffffffff}\ndo_test boundary3-2.20.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000ffffffff'\n  }\n} {4294967295 14}\ndo_test boundary3-2.20.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=14\n  }\n} {4294967295 00000000ffffffff}\ndo_test boundary3-2.20.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 4294967295 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary3-2.20.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 4294967295 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.20.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary3-2.20.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=14\n     ORDER BY x\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36}\ndo_test boundary3-2.20.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 4294967295 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary3-2.20.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 4294967295 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary3-2.20.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary3-2.20.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=14\n     ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.20.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary3-2.20.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 4294967295 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.20.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 4294967295 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.20.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary3-2.20.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.20.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=14\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.20.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary3-2.20.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.20.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 4294967295 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.20.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 4294967295 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.20.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary3-2.20.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.20.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=14\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.20.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14}\ndo_test boundary3-2.20.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=14\n     ORDER BY t1.rowid DESC\n  }\n} {14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.21.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=1099511627775 AND t2.a=t1.a\n  }\n} {57 000000ffffffffff}\ndo_test boundary3-2.21.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000ffffffffff'\n  }\n} {1099511627775 57}\ndo_test boundary3-2.21.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=57\n  }\n} {1099511627775 000000ffffffffff}\ndo_test boundary3-2.21.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 1099511627775 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.21.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 1099511627775 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.21.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary3-2.21.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=57\n     ORDER BY x\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19}\ndo_test boundary3-2.21.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 1099511627775 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary3-2.21.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 1099511627775 ORDER BY t1.a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.21.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary3-2.21.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=57\n     ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.21.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary3-2.21.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 1099511627775 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.21.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 1099511627775 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.21.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary3-2.21.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.21.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=57\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.21.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary3-2.21.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.21.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 1099511627775 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.21.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 1099511627775 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.21.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary3-2.21.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.21.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=57\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.21.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57}\ndo_test boundary3-2.21.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=57\n     ORDER BY t1.rowid DESC\n  }\n} {57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.22.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-8388608 AND t2.a=t1.a\n  }\n} {37 ffffffffff800000}\ndo_test boundary3-2.22.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffff800000'\n  }\n} {-8388608 37}\ndo_test boundary3-2.22.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=37\n  }\n} {-8388608 ffffffffff800000}\ndo_test boundary3-2.22.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -8388608 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.22.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -8388608 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.22.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.22.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary3-2.22.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=37\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 29 32 54 53 52 33 38}\ndo_test boundary3-2.22.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.22.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29}\ndo_test boundary3-2.22.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -8388608 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.22.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -8388608 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.22.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.22.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary3-2.22.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=37\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.22.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.22.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary3-2.22.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -8388608 ORDER BY t2.a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary3-2.22.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -8388608 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary3-2.22.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.22.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.22.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=37\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.22.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.22.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.22.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -8388608 ORDER BY t2.a\n  }\n} {1 2 11 21 37 44 47 55 58 63 64}\ndo_test boundary3-2.22.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -8388608 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 21 11 2 1}\ndo_test boundary3-2.22.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.22.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.22.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=37\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.22.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37}\ndo_test boundary3-2.22.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=37\n     ORDER BY t1.rowid DESC\n  }\n} {37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.23.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=549755813888 AND t2.a=t1.a\n  }\n} {35 0000008000000000}\ndo_test boundary3-2.23.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000008000000000'\n  }\n} {549755813888 35}\ndo_test boundary3-2.23.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=35\n  }\n} {549755813888 0000008000000000}\ndo_test boundary3-2.23.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 549755813888 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 43 45 56 57}\ndo_test boundary3-2.23.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 549755813888 ORDER BY t1.a DESC\n  }\n} {57 56 45 43 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.23.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary3-2.23.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=35\n     ORDER BY x\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57}\ndo_test boundary3-2.23.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 549755813888 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary3-2.23.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 549755813888 ORDER BY t1.a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.23.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary3-2.23.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=35\n     ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.23.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary3-2.23.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 549755813888 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.23.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 549755813888 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.23.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary3-2.23.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.23.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=35\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.23.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary3-2.23.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.23.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 549755813888 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.23.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 549755813888 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.23.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary3-2.23.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.23.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=35\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.23.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35}\ndo_test boundary3-2.23.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=35\n     ORDER BY t1.rowid DESC\n  }\n} {35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.24.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=8388607 AND t2.a=t1.a\n  }\n} {18 00000000007fffff}\ndo_test boundary3-2.24.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000007fffff'\n  }\n} {8388607 18}\ndo_test boundary3-2.24.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=18\n  }\n} {8388607 00000000007fffff}\ndo_test boundary3-2.24.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 8388607 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.24.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 8388607 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.24.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary3-2.24.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=18\n     ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary3-2.24.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 8388607 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.24.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 8388607 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.24.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary3-2.24.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=18\n     ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.24.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary3-2.24.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 8388607 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.24.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 8388607 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.24.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary3-2.24.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.24.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=18\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.24.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary3-2.24.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.24.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 8388607 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.24.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 8388607 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.24.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary3-2.24.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.24.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=18\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.24.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary3-2.24.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=18\n     ORDER BY t1.rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.25.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-3 AND t2.a=t1.a\n  }\n} {52 fffffffffffffffd}\ndo_test boundary3-2.25.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='fffffffffffffffd'\n  }\n} {-3 52}\ndo_test boundary3-2.25.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=52\n  }\n} {-3 fffffffffffffffd}\ndo_test boundary3-2.25.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -3 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.25.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -3 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.25.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.25.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary3-2.25.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=52\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary3-2.25.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.25.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary3-2.25.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -3 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary3-2.25.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -3 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.25.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.25.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary3-2.25.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=52\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary3-2.25.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.25.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary3-2.25.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -3 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary3-2.25.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -3 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.25.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.25.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.25.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=52\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.25.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.25.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.25.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -3 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.25.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -3 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.25.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.25.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.25.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=52\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.25.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.25.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=52\n     ORDER BY t1.rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.26.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=0 AND t2.a=t1.a\n  }\n} {59 0000000000000000}\ndo_test boundary3-2.26.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000000'\n  }\n} {0 59}\ndo_test boundary3-2.26.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=59\n  }\n} {0 0000000000000000}\ndo_test boundary3-2.26.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 0 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary3-2.26.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 0 ORDER BY t1.a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.26.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary3-2.26.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=59\n     ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary3-2.26.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 0 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.26.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 0 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.26.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary3-2.26.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=59\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.26.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary3-2.26.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 0 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.26.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 0 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.26.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.26.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.26.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=59\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.26.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.26.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.26.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 0 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary3-2.26.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 0 ORDER BY t1.a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.26.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary3-2.26.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.26.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=59\n     ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.26.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary3-2.26.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=59\n     ORDER BY t1.rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.27.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-1 AND t2.a=t1.a\n  }\n} {38 ffffffffffffffff}\ndo_test boundary3-2.27.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffffff'\n  }\n} {-1 38}\ndo_test boundary3-2.27.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=38\n  }\n} {-1 ffffffffffffffff}\ndo_test boundary3-2.27.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -1 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.27.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -1 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.27.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.27.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary3-2.27.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=38\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.27.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.27.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59}\ndo_test boundary3-2.27.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -1 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.27.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -1 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.27.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.27.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary3-2.27.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=38\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary3-2.27.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.27.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary3-2.27.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -1 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.27.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -1 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.27.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.27.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.27.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=38\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.27.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.27.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.27.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -1 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.27.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -1 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.27.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.27.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.27.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=38\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.27.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.27.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=38\n     ORDER BY t1.rowid DESC\n  }\n} {38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.28.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2 AND t2.a=t1.a\n  }\n} {33 fffffffffffffffe}\ndo_test boundary3-2.28.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='fffffffffffffffe'\n  }\n} {-2 33}\ndo_test boundary3-2.28.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=33\n  }\n} {-2 fffffffffffffffe}\ndo_test boundary3-2.28.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -2 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.28.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -2 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.28.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.28.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary3-2.28.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=33\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 38}\ndo_test boundary3-2.28.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.28.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38}\ndo_test boundary3-2.28.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -2 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 56 57 59 60 61 62}\ndo_test boundary3-2.28.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -2 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.28.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.28.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary3-2.28.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=33\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 33 38}\ndo_test boundary3-2.28.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.28.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33}\ndo_test boundary3-2.28.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -2 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.28.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -2 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.28.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.28.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.28.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=33\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.28.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52}\ndo_test boundary3-2.28.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.28.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -2 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 44 47 52 53 54 55 58 63 64}\ndo_test boundary3-2.28.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -2 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 52 47 44 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.28.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.28.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.28.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=33\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.28.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33}\ndo_test boundary3-2.28.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=33\n     ORDER BY t1.rowid DESC\n  }\n} {33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.29.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=2097152 AND t2.a=t1.a\n  }\n} {42 0000000000200000}\ndo_test boundary3-2.29.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000200000'\n  }\n} {2097152 42}\ndo_test boundary3-2.29.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=42\n  }\n} {2097152 0000000000200000}\ndo_test boundary3-2.29.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 2097152 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.29.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 2097152 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.29.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary3-2.29.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=42\n     ORDER BY x\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18}\ndo_test boundary3-2.29.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 2097152 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary3-2.29.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 2097152 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.29.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary3-2.29.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=42\n     ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.29.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary3-2.29.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 2097152 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.29.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 2097152 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.29.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary3-2.29.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.29.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=42\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.29.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary3-2.29.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.29.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 2097152 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.29.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 2097152 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.29.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary3-2.29.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.29.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=42\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.29.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42}\ndo_test boundary3-2.29.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=42\n     ORDER BY t1.rowid DESC\n  }\n} {42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.30.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=128 AND t2.a=t1.a\n  }\n} {49 0000000000000080}\ndo_test boundary3-2.30.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000080'\n  }\n} {128 49}\ndo_test boundary3-2.30.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=49\n  }\n} {128 0000000000000080}\ndo_test boundary3-2.30.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 128 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary3-2.30.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 128 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.30.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary3-2.30.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=49\n     ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary3-2.30.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 128 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.30.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 128 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.30.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary3-2.30.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=49\n     ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.30.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary3-2.30.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 128 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.30.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 128 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary3-2.30.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary3-2.30.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.30.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=49\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.30.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary3-2.30.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.30.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 128 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.30.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 128 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary3-2.30.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary3-2.30.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.30.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=49\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.30.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary3-2.30.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=49\n     ORDER BY t1.rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.31.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=255 AND t2.a=t1.a\n  }\n} {30 00000000000000ff}\ndo_test boundary3-2.31.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000000000ff'\n  }\n} {255 30}\ndo_test boundary3-2.31.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=30\n  }\n} {255 00000000000000ff}\ndo_test boundary3-2.31.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 255 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary3-2.31.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 255 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.31.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary3-2.31.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=30\n     ORDER BY x\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61}\ndo_test boundary3-2.31.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 255 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 50 51 56 57 61 62}\ndo_test boundary3-2.31.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 255 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.31.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary3-2.31.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=30\n     ORDER BY x\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.31.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30}\ndo_test boundary3-2.31.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 255 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.31.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 255 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary3-2.31.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary3-2.31.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.31.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=30\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.31.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49}\ndo_test boundary3-2.31.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.31.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 255 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.31.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 255 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary3-2.31.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary3-2.31.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.31.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=30\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.31.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30}\ndo_test boundary3-2.31.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=30\n     ORDER BY t1.rowid DESC\n  }\n} {30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.32.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2147483648 AND t2.a=t1.a\n  }\n} {11 ffffffff80000000}\ndo_test boundary3-2.32.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffff80000000'\n  }\n} {-2147483648 11}\ndo_test boundary3-2.32.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=11\n  }\n} {-2147483648 ffffffff80000000}\ndo_test boundary3-2.32.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -2147483648 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.32.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -2147483648 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.32.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.32.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary3-2.32.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=11\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.32.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.32.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary3-2.32.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -2147483648 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.32.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -2147483648 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.32.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.32.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary3-2.32.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=11\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.32.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.32.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary3-2.32.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -2147483648 ORDER BY t2.a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary3-2.32.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -2147483648 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary3-2.32.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.32.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary3-2.32.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=11\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.32.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.32.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary3-2.32.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -2147483648 ORDER BY t2.a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary3-2.32.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -2147483648 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary3-2.32.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.32.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.32.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=11\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.32.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.32.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=11\n     ORDER BY t1.rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.33.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=34359738367 AND t2.a=t1.a\n  }\n} {39 00000007ffffffff}\ndo_test boundary3-2.33.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000007ffffffff'\n  }\n} {34359738367 39}\ndo_test boundary3-2.33.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=39\n  }\n} {34359738367 00000007ffffffff}\ndo_test boundary3-2.33.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 34359738367 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary3-2.33.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 34359738367 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.33.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary3-2.33.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=39\n     ORDER BY x\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22}\ndo_test boundary3-2.33.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 34359738367 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 22 25 26 27 28 34 35 39 43 45 46 56 57}\ndo_test boundary3-2.33.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 34359738367 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 35 34 28 27 26 25 22 19 17 13 10 7 3}\ndo_test boundary3-2.33.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary3-2.33.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=39\n     ORDER BY x\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.33.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39}\ndo_test boundary3-2.33.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 34359738367 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.33.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 34359738367 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.33.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary3-2.33.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.33.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=39\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.33.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36}\ndo_test boundary3-2.33.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.33.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 34359738367 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.33.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 34359738367 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.33.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary3-2.33.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.33.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=39\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.33.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39}\ndo_test boundary3-2.33.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=39\n     ORDER BY t1.rowid DESC\n  }\n} {39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.34.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-549755813889 AND t2.a=t1.a\n  }\n} {58 ffffff7fffffffff}\ndo_test boundary3-2.34.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffff7fffffffff'\n  }\n} {-549755813889 58}\ndo_test boundary3-2.34.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=58\n  }\n} {-549755813889 ffffff7fffffffff}\ndo_test boundary3-2.34.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -549755813889 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary3-2.34.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -549755813889 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.34.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.34.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary3-2.34.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=58\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.34.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.34.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary3-2.34.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -549755813889 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63}\ndo_test boundary3-2.34.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -549755813889 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.34.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.34.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary3-2.34.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=58\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.34.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.34.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58}\ndo_test boundary3-2.34.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -549755813889 ORDER BY t2.a\n  }\n} {2 21 44 55 64}\ndo_test boundary3-2.34.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -549755813889 ORDER BY t1.a DESC\n  }\n} {64 55 44 21 2}\ndo_test boundary3-2.34.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44}\ndo_test boundary3-2.34.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary3-2.34.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=58\n     ORDER BY x\n  }\n} {55 2 64 21 44}\ndo_test boundary3-2.34.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44}\ndo_test boundary3-2.34.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {44 21 64 2 55}\ndo_test boundary3-2.34.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -549755813889 ORDER BY t2.a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary3-2.34.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -549755813889 ORDER BY t1.a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary3-2.34.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.34.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary3-2.34.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=58\n     ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.34.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.34.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=58\n     ORDER BY t1.rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary3-2.35.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-32768 AND t2.a=t1.a\n  }\n} {32 ffffffffffff8000}\ndo_test boundary3-2.35.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffff8000'\n  }\n} {-32768 32}\ndo_test boundary3-2.35.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=32\n  }\n} {-32768 ffffffffffff8000}\ndo_test boundary3-2.35.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -32768 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.35.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -32768 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.35.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.35.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary3-2.35.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=32\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary3-2.35.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.35.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary3-2.35.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -32768 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.35.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -32768 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 32 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.35.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.35.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary3-2.35.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=32\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 32 54 53 52 33 38}\ndo_test boundary3-2.35.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.35.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32}\ndo_test boundary3-2.35.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -32768 ORDER BY t2.a\n  }\n} {1 2 11 21 29 37 44 47 55 58 63 64}\ndo_test boundary3-2.35.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -32768 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 29 21 11 2 1}\ndo_test boundary3-2.35.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.35.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.35.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=32\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.35.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29}\ndo_test boundary3-2.35.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.35.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -32768 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary3-2.35.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -32768 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.35.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.35.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.35.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=32\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.35.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.35.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=32\n     ORDER BY t1.rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.36.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=2147483647 AND t2.a=t1.a\n  }\n} {20 000000007fffffff}\ndo_test boundary3-2.36.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000007fffffff'\n  }\n} {2147483647 20}\ndo_test boundary3-2.36.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=20\n  }\n} {2147483647 000000007fffffff}\ndo_test boundary3-2.36.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 2147483647 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary3-2.36.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 2147483647 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary3-2.36.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary3-2.36.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=20\n     ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary3-2.36.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 2147483647 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary3-2.36.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 2147483647 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary3-2.36.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary3-2.36.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=20\n     ORDER BY x\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.36.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20}\ndo_test boundary3-2.36.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 2147483647 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.36.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 2147483647 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.36.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary3-2.36.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.36.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=20\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.36.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40}\ndo_test boundary3-2.36.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.36.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 2147483647 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.36.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 2147483647 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.36.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary3-2.36.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.36.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=20\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.36.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary3-2.36.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=20\n     ORDER BY t1.rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.37.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-129 AND t2.a=t1.a\n  }\n} {54 ffffffffffffff7f}\ndo_test boundary3-2.37.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffff7f'\n  }\n} {-129 54}\ndo_test boundary3-2.37.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=54\n  }\n} {-129 ffffffffffffff7f}\ndo_test boundary3-2.37.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -129 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary3-2.37.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -129 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.37.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.37.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary3-2.37.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=54\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary3-2.37.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.37.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary3-2.37.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -129 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.37.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -129 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.37.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.37.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary3-2.37.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=54\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 54 53 52 33 38}\ndo_test boundary3-2.37.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.37.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54}\ndo_test boundary3-2.37.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -129 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 55 58 63 64}\ndo_test boundary3-2.37.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -129 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.37.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.37.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.37.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=54\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.37.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32}\ndo_test boundary3-2.37.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.37.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -129 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary3-2.37.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -129 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.37.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.37.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.37.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=54\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.37.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.37.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=54\n     ORDER BY t1.rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.38.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-128 AND t2.a=t1.a\n  }\n} {53 ffffffffffffff80}\ndo_test boundary3-2.38.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffffffff80'\n  }\n} {-128 53}\ndo_test boundary3-2.38.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=53\n  }\n} {-128 ffffffffffffff80}\ndo_test boundary3-2.38.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -128 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 56 57 59 60 61 62}\ndo_test boundary3-2.38.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -128 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.38.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.38.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary3-2.38.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=53\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 52 33 38}\ndo_test boundary3-2.38.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.38.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52}\ndo_test boundary3-2.38.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -128 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 33 34 35 36 38 39 40 41 42 43 45 46 48 49 50 51 52 53 56 57 59 60 61 62}\ndo_test boundary3-2.38.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -128 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 53 52 51 50 49 48 46 45 43 42 41 40 39 38 36 35 34 33 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.38.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.38.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary3-2.38.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=53\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 53 52 33 38}\ndo_test boundary3-2.38.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.38.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53}\ndo_test boundary3-2.38.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -128 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 54 55 58 63 64}\ndo_test boundary3-2.38.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -128 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.38.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.38.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.38.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=53\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.38.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54}\ndo_test boundary3-2.38.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.38.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -128 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 37 44 47 53 54 55 58 63 64}\ndo_test boundary3-2.38.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -128 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 54 53 47 44 37 32 29 21 11 2 1}\ndo_test boundary3-2.38.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.38.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.38.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=53\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.38.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53}\ndo_test boundary3-2.38.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=53\n     ORDER BY t1.rowid DESC\n  }\n} {53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.39.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=72057594037927936 AND t2.a=t1.a\n  }\n} {28 0100000000000000}\ndo_test boundary3-2.39.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0100000000000000'\n  }\n} {72057594037927936 28}\ndo_test boundary3-2.39.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=28\n  }\n} {72057594037927936 0100000000000000}\ndo_test boundary3-2.39.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 72057594037927936 ORDER BY t2.a\n  }\n} {3}\ndo_test boundary3-2.39.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 72057594037927936 ORDER BY t1.a DESC\n  }\n} {3}\ndo_test boundary3-2.39.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid\n  }\n} {3}\ndo_test boundary3-2.39.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid DESC\n  }\n} {3}\ndo_test boundary3-2.39.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=28\n     ORDER BY x\n  }\n} {3}\ndo_test boundary3-2.39.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 72057594037927936 ORDER BY t2.a\n  }\n} {3 28}\ndo_test boundary3-2.39.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 72057594037927936 ORDER BY t1.a DESC\n  }\n} {28 3}\ndo_test boundary3-2.39.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid\n  }\n} {28 3}\ndo_test boundary3-2.39.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid DESC\n  }\n} {3 28}\ndo_test boundary3-2.39.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=28\n     ORDER BY x\n  }\n} {28 3}\ndo_test boundary3-2.39.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 72057594037927936 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.39.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 72057594037927936 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.39.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17}\ndo_test boundary3-2.39.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid DESC\n  }\n} {17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.39.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=28\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.39.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 72057594037927936 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.39.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 72057594037927936 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.39.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28}\ndo_test boundary3-2.39.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=28\n     ORDER BY t1.rowid DESC\n  }\n} {28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.39.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=28\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.40.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=2147483648 AND t2.a=t1.a\n  }\n} {51 0000000080000000}\ndo_test boundary3-2.40.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000080000000'\n  }\n} {2147483648 51}\ndo_test boundary3-2.40.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=51\n  }\n} {2147483648 0000000080000000}\ndo_test boundary3-2.40.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 2147483648 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 56 57}\ndo_test boundary3-2.40.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 2147483648 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary3-2.40.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary3-2.40.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=51\n     ORDER BY x\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14}\ndo_test boundary3-2.40.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 2147483648 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 22 25 26 27 28 34 35 36 39 43 45 46 51 56 57}\ndo_test boundary3-2.40.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 2147483648 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 39 36 35 34 28 27 26 25 22 19 17 14 13 10 7 3}\ndo_test boundary3-2.40.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary3-2.40.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=51\n     ORDER BY x\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.40.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51}\ndo_test boundary3-2.40.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 2147483648 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.40.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 2147483648 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.40.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary3-2.40.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.40.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=51\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.40.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20}\ndo_test boundary3-2.40.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.40.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 2147483648 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 20 21 23 24 29 30 31 32 33 37 38 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.40.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 2147483648 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 38 37 33 32 31 30 29 24 23 21 20 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.40.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary3-2.40.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.40.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=51\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.40.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51}\ndo_test boundary3-2.40.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=51\n     ORDER BY t1.rowid DESC\n  }\n} {51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.41.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=549755813887 AND t2.a=t1.a\n  }\n} {46 0000007fffffffff}\ndo_test boundary3-2.41.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000007fffffffff'\n  }\n} {549755813887 46}\ndo_test boundary3-2.41.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=46\n  }\n} {549755813887 0000007fffffffff}\ndo_test boundary3-2.41.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 549755813887 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 56 57}\ndo_test boundary3-2.41.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 549755813887 ORDER BY t1.a DESC\n  }\n} {57 56 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.41.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary3-2.41.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=46\n     ORDER BY x\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35}\ndo_test boundary3-2.41.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 549755813887 ORDER BY t2.a\n  }\n} {3 7 10 13 17 19 25 26 27 28 34 35 43 45 46 56 57}\ndo_test boundary3-2.41.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 549755813887 ORDER BY t1.a DESC\n  }\n} {57 56 46 45 43 35 34 28 27 26 25 19 17 13 10 7 3}\ndo_test boundary3-2.41.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary3-2.41.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=46\n     ORDER BY x\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.41.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46}\ndo_test boundary3-2.41.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 549755813887 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.41.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 549755813887 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.41.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary3-2.41.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.41.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=46\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.41.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22}\ndo_test boundary3-2.41.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.41.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 549755813887 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 20 21 22 23 24 29 30 31 32 33 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.41.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 549755813887 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 33 32 31 30 29 24 23 22 21 20 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.41.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary3-2.41.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.41.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=46\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.41.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46}\ndo_test boundary3-2.41.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=46\n     ORDER BY t1.rowid DESC\n  }\n} {46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.42.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-549755813888 AND t2.a=t1.a\n  }\n} {63 ffffff8000000000}\ndo_test boundary3-2.42.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffff8000000000'\n  }\n} {-549755813888 63}\ndo_test boundary3-2.42.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=63\n  }\n} {-549755813888 ffffff8000000000}\ndo_test boundary3-2.42.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -549755813888 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.42.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -549755813888 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.42.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.42.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary3-2.42.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=63\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.42.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.42.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary3-2.42.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -549755813888 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62 63}\ndo_test boundary3-2.42.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -549755813888 ORDER BY t1.a DESC\n  }\n} {63 62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.42.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.42.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary3-2.42.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=63\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.42.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.42.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63}\ndo_test boundary3-2.42.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -549755813888 ORDER BY t2.a\n  }\n} {2 21 44 55 58 64}\ndo_test boundary3-2.42.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -549755813888 ORDER BY t1.a DESC\n  }\n} {64 58 55 44 21 2}\ndo_test boundary3-2.42.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.42.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary3-2.42.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=63\n     ORDER BY x\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.42.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58}\ndo_test boundary3-2.42.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {58 44 21 64 2 55}\ndo_test boundary3-2.42.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -549755813888 ORDER BY t2.a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary3-2.42.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -549755813888 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary3-2.42.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.42.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary3-2.42.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=63\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.42.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.42.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=63\n     ORDER BY t1.rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary3-2.43.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=281474976710655 AND t2.a=t1.a\n  }\n} {10 0000ffffffffffff}\ndo_test boundary3-2.43.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000ffffffffffff'\n  }\n} {281474976710655 10}\ndo_test boundary3-2.43.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=10\n  }\n} {281474976710655 0000ffffffffffff}\ndo_test boundary3-2.43.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 281474976710655 ORDER BY t2.a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary3-2.43.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 281474976710655 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary3-2.43.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary3-2.43.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary3-2.43.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=10\n     ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary3-2.43.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 281474976710655 ORDER BY t2.a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary3-2.43.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 281474976710655 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary3-2.43.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.43.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary3-2.43.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=10\n     ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.43.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 281474976710655 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.43.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 281474976710655 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.43.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary3-2.43.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.43.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=10\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.43.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 281474976710655 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.43.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 281474976710655 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.43.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary3-2.43.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=10\n     ORDER BY t1.rowid DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.43.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=10\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.44.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=4398046511103 AND t2.a=t1.a\n  }\n} {7 000003ffffffffff}\ndo_test boundary3-2.44.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000003ffffffffff'\n  }\n} {4398046511103 7}\ndo_test boundary3-2.44.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=7\n  }\n} {4398046511103 000003ffffffffff}\ndo_test boundary3-2.44.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 4398046511103 ORDER BY t2.a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.44.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 4398046511103 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary3-2.44.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary3-2.44.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=7\n     ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary3-2.44.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 4398046511103 ORDER BY t2.a\n  }\n} {3 7 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.44.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 4398046511103 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 7 3}\ndo_test boundary3-2.44.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary3-2.44.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=7\n     ORDER BY x\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.44.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7}\ndo_test boundary3-2.44.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 4398046511103 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.44.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 4398046511103 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.44.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary3-2.44.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.44.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=7\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.44.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19}\ndo_test boundary3-2.44.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.44.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 4398046511103 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.44.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 4398046511103 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.44.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary3-2.44.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.44.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=7\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.44.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary3-2.44.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=7\n     ORDER BY t1.rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.45.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=268435455 AND t2.a=t1.a\n  }\n} {12 000000000fffffff}\ndo_test boundary3-2.45.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000fffffff'\n  }\n} {268435455 12}\ndo_test boundary3-2.45.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=12\n  }\n} {268435455 000000000fffffff}\ndo_test boundary3-2.45.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 268435455 ORDER BY t2.a\n  }\n} {3 7 10 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.45.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 268435455 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 10 7 3}\ndo_test boundary3-2.45.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary3-2.45.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=12\n     ORDER BY x\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40}\ndo_test boundary3-2.45.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 268435455 ORDER BY t2.a\n  }\n} {3 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.45.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 268435455 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 3}\ndo_test boundary3-2.45.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary3-2.45.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=12\n     ORDER BY x\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.45.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12}\ndo_test boundary3-2.45.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 268435455 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.45.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 268435455 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.45.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary3-2.45.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.45.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=12\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.45.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6}\ndo_test boundary3-2.45.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.45.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 268435455 ORDER BY t2.a\n  }\n} {1 2 4 5 6 8 9 11 12 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.45.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 268435455 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 12 11 9 8 6 5 4 2 1}\ndo_test boundary3-2.45.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary3-2.45.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.45.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=12\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.45.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12}\ndo_test boundary3-2.45.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=12\n     ORDER BY t1.rowid DESC\n  }\n} {12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.46.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-9223372036854775808 AND t2.a=t1.a\n  }\n} {55 8000000000000000}\ndo_test boundary3-2.46.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='8000000000000000'\n  }\n} {-9223372036854775808 55}\ndo_test boundary3-2.46.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=55\n  }\n} {-9223372036854775808 8000000000000000}\ndo_test boundary3-2.46.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -9223372036854775808 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.46.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -9223372036854775808 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.46.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.46.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary3-2.46.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=55\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.46.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -9223372036854775808 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.46.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -9223372036854775808 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.46.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.46.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.46.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=55\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.46.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -9223372036854775808 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.46.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -9223372036854775808 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.46.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.46.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.46.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=55\n     ORDER BY x\n  }\n} {}\ndo_test boundary3-2.46.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -9223372036854775808 ORDER BY t2.a\n  }\n} {55}\ndo_test boundary3-2.46.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -9223372036854775808 ORDER BY t1.a DESC\n  }\n} {55}\ndo_test boundary3-2.46.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid\n  }\n} {55}\ndo_test boundary3-2.46.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=55\n     ORDER BY t1.rowid DESC\n  }\n} {55}\ndo_test boundary3-2.46.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=55\n     ORDER BY x\n  }\n} {55}\ndo_test boundary3-2.47.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=562949953421312 AND t2.a=t1.a\n  }\n} {43 0002000000000000}\ndo_test boundary3-2.47.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0002000000000000'\n  }\n} {562949953421312 43}\ndo_test boundary3-2.47.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=43\n  }\n} {562949953421312 0002000000000000}\ndo_test boundary3-2.47.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 562949953421312 ORDER BY t2.a\n  }\n} {3 17 27 28 45}\ndo_test boundary3-2.47.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 562949953421312 ORDER BY t1.a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary3-2.47.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid\n  }\n} {27 45 17 28 3}\ndo_test boundary3-2.47.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary3-2.47.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=43\n     ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary3-2.47.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 562949953421312 ORDER BY t2.a\n  }\n} {3 17 27 28 43 45}\ndo_test boundary3-2.47.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 562949953421312 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 17 3}\ndo_test boundary3-2.47.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid\n  }\n} {43 27 45 17 28 3}\ndo_test boundary3-2.47.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43}\ndo_test boundary3-2.47.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=43\n     ORDER BY x\n  }\n} {43 27 45 17 28 3}\ndo_test boundary3-2.47.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 562949953421312 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.47.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 562949953421312 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.47.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13}\ndo_test boundary3-2.47.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid DESC\n  }\n} {13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.47.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=43\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.47.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 562949953421312 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.47.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 562949953421312 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.47.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary3-2.47.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=43\n     ORDER BY t1.rowid DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.47.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=43\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.48.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-8388609 AND t2.a=t1.a\n  }\n} {1 ffffffffff7fffff}\ndo_test boundary3-2.48.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffffff7fffff'\n  }\n} {-8388609 1}\ndo_test boundary3-2.48.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=1\n  }\n} {-8388609 ffffffffff7fffff}\ndo_test boundary3-2.48.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -8388609 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.48.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -8388609 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.48.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.48.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary3-2.48.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=1\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.48.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.48.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37}\ndo_test boundary3-2.48.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -8388609 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.48.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -8388609 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.48.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.48.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary3-2.48.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=1\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.48.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.48.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1}\ndo_test boundary3-2.48.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -8388609 ORDER BY t2.a\n  }\n} {2 11 21 44 47 55 58 63 64}\ndo_test boundary3-2.48.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -8388609 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 11 2}\ndo_test boundary3-2.48.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.48.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.48.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=1\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.48.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11}\ndo_test boundary3-2.48.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.48.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -8388609 ORDER BY t2.a\n  }\n} {1 2 11 21 44 47 55 58 63 64}\ndo_test boundary3-2.48.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -8388609 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 11 2 1}\ndo_test boundary3-2.48.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.48.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.48.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=1\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.48.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1}\ndo_test boundary3-2.48.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=1\n     ORDER BY t1.rowid DESC\n  }\n} {1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.49.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=16777215 AND t2.a=t1.a\n  }\n} {9 0000000000ffffff}\ndo_test boundary3-2.49.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000ffffff'\n  }\n} {16777215 9}\ndo_test boundary3-2.49.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=9\n  }\n} {16777215 0000000000ffffff}\ndo_test boundary3-2.49.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 16777215 ORDER BY t2.a\n  }\n} {3 6 7 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.49.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 16777215 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 7 6 3}\ndo_test boundary3-2.49.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary3-2.49.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=9\n     ORDER BY x\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6}\ndo_test boundary3-2.49.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 16777215 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.49.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 16777215 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.49.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary3-2.49.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=9\n     ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.49.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary3-2.49.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 16777215 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.49.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 16777215 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.49.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary3-2.49.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.49.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=9\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.49.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary3-2.49.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.49.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 16777215 ORDER BY t2.a\n  }\n} {1 2 4 5 8 9 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.49.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 16777215 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 9 8 5 4 2 1}\ndo_test boundary3-2.49.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary3-2.49.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.49.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=9\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.49.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9}\ndo_test boundary3-2.49.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=9\n     ORDER BY t1.rowid DESC\n  }\n} {9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.50.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=8388608 AND t2.a=t1.a\n  }\n} {24 0000000000800000}\ndo_test boundary3-2.50.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000800000'\n  }\n} {8388608 24}\ndo_test boundary3-2.50.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=24\n  }\n} {8388608 0000000000800000}\ndo_test boundary3-2.50.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 8388608 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.50.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 8388608 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.50.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary3-2.50.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=24\n     ORDER BY x\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9}\ndo_test boundary3-2.50.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 8388608 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 19 20 22 24 25 26 27 28 34 35 36 39 40 43 45 46 51 56 57}\ndo_test boundary3-2.50.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 8388608 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 40 39 36 35 34 28 27 26 25 24 22 20 19 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.50.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary3-2.50.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=24\n     ORDER BY x\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.50.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24}\ndo_test boundary3-2.50.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 8388608 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.50.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 8388608 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.50.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary3-2.50.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.50.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=24\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.50.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18}\ndo_test boundary3-2.50.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.50.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 8388608 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 18 21 23 24 29 30 31 32 33 37 38 41 42 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.50.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 8388608 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 42 41 38 37 33 32 31 30 29 24 23 21 18 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.50.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary3-2.50.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.50.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=24\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.50.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24}\ndo_test boundary3-2.50.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=24\n     ORDER BY t1.rowid DESC\n  }\n} {24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.51.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=16383 AND t2.a=t1.a\n  }\n} {8 0000000000003fff}\ndo_test boundary3-2.51.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000003fff'\n  }\n} {16383 8}\ndo_test boundary3-2.51.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=8\n  }\n} {16383 0000000000003fff}\ndo_test boundary3-2.51.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 16383 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.51.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 16383 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.51.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary3-2.51.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=8\n     ORDER BY x\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16}\ndo_test boundary3-2.51.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 16383 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.51.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 16383 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.51.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary3-2.51.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=8\n     ORDER BY x\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.51.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8}\ndo_test boundary3-2.51.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 16383 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.51.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 16383 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 5 4 2 1}\ndo_test boundary3-2.51.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary3-2.51.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.51.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=8\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.51.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61}\ndo_test boundary3-2.51.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.51.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 16383 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.51.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 16383 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 11 8 5 4 2 1}\ndo_test boundary3-2.51.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary3-2.51.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.51.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=8\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.51.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8}\ndo_test boundary3-2.51.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=8\n     ORDER BY t1.rowid DESC\n  }\n} {8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.52.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=140737488355328 AND t2.a=t1.a\n  }\n} {34 0000800000000000}\ndo_test boundary3-2.52.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000800000000000'\n  }\n} {140737488355328 34}\ndo_test boundary3-2.52.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=34\n  }\n} {140737488355328 0000800000000000}\ndo_test boundary3-2.52.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 140737488355328 ORDER BY t2.a\n  }\n} {3 10 13 17 26 27 28 43 45}\ndo_test boundary3-2.52.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 140737488355328 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 26 17 13 10 3}\ndo_test boundary3-2.52.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.52.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10}\ndo_test boundary3-2.52.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=34\n     ORDER BY x\n  }\n} {10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.52.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 140737488355328 ORDER BY t2.a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary3-2.52.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 140737488355328 ORDER BY t1.a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary3-2.52.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.52.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary3-2.52.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=34\n     ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.52.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 140737488355328 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.52.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 140737488355328 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.52.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary3-2.52.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.52.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=34\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.52.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 140737488355328 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.52.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 140737488355328 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.52.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34}\ndo_test boundary3-2.52.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=34\n     ORDER BY t1.rowid DESC\n  }\n} {34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.52.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=34\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.53.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=2097151 AND t2.a=t1.a\n  }\n} {15 00000000001fffff}\ndo_test boundary3-2.53.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00000000001fffff'\n  }\n} {2097151 15}\ndo_test boundary3-2.53.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=15\n  }\n} {2097151 00000000001fffff}\ndo_test boundary3-2.53.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 2097151 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary3-2.53.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 2097151 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.53.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary3-2.53.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=15\n     ORDER BY x\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42}\ndo_test boundary3-2.53.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 2097151 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 51 56 57}\ndo_test boundary3-2.53.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 2097151 ORDER BY t1.a DESC\n  }\n} {57 56 51 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.53.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary3-2.53.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=15\n     ORDER BY x\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.53.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15}\ndo_test boundary3-2.53.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 2097151 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.53.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 2097151 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.53.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary3-2.53.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.53.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=15\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.53.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62}\ndo_test boundary3-2.53.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.53.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 2097151 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 15 16 21 23 29 30 31 32 33 37 38 41 44 47 48 49 50 52 53 54 55 58 59 60 61 62 63 64}\ndo_test boundary3-2.53.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 2097151 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 55 54 53 52 50 49 48 47 44 41 38 37 33 32 31 30 29 23 21 16 15 11 8 5 4 2 1}\ndo_test boundary3-2.53.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary3-2.53.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.53.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=15\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.53.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15}\ndo_test boundary3-2.53.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=15\n     ORDER BY t1.rowid DESC\n  }\n} {15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.54.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=140737488355327 AND t2.a=t1.a\n  }\n} {25 00007fffffffffff}\ndo_test boundary3-2.54.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='00007fffffffffff'\n  }\n} {140737488355327 25}\ndo_test boundary3-2.54.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=25\n  }\n} {140737488355327 00007fffffffffff}\ndo_test boundary3-2.54.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 140737488355327 ORDER BY t2.a\n  }\n} {3 10 13 17 26 27 28 34 43 45}\ndo_test boundary3-2.54.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 140737488355327 ORDER BY t1.a DESC\n  }\n} {45 43 34 28 27 26 17 13 10 3}\ndo_test boundary3-2.54.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.54.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34}\ndo_test boundary3-2.54.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=25\n     ORDER BY x\n  }\n} {34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.54.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 140737488355327 ORDER BY t2.a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary3-2.54.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 140737488355327 ORDER BY t1.a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary3-2.54.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.54.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary3-2.54.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=25\n     ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.54.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 140737488355327 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.54.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 140737488355327 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.54.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary3-2.54.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.54.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=25\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.54.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 140737488355327 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.54.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 140737488355327 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.54.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25}\ndo_test boundary3-2.54.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=25\n     ORDER BY t1.rowid DESC\n  }\n} {25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.54.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=25\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.55.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=281474976710656 AND t2.a=t1.a\n  }\n} {26 0001000000000000}\ndo_test boundary3-2.55.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0001000000000000'\n  }\n} {281474976710656 26}\ndo_test boundary3-2.55.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=26\n  }\n} {281474976710656 0001000000000000}\ndo_test boundary3-2.55.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 281474976710656 ORDER BY t2.a\n  }\n} {3 13 17 27 28 43 45}\ndo_test boundary3-2.55.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 281474976710656 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 17 13 3}\ndo_test boundary3-2.55.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary3-2.55.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13}\ndo_test boundary3-2.55.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=26\n     ORDER BY x\n  }\n} {13 43 27 45 17 28 3}\ndo_test boundary3-2.55.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 281474976710656 ORDER BY t2.a\n  }\n} {3 13 17 26 27 28 43 45}\ndo_test boundary3-2.55.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 281474976710656 ORDER BY t1.a DESC\n  }\n} {45 43 28 27 26 17 13 3}\ndo_test boundary3-2.55.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary3-2.55.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26}\ndo_test boundary3-2.55.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=26\n     ORDER BY x\n  }\n} {26 13 43 27 45 17 28 3}\ndo_test boundary3-2.55.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 281474976710656 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.55.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 281474976710656 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.55.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10}\ndo_test boundary3-2.55.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid DESC\n  }\n} {10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.55.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=26\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.55.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 281474976710656 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.55.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 281474976710656 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.55.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26}\ndo_test boundary3-2.55.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=26\n     ORDER BY t1.rowid DESC\n  }\n} {26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.55.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=26\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.56.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=32767 AND t2.a=t1.a\n  }\n} {23 0000000000007fff}\ndo_test boundary3-2.56.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000007fff'\n  }\n} {32767 23}\ndo_test boundary3-2.56.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=23\n  }\n} {32767 0000000000007fff}\ndo_test boundary3-2.56.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 32767 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.56.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 32767 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.56.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary3-2.56.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=23\n     ORDER BY x\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50}\ndo_test boundary3-2.56.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 32767 ORDER BY t2.a\n  }\n} {3 6 7 9 10 12 13 14 15 17 18 19 20 22 23 24 25 26 27 28 34 35 36 39 40 42 43 45 46 48 50 51 56 57 62}\ndo_test boundary3-2.56.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 32767 ORDER BY t1.a DESC\n  }\n} {62 57 56 51 50 48 46 45 43 42 40 39 36 35 34 28 27 26 25 24 23 22 20 19 18 17 15 14 13 12 10 9 7 6 3}\ndo_test boundary3-2.56.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary3-2.56.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=23\n     ORDER BY x\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.56.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23}\ndo_test boundary3-2.56.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 32767 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.56.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 32767 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.56.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary3-2.56.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.56.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=23\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.56.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16}\ndo_test boundary3-2.56.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.56.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 32767 ORDER BY t2.a\n  }\n} {1 2 4 5 8 11 16 21 23 29 30 31 32 33 37 38 41 44 47 49 52 53 54 55 58 59 60 61 63 64}\ndo_test boundary3-2.56.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 32767 ORDER BY t1.a DESC\n  }\n} {64 63 61 60 59 58 55 54 53 52 49 47 44 41 38 37 33 32 31 30 29 23 21 16 11 8 5 4 2 1}\ndo_test boundary3-2.56.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary3-2.56.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.56.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=23\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.56.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23}\ndo_test boundary3-2.56.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=23\n     ORDER BY t1.rowid DESC\n  }\n} {23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.57.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=127 AND t2.a=t1.a\n  }\n} {4 000000000000007f}\ndo_test boundary3-2.57.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='000000000000007f'\n  }\n} {127 4}\ndo_test boundary3-2.57.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=4\n  }\n} {127 000000000000007f}\ndo_test boundary3-2.57.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 127 ORDER BY t2.a\n  }\n} {3 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.57.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 127 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 3}\ndo_test boundary3-2.57.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary3-2.57.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=4\n     ORDER BY x\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49}\ndo_test boundary3-2.57.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 127 ORDER BY t2.a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.57.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 127 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary3-2.57.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary3-2.57.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=4\n     ORDER BY x\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.57.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4}\ndo_test boundary3-2.57.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 127 ORDER BY t2.a\n  }\n} {1 2 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.57.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 127 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 2 1}\ndo_test boundary3-2.57.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary3-2.57.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.57.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=4\n     ORDER BY x\n  }\n} {59 60 41 5 31 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.57.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31}\ndo_test boundary3-2.57.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.57.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 127 ORDER BY t2.a\n  }\n} {1 2 4 5 11 21 29 31 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.57.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 127 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 31 29 21 11 5 4 2 1}\ndo_test boundary3-2.57.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary3-2.57.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.57.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=4\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.57.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4}\ndo_test boundary3-2.57.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=4\n     ORDER BY t1.rowid DESC\n  }\n} {4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.58.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=36028797018963967 AND t2.a=t1.a\n  }\n} {27 007fffffffffffff}\ndo_test boundary3-2.58.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='007fffffffffffff'\n  }\n} {36028797018963967 27}\ndo_test boundary3-2.58.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=27\n  }\n} {36028797018963967 007fffffffffffff}\ndo_test boundary3-2.58.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 36028797018963967 ORDER BY t2.a\n  }\n} {3 17 28 45}\ndo_test boundary3-2.58.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 36028797018963967 ORDER BY t1.a DESC\n  }\n} {45 28 17 3}\ndo_test boundary3-2.58.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid\n  }\n} {45 17 28 3}\ndo_test boundary3-2.58.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45}\ndo_test boundary3-2.58.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=27\n     ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary3-2.58.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 36028797018963967 ORDER BY t2.a\n  }\n} {3 17 27 28 45}\ndo_test boundary3-2.58.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 36028797018963967 ORDER BY t1.a DESC\n  }\n} {45 28 27 17 3}\ndo_test boundary3-2.58.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid\n  }\n} {27 45 17 28 3}\ndo_test boundary3-2.58.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27}\ndo_test boundary3-2.58.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=27\n     ORDER BY x\n  }\n} {27 45 17 28 3}\ndo_test boundary3-2.58.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 36028797018963967 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.58.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 36028797018963967 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.58.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43}\ndo_test boundary3-2.58.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid DESC\n  }\n} {43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.58.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=27\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.58.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 36028797018963967 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.58.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 36028797018963967 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.58.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary3-2.58.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=27\n     ORDER BY t1.rowid DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.58.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=27\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.59.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=4398046511104 AND t2.a=t1.a\n  }\n} {56 0000040000000000}\ndo_test boundary3-2.59.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000040000000000'\n  }\n} {4398046511104 56}\ndo_test boundary3-2.59.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=56\n  }\n} {4398046511104 0000040000000000}\ndo_test boundary3-2.59.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 4398046511104 ORDER BY t2.a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45}\ndo_test boundary3-2.59.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 4398046511104 ORDER BY t1.a DESC\n  }\n} {45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary3-2.59.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary3-2.59.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=56\n     ORDER BY x\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25}\ndo_test boundary3-2.59.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 4398046511104 ORDER BY t2.a\n  }\n} {3 10 13 17 25 26 27 28 34 43 45 56}\ndo_test boundary3-2.59.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 4398046511104 ORDER BY t1.a DESC\n  }\n} {56 45 43 34 28 27 26 25 17 13 10 3}\ndo_test boundary3-2.59.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary3-2.59.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=56\n     ORDER BY x\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.59.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56}\ndo_test boundary3-2.59.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 4398046511104 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.59.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 4398046511104 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.59.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary3-2.59.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.59.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=56\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.59.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7}\ndo_test boundary3-2.59.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.59.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 4398046511104 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 11 12 14 15 16 18 19 20 21 22 23 24 29 30 31 32 33 35 36 37 38 39 40 41 42 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.59.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 4398046511104 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 42 41 40 39 38 37 36 35 33 32 31 30 29 24 23 22 21 20 19 18 16 15 14 12 11 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.59.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary3-2.59.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.59.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=56\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.59.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56}\ndo_test boundary3-2.59.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=56\n     ORDER BY t1.rowid DESC\n  }\n} {56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.60.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=1 AND t2.a=t1.a\n  }\n} {60 0000000000000001}\ndo_test boundary3-2.60.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000001'\n  }\n} {1 60}\ndo_test boundary3-2.60.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=60\n  }\n} {1 0000000000000001}\ndo_test boundary3-2.60.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 1 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.60.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 1 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.60.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary3-2.60.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=60\n     ORDER BY x\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41}\ndo_test boundary3-2.60.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 1 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 41 42 43 45 46 48 49 50 51 56 57 60 61 62}\ndo_test boundary3-2.60.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 1 ORDER BY t1.a DESC\n  }\n} {62 61 60 57 56 51 50 49 48 46 45 43 42 41 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.60.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary3-2.60.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=60\n     ORDER BY x\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.60.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60}\ndo_test boundary3-2.60.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 1 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 63 64}\ndo_test boundary3-2.60.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 1 ORDER BY t1.a DESC\n  }\n} {64 63 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.60.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary3-2.60.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.60.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=60\n     ORDER BY x\n  }\n} {59 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.60.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59}\ndo_test boundary3-2.60.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.60.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 1 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.60.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 1 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.60.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary3-2.60.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.60.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=60\n     ORDER BY x\n  }\n} {59 60 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.60.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60}\ndo_test boundary3-2.60.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=60\n     ORDER BY t1.rowid DESC\n  }\n} {60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.61.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=36028797018963968 AND t2.a=t1.a\n  }\n} {45 0080000000000000}\ndo_test boundary3-2.61.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0080000000000000'\n  }\n} {36028797018963968 45}\ndo_test boundary3-2.61.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=45\n  }\n} {36028797018963968 0080000000000000}\ndo_test boundary3-2.61.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 36028797018963968 ORDER BY t2.a\n  }\n} {3 17 28}\ndo_test boundary3-2.61.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 36028797018963968 ORDER BY t1.a DESC\n  }\n} {28 17 3}\ndo_test boundary3-2.61.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid\n  }\n} {17 28 3}\ndo_test boundary3-2.61.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17}\ndo_test boundary3-2.61.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=45\n     ORDER BY x\n  }\n} {17 28 3}\ndo_test boundary3-2.61.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 36028797018963968 ORDER BY t2.a\n  }\n} {3 17 28 45}\ndo_test boundary3-2.61.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 36028797018963968 ORDER BY t1.a DESC\n  }\n} {45 28 17 3}\ndo_test boundary3-2.61.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid\n  }\n} {45 17 28 3}\ndo_test boundary3-2.61.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45}\ndo_test boundary3-2.61.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=45\n     ORDER BY x\n  }\n} {45 17 28 3}\ndo_test boundary3-2.61.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 36028797018963968 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.61.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 36028797018963968 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.61.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27}\ndo_test boundary3-2.61.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid DESC\n  }\n} {27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.61.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=45\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.61.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 36028797018963968 ORDER BY t2.a\n  }\n} {1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.61.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 36028797018963968 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 27 26 25 24 23 22 21 20 19 18 16 15 14 13 12 11 10 9 8 7 6 5 4 2 1}\ndo_test boundary3-2.61.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45}\ndo_test boundary3-2.61.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=45\n     ORDER BY t1.rowid DESC\n  }\n} {45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.61.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=45\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.62.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-2147483649 AND t2.a=t1.a\n  }\n} {47 ffffffff7fffffff}\ndo_test boundary3-2.62.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ffffffff7fffffff'\n  }\n} {-2147483649 47}\ndo_test boundary3-2.62.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=47\n  }\n} {-2147483649 ffffffff7fffffff}\ndo_test boundary3-2.62.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -2147483649 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.62.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -2147483649 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.62.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.62.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary3-2.62.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=47\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.62.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.62.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11}\ndo_test boundary3-2.62.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -2147483649 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 45 46 47 48 49 50 51 52 53 54 56 57 59 60 61 62}\ndo_test boundary3-2.62.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -2147483649 ORDER BY t1.a DESC\n  }\n} {62 61 60 59 57 56 54 53 52 51 50 49 48 47 46 45 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.62.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.62.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary3-2.62.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=47\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.62.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.62.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47}\ndo_test boundary3-2.62.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -2147483649 ORDER BY t2.a\n  }\n} {2 21 44 55 58 63 64}\ndo_test boundary3-2.62.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -2147483649 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 44 21 2}\ndo_test boundary3-2.62.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.62.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary3-2.62.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=47\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.62.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63}\ndo_test boundary3-2.62.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {63 58 44 21 64 2 55}\ndo_test boundary3-2.62.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -2147483649 ORDER BY t2.a\n  }\n} {2 21 44 47 55 58 63 64}\ndo_test boundary3-2.62.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -2147483649 ORDER BY t1.a DESC\n  }\n} {64 63 58 55 47 44 21 2}\ndo_test boundary3-2.62.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.62.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary3-2.62.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=47\n     ORDER BY x\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.62.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47}\ndo_test boundary3-2.62.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=47\n     ORDER BY t1.rowid DESC\n  }\n} {47 63 58 44 21 64 2 55}\ndo_test boundary3-2.63.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=-36028797018963969 AND t2.a=t1.a\n  }\n} {2 ff7fffffffffffff}\ndo_test boundary3-2.63.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='ff7fffffffffffff'\n  }\n} {-36028797018963969 2}\ndo_test boundary3-2.63.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=2\n  }\n} {-36028797018963969 ff7fffffffffffff}\ndo_test boundary3-2.63.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -36028797018963969 ORDER BY t2.a\n  }\n} {1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.63.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -36028797018963969 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1}\ndo_test boundary3-2.63.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid\n  }\n} {64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.63.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64}\ndo_test boundary3-2.63.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=2\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.63.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -36028797018963969 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.63.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -36028797018963969 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.63.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid\n  }\n} {2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.63.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2}\ndo_test boundary3-2.63.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=2\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.63.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -36028797018963969 ORDER BY t2.a\n  }\n} {55}\ndo_test boundary3-2.63.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -36028797018963969 ORDER BY t1.a DESC\n  }\n} {55}\ndo_test boundary3-2.63.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid\n  }\n} {55}\ndo_test boundary3-2.63.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid DESC\n  }\n} {55}\ndo_test boundary3-2.63.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=2\n     ORDER BY x\n  }\n} {55}\ndo_test boundary3-2.63.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -36028797018963969 ORDER BY t2.a\n  }\n} {2 55}\ndo_test boundary3-2.63.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -36028797018963969 ORDER BY t1.a DESC\n  }\n} {55 2}\ndo_test boundary3-2.63.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid\n  }\n} {55 2}\ndo_test boundary3-2.63.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=2\n     ORDER BY t1.rowid DESC\n  }\n} {2 55}\ndo_test boundary3-2.63.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=2\n     ORDER BY x\n  }\n} {55 2}\ndo_test boundary3-2.64.1 {\n  db eval {\n    SELECT t1.* FROM t1, t2 WHERE t1.rowid=3 AND t2.a=t1.a\n  }\n} {5 0000000000000003}\ndo_test boundary3-2.64.2 {\n  db eval {\n    SELECT t2.* FROM t1 JOIN t2 USING(a) WHERE x='0000000000000003'\n  }\n} {3 5}\ndo_test boundary3-2.64.3 {\n  db eval {\n    SELECT t1.rowid, x FROM t1 JOIN t2 ON t2.r=t1.rowid WHERE t2.a=5\n  }\n} {3 0000000000000003}\ndo_test boundary3-2.64.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 3 ORDER BY t2.a\n  }\n} {3 4 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.64.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 3 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 4 3}\ndo_test boundary3-2.64.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary3-2.64.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=5\n     ORDER BY x\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.gt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.gt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31}\ndo_test boundary3-2.64.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 3 ORDER BY t2.a\n  }\n} {3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 30 31 34 35 36 39 40 42 43 45 46 48 49 50 51 56 57 61 62}\ndo_test boundary3-2.64.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 3 ORDER BY t1.a DESC\n  }\n} {62 61 57 56 51 50 49 48 46 45 43 42 40 39 36 35 34 31 30 28 27 26 25 24 23 22 20 19 18 17 16 15 14 13 12 10 9 8 7 6 5 4 3}\ndo_test boundary3-2.64.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary3-2.64.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=5\n     ORDER BY x\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.ge.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.64.ge.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5}\ndo_test boundary3-2.64.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 3 ORDER BY t2.a\n  }\n} {1 2 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.64.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 3 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 2 1}\ndo_test boundary3-2.64.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary3-2.64.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.64.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=5\n     ORDER BY x\n  }\n} {59 60 41 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.64.lt.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41}\ndo_test boundary3-2.64.lt.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.64.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 3 ORDER BY t2.a\n  }\n} {1 2 5 11 21 29 32 33 37 38 41 44 47 52 53 54 55 58 59 60 63 64}\ndo_test boundary3-2.64.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 3 ORDER BY t1.a DESC\n  }\n} {64 63 60 59 58 55 54 53 52 47 44 41 38 37 33 32 29 21 11 5 2 1}\ndo_test boundary3-2.64.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary3-2.64.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.64.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=5\n     ORDER BY x\n  }\n} {59 60 41 5 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.64.le.10 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5}\ndo_test boundary3-2.64.le.11 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= CAST(t2.r AS real)\n     WHERE t2.a=5\n     ORDER BY t1.rowid DESC\n  }\n} {5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.65.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > 9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.65.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > 9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.65.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.65.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.65.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=65\n     ORDER BY x\n  }\n} {}\ndo_test boundary3-2.65.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= 9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.65.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= 9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.65.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.65.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.65.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=65\n     ORDER BY x\n  }\n} {}\ndo_test boundary3-2.65.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < 9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.65.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < 9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.65.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.65.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.65.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=65\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.65.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= 9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.65.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= 9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.65.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.65.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=65\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.65.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=65\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.66.gt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid > -9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.66.gt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid > -9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.66.gt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.66.gt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.66.gt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid > t2.r\n     WHERE t2.a=66\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.66.ge.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid >= -9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64}\ndo_test boundary3-2.66.ge.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid >= -9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test boundary3-2.66.ge.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid\n  }\n} {55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38 59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3}\ndo_test boundary3-2.66.ge.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid DESC\n  }\n} {3 28 17 45 27 43 13 26 10 34 25 56 7 19 57 35 46 22 39 36 14 51 20 40 12 6 9 24 18 42 15 62 48 50 23 16 8 61 30 49 4 31 5 41 60 59 38 33 52 53 54 32 29 37 1 11 47 63 58 44 21 64 2 55}\ndo_test boundary3-2.66.ge.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid >= t2.r\n     WHERE t2.a=66\n     ORDER BY x\n  }\n} {59 60 41 5 31 4 49 30 61 8 16 23 50 48 62 15 42 18 24 9 6 12 40 20 51 14 36 39 22 46 35 57 19 7 56 25 34 10 26 13 43 27 45 17 28 3 55 2 64 21 44 58 63 47 11 1 37 29 32 54 53 52 33 38}\ndo_test boundary3-2.66.lt.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid < -9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.66.lt.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid < -9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.66.lt.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.66.lt.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.66.lt.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid < t2.r\n     WHERE t2.a=66\n     ORDER BY x\n  }\n} {}\ndo_test boundary3-2.66.le.1 {\n  db eval {\n    SELECT t2.a FROM t1 JOIN t2 USING(a)\n     WHERE t1.rowid <= -9.22337303685477580800e+18 ORDER BY t2.a\n  }\n} {}\ndo_test boundary3-2.66.le.2 {\n  db eval {\n    SELECT t2.a FROM t2 NATURAL JOIN t1\n     WHERE t1.rowid <= -9.22337303685477580800e+18 ORDER BY t1.a DESC\n  }\n} {}\ndo_test boundary3-2.66.le.3 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid\n  }\n} {}\ndo_test boundary3-2.66.le.4 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=66\n     ORDER BY t1.rowid DESC\n  }\n} {}\ndo_test boundary3-2.66.le.5 {\n  db eval {\n    SELECT t1.a FROM t1 JOIN t2 ON t1.rowid <= t2.r\n     WHERE t2.a=66\n     ORDER BY x\n  }\n} {}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary4.tcl",
    "content": "puts {# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary4.tcl,v 1.3 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\nifcapable !altertable     { finish_test; return }\n}\n\nexpr srand(0)\n\n# Generate interesting boundary numbers\n#\nforeach x {\n  0x7f\n  0x7fff\n  0x7fffff\n  0x7fffffff\n  0x7fffffffff\n  0x7fffffffffff\n  0x7fffffffffffff\n  0x7fffffffffffffff\n} {\n  set x [expr {wide($x)}]\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set boundarynum([expr {-($x+1)}]) 1\n  set boundarynum([expr {-($x+2)}]) 1\n  set boundarynum([expr {$x+$x+1}]) 1\n  set boundarynum([expr {$x+$x+2}]) 1\n}\nset x [expr {wide(127)}]\nfor {set i 127} {$i<=9} {incr i} {\n  set boundarynum($x) 1\n  set boundarynum([expr {$x+1}]) 1\n  set x [expr {wide($x*128 + 127)}]\n}\n\n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# A simple selection sort.  Not trying to be efficient.\n#\nproc sort {inlist} {\n  set outlist {}\n  set mn [lindex $inlist 0]\n  foreach x $inlist {\n    if {$x<$mn} {set mn $x}\n  }\n  set outlist $mn\n  set mx $mn\n  while {1} {\n    set valid 0\n    foreach x $inlist {\n      if {$x>$mx && (!$valid || $mn>$x)} {\n        set mn $x\n        set valid 1\n      }\n    }\n    if {!$valid} break\n    lappend outlist $mn\n    set mx $mn\n  }\n  return $outlist\n}\n\n# Reverse the order of a list\n#\nproc reverse {inlist} {\n  set i [llength $inlist]\n  set outlist {}\n  for {incr i -1} {$i>=0} {incr i -1} {\n    lappend outlist [lindex $inlist $i]\n  }\n  return $outlist\n}\n\nset nums1 [scramble [array names boundarynum]]\nset nums2 [scramble [array names boundarynum]]\n\nset tname boundary4\nputs \"do_test $tname-1.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t1(a,x);\"\nset a 0\nset all_rowid {}\nset all_a {}\nset all_x {}\nforeach r $nums1 {\n  incr a\n  set t1ra($r) $a\n  set t1ar($a) $r\n  set x [format %08x%08x [expr {wide($r)>>32}] $r]\n  set t1rx($r) $x\n  set t1xr($x) $r\n  puts \"    INSERT INTO t1(oid,a,x) VALUES($r,$a,'$x');\"\n  lappend all_rowid $r\n  lappend all_a $a\n  lappend all_x $x\n}\nputs \"    CREATE INDEX t1i1 ON t1(a);\"\nputs \"    CREATE INDEX t1i2 ON t1(x);\"\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nputs \"do_test $tname-1.2 \\173\"\nputs \"  db eval \\173\"\nputs \"    SELECT count(*) FROM t1\"\nputs \"  \\175\"\nputs \"\\175 {[llength $nums1]}\"\n\nproc maketest {tnum sql answer} {\n  puts \"do_test $::tname-$tnum \\173\"\n  puts \"  db eval \\173\"\n  puts \"    $sql\"\n  puts \"  \\175\"\n  puts \"\\175 {$answer}\"\n}\n\nset ans {}\nforeach r [sort $all_rowid] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 1.3 {SELECT rowid, a, x FROM t1 ORDER BY +rowid} $ans\nmaketest 1.4 {SELECT rowid, a, x FROM t1 ORDER BY rowid} $ans\n\nset ans {}\nforeach r [reverse [sort $all_rowid]] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 1.5 {SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC} $ans\nmaketest 1.6 {SELECT rowid, a, x FROM t1 ORDER BY rowid DESC} $ans\n\nset ans {}\nforeach a [sort $all_a] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 1.7 {SELECT rowid, a, x FROM t1 ORDER BY +a} $ans\nmaketest 1.8 {SELECT rowid, a, x FROM t1 ORDER BY a} $ans\n\nset ans {}\nforeach a [reverse [sort $all_a]] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 1.9 {SELECT rowid, a, x FROM t1 ORDER BY +a DESC} $ans\nmaketest 1.10 {SELECT rowid, a, x FROM t1 ORDER BY a DESC} $ans\n\nset ans {}\nforeach x [sort $all_x] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 1.11 {SELECT rowid, a, x FROM t1 ORDER BY +x} $ans\nmaketest 1.12 {SELECT rowid, a, x FROM t1 ORDER BY x} $ans\n\nset ans {}\nforeach x [reverse [sort $all_x]] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 1.13 {SELECT rowid, a, x FROM t1 ORDER BY +x DESC} $ans\nmaketest 1.14 {SELECT rowid, a, x FROM t1 ORDER BY x DESC} $ans\n\nmaketest 2.1 {UPDATE t1 SET rowid=a, a=rowid} {}\n\nset ans {}\nforeach r [sort $all_rowid] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 2.3 {SELECT a, rowid, x FROM t1 ORDER BY +a} $ans\nmaketest 2.4 {SELECT a, rowid, x FROM t1 ORDER BY a} $ans\n\nset ans {}\nforeach r [reverse [sort $all_rowid]] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 2.5 {SELECT a, rowid, x FROM t1 ORDER BY +a DESC} $ans\nmaketest 2.6 {SELECT a, rowid, x FROM t1 ORDER BY a DESC} $ans\n\nset ans {}\nforeach a [sort $all_a] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 2.7 {SELECT a, rowid, x FROM t1 ORDER BY +rowid} $ans\nmaketest 2.8 {SELECT a, rowid, x FROM t1 ORDER BY rowid} $ans\n\nset ans {}\nforeach a [reverse [sort $all_a]] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 2.9 {SELECT a, rowid, x FROM t1 ORDER BY +rowid DESC} $ans\nmaketest 2.10 {SELECT a, rowid, x FROM t1 ORDER BY rowid DESC} $ans\n\nset ans {}\nforeach x [sort $all_x] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 2.11 {SELECT a, rowid, x FROM t1 ORDER BY +x} $ans\nmaketest 2.12 {SELECT a, rowid, x FROM t1 ORDER BY x} $ans\n\nset ans {}\nforeach x [reverse [sort $all_x]] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 2.13 {SELECT a, rowid, x FROM t1 ORDER BY +x DESC} $ans\nmaketest 2.14 {SELECT a, rowid, x FROM t1 ORDER BY x DESC} $ans\n\nmaketest 3.1 {UPDATE t1 SET rowid=a, a=rowid} {}\nmaketest 3.2 {ALTER TABLE t1 ADD COLUMN z; UPDATE t1 SET z=zeroblob(600)} {}\n\nset ans {}\nforeach r [sort $all_rowid] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 3.3 {SELECT rowid, a, x FROM t1 ORDER BY +rowid} $ans\nmaketest 3.4 {SELECT rowid, a, x FROM t1 ORDER BY rowid} $ans\n\nset ans {}\nforeach r [reverse [sort $all_rowid]] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 3.5 {SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC} $ans\nmaketest 3.6 {SELECT rowid, a, x FROM t1 ORDER BY rowid DESC} $ans\n\nset ans {}\nforeach a [sort $all_a] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 3.7 {SELECT rowid, a, x FROM t1 ORDER BY +a} $ans\nmaketest 3.8 {SELECT rowid, a, x FROM t1 ORDER BY a} $ans\n\nset ans {}\nforeach a [reverse [sort $all_a]] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 3.9 {SELECT rowid, a, x FROM t1 ORDER BY +a DESC} $ans\nmaketest 3.10 {SELECT rowid, a, x FROM t1 ORDER BY a DESC} $ans\n\nset ans {}\nforeach x [sort $all_x] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 3.11 {SELECT rowid, a, x FROM t1 ORDER BY +x} $ans\nmaketest 3.12 {SELECT rowid, a, x FROM t1 ORDER BY x} $ans\n\nset ans {}\nforeach x [reverse [sort $all_x]] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 3.13 {SELECT rowid, a, x FROM t1 ORDER BY +x DESC} $ans\nmaketest 3.14 {SELECT rowid, a, x FROM t1 ORDER BY x DESC} $ans\n\n\nmaketest 4.1 {UPDATE t1 SET rowid=a, a=rowid, x=z, z=x} {}\n\nset ans {}\nforeach r [sort $all_rowid] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 4.3 {SELECT a, rowid, z FROM t1 ORDER BY +a} $ans\nmaketest 4.4 {SELECT a, rowid, z FROM t1 ORDER BY a} $ans\n\nset ans {}\nforeach r [reverse [sort $all_rowid]] {\n  lappend ans $r $t1ra($r) $t1rx($r)\n}\nmaketest 4.5 {SELECT a, rowid, z FROM t1 ORDER BY +a DESC} $ans\nmaketest 4.6 {SELECT a, rowid, z FROM t1 ORDER BY a DESC} $ans\n\nset ans {}\nforeach a [sort $all_a] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 4.7 {SELECT a, rowid, z FROM t1 ORDER BY +rowid} $ans\nmaketest 4.8 {SELECT a, rowid, z FROM t1 ORDER BY rowid} $ans\n\nset ans {}\nforeach a [reverse [sort $all_a]] {\n  set r $t1ar($a)\n  lappend ans $r $a $t1rx($r)\n}\nmaketest 4.9 {SELECT a, rowid, z FROM t1 ORDER BY +rowid DESC} $ans\nmaketest 4.10 {SELECT a, rowid, z FROM t1 ORDER BY rowid DESC} $ans\n\nset ans {}\nforeach x [sort $all_x] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 4.11 {SELECT a, rowid, z FROM t1 ORDER BY +z} $ans\nmaketest 4.12 {SELECT a, rowid, z FROM t1 ORDER BY z} $ans\n\nset ans {}\nforeach x [reverse [sort $all_x]] {\n  set r $t1xr($x)\n  lappend ans $r $t1ra($r) $x\n}\nmaketest 4.13 {SELECT a, rowid, z FROM t1 ORDER BY +z DESC} $ans\nmaketest 4.14 {SELECT a, rowid, z FROM t1 ORDER BY z DESC} $ans\n\nputs {finish_test}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/boundary4.test",
    "content": "# 2008 December 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is automatically generated from a separate TCL script.\n# This file seeks to exercise integer boundary values.\n#\n# $Id: boundary4.test,v 1.2 2009/01/02 15:45:48 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Many of the boundary tests depend on a working 64-bit implementation.\nif {![working_64bit_int]} { finish_test; return }\nifcapable !altertable     { finish_test; return }\n\ndo_test boundary4-1.1 {\n  db eval {\n    CREATE TABLE t1(a,x);\n    INSERT INTO t1(oid,a,x) VALUES(549755813887,1,'0000007fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-8388608,2,'ffffffffff800000');\n    INSERT INTO t1(oid,a,x) VALUES(0,3,'0000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-129,4,'ffffffffffffff7f');\n    INSERT INTO t1(oid,a,x) VALUES(8388608,5,'0000000000800000');\n    INSERT INTO t1(oid,a,x) VALUES(65535,6,'000000000000ffff');\n    INSERT INTO t1(oid,a,x) VALUES(8388607,7,'00000000007fffff');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627776,8,'0000010000000000');\n    INSERT INTO t1(oid,a,x) VALUES(16777215,9,'0000000000ffffff');\n    INSERT INTO t1(oid,a,x) VALUES(32767,10,'0000000000007fff');\n    INSERT INTO t1(oid,a,x) VALUES(4294967296,11,'0000000100000000');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813888,12,'ffffff8000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355328,13,'ffff800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(256,14,'0000000000000100');\n    INSERT INTO t1(oid,a,x) VALUES(16777216,15,'0000000001000000');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927936,16,'0100000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-1,17,'ffffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(9223372036854775807,18,'7fffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710655,19,'0000ffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(1099511627775,20,'000000ffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-8388609,21,'ffffffffff7fffff');\n    INSERT INTO t1(oid,a,x) VALUES(32768,22,'0000000000008000');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963968,23,'0080000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-32769,24,'ffffffffffff7fff');\n    INSERT INTO t1(oid,a,x) VALUES(127,25,'000000000000007f');\n    INSERT INTO t1(oid,a,x) VALUES(-9223372036854775808,26,'8000000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(72057594037927935,27,'00ffffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-549755813889,28,'ffffff7fffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(255,29,'00000000000000ff');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963969,30,'ff7fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483648,31,'ffffffff80000000');\n    INSERT INTO t1(oid,a,x) VALUES(281474976710656,32,'0001000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(65536,33,'0000000000010000');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355328,34,'0000800000000000');\n    INSERT INTO t1(oid,a,x) VALUES(549755813888,35,'0000008000000000');\n    INSERT INTO t1(oid,a,x) VALUES(2147483648,36,'0000000080000000');\n    INSERT INTO t1(oid,a,x) VALUES(4294967295,37,'00000000ffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(140737488355327,38,'00007fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-2147483649,39,'ffffffff7fffffff');\n    INSERT INTO t1(oid,a,x) VALUES(36028797018963967,40,'007fffffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(128,41,'0000000000000080');\n    INSERT INTO t1(oid,a,x) VALUES(-32768,42,'ffffffffffff8000');\n    INSERT INTO t1(oid,a,x) VALUES(-36028797018963968,43,'ff80000000000000');\n    INSERT INTO t1(oid,a,x) VALUES(-140737488355329,44,'ffff7fffffffffff');\n    INSERT INTO t1(oid,a,x) VALUES(-128,45,'ffffffffffffff80');\n    INSERT INTO t1(oid,a,x) VALUES(2147483647,46,'000000007fffffff');\n    CREATE INDEX t1i1 ON t1(a);\n    CREATE INDEX t1i2 ON t1(x);\n  }\n} {}\ndo_test boundary4-1.2 {\n  db eval {\n    SELECT count(*) FROM t1\n  }\n} {46}\ndo_test boundary4-1.3 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +rowid\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-1.4 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY rowid\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-1.5 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-1.6 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY rowid DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-1.7 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +a\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-1.8 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY a\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-1.9 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +a DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-1.10 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY a DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-1.11 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-1.12 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-1.13 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-1.14 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-2.1 {\n  db eval {\n    UPDATE t1 SET rowid=a, a=rowid\n  }\n} {}\ndo_test boundary4-2.3 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +a\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-2.4 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY a\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-2.5 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +a DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-2.6 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY a DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-2.7 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +rowid\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-2.8 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY rowid\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-2.9 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +rowid DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-2.10 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY rowid DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-2.11 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-2.12 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-2.13 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY +x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-2.14 {\n  db eval {\n    SELECT a, rowid, x FROM t1 ORDER BY x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-3.1 {\n  db eval {\n    UPDATE t1 SET rowid=a, a=rowid\n  }\n} {}\ndo_test boundary4-3.2 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN z; UPDATE t1 SET z=zeroblob(600)\n  }\n} {}\ndo_test boundary4-3.3 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +rowid\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-3.4 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY rowid\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-3.5 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +rowid DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-3.6 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY rowid DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-3.7 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +a\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-3.8 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY a\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-3.9 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +a DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-3.10 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY a DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-3.11 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-3.12 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY x\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-3.13 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY +x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-3.14 {\n  db eval {\n    SELECT rowid, a, x FROM t1 ORDER BY x DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-4.1 {\n  db eval {\n    UPDATE t1 SET rowid=a, a=rowid, x=z, z=x\n  }\n} {}\ndo_test boundary4-4.3 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +a\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-4.4 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY a\n  }\n} {-9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff 0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff}\ndo_test boundary4-4.5 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +a DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-4.6 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY a DESC\n  }\n} {9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000 -1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000}\ndo_test boundary4-4.7 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +rowid\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-4.8 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY rowid\n  }\n} {549755813887 1 0000007fffffffff -8388608 2 ffffffffff800000 0 3 0000000000000000 -129 4 ffffffffffffff7f 8388608 5 0000000000800000 65535 6 000000000000ffff 8388607 7 00000000007fffff 1099511627776 8 0000010000000000 16777215 9 0000000000ffffff 32767 10 0000000000007fff 4294967296 11 0000000100000000 -549755813888 12 ffffff8000000000 -140737488355328 13 ffff800000000000 256 14 0000000000000100 16777216 15 0000000001000000 72057594037927936 16 0100000000000000 -1 17 ffffffffffffffff 9223372036854775807 18 7fffffffffffffff 281474976710655 19 0000ffffffffffff 1099511627775 20 000000ffffffffff -8388609 21 ffffffffff7fffff 32768 22 0000000000008000 36028797018963968 23 0080000000000000 -32769 24 ffffffffffff7fff 127 25 000000000000007f -9223372036854775808 26 8000000000000000 72057594037927935 27 00ffffffffffffff -549755813889 28 ffffff7fffffffff 255 29 00000000000000ff -36028797018963969 30 ff7fffffffffffff -2147483648 31 ffffffff80000000 281474976710656 32 0001000000000000 65536 33 0000000000010000 140737488355328 34 0000800000000000 549755813888 35 0000008000000000 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 140737488355327 38 00007fffffffffff -2147483649 39 ffffffff7fffffff 36028797018963967 40 007fffffffffffff 128 41 0000000000000080 -32768 42 ffffffffffff8000 -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -128 45 ffffffffffffff80 2147483647 46 000000007fffffff}\ndo_test boundary4-4.9 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +rowid DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-4.10 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY rowid DESC\n  }\n} {2147483647 46 000000007fffffff -128 45 ffffffffffffff80 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -32768 42 ffffffffffff8000 128 41 0000000000000080 36028797018963967 40 007fffffffffffff -2147483649 39 ffffffff7fffffff 140737488355327 38 00007fffffffffff 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 549755813888 35 0000008000000000 140737488355328 34 0000800000000000 65536 33 0000000000010000 281474976710656 32 0001000000000000 -2147483648 31 ffffffff80000000 -36028797018963969 30 ff7fffffffffffff 255 29 00000000000000ff -549755813889 28 ffffff7fffffffff 72057594037927935 27 00ffffffffffffff -9223372036854775808 26 8000000000000000 127 25 000000000000007f -32769 24 ffffffffffff7fff 36028797018963968 23 0080000000000000 32768 22 0000000000008000 -8388609 21 ffffffffff7fffff 1099511627775 20 000000ffffffffff 281474976710655 19 0000ffffffffffff 9223372036854775807 18 7fffffffffffffff -1 17 ffffffffffffffff 72057594037927936 16 0100000000000000 16777216 15 0000000001000000 256 14 0000000000000100 -140737488355328 13 ffff800000000000 -549755813888 12 ffffff8000000000 4294967296 11 0000000100000000 32767 10 0000000000007fff 16777215 9 0000000000ffffff 1099511627776 8 0000010000000000 8388607 7 00000000007fffff 65535 6 000000000000ffff 8388608 5 0000000000800000 -129 4 ffffffffffffff7f 0 3 0000000000000000 -8388608 2 ffffffffff800000 549755813887 1 0000007fffffffff}\ndo_test boundary4-4.11 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +z\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-4.12 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY z\n  }\n} {0 3 0000000000000000 127 25 000000000000007f 128 41 0000000000000080 255 29 00000000000000ff 256 14 0000000000000100 32767 10 0000000000007fff 32768 22 0000000000008000 65535 6 000000000000ffff 65536 33 0000000000010000 8388607 7 00000000007fffff 8388608 5 0000000000800000 16777215 9 0000000000ffffff 16777216 15 0000000001000000 2147483647 46 000000007fffffff 2147483648 36 0000000080000000 4294967295 37 00000000ffffffff 4294967296 11 0000000100000000 549755813887 1 0000007fffffffff 549755813888 35 0000008000000000 1099511627775 20 000000ffffffffff 1099511627776 8 0000010000000000 140737488355327 38 00007fffffffffff 140737488355328 34 0000800000000000 281474976710655 19 0000ffffffffffff 281474976710656 32 0001000000000000 36028797018963967 40 007fffffffffffff 36028797018963968 23 0080000000000000 72057594037927935 27 00ffffffffffffff 72057594037927936 16 0100000000000000 9223372036854775807 18 7fffffffffffffff -9223372036854775808 26 8000000000000000 -36028797018963969 30 ff7fffffffffffff -36028797018963968 43 ff80000000000000 -140737488355329 44 ffff7fffffffffff -140737488355328 13 ffff800000000000 -549755813889 28 ffffff7fffffffff -549755813888 12 ffffff8000000000 -2147483649 39 ffffffff7fffffff -2147483648 31 ffffffff80000000 -8388609 21 ffffffffff7fffff -8388608 2 ffffffffff800000 -32769 24 ffffffffffff7fff -32768 42 ffffffffffff8000 -129 4 ffffffffffffff7f -128 45 ffffffffffffff80 -1 17 ffffffffffffffff}\ndo_test boundary4-4.13 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY +z DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\ndo_test boundary4-4.14 {\n  db eval {\n    SELECT a, rowid, z FROM t1 ORDER BY z DESC\n  }\n} {-1 17 ffffffffffffffff -128 45 ffffffffffffff80 -129 4 ffffffffffffff7f -32768 42 ffffffffffff8000 -32769 24 ffffffffffff7fff -8388608 2 ffffffffff800000 -8388609 21 ffffffffff7fffff -2147483648 31 ffffffff80000000 -2147483649 39 ffffffff7fffffff -549755813888 12 ffffff8000000000 -549755813889 28 ffffff7fffffffff -140737488355328 13 ffff800000000000 -140737488355329 44 ffff7fffffffffff -36028797018963968 43 ff80000000000000 -36028797018963969 30 ff7fffffffffffff -9223372036854775808 26 8000000000000000 9223372036854775807 18 7fffffffffffffff 72057594037927936 16 0100000000000000 72057594037927935 27 00ffffffffffffff 36028797018963968 23 0080000000000000 36028797018963967 40 007fffffffffffff 281474976710656 32 0001000000000000 281474976710655 19 0000ffffffffffff 140737488355328 34 0000800000000000 140737488355327 38 00007fffffffffff 1099511627776 8 0000010000000000 1099511627775 20 000000ffffffffff 549755813888 35 0000008000000000 549755813887 1 0000007fffffffff 4294967296 11 0000000100000000 4294967295 37 00000000ffffffff 2147483648 36 0000000080000000 2147483647 46 000000007fffffff 16777216 15 0000000001000000 16777215 9 0000000000ffffff 8388608 5 0000000000800000 8388607 7 00000000007fffff 65536 33 0000000000010000 65535 6 000000000000ffff 32768 22 0000000000008000 32767 10 0000000000007fff 256 14 0000000000000100 255 29 00000000000000ff 128 41 0000000000000080 127 25 000000000000007f 0 3 0000000000000000}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/btree01.test",
    "content": "# 2014-11-27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains test cases for b-tree logic.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix btree01\n\n# The refactoring on the b-tree balance() routine in check-in\n# http://www.sqlite.org/src/info/face33bea1ba3a (2014-10-27)\n# caused the integrity_check on the following SQL to fail.\n#\ndo_execsql_test btree01-1.1 {\n  PRAGMA page_size=65536;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);\n  WITH RECURSIVE\n     c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n  INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n  UPDATE t1 SET b=zeroblob(3000);\n  UPDATE t1 SET b=zeroblob(64000) WHERE a=2;\n  PRAGMA integrity_check;\n} {ok}\n\n# The previous test is sufficient to prevent a regression.  But we\n# add a number of additional tests to stress the balancer in similar\n# ways, looking for related problems.\n#\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.2.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n      UPDATE t1 SET b=zeroblob(3000);\n      UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.3.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n      UPDATE t1 SET b=zeroblob(2000);\n      UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.4.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n      UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==0;\n      UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==1;\n      UPDATE t1 SET b=zeroblob(6499) WHERE (a%3)==2;\n      UPDATE t1 SET b=zeroblob(64000) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.5.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6542) FROM c;\n      UPDATE t1 SET b=zeroblob(2331);\n      UPDATE t1 SET b=zeroblob(65496) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.6.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6542) FROM c;\n      UPDATE t1 SET b=zeroblob(2332);\n      UPDATE t1 SET b=zeroblob(65496) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=30} {incr i} {\n  do_test btree01-1.7.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n      UPDATE t1 SET b=zeroblob(1);\n      UPDATE t1 SET b=zeroblob(65000) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\nfor {set i 1} {$i<=31} {incr i} {\n  do_test btree01-1.8.$i {\n    db eval {\n      DELETE FROM t1;\n      WITH RECURSIVE\n        c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<31)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(6500) FROM c;\n      UPDATE t1 SET b=zeroblob(4000);\n      UPDATE t1 SET b=zeroblob(65000) WHERE a=$::i;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/btree02.test",
    "content": "# 2015-03-25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# The focus of this script is making multiple calls to saveCursorPosition()\n# and restoreCursorPosition() when cursors have eState==CURSOR_SKIPNEXT\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nload_static_extension db eval\ndo_execsql_test btree02-100 {\n  CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID;\n  WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)\n    INSERT INTO t1(a,ax,b) SELECT printf('%02x',i), random(), i FROM c;\n  CREATE INDEX t1a ON t1(a);\n  CREATE TABLE t2(x,y);\n  CREATE TABLE t3(cnt);\n  WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4)\n    INSERT INTO t3(cnt) SELECT i FROM c;\n  SELECT count(*) FROM t1;\n} {10}\ndo_test btree02-110 {\n  db eval BEGIN\n  set i 0\n  db eval {SELECT a, ax, b, cnt FROM t1 CROSS JOIN t3 WHERE b IS NOT NULL} {\n    db eval {INSERT INTO t2(x,y) VALUES($b,$cnt)}\n    # puts \"a,b,cnt = ($a,$b,$cnt)\"\n    incr i\n    if {$i%2==1} {\n      set bx [expr {$b+1000}]\n      # puts \"INSERT ($a),$bx\"\n      db eval {INSERT INTO t1(a,ax,b) VALUES(printf('(%s)',$a),random(),$bx)}\n    } else {\n      # puts \"DELETE a=$a\"\n      db eval {DELETE FROM t1 WHERE a=$a}\n    }\n    db eval {COMMIT; BEGIN}\n  }  \n  db one {COMMIT; SELECT count(*) FROM t1;}\n} {20}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/btreefault.test",
    "content": "# 2013 April 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains fault injection tests designed to test the btree.c \n# module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix btreefault\n\n# This test will not work with an in-memory journal, as the database will\n# become corrupt if an error is injected into a transaction after it starts\n# writing data out to the db file.\nif {[permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\ndo_test 1-pre1 {\n  execsql {\n    PRAGMA auto_vacuum = incremental;\n    PRAGMA journal_mode = DELETE;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));\n    INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n    DELETE FROM t1 WHERE rowid%2;\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 1 -prep {\n  faultsim_restore_and_reopen\n  set ::STMT [sqlite3_prepare db \"SELECT * FROM t1 ORDER BY a\" -1 DUMMY]\n  sqlite3_step $::STMT\n  sqlite3_step $::STMT\n} -body {\n  execsql { PRAGMA incremental_vacuum = 10 }\n} -test {\n  sqlite3_finalize $::STMT\n  faultsim_test_result {0 {}} \n  faultsim_integrity_check\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/busy.test",
    "content": "# 2005 july 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file test the busy handler\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix busy\n\ndo_test busy-1.1 {\n  sqlite3 db2 test.db\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1\n  }\n} 1\nproc busy x {\n  lappend ::busyargs $x\n  if {$x>2} {return 1}\n  return 0\n}\nset busyargs {}\ndo_test busy-1.2 {\n  db busy busy\n  db2 eval {BEGIN EXCLUSIVE}\n  catchsql {BEGIN IMMEDIATE}\n} {1 {database is locked}}\ndo_test busy-1.3 {\n  set busyargs\n} {0 1 2 3}\ndo_test busy-1.4 {\n  set busyargs {}\n  catchsql {BEGIN IMMEDIATE}\n  set busyargs\n} {0 1 2 3}\n\ndo_test busy-2.1 {\n  db2 eval {COMMIT}\n  db eval {BEGIN; INSERT INTO t1 VALUES(5)}\n  db2 eval {BEGIN; SELECT * FROM t1}\n  set busyargs {}\n  catchsql COMMIT\n} {1 {database is locked}}\ndo_test busy-2.2 {\n  set busyargs\n} {0 1 2 3}\n\ndb2 close\n\n#-------------------------------------------------------------------------\n# Test that the busy-handler is invoked correctly for \"PRAGMA optimize\"\n# and ANALYZE commnds.\nifcapable pragma&&analyze&&!stat4 {\n\nreset_db\n\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(y);\n  CREATE TABLE t3(z);\n\n  CREATE INDEX i1 ON t1(x);\n  CREATE INDEX i2 ON t2(y);\n\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t2 VALUES(1);\n  ANALYZE;\n\n  SELECT * FROM t1 WHERE x=1;\n  SELECT * FROM t2 WHERE y=1;\n} {1 1}\n\ndo_test 3.2 {\n  sqlite3 db2 test.db\n  execsql { BEGIN EXCLUSIVE } db2\n  catchsql { PRAGMA optimize }\n} {1 {database is locked}}\n\nproc busy_handler {n} {\n  if {$n>1000} { execsql { COMMIT } db2 }\n  return 0\n}\ndb busy busy_handler\n\ndo_test 3.3 {\n  catchsql { PRAGMA optimize }\n} {0 {}}\n\ndo_test 3.4 {\n  execsql {\n    BEGIN;\n    SELECT count(*) FROM sqlite_master;\n  } db2\n} {6}\n\nproc busy_handler {n} { return 1 }\ndo_test 3.5 {\n  catchsql { PRAGMA optimize }\n} {0 {}}\n\ndo_test 3.6 {\n  execsql { COMMIT } db2\n  execsql {\n    WITH s(i) AS (\n      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000\n    )\n    INSERT INTO t1 SELECT i FROM s;\n  }\n  execsql {\n    BEGIN;\n    SELECT count(*) FROM sqlite_master;\n  } db2\n} {6}\n\ndo_test 3.7 {\n  catchsql { PRAGMA optimize }\n} {1 {database is locked}}\n\nproc busy_handler {n} {\n  if {$n>1000} { execsql { COMMIT } db2 }\n  return 0\n}\ndo_test 3.8 {\n  catchsql { PRAGMA optimize }\n} {0 {}}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cache.test",
    "content": "# 2007 March 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: cache.test,v 1.4 2007/08/22 02:56:44 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !pager_pragmas||!compound {\n  finish_test\n  return\n}\nsqlite3_soft_heap_limit 0\n\nproc pager_cache_size {db} {\n  set bt [btree_from_db $db]\n  db_enter $db\n  array set stats [btree_pager_stats $bt]\n  db_leave $db\n  return $stats(page)\n}\n\nif {[permutation] == \"\"} { \n  do_test cache-1.1 { pager_cache_size db } {0}\n}\n\ndo_test cache-1.2 {\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n  }\n  pager_cache_size db\n} {2}\n\n# At one point, repeatedly locking and unlocking the cache was causing\n# a resource leak of one page per repetition. The page wasn't actually\n# leaked, but would not be reused until the pager-cache was full (i.e. \n# 2000 pages by default).\n#\n# This tests that once the pager-cache is initialized, it can be locked\n# and unlocked repeatedly without internally allocating any new pages.\n#\nset cache_size [pager_cache_size db]\nfor {set ii 0} {$ii < 10} {incr ii} {\n  do_test cache-1.3.$ii {\n    execsql {SELECT * FROM abc}\n    pager_cache_size db\n  } $::cache_size\n}\n\n#-------------------------------------------------------------------------\n# This block of tests checks that it is possible to set the cache_size of a\n# database to a small (< 10) value. More specifically:\n#\n#   cache-2.1.*: Test that \"PRAGMA cache_size\" appears to work with small \n#                values.\n#   cache-2.2.*: Test that \"PRAGMA main.cache_size\" appears to work with \n#                small values.\n#   cache-2.3.*: Test cache_size=1 correctly spills/flushes the cache. \n#   cache-2.4.*: Test cache_size=0 correctly spills/flushes the cache. \n#\n#\ndb_delete_and_reopen\ndo_execsql_test cache-2.0 {\n  PRAGMA auto_vacuum=OFF;\n  PRAGMA journal_mode=DELETE;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(c, d);\n  INSERT INTO t1 VALUES('x', 'y');\n  INSERT INTO t2 VALUES('i', 'j');\n} {delete}\n\nfor {set i 0} {$i < 20} {incr i} {\n  do_execsql_test cache-2.1.$i.1 \"PRAGMA cache_size = $i\"\n  do_execsql_test cache-2.1.$i.2 \"PRAGMA cache_size\" $i\n  do_execsql_test cache-2.1.$i.3 \"SELECT * FROM t1\" {x y}\n  do_execsql_test cache-2.1.$i.4 \"PRAGMA cache_size\" $i\n}\nfor {set i 0} {$i < 20} {incr i} {\n  do_execsql_test cache-2.2.$i.1 \"PRAGMA main.cache_size = $i\"\n  do_execsql_test cache-2.2.$i.2 \"PRAGMA main.cache_size\" $i\n  do_execsql_test cache-2.2.$i.3 \"SELECT * FROM t1\" {x y}\n  do_execsql_test cache-2.2.$i.4 \"PRAGMA main.cache_size\" $i\n}\n\n# Tests for cache_size = 1.\n#\ndo_execsql_test cache-2.3.1 {\n  PRAGMA cache_size = 1;\n  BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n    PRAGMA lock_status;\n} {main reserved temp closed}\ndo_test cache-2.3.2 { pager_cache_size db } 2\ndo_execsql_test cache-2.3.3 {\n    INSERT INTO t2 VALUES(1, 2);\n    PRAGMA lock_status;\n} {main exclusive temp closed}\ndo_test cache-2.3.4 { pager_cache_size db } 2\ndo_execsql_test cache-2.3.5 COMMIT\ndo_test cache-2.3.6 { pager_cache_size db } 1\n\ndo_execsql_test cache-2.3.7 {\n  SELECT * FROM t1 UNION SELECT * FROM t2;\n} {1 2 i j x y}\ndo_test cache-2.3.8 { pager_cache_size db } 1\n\n# Tests for cache_size = 0.\n#\ndo_execsql_test cache-2.4.1 {\n  PRAGMA cache_size = 0;\n  BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n    PRAGMA lock_status;\n} {main reserved temp closed}\ndo_test cache-2.4.2 { pager_cache_size db } 2\ndo_execsql_test cache-2.4.3 {\n    INSERT INTO t2 VALUES(1, 2);\n    PRAGMA lock_status;\n} {main exclusive temp closed}\ndo_test cache-2.4.4 { pager_cache_size db } 2\ndo_execsql_test cache-2.4.5 COMMIT\n\ndo_test cache-2.4.6 { pager_cache_size db } 0\ndo_execsql_test cache-2.4.7 {\n  SELECT * FROM t1 UNION SELECT * FROM t2;\n} {1 2 i j x y}\ndo_test cache-2.4.8 { pager_cache_size db } 0\n\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cacheflush.test",
    "content": "# 2011 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains test cases for sqlite3_db_cacheflush API.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix cacheflush\ntest_set_config_pagecache 0 0\n\n# Run the supplied SQL on a copy of the database currently stored on \n# disk in file $dbfile.\nproc diskquery {dbfile sql} {\n  forcecopy $dbfile dq.db\n  sqlite3 dq dq.db\n  set res [execsql $sql dq]\n  dq close\n  set res\n}\n\n# Simplest possible test.\n#\ndo_execsql_test 1.1.0 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n}\ndo_test 1.1.1 {\n  diskquery test.db { SELECT * FROM t1 } \n} {1 2}\ndo_test 1.1.2 {\n  sqlite3_db_cacheflush db\n  diskquery test.db { SELECT * FROM t1 } \n} {1 2 3 4}\n\n# Test that multiple pages may be flushed to disk.\n#\ndo_execsql_test 1.2.0 {\n  COMMIT;\n  CREATE TABLE t2(a, b);\n  BEGIN;\n    INSERT INTO t1 VALUES(5, 6);\n    INSERT INTO t2 VALUES('a', 'b');\n}\ndo_test 1.2.1 {\n  diskquery test.db { \n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {1 2 3 4}\ndo_test 1.2.2 {\n  sqlite3_db_cacheflush db\n  diskquery test.db { \n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {1 2 3 4 5 6 a b}\n\n# Test that pages with nRef!=0 are not flushed to disk.\n#\ndo_execsql_test 1.3.0 {\n  COMMIT;\n  CREATE TABLE t3(a, b);\n  BEGIN;\n    INSERT INTO t1 VALUES(7, 8);\n    INSERT INTO t2 VALUES('c', 'd');\n    INSERT INTO t3 VALUES('i', 'ii');\n}\ndo_test 1.3.1 {\n  diskquery test.db { \n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {1 2 3 4 5 6 a b}\ndo_test 1.3.2 {\n  db eval { SELECT a FROM t1 } {\n    if {$a==3} {\n      sqlite3_db_cacheflush db\n    }\n  }\n  diskquery test.db { \n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {1 2 3 4 5 6 a b c d i ii}\ndo_test 1.3.2 {\n  sqlite3_db_cacheflush db\n  diskquery test.db { \n    SELECT * FROM t1;\n    SELECT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {1 2 3 4 5 6 7 8 a b c d i ii}\n\n# Check that SQLITE_BUSY is returned if pages cannot be flushed due to\n# conflicting read locks.\n#\ndo_execsql_test 1.4.0 {\n  COMMIT;\n  BEGIN;\n    INSERT INTO t1 VALUES(9, 10);\n}\ndo_test 1.4.1 {\n  sqlite3 db2 test.db\n  db2 eval {\n    BEGIN;\n      SELECT * FROM t1;\n  }\n  diskquery test.db { \n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6 7 8}\ndo_test 1.4.2 {\n  list [catch { sqlite3_db_cacheflush db } msg] $msg\n} {1 {database is locked}}\ndo_test 1.4.3 {\n  diskquery test.db { \n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6 7 8}\ndo_test 1.4.4 {\n  db2 close\n  sqlite3_db_cacheflush db\n  diskquery test.db { \n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6 7 8 9 10}\ndo_execsql_test 1.4.5 { COMMIT }\n\n#-------------------------------------------------------------------------\n# Test that ATTACHed database caches are also flushed.\n#\nforcedelete test.db2\ndo_execsql_test 2.1.0 {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE aux.t4(x, y);\n  INSERT INTO t4 VALUES('A', 'B');\n  BEGIN;\n    INSERT INTO t1 VALUES(11, 12);\n    INSERT INTO t4 VALUES('C', 'D');\n}\ndo_test 2.1.1 {\n  diskquery test.db { SELECT * FROM t1; }\n} {1 2 3 4 5 6 7 8 9 10}\ndo_test 2.1.2 {\n  diskquery test.db2 { SELECT * FROM t4; }\n} {A B}\ndo_test 2.1.3 {\n  sqlite3_db_cacheflush db\n  diskquery test.db { SELECT * FROM t1; }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test 2.1.4 {\n  sqlite3_db_cacheflush db\n  diskquery test.db2 { SELECT * FROM t4; }\n} {A B C D}\ndo_execsql_test 2.1.5 { COMMIT }\n\n# And that hitting an SQLITE_BUSY when flushing \"main\" does not stop\n# SQLite from going on to flush \"aux\".\n#\ndo_execsql_test 2.2.0 {\n  BEGIN;\n    INSERT INTO t1 VALUES(13, 14);\n    INSERT INTO t4 VALUES('E', 'F');\n}\ndo_test 2.2.1 {\n  diskquery test.db { SELECT * FROM t1; }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test 2.2.2 {\n  diskquery test.db2 { SELECT * FROM t4; }\n} {A B C D}\ndo_test 2.2.3 {\n  sqlite3 db2 test.db\n  execsql {\n    BEGIN;\n      SELECT * FROM t1;\n  } db2\n  list [catch { sqlite3_db_cacheflush db } msg] $msg\n} {1 {database is locked}}\ndo_test 2.2.4 {\n  diskquery test.db { SELECT * FROM t1; }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test 2.2.5 {\n  diskquery test.db2 { SELECT * FROM t4; }\n} {A B C D E F}\ndo_test 2.2.6 {\n  db2 close\n  sqlite3_db_cacheflush db\n  diskquery test.db { SELECT * FROM t1; }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\ndo_execsql_test 2.2.7 { COMMIT }\n\n#-------------------------------------------------------------------------\n# Test that nothing terrible happens if sqlite3_db_cacheflush() is\n# called on an in-memory database.\n#\ndo_test 3.0 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    CREATE TABLE t1(x PRIMARY KEY);\n    CREATE TABLE t2(y PRIMARY KEY);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(100));\n      INSERT INTO t2 VALUES(randomblob(100));\n      INSERT INTO t1 VALUES(randomblob(100));\n      INSERT INTO t2 VALUES(randomblob(100));\n  }\n  sqlite3_db_cacheflush db\n} {}\n\ndo_execsql_test 3.1 { PRAGMA integrity_check } ok\ndo_execsql_test 3.2 { COMMIT }\ndo_execsql_test 3.3 { PRAGMA integrity_check } ok\ndo_execsql_test 3.4 { \n  SELECT count(*) FROM t1;\n  SELECT count(*) FROM t2;\n} {2 2}\n\n#-------------------------------------------------------------------------\n# Test that calling sqlite3_db_cacheflush() does not interfere with\n# savepoint transactions.\n#\ndo_test 4.0 {\n  reset_db\n  execsql {\n    CREATE TABLE ta(a, aa);\n    CREATE TABLE tb(b, bb);\n    INSERT INTO ta VALUES('a', randomblob(500));\n    INSERT INTO tb VALUES('b', randomblob(500));\n    BEGIN;\n      UPDATE ta SET a = 'A';\n      SAVEPOINT one;\n        UPDATE tb SET b = 'B';\n  }\n\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A B}\n\ndo_test 4.1 {\n  execsql { \n    ROLLBACK TO one;\n  }\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A b}\n\ndo_test 4.2 {\n  execsql { \n    INSERT INTO tb VALUES('c', randomblob(10));\n    INSERT INTO tb VALUES('d', randomblob(10));\n    INSERT INTO tb VALUES('e', randomblob(10));\n  }\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A b c d e}\n\ndo_test 4.3 {\n  execsql { \n    SAVEPOINT two;\n    UPDATE tb SET b = upper(b);\n  }\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A B C D E}\n\ndo_test 4.4 {\n  execsql { \n    ROLLBACK TO two;\n  }\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A b c d e}\n\ndo_test 4.4 {\n  execsql { \n    ROLLBACK TO one;\n  }\n  sqlite3_db_cacheflush db\n  diskquery test.db {\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {A b}\n\ndo_test 4.5 {\n  execsql { \n    ROLLBACK;\n    SELECT a FROM ta;\n    SELECT b FROM tb;\n  }\n} {a b}\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cachespill.test",
    "content": "# 2017 April 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix cachespill\n\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test that \"PRAGMA cache_spill = 0\" completely disables cache spilling.\n#\ndo_execsql_test 1.1 {\n  PRAGMA auto_vacuum = 0;\n  PRAGMA page_size = 1024;\n  PRAGMA cache_size = 100;\n  CREATE TABLE t1(a);\n}\n\ndo_test 1.2 {\n  file size test.db\n} {2048}\n\ndo_test 1.3 {\n  execsql {\n    BEGIN;\n      WITH s(i) AS (\n        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200\n      ) INSERT INTO t1 SELECT randomblob(900) FROM s;\n  }\n  expr {[file size test.db] > 50000}\n} {1}\n\ndo_test 1.4 {\n  execsql ROLLBACK\n  file size test.db\n} {2048}\n\ndo_test 1.5 {\n  execsql {\n    PRAGMA cache_spill = 0;\n    BEGIN;\n      WITH s(i) AS (\n        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200\n      ) INSERT INTO t1 SELECT randomblob(900) FROM s;\n  }\n  file size test.db\n} {2048}\n\ndo_test 1.5 {\n  execsql {\n    ROLLBACK;\n    PRAGMA cache_spill = 1;\n    BEGIN;\n      WITH s(i) AS (\n        SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<200\n      ) INSERT INTO t1 SELECT randomblob(900) FROM s;\n  }\n  expr {[file size test.db] > 50000}\n} {1}\n\ndo_execsql_test 1.6 { ROLLBACK }\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi2.test",
    "content": "# 2003 January 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the callback-free C/C++ API.\n#\n# $Id: capi2.test,v 1.37 2008/12/30 17:55:00 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Return the text values from the current row pointed at by STMT as a list.\nproc get_row_values {STMT} {\n  set VALUES [list]\n  for {set i 0} {$i < [sqlite3_data_count $STMT]} {incr i} {\n    lappend VALUES [sqlite3_column_text $STMT $i]\n  }\n  return $VALUES\n}\n\n# Return the column names followed by declaration types for the result set\n# of the SQL statement STMT.\n#\n# i.e. for:\n# CREATE TABLE abc(a text, b integer); \n# SELECT * FROM abc;\n#\n# The result is {a b text integer}\nproc get_column_names {STMT} {\n  set VALUES [list]\n  for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n    lappend VALUES [sqlite3_column_name $STMT $i]\n  }\n  for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n    lappend VALUES [sqlite3_column_decltype $STMT $i]\n  }\n  return $VALUES\n}\n\n# Check basic functionality\n#\ndo_test capi2-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  execsql {CREATE TABLE t1(a,b,c)}\n  set VM [sqlite3_prepare $DB {SELECT name, rowid FROM sqlite_master} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-1.2 {\n  sqlite3_step $VM\n} {SQLITE_ROW}\ndo_test capi2-1.3 {\n  sqlite3_data_count $VM\n} {2}\ndo_test capi2-1.4 {\n  get_row_values $VM\n} {t1 1}\ndo_test capi2-1.5 {\n  get_column_names $VM\n} {name rowid text INTEGER}\ndo_test capi2-1.6 {\n  sqlite3_step $VM \n} {SQLITE_DONE}\ndo_test capi2-1.7 {\n  list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]\n} {2 {} {name rowid text INTEGER}}\n\n# This used to be SQLITE_MISUSE.  But now we automatically reset prepared\n# statements.\nifcapable autoreset {\n  do_test capi2-1.8 {\n    sqlite3_step $VM\n  } {SQLITE_ROW}\n} else {\n  do_test capi2-1.8 {\n    sqlite3_step $VM\n  } {SQLITE_MISUSE}\n}\n\n# Update: In v2, once SQLITE_MISUSE is returned the statement handle cannot\n# be interrogated for more information. However in v3, since the column\n# count, names and types are determined at compile time, these are still\n# accessible after an SQLITE_MISUSE error.\ndo_test capi2-1.9 {\n  sqlite3_reset $VM\n  list [sqlite3_column_count $VM] [get_row_values $VM] [get_column_names $VM]\n} {2 {} {name rowid text INTEGER}}\ndo_test capi2-1.10 {\n  sqlite3_data_count $VM\n} {0}\n\ndo_test capi2-1.11 {\n  sqlite3_finalize $VM\n} {SQLITE_OK}\n\n# Check to make sure that the \"tail\" of a multi-statement SQL script\n# is returned by sqlite3_prepare.\n#\ndo_test capi2-2.1 {\n  set SQL {\n    SELECT name, rowid FROM sqlite_master;\n    SELECT name, rowid FROM sqlite_master WHERE 0;\n    -- A comment at the end\n  }\n  set VM [sqlite3_prepare $DB $SQL -1 SQL]\n  set SQL\n} {\n    SELECT name, rowid FROM sqlite_master WHERE 0;\n    -- A comment at the end\n  }\ndo_test capi2-2.2 {\n  set r [sqlite3_step $VM]\n  lappend r [sqlite3_column_count $VM] \\\n            [get_row_values $VM] \\\n            [get_column_names $VM]\n} {SQLITE_ROW 2 {t1 1} {name rowid text INTEGER}}\ndo_test capi2-2.3 {\n  set r [sqlite3_step $VM]\n  lappend r [sqlite3_column_count $VM] \\\n            [get_row_values $VM] \\\n            [get_column_names $VM]\n} {SQLITE_DONE 2 {} {name rowid text INTEGER}}\ndo_test capi2-2.4 {\n  sqlite3_finalize $VM\n} {SQLITE_OK}\ndo_test capi2-2.5 {\n  set VM [sqlite3_prepare $DB $SQL -1 SQL]\n  set SQL\n} {\n    -- A comment at the end\n  }\ndo_test capi2-2.6 {\n  set r [sqlite3_step $VM]\n  lappend r [sqlite3_column_count $VM] \\\n            [get_row_values $VM] \\\n            [get_column_names $VM]\n} {SQLITE_DONE 2 {} {name rowid text INTEGER}}\ndo_test capi2-2.7 {\n  sqlite3_finalize $VM\n} {SQLITE_OK}\ndo_test capi2-2.8 {\n  set VM [sqlite3_prepare $DB $SQL -1 SQL]\n  list $SQL $VM\n} {{} {}}\n\n# Check the error handling.\n#\ndo_test capi2-3.1 {\n  set rc [catch {\n      sqlite3_prepare $DB {select bogus from sqlite_master} -1 TAIL\n  } msg]\n  lappend rc $msg $TAIL\n} {1 {(1) no such column: bogus} {}}\ndo_test capi2-3.2 {\n  set rc [catch {\n      sqlite3_prepare $DB {select bogus from } -1 TAIL\n  } msg]\n  lappend rc $msg $TAIL\n} {1 {(1) near \" \": syntax error} {}}\ndo_test capi2-3.3 {\n  set rc [catch {\n      sqlite3_prepare $DB {;;;;select bogus from sqlite_master} -1 TAIL\n  } msg]\n  lappend rc $msg $TAIL\n} {1 {(1) no such column: bogus} {}}\ndo_test capi2-3.4 {\n  set rc [catch {\n      sqlite3_prepare $DB {select bogus from sqlite_master;x;} -1 TAIL\n  } msg]\n  lappend rc $msg $TAIL\n} {1 {(1) no such column: bogus} {x;}}\ndo_test capi2-3.5 {\n  set rc [catch {\n      sqlite3_prepare $DB {select bogus from sqlite_master;;;x;} -1 TAIL\n  } msg]\n  lappend rc $msg $TAIL\n} {1 {(1) no such column: bogus} {;;x;}}\ndo_test capi2-3.6 {\n  set rc [catch {\n      sqlite3_prepare $DB {select 5/0} -1 TAIL\n  } VM]\n  lappend rc $TAIL\n} {0 {}}\ndo_test capi2-3.7 {\n  list [sqlite3_step $VM] \\\n       [sqlite3_column_count $VM] \\\n       [get_row_values $VM] \\\n       [get_column_names $VM]\n} {SQLITE_ROW 1 {{}} {5/0 {}}}\ndo_test capi2-3.8 {\n  sqlite3_finalize $VM\n} {SQLITE_OK}\ndo_test capi2-3.9 {\n  execsql {CREATE UNIQUE INDEX i1 ON t1(a)}\n  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,2,3)} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-3.9b {db changes} {0}\ndo_test capi2-3.10 {\n  list [sqlite3_step $VM] \\\n       [sqlite3_column_count $VM] \\\n       [get_row_values $VM] \\\n       [get_column_names $VM]\n} {SQLITE_DONE 0 {} {}}\n\n# Update for v3 - the change has not actually happened until the query is\n# finalized. Is this going to cause trouble for anyone? Lee Nelson maybe?\n# (Later:) The change now happens just before SQLITE_DONE is returned.\ndo_test capi2-3.10b {db changes} {1}\ndo_test capi2-3.11 {\n  sqlite3_finalize $VM\n} {SQLITE_OK}\ndo_test capi2-3.11b {db changes} {1}\n#do_test capi2-3.12-misuse {\n#  sqlite3_finalize $VM\n#} {SQLITE_MISUSE}\ndo_test capi2-3.13 {\n  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(1,3,4)} -1 TAIL]\n  list [sqlite3_step $VM] \\\n       [sqlite3_column_count $VM] \\\n       [get_row_values $VM] \\\n       [get_column_names $VM]\n} {SQLITE_ERROR 0 {} {}}\n\n# Update for v3: Preparing a statement does not affect the change counter.\n# (Test result changes from 0 to 1).  (Later:) change counter updates occur\n# when sqlite3_step returns, not at finalize time.\ndo_test capi2-3.13b {db changes} {0}\n\ndo_test capi2-3.14 {\n  list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \\\n       [sqlite3_extended_errcode $DB]\n} {SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.a} SQLITE_CONSTRAINT_UNIQUE}\ndo_test capi2-3.15 {\n  set VM [sqlite3_prepare $DB {CREATE TABLE t2(a NOT NULL, b)} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-3.16 {\n  list [sqlite3_step $VM] \\\n       [sqlite3_column_count $VM] \\\n       [get_row_values $VM] \\\n       [get_column_names $VM]\n} {SQLITE_DONE 0 {} {}}\ndo_test capi2-3.17 {\n  list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]\n} {SQLITE_OK {not an error}}\ndo_test capi2-3.18 {\n  set VM [sqlite3_prepare $DB {INSERT INTO t2 VALUES(NULL,2)} -1 TAIL]\n  list [sqlite3_step $VM] \\\n       [sqlite3_column_count $VM] \\\n       [get_row_values $VM] \\\n       [get_column_names $VM]\n} {SQLITE_ERROR 0 {} {}}\ndo_test capi2-3.19 {\n  list [sqlite3_finalize $VM] [sqlite3_errmsg $DB] \\\n       [sqlite3_extended_errcode $DB]\n} {SQLITE_CONSTRAINT {NOT NULL constraint failed: t2.a} SQLITE_CONSTRAINT_NOTNULL}\n\ndo_test capi2-3.20 {\n  execsql {\n    CREATE TABLE a1(message_id, name , UNIQUE(message_id, name) );\n    INSERT INTO a1 VALUES(1, 1);\n  }\n} {}\ndo_test capi2-3.21 {\n  set VM [sqlite3_prepare $DB {INSERT INTO a1 VALUES(1, 1)} -1 TAIL]\n  sqlite3_step $VM\n} {SQLITE_ERROR}\ndo_test capi2-3.22 {\n  sqlite3_errcode $DB\n} {SQLITE_ERROR}\ndo_test capi2-3.23 {\n  sqlite3_finalize $VM\n} {SQLITE_CONSTRAINT}\ndo_test capi2-3.24 {\n  list [sqlite3_errcode $DB] [sqlite3_extended_errcode $DB]\n} {SQLITE_CONSTRAINT SQLITE_CONSTRAINT_UNIQUE}\n\n# Two or more virtual machines exists at the same time.\n#\ndo_test capi2-4.1 {\n  set VM1 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(1,2)} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-4.2 {\n  set VM2 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-4.3 {\n  set VM3 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(3,4)} -1 TAIL]\n  set TAIL\n} {}\ndo_test capi2-4.4 {\n  list [sqlite3_step $VM2] \\\n       [sqlite3_column_count $VM2] \\\n       [get_row_values $VM2] \\\n       [get_column_names $VM2]\n} {SQLITE_DONE 0 {} {}}\ndo_test capi2-4.5 {\n  execsql {SELECT * FROM t2 ORDER BY a}\n} {2 3}\ndo_test capi2-4.6 {\n  sqlite3_finalize $VM2\n} {SQLITE_OK}\ndo_test capi2-4.7 {\n  list [sqlite3_step $VM3] \\\n       [sqlite3_column_count $VM3] \\\n       [get_row_values $VM3] \\\n       [get_column_names $VM3]\n} {SQLITE_DONE 0 {} {}}\ndo_test capi2-4.8 {\n  execsql {SELECT * FROM t2 ORDER BY a}\n} {2 3 3 4}\ndo_test capi2-4.9 {\n  sqlite3_finalize $VM3\n} {SQLITE_OK}\ndo_test capi2-4.10 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_DONE 0 {} {}}\ndo_test capi2-4.11 {\n  execsql {SELECT * FROM t2 ORDER BY a}\n} {1 2 2 3 3 4}\ndo_test capi2-4.12 {\n  sqlite3_finalize $VM1\n} {SQLITE_OK}\n\n# Interleaved SELECTs\n#\ndo_test capi2-5.1 {\n  set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]\n  set VM2 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]\n  set VM3 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 2 {2 3} {a b {} {}}}\ndo_test capi2-5.2 {\n  list [sqlite3_step $VM2] \\\n       [sqlite3_column_count $VM2] \\\n       [get_row_values $VM2] \\\n       [get_column_names $VM2]\n} {SQLITE_ROW 2 {2 3} {a b {} {}}}\ndo_test capi2-5.3 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 2 {3 4} {a b {} {}}}\ndo_test capi2-5.4 {\n  list [sqlite3_step $VM3] \\\n       [sqlite3_column_count $VM3] \\\n       [get_row_values $VM3] \\\n       [get_column_names $VM3]\n} {SQLITE_ROW 2 {2 3} {a b {} {}}}\ndo_test capi2-5.5 {\n  list [sqlite3_step $VM3] \\\n       [sqlite3_column_count $VM3] \\\n       [get_row_values $VM3] \\\n       [get_column_names $VM3]\n} {SQLITE_ROW 2 {3 4} {a b {} {}}}\ndo_test capi2-5.6 {\n  list [sqlite3_step $VM3] \\\n       [sqlite3_column_count $VM3] \\\n       [get_row_values $VM3] \\\n       [get_column_names $VM3]\n} {SQLITE_ROW 2 {1 2} {a b {} {}}}\ndo_test capi2-5.7 {\n  list [sqlite3_step $VM3] \\\n       [sqlite3_column_count $VM3] \\\n       [get_row_values $VM3] \\\n       [get_column_names $VM3]\n} {SQLITE_DONE 2 {} {a b {} {}}}\ndo_test capi2-5.8 {\n  sqlite3_finalize $VM3\n} {SQLITE_OK}\ndo_test capi2-5.9 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 2 {1 2} {a b {} {}}}\ndo_test capi2-5.10 {\n  sqlite3_finalize $VM1\n} {SQLITE_OK}\ndo_test capi2-5.11 {\n  list [sqlite3_step $VM2] \\\n       [sqlite3_column_count $VM2] \\\n       [get_row_values $VM2] \\\n       [get_column_names $VM2]\n} {SQLITE_ROW 2 {3 4} {a b {} {}}}\ndo_test capi2-5.12 {\n  list [sqlite3_step $VM2] \\\n       [sqlite3_column_count $VM2] \\\n       [get_row_values $VM2] \\\n       [get_column_names $VM2]\n} {SQLITE_ROW 2 {1 2} {a b {} {}}}\ndo_test capi2-5.11 {\n  sqlite3_finalize $VM2\n} {SQLITE_OK}\n\n# Check for proper SQLITE_BUSY returns.\n#\ndo_test capi2-6.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(x counter);\n    INSERT INTO t3 VALUES(1);\n    INSERT INTO t3 VALUES(2);\n    INSERT INTO t3 SELECT x+2 FROM t3;\n    INSERT INTO t3 SELECT x+4 FROM t3;\n    INSERT INTO t3 SELECT x+8 FROM t3;\n    COMMIT;\n  }\n  set VM1 [sqlite3_prepare $DB {SELECT * FROM t3} -1 TAIL]\n  sqlite3 db2 test.db\n  execsql {BEGIN} db2\n} {}\n# Update for v3: BEGIN doesn't write-lock the database. It is quite\n# difficult to get v3 to write-lock the database, which causes a few\n# problems for test scripts.\n#\n# do_test capi2-6.2 {\n#   list [sqlite3_step $VM1] \\\n#        [sqlite3_column_count $VM1] \\\n#        [get_row_values $VM1] \\\n#        [get_column_names $VM1]\n# } {SQLITE_BUSY 0 {} {}}\ndo_test capi2-6.3 {\n  execsql {COMMIT} db2\n} {}\ndo_test capi2-6.4 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 1 {x counter}}\ndo_test capi2-6.5 {\n  catchsql {INSERT INTO t3 VALUES(10);} db2\n} {1 {database is locked}}\ndo_test capi2-6.6 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 2 {x counter}}\ndo_test capi2-6.7 {\n  execsql {SELECT * FROM t2} db2\n} {2 3 3 4 1 2}\ndo_test capi2-6.8 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 3 {x counter}}\ndo_test capi2-6.9 {\n  execsql {SELECT * FROM t2} \n} {2 3 3 4 1 2}\ndo_test capi2-6.10 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 4 {x counter}}\ndo_test capi2-6.11 {\n  execsql {BEGIN}\n} {}\ndo_test capi2-6.12 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 5 {x counter}}\n\n# A read no longer blocks a write in the same connection.\n#do_test capi2-6.13 {\n#  catchsql {UPDATE t3 SET x=x+1}\n#} {1 {database table is locked}}\n\ndo_test capi2-6.14 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 6 {x counter}}\ndo_test capi2-6.15 {\n  execsql {SELECT * FROM t1}\n} {1 2 3}\ndo_test capi2-6.16 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 7 {x counter}}\ndo_test capi2-6.17 {\n  catchsql {UPDATE t1 SET b=b+1}\n} {0 {}}\ndo_test capi2-6.18 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 8 {x counter}}\ndo_test capi2-6.19 {\n  execsql {SELECT * FROM t1}\n} {1 3 3}\ndo_test capi2-6.20 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 9 {x counter}}\n#do_test capi2-6.21 {\n#  execsql {ROLLBACK; SELECT * FROM t1}\n#} {1 2 3}\ndo_test capi2-6.22 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 10 {x counter}}\n#do_test capi2-6.23 {\n#  execsql {BEGIN TRANSACTION;}\n#} {}\ndo_test capi2-6.24 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 11 {x counter}}\ndo_test capi2-6.25 {\n  execsql {\n    INSERT INTO t1 VALUES(2,3,4);\n    SELECT * FROM t1;\n  }\n} {1 3 3 2 3 4}\ndo_test capi2-6.26 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 12 {x counter}}\ndo_test capi2-6.27 {\n  catchsql {\n    INSERT INTO t1 VALUES(2,4,5);\n    SELECT * FROM t1;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test capi2-6.28 {\n  list [sqlite3_step $VM1] \\\n       [sqlite3_column_count $VM1] \\\n       [get_row_values $VM1] \\\n       [get_column_names $VM1]\n} {SQLITE_ROW 1 13 {x counter}}\ndo_test capi2-6.99 {\n  sqlite3_finalize $VM1\n} {SQLITE_OK}\ncatchsql {ROLLBACK}\n\ndo_test capi2-7.1 {\n  stepsql $DB {\n    SELECT * FROM t1\n  }\n} {0 1 2 3}\ndo_test capi2-7.2 {\n  stepsql $DB {\n    PRAGMA count_changes=on\n  }\n} {0}\ndo_test capi2-7.3 {\n  stepsql $DB {\n    UPDATE t1 SET a=a+10;\n  }\n} {0 1}\ndo_test capi2-7.4 {\n  stepsql $DB {\n    INSERT INTO t1 SELECT a+1,b+1,c+1 FROM t1;\n  }\n} {0 1}\ndo_test capi2-7.4b {sqlite3_changes $DB} {1}\ndo_test capi2-7.5 {\n  stepsql $DB {\n    UPDATE t1 SET a=a+10;\n  }\n} {0 2}\ndo_test capi2-7.5b {sqlite3_changes $DB} {2}\ndo_test capi2-7.6 {\n  stepsql $DB {\n    SELECT * FROM t1;\n  }\n} {0 21 2 3 22 3 4}\ndo_test capi2-7.7 {\n  stepsql $DB {\n    INSERT INTO t1 SELECT a+2,b+2,c+2 FROM t1;\n  }\n} {0 2}\ndo_test capi2-7.8 {\n  sqlite3_changes $DB\n} {2}\ndo_test capi2-7.9 {\n  stepsql $DB {\n    SELECT * FROM t1;\n  }\n} {0 21 2 3 22 3 4 23 4 5 24 5 6}\ndo_test capi2-7.10 {\n  stepsql $DB {\n    UPDATE t1 SET a=a-20;\n    SELECT * FROM t1;\n  }\n} {0 4 1 2 3 2 3 4 3 4 5 4 5 6}\n\n# Update for version 3: A SELECT statement no longer resets the change\n# counter (Test result changes from 0 to 4).\ndo_test capi2-7.11 {\n  sqlite3_changes $DB\n} {4}\ndo_test capi2-7.11a {\n  execsql {SELECT count(*) FROM t1}\n} {4}\n\nifcapable {explain} {\n  do_test capi2-7.12 {\n    set x [stepsql $DB {EXPLAIN SELECT * FROM t1}]\n    lindex $x 0\n  } {0}\n}\n\n# Ticket #261 - make sure we can finalize before the end of a query.\n#\ndo_test capi2-8.1 {\n  set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]\n  sqlite3_finalize $VM1\n} {SQLITE_OK}\n  \n# Tickets #384 and #385 - make sure the TAIL argument to sqlite3_prepare\n# and all of the return pointers in sqlite_step can be null.\n#\ndo_test capi2-9.1 {\n  set VM1 [sqlite3_prepare $DB {SELECT * FROM t2} -1 DUMMY]\n  sqlite3_step $VM1\n  sqlite3_finalize $VM1\n} {SQLITE_OK}\n\n# Test that passing a NULL pointer to sqlite3_finalize() or sqlite3_reset\n# does not cause an error.\ndo_test capi2-10.1 {\n  sqlite3_finalize 0\n} {SQLITE_OK}\ndo_test capi2-10.2 {\n  sqlite3_reset 0\n} {SQLITE_OK}\n\n#---------------------------------------------------------------------------\n# The following tests - capi2-11.* - test the \"column origin\" APIs.\n#\n#   sqlite3_column_origin_name()\n#   sqlite3_column_database_name()\n#   sqlite3_column_table_name()\n#\n\nifcapable columnmetadata {\n\n# This proc uses the database handle $::DB to compile the SQL statement passed\n# as a parameter. The return value of this procedure is a list with one\n# element for each column returned by the compiled statement. Each element of\n# this list is itself a list of length three, consisting of the origin\n# database, table and column for the corresponding returned column.\nproc check_origins {sql} {\n  set ret [list]\n  set ::STMT [sqlite3_prepare $::DB $sql -1 dummy]\n  for {set i 0} {$i < [sqlite3_column_count $::STMT]} {incr i} {\n    lappend ret [list                           \\\n      [sqlite3_column_database_name $::STMT $i] \\\n      [sqlite3_column_table_name $::STMT $i]    \\\n      [sqlite3_column_origin_name $::STMT $i]   \\\n    ]\n  }\n  sqlite3_finalize $::STMT\n  return $ret\n}\ndo_test capi2-11.1 {\n  execsql {\n    CREATE TABLE tab1(col1, col2);\n  }\n} {}\ndo_test capi2-11.2 {\n  check_origins {SELECT col2, col1 FROM tab1}\n} [list {main tab1 col2} {main tab1 col1}]\ndo_test capi2-11.3 {\n  check_origins {SELECT col2 AS hello, col1 AS world FROM tab1}\n} [list {main tab1 col2} {main tab1 col1}]\n\nifcapable subquery {\n  do_test capi2-11.4 {\n    check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM tab1)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-11.5 {\n    check_origins {SELECT (SELECT col2 FROM tab1), (SELECT col1 FROM tab1)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-11.6 {\n    check_origins {SELECT (SELECT col2), (SELECT col1) FROM tab1}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-11.7 {\n    check_origins {SELECT * FROM tab1}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-11.8 {\n    check_origins {SELECT * FROM (SELECT * FROM tab1)}\n  } [list {main tab1 col1} {main tab1 col2}]\n}\n\nifcapable view&&subquery {\n  do_test capi2-12.1 {\n    execsql {\n      CREATE VIEW view1 AS SELECT * FROM  tab1;\n    }\n  } {}\n  do_test capi2-12.2 {\n    check_origins {SELECT col2, col1 FROM view1}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-12.3 {\n    check_origins {SELECT col2 AS hello, col1 AS world FROM view1}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-12.4 {\n    check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM view1)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-12.5 {\n    check_origins {SELECT (SELECT col2 FROM view1), (SELECT col1 FROM view1)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-12.6 {\n    check_origins {SELECT (SELECT col2), (SELECT col1) FROM view1}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-12.7 {\n    check_origins {SELECT * FROM view1}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-12.8 {\n    check_origins {select * from (select * from view1)}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-12.9 {\n    check_origins {select * from (select * from (select * from view1))}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-12.10 {\n    db close\n    sqlite3 db test.db\n    set ::DB [sqlite3_connection_pointer db]\n    check_origins {select * from (select * from (select * from view1))}\n  } [list {main tab1 col1} {main tab1 col2}]\n  \n  # This view will thwart the flattening optimization.\n  do_test capi2-13.1 {\n    execsql {\n      CREATE VIEW view2 AS SELECT * FROM tab1 limit 10 offset 10;\n    }\n  } {}\n  do_test capi2-13.2 {\n    check_origins {SELECT col2, col1 FROM view2}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-13.3 {\n    check_origins {SELECT col2 AS hello, col1 AS world FROM view2}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-13.4 {\n    check_origins {SELECT b, a FROM (SELECT col1 AS a, col2 AS b FROM view2)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-13.5 {\n    check_origins {SELECT (SELECT col2 FROM view2), (SELECT col1 FROM view2)}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-13.6 {\n    check_origins {SELECT (SELECT col2), (SELECT col1) FROM view2}\n  } [list {main tab1 col2} {main tab1 col1}]\n  do_test capi2-13.7 {\n    check_origins {SELECT * FROM view2}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-13.8 {\n    check_origins {select * from (select * from view2)}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-13.9 {\n    check_origins {select * from (select * from (select * from view2))}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-13.10 {\n    db close\n    sqlite3 db test.db\n    set ::DB [sqlite3_connection_pointer db]\n    check_origins {select * from (select * from (select * from view2))}\n  } [list {main tab1 col1} {main tab1 col2}]\n  do_test capi2-13.11 {\n    check_origins {select * from (select * from tab1 limit 10 offset 10)}\n  } [list {main tab1 col1} {main tab1 col2}]\n}\n\n\n} ;# ifcapable columnmetadata\n\ndb2 close\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi3.test",
    "content": "# 2003 January 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the callback-free C/C++ API.\n#\n# $Id: capi3.test,v 1.70 2009/01/09 02:49:32 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix capi3\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\n# Return the UTF-8 representation of the supplied UTF-16 string $str. \nproc utf8 {str} {\n  # If $str ends in two 0x00 0x00 bytes, knock these off before\n  # converting to UTF-8 using TCL.\n  binary scan $str \\c* vals\n  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {\n    set str [binary format \\c* [lrange $vals 0 end-2]]\n  }\n\n  set r [encoding convertfrom unicode $str]\n  return $r\n}\n\n# These tests complement those in capi2.test. They are organized\n# as follows:\n#\n# capi3-1.*: Test sqlite3_prepare \n# capi3-2.*: Test sqlite3_prepare16\n# capi3-3.*: Test sqlite3_open\n# capi3-4.*: Test sqlite3_open16\n# capi3-5.*: Test the various sqlite3_result_* APIs\n# capi3-6.*: Test that sqlite3_close fails if there are outstanding VMs.\n#\n\nset DB [sqlite3_connection_pointer db]\n\ndo_test capi3-1.0 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-1.1 {\n  set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {}\ndo_test capi3-1.2.1 {\n  sqlite3_errcode $DB\n} {SQLITE_OK}\ndo_test capi3-1.2.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_OK}\ndo_test capi3-1.3 {\n  sqlite3_errmsg $DB\n} {not an error}\ndo_test capi3-1.4 {\n  set sql {SELECT name FROM sqlite_master;SELECT 10}\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {SELECT 10}\ndo_test capi3-1.5 {\n  set sql {SELECT name FROM sqlite_master;SELECT 10}\n  set STMT [sqlite3_prepare $DB $sql [string length $sql] TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {SELECT 10}\ndo_test capi3-1.6 {\n  set sql {SELECT name FROM sqlite_master;SELECT 10}\n  set STMT [sqlite3_prepare $DB $sql [expr [string length $sql]+1] TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {SELECT 10}\n\ndo_test capi3-1.7 {\n  set sql {SELECT namex FROM sqlite_master}\n  catch {\n    set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  }\n} {1}\ndo_test capi3-1.8.1 {\n  sqlite3_errcode $DB\n} {SQLITE_ERROR}\ndo_test capi3-1.8.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_ERROR}\ndo_test capi3-1.9 {\n  sqlite3_errmsg $DB\n} {no such column: namex}\n\nifcapable {utf16} {\n  do_test capi3-2.1 {\n    set sql16 [utf16 {SELECT name FROM sqlite_master}]\n    set STMT [sqlite3_prepare16 $DB $sql16 -1 ::TAIL]\n    sqlite3_finalize $STMT\n    utf8 $::TAIL\n  } {}\n  do_test capi3-2.2 {\n    set sql [utf16 {SELECT name FROM sqlite_master;SELECT 10}]\n    set STMT [sqlite3_prepare16 $DB $sql -1 TAIL]\n    sqlite3_finalize $STMT\n    utf8 $TAIL\n  } {SELECT 10}\n  do_test capi3-2.3 {\n    set sql [utf16 {SELECT namex FROM sqlite_master}]\n    catch {\n      set STMT [sqlite3_prepare16 $DB $sql -1]\n    }\n  } {1}\n  do_test capi3-2.4.1 {\n    sqlite3_errcode $DB\n  } {SQLITE_ERROR}\n  do_test capi3-2.4.2 {\n    sqlite3_extended_errcode $DB\n  } {SQLITE_ERROR}\n  do_test capi3-2.5 {\n    sqlite3_errmsg $DB\n  } {no such column: namex}\n\n  ifcapable schema_pragmas {\n    do_test capi3-2.6 {\n      execsql {CREATE TABLE tablename(x)}\n      set sql16 [utf16 {PRAGMA table_info(\"TableName\"); --excess text}]\n      set STMT [sqlite3_prepare16 $DB $sql16 -1]\n      sqlite3_step $STMT\n    } SQLITE_ROW\n    do_test capi3-2.7 {\n      sqlite3_step $STMT\n    } SQLITE_DONE\n    do_test capi3-2.8 {\n      sqlite3_finalize $STMT\n    } SQLITE_OK\n  }\n\n} ;# endif utf16\n\n# rename sqlite3_open sqlite3_open_old\n# proc sqlite3_open {fname options} {sqlite3_open_new $fname $options}\n\ndo_test capi3-3.1 {\n  set db2 [sqlite3_open test.db {}]\n  sqlite3_errcode $db2\n} {SQLITE_OK}\n# FIX ME: Should test the db handle works.\ndo_test capi3-3.2 {\n  sqlite3_close $db2\n} {SQLITE_OK}\ndo_test capi3-3.3 {\n  catch {\n    set db2 [sqlite3_open /bogus/path/test.db {}]\n  }\n  set ::capi3_errno [sqlite3_system_errno $db2]\n  list [sqlite3_extended_errcode $db2] [expr {$::capi3_errno!=0}]\n} {SQLITE_CANTOPEN 1}\ndo_test capi3-3.4 {\n  sqlite3_errmsg $db2\n} {unable to open database file}\ndo_test capi3-3.5 {\n  list [sqlite3_system_errno $db2] [sqlite3_close $db2]\n} [list $::capi3_errno SQLITE_OK]\nif {[clang_sanitize_address]==0} {\n  do_test capi3-3.6.1-misuse {\n    sqlite3_close $db2\n  } {SQLITE_MISUSE}\n  do_test capi3-3.6.2-misuse {\n    sqlite3_errmsg $db2\n  } {bad parameter or other API misuse}\n  ifcapable {utf16} {\n    do_test capi3-3.6.3-misuse {\n      utf8 [sqlite3_errmsg16 $db2]\n    } {bad parameter or other API misuse}\n  }\n}\n\ndo_test capi3-3.7 {\n  set db2 [sqlite3_open]\n  sqlite3_errcode $db2\n} {SQLITE_OK}\ndo_test capi3-3.8 {\n  sqlite3_close $db2\n} {SQLITE_OK}\n\n# rename sqlite3_open \"\"\n# rename sqlite3_open_old sqlite3_open\n\nifcapable {utf16} {\ndo_test capi3-4.1 {\n  set db2 [sqlite3_open16 [utf16 test.db] {}]\n  sqlite3_errcode $db2\n} {SQLITE_OK}\n# FIX ME: Should test the db handle works.\ndo_test capi3-4.2 {\n  sqlite3_close $db2\n} {SQLITE_OK}\ndo_test capi3-4.3 {\n  catch {\n    set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}]\n  }\n  sqlite3_errcode $db2\n} {SQLITE_CANTOPEN}\ndo_test capi3-4.4 {\n  utf8 [sqlite3_errmsg16 $db2]\n} {unable to open database file}\ndo_test capi3-4.5 {\n  sqlite3_close $db2\n} {SQLITE_OK}\n} ;# utf16\n\n# This proc is used to test the following API calls:\n#\n# sqlite3_column_count\n# sqlite3_column_name\n# sqlite3_column_name16\n# sqlite3_column_decltype\n# sqlite3_column_decltype16\n#\n# $STMT is a compiled SQL statement. $test is a prefix\n# to use for test names within this proc. $names is a list\n# of the column names that should be returned by $STMT.\n# $decltypes is a list of column declaration types for $STMT.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare \"SELECT 1, 2, 2;\" -1 DUMMY]\n# check_header test1.1 {1 2 3} {\"\" \"\" \"\"}\n#\nproc check_header {STMT test names decltypes} {\n\n  # Use the return value of sqlite3_column_count() to build\n  # a list of column indexes. i.e. If sqlite3_column_count\n  # is 3, build the list {0 1 2}.\n  set ::idxlist [list]\n  set ::numcols [sqlite3_column_count $STMT]\n  for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}\n\n  # Column names in UTF-8\n  do_test $test.1 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} \n    set cnamelist\n  } $names\n\n  # Column names in UTF-16\n  ifcapable {utf16} {\n    do_test $test.2 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]\n      }\n      set cnamelist\n    } $names\n  }\n\n  # Column names in UTF-8\n  do_test $test.3 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} \n    set cnamelist\n  } $names\n\n  # Column names in UTF-16\n  ifcapable {utf16} {\n    do_test $test.4 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]\n      }\n      set cnamelist\n    } $names\n  }\n\n  # Column names in UTF-8\n  do_test $test.5 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]} \n    set cnamelist\n  } $decltypes\n\n  # Column declaration types in UTF-16\n  ifcapable {utf16} {\n    do_test $test.6 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]]\n      }\n      set cnamelist\n    } $decltypes\n  }\n\n\n  # Test some out of range conditions:\n  ifcapable {utf16} {\n    do_test $test.7 {\n      list \\\n        [sqlite3_column_name $STMT -1] \\\n        [sqlite3_column_name16 $STMT -1] \\\n        [sqlite3_column_decltype $STMT -1] \\\n        [sqlite3_column_decltype16 $STMT -1] \\\n        [sqlite3_column_name $STMT $numcols] \\\n        [sqlite3_column_name16 $STMT $numcols] \\\n        [sqlite3_column_decltype $STMT $numcols] \\\n        [sqlite3_column_decltype16 $STMT $numcols]\n    } {{} {} {} {} {} {} {} {}}\n  }\n} \n\n# This proc is used to test the following API calls:\n#\n# sqlite3_column_origin_name\n# sqlite3_column_origin_name16\n# sqlite3_column_table_name\n# sqlite3_column_table_name16\n# sqlite3_column_database_name\n# sqlite3_column_database_name16\n#\n# $STMT is a compiled SQL statement. $test is a prefix\n# to use for test names within this proc. $names is a list\n# of the column names that should be returned by $STMT.\n# $decltypes is a list of column declaration types for $STMT.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare \"SELECT 1, 2, 2;\" -1 DUMMY]\n# check_header test1.1 {1 2 3} {\"\" \"\" \"\"}\n#\nproc check_origin_header {STMT test dbs tables cols} {\n  # If sqlite3_column_origin_name() and friends are not compiled into\n  # this build, this proc is a no-op.\n  ifcapable columnmetadata {\n    # Use the return value of sqlite3_column_count() to build\n    # a list of column indexes. i.e. If sqlite3_column_count\n    # is 3, build the list {0 1 2}.\n    set ::idxlist [list]\n    set ::numcols [sqlite3_column_count $STMT]\n    for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}\n  \n    # Database names in UTF-8\n    do_test $test.8 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_database_name $STMT $i]\n      } \n      set cnamelist\n    } $dbs\n  \n    # Database names in UTF-16\n    ifcapable {utf16} {\n      do_test $test.9 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_database_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $dbs\n    }\n  \n    # Table names in UTF-8\n    do_test $test.10 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_table_name $STMT $i]\n      } \n      set cnamelist\n    } $tables\n  \n    # Table names in UTF-16\n    ifcapable {utf16} {\n      do_test $test.11 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_table_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $tables\n    }\n  \n    # Origin names in UTF-8\n    do_test $test.12 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_origin_name $STMT $i]\n      } \n      set cnamelist\n    } $cols\n  \n    # Origin declaration types in UTF-16\n    ifcapable {utf16} {\n      do_test $test.13 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_origin_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $cols\n    }\n  }\n}\n\n# This proc is used to test the following APIs:\n#\n# sqlite3_data_count\n# sqlite3_column_type\n# sqlite3_column_int\n# sqlite3_column_text\n# sqlite3_column_text16\n# sqlite3_column_double\n#\n# $STMT is a compiled SQL statement for which the previous call \n# to sqlite3_step returned SQLITE_ROW. $test is a prefix to use \n# for test names within this proc. $types is a list of the \n# manifest types for the current row. $ints, $doubles and $strings\n# are lists of the integer, real and string representations of\n# the values in the current row.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare \"SELECT 'hello', 1.1, NULL\" -1 DUMMY]\n# sqlite3_step $STMT\n# check_data test1.2 {TEXT REAL NULL} {0 1 0} {0 1.1 0} {hello 1.1 {}}\n#\nproc check_data {STMT test types ints doubles strings} {\n\n  # Use the return value of sqlite3_column_count() to build\n  # a list of column indexes. i.e. If sqlite3_column_count\n  # is 3, build the list {0 1 2}.\n  set ::idxlist [list]\n  set numcols [sqlite3_data_count $STMT]\n  for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}\n\n# types\ndo_test $test.1 {\n  set types [list]\n  foreach i $idxlist {\n    set x [sqlite3_column_type $STMT $i]\n    # EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five\n    # fundamental datatypes: 64-bit signed integer 64-bit IEEE floating\n    # point number string BLOB NULL\n    if {[lsearch {INTEGER FLOAT TEXT BLOB NULL} $x]<0} {\n      set types ERROR\n      break\n    } else {\n      lappend types $x\n    }\n  }\n  set types\n} $types\n \n\n# Integers\ndo_test $test.2 {\n  set ints [list]\n  foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}\n  set ints\n} $ints\n\n# bytes\nset lens [list]\nforeach i $::idxlist {\n  lappend lens [string length [lindex $strings $i]]\n}\ndo_test $test.3 {\n  set bytes [list]\n  set lens [list]\n  foreach i $idxlist {\n    lappend bytes [sqlite3_column_bytes $STMT $i]\n  }\n  set bytes\n} $lens\n\n# bytes16\nifcapable {utf16} {\n  set lens [list]\n  foreach i $::idxlist {\n    lappend lens [expr 2 * [string length [lindex $strings $i]]]\n  }\n  do_test $test.4 {\n    set bytes [list]\n    set lens [list]\n    foreach i $idxlist {\n      lappend bytes [sqlite3_column_bytes16 $STMT $i]\n    }\n    set bytes\n  } $lens\n}\n\n# Blob\ndo_test $test.5 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}\n  set utf8\n} $strings\n\n# UTF-8\ndo_test $test.6 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}\n  set utf8\n} $strings\n\n# Floats\ndo_test $test.7 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}\n  set utf8\n} $doubles\n\n# UTF-16\nifcapable {utf16} {\n  do_test $test.8 {\n    set utf8 [list]\n    foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}\n    set utf8\n  } $strings\n}\n\n# Integers\ndo_test $test.9 {\n  set ints [list]\n  foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}\n  set ints\n} $ints\n\n# Floats\ndo_test $test.10 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}\n  set utf8\n} $doubles\n\n# UTF-8\ndo_test $test.11 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}\n  set utf8\n} $strings\n\n# Types\ndo_test $test.12 {\n  set types [list]\n  foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}\n  set types\n} $types\n\n# Test that an out of range request returns the equivalent of NULL\ndo_test $test.13 {\n  sqlite3_column_int $STMT -1\n} {0}\ndo_test $test.13 {\n  sqlite3_column_text $STMT -1\n} {}\n\n}\n\nifcapable !floatingpoint {\n  finish_test\n  return\n}\n\ndo_test capi3-5.0 {\n  execsql {\n    CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES('one', 'two', NULL);\n    INSERT INTO t1 VALUES(1.2, 1.3, 1.4);\n  }\n  set sql \"SELECT * FROM t1\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_column_count $STMT\n} 3\n\ncheck_header $STMT capi3-5.1 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3-5.1 {main main main} {t1 t1 t1} {a b c}\ndo_test capi3-5.2 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3-5.3 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3-5.3 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}\n\ndo_test capi3-5.5 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3-5.6 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3-5.6 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}\n\ndo_test capi3-5.8 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3-5.9 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3-5.9 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}\n\ndo_test capi3-5.11 {\n  sqlite3_step $STMT\n} SQLITE_DONE\n\ndo_test capi3-5.12 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\ndo_test capi3-5.20 {\n  set sql \"SELECT a, sum(b), max(c) FROM t1 GROUP BY a\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_column_count $STMT\n} 3\n\ncheck_header $STMT capi3-5.21 {a sum(b) max(c)} {VARINT {} {}}\ncheck_origin_header $STMT capi3-5.22 {main {} {}} {t1 {} {}} {a {} {}}\ndo_test capi3-5.23 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\ndo_test capi3-5.30 {\n  set sql \"SELECT a AS x, sum(b) AS y, max(c) AS z FROM t1 AS m GROUP BY x\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_column_count $STMT\n} 3\n\ncheck_header $STMT capi3-5.31 {x y z} {VARINT {} {}}\ncheck_origin_header $STMT capi3-5.32 {main {} {}} {t1 {} {}} {a {} {}}\ndo_test capi3-5.33 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\n\nset ::ENC [execsql {pragma encoding}]\ndb close\n\ndo_test capi3-6.0 {\n  sqlite3 db test.db\n  set DB [sqlite3_connection_pointer db]\n  if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }\n  set sql {SELECT a FROM t1 order by rowid}\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  expr 0\n} {0}\ndo_test capi3-6.1 {\n  db cache flush\n  sqlite3_close $DB\n} {SQLITE_BUSY}\n\n# 6.2 and 6.3 used to return SQLITE_ERROR and SQLITE_SCHEMA, respectively.\n# But since attempting to close a connection no longer resets the internal\n# schema and expires all statements, this is no longer the case.\ndo_test capi3-6.2 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\n#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1}\ndo_test capi3-6.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\nif {[clang_sanitize_address]==0} {\n  do_test capi3-6.4-misuse {\n    db cache flush\n    sqlite3_close $DB\n  } {SQLITE_OK}\n}\ndb close\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\nif {![sqlite3 -has-codec]} {\n  # Test what happens when the library encounters a newer file format.\n  do_test capi3-7.1 {\n    set_file_format 5\n  } {}\n  do_test capi3-7.2 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {unsupported file format}}\n  db close\n}\n\nif {![sqlite3 -has-codec]} {\n  # Now test that the library correctly handles bogus entries in the\n  # sqlite_master table (schema corruption).\n  do_test capi3-8.1 {\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(a);\n    }\n    db close\n  } {}\n  do_test capi3-8.2 {\n    sqlite3 db test.db\n    execsql {\n      PRAGMA writable_schema=ON;\n      INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);\n    }\n    db close\n  } {}\n  do_test capi3-8.3 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {malformed database schema (?)}}\n  do_test capi3-8.4 {\n    # Build a 5-field row record. The first field is a string 'table', and\n    # subsequent fields are all NULL.\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(a);\n      PRAGMA writable_schema=ON;\n      INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);\n    }\n    db close\n  } {};\n  do_test capi3-8.5 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {malformed database schema (?)}}\n  db close\n}\nforcedelete test.db\nforcedelete test.db-journal\n\n\n# Test the english language string equivalents for sqlite error codes\nset code2english [list \\\nSQLITE_OK         {not an error} \\\nSQLITE_ERROR      {SQL logic error} \\\nSQLITE_PERM       {access permission denied} \\\nSQLITE_ABORT      {query aborted} \\\nSQLITE_BUSY       {database is locked} \\\nSQLITE_LOCKED     {database table is locked} \\\nSQLITE_NOMEM      {out of memory} \\\nSQLITE_READONLY   {attempt to write a readonly database} \\\nSQLITE_INTERRUPT  {interrupted} \\\nSQLITE_IOERR      {disk I/O error} \\\nSQLITE_CORRUPT    {database disk image is malformed} \\\nSQLITE_FULL       {database or disk is full} \\\nSQLITE_CANTOPEN   {unable to open database file} \\\nSQLITE_SCHEMA     {database schema has changed} \\\nSQLITE_CONSTRAINT {constraint failed} \\\nSQLITE_MISMATCH   {datatype mismatch} \\\nSQLITE_MISUSE     {bad parameter or other API misuse} \\\nSQLITE_AUTH       {authorization denied} \\\nSQLITE_RANGE      {column index out of range} \\\nSQLITE_NOTADB     {file is not a database} \\\nunknownerror      {unknown error} \\\n]\n\nset test_number 1\nforeach {code english} $code2english {\n  do_test capi3-9.$test_number \"sqlite3_test_errstr $code\" $english\n  incr test_number\n}\n\n# Test the error message when a \"real\" out of memory occurs.\nif { [permutation] != \"nofaultsim\" } {\nifcapable memdebug {\n  do_test capi3-10-1 {\n    sqlite3 db test.db\n    set DB [sqlite3_connection_pointer db]\n    sqlite3_memdebug_fail 1\n    catchsql {\n      select * from sqlite_master;\n    }\n  } {1 {out of memory}}\n  do_test capi3-10-2 {\n    sqlite3_errmsg $::DB\n  } {out of memory}\n  ifcapable {utf16} {\n    do_test capi3-10-3 {\n      utf8 [sqlite3_errmsg16 $::DB]\n    } {out of memory}\n  }\n  db close\n  sqlite3_memdebug_fail -1\n  do_test capi3-10-4 {\n    sqlite3 db test.db\n    set DB [sqlite3_connection_pointer db]\n    sqlite3_memdebug_fail 1\n    catchsql {\n      select * from sqlite_master where rowid>5;\n    }\n  } {1 {out of memory}}\n  do_test capi3-10-5 {\n    sqlite3_errmsg $::DB\n  } {out of memory}\n  ifcapable {utf16} {\n    do_test capi3-10-6 {\n      utf8 [sqlite3_errmsg16 $::DB]\n    } {out of memory}\n  }\n  db close\n  sqlite3_memdebug_fail -1\n}\n}\n\n# The following tests - capi3-11.* - test that a COMMIT or ROLLBACK\n# statement issued while there are still outstanding VMs that are part of\n# the transaction fails.\nsqlite3 db test.db\nset DB [sqlite3_connection_pointer db]\nsqlite_register_test_function $DB func\ndo_test capi3-11.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 'int');\n    INSERT INTO t1 VALUES(2, 'notatype');\n  }\n} {}\ndo_test capi3-11.1.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3-11.2 {\n  set STMT [sqlite3_prepare $DB \"SELECT func(b, a) FROM t1\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\n\n# As of 3.6.5 a COMMIT is OK during while a query is still running -\n# as long as it is a read-only query and not an incremental BLOB write.\n#\ndo_test capi3-11.3.1 {\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3-11.3.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_OK}\ndo_test capi3-11.3.3 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.3.4 {\n  db eval {PRAGMA lock_status}\n} {main shared temp closed}\n\ndo_test capi3-11.4 {\n  sqlite3_step $STMT\n} {SQLITE_ERROR}\ndo_test capi3-11.5 {\n  sqlite3_finalize $STMT\n} {SQLITE_ERROR}\ndo_test capi3-11.6 {\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {0 {1 int 2 notatype}}\ndo_test capi3-11.7 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.8 {\n  execsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    BEGIN;\n    INSERT INTO t2 VALUES(3);\n  }\n} {}\ndo_test capi3-11.8.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3-11.9 {\n  set STMT [sqlite3_prepare $DB \"SELECT a FROM t2\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-11.9.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3-11.9.2 {\n  catchsql {\n    ROLLBACK;\n  }\n} {0 {}}\ndo_test capi3-11.9.3 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.10 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-11.11 {\n  sqlite3_step $STMT\n} {SQLITE_DONE}\nifcapable !autoreset {\n  do_test capi3-11.12armor {\n    sqlite3_step $STMT\n    sqlite3_step $STMT\n  } {SQLITE_MISUSE}\n} else {\n  do_test capi3-11.12 {\n    sqlite3_step $STMT\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n}\ndo_test capi3-11.13 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\ndo_test capi3-11.14 {\n  execsql {\n    SELECT a FROM t2;\n  }\n} {1 2}\ndo_test capi3-11.14.1 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.15 {\n  catchsql {\n    ROLLBACK;\n  }\n} {1 {cannot rollback - no transaction is active}}\ndo_test capi3-11.15.1 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.16 {\n  execsql {\n    SELECT a FROM t2;\n  }\n} {1 2}\n\n# Sanity check on the definition of 'outstanding VM'. This means any VM\n# that has had sqlite3_step() called more recently than sqlite3_finalize() or\n# sqlite3_reset(). So a VM that has just been prepared or reset does not\n# count as an active VM.\ndo_test capi3-11.17 {\n  execsql {\n    BEGIN;\n  }\n} {}\ndo_test capi3-11.18 {\n  set STMT [sqlite3_prepare $DB \"SELECT a FROM t1\" -1 TAIL]\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3-11.19 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-11.20 {\n  catchsql {\n    BEGIN;\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3-11.20 {\n  sqlite3_reset $STMT\n  catchsql {\n    COMMIT;\n  }\n} {1 {cannot commit - no transaction is active}}\ndo_test capi3-11.21 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\n# The following tests - capi3-12.* - check that its Ok to start a\n# transaction while other VMs are active, and that its Ok to execute\n# atomic updates in the same situation \n#\ndo_test capi3-12.1 {\n  set STMT [sqlite3_prepare $DB \"SELECT a FROM t2\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-12.2 {\n  catchsql {\n    INSERT INTO t1 VALUES(3, NULL);\n  }\n} {0 {}}\ndo_test capi3-12.3 {\n  catchsql {\n    INSERT INTO t2 VALUES(4);\n  }\n} {0 {}}\ndo_test capi3-12.4 {\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(4, NULL);\n  }\n} {0 {}}\ndo_test capi3-12.5 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-12.5.1 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3-12.6 {\n  sqlite3_step $STMT\n} {SQLITE_DONE}\ndo_test capi3-12.7 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\ndo_test capi3-12.8 {\n  execsql {\n    COMMIT;\n    SELECT a FROM t1;\n  }\n} {1 2 3 4}\n\n# Test cases capi3-13.* test the sqlite3_clear_bindings() and \n# sqlite3_sleep APIs.\n#\nif {[llength [info commands sqlite3_clear_bindings]]>0} {\n  do_test capi3-13.1 {\n    execsql {\n      DELETE FROM t1;\n    }\n    set STMT [sqlite3_prepare $DB \"INSERT INTO t1 VALUES(?, ?)\" -1 TAIL]\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3-13.2 {\n    sqlite3_reset $STMT\n    sqlite3_bind_text $STMT 1 hello 5\n    sqlite3_bind_text $STMT 2 world 5\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3-13.3 {\n    sqlite3_reset $STMT\n    sqlite3_clear_bindings $STMT\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3-13-4 {\n    sqlite3_finalize $STMT\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {{} {} hello world {} {}}\n}\nif {[llength [info commands sqlite3_sleep]]>0} {\n  do_test capi3-13-5 {\n    set ms [sqlite3_sleep 80]\n    expr {$ms==80 || $ms==1000}\n  } {1}\n}\n\n# Ticket #1219:  Make sure binding APIs can handle a NULL pointer.\n# \nif {[clang_sanitize_address]==0} {\n  do_test capi3-14.1-misuse {\n    set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]\n      lappend rc $msg\n  } {1 SQLITE_MISUSE}\n}\n\n# Ticket #1650:  Honor the nBytes parameter to sqlite3_prepare.\n#\ndo_test capi3-15.1 {\n  set sql {SELECT * FROM t2}\n  set nbytes [string length $sql]\n  append sql { WHERE a==1}\n  set STMT [sqlite3_prepare $DB $sql $nbytes TAIL]\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {1}\ndo_test capi3-15.2 {\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {2}\ndo_test capi3-15.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\ndo_test capi3-15.4 {\n  #        123456789 1234567\n  set sql {SELECT 1234567890}\n  set STMT [sqlite3_prepare $DB $sql 8 TAIL]\n  sqlite3_step $STMT\n  set v1 [sqlite3_column_int $STMT 0]\n  sqlite3_finalize $STMT\n  set v1\n} {1}\ndo_test capi3-15.5 {\n  #        123456789 1234567\n  set sql {SELECT 1234567890}\n  set STMT [sqlite3_prepare $DB $sql 9 TAIL]\n  sqlite3_step $STMT\n  set v1 [sqlite3_column_int $STMT 0]\n  sqlite3_finalize $STMT\n  set v1\n} {12}\ndo_test capi3-15.6 {\n  #        123456789 1234567\n  set sql {SELECT 1234567890}\n  set STMT [sqlite3_prepare $DB $sql 12 TAIL]\n  sqlite3_step $STMT\n  set v1 [sqlite3_column_int $STMT 0]\n  sqlite3_finalize $STMT\n  set v1\n} {12345}\ndo_test capi3-15.7 {\n  #        123456789 1234567\n  set sql {SELECT 12.34567890}\n  set STMT [sqlite3_prepare $DB $sql 12 TAIL]\n  sqlite3_step $STMT\n  set v1 [sqlite3_column_double $STMT 0]\n  sqlite3_finalize $STMT\n  set v1\n} {12.34}\ndo_test capi3-15.8 {\n  #        123456789 1234567\n  set sql {SELECT 12.34567890}\n  set STMT [sqlite3_prepare $DB $sql 14 TAIL]\n  sqlite3_step $STMT\n  set v1 [sqlite3_column_double $STMT 0]\n  sqlite3_finalize $STMT\n  set v1\n} {12.3456}\n\n# Make sure code is always generated even if an IF EXISTS or \n# IF NOT EXISTS clause is present that the table does not or\n# does exists.  That way we will always have a prepared statement\n# to expire when the schema changes.\n#\ndo_test capi3-16.1 {\n  set sql {DROP TABLE IF EXISTS t3}\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT!=\"\"}\n} {1}\ndo_test capi3-16.2 {\n  set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT!=\"\"}\n} {1}\n\n# But still we do not generate code if there is no SQL\n#\ndo_test capi3-16.3 {\n  set STMT [sqlite3_prepare $DB {} -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT==\"\"}\n} {1}\ndo_test capi3-16.4 {\n  set STMT [sqlite3_prepare $DB {;} -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT==\"\"}\n} {1}\n\n# Ticket #2426:  Misuse of sqlite3_column_* by calling it after\n# a sqlite3_reset should be harmless.\n#\ndo_test capi3-17.1 {\n  set STMT [sqlite3_prepare $DB {SELECT * FROM t2} -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {1}\ndo_test capi3-17.2 {\n  sqlite3_reset $STMT\n  sqlite3_column_int $STMT 0\n} {0}\ndo_test capi3-17.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\n# Verify that sqlite3_step() fails with an SQLITE_SCHEMA error\n# when the statement is prepared with sqlite3_prepare() (not\n# sqlite3_prepare_v2()) and the schema has changed.\n#\ndo_test capi3-18.1 {\n  set STMT [sqlite3_prepare db {SELECT * FROM t2} -1 TAIL]\n  sqlite3 db2 test.db\n  db2 eval {CREATE TABLE t3(x)}\n  db2 close\n  sqlite3_step $STMT\n} {SQLITE_ERROR}\ndo_test capi3-18.2 {\n  sqlite3_reset $STMT\n  sqlite3_errcode db\n} {SQLITE_SCHEMA}\ndo_test capi3-18.3 {\n  sqlite3_errmsg db\n} {database schema has changed}\n# The error persist on retry when sqlite3_prepare() has been used.\ndo_test capi3-18.4 {\n  sqlite3_step $STMT\n} {SQLITE_ERROR}\ndo_test capi3-18.5 {\n  sqlite3_reset $STMT\n  sqlite3_errcode db\n} {SQLITE_SCHEMA}\ndo_test capi3-18.6 {\n  sqlite3_errmsg db\n} {database schema has changed}\nsqlite3_finalize $STMT\n\n# Ticket #3134.  Prepare a statement with an nBytes parameter of 0.\n# Make sure this works correctly and does not reference memory out of\n# range.\n#\ndo_test capi3-19.1 {\n  sqlite3_prepare_tkt3134 db\n} {}\n\n# Test that calling sqlite3_column_blob() on a TEXT value does not change\n# the return type of subsequent calls to sqlite3_column_type().\n#\ndo_execsql_test 20.1 {\n  CREATE TABLE t4(x);\n  INSERT INTO t4 VALUES('abcdefghij');\n}\ndo_test 20.2 {\n  set stmt [sqlite3_prepare db \"SELECT * FROM t4\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_ROW}\ndo_test 20.3 { sqlite3_column_type $stmt 0 } {TEXT}\ndo_test 20.4 { sqlite3_column_blob $stmt 0 } {abcdefghij}\ndo_test 20.5 { sqlite3_column_type $stmt 0 } {TEXT}\ndo_test 20.6 { sqlite3_finalize $stmt } SQLITE_OK\n\n\n# Tests of the interface when no VFS is registered.\n#\nif {![info exists tester_do_binarylog]} {\n  db close\n  vfs_unregister_all\n  do_test capi3-20.1 {\n    sqlite3_sleep 100\n  } {0}\n  vfs_reregister_all\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi3b.test",
    "content": "# 2004 September 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the callback-free C/C++ API and in\n# particular the behavior of sqlite3_step() when trying to commit\n# with lock contention.\n#\n# $Id: capi3b.test,v 1.4 2007/08/10 19:46:14 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# These tests depend on the pager holding changes in cache\n# until it is time to commit.  But that won't happen if the\n# soft-heap-limit is set too low.  So disable the soft heap limit\n# for the duration of this test.\n#\nsqlite3_soft_heap_limit 0\n\n\nset DB [sqlite3_connection_pointer db]\nsqlite3 db2 test.db\nset DB2 [sqlite3_connection_pointer db2]\n\n# Create some data in the database\n#\ndo_test capi3b-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    SELECT * FROM t1\n  }\n} {1 2}\n\n# Make sure the second database connection can see the data\n#\ndo_test capi3b-1.2 {\n  execsql {\n    SELECT * FROM t1\n  } db2\n} {1 2}\n\n# First database connection acquires a shared lock\n#\ndo_test capi3b-1.3 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  }\n} {1 2}\n\n# Second database connection tries to write.  The sqlite3_step()\n# function returns SQLITE_BUSY because it cannot commit.\n#\ndo_test capi3b-1.4 {\n  set VM [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(3)} -1 TAIL]\n  sqlite3_step $VM\n} SQLITE_BUSY\n\n# The sqlite3_step call can be repeated multiple times.\n#\ndo_test capi3b-1.5.1 {\n  sqlite3_step $VM\n} SQLITE_BUSY\ndo_test capi3b-1.5.2 {\n  sqlite3_step $VM\n} SQLITE_BUSY\n\n# The first connection closes its transaction.  This allows the second\n# connections sqlite3_step to succeed.\n#\ndo_test capi3b-1.6 {\n  execsql COMMIT\n  sqlite3_step $VM\n} SQLITE_DONE\ndo_test capi3b-1.7 {\n  sqlite3_finalize $VM\n} SQLITE_OK\ndo_test capi3b-1.8 {\n  execsql {SELECT * FROM t1} db2\n} {1 2 3}\ndo_test capi3b-1.9 {\n  execsql {SELECT * FROM t1}\n} {1 2 3}\n\n# Start doing a SELECT with one connection.  This gets a SHARED lock.\n# Then do an INSERT with the other connection.  The INSERT should\n# not be able to complete until the SELECT finishes.\n#\ndo_test capi3b-2.1 {\n  set VM1 [sqlite3_prepare $DB {SELECT * FROM t1} -1 TAIL]\n  sqlite3_step $VM1\n} SQLITE_ROW\ndo_test capi3b-2.2 {\n  sqlite3_column_text $VM1 0\n} 1\ndo_test capi3b-2.3 {\n  set VM2 [sqlite3_prepare $DB2 {INSERT INTO t1 VALUES(4)} -1 TAIL]\n  sqlite3_step $VM2\n} SQLITE_BUSY\ndo_test capi3b-2.4 {\n  sqlite3_step $VM1\n} SQLITE_ROW\ndo_test capi3b-2.5 {\n  sqlite3_column_text $VM1 0\n} 2\ndo_test capi3b-2.6 {\n  sqlite3_step $VM2\n} SQLITE_BUSY\ndo_test capi3b-2.7 {\n  sqlite3_step $VM1\n} SQLITE_ROW\ndo_test capi3b-2.8 {\n  sqlite3_column_text $VM1 0\n} 3\ndo_test capi3b-2.9 {\n  sqlite3_step $VM2\n} SQLITE_BUSY\ndo_test capi3b-2.10 {\n  sqlite3_step $VM1\n} SQLITE_DONE\ndo_test capi3b-2.11 {\n  sqlite3_step $VM2\n} SQLITE_DONE\ndo_test capi3b-2.12 {\n  sqlite3_finalize $VM1\n  sqlite3_finalize $VM2\n  execsql {SELECT * FROM t1}\n} {1 2 3 4}\n\ncatch {db2 close}\n\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi3c.test",
    "content": "# 2006 November 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  \n#\n# This is a copy of the capi3.test file that has been adapted to\n# test the new sqlite3_prepare_v2 interface.\n#\n# $Id: capi3c.test,v 1.23 2009/07/22 07:27:57 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix capi3c\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\n# Return the UTF-8 representation of the supplied UTF-16 string $str. \nproc utf8 {str} {\n  # If $str ends in two 0x00 0x00 bytes, knock these off before\n  # converting to UTF-8 using TCL.\n  binary scan $str \\c* vals\n  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {\n    set str [binary format \\c* [lrange $vals 0 end-2]]\n  }\n\n  set r [encoding convertfrom unicode $str]\n  return $r\n}\n\n# These tests complement those in capi2.test. They are organized\n# as follows:\n#\n# capi3c-1.*: Test sqlite3_prepare_v2 \n# capi3c-2.*: Test sqlite3_prepare16_v2 \n# capi3c-3.*: Test sqlite3_open\n# capi3c-4.*: Test sqlite3_open16\n# capi3c-5.*: Test the various sqlite3_result_* APIs\n# capi3c-6.*: Test that sqlite3_close fails if there are outstanding VMs.\n#\n\nset DB [sqlite3_connection_pointer db]\n\ndo_test capi3c-1.0 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3c-1.1 {\n  set STMT [sqlite3_prepare_v2 $DB {SELECT name FROM sqlite_master} -1 TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {}\ndo_test capi3c-1.2.1 {\n  sqlite3_errcode $DB\n} {SQLITE_OK}\ndo_test capi3c-1.2.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_OK}\ndo_test capi3c-1.3 {\n  sqlite3_errmsg $DB\n} {not an error}\ndo_test capi3c-1.4 {\n  set sql {SELECT name FROM sqlite_master;SELECT 10}\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  set TAIL\n} {SELECT 10}\ndo_test capi3c-1.5 {\n  set sql {SELECT namex FROM sqlite_master}\n  catch {\n    set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  }\n} {1}\ndo_test capi3c-1.6.1 {\n  sqlite3_errcode $DB\n} {SQLITE_ERROR}\ndo_test capi3c-1.6.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_ERROR}\ndo_test capi3c-1.7 {\n  sqlite3_errmsg $DB\n} {no such column: namex}\n\n\nifcapable {utf16} {\n  do_test capi3c-2.1 {\n    set sql16 [utf16 {SELECT name FROM sqlite_master}]\n    set STMT [sqlite3_prepare16_v2  $DB $sql16 -1 ::TAIL]\n    sqlite3_finalize $STMT\n    utf8 $::TAIL\n  } {}\n  do_test capi3c-2.2 {\n    set sql [utf16 {SELECT name FROM sqlite_master;SELECT 10}]\n    set STMT [sqlite3_prepare16_v2  $DB $sql -1 TAIL]\n    sqlite3_finalize $STMT\n    utf8 $TAIL\n  } {SELECT 10}\n  do_test capi3c-2.3 {\n    set sql [utf16 {SELECT namex FROM sqlite_master}]\n    catch {\n      set STMT [sqlite3_prepare16_v2  $DB $sql -1 TAIL]\n    }\n  } {1}\n  do_test capi3c-2.4.1 {\n    sqlite3_errcode $DB\n  } {SQLITE_ERROR}\n  do_test capi3c-2.4.2 {\n    sqlite3_extended_errcode $DB\n  } {SQLITE_ERROR}\n  do_test capi3c-2.5 {\n    sqlite3_errmsg $DB\n  } {no such column: namex}\n\n  ifcapable schema_pragmas {\n    do_test capi3c-2.6 {\n      execsql {CREATE TABLE tablename(x)}\n      set sql16 [utf16 {PRAGMA table_info(\"TableName\")}]\n      set STMT [sqlite3_prepare16_v2  $DB $sql16 -1 TAIL]\n      sqlite3_step $STMT\n    } SQLITE_ROW\n    do_test capi3c-2.7 {\n      sqlite3_step $STMT\n    } SQLITE_DONE\n    do_test capi3c-2.8 {\n      sqlite3_finalize $STMT\n    } SQLITE_OK\n  }\n\n} ;# endif utf16\n\n# rename sqlite3_open sqlite3_open_old\n# proc sqlite3_open {fname options} {sqlite3_open_new $fname $options}\n\ndo_test capi3c-3.1 {\n  set db2 [sqlite3_open test.db {}]\n  sqlite3_errcode $db2\n} {SQLITE_OK}\n# FIX ME: Should test the db handle works.\ndo_test capi3c-3.2 {\n  sqlite3_close $db2\n} {SQLITE_OK}\ndo_test capi3c-3.3 {\n  catch {\n    set db2 [sqlite3_open /bogus/path/test.db {}]\n  }\n  sqlite3_errcode $db2\n} {SQLITE_CANTOPEN}\ndo_test capi3c-3.4 {\n  sqlite3_errmsg $db2\n} {unable to open database file}\ndo_test capi3c-3.5 {\n  sqlite3_close $db2\n} {SQLITE_OK}\nif {[clang_sanitize_address]==0} {\n  do_test capi3c-3.6.1-misuse {\n    sqlite3_close $db2\n  } {SQLITE_MISUSE}\n  do_test capi3c-3.6.2-misuse {\n    sqlite3_errmsg $db2\n  } {bad parameter or other API misuse}\n  ifcapable {utf16} {\n    do_test capi3c-3.6.3-misuse {\n      utf8 [sqlite3_errmsg16 $db2]\n    } {bad parameter or other API misuse}\n  }\n}\n\n# rename sqlite3_open \"\"\n# rename sqlite3_open_old sqlite3_open\n\nifcapable {utf16} {\ndo_test capi3c-4.1 {\n  set db2 [sqlite3_open16 [utf16 test.db] {}]\n  sqlite3_errcode $db2\n} {SQLITE_OK}\n# FIX ME: Should test the db handle works.\ndo_test capi3c-4.2 {\n  sqlite3_close $db2\n} {SQLITE_OK}\ndo_test capi3c-4.3 {\n  catch {\n    set db2 [sqlite3_open16 [utf16 /bogus/path/test.db] {}]\n  }\n  sqlite3_errcode $db2\n} {SQLITE_CANTOPEN}\ndo_test capi3c-4.4 {\n  utf8 [sqlite3_errmsg16 $db2]\n} {unable to open database file}\ndo_test capi3c-4.5 {\n  sqlite3_close $db2\n} {SQLITE_OK}\n} ;# utf16\n\n# This proc is used to test the following API calls:\n#\n# sqlite3_column_count\n# sqlite3_column_name\n# sqlite3_column_name16\n# sqlite3_column_decltype\n# sqlite3_column_decltype16\n#\n# $STMT is a compiled SQL statement. $test is a prefix\n# to use for test names within this proc. $names is a list\n# of the column names that should be returned by $STMT.\n# $decltypes is a list of column declaration types for $STMT.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare_v2 \"SELECT 1, 2, 2;\" -1 DUMMY]\n# check_header test1.1 {1 2 3} {\"\" \"\" \"\"}\n#\nproc check_header {STMT test names decltypes} {\n\n  # Use the return value of sqlite3_column_count() to build\n  # a list of column indexes. i.e. If sqlite3_column_count\n  # is 3, build the list {0 1 2}.\n  set ::idxlist [list]\n  set ::numcols [sqlite3_column_count $STMT]\n  for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}\n\n  # Column names in UTF-8\n  do_test $test.1 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} \n    set cnamelist\n  } $names\n\n  # Column names in UTF-16\n  ifcapable {utf16} {\n    do_test $test.2 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]\n      }\n      set cnamelist\n    } $names\n  }\n\n  # Column names in UTF-8\n  do_test $test.3 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_name $STMT $i]} \n    set cnamelist\n  } $names\n\n  # Column names in UTF-16\n  ifcapable {utf16} {\n    do_test $test.4 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_name16 $STMT $i]]\n      }\n      set cnamelist\n    } $names\n  }\n\n  # Column names in UTF-8\n  do_test $test.5 {\n    set cnamelist [list]\n    foreach i $idxlist {lappend cnamelist [sqlite3_column_decltype $STMT $i]} \n    set cnamelist\n  } $decltypes\n\n  # Column declaration types in UTF-16\n  ifcapable {utf16} {\n    do_test $test.6 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [utf8 [sqlite3_column_decltype16 $STMT $i]]\n      }\n      set cnamelist\n    } $decltypes\n  }\n\n\n  # Test some out of range conditions:\n  ifcapable {utf16} {\n    do_test $test.7 {\n      list \\\n        [sqlite3_column_name $STMT -1] \\\n        [sqlite3_column_name16 $STMT -1] \\\n        [sqlite3_column_decltype $STMT -1] \\\n        [sqlite3_column_decltype16 $STMT -1] \\\n        [sqlite3_column_name $STMT $numcols] \\\n        [sqlite3_column_name16 $STMT $numcols] \\\n        [sqlite3_column_decltype $STMT $numcols] \\\n        [sqlite3_column_decltype16 $STMT $numcols]\n    } {{} {} {} {} {} {} {} {}}\n  }\n} \n\n# This proc is used to test the following API calls:\n#\n# sqlite3_column_origin_name\n# sqlite3_column_origin_name16\n# sqlite3_column_table_name\n# sqlite3_column_table_name16\n# sqlite3_column_database_name\n# sqlite3_column_database_name16\n#\n# $STMT is a compiled SQL statement. $test is a prefix\n# to use for test names within this proc. $names is a list\n# of the column names that should be returned by $STMT.\n# $decltypes is a list of column declaration types for $STMT.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare_v2 \"SELECT 1, 2, 2;\" -1 DUMMY]\n# check_header test1.1 {1 2 3} {\"\" \"\" \"\"}\n#\nproc check_origin_header {STMT test dbs tables cols} {\n  # If sqlite3_column_origin_name() and friends are not compiled into\n  # this build, this proc is a no-op.\nifcapable columnmetadata {\n\n    # Use the return value of sqlite3_column_count() to build\n    # a list of column indexes. i.e. If sqlite3_column_count\n    # is 3, build the list {0 1 2}.\n    set ::idxlist [list]\n    set ::numcols [sqlite3_column_count $STMT]\n    for {set i 0} {$i < $::numcols} {incr i} {lappend ::idxlist $i}\n  \n    # Database names in UTF-8\n    do_test $test.8 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_database_name $STMT $i]\n      } \n      set cnamelist\n    } $dbs\n  \n    # Database names in UTF-16\n    ifcapable {utf16} {\n      do_test $test.9 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_database_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $dbs\n    }\n  \n    # Table names in UTF-8\n    do_test $test.10 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_table_name $STMT $i]\n      } \n      set cnamelist\n    } $tables\n  \n    # Table names in UTF-16\n    ifcapable {utf16} {\n      do_test $test.11 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_table_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $tables\n    }\n  \n    # Origin names in UTF-8\n    do_test $test.12 {\n      set cnamelist [list]\n      foreach i $idxlist {\n        lappend cnamelist [sqlite3_column_origin_name $STMT $i]\n      } \n      set cnamelist\n    } $cols\n  \n    # Origin declaration types in UTF-16\n    ifcapable {utf16} {\n      do_test $test.13 {\n        set cnamelist [list]\n        foreach i $idxlist {\n          lappend cnamelist [utf8 [sqlite3_column_origin_name16 $STMT $i]]\n        }\n        set cnamelist\n      } $cols\n    }\n  }\n}\n\n# This proc is used to test the following APIs:\n#\n# sqlite3_data_count\n# sqlite3_column_type\n# sqlite3_column_int\n# sqlite3_column_text\n# sqlite3_column_text16\n# sqlite3_column_double\n#\n# $STMT is a compiled SQL statement for which the previous call \n# to sqlite3_step returned SQLITE_ROW. $test is a prefix to use \n# for test names within this proc. $types is a list of the \n# manifest types for the current row. $ints, $doubles and $strings\n# are lists of the integer, real and string representations of\n# the values in the current row.\n#\n# Example:\n#\n# set STMT [sqlite3_prepare_v2 \"SELECT 'hello', 1.1, NULL\" -1 DUMMY]\n# sqlite3_step $STMT\n# check_data test1.2 {TEXT REAL NULL} {0 1 0} {0 1.1 0} {hello 1.1 {}}\n#\nproc check_data {STMT test types ints doubles strings} {\n\n  # Use the return value of sqlite3_column_count() to build\n  # a list of column indexes. i.e. If sqlite3_column_count\n  # is 3, build the list {0 1 2}.\n  set ::idxlist [list]\n  set numcols [sqlite3_data_count $STMT]\n  for {set i 0} {$i < $numcols} {incr i} {lappend ::idxlist $i}\n\n# types\ndo_test $test.1 {\n  set types [list]\n  foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}\n  set types\n} $types\n\n# Integers\ndo_test $test.2 {\n  set ints [list]\n  foreach i $idxlist {lappend ints [sqlite3_column_int64 $STMT $i]}\n  set ints\n} $ints\n\n# bytes\nset lens [list]\nforeach i $::idxlist {\n  lappend lens [string length [lindex $strings $i]]\n}\ndo_test $test.3 {\n  set bytes [list]\n  set lens [list]\n  foreach i $idxlist {\n    lappend bytes [sqlite3_column_bytes $STMT $i]\n  }\n  set bytes\n} $lens\n\n# bytes16\nifcapable {utf16} {\n  set lens [list]\n  foreach i $::idxlist {\n    lappend lens [expr 2 * [string length [lindex $strings $i]]]\n  }\n  do_test $test.4 {\n    set bytes [list]\n    set lens [list]\n    foreach i $idxlist {\n      lappend bytes [sqlite3_column_bytes16 $STMT $i]\n    }\n    set bytes\n  } $lens\n}\n\n# Blob\ndo_test $test.5 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}\n  set utf8\n} $strings\n\n# UTF-8\ndo_test $test.6 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}\n  set utf8\n} $strings\n\n# Floats\ndo_test $test.7 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}\n  set utf8\n} $doubles\n\n# UTF-16\nifcapable {utf16} {\n  do_test $test.8 {\n    set utf8 [list]\n    foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}\n    set utf8\n  } $strings\n}\n\n# Integers\ndo_test $test.9 {\n  set ints [list]\n  foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}\n  set ints\n} $ints\n\n# Floats\ndo_test $test.10 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}\n  set utf8\n} $doubles\n\n# UTF-8\ndo_test $test.11 {\n  set utf8 [list]\n  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}\n  set utf8\n} $strings\n\n# Types\ndo_test $test.12 {\n  set types [list]\n  foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}\n  set types\n} $types\n\n# Test that an out of range request returns the equivalent of NULL\ndo_test $test.13 {\n  sqlite3_column_int $STMT -1\n} {0}\ndo_test $test.13 {\n  sqlite3_column_text $STMT -1\n} {}\n\n}\n\nifcapable !floatingpoint {\n  finish_test\n  return\n}\n\ndo_test capi3c-5.0 {\n  execsql {\n    CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES('one', 'two', NULL);\n    INSERT INTO t1 VALUES(1.2, 1.3, 1.4);\n  }\n  set sql \"SELECT * FROM t1\"\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_column_count $STMT\n} 3\n\ncheck_header $STMT capi3c-5.1 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3c-5.1 {main main main} {t1 t1 t1} {a b c}\ndo_test capi3c-5.2 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3c-5.3 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3c-5.3 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3c-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}\n\ndo_test capi3c-5.5 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3c-5.6 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3c-5.6 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3c-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}\n\ndo_test capi3c-5.8 {\n  sqlite3_step $STMT\n} SQLITE_ROW\n\ncheck_header $STMT capi3c-5.9 {a b c} {VARINT BLOB VARCHAR(16)}\ncheck_origin_header $STMT capi3c-5.9 {main main main} {t1 t1 t1} {a b c}\ncheck_data $STMT capi3c-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}\n\ndo_test capi3c-5.11 {\n  sqlite3_step $STMT\n} SQLITE_DONE\n\ndo_test capi3c-5.12 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\ndo_test capi3c-5.20 {\n  set sql \"SELECT a, sum(b), max(c) FROM t1 GROUP BY a\"\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_column_count $STMT\n} 3\n\ncheck_header $STMT capi3c-5.21 {a sum(b) max(c)} {VARINT {} {}}\ncheck_origin_header $STMT capi3c-5.22 {main {} {}} {t1 {} {}} {a {} {}}\ndo_test capi3c-5.23 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\n\nset ::ENC [execsql {pragma encoding}]\ndb close\n\ndo_test capi3c-6.0 {\n  sqlite3 db test.db\n  set DB [sqlite3_connection_pointer db]\n  if {[sqlite3 -has-codec]==0} { sqlite3_key $DB xyzzy }\n  set sql {SELECT a FROM t1 order by rowid}\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  expr 0\n} {0}\ndo_test capi3c-6.1 {\n  db cache flush\n  sqlite3_close $DB\n} {SQLITE_BUSY}\ndo_test capi3c-6.2 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ncheck_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1}\ndo_test capi3c-6.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\nif {[clang_sanitize_address]==0} {\n  do_test capi3c-6.4 {\n    db cache flush\n      sqlite3_close $DB\n  } {SQLITE_OK}\n  do_test capi3c-6.99-misuse {\n    db close\n  } {}\n} else {\n  db close\n}\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\nif {![sqlite3 -has-codec]} {\n  # Test what happens when the library encounters a newer file format.\n  do_test capi3c-7.1 {\n    set_file_format 5\n  } {}\n  do_test capi3c-7.2 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {unsupported file format}}\n  db close\n}\n\nif {![sqlite3 -has-codec]} {\n  # Now test that the library correctly handles bogus entries in the\n  # sqlite_master table (schema corruption).\n  do_test capi3c-8.1 {\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(a);\n    }\n    db close\n  } {}\n  do_test capi3c-8.2 {\n    sqlite3 db test.db\n    execsql {\n      PRAGMA writable_schema=ON;\n      INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);\n    }\n    db close\n  } {}\n  do_test capi3c-8.3 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {malformed database schema (?)}}\n  do_test capi3c-8.4 {\n    # Build a 5-field row record. The first field is a string 'table', and\n    # subsequent fields are all NULL.\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(a);\n      PRAGMA writable_schema=ON;\n      INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);\n    }\n    db close\n  } {};\n  do_test capi3c-8.5 {\n    catch { sqlite3 db test.db }\n    catchsql {\n      SELECT * FROM sqlite_master;\n    }\n  } {1 {malformed database schema (?)}}\n  db close\n}\nforcedelete test.db\nforcedelete test.db-journal\n\n\n# Test the english language string equivalents for sqlite error codes\nset code2english [list \\\nSQLITE_OK         {not an error} \\\nSQLITE_ERROR      {SQL logic error} \\\nSQLITE_PERM       {access permission denied} \\\nSQLITE_ABORT      {query aborted} \\\nSQLITE_BUSY       {database is locked} \\\nSQLITE_LOCKED     {database table is locked} \\\nSQLITE_NOMEM      {out of memory} \\\nSQLITE_READONLY   {attempt to write a readonly database} \\\nSQLITE_INTERRUPT  {interrupted} \\\nSQLITE_IOERR      {disk I/O error} \\\nSQLITE_CORRUPT    {database disk image is malformed} \\\nSQLITE_FULL       {database or disk is full} \\\nSQLITE_CANTOPEN   {unable to open database file} \\\nSQLITE_EMPTY      {unknown error} \\\nSQLITE_SCHEMA     {database schema has changed} \\\nSQLITE_CONSTRAINT {constraint failed} \\\nSQLITE_MISMATCH   {datatype mismatch} \\\nSQLITE_MISUSE     {bad parameter or other API misuse} \\\nSQLITE_AUTH       {authorization denied} \\\nSQLITE_RANGE      {column index out of range} \\\nSQLITE_NOTADB     {file is not a database} \\\nunknownerror      {unknown error} \\\n]\n\nset test_number 1\nforeach {code english} $code2english {\n  do_test capi3c-9.$test_number \"sqlite3_test_errstr $code\" $english\n  incr test_number\n}\n\n# Test the error message when a \"real\" out of memory occurs.\nif { [permutation] != \"nofaultsim\" } {\nifcapable memdebug {\n  do_test capi3c-10-1 {\n    sqlite3 db test.db\n    set DB [sqlite3_connection_pointer db]\n    sqlite3_memdebug_fail 0\n    catchsql {\n      select * from sqlite_master;\n    }\n  } {1 {out of memory}}\n  do_test capi3c-10-2 {\n    sqlite3_errmsg $::DB\n  } {out of memory}\n  ifcapable {utf16} {\n    do_test capi3c-10-3 {\n      utf8 [sqlite3_errmsg16 $::DB]\n    } {out of memory}\n  }\n  db close\n  sqlite3_memdebug_fail -1\n}\n}\n\n# The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK\n# statement issued while there are still outstanding VMs that are part of\n# the transaction fails.\nsqlite3 db test.db\nset DB [sqlite3_connection_pointer db]\nsqlite_register_test_function $DB func\ndo_test capi3c-11.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 'int');\n    INSERT INTO t1 VALUES(2, 'notatype');\n  }\n} {}\ndo_test capi3c-11.1.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3c-11.2 {\n  set STMT [sqlite3_prepare_v2 $DB \"SELECT func(b, a) FROM t1\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\n\n# As of 3.6.5 a COMMIT is OK during while a query is still running -\n# as long as it is a read-only query and not an incremental BLOB write.\n#\ndo_test capi3-11.3.1 {\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3-11.3.2 {\n  sqlite3_extended_errcode $DB\n} {SQLITE_OK}\ndo_test capi3-11.3.3 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3-11.3.4 {\n  db eval {PRAGMA lock_status}\n} {main shared temp closed}\n\ndo_test capi3c-11.4 {\n  sqlite3_step $STMT\n} {SQLITE_ERROR}\ndo_test capi3c-11.5 {\n  sqlite3_finalize $STMT\n} {SQLITE_ERROR}\ndo_test capi3c-11.6 {\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {0 {1 int 2 notatype}}\ndo_test capi3c-11.7 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3c-11.8 {\n  execsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    BEGIN;\n    INSERT INTO t2 VALUES(3);\n  }\n} {}\ndo_test capi3c-11.8.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3c-11.9 {\n  set STMT [sqlite3_prepare_v2 $DB \"SELECT a FROM t2\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-11.9.1 {\n  sqlite3_get_autocommit $DB\n} 0\ndo_test capi3c-11.9.2 {\n  catchsql {\n    ROLLBACK;\n  }\n} {0 {}}\ndo_test capi3c-11.9.3 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3c-11.10 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-11.11 {\n  sqlite3_step $STMT\n} {SQLITE_DONE}\nifcapable !autoreset {\n  do_test capi3c-11.12armor {\n    sqlite3_step $STMT\n    sqlite3_step $STMT\n  } {SQLITE_MISUSE}\n} else {\n  do_test capi3c-11.12 {\n    sqlite3_step $STMT\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n}\ndo_test capi3c-11.13 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\ndo_test capi3c-11.14 {\n  execsql {\n    SELECT a FROM t2;\n  }\n} {1 2}\ndo_test capi3c-11.14.1 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3c-11.15 {\n  catchsql {\n    ROLLBACK;\n  }\n} {1 {cannot rollback - no transaction is active}}\ndo_test capi3c-11.15.1 {\n  sqlite3_get_autocommit $DB\n} 1\ndo_test capi3c-11.16 {\n  execsql {\n    SELECT a FROM t2;\n  }\n} {1 2}\n\n# Sanity check on the definition of 'outstanding VM'. This means any VM\n# that has had sqlite3_step() called more recently than sqlite3_finalize() or\n# sqlite3_reset(). So a VM that has just been prepared or reset does not\n# count as an active VM.\ndo_test capi3c-11.17 {\n  execsql {\n    BEGIN;\n  }\n} {}\ndo_test capi3c-11.18 {\n  set STMT [sqlite3_prepare_v2 $DB \"SELECT a FROM t1\" -1 TAIL]\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3c-11.19 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-11.20 {\n  catchsql {\n    BEGIN;\n    COMMIT;\n  }\n} {0 {}}\ndo_test capi3c-11.20 {\n  sqlite3_reset $STMT\n  catchsql {\n    COMMIT;\n  }\n} {1 {cannot commit - no transaction is active}}\ndo_test capi3c-11.21 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\n# The following tests - capi3c-12.* - check that its Ok to start a\n# transaction while other VMs are active, and that its Ok to execute\n# atomic updates in the same situation \n#\ndo_test capi3c-12.1 {\n  set STMT [sqlite3_prepare_v2 $DB \"SELECT a FROM t2\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-12.2 {\n  catchsql {\n    INSERT INTO t1 VALUES(3, NULL);\n  }\n} {0 {}}\ndo_test capi3c-12.3 {\n  catchsql {\n    INSERT INTO t2 VALUES(4);\n  }\n} {0 {}}\ndo_test capi3c-12.4 {\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(4, NULL);\n  }\n} {0 {}}\ndo_test capi3c-12.5 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-12.5.1 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test capi3c-12.6 {\n  sqlite3_step $STMT\n} {SQLITE_DONE}\ndo_test capi3c-12.7 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\ndo_test capi3c-12.8 {\n  execsql {\n    COMMIT;\n    SELECT a FROM t1;\n  }\n} {1 2 3 4}\n\n# Test cases capi3c-13.* test the sqlite3_clear_bindings() and \n# sqlite3_sleep APIs.\n#\nif {[llength [info commands sqlite3_clear_bindings]]>0} {\n  do_test capi3c-13.1 {\n    execsql {\n      DELETE FROM t1;\n    }\n    set STMT [sqlite3_prepare_v2 $DB \"INSERT INTO t1 VALUES(?, ?)\" -1 TAIL]\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3c-13.2 {\n    sqlite3_reset $STMT\n    sqlite3_bind_text $STMT 1 hello 5\n    sqlite3_bind_text $STMT 2 world 5\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3c-13.3 {\n    sqlite3_reset $STMT\n    sqlite3_clear_bindings $STMT\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test capi3c-13-4 {\n    sqlite3_finalize $STMT\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {{} {} hello world {} {}}\n}\nif {[llength [info commands sqlite3_sleep]]>0} {\n  do_test capi3c-13-5 {\n    set ms [sqlite3_sleep 80]\n    expr {$ms==80 || $ms==1000}\n  } {1}\n}\n\n# Ticket #1219:  Make sure binding APIs can handle a NULL pointer.\n#\ndo_test capi3c-14.1 {\n  set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]\n  lappend rc $msg\n} {1 SQLITE_MISUSE}\n\n# Ticket #1650:  Honor the nBytes parameter to sqlite3_prepare.\n#\ndo_test capi3c-15.1 {\n  set sql {SELECT * FROM t2}\n  set nbytes [string length $sql]\n  append sql { WHERE a==1}\n  set STMT [sqlite3_prepare_v2 $DB $sql $nbytes TAIL]\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {1}\ndo_test capi3c-15.2 {\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {2}\ndo_test capi3c-15.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\n# Make sure code is always generated even if an IF EXISTS or \n# IF NOT EXISTS clause is present that the table does not or\n# does exists.  That way we will always have a prepared statement\n# to expire when the schema changes.\n#\ndo_test capi3c-16.1 {\n  set sql {DROP TABLE IF EXISTS t3}\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT!=\"\"}\n} {1}\ndo_test capi3c-16.2 {\n  set sql {CREATE TABLE IF NOT EXISTS t1(x,y)}\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT!=\"\"}\n} {1}\n\n# But still we do not generate code if there is no SQL\n#\ndo_test capi3c-16.3 {\n  set STMT [sqlite3_prepare_v2 $DB {} -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT==\"\"}\n} {1}\ndo_test capi3c-16.4 {\n  set STMT [sqlite3_prepare_v2 $DB {;} -1 TAIL]\n  sqlite3_finalize $STMT\n  expr {$STMT==\"\"}\n} {1}\n\n# Ticket #2154.\n#\ndo_test capi3c-17.1 {\n  set STMT [sqlite3_prepare_v2 $DB {SELECT max(a) FROM t2} -1 TAIL]\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.2 {\n  sqlite3_column_int $STMT 0\n} 4\ndo_test capi3c-17.3 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.4 {\n  sqlite3_reset $STMT\n  db eval {CREATE INDEX i2 ON t2(a)}\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.5 {\n  sqlite3_column_int $STMT 0\n} 4\ndo_test capi3c-17.6 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.7 {\n  sqlite3_reset $STMT\n  db eval {DROP INDEX i2}\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.8 {\n  sqlite3_column_int $STMT 0\n} 4\ndo_test capi3c-17.9 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.10 {\n  sqlite3_finalize $STMT\n  set STMT [sqlite3_prepare_v2 $DB {SELECT b FROM t1 WHERE a=?} -1 TAIL]\n  sqlite3_bind_int $STMT 1 2\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,'one');\n    INSERT INTO t1 VALUES(2,'two');\n    INSERT INTO t1 VALUES(3,'three');\n    INSERT INTO t1 VALUES(4,'four');\n  }\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.11 {\n  sqlite3_column_text $STMT 0\n} two\ndo_test capi3c-17.12 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.13 {\n  sqlite3_reset $STMT\n  db eval {CREATE INDEX i1 ON t1(a)}\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.14 {\n  sqlite3_column_text $STMT 0\n} two\ndo_test capi3c-17.15 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.16 {\n  sqlite3_reset $STMT\n  db eval {DROP INDEX i1}\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-17.17 {\n  sqlite3_column_text $STMT 0\n} two\ndo_test capi3c-17.18 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-17.99 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\n# On the mailing list it has been reported that finalizing after\n# an SQLITE_BUSY return leads to a segfault.  Here we test that case.\n#\ndo_test capi3c-18.1 {\n  sqlite3 db2 test.db\n  set STMT [sqlite3_prepare_v2 $DB {SELECT max(a) FROM t1} -1 TAIL]\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-18.2 {\n  sqlite3_column_int $STMT 0\n} 4\ndo_test capi3c-18.3 {\n  sqlite3_reset $STMT\n  db2 eval {BEGIN EXCLUSIVE}\n  sqlite3_step $STMT\n} SQLITE_BUSY\ndo_test capi3c-18.4 {\n  sqlite3_finalize $STMT\n} SQLITE_BUSY\ndo_test capi3c-18.5 {\n  db2 eval {COMMIT}\n  db2 close\n} {}\n\n# Ticket #2158.  The sqlite3_step() will still return SQLITE_SCHEMA\n# if the database schema changes in a way that makes the statement\n# no longer valid.\n#\ndo_test capi3c-19.1 {\n  db eval {\n     CREATE TABLE t3(x,y);\n     INSERT INTO t3 VALUES(1,2);\n  }\n  set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-19.2 {\n  sqlite3_column_int $STMT 0\n} 1\ndo_test capi3c-19.3 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-19.4 {\n  sqlite3_reset $STMT\n  db eval {DROP TABLE t3}\n  sqlite3_step $STMT\n} SQLITE_ERROR\ndo_test capi3c-19.4.1 {\n  sqlite3_errmsg $DB\n} {no such table: t3}\nifcapable deprecated {\n  do_test capi3c-19.4.2 {\n    sqlite3_expired $STMT\n  } 1\n}\ndo_test capi3c-19.4.3 {\n  sqlite3_errmsg $DB\n} {no such table: t3}\nifcapable deprecated {\n  do_test capi3c-19.4.4 {\n    sqlite3_expired 0\n  } 1\n}\ndo_test capi3c-19.5 {\n  sqlite3_reset $STMT\n  db eval {\n     CREATE TABLE t3(x,y);\n     INSERT INTO t3 VALUES(1,2);\n  }\n  sqlite3_step $STMT\n} SQLITE_ROW\nifcapable deprecated {\n  do_test capi3c-19.5.2 {\n    sqlite3_expired $STMT\n  } 0\n}\ndo_test capi3c-19.6 {\n  sqlite3_column_int $STMT 1\n} 2\ndo_test capi3c-19.99 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\n# Make sure a change in a separate database connection does not\n# cause an SQLITE_SCHEMA return.\n#\ndo_test capi3c-20.1 {\n  set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]\n  sqlite3 db2 test.db\n  db2 eval {CREATE TABLE t4(x)}\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test capi3c-20.2 {\n  sqlite3_column_int $STMT 1\n} 2\ndo_test capi3c-20.3 {\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test capi3c-20.4 {\n  db2 close\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\n# Test that sqlite3_step() sets the database error code correctly.\n# See ticket #2497.\n#\nifcapable progress {\n  do_test capi3c-21.1 {\n    set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]\n    db progress 5 \"expr 1\"\n    sqlite3_step $STMT\n  } {SQLITE_INTERRUPT}\n  do_test capi3c-21.2 {\n    sqlite3_extended_errcode $DB\n  } {SQLITE_INTERRUPT}\n  do_test capi3c-21.3 {\n    sqlite3_finalize $STMT\n  } {SQLITE_INTERRUPT}\n  do_test capi3c-21.4 {\n    set STMT [sqlite3_prepare $DB {SELECT * FROM t3} -1 TAIL]\n    db progress 5 \"expr 1\"\n    sqlite3_step $STMT\n  } {SQLITE_ERROR}\n  do_test capi3c-21.5 {\n    sqlite3_errcode $DB\n  } {SQLITE_ERROR}\n  do_test capi3c-21.6 {\n    sqlite3_finalize $STMT\n  } {SQLITE_INTERRUPT}\n  do_test capi3c-21.7 {\n    sqlite3_errcode $DB\n  } {SQLITE_INTERRUPT}\n  do_test capi3c-21.8 {\n    sqlite3_extended_errcode $DB\n  } {SQLITE_INTERRUPT}\n}\n\n# Make sure sqlite3_result_error_code() returns the correct error code.\n# See ticket #2940\n#\ndo_test capi3c-22.1 {\n  db progress 0 {}\n  set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',3)} -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_PERM}\nsqlite3_finalize $STMT\ndo_test capi3c-22.2 {\n  set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',4)} -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ABORT}\nsqlite3_finalize $STMT\ndo_test capi3c-22.3 {\n  set STMT [sqlite3_prepare_v2 db {SELECT test_error('the message',16)} -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_EMPTY}\nsqlite3_finalize $STMT\n\n# For a multi-column result set where the same table column is repeated\n# in multiple columns of the output, verify that doing a UTF-8 to UTF-16\n# conversion (or vice versa) on one column does not change the value of\n# the second.\n#\nifcapable utf16 {\n  do_test capi3c-23.1 {\n    set STMT [sqlite3_prepare_v2 db {SELECT b,b,b,b FROM t1} -1 TAIL]\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test capi3c-23.2 {\n    sqlite3_column_text16 $STMT 0\n    sqlite3_column_text $STMT 1\n  } {one}\n  do_test capi3c-23.3 {\n    sqlite3_column_text16 $STMT 2\n    sqlite3_column_text $STMT 3\n  } {one}\n  sqlite3_finalize $STMT\n  do_test capi3c-23.4 {\n    set STMT [sqlite3_prepare_v2 db {SELECT b||'x',b,b,b FROM t1} -1 TAIL]\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test capi3c-23.5 {\n    sqlite3_column_text16 $STMT 0\n    sqlite3_column_text $STMT 1\n  } {one}\n  do_test capi3c-23.6 {\n    sqlite3_column_text16 $STMT 2\n    sqlite3_column_text $STMT 3\n  } {one}\n  sqlite3_finalize $STMT\n}\n\n# Test decltype on some SELECT statements that contain sub-selects.\n#\nproc decltype {zSql} {\n  set ret [list]\n  set STMT [sqlite3_prepare_v2 db $zSql -1 TAIL]\n  for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n    lappend ret [sqlite3_column_decltype $STMT $i]\n  }\n  sqlite3_finalize $STMT\n  return $ret\n}\ndo_test capi3c-24.1 {\n  execsql { CREATE TABLE t5(a INTEGER, b STRING, c DATETIME) }\n  decltype {SELECT * FROM t5}\n} {INTEGER STRING DATETIME}\ndo_test capi3c-24.2 {\n  decltype {SELECT (SELECT c) FROM t5}\n} {DATETIME}\ndo_test capi3c-24.3 {\n  decltype {SELECT (SELECT * FROM (SELECT c)) FROM t5}\n} {DATETIME}\ndo_test capi3c-24.4 {\n  decltype {SELECT * FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b}\n} {INTEGER STRING DATETIME}\ndo_test capi3c-24.5 {\n  decltype {\n    SELECT (SELECT x FROM (SELECT c AS x)) \n    FROM (SELECT * FROM t5 ORDER BY c LIMIT 1) ORDER BY b\n  }\n} {DATETIME}\ndo_test capi3c-24.3 {\n  decltype {SELECT (SELECT x FROM (SELECT t5.a AS x)) FROM t5}\n} {INTEGER}\n\n\n# Further tests of sqlite3_column_decltype():\n#\ndo_execsql_test 25.0 {\n  CREATE TABLE t11(a VARCHAR(10), b INTEGER);\n  CREATE TABLE t12(a VARCHAR(15), b FLOAT);\n}\n\nforeach {tn sql} {\n  1 \"SELECT * FROM t11 UNION ALL SELECT * FROM t12\"\n  2 \"SELECT * FROM t11 UNION SELECT * FROM t12\"\n  3 \"SELECT * FROM t11 EXCEPT SELECT * FROM t12\"\n  4 \"SELECT * FROM t11 INTERSECT SELECT * FROM t12\"\n\n  5 \"SELECT * FROM t11 UNION ALL SELECT * FROM t12 ORDER BY 1\"\n  6 \"SELECT * FROM t11 UNION SELECT * FROM t12 ORDER BY 1\"\n  7 \"SELECT * FROM t11 EXCEPT SELECT * FROM t12 ORDER BY 1\"\n  8 \"SELECT * FROM t11 INTERSECT SELECT * FROM t12 ORDER BY 1\"\n} {\n  do_test 25.$tn { decltype $sql } {VARCHAR(10) INTEGER}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi3d.test",
    "content": "# 2008 June 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  \n#\n# This file is devoted to testing the sqlite3_next_stmt and\n# sqlite3_stmt_readonly and sqlite3_stmt_busy interfaces.\n#\n# $Id: capi3d.test,v 1.2 2008/07/14 15:11:20 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create N prepared statements against database connection db\n# and return a list of all the generated prepared statements.\n#\nproc make_prepared_statements {N} {\n  set plist {}\n  for {set i 0} {$i<$N} {incr i} {\n    set sql \"SELECT $i FROM sqlite_master WHERE name LIKE '%$i%'\"\n    if {rand()<0.33} {    \n      set s [sqlite3_prepare_v2 db $sql -1 notused]\n    } else {\n      ifcapable utf16 {\n        if {rand()<0.5} {\n          set sql [encoding convertto unicode $sql]\\x00\\x00\n          set s [sqlite3_prepare16 db $sql -1 notused]\n        } else {\n          set s [sqlite3_prepare db $sql -1 notused]\n        }\n      }\n      ifcapable !utf16 {\n        set s [sqlite3_prepare db $sql -1 notused]\n      }\n    }\n    lappend plist $s\n  }\n  return $plist\n}\n\n\n# Scramble the $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# Database initially has no prepared statements.\n#\ndo_test capi3d-1.1 {\n  db cache flush\n  sqlite3_next_stmt db 0\n} {}\n\n# Run the following tests for between 1 and 100 prepared statements.\n#\nfor {set i 1} {$i<=100} {incr i} {\n  set stmtlist [make_prepared_statements $i]\n  do_test capi3d-1.2.$i.1 {\n    set p [sqlite3_next_stmt db 0]\n    set x {}\n    while {$p!=\"\"} {\n      lappend x $p\n      set p [sqlite3_next_stmt db $p]\n    }\n    lsort $x\n  } [lsort $stmtlist]\n  do_test capi3-1.2.$i.2 {\n    foreach p [scramble $::stmtlist] {\n      sqlite3_finalize $p\n    }\n    sqlite3_next_stmt db 0\n  } {}\n}\n\n# Tests for the is-read-only interface.\n#\nproc test_is_readonly {testname sql truth} {\n  do_test $testname [format {\n    set DB [sqlite3_connection_pointer db]\n    set STMT [sqlite3_prepare $DB {%s} -1 TAIL]\n    set rc [sqlite3_stmt_readonly $STMT]\n    sqlite3_finalize $STMT\n    set rc\n  } $sql] $truth\n}\n\ntest_is_readonly capi3d-2.1 {SELECT * FROM sqlite_master} 1\ntest_is_readonly capi3d-2.2 {CREATE TABLE t1(x)} 0\ndb eval {CREATE TABLE t1(x)}\ntest_is_readonly capi3d-2.3 {INSERT INTO t1 VALUES(5)} 0\ntest_is_readonly capi3d-2.4 {UPDATE t1 SET x=x+1 WHERE x<0} 0\ntest_is_readonly capi3d-2.5 {SELECT * FROM t1} 1\nifcapable wal {\n  test_is_readonly capi3d-2.6 {PRAGMA journal_mode=WAL} 0\n  test_is_readonly capi3d-2.7 {PRAGMA wal_checkpoint} 0\n}\ntest_is_readonly capi3d-2.8 {PRAGMA application_id=1234} 0\ntest_is_readonly capi3d-2.9 {VACUUM} 0\ntest_is_readonly capi3d-2.10 {PRAGMA integrity_check} 1\ndo_test capi3-2.99 {\n  sqlite3_stmt_readonly 0\n} 1\n\n# Tests for sqlite3_stmt_busy\n#\ndo_test capi3d-3.1 {\n  db eval {INSERT INTO t1 VALUES(6); INSERT INTO t1 VALUES(7);}\n  set STMT [sqlite3_prepare db {SELECT * FROM t1} -1 TAIL]\n  sqlite3_stmt_busy $STMT\n} {0}\ndo_test capi3d-3.2 {\n  sqlite3_step $STMT\n  sqlite3_stmt_busy $STMT\n} {1}\ndo_test capi3d-3.3 {\n  sqlite3_step $STMT\n  sqlite3_stmt_busy $STMT\n} {1}\ndo_test capi3d-3.4 {\n  sqlite3_reset $STMT\n  sqlite3_stmt_busy $STMT\n} {0}\n\ndo_test capi3d-3.99 {\n  sqlite3_finalize $STMT\n  sqlite3_stmt_busy 0\n} {0}\n\n#--------------------------------------------------------------------------\n# Test the sqlite3_stmt_busy() function with ROLLBACK statements.\n#\nreset_db\n\ndo_execsql_test capi3d-4.1 {\n  CREATE TABLE t4(x,y);\n  BEGIN;\n}\n\ndo_test capi3d-4.2.1 {\n  set ::s1 [sqlite3_prepare_v2 db \"ROLLBACK\" -1 notused]\n  sqlite3_step $::s1\n} {SQLITE_DONE}\n\ndo_test capi3d-4.2.2 {\n  sqlite3_stmt_busy $::s1\n} {0}\n\ndo_catchsql_test capi3d-4.2.3 {\n  VACUUM\n} {0 {}}\n\ndo_test capi3d-4.2.4 {\n  sqlite3_reset $::s1\n} {SQLITE_OK}\n\ndo_catchsql_test capi3d-4.2.5 {\n  VACUUM\n} {0 {}}\n\ndo_test capi3d-4.2.6 {\n  sqlite3_finalize $::s1\n} {SQLITE_OK}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/capi3e.test",
    "content": "# 2010 Novemeber 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the callback-free C/C++ API.\n#\n# $Id: capi3e.test,v 1.70 2009/01/09 02:49:32 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Make sure the system encoding is utf-8. Otherwise, if the system encoding\n# is other than utf-8, [file isfile $x] may not refer to the same file\n# as [sqlite3 db $x].\n#\n# This is no longer needed here because it should be done within the test\n# fixture executable itself, via Tcl_SetSystemEncoding.\n#\n# encoding system utf-8\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\n# Return the UTF-8 representation of the supplied UTF-16 string $str. \nproc utf8 {str} {\n  # If $str ends in two 0x00 0x00 bytes, knock these off before\n  # converting to UTF-8 using TCL.\n  binary scan $str \\c* vals\n  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {\n    set str [binary format \\c* [lrange $vals 0 end-2]]\n  }\n\n  set r [encoding convertfrom unicode $str]\n  return $r\n}\n\n# These tests complement those in capi2.test. They are organized\n# as follows:\n#\n# capi3e-1.*: Test sqlite3_open with various UTF8 filenames\n# capi3e-2.*: Test sqlite3_open16 with various UTF8 filenames\n# capi3e-3.*: Test ATTACH with various UTF8 filenames\n\ndb close\n\n# here's the list of file names we're testing\nset names {t 1 t. 1. t.d 1.d t-1 1-1 t.db ä.db ë.db ö.db ü.db ÿ.db}\n\nset i 0\nforeach name $names {\n  incr i\n  do_test capi3e-1.1.$i {\n    set db2 [sqlite3_open $name {}]\n    sqlite3_errcode $db2\n  } {SQLITE_OK}\n  do_test capi3e-1.2.$i {\n    sqlite3_close $db2\n  } {SQLITE_OK}\n  do_test capi3e-1.3.$i {\n    file isfile $name\n  } {1}\n}\n\nifcapable {utf16} {\n  set i 0\n  foreach name $names {\n    incr i\n    do_test capi3e-2.1.$i {\n      set db2 [sqlite3_open16 [utf16 $name] {}]\n      sqlite3_errcode $db2\n    } {SQLITE_OK}\n    do_test capi3e-2.2.$i {\n      sqlite3_close $db2\n    } {SQLITE_OK}\n    do_test capi3e-2.3.$i {\n      file isfile $name\n    } {1}\n  }\n}\n\nifcapable attach {\n  do_test capi3e-3.1 {\n    sqlite3 db2 base.db\n  } {}\n  set i 0\n  foreach name $names {\n    incr i\n    do_test capi3e-3.2.$i {\n      db2 eval \"ATTACH DATABASE '$name' AS db$i;\"\n    } {}\n    do_test capi3e-3.3.$i {\n      db2 eval \"DETACH DATABASE db$i;\"\n    } {}\n  }\n  do_test capi3e-3.4 {\n    db2 close\n  } {}\n}\n\n# clean up\nforcedelete base.db\nforeach name $names {\n  forcedelete $name\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cast.test",
    "content": "# 2005 June 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CAST operator.\n#\n# $Id: cast.test,v 1.10 2008/11/06 15:33:04 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Only run these tests if the build includes the CAST operator\nifcapable !cast {\n  finish_test\n  return\n}\n\n# Tests for the CAST( AS blob), CAST( AS text) and CAST( AS numeric) built-ins\n#\nifcapable bloblit {\n  do_test cast-1.1 {\n    execsql {SELECT x'616263'}\n  } abc\n  do_test cast-1.2 {\n    execsql {SELECT typeof(x'616263')}\n  } blob\n  do_test cast-1.3 {\n    execsql {SELECT CAST(x'616263' AS text)}\n  } abc\n  do_test cast-1.4 {\n    execsql {SELECT typeof(CAST(x'616263' AS text))}\n  } text\n  do_test cast-1.5 {\n    execsql {SELECT CAST(x'616263' AS numeric)}\n  } 0\n  do_test cast-1.6 {\n    execsql {SELECT typeof(CAST(x'616263' AS numeric))}\n  } integer\n  do_test cast-1.7 {\n    execsql {SELECT CAST(x'616263' AS blob)}\n  } abc\n  do_test cast-1.8 {\n    execsql {SELECT typeof(CAST(x'616263' AS blob))}\n  } blob\n  do_test cast-1.9 {\n    execsql {SELECT CAST(x'616263' AS integer)}\n  } 0\n  do_test cast-1.10 {\n    execsql {SELECT typeof(CAST(x'616263' AS integer))}\n  } integer\n}\ndo_test cast-1.11 {\n  execsql {SELECT null}\n} {{}}\ndo_test cast-1.12 {\n  execsql {SELECT typeof(NULL)}\n} null\ndo_test cast-1.13 {\n  execsql {SELECT CAST(NULL AS text)}\n} {{}}\ndo_test cast-1.14 {\n  execsql {SELECT typeof(CAST(NULL AS text))}\n} null\ndo_test cast-1.15 {\n  execsql {SELECT CAST(NULL AS numeric)}\n} {{}}\ndo_test cast-1.16 {\n  execsql {SELECT typeof(CAST(NULL AS numeric))}\n} null\ndo_test cast-1.17 {\n  execsql {SELECT CAST(NULL AS blob)}\n} {{}}\ndo_test cast-1.18 {\n  execsql {SELECT typeof(CAST(NULL AS blob))}\n} null\ndo_test cast-1.19 {\n  execsql {SELECT CAST(NULL AS integer)}\n} {{}}\ndo_test cast-1.20 {\n  execsql {SELECT typeof(CAST(NULL AS integer))}\n} null\ndo_test cast-1.21 {\n  execsql {SELECT 123}\n} {123}\ndo_test cast-1.22 {\n  execsql {SELECT typeof(123)}\n} integer\ndo_test cast-1.23 {\n  execsql {SELECT CAST(123 AS text)}\n} {123}\ndo_test cast-1.24 {\n  execsql {SELECT typeof(CAST(123 AS text))}\n} text\ndo_test cast-1.25 {\n  execsql {SELECT CAST(123 AS numeric)}\n} 123\ndo_test cast-1.26 {\n  execsql {SELECT typeof(CAST(123 AS numeric))}\n} integer\ndo_test cast-1.27 {\n  execsql {SELECT CAST(123 AS blob)}\n} {123}\ndo_test cast-1.28 {\n  execsql {SELECT typeof(CAST(123 AS blob))}\n} blob\ndo_test cast-1.29 {\n  execsql {SELECT CAST(123 AS integer)}\n} {123}\ndo_test cast-1.30 {\n  execsql {SELECT typeof(CAST(123 AS integer))}\n} integer\ndo_test cast-1.31 {\n  execsql {SELECT 123.456}\n} {123.456}\ndo_test cast-1.32 {\n  execsql {SELECT typeof(123.456)}\n} real\ndo_test cast-1.33 {\n  execsql {SELECT CAST(123.456 AS text)}\n} {123.456}\ndo_test cast-1.34 {\n  execsql {SELECT typeof(CAST(123.456 AS text))}\n} text\ndo_test cast-1.35 {\n  execsql {SELECT CAST(123.456 AS numeric)}\n} 123.456\ndo_test cast-1.36 {\n  execsql {SELECT typeof(CAST(123.456 AS numeric))}\n} real\ndo_test cast-1.37 {\n  execsql {SELECT CAST(123.456 AS blob)}\n} {123.456}\ndo_test cast-1.38 {\n  execsql {SELECT typeof(CAST(123.456 AS blob))}\n} blob\ndo_test cast-1.39 {\n  execsql {SELECT CAST(123.456 AS integer)}\n} {123}\ndo_test cast-1.38 {\n  execsql {SELECT typeof(CAST(123.456 AS integer))}\n} integer\ndo_test cast-1.41 {\n  execsql {SELECT '123abc'}\n} {123abc}\ndo_test cast-1.42 {\n  execsql {SELECT typeof('123abc')}\n} text\ndo_test cast-1.43 {\n  execsql {SELECT CAST('123abc' AS text)}\n} {123abc}\ndo_test cast-1.44 {\n  execsql {SELECT typeof(CAST('123abc' AS text))}\n} text\ndo_test cast-1.45 {\n  execsql {SELECT CAST('123abc' AS numeric)}\n} 123\ndo_test cast-1.46 {\n  execsql {SELECT typeof(CAST('123abc' AS numeric))}\n} integer\ndo_test cast-1.47 {\n  execsql {SELECT CAST('123abc' AS blob)}\n} {123abc}\ndo_test cast-1.48 {\n  execsql {SELECT typeof(CAST('123abc' AS blob))}\n} blob\ndo_test cast-1.49 {\n  execsql {SELECT CAST('123abc' AS integer)}\n} 123\ndo_test cast-1.50 {\n  execsql {SELECT typeof(CAST('123abc' AS integer))}\n} integer\ndo_test cast-1.51 {\n  execsql {SELECT CAST('123.5abc' AS numeric)}\n} 123.5\ndo_test cast-1.53 {\n  execsql {SELECT CAST('123.5abc' AS integer)}\n} 123\n\ndo_test case-1.60 {\n  execsql {SELECT CAST(null AS REAL)}\n} {{}}\ndo_test case-1.61 {\n  execsql {SELECT typeof(CAST(null AS REAL))}\n} {null}\ndo_test case-1.62 {\n  execsql {SELECT CAST(1 AS REAL)}\n} {1.0}\ndo_test case-1.63 {\n  execsql {SELECT typeof(CAST(1 AS REAL))}\n} {real}\ndo_test case-1.64 {\n  execsql {SELECT CAST('1' AS REAL)}\n} {1.0}\ndo_test case-1.65 {\n  execsql {SELECT typeof(CAST('1' AS REAL))}\n} {real}\ndo_test case-1.66 {\n  execsql {SELECT CAST('abc' AS REAL)}\n} {0.0}\ndo_test case-1.67 {\n  execsql {SELECT typeof(CAST('abc' AS REAL))}\n} {real}\ndo_test case-1.68 {\n  execsql {SELECT CAST(x'31' AS REAL)}\n} {1.0}\ndo_test case-1.69 {\n  execsql {SELECT typeof(CAST(x'31' AS REAL))}\n} {real}\n\n\n# Ticket #1662.  Ignore leading spaces in numbers when casting.\n#\ndo_test cast-2.1 {\n  execsql {SELECT CAST('   123' AS integer)}\n} 123\ndo_test cast-2.2 {\n  execsql {SELECT CAST('   -123.456' AS real)}\n} -123.456\n\n# ticket #2364.  Use full percision integers if possible when casting\n# to numeric.  Do not fallback to real (and the corresponding 48-bit\n# mantissa) unless absolutely necessary.\n#\ndo_test cast-3.1 {\n  execsql {SELECT CAST(9223372036854774800 AS integer)}\n} 9223372036854774800\ndo_test cast-3.2 {\n  execsql {SELECT CAST(9223372036854774800 AS numeric)}\n} 9223372036854774800\ndo_realnum_test cast-3.3 {\n  execsql {SELECT CAST(9223372036854774800 AS real)}\n} 9.22337203685477e+18\ndo_test cast-3.4 {\n  execsql {SELECT CAST(CAST(9223372036854774800 AS real) AS integer)}\n} 9223372036854774784\ndo_test cast-3.5 {\n  execsql {SELECT CAST(-9223372036854774800 AS integer)}\n} -9223372036854774800\ndo_test cast-3.6 {\n  execsql {SELECT CAST(-9223372036854774800 AS numeric)}\n} -9223372036854774800\ndo_realnum_test cast-3.7 {\n  execsql {SELECT CAST(-9223372036854774800 AS real)}\n} -9.22337203685477e+18\ndo_test cast-3.8 {\n  execsql {SELECT CAST(CAST(-9223372036854774800 AS real) AS integer)}\n} -9223372036854774784\ndo_test cast-3.11 {\n  execsql {SELECT CAST('9223372036854774800' AS integer)}\n} 9223372036854774800\ndo_test cast-3.12 {\n  execsql {SELECT CAST('9223372036854774800' AS numeric)}\n} 9223372036854774800\ndo_realnum_test cast-3.13 {\n  execsql {SELECT CAST('9223372036854774800' AS real)}\n} 9.22337203685477e+18\nifcapable long_double {\n  do_test cast-3.14 {\n    execsql {SELECT CAST(CAST('9223372036854774800' AS real) AS integer)}\n  } 9223372036854774784\n}\ndo_test cast-3.15 {\n  execsql {SELECT CAST('-9223372036854774800' AS integer)}\n} -9223372036854774800\ndo_test cast-3.16 {\n  execsql {SELECT CAST('-9223372036854774800' AS numeric)}\n} -9223372036854774800\ndo_realnum_test cast-3.17 {\n  execsql {SELECT CAST('-9223372036854774800' AS real)}\n} -9.22337203685477e+18\nifcapable long_double {\n  do_test cast-3.18 {\n    execsql {SELECT CAST(CAST('-9223372036854774800' AS real) AS integer)}\n  } -9223372036854774784\n}\nif {[db eval {PRAGMA encoding}]==\"UTF-8\"} {\n  do_test cast-3.21 {\n    execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS integer)}\n  } 9223372036854774800\n  do_test cast-3.22 {\n    execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS numeric)}\n  } 9223372036854774800\n  do_realnum_test cast-3.23 {\n    execsql {SELECT CAST(x'39323233333732303336383534373734383030' AS real)}\n  } 9.22337203685477e+18\n  ifcapable long_double {\n    do_test cast-3.24 {\n      execsql {\n        SELECT CAST(CAST(x'39323233333732303336383534373734383030' AS real)\n                    AS integer)\n      }\n    } 9223372036854774784\n  }\n}\ndo_test case-3.31 {\n  execsql {SELECT CAST(NULL AS numeric)}\n} {{}}\n\n# Test to see if it is possible to trick SQLite into reading past \n# the end of a blob when converting it to a number.\ndo_test cast-3.32.1 {\n  set blob \"1234567890\"\n  set DB [sqlite3_connection_pointer db]\n  set ::STMT [sqlite3_prepare $DB {SELECT CAST(? AS real)} -1 TAIL]\n  sqlite3_bind_blob -static $::STMT 1 $blob 5\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test cast-3.32.2 {\n  sqlite3_column_int $::STMT 0\n} {12345}\ndo_test cast-3.32.3 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\n\ndo_test cast-4.1 {\n  db eval {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES('abc');\n    SELECT a, CAST(a AS integer) FROM t1;\n  }\n} {abc 0}\ndo_test cast-4.2 {\n  db eval {\n    SELECT CAST(a AS integer), a FROM t1;\n  }\n} {0 abc}\ndo_test cast-4.3 {\n  db eval {\n    SELECT a, CAST(a AS integer), a FROM t1;\n  }\n} {abc 0 abc}\ndo_test cast-4.4 {\n  db eval {\n    SELECT CAST(a AS integer), a, CAST(a AS real), a FROM t1;\n  }\n} {0 abc 0.0 abc}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cffault.test",
    "content": "# 2011 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains fault-injection test cases for the \n# sqlite3_db_cacheflush API.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix cffault\nsource $testdir/malloc_common.tcl\n\n# Run the supplied SQL on a copy of the database currently stored on \n# disk in file $dbfile.\nproc diskquery {dbfile sql} {\n  forcecopy $dbfile dq.db\n  sqlite3 dq dq.db\n  set res [execsql $sql dq]\n  dq close\n  set res\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE INDEX i1 ON t1(b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n  INSERT INTO t1 VALUES(7, 8);\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 1.1 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b+1;\n  }\n} -body {\n  sqlite3_db_cacheflush db\n} -test {\n  if {[sqlite3_get_autocommit db]} { error \"Transaction rolled back!\" }\n  faultsim_test_result {0 {}} {1 {disk I/O error}}\n  catch { db eval COMMIT }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test 1.2 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b+1;\n  }\n} -body {\n  set result [list]\n  db eval { SELECT * FROM t1 } {\n    if {$a==5} { catch { sqlite3_db_cacheflush db } }\n    lappend result $a $b\n  }\n  set result\n} -test {\n  faultsim_test_result {0 {1 3 3 5 5 7 7 9}} {1 {disk I/O error}}\n  catch { db eval COMMIT }\n  faultsim_integrity_check\n}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  CREATE INDEX i1 ON t1(b);\n  CREATE INDEX i2 ON t1(c, b);\n  INSERT INTO t1 VALUES(1, 2,  randomblob(600));\n  INSERT INTO t1 VALUES(3, 4,  randomblob(600));\n  INSERT INTO t1 VALUES(5, 6,  randomblob(600));\n  INSERT INTO t1 VALUES(7, 8,  randomblob(600));\n  INSERT INTO t1 VALUES(9, 10, randomblob(600));\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 2.1 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b+1;\n  }\n} -body {\n  set result [list]\n  db eval { SELECT * FROM t1 } {\n    if {$a==5} { catch { sqlite3_db_cacheflush db } }\n    lappend result $a $b\n  }\n  set result\n} -test {\n  faultsim_test_result {0 {1 3 3 5 5 7 7 9 9 11}} {1 {disk I/O error}}\n  catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } }\n  catch { db eval COMMIT }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test 2.2 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b+1;\n  }\n} -body {\n  sqlite3_db_cacheflush db\n} -test {\n  if {[sqlite3_get_autocommit db]} { error \"Transaction rolled back!\" }\n  faultsim_test_result {0 {}} {1 {disk I/O error}}\n  catch { db eval { SELECT * FROM t1 } }\n  catch { db eval COMMIT }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test 2.3 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b-1;\n  }\n} -body {\n  sqlite3_db_cacheflush db\n} -test {\n  if {[sqlite3_get_autocommit db]} { error \"Transaction rolled back!\" }\n  faultsim_test_result {0 {}} {1 {disk I/O error}}\n  catch { db eval { INSERT INTO t1 VALUES(11, 12, randomblob(600)) } }\n  catch { db eval COMMIT }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test 2.4 -prep {\n  faultsim_restore_and_reopen\n  db eval {\n    BEGIN;\n      UPDATE t1 SET b=b-1;\n  }\n} -body {\n  catch { sqlite3_db_cacheflush db }\n  catch { sqlite3_db_release_memory db }\n  catch { sqlite3_db_cacheflush db }\n  execsql { SELECT a, b FROM t1 }\n} -test {\n  faultsim_test_result {0 {1 1 3 3 5 5 7 7 9 9}} {1 {disk I/O error}}\n  catchsql ROLLBACK\n  faultsim_integrity_check\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/check.test",
    "content": "# 2005 November 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing CHECK constraints\n#\n# $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix check\n\n# Only run these tests if the build includes support for CHECK constraints\nifcapable !check {\n  finish_test\n  return\n}\n\ndo_test check-1.1 {\n  execsql {\n    CREATE TABLE t1(\n      x INTEGER CHECK( x<5 ),\n      y REAL CHECK( y>x )\n    );\n  }\n} {}\ndo_test check-1.2 {\n  execsql {\n    INSERT INTO t1 VALUES(3,4);\n    SELECT * FROM t1;\n  }  \n} {3 4.0}\ndo_test check-1.3 {\n  catchsql {\n    INSERT INTO t1 VALUES(6,7);\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-1.4 {\n  execsql {\n    SELECT * FROM t1;\n  }  \n} {3 4.0}\ndo_test check-1.5 {\n  catchsql {\n    INSERT INTO t1 VALUES(4,3);\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-1.6 {\n  execsql {\n    SELECT * FROM t1;\n  }  \n} {3 4.0}\ndo_test check-1.7 {\n  catchsql {\n    INSERT INTO t1 VALUES(NULL,6);\n  }\n} {0 {}}\ndo_test check-1.8 {\n  execsql {\n    SELECT * FROM t1;\n  }  \n} {3 4.0 {} 6.0}\ndo_test check-1.9 {\n  catchsql {\n    INSERT INTO t1 VALUES(2,NULL);\n  }\n} {0 {}}\ndo_test check-1.10 {\n  execsql {\n    SELECT * FROM t1;\n  }  \n} {3 4.0 {} 6.0 2 {}}\ndo_test check-1.11 {\n  execsql {\n    DELETE FROM t1 WHERE x IS NULL OR x!=3;\n    UPDATE t1 SET x=2 WHERE x==3;\n    SELECT * FROM t1;\n  }\n} {2 4.0}\ndo_test check-1.12 {\n  catchsql {\n    UPDATE t1 SET x=7 WHERE x==2\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-1.13 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {2 4.0}\ndo_test check-1.14 {\n  catchsql {\n    UPDATE t1 SET x=5 WHERE x==2\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-1.15 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {2 4.0}\ndo_test check-1.16 {\n  catchsql {\n    UPDATE t1 SET x=4, y=11 WHERE x==2\n  }\n} {0 {}}\ndo_test check-1.17 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {4 11.0}\n\ndo_test check-2.1 {\n  execsql {\n    CREATE TABLE t2(\n      x INTEGER CONSTRAINT one CHECK( typeof(coalesce(x,0))==\"integer\" ),\n      y REAL CONSTRAINT two CHECK( typeof(coalesce(y,0.1))=='real' ),\n      z TEXT CONSTRAINT three CHECK( typeof(coalesce(z,''))=='text' )\n    );\n  }\n} {}\ndo_test check-2.2 {\n  execsql {\n    INSERT INTO t2 VALUES(1,2.2,'three');\n    SELECT * FROM t2;\n  }\n} {1 2.2 three}\ndb close\nsqlite3 db test.db\ndo_test check-2.3 {\n  execsql {\n    INSERT INTO t2 VALUES(NULL, NULL, NULL);\n    SELECT * FROM t2;\n  }\n} {1 2.2 three {} {} {}}\ndo_test check-2.4 {\n  catchsql {\n    INSERT INTO t2 VALUES(1.1, NULL, NULL);\n  }\n} {1 {CHECK constraint failed: one}}\ndo_test check-2.5 {\n  catchsql {\n    INSERT INTO t2 VALUES(NULL, 5, NULL);\n  }\n} {1 {CHECK constraint failed: two}}\ndo_test check-2.6 {\n  catchsql {\n    INSERT INTO t2 VALUES(NULL, NULL, 3.14159);\n  }\n} {1 {CHECK constraint failed: three}}\n\n# Undocumented behavior:  The CONSTRAINT name clause can follow a constraint.\n# Such a clause is ignored.  But the parser must accept it for backwards\n# compatibility.\n#\ndo_test check-2.10 {\n  execsql {\n    CREATE TABLE t2b(\n      x INTEGER CHECK( typeof(coalesce(x,0))=='integer' ) CONSTRAINT one,\n      y TEXT PRIMARY KEY constraint two,\n      z INTEGER,\n      UNIQUE(x,z) constraint three\n    );\n  }\n} {}\ndo_test check-2.11 {\n  catchsql {\n    INSERT INTO t2b VALUES('xyzzy','hi',5);\n  }\n} {1 {CHECK constraint failed: t2b}}\ndo_test check-2.12 {\n  execsql {\n    CREATE TABLE t2c(\n      x INTEGER CONSTRAINT x_one CONSTRAINT x_two\n          CHECK( typeof(coalesce(x,0))=='integer' )\n          CONSTRAINT x_two CONSTRAINT x_three,\n      y INTEGER, z INTEGER,\n      CONSTRAINT u_one UNIQUE(x,y,z) CONSTRAINT u_two\n    );\n  }\n} {}\ndo_test check-2.13 {\n  catchsql {\n    INSERT INTO t2c VALUES('xyzzy',7,8);\n  }\n} {1 {CHECK constraint failed: x_two}}\ndo_test check-2.cleanup {\n  execsql {\n    DROP TABLE IF EXISTS t2b;\n    DROP TABLE IF EXISTS t2c;\n  }\n} {}\n\nifcapable subquery {\n  do_test check-3.1 {\n    catchsql {\n      CREATE TABLE t3(\n        x, y, z,\n        CHECK( x<(SELECT min(x) FROM t1) )\n      );\n    }\n  } {1 {subqueries prohibited in CHECK constraints}}\n}\n\ndo_test check-3.2 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY name\n  }\n} {t1 t2}\ndo_test check-3.3 {\n  catchsql {\n    CREATE TABLE t3(\n      x, y, z,\n      CHECK( q<x )\n    );\n  }\n} {1 {no such column: q}}\ndo_test check-3.4 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY name\n  }\n} {t1 t2}\ndo_test check-3.5 {\n  catchsql {\n    CREATE TABLE t3(\n      x, y, z,\n      CHECK( t2.x<x )\n    );\n  }\n} {1 {no such column: t2.x}}\ndo_test check-3.6 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY name\n  }\n} {t1 t2}\ndo_test check-3.7 {\n  catchsql {\n    CREATE TABLE t3(\n      x, y, z,\n      CHECK( t3.x<25 )\n    );\n  }\n} {0 {}}\ndo_test check-3.8 {\n  execsql {\n    INSERT INTO t3 VALUES(1,2,3);\n    SELECT * FROM t3;\n  }\n} {1 2 3}\ndo_test check-3.9 {\n  catchsql {\n    INSERT INTO t3 VALUES(111,222,333);\n  }\n} {1 {CHECK constraint failed: t3}}\n\ndo_test check-4.1 {\n  execsql {\n    CREATE TABLE t4(x, y,\n      CHECK (\n           x+y==11\n        OR x*y==12\n        OR x/y BETWEEN 5 AND 8\n        OR -x==y+10\n      )\n    );\n  }\n} {}\ndo_test check-4.2 {\n  execsql {\n    INSERT INTO t4 VALUES(1,10);\n    SELECT * FROM t4\n  }\n} {1 10}\ndo_test check-4.3 {\n  execsql {\n    UPDATE t4 SET x=4, y=3;\n    SELECT * FROM t4\n  }\n} {4 3}\ndo_test check-4.4 {\n  execsql {\n    UPDATE t4 SET x=12, y=2;\n    SELECT * FROM t4\n  }\n} {12 2}\ndo_test check-4.5 {\n  execsql {\n    UPDATE t4 SET x=12, y=-22;\n    SELECT * FROM t4\n  }\n} {12 -22}\ndo_test check-4.6 {\n  catchsql {\n    UPDATE t4 SET x=0, y=1;\n  }\n} {1 {CHECK constraint failed: t4}}\ndo_test check-4.7 {\n  execsql {\n    SELECT * FROM t4;\n  }\n} {12 -22}\ndo_test check-4.8 {\n  execsql {\n    PRAGMA ignore_check_constraints=ON;\n    UPDATE t4 SET x=0, y=1;\n    SELECT * FROM t4;\n    PRAGMA integrity_check;\n  }\n} {0 1 ok}\ndo_execsql_test check-4.8.1 {\n  PRAGMA ignore_check_constraints=OFF;\n  PRAGMA integrity_check;\n} {{CHECK constraint failed in t4}}\ndo_test check-4.9 {\n  catchsql {\n    UPDATE t4 SET x=0, y=2;\n  }\n} {1 {CHECK constraint failed: t4}}\nifcapable vacuum {\n  do_test check_4.10 {\n    catchsql {\n      VACUUM\n    }\n  } {0 {}}\n}\n\ndo_test check-5.1 {\n  catchsql {\n    CREATE TABLE t5(x, y,\n      CHECK( x*y<:abc )\n    );\n  }\n} {1 {parameters prohibited in CHECK constraints}}\ndo_test check-5.2 {\n  catchsql {\n    CREATE TABLE t5(x, y,\n      CHECK( x*y<? )\n    );\n  }\n} {1 {parameters prohibited in CHECK constraints}}\n\nifcapable conflict {\n\ndo_test check-6.1 {\n  execsql {SELECT * FROM t1}\n} {4 11.0}\ndo_test check-6.2 {\n  execsql {\n    UPDATE OR IGNORE t1 SET x=5;\n    SELECT * FROM t1;\n  }\n} {4 11.0}\ndo_test check-6.3 {\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(5,4.0);\n    SELECT * FROM t1;\n  }\n} {4 11.0}\ndo_test check-6.4 {\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(2,20.0);\n    SELECT * FROM t1;\n  }\n} {4 11.0 2 20.0}\ndo_test check-6.5 {\n  catchsql {\n    UPDATE OR FAIL t1 SET x=7-x, y=y+1;\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-6.6 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {3 12.0 2 20.0}\ndo_test check-6.7 {\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(1,30.0);\n    INSERT OR ROLLBACK INTO t1 VALUES(8,40.0);\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-6.8 {\n  catchsql {\n    COMMIT;\n  }\n} {1 {cannot commit - no transaction is active}}\ndo_test check-6.9 {\n  execsql {\n    SELECT * FROM t1\n  }\n} {3 12.0 2 20.0}\n\ndo_test check-6.11 {\n  execsql {SELECT * FROM t1}\n} {3 12.0 2 20.0}\ndo_test check-6.12 {\n  catchsql {\n    REPLACE INTO t1 VALUES(6,7);\n  }\n} {1 {CHECK constraint failed: t1}}\ndo_test check-6.13 {\n  execsql {SELECT * FROM t1}\n} {3 12.0 2 20.0}\ndo_test check-6.14 {\n  catchsql {\n    INSERT OR IGNORE INTO t1 VALUES(6,7);\n  }\n} {0 {}}\ndo_test check-6.15 {\n  execsql {SELECT * FROM t1}\n} {3 12.0 2 20.0}\n\n\n}\n\n#--------------------------------------------------------------------------\n# If a connection opens a database that contains a CHECK constraint that\n# uses an unknown UDF, the schema should not be considered malformed.\n# Attempting to modify the table should fail (since the CHECK constraint\n# cannot be tested).\n#\nreset_db\nproc myfunc {x} {expr $x < 10}\ndb func myfunc myfunc\n\ndo_execsql_test  7.1 { CREATE TABLE t6(a CHECK (myfunc(a))) }\ndo_execsql_test  7.2 { INSERT INTO t6 VALUES(9)  }\ndo_catchsql_test 7.3 { INSERT INTO t6 VALUES(11) } \\\n          {1 {CHECK constraint failed: t6}}\n\ndo_test 7.4 {\n  sqlite3 db2 test.db\n  execsql { SELECT * FROM t6 } db2 \n} {9}\n\ndo_test 7.5 {\n  catchsql { INSERT INTO t6 VALUES(8) } db2\n} {1 {unknown function: myfunc()}}\n\ndo_test 7.6 {\n  catchsql { CREATE TABLE t7(a CHECK (myfunc(a))) } db2\n} {1 {no such function: myfunc}}\n\ndo_test 7.7 {\n  db2 func myfunc myfunc\n  execsql { INSERT INTO t6 VALUES(8) } db2\n} {}\n\ndo_test 7.8 {\n  db2 func myfunc myfunc\n  catchsql { INSERT INTO t6 VALUES(12) } db2\n} {1 {CHECK constraint failed: t6}}\n\n# 2013-08-02:  Silently ignore database name qualifiers in CHECK constraints.\n#\ndo_execsql_test 8.1 {\n  CREATE TABLE t810(a, CHECK( main.t810.a>0 ));\n  CREATE TABLE t811(b, CHECK( xyzzy.t811.b BETWEEN 5 AND 10 ));\n} {}\n\n# Make sure check constraints involving the ROWID are not ignored\n#\ndo_execsql_test 9.1 {\n  CREATE TABLE t1(\n    a INTEGER PRIMARY KEY,\n    b INTEGER NOT NULL CONSTRAINT 'b-check' CHECK( b>a ),\n    c INTEGER NOT NULL CONSTRAINT 'c-check' CHECK( c>rowid*2 ),\n    d INTEGER NOT NULL CONSTRAINT 'd-check' CHECK( d BETWEEN b AND c )\n  );\n  INSERT INTO t1(a,b,c,d) VALUES(1,2,4,3),(2,4,6,5),(3,10,30,20);\n} {}\ndo_catchsql_test 9.2 {\n  UPDATE t1 SET b=0 WHERE a=1;\n} {1 {CHECK constraint failed: b-check}}\ndo_catchsql_test 9.3 {\n  UPDATE t1 SET c=a*2 WHERE a=1;\n} {1 {CHECK constraint failed: c-check}}\n\n# Integrity check on a VIEW with columns.\n#\ndb close\ndb2 close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 10.1 {\n  CREATE TABLE t1(x);\n  CREATE VIEW v1(y) AS SELECT x FROM t1;\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/checkfreelist.test",
    "content": "# 2017-10-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the checkfreelist extension.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix checkfreelist\n\nifcapable !vtab||!compound {\n  finish_test\n  return\n}\n\nif {[file exists ../checkfreelist.so]==0} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n}\n\ndb enable_load_extension 1\ndo_execsql_test 1.1 {\n  SELECT load_extension('../checkfreelist.so');\n} {{}}\n\ndo_execsql_test 1.2 { SELECT checkfreelist('main') } {ok}\ndo_execsql_test 1.3 {\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000\n  )\n  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;\n  DELETE FROM t1 WHERE rowid%3;\n  PRAGMA freelist_count;\n} {6726}\n\ndo_execsql_test 1.4 { SELECT checkfreelist('main') } {ok}\ndo_execsql_test 1.5 {\n  WITH freelist_trunk(i, d, n) AS (\n    SELECT 1, NULL, sqlite_readint32(data, 32) FROM sqlite_dbpage WHERE pgno=1\n      UNION ALL\n    SELECT n, data, sqlite_readint32(data) \n    FROM freelist_trunk, sqlite_dbpage WHERE pgno=n\n  )\n  SELECT i FROM freelist_trunk WHERE i!=1;\n} {\n  10010 9716 9344 8970 8596 8223 7848 7475 7103 6728 6355 5983 5609 5235\n  4861 4488 4113 3741 3368 2993 2620 2248 1873 1500 1126 753 378 5\n}\n\ndo_execsql_test 1.6 { SELECT checkfreelist('main') } {ok}\n\nproc set_int {blob idx newval} {\n  binary scan $blob I* ints\n  lset ints $idx $newval\n  binary format I* $ints\n}\ndb func set_int set_int\n\nproc get_int {blob idx} {\n  binary scan $blob I* ints\n  lindex $ints $idx\n}\ndb func get_int get_int\n\ndo_execsql_test 1.7 {\n  BEGIN;\n    UPDATE sqlite_dbpage \n      SET data = set_int(data, 1, get_int(data, 1)-1) \n      WHERE pgno=4861;\n    SELECT checkfreelist('main');\n  ROLLBACK;\n} {{free-list count mismatch: actual=6725 header=6726}}\n\ndo_execsql_test 1.8 {\n  BEGIN;\n    UPDATE sqlite_dbpage \n      SET data = set_int(data, 5, (SELECT * FROM pragma_page_count)+1)\n      WHERE pgno=4861;\n    SELECT checkfreelist('main');\n  ROLLBACK;\n} {{leaf page 10093 is out of range (child 3 of trunk page 4861)}}\n\ndo_execsql_test 1.9 {\n  BEGIN;\n    UPDATE sqlite_dbpage \n      SET data = set_int(data, 5, 0)\n      WHERE pgno=4861;\n    SELECT checkfreelist('main');\n  ROLLBACK;\n} {{leaf page 0 is out of range (child 3 of trunk page 4861)}}\n\ndo_execsql_test 1.10 {\n  BEGIN;\n    UPDATE sqlite_dbpage \n      SET data = set_int(data, get_int(data, 1)+1, 0)\n      WHERE pgno=5;\n    SELECT checkfreelist('main');\n  ROLLBACK;\n} {{leaf page 0 is out of range (child 247 of trunk page 5)}}\n\ndo_execsql_test 1.11 {\n  BEGIN;\n    UPDATE sqlite_dbpage \n      SET data = set_int(data, 1, 249)\n      WHERE pgno=5;\n    SELECT checkfreelist('main');\n  ROLLBACK;\n} {{leaf count out of range (249) on trunk page 5}}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/close.test",
    "content": "# 2013 May 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test some specific circumstances to do with shared cache mode.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix close\n\n# This module bypasses the \"-key\" logic in tester.tcl, so it cannot run\n# with the codec enabled.\ndo_not_use_codec\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES('one');\n  INSERT INTO t1 VALUES('two');\n  INSERT INTO t1 VALUES('three');\n}\ndb close\n\ndo_test 1.1 {\n  set DB [sqlite3_open test.db]\n  sqlite3_close_v2 $DB\n} {SQLITE_OK}\n\ndo_test 1.2.1 {\n  set DB [sqlite3_open test.db]\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM t1\" -1 dummy]\n  sqlite3_close_v2 $DB\n} {SQLITE_OK}\ndo_test 1.2.2 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\ndo_test 1.3.1 {\n  set DB [sqlite3_open test.db]\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM t1\" -1 dummy]\n  sqlite3_step $STMT\n  sqlite3_close_v2 $DB\n} {SQLITE_OK}\n\ndo_test 1.3.2 {\n  sqlite3_column_text $STMT 0\n} {one}\n\ndo_test 1.3.3 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\ndo_test 1.4.1 {\n  set DB [sqlite3_open test.db]\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM t1\" -1 dummy]\n  sqlite3_step $STMT\n  sqlite3_close_v2 $DB\n} {SQLITE_OK}\n\ndo_test 1.4.2 {\n  list [sqlite3_step $STMT] [sqlite3_column_text $STMT 0]\n} {SQLITE_ROW two}\n\ndo_test 1.4.3 {\n  list [catch {\n    sqlite3_prepare $DB \"SELECT * FROM sqlite_master\" -1 dummy\n  } msg] $msg\n} {1 {(21) bad parameter or other API misuse}}\n\ndo_test 1.4.4 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/closure01.test",
    "content": "# 2013-04-25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases for transitive_closure virtual table.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix closure01\n\nifcapable !vtab||!cte { finish_test ; return }\n\nload_static_extension db closure\n\ndo_execsql_test 1.0 {\n  BEGIN;\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y INTEGER);\n  WITH RECURSIVE\n    cnt(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM cnt LIMIT 131072)\n  INSERT INTO t1(x, y) SELECT i, nullif(i,1)/2 FROM cnt;\n  CREATE INDEX t1y ON t1(y);\n  COMMIT;\n  CREATE VIRTUAL TABLE cx \n   USING transitive_closure(tablename=t1, idcolumn=x, parentcolumn=y);\n} {}\n\n# The entire table\ndo_timed_execsql_test 1.1 {\n  SELECT count(*), depth FROM cx WHERE root=1 GROUP BY depth ORDER BY 1;\n} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}\ndo_timed_execsql_test 1.1-cte {\n  WITH RECURSIVE\n    below(id,depth) AS (\n      VALUES(1,0)\n       UNION ALL\n      SELECT t1.x, below.depth+1\n        FROM t1 JOIN below on t1.y=below.id\n    )\n  SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1;\n} {/1 0 1 17 2 1 4 2 8 3 16 4 .* 65536 16/}\n\n# descendents of 32768\ndo_timed_execsql_test 1.2 {\n  SELECT * FROM cx WHERE root=32768 ORDER BY id;\n} {32768 0 65536 1 65537 1 131072 2}\ndo_timed_execsql_test 1.2-cte {\n  WITH RECURSIVE\n    below(id,depth) AS (\n      VALUES(32768,0)\n       UNION ALL\n      SELECT t1.x, below.depth+1\n        FROM t1 JOIN below on t1.y=below.id\n       WHERE below.depth<2\n    )\n  SELECT id, depth FROM below ORDER BY id;\n} {32768 0 65536 1 65537 1 131072 2}\n\n# descendents of 16384\ndo_timed_execsql_test 1.3 {\n  SELECT * FROM cx WHERE root=16384 AND depth<=2 ORDER BY id;\n} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}\ndo_timed_execsql_test 1.3-cte {\n  WITH RECURSIVE\n    below(id,depth) AS (\n      VALUES(16384,0)\n       UNION ALL\n      SELECT t1.x, below.depth+1\n        FROM t1 JOIN below on t1.y=below.id\n       WHERE below.depth<2\n    )\n  SELECT id, depth FROM below ORDER BY id;\n} {16384 0 32768 1 32769 1 65536 2 65537 2 65538 2 65539 2}\n\n# children of 16384\ndo_execsql_test 1.4 {\n  SELECT id, depth, root, tablename, idcolumn, parentcolumn FROM cx\n   WHERE root=16384\n     AND depth=1\n   ORDER BY id;\n} {32768 1 {} t1 x y 32769 1 {} t1 x y}\n\n# great-grandparent of 16384\ndo_timed_execsql_test 1.5 {\n  SELECT id, depth, root, tablename, idcolumn, parentcolumn FROM cx\n   WHERE root=16384\n     AND depth=3\n     AND idcolumn='Y'\n     AND parentcolumn='X';\n} {2048 3 {} t1 Y X}\ndo_timed_execsql_test 1.5-cte {\n  WITH RECURSIVE\n    above(id,depth) AS (\n      VALUES(16384,0)\n      UNION ALL\n      SELECT t1.y, above.depth+1\n        FROM t1 JOIN above ON t1.x=above.id\n       WHERE above.depth<3\n    )\n  SELECT id FROM above WHERE depth=3;\n} {2048}\n\n# depth<5\ndo_timed_execsql_test 1.6 {\n  SELECT count(*), depth FROM cx WHERE root=1 AND depth<5\n   GROUP BY depth ORDER BY 1;\n} {1 0 2 1 4 2 8 3 16 4}\ndo_timed_execsql_test 1.6-cte {\n  WITH RECURSIVE\n    below(id,depth) AS (\n      VALUES(1,0)\n      UNION ALL\n      SELECT t1.x, below.depth+1\n        FROM t1 JOIN below ON t1.y=below.id\n       WHERE below.depth<4\n    )\n  SELECT count(*), depth FROM below GROUP BY depth ORDER BY 1;\n} {1 0 2 1 4 2 8 3 16 4}\n\n# depth<=5\ndo_execsql_test 1.7 {\n  SELECT count(*), depth FROM cx WHERE root=1 AND depth<=5\n   GROUP BY depth ORDER BY 1;\n} {1 0 2 1 4 2 8 3 16 4 32 5}\n\n# depth==5\ndo_execsql_test 1.8 {\n  SELECT count(*), depth FROM cx WHERE root=1 AND depth=5\n   GROUP BY depth ORDER BY 1;\n} {32 5}\n\n# depth BETWEEN 3 AND 5\ndo_execsql_test 1.9 {\n  SELECT count(*), depth FROM cx WHERE root=1 AND depth BETWEEN 3 AND 5\n   GROUP BY depth ORDER BY 1;\n} {8 3 16 4 32 5}\n\n# depth==5 with min() and max()\ndo_timed_execsql_test 1.10 {\n  SELECT count(*), min(id), max(id) FROM cx WHERE root=1 AND depth=5;\n} {32 32 63}\ndo_timed_execsql_test 1.10-cte {\n  WITH RECURSIVE\n    below(id,depth) AS (\n      VALUES(1,0)\n      UNION ALL\n      SELECT t1.x, below.depth+1\n        FROM t1 JOIN below ON t1.y=below.id\n       WHERE below.depth<5\n    )\n  SELECT count(*), min(id), max(id) FROM below WHERE depth=5;\n} {32 32 63}\n\n# Create a much smaller table t2 with only 32 elements \ndb eval {\n  CREATE TABLE t2(x INTEGER PRIMARY KEY, y INTEGER);\n  INSERT INTO t2 SELECT x, y FROM t1 WHERE x<32;\n  CREATE INDEX t2y ON t2(y);\n  CREATE VIRTUAL TABLE c2 \n   USING transitive_closure(tablename=t2, idcolumn=x, parentcolumn=y);\n}\n\n# t2 full-table\ndo_execsql_test 2.1 {\n  SELECT count(*), min(id), max(id) FROM c2 WHERE root=1;\n} {31 1 31}\n# t2 root=10\ndo_execsql_test 2.2 {\n  SELECT id FROM c2 WHERE root=10;\n} {10 20 21}\n# t2 root=11\ndo_execsql_test 2.3 {\n  SELECT id FROM c2 WHERE root=12;\n} {12 24 25}\n# t2 root IN [10,12]\ndo_execsql_test 2.4 {\n  SELECT id FROM c2 WHERE root IN (10,12) ORDER BY id;\n} {10 12 20 21 24 25}\n# t2 root IN [10,12] (sorted)\ndo_execsql_test 2.5 {\n  SELECT id FROM c2 WHERE root IN (10,12) ORDER BY +id;\n} {10 12 20 21 24 25}\n\n# t2 c2up from 20\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE c2up USING transitive_closure(\n    tablename = t2,\n    idcolumn = y,\n    parentcolumn = x\n  );\n  SELECT id FROM c2up WHERE root=20;\n} {1 2 5 10 20}\n\n# cx as c2up\ndo_execsql_test 3.1 {\n  SELECT id FROM cx\n   WHERE root=20\n     AND tablename='t2'\n     AND idcolumn='y'\n     AND parentcolumn='x';\n} {1 2 5 10 20}\n\n# t2 first cousins of 20\ndo_execsql_test 3.2 {\n  SELECT DISTINCT id FROM c2\n   WHERE root IN (SELECT id FROM c2up\n                   WHERE root=20 AND depth<=2)\n   ORDER BY id;\n} {5 10 11 20 21 22 23}\n\n# t2 first cousins of 20\ndo_execsql_test 3.3 {\n  SELECT id FROM c2\n   WHERE root=(SELECT id FROM c2up\n               WHERE root=20 AND depth=2)\n     AND depth=2\n  EXCEPT\n  SELECT id FROM c2\n   WHERE root=(SELECT id FROM c2up\n               WHERE root=20 AND depth=1)\n     AND depth<=1\n   ORDER BY id;\n} {22 23}\n\n# missing tablename.\ndo_test 4.1 {\n  catchsql {\n    SELECT id FROM cx\n     WHERE root=20\n       AND tablename='t3'\n       AND idcolumn='y'\n       AND parentcolumn='x';\n  }\n} {1 {no such table: t3}}\n\n# missing idcolumn\ndo_test 4.2 {\n  catchsql {\n    SELECT id FROM cx\n     WHERE root=20\n       AND tablename='t2'\n       AND idcolumn='xyz'\n       AND parentcolumn='x';\n  }\n} {1 {no such column: t2.xyz}}\n\n# missing parentcolumn\ndo_test 4.3 {\n  catchsql {\n    SELECT id FROM cx\n     WHERE root=20\n       AND tablename='t2'\n       AND idcolumn='x'\n       AND parentcolumn='pqr';\n  }\n} {1 {no such column: t2.pqr}}\n\n# generic closure\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE temp.closure USING transitive_closure;\n  SELECT id FROM closure\n   WHERE root=1\n     AND depth=3\n     AND tablename='t1'\n     AND idcolumn='x'\n     AND parentcolumn='y'\n  ORDER BY id;\n} {8 9 10 11 12 13 14 15}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/coalesce.test",
    "content": "# 2009 November 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Additional test cases for the COALESCE() and IFNULL() functions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\ndo_test coalesce-1.0 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n    INSERT INTO t1 VALUES(1, null, null, null);\n    INSERT INTO t1 VALUES(2, 2, 99, 99);\n    INSERT INTO t1 VALUES(3, null, 3, 99);\n    INSERT INTO t1 VALUES(4, null, null, 4);\n    INSERT INTO t1 VALUES(5, null, null, null);\n    INSERT INTO t1 VALUES(6, 22, 99, 99);\n    INSERT INTO t1 VALUES(7, null, 33, 99);\n    INSERT INTO t1 VALUES(8, null, null, 44);\n\n    SELECT coalesce(b,c,d) FROM t1 ORDER BY a;\n  }\n} {{} 2 3 4 {} 22 33 44}\ndo_test coalesce-1.1 {\n  db eval {\n    SELECT coalesce(d+c+b,d+c,d) FROM t1 ORDER BY a;\n  }\n} {{} 200 102 4 {} 220 132 44}\ndo_test coalesce-1.2 {\n  db eval {\n    SELECT ifnull(d+c+b,ifnull(d+c,d)) FROM t1 ORDER BY a;\n  }\n} {{} 200 102 4 {} 220 132 44}\ndo_test coalesce-1.3 {\n  db eval {\n    SELECT ifnull(ifnull(d+c+b,d+c),d) FROM t1 ORDER BY a;\n  }\n} {{} 200 102 4 {} 220 132 44}\ndo_test coalesce-1.4 {\n  db eval {\n    SELECT ifnull(ifnull(b,c),d) FROM t1 ORDER BY a;\n  }\n} {{} 2 3 4 {} 22 33 44}\ndo_test coalesce-1.5 {\n  db eval {\n    SELECT ifnull(b,ifnull(c,d)) FROM t1 ORDER BY a;\n  }\n} {{} 2 3 4 {} 22 33 44}\ndo_test coalesce-1.6 {\n  db eval {\n    SELECT coalesce(b,NOT b,-b,abs(b),lower(b),length(b),min(b,5),b*123,c)\n      FROM t1 ORDER BY a;\n  }\n} {{} 2 3 {} {} 22 33 {}}\ndo_test coalesce-1.7 {\n  db eval {\n    SELECT ifnull(nullif(a,4),99)\n      FROM t1 ORDER BY a;\n  }\n} {1 2 3 99 5 6 7 8}\ndo_test coalesce-1.8 {\n  db eval {\npragma vdbe_listing=on;\n    SELECT coalesce(\n      CASE WHEN b=2 THEN 123 END,\n      CASE WHEN b=3 THEN 234 END,\n      CASE WHEN c=3 THEN 345 WHEN c=33 THEN 456 END,\n      d\n    )\n    FROM t1 ORDER BY a;\n  }\n} {{} 123 345 4 {} 99 456 44}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate1.test",
    "content": "#\n# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing collation sequences.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix collate1\n\n#\n# Tests are roughly organised as follows:\n#\n# collate1-1.* - Single-field ORDER BY with an explicit COLLATE clause.\n# collate1-2.* - Multi-field ORDER BY with an explicit COLLATE clause.\n# collate1-3.* - ORDER BY using a default collation type. Also that an \n#                explict collate type overrides a default collate type.\n# collate1-4.* - ORDER BY using a data type.\n#\n\n#\n# Collation type 'HEX'. If an argument can be interpreted as a hexadecimal\n# number, then it is converted to one before the comparison is performed. \n# Numbers are less than other strings. If neither argument is a number, \n# [string compare] is used.\n#\ndb collate HEX hex_collate\nproc hex_collate {lhs rhs} {\n  set lhs_ishex [regexp {^(0x|)[1234567890abcdefABCDEF]+$} $lhs]\n  set rhs_ishex [regexp {^(0x|)[1234567890abcdefABCDEF]+$} $rhs]\n  if {$lhs_ishex && $rhs_ishex} { \n    set lhsx [scan $lhs %x]\n    set rhsx [scan $rhs %x]\n    if {$lhs < $rhs} {return -1}\n    if {$lhs == $rhs} {return 0}\n    if {$lhs > $rhs} {return 1}\n  }\n  if {$lhs_ishex} {\n    return -1;\n  }\n  if {$rhs_ishex} {\n    return 1;\n  }\n  return [string compare $lhs $rhs]\n}\ndb function hex {format 0x%X}\n\n# Mimic the SQLite 2 collation type NUMERIC.\ndb collate numeric numeric_collate\nproc numeric_collate {lhs rhs} {\n  if {$lhs == $rhs} {return 0} \n  return [expr ($lhs>$rhs)?1:-1]\n}\n\ndo_test collate1-1.0 {\n  execsql {\n    CREATE TABLE collate1t1(c1, c2);\n    INSERT INTO collate1t1 VALUES(45, hex(45));\n    INSERT INTO collate1t1 VALUES(NULL, NULL);\n    INSERT INTO collate1t1 VALUES(281, hex(281));\n  }\n} {}\ndo_test collate1-1.1 {\n  execsql {\n    SELECT c2 FROM collate1t1 ORDER BY 1;\n  }\n} {{} 0x119 0x2D}\ndo_test collate1-1.2 {\n  execsql {\n    SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex;\n  }\n} {{} 0x2D 0x119}\ndo_test collate1-1.3 {\n  execsql {\n    SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex DESC;\n  }\n} {0x119 0x2D {}}\ndo_test collate1-1.4 {\n  execsql {\n   SELECT c2 FROM collate1t1 ORDER BY 1 COLLATE hex ASC;\n  }\n} {{} 0x2D 0x119}\ndo_test collate1-1.5 {\n  execsql {\n    SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1\n  }\n} {{} 0x2D 0x119}\ndo_test collate1-1.6 {\n  execsql {\n    SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1 ASC\n  }\n} {{} 0x2D 0x119}\ndo_test collate1-1.7 {\n  execsql {\n    SELECT c2 COLLATE hex FROM collate1t1 ORDER BY 1 DESC\n  }\n} {0x119 0x2D {}}\ndo_test collate1-1.99 {\n  execsql {\n    DROP TABLE collate1t1;\n  }\n} {}\n\ndo_test collate1-2.0 {\n  execsql {\n    CREATE TABLE collate1t1(c1, c2);\n    INSERT INTO collate1t1 VALUES('5', '0x11');\n    INSERT INTO collate1t1 VALUES('5', '0xA');\n    INSERT INTO collate1t1 VALUES(NULL, NULL);\n    INSERT INTO collate1t1 VALUES('7', '0xA');\n    INSERT INTO collate1t1 VALUES('11', '0x11');\n    INSERT INTO collate1t1 VALUES('11', '0x101');\n  }\n} {}\ndo_test collate1-2.2 {\n  execsql {\n    SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE numeric, 2 COLLATE hex;\n  }\n} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}\ndo_test collate1-2.3 {\n  execsql {\n    SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE binary, 2 COLLATE hex;\n  }\n} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}\ndo_test collate1-2.4 {\n  execsql {\n    SELECT c1, c2 FROM collate1t1 ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex;\n  }\n} {7 0xA 5 0xA 5 0x11 11 0x11 11 0x101 {} {}}\ndo_test collate1-2.5 {\n  execsql {\n    SELECT c1, c2 FROM collate1t1 \n        ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex DESC;\n  }\n} {7 0xA 5 0x11 5 0xA 11 0x101 11 0x11 {} {}}\ndo_test collate1-2.6 {\n  execsql {\n    SELECT c1, c2 FROM collate1t1 \n        ORDER BY 1 COLLATE binary ASC, 2 COLLATE hex ASC;\n  }\n} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}\ndo_test collate1-2.12.1 {\n  execsql {\n    SELECT c1 COLLATE numeric, c2 FROM collate1t1 \n     ORDER BY 1, 2 COLLATE hex;\n  }\n} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}\ndo_test collate1-2.12.2 {\n  execsql {\n    SELECT c1 COLLATE hex, c2 FROM collate1t1 \n     ORDER BY 1 COLLATE numeric, 2 COLLATE hex;\n  }\n} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}\ndo_test collate1-2.12.3 {\n  execsql {\n    SELECT c1, c2 COLLATE hex FROM collate1t1 \n     ORDER BY 1 COLLATE numeric, 2;\n  }\n} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}\ndo_test collate1-2.12.4 {\n  execsql {\n    SELECT c1 COLLATE numeric, c2 COLLATE hex\n      FROM collate1t1 \n     ORDER BY 1, 2;\n  }\n} {{} {} 5 0xA 5 0x11 7 0xA 11 0x11 11 0x101}\ndo_test collate1-2.13 {\n  execsql {\n    SELECT c1 COLLATE binary, c2 COLLATE hex\n      FROM collate1t1\n     ORDER BY 1, 2;\n  }\n} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}\ndo_test collate1-2.14 {\n  execsql {\n    SELECT c1, c2\n      FROM collate1t1 ORDER BY 1 COLLATE binary DESC, 2 COLLATE hex;\n  }\n} {7 0xA 5 0xA 5 0x11 11 0x11 11 0x101 {} {}}\ndo_test collate1-2.15 {\n  execsql {\n    SELECT c1 COLLATE binary, c2 COLLATE hex\n      FROM collate1t1 \n     ORDER BY 1 DESC, 2 DESC;\n  }\n} {7 0xA 5 0x11 5 0xA 11 0x101 11 0x11 {} {}}\ndo_test collate1-2.16 {\n  execsql {\n    SELECT c1 COLLATE hex, c2 COLLATE binary\n      FROM collate1t1 \n     ORDER BY 1 COLLATE binary ASC, 2 COLLATE hex ASC;\n  }\n} {{} {} 11 0x11 11 0x101 5 0xA 5 0x11 7 0xA}\ndo_test collate1-2.99 {\n  execsql {\n    DROP TABLE collate1t1;\n  }\n} {}\n\n#\n# These tests ensure that the default collation type for a column is used \n# by an ORDER BY clause correctly. The focus is all the different ways\n# the column can be referenced. i.e. a, collate2t1.a, main.collate2t1.a etc.\n#\ndo_test collate1-3.0 {\n  execsql {\n    CREATE TABLE collate1t1(a COLLATE hex, b);\n    INSERT INTO collate1t1 VALUES( '0x5', 5 );\n    INSERT INTO collate1t1 VALUES( '1', 1 );\n    INSERT INTO collate1t1 VALUES( '0x45', 69 );\n    INSERT INTO collate1t1 VALUES( NULL, NULL );\n    SELECT * FROM collate1t1 ORDER BY a;\n  }\n} {{} {} 1 1 0x5 5 0x45 69}\n\ndo_test collate1-3.1 {\n  execsql {\n    SELECT * FROM collate1t1 ORDER BY 1;\n  }\n} {{} {} 1 1 0x5 5 0x45 69}\ndo_test collate1-3.2 {\n  execsql {\n    SELECT * FROM collate1t1 ORDER BY collate1t1.a;\n  }\n} {{} {} 1 1 0x5 5 0x45 69}\ndo_test collate1-3.3 {\n  execsql {\n    SELECT * FROM collate1t1 ORDER BY main.collate1t1.a;\n  }\n} {{} {} 1 1 0x5 5 0x45 69}\ndo_test collate1-3.4 {\n  execsql {\n    SELECT a as c1, b as c2 FROM collate1t1 ORDER BY c1;\n  }\n} {{} {} 1 1 0x5 5 0x45 69}\ndo_test collate1-3.5 {\n  execsql {\n    SELECT a as c1, b as c2 FROM collate1t1 ORDER BY c1 COLLATE binary;\n  }\n} {{} {} 0x45 69 0x5 5 1 1}\ndo_test collate1-3.5.1 {\n  execsql {\n    SELECT a COLLATE binary as c1, b as c2\n      FROM collate1t1 ORDER BY c1;\n  }\n} {{} {} 0x45 69 0x5 5 1 1}\ndo_test collate1-3.6 {\n  execsql {\n    DROP TABLE collate1t1;\n  }\n} {}\n\n# Update for SQLite version 3. The collate1-4.* test cases were written\n# before manifest types were introduced. The following test cases still\n# work, due to the 'affinity' mechanism, but they don't prove anything\n# about collation sequences.\n#\ndo_test collate1-4.0 {\n  execsql {\n    CREATE TABLE collate1t1(c1 numeric, c2 text);\n    INSERT INTO collate1t1 VALUES(1, 1);\n    INSERT INTO collate1t1 VALUES(12, 12);\n    INSERT INTO collate1t1 VALUES(NULL, NULL);\n    INSERT INTO collate1t1 VALUES(101, 101);\n  }\n} {}\ndo_test collate1-4.1 {\n  execsql {\n    SELECT c1 FROM collate1t1 ORDER BY 1;\n  }\n} {{} 1 12 101}\ndo_test collate1-4.2 {\n  execsql {\n    SELECT c2 FROM collate1t1 ORDER BY 1;\n  }\n} {{} 1 101 12}\ndo_test collate1-4.3 {\n  execsql {\n    SELECT c2+0 FROM collate1t1 ORDER BY 1;\n  }\n} {{} 1 12 101}\ndo_test collate1-4.4 {\n  execsql {\n    SELECT c1||'' FROM collate1t1 ORDER BY 1;\n  }\n} {{} 1 101 12}\ndo_test collate1-4.4.1 {\n  execsql {\n    SELECT (c1||'') COLLATE numeric FROM collate1t1 ORDER BY 1;\n  }\n} {{} 1 12 101}\ndo_test collate1-4.5 {\n  execsql {\n    DROP TABLE collate1t1;\n  }\n} {}\n\n# A problem reported on the mailing list:  A CREATE TABLE statement\n# is allowed to have two or more COLLATE clauses on the same column.\n# That probably ought to be an error, but we allow it for backwards\n# compatibility.  Just make sure it works and doesn't leak memory.\n#\ndo_test collate1-5.1 {\n  execsql {\n    CREATE TABLE c5(\n      id INTEGER PRIMARY KEY,\n      a TEXT COLLATE binary COLLATE nocase COLLATE rtrim,\n      b TEXT COLLATE nocase COLLATE binary,\n      c TEXT COLLATE rtrim COLLATE binary COLLATE rtrim COLLATE nocase\n    );\n    INSERT INTO c5 VALUES(1, 'abc','abc','abc');\n    INSERT INTO c5 VALUES(2, 'abc   ','ABC','ABC');\n    SELECT id FROM c5 WHERE a='abc' ORDER BY id;\n  }\n} {1 2}\ndo_test collate1-5.2 {\n  execsql {\n    SELECT id FROM c5 WHERE b='abc' ORDER BY id;\n  }\n} {1}\ndo_test collate1-5.3 {\n  execsql {\n    SELECT id FROM c5 WHERE c='abc' ORDER BY id;\n  }\n} {1 2}\n\n\n\n#-------------------------------------------------------------------------\n# Fix problems with handling collation sequences named '\"\"\"'.\n#\ndo_execsql_test 6.1 {\n  SELECT \"\"\"\"\"\"\"\";\n} {\\\"\\\"\\\"}\n\ndo_catchsql_test 6.2 {\n  CREATE TABLE x1(a);\n  SELECT a FROM x1 ORDER BY a COLLATE \"\"\"\"\"\"\"\";\n} {1 {no such collation sequence: \"\"\"}}\n\ndo_catchsql_test 6.3 {\n  SELECT a FROM x1 ORDER BY 1 COLLATE \"\"\"\"\"\"\"\";\n} {1 {no such collation sequence: \"\"\"}}\n\ndo_catchsql_test 6.4 {\n  SELECT 0 UNION SELECT 0 ORDER BY 1 COLLATE \"\"\"\"\"\"\"\";\n} {1 {no such collation sequence: \"\"\"}}\n\ndb collate {\"\"\"} [list string compare -nocase]\n\ndo_execsql_test 6.5 {\n  PRAGMA foreign_keys = ON;\n  CREATE TABLE p1(a PRIMARY KEY COLLATE '\"\"\"');\n  CREATE TABLE c1(x, y REFERENCES p1);\n} {}\n\ndo_execsql_test 6.6 { \n  INSERT INTO p1 VALUES('abc'); \n  INSERT INTO c1 VALUES(1, 'ABC'); \n}\n\nifcapable foreignkey {\n  do_catchsql_test 6.7 { \n    DELETE FROM p1 WHERE rowid = 1 \n  } {1 {FOREIGN KEY constraint failed}}\n}\n\ndo_execsql_test 6.8 { \n  INSERT INTO p1 VALUES('abb');\n  INSERT INTO p1 VALUES('wxz');\n  INSERT INTO p1 VALUES('wxy');\n\n  INSERT INTO c1 VALUES(2, 'abb');\n  INSERT INTO c1 VALUES(3, 'wxz');\n  INSERT INTO c1 VALUES(4, 'WXY');\n  SELECT x, y FROM c1 ORDER BY y COLLATE \"\"\"\"\"\"\"\";\n} {2 abb 1 ABC 4 WXY 3 wxz}\n\n# 2015-04-15:  Nested COLLATE operators\n#\ndo_execsql_test 7.0 {\n   SELECT 'abc' UNION ALL SELECT 'DEF'\n    ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE nocase;\n} {abc DEF}\ndo_execsql_test 7.1 {\n   SELECT 'abc' UNION ALL SELECT 'DEF'\n    ORDER BY 1 COLLATE nocase COLLATE nocase COLLATE nocase COLLATE binary;\n} {DEF abc}\ndo_execsql_test 7.2 {\n   SELECT 'abc' UNION ALL SELECT 'DEF'\n    ORDER BY 1 COLLATE binary COLLATE binary COLLATE binary COLLATE nocase;\n} {abc DEF}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate2.test",
    "content": "#\n# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is page cache subsystem.\n#\n# $Id: collate2.test,v 1.6 2008/08/20 16:35:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix collate2\n\n#\n# Tests are organised as follows:\n#\n# collate2-1.* WHERE <expr> expressions (sqliteExprIfTrue).\n# collate2-2.* WHERE NOT <expr> expressions (sqliteExprIfFalse).\n# collate2-3.* SELECT <expr> expressions (sqliteExprCode).\n# collate2-4.* Precedence of collation/data types in binary comparisons\n# collate2-5.* JOIN syntax.\n#\n\n# Create a collation type BACKWARDS for use in testing. This collation type\n# is similar to the built-in TEXT collation type except the order of\n# characters in each string is reversed before the comparison is performed.\ndb collate BACKWARDS backwards_collate\nproc backwards_collate {a b} {\n  set ra {};\n  set rb {}\n  foreach c [split $a {}] { set ra $c$ra }\n  foreach c [split $b {}] { set rb $c$rb }\n  return [string compare $ra $rb]\n}\n\n# The following values are used in these tests:\n# NULL   aa ab ba bb   aA aB bA bB   Aa Ab Ba Bb   AA AB BA BB \n#\n# The collation orders for each of the tested collation types are:\n#\n# BINARY:    NULL  AA AB Aa Ab  BA BB Ba Bb  aA aB aa ab  bA bB ba bb \n# NOCASE:    NULL  aa aA Aa AA  ab aB Ab AB  ba bA Ba BA  bb bB Bb BB \n# BACKWARDS: NULL  AA BA aA bA  AB BB aB bB  Aa Ba aa ba  Ab Bb ab bb \n#\n# These tests verify that the default collation type for a column is used\n# for comparison operators (<, >, <=, >=, =) involving that column and \n# an expression that is not a column with a default collation type.\n# \n# The collation sequences BINARY and NOCASE are built-in, the BACKWARDS\n# collation sequence is implemented by the TCL proc backwards_collate\n# above.\n#\ndo_test collate2-1.0 {\n  execsql {\n    CREATE TABLE collate2t1(\n      a COLLATE BINARY, \n      b COLLATE NOCASE, \n      c COLLATE BACKWARDS\n    );\n    INSERT INTO collate2t1 VALUES( NULL, NULL, NULL );\n\n    INSERT INTO collate2t1 VALUES( 'aa', 'aa', 'aa' );\n    INSERT INTO collate2t1 VALUES( 'ab', 'ab', 'ab' );\n    INSERT INTO collate2t1 VALUES( 'ba', 'ba', 'ba' );\n    INSERT INTO collate2t1 VALUES( 'bb', 'bb', 'bb' );\n\n    INSERT INTO collate2t1 VALUES( 'aA', 'aA', 'aA' );\n    INSERT INTO collate2t1 VALUES( 'aB', 'aB', 'aB' );\n    INSERT INTO collate2t1 VALUES( 'bA', 'bA', 'bA' );\n    INSERT INTO collate2t1 VALUES( 'bB', 'bB', 'bB' );\n\n    INSERT INTO collate2t1 VALUES( 'Aa', 'Aa', 'Aa' );\n    INSERT INTO collate2t1 VALUES( 'Ab', 'Ab', 'Ab' );\n    INSERT INTO collate2t1 VALUES( 'Ba', 'Ba', 'Ba' );\n    INSERT INTO collate2t1 VALUES( 'Bb', 'Bb', 'Bb' );\n\n    INSERT INTO collate2t1 VALUES( 'AA', 'AA', 'AA' );\n    INSERT INTO collate2t1 VALUES( 'AB', 'AB', 'AB' );\n    INSERT INTO collate2t1 VALUES( 'BA', 'BA', 'BA' );\n    INSERT INTO collate2t1 VALUES( 'BB', 'BB', 'BB' );\n  }\n  if {[info exists collate_test_use_index]} { \n    execsql {\n      CREATE INDEX collate2t1_i1 ON collate2t1(a);\n      CREATE INDEX collate2t1_i2 ON collate2t1(b);\n      CREATE INDEX collate2t1_i3 ON collate2t1(c);\n    }\n  }\n} {}\ndo_test collate2-1.1 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a > 'aa' ORDER BY 1;\n  }\n} {ab bA bB ba bb}\ndo_test collate2-1.1.1 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a COLLATE binary > 'aa' ORDER BY 1;\n  }\n} {ab bA bB ba bb}\ndo_test collate2-1.1.2 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE b COLLATE binary > 'aa' ORDER BY 1;\n  }\n} {ab bA bB ba bb}\ndo_test collate2-1.1.3 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE c COLLATE binary > 'aa' ORDER BY 1;\n  }\n} {ab bA bB ba bb}\ndo_test collate2-1.2 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY 1, oid;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.1 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa'\n     ORDER BY 1, oid;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.2 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa'\n     ORDER BY 1, oid;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.3 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa'\n     ORDER BY 1, oid;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.4 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY +b;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.5 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa' ORDER BY +b;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.6 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa' ORDER BY +b;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.2.7 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa' ORDER BY +b;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.3 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c > 'aa' ORDER BY 1;\n  }\n} {ba Ab Bb ab bb}\ndo_test collate2-1.3.1 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE a COLLATE backwards > 'aa'\n    ORDER BY 1;\n  }\n} {ba Ab Bb ab bb}\ndo_test collate2-1.3.2 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE b COLLATE backwards > 'aa'\n    ORDER BY 1;\n  }\n} {ba Ab Bb ab bb}\ndo_test collate2-1.3.3 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c COLLATE backwards > 'aa'\n    ORDER BY 1;\n  }\n} {ba Ab Bb ab bb}\ndo_test collate2-1.4 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a < 'aa' ORDER BY 1;\n  }\n} {AA AB Aa Ab BA BB Ba Bb aA aB}\ndo_test collate2-1.5 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY 1, oid;\n  }\n} {}\ndo_test collate2-1.5.1 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY +b;\n  }\n} {}\ndo_test collate2-1.6 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c < 'aa' ORDER BY 1;\n  }\n} {AA BA aA bA AB BB aB bB Aa Ba}\ndo_test collate2-1.7 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a = 'aa';\n  }\n} {aa}\ndo_test collate2-1.8 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b = 'aa' ORDER BY oid;\n  }\n} {aa aA Aa AA}\ndo_test collate2-1.9 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c = 'aa';\n  }\n} {aa}\ndo_test collate2-1.10 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a >= 'aa' ORDER BY 1;\n  }\n} {aa ab bA bB ba bb}\ndo_test collate2-1.11 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b >= 'aa' ORDER BY 1, oid;\n  }\n} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.12 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c >= 'aa' ORDER BY 1;\n  }\n} {aa ba Ab Bb ab bb}\ndo_test collate2-1.13 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a <= 'aa' ORDER BY 1;\n  }\n} {AA AB Aa Ab BA BB Ba Bb aA aB aa}\ndo_test collate2-1.14 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b <= 'aa' ORDER BY 1, oid;\n  }\n} {aa aA Aa AA}\ndo_test collate2-1.15 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c <= 'aa' ORDER BY 1;\n  }\n} {AA BA aA bA AB BB aB bB Aa Ba aa}\ndo_test collate2-1.16 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a BETWEEN 'Aa' AND 'Bb' ORDER BY 1;\n  }\n} {Aa Ab BA BB Ba Bb}\ndo_test collate2-1.17 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;\n  }\n} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.17.1 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY +b;\n  }\n} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-1.18 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c BETWEEN 'Aa' AND 'Bb' ORDER BY 1;\n  }\n} {Aa Ba aa ba Ab Bb}\ndo_test collate2-1.19 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE \n      CASE a WHEN 'aa' THEN 1 ELSE 0 END\n        ORDER BY 1, oid;\n  }\n} {aa}\ndo_test collate2-1.20 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE \n      CASE b WHEN 'aa' THEN 1 ELSE 0 END\n        ORDER BY 1, oid;\n  }\n} {aa aA Aa AA}\ndo_test collate2-1.21 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE \n      CASE c WHEN 'aa' THEN 1 ELSE 0 END\n        ORDER BY 1, oid;\n  }\n} {aa}\n\nifcapable subquery {\n  do_test collate2-1.22 {\n    execsql {\n      SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb') ORDER BY 1, oid;\n    }\n  } {aa bb}\n  do_test collate2-1.23 {\n    execsql {\n      SELECT b FROM collate2t1 WHERE b IN ('aa', 'bb') ORDER BY 1, oid;\n    }\n  } {aa aA Aa AA bb bB Bb BB}\n  do_test collate2-1.24 {\n    execsql {\n      SELECT c FROM collate2t1 WHERE c IN ('aa', 'bb') ORDER BY 1, oid;\n    }\n  } {aa bb}\n  do_test collate2-1.25 {\n    execsql {\n      SELECT a FROM collate2t1 \n        WHERE a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {aa bb}\n  do_test collate2-1.26 {\n    execsql {\n      SELECT b FROM collate2t1 \n        WHERE b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {aa bb aA bB Aa Bb AA BB}\n  do_test collate2-1.27 {\n    execsql {\n      SELECT c FROM collate2t1 \n        WHERE c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {aa bb}\n} ;# ifcapable subquery\n\ndo_test collate2-2.1 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT a > 'aa' ORDER BY 1;\n  }\n} {AA AB Aa Ab BA BB Ba Bb aA aB aa}\ndo_test collate2-2.2 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT b > 'aa' ORDER BY 1, oid;\n  }\n} {aa aA Aa AA}\ndo_test collate2-2.3 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT c > 'aa' ORDER BY 1;\n  }\n} {AA BA aA bA AB BB aB bB Aa Ba aa}\ndo_test collate2-2.4 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT a < 'aa' ORDER BY 1;\n  }\n} {aa ab bA bB ba bb}\ndo_test collate2-2.5 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT b < 'aa' ORDER BY 1, oid;\n  }\n} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-2.6 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT c < 'aa' ORDER BY 1;\n  }\n} {aa ba Ab Bb ab bb}\ndo_test collate2-2.7 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT a = 'aa';\n  }\n} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\ndo_test collate2-2.8 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT b = 'aa';\n  }\n} {ab ba bb aB bA bB Ab Ba Bb AB BA BB}\ndo_test collate2-2.9 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT c = 'aa';\n  }\n} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\ndo_test collate2-2.10 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT a >= 'aa' ORDER BY 1;\n  }\n} {AA AB Aa Ab BA BB Ba Bb aA aB}\ndo_test collate2-2.11 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT b >= 'aa' ORDER BY 1, oid;\n  }\n} {}\ndo_test collate2-2.12 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT c >= 'aa' ORDER BY 1;\n  }\n} {AA BA aA bA AB BB aB bB Aa Ba}\ndo_test collate2-2.13 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT a <= 'aa' ORDER BY 1;\n  }\n} {ab bA bB ba bb}\ndo_test collate2-2.14 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT b <= 'aa' ORDER BY 1, oid;\n  }\n} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}\ndo_test collate2-2.15 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT c <= 'aa' ORDER BY 1;\n  }\n} {ba Ab Bb ab bb}\ndo_test collate2-2.16 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE a NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;\n  }\n} {AA AB aA aB aa ab bA bB ba bb}\ndo_test collate2-2.17 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE b NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;\n  }\n} {}\ndo_test collate2-2.18 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE c NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;\n  }\n} {AA BA aA bA AB BB aB bB ab bb}\ndo_test collate2-2.19 {\n  execsql {\n    SELECT a FROM collate2t1 WHERE NOT CASE a WHEN 'aa' THEN 1 ELSE 0 END;\n  }\n} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\ndo_test collate2-2.20 {\n  execsql {\n    SELECT b FROM collate2t1 WHERE NOT CASE b WHEN 'aa' THEN 1 ELSE 0 END;\n  }\n} {{} ab ba bb aB bA bB Ab Ba Bb AB BA BB}\ndo_test collate2-2.21 {\n  execsql {\n    SELECT c FROM collate2t1 WHERE NOT CASE c WHEN 'aa' THEN 1 ELSE 0 END;\n  }\n} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\n\nifcapable subquery {\n  do_test collate2-2.22 {\n    execsql {\n      SELECT a FROM collate2t1 WHERE NOT a IN ('aa', 'bb');\n    }\n  } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\n  do_test collate2-2.23 {\n    execsql {\n      SELECT b FROM collate2t1 WHERE NOT b IN ('aa', 'bb');\n    }\n  } {ab ba aB bA Ab Ba AB BA}\n  do_test collate2-2.24 {\n    execsql {\n      SELECT c FROM collate2t1 WHERE NOT c IN ('aa', 'bb');\n    }\n  } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\n  do_test collate2-2.25 {\n    execsql {\n      SELECT a FROM collate2t1 \n        WHERE NOT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\n  do_test collate2-2.26 {\n    execsql {\n      SELECT b FROM collate2t1 \n        WHERE NOT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {ab ba aB bA Ab Ba AB BA}\n  do_test collate2-2.27 {\n    execsql {\n      SELECT c FROM collate2t1 \n        WHERE NOT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));\n    }\n  } {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}\n}\n\ndo_test collate2-3.1 {\n  execsql {\n    SELECT a > 'aa' FROM collate2t1;\n  }\n} {{} 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}\ndo_test collate2-3.2 {\n  execsql {\n    SELECT b > 'aa' FROM collate2t1;\n  }\n} {{} 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1}\ndo_test collate2-3.3 {\n  execsql {\n    SELECT c > 'aa' FROM collate2t1;\n  }\n} {{} 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}\ndo_test collate2-3.4 {\n  execsql {\n    SELECT a < 'aa' FROM collate2t1;\n  }\n} {{} 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}\ndo_test collate2-3.5 {\n  execsql {\n    SELECT b < 'aa' FROM collate2t1;\n  }\n} {{} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}\ndo_test collate2-3.6 {\n  execsql {\n    SELECT c < 'aa' FROM collate2t1;\n  }\n} {{} 0 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}\ndo_test collate2-3.7 {\n  execsql {\n    SELECT a = 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}\ndo_test collate2-3.8 {\n  execsql {\n    SELECT b = 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}\ndo_test collate2-3.9 {\n  execsql {\n    SELECT c = 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}\ndo_test collate2-3.10 {\n  execsql {\n    SELECT a <= 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}\ndo_test collate2-3.11 {\n  execsql {\n    SELECT b <= 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}\ndo_test collate2-3.12 {\n  execsql {\n    SELECT c <= 'aa' FROM collate2t1;\n  }\n} {{} 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}\ndo_test collate2-3.13 {\n  execsql {\n    SELECT a >= 'aa' FROM collate2t1;\n  }\n} {{} 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}\ndo_test collate2-3.14 {\n  execsql {\n    SELECT b >= 'aa' FROM collate2t1;\n  }\n} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}\ndo_test collate2-3.15 {\n  execsql {\n    SELECT c >= 'aa' FROM collate2t1;\n  }\n} {{} 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}\ndo_test collate2-3.16 {\n  execsql {\n    SELECT a BETWEEN 'Aa' AND 'Bb' FROM collate2t1;\n  }\n} {{} 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1}\ndo_test collate2-3.17 {\n  execsql {\n    SELECT b BETWEEN 'Aa' AND 'Bb' FROM collate2t1;\n  }\n} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}\ndo_test collate2-3.18 {\n  execsql {\n    SELECT c BETWEEN 'Aa' AND 'Bb' FROM collate2t1;\n  }\n} {{} 1 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0}\ndo_test collate2-3.19 {\n  execsql {\n    SELECT CASE a WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;\n  }\n} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}\ndo_test collate2-3.20 {\n  execsql {\n    SELECT CASE b WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;\n  }\n} {0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}\ndo_test collate2-3.21 {\n  execsql {\n    SELECT CASE c WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;\n  }\n} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}\n\nifcapable subquery {\n  do_test collate2-3.22 {\n    execsql {\n      SELECT a IN ('aa', 'bb') FROM collate2t1;\n    }\n  } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}\n  do_test collate2-3.23 {\n    execsql {\n      SELECT b IN ('aa', 'bb') FROM collate2t1;\n    }\n  } {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}\n  do_test collate2-3.24 {\n    execsql {\n      SELECT c IN ('aa', 'bb') FROM collate2t1;\n    }\n  } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}\n  do_test collate2-3.25 {\n    execsql {\n      SELECT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb')) \n        FROM collate2t1;\n    }\n  } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}\n  do_test collate2-3.26 {\n    execsql {\n      SELECT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb')) \n        FROM collate2t1;\n    }\n  } {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}\n  do_test collate2-3.27 {\n    execsql {\n      SELECT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb')) \n        FROM collate2t1;\n    }\n  } {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}\n}\n\ndo_test collate2-4.0 {\n  execsql {\n    CREATE TABLE collate2t2(b COLLATE binary);\n    CREATE TABLE collate2t3(b text);\n    INSERT INTO collate2t2 VALUES('aa');\n    INSERT INTO collate2t3 VALUES('aa');\n  }\n} {}\n\n# Test that when both sides of a binary comparison operator have\n# default collation types, the collate type for the leftmost term\n# is used.\ndo_test collate2-4.1 {\n  execsql {\n    SELECT collate2t1.a FROM collate2t1, collate2t2 \n      WHERE collate2t1.b = collate2t2.b;\n  }\n} {aa aA Aa AA}\ndo_test collate2-4.2 {\n  execsql {\n    SELECT collate2t1.a FROM collate2t1, collate2t2 \n      WHERE collate2t2.b = collate2t1.b;\n  }\n} {aa}\n\n# Test that when one side has a default collation type and the other\n# does not, the collation type is used.\ndo_test collate2-4.3 {\n  execsql {\n    SELECT collate2t1.a FROM collate2t1, collate2t3 \n      WHERE collate2t1.b = collate2t3.b||''\n      ORDER BY +collate2t1.a DESC;\n  }\n} {aa aA Aa AA}\ndo_test collate2-4.4 {\n  execsql {\n    SELECT collate2t1.a FROM collate2t1, collate2t3 \n      WHERE collate2t3.b||'' = collate2t1.b\n      ORDER BY +collate2t1.a DESC;\n  }\n} {aa aA Aa AA}\n\ndo_test collate2-4.5 {\n  execsql {\n    DROP TABLE collate2t3;\n  }\n} {}\n\n#\n# Test that the default collation types are used when the JOIN syntax\n# is used in place of a WHERE clause.\n#\n# SQLite transforms the JOIN syntax into a WHERE clause internally, so\n# the focus of these tests is to ensure that the table on the left-hand-side\n# of the join determines the collation type used. \n#\ndo_test collate2-5.0 {\n  execsql {\n    SELECT collate2t1.b FROM collate2t1 JOIN collate2t2 USING (b);\n  }\n} {aa aA Aa AA}\ndo_test collate2-5.1 {\n  execsql {\n    SELECT collate2t1.b FROM collate2t2 JOIN collate2t1 USING (b);\n  }\n} {aa}\ndo_test collate2-5.2 {\n  execsql {\n    SELECT collate2t1.b FROM collate2t1 NATURAL JOIN collate2t2;\n  }\n} {aa aA Aa AA}\ndo_test collate2-5.3 {\n  execsql {\n    SELECT collate2t1.b FROM collate2t2 NATURAL JOIN collate2t1;\n  }\n} {aa}\ndo_test collate2-5.4 {\n  execsql {\n    SELECT collate2t2.b FROM collate2t1 LEFT OUTER JOIN collate2t2 USING (b) order by collate2t1.oid;\n  }\n} {{} aa {} {} {} aa {} {} {} aa {} {} {} aa {} {} {}}\ndo_test collate2-5.5 {\n  execsql {\n    SELECT collate2t1.b, collate2t2.b FROM collate2t2 LEFT OUTER JOIN collate2t1 USING (b);\n  }\n} {aa aa}\n\ndo_execsql_test 6.1 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES('b');\n  INSERT INTO t1 VALUES('B');\n}\ndo_execsql_test 6.2 {\n  SELECT * FROM t1 WHERE x COLLATE nocase BETWEEN 'a' AND 'c';\n} {b B}\ndo_execsql_test 6.3 {\n  SELECT * FROM t1 WHERE x BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;\n} {b B}\ndo_execsql_test 6.4 {\n  SELECT * FROM t1 \n  WHERE x COLLATE nocase BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;\n} {b B}\ndo_execsql_test 6.5 {\n  SELECT * FROM t1 WHERE +x COLLATE nocase BETWEEN 'a' AND 'c';\n} {b B}\ndo_execsql_test 6.6 {\n  SELECT * FROM t1 WHERE +x BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;\n} {b B}\ndo_execsql_test 6.7 {\n  SELECT * FROM t1 \n  WHERE +x COLLATE nocase BETWEEN 'a' COLLATE nocase AND 'c' COLLATE nocase;\n} {b B}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate3.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is page cache subsystem.\n#\n# $Id: collate3.test,v 1.13 2008/08/20 16:35:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#\n# Tests are organised as follows:\n#\n# collate3.1.* - Errors related to unknown collation sequences.\n# collate3.2.* - Errors related to undefined collation sequences.\n# collate3.3.* - Writing to a table that has an index with an undefined c.s.\n# collate3.4.* - Misc errors.\n# collate3.5.* - Collation factory.\n#\n\n#\n# These tests ensure that when a user executes a statement with an \n# unknown collation sequence an error is returned.\n#\ndo_test collate3-1.0 {\n  execsql {\n    CREATE TABLE collate3t1(c1 UNIQUE);\n  }\n} {}\ndo_test collate3-1.1 {\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY 1 collate garbage;\n  }\n} {1 {no such collation sequence: garbage}}\ndo_test collate3-1.1.2 {\n  catchsql {\n    SELECT DISTINCT c1 COLLATE garbage FROM collate3t1;\n  }\n} {1 {no such collation sequence: garbage}}\ndo_test collate3-1.2 {\n  catchsql {\n    CREATE TABLE collate3t2(c1 collate garbage);\n  }\n} {1 {no such collation sequence: garbage}}\ndo_test collate3-1.3 {\n  catchsql {\n    CREATE INDEX collate3i1 ON collate3t1(c1 COLLATE garbage);\n  }\n} {1 {no such collation sequence: garbage}}\n\nexecsql {\n  DROP TABLE collate3t1;\n}\n\nproc caseless {a b} { string compare -nocase $a $b }\ndo_test collate3-1.4 {\n  db collate caseless caseless\n  execsql { \n    CREATE TABLE t1(a COLLATE caseless); \n    INSERT INTO t1 VALUES('Abc2');\n    INSERT INTO t1 VALUES('abc1');\n    INSERT INTO t1 VALUES('aBc3');\n  }\n  execsql { SELECT * FROM t1 ORDER BY a }\n} {abc1 Abc2 aBc3}\n\ndo_test collate3-1.5 {\n  db close\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 ORDER BY a }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.6.1 {\n  db collate caseless caseless\n  execsql { CREATE INDEX i1 ON t1(a) }\n  execsql { SELECT * FROM t1 ORDER BY a }\n} {abc1 Abc2 aBc3}\n\ndo_test collate3-1.6.2 {\n  db close\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 ORDER BY a }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.6.3 {\n  db close\n  sqlite3 db test.db\n  catchsql { PRAGMA integrity_check }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.6.4 {\n  db close\n  sqlite3 db test.db\n  catchsql { REINDEX }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.7.1 {\n  db collate caseless caseless\n  execsql {\n    DROP TABLE t1;\n    CREATE TABLE t1(a);\n    CREATE INDEX i1 ON t1(a COLLATE caseless);\n    INSERT INTO t1 VALUES('Abc2');\n    INSERT INTO t1 VALUES('abc1');\n    INSERT INTO t1 VALUES('aBc3');\n    SELECT * FROM t1 ORDER BY a COLLATE caseless;\n  }\n} {abc1 Abc2 aBc3}\n\ndo_test collate3-1.7.2 {\n  db close\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 ORDER BY a COLLATE caseless}\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.7.4 {\n  db close\n  sqlite3 db test.db\n  catchsql { REINDEX }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.7.3 {\n  db close\n  sqlite3 db test.db\n  catchsql { PRAGMA integrity_check }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.7.4 {\n  db close\n  sqlite3 db test.db\n  catchsql { REINDEX }\n} {1 {no such collation sequence: caseless}}\n\ndo_test collate3-1.7.5 {\n  db close\n  sqlite3 db test.db\n  db collate caseless caseless\n  catchsql { PRAGMA integrity_check }\n} {0 ok}\n\nproc needed {nm} { db collate caseless caseless }\ndo_test collate3-1.7.6 {\n  db close\n  sqlite3 db test.db\n  db collation_needed needed\n  catchsql { PRAGMA integrity_check }\n} {0 ok}\n\ndo_test collate3-1.8 {\n  execsql { DROP TABLE t1 }\n} {}\n\n#\n# Create a table with a default collation sequence, then close\n# and re-open the database without re-registering the collation\n# sequence. Then make sure the library stops us from using\n# the collation sequence in:\n# * an explicitly collated ORDER BY\n# * an ORDER BY that uses the default collation sequence\n# * an expression (=)\n# * a CREATE TABLE statement\n# * a CREATE INDEX statement that uses a default collation sequence\n# * a GROUP BY that uses the default collation sequence\n# * a SELECT DISTINCT that uses the default collation sequence\n# * Compound SELECTs that uses the default collation sequence\n# * An ORDER BY on a compound SELECT with an explicit ORDER BY.\n#\ndo_test collate3-2.0 {\n  db collate string_compare {string compare}\n  execsql {\n    CREATE TABLE collate3t1(c1 COLLATE string_compare, c2);\n  }\n  db close\n  sqlite3 db test.db\n  expr 0\n} 0\ndo_test collate3-2.1 {\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY 1 COLLATE string_compare;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-2.2 {\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY c1;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-2.3 {\n  catchsql {\n    SELECT * FROM collate3t1 WHERE c1 = 'xxx';\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-2.4 {\n  catchsql {\n    CREATE TABLE collate3t2(c1 COLLATE string_compare);\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-2.5 {\n  catchsql {\n    CREATE INDEX collate3t1_i1 ON collate3t1(c1);\n  }\n} {1 {no such collation sequence: string_compare}}\ndo_test collate3-2.6 {\n  catchsql {\n    SELECT * FROM collate3t1;\n  }\n} {0 {}}\ndo_test collate3-2.7.1 {\n  catchsql {\n    SELECT count(*) FROM collate3t1 GROUP BY c1;\n  }\n} {1 {no such collation sequence: string_compare}} \n# do_test collate3-2.7.2 {\n#   catchsql {\n#     SELECT * FROM collate3t1 GROUP BY c1;\n#   }\n# } {1 {GROUP BY may only be used on aggregate queries}}\ndo_test collate3-2.7.2 {\n  catchsql {\n    SELECT * FROM collate3t1 GROUP BY c1;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-2.8 {\n  catchsql {\n    SELECT DISTINCT c1 FROM collate3t1;\n  }\n} {1 {no such collation sequence: string_compare}} \n\nifcapable compound {\n  do_test collate3-2.9 {\n    catchsql {\n      SELECT c1 FROM collate3t1 UNION SELECT c1 FROM collate3t1;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.10 {\n    catchsql {\n      SELECT c1 FROM collate3t1 EXCEPT SELECT c1 FROM collate3t1;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.11 {\n    catchsql {\n      SELECT c1 FROM collate3t1 INTERSECT SELECT c1 FROM collate3t1;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.12 {\n    catchsql {\n      SELECT c1 FROM collate3t1 UNION ALL SELECT c1 FROM collate3t1;\n    }\n  } {0 {}}\n  do_test collate3-2.13 {\n    catchsql {\n      SELECT 10 UNION ALL SELECT 20 ORDER BY 1 COLLATE string_compare;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.14 {\n    catchsql {\n      SELECT 10 INTERSECT SELECT 20 ORDER BY 1 COLLATE string_compare;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.15 {\n    catchsql {\n      SELECT 10 EXCEPT SELECT 20 ORDER BY 1 COLLATE string_compare;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.16 {\n    catchsql {\n      SELECT 10 UNION SELECT 20 ORDER BY 1 COLLATE string_compare;\n    }\n  } {1 {no such collation sequence: string_compare}} \n  do_test collate3-2.17 {\n    catchsql {\n      SELECT c1 FROM collate3t1 UNION ALL SELECT c1 FROM collate3t1 ORDER BY 1;\n    }\n  } {1 {no such collation sequence: string_compare}} \n} ;# ifcapable compound\n\n#\n# Create an index that uses a collation sequence then close and\n# re-open the database without re-registering the collation\n# sequence. Then check that for the table with the index \n# * An INSERT fails,\n# * An UPDATE on the column with the index fails,\n# * An UPDATE on a different column succeeds.\n# * A DELETE with a WHERE clause fails\n# * A DELETE without a WHERE clause succeeds\n#\n# Also, ensure that the restrictions tested by collate3-2.* still\n# apply after the index has been created.\n#\ndo_test collate3-3.0 {\n  db collate string_compare {string compare}\n  execsql {\n    CREATE INDEX collate3t1_i1 ON collate3t1(c1);\n    INSERT INTO collate3t1 VALUES('xxx', 'yyy');\n  }\n  db close\n  sqlite3 db test.db\n  expr 0\n} 0\ndb eval {select * from collate3t1}\ndo_test collate3-3.1 {\n  catchsql {\n    INSERT INTO collate3t1 VALUES('xxx', 0);\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.2 {\n  catchsql {\n    UPDATE collate3t1 SET c1 = 'xxx';\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.3 {\n  catchsql {\n    UPDATE collate3t1 SET c2 = 'xxx';\n  }\n} {0 {}}\ndo_test collate3-3.4 {\n  catchsql {\n    DELETE FROM collate3t1 WHERE 1;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.5 {\n  catchsql {\n    SELECT * FROM collate3t1;\n  }\n} {0 {xxx xxx}}\ndo_test collate3-3.6 {\n  catchsql {\n    DELETE FROM collate3t1;\n  }\n} {0 {}}\nifcapable {integrityck} {\n  do_test collate3-3.8 {\n    catchsql {\n      PRAGMA integrity_check\n    }\n  } {1 {no such collation sequence: string_compare}}\n}\ndo_test collate3-3.9 {\n  catchsql {\n    SELECT * FROM collate3t1;\n  }\n} {0 {}}\ndo_test collate3-3.10 {\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY 1 COLLATE string_compare;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.11 {\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY c1;\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.12 {\n  catchsql {\n    SELECT * FROM collate3t1 WHERE c1 = 'xxx';\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.13 {\n  catchsql {\n    CREATE TABLE collate3t2(c1 COLLATE string_compare);\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.14 {\n  catchsql {\n    CREATE INDEX collate3t1_i2 ON collate3t1(c1);\n  }\n} {1 {no such collation sequence: string_compare}} \ndo_test collate3-3.15 {\n  execsql {\n    DROP TABLE collate3t1;\n  }\n} {}\n\n# Check we can create an index that uses an explicit collation \n# sequence and then close and re-open the database.\ndo_test collate3-4.6 {\n  db collate user_defined \"string compare\"\n  execsql {\n    CREATE TABLE collate3t1(a, b);\n    INSERT INTO collate3t1 VALUES('hello', NULL);\n    CREATE INDEX collate3i1 ON collate3t1(a COLLATE user_defined);\n  }\n} {}\ndo_test collate3-4.7 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;\n  }\n} {1 {no such collation sequence: user_defined}}\ndo_test collate3-4.8.1 {\n  db collate user_defined \"string compare\"\n  catchsql {\n    SELECT * FROM collate3t1 ORDER BY a COLLATE user_defined;\n  }\n} {0 {hello {}}}\ndo_test collate3-4.8.2 {\n  db close\n  lindex [catch {\n    sqlite3 db test.db\n  }] 0\n} {0}\ndo_test collate3-4.8.3 {\n  execsql {\n    DROP TABLE collate3t1;\n  }\n} {}\n\n# Compare strings as numbers.\nproc numeric_compare {lhs rhs} {\n  if {$rhs > $lhs} {\n    set res -1\n  } else {\n    set res [expr ($lhs > $rhs)?1:0]\n  }\n  return $res\n}\n\n# Check we can create a view that uses an explicit collation \n# sequence and then close and re-open the database.\nifcapable view {\ndo_test collate3-4.9 {\n  db collate user_defined numeric_compare\n  execsql {\n    CREATE TABLE collate3t1(a, b);\n    INSERT INTO collate3t1 VALUES('2', NULL);\n    INSERT INTO collate3t1 VALUES('101', NULL);\n    INSERT INTO collate3t1 VALUES('12', NULL);\n    CREATE VIEW collate3v1 AS SELECT * FROM collate3t1 \n        ORDER BY 1 COLLATE user_defined;\n    SELECT * FROM collate3v1;\n  }\n} {2 {} 12 {} 101 {}}\ndo_test collate3-4.10 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM collate3v1;\n  }\n} {1 {no such collation sequence: user_defined}}\ndo_test collate3-4.11 {\n  db collate user_defined numeric_compare\n  catchsql {\n    SELECT * FROM collate3v1;\n  }\n} {0 {2 {} 12 {} 101 {}}}\ndo_test collate3-4.12 {\n  execsql {\n    DROP TABLE collate3t1;\n  }\n} {}\n} ;# ifcapable view\n\n#\n# Test the collation factory. In the code, the \"no such collation sequence\"\n# message is only generated in two places. So these tests just test that\n# the collation factory can be called once from each of those points.\n#\ndo_test collate3-5.0 {\n  catchsql {\n    CREATE TABLE collate3t1(a);\n    INSERT INTO collate3t1 VALUES(10);\n    SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;\n  }\n} {1 {no such collation sequence: unk}}\ndo_test collate3-5.1 {\n  set ::cfact_cnt 0\n  proc cfact {nm} {\n    db collate $nm {string compare}\n    incr ::cfact_cnt\n  }\n  db collation_needed cfact\n} {}\ndo_test collate3-5.2 {\n  catchsql {\n    SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;\n  }\n} {0 10}\ndo_test collate3-5.3 {\n  set ::cfact_cnt\n} {1}\ndo_test collate3-5.4 {\n  catchsql {\n    SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;\n  }\n} {0 10}\ndo_test collate3-5.5 {\n  set ::cfact_cnt\n} {1}\ndo_test collate3-5.6 {\n  catchsql {\n    SELECT a FROM collate3t1 ORDER BY 1 COLLATE unk;\n  }\n} {0 10}\ndo_test collate3-5.7 {\n  execsql {\n    DROP TABLE collate3t1;\n    CREATE TABLE collate3t1(a COLLATE unk);\n  }\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT a FROM collate3t1 ORDER BY 1;\n  }\n} {1 {no such collation sequence: unk}}\ndo_test collate3-5.8 {\n  set ::cfact_cnt 0\n  proc cfact {nm} {\n    db collate $nm {string compare}\n    incr ::cfact_cnt\n  }\n  db collation_needed cfact\n  catchsql {\n    SELECT a FROM collate3t1 ORDER BY 1;\n  }\n} {0 {}}\n\ndo_test collate3-5.9 {\n  execsql {\n    DROP TABLE collate3t1;\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate4.test",
    "content": "#\n# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is page cache subsystem.\n#\n# $Id: collate4.test,v 1.9 2008/01/05 17:39:30 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndb collate TEXT text_collate\nproc text_collate {a b} {\n  return [string compare $a $b]\n}\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# This procedure executes the SQL.  Then it checks the generated program\n# for the SQL and appends a \"nosort\" to the result if the program contains the\n# SortCallback opcode.  If the program does not contain the SortCallback\n# opcode it appends \"sort\"\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# \n# Test cases are organized roughly as follows:\n#\n# collate4-1.*      ORDER BY.\n# collate4-2.*      WHERE clauses.\n# collate4-3.*      constraints (primary key, unique).\n# collate4-4.*      simple min() or max() queries.\n# collate4-5.*      REINDEX command\n# collate4-6.*      INTEGER PRIMARY KEY indices.\n#\n\n#\n# These tests - collate4-1.* - check that indices are correctly\n# selected or not selected to implement ORDER BY clauses when \n# user defined collation sequences are involved. \n#\n# Because these tests also exercise all the different ways indices \n# can be created, they also serve to verify that indices are correctly \n# initialized with user-defined collation sequences when they are\n# created.\n#\n# Tests named collate4-1.1.* use indices with a single column. Tests\n# collate4-1.2.* use indices with two columns.\n#\ndo_test collate4-1.1.0 {\n  execsql {\n    CREATE TABLE collate4t1(a COLLATE NOCASE, b COLLATE TEXT);\n    INSERT INTO collate4t1 VALUES( 'a', 'a' );\n    INSERT INTO collate4t1 VALUES( 'b', 'b' );\n    INSERT INTO collate4t1 VALUES( NULL, NULL );\n    INSERT INTO collate4t1 VALUES( 'B', 'B' );\n    INSERT INTO collate4t1 VALUES( 'A', 'A' );\n    CREATE INDEX collate4i1 ON collate4t1(a);\n    CREATE INDEX collate4i2 ON collate4t1(b);\n  }\n} {}\ndo_test collate4-1.1.1 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a}\n} {{} a A b B nosort}\ndo_test collate4-1.1.2 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE NOCASE}\n} {{} a A b B nosort}\ndo_test collate4-1.1.3 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE TEXT}\n} {{} A B a b sort}\ndo_test collate4-1.1.4 {\n  cksort {SELECT b FROM collate4t1 ORDER BY b}\n} {{} A B a b nosort}\ndo_test collate4-1.1.5 {\n  cksort {SELECT b FROM collate4t1 ORDER BY b COLLATE TEXT}\n} {{} A B a b nosort}\ndo_test collate4-1.1.6 {\n  cksort {SELECT b FROM collate4t1 ORDER BY b COLLATE NOCASE, rowid}\n} {{} a A b B sort}\n\ndo_test collate4-1.1.7 {\n  execsql {\n    CREATE TABLE collate4t2(\n      a PRIMARY KEY COLLATE NOCASE, \n      b UNIQUE COLLATE TEXT\n    );\n    INSERT INTO collate4t2 VALUES( 'a', 'a' );\n    INSERT INTO collate4t2 VALUES( NULL, NULL );\n    INSERT INTO collate4t2 VALUES( 'B', 'B' );\n  }\n} {}\ndo_test collate4-1.1.8 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a}\n} {{} a B nosort}\ndo_test collate4-1.1.9 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE NOCASE}\n} {{} a B nosort}\ndo_test collate4-1.1.10 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE TEXT}\n} {{} B a sort}\ndo_test collate4-1.1.11 {\n  cksort {SELECT b FROM collate4t2 ORDER BY b}\n} {{} B a nosort}\ndo_test collate4-1.1.12 {\n  cksort {SELECT b FROM collate4t2 ORDER BY b COLLATE TEXT}\n} {{} B a nosort}\ndo_test collate4-1.1.13 {\n  cksort {SELECT b FROM collate4t2 ORDER BY b COLLATE NOCASE}\n} {{} a B sort}\n\ndo_test collate4-1.1.14 {\n  execsql {\n    CREATE TABLE collate4t3(\n      b COLLATE TEXT,  \n      a COLLATE NOCASE, \n      UNIQUE(a), PRIMARY KEY(b)\n    );\n    INSERT INTO collate4t3 VALUES( 'a', 'a' );\n    INSERT INTO collate4t3 VALUES( NULL, NULL );\n    INSERT INTO collate4t3 VALUES( 'B', 'B' );\n  }\n} {}\ndo_test collate4-1.1.15 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a}\n} {{} a B nosort}\ndo_test collate4-1.1.16 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE NOCASE}\n} {{} a B nosort}\ndo_test collate4-1.1.17 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE TEXT}\n} {{} B a sort}\ndo_test collate4-1.1.18 {\n  cksort {SELECT b FROM collate4t3 ORDER BY b}\n} {{} B a nosort}\ndo_test collate4-1.1.19 {\n  cksort {SELECT b FROM collate4t3 ORDER BY b COLLATE TEXT}\n} {{} B a nosort}\ndo_test collate4-1.1.20 {\n  cksort {SELECT b FROM collate4t3 ORDER BY b COLLATE NOCASE}\n} {{} a B sort}\n\ndo_test collate4-1.1.21 {\n  execsql {\n    CREATE TABLE collate4t4(a COLLATE NOCASE, b COLLATE TEXT);\n    INSERT INTO collate4t4 VALUES( 'a', 'a' );\n    INSERT INTO collate4t4 VALUES( 'b', 'b' );\n    INSERT INTO collate4t4 VALUES( NULL, NULL );\n    INSERT INTO collate4t4 VALUES( 'B', 'B' );\n    INSERT INTO collate4t4 VALUES( 'A', 'A' );\n    CREATE INDEX collate4i3 ON collate4t4(a COLLATE TEXT);\n    CREATE INDEX collate4i4 ON collate4t4(b COLLATE NOCASE);\n  }\n} {}\ndo_test collate4-1.1.22 {\n  cksort {SELECT a FROM collate4t4 ORDER BY a, rowid}\n} {{} a A b B sort}\ndo_test collate4-1.1.23 {\n  cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE NOCASE, rowid}\n} {{} a A b B sort}\ndo_test collate4-1.1.24 {\n  cksort {SELECT a FROM collate4t4 ORDER BY a COLLATE TEXT, rowid}\n} {{} A B a b nosort}\ndo_test collate4-1.1.25 {\n  cksort {SELECT b FROM collate4t4 ORDER BY b}\n} {{} A B a b sort}\ndo_test collate4-1.1.26 {\n  cksort {SELECT b FROM collate4t4 ORDER BY b COLLATE TEXT}\n} {{} A B a b sort}\ndo_test collate4-1.1.27 {\n  cksort {SELECT b FROM collate4t4 ORDER BY b COLLATE NOCASE}\n} {{} a A b B nosort}\n\ndo_test collate4-1.1.30 {\n  execsql {\n    DROP TABLE collate4t1;\n    DROP TABLE collate4t2;\n    DROP TABLE collate4t3;\n    DROP TABLE collate4t4;\n  }\n} {}\n\ndo_test collate4-1.2.0 {\n  execsql {\n    CREATE TABLE collate4t1(a COLLATE NOCASE, b COLLATE TEXT);\n    INSERT INTO collate4t1 VALUES( 'a', 'a' );\n    INSERT INTO collate4t1 VALUES( 'b', 'b' );\n    INSERT INTO collate4t1 VALUES( NULL, NULL );\n    INSERT INTO collate4t1 VALUES( 'B', 'B' );\n    INSERT INTO collate4t1 VALUES( 'A', 'A' );\n    CREATE INDEX collate4i1 ON collate4t1(a, b);\n  }\n} {}\ndo_test collate4-1.2.1 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a}\n} {{} A a B b nosort}\ndo_test collate4-1.2.2 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE nocase}\n} {{} A a B b nosort}\ndo_test collate4-1.2.3 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a COLLATE text}\n} {{} A B a b sort}\ndo_test collate4-1.2.4 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a, b}\n} {{} A a B b nosort}\ndo_test collate4-1.2.5 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a, b COLLATE nocase, rowid}\n} {{} a A b B sort}\ndo_test collate4-1.2.6 {\n  cksort {SELECT a FROM collate4t1 ORDER BY a, b COLLATE text}\n} {{} A a B b nosort}\n\ndo_test collate4-1.2.7 {\n  execsql {\n    CREATE TABLE collate4t2(\n      a COLLATE NOCASE, \n      b COLLATE TEXT, \n      PRIMARY KEY(a, b)\n    );\n    INSERT INTO collate4t2 VALUES( 'a', 'a' );\n    INSERT INTO collate4t2 VALUES( NULL, NULL );\n    INSERT INTO collate4t2 VALUES( 'B', 'B' );\n  }\n} {}\ndo_test collate4-1.2.8 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a}\n} {{} a B nosort}\ndo_test collate4-1.2.9 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE nocase}\n} {{} a B nosort}\ndo_test collate4-1.2.10 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a COLLATE text}\n} {{} B a sort}\ndo_test collate4-1.2.11 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a, b}\n} {{} a B nosort}\ndo_test collate4-1.2.12 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a, b COLLATE nocase}\n} {{} a B sort}\ndo_test collate4-1.2.13 {\n  cksort {SELECT a FROM collate4t2 ORDER BY a, b COLLATE text}\n} {{} a B nosort}\n\ndo_test collate4-1.2.14 {\n  execsql {\n    CREATE TABLE collate4t3(a COLLATE NOCASE, b COLLATE TEXT);\n    INSERT INTO collate4t3 VALUES( 'a', 'a' );\n    INSERT INTO collate4t3 VALUES( 'b', 'b' );\n    INSERT INTO collate4t3 VALUES( NULL, NULL );\n    INSERT INTO collate4t3 VALUES( 'B', 'B' );\n    INSERT INTO collate4t3 VALUES( 'A', 'A' );\n    CREATE INDEX collate4i2 ON collate4t3(a COLLATE TEXT, b COLLATE NOCASE);\n  }\n} {}\ndo_test collate4-1.2.15 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a, rowid}\n} {{} a A b B sort}\ndo_test collate4-1.2.16 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE nocase, rowid}\n} {{} a A b B sort}\ndo_test collate4-1.2.17 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text}\n} {{} A B a b nosort}\ndo_test collate4-1.2.18 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b}\n} {{} A B a b sort}\ndo_test collate4-1.2.19 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b COLLATE nocase}\n} {{} A B a b nosort}\ndo_test collate4-1.2.20 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text, b COLLATE text}\n} {{} A B a b sort}\ndo_test collate4-1.2.21 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text DESC}\n} {b a B A {} nosort}\ndo_test collate4-1.2.22 {\n  cksort {SELECT a FROM collate4t3 ORDER BY a COLLATE text DESC, b}\n} {b a B A {} sort}\ndo_test collate4-1.2.23 {\n  cksort {SELECT a FROM collate4t3 \n            ORDER BY a COLLATE text DESC, b COLLATE nocase}\n} {b a B A {} sort}\ndo_test collate4-1.2.24 {\n  cksort {SELECT a FROM collate4t3 \n            ORDER BY a COLLATE text DESC, b COLLATE nocase DESC}\n} {b a B A {} nosort}\n\ndo_test collate4-1.2.25 {\n  execsql {\n    DROP TABLE collate4t1;\n    DROP TABLE collate4t2;\n    DROP TABLE collate4t3;\n  }\n} {}\n\n#\n# These tests - collate4-2.* - check that indices are correctly\n# selected or not selected to implement WHERE clauses when user \n# defined collation sequences are involved. \n#\n# Indices may optimise WHERE clauses using <, >, <=, >=, = or IN\n# operators.\n#\ndo_test collate4-2.1.0 {\n  execsql {\n    PRAGMA automatic_index=OFF;\n    CREATE TABLE collate4t1(a COLLATE NOCASE);\n    CREATE TABLE collate4t2(b COLLATE TEXT);\n\n    INSERT INTO collate4t1 VALUES('a');\n    INSERT INTO collate4t1 VALUES('A');\n    INSERT INTO collate4t1 VALUES('b');\n    INSERT INTO collate4t1 VALUES('B');\n    INSERT INTO collate4t1 VALUES('c');\n    INSERT INTO collate4t1 VALUES('C');\n    INSERT INTO collate4t1 VALUES('d');\n    INSERT INTO collate4t1 VALUES('D');\n    INSERT INTO collate4t1 VALUES('e');\n    INSERT INTO collate4t1 VALUES('D');\n\n    INSERT INTO collate4t2 VALUES('A');\n    INSERT INTO collate4t2 VALUES('Z');\n  }\n} {}\ndo_test collate4-2.1.1 {\n  count {\n    SELECT * FROM collate4t2, collate4t1 WHERE a = b;\n  }\n} {A a A A 19}\ndo_test collate4-2.1.2 {\n  execsql {\n    CREATE INDEX collate4i1 ON collate4t1(a);\n  }\n  count {\n    SELECT * FROM collate4t2, collate4t1 WHERE a = b;\n  }\n} {A a A A 4}\ndo_test collate4-2.1.3 {\n  count {\n    SELECT * FROM collate4t2, collate4t1 WHERE b = a;\n  }\n} {A A 19}\ndo_test collate4-2.1.4 {\n  execsql {\n    DROP INDEX collate4i1;\n    CREATE INDEX collate4i1 ON collate4t1(a COLLATE TEXT);\n  }\n  count {\n    SELECT * FROM collate4t2, collate4t1 WHERE a = b\n     ORDER BY collate4t2.rowid, collate4t1.rowid\n  }\n} {A a A A 19}\ndo_test collate4-2.1.5 {\n  count {\n    SELECT * FROM collate4t2, collate4t1 WHERE b = a;\n  }\n} {A A 3}\nifcapable subquery {\n  do_test collate4-2.1.6 {\n    count {\n      SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2)\n       ORDER BY rowid\n    }\n  } {a A 10}\n  do_test collate4-2.1.7 {\n    execsql {\n      DROP INDEX collate4i1;\n      CREATE INDEX collate4i1 ON collate4t1(a);\n    }\n    count {\n      SELECT a FROM collate4t1 WHERE a IN (SELECT * FROM collate4t2)\n       ORDER BY rowid\n    }\n  } {a A 5}\n  do_test collate4-2.1.8 {\n    count {\n      SELECT a FROM collate4t1 WHERE a IN ('z', 'a');\n    }\n  } {a A 4}\n  do_test collate4-2.1.9 {\n    execsql {\n      DROP INDEX collate4i1;\n      CREATE INDEX collate4i1 ON collate4t1(a COLLATE TEXT);\n    }\n    count {\n      SELECT a FROM collate4t1 WHERE a IN ('z', 'a') ORDER BY rowid;\n    }\n  } {a A 9}\n}\ndo_test collate4-2.1.10 {\n  execsql {\n    DROP TABLE collate4t1;\n    DROP TABLE collate4t2;\n  }\n} {}\n\ndo_test collate4-2.2.0 {\n  execsql {\n    CREATE TABLE collate4t1(a COLLATE nocase, b COLLATE text, c);\n    CREATE TABLE collate4t2(a COLLATE nocase, b COLLATE text, c COLLATE TEXT);\n\n    INSERT INTO collate4t1 VALUES('0', '0', '0');\n    INSERT INTO collate4t1 VALUES('0', '0', '1');\n    INSERT INTO collate4t1 VALUES('0', '1', '0');\n    INSERT INTO collate4t1 VALUES('0', '1', '1');\n    INSERT INTO collate4t1 VALUES('1', '0', '0');\n    INSERT INTO collate4t1 VALUES('1', '0', '1');\n    INSERT INTO collate4t1 VALUES('1', '1', '0');\n    INSERT INTO collate4t1 VALUES('1', '1', '1');\n    insert into collate4t2 SELECT * FROM collate4t1;\n  }\n} {}\ndo_test collate4-2.2.1 {\n  count {\n    SELECT * FROM collate4t2 NOT INDEXED NATURAL JOIN collate4t1 NOT INDEXED;\n  }\n} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 63}\ndo_test collate4-2.2.1b {\n  execsql {\n    CREATE INDEX collate4i1 ON collate4t1(a, b, c);\n  }\n  count {\n    SELECT * FROM collate4t2 NATURAL JOIN collate4t1;\n  }\n} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 29}\ndo_test collate4-2.2.2 {\n  execsql {\n    DROP INDEX collate4i1;\n    CREATE INDEX collate4i1 ON collate4t1(a, b, c COLLATE text);\n  }\n  count {\n    SELECT * FROM collate4t2 NATURAL JOIN collate4t1;\n  }\n} {0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 22}\n\ndo_test collate4-2.2.10 {\n  execsql {\n    DROP TABLE collate4t1;\n    DROP TABLE collate4t2;\n  }\n} {}\n\n#\n# These tests - collate4-3.* verify that indices that implement\n# UNIQUE and PRIMARY KEY constraints operate correctly with user\n# defined collation sequences.\n#\ndo_test collate4-3.0 {\n  execsql {\n    CREATE TABLE collate4t1(a PRIMARY KEY COLLATE NOCASE);\n  }\n} {}\ndo_test collate4-3.1 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES('abc');\n    INSERT INTO collate4t1 VALUES('ABC');\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.2 {\n  execsql {\n    SELECT * FROM collate4t1;\n  }\n} {abc}\ndo_test collate4-3.3 {\n  catchsql {\n    INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.4 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES(1);\n    UPDATE collate4t1 SET a = 'abc';\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.5 {\n  execsql {\n    DROP TABLE collate4t1;\n    CREATE TABLE collate4t1(a COLLATE NOCASE UNIQUE);\n  }\n} {}\ndo_test collate4-3.6 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES('abc');\n    INSERT INTO collate4t1 VALUES('ABC');\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.7 {\n  execsql {\n    SELECT * FROM collate4t1;\n  }\n} {abc}\ndo_test collate4-3.8 {\n  catchsql {\n    INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.9 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES(1);\n    UPDATE collate4t1 SET a = 'abc';\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.10 {\n  execsql {\n    DROP TABLE collate4t1;\n    CREATE TABLE collate4t1(a);\n    CREATE UNIQUE INDEX collate4i1 ON collate4t1(a COLLATE NOCASE);\n  }\n} {}\ndo_test collate4-3.11 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES('abc');\n    INSERT INTO collate4t1 VALUES('ABC');\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.12 {\n  execsql {\n    SELECT * FROM collate4t1;\n  }\n} {abc}\ndo_test collate4-3.13 {\n  catchsql {\n    INSERT INTO collate4t1 SELECT upper(a) FROM collate4t1;\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\ndo_test collate4-3.14 {\n  catchsql {\n    INSERT INTO collate4t1 VALUES(1);\n    UPDATE collate4t1 SET a = 'abc';\n  }\n} {1 {UNIQUE constraint failed: collate4t1.a}}\n\ndo_test collate4-3.15 {\n  execsql {\n    DROP TABLE collate4t1;\n  }\n} {}\n\n# Mimic the SQLite 2 collation type NUMERIC.\ndb collate numeric numeric_collate\nproc numeric_collate {lhs rhs} {\n  if {$lhs == $rhs} {return 0} \n  return [expr ($lhs>$rhs)?1:-1]\n}\n\n#\n# These tests - collate4-4.* check that min() and max() only ever \n# use indices constructed with built-in collation type numeric.\n#\n# CHANGED:  min() and max() now use the collation type. If there\n# is an indice that can be used, it is used.\n#\ndo_test collate4-4.0 {\n  execsql {\n    CREATE TABLE collate4t1(a COLLATE TEXT);\n    INSERT INTO collate4t1 VALUES('2');\n    INSERT INTO collate4t1 VALUES('10');\n    INSERT INTO collate4t1 VALUES('20');\n    INSERT INTO collate4t1 VALUES('104');\n  }\n} {}\ndo_test collate4-4.1 {\n  count {\n    SELECT max(a) FROM collate4t1\n  }\n} {20 3}\ndo_test collate4-4.2 {\n  count {\n    SELECT min(a) FROM collate4t1\n  }\n} {10 3}\ndo_test collate4-4.3 {\n  # Test that the index with collation type TEXT is used.\n  execsql {\n    CREATE INDEX collate4i1 ON collate4t1(a);\n  }\n  count {\n    SELECT min(a) FROM collate4t1;\n  }\n} {10 1}\ndo_test collate4-4.4 {\n  count {\n    SELECT max(a) FROM collate4t1;\n  }\n} {20 0}\ndo_test collate4-4.5 {\n  # Test that the index with collation type NUMERIC is not used.\n  execsql {\n    DROP INDEX collate4i1;\n    CREATE INDEX collate4i1 ON collate4t1(a COLLATE NUMERIC);\n  }\n  count {\n    SELECT min(a) FROM collate4t1;\n  }\n} {10 3}\ndo_test collate4-4.6 {\n  count {\n    SELECT max(a) FROM collate4t1;\n  }\n} {20 3}\ndo_test collate4-4.7 {\n  execsql {\n    DROP TABLE collate4t1;\n  }\n} {}\n\n# Also test the scalar min() and max() functions.\n#\ndo_test collate4-4.8 {\n  execsql {\n    CREATE TABLE collate4t1(a COLLATE TEXT, b COLLATE NUMERIC);\n    INSERT INTO collate4t1 VALUES('11', '101');\n    INSERT INTO collate4t1 VALUES('101', '11')\n  }\n} {}\ndo_test collate4-4.9 {\n  execsql {\n    SELECT max(a, b) FROM collate4t1;\n  }\n} {11 11}\ndo_test collate4-4.10 {\n  execsql {\n    SELECT max(b, a) FROM collate4t1;\n  }\n} {101 101}\ndo_test collate4-4.11 {\n  execsql {\n    SELECT max(a, '101') FROM collate4t1;\n  }\n} {11 101}\ndo_test collate4-4.12 {\n  execsql {\n    SELECT max('101', a) FROM collate4t1;\n  }\n} {11 101}\ndo_test collate4-4.13 {\n  execsql {\n    SELECT max(b, '101') FROM collate4t1;\n  }\n} {101 101}\ndo_test collate4-4.14 {\n  execsql {\n    SELECT max('101', b) FROM collate4t1;\n  }\n} {101 101}\n\ndo_test collate4-4.15 {\n  execsql {\n    DROP TABLE collate4t1;\n  }\n} {}\n\n#\n# These tests - collate4.6.* - ensure that implict INTEGER PRIMARY KEY \n# indices do not confuse collation sequences. \n#\n# These indices are never used for sorting in SQLite. And you can't\n# create another index on an INTEGER PRIMARY KEY column, so we don't have \n# to test that.\n# (Revised 2004-Nov-22):  The ROWID can be used for sorting now.\n#\ndo_test collate4-6.0 {\n  execsql {\n    CREATE TABLE collate4t1(a INTEGER PRIMARY KEY);\n    INSERT INTO collate4t1 VALUES(101);\n    INSERT INTO collate4t1 VALUES(10);\n    INSERT INTO collate4t1 VALUES(15);\n  }\n} {}\ndo_test collate4-6.1 {\n  cksort {\n    SELECT * FROM collate4t1 ORDER BY 1;\n  }\n} {10 15 101 nosort}\ndo_test collate4-6.2 {\n  cksort {\n    SELECT * FROM collate4t1 ORDER BY oid;\n  }\n} {10 15 101 nosort}\ndo_test collate4-6.3 {\n  cksort {\n    SELECT * FROM collate4t1 ORDER BY oid||'' COLLATE TEXT;\n  }\n} {10 101 15 sort}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate5.test",
    "content": "#\n# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing DISTINCT, UNION, INTERSECT and EXCEPT\n# SELECT statements that use user-defined collation sequences. Also\n# GROUP BY clauses that use user-defined collation sequences.\n#\n# $Id: collate5.test,v 1.7 2008/09/16 11:58:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n#\n# Tests are organised as follows:\n# collate5-1.* - DISTINCT\n# collate5-2.* - Compound SELECT\n# collate5-3.* - ORDER BY on compound SELECT\n# collate5-4.* - GROUP BY\n\n# Create the collation sequence 'TEXT', purely for asthetic reasons. The\n# test cases in this script could just as easily use BINARY.\ndb collate TEXT [list string compare]\n\n# Mimic the SQLite 2 collation type NUMERIC.\ndb collate numeric numeric_collate\nproc numeric_collate {lhs rhs} {\n  if {$lhs == $rhs} {return 0} \n  return [expr ($lhs>$rhs)?1:-1]\n}\n\n#\n# These tests - collate5-1.* - focus on the DISTINCT keyword.\n#\ndo_test collate5-1.0 {\n  execsql {\n    CREATE TABLE collate5t1(a COLLATE nocase, b COLLATE text);\n\n    INSERT INTO collate5t1 VALUES('a', 'apple');\n    INSERT INTO collate5t1 VALUES('A', 'Apple');\n    INSERT INTO collate5t1 VALUES('b', 'banana');\n    INSERT INTO collate5t1 VALUES('B', 'banana');\n    INSERT INTO collate5t1 VALUES('n', NULL);\n    INSERT INTO collate5t1 VALUES('N', NULL);\n  } \n} {}\ndo_test collate5-1.1 {\n  execsql {\n    SELECT DISTINCT a FROM collate5t1;\n  }\n} {a b n}\ndo_test collate5-1.2 {\n  execsql {\n    SELECT DISTINCT b FROM collate5t1;\n  }\n} {apple Apple banana {}}\ndo_test collate5-1.3 {\n  execsql {\n    SELECT DISTINCT a, b FROM collate5t1;\n  }\n} {a apple A Apple b banana n {}}\n\n# Ticket #3376\n#\ndo_test collate5-1.11 {\n  execsql {\n    CREATE TABLE tkt3376(a COLLATE nocase PRIMARY KEY);\n    INSERT INTO tkt3376 VALUES('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz');\n    INSERT INTO tkt3376 VALUES('ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789');\n    SELECT DISTINCT a FROM tkt3376;\n  }\n} {abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789ABXYZ012234567890123456789}\ndo_test collate5-1.12 {\n  sqlite3 db2 :memory:\n  db2 eval {\n    PRAGMA encoding=UTF16le;\n    CREATE TABLE tkt3376(a COLLATE nocase PRIMARY KEY);\n    INSERT INTO tkt3376 VALUES('abc');\n    INSERT INTO tkt3376 VALUES('ABX');\n    SELECT DISTINCT a FROM tkt3376;\n  }\n} {abc ABX}\ncatch {db2 close}\n\n# The remainder of this file tests compound SELECT statements.\n# Omit it if the library is compiled such that they are omitted.\n#\nifcapable !compound {\n  finish_test\n  return\n}\n\n#\n# Tests named collate5-2.* focus on UNION, EXCEPT and INTERSECT\n# queries that use user-defined collation sequences.\n#\n# collate5-2.1.* - UNION\n# collate5-2.2.* - INTERSECT\n# collate5-2.3.* - EXCEPT\n#\ndo_test collate5-2.0 {\n  execsql {\n    CREATE TABLE collate5t2(a COLLATE text, b COLLATE nocase);\n\n    INSERT INTO collate5t2 VALUES('a', 'apple');\n    INSERT INTO collate5t2 VALUES('A', 'apple');\n    INSERT INTO collate5t2 VALUES('b', 'banana');\n    INSERT INTO collate5t2 VALUES('B', 'Banana');\n  } \n} {}\n\ndo_test collate5-2.1.1 {\n  execsql {\n    SELECT a FROM collate5t1 UNION select a FROM collate5t2;\n  }\n} {A B N}\ndo_test collate5-2.1.2 {\n  execsql {\n    SELECT a FROM collate5t2 UNION select a FROM collate5t1;\n  }\n} {A B N a b n}\ndo_test collate5-2.1.3 {\n  execsql {\n    SELECT a, b FROM collate5t1 UNION select a, b FROM collate5t2;\n  }\n} {A Apple A apple B Banana b banana N {}}\ndo_test collate5-2.1.4 {\n  execsql {\n    SELECT a, b FROM collate5t2 UNION select a, b FROM collate5t1;\n  }\n} {A Apple B banana N {} a apple b banana n {}}\n\ndo_test collate5-2.2.1 {\n  execsql {\n    SELECT a FROM collate5t1 EXCEPT select a FROM collate5t2;\n  }\n} {N}\ndo_test collate5-2.2.2 {\n  execsql {\n    SELECT a FROM collate5t2 EXCEPT select a FROM collate5t1 WHERE a != 'a';\n  }\n} {A a}\ndo_test collate5-2.2.3 {\n  execsql {\n    SELECT a, b FROM collate5t1 EXCEPT select a, b FROM collate5t2;\n  }\n} {A Apple N {}}\ndo_test collate5-2.2.4 {\n  execsql {\n    SELECT a, b FROM collate5t2 EXCEPT select a, b FROM collate5t1 \n      where a != 'a';\n  }\n} {A apple a apple}\n\ndo_test collate5-2.3.1 {\n  execsql {\n    SELECT a FROM collate5t1 INTERSECT select a FROM collate5t2;\n  }\n} {A B}\ndo_test collate5-2.3.2 {\n  execsql {\n    SELECT a FROM collate5t2 INTERSECT select a FROM collate5t1 WHERE a != 'a';\n  }\n} {B b}\ndo_test collate5-2.3.3 {\n  execsql {\n    SELECT a, b FROM collate5t1 INTERSECT select a, b FROM collate5t2;\n  }\n} {a apple B banana}\ndo_test collate5-2.3.4 {\n  execsql {\n    SELECT a, b FROM collate5t2 INTERSECT select a, b FROM collate5t1;\n  }\n} {A apple B Banana a apple b banana}\n\n#\n# This test ensures performs a UNION operation with a bunch of different\n# length records. The goal is to test that the logic that compares records\n# for the compound SELECT operators works with record lengths that lie\n# either side of the troublesome 256 and 65536 byte marks.\n#\nset ::lens [list \\\n  0 1 2 3 4 5 6 7 8 9 \\\n  240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 \\\n  257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 \\\n  65520 65521 65522 65523 65524 65525 65526 65527 65528 65529 65530 \\\n  65531 65532 65533 65534 65535 65536 65537 65538 65539 65540 65541 \\\n  65542 65543 65544 65545 65546 65547 65548 65549 65550 65551 ]\ndo_test collate5-2.4.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE collate5t3(a, b);\n  }\n  foreach ii $::lens { \n    execsql \"INSERT INTO collate5t3 VALUES($ii, '[string repeat a $ii]');\"\n  }\n  expr [llength [execsql {\n    COMMIT;\n    SELECT * FROM collate5t3 UNION SELECT * FROM collate5t3;\n  }]] / 2\n} [llength $::lens]\ndo_test collate5-2.4.1 {\n  execsql {DROP TABLE collate5t3;}\n} {}\nunset ::lens\n\n#\n# These tests - collate5-3.* - focus on compound SELECT queries that \n# feature ORDER BY clauses.\n#\ndo_test collate5-3.0 {\n  execsql {\n    SELECT a FROM collate5t1 UNION ALL SELECT a FROM collate5t2 ORDER BY 1;\n  }\n} {/[aA] [aA] [aA] [aA] [bB] [bB] [bB] [bB] [nN] [nN]/}\ndo_test collate5-3.1 {\n  execsql {\n    SELECT a FROM collate5t2 UNION ALL SELECT a FROM collate5t1 ORDER BY 1;\n  }\n} {A A B B N a a b b n}\ndo_test collate5-3.2 {\n  execsql {\n    SELECT a FROM collate5t1 UNION ALL SELECT a FROM collate5t2 \n      ORDER BY 1 COLLATE TEXT;\n  }\n} {A A B B N a a b b n}\n\ndo_test collate5-3.3 {\n  execsql {\n    CREATE TABLE collate5t_cn(a COLLATE NUMERIC);\n    CREATE TABLE collate5t_ct(a COLLATE TEXT);\n    INSERT INTO collate5t_cn VALUES('1');\n    INSERT INTO collate5t_cn VALUES('11');\n    INSERT INTO collate5t_cn VALUES('101');\n    INSERT INTO collate5t_ct SELECT * FROM collate5t_cn;\n  }\n} {}\ndo_test collate5-3.4 {\n  execsql {\n    SELECT a FROM collate5t_cn INTERSECT SELECT a FROM collate5t_ct ORDER BY 1;\n  }\n} {1 11 101}\ndo_test collate5-3.5 {\n  execsql {\n    SELECT a FROM collate5t_ct INTERSECT SELECT a FROM collate5t_cn ORDER BY 1;\n  }\n} {1 101 11}\n\ndo_test collate5-3.20 {\n  execsql {\n    DROP TABLE collate5t_cn;\n    DROP TABLE collate5t_ct;\n    DROP TABLE collate5t1;\n    DROP TABLE collate5t2;\n  }\n} {}\n\ndo_test collate5-4.0 {\n  execsql {\n    CREATE TABLE collate5t1(a COLLATE NOCASE, b COLLATE NUMERIC); \n    INSERT INTO collate5t1 VALUES('a', '1');\n    INSERT INTO collate5t1 VALUES('A', '1.0');\n    INSERT INTO collate5t1 VALUES('b', '2');\n    INSERT INTO collate5t1 VALUES('B', '3');\n  }\n} {}\ndo_test collate5-4.1 {\n  string tolower [execsql {\n    SELECT a, count(*) FROM collate5t1 GROUP BY a;\n  }]\n} {a 2 b 2}\ndo_test collate5-4.2 {\n  execsql {\n    SELECT a, b, count(*) FROM collate5t1 GROUP BY a, b ORDER BY a, b;\n  }\n} {/[aA] 1(.0)? 2 [bB] 2 1 [bB] 3 1/}\ndo_test collate5-4.3 {\n  execsql {\n    DROP TABLE collate5t1;\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate6.test",
    "content": "#\n# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is collation sequences in concert with triggers.\n#\n# $Id: collate6.test,v 1.4 2007/07/30 14:40:48 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# There are no tests in this file that will work without\n# trigger support.\n#\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Create a case-insensitive collation type NOCASE for use in testing. \n# Normally, capital letters are less than their lower-case counterparts.\ndb collate NOCASE nocase_collate\nproc nocase_collate {a b} {\n  return [string compare -nocase $a $b]\n}\n\n#\n# Tests are organized as follows:\n# collate6-1.* - triggers.\n#\n\ndo_test collate6-1.0 {\n  execsql {\n    CREATE TABLE collate6log(a, b);\n    CREATE TABLE collate6tab(a COLLATE NOCASE, b COLLATE BINARY);\n  }\n} {}\n\n# Test that the default collation sequence applies to new.* references \n# in WHEN clauses.\ndo_test collate6-1.1 {\n  execsql {\n    CREATE TRIGGER collate6trig BEFORE INSERT ON collate6tab \n      WHEN new.a = 'a' BEGIN\n        INSERT INTO collate6log VALUES(new.a, new.b);\n    END;\n  }\n} {}\ndo_test collate6-1.2 {\n  execsql {\n    INSERT INTO collate6tab VALUES('a', 'b');\n    SELECT * FROM collate6log;\n  }\n} {a b}\ndo_test collate6-1.3 {\n  execsql {\n    INSERT INTO collate6tab VALUES('A', 'B');\n    SELECT * FROM collate6log;\n  }\n} {a b A B}\ndo_test collate6-1.4 {\n  execsql {\n    DROP TRIGGER collate6trig;\n    DELETE FROM collate6log;\n  } \n} {}\n\n# Test that the default collation sequence applies to new.* references \n# in the body of triggers.\ndo_test collate6-1.5 {\n  execsql {\n    CREATE TRIGGER collate6trig BEFORE INSERT ON collate6tab BEGIN\n      INSERT INTO collate6log VALUES(new.a='a', new.b='b');\n    END;\n  }\n} {}\ndo_test collate6-1.6 {\n  execsql {\n    INSERT INTO collate6tab VALUES('a', 'b');\n    SELECT * FROM collate6log;\n  }\n} {1 1}\ndo_test collate6-1.7 {\n  execsql {\n    INSERT INTO collate6tab VALUES('A', 'B');\n    SELECT * FROM collate6log;\n  }\n} {1 1 1 0}\ndo_test collate6-1.8 {\n  execsql {\n    DROP TRIGGER collate6trig;\n    DELETE FROM collate6log;\n  } \n} {}\n\ndo_test collate6-1.9 {\n  execsql {\n    DROP TABLE collate6tab;\n  }\n} {}\n\n# Test that an explicit collation sequence overrides an implicit \n# one attached to a 'new' reference.\n#\ndo_test collate6-2.1 {\n  execsql {\n    CREATE TABLE abc(a COLLATE binary, b, c);\n    CREATE TABLE def(a, b, c);\n    CREATE TRIGGER abc_t1 AFTER INSERT ON abc BEGIN\n      INSERT INTO def SELECT * FROM abc WHERE a < new.a COLLATE nocase;\n    END\n  }\n} {}\ndo_test collate6-2.2 {\n  execsql {\n    INSERT INTO abc VALUES('One', 'Two', 'Three');\n    INSERT INTO abc VALUES('one', 'two', 'three');\n    SELECT * FROM def;\n  }\n} {}\ndo_test collate6-2.3 {\n  execsql {\n    UPDATE abc SET a = 'four' WHERE a = 'one';\n    CREATE TRIGGER abc_t2 AFTER UPDATE ON abc BEGIN\n      INSERT INTO def SELECT * FROM abc WHERE a < new.a COLLATE nocase;\n    END;\n    SELECT * FROM def;\n  }\n} {}\n\n# At one point the 6-3.2 (but not 6-3.1) was causing an assert() to fail.\n#\ndo_test collate6-3.1 {\n  execsql {\n    SELECT 1 FROM sqlite_master WHERE name COLLATE nocase = 'hello';\n  }\n} {}\ndo_test collate6-3.2 {\n  execsql {\n    SELECT 1 FROM sqlite_master WHERE 'hello' = name COLLATE nocase;\n  }\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate7.test",
    "content": "#\n# 2007 May 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the experimental sqlite3_create_collation_v2()\n# API.\n#\n# $Id: collate7.test,v 1.2 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::caseless_del 0\nproc caseless_cmp {zLeft zRight} {\n  string compare -nocase $zLeft $zRight\n}\n\ndo_test collate7-1.1 {\n  set cmd [list incr ::caseless_del]\n  sqlite3_create_collation_v2 db CASELESS caseless_cmp $cmd\n  set ::caseless_del\n} {0}\ndo_test collate7-1.2 {\n  sqlite_delete_collation db CASELESS\n  set ::caseless_del\n} {1}\ndo_test collate7-1.3 {\n  catchsql {\n    CREATE TABLE abc(a COLLATE CASELESS, b, c);\n  }\n} {1 {no such collation sequence: CASELESS}}\ndo_test collate7-1.4 {\n  sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}\n  db close\n  set ::caseless_del\n} {2}\n\ndo_test collate7-2.1 {\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}\n  execsql {\n    PRAGMA encoding='utf-16';\n    CREATE TABLE abc16(a COLLATE CASELESS, b, c);\n  } db\n  set ::caseless_del\n} {2}\ndo_test collate7-2.2 {\n  execsql {\n    SELECT * FROM abc16 WHERE a < 'abc';\n  }\n  set ::caseless_del\n} {2}\ndo_test collate7-2.3 {\n  sqlite_delete_collation db CASELESS\n  set ::caseless_del\n} {3}\ndo_test collate7-2.4 {\n  catchsql {\n    SELECT * FROM abc16 WHERE a < 'abc';\n  }\n} {1 {no such collation sequence: CASELESS}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate8.test",
    "content": "#\n# 2007 June 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is making sure collations pass through the\n# unary + operator.\n#\n# 2015-02-09:  Added tests to make sure COLLATE passes through function\n# calls.  Ticket [ca0d20b6cdddec5e81b8d66f89c46a5583b5f6f6].\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test collate8-1.1 {\n  execsql {\n    CREATE TABLE t1(a TEXT COLLATE nocase);\n    INSERT INTO t1 VALUES('aaa');\n    INSERT INTO t1 VALUES('BBB');\n    INSERT INTO t1 VALUES('ccc');\n    INSERT INTO t1 VALUES('DDD');\n    SELECT a FROM t1 ORDER BY a;\n  }\n} {aaa BBB ccc DDD}\ndo_test collate8-1.2 {\n  execsql {\n    SELECT rowid FROM t1 WHERE a<'ccc' ORDER BY 1\n  }\n} {1 2}\ndo_test collate8-1.3 {\n  execsql {\n    SELECT rowid FROM t1 WHERE a<'ccc' COLLATE binary ORDER BY 1\n  }\n} {1 2 4}\ndo_test collate8-1.4 {\n  execsql {\n    SELECT rowid FROM t1 WHERE +a<'ccc' ORDER BY 1\n  }\n} {1 2}\ndo_test collate8-1.5 {\n  execsql {\n    SELECT a FROM t1 ORDER BY +a\n  }\n} {aaa BBB ccc DDD}\ndo_test collate8-1.11 {\n  execsql {\n    SELECT a AS x FROM t1 ORDER BY \"x\";\n  }\n} {aaa BBB ccc DDD}\ndo_test collate8-1.12 {\n  execsql {\n    SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1\n  }\n} {aaa BBB}\ndo_test collate8-1.13 {\n  execsql {\n    SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x]\n  }\n} {aaa BBB DDD}\ndo_test collate8-1.14 {\n  execsql {\n    SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1\n  }\n} {aaa BBB}\ndo_test collate8-1.15 {\n  execsql {\n    SELECT a AS x FROM t1 ORDER BY +x\n  }\n} {aaa BBB ccc DDD}\n\n\n# When a result-set column is aliased into a WHERE clause, make sure the\n# collating sequence logic works correctly.\n#\ndo_test collate8-2.1 {\n  execsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES('abc');\n    INSERT INTO t2 VALUES('ABC');\n    SELECT a AS x FROM t2 WHERE x='abc';\n  }\n} {abc}\ndo_test collate8-2.2 {\n  execsql {\n    SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase;\n  }\n} {abc ABC}\ndo_test collate8-2.3 {\n  execsql {\n    SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc';\n  }\n} {abc ABC}\ndo_test collate8-2.4 {\n  execsql {\n    SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc';\n  }\n} {abc ABC}\ndo_test collate8-2.5 {\n  execsql {\n    SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc';\n  }\n} {abc}\ndo_test collate8-2.6 {\n  execsql {\n    SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary;\n  }\n} {abc ABC}\ndo_test collate8-2.7 {\n  execsql {\n    SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary;\n  }\n} {abc ABC}\ndo_test collate8-2.8 {\n  execsql {\n    SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary;\n  }\n} {abc}\n\n# Make sure the COLLATE operator perculates up through function calls\n# and other Expr structures that use the Expr.x.pList field.\n#\ndo_execsql_test collate8-3.1 {\n  SELECT 'abc'==('ABC'||'') COLLATE nocase;\n  SELECT 'abc'==('ABC'||'' COLLATE nocase);\n  SELECT 'abc'==('ABC'||('' COLLATE nocase));\n  SELECT 'abc'==('ABC'||upper('' COLLATE nocase));\n} {1 1 1 1}\ndo_execsql_test collate8-3.2 {\n  SELECT 'abc'==('ABC'||max('' COLLATE nocase,'' COLLATE binary));\n} {1}\n\n# The COLLATE binary is on the left and so takes precedence\ndo_execsql_test collate8-3.3 {\n  SELECT 'abc'==('ABC'||max('' COLLATE binary,'' COLLATE nocase));\n} {0}\n\ndo_execsql_test collate8-3.4 {\n  SELECT 'abc'==('ABC'||CASE WHEN 1-1=2 THEN '' COLLATE nocase\n                                        ELSE '' COLLATE binary END);\n  SELECT 'abc'==('ABC'||CASE WHEN 1+1=2 THEN '' COLLATE nocase\n                                        ELSE '' COLLATE binary END);\n} {1 1}\ndo_execsql_test collate8-3.5 {\n  SELECT 'abc'==('ABC'||CASE WHEN 1=2 THEN '' COLLATE binary\n                                      ELSE '' COLLATE nocase END);\n} {0}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collate9.test",
    "content": "#\n# 2007 November 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is making sure that the names of collation\n# sequences may be quoted using double quotes in SQL statements.\n#\n# $Id: collate9.test,v 1.2 2008/07/10 00:32:42 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc reverse_sort {lhs rhs} {\n  return [string compare $rhs $lhs]\n}\ndb collate \"reverse sort\" reverse_sort\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# Test plan:\n#\n#     collate9-1.* - Test collation sequences attached to table columns\n#     collate9-2.* - Test collation sequences attached to expressions\n#     collate9-3.* - Test collation sequences attached to an index\n#     collate9-4.* - Test collation sequences as an argument to REINDEX\n#\n\ndo_test collate9-1.1 {\n  execsql {\n    CREATE TABLE xy(x COLLATE \"reverse sort\", y COLLATE binary);\n    INSERT INTO xy VALUES('one', 'one');\n    INSERT INTO xy VALUES('two', 'two');\n    INSERT INTO xy VALUES('three', 'three');\n  }\n} {}\ndo_test collate9-1.2 {\n  execsql { \n    SELECT x FROM xy ORDER BY x\n  }\n} {two three one}\ndo_test collate9-1.3 {\n  execsql { \n    SELECT y FROM xy ORDER BY y\n  }\n} {one three two}\ndo_test collate9-1.4 {\n  cksort { \n    SELECT x FROM xy ORDER BY x\n  }\n} {two three one sort}\ndo_test collate9-1.5 {\n  execsql { \n    CREATE INDEX xy_i ON xy(x)\n  }\n} {}\ndo_test collate9-1.6 {\n  cksort { \n    SELECT x FROM xy ORDER BY x\n  }\n} {two three one nosort}\n\ndo_test collate9-2.1 {\n  execsql { \n    SELECT x, x < 'seven' FROM xy ORDER BY x\n  }\n} {two 1 three 1 one 0}\ndo_test collate9-2.2 {\n  execsql { \n    SELECT y, y < 'seven' FROM xy ORDER BY x\n  }\n} {two 0 three 0 one 1}\ndo_test collate9-2.3 {\n  execsql { \n    SELECT y, y COLLATE \"reverse sort\" < 'seven' FROM xy ORDER BY x\n  }\n} {two 1 three 1 one 0}\ndo_test collate9-2.4 {\n  execsql {\n    SELECT y FROM xy ORDER BY y\n  }\n} {one three two}\ndo_test collate9-2.5 {\n  execsql {\n    SELECT y FROM xy ORDER BY y COLLATE \"reverse sort\"\n  }\n} {two three one}\ndo_test collate9-2.6 {\n  execsql {\n    SELECT y COLLATE \"reverse sort\" AS aaa FROM xy ORDER BY aaa\n  }\n} {two three one}\n\ndo_test collate9-3.1 {\n  execsql {\n    CREATE INDEX xy_i2 ON xy(y COLLATE \"reverse sort\");\n  }\n} {}\ndo_test collate9-3.2 {\n  cksort { \n    SELECT y FROM xy ORDER BY y \n  }\n} {one three two sort}\ndo_test collate9-3.3 {\n  cksort { \n    SELECT y FROM xy ORDER BY y COLLATE \"reverse sort\"\n  }\n} {two three one nosort}\ndo_test collate9-3.4 {\n  cksort { \n    SELECT y AS aaa FROM xy ORDER BY aaa\n  }\n} {one three two sort}\ndo_test collate9-3.5 {\n  cksort { \n    SELECT y COLLATE \"reverse sort\" AS aaa FROM xy ORDER BY aaa\n  }\n} {two three one nosort}\n\nifcapable reindex {\n  do_test collate9-4.1 {\n    execsql {\n      REINDEX \"reverse sort\"\n    }\n  } {}\n\n  # Modify the \"reverse sort\" collation so that it now sorts in the same\n  # order as binary.\n  proc reverse_sort {lhs rhs} {\n    return [string compare $lhs $rhs]\n  }\n\n  # The integrity check should now fail because the indexes created using\n  # \"reverse sort\" are no longer in sync with the collation sequence\n  # implementation.\n  do_test collate9-4.2 {\n    expr {\"ok\" eq [execsql { PRAGMA integrity_check }]}\n  } {0}\n\n  do_test collate9-4.3 {\n    execsql {\n      REINDEX \"reverse sort\"\n    }\n  } {}\n\n  # Integrity check should now pass.\n  do_test collate9-4.4 {\n    expr {\"ok\" eq [execsql { PRAGMA integrity_check }]}\n  } {1}\n\n  do_test collate9-4.5 {\n    cksort {\n      SELECT x FROM xy ORDER BY x COLLATE \"reverse sort\"\n    }\n  } {one three two nosort}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collateA.test",
    "content": "#\n# 2008 January 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the built-in RTRIM collating\n# API.\n#\n# $Id: collateA.test,v 1.3 2008/04/15 04:02:41 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test collateA-1.1 {\n  execsql {\n    CREATE TABLE t1(\n      a INTEGER PRIMARY KEY,\n      b TEXT COLLATE BINARY,\n      c TEXT COLLATE RTRIM\n    );\n    INSERT INTO t1 VALUES(1, 'abcde','abcde');\n    INSERT INTO t1 VALUES(2, 'xyzzy ','xyzzy ');\n    INSERT INTO t1 VALUES(3, 'xyzzy  ','xyzzy  ');\n    INSERT INTO t1 VALUES(4, 'xyzzy   ','xyzzy   ');\n    INSERT INTO t1 VALUES(5, '   ', '   ');\n    INSERT INTO t1 VALUES(6, '', '');\n    SELECT count(*) FROM t1;\n  }\n} {6}\ndo_test collateA-1.2 {\n  execsql {SELECT a FROM t1 WHERE b='abcde     '}\n} {}\ndo_test collateA-1.3 {\n  execsql {SELECT a FROM t1 WHERE c='abcde     '}\n} {1}\ndo_test collateA-1.4 {\n  execsql {SELECT a FROM t1 WHERE b='xyzzy'}\n} {}\ndo_test collateA-1.5 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy'}\n} {2 3 4}\ndo_test collateA-1.6 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy '}\n} {2 3 4}\ndo_test collateA-1.7 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy  '}\n} {2 3 4}\ndo_test collateA-1.8 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy   '}\n} {2 3 4}\ndo_test collateA-1.9 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy    '}\n} {2 3 4}\ndo_test collateA-1.10 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy                                  '}\n} {2 3 4}\ndo_test collateA-1.11 {\n  execsql {SELECT 'abc123'='abc123                         ' COLLATE RTRIM;}\n} {1}\ndo_test collateA-1.12 {\n  execsql {SELECT 'abc123                         '='abc123' COLLATE RTRIM;}\n} {1}\ndo_test collateA-1.13 {\n  execsql {SELECT '  '='' COLLATE RTRIM, '  '='' COLLATE BINARY, '  '=''}\n} {1 0 0}\ndo_test collateA-1.14 {\n  execsql {SELECT ''='  ' COLLATE RTRIM, ''='  ' COLLATE BINARY, ''='  '}\n} {1 0 0}\ndo_test collateA-1.15 {\n  execsql {SELECT '  '='      ' COLLATE RTRIM, '  '='        '}\n} {1 0}\ndo_test collateA-1.16 {\n  execsql {SELECT ''<>'  ' COLLATE RTRIM, ''<>'  ' COLLATE BINARY, ''<>'  '}\n} {0 1 1}\ndo_test collateA-1.17 {\n  execsql {SELECT a FROM t1 WHERE c='xyzz'}\n} {}\ndo_test collateA-1.18 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzyy   '}\n} {}\ndo_test collateA-1.19 {\n  execsql {SELECT a FROM t1 WHERE c='xyzz   '}\n} {}\ndo_test collateA-1.20 {\n  execsql {SELECT a FROM t1 WHERE c='abcd   '}\n} {}\ndo_test collateA-1.21 {\n  execsql {SELECT a FROM t1 WHERE c='abcd'}\n} {}\ndo_test collateA-1.22 {\n  execsql {SELECT a FROM t1 WHERE c='abc'}\n} {}\ndo_test collateA-1.23 {\n  execsql {SELECT a FROM t1 WHERE c='abcdef    '}\n} {}\ndo_test collateA-1.24 {\n  execsql {SELECT a FROM t1 WHERE c=''}\n} {5 6}\ndo_test collateA-1.25 {\n  execsql {SELECT a FROM t1 WHERE c=' '}\n} {5 6}\ndo_test collateA-1.26 {\n  execsql {SELECT a FROM t1 WHERE c='                    '}\n} {5 6}\n\n\ndo_test collateA-2.1 {\n  execsql {\n    CREATE INDEX i1b ON t1(b);\n    CREATE INDEX i1c ON t1(c);\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_test collateA-2.2 {\n  execsql {SELECT a FROM t1 WHERE b='abcde     '}\n} {}\ndo_test collateA-2.3 {\n  execsql {SELECT a FROM t1 WHERE c='abcde     '}\n} {1}\ndo_test collateA-2.4 {\n  execsql {SELECT a FROM t1 WHERE b='xyzzy'}\n} {}\ndo_test collateA-2.5 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy'}\n} {2 3 4}\ndo_test collateA-2.6 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy '}\n} {2 3 4}\ndo_test collateA-2.7 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy  '}\n} {2 3 4}\ndo_test collateA-2.8 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy   '}\n} {2 3 4}\ndo_test collateA-2.9 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy    '}\n} {2 3 4}\ndo_test collateA-2.10 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy                                  '}\n} {2 3 4}\ndo_test collateA-2.17 {\n  execsql {SELECT a FROM t1 WHERE c='xyzz'}\n} {}\ndo_test collateA-2.18 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzyy   '}\n} {}\ndo_test collateA-2.19 {\n  execsql {SELECT a FROM t1 WHERE c='xyzz   '}\n} {}\ndo_test collateA-2.20 {\n  execsql {SELECT a FROM t1 WHERE c='abcd   '}\n} {}\ndo_test collateA-2.21 {\n  execsql {SELECT a FROM t1 WHERE c='abcd'}\n} {}\ndo_test collateA-2.22 {\n  execsql {SELECT a FROM t1 WHERE c='abc'}\n} {}\ndo_test collateA-2.23 {\n  execsql {SELECT a FROM t1 WHERE c='abcdef    '}\n} {}\ndo_test collateA-2.24 {\n  execsql {SELECT a FROM t1 WHERE c=''}\n} {5 6}\ndo_test collateA-2.25 {\n  execsql {SELECT a FROM t1 WHERE c=' '}\n} {5 6}\ndo_test collateA-2.26 {\n  execsql {SELECT a FROM t1 WHERE c='                    '}\n} {5 6}\n\n\ndo_test collateA-3.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    REINDEX;\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_test collateA-3.2 {\n  execsql {SELECT a FROM t1 WHERE b='abcde     '}\n} {}\ndo_test collateA-3.3 {\n  execsql {SELECT a FROM t1 WHERE c='abcde     '}\n} {1}\ndo_test collateA-3.4 {\n  execsql {SELECT a FROM t1 WHERE b='xyzzy'}\n} {}\ndo_test collateA-3.5 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy'}\n} {2 3 4}\ndo_test collateA-3.6 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy '}\n} {2 3 4}\ndo_test collateA-3.7 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy  '}\n} {2 3 4}\ndo_test collateA-3.8 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy   '}\n} {2 3 4}\ndo_test collateA-3.9 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy    '}\n} {2 3 4}\ndo_test collateA-3.10 {\n  execsql {SELECT a FROM t1 WHERE c='xyzzy                                  '}\n} {2 3 4}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/collateB.test",
    "content": "# 2016-07-01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test cases for a crash bug.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix collateB\n\ndo_execsql_test collateB-1.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY);\n  CREATE TABLE t2(b INTEGER PRIMARY KEY, x1 INT COLLATE NOCASE);\n  CREATE TABLE t3(x2 INT);\n  SELECT * FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1;\n} {}\ndo_execsql_test collateB-1.2 {\n  INSERT INTO t1(a) VALUES(1),(2),(3);\n  INSERT INTO t2(b,x1) VALUES(11,1),(22,2),(33,3);\n  INSERT INTO t3(x2) VALUES(11),(22),(33);\n  SELECT *,'|' FROM t3, t2, t1 WHERE x2=b AND x1=a AND a=1;\n} {11 11 1 1 |}\ndo_execsql_test collateB-1.3 {\n  SELECT *,'|' FROM t3, t1, t2 WHERE x2=b AND x1=a AND a=1;\n} {11 1 11 1 |}\ndo_execsql_test collateB-1.4 {\n  SELECT *,'|' FROM t2, t3, t1 WHERE x2=b AND x1=a AND a=1;\n} {11 1 11 1 |}\ndo_execsql_test collateB-1.5 {\n  SELECT *,'|' FROM t2, t1, t3 WHERE x2=b AND x1=a AND a=1;\n} {11 1 1 11 |}\ndo_execsql_test collateB-1.6 {\n  SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1;\n} {1 11 1 11 |}\ndo_execsql_test collateB-1.7 {\n  SELECT *,'|' FROM t1, t2, t3 WHERE x2=b AND x1=a AND a=1;\n} {1 11 1 11 |}\ndo_execsql_test collateB-1.12 {\n  SELECT *,'|' FROM t3, t2, t1 WHERE b=x2 AND a=x1 AND 1=a;\n} {11 11 1 1 |}\ndo_execsql_test collateB-1.13 {\n  SELECT *,'|' FROM t3, t1, t2 WHERE b=x2 AND a=x1 AND 1=a;\n} {11 1 11 1 |}\ndo_execsql_test collateB-1.14 {\n  SELECT *,'|' FROM t2, t3, t1 WHERE b=x2 AND a=x1 AND 1=a;\n} {11 1 11 1 |}\ndo_execsql_test collateB-1.15 {\n  SELECT *,'|' FROM t2, t1, t3 WHERE b=x2 AND a=x1 AND 1=a;\n} {11 1 1 11 |}\ndo_execsql_test collateB-1.16 {\n  SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a;\n} {1 11 1 11 |}\ndo_execsql_test collateB-1.17 {\n  SELECT *,'|' FROM t1, t2, t3 WHERE b=x2 AND a=x1 AND 1=a;\n} {1 11 1 11 |}\n\n#-------------------------------------------------------------------------\n# Test an assert() failure that was occuring if an index were created\n# on a column explicitly declared \"COLLATE binary\".\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE t4(a COLLATE binary);\n  CREATE INDEX i4 ON t4(a);\n  INSERT INTO t4 VALUES('one'), ('two'), ('three');\n  VACUUM;\n} \n\nintegrity_check 2.2\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/colmeta.test",
    "content": "#\n# 2006 February 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the sqlite3_table_column_metadata() API.\n#\n# $Id: colmeta.test,v 1.4 2008/01/23 12:52:41 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Set up a schema in the main and temp test databases.\ndo_test colmeta-0 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE abc2(a PRIMARY KEY COLLATE NOCASE, b VARCHAR(32), c);\n    CREATE TABLE abc3(a NOT NULL, b INTEGER PRIMARY KEY, c);\n    CREATE TABLE abc5(w,x,y,z,PRIMARY KEY(x,z)) WITHOUT ROWID;\n    CREATE TABLE abc6(rowid TEXT COLLATE rtrim, oid REAL, _rowid_ BLOB);\n  }\n  ifcapable autoinc {\n    execsql {\n      CREATE TABLE abc4(a, b INTEGER PRIMARY KEY AUTOINCREMENT, c);\n    }\n  }\n  ifcapable view {\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM abc2;\n    }\n  }\n} {}\n\n\n# Return values are of the form:\n#\n#   {<decl-type> <collation> <not null> <primary key> <auto increment>}\n#\nset tests {\n  1  {main abc a}                {0 {{} BINARY 0 0 0}}\n  2  {{} abc a}                  {0 {{} BINARY 0 0 0}}\n  3  {{} abc2 b}                 {0 {VARCHAR(32) BINARY 0 0 0}}\n  4  {main abc2 b}               {0 {VARCHAR(32) BINARY 0 0 0}}\n  5  {{} abc2 a}                 {0 {{} NOCASE 0 1 0}}\n  6  {{} abc3 a}                 {0 {{} BINARY 1 0 0}}\n  7  {{} abc3 b}                 {0 {INTEGER BINARY 0 1 0}}\n  13 {main abc rowid}            {0 {INTEGER BINARY 0 1 0}}\n  14 {main abc3 rowid}           {0 {INTEGER BINARY 0 1 0}}\n  16 {main abc d}                {1 {no such table column: abc.d}}\n  20 {main abc5 w}               {0 {{} BINARY 0 0 0}}\n  21 {main abc5 x}               {0 {{} BINARY 1 1 0}}\n  22 {main abc5 y}               {0 {{} BINARY 0 0 0}}\n  23 {main abc5 z}               {0 {{} BINARY 1 1 0}}\n  24 {main abc5 rowid}           {1 {no such table column: abc5.rowid}}\n  30 {main abc6 rowid}           {0 {TEXT rtrim 0 0 0}}\n  31 {main abc6 oid}             {0 {REAL BINARY 0 0 0}}\n  32 {main abc6 _rowid_}         {0 {BLOB BINARY 0 0 0}}\n}\nifcapable autoinc {\n  set tests [concat $tests {\n    100 {{} abc4 b}              {0 {INTEGER BINARY 0 1 1}}\n    101 {main abc4 rowid}        {0 {INTEGER BINARY 0 1 1}}\n  }]\n}\nifcapable view {\n  set tests [concat $tests {\n    200 {{} v1 a}                {1 {no such table column: v1.a}}\n    201 {main v1 b}              {1 {no such table column: v1.b}}\n    202 {main v1 badname}        {1 {no such table column: v1.badname}}\n    203 {main v1 rowid}          {1 {no such table column: v1.rowid}}\n  }]\n}\n\nforeach {tn params results} $tests {\n  set ::DB [sqlite3_connection_pointer db]\n\n  set tstbody [concat sqlite3_table_column_metadata $::DB $params] \n  do_test colmeta-$tn.1 {\n    list [catch $tstbody msg] [set msg]\n  } $results\n\n  db close\n  sqlite3 db test.db\n\n  set ::DB [sqlite3_connection_pointer db]\n  set tstbody [concat sqlite3_table_column_metadata $::DB $params] \n  do_test colmeta-$tn.2 {\n    list [catch $tstbody msg] [set msg]\n  } $results\n}\n\n# Calling sqlite3_table_column_metadata with a NULL column name merely\n# checks for the existance of the table.\n#\ndo_test colmeta-300 {\n  catch {sqlite3_table_column_metadata $::DB main xyzzy} res\n} {1}\ndo_test colmeta-301 {\n  catch {sqlite3_table_column_metadata $::DB main abc} res\n} {0}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/colname.test",
    "content": "# 2008 July 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The focus of this file is testing how SQLite generates the names\n# of columns in a result set.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Rules (applied in order):\n#\n# (1) If there is an AS clause, use it.\n#\n# (2) A non-trival expression (not a table column name) then the name is\n#     a copy of the expression text.\n#\n# (3) If short_column_names=ON, then just the abbreviated column name without\n#     the table name.\n#\n# (4) When short_column_names=OFF and full_column_names=OFF then\n#     use case (2) for simple queries and case (5) for joins.\n#\n# (5) When short_column_names=OFF and full_column_names=ON then\n#     use the form: TABLE.COLUMN\n#\n\n\n# Verify the default settings for short_column_name and full_column_name\n#\ndo_test colname-1.1 {\n  db eval {PRAGMA short_column_names}\n} {1}\ndo_test colname-1.2 {\n  db eval {PRAGMA full_column_names}\n} {0}\n\n# Tests for then short=ON and full=any\n#\ndo_test colname-2.1 {\n  db eval {\n    CREATE TABLE tabc(a,b,c);\n    INSERT INTO tabc VALUES(1,2,3);\n    CREATE TABLE txyz(x,y,z);\n    INSERT INTO txyz VALUES(4,5,6);\n    CREATE TABLE tboth(a,b,c,x,y,z);\n    INSERT INTO tboth VALUES(11,12,13,14,15,16);\n    CREATE VIEW v1 AS SELECT tabC.a, txyZ.x, * \n      FROM tabc, txyz ORDER BY 1 LIMIT 1;\n    CREATE VIEW v2 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, *\n      FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;\n  }\n  execsql2 {\n    SELECT * FROM tabc;\n  }\n} {a 1 b 2 c 3}\ndo_test colname-2.2 {\n  execsql2 {\n    SELECT Tabc.a, tAbc.b, taBc.c, * FROM tabc\n  }\n} {a 1 b 2 c 3 a 1 b 2 c 3}\ndo_test colname-2.3 {\n  execsql2 {\n    SELECT +tabc.a, -tabc.b, tabc.c, * FROM tabc\n  }\n} {+tabc.a 1 -tabc.b -2 c 3 a 1 b 2 c 3}\ndo_test colname-2.4 {\n  execsql2 {\n    SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC, * FROM tabc\n  }\n} {AAA 1 BBB -2 CCC 3 a 1 b 2 c 3}\ndo_test colname-2.5 {\n  execsql2 {\n    SELECT tabc.a, txyz.x, * FROM tabc, txyz;\n  }\n} {a 1 x 4 a 1 b 2 c 3 x 4 y 5 z 6}\ndo_test colname-2.6 {\n  execsql2 {\n    SELECT tabc.a, txyz.x, tabc.*, txyz.* FROM tabc, txyz;\n  }\n} {a 1 x 4 a 1 b 2 c 3 x 4 y 5 z 6}\ndo_test colname-2.7 {\n  execsql2 {\n    SELECT tabc.a, txyz.x, tboth.a, tboth.x, * FROM tabc, txyz, tboth;\n  }\n} {a 11 x 14 a 11 x 14 a 11 b 12 c 13 x 14 y 15 z 16 a 11 b 12 c 13 x 14 y 15 z 16}\ndo_test colname-2.8 {\n  execsql2 {\n    SELECT * FROM v1 ORDER BY 2;\n  }\n} {a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}\ndo_test colname-2.9 {\n  execsql2 {\n    SELECT * FROM v2 ORDER BY 2;\n  }\n} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}\n\n\n# Tests for short=OFF and full=OFF\n#\ndo_test colname-3.1 {\n  db eval {\n    PRAGMA short_column_names=OFF;\n    PRAGMA full_column_names=OFF;\n    CREATE VIEW v3 AS SELECT tabC.a, txyZ.x, *\n      FROM tabc, txyz ORDER BY 1 LIMIT 1;\n    CREATE VIEW v4 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, * \n      FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;\n  }\n  execsql2 {\n    SELECT * FROM tabc;\n  }\n} {a 1 b 2 c 3}\ndo_test colname-3.2 {\n  execsql2 {\n    SELECT Tabc.a, tAbc.b, taBc.c FROM tabc\n  }\n} {Tabc.a 1 tAbc.b 2 taBc.c 3}\ndo_test colname-3.3 {\n  execsql2 {\n    SELECT +tabc.a, -tabc.b, tabc.c FROM tabc\n  }\n} {+tabc.a 1 -tabc.b -2 tabc.c 3}\ndo_test colname-3.4 {\n  execsql2 {\n    SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC FROM tabc\n  }\n} {AAA 1 BBB -2 CCC 3}\ndo_test colname-3.5 {\n  execsql2 {\n    SELECT Tabc.a, Txyz.x, * FROM tabc, txyz;\n  }\n} {Tabc.a 1 Txyz.x 4 a 1 b 2 c 3 x 4 y 5 z 6}\ndo_test colname-3.6 {\n  execsql2 {\n    SELECT tabc.*, txyz.* FROM tabc, txyz;\n  }\n} {a 1 b 2 c 3 x 4 y 5 z 6}\ndo_test colname-3.7 {\n  execsql2 {\n    SELECT * FROM tabc, txyz, tboth;\n  }\n} {a 11 b 12 c 13 x 14 y 15 z 16 a 11 b 12 c 13 x 14 y 15 z 16}\ndo_test colname-3.8 {\n  execsql2 {\n    SELECT v1.a, * FROM v1 ORDER BY 2;\n  }\n} {v1.a 1 a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}\ndo_test colname-3.9 {\n  execsql2 {\n    SELECT * FROM v2 ORDER BY 2;\n  }\n} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}\ndo_test colname-3.10 {\n  execsql2 {\n    SELECT * FROM v3 ORDER BY 2;\n  }\n} {a 1 x 4 a:1 1 b 2 c 3 x:1 4 y 5 z 6}\ndo_test colname-3.11 {\n  execsql2 {\n    SELECT * FROM v4 ORDER BY 2;\n  }\n} {a 1 x 4 a:1 11 x:1 14 a:2 1 b 2 c 3 x:2 4 y 5 z 6 a:3 11 b:1 12 c:1 13 x:3 14 y:1 15 z:1 16}\n\n# Test for short=OFF and full=ON\n#\ndo_test colname-4.1 {\n  db eval {\n    PRAGMA short_column_names=OFF;\n    PRAGMA full_column_names=ON;\n    CREATE VIEW v5 AS SELECT tabC.a, txyZ.x, *\n      FROM tabc, txyz ORDER BY 1 LIMIT 1;\n    CREATE VIEW v6 AS SELECT tabC.a, txyZ.x, tboTh.a, tbotH.x, * \n      FROM tabc, txyz, tboth ORDER BY 1 LIMIT 1;\n  }\n  execsql2 {\n    SELECT * FROM tabc;\n  }\n} {tabc.a 1 tabc.b 2 tabc.c 3}\ndo_test colname-4.2 {\n  execsql2 {\n    SELECT Tabc.a, tAbc.b, taBc.c FROM tabc\n  }\n} {tabc.a 1 tabc.b 2 tabc.c 3}\ndo_test colname-4.3 {\n  execsql2 {\n    SELECT +tabc.a, -tabc.b, tabc.c FROM tabc\n  }\n} {+tabc.a 1 -tabc.b -2 tabc.c 3}\ndo_test colname-4.4 {\n  execsql2 {\n    SELECT +tabc.a AS AAA, -tabc.b AS BBB, tabc.c CCC FROM tabc\n  }\n} {AAA 1 BBB -2 CCC 3}\ndo_test colname-4.5 {\n  execsql2 {\n    SELECT Tabc.a, Txyz.x, * FROM tabc, txyz;\n  }\n} {tabc.a 1 txyz.x 4 tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6}\ndo_test colname-4.6 {\n  execsql2 {\n    SELECT tabc.*, txyz.* FROM tabc, txyz;\n  }\n} {tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6}\ndo_test colname-4.7 {\n  execsql2 {\n    SELECT * FROM tabc, txyz, tboth;\n  }\n} {tabc.a 1 tabc.b 2 tabc.c 3 txyz.x 4 txyz.y 5 txyz.z 6 tboth.a 11 tboth.b 12 tboth.c 13 tboth.x 14 tboth.y 15 tboth.z 16}\ndo_test colname-4.8 {\n  execsql2 {\n    SELECT * FROM v1 ORDER BY 2;\n  }\n} {v1.a 1 v1.x 4 v1.a:1 1 v1.b 2 v1.c 3 v1.x:1 4 v1.y 5 v1.z 6}\ndo_test colname-4.9 {\n  execsql2 {\n    SELECT * FROM v2 ORDER BY 2;\n  }\n} {v2.a 1 v2.x 4 v2.a:1 11 v2.x:1 14 v2.a:2 1 v2.b 2 v2.c 3 v2.x:2 4 v2.y 5 v2.z 6 v2.a:3 11 v2.b:1 12 v2.c:1 13 v2.x:3 14 v2.y:1 15 v2.z:1 16}\ndo_test colname-4.10 {\n  execsql2 {\n    SELECT * FROM v3 ORDER BY 2;\n  }\n} {v3.a 1 v3.x 4 v3.a:1 1 v3.b 2 v3.c 3 v3.x:1 4 v3.y 5 v3.z 6}\ndo_test colname-4.11 {\n  execsql2 {\n    SELECT * FROM v4 ORDER BY 2;\n  }\n} {v4.a 1 v4.x 4 v4.a:1 11 v4.x:1 14 v4.a:2 1 v4.b 2 v4.c 3 v4.x:2 4 v4.y 5 v4.z 6 v4.a:3 11 v4.b:1 12 v4.c:1 13 v4.x:3 14 v4.y:1 15 v4.z:1 16}\ndo_test colname-4.12 {\n  execsql2 {\n    SELECT * FROM v5 ORDER BY 2;\n  }\n} {v5.a 1 v5.x 4 v5.a:1 1 v5.b 2 v5.c 3 v5.x:1 4 v5.y 5 v5.z 6}\ndo_test colname-4.13 {\n  execsql2 {\n    SELECT * FROM v6 ORDER BY 2;\n  }\n} {v6.a 1 v6.x 4 v6.a:1 11 v6.x:1 14 v6.a:2 1 v6.b 2 v6.c 3 v6.x:2 4 v6.y 5 v6.z 6 v6.a:3 11 v6.b:1 12 v6.c:1 13 v6.x:3 14 v6.y:1 15 v6.z:1 16}\n\n# ticket #3229\ndo_test colname-5.1 {\n  lreplace [db eval {\n    SELECT x.* FROM sqlite_master X LIMIT 1;\n  }] 3 3 x\n} {table tabc tabc x {CREATE TABLE tabc(a,b,c)}}\n\n# ticket #3370, #3371, #3372\n#\ndo_test colname-6.1 {\n  db close\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t6(a, ['a'], [\"a\"], \"[a]\", [`a`]);\n    INSERT INTO t6 VALUES(1,2,3,4,5);\n  }\n  execsql2 {SELECT * FROM t6}\n} {a 1 'a' 2 {\"a\"} 3 {[a]} 4 `a` 5}\ndo_test colname-6.2 {\n  execsql2 {SELECT ['a'], [`a`], \"[a]\", [a], [\"a\"] FROM t6}\n} {'a' 2 `a` 5 {[a]} 4 a 1 {\"a\"} 3}\ndo_test colname-6.3 {\n  execsql2 {SELECT \"'a'\", \"`a`\", \"[a]\", \"a\", \"\"\"a\"\"\" FROM t6}\n} {'a' 2 `a` 5 {[a]} 4 a 1 {\"a\"} 3}\ndo_test colname-6.4 {\n  execsql2 {SELECT `'a'`, ```a```, `[a]`, `a`, `\"a\"` FROM t6}\n} {'a' 2 `a` 5 {[a]} 4 a 1 {\"a\"} 3}\ndo_test colname-6.11 {\n  execsql2 {SELECT a, max(a) AS m FROM t6}\n} {a 1 m 1}\ndo_test colname-6.12 {\n  execsql2 {SELECT `a`, max(a) AS m FROM t6}\n} {a 1 m 1}\ndo_test colname-6.13 {\n  execsql2 {SELECT \"a\", max(a) AS m FROM t6}\n} {a 1 m 1}\ndo_test colname-6.14 {\n  execsql2 {SELECT [a], max(a) AS m FROM t6}\n} {a 1 m 1}\ndo_test colname-6.15 {\n  execsql2 {SELECT t6.a, max(a) AS m FROM t6}\n} {a 1 m 1}\ndo_test colname-6.16 {\n  execsql2 {SELECT ['a'], max(['a']) AS m FROM t6}\n} {'a' 2 m 2}\ndo_test colname-6.17 {\n  execsql2 {SELECT [\"a\"], max([\"a\"]) AS m FROM t6}\n} {{\"a\"} 3 m 3}\ndo_test colname-6.18 {\n  execsql2 {SELECT \"[a]\", max(\"[a]\") AS m FROM t6}\n} {{[a]} 4 m 4}\ndo_test colname-6.19 {\n  execsql2 {SELECT \"`a`\", max([`a`]) AS m FROM t6}\n} {`a` 5 m 5}\n\n\n# Ticket #3429\n# We cannot find anything wrong, but it never hurts to add another\n# test case.\n#\ndo_test colname-7.1 {\n  db eval {\n    CREATE TABLE t7(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t7 VALUES(1,2);\n  }\n  execsql2 {SELECT rowid, * FROM t7}\n} {x 1 x 1 y 2}\n\n# Tickets #3893 and #3984.  (Same problem; independently reported)\n#\ndo_test colname-8.1 {\n  db eval {\n    CREATE TABLE \"t3893\"(\"x\");\n    INSERT INTO t3893 VALUES(123);\n    SELECT \"y\".\"x\" FROM (SELECT \"x\" FROM \"t3893\") AS \"y\";\n  }\n} {123}\n\n# 2017-07-29: Interaction between column naming and query flattening.\n# For years now, the query flattener has inserted AS clauses on the\n# outer query that were the original SQL text of the column.  This caused\n# column-name shifts when the query flattener was enhanced, breaking\n# legacy applications.  See https://sqlite.org/src/info/41c27bc0ff1d3135\n# for details.\n#\n# To fix this, the column naming logic was moved ahead of the query\n# flattener so that column names are assigned before the query flattener\n# runs.\n#\ndb close\nsqlite3 db :memory:\ndo_test colname-9.100 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    CREATE VIEW v1(x,y) AS SELECT a,b FROM t1;\n  }\n  execsql2 {SELECT v1.x, (Y) FROM v1}\n  # Prior to the fix, this would return:  \"v1.x 1 (Y) 2\"\n} {x 1 y 2}\ndo_test colname-9.110 {\n  execsql2 {SELECT * FROM v1}\n} {x 1 y 2}\ndo_test colname-9.120 {\n  db eval {\n    CREATE VIEW v2(x,y) AS SELECT a,b FROM t1 LIMIT 10;\n  }\n  execsql2 {SELECT * FROM v2 WHERE 1}\n} {x 1 y 2}\ndo_test colname-9.130 {\n  execsql2 {SELECT v2.x, [v2].[y] FROM v2 WHERE 1}\n} {x 1 y 2}\ndo_test colname-9.140 {\n  execsql2 {SELECT +x, +y FROM v2 WHERE 1}\n} {+x 1 +y 2}\n\ndo_test colname-9.200 {\n  db eval {\n    CREATE TABLE t2(c,d);\n    INSERT INTO t2 VALUES(3,4);\n    CREATE VIEW v3 AS SELECT c AS a, d AS b FROM t2;\n  }\n  execsql2 {SELECT t1.a, v3.a AS n FROM t1 LEFT JOIN v3}\n} {a 1 n 3}\ndo_test colname-9.211 {\n  execsql2 {SELECT t1.a AS n, v3.a FROM t1 JOIN v3}\n} {n 1 a 3}\ndo_test colname-9.210 {\n  execsql2 {SELECT t1.a, v3.a AS n FROM t1 JOIN v3}\n} {a 1 n 3}\n\n# Make sure the quotation marks get removed from the column names\n# when constructing a new table from an aggregate SELECT.\n# Email from Juergen Palm on 2017-07-11.\n#\ndo_execsql_test colname-10.100 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\"with space\" TEXT);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2 AS SELECT \"with space\" FROM t1;\n  PRAGMA table_info(t2);\n} {0 {with space} TEXT 0 {} 0}\ndo_execsql_test colname-10.110 {\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE t3 AS SELECT \"with space\" FROM t1 GROUP BY 1;\n  PRAGMA table_info(t3);\n} {0 {with space} TEXT 0 {} 0}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/conflict.test",
    "content": "# 2002 January 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the conflict resolution extension\n# to SQLite.\n#\n# $Id: conflict.test,v 1.32 2009/04/30 09:10:38 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !conflict {\n  finish_test\n  return\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict-1.0 {\n  execsql {\n    CREATE TABLE t1(a, b, c, UNIQUE(a,b));\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#   t3     Number of temporary files created by this test\n#\nforeach {i cmd t0 t1 t2 t3} {\n  1 INSERT                  1 {}  1  0\n  2 {INSERT OR IGNORE}      0 3   1  0\n  3 {INSERT OR REPLACE}     0 4   1  0\n  4 REPLACE                 0 4   1  0\n  5 {INSERT OR FAIL}        1 {}  1  0\n  6 {INSERT OR ABORT}       1 {}  1  0\n  7 {INSERT OR ROLLBACK}    1 {}  {} 0\n} {\n  do_test conflict-1.$i {\n    set ::sqlite_opentemp_count 0\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    set r3 $::sqlite_opentemp_count\n    list $r0 $r1 $r2 $r3\n  } [list $t0 $t1 $t2 $t3]\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict-2.0 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b));\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i cmd t0 t1 t2} {\n  1 INSERT                  1 {}  1\n  2 {INSERT OR IGNORE}      0 3   1\n  3 {INSERT OR REPLACE}     0 4   1\n  4 REPLACE                 0 4   1\n  5 {INSERT OR FAIL}        1 {}  1\n  6 {INSERT OR ABORT}       1 {}  1\n  7 {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  do_test conflict-2.$i {\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict-3.0 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b));\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i cmd t0 t1 t2} {\n  1 INSERT                  1 {}  1\n  2 {INSERT OR IGNORE}      0 3   1\n  3 {INSERT OR REPLACE}     0 4   1\n  4 REPLACE                 0 4   1\n  5 {INSERT OR FAIL}        1 {}  1\n  6 {INSERT OR ABORT}       1 {}  1\n  7 {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  do_test conflict-3.$i {\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict-4.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(x);\n    SELECT x FROM t2;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the UNIQUE constraint\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i conf1 cmd t0 t1 t2} {\n  1 {}       INSERT                  1 {}  1\n  2 REPLACE  INSERT                  0 4   1\n  3 IGNORE   INSERT                  0 3   1\n  4 FAIL     INSERT                  1 {}  1\n  5 ABORT    INSERT                  1 {}  1\n  6 ROLLBACK INSERT                  1 {}  {}\n  7 REPLACE  {INSERT OR IGNORE}      0 3   1\n  8 IGNORE   {INSERT OR REPLACE}     0 4   1\n  9 FAIL     {INSERT OR IGNORE}      0 3   1\n 10 ABORT    {INSERT OR REPLACE}     0 4   1\n 11 ROLLBACK {INSERT OR IGNORE }     0 3   1\n} {\n  do_test conflict-4.$i {\n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c,UNIQUE(a,b) $conf1);\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict-5.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(x);\n    SELECT x FROM t2;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the NOT NULL constraint\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i conf1 cmd t0 t1 t2} {\n  1 {}       INSERT                  1 {}  1\n  2 REPLACE  INSERT                  0 5   1\n  3 IGNORE   INSERT                  0 {}  1\n  4 FAIL     INSERT                  1 {}  1\n  5 ABORT    INSERT                  1 {}  1\n  6 ROLLBACK INSERT                  1 {}  {}\n  7 REPLACE  {INSERT OR IGNORE}      0 {}  1\n  8 IGNORE   {INSERT OR REPLACE}     0 5   1\n  9 FAIL     {INSERT OR IGNORE}      0 {}  1\n 10 ABORT    {INSERT OR REPLACE}     0 5   1\n 11 ROLLBACK {INSERT OR IGNORE}      0 {}  1\n 12 {}       {INSERT OR IGNORE}      0 {}  1\n 13 {}       {INSERT OR REPLACE}     0 5   1\n 14 {}       {INSERT OR FAIL}        1 {}  1\n 15 {}       {INSERT OR ABORT}       1 {}  1\n 16 {}       {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  if {$t0} {set t1 {NOT NULL constraint failed: t1.c}}\n  do_test conflict-5.$i {\n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);\n      DELETE FROM t2;\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,NULL);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict-6.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES(1,2,1);\n    INSERT INTO t2 VALUES(2,3,2);\n    INSERT INTO t2 VALUES(3,4,1);\n    INSERT INTO t2 VALUES(4,5,4);\n    SELECT c FROM t2 ORDER BY b;\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n  }\n} {1 2 1 4}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the UNIQUE constraint\n#   cmd    An UPDATE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"b\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t3\n#   t3     Number of temporary files for tables\n#   t4     Number of temporary files for statement journals\n#\n# Update (2007-08-21): Since temporary table files are now opened lazily, \n# and none of the following tests use large quantities of data, t3 is always 0.\n#\n# Update (2016-03-04): Subjournals now also open lazily, so t4 is also always 0.\n#\nforeach {i conf1 cmd t0 t1 t2 t3 t4} {\n  1 {}       UPDATE                  1 {6 7 8 9}  1 0 0\n  2 REPLACE  UPDATE                  0 {7 6 9}    1 0 0\n  3 IGNORE   UPDATE                  0 {6 7 3 9}  1 0 0\n  4 FAIL     UPDATE                  1 {6 7 3 4}  1 0 0\n  5 ABORT    UPDATE                  1 {1 2 3 4}  1 0 0\n  6 ROLLBACK UPDATE                  1 {1 2 3 4}  0 0 0\n  7 REPLACE  {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n  8 IGNORE   {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n  9 FAIL     {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 10 ABORT    {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n 11 ROLLBACK {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 12 {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 13 {}       {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n 14 {}       {UPDATE OR FAIL}        1 {6 7 3 4}  1 0 0\n 15 {}       {UPDATE OR ABORT}       1 {1 2 3 4}  1 0 0\n 16 {}       {UPDATE OR ROLLBACK}    1 {1 2 3 4}  0 0 0\n} {\n  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}\n  if {[info exists TEMP_STORE] && $TEMP_STORE==3} {\n    set t3 0\n  } else {\n    set t3 [expr {$t3+$t4}]\n  }\n  do_test conflict-6.$i {\n    db close\n    sqlite3 db test.db \n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    execsql {pragma temp_store=file}\n    set ::sqlite_opentemp_count 0\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);\n      INSERT INTO t1 SELECT * FROM t2;\n      UPDATE t3 SET x=0;\n      BEGIN;\n      $cmd t3 SET x=1;\n      $cmd t1 SET b=b*2;\n      $cmd t1 SET a=c+5;\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}\n    set r2 [execsql {SELECT x FROM t3}]\n    list $r0 $r1 $r2 $::sqlite_opentemp_count\n  } [list $t0 $t1 $t2 $t3]\n}\n\n# Test to make sure a lot of IGNOREs don't cause a stack overflow\n#\ndo_test conflict-7.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n    CREATE TABLE t1(a unique, b);\n  }\n  for {set i 1} {$i<=50} {incr i} {\n    execsql \"INSERT into t1 values($i,[expr {$i+1}]);\"\n  }\n  execsql {\n    SELECT count(*), min(a), max(b) FROM t1;\n  }\n} {50 1 51}\ndo_test conflict-7.2 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE OR IGNORE t1 SET a=1000;\n  }\n} {1}\ndo_test conflict-7.2.1 {\n  db changes\n} {1}\ndo_test conflict-7.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a=1000;\n  }\n} {2}\ndo_test conflict-7.4 {\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {50}\ndo_test conflict-7.5 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE OR REPLACE t1 SET a=1001;\n  }\n} {50}\ndo_test conflict-7.5.1 {\n  db changes\n} {50}\ndo_test conflict-7.6 {\n  execsql {\n    SELECT b FROM t1 WHERE a=1001;\n  }\n} {51}\ndo_test conflict-7.7 {\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {1}\n\n# Update for version 3: A SELECT statement no longer resets the change\n# counter (Test result changes from 0 to 50).\ndo_test conflict-7.7.1 {\n  db changes\n} {50}\n\n# Make sure the row count is right for rows that are ignored on\n# an insert.\n#\ndo_test conflict-8.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2);\n  }\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(2,3);\n  }\n} {1}\ndo_test conflict-8.1.1 {\n  db changes\n} {1}\ndo_test conflict-8.2 {\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(2,4);\n  }\n} {0}\ndo_test conflict-8.2.1 {\n  db changes\n} {0}\ndo_test conflict-8.3 {\n  execsql {\n    INSERT OR REPLACE INTO t1 VALUES(2,4);\n  }\n} {1}\ndo_test conflict-8.3.1 {\n  db changes\n} {1}\ndo_test conflict-8.4 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT * FROM t1;\n  }\n} {0}\ndo_test conflict-8.4.1 {\n  db changes\n} {0}\ndo_test conflict-8.5 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;\n  }\n} {2}\ndo_test conflict-8.5.1 {\n  db changes\n} {2}\ndo_test conflict-8.6 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;\n  }\n} {3}\ndo_test conflict-8.6.1 {\n  db changes\n} {3}\n\nintegrity_check conflict-8.99\n\ndo_test conflict-9.1 {\n  execsql {\n    PRAGMA count_changes=0;\n    CREATE TABLE t2(\n      a INTEGER UNIQUE ON CONFLICT IGNORE,\n      b INTEGER UNIQUE ON CONFLICT FAIL,\n      c INTEGER UNIQUE ON CONFLICT REPLACE,\n      d INTEGER UNIQUE ON CONFLICT ABORT,\n      e INTEGER UNIQUE ON CONFLICT ROLLBACK\n    );\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n    SELECT * FROM t3;\n  }\n} {1}\ndo_test conflict-9.2 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,1,1,1,1);\n    INSERT INTO t2 VALUES(2,2,2,2,2);\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict-9.3 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,3,3,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict-9.4 {\n  catchsql {\n    UPDATE t2 SET a=a+1 WHERE a=1;\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict-9.5 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,1,3,3,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict-9.6 {\n  catchsql {\n    UPDATE t2 SET b=b+1 WHERE b=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict-9.7 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,1,3,3,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict-9.8 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {2}\ndo_test conflict-9.9 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET b=b+1 WHERE b=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict-9.10 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {3}\ndo_test conflict-9.11 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,3,1,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict-9.12 {\n  catchsql {\n    UPDATE t2 SET d=d+1 WHERE d=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict-9.13 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,3,1,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict-9.14 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {4}\ndo_test conflict-9.15 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET d=d+1 WHERE d=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict-9.16 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict-9.17 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,3,3,1);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\ndo_test conflict-9.18 {\n  catchsql {\n    UPDATE t2 SET e=e+1 WHERE e=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\ndo_test conflict-9.19 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,3,3,1);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\nverify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE\ndo_test conflict-9.20 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict-9.21 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET e=e+1 WHERE e=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\nverify_ex_errcode conflict-9.21b SQLITE_CONSTRAINT_UNIQUE\ndo_test conflict-9.22 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict-9.23 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,1,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {2 2 2 2 2 3 3 1 3 3}}\ndo_test conflict-9.24 {\n  catchsql {\n    UPDATE t2 SET c=c-1 WHERE c=2;\n    SELECT * FROM t2;\n  }\n} {0 {2 2 1 2 2}}\ndo_test conflict-9.25 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,1,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {3 3 1 3 3}}\ndo_test conflict-9.26 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {6}\n\ndo_test conflict-10.1 {\n  catchsql {\n    DELETE FROM t1;\n    BEGIN;\n    INSERT OR ROLLBACK INTO t1 VALUES(1,2);\n    INSERT OR ROLLBACK INTO t1 VALUES(1,3);\n    COMMIT;\n  }\n  execsql {SELECT * FROM t1}\n} {}\ndo_test conflict-10.2 {\n  catchsql {\n    CREATE TABLE t4(x);\n    CREATE UNIQUE INDEX t4x ON t4(x);\n    BEGIN;\n    INSERT OR ROLLBACK INTO t4 VALUES(1);\n    INSERT OR ROLLBACK INTO t4 VALUES(1);\n    COMMIT;\n  }\n  execsql {SELECT * FROM t4}\n} {}\n\n# Ticket #1171.  Make sure statement rollbacks do not\n# damage the database.\n#\ndo_test conflict-11.1 {\n  execsql {\n    -- Create a database object (pages 2, 3 of the file)\n    BEGIN;\n      CREATE TABLE abc(a UNIQUE, b, c);\n      INSERT INTO abc VALUES(1, 2, 3);\n      INSERT INTO abc VALUES(4, 5, 6);\n      INSERT INTO abc VALUES(7, 8, 9);\n    COMMIT;\n  }\n\n  \n  # Set a small cache size so that changes will spill into\n  # the database file.  \n  execsql {\n    PRAGMA cache_size = 10;\n  }\n  \n  # Make lots of changes.  Because of the small cache, some\n  # (most?) of these changes will spill into the disk file.\n  # In other words, some of the changes will not be held in\n  # cache.\n  #\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n\n  # Execute a statement that does a statement rollback due to\n  # a constraint failure.\n  #\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n\n  # Rollback the database.  Verify that the state of the ABC table\n  # is unchanged from the beginning of the transaction.  In other words,\n  # make sure the DELETE on table ABC that occurred within the transaction\n  # had no effect.\n  #\n  execsql {\n    ROLLBACK;\n    SELECT * FROM abc;\n  }\n} {1 2 3 4 5 6 7 8 9}\nintegrity_check conflict-11.2\n\n# Repeat test conflict-11.1 but this time commit.\n#\ndo_test conflict-11.3 {\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      UPDATE abc SET a=a+1;\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n  execsql {\n    ROLLBACK;\n    SELECT * FROM abc;\n  }\n} {1 2 3 4 5 6 7 8 9}\n# Repeat test conflict-11.1 but this time commit.\n#\ndo_test conflict-11.5 {\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n  execsql {\n    COMMIT;\n    SELECT * FROM abc;\n  }\n} {1 2 3 7 8 9}\nintegrity_check conflict-11.6\n\n# Make sure UPDATE OR REPLACE works on tables that have only\n# an INTEGER PRIMARY KEY.\n#\ndo_test conflict-12.1 {\n  execsql {\n    CREATE TABLE t5(a INTEGER PRIMARY KEY, b text);\n    INSERT INTO t5 VALUES(1,'one');\n    INSERT INTO t5 VALUES(2,'two');\n    SELECT * FROM t5\n  }\n} {1 one 2 two}\ndo_test conflict-12.2 {\n  execsql {\n    UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1;\n    SELECT * FROM t5;\n  }\n} {1 one 2 two}\ndo_test conflict-12.3 {\n  catchsql {\n    UPDATE t5 SET a=a+1 WHERE a=1;\n  }\n} {1 {UNIQUE constraint failed: t5.a}}\nverify_ex_errcode conflict-12.3b SQLITE_CONSTRAINT_PRIMARYKEY\ndo_test conflict-12.4 {\n  execsql {\n    UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;\n    SELECT * FROM t5;\n  }\n} {2 one}\ndo_test conflict-12.5 {\n  catchsql {\n    CREATE TABLE t5b(x);\n    INSERT INTO t5b(rowid, x) VALUES(1,10),(2,11);\n    UPDATE t5b SET rowid=rowid+1 WHERE x=10;\n  }\n} {1 {UNIQUE constraint failed: t5b.rowid}}\nverify_ex_errcode conflict-12.5b SQLITE_CONSTRAINT_ROWID\n\n\n# Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]\n# REPLACE works like ABORT on a CHECK constraint.\n#\ndo_test conflict-13.1 {\n  execsql {\n    CREATE TABLE t13(a CHECK(a!=2));\n    BEGIN;\n    REPLACE INTO t13 VALUES(1);\n  }\n  catchsql {\n    REPLACE INTO t13 VALUES(2);\n  }\n} {1 {CHECK constraint failed: t13}}\nverify_ex_errcode conflict-13.1b SQLITE_CONSTRAINT_CHECK\ndo_test conflict-13.2 {\n  execsql {\n    REPLACE INTO t13 VALUES(3);\n    COMMIT;\n    SELECT * FROM t13;\n  }\n} {1 3}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/conflict2.test",
    "content": "# 2013-11-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the conflict resolution extension\n# in WITHOUT ROWID tables\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !conflict {\n  finish_test\n  return\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict2-1.0 {\n  execsql {\n    CREATE TABLE t1(a, b, c, PRIMARY KEY(a,b)) WITHOUT rowid;\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#   t3     Number of temporary files created by this test\n#\nforeach {i cmd t0 t1 t2 t3} {\n  1 INSERT                  1 {}  1  0\n  2 {INSERT OR IGNORE}      0 3   1  0\n  3 {INSERT OR REPLACE}     0 4   1  0\n  4 REPLACE                 0 4   1  0\n  5 {INSERT OR FAIL}        1 {}  1  0\n  6 {INSERT OR ABORT}       1 {}  1  0\n  7 {INSERT OR ROLLBACK}    1 {}  {} 0\n} {\n  do_test conflict2-1.$i {\n    set ::sqlite_opentemp_count 0\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    set r3 $::sqlite_opentemp_count\n    list $r0 $r1 $r2 $r3\n  } [list $t0 $t1 $t2 $t3]\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict2-2.0 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(a,b)) WITHOUT rowid;\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i cmd t0 t1 t2} {\n  1 INSERT                  1 {}  1\n  2 {INSERT OR IGNORE}      0 3   1\n  3 {INSERT OR REPLACE}     0 4   1\n  4 REPLACE                 0 4   1\n  5 {INSERT OR FAIL}        1 {}  1\n  6 {INSERT OR ABORT}       1 {}  1\n  7 {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  do_test conflict2-2.$i {\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\n# Create tables for the first group of tests.\n#\ndo_test conflict2-3.0 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    CREATE TABLE t1(a, b, c INTEGER, PRIMARY KEY(c), UNIQUE(a,b)) WITHOUT rowid;\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i cmd t0 t1 t2} {\n  1 INSERT                  1 {}  1\n  2 {INSERT OR IGNORE}      0 3   1\n  3 {INSERT OR REPLACE}     0 4   1\n  4 REPLACE                 0 4   1\n  5 {INSERT OR FAIL}        1 {}  1\n  6 {INSERT OR ABORT}       1 {}  1\n  7 {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  do_test conflict2-3.$i {\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict2-4.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(x);\n    SELECT x FROM t2;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the UNIQUE constraint\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i conf1 cmd t0 t1 t2} {\n  1 {}       INSERT                  1 {}  1\n  2 REPLACE  INSERT                  0 4   1\n  3 IGNORE   INSERT                  0 3   1\n  4 FAIL     INSERT                  1 {}  1\n  5 ABORT    INSERT                  1 {}  1\n  6 ROLLBACK INSERT                  1 {}  {}\n  7 REPLACE  {INSERT OR IGNORE}      0 3   1\n  8 IGNORE   {INSERT OR REPLACE}     0 4   1\n  9 FAIL     {INSERT OR IGNORE}      0 3   1\n 10 ABORT    {INSERT OR REPLACE}     0 4   1\n 11 ROLLBACK {INSERT OR IGNORE }     0 3   1\n} {\n  do_test conflict2-4.$i {\n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c,PRIMARY KEY(a,b) $conf1) WITHOUT rowid;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict2-5.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(x);\n    SELECT x FROM t2;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the NOT NULL constraint\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i conf1 cmd t0 t1 t2} {\n  1 {}       INSERT                  1 {}  1\n  2 REPLACE  INSERT                  0 5   1\n  3 IGNORE   INSERT                  0 {}  1\n  4 FAIL     INSERT                  1 {}  1\n  5 ABORT    INSERT                  1 {}  1\n  6 ROLLBACK INSERT                  1 {}  {}\n  7 REPLACE  {INSERT OR IGNORE}      0 {}  1\n  8 IGNORE   {INSERT OR REPLACE}     0 5   1\n  9 FAIL     {INSERT OR IGNORE}      0 {}  1\n 10 ABORT    {INSERT OR REPLACE}     0 5   1\n 11 ROLLBACK {INSERT OR IGNORE}      0 {}  1\n 12 {}       {INSERT OR IGNORE}      0 {}  1\n 13 {}       {INSERT OR REPLACE}     0 5   1\n 14 {}       {INSERT OR FAIL}        1 {}  1\n 15 {}       {INSERT OR ABORT}       1 {}  1\n 16 {}       {INSERT OR ROLLBACK}    1 {}  {}\n} {\n  if {$t0} {set t1 {NOT NULL constraint failed: t1.c}}\n  do_test conflict2-5.$i {\n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c NOT NULL $conf1 DEFAULT 5);\n      DELETE FROM t2;\n      BEGIN;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,NULL);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {!$r0} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test conflict2-6.0 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES(1,2,1);\n    INSERT INTO t2 VALUES(2,3,2);\n    INSERT INTO t2 VALUES(3,4,1);\n    INSERT INTO t2 VALUES(4,5,4);\n    SELECT c FROM t2 ORDER BY b;\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n  }\n} {1 2 1 4}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the UNIQUE constraint\n#   cmd    An UPDATE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"b\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t3\n#   t3     Number of temporary files for tables\n#   t4     Number of temporary files for statement journals\n#\n# Update: Since temporary table files are now opened lazily, and none\n# of the following tests use large quantities of data, t3 is always 0.\n#\n# Update (2016-03-04): Subjournals now only open when their size\n# exceeds 64KB.\n#\nforeach {i conf1 cmd t0 t1 t2 t3 t4} {\n  1 {}       UPDATE                  1 {6 7 8 9}  1 0 0\n  2 REPLACE  UPDATE                  0 {7 6 9}    1 0 0\n  3 IGNORE   UPDATE                  0 {6 7 3 9}  1 0 0\n  4 FAIL     UPDATE                  1 {6 7 3 4}  1 0 0\n  5 ABORT    UPDATE                  1 {1 2 3 4}  1 0 0\n  6 ROLLBACK UPDATE                  1 {1 2 3 4}  0 0 0\n  7 REPLACE  {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n  8 IGNORE   {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n  9 FAIL     {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 10 ABORT    {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n 11 ROLLBACK {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 12 {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1 0 0\n 13 {}       {UPDATE OR REPLACE}     0 {7 6 9}    1 0 0\n 14 {}       {UPDATE OR FAIL}        1 {6 7 3 4}  1 0 0\n 15 {}       {UPDATE OR ABORT}       1 {1 2 3 4}  1 0 0\n 16 {}       {UPDATE OR ROLLBACK}    1 {1 2 3 4}  0 0 0\n} {\n\n  # When using in-memory journals, no temporary files are required for\n  # statement journals.\n  if {[permutation] == \"inmemory_journal\"} { set t4 0 }\n\n  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}\n  if {[info exists TEMP_STORE] && $TEMP_STORE==3} {\n    set t3 0\n  } else {\n    set t3 [expr {$t3+$t4}]\n  }\n  do_test conflict2-6.$i {\n    db close\n    sqlite3 db test.db \n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    execsql {pragma temp_store=file}\n    set ::sqlite_opentemp_count 0\n    set r0 [catch {execsql [subst {\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c, PRIMARY KEY(a) $conf1) WITHOUT rowid;\n      INSERT INTO t1 SELECT * FROM t2;\n      UPDATE t3 SET x=0;\n      BEGIN;\n      $cmd t3 SET x=1;\n      $cmd t1 SET b=b*2;\n      $cmd t1 SET a=c+5;\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}\n    set r2 [execsql {SELECT x FROM t3}]\n    list $r0 $r1 $r2 $::sqlite_opentemp_count\n  } [list $t0 $t1 $t2 $t3]\n}\n\n# Test to make sure a lot of IGNOREs don't cause a stack overflow\n#\ndo_test conflict2-7.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n    CREATE TABLE t1(a PRIMARY KEY, b) without rowid;\n  }\n  for {set i 1} {$i<=50} {incr i} {\n    execsql \"INSERT into t1 values($i,[expr {$i+1}]);\"\n  }\n  execsql {\n    SELECT count(*), min(a), max(b) FROM t1;\n  }\n} {50 1 51}\ndo_test conflict2-7.2 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE OR IGNORE t1 SET a=1000;\n  }\n} {1}\ndo_test conflict2-7.2.1 {\n  db changes\n} {1}\ndo_test conflict2-7.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a=1000;\n  }\n} {2}\ndo_test conflict2-7.4 {\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {50}\ndo_test conflict2-7.5 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE OR REPLACE t1 SET a=1001;\n  }\n} {50}\ndo_test conflict2-7.5.1 {\n  db changes\n} {50}\ndo_test conflict2-7.7 {\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {1}\n\n# Update for version 3: A SELECT statement no longer resets the change\n# counter (Test result changes from 0 to 50).\ndo_test conflict2-7.7.1 {\n  db changes\n} {50}\n\n# Make sure the row count is right for rows that are ignored on\n# an insert.\n#\ndo_test conflict2-8.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2);\n  }\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(2,3);\n  }\n} {1}\ndo_test conflict2-8.1.1 {\n  db changes\n} {1}\ndo_test conflict2-8.2 {\n  execsql {\n    INSERT OR IGNORE INTO t1 VALUES(2,4);\n  }\n} {0}\ndo_test conflict2-8.2.1 {\n  db changes\n} {0}\ndo_test conflict2-8.3 {\n  execsql {\n    INSERT OR REPLACE INTO t1 VALUES(2,4);\n  }\n} {1}\ndo_test conflict2-8.3.1 {\n  db changes\n} {1}\ndo_test conflict2-8.4 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT * FROM t1;\n  }\n} {0}\ndo_test conflict2-8.4.1 {\n  db changes\n} {0}\ndo_test conflict2-8.5 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT a+2,b+2 FROM t1;\n  }\n} {2}\ndo_test conflict2-8.5.1 {\n  db changes\n} {2}\ndo_test conflict2-8.6 {\n  execsql {\n    INSERT OR IGNORE INTO t1 SELECT a+3,b+3 FROM t1;\n  }\n} {3}\ndo_test conflict2-8.6.1 {\n  db changes\n} {3}\n\nintegrity_check conflict2-8.99\n\ndo_test conflict2-9.1 {\n  execsql {\n    PRAGMA count_changes=0;\n    CREATE TABLE t2(\n      a INTEGER PRIMARY KEY ON CONFLICT IGNORE,\n      b INTEGER UNIQUE ON CONFLICT FAIL,\n      c INTEGER UNIQUE ON CONFLICT REPLACE,\n      d INTEGER UNIQUE ON CONFLICT ABORT,\n      e INTEGER UNIQUE ON CONFLICT ROLLBACK\n    ) WITHOUT rowid;\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n    SELECT * FROM t3;\n  }\n} {1}\ndo_test conflict2-9.2 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,1,1,1,1);\n    INSERT INTO t2 VALUES(2,2,2,2,2);\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict2-9.3 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,3,3,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict2-9.4 {\n  catchsql {\n    UPDATE t2 SET a=a+1 WHERE a=1;\n    SELECT * FROM t2;\n  }\n} {0 {1 1 1 1 1 2 2 2 2 2}}\ndo_test conflict2-9.5 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,1,3,3,3);\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict2-9.5b {\n  db eval {SELECT * FROM t2;}\n} {1 1 1 1 1 2 2 2 2 2}\ndo_test conflict2-9.6 {\n  catchsql {\n    UPDATE t2 SET b=b+1 WHERE b=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict2-9.6b {\n  db eval {SELECT * FROM t2;}\n} {1 1 1 1 1 2 2 2 2 2}\ndo_test conflict2-9.7 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,1,3,3,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict2-9.8 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {2}\ndo_test conflict2-9.9 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET b=b+1 WHERE b=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.b}}\ndo_test conflict2-9.10 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {3}\ndo_test conflict2-9.11 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,3,1,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict2-9.12 {\n  catchsql {\n    UPDATE t2 SET d=d+1 WHERE d=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict2-9.13 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,3,1,3);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict2-9.14 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {4}\ndo_test conflict2-9.15 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET d=d+1 WHERE d=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.d}}\ndo_test conflict2-9.16 {\n  execsql {COMMIT}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict2-9.17 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,3,3,1);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\ndo_test conflict2-9.18 {\n  catchsql {\n    UPDATE t2 SET e=e+1 WHERE e=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\ndo_test conflict2-9.19 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,3,3,1);\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\nverify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE\ndo_test conflict2-9.20 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict2-9.21 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    UPDATE t2 SET e=e+1 WHERE e=1;\n    SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t2.e}}\nverify_ex_errcode conflict2-9.21b SQLITE_CONSTRAINT_UNIQUE\ndo_test conflict2-9.22 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {5}\ndo_test conflict2-9.23 {\n  catchsql {\n    INSERT INTO t2 VALUES(3,3,1,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {2 2 2 2 2 3 3 1 3 3}}\ndo_test conflict2-9.24 {\n  catchsql {\n    UPDATE t2 SET c=c-1 WHERE c=2;\n    SELECT * FROM t2;\n  }\n} {0 {2 2 1 2 2}}\ndo_test conflict2-9.25 {\n  catchsql {\n    BEGIN;\n    UPDATE t3 SET x=x+1;\n    INSERT INTO t2 VALUES(3,3,1,3,3);\n    SELECT * FROM t2;\n  }\n} {0 {3 3 1 3 3}}\ndo_test conflict2-9.26 {\n  catch {execsql {COMMIT}}\n  execsql {SELECT * FROM t3}\n} {6}\n\ndo_test conflict2-10.1 {\n  catchsql {\n    DELETE FROM t1;\n    BEGIN;\n    INSERT OR ROLLBACK INTO t1 VALUES(1,2);\n    INSERT OR ROLLBACK INTO t1 VALUES(1,3);\n    COMMIT;\n  }\n  execsql {SELECT * FROM t1}\n} {}\ndo_test conflict2-10.2 {\n  catchsql {\n    CREATE TABLE t4(x);\n    CREATE UNIQUE INDEX t4x ON t4(x);\n    BEGIN;\n    INSERT OR ROLLBACK INTO t4 VALUES(1);\n    INSERT OR ROLLBACK INTO t4 VALUES(1);\n    COMMIT;\n  }\n  execsql {SELECT * FROM t4}\n} {}\n\n# Ticket #1171.  Make sure statement rollbacks do not\n# damage the database.\n#\ndo_test conflict2-11.1 {\n  execsql {\n    -- Create a database object (pages 2, 3 of the file)\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY, b, c) WITHOUT rowid;\n      INSERT INTO abc VALUES(1, 2, 3);\n      INSERT INTO abc VALUES(4, 5, 6);\n      INSERT INTO abc VALUES(7, 8, 9);\n    COMMIT;\n  }\n\n  \n  # Set a small cache size so that changes will spill into\n  # the database file.  \n  execsql {\n    PRAGMA cache_size = 10;\n  }\n  \n  # Make lots of changes.  Because of the small cache, some\n  # (most?) of these changes will spill into the disk file.\n  # In other words, some of the changes will not be held in\n  # cache.\n  #\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n\n  # Execute a statement that does a statement rollback due to\n  # a constraint failure.\n  #\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n\n  # Rollback the database.  Verify that the state of the ABC table\n  # is unchanged from the beginning of the transaction.  In other words,\n  # make sure the DELETE on table ABC that occurred within the transaction\n  # had no effect.\n  #\n  execsql {\n    ROLLBACK;\n    SELECT * FROM abc;\n  }\n} {1 2 3 4 5 6 7 8 9}\nintegrity_check conflict2-11.2\n\n# Repeat test conflict2-11.1 but this time commit.\n#\ndo_test conflict2-11.3 {\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      UPDATE abc SET a=a+1;\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n  execsql {\n    ROLLBACK;\n    SELECT * FROM abc;\n  }\n} {1 2 3 4 5 6 7 8 9}\n# Repeat test conflict2-11.1 but this time commit.\n#\ndo_test conflict2-11.5 {\n  execsql {\n    BEGIN;\n      -- Make sure the pager is in EXCLUSIVE state.\n      CREATE TABLE def(d, e, f);\n      INSERT INTO def VALUES\n          ('xxxxxxxxxxxxxxx', 'yyyyyyyyyyyyyyyy', 'zzzzzzzzzzzzzzzz');\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      INSERT INTO def SELECT * FROM def;\n      DELETE FROM abc WHERE a = 4;\n  }\n  catchsql {\n    INSERT INTO abc SELECT 10, 20, 30 FROM def;\n  }\n  execsql {\n    COMMIT;\n    SELECT * FROM abc;\n  }\n} {1 2 3 7 8 9}\nintegrity_check conflict2-11.6\n\n# Make sure UPDATE OR REPLACE works on tables that have only\n# an INTEGER PRIMARY KEY.\n#\ndo_test conflict2-12.1 {\n  execsql {\n    CREATE TABLE t5(a INTEGER PRIMARY KEY, b text) WITHOUT rowid;\n    INSERT INTO t5 VALUES(1,'one');\n    INSERT INTO t5 VALUES(2,'two');\n    SELECT * FROM t5\n  }\n} {1 one 2 two}\ndo_test conflict2-12.2 {\n  execsql {\n    UPDATE OR IGNORE t5 SET a=a+1 WHERE a=1;\n    SELECT * FROM t5;\n  }\n} {1 one 2 two}\ndo_test conflict2-12.3 {\n  catchsql {\n    UPDATE t5 SET a=a+1 WHERE a=1;\n  }\n} {1 {UNIQUE constraint failed: t5.a}}\nverify_ex_errcode conflict2-12.3b SQLITE_CONSTRAINT_PRIMARYKEY\ndo_test conflict2-12.4 {\n  execsql {\n    UPDATE OR REPLACE t5 SET a=a+1 WHERE a=1;\n    SELECT * FROM t5;\n  }\n} {2 one}\n\n\n# Ticket [c38baa3d969eab7946dc50ba9d9b4f0057a19437]\n# REPLACE works like ABORT on a CHECK constraint.\n#\ndo_test conflict2-13.1 {\n  execsql {\n    CREATE TABLE t13(a PRIMARY KEY CHECK(a!=2)) WITHOUT rowid;\n    BEGIN;\n    REPLACE INTO t13 VALUES(1);\n  }\n  catchsql {\n    REPLACE INTO t13 VALUES(2);\n  }\n} {1 {CHECK constraint failed: t13}}\nverify_ex_errcode conflict2-13.1b SQLITE_CONSTRAINT_CHECK\ndo_test conflict2-13.2 {\n  execsql {\n    REPLACE INTO t13 VALUES(3);\n    COMMIT;\n    SELECT * FROM t13;\n  }\n} {1 3}\n\n# Test for an unreleased bug in the REPLACE conflict resolution\n# discovered on 2013-11-09.  \n#\ndo_execsql_test conflict2-14.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\n    x TEXT PRIMARY KEY NOT NULL, \n    y TEXT NOT NULL,\n    z INTEGER\n  );\n  INSERT INTO t1 VALUES('alpha','beta',1);\n  CREATE UNIQUE INDEX t1xy ON t1(x,y);\n  REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);\n  PRAGMA integrity_check;\n  SELECT x,y FROM t1 INDEXED BY t1xy;\n  SELECT x,y,z FROM t1 NOT INDEXED;\n} {ok alpha gamma alpha gamma 1}\ndo_execsql_test conflict2-14.2 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\n    x TEXT PRIMARY KEY NOT NULL, \n    y TEXT NOT NULL,\n    z INTEGER\n  ) WITHOUT ROWID;\n  INSERT INTO t1 VALUES('alpha','beta',1);\n  CREATE UNIQUE INDEX t1xy ON t1(x,y);\n  REPLACE INTO t1(x,y,z) VALUES('alpha','gamma',1);\n  PRAGMA integrity_check;\n  SELECT x,y FROM t1 INDEXED BY t1xy;\n  SELECT x,y,z FROM t1 NOT INDEXED;\n} {ok alpha gamma alpha gamma 1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/conflict3.test",
    "content": "# 2013-11-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the conflict resolution extension\n# to SQLite.\n#\n# This file focuses on making sure that combinations of REPLACE,\n# IGNORE, and FAIL conflict resolution play well together.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix conflict3\n\nifcapable !conflict {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(\n    a INTEGER PRIMARY KEY ON CONFLICT REPLACE, \n    b UNIQUE ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 1.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 1.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 1.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Replete the tests above, but this time on a table non-INTEGER primary key.\n#\ndo_execsql_test 2.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a INT PRIMARY KEY ON CONFLICT REPLACE, \n    b UNIQUE ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 2.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 2.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 2.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Replete again on a WITHOUT ROWID table.\n#\ndo_execsql_test 3.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a INT PRIMARY KEY ON CONFLICT REPLACE, \n    b UNIQUE ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 3.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 3.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 3.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Arrange the table rows in a different order and repeat.\n#\ndo_execsql_test 4.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    b UNIQUE ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL,\n    a INT PRIMARY KEY ON CONFLICT REPLACE\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 4.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 4.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 4.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Arrange the table rows in a different order and repeat.\n#\ndo_execsql_test 5.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    b UNIQUE ON CONFLICT IGNORE,\n    a INT PRIMARY KEY ON CONFLICT REPLACE,\n    c UNIQUE ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 5.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 5.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 5.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Arrange the table rows in a different order and repeat.\n#\ndo_execsql_test 6.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    c UNIQUE ON CONFLICT FAIL,\n    a INT PRIMARY KEY ON CONFLICT REPLACE,\n    b UNIQUE ON CONFLICT IGNORE\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 6.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 6.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 6.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Change which column is the PRIMARY KEY\n#\ndo_execsql_test 7.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a UNIQUE ON CONFLICT REPLACE, \n    b INTEGER PRIMARY KEY ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 7.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 7.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 7.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Change which column is the PRIMARY KEY\n#\ndo_execsql_test 8.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a UNIQUE ON CONFLICT REPLACE, \n    b INT PRIMARY KEY ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 8.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 8.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 8.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Change which column is the PRIMARY KEY\n#\ndo_execsql_test 9.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a UNIQUE ON CONFLICT REPLACE, \n    b INT PRIMARY KEY ON CONFLICT IGNORE,\n    c UNIQUE ON CONFLICT FAIL\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 9.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 9.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 9.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Change which column is the PRIMARY KEY\n#\ndo_execsql_test 10.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a UNIQUE ON CONFLICT REPLACE, \n    b UNIQUE ON CONFLICT IGNORE,\n    c INTEGER PRIMARY KEY ON CONFLICT FAIL\n  );\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 10.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 10.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 10.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Change which column is the PRIMARY KEY\n#\ndo_execsql_test 11.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(\n    a UNIQUE ON CONFLICT REPLACE, \n    b UNIQUE ON CONFLICT IGNORE,\n    c PRIMARY KEY ON CONFLICT FAIL\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,2,3), (2,3,4);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert a row that conflicts on column B.  The insert should be ignored.\n#\ndo_execsql_test 11.2 {\n  INSERT INTO t1(a,b,c) VALUES(3,2,5);\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4}\n\n# Insert two rows where the second conflicts on C.  The first row show go\n# and and then there should be a constraint error.\n#\ndo_test 11.3 {\n  catchsql {INSERT INTO t1(a,b,c) VALUES(4,5,6), (5,6,4);}\n} {1 {UNIQUE constraint failed: t1.c}}\ndo_execsql_test 11.4 {\n  SELECT a,b,c FROM t1 ORDER BY a;\n} {1 2 3 2 3 4 4 5 6}\n\n# Check that ticket [f68dc596c4] has been fixed.\n#\ndo_execsql_test 12.1 {\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n  INSERT INTO t2 VALUES(111, '111');\n}\ndo_execsql_test 12.2 {\n  REPLACE INTO t2 VALUES(NULL, '112'), (111, '111B');\n}\ndo_execsql_test 12.3 {\n  SELECT * FROM t2;\n} {111 111B 112 112}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/contrib01.test",
    "content": "# 2013-06-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file contains test cases that were contributed on the sqlite-users\n# mailing list on 2013-06-05 by Mi Chen at mi.chen@echostar.com.\n#\n# At the time it was contributed, this test failed on trunk, but \n# worked on the NGQP.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test contrib01-1.0 {\n  db eval {\n    CREATE TABLE T1 (B INTEGER NOT NULL,\n                     C INTEGER NOT NULL,\n                     D INTEGER NOT NULL,\n                     E INTEGER NOT NULL,\n                     F INTEGER NOT NULL,\n                     G INTEGER NOT NULL,\n                     H INTEGER NOT NULL,\n                     PRIMARY KEY (B, C, D));\n    \n    CREATE TABLE T2 (A INTEGER NOT NULL,\n                     B INTEGER NOT NULL,\n                     C INTEGER NOT NULL,\n                     PRIMARY KEY (A, B, C));\n    \n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15527);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15560);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15561);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15563);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15564);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15566);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15567);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15569);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15612);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15613);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15638);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15681);\n    INSERT INTO T2(A, B, C) VALUES(702118,16183,15682);\n    \n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15527,6,0,5,5,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15560,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15561,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15563,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15564,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15566,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15567,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15569,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15612,6,0,5,5,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15613,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15638,6,0,5,2,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15681,6,0,5,5,0);\n    INSERT INTO T1(B, C, D, E, F, G, H) VALUES(16183,15682,6,0,5,2,0);\n  }\n} {}\ndo_test contrib01-1.1 {\n  db eval {\n    SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'\n      FROM T1, T2\n     WHERE T1.B = T2.B\n       AND T1.C = T2.C\n     GROUP BY T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H\n     ORDER BY +max(t1.c);\n  }\n} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}\ndo_test contrib01-1.2 {\n  db eval {\n   SELECT T2.A, T2.B, T1.D, T1.E, T1.F, T1.G, T1.H, MAX(T1.C), '^'\n     FROM T1, T2\n    WHERE T1.B = T2.B\n      AND T1.C = T2.C\n    GROUP BY T2.A, T2.B, T1.F, T1.D, T1.E, T1.G, T1.H\n    ORDER BY +max(t1.c);\n  }\n} {702118 16183 6 0 5 5 0 15681 ^ 702118 16183 6 0 5 2 0 15682 ^}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt.test",
    "content": "# 2004 August 30 {}\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.\n#\n# $Id: corrupt.test,v 1.12 2009/07/13 09:41:45 danielk1977 Exp $\n\ncatch {forcedelete test.db test.db-journal test.bu}\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# Construct a large database for testing.\n#\ndo_test corrupt-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randstr(100,100));\n    INSERT INTO t1 VALUES(randstr(90,90));\n    INSERT INTO t1 VALUES(randstr(80,80));\n    INSERT INTO t1 SELECT x || randstr(5,5) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(6,6) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(7,7) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(8,8) FROM t1;\n    INSERT INTO t1 VALUES(randstr(3000,3000));\n    INSERT INTO t1 SELECT x || randstr(9,9) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(10,10) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(11,11) FROM t1;\n    INSERT INTO t1 SELECT x || randstr(12,12) FROM t1;\n    CREATE INDEX t1i1 ON t1(x);\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    DELETE FROM t2 WHERE rowid%5!=0;\n    COMMIT;\n  }\n} {}\nintegrity_check corrupt-1.2\n\n# Setup for the tests.  Make a backup copy of the good database in test.bu.\n# Create a string of garbage data that is 256 bytes long.\n#\nforcecopy test.db test.bu\nset fsize [file size test.db]\nset junk \"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nwhile {[string length $junk]<256} {append junk $junk}\nset junk [string range $junk 0 255]\n\n# Go through the database and write garbage data into each 256 segment\n# of the file.  Then do various operations on the file to make sure that\n# the database engine can recover gracefully from the corruption.\n#\nfor {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} {\n  set tn [expr {$i/256}]\n  db close\n  forcecopy test.bu test.db\n  set fd [open test.db r+]\n  fconfigure $fd -translation binary\n  seek $fd $i\n  puts -nonewline $fd $junk\n  close $fd\n  do_test corrupt-2.$tn.1 {\n    sqlite3 db test.db\n    catchsql {SELECT count(*) FROM sqlite_master}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.2 {\n    catchsql {SELECT count(*) FROM t1}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.3 {\n    catchsql {SELECT count(*) FROM t1 WHERE x>'abcdef'}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.4 {\n    catchsql {SELECT count(*) FROM t2}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.5 {\n    catchsql {CREATE TABLE t3 AS SELECT * FROM t1}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.6 {\n    catchsql {DROP TABLE t1}\n    set x {}\n  } {}\n  do_test corrupt-2.$tn.7 {\n    catchsql {PRAGMA integrity_check}\n    set x {}\n  } {}\n\n  # Check that no page references were leaked.\n  do_test corrupt-2.$tn.8 {\n    set bt [btree_from_db db]\n    db_enter db\n    array set stats [btree_pager_stats $bt]\n    db_leave db\n    set stats(ref)\n  } {0}\n}  \n\n#------------------------------------------------------------------------\n# For these tests, swap the rootpage entries of t1 (a table) and t1i1 (an\n# index on t1) in sqlite_master. Then perform a few different queries\n# and make sure this is detected as corruption.\n#\ndo_test corrupt-3.1 {\n  db close\n  forcecopy test.bu test.db\n  sqlite3 db test.db\n  list\n} {}\ndo_test corrupt-3.2 {\n  set t1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1i1'}]\n  set t1i1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]\n  set cookie [expr [execsql {PRAGMA schema_version}] + 1]\n  execsql \"\n    PRAGMA writable_schema = 1;\n    UPDATE sqlite_master SET rootpage = $t1_r WHERE name = 't1';\n    UPDATE sqlite_master SET rootpage = $t1i1_r WHERE name = 't1i1';\n    PRAGMA writable_schema = 0;\n    PRAGMA schema_version = $cookie;\n  \"\n} {}\n\n# This one tests the case caught by code in checkin [2313].\ndo_test corrupt-3.3 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    INSERT INTO t1 VALUES('abc');\n  }\n} {1 {database disk image is malformed}}\ndo_test corrupt-3.4 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {1 {database disk image is malformed}}\ndo_test corrupt-3.5 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM t1 WHERE oid = 10;\n  }\n} {1 {database disk image is malformed}}\ndo_test corrupt-3.6 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM t1 WHERE x = 'abcde';\n  }\n} {1 {database disk image is malformed}}\n\ndo_test corrupt-4.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n  }\n  for {set i 0} {$i < 10} {incr i} {\n    set text [string repeat $i 220]\n    execsql { INSERT INTO t1 VALUES($i, $text) }\n  }\n  execsql { CREATE INDEX i1 ON t1(b) }\n} {}\ndo_test corrupt-4.2 {\n  set iRoot [db one {SELECT rootpage FROM sqlite_master WHERE name = 'i1'}]\n  set iOffset [hexio_get_int [hexio_read test.db [expr 12+($iRoot-1)*1024] 2]]\n  set data [hexio_render_int32 [expr $iRoot - 1]]\n  hexio_write test.db [expr ($iRoot-1)*1024 + $iOffset] $data\n  db close\n  sqlite3 db test.db\n\n  # The following DELETE statement attempts to delete a cell stored on the\n  # root page of index i1. After this cell is deleted it must be replaced\n  # by a cell retrieved from the child page (a leaf) of the deleted cell.\n  # This will fail, as the block modified the database image so that the\n  # child page of the deleted cell is from a table (intkey) b-tree, not an\n  # index b-tree as expected. At one point this was causing an assert()\n  # to fail.\n  catchsql { DELETE FROM t1 WHERE rowid = 3 }\n} {1 {database disk image is malformed}}\n\ndo_test corrupt-5.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n\n  execsql { PRAGMA page_size = 1024 }\n  set ct \"CREATE TABLE t1(c0 \"\n  set i 0\n  while {[string length $ct] < 950} { append ct \", c[incr i]\" }\n  append ct \")\"\n  execsql $ct\n} {}\n\ndo_test corrupt-5.2 {\n  db close\n  hexio_write test.db 108 00000000 \n  sqlite3 db test.db\n  catchsql { SELECT * FROM sqlite_master }\n} {1 {database disk image is malformed}}\n\n# At one point, the specific corruption caused by this test case was\n# causing a buffer overwrite. Although a crash was never demonstrated,\n# running this testcase under valgrind revealed the problem.\ndo_test corrupt-6.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql { \n    PRAGMA page_size = 1024; CREATE TABLE t1(x);\n  }\n\n  # The root page of t1 is 1024 bytes in size. The header is 8 bytes, and\n  # each of the cells inserted by the following INSERT statements consume\n  # 16 bytes (including the 2 byte cell-offset array entry). So the page\n  # can contain up to 63 cells.\n  for {set i 0} {$i < 63} {incr i} {\n    execsql { INSERT INTO t1 VALUES( randomblob(10) ) }\n  }\n\n  # Free the cell stored right at the end of the page (at offset pgsz-14).\n  execsql { DELETE FROM t1 WHERE rowid=1 }\n  set rootpage [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]\n  db close\n\n  set offset [expr ($rootpage * 1024)-14+2]\n  hexio_write test.db $offset 00FF\n  sqlite3 db test.db \n\n  catchsql { INSERT INTO t1 VALUES( randomblob(10) ) }\n} {1 {database disk image is malformed}}\n\nifcapable oversize_cell_check {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql { \n    PRAGMA page_size = 1024; CREATE TABLE t1(x);\n  }\n\n  do_test corrupt-7.1 {\n    for {set i 0} {$i < 39} {incr i} {\n      execsql {\n        INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');\n      }\n    }\n  } {}\n  db close\n  \n  # Corrupt the root page of table t1 so that the first offset in the \n  # cell-offset array points to the data for the SQL blob associated with\n  # record (rowid=10). The root page still passes the checks in btreeInitPage(),\n  # because the start of said blob looks like the start of a legitimate \n  # page cell.\n  #\n  # Test case cc-2 overwrites the blob so that it no longer looks like a\n  # real cell. But, by the time it is overwritten, btreeInitPage() has already\n  # initialized the root page, so no corruption is detected.\n  #\n  # Test case cc-3 inserts an extra record into t1, forcing balance-deeper\n  # to run. After copying the contents of the root page to the new child,\n  # btreeInitPage() is called on the child. This time, it detects corruption\n  # (because the start of the blob associated with the (rowid=10) record\n  # no longer looks like a real cell). At one point the code assumed that \n  # detecting corruption was not possible at that point, and an assert() failed.\n  #\n  set fd [open test.db r+]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd [expr 1024+8]\n  puts -nonewline $fd \"\\x03\\x14\"\n  close $fd\n  \n  sqlite3 db test.db\n  do_test corrupt-7.2 {\n    execsql { \n      UPDATE t1 SET x = X'870400020003000400050006000700080009000A' \n      WHERE rowid = 10;\n    }\n  } {}\n  do_test corrupt-7.3 {\n    catchsql {\n      INSERT INTO t1 VALUES(X'000100020003000400050006000700080009000A');\n    }\n  } {1 {database disk image is malformed}}\n}\n\ndb close\nforcedelete test.db test.db-journal\ndo_test corrupt-8.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA secure_delete = on;\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(5, randomblob(1900));\n  }\n\n  hexio_write test.db 2044 [hexio_render_int32 2]\n  hexio_write test.db 24   [hexio_render_int32 45]\n\n  catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) }\n} {1 {database disk image is malformed}}\n\ndb close\nforcedelete test.db test.db-journal\ndo_test corrupt-8.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA secure_delete = on;\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(5, randomblob(900));\n    INSERT INTO t1 VALUES(6, randomblob(900));\n  }\n\n  hexio_write test.db 2047 FF\n  hexio_write test.db 24   [hexio_render_int32 45]\n\n  catchsql { INSERT INTO t1 VALUES(4, randomblob(1900)) }\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt2.test",
    "content": "# 2004 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.\n#\n# $Id: corrupt2.test,v 1.20 2009/04/06 17:50:03 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corrupt2\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\nset presql \"\"\ncatch { set presql \"$::G(perm:presql);\" }\nunset -nocomplain ::G(perm:presql)\n\n# The following tests - corrupt2-1.* - create some databases corrupted in\n# specific ways and ensure that SQLite detects them as corrupt.\n#\ndo_test corrupt2-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=0;\n    PRAGMA page_size=1024;\n    CREATE TABLE abc(a, b, c);\n  }\n} {}\n\ndo_test corrupt2-1.2 {\n\n  # Corrupt the 16 byte magic string at the start of the file\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  forcecopy test.db corrupt.db\n  set f [open corrupt.db RDWR]\n  seek $f 8 start\n  puts $f blah\n  close $f\n\n  sqlite3 db2 corrupt.db\n  catchsql \"\n    $::presql\n    SELECT * FROM sqlite_master;\n  \" db2\n} {1 {file is not a database}}\n\ndo_test corrupt2-1.3 {\n  db2 close\n\n  # Corrupt the page-size (bytes 16 and 17 of page 1).\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  forcecopy test.db corrupt.db\n  set f [open corrupt.db RDWR]\n  fconfigure $f -encoding binary\n  seek $f 16 start\n  puts -nonewline $f \"\\x00\\xFF\"\n  close $f\n\n  sqlite3 db2 corrupt.db\n  catchsql \"\n    $::presql\n    SELECT * FROM sqlite_master;\n  \" db2\n} {1 {file is not a database}}\n\ndo_test corrupt2-1.4 {\n  db2 close\n\n  # Corrupt the free-block list on page 1.\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  forcecopy test.db corrupt.db\n  set f [open corrupt.db RDWR]\n  fconfigure $f -encoding binary\n  seek $f 101 start\n  puts -nonewline $f \"\\xFF\\xFF\"\n  close $f\n\n  sqlite3 db2 corrupt.db\n  catchsql \"\n    $::presql\n    SELECT * FROM sqlite_master;\n  \" db2\n} {1 {database disk image is malformed}}\n\ndo_test corrupt2-1.5 {\n  db2 close\n\n  # Corrupt the free-block list on page 1.\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  forcecopy test.db corrupt.db\n  set f [open corrupt.db RDWR]\n  fconfigure $f -encoding binary\n  seek $f 101 start\n  puts -nonewline $f \"\\x00\\xC8\"\n  seek $f 200 start\n  puts -nonewline $f \"\\x00\\x00\"\n  puts -nonewline $f \"\\x10\\x00\"\n  close $f\n\n  sqlite3 db2 corrupt.db\n  catchsql \"\n    $::presql\n    SELECT * FROM sqlite_master;\n  \" db2\n} {1 {database disk image is malformed}}\ndb2 close\n\n# Corrupt a database by having 2 indices of the same name:\ndo_test corrupt2-2.1 {\n\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  forcecopy test.db corrupt.db\n\n  sqlite3 db2 corrupt.db \n  execsql \"\n    $::presql\n    CREATE INDEX a1 ON abc(a);\n    CREATE INDEX a2 ON abc(b);\n    PRAGMA writable_schema = 1;\n    UPDATE sqlite_master \n      SET name = 'a3', sql = 'CREATE INDEX a3' || substr(sql, 16, 10000)\n      WHERE type = 'index';\n    PRAGMA writable_schema = 0;\n  \" db2\n\n  db2 close\n  sqlite3 db2 corrupt.db \n  catchsql \"\n    $::presql\n    SELECT * FROM sqlite_master;\n  \" db2\n} {1 {malformed database schema (a3) - index a3 already exists}}\n\ndb2 close\n\ndo_test corrupt2-3.1 {\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  sqlite3 db2 corrupt.db \n\n  execsql \"\n    $::presql\n    PRAGMA auto_vacuum = 1;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n    INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n  \" db2\n\n  db2 close\n\n  # On the root page of table t2 (page 4), set one of the child page-numbers\n  # to 0. This corruption will be detected when SQLite attempts to update\n  # the pointer-map after moving the content of page 4 to page 3 as part\n  # of the DROP TABLE operation below.\n  #\n  set fd [open corrupt.db r+]\n  fconfigure $fd -encoding binary -translation binary\n  seek $fd [expr 1024*3 + 12]\n  set zCelloffset [read $fd 2]\n  binary scan $zCelloffset S iCelloffset\n  seek $fd [expr 1024*3 + $iCelloffset]\n  puts -nonewline $fd \"\\00\\00\\00\\00\" \n  close $fd\n\n  sqlite3 db2 corrupt.db \n  catchsql \"\n    $::presql\n    DROP TABLE t1;\n  \" db2\n} {1 {database disk image is malformed}}\n\ndo_test corrupt2-4.1 {\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {1 {database disk image is malformed}}\n\ndb2 close\n\nunset -nocomplain result\ndo_test corrupt2-5.1 {\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n  sqlite3 db2 corrupt.db \n\n  execsql \"\n    $::presql\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n    INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100));\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t2;\n    INSERT INTO t1 SELECT * FROM t2;\n  \" db2\n\n  db2 close\n\n  # This block links a page from table t2 into the t1 table structure.\n  #\n  set fd [open corrupt.db r+]\n  fconfigure $fd -encoding binary -translation binary\n  seek $fd [expr 1024 + 12]\n  set zCelloffset [read $fd 2]\n  binary scan $zCelloffset S iCelloffset\n  seek $fd [expr 1024 + $iCelloffset]\n  set zChildPage [read $fd 4]\n  seek $fd [expr 2*1024 + 12]\n  set zCelloffset [read $fd 2]\n  binary scan $zCelloffset S iCelloffset\n  seek $fd [expr 2*1024 + $iCelloffset]\n  puts -nonewline $fd $zChildPage\n  close $fd\n\n  sqlite3 db2 corrupt.db \n  db2 eval $::presql\n  db2 eval {SELECT rowid FROM t1} {\n    set result [db2 eval {pragma integrity_check}]\n    break\n  }\n  set result\n} {{*** in database main ***\nOn tree page 2 cell 0: 2nd reference to page 10\nPage 4 is never used}}\n\ndb2 close\n\nproc corruption_test {args} {\n  set A(-corrupt) {}\n  set A(-sqlprep) {}\n  set A(-tclprep) {}\n  array set A $args\n\n  catch {db close}\n  forcedelete corrupt.db\n  forcedelete corrupt.db-journal\n\n  sqlite3 db corrupt.db \n  db eval $::presql\n  eval $A(-tclprep)\n  db eval $A(-sqlprep)\n  db close\n\n  eval $A(-corrupt)\n\n  sqlite3 db corrupt.db\n  eval $A(-test)\n}\n\nifcapable autovacuum {\n  # The tests within this block - corrupt2-6.* - aim to test corruption\n  # detection within an incremental-vacuum. When an incremental-vacuum\n  # step is executed, the last non-free page of the database file is \n  # moved into a free space in the body of the file. After doing so,\n  # the page reference in the parent page must be updated to refer\n  # to the new location. These tests test the outcome of corrupting\n  # that page reference before performing the incremental vacuum.\n  #\n\n  # The last page in the database page is the second page \n  # in an overflow chain.\n  #\n  corruption_test -sqlprep {\n    PRAGMA auto_vacuum = incremental;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randomblob(2500));\n    INSERT INTO t1 VALUES(2, randomblob(2500));\n    DELETE FROM t1 WHERE a = 1;\n  } -corrupt {\n    hexio_write corrupt.db [expr 1024*5] 00000008\n  } -test {\n    do_test corrupt2-6.1 {\n      catchsql \" $::presql pragma incremental_vacuum = 1 \"\n    } {1 {database disk image is malformed}}\n  }\n\n  # The last page in the database page is a non-root b-tree page.\n  #\n  corruption_test -sqlprep {\n    PRAGMA auto_vacuum = incremental;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, randomblob(2500));\n    INSERT INTO t1 VALUES(2, randomblob(50));\n    INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n    INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n    INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n    INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n    DELETE FROM t1 WHERE a = 1;\n  } -corrupt {\n    hexio_write corrupt.db [expr 1024*2 + 8] 00000009\n  } -test {\n    do_test corrupt2-6.2 {\n      catchsql \" $::presql pragma incremental_vacuum = 1 \"\n    } {1 {database disk image is malformed}}\n  }\n\n  # Set up a pointer-map entry so that the last page of the database\n  # file appears to be a b-tree root page. This should be detected\n  # as corruption.\n  #\n  corruption_test -sqlprep {\n    PRAGMA auto_vacuum = incremental;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, randomblob(2500));\n    INSERT INTO t1 VALUES(2, randomblob(2500));\n    INSERT INTO t1 VALUES(3, randomblob(2500));\n    DELETE FROM t1 WHERE a = 1;\n  } -corrupt {\n    set nPage [expr [file size corrupt.db] / 1024]\n    hexio_write corrupt.db [expr 1024 + ($nPage-3)*5] 010000000\n  } -test {\n    do_test corrupt2-6.3 {\n      catchsql \" $::presql pragma incremental_vacuum = 1 \"\n    } {1 {database disk image is malformed}}\n  }\n\n  if {![nonzero_reserved_bytes]} {\n    corruption_test -sqlprep {\n      PRAGMA auto_vacuum = 1;\n      PRAGMA page_size = 1024;\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1, randomblob(2500));\n      DELETE FROM t1 WHERE a = 1;\n    } -corrupt {\n      set nAppend [expr 1024*207 - [file size corrupt.db]]\n      set fd [open corrupt.db r+]\n      seek $fd 0 end\n      puts -nonewline $fd [string repeat x $nAppend]\n      close $fd\n      hexio_write corrupt.db 28 00000000\n    } -test {\n      do_test corrupt2-6.4 {\n        catchsql \" \n          $::presql \n          BEGIN EXCLUSIVE;\n          COMMIT;\n        \"\n      } {1 {database disk image is malformed}}\n    }\n  }\n}\n\n\nset sqlprep {\n  PRAGMA auto_vacuum = 0;\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE INDEX i1 ON t1(b);\n  INSERT INTO t1 VALUES(1, randomblob(50));\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n  INSERT INTO t1 SELECT NULL, randomblob(50) FROM t1;\n}\n\ncorruption_test -sqlprep $sqlprep -corrupt {\n  # Set the page-flags of one of the leaf pages of the index B-Tree to\n  # 0x0D (interpreted by SQLite as \"leaf page of a table B-Tree\").\n  #\n  set fd [open corrupt.db r+]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd [expr 1024*2 + 8] \n  set zRightChild [read $fd 4]\n  binary scan $zRightChild I iRightChild\n  seek $fd [expr 1024*($iRightChild-1)]\n  puts -nonewline $fd \"\\x0D\"\n  close $fd\n} -test {\n  do_test corrupt2-7.1 {\n    catchsql \" $::presql SELECT b FROM t1 ORDER BY b ASC \"\n  } {1 {database disk image is malformed}}\n}\n\ncorruption_test -sqlprep $sqlprep -corrupt {\n  # Mess up the page-header of one of the leaf pages of the index B-Tree.\n  # The corruption is detected as part of an OP_Prev opcode.\n  #\n  set fd [open corrupt.db r+]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd [expr 1024*2 + 12] \n  set zCellOffset [read $fd 2]\n  binary scan $zCellOffset S iCellOffset\n  seek $fd [expr 1024*2 + $iCellOffset]\n  set zChild [read $fd 4]\n  binary scan $zChild I iChild\n  seek $fd [expr 1024*($iChild-1)+3]\n  puts -nonewline $fd \"\\xFFFF\"\n  close $fd\n} -test {\n  do_test corrupt2-7.1 {\n    catchsql \" $::presql SELECT b FROM t1 ORDER BY b DESC \"\n  } {1 {database disk image is malformed}}\n}\n\ncorruption_test -sqlprep $sqlprep -corrupt {\n  # Set the page-flags of one of the leaf pages of the table B-Tree to\n  # 0x0A (interpreted by SQLite as \"leaf page of an index B-Tree\").\n  #\n  set fd [open corrupt.db r+]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd [expr 1024*1 + 8] \n  set zRightChild [read $fd 4]\n  binary scan $zRightChild I iRightChild\n  seek $fd [expr 1024*($iRightChild-1)]\n  puts -nonewline $fd \"\\x0A\"\n  close $fd\n} -test {\n  do_test corrupt2-8.1 {\n    catchsql \" $::presql SELECT * FROM t1 WHERE rowid=1000 \"\n  } {1 {database disk image is malformed}}\n}\n\ncorruption_test -sqlprep {\n  CREATE TABLE t1(a, b, c); CREATE TABLE t8(a, b, c); CREATE TABLE tE(a, b, c);\n  CREATE TABLE t2(a, b, c); CREATE TABLE t9(a, b, c); CREATE TABLE tF(a, b, c);\n  CREATE TABLE t3(a, b, c); CREATE TABLE tA(a, b, c); CREATE TABLE tG(a, b, c);\n  CREATE TABLE t4(a, b, c); CREATE TABLE tB(a, b, c); CREATE TABLE tH(a, b, c);\n  CREATE TABLE t5(a, b, c); CREATE TABLE tC(a, b, c); CREATE TABLE tI(a, b, c);\n  CREATE TABLE t6(a, b, c); CREATE TABLE tD(a, b, c); CREATE TABLE tJ(a, b, c);\n  CREATE TABLE x1(a, b, c); CREATE TABLE x8(a, b, c); CREATE TABLE xE(a, b, c);\n  CREATE TABLE x2(a, b, c); CREATE TABLE x9(a, b, c); CREATE TABLE xF(a, b, c);\n  CREATE TABLE x3(a, b, c); CREATE TABLE xA(a, b, c); CREATE TABLE xG(a, b, c);\n  CREATE TABLE x4(a, b, c); CREATE TABLE xB(a, b, c); CREATE TABLE xH(a, b, c);\n  CREATE TABLE x5(a, b, c); CREATE TABLE xC(a, b, c); CREATE TABLE xI(a, b, c);\n  CREATE TABLE x6(a, b, c); CREATE TABLE xD(a, b, c); CREATE TABLE xJ(a, b, c);\n} -corrupt {\n  set fd [open corrupt.db r+]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd 108\n  set zRightChild [read $fd 4]\n  binary scan $zRightChild I iRightChild\n  seek $fd [expr 1024*($iRightChild-1)+3]\n  puts -nonewline $fd \"\\x00\\x00\"\n  close $fd\n} -test {\n  do_test corrupt2-9.1 {\n    catchsql \" $::presql SELECT sql FROM sqlite_master \"\n  } {1 {database disk image is malformed}}\n}\n\ncorruption_test -sqlprep {\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(a, b, c);\n  PRAGMA writable_schema = 1;\n  UPDATE sqlite_master SET rootpage = NULL WHERE name = 't2';\n} -test {\n  do_test corrupt2-10.1 {\n    catchsql \" $::presql SELECT * FROM t2 \"\n  } {1 {malformed database schema (t2)}}\n  do_test corrupt2-10.2 {\n    sqlite3_errcode db\n  } {SQLITE_CORRUPT}\n}\n\ncorruption_test -sqlprep {\n  PRAGMA auto_vacuum = incremental;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, randstr(100,100));\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t2 SELECT * FROM t1;\n  DELETE FROM t1;\n} -corrupt {\n  set offset [expr [file size corrupt.db] - 1024]\n  hexio_write corrupt.db $offset FF \n  hexio_write corrupt.db 24   12345678\n} -test {\n  do_test corrupt2-11.1 {\n    catchsql \" $::presql PRAGMA incremental_vacuum \"\n  } {1 {database disk image is malformed}}\n}\ncorruption_test -sqlprep {\n  PRAGMA auto_vacuum = incremental;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, randstr(100,100));\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t1 SELECT NULL, randstr(100,100) FROM t1;\n  INSERT INTO t2 SELECT * FROM t1;\n  DELETE FROM t1;\n} -corrupt {\n  set pgno [expr [file size corrupt.db] / 1024]\n  hexio_write corrupt.db [expr 1024+5*($pgno-3)] 03 \n  hexio_write corrupt.db 24   12345678\n} -test {\n  do_test corrupt2-12.1 {\n    catchsql \" $::presql PRAGMA incremental_vacuum \"\n  } {1 {database disk image is malformed}}\n}\n\nifcapable autovacuum {\n  # It is not possible for the last page in a database file to be the\n  # pending-byte page (AKA the locking page). This test verifies that if\n  # an attempt is made to commit a transaction to such an auto-vacuum \n  # database SQLITE_CORRUPT is returned.\n  #\n  corruption_test -tclprep {\n    db eval { \n      PRAGMA auto_vacuum = full;\n      PRAGMA page_size = 1024;\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(NULL, randstr(50,50));\n    }\n    for {set ii 0} {$ii < 10} {incr ii} {\n      db eval \" $::presql INSERT INTO t1 SELECT NULL, randstr(50,50) FROM t1 \"\n    }\n  } -corrupt {\n    do_test corrupt2-13.1 {\n      file size corrupt.db\n    } $::sqlite_pending_byte\n    hexio_write corrupt.db [expr $::sqlite_pending_byte+1023] 00\n    hexio_write corrupt.db 28 00000000\n  } -test {\n    do_test corrupt2-13.2 {\n      file size corrupt.db\n    } [expr $::sqlite_pending_byte + 1024]\n    do_test corrupt2-13.3 {\n      catchsql { DELETE FROM t1 WHERE rowid < 30; }\n    } {1 {database disk image is malformed}}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that PRAGMA integrity_check detects cases where the freelist-count\n# header field is smaller than the actual number of pages on the freelist.\n#\n\nreset_db\ndo_execsql_test 14.0 {\n  PRAGMA auto_vacuum = 0;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(randomblob(3500));\n  DELETE FROM t1;\n}\n\ndo_execsql_test 14.1 {\n  PRAGMA integrity_check;\n  PRAGMA freelist_count;\n} {ok 3}\n\n# There are now 3 free pages. Modify the header-field so that it \n# (incorrectly) says that just 2 are free.\ndo_test 14.2 {\n  db close\n  hexio_write test.db 36 [hexio_render_int32 2]\n  sqlite3 db test.db\n  execsql { PRAGMA freelist_count }\n} {2}\n\ndo_execsql_test 14.3 {\n  PRAGMA integrity_check;\n} {{*** in database main ***\nMain freelist: free-page count in header is too small}}\n\n# Use 2 of the free pages on the free-list.\n#\ndo_execsql_test 14.4 {\n  INSERT INTO t1 VALUES(randomblob(2500));\n  PRAGMA freelist_count;\n} {0}\n\ndo_execsql_test 14.5 {\n  PRAGMA integrity_check;\n} {{*** in database main ***\nPage 3 is never used}}\n\n\nfinish_test\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt3.test",
    "content": "# 2007 April 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.\n#\n# $Id: corrupt3.test,v 1.2 2007/04/06 21:42:22 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas||direct_read {\n  finish_test\n  return\n}\n\n# Create a database with an overflow page.\n#\ndo_test corrupt3-1.1 {\n  set bigstring [string repeat 0123456789 200]\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES($bigstring);\n  }\n  file size test.db\n} [expr {1024*3}]\n\n# Verify that the file format is as we expect.  The page size\n# should be 1024 bytes.  The only record should have a single\n# overflow page.  The overflow page is page 3.  The pointer to\n# the overflow page is on the last 4 bytes of page 2.\n#\ndo_test corrupt3-1.2 {\n  hexio_get_int [hexio_read test.db 16 2]\n} 1024   ;# The page size is 1024\ndo_test corrupt3-1.3 {\n  hexio_get_int [hexio_read test.db 20 1]\n} 0      ;# Unused bytes per page is 0\ndo_test corrupt3-1.4 {\n  hexio_get_int [hexio_read test.db 2044 4]\n} 3      ;# Overflow page is 3\ndo_test corrupt3-1.5 {\n  hexio_get_int [hexio_read test.db 2048 4]\n} 0      ;# First chained overflow is 0\n\nintegrity_check corrupt3-1.6\n\n# Make the overflow chain loop back on itself.   See if the\n# corruption is detected.   (Actually, the last pointer in\n# an overflow chain is ignored, so this is not an error.)\n#\ndo_test corrupt3-1.7 {\n  db close\n  hexio_write test.db 2048 [hexio_render_int32 3]\n  sqlite3 db test.db\n  catchsql {\n    SELECT x FROM t1\n  }\n} [list 0 $bigstring]\nintegrity_check corrupt3-1.8\n\n# Change the pointer for the first page of the overflow\n# change to be a non-existant page.\n#\ndo_test corrupt3-1.9 {\n  db close\n  hexio_write test.db 2044 [hexio_render_int32 4]\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,10) FROM t1\n  }\n} [list 0 0123456789]\ndo_test corrupt3-1.10 {\n  catchsql {\n    PRAGMA integrity_check\n  }\n} {0 {{*** in database main ***\nOn tree page 2 cell 0: invalid page number 4\nPage 3 is never used}}}\ndo_test corrupt3-1.11 {\n  db close\n  hexio_write test.db 2044 [hexio_render_int32 0]\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,10) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\ndo_test corrupt3-1.12 {\n  catchsql {\n    PRAGMA integrity_check\n  }\n} {0 {{*** in database main ***\nOn tree page 2 cell 0: 1 of 1 pages missing from overflow list starting at 0\nPage 3 is never used}}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt4.test",
    "content": "# 2007 Sept 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.\n#\n# $Id: corrupt4.test,v 1.1 2007/09/07 14:32:07 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n# Create a database with a freelist containing at least two pages.\n#\ndo_test corrupt4-1.1 {\n  set bigstring [string repeat 0123456789 200]\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES($bigstring);\n    CREATE TABLE t2(y);\n    INSERT INTO t2 VALUES(1);\n    DROP TABLE t1;\n  }\n  file size test.db\n} [expr {1024*4}]\n\n# Verify that there are two pages on the freelist.\n#\ndo_test corrupt4-1.2 {\n  execsql {PRAGMA freelist_count}\n} {2}\n\n# Get the page number for the trunk of the freelist.\n#\nset trunkpgno [hexio_get_int [hexio_read test.db 32 4]]\nset baseaddr [expr {($trunkpgno-1)*1024}]\n\n# Verify that the trunk of the freelist has exactly one\n# leaf.\n#\ndo_test corrupt4-1.3 {\n  hexio_get_int [hexio_read test.db [expr {$::baseaddr+4}] 4]\n} {1}\n\n# Insert a negative number as the number of leaves on the trunk.\n# Then try to add a new element to the freelist.\n#\ndo_test corrupt4-1.4 {\n  hexio_write test.db [expr {$::baseaddr+4}] [hexio_render_int32 -100000000]\n  db close\n  sqlite3 db test.db\n  catchsql {\n    DROP TABLE t2\n  }\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt5.test",
    "content": "# 2008 Jan 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  Checks for \n# malformed schema.\n#\n# $Id: corrupt5.test,v 1.3 2009/06/04 02:47:04 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n# Create a database with a freelist containing at least two pages.\n#\ndo_test corrupt5-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    CREATE INDEX i1 ON t1(a,b);\n    PRAGMA writable_schema=ON;\n    UPDATE sqlite_master SET name=NULL, sql=NULL WHERE name='i1';\n  }\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM t1\n  }\n} {1 {malformed database schema (?)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt6.test",
    "content": "# 2008 May 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on corrupt SerialTypeLen values.\n#\n# $Id: corrupt6.test,v 1.2 2008/05/19 15:37:10 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n# Create a simple, small database.\n#\ndo_test corrupt6-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890123456789');\n    INSERT INTO t1(x) VALUES('varint32-01234567890123456789012345678901234567890123456789');\n  }\n  file size test.db\n} [expr {1024*2}]\n\n# Verify that the file format is as we expect.  The page size\n# should be 1024 bytes.\n#\ndo_test corrupt6-1.2 {\n  hexio_get_int [hexio_read test.db 16 2]\n} 1024   ;# The page size is 1024\ndo_test corrupt6-1.3 {\n  hexio_get_int [hexio_read test.db 20 1]\n} 0      ;# Unused bytes per page is 0\n\nintegrity_check corrupt6-1.4\n\n# Verify SerialTypeLen for first field of two records as we expect.\n# SerialTypeLen = (len*2+12) = 60*2+12 = 132\ndo_test corrupt6-1.5.1 {\n  hexio_read test.db 1923 2\n} 8103      ;# First text field size is 81 03 == 131\ndo_test corrupt6-1.5.2 {\n  hexio_read test.db 1987 2\n} 8103      ;# Second text field size is 81 03 == 131\n\n# Verify simple query results as expected.\ndo_test corrupt6-1.6 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 0 {varint32 varint32} ]\nintegrity_check corrupt6-1.7\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Increase SerialTypeLen by 2.\ndo_test corrupt6-1.8.1 {\n  db close\n  hexio_write test.db 1923 8105\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Decrease SerialTypeLen by 2.\ndo_test corrupt6-1.8.2 {\n  db close\n  hexio_write test.db 1923 8101\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Put value of record 1 / field 1 SerialTypeLen back.\ndo_test corrupt6-1.8.3 {\n  db close\n  hexio_write test.db 1923 8103\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 0 {varint32 varint32} ]\nintegrity_check corrupt6-1.8.4\n\n# Adjust value of record 2 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Increase SerialTypeLen by 2.\ndo_test corrupt6-1.9.1 {\n  db close\n  hexio_write test.db 1987 8105\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 2 / field 2 SerialTypeLen and see if the\n# corruption is detected.\n# Decrease SerialTypeLen by 2.\ndo_test corrupt6-1.9.2 {\n  db close\n  hexio_write test.db 1987 8101\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Put value of record 1 / field 2 SerialTypeLen back.\ndo_test corrupt6-1.9.3 {\n  db close\n  hexio_write test.db 1987 8103\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 0 {varint32 varint32} ]\nintegrity_check corrupt6-1.9.4\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF 7F (2 bytes)\ndo_test corrupt6-1.10.1 {\n  db close\n  hexio_write test.db 1923 FF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF 7F (3 bytes)\ndo_test corrupt6-1.10.2 {\n  db close\n  hexio_write test.db 1923 FFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF 7F (4 bytes)\ndo_test corrupt6-1.10.3 {\n  db close\n  hexio_write test.db 1923 FFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF FF 7F (5 bytes)\ndo_test corrupt6-1.10.4 {\n  db close\n  hexio_write test.db 1923 FFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF FF FF 7F (6 bytes, and overflows).\ndo_test corrupt6-1.10.5 {\n  db close\n  hexio_write test.db 1923 FFFFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF FF FF FF 7F (7 bytes, and overflows).\ndo_test corrupt6-1.10.6 {\n  db close\n  hexio_write test.db 1923 FFFFFFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF FF FF FF FF 7F (8 bytes, and overflows).\ndo_test corrupt6-1.10.7 {\n  db close\n  hexio_write test.db 1923 FFFFFFFFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FF FF FF FF FF FF FF FF 7F (9 bytes, and overflows).\ndo_test corrupt6-1.10.8 {\n  db close\n  hexio_write test.db 1923 FFFFFFFFFFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\n# Adjust value of record 1 / field 1 SerialTypeLen and see if the\n# corruption is detected.\n# Set SerialTypeLen to FFFF FF FF FF FF FF FF FF 7F (10 bytes, and overflows).\ndo_test corrupt6-1.10.9 {\n  db close\n  hexio_write test.db 1923 FFFFFFFFFFFFFFFFFF7F\n  sqlite3 db test.db\n  catchsql {\n    SELECT substr(x,1,8) FROM t1\n  }\n} [list 1 {database disk image is malformed}]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt7.test",
    "content": "# 2008 June 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on corrupt cell offsets in a btree page.\n#\n# $Id: corrupt7.test,v 1.8 2009/08/10 10:18:08 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n# Create a simple, small database.\n#\ndo_test corrupt7-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(1);\n    INSERT INTO t1(x) VALUES(2);\n    INSERT INTO t1(x) SELECT x+2 FROM t1;\n    INSERT INTO t1(x) SELECT x+4 FROM t1;\n    INSERT INTO t1(x) SELECT x+8 FROM t1;\n  }\n  file size test.db\n} [expr {1024*2}]\n\n# Verify that the file format is as we expect.  The page size\n# should be 1024 bytes.\n#\ndo_test corrupt7-1.2 {\n  hexio_get_int [hexio_read test.db 16 2]\n} 1024   ;# The page size is 1024\ndo_test corrupt7-1.3 {\n  hexio_get_int [hexio_read test.db 20 1]\n} 0      ;# Unused bytes per page is 0\n\nintegrity_check corrupt7-1.4\n\n# Deliberately corrupt some of the cell offsets in the btree page\n# on page 2 of the database.\ndo_test corrupt7-2.1 {\n  db close\n  hexio_write test.db 1062 FF\n  sqlite3 db test.db\n  db eval {PRAGMA integrity_check(1)}\n} {{*** in database main ***\nOn tree page 2 cell 15: Offset 65457 out of range 945..1020}}\ndo_test corrupt7-2.2 {\n  db close\n  hexio_write test.db 1062 04\n  sqlite3 db test.db\n  db eval {PRAGMA integrity_check(1)}\n} {{*** in database main ***\nOn tree page 2 cell 15: Offset 1201 out of range 945..1020}}\n  \n# The code path that was causing the buffer overrun that this test\n# case was checking for was removed.\n#\n#do_test corrupt7-3.1 {\n#  execsql {\n#    DROP TABLE t1;\n#    CREATE TABLE t1(a, b);\n#    INSERT INTO t1 VALUES(1, 'one');\n#    INSERT INTO t1 VALUES(100, 'one hundred');\n#    INSERT INTO t1 VALUES(100000, 'one hundred thousand');\n#    CREATE INDEX i1 ON t1(b);\n#  }\n#  db close\n#\n#  # Locate the 3rd cell in the index.\n#  set cell_offset [hexio_get_int [hexio_read test.db [expr 1024*2 + 12] 2]]\n#  incr cell_offset [expr 1024*2]\n#  incr cell_offset 1\n#\n#  # This write corrupts the \"header-size\" field of the database record\n#  # stored in the index cell. At one point this was causing sqlite to \n#  # reference invalid memory.\n#  hexio_write test.db $cell_offset FFFF7F\n#  \n#  sqlite3 db test.db\n#  catchsql {\n#    SELECT b FROM t1 WHERE b > 'o' AND b < 'p';\n#  }\n#} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt8.test",
    "content": "# 2008 July 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on corrupt pointer map pages.\n#\n# $Id: corrupt8.test,v 1.2 2008/07/11 03:34:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas||!autovacuum {\n  finish_test\n  return\n}\n\n# Create a database to work with.\n#\ndo_test corrupt8-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=1;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(1);\n    INSERT INTO t1(x) VALUES(2);\n    INSERT INTO t1(x) SELECT x+2 FROM t1;\n    INSERT INTO t1(x) SELECT x+4 FROM t1;\n    INSERT INTO t1(x) SELECT x+8 FROM t1;\n    INSERT INTO t1(x) SELECT x+16 FROM t1;\n    INSERT INTO t1(x) SELECT x+32 FROM t1;\n    INSERT INTO t1(x) SELECT x+64 FROM t1;\n    INSERT INTO t1(x) SELECT x+128 FROM t1;\n    INSERT INTO t1(x) SELECT x+256 FROM t1;\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 SELECT x, x*x FROM t1;\n  }\n  expr {[file size test.db]>1024*12}\n} {1}\nintegrity_check corrupt8-1.2\n\n# Loop through each ptrmap entry.  Corrupt the entry and make sure the\n# corruption is detected by the integrity_check.\n#\nfor {set i 1024} {$i<2048} {incr i 5} {\n  set oldval [hexio_read test.db $i 1]\n  if {$oldval==0} break\n  hexio_write test.db $i 00\n  do_test corrupt8-2.$i.0 {\n    db close\n    sqlite3 db test.db\n    set x [db eval {PRAGMA integrity_check}]\n    expr {$x!=\"ok\"}\n  } {1}\n  for {set k 1} {$k<=5} {incr k} {\n    if {$k==$oldval} continue\n    hexio_write test.db $i 0$k\n    do_test corrupt8-2.$i.$k {\n      db close\n      sqlite3 db test.db\n      set x [db eval {PRAGMA integrity_check}]\n      expr {$x!=\"ok\"}\n    } {1}\n  }\n  hexio_write test.db $i 06\n  do_test corrupt8-2.$i.6 {\n    db close\n    sqlite3 db test.db\n    set x [db eval {PRAGMA integrity_check}]\n    expr {$x!=\"ok\"}\n  } {1}\n  hexio_write test.db $i $oldval\n  if {$oldval>2} {\n    set i2 [expr {$i+1+$i%4}]\n    set oldval [hexio_read test.db $i2 1]\n    hexio_write test.db $i2 [format %02x [expr {($oldval+1)&0xff}]]\n    do_test corrupt8-2.$i.7 {\n      db close\n      sqlite3 db test.db\n      set x [db eval {PRAGMA integrity_check}]\n      expr {$x!=\"ok\"}\n    } {1}\n    hexio_write test.db $i2 $oldval\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corrupt9.test",
    "content": "# 2008 July 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on corruption in the form of duplicate entries on the freelist.\n#\n# $Id: corrupt9.test,v 1.3 2009/06/04 02:47:04 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# We must have the page_size pragma for these tests to work.\n#\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\n# Return the offset to the first (trunk) page of the freelist.  Return\n# zero of the freelist is empty.\n#\nproc freelist_trunk_offset {filename} {\n  if {[hexio_read $filename 36 4]==0} {return 0}\n  set pgno [hexio_get_int [hexio_read $filename 32 4]]\n  return [expr {($pgno-1)*[hexio_get_int [hexio_read $filename 16 2]]}]\n}\n\n# This procedure looks at the first trunk page of the freelist and\n# corrupts that page by overwriting up to N entries with duplicates\n# of the first entry.\n#\nproc corrupt_freelist {filename N} {\n  set offset [freelist_trunk_offset $filename]\n  if {$offset==0} {error \"Freelist is empty\"}\n  set cnt [hexio_get_int [hexio_read $filename [expr {$offset+4}] 4]]\n  set pgno [hexio_read $filename [expr {$offset+8}] 4]\n  for {set i 12} {$N>0 && $i<8+4*$cnt} {incr i 4; incr N -1} {\n    hexio_write $filename [expr {$offset+$i}] $pgno\n  }\n}\n\n# Create a database to work with.  Make sure there are plenty of\n# entries on the freelist.\n#\ndo_test corrupt9-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=NONE;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(1);\n    INSERT INTO t1(x) VALUES(2);\n    INSERT INTO t1(x) SELECT x+2 FROM t1;\n    INSERT INTO t1(x) SELECT x+4 FROM t1;\n    INSERT INTO t1(x) SELECT x+8 FROM t1;\n    INSERT INTO t1(x) SELECT x+16 FROM t1;\n    INSERT INTO t1(x) SELECT x+32 FROM t1;\n    INSERT INTO t1(x) SELECT x+64 FROM t1;\n    INSERT INTO t1(x) SELECT x+128 FROM t1;\n    INSERT INTO t1(x) SELECT x+256 FROM t1;\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 SELECT x, x*x FROM t1;\n    CREATE INDEX i1 ON t1(x);\n    CREATE INDEX i2 ON t2(b,a);\n    DROP INDEX i2;\n  }\n  expr {[file size test.db]>1024*24}\n} {1}\nintegrity_check corrupt9-1.2\n\n# Corrupt the freelist by adding duplicate entries to the freelist.\n# Make sure the corruption is detected.\n#\ndb close\nforcecopy test.db test.db-template\n\ncorrupt_freelist test.db 1\nsqlite3 db test.db\ndo_test corrupt9-2.1 {\n  set x [db eval {PRAGMA integrity_check}]\n  expr {$x!=\"ok\"}\n} {1}\ndo_test corrupt9-2.2 {\n  catchsql {\n    CREATE INDEX i2 ON t2(b,a);\n    REINDEX;\n  }\n} {1 {database disk image is malformed}}\n\n\ndb close\nforcecopy test.db-template test.db\ncorrupt_freelist test.db 2\nsqlite3 db test.db\ndo_test corrupt9-3.1 {\n  set x [db eval {PRAGMA integrity_check}]\n  expr {$x!=\"ok\"}\n} {1}\ndo_test corrupt9-3.2 {\n  catchsql {\n    CREATE INDEX i2 ON t2(b,a);\n    REINDEX;\n  }\n} {1 {database disk image is malformed}}\n\ndb close\nforcecopy test.db-template test.db\ncorrupt_freelist test.db 3\nsqlite3 db test.db\ndo_test corrupt9-4.1 {\n  set x [db eval {PRAGMA integrity_check}]\n  expr {$x!=\"ok\"}\n} {1}\ndo_test corrupt9-4.2 {\n  catchsql {\n    CREATE INDEX i2 ON t2(b,a);\n    REINDEX;\n  }\n} {1 {database disk image is malformed}}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptA.test",
    "content": "# 2008 July 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on corrupt database headers.\n#\n# $Id: corruptA.test,v 1.1 2008/07/11 16:39:23 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n\n# Create a database to work with.\n#\ndo_test corruptA-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(1);\n  }\n  expr {[file size test.db]>=1024}\n} {1}\nintegrity_check corruptA-1.2\n\n# Corrupt the file header in various ways and make sure the corruption\n# is detected when opening the database file.\n#\ndb close\nforcecopy test.db test.db-template\n\nset unreadable_version 02\nifcapable wal { set unreadable_version 03 }\ndo_test corruptA-2.1 {\n  forcecopy test.db-template test.db\n  hexio_write test.db 19 $unreadable_version   ;# the read format number\n  sqlite3 db test.db\n  catchsql {SELECT * FROM t1}  \n} {1 {file is not a database}}\n \ndo_test corruptA-2.2 {\n  db close\n  forcecopy test.db-template test.db\n  hexio_write test.db 21 41   ;# max embedded payload fraction\n  sqlite3 db test.db\n  catchsql {SELECT * FROM t1}  \n} {1 {file is not a database}}\n \ndo_test corruptA-2.3 {\n  db close\n  forcecopy test.db-template test.db\n  hexio_write test.db 22 1f   ;# min embedded payload fraction\n  sqlite3 db test.db\n  catchsql {SELECT * FROM t1}  \n} {1 {file is not a database}}\n \ndo_test corruptA-2.4 {\n  db close\n  forcecopy test.db-template test.db\n  hexio_write test.db 23 21   ;# min leaf payload fraction\n  sqlite3 db test.db\n  catchsql {SELECT * FROM t1}  \n} {1 {file is not a database}}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptB.test",
    "content": "# 2008 Sep 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifically focuses\n# on loops in the B-Tree structure. A loop is formed in a B-Tree structure\n# when there exists a page that is both an a descendent or ancestor of\n# itself.\n#\n# Also test that an SQLITE_CORRUPT error is returned if a B-Tree page\n# contains a (corrupt) reference to a page greater than the configured\n# maximum page number.\n#\n# $Id: corruptB.test,v 1.4 2009/07/21 19:25:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n\ndo_test corruptB-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n  }\n  expr {[file size test.db] > (1024*9)}\n} {1}\nintegrity_check corruptB-1.2\n\nforcecopy test.db bak.db\n\n# Set the right-child of a B-Tree rootpage to refer to the root-page itself.\n#\ndo_test corruptB-1.3.1 {\n  set ::root [execsql {SELECT rootpage FROM sqlite_master}]\n  set ::offset [expr {($::root-1)*1024}]\n  hexio_write test.db [expr $offset+8] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.3.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n# Set the left-child of a cell in a B-Tree rootpage to refer to the \n# root-page itself.\n#\ndo_test corruptB-1.4.1 {\n  db close\n  forcecopy bak.db test.db\n  set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]]\n  hexio_write test.db [expr $offset+$cell_offset] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.4.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n# Now grow the table B-Tree so that it is more than 2 levels high.\n#\ndo_test corruptB-1.5.1 {\n  db close\n  forcecopy bak.db test.db\n  sqlite3 db test.db\n  execsql {\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n  }\n} {}\n\nforcecopy test.db bak.db\n\n# Set the right-child pointer of the right-child of the root page to point\n# back to the root page.\n#\ndo_test corruptB-1.6.1 {\n  db close\n  set iRightChild [hexio_get_int [hexio_read test.db [expr $offset+8] 4]]\n  set c_offset [expr ($iRightChild-1)*1024]\n  hexio_write test.db [expr $c_offset+8] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.6.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n# Set the left-child pointer of a cell of the right-child of the root page to\n# point back to the root page.\n#\ndo_test corruptB-1.7.1 {\n  db close\n  forcecopy bak.db test.db\n  set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]\n  hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.7.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\ndo_test corruptB-1.8.1 {\n  db close\n  set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]]\n  set iLeftChild [\n      hexio_get_int [hexio_read test.db [expr $offset+$cell_offset] 4]\n  ]\n  set c_offset [expr ($iLeftChild-1)*1024]\n  hexio_write test.db [expr $c_offset+8] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.8.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n# Set the left-child pointer of a cell of the right-child of the root page to\n# point back to the root page.\n#\ndo_test corruptB-1.9.1 {\n  db close\n  forcecopy bak.db test.db\n  set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]]\n  hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root]\n} {4}\ndo_test corruptB-1.9.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n#---------------------------------------------------------------------------\n\ndo_test corruptB-2.1.1 {\n  db close\n  forcecopy bak.db test.db\n  hexio_write test.db [expr $offset+8] [hexio_render_int32 0x6FFFFFFF]\n} {4}\ndo_test corruptB-2.1.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 }\n} {1 {database disk image is malformed}}\n\n#---------------------------------------------------------------------------\n\n# Corrupt the header-size field of a database record.\n#\ndo_test corruptB-3.1.1 {\n  db close\n  forcecopy bak.db test.db\n  sqlite3 db test.db\n  set v [string repeat abcdefghij 200]\n  execsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES($v);\n  }\n  set t2_root [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't2'}]\n  set iPage [expr ($t2_root-1)*1024]\n  set iCellarray [expr $iPage + 8]\n  set iRecord [hexio_get_int [hexio_read test.db $iCellarray 2]]\n  db close\n  hexio_write test.db [expr $iPage+$iRecord+3] FF00\n} {2}\ndo_test corruptB-3.1.2 {\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t2 }\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptC.test",
    "content": "# 2004 August 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It creates a base\n# data base file, then tests that single byte corruptions in \n# increasingly larger quantities are handled gracefully.\n#\n# $Id: corruptC.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $\n\ncatch {forcedelete test.db test.db-journal test.bu}\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# Construct a compact, dense database for testing.\n#\ndo_test corruptC-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA legacy_file_format=1;\n    BEGIN;\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT OR IGNORE INTO t1 SELECT x*2,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*3,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*5,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*7,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*11,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*13,y FROM t1;\n    CREATE INDEX t1i1 ON t1(x);\n    CREATE TABLE t2 AS SELECT x,2 as y FROM t1 WHERE rowid%5!=0;\n    COMMIT;\n  }\n} {}\n\nifcapable {integrityck} {\n  integrity_check corruptC-1.2\n}\n\n# Generate random integer\n#\nproc random {range} {\n  return [expr {round(rand()*$range)}]\n}\n\n# Setup for the tests.  Make a backup copy of the good database in test.bu.\n#\ndb close\nforcecopy test.db test.bu\nsqlite3 db test.db\nset fsize [file size test.db]\n\n# Set a quasi-random random seed. \nif {[info exists ::G(issoak)]} {\n  # If we are doing SOAK tests, we want a different\n  # random seed for each run.  Ideally we would like \n  # to use [clock clicks] or something like that here.\n  set qseed [file mtime test.db]\n} else {\n  # If we are not doing soak tests,\n  # make it repeatable.\n  set qseed 0\n}\nexpr srand($qseed)\n\n#\n# First test some specific corruption tests found from earlier runs\n# with specific seeds.\n#\n\n# test that a corrupt content offset size is handled (seed 5577)\ndo_test corruptC-2.1 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 2053 [format %02x 0x04]\n\n  sqlite3 db test.db\n  catchsql {PRAGMA integrity_check}\n} {1 {database disk image is malformed}}\n\n# test that a corrupt content offset size is handled (seed 5649)\n#\n# Update 2016-12-27:  As of check-in [0b86fbca66] \"In sqlite3BtreeInsert() when\n# replacing a re-existing row, try to overwrite the cell directly rather than\n# deallocate and reallocate the cell\" on 2016-12-09, this test case no longer\n# detects the offset size problem during the UPDATE.  We have to run a subsequent\n# integrity_check to see it.\ndo_test corruptC-2.2 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 27   [format %02x 0x08]\n  hexio_write test.db 233  [format %02x 0x6a]\n  hexio_write test.db 328  [format %02x 0x67]\n  hexio_write test.db 750  [format %02x 0x1f]\n  hexio_write test.db 1132 [format %02x 0x52]\n  hexio_write test.db 1133 [format %02x 0x84]\n  hexio_write test.db 1220 [format %02x 0x01]\n  hexio_write test.db 3688 [format %02x 0xc1]\n  hexio_write test.db 3714 [format %02x 0x58]\n  hexio_write test.db 3746 [format %02x 0x9a]\n\n  sqlite3 db test.db\n  db eval {UPDATE t1 SET y=1}\n  db eval {PRAGMA integrity_check}\n} {/Offset .* out of range/}\n\n# test that a corrupt free cell size is handled (seed 13329)\ndo_test corruptC-2.3 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 1094 [format %02x 0x76]\n\n  sqlite3 db test.db\n  catchsql {UPDATE t1 SET y=1}\n} {1 {database disk image is malformed}}\n\n# test that a corrupt free cell size is handled (seed 169571)\ndo_test corruptC-2.4 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 3119 [format %02x 0xdf]\n\n  sqlite3 db test.db\n  catchsql {UPDATE t2 SET y='abcdef-uvwxyz'}\n} {1 {database disk image is malformed}}\n\n# test that a corrupt free cell size is handled (seed 169571)\ndo_test corruptC-2.5 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 3119 [format %02x 0xdf]\n  hexio_write test.db 4073 [format %02x 0xbf]\n\n  sqlite3 db test.db\n  catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}\n  catchsql {PRAGMA integrity_check}\n} {0 {{*** in database main ***\nOn tree page 4 cell 19: Extends off end of page} {database disk image is malformed}}}\n\n# {0 {{*** in database main ***\n# Corruption detected in cell 710 on page 4\n# Multiple uses for byte 661 of page 4\n# Fragmented space is 249 byte reported as 21 on page 4}}}\n\n# test that a corrupt free cell size is handled (seed 169595)\ndo_test corruptC-2.6 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 619 [format %02x 0xe2]\n  hexio_write test.db 3150 [format %02x 0xa8]\n\n  sqlite3 db test.db\n  catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}\n} {1 {database disk image is malformed}}\n\n# corruption (seed 178692)\ndo_test corruptC-2.7 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 3074 [format %02x 0xa0]\n\n  sqlite3 db test.db\n  catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}\n} {1 {database disk image is malformed}}\n\n\n# corruption (seed 179069)\n# Obsolete.  With single-pass DELETE the corruption in the\n# main database is not detected.\nif 0 {\ndo_test corruptC-2.8 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 1393 [format %02x 0x7d]\n  hexio_write test.db 84 [format %02x 0x19]\n  hexio_write test.db 3287 [format %02x 0x3b]\n  hexio_write test.db 2564 [format %02x 0xed]\n  hexio_write test.db 2139 [format %02x 0x55]\n\n  sqlite3 db test.db\n  catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}\n} {1 {database disk image is malformed}}\n}\n\n# corruption (seed 170434)\n#\n# UPDATE: Prior to 3.8.2, this used to return SQLITE_CORRUPT. It no longer\n# does. That is Ok, the point of these tests is to verify that no buffer\n# overruns or overreads can be caused by corrupt databases.\ndo_test corruptC-2.9 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 2095 [format %02x 0xd6]\n\n  sqlite3 db test.db\n  catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}\n} {0 {}}\n\n# corruption (seed 186504)\ndo_test corruptC-2.10 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 3130 [format %02x 0x02]\n  \n  sqlite3 db test.db\n  catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}\n} {1 {database disk image is malformed}}\n\n# corruption (seed 1589)\ndo_test corruptC-2.11 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 55 [format %02x 0xa7]\n  \n  sqlite3 db test.db\n  catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}\n} {1 {database disk image is malformed}}\n\n# corruption (seed 14166)\ndo_test corruptC-2.12 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 974 [format %02x 0x2e]\n  \n  sqlite3 db test.db\n  catchsql {SELECT count(*) FROM sqlite_master;}\n} {1 {malformed database schema (t1i1) - corrupt database}}\n\n# corruption (seed 218803)\ndo_test corruptC-2.13 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 102 [format %02x 0x12]\n  \n  sqlite3 db test.db\n  catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}\n} {1 {database disk image is malformed}}\n\ndo_test corruptC-2.14 {\n  db close\n  forcecopy test.bu test.db\n\n  sqlite3 db test.db\n  set blob [string repeat abcdefghij 10000]\n  execsql { INSERT INTO t1 VALUES (1, $blob) }\n\n  sqlite3 db test.db\n  set filesize [file size test.db]\n  hexio_write test.db [expr $filesize-2048] 00000001\n  catchsql {DELETE FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1)}\n} {1 {database disk image is malformed}}\n\n# At one point this particular corrupt database was causing a buffer\n# overread. Which caused a crash in a run of all.test once.\n#\ndo_test corruptC-2.15 {\n  db close\n  forcecopy test.bu test.db\n  hexio_write test.db 986 b9\n  sqlite3 db test.db\n  catchsql {SELECT count(*) FROM sqlite_master;}\n} {1 {database disk image is malformed}}\n\n#\n# Now test for a series of quasi-random seeds.\n# We loop over the entire file size and touch\n# each byte at least once.\nfor {set tn 0} {$tn<$fsize} {incr tn 1} {\n\n  # setup for test\n  db close\n  forcecopy test.bu test.db\n  sqlite3 db test.db\n\n  # Seek to a random location in the file, and write a random single byte\n  # value.  Then do various operations on the file to make sure that\n  # the database engine can handle the corruption gracefully.\n  #\n  set last 0\n  for {set i 1} {$i<=512 && !$last} {incr i 1} {\n\n    db close\n    if {$i==1} {\n      # on the first corrupt value, use location $tn\n      # this ensures that we touch each location in the \n      # file at least once.\n      set roffset $tn\n    } else { \n      # insert random byte at random location\n      set roffset [random $fsize]\n    }\n    set rbyte [format %02x [random 255]]\n\n    # You can uncomment the following to have it trace\n    # exactly how it's corrupting the file.  This is \n    # useful for generating the \"seed specific\" tests\n    # above.\n    # set rline \"$roffset $rbyte\"\n    # puts stdout $rline\n\n    hexio_write test.db $roffset $rbyte\n    sqlite3 db test.db\n\n    # do a few random operations to make sure that if \n    # they error, they error gracefully instead of crashing.\n    do_test corruptC-3.$tn.($qseed).$i.1 {\n      catchsql {SELECT count(*) FROM sqlite_master}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.2 {\n      catchsql {SELECT count(*) FROM t1}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.3 {\n      catchsql {SELECT count(*) FROM t1 WHERE x>13}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.4 {\n      catchsql {SELECT count(*) FROM t2}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.5 {\n      catchsql {SELECT count(*) FROM t2 WHERE x<13}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.6 {\n      catchsql {BEGIN; UPDATE t1 SET y=1; ROLLBACK;}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.7 {\n      catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.8 {\n      catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.9 {\n      catchsql {BEGIN; DELETE FROM t2 WHERE x<13; ROLLBACK;}\n      set x {}\n    } {}\n    do_test corruptC-3.$tn.($qseed).$i.10 {\n      catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;}\n      set x {}\n    } {}\n\n    # check the integrity of the database.\n    # once the corruption is detected, we can stop.\n    ifcapable {integrityck} {\n      set res [ catchsql {PRAGMA integrity_check} ]\n      set ans [lindex $res 1]\n      if { [ string compare $ans \"ok\" ] != 0 } {\n        set last -1\n      }\n    }\n    # if we are not capable of doing an integrity check,\n    # stop after corrupting 5 bytes.\n    ifcapable {!integrityck} {\n      if { $i > 5 } {\n        set last -1\n      }\n    }\n\n    # Check that no page references were leaked.\n    # TBD:  need to figure out why this doesn't work\n    # work with ROLLBACKs...\n    if {0} {\n      do_test corruptC-3.$tn.($qseed).$i.11 {\n        set bt [btree_from_db db]\n        db_enter db\n        array set stats [btree_pager_stats $bt]\n        db_leave db\n        set stats(ref)\n      } {0}\n    }\n  }\n  # end for i\n\n}\n# end for tn\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptD.test",
    "content": "# 2009 June 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: corruptD.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n#--------------------------------------------------------------------------\n# OVERVIEW\n#\n#   This test file attempts to verify that SQLite does not read past the \n#   end of any in-memory buffers as a result of corrupted database page \n#   images. Usually this happens because a field within a database page\n#   that contains an offset to some other structure within the same page\n#   is set to too large a value. A database page contains the following\n#   such fields:\n#\n#     1. The page header field that contains the offset to the first \n#        free block of space.\n#\n#     2. The first two bytes of all but the last free block on the free-block\n#        list (the offset to the next free block).\n#\n#     3. The page header field containing the number of cells on the page\n#        (implicitly defines the offset to the final element in the cell offset\n#        array, which could potentially be off the end of the page).\n#\n#     4. The page header field containing the offset to the start of the cell\n#        content area.\n#\n#     5. The contents of the cell offset array.\n#\n#     6. The first few bytes of each cell determine the size of the cell\n#        stored within the page, and hence the offset to the final byte of\n#        the cell.\n#\n#   If any of the above fields are set to too large a value, then a buffer\n#   overread may occur. This test script creates and operates on various\n#   strategically corrupted database files to attempt to provoke such buffer\n#   overreads.\n#\n#   Very often, a buffer overread passes unnoticed, particularly in workstation\n#   environments. For this reason, this test script should be run using valgrind\n#   (or similar) in order to verify that no overreads occur.\n#\n# TEST PLAN\n# \n#   Test cases corruptD-1.* are white-box tests. They attempt to corrupt\n#   one of the above fields, then exercise each part of the code in btree.c\n#   that uses said field.\n#   \n#   Offset variables 1, 2, 3 and 4 are all checked to make sure they\n#   will not result in buffer overruns as part of page initialization in\n#   sqlite3BtreeInitPage(). Offsets 5 and 6 cannot be tested as part of\n#   page initialization, as trying to do so causes a performance hit.\n#\n\ndo_test corruptD-1.0 {\n  execsql { \n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n  }\n  for {set ii 1} {$ii < 50} {incr ii} {\n    execsql { INSERT INTO t1 VALUES($ii, $ii * $ii) }\n  }\n  execsql {\n    DELETE FROM t1 WHERE a = 10;\n    DELETE FROM t1 WHERE a = 20;\n    DELETE FROM t1 WHERE a = 30;\n    DELETE FROM t1 WHERE a = 40;\n  }\n  forcecopy test.db test.bu\n} {}\n\nproc incr_change_counter {} {\n  hexio_write test.db 24 [\n    hexio_render_int32 [expr [hexio_get_int [hexio_read test.db 24 4]] + 1]\n  ]\n}\n\nproc restore_file {} {\n  db close\n  forcecopy test.bu test.db\n  sqlite3 db test.db\n}\n\n#-------------------------------------------------------------------------\n# The following tests, corruptD-1.1.*, focus on the page header field\n# containing the offset of the first free block in a page. \n#\ndo_test corruptD-1.1.1 {\n  incr_change_counter\n  hexio_write test.db [expr 1024+1] FFFF\n  catchsql { SELECT * FROM t1 ORDER BY rowid }\n} {1 {database disk image is malformed}}\ndo_test corruptD-1.1.2 {\n  incr_change_counter\n  hexio_write test.db [expr 1024+1] [hexio_render_int32 1021]\n  catchsql { SELECT * FROM t1 ORDER BY rowid }\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n# The following tests, corruptD-1.2.*, focus on the offsets contained\n# in the first 2 byte of each free-block on the free-list.\n#\ndo_test corruptD-1.2.1 {\n  restore_file\n} {}\ndo_test corruptD-1.2.2 {\n} {}\n\n#-------------------------------------------------------------------------\n# The following tests, corruptD-1.4.*, ...\n#\n\n\n#-------------------------------------------------------------------------\n# The following tests, corruptD-1.5.*, focus on the offsets contained\n# in the cell offset array.\n# \n#   defragmentPage\n#\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptE.test",
    "content": "# 2010 February 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite does not crash or\n# segfault if it sees a corrupt database file.  It specifcally\n# focuses on rowid order corruption.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# Do not run the tests in this file if ENABLE_OVERSIZE_CELL_CHECK is on.\n#\nifcapable oversize_cell_check {\n  finish_test\n  return\n}\n\n# Construct a compact, dense database for testing.\n#\ndo_test corruptE-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA legacy_file_format=1;\n    BEGIN;\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT OR IGNORE INTO t1 SELECT x*2,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*3,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*5,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*7,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*11,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*13,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*17,y FROM t1;\n    INSERT OR IGNORE INTO t1 SELECT x*19,y FROM t1;\n    CREATE INDEX t1i1 ON t1(x);\n    CREATE TABLE t2 AS SELECT x,2 as y FROM t1 WHERE rowid%5!=0 ORDER BY rowid;\n    COMMIT;\n  }\n} {}\n\nifcapable {integrityck} {\n  integrity_check corruptE-1.2\n}\n\n# Setup for the tests.  Make a backup copy of the good database in test.bu.\n#\ndb close\nforcecopy test.db test.bu\nsqlite3 db test.db\nset fsize [file size test.db]\n\n\ndo_test corruptE-2.1 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 2041 [format %02x 0x2e]\n\n  sqlite3 db test.db\n\n  catchsql {PRAGMA integrity_check}\n} {/ out of order/}\n\ndo_test corruptE-2.2 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 2047 [format %02x 0x84]\n\n  sqlite3 db test.db\n\n  catchsql {PRAGMA integrity_check}\n} {/ Extends off end of page/}\n\ndo_test corruptE-2.3 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 7420 [format %02x 0xa8]\n  hexio_write test.db 10459 [format %02x 0x8d]\n\n  sqlite3 db test.db\n\n  catchsql {PRAGMA integrity_check}\n} {/out of order/}\n\ndo_test corruptE-2.4 {\n  db close\n  forcecopy test.bu test.db\n\n  # insert corrupt byte(s)\n  hexio_write test.db 10233 [format %02x 0xd0]\n\n  sqlite3 db test.db\n\n  catchsql {PRAGMA integrity_check}\n} {/out of order/}\n\n\nset tests [list {10233 0xd0} \\\n                {941 0x42} \\\n                {2041 0xd0} \\\n                {2042 0x1f} \\\n                {2274 0x75} \\\n                {3267 0xf2} \\\n                {5113 0x36} \\\n                {10233 0x84} \\\n                {10234 0x74} \\\n                {10239 0x41} \\\n                {11273 0x28} \\\n                {11461 0xe6} \\\n                {12297 0xd7} \\\n                {13303 0x53} ]\n\nset tc 1\nforeach test $tests {\n  do_test corruptE-3.$tc {\n    db close\n    forcecopy test.bu test.db\n\n    # insert corrupt byte(s)\n    hexio_write test.db [lindex $test 0] [format %02x [lindex $test 1]]\n\n    sqlite3 db test.db\n\n    catchsql {PRAGMA integrity_check}\n  } {/out of order/}\n  incr tc 1\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptF.test",
    "content": "# 2012 January 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptF\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\nproc str {i} { format %08d $i }\n\n# Create a 6 page database containing a single table - t1. Table t1 \n# consists of page 2 (the root page) and pages 5 and 6 (leaf pages). \n# Database pages 3 and 4 are on the free list.\n#\nproc create_test_db {} {\n  catch { db close }\n  forcedelete test.db\n  sqlite3 db test.db\n  db func str str\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);         /* root page = 2 */\n    CREATE TABLE t2(x);         /* root page = 3 */\n    CREATE TABLE t3(x);         /* root page = 4 */\n\n    INSERT INTO t1 VALUES(str(1));\n    INSERT INTO t1 SELECT str(rowid+1) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+2) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+4) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+8) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+16) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+32) FROM t1;\n    INSERT INTO t1 SELECT str(rowid+64) FROM t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n  }\n  db close\n}\n\ndo_test 1.1 { create_test_db } {}\n\n# Check the db is as we expect. 6 pages in total, with 3 and 4 on the free\n# list. Page 3 is the free list trunk and page 4 is a leaf.\n#\ndo_test 1.2 { file size test.db } [expr 6*1024]\ndo_test 1.3 { hexio_read test.db 32 4 } 00000003\ndo_test 1.4 { hexio_read test.db [expr 2*1024] 12 } 000000000000000100000004\n\n# Change the free-list entry to page 6 and reopen the db file.\ndo_test 1.5 { \n  hexio_write test.db [expr 2*1024 + 8] 00000006 \n  sqlite3 db test.db\n} {}\n\n# Now create a new table in the database file. The root of the new table\n# is page 6, which is also the right-most leaf page in table t1.\n#\ndo_execsql_test 1.6 { \n  CREATE TABLE t4(x);\n  SELECT * FROM sqlite_master;\n} {\n  table t1 t1 2 {CREATE TABLE t1(x)} \n  table t4 t4 6 {CREATE TABLE t4(x)}\n}\n\n# At one point this was causing an assert to fail.\n#\n# This statement opens a cursor on table t1 and does a full table scan. As\n# each row is visited, it is copied into table t4. There is no temporary\n# table.\n#\n# When the t1 cursor reaches page 6 (which is both the right-most leaf of\n# t1 and the root of t4), it continues to iterate through the keys within\n# it (which at this point are keys that have been inserted into t4). And\n# for each row visited, another row is inserted into page 6 - it being the\n# root page of t4. Eventually, page 6 becomes full and the height of the\n# b-tree for table t4 increased. From the point of view of the t1 cursor,\n# this unexpectedly reduces the number of keys on page 6 in the middle of\n# its iteration, which causes an assert() to fail.\n#\ndb_save_and_close\nif 1 {\nfor {set i 0} {$i < 128} {incr i} {\n  db_restore_and_reopen\n  do_test 1.7.$i { \n    set res [\n      catchsql { INSERT INTO t4 SELECT x FROM t1 WHERE rowid>$i }\n    ]\n    if {$res == \"0 {}\" || $res == \"1 {database disk image is malformed}\"} {\n      set res \"\"\n    }\n    set res\n  } {}\n}\n}\n\ndo_test 2.1 { create_test_db } {}\ndo_test 2.2 { file size test.db } [expr 6*1024]\ndo_test 2.3 { hexio_read test.db 32 4 } 00000003\ndo_test 2.4 { hexio_read test.db [expr 2*1024] 12 } 000000000000000100000004\n\n# Change the free-list entry to page 5 and reopen the db file.\ndo_test 2.5 { \n  hexio_write test.db [expr 2*1024 + 8] 00000005 \n  sqlite3 db test.db\n} {}\n\n# Now create a new table in the database file. The root of the new table\n# is page 5, which is also the right-most leaf page in table t1.\n#\ndo_execsql_test 2.6 { \n  CREATE TABLE t4(x);\n  SELECT * FROM sqlite_master;\n} {\n  table t1 t1 2 {CREATE TABLE t1(x)} \n  table t4 t4 5 {CREATE TABLE t4(x)}\n}\n\ndb_save_and_close\nfor {set i 127} {$i >= 0} {incr i -1} {\n  db_restore_and_reopen\n  do_test 2.7.$i { \n    set res [\n      catchsql { \n        INSERT INTO t4 SELECT x FROM t1 WHERE rowid<$i ORDER BY rowid DESC \n      }\n    ]\n    if {$res == \"0 {}\" || $res == \"1 {database disk image is malformed}\"} {\n      set res \"\"\n    }\n    set res\n  } {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptG.test",
    "content": "# 2013-08-01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptG\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\n\n# Create a simple database with a single entry.  Then corrupt the\n# header-size varint on the index payload so that it maps into a\n# negative number.  Try to use the database.\n#\n\ndo_execsql_test 1.1 {\n  PRAGMA page_size=512;\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1(rowid,a,b,c) VALUES(52,'abc','xyz','123');\n  CREATE INDEX t1abc ON t1(a,b,c);\n}\n\nset idxroot [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1abc'}]\n\n# Corrupt the file\ndb close\nhexio_write test.db [expr {$idxroot*512 - 15}] 888080807f\nsqlite3 db test.db\n\n# Try to use the file.\ndo_test 1.2 {\n  catchsql {\n    SELECT c FROM t1 WHERE a>'abc';\n  }\n} {1 {database disk image is malformed}}\ndo_test 1.3 {\n  catchsql {\n     PRAGMA integrity_check\n  }\n} {1 {database disk image is malformed}}\ndo_test 1.4 {\n  catchsql {\n    SELECT c FROM t1 ORDER BY a;\n  }\n} {1 {database disk image is malformed}}\n\n# Corrupt the same file in a slightly different way.  Make the record header\n# sane, but corrupt one of the serial_type value to indicate a huge payload\n# such that the payload begins in allocated space but overflows the buffer.\n#\ndb close\nhexio_write test.db [expr {$idxroot*512-15}] 0513ff7f01\nsqlite3 db test.db\n\ndo_test 2.1 {\n  catchsql {\n    SELECT rowid FROM t1 WHERE a='abc' and b='xyz123456789XYZ';\n  }\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptH.test",
    "content": "# 2014-01-20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptH\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\ndatabase_may_be_corrupt\n\n# The corruption migrations tested by the code in this file are not detected\n# mmap mode.\n#\n# The reason is that in mmap mode, the different queries may use different\n# PgHdr objects for the same page (same data, but different PgHdr container \n# objects). And so the corruption is not detected. \n#\nif {[permutation]==\"mmap\"} {\n  finish_test\n  return\n}\n\n# Initialize the database.\n#\ndo_execsql_test 1.1 {\n  PRAGMA page_size=1024;\n\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n\n  CREATE TABLE t2(x);\n  INSERT INTO t2 VALUES(randomblob(200));\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n  INSERT INTO t2 SELECT randomblob(200) FROM t2;\n} {}\n\n# Corrupt the file so that the root page of t1 is also linked into t2 as\n# a leaf page.\n#\ndo_test 1.2 {\n  db eval { SELECT name, rootpage FROM sqlite_master } { \n    set r($name) $rootpage \n  }\n  db close\n  hexio_write test.db [expr {($r(t2)-1)*1024 + 11}] [format %.2X $r(t1)]\n  sqlite3 db test.db\n} {}\n\ndo_test 1.3 {\n  db eval { PRAGMA secure_delete=1 }\n  list [catch {\n    db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {\n      db eval { DELETE FROM t2 }\n    }\n  } msg] $msg\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\nreset_db\n\n# Initialize the database.\n#\ndo_execsql_test 2.1 {\n  PRAGMA auto_vacuum=0;\n  PRAGMA page_size=1024;\n\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n\n  CREATE TABLE t3(x);\n\n  CREATE TABLE t2(x PRIMARY KEY) WITHOUT ROWID;\n  INSERT INTO t2 VALUES(randomblob(100));\n\n  DROP TABLE t3;\n} {}\n\ndo_test 2.2 {\n  db eval { SELECT name, rootpage FROM sqlite_master } { \n    set r($name) $rootpage \n  }\n  db close\n  set fl [hexio_get_int [hexio_read test.db 32 4]]\n\n  hexio_write test.db [expr {($fl-1) * 1024 + 0}] 00000000 \n  hexio_write test.db [expr {($fl-1) * 1024 + 4}] 00000001 \n  hexio_write test.db [expr {($fl-1) * 1024 + 8}] [format %.8X $r(t1)]\n  hexio_write test.db 36 00000002\n\n  sqlite3 db test.db\n} {}\n\n\n# The trick here is that the root page of the tree scanned by the outer \n# query is also currently on the free-list. So while the first seek on\n# the table (for a==1) works, by the time the second is attempted The \n# \"INSERT INTO t2...\" statements have recycled the root page of t1 and\n# used it as an index leaf. Normally, BtreeMovetoUnpacked() detects\n# that the PgHdr object associated with said root page does not match\n# the cursor (as it is now marked with PgHdr.intKey==0) and returns\n# SQLITE_CORRUPT. \n#\nset res23 {1 {database disk image is malformed}}\ndo_test 2.3 {\n  list [catch {\n  set res [list]\n  db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {\n    db eval { \n      INSERT INTO t2 SELECT randomblob(100) FROM t2;\n      INSERT INTO t2 SELECT randomblob(100) FROM t2;\n      INSERT INTO t2 SELECT randomblob(100) FROM t2;\n      INSERT INTO t2 SELECT randomblob(100) FROM t2;\n      INSERT INTO t2 SELECT randomblob(100) FROM t2;\n    }\n    lappend res $b\n  }\n  set res\n  } msg] $msg\n} $res23\n\n#-------------------------------------------------------------------------\nreset_db\n\n# Initialize the database.\n#\ndo_execsql_test 3.1 {\n  PRAGMA page_size=1024;\n\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n\n  CREATE TABLE t2(c INTEGER PRAGMA KEY, d);\n  INSERT INTO t2 VALUES(1, randomblob(1100));\n} {}\n\ndo_test 3.2 {\n  db eval { SELECT name, rootpage FROM sqlite_master } { \n    set r($name) $rootpage \n  }\n  db close\n\n  hexio_write test.db [expr {($r(t2)-1) * 1024 + 1020}] 00000002\n\n  sqlite3 db test.db\n} {}\n\ndo_test 3.3 {\n  list [catch {\n  db eval { SELECT * FROM t1 WHERE a IN (1, 2) } {\n    db eval { \n      DELETE FROM t2 WHERE c=1;\n    }\n  }\n  } msg] $msg\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptI.test",
    "content": "# 2014-01-20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptI\n\nif {[permutation]==\"mmap\"} {\n  finish_test\n  return\n}\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\ndatabase_may_be_corrupt\n\n# Initialize the database.\n#\ndo_execsql_test 1.1 {\n  PRAGMA page_size=1024;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(a);\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1 VALUES('abcdefghijklmnop');\n} {}\ndb close\n\ndo_test 1.2 {\n  set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]\n  set off [expr 2*1024 + $offset + 1]\n  hexio_write test.db $off 7f06\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 WHERE a = 10 }\n} {0 {}}\n\ndo_test 1.3 {\n  db close\n  set offset [hexio_get_int [hexio_read test.db [expr 2*1024 + 8] 2]]\n  set off [expr 2*1024 + $offset + 1]\n  hexio_write test.db $off FFFF7f02\n  sqlite3 db test.db\n  catchsql { SELECT * FROM t1 WHERE a = 10 }\n} {1 {database disk image is malformed}}\n\ndo_test 2.0 {\n  execsql {\n    CREATE TABLE r(x);\n    INSERT INTO r VALUES('ABCDEFGHIJK');\n    CREATE INDEX r1 ON r(x);\n  }\n  set pg [db one {SELECT rootpage FROM sqlite_master WHERE name = 'r1'}]\n} {5}\n\ndo_test 2.1 {\n  db close\n  set offset [hexio_get_int [hexio_read test.db [expr (5-1)*1024 + 8] 2]]\n  set off [expr (5-1)*1024 + $offset + 1]\n  hexio_write test.db $off FFFF0004\n  sqlite3 db test.db\n  catchsql { SELECT * FROM r WHERE x >= 10.0 }\n} {1 {database disk image is malformed}}\n\ndo_test 2.2 {\n  catchsql { SELECT * FROM r WHERE x >= 10 }\n} {1 {database disk image is malformed}}\n\nif {[db one {SELECT sqlite_compileoption_used('ENABLE_OVERSIZE_CELL_CHECK')}]} {\n  # The following tests only work if OVERSIZE_CELL_CHECK is disabled\n} else {\n  reset_db\n  do_execsql_test 3.1 {\n     PRAGMA auto_vacuum=0;\n     PRAGMA page_size = 512;\n     CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n     WITH s(a, b) AS (\n       SELECT 2, 'abcdefghij'\n       UNION ALL\n       SELECT a+2, b FROM s WHERe a < 40\n     )\n     INSERT INTO t1 SELECT * FROM s;\n   } {}\n   \n   do_test 3.2 {\n     hexio_write test.db [expr 512+3] 0054\n     db close\n     sqlite3 db test.db\n     execsql { INSERT INTO t1 VALUES(5, 'klmnopqrst') }\n     execsql { INSERT INTO t1 VALUES(7, 'klmnopqrst') }\n   } {}\n   \n   db close\n   sqlite3 db test.db\n   do_catchsql_test 3.3 {\n     INSERT INTO t1 VALUES(9, 'klmnopqrst');\n   } {1 {database disk image is malformed}}\n} ;# end-if !defined(ENABLE_OVERSIZE_CELL_CHECK)\n\n\n#-------------------------------------------------------------------------\n# Test that an assert() failure discovered by AFL corrupt database file\n# testing has been fixed.\n#\nreset_db\ndo_execsql_test 4.0 {\n  PRAGMA page_size = 65536;\n  PRAGMA autovacuum = 0;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(-1, 'abcdefghij');\n  INSERT INTO t1 VALUES(0, 'abcdefghij');\n}\n\nset root [db one {SELECT rootpage FROM sqlite_master}]\nset offset [expr ($root-1) * 65536]\n\nifcapable oversize_cell_check {\n  set res {1 {database disk image is malformed}}\n} else {\n  set res {0 {}}\n}\ndo_test 4.1 {\n  db close\n  hexio_write test.db [expr $offset + 8 + 2] 0000\n  hexio_write test.db [expr $offset + 5] 0000\n  sqlite3 db test.db\n  catchsql { DELETE FROM t1 WHERE a=0 }\n} $res\n\n\n#-------------------------------------------------------------------------\n# Database properties:\n#\n#   * Incremental vacuum mode.\n#   * Database root table has a single leaf page.\n#   * Free list consists of a single trunk page.\n#\n# The db is then corrupted by adding the root table leaf page as a free-list\n# leaf page (so that it is referenced twice).\n#\n# Then, a new table is created. The new root page is the current free-list\n# trunk. This means that the root table leaf page is made into the new\n# free list trunk, which corrupts its header. Then, when the new entry is\n# inserted into the root table, things would get chaotic.\n#\nreset_db\ndo_test 5.0 {\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA auto_vacuum = 2;\n  }\n  for {set i 3} {1} {incr i} {\n    execsql \"CREATE TABLE t${i}(x)\"\n    if {[db one {PRAGMA page_count}]>$i} break\n  }\n  set nPage [db one {PRAGMA page_count}]\n  execsql {\n    CREATE TABLE t100(x);\n    DROP TABLE t100;\n  }\n} {}\n\ndo_execsql_test 5.1 { \n  PRAGMA page_count \n} [expr $nPage+1]\n\ndo_test 5.2 { \n  # The last page of the db is now the only leaf of the sqlite_master table.\n  # Corrupt the db by adding it to the free-list as well (the second last\n  # page of the db is the free-list trunk).\n  db close\n  hexio_write test.db [expr 512*($nPage-1)] [\n    format \"%.8X%.8X%.8X\" 0 1 [expr $nPage+1]\n  ]\n} {12}\n\ndo_test 5.3 {\n  sqlite3 db test.db\n  catchsql { CREATE TABLE tx(x); }\n} {1 {database disk image is malformed}}\n\n\n#-------------------------------------------------------------------------\n# Set the payload size of a cell to just less than 2^32 bytes (not\n# possible in an uncorrupted db). Then try to delete the cell. At one\n# point this led to an integer overflow that caused an assert() to fail.\n#\nreset_db\ndo_execsql_test 6.0 {\n  PRAGMA page_size = 512;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(zeroblob(300));\n  INSERT INTO t1 VALUES(zeroblob(600));\n} {}\ndo_test 6.1 {\n  db close\n  hexio_write test.db 616 8FFFFFFF7F02\n  sqlite3 db test.db\n  execsql { DELETE FROM t1 WHERE rowid=2 }\n} {}\n\n#-------------------------------------------------------------------------\n# See what happens if the sqlite_master entry associated with a PRIMARY\n# KEY or UNIQUE index is removed. \n#\nreset_db\ndo_execsql_test 7.0 {\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(x PRIMARY KEY, y);\n  INSERT INTO t1 VALUES('a', 'A');\n  INSERT INTO t1 VALUES('b', 'A');\n  INSERT INTO t1 VALUES('c', 'A');\n  SELECT name FROM sqlite_master;\n} {t1 sqlite_autoindex_t1_1}\ndo_execsql_test 7.1 {\n  PRAGMA writable_schema = 1;\n  DELETE FROM sqlite_master WHERE name = 'sqlite_autoindex_t1_1';\n}\ndo_test 7.2 {\n  db close\n  sqlite3 db test.db\n  catchsql { UPDATE t1 SET x='d' AND y='D' WHERE rowid = 2 }\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n# At one point an assert() would fail if attempt was made to free page 1.\n#\nreset_db\ndo_execsql_test 8.0 {\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(zeroblob(300));\n  INSERT INTO t1 VALUES(zeroblob(300));\n  INSERT INTO t1 VALUES(zeroblob(300));\n  INSERT INTO t1 VALUES(zeroblob(300));\n} {}\n\ndo_test 8.1 {\n  db close\n  hexio_write test.db [expr 1024 + 8] 00000001\n  sqlite3 db test.db\n  catchsql { DELETE FROM t1 }\n} {1 {database disk image is malformed}}\n\ndo_test 8.2 {\n  db close\n  sqlite3 db test.db\n  execsql { PRAGMA integrity_check }\n} {/.*in database main.*/}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptJ.test",
    "content": "# 2015-03-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Corruption consisting of a database page that thinks it is a child\n# of itself.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptJ\n\nif {[permutation]==\"mmap\"} {\n  finish_test\n  return\n}\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\ndatabase_may_be_corrupt\n\n# Initialize the database.\n#\ndo_execsql_test 1.1 {\n  PRAGMA page_size=1024;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(a,b);\n  WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)\n    INSERT INTO t1(a,b) SELECT i, zeroblob(700) FROM c;\n} {}\ndb close\n\n# Corrupt the root page of the t1 table such that the left-child pointer\n# for the very first cell points back to the root.  Then try to DROP the\n# table.  The clearDatabasePage() routine should not loop.\n#\ndo_test 1.2 {\n  hexio_write test.db [expr {2*1024-2}] 02\n  sqlite3 db test.db\n  catchsql { DROP TABLE t1 }\n} {1 {database disk image is malformed}}\n\n# Similar test using a WITHOUT ROWID table\n#\ndo_test 2.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA auto_vacuum=0;\n    CREATE TABLE t1(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;\n    WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)\n      INSERT INTO t1(a,b) SELECT i, zeroblob(200) FROM c;\n  }\n} {}\n\n# The table is three levels deep.  Corrupt the left child of an intermediate\n# page so that it points back to the root page.\n#\ndo_test 2.2 {\n  db close\n  hexio_read test.db [expr {9*1024+391}] 8\n} {00000008814D0401}\ndo_test 2.2b {\n  hexio_write test.db [expr {9*1024+391}] 00000002\n  sqlite3 db test.db\n  catchsql { PRAGMA secure_delete=ON; DROP TABLE t1; }\n} {1 {database disk image is malformed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/corruptK.test",
    "content": "# 2017-03-03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix corruptK\n\nif {[permutation]==\"mmap\"} {\n  finish_test\n  return\n}\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\ndatabase_may_be_corrupt\n\n# Initialize the database.\n# \ndo_execsql_test 1.1 {\n  PRAGMA page_size=1024;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(x);\n\n  INSERT INTO t1 VALUES(randomblob(20));\n  INSERT INTO t1 VALUES(randomblob(100));   -- make this into a free slot\n  INSERT INTO t1 VALUES(randomblob(27));    -- this one will be corrupt\n  INSERT INTO t1 VALUES(randomblob(800));\n\n  DELETE FROM t1 WHERE rowid=2;  -- free the 100 byte slot\n  PRAGMA page_count\n} {2}\n\n\n# Corrupt the database so that the blob stored immediately before \n# the free slot (rowid==3) has an overlarge length field. So that\n# we can use sqlite3_blob_write() to manipulate the size field of\n# the free slot.\n#\n# Then use sqlite3_blob_write() to set the size of said free slot\n# to 24 bytes (instead of the actual 100).\n#\n# Then use the new 24 byte slot. Leaving the in-memory version of\n# the page with zero free slots and a large nFree value. Then try\n# to allocate another slot to get to defragmentPage().\n#\ndo_test 1.2 {\n  db close\n  hexio_write test.db [expr 1024 + 0x360] 21\n  hexio_write test.db [expr 1024 + 0x363] [format %x [expr 31*2 + 12]]\n  sqlite3 db test.db\n\n  set fd [db incrblob t1 x 3]\n  fconfigure $fd -translation binary -encoding binary\n  seek $fd 30\n  puts -nonewline $fd \"\\x18\"\n  close $fd\n} {}\ndo_execsql_test 1.3 {\n  INSERT INTO t1 VALUES(randomblob(20));\n}\ndo_catchsql_test 1.4 {\n  INSERT INTO t1 VALUES(randomblob(90));\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\nreset_db\ndo_execsql_test 2.1 {\n  PRAGMA page_size=1024;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE t1(x);\n\n  INSERT INTO t1 VALUES(randomblob(20));\n  INSERT INTO t1 VALUES(randomblob(20));    -- free this one\n  INSERT INTO t1 VALUES(randomblob(20));\n  INSERT INTO t1 VALUES(randomblob(20));    -- and this one\n  INSERT INTO t1 VALUES(randomblob(20));    -- corrupt this one.\n\n  DELETE FROM t1 WHERE rowid IN(2, 4);\n  PRAGMA page_count\n} {2}\n\ndo_test 2.2 {\n  db close\n  hexio_write test.db [expr 1024 + 0x388] 53\n  hexio_write test.db [expr 1024 + 0x38A] 03812C\n\n  sqlite3 db test.db\n  set fd [db incrblob t1 x 5]\n  fconfigure $fd -translation binary -encoding binary\n\n  seek $fd 22\n  puts -nonewline $fd \"\\x5d\"\n  close $fd\n} {}\n\ndo_catchsql_test 2.3 {\n  INSERT INTO t1 VALUES(randomblob(900));\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n\nifcapable vtab {\nif {[permutation]!=\"inmemory_journal\"} {\n\n  proc hex2blob {hex} {\n    # Split on newlines:\n    set bytes [list]\n    foreach l [split $hex \"\\n\"] {\n      if {[string is space $l]} continue\n      set L [list]\n      foreach b [split $l] {\n        if {[string is xdigit $b] && [string length $b]==2} { \n          lappend L [expr \"0x$b\"]\n        }\n      }\n      if {[llength $L]!=16} {\n        error \"Badly formed hex (1)\"\n      }\n      set bytes [concat $bytes $L]\n    }\n  \n    binary format c* $bytes\n  }\n  \n  reset_db\n  db func hex2blob hex2blob\n  \n  do_execsql_test 3.1 {\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n    CREATE TABLE t3(a, b, c);\n    CREATE TABLE t4(a, b, c);\n    CREATE TABLE t5(a, b, c);\n  }\n  \n  do_execsql_test 3.2 {\n    UPDATE sqlite_dbpage SET data = hex2blob('\n   000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.\n   010: 04 00 01 01 20 40 20 20 00 00 3e d9 00 00 00 06 .... @  ..>.....\n   020: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................\n   030: 0f 00 00 00 00 00 00 00 00 00 00 01 00 00 83 00 ................\n   040: 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 .............8..\n   050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e d9 ..............>.\n   060: 00 2d e6 07 0d 00 00 00 01 03 a0 00 03 e0 00 00 .-..............\n   070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   0d0: 00 00 00 00 00 c1 00 00 00 00 00 00 00 00 00 00 ................\n   0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   160: 00 83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   180: 00 00 00 00 00 00 00 00 00 00 07 00 30 00 00 00 ............0...\n   190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   1c0: 02 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 ................\n   1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   1f0: 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   220: 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   230: 0c 00 00 00 00 00 00 60 00 00 00 06 00 00 c3 00 .......`........\n   240: 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   270: 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   290: 04 00 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   2b0: 00 00 00 00 83 00 8c 00 00 00 00 00 00 00 00 00 ................\n   2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   310: 00 78 00 00 00 00 00 00 00 00 00 00 00 00 70 00 .x............p.\n   320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   340: 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   350: 00 00 00 00 00 68 00 00 00 00 00 00 00 00 00 00 .....h..........\n   360: 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 ................\n   370: 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 ................\n   380: 00 00 00 00 70 00 00 00 00 00 00 00 00 00 00 00 ....p...........\n   390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n   3a0: 5e 01 07 17 1b 1b 01 81 13 74 61 62 6c 65 73 65 ^........tablese\n   3b0: 6e 73 6f 32 73 73 65 6e 73 6f 72 73 02 43 52 45 nso2ssensors.CRE\n   3c0: 41 54 45 20 54 41 42 4c 45 20 73 65 6e 73 6f 72 ATE TABLE sensor\n   3d0: 73 20 0a 20 20 24 20 20 20 20 20 20 20 20 20 20 s .  $          \n   3e0: b8 6e 61 6d 65 21 74 65 78 74 2c 20 79 61 6c 20 .name!text, yal \n   3f0: 72 65 61 6c 2c 20 74 69 6d 65 20 74 65 78 74 29 real, time text)\n    ') WHERE pgno=1\n  }\n  \n  db close\n  sqlite3 db test.db\n  \n  do_catchsql_test 3.3 {\n    PRAGMA integrity_check;\n  } {1 {database disk image is malformed}}\n\n} ;# [permutation]!=\"inmemory_journal\"\n} ;# ifcapable vtab\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cost.test",
    "content": "# 2014-04-26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix cost\n\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t3(id INTEGER PRIMARY KEY, b NOT NULL);\n  CREATE TABLE t4(c, d, e);\n  CREATE UNIQUE INDEX i3 ON t3(b);\n  CREATE UNIQUE INDEX i4 ON t4(c, d);\n}\ndo_eqp_test 1.2 {\n  SELECT e FROM t3, t4 WHERE b=c ORDER BY b, d;\n} {\n  0 0 0 {SCAN TABLE t3 USING COVERING INDEX i3} \n  0 1 1 {SEARCH TABLE t4 USING INDEX i4 (c=?)}\n}\n\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n}\n\n# It is better to use an index for ORDER BY than sort externally, even \n# if the index is a non-covering index.\ndo_eqp_test 2.2 {\n  SELECT * FROM t1 ORDER BY a;\n} {\n  0 0 0 {SCAN TABLE t1 USING INDEX i1}\n}\n\ndo_execsql_test 3.1 {\n  CREATE TABLE t5(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\n  CREATE INDEX t5b ON t5(b);\n  CREATE INDEX t5c ON t5(c);\n  CREATE INDEX t5d ON t5(d);\n  CREATE INDEX t5e ON t5(e);\n  CREATE INDEX t5f ON t5(f);\n  CREATE INDEX t5g ON t5(g);\n}\n\ndo_eqp_test 3.2 {\n  SELECT a FROM t5 \n  WHERE b IS NULL OR c IS NULL OR d IS NULL \n  ORDER BY a;\n} {\n  0 0 0 {SEARCH TABLE t5 USING INDEX t5b (b=?)} \n  0 0 0 {SEARCH TABLE t5 USING INDEX t5c (c=?)} \n  0 0 0 {SEARCH TABLE t5 USING INDEX t5d (d=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n#-------------------------------------------------------------------------\n# If there is no likelihood() or stat3 data, SQLite assumes that a closed\n# range scan (e.g. one constrained by \"col BETWEEN ? AND ?\" constraint)\n# visits 1/64 of the rows in a table.\n#\n# Note: 1/63 =~ 0.016\n# Note: 1/65 =~ 0.015\n#\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n}\ndo_eqp_test 4.2 {\n  SELECT * FROM t1 WHERE likelihood(a=?, 0.014) AND b BETWEEN ? AND ?;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}\n}\ndo_eqp_test 4.3 {\n  SELECT * FROM t1 WHERE likelihood(a=?, 0.016) AND b BETWEEN ? AND ?;\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b>? AND b<?)}\n}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 5.1 {\n  CREATE TABLE t2(x, y);\n  CREATE INDEX t2i1 ON t2(x);\n}\n\ndo_eqp_test 5.2 {\n  SELECT * FROM t2 ORDER BY x, y;\n} {\n  0 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  0 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n}\n\ndo_eqp_test 5.3 {\n  SELECT * FROM t2 WHERE x BETWEEN ? AND ? ORDER BY rowid;\n} {\n  0 0 0 {SEARCH TABLE t2 USING INDEX t2i1 (x>? AND x<?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n# where7.test, where8.test:\n#\ndo_execsql_test 6.1 {\n  CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX t3i1 ON t3(b);\n  CREATE INDEX t3i2 ON t3(c);\n}\n\ndo_eqp_test 6.2 {\n  SELECT a FROM t3 WHERE (b BETWEEN 2 AND 4) OR c=100 ORDER BY a\n} {\n  0 0 0 {SEARCH TABLE t3 USING INDEX t3i1 (b>? AND b<?)} \n  0 0 0 {SEARCH TABLE t3 USING INDEX t3i2 (c=?)}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 7.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\n  CREATE INDEX t1b ON t1(b);\n  CREATE INDEX t1c ON t1(c);\n  CREATE INDEX t1d ON t1(d);\n  CREATE INDEX t1e ON t1(e);\n  CREATE INDEX t1f ON t1(f);\n  CREATE INDEX t1g ON t1(g);\n}\n\ndo_eqp_test 7.2 {\n  SELECT a FROM t1\n     WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)\n  ORDER BY a\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>? AND b<?)} \n  0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\ndo_eqp_test 7.3 {\n  SELECT rowid FROM t1\n  WHERE (+b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n} {\n  0 0 0 {SCAN TABLE t1}\n}\n\ndo_eqp_test 7.4 {\n  SELECT rowid FROM t1 WHERE (+b IS NULL AND c NOT NULL) OR c IS NULL\n} {\n  0 0 0 {SCAN TABLE t1}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 8.1 {\n  CREATE TABLE composer(\n    cid INTEGER PRIMARY KEY,\n    cname TEXT\n  );\n  CREATE TABLE album(\n    aid INTEGER PRIMARY KEY,\n    aname TEXT\n  );\n  CREATE TABLE track(\n    tid INTEGER PRIMARY KEY,\n    cid INTEGER REFERENCES composer,\n    aid INTEGER REFERENCES album,\n    title TEXT\n  );\n  CREATE INDEX track_i1 ON track(cid);\n  CREATE INDEX track_i2 ON track(aid);\n}\n\ndo_eqp_test 8.2 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE cname LIKE '%bach%'\n     AND unlikely(composer.cid=track.cid)\n     AND unlikely(album.aid=track.aid);\n} {\n  0 0 2 {SCAN TABLE track} \n  0 1 0 {SEARCH TABLE album USING INTEGER PRIMARY KEY (rowid=?)}\n  0 2 1 {SEARCH TABLE composer USING INTEGER PRIMARY KEY (rowid=?)}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 9.1 {\n  CREATE TABLE t1(\n    a,b,c,d,e, f,g,h,i,j,\n    k,l,m,n,o, p,q,r,s,t\n  );\n  CREATE INDEX i1 ON t1(k,l,m,n,o,p,q,r,s,t);\n}\ndo_test 9.2 {\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO t1 DEFAULT VALUES }\n  }\n  execsql {\n    ANALYZE;\n    CREATE INDEX i2 ON t1(a,b,c,d,e,f,g,h,i,j);\n  }\n} {}\n\nset L [list a=? b=? c=? d=? e=? f=? g=? h=? i=? j=?]\nforeach {tn nTerm nRow} {\n  1   1 10\n  2   2  9\n  3   3  8\n  4   4  7\n  5   5  6\n  6   6  5\n  7   7  5\n  8   8  5\n  9   9  5\n  10 10  5\n} {\n  set w [join [lrange $L 0 [expr $nTerm-1]] \" AND \"]\n  set p1 [expr ($nRow-1) / 100.0]\n  set p2 [expr ($nRow+1) / 100.0]\n\n  set sql1 \"SELECT * FROM t1 WHERE likelihood(k=?, $p1) AND $w\"\n  set sql2 \"SELECT * FROM t1 WHERE likelihood(k=?, $p2) AND $w\"\n\n  do_eqp_test 9.3.$tn.1 $sql1 {/INDEX i1/}\n  do_eqp_test 9.3.$tn.2 $sql2 {/INDEX i2/}\n}\n\n\n#-------------------------------------------------------------------------\n#\n\nifcapable stat4 {\n  do_execsql_test 10.1 {\n    CREATE TABLE t6(a, b, c);\n    CREATE INDEX t6i1 ON t6(a, b);\n    CREATE INDEX t6i2 ON t6(c);\n  }\n  \n  do_test 10.2 {\n    for {set i 0} {$i < 16} {incr i} {\n      execsql { INSERT INTO t6 VALUES($i%4, 'xyz', $i%8) }\n    }\n    execsql ANALYZE\n  } {}\n\n  do_eqp_test 10.3 {\n    SELECT rowid FROM t6 WHERE a=0 AND c=0\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX t6i2 (c=?)}\n  }\n\n  do_eqp_test 10.4 {\n    SELECT rowid FROM t6 WHERE a=0 AND b='xyz' AND c=0\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX t6i2 (c=?)}\n  }\n\n  do_eqp_test 10.5 {\n    SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND c=0\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX t6i1 (a=?)}\n  }\n\n  do_eqp_test 10.6 {\n    SELECT rowid FROM t6 WHERE likelihood(a=0, 0.1) AND b='xyz' AND c=0\n  } {\n    0 0 0 {SEARCH TABLE t6 USING INDEX t6i1 (a=? AND b=?)}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/count.test",
    "content": "# 2009-02-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing \"SELECT count(*)\" statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test plan:\n#\n#  count-0.*: Make sure count(*) works on an empty database.  (Ticket #3774)\n#\n#  count-1.*: Test that the OP_Count instruction appears to work on both\n#             tables and indexes. Test both when they contain 0 entries,\n#             when all entries are on the root page, and when the b-tree\n#             forms a structure 2 and 3 levels deep.\n#\n#\n\ndo_test count-0.1 {\n  db eval {\n     SELECT count(*) FROM sqlite_master;\n  }\n} {0}\n\nset iTest 0\nforeach zIndex [list {\n  /* no-op */\n} {\n  CREATE INDEX i1 ON t1(a);\n}] { \n  incr iTest\n  do_test count-1.$iTest.1 {\n    execsql {\n      DROP TABLE IF EXISTS t1;\n      CREATE TABLE t1(a, b);\n    }\n    execsql $zIndex\n    execsql { SELECT count(*) FROM t1 }\n  } {0}\n  \n  do_test count-1.$iTest.2 {\n    execsql {\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      SELECT count(*) FROM t1;\n    }\n  } {2}\n\n  do_test count-1.$iTest.3 {\n    execsql {\n      INSERT INTO t1 SELECT * FROM t1;          --   4\n      INSERT INTO t1 SELECT * FROM t1;          --   8\n      INSERT INTO t1 SELECT * FROM t1;          --  16\n      INSERT INTO t1 SELECT * FROM t1;          --  32\n      INSERT INTO t1 SELECT * FROM t1;          --  64\n      INSERT INTO t1 SELECT * FROM t1;          -- 128\n      INSERT INTO t1 SELECT * FROM t1;          -- 256\n      SELECT count(*) FROM t1;\n    }\n  } {256}\n  \n  do_test count-1.$iTest.4 {\n    execsql {\n      INSERT INTO t1 SELECT * FROM t1;          --  512\n      INSERT INTO t1 SELECT * FROM t1;          -- 1024\n      INSERT INTO t1 SELECT * FROM t1;          -- 2048\n      INSERT INTO t1 SELECT * FROM t1;          -- 4096\n      SELECT count(*) FROM t1;\n    }\n  } {4096}\n  \n  do_test count-1.$iTest.5 {\n    execsql {\n      BEGIN;\n      INSERT INTO t1 SELECT * FROM t1;          --  8192\n      INSERT INTO t1 SELECT * FROM t1;          -- 16384\n      INSERT INTO t1 SELECT * FROM t1;          -- 32768\n      INSERT INTO t1 SELECT * FROM t1;          -- 65536\n      COMMIT;\n      SELECT count(*) FROM t1;\n    }\n  } {65536}\n}\n\nproc uses_op_count {sql} {\n  if {[lsearch [execsql \"EXPLAIN $sql\"] Count]>=0} {\n    return 1;\n  }\n  return 0\n}\n\ndo_test count-2.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n  }\n  uses_op_count {SELECT count(*) FROM t2}\n} {1}\ndo_test count-2.2 {\n  catchsql {SELECT count(DISTINCT *) FROM t2}\n} {1 {near \"*\": syntax error}}\ndo_test count-2.3 {\n  uses_op_count {SELECT count(DISTINCT a) FROM t2}\n} {0}\ndo_test count-2.4 {\n  uses_op_count {SELECT count(a) FROM t2}\n} {0}\ndo_test count-2.5 {\n  uses_op_count {SELECT count() FROM t2}\n} {1}\ndo_test count-2.6 {\n  catchsql {SELECT count(DISTINCT) FROM t2}\n} {1 {DISTINCT aggregates must have exactly one argument}}\ndo_test count-2.7 {\n  uses_op_count {SELECT count(*)+1 FROM t2}\n} {0}\ndo_test count-2.8 {\n  uses_op_count {SELECT count(*) FROM t2 WHERE a IS NOT NULL}\n} {0}\ndo_test count-2.9 {\n  catchsql {SELECT count(*) FROM t2 HAVING count(*)>1}\n} {1 {a GROUP BY clause is required before HAVING}}\ndo_test count-2.10 {\n  uses_op_count {SELECT count(*) FROM (SELECT 1)}\n} {0}\ndo_test count-2.11 {\n  execsql { CREATE VIEW v1 AS SELECT 1 AS a }\n  uses_op_count {SELECT count(*) FROM v1}\n} {0}\ndo_test count-2.12 {\n  uses_op_count {SELECT count(*), max(a) FROM t2}\n} {0}\ndo_test count-2.13 {\n  uses_op_count {SELECT count(*) FROM t1, t2}\n} {0}\n\nifcapable vtab {\n  register_echo_module [sqlite3_connection_pointer db]\n  do_test count-2.14 {\n    execsql { CREATE VIRTUAL TABLE techo USING echo(t1); }\n    uses_op_count {SELECT count(*) FROM techo}\n  } {0}\n}\n\ndo_test count-3.1 {\n  execsql {\n    CREATE TABLE t3(a, b);\n    SELECT a FROM (SELECT count(*) AS a FROM t3) WHERE a==0;\n  }\n} {0}\ndo_test count-3.2 {\n  execsql {\n    SELECT a FROM (SELECT count(*) AS a FROM t3) WHERE a==1;\n  }\n} {}\n\ndo_test count-4.1 {\n  execsql {\n    CREATE TABLE t4(a, b);\n    INSERT INTO t4 VALUES('a', 'b');\n    CREATE INDEX t4i1 ON t4(b, a);\n    SELECT count(*) FROM t4;\n  }\n} {1}\ndo_test count-4.2 {\n  execsql {\n    CREATE INDEX t4i2 ON t4(b);\n    SELECT count(*) FROM t4;\n  }\n} {1}\ndo_test count-4.3 {\n  execsql {\n    DROP INDEX t4i1;\n    CREATE INDEX t4i1 ON t4(b, a);\n    SELECT count(*) FROM t4;\n  }\n} {1}\n\ndo_execsql_test count-5.1 {\n  CREATE TABLE t5(a TEXT PRIMARY KEY, b VARCHAR(50)) WITHOUT ROWID;\n  INSERT INTO t5 VALUES('bison','jazz');\n  SELECT count(*) FROM t5;\n} {1}\n\ndo_catchsql_test count-6.1 {\n  CREATE TABLE t6(x);\n  SELECT count(DISTINCT) FROM t6 GROUP BY x;\n} {1 {DISTINCT aggregates must have exactly one argument}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/coveridxscan.test",
    "content": "# 2012 September 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the optimization which attempts to use a covering index\n# for a full-table scan (under the theory that the index will be smaller\n# and require less I/O and hence will run faster.)\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix coveridxscan\n\ndo_test 1.1 {\n  db eval {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(5,4,3), (4,8,2), (3,2,1);\n    CREATE INDEX t1ab ON t1(a,b);\n    CREATE INDEX t1b ON t1(b);\n    SELECT a FROM t1;\n  }\n  # covering index used for the scan, hence values are increasing\n} {3 4 5}\n\ndo_test 1.2 {\n  db eval {\n    SELECT a, c FROM t1;\n  }\n  # There is no covering index, hence the values are in rowid order\n} {5 3 4 2 3 1}\n\ndo_test 1.3 {\n  db eval {\n    SELECT b FROM t1;\n  }\n  # Choice of two indices: use the one with fewest columns\n} {2 4 8}\n\ndo_test 2.1 {\n  optimization_control db cover-idx-scan 0\n  db eval {SELECT a FROM t1}\n  # With the optimization turned off, output in rowid order\n} {5 4 3}\ndo_test 2.2 {\n  db eval {SELECT a, c FROM t1}\n} {5 3 4 2 3 1}\ndo_test 2.3 {\n  db eval {SELECT b FROM t1}\n} {4 8 2}\n\ndb close\nsqlite3_shutdown\nsqlite3_config_cis 0\nsqlite3 db test.db\n\ndo_test 3.1 {\n  db eval {SELECT a FROM t1}\n  # With the optimization configured off, output in rowid order\n} {5 4 3}\ndo_test 3.2 {\n  db eval {SELECT a, c FROM t1}\n} {5 3 4 2 3 1}\ndo_test 3.3 {\n  db eval {SELECT b FROM t1}\n} {4 8 2}\n\ndb close\nsqlite3_shutdown\nsqlite3_config_cis 1\nsqlite3 db test.db\n\n# The CIS optimization is enabled again.  Covering indices are once again\n# used for all table scans.\ndo_test 4.1 {\n  db eval {SELECT a FROM t1}\n} {3 4 5}\ndo_test 4.2 {\n  db eval {SELECT a, c FROM t1}\n} {5 3 4 2 3 1}\ndo_test 4.3 {\n  db eval {SELECT b FROM t1}\n} {2 4 8}\n\n#-------------------------------------------------------------------------\n# Test that indexes with large numbers of columns can be correctly \n# identified as covering indexes.\nreset_db\nset L [list]\nfor {set i 1} {$i<120} {incr i} {\n  lappend L \"c$i\"\n}\nset cols [join $L ,]\n\ndo_execsql_test 5.1.0 \"\n  CREATE TABLE t1(a, b, c, $cols, PRIMARY KEY(a, b, c)) WITHOUT ROWID;\n  CREATE INDEX i1 ON t1($cols);\n\n  CREATE TABLE t2(i INTEGER PRIMARY KEY, $cols);\n  CREATE INDEX i2 ON t2($cols);\n\"\n\ndo_eqp_test 5.1.1 {\n  SELECT * FROM t1 ORDER BY c1, c2;\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}\n}\n\ndo_eqp_test 5.1.2 {\n  SELECT * FROM t2 ORDER BY c1, c2;\n} {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX i2}\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# The focus of this file is testing the ability of the database to\n# uses its rollback journal to recover intact (no database corruption)\n# from a power failure during the middle of a COMMIT.  The OS interface\n# modules are overloaded using the modified I/O routines found in test6.c.  \n# These routines allow us to simulate the kind of file damage that \n# occurs after a power failure.\n#\n# $Id: crash.test,v 1.27 2008/01/08 15:18:52 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\nset repeats 100\n#set repeats 10\n\n# The following procedure computes a \"signature\" for table \"abc\".  If\n# abc changes in any way, the signature should change.  \nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]\n}\nproc signature2 {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc2}]\n}\n\n#--------------------------------------------------------------------------\n# Simple crash test:\n#\n# crash-1.1: Create a database with a table with two rows.\n# crash-1.2: Run a 'DELETE FROM abc WHERE a = 1' that crashes during\n#            the first journal-sync.\n# crash-1.3: Ensure the database is in the same state as after crash-1.1.\n# crash-1.4: Run a 'DELETE FROM abc WHERE a = 1' that crashes during\n#            the first database-sync.\n# crash-1.5: Ensure the database is in the same state as after crash-1.1.\n# crash-1.6: Run a 'DELETE FROM abc WHERE a = 1' that crashes during\n#            the second journal-sync.\n# crash-1.7: Ensure the database is in the same state as after crash-1.1.\n#\n# Tests 1.8 through 1.11 test for crashes on the third journal sync and\n# second database sync.  Neither of these is required in such a small test\n# case, so these tests are just to verify that the test infrastructure\n# operates as expected.\n#\ndo_test crash-1.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(4, 5, 6);\n  }\n  set ::sig [signature]\n  expr 0\n} {0}\nfor {set i 0} {$i<10} {incr i} {\n  set seed [expr {int(abs(rand()*10000))}]\n  do_test crash-1.2.$i {\n    crashsql -delay 1 -file test.db-journal -seed $seed {\n      DELETE FROM abc WHERE a = 1;\n    }\n  } {1 {child process exited abnormally}}\n  do_test crash-1.3.$i {\n    signature\n  } $::sig\n}\ndo_test crash-1.4 {\n  crashsql -delay 1 -file test.db {\n    DELETE FROM abc WHERE a = 1;\n  }\n} {1 {child process exited abnormally}}\ndo_test crash-1.5 {\n  signature\n} $::sig\ndo_test crash-1.6 {\n  crashsql -delay 2 -file test.db-journal {\n    DELETE FROM abc WHERE a = 1;\n  }\n} {1 {child process exited abnormally}}\ndo_test crash-1.7 {\n  catchsql {\n    SELECT * FROM abc;\n  }\n} {0 {1 2 3 4 5 6}}\n\ndo_test crash-1.8 {\n  crashsql -delay 3 -file test.db-journal {\n    DELETE FROM abc WHERE a = 1;\n  }\n} {0 {}}\ndo_test crash-1.9 {\n  catchsql {\n    SELECT * FROM abc;\n  }\n} {0 {4 5 6}}\ndo_test crash-1.10 {\n  crashsql -delay 2 -file test.db {\n    DELETE FROM abc WHERE a = 4;\n  }\n} {0 {}}\ndo_test crash-1.11 {\n  catchsql {\n    SELECT * FROM abc;\n  }\n} {0 {}}\n\n#--------------------------------------------------------------------------\n# The following tests test recovery when both the database file and the\n# journal file contain corrupt data. This can happen after pages are\n# written to the database file before a transaction is committed due to\n# cache-pressure.\n#\n# crash-2.1: Insert 18 pages of data into the database.\n# crash-2.2: Check the database file size looks ok.\n# crash-2.3: Delete 15 or so pages (with a 10 page page-cache), then crash.\n# crash-2.4: Ensure the database is in the same state as after crash-2.1.\n#\n# Test cases crash-2.5 and crash-2.6 check that the database is OK if the \n# crash occurs during the main database file sync. But this isn't really\n# different from the crash-1.* cases.\n#\ndo_test crash-2.1 {\n  execsql { BEGIN }\n  for {set n 0} {$n < 1000} {incr n} {\n    execsql \"INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])\"\n  }\n  execsql { COMMIT }\n  set ::sig [signature]\n  execsql { SELECT sum(a), sum(b), sum(c) from abc }\n} {499500 999000 1498500}\ndo_test crash-2.2 {\n  expr ([file size test.db] / 1024)>16\n} {1}\ndo_test crash-2.3 {\n  crashsql -delay 2 -file test.db-journal {\n    DELETE FROM abc WHERE a < 800;\n  }\n} {1 {child process exited abnormally}}\ndo_test crash-2.4 {\n  signature\n} $sig\ndo_test crash-2.5 {\n  crashsql -delay 1 -file test.db {\n    DELETE FROM abc WHERE a<800;\n  }\n} {1 {child process exited abnormally}}\ndo_test crash-2.6 {\n  signature\n} $sig\n\n#--------------------------------------------------------------------------\n# The crash-3.* test cases are essentially the same test as test case\n# crash-2.*, but with a more complicated data set. \n#\n# The test is repeated a few times with different seeds for the random\n# number generator in the crashing executable. Because there is no way to\n# seed the random number generator directly, some SQL is added to the test\n# case to 'use up' a different quantity random numbers before the test SQL\n# is executed.\n#\n\n# Make sure the file is much bigger than the pager-cache (10 pages). This\n# ensures that cache-spills happen regularly.\ndo_test crash-3.0 {\n  execsql {\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n  }\n  expr ([file size test.db] / 1024) > 450\n} {1}\nfor {set i 1} {$i < $repeats} {incr i} {\n  set sig [signature]\n  do_test crash-3.$i.1 {\n     set seed [expr {int(abs(rand()*10000))}]\n     crashsql -delay [expr $i%5 + 1] -file test.db-journal -seed $seed \"\n       BEGIN;\n       SELECT random() FROM abc LIMIT $i;\n       INSERT INTO abc VALUES(randstr(10,10), 0, 0);\n       DELETE FROM abc WHERE random()%10!=0;\n       COMMIT;\n     \"\n  } {1 {child process exited abnormally}}\n  do_test crash-3.$i.2 {\n    signature\n  } $sig\n} \n\n#--------------------------------------------------------------------------\n# The following test cases - crash-4.* - test the correct recovery of the\n# database when a crash occurs during a multi-file transaction.\n#\n# crash-4.1.*: Test recovery when crash occurs during sync() of the \n#              main database journal file.\n# crash-4.2.*: Test recovery when crash occurs during sync() of an \n#              attached database journal file.\n# crash-4.3.*: Test recovery when crash occurs during sync() of the master\n#              journal file. \n#\nifcapable attach {\n  do_test crash-4.0 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.default_cache_size = 10;\n      CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc;\n    }\n    expr ([file size test2.db] / 1024) > 450\n  } {1}\n  \n  set fin 0\n  for {set i 1} {$i<$repeats} {incr i} {\n    set seed [expr {int(abs(rand()*10000))}]\n    set sig [signature]\n    set sig2 [signature2]\n    do_test crash-4.1.$i.1 {\n       set c [crashsql -delay $i -file test.db-journal -seed $::seed \"\n         ATTACH 'test2.db' AS aux;\n         BEGIN;\n         SELECT randstr($i,$i) FROM abc LIMIT $i;\n         INSERT INTO abc VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc WHERE random()%10!=0;\n         INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc2 WHERE random()%10!=0;\n         COMMIT;\n       \"]\n       if { $c == {0 {}} } {\n         set ::fin 1\n         set c {1 {child process exited abnormally}}\n       }\n       set c\n    } {1 {child process exited abnormally}}\n    if {$::fin} break\n    do_test crash-4.1.$i.2 {\n      signature\n    } $sig\n    do_test crash-4.1.$i.3 {\n      signature2\n    } $sig2\n  } \n  set i 0\n  set fin 0\n  while {[incr i]} {\n    set seed [expr {int(abs(rand()*10000))}]\n    set sig [signature]\n    set sig2 [signature2]\n    set ::fin 0\n    do_test crash-4.2.$i.1 {\n       set c [crashsql -delay $i -file test2.db-journal -seed $::seed \"\n         ATTACH 'test2.db' AS aux;\n         BEGIN;\n         SELECT randstr($i,$i) FROM abc LIMIT $i;\n         INSERT INTO abc VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc WHERE random()%10!=0;\n         INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc2 WHERE random()%10!=0;\n         COMMIT;\n       \"]\n       if { $c == {0 {}} } {\n         set ::fin 1\n         set c {1 {child process exited abnormally}}\n       }\n       set c\n    } {1 {child process exited abnormally}}\n    if { $::fin } break\n    do_test crash-4.2.$i.2 {\n      signature\n    } $sig\n    do_test crash-4.2.$i.3 {\n      signature2\n    } $sig2\n  } \n  for {set i 1} {$i < 5} {incr i} {\n    set sig [signature]\n    set sig2 [signature2]\n    do_test crash-4.3.$i.1 {\n       crashsql -delay 1 -file test.db-mj* \"\n         ATTACH 'test2.db' AS aux;\n         BEGIN;\n         SELECT random() FROM abc LIMIT $i;\n         INSERT INTO abc VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc WHERE random()%10!=0;\n         INSERT INTO abc2 VALUES(randstr(10,10), 0, 0);\n         DELETE FROM abc2 WHERE random()%10!=0;\n         COMMIT;\n       \"\n    } {1 {child process exited abnormally}}\n    do_test crash-4.3.$i.2 {\n      signature\n    } $sig\n    do_test crash-4.3.$i.3 {\n      signature2\n    } $sig2\n  }\n}\n\n#--------------------------------------------------------------------------\n# The following test cases - crash-5.* - exposes a bug that existed in the\n# sqlite3pager_movepage() API used by auto-vacuum databases.\n# database when a crash occurs during a multi-file transaction. See comments\n# in test crash-5.3 for details.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_test crash-5.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);                          -- Root page 3\n    INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);   -- Overflow page 4\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n  }\n} {}\ndo_test crash-5.2 {\n  expr [file size test.db] / 1024\n} [expr [string match [execsql {pragma auto_vacuum}] 1] ? 11 : 10]\nset sig [signature]\ndo_test crash-5.3 {\n# The SQL below is used to expose a bug that existed in\n# sqlite3pager_movepage() during development of the auto-vacuum feature. It\n# functions as follows:\n# \n# 1: Begin a transaction.\n# 2: Put page 4 on the free-list (was the overflow page for the row deleted).\n# 3: Write data to page 4 (it becomes the overflow page for the row inserted).\n#    The old page 4 data has been written to the journal file, but the\n#    journal file has not been sync()hronized.\n# 4: Create a table, which calls sqlite3pager_movepage() to move page 4\n#    to the end of the database (page 12) to make room for the new root-page.\n# 5: Put pressure on the pager-cache. This results in page 4 being written\n#    to the database file to make space in the cache to load a new page. The\n#    bug was that page 4 was written to the database file before the journal\n#    is sync()hronized.\n# 6: Commit. A crash occurs during the sync of the journal file.\n#\n# End result: Before the bug was fixed, data has been written to page 4 of the\n# database file and the journal file does not contain trustworthy rollback\n# data for this page.\n#\n  crashsql -delay 1 -file test.db-journal {\n    BEGIN;                                             -- 1\n    DELETE FROM abc WHERE oid = 1;                     -- 2\n    INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);  -- 3\n    CREATE TABLE abc2(a, b, c);                        -- 4\n    SELECT * FROM abc;                                 -- 5\n    COMMIT;                                            -- 6\n  }\n} {1 {child process exited abnormally}}\nintegrity_check crash-5.4\ndo_test crash-5.5 {\n  signature\n} $sig\n\n#--------------------------------------------------------------------------\n# The following test cases - crash-6.* - test that a DROP TABLE operation\n# is correctly rolled back in the event of a crash while the database file\n# is being written. This is mainly to test that all pages are written to the\n# journal file before truncation in an auto-vacuum database.\n#\ndo_test crash-6.1 {\n  crashsql -delay 1 -file test.db {\n    DROP TABLE abc;\n  }\n} {1 {child process exited abnormally}}\ndo_test crash-6.2 {\n  signature\n} $sig\n\n#--------------------------------------------------------------------------\n# These test cases test the case where the master journal file name is \n# corrupted slightly so that the corruption has to be detected by the\n# checksum.\ndo_test crash-7.1 {\n  crashsql -delay 1 -file test.db {\n    ATTACH 'test2.db' AS aux;\n    BEGIN;\n    INSERT INTO abc VALUES(randstr(1500,1500), 0, 0);\n    INSERT INTO abc2 VALUES(randstr(1500,1500), 0, 0);\n    COMMIT;\n  }\n\n  # Change the checksum value for the master journal name.\n  set f [open test.db-journal a]\n  fconfigure $f -encoding binary\n  seek $f [expr [file size test.db-journal] - 12]\n  puts -nonewline $f \"\\00\\00\\00\\00\"\n  close $f\n} {}\ndo_test crash-7.2 {\n  signature\n} $sig\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash2.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# The focus of this file is testing the ability of the database to\n# uses its rollback journal to recover intact (no database corruption)\n# from a power failure during the middle of a COMMIT. Even more\n# specifically, the tests in this file verify this functionality\n# for storage mediums with various sector sizes.\n#\n# $Id: crash2.test,v 1.6 2008/08/25 07:12:29 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\ndb close\n\n# This test is designed to check that the crash-test infrastructure\n# can create files that do not consist of an integer number of\n# simulated disk blocks (i.e. 3KB file using 2KB disk blocks).\n#\ndo_test crash2-1.1 {\n  crashsql -delay 500 -file test.db -blocksize 2048 {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    BEGIN;\n    CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;\n    CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;\n    COMMIT;\n  }\n  file size test.db\n} {3072}\n\nfor {set ii 0} {$ii < 5} {incr ii} {\n\n  # Simple test using the database created above: Create a new\n  # table so that page 1 and page 4 are modified. Using a\n  # block-size of 2048 and page-size of 1024, this means\n  # pages 2 and 3 must also be saved in the journal to avoid\n  # risking corruption.\n  #\n  # The loop is so that this test can be run with a couple\n  # of different seeds for the random number generator.\n  #\n  do_test crash2-1.2.$ii {\n    crashsql -file test.db -blocksize 2048 [subst {\n      [string repeat {SELECT random();} $ii]\n      CREATE TABLE hij(h, i, j);\n    }]\n    sqlite3 db test.db\n    db eval {PRAGMA integrity_check}\n  } {ok}\n}\n\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]\n}\n\n# Test case for crashing during journal sync with simulated\n# sector-size values from 1024 to 8192.\n#\ndo_test crash2-2.0 {\n  execsql BEGIN\n  for {set n 0} {$n < 1000} {incr n} {\n    execsql \"INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])\"\n  }\n  execsql {\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n  }\n  execsql COMMIT\n  expr ([file size test.db] / 1024) > 450\n} {1}\nfor {set i 1} {$i < 30} {incr i} {\n  set sig [signature]\n  set sector [expr 1024 * 1<<($i%4)]\n  db close\n  do_test crash2-2.$i.1 {\n     crashsql -blocksize $sector -delay [expr $i%5 + 1] -file test.db-journal \"\n       PRAGMA temp_store = memory;\n       BEGIN;\n       SELECT random() FROM abc LIMIT $i;\n       INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;\n       DELETE FROM abc WHERE random()%2!=0;\n       COMMIT;\n     \"\n  } {1 {child process exited abnormally}}\n  do_test crash2-2.$i.2 {\n    sqlite3 db test.db\n    signature\n  } $sig\n} \n\n\n# Test case for crashing during database sync with simulated\n# sector-size values from 1024 to 8192.\n#\nfor {set i 1} {$i < 10} {incr i} {\n  set sig [signature]\n  set sector [expr 1024 * 1<<($i%4)]\n  db close\n  do_test crash2-3.$i.1 {\n     crashsql -blocksize $sector -file test.db \"\n       BEGIN;\n       SELECT random() FROM abc LIMIT $i;\n       INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;\n       DELETE FROM abc WHERE random()%2!=0;\n       COMMIT;\n     \"\n  } {1 {child process exited abnormally}}\n  do_test crash2-3.$i.2 {\n    sqlite3 db test.db\n    signature\n  } $sig\n} \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash3.test",
    "content": "# 2007 August 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests that verify that SQLite can correctly rollback\n# databases after crashes when using the special IO modes triggered \n# by device IOCAP flags.\n#\n# $Id: crash3.test,v 1.4 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\nproc do_test2 {name tcl res1 res2} {\n  set script [subst -nocommands {\n    do_test $name {\n      set res1 {$res1}\n      set res2 {$res2}\n      set res [eval {$tcl}]\n      if {[set res] eq [set res1] || [set res] eq [set res2]} {\n        set res \"{[set res1]} or {[set res2]}\"\n      }\n      set res\n    } {{$res1} or {$res2}}\n  }]\n  uplevel $script\n}\n\n# This block tests crash-recovery when the IOCAP_ATOMIC flags is set.\n#\n# Each iteration of the following loop sets up the database to contain\n# the following schema and data:\n#\n#    CREATE TABLE abc(a, b, c);\n#    INSERT INTO abc VALUES(1, 2, 3);\n#\n# Then execute the SQL statement, scheduling a crash for part-way through\n# the first sync() of either the database file or the journal file (often\n# the journal file is not required - meaning no crash occurs).\n#\n# After the crash (or absence of a crash), open the database and \n# verify that:\n#\n#   * The integrity check passes, and\n#   * The contents of table abc is either {1 2 3} or the value specified\n#     to the right of the SQL statement below.\n#\n# The procedure is repeated 10 times for each SQL statement. Five times\n# with the crash scheduled for midway through the first journal sync (if \n# any), and five times with the crash midway through the database sync.\n#\nset tn 1\nforeach {sql res2} [list \\\n  {INSERT INTO abc VALUES(4, 5, 6)}                    {1 2 3 4 5 6} \\\n  {DELETE FROM abc}                                    {}    \\\n  {INSERT INTO abc SELECT * FROM abc}                  {1 2 3 1 2 3} \\\n  {UPDATE abc SET a = 2}                               {2 2 3}       \\\n  {INSERT INTO abc VALUES(4, 5, randstr(1000,1000))}   {n/a} \\\n  {CREATE TABLE def(d, e, f)}                          {n/a} \\\n] {\n  for {set ii 0} {$ii < 10} {incr ii} {\n\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    do_test crash3-1.$tn.1 {\n      execsql {\n        PRAGMA page_size = 1024;\n        BEGIN;\n        CREATE TABLE abc(a, b, c);\n        INSERT INTO abc VALUES(1, 2, 3);\n        COMMIT;\n      }\n    } {}\n    db close\n  \n    set crashfile test.db\n    if {($ii%2)==0} { append crashfile -journal }\n    set rand \"SELECT randstr($tn,$tn);\"\n    do_test crash3-1.$tn.2 [subst {\n      crashsql -file $crashfile -char atomic {$rand $sql}\n      sqlite3 db test.db\n      execsql { PRAGMA integrity_check; }\n    }] {ok}\n  \n    do_test2 crash3-1.$tn.3 {\n      execsql { SELECT * FROM abc }\n    } {1 2 3} $res2\n\n    incr tn\n  }\n}\n\n# This block tests both the IOCAP_SEQUENTIAL and IOCAP_SAFE_APPEND flags.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\ndo_test crash3-2.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE abc(a PRIMARY KEY, b, c);\n    CREATE TABLE def(d PRIMARY KEY, e, f);\n    PRAGMA default_cache_size = 10;\n    INSERT INTO abc VALUES(randstr(10,1000),randstr(10,1000),randstr(10,1000));\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    INSERT INTO abc \n      SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) FROM abc;\n    COMMIT;\n  }\n} {}\n\nset tn 1\nforeach {::crashfile ::delay ::char} {\n  test.db         1 sequential\n  test.db         1 safe_append\n  test.db-journal 1 sequential\n  test.db-journal 1 safe_append\n  test.db-journal 2 safe_append\n  test.db-journal 2 sequential\n  test.db-journal 3 sequential\n  test.db-journal 3 safe_append\n} {\n  for {set ii 0} {$ii < 100} {incr ii} {\n    set ::SQL [subst {\n      SELECT randstr($ii,$ii+10);\n      BEGIN;\n      DELETE FROM abc WHERE random()%5;\n      INSERT INTO abc \n        SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) \n        FROM abc\n        WHERE (random()%5)==0;\n      DELETE FROM def WHERE random()%5;\n      INSERT INTO def \n        SELECT randstr(10,1000),randstr(10,1000),randstr(10,1000) \n        FROM def\n        WHERE (random()%5)==0;\n      COMMIT;\n    }]\n\n    do_test crash3-2.$tn.$ii {\n      crashsql -file $::crashfile -delay $::delay -char $::char $::SQL\n      db close\n      sqlite3 db test.db\n      execsql {PRAGMA integrity_check}\n    } {ok}\n  }\n  incr tn\n}\n\n# The following block tests an interaction between IOCAP_ATOMIC and\n# IOCAP_SEQUENTIAL. At one point, if both flags were set, small\n# journal files that contained only a single page, but were required \n# for some other reason (i.e. nTrunk) were not being written to\n# disk.\n#\nfor {set ii 0} {$ii < 10} {incr ii} {\n  db close\n  forcedelete test.db test.db-journal\n  crashsql -file test.db -char {sequential atomic} {\n    CREATE TABLE abc(a, b, c);\n  }\n  sqlite3 db test.db\n  do_test crash3-3.$ii {\n    execsql {PRAGMA integrity_check}\n  } {ok}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash4.test",
    "content": "# 2008 January 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains additional tests to verify that SQLite database\n# file survive a power loss or OS crash.\n#\n# $Id: crash4.test,v 1.3 2008/01/16 17:46:38 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\n\n# A sequence of SQL commands:\n#\nset sql_cmd_list {\n  {CREATE TABLE a(id INTEGER, name CHAR(50))}\n  {INSERT INTO a(id,name) VALUES(1,'one')}\n  {INSERT INTO a(id,name) VALUES(2,'two')}\n  {INSERT INTO a(id,name) VALUES(3,'three')}\n  {INSERT INTO a(id,name) VALUES(4,'four')}\n  {INSERT INTO a(id,name) VALUES(5,'five')}\n  {INSERT INTO a(id,name) VALUES(6,'six')}\n  {INSERT INTO a(id,name) VALUES(7,'seven')}\n  {INSERT INTO a(id,name) VALUES(8,'eight')}\n  {INSERT INTO a(id,name) VALUES(9,'nine')}\n  {INSERT INTO a(id,name) VALUES(10,'ten')}\n  {UPDATE A SET name='new text for row 3' WHERE id=3}\n}\n\n# Assume that a database is created by evaluating the SQL statements\n# in $sql_cmd_list.  Compute a set of checksums that capture the state\n# of the database after each statement.  Also include a checksum for\n# the state of the database prior to any of these statements.\n#\nset crash4_cksum_set {}\nlappend crash4_cksum_set [allcksum db]\nforeach cmd $sql_cmd_list {\n  db eval $cmd\n  lappend crash4_cksum_set [allcksum db]\n}\n\n# Run the sequence of SQL statements shown above repeatedly.\n# Close and reopen the database right before the UPDATE statement.\n# On each repetition, introduce database corruption typical of\n# what might be seen in a power loss or OS crash.  \n#\n# Slowly increase the delay before the crash, repeating the test\n# over and over.  Stop testing when the entire sequence of SQL\n# statements runs to completing without hitting the crash.\n#\nfor {set cnt 1; set fin 0} {!$fin} {incr cnt} {\n  db close\n  forcedelete test.db test.db-journal\n  do_test crash4-1.$cnt.1 {\n    set seed [expr {int(abs(rand()*10000))}]\n    set delay [expr {int($cnt/50)+1}]\n    set file [expr {($cnt&1)?\"test.db\":\"test.db-journal\"}]\n    set c [crashsql -delay $delay -file $file -seed $seed -tclbody {\n      db eval {CREATE TABLE a(id INTEGER, name CHAR(50))}\n      db eval {INSERT INTO a(id,name) VALUES(1,'one')}\n      db eval {INSERT INTO a(id,name) VALUES(2,'two')}\n      db eval {INSERT INTO a(id,name) VALUES(3,'three')}\n      db eval {INSERT INTO a(id,name) VALUES(4,'four')}\n      db eval {INSERT INTO a(id,name) VALUES(5,'five')}\n      db eval {INSERT INTO a(id,name) VALUES(6,'six')}\n      db eval {INSERT INTO a(id,name) VALUES(7,'seven')}\n      db eval {INSERT INTO a(id,name) VALUES(8,'eight')}\n      db eval {INSERT INTO a(id,name) VALUES(9,'nine')}\n      db eval {INSERT INTO a(id,name) VALUES(10,'ten')}\n      db close\n      sqlite3 db test.db\n      db eval {UPDATE A SET name='new text for row 3' WHERE id=3}\n      db close\n    } {}]\n    if {$c==[list 0 {}]} {\n      set ::fin 1\n      set c [list 1 {child process exited abnormally}]\n    }\n    set c\n  } {1 {child process exited abnormally}}\n  sqlite3 db test.db\n  integrity_check crash4-1.$cnt.2\n  do_test crash4-1.$cnt.3 {\n    set x [lsearch $::crash4_cksum_set [allcksum db]]\n    expr {$x>=0}\n  } {1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash5.test",
    "content": "\n# 2007 Aug 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file tests aspects of recovery from a malloc() failure\n# in a CREATE INDEX statement.\n#\n# $Id: crash5.test,v 1.3 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nifcapable !memdebug||!crashtest||!memorymanage {\n   puts \"Skipping crash5 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\ndb close\n\nfor {set ii 0} {$ii < 10} {incr ii} {\n  for {set jj 50} {$jj < 100} {incr jj} {\n\n    # Set up the database so that it is an auto-vacuum database \n    # containing a single table (root page 3) with a single row. \n    # The row has an overflow page (page 4).\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    set c [string repeat 3 1500]\n    db eval {\n      pragma auto_vacuum = 1;\n      CREATE TABLE t1(a, b, c);\n      INSERT INTO t1 VALUES('1111111111', '2222222222', $c);\n    }\n    db close\n\n    do_test crash5-$ii.$jj.1 {\n      crashsql -delay 1 -file test.db-journal -seed $ii -tclbody [join [list \\\n        [list set iFail $jj] {\n        sqlite3_crashparams 0 [file join [get_pwd] test.db-journal]\n      \n        # Begin a transaction and evaluate a \"CREATE INDEX\" statement\n        # with the iFail'th malloc() set to fail. This operation will\n        # have to move the current contents of page 4 (the overflow\n        # page) to make room for the new root page. The bug is that\n        # if malloc() fails at a particular point in sqlite3PagerMovepage(),\n        # sqlite mistakenly thinks that the page being moved (page 4) has \n        # been safely synced into the journal. If the page is written\n        # to later in the transaction, it may be written out to the database\n        # before the relevant part of the journal has been synced.\n        #\n        db eval BEGIN\n        sqlite3_memdebug_fail $iFail -repeat 0\n        catch {db eval { CREATE UNIQUE INDEX i1 ON t1(a); }} msg\n        # puts \"$n $msg ac=[sqlite3_get_autocommit db]\"\n      \n        # If the transaction is still active (it may not be if the malloc()\n        # failure occurred in the OS layer), write to the database. Make sure\n        # page 4 is among those written.\n        #\n        if {![sqlite3_get_autocommit db]} {\n          db eval {\n            DELETE FROM t1;  -- This will put page 4 on the free list.\n            INSERT INTO t1 VALUES('111111111', '2222222222', '33333333');\n            INSERT INTO t1 SELECT * FROM t1;                     -- 2\n            INSERT INTO t1 SELECT * FROM t1;                     -- 4\n            INSERT INTO t1 SELECT * FROM t1;                     -- 8\n            INSERT INTO t1 SELECT * FROM t1;                     -- 16\n            INSERT INTO t1 SELECT * FROM t1;                     -- 32\n            INSERT INTO t1 SELECT * FROM t1 WHERE rowid%2;       -- 48\n          }\n        }\n        \n        # If the right malloc() failed during the 'CREATE INDEX' above and\n        # the transaction was not rolled back, then the sqlite cache now \n        # has a dirty page 4 that it incorrectly believes is already safely\n        # in the synced part of the journal file. When \n        # sqlite3_release_memory() is called sqlite tries to free memory\n        # by writing page 4 out to the db file. If it crashes later on,\n        # before syncing the journal... Corruption!\n        #\n        sqlite3_crashparams 1 [file join [get_pwd] test.db-journal]\n        sqlite3_release_memory 8092\n      }]] {}\n      expr 1\n    } {1}\n  \n    sqlite3 db test.db\n    do_test crash5-$ii.$jj.2 {\n      db eval {pragma integrity_check}\n    } {ok}\n    do_test crash5-$ii.$jj.3 {\n      db eval {SELECT * FROM t1}\n    } [list 1111111111 2222222222 $::c]\n    db close\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash6.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests that rollback journals for databases that use a \n# page-size other than the default page-size can be rolled back Ok.\n#\n# $Id: crash6.test,v 1.2 2008/04/14 15:27:19 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\nfor {set ii 0} {$ii < 10} {incr ii} {\n  catch {db close}\n  forcedelete test.db test.db-journal\n  crashsql -delay 2 -file test.db {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=4096;\n    BEGIN;\n    CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;\n    COMMIT;\n    BEGIN;\n    CREATE TABLE def AS SELECT 1 AS d, 2 AS e, 3 AS f;\n    COMMIT;\n  }\n  sqlite3 db test.db\n  integrity_check crash6-1.$ii\n}\n\nfor {set ii 0} {$ii < 10} {incr ii} {\n  catch {db close}\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=2048;\n    BEGIN;\n    CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c;\n    COMMIT;\n  }\n  db close\n  crashsql -delay 1 -file test.db {\n    INSERT INTO abc VALUES(5, 6, 7);\n  }\n  sqlite3 db test.db\n  integrity_check crash6-2.$ii\n}\n\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]\n}\n\n# Test case for crashing during database sync with page-size values \n# from 1024 to 8192.\n#\nfor {set ii 0} {$ii < 30} {incr ii} {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  set pagesize [expr 1024 << ($ii % 4)]\n  if {$pagesize>$::SQLITE_MAX_PAGE_SIZE} {\n    set pagesize $::SQLITE_MAX_PAGE_SIZE\n  }\n  do_test crash6-3.$ii.0 {\n    execsql \"pragma page_size = $pagesize\"\n    execsql \"pragma page_size\"\n  } $pagesize\n\n  do_test crash6-3.$ii.1 {\n  \n    execsql BEGIN\n    execsql {CREATE TABLE abc(a, b, c)}\n    for {set n 0} {$n < 1000} {incr n} {\n      execsql \"INSERT INTO abc VALUES($n, [expr 2*$n], [expr 3*$n])\"\n    }\n    execsql {\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n    }\n    execsql COMMIT\n    expr ([file size test.db] / 1024) > 450\n  } {1}\n\n  set sig [signature]\n  db close\n\n  do_test crash6-3.$ii.2 {\n     crashsql -file test.db \"\n       BEGIN;\n       SELECT random() FROM abc LIMIT $ii;\n       INSERT INTO abc SELECT randstr(10,10), 0, 0 FROM abc WHERE random()%2==0;\n       DELETE FROM abc WHERE random()%2!=0;\n       COMMIT;\n     \"\n  } {1 {child process exited abnormally}}\n\n  do_test crash6-3.$ii.3 {\n    sqlite3 db test.db\n    signature\n  } $sig\n} \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash7.test",
    "content": "# 2008 March 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: crash7.test,v 1.1 2008/04/03 14:36:26 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix crash7\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]\n}\n\nforeach f [list test.db test.db-journal] {\n  for {set ii 1} {$ii < 64} {incr ii} {\n    db close\n    delete_file test.db\n    sqlite3 db test.db\n  \n    set from_size [expr 1024 << ($ii&3)]\n    set to_size   [expr 1024 << (($ii>>2)&3)]\n  \n    execsql \"\n      PRAGMA page_size = $from_size;\n      BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY, b, c);\n      INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));\n      INSERT INTO abc \n          SELECT randomblob(1000), randomblob(200), randomblob(100)\n          FROM abc;\n      INSERT INTO abc \n          SELECT randomblob(100), randomblob(200), randomblob(1000)\n          FROM abc;\n      INSERT INTO abc \n          SELECT randomblob(100), randomblob(200), randomblob(1000)\n          FROM abc;\n      INSERT INTO abc \n          SELECT randomblob(100), randomblob(200), randomblob(1000)\n          FROM abc;\n      INSERT INTO abc \n          SELECT randomblob(100), randomblob(200), randomblob(1000)\n          FROM abc WHERE [expr $ii&16];\n      INSERT INTO abc \n          SELECT randomblob(25), randomblob(45), randomblob(9456)\n          FROM abc WHERE [expr $ii&32];\n      INSERT INTO abc \n          SELECT randomblob(100), randomblob(200), randomblob(1000)\n          FROM abc WHERE [expr $ii&8];\n      INSERT INTO abc \n          SELECT randomblob(25), randomblob(45), randomblob(9456)\n          FROM abc WHERE [expr $ii&4];\n      COMMIT;\n    \"\n  \n    set sig [signature]\n    db close\n  \n    do_test crash7-1.$ii.crash {\n       crashsql -file $f \"\n         PRAGMA page_size = $to_size;\n         VACUUM;\n       \"\n    } {1 {child process exited abnormally}}\n  \n    sqlite3 db test.db\n    integrity_check crash7-1.$ii.integrity\n  } \n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a, b, UNIQUE(a, b));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM t1;\n  DELETE FROM t1 WHERE rowid%2;\n}\ndb_save_and_close\n\nfor {set i 0} {$i < 20} {incr i} {\n  db_restore_and_reopen\n  do_test 2.[expr $i+1].1 {\n    crashsql -file test.db -seed $i {VACUUM}\n  } {1 {child process exited abnormally}}\n  do_execsql_test 2.[expr $i+1].2 { PRAGMA integrity_check } {ok}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crash8.test",
    "content": "# 2009 January 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test verifies a couple of specific potential data corruption \n# scenarios involving crashes or power failures.\n#\n# Later: Also, some other specific scenarios required for coverage\n# testing that do not lead to corruption.\n#\n# $Id: crash8.test,v 1.4 2009/01/11 00:44:48 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\ndo_not_use_codec\n\ndo_test crash8-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 VALUES(2, randstr(1000,1000));\n    INSERT INTO t1 VALUES(3, randstr(1000,1000));\n    INSERT INTO t1 VALUES(4, randstr(1000,1000));\n    INSERT INTO t1 VALUES(5, randstr(1000,1000));\n    INSERT INTO t1 VALUES(6, randstr(1000,1000));\n    CREATE TABLE t2(a, b);\n    CREATE TABLE t3(a, b);\n    CREATE TABLE t4(a, b);\n    CREATE TABLE t5(a, b);\n    CREATE TABLE t6(a, b);\n    CREATE TABLE t7(a, b);\n    CREATE TABLE t8(a, b);\n    CREATE TABLE t9(a, b);\n    CREATE TABLE t10(a, b);\n    PRAGMA integrity_check\n  }\n} {ok}\n\n\n# Potential corruption scenario 1. A second process opens the database \n# and modifies a large portion of it. It then opens a second transaction\n# and modifies a small part of the database, but crashes before it commits\n# the transaction. \n#\n# When the first process accessed the database again, it was rolling back\n# the aborted transaction, but was not purging its in-memory cache (which\n# was loaded before the second process made its first, successful, \n# modification). Producing an inconsistent cache.\n#\ndo_test crash8-1.2 {\n  crashsql -delay 2 -file test.db {\n    PRAGMA cache_size = 10;\n    UPDATE t1 SET b = randstr(1000,1000);\n    INSERT INTO t9 VALUES(1, 2);\n  }\n} {1 {child process exited abnormally}}\ndo_test crash8-1.3 {\n  execsql {PRAGMA integrity_check}\n} {ok}\n\n# Potential corruption scenario 2. The second process, operating in\n# persistent-journal mode, makes a large change to the database file\n# with a small in-memory cache. Such that more than one journal-header\n# was written to the file. It then opens a second transaction and makes\n# a smaller change that requires only a single journal-header to be\n# written to the journal file. The second change is such that the \n# journal content written to the persistent journal file exactly overwrites\n# the first journal-header and set of subsequent records written by the\n# first, successful, change. The second process crashes before it can\n# commit its second change.\n#\n# When the first process accessed the database again, it was rolling back\n# the second aborted transaction, then continuing to rollback the second\n# and subsequent journal-headers written by the first, successful, change.\n# Database corruption.\n#\ndo_test crash8.2.1 {\n  crashsql -delay 2 -file test.db {\n    PRAGMA journal_mode = persist;\n    PRAGMA cache_size = 10;\n    UPDATE t1 SET b = randstr(1000,1000);\n    PRAGMA cache_size = 100;\n    BEGIN;\n      INSERT INTO t2 VALUES('a', 'b');\n      INSERT INTO t3 VALUES('a', 'b');\n      INSERT INTO t4 VALUES('a', 'b');\n      INSERT INTO t5 VALUES('a', 'b');\n      INSERT INTO t6 VALUES('a', 'b');\n      INSERT INTO t7 VALUES('a', 'b');\n      INSERT INTO t8 VALUES('a', 'b');\n      INSERT INTO t9 VALUES('a', 'b');\n      INSERT INTO t10 VALUES('a', 'b');\n    COMMIT;\n  }\n} {1 {child process exited abnormally}}\n\ndo_test crash8-2.3 {\n  execsql {PRAGMA integrity_check}\n} {ok}\n\nproc read_file {zFile} {\n  set fd [open $zFile]\n  fconfigure $fd -translation binary \n  set zData [read $fd]\n  close $fd\n  return $zData\n}\nproc write_file {zFile zData} {\n  set fd [open $zFile w]\n  fconfigure $fd -translation binary \n  puts -nonewline $fd $zData\n  close $fd\n}\n\n# The following tests check that SQLite will not roll back a hot-journal\n# file if the sector-size field in the first journal file header is\n# suspect. Definition of suspect:\n# \n#    a) Not a power of 2, or                (crash8-3.5)\n#    b) Greater than 0x01000000 (16MB), or  (crash8-3.6)\n#    c) Less than 512.                      (crash8-3.7)\n#\n# Also test that SQLite will not rollback a hot-journal file with a\n# suspect page-size. In this case \"suspect\" means:\n# \n#    a) Not a power of 2, or\n#    b) Less than 512, or\n#    c) Greater than SQLITE_MAX_PAGE_SIZE\n#\ndo_test crash8-3.1 {\n  list [file exists test.db-joural] [file exists test.db]\n} {0 1}\ndo_test crash8-3.2 {\n  execsql {\n    PRAGMA synchronous = off;\n    BEGIN;\n    DELETE FROM t1;\n    SELECT count(*) FROM t1;\n  }\n} {0}\ndo_test crash8-3.3 {\n  set zJournal [read_file test.db-journal]\n  execsql { \n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {0}\ndo_test crash8-3.4 {\n  binary scan [string range $zJournal 20 23] I nSector\n  set nSector\n} {512}\n\ndo_test crash8-3.5 {\n  set zJournal2 [string replace $zJournal 20 23 [binary format I 513]]\n  write_file test.db-journal $zJournal2\n\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\ndo_test crash8-3.6 {\n  set zJournal2 [string replace $zJournal 20 23 [binary format I 0x2000000]]\n  write_file test.db-journal $zJournal2\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\ndo_test crash8-3.7 {\n  set zJournal2 [string replace $zJournal 20 23 [binary format I 256]]\n  write_file test.db-journal $zJournal2\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\n\ndo_test crash8-3.8 {\n  set zJournal2 [string replace $zJournal 24 27 [binary format I 513]]\n  write_file test.db-journal $zJournal2\n\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\ndo_test crash8-3.9 {\n  set big [expr $SQLITE_MAX_PAGE_SIZE * 2]\n  set zJournal2 [string replace $zJournal 24 27 [binary format I $big]]\n  write_file test.db-journal $zJournal2\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\ndo_test crash8-3.10 {\n  set zJournal2 [string replace $zJournal 24 27 [binary format I 256]]\n  write_file test.db-journal $zJournal2\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {0 ok}\n\ndo_test crash8-3.11 {\n  set fd [open test.db-journal w]\n  fconfigure $fd -translation binary \n  puts -nonewline $fd $zJournal\n  close $fd\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check\n  }\n} {6 ok}\n\n\n# If a connection running in persistent-journal mode is part of a \n# multi-file transaction, it must ensure that the master-journal name\n# appended to the journal file contents during the commit is located\n# at the end of the physical journal file. If there was already a\n# large journal file allocated at the start of the transaction, this\n# may mean truncating the file so that the master journal name really\n# is at the physical end of the file.\n#\n# This block of tests test that SQLite correctly truncates such\n# journal files, and that the results behave correctly if a hot-journal\n# rollback occurs.\n#\nifcapable pragma {\n  reset_db\n  forcedelete test2.db\n\n  do_test crash8-4.1 {\n    execsql {\n      PRAGMA journal_mode = persist;\n      CREATE TABLE ab(a, b);\n      INSERT INTO ab VALUES(0, 'abc');\n      INSERT INTO ab VALUES(1, NULL);\n      INSERT INTO ab VALUES(2, NULL);\n      INSERT INTO ab VALUES(3, NULL);\n      INSERT INTO ab VALUES(4, NULL);\n      INSERT INTO ab VALUES(5, NULL);\n      INSERT INTO ab VALUES(6, NULL);\n      UPDATE ab SET b = randstr(1000,1000);\n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.journal_mode = persist;\n      CREATE TABLE aux.ab(a, b);\n      INSERT INTO aux.ab SELECT * FROM main.ab;\n\n      UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1;\n      UPDATE ab SET b = randstr(1000,1000) WHERE a>=1;\n    }\n    list [file exists test.db-journal] [file exists test2.db-journal]\n  } {1 1}\n\n  do_test crash8-4.2 {\n    execsql {\n      BEGIN;\n        UPDATE aux.ab SET b = 'def' WHERE a = 0;\n        UPDATE main.ab SET b = 'def' WHERE a = 0;\n      COMMIT;\n    }\n  } {}\n\n  do_test crash8-4.3 {\n    execsql {\n      UPDATE aux.ab SET b = randstr(1000,1000) WHERE a>=1;\n      UPDATE ab SET b = randstr(1000,1000) WHERE a>=1;\n    }\n  } {}\n\n  set contents_main [db eval {SELECT b FROM main.ab WHERE a = 1}]\n  set contents_aux  [db eval {SELECT b FROM  aux.ab WHERE a = 1}]\n\n  do_test crash8-4.4 {\n    crashsql -file test2.db -delay 1 {\n      ATTACH 'test2.db' AS aux;\n      BEGIN;\n        UPDATE aux.ab SET b = 'ghi' WHERE a = 0;\n        UPDATE main.ab SET b = 'ghi' WHERE a = 0;\n      COMMIT;\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test crash8-4.5 {\n    list [file exists test.db-journal] [file exists test2.db-journal]\n  } {1 1}\n\n  do_test crash8-4.6 {\n    execsql {\n      SELECT b FROM main.ab WHERE a = 0;\n      SELECT b FROM aux.ab WHERE a = 0;\n    }\n  } {def def}\n\n  do_test crash8-4.7 {\n    crashsql -file test2.db -delay 1 {\n      ATTACH 'test2.db' AS aux;\n      BEGIN;\n        UPDATE aux.ab SET b = 'jkl' WHERE a = 0;\n        UPDATE main.ab SET b = 'jkl' WHERE a = 0;\n      COMMIT;\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test crash8-4.8 {\n    set fd [open test.db-journal]\n    fconfigure $fd -translation binary\n    seek $fd -16 end\n    binary scan [read $fd 4] I len\n\n    seek $fd [expr {-1 * ($len + 16)}] end\n    set zMasterJournal [read $fd $len]\n    close $fd\n\n    file exists $zMasterJournal\n  } {1}\n\n  do_test crash8-4.9 {\n    execsql { SELECT b FROM aux.ab WHERE a = 0 }\n  } {def}\n\n  do_test crash8-4.10 {\n    delete_file $zMasterJournal\n    execsql { SELECT b FROM main.ab WHERE a = 0 }\n  } {jkl}\n}\n\n#\n# Since the following tests (crash8-5.*) rely upon being able\n# to copy a file while open, they will not work on Windows.\n#\nif {$::tcl_platform(platform)==\"unix\"} {\n  for {set i 1} {$i < 10} {incr i} {\n    catch { db close }\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    do_test crash8-5.$i.1 {\n      execsql {\n        CREATE TABLE t1(x PRIMARY KEY);\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 rows */\n      }\n      crashsql -file test.db -delay [expr ($::i%2) + 1] {\n        PRAGMA cache_size = 10;\n        BEGIN;\n          UPDATE t1 SET x = randomblob(900);\n        ROLLBACK;\n        INSERT INTO t1 VALUES(randomblob(900));\n      }\n      execsql { PRAGMA integrity_check }\n    } {ok}\n  \n    catch { db close }\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    do_test crash8-5.$i.2 {\n      execsql {\n        PRAGMA cache_size = 10;\n        CREATE TABLE t1(x PRIMARY KEY);\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;          /* 64 rows */\n        BEGIN;\n          UPDATE t1 SET x = randomblob(900);\n      }\n      forcedelete testX.db testX.db-journal testX.db-wal\n      forcecopy test.db testX.db\n      forcecopy test.db-journal testX.db-journal\n      db close\n\n      crashsql -file test.db -delay [expr ($::i%2) + 1] {\n        SELECT * FROM sqlite_master;\n        INSERT INTO t1 VALUES(randomblob(900));\n      }\n\n      sqlite3 db2 testX.db\n      execsql { PRAGMA integrity_check } db2\n    } {ok}\n  }\n  catch {db2 close}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crashM.test",
    "content": "# 2015 Mar 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Crash tests for the multiplex module with 8.3 filenames enabled.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix crashM\n\nifcapable !crashtest||!8_3_names {\n  finish_test\n  return\n}\n\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\nforeach f [glob -nocomplain test1.* test2.*] { forcedelete $f }\nsqlite3_multiplex_initialize \"\" 1\nsqlite3 db file:test1.db?8_3_names=1\nsqlite3_multiplex_control db main chunk_size [expr 64*1024]\n\ndo_execsql_test 1.0 {\n  ATTACH 'file:test2.db?8_3_names=1' AS aux;\n\n  CREATE TABLE t1(x, y);\n  CREATE INDEX t1x ON t1(x);\n  CREATE INDEX t1y ON t1(y);\n\n  CREATE TABLE aux.t2(x, y);\n  CREATE INDEX aux.t2x ON t2(x);\n  CREATE INDEX aux.t2y ON t2(y);\n\n  WITH s(a) AS (\n    SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000\n  )\n  INSERT INTO t1 SELECT a, randomblob(500) FROM s;\n\n  WITH s(a) AS (\n    SELECT 1 UNION ALL SELECT a+1 FROM s WHERE a<1000\n  )\n  INSERT INTO t2 SELECT a, randomblob(500) FROM s;\n} {}\n\nfor {set i 0} {$i < 20} {incr i} {\n  do_test 2.$i.1 {\n    crashsql -delay 1 -file test1.db -opendb {\n      sqlite3_shutdown\n      sqlite3_config_uri 1\n      sqlite3_multiplex_initialize crash 1\n      sqlite3 db file:test1.db?8_3_names=1\n      sqlite3_multiplex_control db main chunk_size [expr 64*1024]\n    } {\n      ATTACH 'file:test2.db?8_3_names=1' AS aux;\n      BEGIN;\n        UPDATE t1 SET y = randomblob(500) WHERE (x%10)==0;\n        UPDATE t2 SET y = randomblob(500) WHERE (x%10)==0;\n      COMMIT;\n    }\n  } {1 {child process exited abnormally}}\n\n  do_execsql_test 2.$i.2 {\n    PRAGMA main.integrity_check;\n    PRAGMA aux.integrity_check;\n  } {ok ok}\n}\n\ncatch { db close }\nsqlite3_multiplex_shutdown\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/crashtest1.c",
    "content": "/*\n** This program tests the ability of SQLite database to recover from a crash.\n** This program runs under Unix only, but the results are applicable to all\n** systems.\n**\n** The main process first constructs a test database, then starts creating\n** subprocesses that write to that database.  Each subprocess is killed off,\n** without a chance to clean up its database connection, after a random\n** delay.  This killing of the subprocesses simulates a crash or power\n** failure.  The next subprocess to open the database should rollback\n** whatever operation was in process at the time of the simulated crash.\n**\n** If any problems are encountered, an error is reported and the test stops.\n** If no problems are seen after a large number of tests, we assume that\n** the rollback mechanism is working.\n*/\n#include <stdio.h>\n#include <unistd.h>\n#include <sys/types.h>\n#include <sys/wait.h>\n#include <signal.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sched.h>\n#include \"sqlite.h\"\n\nstatic void do_some_sql(int parent){\n  char *zErr;\n  int rc = SQLITE_OK;\n  sqlite *db;\n  int cnt = 0;\n  static char zBig[] = \n    \"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    \"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n  if( access(\"./test.db-journal\",0)==0 ){\n    /*printf(\"pid %d: journal exists.  rollback will be required\\n\",getpid());*/    unlink(\"test.db-saved\");\n    system(\"cp test.db test.db-saved\");\n    unlink(\"test.db-journal-saved\");\n    system(\"cp test.db-journal test.db-journal-saved\");\n  }\n  db = sqlite_open(\"./test.db\", 0, &zErr);\n  if( db==0 ){\n    printf(\"ERROR: %s\\n\", zErr);\n    if( strcmp(zErr,\"database disk image is malformed\")==0 ){\n      kill(parent, SIGKILL);\n    }\n    exit(1);\n  }\n  srand(getpid());\n  while( rc==SQLITE_OK ){\n    cnt++;\n    rc = sqlite_exec_printf(db, \n       \"INSERT INTO t1 VALUES(%d,'%d%s')\", 0, 0, &zErr,\n       rand(), rand(), zBig);\n  }\n  if( rc!=SQLITE_OK ){\n    printf(\"ERROR #%d: %s\\n\", rc, zErr);\n    if( rc==SQLITE_CORRUPT ){\n      kill(parent, SIGKILL);\n    }\n  }\n  printf(\"pid %d: cnt=%d\\n\", getpid(), cnt);\n}\n\n\nint main(int argc, char **argv){\n  int i;\n  sqlite *db;\n  char *zErr;\n  int status;\n  int parent = getpid();\n\n  unlink(\"test.db\");\n  unlink(\"test.db-journal\");\n  db = sqlite_open(\"test.db\", 0, &zErr);\n  if( db==0 ){\n    printf(\"Cannot initialize: %s\\n\", zErr);\n    return 1;\n  }\n  sqlite_exec(db, \"CREATE TABLE t1(a,b)\", 0, 0, 0);\n  sqlite_close(db);\n  for(i=0; i<10000; i++){\n    int pid = fork();\n    if( pid==0 ){\n      sched_yield();\n      do_some_sql(parent);\n      return 0;\n    }\n    printf(\"test %d, pid=%d\\n\", i, pid);\n    usleep(rand()%10000 + 1000);\n    kill(pid, SIGKILL);\n    waitpid(pid, &status, 0);\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/createtab.test",
    "content": "# 2007 May 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that it is OK to create new tables\n# and indices while creating existing tables and indices.\n#\n# $Id: createtab.test,v 1.3 2007/09/12 17:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable autovacuum {\n  set upperBound 2\n} else {\n  set upperBound 0\n}\n\n# Run these tests for all possible values of autovacuum.\n#\nfor {set av 0} {$av<=$upperBound} {incr av} {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n\n  # Create a table that spans multiple pages.  It is important\n  # that part of the database be in pages beyond the root page.\n  #\n  do_test createtab-$av.1 {\n    execsql \"PRAGMA auto_vacuum=$av\"\n    execsql {\n      PRAGMA page_size=1024;\n      CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n      INSERT INTO t1 VALUES(1, hex(randomblob(200)));\n      INSERT INTO t1 VALUES(2, hex(randomblob(200)));\n      INSERT INTO t1 VALUES(3, hex(randomblob(200)));\n      INSERT INTO t1 VALUES(4, hex(randomblob(200)));\n      SELECT count(*) FROM t1;\n    }\n  } {4}\n\n  set isUtf16 0\n  ifcapable utf16 { \n    set isUtf16 [expr {[execsql {PRAGMA encoding}] != \"UTF-8\"}]\n  }\n\n  do_test createtab-$av.2 {\n    file size test.db\n  } [expr {1024*(4+($av!=0)+(${isUtf16}*2))}]\n  \n  # Start reading the table\n  #\n  do_test createtab-$av.3 {\n    set STMT [sqlite3_prepare db {SELECT x FROM t1} -1 TAIL]\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test createtab-$av.4 {\n    sqlite3_column_int $STMT 0\n  } {1}\n  \n  # While still reading the table, create a new table.\n  #\n  do_test createtab-$av.5 {\n    execsql {\n      CREATE TABLE t2(a,b);\n      INSERT INTO t2 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {1 2}\n  \n  # Continue reading the original table.\n  #\n  do_test createtab-$av.6 {\n    sqlite3_column_int $STMT 0\n  } {1}\n  do_test createtab-$av.7 {\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test createtab-$av.8 {\n    sqlite3_column_int $STMT 0\n  } {2}\n  \n  # Do another cycle of creating a new database table while contining\n  # to read the original table.\n  #\n  do_test createtab-$av.11 {\n    execsql {\n      CREATE TABLE t3(a,b);\n      INSERT INTO t3 VALUES(4,5);\n      SELECT * FROM t3;\n    }\n  } {4 5}\n  do_test createtab-$av.12 {\n    sqlite3_column_int $STMT 0\n  } {2}\n  do_test createtab-$av.13 {\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test createtab-$av.14 {\n    sqlite3_column_int $STMT 0\n  } {3}\n  \n  # One more cycle.\n  #\n  do_test createtab-$av.21 {\n    execsql {\n      CREATE TABLE t4(a,b);\n      INSERT INTO t4 VALUES('abc','xyz');\n      SELECT * FROM t4;\n    }\n  } {abc xyz}\n  do_test createtab-$av.22 {\n    sqlite3_column_int $STMT 0\n  } {3}\n  do_test createtab-$av.23 {\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n  do_test createtab-$av.24 {\n    sqlite3_column_int $STMT 0\n  } {4}\n  \n  # Finish reading.  Do an integrity check on the database.\n  #\n  do_test createtab-$av.30 {\n    sqlite3_step $STMT\n  } {SQLITE_DONE}\n  do_test createtab-$av.31 {\n    sqlite3_finalize $STMT\n  } {SQLITE_OK}\n  do_test createtab-$av.32 {\n    execsql {\n      SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1\n    }\n  } {t1 t2 t3 t4}\n  integrity_check createtab-$av.40\n\n}\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cse.test",
    "content": "# 2008 April 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases designed to exercise and verify the logic for\n# factoring constant expressions out of loops and for\n# common subexpression eliminations.\n#\n# $Id: cse.test,v 1.6 2008/08/04 03:51:24 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test cse-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e, f);\n    INSERT INTO t1 VALUES(1,11,12,13,14,15);\n    INSERT INTO t1 VALUES(2,21,22,23,24,25);\n  }\n  execsql {\n    SELECT b, -b, ~b, NOT b, NOT NOT b, b-b, b+b, b*b, b/b, b FROM t1\n  }\n} {11 -11 -12 0 1 0 22 121 1 11 21 -21 -22 0 1 0 42 441 1 21}\ndo_test cse-1.2 {\n  execsql {\n    SELECT b, b%b, b==b, b!=b, b<b, b<=b, b IS NULL, b NOT NULL, b FROM t1\n  }\n} {11 0 1 0 0 1 0 1 11 21 0 1 0 0 1 0 1 21}\ndo_test cse-1.3 {\n  execsql {\n    SELECT b, abs(b), coalesce(b,-b,NOT b,c,NOT c), c, -c FROM t1;\n  }\n} {11 11 11 12 -12 21 21 21 22 -22}\ndo_test cse-1.4 {\n  execsql {\n    SELECT CASE WHEN a==1 THEN b ELSE c END, b, c FROM t1\n  }\n} {11 11 12 22 21 22}\ndo_test cse-1.5 {\n  execsql {\n    SELECT CASE a WHEN 1 THEN b WHEN 2 THEN c ELSE d END, b, c, d FROM t1\n  }\n} {11 11 12 13 22 21 22 23}\ndo_test cse-1.6.1 {\n  execsql {\n    SELECT CASE b WHEN 11 THEN -b WHEN 21 THEN -c ELSE -d END, b, c, d FROM t1\n  }\n} {-11 11 12 13 -22 21 22 23}\ndo_test cse-1.6.2 {\n  execsql {\n    SELECT CASE b+1 WHEN c THEN d WHEN e THEN f ELSE 999 END, b, c, d FROM t1\n  }\n} {13 11 12 13 23 21 22 23}\ndo_test cse-1.6.3 {\n  execsql {\n    SELECT CASE WHEN b THEN d WHEN e THEN f ELSE 999 END, b, c, d FROM t1\n  }\n} {13 11 12 13 23 21 22 23}\ndo_test cse-1.6.4 {\n  execsql {\n    SELECT b, c, d, CASE WHEN b THEN d WHEN e THEN f ELSE 999 END FROM t1\n  }\n} {11 12 13 13 21 22 23 23}\ndo_test cse-1.6.5 {\n  execsql {\n    SELECT b, c, d, CASE WHEN 0 THEN d WHEN e THEN f ELSE 999 END FROM t1\n  }\n} {11 12 13 15 21 22 23 25}\ndo_test cse-1.7 {\n  execsql {\n    SELECT a, -a, ~a, NOT a, NOT NOT a, a-a, a+a, a*a, a/a, a FROM t1\n  }\n} {1 -1 -2 0 1 0 2 1 1 1 2 -2 -3 0 1 0 4 4 1 2}\ndo_test cse-1.8 {\n  execsql {\n    SELECT a, a%a, a==a, a!=a, a<a, a<=a, a IS NULL, a NOT NULL, a FROM t1\n  }\n} {1 0 1 0 0 1 0 1 1 2 0 1 0 0 1 0 1 2}\ndo_test cse-1.9 {\n  execsql {\n    SELECT NOT b, ~b, NOT NOT b, b FROM t1\n  }\n} {0 -12 1 11 0 -22 1 21}\ndo_test cse-1.10 {\n  execsql {\n    SELECT CAST(b AS integer), typeof(b), CAST(b AS text), typeof(b) FROM t1\n  }\n} {11 integer 11 integer 21 integer 21 integer}\nifcapable compound {\n  do_test cse-1.11 { \n    execsql {\n      SELECT *,* FROM t1 WHERE a=2\n      UNION ALL\n      SELECT *,* FROM t1 WHERE a=1\n    }\n  } {2 21 22 23 24 25 2 21 22 23 24 25 1 11 12 13 14 15 1 11 12 13 14 15}\n  do_test cse-1.12 { \n    execsql {\n      SELECT coalesce(b,c,d,e), a, b, c, d, e FROM t1 WHERE a=2\n      UNION ALL\n      SELECT coalesce(e,d,c,b), e, d, c, b, a FROM t1 WHERE a=1\n    }\n  } {21 2 21 22 23 24 14 14 13 12 11 1}\n}\ndo_test cse-1.13 {\n  execsql {\n     SELECT upper(b), typeof(b), b FROM t1\n  }\n} {11 integer 11 21 integer 21}\ndo_test cse-1.14 {\n  execsql {\n     SELECT b, typeof(b), upper(b), typeof(b), b FROM t1\n  }\n} {11 integer 11 integer 11 21 integer 21 integer 21}\n\n# Overflow the column cache.  Create queries involving more and more\n# columns until the cache overflows.  Verify correct operation throughout.\n#\ndo_test cse-2.1 {\n  execsql {\n    CREATE TABLE t2(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,\n                    a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,\n                    a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,\n                    a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,\n                    a40,a41,a42,a43,a44,a45,a46,a47,a48,a49);\n    INSERT INTO t2 VALUES(0,1,2,3,4,5,6,7,8,9,\n                    10,11,12,13,14,15,16,17,18,19,\n                    20,21,22,23,24,25,26,27,28,29,\n                    30,31,32,33,34,35,36,37,38,39,\n                    40,41,42,43,44,45,46,47,48,49);\n    SELECT * FROM t2;\n  }\n} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49}\n\nfor {set i 1} {$i<100} {incr i} {\n  set n [expr {int(rand()*44)+5}]\n  set colset {}\n  set answer {}\n  for {set j 0} {$j<$n} {incr j} {\n    set r [expr {$j+int(rand()*5)}]\n    if {$r>49} {set r [expr {99-$r}]}\n    lappend colset a$j a$r \n    lappend answer $j $r\n  }\n  set sql \"SELECT [join $colset ,] FROM t2\"\n  do_test cse-2.2.$i {\n    # explain $::sql\n    execsql $::sql\n  } $answer\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/csv01.test",
    "content": "# 2016-06-02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases for CSV virtual table.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix csv01\n\nifcapable !vtab||!cte { finish_test ; return }\n\nload_static_extension db csv\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE temp.t1 USING csv(\n    data=\n'1,2,3,4\n5,6,7,8\n9,10,11,12\n13,14,15,16\n',\n    columns=4\n  );\n  SELECT * FROM t1 WHERE c1=10;\n} {9 10 11 12}\ndo_execsql_test 1.1 {\n  SELECT * FROM t1 WHERE c1='10';\n} {9 10 11 12}\ndo_execsql_test 1.2 {\n  SELECT rowid FROM t1;\n} {1 2 3 4}\n\ndo_execsql_test 2.0 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE temp.t2 USING csv(\n    data=\n'1,2,3,4\n5,6,7,8\n9,10,11,12\n13,14,15,16\n',\n    columns=4,\n    schema='CREATE TABLE t2(a INT, b TEXT, c REAL, d BLOB)'\n  );\n  SELECT * FROM t2 WHERE a=9;\n} {9 10 11 12}\ndo_execsql_test 2.1 {\n  SELECT * FROM t2 WHERE b=10;\n} {9 10 11 12}\ndo_execsql_test 2.2 {\n  SELECT * FROM t2 WHERE c=11;\n} {9 10 11 12}\ndo_execsql_test 2.3 {\n  SELECT * FROM t2 WHERE d=12;\n} {}\ndo_execsql_test 2.4 {\n  SELECT * FROM t2 WHERE d='12';\n} {9 10 11 12}\ndo_execsql_test 2.5 {\n  SELECT * FROM t2 WHERE a='9';\n} {9 10 11 12}\n\ndo_execsql_test 3.0 {\n  DROP TABLE t2;\n  CREATE VIRTUAL TABLE temp.t3 USING csv(\n    data=\n'1,2,3,4\n5,6,7,8\n9,10,11,12\n13,14,15,16\n',\n    columns=4,\n    schema=\n      'CREATE TABLE t3(a PRIMARY KEY,b TEXT,c TEXT,d TEXT) WITHOUT ROWID',\n    testflags=1\n  );\n  SELECT a FROM t3 WHERE b=6 OR c=7 OR d=12 ORDER BY +a;\n} {5 9}\ndo_execsql_test 3.1 {\n  SELECT a FROM t3 WHERE +b=6 OR c=7 OR d=12 ORDER BY +a;\n} {5 9}\n\n# The rowid column is not visible on a WITHOUT ROWID virtual table\ndo_catchsql_test 3.2 {\n  SELECT rowid, a FROM t3;\n} {1 {no such column: rowid}}\n\n# Multi-column WITHOUT ROWID virtual tables may not be writable.\ndo_catchsql_test 4.0 {\n  DROP TABLE t3;\n  CREATE VIRTUAL TABLE temp.t4 USING csv_wr(\n    data=\n'1,2,3,4\n5,6,7,8\n9,10,11,12\n13,14,15,16',\n    columns=4,\n    schema=\n      'CREATE TABLE t3(a,b,c,d,PRIMARY KEY(a,b)) WITHOUT ROWID',\n    testflags=1\n  );\n} {1 {vtable constructor failed: t4}}\n\n# WITHOUT ROWID tables with a single-column PRIMARY KEY may be writable.\ndo_catchsql_test 4.1 {\n  DROP TABLE IF EXISTS t4;\n  CREATE VIRTUAL TABLE temp.t4 USING csv_wr(\n    data=\n'1,2,3,4\n5,6,7,8\n9,10,11,12\n13,14,15,16',\n    columns=4,\n    schema=\n      'CREATE TABLE t3(a,b,c,d,PRIMARY KEY(b)) WITHOUT ROWID',\n    testflags=1\n  );\n} {0 {}}\n\ndo_catchsql_test 4.2 {\n  DROP TABLE IF EXISTS t5;\n  CREATE VIRTUAL TABLE temp.t5 USING csv_wr(\n      data=\n      '1,2,3,4\n      5,6,7,8\n      9,10,11,12\n      13,14,15,16',\n      columns=4,\n      schema=\n      'CREATE TABLE t3(a,b,c,d) WITHOUT ROWID',\n      testflags=1\n      );\n} {1 {vtable constructor failed: t5}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ctime.test",
    "content": "# 2009 February 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the compile time diagnostic \n# functions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test organization:\n#\n# ctime-1.*: Test pragma support.\n# ctime-2.*: Test function support.\n#\n\nifcapable !pragma||!compileoption_diags {\n  finish_test\n  return\n}\n\n#####################\n# ctime-1.*: Test pragma support.\n\ndo_test ctime-1.1.1 {\n  catchsql {\n    PRAGMA compile_options();\n  }\n} {1 {near \")\": syntax error}}\ndo_test ctime-1.1.2 {\n  catchsql {\n    PRAGMA compile_options(NULL);\n  }\n} {1 {near \"NULL\": syntax error}}\ndo_test ctime-1.1.3 {\n  catchsql {\n    PRAGMA compile_options *;\n  }\n} {1 {near \"*\": syntax error}}\n\ndo_test ctime-1.2.1 {\n  set ans [ catchsql {\n    PRAGMA compile_options;\n  } ]\n  list [ lindex $ans 0 ]\n} {0}\n# the results should be in sorted order already\ndo_test ctime-1.2.2 {\n  set ans [ catchsql {\n    PRAGMA compile_options;\n  } ]\n  list [ lindex $ans 0 ] [ expr { [lsort [lindex $ans 1]]==[lindex $ans 1] } ]\n} {0 1}\n\n# Check the THREADSAFE option for SQLITE_THREADSAFE=2 builds (there are\n# a couple of these configurations in releasetest.tcl).\n#\nifcapable threadsafe2 {\n  foreach {tn opt res} {\n    1 SQLITE_THREADSAFE     1\n    2 THREADSAFE            1\n    3 THREADSAFE=0          0\n    4 THREADSAFE=1          0\n    5 THREADSAFE=2          1\n    6 THREADSAFE=           0\n  } {\n    do_execsql_test ctime-1.3.$tn {\n      SELECT sqlite_compileoption_used($opt)\n    } $res\n  }\n}\n\n# SQLITE_THREADSAFE should pretty much always be defined\n# one way or the other, and it must have a value of 0 or 1.\ndo_test ctime-1.4.1 {\n  catchsql {\n    SELECT sqlite_compileoption_used('SQLITE_THREADSAFE');\n  }\n} {0 1}\ndo_test ctime-1.4.2 {\n  catchsql {\n    SELECT sqlite_compileoption_used('THREADSAFE');\n  }\n} {0 1}\ndo_test ctime-1.4.3 {\n  catchsql {\n    SELECT sqlite_compileoption_used(\"THREADSAFE\");\n  }\n} {0 1}\n\ndo_test ctime-1.5 {\n  set ans1 [ catchsql {\n    SELECT sqlite_compileoption_used('THREADSAFE=0');\n  } ]\n  set ans2 [ catchsql {\n    SELECT sqlite_compileoption_used('THREADSAFE=1');\n  } ]\n  set ans3 [ catchsql {\n    SELECT sqlite_compileoption_used('THREADSAFE=2');\n  } ]\n  lsort [ list $ans1 $ans2 $ans3 ]\n} {{0 0} {0 0} {0 1}}\n\ndo_test ctime-1.6 {\n  execsql {\n    SELECT sqlite_compileoption_used('THREADSAFE=');\n  }\n} {0}\n\ndo_test ctime-1.7.1 {\n  execsql {\n    SELECT sqlite_compileoption_used('SQLITE_OMIT_COMPILEOPTION_DIAGS');\n  }\n} {0}\ndo_test ctime-1.7.2 {\n  execsql {\n    SELECT sqlite_compileoption_used('OMIT_COMPILEOPTION_DIAGS');\n  }\n} {0}\n\n#####################\n# ctime-2.*: Test function support.\n\ndo_test ctime-2.1.1 {\n  catchsql {\n    SELECT sqlite_compileoption_used();\n  }\n} {1 {wrong number of arguments to function sqlite_compileoption_used()}}\ndo_test ctime-2.1.2 {\n  catchsql {\n    SELECT sqlite_compileoption_used(NULL);\n  }\n} {0 {{}}}\ndo_test ctime-2.1.3 {\n  catchsql {\n    SELECT sqlite_compileoption_used(\"\");\n  }\n} {0 0}\ndo_test ctime-2.1.4 {\n  catchsql {\n    SELECT sqlite_compileoption_used('');\n  }\n} {0 0}\ndo_test ctime-2.1.5 {\n  catchsql {\n    SELECT sqlite_compileoption_used(foo);\n  }\n} {1 {no such column: foo}}\ndo_test ctime-2.1.6 {\n  catchsql {\n    SELECT sqlite_compileoption_used('THREADSAFE', 0);\n  }\n} {1 {wrong number of arguments to function sqlite_compileoption_used()}}\ndo_test ctime-2.1.7 {\n  catchsql {\n    SELECT sqlite_compileoption_used(0);\n  }\n} {0 0}\ndo_test ctime-2.1.8 {\n  catchsql {\n    SELECT sqlite_compileoption_used('0');\n  }\n} {0 0}\ndo_test ctime-2.1.9 {\n  catchsql {\n    SELECT sqlite_compileoption_used(1.0);\n  }\n} {0 0}\n\ndo_test ctime-2.2.1 {\n  catchsql {\n    SELECT sqlite_compileoption_get();\n  }\n} {1 {wrong number of arguments to function sqlite_compileoption_get()}}\ndo_test ctime-2.2.2 {\n  catchsql {\n    SELECT sqlite_compileoption_get(0, 0);\n  }\n} {1 {wrong number of arguments to function sqlite_compileoption_get()}}\n\n# This assumes there is at least 1 compile time option\n# (see SQLITE_THREADSAFE above).\ndo_test ctime-2.3 {\n  catchsql {\n    SELECT sqlite_compileoption_used(sqlite_compileoption_get(0));\n  }\n} {0 1}\n\n# This assumes there is at least 1 compile time option\n# (see SQLITE_THREADSAFE above).\ndo_test ctime-2.4 {\n  set ans [ catchsql {\n    SELECT sqlite_compileoption_get(0);\n  } ]\n  list [lindex $ans 0]\n} {0}\n\n# Get the list of defines using the pragma,\n# then try querying each one with the functions.\nset ans [ catchsql {\n  PRAGMA compile_options;\n} ]\nset opts [ lindex $ans 1 ]\nset tc 1\nforeach opt $opts {\n  do_test ctime-2.5.$tc {\n    set N [ expr {$tc-1} ]\n    set ans1 [catch {db one {\n      SELECT sqlite_compileoption_get($N);\n    }} msg]\n    lappend ans1 $msg\n    set ans2 [ catchsql {\n      SELECT sqlite_compileoption_used($opt);\n    } ]\n    list [ lindex $ans1 0 ] [ expr { [lindex $ans1 1]==$opt } ] \\\n         [ expr { $ans2 } ]\n  } {0 1 {0 1}}\n  incr tc 1\n}\n# test 1 past array bounds\ndo_test ctime-2.5.$tc {\n  set N [ expr {$tc-1} ]\n  set ans [ catchsql {\n    SELECT sqlite_compileoption_get($N);\n  } ]\n} {0 {{}}}\nincr tc 1\n# test 1 before array bounds (N=-1)\ndo_test ctime-2.5.$tc {\n  set N -1\n  set ans [ catchsql {\n    SELECT sqlite_compileoption_get($N);\n  } ]\n} {0 {{}}}\n\n#--------------------------------------------------------------------------\n# Test that SQLITE_DIRECT_OVERFLOW_READ is reflected in the output of\n# \"PRAGMA compile_options\".\n#\nifcapable direct_read {\n  set res 1\n} else {\n  set res 0\n}\ndo_test ctime-3.0.1 {\n  expr [lsearch [db eval {PRAGMA compile_options}] DIRECT_OVERFLOW_READ]>=0\n} $res\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cursorhint.test",
    "content": "# 2014 July 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix cursorhint\n\nifcapable !cursorhints {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE TABLE t2(x,y,z);\n  INSERT INTO t1(a,b) VALUES(10, 15);\n  INSERT INTO t1(a,b) VALUES(20, 25);\n  INSERT INTO t2(x,y) VALUES('ten', 'fifteen');\n  INSERT INTO t2(x,y) VALUES('twenty', 'twentyfive');\n  CREATE TABLE t3(id TEXT PRIMARY KEY, a, b, c, d) WITHOUT ROWID;\n  INSERT INTO t3(id,a,b,c,d) SELECT rowid, a, b, c, d FROM t1;\n  PRAGMA automatic_index = 0;\n}\n\n# Run EXPLAIN on $sql.  Return a list of P4 values for all $opcode\n# opcodes.\n#\nproc p4_of_opcode {db opcode sql} {\n  set res {}\n  $db eval \"EXPLAIN $sql\" x {\n    if {$x(opcode)==$opcode} {lappend res $x(p4)}\n  }\n  return $res\n}\n\n# Run EXPLAIN on $sql.  Return a list of P5 values for all $opcode\n# opcodes that contain regexp $comment in their comment\n#\nproc p5_of_opcode {db opcode sql} {\n  set res {}\n  $db eval \"EXPLAIN $sql\" x {\n    if {$x(opcode)==$opcode} {\n      lappend res $x(p5)\n    }\n  }\n  return $res\n}\n\n# Verify that when t1 is in the outer loop and t2 is in the inner loop,\n# no cursor hints occur for t1 (since it is a full table scan) but that\n# each t2 access has a cursor hint based on the current t1.a value.\n#\ndo_test 1.1 {\n  p4_of_opcode db CursorHint {\n     SELECT * FROM t1 CROSS JOIN t2 WHERE a=x\n  }\n} {{EQ(r[1],c0)}}\ndo_test 1.2 {\n  p5_of_opcode db OpenRead {\n     SELECT * FROM t1 CROSS JOIN t2 WHERE a=x\n  }\n} {00 00}\n\n# Do the same test the other way around.\n#\ndo_test 2.1 {\n  p4_of_opcode db CursorHint {\n     SELECT * FROM t2 CROSS JOIN t1 WHERE a=x\n  }\n} {{EQ(c0,r[1])}}\ndo_test 2.2 {\n  p5_of_opcode db OpenRead {\n     SELECT * FROM t2 CROSS JOIN t1 WHERE a=x\n  }\n} {00 00}\n\n# Various expressions captured by CursorHint\n#\ndo_test 3.1 {\n  p4_of_opcode db CursorHint {\n    SELECT * FROM t1 WHERE a=15 AND c=22 AND rowid!=98\n  }\n} {AND(AND(EQ(c0,15),EQ(c2,22)),NE(rowid,98))}\ndo_test 3.2 {\n  p4_of_opcode db CursorHint {\n    SELECT * FROM t3 WHERE a<15 AND b>22 AND id!=98\n  }\n} {AND(AND(LT(c1,15),GT(c2,22)),NE(c0,98))}\n\n# Indexed queries\n#\ndo_test 4.1asc {\n  db eval {\n    CREATE INDEX t1bc ON t1(b,c);\n    CREATE INDEX t2yz ON t2(y,z);\n  }\n  p4_of_opcode db CursorHint {\n    SELECT * FROM t1 WHERE b>11 ORDER BY b ASC;\n  }\n} {}\ndo_test 4.1desc {\n  p4_of_opcode db CursorHint {\n    SELECT * FROM t1 WHERE b>11 ORDER BY b DESC;\n  }\n} {GT(c0,11)}\ndo_test 4.2 {\n  p5_of_opcode db OpenRead {\n    SELECT * FROM t1 WHERE b>11;\n  }\n} {02 00}\ndo_test 4.3asc {\n  p4_of_opcode db CursorHint {\n    SELECT c FROM t1 WHERE b<11 ORDER BY b ASC;\n  }\n} {LT(c0,11)}\ndo_test 4.3desc {\n  p4_of_opcode db CursorHint {\n    SELECT c FROM t1 WHERE b<11 ORDER BY b DESC;\n  }\n} {}\ndo_test 4.4 {\n  p5_of_opcode db OpenRead {\n    SELECT c FROM t1 WHERE b<11;\n  }\n} {00}\n\ndo_test 4.5asc {\n  p4_of_opcode db CursorHint {\n    SELECT c FROM t1 WHERE b>=10 AND b<=20 ORDER BY b ASC;\n  }\n} {LE(c0,20)}\ndo_test 4.5desc {\n  p4_of_opcode db CursorHint {\n    SELECT c FROM t1 WHERE b>=10 AND b<=20 ORDER BY b DESC;\n  }\n} {GE(c0,10)}\n\n# If there are any equality terms used in the constraint, then all terms\n# should be hinted.\n#\ndo_test 4.6asc {\n  p4_of_opcode db CursorHint {\n    SELECT rowid FROM t1 WHERE b=22 AND c>=10 AND c<=20 ORDER BY b,c ASC;\n  }\n} {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))}\ndo_test 4.6desc {\n  p4_of_opcode db CursorHint {\n    SELECT rowid FROM t1 WHERE b=22 AND c>=10 AND c<=20 ORDER BY b,c DESC;\n  }\n} {AND(AND(EQ(c0,22),GE(c1,10)),LE(c1,20))}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/cursorhint2.test",
    "content": "# 2016 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus is on testing that cursor-hints are correct for queries\n# involving LEFT JOIN.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix cursorhint2\n\nifcapable !cursorhints {\n  finish_test\n  return\n}\n\nproc extract_hints {sql} {\n\n  db eval \"SELECT tbl_name, rootpage FROM sqlite_master where rootpage\" {\n    set lookup($rootpage) $tbl_name\n  }\n\n  set ret [list]\n  db eval \"EXPLAIN $sql\" a {\n    switch -- $a(opcode) {\n      OpenRead {\n        set csr($a(p1)) $lookup($a(p2))\n      }\n      CursorHint { \n        lappend ret $csr($a(p1)) $a(p4) \n      }\n    }\n  }\n\n  set ret\n}\n\nproc do_extract_hints_test {tn sql ret} {\n  uplevel [list do_test $tn [list extract_hints $sql] [list {*}$ret]]\n}\n\ndo_execsql_test 1.0 {\n  PRAGMA automatic_index = 0;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(c, d);\n  CREATE TABLE t3(e, f);\n}\n\ndo_extract_hints_test 1.1 {\n  SELECT * FROM t1 WHERE a=1;\n} {\n  t1 EQ(c0,1)\n}\n\ndo_extract_hints_test 1.2 {\n  SELECT * FROM t1 CROSS JOIN t2 ON (a=c) WHERE d IS NULL;\n} {\n  t2 {AND(ISNULL(c1),EQ(r[1],c0))}\n}\n\ndo_extract_hints_test 1.3 {\n  SELECT * FROM t1 LEFT JOIN t2 ON (a=c) WHERE d IS NULL;\n} {\n  t2 {EQ(r[2],c0)}\n}\n\ndo_extract_hints_test 1.4 {\n  SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND a=10) WHERE d IS NULL;\n} {\n  t2 {AND(EQ(r[2],c0),EQ(r[3],10))}\n}\n\ndo_extract_hints_test 1.5 {\n  SELECT * FROM t1 CROSS JOIN t2 ON (a=c AND a=10) WHERE d IS NULL;\n} {\n  t1 EQ(c0,10) t2 {AND(ISNULL(c1),EQ(r[3],c0))}\n}\n\ndo_extract_hints_test 1.6 {\n  SELECT * FROM t1 LEFT JOIN t2 ON (a=c) LEFT JOIN t3 ON (d=f);\n} {\n  t2 {EQ(r[2],c0)} t3 {EQ(r[6],c1)}\n}\n\nif 0 {\n  do_extract_hints_test 1.7 {\n    SELECT * FROM t1 LEFT JOIN t2 ON (a=c AND d=e) LEFT JOIN t3 ON (d=f);\n  } {\n    t2 {EQ(r[2],c0)} t3 {AND(EQ(r[6],c0),EQ(r[7],c1))}\n  }\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE x1(x, y);\n  CREATE TABLE x2(a, b);\n}\n\ndo_extract_hints_test 2.1 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NULL;\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.2 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS +NULL;\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.3 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = (b IS NULL)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.4 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.5 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 1 = coalesce(b, 1)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.6 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 0 = (b IS NOT NULL)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.7 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE 0 = (b IS NOT +NULL)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.8 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE b IS NOT +NULL\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.9 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE CASE b WHEN 0 THEN 0 ELSE 1 END;\n} {\n  x2 {EQ(c0,r[2])}\n}\n\ndo_extract_hints_test 2.10 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b = 32+32\n} {\n  x2 {AND(EQ(c1,ADD(32,32)),EQ(c0,r[2]))}\n}\n\nifcapable !icu {\n  # This test only works using the built-in LIKE, not the ICU LIKE extension.\n  do_extract_hints_test 2.11 {\n    SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE x2.b LIKE 'abc%'\n  } {\n    x2 {AND(expr,EQ(c0,r[2]))}\n  }\n}\n\ndo_extract_hints_test 2.12 {\n  SELECT * FROM x1 LEFT JOIN x2 ON (a=x) WHERE coalesce(x2.b, 1)\n} {\n  x2 {EQ(c0,r[2])}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/date.test",
    "content": "# 2003 October 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing date and time functions.\n#\n# $Id: date.test,v 1.34 2009/04/16 12:58:03 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Skip this whole file if date and time functions are omitted\n# at compile-time\n#\nifcapable {!datetime} {\n  finish_test\n  return\n}\n\nproc datetest {tnum expr result} {\n  do_test date-$tnum [subst {\n    execsql \"SELECT coalesce($expr,'NULL')\"\n  }] [list $result]\n}\nset tcl_precision 15\ndatetest 1.1 julianday('2000-01-01') 2451544.5\ndatetest 1.2 julianday('1970-01-01') 2440587.5\ndatetest 1.3 julianday('1910-04-20') 2418781.5\ndatetest 1.4 julianday('1986-02-09') 2446470.5\ndatetest 1.5 julianday('12:00:00') 2451545.0\ndatetest 1.6 {julianday('2000-01-01 12:00:00')} 2451545.0\ndatetest 1.7 {julianday('2000-01-01 12:00')} 2451545.0\ndatetest 1.8 julianday('bogus') NULL\ndatetest 1.9 julianday('1999-12-31') 2451543.5\ndatetest 1.10 julianday('1999-12-32') NULL\ndatetest 1.11 julianday('1999-13-01') NULL\ndatetest 1.12 julianday('2003-02-31') 2452701.5\ndatetest 1.13 julianday('2003-03-03') 2452701.5\ndatetest 1.14 julianday('+2000-01-01') NULL\ndatetest 1.15 julianday('200-01-01') NULL\ndatetest 1.16 julianday('2000-1-01') NULL\ndatetest 1.17 julianday('2000-01-1') NULL\ndatetest 1.18.1 {julianday('2000-01-01     12:00:00')} 2451545.0\ndatetest 1.18.2 {julianday('2000-01-01T12:00:00')} 2451545.0\ndatetest 1.18.3 {julianday('2000-01-01 T12:00:00')} 2451545.0\ndatetest 1.18.4 {julianday('2000-01-01T 12:00:00')} 2451545.0\ndatetest 1.18.4 {julianday('2000-01-01 T 12:00:00')} 2451545.0\ndatetest 1.19 {julianday('2000-01-01 12:00:00.1')}   2451545.00000116\ndatetest 1.20 {julianday('2000-01-01 12:00:00.01')}  2451545.00000012\ndatetest 1.21 {julianday('2000-01-01 12:00:00.001')} 2451545.00000001\ndatetest 1.22 {julianday('2000-01-01 12:00:00.')} NULL\ndatetest 1.23 julianday(12345.6) 12345.6\ndatetest 1.23b julianday(1721059.5) 1721059.5\ndatetest 1.24 {julianday('2001-01-01 12:00:00 bogus')} NULL\ndatetest 1.25 {julianday('2001-01-01 bogus')} NULL\ndatetest 1.26 {julianday('2001-01-01 12:60:00')} NULL\ndatetest 1.27 {julianday('2001-01-01 12:59:60')} NULL\ndatetest 1.28 {julianday('2001-00-01')} NULL\ndatetest 1.29 {julianday('2001-01-00')} NULL\n\ndatetest 2.1 datetime(0,'unixepoch') {1970-01-01 00:00:00}\ndatetest 2.1b datetime(0,'unixepoc') NULL\ndatetest 2.1c datetime(0,'unixepochx') NULL\ndatetest 2.1d datetime('2003-10-22','unixepoch') NULL\ndatetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}\ndatetest 2.2b datetime('946684800','unixepoch') {2000-01-01 00:00:00}\nfor {set i 0} {$i<1000} {incr i} {\n  set sql [format {strftime('%%H:%%M:%%f',1237962480.%03d,'unixepoch')} $i]\n  set res [format {06:28:00.%03d} $i]\n  datetest 2.2c-$i $sql $res\n}\ndatetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26\ndatetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27\ndatetest 2.4a {date('2003-10-22','weekday  1')} 2003-10-27\ndatetest 2.4b {date('2003-10-22','weekday  1x')} NULL\ndatetest 2.4c {date('2003-10-22','weekday  -1')} NULL\ndatetest 2.4d {date('2003-10-22','weakday  1x')} NULL\ndatetest 2.4e {date('2003-10-22','weekday ')} NULL\ndatetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28\ndatetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22\ndatetest 2.7 {date('2003-10-22','weekday 4')} 2003-10-23\ndatetest 2.8 {date('2003-10-22','weekday 5')} 2003-10-24\ndatetest 2.9 {date('2003-10-22','weekday 6')} 2003-10-25\ndatetest 2.10 {date('2003-10-22','weekday 7')} NULL\ndatetest 2.11 {date('2003-10-22','weekday 5.5')} NULL\ndatetest 2.12 {datetime('2003-10-22 12:34','weekday 0')} {2003-10-26 12:34:00}\ndatetest 2.13 {datetime('2003-10-22 12:34','start of month')} \\\n   {2003-10-01 00:00:00}\ndatetest 2.14 {datetime('2003-10-22 12:34','start of year')} \\\n   {2003-01-01 00:00:00}\ndatetest 2.15 {datetime('2003-10-22 12:34','start of day')} \\\n   {2003-10-22 00:00:00}\ndatetest 2.15a {datetime('2003-10-22 12:34','start of')} NULL\ndatetest 2.15b {datetime('2003-10-22 12:34','start of bogus')} NULL\ndatetest 2.16 time('12:34:56.43') 12:34:56\ndatetest 2.17 {datetime('2003-10-22 12:34','1 day')} {2003-10-23 12:34:00}\ndatetest 2.18 {datetime('2003-10-22 12:34','+1 day')} {2003-10-23 12:34:00}\ndatetest 2.19 {datetime('2003-10-22 12:34','+1.25 day')} {2003-10-23 18:34:00}\ndatetest 2.20 {datetime('2003-10-22 12:34','-1.0 day')} {2003-10-21 12:34:00}\ndatetest 2.21 {datetime('2003-10-22 12:34','1 month')} {2003-11-22 12:34:00}\ndatetest 2.22 {datetime('2003-10-22 12:34','11 month')} {2004-09-22 12:34:00}\ndatetest 2.23 {datetime('2003-10-22 12:34','-13 month')} {2002-09-22 12:34:00}\ndatetest 2.24 {datetime('2003-10-22 12:34','1.5 months')} {2003-12-07 12:34:00}\ndatetest 2.25 {datetime('2003-10-22 12:34','-5 years')} {1998-10-22 12:34:00}\ndatetest 2.26 {datetime('2003-10-22 12:34','+10.5 minutes')} \\\n  {2003-10-22 12:44:30}\ndatetest 2.27 {datetime('2003-10-22 12:34','-1.25 hours')} \\\n  {2003-10-22 11:19:00}\ndatetest 2.28 {datetime('2003-10-22 12:34','11.25 seconds')} \\\n  {2003-10-22 12:34:11}\ndatetest 2.29 {datetime('2003-10-22 12:24','+5 bogus')} NULL\ndatetest 2.30 {datetime('2003-10-22 12:24','+++')} NULL\ndatetest 2.31 {datetime('2003-10-22 12:24','+12.3e4 femtoseconds')} NULL\ndatetest 2.32 {datetime('2003-10-22 12:24','+12.3e4 uS')} NULL\ndatetest 2.33 {datetime('2003-10-22 12:24','+1 abc')} NULL\ndatetest 2.34 {datetime('2003-10-22 12:24','+1 abcd')} NULL\ndatetest 2.35 {datetime('2003-10-22 12:24','+1 abcde')} NULL\ndatetest 2.36 {datetime('2003-10-22 12:24','+1 abcdef')} NULL\ndatetest 2.37 {datetime('2003-10-22 12:24','+1 abcdefg')} NULL\ndatetest 2.38 {datetime('2003-10-22 12:24','+1 abcdefgh')} NULL\ndatetest 2.39 {datetime('2003-10-22 12:24','+1 abcdefghi')} NULL\nset sqlite_current_time 1199243045\ndatetest 2.40 {datetime()} {2008-01-02 03:04:05}\nset sqlite_current_time 0\ndatetest 2.41 {datetime('2003-10-22 12:24','23 seconds')} {2003-10-22 12:24:23}\ndatetest 2.42 {datetime('2003-10-22 12:24','345 second')} {2003-10-22 12:29:45}\ndatetest 2.43 {datetime('2003-10-22 12:24','4 second')} {2003-10-22 12:24:04}\ndatetest 2.44 {datetime('2003-10-22 12:24','56 second')} {2003-10-22 12:24:56}\ndatetest 2.45 {datetime('2003-10-22 12:24','60 second')} {2003-10-22 12:25:00}\ndatetest 2.46 {datetime('2003-10-22 12:24','70 second')} {2003-10-22 12:25:10}\ndatetest 2.47 {datetime('2003-10-22 12:24','8.6 seconds')} {2003-10-22 12:24:08}\ndatetest 2.48 {datetime('2003-10-22 12:24','9.4 second')} {2003-10-22 12:24:09}\ndatetest 2.49 {datetime('2003-10-22 12:24','0000 second')} {2003-10-22 12:24:00}\ndatetest 2.50 {datetime('2003-10-22 12:24','0001 second')} {2003-10-22 12:24:01}\ndatetest 2.51 {datetime('2003-10-22 12:24','nonsense')} NULL\n\ndatetest 3.1 {strftime('%d','2003-10-31 12:34:56.432')} 31\ndatetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post\ndatetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999\ndatetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12\ndatetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304\ndatetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.024264259\ndatetest 3.6 {strftime('%m','2003-10-31 12:34:56.432')} 10\ndatetest 3.7 {strftime('%M','2003-10-31 12:34:56.432')} 34\ndatetest 3.8.1 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696\ndatetest 3.8.2 {strftime('%s','2038-01-19 03:14:07')} 2147483647\ndatetest 3.8.3 {strftime('%s','2038-01-19 03:14:08')} 2147483648\ndatetest 3.8.4 {strftime('%s','2201-04-09 12:00:00')} 7298164800\ndatetest 3.8.5 {strftime('%s','9999-12-31 23:59:59')} 253402300799\ndatetest 3.8.6 {strftime('%s','1969-12-31 23:59:59')} -1\ndatetest 3.8.7 {strftime('%s','1901-12-13 20:45:52')} -2147483648\ndatetest 3.8.8 {strftime('%s','1901-12-13 20:45:51')} -2147483649\ndatetest 3.8.9 {strftime('%s','1776-07-04 00:00:00')} -6106060800\ndatetest 3.9 {strftime('%S','2003-10-31 12:34:56.432')} 56\ndatetest 3.10 {strftime('%w','2003-10-31 12:34:56.432')} 5\ndatetest 3.11.1 {strftime('%W','2003-10-31 12:34:56.432')} 43\ndatetest 3.11.2 {strftime('%W','2004-01-01')} 00\ndatetest 3.11.3 {strftime('%W','2004-01-02')} 00\ndatetest 3.11.4 {strftime('%W','2004-01-03')} 00\ndatetest 3.11.5 {strftime('abc%Wxyz','2004-01-04')} abc00xyz\ndatetest 3.11.6 {strftime('%W','2004-01-05')} 01\ndatetest 3.11.7 {strftime('%W','2004-01-06')} 01\ndatetest 3.11.8 {strftime('%W','2004-01-07')} 01\ndatetest 3.11.9 {strftime('%W','2004-01-08')} 01\ndatetest 3.11.10 {strftime('%W','2004-01-09')} 01\ndatetest 3.11.11 {strftime('%W','2004-07-18')} 28\ndatetest 3.11.12 {strftime('%W','2004-12-31')} 52\ndatetest 3.11.13 {strftime('%W','2007-12-31')} 53\ndatetest 3.11.14 {strftime('%W','2007-01-01')} 01\ndatetest 3.11.15 {strftime('%W %j',2454109.04140970)} {02 008}\ndatetest 3.11.16 {strftime('%W %j',2454109.04140971)} {02 008}\ndatetest 3.11.17 {strftime('%W %j',2454109.04140972)} {02 008}\ndatetest 3.11.18 {strftime('%W %j',2454109.04140973)} {02 008}\ndatetest 3.11.19 {strftime('%W %j',2454109.04140974)} {02 008}\ndatetest 3.11.20 {strftime('%W %j',2454109.04140975)} {02 008}\ndatetest 3.11.21 {strftime('%W %j',2454109.04140976)} {02 008}\ndatetest 3.11.22 {strftime('%W %j',2454109.04140977)} {02 008}\ndatetest 3.11.23 {strftime('%W %j',2454109.04140978)} {02 008}\ndatetest 3.11.24 {strftime('%W %j',2454109.04140979)} {02 008}\ndatetest 3.11.25 {strftime('%W %j',2454109.04140980)} {02 008}\ndatetest 3.11.99 {strftime('%W %j','2454109.04140970')} {02 008}\ndatetest 3.12 {strftime('%Y','2003-10-31 12:34:56.432')} 2003\ndatetest 3.13 {strftime('%%','2003-10-31 12:34:56.432')} %\ndatetest 3.14 {strftime('%_','2003-10-31 12:34:56.432')} NULL\ndatetest 3.15 {strftime('%Y-%m-%d','2003-10-31')} 2003-10-31\nproc repeat {n txt} {\n  set x {} \n  while {$n>0} {\n    append x $txt\n    incr n -1\n  }\n  return $x\n}\ndatetest 3.16 \"strftime('[repeat 200 %Y]','2003-10-31')\" [repeat 200 2003]\ndatetest 3.17 \"strftime('[repeat 200 abc%m123]','2003-10-31')\" \\\n    [repeat 200 abc10123]\n\nforeach c {a b c e g h i k l n o p q r t v x y z\n           A B C D E F G I K L N O P Q R T U V Z\n           0 1 2 3 4 5 6 6 7 9 _} {\n  datetest 3.18.$c \"strftime('%$c','2003-10-31')\" NULL\n}\n\n# Ticket #2276.  Make sure leading zeros are inserted where appropriate.\n#\ndatetest 3.20 \\\n   {strftime('%d/%f/%H/%W/%j/%m/%M/%S/%Y','0421-01-02 03:04:05.006')} \\\n   02/05.006/03/00/002/01/04/05/0421\n\nset sqlite_current_time 1157124367\ndatetest 4.1 {date('now')} {2006-09-01}\nset sqlite_current_time 0\n\ndatetest 5.1 {datetime('1994-04-16 14:00:00 +05:00')} {1994-04-16 09:00:00}\ndatetest 5.2 {datetime('1994-04-16 14:00:00 -05:15')} {1994-04-16 19:15:00}\ndatetest 5.3 {datetime('1994-04-16 05:00:00 +08:30')} {1994-04-15 20:30:00}\ndatetest 5.4 {datetime('1994-04-16 14:00:00 -11:55')} {1994-04-17 01:55:00}\ndatetest 5.5 {datetime('1994-04-16 14:00:00 -11:60')} NULL\ndatetest 5.6 {datetime('1994-04-16 14:00:00 -11:55  ')} {1994-04-17 01:55:00}\ndatetest 5.7 {datetime('1994-04-16 14:00:00 -11:55 x')} NULL\ndatetest 5.8 {datetime('1994-04-16T14:00:00Z')} {1994-04-16 14:00:00}\ndatetest 5.9 {datetime('1994-04-16 14:00:00z')} {1994-04-16 14:00:00}\ndatetest 5.10 {datetime('1994-04-16 14:00:00 Z')} {1994-04-16 14:00:00}\ndatetest 5.11 {datetime('1994-04-16 14:00:00z    ')} {1994-04-16 14:00:00}\ndatetest 5.12 {datetime('1994-04-16 14:00:00     z    ')} {1994-04-16 14:00:00}\ndatetest 5.13 {datetime('1994-04-16 14:00:00Zulu')} NULL\ndatetest 5.14 {datetime('1994-04-16 14:00:00Z +05:00')} NULL\ndatetest 5.15 {datetime('1994-04-16 14:00:00 +05:00 Z')} NULL\n\n# localtime->utc and utc->localtime conversions.  These tests only work\n# if the localtime is in the US Eastern Time (the time in Charlotte, NC\n# and in New York.)\n#\n# On non-Vista Windows platform, '2006-03-31' is treated incorrectly as being\n# in DST giving a 4 hour offset instead of 5.  In 2007, DST was extended to \n# start three weeks earlier (second Sunday in March) and end one week\n# later (first Sunday in November).  Older Windows systems apply this\n# new rule incorrectly to dates prior to 2007.\n#\n# It might be argued that this is masking a problem on non-Vista Windows\n# platform.  A ticket has already been opened for this issue \n# (http://www.sqlite.org/cvstrac/tktview?tn=2322).  This is just to prevent\n# more confusion/reports of the issue.\n#\n\n# $tzoffset_old should be 5 if DST is working correctly.\nset tzoffset_old [db one {\n  SELECT CAST(24*(julianday('2006-03-31') -\n                  julianday('2006-03-31','localtime'))+0.5\n              AS INT)\n}]\n\n# $tzoffset_new should be 4 if DST is working correctly.\nset tzoffset_new [db one {\n  SELECT CAST(24*(julianday('2007-03-31') -\n                  julianday('2007-03-31','localtime'))+0.5\n              AS INT)\n}]\n\n# Warn about possibly broken Windows DST implementations.\nif {$::tcl_platform(platform)==\"windows\" && $tzoffset_new==4 && $tzoffset_old==4} {\n  puts \"******************************************************************\"\n  puts \"N.B.:  The DST support provided by your current O/S seems to be\"\n  puts \"suspect in that it is reporting incorrect DST values for dates\"\n  puts \"prior to 2007.  This is the known case for most (all?) non-Vista\"\n  puts \"Windows versions.  Please see ticket #2322 for more information.\"\n  puts \"******************************************************************\"\n}\n\nif {$tzoffset_new==4} {\n  datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\\\n      {2000-10-29 01:59:00}\n  datetest 6.1.1 {datetime('2006-10-29 05:59:00','localtime')}\\\n      {2006-10-29 01:59:00}\n  datetest 6.1.2 {datetime('2007-11-04 05:59:00','localtime')}\\\n      {2007-11-04 01:59:00}\n\n  # If the new and old DST rules seem to be working correctly...\n  if {$tzoffset_new==4 && $tzoffset_old==5} {\n    datetest 6.2 {datetime('2000-10-29 06:00:00','localtime')}\\\n        {2000-10-29 01:00:00}\n    datetest 6.2.1 {datetime('2006-10-29 06:00:00','localtime')}\\\n        {2006-10-29 01:00:00}\n  }\n  datetest 6.2.2 {datetime('2007-11-04 06:00:00','localtime')}\\\n      {2007-11-04 01:00:00}\n\n  # If the new and old DST rules seem to be working correctly...\n  if {$tzoffset_new==4 && $tzoffset_old==5} {\n    datetest 6.3 {datetime('2000-04-02 06:59:00','localtime')}\\\n        {2000-04-02 01:59:00}\n    datetest 6.3.1 {datetime('2006-04-02 06:59:00','localtime')}\\\n        {2006-04-02 01:59:00}\n  }\n  datetest 6.3.2 {datetime('2007-03-11 07:00:00','localtime')}\\\n      {2007-03-11 03:00:00}\n\n  datetest 6.4 {datetime('2000-04-02 07:00:00','localtime')}\\\n      {2000-04-02 03:00:00}\n  datetest 6.4.1 {datetime('2006-04-02 07:00:00','localtime')}\\\n      {2006-04-02 03:00:00}\n  datetest 6.4.2 {datetime('2007-03-11 07:00:00','localtime')}\\\n      {2007-03-11 03:00:00}\n      \n  datetest 6.5 {datetime('2000-10-29 01:59:00','utc')} {2000-10-29 05:59:00}\n  datetest 6.5.1 {datetime('2006-10-29 01:59:00','utc')} {2006-10-29 05:59:00}\n  datetest 6.5.2 {datetime('2007-11-04 01:59:00','utc')} {2007-11-04 05:59:00}\n\n  # If the new and old DST rules seem to be working correctly...\n  if {$tzoffset_new==4 && $tzoffset_old==5} {\n    datetest 6.6 {datetime('2000-10-29 02:00:00','utc')} {2000-10-29 07:00:00}\n    datetest 6.6.1 {datetime('2006-10-29 02:00:00','utc')} {2006-10-29 07:00:00}\n  }\n  datetest 6.6.2 {datetime('2007-11-04 02:00:00','utc')} {2007-11-04 07:00:00}\n\n  # If the new and old DST rules seem to be working correctly...\n  if {$tzoffset_new==4 && $tzoffset_old==5} {\n    datetest 6.7 {datetime('2000-04-02 01:59:00','utc')} {2000-04-02 06:59:00}\n    datetest 6.7.1 {datetime('2006-04-02 01:59:00','utc')} {2006-04-02 06:59:00}\n  }\n  datetest 6.7.2 {datetime('2007-03-11 01:59:00','utc')} {2007-03-11 06:59:00}\n\n  datetest 6.8 {datetime('2000-04-02 02:00:00','utc')} {2000-04-02 06:00:00}\n  datetest 6.8.1 {datetime('2006-04-02 02:00:00','utc')} {2006-04-02 06:00:00}\n  datetest 6.8.2 {datetime('2007-03-11 02:00:00','utc')} {2007-03-11 06:00:00}\n\n  # The 'utc' modifier is a no-op if the LHS is known to already be in UTC\n  datetest 6.9.1 {datetime('2015-12-23 12:00:00','utc')} {2015-12-23 17:00:00}\n  datetest 6.9.2 {datetime('2015-12-23 12:00:00z','utc')} {2015-12-23 12:00:00}\n  datetest 6.9.3 {datetime('2015-12-23 12:00:00-03:00','utc')} \\\n         {2015-12-23 15:00:00}\n  datetest 6.9.4 {datetime('2015-12-23 12:00:00','utc','utc','utc')} \\\n         {2015-12-23 17:00:00}\n\n\n  datetest 6.10 {datetime('2000-01-01 12:00:00','localtime')} \\\n      {2000-01-01 07:00:00}\n  datetest 6.11 {datetime('1969-01-01 12:00:00','localtime')} \\\n      {1969-01-01 07:00:00}\n  datetest 6.12 {datetime('2039-01-01 12:00:00','localtime')} \\\n      {2039-01-01 07:00:00}\n  datetest 6.13 {datetime('2000-07-01 12:00:00','localtime')} \\\n      {2000-07-01 08:00:00}\n  datetest 6.14 {datetime('1969-07-01 12:00:00','localtime')} \\\n      {1969-07-01 07:00:00}\n  datetest 6.15 {datetime('2039-07-01 12:00:00','localtime')} \\\n      {2039-07-01 07:00:00}\n  set sqlite_current_time \\\n     [db eval {SELECT strftime('%s','2000-07-01 12:34:56')}]\n  datetest 6.16 {datetime('now','localtime')} {2000-07-01 08:34:56}\n  datetest 6.17 {datetime('now','localtimex')} NULL\n  datetest 6.18 {datetime('now','localtim')} NULL\n  set sqlite_current_time 0\n}\n\n# These two are a bit of a scam. They are added to ensure that 100% of\n# the date.c file is covered by testing, even when the time-zone\n# is not -0400 (the condition for running of the block of tests above).\n#\ndatetest 6.19 {datetime('2039-07-01 12:00:00','localtime',null)} NULL\ndatetest 6.20 {datetime('2039-07-01 12:00:00','utc',null)} NULL\n\n# Date-time functions that contain NULL arguments return a NULL\n# result.\n#\ndatetest 7.1 {datetime(null)} NULL\ndatetest 7.2 {datetime('now',null)} NULL\ndatetest 7.3 {datetime('now','localtime',null)} NULL\ndatetest 7.4 {time(null)} NULL\ndatetest 7.5 {time('now',null)} NULL\ndatetest 7.6 {time('now','localtime',null)} NULL\ndatetest 7.7 {date(null)} NULL\ndatetest 7.8 {date('now',null)} NULL\ndatetest 7.9 {date('now','localtime',null)} NULL\ndatetest 7.10 {julianday(null)} NULL\ndatetest 7.11 {julianday('now',null)} NULL\ndatetest 7.12 {julianday('now','localtime',null)} NULL\ndatetest 7.13 {strftime(null,'now')} NULL\ndatetest 7.14 {strftime('%s',null)} NULL\ndatetest 7.15 {strftime('%s','now',null)} NULL\ndatetest 7.16 {strftime('%s','now','localtime',null)} NULL\n\n# Test modifiers when the date begins as a julian day number - to\n# make sure the HH:MM:SS is preserved.  Ticket #551.\n#\nset sqlite_current_time [db eval {SELECT strftime('%s','2003-10-22 12:34:00')}]\ndatetest 8.1 {datetime('now','weekday 0')} {2003-10-26 12:34:00}\ndatetest 8.2 {datetime('now','weekday 1')} {2003-10-27 12:34:00}\ndatetest 8.3 {datetime('now','weekday 2')} {2003-10-28 12:34:00}\ndatetest 8.4 {datetime('now','weekday 3')} {2003-10-22 12:34:00}\ndatetest 8.5 {datetime('now','start of month')} {2003-10-01 00:00:00}\ndatetest 8.6 {datetime('now','start of year')} {2003-01-01 00:00:00}\ndatetest 8.7 {datetime('now','start of day')} {2003-10-22 00:00:00}\ndatetest 8.8 {datetime('now','1 day')} {2003-10-23 12:34:00}\ndatetest 8.9 {datetime('now','+1 day')} {2003-10-23 12:34:00}\ndatetest 8.10 {datetime('now','+1.25 day')} {2003-10-23 18:34:00}\ndatetest 8.11 {datetime('now','-1.0 day')} {2003-10-21 12:34:00}\ndatetest 8.12 {datetime('now','1 month')} {2003-11-22 12:34:00}\ndatetest 8.13 {datetime('now','11 month')} {2004-09-22 12:34:00}\ndatetest 8.14 {datetime('now','-13 month')} {2002-09-22 12:34:00}\ndatetest 8.15 {datetime('now','1.5 months')} {2003-12-07 12:34:00}\ndatetest 8.16 {datetime('now','-5 years')} {1998-10-22 12:34:00}\ndatetest 8.17 {datetime('now','+10.5 minutes')} {2003-10-22 12:44:30}\ndatetest 8.18 {datetime('now','-1.25 hours')} {2003-10-22 11:19:00}\ndatetest 8.19 {datetime('now','11.25 seconds')} {2003-10-22 12:34:11}\ndatetest 8.90 {datetime('now','abcdefghijklmnopqrstuvwyxzABCDEFGHIJLMNOP')} NULL\nset sqlite_current_time 0\n\n# Negative years work.  Example:  '-4713-11-26' is JD 1.5.\n#\ndatetest 9.1 {julianday('-4713-11-24 12:00:00')} {0.0}\ndatetest 9.2 {julianday(datetime(5))} {5.0}\ndatetest 9.3 {julianday(datetime(10))} {10.0}\ndatetest 9.4 {julianday(datetime(100))} {100.0}\ndatetest 9.5 {julianday(datetime(1000))} {1000.0}\ndatetest 9.6 {julianday(datetime(10000))} {10000.0}\ndatetest 9.7 {julianday(datetime(100000))} {100000.0}\n\n# datetime() with just an HH:MM:SS correctly inserts the date 2000-01-01.\n#\ndatetest 10.1 {datetime('01:02:03')}  {2000-01-01 01:02:03}\ndatetest 10.2 {date('01:02:03')}  {2000-01-01}\ndatetest 10.3 {strftime('%Y-%m-%d %H:%M','01:02:03')} {2000-01-01 01:02}\n\n# Test the new HH:MM:SS modifier\n#\ndatetest 11.1 {datetime('2004-02-28 20:00:00', '-01:20:30')} \\\n   {2004-02-28 18:39:30}\ndatetest 11.2 {datetime('2004-02-28 20:00:00', '+12:30:00')} \\\n   {2004-02-29 08:30:00}\ndatetest 11.3 {datetime('2004-02-28 20:00:00', '+12:30')} \\\n   {2004-02-29 08:30:00}\ndatetest 11.4 {datetime('2004-02-28 20:00:00', '12:30')} \\\n   {2004-02-29 08:30:00}\ndatetest 11.5 {datetime('2004-02-28 20:00:00', '-12:00')} \\\n   {2004-02-28 08:00:00}\ndatetest 11.6 {datetime('2004-02-28 20:00:00', '-12:01')} \\\n   {2004-02-28 07:59:00}\ndatetest 11.7 {datetime('2004-02-28 20:00:00', '-11:59')} \\\n   {2004-02-28 08:01:00}\ndatetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \\\n   {2004-02-29 07:59:00}\ndatetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \\\n   {2004-02-29 08:01:00}\ndatetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL\n\n# Ticket #1964\ndatetest 12.1 {datetime('2005-09-01')} {2005-09-01 00:00:00}\ndatetest 12.2 {datetime('2005-09-01','+0 hours')} {2005-09-01 00:00:00}\n\n# Ticket #1991\ndo_test date-13.1 {\n  execsql {\n    SELECT strftime('%Y-%m-%d %H:%M:%f', julianday('2006-09-24T10:50:26.047'))\n  }\n} {{2006-09-24 10:50:26.047}}\n\n# Ticket #2153\ndatetest 13.2 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 12:34:59.6')} \\\n  {2007-01-01 12:34:59}\ndatetest 13.3 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:34:59.6')} \\\n  {2007-01-01 12:34:59.600}\ndatetest 13.4 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 12:59:59.6')} \\\n  {2007-01-01 12:59:59}\ndatetest 13.5 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 12:59:59.6')} \\\n  {2007-01-01 12:59:59.600}\ndatetest 13.6 {strftime('%Y-%m-%d %H:%M:%S', '2007-01-01 23:59:59.6')} \\\n  {2007-01-01 23:59:59}\ndatetest 13.7 {strftime('%Y-%m-%d %H:%M:%f', '2007-01-01 23:59:59.6')} \\\n  {2007-01-01 23:59:59.600}\n\n# Ticket #3618\ndatetest 13.11 {julianday(2454832.5,'-1 day')} {2454831.5}\ndatetest 13.12 {julianday(2454832.5,'+1 day')} {2454833.5}\ndatetest 13.13 {julianday(2454832.5,'-1.5 day')} {2454831.0}\ndatetest 13.14 {julianday(2454832.5,'+1.5 day')} {2454834.0}\ndatetest 13.15 {julianday(2454832.5,'-3 hours')} {2454832.375}\ndatetest 13.16 {julianday(2454832.5,'+3 hours')} {2454832.625}\ndatetest 13.17 {julianday(2454832.5,'-45 minutes')} {2454832.46875}\ndatetest 13.18 {julianday(2454832.5,'+45 minutes')} {2454832.53125}\ndatetest 13.19 {julianday(2454832.5,'-675 seconds')} {2454832.4921875}\ndatetest 13.20 {julianday(2454832.5,'+675 seconds')} {2454832.5078125}\ndatetest 13.21 {julianday(2454832.5,'-1.5 months')} {2454786.5}\ndatetest 13.22 {julianday(2454832.5,'+1.5 months')} {2454878.5}\ndatetest 13.23 {julianday(2454832.5,'-1.5 years')} {2454284.0}\ndatetest 13.24 {julianday(2454832.5,'+1.5 years')} {2455380.0}\n\ndatetest 13.30 {date('2000-01-01','+1.5 years')} {2001-07-02}\ndatetest 13.31 {date('2001-01-01','+1.5 years')} {2002-07-02}\ndatetest 13.32 {date('2002-01-01','+1.5 years')} {2003-07-02}\ndatetest 13.33 {date('2002-01-01','-1.5 years')} {2000-07-02}\ndatetest 13.34 {date('2001-01-01','-1.5 years')} {1999-07-02}\n\n# Test for issues reported by BareFeet (list.sql at tandb.com.au)\n# on mailing list on 2008-06-12.\n#\n# Put a floating point number in the database so that we can manipulate\n# raw bits using the hexio interface.\n#\nif {0==[sqlite3 -has-codec]} {\n  do_test date-14.1 {\n    execsql {\n      PRAGMA auto_vacuum=OFF;\n      PRAGMA page_size = 1024;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES(1.1);\n    }\n    db close\n    hexio_write test.db 2040 4142ba32bffffff9\n    sqlite3 db test.db\n    db eval {SELECT * FROM t1}\n  } {2454629.5}\n  \n  # Changing the least significant byte of the floating point value between\n  # 00 and FF should always generate a time of either 23:59:59 or 00:00:00,\n  # never 24:00:00\n  #\n  for {set i 0} {$i<=255} {incr i} {\n    db close\n    hexio_write test.db 2047 [format %02x $i]\n    sqlite3 db test.db\n    do_test date-14.2.$i {\n      set date [db one {SELECT datetime(x) FROM t1}]\n      expr {$date eq \"2008-06-12 00:00:00\" || $date eq \"2008-06-11 23:59:59\"}\n    } {1}\n  }\n}\n\n# Verify that multiple calls to date functions with 'now' return the\n# same answer.\n#\n# EVIDENCE-OF: R-34818-13664 The 'now' argument to date and time\n# functions always returns exactly the same value for multiple\n# invocations within the same sqlite3_step() call.\n#\nproc sleeper {} {after 100}\ndo_test date-15.1 {\n  db func sleeper sleeper\n  db eval {\n     SELECT c - a FROM (SELECT julianday('now') AS a,\n                               sleeper(), julianday('now') AS c);\n  }\n} {0.0}\ndo_test date-15.2 {\n  db eval {\n     SELECT a==b FROM (SELECT current_timestamp AS a,\n                               sleeper(), current_timestamp AS b);\n  }\n} {1}\n\n# Tests of extreme values in date/time functions.  Run with UBSan or the\n# equivalent to verify no signed interger overflow warnings.\n#\ndatetest 16.1 {date(147483649)} NULL\ndatetest 16.2 {datetime(0)} {-4713-11-24 12:00:00}\ndatetest 16.3 {datetime(5373484.49999999)} {9999-12-31 23:59:59}\ndatetest 16.4 {julianday('-4713-11-24 12:00:00')} 0.0\ndatetest 16.5 {julianday('9999-12-31 23:59:59.999')} 5373484.49999999\ndatetest 16.6 {datetime(0,'+464269060799 seconds')} {9999-12-31 23:59:59}\ndatetest 16.7 {datetime(0,'+464269060800 seconds')} NULL\ndatetest 16.8 {datetime(0,'+7737817679 minutes')} {9999-12-31 23:59:00}\ndatetest 16.9 {datetime(0,'+7737817680 minutes')} NULL\ndatetest 16.10 {datetime(0,'+128963627 hours')} {9999-12-31 23:00:00}\ndatetest 16.11 {datetime(0,'+128963628 hours')} NULL\ndatetest 16.12 {datetime(0,'+5373484 days')} {9999-12-31 12:00:00}\ndatetest 16.13 {datetime(0,'+5373485 days')} NULL\ndatetest 16.14 {datetime(0,'+176545 months')} {9999-12-24 12:00:00}\ndatetest 16.15 {datetime(0,'+176546 months')} NULL\ndatetest 16.16 {datetime(0,'+14712 years')} {9999-11-24 12:00:00}\ndatetest 16.17 {datetime(0,'+14713 years')} NULL\ndatetest 16.20 {datetime(5373484.4999999,'-464269060799 seconds')} \\\n                {-4713-11-24 12:00:00}\ndatetest 16.21 {datetime(5373484,'-464269060800 seconds')} NULL\ndatetest 16.22 {datetime(5373484.4999999,'-7737817679 minutes')} \\\n               {-4713-11-24 12:00:59}\ndatetest 16.23 {datetime(5373484,'-7737817680 minutes')} NULL\ndatetest 16.24 {datetime(5373484.4999999,'-128963627 hours')} \\\n               {-4713-11-24 12:59:59}\ndatetest 16.25 {datetime(5373484,'-128963628 hours')} NULL\ndatetest 16.26 {datetime(5373484,'-5373484 days')} {-4713-11-24 12:00:00}\ndatetest 16.27 {datetime(5373484,'-5373485 days')} NULL\ndatetest 16.28 {datetime(5373484,'-176545 months')} {-4713-12-01 12:00:00}\ndatetest 16.29 {datetime(5373484,'-176546 months')} NULL\ndatetest 16.30 {datetime(5373484,'-14712 years')} {-4713-12-31 12:00:00}\ndatetest 16.31 {datetime(5373484,'-14713 years')} NULL\n\n# 2017-03-02: Wrong 'start of day' computation.\n# https://www.sqlite.org/src/info/6097cb92745327a1\n#\ndatetest 17.1 {datetime(2457754, 'start of day')} {2016-12-31 00:00:00}\ndatetest 17.2 {datetime(2457828)} {2017-03-15 12:00:00}\ndatetest 17.3 {datetime(2457828,'start of day')} {2017-03-15 00:00:00}\ndatetest 17.4 {datetime(2457828,'start of month')} {2017-03-01 00:00:00}\ndatetest 17.5 {datetime(2457828,'start of year')} {2017-01-01 00:00:00}\ndatetest 17.6 {datetime(37,'start of year')} NULL\ndatetest 17.7 {datetime(38,'start of year')} {-4712-01-01 00:00:00}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/date2.test",
    "content": "# 2017-07-20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing date and time functions used in\n# check constraints and index expressions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Skip this whole file if date and time functions are omitted\n# at compile-time\n#\nifcapable {!datetime} {\n  finish_test\n  return\n}\n\ndo_execsql_test date2-100 {\n  CREATE TABLE t1(x, y, CHECK( date(x) BETWEEN '2017-07-01' AND '2017-07-31' ));\n  INSERT INTO t1(x,y) VALUES('2017-07-20','one');\n} {}\ndo_catchsql_test date2-110 {\n  INSERT INTO t1(x,y) VALUES('now','two');\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_execsql_test date2-120 {\n  SELECT * FROM t1;\n} {2017-07-20 one}\ndo_catchsql_test date2-130 {\n  INSERT INTO t1(x,y) VALUES('2017-08-01','two');\n} {1 {CHECK constraint failed: t1}}\n\ndo_execsql_test date2-200 {\n  CREATE TABLE t2(x,y);\n  INSERT INTO t2(x,y) VALUES(1, '2017-07-20'), (2, 'xyzzy');\n  CREATE INDEX t2y ON t2(date(y));\n}\ndo_catchsql_test date2-210 {\n  INSERT INTO t2(x,y) VALUES(3, 'now');\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_execsql_test date2-220 {\n  SELECT x, y FROM t2 ORDER BY x;\n} {1 2017-07-20 2 xyzzy}\n\ndo_execsql_test date2-300 {\n  CREATE TABLE t3(a INTEGER PRIMARY KEY,b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n    INSERT INTO t3(a,b) SELECT x, julianday('2017-07-01')+x FROM c;\n  UPDATE t3 SET b='now' WHERE a=500;\n}\ndo_catchsql_test date2-310 {\n  CREATE INDEX t3b1 ON t3(datetime(b));\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_catchsql_test date2-320 {\n  CREATE INDEX t3b1 ON t3(datetime(b)) WHERE typeof(b)='real';\n} {0 {}}\ndo_execsql_test date2-330 {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t3\n   WHERE typeof(b)='real'\n     AND datetime(b) BETWEEN '2017-07-04' AND '2017-07-08';\n} {/USING INDEX t3b/}\ndo_execsql_test date2-331 {\n  SELECT a FROM t3\n   WHERE typeof(b)='real'\n     AND datetime(b) BETWEEN '2017-07-04' AND '2017-07-08'\n  ORDER BY a;\n} {3 4 5 6}\n\ndo_execsql_test date2-400 {\n  CREATE TABLE t4(a INTEGER PRIMARY KEY,b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n    INSERT INTO t4(a,b) SELECT x, julianday('2017-07-01')+x FROM c;\n  UPDATE t4 SET b='now' WHERE a=500;\n}\ndo_catchsql_test date2-410 {\n  CREATE INDEX t4b1 ON t4(b)\n    WHERE date(b) BETWEEN '2017-06-01' AND '2017-08-31';\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_execsql_test date2-420 {\n  DELETE FROM t4 WHERE a=500;\n  CREATE INDEX t4b1 ON t4(b)\n    WHERE date(b) BETWEEN '2017-06-01' AND '2017-08-31';\n}\ndo_catchsql_test date2-430 {\n  INSERT INTO t4(a,b) VALUES(9999,'now');\n} {1 {non-deterministic function in index expression or CHECK constraint}}\n\ndo_execsql_test date2-500 {\n  CREATE TABLE mods(x);\n  INSERT INTO mods(x) VALUES\n    ('+10 days'),\n    ('-10 days'),\n    ('+10 hours'),\n    ('-10 hours'),\n    ('+10 minutes'),\n    ('-10 minutes'),\n    ('+10 seconds'),\n    ('-10 seconds'),\n    ('+10 months'),\n    ('-10 months'),\n    ('+10 years'),\n    ('-10 years'),\n    ('start of month'),\n    ('start of year'),\n    ('start of day'),\n    ('weekday 1'),\n    ('unixepoch');\n  CREATE TABLE t5(y,m);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)\n    INSERT INTO t5(y,m) SELECT julianday('2017-07-01')+c.x, mods.x FROM c, mods;\n  CREATE INDEX t5x1 on t5(y) WHERE datetime(y,m) IS NOT NULL;\n}\ndo_catchsql_test date2-510 {\n  INSERT INTO t5(y,m) VALUES('2017-07-20','localtime');\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_catchsql_test date2-520 {\n  INSERT INTO t5(y,m) VALUES('2017-07-20','utc');\n} {1 {non-deterministic function in index expression or CHECK constraint}}\n\n\n\n  \n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/dbfuzz.c",
    "content": "/*\n** 2016-12-17\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This program is designed for fuzz-testing SQLite database files.\n**\n** This program reads fuzzed database files from the disk files named\n** on the command-line.  Each database is loaded into an in-memory\n** filesystem so that the original database file is unmolested.\n**\n** The fuzzed database is then opened, and series of SQL statements\n** are run against the database to ensure that SQLite can safely handle\n** the fuzzed database.\n*/\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <ctype.h>\n#define ISSPACE(X) isspace((unsigned char)(X))\n#define ISDIGIT(X) isdigit((unsigned char)(X))\n#include \"sqlite3.h\"\n#ifdef __unix__\n# include <signal.h>\n# include <unistd.h>\n#endif\n\n/*\n** Print sketchy documentation for this utility program\n*/\nstatic void showHelp(const char *zArgv0){\n  printf(\"Usage: %s [options] DATABASE ...\\n\", zArgv0);\n  printf(\n\"Read databases into an in-memory filesystem.  Run test SQL as specified\\n\"\n\"by command-line arguments or from\\n\"\n\"\\n\"\n\"    SELECT group_concat(sql) FROM autoexec;\\n\"\n\"\\n\"\n\"Options:\\n\"\n\"  --help              Show this help text\\n\"\n\"  -q|--quiet          Reduced output\\n\"\n\"  --limit-mem N       Limit memory used by test SQLite instances to N bytes\\n\"\n\"  --limit-vdbe        Panic if any test runs for more than 100,000 cycles\\n\"\n\"  --no-lookaside      Disable the lookaside memory allocator\\n\"\n\"  --timeout N         Timeout after N seconds.\\n\"\n\"  --trace             Show the results of each SQL command\\n\"\n\"  -v|--verbose        Increased output.  Repeat for more output.\\n\"\n  );\n  exit(0);\n}\n\n/*\n** Print an error message and quit.\n*/\nstatic void fatalError(const char *zFormat, ...){\n  va_list ap;\n  va_start(ap, zFormat);\n  vfprintf(stderr, zFormat, ap);\n  va_end(ap);\n  fprintf(stderr, \"\\n\");\n  exit(1);\n}\n\n/*\n** Files in the virtual file system.\n*/\ntypedef struct VFile VFile;\ntypedef struct VHandle VHandle;\nstruct VFile {\n  char *zFilename;      /* Filename. NULL for delete-on-close. From malloc() */\n  int sz;               /* Size of the file in bytes */\n  int nRef;             /* Number of references to this file */\n  unsigned char *a;     /* Content of the file.  From malloc() */\n};\nstruct VHandle {\n  sqlite3_file base;    /* Base class.  Must be first */\n  VFile *pVFile;        /* The underlying file */\n};\n\n/*\n** Maximum number of files in the in-memory virtual filesystem.\n*/\n#define MX_FILE  10\n\n/*\n** Maximum allowed file size\n*/\n#define MX_FILE_SZ 1000000\n\n/*\n** All global variables are gathered into the \"g\" singleton.\n*/\nstatic struct GlobalVars {\n  VFile aFile[MX_FILE];            /* The virtual filesystem */\n} g;\n\n\n/*\n** Initialize the virtual file system.\n*/\nstatic void formatVfs(void){\n  int i;\n  for(i=0; i<MX_FILE; i++){\n    g.aFile[i].sz = -1;\n    g.aFile[i].zFilename = 0;\n    g.aFile[i].a = 0;\n    g.aFile[i].nRef = 0;\n  }\n}\n\n\n/*\n** Erase all information in the virtual file system.\n*/\nstatic void reformatVfs(void){\n  int i;\n  for(i=0; i<MX_FILE; i++){\n    if( g.aFile[i].sz<0 ) continue;\n    if( g.aFile[i].zFilename ){\n      free(g.aFile[i].zFilename);\n      g.aFile[i].zFilename = 0;\n    }\n    if( g.aFile[i].nRef>0 ){\n      fatalError(\"file %d still open.  nRef=%d\", i, g.aFile[i].nRef);\n    }\n    g.aFile[i].sz = -1;\n    free(g.aFile[i].a);\n    g.aFile[i].a = 0;\n    g.aFile[i].nRef = 0;\n  }\n}\n\n/*\n** Find a VFile by name\n*/\nstatic VFile *findVFile(const char *zName){\n  int i;\n  if( zName==0 ) return 0;\n  for(i=0; i<MX_FILE; i++){\n    if( g.aFile[i].zFilename==0 ) continue;   \n    if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i];\n  }\n  return 0;\n}\n\n/*\n** Find a VFile called zName.  Initialize it to the content of\n** disk file zDiskFile.\n**\n** Return NULL if the filesystem is full.\n*/\nstatic VFile *createVFile(const char *zName, const char *zDiskFile){\n  VFile *pNew = findVFile(zName);\n  int i;\n  FILE *in = 0;\n  long sz = 0;\n\n  if( pNew ) return pNew;\n  for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}\n  if( i>=MX_FILE ) return 0;\n  if( zDiskFile ){\n    in = fopen(zDiskFile, \"rb\");\n    if( in==0 ) fatalError(\"no such file: \\\"%s\\\"\", zDiskFile);\n    fseek(in, 0, SEEK_END);\n    sz = ftell(in);\n    rewind(in);\n  }\n  pNew = &g.aFile[i];\n  if( zName ){\n    int nName = (int)strlen(zName)+1;\n    pNew->zFilename = malloc(nName);\n    if( pNew->zFilename==0 ){\n      if( in ) fclose(in);\n      return 0;\n    }\n    memcpy(pNew->zFilename, zName, nName);\n  }else{\n    pNew->zFilename = 0;\n  }\n  pNew->nRef = 0;\n  pNew->sz = sz;\n  pNew->a = malloc(sz);\n  if( sz>0 ){\n    if( pNew->a==0 || fread(pNew->a, sz, 1, in)<1 ){\n      free(pNew->zFilename);\n      free(pNew->a);\n      pNew->a = 0;\n      pNew->zFilename = 0;\n      pNew->sz = -1;\n      pNew = 0;\n    }\n  }\n  if( in ) fclose(in);\n  return pNew;\n}\n\n/* Methods for the VHandle object\n*/\nstatic int inmemClose(sqlite3_file *pFile){\n  VHandle *p = (VHandle*)pFile;\n  VFile *pVFile = p->pVFile;\n  pVFile->nRef--;\n  if( pVFile->nRef==0 && pVFile->zFilename==0 ){\n    pVFile->sz = -1;\n    free(pVFile->a);\n    pVFile->a = 0;\n  }\n  return SQLITE_OK;\n}\nstatic int inmemRead(\n  sqlite3_file *pFile,   /* Read from this open file */\n  void *pData,           /* Store content in this buffer */\n  int iAmt,              /* Bytes of content */\n  sqlite3_int64 iOfst    /* Start reading here */\n){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( iOfst<0 || iOfst>=pVFile->sz ){\n    memset(pData, 0, iAmt);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  if( iOfst+iAmt>pVFile->sz ){\n    memset(pData, 0, iAmt);\n    iAmt = (int)(pVFile->sz - iOfst);\n    memcpy(pData, pVFile->a, iAmt);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  memcpy(pData, pVFile->a + iOfst, iAmt);\n  return SQLITE_OK;\n}\nstatic int inmemWrite(\n  sqlite3_file *pFile,   /* Write to this file */\n  const void *pData,     /* Content to write */\n  int iAmt,              /* bytes to write */\n  sqlite3_int64 iOfst    /* Start writing here */\n){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( iOfst+iAmt > pVFile->sz ){\n    unsigned char *aNew;\n    if( iOfst+iAmt >= MX_FILE_SZ ){\n      return SQLITE_FULL;\n    }\n    aNew = realloc(pVFile->a, (int)(iOfst+iAmt));\n    if( aNew==0 ){\n      return SQLITE_FULL;\n    }\n    pVFile->a = aNew;\n    if( iOfst > pVFile->sz ){\n      memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz));\n    }\n    pVFile->sz = (int)(iOfst + iAmt);\n  }\n  memcpy(pVFile->a + iOfst, pData, iAmt);\n  return SQLITE_OK;\n}\nstatic int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize;\n  return SQLITE_OK;\n}\nstatic int inmemSync(sqlite3_file *pFile, int flags){\n  return SQLITE_OK;\n}\nstatic int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){\n  *pSize = ((VHandle*)pFile)->pVFile->sz;\n  return SQLITE_OK;\n}\nstatic int inmemLock(sqlite3_file *pFile, int type){\n  return SQLITE_OK;\n}\nstatic int inmemUnlock(sqlite3_file *pFile, int type){\n  return SQLITE_OK;\n}\nstatic int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){\n  *pOut = 0;\n  return SQLITE_OK;\n}\nstatic int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){\n  return SQLITE_NOTFOUND;\n}\nstatic int inmemSectorSize(sqlite3_file *pFile){\n  return 512;\n}\nstatic int inmemDeviceCharacteristics(sqlite3_file *pFile){\n  return\n      SQLITE_IOCAP_SAFE_APPEND |\n      SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n      SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n}\n\n\n/* Method table for VHandle\n*/\nstatic sqlite3_io_methods VHandleMethods = {\n  /* iVersion    */  1,\n  /* xClose      */  inmemClose,\n  /* xRead       */  inmemRead,\n  /* xWrite      */  inmemWrite,\n  /* xTruncate   */  inmemTruncate,\n  /* xSync       */  inmemSync,\n  /* xFileSize   */  inmemFileSize,\n  /* xLock       */  inmemLock,\n  /* xUnlock     */  inmemUnlock,\n  /* xCheck...   */  inmemCheckReservedLock,\n  /* xFileCtrl   */  inmemFileControl,\n  /* xSectorSz   */  inmemSectorSize,\n  /* xDevchar    */  inmemDeviceCharacteristics,\n  /* xShmMap     */  0,\n  /* xShmLock    */  0,\n  /* xShmBarrier */  0,\n  /* xShmUnmap   */  0,\n  /* xFetch      */  0,\n  /* xUnfetch    */  0\n};\n\n/*\n** Open a new file in the inmem VFS.  All files are anonymous and are\n** delete-on-close.\n*/\nstatic int inmemOpen(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  sqlite3_file *pFile,\n  int openFlags,\n  int *pOutFlags\n){\n  VFile *pVFile = createVFile(zFilename, 0);\n  VHandle *pHandle = (VHandle*)pFile;\n  if( pVFile==0 ){\n    return SQLITE_FULL;\n  }\n  pHandle->pVFile = pVFile;\n  pVFile->nRef++;\n  pFile->pMethods = &VHandleMethods;\n  if( pOutFlags ) *pOutFlags = openFlags;\n  return SQLITE_OK;\n}\n\n/*\n** Delete a file by name\n*/\nstatic int inmemDelete(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int syncdir\n){\n  VFile *pVFile = findVFile(zFilename);\n  if( pVFile==0 ) return SQLITE_OK;\n  if( pVFile->nRef==0 ){\n    free(pVFile->zFilename);\n    pVFile->zFilename = 0;\n    pVFile->sz = -1;\n    free(pVFile->a);\n    pVFile->a = 0;\n    return SQLITE_OK;\n  }\n  return SQLITE_IOERR_DELETE;\n}\n\n/* Check for the existance of a file\n*/\nstatic int inmemAccess(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int flags,\n  int *pResOut\n){\n  VFile *pVFile = findVFile(zFilename);\n  *pResOut =  pVFile!=0;\n  return SQLITE_OK;\n}\n\n/* Get the canonical pathname for a file\n*/\nstatic int inmemFullPathname(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int nOut,\n  char *zOut\n){\n  sqlite3_snprintf(nOut, zOut, \"%s\", zFilename);\n  return SQLITE_OK;\n}\n\n/*\n** Register the VFS that reads from the g.aFile[] set of files.\n*/\nstatic void inmemVfsRegister(void){\n  static sqlite3_vfs inmemVfs;\n  sqlite3_vfs *pDefault = sqlite3_vfs_find(0);\n  inmemVfs.iVersion = 3;\n  inmemVfs.szOsFile = sizeof(VHandle);\n  inmemVfs.mxPathname = 200;\n  inmemVfs.zName = \"inmem\";\n  inmemVfs.xOpen = inmemOpen;\n  inmemVfs.xDelete = inmemDelete;\n  inmemVfs.xAccess = inmemAccess;\n  inmemVfs.xFullPathname = inmemFullPathname;\n  inmemVfs.xRandomness = pDefault->xRandomness;\n  inmemVfs.xSleep = pDefault->xSleep;\n  inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;\n  sqlite3_vfs_register(&inmemVfs, 0);\n};\n\n/*\n** Timeout handler\n*/\n#ifdef __unix__\nstatic void timeoutHandler(int NotUsed){\n  (void)NotUsed;\n  fatalError(\"timeout\\n\");\n}\n#endif\n\n/*\n** Set the an alarm to go off after N seconds.  Disable the alarm\n** if N==0\n*/\nstatic void setAlarm(int N){\n#ifdef __unix__\n  alarm(N);\n#else\n  (void)N;\n#endif\n}\n/***************************************************************************\n** String accumulator object\n*/\ntypedef struct Str Str;\nstruct Str {\n  char *z;                /* The string.  Memory from malloc() */\n  sqlite3_uint64 n;       /* Bytes of input used */\n  sqlite3_uint64 nAlloc;  /* Bytes allocated to z[] */\n  int oomErr;             /* OOM error has been seen */\n};\n\n/* Initialize a Str object */\nstatic void StrInit(Str *p){\n  memset(p, 0, sizeof(*p));\n}\n\n/* Append text to the end of a Str object */\nstatic void StrAppend(Str *p, const char *z){\n  sqlite3_uint64 n = strlen(z);\n  if( p->n + n >= p->nAlloc ){\n    char *zNew;\n    sqlite3_uint64 nNew;\n    if( p->oomErr ) return;\n    nNew = p->nAlloc*2 + 100 + n;\n    zNew = sqlite3_realloc64(p->z, nNew);\n    if( zNew==0 ){\n      sqlite3_free(p->z);\n      memset(p, 0, sizeof(*p));\n      p->oomErr = 1;\n      return;\n    }\n    p->z = zNew;\n    p->nAlloc = nNew;\n  }\n  memcpy(p->z + p->n, z, (int)n);\n  p->n += n;\n  p->z[p->n] = 0;\n}\n\n/* Return the current string content */\nstatic char *StrStr(Str *p){\n return p->z;\n}\n\n/* Free the string */\nstatic void StrFree(Str *p){\n  sqlite3_free(p->z);\n  StrInit(p);\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic int integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( ISDIGIT(zArg[0]) ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  if( v>0x7fffffff ) fatalError(\"parameter too large - max 2147483648\");\n  return (int)(isNeg? -v : v);\n}\n\n/*\n** This callback is invoked by sqlite3_log().\n*/\nstatic void sqlLog(void *pNotUsed, int iErrCode, const char *zMsg){\n  printf(\"LOG: (%d) %s\\n\", iErrCode, zMsg);\n  fflush(stdout);\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This an SQL progress handler.  After an SQL statement has run for\n** many steps, we want to interrupt it.  This guards against infinite\n** loops from recursive common table expressions.\n**\n** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used.\n** In that case, hitting the progress handler is a fatal error.\n*/\nstatic int progressHandler(void *pVdbeLimitFlag){\n  if( *(int*)pVdbeLimitFlag ) fatalError(\"too many VDBE cycles\");\n  return 1;\n}\n#endif\n\n/*\n** Allowed values for the runFlags parameter to runSql()\n*/\n#define SQL_TRACE  0x0001     /* Print each SQL statement as it is prepared */\n#define SQL_OUTPUT 0x0002     /* Show the SQL output */\n\n/*\n** Run multiple commands of SQL.  Similar to sqlite3_exec(), but does not\n** stop if an error is encountered.\n*/\nstatic void runSql(sqlite3 *db, const char *zSql, unsigned  runFlags){\n  const char *zMore;\n  const char *zEnd = &zSql[strlen(zSql)];\n  sqlite3_stmt *pStmt;\n\n  while( zSql && zSql[0] ){\n    zMore = 0;\n    pStmt = 0;\n    sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);\n    assert( zMore<=zEnd );\n    if( zMore==zSql ) break;\n    if( runFlags & SQL_TRACE ){\n      const char *z = zSql;\n      int n;\n      while( z<zMore && ISSPACE(z[0]) ) z++;\n      n = (int)(zMore - z);\n      while( n>0 && ISSPACE(z[n-1]) ) n--;\n      if( n==0 ) break;\n      if( pStmt==0 ){\n        printf(\"TRACE: %.*s (error: %s)\\n\", n, z, sqlite3_errmsg(db));\n      }else{\n        printf(\"TRACE: %.*s\\n\", n, z);\n      }\n    }\n    zSql = zMore;\n    if( pStmt ){\n      if( (runFlags & SQL_OUTPUT)==0 ){\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){}\n      }else{\n        int nCol = -1;\n        int nRow;\n        for(nRow=0; SQLITE_ROW==sqlite3_step(pStmt); nRow++){\n          int i;\n          if( nCol<0 ){\n            nCol = sqlite3_column_count(pStmt);\n          }\n          for(i=0; i<nCol; i++){\n            int eType = sqlite3_column_type(pStmt,i);\n            printf(\"ROW[%d].%s = \", nRow, sqlite3_column_name(pStmt,i));\n            switch( eType ){\n              case SQLITE_NULL: {\n                printf(\"NULL\\n\");\n                break;\n              }\n              case SQLITE_INTEGER: {\n                printf(\"INT %s\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_FLOAT: {\n                printf(\"FLOAT %s\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_TEXT: {\n                printf(\"TEXT [%s]\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_BLOB: {\n                printf(\"BLOB (%d bytes)\\n\", sqlite3_column_bytes(pStmt,i));\n                break;\n              }\n            }\n          }\n        }\n      }         \n      sqlite3_finalize(pStmt);\n    }\n  }\n}\n\nint main(int argc, char **argv){\n  int i;                 /* Loop counter */\n  int nDb = 0;           /* Number of databases to fuzz */\n  char **azDb = 0;       /* Names of the databases (limit: 20) */\n  int verboseFlag = 0;   /* True for extra output */\n  int noLookaside = 0;   /* Disable lookaside if true */\n  int vdbeLimitFlag = 0; /* Stop after 100,000 VDBE ops */\n  int nHeap = 0;         /* True for fixed heap size */\n  int iTimeout = 0;      /* Timeout delay in seconds */\n  int rc;                /* Result code from SQLite3 API calls */\n  sqlite3 *db;           /* The database connection */\n  sqlite3_stmt *pStmt;   /* A single SQL statement */\n  Str sql;               /* SQL to run */\n  unsigned runFlags = 0; /* Flags passed to runSql */\n\n  for(i=1; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ){\n      azDb = realloc(azDb, sizeof(azDb[0])*(nDb+1));\n      if( azDb==0 ) fatalError(\"out of memory\");\n      azDb[nDb++] = z;\n      continue;\n    }\n    z++;\n    if( z[0]=='-' ) z++;\n    if( strcmp(z, \"help\")==0 ){\n      showHelp(argv[0]);\n    }else if( strcmp(z, \"limit-mem\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument to %s\", argv[i]);\n      nHeap = integerValue(argv[++i]);\n    }else if( strcmp(z, \"no-lookaside\")==0 ){\n      noLookaside = 1;\n    }else if( strcmp(z, \"timeout\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument to %s\", argv[i]);\n      iTimeout = integerValue(argv[++i]);\n    }else if( strcmp(z, \"trace\")==0 ){\n      runFlags |= SQL_OUTPUT|SQL_TRACE;\n    }else if( strcmp(z, \"limit-vdbe\")==0 ){\n      vdbeLimitFlag = 1;\n    }else if( strcmp(z, \"v\")==0 || strcmp(z, \"verbose\")==0 ){\n      verboseFlag = 1;\n      runFlags |= SQL_TRACE;\n    }else{\n      fatalError(\"unknown command-line option: \\\"%s\\\"\\n\", argv[i]);\n    }\n  }\n  if( nDb==0 ){\n    showHelp(argv[0]);\n  }\n  if( verboseFlag ){\n    sqlite3_config(SQLITE_CONFIG_LOG, sqlLog);\n  }\n  if( nHeap>0 ){\n    void *pHeap = malloc( nHeap );\n    if( pHeap==0 ) fatalError(\"cannot allocate %d-byte heap\\n\", nHeap);\n    rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, 32);\n    if( rc ) fatalError(\"heap configuration failed: %d\\n\", rc);\n  }\n  if( noLookaside ){\n    sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);\n  }\n  inmemVfsRegister();\n  formatVfs();\n  StrInit(&sql);\n#ifdef __unix__\n  signal(SIGALRM, timeoutHandler);\n#endif\n  for(i=0; i<nDb; i++){\n    if( verboseFlag && nDb>1 ){\n      printf(\"DATABASE-FILE: %s\\n\", azDb[i]);\n      fflush(stdout);\n    }\n    if( iTimeout ) setAlarm(iTimeout);\n    createVFile(\"test.db\", azDb[i]);\n    rc = sqlite3_open_v2(\"test.db\", &db, SQLITE_OPEN_READWRITE, \"inmem\");\n    if( rc ){\n      printf(\"cannot open test.db for \\\"%s\\\"\\n\", azDb[i]);\n      reformatVfs();\n      continue;\n    }\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n    if( vdbeLimitFlag ){\n      sqlite3_progress_handler(db, 100000, progressHandler, &vdbeLimitFlag);\n    }\n#endif\n    rc = sqlite3_prepare_v2(db, \"SELECT sql FROM autoexec\", -1, &pStmt, 0);\n    if( rc==SQLITE_OK ){\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        StrAppend(&sql, (const char*)sqlite3_column_text(pStmt, 0));\n        StrAppend(&sql, \"\\n\");\n      }\n    }\n    sqlite3_finalize(pStmt);\n    StrAppend(&sql, \"PRAGMA integrity_check;\\n\");\n    runSql(db, StrStr(&sql), runFlags);\n    sqlite3_close(db);\n    reformatVfs();\n    StrFree(&sql);\n    if( sqlite3_memory_used()>0 ){\n      free(azDb);\n      reformatVfs();\n      fatalError(\"memory leak of %lld bytes\", sqlite3_memory_used());\n    }\n  }\n  StrFree(&sql);\n  reformatVfs();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/dbpage.test",
    "content": "# 2017-10-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite_dbpage virtual table.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix dbpage\n\nifcapable !vtab||!compound {\n  finish_test\n  return\n}\n\ndo_test 100 {\n  execsql {\n    PRAGMA auto_vacuum=0;\n    PRAGMA page_size=4096;\n    PRAGMA journal_mode=WAL;\n  }\n  execsql { \n    CREATE TABLE t1(a,b);\n    WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n      INSERT INTO t1(a,b) SELECT x, printf('%d-x%.*c',x,x,'x') FROM c;\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_execsql_test 110 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('main') ORDER BY pgno;\n} {1 X'53514C6974' 2 X'0500000001' 3 X'0D0000004E' 4 X'0D00000016'}\ndo_execsql_test 120 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=2;\n} {2 X'0500000001'}\ndo_execsql_test 130 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=4;\n} {4 X'0D00000016'}\ndo_execsql_test 140 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=5;\n} {}\ndo_execsql_test 150 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage WHERE pgno=0;\n} {}\n\ndo_execsql_test 200 {\n  CREATE TEMP TABLE saved_content(x);\n  INSERT INTO saved_content(x) SELECT data FROM sqlite_dbpage WHERE pgno=4;\n  UPDATE sqlite_dbpage SET data=zeroblob(4096) WHERE pgno=4;\n} {}\ndo_catchsql_test 210 {\n  PRAGMA integrity_check;\n} {1 {database disk image is malformed}}\ndo_execsql_test 220 {\n  SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('main') ORDER BY pgno;\n} {1 X'53514C6974' 2 X'0500000001' 3 X'0D0000004E' 4 X'0000000000'}\ndo_execsql_test 230 {\n  UPDATE sqlite_dbpage SET data=(SELECT x FROM saved_content) WHERE pgno=4;\n} {}\ndo_catchsql_test 230 {\n  PRAGMA integrity_check;\n} {0 ok}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/dbstatus.test",
    "content": "# 2010 March 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the sqlite3_db_status() function\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix dbstatus\n\nifcapable !compound {\n  finish_test\n  return\n}\n\n# Memory statistics must be enabled for this test.\ndb close\nsqlite3_shutdown\nsqlite3_config_memstatus 1\nsqlite3_config_uri 1\nsqlite3_initialize\nsqlite3 db test.db\n\n\n# Make sure sqlite3_db_config() and sqlite3_db_status are working.\n#\nunset -nocomplain PAGESZ\nunset -nocomplain BASESZ\ndo_test dbstatus-1.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    CREATE TABLE t1(x);\n  }\n  set sz1 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1]\n  db eval {\n    CREATE TABLE t2(y);\n  }\n  set sz2 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1]\n  set ::PAGESZ [expr {$sz2-$sz1}]\n  set ::BASESZ [expr {$sz1-$::PAGESZ}]\n  expr {$::PAGESZ>1024 && $::PAGESZ<1300}\n} {1}\ndo_test dbstatus-1.2 {\n  db eval {\n    INSERT INTO t1 VALUES(zeroblob(9000));\n  }\n  lindex [sqlite3_db_status db SQLITE_DBSTATUS_CACHE_USED 0] 1\n} [expr {$BASESZ + 10*$PAGESZ}]\n\n\nproc lookaside {db} {\n  expr { $::lookaside_buffer_size *\n    [lindex [sqlite3_db_status $db SQLITE_DBSTATUS_LOOKASIDE_USED 0] 1]\n  }\n}\n\nifcapable stat4||stat3 {\n  set STAT3 1\n} else {\n  set STAT3 0\n}\n\n#---------------------------------------------------------------------------\n# Run the dbstatus-2 and dbstatus-3 tests with several of different\n# lookaside buffer sizes.\n#\nforeach ::lookaside_buffer_size {0 64 120} {\n  ifcapable malloc_usable_size break\n\n  # Do not run any of these tests if there is SQL configured to run\n  # as part of the [sqlite3] command. This prevents the script from\n  # configuring the size of the lookaside buffer after [sqlite3] has\n  # returned.\n  if {[presql] != \"\"} break\n\n  #-------------------------------------------------------------------------\n  # Tests for SQLITE_DBSTATUS_SCHEMA_USED.\n  #\n  # Each test in the following block works as follows. Each test uses a\n  # different database schema.\n  #\n  #   1. Open a connection to an empty database. Disable statement caching.\n  #\n  #   2. Execute the SQL to create the database schema. Measure the total \n  #      heap and lookaside memory allocated by SQLite, and the memory \n  #      allocated for the database schema according to sqlite3_db_status().\n  #\n  #   3. Drop all tables in the database schema. Measure the total memory \n  #      and the schema memory again.\n  #\n  #   4. Repeat step 2.\n  #\n  #   5. Repeat step 3.\n  #\n  # Then test that:\n  #\n  #   a) The difference in schema memory quantities in steps 2 and 3 is the\n  #      same as the difference in total memory in steps 2 and 3.\n  #\n  #   b) Step 4 reports the same amount of schema and total memory used as\n  #      in step 2.\n  #\n  #   c) Step 5 reports the same amount of schema and total memory used as\n  #      in step 3.\n  #\n  foreach {tn schema} { \n    1 { CREATE TABLE t1(a, b) }\n    2 { CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1, c UNIQUE) }\n    3 {\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n    }\n    4 {\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(c, d);\n      CREATE TRIGGER AFTER INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(new.a, new.b);\n        SELECT * FROM t1, t2 WHERE a=c AND b=d GROUP BY b HAVING a>5 ORDER BY a;\n      END;\n    }\n    5 {\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(c, d);\n      CREATE VIEW v1 AS SELECT * FROM t1 UNION SELECT * FROM t2;\n    }\n    6k {\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a);\n      CREATE INDEX i2 ON t1(a,b);\n      CREATE INDEX i3 ON t1(b,b);\n      INSERT INTO t1 VALUES(randomblob(20), randomblob(25));\n      INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;\n      INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;\n      INSERT INTO t1 SELECT randomblob(20), randomblob(25) FROM t1;\n      ANALYZE;\n    }\n    7 {\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(c, d);\n      CREATE VIEW v1 AS \n        SELECT * FROM t1 \n        UNION \n        SELECT * FROM t2\n        UNION ALL\n        SELECT c||b, d||a FROM t2 LEFT OUTER JOIN t1 GROUP BY c, d\n        ORDER BY 1, 2\n      ;\n      CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN\n        SELECT * FROM v1;\n        UPDATE t1 SET a=5, b=(SELECT c FROM t2);\n      END;\n      SELECT * FROM v1;\n    }\n    8x {\n      CREATE TABLE t1(a, b, UNIQUE(a, b));\n      CREATE VIRTUAL TABLE t2 USING echo(t1);\n    }\n  } {\n    set tn \"$::lookaside_buffer_size-$tn\"\n  \n    # Step 1.\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500\n    db cache size 0\n\n    catch { register_echo_module db }\n    ifcapable !vtab { if {[string match *x $tn]} continue }\n  \n    # Step 2.\n    execsql $schema\n    set nAlloc1  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc1 [lookaside db]\n    set nSchema1 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]\n  \n    # Step 3.\n    drop_all_tables\n    set nAlloc2  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc2 [lookaside db]\n    set nSchema2 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]\n  \n    # Step 4.\n    execsql $schema\n    set nAlloc3  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc3 [lookaside db]\n    set nSchema3 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]\n    \n    # Step 5.\n    drop_all_tables\n    set nAlloc4  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc4 [lookaside db]\n    set nSchema4 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_SCHEMA_USED 0] 1]\n    set nFree [expr {$nAlloc1-$nAlloc2}]\n    \n    # Tests for which the test name ends in an \"k\" report slightly less\n    # memory than is actually freed when all schema items are finalized.\n    # This is because memory allocated by KeyInfo objects is no longer\n    # counted as \"schema memory\".\n    #\n    # Tests for which the test name ends in an \"x\" report slightly less\n    # memory than is actually freed when all schema items are finalized.\n    # This is because memory allocated by virtual table implementations\n    # for any reason is not counted as \"schema memory\".\n    #\n    # Additionally, in auto-vacuum mode, dropping tables and indexes causes\n    # the page-cache to shrink. So the amount of memory freed is always\n    # much greater than just that reported by DBSTATUS_SCHEMA_USED in this\n    # case.\n    #\n    # Some of the memory used for sqlite_stat4 is unaccounted for by\n    # dbstatus.\n    #\n    # Finally, on osx the estimate of memory used by the schema may be\n    # slightly low. \n    #\n    if {[string match *k $tn]\n         || [string match *x $tn] || $AUTOVACUUM\n         || ([string match *y $tn] && $STAT3)\n         || ($::tcl_platform(os) == \"Darwin\")\n    } {\n      do_test dbstatus-2.$tn.ax { expr {($nSchema1-$nSchema2)<=$nFree} } 1\n    } else {\n      do_test dbstatus-2.$tn.a { expr {$nSchema1-$nSchema2} } $nFree\n    }\n  \n    do_test dbstatus-2.$tn.b { list $nAlloc1 $nSchema1 } \"$nAlloc3 $nSchema3\"\n    do_test dbstatus-2.$tn.c { list $nAlloc2 $nSchema2 } \"$nAlloc4 $nSchema4\"\n  }\n  \n  #-------------------------------------------------------------------------\n  # Tests for SQLITE_DBSTATUS_STMT_USED.\n  #\n  # Each test in the following block works as follows. Each test uses a\n  # different database schema.\n  #\n  #   1. Open a connection to an empty database. Initialized the database\n  #      schema.\n  #\n  #   2. Prepare a bunch of SQL statements. Measure the total heap and \n  #      lookaside memory allocated by SQLite, and the memory allocated \n  #      for the prepared statements according to sqlite3_db_status().\n  #\n  #   3. Finalize all prepared statements. Measure the total memory \n  #      and the prepared statement memory again.\n  #\n  #   4. Repeat step 2.\n  #\n  #   5. Repeat step 3.\n  #\n  # Then test that:\n  #\n  #   a) The difference in schema memory quantities in steps 2 and 3 is the\n  #      same as the difference in total memory in steps 2 and 3.\n  #\n  #   b) Step 4 reports the same amount of schema and total memory used as\n  #      in step 2.\n  #\n  #   c) Step 5 reports the same amount of schema and total memory used as\n  #      in step 3.\n  #\n  foreach {tn schema statements} { \n    1 { CREATE TABLE t1(a, b) } {\n      SELECT * FROM t1;\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 SELECT * FROM t1;\n      UPDATE t1 SET a=5;\n      DELETE FROM t1;\n    }\n    2 {\n      PRAGMA recursive_triggers = 1;\n      CREATE TABLE t1(a, b);\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN\n        INSERT INTO t1 VALUES(new.a-1, new.b);\n      END;\n    } {\n      INSERT INTO t1 VALUES(5, 'x');\n    } \n    3 {\n      PRAGMA recursive_triggers = 1;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN\n        INSERT INTO t2 VALUES(new.a-1, new.b);\n      END;\n      CREATE TRIGGER tr2 AFTER INSERT ON t1 WHEN (new.a>0) BEGIN\n        INSERT INTO t1 VALUES(new.a-1, new.b);\n      END;\n    } {\n      INSERT INTO t1 VALUES(10, 'x');\n    } \n    4 {\n      CREATE TABLE t1(a, b);\n    } {\n      SELECT count(*) FROM t1 WHERE upper(a)='ABC';\n    }\n    5x {\n      CREATE TABLE t1(a, b UNIQUE);\n      CREATE VIRTUAL TABLE t2 USING echo(t1);\n    } {\n      SELECT count(*) FROM t2;\n      SELECT * FROM t2 WHERE b>5;\n      SELECT * FROM t2 WHERE b='abcdefg';\n    }\n  } {\n    set tn \"$::lookaside_buffer_size-$tn\"\n\n    # Step 1.\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500\n    db cache size 1000\n\n    catch { register_echo_module db }\n    ifcapable !vtab { if {[string match *x $tn]} continue }\n  \n    execsql $schema\n    db cache flush\n  \n    # Step 2.\n    execsql $statements\n    set nAlloc1  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc1 [lookaside db]\n    set nStmt1   [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]\n    execsql $statements\n  \n    # Step 3.\n    db cache flush\n    set nAlloc2  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc2 [lookaside db]\n    set nStmt2   [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]\n    \n    # Step 3.\n    execsql $statements\n    set nAlloc3  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc3 [lookaside db]\n    set nStmt3   [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]\n    execsql $statements\n  \n    # Step 4.\n    db cache flush\n    set nAlloc4  [lindex [sqlite3_status SQLITE_STATUS_MEMORY_USED 0] 1]\n    incr nAlloc4 [lookaside db]\n    set nStmt4 [lindex [sqlite3_db_status db SQLITE_DBSTATUS_STMT_USED 0] 1]\n  \n    set nFree [expr {$nAlloc1-$nAlloc2}]\n\n    do_test dbstatus-3.$tn.a { expr $nStmt2 } {0}\n\n    # Tests for which the test name ends in an \"x\" report slightly less\n    # memory than is actually freed when all statements are finalized.\n    # This is because a small amount of memory allocated by a virtual table\n    # implementation using sqlite3_mprintf() is technically considered\n    # external and so is not counted as \"statement memory\".\n    #\n#puts \"$nStmt1 $nFree\"\n    if {[string match *x $tn]} {\n      do_test dbstatus-3.$tn.bx { expr $nStmt1<=$nFree }  {1}\n    } else {\n      do_test dbstatus-3.$tn.b { expr $nStmt1==$nFree } {1}\n    }\n\n    do_test dbstatus-3.$tn.c { list $nAlloc1 $nStmt1 } [list $nAlloc3 $nStmt3]\n    do_test dbstatus-3.$tn.d { list $nAlloc2 $nStmt2 } [list $nAlloc4 $nStmt4]\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following tests focus on DBSTATUS_CACHE_USED_SHARED\n#\nifcapable shared_cache {\n  if {[permutation]==\"memsys3\"\n      || [permutation]==\"memsys5\"\n      || $::tcl_platform(os)==\"Linux\"} {\n    proc do_cacheused_test {tn db res} {\n      set cu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED 0]\n      set pcu [sqlite3_db_status $db SQLITE_DBSTATUS_CACHE_USED_SHARED 0]\n      set cu [lindex $cu 1]\n      set pcu [lindex $pcu 1]\n      uplevel [list do_test $tn [list list $cu $pcu] \"#/$res/\"]\n    }\n    reset_db\n    sqlite3 db file:test.db?cache=shared\n  \n    do_execsql_test 4.0 {\n      PRAGMA auto_vacuum=NONE;\n      CREATE TABLE t1(a, b, c);\n      INSERT INTO t1 VALUES(1, 2, 3);\n    }\n    do_cacheused_test 4.0.1 db { 4568 4568 }\n    do_execsql_test 4.1 {\n      CREATE TEMP TABLE tt(a, b, c);\n      INSERT INTO tt VALUES(1, 2, 3);\n    }\n    do_cacheused_test 4.1.1 db { 9000 9000 }\n  \n    sqlite3 db2 file:test.db?cache=shared\n    do_cacheused_test 4.2.1 db2 { 4568 2284 }\n    do_cacheused_test 4.2.2 db { 9000 6716 }\n    db close\n    do_cacheused_test 4.2.3 db2 { 4568 4568 }\n    sqlite3 db file:test.db?cache=shared\n    do_cacheused_test 4.2.4 db2 { 4568 2284 }\n    db2 close\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/dbstatus2.test",
    "content": "# 2011 September 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the sqlite3_db_status() function\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix dbstatus2\n\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 1024;\n  PRAGMA auto_vacuum = 0;\n\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  INSERT INTO t1 VALUES(1, randomblob(600));\n  INSERT INTO t1 VALUES(2, randomblob(600));\n  INSERT INTO t1 VALUES(3, randomblob(600));\n}\n\nproc db_hit_miss {db {reset 0}} {\n  set nHit  [sqlite3_db_status $db CACHE_HIT $reset]\n  set nMiss [sqlite3_db_status $db CACHE_MISS $reset]\n  list $nHit $nMiss\n}\n\nproc db_write {db {reset 0}} {\n  sqlite3_db_status $db CACHE_WRITE $reset\n}\n\ndo_test 1.1 {\n  db close\n  sqlite3 db test.db\n  execsql { PRAGMA mmap_size = 0 }\n  expr {[file size test.db] / 1024}\n} 6\n\ndo_test 1.2 {\n  execsql { SELECT b FROM t1 WHERE a=2 }\n  db_hit_miss db\n} {{0 2 0} {0 4 0}}\n\ndo_test 1.3 { \n  execsql { SELECT b FROM t1 WHERE a=2 }\n  db_hit_miss db\n} {{0 6 0} {0 4 0}}\n\ndo_test 1.4 { \n  execsql { SELECT b FROM t1 WHERE a=2 }\n  db_hit_miss db\n} {{0 10 0} {0 4 0}}\n\ndo_test 1.5 { \n  db_hit_miss db 1\n} {{0 10 0} {0 4 0}}\n\ndo_test 1.6 { \n  db_hit_miss db 0\n} {{0 0 0} {0 0 0}}\n\ndo_test 1.7 {\n  set fd [db incrblob main t1 b 1]\n  fconfigure $fd -translation binary\n  set len [string length [read $fd]]\n  close $fd\n  set len\n} 600\ndo_test 1.8 { sqlite3_db_status db CACHE_HIT  0 } {0 2 0}\ndo_test 1.9 { sqlite3_db_status db CACHE_MISS 0 } {0 1 0}\n\ndo_test 2.1 { db_write db } {0 0 0}\ndo_test 2.2 { \n  execsql { INSERT INTO t1 VALUES(4, randomblob(600)) }\n  db_write db\n} {0 4 0}\ndo_test 2.3 { db_write db 1 } {0 4 0}\ndo_test 2.4 { db_write db 0 } {0 0 0}\ndo_test 2.5 { db_write db 1 } {0 0 0}\n\nif {[wal_is_capable]} {\n  do_test 2.6 { \n    execsql { PRAGMA journal_mode = WAL }\n    db_write db 1\n  } {0 1 0}\n}\ndo_test 2.7 { \n  execsql { INSERT INTO t1 VALUES(5, randomblob(600)) }\n  db_write db\n} {0 4 0}\ndo_test 2.8 { db_write db 1 } {0 4 0}\ndo_test 2.9 { db_write db 0 } {0 0 0}\n \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/default.test",
    "content": "# 2005 August 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing corner cases of the DEFAULT syntax\n# on table definitions.\n#\n# $Id: default.test,v 1.3 2009/02/19 14:39:25 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable bloblit {\n  do_test default-1.1 {\n    execsql {\n      CREATE TABLE t1(\n        a INTEGER,\n        b BLOB DEFAULT x'6869'\n      );\n      INSERT INTO t1(a) VALUES(1);\n      SELECT * from t1;\n    }\n  } {1 hi}\n}\ndo_test default-1.2 {\n  execsql {\n    CREATE TABLE t2(\n      x INTEGER,\n      y INTEGER DEFAULT NULL\n    );\n    INSERT INTO t2(x) VALUES(1);\n    SELECT * FROM t2;\n  }\n} {1 {}}\ndo_test default-1.3 {\n  catchsql {\n    CREATE TABLE t3(\n      x INTEGER,\n      y INTEGER DEFAULT (max(x,5))\n    )\n  }\n} {1 {default value of column [y] is not constant}}\n\nifcapable pragma {\n  do_test default-2.1 {\n    execsql {\n      CREATE TABLE t4(c DEFAULT 'abc');\n      PRAGMA table_info(t4);\n    }\n  } {0 c {} 0 'abc' 0}\n  do_test default-2.2 {\n    execsql {\n      INSERT INTO t4 DEFAULT VALUES;\n      PRAGMA table_info(t4);\n    }\n  } {0 c {} 0 'abc' 0}\n}\n\ndo_execsql_test default-3.1 {\n  CREATE TABLE t3(\n    a INTEGER PRIMARY KEY AUTOINCREMENT,\n    b INT DEFAULT 12345 UNIQUE NOT NULL CHECK( b>=0 AND b<99999 ),\n    c VARCHAR(123,456) DEFAULT 'hello' NOT NULL ON CONFLICT REPLACE,\n    d REAL,\n    e FLOATING POINT(5,10) DEFAULT 4.36,\n    f NATIONAL CHARACTER(15) COLLATE RTRIM,\n    g LONG INTEGER DEFAULT( 3600*12 )\n  );\n  INSERT INTO t3 VALUES(null, 5, 'row1', '5.25', 'xyz', 321, '432');\n  SELECT a, typeof(a), b, typeof(b), c, typeof(c), \n         d, typeof(d), e, typeof(e), f, typeof(f),\n         g, typeof(g) FROM t3;\n} {1 integer 5 integer row1 text 5.25 real xyz text 321 text 432 integer}\ndo_execsql_test default-3.2 {\n  DELETE FROM t3;\n  INSERT INTO t3 DEFAULT VALUES;\n  SELECT * FROM t3;\n} {2 12345 hello {} 4.36 {} 43200}\ndo_execsql_test default-3.3 {\n  CREATE TABLE t300(\n    a INT DEFAULT 2147483647,\n    b INT DEFAULT 2147483648,\n    c INT DEFAULT +9223372036854775807,\n    d INT DEFAULT -2147483647,\n    e INT DEFAULT -2147483648,\n    f INT DEFAULT -9223372036854775808,\n    g INT DEFAULT (-(-9223372036854775808)),\n    h INT DEFAULT (-(-9223372036854775807))\n  );\n  INSERT INTO t300 DEFAULT VALUES;\n  SELECT * FROM t300;\n} {2147483647 2147483648 9223372036854775807 -2147483647 -2147483648 -9223372036854775808 9.22337203685478e+18 9223372036854775807}\n\n# Do now allow bound parameters in new DEFAULT values. \n# Silently convert bound parameters to NULL in DEFAULT causes\n# in the sqlite_master table, for backwards compatibility.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test default-4.0 {\n  CREATE TABLE t1(a TEXT, b TEXT DEFAULT(99));\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE TABLE t1(a TEXT, b TEXT DEFAULT(:xyz))';\n} {}\ndb close \nsqlite3 db test.db\ndo_execsql_test default-4.1 {\n  INSERT INTO t1(a) VALUES('xyzzy');\n  SELECT a, quote(b) FROM t1;\n} {xyzzy NULL}\ndo_catchsql_test default-4.2 {\n  CREATE TABLE t2(a TEXT, b TEXT DEFAULT(:xyz));\n} {1 {default value of column [b] is not constant}}\ndo_catchsql_test default-4.3 {\n  CREATE TABLE t2(a TEXT, b TEXT DEFAULT(abs(:xyz)));\n} {1 {default value of column [b] is not constant}}\ndo_catchsql_test default-4.4 {\n  CREATE TABLE t2(a TEXT, b TEXT DEFAULT(98+coalesce(5,:xyz)));\n} {1 {default value of column [b] is not constant}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/delete.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the DELETE FROM statement.\n#\n# $Id: delete.test,v 1.26 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Try to delete from a non-existant table.\n#\ndo_test delete-1.1 {\n  set v [catch {execsql {DELETE FROM test1}} msg]\n  lappend v $msg\n} {1 {no such table: test1}}\n\n# Try to delete from sqlite_master\n#\ndo_test delete-2.1 {\n  set v [catch {execsql {DELETE FROM sqlite_master}} msg]\n  lappend v $msg\n} {1 {table sqlite_master may not be modified}}\n\n# Delete selected entries from a table with and without an index.\n#\ndo_test delete-3.1.1 {\n  execsql {CREATE TABLE table1(f1 int, f2 int)}\n  execsql {INSERT INTO table1 VALUES(1,2)}\n  execsql {INSERT INTO table1 VALUES(2,4)}\n  execsql {INSERT INTO table1 VALUES(3,8)}\n  execsql {INSERT INTO table1 VALUES(4,16)}\n  execsql {SELECT * FROM table1 ORDER BY f1}\n} {1 2 2 4 3 8 4 16}\ndo_test delete-3.1.2 {\n  execsql {DELETE FROM table1 WHERE f1=3}\n} {}\ndo_test delete-3.1.3 {\n  execsql {SELECT * FROM table1 ORDER BY f1}\n} {1 2 2 4 4 16}\ndo_test delete-3.1.4 {\n  execsql {CREATE INDEX index1 ON table1(f1)}\n  execsql {PRAGMA count_changes=on}\n  ifcapable explain {\n    execsql {EXPLAIN DELETE FROM table1 WHERE f1=3}\n  }\n  execsql {DELETE FROM 'table1' WHERE f1=3}\n} {0}\ndo_test delete-3.1.5 {\n  execsql {SELECT * FROM table1 ORDER BY f1}\n} {1 2 2 4 4 16}\ndo_test delete-3.1.6.1 {\n  execsql {DELETE FROM table1 WHERE f1=2}\n} {1}\ndo_test delete-3.1.6.2 {\n  db changes\n} 1\ndo_test delete-3.1.7 {\n  execsql {SELECT * FROM table1 ORDER BY f1}\n} {1 2 4 16}\nintegrity_check delete-3.2\n\n# Semantic errors in the WHERE clause\n#\ndo_test delete-4.1 {\n  execsql {CREATE TABLE table2(f1 int, f2 int)}\n  set v [catch {execsql {DELETE FROM table2 WHERE f3=5}} msg]\n  lappend v $msg\n} {1 {no such column: f3}}\n\ndo_test delete-4.2 {\n  set v [catch {execsql {DELETE FROM table2 WHERE xyzzy(f1+4)}} msg]\n  lappend v $msg\n} {1 {no such function: xyzzy}}\nintegrity_check delete-4.3\n\n# Lots of deletes\n#\ndo_test delete-5.1.1 {\n  execsql {DELETE FROM table1}\n} {2}\ndo_test delete-5.1.2 {\n  execsql {SELECT count(*) FROM table1}\n} {0}\ndo_test delete-5.2.1 {\n  execsql {BEGIN TRANSACTION}\n  for {set i 1} {$i<=200} {incr i} {\n     execsql \"INSERT INTO table1 VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {COMMIT}\n  execsql {SELECT count(*) FROM table1}\n} {200}\ndo_test delete-5.2.2 {\n  execsql {DELETE FROM table1}\n} {200}\ndo_test delete-5.2.3 {\n  execsql {BEGIN TRANSACTION}\n  for {set i 1} {$i<=200} {incr i} {\n     execsql \"INSERT INTO table1 VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {COMMIT}\n  execsql {SELECT count(*) FROM table1}\n} {200}\ndo_test delete-5.2.4 {\n  execsql {PRAGMA count_changes=off}\n  execsql {DELETE FROM table1}\n} {}\ndo_test delete-5.2.5 {\n  execsql {SELECT count(*) FROM table1}\n} {0}\ndo_test delete-5.2.6 {\n  execsql {BEGIN TRANSACTION}\n  for {set i 1} {$i<=200} {incr i} {\n     execsql \"INSERT INTO table1 VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {COMMIT}\n  execsql {SELECT count(*) FROM table1}\n} {200}\ndo_test delete-5.3 {\n  for {set i 1} {$i<=200} {incr i 4} {\n     execsql \"DELETE FROM table1 WHERE f1==$i\"\n  }\n  execsql {SELECT count(*) FROM table1}\n} {150}\ndo_test delete-5.4.1 {\n  execsql \"DELETE FROM table1 WHERE f1>50\"\n  db changes\n} [db one {SELECT count(*) FROM table1 WHERE f1>50}]\ndo_test delete-5.4.2 {\n  execsql {SELECT count(*) FROM table1}\n} {37}\ndo_test delete-5.5 {\n  for {set i 1} {$i<=70} {incr i 3} {\n     execsql \"DELETE FROM table1 WHERE f1==$i\"\n  }\n  execsql {SELECT f1 FROM table1 ORDER BY f1}\n} {2 3 6 8 11 12 14 15 18 20 23 24 26 27 30 32 35 36 38 39 42 44 47 48 50}\ndo_test delete-5.6 {\n  for {set i 1} {$i<40} {incr i} {\n     execsql \"DELETE FROM table1 WHERE f1==$i\"\n  }\n  execsql {SELECT f1 FROM table1 ORDER BY f1}\n} {42 44 47 48 50}\ndo_test delete-5.7 {\n  execsql \"DELETE FROM table1 WHERE f1!=48\"\n  execsql {SELECT f1 FROM table1 ORDER BY f1}\n} {48}\nintegrity_check delete-5.8\n\n\n# Delete large quantities of data.  We want to test the List overflow\n# mechanism in the vdbe.\n#\ndo_test delete-6.1 {\n  execsql {BEGIN; DELETE FROM table1}\n  for {set i 1} {$i<=3000} {incr i} {\n    execsql \"INSERT INTO table1 VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {DELETE FROM table2}\n  for {set i 1} {$i<=3000} {incr i} {\n    execsql \"INSERT INTO table2 VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {COMMIT}\n  execsql {SELECT count(*) FROM table1}\n} {3000}\ndo_test delete-6.2 {\n  execsql {SELECT count(*) FROM table2}\n} {3000}\ndo_test delete-6.3 {\n  execsql {SELECT f1 FROM table1 WHERE f1<10 ORDER BY f1}\n} {1 2 3 4 5 6 7 8 9}\ndo_test delete-6.4 {\n  execsql {SELECT f1 FROM table2 WHERE f1<10 ORDER BY f1}\n} {1 2 3 4 5 6 7 8 9}\ndo_test delete-6.5.1 {\n  execsql {DELETE FROM table1 WHERE f1>7}\n  db changes\n} {2993}\ndo_test delete-6.5.2 {\n  execsql {SELECT f1 FROM table1 ORDER BY f1}\n} {1 2 3 4 5 6 7}\ndo_test delete-6.6 {\n  execsql {DELETE FROM table2 WHERE f1>7}\n  execsql {SELECT f1 FROM table2 ORDER BY f1}\n} {1 2 3 4 5 6 7}\ndo_test delete-6.7 {\n  execsql {DELETE FROM table1}\n  execsql {SELECT f1 FROM table1}\n} {}\ndo_test delete-6.8 {\n  execsql {INSERT INTO table1 VALUES(2,3)}\n  execsql {SELECT f1 FROM table1}\n} {2}\ndo_test delete-6.9 {\n  execsql {DELETE FROM table2}\n  execsql {SELECT f1 FROM table2}\n} {}\ndo_test delete-6.10 {\n  execsql {INSERT INTO table2 VALUES(2,3)}\n  execsql {SELECT f1 FROM table2}\n} {2}\nintegrity_check delete-6.11\n\ndo_test delete-7.1 {\n  execsql {\n    CREATE TABLE t3(a);\n    INSERT INTO t3 VALUES(1);\n    INSERT INTO t3 SELECT a+1 FROM t3;\n    INSERT INTO t3 SELECT a+2 FROM t3;\n    SELECT * FROM t3;\n  }\n} {1 2 3 4}\nifcapable {trigger} {\n  do_test delete-7.2 {\n    execsql {\n      CREATE TABLE cnt(del);\n      INSERT INTO cnt VALUES(0);\n      CREATE TRIGGER r1 AFTER DELETE ON t3 FOR EACH ROW BEGIN\n        UPDATE cnt SET del=del+1;\n      END;\n      DELETE FROM t3 WHERE a<2;\n      SELECT * FROM t3;\n    }\n  } {2 3 4}\n  do_test delete-7.3 {\n    execsql {\n      SELECT * FROM cnt;\n    }\n  } {1}\n  do_test delete-7.4 {\n    execsql {\n      DELETE FROM t3;\n      SELECT * FROM t3;\n    }\n  } {}\n  do_test delete-7.5 {\n    execsql {\n      SELECT * FROM cnt;\n    }\n  } {4}\n  do_test delete-7.6 {\n    execsql {\n      INSERT INTO t3 VALUES(1);\n      INSERT INTO t3 SELECT a+1 FROM t3;\n      INSERT INTO t3 SELECT a+2 FROM t3;\n      CREATE TABLE t4 AS SELECT * FROM t3;\n      PRAGMA count_changes=ON;\n      DELETE FROM t3;\n      DELETE FROM t4;\n    }\n  } {4 4}\n} ;# endif trigger\nifcapable {!trigger} {\n  execsql {DELETE FROM t3}\n}\nintegrity_check delete-7.7\n\n# Make sure error messages are consistent when attempting to delete\n# from a read-only database.  Ticket #304.\n#\ndo_test delete-8.0 {\n  execsql {\n    PRAGMA count_changes=OFF;\n    INSERT INTO t3 VALUES(123);\n    SELECT * FROM t3;\n  }\n} {123}\ndb close\ncatch {forcedelete test.db-journal}\ncatch {file attributes test.db -permissions 0444}\ncatch {file attributes test.db -readonly 1}\nsqlite3 db test.db\nset ::DB [sqlite3_connection_pointer db]\ndo_test delete-8.1 {\n  catchsql {\n    DELETE FROM t3;\n  }\n} {1 {attempt to write a readonly database}}\ndo_test delete-8.2 {\n  execsql {SELECT * FROM t3} \n} {123}\ndo_test delete-8.3 {\n  catchsql {\n    DELETE FROM t3 WHERE 1;\n  }\n} {1 {attempt to write a readonly database}}\ndo_test delete-8.4 {\n  execsql {SELECT * FROM t3} \n} {123}\n\n# Update for v3: In v2 the DELETE statement would succeed because no\n# database writes actually occur. Version 3 refuses to open a transaction\n# on a read-only file, so the statement fails.\ndo_test delete-8.5 {\n  catchsql {\n    DELETE FROM t3 WHERE a<100;\n  }\n# v2 result: {0 {}}\n} {1 {attempt to write a readonly database}}\ndo_test delete-8.6 {\n  execsql {SELECT * FROM t3}\n} {123}\nintegrity_check delete-8.7\n\n# Need to do the following for tcl 8.5 on mac. On that configuration, the\n# -readonly flag is taken so seriously that a subsequent [forcedelete]\n# (required before the next test file can be executed) will fail.\n#\ncatch {file attributes test.db -readonly 0}\ndb close\nforcedelete test.db test.db-journal\n\n# The following tests verify that SQLite correctly handles the case\n# where an index B-Tree is being scanned, the rowid column being read\n# from each index entry and another statement deletes some rows from\n# the index B-Tree. At one point this (obscure) scenario was causing \n# SQLite to return spurious SQLITE_CORRUPT errors and arguably incorrect\n# query results. \n#\ndo_test delete-9.1 {\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t5(a, b);\n    CREATE TABLE t6(c, d);\n    INSERT INTO t5 VALUES(1, 2);\n    INSERT INTO t5 VALUES(3, 4);\n    INSERT INTO t5 VALUES(5, 6);\n    INSERT INTO t6 VALUES('a', 'b');\n    INSERT INTO t6 VALUES('c', 'd');\n    CREATE INDEX i5 ON t5(a);\n    CREATE INDEX i6 ON t6(c);\n  }\n} {}\ndo_test delete-9.2 {\n  set res [list]\n  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {\n    if {$r==2} { db eval { DELETE FROM t5 } }\n    lappend res $r $c $d\n  }\n  set res\n} {1 a b 1 c d 2 a b {} c d}\ndo_test delete-9.3 {\n  execsql {\n    INSERT INTO t5 VALUES(1, 2);\n    INSERT INTO t5 VALUES(3, 4);\n    INSERT INTO t5 VALUES(5, 6);\n  }\n  set res [list]\n  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {\n    if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 2 } }\n    lappend res $r $c $d\n  }\n  set res\n} {1 a b 1 c d 2 a b {} c d 3 a b 3 c d}\ndo_test delete-9.4 {\n  execsql {\n    DELETE FROM t5;\n    INSERT INTO t5 VALUES(1, 2);\n    INSERT INTO t5 VALUES(3, 4);\n    INSERT INTO t5 VALUES(5, 6);\n  }\n  set res [list]\n  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {\n    if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 1 } }\n    lappend res $r $c $d\n  }\n  set res\n} {1 a b 1 c d 2 a b 2 c d 3 a b 3 c d}\ndo_test delete-9.5 {\n  execsql {\n    DELETE FROM t5;\n    INSERT INTO t5 VALUES(1, 2);\n    INSERT INTO t5 VALUES(3, 4);\n    INSERT INTO t5 VALUES(5, 6);\n  }\n  set res [list]\n  db eval { SELECT t5.rowid AS r, c, d FROM t5, t6 ORDER BY a } {\n    if {$r==2} { db eval { DELETE FROM t5 WHERE rowid = 3 } }\n    lappend res $r $c $d\n  }\n  set res\n} {1 a b 1 c d 2 a b 2 c d}\n\ndo_execsql_test delete-10.0 {\n  CREATE TABLE t1(a INT UNIQUE, b INT);\n  INSERT INTO t1(a,b) VALUES('1','2');\n  SELECT * FROM t1 WHERE a='1' AND b='2';\n} {1 2}\n\ndo_execsql_test delete-10.1 {\n  DELETE FROM t1 WHERE a='1' AND b='2';\n}\n\ndo_execsql_test delete-10.2 {\n  SELECT * FROM t1 WHERE a='1' AND b='2';\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/delete2.test",
    "content": "# 2003 September 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is a test to replicate the bug reported by\n# ticket #842.\n#\n# Ticket #842 was a database corruption problem caused by a DELETE that\n# removed an index entry by not the main table entry.  To recreate the\n# problem do this:\n#\n#   (1) Create a table with an index.  Insert some data into that table.\n#   (2) Start a query on the table but do not complete the query.\n#   (3) Try to delete a single entry from the table.\n#\n# Step 3 will fail because there is still a read cursor on the table.\n# But the database is corrupted by the DELETE.  It turns out that the\n# index entry was deleted first, before the table entry.  And the index\n# delete worked.  Thus an entry was deleted from the index but not from\n# the table.\n#\n# The solution to the problem was to detect that the table is locked\n# before the index entry is deleted.\n#\n# $Id: delete2.test,v 1.8 2008/07/08 15:59:52 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table that has an index.\n#\ndo_test delete2-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE q(s string, id string, constraint pk_q primary key(id));\n    BEGIN;\n    INSERT INTO q(s,id) VALUES('hello','id.1');\n    INSERT INTO q(s,id) VALUES('goodbye','id.2');\n    INSERT INTO q(s,id) VALUES('again','id.3');\n    END;\n    SELECT * FROM q;\n  }\n} {hello id.1 goodbye id.2 again id.3}\ndo_test delete2-1.2 {\n  execsql {\n    SELECT * FROM q WHERE id='id.1';\n  }\n} {hello id.1}\nintegrity_check delete2-1.3\n\n# Start a query on the table.  The query should not use the index.\n# Do not complete the query, thus leaving the table locked.\n#\ndo_test delete2-1.4 {\n  set STMT [sqlite3_prepare $DB {SELECT * FROM q} -1 TAIL]\n  sqlite3_step $STMT\n} SQLITE_ROW\nintegrity_check delete2-1.5\n\n# Try to delete a row from the table while a read is in process.\n# As of 2006-08-16, this is allowed.  (It used to fail with SQLITE_LOCKED.)\n#\ndo_test delete2-1.6 {\n  catchsql {\n    DELETE FROM q WHERE rowid=1\n  }\n} {0 {}}\nintegrity_check delete2-1.7\ndo_test delete2-1.8 {\n  execsql {\n    SELECT * FROM q;\n  }\n} {goodbye id.2 again id.3}\n\n# Finalize the query, thus clearing the lock on the table.  Then\n# retry the delete.  The delete should work this time.\n#\ndo_test delete2-1.9 {\n  sqlite3_finalize $STMT\n  catchsql {\n    DELETE FROM q WHERE rowid=1\n  }\n} {0 {}}\nintegrity_check delete2-1.10\ndo_test delete2-1.11 {\n  execsql {\n    SELECT * FROM q;\n  }\n} {goodbye id.2 again id.3}\n\ndo_test delete2-2.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(c, d);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES(3, 4);\n    INSERT INTO t2 VALUES(5, 6);\n  }\n} {}\ndo_test delete2-2.2 {\n  set res [list]\n  db eval {\n    SELECT CASE WHEN c = 5 THEN b ELSE NULL END AS b, c, d FROM t1, t2\n  } {\n    db eval {DELETE FROM t1}\n    lappend res $b $c $d\n  }\n  set res\n} {{} 3 4 {} 5 6}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/delete3.test",
    "content": "# 2005 August 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is a test of the DELETE command where a\n# large number of rows are deleted.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table that contains a large number of rows.\n#\ndo_test delete3-1.1 {\n  execsql {\n    CREATE TABLE t1(x integer primary key);\n    BEGIN;\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT x+2 FROM t1;\n    INSERT INTO t1 SELECT x+4 FROM t1;\n    INSERT INTO t1 SELECT x+8 FROM t1;\n    INSERT INTO t1 SELECT x+16 FROM t1;\n    INSERT INTO t1 SELECT x+32 FROM t1;\n    INSERT INTO t1 SELECT x+64 FROM t1;\n    INSERT INTO t1 SELECT x+128 FROM t1;\n    INSERT INTO t1 SELECT x+256 FROM t1;\n    INSERT INTO t1 SELECT x+512 FROM t1;\n    INSERT INTO t1 SELECT x+1024 FROM t1;\n    INSERT INTO t1 SELECT x+2048 FROM t1;\n    INSERT INTO t1 SELECT x+4096 FROM t1;\n    INSERT INTO t1 SELECT x+8192 FROM t1;\n    INSERT INTO t1 SELECT x+16384 FROM t1;\n    INSERT INTO t1 SELECT x+32768 FROM t1;\n    INSERT INTO t1 SELECT x+65536 FROM t1;\n    INSERT INTO t1 SELECT x+131072 FROM t1;\n    INSERT INTO t1 SELECT x+262144 FROM t1;\n    COMMIT;\n    SELECT count(*) FROM t1;\t\n  }\n} {524288}\ndo_test delete3-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE x%2==0;\n    SELECT count(*) FROM t1;\n  }\n} {262144}\nintegrity_check delete3-1.3\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/delete4.test",
    "content": "# 2005 August 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is a test of the DELETE command.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix delete4\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n  INSERT INTO t1 VALUES(1, 0);\n  INSERT INTO t1 VALUES(2, 1);\n  INSERT INTO t1 VALUES(3, 0);\n  INSERT INTO t1 VALUES(4, 1);\n  INSERT INTO t1 VALUES(5, 0);\n  INSERT INTO t1 VALUES(6, 1);\n  INSERT INTO t1 VALUES(7, 0);\n  INSERT INTO t1 VALUES(8, 1);\n}\ndo_execsql_test 1.2 {\n  DELETE FROM t1 WHERE y=1;\n}\ndo_execsql_test 1.3 {\n  SELECT x FROM t1;\n} {1 3 5 7}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);\n  INSERT INTO t1 VALUES(1, 0, randomblob(200));\n  INSERT INTO t1 VALUES(2, 1, randomblob(200));\n  INSERT INTO t1 VALUES(3, 0, randomblob(200));\n  INSERT INTO t1 VALUES(4, 1, randomblob(200));\n  INSERT INTO t1 VALUES(5, 0, randomblob(200));\n  INSERT INTO t1 VALUES(6, 1, randomblob(200));\n  INSERT INTO t1 VALUES(7, 0, randomblob(200));\n  INSERT INTO t1 VALUES(8, 1, randomblob(200));\n}\ndo_execsql_test 2.2 {\n  DELETE FROM t1 WHERE y=1;\n}\ndo_execsql_test 2.3 {\n  SELECT x FROM t1;\n} {1 3 5 7}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(2, 4);\n  INSERT INTO t1 VALUES(1, 5);\n  DELETE FROM t1 WHERE a=1;\n  SELECT * FROM t1;\n} {2 4}\n\n#-------------------------------------------------------------------------\n# DELETE statement that uses the OR optimization\n#\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);\n  CREATE INDEX i1a ON t1(a);\n  CREATE INDEX i1b ON t1(b);\n  INSERT INTO t1 VALUES(1, 'one', 'i');\n  INSERT INTO t1 VALUES(2, 'two', 'ii');\n  INSERT INTO t1 VALUES(3, 'three', 'iii');\n  INSERT INTO t1 VALUES(4, 'four', 'iv');\n  INSERT INTO t1 VALUES(5, 'one', 'i');\n  INSERT INTO t1 VALUES(6, 'two', 'ii');\n  INSERT INTO t1 VALUES(7, 'three', 'iii');\n  INSERT INTO t1 VALUES(8, 'four', 'iv');\n} {}\n\ndo_execsql_test 3.2 {\n  DELETE FROM t1 WHERE a='two' OR b='iv';\n}\n\ndo_execsql_test 3.3 {\n  SELECT i FROM t1 ORDER BY i;\n} {1 3 5 7}\n\ndo_execsql_test 3.4 { \n  PRAGMA integrity_check; \n} {ok}\n\n# Between 2015-09-14 and 2015-09-28, the following test cases would result\n# in corruption (wrong # of entries in index) due to a bug in the ONEPASS\n# optimization.\n#\ndo_execsql_test 4.1 {\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t4(col0, col1);\n  INSERT INTO \"t4\" VALUES(14, 'abcde');\n  CREATE INDEX idx_t4_0 ON t4 (col1, col0);\n  CREATE INDEX idx_t4_3 ON t4 (col0);\n  DELETE FROM t4 WHERE col0=69 OR col0>7;\n  PRAGMA integrity_check;\n} {ok}\ndo_execsql_test 4.2 {\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t4(col0, col1);\n  INSERT INTO \"t4\" VALUES(14, 'abcde');\n  CREATE INDEX idx_t4_3 ON t4 (col0);\n  CREATE INDEX idx_t4_0 ON t4 (col1, col0);\n  DELETE FROM t4 WHERE col0=69 OR col0>7;\n  PRAGMA integrity_check;\n} {ok}\ndo_execsql_test 4.11 {\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t4(col0, col1, pk PRIMARY KEY) WITHOUT ROWID;\n  INSERT INTO t4 VALUES(14, 'abcde','xyzzy');\n  CREATE INDEX idx_t4_0 ON t4 (col1, col0);\n  CREATE INDEX idx_t4_3 ON t4 (col0);\n  DELETE FROM t4 WHERE col0=69 OR col0>7;\n  PRAGMA integrity_check;\n} {ok}\ndo_execsql_test 4.12 {\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t4(col0, col1, pk PRIMARY KEY) WITHOUT ROWID;\n  INSERT INTO t4 VALUES(14, 'abcde','xyzzy');\n  CREATE INDEX idx_t4_3 ON t4 (col0);\n  CREATE INDEX idx_t4_0 ON t4 (col1, col0);\n  DELETE FROM t4 WHERE col0=69 OR col0>7;\n  PRAGMA integrity_check;\n} {ok}\n\n# 2016-04-09\n# Ticket https://sqlite.org/src/info/a306e56ff68b8fa5\n# Failure to completely delete when reverse_unordered_selects is\n# engaged.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 5.0 {\n  PRAGMA page_size=1024;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX x1 ON t1(b, c);\n  INSERT INTO t1(a,b,c) VALUES(1, 1, zeroblob(80));\n  INSERT INTO t1(a,b,c) SELECT a+1, 1, c FROM t1;\n  INSERT INTO t1(a,b,c) SELECT a+2, 1, c FROM t1;\n  INSERT INTO t1(a,b,c) SELECT a+10, 2, c FROM t1 WHERE b=1;\n  INSERT INTO t1(a,b,c) SELECT a+20, 3, c FROM t1 WHERE b=1;\n  PRAGMA reverse_unordered_selects = ON;\n  DELETE FROM t1 WHERE b=2;\n  SELECT a FROM t1 WHERE b=2;\n} {}\n\n# 2016-05-02\n# Ticket https://www.sqlite.org/src/tktview/dc6ebeda93960877\n# A subquery in the WHERE clause of a one-pass DELETE can cause an\n# incorrect answer.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 6.0 {\n  CREATE TABLE t2(x INT);\n  INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5);\n  DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x-1);\n  SELECT x FROM t2;\n} {1}\ndo_execsql_test 6.1 {\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(x INT);\n  INSERT INTO t2(x) VALUES(1),(2),(3),(4),(5);\n  DELETE FROM t2 WHERE EXISTS(SELECT 1 FROM t2 AS v WHERE v.x=t2.x+1);\n  SELECT x FROM t2;\n} {5}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/delete_db.test",
    "content": "# 2016 September 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the code in test_delete.c (the\n# sqlite3_delete_database() API).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix delete_db\n\nproc delete_all {} {\n  foreach f [glob -nocomplain test2*] { file delete $f }\n  foreach f [glob -nocomplain test3*] { file delete $f }\n}\n\nproc copydb {} {\n  foreach f [glob -nocomplain test3*] { file delete $f }\n  foreach f [glob -nocomplain test2*] { \n    set p [string range $f 5 end]\n    file copy \"test2$p\" \"test3$p\"\n  }\n}\n\nproc files {} {\n  lsort [glob -nocomplain test3*]\n}\n\ndb close\ndelete_all\nsqlite3 db test2.database\n\n#-------------------------------------------------------------------------\n#\n# 1.1: Journal files.\n# 1.2: Wal files.\n# 1.3: Multiplexor with journal file.\n# 1.4: Multiplexor with wal file.\n#\n# 2.* are a copy of 1.* with the multiplexor enabled.\n#\n# 3.* tests errors.\n#\n\ndo_test 1.1.0 {\n  execsql {\n    CREATE TABLE t1(x, y);\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n  }\n  copydb\n  files\n} {test3.database test3.database-journal}\n\ndo_test 1.1.1 {\n  sqlite3_delete_database test3.database\n  files\n} {}\n\ndo_test 1.2.0 {\n  execsql {\n    COMMIT;\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  copydb\n  files\n} {test3.database test3.database-shm test3.database-wal}\ndo_test 1.2.1 {\n  sqlite3_delete_database test3.database\n  files\n} {}\n\ndb close\ndelete_all\nsqlite3_multiplex_initialize \"\" 0\nsqlite3 db test2.database -vfs multiplex\nsqlite3_multiplex_control db \"main\" chunk_size 32768\n\ndo_test 1.3.0 {\n  execsql { PRAGMA auto_vacuum = 0; }\n  execsql {\n    CREATE TABLE x1(a, b);\n    WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )\n    INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;\n    BEGIN;\n      UPDATE x1 SET a=randomblob(101)\n  }\n  copydb\n  files\n} [list {*}{\n  test3.database test3.database-journal test3.database001 \n  test3.database002 test3.database003\n}]\ndo_test 1.3.1 {\n  sqlite3_delete_database test3.database\n  files\n} {}\n\n\ndo_test 1.4.0 {\n  execsql {\n    COMMIT;\n    PRAGMA journal_mode = wal;\n    UPDATE x1 SET a=randomblob(102)\n  }\n  copydb\n  files\n} [list {*}{\n  test3.database test3.database-shm test3.database-wal test3.database001 \n  test3.database002 test3.database003\n}]\ndo_test 1.4.1 {\n  sqlite3_delete_database test3.database\n  files\n} {}\n\n\nifcapable 8_3_names {\n  db close\n  delete_all\n  sqlite3 db file:test2.db?8_3_names=1 -uri 1\n\n  do_test 2.1.0 {\n    execsql {\n      CREATE TABLE t1(x, y);\n      BEGIN;\n        INSERT INTO t1 VALUES(1, 2);\n    }\n    copydb\n    files\n  } {test3.db test3.nal}\n  \n  do_test 2.1.1 {\n    sqlite3_delete_database test3.db\n    files\n  } {}\n  \n  do_test 2.2.0 {\n    execsql {\n      COMMIT;\n      PRAGMA journal_mode = wal;\n      INSERT INTO t1 VALUES(3, 4);\n    }\n    copydb\n    files\n  } {test3.db test3.shm test3.wal}\n  do_test 2.2.1 {\n    sqlite3_delete_database test3.db\n    files\n  } {}\n\n\n  db close\n  delete_all\n  sqlite3_multiplex_initialize \"\" 0\n  sqlite3 db file:test2.db?8_3_names=1 -uri 1 -vfs multiplex\n  sqlite3_multiplex_control db \"main\" chunk_size 32768\n  \n  do_test 2.3.0 {\n    execsql { PRAGMA auto_vacuum = 0; }\n    execsql {\n      CREATE TABLE x1(a, b);\n      WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 )\n      INSERT INTO x1 SELECT randomblob(100), randomblob(100) FROM s;\n      BEGIN;\n        UPDATE x1 SET a=randomblob(101)\n    }\n    copydb\n    files\n  } [list {*}{\n    test3.001 test3.002 test3.003 test3.db test3.nal \n  }]\n  do_test 2.3.1 {\n    sqlite3_delete_database test3.db\n    files\n  } {}\n  \n  \n  do_test 2.4.0 {\n    execsql {\n      COMMIT;\n      PRAGMA journal_mode = wal;\n      UPDATE x1 SET a=randomblob(102)\n    }\n    copydb\n    files\n  } [list {*}{\n    test3.001 test3.002 test3.003 test3.db test3.db-shm test3.wal \n  }]\n  do_test 2.4.1 {\n    sqlite3_delete_database test3.db\n    files\n  } {}\n}\n\ndb close\ndelete_all\nsqlite3_multiplex_shutdown \n\ndo_test 3.0 {\n  file mkdir dir2.db\n  sqlite3_delete_database dir2.db\n} {SQLITE_ERROR}\ndo_test 3.1 {\n  sqlite3_delete_database dir2.db/test.db\n} {SQLITE_OK}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/descidx1.test",
    "content": "# 2005 December 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is descending indices.\n#\n# $Id: descidx1.test,v 1.10 2008/03/19 00:21:31 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\ndb eval {PRAGMA legacy_file_format=OFF}\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\n\n# Verify that the file format starts as 4.\n#\ndo_test descidx1-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    CREATE INDEX i1 ON t1(b ASC);\n  }\n  get_file_format\n} {4}\ndo_test descidx1-1.2 {\n  execsql {\n    CREATE INDEX i2 ON t1(a DESC);\n  }\n  get_file_format\n} {4}\n\n# Put some information in the table and verify that the descending\n# index actually works.\n#\ndo_test descidx1-2.1 {\n  execsql {\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 SELECT a+2, a+2 FROM t1;\n    INSERT INTO t1 SELECT a+4, a+4 FROM t1;\n    SELECT b FROM t1 WHERE a>3 AND a<7;\n  }\n} {6 5 4}\ndo_test descidx1-2.2 {\n  execsql {\n    SELECT a FROM t1 WHERE b>3 AND b<7;\n  }\n} {4 5 6}\ndo_test descidx1-2.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a>=3 AND a<7;\n  }\n} {6 5 4 3}\ndo_test descidx1-2.4 {\n  execsql {\n    SELECT b FROM t1 WHERE a>3 AND a<=7;\n  }\n} {7 6 5 4}\ndo_test descidx1-2.5 {\n  execsql {\n    SELECT b FROM t1 WHERE a>=3 AND a<=7;\n  }\n} {7 6 5 4 3}\ndo_test descidx1-2.6 {\n  execsql {\n    SELECT a FROM t1 WHERE b>=3 AND b<=7;\n  }\n} {3 4 5 6 7}\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# Test sorting using a descending index.\n#\ndo_test descidx1-3.1 {\n  cksort {SELECT a FROM t1 ORDER BY a}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.2 {\n  cksort {SELECT a FROM t1 ORDER BY a ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.3 {\n  cksort {SELECT a FROM t1 ORDER BY a DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx1-3.4 {\n  cksort {SELECT b FROM t1 ORDER BY a}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.5 {\n  cksort {SELECT b FROM t1 ORDER BY a ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.6 {\n  cksort {SELECT b FROM t1 ORDER BY a DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx1-3.7 {\n  cksort {SELECT a FROM t1 ORDER BY b}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.8 {\n  cksort {SELECT a FROM t1 ORDER BY b ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.9 {\n  cksort {SELECT a FROM t1 ORDER BY b DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx1-3.10 {\n  cksort {SELECT b FROM t1 ORDER BY b}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.11 {\n  cksort {SELECT b FROM t1 ORDER BY b ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx1-3.12 {\n  cksort {SELECT b FROM t1 ORDER BY b DESC}\n} {8 7 6 5 4 3 2 1 nosort}\n\ndo_test descidx1-3.21 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a}\n} {4 5 6 7 nosort}\ndo_test descidx1-3.22 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}\n} {4 5 6 7 nosort}\ndo_test descidx1-3.23 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}\n} {7 6 5 4 nosort}\ndo_test descidx1-3.24 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a}\n} {4 5 6 7 nosort}\ndo_test descidx1-3.25 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}\n} {4 5 6 7 nosort}\ndo_test descidx1-3.26 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}\n} {7 6 5 4 nosort}\n\n# Create a table with indices that are descending on some terms and\n# ascending on others.\n#\nifcapable bloblit {\n  do_test descidx1-4.1 {\n    execsql {\n      CREATE TABLE t2(a INT, b TEXT, c BLOB, d REAL);\n      CREATE INDEX i3 ON t2(a ASC, b DESC, c ASC);\n      CREATE INDEX i4 ON t2(b DESC, a ASC, d DESC);\n      INSERT INTO t2 VALUES(1,'one',x'31',1.0);\n      INSERT INTO t2 VALUES(2,'two',x'3232',2.0);\n      INSERT INTO t2 VALUES(3,'three',x'333333',3.0);\n      INSERT INTO t2 VALUES(4,'four',x'34343434',4.0);\n      INSERT INTO t2 VALUES(5,'five',x'3535353535',5.0);\n      INSERT INTO t2 VALUES(6,'six',x'363636363636',6.0);\n      INSERT INTO t2 VALUES(2,'two',x'323232',2.1);\n      INSERT INTO t2 VALUES(2,'zwei',x'3232',2.2);\n      INSERT INTO t2 VALUES(2,NULL,NULL,2.3);\n      SELECT count(*) FROM t2;\n    }\n  } {9}\n  do_test descidx1-4.2 {\n    execsql {\n      SELECT d FROM t2 ORDER BY a;\n    }\n  } {1.0 2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}\n  do_test descidx1-4.3 {\n    execsql {\n      SELECT d FROM t2 WHERE a>=2 ORDER BY a;\n    }\n  } {2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}\n  do_test descidx1-4.4 {\n    execsql {\n      SELECT d FROM t2 WHERE a>2 ORDER BY a;\n    }\n  } {3.0 4.0 5.0 6.0}\n  do_test descidx1-4.5 {\n    execsql {\n      SELECT d FROM t2 WHERE a=2 AND b>'two';\n    }\n  } {2.2}\n  do_test descidx1-4.6 {\n    execsql {\n      SELECT d FROM t2 WHERE a=2 AND b>='two';\n    }\n  } {2.2 2.0 2.1}\n  do_test descidx1-4.7 {\n    execsql {\n      SELECT d FROM t2 WHERE a=2 AND b<'two';\n    }\n  } {}\n  do_test descidx1-4.8 {\n    execsql {\n      SELECT d FROM t2 WHERE a=2 AND b<='two';\n    }\n  } {2.0 2.1}\n}\n\ndo_test descidx1-5.1 {\n  execsql {\n    CREATE TABLE t3(a,b,c,d);\n    CREATE INDEX t3i1 ON t3(a DESC, b ASC, c DESC, d ASC);\n    INSERT INTO t3 VALUES(0,0,0,0);\n    INSERT INTO t3 VALUES(0,0,0,1);\n    INSERT INTO t3 VALUES(0,0,1,0);\n    INSERT INTO t3 VALUES(0,0,1,1);\n    INSERT INTO t3 VALUES(0,1,0,0);\n    INSERT INTO t3 VALUES(0,1,0,1);\n    INSERT INTO t3 VALUES(0,1,1,0);\n    INSERT INTO t3 VALUES(0,1,1,1);\n    INSERT INTO t3 VALUES(1,0,0,0);\n    INSERT INTO t3 VALUES(1,0,0,1);\n    INSERT INTO t3 VALUES(1,0,1,0);\n    INSERT INTO t3 VALUES(1,0,1,1);\n    INSERT INTO t3 VALUES(1,1,0,0);\n    INSERT INTO t3 VALUES(1,1,0,1);\n    INSERT INTO t3 VALUES(1,1,1,0);\n    INSERT INTO t3 VALUES(1,1,1,1);\n    SELECT count(*) FROM t3;\n  }\n} {16}\ndo_test descidx1-5.2 {\n  cksort {\n    SELECT a||b||c||d FROM t3 ORDER BY a,b,c,d;\n  }\n} {0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 sort}\ndo_test descidx1-5.3 {\n  cksort {\n    SELECT a||b||c||d FROM t3 ORDER BY a DESC, b ASC, c DESC, d ASC;\n  }\n} {1010 1011 1000 1001 1110 1111 1100 1101 0010 0011 0000 0001 0110 0111 0100 0101 nosort}\ndo_test descidx1-5.4 {\n  cksort {\n    SELECT a||b||c||d FROM t3 ORDER BY a ASC, b DESC, c ASC, d DESC;\n  }\n} {0101 0100 0111 0110 0001 0000 0011 0010 1101 1100 1111 1110 1001 1000 1011 1010 nosort}\ndo_test descidx1-5.5 {\n  cksort {\n    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b ASC, c DESC\n  }\n} {101 100 111 110 001 000 011 010 nosort}\ndo_test descidx1-5.6 {\n  cksort {\n    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c ASC\n  }\n} {010 011 000 001 110 111 100 101 nosort}\ndo_test descidx1-5.7 {\n  cksort {\n    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b DESC, c DESC\n  }\n} {011 010 001 000 111 110 101 100 sort}\ndo_test descidx1-5.8 {\n  cksort {\n    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a ASC, b ASC, c ASC\n  }\n} {000 001 010 011 100 101 110 111 sort}\ndo_test descidx1-5.9 {\n  cksort {\n    SELECT a||b||c FROM t3 WHERE d=0 ORDER BY a DESC, b DESC, c ASC\n  }\n} {110 111 100 101 010 011 000 001 sort}\n\n# Test the legacy_file_format pragma here because we have access to\n# the get_file_format command.\n#\nifcapable legacyformat {\n  do_test descidx1-6.1 {\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {PRAGMA legacy_file_format}\n  } {1}\n} else {\n  do_test descidx1-6.1 {\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    execsql {PRAGMA legacy_file_format}\n  } {0}\n}\ndo_test descidx1-6.2 {\n  execsql {PRAGMA legacy_file_format=YES}\n  execsql {PRAGMA legacy_file_format}\n} {1}\ndo_test descidx1-6.3 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n  }\n  get_file_format\n} {1}\nifcapable vacuum {\n  # Verify that the file format is preserved across a vacuum.\n  do_test descidx1-6.3.1 {\n    execsql {VACUUM}\n    get_file_format\n  } {1}\n}\ndo_test descidx1-6.4 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql {PRAGMA legacy_file_format=NO}\n  execsql {PRAGMA legacy_file_format}\n} {0}\ndo_test descidx1-6.5 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    CREATE INDEX i1 ON t1(a ASC, b DESC, c ASC);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(1,1,0);\n    INSERT INTO t1 VALUES(1,2,1);\n    INSERT INTO t1 VALUES(1,3,4);\n  }\n  get_file_format\n} {4}\nifcapable vacuum {\n  # Verify that the file format is preserved across a vacuum.\n  do_test descidx1-6.6 {\n    execsql {VACUUM}\n    get_file_format\n  } {4}\n  do_test descidx1-6.7 {\n    execsql {\n      PRAGMA legacy_file_format=ON;\n      VACUUM;\n    }\n    get_file_format\n  } {4}\n} \n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/descidx2.test",
    "content": "# 2005 December 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is descending indices.\n#\n# $Id: descidx2.test,v 1.5 2008/03/19 00:21:31 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n\ndb eval {PRAGMA legacy_file_format=OFF}\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\n\n# Verify that the file format starts as 4\n#\ndo_test descidx2-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    CREATE INDEX i1 ON t1(b ASC);\n  }\n  get_file_format\n} {4}\ndo_test descidx2-1.2 {\n  execsql {\n    CREATE INDEX i2 ON t1(a DESC);\n  }\n  get_file_format\n} {4}\n\n# Before adding any information to the database, set the file format\n# back to three.  Then close and reopen the database.  With the file\n# format set to three, SQLite should ignore the DESC argument on the\n# index.\n#\ndo_test descidx2-2.0 {\n  set_file_format 3\n  db close\n  sqlite3 db test.db\n  get_file_format\n} {3}\n\n# Put some information in the table and verify that the DESC\n# on the index is ignored.\n#\ndo_test descidx2-2.1 {\n  execsql {\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 SELECT a+2, a+2 FROM t1;\n    INSERT INTO t1 SELECT a+4, a+4 FROM t1;\n    SELECT b FROM t1 WHERE a>3 AND a<7;\n  }\n} {4 5 6}\ndo_test descidx2-2.2 {\n  execsql {\n    SELECT a FROM t1 WHERE b>3 AND b<7;\n  }\n} {4 5 6}\ndo_test descidx2-2.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a>=3 AND a<7;\n  }\n} {3 4 5 6}\ndo_test descidx2-2.4 {\n  execsql {\n    SELECT b FROM t1 WHERE a>3 AND a<=7;\n  }\n} {4 5 6 7}\ndo_test descidx2-2.5 {\n  execsql {\n    SELECT b FROM t1 WHERE a>=3 AND a<=7;\n  }\n} {3 4 5 6 7}\ndo_test descidx2-2.6 {\n  execsql {\n    SELECT a FROM t1 WHERE b>=3 AND b<=7;\n  }\n} {3 4 5 6 7}\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# Test sorting using a descending index.\n#\ndo_test descidx2-3.1 {\n  cksort {SELECT a FROM t1 ORDER BY a}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.2 {\n  cksort {SELECT a FROM t1 ORDER BY a ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.3 {\n  cksort {SELECT a FROM t1 ORDER BY a DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx2-3.4 {\n  cksort {SELECT b FROM t1 ORDER BY a}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.5 {\n  cksort {SELECT b FROM t1 ORDER BY a ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.6 {\n  cksort {SELECT b FROM t1 ORDER BY a DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx2-3.7 {\n  cksort {SELECT a FROM t1 ORDER BY b}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.8 {\n  cksort {SELECT a FROM t1 ORDER BY b ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.9 {\n  cksort {SELECT a FROM t1 ORDER BY b DESC}\n} {8 7 6 5 4 3 2 1 nosort}\ndo_test descidx2-3.10 {\n  cksort {SELECT b FROM t1 ORDER BY b}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.11 {\n  cksort {SELECT b FROM t1 ORDER BY b ASC}\n} {1 2 3 4 5 6 7 8 nosort}\ndo_test descidx2-3.12 {\n  cksort {SELECT b FROM t1 ORDER BY b DESC}\n} {8 7 6 5 4 3 2 1 nosort}\n\ndo_test descidx2-3.21 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a}\n} {4 5 6 7 nosort}\ndo_test descidx2-3.22 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}\n} {4 5 6 7 nosort}\ndo_test descidx2-3.23 {\n  cksort {SELECT a FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}\n} {7 6 5 4 nosort}\ndo_test descidx2-3.24 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a}\n} {4 5 6 7 nosort}\ndo_test descidx2-3.25 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a ASC}\n} {4 5 6 7 nosort}\ndo_test descidx2-3.26 {\n  cksort {SELECT b FROM t1 WHERE a>3 AND a<8 ORDER BY a DESC}\n} {7 6 5 4 nosort}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/descidx3.test",
    "content": "# 2006 January 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is descending indices.\n#\n# $Id: descidx3.test,v 1.6 2008/03/19 00:21:31 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\nifcapable !bloblit {\n  finish_test\n  return\n}\ndb eval {PRAGMA legacy_file_format=OFF}\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\n# This procedure returns the value of the file-format in file 'test.db'.\n# \nproc get_file_format {{fname test.db}} {\n  return [hexio_get_int [hexio_read $fname 44 4]]\n}\n\n# Verify that the file format starts as 4.\n#\ndo_test descidx3-1.1 {\n  execsql {\n    CREATE TABLE t1(i INTEGER PRIMARY KEY,a,b,c,d);\n    CREATE INDEX t1i1 ON t1(a DESC, b ASC, c DESC);\n    CREATE INDEX t1i2 ON t1(b DESC, c ASC, d DESC);\n  }\n  get_file_format\n} {4}\n\n# Put some information in the table and verify that the descending\n# index actually works.\n#\ndo_test descidx3-2.1 {\n  execsql {\n    INSERT INTO t1 VALUES(1, NULL, NULL, NULL, NULL);\n    INSERT INTO t1 VALUES(2, 2, 2, 2, 2);\n    INSERT INTO t1 VALUES(3, 3, 3, 3, 3);\n    INSERT INTO t1 VALUES(4, 2.5, 2.5, 2.5, 2.5);\n    INSERT INTO t1 VALUES(5, -5, -5, -5, -5);\n    INSERT INTO t1 VALUES(6, 'six', 'six', 'six', 'six');\n    INSERT INTO t1 VALUES(7, x'77', x'77', x'77', x'77');\n    INSERT INTO t1 VALUES(8, 'eight', 'eight', 'eight', 'eight');\n    INSERT INTO t1 VALUES(9, x'7979', x'7979', x'7979', x'7979');\n    SELECT count(*) FROM t1;\n  }\n} 9\ndo_test descidx3-2.2 {\n  execsql {\n    SELECT i FROM t1 ORDER BY a;\n  }\n} {1 5 2 4 3 8 6 7 9}\ndo_test descidx3-2.3 {\n  execsql {\n    SELECT i FROM t1 ORDER BY a DESC;\n  }\n} {9 7 6 8 3 4 2 5 1}\n\n# The \"natural\" order for the index is decreasing\ndo_test descidx3-2.4 {\n  execsql {\n    SELECT i FROM t1 WHERE a<=x'7979';\n  }\n} {9 7 6 8 3 4 2 5}\ndo_test descidx3-2.5 {\n  execsql {\n    SELECT i FROM t1 WHERE a>-99;\n  }\n} {9 7 6 8 3 4 2 5}\n\n# Even when all values of t1.a are the same, sorting by A returns\n# the rows in reverse order because this the natural order of the\n# index.\n#\ndo_test descidx3-3.1 {\n  execsql {\n    UPDATE t1 SET a=1;\n    SELECT i FROM t1 ORDER BY a;\n  }\n} {9 7 6 8 3 4 2 5 1}\ndo_test descidx3-3.2 {\n  execsql {\n    SELECT i FROM t1 WHERE a=1 AND b>0 AND b<'zzz'\n  }\n} {2 4 3 8 6}\ndo_test descidx3-3.3 {\n  execsql {\n    SELECT i FROM t1 WHERE b>0 AND b<'zzz'\n  }\n} {6 8 3 4 2}\ndo_test descidx3-3.4 {\n  execsql {\n    SELECT i FROM t1 WHERE a=1 AND b>-9999 AND b<x'ffffffff'\n  }\n} {5 2 4 3 8 6 7 9}\ndo_test descidx3-3.5 {\n  execsql {\n    SELECT i FROM t1 WHERE b>-9999 AND b<x'ffffffff'\n  }\n} {9 7 6 8 3 4 2 5}\n\nifcapable subquery {\n  # If the subquery capability is not compiled in to the binary, then\n  # the IN(...) operator is not available. Hence these tests cannot be \n  # run.\n  do_test descidx3-4.1 {\n    lsort [execsql {\n      UPDATE t1 SET a=2 WHERE i<6;\n      SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';\n    }]\n  } {2 3 4 6 8}\n  do_test descidx3-4.2 {\n    execsql {\n      UPDATE t1 SET a=1;\n      SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';\n    }\n  } {2 4 3 8 6}\n  do_test descidx3-4.3 {\n    execsql {\n      UPDATE t1 SET b=2;\n      SELECT i FROM t1 WHERE a IN (1,2) AND b>0 AND b<'zzz';\n    }\n  } {9 7 6 8 3 4 2 5 1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/diskfull.test",
    "content": "# 2001 October 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of disk full\n# errors.\n# \n# $Id: diskfull.test,v 1.8 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset sqlite_io_error_persist 0\nset sqlite_io_error_hit 0\nset sqlite_io_error_pending 0\ndo_test diskfull-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randstr(1000,1000));\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    CREATE INDEX t1i1 ON t1(x);\n    CREATE TABLE t2 AS SELECT x AS a, x AS b FROM t1;\n    CREATE INDEX t2i1 ON t2(b);\n  }\n} {}\nset sqlite_diskfull_pending 0\nintegrity_check diskfull-1.2\ndo_test diskfull-1.3 {\n  set sqlite_diskfull_pending 1\n  catchsql {\n    INSERT INTO t1 SELECT * FROM t1;\n  }\n} {1 {database or disk is full}}\nset sqlite_diskfull_pending 0\nintegrity_check diskfull-1.4\ndo_test diskfull-1.5 {\n  set sqlite_diskfull_pending 1\n  catchsql {\n    DELETE FROM t1;\n  }\n} {1 {database or disk is full}}\nset sqlite_diskfull_pending 0\nset sqlite_io_error_hit 0\nintegrity_check diskfull-1.6\n\nproc do_diskfull_test {prefix sql} {\n  set ::go 1\n  set ::sql $sql\n  set ::i 1\n  while {$::go} {\n    incr ::i\n    do_test ${prefix}.$::i.1 {\n      set ::sqlite_diskfull_pending $::i\n      set ::sqlite_diskfull 0\n      set r [catchsql $::sql]\n      if {!$::sqlite_diskfull} {\n        set r {1 {database or disk is full}}\n        set ::go 0\n      }\n      if {$r==\"1 {disk I/O error}\"} {\n        set r {1 {database or disk is full}}\n      }\n      set r\n    } {1 {database or disk is full}}\n    set ::sqlite_diskfull_pending 0\n    db close\n    sqlite3 db test.db\n    integrity_check ${prefix}.$::i.2\n  }\n}\n\ndo_diskfull_test diskfull-2 VACUUM\n\n# db close\n# forcedelete test.db\n# forcedelete test.db-journal\n# sqlite3 db test.db\n# \n# do_test diskfull-3.1 {\n#   execsql {\n#     PRAGMA default_cache_size = 10;\n#     CREATE TABLE t3(a, b, UNIQUE(a, b));\n#     INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n#     UPDATE t3 \n#     SET b = (SELECT a FROM t3 WHERE rowid = (SELECT max(rowid)-1 FROM t3))\n#     WHERE rowid = (SELECT max(rowid) FROM t3);\n#     PRAGMA cache_size;\n#   }\n# } {10}\n# \n# do_diskfull_test diskfull-3.2 {\n#   BEGIN;\n#     INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );\n#     UPDATE t3 SET a = b;\n#   COMMIT;\n# }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/distinct.test",
    "content": "# 2011 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the DISTINCT modifier.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nset testprefix distinct\n\n\nproc is_distinct_noop {sql} {\n  set sql1 $sql\n  set sql2 [string map {DISTINCT \"\"} $sql]\n\n  set program1 [list]\n  set program2 [list]\n  db eval \"EXPLAIN $sql1\" {\n    if {$opcode != \"Noop\"} { lappend program1 $opcode }\n  }\n  db eval \"EXPLAIN $sql2\" {\n    if {$opcode != \"Noop\"} { lappend program2 $opcode }\n  }\n\n  return [expr {$program1==$program2}]\n}\n\nproc do_distinct_noop_test {tn sql} {\n  uplevel [list do_test $tn [list is_distinct_noop $sql] 1]\n}\nproc do_distinct_not_noop_test {tn sql} {\n  uplevel [list do_test $tn [list is_distinct_noop $sql] 0]\n}\n\nproc do_temptables_test {tn sql temptables} {\n  uplevel [list do_test $tn [subst -novar {\n    set ret \"\"\n    db eval \"EXPLAIN [set sql]\" {\n      if {$opcode == \"OpenEphemeral\" || $opcode == \"SorterOpen\"} { \n        if {$p5 != \"08\" && $p5!=\"00\"} { error \"p5 = $p5\" }\n        if {$p5 == \"08\"} {\n          lappend ret hash\n        } else {\n          lappend ret btree\n        }\n      }\n    }\n    set ret\n  }] $temptables]\n}\n\n\n#-------------------------------------------------------------------------\n# The following tests - distinct-1.* - check that the planner correctly \n# detects cases where a UNIQUE index means that a DISTINCT clause is \n# redundant. Currently the planner only detects such cases when there\n# is a single table in the FROM clause.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, d);\n  CREATE UNIQUE INDEX i1 ON t1(b, c);\n  CREATE UNIQUE INDEX i2 ON t1(d COLLATE nocase);\n\n  CREATE TABLE t2(x INTEGER PRIMARY KEY, y);\n\n  CREATE TABLE t3(c1 PRIMARY KEY NOT NULL, c2 NOT NULL);\n  CREATE INDEX i3 ON t3(c2);\n\n  CREATE TABLE t4(a, b NOT NULL, c NOT NULL, d NOT NULL);\n  CREATE UNIQUE INDEX t4i1 ON t4(b, c);\n  CREATE UNIQUE INDEX t4i2 ON t4(d COLLATE nocase);\n}\nforeach {tn noop sql} {\n\n  1.1 0   \"SELECT DISTINCT b, c FROM t1\"\n  1.2 1   \"SELECT DISTINCT b, c FROM t4\"\n  2.1 0   \"SELECT DISTINCT c FROM t1 WHERE b = ?\"\n  2.2 1   \"SELECT DISTINCT c FROM t4 WHERE b = ?\"\n  3   1   \"SELECT DISTINCT rowid FROM t1\"\n  4   1   \"SELECT DISTINCT rowid, a FROM t1\"\n  5   1   \"SELECT DISTINCT x FROM t2\"\n  6   1   \"SELECT DISTINCT * FROM t2\"\n  7   1   \"SELECT DISTINCT * FROM (SELECT * FROM t2)\"\n\n  8.1 0   \"SELECT DISTINCT * FROM t1\"\n  8.2 1   \"SELECT DISTINCT * FROM t4\"\n\n  8   0   \"SELECT DISTINCT a, b FROM t1\"\n\n  9   0   \"SELECT DISTINCT c FROM t1 WHERE b IN (1,2)\"\n  10  0   \"SELECT DISTINCT c FROM t1\"\n  11  0   \"SELECT DISTINCT b FROM t1\"\n\n  12.1 0   \"SELECT DISTINCT a, d FROM t1\"\n  12.2 0   \"SELECT DISTINCT a, d FROM t4\"\n  13.1 0   \"SELECT DISTINCT a, b, c COLLATE nocase FROM t1\"\n  13.2 0   \"SELECT DISTINCT a, b, c COLLATE nocase FROM t4\"\n  14.1 0   \"SELECT DISTINCT a, d COLLATE nocase FROM t1\"\n  14.2 1   \"SELECT DISTINCT a, d COLLATE nocase FROM t4\"\n\n  15   0   \"SELECT DISTINCT a, d COLLATE binary FROM t1\"\n  16.1 0   \"SELECT DISTINCT a, b, c COLLATE binary FROM t1\"\n  16.2 1   \"SELECT DISTINCT a, b, c COLLATE binary FROM t4\"\n\n  16  0   \"SELECT DISTINCT t1.rowid FROM t1, t2\"\n  17  0   { /* Technically, it would be possible to detect that DISTINCT\n            ** is a no-op in cases like the following. But SQLite does not\n            ** do so. */\n            SELECT DISTINCT t1.rowid FROM t1, t2 WHERE t1.rowid=t2.rowid }\n\n  18  1   \"SELECT DISTINCT c1, c2 FROM t3\"\n  19  1   \"SELECT DISTINCT c1 FROM t3\"\n  20  1   \"SELECT DISTINCT * FROM t3\"\n  21  0   \"SELECT DISTINCT c2 FROM t3\"\n\n  22  0   \"SELECT DISTINCT * FROM (SELECT 1, 2, 3 UNION SELECT 4, 5, 6)\"\n  23  1   \"SELECT DISTINCT rowid FROM (SELECT 1, 2, 3 UNION SELECT 4, 5, 6)\"\n\n  24  0   \"SELECT DISTINCT rowid/2 FROM t1\"\n  25  1   \"SELECT DISTINCT rowid/2, rowid FROM t1\"\n  26.1  0   \"SELECT DISTINCT rowid/2, b FROM t1 WHERE c = ?\"\n  26.2  1   \"SELECT DISTINCT rowid/2, b FROM t4 WHERE c = ?\"\n} {\n  if {$noop} {\n    do_distinct_noop_test 1.$tn $sql\n  } else {\n    do_distinct_not_noop_test 1.$tn $sql\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following tests - distinct-2.* - test cases where an index is\n# used to deliver results in order of the DISTINCT expressions. \n#\ndrop_all_tables\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a, b, c);\n\n  CREATE INDEX i1 ON t1(a, b);\n  CREATE INDEX i2 ON t1(b COLLATE nocase, c COLLATE nocase);\n\n  INSERT INTO t1 VALUES('a', 'b', 'c');\n  INSERT INTO t1 VALUES('A', 'B', 'C');\n  INSERT INTO t1 VALUES('a', 'b', 'c');\n  INSERT INTO t1 VALUES('A', 'B', 'C');\n}\n\nforeach {tn sql temptables res} {\n  1   \"a, b FROM t1\"                                       {}      {A B a b}\n  2   \"b, a FROM t1\"                                       {}      {B A b a}\n  3   \"a, b, c FROM t1\"                                    {hash}  {A B C a b c}\n  4   \"a, b, c FROM t1 ORDER BY a, b, c\"                   {btree} {A B C a b c}\n  5   \"b FROM t1 WHERE a = 'a'\"                            {}      {b}\n  6   \"b FROM t1 ORDER BY +b COLLATE binary\"          {btree hash} {B b}\n  7   \"a FROM t1\"                                          {}      {A a}\n  8   \"b COLLATE nocase FROM t1\"                           {}      {b}\n  9   \"b COLLATE nocase FROM t1 ORDER BY b COLLATE nocase\" {}      {b}\n} {\n  do_execsql_test    2.$tn.1 \"SELECT DISTINCT $sql\" $res\n  do_temptables_test 2.$tn.2 \"SELECT DISTINCT $sql\" $temptables\n}\n\ndo_execsql_test 2.A {\n  SELECT (SELECT DISTINCT o.a FROM t1 AS i) FROM t1 AS o ORDER BY rowid;\n} {a A a A}\n\ndo_test 3.0 {\n  db eval {\n    CREATE TABLE t3(a INTEGER, b INTEGER, c, UNIQUE(a,b));\n    INSERT INTO t3 VALUES\n        (null, null, 1),\n        (null, null, 2),\n        (null, 3, 4),\n        (null, 3, 5),\n        (6, null, 7),\n        (6, null, 8);\n    SELECT DISTINCT a, b FROM t3 ORDER BY +a, +b;\n  }\n} {{} {} {} 3 6 {}}\ndo_test 3.1 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT DISTINCT a, b FROM t3 ORDER BY +a, +b;\n  }]\n} {0}\n\n#-------------------------------------------------------------------------\n# Ticket  [fccbde530a6583bf2748400919f1603d5425995c] (2014-01-08)\n# The logic that computes DISTINCT sometimes thinks that a zeroblob()\n# and a blob of all zeros are different when they should be the same. \n#\ndo_execsql_test 4.1 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t1(a INTEGER);\n  INSERT INTO t1 VALUES(3);\n  INSERT INTO t1 VALUES(2);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n  INSERT INTO t1 VALUES(3);\n  INSERT INTO t1 VALUES(1);\n  CREATE TABLE t2(x);\n  INSERT INTO t2\n    SELECT DISTINCT\n      CASE a WHEN 1 THEN x'0000000000'\n             WHEN 2 THEN zeroblob(5)\n             ELSE 'xyzzy' END\n      FROM t1;\n  SELECT quote(x) FROM t2 ORDER BY 1;\n} {'xyzzy' X'0000000000'}\n\n#----------------------------------------------------------------------------\n# Ticket [c5ea805691bfc4204b1cb9e9aa0103bd48bc7d34] (2014-12-04)\n# Make sure that DISTINCT works together with ORDER BY and descending\n# indexes.\n#\ndo_execsql_test 5.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1(x) VALUES(3),(1),(5),(2),(6),(4),(5),(1),(3);\n  CREATE INDEX t1x ON t1(x DESC);\n  SELECT DISTINCT x FROM t1 ORDER BY x ASC;\n} {1 2 3 4 5 6}\ndo_execsql_test 5.2 {\n  SELECT DISTINCT x FROM t1 ORDER BY x DESC;\n} {6 5 4 3 2 1}\ndo_execsql_test 5.3 {\n  SELECT DISTINCT x FROM t1 ORDER BY x;\n} {1 2 3 4 5 6}\ndo_execsql_test 5.4 {\n  DROP INDEX t1x;\n  CREATE INDEX t1x ON t1(x ASC);\n  SELECT DISTINCT x FROM t1 ORDER BY x ASC;\n} {1 2 3 4 5 6}\ndo_execsql_test 5.5 {\n  SELECT DISTINCT x FROM t1 ORDER BY x DESC;\n} {6 5 4 3 2 1}\ndo_execsql_test 5.6 {\n  SELECT DISTINCT x FROM t1 ORDER BY x;\n} {1 2 3 4 5 6}\n\n#-------------------------------------------------------------------------\n# 2015-11-23.  Problem discovered by Kostya Serebryany using libFuzzer\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test 6.1 {\n  CREATE TABLE jjj(x);\n  SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) \n    FROM sqlite_master;\n} {jjj}\ndo_execsql_test 6.2 {\n  CREATE TABLE nnn(x);\n  SELECT (SELECT 'mmm' UNION SELECT DISTINCT max(name) ORDER BY 1) \n    FROM sqlite_master;\n} {mmm}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/distinct2.test",
    "content": "# 2016-04-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is DISTINCT queries using the skip-ahead \n# optimization.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix distinct2\n\ndo_execsql_test 100 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY);\n  INSERT INTO t1 VALUES(0),(1),(2);\n  CREATE TABLE t2 AS\n     SELECT DISTINCT a.x AS aa, b.x AS bb\n      FROM t1 a, t1 b;\n  SELECT *, '|' FROM t2 ORDER BY aa, bb;\n} {0 0 | 0 1 | 0 2 | 1 0 | 1 1 | 1 2 | 2 0 | 2 1 | 2 2 |}\ndo_execsql_test 110 {\n  DROP TABLE t2;\n  CREATE TABLE t2 AS\n     SELECT DISTINCT a.x AS aa, b.x AS bb\n       FROM t1 a, t1 b\n      WHERE a.x IN t1 AND b.x IN t1;\n  SELECT *, '|' FROM t2 ORDER BY aa, bb;\n} {0 0 | 0 1 | 0 2 | 1 0 | 1 1 | 1 2 | 2 0 | 2 1 | 2 2 |}\ndo_execsql_test 120 {\n  CREATE TABLE t102 (i0 TEXT UNIQUE NOT NULL);\n  INSERT INTO t102 VALUES ('0'),('1'),('2');\n  DROP TABLE t2;\n  CREATE TABLE t2 AS\n    SELECT DISTINCT * \n    FROM t102 AS t0 \n    JOIN t102 AS t4 ON (t2.i0 IN t102)\n    NATURAL JOIN t102 AS t3\n    JOIN t102 AS t1 ON (t0.i0 IN t102)\n    JOIN t102 AS t2 ON (t2.i0=+t0.i0 OR (t0.i0<>500 AND t2.i0=t1.i0));\n  SELECT *, '|' FROM t2 ORDER BY 1, 2, 3, 4, 5;\n} {0 0 0 0 | 0 0 1 0 | 0 0 1 1 | 0 0 2 0 | 0 0 2 2 | 0 1 0 0 | 0 1 1 0 | 0 1 1 1 | 0 1 2 0 | 0 1 2 2 | 0 2 0 0 | 0 2 1 0 | 0 2 1 1 | 0 2 2 0 | 0 2 2 2 | 1 0 0 0 | 1 0 0 1 | 1 0 1 1 | 1 0 2 1 | 1 0 2 2 | 1 1 0 0 | 1 1 0 1 | 1 1 1 1 | 1 1 2 1 | 1 1 2 2 | 1 2 0 0 | 1 2 0 1 | 1 2 1 1 | 1 2 2 1 | 1 2 2 2 | 2 0 0 0 | 2 0 0 2 | 2 0 1 1 | 2 0 1 2 | 2 0 2 2 | 2 1 0 0 | 2 1 0 2 | 2 1 1 1 | 2 1 1 2 | 2 1 2 2 | 2 2 0 0 | 2 2 0 2 | 2 2 1 1 | 2 2 1 2 | 2 2 2 2 |}\n\ndo_execsql_test 400 {\n  CREATE TABLE t4(a,b,c,d,e,f,g,h,i,j);\n  INSERT INTO t4 VALUES(0,1,2,3,4,5,6,7,8,9);\n  INSERT INTO t4 SELECT * FROM t4;\n  INSERT INTO t4 SELECT * FROM t4;\n  CREATE INDEX t4x ON t4(c,d,e);\n  SELECT DISTINCT a,b,c FROM t4 WHERE a=0 AND b=1;\n} {0 1 2}\ndo_execsql_test 410 {\n  SELECT DISTINCT a,b,c,d FROM t4 WHERE a=0 AND b=1;\n} {0 1 2 3}\ndo_execsql_test 411 {\n  SELECT DISTINCT d,a,b,c FROM t4 WHERE a=0 AND b=1;\n} {3 0 1 2}\ndo_execsql_test 420 {\n  SELECT DISTINCT a,b,c,d,e FROM t4 WHERE a=0 AND b=1;\n} {0 1 2 3 4}\ndo_execsql_test 430 {\n  SELECT DISTINCT a,b,c,d,e,f FROM t4 WHERE a=0 AND b=1;\n} {0 1 2 3 4 5}\n\ndo_execsql_test 500 {\n  CREATE TABLE t5(a INT, b INT);\n  CREATE UNIQUE INDEX t5x ON t5(a+b);\n  INSERT INTO t5(a,b) VALUES(0,0),(1,0),(1,1),(0,3);\n  CREATE TEMP TABLE out AS SELECT DISTINCT a+b FROM t5;\n  SELECT * FROM out ORDER BY 1;\n} {0 1 2 3}\n\ndo_execsql_test 600 {\n  CREATE TABLE t6a(x INTEGER PRIMARY KEY);\n  INSERT INTO t6a VALUES(1);\n  CREATE TABLE t6b(y INTEGER PRIMARY KEY);\n  INSERT INTO t6b VALUES(2),(3);\n  SELECT DISTINCT x, x FROM t6a, t6b;\n} {1 1}\n\ndo_execsql_test 700 {\n  CREATE TABLE t7(a, b, c);\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE (i+1)<200\n  )\n  INSERT INTO t7 SELECT i/100, i/50, i FROM s;\n}\ndo_execsql_test 710 {\n  SELECT DISTINCT a, b FROM t7;\n} {\n  0 0    0 1\n  1 2    1 3\n}\ndo_execsql_test 720 {\n  SELECT DISTINCT a, b+1 FROM t7;\n} {\n  0 1    0 2\n  1 3    1 4\n}\ndo_execsql_test 730 {\n  CREATE INDEX i7 ON t7(a, b+1);\n  ANALYZE;\n  SELECT DISTINCT a, b+1 FROM t7;\n} {\n  0 1    0 2\n  1 3    1 4\n}\n\ndo_execsql_test 800 {\n  CREATE TABLE t8(a, b, c);\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE (i+1)<100\n  )\n  INSERT INTO t8 SELECT i/40, i/20, i/40 FROM s;\n}\n\ndo_execsql_test 820 {\n  SELECT DISTINCT a, b, c FROM t8;\n} {\n  0 0 0    0 1 0\n  1 2 1    1 3 1\n  2 4 2\n}\n\ndo_execsql_test 820 {\n  SELECT DISTINCT a, b, c FROM t8 WHERE b=3;\n} {1 3 1}\n\ndo_execsql_test 830 {\n  CREATE INDEX i8 ON t8(a, c);\n  ANALYZE;\n  SELECT DISTINCT a, b, c FROM t8 WHERE b=3;\n} {1 3 1}\n\ndo_execsql_test 900 {\n  CREATE TABLE t9(v);\n  INSERT INTO t9 VALUES \n    ('abcd'), ('Abcd'), ('aBcd'), ('ABcd'), ('abCd'), ('AbCd'), ('aBCd'), \n    ('ABCd'), ('abcD'), ('AbcD'), ('aBcD'), ('ABcD'), ('abCD'), ('AbCD'), \n    ('aBCD'), ('ABCD'),\n    ('wxyz'), ('Wxyz'), ('wXyz'), ('WXyz'), ('wxYz'), ('WxYz'), ('wXYz'), \n    ('WXYz'), ('wxyZ'), ('WxyZ'), ('wXyZ'), ('WXyZ'), ('wxYZ'), ('WxYZ'), \n    ('wXYZ'), ('WXYZ');\n}\n\ndo_execsql_test 910 {\n  SELECT DISTINCT v COLLATE NOCASE, v FROM t9 ORDER BY +v;\n} {\n  ABCD ABCD ABCd ABCd ABcD ABcD ABcd ABcd AbCD\n  AbCD AbCd AbCd AbcD AbcD Abcd Abcd\n  WXYZ WXYZ WXYz WXYz WXyZ WXyZ WXyz WXyz WxYZ\n  WxYZ WxYz WxYz WxyZ WxyZ Wxyz Wxyz\n  aBCD aBCD aBCd aBCd aBcD aBcD aBcd aBcd abCD\n  abCD abCd abCd abcD abcD abcd abcd\n  wXYZ wXYZ wXYz wXYz wXyZ wXyZ wXyz wXyz wxYZ\n  wxYZ wxYz wxYz wxyZ wxyZ wxyz wxyz\n}\n\ndo_execsql_test 920 {\n  CREATE INDEX i9 ON t9(v COLLATE NOCASE, v);\n  ANALYZE;\n\n  SELECT DISTINCT v COLLATE NOCASE, v FROM t9 ORDER BY +v;\n} {\n  ABCD ABCD ABCd ABCd ABcD ABcD ABcd ABcd AbCD\n  AbCD AbCd AbCd AbcD AbcD Abcd Abcd\n  WXYZ WXYZ WXYz WXYz WXyZ WXyZ WXyz WXyz WxYZ\n  WxYZ WxYz WxYz WxyZ WxyZ Wxyz Wxyz\n  aBCD aBCD aBCd aBCd aBcD aBcD aBcd aBcd abCD\n  abCD abCd abCd abcD abcD abcd abcd\n  wXYZ wXYZ wXYz wXYz wXyZ wXyZ wXyz wXyz wxYZ\n  wxYZ wxYz wxYz wxyZ wxyZ wxyz wxyz\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/distinctagg.test",
    "content": "# 2005 September 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the DISTINCT modifier on aggregate functions.\n#\n# $Id: distinctagg.test,v 1.3 2009/02/09 13:19:28 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test distinctagg-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(1,3,4);\n    INSERT INTO t1 VALUES(1,3,5);\n    SELECT count(distinct a),\n           count(distinct b),\n           count(distinct c),\n           count(all a) FROM t1;\n  }\n} {1 2 3 3}\ndo_test distinctagg-1.2 {\n  execsql {\n    SELECT b, count(distinct c) FROM t1 GROUP BY b ORDER BY b\n  }\n} {2 1 3 2}\ndo_test distinctagg-1.3 {\n  execsql {\n    INSERT INTO t1 SELECT a+1, b+3, c+5 FROM t1;\n    INSERT INTO t1 SELECT a+2, b+6, c+10 FROM t1;\n    INSERT INTO t1 SELECT a+4, b+12, c+20 FROM t1;\n    SELECT count(*), count(distinct a), count(distinct b) FROM t1\n  }\n} {24 8 16}\ndo_test distinctagg-1.4 {\n  execsql {\n    SELECT a, count(distinct c) FROM t1 GROUP BY a ORDER BY a\n  }\n} {1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3}\n\ndo_test distinctagg-2.1 {\n  catchsql {\n    SELECT count(distinct) FROM t1;\n  }\n} {1 {DISTINCT aggregates must have exactly one argument}}\ndo_test distinctagg-2.2 {\n  catchsql {\n    SELECT group_concat(distinct a,b) FROM t1;\n  }\n} {1 {DISTINCT aggregates must have exactly one argument}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_blobbytes.test",
    "content": "# 2014 October 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_blobbytes\n\ndo_execsql_test 1.0 {\n  CREATE TABLE q1(r INTEGER PRIMARY KEY, s TEXT);\n  WITH d(a, b) AS (\n    SELECT 0, '' \n      UNION ALL\n    SELECT a+1, b||'.' FROM d WHERE a<10000\n  )\n  INSERT INTO q1 SELECT * FROM d;\n}\n\n\n# EVIDENCE-OF: R-07796-55423 Returns the size in bytes of the BLOB\n# accessible via the successfully opened BLOB handle in its only\n# argument.\n#\nproc check_blob_size {tn rowid bytes} {\n  uplevel [list do_test $tn [subst -nocommands {\n    sqlite3_blob_open db main q1 s $rowid 0 B\n    set res [sqlite3_blob_bytes [set B]]\n    sqlite3_blob_close [set B]\n    set res\n  }] $bytes]\n}\ncheck_blob_size 1.1 43 43\ncheck_blob_size 1.2 391 391\ncheck_blob_size 1.3 6349 6349\ncheck_blob_size 1.4 2621 2621\ncheck_blob_size 1.5 7771 7771\ncheck_blob_size 1.6 7949 7949\ncheck_blob_size 1.7 4374 4374\ncheck_blob_size 1.8 2578 2578\ncheck_blob_size 1.9 7004 7004\ncheck_blob_size 1.10 2180 2180\ncheck_blob_size 1.11 3796 3796\ncheck_blob_size 1.12 7101 7101\ncheck_blob_size 1.13 7449 7449\ncheck_blob_size 1.14 7224 7224\ncheck_blob_size 1.15 3038 3038\ncheck_blob_size 1.16 1083 1083\ncheck_blob_size 1.17 5157 5157\ncheck_blob_size 1.18 6686 6686\ncheck_blob_size 1.19 6592 6592\ncheck_blob_size 1.20 0 0\n\n\n# EVIDENCE-OF: R-53088-19343 The incremental blob I/O routines can only\n# read or overwriting existing blob content; they cannot change the size\n# of a blob.\n#\n#   Also demonstrated in other e_blobXXX.test files.\n#\ndo_test 2.1 {\n  sqlite3_blob_open db main q1 s 86 1 B\n  list [catch { sqlite3_blob_write $B 86 \"1\" 1 } msg] $msg\n} {1 SQLITE_ERROR}\nsqlite3_blob_close $B\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_blobclose.test",
    "content": "# 2014 October 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_blobclose\n\nset dots [string repeat . 40]\ndo_execsql_test 1.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b DOTS);\n  INSERT INTO x1 VALUES(-1, $dots);\n  INSERT INTO x1 VALUES(-10, $dots);\n  INSERT INTO x1 VALUES(-100, $dots);\n  INSERT INTO x1 VALUES(-1000, $dots);\n  INSERT INTO x1 VALUES(-10000, $dots);\n}\n\n# EVIDENCE-OF: R-03145-46390 This function closes an open BLOB handle.\n#\n#   It's not clear how to test that a blob handle really is closed.\n#   Attempting to use a closed blob handle will likely crash the process.\n#   Assume here that if the SHARED lock on the db file is released,\n#   the blob handle has been closed.\n#\ndo_execsql_test 1.1 { PRAGMA lock_status } {main unlocked temp closed}\nsqlite3_blob_open db main x1 b -1 0 B\ndo_execsql_test 1.2 { PRAGMA lock_status } {main shared temp closed}\nsqlite3_blob_close $B\ndo_execsql_test 1.3 { PRAGMA lock_status } {main unlocked temp closed}\n\n\n# EVIDENCE-OF: R-34027-00617 If the blob handle being closed was opened\n# for read-write access, and if the database is in auto-commit mode and\n# there are no other open read-write blob handles or active write\n# statements, the current transaction is committed.\n#\n#   2.1.*: Transaction is not committed if there are other open \n#          read-write blob handles.\n#\n#   2.2.*: Transaction is not committed if not in auto-commit mode.\n#\n#   2.3.*: Active write statements.\n#\ndo_test 2.1.1 {\n  sqlite3_blob_open db main x1 b -100 1 B1\n  sqlite3_blob_open db main x1 b -1000 1 B2\n  sqlite3_blob_open db main x1 b -10000 1 B3\n  sqlite3_blob_open db main x1 b -10000 0 B4      ;# B4 is read-only!\n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.1.2 {\n  sqlite3_blob_close $B1 \n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.1.3 {\n  sqlite3_blob_close $B2 \n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.1.4 {\n  sqlite3_blob_close $B3 \n  execsql { PRAGMA lock_status }\n} {main shared temp closed}\ndo_test 2.1.5 {\n  sqlite3_blob_close $B4 \n  execsql { PRAGMA lock_status }\n} {main unlocked temp closed}\n\ndo_test 2.2.1 {\n  sqlite3_blob_open db main x1 b -100 1 B1\n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.2.2 {\n  execsql { BEGIN }\n  sqlite3_blob_close $B1 \n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.2.3 {\n  execsql { COMMIT }\n  execsql { PRAGMA lock_status }\n} {main unlocked temp closed}\n\nproc val {} { \n  sqlite3_blob_close $::B \n  db eval { PRAGMA lock_status }\n}\ndb func val val\ndo_test 2.3.1 {\n  sqlite3_blob_open db main x1 b -100 1 B\n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.3.2 {\n  execsql { INSERT INTO x1 VALUES(15, val()) }\n  execsql { PRAGMA lock_status }\n} {main unlocked temp closed}\ndo_test 2.3.3 {\n  execsql { SELECT * FROM x1 WHERE a = 15 }\n} {15 {main reserved temp closed}}\n\n# A reader does not inhibit commit.\ndo_test 2.3.4 {\n  sqlite3_blob_open db main x1 b -100 1 B\n  execsql { PRAGMA lock_status }\n} {main reserved temp closed}\ndo_test 2.3.5 {\n  execsql { SELECT a, val() FROM x1 LIMIT 1 }\n} {-10000 {main shared temp closed}}\n\n\ndo_test 3.1 {\n  sqlite3_blob_open db main x1 b -10 1 B\n  execsql {\n    INSERT INTO x1 VALUES(1, 'abc');\n    SELECT * FROM x1 WHERE a=1;\n  }\n} {1 abc}\ndo_test 3.2 {\n  sqlite3_blob_write $B 0 \"abcdefghij\" 10\n  execsql { SELECT * FROM x1 WHERE a=-10 }\n} {-10 abcdefghij..............................}\n\ndo_test 3.3 {\n  sqlite3 db2 test.db\n  execsql { BEGIN ; SELECT * FROM x1 } db2\n  sqlite3_blob_close $B \n} {SQLITE_BUSY}\n\n# EVIDENCE-OF: R-41959-38737 Otherwise, if this function is passed a\n# valid open blob handle, the values returned by the sqlite3_errcode()\n# and sqlite3_errmsg() functions are set before returning.\n#\ndo_test 3.4 {\n  list [sqlite3_errcode db] [sqlite3_errmsg db]\n} {SQLITE_BUSY {database is locked}}\n\n# EVIDENCE-OF: R-37801-37633 The BLOB handle is closed unconditionally.\n# Even if this routine returns an error code, the handle is still\n# closed.\n#\n#   Test that the lock has been released. Assume this means the handle\n#   is closed, even though blob_close() returned SQLITE_BUSY.\n#\ndo_execsql_test 3.4 { PRAGMA lock_status } {main unlocked temp closed}\n\n# EVIDENCE-OF: R-35111-05628 If an error occurs while committing the\n# transaction, an error code is returned and the transaction rolled\n# back.\n#\n#   Row 1 is removed (it was inserted this transaction) and row -10\n#   is restored to its original state. Transaction has been rolled back.\n#\ndo_execsql_test 3.5 {\n  SELECT * FROM x1 WHERE a IN (1, -10);\n} {-10 ........................................}\n\n# EVIDENCE-OF: R-25894-51060 Calling this routine with a null pointer\n# (such as would be returned by a failed call to sqlite3_blob_open()) is\n# a harmless no-op.\n#\ndo_test 4.0 { sqlite3_blob_close 0 } {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_blobopen.test",
    "content": "# 2014 October 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_blobopen\n\nforcedelete test.db2\n\ndo_execsql_test 1.0 {\n  ATTACH 'test.db2' AS aux;\n\n  CREATE TABLE main.t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n  CREATE TEMP TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n  CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n\n  CREATE TABLE main.x1(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n  CREATE TEMP TABLE x2(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n  CREATE TABLE aux.x3(a INTEGER PRIMARY KEY, b TEXT, c BLOB);\n\n  INSERT INTO main.t1 VALUES(1, 'main one', X'0101');\n  INSERT INTO main.t1 VALUES(2, 'main two', X'0102');\n  INSERT INTO main.t1 VALUES(3, 'main three', X'0103');\n  INSERT INTO main.t1 VALUES(4, 'main four', X'0104');\n  INSERT INTO main.t1 VALUES(5, 'main five', X'0105');\n\n  INSERT INTO main.x1 VALUES(1, 'x main one', X'000101');\n  INSERT INTO main.x1 VALUES(2, 'x main two', X'000102');\n  INSERT INTO main.x1 VALUES(3, 'x main three', X'000103');\n  INSERT INTO main.x1 VALUES(4, 'x main four', X'000104');\n  INSERT INTO main.x1 VALUES(5, 'x main five', X'000105');\n\n  INSERT INTO temp.t1 VALUES(1, 'temp one', X'0201');\n  INSERT INTO temp.t1 VALUES(2, 'temp two', X'0202');\n  INSERT INTO temp.t1 VALUES(3, 'temp three', X'0203');\n  INSERT INTO temp.t1 VALUES(4, 'temp four', X'0204');\n  INSERT INTO temp.t1 VALUES(5, 'temp five', X'0205');\n\n  INSERT INTO temp.x2 VALUES(1, 'x temp one', X'000201');\n  INSERT INTO temp.x2 VALUES(2, 'x temp two', X'000202');\n  INSERT INTO temp.x2 VALUES(3, 'x temp three', X'000203');\n  INSERT INTO temp.x2 VALUES(4, 'x temp four', X'000204');\n  INSERT INTO temp.x2 VALUES(5, 'x temp five', X'000205');\n\n  INSERT INTO aux.t1 VALUES(1, 'aux one', X'0301');\n  INSERT INTO aux.t1 VALUES(2, 'aux two', X'0302');\n  INSERT INTO aux.t1 VALUES(3, 'aux three', X'0303');\n  INSERT INTO aux.t1 VALUES(4, 'aux four', X'0304');\n  INSERT INTO aux.t1 VALUES(5, 'aux five', X'0305');\n\n  INSERT INTO aux.x3 VALUES(1, 'x aux one', X'000301');\n  INSERT INTO aux.x3 VALUES(2, 'x aux two', X'000302');\n  INSERT INTO aux.x3 VALUES(3, 'x aux three', X'000303');\n  INSERT INTO aux.x3 VALUES(4, 'x aux four', X'000304');\n  INSERT INTO aux.x3 VALUES(5, 'x aux five', X'000305');\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-37639-55938 This interfaces opens a handle to the BLOB\n# located in row iRow, column zColumn, table zTable in database zDb; in\n# other words, the same BLOB that would be selected by: SELECT zColumn\n# FROM zDb.zTable WHERE rowid = iRow;\n#\nproc read_blob {zDb zTab zCol iRow} {\n  sqlite3_blob_open db $zDb $zTab $zCol $iRow 0 B\n  set nByte [sqlite3_blob_bytes $B]\n  set data [sqlite3_blob_read $B 0 $nByte]\n  sqlite3_blob_close $B\n  return $data\n}\n\ndo_test 1.1.1 { read_blob main t1 b 1 } \"main one\"\ndo_test 1.1.2 { read_blob main t1 c 1 } \"\\01\\01\"\ndo_test 1.1.3 { read_blob temp t1 b 1 } \"temp one\"\ndo_test 1.1.4 { read_blob temp t1 c 1 } \"\\02\\01\"\ndo_test 1.1.6 { read_blob aux  t1 b 1 } \"aux one\"\ndo_test 1.1.7 { read_blob aux  t1 c 1 } \"\\03\\01\"\n\ndo_test 1.2.1 { read_blob main t1 b 4 } \"main four\"\ndo_test 1.2.2 { read_blob main t1 c 4 } \"\\01\\04\"\ndo_test 1.2.3 { read_blob temp t1 b 4 } \"temp four\"\ndo_test 1.2.4 { read_blob temp t1 c 4 } \"\\02\\04\"\ndo_test 1.2.6 { read_blob aux  t1 b 4 } \"aux four\"\ndo_test 1.2.7 { read_blob aux  t1 c 4 } \"\\03\\04\"\n\ndo_test 1.3.1 { read_blob main x1 b 2 } \"x main two\"\ndo_test 1.3.2 { read_blob main x1 c 2 } \"\\00\\01\\02\"\ndo_test 1.3.3 { read_blob temp x2 b 2 } \"x temp two\"\ndo_test 1.3.4 { read_blob temp x2 c 2 } \"\\00\\02\\02\"\ndo_test 1.3.6 { read_blob aux  x3 b 2 } \"x aux two\"\ndo_test 1.3.7 { read_blob aux  x3 c 2 } \"\\00\\03\\02\"\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-27234-05761 Parameter zDb is not the filename that\n# contains the database, but rather the symbolic name of the database.\n# For attached databases, this is the name that appears after the AS\n# keyword in the ATTACH statement. For the main database file, the\n# database name is \"main\". For TEMP tables, the database name is \"temp\".\n#\n#   The test cases immediately above demonstrate that the database name\n#   for the main db, for TEMP tables and for those in attached databases\n#   is correct. The following tests check that filenames cannot be\n#   used as well.\n#\ndo_test 2.1 {\n  list [catch { sqlite3_blob_open db \"test.db\" t1 b 1 0 B } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test 2.2 {\n  list [catch { sqlite3_blob_open db \"test.db2\" t1 b 1 0 B } msg] $msg\n} {1 SQLITE_ERROR}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-50854-53979 If the flags parameter is non-zero, then\n# the BLOB is opened for read and write access.\n#\n# EVIDENCE-OF: R-03922-41160 If the flags parameter is zero, the BLOB is\n# opened for read-only access.\n#\nforeach {tn iRow flags} {\n  1 1   0\n  2 2   1\n  3 3  -1\n  4 4   2147483647\n  5 5  -2147483648\n} {\n  do_test 3.$tn.1 {\n    sqlite3_blob_open db main x1 c $iRow $flags B\n    set n [sqlite3_blob_bytes $B]\n    sqlite3_blob_read $B 0 $n\n  } [binary format ccc 0 1 $iRow]\n\n  if {$flags==0} {\n    # Blob was opened for read-only access - writing returns an error.\n    do_test 3.$tn.2 {\n      list [catch { sqlite3_blob_write $B 0 xxx 3 } msg] $msg\n    } {1 SQLITE_READONLY}\n\n    do_execsql_test 3.$tn.3 {\n      SELECT c FROM x1 WHERE a=$iRow;\n    } [binary format ccc 0 1 $iRow]\n  } else {\n    # Blob was opened for read/write access - writing succeeds\n    do_test 3.$tn.4 {\n      list [catch { sqlite3_blob_write $B 0 xxx 3 } msg] $msg\n    } {0 {}}\n\n    do_execsql_test 3.$tn.5 {\n      SELECT c FROM x1 WHERE a=$iRow;\n    } {xxx}\n  }\n\n  sqlite3_blob_close $B\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES('abcd', 152);\n  INSERT INTO t1 VALUES(NULL, X'00010203');\n  INSERT INTO t1 VALUES('', 154.2);\n\n  CREATE TABLE t2(x PRIMARY KEY, y) WITHOUT ROWID;\n  INSERT INTO t2 VALUES(1, 'blob');\n\n  CREATE TABLE t3(a PRIMARY KEY, b, c, d, e, f, UNIQUE(e, f));\n  INSERT INTO t3 VALUES('aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff');\n  CREATE INDEX t3b ON t3(b);\n\n  CREATE TABLE p1(x PRIMARY KEY);\n  INSERT INTO p1 VALUES('abc');\n\n  CREATE TABLE c1(a INTEGER PRIMARY KEY, b REFERENCES p1);\n  INSERT INTO c1 VALUES(45, 'abc');\n}\n\nproc test_blob_open {tn zDb zTab zCol iRow flags    errcode errmsg} {\n  global B\n  set B \"0x1234\"\n\n  if {$errcode==\"SQLITE_OK\"} {\n    set expected \"0 {}\"\n  } else {\n    set expected \"1 $errcode\"\n  }\n\n  set ::res [list [\n    catch { sqlite3_blob_open db $zDb $zTab $zCol $iRow $flags B } msg\n  ] $msg]\n  do_test 4.$tn.1 { set ::res } $expected\n\n  # EVIDENCE-OF: R-08940-21305 Unless it returns SQLITE_MISUSE, this\n  # function sets the database connection error code and message\n  # accessible via sqlite3_errcode() and sqlite3_errmsg() and related\n  # functions.\n  #\n  #   This proc (test_blob_open) is used below to test various error and\n  #   non-error conditions. But never SQLITE_MISUSE conditions. So these\n  #   test cases are considered as partly verifying the requirement above.\n  #   See below for a test of the SQLITE_MISUSE case.\n  #\n  do_test 4.$tn.2 {\n    sqlite3_errcode db\n  } $errcode\n  do_test 4.$tn.3 {\n    sqlite3_errmsg db\n  } $errmsg\n\n  # EVIDENCE-OF: R-31086-35521 On success, SQLITE_OK is returned and the\n  # new BLOB handle is stored in *ppBlob. Otherwise an error code is\n  # returned and, unless the error code is SQLITE_MISUSE, *ppBlob is set\n  # to NULL.\n  #\n  do_test 4.$tn.4 {\n    expr {$B == \"0\"}\n  } [expr {$errcode != \"SQLITE_OK\"}]\n\n  # EVIDENCE-OF: R-63421-15521 This means that, provided the API is not\n  # misused, it is always safe to call sqlite3_blob_close() on *ppBlob\n  # after this function it returns.\n  do_test 4.$tn.5 {\n    sqlite3_blob_close $B\n  } {}\n}\n\n# EVIDENCE-OF: R-31204-44780 Database zDb does not exist\ntest_blob_open 1 nosuchdb t1 x 1 0 SQLITE_ERROR \"no such table: nosuchdb.t1\"\n\n# EVIDENCE-OF: R-28676-08005 Table zTable does not exist within database zDb\ntest_blob_open 2 main tt1 x 1 0    SQLITE_ERROR \"no such table: main.tt1\"\n\n# EVIDENCE-OF: R-40134-30296 Table zTable is a WITHOUT ROWID table\ntest_blob_open 3 main t2 y 1 0     SQLITE_ERROR \\\n    \"cannot open table without rowid: t2\"\n\n# EVIDENCE-OF: R-56376-21261 Column zColumn does not exist\ntest_blob_open 4 main t1 z 2 0     SQLITE_ERROR \"no such column: \\\"z\\\"\"\n\n# EVIDENCE-OF: R-28258-23166 Row iRow is not present in the table\ntest_blob_open 5 main t1 y 6 0     SQLITE_ERROR \"no such rowid: 6\"\n\n# EVIDENCE-OF: R-11683-62380 The specified column of row iRow contains a\n# value that is not a TEXT or BLOB value\ntest_blob_open 6 main t1 x 2 0 SQLITE_ERROR \"cannot open value of type null\"\ntest_blob_open 7 main t1 y 1 0 SQLITE_ERROR \"cannot open value of type integer\"\ntest_blob_open 8 main t1 y 3 0 SQLITE_ERROR \"cannot open value of type real\"\n\n# EVIDENCE-OF: R-34146-30782 Column zColumn is part of an index, PRIMARY\n# KEY or UNIQUE constraint and the blob is being opened for read/write\n# access\n#\n# Test cases 8.1.* show that such columns can be opened for read-access. \n# Tests 8.2.* show that read-write access is different. Columns \"c\" and \"c\"\n# are not part of an index, PK or UNIQUE constraint, so they work in both\n# cases.\n#\ntest_blob_open 8.1.1 main t3 a 1 0 SQLITE_OK \"not an error\"\ntest_blob_open 8.1.2 main t3 b 1 0 SQLITE_OK \"not an error\"\ntest_blob_open 8.1.3 main t3 c 1 0 SQLITE_OK \"not an error\"\ntest_blob_open 8.1.4 main t3 d 1 0 SQLITE_OK \"not an error\"\ntest_blob_open 8.1.5 main t3 e 1 0 SQLITE_OK \"not an error\"\ntest_blob_open 8.1.6 main t3 f 1 0 SQLITE_OK \"not an error\"\n\nset cannot \"cannot open indexed column for writing\"\ntest_blob_open 8.2.1 main t3 a 1 8 SQLITE_ERROR $cannot\ntest_blob_open 8.2.2 main t3 b 1 8 SQLITE_ERROR $cannot\ntest_blob_open 8.2.3 main t3 c 1 8 SQLITE_OK \"not an error\"\ntest_blob_open 8.2.4 main t3 d 1 8 SQLITE_OK \"not an error\"\ntest_blob_open 8.2.5 main t3 e 1 8 SQLITE_ERROR $cannot\ntest_blob_open 8.2.6 main t3 f 1 8 SQLITE_ERROR $cannot\n\n# EVIDENCE-OF: R-50117-55204 Foreign key constraints are enabled, column\n# zColumn is part of a child key definition and the blob is being opened\n# for read/write access\n#\n#   9.1: FK disabled, read-only access.\n#   9.2: FK disabled, read-only access.\n#   9.3: FK enabled, read/write access.\n#   9.4: FK enabled, read/write access.\n#\ntest_blob_open 9.1 main c1 b 45 0 SQLITE_OK \"not an error\"\ntest_blob_open 9.2 main c1 b 45 1 SQLITE_OK \"not an error\"\nexecsql { PRAGMA foreign_keys = ON }\ntest_blob_open 9.3 main c1 b 45 0 SQLITE_OK \"not an error\"\ntest_blob_open 9.4 main c1 b 45 1 SQLITE_ERROR \\\n        \"cannot open foreign key column for writing\"\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-08940-21305 Unless it returns SQLITE_MISUSE, this\n# function sets the database connection error code and message\n# accessible via sqlite3_errcode() and sqlite3_errmsg() and related\n# functions.\n#\n#   This requirement is partially verified by the many uses of test\n#   command [test_blob_open] above. All that is left is to verify the\n#   SQLITE_MISUSE case.\n#\n#   SQLITE_MISUSE is only returned if SQLITE_ENABLE_API_ARMOR is defined\n#   during compilation.\n#\nifcapable api_armor {\n  sqlite3_blob_open db main t1 x 1 0 B\n\n  do_test 10.1.1 {\n    list [catch {sqlite3_blob_open $B main t1 x 1 0 B2} msg] $msg\n  } {1 SQLITE_MISUSE}\n  do_test 10.1.2 {\n    list [sqlite3_errcode db] [sqlite3_errmsg db]\n  } {SQLITE_OK {not an error}}\n  sqlite3_blob_close $B\n\n  do_test 10.2.1 {\n    list [catch {sqlite3_blob_open db main {} x 1 0 B} msg] $msg\n  } {1 SQLITE_MISUSE}\n  do_test 10.2.2 {\n    list [sqlite3_errcode db] [sqlite3_errmsg db]\n  } {SQLITE_OK {not an error}}\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-50542-62589 If the row that a BLOB handle points to is\n# modified by an UPDATE, DELETE, or by ON CONFLICT side-effects then the\n# BLOB handle is marked as \"expired\". This is true if any column of the\n# row is changed, even a column other than the one the BLOB handle is\n# open on.\n#\n# EVIDENCE-OF: R-48367-20048 Calls to sqlite3_blob_read() and\n# sqlite3_blob_write() for an expired BLOB handle fail with a return\n# code of SQLITE_ABORT.\n#\n#   11.2: read-only handle, DELETE.\n#   11.3: read-only handle, UPDATE.\n#   11.4: read-only handle, REPLACE.\n#   11.5: read/write handle, DELETE.\n#   11.6: read/write handle, UPDATE.\n#   11.7: read/write handle, REPLACE.\n#\ndo_execsql_test 11.1 {\n  CREATE TABLE b1(a INTEGER PRIMARY KEY, b, c UNIQUE);\n  INSERT INTO b1 VALUES(1, '1234567890', 1);\n  INSERT INTO b1 VALUES(2, '1234567890', 2);\n  INSERT INTO b1 VALUES(3, '1234567890', 3);\n  INSERT INTO b1 VALUES(4, '1234567890', 4);\n  INSERT INTO b1 VALUES(5, '1234567890', 5);\n  INSERT INTO b1 VALUES(6, '1234567890', 6);\n\n  CREATE TABLE b2(a INTEGER PRIMARY KEY, b, c UNIQUE);\n  INSERT INTO b2 VALUES(1, '1234567890', 1);\n  INSERT INTO b2 VALUES(2, '1234567890', 2);\n  INSERT INTO b2 VALUES(3, '1234567890', 3);\n  INSERT INTO b2 VALUES(4, '1234567890', 4);\n  INSERT INTO b2 VALUES(5, '1234567890', 5);\n  INSERT INTO b2 VALUES(6, '1234567890', 6);\n}\n\ndo_test 11.2.1 {\n  sqlite3_blob_open db main b1 b 2 0 B\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.2.2 {\n  # Deleting a different row does not invalidate the blob handle.\n  execsql { DELETE FROM b1 WHERE a = 1 }\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.2.3 {\n  execsql { DELETE FROM b1 WHERE a = 2 }\n  list [catch { sqlite3_blob_read $B 0 10 } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.2.4 {\n  sqlite3_blob_close $B\n} {}\n\ndo_test 11.3.1 {\n  sqlite3_blob_open db main b1 b 3 0 B\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.3.2 {\n  # Updating a different row\n  execsql { UPDATE b1 SET c = 42 WHERE a=4 }\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.3.3 {\n  execsql { UPDATE b1 SET c = 43 WHERE a=3 }\n  list [catch { sqlite3_blob_read $B 0 10 } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.3.4 {\n  sqlite3_blob_close $B\n} {}\n\ndo_test 11.4.1 {\n  sqlite3_blob_open db main b1 b 6 0 B\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.4.2 {\n  # Replace a different row\n  execsql { INSERT OR REPLACE INTO b1 VALUES(10, 'abcdefghij', 5) }\n  sqlite3_blob_read $B 0 10\n} {1234567890}\ndo_test 11.4.3 {\n  execsql { INSERT OR REPLACE INTO b1 VALUES(11, 'abcdefghij', 6) }\n  list [catch { sqlite3_blob_read $B 0 10 } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.4.4 {\n  sqlite3_blob_close $B\n} {}\n\ndo_test 11.4.1 {\n  sqlite3_blob_open db main b2 b 2 1 B\n  sqlite3_blob_write $B 0 \"abcdefghij\"\n} {}\ndo_test 11.4.2 {\n  # Deleting a different row does not invalidate the blob handle.\n  execsql { DELETE FROM b2 WHERE a = 1 }\n  sqlite3_blob_write $B 0 \"ABCDEFGHIJ\"\n} {}\ndo_test 11.4.3 {\n  execsql { DELETE FROM b2 WHERE a = 2 }\n  list [catch { sqlite3_blob_write $B 0 \"0987654321\" } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.4.4 {\n  sqlite3_blob_close $B\n} {}\n\ndo_test 11.5.1 {\n  sqlite3_blob_open db main b2 b 3 1 B\n  sqlite3_blob_write $B 0 \"abcdefghij\"\n} {}\ndo_test 11.5.2 {\n  # Updating a different row\n  execsql { UPDATE b2 SET c = 42 WHERE a=4 }\n  sqlite3_blob_write $B 0 \"ABCDEFGHIJ\"\n} {}\ndo_test 11.5.3 {\n  execsql { UPDATE b2 SET c = 43 WHERE a=3 }\n  list [catch { sqlite3_blob_write $B 0 \"0987654321\" } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.5.4 {\n  sqlite3_blob_close $B\n} {}\n\ndo_test 11.6.1 {\n  sqlite3_blob_open db main b2 b 6 1 B\n  sqlite3_blob_write $B 0 \"abcdefghij\"\n} {}\ndo_test 11.6.2 {\n  # Replace a different row\n  execsql { INSERT OR REPLACE INTO b2 VALUES(10, 'abcdefghij', 5) }\n  sqlite3_blob_write $B 0 \"ABCDEFGHIJ\"\n} {}\ndo_test 11.6.3 {\n  execsql { INSERT OR REPLACE INTO b2 VALUES(11, 'abcdefghij', 6) }\n  list [catch { sqlite3_blob_write $B 0 \"0987654321\" } msg] $msg\n} {1 SQLITE_ABORT}\ndo_test 11.6.4 {\n  sqlite3_blob_close $B\n} {}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-45408-40694 Changes written into a BLOB prior to the\n# BLOB expiring are not rolled back by the expiration of the BLOB. Such\n# changes will eventually commit if the transaction continues to\n# completion.\n#\ndo_execsql_test 12.1 {\n  CREATE TABLE b3(x INTEGER PRIMARY KEY, y TEXT, z INTEGER);\n  INSERT INTO b3 VALUES(22, '..........', NULL);\n}\ndo_test 12.2 {\n  sqlite3_blob_open db main b3 y 22 1 B\n  sqlite3_blob_write $B 0 \"xxxxx\" 5\n} {}\ndo_execsql_test 12.3 {\n  UPDATE b3 SET z = 'not null';\n}\ndo_test 12.4 {\n  list [catch {sqlite3_blob_write $B 5 \"xxxxx\" 5} msg] $msg\n} {1 SQLITE_ABORT}\ndo_execsql_test 12.5 {\n  SELECT * FROM b3;\n} {22 xxxxx..... {not null}}\ndo_test 12.5 {\n  sqlite3_blob_close $B\n} {}\ndo_execsql_test 12.6 {\n  SELECT * FROM b3;\n} {22 xxxxx..... {not null}}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-58813-55036 The sqlite3_bind_zeroblob() and\n# sqlite3_result_zeroblob() interfaces and the built-in zeroblob SQL\n# function may be used to create a zero-filled blob to read or write\n# using the incremental-blob interface.\n#\ndo_execsql_test 13.1 {\n  CREATE TABLE c2(i INTEGER PRIMARY KEY, j);\n  INSERT INTO c2 VALUES(10, zeroblob(24));\n}\n\ndo_test 13.2 {\n  set stmt [sqlite3_prepare_v2 db \"INSERT INTO c2 VALUES(11, ?)\" -1]\n  sqlite3_bind_zeroblob $stmt 1 45\n  sqlite3_step $stmt\n  sqlite3_finalize $stmt\n} {SQLITE_OK}\n\n# The blobs can be read:\n#\ndo_test 13.3.1 {\n  sqlite3_blob_open db main c2 j 10 1 B\n  sqlite3_blob_open db main c2 j 11 1 B2\n  list [sqlite3_blob_bytes $B] [sqlite3_blob_bytes $B2]\n} {24 45}\ndo_test 13.3.2 {\n  sqlite3_blob_read $B 0 24\n} [string repeat [binary format c 0] 24]\ndo_test 13.3.3 {\n  sqlite3_blob_read $B2 0 45\n} [string repeat [binary format c 0] 45]\n\n# And also written:\n#\ndo_test 13.4.1 {\n  sqlite3_blob_write $B 0 [string repeat [binary format c 1] 24]\n} {}\ndo_test 13.4.2 {\n  sqlite3_blob_write $B2 0 [string repeat [binary format c 1] 45]\n} {}\ndo_test 13.5 {\n  sqlite3_blob_close $B\n  sqlite3_blob_close $B2\n  execsql { SELECT j FROM c2 }\n} [list \\\n    [string repeat [binary format c 1] 24] \\\n    [string repeat [binary format c 1] 45] \\\n]\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_blobwrite.test",
    "content": "# 2014 October 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_blobwrite\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-62898-22698 This function is used to write data into an\n# open BLOB handle from a caller-supplied buffer. N bytes of data are\n# copied from the buffer Z into the open BLOB, starting at offset\n# iOffset.\n#\nset dots [string repeat . 40]\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, t TEXT);\n  INSERT INTO t1 VALUES(-1, $dots);\n  INSERT INTO t1 VALUES(-2, $dots);\n  INSERT INTO t1 VALUES(-3, $dots);\n  INSERT INTO t1 VALUES(-4, $dots);\n  INSERT INTO t1 VALUES(-5, $dots);\n  INSERT INTO t1 VALUES(-6, $dots);\n}\n\nproc blob_write_test {tn id iOffset blob nData final} {\n  sqlite3_blob_open db main t1 t $id 1 B\n\n  # EVIDENCE-OF: R-45864-01884 On success, sqlite3_blob_write() returns\n  # SQLITE_OK. Otherwise, an error code or an extended error code is\n  # returned.\n  #\n  #   This block tests the SQLITE_OK case in the requirement above (the\n  #   Tcl sqlite3_blob_write() wrapper uses an empty string in place of\n  #   \"SQLITE_OK\"). The error cases are tested by the \"blob_write_error_test\"\n  #   tests below.\n  #\n  set res [sqlite3_blob_write $B $iOffset $blob $nData]\n  uplevel [list do_test $tn.1 [list set {} $res] {}]\n\n  sqlite3_blob_close $B\n  uplevel [list do_execsql_test $tn.3 \"SELECT t FROM t1 WHERE a=$id\" $final]\n}\n\nset blob \"0123456789012345678901234567890123456789\"\nblob_write_test 1.1 -1 0 $blob 10  { 0123456789.............................. }\nblob_write_test 1.2 -2 8 $blob 10  { ........0123456789...................... }\nblob_write_test 1.3 -3 8 $blob 1   { ........0............................... }\nblob_write_test 1.4 -4 18 $blob 22 { ..................0123456789012345678901 }\nblob_write_test 1.5 -5 18 $blob 0  { ........................................ }\nblob_write_test 1.6 -6 0 $blob 40  { 0123456789012345678901234567890123456789 }\n\n\nproc blob_write_error_test {tn B iOffset blob nData errcode errmsg} {\n\n  # In cases where the underlying sqlite3_blob_write() function returns\n  # SQLITE_OK, the Tcl wrapper returns an empty string. If the underlying\n  # function returns an error, the Tcl wrapper throws an exception with\n  # the error code as the Tcl exception message.\n  #\n  if {$errcode==\"SQLITE_OK\"} {\n    set ret \"\"\n    set isError 0\n  } else {\n    set ret $errcode\n    set isError 1\n  }\n\n  set cmd [list sqlite3_blob_write $B $iOffset $blob $nData]\n  uplevel [list do_test $tn.1 [subst -nocommands {\n    list [catch {$cmd} msg] [set msg]              \n  }] [list $isError $ret]]\n\n  # EVIDENCE-OF: R-34782-18311 Unless SQLITE_MISUSE is returned, this\n  # function sets the database connection error code and message\n  # accessible via sqlite3_errcode() and sqlite3_errmsg() and related\n  # functions.\n  #\n  if {$errcode == \"SQLITE_MISUSE\"} { error \"test proc misuse!\" }\n  uplevel [list do_test $tn.2 [list sqlite3_errcode db] $errcode]\n  uplevel [list do_test $tn.3 [list sqlite3_errmsg db] $errmsg]\n}\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a TEXT, b INTEGER PRIMARY KEY);\n  INSERT INTO t2 VALUES($dots, 43);\n  INSERT INTO t2 VALUES($dots, 44);\n  INSERT INTO t2 VALUES($dots, 45);\n}\n\n# EVIDENCE-OF: R-63341-57517 If the BLOB handle passed as the first\n# argument was not opened for writing (the flags parameter to\n# sqlite3_blob_open() was zero), this function returns SQLITE_READONLY.\n#\nsqlite3_blob_open db main t2 a 43 0 B\nblob_write_error_test 2.1 $B 0 $blob 10   \\\n    SQLITE_READONLY {attempt to write a readonly database}\nsqlite3_blob_close $B\n\n# EVIDENCE-OF: R-29804-27366 If offset iOffset is less than N bytes from\n# the end of the BLOB, SQLITE_ERROR is returned and no data is written.\n#\nsqlite3_blob_open db main t2 a 44 3 B\nblob_write_error_test 2.2.1 $B 31 $blob 10   \\\n    SQLITE_ERROR {SQL logic error}\n\n# Make a successful write to the blob handle. This shows that the\n# sqlite3_errcode() and sqlite3_errmsg() values are set even if the\n# blob_write() call succeeds (see requirement in the [blob_write_error_test]\n# proc).\nblob_write_error_test 2.2.1 $B 30 $blob 10 SQLITE_OK {not an error}\n\n# EVIDENCE-OF: R-58570-38916 If N or iOffset are less than zero\n# SQLITE_ERROR is returned and no data is written.\n#\nblob_write_error_test 2.2.2 $B 31 $blob -1   \\\n    SQLITE_ERROR {SQL logic error}\nblob_write_error_test 2.2.3 $B 20 $blob 10 SQLITE_OK {not an error}\nblob_write_error_test 2.2.4 $B -1 $blob 10   \\\n    SQLITE_ERROR {SQL logic error}\nsqlite3_blob_close $B\n\n# EVIDENCE-OF: R-20958-54138 An attempt to write to an expired BLOB\n# handle fails with an error code of SQLITE_ABORT.\n#\ndo_test 2.3 {\n  sqlite3_blob_open db main t2 a 43 0 B\n  execsql { DELETE FROM t2 WHERE b=43 }\n} {}\nblob_write_error_test 2.3.1 $B 5 $blob 5 \\\n    SQLITE_ABORT {query aborted}\ndo_test 2.3.2 {\n  execsql { SELECT 1, 2, 3 }\n  sqlite3_errcode db\n} {SQLITE_OK}\nblob_write_error_test 2.3.3 $B 5 $blob 5 \\\n    SQLITE_ABORT {query aborted}\nsqlite3_blob_close $B\n\n# EVIDENCE-OF: R-08382-59936 Writes to the BLOB that occurred before the\n# BLOB handle expired are not rolled back by the expiration of the\n# handle, though of course those changes might have been overwritten by\n# the statement that expired the BLOB handle or by other independent\n# statements.\n#\n#   3.1.*: not rolled back, \n#   3.2.*: overwritten.\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE t3(i INTEGER PRIMARY KEY, j TEXT, k TEXT);\n  INSERT INTO t3 VALUES(1, $dots, $dots);\n  INSERT INTO t3 VALUES(2, $dots, $dots);\n  SELECT * FROM t3 WHERE i=1;\n} {\n  1\n  ........................................\n  ........................................\n}\nsqlite3_blob_open db main t3 j 1 1 B\nblob_write_error_test 3.1.1 $B 5 $blob 10 SQLITE_OK {not an error}\ndo_execsql_test 3.1.2 {\n  UPDATE t3 SET k = 'xyz' WHERE i=1;\n  SELECT * FROM t3 WHERE i=1;\n} {\n  1 .....0123456789......................... xyz\n}\nblob_write_error_test 3.1.3 $B 15 $blob 10 \\\n    SQLITE_ABORT {query aborted}\nsqlite3_blob_close $B\ndo_execsql_test 3.1.4 {\n  SELECT * FROM t3 WHERE i=1;\n} {\n  1 .....0123456789......................... xyz\n}\n\nsqlite3_blob_open db main t3 j 2 1 B\nblob_write_error_test 3.2.1 $B 5 $blob 10 SQLITE_OK {not an error}\ndo_execsql_test 3.2.2 {\n  UPDATE t3 SET j = 'xyz' WHERE i=2;\n  SELECT * FROM t3 WHERE i=2;\n} {\n  2 xyz ........................................\n}\nblob_write_error_test 3.2.3 $B 15 $blob 10 \\\n    SQLITE_ABORT {query aborted}\nsqlite3_blob_close $B\ndo_execsql_test 3.2.4 {\n  SELECT * FROM t3 WHERE i=2;\n} {\n  2 xyz ........................................\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_changes.test",
    "content": "# 2011 October 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_changes\n\n# Like [do_execsql_test], except it appends the value returned by \n# [db changes] to the result of executing the SQL script.\n#\nproc do_changes_test {tn sql res} {\n  uplevel [list \\\n    do_test $tn \"concat \\[execsql {$sql}\\] \\[db changes\\]\" $res\n  ]\n}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-15996-49369 This function returns the number of rows\n# modified, inserted or deleted by the most recently completed INSERT,\n# UPDATE or DELETE statement on the database connection specified by the\n# only parameter.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t2(y);\n}\nforeach {tn schema} {\n  1 { \n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(b);\n  }\n  2 { \n      CREATE TABLE t1(a, b, PRIMARY KEY(a, b)) WITHOUT ROWID;\n      CREATE INDEX i1 ON t1(b);\n  }\n} {\n  reset_db\n  execsql $schema\n\n  # Insert 1 row.\n  do_changes_test 1.$tn.1 { INSERT INTO t1 VALUES(0, 0) } 1\n\n  # Insert 10 rows.\n  do_changes_test 1.$tn.2 {\n    WITH rows(i, j) AS (\n        SELECT 1, 1 UNION ALL SELECT i+1, j+i FROM rows WHERE i<10\n    )\n    INSERT INTO t1 SELECT * FROM rows\n  } 10\n\n  # Modify 5 rows.\n  do_changes_test 1.$tn.3 {\n    UPDATE t1 SET b=b+1 WHERE a<5;\n  } 5\n\n  # Delete 4 rows\n  do_changes_test 1.$tn.4 {\n    DELETE FROM t1 WHERE a>6\n  } 4\n\n  # Check the \"on the database connecton specified\" part of hte\n  # requirement - changes made by other connections do not show up in\n  # the return value of sqlite3_changes().\n  do_test 1.$tn.5 {\n    sqlite3 db2 test.db\n    execsql { INSERT INTO t1 VALUES(-1, -1) } db2\n    db2 changes\n  } 1\n  do_test 1.$tn.6 {\n    db changes\n  } 4\n  db2 close\n\n  # Test that statements that modify no rows because they hit UNIQUE\n  # constraints set the sqlite3_changes() value to 0. Regardless of\n  # whether or not they are executed inside an explicit transaction.\n  #\n  #   1.$tn.8-9: outside of a transaction\n  #   1.$tn.10-12: inside a transaction\n  #\n  do_changes_test 1.$tn.7 {\n    CREATE UNIQUE INDEX i2 ON t1(a);\n  } 4\n  do_catchsql_test 1.$tn.8 {\n    INSERT INTO t1 VALUES('a', 0), ('b', 0), ('c', 0), (0, 11);\n  } {1 {UNIQUE constraint failed: t1.a}}\n  do_test 1.$tn.9 { db changes } 0\n  do_catchsql_test 1.$tn.10 {\n    BEGIN;\n      INSERT INTO t1 VALUES('a', 0), ('b', 0), ('c', 0), (0, 11);\n  } {1 {UNIQUE constraint failed: t1.a}}\n  do_test 1.$tn.11 { db changes } 0\n  do_changes_test 1.$tn.12 COMMIT 0\n\n}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-44877-05564 Executing any other type of SQL statement\n# does not modify the value returned by this function.\n#\nreset_db\ndo_changes_test 2.1 { CREATE TABLE t1(x)          } 0\ndo_changes_test 2.2 { \n  WITH d(y) AS (SELECT 1 UNION ALL SELECT y+1 FROM d WHERE y<47)\n  INSERT INTO t1 SELECT y FROM d;\n} 47\n\n# The statement above set changes() to 47. Check that none of the following\n# modify this.\ndo_changes_test 2.3 { SELECT count(x) FROM t1 } {47 47}\ndo_changes_test 2.4 { DROP TABLE t1               } 47\ndo_changes_test 2.5 { CREATE TABLE t1(x)          } 47\ndo_changes_test 2.6 { ALTER TABLE t1 ADD COLUMN b } 47\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-53938-27527 Only changes made directly by the INSERT,\n# UPDATE or DELETE statement are considered - auxiliary changes caused\n# by triggers, foreign key actions or REPLACE constraint resolution are\n# not counted.\n#\n#   3.1.*: triggers\n#   3.2.*: foreign key actions\n#   3.3.*: replace constraints\n#\nreset_db\ndo_execsql_test 3.1.0 {\n  CREATE TABLE log(x);\n  CREATE TABLE p1(one PRIMARY KEY, two);\n\n  CREATE TRIGGER tr_ai AFTER INSERT ON p1 BEGIN\n    INSERT INTO log VALUES('insert');\n  END;\n  CREATE TRIGGER tr_bd BEFORE DELETE ON p1 BEGIN\n    INSERT INTO log VALUES('delete');\n  END;\n  CREATE TRIGGER tr_au AFTER UPDATE ON p1 BEGIN\n    INSERT INTO log VALUES('update');\n  END;\n\n}\n\ndo_changes_test 3.1.1 {\n  INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');\n} 3\ndo_changes_test 3.1.2 {\n  UPDATE p1 SET two = two||two;\n} 3\ndo_changes_test 3.1.3 {\n  DELETE FROM p1 WHERE one IN ('a', 'c');\n} 2\ndo_execsql_test 3.1.4 {\n  -- None of the inserts on table log were counted.\n  SELECT count(*) FROM log\n} 8\n\ndo_execsql_test 3.2.0 {\n  DELETE FROM p1;\n  INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');\n\n  CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET NULL);\n  CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET DEFAULT);\n  CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE CASCADE);\n  INSERT INTO c1 VALUES('a', 'aaa');\n  INSERT INTO c2 VALUES('b', 'bbb');\n  INSERT INTO c3 VALUES('c', 'ccc');\n\n  INSERT INTO p1 VALUES('d', 'D'), ('e', 'E'), ('f', 'F');\n  CREATE TABLE c4(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET NULL);\n  CREATE TABLE c5(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET DEFAULT);\n  CREATE TABLE c6(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE CASCADE);\n  INSERT INTO c4 VALUES('d', 'aaa');\n  INSERT INTO c5 VALUES('e', 'bbb');\n  INSERT INTO c6 VALUES('f', 'ccc');\n\n  PRAGMA foreign_keys = ON;\n}\n\ndo_changes_test 3.2.1 { DELETE FROM p1 WHERE one = 'a' } 1\ndo_changes_test 3.2.2 { DELETE FROM p1 WHERE one = 'b' } 1\ndo_changes_test 3.2.3 { DELETE FROM p1 WHERE one = 'c' } 1\ndo_execsql_test 3.2.4 { \n  SELECT * FROM c1;\n  SELECT * FROM c2;\n  SELECT * FROM c3;\n} {{} aaa {} bbb}\n\ndo_changes_test 3.2.5 { UPDATE p1 SET one = 'g' WHERE one = 'd' } 1\ndo_changes_test 3.2.6 { UPDATE p1 SET one = 'h' WHERE one = 'e' } 1\ndo_changes_test 3.2.7 { UPDATE p1 SET one = 'i' WHERE one = 'f' } 1\ndo_execsql_test 3.2.8 { \n  SELECT * FROM c4;\n  SELECT * FROM c5;\n  SELECT * FROM c6;\n} {{} aaa {} bbb i ccc}\n\ndo_execsql_test 3.3.0 {\n  CREATE TABLE r1(a UNIQUE, b UNIQUE);\n  INSERT INTO r1 VALUES('i', 'i');\n  INSERT INTO r1 VALUES('ii', 'ii');\n  INSERT INTO r1 VALUES('iii', 'iii');\n  INSERT INTO r1 VALUES('iv', 'iv');\n  INSERT INTO r1 VALUES('v', 'v');\n  INSERT INTO r1 VALUES('vi', 'vi');\n  INSERT INTO r1 VALUES('vii', 'vii');\n}\n\ndo_changes_test 3.3.1 { INSERT OR REPLACE INTO r1 VALUES('i', 1)    }   1\ndo_changes_test 3.3.2 { INSERT OR REPLACE INTO r1 VALUES('iv', 'v') }   1\ndo_changes_test 3.3.3 { UPDATE OR REPLACE r1 SET b='v' WHERE a='iii' }  1\ndo_changes_test 3.3.4 { UPDATE OR REPLACE r1 SET b='vi',a='vii' WHERE a='ii' } 1\ndo_execsql_test 3.3.5 { \n  SELECT * FROM r1 ORDER BY a;\n} {i 1   iii v   vii vi}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-09813-48563 The value returned by sqlite3_changes()\n# immediately after an INSERT, UPDATE or DELETE statement run on a view\n# is always zero.\n#\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE log(log);\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n\n  CREATE VIEW v1 AS SELECT * FROM t1;\n  CREATE TRIGGER v1_i INSTEAD OF INSERT ON v1 BEGIN\n    INSERT INTO log VALUES('insert');\n  END;\n  CREATE TRIGGER v1_u INSTEAD OF UPDATE ON v1 BEGIN\n    INSERT INTO log VALUES('update'), ('update');\n  END;\n  CREATE TRIGGER v1_d INSTEAD OF DELETE ON v1 BEGIN\n    INSERT INTO log VALUES('delete'), ('delete'), ('delete');\n  END;\n}\n\ndo_changes_test 4.2.1 { INSERT INTO t1 SELECT * FROM t1 }  3\ndo_changes_test 4.2.2 { INSERT INTO v1 VALUES(1, 2) }      0\n\ndo_changes_test 4.3.1 { INSERT INTO t1 SELECT * FROM t1 }  6\ndo_changes_test 4.3.2 { UPDATE v1 SET y='xyz' WHERE x=1 }  0\n\ndo_changes_test 4.4.1 { INSERT INTO t1 SELECT * FROM t1 } 12\ndo_changes_test 4.4.2 { DELETE FROM v1 WHERE x=5 }         0\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-32918-61474 Before entering a trigger program the value\n# returned by sqlite3_changes() function is saved. After the trigger\n# program has finished, the original value is restored.\n#\nreset_db\ndb func my_changes my_changes\nset ::changes [list]\nproc my_changes {x} {\n  set res [db changes]\n  lappend ::changes $x $res\n  return $res\n}\n\ndo_execsql_test 5.1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t2(x);\n  INSERT INTO t1 VALUES(1, NULL);\n  INSERT INTO t1 VALUES(2, NULL);\n  INSERT INTO t1 VALUES(3, NULL);\n  CREATE TRIGGER AFTER UPDATE ON t1 BEGIN\n    INSERT INTO t2 VALUES('a'), ('b'), ('c');\n    SELECT my_changes('trigger');\n  END;\n}\n\ndo_execsql_test 5.1.1 {\n  INSERT INTO t2 VALUES('a'), ('b');\n  UPDATE t1 SET b = my_changes('update');\n  SELECT * FROM t1;\n} {1 2 2 2 3 2}\n\n# Value is being restored to \"2\" when the trigger program exits.\ndo_test 5.1.2 {\n  set ::changes\n} {update 2 trigger 3 update 2 trigger 3 update 2 trigger 3}\n\n\nreset_db\ndo_execsql_test 5.2.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE log(x);\n  INSERT INTO t1 VALUES(1, 0);\n  INSERT INTO t1 VALUES(2, 0);\n  INSERT INTO t1 VALUES(3, 0);\n  CREATE TRIGGER t1_a_u AFTER UPDATE ON t1 BEGIN\n    INSERT INTO log VALUES(old.b || ' -> ' || new.b || ' c = ' || changes() );\n  END;\n  CREATE TABLE t2(a);\n  INSERT INTO t2 VALUES(1), (2), (3);\n  UPDATE t1 SET b = changes();\n}\ndo_execsql_test 5.2.1 {\n  SELECT * FROM t1;\n} {1 3 2 3 3 3}\ndo_execsql_test 5.2.2 {\n  SELECT * FROM log;\n} {{0 -> 3 c = 3} {0 -> 3 c = 3} {0 -> 3 c = 3}}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-17146-37073 Within a trigger program each INSERT,\n# UPDATE and DELETE statement sets the value returned by\n# sqlite3_changes() upon completion as normal. Of course, this value\n# will not include any changes performed by sub-triggers, as the\n# sqlite3_changes() value will be saved and restored after each\n# sub-trigger has run.\nreset_db\ndo_execsql_test 6.0 {\n\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE TABLE t3(a, b);\n  CREATE TABLE log(x);\n\n  CREATE TRIGGER t1_i BEFORE INSERT ON t1 BEGIN\n    INSERT INTO t2 VALUES(new.a, new.b), (new.a, new.b);\n    INSERT INTO log VALUES('t2->' || changes());\n  END;\n\n  CREATE TRIGGER t2_i AFTER INSERT ON t2 BEGIN\n    INSERT INTO t3 VALUES(new.a, new.b), (new.a, new.b), (new.a, new.b);\n    INSERT INTO log VALUES('t3->' || changes());\n  END;\n\n  CREATE TRIGGER t1_u AFTER UPDATE ON t1 BEGIN\n    UPDATE t2 SET b=new.b WHERE a=old.a;\n    INSERT INTO log VALUES('t2->' || changes());\n  END;\n\n  CREATE TRIGGER t2_u BEFORE UPDATE ON t2 BEGIN\n    UPDATE t3 SET b=new.b WHERE a=old.a;\n    INSERT INTO log VALUES('t3->' || changes());\n  END;\n\n  CREATE TRIGGER t1_d AFTER DELETE ON t1 BEGIN\n    DELETE FROM t2 WHERE a=old.a AND b=old.b;\n    INSERT INTO log VALUES('t2->' || changes());\n  END;\n\n  CREATE TRIGGER t2_d BEFORE DELETE ON t2 BEGIN\n    DELETE FROM t3 WHERE a=old.a AND b=old.b;\n    INSERT INTO log VALUES('t3->' || changes());\n  END;\n}\n\ndo_changes_test 6.1 {\n  INSERT INTO t1 VALUES('+', 'o');\n  SELECT * FROM log;\n} {t3->3 t3->3 t2->2 1}\n\ndo_changes_test 6.2 {\n  DELETE FROM log;\n  UPDATE t1 SET b='*';\n  SELECT * FROM log;\n} {t3->6 t3->6 t2->2 1}\n\ndo_changes_test 6.3 {\n  DELETE FROM log;\n  DELETE FROM t1;\n  SELECT * FROM log;\n} {t3->6 t3->0 t2->2 1}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-43399-09409 This means that if the changes() SQL\n# function (or similar) is used by the first INSERT, UPDATE or DELETE\n# statement within a trigger, it returns the value as set when the\n# calling statement began executing.\n#\n# EVIDENCE-OF: R-53215-27584 If it is used by the second or subsequent\n# such statement within a trigger program, the value returned reflects\n# the number of rows modified by the previous INSERT, UPDATE or DELETE\n# statement within the same trigger.\n#\nreset_db\ndo_execsql_test 7.1 {\n  CREATE TABLE q1(t);\n  CREATE TABLE q2(u, v);\n  CREATE TABLE q3(w);\n\n  CREATE TRIGGER q2_insert BEFORE INSERT ON q2 BEGIN\n\n    /* changes() returns value from previous I/U/D in callers context */\n    INSERT INTO q1 VALUES('1:' || changes());\n\n    /* changes() returns value of previous I/U/D in this context */\n    INSERT INTO q3 VALUES(changes()), (2), (3);\n    INSERT INTO q1 VALUES('2:' || changes());\n    INSERT INTO q3 VALUES(changes() + 3), (changes()+4);\n    SELECT 'this does not affect things!';\n    INSERT INTO q1 VALUES('3:' || changes());\n    UPDATE q3 SET w = w+10 WHERE w%2;\n    INSERT INTO q1 VALUES('4:' || changes());\n    DELETE FROM q3;\n    INSERT INTO q1 VALUES('5:' || changes());\n  END;\n}\n\ndo_execsql_test 7.2 {\n  INSERT INTO q2 VALUES('x', 'y');\n  SELECT * FROM q1;\n} {\n  1:0   2:3   3:2   4:3   5:5\n}\n\ndo_execsql_test 7.3 {\n  DELETE FROM q1;\n  INSERT INTO q2 VALUES('x', 'y');\n  SELECT * FROM q1;\n} {\n  1:5   2:3   3:2   4:3   5:5\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_createtable.test",
    "content": "# 2010 September 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_createtable.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix e_createtable\n\n# Test organization:\n#\n#   e_createtable-0.*: Test that the syntax diagrams are correct.\n#\n#   e_createtable-1.*: Test statements related to table and database names, \n#       the TEMP and TEMPORARY keywords, and the IF NOT EXISTS clause.\n#\n#   e_createtable-2.*: Test \"CREATE TABLE AS\" statements.\n#\n\nproc do_createtable_tests {nm args} {\n  uplevel do_select_tests [list e_createtable-$nm] $args\n}\n\n\n#-------------------------------------------------------------------------\n# This command returns a serialized tcl array mapping from the name of\n# each attached database to a list of tables in that database. For example,\n# if the database schema is created with:\n#\n#   CREATE TABLE t1(x);\n#   CREATE TEMP TABLE t2(x);\n#   CREATE TEMP TABLE t3(x);\n#\n# Then this command returns \"main t1 temp {t2 t3}\".\n#\nproc table_list {} {\n  set res [list]\n  db eval { pragma database_list } a {\n    set dbname $a(name)\n    set master $a(name).sqlite_master\n    if {$dbname == \"temp\"} { set master sqlite_temp_master }\n    lappend res $dbname [\n      db eval \"SELECT DISTINCT tbl_name FROM $master ORDER BY tbl_name\"\n    ]\n  }\n  set res\n}\n\n\ndo_createtable_tests 0.1.1 -repair {\n  drop_all_tables\n} {\n  1   \"CREATE TABLE t1(c1 one)\"                        {}\n  2   \"CREATE TABLE t1(c1 one two)\"                    {}\n  3   \"CREATE TABLE t1(c1 one two three)\"              {}\n  4   \"CREATE TABLE t1(c1 one two three four)\"         {}\n  5   \"CREATE TABLE t1(c1 one two three four(14))\"     {}\n  6   \"CREATE TABLE t1(c1 one two three four(14, 22))\" {}\n  7   \"CREATE TABLE t1(c1 var(+14, -22.3))\"            {}\n  8   \"CREATE TABLE t1(c1 var(1.0e10))\"                {}\n}\ndo_createtable_tests 0.1.2 -error {\n  near \"%s\": syntax error\n} {\n  1   \"CREATE TABLE t1(c1 one(number))\"                {number}\n}\n\n\n# syntax diagram column-constraint\n#\ndo_createtable_tests 0.2.1 -repair {\n  drop_all_tables \n  execsql { CREATE TABLE t2(x PRIMARY KEY) }\n} {\n  1.1   \"CREATE TABLE t1(c1 text PRIMARY KEY)\"                         {}\n  1.2   \"CREATE TABLE t1(c1 text PRIMARY KEY ASC)\"                     {}\n  1.3   \"CREATE TABLE t1(c1 text PRIMARY KEY DESC)\"                    {}\n  1.4   \"CREATE TABLE t1(c1 text CONSTRAINT cons PRIMARY KEY DESC)\"    {}\n\n  2.1   \"CREATE TABLE t1(c1 text NOT NULL)\"                            {}\n  2.2   \"CREATE TABLE t1(c1 text CONSTRAINT nm NOT NULL)\"              {}\n  2.3   \"CREATE TABLE t1(c1 text NULL)\"                                {}\n  2.4   \"CREATE TABLE t1(c1 text CONSTRAINT nm NULL)\"                  {}\n\n  3.1   \"CREATE TABLE t1(c1 text UNIQUE)\"                              {}\n  3.2   \"CREATE TABLE t1(c1 text CONSTRAINT un UNIQUE)\"                {}\n\n  4.1   \"CREATE TABLE t1(c1 text CHECK(c1!=0))\"                        {}\n  4.2   \"CREATE TABLE t1(c1 text CONSTRAINT chk CHECK(c1!=0))\"         {}\n\n  5.1   \"CREATE TABLE t1(c1 text DEFAULT 1)\"                           {}\n  5.2   \"CREATE TABLE t1(c1 text DEFAULT -1)\"                          {}\n  5.3   \"CREATE TABLE t1(c1 text DEFAULT +1)\"                          {}\n  5.4   \"CREATE TABLE t1(c1 text DEFAULT -45.8e22)\"                    {}\n  5.5   \"CREATE TABLE t1(c1 text DEFAULT (1+1))\"                       {}\n  5.6   \"CREATE TABLE t1(c1 text CONSTRAINT \\\"1 2\\\" DEFAULT (1+1))\"    {}\n\n  6.1   \"CREATE TABLE t1(c1 text COLLATE nocase)\"        {}\n  6.2   \"CREATE TABLE t1(c1 text CONSTRAINT 'a x' COLLATE nocase)\"     {}\n\n  7.1   \"CREATE TABLE t1(c1 REFERENCES t2)\"                            {}\n  7.2   \"CREATE TABLE t1(c1 CONSTRAINT abc REFERENCES t2)\"             {}\n\n  8.1   {\n    CREATE TABLE t1(c1 \n      PRIMARY KEY NOT NULL UNIQUE CHECK(c1 IS 'ten') DEFAULT 123 REFERENCES t1\n    );\n  } {}\n  8.2   {\n    CREATE TABLE t1(c1 \n      REFERENCES t1 DEFAULT 123 CHECK(c1 IS 'ten') UNIQUE NOT NULL PRIMARY KEY \n    );\n  } {}\n}\n\n# -- syntax diagram table-constraint\n#\ndo_createtable_tests 0.3.1 -repair {\n  drop_all_tables \n  execsql { CREATE TABLE t2(x PRIMARY KEY) }\n} {\n  1.1   \"CREATE TABLE t1(c1, c2, PRIMARY KEY(c1))\"                         {}\n  1.2   \"CREATE TABLE t1(c1, c2, PRIMARY KEY(c1, c2))\"                     {}\n  1.3   \"CREATE TABLE t1(c1, c2, PRIMARY KEY(c1, c2) ON CONFLICT IGNORE)\"  {}\n\n  2.1   \"CREATE TABLE t1(c1, c2, UNIQUE(c1))\"                              {}\n  2.2   \"CREATE TABLE t1(c1, c2, UNIQUE(c1, c2))\"                          {}\n  2.3   \"CREATE TABLE t1(c1, c2, UNIQUE(c1, c2) ON CONFLICT IGNORE)\"       {}\n\n  3.1   \"CREATE TABLE t1(c1, c2, CHECK(c1 IS NOT c2))\"                     {}\n\n  4.1   \"CREATE TABLE t1(c1, c2, FOREIGN KEY(c1) REFERENCES t2)\"           {}\n}\n\n# -- syntax diagram column-def\n#\ndo_createtable_tests 0.4.1 -repair {\n  drop_all_tables \n} {\n  1     {CREATE TABLE t1(\n           col1,\n           col2 TEXT,\n           col3 INTEGER UNIQUE,\n           col4 VARCHAR(10, 10) PRIMARY KEY,\n           \"name with spaces\" REFERENCES t1\n         );\n        } {}\n}\n\n# -- syntax diagram create-table-stmt\n#\ndo_createtable_tests 0.5.1 -repair {\n  drop_all_tables \n  execsql { CREATE TABLE t2(a, b, c) }\n} {\n  1     \"CREATE TABLE t1(a, b, c)\"                                    {}\n  2     \"CREATE TEMP TABLE t1(a, b, c)\"                               {}\n  3     \"CREATE TEMPORARY TABLE t1(a, b, c)\"                          {}\n  4     \"CREATE TABLE IF NOT EXISTS t1(a, b, c)\"                      {}\n  5     \"CREATE TEMP TABLE IF NOT EXISTS t1(a, b, c)\"                 {}\n  6     \"CREATE TEMPORARY TABLE IF NOT EXISTS t1(a, b, c)\"            {}\n\n  7     \"CREATE TABLE main.t1(a, b, c)\"                               {}\n  8     \"CREATE TEMP TABLE temp.t1(a, b, c)\"                          {}\n  9     \"CREATE TEMPORARY TABLE temp.t1(a, b, c)\"                     {}\n  10    \"CREATE TABLE IF NOT EXISTS main.t1(a, b, c)\"                 {}\n  11    \"CREATE TEMP TABLE IF NOT EXISTS temp.t1(a, b, c)\"            {}\n  12    \"CREATE TEMPORARY TABLE IF NOT EXISTS temp.t1(a, b, c)\"       {}\n\n  13    \"CREATE TABLE t1 AS SELECT * FROM t2\"                         {}\n  14    \"CREATE TEMP TABLE t1 AS SELECT c, b, a FROM t2\"              {}\n  15    \"CREATE TABLE t1 AS SELECT count(*), max(b), min(a) FROM t2\"  {}\n}\n\n#\n#   1:         Explicit parent-key columns.\n#   2:         Implicit child-key columns.\n#\n#   1:         MATCH FULL\n#   2:         MATCH PARTIAL\n#   3:         MATCH SIMPLE\n#   4:         MATCH STICK\n#   5:         \n#\n#   1:         ON DELETE SET NULL\n#   2:         ON DELETE SET DEFAULT\n#   3:         ON DELETE CASCADE\n#   4:         ON DELETE RESTRICT\n#   5:         ON DELETE NO ACTION\n#   6:\n#\n#   1:         ON UPDATE SET NULL\n#   2:         ON UPDATE SET DEFAULT\n#   3:         ON UPDATE CASCADE\n#   4:         ON UPDATE RESTRICT\n#   5:         ON UPDATE NO ACTION\n#   6:\n#\n#   1:         NOT DEFERRABLE INITIALLY DEFERRED\n#   2:         NOT DEFERRABLE INITIALLY IMMEDIATE\n#   3:         NOT DEFERRABLE\n#   4:         DEFERRABLE INITIALLY DEFERRED\n#   5:         DEFERRABLE INITIALLY IMMEDIATE\n#   6:         DEFERRABLE\n#   7:         \n#\ndo_createtable_tests 0.6.1 -repair {\n  drop_all_tables \n  execsql { CREATE TABLE t2(x PRIMARY KEY, y) }\n  execsql { CREATE TABLE t3(i, j, UNIQUE(i, j) ) }\n} {\n  11146 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH FULL \n    ON DELETE SET NULL ON UPDATE RESTRICT DEFERRABLE\n  )} {}\n  11412 { CREATE TABLE t1(a \n    REFERENCES t2(x) \n    ON DELETE RESTRICT ON UPDATE SET NULL MATCH FULL \n    NOT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  12135 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH PARTIAL \n    ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  12427 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH PARTIAL \n    ON DELETE RESTRICT ON UPDATE SET DEFAULT \n  )} {}\n  12446 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH PARTIAL \n    ON DELETE RESTRICT ON UPDATE RESTRICT DEFERRABLE\n  )} {}\n  12522 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH PARTIAL \n    ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  13133 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE SET NULL ON UPDATE CASCADE NOT DEFERRABLE\n  )} {}\n  13216 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE SET DEFAULT ON UPDATE SET NULL DEFERRABLE\n  )} {}\n  13263 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE SET DEFAULT  NOT DEFERRABLE\n  )} {}\n  13421 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE RESTRICT ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY DEFERRED\n  )} {}\n  13432 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE RESTRICT ON UPDATE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  13523 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH SIMPLE \n    ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE\n  )} {}\n  14336 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH STICK \n    ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE\n  )} {}\n  14611 { CREATE TABLE t1(a \n    REFERENCES t2(x) MATCH STICK \n    ON UPDATE SET NULL NOT DEFERRABLE INITIALLY DEFERRED\n  )} {}\n  15155 { CREATE TABLE t1(a \n    REFERENCES t2(x)\n    ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  15453 { CREATE TABLE t1(a \n    REFERENCES t2(x) ON DELETE RESTRICT ON UPDATE NO ACTION NOT DEFERRABLE\n  )} {}\n  15661 { CREATE TABLE t1(a \n    REFERENCES t2(x) NOT DEFERRABLE INITIALLY DEFERRED\n  )} {}\n  21115 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH FULL \n    ON DELETE SET NULL ON UPDATE SET NULL DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  21123 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH FULL \n    ON DELETE SET NULL ON UPDATE SET DEFAULT NOT DEFERRABLE\n  )} {}\n  21217 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH FULL ON DELETE SET DEFAULT ON UPDATE SET NULL \n  )} {}\n  21362 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH FULL \n    ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  22143 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH PARTIAL \n    ON DELETE SET NULL ON UPDATE RESTRICT NOT DEFERRABLE\n  )} {}\n  22156 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH PARTIAL \n    ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE\n  )} {}\n  22327 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH PARTIAL ON DELETE CASCADE ON UPDATE SET DEFAULT \n  )} {}\n  22663 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH PARTIAL NOT DEFERRABLE\n  )} {}\n  23236 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH SIMPLE \n    ON DELETE SET DEFAULT ON UPDATE CASCADE DEFERRABLE\n  )} {}\n  24155 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH STICK \n    ON DELETE SET NULL ON UPDATE NO ACTION DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  24522 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH STICK \n    ON DELETE NO ACTION ON UPDATE SET DEFAULT NOT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  24625 { CREATE TABLE t1(a \n    REFERENCES t2 MATCH STICK \n    ON UPDATE SET DEFAULT DEFERRABLE INITIALLY IMMEDIATE\n  )} {}\n  25454 { CREATE TABLE t1(a \n    REFERENCES t2 \n    ON DELETE RESTRICT ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED\n  )} {}\n}\n\n#-------------------------------------------------------------------------\n# Test cases e_createtable-1.* - test statements related to table and\n# database names, the TEMP and TEMPORARY keywords, and the IF NOT EXISTS\n# clause.\n#\ndrop_all_tables\nforcedelete test.db2 test.db3\n\ndo_execsql_test e_createtable-1.0 {\n  ATTACH 'test.db2' AS auxa;\n  ATTACH 'test.db3' AS auxb;\n} {}\n\n# EVIDENCE-OF: R-17899-04554 Table names that begin with \"sqlite_\" are\n# reserved for internal use. It is an error to attempt to create a table\n# with a name that starts with \"sqlite_\".\n#\ndo_createtable_tests 1.1.1 -error {\n  object name reserved for internal use: %s\n} {\n  1    \"CREATE TABLE sqlite_abc(a, b, c)\"        sqlite_abc\n  2    \"CREATE TABLE temp.sqlite_helloworld(x)\"  sqlite_helloworld\n  3    {CREATE TABLE auxa.\"sqlite__\"(x, y)}      sqlite__\n  4    {CREATE TABLE auxb.\"sqlite_\"(z)}          sqlite_\n  5    {CREATE TABLE \"SQLITE_TBL\"(z)}            SQLITE_TBL\n}\ndo_createtable_tests 1.1.2 {\n  1    \"CREATE TABLE sqlit_abc(a, b, c)\"         {}\n  2    \"CREATE TABLE temp.sqlitehelloworld(x)\"   {}\n  3    {CREATE TABLE auxa.\"sqlite\"(x, y)}        {}\n  4    {CREATE TABLE auxb.\"sqlite-\"(z)}          {}\n  5    {CREATE TABLE \"SQLITE-TBL\"(z)}            {}\n}\n\n\n# EVIDENCE-OF: R-18448-33677 If a schema-name is specified, it must be\n# either \"main\", \"temp\", or the name of an attached database.\n#\n# EVIDENCE-OF: R-39822-07822 In this case the new table is created in\n# the named database.\n#\n#   Test cases 1.2.* test the first of the two requirements above. The\n#   second is verified by cases 1.3.*.\n#\ndo_createtable_tests 1.2.1 -error {\n  unknown database %s\n} {\n  1    \"CREATE TABLE george.t1(a, b)\"            george\n  2    \"CREATE TABLE _.t1(a, b)\"                 _\n}\ndo_createtable_tests 1.2.2 {\n  1    \"CREATE TABLE main.abc(a, b, c)\"          {}\n  2    \"CREATE TABLE temp.helloworld(x)\"         {}\n  3    {CREATE TABLE auxa.\"t 1\"(x, y)}           {}\n  4    {CREATE TABLE auxb.xyz(z)}                {}\n}\ndrop_all_tables\ndo_createtable_tests 1.3 -tclquery {\n  unset -nocomplain X\n  array set X [table_list]\n  list $X(main) $X(temp) $X(auxa) $X(auxb)\n} {\n  1    \"CREATE TABLE main.abc(a, b, c)\"  {abc {} {} {}}\n  2    \"CREATE TABLE main.t1(a, b, c)\"   {{abc t1} {} {} {}}\n  3    \"CREATE TABLE temp.tmp(a, b, c)\"  {{abc t1} tmp {} {}}\n  4    \"CREATE TABLE auxb.tbl(x, y)\"     {{abc t1} tmp {} tbl}\n  5    \"CREATE TABLE auxb.t1(k, v)\"      {{abc t1} tmp {} {t1 tbl}}\n  6    \"CREATE TABLE auxa.next(c, d)\"    {{abc t1} tmp next {t1 tbl}}\n}\n\n# EVIDENCE-OF: R-18895-27365 If the \"TEMP\" or \"TEMPORARY\" keyword occurs\n# between the \"CREATE\" and \"TABLE\" then the new table is created in the\n# temp database.\n#\ndrop_all_tables\ndo_createtable_tests 1.4 -tclquery {\n  unset -nocomplain X\n  array set X [table_list]\n  list $X(main) $X(temp) $X(auxa) $X(auxb)\n} {\n  1    \"CREATE TEMP TABLE t1(a, b)\"      {{} t1 {} {}}\n  2    \"CREATE TEMPORARY TABLE t2(a, b)\" {{} {t1 t2} {} {}}\n}\n\n# EVIDENCE-OF: R-23976-43329 It is an error to specify both a\n# schema-name and the TEMP or TEMPORARY keyword, unless the schema-name\n# is \"temp\".\n#\ndrop_all_tables\ndo_createtable_tests 1.5.1 -error {\n  temporary table name must be unqualified\n} {\n  1    \"CREATE TEMP TABLE main.t1(a, b)\"        {}\n  2    \"CREATE TEMPORARY TABLE auxa.t2(a, b)\"   {}\n  3    \"CREATE TEMP TABLE auxb.t3(a, b)\"        {}\n  4    \"CREATE TEMPORARY TABLE main.xxx(x)\"     {}\n}\ndrop_all_tables\ndo_createtable_tests 1.5.2 -tclquery {\n  unset -nocomplain X\n  array set X [table_list]\n  list $X(main) $X(temp) $X(auxa) $X(auxb)\n} {\n  1    \"CREATE TEMP TABLE temp.t1(a, b)\"        {{} t1 {} {}}\n  2    \"CREATE TEMPORARY TABLE temp.t2(a, b)\"   {{} {t1 t2} {} {}}\n  3    \"CREATE TEMP TABLE TEMP.t3(a, b)\"        {{} {t1 t2 t3} {} {}}\n  4    \"CREATE TEMPORARY TABLE TEMP.xxx(x)\"     {{} {t1 t2 t3 xxx} {} {}}\n}\n\n# EVIDENCE-OF: R-31997-24564 If no schema name is specified and the TEMP\n# keyword is not present then the table is created in the main database.\n#\ndrop_all_tables\ndo_createtable_tests 1.6 -tclquery {\n  unset -nocomplain X\n  array set X [table_list]\n  list $X(main) $X(temp) $X(auxa) $X(auxb)\n} {\n  1    \"CREATE TABLE t1(a, b)\"   {t1 {} {} {}}\n  2    \"CREATE TABLE t2(a, b)\"   {{t1 t2} {} {} {}}\n  3    \"CREATE TABLE t3(a, b)\"   {{t1 t2 t3} {} {} {}}\n  4    \"CREATE TABLE xxx(x)\"     {{t1 t2 t3 xxx} {} {} {}}\n}\n\ndrop_all_tables\ndo_execsql_test e_createtable-1.7.0 {\n  CREATE TABLE t1(x, y);\n  CREATE INDEX i1 ON t1(x);\n  CREATE VIEW  v1 AS SELECT * FROM t1;\n\n  CREATE TABLE auxa.tbl1(x, y);\n  CREATE INDEX auxa.idx1 ON tbl1(x);\n  CREATE VIEW auxa.view1 AS SELECT * FROM tbl1;\n} {}\n\n# EVIDENCE-OF: R-01232-54838 It is usually an error to attempt to create\n# a new table in a database that already contains a table, index or view\n# of the same name.\n#\n#   Test cases 1.7.1.* verify that creating a table in a database with a\n#   table/index/view of the same name does fail. 1.7.2.* tests that creating\n#   a table with the same name as a table/index/view in a different database\n#   is Ok.\n#\ndo_createtable_tests 1.7.1 -error { %s } {\n  1    \"CREATE TABLE t1(a, b)\"   {{table t1 already exists}}\n  2    \"CREATE TABLE i1(a, b)\"   {{there is already an index named i1}}\n  3    \"CREATE TABLE v1(a, b)\"   {{table v1 already exists}}\n  4    \"CREATE TABLE auxa.tbl1(a, b)\"   {{table tbl1 already exists}}\n  5    \"CREATE TABLE auxa.idx1(a, b)\"   {{there is already an index named idx1}}\n  6    \"CREATE TABLE auxa.view1(a, b)\"  {{table view1 already exists}}\n}\ndo_createtable_tests 1.7.2 {\n  1    \"CREATE TABLE auxa.t1(a, b)\"   {}\n  2    \"CREATE TABLE auxa.i1(a, b)\"   {}\n  3    \"CREATE TABLE auxa.v1(a, b)\"   {}\n  4    \"CREATE TABLE tbl1(a, b)\"      {}\n  5    \"CREATE TABLE idx1(a, b)\"      {}\n  6    \"CREATE TABLE view1(a, b)\"     {}\n}\n\n# EVIDENCE-OF: R-33917-24086 However, if the \"IF NOT EXISTS\" clause is\n# specified as part of the CREATE TABLE statement and a table or view of\n# the same name already exists, the CREATE TABLE command simply has no\n# effect (and no error message is returned).\n#\ndrop_all_tables\ndo_execsql_test e_createtable-1.8.0 {\n  CREATE TABLE t1(x, y);\n  CREATE INDEX i1 ON t1(x);\n  CREATE VIEW  v1 AS SELECT * FROM t1;\n  CREATE TABLE auxa.tbl1(x, y);\n  CREATE INDEX auxa.idx1 ON tbl1(x);\n  CREATE VIEW auxa.view1 AS SELECT * FROM tbl1;\n} {}\ndo_createtable_tests 1.8 {\n  1    \"CREATE TABLE IF NOT EXISTS t1(a, b)\"          {}\n  2    \"CREATE TABLE IF NOT EXISTS auxa.tbl1(a, b)\"   {}\n  3    \"CREATE TABLE IF NOT EXISTS v1(a, b)\"          {}\n  4    \"CREATE TABLE IF NOT EXISTS auxa.view1(a, b)\"  {}\n}\n\n# EVIDENCE-OF: R-16465-40078 An error is still returned if the table\n# cannot be created because of an existing index, even if the \"IF NOT\n# EXISTS\" clause is specified.\n#\ndo_createtable_tests 1.9 -error { %s } {\n  1    \"CREATE TABLE IF NOT EXISTS i1(a, b)\"   \n       {{there is already an index named i1}}\n  2    \"CREATE TABLE IF NOT EXISTS auxa.idx1(a, b)\"   \n       {{there is already an index named idx1}}\n}\n\n# EVIDENCE-OF: R-05513-33819 It is not an error to create a table that\n# has the same name as an existing trigger.\n#\ndrop_all_tables\ndo_execsql_test e_createtable-1.10.0 {\n  CREATE TABLE t1(x, y);\n  CREATE TABLE auxb.t2(x, y);\n\n  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n    SELECT 1;\n  END;\n  CREATE TRIGGER auxb.tr2 AFTER INSERT ON t2 BEGIN\n    SELECT 1;\n  END;\n} {}\ndo_createtable_tests 1.10 {\n  1    \"CREATE TABLE tr1(a, b)\"          {}\n  2    \"CREATE TABLE tr2(a, b)\"          {}\n  3    \"CREATE TABLE auxb.tr1(a, b)\"     {}\n  4    \"CREATE TABLE auxb.tr2(a, b)\"     {}\n}\n\n# EVIDENCE-OF: R-22283-14179 Tables are removed using the DROP TABLE\n# statement.\n#\ndrop_all_tables\ndo_execsql_test e_createtable-1.11.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE TABLE auxa.t3(a, b);\n  CREATE TABLE auxa.t4(a, b);\n} {}\n\ndo_execsql_test e_createtable-1.11.1.1 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n  SELECT * FROM t3;\n  SELECT * FROM t4;\n} {}\ndo_execsql_test  e_createtable-1.11.1.2 { DROP TABLE t1 } {}\ndo_catchsql_test e_createtable-1.11.1.3 { \n  SELECT * FROM t1 \n} {1 {no such table: t1}}\ndo_execsql_test  e_createtable-1.11.1.4 { DROP TABLE t3 } {}\ndo_catchsql_test e_createtable-1.11.1.5 { \n  SELECT * FROM t3 \n} {1 {no such table: t3}}\n\ndo_execsql_test e_createtable-1.11.2.1 {\n  SELECT name FROM sqlite_master;\n  SELECT name FROM auxa.sqlite_master;\n} {t2 t4}\ndo_execsql_test  e_createtable-1.11.2.2 { DROP TABLE t2 } {}\ndo_execsql_test  e_createtable-1.11.2.3 { DROP TABLE t4 } {}\ndo_execsql_test e_createtable-1.11.2.4 {\n  SELECT name FROM sqlite_master;\n  SELECT name FROM auxa.sqlite_master;\n} {}\n\n#-------------------------------------------------------------------------\n# Test cases e_createtable-2.* - test statements related to the CREATE\n# TABLE AS ... SELECT statement.\n#\n\n# Three Tcl commands:\n#\n#   select_column_names SQL\n#     The argument must be a SELECT statement. Return a list of the names\n#     of the columns of the result-set that would be returned by executing\n#     the SELECT.\n#\n#   table_column_names TBL\n#     The argument must be a table name. Return a list of column names, from\n#     left to right, for the table.\n#\n#   table_column_decltypes TBL\n#     The argument must be a table name. Return a list of column declared\n#     types, from left to right, for the table.\n#\nproc sci {select cmd} {\n  set res [list]\n  set STMT [sqlite3_prepare_v2 db $select -1 dummy]\n  for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n    lappend res [$cmd $STMT $i]\n  }\n  sqlite3_finalize $STMT\n  set res\n}\nproc tci {tbl cmd} { sci \"SELECT * FROM $tbl\" $cmd }\nproc select_column_names    {sql} { sci $sql sqlite3_column_name }\nproc table_column_names     {tbl} { tci $tbl sqlite3_column_name }\nproc table_column_decltypes {tbl} { tci $tbl sqlite3_column_decltype }\n\n# Create a database schema. This schema is used by tests 2.1.* through 2.3.*.\n#\ndrop_all_tables\ndo_execsql_test e_createtable-2.0 {\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(d, e, f);\n  CREATE TABLE t3(g BIGINT, h VARCHAR(10));\n  CREATE TABLE t4(i BLOB, j ANYOLDATA);\n  CREATE TABLE t5(k FLOAT, l INTEGER);\n  CREATE TABLE t6(m DEFAULT 10, n DEFAULT 5, PRIMARY KEY(m, n));\n  CREATE TABLE t7(x INTEGER PRIMARY KEY);\n  CREATE TABLE t8(o COLLATE nocase DEFAULT 'abc');\n  CREATE TABLE t9(p NOT NULL, q DOUBLE CHECK (q!=0), r STRING UNIQUE);\n} {}\n\n# EVIDENCE-OF: R-64828-59568 The table has the same number of columns as\n# the rows returned by the SELECT statement. The name of each column is\n# the same as the name of the corresponding column in the result set of\n# the SELECT statement.\n#\ndo_createtable_tests 2.1 -tclquery {\n  table_column_names x1\n} -repair {\n  catchsql { DROP TABLE x1 }\n} {\n  1    \"CREATE TABLE x1 AS SELECT * FROM t1\"                     {a b c}\n  2    \"CREATE TABLE x1 AS SELECT c, b, a FROM t1\"               {c b a}\n  3    \"CREATE TABLE x1 AS SELECT * FROM t1, t2\"                 {a b c d e f}\n  4    \"CREATE TABLE x1 AS SELECT count(*) FROM t1\"              {count(*)}\n  5    \"CREATE TABLE x1 AS SELECT count(a) AS a, max(b) FROM t1\" {a max(b)}\n}\n\n# EVIDENCE-OF: R-37111-22855 The declared type of each column is\n# determined by the expression affinity of the corresponding expression\n# in the result set of the SELECT statement, as follows: Expression\n# Affinity Column Declared Type TEXT \"TEXT\" NUMERIC \"NUM\" INTEGER \"INT\"\n# REAL \"REAL\" NONE \"\" (empty string)\n#\ndo_createtable_tests 2.2 -tclquery {\n  table_column_decltypes x1\n} -repair {\n  catchsql { DROP TABLE x1 }\n} {\n  1    \"CREATE TABLE x1 AS SELECT a FROM t1\"     {\"\"}\n  2    \"CREATE TABLE x1 AS SELECT * FROM t3\"     {INT TEXT}\n  3    \"CREATE TABLE x1 AS SELECT * FROM t4\"     {\"\" NUM}\n  4    \"CREATE TABLE x1 AS SELECT * FROM t5\"     {REAL INT}\n}\n\n# EVIDENCE-OF: R-16667-09772 A table created using CREATE TABLE AS has\n# no PRIMARY KEY and no constraints of any kind. The default value of\n# each column is NULL. The default collation sequence for each column of\n# the new table is BINARY.\n#\n#   The following tests create tables based on SELECT statements that read\n#   from tables that have primary keys, constraints and explicit default \n#   collation sequences. None of this is transfered to the definition of\n#   the new table as stored in the sqlite_master table.\n#\n#   Tests 2.3.2.* show that the default value of each column is NULL.\n#\ndo_createtable_tests 2.3.1 -query {\n  SELECT sql FROM sqlite_master ORDER BY rowid DESC LIMIT 1\n} {\n  1    \"CREATE TABLE x1 AS SELECT * FROM t6\" {{CREATE TABLE x1(m,n)}}\n  2    \"CREATE TABLE x2 AS SELECT * FROM t7\" {{CREATE TABLE x2(x INT)}}\n  3    \"CREATE TABLE x3 AS SELECT * FROM t8\" {{CREATE TABLE x3(o)}}\n  4    \"CREATE TABLE x4 AS SELECT * FROM t9\" {{CREATE TABLE x4(p,q REAL,r NUM)}}\n}\ndo_execsql_test e_createtable-2.3.2.1 {\n  INSERT INTO x1 DEFAULT VALUES;\n  INSERT INTO x2 DEFAULT VALUES;\n  INSERT INTO x3 DEFAULT VALUES;\n  INSERT INTO x4 DEFAULT VALUES;\n} {}\ndb nullvalue null\ndo_execsql_test e_createtable-2.3.2.2 { SELECT * FROM x1 } {null null}\ndo_execsql_test e_createtable-2.3.2.3 { SELECT * FROM x2 } {null}\ndo_execsql_test e_createtable-2.3.2.4 { SELECT * FROM x3 } {null}\ndo_execsql_test e_createtable-2.3.2.5 { SELECT * FROM x4 } {null null null}\ndb nullvalue {}\n\ndrop_all_tables\ndo_execsql_test e_createtable-2.4.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES('i',   'one');\n  INSERT INTO t1 VALUES('ii',  'two');\n  INSERT INTO t1 VALUES('iii', 'three');\n} {}\n\n# EVIDENCE-OF: R-24153-28352 Tables created using CREATE TABLE AS are\n# initially populated with the rows of data returned by the SELECT\n# statement.\n#\n# EVIDENCE-OF: R-08224-30249 Rows are assigned contiguously ascending\n# rowid values, starting with 1, in the order that they are returned by\n# the SELECT statement.\n#\n#   Each test case below is specified as the name of a table to create\n#   using \"CREATE TABLE ... AS SELECT ...\" and a SELECT statement to use in\n#   creating it. The table is created. \n#\n#   Test cases 2.4.*.1 check that after it has been created, the data in the\n#   table is the same as the data returned by the SELECT statement executed as\n#   a standalone command, verifying the first testable statement above.\n#\n#   Test cases 2.4.*.2 check that the rowids were allocated contiguously\n#   as required by the second testable statement above. That the rowids\n#   from the contiguous block were allocated to rows in the order rows are\n#   returned by the SELECT statement is verified by 2.4.*.1.\n#\n# EVIDENCE-OF: R-32365-09043 A \"CREATE TABLE ... AS SELECT\" statement\n# creates and populates a database table based on the results of a\n# SELECT statement.\n#\n#   The above is also considered to be tested by the following. It is\n#   clear that tables are being created and populated by the command in\n#   question.\n#\nforeach {tn tbl select} {\n  1   x1   \"SELECT * FROM t1\"\n  2   x2   \"SELECT * FROM t1 ORDER BY x DESC\"\n  3   x3   \"SELECT * FROM t1 ORDER BY x ASC\"\n} {\n  # Create the table using a \"CREATE TABLE ... AS SELECT ...\" command.\n  execsql [subst {CREATE TABLE $tbl AS $select}]\n\n  # Check that the rows inserted into the table, sorted in ascending rowid\n  # order, match those returned by executing the SELECT statement as a\n  # standalone command.\n  do_execsql_test e_createtable-2.4.$tn.1 [subst {\n    SELECT * FROM $tbl ORDER BY rowid;\n  }] [execsql $select]\n\n  # Check that the rowids in the new table are a contiguous block starting\n  # with rowid 1. Note that this will fail if SELECT statement $select \n  # returns 0 rows (as max(rowid) will be NULL).\n  do_execsql_test e_createtable-2.4.$tn.2 [subst {\n    SELECT min(rowid), count(rowid)==max(rowid) FROM $tbl\n  }] {1 1}\n}\n\n#--------------------------------------------------------------------------\n# Test cases for column defintions in CREATE TABLE statements that do not\n# use a SELECT statement. Not including data constraints. In other words,\n# tests for the specification of:\n#\n#   * declared types,\n#   * default values, and\n#   * default collation sequences.\n#\n\n# EVIDENCE-OF: R-27219-49057 Unlike most SQL databases, SQLite does not\n# restrict the type of data that may be inserted into a column based on\n# the columns declared type.\n#\n#   Test this by creating a few tables with varied declared types, then\n#   inserting various different types of values into them.\n#\ndrop_all_tables\ndo_execsql_test e_createtable-3.1.0 {\n  CREATE TABLE t1(x VARCHAR(10), y INTEGER, z DOUBLE);\n  CREATE TABLE t2(a DATETIME, b STRING, c REAL);\n  CREATE TABLE t3(o, t);\n} {}\n\n# value type -> declared column type\n# ----------------------------------\n# integer    -> VARCHAR(10)\n# string     -> INTEGER\n# blob       -> DOUBLE\n#\ndo_execsql_test e_createtable-3.1.1 {\n  INSERT INTO t1 VALUES(14, 'quite a lengthy string', X'555655');\n  SELECT * FROM t1;\n} {14 {quite a lengthy string} UVU}\n\n# string     -> DATETIME\n# integer    -> STRING\n# time       -> REAL\n#\ndo_execsql_test e_createtable-3.1.2 {\n  INSERT INTO t2 VALUES('not a datetime', 13, '12:41:59');\n  SELECT * FROM t2;\n} {{not a datetime} 13 12:41:59}\n\n# EVIDENCE-OF: R-10565-09557 The declared type of a column is used to\n# determine the affinity of the column only.\n#\n#     Affinities are tested in more detail elsewhere (see document\n#     datatype3.html). Here, just test that affinity transformations\n#     consistent with the expected affinity of each column (based on\n#     the declared type) appear to take place.\n#\n# Affinities of t1 (test cases 3.2.1.*): TEXT, INTEGER, REAL\n# Affinities of t2 (test cases 3.2.2.*): NUMERIC, NUMERIC, REAL\n# Affinities of t3 (test cases 3.2.3.*): NONE, NONE\n#\ndo_execsql_test e_createtable-3.2.0 { DELETE FROM t1; DELETE FROM t2; } {}\n\ndo_createtable_tests 3.2.1 -query {\n  SELECT quote(x), quote(y), quote(z) FROM t1 ORDER BY rowid DESC LIMIT 1;\n} {\n  1   \"INSERT INTO t1 VALUES(15,   '22.0', '14')\"   {'15' 22 14.0}\n  2   \"INSERT INTO t1 VALUES(22.0, 22.0, 22.0)\"     {'22.0' 22 22.0}\n}\ndo_createtable_tests 3.2.2 -query {\n  SELECT quote(a), quote(b), quote(c) FROM t2 ORDER BY rowid DESC LIMIT 1;\n} {\n  1   \"INSERT INTO t2 VALUES(15,   '22.0', '14')\"   {15   22  14.0}\n  2   \"INSERT INTO t2 VALUES(22.0, 22.0, 22.0)\"     {22   22  22.0}\n}\ndo_createtable_tests 3.2.3 -query {\n  SELECT quote(o), quote(t) FROM t3 ORDER BY rowid DESC LIMIT 1;\n} {\n  1   \"INSERT INTO t3 VALUES('15', '22.0')\"         {'15' '22.0'}\n  2   \"INSERT INTO t3 VALUES(15, 22.0)\"             {15 22.0}\n}\n\n# EVIDENCE-OF: R-42316-09582 If there is no explicit DEFAULT clause\n# attached to a column definition, then the default value of the column\n# is NULL.\n#\n#     None of the columns in table t1 have an explicit DEFAULT clause.\n#     So testing that the default value of all columns in table t1 is\n#     NULL serves to verify the above.\n#     \ndo_createtable_tests 3.2.3 -query {\n  SELECT quote(x), quote(y), quote(z) FROM t1\n} -repair {\n  execsql { DELETE FROM t1 }\n} {\n  1   \"INSERT INTO t1(x, y) VALUES('abc', 'xyz')\"   {'abc' 'xyz' NULL}\n  2   \"INSERT INTO t1(x, z) VALUES('abc', 'xyz')\"   {'abc' NULL 'xyz'}\n  3   \"INSERT INTO t1 DEFAULT VALUES\"               {NULL NULL NULL}\n}\n\n# EVIDENCE-OF: R-07343-35026 An explicit DEFAULT clause may specify that\n# the default value is NULL, a string constant, a blob constant, a\n# signed-number, or any constant expression enclosed in parentheses. A\n# default value may also be one of the special case-independent keywords\n# CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP.\n#\ndo_execsql_test e_createtable-3.3.1 {\n  CREATE TABLE t4(\n    a DEFAULT NULL,\n    b DEFAULT 'string constant',\n    c DEFAULT X'424C4F42',\n    d DEFAULT 1,\n    e DEFAULT -1,\n    f DEFAULT 3.14,\n    g DEFAULT -3.14,\n    h DEFAULT ( substr('abcd', 0, 2) || 'cd' ),\n    i DEFAULT CURRENT_TIME,\n    j DEFAULT CURRENT_DATE,\n    k DEFAULT CURRENT_TIMESTAMP\n  );\n} {}\n\n# EVIDENCE-OF: R-18415-27776 For the purposes of the DEFAULT clause, an\n# expression is considered constant if it does contains no sub-queries,\n# column or table references, bound parameters, or string literals\n# enclosed in double-quotes instead of single-quotes.\n#\ndo_createtable_tests 3.4.1 -error {\n  default value of column [x] is not constant\n} {\n  1   {CREATE TABLE t5(x DEFAULT ( (SELECT 1) ))}  {}\n  2   {CREATE TABLE t5(x DEFAULT ( \"abc\" ))}  {}\n  3   {CREATE TABLE t5(x DEFAULT ( 1 IN (SELECT 1) ))}  {}\n  4   {CREATE TABLE t5(x DEFAULT ( EXISTS (SELECT 1) ))}  {}\n  5   {CREATE TABLE t5(x DEFAULT ( x!=?1 ))}  {}\n}\ndo_createtable_tests 3.4.2 -repair {\n  catchsql { DROP TABLE t5 }\n} {\n  1   {CREATE TABLE t5(x DEFAULT ( 'abc' ))}  {}\n  2   {CREATE TABLE t5(x DEFAULT ( 1 IN (1, 2, 3) ))}  {}\n}\n\n# EVIDENCE-OF: R-18814-23501 Each time a row is inserted into the table\n# by an INSERT statement that does not provide explicit values for all\n# table columns the values stored in the new row are determined by their\n# default values\n#\n#     Verify this with some assert statements for which all, some and no\n#     columns lack explicit values.\n#\nset sqlite_current_time 1000000000\ndo_createtable_tests 3.5 -query {\n  SELECT quote(a), quote(b), quote(c), quote(d), quote(e), quote(f), \n         quote(g), quote(h), quote(i), quote(j), quote(k)\n  FROM t4 ORDER BY rowid DESC LIMIT 1;\n} {\n  1 \"INSERT INTO t4 DEFAULT VALUES\" {\n    NULL {'string constant'} X'424C4F42' 1 -1 3.14 -3.14 \n    'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}\n  }\n\n  2 \"INSERT INTO t4(a, b, c) VALUES(1, 2, 3)\" {\n    1 2 3 1 -1 3.14 -3.14 'acd' '01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}\n  }\n\n  3 \"INSERT INTO t4(k, j, i) VALUES(1, 2, 3)\" {\n    NULL {'string constant'} X'424C4F42' 1 -1 3.14 -3.14 'acd' 3 2 1\n  }\n\n  4 \"INSERT INTO t4(a,b,c,d,e,f,g,h,i,j,k) VALUES(1,2,3,4,5,6,7,8,9,10,11)\" {\n    1 2 3 4 5 6 7 8 9 10 11\n  }\n}\n\n# EVIDENCE-OF: R-12572-62501 If the default value of the column is a\n# constant NULL, text, blob or signed-number value, then that value is\n# used directly in the new row.\n#\ndo_execsql_test e_createtable-3.6.1 {\n  CREATE TABLE t5(\n    a DEFAULT NULL,  \n    b DEFAULT 'text value',  \n    c DEFAULT X'424C4F42',\n    d DEFAULT -45678.6,\n    e DEFAULT 394507\n  );\n} {}\ndo_execsql_test e_createtable-3.6.2 {\n  INSERT INTO t5 DEFAULT VALUES;\n  SELECT quote(a), quote(b), quote(c), quote(d), quote(e) FROM t5;\n} {NULL {'text value'} X'424C4F42' -45678.6 394507}\n\n# EVIDENCE-OF: R-60616-50251 If the default value of a column is an\n# expression in parentheses, then the expression is evaluated once for\n# each row inserted and the results used in the new row.\n#\n#   Test case 3.6.4 demonstrates that the expression is evaluated \n#   separately for each row if the INSERT is an \"INSERT INTO ... SELECT ...\"\n#   command.\n#\nset ::nextint 0\nproc nextint {} { incr ::nextint }\ndb func nextint nextint\n\ndo_execsql_test e_createtable-3.7.1 {\n  CREATE TABLE t6(a DEFAULT ( nextint() ), b DEFAULT ( nextint() ));\n} {}\ndo_execsql_test e_createtable-3.7.2 {\n  INSERT INTO t6 DEFAULT VALUES;\n  SELECT quote(a), quote(b) FROM t6;\n} {1 2}\ndo_execsql_test e_createtable-3.7.3 {\n  INSERT INTO t6(a) VALUES('X');\n  SELECT quote(a), quote(b) FROM t6;\n} {1 2 'X' 3}\ndo_execsql_test e_createtable-3.7.4 {\n  INSERT INTO t6(a) SELECT a FROM t6;\n  SELECT quote(a), quote(b) FROM t6;\n} {1 2 'X' 3 1 4 'X' 5}\n\n# EVIDENCE-OF: R-15363-55230 If the default value of a column is\n# CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP, then the value used\n# in the new row is a text representation of the current UTC date and/or\n# time.\n#\n#     This is difficult to test literally without knowing what time the \n#     user will run the tests. Instead, we test that the three cases\n#     above set the value to the current date and/or time according to\n#     the xCurrentTime() method of the VFS. Which is usually the same\n#     as UTC. In this case, however, we instrument it to always return\n#     a time equivalent to \"2001-09-09 01:46:40 UTC\".\n#\nset sqlite_current_time 1000000000\ndo_execsql_test e_createtable-3.8.1 {\n  CREATE TABLE t7(\n    a DEFAULT CURRENT_TIME, \n    b DEFAULT CURRENT_DATE, \n    c DEFAULT CURRENT_TIMESTAMP\n  );\n} {}\ndo_execsql_test e_createtable-3.8.2 {\n  INSERT INTO t7 DEFAULT VALUES;\n  SELECT quote(a), quote(b), quote(c) FROM t7;\n} {'01:46:40' '2001-09-09' {'2001-09-09 01:46:40'}}\n\n\n# EVIDENCE-OF: R-62327-53843 For CURRENT_TIME, the format of the value\n# is \"HH:MM:SS\".\n#\n# EVIDENCE-OF: R-03775-43471 For CURRENT_DATE, \"YYYY-MM-DD\".\n#\n# EVIDENCE-OF: R-07677-44926 The format for CURRENT_TIMESTAMP is\n# \"YYYY-MM-DD HH:MM:SS\".\n#\n#     The three above are demonstrated by tests 1, 2 and 3 below. \n#     Respectively.\n#\ndo_createtable_tests 3.8.3 -query {\n  SELECT a, b, c FROM t7 ORDER BY rowid DESC LIMIT 1;\n} {\n  1 \"INSERT INTO t7(b, c) VALUES('x', 'y')\" {01:46:40 x y}\n  2 \"INSERT INTO t7(c, a) VALUES('x', 'y')\" {y 2001-09-09 x}\n  3 \"INSERT INTO t7(a, b) VALUES('x', 'y')\" {x y {2001-09-09 01:46:40}}\n}\n\n# EVIDENCE-OF: R-55061-47754 The COLLATE clause specifies the name of a\n# collating sequence to use as the default collation sequence for the\n# column.\n#\n# EVIDENCE-OF: R-40275-54363 If no COLLATE clause is specified, the\n# default collation sequence is BINARY.\n#\ndo_execsql_test e_createtable-3-9.1 {\n  CREATE TABLE t8(a COLLATE nocase, b COLLATE rtrim, c COLLATE binary, d);\n  INSERT INTO t8 VALUES('abc',   'abc',   'abc',   'abc');\n  INSERT INTO t8 VALUES('abc  ', 'abc  ', 'abc  ', 'abc  ');\n  INSERT INTO t8 VALUES('ABC  ', 'ABC  ', 'ABC  ', 'ABC  ');\n  INSERT INTO t8 VALUES('ABC',   'ABC',   'ABC',   'ABC');\n} {}\ndo_createtable_tests 3.9 {\n  2    \"SELECT a FROM t8 ORDER BY a, rowid\"    {abc ABC {abc  } {ABC  }}\n  3    \"SELECT b FROM t8 ORDER BY b, rowid\"    {{ABC  } ABC abc {abc  }}\n  4    \"SELECT c FROM t8 ORDER BY c, rowid\"    {ABC {ABC  } abc {abc  }}\n  5    \"SELECT d FROM t8 ORDER BY d, rowid\"    {ABC {ABC  } abc {abc  }}\n}\n\n# EVIDENCE-OF: R-25473-20557 The number of columns in a table is limited\n# by the SQLITE_MAX_COLUMN compile-time parameter.\n#\nproc columns {n} {\n  set res [list]\n  for {set i 0} {$i < $n} {incr i} { lappend res \"c$i\" }\n  join $res \", \"\n}\ndo_execsql_test e_createtable-3.10.1 [subst {\n  CREATE TABLE t9([columns $::SQLITE_MAX_COLUMN]);\n}] {}\ndo_catchsql_test e_createtable-3.10.2 [subst {\n  CREATE TABLE t10([columns [expr $::SQLITE_MAX_COLUMN+1]]);\n}] {1 {too many columns on t10}}\n\n# EVIDENCE-OF: R-27775-64721 Both of these limits can be lowered at\n# runtime using the sqlite3_limit() C/C++ interface.\n#\n#   A 30,000 byte blob consumes 30,003 bytes of record space. A record \n#   that contains 3 such blobs consumes (30,000*3)+1 bytes of space. Tests\n#   3.11.4 and 3.11.5, which verify that SQLITE_MAX_LENGTH may be lowered\n#   at runtime, are based on this calculation.\n#\nsqlite3_limit db SQLITE_LIMIT_COLUMN 500\ndo_execsql_test e_createtable-3.11.1 [subst {\n  CREATE TABLE t10([columns 500]);\n}] {}\ndo_catchsql_test e_createtable-3.11.2 [subst {\n  CREATE TABLE t11([columns 501]);\n}] {1 {too many columns on t11}}\n\n# Check that it is not possible to raise the column limit above its \n# default compile time value.\n#\nsqlite3_limit db SQLITE_LIMIT_COLUMN [expr $::SQLITE_MAX_COLUMN+2]\ndo_catchsql_test e_createtable-3.11.3 [subst {\n  CREATE TABLE t11([columns [expr $::SQLITE_MAX_COLUMN+1]]);\n}] {1 {too many columns on t11}}\n\nsqlite3_limit db SQLITE_LIMIT_LENGTH 90010\ndo_execsql_test e_createtable-3.11.4 {\n  CREATE TABLE t12(a, b, c);\n  INSERT INTO t12 VALUES(randomblob(30000),randomblob(30000),randomblob(30000));\n} {}\ndo_catchsql_test e_createtable-3.11.5 {\n  INSERT INTO t12 VALUES(randomblob(30001),randomblob(30000),randomblob(30000));\n} {1 {string or blob too big}}\n\n#-------------------------------------------------------------------------\n# Tests for statements regarding constraints (PRIMARY KEY, UNIQUE, NOT \n# NULL and CHECK constraints).\n#\n\n# EVIDENCE-OF: R-52382-54248 Each table in SQLite may have at most one\n# PRIMARY KEY.\n# \n# EVIDENCE-OF: R-31826-01813 An error is raised if more than one PRIMARY\n# KEY clause appears in a CREATE TABLE statement.\n#\n#     To test the two above, show that zero primary keys is Ok, one primary\n#     key is Ok, and two or more primary keys is an error.\n#\ndrop_all_tables\ndo_createtable_tests 4.1.1 {\n  1    \"CREATE TABLE t1(a, b, c)\"                                        {}\n  2    \"CREATE TABLE t2(a PRIMARY KEY, b, c)\"                            {}\n  3    \"CREATE TABLE t3(a, b, c, PRIMARY KEY(a))\"                        {}\n  4    \"CREATE TABLE t4(a, b, c, PRIMARY KEY(c,b,a))\"                    {}\n}\ndo_createtable_tests 4.1.2 -error {\n  table \"t5\" has more than one primary key\n} {\n  1    \"CREATE TABLE t5(a PRIMARY KEY, b PRIMARY KEY, c)\"                {}\n  2    \"CREATE TABLE t5(a, b PRIMARY KEY, c, PRIMARY KEY(a))\"            {}\n  3    \"CREATE TABLE t5(a INTEGER PRIMARY KEY, b PRIMARY KEY, c)\"        {}\n  4    \"CREATE TABLE t5(a INTEGER PRIMARY KEY, b, c, PRIMARY KEY(b, c))\" {}\n  5    \"CREATE TABLE t5(a PRIMARY KEY, b, c, PRIMARY KEY(a))\"            {}\n  6    \"CREATE TABLE t5(a INTEGER PRIMARY KEY, b, c, PRIMARY KEY(a))\"    {}\n}\n\n# EVIDENCE-OF: R-54755-39291 The PRIMARY KEY is optional for ordinary\n# tables but is required for WITHOUT ROWID tables.\n#\ndo_catchsql_test 4.1.3 {\n  CREATE TABLE t6(a, b); --ok\n} {0 {}}\ndo_catchsql_test 4.1.4 {\n  CREATE TABLE t7(a, b) WITHOUT ROWID; --Error, no PRIMARY KEY\n} {1 {PRIMARY KEY missing on table t7}}\n\n\nproc table_pk {tbl} { \n  set pk [list]\n  db eval \"pragma table_info($tbl)\" a {\n    if {$a(pk)} { lappend pk $a(name) }\n  }\n  set pk\n}\n\n# EVIDENCE-OF: R-41411-18837 If the keywords PRIMARY KEY are added to a\n# column definition, then the primary key for the table consists of that\n# single column.\n#\n#     The above is tested by 4.2.1.*\n#\n# EVIDENCE-OF: R-31775-48204 Or, if a PRIMARY KEY clause is specified as\n# a table-constraint, then the primary key of the table consists of the\n# list of columns specified as part of the PRIMARY KEY clause.\n#\n#     The above is tested by 4.2.2.*\n#\ndo_createtable_tests 4.2 -repair {\n  catchsql { DROP TABLE t5 }\n} -tclquery {\n  table_pk t5\n} {\n  1.1    \"CREATE TABLE t5(a, b INTEGER PRIMARY KEY, c)\"       {b}\n  1.2    \"CREATE TABLE t5(a PRIMARY KEY, b, c)\"               {a}\n\n  2.1    \"CREATE TABLE t5(a, b, c, PRIMARY KEY(a))\"           {a}\n  2.2    \"CREATE TABLE t5(a, b, c, PRIMARY KEY(c,b,a))\"       {a b c}\n  2.3    \"CREATE TABLE t5(a, b INTEGER PRIMARY KEY, c)\"       {b}\n}\n\n# EVIDENCE-OF: R-59124-61339 Each row in a table with a primary key must\n# have a unique combination of values in its primary key columns.\n#\n# EVIDENCE-OF: R-06471-16287 If an INSERT or UPDATE statement attempts\n# to modify the table content so that two or more rows have identical\n# primary key values, that is a constraint violation.\n#\ndrop_all_tables\ndo_execsql_test 4.3.0 {\n  CREATE TABLE t1(x PRIMARY KEY, y);\n  INSERT INTO t1 VALUES(0,          'zero');\n  INSERT INTO t1 VALUES(45.5,       'one');\n  INSERT INTO t1 VALUES('brambles', 'two');\n  INSERT INTO t1 VALUES(X'ABCDEF',  'three');\n\n  CREATE TABLE t2(x, y, PRIMARY KEY(x, y));\n  INSERT INTO t2 VALUES(0,          'zero');\n  INSERT INTO t2 VALUES(45.5,       'one');\n  INSERT INTO t2 VALUES('brambles', 'two');\n  INSERT INTO t2 VALUES(X'ABCDEF',  'three');\n} {}\n\ndo_createtable_tests 4.3.1 -error {UNIQUE constraint failed: t1.x} {\n  1    \"INSERT INTO t1 VALUES(0, 0)\"                 {\"column x is\"}\n  2    \"INSERT INTO t1 VALUES(45.5, 'abc')\"          {\"column x is\"}\n  3    \"INSERT INTO t1 VALUES(0.0, 'abc')\"           {\"column x is\"}\n  4    \"INSERT INTO t1 VALUES('brambles', 'abc')\"    {\"column x is\"}\n  5    \"INSERT INTO t1 VALUES(X'ABCDEF', 'abc')\"     {\"column x is\"}\n}\ndo_createtable_tests 4.3.1 -error {UNIQUE constraint failed: t2.x, t2.y} {\n  6    \"INSERT INTO t2 VALUES(0, 'zero')\"            {\"columns x, y are\"}\n  7    \"INSERT INTO t2 VALUES(45.5, 'one')\"          {\"columns x, y are\"}\n  8    \"INSERT INTO t2 VALUES(0.0, 'zero')\"          {\"columns x, y are\"}\n  9    \"INSERT INTO t2 VALUES('brambles', 'two')\"    {\"columns x, y are\"}\n  10   \"INSERT INTO t2 VALUES(X'ABCDEF', 'three')\"   {\"columns x, y are\"}\n}\ndo_createtable_tests 4.3.2 {\n  1    \"INSERT INTO t1 VALUES(-1, 0)\"                {}\n  2    \"INSERT INTO t1 VALUES(45.2, 'abc')\"          {}\n  3    \"INSERT INTO t1 VALUES(0.01, 'abc')\"          {}\n  4    \"INSERT INTO t1 VALUES('bramble', 'abc')\"     {}\n  5    \"INSERT INTO t1 VALUES(X'ABCDEE', 'abc')\"     {}\n\n  6    \"INSERT INTO t2 VALUES(0, 0)\"                 {}\n  7    \"INSERT INTO t2 VALUES(45.5, 'abc')\"          {}\n  8    \"INSERT INTO t2 VALUES(0.0, 'abc')\"           {}\n  9    \"INSERT INTO t2 VALUES('brambles', 'abc')\"    {}\n  10   \"INSERT INTO t2 VALUES(X'ABCDEF', 'abc')\"     {}\n}\ndo_createtable_tests 4.3.3 -error {UNIQUE constraint failed: t1.x} {\n  1    \"UPDATE t1 SET x=0           WHERE y='two'\"    {\"column x is\"}\n  2    \"UPDATE t1 SET x='brambles'  WHERE y='three'\"  {\"column x is\"}\n  3    \"UPDATE t1 SET x=45.5        WHERE y='zero'\"   {\"column x is\"}\n  4    \"UPDATE t1 SET x=X'ABCDEF'   WHERE y='one'\"    {\"column x is\"}\n  5    \"UPDATE t1 SET x=0.0         WHERE y='three'\"  {\"column x is\"}\n}\ndo_createtable_tests 4.3.3 -error {UNIQUE constraint failed: t2.x, t2.y} {\n  6    \"UPDATE t2 SET x=0, y='zero' WHERE y='two'\"    {\"columns x, y are\"}\n  7    \"UPDATE t2 SET x='brambles', y='two' WHERE y='three'\"  \n       {\"columns x, y are\"}\n  8    \"UPDATE t2 SET x=45.5, y='one' WHERE y='zero'\" {\"columns x, y are\"}\n  9    \"UPDATE t2 SET x=X'ABCDEF', y='three' WHERE y='one'\" \n       {\"columns x, y are\"}\n  10   \"UPDATE t2 SET x=0.0, y='zero'        WHERE y='three'\"  \n       {\"columns x, y are\"}\n}\n\n\n# EVIDENCE-OF: R-52572-02078 For the purposes of determining the\n# uniqueness of primary key values, NULL values are considered distinct\n# from all other values, including other NULLs.\n#\ndo_createtable_tests 4.4 {\n  1    \"INSERT INTO t1 VALUES(NULL, 0)\"              {}\n  2    \"INSERT INTO t1 VALUES(NULL, 0)\"              {}\n  3    \"INSERT INTO t1 VALUES(NULL, 0)\"              {}\n\n  4    \"INSERT INTO t2 VALUES(NULL, 'zero')\"         {}\n  5    \"INSERT INTO t2 VALUES(NULL, 'one')\"          {}\n  6    \"INSERT INTO t2 VALUES(NULL, 'two')\"          {}\n  7    \"INSERT INTO t2 VALUES(NULL, 'three')\"        {}\n\n  8    \"INSERT INTO t2 VALUES(0, NULL)\"              {}\n  9    \"INSERT INTO t2 VALUES(45.5, NULL)\"           {}\n  10   \"INSERT INTO t2 VALUES(0.0, NULL)\"            {}\n  11   \"INSERT INTO t2 VALUES('brambles', NULL)\"     {}\n  12   \"INSERT INTO t2 VALUES(X'ABCDEF', NULL)\"      {}\n\n  13   \"INSERT INTO t2 VALUES(NULL, NULL)\"           {}\n  14   \"INSERT INTO t2 VALUES(NULL, NULL)\"           {}\n}\n\n# EVIDENCE-OF: R-35113-43214 Unless the column is an INTEGER PRIMARY KEY\n# or the table is a WITHOUT ROWID table or the column is declared NOT\n# NULL, SQLite allows NULL values in a PRIMARY KEY column.\n#\n#     If the column is an integer primary key, attempting to insert a NULL\n#     into the column triggers the auto-increment behavior. Attempting\n#     to use UPDATE to set an ipk column to a NULL value is an error.\n#\ndo_createtable_tests 4.5.1 {\n  1    \"SELECT count(*) FROM t1 WHERE x IS NULL\"                   3\n  2    \"SELECT count(*) FROM t2 WHERE x IS NULL\"                   6\n  3    \"SELECT count(*) FROM t2 WHERE y IS NULL\"                   7\n  4    \"SELECT count(*) FROM t2 WHERE x IS NULL AND y IS NULL\"     2\n}\ndo_execsql_test 4.5.2 {\n  CREATE TABLE t3(s, u INTEGER PRIMARY KEY, v);\n  INSERT INTO t3 VALUES(1, NULL, 2);\n  INSERT INTO t3 VALUES('x', NULL, 'y');\n  SELECT u FROM t3;\n} {1 2}\ndo_catchsql_test 4.5.3 {\n  INSERT INTO t3 VALUES(2, 5, 3);\n  UPDATE t3 SET u = NULL WHERE s = 2;\n} {1 {datatype mismatch}}\ndo_catchsql_test 4.5.4 {\n  CREATE TABLE t4(s, u INT PRIMARY KEY, v) WITHOUT ROWID;\n  INSERT INTO t4 VALUES(1, NULL, 2);\n} {1 {NOT NULL constraint failed: t4.u}}\ndo_catchsql_test 4.5.5 {\n  CREATE TABLE t5(s, u INT PRIMARY KEY NOT NULL, v);\n  INSERT INTO t5 VALUES(1, NULL, 2);\n} {1 {NOT NULL constraint failed: t5.u}}\n\n# EVIDENCE-OF: R-00227-21080 A UNIQUE constraint is similar to a PRIMARY\n# KEY constraint, except that a single table may have any number of\n# UNIQUE constraints.\n#\ndrop_all_tables\ndo_createtable_tests 4.6 {\n  1    \"CREATE TABLE t1(a UNIQUE, b UNIQUE)\"                       {}\n  2    \"CREATE TABLE t2(a UNIQUE, b, c, UNIQUE(c, b))\"             {}\n  3    \"CREATE TABLE t3(a, b, c, UNIQUE(a), UNIQUE(b), UNIQUE(c))\" {}\n  4    \"CREATE TABLE t4(a, b, c, UNIQUE(a, b, c))\"                 {}\n}\n\n# EVIDENCE-OF: R-30981-64168 For each UNIQUE constraint on the table,\n# each row must contain a unique combination of values in the columns\n# identified by the UNIQUE constraint.\n#\n# EVIDENCE-OF: R-59124-61339 Each row in a table with a primary key must\n# have a unique combination of values in its primary key columns.\n#\ndo_execsql_test 4.7.0 {\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(4.3, 5.5);\n  INSERT INTO t1 VALUES('reveal', 'variableness');\n  INSERT INTO t1 VALUES(X'123456', X'654321');\n\n  INSERT INTO t4 VALUES('xyx', 1, 1);\n  INSERT INTO t4 VALUES('xyx', 2, 1);\n  INSERT INTO t4 VALUES('uvw', 1, 1);\n}\ndo_createtable_tests 4.7.1 -error {UNIQUE constraint failed: %s} {\n  1    \"INSERT INTO t1 VALUES(1, 'one')\"             {{t1.a}}\n  2    \"INSERT INTO t1 VALUES(4.3, 'two')\"           {{t1.a}}\n  3    \"INSERT INTO t1 VALUES('reveal', 'three')\"    {{t1.a}}\n  4    \"INSERT INTO t1 VALUES(X'123456', 'four')\"    {{t1.a}}\n\n  5    \"UPDATE t1 SET a = 1 WHERE rowid=2\"           {{t1.a}}\n  6    \"UPDATE t1 SET a = 4.3 WHERE rowid=3\"         {{t1.a}}\n  7    \"UPDATE t1 SET a = 'reveal' WHERE rowid=4\"    {{t1.a}}\n  8    \"UPDATE t1 SET a = X'123456' WHERE rowid=1\"   {{t1.a}}\n\n  9    \"INSERT INTO t4 VALUES('xyx', 1, 1)\"          {{t4.a, t4.b, t4.c}}\n  10   \"INSERT INTO t4 VALUES('xyx', 2, 1)\"          {{t4.a, t4.b, t4.c}}\n  11   \"INSERT INTO t4 VALUES('uvw', 1, 1)\"          {{t4.a, t4.b, t4.c}}\n\n  12   \"UPDATE t4 SET a='xyx' WHERE rowid=3\"         {{t4.a, t4.b, t4.c}}\n  13   \"UPDATE t4 SET b=1 WHERE rowid=2\"             {{t4.a, t4.b, t4.c}}\n  14   \"UPDATE t4 SET a=0, b=0, c=0\"                 {{t4.a, t4.b, t4.c}}\n}\n\n# EVIDENCE-OF: R-00404-17670 For the purposes of UNIQUE constraints,\n# NULL values are considered distinct from all other values, including\n# other NULLs.\n#\ndo_createtable_tests 4.8 {\n  1    \"INSERT INTO t1 VALUES(NULL, NULL)\"           {}\n  2    \"INSERT INTO t1 VALUES(NULL, NULL)\"           {}\n  3    \"UPDATE t1 SET a = NULL\"                      {}\n  4    \"UPDATE t1 SET b = NULL\"                      {}\n\n  5    \"INSERT INTO t4 VALUES(NULL, NULL, NULL)\"     {}\n  6    \"INSERT INTO t4 VALUES(NULL, NULL, NULL)\"     {}\n  7    \"UPDATE t4 SET a = NULL\"                      {}\n  8    \"UPDATE t4 SET b = NULL\"                      {}\n  9    \"UPDATE t4 SET c = NULL\"                      {}\n}\n\n# EVIDENCE-OF: R-55820-29984 In most cases, UNIQUE and PRIMARY KEY\n# constraints are implemented by creating a unique index in the\n# database.\ndo_createtable_tests 4.9 -repair drop_all_tables -query {\n  SELECT count(*) FROM sqlite_master WHERE type='index'\n} {\n  1    \"CREATE TABLE t1(a TEXT PRIMARY KEY, b)\"              1\n  2    \"CREATE TABLE t1(a INTEGER PRIMARY KEY, b)\"           0\n  3    \"CREATE TABLE t1(a TEXT UNIQUE, b)\"                   1\n  4    \"CREATE TABLE t1(a PRIMARY KEY, b TEXT UNIQUE)\"       2\n  5    \"CREATE TABLE t1(a PRIMARY KEY, b, c, UNIQUE(c, b))\"  2\n}\n\n# Obsolete: R-02252-33116 Such an index is used like any other index\n# in the database to optimize queries.\n#\ndo_execsql_test 4.10.0 {\n  CREATE TABLE t1(a, b PRIMARY KEY);\n  CREATE TABLE t2(a, b, c, UNIQUE(b, c));\n}\ndo_createtable_tests 4.10 {\n  1    \"EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 5\" \n       {0 0 0 {SEARCH TABLE t1 USING INDEX sqlite_autoindex_t1_1 (b=?)}}\n\n  2    \"EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c\"\n       {0 0 0 {SCAN TABLE t2 USING INDEX sqlite_autoindex_t2_1}}\n\n  3    \"EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10\"\n       {0 0 0 {SEARCH TABLE t2 USING INDEX sqlite_autoindex_t2_1 (b=? AND c>?)}}\n}\n\n# EVIDENCE-OF: R-45493-35653 A CHECK constraint may be attached to a\n# column definition or specified as a table constraint. In practice it\n# makes no difference.\n#\n#   All the tests that deal with CHECK constraints below (4.11.* and \n#   4.12.*) are run once for a table with the check constraint attached\n#   to a column definition, and once with a table where the check \n#   condition is specified as a table constraint.\n#\n# EVIDENCE-OF: R-55435-14303 Each time a new row is inserted into the\n# table or an existing row is updated, the expression associated with\n# each CHECK constraint is evaluated and cast to a NUMERIC value in the\n# same way as a CAST expression. If the result is zero (integer value 0\n# or real value 0.0), then a constraint violation has occurred.\n#\ndrop_all_tables\ndo_execsql_test 4.11 {\n  CREATE TABLE x1(a TEXT, b INTEGER CHECK( b>0 ));\n  CREATE TABLE t1(a TEXT, b INTEGER, CHECK( b>0 ));\n  INSERT INTO x1 VALUES('x', 'xx');\n  INSERT INTO x1 VALUES('y', 'yy');\n  INSERT INTO t1 SELECT * FROM x1;\n\n  CREATE TABLE x2(a CHECK( a||b ), b);\n  CREATE TABLE t2(a, b, CHECK( a||b ));\n  INSERT INTO x2 VALUES(1, 'xx');\n  INSERT INTO x2 VALUES(1, 'yy');\n  INSERT INTO t2 SELECT * FROM x2;\n}\n\ndo_createtable_tests 4.11 -error {CHECK constraint failed: %s} {\n  1a    \"INSERT INTO x1 VALUES('one', 0)\"       {x1}\n  1b    \"INSERT INTO t1 VALUES('one', -4.0)\"    {t1}\n\n  2a    \"INSERT INTO x2 VALUES('abc', 1)\"       {x2}\n  2b    \"INSERT INTO t2 VALUES('abc', 1)\"       {t2}\n\n  3a    \"INSERT INTO x2 VALUES(0, 'abc')\"       {x2}\n  3b    \"INSERT INTO t2 VALUES(0, 'abc')\"       {t2}\n\n  4a    \"UPDATE t1 SET b=-1 WHERE rowid=1\"      {t1}\n  4b    \"UPDATE x1 SET b=-1 WHERE rowid=1\"      {x1}\n\n  4a    \"UPDATE x2 SET a='' WHERE rowid=1\"      {x2}\n  4b    \"UPDATE t2 SET a='' WHERE rowid=1\"      {t2}\n}\n\n# EVIDENCE-OF: R-34109-39108 If the CHECK expression evaluates to NULL,\n# or any other non-zero value, it is not a constraint violation.\n#\ndo_createtable_tests 4.12 {\n  1a    \"INSERT INTO x1 VALUES('one', NULL)\"    {}\n  1b    \"INSERT INTO t1 VALUES('one', NULL)\"    {}\n\n  2a    \"INSERT INTO x1 VALUES('one', 2)\"    {}\n  2b    \"INSERT INTO t1 VALUES('one', 2)\"    {}\n\n  3a    \"INSERT INTO x2 VALUES(1, 'abc')\"       {}\n  3b    \"INSERT INTO t2 VALUES(1, 'abc')\"       {}\n}\n\n# EVIDENCE-OF: R-02060-64547 A NOT NULL constraint may only be attached\n# to a column definition, not specified as a table constraint.\n#\ndrop_all_tables\ndo_createtable_tests 4.13.1 {\n  1     \"CREATE TABLE t1(a NOT NULL, b)\"                               {}\n  2     \"CREATE TABLE t2(a PRIMARY KEY NOT NULL, b)\"                   {}\n  3     \"CREATE TABLE t3(a NOT NULL, b NOT NULL, c NOT NULL UNIQUE)\"   {}\n}\ndo_createtable_tests 4.13.2 -error {\n  near \"NOT\": syntax error\n} {\n  1     \"CREATE TABLE t4(a, b, NOT NULL(a))\"                   {}\n  2     \"CREATE TABLE t4(a PRIMARY KEY, b, NOT NULL(a))\"       {}\n  3     \"CREATE TABLE t4(a, b, c UNIQUE, NOT NULL(a, b, c))\"   {}\n}\n\n# EVIDENCE-OF: R-31795-57643 a NOT NULL constraint dictates that the\n# associated column may not contain a NULL value. Attempting to set the\n# column value to NULL when inserting a new row or updating an existing\n# one causes a constraint violation.\n#\n#     These tests use the tables created by 4.13.\n#\ndo_execsql_test 4.14.0 {\n  INSERT INTO t1 VALUES('x', 'y');\n  INSERT INTO t1 VALUES('z', NULL);\n\n  INSERT INTO t2 VALUES('x', 'y');\n  INSERT INTO t2 VALUES('z', NULL);\n\n  INSERT INTO t3 VALUES('x', 'y', 'z');\n  INSERT INTO t3 VALUES(1, 2, 3);\n}\ndo_createtable_tests 4.14 -error {NOT NULL constraint failed: %s} {\n  1    \"INSERT INTO t1 VALUES(NULL, 'a')\"         {t1.a}\n  2    \"INSERT INTO t2 VALUES(NULL, 'b')\"         {t2.a}\n  3    \"INSERT INTO t3 VALUES('c', 'd', NULL)\"    {t3.c}\n  4    \"INSERT INTO t3 VALUES('e', NULL, 'f')\"    {t3.b}\n  5    \"INSERT INTO t3 VALUES(NULL, 'g', 'h')\"    {t3.a}\n}\n\n# EVIDENCE-OF: R-42511-39459 PRIMARY KEY, UNIQUE and NOT NULL\n# constraints may be explicitly assigned a default conflict resolution\n# algorithm by including a conflict-clause in their definitions.\n#\n#     Conflict clauses: ABORT, ROLLBACK, IGNORE, FAIL, REPLACE\n#\n#     Test cases 4.15.*, 4.16.* and 4.17.* focus on PRIMARY KEY, NOT NULL\n#     and UNIQUE constraints, respectively.\n#\ndrop_all_tables\ndo_execsql_test 4.15.0 {\n  CREATE TABLE t1_ab(a PRIMARY KEY ON CONFLICT ABORT, b);\n  CREATE TABLE t1_ro(a PRIMARY KEY ON CONFLICT ROLLBACK, b);\n  CREATE TABLE t1_ig(a PRIMARY KEY ON CONFLICT IGNORE, b);\n  CREATE TABLE t1_fa(a PRIMARY KEY ON CONFLICT FAIL, b);\n  CREATE TABLE t1_re(a PRIMARY KEY ON CONFLICT REPLACE, b);\n  CREATE TABLE t1_xx(a PRIMARY KEY, b);\n\n  INSERT INTO t1_ab VALUES(1, 'one');\n  INSERT INTO t1_ab VALUES(2, 'two');\n  INSERT INTO t1_ro SELECT * FROM t1_ab;\n  INSERT INTO t1_ig SELECT * FROM t1_ab;\n  INSERT INTO t1_fa SELECT * FROM t1_ab;\n  INSERT INTO t1_re SELECT * FROM t1_ab;\n  INSERT INTO t1_xx SELECT * FROM t1_ab;\n\n  CREATE TABLE t2_ab(a, b NOT NULL ON CONFLICT ABORT);\n  CREATE TABLE t2_ro(a, b NOT NULL ON CONFLICT ROLLBACK);\n  CREATE TABLE t2_ig(a, b NOT NULL ON CONFLICT IGNORE);\n  CREATE TABLE t2_fa(a, b NOT NULL ON CONFLICT FAIL);\n  CREATE TABLE t2_re(a, b NOT NULL ON CONFLICT REPLACE);\n  CREATE TABLE t2_xx(a, b NOT NULL);\n\n  INSERT INTO t2_ab VALUES(1, 'one');\n  INSERT INTO t2_ab VALUES(2, 'two');\n  INSERT INTO t2_ro SELECT * FROM t2_ab;\n  INSERT INTO t2_ig SELECT * FROM t2_ab;\n  INSERT INTO t2_fa SELECT * FROM t2_ab;\n  INSERT INTO t2_re SELECT * FROM t2_ab;\n  INSERT INTO t2_xx SELECT * FROM t2_ab;\n\n  CREATE TABLE t3_ab(a, b, UNIQUE(a, b) ON CONFLICT ABORT);\n  CREATE TABLE t3_ro(a, b, UNIQUE(a, b) ON CONFLICT ROLLBACK);\n  CREATE TABLE t3_ig(a, b, UNIQUE(a, b) ON CONFLICT IGNORE);\n  CREATE TABLE t3_fa(a, b, UNIQUE(a, b) ON CONFLICT FAIL);\n  CREATE TABLE t3_re(a, b, UNIQUE(a, b) ON CONFLICT REPLACE);\n  CREATE TABLE t3_xx(a, b, UNIQUE(a, b));\n\n  INSERT INTO t3_ab VALUES(1, 'one');\n  INSERT INTO t3_ab VALUES(2, 'two');\n  INSERT INTO t3_ro SELECT * FROM t3_ab;\n  INSERT INTO t3_ig SELECT * FROM t3_ab;\n  INSERT INTO t3_fa SELECT * FROM t3_ab;\n  INSERT INTO t3_re SELECT * FROM t3_ab;\n  INSERT INTO t3_xx SELECT * FROM t3_ab;\n}\n\nforeach {tn tbl res ac data} {\n  1   t1_ab    {1 {UNIQUE constraint failed: t1_ab.a}} 0 {1 one 2 two 3 three}\n  2   t1_ro    {1 {UNIQUE constraint failed: t1_ro.a}} 1 {1 one 2 two}\n  3   t1_fa    {1 {UNIQUE constraint failed: t1_fa.a}} 0 {1 one 2 two 3 three 4 string}\n  4   t1_ig    {0 {}} 0 {1 one 2 two 3 three 4 string 6 string}\n  5   t1_re    {0 {}} 0 {1 one 2 two 4 string 3 string 6 string}\n  6   t1_xx    {1 {UNIQUE constraint failed: t1_xx.a}} 0 {1 one 2 two 3 three}\n} {\n  catchsql COMMIT\n  do_execsql_test  4.15.$tn.1 \"BEGIN; INSERT INTO $tbl VALUES(3, 'three')\"\n\n  do_catchsql_test 4.15.$tn.2 \" \n    INSERT INTO $tbl SELECT ((a%2)*a+3), 'string' FROM $tbl;\n  \" $res\n\n  do_test e_createtable-4.15.$tn.3 { sqlite3_get_autocommit db } $ac\n  do_execsql_test 4.15.$tn.4 \"SELECT * FROM $tbl\" $data\n}\nforeach {tn tbl res ac data} {\n  1   t2_ab    {1 {NOT NULL constraint failed: t2_ab.b}} 0 {1 one 2 two 3 three}\n  2   t2_ro    {1 {NOT NULL constraint failed: t2_ro.b}} 1 {1 one 2 two}\n  3   t2_fa    {1 {NOT NULL constraint failed: t2_fa.b}} 0 {1 one 2 two 3 three 4 xx}\n  4   t2_ig    {0 {}} 0 {1 one 2 two 3 three 4 xx 6 xx}\n  5   t2_re    {1 {NOT NULL constraint failed: t2_re.b}} 0 {1 one 2 two 3 three}\n  6   t2_xx    {1 {NOT NULL constraint failed: t2_xx.b}} 0 {1 one 2 two 3 three}\n} {\n  catchsql COMMIT\n  do_execsql_test  4.16.$tn.1 \"BEGIN; INSERT INTO $tbl VALUES(3, 'three')\"\n\n  do_catchsql_test 4.16.$tn.2 \" \n    INSERT INTO $tbl SELECT a+3, CASE a WHEN 2 THEN NULL ELSE 'xx' END FROM $tbl\n  \" $res\n\n  do_test e_createtable-4.16.$tn.3 { sqlite3_get_autocommit db } $ac\n  do_execsql_test 4.16.$tn.4 \"SELECT * FROM $tbl\" $data\n}\nforeach {tn tbl res ac data} {\n  1   t3_ab    {1 {UNIQUE constraint failed: t3_ab.a, t3_ab.b}}\n               0 {1 one 2 two 3 three}\n  2   t3_ro    {1 {UNIQUE constraint failed: t3_ro.a, t3_ro.b}}\n               1 {1 one 2 two}\n  3   t3_fa    {1 {UNIQUE constraint failed: t3_fa.a, t3_fa.b}}\n               0 {1 one 2 two 3 three 4 three}\n  4   t3_ig    {0 {}} 0 {1 one 2 two 3 three 4 three 6 three}\n  5   t3_re    {0 {}} 0 {1 one 2 two 4 three 3 three 6 three}\n  6   t3_xx    {1 {UNIQUE constraint failed: t3_xx.a, t3_xx.b}}\n               0 {1 one 2 two 3 three}\n} {\n  catchsql COMMIT\n  do_execsql_test  4.17.$tn.1 \"BEGIN; INSERT INTO $tbl VALUES(3, 'three')\"\n\n  do_catchsql_test 4.17.$tn.2 \" \n    INSERT INTO $tbl SELECT ((a%2)*a+3), 'three' FROM $tbl\n  \" $res\n\n  do_test e_createtable-4.17.$tn.3 { sqlite3_get_autocommit db } $ac\n  do_execsql_test 4.17.$tn.4 \"SELECT * FROM $tbl ORDER BY rowid\" $data\n}\ncatchsql COMMIT\n\n# EVIDENCE-OF: R-12645-39772 Or, if a constraint definition does not\n# include a conflict-clause or it is a CHECK constraint, the default\n# conflict resolution algorithm is ABORT.\n#\n#     The first half of the above is tested along with explicit ON \n#     CONFLICT clauses above (specifically, the tests involving t1_xx, t2_xx\n#     and t3_xx). The following just tests that the default conflict\n#     handling for CHECK constraints is ABORT.\n#\ndo_execsql_test 4.18.1 {\n  CREATE TABLE t4(a, b CHECK (b!=10));\n  INSERT INTO t4 VALUES(1, 2);\n  INSERT INTO t4 VALUES(3, 4);\n}\ndo_execsql_test  4.18.2 { BEGIN; INSERT INTO t4 VALUES(5, 6) }\ndo_catchsql_test 4.18.3 { \n  INSERT INTO t4 SELECT a+4, b+4 FROM t4\n} {1 {CHECK constraint failed: t4}}\ndo_test e_createtable-4.18.4 { sqlite3_get_autocommit db } 0\ndo_execsql_test 4.18.5 { SELECT * FROM t4 } {1 2 3 4 5 6}\n\n# EVIDENCE-OF: R-19114-56113 Different constraints within the same table\n# may have different default conflict resolution algorithms.\n#\ndo_execsql_test 4.19.0 {\n  CREATE TABLE t5(a NOT NULL ON CONFLICT IGNORE, b NOT NULL ON CONFLICT ABORT);\n}\ndo_catchsql_test 4.19.1 { INSERT INTO t5 VALUES(NULL, 'not null') } {0 {}}\ndo_execsql_test  4.19.2 { SELECT * FROM t5 } {}\ndo_catchsql_test 4.19.3 { INSERT INTO t5 VALUES('not null', NULL) } \\\n  {1 {NOT NULL constraint failed: t5.b}}\ndo_execsql_test  4.19.4 { SELECT * FROM t5 } {}\n\n#------------------------------------------------------------------------\n# Tests for INTEGER PRIMARY KEY and rowid related statements.\n#\n\n# EVIDENCE-OF: R-52584-04009 The rowid value can be accessed using one\n# of the special case-independent names \"rowid\", \"oid\", or \"_rowid_\" in\n# place of a column name.\n#\n# EVIDENCE-OF: R-06726-07466 A column name can be any of the names\n# defined in the CREATE TABLE statement or one of the following special\n# identifiers: \"ROWID\", \"OID\", or \"_ROWID_\".\n#\ndrop_all_tables\ndo_execsql_test 5.1.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES('one', 'first');\n  INSERT INTO t1 VALUES('two', 'second');\n  INSERT INTO t1 VALUES('three', 'third');\n}\ndo_createtable_tests 5.1 {\n  1   \"SELECT rowid FROM t1\"        {1 2 3}\n  2   \"SELECT oid FROM t1\"          {1 2 3}\n  3   \"SELECT _rowid_ FROM t1\"      {1 2 3}\n  4   \"SELECT ROWID FROM t1\"        {1 2 3}\n  5   \"SELECT OID FROM t1\"          {1 2 3}\n  6   \"SELECT _ROWID_ FROM t1\"      {1 2 3}\n  7   \"SELECT RoWiD FROM t1\"        {1 2 3}\n  8   \"SELECT OiD FROM t1\"          {1 2 3}\n  9   \"SELECT _RoWiD_ FROM t1\"      {1 2 3}\n}\n\n# EVIDENCE-OF: R-26501-17306 If a table contains a user defined column\n# named \"rowid\", \"oid\" or \"_rowid_\", then that name always refers the\n# explicitly declared column and cannot be used to retrieve the integer\n# rowid value.\n#\n# EVIDENCE-OF: R-44615-33286 The special identifiers only refer to the\n# row key if the CREATE TABLE statement does not define a real column\n# with the same name.\n#\ndo_execsql_test 5.2.0 {\n  CREATE TABLE t2(oid, b);\n  CREATE TABLE t3(a, _rowid_);\n  CREATE TABLE t4(a, b, rowid);\n\n  INSERT INTO t2 VALUES('one', 'two');\n  INSERT INTO t2 VALUES('three', 'four');\n\n  INSERT INTO t3 VALUES('five', 'six');\n  INSERT INTO t3 VALUES('seven', 'eight');\n\n  INSERT INTO t4 VALUES('nine', 'ten', 'eleven');\n  INSERT INTO t4 VALUES('twelve', 'thirteen', 'fourteen');\n}\ndo_createtable_tests 5.2 {\n  1   \"SELECT oid, rowid, _rowid_ FROM t2\"   {one 1 1      three 2 2}\n  2   \"SELECT oid, rowid, _rowid_ FROM t3\"   {1 1 six      2 2 eight} \n  3   \"SELECT oid, rowid, _rowid_ FROM t4\"   {1 eleven 1   2 fourteen 2}\n}\n\n\n# Argument $tbl is the name of a table in the database. Argument $col is\n# the name of one of the tables columns. Return 1 if $col is an alias for\n# the rowid, or 0 otherwise.\n#\nproc is_integer_primary_key {tbl col} {\n  lindex [db eval [subst {\n    DELETE FROM $tbl;\n    INSERT INTO $tbl ($col) VALUES(0);\n    SELECT (rowid==$col) FROM $tbl;\n    DELETE FROM $tbl;\n  }]] 0\n}\n\n# EVIDENCE-OF: R-47901-33947 With one exception noted below, if a rowid\n# table has a primary key that consists of a single column and the\n# declared type of that column is \"INTEGER\" in any mixture of upper and\n# lower case, then the column becomes an alias for the rowid.\n#\n# EVIDENCE-OF: R-45951-08347 if the declaration of a column with\n# declared type \"INTEGER\" includes an \"PRIMARY KEY DESC\" clause, it does\n# not become an alias for the rowid and is not classified as an integer\n# primary key.\n#\ndo_createtable_tests 5.3 -tclquery { \n  is_integer_primary_key t5 pk\n} -repair {\n  catchsql { DROP TABLE t5 }\n} {\n  1   \"CREATE TABLE t5(pk integer primary key)\"                         1\n  2   \"CREATE TABLE t5(pk integer, primary key(pk))\"                    1\n  3   \"CREATE TABLE t5(pk integer, v integer, primary key(pk))\"         1\n  4   \"CREATE TABLE t5(pk integer, v integer, primary key(pk, v))\"      0\n  5   \"CREATE TABLE t5(pk int, v integer, primary key(pk, v))\"          0\n  6   \"CREATE TABLE t5(pk int, v integer, primary key(pk))\"             0\n  7   \"CREATE TABLE t5(pk int primary key, v integer)\"                  0\n  8   \"CREATE TABLE t5(pk inTEger primary key)\"                         1\n  9   \"CREATE TABLE t5(pk inteGEr, primary key(pk))\"                    1\n  10  \"CREATE TABLE t5(pk INTEGER, v integer, primary key(pk))\"         1\n}\n\n# EVIDENCE-OF: R-41444-49665 Other integer type names like \"INT\" or\n# \"BIGINT\" or \"SHORT INTEGER\" or \"UNSIGNED INTEGER\" causes the primary\n# key column to behave as an ordinary table column with integer affinity\n# and a unique index, not as an alias for the rowid.\n#\ndo_execsql_test 5.4.1 {\n  CREATE TABLE t6(pk INT primary key);\n  CREATE TABLE t7(pk BIGINT primary key);\n  CREATE TABLE t8(pk SHORT INTEGER primary key);\n  CREATE TABLE t9(pk UNSIGNED INTEGER primary key);\n} \ndo_test e_createtable-5.4.2.1 { is_integer_primary_key t6 pk } 0\ndo_test e_createtable-5.4.2.2 { is_integer_primary_key t7 pk } 0\ndo_test e_createtable-5.4.2.3 { is_integer_primary_key t8 pk } 0\ndo_test e_createtable-5.4.2.4 { is_integer_primary_key t9 pk } 0\n\ndo_execsql_test 5.4.3 {\n  INSERT INTO t6 VALUES('2.0');\n  INSERT INTO t7 VALUES('2.0');\n  INSERT INTO t8 VALUES('2.0');\n  INSERT INTO t9 VALUES('2.0');\n  SELECT typeof(pk), pk FROM t6;\n  SELECT typeof(pk), pk FROM t7;\n  SELECT typeof(pk), pk FROM t8;\n  SELECT typeof(pk), pk FROM t9;\n} {integer 2 integer 2 integer 2 integer 2}\n\ndo_catchsql_test 5.4.4.1 { \n  INSERT INTO t6 VALUES(2) \n} {1 {UNIQUE constraint failed: t6.pk}}\ndo_catchsql_test 5.4.4.2 { \n  INSERT INTO t7 VALUES(2) \n} {1 {UNIQUE constraint failed: t7.pk}}\ndo_catchsql_test 5.4.4.3 { \n  INSERT INTO t8 VALUES(2) \n} {1 {UNIQUE constraint failed: t8.pk}}\ndo_catchsql_test 5.4.4.4 { \n  INSERT INTO t9 VALUES(2) \n} {1 {UNIQUE constraint failed: t9.pk}}\n\n# EVIDENCE-OF: R-56094-57830 the following three table declarations all\n# cause the column \"x\" to be an alias for the rowid (an integer primary\n# key): CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z); CREATE TABLE\n# t(x INTEGER, y, z, PRIMARY KEY(x ASC)); CREATE TABLE t(x INTEGER, y,\n# z, PRIMARY KEY(x DESC));\n#\n# EVIDENCE-OF: R-20149-25884 the following declaration does not result\n# in \"x\" being an alias for the rowid: CREATE TABLE t(x INTEGER PRIMARY\n# KEY DESC, y, z);\n#\ndo_createtable_tests 5 -tclquery { \n  is_integer_primary_key t x\n} -repair {\n  catchsql { DROP TABLE t }\n} {\n  5.1    \"CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y, z)\"      1\n  5.2    \"CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x ASC))\"  1\n  5.3    \"CREATE TABLE t(x INTEGER, y, z, PRIMARY KEY(x DESC))\" 1\n  6.1    \"CREATE TABLE t(x INTEGER PRIMARY KEY DESC, y, z)\"     0\n}\n\n# EVIDENCE-OF: R-03733-29734 Rowid values may be modified using an\n# UPDATE statement in the same way as any other column value can, either\n# using one of the built-in aliases (\"rowid\", \"oid\" or \"_rowid_\") or by\n# using an alias created by an integer primary key.\n#\ndo_execsql_test 5.7.0 {\n  CREATE TABLE t10(a, b);\n  INSERT INTO t10 VALUES('ten', 10);\n\n  CREATE TABLE t11(a, b INTEGER PRIMARY KEY);\n  INSERT INTO t11 VALUES('ten', 10);\n}\ndo_createtable_tests 5.7.1 -query { \n  SELECT rowid, _rowid_, oid FROM t10;\n} {\n  1    \"UPDATE t10 SET rowid = 5\"   {5 5 5}\n  2    \"UPDATE t10 SET _rowid_ = 6\" {6 6 6}\n  3    \"UPDATE t10 SET oid = 7\"     {7 7 7}\n}\ndo_createtable_tests 5.7.2 -query { \n  SELECT rowid, _rowid_, oid, b FROM t11;\n} {\n  1    \"UPDATE t11 SET rowid = 5\"   {5 5 5 5}\n  2    \"UPDATE t11 SET _rowid_ = 6\" {6 6 6 6}\n  3    \"UPDATE t11 SET oid = 7\"     {7 7 7 7}\n  4    \"UPDATE t11 SET b = 8\"       {8 8 8 8}\n}\n\n# EVIDENCE-OF: R-58706-14229 Similarly, an INSERT statement may provide\n# a value to use as the rowid for each row inserted.\n#\ndo_createtable_tests 5.8.1 -query { \n  SELECT rowid, _rowid_, oid FROM t10;\n} -repair { \n  execsql { DELETE FROM t10 } \n} {\n  1    \"INSERT INTO t10(oid) VALUES(15)\"           {15 15 15}\n  2    \"INSERT INTO t10(rowid) VALUES(16)\"         {16 16 16}\n  3    \"INSERT INTO t10(_rowid_) VALUES(17)\"       {17 17 17}\n  4    \"INSERT INTO t10(a, b, oid) VALUES(1,2,3)\"  {3 3 3}\n}\ndo_createtable_tests 5.8.2 -query { \n  SELECT rowid, _rowid_, oid, b FROM t11;\n} -repair { \n  execsql { DELETE FROM t11 } \n} {\n  1    \"INSERT INTO t11(oid) VALUES(15)\"           {15 15 15 15}\n  2    \"INSERT INTO t11(rowid) VALUES(16)\"         {16 16 16 16}\n  3    \"INSERT INTO t11(_rowid_) VALUES(17)\"       {17 17 17 17}\n  4    \"INSERT INTO t11(a, b) VALUES(1,2)\"         {2 2 2 2}\n}\n\n# EVIDENCE-OF: R-32326-44592 Unlike normal SQLite columns, an integer\n# primary key or rowid column must contain integer values. Integer\n# primary key or rowid columns are not able to hold floating point\n# values, strings, BLOBs, or NULLs.\n#\n#     This is considered by the tests for the following 3 statements,\n#     which show that:\n#\n#       1. Attempts to UPDATE a rowid column to a non-integer value fail,\n#       2. Attempts to INSERT a real, string or blob value into a rowid \n#          column fail, and\n#       3. Attempting to INSERT a NULL value into a rowid column causes the\n#          system to automatically select an integer value to use.\n#\n\n\n# EVIDENCE-OF: R-64224-62578 If an UPDATE statement attempts to set an\n# integer primary key or rowid column to a NULL or blob value, or to a\n# string or real value that cannot be losslessly converted to an\n# integer, a \"datatype mismatch\" error occurs and the statement is\n# aborted.\n#\ndrop_all_tables\ndo_execsql_test 5.9.0 {\n  CREATE TABLE t12(x INTEGER PRIMARY KEY, y);\n  INSERT INTO t12 VALUES(5, 'five');\n}\ndo_createtable_tests 5.9.1 -query { SELECT typeof(x), x FROM t12 } {\n  1   \"UPDATE t12 SET x = 4\"       {integer 4}\n  2   \"UPDATE t12 SET x = 10.0\"    {integer 10}\n  3   \"UPDATE t12 SET x = '12.0'\"  {integer 12}\n  4   \"UPDATE t12 SET x = '-15.0'\" {integer -15}\n}\ndo_createtable_tests 5.9.2 -error {\n  datatype mismatch\n} {\n  1   \"UPDATE t12 SET x = 4.1\"         {}\n  2   \"UPDATE t12 SET x = 'hello'\"     {}\n  3   \"UPDATE t12 SET x = NULL\"        {}\n  4   \"UPDATE t12 SET x = X'ABCD'\"     {}\n  5   \"UPDATE t12 SET x = X'3900'\"     {}\n  6   \"UPDATE t12 SET x = X'39'\"       {}\n}\n\n# EVIDENCE-OF: R-05734-13629 If an INSERT statement attempts to insert a\n# blob value, or a string or real value that cannot be losslessly\n# converted to an integer into an integer primary key or rowid column, a\n# \"datatype mismatch\" error occurs and the statement is aborted.\n#\ndo_execsql_test 5.10.0 { DELETE FROM t12 }\ndo_createtable_tests 5.10.1 -error { \n  datatype mismatch\n} {\n  1   \"INSERT INTO t12(x) VALUES(4.1)\"     {}\n  2   \"INSERT INTO t12(x) VALUES('hello')\" {}\n  3   \"INSERT INTO t12(x) VALUES(X'ABCD')\" {}\n  4   \"INSERT INTO t12(x) VALUES(X'3900')\" {}\n  5   \"INSERT INTO t12(x) VALUES(X'39')\"   {}\n}\ndo_createtable_tests 5.10.2 -query { \n  SELECT typeof(x), x FROM t12 \n} -repair {\n  execsql { DELETE FROM t12 }\n} {\n  1   \"INSERT INTO t12(x) VALUES(4)\"       {integer 4}\n  2   \"INSERT INTO t12(x) VALUES(10.0)\"    {integer 10}\n  3   \"INSERT INTO t12(x) VALUES('12.0')\"  {integer 12}\n  4   \"INSERT INTO t12(x) VALUES('4e3')\"   {integer 4000}\n  5   \"INSERT INTO t12(x) VALUES('-14.0')\" {integer -14}\n}\n\n# EVIDENCE-OF: R-07986-46024 If an INSERT statement attempts to insert a\n# NULL value into a rowid or integer primary key column, the system\n# chooses an integer value to use as the rowid automatically.\n#\ndo_execsql_test 5.11.0 { DELETE FROM t12 }\ndo_createtable_tests 5.11 -query { \n  SELECT typeof(x), x FROM t12 WHERE y IS (SELECT max(y) FROM t12)\n} {\n  1   \"INSERT INTO t12 DEFAULT VALUES\"                {integer 1}\n  2   \"INSERT INTO t12(y)   VALUES(5)\"                {integer 2}\n  3   \"INSERT INTO t12(x,y) VALUES(NULL, 10)\"         {integer 3}\n  4   \"INSERT INTO t12(x,y) SELECT NULL, 15 FROM t12\" \n      {integer 4 integer 5 integer 6}\n  5   \"INSERT INTO t12(y) SELECT 20 FROM t12 LIMIT 3\"\n      {integer 7 integer 8 integer 9}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_delete.test",
    "content": "# 2010 September 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_delete.html document are correct.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nproc do_delete_tests {args} {\n  uplevel do_select_tests $args\n}\n\ndo_execsql_test e_delete-0.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n} {}\n\n# -- syntax diagram delete-stmt\n# -- syntax diagram qualified-table-name\n#\ndo_delete_tests e_delete-0.1 {\n  1  \"DELETE FROM t1\"                              {}\n  2  \"DELETE FROM t1 INDEXED BY i1\"                {}\n  3  \"DELETE FROM t1 NOT INDEXED\"                  {}\n  4  \"DELETE FROM main.t1\"                         {}\n  5  \"DELETE FROM main.t1 INDEXED BY i1\"           {}\n  6  \"DELETE FROM main.t1 NOT INDEXED\"             {}\n  7  \"DELETE FROM t1 WHERE a>2\"                    {}\n  8  \"DELETE FROM t1 INDEXED BY i1 WHERE a>2\"      {}\n  9  \"DELETE FROM t1 NOT INDEXED WHERE a>2\"        {}\n  10 \"DELETE FROM main.t1 WHERE a>2\"               {}\n  11 \"DELETE FROM main.t1 INDEXED BY i1 WHERE a>2\" {}\n  12 \"DELETE FROM main.t1 NOT INDEXED WHERE a>2\"   {}\n}\n\n# EVIDENCE-OF: R-20205-17349 If the WHERE clause is not present, all\n# records in the table are deleted.\n#\ndrop_all_tables\ndo_test e_delete-1.0 {\n  db transaction {\n    foreach t {t1 t2 t3 t4 t5 t6} {\n      execsql [string map [list %T% $t] {\n        CREATE TABLE %T%(x, y);\n        INSERT INTO %T% VALUES(1, 'one');\n        INSERT INTO %T% VALUES(2, 'two');\n        INSERT INTO %T% VALUES(3, 'three');\n        INSERT INTO %T% VALUES(4, 'four');\n        INSERT INTO %T% VALUES(5, 'five');\n      }]\n    }\n  }\n} {}\ndo_delete_tests e_delete-1.1 {\n  1  \"DELETE FROM t1       ; SELECT * FROM t1\"       {}\n  2  \"DELETE FROM main.t2  ; SELECT * FROM t2\"       {}\n}\n\n# EVIDENCE-OF: R-26300-50198 If a WHERE clause is supplied, then only\n# those rows for which the WHERE clause boolean expression is true are\n# deleted.\n#\n# EVIDENCE-OF: R-23360-48280 Rows for which the expression is false or\n# NULL are retained.\n#\ndo_delete_tests e_delete-1.2 {\n  1  \"DELETE FROM t3 WHERE 1       ; SELECT x FROM t3\"       {}\n  2  \"DELETE FROM main.t4 WHERE 0  ; SELECT x FROM t4\"       {1 2 3 4 5}\n  3  \"DELETE FROM t4 WHERE 0.0     ; SELECT x FROM t4\"       {1 2 3 4 5}\n  4  \"DELETE FROM t4 WHERE NULL    ; SELECT x FROM t4\"       {1 2 3 4 5}\n  5  \"DELETE FROM t4 WHERE y!='two'; SELECT x FROM t4\"       {2}\n  6  \"DELETE FROM t4 WHERE y='two' ; SELECT x FROM t4\"       {}\n  7  \"DELETE FROM t5 WHERE x=(SELECT max(x) FROM t5);SELECT x FROM t5\" {1 2 3 4}\n  8  \"DELETE FROM t5 WHERE (SELECT max(x) FROM t4)  ;SELECT x FROM t5\" {1 2 3 4}\n  9  \"DELETE FROM t5 WHERE (SELECT max(x) FROM t6)  ;SELECT x FROM t5\" {}\n  10 \"DELETE FROM t6 WHERE y>'seven' ; SELECT y FROM t6\"     {one four five}\n}\n\n\n#-------------------------------------------------------------------------\n# Tests for restrictions on DELETE statements that appear within trigger\n# programs.\n#\nforcedelete test.db2\nforcedelete test.db3\ndo_execsql_test e_delete-2.0 {\n  ATTACH 'test.db2' AS aux;\n  ATTACH 'test.db3' AS aux2;\n\n  CREATE TABLE temp.t7(a, b);   INSERT INTO temp.t7 VALUES(1, 2);\n  CREATE TABLE main.t7(a, b);   INSERT INTO main.t7 VALUES(3, 4);\n  CREATE TABLE aux.t7(a, b);    INSERT INTO aux.t7 VALUES(5, 6);\n  CREATE TABLE aux2.t7(a, b);   INSERT INTO aux2.t7 VALUES(7, 8);\n\n  CREATE TABLE main.t8(a, b);   INSERT INTO main.t8 VALUES(1, 2);\n  CREATE TABLE aux.t8(a, b);    INSERT INTO aux.t8 VALUES(3, 4);\n  CREATE TABLE aux2.t8(a, b);   INSERT INTO aux2.t8 VALUES(5, 6);\n\n  CREATE TABLE aux.t9(a, b);    INSERT INTO aux.t9 VALUES(1, 2);\n  CREATE TABLE aux2.t9(a, b);   INSERT INTO aux2.t9 VALUES(3, 4);\n\n  CREATE TABLE aux2.t10(a, b);  INSERT INTO aux2.t10 VALUES(1, 2);\n} {}\n\n\n# EVIDENCE-OF: R-09681-58560 The table-name specified as part of a\n# DELETE statement within a trigger body must be unqualified.\n#\n# EVIDENCE-OF: R-12275-20298 In other words, the schema-name. prefix on\n# the table name is not allowed within triggers.\n#\ndo_delete_tests e_delete-2.1 -error {\n  qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers\n} {\n  1 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n        DELETE FROM main.t2;\n      END;\n  } {}\n\n  2 {\n      CREATE TRIGGER tr1 BEFORE UPDATE ON t2 BEGIN\n        DELETE FROM temp.t7 WHERE a=new.a;\n      END;\n  } {}\n\n  3 {\n      CREATE TRIGGER tr1 AFTER UPDATE ON t8 BEGIN\n        DELETE FROM aux2.t8 WHERE b!=a;\n      END;\n  } {}\n}\n\n# EVIDENCE-OF: R-28818-63526 If the table to which the trigger is\n# attached is not in the temp database, then DELETE statements within\n# the trigger body must operate on tables within the same database as\n# it.\n# \n#   This is tested in two parts. First, check that if a table of the\n#   specified name does not exist, an error is raised. Secondly, test\n#   that if tables with the specified name exist in multiple databases,\n#   the local database table is used.\n#\ndo_delete_tests e_delete-2.2.1 -error { no such table: %s } {\n  1 {\n      CREATE TRIGGER main.tr1 AFTER INSERT ON main.t7 BEGIN\n        DELETE FROM t9;\n      END;\n      INSERT INTO main.t7 VALUES(1, 2);\n  } {main.t9}\n\n  2 {\n      CREATE TRIGGER aux.tr2 BEFORE UPDATE ON t9 BEGIN\n        DELETE FROM t10;\n      END;\n      UPDATE t9 SET a=1;\n  } {aux.t10}\n}\ndo_execsql_test e_delete-2.2.X {\n  DROP TRIGGER main.tr1;\n  DROP TRIGGER aux.tr2;\n} {}\n\ndo_delete_tests e_delete-2.2.2 {\n  1 {\n      CREATE TRIGGER aux.tr1 AFTER INSERT ON t8 BEGIN\n        DELETE FROM t9;\n      END;\n      INSERT INTO aux.t8 VALUES(1, 2);\n\n      SELECT count(*) FROM aux.t9 \n        UNION ALL\n      SELECT count(*) FROM aux2.t9;\n  } {0 1}\n\n  2 {\n      CREATE TRIGGER main.tr1 AFTER INSERT ON t8 BEGIN\n        DELETE FROM t7;\n      END;\n      INSERT INTO main.t8 VALUES(1, 2);\n\n      SELECT count(*) FROM temp.t7 \n        UNION ALL\n      SELECT count(*) FROM main.t7\n        UNION ALL\n      SELECT count(*) FROM aux.t7\n        UNION ALL\n      SELECT count(*) FROM aux2.t7;\n  } {1 0 1 1}\n}\n\n# EVIDENCE-OF: R-31567-38587 If the table to which the trigger is\n# attached is in the TEMP database, then the unqualified name of the\n# table being deleted is resolved in the same way as it is for a\n# top-level statement (by searching first the TEMP database, then the\n# main database, then any other databases in the order they were\n# attached).\n#\ndo_execsql_test e_delete-2.3.0 {\n  DROP TRIGGER aux.tr1;\n  DROP TRIGGER main.tr1;\n  DELETE FROM main.t8 WHERE oid>1;\n  DELETE FROM aux.t8 WHERE oid>1;\n  INSERT INTO aux.t9 VALUES(1, 2);\n  INSERT INTO main.t7 VALUES(3, 4);\n} {}\ndo_execsql_test e_delete-2.3.1 {\n  SELECT count(*) FROM temp.t7 UNION ALL SELECT count(*) FROM main.t7 UNION ALL\n  SELECT count(*) FROM aux.t7  UNION ALL SELECT count(*) FROM aux2.t7;\n\n  SELECT count(*) FROM main.t8 UNION ALL SELECT count(*) FROM aux.t8  \n  UNION ALL SELECT count(*) FROM aux2.t8;\n\n  SELECT count(*) FROM aux.t9  UNION ALL SELECT count(*) FROM aux2.t9;\n\n  SELECT count(*) FROM aux2.t10;\n} {1 1 1 1 1 1 1 1 1 1}\ndo_execsql_test e_delete-2.3.2 {\n  CREATE TRIGGER temp.tr1 AFTER INSERT ON t7 BEGIN\n    DELETE FROM t7;\n    DELETE FROM t8;\n    DELETE FROM t9;\n    DELETE FROM t10;\n  END;\n  INSERT INTO temp.t7 VALUES('hello', 'world');\n} {}\ndo_execsql_test e_delete-2.3.3 {\n  SELECT count(*) FROM temp.t7 UNION ALL SELECT count(*) FROM main.t7 UNION ALL\n  SELECT count(*) FROM aux.t7  UNION ALL SELECT count(*) FROM aux2.t7;\n\n  SELECT count(*) FROM main.t8 UNION ALL SELECT count(*) FROM aux.t8  \n  UNION ALL SELECT count(*) FROM aux2.t8;\n\n  SELECT count(*) FROM aux.t9  UNION ALL SELECT count(*) FROM aux2.t9;\n\n  SELECT count(*) FROM aux2.t10;\n} {0 1 1 1 0 1 1 0 1 0}\n\n# EVIDENCE-OF: R-28691-49464 The INDEXED BY and NOT INDEXED clauses are\n# not allowed on DELETE statements within triggers.\n#\ndo_execsql_test e_delete-2.4.0 {\n  CREATE INDEX i8 ON t8(a, b);\n} {}\ndo_delete_tests e_delete-2.4 -error {\n  the %s %s clause is not allowed on UPDATE or DELETE statements within triggers\n} {\n  1 {\n    CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN\n      DELETE FROM t8 INDEXED BY i8 WHERE a=5;\n    END;\n  } {INDEXED BY}\n  2 {\n    CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN\n      DELETE FROM t8 NOT INDEXED WHERE a=5;\n    END;\n  } {NOT INDEXED}\n}\n\nifcapable update_delete_limit {\n\n# EVIDENCE-OF: R-64942-06615 The LIMIT and ORDER BY clauses (described\n# below) are unsupported for DELETE statements within triggers.\n#\ndo_delete_tests e_delete-2.5 -error { near \"%s\": syntax error } {\n  1 {\n    CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN\n      DELETE FROM t8 LIMIT 10;\n    END;\n  } {LIMIT}\n  2 {\n    CREATE TRIGGER tr3 AFTER INSERT ON t8 BEGIN\n      DELETE FROM t8 ORDER BY a LIMIT 5;\n    END;\n  } {ORDER}\n}\n\n# EVIDENCE-OF: R-40026-10531 If SQLite is compiled with the\n# SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option, then the syntax\n# of the DELETE statement is extended by the addition of optional ORDER\n# BY and LIMIT clauses:\n#\n# -- syntax diagram delete-stmt-limited\n#\ndo_delete_tests e_delete-3.1 {\n  1   \"DELETE FROM t1 LIMIT 5\"                                    {}\n  2   \"DELETE FROM t1 LIMIT 5-1 OFFSET 2+2\"                       {}\n  3   \"DELETE FROM t1 LIMIT 2+2, 16/4\"                            {}\n  4   \"DELETE FROM t1 ORDER BY x LIMIT 5\"                         {}\n  5   \"DELETE FROM t1 ORDER BY x LIMIT 5-1 OFFSET 2+2\"            {}\n  6   \"DELETE FROM t1 ORDER BY x LIMIT 2+2, 16/4\"                 {}\n  7   \"DELETE FROM t1 WHERE x>2 LIMIT 5\"                          {}\n  8   \"DELETE FROM t1 WHERE x>2 LIMIT 5-1 OFFSET 2+2\"             {}\n  9   \"DELETE FROM t1 WHERE x>2 LIMIT 2+2, 16/4\"                  {}\n  10  \"DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 5\"               {}\n  11  \"DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 5-1 OFFSET 2+2\"  {}\n  12  \"DELETE FROM t1 WHERE x>2 ORDER BY x LIMIT 2+2, 16/4\"       {}\n}\n\ndrop_all_tables\nproc rebuild_t1 {} {\n  catchsql { DROP TABLE t1 }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t1 VALUES(4, 'four');\n    INSERT INTO t1 VALUES(5, 'five');\n  }\n}\n\n# EVIDENCE-OF: R-44062-08550 If a DELETE statement has a LIMIT clause,\n# the maximum number of rows that will be deleted is found by evaluating\n# the accompanying expression and casting it to an integer value.\n#\nrebuild_t1\ndo_delete_tests e_delete-3.2 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1   \"DELETE FROM t1 LIMIT 3\"       {4 5}\n  2   \"DELETE FROM t1 LIMIT 1+1\"     {3 4 5}\n  3   \"DELETE FROM t1 LIMIT '4'\"     {5}\n  4   \"DELETE FROM t1 LIMIT '1.0'\"   {2 3 4 5}\n}\n\n# EVIDENCE-OF: R-02661-56399 If the result of the evaluating the LIMIT\n# clause cannot be losslessly converted to an integer value, it is an\n# error.\n#\ndo_delete_tests e_delete-3.3 -error { datatype mismatch } {\n  1   \"DELETE FROM t1 LIMIT 'abc'\"   {}\n  2   \"DELETE FROM t1 LIMIT NULL\"    {}\n  3   \"DELETE FROM t1 LIMIT X'ABCD'\" {}\n  4   \"DELETE FROM t1 LIMIT 1.2\"     {}\n}\n\n# EVIDENCE-OF: R-00598-03741 A negative LIMIT value is interpreted as\n# \"no limit\".\n#\ndo_delete_tests e_delete-3.4 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1   \"DELETE FROM t1 LIMIT -1\"       {}\n  2   \"DELETE FROM t1 LIMIT 2-4\"      {}\n  3   \"DELETE FROM t1 LIMIT -4.0\"     {}\n  4   \"DELETE FROM t1 LIMIT 5*-1\"     {}\n}\n\n# EVIDENCE-OF: R-26377-49195 If the DELETE statement also has an OFFSET\n# clause, then it is similarly evaluated and cast to an integer value.\n# Again, it is an error if the value cannot be losslessly converted to\n# an integer.\n#\ndo_delete_tests e_delete-3.5 -error { datatype mismatch } {\n  1   \"DELETE FROM t1 LIMIT 1 OFFSET 'abc'\"   {}\n  2   \"DELETE FROM t1 LIMIT 1 OFFSET NULL\"    {}\n  3   \"DELETE FROM t1 LIMIT 1 OFFSET X'ABCD'\" {}\n  4   \"DELETE FROM t1 LIMIT 1 OFFSET 1.2\"     {}\n  5   \"DELETE FROM t1 LIMIT 'abc', 1\"         {}\n  6   \"DELETE FROM t1 LIMIT NULL, 1\"          {}\n  7   \"DELETE FROM t1 LIMIT X'ABCD', 1\"       {}\n  8   \"DELETE FROM t1 LIMIT 1.2, 1\"           {}\n}\n\n\n# EVIDENCE-OF: R-64004-53814 If there is no OFFSET clause, or the\n# calculated integer value is negative, the effective OFFSET value is\n# zero.\n#\ndo_delete_tests e_delete-3.6 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1a  \"DELETE FROM t1 LIMIT 3 OFFSET 0\"        {4 5}\n  1b  \"DELETE FROM t1 LIMIT 3\"                 {4 5}\n  1c  \"DELETE FROM t1 LIMIT 3 OFFSET -1\"       {4 5}\n  2a  \"DELETE FROM t1 LIMIT 1+1 OFFSET 0\"      {3 4 5}\n  2b  \"DELETE FROM t1 LIMIT 1+1\"               {3 4 5}\n  2c  \"DELETE FROM t1 LIMIT 1+1 OFFSET 2-5\"    {3 4 5}\n  3a  \"DELETE FROM t1 LIMIT '4' OFFSET 0\"      {5}\n  3b  \"DELETE FROM t1 LIMIT '4'\"               {5}\n  3c  \"DELETE FROM t1 LIMIT '4' OFFSET -1.0\"   {5}\n  4a  \"DELETE FROM t1 LIMIT '1.0' OFFSET 0\"    {2 3 4 5}\n  4b  \"DELETE FROM t1 LIMIT '1.0'\"             {2 3 4 5}\n  4c  \"DELETE FROM t1 LIMIT '1.0' OFFSET -11\"  {2 3 4 5}\n}\n\n# EVIDENCE-OF: R-48141-52334 If the DELETE statement has an ORDER BY\n# clause, then all rows that would be deleted in the absence of the\n# LIMIT clause are sorted according to the ORDER BY. The first M rows,\n# where M is the value found by evaluating the OFFSET clause expression,\n# are skipped, and the following N, where N is the value of the LIMIT\n# expression, are deleted.\n#\ndo_delete_tests e_delete-3.7 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1   \"DELETE FROM t1 ORDER BY b LIMIT 2\"               {1 2 3}\n  2   \"DELETE FROM t1 ORDER BY length(b), a LIMIT 3\"    {3 5}\n  3   \"DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 0\"  {1 2 3 4}\n  4   \"DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 1\"  {1 2 3 5}\n  5   \"DELETE FROM t1 ORDER BY a DESC LIMIT 1 OFFSET 2\"  {1 2 4 5}\n}\n\n# EVIDENCE-OF: R-64535-08414 If there are less than N rows remaining\n# after taking the OFFSET clause into account, or if the LIMIT clause\n# evaluated to a negative value, then all remaining rows are deleted.\n#\ndo_delete_tests e_delete-3.8 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1   \"DELETE FROM t1 ORDER BY a ASC LIMIT 10\"           {}\n  2   \"DELETE FROM t1 ORDER BY a ASC LIMIT -1\"           {}\n  3   \"DELETE FROM t1 ORDER BY a ASC LIMIT 4 OFFSET 2\"   {1 2}\n}\n\n# EVIDENCE-OF: R-37284-06965 If the DELETE statement has no ORDER BY\n# clause, then all rows that would be deleted in the absence of the\n# LIMIT clause are assembled in an arbitrary order before applying the\n# LIMIT and OFFSET clauses to determine the subset that are actually\n# deleted.\n#\n#     In practice, the \"arbitrary order\" is rowid order.\n#\ndo_delete_tests e_delete-3.9 -repair rebuild_t1 -query {\n  SELECT a FROM t1\n} {\n  1   \"DELETE FROM t1 LIMIT 2\"               {3 4 5}\n  2   \"DELETE FROM t1 LIMIT 3\"               {4 5}\n  3   \"DELETE FROM t1 LIMIT 1 OFFSET 0\"      {2 3 4 5}\n  4   \"DELETE FROM t1 LIMIT 1 OFFSET 1\"      {1 3 4 5}\n  5   \"DELETE FROM t1 LIMIT 1 OFFSET 2\"      {1 2 4 5}\n}\n\n\n# EVIDENCE-OF: R-07548-13422 The ORDER BY clause on a DELETE statement\n# is used only to determine which rows fall within the LIMIT. The order\n# in which rows are deleted is arbitrary and is not influenced by the\n# ORDER BY clause.\n#\n#     In practice, rows are always deleted in rowid order.\n#\ndo_delete_tests e_delete-3.10 -repair {\n  rebuild_t1 \n  catchsql { DROP TABLE t1log }\n  execsql {\n    CREATE TABLE t1log(x);\n    CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN\n      INSERT INTO t1log VALUES(old.a);\n    END;\n  }\n} -query {\n  SELECT x FROM t1log\n} {\n  1   \"DELETE FROM t1 ORDER BY a DESC LIMIT 2\"   {4 5}\n  2   \"DELETE FROM t1 ORDER BY a DESC LIMIT -1\"  {1 2 3 4 5}\n  3   \"DELETE FROM t1 ORDER BY a ASC LIMIT 2\"    {1 2}\n  4   \"DELETE FROM t1 ORDER BY a ASC LIMIT -1\"   {1 2 3 4 5}\n}\n\n}\n \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_droptrigger.test",
    "content": "# 2010 November 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_droptrigger.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix e_droptrigger\n\nifcapable !trigger { finish_test ; return }\n\nproc do_droptrigger_tests {nm args} {\n  uplevel do_select_tests [list e_createtable-$nm] $args\n}\n\nproc list_all_triggers {{db db}} {\n  set res [list]\n  $db eval { PRAGMA database_list } {\n    if {$name == \"temp\"} {\n      set tbl sqlite_temp_master\n    } else {\n      set tbl \"$name.sqlite_master\"\n    }\n    lappend res {*}[\n      db eval \"SELECT '$name.' || name FROM $tbl WHERE type = 'trigger'\"\n    ]\n  }\n  set res\n}\n\n\nproc droptrigger_reopen_db {{event INSERT}} {\n  db close\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n\n  set ::triggers_fired [list]\n  proc r {x} { lappend ::triggers_fired $x }\n  db func r r\n\n  db eval \"\n    ATTACH 'test.db2' AS aux;\n\n    CREATE TEMP TABLE t1(a, b);\n    INSERT INTO t1 VALUES('a', 'b');\n    CREATE TRIGGER tr1 AFTER $event ON t1 BEGIN SELECT r('temp.tr1') ; END;\n\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES('a', 'b');\n    CREATE TRIGGER tr1 BEFORE $event ON t2 BEGIN SELECT r('main.tr1') ; END;\n    CREATE TRIGGER tr2 AFTER  $event ON t2 BEGIN SELECT r('main.tr2') ; END;\n\n    CREATE TABLE aux.t3(a, b);\n    INSERT INTO t3 VALUES('a', 'b');\n    CREATE TRIGGER aux.tr1 BEFORE $event ON t3 BEGIN SELECT r('aux.tr1') ; END;\n    CREATE TRIGGER aux.tr2 AFTER  $event ON t3 BEGIN SELECT r('aux.tr2') ; END;\n    CREATE TRIGGER aux.tr3 AFTER  $event ON t3 BEGIN SELECT r('aux.tr3') ; END;\n  \"\n}\n\n\n# -- syntax diagram drop-trigger-stmt\n#\ndo_droptrigger_tests 1.1 -repair {\n  droptrigger_reopen_db\n} -tclquery {\n  list_all_triggers \n} {\n  1   \"DROP TRIGGER main.tr1\"            \n      {main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}\n  2   \"DROP TRIGGER IF EXISTS main.tr1\"  \n      {main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}\n  3   \"DROP TRIGGER tr1\"                 \n      {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}\n  4   \"DROP TRIGGER IF EXISTS tr1\"       \n      {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}\n\n  5   \"DROP TRIGGER aux.tr1\"             \n      {main.tr1 main.tr2 temp.tr1 aux.tr2 aux.tr3}\n  6   \"DROP TRIGGER IF EXISTS aux.tr1\"   \n      {main.tr1 main.tr2 temp.tr1 aux.tr2 aux.tr3}\n\n  7   \"DROP TRIGGER IF EXISTS aux.xxx\"   \n      {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}\n  8   \"DROP TRIGGER IF EXISTS aux.xxx\"   \n      {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}\n}\n\n# EVIDENCE-OF: R-61172-15671 The DROP TRIGGER statement removes a\n# trigger created by the CREATE TRIGGER statement.\n#\nforeach {tn tbl droptrigger before after} {\n  1   t1  \"DROP TRIGGER tr1\" {temp.tr1}                {}\n  2   t2  \"DROP TRIGGER tr1\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  3   t3  \"DROP TRIGGER tr1\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  4   t1  \"DROP TRIGGER tr2\" {temp.tr1}                {temp.tr1}\n  5   t2  \"DROP TRIGGER tr2\" {main.tr1 main.tr2}       {main.tr1}\n  6   t3  \"DROP TRIGGER tr2\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  7   t1  \"DROP TRIGGER tr3\" {temp.tr1}                {temp.tr1}\n  8   t2  \"DROP TRIGGER tr3\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  9   t3  \"DROP TRIGGER tr3\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}\n} {\n\n  do_test 2.$tn.1 {\n    droptrigger_reopen_db\n    execsql \" INSERT INTO $tbl VALUES('1', '2') \"\n    set ::triggers_fired\n  } $before\n\n  do_test 2.$tn.2 {\n    droptrigger_reopen_db\n    execsql $droptrigger\n    execsql \" INSERT INTO $tbl VALUES('1', '2') \"\n    set ::triggers_fired\n  } $after\n}\n\n# EVIDENCE-OF: R-50239-29811 Once removed, the trigger definition is no\n# longer present in the sqlite_master (or sqlite_temp_master) table and\n# is not fired by any subsequent INSERT, UPDATE or DELETE statements.\n#\n#   Test cases e_droptrigger-1.* test the first part of this statement\n#   (that dropped triggers do not appear in the schema table), and tests\n#   droptrigger-2.* test that dropped triggers are not fired by INSERT\n#   statements. The following tests verify that they are not fired by\n#   UPDATE or DELETE statements.\n#\nforeach {tn tbl droptrigger before after} {\n  1   t1  \"DROP TRIGGER tr1\" {temp.tr1}                {}\n  2   t2  \"DROP TRIGGER tr1\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  3   t3  \"DROP TRIGGER tr1\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  4   t1  \"DROP TRIGGER tr2\" {temp.tr1}                {temp.tr1}\n  5   t2  \"DROP TRIGGER tr2\" {main.tr1 main.tr2}       {main.tr1}\n  6   t3  \"DROP TRIGGER tr2\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  7   t1  \"DROP TRIGGER tr3\" {temp.tr1}                {temp.tr1}\n  8   t2  \"DROP TRIGGER tr3\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  9   t3  \"DROP TRIGGER tr3\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}\n} {\n\n  do_test 3.1.$tn.1 {\n    droptrigger_reopen_db UPDATE\n    execsql \"UPDATE $tbl SET a = 'abc'\"\n    set ::triggers_fired\n  } $before\n\n  do_test 3.1.$tn.2 {\n    droptrigger_reopen_db UPDATE\n    execsql $droptrigger\n    execsql \"UPDATE $tbl SET a = 'abc'\"\n    set ::triggers_fired\n  } $after\n}\nforeach {tn tbl droptrigger before after} {\n  1   t1  \"DROP TRIGGER tr1\" {temp.tr1}                {}\n  2   t2  \"DROP TRIGGER tr1\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  3   t3  \"DROP TRIGGER tr1\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  4   t1  \"DROP TRIGGER tr2\" {temp.tr1}                {temp.tr1}\n  5   t2  \"DROP TRIGGER tr2\" {main.tr1 main.tr2}       {main.tr1}\n  6   t3  \"DROP TRIGGER tr2\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr3 aux.tr2}\n\n  7   t1  \"DROP TRIGGER tr3\" {temp.tr1}                {temp.tr1}\n  8   t2  \"DROP TRIGGER tr3\" {main.tr1 main.tr2}       {main.tr1 main.tr2}\n  9   t3  \"DROP TRIGGER tr3\" {aux.tr1 aux.tr3 aux.tr2} {aux.tr1 aux.tr2}\n} {\n\n  do_test 3.2.$tn.1 {\n    droptrigger_reopen_db DELETE\n    execsql \"DELETE FROM $tbl\"\n    set ::triggers_fired\n  } $before\n\n  do_test 3.2.$tn.2 {\n    droptrigger_reopen_db DELETE\n    execsql $droptrigger\n    execsql \"DELETE FROM $tbl\"\n    set ::triggers_fired\n  } $after\n}\n\n# EVIDENCE-OF: R-37808-62273 Note that triggers are automatically\n# dropped when the associated table is dropped.\n#\ndo_test 4.1 {\n  droptrigger_reopen_db\n  list_all_triggers\n} {main.tr1 main.tr2 temp.tr1 aux.tr1 aux.tr2 aux.tr3}\ndo_test 4.2 {\n  droptrigger_reopen_db\n  execsql \"DROP TABLE t1\"\n  list_all_triggers\n} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}\ndo_test 4.3 {\n  droptrigger_reopen_db\n  execsql \"DROP TABLE t1\"\n  list_all_triggers\n} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}\ndo_test 4.4 {\n  droptrigger_reopen_db\n  execsql \"DROP TABLE t1\"\n  list_all_triggers\n} {main.tr1 main.tr2 aux.tr1 aux.tr2 aux.tr3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_dropview.test",
    "content": "# 2010 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_dropview.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix e_dropview\n\nproc dropview_reopen_db {} {\n  db close\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n\n  db eval {\n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE t1(a, b); \n    INSERT INTO t1 VALUES('a main', 'b main');\n    CREATE VIEW v1 AS SELECT * FROM t1;\n    CREATE VIEW v2 AS SELECT * FROM t1;\n\n    CREATE TEMP TABLE t1(a, b);\n    INSERT INTO temp.t1 VALUES('a temp', 'b temp');\n    CREATE VIEW temp.v1 AS SELECT * FROM t1;\n\n    CREATE TABLE aux.t1(a, b);\n    INSERT INTO aux.t1 VALUES('a aux', 'b aux');\n    CREATE VIEW aux.v1 AS SELECT * FROM t1;\n    CREATE VIEW aux.v2 AS SELECT * FROM t1;\n    CREATE VIEW aux.v3 AS SELECT * FROM t1;\n  }\n}\n\nproc list_all_views {{db db}} {\n  set res [list]\n  $db eval { PRAGMA database_list } {\n    set tbl \"$name.sqlite_master\"\n    if {$name == \"temp\"} { set tbl temp.sqlite_master }\n\n    set sql \"SELECT '$name.' || name FROM $tbl WHERE type = 'view'\"\n    lappend res {*}[$db eval $sql]\n  }\n  set res\n}\n\nproc list_all_data {{db db}} {\n  set res [list]\n  $db eval { PRAGMA database_list } {\n    set tbl \"$name.sqlite_master\"\n    if {$name == \"temp\"} { set tbl sqlite_temp_master }\n\n    db eval \"SELECT '$name.' || name AS x FROM $tbl WHERE type = 'table'\" {\n      lappend res [list $x [db eval \"SELECT * FROM $x\"]]\n    }\n  }\n  set res\n}\n\nproc do_dropview_tests {nm args} {\n  uplevel do_select_tests $nm $args\n}\n\n# -- syntax diagram drop-view-stmt\n#\n# All paths in the syntax diagram for DROP VIEW are tested by tests 1.*.\n#\ndo_dropview_tests 1 -repair {\n  dropview_reopen_db\n} -tclquery {\n  list_all_views\n} {\n  1   \"DROP VIEW v1\"                  {main.v1 main.v2 aux.v1 aux.v2 aux.v3}\n  2   \"DROP VIEW v2\"                  {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}\n  3   \"DROP VIEW main.v1\"             {main.v2 temp.v1 aux.v1 aux.v2 aux.v3}\n  4   \"DROP VIEW main.v2\"             {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}\n  5   \"DROP VIEW IF EXISTS v1\"        {main.v1 main.v2 aux.v1 aux.v2 aux.v3}\n  6   \"DROP VIEW IF EXISTS v2\"        {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}\n  7   \"DROP VIEW IF EXISTS main.v1\"   {main.v2 temp.v1 aux.v1 aux.v2 aux.v3}\n  8   \"DROP VIEW IF EXISTS main.v2\"   {main.v1 temp.v1 aux.v1 aux.v2 aux.v3}\n}\n\n# EVIDENCE-OF: R-27002-52307 The DROP VIEW statement removes a view\n# created by the CREATE VIEW statement.\n#\ndropview_reopen_db\ndo_execsql_test 2.1 {\n  CREATE VIEW \"new view\" AS SELECT * FROM t1 AS x, t1 AS y;\n  SELECT * FROM \"new view\";\n} {{a main} {b main} {a main} {b main}}\ndo_execsql_test 2.2 {;\n  SELECT * FROM sqlite_master WHERE name = 'new view';\n} {\n  view {new view} {new view} 0 \n  {CREATE VIEW \"new view\" AS SELECT * FROM t1 AS x, t1 AS y}\n}\ndo_execsql_test 2.3 {\n  DROP VIEW \"new view\";\n  SELECT * FROM sqlite_master WHERE name = 'new view';\n} {}\ndo_catchsql_test 2.4 {\n  SELECT * FROM \"new view\"\n} {1 {no such table: new view}}\n\n# EVIDENCE-OF: R-00359-41639 The view definition is removed from the\n# database schema, but no actual data in the underlying base tables is\n# modified.\n#\n#     For each view in the database, check that it can be queried. Then drop\n#     it. Check that it can no longer be queried and is no longer listed\n#     in any schema table. Then check that the contents of the db tables have \n#     not changed\n#\nset databasedata [list_all_data]\n\ndo_execsql_test  3.1.0 { SELECT * FROM temp.v1 } {{a temp} {b temp}}\ndo_execsql_test  3.1.1 { DROP VIEW temp.v1 } {}\ndo_catchsql_test 3.1.2 { SELECT * FROM temp.v1 } {1 {no such table: temp.v1}}\ndo_test          3.1.3 { list_all_views } {main.v1 main.v2 aux.v1 aux.v2 aux.v3}\ndo_test          3.1.4 { list_all_data  } $databasedata\n\ndo_execsql_test  3.2.0 { SELECT * FROM v1 } {{a main} {b main}}\ndo_execsql_test  3.2.1 { DROP VIEW v1 } {}\ndo_catchsql_test 3.2.2 { SELECT * FROM main.v1 } {1 {no such table: main.v1}}\ndo_test          3.2.3 { list_all_views } {main.v2 aux.v1 aux.v2 aux.v3}\ndo_test          3.2.4 { list_all_data  } $databasedata\n\ndo_execsql_test  3.3.0 { SELECT * FROM v2 } {{a main} {b main}}\ndo_execsql_test  3.3.1 { DROP VIEW v2 } {}\ndo_catchsql_test 3.3.2 { SELECT * FROM main.v2 } {1 {no such table: main.v2}}\ndo_test          3.3.3 { list_all_views } {aux.v1 aux.v2 aux.v3}\ndo_test          3.3.4 { list_all_data  } $databasedata\n\ndo_execsql_test  3.4.0 { SELECT * FROM v1 } {{a aux} {b aux}}\ndo_execsql_test  3.4.1 { DROP VIEW v1 } {}\ndo_catchsql_test 3.4.2 { SELECT * FROM v1 } {1 {no such table: v1}}\ndo_test          3.4.3 { list_all_views } {aux.v2 aux.v3}\ndo_test          3.4.4 { list_all_data  } $databasedata\n\ndo_execsql_test  3.4.0 { SELECT * FROM aux.v2 } {{a aux} {b aux}}\ndo_execsql_test  3.4.1 { DROP VIEW aux.v2 } {}\ndo_catchsql_test 3.4.2 { SELECT * FROM aux.v2 } {1 {no such table: aux.v2}}\ndo_test          3.4.3 { list_all_views } {aux.v3}\ndo_test          3.4.4 { list_all_data  } $databasedata\n\ndo_execsql_test  3.5.0 { SELECT * FROM v3 } {{a aux} {b aux}}\ndo_execsql_test  3.5.1 { DROP VIEW v3 } {}\ndo_catchsql_test 3.5.2 { SELECT * FROM v3 } {1 {no such table: v3}}\ndo_test          3.5.3 { list_all_views } {}\ndo_test          3.5.4 { list_all_data  } $databasedata\n\n# EVIDENCE-OF: R-25558-37487 If the specified view cannot be found and\n# the IF EXISTS clause is not present, it is an error.\n#\ndo_dropview_tests 4 -repair {\n  dropview_reopen_db \n} -errorformat {\n  no such view: %s\n} {\n  1   \"DROP VIEW xx\"                  xx\n  2   \"DROP VIEW main.xx\"             main.xx\n  3   \"DROP VIEW temp.v2\"             temp.v2\n}\n\n# EVIDENCE-OF: R-07490-32536 If the specified view cannot be found and\n# an IF EXISTS clause is present in the DROP VIEW statement, then the\n# statement is a no-op.\n#\ndo_dropview_tests 5 -repair {\n  dropview_reopen_db\n} -tclquery {\n  list_all_views\n  expr {[list_all_views] == \"main.v1 main.v2 temp.v1 aux.v1 aux.v2 aux.v3\"}\n} {\n  1    \"DROP VIEW IF EXISTS xx\"       1\n  2    \"DROP VIEW IF EXISTS main.xx\"  1\n  3    \"DROP VIEW IF EXISTS temp.v2\"  1\n}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_expr.test",
    "content": "# 2010 July 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_expr.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nproc do_expr_test {tn expr type value} {\n  uplevel do_execsql_test $tn [list \"SELECT typeof($expr), $expr\"] [\n    list [list $type $value]\n  ]\n}\n\nproc do_qexpr_test {tn expr value} {\n  uplevel do_execsql_test $tn [list \"SELECT quote($expr)\"] [list $value]\n}\n\n# Set up three global variables:\n#\n#   ::opname         An array mapping from SQL operator to an easy to parse\n#                    name. The names are used as part of test case names.\n#\n#   ::opprec         An array mapping from SQL operator to a numeric\n#                    precedence value. Operators that group more tightly\n#                    have lower numeric precedences.\n#\n#   ::oplist         A list of all SQL operators supported by SQLite.\n#\nforeach {op opn} {\n      ||   cat     *   mul       /  div       %     mod       +      add\n      -    sub     <<  lshift    >> rshift    &     bitand    |      bitor\n      <    less    <=  lesseq    >  more      >=    moreeq    =      eq1\n      ==   eq2     <>  ne1       != ne2       IS    is        LIKE   like\n      GLOB glob    AND and       OR or        MATCH match     REGEXP regexp\n      {IS NOT} isnt\n} {\n  set ::opname($op) $opn\n}\nset oplist [list]\nforeach {prec opl} {\n  1   ||\n  2   {* / %}\n  3   {+ -}\n  4   {<< >> & |}\n  5   {< <= > >=}\n  6   {= == != <> IS {IS NOT} LIKE GLOB MATCH REGEXP}\n  7   AND\n  8   OR\n} {\n  foreach op $opl { \n    set ::opprec($op) $prec \n    lappend oplist $op\n  }\n}\n\n\n# Hook in definitions of MATCH and REGEX. The following implementations\n# cause MATCH and REGEX to behave similarly to the == operator.\n#\nproc matchfunc {a b} { return [expr {$a==$b}] }\nproc regexfunc {a b} { return [expr {$a==$b}] }\ndb func match  -argcount 2 matchfunc\ndb func regexp -argcount 2 regexfunc\n\n#-------------------------------------------------------------------------\n# Test cases e_expr-1.* attempt to verify that all binary operators listed\n# in the documentation exist and that the relative precedences of the\n# operators are also as the documentation suggests.\n#\n# EVIDENCE-OF: R-15514-65163 SQLite understands the following binary\n# operators, in order from highest to lowest precedence: || * / % + -\n# << >> & | < <= > >= = == != <> IS IS\n# NOT IN LIKE GLOB MATCH REGEXP AND OR\n#\n# EVIDENCE-OF: R-38759-38789 Operators IS and IS NOT have the same\n# precedence as =.\n#\n\nunset -nocomplain untested\nforeach op1 $oplist {\n  foreach op2 $oplist {\n    set untested($op1,$op2) 1\n    foreach {tn A B C} {\n       1     22   45    66\n       2      0    0     0\n       3      0    0     1\n       4      0    1     0\n       5      0    1     1\n       6      1    0     0\n       7      1    0     1\n       8      1    1     0\n       9      1    1     1\n      10      5    6     1\n      11      1    5     6\n      12      1    5     5\n      13      5    5     1\n\n      14      5    2     1\n      15      1    4     1\n      16     -1    0     1\n      17      0    1    -1\n\n    } {\n      set testname \"e_expr-1.$opname($op1).$opname($op2).$tn\"\n\n      # If $op2 groups more tightly than $op1, then the result\n      # of executing $sql1 whould be the same as executing $sql3.\n      # If $op1 groups more tightly, or if $op1 and $op2 have \n      # the same precedence, then executing $sql1 should return\n      # the same value as $sql2.\n      #\n      set sql1 \"SELECT $A $op1 $B $op2 $C\"\n      set sql2 \"SELECT ($A $op1 $B) $op2 $C\"\n      set sql3 \"SELECT $A $op1 ($B $op2 $C)\"\n\n      set a2 [db one $sql2]\n      set a3 [db one $sql3]\n\n      do_execsql_test $testname $sql1 [list [\n        if {$opprec($op2) < $opprec($op1)} {set a3} {set a2}\n      ]]\n      if {$a2 != $a3} { unset -nocomplain untested($op1,$op2) }\n    }\n  }\n}\n\nforeach op {* AND OR + || & |} { unset untested($op,$op) }\nunset untested(+,-)  ;#       Since    (a+b)-c == a+(b-c)\nunset untested(*,<<) ;#       Since    (a*b)<<c == a*(b<<c)\n\ndo_test e_expr-1.1 { array names untested } {}\n\n# At one point, test 1.2.2 was failing. Instead of the correct result, it\n# was returning {1 1 0}. This would seem to indicate that LIKE has the\n# same precedence as '<'. Which is incorrect. It has lower precedence.\n#\ndo_execsql_test e_expr-1.2.1 { \n  SELECT 0 < 2 LIKE 1,   (0 < 2) LIKE 1,   0 < (2 LIKE 1)\n} {1 1 0}\ndo_execsql_test e_expr-1.2.2 { \n  SELECT 0 LIKE 0 < 2,   (0 LIKE 0) < 2,   0 LIKE (0 < 2)\n} {0 1 0}\n\n# Showing that LIKE and == have the same precedence\n#\ndo_execsql_test e_expr-1.2.3 { \n  SELECT 2 LIKE 2 == 1,   (2 LIKE 2) == 1,    2 LIKE (2 == 1)\n} {1 1 0}\ndo_execsql_test e_expr-1.2.4 { \n  SELECT 2 == 2 LIKE 1,   (2 == 2) LIKE 1,    2 == (2 LIKE 1)\n} {1 1 0}\n\n# Showing that < groups more tightly than == (< has higher precedence). \n#\ndo_execsql_test e_expr-1.2.5 { \n  SELECT 0 < 2 == 1,   (0 < 2) == 1,   0 < (2 == 1)\n} {1 1 0}\ndo_execsql_test e_expr-1.6 { \n  SELECT 0 == 0 < 2,   (0 == 0) < 2,   0 == (0 < 2)\n} {0 1 0}\n\n#-------------------------------------------------------------------------\n# Check that the four unary prefix operators mentioned in the \n# documentation exist.\n#\n# EVIDENCE-OF: R-13958-53419 Supported unary prefix operators are these:\n# - + ~ NOT\n#\ndo_execsql_test e_expr-2.1 { SELECT -   10   } {-10}\ndo_execsql_test e_expr-2.2 { SELECT +   10   } {10}\ndo_execsql_test e_expr-2.3 { SELECT ~   10   } {-11}\ndo_execsql_test e_expr-2.4 { SELECT NOT 10   } {0}\n\n#-------------------------------------------------------------------------\n# Tests for the two statements made regarding the unary + operator.\n#\n# EVIDENCE-OF: R-53670-03373 The unary operator + is a no-op.\n#\n# EVIDENCE-OF: R-19480-30968 It can be applied to strings, numbers,\n# blobs or NULL and it always returns a result with the same value as\n# the operand.\n#\nforeach {tn literal type} {\n  1     'helloworld'   text\n  2     45             integer\n  3     45.2           real\n  4     45.0           real\n  5     X'ABCDEF'      blob\n  6     NULL           null\n} {\n  set sql \" SELECT quote( + $literal ), typeof( + $literal) \"\n  do_execsql_test e_expr-3.$tn $sql [list $literal $type]\n}\n\n#-------------------------------------------------------------------------\n# Check that both = and == are both acceptable as the \"equals\" operator.\n# Similarly, either != or <> work as the not-equals operator.\n#\n# EVIDENCE-OF: R-03679-60639 Equals can be either = or ==.\n#\n# EVIDENCE-OF: R-30082-38996 The non-equals operator can be either != or\n# <>.\n#\nforeach {tn literal different} {\n  1   'helloworld'  '12345'\n  2   22            23\n  3   'xyz'         X'78797A'\n  4   X'78797A00'   'xyz'\n} {\n  do_execsql_test e_expr-4.$tn \"\n    SELECT $literal  = $literal,   $literal == $literal,\n           $literal  = $different, $literal == $different,\n           $literal  = NULL,       $literal == NULL,\n           $literal != $literal,   $literal <> $literal,\n           $literal != $different, $literal <> $different,\n           $literal != NULL,       $literal != NULL\n\n  \" {1 1 0 0 {} {} 0 0 1 1 {} {}}\n}\n\n#-------------------------------------------------------------------------\n# Test the || operator.\n#\n# EVIDENCE-OF: R-44409-62641 The || operator is \"concatenate\" - it joins\n# together the two strings of its operands.\n#\nforeach {tn a b} {\n  1   'helloworld'  '12345'\n  2   22            23\n} {\n  set as [db one \"SELECT $a\"]\n  set bs [db one \"SELECT $b\"]\n  \n  do_execsql_test e_expr-5.$tn \"SELECT $a || $b\" [list \"${as}${bs}\"]\n}\n\n#-------------------------------------------------------------------------\n# Test the % operator.\n#\n# EVIDENCE-OF: R-04223-04352 The operator % outputs the integer value of\n# its left operand modulo its right operand.\n#\ndo_execsql_test e_expr-6.1 {SELECT  72%5}  {2}\ndo_execsql_test e_expr-6.2 {SELECT  72%-5} {2}\ndo_execsql_test e_expr-6.3 {SELECT -72%-5} {-2}\ndo_execsql_test e_expr-6.4 {SELECT -72%5}  {-2}\ndo_execsql_test e_expr-6.5 {SELECT 72.35%5} {2.0}\n\n#-------------------------------------------------------------------------\n# Test that the results of all binary operators are either numeric or \n# NULL, except for the || operator, which may evaluate to either a text\n# value or NULL.\n#\n# EVIDENCE-OF: R-20665-17792 The result of any binary operator is either\n# a numeric value or NULL, except for the || concatenation operator\n# which always evaluates to either NULL or a text value.\n#\nset literals {\n  1 'abc'        2 'hexadecimal'       3 ''\n  4 123          5 -123                6 0\n  7 123.4        8 0.0                 9 -123.4\n 10 X'ABCDEF'   11 X''                12 X'0000'\n 13     NULL\n}\nforeach op $oplist {\n  foreach {n1 rhs} $literals { \n  foreach {n2 lhs} $literals {\n\n    set t [db one \" SELECT typeof($lhs $op $rhs) \"]\n    do_test e_expr-7.$opname($op).$n1.$n2 {\n      expr {\n           ($op==\"||\" && ($t == \"text\" || $t == \"null\"))\n        || ($op!=\"||\" && ($t == \"integer\" || $t == \"real\" || $t == \"null\"))\n      }\n    } 1\n\n  }}\n}\n\n#-------------------------------------------------------------------------\n# Test the IS and IS NOT operators.\n#\n# EVIDENCE-OF: R-24731-45773 The IS and IS NOT operators work like = and\n# != except when one or both of the operands are NULL.\n#\n# EVIDENCE-OF: R-06325-15315 In this case, if both operands are NULL,\n# then the IS operator evaluates to 1 (true) and the IS NOT operator\n# evaluates to 0 (false).\n#\n# EVIDENCE-OF: R-19812-36779 If one operand is NULL and the other is\n# not, then the IS operator evaluates to 0 (false) and the IS NOT\n# operator is 1 (true).\n#\n# EVIDENCE-OF: R-61975-13410 It is not possible for an IS or IS NOT\n# expression to evaluate to NULL.\n#\ndo_execsql_test e_expr-8.1.1  { SELECT NULL IS     NULL } {1}\ndo_execsql_test e_expr-8.1.2  { SELECT 'ab' IS     NULL } {0}\ndo_execsql_test e_expr-8.1.3  { SELECT NULL IS     'ab' } {0}\ndo_execsql_test e_expr-8.1.4  { SELECT 'ab' IS     'ab' } {1}\ndo_execsql_test e_expr-8.1.5  { SELECT NULL ==     NULL } {{}}\ndo_execsql_test e_expr-8.1.6  { SELECT 'ab' ==     NULL } {{}}\ndo_execsql_test e_expr-8.1.7  { SELECT NULL ==     'ab' } {{}}\ndo_execsql_test e_expr-8.1.8  { SELECT 'ab' ==     'ab' } {1}\ndo_execsql_test e_expr-8.1.9  { SELECT NULL IS NOT NULL } {0}\ndo_execsql_test e_expr-8.1.10 { SELECT 'ab' IS NOT NULL } {1}\ndo_execsql_test e_expr-8.1.11 { SELECT NULL IS NOT 'ab' } {1}\ndo_execsql_test e_expr-8.1.12 { SELECT 'ab' IS NOT 'ab' } {0}\ndo_execsql_test e_expr-8.1.13 { SELECT NULL !=     NULL } {{}}\ndo_execsql_test e_expr-8.1.14 { SELECT 'ab' !=     NULL } {{}}\ndo_execsql_test e_expr-8.1.15 { SELECT NULL !=     'ab' } {{}}\ndo_execsql_test e_expr-8.1.16 { SELECT 'ab' !=     'ab' } {0}\n\nforeach {n1 rhs} $literals { \n  foreach {n2 lhs} $literals {\n    if {$rhs!=\"NULL\" && $lhs!=\"NULL\"} {\n      set eq [execsql \"SELECT $lhs = $rhs, $lhs != $rhs\"]\n    } else {\n      set eq [list [expr {$lhs==\"NULL\" && $rhs==\"NULL\"}] \\\n                   [expr {$lhs!=\"NULL\" || $rhs!=\"NULL\"}]\n      ]\n    }\n    set test e_expr-8.2.$n1.$n2\n    do_execsql_test $test.1 \"SELECT $lhs IS $rhs, $lhs IS NOT $rhs\" $eq\n    do_execsql_test $test.2 \"\n      SELECT ($lhs IS $rhs) IS NULL, ($lhs IS NOT $rhs) IS NULL\n    \" {0 0}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Run some tests on the COLLATE \"unary postfix operator\".\n#\n# This collation sequence reverses both arguments before using \n# [string compare] to compare them. For example, when comparing the\n# strings 'one' and 'four', return the result of:\n#   \n#   string compare eno ruof\n#\nproc reverse_str {zStr} {\n  set out \"\"\n  foreach c [split $zStr {}] { set out \"${c}${out}\" }\n  set out\n}\nproc reverse_collate {zLeft zRight} {\n  string compare [reverse_str $zLeft] [reverse_str $zRight]\n}\ndb collate reverse reverse_collate\n\n# EVIDENCE-OF: R-59577-33471 The COLLATE operator is a unary postfix\n# operator that assigns a collating sequence to an expression.\n#\n# EVIDENCE-OF: R-36231-30731 The COLLATE operator has a higher\n# precedence (binds more tightly) than any binary operator and any unary\n# prefix operator except \"~\".\n#\ndo_execsql_test e_expr-9.1 { SELECT  'abcd' < 'bbbb'    COLLATE reverse } 0\ndo_execsql_test e_expr-9.2 { SELECT ('abcd' < 'bbbb')   COLLATE reverse } 1\ndo_execsql_test e_expr-9.3 { SELECT  'abcd' <= 'bbbb'   COLLATE reverse } 0\ndo_execsql_test e_expr-9.4 { SELECT ('abcd' <= 'bbbb')  COLLATE reverse } 1\n\ndo_execsql_test e_expr-9.5 { SELECT  'abcd' > 'bbbb'    COLLATE reverse } 1\ndo_execsql_test e_expr-9.6 { SELECT ('abcd' > 'bbbb')   COLLATE reverse } 0\ndo_execsql_test e_expr-9.7 { SELECT  'abcd' >= 'bbbb'   COLLATE reverse } 1\ndo_execsql_test e_expr-9.8 { SELECT ('abcd' >= 'bbbb')  COLLATE reverse } 0\n\ndo_execsql_test e_expr-9.10 { SELECT  'abcd' =  'ABCD'  COLLATE nocase } 1\ndo_execsql_test e_expr-9.11 { SELECT ('abcd' =  'ABCD') COLLATE nocase } 0\ndo_execsql_test e_expr-9.12 { SELECT  'abcd' == 'ABCD'  COLLATE nocase } 1\ndo_execsql_test e_expr-9.13 { SELECT ('abcd' == 'ABCD') COLLATE nocase } 0\ndo_execsql_test e_expr-9.14 { SELECT  'abcd' IS 'ABCD'  COLLATE nocase } 1\ndo_execsql_test e_expr-9.15 { SELECT ('abcd' IS 'ABCD') COLLATE nocase } 0\n\ndo_execsql_test e_expr-9.16 { SELECT  'abcd' != 'ABCD'      COLLATE nocase } 0\ndo_execsql_test e_expr-9.17 { SELECT ('abcd' != 'ABCD')     COLLATE nocase } 1\ndo_execsql_test e_expr-9.18 { SELECT  'abcd' <> 'ABCD'      COLLATE nocase } 0\ndo_execsql_test e_expr-9.19 { SELECT ('abcd' <> 'ABCD')     COLLATE nocase } 1\ndo_execsql_test e_expr-9.20 { SELECT  'abcd' IS NOT 'ABCD'  COLLATE nocase } 0\ndo_execsql_test e_expr-9.21 { SELECT ('abcd' IS NOT 'ABCD') COLLATE nocase } 1\n\ndo_execsql_test e_expr-9.22 { \n  SELECT 'bbb' BETWEEN 'AAA' AND 'CCC' COLLATE nocase \n} 1\ndo_execsql_test e_expr-9.23 { \n  SELECT ('bbb' BETWEEN 'AAA' AND 'CCC') COLLATE nocase \n} 0\n\n# EVIDENCE-OF: R-58731-25439 The collating sequence set by the COLLATE\n# operator overrides the collating sequence determined by the COLLATE\n# clause in a table column definition.\n#\ndo_execsql_test e_expr-9.24 { \n  CREATE TABLE t24(a COLLATE NOCASE, b);\n  INSERT INTO t24 VALUES('aaa', 1);\n  INSERT INTO t24 VALUES('bbb', 2);\n  INSERT INTO t24 VALUES('ccc', 3);\n} {}\ndo_execsql_test e_expr-9.25 { SELECT 'BBB' = a FROM t24 } {0 1 0}\ndo_execsql_test e_expr-9.25 { SELECT a = 'BBB' FROM t24 } {0 1 0}\ndo_execsql_test e_expr-9.25 { SELECT 'BBB' = a COLLATE binary FROM t24 } {0 0 0}\ndo_execsql_test e_expr-9.25 { SELECT a COLLATE binary = 'BBB' FROM t24 } {0 0 0}\n\n#-------------------------------------------------------------------------\n# Test statements related to literal values.\n#\n# EVIDENCE-OF: R-31536-32008 Literal values may be integers, floating\n# point numbers, strings, BLOBs, or NULLs.\n#\ndo_execsql_test e_expr-10.1.1 { SELECT typeof(5)       } {integer}\ndo_execsql_test e_expr-10.1.2 { SELECT typeof(5.1)     } {real}\ndo_execsql_test e_expr-10.1.3 { SELECT typeof('5.1')   } {text}\ndo_execsql_test e_expr-10.1.4 { SELECT typeof(X'ABCD') } {blob}\ndo_execsql_test e_expr-10.1.5 { SELECT typeof(NULL)    } {null}\n\n# \"Scientific notation is supported for point literal values.\"\n#\ndo_execsql_test e_expr-10.2.1 { SELECT typeof(3.4e-02)    } {real}\ndo_execsql_test e_expr-10.2.2 { SELECT typeof(3e+5)       } {real}\ndo_execsql_test e_expr-10.2.3 { SELECT 3.4e-02            } {0.034}\ndo_execsql_test e_expr-10.2.4 { SELECT 3e+4               } {30000.0}\n\n# EVIDENCE-OF: R-35229-17830 A string constant is formed by enclosing\n# the string in single quotes (').\n#\n# EVIDENCE-OF: R-07100-06606 A single quote within the string can be\n# encoded by putting two single quotes in a row - as in Pascal.\n#\ndo_execsql_test e_expr-10.3.1 { SELECT 'is not' }         {{is not}}\ndo_execsql_test e_expr-10.3.2 { SELECT typeof('is not') } {text}\ndo_execsql_test e_expr-10.3.3 { SELECT 'isn''t' }         {isn't}\ndo_execsql_test e_expr-10.3.4 { SELECT typeof('isn''t') } {text}\n\n# EVIDENCE-OF: R-09593-03321 BLOB literals are string literals\n# containing hexadecimal data and preceded by a single \"x\" or \"X\"\n# character.\n#\n# EVIDENCE-OF: R-19836-11244 Example: X'53514C697465'\n#\ndo_execsql_test e_expr-10.4.1 { SELECT typeof(X'0123456789ABCDEF') } blob\ndo_execsql_test e_expr-10.4.2 { SELECT typeof(x'0123456789ABCDEF') } blob\ndo_execsql_test e_expr-10.4.3 { SELECT typeof(X'0123456789abcdef') } blob\ndo_execsql_test e_expr-10.4.4 { SELECT typeof(x'0123456789abcdef') } blob\ndo_execsql_test e_expr-10.4.5 { SELECT typeof(X'53514C697465')     } blob\n\n# EVIDENCE-OF: R-23914-51476 A literal value can also be the token\n# \"NULL\".\n#\ndo_execsql_test e_expr-10.5.1 { SELECT NULL         } {{}}\ndo_execsql_test e_expr-10.5.2 { SELECT typeof(NULL) } {null}\n\n#-------------------------------------------------------------------------\n# Test statements related to bound parameters\n#\n\nproc parameter_test {tn sql params result} {\n  set stmt [sqlite3_prepare_v2 db $sql -1]\n\n  foreach {number name} $params {\n    set nm [sqlite3_bind_parameter_name $stmt $number]\n    do_test $tn.name.$number [list set {} $nm] $name\n    sqlite3_bind_int $stmt $number [expr -1 * $number]\n  }\n\n  sqlite3_step $stmt\n\n  set res [list]\n  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {\n    lappend res [sqlite3_column_text $stmt $i]\n  }\n\n  set rc [sqlite3_finalize $stmt]\n  do_test $tn.rc [list set {} $rc] SQLITE_OK\n  do_test $tn.res [list set {} $res] $result\n}\n\n# EVIDENCE-OF: R-33509-39458 A question mark followed by a number NNN\n# holds a spot for the NNN-th parameter. NNN must be between 1 and\n# SQLITE_MAX_VARIABLE_NUMBER.\n#\nset mvn $SQLITE_MAX_VARIABLE_NUMBER\nparameter_test e_expr-11.1 \"\n  SELECT ?1, ?123, ?$SQLITE_MAX_VARIABLE_NUMBER, ?123, ?4\n\"   \"1 ?1  123 ?123 $mvn ?$mvn 4 ?4\"   \"-1 -123 -$mvn -123 -4\"\n\nset errmsg \"variable number must be between ?1 and ?$SQLITE_MAX_VARIABLE_NUMBER\"\nforeach {tn param_number} [list \\\n  2  0                                    \\\n  3  [expr $SQLITE_MAX_VARIABLE_NUMBER+1] \\\n  4  [expr $SQLITE_MAX_VARIABLE_NUMBER+2] \\\n  5  12345678903456789034567890234567890  \\\n  6  2147483648                           \\\n  7  2147483649                           \\\n  8  4294967296                           \\\n  9  4294967297                           \\\n  10 9223372036854775808                  \\\n  11 9223372036854775809                  \\\n  12 18446744073709551616                 \\\n  13 18446744073709551617                 \\\n] {\n  do_catchsql_test e_expr-11.1.$tn \"SELECT ?$param_number\" [list 1 $errmsg]\n}\n\n# EVIDENCE-OF: R-33670-36097 A question mark that is not followed by a\n# number creates a parameter with a number one greater than the largest\n# parameter number already assigned.\n#\n# EVIDENCE-OF: R-42938-07030 If this means the parameter number is\n# greater than SQLITE_MAX_VARIABLE_NUMBER, it is an error.\n#\nparameter_test e_expr-11.2.1 \"SELECT ?\"          {1 {}}       -1\nparameter_test e_expr-11.2.2 \"SELECT ?, ?\"       {1 {} 2 {}}  {-1 -2}\nparameter_test e_expr-11.2.3 \"SELECT ?5, ?\"      {5 ?5 6 {}}  {-5 -6}\nparameter_test e_expr-11.2.4 \"SELECT ?, ?5\"      {1 {} 5 ?5}  {-1 -5}\nparameter_test e_expr-11.2.5 \"SELECT ?, ?456, ?\" {\n  1 {} 456 ?456 457 {}\n}  {-1 -456 -457}\nparameter_test e_expr-11.2.5 \"SELECT ?, ?456, ?4, ?\" {\n  1 {} 456 ?456 4 ?4 457 {}\n}  {-1 -456 -4 -457}\nforeach {tn sql} [list                           \\\n  1  \"SELECT ?$mvn, ?\"                           \\\n  2  \"SELECT ?[expr $mvn-5], ?, ?, ?, ?, ?, ?\"   \\\n  3  \"SELECT ?[expr $mvn], ?5, ?6, ?\"            \\\n] {\n  do_catchsql_test e_expr-11.3.$tn $sql [list 1 {too many SQL variables}]\n}\n\n# EVIDENCE-OF: R-11620-22743 A colon followed by an identifier name\n# holds a spot for a named parameter with the name :AAAA.\n#\n# Identifiers in SQLite consist of alphanumeric, '_' and '$' characters,\n# and any UTF characters with codepoints larger than 127 (non-ASCII \n# characters).\n#\nparameter_test e_expr-11.2.1 {SELECT :AAAA}         {1 :AAAA}       -1\nparameter_test e_expr-11.2.2 {SELECT :123}          {1 :123}        -1\nparameter_test e_expr-11.2.3 {SELECT :__}           {1 :__}         -1\nparameter_test e_expr-11.2.4 {SELECT :_$_}          {1 :_$_}        -1\nparameter_test e_expr-11.2.5 \"\n  SELECT :\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\n\" \"1 :\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\" -1\nparameter_test e_expr-11.2.6 \"SELECT :\\u0080\" \"1 :\\u0080\" -1\n\n# EVIDENCE-OF: R-49783-61279 An \"at\" sign works exactly like a colon,\n# except that the name of the parameter created is @AAAA.\n#\nparameter_test e_expr-11.3.1 {SELECT @AAAA}         {1 @AAAA}       -1\nparameter_test e_expr-11.3.2 {SELECT @123}          {1 @123}        -1\nparameter_test e_expr-11.3.3 {SELECT @__}           {1 @__}         -1\nparameter_test e_expr-11.3.4 {SELECT @_$_}          {1 @_$_}        -1\nparameter_test e_expr-11.3.5 \"\n  SELECT @\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\n\" \"1 @\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\" -1\nparameter_test e_expr-11.3.6 \"SELECT @\\u0080\" \"1 @\\u0080\" -1\n\n# EVIDENCE-OF: R-62610-51329 A dollar-sign followed by an identifier\n# name also holds a spot for a named parameter with the name $AAAA.\n#\n# EVIDENCE-OF: R-55025-21042 The identifier name in this case can\n# include one or more occurrences of \"::\" and a suffix enclosed in\n# \"(...)\" containing any text at all.\n#\n# Note: Looks like an identifier cannot consist entirely of \"::\" \n# characters or just a suffix. Also, the other named variable characters\n# (: and @) work the same way internally. Why not just document it that way?\n#\nparameter_test e_expr-11.4.1 {SELECT $AAAA}         {1 $AAAA}       -1\nparameter_test e_expr-11.4.2 {SELECT $123}          {1 $123}        -1\nparameter_test e_expr-11.4.3 {SELECT $__}           {1 $__}         -1\nparameter_test e_expr-11.4.4 {SELECT $_$_}          {1 $_$_}        -1\nparameter_test e_expr-11.4.5 \"\n  SELECT \\$\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\n\" \"1 \\$\\u0e40\\u0e2d\\u0e28\\u0e02\\u0e39\\u0e40\\u0e2d\\u0e25\" -1\nparameter_test e_expr-11.4.6 \"SELECT \\$\\u0080\" \"1 \\$\\u0080\" -1\n\nparameter_test e_expr-11.5.1 {SELECT $::::a(++--++)} {1 $::::a(++--++)} -1\nparameter_test e_expr-11.5.2 {SELECT $::a()} {1 $::a()} -1\nparameter_test e_expr-11.5.3 {SELECT $::1(::#$)} {1 $::1(::#$)} -1\n \n# EVIDENCE-OF: R-11370-04520 Named parameters are also numbered. The\n# number assigned is one greater than the largest parameter number\n# already assigned.\n#\n# EVIDENCE-OF: R-42620-22184 If this means the parameter would be\n# assigned a number greater than SQLITE_MAX_VARIABLE_NUMBER, it is an\n# error.\n#\nparameter_test e_expr-11.6.1 \"SELECT ?, @abc\"    {1 {} 2 @abc} {-1 -2}\nparameter_test e_expr-11.6.2 \"SELECT ?123, :a1\"  {123 ?123 124 :a1} {-123 -124}\nparameter_test e_expr-11.6.3 {SELECT $a, ?8, ?, $b, ?2, $c} {\n  1 $a 8 ?8 9 {} 10 $b 2 ?2 11 $c\n} {-1 -8 -9 -10 -2 -11}\nforeach {tn sql} [list                           \\\n  1  \"SELECT ?$mvn, \\$::a\"                       \\\n  2  \"SELECT ?$mvn, ?4, @a1\"                     \\\n  3  \"SELECT ?[expr $mvn-2], :bag, @123, \\$x\"    \\\n] {\n  do_catchsql_test e_expr-11.7.$tn $sql [list 1 {too many SQL variables}]\n}\n\n# EVIDENCE-OF: R-14068-49671 Parameters that are not assigned values\n# using sqlite3_bind() are treated as NULL.\n#\ndo_test e_expr-11.7.1 {\n  set stmt [sqlite3_prepare_v2 db { SELECT ?, :a, @b, $d } -1]\n  sqlite3_step $stmt\n\n  list [sqlite3_column_type $stmt 0] \\\n       [sqlite3_column_type $stmt 1] \\\n       [sqlite3_column_type $stmt 2] \\\n       [sqlite3_column_type $stmt 3] \n} {NULL NULL NULL NULL}\ndo_test e_expr-11.7.1 { sqlite3_finalize $stmt } SQLITE_OK\n\n#-------------------------------------------------------------------------\n# \"Test\" the syntax diagrams in lang_expr.html.\n#\n# -- syntax diagram signed-number\n#\ndo_execsql_test e_expr-12.1.1 { SELECT 0, +0, -0 } {0 0 0}\ndo_execsql_test e_expr-12.1.2 { SELECT 1, +1, -1 } {1 1 -1}\ndo_execsql_test e_expr-12.1.3 { SELECT 2, +2, -2 } {2 2 -2}\ndo_execsql_test e_expr-12.1.4 { \n  SELECT 1.4, +1.4, -1.4 \n} {1.4 1.4 -1.4}\ndo_execsql_test e_expr-12.1.5 { \n  SELECT 1.5e+5, +1.5e+5, -1.5e+5 \n} {150000.0 150000.0 -150000.0}\ndo_execsql_test e_expr-12.1.6 { \n  SELECT 0.0001, +0.0001, -0.0001 \n} {0.0001 0.0001 -0.0001}\n\n# -- syntax diagram literal-value\n#\nset sqlite_current_time 1\ndo_execsql_test e_expr-12.2.1 {SELECT 123}               {123}\ndo_execsql_test e_expr-12.2.2 {SELECT 123.4e05}          {12340000.0}\ndo_execsql_test e_expr-12.2.3 {SELECT 'abcde'}           {abcde}\ndo_execsql_test e_expr-12.2.4 {SELECT X'414243'}         {ABC}\ndo_execsql_test e_expr-12.2.5 {SELECT NULL}              {{}}\ndo_execsql_test e_expr-12.2.6 {SELECT CURRENT_TIME}      {00:00:01}\ndo_execsql_test e_expr-12.2.7 {SELECT CURRENT_DATE}      {1970-01-01}\ndo_execsql_test e_expr-12.2.8 {SELECT CURRENT_TIMESTAMP} {{1970-01-01 00:00:01}}\nset sqlite_current_time 0\n\n# -- syntax diagram expr\n#\nforcedelete test.db2\nexecsql {\n  ATTACH 'test.db2' AS dbname;\n  CREATE TABLE dbname.tblname(cname);\n}\n\nproc glob {args} {return 1}\ndb function glob glob\ndb function match glob\ndb function regexp glob\n\nforeach {tn expr} {\n  1 123\n  2 123.4e05\n  3 'abcde'\n  4 X'414243'\n  5 NULL\n  6 CURRENT_TIME\n  7 CURRENT_DATE\n  8 CURRENT_TIMESTAMP\n\n  9 ?\n 10 ?123\n 11 @hello\n 12 :world\n 13 $tcl\n 14 $tcl(array)\n  \n  15 cname\n  16 tblname.cname\n  17 dbname.tblname.cname\n\n  18 \"+ EXPR\"\n  19 \"- EXPR\"\n  20 \"NOT EXPR\"\n  21 \"~ EXPR\"\n\n  22 \"EXPR1 || EXPR2\"\n  23 \"EXPR1 * EXPR2\"\n  24 \"EXPR1 / EXPR2\"\n  25 \"EXPR1 % EXPR2\"\n  26 \"EXPR1 + EXPR2\"\n  27 \"EXPR1 - EXPR2\"\n  28 \"EXPR1 << EXPR2\"\n  29 \"EXPR1 >> EXPR2\"\n  30 \"EXPR1 & EXPR2\"\n  31 \"EXPR1 | EXPR2\"\n  32 \"EXPR1 < EXPR2\"\n  33 \"EXPR1 <= EXPR2\"\n  34 \"EXPR1 > EXPR2\"\n  35 \"EXPR1 >= EXPR2\"\n  36 \"EXPR1 = EXPR2\"\n  37 \"EXPR1 == EXPR2\"\n  38 \"EXPR1 != EXPR2\"\n  39 \"EXPR1 <> EXPR2\"\n  40 \"EXPR1 IS EXPR2\"\n  41 \"EXPR1 IS NOT EXPR2\"\n  42 \"EXPR1 AND EXPR2\"\n  43 \"EXPR1 OR EXPR2\"\n \n  44 \"count(*)\"\n  45 \"count(DISTINCT EXPR)\"\n  46 \"substr(EXPR, 10, 20)\"\n  47 \"changes()\"\n \n  48 \"( EXPR )\"\n \n  49 \"CAST ( EXPR AS integer )\"\n  50 \"CAST ( EXPR AS 'abcd' )\"\n  51 \"CAST ( EXPR AS 'ab$ $cd' )\"\n \n  52 \"EXPR COLLATE nocase\"\n  53 \"EXPR COLLATE binary\"\n \n  54 \"EXPR1 LIKE EXPR2\"\n  55 \"EXPR1 LIKE EXPR2 ESCAPE EXPR\"\n  56 \"EXPR1 GLOB EXPR2\"\n  57 \"EXPR1 GLOB EXPR2 ESCAPE EXPR\"\n  58 \"EXPR1 REGEXP EXPR2\"\n  59 \"EXPR1 REGEXP EXPR2 ESCAPE EXPR\"\n  60 \"EXPR1 MATCH EXPR2\"\n  61 \"EXPR1 MATCH EXPR2 ESCAPE EXPR\"\n  62 \"EXPR1 NOT LIKE EXPR2\"\n  63 \"EXPR1 NOT LIKE EXPR2 ESCAPE EXPR\"\n  64 \"EXPR1 NOT GLOB EXPR2\"\n  65 \"EXPR1 NOT GLOB EXPR2 ESCAPE EXPR\"\n  66 \"EXPR1 NOT REGEXP EXPR2\"\n  67 \"EXPR1 NOT REGEXP EXPR2 ESCAPE EXPR\"\n  68 \"EXPR1 NOT MATCH EXPR2\"\n  69 \"EXPR1 NOT MATCH EXPR2 ESCAPE EXPR\"\n \n  70 \"EXPR ISNULL\"\n  71 \"EXPR NOTNULL\"\n  72 \"EXPR NOT NULL\"\n \n  73 \"EXPR1 IS EXPR2\"\n  74 \"EXPR1 IS NOT EXPR2\"\n\n  75 \"EXPR NOT BETWEEN EXPR1 AND EXPR2\"\n  76 \"EXPR BETWEEN EXPR1 AND EXPR2\"\n\n  77 \"EXPR NOT IN (SELECT cname FROM tblname)\"\n  78 \"EXPR NOT IN (1)\"\n  79 \"EXPR NOT IN (1, 2, 3)\"\n  80 \"EXPR NOT IN tblname\"\n  81 \"EXPR NOT IN dbname.tblname\"\n  82 \"EXPR IN (SELECT cname FROM tblname)\"\n  83 \"EXPR IN (1)\"\n  84 \"EXPR IN (1, 2, 3)\"\n  85 \"EXPR IN tblname\"\n  86 \"EXPR IN dbname.tblname\"\n\n  87 \"EXISTS (SELECT cname FROM tblname)\"\n  88 \"NOT EXISTS (SELECT cname FROM tblname)\"\n\n  89 \"CASE EXPR WHEN EXPR1 THEN EXPR2 ELSE EXPR END\"\n  90 \"CASE EXPR WHEN EXPR1 THEN EXPR2 END\"\n  91 \"CASE EXPR WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 ELSE EXPR2 END\"\n  92 \"CASE EXPR WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 END\"\n  93 \"CASE WHEN EXPR1 THEN EXPR2 ELSE EXPR END\"\n  94 \"CASE WHEN EXPR1 THEN EXPR2 END\"\n  95 \"CASE WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 ELSE EXPR2 END\"\n  96 \"CASE WHEN EXPR1 THEN EXPR2 WHEN EXPR THEN EXPR1 END\"\n} {\n\n  # If the expression string being parsed contains \"EXPR2\", then replace\n  # string \"EXPR1\" and \"EXPR2\" with arbitrary SQL expressions. If it \n  # contains \"EXPR\", then replace EXPR with an arbitrary SQL expression.\n  # \n  set elist [list $expr]\n  if {[string match *EXPR2* $expr]} {\n    set elist [list]\n    foreach {e1 e2} { cname \"34+22\" } {\n      lappend elist [string map [list EXPR1 $e1 EXPR2 $e2] $expr]\n    }\n  } \n  if {[string match *EXPR* $expr]} {\n    set elist2 [list]\n    foreach el $elist {\n      foreach e { cname \"34+22\" } {\n        lappend elist2 [string map [list EXPR $e] $el]\n      }\n    }\n    set elist $elist2\n  }\n\n  set x 0\n  foreach e $elist {\n    incr x\n    do_test e_expr-12.3.$tn.$x { \n      set rc [catch { execsql \"SELECT $e FROM tblname\" } msg]\n    } {0}\n  }\n}\n\n# -- syntax diagram raise-function\n#\nforeach {tn raiseexpr} {\n  1 \"RAISE(IGNORE)\"\n  2 \"RAISE(ROLLBACK, 'error message')\"\n  3 \"RAISE(ABORT, 'error message')\"\n  4 \"RAISE(FAIL, 'error message')\"\n} {\n  do_execsql_test e_expr-12.4.$tn \"\n    CREATE TRIGGER dbname.tr$tn BEFORE DELETE ON tblname BEGIN\n      SELECT $raiseexpr ;\n    END;\n  \" {}\n}\n\n#-------------------------------------------------------------------------\n# Test the statements related to the BETWEEN operator.\n#\n# EVIDENCE-OF: R-40079-54503 The BETWEEN operator is logically\n# equivalent to a pair of comparisons. \"x BETWEEN y AND z\" is equivalent\n# to \"x>=y AND x<=z\" except that with BETWEEN, the x expression is\n# only evaluated once.\n#\ndb func x x\nproc x {} { incr ::xcount ; return [expr $::x] }\nforeach {tn x expr res nEval} {\n  1  10  \"x() >= 5 AND x() <= 15\"  1  2\n  2  10  \"x() BETWEEN 5 AND 15\"    1  1\n\n  3   5  \"x() >= 5 AND x() <= 5\"   1  2\n  4   5  \"x() BETWEEN 5 AND 5\"     1  1\n\n  5   9  \"(x(),8) >= (9,7) AND (x(),8)<=(9,10)\"  1 2\n  6   9  \"(x(),8) BETWEEN (9,7) AND (9,10)\"      1 1\n} {\n  do_test e_expr-13.1.$tn {\n    set ::xcount 0\n    set a [execsql \"SELECT $expr\"]\n    list $::xcount $a\n  } [list $nEval $res]\n}\n\n# EVIDENCE-OF: R-05155-34454 The precedence of the BETWEEN operator is\n# the same as the precedence as operators == and != and LIKE and groups\n# left to right.\n# \n# Therefore, BETWEEN groups more tightly than operator \"AND\", but less\n# so than \"<\".\n#\ndo_execsql_test e_expr-13.2.1  { SELECT 1 == 10 BETWEEN 0 AND 2   }  1\ndo_execsql_test e_expr-13.2.2  { SELECT (1 == 10) BETWEEN 0 AND 2 }  1\ndo_execsql_test e_expr-13.2.3  { SELECT 1 == (10 BETWEEN 0 AND 2) }  0\ndo_execsql_test e_expr-13.2.4  { SELECT  6 BETWEEN 4 AND 8 == 1 }    1\ndo_execsql_test e_expr-13.2.5  { SELECT (6 BETWEEN 4 AND 8) == 1 }   1\ndo_execsql_test e_expr-13.2.6  { SELECT  6 BETWEEN 4 AND (8 == 1) }  0\n\ndo_execsql_test e_expr-13.2.7  { SELECT  5 BETWEEN 0 AND 0  != 1 }   1\ndo_execsql_test e_expr-13.2.8  { SELECT (5 BETWEEN 0 AND 0) != 1 }   1\ndo_execsql_test e_expr-13.2.9  { SELECT  5 BETWEEN 0 AND (0 != 1) }  0\ndo_execsql_test e_expr-13.2.10 { SELECT  1 != 0  BETWEEN 0 AND 2  }  1\ndo_execsql_test e_expr-13.2.11 { SELECT (1 != 0) BETWEEN 0 AND 2  }  1\ndo_execsql_test e_expr-13.2.12 { SELECT  1 != (0 BETWEEN 0 AND 2) }  0\n\ndo_execsql_test e_expr-13.2.13 { SELECT 1 LIKE 10 BETWEEN 0 AND 2   }  1\ndo_execsql_test e_expr-13.2.14 { SELECT (1 LIKE 10) BETWEEN 0 AND 2 }  1\ndo_execsql_test e_expr-13.2.15 { SELECT 1 LIKE (10 BETWEEN 0 AND 2) }  0\ndo_execsql_test e_expr-13.2.16 { SELECT  6 BETWEEN 4 AND 8 LIKE 1   }  1\ndo_execsql_test e_expr-13.2.17 { SELECT (6 BETWEEN 4 AND 8) LIKE 1  }  1\ndo_execsql_test e_expr-13.2.18 { SELECT  6 BETWEEN 4 AND (8 LIKE 1) }  0\n\ndo_execsql_test e_expr-13.2.19 { SELECT 0 AND 0 BETWEEN 0 AND 1   } 0\ndo_execsql_test e_expr-13.2.20 { SELECT 0 AND (0 BETWEEN 0 AND 1) } 0\ndo_execsql_test e_expr-13.2.21 { SELECT (0 AND 0) BETWEEN 0 AND 1 } 1\ndo_execsql_test e_expr-13.2.22 { SELECT 0 BETWEEN -1 AND 1 AND 0   } 0\ndo_execsql_test e_expr-13.2.23 { SELECT (0 BETWEEN -1 AND 1) AND 0 } 0\ndo_execsql_test e_expr-13.2.24 { SELECT 0 BETWEEN -1 AND (1 AND 0) } 1\n\ndo_execsql_test e_expr-13.2.25 { SELECT 2 < 3 BETWEEN 0 AND 1   } 1\ndo_execsql_test e_expr-13.2.26 { SELECT (2 < 3) BETWEEN 0 AND 1 } 1\ndo_execsql_test e_expr-13.2.27 { SELECT 2 < (3 BETWEEN 0 AND 1) } 0\ndo_execsql_test e_expr-13.2.28 { SELECT 2 BETWEEN 1 AND 2 < 3    } 0\ndo_execsql_test e_expr-13.2.29 { SELECT 2 BETWEEN 1 AND (2 < 3)  } 0\ndo_execsql_test e_expr-13.2.30 { SELECT (2 BETWEEN 1 AND 2) < 3  } 1\n\n#-------------------------------------------------------------------------\n# Test the statements related to the LIKE and GLOB operators.\n#\n# EVIDENCE-OF: R-16584-60189 The LIKE operator does a pattern matching\n# comparison.\n#\n# EVIDENCE-OF: R-11295-04657 The operand to the right of the LIKE\n# operator contains the pattern and the left hand operand contains the\n# string to match against the pattern.\n#\ndo_execsql_test e_expr-14.1.1 { SELECT 'abc%' LIKE 'abcde' } 0\ndo_execsql_test e_expr-14.1.2 { SELECT 'abcde' LIKE 'abc%' } 1\n\n# EVIDENCE-OF: R-55406-38524 A percent symbol (\"%\") in the LIKE pattern\n# matches any sequence of zero or more characters in the string.\n#\ndo_execsql_test e_expr-14.2.1 { SELECT 'abde'    LIKE 'ab%de' } 1\ndo_execsql_test e_expr-14.2.2 { SELECT 'abXde'   LIKE 'ab%de' } 1\ndo_execsql_test e_expr-14.2.3 { SELECT 'abABCde' LIKE 'ab%de' } 1\n\n# EVIDENCE-OF: R-30433-25443 An underscore (\"_\") in the LIKE pattern\n# matches any single character in the string.\n#\ndo_execsql_test e_expr-14.3.1 { SELECT 'abde'    LIKE 'ab_de' } 0\ndo_execsql_test e_expr-14.3.2 { SELECT 'abXde'   LIKE 'ab_de' } 1\ndo_execsql_test e_expr-14.3.3 { SELECT 'abABCde' LIKE 'ab_de' } 0\n\n# EVIDENCE-OF: R-59007-20454 Any other character matches itself or its\n# lower/upper case equivalent (i.e. case-insensitive matching).\n#\ndo_execsql_test e_expr-14.4.1 { SELECT 'abc' LIKE 'aBc' } 1\ndo_execsql_test e_expr-14.4.2 { SELECT 'aBc' LIKE 'aBc' } 1\ndo_execsql_test e_expr-14.4.3 { SELECT 'ac'  LIKE 'aBc' } 0\n\n# EVIDENCE-OF: R-23648-58527 SQLite only understands upper/lower case\n# for ASCII characters by default.\n#\n# EVIDENCE-OF: R-04532-11527 The LIKE operator is case sensitive by\n# default for unicode characters that are beyond the ASCII range.\n#\n# EVIDENCE-OF: R-44381-11669 the expression\n# 'a'&nbsp;LIKE&nbsp;'A' is TRUE but\n# '&aelig;'&nbsp;LIKE&nbsp;'&AElig;' is FALSE.\n#\n#   The restriction to ASCII characters does not apply if the ICU\n#   library is compiled in. When ICU is enabled SQLite does not act\n#   as it does \"by default\".\n#\ndo_execsql_test e_expr-14.5.1 { SELECT 'A' LIKE 'a'         } 1\nifcapable !icu {\n  do_execsql_test e_expr-14.5.2 \"SELECT '\\u00c6' LIKE '\\u00e6'\" 0\n}\n\n# EVIDENCE-OF: R-56683-13731 If the optional ESCAPE clause is present,\n# then the expression following the ESCAPE keyword must evaluate to a\n# string consisting of a single character.\n#\ndo_catchsql_test e_expr-14.6.1 { \n  SELECT 'A' LIKE 'a' ESCAPE '12' \n} {1 {ESCAPE expression must be a single character}}\ndo_catchsql_test e_expr-14.6.2 { \n  SELECT 'A' LIKE 'a' ESCAPE '' \n} {1 {ESCAPE expression must be a single character}}\ndo_catchsql_test e_expr-14.6.3 { SELECT 'A' LIKE 'a' ESCAPE 'x' }    {0 1}\ndo_catchsql_test e_expr-14.6.4 \"SELECT 'A' LIKE 'a' ESCAPE '\\u00e6'\" {0 1}\n\n# EVIDENCE-OF: R-02045-23762 This character may be used in the LIKE\n# pattern to include literal percent or underscore characters.\n#\n# EVIDENCE-OF: R-13345-31830 The escape character followed by a percent\n# symbol (%), underscore (_), or a second instance of the escape\n# character itself matches a literal percent symbol, underscore, or a\n# single escape character, respectively.\n#\ndo_execsql_test e_expr-14.7.1  { SELECT 'abc%'  LIKE 'abcX%' ESCAPE 'X' } 1\ndo_execsql_test e_expr-14.7.2  { SELECT 'abc5'  LIKE 'abcX%' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.3  { SELECT 'abc'   LIKE 'abcX%' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.4  { SELECT 'abcX%' LIKE 'abcX%' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.5  { SELECT 'abc%%' LIKE 'abcX%' ESCAPE 'X' } 0\n\ndo_execsql_test e_expr-14.7.6  { SELECT 'abc_'  LIKE 'abcX_' ESCAPE 'X' } 1\ndo_execsql_test e_expr-14.7.7  { SELECT 'abc5'  LIKE 'abcX_' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.8  { SELECT 'abc'   LIKE 'abcX_' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.9  { SELECT 'abcX_' LIKE 'abcX_' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.10 { SELECT 'abc__' LIKE 'abcX_' ESCAPE 'X' } 0\n\ndo_execsql_test e_expr-14.7.11 { SELECT 'abcX'  LIKE 'abcXX' ESCAPE 'X' } 1\ndo_execsql_test e_expr-14.7.12 { SELECT 'abc5'  LIKE 'abcXX' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.13 { SELECT 'abc'   LIKE 'abcXX' ESCAPE 'X' } 0\ndo_execsql_test e_expr-14.7.14 { SELECT 'abcXX' LIKE 'abcXX' ESCAPE 'X' } 0\n\n# EVIDENCE-OF: R-51359-17496 The infix LIKE operator is implemented by\n# calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).\n#\nproc likefunc {args} {\n  eval lappend ::likeargs $args\n  return 1\n}\ndb func like -argcount 2 likefunc\ndb func like -argcount 3 likefunc\nset ::likeargs [list]\ndo_execsql_test e_expr-15.1.1 { SELECT 'abc' LIKE 'def' } 1\ndo_test         e_expr-15.1.2 { set likeargs } {def abc}\nset ::likeargs [list]\ndo_execsql_test e_expr-15.1.3 { SELECT 'abc' LIKE 'def' ESCAPE 'X' } 1\ndo_test         e_expr-15.1.4 { set likeargs } {def abc X}\ndb close\nsqlite3 db test.db\n\n# EVIDENCE-OF: R-22868-25880 The LIKE operator can be made case\n# sensitive using the case_sensitive_like pragma.\n#\ndo_execsql_test e_expr-16.1.1 { SELECT 'abcxyz' LIKE 'ABC%' } 1\ndo_execsql_test e_expr-16.1.2 { PRAGMA case_sensitive_like = 1 } {}\ndo_execsql_test e_expr-16.1.3 { SELECT 'abcxyz' LIKE 'ABC%' } 0\ndo_execsql_test e_expr-16.1.4 { SELECT 'ABCxyz' LIKE 'ABC%' } 1\ndo_execsql_test e_expr-16.1.5 { PRAGMA case_sensitive_like = 0 } {}\ndo_execsql_test e_expr-16.1.6 { SELECT 'abcxyz' LIKE 'ABC%' } 1\ndo_execsql_test e_expr-16.1.7 { SELECT 'ABCxyz' LIKE 'ABC%' } 1\n\n# EVIDENCE-OF: R-52087-12043 The GLOB operator is similar to LIKE but\n# uses the Unix file globbing syntax for its wildcards.\n#\n# EVIDENCE-OF: R-09813-17279 Also, GLOB is case sensitive, unlike LIKE.\n#\ndo_execsql_test e_expr-17.1.1 { SELECT 'abcxyz' GLOB 'abc%' } 0\ndo_execsql_test e_expr-17.1.2 { SELECT 'abcxyz' GLOB 'abc*' } 1\ndo_execsql_test e_expr-17.1.3 { SELECT 'abcxyz' GLOB 'abc___' } 0\ndo_execsql_test e_expr-17.1.4 { SELECT 'abcxyz' GLOB 'abc???' } 1\n\ndo_execsql_test e_expr-17.1.5 { SELECT 'abcxyz' GLOB 'abc*' } 1\ndo_execsql_test e_expr-17.1.6 { SELECT 'ABCxyz' GLOB 'abc*' } 0\ndo_execsql_test e_expr-17.1.7 { SELECT 'abcxyz' GLOB 'ABC*' } 0\n\n# EVIDENCE-OF: R-39616-20555 Both GLOB and LIKE may be preceded by the\n# NOT keyword to invert the sense of the test.\n#\ndo_execsql_test e_expr-17.2.1 { SELECT 'abcxyz' NOT GLOB 'ABC*' } 1\ndo_execsql_test e_expr-17.2.2 { SELECT 'abcxyz' NOT GLOB 'abc*' } 0\ndo_execsql_test e_expr-17.2.3 { SELECT 'abcxyz' NOT LIKE 'ABC%' } 0\ndo_execsql_test e_expr-17.2.4 { SELECT 'abcxyz' NOT LIKE 'abc%' } 0\ndo_execsql_test e_expr-17.2.5 { SELECT 'abdxyz' NOT LIKE 'abc%' } 1\n\ndb nullvalue null\ndo_execsql_test e_expr-17.2.6 { SELECT 'abcxyz' NOT GLOB NULL } null\ndo_execsql_test e_expr-17.2.7 { SELECT 'abcxyz' NOT LIKE NULL } null\ndo_execsql_test e_expr-17.2.8 { SELECT NULL NOT GLOB 'abc*' } null\ndo_execsql_test e_expr-17.2.9 { SELECT NULL NOT LIKE 'ABC%' } null\ndb nullvalue {}\n\n# EVIDENCE-OF: R-39414-35489 The infix GLOB operator is implemented by\n# calling the function glob(Y,X) and can be modified by overriding that\n# function.\nproc globfunc {args} {\n  eval lappend ::globargs $args\n  return 1\n}\ndb func glob -argcount 2 globfunc\nset ::globargs [list]\ndo_execsql_test e_expr-17.3.1 { SELECT 'abc' GLOB 'def' } 1\ndo_test         e_expr-17.3.2 { set globargs } {def abc}\nset ::globargs [list]\ndo_execsql_test e_expr-17.3.3 { SELECT 'X' NOT GLOB 'Y' } 0\ndo_test         e_expr-17.3.4 { set globargs } {Y X}\nsqlite3 db test.db\n\n# EVIDENCE-OF: R-41650-20872 No regexp() user function is defined by\n# default and so use of the REGEXP operator will normally result in an\n# error message.\n#\n#   There is a regexp function if ICU is enabled though.\n#\nifcapable !icu {\n  do_catchsql_test e_expr-18.1.1 { \n    SELECT regexp('abc', 'def') \n  } {1 {no such function: regexp}}\n  do_catchsql_test e_expr-18.1.2 { \n    SELECT 'abc' REGEXP 'def'\n  } {1 {no such function: REGEXP}}\n}\n\n# EVIDENCE-OF: R-33693-50180 The REGEXP operator is a special syntax for\n# the regexp() user function.\n#\n# EVIDENCE-OF: R-65524-61849 If an application-defined SQL function\n# named \"regexp\" is added at run-time, then the \"X REGEXP Y\" operator\n# will be implemented as a call to \"regexp(Y,X)\".\n#\nproc regexpfunc {args} {\n  eval lappend ::regexpargs $args\n  return 1\n}\ndb func regexp -argcount 2 regexpfunc\nset ::regexpargs [list]\ndo_execsql_test e_expr-18.2.1 { SELECT 'abc' REGEXP 'def' } 1\ndo_test         e_expr-18.2.2 { set regexpargs } {def abc}\nset ::regexpargs [list]\ndo_execsql_test e_expr-18.2.3 { SELECT 'X' NOT REGEXP 'Y' } 0\ndo_test         e_expr-18.2.4 { set regexpargs } {Y X}\nsqlite3 db test.db\n\n# EVIDENCE-OF: R-42037-37826 The default match() function implementation\n# raises an exception and is not really useful for anything.\n#\ndo_catchsql_test e_expr-19.1.1 { \n  SELECT 'abc' MATCH 'def' \n} {1 {unable to use function MATCH in the requested context}}\ndo_catchsql_test e_expr-19.1.2 { \n  SELECT match('abc', 'def')\n} {1 {unable to use function MATCH in the requested context}}\n\n# EVIDENCE-OF: R-37916-47407 The MATCH operator is a special syntax for\n# the match() application-defined function.\n#\n# EVIDENCE-OF: R-06021-09373 But extensions can override the match()\n# function with more helpful logic.\n#\nproc matchfunc {args} {\n  eval lappend ::matchargs $args\n  return 1\n}\ndb func match -argcount 2 matchfunc\nset ::matchargs [list]\ndo_execsql_test e_expr-19.2.1 { SELECT 'abc' MATCH 'def' } 1\ndo_test         e_expr-19.2.2 { set matchargs } {def abc}\nset ::matchargs [list]\ndo_execsql_test e_expr-19.2.3 { SELECT 'X' NOT MATCH 'Y' } 0\ndo_test         e_expr-19.2.4 { set matchargs } {Y X}\nsqlite3 db test.db\n\n#-------------------------------------------------------------------------\n# Test cases for the testable statements related to the CASE expression.\n#\n# EVIDENCE-OF: R-15199-61389 There are two basic forms of the CASE\n# expression: those with a base expression and those without.\n#\ndo_execsql_test e_expr-20.1 {\n  SELECT CASE WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE 'else' END;\n} {true}\ndo_execsql_test e_expr-20.2 {\n  SELECT CASE 0 WHEN 1 THEN 'true' WHEN 0 THEN 'false' ELSE 'else' END;\n} {false}\n\nproc var {nm} {\n  lappend ::varlist $nm\n  return [set \"::$nm\"]\n}\ndb func var var\n\n# EVIDENCE-OF: R-30638-59954 In a CASE without a base expression, each\n# WHEN expression is evaluated and the result treated as a boolean,\n# starting with the leftmost and continuing to the right.\n#\nforeach {a b c} {0 0 0} break\nset varlist [list]\ndo_execsql_test e_expr-21.1.1 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C' END\n} {{}}\ndo_test e_expr-21.1.2 { set varlist } {a b c}\nset varlist [list]\ndo_execsql_test e_expr-21.1.3 {\n  SELECT CASE WHEN var('c') THEN 'C' \n              WHEN var('b') THEN 'B' \n              WHEN var('a') THEN 'A' \n              ELSE 'no result'\n  END\n} {{no result}}\ndo_test e_expr-21.1.4 { set varlist } {c b a}\n\n# EVIDENCE-OF: R-39009-25596 The result of the CASE expression is the\n# evaluation of the THEN expression that corresponds to the first WHEN\n# expression that evaluates to true.\n#\nforeach {a b c} {0 1 0} break\ndo_execsql_test e_expr-21.2.1 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C' \n              ELSE 'no result'\n  END\n} {B}\nforeach {a b c} {0 1 1} break\ndo_execsql_test e_expr-21.2.2 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C'\n              ELSE 'no result'\n  END\n} {B}\nforeach {a b c} {0 0 1} break\ndo_execsql_test e_expr-21.2.3 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C'\n              ELSE 'no result'\n  END\n} {C}\n\n# EVIDENCE-OF: R-24227-04807 Or, if none of the WHEN expressions\n# evaluate to true, the result of evaluating the ELSE expression, if\n# any.\n#\nforeach {a b c} {0 0 0} break\ndo_execsql_test e_expr-21.3.1 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C'\n              ELSE 'no result'\n  END\n} {{no result}}\n\n# EVIDENCE-OF: R-14168-07579 If there is no ELSE expression and none of\n# the WHEN expressions are true, then the overall result is NULL.\n#\ndb nullvalue null\ndo_execsql_test e_expr-21.3.2 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C'\n  END\n} {null}\ndb nullvalue {}\n\n# EVIDENCE-OF: R-13943-13592 A NULL result is considered untrue when\n# evaluating WHEN terms.\n#\ndo_execsql_test e_expr-21.4.1 {\n  SELECT CASE WHEN NULL THEN 'A' WHEN 1 THEN 'B' END\n} {B}\ndo_execsql_test e_expr-21.4.2 {\n  SELECT CASE WHEN 0 THEN 'A' WHEN NULL THEN 'B' ELSE 'C' END\n} {C}\n\n# EVIDENCE-OF: R-38620-19499 In a CASE with a base expression, the base\n# expression is evaluated just once and the result is compared against\n# the evaluation of each WHEN expression from left to right.\n#\n# Note: This test case tests the \"evaluated just once\" part of the above\n# statement. Tests associated with the next two statements test that the\n# comparisons take place.\n#\nforeach {a b c} [list [expr 3] [expr 4] [expr 5]] break\nset ::varlist [list]\ndo_execsql_test e_expr-22.1.1 {\n  SELECT CASE var('a') WHEN 1 THEN 'A' WHEN 2 THEN 'B' WHEN 3 THEN 'C' END\n} {C}\ndo_test e_expr-22.1.2 { set ::varlist } {a}\n\n# EVIDENCE-OF: R-07667-49537 The result of the CASE expression is the\n# evaluation of the THEN expression that corresponds to the first WHEN\n# expression for which the comparison is true.\n#\ndo_execsql_test e_expr-22.2.1 {\n  SELECT CASE 23 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END\n} {B}\ndo_execsql_test e_expr-22.2.2 {\n  SELECT CASE 1 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END\n} {A}\n\n# EVIDENCE-OF: R-47543-32145 Or, if none of the WHEN expressions\n# evaluate to a value equal to the base expression, the result of\n# evaluating the ELSE expression, if any.\n#\ndo_execsql_test e_expr-22.3.1 {\n  SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' ELSE 'D' END\n} {D}\n\n# EVIDENCE-OF: R-54721-48557 If there is no ELSE expression and none of\n# the WHEN expressions produce a result equal to the base expression,\n# the overall result is NULL.\n#\ndo_execsql_test e_expr-22.4.1 {\n  SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END\n} {{}}\ndb nullvalue null\ndo_execsql_test e_expr-22.4.2 {\n  SELECT CASE 24 WHEN 1 THEN 'A' WHEN 23 THEN 'B' WHEN 23 THEN 'C' END\n} {null}\ndb nullvalue {}\n\n# EVIDENCE-OF: R-11479-62774 When comparing a base expression against a\n# WHEN expression, the same collating sequence, affinity, and\n# NULL-handling rules apply as if the base expression and WHEN\n# expression are respectively the left- and right-hand operands of an =\n# operator.\n#\nproc rev {str} {\n  set ret \"\"\n  set chars [split $str]\n  for {set i [expr [llength $chars]-1]} {$i>=0} {incr i -1} {\n    append ret [lindex $chars $i]\n  }\n  set ret\n}\nproc reverse {lhs rhs} {\n  string compare [rev $lhs] [rev $rhs]\n}\ndb collate reverse reverse\ndo_execsql_test e_expr-23.1.1 {\n  CREATE TABLE t1(\n    a TEXT     COLLATE NOCASE,\n    b          COLLATE REVERSE,\n    c INTEGER,\n    d BLOB\n  );\n  INSERT INTO t1 VALUES('abc', 'cba', 55, 34.5);\n} {}\ndo_execsql_test e_expr-23.1.2 {\n  SELECT CASE a WHEN 'xyz' THEN 'A' WHEN 'AbC' THEN 'B' END FROM t1\n} {B}\ndo_execsql_test e_expr-23.1.3 {\n  SELECT CASE 'AbC' WHEN 'abc' THEN 'A' WHEN a THEN 'B' END FROM t1\n} {B}\ndo_execsql_test e_expr-23.1.4 {\n  SELECT CASE a WHEN b THEN 'A' ELSE 'B' END FROM t1\n} {B}\ndo_execsql_test e_expr-23.1.5 {\n  SELECT CASE b WHEN a THEN 'A' ELSE 'B' END FROM t1\n} {B}\ndo_execsql_test e_expr-23.1.6 {\n  SELECT CASE 55 WHEN '55' THEN 'A' ELSE 'B' END\n} {B}\ndo_execsql_test e_expr-23.1.7 {\n  SELECT CASE c WHEN '55' THEN 'A' ELSE 'B' END FROM t1\n} {A}\ndo_execsql_test e_expr-23.1.8 {\n  SELECT CASE '34.5' WHEN d THEN 'A' ELSE 'B' END FROM t1\n} {B}\ndo_execsql_test e_expr-23.1.9 {\n  SELECT CASE NULL WHEN NULL THEN 'A' ELSE 'B' END\n} {B}\n\n# EVIDENCE-OF: R-37304-39405 If the base expression is NULL then the\n# result of the CASE is always the result of evaluating the ELSE\n# expression if it exists, or NULL if it does not.\n#\ndo_execsql_test e_expr-24.1.1 {\n  SELECT CASE NULL WHEN 'abc' THEN 'A' WHEN 'def' THEN 'B' END;\n} {{}}\ndo_execsql_test e_expr-24.1.2 {\n  SELECT CASE NULL WHEN 'abc' THEN 'A' WHEN 'def' THEN 'B' ELSE 'C' END;\n} {C}\n\n# EVIDENCE-OF: R-56280-17369 Both forms of the CASE expression use lazy,\n# or short-circuit, evaluation.\n#\nset varlist [list]\nforeach {a b c} {0 1 0} break\ndo_execsql_test e_expr-25.1.1 {\n  SELECT CASE WHEN var('a') THEN 'A' \n              WHEN var('b') THEN 'B' \n              WHEN var('c') THEN 'C' \n  END\n} {B}\ndo_test e_expr-25.1.2 { set ::varlist } {a b}\nset varlist [list]\ndo_execsql_test e_expr-25.1.3 {\n  SELECT CASE '0' WHEN var('a') THEN 'A' \n                  WHEN var('b') THEN 'B' \n                  WHEN var('c') THEN 'C' \n  END\n} {A}\ndo_test e_expr-25.1.4 { set ::varlist } {a}\n\n# EVIDENCE-OF: R-34773-62253 The only difference between the following\n# two CASE expressions is that the x expression is evaluated exactly\n# once in the first example but might be evaluated multiple times in the\n# second: CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END CASE WHEN\n# x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END\n#\nproc ceval {x} {\n  incr ::evalcount\n  return $x\n}\ndb func ceval ceval\nset ::evalcount 0\n\ndo_execsql_test e_expr-26.1.1 {\n  CREATE TABLE t2(x, w1, r1, w2, r2, r3);\n  INSERT INTO t2 VALUES(1, 1, 'R1', 2, 'R2', 'R3');\n  INSERT INTO t2 VALUES(2, 1, 'R1', 2, 'R2', 'R3');\n  INSERT INTO t2 VALUES(3, 1, 'R1', 2, 'R2', 'R3');\n} {}\ndo_execsql_test e_expr-26.1.2 {\n  SELECT CASE x WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END FROM t2\n} {R1 R2 R3}\ndo_execsql_test e_expr-26.1.3 {\n  SELECT CASE WHEN x=w1 THEN r1 WHEN x=w2 THEN r2 ELSE r3 END FROM t2\n} {R1 R2 R3}\n\ndo_execsql_test e_expr-26.1.4 {\n  SELECT CASE ceval(x) WHEN w1 THEN r1 WHEN w2 THEN r2 ELSE r3 END FROM t2\n} {R1 R2 R3}\ndo_test e_expr-26.1.5 { set ::evalcount } {3}\nset ::evalcount 0\ndo_execsql_test e_expr-26.1.6 {\n  SELECT CASE \n    WHEN ceval(x)=w1 THEN r1 \n    WHEN ceval(x)=w2 THEN r2 \n    ELSE r3 END \n  FROM t2\n} {R1 R2 R3}\ndo_test e_expr-26.1.6 { set ::evalcount } {5}\n\n\n#-------------------------------------------------------------------------\n# Test statements related to CAST expressions.\n#\n# EVIDENCE-OF: R-20854-17109 A CAST conversion is similar to the\n# conversion that takes place when a column affinity is applied to a\n# value except that with the CAST operator the conversion always takes\n# place even if the conversion lossy and irreversible, whereas column\n# affinity only changes the data type of a value if the change is\n# lossless and reversible.\n#\ndo_execsql_test e_expr-27.1.1 {\n  CREATE TABLE t3(a TEXT, b REAL, c INTEGER);\n  INSERT INTO t3 VALUES(X'555655', '1.23abc', 4.5);\n  SELECT typeof(a), a, typeof(b), b, typeof(c), c FROM t3;\n} {blob UVU text 1.23abc real 4.5}\ndo_execsql_test e_expr-27.1.2 {\n  SELECT \n    typeof(CAST(X'555655' as TEXT)), CAST(X'555655' as TEXT),\n    typeof(CAST('1.23abc' as REAL)), CAST('1.23abc' as REAL),\n    typeof(CAST(4.5 as INTEGER)), CAST(4.5 as INTEGER)\n} {text UVU real 1.23 integer 4}\n\n# EVIDENCE-OF: R-32434-09092 If the value of expr is NULL, then the\n# result of the CAST expression is also NULL.\n#\ndo_expr_test e_expr-27.2.1 { CAST(NULL AS integer) } null {}\ndo_expr_test e_expr-27.2.2 { CAST(NULL AS text) }    null {}\ndo_expr_test e_expr-27.2.3 { CAST(NULL AS blob) }    null {}\ndo_expr_test e_expr-27.2.4 { CAST(NULL AS number) }  null {}\n\n# EVIDENCE-OF: R-29283-15561 Otherwise, the storage class of the result\n# is determined by applying the rules for determining column affinity to\n# the type-name.\n#\n# The R-29283-15561 requirement above is demonstrated by all of the \n# subsequent e_expr-26 tests.\n#\n# EVIDENCE-OF: R-43522-35548 Casting a value to a type-name with no\n# affinity causes the value to be converted into a BLOB.\n#\ndo_expr_test e_expr-27.3.1 { CAST('abc' AS blob)       } blob abc\ndo_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def\ndo_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10)   } blob ghi\n\n# EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting\n# the value to TEXT in the encoding of the database connection, then\n# interpreting the resulting byte sequence as a BLOB instead of as TEXT.\n#\ndo_qexpr_test e_expr-27.4.1 { CAST('ghi' AS blob) } X'676869'\ndo_qexpr_test e_expr-27.4.2 { CAST(456 AS blob) }   X'343536'\ndo_qexpr_test e_expr-27.4.3 { CAST(1.78 AS blob) }  X'312E3738'\nrename db db2\nsqlite3 db :memory:\nifcapable {utf16} {\ndb eval { PRAGMA encoding = 'utf-16le' }\ndo_qexpr_test e_expr-27.4.4 { CAST('ghi' AS blob) } X'670068006900'\ndo_qexpr_test e_expr-27.4.5 { CAST(456 AS blob) }   X'340035003600'\ndo_qexpr_test e_expr-27.4.6 { CAST(1.78 AS blob) }  X'31002E0037003800'\n}\ndb close\nsqlite3 db :memory:\ndb eval { PRAGMA encoding = 'utf-16be' }\nifcapable {utf16} {\ndo_qexpr_test e_expr-27.4.7 { CAST('ghi' AS blob) } X'006700680069'\ndo_qexpr_test e_expr-27.4.8 { CAST(456 AS blob) }   X'003400350036'\ndo_qexpr_test e_expr-27.4.9 { CAST(1.78 AS blob) }  X'0031002E00370038'\n}\ndb close\nrename db2 db\n\n# EVIDENCE-OF: R-04207-37981 To cast a BLOB value to TEXT, the sequence\n# of bytes that make up the BLOB is interpreted as text encoded using\n# the database encoding.\n#\ndo_expr_test e_expr-28.1.1 { CAST (X'676869' AS text) } text ghi\ndo_expr_test e_expr-28.1.2 { CAST (X'670068006900' AS text) } text g\nrename db db2\nsqlite3 db :memory:\ndb eval { PRAGMA encoding = 'utf-16le' }\nifcapable {utf16} {\ndo_expr_test e_expr-28.1.3 { CAST (X'676869' AS text) == 'ghi' } integer 0\ndo_expr_test e_expr-28.1.4 { CAST (X'670068006900' AS text) } text ghi\n}\ndb close\nrename db2 db\n\n# EVIDENCE-OF: R-22235-47006 Casting an INTEGER or REAL value into TEXT\n# renders the value as if via sqlite3_snprintf() except that the\n# resulting TEXT uses the encoding of the database connection.\n#\ndo_expr_test e_expr-28.2.1 { CAST (1 AS text)   }     text 1\ndo_expr_test e_expr-28.2.2 { CAST (45 AS text)  }     text 45\ndo_expr_test e_expr-28.2.3 { CAST (-45 AS text) }     text -45\ndo_expr_test e_expr-28.2.4 { CAST (8.8 AS text)    }  text 8.8\ndo_expr_test e_expr-28.2.5 { CAST (2.3e+5 AS text) }  text 230000.0\ndo_expr_test e_expr-28.2.6 { CAST (-2.3e-5 AS text) } text -2.3e-05\ndo_expr_test e_expr-28.2.7 { CAST (0.0 AS text) }     text 0.0\ndo_expr_test e_expr-28.2.7 { CAST (0 AS text) }       text 0\n\n# EVIDENCE-OF: R-26346-36443 When casting a BLOB value to a REAL, the\n# value is first converted to TEXT.\n#\ndo_expr_test e_expr-29.1.1 { CAST (X'312E3233' AS REAL) } real 1.23\ndo_expr_test e_expr-29.1.2 { CAST (X'3233302E30' AS REAL) } real 230.0\ndo_expr_test e_expr-29.1.3 { CAST (X'2D392E3837' AS REAL) } real -9.87\ndo_expr_test e_expr-29.1.4 { CAST (X'302E30303031' AS REAL) } real 0.0001\nrename db db2\nsqlite3 db :memory:\nifcapable {utf16} {\ndb eval { PRAGMA encoding = 'utf-16le' }\ndo_expr_test e_expr-29.1.5 { \n    CAST (X'31002E0032003300' AS REAL) } real 1.23\ndo_expr_test e_expr-29.1.6 { \n    CAST (X'3200330030002E003000' AS REAL) } real 230.0\ndo_expr_test e_expr-29.1.7 { \n    CAST (X'2D0039002E0038003700' AS REAL) } real -9.87\ndo_expr_test e_expr-29.1.8 { \n    CAST (X'30002E003000300030003100' AS REAL) } real 0.0001\n}\ndb close\nrename db2 db\n\n# EVIDENCE-OF: R-54898-34554 When casting a TEXT value to REAL, the\n# longest possible prefix of the value that can be interpreted as a real\n# number is extracted from the TEXT value and the remainder ignored.\n#\ndo_expr_test e_expr-29.2.1 { CAST('1.23abcd' AS REAL) } real 1.23\ndo_expr_test e_expr-29.2.2 { CAST('1.45.23abcd' AS REAL) } real 1.45\ndo_expr_test e_expr-29.2.3 { CAST('-2.12e-01ABC' AS REAL) } real -0.212\ndo_expr_test e_expr-29.2.4 { CAST('1 2 3 4' AS REAL) } real 1.0\n\n# EVIDENCE-OF: R-11321-47427 Any leading spaces in the TEXT value are\n# ignored when converging from TEXT to REAL.\n#\ndo_expr_test e_expr-29.3.1 { CAST(' 1.23abcd' AS REAL) } real 1.23\ndo_expr_test e_expr-29.3.2 { CAST('    1.45.23abcd' AS REAL) } real 1.45\ndo_expr_test e_expr-29.3.3 { CAST('   -2.12e-01ABC' AS REAL) } real -0.212\ndo_expr_test e_expr-29.3.4 { CAST(' 1 2 3 4' AS REAL) } real 1.0\n\n# EVIDENCE-OF: R-22662-28218 If there is no prefix that can be\n# interpreted as a real number, the result of the conversion is 0.0.\n#\ndo_expr_test e_expr-29.4.1 { CAST('' AS REAL) } real 0.0\ndo_expr_test e_expr-29.4.2 { CAST('not a number' AS REAL) } real 0.0\ndo_expr_test e_expr-29.4.3 { CAST('XXI' AS REAL) } real 0.0\n\n# EVIDENCE-OF: R-21829-14563 When casting a BLOB value to INTEGER, the\n# value is first converted to TEXT.\n#\ndo_expr_test e_expr-30.1.1 { CAST(X'313233' AS INTEGER) } integer 123\ndo_expr_test e_expr-30.1.2 { CAST(X'2D363738' AS INTEGER) } integer -678\ndo_expr_test e_expr-30.1.3 { \n  CAST(X'31303030303030' AS INTEGER) \n} integer 1000000\ndo_expr_test e_expr-30.1.4 { \n  CAST(X'2D31313235383939393036383432363234' AS INTEGER) \n} integer -1125899906842624\n\nrename db db2\nsqlite3 db :memory:\nifcapable {utf16} {\nexecsql { PRAGMA encoding = 'utf-16be' }\ndo_expr_test e_expr-30.1.5 { CAST(X'003100320033' AS INTEGER) } integer 123\ndo_expr_test e_expr-30.1.6 { CAST(X'002D003600370038' AS INTEGER) } integer -678\ndo_expr_test e_expr-30.1.7 { \n  CAST(X'0031003000300030003000300030' AS INTEGER) \n} integer 1000000\ndo_expr_test e_expr-30.1.8 { \n  CAST(X'002D0031003100320035003800390039003900300036003800340032003600320034' AS INTEGER) \n} integer -1125899906842624\n}\ndb close\nrename db2 db\n\n# EVIDENCE-OF: R-47612-45842 When casting a TEXT value to INTEGER, the\n# longest possible prefix of the value that can be interpreted as an\n# integer number is extracted from the TEXT value and the remainder\n# ignored.\n#\ndo_expr_test e_expr-30.2.1 { CAST('123abcd' AS INT) } integer 123\ndo_expr_test e_expr-30.2.2 { CAST('14523abcd' AS INT) } integer 14523\ndo_expr_test e_expr-30.2.3 { CAST('-2.12e-01ABC' AS INT) } integer -2\ndo_expr_test e_expr-30.2.4 { CAST('1 2 3 4' AS INT) } integer 1\n\n# EVIDENCE-OF: R-34400-33772 Any leading spaces in the TEXT value when\n# converting from TEXT to INTEGER are ignored.\n#\ndo_expr_test e_expr-30.3.1 { CAST('   123abcd' AS INT) } integer 123\ndo_expr_test e_expr-30.3.2 { CAST('  14523abcd' AS INT) } integer 14523\ndo_expr_test e_expr-30.3.3 { CAST(' -2.12e-01ABC' AS INT) } integer -2\ndo_expr_test e_expr-30.3.4 { CAST('     1 2 3 4' AS INT) } integer 1\n\n# EVIDENCE-OF: R-43164-44276 If there is no prefix that can be\n# interpreted as an integer number, the result of the conversion is 0.\n#\ndo_expr_test e_expr-30.4.1 { CAST('' AS INTEGER) } integer 0\ndo_expr_test e_expr-30.4.2 { CAST('not a number' AS INTEGER) } integer 0\ndo_expr_test e_expr-30.4.3 { CAST('XXI' AS INTEGER) } integer 0\n\n# EVIDENCE-OF: R-08980-53124 The CAST operator understands decimal\n# integers only &mdash; conversion of hexadecimal integers stops at\n# the \"x\" in the \"0x\" prefix of the hexadecimal integer string and thus\n# result of the CAST is always zero.\ndo_expr_test e_expr-30.5.1 { CAST('0x1234' AS INTEGER) } integer 0\ndo_expr_test e_expr-30.5.2 { CAST('0X1234' AS INTEGER) } integer 0\n\n# EVIDENCE-OF: R-02752-50091 A cast of a REAL value into an INTEGER\n# results in the integer between the REAL value and zero that is closest\n# to the REAL value.\n#\ndo_expr_test e_expr-31.1.1 { CAST(3.14159 AS INTEGER) } integer 3\ndo_expr_test e_expr-31.1.2 { CAST(1.99999 AS INTEGER) } integer 1\ndo_expr_test e_expr-31.1.3 { CAST(-1.99999 AS INTEGER) } integer -1\ndo_expr_test e_expr-31.1.4 { CAST(-0.99999 AS INTEGER) } integer 0\n\n# EVIDENCE-OF: R-51517-40824 If a REAL is greater than the greatest\n# possible signed integer (+9223372036854775807) then the result is the\n# greatest possible signed integer and if the REAL is less than the\n# least possible signed integer (-9223372036854775808) then the result\n# is the least possible signed integer.\n#\ndo_expr_test e_expr-31.2.1 { CAST(2e+50 AS INT) } integer 9223372036854775807\ndo_expr_test e_expr-31.2.2 { CAST(-2e+50 AS INT) } integer -9223372036854775808\ndo_expr_test e_expr-31.2.3 { \n  CAST(-9223372036854775809.0 AS INT)\n} integer -9223372036854775808\ndo_expr_test e_expr-31.2.4 { \n  CAST(9223372036854775809.0 AS INT)\n} integer 9223372036854775807\n\n\n# EVIDENCE-OF: R-09295-61337 Casting a TEXT or BLOB value into NUMERIC\n# first does a forced conversion into REAL but then further converts the\n# result into INTEGER if and only if the conversion from REAL to INTEGER\n# is lossless and reversible.\n#\ndo_expr_test e_expr-32.1.1 { CAST('45'   AS NUMERIC)  } integer 45\ndo_expr_test e_expr-32.1.2 { CAST('45.0' AS NUMERIC)  } integer 45\ndo_expr_test e_expr-32.1.3 { CAST('45.2' AS NUMERIC)  } real 45.2\ndo_expr_test e_expr-32.1.4 { CAST('11abc' AS NUMERIC) } integer 11\ndo_expr_test e_expr-32.1.5 { CAST('11.1abc' AS NUMERIC) } real 11.1\n\n# EVIDENCE-OF: R-30347-18702 Casting a REAL or INTEGER value to NUMERIC\n# is a no-op, even if a real value could be losslessly converted to an\n# integer.\n#\ndo_expr_test e_expr-32.2.1 { CAST(13.0 AS NUMERIC) } real 13.0\ndo_expr_test e_expr-32.2.2 { CAST(13.5 AS NUMERIC) } real 13.5\n\ndo_expr_test e_expr-32.2.3 { \n  CAST(-9223372036854775808 AS NUMERIC)\n} integer -9223372036854775808\ndo_expr_test e_expr-32.2.4 { \n  CAST(9223372036854775807 AS NUMERIC)\n} integer 9223372036854775807\ndo_expr_test e_expr-32.2.5 { \n  CAST('9223372036854775807 ' AS NUMERIC)\n} integer 9223372036854775807\ndo_expr_test e_expr-32.2.6 { \n  CAST('   9223372036854775807   ' AS NUMERIC)\n} integer 9223372036854775807\ndo_expr_test e_expr-32.2.7 { \n  CAST('  ' AS NUMERIC)\n} integer 0\ndo_execsql_test e_expr-32.2.8 {\n  WITH t1(x) AS (VALUES\n     ('9000000000000000001'),\n     ('9000000000000000001x'),\n     ('9000000000000000001 '),\n     (' 9000000000000000001 '),\n     (' 9000000000000000001'),\n     (' 9000000000000000001.'),\n     ('9223372036854775807'),\n     ('9223372036854775807 '),\n     ('   9223372036854775807   '),\n     ('9223372036854775808'),\n     ('   9223372036854775808   '),\n     ('9223372036854775807.0'),\n     ('9223372036854775807e+0'),\n     ('-5.0'),\n     ('-5e+0'))\n  SELECT typeof(CAST(x AS NUMERIC)), CAST(x AS NUMERIC)||'' FROM t1;\n} [list \\\n integer 9000000000000000001 \\\n integer 9000000000000000001 \\\n integer 9000000000000000001 \\\n integer 9000000000000000001 \\\n integer 9000000000000000001 \\\n integer 9000000000000000001 \\\n integer 9223372036854775807 \\\n integer 9223372036854775807 \\\n integer 9223372036854775807 \\\n real 9.22337203685478e+18 \\\n real 9.22337203685478e+18 \\\n integer 9223372036854775807 \\\n integer 9223372036854775807 \\\n integer -5 \\\n integer -5 \\\n]\n\n# EVIDENCE-OF: R-64550-29191 Note that the result from casting any\n# non-BLOB value into a BLOB and the result from casting any BLOB value\n# into a non-BLOB value may be different depending on whether the\n# database encoding is UTF-8, UTF-16be, or UTF-16le.\n#\nifcapable {utf16} {\nsqlite3 db1 :memory: ; db1 eval { PRAGMA encoding = 'utf-8' }\nsqlite3 db2 :memory: ; db2 eval { PRAGMA encoding = 'utf-16le' }\nsqlite3 db3 :memory: ; db3 eval { PRAGMA encoding = 'utf-16be' }\nforeach {tn castexpr differs} {\n  1 { CAST(123 AS BLOB)    } 1\n  2 { CAST('' AS BLOB)     } 0\n  3 { CAST('abcd' AS BLOB) } 1\n\n  4 { CAST(X'abcd' AS TEXT) } 1\n  5 { CAST(X'' AS TEXT)     } 0\n} {\n  set r1 [db1 eval \"SELECT typeof($castexpr), quote($castexpr)\"]\n  set r2 [db2 eval \"SELECT typeof($castexpr), quote($castexpr)\"]\n  set r3 [db3 eval \"SELECT typeof($castexpr), quote($castexpr)\"]\n\n  if {$differs} {\n    set res [expr {$r1!=$r2 && $r2!=$r3}]\n  } else {\n    set res [expr {$r1==$r2 && $r2==$r3}]\n  }\n\n  do_test e_expr-33.1.$tn {set res} 1\n}\ndb1 close\ndb2 close\ndb3 close\n}\n\n#-------------------------------------------------------------------------\n# Test statements related to the EXISTS and NOT EXISTS operators.\n#\ncatch { db close }\nforcedelete test.db\nsqlite3 db test.db\n\ndo_execsql_test e_expr-34.1 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(NULL, 2);\n  INSERT INTO t1 VALUES(1, NULL);\n  INSERT INTO t1 VALUES(NULL, NULL);\n} {}\n\n# EVIDENCE-OF: R-25588-27181 The EXISTS operator always evaluates to one\n# of the integer values 0 and 1.\n#\n# This statement is not tested by itself. Instead, all e_expr-34.* tests \n# following this point explicitly test that specific invocations of EXISTS\n# return either integer 0 or integer 1.\n#\n\n# EVIDENCE-OF: R-58553-63740 If executing the SELECT statement specified\n# as the right-hand operand of the EXISTS operator would return one or\n# more rows, then the EXISTS operator evaluates to 1.\n#\nforeach {tn expr} {\n    1 { EXISTS ( SELECT a FROM t1 ) }\n    2 { EXISTS ( SELECT b FROM t1 ) }\n    3 { EXISTS ( SELECT 24 ) }\n    4 { EXISTS ( SELECT NULL ) }\n    5 { EXISTS ( SELECT a FROM t1 WHERE a IS NULL ) }\n} {\n  do_expr_test e_expr-34.2.$tn $expr integer 1\n}\n\n# EVIDENCE-OF: R-19673-40972 If executing the SELECT would return no\n# rows at all, then the EXISTS operator evaluates to 0.\n#\nforeach {tn expr} {\n    1 { EXISTS ( SELECT a FROM t1 WHERE 0) }\n    2 { EXISTS ( SELECT b FROM t1 WHERE a = 5) }\n    3 { EXISTS ( SELECT 24 WHERE 0) }\n    4 { EXISTS ( SELECT NULL WHERE 1=2) }\n} {\n  do_expr_test e_expr-34.3.$tn $expr integer 0\n}\n\n# EVIDENCE-OF: R-35109-49139 The number of columns in each row returned\n# by the SELECT statement (if any) and the specific values returned have\n# no effect on the results of the EXISTS operator.\n#\nforeach {tn expr res} {\n    1 { EXISTS ( SELECT * FROM t1 ) }                          1\n    2 { EXISTS ( SELECT *, *, * FROM t1 ) }                    1\n    3 { EXISTS ( SELECT 24, 25 ) }                             1\n    4 { EXISTS ( SELECT NULL, NULL, NULL ) }                   1\n    5 { EXISTS ( SELECT a,b,a||b FROM t1 WHERE a IS NULL ) }   1\n\n    6 { EXISTS ( SELECT a, a FROM t1 WHERE 0) }                0\n    7 { EXISTS ( SELECT b, b, a FROM t1 WHERE a = 5) }         0\n    8 { EXISTS ( SELECT 24, 46, 89 WHERE 0) }                  0\n    9 { EXISTS ( SELECT NULL, NULL WHERE 1=2) }                0\n} {\n  do_expr_test e_expr-34.4.$tn $expr integer $res\n}\n\n# EVIDENCE-OF: R-10645-12439 In particular, rows containing NULL values\n# are not handled any differently from rows without NULL values.\n#\nforeach {tn e1 e2} {\n  1 { EXISTS (SELECT 'not null') }    { EXISTS (SELECT NULL) }\n  2 { EXISTS (SELECT NULL FROM t1) }  { EXISTS (SELECT 'bread' FROM t1) }\n} {\n  set res [db one \"SELECT $e1\"]\n  do_expr_test e_expr-34.5.${tn}a $e1 integer $res\n  do_expr_test e_expr-34.5.${tn}b $e2 integer $res\n}\n\n#-------------------------------------------------------------------------\n# Test statements related to scalar sub-queries.\n#\n\ncatch { db close }\nforcedelete test.db\nsqlite3 db test.db\ndo_test e_expr-35.0 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES('one', 'two');\n    INSERT INTO t2 VALUES('three', NULL);\n    INSERT INTO t2 VALUES(4, 5.0);\n  }\n} {}\n\n# EVIDENCE-OF: R-43573-23448 A SELECT statement enclosed in parentheses\n# is a subquery.\n#\n# EVIDENCE-OF: R-56294-03966 All types of SELECT statement, including\n# aggregate and compound SELECT queries (queries with keywords like\n# UNION or EXCEPT) are allowed as scalar subqueries.\n#\ndo_expr_test e_expr-35.1.1 { (SELECT 35)   } integer 35\ndo_expr_test e_expr-35.1.2 { (SELECT NULL) } null {}\n\ndo_expr_test e_expr-35.1.3 { (SELECT count(*) FROM t2) } integer 3\ndo_expr_test e_expr-35.1.4 { (SELECT 4 FROM t2) } integer 4\n\ndo_expr_test e_expr-35.1.5 { \n  (SELECT b FROM t2 UNION SELECT a+1 FROM t2)\n} null {}\ndo_expr_test e_expr-35.1.6 { \n  (SELECT a FROM t2 UNION SELECT COALESCE(b, 55) FROM t2 ORDER BY 1)\n} integer 4\n\n# EVIDENCE-OF: R-22239-33740 A subquery that returns two or more columns\n# is a row value subquery and can only be used as the operand of a\n# comparison operator.\n#\n# The following block tests that errors are returned in a bunch of cases\n# where a subquery returns more than one column.\n#\nset M {/1 {sub-select returns [23] columns - expected 1}/}\nforeach {tn sql} {\n  1     { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2) }\n  2     { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2 ORDER BY 1) }\n  3     { SELECT (SELECT 1, 2) }\n  4     { SELECT (SELECT NULL, NULL, NULL) }\n  5     { SELECT (SELECT * FROM t2) }\n  6     { SELECT (SELECT * FROM (SELECT 1, 2, 3)) }\n} {\n  do_catchsql_test e_expr-35.2.$tn $sql $M\n}\n\n# EVIDENCE-OF: R-18318-14995 The value of a subquery expression is the\n# first row of the result from the enclosed SELECT statement.\n#\n# EVIDENCE-OF: R-15900-52156 In other words, an implied \"LIMIT 1\" is\n# added to the subquery, overriding an explicitly coded LIMIT.\n#\ndo_execsql_test e_expr-36.3.1 {\n  CREATE TABLE t4(x, y);\n  INSERT INTO t4 VALUES(1, 'one');\n  INSERT INTO t4 VALUES(2, 'two');\n  INSERT INTO t4 VALUES(3, 'three');\n} {}\n\nforeach {tn expr restype resval} {\n    2  { ( SELECT x FROM t4 ORDER BY x )      }        integer 1\n    3  { ( SELECT x FROM t4 ORDER BY y )      }        integer 1\n    4  { ( SELECT x FROM t4 ORDER BY x DESC ) }        integer 3\n    5  { ( SELECT x FROM t4 ORDER BY y DESC ) }        integer 2\n    6  { ( SELECT y FROM t4 ORDER BY y DESC ) }        text    two\n\n    7  { ( SELECT sum(x) FROM t4 )           }         integer 6\n    8  { ( SELECT group_concat(y,'') FROM t4 ) }       text    onetwothree\n    9  { ( SELECT max(x) FROM t4 WHERE y LIKE '___') } integer 2 \n\n} {\n  do_expr_test e_expr-36.3.$tn $expr $restype $resval\n}\n\n# EVIDENCE-OF: R-52325-25449 The value of a subquery expression is NULL\n# if the enclosed SELECT statement returns no rows.\n#\nforeach {tn expr} {\n    1  { ( SELECT x FROM t4 WHERE x>3 ORDER BY x )      }\n    2  { ( SELECT x FROM t4 WHERE y<'one' ORDER BY y )  }\n} {\n  do_expr_test e_expr-36.4.$tn $expr null {}\n}\n\n# EVIDENCE-OF: R-62477-06476 For example, the values NULL, 0.0, 0,\n# 'english' and '0' are all considered to be false.\n#\ndo_execsql_test e_expr-37.1 {\n   SELECT CASE WHEN NULL THEN 'true' ELSE 'false' END;\n} {false}\ndo_execsql_test e_expr-37.2 {\n   SELECT CASE WHEN 0.0 THEN 'true' ELSE 'false' END;\n} {false}\ndo_execsql_test e_expr-37.3 {\n   SELECT CASE WHEN 0 THEN 'true' ELSE 'false' END;\n} {false}\ndo_execsql_test e_expr-37.4 {\n   SELECT CASE WHEN 'engligh' THEN 'true' ELSE 'false' END;\n} {false}\ndo_execsql_test e_expr-37.5 {\n   SELECT CASE WHEN '0' THEN 'true' ELSE 'false' END;\n} {false}\n\n# EVIDENCE-OF: R-55532-10108 Values 1, 1.0, 0.1, -0.1 and '1english' are\n# considered to be true.\n#\ndo_execsql_test e_expr-37.6 {\n   SELECT CASE WHEN 1 THEN 'true' ELSE 'false' END;\n} {true}\ndo_execsql_test e_expr-37.7 {\n   SELECT CASE WHEN 1.0 THEN 'true' ELSE 'false' END;\n} {true}\ndo_execsql_test e_expr-37.8 {\n   SELECT CASE WHEN 0.1 THEN 'true' ELSE 'false' END;\n} {true}\ndo_execsql_test e_expr-37.9 {\n   SELECT CASE WHEN -0.1 THEN 'true' ELSE 'false' END;\n} {true}\ndo_execsql_test e_expr-37.10 {\n   SELECT CASE WHEN '1english' THEN 'true' ELSE 'false' END;\n} {true}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_fkey.test",
    "content": "# 2009 October 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify the \"testable statements\" in the\n# foreignkeys.in document.\n#\n# The tests in this file are arranged to mirror the structure of \n# foreignkey.in, with one exception: The statements in section 2, which \n# deals with enabling/disabling foreign key support, is tested first,\n# before section 1. This is because some statements in section 2 deal\n# with builds that do not include complete foreign key support (because\n# either SQLITE_OMIT_TRIGGER or SQLITE_OMIT_FOREIGN_KEY was defined\n# at build time).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc eqp {sql {db db}} { uplevel execsql [list \"EXPLAIN QUERY PLAN $sql\"] $db }\n\n###########################################################################\n### SECTION 2: Enabling Foreign Key Support\n###########################################################################\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-33710-56344 In order to use foreign key constraints in\n# SQLite, the library must be compiled with neither\n# SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined.\n#\nifcapable trigger&&foreignkey {\n  do_test e_fkey-1 {\n    execsql {\n      PRAGMA foreign_keys = ON;\n      CREATE TABLE p(i PRIMARY KEY);\n      CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);\n      INSERT INTO p VALUES('hello');\n      INSERT INTO c VALUES('hello');\n      UPDATE p SET i = 'world';\n      SELECT * FROM c;\n    }\n  } {world}\n}\n\n#-------------------------------------------------------------------------\n# Test the effects of defining OMIT_TRIGGER but not OMIT_FOREIGN_KEY.\n#\n# EVIDENCE-OF: R-10109-20452 If SQLITE_OMIT_TRIGGER is defined but\n# SQLITE_OMIT_FOREIGN_KEY is not, then SQLite behaves as it did prior to\n# version 3.6.19 (2009-10-14) - foreign key definitions are parsed and\n# may be queried using PRAGMA foreign_key_list, but foreign key\n# constraints are not enforced.\n#\n# Specifically, test that \"PRAGMA foreign_keys\" is a no-op in this case.\n# When using the pragma to query the current setting, 0 rows are returned.\n#\n# EVIDENCE-OF: R-22567-44039 The PRAGMA foreign_keys command is a no-op\n# in this configuration.\n#\n# EVIDENCE-OF: R-41784-13339 Tip: If the command \"PRAGMA foreign_keys\"\n# returns no data instead of a single row containing \"0\" or \"1\", then\n# the version of SQLite you are using does not support foreign keys\n# (either because it is older than 3.6.19 or because it was compiled\n# with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).\n#\nreset_db\nifcapable !trigger&&foreignkey {\n  do_test e_fkey-2.1 {\n    execsql {\n      PRAGMA foreign_keys = ON;\n      CREATE TABLE p(i PRIMARY KEY);\n      CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);\n      INSERT INTO p VALUES('hello');\n      INSERT INTO c VALUES('hello');\n      UPDATE p SET i = 'world';\n      SELECT * FROM c;\n    }\n  } {hello}\n  do_test e_fkey-2.2 {\n    execsql { PRAGMA foreign_key_list(c) }\n  } {0 0 p j {} CASCADE {NO ACTION} NONE}\n  do_test e_fkey-2.3 {\n    execsql { PRAGMA foreign_keys }\n  } {}\n}\n\n\n#-------------------------------------------------------------------------\n# Test the effects of defining OMIT_FOREIGN_KEY.\n#\n# EVIDENCE-OF: R-58428-36660 If OMIT_FOREIGN_KEY is defined, then\n# foreign key definitions cannot even be parsed (attempting to specify a\n# foreign key definition is a syntax error).\n#\n# Specifically, test that foreign key constraints cannot even be parsed \n# in such a build.\n#\nreset_db\nifcapable !foreignkey {\n  do_test e_fkey-3.1 {\n    execsql { CREATE TABLE p(i PRIMARY KEY) }\n    catchsql { CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE) }\n  } {1 {near \"ON\": syntax error}}\n  do_test e_fkey-3.2 {\n    # This is allowed, as in this build, \"REFERENCES\" is not a keyword.\n    # The declared datatype of column j is \"REFERENCES p\".\n    execsql { CREATE TABLE c(j REFERENCES p) }\n  } {}\n  do_test e_fkey-3.3 {\n    execsql { PRAGMA table_info(c) }\n  } {0 j {REFERENCES p} 0 {} 0}\n  do_test e_fkey-3.4 {\n    execsql { PRAGMA foreign_key_list(c) }\n  } {}\n  do_test e_fkey-3.5 {\n    execsql { PRAGMA foreign_keys }\n  } {}\n}\n\nifcapable !foreignkey||!trigger { finish_test ; return }\nreset_db\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-07280-60510 Assuming the library is compiled with\n# foreign key constraints enabled, it must still be enabled by the\n# application at runtime, using the PRAGMA foreign_keys command.\n#\n# This also tests that foreign key constraints are disabled by default.\n#\n# EVIDENCE-OF: R-44261-39702 Foreign key constraints are disabled by\n# default (for backwards compatibility), so must be enabled separately\n# for each database connection.\n#\ndrop_all_tables\ndo_test e_fkey-4.1 {\n  execsql {\n    CREATE TABLE p(i PRIMARY KEY);\n    CREATE TABLE c(j REFERENCES p ON UPDATE CASCADE);\n    INSERT INTO p VALUES('hello');\n    INSERT INTO c VALUES('hello');\n    UPDATE p SET i = 'world';\n    SELECT * FROM c;\n  } \n} {hello}\ndo_test e_fkey-4.2 {\n  execsql {\n    DELETE FROM c;\n    DELETE FROM p;\n    PRAGMA foreign_keys = ON;\n    INSERT INTO p VALUES('hello');\n    INSERT INTO c VALUES('hello');\n    UPDATE p SET i = 'world';\n    SELECT * FROM c;\n  } \n} {world}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-08013-37737 The application can also use a PRAGMA\n# foreign_keys statement to determine if foreign keys are currently\n# enabled.\n\n#\n# This also tests the example code in section 2 of foreignkeys.in.\n#\n# EVIDENCE-OF: R-11255-19907\n# \nreset_db\ndo_test e_fkey-5.1 {\n  execsql { PRAGMA foreign_keys }\n} {0}\ndo_test e_fkey-5.2 {\n  execsql { \n    PRAGMA foreign_keys = ON;\n    PRAGMA foreign_keys;\n  }\n} {1}\ndo_test e_fkey-5.3 {\n  execsql { \n    PRAGMA foreign_keys = OFF;\n    PRAGMA foreign_keys;\n  }\n} {0}\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to enable or disable foreign key support\n# while not in auto-commit mode.\n#\n# EVIDENCE-OF: R-46649-58537 It is not possible to enable or disable\n# foreign key constraints in the middle of a multi-statement transaction\n# (when SQLite is not in autocommit mode). Attempting to do so does not\n# return an error; it simply has no effect.\n#\nreset_db\ndo_test e_fkey-6.1 {\n  execsql {\n    PRAGMA foreign_keys = ON;\n    CREATE TABLE t1(a UNIQUE, b);\n    CREATE TABLE t2(c, d REFERENCES t1(a));\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES(2, 1);\n    BEGIN;\n      PRAGMA foreign_keys = OFF;\n  }\n  catchsql {\n      DELETE FROM t1\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-6.2 {\n  execsql { PRAGMA foreign_keys }\n} {1}\ndo_test e_fkey-6.3 {\n  execsql {\n    COMMIT;\n    PRAGMA foreign_keys = OFF;\n    BEGIN;\n      PRAGMA foreign_keys = ON;\n      DELETE FROM t1;\n      PRAGMA foreign_keys;\n  }\n} {0}\ndo_test e_fkey-6.4 {\n  execsql COMMIT\n} {}\n\n###########################################################################\n### SECTION 1: Introduction to Foreign Key Constraints\n###########################################################################\nexecsql \"PRAGMA foreign_keys = ON\"\n\n#-------------------------------------------------------------------------\n# Verify that the syntax in the first example in section 1 is valid.\n#\n# EVIDENCE-OF: R-04042-24825 To do so, a foreign key definition may be\n# added by modifying the declaration of the track table to the\n# following: CREATE TABLE track( trackid INTEGER, trackname TEXT,\n# trackartist INTEGER, FOREIGN KEY(trackartist) REFERENCES\n# artist(artistid) );\n#\ndo_test e_fkey-7.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER, \n      trackname   TEXT, \n      trackartist INTEGER,\n      FOREIGN KEY(trackartist) REFERENCES artist(artistid)\n    );\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-61362-32087 Attempting to insert a row into the track\n# table that does not correspond to any row in the artist table will\n# fail,\n#\ndo_test e_fkey-8.1 {\n  catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-8.2 {\n  execsql { INSERT INTO artist VALUES(2, 'artist 1') }\n  catchsql { INSERT INTO track VALUES(1, 'track 1', 1) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-8.2 {\n  execsql { INSERT INTO track VALUES(1, 'track 1', 2) }\n} {}\n\n#-------------------------------------------------------------------------\n# Attempting to delete a row from the 'artist' table while there are \n# dependent rows in the track table also fails.\n#\n# EVIDENCE-OF: R-24401-52400 as will attempting to delete a row from the\n# artist table when there exist dependent rows in the track table\n#\ndo_test e_fkey-9.1 {\n  catchsql { DELETE FROM artist WHERE artistid = 2 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-9.2 {\n  execsql { \n    DELETE FROM track WHERE trackartist = 2;\n    DELETE FROM artist WHERE artistid = 2;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# If the foreign key column (trackartist) in table 'track' is set to NULL,\n# there is no requirement for a matching row in the 'artist' table.\n#\n# EVIDENCE-OF: R-23980-48859 There is one exception: if the foreign key\n# column in the track table is NULL, then no corresponding entry in the\n# artist table is required.\n#\ndo_test e_fkey-10.1 {\n  execsql {\n    INSERT INTO track VALUES(1, 'track 1', NULL);\n    INSERT INTO track VALUES(2, 'track 2', NULL);\n  }\n} {}\ndo_test e_fkey-10.2 {\n  execsql { SELECT * FROM artist }\n} {}\ndo_test e_fkey-10.3 {\n  # Setting the trackid to a non-NULL value fails, of course.\n  catchsql { UPDATE track SET trackartist = 5 WHERE trackid = 1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-10.4 {\n  execsql {\n    INSERT INTO artist VALUES(5, 'artist 5');\n    UPDATE track SET trackartist = 5 WHERE trackid = 1;\n  }\n  catchsql { DELETE FROM artist WHERE artistid = 5}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-10.5 {\n  execsql { \n    UPDATE track SET trackartist = NULL WHERE trackid = 1;\n    DELETE FROM artist WHERE artistid = 5;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test that the following is true fo all rows in the track table:\n#\n#   trackartist IS NULL OR \n#   EXISTS(SELECT 1 FROM artist WHERE artistid=trackartist)\n#\n# EVIDENCE-OF: R-52486-21352 Expressed in SQL, this means that for every\n# row in the track table, the following expression evaluates to true:\n# trackartist IS NULL OR EXISTS(SELECT 1 FROM artist WHERE\n# artistid=trackartist)\n\n# This procedure executes a test case to check that statement \n# R-52486-21352 is true after executing the SQL statement passed.\n# as the second argument.\nproc test_r52486_21352 {tn sql} {\n  set res [catchsql $sql]\n  set results {\n    {0 {}} \n    {1 {UNIQUE constraint failed: artist.artistid}} \n    {1 {FOREIGN KEY constraint failed}}\n  }\n  if {[lsearch $results $res]<0} {\n    error $res\n  }\n\n  do_test e_fkey-11.$tn {\n    execsql {\n      SELECT count(*) FROM track WHERE NOT (\n        trackartist IS NULL OR \n        EXISTS(SELECT 1 FROM artist WHERE artistid=trackartist)\n      )\n    }\n  } {0}\n}\n\n# Execute a series of random INSERT, UPDATE and DELETE operations\n# (some of which may fail due to FK or PK constraint violations) on \n# the two tables in the example schema. Test that R-52486-21352\n# is true after executing each operation.\n#\nset Template {\n  {INSERT INTO track VALUES($t, 'track $t', $a)}\n  {DELETE FROM track WHERE trackid = $t}\n  {UPDATE track SET trackartist = $a WHERE trackid = $t}\n  {INSERT INTO artist VALUES($a, 'artist $a')}\n  {DELETE FROM artist WHERE artistid = $a}\n  {UPDATE artist SET artistid = $a2 WHERE artistid = $a}\n}\nfor {set i 0} {$i < 500} {incr i} {\n  set a   [expr int(rand()*10)]\n  set a2  [expr int(rand()*10)]\n  set t   [expr int(rand()*50)]\n  set sql [subst [lindex $Template [expr int(rand()*6)]]]\n\n  test_r52486_21352 $i $sql\n}\n\n#-------------------------------------------------------------------------\n# Check that a NOT NULL constraint can be added to the example schema\n# to prohibit NULL child keys from being inserted.\n#\n# EVIDENCE-OF: R-42412-59321 Tip: If the application requires a stricter\n# relationship between artist and track, where NULL values are not\n# permitted in the trackartist column, simply add the appropriate \"NOT\n# NULL\" constraint to the schema.\n#\ndrop_all_tables\ndo_test e_fkey-12.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER, \n      trackname   TEXT, \n      trackartist INTEGER NOT NULL,\n      FOREIGN KEY(trackartist) REFERENCES artist(artistid)\n    );\n  }\n} {}\ndo_test e_fkey-12.2 {\n  catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }\n} {1 {NOT NULL constraint failed: track.trackartist}}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-16127-35442\n#\n# Test an example from foreignkeys.html.\n#\ndrop_all_tables\ndo_test e_fkey-13.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER, \n      trackname   TEXT, \n      trackartist INTEGER,\n      FOREIGN KEY(trackartist) REFERENCES artist(artistid)\n    );\n    INSERT INTO artist VALUES(1, 'Dean Martin');\n    INSERT INTO artist VALUES(2, 'Frank Sinatra');\n    INSERT INTO track VALUES(11, 'That''s Amore', 1);\n    INSERT INTO track VALUES(12, 'Christmas Blues', 1);\n    INSERT INTO track VALUES(13, 'My Way', 2);\n  }\n} {}\ndo_test e_fkey-13.2 {\n  catchsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', 3) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-13.3 {\n  execsql { INSERT INTO track VALUES(14, 'Mr. Bojangles', NULL) }\n} {}\ndo_test e_fkey-13.4 {\n  catchsql { \n    UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-13.5 {\n  execsql {\n    INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');\n    UPDATE track SET trackartist = 3 WHERE trackname = 'Mr. Bojangles';\n    INSERT INTO track VALUES(15, 'Boogie Woogie', 3);\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-15958-50233\n#\n# Test the second example from the first section of foreignkeys.html.\n#\ndo_test e_fkey-14.1 {\n  catchsql {\n    DELETE FROM artist WHERE artistname = 'Frank Sinatra';\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-14.2 {\n  execsql {\n    DELETE FROM track WHERE trackname = 'My Way';\n    DELETE FROM artist WHERE artistname = 'Frank Sinatra';\n  }\n} {}\ndo_test e_fkey-14.3 {\n  catchsql {\n    UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-14.4 {\n  execsql {\n    DELETE FROM track WHERE trackname IN('That''s Amore', 'Christmas Blues');\n    UPDATE artist SET artistid=4 WHERE artistname = 'Dean Martin';\n  }\n} {}\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-56032-24923 The foreign key constraint is satisfied if\n# for each row in the child table either one or more of the child key\n# columns are NULL, or there exists a row in the parent table for which\n# each parent key column contains a value equal to the value in its\n# associated child key column.\n#\n# Test also that the usual comparison rules are used when testing if there \n# is a matching row in the parent table of a foreign key constraint.\n#\n# EVIDENCE-OF: R-57765-12380 In the above paragraph, the term \"equal\"\n# means equal when values are compared using the rules specified here.\n#\ndrop_all_tables\ndo_test e_fkey-15.1 {\n  execsql {\n    CREATE TABLE par(p PRIMARY KEY);\n    CREATE TABLE chi(c REFERENCES par);\n\n    INSERT INTO par VALUES(1);\n    INSERT INTO par VALUES('1');\n    INSERT INTO par VALUES(X'31');\n    SELECT typeof(p) FROM par;\n  }\n} {integer text blob}\n\nproc test_efkey_45 {tn isError sql} {\n  do_test e_fkey-15.$tn.1 \"\n    catchsql {$sql}\n  \" [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]\n\n  do_test e_fkey-15.$tn.2 {\n    execsql {\n      SELECT * FROM chi WHERE c IS NOT NULL AND c NOT IN (SELECT p FROM par)\n    }\n  } {}\n}\n\ntest_efkey_45 1 0 \"INSERT INTO chi VALUES(1)\"\ntest_efkey_45 2 1 \"INSERT INTO chi VALUES('1.0')\"\ntest_efkey_45 3 0 \"INSERT INTO chi VALUES('1')\"\ntest_efkey_45 4 1 \"DELETE FROM par WHERE p = '1'\"\ntest_efkey_45 5 0 \"DELETE FROM chi WHERE c = '1'\"\ntest_efkey_45 6 0 \"DELETE FROM par WHERE p = '1'\"\ntest_efkey_45 7 1 \"INSERT INTO chi VALUES('1')\"\ntest_efkey_45 8 0 \"INSERT INTO chi VALUES(X'31')\"\ntest_efkey_45 9 1 \"INSERT INTO chi VALUES(X'32')\"\n\n#-------------------------------------------------------------------------\n# Specifically, test that when comparing child and parent key values the\n# default collation sequence of the parent key column is used.\n#\n# EVIDENCE-OF: R-15796-47513 When comparing text values, the collating\n# sequence associated with the parent key column is always used.\n#\ndrop_all_tables\ndo_test e_fkey-16.1 {\n  execsql {\n    CREATE TABLE t1(a COLLATE nocase PRIMARY KEY);\n    CREATE TABLE t2(b REFERENCES t1);\n  }\n} {}\ndo_test e_fkey-16.2 {\n  execsql {\n    INSERT INTO t1 VALUES('oNe');\n    INSERT INTO t2 VALUES('one');\n    INSERT INTO t2 VALUES('ONE');\n    UPDATE t2 SET b = 'OnE';\n    UPDATE t1 SET a = 'ONE';\n  }\n} {}\ndo_test e_fkey-16.3 {\n  catchsql { UPDATE t2 SET b = 'two' WHERE rowid = 1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-16.4 {\n  catchsql { DELETE FROM t1 WHERE rowid = 1 }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Specifically, test that when comparing child and parent key values the\n# affinity of the parent key column is applied to the child key value\n# before the comparison takes place.\n#\n# EVIDENCE-OF: R-04240-13860 When comparing values, if the parent key\n# column has an affinity, then that affinity is applied to the child key\n# value before the comparison is performed.\n#\ndrop_all_tables\ndo_test e_fkey-17.1 {\n  execsql {\n    CREATE TABLE t1(a NUMERIC PRIMARY KEY);\n    CREATE TABLE t2(b TEXT REFERENCES t1);\n  }\n} {}\ndo_test e_fkey-17.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES('three');\n    INSERT INTO t2 VALUES('2.0');\n    SELECT b, typeof(b) FROM t2;\n  }\n} {2.0 text}\ndo_test e_fkey-17.3 {\n  execsql { SELECT typeof(a) FROM t1 }\n} {integer integer text}\ndo_test e_fkey-17.4 {\n  catchsql { DELETE FROM t1 WHERE rowid = 2 }\n} {1 {FOREIGN KEY constraint failed}}\n\n###########################################################################\n### SECTION 3: Required and Suggested Database Indexes\n###########################################################################\n\n#-------------------------------------------------------------------------\n# A parent key must be either a PRIMARY KEY, subject to a UNIQUE \n# constraint, or have a UNIQUE index created on it.\n#\n# EVIDENCE-OF: R-13435-26311 Usually, the parent key of a foreign key\n# constraint is the primary key of the parent table. If they are not the\n# primary key, then the parent key columns must be collectively subject\n# to a UNIQUE constraint or have a UNIQUE index.\n# \n# Also test that if a parent key is not subject to a PRIMARY KEY or UNIQUE\n# constraint, but does have a UNIQUE index created on it, then the UNIQUE index\n# must use the default collation sequences associated with the parent key\n# columns.\n#\n# EVIDENCE-OF: R-00376-39212 If the parent key columns have a UNIQUE\n# index, then that index must use the collation sequences that are\n# specified in the CREATE TABLE statement for the parent table.\n#\ndrop_all_tables\ndo_test e_fkey-18.1 {\n  execsql {\n    CREATE TABLE t2(a REFERENCES t1(x));\n  }\n} {}\nproc test_efkey_57 {tn isError sql} {\n  catchsql { DROP TABLE t1 }\n  execsql $sql\n  do_test e_fkey-18.$tn {\n    catchsql { INSERT INTO t2 VALUES(NULL) }\n  } [lindex {{0 {}} {/1 {foreign key mismatch - \".*\" referencing \".*\"}/}} \\\n     $isError]\n}\ntest_efkey_57 2 0 { CREATE TABLE t1(x PRIMARY KEY) }\ntest_efkey_57 3 0 { CREATE TABLE t1(x UNIQUE) }\ntest_efkey_57 4 0 { CREATE TABLE t1(x); CREATE UNIQUE INDEX t1i ON t1(x) }\ntest_efkey_57 5 1 { \n  CREATE TABLE t1(x); \n  CREATE UNIQUE INDEX t1i ON t1(x COLLATE nocase);\n}\ntest_efkey_57 6 1 { CREATE TABLE t1(x) }\ntest_efkey_57 7 1 { CREATE TABLE t1(x, y, PRIMARY KEY(x, y)) }\ntest_efkey_57 8 1 { CREATE TABLE t1(x, y, UNIQUE(x, y)) }\ntest_efkey_57 9 1 { \n  CREATE TABLE t1(x, y); \n  CREATE UNIQUE INDEX t1i ON t1(x, y);\n}\n\n\n#-------------------------------------------------------------------------\n# This block tests an example in foreignkeys.html. Several testable\n# statements refer to this example, as follows\n#\n# EVIDENCE-OF: R-27484-01467\n#\n# FK Constraints on child1, child2 and child3 are Ok.\n#\n# Problem with FK on child4:\n#\n# EVIDENCE-OF: R-51039-44840 The foreign key declared as part of table\n# child4 is an error because even though the parent key column is\n# indexed, the index is not UNIQUE.\n#\n# Problem with FK on child5:\n#\n# EVIDENCE-OF: R-01060-48788 The foreign key for table child5 is an\n# error because even though the parent key column has a unique index,\n# the index uses a different collating sequence.\n#\n# Problem with FK on child6 and child7:\n#\n# EVIDENCE-OF: R-63088-37469 Tables child6 and child7 are incorrect\n# because while both have UNIQUE indices on their parent keys, the keys\n# are not an exact match to the columns of a single UNIQUE index.\n#\ndrop_all_tables\ndo_test e_fkey-19.1 {\n  execsql {\n    CREATE TABLE parent(a PRIMARY KEY, b UNIQUE, c, d, e, f);\n    CREATE UNIQUE INDEX i1 ON parent(c, d);\n    CREATE INDEX i2 ON parent(e);\n    CREATE UNIQUE INDEX i3 ON parent(f COLLATE nocase);\n\n    CREATE TABLE child1(f, g REFERENCES parent(a));                       -- Ok\n    CREATE TABLE child2(h, i REFERENCES parent(b));                       -- Ok\n    CREATE TABLE child3(j, k, FOREIGN KEY(j, k) REFERENCES parent(c, d)); -- Ok\n    CREATE TABLE child4(l, m REFERENCES parent(e));                       -- Err\n    CREATE TABLE child5(n, o REFERENCES parent(f));                       -- Err\n    CREATE TABLE child6(p, q, FOREIGN KEY(p,q) REFERENCES parent(b, c));  -- Err\n    CREATE TABLE child7(r REFERENCES parent(c));                          -- Err\n  }\n} {}\ndo_test e_fkey-19.2 {\n  execsql {\n    INSERT INTO parent VALUES(1, 2, 3, 4, 5, 6);\n    INSERT INTO child1 VALUES('xxx', 1);\n    INSERT INTO child2 VALUES('xxx', 2);\n    INSERT INTO child3 VALUES(3, 4);\n  }\n} {}\ndo_test e_fkey-19.2 {\n  catchsql { INSERT INTO child4 VALUES('xxx', 5) }\n} {1 {foreign key mismatch - \"child4\" referencing \"parent\"}}\ndo_test e_fkey-19.3 {\n  catchsql { INSERT INTO child5 VALUES('xxx', 6) }\n} {1 {foreign key mismatch - \"child5\" referencing \"parent\"}}\ndo_test e_fkey-19.4 {\n  catchsql { INSERT INTO child6 VALUES(2, 3) }\n} {1 {foreign key mismatch - \"child6\" referencing \"parent\"}}\ndo_test e_fkey-19.5 {\n  catchsql { INSERT INTO child7 VALUES(3) }\n} {1 {foreign key mismatch - \"child7\" referencing \"parent\"}}\n\n#-------------------------------------------------------------------------\n# Test errors in the database schema that are detected while preparing\n# DML statements. The error text for these messages always matches \n# either \"foreign key mismatch\" or \"no such table*\" (using [string match]).\n#\n# EVIDENCE-OF: R-45488-08504 If the database schema contains foreign key\n# errors that require looking at more than one table definition to\n# identify, then those errors are not detected when the tables are\n# created.\n#\n# EVIDENCE-OF: R-48391-38472 Instead, such errors prevent the\n# application from preparing SQL statements that modify the content of\n# the child or parent tables in ways that use the foreign keys.\n#\n# EVIDENCE-OF: R-03108-63659 The English language error message for\n# foreign key DML errors is usually \"foreign key mismatch\" but can also\n# be \"no such table\" if the parent table does not exist.\n#\n# EVIDENCE-OF: R-35763-48267 Foreign key DML errors are reported if: The\n# parent table does not exist, or The parent key columns named in the\n# foreign key constraint do not exist, or The parent key columns named\n# in the foreign key constraint are not the primary key of the parent\n# table and are not subject to a unique constraint using collating\n# sequence specified in the CREATE TABLE, or The child table references\n# the primary key of the parent without specifying the primary key\n# columns and the number of primary key columns in the parent do not\n# match the number of child key columns.\n#\ndo_test e_fkey-20.1 {\n  execsql {\n    CREATE TABLE c1(c REFERENCES nosuchtable, d);\n\n    CREATE TABLE p2(a, b, UNIQUE(a, b));\n    CREATE TABLE c2(c, d, FOREIGN KEY(c, d) REFERENCES p2(a, x));\n\n    CREATE TABLE p3(a PRIMARY KEY, b);\n    CREATE TABLE c3(c REFERENCES p3(b), d);\n\n    CREATE TABLE p4(a PRIMARY KEY, b);\n    CREATE UNIQUE INDEX p4i ON p4(b COLLATE nocase);\n    CREATE TABLE c4(c REFERENCES p4(b), d);\n\n    CREATE TABLE p5(a PRIMARY KEY, b COLLATE nocase);\n    CREATE UNIQUE INDEX p5i ON p5(b COLLATE binary);\n    CREATE TABLE c5(c REFERENCES p5(b), d);\n\n    CREATE TABLE p6(a PRIMARY KEY, b);\n    CREATE TABLE c6(c, d, FOREIGN KEY(c, d) REFERENCES p6);\n\n    CREATE TABLE p7(a, b, PRIMARY KEY(a, b));\n    CREATE TABLE c7(c, d REFERENCES p7);\n  }\n} {}\n\nforeach {tn tbl ptbl err} {\n  2 c1 {} \"no such table: main.nosuchtable\"\n  3 c2 p2 \"foreign key mismatch - \\\"c2\\\" referencing \\\"p2\\\"\"\n  4 c3 p3 \"foreign key mismatch - \\\"c3\\\" referencing \\\"p3\\\"\"\n  5 c4 p4 \"foreign key mismatch - \\\"c4\\\" referencing \\\"p4\\\"\"\n  6 c5 p5 \"foreign key mismatch - \\\"c5\\\" referencing \\\"p5\\\"\"\n  7 c6 p6 \"foreign key mismatch - \\\"c6\\\" referencing \\\"p6\\\"\"\n  8 c7 p7 \"foreign key mismatch - \\\"c7\\\" referencing \\\"p7\\\"\"\n} {\n  do_test e_fkey-20.$tn.1 {\n    catchsql \"INSERT INTO $tbl VALUES('a', 'b')\"\n  } [list 1 $err]\n  do_test e_fkey-20.$tn.2 {\n    catchsql \"UPDATE $tbl SET c = ?, d = ?\"\n  } [list 1 $err]\n  do_test e_fkey-20.$tn.3 {\n    catchsql \"INSERT INTO $tbl SELECT ?, ?\"\n  } [list 1 $err]\n\n  if {$ptbl ne \"\"} {\n    do_test e_fkey-20.$tn.4 {\n      catchsql \"DELETE FROM $ptbl\"\n    } [list 1 $err]\n    do_test e_fkey-20.$tn.5 {\n      catchsql \"UPDATE $ptbl SET a = ?, b = ?\"\n    } [list 1 $err]\n    do_test e_fkey-20.$tn.6 {\n      catchsql \"INSERT INTO $ptbl SELECT ?, ?\"\n    } [list 1 $err]\n  }\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-19353-43643\n#\n# Test the example of foreign key mismatch errors caused by implicitly\n# mapping a child key to the primary key of the parent table when the\n# child key consists of a different number of columns to that primary key.\n# \ndrop_all_tables\ndo_test e_fkey-21.1 {\n  execsql {\n    CREATE TABLE parent2(a, b, PRIMARY KEY(a,b));\n\n    CREATE TABLE child8(x, y, FOREIGN KEY(x,y) REFERENCES parent2);     -- Ok\n    CREATE TABLE child9(x REFERENCES parent2);                          -- Err\n    CREATE TABLE child10(x,y,z, FOREIGN KEY(x,y,z) REFERENCES parent2); -- Err\n  }\n} {}\ndo_test e_fkey-21.2 {\n  execsql {\n    INSERT INTO parent2 VALUES('I', 'II');\n    INSERT INTO child8 VALUES('I', 'II');\n  }\n} {}\ndo_test e_fkey-21.3 {\n  catchsql { INSERT INTO child9 VALUES('I') }\n} {1 {foreign key mismatch - \"child9\" referencing \"parent2\"}}\ndo_test e_fkey-21.4 {\n  catchsql { INSERT INTO child9 VALUES('II') }\n} {1 {foreign key mismatch - \"child9\" referencing \"parent2\"}}\ndo_test e_fkey-21.5 {\n  catchsql { INSERT INTO child9 VALUES(NULL) }\n} {1 {foreign key mismatch - \"child9\" referencing \"parent2\"}}\ndo_test e_fkey-21.6 {\n  catchsql { INSERT INTO child10 VALUES('I', 'II', 'III') }\n} {1 {foreign key mismatch - \"child10\" referencing \"parent2\"}}\ndo_test e_fkey-21.7 {\n  catchsql { INSERT INTO child10 VALUES(1, 2, 3) }\n} {1 {foreign key mismatch - \"child10\" referencing \"parent2\"}}\ndo_test e_fkey-21.8 {\n  catchsql { INSERT INTO child10 VALUES(NULL, NULL, NULL) }\n} {1 {foreign key mismatch - \"child10\" referencing \"parent2\"}}\n\n#-------------------------------------------------------------------------\n# Test errors that are reported when creating the child table. \n# Specifically:\n#\n#   * different number of child and parent key columns, and\n#   * child columns that do not exist.\n#\n# EVIDENCE-OF: R-23682-59820 By contrast, if foreign key errors can be\n# recognized simply by looking at the definition of the child table and\n# without having to consult the parent table definition, then the CREATE\n# TABLE statement for the child table fails.\n#\n# These errors are reported whether or not FK support is enabled.\n#\n# EVIDENCE-OF: R-33883-28833 Foreign key DDL errors are reported\n# regardless of whether or not foreign key constraints are enabled when\n# the table is created.\n#\ndrop_all_tables\nforeach fk [list OFF ON] {\n  execsql \"PRAGMA foreign_keys = $fk\"\n  set i 0\n  foreach {sql error} {\n    \"CREATE TABLE child1(a, b, FOREIGN KEY(a, b) REFERENCES p(c))\"\n      {number of columns in foreign key does not match the number of columns in the referenced table}\n    \"CREATE TABLE child2(a, b, FOREIGN KEY(a, b) REFERENCES p(c, d, e))\"\n      {number of columns in foreign key does not match the number of columns in the referenced table}\n    \"CREATE TABLE child2(a, b, FOREIGN KEY(a, c) REFERENCES p(c, d))\"\n      {unknown column \"c\" in foreign key definition}\n    \"CREATE TABLE child2(a, b, FOREIGN KEY(c, b) REFERENCES p(c, d))\"\n      {unknown column \"c\" in foreign key definition}\n  } {\n    do_test e_fkey-22.$fk.[incr i] {\n      catchsql $sql\n    } [list 1 $error]\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that a REFERENCING clause that does not specify parent key columns\n# implicitly maps to the primary key of the parent table.\n#\n# EVIDENCE-OF: R-43879-08025 Attaching a \"REFERENCES <parent-table>\"\n# clause to a column definition creates a foreign\n# key constraint that maps the column to the primary key of\n# <parent-table>.\n# \ndo_test e_fkey-23.1 {\n  execsql {\n    CREATE TABLE p1(a, b, PRIMARY KEY(a, b));\n    CREATE TABLE p2(a, b PRIMARY KEY);\n    CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES p1);\n    CREATE TABLE c2(a, b REFERENCES p2);\n  }\n} {}\nproc test_efkey_60 {tn isError sql} {\n  do_test e_fkey-23.$tn \"\n    catchsql {$sql}\n  \" [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]\n}\n\ntest_efkey_60 2 1 \"INSERT INTO c1 VALUES(239, 231)\"\ntest_efkey_60 3 0 \"INSERT INTO p1 VALUES(239, 231)\"\ntest_efkey_60 4 0 \"INSERT INTO c1 VALUES(239, 231)\"\ntest_efkey_60 5 1 \"INSERT INTO c2 VALUES(239, 231)\"\ntest_efkey_60 6 0 \"INSERT INTO p2 VALUES(239, 231)\"\ntest_efkey_60 7 0 \"INSERT INTO c2 VALUES(239, 231)\"\n\n#-------------------------------------------------------------------------\n# Test that an index on on the child key columns of an FK constraint\n# is optional.\n#\n# EVIDENCE-OF: R-15417-28014 Indices are not required for child key\n# columns\n#\n# Also test that if an index is created on the child key columns, it does\n# not make a difference whether or not it is a UNIQUE index.\n#\n# EVIDENCE-OF: R-15741-50893 The child key index does not have to be\n# (and usually will not be) a UNIQUE index.\n#\ndrop_all_tables\ndo_test e_fkey-24.1 {\n  execsql {\n    CREATE TABLE parent(x, y, UNIQUE(y, x));\n    CREATE TABLE c1(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));\n    CREATE TABLE c2(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));\n    CREATE TABLE c3(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));\n    CREATE INDEX c2i ON c2(a, b);\n    CREATE UNIQUE INDEX c3i ON c2(b, a);\n  }\n} {}\nproc test_efkey_61 {tn isError sql} {\n  do_test e_fkey-24.$tn \"\n    catchsql {$sql}\n  \" [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]\n}\nforeach {tn c} [list 2 c1 3 c2 4 c3] {\n  test_efkey_61 $tn.1 1 \"INSERT INTO $c VALUES(1, 2)\"\n  test_efkey_61 $tn.2 0 \"INSERT INTO parent VALUES(1, 2)\"\n  test_efkey_61 $tn.3 0 \"INSERT INTO $c VALUES(1, 2)\"\n\n  execsql \"DELETE FROM $c ; DELETE FROM parent\"\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-00279-52283\n#\n# Test an example showing that when a row is deleted from the parent \n# table, the child table is queried for orphaned rows as follows:\n#\n#   SELECT rowid FROM track WHERE trackartist = ?\n#\n# EVIDENCE-OF: R-23302-30956 If this SELECT returns any rows at all,\n# then SQLite concludes that deleting the row from the parent table\n# would violate the foreign key constraint and returns an error.\n#\ndo_test e_fkey-25.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER, \n      trackname   TEXT, \n      trackartist INTEGER,\n      FOREIGN KEY(trackartist) REFERENCES artist(artistid)\n    );\n  }\n} {}\ndo_execsql_test e_fkey-25.2 {\n  PRAGMA foreign_keys = OFF;\n  EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;\n  EXPLAIN QUERY PLAN SELECT rowid FROM track WHERE trackartist = ?;\n} {\n  0 0 0 {SCAN TABLE artist} \n  0 0 0 {SCAN TABLE track}\n}\ndo_execsql_test e_fkey-25.3 {\n  PRAGMA foreign_keys = ON;\n  EXPLAIN QUERY PLAN DELETE FROM artist WHERE 1;\n} {\n  0 0 0 {SCAN TABLE artist} \n  0 0 0 {SCAN TABLE track}\n}\ndo_test e_fkey-25.4 {\n  execsql {\n    INSERT INTO artist VALUES(5, 'artist 5');\n    INSERT INTO artist VALUES(6, 'artist 6');\n    INSERT INTO artist VALUES(7, 'artist 7');\n    INSERT INTO track VALUES(1, 'track 1', 5);\n    INSERT INTO track VALUES(2, 'track 2', 6);\n  }\n} {}\n\ndo_test e_fkey-25.5 {\n  concat \\\n    [execsql { SELECT rowid FROM track WHERE trackartist = 5 }]   \\\n    [catchsql { DELETE FROM artist WHERE artistid = 5 }]\n} {1 1 {FOREIGN KEY constraint failed}}\n\ndo_test e_fkey-25.6 {\n  concat \\\n    [execsql { SELECT rowid FROM track WHERE trackartist = 7 }]   \\\n    [catchsql { DELETE FROM artist WHERE artistid = 7 }]\n} {0 {}}\n\ndo_test e_fkey-25.7 {\n  concat \\\n    [execsql { SELECT rowid FROM track WHERE trackartist = 6 }]   \\\n    [catchsql { DELETE FROM artist WHERE artistid = 6 }]\n} {2 1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-47936-10044 Or, more generally:\n# SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value\n#\n# Test that when a row is deleted from the parent table of an FK \n# constraint, the child table is queried for orphaned rows. The\n# query is equivalent to:\n#\n#   SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value\n#\n# Also test that when a row is inserted into the parent table, or when the \n# parent key values of an existing row are modified, a query equivalent\n# to the following is planned. In some cases it is not executed, but it\n# is always planned.\n#\n#   SELECT rowid FROM <child-table> WHERE <child-key> = :parent_key_value\n#\n# EVIDENCE-OF: R-61616-46700 Similar queries may be run if the content\n# of the parent key is modified or a new row is inserted into the parent\n# table.\n#\n#\ndrop_all_tables\ndo_test e_fkey-26.1 {\n  execsql { CREATE TABLE parent(x, y, UNIQUE(y, x)) }\n} {}\nforeach {tn sql} {\n  2 { \n    CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y))\n  }\n  3 { \n    CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));\n    CREATE INDEX childi ON child(a, b);\n  }\n  4 { \n    CREATE TABLE child(a, b, FOREIGN KEY(a, b) REFERENCES parent(x, y));\n    CREATE UNIQUE INDEX childi ON child(b, a);\n  }\n} {\n  execsql $sql\n\n  execsql {PRAGMA foreign_keys = OFF}\n  set delete [concat \\\n      [eqp \"DELETE FROM parent WHERE 1\"] \\\n      [eqp \"SELECT rowid FROM child WHERE a = ? AND b = ?\"]\n  ]\n  set update [concat \\\n      [eqp \"UPDATE parent SET x=?, y=?\"] \\\n      [eqp \"SELECT rowid FROM child WHERE a = ? AND b = ?\"] \\\n      [eqp \"SELECT rowid FROM child WHERE a = ? AND b = ?\"]\n  ]\n  execsql {PRAGMA foreign_keys = ON}\n\n  do_test e_fkey-26.$tn.1 { eqp \"DELETE FROM parent WHERE 1\" } $delete\n  do_test e_fkey-26.$tn.2 { eqp \"UPDATE parent set x=?, y=?\" } $update\n\n  execsql {DROP TABLE child}\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-14553-34013\n#\n# Test the example schema at the end of section 3. Also test that is\n# is \"efficient\". In this case \"efficient\" means that foreign key\n# related operations on the parent table do not provoke linear scans.\n#\ndrop_all_tables\ndo_test e_fkey-27.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER,\n      trackname   TEXT, \n      trackartist INTEGER REFERENCES artist\n    );\n    CREATE INDEX trackindex ON track(trackartist);\n  }\n} {}\ndo_test e_fkey-27.2 {\n  eqp { INSERT INTO artist VALUES(?, ?) }\n} {}\ndo_execsql_test e_fkey-27.3 {\n  EXPLAIN QUERY PLAN UPDATE artist SET artistid = ?, artistname = ?\n} {\n  0 0 0 {SCAN TABLE artist} \n  0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)} \n  0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)}\n}\ndo_execsql_test e_fkey-27.4 {\n  EXPLAIN QUERY PLAN DELETE FROM artist\n} {\n  0 0 0 {SCAN TABLE artist} \n  0 0 0 {SEARCH TABLE track USING COVERING INDEX trackindex (trackartist=?)}\n}\n\n\n###########################################################################\n### SECTION 4.1: Composite Foreign Key Constraints\n###########################################################################\n\n#-------------------------------------------------------------------------\n# Check that parent and child keys must have the same number of columns.\n#\n# EVIDENCE-OF: R-41062-34431 Parent and child keys must have the same\n# cardinality.\n#\nforeach {tn sql err} {\n  1 \"CREATE TABLE c(jj REFERENCES p(x, y))\" \n    {foreign key on jj should reference only one column of table p}\n\n  2 \"CREATE TABLE c(jj REFERENCES p())\" {near \")\": syntax error}\n\n  3 \"CREATE TABLE c(jj, FOREIGN KEY(jj) REFERENCES p(x, y))\" \n    {number of columns in foreign key does not match the number of columns in the referenced table}\n\n  4 \"CREATE TABLE c(jj, FOREIGN KEY(jj) REFERENCES p())\" \n    {near \")\": syntax error}\n\n  5 \"CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p())\" \n    {near \")\": syntax error}\n\n  6 \"CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p(x))\" \n    {number of columns in foreign key does not match the number of columns in the referenced table}\n\n  7 \"CREATE TABLE c(ii, jj, FOREIGN KEY(jj, ii) REFERENCES p(x,y,z))\" \n    {number of columns in foreign key does not match the number of columns in the referenced table}\n} {\n  drop_all_tables\n  do_test e_fkey-28.$tn [list catchsql $sql] [list 1 $err]\n}\ndo_test e_fkey-28.8 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE p(x PRIMARY KEY);\n    CREATE TABLE c(a, b, FOREIGN KEY(a,b) REFERENCES p);\n  }\n  catchsql {DELETE FROM p}\n} {1 {foreign key mismatch - \"c\" referencing \"p\"}}\ndo_test e_fkey-28.9 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE p(x, y, PRIMARY KEY(x,y));\n    CREATE TABLE c(a REFERENCES p);\n  }\n  catchsql {DELETE FROM p}\n} {1 {foreign key mismatch - \"c\" referencing \"p\"}}\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-24676-09859\n#\n# Test the example schema in the \"Composite Foreign Key Constraints\" \n# section.\n#\ndo_test e_fkey-29.1 {\n  execsql {\n    CREATE TABLE album(\n      albumartist TEXT,\n      albumname TEXT,\n      albumcover BINARY,\n      PRIMARY KEY(albumartist, albumname)\n    );\n    CREATE TABLE song(\n      songid INTEGER,\n      songartist TEXT,\n      songalbum TEXT,\n      songname TEXT,\n      FOREIGN KEY(songartist, songalbum) REFERENCES album(albumartist,albumname)\n    );\n  }\n} {}\n\ndo_test e_fkey-29.2 {\n  execsql {\n    INSERT INTO album VALUES('Elvis Presley', 'Elvis'' Christmas Album', NULL);\n    INSERT INTO song VALUES(\n      1, 'Elvis Presley', 'Elvis'' Christmas Album', 'Here Comes Santa Clause'\n    );\n  }\n} {}\ndo_test e_fkey-29.3 {\n  catchsql {\n    INSERT INTO song VALUES(2, 'Elvis Presley', 'Elvis Is Back!', 'Fever');\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-33626-48418 In SQLite, if any of the child key columns\n# (in this case songartist and songalbum) are NULL, then there is no\n# requirement for a corresponding row in the parent table.\n#\ndo_test e_fkey-30.1 {\n  execsql {\n    INSERT INTO song VALUES(2, 'Elvis Presley', NULL, 'Fever');\n    INSERT INTO song VALUES(3, NULL, 'Elvis Is Back', 'Soldier Boy');\n  }\n} {}\n\n###########################################################################\n### SECTION 4.2: Deferred Foreign Key Constraints\n###########################################################################\n\n#-------------------------------------------------------------------------\n# Test that if a statement violates an immediate FK constraint, and the\n# database does not satisfy the FK constraint once all effects of the\n# statement have been applied, an error is reported and the effects of\n# the statement rolled back.\n#\n# EVIDENCE-OF: R-09323-30470 If a statement modifies the contents of the\n# database so that an immediate foreign key constraint is in violation\n# at the conclusion the statement, an exception is thrown and the\n# effects of the statement are reverted.\n#\ndrop_all_tables\ndo_test e_fkey-31.1 {\n  execsql {\n    CREATE TABLE king(a, b, PRIMARY KEY(a));\n    CREATE TABLE prince(c REFERENCES king, d);\n  }\n} {}\n\ndo_test e_fkey-31.2 {\n  # Execute a statement that violates the immediate FK constraint.\n  catchsql { INSERT INTO prince VALUES(1, 2) }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test e_fkey-31.3 {\n  # This time, use a trigger to fix the constraint violation before the\n  # statement has finished executing. Then execute the same statement as\n  # in the previous test case. This time, no error.\n  execsql {\n    CREATE TRIGGER kt AFTER INSERT ON prince WHEN\n      NOT EXISTS (SELECT a FROM king WHERE a = new.c)\n    BEGIN\n      INSERT INTO king VALUES(new.c, NULL);\n    END\n  }\n  execsql { INSERT INTO prince VALUES(1, 2) }\n} {}\n\n# Test that operating inside a transaction makes no difference to \n# immediate constraint violation handling.\ndo_test e_fkey-31.4 {\n  execsql {\n    BEGIN;\n    INSERT INTO prince VALUES(2, 3);\n    DROP TRIGGER kt;\n  }\n  catchsql { INSERT INTO prince VALUES(3, 4) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-31.5 {\n  execsql {\n    COMMIT;\n    SELECT * FROM king;\n  }\n} {1 {} 2 {}}\n\n#-------------------------------------------------------------------------\n# Test that if a deferred constraint is violated within a transaction,\n# nothing happens immediately and the database is allowed to persist\n# in a state that does not satisfy the FK constraint. However attempts\n# to COMMIT the transaction fail until the FK constraint is satisfied.\n#\n# EVIDENCE-OF: R-49178-21358 By contrast, if a statement modifies the\n# contents of the database such that a deferred foreign key constraint\n# is violated, the violation is not reported immediately.\n#\n# EVIDENCE-OF: R-39692-12488 Deferred foreign key constraints are not\n# checked until the transaction tries to COMMIT.\n#\n# EVIDENCE-OF: R-55147-47664 For as long as the user has an open\n# transaction, the database is allowed to exist in a state that violates\n# any number of deferred foreign key constraints.\n#\n# EVIDENCE-OF: R-29604-30395 However, COMMIT will fail as long as\n# foreign key constraints remain in violation.\n#\nproc test_efkey_34 {tn isError sql} {\n  do_test e_fkey-32.$tn \"\n    catchsql {$sql}\n  \" [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]\n}\ndrop_all_tables\n\ntest_efkey_34  1 0 {\n  CREATE TABLE ll(k PRIMARY KEY);\n  CREATE TABLE kk(c REFERENCES ll DEFERRABLE INITIALLY DEFERRED);\n}\ntest_efkey_34  2 0 \"BEGIN\"\ntest_efkey_34  3 0   \"INSERT INTO kk VALUES(5)\"\ntest_efkey_34  4 0   \"INSERT INTO kk VALUES(10)\"\ntest_efkey_34  5 1 \"COMMIT\"\ntest_efkey_34  6 0   \"INSERT INTO ll VALUES(10)\"\ntest_efkey_34  7 1 \"COMMIT\"\ntest_efkey_34  8 0   \"INSERT INTO ll VALUES(5)\"\ntest_efkey_34  9 0 \"COMMIT\"\n\n#-------------------------------------------------------------------------\n# When not running inside a transaction, a deferred constraint is similar\n# to an immediate constraint (violations are reported immediately).\n#\n# EVIDENCE-OF: R-56844-61705 If the current statement is not inside an\n# explicit transaction (a BEGIN/COMMIT/ROLLBACK block), then an implicit\n# transaction is committed as soon as the statement has finished\n# executing. In this case deferred constraints behave the same as\n# immediate constraints.\n#\ndrop_all_tables\nproc test_efkey_35 {tn isError sql} {\n  do_test e_fkey-33.$tn \"\n    catchsql {$sql}\n  \" [lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError]\n}\ndo_test e_fkey-33.1 {\n  execsql {\n    CREATE TABLE parent(x, y);\n    CREATE UNIQUE INDEX pi ON parent(x, y);\n    CREATE TABLE child(a, b,\n      FOREIGN KEY(a, b) REFERENCES parent(x, y) DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {}\ntest_efkey_35 2 1 \"INSERT INTO child  VALUES('x', 'y')\"\ntest_efkey_35 3 0 \"INSERT INTO parent VALUES('x', 'y')\"\ntest_efkey_35 4 0 \"INSERT INTO child  VALUES('x', 'y')\"\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-12782-61841\n#\n# Test that an FK constraint is made deferred by adding the following\n# to the definition:\n#\n#   DEFERRABLE INITIALLY DEFERRED\n#\n# EVIDENCE-OF: R-09005-28791\n#\n# Also test that adding any of the following to a foreign key definition \n# makes the constraint IMMEDIATE:\n#\n#   NOT DEFERRABLE INITIALLY DEFERRED\n#   NOT DEFERRABLE INITIALLY IMMEDIATE\n#   NOT DEFERRABLE\n#   DEFERRABLE INITIALLY IMMEDIATE\n#   DEFERRABLE\n#\n# Foreign keys are IMMEDIATE by default (if there is no DEFERRABLE or NOT\n# DEFERRABLE clause).\n#\n# EVIDENCE-OF: R-35290-16460 Foreign key constraints are immediate by\n# default.\n#\n# EVIDENCE-OF: R-30323-21917 Each foreign key constraint in SQLite is\n# classified as either immediate or deferred.\n#\ndrop_all_tables\ndo_test e_fkey-34.1 {\n  execsql {\n    CREATE TABLE parent(x, y, z, PRIMARY KEY(x,y,z));\n    CREATE TABLE c1(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE INITIALLY DEFERRED\n    );\n    CREATE TABLE c2(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE INITIALLY IMMEDIATE\n    );\n    CREATE TABLE c3(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent NOT DEFERRABLE\n    );\n    CREATE TABLE c4(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE INITIALLY IMMEDIATE\n    );\n    CREATE TABLE c5(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE\n    );\n    CREATE TABLE c6(a, b, c, FOREIGN KEY(a, b, c) REFERENCES parent);\n\n    -- This FK constraint is the only deferrable one.\n    CREATE TABLE c7(a, b, c,\n      FOREIGN KEY(a, b, c) REFERENCES parent DEFERRABLE INITIALLY DEFERRED\n    );\n\n    INSERT INTO parent VALUES('a', 'b', 'c');\n    INSERT INTO parent VALUES('d', 'e', 'f');\n    INSERT INTO parent VALUES('g', 'h', 'i');\n    INSERT INTO parent VALUES('j', 'k', 'l');\n    INSERT INTO parent VALUES('m', 'n', 'o');\n    INSERT INTO parent VALUES('p', 'q', 'r');\n    INSERT INTO parent VALUES('s', 't', 'u');\n\n    INSERT INTO c1 VALUES('a', 'b', 'c');\n    INSERT INTO c2 VALUES('d', 'e', 'f');\n    INSERT INTO c3 VALUES('g', 'h', 'i');\n    INSERT INTO c4 VALUES('j', 'k', 'l');\n    INSERT INTO c5 VALUES('m', 'n', 'o');\n    INSERT INTO c6 VALUES('p', 'q', 'r');\n    INSERT INTO c7 VALUES('s', 't', 'u');\n  }\n} {}\n\nproc test_efkey_29 {tn sql isError} {\n  do_test e_fkey-34.$tn \"catchsql {$sql}\" [\n    lindex {{0 {}} {1 {FOREIGN KEY constraint failed}}} $isError\n  ]\n}\ntest_efkey_29  2 \"BEGIN\"                                   0\ntest_efkey_29  3 \"DELETE FROM parent WHERE x = 'a'\"        1\ntest_efkey_29  4 \"DELETE FROM parent WHERE x = 'd'\"        1\ntest_efkey_29  5 \"DELETE FROM parent WHERE x = 'g'\"        1\ntest_efkey_29  6 \"DELETE FROM parent WHERE x = 'j'\"        1\ntest_efkey_29  7 \"DELETE FROM parent WHERE x = 'm'\"        1\ntest_efkey_29  8 \"DELETE FROM parent WHERE x = 'p'\"        1\ntest_efkey_29  9 \"DELETE FROM parent WHERE x = 's'\"        0\ntest_efkey_29 10 \"COMMIT\"                                  1\ntest_efkey_29 11 \"ROLLBACK\"                                0\n\ntest_efkey_29  9 \"BEGIN\"                                   0\ntest_efkey_29 10 \"UPDATE parent SET z = 'z' WHERE z = 'c'\" 1\ntest_efkey_29 11 \"UPDATE parent SET z = 'z' WHERE z = 'f'\" 1\ntest_efkey_29 12 \"UPDATE parent SET z = 'z' WHERE z = 'i'\" 1\ntest_efkey_29 13 \"UPDATE parent SET z = 'z' WHERE z = 'l'\" 1\ntest_efkey_29 14 \"UPDATE parent SET z = 'z' WHERE z = 'o'\" 1\ntest_efkey_29 15 \"UPDATE parent SET z = 'z' WHERE z = 'r'\" 1\ntest_efkey_29 16 \"UPDATE parent SET z = 'z' WHERE z = 'u'\" 0\ntest_efkey_29 17 \"COMMIT\"                                  1\ntest_efkey_29 18 \"ROLLBACK\"                                0\n\ntest_efkey_29 17 \"BEGIN\"                                   0\ntest_efkey_29 18 \"INSERT INTO c1 VALUES(1, 2, 3)\"          1\ntest_efkey_29 19 \"INSERT INTO c2 VALUES(1, 2, 3)\"          1\ntest_efkey_29 20 \"INSERT INTO c3 VALUES(1, 2, 3)\"          1\ntest_efkey_29 21 \"INSERT INTO c4 VALUES(1, 2, 3)\"          1\ntest_efkey_29 22 \"INSERT INTO c5 VALUES(1, 2, 3)\"          1\ntest_efkey_29 22 \"INSERT INTO c6 VALUES(1, 2, 3)\"          1\ntest_efkey_29 22 \"INSERT INTO c7 VALUES(1, 2, 3)\"          0\ntest_efkey_29 23 \"COMMIT\"                                  1\ntest_efkey_29 24 \"INSERT INTO parent VALUES(1, 2, 3)\"      0\ntest_efkey_29 25 \"COMMIT\"                                  0\n\ntest_efkey_29 26 \"BEGIN\"                                   0\ntest_efkey_29 27 \"UPDATE c1 SET a = 10\"                    1\ntest_efkey_29 28 \"UPDATE c2 SET a = 10\"                    1\ntest_efkey_29 29 \"UPDATE c3 SET a = 10\"                    1\ntest_efkey_29 30 \"UPDATE c4 SET a = 10\"                    1\ntest_efkey_29 31 \"UPDATE c5 SET a = 10\"                    1\ntest_efkey_29 31 \"UPDATE c6 SET a = 10\"                    1\ntest_efkey_29 31 \"UPDATE c7 SET a = 10\"                    0\ntest_efkey_29 32 \"COMMIT\"                                  1\ntest_efkey_29 33 \"ROLLBACK\"                                0\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-24499-57071\n#\n# Test an example from foreignkeys.html dealing with a deferred foreign \n# key constraint.\n#\ndo_test e_fkey-35.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER,\n      trackname   TEXT, \n      trackartist INTEGER REFERENCES artist(artistid) DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {}\ndo_test e_fkey-35.2 {\n  execsql {\n    BEGIN;\n      INSERT INTO track VALUES(1, 'White Christmas', 5);\n  }\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-35.3 {\n  execsql {\n    INSERT INTO artist VALUES(5, 'Bing Crosby');\n    COMMIT;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Verify that a nested savepoint may be released without satisfying \n# deferred foreign key constraints.\n#\n# EVIDENCE-OF: R-07223-48323 A nested savepoint transaction may be\n# RELEASEd while the database is in a state that does not satisfy a\n# deferred foreign key constraint.\n#\ndrop_all_tables\ndo_test e_fkey-36.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY,\n      b REFERENCES t1 DEFERRABLE INITIALLY DEFERRED\n    );\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 2);\n    INSERT INTO t1 VALUES(3, 3);\n  }\n} {}\ndo_test e_fkey-36.2 {\n  execsql {\n    BEGIN;\n      SAVEPOINT one;\n        INSERT INTO t1 VALUES(4, 5);\n      RELEASE one;\n  }\n} {}\ndo_test e_fkey-36.3 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-36.4 {\n  execsql {\n    UPDATE t1 SET a = 5 WHERE a = 4;\n    COMMIT;\n  }\n} {}\n\n\n#-------------------------------------------------------------------------\n# Check that a transaction savepoint (an outermost savepoint opened when\n# the database was in auto-commit mode) cannot be released without\n# satisfying deferred foreign key constraints. It may be rolled back.\n#\n# EVIDENCE-OF: R-44295-13823 A transaction savepoint (a non-nested\n# savepoint that was opened while there was not currently an open\n# transaction), on the other hand, is subject to the same restrictions\n# as a COMMIT - attempting to RELEASE it while the database is in such a\n# state will fail.\n#\ndo_test e_fkey-37.1 {\n  execsql {\n    SAVEPOINT one;\n      SAVEPOINT two;\n        INSERT INTO t1 VALUES(6, 7);\n      RELEASE two;\n  }\n} {}\ndo_test e_fkey-37.2 {\n  catchsql {RELEASE one}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-37.3 {\n  execsql {\n      UPDATE t1 SET a = 7 WHERE a = 6;\n    RELEASE one;\n  }\n} {}\ndo_test e_fkey-37.4 {\n  execsql {\n    SAVEPOINT one;\n      SAVEPOINT two;\n        INSERT INTO t1 VALUES(9, 10);\n      RELEASE two;\n  }\n} {}\ndo_test e_fkey-37.5 {\n  catchsql {RELEASE one}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-37.6 {\n  execsql {ROLLBACK TO one ; RELEASE one}\n} {}\n\n#-------------------------------------------------------------------------\n# Test that if a COMMIT operation fails due to deferred foreign key \n# constraints, any nested savepoints remain open.\n#\n# EVIDENCE-OF: R-37736-42616 If a COMMIT statement (or the RELEASE of a\n# transaction SAVEPOINT) fails because the database is currently in a\n# state that violates a deferred foreign key constraint and there are\n# currently nested savepoints, the nested savepoints remain open.\n#\ndo_test e_fkey-38.1 {\n  execsql {\n    DELETE FROM t1 WHERE a>3;\n    SELECT * FROM t1;\n  }\n} {1 1 2 2 3 3}\ndo_test e_fkey-38.2 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES(4, 4);\n      SAVEPOINT one;\n        INSERT INTO t1 VALUES(5, 6);\n        SELECT * FROM t1;\n  }\n} {1 1 2 2 3 3 4 4 5 6}\ndo_test e_fkey-38.3 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-38.4 {\n  execsql {\n    ROLLBACK TO one;\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {1 1 2 2 3 3 4 4}\n\ndo_test e_fkey-38.5 {\n  execsql {\n    SAVEPOINT a;\n      INSERT INTO t1 VALUES(5, 5);\n      SAVEPOINT b;\n        INSERT INTO t1 VALUES(6, 7);\n        SAVEPOINT c;\n          INSERT INTO t1 VALUES(7, 8);\n  }\n} {}\ndo_test e_fkey-38.6 {\n  catchsql {RELEASE a}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-38.7 {\n  execsql  {ROLLBACK TO c}\n  catchsql {RELEASE a}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-38.8 {\n  execsql  {\n    ROLLBACK TO b;\n    RELEASE a;\n    SELECT * FROM t1;\n  }\n} {1 1 2 2 3 3 4 4 5 5}\n\n###########################################################################\n### SECTION 4.3: ON DELETE and ON UPDATE Actions\n###########################################################################\n\n#-------------------------------------------------------------------------\n# Test that configured ON DELETE and ON UPDATE actions take place when\n# deleting or modifying rows of the parent table, respectively.\n#\n# EVIDENCE-OF: R-48270-44282 Foreign key ON DELETE and ON UPDATE clauses\n# are used to configure actions that take place when deleting rows from\n# the parent table (ON DELETE), or modifying the parent key values of\n# existing rows (ON UPDATE).\n#\n# Test that a single FK constraint may have different actions configured\n# for ON DELETE and ON UPDATE.\n#\n# EVIDENCE-OF: R-48124-63225 A single foreign key constraint may have\n# different actions configured for ON DELETE and ON UPDATE.\n#\ndo_test e_fkey-39.1 {\n  execsql {\n    CREATE TABLE p(a, b PRIMARY KEY, c);\n    CREATE TABLE c1(d, e, f DEFAULT 'k0' REFERENCES p \n      ON UPDATE SET DEFAULT\n      ON DELETE SET NULL\n    );\n\n    INSERT INTO p VALUES(0, 'k0', '');\n    INSERT INTO p VALUES(1, 'k1', 'I');\n    INSERT INTO p VALUES(2, 'k2', 'II');\n    INSERT INTO p VALUES(3, 'k3', 'III');\n\n    INSERT INTO c1 VALUES(1, 'xx', 'k1');\n    INSERT INTO c1 VALUES(2, 'xx', 'k2');\n    INSERT INTO c1 VALUES(3, 'xx', 'k3');\n  }\n} {}\ndo_test e_fkey-39.2 {\n  execsql {\n    UPDATE p SET b = 'k4' WHERE a = 1;\n    SELECT * FROM c1;\n  }\n} {1 xx k0 2 xx k2 3 xx k3}\ndo_test e_fkey-39.3 {\n  execsql {\n    DELETE FROM p WHERE a = 2;\n    SELECT * FROM c1;\n  }\n} {1 xx k0 2 xx {} 3 xx k3}\ndo_test e_fkey-39.4 {\n  execsql {\n    CREATE UNIQUE INDEX pi ON p(c);\n    REPLACE INTO p VALUES(5, 'k5', 'III');\n    SELECT * FROM c1;\n  }\n} {1 xx k0 2 xx {} 3 xx {}}\n\n#-------------------------------------------------------------------------\n# Each foreign key in the system has an ON UPDATE and ON DELETE action,\n# either \"NO ACTION\", \"RESTRICT\", \"SET NULL\", \"SET DEFAULT\" or \"CASCADE\".\n#\n# EVIDENCE-OF: R-33326-45252 The ON DELETE and ON UPDATE action\n# associated with each foreign key in an SQLite database is one of \"NO\n# ACTION\", \"RESTRICT\", \"SET NULL\", \"SET DEFAULT\" or \"CASCADE\".\n#\n# If none is specified explicitly, \"NO ACTION\" is the default.\n#\n# EVIDENCE-OF: R-19803-45884 If an action is not explicitly specified,\n# it defaults to \"NO ACTION\".\n# \ndrop_all_tables\ndo_test e_fkey-40.1 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY, y);\n    CREATE TABLE child1(a, \n      b REFERENCES parent ON UPDATE NO ACTION ON DELETE RESTRICT\n    );\n    CREATE TABLE child2(a, \n      b REFERENCES parent ON UPDATE RESTRICT ON DELETE SET NULL\n    );\n    CREATE TABLE child3(a, \n      b REFERENCES parent ON UPDATE SET NULL ON DELETE SET DEFAULT\n    );\n    CREATE TABLE child4(a, \n      b REFERENCES parent ON UPDATE SET DEFAULT ON DELETE CASCADE\n    );\n\n    -- Create some foreign keys that use the default action - \"NO ACTION\"\n    CREATE TABLE child5(a, b REFERENCES parent ON UPDATE CASCADE);\n    CREATE TABLE child6(a, b REFERENCES parent ON DELETE RESTRICT);\n    CREATE TABLE child7(a, b REFERENCES parent ON DELETE NO ACTION);\n    CREATE TABLE child8(a, b REFERENCES parent ON UPDATE NO ACTION);\n  }\n} {}\n\nforeach {tn zTab lRes} {\n  2 child1 {0 0 parent b {} {NO ACTION} RESTRICT NONE}\n  3 child2 {0 0 parent b {} RESTRICT {SET NULL} NONE}\n  4 child3 {0 0 parent b {} {SET NULL} {SET DEFAULT} NONE}\n  5 child4 {0 0 parent b {} {SET DEFAULT} CASCADE NONE}\n  6 child5 {0 0 parent b {} CASCADE {NO ACTION} NONE}\n  7 child6 {0 0 parent b {} {NO ACTION} RESTRICT NONE}\n  8 child7 {0 0 parent b {} {NO ACTION} {NO ACTION} NONE}\n  9 child8 {0 0 parent b {} {NO ACTION} {NO ACTION} NONE}\n} {\n  do_test e_fkey-40.$tn { execsql \"PRAGMA foreign_key_list($zTab)\" } $lRes\n}\n\n#-------------------------------------------------------------------------\n# Test that \"NO ACTION\" means that nothing happens to a child row when\n# it's parent row is updated or deleted.\n#\n# EVIDENCE-OF: R-19971-54976 Configuring \"NO ACTION\" means just that:\n# when a parent key is modified or deleted from the database, no special\n# action is taken.\n#\ndrop_all_tables\ndo_test e_fkey-41.1 {\n  execsql {\n    CREATE TABLE parent(p1, p2, PRIMARY KEY(p1, p2));\n    CREATE TABLE child(c1, c2, \n      FOREIGN KEY(c1, c2) REFERENCES parent\n      ON UPDATE NO ACTION\n      ON DELETE NO ACTION\n      DEFERRABLE INITIALLY DEFERRED\n    );\n    INSERT INTO parent VALUES('j', 'k');\n    INSERT INTO parent VALUES('l', 'm');\n    INSERT INTO child VALUES('j', 'k');\n    INSERT INTO child VALUES('l', 'm');\n  }\n} {}\ndo_test e_fkey-41.2 {\n  execsql {\n    BEGIN;\n      UPDATE parent SET p1='k' WHERE p1='j';\n      DELETE FROM parent WHERE p1='l';\n      SELECT * FROM child;\n  }\n} {j k l m}\ndo_test e_fkey-41.3 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-41.4 {\n  execsql ROLLBACK\n} {}\n\n#-------------------------------------------------------------------------\n# Test that \"RESTRICT\" means the application is prohibited from deleting\n# or updating a parent table row when there exists one or more child keys\n# mapped to it.\n#\n# EVIDENCE-OF: R-04272-38653 The \"RESTRICT\" action means that the\n# application is prohibited from deleting (for ON DELETE RESTRICT) or\n# modifying (for ON UPDATE RESTRICT) a parent key when there exists one\n# or more child keys mapped to it.\n#\ndrop_all_tables\ndo_test e_fkey-41.1 {\n  execsql {\n    CREATE TABLE parent(p1, p2);\n    CREATE UNIQUE INDEX parent_i ON parent(p1, p2);\n    CREATE TABLE child1(c1, c2, \n      FOREIGN KEY(c2, c1) REFERENCES parent(p1, p2) ON DELETE RESTRICT\n    );\n    CREATE TABLE child2(c1, c2, \n      FOREIGN KEY(c2, c1) REFERENCES parent(p1, p2) ON UPDATE RESTRICT\n    );\n  }\n} {}\ndo_test e_fkey-41.2 {\n  execsql {\n    INSERT INTO parent VALUES('a', 'b');\n    INSERT INTO parent VALUES('c', 'd');\n    INSERT INTO child1 VALUES('b', 'a');\n    INSERT INTO child2 VALUES('d', 'c');\n  }\n} {}\ndo_test e_fkey-41.3 {\n  catchsql { DELETE FROM parent WHERE p1 = 'a' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-41.4 {\n  catchsql { UPDATE parent SET p2 = 'e' WHERE p1 = 'c' }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Test that RESTRICT is slightly different from NO ACTION for IMMEDIATE\n# constraints, in that it is enforced immediately, not at the end of the \n# statement.\n#\n# EVIDENCE-OF: R-37997-42187 The difference between the effect of a\n# RESTRICT action and normal foreign key constraint enforcement is that\n# the RESTRICT action processing happens as soon as the field is updated\n# - not at the end of the current statement as it would with an\n# immediate constraint, or at the end of the current transaction as it\n# would with a deferred constraint.\n#\ndrop_all_tables\ndo_test e_fkey-42.1 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child1(c REFERENCES parent ON UPDATE RESTRICT);\n    CREATE TABLE child2(c REFERENCES parent ON UPDATE NO ACTION);\n\n    INSERT INTO parent VALUES('key1');\n    INSERT INTO parent VALUES('key2');\n    INSERT INTO child1 VALUES('key1');\n    INSERT INTO child2 VALUES('key2');\n\n    CREATE TRIGGER parent_t AFTER UPDATE ON parent BEGIN\n      UPDATE child1 set c = new.x WHERE c = old.x;\n      UPDATE child2 set c = new.x WHERE c = old.x;\n    END;\n  }\n} {}\ndo_test e_fkey-42.2 {\n  catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-42.3 {\n  execsql { \n    UPDATE parent SET x = 'key two' WHERE x = 'key2';\n    SELECT * FROM child2;\n  }\n} {{key two}}\n\ndrop_all_tables\ndo_test e_fkey-42.4 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT);\n    CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION);\n\n    INSERT INTO parent VALUES('key1');\n    INSERT INTO parent VALUES('key2');\n    INSERT INTO child1 VALUES('key1');\n    INSERT INTO child2 VALUES('key2');\n\n    CREATE TRIGGER parent_t AFTER DELETE ON parent BEGIN\n      UPDATE child1 SET c = NULL WHERE c = old.x;\n      UPDATE child2 SET c = NULL WHERE c = old.x;\n    END;\n  }\n} {}\ndo_test e_fkey-42.5 {\n  catchsql { DELETE FROM parent WHERE x = 'key1' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-42.6 {\n  execsql { \n    DELETE FROM parent WHERE x = 'key2';\n    SELECT * FROM child2;\n  }\n} {{}}\n\ndrop_all_tables\ndo_test e_fkey-42.7 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT);\n    CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION);\n\n    INSERT INTO parent VALUES('key1');\n    INSERT INTO parent VALUES('key2');\n    INSERT INTO child1 VALUES('key1');\n    INSERT INTO child2 VALUES('key2');\n  }\n} {}\ndo_test e_fkey-42.8 {\n  catchsql { REPLACE INTO parent VALUES('key1') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-42.9 {\n  execsql { \n    REPLACE INTO parent VALUES('key2');\n    SELECT * FROM child2;\n  }\n} {key2}\n\n#-------------------------------------------------------------------------\n# Test that RESTRICT is enforced immediately, even for a DEFERRED constraint.\n#\n# EVIDENCE-OF: R-24179-60523 Even if the foreign key constraint it is\n# attached to is deferred, configuring a RESTRICT action causes SQLite\n# to return an error immediately if a parent key with dependent child\n# keys is deleted or modified.\n#\ndrop_all_tables\ndo_test e_fkey-43.1 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child1(c REFERENCES parent ON UPDATE RESTRICT\n      DEFERRABLE INITIALLY DEFERRED\n    );\n    CREATE TABLE child2(c REFERENCES parent ON UPDATE NO ACTION\n      DEFERRABLE INITIALLY DEFERRED\n    );\n\n    INSERT INTO parent VALUES('key1');\n    INSERT INTO parent VALUES('key2');\n    INSERT INTO child1 VALUES('key1');\n    INSERT INTO child2 VALUES('key2');\n    BEGIN;\n  }\n} {}\ndo_test e_fkey-43.2 {\n  catchsql { UPDATE parent SET x = 'key one' WHERE x = 'key1' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-43.3 {\n  execsql { UPDATE parent SET x = 'key two' WHERE x = 'key2' }\n} {}\ndo_test e_fkey-43.4 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-43.5 {\n  execsql {\n    UPDATE child2 SET c = 'key two';\n    COMMIT;\n  }\n} {}\n\ndrop_all_tables\ndo_test e_fkey-43.6 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child1(c REFERENCES parent ON DELETE RESTRICT\n      DEFERRABLE INITIALLY DEFERRED\n    );\n    CREATE TABLE child2(c REFERENCES parent ON DELETE NO ACTION\n      DEFERRABLE INITIALLY DEFERRED\n    );\n\n    INSERT INTO parent VALUES('key1');\n    INSERT INTO parent VALUES('key2');\n    INSERT INTO child1 VALUES('key1');\n    INSERT INTO child2 VALUES('key2');\n    BEGIN;\n  }\n} {}\ndo_test e_fkey-43.7 {\n  catchsql { DELETE FROM parent WHERE x = 'key1' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-43.8 {\n  execsql { DELETE FROM parent WHERE x = 'key2' }\n} {}\ndo_test e_fkey-43.9 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-43.10 {\n  execsql {\n    UPDATE child2 SET c = NULL;\n    COMMIT;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test SET NULL actions.\n#\n# EVIDENCE-OF: R-03353-05327 If the configured action is \"SET NULL\",\n# then when a parent key is deleted (for ON DELETE SET NULL) or modified\n# (for ON UPDATE SET NULL), the child key columns of all rows in the\n# child table that mapped to the parent key are set to contain SQL NULL\n# values.\n#\ndrop_all_tables\ndo_test e_fkey-44.1 {\n  execsql {\n    CREATE TABLE pA(x PRIMARY KEY);\n    CREATE TABLE cA(c REFERENCES pA ON DELETE SET NULL);\n    CREATE TABLE cB(c REFERENCES pA ON UPDATE SET NULL);\n\n    INSERT INTO pA VALUES(X'ABCD');\n    INSERT INTO pA VALUES(X'1234');\n    INSERT INTO cA VALUES(X'ABCD');\n    INSERT INTO cB VALUES(X'1234');\n  }\n} {}\ndo_test e_fkey-44.2 {\n  execsql {\n    DELETE FROM pA WHERE rowid = 1;\n    SELECT quote(x) FROM pA;\n  }\n} {X'1234'}\ndo_test e_fkey-44.3 {\n  execsql {\n    SELECT quote(c) FROM cA;\n  }\n} {NULL}\ndo_test e_fkey-44.4 {\n  execsql {\n    UPDATE pA SET x = X'8765' WHERE rowid = 2;\n    SELECT quote(x) FROM pA;\n  }\n} {X'8765'}\ndo_test e_fkey-44.5 {\n  execsql { SELECT quote(c) FROM cB }\n} {NULL}\n\n#-------------------------------------------------------------------------\n# Test SET DEFAULT actions.\n#\n# EVIDENCE-OF: R-43054-54832 The \"SET DEFAULT\" actions are similar to\n# \"SET NULL\", except that each of the child key columns is set to\n# contain the columns default value instead of NULL.\n#\ndrop_all_tables\ndo_test e_fkey-45.1 {\n  execsql {\n    CREATE TABLE pA(x PRIMARY KEY);\n    CREATE TABLE cA(c DEFAULT X'0000' REFERENCES pA ON DELETE SET DEFAULT);\n    CREATE TABLE cB(c DEFAULT X'9999' REFERENCES pA ON UPDATE SET DEFAULT);\n\n    INSERT INTO pA(rowid, x) VALUES(1, X'0000');\n    INSERT INTO pA(rowid, x) VALUES(2, X'9999');\n    INSERT INTO pA(rowid, x) VALUES(3, X'ABCD');\n    INSERT INTO pA(rowid, x) VALUES(4, X'1234');\n\n    INSERT INTO cA VALUES(X'ABCD');\n    INSERT INTO cB VALUES(X'1234');\n  }\n} {}\ndo_test e_fkey-45.2 {\n  execsql {\n    DELETE FROM pA WHERE rowid = 3;\n    SELECT quote(x) FROM pA ORDER BY rowid;\n  }\n} {X'0000' X'9999' X'1234'}\ndo_test e_fkey-45.3 {\n  execsql { SELECT quote(c) FROM cA }\n} {X'0000'}\ndo_test e_fkey-45.4 {\n  execsql {\n    UPDATE pA SET x = X'8765' WHERE rowid = 4;\n    SELECT quote(x) FROM pA ORDER BY rowid;\n  }\n} {X'0000' X'9999' X'8765'}\ndo_test e_fkey-45.5 {\n  execsql { SELECT quote(c) FROM cB }\n} {X'9999'}\n\n#-------------------------------------------------------------------------\n# Test ON DELETE CASCADE actions.\n#\n# EVIDENCE-OF: R-61376-57267 A \"CASCADE\" action propagates the delete or\n# update operation on the parent key to each dependent child key.\n#\n# EVIDENCE-OF: R-61809-62207 For an \"ON DELETE CASCADE\" action, this\n# means that each row in the child table that was associated with the\n# deleted parent row is also deleted.\n#\ndrop_all_tables\ndo_test e_fkey-46.1 {\n  execsql {\n    CREATE TABLE p1(a, b UNIQUE);\n    CREATE TABLE c1(c REFERENCES p1(b) ON DELETE CASCADE, d);\n    INSERT INTO p1 VALUES(NULL, NULL);\n    INSERT INTO p1 VALUES(4, 4);\n    INSERT INTO p1 VALUES(5, 5);\n    INSERT INTO c1 VALUES(NULL, NULL);\n    INSERT INTO c1 VALUES(4, 4);\n    INSERT INTO c1 VALUES(5, 5);\n    SELECT count(*) FROM c1;\n  }\n} {3}\ndo_test e_fkey-46.2 {\n  execsql {\n    DELETE FROM p1 WHERE a = 4;\n    SELECT d, c FROM c1;\n  }\n} {{} {} 5 5}\ndo_test e_fkey-46.3 {\n  execsql {\n    DELETE FROM p1;\n    SELECT d, c FROM c1;\n  }\n} {{} {}}\ndo_test e_fkey-46.4 {\n  execsql { SELECT * FROM p1 }\n} {}\n\n\n#-------------------------------------------------------------------------\n# Test ON UPDATE CASCADE actions.\n#\n# EVIDENCE-OF: R-13877-64542 For an \"ON UPDATE CASCADE\" action, it means\n# that the values stored in each dependent child key are modified to\n# match the new parent key values.\n#\n# EVIDENCE-OF: R-61376-57267 A \"CASCADE\" action propagates the delete or\n# update operation on the parent key to each dependent child key.\n#\ndrop_all_tables\ndo_test e_fkey-47.1 {\n  execsql {\n    CREATE TABLE p1(a, b UNIQUE);\n    CREATE TABLE c1(c REFERENCES p1(b) ON UPDATE CASCADE, d);\n    INSERT INTO p1 VALUES(NULL, NULL);\n    INSERT INTO p1 VALUES(4, 4);\n    INSERT INTO p1 VALUES(5, 5);\n    INSERT INTO c1 VALUES(NULL, NULL);\n    INSERT INTO c1 VALUES(4, 4);\n    INSERT INTO c1 VALUES(5, 5);\n    SELECT count(*) FROM c1;\n  }\n} {3}\ndo_test e_fkey-47.2 {\n  execsql {\n    UPDATE p1 SET b = 10 WHERE b = 5;\n    SELECT d, c FROM c1;\n  }\n} {{} {} 4 4 5 10}\ndo_test e_fkey-47.3 {\n  execsql {\n    UPDATE p1 SET b = 11 WHERE b = 4;\n    SELECT d, c FROM c1;\n  }\n} {{} {} 4 11 5 10}\ndo_test e_fkey-47.4 {\n  execsql { \n    UPDATE p1 SET b = 6 WHERE b IS NULL;\n    SELECT d, c FROM c1;\n  }\n} {{} {} 4 11 5 10}\ndo_test e_fkey-46.5 {\n  execsql { SELECT * FROM p1 }\n} {{} 6 4 11 5 10}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-65058-57158\n#\n# Test an example from the \"ON DELETE and ON UPDATE Actions\" section \n# of foreignkeys.html.\n#\ndrop_all_tables\ndo_test e_fkey-48.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER,\n      trackname   TEXT, \n      trackartist INTEGER REFERENCES artist(artistid) ON UPDATE CASCADE\n    );\n\n    INSERT INTO artist VALUES(1, 'Dean Martin');\n    INSERT INTO artist VALUES(2, 'Frank Sinatra');\n    INSERT INTO track VALUES(11, 'That''s Amore', 1);\n    INSERT INTO track VALUES(12, 'Christmas Blues', 1);\n    INSERT INTO track VALUES(13, 'My Way', 2);\n  }\n} {}\ndo_test e_fkey-48.2 {\n  execsql {\n    UPDATE artist SET artistid = 100 WHERE artistname = 'Dean Martin';\n  }\n} {}\ndo_test e_fkey-48.3 {\n  execsql { SELECT * FROM artist }\n} {2 {Frank Sinatra} 100 {Dean Martin}}\ndo_test e_fkey-48.4 {\n  execsql { SELECT * FROM track }\n} {11 {That's Amore} 100 12 {Christmas Blues} 100 13 {My Way} 2}\n\n\n#-------------------------------------------------------------------------\n# Verify that adding an FK action does not absolve the user of the \n# requirement not to violate the foreign key constraint.\n#\n# EVIDENCE-OF: R-53968-51642 Configuring an ON UPDATE or ON DELETE\n# action does not mean that the foreign key constraint does not need to\n# be satisfied.\n#\ndrop_all_tables\ndo_test e_fkey-49.1 {\n  execsql {\n    CREATE TABLE parent(a COLLATE nocase, b, c, PRIMARY KEY(c, a));\n    CREATE TABLE child(d DEFAULT 'a', e, f DEFAULT 'c',\n      FOREIGN KEY(f, d) REFERENCES parent ON UPDATE SET DEFAULT\n    );\n\n    INSERT INTO parent VALUES('A', 'b', 'c');\n    INSERT INTO parent VALUES('ONE', 'two', 'three');\n    INSERT INTO child VALUES('one', 'two', 'three');\n  }\n} {}\ndo_test e_fkey-49.2 {\n  execsql {\n    BEGIN;\n      UPDATE parent SET a = '' WHERE a = 'oNe';\n      SELECT * FROM child;\n  }\n} {a two c}\ndo_test e_fkey-49.3 {\n  execsql {\n    ROLLBACK;\n    DELETE FROM parent WHERE a = 'A';\n    SELECT * FROM parent;\n  }\n} {ONE two three}\ndo_test e_fkey-49.4 {\n  catchsql { UPDATE parent SET a = '' WHERE a = 'oNe' }\n} {1 {FOREIGN KEY constraint failed}}\n\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-11856-19836\n#\n# Test an example from the \"ON DELETE and ON UPDATE Actions\" section \n# of foreignkeys.html. This example shows that adding an \"ON DELETE DEFAULT\"\n# clause does not abrogate the need to satisfy the foreign key constraint\n# (R-28220-46694).\n#\n# EVIDENCE-OF: R-28220-46694 For example, if an \"ON DELETE SET DEFAULT\"\n# action is configured, but there is no row in the parent table that\n# corresponds to the default values of the child key columns, deleting a\n# parent key while dependent child keys exist still causes a foreign key\n# violation.\n#\ndrop_all_tables\ndo_test e_fkey-50.1 {\n  execsql {\n    CREATE TABLE artist(\n      artistid    INTEGER PRIMARY KEY, \n      artistname  TEXT\n    );\n    CREATE TABLE track(\n      trackid     INTEGER,\n      trackname   TEXT, \n      trackartist INTEGER DEFAULT 0 REFERENCES artist(artistid) ON DELETE SET DEFAULT\n    );\n    INSERT INTO artist VALUES(3, 'Sammy Davis Jr.');\n    INSERT INTO track VALUES(14, 'Mr. Bojangles', 3);\n  }\n} {}\ndo_test e_fkey-50.2 {\n  catchsql { DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-50.3 {\n  execsql {\n    INSERT INTO artist VALUES(0, 'Unknown Artist');\n    DELETE FROM artist WHERE artistname = 'Sammy Davis Jr.';\n  }\n} {}\ndo_test e_fkey-50.4 {\n  execsql { SELECT * FROM artist }\n} {0 {Unknown Artist}}\ndo_test e_fkey-50.5 {\n  execsql { SELECT * FROM track }\n} {14 {Mr. Bojangles} 0}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-09564-22170\n#\n# Check that the order of steps in an UPDATE or DELETE on a parent \n# table is as follows:\n#\n#   1. Execute applicable BEFORE trigger programs,\n#   2. Check local (non foreign key) constraints,\n#   3. Update or delete the row in the parent table,\n#   4. Perform any required foreign key actions,\n#   5. Execute applicable AFTER trigger programs. \n#\ndrop_all_tables\ndo_test e_fkey-51.1 {\n  proc maxparent {args} { db one {SELECT max(x) FROM parent} }\n  db func maxparent maxparent\n\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n\n    CREATE TRIGGER bu BEFORE UPDATE ON parent BEGIN\n      INSERT INTO parent VALUES(new.x-old.x);\n    END;\n    CREATE TABLE child(\n      a DEFAULT (maxparent()) REFERENCES parent ON UPDATE SET DEFAULT\n    );\n    CREATE TRIGGER au AFTER UPDATE ON parent BEGIN\n      INSERT INTO parent VALUES(new.x+old.x);\n    END;\n\n    INSERT INTO parent VALUES(1);\n    INSERT INTO child VALUES(1);\n  }\n} {}\ndo_test e_fkey-51.2 {\n  execsql {\n    UPDATE parent SET x = 22;\n    SELECT * FROM parent ORDER BY rowid; SELECT 'xxx' ; SELECT a FROM child;\n  }\n} {22 21 23 xxx 22}\ndo_test e_fkey-51.3 {\n  execsql {\n    DELETE FROM child;\n    DELETE FROM parent;\n    INSERT INTO parent VALUES(-1);\n    INSERT INTO child VALUES(-1);\n    UPDATE parent SET x = 22;\n    SELECT * FROM parent ORDER BY rowid; SELECT 'xxx' ; SELECT a FROM child;\n  }\n} {22 23 21 xxx 23}\n\n\n#-------------------------------------------------------------------------\n# Verify that ON UPDATE actions only actually take place if the parent key\n# is set to a new value that is distinct from the old value. The default\n# collation sequence and affinity are used to determine if the new value\n# is 'distinct' from the old or not.\n#\n# EVIDENCE-OF: R-27383-10246 An ON UPDATE action is only taken if the\n# values of the parent key are modified so that the new parent key\n# values are not equal to the old.\n#\ndrop_all_tables\ndo_test e_fkey-52.1 {\n  execsql {\n    CREATE TABLE zeus(a INTEGER COLLATE NOCASE, b, PRIMARY KEY(a, b));\n    CREATE TABLE apollo(c, d, \n      FOREIGN KEY(c, d) REFERENCES zeus ON UPDATE CASCADE\n    );\n    INSERT INTO zeus VALUES('abc', 'xyz');\n    INSERT INTO apollo VALUES('ABC', 'xyz');\n  }\n  execsql {\n    UPDATE zeus SET a = 'aBc';\n    SELECT * FROM apollo;\n  }\n} {ABC xyz}\ndo_test e_fkey-52.2 {\n  execsql {\n    UPDATE zeus SET a = 1, b = 1;\n    SELECT * FROM apollo;\n  }\n} {1 1}\ndo_test e_fkey-52.3 {\n  execsql {\n    UPDATE zeus SET a = 1, b = 1;\n    SELECT typeof(c), c, typeof(d), d FROM apollo;\n  }\n} {integer 1 integer 1}\ndo_test e_fkey-52.4 {\n  execsql {\n    UPDATE zeus SET a = '1';\n    SELECT typeof(c), c, typeof(d), d FROM apollo;\n  }\n} {integer 1 integer 1}\ndo_test e_fkey-52.5 {\n  execsql {\n    UPDATE zeus SET b = '1';\n    SELECT typeof(c), c, typeof(d), d FROM apollo;\n  }\n} {integer 1 text 1}\ndo_test e_fkey-52.6 {\n  execsql {\n    UPDATE zeus SET b = NULL;\n    SELECT typeof(c), c, typeof(d), d FROM apollo;\n  }\n} {integer 1 null {}}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-35129-58141\n#\n# Test an example from the \"ON DELETE and ON UPDATE Actions\" section \n# of foreignkeys.html. This example demonstrates that ON UPDATE actions\n# only take place if at least one parent key column is set to a value \n# that is distinct from its previous value.\n#\ndrop_all_tables\ndo_test e_fkey-53.1 {\n  execsql {\n    CREATE TABLE parent(x PRIMARY KEY);\n    CREATE TABLE child(y REFERENCES parent ON UPDATE SET NULL);\n    INSERT INTO parent VALUES('key');\n    INSERT INTO child VALUES('key');\n  }\n} {}\ndo_test e_fkey-53.2 {\n  execsql {\n    UPDATE parent SET x = 'key';\n    SELECT IFNULL(y, 'null') FROM child;\n  }\n} {key}\ndo_test e_fkey-53.3 {\n  execsql {\n    UPDATE parent SET x = 'key2';\n    SELECT IFNULL(y, 'null') FROM child;\n  }\n} {null}\n\n###########################################################################\n### SECTION 5: CREATE, ALTER and DROP TABLE commands\n###########################################################################\n\n#-------------------------------------------------------------------------\n# Test that parent keys are not checked when tables are created.\n#\n# EVIDENCE-OF: R-36018-21755 The parent key definitions of foreign key\n# constraints are not checked when a table is created.\n#\n# EVIDENCE-OF: R-25384-39337 There is nothing stopping the user from\n# creating a foreign key definition that refers to a parent table that\n# does not exist, or to parent key columns that do not exist or are not\n# collectively bound by a PRIMARY KEY or UNIQUE constraint.\n#\n# Child keys are checked to ensure all component columns exist. If parent\n# key columns are explicitly specified, SQLite checks to make sure there\n# are the same number of columns in the child and parent keys. (TODO: This\n# is tested but does not correspond to any testable statement.)\n#\n# Also test that the above statements are true regardless of whether or not\n# foreign keys are enabled:  \"A CREATE TABLE command operates the same whether\n# or not foreign key constraints are enabled.\"\n#\n# EVIDENCE-OF: R-08908-23439 A CREATE TABLE command operates the same\n# whether or not foreign key constraints are enabled.\n# \nforeach {tn zCreateTbl lRes} {\n  1 \"CREATE TABLE t1(a, b REFERENCES t1)\"                            {0 {}}\n  2 \"CREATE TABLE t1(a, b REFERENCES t2)\"                            {0 {}}\n  3 \"CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t1)\"          {0 {}}\n  4 \"CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2)\"          {0 {}}\n  5 \"CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2)\"          {0 {}}\n  6 \"CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t2(n,d))\"     {0 {}}\n  7 \"CREATE TABLE t1(a, b, FOREIGN KEY(a,b) REFERENCES t1(a,b))\"     {0 {}}\n\n  A \"CREATE TABLE t1(a, b, FOREIGN KEY(c,b) REFERENCES t2)\"          \n     {1 {unknown column \"c\" in foreign key definition}}\n  B \"CREATE TABLE t1(a, b, FOREIGN KEY(c,b) REFERENCES t2(d))\"          \n     {1 {number of columns in foreign key does not match the number of columns in the referenced table}}\n} {\n  do_test e_fkey-54.$tn.off {\n    drop_all_tables\n    execsql {PRAGMA foreign_keys = OFF}\n    catchsql $zCreateTbl\n  } $lRes\n  do_test e_fkey-54.$tn.on {\n    drop_all_tables\n    execsql {PRAGMA foreign_keys = ON}\n    catchsql $zCreateTbl\n  } $lRes\n}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-47952-62498 It is not possible to use the \"ALTER TABLE\n# ... ADD COLUMN\" syntax to add a column that includes a REFERENCES\n# clause, unless the default value of the new column is NULL. Attempting\n# to do so returns an error.\n#\nproc test_efkey_6 {tn zAlter isError} {\n  drop_all_tables \n\n  do_test e_fkey-56.$tn.1 \"\n    execsql { CREATE TABLE tbl(a, b) }\n    [list catchsql $zAlter]\n  \" [lindex {{0 {}} {1 {Cannot add a REFERENCES column with non-NULL default value}}} $isError]\n\n}\n\ntest_efkey_6 1 \"ALTER TABLE tbl ADD COLUMN c REFERENCES xx\" 0\ntest_efkey_6 2 \"ALTER TABLE tbl ADD COLUMN c DEFAULT NULL REFERENCES xx\" 0\ntest_efkey_6 3 \"ALTER TABLE tbl ADD COLUMN c DEFAULT 0 REFERENCES xx\" 1\n\n#-------------------------------------------------------------------------\n# Test that ALTER TABLE adjusts REFERENCES clauses when the parent table\n# is RENAMED.\n#\n# EVIDENCE-OF: R-47080-02069 If an \"ALTER TABLE ... RENAME TO\" command\n# is used to rename a table that is the parent table of one or more\n# foreign key constraints, the definitions of the foreign key\n# constraints are modified to refer to the parent table by its new name\n#\n# Test that these adjustments are visible in the sqlite_master table.\n#\n# EVIDENCE-OF: R-63827-54774 The text of the child CREATE TABLE\n# statement or statements stored in the sqlite_master table are modified\n# to reflect the new parent table name.\n#\ndo_test e_fkey-56.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE 'p 1 \"parent one\"'(a REFERENCES 'p 1 \"parent one\"', b, PRIMARY KEY(b));\n\n    CREATE TABLE c1(c, d REFERENCES 'p 1 \"parent one\"' ON UPDATE CASCADE);\n    CREATE TABLE c2(e, f, FOREIGN KEY(f) REFERENCES 'p 1 \"parent one\"' ON UPDATE CASCADE);\n    CREATE TABLE c3(e, 'f col 2', FOREIGN KEY('f col 2') REFERENCES 'p 1 \"parent one\"' ON UPDATE CASCADE);\n\n    INSERT INTO 'p 1 \"parent one\"' VALUES(1, 1);\n    INSERT INTO c1 VALUES(1, 1);\n    INSERT INTO c2 VALUES(1, 1);\n    INSERT INTO c3 VALUES(1, 1);\n\n    -- CREATE TABLE q(a, b, PRIMARY KEY(b));\n  }\n} {}\ndo_test e_fkey-56.2 {\n  execsql { ALTER TABLE 'p 1 \"parent one\"' RENAME TO p }\n} {}\ndo_test e_fkey-56.3 {\n  execsql {\n    UPDATE p SET a = 'xxx', b = 'xxx';\n    SELECT * FROM p;\n    SELECT * FROM c1;\n    SELECT * FROM c2;\n    SELECT * FROM c3;\n  }\n} {xxx xxx 1 xxx 1 xxx 1 xxx}\ndo_test e_fkey-56.4 {\n  execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}\n} [list                                                                     \\\n  {CREATE TABLE \"p\"(a REFERENCES \"p\", b, PRIMARY KEY(b))}                   \\\n  {CREATE TABLE c1(c, d REFERENCES \"p\" ON UPDATE CASCADE)}                  \\\n  {CREATE TABLE c2(e, f, FOREIGN KEY(f) REFERENCES \"p\" ON UPDATE CASCADE)}  \\\n  {CREATE TABLE c3(e, 'f col 2', FOREIGN KEY('f col 2') REFERENCES \"p\" ON UPDATE CASCADE)} \\\n]\n\n#-------------------------------------------------------------------------\n# Check that a DROP TABLE does an implicit DELETE FROM. Which does not\n# cause any triggers to fire, but does fire foreign key actions.\n#\n# EVIDENCE-OF: R-14208-23986 If foreign key constraints are enabled when\n# it is prepared, the DROP TABLE command performs an implicit DELETE to\n# remove all rows from the table before dropping it.\n#\n# EVIDENCE-OF: R-11078-03945 The implicit DELETE does not cause any SQL\n# triggers to fire, but may invoke foreign key actions or constraint\n# violations.\n#\ndo_test e_fkey-57.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE p(a, b, PRIMARY KEY(a, b));\n\n    CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE SET NULL);\n    CREATE TABLE c2(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE SET DEFAULT);\n    CREATE TABLE c3(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE CASCADE);\n    CREATE TABLE c4(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE RESTRICT);\n    CREATE TABLE c5(c, d, FOREIGN KEY(c, d) REFERENCES p ON DELETE NO ACTION);\n\n    CREATE TABLE c6(c, d, \n      FOREIGN KEY(c, d) REFERENCES p ON DELETE RESTRICT \n      DEFERRABLE INITIALLY DEFERRED\n    );\n    CREATE TABLE c7(c, d, \n      FOREIGN KEY(c, d) REFERENCES p ON DELETE NO ACTION\n      DEFERRABLE INITIALLY DEFERRED\n    );\n\n    CREATE TABLE log(msg);\n    CREATE TRIGGER tt AFTER DELETE ON p BEGIN\n      INSERT INTO log VALUES('delete ' || old.rowid);\n    END;\n  }\n} {}\n\ndo_test e_fkey-57.2 {\n  execsql {\n    INSERT INTO p VALUES('a', 'b');\n    INSERT INTO c1 VALUES('a', 'b');\n    INSERT INTO c2 VALUES('a', 'b');\n    INSERT INTO c3 VALUES('a', 'b');\n    BEGIN;\n      DROP TABLE p;\n      SELECT * FROM c1;\n  }\n} {{} {}}\ndo_test e_fkey-57.3 {\n  execsql { SELECT * FROM c2 }\n} {{} {}}\ndo_test e_fkey-57.4 {\n  execsql { SELECT * FROM c3 }\n} {}\ndo_test e_fkey-57.5 {\n  execsql { SELECT * FROM log }\n} {}\ndo_test e_fkey-57.6 {\n  execsql ROLLBACK\n} {}\ndo_test e_fkey-57.7 {\n  execsql {\n    BEGIN;\n      DELETE FROM p;\n      SELECT * FROM log;\n    ROLLBACK;\n  }\n} {{delete 1}}\n\n#-------------------------------------------------------------------------\n# If an IMMEDIATE foreign key fails as a result of a DROP TABLE, the\n# DROP TABLE command fails.\n#\n# EVIDENCE-OF: R-32768-47925 If an immediate foreign key constraint is\n# violated, the DROP TABLE statement fails and the table is not dropped.\n#\ndo_test e_fkey-58.1 {\n  execsql { \n    DELETE FROM c1;\n    DELETE FROM c2;\n    DELETE FROM c3;\n  }\n  execsql { INSERT INTO c5 VALUES('a', 'b') }\n  catchsql { DROP TABLE p }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-58.2 {\n  execsql { SELECT * FROM p }\n} {a b}\ndo_test e_fkey-58.3 {\n  catchsql {\n    BEGIN;\n      DROP TABLE p;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-58.4 {\n  execsql {\n    SELECT * FROM p;\n    SELECT * FROM c5;\n    ROLLBACK;\n  }\n} {a b a b}\n\n#-------------------------------------------------------------------------\n# If a DEFERRED foreign key fails as a result of a DROP TABLE, attempting\n# to commit the transaction fails unless the violation is fixed.\n#\n# EVIDENCE-OF: R-05903-08460 If a deferred foreign key constraint is\n# violated, then an error is reported when the user attempts to commit\n# the transaction if the foreign key constraint violations still exist\n# at that point.\n#\ndo_test e_fkey-59.1 {\n  execsql { \n    DELETE FROM c1 ; DELETE FROM c2 ; DELETE FROM c3 ;\n    DELETE FROM c4 ; DELETE FROM c5 ; DELETE FROM c6 ;\n    DELETE FROM c7 \n  }\n} {}\ndo_test e_fkey-59.2 {\n  execsql { INSERT INTO c7 VALUES('a', 'b') }\n  execsql {\n    BEGIN;\n      DROP TABLE p;\n  }\n} {}\ndo_test e_fkey-59.3 {\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-59.4 {\n  execsql { CREATE TABLE p(a, b, PRIMARY KEY(a, b)) }\n  catchsql COMMIT\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-59.5 {\n  execsql { INSERT INTO p VALUES('a', 'b') }\n  execsql COMMIT\n} {}\n\n#-------------------------------------------------------------------------\n# Any \"foreign key mismatch\" errors encountered while running an implicit\n# \"DELETE FROM tbl\" are ignored.\n#\n# EVIDENCE-OF: R-57242-37005 Any \"foreign key mismatch\" errors\n# encountered as part of an implicit DELETE are ignored.\n#\ndrop_all_tables\ndo_test e_fkey-60.1 {\n  execsql {\n    PRAGMA foreign_keys = OFF;\n\n    CREATE TABLE p(a PRIMARY KEY, b REFERENCES nosuchtable);\n    CREATE TABLE c1(c, d, FOREIGN KEY(c, d) REFERENCES a);\n    CREATE TABLE c2(c REFERENCES p(b), d);\n    CREATE TABLE c3(c REFERENCES p ON DELETE SET NULL, d);\n\n    INSERT INTO p VALUES(1, 2);\n    INSERT INTO c1 VALUES(1, 2);\n    INSERT INTO c2 VALUES(1, 2);\n    INSERT INTO c3 VALUES(1, 2);\n  }\n} {}\ndo_test e_fkey-60.2 {\n  execsql { PRAGMA foreign_keys = ON }\n  catchsql { DELETE FROM p }\n} {1 {no such table: main.nosuchtable}}\ndo_test e_fkey-60.3 {\n  execsql {\n    BEGIN;\n      DROP TABLE p;\n      SELECT * FROM c3;\n    ROLLBACK;\n  }\n} {{} 2}\ndo_test e_fkey-60.4 {\n  execsql { CREATE TABLE nosuchtable(x PRIMARY KEY) }\n  catchsql { DELETE FROM p }\n} {1 {foreign key mismatch - \"c2\" referencing \"p\"}}\ndo_test e_fkey-60.5 {\n  execsql { DROP TABLE c1 }\n  catchsql { DELETE FROM p }\n} {1 {foreign key mismatch - \"c2\" referencing \"p\"}}\ndo_test e_fkey-60.6 {\n  execsql { DROP TABLE c2 }\n  execsql { DELETE FROM p }\n} {}\n\n#-------------------------------------------------------------------------\n# Test that the special behaviors of ALTER and DROP TABLE are only\n# activated when foreign keys are enabled. Special behaviors are:\n#\n#   1. ADD COLUMN not allowing a REFERENCES clause with a non-NULL \n#      default value.\n#   2. Modifying foreign key definitions when a parent table is RENAMEd.\n#   3. Running an implicit DELETE FROM command as part of DROP TABLE.\n#\n# EVIDENCE-OF: R-54142-41346 The properties of the DROP TABLE and ALTER\n# TABLE commands described above only apply if foreign keys are enabled.\n#\ndo_test e_fkey-61.1.1 {\n  drop_all_tables\n  execsql { CREATE TABLE t1(a, b) }\n  catchsql { ALTER TABLE t1 ADD COLUMN c DEFAULT 'xxx' REFERENCES t2 }\n} {1 {Cannot add a REFERENCES column with non-NULL default value}}\ndo_test e_fkey-61.1.2 {\n  execsql { PRAGMA foreign_keys = OFF }\n  execsql { ALTER TABLE t1 ADD COLUMN c DEFAULT 'xxx' REFERENCES t2 }\n  execsql { SELECT sql FROM sqlite_master WHERE name = 't1' }\n} {{CREATE TABLE t1(a, b, c DEFAULT 'xxx' REFERENCES t2)}}\ndo_test e_fkey-61.1.3 {\n  execsql { PRAGMA foreign_keys = ON }\n} {}\n\ndo_test e_fkey-61.2.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE p(a UNIQUE);\n    CREATE TABLE c(b REFERENCES p(a));\n    BEGIN;\n      ALTER TABLE p RENAME TO parent;\n      SELECT sql FROM sqlite_master WHERE name = 'c';\n    ROLLBACK;\n  }\n} {{CREATE TABLE c(b REFERENCES \"parent\"(a))}}\ndo_test e_fkey-61.2.2 {\n  execsql {\n    PRAGMA foreign_keys = OFF;\n    ALTER TABLE p RENAME TO parent;\n    SELECT sql FROM sqlite_master WHERE name = 'c';\n  }\n} {{CREATE TABLE c(b REFERENCES p(a))}}\ndo_test e_fkey-61.2.3 {\n  execsql { PRAGMA foreign_keys = ON }\n} {}\n\ndo_test e_fkey-61.3.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE p(a UNIQUE);\n    CREATE TABLE c(b REFERENCES p(a) ON DELETE SET NULL);\n    INSERT INTO p VALUES('x');\n    INSERT INTO c VALUES('x');\n    BEGIN;\n      DROP TABLE p;\n      SELECT * FROM c;\n    ROLLBACK;\n  }\n} {{}}\ndo_test e_fkey-61.3.2 {\n  execsql {\n    PRAGMA foreign_keys = OFF;\n    DROP TABLE p;\n    SELECT * FROM c;\n  }\n} {x}\ndo_test e_fkey-61.3.3 {\n  execsql { PRAGMA foreign_keys = ON }\n} {}\n\n###########################################################################\n### SECTION 6: Limits and Unsupported Features\n###########################################################################\n\n#-------------------------------------------------------------------------\n# Test that MATCH clauses are parsed, but SQLite treats every foreign key\n# constraint as if it were \"MATCH SIMPLE\".\n#\n# EVIDENCE-OF: R-24728-13230 SQLite parses MATCH clauses (i.e. does not\n# report a syntax error if you specify one), but does not enforce them.\n#\n# EVIDENCE-OF: R-24450-46174 All foreign key constraints in SQLite are\n# handled as if MATCH SIMPLE were specified.\n#\nforeach zMatch [list SIMPLE PARTIAL FULL Simple parTIAL FuLL ] {\n  drop_all_tables\n  do_test e_fkey-62.$zMatch.1 {\n    execsql \"\n      CREATE TABLE p(a, b, c, PRIMARY KEY(b, c));\n      CREATE TABLE c(d, e, f, FOREIGN KEY(e, f) REFERENCES p MATCH $zMatch);\n    \"\n  } {}\n  do_test e_fkey-62.$zMatch.2 {\n    execsql { INSERT INTO p VALUES(1, 2, 3)         }\n\n    # MATCH SIMPLE behavior: Allow any child key that contains one or more\n    # NULL value to be inserted. Non-NULL values do not have to map to any\n    # parent key values, so long as at least one field of the child key is\n    # NULL.\n    execsql { INSERT INTO c VALUES('w', 2, 3)       }\n    execsql { INSERT INTO c VALUES('x', 'x', NULL)  }\n    execsql { INSERT INTO c VALUES('y', NULL, 'x')  }\n    execsql { INSERT INTO c VALUES('z', NULL, NULL) }\n\n    # Check that the FK is enforced properly if there are no NULL values \n    # in the child key columns.\n    catchsql { INSERT INTO c VALUES('a', 2, 4) }\n  } {1 {FOREIGN KEY constraint failed}}\n}\n\n#-------------------------------------------------------------------------\n# Test that SQLite does not support the SET CONSTRAINT statement. And\n# that it is possible to create both immediate and deferred constraints.\n#\n# EVIDENCE-OF: R-21599-16038 In SQLite, a foreign key constraint is\n# permanently marked as deferred or immediate when it is created.\n#\ndrop_all_tables\ndo_test e_fkey-62.1 {\n  catchsql { SET CONSTRAINTS ALL IMMEDIATE }\n} {1 {near \"SET\": syntax error}}\ndo_test e_fkey-62.2 {\n  catchsql { SET CONSTRAINTS ALL DEFERRED }\n} {1 {near \"SET\": syntax error}}\n\ndo_test e_fkey-62.3 {\n  execsql {\n    CREATE TABLE p(a, b, PRIMARY KEY(a, b));\n    CREATE TABLE cd(c, d, \n      FOREIGN KEY(c, d) REFERENCES p DEFERRABLE INITIALLY DEFERRED);\n    CREATE TABLE ci(c, d, \n      FOREIGN KEY(c, d) REFERENCES p DEFERRABLE INITIALLY IMMEDIATE);\n    BEGIN;\n  }\n} {}\ndo_test e_fkey-62.4 {\n  catchsql { INSERT INTO ci VALUES('x', 'y') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-62.5 {\n  catchsql { INSERT INTO cd VALUES('x', 'y') }\n} {0 {}}\ndo_test e_fkey-62.6 {\n  catchsql { COMMIT }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test e_fkey-62.7 {\n  execsql { \n    DELETE FROM cd;\n    COMMIT;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test that the maximum recursion depth of foreign key action programs is\n# governed by the SQLITE_MAX_TRIGGER_DEPTH and SQLITE_LIMIT_TRIGGER_DEPTH\n# settings.\n#\n# EVIDENCE-OF: R-42264-30503 The SQLITE_MAX_TRIGGER_DEPTH and\n# SQLITE_LIMIT_TRIGGER_DEPTH settings determine the maximum allowable\n# depth of trigger program recursion. For the purposes of these limits,\n# foreign key actions are considered trigger programs.\n#\nproc test_on_delete_recursion {limit} {\n  drop_all_tables\n  execsql { \n    BEGIN;\n    CREATE TABLE t0(a PRIMARY KEY, b);\n    INSERT INTO t0 VALUES('x0', NULL);\n  }\n  for {set i 1} {$i <= $limit} {incr i} {\n    execsql \"\n      CREATE TABLE t$i (\n        a PRIMARY KEY, b REFERENCES t[expr $i-1] ON DELETE CASCADE\n      );\n      INSERT INTO t$i VALUES('x$i', 'x[expr $i-1]');\n    \"\n  }\n  execsql COMMIT\n  catchsql \"\n    DELETE FROM t0;\n    SELECT count(*) FROM t$limit;\n  \"\n}\nproc test_on_update_recursion {limit} {\n  drop_all_tables\n  execsql { \n    BEGIN;\n    CREATE TABLE t0(a PRIMARY KEY);\n    INSERT INTO t0 VALUES('xxx');\n  }\n  for {set i 1} {$i <= $limit} {incr i} {\n    set j [expr $i-1]\n\n    execsql \"\n      CREATE TABLE t$i (a PRIMARY KEY REFERENCES t$j ON UPDATE CASCADE);\n      INSERT INTO t$i VALUES('xxx');\n    \"\n  }\n  execsql COMMIT\n  catchsql \"\n    UPDATE t0 SET a = 'yyy';\n    SELECT NOT (a='yyy') FROM t$limit;\n  \"\n}\n\n# If the current build was created using clang with the -fsanitize=address\n# switch, then the library uses considerably more stack space than usual.\n# So much more, that some of the following tests cause stack overflows\n# if they are run under this configuration.\n#\nif {[clang_sanitize_address]==0} {\n  do_test e_fkey-63.1.1 {\n    test_on_delete_recursion $SQLITE_MAX_TRIGGER_DEPTH\n  } {0 0}\n  do_test e_fkey-63.1.2 {\n    test_on_delete_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]\n  } {1 {too many levels of trigger recursion}}\n  do_test e_fkey-63.1.3 {\n    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5\n      test_on_delete_recursion 5\n  } {0 0}\n  do_test e_fkey-63.1.4 {\n    test_on_delete_recursion 6\n  } {1 {too many levels of trigger recursion}}\n  do_test e_fkey-63.1.5 {\n    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000\n  } {5}\n  do_test e_fkey-63.2.1 {\n    test_on_update_recursion $SQLITE_MAX_TRIGGER_DEPTH\n  } {0 0}\n  do_test e_fkey-63.2.2 {\n    test_on_update_recursion [expr $SQLITE_MAX_TRIGGER_DEPTH+1]\n  } {1 {too many levels of trigger recursion}}\n  do_test e_fkey-63.2.3 {\n    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 5\n      test_on_update_recursion 5\n  } {0 0}\n  do_test e_fkey-63.2.4 {\n    test_on_update_recursion 6\n  } {1 {too many levels of trigger recursion}}\n  do_test e_fkey-63.2.5 {\n    sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1000000\n  } {5}\n}\n\n#-------------------------------------------------------------------------\n# The setting of the recursive_triggers pragma does not affect foreign\n# key actions.\n#\n# EVIDENCE-OF: R-44355-00270 The PRAGMA recursive_triggers setting does\n# not affect the operation of foreign key actions.\n#\nforeach recursive_triggers_setting [list 0 1 ON OFF] {\n  drop_all_tables\n  execsql \"PRAGMA recursive_triggers = $recursive_triggers_setting\"\n\n  do_test e_fkey-64.$recursive_triggers_setting.1 {\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1 ON DELETE CASCADE);\n      INSERT INTO t1 VALUES(1, NULL);\n      INSERT INTO t1 VALUES(2, 1);\n      INSERT INTO t1 VALUES(3, 2);\n      INSERT INTO t1 VALUES(4, 3);\n      INSERT INTO t1 VALUES(5, 4);\n      SELECT count(*) FROM t1;\n    }\n  } {5}\n  do_test e_fkey-64.$recursive_triggers_setting.2 {\n    execsql { SELECT count(*) FROM t1 WHERE a = 1 }\n  } {1}\n  do_test e_fkey-64.$recursive_triggers_setting.3 {\n    execsql { \n      DELETE FROM t1 WHERE a = 1;\n      SELECT count(*) FROM t1;\n    }\n  } {0}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_fts3.test",
    "content": "# 2009 November 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify the \"testable statements\" in the\n# fts3.in document.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build does not include FTS3, skip the tests in this file.\n#\nifcapable !fts3 { finish_test ; return }\nsource $testdir/fts3_common.tcl\nsource $testdir/malloc_common.tcl\n\n# Procs used to make the tests in this file easier to read.\n#\nproc ddl_test {tn ddl} {\n  uplevel [list do_write_test e_fts3-$tn sqlite_master $ddl]\n}\nproc write_test {tn tbl sql} {\n  uplevel [list do_write_test e_fts3-$tn $tbl $sql]\n}\nproc read_test {tn sql result} {\n  uplevel [list do_select_test e_fts3-$tn $sql $result]\n}\nproc error_test {tn sql result} {\n  uplevel [list do_error_test e_fts3-$tn $sql $result]\n}\n\n\n#-------------------------------------------------------------------------\n# The body of the following [foreach] block contains test cases to verify\n# that the example code in fts3.html works as expected. The tests run three\n# times, with different values for DO_MALLOC_TEST.\n# \n#   DO_MALLOC_TEST=0: Run tests with no OOM errors.\n#   DO_MALLOC_TEST=1: Run tests with transient OOM errors.\n#   DO_MALLOC_TEST=2: Run tests with persistent OOM errors.\n#\nforeach {DO_MALLOC_TEST enc} {\n  0 utf-8\n  1 utf-8\n  2 utf-8\n  1 utf-16\n} {\n\n#if {$DO_MALLOC_TEST} break\n\n# Reset the database and database connection. If this iteration of the \n# [foreach] loop is testing with OOM errors, disable the lookaside buffer.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\nif {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }\ndb eval \"PRAGMA encoding = '$enc'\"\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\n##########################################################################\n# Test the example CREATE VIRTUAL TABLE statements in section 1.1 \n# of fts3.in.\n#\nddl_test   1.1.1.1 {CREATE VIRTUAL TABLE data USING fts3()}\nread_test  1.1.1.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}\n\nddl_test   1.1.2.1 {\n  CREATE VIRTUAL TABLE pages USING fts3(title, keywords, body)\n}\nread_test  1.1.2.2 {\n  PRAGMA table_info(pages)\n} {0 title {} 0 {} 0 1 keywords {} 0 {} 0 2 body {} 0 {} 0}\n\nddl_test   1.1.3.1 {\n  CREATE VIRTUAL TABLE mail USING fts3(\n      subject VARCHAR(256) NOT NULL,\n      body TEXT CHECK(length(body)<10240)\n  )\n}\nread_test  1.1.3.2 {\n  PRAGMA table_info(mail)\n} {0 subject {} 0 {} 0 1 body {} 0 {} 0}\n\n# A very large string. Used to test if the constraint on column \"body\" of\n# table \"mail\" is enforced (it should not be - FTS3 tables do not support\n# constraints).\nset largetext [string repeat \"the quick brown fox \" 5000]\nwrite_test 1.1.3.3 mail_content { INSERT INTO mail VALUES(NULL, $largetext) }\nread_test  1.1.3.4 {\n  SELECT subject IS NULL, length(body) FROM mail\n} [list 1 100000]\n\nddl_test   1.1.4.1 {\n  CREATE VIRTUAL TABLE papers USING fts3(author, document, tokenize=porter)\n}\nread_test  1.1.4.2 {\n  PRAGMA table_info(papers)\n} {0 author {} 0 {} 0 1 document {} 0 {} 0}\n\nddl_test   1.1.5.1 {\n  CREATE VIRTUAL TABLE simpledata USING fts3(tokenize=simple)\n}\nread_test  1.1.5.2 {\n  PRAGMA table_info(simpledata)\n} {0 content {} 0 {} 0}\n\nifcapable icu {\n  ddl_test 1.1.6.1 {\n    CREATE VIRTUAL TABLE names USING fts3(a, b, tokenize=icu en_AU)\n  }\n  read_test  1.1.6.2 {\n    PRAGMA table_info(names)\n  } {0 a {} 0 {} 0 1 b {} 0 {} 0}\n}\n\nddl_test   1.1.7.1 {DROP TABLE data}\nddl_test   1.1.7.2 {DROP TABLE pages}\nddl_test   1.1.7.3 {DROP TABLE mail}\nddl_test   1.1.7.4 {DROP TABLE papers}\nddl_test   1.1.7.5 {DROP TABLE simpledata}\nread_test  1.1.7.6 {SELECT * FROM sqlite_master} {}\n\n# The following is not one of the examples in section 1.1. It tests \n# specifying an FTS3 table with no module arguments using a slightly\n# different syntax.\nddl_test   1.1.8.1 {CREATE VIRTUAL TABLE data USING fts3;}\nread_test  1.1.8.2 {PRAGMA table_info(data)} {0 content {} 0 {} 0}\nddl_test   1.1.8.3 {DROP TABLE data}\n\n##########################################################################\n# Test the examples in section 1.2 (populating fts3 tables)\n#\nddl_test   1.2.1.1 {\n  CREATE VIRTUAL TABLE pages USING fts3(title, body);\n}\nwrite_test 1.2.1.2 pages_content {\n  INSERT INTO pages(docid, title, body) \n  VALUES(53, 'Home Page', 'SQLite is a software...');\n}\nread_test  1.2.1.3 {\n  SELECT docid, * FROM pages\n} {53 {Home Page} {SQLite is a software...}}\n\nwrite_test 1.2.1.4 pages_content {\n  INSERT INTO pages(title, body) \n  VALUES('Download', 'All SQLite source code...');\n}\nread_test  1.2.1.5 {\n  SELECT docid, * FROM pages\n} {53 {Home Page} {SQLite is a software...} 54 Download {All SQLite source code...}}\n\nwrite_test 1.2.1.6 pages_content {\n  UPDATE pages SET title = 'Download SQLite' WHERE rowid = 54\n}\nread_test  1.2.1.7 {\n  SELECT docid, * FROM pages\n} {53 {Home Page} {SQLite is a software...} 54 {Download SQLite} {All SQLite source code...}}\n\nwrite_test 1.2.1.8 pages_content { DELETE FROM pages }\nread_test  1.2.1.9 { SELECT docid, * FROM pages } {}\n\ndo_error_test fts3-1.2.1.10 {\n  INSERT INTO pages(rowid, docid, title, body) VALUES(1, 2, 'A title', 'A document body');\n} {SQL logic error}\n\n# Test the optimize() function example:\nddl_test   1.2.2.1 { CREATE VIRTUAL TABLE docs USING fts3 }\nwrite_test 1.2.2.2 docs_content {\n  INSERT INTO docs VALUES('Others translate the first clause as');\n}\nwrite_test 1.2.2.3 docs_content {\n  INSERT INTO docs VALUES('\"which is for Solomon,\" meaning that');\n}\nwrite_test 1.2.2.4 docs_content {\n  INSERT INTO docs VALUES('the book is dedicated to Solomon.');\n}\nread_test  1.2.2.5 { SELECT count(*) FROM docs_segdir } {3}\nwrite_test 1.2.2.6 docs_segdir {\n  INSERT INTO docs(docs) VALUES('optimize');\n}\nread_test  1.2.2.7 { SELECT count(*) FROM docs_segdir } {1}\nddl_test   1.2.2.8 { DROP TABLE docs }\n\n##########################################################################\n# Test the examples in section 1.3 (querying FTS3 tables)\n#\nddl_test   1.3.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }\nread_test  1.3.1.2 { \n  SELECT * FROM mail WHERE rowid = 15;                -- Fast. Rowid lookup.\n  SELECT * FROM mail WHERE body MATCH 'sqlite';       -- Fast. Full-text query.\n  SELECT * FROM mail WHERE mail MATCH 'search';       -- Fast. Full-text query.\n  SELECT * FROM mail WHERE rowid BETWEEN 15 AND 20;   -- Slow. Linear scan.\n  SELECT * FROM mail WHERE subject = 'database';      -- Slow. Linear scan.\n  SELECT * FROM mail WHERE subject MATCH 'database';  -- Fast. Full-text query.\n} {}\nddl_test   1.3.1.3 { DROP TABLE mail }\n\nddl_test   1.3.2.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }\n\nwrite_test 1.3.2.2 mail_content {\n  INSERT INTO mail(docid, subject, body) \n  VALUES(1, 'software feedback', 'found it too slow')\n}\nwrite_test 1.3.2.3 mail_content {\n  INSERT INTO mail(docid, subject, body) \n  VALUES(2, 'software feedback', 'no feedback')\n}\nwrite_test 1.3.2.4 mail_content {\n  INSERT INTO mail(docid, subject, body) \n  VALUES(3, 'slow lunch order',  'was a software problem')\n}\nread_test  1.3.2.5 {\n  SELECT * FROM mail WHERE subject MATCH 'software'\n} {{software feedback} {found it too slow} {software feedback} {no feedback}}\nread_test  1.3.2.6 {\n  SELECT * FROM mail WHERE body MATCH 'feedback'\n} {{software feedback} {no feedback}}\nread_test  1.3.2.7 {\n  SELECT * FROM mail WHERE mail MATCH 'software'\n} {{software feedback} {found it too slow} {software feedback} {no feedback} {slow lunch order} {was a software problem}}\nread_test  1.3.2.7 {\n  SELECT * FROM mail WHERE mail MATCH 'slow'\n} {{software feedback} {found it too slow} {slow lunch order} {was a software problem}}\nddl_test   1.3.2.8 { DROP TABLE mail }\n\nddl_test   1.3.3.1 { CREATE VIRTUAL TABLE docs USING fts3(content) }\nread_test  1.3.3.2 { SELECT * FROM docs WHERE docs MATCH 'sqlite' } {}\nread_test  1.3.3.3 { SELECT * FROM docs WHERE docs.docs MATCH 'sqlite' } {}\nread_test  1.3.3.4 { SELECT * FROM docs WHERE main.docs.docs MATCH 'sqlite' } {}\ndo_error_test e_fts3-1.3.3.5 { \n  SELECT * FROM docs WHERE main.docs MATCH 'sqlite' \n} {no such column: main.docs}\nddl_test   1.3.2.8 { DROP TABLE docs }\n\n##########################################################################\n# Test the examples in section 3 (full-text index queries).\n#\nddl_test   1.4.1.1 { CREATE VIRTUAL TABLE docs USING fts3(title, body) }\nunset -nocomplain R\nforeach {tn title body} {\n  2 \"linux driver\" \"a device\"\n  3 \"driver\"       \"linguistic trick\"\n  4 \"problems\"     \"linux problems\"\n  5 \"linux\"        \"big problems\"\n  6 \"linux driver\" \"a device driver problem\"\n  7 \"good times\"   \"applications for linux\"\n  8 \"not so good\"  \"linux applications\"\n  9 \"alternative\"  \"linoleum appliances\"\n 10 \"no L I N\"     \"to be seen\"\n} {\n  write_test 1.4.1.$tn docs_content { INSERT INTO docs VALUES($title,$body) }\n  set R($tn) [list $title $body]\n}\n\nread_test  1.4.1.11 { \n  SELECT * FROM docs WHERE docs MATCH 'linux'\n} [concat $R(2) $R(4) $R(5) $R(6) $R(7) $R(8)]\nread_test  1.4.1.12 { \n  SELECT * FROM docs WHERE docs MATCH 'lin*'\n} [concat $R(2) $R(3) $R(4) $R(5) $R(6) $R(7) $R(8) $R(9)]\nread_test  1.4.1.13 { \n  SELECT * FROM docs WHERE docs MATCH 'title:linux problems'\n} [concat $R(5)]\nread_test  1.4.1.14 { \n  SELECT * FROM docs WHERE body MATCH 'title:linux driver'\n} [concat $R(6)]\nread_test  1.4.1.15 { \n  SELECT * FROM docs WHERE docs MATCH '\"linux applications\"'\n} [concat $R(8)]\nread_test  1.4.1.16 { \n  SELECT * FROM docs WHERE docs MATCH '\"lin* app*\"'\n} [concat $R(8) $R(9)]\nddl_test   1.4.1.17 { DROP TABLE docs }\nunset R\n\nddl_test   1.4.2.1 { CREATE VIRTUAL TABLE docs USING fts3() }\nwrite_test 1.4.2.2 docs_content { \n  INSERT INTO docs VALUES(\n  'SQLite is an ACID compliant embedded relational database management system')\n}\nforeach {tn query hit} {\n3 {SELECT * FROM docs WHERE docs MATCH 'sqlite NEAR database'} 1\n4 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/6 sqlite'} 1\n5 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/5 sqlite'} 0\n6 {SELECT * FROM docs WHERE docs MATCH 'database NEAR/2 \"ACID compliant\"'} 1\n7 {SELECT * FROM docs WHERE docs MATCH '\"ACID compliant\" NEAR/2 sqlite'} 1\n8 {SELECT * FROM docs WHERE docs MATCH 'sqlite NEAR/2 acid NEAR/2 relational'} 1\n9 {SELECT * FROM docs WHERE docs MATCH 'acid NEAR/2 sqlite NEAR/2 relational'} 0\n} {\n  set res [db eval {SELECT * FROM docs WHERE $hit}]\n  read_test 1.4.2.$tn $query $res\n}\nddl_test 1.4.2.10 { DROP TABLE docs }\n\n##########################################################################\n# Test the example in section 3.1 (set operators with enhanced syntax).\n#\nset sqlite_fts3_enable_parentheses 1\nddl_test 1.5.1.1 { CREATE VIRTUAL TABLE docs USING fts3() }\nforeach {tn docid content} {\n  2 1 \"a database is a software system\"\n  3 2 \"sqlite is a software system\"\n  4 3 \"sqlite is a database\"\n} {\n  set R($docid) $content\n  write_test 1.5.1.$tn docs_content { \n    INSERT INTO docs(docid, content) VALUES($docid, $content)\n  }\n}\nread_test 1.5.1.4 {\n  SELECT * FROM docs WHERE docs MATCH 'sqlite AND database'\n} [list $R(3)]\nread_test 1.5.1.5 {\n  SELECT * FROM docs WHERE docs MATCH 'database sqlite'\n} [list $R(3)]\nread_test 1.5.1.6 {\n  SELECT * FROM docs WHERE docs MATCH 'sqlite OR database'\n} [list $R(1) $R(2) $R(3)]\nread_test 1.5.1.7 {\n  SELECT * FROM docs WHERE docs MATCH 'database NOT sqlite'\n} [list $R(1)]\nread_test 1.5.1.8 {\n  SELECT * FROM docs WHERE docs MATCH 'database and sqlite'\n} {}\n\nwrite_test 1.5.2.1 docs_content {\n  INSERT INTO docs \n    SELECT 'sqlite is also a library' UNION ALL\n    SELECT 'library software'\n}\nread_test 1.5.2.2 {\n  SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database OR library'\n} {3 4 5}\nread_test 1.5.2.3 {\n  SELECT docid FROM docs WHERE docs MATCH 'sqlite AND database'\n    UNION\n  SELECT docid FROM docs WHERE docs MATCH 'library'\n} {3 4 5}\nwrite_test 1.5.2.4 docs_content {\n  INSERT INTO docs \n    SELECT 'the sqlite library runs on linux' UNION ALL\n    SELECT 'as does the sqlite database (on linux)' UNION ALL\n    SELECT 'the sqlite database is accessed by the sqlite library'\n}\nread_test 1.5.2.2 {\n  SELECT docid FROM docs \n  WHERE docs MATCH '(\"sqlite database\" OR \"sqlite library\") AND linux';\n} {6 7}\nread_test 1.5.2.3 {\n  SELECT docid FROM docs WHERE docs MATCH 'linux'\n    INTERSECT\n  SELECT docid FROM (\n    SELECT docid FROM docs WHERE docs MATCH '\"sqlite library\"'\n      UNION\n    SELECT docid FROM docs WHERE docs MATCH '\"sqlite database\"'\n  );\n} {6 7}\n\n##########################################################################\n# Test the examples in section 3.2 (set operators with standard syntax).\n# These tests reuse the table populated by the block above.\n#\nset sqlite_fts3_enable_parentheses 0\nread_test 1.6.1.1 {\n  SELECT * FROM docs WHERE docs MATCH 'sqlite -database'\n} {{sqlite is a software system} {sqlite is also a library} {the sqlite library runs on linux}}\nread_test 1.6.1.2 {\n  SELECT * FROM docs WHERE docs MATCH 'sqlite OR database library'\n} {{sqlite is also a library} {the sqlite library runs on linux} {the sqlite database is accessed by the sqlite library}}\n\nset sqlite_fts3_enable_parentheses 1\nread_test 1.6.1.3 {\n  SELECT * FROM docs WHERE docs MATCH 'sqlite OR database library'\n} {{sqlite is a software system} {sqlite is a database} {sqlite is also a library} {the sqlite library runs on linux} {as does the sqlite database (on linux)} {the sqlite database is accessed by the sqlite library}}\nread_test 1.6.1.4 {\n  SELECT * FROM docs WHERE docs MATCH '(sqlite OR database) library'\n} {{sqlite is also a library} {the sqlite library runs on linux} {the sqlite database is accessed by the sqlite library}}\nset sqlite_fts3_enable_parentheses 0\nddl_test  1.6.1.5 { DROP TABLE docs }\n\n##########################################################################\n# Test the examples in section 4 (auxillary functions).\n#\nddl_test   1.7.1.1 { CREATE VIRTUAL TABLE mail USING fts3(subject, body) }\n\nwrite_test 1.7.1.2 mail_content { \n  INSERT INTO mail VALUES(\n    'hello world', 'This message is a hello world message.');\n}\nwrite_test 1.7.1.3 mail_content { \n  INSERT INTO mail VALUES(\n    'urgent: serious', 'This mail is seen as a more serious mail');\n}\n\nread_test  1.7.1.4 { \n  SELECT offsets(mail) FROM mail WHERE mail MATCH 'world';\n} {{0 0 6 5 1 0 24 5}}\nread_test  1.7.1.5 { \n  SELECT offsets(mail) FROM mail WHERE mail MATCH 'message'\n} {{1 0 5 7 1 0 30 7}}\nread_test  1.7.1.6 { \n  SELECT offsets(mail) FROM mail WHERE mail MATCH '\"serious mail\"'\n} {{1 0 28 7 1 1 36 4}}\n\nddl_test   1.7.2.1 { CREATE VIRTUAL TABLE text USING fts3() }\n\nwrite_test 1.7.2.2 text_content {\n  INSERT INTO text VALUES('\n    During 30 Nov-1 Dec, 2-3oC drops. Cool in the upper portion, minimum temperature 14-16oC and cool elsewhere, minimum temperature 17-20oC. Cold to very cold on mountaintops, minimum temperature 6-12oC. Northeasterly winds 15-30 km/hr. After that, temperature increases. Northeasterly winds 15-30 km/hr.\n  ');\n}\n\nread_test  1.7.2.3 {\n  SELECT snippet(text) FROM text WHERE text MATCH 'cold'\n} {{<b>...</b>cool elsewhere, minimum temperature 17-20oC. <b>Cold</b> to very <b>cold</b> on mountaintops, minimum temperature 6<b>...</b>}}\n\nread_test  1.7.2.4 {\n  SELECT snippet(text, '[', ']', '...') FROM text WHERE text MATCH '\"min* tem*\"'\n} {{...the upper portion, [minimum] [temperature] 14-16oC and cool elsewhere, [minimum] [temperature] 17-20oC. Cold...}}\n\nddl_test   1.7.3.1 { DROP TABLE IF EXISTS t1 }\nddl_test   1.7.3.2 { CREATE VIRTUAL TABLE t1 USING fts3(a, b) }\nwrite_test 1.7.3.3 t1_content { \n  INSERT INTO t1 VALUES(\n    'transaction default models default', 'Non transaction reads');\n}\nwrite_test 1.7.3.4 t1_content { \n  INSERT INTO t1 VALUES('the default transaction', 'these semantics present');\n}\nwrite_test 1.7.3.5 t1_content { \n  INSERT INTO t1 VALUES('single request', 'default data');\n}\nread_test  1.7.3.6 { \n  SELECT mit(matchinfo(t1)) FROM t1 \n    WHERE t1 MATCH 'default transaction \"these semantics\"';\n} {{3 2 1 3 2 0 1 1 1 2 2 0 1 1 0 0 0 1 1 1}}\n\n##########################################################################\n# Test the example in section 5 (custom tokenizers).\n#\nddl_test   1.8.1.1 { CREATE VIRTUAL TABLE simple USING fts3(tokenize=simple) } \nwrite_test 1.8.1.2 simple_content { \n  INSERT INTO simple VALUES('Right now they''re very frustrated')\n}\nread_test 1.8.1.3 {SELECT docid FROM simple WHERE simple MATCH 'Frustrated'} {1} \nread_test 1.8.1.4 {SELECT docid FROM simple WHERE simple MATCH 'Frustration'} {}\n\nddl_test   1.8.2.1 { CREATE VIRTUAL TABLE porter USING fts3(tokenize=porter) } \nwrite_test 1.8.2.2 porter_content { \n  INSERT INTO porter VALUES('Right now they''re very frustrated')\n}\nread_test 1.8.2.4 {\n  SELECT docid FROM porter WHERE porter MATCH 'Frustration'\n} {1}\n\n}\n# End of tests of example code in fts3.html\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test that errors in the arguments passed to the snippet and offsets\n# functions are handled correctly.\n#\nset DO_MALLOC_TEST 0\nddl_test   2.1.0 { DROP TABLE IF EXISTS t1 }\nddl_test   2.1.1 { CREATE VIRTUAL TABLE t1 USING fts3(a, b) }\nwrite_test 2.1.2 t1_content { \n  INSERT INTO t1 VALUES('one two three', x'A1B2C3D4E5F6');\n}\nerror_test 2.1.3 {\n  SELECT offsets(a) FROM t1 WHERE a MATCH 'one'\n} {illegal first argument to offsets}\nerror_test 2.1.4 {\n  SELECT offsets(b) FROM t1 WHERE a MATCH 'one'\n} {illegal first argument to offsets}\nerror_test 2.1.5 {\n  SELECT optimize(a) FROM t1 LIMIT 1\n} {illegal first argument to optimize}\nerror_test 2.1.6 {\n  SELECT snippet(a) FROM t1 WHERE a MATCH 'one'\n} {illegal first argument to snippet}\nerror_test 2.1.7 {\n  SELECT snippet() FROM t1 WHERE a MATCH 'one'\n} {unable to use function snippet in the requested context}\nerror_test 2.1.8 {\n  SELECT snippet(a, b, 'A', 'B', 'C', 'D', 'E') FROM t1 WHERE a MATCH 'one'\n} {wrong number of arguments to function snippet()}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test the effect of an OOM error while installing the FTS3 module (i.e.\n# opening a database handle). This case was not tested by the OOM testing\n# of the document examples above.\n#\ndo_malloc_test e_fts3-3 -tclbody { \n  if {[catch {sqlite3 db test.db}]} { error \"out of memory\" }\n}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Verify the return values of the optimize() function. If no error occurs,\n# the returned value should be \"Index optimized\" if the data structure\n# was modified, or \"Index already optimal\" if it were not.\n#\nset DO_MALLOC_TEST 0\nddl_test   4.1 { CREATE VIRTUAL TABLE t4 USING fts3(a, b) }\nwrite_test 4.2 t4_content {\n  INSERT INTO t4 VALUES('In Xanadu', 'did Kubla Khan');\n}\nwrite_test 4.3 t4_content {\n  INSERT INTO t4 VALUES('a stately pleasure', 'dome decree');\n}\ndo_test e_fts3-4.4 {\n  execsql { SELECT optimize(t4) FROM t4 LIMIT 1 } \n} {{Index optimized}}\ndo_test e_fts3-4.5 {\n  execsql { SELECT optimize(t4) FROM t4 LIMIT 1 } \n} {{Index already optimal}}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test that the snippet function appears to work correctly with 1, 2, 3\n# or 4 arguments passed to it.\n#\nset DO_MALLOC_TEST 0\nddl_test   5.1 { CREATE VIRTUAL TABLE t5 USING fts3(x) }\nwrite_test 5.2 t5_content {\n  INSERT INTO t5 VALUES('In Xanadu did Kubla Khan A stately pleasure-dome decree Where Alph, the sacred river, ran Through caverns measureless to man Down to a sunless sea.  So twice five miles of fertile ground With walls and towers were girdled round : And there were gardens bright with sinuous rills, Where blossomed many an incense-bearing tree ; And here were forests ancient as the hills, Enfolding sunny spots of greenery.');\n}\nread_test 5.3 { \n  SELECT snippet(t5) FROM t5 WHERE t5 MATCH 'miles'\n} {{<b>...</b>to a sunless sea.  So twice five <b>miles</b> of fertile ground With walls and towers<b>...</b>}}\nread_test 5.4 { \n  SELECT snippet(t5, '<i>') FROM t5 WHERE t5 MATCH 'miles'\n} {{<b>...</b>to a sunless sea.  So twice five <i>miles</b> of fertile ground With walls and towers<b>...</b>}}\nread_test 5.5 { \n  SELECT snippet(t5, '<i>', '</i>') FROM t5 WHERE t5 MATCH 'miles'\n} {{<b>...</b>to a sunless sea.  So twice five <i>miles</i> of fertile ground With walls and towers<b>...</b>}}\nread_test 5.6 { \n  SELECT snippet(t5, '<i>', '</i>', 'XXX') FROM t5 WHERE t5 MATCH 'miles'\n} {{XXXto a sunless sea.  So twice five <i>miles</i> of fertile ground With walls and towersXXX}}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test that an empty MATCH expression returns an empty result set. As\n# does passing a NULL value as a MATCH expression.\n#\nset DO_MALLOC_TEST 0\nddl_test   6.1 { CREATE VIRTUAL TABLE t6 USING fts3(x) }\nwrite_test 6.2 t5_content { INSERT INTO t6 VALUES('a'); }\nwrite_test 6.3 t5_content { INSERT INTO t6 VALUES('b'); }\nwrite_test 6.4 t5_content { INSERT INTO t6 VALUES('c'); }\nread_test  6.5 { SELECT * FROM t6 WHERE t6 MATCH '' } {}\nread_test  6.6 { SELECT * FROM t6 WHERE x MATCH '' } {}\nread_test  6.7 { SELECT * FROM t6 WHERE t6 MATCH NULL } {}\nread_test  6.8 { SELECT * FROM t6 WHERE x MATCH NULL } {}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test a few facets of the FTS3 xFilter() callback implementation:\n#\n#   1. That the sqlite3_index_constraint.usable flag is respected.\n#\n#   2. That it is an error to use the \"docid\" or \"rowid\" column of\n#      an FTS3 table as the LHS of a MATCH operator.\n#\n#   3. That it is an error to AND together two MATCH expressions in \n#      that refer to a single FTS3 table in a WHERE clause.\n#\n#\nset DO_MALLOC_TEST 0\nddl_test   7.1.1 { CREATE VIRTUAL TABLE t7 USING fts3(a) }\nddl_test   7.1.2 { CREATE VIRTUAL TABLE t8 USING fts3(b) }\nwrite_test 7.1.3 t7_content { INSERT INTO t7(docid, a) VALUES(4,'number four') }\nwrite_test 7.1.4 t7_content { INSERT INTO t7(docid, a) VALUES(5,'number five') }\nwrite_test 7.1.5 t8_content { INSERT INTO t8(docid, b) VALUES(4,'letter D') }\nwrite_test 7.1.6 t8_content { INSERT INTO t8(docid, b) VALUES(5,'letter E') }\nread_test  7.1.7 {\n  SELECT a || ':' || b FROM t7 JOIN t8 USING(docid)\n} {{number four:letter D} {number five:letter E}}\n\nerror_test 7.2.1 {\n  SELECT * FROM t7 WHERE docid MATCH 'number'\n} {unable to use function MATCH in the requested context}\nerror_test 7.2.2 {\n  SELECT * FROM t7 WHERE rowid MATCH 'number'\n} {unable to use function MATCH in the requested context}\n\nerror_test 7.3.1 {\n  SELECT * FROM t7 WHERE a MATCH 'number' AND a MATCH 'four'\n} {unable to use function MATCH in the requested context}\nerror_test 7.3.2 {\n  SELECT * FROM t7, t8 WHERE a MATCH 'number' AND a MATCH 'four'\n} {unable to use function MATCH in the requested context}\nerror_test 7.3.3 {\n  SELECT * FROM t7, t8 WHERE b MATCH 'letter' AND b MATCH 'd'\n} {unable to use function MATCH in the requested context}\nread_test 7.3.4 {\n  SELECT * FROM t7, t8 WHERE a MATCH 'number' AND b MATCH 'letter'\n} {{number four} {letter D} {number four} {letter E} {number five} {letter D} {number five} {letter E}}\nread_test 7.3.5 {\n  SELECT * FROM t7 WHERE a MATCH 'number' AND docid = 4\n} {{number four}}\n\n#-------------------------------------------------------------------------\n# Test the quoting of FTS3 table column names. Names may be quoted using\n# any of \"\", '', ``` or [].\n#\nset DO_MALLOC_TEST 0\nddl_test  8.1.1 { CREATE VIRTUAL TABLE t9a USING fts3(\"c1\", [c2]) }\nddl_test  8.1.2 { CREATE VIRTUAL TABLE t9b USING fts3('c1', `c2`) }\nread_test 8.1.3 { PRAGMA table_info(t9a) } {0 c1 {} 0 {} 0 1 c2 {} 0 {} 0}\nread_test 8.1.4 { PRAGMA table_info(t9b) } {0 c1 {} 0 {} 0 1 c2 {} 0 {} 0}\nddl_test  8.2.1 { CREATE VIRTUAL TABLE t9c USING fts3(\"c\"\"1\", 'c''2') }\nread_test 8.2.2 { PRAGMA table_info(t9c) } {0 c\\\"1 {} 0 {} 0 1 c'2 {} 0 {} 0}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test that FTS3 tables can be renamed using the ALTER RENAME command.\n# OOM errors are tested during ALTER RENAME commands also.\n#\nforeach DO_MALLOC_TEST {0 1 2} {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 }\n\n  ddl_test   9.1.1             { CREATE VIRTUAL TABLE t10 USING fts3(x) }\n  write_test 9.1.2 t10_content { INSERT INTO t10 VALUES('fts3 tables') }\n  write_test 9.1.3 t10_content { INSERT INTO t10 VALUES('are renameable') }\n\n  read_test  9.1.4 {\n    SELECT * FROM t10 WHERE t10 MATCH 'table*'\n  } {{fts3 tables}}\n  read_test  9.1.5 {\n    SELECT * FROM t10 WHERE x MATCH 'rename*'\n  } {{are renameable}}\n\n  ddl_test   9.1.6             { ALTER TABLE t10 RENAME TO t11 }\n\n  read_test  9.1.7 {\n    SELECT * FROM t11 WHERE t11 MATCH 'table*'\n  } {{fts3 tables}}\n  read_test  9.1.8 {\n    SELECT * FROM t11 WHERE x MATCH 'rename*'\n  } {{are renameable}}\n}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Test a couple of cases involving corrupt data structures:\n#\n#   1) A case where a document referenced by the full-text index is\n#      not present in the %_content table.\n#\n#   2) A badly formatted b-tree segment node.\n#\nset DO_MALLOC_TEST 0\nddl_test   10.1.1 { CREATE VIRTUAL TABLE ta USING fts3 }\nwrite_test 10.1.2 ta_content { \n  INSERT INTO ta VALUES('During a summer vacation in 1790') }\nwrite_test 10.1.3 ta_content {\n  INSERT INTO ta VALUES('Wordsworth went on a walking tour') }\nwrite_test 10.1.4 ta_content { DELETE FROM ta_content WHERE rowid = 2 }\nread_test  10.1.5 {\n  SELECT * FROM ta WHERE ta MATCH 'summer'\n} {{During a summer vacation in 1790}}\nerror_test 10.1.6 {\n  SELECT * FROM ta WHERE ta MATCH 'walking'\n} {database disk image is malformed}\n\nwrite_test 10.2.1 ta_content { DELETE FROM ta }\nwrite_test 10.2.2 ta_content { \n  INSERT INTO ta VALUES('debate demonstrated the rising difficulty') }\nwrite_test 10.2.3 ta_content { \n  INSERT INTO ta VALUES('Google released its browser beta') }\n\nset blob [db one {SELECT root FROM ta_segdir WHERE rowid = 2}]\nbinary scan $blob \"a6 a3 a*\" start middle end\nset middle \"\\x0E\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\x06\\x06\"\nset blob [binary format \"a6 a* a*\" $start $middle $end]\nwrite_test 10.2.4 ta_segdir { \n  UPDATE ta_segdir SET root = $blob WHERE rowid = 2\n}\nerror_test 10.2.5 {\n  SELECT * FROM ta WHERE ta MATCH 'beta'\n} {database disk image is malformed}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_insert.test",
    "content": "# 2010 September 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The majority of this file implements tests to verify that the \"testable\n# statements\" in the lang_insert.html document are correct.\n#\n# Also, it contains tests to verify the statements in (the very short)\n# lang_replace.html.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\n# Organization of tests:\n#\n#   e_insert-0.*: Test the syntax diagram.\n#\n#   e_insert-1.*: Test statements of the form \"INSERT ... VALUES(...)\".\n#   \n#   e_insert-2.*: Test statements of the form \"INSERT ... SELECT ...\".\n#\n#   e_insert-3.*: Test statements of the form \"INSERT ... DEFAULT VALUES\".\n#\n#   e_insert-4.*: Test statements regarding the conflict clause.\n#\n#   e_insert-5.*: Test that the qualified table name and \"DEFAULT VALUES\"\n#                 syntaxes do not work in trigger bodies.\n#\n\ndo_execsql_test e_insert-0.0 {\n  CREATE TABLE a1(a, b);\n  CREATE TABLE a2(a, b, c DEFAULT 'xyz');\n  CREATE TABLE a3(x DEFAULT 1.0, y DEFAULT 'string', z);\n  CREATE TABLE a4(c UNIQUE, d);\n} {}\n\nproc do_insert_tests {args} {\n  uplevel do_select_tests $args\n}\n\n# -- syntax diagram insert-stmt\n#\ndo_insert_tests e_insert-0 {\n     1  \"INSERT             INTO a1 DEFAULT VALUES\"                   {}\n     2  \"INSERT             INTO main.a1 DEFAULT VALUES\"              {}\n     3  \"INSERT OR ROLLBACK INTO main.a1 DEFAULT VALUES\"              {}\n     4  \"INSERT OR ROLLBACK INTO a1 DEFAULT VALUES\"                   {}\n     5  \"INSERT OR ABORT    INTO main.a1 DEFAULT VALUES\"              {}\n     6  \"INSERT OR ABORT    INTO a1 DEFAULT VALUES\"                   {}\n     7  \"INSERT OR REPLACE  INTO main.a1 DEFAULT VALUES\"              {}\n     8  \"INSERT OR REPLACE  INTO a1 DEFAULT VALUES\"                   {}\n     9  \"INSERT OR FAIL     INTO main.a1 DEFAULT VALUES\"              {}\n    10  \"INSERT OR FAIL     INTO a1 DEFAULT VALUES\"                   {}\n    11  \"INSERT OR FAIL     INTO main.a1 DEFAULT VALUES\"              {}\n    12  \"INSERT OR IGNORE   INTO a1 DEFAULT VALUES\"                   {}\n    13  \"REPLACE            INTO a1 DEFAULT VALUES\"                   {}\n    14  \"REPLACE            INTO main.a1 DEFAULT VALUES\"              {}\n    15  \"INSERT             INTO a1      VALUES(1, 2)\"                {}\n    16  \"INSERT             INTO main.a1 VALUES(1, 2)\"                {}\n    17  \"INSERT OR ROLLBACK INTO main.a1 VALUES(1, 2)\"                {}\n    18  \"INSERT OR ROLLBACK INTO a1      VALUES(1, 2)\"                {}\n    19  \"INSERT OR ABORT    INTO main.a1 VALUES(1, 2)\"                {}\n    20  \"INSERT OR ABORT    INTO a1      VALUES(1, 2)\"                {}\n    21  \"INSERT OR REPLACE  INTO main.a1 VALUES(1, 2)\"                {}\n    22  \"INSERT OR REPLACE  INTO a1      VALUES(1, 2)\"                {}\n    23  \"INSERT OR FAIL     INTO main.a1 VALUES(1, 2)\"                {}\n    24  \"INSERT OR FAIL     INTO a1      VALUES(1, 2)\"                {}\n    25  \"INSERT OR FAIL     INTO main.a1 VALUES(1, 2)\"                {}\n    26  \"INSERT OR IGNORE   INTO a1      VALUES(1, 2)\"                {}\n    27  \"REPLACE            INTO a1      VALUES(1, 2)\"                {}\n    28  \"REPLACE            INTO main.a1 VALUES(1, 2)\"                {}\n    29  \"INSERT             INTO a1      (b, a) VALUES(1, 2)\"         {}\n    30  \"INSERT             INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    31  \"INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    32  \"INSERT OR ROLLBACK INTO a1      (b, a) VALUES(1, 2)\"         {}\n    33  \"INSERT OR ABORT    INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    34  \"INSERT OR ABORT    INTO a1      (b, a) VALUES(1, 2)\"         {}\n    35  \"INSERT OR REPLACE  INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    36  \"INSERT OR REPLACE  INTO a1      (b, a) VALUES(1, 2)\"         {}\n    37  \"INSERT OR FAIL     INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    38  \"INSERT OR FAIL     INTO a1      (b, a) VALUES(1, 2)\"         {}\n    39  \"INSERT OR FAIL     INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    40  \"INSERT OR IGNORE   INTO a1      (b, a) VALUES(1, 2)\"         {}\n    41  \"REPLACE            INTO a1      (b, a) VALUES(1, 2)\"         {}\n    42  \"REPLACE            INTO main.a1 (b, a) VALUES(1, 2)\"         {}\n    43  \"INSERT             INTO a1      SELECT c, b FROM a2\"         {}\n    44  \"INSERT             INTO main.a1 SELECT c, b FROM a2\"         {}\n    45  \"INSERT OR ROLLBACK INTO main.a1 SELECT c, b FROM a2\"         {}\n    46  \"INSERT OR ROLLBACK INTO a1      SELECT c, b FROM a2\"         {}\n    47  \"INSERT OR ABORT    INTO main.a1 SELECT c, b FROM a2\"         {}\n    48  \"INSERT OR ABORT    INTO a1      SELECT c, b FROM a2\"         {}\n    49  \"INSERT OR REPLACE  INTO main.a1 SELECT c, b FROM a2\"         {}\n    50  \"INSERT OR REPLACE  INTO a1      SELECT c, b FROM a2\"         {}\n    51  \"INSERT OR FAIL     INTO main.a1 SELECT c, b FROM a2\"         {}\n    52  \"INSERT OR FAIL     INTO a1      SELECT c, b FROM a2\"         {}\n    53  \"INSERT OR FAIL     INTO main.a1 SELECT c, b FROM a2\"         {}\n    54  \"INSERT OR IGNORE   INTO a1      SELECT c, b FROM a2\"         {}\n    55  \"REPLACE            INTO a1      SELECT c, b FROM a2\"         {}\n    56  \"REPLACE            INTO main.a1 SELECT c, b FROM a2\"         {}\n    57  \"INSERT             INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    58  \"INSERT             INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    59  \"INSERT OR ROLLBACK INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    60  \"INSERT OR ROLLBACK INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    61  \"INSERT OR ABORT    INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    62  \"INSERT OR ABORT    INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    63  \"INSERT OR REPLACE  INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    64  \"INSERT OR REPLACE  INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    65  \"INSERT OR FAIL     INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    66  \"INSERT OR FAIL     INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    67  \"INSERT OR FAIL     INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    68  \"INSERT OR IGNORE   INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    69  \"REPLACE            INTO a1      (b, a) SELECT c, b FROM a2\"  {}\n    70  \"REPLACE            INTO main.a1 (b, a) SELECT c, b FROM a2\"  {}\n    71  \"INSERT             INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    72  \"INSERT             INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    73  \"INSERT OR ROLLBACK INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    74  \"INSERT OR ROLLBACK INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    75  \"INSERT OR ABORT    INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    76  \"INSERT OR ABORT    INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    77  \"INSERT OR REPLACE  INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    78  \"INSERT OR REPLACE  INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    79  \"INSERT OR FAIL     INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    80  \"INSERT OR FAIL     INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    81  \"INSERT OR FAIL     INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n    82  \"INSERT OR IGNORE   INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    83  \"REPLACE            INTO a1      (b, a) VALUES(1, 2),(3,4)\"   {}\n    84  \"REPLACE            INTO main.a1 (b, a) VALUES(1, 2),(3,4)\"   {}\n}\n\ndelete_all_data\n\n# EVIDENCE-OF: R-21490-41092 The first form (with the \"VALUES\" keyword)\n# creates one or more new rows in an existing table.\n#\ndo_insert_tests e_insert-1.1 {\n    0    \"SELECT count(*) FROM a2\"           {0}\n\n    1a   \"INSERT INTO a2 VALUES(1, 2, 3)\"    {}\n    1b   \"SELECT count(*) FROM a2\"           {1}\n\n    2a   \"INSERT INTO a2(a, b) VALUES(1, 2)\" {}\n    2b   \"SELECT count(*) FROM a2\"           {2}\n\n    3a   \"INSERT INTO a2(a) VALUES(3),(4)\"   {}\n    3b   \"SELECT count(*) FROM a2\"           {4}\n}\n\n# EVIDENCE-OF: R-19218-01018 If the column-name list after table-name is\n# omitted then the number of values inserted into each row must be the\n# same as the number of columns in the table.\n#\n#   A test in the block above verifies that if the VALUES list has the\n#   correct number of columns (for table a2, 3 columns) works. So these\n#   tests just show that other values cause an error.\n#\ndo_insert_tests e_insert-1.2 -error { \n  table %s has %d columns but %d values were supplied\n} {\n    1    \"INSERT INTO a2 VALUES(1)\"         {a2 3 1}\n    2    \"INSERT INTO a2 VALUES(1,2)\"       {a2 3 2}\n    3    \"INSERT INTO a2 VALUES(1,2,3,4)\"   {a2 3 4}\n    4    \"INSERT INTO a2 VALUES(1,2,3,4,5)\" {a2 3 5}\n}\n\n# EVIDENCE-OF: R-29730-42609 In this case the result of evaluating the\n# left-most expression from each term of the VALUES list is inserted\n# into the left-most column of each new row, and so forth for each\n# subsequent expression.\n#\ndelete_all_data\ndo_insert_tests e_insert-1.3 {\n    1a   \"INSERT INTO a2 VALUES(1, 2, 3)\"    {}\n    1b   \"SELECT * FROM a2 WHERE oid=last_insert_rowid()\" {1 2 3}\n\n    2a   \"INSERT INTO a2 VALUES('abc', NULL, 3*3+1)\"      {}\n    2b   \"SELECT * FROM a2 WHERE oid=last_insert_rowid()\" {abc {} 10}\n\n    3a   \"INSERT INTO a2 VALUES((SELECT count(*) FROM a2), 'x', 'y')\" {}\n    3b   \"SELECT * FROM a2 WHERE oid=last_insert_rowid()\" {2 x y}\n}\n\n# EVIDENCE-OF: R-21115-58321 If a column-name list is specified, then\n# the number of values in each term of the VALUE list must match the\n# number of specified columns.\n#\ndo_insert_tests e_insert-1.4 -error { \n  %d values for %d columns\n} {\n    1    \"INSERT INTO a2(a, b, c) VALUES(1)\"         {1 3}\n    2    \"INSERT INTO a2(a, b, c) VALUES(1,2)\"       {2 3}\n    3    \"INSERT INTO a2(a, b, c) VALUES(1,2,3,4)\"   {4 3}\n    4    \"INSERT INTO a2(a, b, c) VALUES(1,2,3,4,5)\" {5 3}\n\n    5    \"INSERT INTO a2(c, a) VALUES(1)\"            {1 2}\n    6    \"INSERT INTO a2(c, a) VALUES(1,2,3)\"        {3 2}\n    7    \"INSERT INTO a2(c, a) VALUES(1,2,3,4)\"      {4 2}\n    8    \"INSERT INTO a2(c, a) VALUES(1,2,3,4,5)\"    {5 2}\n}\n\n# EVIDENCE-OF: R-07016-26442 Each of the named columns of the new row is\n# populated with the results of evaluating the corresponding VALUES\n# expression.\n#\n# EVIDENCE-OF: R-12183-43719 Table columns that do not appear in the\n# column list are populated with the default column value (specified as\n# part of the CREATE TABLE statement), or with NULL if no default value\n# is specified.\n#\ndelete_all_data\ndo_insert_tests e_insert-1.5 {\n    1a   \"INSERT INTO a2(b, c) VALUES('b', 'c')\"     {}\n    1b   \"SELECT * FROM a2\"                          {{} b c}\n\n    2a   \"INSERT INTO a2(a, b) VALUES('a', 'b')\"     {}\n    2b   \"SELECT * FROM a2\"                          {{} b c  a b xyz}\n}\n\n# EVIDENCE-OF: R-52173-30215 A new entry is inserted into the table for\n# each row of data returned by executing the SELECT statement.\n#\ndelete_all_data\ndo_insert_tests e_insert-2.1 {\n    0    \"SELECT count(*) FROM a1\"            {0}\n\n    1a   \"SELECT count(*) FROM (SELECT 1, 2)\" {1}\n    1b   \"INSERT INTO a1 SELECT 1, 2\"         {}\n    1c   \"SELECT count(*) FROM a1\"            {1}\n\n    2a   \"SELECT count(*) FROM (SELECT b, a FROM a1)\"           {1}\n    2b   \"INSERT INTO a1 SELECT b, a FROM a1\"                   {}\n    2c   \"SELECT count(*) FROM a1\"                              {2}\n\n    3a   \"SELECT count(*) FROM (SELECT b, a FROM a1)\"           {2}\n    3b   \"INSERT INTO a1 SELECT b, a FROM a1\"                   {}\n    3c   \"SELECT count(*) FROM a1\"                              {4}\n\n    4a   \"SELECT count(*) FROM (SELECT b, a FROM a1)\"           {4}\n    4b   \"INSERT INTO a1 SELECT b, a FROM a1\"                   {}\n    4c   \"SELECT count(*) FROM a1\"                              {8}\n\n    4a   \"SELECT count(*) FROM (SELECT min(b), min(a) FROM a1)\" {1}\n    4b   \"INSERT INTO a1 SELECT min(b), min(a) FROM a1\"         {}\n    4c   \"SELECT count(*) FROM a1\"                              {9}\n}\n\n\n# EVIDENCE-OF: R-63614-47421 If a column-list is specified, the number\n# of columns in the result of the SELECT must be the same as the number\n# of items in the column-list.\n#\ndo_insert_tests e_insert-2.2 -error {\n  %d values for %d columns\n} {\n    1    \"INSERT INTO a3(x, y) SELECT a, b, c FROM a2\"            {3 2}\n    2    \"INSERT INTO a3(x, y) SELECT * FROM a2\"                  {3 2}\n    3    \"INSERT INTO a3(x, y) SELECT * FROM a2 CROSS JOIN a1\"    {5 2}\n    4    \"INSERT INTO a3(x, y) SELECT * FROM a2 NATURAL JOIN a1\"  {3 2}\n    5    \"INSERT INTO a3(x, y) SELECT a2.a FROM a2,a1\"            {1 2}\n\n    6    \"INSERT INTO a3(z) SELECT a, b, c FROM a2\"               {3 1}\n    7    \"INSERT INTO a3(z) SELECT * FROM a2\"                     {3 1}\n    8    \"INSERT INTO a3(z) SELECT * FROM a2 CROSS JOIN a1\"       {5 1}\n    9    \"INSERT INTO a3(z) SELECT * FROM a2 NATURAL JOIN a1\"     {3 1}\n    10   \"INSERT INTO a3(z) SELECT a1.* FROM a2,a1\"               {2 1}\n}\n\n# EVIDENCE-OF: R-58951-07798 Otherwise, if no column-list is specified,\n# the number of columns in the result of the SELECT must be the same as\n# the number of columns in the table.\n#\ndo_insert_tests e_insert-2.3 -error {\n  table %s has %d columns but %d values were supplied\n} {\n    1    \"INSERT INTO a1 SELECT a, b, c FROM a2\"            {a1 2 3}\n    2    \"INSERT INTO a1 SELECT * FROM a2\"                  {a1 2 3}\n    3    \"INSERT INTO a1 SELECT * FROM a2 CROSS JOIN a1\"    {a1 2 5}\n    4    \"INSERT INTO a1 SELECT * FROM a2 NATURAL JOIN a1\"  {a1 2 3}\n    5    \"INSERT INTO a1 SELECT a2.a FROM a2,a1\"            {a1 2 1}\n}\n\n# EVIDENCE-OF: R-31074-37730 Any SELECT statement, including compound\n# SELECTs and SELECT statements with ORDER BY and/or LIMIT clauses, may\n# be used in an INSERT statement of this form.\n#\ndelete_all_data\ndo_execsql_test e_insert-2.3.0 {\n  INSERT INTO a1 VALUES('x', 'y');\n} {}\ndo_insert_tests e_insert-2.3 {\n  1  \"INSERT INTO a1 SELECT a,b FROM a1 UNION SELECT b,a FROM a1 ORDER BY 1\" {}\n  2  \"INSERT INTO a1(b, a) SELECT * FROM a1 LIMIT 1\"                         {}\n  3  \"INSERT INTO a1 SELECT 'a'||a, 'b'||b FROM a1 LIMIT 2 OFFSET 1\"         {}\n  4  \"INSERT INTO a1 SELECT * FROM a1 ORDER BY b, a\"                         {}\n  S  \"SELECT * FROM a1\" {\n      x y \n      x y y x\n      y x\n      ax by ay bx \n      ay bx ax by y x y x x y x y\n  }\n}\n\n# EVIDENCE-OF: R-25149-22012 The INSERT ... DEFAULT VALUES statement\n# inserts a single new row into the named table.\n#\ndelete_all_data\ndo_insert_tests e_insert-3.1 {\n    1    \"SELECT count(*) FROM a3\"           {0}\n    2a   \"INSERT INTO a3 DEFAULT VALUES\"     {}\n    2b   \"SELECT count(*) FROM a3\"           {1}\n}\n\n# EVIDENCE-OF: R-18927-01951 Each column of the new row is populated\n# with its default value, or with a NULL if no default value is\n# specified as part of the column definition in the CREATE TABLE\n# statement.\n#\ndelete_all_data\ndo_insert_tests e_insert-3.2 {\n    1.1    \"INSERT INTO a3 DEFAULT VALUES\"     {}\n    1.2    \"SELECT * FROM a3\"                  {1.0 string {}}\n\n    2.1    \"INSERT INTO a3 DEFAULT VALUES\"     {}\n    2.2    \"SELECT * FROM a3\"                  {1.0 string {} 1.0 string {}}\n\n    3.1    \"INSERT INTO a2 DEFAULT VALUES\"     {}\n    3.2    \"SELECT * FROM a2\"                  {{} {} xyz}\n\n    4.1    \"INSERT INTO a2 DEFAULT VALUES\"     {}\n    4.2    \"SELECT * FROM a2\"                  {{} {} xyz {} {} xyz}\n\n    5.1    \"INSERT INTO a1 DEFAULT VALUES\"     {}\n    5.2    \"SELECT * FROM a1\"                  {{} {}}\n\n    6.1    \"INSERT INTO a1 DEFAULT VALUES\"     {}\n    6.2    \"SELECT * FROM a1\"                  {{} {} {} {}}\n}\n\n# EVIDENCE-OF: R-00267-47727 The initial \"INSERT\" keyword can be\n# replaced by \"REPLACE\" or \"INSERT OR action\" to specify an alternative\n# constraint conflict resolution algorithm to use during that one INSERT\n# command.\n#\n# EVIDENCE-OF: R-23110-47146 the parser allows the use of the single\n# keyword REPLACE as an alias for \"INSERT OR REPLACE\".\n#\n#    The two requirements above are tested by e_select-4.1.* and\n#    e_select-4.2.*, respectively.\n#\n# EVIDENCE-OF: R-03421-22330 The REPLACE command is an alias for the\n# \"INSERT OR REPLACE\" variant of the INSERT command.\n#\n#    This is a dup of R-23110-47146. Therefore it is also verified \n#    by e_select-4.2.*. This requirement is the only one from\n#    lang_replace.html.\n#\ndo_execsql_test e_insert-4.1.0 {\n  INSERT INTO a4 VALUES(1, 'a');\n  INSERT INTO a4 VALUES(2, 'a');\n  INSERT INTO a4 VALUES(3, 'a');\n} {}\nforeach {tn sql error ac data } {\n  1.1  \"INSERT INTO a4 VALUES(2,'b')\"  {UNIQUE constraint failed: a4.c}  1 {1 a 2 a 3 a}\n  1.2  \"INSERT OR REPLACE INTO a4 VALUES(2, 'b')\"            {}  1 {1 a 3 a 2 b}\n  1.3  \"INSERT OR IGNORE INTO a4 VALUES(3, 'c')\"             {}  1 {1 a 3 a 2 b}\n  1.4  \"BEGIN\" {} 0 {1 a 3 a 2 b}\n  1.5  \"INSERT INTO a4 VALUES(1, 'd')\" {UNIQUE constraint failed: a4.c}  0 {1 a 3 a 2 b}\n  1.6  \"INSERT OR ABORT INTO a4 VALUES(1, 'd')\" \n        {UNIQUE constraint failed: a4.c}  0 {1 a 3 a 2 b}\n  1.7  \"INSERT OR ROLLBACK INTO a4 VALUES(1, 'd')\" \n        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b}\n  1.8  \"INSERT INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'\"\n        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b}\n  1.9  \"INSERT OR FAIL INTO a4 SELECT 4, 'e' UNION ALL SELECT 3, 'e'\"\n        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b 4 e}\n\n  2.1  \"INSERT INTO a4 VALUES(2,'f')\"  \n        {UNIQUE constraint failed: a4.c}  1 {1 a 3 a 2 b 4 e}\n  2.2  \"REPLACE INTO a4 VALUES(2, 'f')\" {}  1 {1 a 3 a 4 e 2 f}\n} {\n  do_catchsql_test e_insert-4.1.$tn.1 $sql [list [expr {$error!=\"\"}] $error]\n  do_execsql_test  e_insert-4.1.$tn.2 {SELECT * FROM a4} [list {*}$data]\n  do_test          e_insert-4.1.$tn.3 {sqlite3_get_autocommit db} $ac\n}\n\n# EVIDENCE-OF: R-59829-49719 The optional \"schema-name.\" prefix on the\n# table-name is supported for top-level INSERT statements only.\n#\n# EVIDENCE-OF: R-05731-00924 The table name must be unqualified for\n# INSERT statements that occur within CREATE TRIGGER statements.\n#\nset err {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}\n\ndo_catchsql_test e_insert-5.1.1 {\n  CREATE TRIGGER AFTER UPDATE ON a1 BEGIN\n    INSERT INTO main.a4 VALUES(new.a, new.b);\n  END;\n} $err\ndo_catchsql_test e_insert-5.1.2 {\n  CREATE TEMP TABLE IF NOT EXISTS tmptable(a, b);\n  CREATE TRIGGER AFTER DELETE ON a3 BEGIN\n    INSERT INTO temp.tmptable VALUES(1, 2);\n  END;\n} $err\n\n# EVIDENCE-OF: R-15888-36326 Similarly, the \"DEFAULT VALUES\" form of the\n# INSERT statement is supported for top-level INSERT statements only and\n# not for INSERT statements within triggers.\n#\ndo_catchsql_test e_insert-5.2.1 {\n  CREATE TRIGGER AFTER UPDATE ON a1 BEGIN\n    INSERT INTO a4 DEFAULT VALUES;\n  END;\n} {1 {near \"DEFAULT\": syntax error}}\n\n\ndelete_all_data\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_reindex.test",
    "content": "# 2010 September 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_reindex.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc do_reindex_tests {args} {\n  uplevel do_select_tests $args\n}\n\ndo_execsql_test e_reindex-0.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  CREATE INDEX i2 ON t1(b, a);\n} {}\n\n#  -- syntax diagram reindex-stmt\n#\ndo_reindex_tests e_reindex-0.1 {\n  1   \"REINDEX\"           {}\n  2   \"REINDEX nocase\"    {}\n  3   \"REINDEX binary\"    {}\n  4   \"REINDEX t1\"        {}\n  5   \"REINDEX main.t1\"   {}\n  6   \"REINDEX i1\"        {}\n  7   \"REINDEX main.i1\"   {}\n}\n\n# EVIDENCE-OF: R-52173-44778 The REINDEX command is used to delete and\n# recreate indices from scratch.\n#\n#    Test this by corrupting some database indexes, running REINDEX, and\n#    observing that the corruption is gone.\n#\ndo_execsql_test e_reindex-1.1 {\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n\n  CREATE TABLE saved(a,b,c,d,e);\n  INSERT INTO saved SELECT * FROM sqlite_master WHERE type = 'index';\n  PRAGMA writable_schema = 1;\n  DELETE FROM sqlite_master WHERE type = 'index';\n} {}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test e_reindex-1.2 {\n  DELETE FROM t1 WHERE a = 3;\n  INSERT INTO t1 VALUES(7, 8);\n  INSERT INTO t1 VALUES(9, 10);\n  PRAGMA writable_schema = 1;\n  INSERT INTO sqlite_master SELECT * FROM saved;\n  DROP TABLE saved;\n} {}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test e_reindex-1.3 {\n  PRAGMA integrity_check;\n} [list \\\n  {row 3 missing from index i2} \\\n  {row 3 missing from index i1} \\\n  {row 4 missing from index i2} \\\n  {row 4 missing from index i1} \\\n  {wrong # of entries in index i2} \\\n  {wrong # of entries in index i1}\n]\n\ndo_execsql_test e_reindex-1.4 {\n  REINDEX;\n  PRAGMA integrity_check;\n} {ok}\n\n#-------------------------------------------------------------------------\n# The remaining tests in this file focus on testing that the REINDEX \n# command reindexes the correct subset of the indexes in the database.\n# They all use the following dataset.\n#\ndb close\nforcedelete test.db2\nforcedelete test.db\nsqlite3 db test.db\n\nproc sort_by_length {lhs rhs} {\n  set res [expr {[string length $lhs] - [string length $rhs]}]\n  if {$res!=0} {return $res}\n  return [string compare $lhs $rhs]\n}\narray set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8}\nproc sort_by_value {lhs rhs} {\n  global V\n  set res [expr {$V($lhs) - $V($rhs)}]\n  if {$res!=0} {return $res}\n  return [string compare $lhs $rhs]\n}\n\ndb collate collA sort_by_length\ndb collate collB sort_by_value\n\nset BY(length) {one six two five four eight seven three}\nset BY(value)  {one two three four five six seven eight}\n\ndo_execsql_test e_reindex-2.0 {\n  ATTACH 'test.db2' AS aux;\n\n  CREATE TABLE t1(x);\n  CREATE INDEX i1_a ON t1(x COLLATE collA);\n  CREATE INDEX i1_b ON t1(x COLLATE collB);\n  INSERT INTO t1 VALUES('one');\n  INSERT INTO t1 VALUES('two');\n  INSERT INTO t1 VALUES('three');\n  INSERT INTO t1 VALUES('four');\n  INSERT INTO t1 VALUES('five');\n  INSERT INTO t1 VALUES('six');\n  INSERT INTO t1 VALUES('seven');\n  INSERT INTO t1 VALUES('eight');\n\n  CREATE TABLE t2(x);\n  CREATE INDEX i2_a ON t2(x COLLATE collA);\n  CREATE INDEX i2_b ON t2(x COLLATE collB);\n  INSERT INTO t2 SELECT x FROM t1;\n\n  CREATE TABLE aux.t1(x);\n  CREATE INDEX aux.i1_a ON t1(x COLLATE collA);\n  CREATE INDEX aux.i1_b ON t1(x COLLATE collB);\n  INSERT INTO aux.t1 SELECT x FROM main.t1;\n\n} {}\n\nproc test_index {tn tbl collation expected} {\n  set sql \"SELECT x FROM $tbl ORDER BY x COLLATE $collation\"\n  uplevel do_execsql_test e_reindex-2.$tn [list $sql] [list $::BY($expected)]\n}\n\nproc set_collations {a b} {\n  db collate collA \"sort_by_$a\"\n  db collate collB \"sort_by_$b\"\n}\n\ntest_index 1.1   t1     collA   length\ntest_index 1.2   t1     collB   value\ntest_index 1.3   t2     collA   length\ntest_index 1.4   t2     collB   value\ntest_index 1.5   aux.t1 collA   length\ntest_index 1.6   aux.t1 collB   value\n\n\n# EVIDENCE-OF: R-47362-07898 If the REINDEX keyword is not followed by a\n# collation-sequence or database object identifier, then all indices in\n# all attached databases are rebuilt.\n#\nset_collations value length\ndo_execsql_test e_reindex-2.2.1 \"REINDEX\" {}\ntest_index 2.2   t1     collA   value\ntest_index 2.3   t1     collB   length\ntest_index 2.4   t2     collA   value\ntest_index 2.5   t2     collB   length\ntest_index 2.6   aux.t1 collA   value\ntest_index 2.7   aux.t1 collB   length\n\n# EVIDENCE-OF: R-45878-07697 If the REINDEX keyword is followed by a\n# collation-sequence name, then all indices in all attached databases\n# that use the named collation sequences are recreated.\n#\nset_collations length value\ndo_execsql_test e_reindex-2.3.1 \"REINDEX collA\" {}\ntest_index 3.2   t1     collA   length\ntest_index 3.3   t1     collB   length\ntest_index 3.4   t2     collA   length\ntest_index 3.5   t2     collB   length\ntest_index 3.6   aux.t1 collA   length\ntest_index 3.7   aux.t1 collB   length\ndo_execsql_test e_reindex-2.3.8 \"REINDEX collB\" {}\ntest_index 3.9   t1     collA   length\ntest_index 3.10  t1     collB   value\ntest_index 3.11  t2     collA   length\ntest_index 3.12  t2     collB   value\ntest_index 3.13  aux.t1 collA   length\ntest_index 3.14  aux.t1 collB   value\n\n# EVIDENCE-OF: R-49616-30196 Or, if the argument attached to the REINDEX\n# identifies a specific database table, then all indices attached to the\n# database table are rebuilt.\n#\nset_collations value length\ndo_execsql_test e_reindex-2.4.1 \"REINDEX t1\" {}\ntest_index 4.2   t1     collA   value\ntest_index 4.3   t1     collB   length\ntest_index 4.4   t2     collA   length\ntest_index 4.5   t2     collB   value\ntest_index 4.6   aux.t1 collA   length\ntest_index 4.7   aux.t1 collB   value\ndo_execsql_test e_reindex-2.4.8 \"REINDEX aux.t1\" {}\ntest_index 4.9   t1     collA   value\ntest_index 4.10  t1     collB   length\ntest_index 4.11  t2     collA   length\ntest_index 4.12  t2     collB   value\ntest_index 4.13  aux.t1 collA   value\ntest_index 4.14  aux.t1 collB   length\ndo_execsql_test e_reindex-2.4.15 \"REINDEX t2\" {}\ntest_index 4.16  t1     collA   value\ntest_index 4.17  t1     collB   length\ntest_index 4.18  t2     collA   value\ntest_index 4.19  t2     collB   length\ntest_index 4.20  aux.t1 collA   value\ntest_index 4.21  aux.t1 collB   length\n\n# EVIDENCE-OF: R-58823-28748 If it identifies a specific database index,\n# then just that index is recreated.\n#\nset_collations length value\ndo_execsql_test e_reindex-2.5.1 \"REINDEX i1_a\" {}\ntest_index 5.2   t1     collA   length\ntest_index 5.3   t1     collB   length\ntest_index 5.4   t2     collA   value\ntest_index 5.5   t2     collB   length\ntest_index 5.6   aux.t1 collA   value\ntest_index 5.7   aux.t1 collB   length\ndo_execsql_test e_reindex-2.5.8 \"REINDEX i2_b\" {}\ntest_index 5.9   t1     collA   length\ntest_index 5.10  t1     collB   length\ntest_index 5.11  t2     collA   value\ntest_index 5.12  t2     collB   value\ntest_index 5.13  aux.t1 collA   value\ntest_index 5.14  aux.t1 collB   length\ndo_execsql_test e_reindex-2.5.15 \"REINDEX aux.i1_b\" {}\ntest_index 5.16  t1     collA   length\ntest_index 5.17  t1     collB   length\ntest_index 5.18  t2     collA   value\ntest_index 5.19  t2     collB   value\ntest_index 5.20  aux.t1 collA   value\ntest_index 5.21  aux.t1 collB   value\ndo_execsql_test e_reindex-2.5.22 \"REINDEX i1_b\" {}\ntest_index 5.23  t1     collA   length\ntest_index 5.24  t1     collB   value\ntest_index 5.25  t2     collA   value\ntest_index 5.26  t2     collB   value\ntest_index 5.27  aux.t1 collA   value\ntest_index 5.28  aux.t1 collB   value\ndo_execsql_test e_reindex-2.5.29 \"REINDEX i2_a\" {}\ntest_index 5.30  t1     collA   length\ntest_index 5.31  t1     collB   value\ntest_index 5.32  t2     collA   length\ntest_index 5.33  t2     collB   value\ntest_index 5.34  aux.t1 collA   value\ntest_index 5.35  aux.t1 collB   value\ndo_execsql_test e_reindex-2.5.36 \"REINDEX aux.i1_a\" {}\ntest_index 5.37  t1     collA   length\ntest_index 5.38  t1     collB   value\ntest_index 5.39  t2     collA   length\ntest_index 5.40  t2     collB   value\ntest_index 5.41  aux.t1 collA   length\ntest_index 5.42  aux.t1 collB   value\n\n# EVIDENCE-OF: R-35892-30289 For a command of the form \"REINDEX name\", a\n# match against collation-name takes precedence over a match against\n# index-name or table-name.\n#\nset_collations value length\ndo_execsql_test e_reindex-2.6.0 {\n  CREATE TABLE collA(x);\n  CREATE INDEX icolla_a ON collA(x COLLATE collA);\n  CREATE INDEX icolla_b ON collA(x COLLATE collB);\n\n  INSERT INTO collA SELECT x FROM t1;\n} {}\n\ntest_index 6.1   collA  collA   value\ntest_index 6.2   collA  collB   length\n\nset_collations length value\ndo_execsql_test e_reindex-2.6.3 \"REINDEX collA\" {}\ntest_index 6.4   collA  collA   length\ntest_index 6.5   collA  collB   length\ndo_execsql_test e_reindex-2.6.3 \"REINDEX main.collA\" {}\ntest_index 6.4   collA  collA   length\ntest_index 6.5   collA  collB   value\n\nset_collations value length\ndo_execsql_test e_reindex-2.6.6 \"REINDEX main.collA\" {}\ntest_index 6.7   collA  collA   value\ntest_index 6.8   collA  collB   length\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_resolve.test",
    "content": "# 2010 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_naming.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix e_resolve\n\n# An example database schema for testing name resolution:\n#\nset schema {\n  ATTACH 'test.db2' AS at1;\n  ATTACH 'test.db3' AS at2;\n\n  CREATE TABLE   temp.n1(x, y); INSERT INTO temp.n1 VALUES('temp', 'n1');\n  CREATE TRIGGER temp.n3 AFTER INSERT ON n1 BEGIN SELECT 1; END;\n  CREATE INDEX   temp.n4 ON n1(x, y);\n\n  CREATE TABLE   main.n1(x, y); INSERT INTO main.n1 VALUES('main', 'n1');\n  CREATE TABLE   main.n2(x, y); INSERT INTO main.n2 VALUES('main', 'n2');\n  CREATE INDEX   main.n3 ON n2(y, x);\n  CREATE TRIGGER main.n4 BEFORE INSERT ON n2 BEGIN SELECT 1; END;\n\n  CREATE TABLE   at1.n1(x, y);  INSERT INTO at1.n1 VALUES('at1', 'n1');\n  CREATE TABLE   at1.n2(x, y);  INSERT INTO at1.n2 VALUES('at1', 'n2');\n  CREATE TABLE   at1.n3(x, y);  INSERT INTO at1.n3 VALUES('at1', 'n3');\n\n  CREATE TABLE   at2.n1(x, y);  INSERT INTO at2.n1 VALUES('at2', 'n1');\n  CREATE TABLE   at2.n2(x, y);  INSERT INTO at2.n2 VALUES('at2', 'n2');\n  CREATE TABLE   at2.n3(x, y);  INSERT INTO at2.n3 VALUES('at2', 'n3');\n  CREATE TABLE   at2.n4(x, y);  INSERT INTO at2.n4 VALUES('at2', 'n4');\n  CREATE TRIGGER at2.n4 BEFORE INSERT ON n4 BEGIN SELECT 1; END;\n}\n\nproc resolve_reopen_db {} {\n  db close\n  forcedelete test.db test.db2 test.db3\n  sqlite3 db test.db\n  db eval $::schema\n}\n\n\n\n# EVIDENCE-OF: R-33528-20612 If no database is specified as part of the\n# object reference, then SQLite searches the main, temp and all attached\n# databases for an object with a matching name. The temp database is\n# searched first, followed by the main database, followed all attached\n# databases in the order that they were attached. The reference resolves\n# to the first match found.\n#\nresolve_reopen_db\ndo_execsql_test 1.1 { SELECT * FROM n1 } {temp n1}\ndo_execsql_test 1.2 { SELECT * FROM n2 } {main n2}\ndo_execsql_test 1.3 { SELECT * FROM n3 } {at1  n3}\ndo_execsql_test 1.4 { SELECT * FROM n4 } {at2  n4}\n\n# EVIDENCE-OF: R-00634-08585 If a schema name is specified as part of an\n# object reference, it must be either \"main\", or \"temp\" or the\n# schema-name of an attached database.\n#\n#   Or else it is a \"no such table: xxx\" error.\n#\nresolve_reopen_db\ndo_execsql_test 2.1.1 { SELECT * FROM main.n1 } {main n1}\ndo_execsql_test 2.1.2 { SELECT * FROM temp.n1 } {temp n1}\ndo_execsql_test 2.1.3 { SELECT * FROM at1.n1 } {at1 n1}\ndo_execsql_test 2.1.4 { SELECT * FROM at2.n1 } {at2 n1}\n\ndo_catchsql_test 2.2 { SELECT * FROM xxx.n1 } {1 {no such table: xxx.n1}}\n\n# EVIDENCE-OF: R-17446-42210 Like other SQL identifiers, schema names\n# are case-insensitive.\n#\nresolve_reopen_db\ndo_execsql_test 3.1 { SELECT * FROM MAIN.n1 } {main n1}\ndo_execsql_test 3.2 { SELECT * FROM tEmP.n1 } {temp n1}\ndo_execsql_test 3.3 { SELECT * FROM aT1.n1 } {at1 n1}\ndo_execsql_test 3.4 { SELECT * FROM At2.n1 } {at2 n1}\n\n# EVIDENCE-OF: R-14755-58619 If a schema name is specified, then only\n# that one schema is searched for the named object.\n#\ndo_catchsql_test 4.1 { SELECT * FROM temp.n2 } {1 {no such table: temp.n2}}\ndo_catchsql_test 4.2 { SELECT * FROM main.n2 } {0 {main n2}}\ndo_catchsql_test 4.3 { SELECT * FROM at1.n2 }  {0 {at1 n2}}\ndo_catchsql_test 4.4 { SELECT * FROM at2.n2 }  {0 {at2 n2}}\n\n# EVIDENCE-OF: R-08951-19801 When searching database schemas for a named\n# object, objects of types that cannot be used in the context of the\n# reference are always ignored.\n#\n#   In this case, \"types that cannot be used\" are triggers and indexes.\n#   The temp and main databases both contain triggers and indexes named\n#   \"n3\" and \"n4\". Database \"at2\" contains a trigger called \"n4\". And yet:\n#\ndo_execsql_test 5.1 { SELECT * FROM n3 } {at1  n3}\ndo_execsql_test 5.2 { SELECT * FROM n4 } {at2  n4}\n\n#-------------------------------------------------------------------------\n# EVIDENCE-OF: R-37286-42536 \n#\ndb close\nforcedelete test.db file.db\nsqlite3 db test.db\ndo_execsql_test 6.1 {\n  ATTACH 'file.db' AS aux;\n  CREATE TABLE t1(x, y);\n  CREATE TEMP TABLE t1(x, y);\n  CREATE TABLE aux.t1(x, y);\n}\n\ndo_execsql_test  6.2.0 { DROP TABLE t1 }\ndo_catchsql_test 6.2.1 { SELECT * FROM temp.t1 } {1 {no such table: temp.t1}}\ndo_catchsql_test 6.2.2 { SELECT * FROM main.t1 } {0 {}}\ndo_catchsql_test 6.2.3 { SELECT * FROM aux.t1  } {0 {}}\n\ndo_execsql_test  6.3.0 { DROP TABLE t1 }\ndo_catchsql_test 6.3.1 { SELECT * FROM main.t1 } {1 {no such table: main.t1}}\ndo_catchsql_test 6.3.3 { SELECT * FROM aux.t1  } {0 {}}\n\ndo_execsql_test  6.4.0 { DROP TABLE t1 }\ndo_catchsql_test 6.4.1 { SELECT * FROM aux.t1 } {1 {no such table: aux.t1}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_select.test",
    "content": "# 2010 July 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_select.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_execsql_test e_select-1.0 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES('a', 'one');\n  INSERT INTO t1 VALUES('b', 'two');\n  INSERT INTO t1 VALUES('c', 'three');\n\n  CREATE TABLE t2(a, b);\n  INSERT INTO t2 VALUES('a', 'I');\n  INSERT INTO t2 VALUES('b', 'II');\n  INSERT INTO t2 VALUES('c', 'III');\n\n  CREATE TABLE t3(a, c);\n  INSERT INTO t3 VALUES('a', 1);\n  INSERT INTO t3 VALUES('b', 2);\n\n  CREATE TABLE t4(a, c);\n  INSERT INTO t4 VALUES('a', NULL);\n  INSERT INTO t4 VALUES('b', 2);\n} {}\nset t1_cross_t2 [list                \\\n   a one   a I      a one   b II     \\\n   a one   c III    b two   a I      \\\n   b two   b II     b two   c III    \\\n   c three a I      c three b II     \\\n   c three c III                     \\\n]\nset t1_cross_t1 [list                  \\\n   a one   a one      a one   b two    \\\n   a one   c three    b two   a one    \\\n   b two   b two      b two   c three  \\\n   c three a one      c three b two    \\\n   c three c three                     \\\n]\n\n\n# This proc is a specialized version of [do_execsql_test].\n#\n# The second argument to this proc must be a SELECT statement that \n# features a cross join of some time. Instead of the usual \",\", \n# \"CROSS JOIN\" or \"INNER JOIN\" join-op, the string %JOIN% must be \n# substituted.\n#\n# This test runs the SELECT three times - once with:\n#\n#   * s/%JOIN%/,/\n#   * s/%JOIN%/JOIN/\n#   * s/%JOIN%/INNER JOIN/\n#   * s/%JOIN%/CROSS JOIN/\n#\n# and checks that each time the results of the SELECT are $res.\n#\nproc do_join_test {tn select res} {\n  foreach {tn2 joinop} [list    1 ,    2 \"CROSS JOIN\"    3 \"INNER JOIN\"] {\n    set S [string map [list %JOIN% $joinop] $select]\n    uplevel do_execsql_test $tn.$tn2 [list $S] [list $res]\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following tests check that all paths on the syntax diagrams on\n# the lang_select.html page may be taken.\n#\n# -- syntax diagram join-constraint\n#\ndo_join_test e_select-0.1.1 {\n  SELECT count(*) FROM t1 %JOIN% t2 ON (t1.a=t2.a)\n} {3}\ndo_join_test e_select-0.1.2 {\n  SELECT count(*) FROM t1 %JOIN% t2 USING (a)\n} {3}\ndo_join_test e_select-0.1.3 {\n  SELECT count(*) FROM t1 %JOIN% t2\n} {9}\ndo_catchsql_test e_select-0.1.4 {\n  SELECT count(*) FROM t1, t2 ON (t1.a=t2.a) USING (a)\n} {1 {cannot have both ON and USING clauses in the same join}}\ndo_catchsql_test e_select-0.1.5 {\n  SELECT count(*) FROM t1, t2 USING (a) ON (t1.a=t2.a)\n} {1 {near \"ON\": syntax error}}\n\n# -- syntax diagram select-core\n#\n#   0: SELECT ...\n#   1: SELECT DISTINCT ...\n#   2: SELECT ALL ...\n#\n#   0: No FROM clause\n#   1: Has FROM clause\n#\n#   0: No WHERE clause\n#   1: Has WHERE clause\n#\n#   0: No GROUP BY clause\n#   1: Has GROUP BY clause\n#   2: Has GROUP BY and HAVING clauses\n#\ndo_select_tests e_select-0.2 {\n  0000.1  \"SELECT 1, 2, 3 \" {1 2 3}\n  1000.1  \"SELECT DISTINCT 1, 2, 3 \" {1 2 3}\n  2000.1  \"SELECT ALL 1, 2, 3 \" {1 2 3}\n  \n  0100.1  \"SELECT a, b, a||b FROM t1 \" {\n    a one aone b two btwo c three cthree\n  }\n  1100.1  \"SELECT DISTINCT a, b, a||b FROM t1 \" {\n    a one aone b two btwo c three cthree\n  }\n  1200.1  \"SELECT ALL a, b, a||b FROM t1 \" {\n    a one aone b two btwo c three cthree\n  }\n\n  0010.1  \"SELECT 1, 2, 3 WHERE 1 \" {1 2 3}\n  0010.2  \"SELECT 1, 2, 3 WHERE 0 \" {}\n  0010.3  \"SELECT 1, 2, 3 WHERE NULL \" {}\n\n  1010.1  \"SELECT DISTINCT 1, 2, 3 WHERE 1 \" {1 2 3}\n\n  2010.1  \"SELECT ALL 1, 2, 3 WHERE 1 \" {1 2 3}\n\n  0110.1  \"SELECT a, b, a||b FROM t1 WHERE a!='x' \" {\n    a one aone b two btwo c three cthree\n  }\n  0110.2  \"SELECT a, b, a||b FROM t1 WHERE a=='x'\" {}\n\n  1110.1  \"SELECT DISTINCT a, b, a||b FROM t1 WHERE a!='x' \" {\n    a one aone b two btwo c three cthree\n  }\n\n  2110.0  \"SELECT ALL a, b, a||b FROM t1 WHERE a=='x'\" {}\n\n  0001.1  \"SELECT 1, 2, 3 GROUP BY 2\" {1 2 3}\n  0002.1  \"SELECT 1, 2, 3 GROUP BY 2 HAVING count(*)=1\" {1 2 3}\n  0002.2  \"SELECT 1, 2, 3 GROUP BY 2 HAVING count(*)>1\" {}\n\n  1001.1  \"SELECT DISTINCT 1, 2, 3 GROUP BY 2\" {1 2 3}\n  1002.1  \"SELECT DISTINCT 1, 2, 3 GROUP BY 2 HAVING count(*)=1\" {1 2 3}\n  1002.2  \"SELECT DISTINCT 1, 2, 3 GROUP BY 2 HAVING count(*)>1\" {}\n\n  2001.1  \"SELECT ALL 1, 2, 3 GROUP BY 2\" {1 2 3}\n  2002.1  \"SELECT ALL 1, 2, 3 GROUP BY 2 HAVING count(*)=1\" {1 2 3}\n  2002.2  \"SELECT ALL 1, 2, 3 GROUP BY 2 HAVING count(*)>1\" {}\n\n  0101.1  \"SELECT count(*), max(a) FROM t1 GROUP BY b\" {1 a 1 c 1 b}\n  0102.1  \"SELECT count(*), max(a) FROM t1 GROUP BY b HAVING count(*)=1\" {\n    1 a 1 c 1 b\n  }\n  0102.2  \"SELECT count(*), max(a) FROM t1 GROUP BY b HAVING count(*)=2\" { }\n\n  1101.1  \"SELECT DISTINCT count(*), max(a) FROM t1 GROUP BY b\" {1 a 1 c 1 b}\n  1102.1  \"SELECT DISTINCT count(*), max(a) FROM t1 \n           GROUP BY b HAVING count(*)=1\" {\n    1 a 1 c 1 b\n  }\n  1102.2  \"SELECT DISTINCT count(*), max(a) FROM t1 \n           GROUP BY b HAVING count(*)=2\" { \n  }\n\n  2101.1  \"SELECT ALL count(*), max(a) FROM t1 GROUP BY b\" {1 a 1 c 1 b}\n  2102.1  \"SELECT ALL count(*), max(a) FROM t1 \n           GROUP BY b HAVING count(*)=1\" {\n    1 a 1 c 1 b\n  }\n  2102.2  \"SELECT ALL count(*), max(a) FROM t1 \n           GROUP BY b HAVING count(*)=2\" { \n  }\n\n  0011.1  \"SELECT 1, 2, 3 WHERE 1 GROUP BY 2\" {1 2 3}\n  0012.1  \"SELECT 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)=1\" {}\n  0012.2  \"SELECT 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)>1\" {}\n\n  1011.1  \"SELECT DISTINCT 1, 2, 3 WHERE 0 GROUP BY 2\" {}\n  1012.1  \"SELECT DISTINCT 1, 2, 3 WHERE 1 GROUP BY 2 HAVING count(*)=1\" \n          {1 2 3}\n  1012.2  \"SELECT DISTINCT 1, 2, 3 WHERE NULL GROUP BY 2 HAVING count(*)>1\" {}\n\n  2011.1  \"SELECT ALL 1, 2, 3 WHERE 1 GROUP BY 2\" {1 2 3}\n  2012.1  \"SELECT ALL 1, 2, 3 WHERE 0 GROUP BY 2 HAVING count(*)=1\" {}\n  2012.2  \"SELECT ALL 1, 2, 3 WHERE 'abc' GROUP BY 2 HAVING count(*)>1\" {}\n\n  0111.1  \"SELECT count(*), max(a) FROM t1 WHERE a='a' GROUP BY b\" {1 a}\n  0112.1  \"SELECT count(*), max(a) FROM t1 \n           WHERE a='c' GROUP BY b HAVING count(*)=1\" {1 c}\n  0112.2  \"SELECT count(*), max(a) FROM t1 \n           WHERE 0 GROUP BY b HAVING count(*)=2\" { }\n  1111.1  \"SELECT DISTINCT count(*), max(a) FROM t1 WHERE a<'c' GROUP BY b\" \n          {1 a 1 b}\n  1112.1  \"SELECT DISTINCT count(*), max(a) FROM t1 WHERE a>'a'\n           GROUP BY b HAVING count(*)=1\" {\n    1 c 1 b\n  }\n  1112.2  \"SELECT DISTINCT count(*), max(a) FROM t1 WHERE 0\n           GROUP BY b HAVING count(*)=2\" { \n  }\n\n  2111.1  \"SELECT ALL count(*), max(a) FROM t1 WHERE b>'one' GROUP BY b\" \n          {1 c 1 b}\n  2112.1  \"SELECT ALL count(*), max(a) FROM t1 WHERE a!='b'\n           GROUP BY b HAVING count(*)=1\" {\n    1 a 1 c\n  }\n  2112.2  \"SELECT ALL count(*), max(a) FROM t1 \n           WHERE 0 GROUP BY b HAVING count(*)=2\" { }\n}\n\n\n# -- syntax diagram result-column\n#\ndo_select_tests e_select-0.3 {\n  1  \"SELECT * FROM t1\" {a one b two c three}\n  2  \"SELECT t1.* FROM t1\" {a one b two c three}\n  3  \"SELECT 'x'||a||'x' FROM t1\" {xax xbx xcx}\n  4  \"SELECT 'x'||a||'x' alias FROM t1\" {xax xbx xcx}\n  5  \"SELECT 'x'||a||'x' AS alias FROM t1\" {xax xbx xcx}\n}\n\n# -- syntax diagram join-source\n#\n# -- syntax diagram join-op\n#\ndo_select_tests e_select-0.4 {\n  1  \"SELECT t1.rowid FROM t1\" {1 2 3}\n  2  \"SELECT t1.rowid FROM t1,t2\" {1 1 1 2 2 2 3 3 3}\n  3  \"SELECT t1.rowid FROM t1,t2,t3\" {1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3}\n\n  4  \"SELECT t1.rowid FROM t1\" {1 2 3}\n  5  \"SELECT t1.rowid FROM t1 JOIN t2\" {1 1 1 2 2 2 3 3 3}\n  6  \"SELECT t1.rowid FROM t1 JOIN t2 JOIN t3\" \n     {1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3}\n\n  7  \"SELECT t1.rowid FROM t1 NATURAL JOIN t3\" {1 2}\n  8  \"SELECT t1.rowid FROM t1 NATURAL LEFT OUTER JOIN t3\" {1 2 3}\n  9  \"SELECT t1.rowid FROM t1 NATURAL LEFT JOIN t3\" {1 2 3}\n  10 \"SELECT t1.rowid FROM t1 NATURAL INNER JOIN t3\" {1 2}\n  11 \"SELECT t1.rowid FROM t1 NATURAL CROSS JOIN t3\" {1 2}\n\n  12 \"SELECT t1.rowid FROM t1 JOIN t3\" {1 1 2 2 3 3}\n  13 \"SELECT t1.rowid FROM t1 LEFT OUTER JOIN t3\" {1 1 2 2 3 3}\n  14 \"SELECT t1.rowid FROM t1 LEFT JOIN t3\" {1 1 2 2 3 3}\n  15 \"SELECT t1.rowid FROM t1 INNER JOIN t3\" {1 1 2 2 3 3}\n  16 \"SELECT t1.rowid FROM t1 CROSS JOIN t3\" {1 1 2 2 3 3}\n}\n\n# -- syntax diagram compound-operator\n#\ndo_select_tests e_select-0.5 {\n  1  \"SELECT rowid FROM t1 UNION ALL SELECT rowid+2 FROM t4\" {1 2 3 3 4}\n  2  \"SELECT rowid FROM t1 UNION     SELECT rowid+2 FROM t4\" {1 2 3 4}\n  3  \"SELECT rowid FROM t1 INTERSECT SELECT rowid+2 FROM t4\" {3}\n  4  \"SELECT rowid FROM t1 EXCEPT    SELECT rowid+2 FROM t4\" {1 2}\n}\n\n# -- syntax diagram ordering-term\n#\ndo_select_tests e_select-0.6 {\n  1  \"SELECT b||a FROM t1 ORDER BY b||a\"                  {onea threec twob}\n  2  \"SELECT b||a FROM t1 ORDER BY (b||a) COLLATE nocase\" {onea threec twob}\n  3  \"SELECT b||a FROM t1 ORDER BY (b||a) ASC\"            {onea threec twob}\n  4  \"SELECT b||a FROM t1 ORDER BY (b||a) DESC\"           {twob threec onea}\n}\n\n# -- syntax diagram select-stmt\n#\ndo_select_tests e_select-0.7 {\n  1  \"SELECT * FROM t1\" {a one b two c three}\n  2  \"SELECT * FROM t1 ORDER BY b\" {a one c three b two}\n  3  \"SELECT * FROM t1 ORDER BY b, a\" {a one c three b two}\n\n  4  \"SELECT * FROM t1 LIMIT 10\" {a one b two c three}\n  5  \"SELECT * FROM t1 LIMIT 10 OFFSET 5\" {}\n  6  \"SELECT * FROM t1 LIMIT 10, 5\" {}\n\n  7  \"SELECT * FROM t1 ORDER BY a LIMIT 10\" {a one b two c three}\n  8  \"SELECT * FROM t1 ORDER BY b LIMIT 10 OFFSET 5\" {}\n  9  \"SELECT * FROM t1 ORDER BY a,b LIMIT 10, 5\" {}\n\n  10  \"SELECT * FROM t1 UNION SELECT b, a FROM t1\" \n     {a one b two c three one a three c two b}\n  11  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b\" \n     {one a two b three c a one c three b two}\n  12  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b, a\" \n     {one a two b three c a one c three b two}\n  13  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10\" \n     {a one b two c three one a three c two b}\n  14  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10 OFFSET 5\" \n     {two b}\n  15  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 LIMIT 10, 5\" \n     {}\n  16  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY a LIMIT 10\" \n     {a one b two c three one a three c two b}\n  17  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY b LIMIT 10 OFFSET 5\" \n     {b two}\n  18  \"SELECT * FROM t1 UNION SELECT b, a FROM t1 ORDER BY a,b LIMIT 10, 5\" \n     {}\n}\n\n#-------------------------------------------------------------------------\n# The following tests focus on FROM clause (join) processing.\n#\n\n# EVIDENCE-OF: R-16074-54196 If the FROM clause is omitted from a simple\n# SELECT statement, then the input data is implicitly a single row zero\n# columns wide\n#\ndo_select_tests e_select-1.1 {\n  1 \"SELECT 'abc'\"            {abc}\n  2 \"SELECT 'abc' WHERE NULL\" {}\n  3 \"SELECT NULL\"             {{}}\n  4 \"SELECT count(*)\"         {1}\n  5 \"SELECT count(*) WHERE 0\" {0}\n  6 \"SELECT count(*) WHERE 1\" {1}\n}\n\n# EVIDENCE-OF: R-45424-07352 If there is only a single table or subquery\n# in the FROM clause, then the input data used by the SELECT statement\n# is the contents of the named table.\n#\n#   The results of the SELECT queries suggest that they are operating on the\n#   contents of the table 'xx'.\n#\ndo_execsql_test e_select-1.2.0 {\n  CREATE TABLE xx(x, y);\n  INSERT INTO xx VALUES('IiJlsIPepMuAhU', X'10B00B897A15BAA02E3F98DCE8F2');\n  INSERT INTO xx VALUES(NULL, -16.87);\n  INSERT INTO xx VALUES(-17.89, 'linguistically');\n} {}\ndo_select_tests e_select-1.2 {\n  1  \"SELECT quote(x), quote(y) FROM xx\" {\n     'IiJlsIPepMuAhU' X'10B00B897A15BAA02E3F98DCE8F2' \n     NULL             -16.87                          \n     -17.89           'linguistically'                \n  }\n\n  2  \"SELECT count(*), count(x), count(y) FROM xx\" {3 2 3}\n  3  \"SELECT sum(x), sum(y) FROM xx\"               {-17.89 -16.87}\n}\n\n# EVIDENCE-OF: R-28355-09804 If there is more than one table or subquery\n# in FROM clause then the contents of all tables and/or subqueries are\n# joined into a single dataset for the simple SELECT statement to\n# operate on.\n#\n#   There are more detailed tests for subsequent requirements that add \n#   more detail to this idea. We just add a single test that shows that\n#   data is coming from each of the three tables following the FROM clause\n#   here to show that the statement, vague as it is, is not incorrect.\n#\ndo_select_tests e_select-1.3 {\n  1 \"SELECT * FROM t1, t2, t3\" {\n      a one a I a 1 a one a I b 2 a one b II a 1 \n      a one b II b 2 a one c III a 1 a one c III b 2 \n      b two a I a 1 b two a I b 2 b two b II a 1 \n      b two b II b 2 b two c III a 1 b two c III b 2 \n      c three a I a 1 c three a I b 2 c three b II a 1 \n      c three b II b 2 c three c III a 1 c three c III b 2\n  }\n}\n\n#\n# The following block of tests - e_select-1.4.* - test that the description\n# of cartesian joins in the SELECT documentation is consistent with SQLite.\n# In doing so, we test the following three requirements as a side-effect:\n#\n# EVIDENCE-OF: R-49872-03192 If the join-operator is \"CROSS JOIN\",\n# \"INNER JOIN\", \"JOIN\" or a comma (\",\") and there is no ON or USING\n# clause, then the result of the join is simply the cartesian product of\n# the left and right-hand datasets.\n#\n#    The tests are built on this assertion. Really, they test that the output\n#    of a CROSS JOIN, JOIN, INNER JOIN or \",\" join matches the expected result\n#    of calculating the cartesian product of the left and right-hand datasets. \n#\n# EVIDENCE-OF: R-46256-57243 There is no difference between the \"INNER\n# JOIN\", \"JOIN\" and \",\" join operators.\n#\n# EVIDENCE-OF: R-25071-21202 The \"CROSS JOIN\" join operator produces the\n# same result as the \"INNER JOIN\", \"JOIN\" and \",\" operators\n#\n#    All tests are run 4 times, with the only difference in each run being\n#    which of the 4 equivalent cartesian product join operators are used.\n#    Since the output data is the same in all cases, we consider that this\n#    qualifies as testing the two statements above.\n#\ndo_execsql_test e_select-1.4.0 {\n  CREATE TABLE x1(a, b);\n  CREATE TABLE x2(c, d, e);\n  CREATE TABLE x3(f, g, h, i);\n\n  -- x1: 3 rows, 2 columns\n  INSERT INTO x1 VALUES(24, 'converging');\n  INSERT INTO x1 VALUES(NULL, X'CB71');\n  INSERT INTO x1 VALUES('blonds', 'proprietary');\n\n  -- x2: 2 rows, 3 columns\n  INSERT INTO x2 VALUES(-60.06, NULL, NULL);\n  INSERT INTO x2 VALUES(-58, NULL, 1.21);\n\n  -- x3: 5 rows, 4 columns\n  INSERT INTO x3 VALUES(-39.24, NULL, 'encompass', -1);\n  INSERT INTO x3 VALUES('presenting', 51, 'reformation', 'dignified');\n  INSERT INTO x3 VALUES('conducting', -87.24, 37.56, NULL);\n  INSERT INTO x3 VALUES('coldest', -96, 'dramatists', 82.3);\n  INSERT INTO x3 VALUES('alerting', NULL, -93.79, NULL);\n} {}\n\n# EVIDENCE-OF: R-59089-25828 The columns of the cartesian product\n# dataset are, in order, all the columns of the left-hand dataset\n# followed by all the columns of the right-hand dataset.\n#\ndo_join_test e_select-1.4.1.1 {\n  SELECT * FROM x1 %JOIN% x2 LIMIT 1\n} [concat {24 converging} {-60.06 {} {}}]\n\ndo_join_test e_select-1.4.1.2 {\n  SELECT * FROM x2 %JOIN% x1 LIMIT 1\n} [concat {-60.06 {} {}} {24 converging}]\n\ndo_join_test e_select-1.4.1.3 {\n  SELECT * FROM x3 %JOIN% x2 LIMIT 1\n} [concat {-39.24 {} encompass -1} {-60.06 {} {}}]\n\ndo_join_test e_select-1.4.1.4 {\n  SELECT * FROM x2 %JOIN% x3 LIMIT 1\n} [concat {-60.06 {} {}} {-39.24 {} encompass -1}]\n\n# EVIDENCE-OF: R-44414-54710 There is a row in the cartesian product\n# dataset formed by combining each unique combination of a row from the\n# left-hand and right-hand datasets.\n#\ndo_join_test e_select-1.4.2.1 {\n  SELECT * FROM x2 %JOIN% x3 ORDER BY +c, +f\n} [list -60.06 {} {}      -39.24 {} encompass -1                 \\\n        -60.06 {} {}      alerting {} -93.79 {}                  \\\n        -60.06 {} {}      coldest -96 dramatists 82.3            \\\n        -60.06 {} {}      conducting -87.24 37.56 {}             \\\n        -60.06 {} {}      presenting 51 reformation dignified    \\\n        -58 {} 1.21       -39.24 {} encompass -1                 \\\n        -58 {} 1.21       alerting {} -93.79 {}                  \\\n        -58 {} 1.21       coldest -96 dramatists 82.3            \\\n        -58 {} 1.21       conducting -87.24 37.56 {}             \\\n        -58 {} 1.21       presenting 51 reformation dignified    \\\n]\n# TODO: Come back and add a few more like the above.\n\n# EVIDENCE-OF: R-18439-38548 In other words, if the left-hand dataset\n# consists of Nleft rows of Mleft columns, and the right-hand dataset of\n# Nright rows of Mright columns, then the cartesian product is a dataset\n# of Nleft&times;Nright rows, each containing Mleft+Mright columns.\n#\n# x1, x2    (Nlhs=3, Nrhs=2)   (Mlhs=2, Mrhs=3)\ndo_join_test e_select-1.4.3.1 { \n  SELECT count(*) FROM x1 %JOIN% x2 \n} [expr 3*2]\ndo_test e_select-1.4.3.2 { \n  expr {[llength [execsql {SELECT * FROM x1, x2}]] / 6}\n} [expr 2+3]\n\n# x2, x3    (Nlhs=2, Nrhs=5)   (Mlhs=3, Mrhs=4)\ndo_join_test e_select-1.4.3.3 { \n  SELECT count(*) FROM x2 %JOIN% x3 \n} [expr 2*5]\ndo_test e_select-1.4.3.4 { \n  expr {[llength [execsql {SELECT * FROM x2 JOIN x3}]] / 10}\n} [expr 3+4]\n\n# x3, x1    (Nlhs=5, Nrhs=3)   (Mlhs=4, Mrhs=2)\ndo_join_test e_select-1.4.3.5 { \n  SELECT count(*) FROM x3 %JOIN% x1 \n} [expr 5*3]\ndo_test e_select-1.4.3.6 { \n  expr {[llength [execsql {SELECT * FROM x3 CROSS JOIN x1}]] / 15}\n} [expr 4+2]\n\n# x3, x3    (Nlhs=5, Nrhs=5)   (Mlhs=4, Mrhs=4)\ndo_join_test e_select-1.4.3.7 { \n  SELECT count(*) FROM x3 %JOIN% x3 \n} [expr 5*5]\ndo_test e_select-1.4.3.8 { \n  expr {[llength [execsql {SELECT * FROM x3 INNER JOIN x3 AS x4}]] / 25}\n} [expr 4+4]\n\n# Some extra cartesian product tests using tables t1 and t2.\n#\ndo_execsql_test e_select-1.4.4.1 { SELECT * FROM t1, t2 } $t1_cross_t2\ndo_execsql_test e_select-1.4.4.2 { SELECT * FROM t1 AS x, t1 AS y} $t1_cross_t1\n\ndo_select_tests e_select-1.4.5 [list                                   \\\n    1 { SELECT * FROM t1 CROSS JOIN t2 }           $t1_cross_t2        \\\n    2 { SELECT * FROM t1 AS y CROSS JOIN t1 AS x } $t1_cross_t1        \\\n    3 { SELECT * FROM t1 INNER JOIN t2 }           $t1_cross_t2        \\\n    4 { SELECT * FROM t1 AS y INNER JOIN t1 AS x } $t1_cross_t1        \\\n]\n\n# EVIDENCE-OF: R-38465-03616 If there is an ON clause then the ON\n# expression is evaluated for each row of the cartesian product as a\n# boolean expression. Only rows for which the expression evaluates to\n# true are included from the dataset.\n#\nforeach {tn select res} [list                                              \\\n    1 { SELECT * FROM t1 %JOIN% t2 ON (1) }       $t1_cross_t2             \\\n    2 { SELECT * FROM t1 %JOIN% t2 ON (0) }       [list]                   \\\n    3 { SELECT * FROM t1 %JOIN% t2 ON (NULL) }    [list]                   \\\n    4 { SELECT * FROM t1 %JOIN% t2 ON ('abc') }   [list]                   \\\n    5 { SELECT * FROM t1 %JOIN% t2 ON ('1ab') }   $t1_cross_t2             \\\n    6 { SELECT * FROM t1 %JOIN% t2 ON (0.9) }     $t1_cross_t2             \\\n    7 { SELECT * FROM t1 %JOIN% t2 ON ('0.9') }   $t1_cross_t2             \\\n    8 { SELECT * FROM t1 %JOIN% t2 ON (0.0) }     [list]                   \\\n                                                                           \\\n    9 { SELECT t1.b, t2.b FROM t1 %JOIN% t2 ON (t1.a = t2.a) }             \\\n      {one I two II three III}                                             \\\n   10 { SELECT t1.b, t2.b FROM t1 %JOIN% t2 ON (t1.a = 'a') }              \\\n      {one I one II one III}                                               \\\n   11 { SELECT t1.b, t2.b \n        FROM t1 %JOIN% t2 ON (CASE WHEN t1.a = 'a' THEN NULL ELSE 1 END) } \\\n      {two I two II two III three I three II three III}                    \\\n] {\n  do_join_test e_select-1.3.$tn $select $res\n}\n\n# EVIDENCE-OF: R-49933-05137 If there is a USING clause then each of the\n# column names specified must exist in the datasets to both the left and\n# right of the join-operator.\n#\ndo_select_tests e_select-1.4 -error {\n  cannot join using column %s - column not present in both tables\n} {\n  1 { SELECT * FROM t1, t3 USING (b) }   \"b\"\n  2 { SELECT * FROM t3, t1 USING (c) }   \"c\"\n  3 { SELECT * FROM t3, (SELECT a AS b, b AS c FROM t1) USING (a) }   \"a\"\n} \n\n# EVIDENCE-OF: R-22776-52830 For each pair of named columns, the\n# expression \"lhs.X = rhs.X\" is evaluated for each row of the cartesian\n# product as a boolean expression. Only rows for which all such\n# expressions evaluates to true are included from the result set.\n#\ndo_select_tests e_select-1.5 {\n  1 { SELECT * FROM t1, t3 USING (a)   }  {a one 1 b two 2}\n  2 { SELECT * FROM t3, t4 USING (a,c) }  {b 2}\n} \n\n# EVIDENCE-OF: R-54046-48600 When comparing values as a result of a\n# USING clause, the normal rules for handling affinities, collation\n# sequences and NULL values in comparisons apply.\n#\n# EVIDENCE-OF: R-38422-04402 The column from the dataset on the\n# left-hand side of the join-operator is considered to be on the\n# left-hand side of the comparison operator (=) for the purposes of\n# collation sequence and affinity precedence.\n#\ndo_execsql_test e_select-1.6.0 {\n  CREATE TABLE t5(a COLLATE nocase, b COLLATE binary);\n  INSERT INTO t5 VALUES('AA', 'cc');\n  INSERT INTO t5 VALUES('BB', 'dd');\n  INSERT INTO t5 VALUES(NULL, NULL);\n  CREATE TABLE t6(a COLLATE binary, b COLLATE nocase);\n  INSERT INTO t6 VALUES('aa', 'cc');\n  INSERT INTO t6 VALUES('bb', 'DD');\n  INSERT INTO t6 VALUES(NULL, NULL);\n} {}\nforeach {tn select res} {\n  1 { SELECT * FROM t5 %JOIN% t6 USING (a) } {AA cc cc BB dd DD}\n  2 { SELECT * FROM t6 %JOIN% t5 USING (a) } {}\n  3 { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) %JOIN% t5 USING (a) } \n    {aa cc cc bb DD dd}\n  4 { SELECT * FROM t5 %JOIN% t6 USING (a,b) } {AA cc}\n  5 { SELECT * FROM t6 %JOIN% t5 USING (a,b) } {}\n} {\n  do_join_test e_select-1.6.$tn $select $res\n}\n\n# EVIDENCE-OF: R-57047-10461 For each pair of columns identified by a\n# USING clause, the column from the right-hand dataset is omitted from\n# the joined dataset.\n#\n# EVIDENCE-OF: R-56132-15700 This is the only difference between a USING\n# clause and its equivalent ON constraint.\n#\nforeach {tn select res} {\n  1a { SELECT * FROM t1 %JOIN% t2 USING (a)      } \n     {a one I b two II c three III}\n  1b { SELECT * FROM t1 %JOIN% t2 ON (t1.a=t2.a) }\n     {a one a I b two b II c three c III}\n\n  2a { SELECT * FROM t3 %JOIN% t4 USING (a)      }  \n     {a 1 {} b 2 2}\n  2b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a) } \n     {a 1 a {} b 2 b 2}\n\n  3a { SELECT * FROM t3 %JOIN% t4 USING (a,c)                  } {b 2}\n  3b { SELECT * FROM t3 %JOIN% t4 ON (t3.a=t4.a AND t3.c=t4.c) } {b 2 b 2}\n\n  4a { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x \n       %JOIN% t5 USING (a) } \n     {aa cc cc bb DD dd}\n  4b { SELECT * FROM (SELECT a COLLATE nocase, b FROM t6) AS x\n       %JOIN% t5 ON (x.a=t5.a) } \n     {aa cc AA cc bb DD BB dd}\n} {\n  do_join_test e_select-1.7.$tn $select $res\n}\n# EVIDENCE-OF: R-42531-52874 If the join-operator is a \"LEFT JOIN\" or\n# \"LEFT OUTER JOIN\", then after the ON or USING filtering clauses have\n# been applied, an extra row is added to the output for each row in the\n# original left-hand input dataset that corresponds to no rows at all in\n# the composite dataset (if any).\n#\ndo_execsql_test e_select-1.8.0 {\n  CREATE TABLE t7(a, b, c);\n  CREATE TABLE t8(a, d, e);\n\n  INSERT INTO t7 VALUES('x', 'ex',  24);\n  INSERT INTO t7 VALUES('y', 'why', 25);\n\n  INSERT INTO t8 VALUES('x', 'abc', 24);\n  INSERT INTO t8 VALUES('z', 'ghi', 26);\n} {}\n\ndo_select_tests e_select-1.8 {\n  1a \"SELECT count(*) FROM t7 JOIN t8 ON (t7.a=t8.a)\" {1}\n  1b \"SELECT count(*) FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)\" {2}\n  2a \"SELECT count(*) FROM t7 JOIN t8 USING (a)\" {1}\n  2b \"SELECT count(*) FROM t7 LEFT JOIN t8 USING (a)\" {2}\n}\n\n\n# EVIDENCE-OF: R-15607-52988 The added rows contain NULL values in the\n# columns that would normally contain values copied from the right-hand\n# input dataset.\n#\ndo_select_tests e_select-1.9 {\n  1a \"SELECT * FROM t7 JOIN t8 ON (t7.a=t8.a)\" {x ex 24 x abc 24}\n  1b \"SELECT * FROM t7 LEFT JOIN t8 ON (t7.a=t8.a)\" \n     {x ex 24 x abc 24 y why 25 {} {} {}}\n  2a \"SELECT * FROM t7 JOIN t8 USING (a)\" {x ex 24 abc 24}\n  2b \"SELECT * FROM t7 LEFT JOIN t8 USING (a)\" {x ex 24 abc 24 y why 25 {} {}}\n}\n\n# EVIDENCE-OF: R-04932-55942 If the NATURAL keyword is in the\n# join-operator then an implicit USING clause is added to the\n# join-constraints. The implicit USING clause contains each of the\n# column names that appear in both the left and right-hand input\n# datasets.\n#\ndo_select_tests e_select-1-10 {\n  1a \"SELECT * FROM t7 JOIN t8 USING (a)\"        {x ex 24 abc 24}\n  1b \"SELECT * FROM t7 NATURAL JOIN t8\"          {x ex 24 abc 24}\n\n  2a \"SELECT * FROM t8 JOIN t7 USING (a)\"        {x abc 24 ex 24}\n  2b \"SELECT * FROM t8 NATURAL JOIN t7\"          {x abc 24 ex 24}\n\n  3a \"SELECT * FROM t7 LEFT JOIN t8 USING (a)\"   {x ex 24 abc 24 y why 25 {} {}}\n  3b \"SELECT * FROM t7 NATURAL LEFT JOIN t8\"     {x ex 24 abc 24 y why 25 {} {}}\n\n  4a \"SELECT * FROM t8 LEFT JOIN t7 USING (a)\"   {x abc 24 ex 24 z ghi 26 {} {}}\n  4b \"SELECT * FROM t8 NATURAL LEFT JOIN t7\"     {x abc 24 ex 24 z ghi 26 {} {}}\n\n  5a \"SELECT * FROM t3 JOIN t4 USING (a,c)\"      {b 2}\n  5b \"SELECT * FROM t3 NATURAL JOIN t4\"          {b 2}\n\n  6a \"SELECT * FROM t3 LEFT JOIN t4 USING (a,c)\" {a 1 b 2}\n  6b \"SELECT * FROM t3 NATURAL LEFT JOIN t4\"     {a 1 b 2}\n} \n\n# EVIDENCE-OF: R-49566-01570 If the left and right-hand input datasets\n# feature no common column names, then the NATURAL keyword has no effect\n# on the results of the join.\n#\ndo_execsql_test e_select-1.11.0 {\n  CREATE TABLE t10(x, y);\n  INSERT INTO t10 VALUES(1, 'true');\n  INSERT INTO t10 VALUES(0, 'false');\n} {}\ndo_select_tests e_select-1-11 {\n  1a \"SELECT a, x FROM t1 CROSS JOIN t10\" {a 1 a 0 b 1 b 0 c 1 c 0}\n  1b \"SELECT a, x FROM t1 NATURAL CROSS JOIN t10\" {a 1 a 0 b 1 b 0 c 1 c 0}\n}\n\n# EVIDENCE-OF: R-39625-59133 A USING or ON clause may not be added to a\n# join that specifies the NATURAL keyword.\n#\nforeach {tn sql} {\n  1 {SELECT * FROM t1 NATURAL LEFT JOIN t2 USING (a)}\n  2 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (t1.a=t2.a)}\n  3 {SELECT * FROM t1 NATURAL LEFT JOIN t2 ON (45)}\n} {\n  do_catchsql_test e_select-1.12.$tn \"\n    $sql\n  \" {1 {a NATURAL join may not have an ON or USING clause}}\n}\n\n#-------------------------------------------------------------------------\n# The next block of tests - e_select-3.* - concentrate on verifying \n# statements made regarding WHERE clause processing.\n#\ndrop_all_tables\ndo_execsql_test e_select-3.0 {\n  CREATE TABLE x1(k, x, y, z);\n  INSERT INTO x1 VALUES(1, 'relinquished', 'aphasia', 78.43);\n  INSERT INTO x1 VALUES(2, X'A8E8D66F',    X'07CF',   -81);\n  INSERT INTO x1 VALUES(3, -22,            -27.57,    NULL);\n  INSERT INTO x1 VALUES(4, NULL,           'bygone',  'picky');\n  INSERT INTO x1 VALUES(5, NULL,           96.28,     NULL);\n  INSERT INTO x1 VALUES(6, 0,              1,         2);\n\n  CREATE TABLE x2(k, x, y2);\n  INSERT INTO x2 VALUES(1, 50, X'B82838');\n  INSERT INTO x2 VALUES(5, 84.79, 65.88);\n  INSERT INTO x2 VALUES(3, -22, X'0E1BE452A393');\n  INSERT INTO x2 VALUES(7, 'mistrusted', 'standardized');\n} {}\n\n# EVIDENCE-OF: R-60775-64916 If a WHERE clause is specified, the WHERE\n# expression is evaluated for each row in the input data as a boolean\n# expression. Only rows for which the WHERE clause expression evaluates\n# to true are included from the dataset before continuing.\n#\ndo_execsql_test e_select-3.1.1 { SELECT k FROM x1 WHERE x }         {3}\ndo_execsql_test e_select-3.1.2 { SELECT k FROM x1 WHERE y }         {3 5 6}\ndo_execsql_test e_select-3.1.3 { SELECT k FROM x1 WHERE z }         {1 2 6}\ndo_execsql_test e_select-3.1.4 { SELECT k FROM x1 WHERE '1'||z    } {1 2 4 6}\ndo_execsql_test e_select-3.1.5 { SELECT k FROM x1 WHERE x IS NULL } {4 5}\ndo_execsql_test e_select-3.1.6 { SELECT k FROM x1 WHERE z - 78.43 } {2 4 6}\n\ndo_execsql_test e_select-3.2.1a {\n  SELECT k FROM x1 LEFT JOIN x2 USING(k)\n} {1 2 3 4 5 6}\ndo_execsql_test e_select-3.2.1b {\n  SELECT k FROM x1 LEFT JOIN x2 USING(k) WHERE x2.k\n} {1 3 5}\ndo_execsql_test e_select-3.2.2 {\n  SELECT k FROM x1 LEFT JOIN x2 USING(k) WHERE x2.k IS NULL\n} {2 4 6}\n\ndo_execsql_test e_select-3.2.3 {\n  SELECT k FROM x1 NATURAL JOIN x2 WHERE x2.k\n} {3}\ndo_execsql_test e_select-3.2.4 {\n  SELECT k FROM x1 NATURAL JOIN x2 WHERE x2.k-3\n} {}\n\n#-------------------------------------------------------------------------\n# Tests below this point are focused on verifying the testable statements\n# related to caculating the result rows of a simple SELECT statement.\n#\n\ndrop_all_tables\ndo_execsql_test e_select-4.0 {\n  CREATE TABLE z1(a, b, c);\n  CREATE TABLE z2(d, e);\n  CREATE TABLE z3(a, b);\n\n  INSERT INTO z1 VALUES(51.65, -59.58, 'belfries');\n  INSERT INTO z1 VALUES(-5, NULL, 75);\n  INSERT INTO z1 VALUES(-2.2, -23.18, 'suiters');\n  INSERT INTO z1 VALUES(NULL, 67, 'quartets');\n  INSERT INTO z1 VALUES(-1.04, -32.3, 'aspen');\n  INSERT INTO z1 VALUES(63, 'born', -26);\n\n  INSERT INTO z2 VALUES(NULL, 21);\n  INSERT INTO z2 VALUES(36, 6);\n\n  INSERT INTO z3 VALUES('subsistence', 'gauze');\n  INSERT INTO z3 VALUES(49.17, -67);\n} {}\n\n# EVIDENCE-OF: R-36327-17224 If a result expression is the special\n# expression \"*\" then all columns in the input data are substituted for\n# that one expression.\n#\n# EVIDENCE-OF: R-43693-30522 If the expression is the alias of a table\n# or subquery in the FROM clause followed by \".*\" then all columns from\n# the named table or subquery are substituted for the single expression.\n#\ndo_select_tests e_select-4.1 {\n  1  \"SELECT * FROM z1 LIMIT 1\"             {51.65 -59.58 belfries}\n  2  \"SELECT * FROM z1,z2 LIMIT 1\"          {51.65 -59.58 belfries {} 21}\n  3  \"SELECT z1.* FROM z1,z2 LIMIT 1\"       {51.65 -59.58 belfries}\n  4  \"SELECT z2.* FROM z1,z2 LIMIT 1\"       {{} 21}\n  5  \"SELECT z2.*, z1.* FROM z1,z2 LIMIT 1\" {{} 21 51.65 -59.58 belfries}\n\n  6  \"SELECT count(*), * FROM z1\"           {6 63 born -26}\n  7  \"SELECT max(a), * FROM z1\"             {63 63 born -26}\n  8  \"SELECT *, min(a) FROM z1\"             {-5 {} 75 -5}\n\n  9  \"SELECT *,* FROM z1,z2 LIMIT 1\" {        \n     51.65 -59.58 belfries {} 21 51.65 -59.58 belfries {} 21\n  }\n  10 \"SELECT z1.*,z1.* FROM z2,z1 LIMIT 1\" {        \n     51.65 -59.58 belfries 51.65 -59.58 belfries\n  }\n}\n\n# EVIDENCE-OF: R-38023-18396 It is an error to use a \"*\" or \"alias.*\"\n# expression in any context other than a result expression list.\n#\n# EVIDENCE-OF: R-44324-41166 It is also an error to use a \"*\" or\n# \"alias.*\" expression in a simple SELECT query that does not have a\n# FROM clause.\n#\nforeach {tn select err} {\n  1.1  \"SELECT a, b, c FROM z1 WHERE *\"    {near \"*\": syntax error}\n  1.2  \"SELECT a, b, c FROM z1 GROUP BY *\" {near \"*\": syntax error}\n  1.3  \"SELECT 1 + * FROM z1\"              {near \"*\": syntax error}\n  1.4  \"SELECT * + 1 FROM z1\"              {near \"+\": syntax error}\n\n  2.1 \"SELECT *\" {no tables specified}\n  2.2 \"SELECT * WHERE 1\" {no tables specified}\n  2.3 \"SELECT * WHERE 0\" {no tables specified}\n  2.4 \"SELECT count(*), *\" {no tables specified}\n} {\n  do_catchsql_test e_select-4.2.$tn $select [list 1 $err]\n}\n\n# EVIDENCE-OF: R-08669-22397 The number of columns in the rows returned\n# by a simple SELECT statement is equal to the number of expressions in\n# the result expression list after substitution of * and alias.*\n# expressions.\n#\nforeach {tn select nCol} {\n  1   \"SELECT * FROM z1\"   3\n  2   \"SELECT * FROM z1 NATURAL JOIN z3\"            3\n  3   \"SELECT z1.* FROM z1 NATURAL JOIN z3\"         3\n  4   \"SELECT z3.* FROM z1 NATURAL JOIN z3\"         2\n  5   \"SELECT z1.*, z3.* FROM z1 NATURAL JOIN z3\"   5\n  6   \"SELECT 1, 2, z1.* FROM z1\"                   5\n  7   \"SELECT a, *, b, c FROM z1\"                   6\n} {\n  set ::stmt [sqlite3_prepare_v2 db $select -1 DUMMY]\n  do_test e_select-4.3.$tn { sqlite3_column_count $::stmt } $nCol\n  sqlite3_finalize $::stmt\n}\n\n\n\n# In lang_select.html, a non-aggregate query is defined as any simple SELECT\n# that has no GROUP BY clause and no aggregate expressions in the result\n# expression list. Other queries are aggregate queries. Test cases\n# e_select-4.4.* through e_select-4.12.*, inclusive, which test the part of\n# simple SELECT that is different for aggregate and non-aggregate queries\n# verify (in a way) that these definitions are consistent:\n#\n# EVIDENCE-OF: R-20637-43463 A simple SELECT statement is an aggregate\n# query if it contains either a GROUP BY clause or one or more aggregate\n# functions in the result-set.\n#\n# EVIDENCE-OF: R-23155-55597 Otherwise, if a simple SELECT contains no\n# aggregate functions or a GROUP BY clause, it is a non-aggregate query.\n#\n\n# EVIDENCE-OF: R-44050-47362 If the SELECT statement is a non-aggregate\n# query, then each expression in the result expression list is evaluated\n# for each row in the dataset filtered by the WHERE clause.\n#\ndo_select_tests e_select-4.4 {\n  1 \"SELECT a, b FROM z1\"\n    {51.65 -59.58 -5 {} -2.2 -23.18 {} 67 -1.04 -32.3 63 born}\n\n  2 \"SELECT a IS NULL, b+1, * FROM z1\" {\n        0 -58.58   51.65 -59.58 belfries\n        0 {}       -5 {} 75            \n        0 -22.18   -2.2 -23.18 suiters\n        1 68       {} 67 quartets    \n        0 -31.3    -1.04 -32.3 aspen\n        0 1        63 born -26\n  }\n\n  3 \"SELECT 32*32, d||e FROM z2\" {1024 {} 1024 366}\n}\n\n\n# Test cases e_select-4.5.* and e_select-4.6.* together show that:\n#\n# EVIDENCE-OF: R-51988-01124 The single row of result-set data created\n# by evaluating the aggregate and non-aggregate expressions in the\n# result-set forms the result of an aggregate query without a GROUP BY\n# clause.\n#\n\n# EVIDENCE-OF: R-57629-25253 If the SELECT statement is an aggregate\n# query without a GROUP BY clause, then each aggregate expression in the\n# result-set is evaluated once across the entire dataset.\n#\ndo_select_tests e_select-4.5 {\n  1 \"SELECT count(a), max(a), count(b), max(b) FROM z1\"      {5 63 5 born}\n  2 \"SELECT count(*), max(1)\"                                {1 1}\n\n  3 \"SELECT sum(b+1) FROM z1 NATURAL LEFT JOIN z3\"           {-43.06}\n  4 \"SELECT sum(b+2) FROM z1 NATURAL LEFT JOIN z3\"           {-38.06}\n  5 \"SELECT sum(b IS NOT NULL) FROM z1 NATURAL LEFT JOIN z3\" {5}\n}\n\n# EVIDENCE-OF: R-26684-40576 Each non-aggregate expression in the\n# result-set is evaluated once for an arbitrarily selected row of the\n# dataset.\n#\n# EVIDENCE-OF: R-27994-60376 The same arbitrarily selected row is used\n# for each non-aggregate expression.\n#\n#   Note: The results of many of the queries in this block of tests are\n#   technically undefined, as the documentation does not specify which row\n#   SQLite will arbitrarily select to use for the evaluation of the\n#   non-aggregate expressions.\n#\ndrop_all_tables\ndo_execsql_test e_select-4.6.0 {\n  CREATE TABLE a1(one PRIMARY KEY, two);\n  INSERT INTO a1 VALUES(1, 1);\n  INSERT INTO a1 VALUES(2, 3);\n  INSERT INTO a1 VALUES(3, 6);\n  INSERT INTO a1 VALUES(4, 10);\n\n  CREATE TABLE a2(one PRIMARY KEY, three);\n  INSERT INTO a2 VALUES(1, 1);\n  INSERT INTO a2 VALUES(3, 2);\n  INSERT INTO a2 VALUES(6, 3);\n  INSERT INTO a2 VALUES(10, 4);\n} {}\ndo_select_tests e_select-4.6 {\n  1 \"SELECT one, two, count(*) FROM a1\"                        {4 10 4} \n  2 \"SELECT one, two, count(*) FROM a1 WHERE one<3\"            {2 3 2} \n  3 \"SELECT one, two, count(*) FROM a1 WHERE one>3\"            {4 10 1} \n  4 \"SELECT *, count(*) FROM a1 JOIN a2\"                       {4 10 10 4 16} \n  5 \"SELECT *, sum(three) FROM a1 NATURAL JOIN a2\"             {3 6 2 3}\n  6 \"SELECT *, sum(three) FROM a1 NATURAL JOIN a2\"             {3 6 2 3}\n  7 \"SELECT group_concat(three, ''), a1.* FROM a1 NATURAL JOIN a2\" {12 3 6}\n}\n\n# EVIDENCE-OF: R-04486-07266 Or, if the dataset contains zero rows, then\n# each non-aggregate expression is evaluated against a row consisting\n# entirely of NULL values.\n#\ndo_select_tests e_select-4.7 {\n  1  \"SELECT one, two, count(*) FROM a1 WHERE 0\"           {{} {} 0}\n  2  \"SELECT sum(two), * FROM a1, a2 WHERE three>5\"        {{} {} {} {} {}}\n  3  \"SELECT max(one) IS NULL, one IS NULL, two IS NULL FROM a1 WHERE two=7\" {\n    1 1 1\n  }\n} \n\n# EVIDENCE-OF: R-64138-28774 An aggregate query without a GROUP BY\n# clause always returns exactly one row of data, even if there are zero\n# rows of input data.\n#\nforeach {tn select} {\n  8.1  \"SELECT count(*) FROM a1\"\n  8.2  \"SELECT count(*) FROM a1 WHERE 0\"\n  8.3  \"SELECT count(*) FROM a1 WHERE 1\"\n  8.4  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 1\"\n  8.5  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 0\"\n} {\n  # Set $nRow to the number of rows returned by $select:\n  set ::stmt [sqlite3_prepare_v2 db $select -1 DUMMY]\n  set nRow 0\n  while {\"SQLITE_ROW\" == [sqlite3_step $::stmt]} { incr nRow }\n  set rc [sqlite3_finalize $::stmt]\n\n  # Test that $nRow==1 and that statement execution was successful \n  # (rc==SQLITE_OK).\n  do_test e_select-4.$tn [list list $rc $nRow] {SQLITE_OK 1}\n}\n\ndrop_all_tables\ndo_execsql_test e_select-4.9.0 {\n  CREATE TABLE b1(one PRIMARY KEY, two);\n  INSERT INTO b1 VALUES(1, 'o');\n  INSERT INTO b1 VALUES(4, 'f');\n  INSERT INTO b1 VALUES(3, 't');\n  INSERT INTO b1 VALUES(2, 't');\n  INSERT INTO b1 VALUES(5, 'f');\n  INSERT INTO b1 VALUES(7, 's');\n  INSERT INTO b1 VALUES(6, 's');\n\n  CREATE TABLE b2(x, y);\n  INSERT INTO b2 VALUES(NULL, 0);\n  INSERT INTO b2 VALUES(NULL, 1);\n  INSERT INTO b2 VALUES('xyz', 2);\n  INSERT INTO b2 VALUES('abc', 3);\n  INSERT INTO b2 VALUES('xyz', 4);\n\n  CREATE TABLE b3(a COLLATE nocase, b COLLATE binary);\n  INSERT INTO b3 VALUES('abc', 'abc');\n  INSERT INTO b3 VALUES('aBC', 'aBC');\n  INSERT INTO b3 VALUES('Def', 'Def');\n  INSERT INTO b3 VALUES('dEF', 'dEF');\n} {}\n\n# EVIDENCE-OF: R-07284-35990 If the SELECT statement is an aggregate\n# query with a GROUP BY clause, then each of the expressions specified\n# as part of the GROUP BY clause is evaluated for each row of the\n# dataset. Each row is then assigned to a \"group\" based on the results;\n# rows for which the results of evaluating the GROUP BY expressions are\n# the same get assigned to the same group.\n#\n#   These tests also show that the following is not untrue:\n#\n# EVIDENCE-OF: R-25883-55063 The expressions in the GROUP BY clause do\n# not have to be expressions that appear in the result.\n#\ndo_select_tests e_select-4.9 {\n  1  \"SELECT group_concat(one), two FROM b1 GROUP BY two\" {\n    /#,# f   1 o   #,#   s #,# t/\n  }\n  2  \"SELECT group_concat(one), sum(one) FROM b1 GROUP BY (one>4)\" {\n    1,2,3,4 10    5,6,7 18\n  }\n  3  \"SELECT group_concat(one) FROM b1 GROUP BY (two>'o'), one%2\" {\n    4  1,5    2,6   3,7\n  }\n  4  \"SELECT group_concat(one) FROM b1 GROUP BY (one==2 OR two=='o')\" {\n    4,3,5,7,6    1,2\n  }\n}\n\n# EVIDENCE-OF: R-14926-50129 For the purposes of grouping rows, NULL\n# values are considered equal.\n#\ndo_select_tests e_select-4.10 {\n  1  \"SELECT group_concat(y) FROM b2 GROUP BY x\" {/#,#   3   #,#/}\n  2  \"SELECT count(*) FROM b2 GROUP BY CASE WHEN y<4 THEN NULL ELSE 0 END\" {4 1}\n} \n\n# EVIDENCE-OF: R-10470-30318 The usual rules for selecting a collation\n# sequence with which to compare text values apply when evaluating\n# expressions in a GROUP BY clause.\n#\ndo_select_tests e_select-4.11 {\n  1  \"SELECT count(*) FROM b3 GROUP BY b\"      {1 1 1 1}\n  2  \"SELECT count(*) FROM b3 GROUP BY a\"      {2 2}\n  3  \"SELECT count(*) FROM b3 GROUP BY +b\"     {1 1 1 1}\n  4  \"SELECT count(*) FROM b3 GROUP BY +a\"     {2 2}\n  5  \"SELECT count(*) FROM b3 GROUP BY b||''\"  {1 1 1 1}\n  6  \"SELECT count(*) FROM b3 GROUP BY a||''\"  {1 1 1 1}\n}\n\n# EVIDENCE-OF: R-63573-50730 The expressions in a GROUP BY clause may\n# not be aggregate expressions.\n#\nforeach {tn select} {\n  12.1  \"SELECT * FROM b3 GROUP BY count(*)\"\n  12.2  \"SELECT max(a) FROM b3 GROUP BY max(b)\"\n  12.3  \"SELECT group_concat(a) FROM b3 GROUP BY a, max(b)\"\n} {\n  set res {1 {aggregate functions are not allowed in the GROUP BY clause}}\n  do_catchsql_test e_select-4.$tn $select $res\n}\n\n# EVIDENCE-OF: R-31537-00101 If a HAVING clause is specified, it is\n# evaluated once for each group of rows as a boolean expression. If the\n# result of evaluating the HAVING clause is false, the group is\n# discarded.\n#\n#   This requirement is tested by all e_select-4.13.* tests.\n#\n# EVIDENCE-OF: R-04132-09474 If the HAVING clause is an aggregate\n# expression, it is evaluated across all rows in the group.\n#\n#   Tested by e_select-4.13.1.*\n#\n# EVIDENCE-OF: R-28262-47447 If a HAVING clause is a non-aggregate\n# expression, it is evaluated with respect to an arbitrarily selected\n# row from the group.\n#\n#   Tested by e_select-4.13.2.*\n#\n#   Tests in this block also show that this is not untrue:\n#\n# EVIDENCE-OF: R-55403-13450 The HAVING expression may refer to values,\n# even aggregate functions, that are not in the result.\n#\ndo_execsql_test e_select-4.13.0 {\n  CREATE TABLE c1(up, down);\n  INSERT INTO c1 VALUES('x', 1);\n  INSERT INTO c1 VALUES('x', 2);\n  INSERT INTO c1 VALUES('x', 4);\n  INSERT INTO c1 VALUES('x', 8);\n  INSERT INTO c1 VALUES('y', 16);\n  INSERT INTO c1 VALUES('y', 32);\n\n  CREATE TABLE c2(i, j);\n  INSERT INTO c2 VALUES(1, 0);\n  INSERT INTO c2 VALUES(2, 1);\n  INSERT INTO c2 VALUES(3, 3);\n  INSERT INTO c2 VALUES(4, 6);\n  INSERT INTO c2 VALUES(5, 10);\n  INSERT INTO c2 VALUES(6, 15);\n  INSERT INTO c2 VALUES(7, 21);\n  INSERT INTO c2 VALUES(8, 28);\n  INSERT INTO c2 VALUES(9, 36);\n\n  CREATE TABLE c3(i PRIMARY KEY, k TEXT);\n  INSERT INTO c3 VALUES(1,  'hydrogen');\n  INSERT INTO c3 VALUES(2,  'helium');\n  INSERT INTO c3 VALUES(3,  'lithium');\n  INSERT INTO c3 VALUES(4,  'beryllium');\n  INSERT INTO c3 VALUES(5,  'boron');\n  INSERT INTO c3 VALUES(94, 'plutonium');\n} {}\n\ndo_select_tests e_select-4.13 {\n  1.1  \"SELECT up FROM c1 GROUP BY up HAVING count(*)>3\" {x}\n  1.2  \"SELECT up FROM c1 GROUP BY up HAVING sum(down)>16\" {y}\n  1.3  \"SELECT up FROM c1 GROUP BY up HAVING sum(down)<16\" {x}\n  1.4  \"SELECT up||down FROM c1 GROUP BY (down<5) HAVING max(down)<10\" {x4}\n\n  2.1  \"SELECT up FROM c1 GROUP BY up HAVING down>10\" {y}\n  2.2  \"SELECT up FROM c1 GROUP BY up HAVING up='y'\"  {y}\n\n  2.3  \"SELECT i, j FROM c2 GROUP BY i>4 HAVING i>6\"  {9 36}\n}\n\n# EVIDENCE-OF: R-23927-54081 Each expression in the result-set is then\n# evaluated once for each group of rows.\n#\n# EVIDENCE-OF: R-53735-47017 If the expression is an aggregate\n# expression, it is evaluated across all rows in the group.\n#\ndo_select_tests e_select-4.15 {\n  1  \"SELECT sum(down) FROM c1 GROUP BY up\" {15 48}\n  2  \"SELECT sum(j), max(j) FROM c2 GROUP BY (i%3)\"     {54 36 27 21 39 28}\n  3  \"SELECT sum(j), max(j) FROM c2 GROUP BY (j%2)\"     {80 36 40 21}\n  4  \"SELECT 1+sum(j), max(j)+1 FROM c2 GROUP BY (j%2)\" {81 37 41 22}\n  5  \"SELECT count(*), round(avg(i),2) FROM c1, c2 ON (i=down) GROUP BY j%2\"\n        {3 4.33 1 2.0}\n} \n\n# EVIDENCE-OF: R-62913-19830 Otherwise, it is evaluated against a single\n# arbitrarily chosen row from within the group.\n#\n# EVIDENCE-OF: R-53924-08809 If there is more than one non-aggregate\n# expression in the result-set, then all such expressions are evaluated\n# for the same row.\n#\ndo_select_tests e_select-4.15 {\n  1  \"SELECT i, j FROM c2 GROUP BY i%2\"             {8 28   9 36}\n  2  \"SELECT i, j FROM c2 GROUP BY i%2 HAVING j<30\" {8 28}\n  3  \"SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30\" {9 36}\n  4  \"SELECT i, j FROM c2 GROUP BY i%2 HAVING j>30\" {9 36}\n  5  \"SELECT count(*), i, k FROM c2 NATURAL JOIN c3 GROUP BY substr(k, 1, 1)\"\n        {2 5 boron   2 2 helium   1 3 lithium}\n} \n\n# EVIDENCE-OF: R-19334-12811 Each group of input dataset rows\n# contributes a single row to the set of result rows.\n#\n# EVIDENCE-OF: R-02223-49279 Subject to filtering associated with the\n# DISTINCT keyword, the number of rows returned by an aggregate query\n# with a GROUP BY clause is the same as the number of groups of rows\n# produced by applying the GROUP BY and HAVING clauses to the filtered\n# input dataset.\n#\ndo_select_tests e_select.4.16 -count {\n  1  \"SELECT i, j FROM c2 GROUP BY i%2\"          2\n  2  \"SELECT i, j FROM c2 GROUP BY i\"            9\n  3  \"SELECT i, j FROM c2 GROUP BY i HAVING i<5\" 4\n} \n\n#-------------------------------------------------------------------------\n# The following tests attempt to verify statements made regarding the ALL\n# and DISTINCT keywords.\n#\ndrop_all_tables\ndo_execsql_test e_select-5.1.0 {\n  CREATE TABLE h1(a, b);\n  INSERT INTO h1 VALUES(1, 'one');\n  INSERT INTO h1 VALUES(1, 'I');\n  INSERT INTO h1 VALUES(1, 'i');\n  INSERT INTO h1 VALUES(4, 'four');\n  INSERT INTO h1 VALUES(4, 'IV');\n  INSERT INTO h1 VALUES(4, 'iv');\n\n  CREATE TABLE h2(x COLLATE nocase);\n  INSERT INTO h2 VALUES('One');\n  INSERT INTO h2 VALUES('Two');\n  INSERT INTO h2 VALUES('Three');\n  INSERT INTO h2 VALUES('Four');\n  INSERT INTO h2 VALUES('one');\n  INSERT INTO h2 VALUES('two');\n  INSERT INTO h2 VALUES('three');\n  INSERT INTO h2 VALUES('four');\n\n  CREATE TABLE h3(c, d);\n  INSERT INTO h3 VALUES(1, NULL);\n  INSERT INTO h3 VALUES(2, NULL);\n  INSERT INTO h3 VALUES(3, NULL);\n  INSERT INTO h3 VALUES(4, '2');\n  INSERT INTO h3 VALUES(5, NULL);\n  INSERT INTO h3 VALUES(6, '2,3');\n  INSERT INTO h3 VALUES(7, NULL);\n  INSERT INTO h3 VALUES(8, '2,4');\n  INSERT INTO h3 VALUES(9, '3');\n} {}\n\n# EVIDENCE-OF: R-60770-10612 One of the ALL or DISTINCT keywords may\n# follow the SELECT keyword in a simple SELECT statement.\n#\ndo_select_tests e_select-5.1 {\n  1   \"SELECT ALL a FROM h1\"      {1 1 1 4 4 4}\n  2   \"SELECT DISTINCT a FROM h1\" {1 4}\n}\n\n# EVIDENCE-OF: R-08861-34280 If the simple SELECT is a SELECT ALL, then\n# the entire set of result rows are returned by the SELECT.\n#\n# EVIDENCE-OF: R-01256-01950 If neither ALL or DISTINCT are present,\n# then the behavior is as if ALL were specified.\n#\n# EVIDENCE-OF: R-14442-41305 If the simple SELECT is a SELECT DISTINCT,\n# then duplicate rows are removed from the set of result rows before it\n# is returned.\n#\n#   The three testable statements above are tested by e_select-5.2.*,\n#   5.3.* and 5.4.* respectively.\n#\ndo_select_tests e_select-5 {\n  3.1 \"SELECT ALL x FROM h2\" {One Two Three Four one two three four}\n  3.2 \"SELECT ALL x FROM h1, h2 ON (x=b)\" {One one Four four}\n\n  3.1 \"SELECT x FROM h2\" {One Two Three Four one two three four}\n  3.2 \"SELECT x FROM h1, h2 ON (x=b)\" {One one Four four}\n\n  4.1 \"SELECT DISTINCT x FROM h2\" {One Two Three Four}\n  4.2 \"SELECT DISTINCT x FROM h1, h2 ON (x=b)\" {One Four}\n} \n\n# EVIDENCE-OF: R-02054-15343 For the purposes of detecting duplicate\n# rows, two NULL values are considered to be equal.\n#\ndo_select_tests e_select-5.5 {\n  1  \"SELECT DISTINCT d FROM h3\" {{} 2 2,3 2,4 3}\n}\n\n# EVIDENCE-OF: R-47709-27231 The usual rules apply for selecting a\n# collation sequence to compare text values.\n#\ndo_select_tests e_select-5.6 {\n  1  \"SELECT DISTINCT b FROM h1\"                  {one I i four IV iv}\n  2  \"SELECT DISTINCT b COLLATE nocase FROM h1\"   {one I four IV}\n  3  \"SELECT DISTINCT x FROM h2\"                  {One Two Three Four}\n  4  \"SELECT DISTINCT x COLLATE binary FROM h2\"   {\n    One Two Three Four one two three four\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following tests - e_select-7.* - test that statements made to do\n# with compound SELECT statements are correct.\n#\n\n# EVIDENCE-OF: R-39368-64333 In a compound SELECT, all the constituent\n# SELECTs must return the same number of result columns.\n#\n#   All the other tests in this section use compound SELECTs created\n#   using component SELECTs that do return the same number of columns.\n#   So the tests here just show that it is an error to attempt otherwise.\n#\ndrop_all_tables\ndo_execsql_test e_select-7.1.0 {\n  CREATE TABLE j1(a, b, c);\n  CREATE TABLE j2(e, f);\n  CREATE TABLE j3(g);\n} {}\ndo_select_tests e_select-7.1 -error {\n  SELECTs to the left and right of %s do not have the same number of result columns\n} {\n  1   \"SELECT a, b FROM j1    UNION ALL SELECT g FROM j3\"    {{UNION ALL}}\n  2   \"SELECT *    FROM j1    UNION ALL SELECT * FROM j3\"    {{UNION ALL}}\n  3   \"SELECT a, b FROM j1    UNION ALL SELECT g FROM j3\"    {{UNION ALL}}\n  4   \"SELECT a, b FROM j1    UNION ALL SELECT * FROM j3,j2\" {{UNION ALL}}\n  5   \"SELECT *    FROM j3,j2 UNION ALL SELECT a, b FROM j1\" {{UNION ALL}}\n\n  6   \"SELECT a, b FROM j1    UNION SELECT g FROM j3\"        {UNION}\n  7   \"SELECT *    FROM j1    UNION SELECT * FROM j3\"        {UNION}\n  8   \"SELECT a, b FROM j1    UNION SELECT g FROM j3\"        {UNION}\n  9   \"SELECT a, b FROM j1    UNION SELECT * FROM j3,j2\"     {UNION}\n  10  \"SELECT *    FROM j3,j2 UNION SELECT a, b FROM j1\"     {UNION}\n\n  11  \"SELECT a, b FROM j1    INTERSECT SELECT g FROM j3\"    {INTERSECT}\n  12  \"SELECT *    FROM j1    INTERSECT SELECT * FROM j3\"    {INTERSECT}\n  13  \"SELECT a, b FROM j1    INTERSECT SELECT g FROM j3\"    {INTERSECT}\n  14  \"SELECT a, b FROM j1    INTERSECT SELECT * FROM j3,j2\" {INTERSECT}\n  15  \"SELECT *    FROM j3,j2 INTERSECT SELECT a, b FROM j1\" {INTERSECT}\n\n  16  \"SELECT a, b FROM j1    EXCEPT SELECT g FROM j3\"       {EXCEPT}\n  17  \"SELECT *    FROM j1    EXCEPT SELECT * FROM j3\"       {EXCEPT}\n  18  \"SELECT a, b FROM j1    EXCEPT SELECT g FROM j3\"       {EXCEPT}\n  19  \"SELECT a, b FROM j1    EXCEPT SELECT * FROM j3,j2\"    {EXCEPT}\n  20  \"SELECT *    FROM j3,j2 EXCEPT SELECT a, b FROM j1\"    {EXCEPT}\n} \n\n# EVIDENCE-OF: R-01450-11152 As the components of a compound SELECT must\n# be simple SELECT statements, they may not contain ORDER BY or LIMIT\n# clauses.\n# \nforeach {tn select op1 op2} {\n  1   \"SELECT * FROM j1 ORDER BY a UNION ALL SELECT * FROM j2,j3\" \n      {ORDER BY} {UNION ALL}\n  2   \"SELECT count(*) FROM j1 ORDER BY 1 UNION ALL SELECT max(e) FROM j2\"\n      {ORDER BY} {UNION ALL}\n  3   \"SELECT count(*), * FROM j1 ORDER BY 1,2,3 UNION ALL SELECT *,* FROM j2\"\n      {ORDER BY} {UNION ALL}\n  4   \"SELECT * FROM j1 LIMIT 10 UNION ALL SELECT * FROM j2,j3\" \n      LIMIT {UNION ALL}\n  5   \"SELECT * FROM j1 LIMIT 10 OFFSET 5 UNION ALL SELECT * FROM j2,j3\" \n      LIMIT {UNION ALL}\n  6   \"SELECT a FROM j1 LIMIT (SELECT e FROM j2) UNION ALL SELECT g FROM j2,j3\" \n      LIMIT {UNION ALL}\n\n  7   \"SELECT * FROM j1 ORDER BY a UNION SELECT * FROM j2,j3\" \n      {ORDER BY} {UNION}\n  8   \"SELECT count(*) FROM j1 ORDER BY 1 UNION SELECT max(e) FROM j2\"\n      {ORDER BY} {UNION}\n  9   \"SELECT count(*), * FROM j1 ORDER BY 1,2,3 UNION SELECT *,* FROM j2\"\n      {ORDER BY} {UNION}\n  10  \"SELECT * FROM j1 LIMIT 10 UNION SELECT * FROM j2,j3\" \n      LIMIT {UNION}\n  11  \"SELECT * FROM j1 LIMIT 10 OFFSET 5 UNION SELECT * FROM j2,j3\" \n      LIMIT {UNION}\n  12  \"SELECT a FROM j1 LIMIT (SELECT e FROM j2) UNION SELECT g FROM j2,j3\" \n      LIMIT {UNION}\n\n  13  \"SELECT * FROM j1 ORDER BY a EXCEPT SELECT * FROM j2,j3\" \n      {ORDER BY} {EXCEPT}\n  14  \"SELECT count(*) FROM j1 ORDER BY 1 EXCEPT SELECT max(e) FROM j2\"\n      {ORDER BY} {EXCEPT}\n  15  \"SELECT count(*), * FROM j1 ORDER BY 1,2,3 EXCEPT SELECT *,* FROM j2\"\n      {ORDER BY} {EXCEPT}\n  16  \"SELECT * FROM j1 LIMIT 10 EXCEPT SELECT * FROM j2,j3\" \n      LIMIT {EXCEPT}\n  17  \"SELECT * FROM j1 LIMIT 10 OFFSET 5 EXCEPT SELECT * FROM j2,j3\" \n      LIMIT {EXCEPT}\n  18  \"SELECT a FROM j1 LIMIT (SELECT e FROM j2) EXCEPT SELECT g FROM j2,j3\" \n      LIMIT {EXCEPT}\n\n  19  \"SELECT * FROM j1 ORDER BY a INTERSECT SELECT * FROM j2,j3\" \n      {ORDER BY} {INTERSECT}\n  20  \"SELECT count(*) FROM j1 ORDER BY 1 INTERSECT SELECT max(e) FROM j2\"\n      {ORDER BY} {INTERSECT}\n  21  \"SELECT count(*), * FROM j1 ORDER BY 1,2,3 INTERSECT SELECT *,* FROM j2\"\n      {ORDER BY} {INTERSECT}\n  22  \"SELECT * FROM j1 LIMIT 10 INTERSECT SELECT * FROM j2,j3\" \n      LIMIT {INTERSECT}\n  23  \"SELECT * FROM j1 LIMIT 10 OFFSET 5 INTERSECT SELECT * FROM j2,j3\" \n      LIMIT {INTERSECT}\n  24  \"SELECT a FROM j1 LIMIT (SELECT e FROM j2) INTERSECT SELECT g FROM j2,j3\" \n      LIMIT {INTERSECT}\n} {\n  set err \"$op1 clause should come after $op2 not before\"\n  do_catchsql_test e_select-7.2.$tn $select [list 1 $err]\n}\n\n# EVIDENCE-OF: R-45440-25633 ORDER BY and LIMIT clauses may only occur\n# at the end of the entire compound SELECT, and then only if the final\n# element of the compound is not a VALUES clause.\n#\nforeach {tn select} {\n  1   \"SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 ORDER BY a\"\n  2   \"SELECT count(*) FROM j1 UNION ALL SELECT max(e) FROM j2 ORDER BY 1\"\n  3   \"SELECT count(*), * FROM j1 UNION ALL SELECT *,* FROM j2 ORDER BY 1,2,3\"\n  4   \"SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 LIMIT 10\" \n  5   \"SELECT * FROM j1 UNION ALL SELECT * FROM j2,j3 LIMIT 10 OFFSET 5\" \n  6   \"SELECT a FROM j1 UNION ALL SELECT g FROM j2,j3 LIMIT (SELECT 10)\" \n\n  7   \"SELECT * FROM j1 UNION SELECT * FROM j2,j3 ORDER BY a\"\n  8   \"SELECT count(*) FROM j1 UNION SELECT max(e) FROM j2 ORDER BY 1\"\n  8b  \"VALUES('8b') UNION SELECT max(e) FROM j2 ORDER BY 1\"\n  9   \"SELECT count(*), * FROM j1 UNION SELECT *,* FROM j2 ORDER BY 1,2,3\"\n  10  \"SELECT * FROM j1 UNION SELECT * FROM j2,j3 LIMIT 10\" \n  11  \"SELECT * FROM j1 UNION SELECT * FROM j2,j3 LIMIT 10 OFFSET 5\" \n  12  \"SELECT a FROM j1 UNION SELECT g FROM j2,j3 LIMIT (SELECT 10)\" \n\n  13  \"SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 ORDER BY a\"\n  14  \"SELECT count(*) FROM j1 EXCEPT SELECT max(e) FROM j2 ORDER BY 1\"\n  15  \"SELECT count(*), * FROM j1 EXCEPT SELECT *,* FROM j2 ORDER BY 1,2,3\"\n  16  \"SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 LIMIT 10\" \n  17  \"SELECT * FROM j1 EXCEPT SELECT * FROM j2,j3 LIMIT 10 OFFSET 5\" \n  18  \"SELECT a FROM j1 EXCEPT SELECT g FROM j2,j3 LIMIT (SELECT 10)\" \n\n  19  \"SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 ORDER BY a\"\n  20  \"SELECT count(*) FROM j1 INTERSECT SELECT max(e) FROM j2 ORDER BY 1\"\n  21  \"SELECT count(*), * FROM j1 INTERSECT SELECT *,* FROM j2 ORDER BY 1,2,3\"\n  22  \"SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 LIMIT 10\" \n  23  \"SELECT * FROM j1 INTERSECT SELECT * FROM j2,j3 LIMIT 10 OFFSET 5\" \n  24  \"SELECT a FROM j1 INTERSECT SELECT g FROM j2,j3 LIMIT (SELECT 10)\" \n} {\n  do_test e_select-7.3.$tn { catch {execsql $select} msg } 0\n}\nforeach {tn select} {\n  50   \"SELECT * FROM j1 ORDER BY 1 UNION ALL SELECT * FROM j2,j3\"\n  51   \"SELECT * FROM j1 LIMIT 1 UNION ALL SELECT * FROM j2,j3\"\n  52   \"SELECT count(*) FROM j1 UNION ALL VALUES(11) ORDER BY 1\"\n  53   \"SELECT count(*) FROM j1 UNION ALL VALUES(11) LIMIT 1\"\n} {\n  do_test e_select-7.3.$tn { catch {execsql $select} msg } 1\n}\n\n# EVIDENCE-OF: R-08531-36543 A compound SELECT created using UNION ALL\n# operator returns all the rows from the SELECT to the left of the UNION\n# ALL operator, and all the rows from the SELECT to the right of it.\n#\ndrop_all_tables\ndo_execsql_test e_select-7.4.0 {\n  CREATE TABLE q1(a TEXT, b INTEGER, c);\n  CREATE TABLE q2(d NUMBER, e BLOB);\n  CREATE TABLE q3(f REAL, g);\n\n  INSERT INTO q1 VALUES(16, -87.66, NULL);\n  INSERT INTO q1 VALUES('legible', 94, -42.47);\n  INSERT INTO q1 VALUES('beauty', 36, NULL);\n\n  INSERT INTO q2 VALUES('legible', 1);\n  INSERT INTO q2 VALUES('beauty', 2);\n  INSERT INTO q2 VALUES(-65.91, 4);\n  INSERT INTO q2 VALUES('emanating', -16.56);\n\n  INSERT INTO q3 VALUES('beauty', 2);\n  INSERT INTO q3 VALUES('beauty', 2);\n} {}\ndo_select_tests e_select-7.4 {\n  1   {SELECT a FROM q1 UNION ALL SELECT d FROM q2}\n      {16 legible beauty legible beauty -65.91 emanating}\n\n  2   {SELECT * FROM q1 WHERE a=16 UNION ALL SELECT 'x', * FROM q2 WHERE oid=1}\n      {16 -87.66 {} x legible 1}\n\n  3   {SELECT count(*) FROM q1 UNION ALL SELECT min(e) FROM q2} \n      {3 -16.56}\n\n  4   {SELECT * FROM q2 UNION ALL SELECT * FROM q3} \n      {legible 1 beauty 2 -65.91 4 emanating -16.56 beauty 2 beauty 2}\n} \n\n# EVIDENCE-OF: R-20560-39162 The UNION operator works the same way as\n# UNION ALL, except that duplicate rows are removed from the final\n# result set.\n#\ndo_select_tests e_select-7.5 {\n  1   {SELECT a FROM q1 UNION SELECT d FROM q2}\n      {-65.91 16 beauty emanating legible}\n\n  2   {SELECT * FROM q1 WHERE a=16 UNION SELECT 'x', * FROM q2 WHERE oid=1}\n      {16 -87.66 {} x legible 1}\n\n  3   {SELECT count(*) FROM q1 UNION SELECT min(e) FROM q2} \n      {-16.56 3}\n\n  4   {SELECT * FROM q2 UNION SELECT * FROM q3} \n      {-65.91 4 beauty 2 emanating -16.56 legible 1}\n} \n\n# EVIDENCE-OF: R-45764-31737 The INTERSECT operator returns the\n# intersection of the results of the left and right SELECTs.\n#\ndo_select_tests e_select-7.6 {\n  1   {SELECT a FROM q1 INTERSECT SELECT d FROM q2} {beauty legible}\n  2   {SELECT * FROM q2 INTERSECT SELECT * FROM q3} {beauty 2}\n}\n\n# EVIDENCE-OF: R-25787-28949 The EXCEPT operator returns the subset of\n# rows returned by the left SELECT that are not also returned by the\n# right-hand SELECT.\n#\ndo_select_tests e_select-7.7 {\n  1   {SELECT a FROM q1 EXCEPT SELECT d FROM q2} {16}\n\n  2   {SELECT * FROM q2 EXCEPT SELECT * FROM q3} \n      {-65.91 4 emanating -16.56 legible 1}\n}\n\n# EVIDENCE-OF: R-40729-56447 Duplicate rows are removed from the results\n# of INTERSECT and EXCEPT operators before the result set is returned.\n#\ndo_select_tests e_select-7.8 {\n  0   {SELECT * FROM q3} {beauty 2 beauty 2}\n\n  1   {SELECT * FROM q3 INTERSECT SELECT * FROM q3} {beauty 2}\n  2   {SELECT * FROM q3 EXCEPT SELECT a,b FROM q1}  {beauty 2}\n}\n\n# EVIDENCE-OF: R-46765-43362 For the purposes of determining duplicate\n# rows for the results of compound SELECT operators, NULL values are\n# considered equal to other NULL values and distinct from all non-NULL\n# values.\n#\ndb nullvalue null\ndo_select_tests e_select-7.9 {\n  1   {SELECT NULL UNION ALL SELECT NULL} {null null}\n  2   {SELECT NULL UNION     SELECT NULL} {null}\n  3   {SELECT NULL INTERSECT SELECT NULL} {null}\n  4   {SELECT NULL EXCEPT    SELECT NULL} {}\n\n  5   {SELECT NULL UNION ALL SELECT 'ab'} {null ab}\n  6   {SELECT NULL UNION     SELECT 'ab'} {null ab}\n  7   {SELECT NULL INTERSECT SELECT 'ab'} {}\n  8   {SELECT NULL EXCEPT    SELECT 'ab'} {null}\n\n  9   {SELECT NULL UNION ALL SELECT 0} {null 0}\n  10  {SELECT NULL UNION     SELECT 0} {null 0}\n  11  {SELECT NULL INTERSECT SELECT 0} {}\n  12  {SELECT NULL EXCEPT    SELECT 0} {null}\n\n  13  {SELECT c FROM q1 UNION ALL SELECT g FROM q3} {null -42.47 null 2 2}\n  14  {SELECT c FROM q1 UNION     SELECT g FROM q3} {null -42.47 2}\n  15  {SELECT c FROM q1 INTERSECT SELECT g FROM q3} {}\n  16  {SELECT c FROM q1 EXCEPT    SELECT g FROM q3} {null -42.47}\n}\ndb nullvalue {} \n\n# EVIDENCE-OF: R-51232-50224 The collation sequence used to compare two\n# text values is determined as if the columns of the left and right-hand\n# SELECT statements were the left and right-hand operands of the equals\n# (=) operator, except that greater precedence is not assigned to a\n# collation sequence specified with the postfix COLLATE operator.\n#\ndrop_all_tables\ndo_execsql_test e_select-7.10.0 {\n  CREATE TABLE y1(a COLLATE nocase, b COLLATE binary, c);\n  INSERT INTO y1 VALUES('Abc', 'abc', 'aBC');\n} {}\ndo_select_tests e_select-7.10 {\n  1   {SELECT 'abc'                UNION SELECT 'ABC'} {ABC abc}\n  2   {SELECT 'abc' COLLATE nocase UNION SELECT 'ABC'} {ABC}\n  3   {SELECT 'abc'                UNION SELECT 'ABC' COLLATE nocase} {ABC}\n  4   {SELECT 'abc' COLLATE binary UNION SELECT 'ABC' COLLATE nocase} {ABC abc}\n  5   {SELECT 'abc' COLLATE nocase UNION SELECT 'ABC' COLLATE binary} {ABC}\n\n  6   {SELECT a FROM y1 UNION SELECT b FROM y1}                {abc}\n  7   {SELECT b FROM y1 UNION SELECT a FROM y1}                {Abc abc}\n  8   {SELECT a FROM y1 UNION SELECT c FROM y1}                {aBC}\n\n  9   {SELECT a FROM y1 UNION SELECT c COLLATE binary FROM y1} {aBC}\n}\n\n# EVIDENCE-OF: R-32706-07403 No affinity transformations are applied to\n# any values when comparing rows as part of a compound SELECT.\n#\ndrop_all_tables\ndo_execsql_test e_select-7.10.0 {\n  CREATE TABLE w1(a TEXT, b NUMBER);\n  CREATE TABLE w2(a, b TEXT);\n\n  INSERT INTO w1 VALUES('1', 4.1);\n  INSERT INTO w2 VALUES(1, 4.1);\n} {}\n\ndo_select_tests e_select-7.11 {\n  1  { SELECT a FROM w1 UNION SELECT a FROM w2 } {1 1}\n  2  { SELECT a FROM w2 UNION SELECT a FROM w1 } {1 1}\n  3  { SELECT b FROM w1 UNION SELECT b FROM w2 } {4.1 4.1}\n  4  { SELECT b FROM w2 UNION SELECT b FROM w1 } {4.1 4.1}\n\n  5  { SELECT a FROM w1 INTERSECT SELECT a FROM w2 } {}\n  6  { SELECT a FROM w2 INTERSECT SELECT a FROM w1 } {}\n  7  { SELECT b FROM w1 INTERSECT SELECT b FROM w2 } {}\n  8  { SELECT b FROM w2 INTERSECT SELECT b FROM w1 } {}\n\n  9  { SELECT a FROM w1 EXCEPT SELECT a FROM w2 } {1}\n  10 { SELECT a FROM w2 EXCEPT SELECT a FROM w1 } {1}\n  11 { SELECT b FROM w1 EXCEPT SELECT b FROM w2 } {4.1}\n  12 { SELECT b FROM w2 EXCEPT SELECT b FROM w1 } {4.1}\n}\n\n\n# EVIDENCE-OF: R-32562-20566 When three or more simple SELECTs are\n# connected into a compound SELECT, they group from left to right. In\n# other words, if \"A\", \"B\" and \"C\" are all simple SELECT statements, (A\n# op B op C) is processed as ((A op B) op C).\n#\n#   e_select-7.12.1: Precedence of UNION vs. INTERSECT \n#   e_select-7.12.2: Precedence of UNION vs. UNION ALL \n#   e_select-7.12.3: Precedence of UNION vs. EXCEPT\n#   e_select-7.12.4: Precedence of INTERSECT vs. UNION ALL \n#   e_select-7.12.5: Precedence of INTERSECT vs. EXCEPT\n#   e_select-7.12.6: Precedence of UNION ALL vs. EXCEPT\n#   e_select-7.12.7: Check that \"a EXCEPT b EXCEPT c\" is processed as \n#                   \"(a EXCEPT b) EXCEPT c\".\n#\n# The INTERSECT and EXCEPT operations are mutually commutative. So\n# the e_select-7.12.5 test cases do not prove very much.\n#\ndrop_all_tables\ndo_execsql_test e_select-7.12.0 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n  INSERT INTO t1 VALUES(3);\n} {}\nforeach {tn select res} {\n  1a \"(1,2) INTERSECT (1)   UNION     (3)\"   {1 3}\n  1b \"(3)   UNION     (1,2) INTERSECT (1)\"   {1}\n\n  2a \"(1,2) UNION     (3)   UNION ALL (1)\"   {1 2 3 1}\n  2b \"(1)   UNION ALL (3)   UNION     (1,2)\" {1 2 3}\n\n  3a \"(1,2) UNION     (3)   EXCEPT    (1)\"   {2 3}\n  3b \"(1,2) EXCEPT    (3)   UNION     (1)\"   {1 2}\n\n  4a \"(1,2) INTERSECT (1)   UNION ALL (3)\"   {1 3}\n  4b \"(3)   UNION     (1,2) INTERSECT (1)\"   {1}\n\n  5a \"(1,2) INTERSECT (2)   EXCEPT    (2)\"   {}\n  5b \"(2,3) EXCEPT    (2)   INTERSECT (2)\"   {}\n\n  6a \"(2)   UNION ALL (2)   EXCEPT    (2)\"   {}\n  6b \"(2)   EXCEPT    (2)   UNION ALL (2)\"   {2}\n\n  7  \"(2,3) EXCEPT    (2)   EXCEPT    (3)\"   {}\n} {\n  set select [string map {( {SELECT x FROM t1 WHERE x IN (}} $select]\n  do_execsql_test e_select-7.12.$tn $select [list {*}$res]\n}\n\n\n#-------------------------------------------------------------------------\n# ORDER BY clauses\n#\n\ndrop_all_tables\ndo_execsql_test e_select-8.1.0 {\n  CREATE TABLE d1(x, y, z);\n\n  INSERT INTO d1 VALUES(1, 2, 3);\n  INSERT INTO d1 VALUES(2, 5, -1);\n  INSERT INTO d1 VALUES(1, 2, 8);\n  INSERT INTO d1 VALUES(1, 2, 7);\n  INSERT INTO d1 VALUES(2, 4, 93);\n  INSERT INTO d1 VALUES(1, 2, -20);\n  INSERT INTO d1 VALUES(1, 4, 93);\n  INSERT INTO d1 VALUES(1, 5, -1);\n\n  CREATE TABLE d2(a, b);\n  INSERT INTO d2 VALUES('gently', 'failings');\n  INSERT INTO d2 VALUES('commercials', 'bathrobe');\n  INSERT INTO d2 VALUES('iterate', 'sexton');\n  INSERT INTO d2 VALUES('babied', 'charitableness');\n  INSERT INTO d2 VALUES('solemnness', 'annexed');\n  INSERT INTO d2 VALUES('rejoicing', 'liabilities');\n  INSERT INTO d2 VALUES('pragmatist', 'guarded');\n  INSERT INTO d2 VALUES('barked', 'interrupted');\n  INSERT INTO d2 VALUES('reemphasizes', 'reply');\n  INSERT INTO d2 VALUES('lad', 'relenting');\n} {}\n\n# EVIDENCE-OF: R-44988-41064 Rows are first sorted based on the results\n# of evaluating the left-most expression in the ORDER BY list, then ties\n# are broken by evaluating the second left-most expression and so on.\n#\ndo_select_tests e_select-8.1 {\n  1  \"SELECT * FROM d1 ORDER BY x, y, z\" {\n     1 2 -20    1 2 3    1 2 7    1 2 8    \n     1 4  93    1 5 -1   2 4 93   2 5 -1\n  }\n}\n\n# EVIDENCE-OF: R-06617-54588 Each ORDER BY expression may be optionally\n# followed by one of the keywords ASC (smaller values are returned\n# first) or DESC (larger values are returned first).\n#\n#   Test cases e_select-8.2.* test the above.\n#\n# EVIDENCE-OF: R-18705-33393 If neither ASC or DESC are specified, rows\n# are sorted in ascending (smaller values first) order by default.\n#\n#   Test cases e_select-8.3.* test the above. All 8.3 test cases are\n#   copies of 8.2 test cases with the explicit \"ASC\" removed.\n#\ndo_select_tests e_select-8 {\n  2.1  \"SELECT * FROM d1 ORDER BY x ASC, y ASC, z ASC\" {\n     1 2 -20    1 2 3    1 2 7    1 2 8    \n     1 4  93    1 5 -1   2 4 93   2 5 -1\n  }\n  2.2  \"SELECT * FROM d1 ORDER BY x DESC, y DESC, z DESC\" {\n     2 5 -1     2 4 93   1 5 -1   1 4  93    \n     1 2 8      1 2 7    1 2 3    1 2 -20    \n  }\n  2.3 \"SELECT * FROM d1 ORDER BY x DESC, y ASC, z DESC\" {\n     2 4 93   2 5 -1     1 2 8      1 2 7    \n     1 2 3    1 2 -20    1 4  93    1 5 -1   \n  }\n  2.4  \"SELECT * FROM d1 ORDER BY x DESC, y ASC, z ASC\" {\n     2 4 93   2 5 -1     1 2 -20    1 2 3    \n     1 2 7    1 2 8      1 4  93    1 5 -1   \n  }\n\n  3.1  \"SELECT * FROM d1 ORDER BY x, y, z\" {\n     1 2 -20    1 2 3    1 2 7    1 2 8    \n     1 4  93    1 5 -1   2 4 93   2 5 -1\n  }\n  3.3  \"SELECT * FROM d1 ORDER BY x DESC, y, z DESC\" {\n     2 4 93   2 5 -1     1 2 8      1 2 7    \n     1 2 3    1 2 -20    1 4  93    1 5 -1   \n  }\n  3.4 \"SELECT * FROM d1 ORDER BY x DESC, y, z\" {\n     2 4 93   2 5 -1     1 2 -20    1 2 3    \n     1 2 7    1 2 8      1 4  93    1 5 -1   \n  }\n}\n\n# EVIDENCE-OF: R-29779-04281 If the ORDER BY expression is a constant\n# integer K then the expression is considered an alias for the K-th\n# column of the result set (columns are numbered from left to right\n# starting with 1).\n#\ndo_select_tests e_select-8.4 {\n  1  \"SELECT * FROM d1 ORDER BY 1 ASC, 2 ASC, 3 ASC\" {\n     1 2 -20    1 2 3    1 2 7    1 2 8    \n     1 4  93    1 5 -1   2 4 93   2 5 -1\n  }\n  2  \"SELECT * FROM d1 ORDER BY 1 DESC, 2 DESC, 3 DESC\" {\n     2 5 -1     2 4 93   1 5 -1   1 4  93    \n     1 2 8      1 2 7    1 2 3    1 2 -20    \n  }\n  3 \"SELECT * FROM d1 ORDER BY 1 DESC, 2 ASC, 3 DESC\" {\n     2 4 93   2 5 -1     1 2 8      1 2 7    \n     1 2 3    1 2 -20    1 4  93    1 5 -1   \n  }\n  4  \"SELECT * FROM d1 ORDER BY 1 DESC, 2 ASC, 3 ASC\" {\n     2 4 93   2 5 -1     1 2 -20    1 2 3    \n     1 2 7    1 2 8      1 4  93    1 5 -1   \n  }\n  5  \"SELECT * FROM d1 ORDER BY 1, 2, 3\" {\n     1 2 -20    1 2 3    1 2 7    1 2 8    \n     1 4  93    1 5 -1   2 4 93   2 5 -1\n  }\n  6  \"SELECT * FROM d1 ORDER BY 1 DESC, 2, 3 DESC\" {\n     2 4 93   2 5 -1     1 2 8      1 2 7    \n     1 2 3    1 2 -20    1 4  93    1 5 -1   \n  }\n  7  \"SELECT * FROM d1 ORDER BY 1 DESC, 2, 3\" {\n     2 4 93   2 5 -1     1 2 -20    1 2 3    \n     1 2 7    1 2 8      1 4  93    1 5 -1   \n  }\n  8  \"SELECT z, x FROM d1 ORDER BY 2\" {\n     /# 1    # 1    # 1   # 1 \n      # 1    # 1    # 2   # 2/\n  }\n  9  \"SELECT z, x FROM d1 ORDER BY 1\" {\n     /-20 1  -1 #   -1 #   3 1\n     7 1     8 1   93 #   93 #/   \n  }\n}\n\n# EVIDENCE-OF: R-63286-51977 If the ORDER BY expression is an identifier\n# that corresponds to the alias of one of the output columns, then the\n# expression is considered an alias for that column.\n#\ndo_select_tests e_select-8.5 {\n  1   \"SELECT z+1 AS abc FROM d1 ORDER BY abc\" {\n    -19 0 0 4 8 9 94 94\n  }\n  2   \"SELECT z+1 AS abc FROM d1 ORDER BY abc DESC\" {\n    94 94 9 8 4 0 0 -19\n  }\n  3  \"SELECT z AS x, x AS z FROM d1 ORDER BY z\" {\n    /# 1    # 1    # 1    # 1    # 1    # 1    # 2    # 2/\n  }\n  4  \"SELECT z AS x, x AS z FROM d1 ORDER BY x\" {\n    /-20 1    -1 #    -1 #    3 1    7 1    8 1    93 #    93 #/\n  }\n}\n\n# EVIDENCE-OF: R-65068-27207 Otherwise, if the ORDER BY expression is\n# any other expression, it is evaluated and the returned value used to\n# order the output rows.\n#\n# EVIDENCE-OF: R-03421-57988 If the SELECT statement is a simple SELECT,\n# then an ORDER BY may contain any arbitrary expressions.\n#\ndo_select_tests e_select-8.6 {\n  1   \"SELECT * FROM d1 ORDER BY x+y+z\" {\n    1 2 -20    1 5 -1    1 2 3    2 5 -1 \n    1 2 7      1 2 8     1 4 93   2 4 93\n  }\n  2   \"SELECT * FROM d1 ORDER BY x*z\" {\n    1 2 -20    2 5 -1    1 5 -1    1 2 3 \n    1 2 7      1 2 8     1 4 93    2 4 93\n  }\n  3   \"SELECT * FROM d1 ORDER BY y*z\" {\n    1 2 -20    2 5 -1    1 5 -1    1 2 3 \n    1 2 7      1 2 8     2 4 93    1 4 93\n  }\n}\n\n# EVIDENCE-OF: R-28853-08147 However, if the SELECT is a compound\n# SELECT, then ORDER BY expressions that are not aliases to output\n# columns must be exactly the same as an expression used as an output\n# column.\n#\ndo_select_tests e_select-8.7.1 -error {\n  %s ORDER BY term does not match any column in the result set\n} {\n  1   \"SELECT x FROM d1 UNION ALL SELECT a FROM d2 ORDER BY x*z\"        1st\n  2   \"SELECT x,z FROM d1 UNION ALL SELECT a,b FROM d2 ORDER BY x, x/z\" 2nd\n} \n\ndo_select_tests e_select-8.7.2 {\n  1   \"SELECT x*z FROM d1 UNION ALL SELECT a FROM d2 ORDER BY x*z\" {\n    -20 -2 -1 3 7 8 93 186 babied barked commercials gently \n    iterate lad pragmatist reemphasizes rejoicing solemnness\n  }\n  2   \"SELECT x, x/z FROM d1 UNION ALL SELECT a,b FROM d2 ORDER BY x, x/z\" {\n    1 -1 1 0 1 0 1 0 1 0 1 0 2 -2 2 0 \n    babied charitableness barked interrupted commercials bathrobe gently\n    failings iterate sexton lad relenting pragmatist guarded reemphasizes reply\n    rejoicing liabilities solemnness annexed\n  }\n} \n\ndo_execsql_test e_select-8.8.0 {\n  CREATE TABLE d3(a);\n  INSERT INTO d3 VALUES('text');\n  INSERT INTO d3 VALUES(14.1);\n  INSERT INTO d3 VALUES(13);\n  INSERT INTO d3 VALUES(X'78787878');\n  INSERT INTO d3 VALUES(15);\n  INSERT INTO d3 VALUES(12.9);\n  INSERT INTO d3 VALUES(null);\n\n  CREATE TABLE d4(x COLLATE nocase);\n  INSERT INTO d4 VALUES('abc');\n  INSERT INTO d4 VALUES('ghi');\n  INSERT INTO d4 VALUES('DEF');\n  INSERT INTO d4 VALUES('JKL');\n} {}\n\n# EVIDENCE-OF: R-10883-17697 For the purposes of sorting rows, values\n# are compared in the same way as for comparison expressions.\n#\n#   The following tests verify that values of different types are sorted\n#   correctly, and that mixed real and integer values are compared properly.\n#\ndo_execsql_test e_select-8.8.1 {\n  SELECT a FROM d3 ORDER BY a\n} {{} 12.9 13 14.1 15 text xxxx}\ndo_execsql_test e_select-8.8.2 {\n  SELECT a FROM d3 ORDER BY a DESC\n} {xxxx text 15 14.1 13 12.9 {}}\n\n\n# EVIDENCE-OF: R-64199-22471 If the ORDER BY expression is assigned a\n# collation sequence using the postfix COLLATE operator, then the\n# specified collation sequence is used.\n#\ndo_execsql_test e_select-8.9.1 {\n  SELECT x FROM d4 ORDER BY 1 COLLATE binary\n} {DEF JKL abc ghi}\ndo_execsql_test e_select-8.9.2 {\n  SELECT x COLLATE binary FROM d4 ORDER BY 1 COLLATE nocase\n} {abc DEF ghi JKL}\n\n# EVIDENCE-OF: R-09398-26102 Otherwise, if the ORDER BY expression is \n# an alias to an expression that has been assigned a collation sequence \n# using the postfix COLLATE operator, then the collation sequence \n# assigned to the aliased expression is used.\n#\n#   In the test 8.10.2, the only result-column expression has no alias. So the\n#   ORDER BY expression is not a reference to it and therefore does not inherit\n#   the collation sequence. In test 8.10.3, \"x\" is the alias (as well as the\n#   column name), so the ORDER BY expression is interpreted as an alias and the\n#   collation sequence attached to the result column is used for sorting.\n#\ndo_execsql_test e_select-8.10.1 {\n  SELECT x COLLATE binary FROM d4 ORDER BY 1\n} {DEF JKL abc ghi}\ndo_execsql_test e_select-8.10.2 {\n  SELECT x COLLATE binary FROM d4 ORDER BY x\n} {abc DEF ghi JKL}\ndo_execsql_test e_select-8.10.3 {\n  SELECT x COLLATE binary AS x FROM d4 ORDER BY x\n} {DEF JKL abc ghi}\n\n# EVIDENCE-OF: R-27301-09658 Otherwise, if the ORDER BY expression is a\n# column or an alias of an expression that is a column, then the default\n# collation sequence for the column is used.\n#\ndo_execsql_test e_select-8.11.1 {\n  SELECT x AS y FROM d4 ORDER BY y\n} {abc DEF ghi JKL}\ndo_execsql_test e_select-8.11.2 {\n  SELECT x||'' FROM d4 ORDER BY x\n} {abc DEF ghi JKL}\n\n# EVIDENCE-OF: R-49925-55905 Otherwise, the BINARY collation sequence is\n# used.\n#\ndo_execsql_test e_select-8.12.1 {\n  SELECT x FROM d4 ORDER BY x||''\n} {DEF JKL abc ghi}\n\n# EVIDENCE-OF: R-44130-32593 If an ORDER BY expression is not an integer\n# alias, then SQLite searches the left-most SELECT in the compound for a\n# result column that matches either the second or third rules above. If\n# a match is found, the search stops and the expression is handled as an\n# alias for the result column that it has been matched against.\n# Otherwise, the next SELECT to the right is tried, and so on.\n#\ndo_execsql_test e_select-8.13.0 {\n  CREATE TABLE d5(a, b);\n  CREATE TABLE d6(c, d);\n  CREATE TABLE d7(e, f);\n \n  INSERT INTO d5 VALUES(1, 'f');\n  INSERT INTO d6 VALUES(2, 'e');\n  INSERT INTO d7 VALUES(3, 'd');\n  INSERT INTO d5 VALUES(4, 'c');\n  INSERT INTO d6 VALUES(5, 'b');\n  INSERT INTO d7 VALUES(6, 'a');\n\n  CREATE TABLE d8(x COLLATE nocase);\n  CREATE TABLE d9(y COLLATE nocase);\n\n  INSERT INTO d8 VALUES('a');\n  INSERT INTO d9 VALUES('B');\n  INSERT INTO d8 VALUES('c');\n  INSERT INTO d9 VALUES('D');\n} {}\ndo_select_tests e_select-8.13 {\n  1   { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7\n         ORDER BY a\n      } {1 2 3 4 5 6}\n  2   { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7\n         ORDER BY c\n      } {1 2 3 4 5 6}\n  3   { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7\n         ORDER BY e\n      } {1 2 3 4 5 6}\n  4   { SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7\n         ORDER BY 1\n      } {1 2 3 4 5 6}\n\n  5   { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY b } \n      {f 1   c 4   4 c   1 f}\n  6   { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 2 } \n      {f 1   c 4   4 c   1 f}\n\n  7   { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY a } \n      {1 f   4 c   c 4   f 1}\n  8   { SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 1 } \n      {1 f   4 c   c 4   f 1}\n\n  9   { SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 } \n      {f 2   c 5   4 c   1 f}\n  10  { SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 2 } \n      {f 2   c 5   4 c   1 f}\n\n  11  { SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 } \n      {2 f   5 c   c 5   f 2}\n  12  { SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 1 } \n      {2 f   5 c   c 5   f 2}\n} \n\n# EVIDENCE-OF: R-39265-04070 If no matching expression can be found in\n# the result columns of any constituent SELECT, it is an error.\n#\ndo_select_tests e_select-8.14 -error {\n  %s ORDER BY term does not match any column in the result set\n} {\n  1   { SELECT a FROM d5 UNION SELECT c FROM d6 ORDER BY a+1 }          1st\n  2   { SELECT a FROM d5 UNION SELECT c FROM d6 ORDER BY a, a+1 }       2nd\n  3   { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY 'hello' }  1st\n  4   { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY blah    }  1st\n  5   { SELECT * FROM d5 INTERSECT SELECT * FROM d6 ORDER BY c,d,c+d }  3rd\n  6   { SELECT * FROM d5 EXCEPT SELECT * FROM d7 ORDER BY 1,2,b,a/b  }  4th\n} \n\n# EVIDENCE-OF: R-03407-11483 Each term of the ORDER BY clause is\n# processed separately and may be matched against result columns from\n# different SELECT statements in the compound.\n# \ndo_select_tests e_select-8.15 {\n  1  { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY a, d }\n     {1 e   1 f   4 b   4 c}\n  2  { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY c-1, b }\n     {1 e   1 f   4 b   4 c}\n  3  { SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY 1, 2 }\n     {1 e   1 f   4 b   4 c}\n} \n\n\n#-------------------------------------------------------------------------\n# Tests related to statements made about the LIMIT/OFFSET clause.\n#\ndo_execsql_test e_select-9.0 {\n  CREATE TABLE f1(a, b);\n  INSERT INTO f1 VALUES(26, 'z');\n  INSERT INTO f1 VALUES(25, 'y');\n  INSERT INTO f1 VALUES(24, 'x');\n  INSERT INTO f1 VALUES(23, 'w');\n  INSERT INTO f1 VALUES(22, 'v');\n  INSERT INTO f1 VALUES(21, 'u');\n  INSERT INTO f1 VALUES(20, 't');\n  INSERT INTO f1 VALUES(19, 's');\n  INSERT INTO f1 VALUES(18, 'r');\n  INSERT INTO f1 VALUES(17, 'q');\n  INSERT INTO f1 VALUES(16, 'p');\n  INSERT INTO f1 VALUES(15, 'o');\n  INSERT INTO f1 VALUES(14, 'n');\n  INSERT INTO f1 VALUES(13, 'm');\n  INSERT INTO f1 VALUES(12, 'l');\n  INSERT INTO f1 VALUES(11, 'k');\n  INSERT INTO f1 VALUES(10, 'j');\n  INSERT INTO f1 VALUES(9, 'i');\n  INSERT INTO f1 VALUES(8, 'h');\n  INSERT INTO f1 VALUES(7, 'g');\n  INSERT INTO f1 VALUES(6, 'f');\n  INSERT INTO f1 VALUES(5, 'e');\n  INSERT INTO f1 VALUES(4, 'd');\n  INSERT INTO f1 VALUES(3, 'c');\n  INSERT INTO f1 VALUES(2, 'b');\n  INSERT INTO f1 VALUES(1, 'a');\n} {}\n\n# EVIDENCE-OF: R-30481-56627 Any scalar expression may be used in the\n# LIMIT clause, so long as it evaluates to an integer or a value that\n# can be losslessly converted to an integer.\n#\ndo_select_tests e_select-9.1 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 5 } {a b c d e}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT 2+3 } {a b c d e}\n  3  { SELECT b FROM f1 ORDER BY a LIMIT (SELECT a FROM f1 WHERE b = 'e') } \n     {a b c d e}\n  4  { SELECT b FROM f1 ORDER BY a LIMIT 5.0 } {a b c d e}\n  5  { SELECT b FROM f1 ORDER BY a LIMIT '5' } {a b c d e}\n}\n\n# EVIDENCE-OF: R-46155-47219 If the expression evaluates to a NULL value\n# or any other value that cannot be losslessly converted to an integer,\n# an error is returned.\n#\n\ndo_select_tests e_select-9.2 -error \"datatype mismatch\" {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 'hello' } {}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT NULL } {}\n  3  { SELECT b FROM f1 ORDER BY a LIMIT X'ABCD' } {}\n  4  { SELECT b FROM f1 ORDER BY a LIMIT 5.1 } {}\n  5  { SELECT b FROM f1 ORDER BY a LIMIT (SELECT group_concat(b) FROM f1) } {}\n} \n\n# EVIDENCE-OF: R-03014-26414 If the LIMIT expression evaluates to a\n# negative value, then there is no upper bound on the number of rows\n# returned.\n#\ndo_select_tests e_select-9.4 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT -1 } \n     {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT length('abc')-100 } \n     {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n  3  { SELECT b FROM f1 ORDER BY a LIMIT (SELECT count(*) FROM f1)/2 - 14 }\n     {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n}\n\n# EVIDENCE-OF: R-33750-29536 Otherwise, the SELECT returns the first N\n# rows of its result set only, where N is the value that the LIMIT\n# expression evaluates to.\n#\ndo_select_tests e_select-9.5 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 0 } {}\n  2  { SELECT b FROM f1 ORDER BY a DESC LIMIT 4 } {z y x w}\n  3  { SELECT b FROM f1 ORDER BY a DESC LIMIT 8 } {z y x w v u t s}\n  4  { SELECT b FROM f1 ORDER BY a DESC LIMIT '12.0' } {z y x w v u t s r q p o}\n}\n\n# EVIDENCE-OF: R-54935-19057 Or, if the SELECT statement would return\n# less than N rows without a LIMIT clause, then the entire result set is\n# returned.\n#\ndo_select_tests e_select-9.6 {\n  1  { SELECT b FROM f1 WHERE a>21 ORDER BY a LIMIT 10 } {v w x y z}\n  2  { SELECT count(*) FROM f1 GROUP BY a/5 ORDER BY 1 LIMIT 10 } {2 4 5 5 5 5}\n} \n\n\n# EVIDENCE-OF: R-24188-24349 The expression attached to the optional\n# OFFSET clause that may follow a LIMIT clause must also evaluate to an\n# integer, or a value that can be losslessly converted to an integer.\n#\nforeach {tn select} {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 'hello' } \n  2  { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET NULL } \n  3  { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET X'ABCD' } \n  4  { SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 5.1 } \n  5  { SELECT b FROM f1 ORDER BY a \n       LIMIT 2 OFFSET (SELECT group_concat(b) FROM f1) \n  } \n} {\n  do_catchsql_test e_select-9.7.$tn $select {1 {datatype mismatch}}\n}\n\n# EVIDENCE-OF: R-20467-43422 If an expression has an OFFSET clause, then\n# the first M rows are omitted from the result set returned by the\n# SELECT statement and the next N rows are returned, where M and N are\n# the values that the OFFSET and LIMIT clauses evaluate to,\n# respectively.\n#\ndo_select_tests e_select-9.8 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 10 OFFSET 5} {f g h i j k l m n o}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT 2+3 OFFSET 10} {k l m n o}\n  3  { SELECT b FROM f1 ORDER BY a \n       LIMIT  (SELECT a FROM f1 WHERE b='j') \n       OFFSET (SELECT a FROM f1 WHERE b='b') \n     } {c d e f g h i j k l}\n  4  { SELECT b FROM f1 ORDER BY a LIMIT '5' OFFSET 3.0 } {d e f g h}\n  5  { SELECT b FROM f1 ORDER BY a LIMIT '5' OFFSET 0 } {a b c d e}\n  6  { SELECT b FROM f1 ORDER BY a LIMIT 0 OFFSET 10 } {}\n  7  { SELECT b FROM f1 ORDER BY a LIMIT 3 OFFSET '1'||'5' } {p q r}\n}\n\n# EVIDENCE-OF: R-34648-44875 Or, if the SELECT would return less than\n# M+N rows if it did not have a LIMIT clause, then the first M rows are\n# skipped and the remaining rows (if any) are returned.\n#\ndo_select_tests e_select-9.9 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 10 OFFSET 20} {u v w x y z}\n  2  { SELECT a FROM f1 ORDER BY a DESC LIMIT 100 OFFSET 18+4} {4 3 2 1}\n}\n\n\n# EVIDENCE-OF: R-23293-62447 If the OFFSET clause evaluates to a\n# negative value, the results are the same as if it had evaluated to\n# zero.\n#\ndo_select_tests e_select-9.10 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET -1 } {a b c d e}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET -500 } {a b c d e}\n  3  { SELECT b FROM f1 ORDER BY a LIMIT 5 OFFSET 0  } {a b c d e}\n} \n\n# EVIDENCE-OF: R-19509-40356 Instead of a separate OFFSET clause, the\n# LIMIT clause may specify two scalar expressions separated by a comma.\n#\n# EVIDENCE-OF: R-33788-46243 In this case, the first expression is used\n# as the OFFSET expression and the second as the LIMIT expression.\n#\ndo_select_tests e_select-9.11 {\n  1  { SELECT b FROM f1 ORDER BY a LIMIT 5, 10 } {f g h i j k l m n o}\n  2  { SELECT b FROM f1 ORDER BY a LIMIT 10, 2+3 } {k l m n o}\n  3  { SELECT b FROM f1 ORDER BY a \n       LIMIT (SELECT a FROM f1 WHERE b='b'), (SELECT a FROM f1 WHERE b='j') \n     } {c d e f g h i j k l}\n  4  { SELECT b FROM f1 ORDER BY a LIMIT 3.0, '5' } {d e f g h}\n  5  { SELECT b FROM f1 ORDER BY a LIMIT 0, '5' } {a b c d e}\n  6  { SELECT b FROM f1 ORDER BY a LIMIT 10, 0 } {}\n  7  { SELECT b FROM f1 ORDER BY a LIMIT '1'||'5', 3 } {p q r}\n\n  8  { SELECT b FROM f1 ORDER BY a LIMIT 20, 10 } {u v w x y z}\n  9  { SELECT a FROM f1 ORDER BY a DESC LIMIT 18+4, 100 } {4 3 2 1}\n\n  10 { SELECT b FROM f1 ORDER BY a LIMIT -1, 5 } {a b c d e}\n  11 { SELECT b FROM f1 ORDER BY a LIMIT -500, 5 } {a b c d e}\n  12 { SELECT b FROM f1 ORDER BY a LIMIT 0, 5 } {a b c d e}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_select2.test",
    "content": "# 2010 September 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_select.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#-------------------------------------------------------------------------\n# te_* commands:\n#\n#\n#   te_read_sql DB SELECT-STATEMENT\n#   te_read_tbl DB TABLENAME\n#\n# These two commands are used to read a dataset from the database. A dataset\n# consists of N rows of M named columns of values each, where each value has a\n# type (null, integer, real, text or blob) and a value within the types domain.\n# The tcl format for a \"dataset\" is a list of two elements:\n#\n#   * A list of the column names.\n#   * A list of data rows. Each row is itself a list, where each element is\n#     the contents of a column of the row. Each of these is a list of two\n#     elements, the type name and the actual value.\n#\n# For example, the contents of table [t1] as a dataset is:\n#\n#   CREATE TABLE t1(a, b);\n#   INSERT INTO t1 VALUES('abc', NULL);\n#   INSERT INTO t1 VALUES(43.1, 22);\n#\n#   {a b} {{{TEXT abc} {NULL {}}} {{REAL 43.1} {INTEGER 22}}}\n#\n# The [te_read_tbl] command returns a dataset read from a table. The\n# [te_read_sql] returns the dataset that results from executing a SELECT\n# command.\n#\n#\n#   te_tbljoin ?SWITCHES? LHS-TABLE RHS-TABLE\n#   te_join ?SWITCHES? LHS-DATASET RHS-DATASET\n#\n# This command joins the two datasets and returns the resulting dataset. If \n# there are no switches specified, then the results is the cartesian product\n# of the two inputs.  The [te_tbljoin] command reads the left and right-hand\n# datasets from the specified tables. The [te_join] command is passed the\n# datasets directly.\n#\n# Optional switches are as follows:\n#\n#   -on SCRIPT\n#   -using COLUMN-LIST\n#   -left\n#\n# The -on option specifies a tcl script that is executed for each row in the\n# cartesian product of the two datasets. The script has 4 arguments appended\n# to it, in the following order:\n#\n#   * The list of column-names from the left-hand dataset.\n#   * A single row from the left-hand dataset (one \"data row\" list as \n#     described above.\n#   * The list of column-names from the right-hand dataset.\n#   * A single row from the right-hand dataset.\n#\n# The script must return a boolean value - true if the combination of rows\n# should be included in the output dataset, or false otherwise.\n#\n# The -using option specifies a list of the columns from the right-hand\n# dataset that should be omitted from the output dataset.\n#\n# If the -left option is present, the join is done LEFT JOIN style. \n# Specifically, an extra row is inserted if after the -on script is run there\n# exist rows in the left-hand dataset that have no corresponding rows in\n# the output. See the implementation for more specific comments.\n#\n#\n#   te_equals ?SWITCHES? COLNAME1 COLNAME2 <-on script args>\n#\n# The only supported switch is \"-nocase\". If it is present, then text values\n# are compared in a case-independent fashion. Otherwise, they are compared\n# as if using the SQLite BINARY collation sequence.\n#\n#\n#   te_and ONSCRIPT1 ONSCRIPT2...\n#\n#\n\n\n#\n#   te_read_tbl DB TABLENAME\n#   te_read_sql DB SELECT-STATEMENT\n#\n# These two procs are used to extract datasets from the database, either\n# by reading the contents of a named table (te_read_tbl), or by executing\n# a SELECT statement (t3_read_sql).  \n#\n# See the comment above, describing \"te_* commands\", for details of the\n# return values.\n#\nproc te_read_tbl {db tbl} {\n te_read_sql $db \"SELECT * FROM '$tbl'\"\n}\nproc te_read_sql {db sql} {\n  set S [sqlite3_prepare_v2 $db $sql -1 DUMMY]\n\n  set cols [list]\n  for {set i 0} {$i < [sqlite3_column_count $S]} {incr i} {\n    lappend cols [sqlite3_column_name $S $i]\n  }\n\n  set rows [list]\n  while {[sqlite3_step $S] == \"SQLITE_ROW\"} {\n    set r [list]\n    for {set i 0} {$i < [sqlite3_column_count $S]} {incr i} {\n      lappend r [list [sqlite3_column_type $S $i] [sqlite3_column_text $S $i]]\n    }\n    lappend rows $r\n  }\n  sqlite3_finalize $S\n\n  return [list $cols $rows]\n}\n\n#-------\n# Usage:   te_join <table-data1> <table-data2> <join spec>...\n#\n# Where a join-spec is an optional list of arguments as follows:\n#\n#   ?-left?\n#   ?-using colname-list?\n#   ?-on on-expr-proc?\n#\nproc te_join {data1 data2 args} {\n\n  set testproc \"\"\n  set usinglist [list]\n  set isleft 0\n  for {set i 0} {$i < [llength $args]} {incr i} {\n    set a [lindex $args $i]\n    switch -- $a {\n      -on     { set testproc [lindex $args [incr i]] }\n      -using  { set usinglist [lindex $args [incr i]] }\n      -left   { set isleft 1 }\n      default {\n        error \"Unknown argument: $a\"\n      }\n    }\n  }\n\n  set c1 [lindex $data1 0]\n  set c2 [lindex $data2 0]\n  set omitlist [list]\n  set nullrowlist [list]\n  set cret $c1\n\n  set cidx 0\n  foreach col $c2 {\n    set idx [lsearch $usinglist $col]\n    if {$idx>=0} {lappend omitlist $cidx}\n    if {$idx<0} {\n      lappend nullrowlist {NULL {}}\n      lappend cret $col\n    }\n    incr cidx\n  }\n  set omitlist [lsort -integer -decreasing $omitlist]\n\n\n  set rret [list]\n  foreach r1 [lindex $data1 1] {\n    set one 0\n    foreach r2 [lindex $data2 1] {\n      set ok 1\n      if {$testproc != \"\"} {\n        set ok [eval $testproc [list $c1 $r1 $c2 $r2]]\n      }\n      if {$ok} {\n        set one 1\n        foreach idx $omitlist {set r2 [lreplace $r2 $idx $idx]}\n        lappend rret [concat $r1 $r2]\n      }\n    }\n\n    if {$isleft && $one==0} {\n      lappend rret [concat $r1 $nullrowlist]\n    }\n  }\n  \n  list $cret $rret\n}\n\nproc te_tbljoin {db t1 t2 args} {\n  te_join [te_read_tbl $db $t1] [te_read_tbl $db $t2] {*}$args\n}\n\nproc te_apply_affinity {affinity typevar valvar} {\n  upvar $typevar type\n  upvar $valvar val\n\n  switch -- $affinity {\n    integer {\n      if {[string is double $val]} { set type REAL }\n      if {[string is wideinteger $val]} { set type INTEGER }\n      if {$type == \"REAL\" && int($val)==$val} { \n        set type INTEGER \n        set val [expr {int($val)}]\n      }\n    }\n    text {\n      set type TEXT\n    }\n    none { }\n\n    default { error \"invalid affinity: $affinity\" }\n  }\n}\n\n#----------\n# te_equals ?SWITCHES? c1 c2 cols1 row1 cols2 row2\n#\nproc te_equals {args} {\n\n  if {[llength $args]<6} {error \"invalid arguments to te_equals\"}\n  foreach {c1 c2 cols1 row1 cols2 row2} [lrange $args end-5 end] break\n\n  set nocase 0\n  set affinity none\n\n  for {set i 0} {$i < ([llength $args]-6)} {incr i} {\n    set a [lindex $args $i]\n    switch -- $a {\n      -nocase {\n        set nocase 1\n      }\n      -affinity {\n        set affinity [string tolower [lindex $args [incr i]]]\n      }\n      default {\n        error \"invalid arguments to te_equals\"\n      }\n    }\n  }\n\n  set idx2 [if {[string is integer $c2]} { set c2 } else { lsearch $cols2 $c2 }]\n  set idx1 [if {[string is integer $c1]} { set c1 } else { lsearch $cols1 $c1 }]\n\n  set t1 [lindex $row1 $idx1 0]\n  set t2 [lindex $row2 $idx2 0]\n  set v1 [lindex $row1 $idx1 1]\n  set v2 [lindex $row2 $idx2 1]\n\n  te_apply_affinity $affinity t1 v1\n  te_apply_affinity $affinity t2 v2\n\n  if {$t1 == \"NULL\" || $t2 == \"NULL\"} { return 0 }\n  if {$nocase && $t1 == \"TEXT\"} { set v1 [string tolower $v1] }\n  if {$nocase && $t2 == \"TEXT\"} { set v2 [string tolower $v2] }\n\n\n  set res [expr {$t1 == $t2 && [string equal $v1 $v2]}]\n  return $res\n}\n\nproc te_false {args} { return 0 }\nproc te_true  {args} { return 1 }\n\nproc te_and {args} {\n  foreach a [lrange $args 0 end-4] {\n    set res [eval $a [lrange $args end-3 end]]\n    if {$res == 0} {return 0}\n  }\n  return 1\n}\n\n\nproc te_dataset_eq {testname got expected} {\n  uplevel #0 [list do_test $testname [list set {} $got] $expected]\n}\nproc te_dataset_eq_unordered {testname got expected} {\n  lset got      1 [lsort [lindex $got 1]]\n  lset expected 1 [lsort [lindex $expected 1]]\n  te_dataset_eq $testname $got $expected\n}\n\nproc te_dataset_ne {testname got unexpected} {\n  uplevel #0 [list do_test $testname [list string equal $got $unexpected] 0]\n}\nproc te_dataset_ne_unordered {testname got unexpected} {\n  lset got      1 [lsort [lindex $got 1]]\n  lset unexpected 1 [lsort [lindex $unexpected 1]]\n  te_dataset_ne $testname $got $unexpected\n}\n\n\n#-------------------------------------------------------------------------\n#\nproc test_join {tn sqljoin tbljoinargs} {\n  set sql [te_read_sql db \"SELECT * FROM $sqljoin\"]\n  set te  [te_tbljoin db {*}$tbljoinargs]\n  te_dataset_eq_unordered $tn $sql $te\n}\n\ndrop_all_tables\ndo_execsql_test e_select-2.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE TABLE t3(b COLLATE nocase);\n\n  INSERT INTO t1 VALUES(2, 'B');\n  INSERT INTO t1 VALUES(1, 'A');\n  INSERT INTO t1 VALUES(4, 'D');\n  INSERT INTO t1 VALUES(NULL, NULL);\n  INSERT INTO t1 VALUES(3, NULL);\n\n  INSERT INTO t2 VALUES(1, 'A');\n  INSERT INTO t2 VALUES(2, NULL);\n  INSERT INTO t2 VALUES(5, 'E');\n  INSERT INTO t2 VALUES(NULL, NULL);\n  INSERT INTO t2 VALUES(3, 'C');\n\n  INSERT INTO t3 VALUES('a');\n  INSERT INTO t3 VALUES('c');\n  INSERT INTO t3 VALUES('b');\n} {}\n\nforeach {tn indexes} {\n  e_select-2.1.1 { }\n  e_select-2.1.2 { CREATE INDEX i1 ON t1(a) }\n  e_select-2.1.3 { CREATE INDEX i1 ON t2(a) }\n  e_select-2.1.4 { CREATE INDEX i1 ON t3(b) }\n} {\n\n  catchsql { DROP INDEX i1 }\n  catchsql { DROP INDEX i2 }\n  catchsql { DROP INDEX i3 }\n  execsql $indexes\n\n  # EVIDENCE-OF: R-49872-03192 If the join-operator is \"CROSS JOIN\",\n  # \"INNER JOIN\", \"JOIN\" or a comma (\",\") and there is no ON or USING\n  # clause, then the result of the join is simply the cartesian product of\n  # the left and right-hand datasets.\n  #\n  # EVIDENCE-OF: R-46256-57243 There is no difference between the \"INNER\n  # JOIN\", \"JOIN\" and \",\" join operators.\n  #\n  # EVIDENCE-OF: R-25071-21202 The \"CROSS JOIN\" join operator produces the\n  # same result as the \"INNER JOIN\", \"JOIN\" and \",\" operators\n  #\n  test_join $tn.1.1  \"t1, t2\"                {t1 t2}\n  test_join $tn.1.2  \"t1 INNER JOIN t2\"      {t1 t2}\n  test_join $tn.1.3  \"t1 CROSS JOIN t2\"      {t1 t2}\n  test_join $tn.1.4  \"t1 JOIN t2\"            {t1 t2}\n  test_join $tn.1.5  \"t2, t3\"                {t2 t3}\n  test_join $tn.1.6  \"t2 INNER JOIN t3\"      {t2 t3}\n  test_join $tn.1.7  \"t2 CROSS JOIN t3\"      {t2 t3}\n  test_join $tn.1.8  \"t2 JOIN t3\"            {t2 t3}\n  test_join $tn.1.9  \"t2, t2 AS x\"           {t2 t2}\n  test_join $tn.1.10 \"t2 INNER JOIN t2 AS x\" {t2 t2}\n  test_join $tn.1.11 \"t2 CROSS JOIN t2 AS x\" {t2 t2}\n  test_join $tn.1.12 \"t2 JOIN t2 AS x\"       {t2 t2}\n\n  # EVIDENCE-OF: R-38465-03616 If there is an ON clause then the ON\n  # expression is evaluated for each row of the cartesian product as a\n  # boolean expression. Only rows for which the expression evaluates to\n  # true are included from the dataset.\n  #\n  test_join $tn.2.1  \"t1, t2 ON (t1.a=t2.a)\"  {t1 t2 -on {te_equals a a}}\n  test_join $tn.2.2  \"t2, t1 ON (t1.a=t2.a)\"  {t2 t1 -on {te_equals a a}}\n  test_join $tn.2.3  \"t2, t1 ON (1)\"          {t2 t1 -on te_true}\n  test_join $tn.2.4  \"t2, t1 ON (NULL)\"       {t2 t1 -on te_false}\n  test_join $tn.2.5  \"t2, t1 ON (1.1-1.1)\"    {t2 t1 -on te_false}\n  test_join $tn.2.6  \"t1, t2 ON (1.1-1.0)\"    {t1 t2 -on te_true}\n\n\n  test_join $tn.3 \"t1 LEFT JOIN t2 ON (t1.a=t2.a)\" {t1 t2 -left -on {te_equals a a}}\n  test_join $tn.4 \"t1 LEFT JOIN t2 USING (a)\" {\n    t1 t2 -left -using a -on {te_equals a a}\n  }\n  test_join $tn.5 \"t1 CROSS JOIN t2 USING(b, a)\" {\n    t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.6 \"t1 NATURAL JOIN t2\" {\n    t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.7 \"t1 NATURAL INNER JOIN t2\" {\n    t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.8 \"t1 NATURAL CROSS JOIN t2\" {\n    t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.9 \"t1 NATURAL INNER JOIN t2\" {\n    t1 t2 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.10 \"t1 NATURAL LEFT JOIN t2\" {\n    t1 t2 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.11 \"t1 NATURAL LEFT OUTER JOIN t2\" {\n    t1 t2 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.12 \"t2 NATURAL JOIN t1\" {\n    t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.13 \"t2 NATURAL INNER JOIN t1\" {\n    t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.14 \"t2 NATURAL CROSS JOIN t1\" {\n    t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.15 \"t2 NATURAL INNER JOIN t1\" {\n    t2 t1 -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.16 \"t2 NATURAL LEFT JOIN t1\" {\n    t2 t1 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.17 \"t2 NATURAL LEFT OUTER JOIN t1\" {\n    t2 t1 -left -using {a b} -on {te_and {te_equals a a} {te_equals b b}}\n  }\n  test_join $tn.18 \"t1 LEFT JOIN t2 USING (b)\" {\n    t1 t2 -left -using b -on {te_equals b b}\n  }\n  test_join $tn.19 \"t1 JOIN t3 USING(b)\" {t1 t3 -using b -on {te_equals b b}}\n  test_join $tn.20 \"t3 JOIN t1 USING(b)\" {\n    t3 t1 -using b -on {te_equals -nocase b b}\n  }\n  test_join $tn.21 \"t1 NATURAL JOIN t3\"  {\n    t1 t3 -using b -on {te_equals b b}\n  }\n  test_join $tn.22 \"t3 NATURAL JOIN t1\"  {\n    t3 t1 -using b -on {te_equals -nocase b b}\n  }\n  test_join $tn.23 \"t1 NATURAL LEFT JOIN t3\" {\n    t1 t3 -left -using b -on {te_equals b b}\n  }\n  test_join $tn.24 \"t3 NATURAL LEFT JOIN t1\" {\n    t3 t1 -left -using b -on {te_equals -nocase b b}\n  }\n  test_join $tn.25 \"t1 LEFT JOIN t3 ON (t3.b=t1.b)\" {\n    t1 t3 -left -on {te_equals -nocase b b}\n  }\n  test_join $tn.26 \"t1 LEFT JOIN t3 ON (t1.b=t3.b)\" {\n    t1 t3 -left -on {te_equals b b}\n  }\n  test_join $tn.27 \"t1 JOIN t3 ON (t1.b=t3.b)\" { t1 t3 -on {te_equals b b} }\n\n  # EVIDENCE-OF: R-28760-53843 When more than two tables are joined\n  # together as part of a FROM clause, the join operations are processed\n  # in order from left to right. In other words, the FROM clause (A\n  # join-op-1 B join-op-2 C) is computed as ((A join-op-1 B) join-op-2 C).\n  #\n  #   Tests 28a and 28b show that the statement above is true for this case.\n  #   Test 28c shows that if the parenthesis force a different order of\n  #   evaluation the result is different. Test 28d verifies that the result\n  #   of the query with the parenthesis forcing a different order of evaluation\n  #   is as calculated by the [te_*] procs.\n  #\n  set t3_natural_left_join_t2 [\n    te_tbljoin db t3 t2 -left -using {b} -on {te_equals -nocase b b}\n  ]\n  set t1 [te_read_tbl db t1]\n  te_dataset_eq_unordered $tn.28a [\n    te_read_sql db \"SELECT * FROM t3 NATURAL LEFT JOIN t2 NATURAL JOIN t1\"\n  ] [te_join $t3_natural_left_join_t2 $t1                                \\\n      -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}}  \\\n  ]\n\n  te_dataset_eq_unordered $tn.28b [\n    te_read_sql db \"SELECT * FROM (t3 NATURAL LEFT JOIN t2) NATURAL JOIN t1\"\n  ] [te_join $t3_natural_left_join_t2 $t1                                \\\n      -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}}  \\\n  ]\n\n  te_dataset_ne_unordered $tn.28c [\n    te_read_sql db \"SELECT * FROM (t3 NATURAL LEFT JOIN t2) NATURAL JOIN t1\"\n  ] [\n    te_read_sql db \"SELECT * FROM t3 NATURAL LEFT JOIN (t2 NATURAL JOIN t1)\"\n  ]\n\n  set t2_natural_join_t1 [te_tbljoin db t2 t1 -using {a b}                 \\\n        -using {a b} -on {te_and {te_equals a a} {te_equals -nocase b b}}  \\\n  ]\n  set t3 [te_read_tbl db t3]\n  te_dataset_eq_unordered $tn.28d [\n    te_read_sql db \"SELECT * FROM t3 NATURAL LEFT JOIN (t2 NATURAL JOIN t1)\"\n  ] [te_join $t3 $t2_natural_join_t1                                       \\\n      -left -using {b} -on {te_equals -nocase b b}                         \\\n  ]\n}\n\ndo_execsql_test e_select-2.2.0 {\n  CREATE TABLE t4(x TEXT COLLATE nocase);\n  CREATE TABLE t5(y INTEGER, z TEXT COLLATE binary);\n\n  INSERT INTO t4 VALUES('2.0');\n  INSERT INTO t4 VALUES('TWO');\n  INSERT INTO t5 VALUES(2, 'two');\n} {}\n\n# EVIDENCE-OF: R-59237-46742 A subquery specified in the\n# table-or-subquery following the FROM clause in a simple SELECT\n# statement is handled as if it was a table containing the data returned\n# by executing the subquery statement.\n#\n# EVIDENCE-OF: R-27438-53558 Each column of the subquery has the\n# collation sequence and affinity of the corresponding expression in the\n# subquery statement.\n#\nforeach {tn subselect select spec} {\n  1   \"SELECT * FROM t2\"   \"SELECT * FROM t1 JOIN %ss%\" \n      {t1 %ss%}\n\n  2   \"SELECT * FROM t2\"   \"SELECT * FROM t1 JOIN %ss% AS x ON (t1.a=x.a)\" \n      {t1 %ss% -on {te_equals 0 0}}\n\n  3   \"SELECT * FROM t2\"   \"SELECT * FROM %ss% AS x JOIN t1 ON (t1.a=x.a)\" \n      {%ss% t1 -on {te_equals 0 0}}\n\n  4   \"SELECT * FROM t1, t2\" \"SELECT * FROM %ss% AS x JOIN t3\"\n      {%ss% t3}\n\n  5   \"SELECT * FROM t1, t2\" \"SELECT * FROM %ss% NATURAL JOIN t3\"\n      {%ss% t3 -using b -on {te_equals 1 0}}\n\n  6   \"SELECT * FROM t1, t2\" \"SELECT * FROM t3 NATURAL JOIN %ss%\"\n      {t3 %ss% -using b -on {te_equals -nocase 0 1}}\n\n  7   \"SELECT * FROM t1, t2\" \"SELECT * FROM t3 NATURAL LEFT JOIN %ss%\"\n      {t3 %ss% -left -using b -on {te_equals -nocase 0 1}}\n\n  8   \"SELECT count(*) AS y FROM t4\"   \"SELECT * FROM t5, %ss% USING (y)\"\n      {t5 %ss% -using y -on {te_equals -affinity text 0 0}}\n\n  9   \"SELECT count(*) AS y FROM t4\"   \"SELECT * FROM %ss%, t5 USING (y)\"\n      {%ss% t5 -using y -on {te_equals -affinity text 0 0}}\n\n  10  \"SELECT x AS y FROM t4\"   \"SELECT * FROM %ss% JOIN t5 USING (y)\"\n      {%ss% t5 -using y -on {te_equals -nocase -affinity integer 0 0}}\n\n  11  \"SELECT x AS y FROM t4\"   \"SELECT * FROM t5 JOIN %ss% USING (y)\"\n      {t5 %ss% -using y -on {te_equals -nocase -affinity integer 0 0}}\n\n  12  \"SELECT y AS x FROM t5\"   \"SELECT * FROM %ss% JOIN t4 USING (x)\"\n      {%ss% t4 -using x -on {te_equals -nocase -affinity integer 0 0}}\n\n  13  \"SELECT y AS x FROM t5\"   \"SELECT * FROM t4 JOIN %ss% USING (x)\"\n      {t4 %ss% -using x -on {te_equals -nocase -affinity integer 0 0}}\n\n  14  \"SELECT +y AS x FROM t5\"   \"SELECT * FROM %ss% JOIN t4 USING (x)\"\n      {%ss% t4 -using x -on {te_equals -nocase -affinity text 0 0}}\n\n  15  \"SELECT +y AS x FROM t5\"   \"SELECT * FROM t4 JOIN %ss% USING (x)\"\n      {t4 %ss% -using x -on {te_equals -nocase -affinity text 0 0}}\n} {\n\n  # Create a temporary table named %ss% containing the data returned by\n  # the sub-select. Then have the [te_tbljoin] proc use this table to\n  # compute the expected results of the $select query. Drop the temporary\n  # table before continuing.\n  #\n  execsql \"CREATE TEMP TABLE '%ss%' AS $subselect\"\n  set te [eval te_tbljoin db $spec]\n  execsql \"DROP TABLE '%ss%'\"\n\n  # Check that the actual data returned by the $select query is the same\n  # as the expected data calculated using [te_tbljoin] above.\n  #\n  te_dataset_eq_unordered e_select-2.2.1.$tn [\n    te_read_sql db [string map [list %ss% \"($subselect)\"] $select]\n  ] $te\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_totalchanges.test",
    "content": "# 2011 May 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_totalchanges\n\n# Like [do_execsql_test], except it appends the value returned by \n# [db total_changes] to the result of executing the SQL script.\n#\nproc do_tc_test {tn sql res} {\n  uplevel [list \\\n    do_test $tn \"concat \\[execsql {$sql}\\] \\[db total_changes\\]\" $res\n  ]\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX t1_b ON t1(b);\n  CREATE TABLE t2(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;\n  CREATE INDEX t2_y ON t2(y);\n}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-65438-26258 This function returns the total number of\n# rows inserted, modified or deleted by all INSERT, UPDATE or DELETE\n# statements completed since the database connection was opened,\n# including those executed as part of trigger programs.\n#\n#   1.1.*: different types of I/U/D statements,\n#   1.2.*: trigger programs.\n#\ndo_tc_test 1.1.1 {\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  UPDATE t1 SET a = a+1;\n  DELETE FROM t1;\n} {6}\ndo_tc_test 1.1.2 {\n  DELETE FROM t1\n} {6}\n\ndo_tc_test 1.1.3 {\n  WITH data(a,b) AS (\n      SELECT 0, 0 UNION ALL SELECT a+1, b+1 FROM data WHERE a<99\n  )\n  INSERT INTO t1 SELECT * FROM data;\n} {106}\n\ndo_tc_test 1.1.4 {\n  INSERT INTO t2 SELECT * FROM t1 WHERE a<50;\n  UPDATE t2 SET y=y+1;\n} {206}\n\ndo_tc_test 1.1.5 {\n  DELETE FROM t2 WHERE y<=25\n} {231}\n\ndo_execsql_test 1.2.1 {\n  DELETE FROM t1;\n  DELETE FROM t2;\n}\nsqlite3 db test.db     ; # To reset total_changes\ndo_tc_test 1.2.2 {\n  CREATE TABLE log(detail);\n  CREATE TRIGGER t1_after_insert AFTER INSERT ON t1 BEGIN \n    INSERT INTO log VALUES('inserted into t1');\n  END;\n\n  CREATE TRIGGER t1_before_delete BEFORE DELETE ON t1 BEGIN \n    INSERT INTO log VALUES('deleting from t1');\n    INSERT INTO log VALUES('here we go!');\n  END;\n\n  CREATE TRIGGER t1_after_update AFTER UPDATE ON t1 BEGIN \n    INSERT INTO log VALUES('update');\n    DELETE FROM log;\n  END;\n\n  INSERT INTO t1 VALUES('a', 'b');   -- 1 + 1\n  UPDATE t1 SET b='c';               -- 1 + 1 + 2\n  DELETE FROM t1;                    -- 1 + 1 + 1\n} {9}\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-61766-15253 Executing any other type of SQL statement\n# does not affect the value returned by sqlite3_total_changes().\ndo_tc_test 2.1 {\n  INSERT INTO t1 VALUES(1, 2), (3, 4);\n  INSERT INTO t2 VALUES(1, 2), (3, 4);\n} {15}\ndo_tc_test 2.2 {\n  SELECT count(*) FROM t1;\n} {2 15}\ndo_tc_test 2.3 {\n  CREATE TABLE t4(a, b);\n  ALTER TABLE t4 ADD COLUMN c;\n  CREATE INDEX i4 ON t4(c);\n  ALTER TABLE t4 RENAME TO t5;\n  ANALYZE;\n  BEGIN;\n  DROP TABLE t2;\n  ROLLBACK;\n  VACUUM;\n} {15}\n\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-36043-10590 Changes made as part of foreign key\n# actions are included in the count, but those made as part of REPLACE\n# constraint resolution are not.\n#\n#   3.1.*: foreign key actions\n#   3.2.*: REPLACE constraints.\n#\nsqlite3 db test.db     ; # To reset total_changes\ndo_tc_test 3.1.1 {\n  CREATE TABLE p1(c PRIMARY KEY, d);\n  CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET NULL);\n  CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE CASCADE);\n  CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON DELETE SET DEFAULT);\n\n  INSERT INTO p1 VALUES(1, 'one');\n  INSERT INTO p1 VALUES(2, 'two');\n  INSERT INTO p1 VALUES(3, 'three');\n  INSERT INTO p1 VALUES(4, 'four');\n\n  INSERT INTO c1 VALUES(1, 'i');\n  INSERT INTO c2 VALUES(2, 'ii');\n  INSERT INTO c3 VALUES(3, 'iii');\n  PRAGMA foreign_keys = ON;\n} {7}\n\ndo_tc_test 3.1.2 { DELETE FROM p1 WHERE c=1; } {9}\ndo_tc_test 3.1.3 { DELETE FROM p1 WHERE c=2; } {11}\ndo_tc_test 3.1.4 { DELETE FROM p1 WHERE c=3; } {13}\ndo_tc_test 3.1.5 { DELETE FROM p1 WHERE c=4; } {14}  ; # only 1 this time.\n\nsqlite3 db test.db     ; # To reset total_changes\ndo_tc_test 3.1.6 {\n  DROP TABLE c1;\n  DROP TABLE c2;\n  DROP TABLE c3;\n  CREATE TABLE c1(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET NULL);\n  CREATE TABLE c2(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE CASCADE);\n  CREATE TABLE c3(a, b, FOREIGN KEY(a) REFERENCES p1 ON UPDATE SET DEFAULT);\n\n  INSERT INTO p1 VALUES(1, 'one');\n  INSERT INTO p1 VALUES(2, 'two');\n  INSERT INTO p1 VALUES(3, 'three');\n  INSERT INTO p1 VALUES(4, 'four');\n\n  INSERT INTO c1 VALUES(1, 'i');\n  INSERT INTO c2 VALUES(2, 'ii');\n  INSERT INTO c3 VALUES(3, 'iii');\n  PRAGMA foreign_keys = ON;\n} {7}\n\ndo_tc_test 3.1.7  { UPDATE p1 SET c=c+4 WHERE c=1; } {9}\ndo_tc_test 3.1.8  { UPDATE p1 SET c=c+4 WHERE c=2; } {11}\ndo_tc_test 3.1.9  { UPDATE p1 SET c=c+4 WHERE c=3; } {13}\ndo_tc_test 3.1.10 { UPDATE p1 SET c=c+4 WHERE c=4; } {14}  ; # only 1 this time.\n\nsqlite3 db test.db     ; # To reset total_changes\ndo_tc_test 3.2.1 {\n  CREATE TABLE t3(a UNIQUE, b UNIQUE);\n  INSERT INTO t3 VALUES('one', 'one');\n  INSERT INTO t3 VALUES('two', 'two');\n  INSERT OR REPLACE INTO t3 VALUES('one', 'two');\n} {3}\n\ndo_tc_test 3.2.2 {\n  INSERT INTO t3 VALUES('three', 'one');\n  UPDATE OR REPLACE t3 SET b='two' WHERE b='one';\n  SELECT * FROM t3;\n} {three two 5}\n\n#--------------------------------------------------------------------------\n# EVIDENCE-OF: R-54872-08741 Changes to a view that are intercepted by\n# INSTEAD OF triggers are not counted.\n#\nsqlite3 db test.db     ; # To reset total_changes\ndo_tc_test 4.1 {\n  CREATE TABLE t6(x);\n  CREATE VIEW v1 AS SELECT * FROM t6;\n  CREATE TRIGGER v1_tr1 INSTEAD OF INSERT ON v1 BEGIN\n    SELECT 'no-op';\n  END;\n\n  INSERT INTO v1 VALUES('a');\n  INSERT INTO v1 VALUES('b');\n} {0}\ndo_tc_test 4.2 {\n  CREATE TRIGGER v1_tr2 INSTEAD OF INSERT ON v1 BEGIN\n    INSERT INTO t6 VALUES(new.x);\n  END;\n\n  INSERT INTO v1 VALUES('c');\n  INSERT INTO v1 VALUES('d');\n} {2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_update.test",
    "content": "# 2010 September 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_update.html document are correct.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#--------------------\n# Test organization:\n#\n#   e_update-1.*: Test statements describing the workings of UPDATE statements.\n#\n#   e_update-2.*: Test the restrictions on the UPDATE statement syntax that\n#                 can be used within triggers.\n#\n#   e_update-3.*: Test the special LIMIT/OFFSET and ORDER BY clauses that can\n#                 be used with UPDATE when SQLite is compiled with\n#                 SQLITE_ENABLE_UPDATE_DELETE_LIMIT.\n#\n\nforcedelete test.db2\n\ndo_execsql_test e_update-0.0 {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b, c);\n  CREATE TABLE t3(a, b UNIQUE);\n  CREATE TABLE t6(x, y);\n  CREATE INDEX i1 ON t1(a);\n\n  CREATE TEMP TABLE t4(x, y);\n  CREATE TEMP TABLE t6(x, y);\n\n  CREATE TABLE aux.t1(a, b);\n  CREATE TABLE aux.t5(a, b);\n} {}\n\nproc do_update_tests {args} {\n  uplevel do_select_tests $args\n}\n\n# -- syntax diagram update-stmt\n#\ndo_update_tests e_update-0 {\n  1    \"UPDATE t1 SET a=10\" {}\n  2    \"UPDATE t1 SET a=10, b=5\" {}\n  3    \"UPDATE t1 SET a=10 WHERE b=5\" {}\n  4    \"UPDATE t1 SET b=5,a=10 WHERE 1\" {}\n  5    \"UPDATE main.t1 SET a=10\" {}\n  6    \"UPDATE main.t1 SET a=10, b=5\" {}\n  7    \"UPDATE main.t1 SET a=10 WHERE b=5\" {}\n  9    \"UPDATE OR ROLLBACK t1 SET a=10\" {}\n  10   \"UPDATE OR ROLLBACK t1 SET a=10, b=5\" {}\n  11   \"UPDATE OR ROLLBACK t1 SET a=10 WHERE b=5\" {}\n  12   \"UPDATE OR ROLLBACK t1 SET b=5,a=10 WHERE 1\" {}\n  13   \"UPDATE OR ROLLBACK main.t1 SET a=10\" {}\n  14   \"UPDATE OR ROLLBACK main.t1 SET a=10, b=5\" {}\n  15   \"UPDATE OR ROLLBACK main.t1 SET a=10 WHERE b=5\" {}\n  16   \"UPDATE OR ROLLBACK main.t1 SET b=5,a=10 WHERE 1\" {}\n  17   \"UPDATE OR ABORT t1 SET a=10\" {}\n  18   \"UPDATE OR ABORT t1 SET a=10, b=5\" {}\n  19   \"UPDATE OR ABORT t1 SET a=10 WHERE b=5\" {}\n  20   \"UPDATE OR ABORT t1 SET b=5,a=10 WHERE 1\" {}\n  21   \"UPDATE OR ABORT main.t1 SET a=10\" {}\n  22   \"UPDATE OR ABORT main.t1 SET a=10, b=5\" {}\n  23   \"UPDATE OR ABORT main.t1 SET a=10 WHERE b=5\" {}\n  24   \"UPDATE OR ABORT main.t1 SET b=5,a=10 WHERE 1\" {}\n  25   \"UPDATE OR REPLACE t1 SET a=10\" {}\n  26   \"UPDATE OR REPLACE t1 SET a=10, b=5\" {}\n  27   \"UPDATE OR REPLACE t1 SET a=10 WHERE b=5\" {}\n  28   \"UPDATE OR REPLACE t1 SET b=5,a=10 WHERE 1\" {}\n  29   \"UPDATE OR REPLACE main.t1 SET a=10\" {}\n  30   \"UPDATE OR REPLACE main.t1 SET a=10, b=5\" {}\n  31   \"UPDATE OR REPLACE main.t1 SET a=10 WHERE b=5\" {}\n  32   \"UPDATE OR REPLACE main.t1 SET b=5,a=10 WHERE 1\" {}\n  33   \"UPDATE OR FAIL t1 SET a=10\" {}\n  34   \"UPDATE OR FAIL t1 SET a=10, b=5\" {}\n  35   \"UPDATE OR FAIL t1 SET a=10 WHERE b=5\" {}\n  36   \"UPDATE OR FAIL t1 SET b=5,a=10 WHERE 1\" {}\n  37   \"UPDATE OR FAIL main.t1 SET a=10\" {}\n  38   \"UPDATE OR FAIL main.t1 SET a=10, b=5\" {}\n  39   \"UPDATE OR FAIL main.t1 SET a=10 WHERE b=5\" {}\n  40   \"UPDATE OR FAIL main.t1 SET b=5,a=10 WHERE 1\" {}\n  41   \"UPDATE OR IGNORE t1 SET a=10\" {}\n  42   \"UPDATE OR IGNORE t1 SET a=10, b=5\" {}\n  43   \"UPDATE OR IGNORE t1 SET a=10 WHERE b=5\" {}\n  44   \"UPDATE OR IGNORE t1 SET b=5,a=10 WHERE 1\" {}\n  45   \"UPDATE OR IGNORE main.t1 SET a=10\" {}\n  46   \"UPDATE OR IGNORE main.t1 SET a=10, b=5\" {}\n  47   \"UPDATE OR IGNORE main.t1 SET a=10 WHERE b=5\" {}\n  48   \"UPDATE OR IGNORE main.t1 SET b=5,a=10 WHERE 1\" {}\n}\n\n# EVIDENCE-OF: R-38515-45264 An UPDATE statement is used to modify a\n# subset of the values stored in zero or more rows of the database table\n# identified by the qualified-table-name specified as part of the UPDATE\n# statement.\n#\n#     Test cases e_update-1.1.1.* test the \"identified by the\n#     qualified-table-name\" part of the statement above. Tests \n#     e_update-1.1.2.* show that the \"zero or more rows\" part is \n#     accurate.\n#\ndo_execsql_test e_update-1.1.0 {\n  INSERT INTO main.t1 VALUES(1, 'i');\n  INSERT INTO main.t1 VALUES(2, 'ii');\n  INSERT INTO main.t1 VALUES(3, 'iii');\n\n  INSERT INTO aux.t1 VALUES(1, 'I');\n  INSERT INTO aux.t1 VALUES(2, 'II');\n  INSERT INTO aux.t1 VALUES(3, 'III');\n} {}\ndo_update_tests e_update-1.1 {\n  1.1  \"UPDATE t1 SET a = a+1; SELECT * FROM t1\"             {2 i  3 ii  4 iii}\n  1.2  \"UPDATE main.t1 SET a = a+1; SELECT * FROM main.t1\"   {3 i  4 ii  5 iii}\n  1.3  \"UPDATE aux.t1 SET a = a+1; SELECT * FROM aux.t1\"     {2 I  3 II  4 III}\n\n  2.1  \"UPDATE t1 SET a = a+1 WHERE a = 1; SELECT * FROM t1\" {3 i  4 ii  5 iii}\n  2.2  \"UPDATE t1 SET a = a+1 WHERE a = 4; SELECT * FROM t1\" {3 i  5 ii  5 iii}\n}\n\n# EVIDENCE-OF: R-55869-30521 If the UPDATE statement does not have a\n# WHERE clause, all rows in the table are modified by the UPDATE.\n#\ndo_execsql_test e_update-1.2.0 {\n  DELETE FROM main.t1;\n  INSERT INTO main.t1 VALUES(1, 'i');\n  INSERT INTO main.t1 VALUES(2, 'ii');\n  INSERT INTO main.t1 VALUES(3, 'iii');\n} {}\ndo_update_tests e_update-1.2 {\n  1  \"UPDATE t1 SET b = 'roman' ; SELECT * FROM t1\"\n     {1 roman  2 roman  3 roman}\n\n  2  \"UPDATE t1 SET a = 'greek' ; SELECT * FROM t1\"\n     {greek roman  greek roman  greek roman}\n}\n\n# EVIDENCE-OF: R-58095-46013 Otherwise, the UPDATE affects only those\n# rows for which the WHERE clause boolean expression is true.\n#\ndo_execsql_test e_update-1.3.0 {\n  DELETE FROM main.t1;\n  INSERT INTO main.t1 VALUES(NULL, '');\n  INSERT INTO main.t1 VALUES(1, 'i');\n  INSERT INTO main.t1 VALUES(2, 'ii');\n  INSERT INTO main.t1 VALUES(3, 'iii');\n} {}\ndo_update_tests e_update-1.3 {\n  1  \"UPDATE t1 SET b = 'roman' WHERE a<2 ; SELECT * FROM t1\"\n     {{} {}  1 roman  2 ii  3 iii}\n\n  2  \"UPDATE t1 SET b = 'egyptian' WHERE (a-3)/10.0 ; SELECT * FROM t1\"\n     {{} {}  1 egyptian  2 egyptian  3 iii}\n\n  3  \"UPDATE t1 SET b = 'macedonian' WHERE a; SELECT * FROM t1\"\n     {{} {}  1 macedonian  2 macedonian  3 macedonian}\n\n  4  \"UPDATE t1 SET b = 'lithuanian' WHERE a IS NULL; SELECT * FROM t1\"\n     {{} lithuanian  1 macedonian  2 macedonian  3 macedonian}\n}\n\n# EVIDENCE-OF: R-58129-20729 It is not an error if the WHERE clause does\n# not evaluate to true for any row in the table - this just means that\n# the UPDATE statement affects zero rows.\n#\ndo_execsql_test e_update-1.4.0 {\n  DELETE FROM main.t1;\n  INSERT INTO main.t1 VALUES(NULL, '');\n  INSERT INTO main.t1 VALUES(1, 'i');\n  INSERT INTO main.t1 VALUES(2, 'ii');\n  INSERT INTO main.t1 VALUES(3, 'iii');\n} {}\ndo_update_tests e_update-1.4 -query {\n  SELECT * FROM t1\n} {\n  1  \"UPDATE t1 SET b = 'burmese' WHERE a=5\" {{} {}  1 i  2 ii  3 iii}\n\n  2  \"UPDATE t1 SET b = 'burmese' WHERE length(b)<1 AND a IS NOT NULL\"\n     {{} {}  1 i  2 ii  3 iii}\n\n  3  \"UPDATE t1 SET b = 'burmese' WHERE 0\" {{} {}  1 i  2 ii  3 iii}\n\n  4  \"UPDATE t1 SET b = 'burmese' WHERE (SELECT a FROM t1 WHERE rowid=1)\"\n     {{} {}  1 i  2 ii  3 iii}\n}\n\n# EVIDENCE-OF: R-40598-36595 For each affected row, the named columns\n# are set to the values found by evaluating the corresponding scalar\n# expressions.\n#\n# EVIDENCE-OF: R-40472-60438 Columns that do not appear in the list of\n# assignments are left unmodified.\n#\ndo_execsql_test e_update-1.5.0 {\n  INSERT INTO t2(rowid, a, b, c) VALUES(1,  3, 1, 4);\n  INSERT INTO t2(rowid, a, b, c) VALUES(2,  1, 5, 9);\n  INSERT INTO t2(rowid, a, b, c) VALUES(3,  2, 6, 5);\n} {}\ndo_update_tests e_update-1.5 -query {\n  SELECT * FROM t2\n} {\n  1   \"UPDATE t2 SET c = 1+1 WHERE a=2\" \n      {3 1 4   1 5 9   2 6 2}\n\n  2   \"UPDATE t2 SET b = 4/2, c=CAST((0.4*5) AS INTEGER) WHERE a<3\"\n      {3 1 4   1 2 2   2 2 2}\n\n  3   \"UPDATE t2 SET a = 1\"\n      {1 1 4   1 2 2   1 2 2}\n\n  4   \"UPDATE t2 SET b = (SELECT count(*)+2 FROM t2), c = 24/3+1 WHERE rowid=2\"\n      {1 1 4   1 5 9   1 2 2}\n\n  5   \"UPDATE t2 SET a = 3 WHERE c = 4\"\n      {3 1 4   1 5 9   1 2 2}\n\n  6   \"UPDATE t2 SET a = b WHERE rowid>2\"\n      {3 1 4   1 5 9   2 2 2}\n\n  6   \"UPDATE t2 SET b=6, c=5 WHERE a=b AND b=c\"\n      {3 1 4   1 5 9   2 6 5}\n}\n\n# EVIDENCE-OF: R-34751-18293 If a single column-name appears more than\n# once in the list of assignment expressions, all but the rightmost\n# occurrence is ignored.\n#\ndo_update_tests e_update-1.6 -query {\n  SELECT * FROM t2\n} {\n  1   \"UPDATE t2 SET c=5, c=6, c=7 WHERE rowid=1\" {3 1 7   1 5 9   2 6 5}\n  2   \"UPDATE t2 SET c=7, c=6, c=5 WHERE rowid=1\" {3 1 5   1 5 9   2 6 5}\n  3   \"UPDATE t2 SET c=5, b=6, c=7 WHERE rowid=1\" {3 6 7   1 5 9   2 6 5}\n}\n\n# EVIDENCE-OF: R-36239-04077 The scalar expressions may refer to columns\n# of the row being updated.\n#\n# EVIDENCE-OF: R-04558-24451 In this case all scalar expressions are\n# evaluated before any assignments are made.\n#\ndo_execsql_test e_update-1.7.0 {\n  DELETE FROM t2;\n  INSERT INTO t2(rowid, a, b, c) VALUES(1,  3, 1, 4);\n  INSERT INTO t2(rowid, a, b, c) VALUES(2,  1, 5, 9);\n  INSERT INTO t2(rowid, a, b, c) VALUES(3,  2, 6, 5);\n} {}\ndo_update_tests e_update-1.7 -query {\n  SELECT * FROM t2\n} {\n  1   \"UPDATE t2 SET a=b+c\"          {5 1 4     14 5 9   11  6 5}\n  2   \"UPDATE t2 SET a=b, b=a\"       {1 5 4     5 14 9    6 11 5}\n  3   \"UPDATE t2 SET a=c||c, c=NULL\" {44 5 {}  99 14 {}  55 11 {}}\n}\n\n# EVIDENCE-OF: R-28518-13457 The optional \"OR action\" conflict clause\n# that follows the UPDATE keyword allows the user to nominate a specific\n# constraint conflict resolution algorithm to use during this one UPDATE\n# command.\n#\ndo_execsql_test e_update-1.8.0 {\n  DELETE FROM t3;\n  INSERT INTO t3 VALUES(1, 'one');\n  INSERT INTO t3 VALUES(2, 'two');\n  INSERT INTO t3 VALUES(3, 'three');\n  INSERT INTO t3 VALUES(4, 'four');\n} {}\nforeach {tn sql error ac data } {\n  1  \"UPDATE t3 SET b='one' WHERE a=3\" \n     {UNIQUE constraint failed: t3.b} 1 {1 one 2 two 3 three 4 four}\n\n  2  \"UPDATE OR REPLACE t3 SET b='one' WHERE a=3\" \n     {} 1 {2 two 3 one 4 four}\n\n  3  \"UPDATE OR FAIL t3 SET b='three'\"\n     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}\n\n  4  \"UPDATE OR IGNORE t3 SET b='three' WHERE a=3\" \n     {} 1 {2 three 3 one 4 four}\n\n  5  \"UPDATE OR ABORT t3 SET b='three' WHERE a=3\" \n     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}\n\n  6  \"BEGIN\" {} 0 {2 three 3 one 4 four}\n\n  7  \"UPDATE t3 SET b='three' WHERE a=3\" \n     {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}\n\n  8  \"UPDATE OR ABORT t3 SET b='three' WHERE a=3\" \n     {UNIQUE constraint failed: t3.b} 0 {2 three 3 one 4 four}\n\n  9  \"UPDATE OR FAIL t3 SET b='two'\"\n     {UNIQUE constraint failed: t3.b} 0 {2 two 3 one 4 four}\n\n  10 \"UPDATE OR IGNORE t3 SET b='four' WHERE a=3\"\n     {} 0 {2 two 3 one 4 four}\n\n  11 \"UPDATE OR REPLACE t3 SET b='four' WHERE a=3\"\n     {} 0 {2 two 3 four}\n\n  12 \"UPDATE OR ROLLBACK t3 SET b='four'\"\n     {UNIQUE constraint failed: t3.b} 1 {2 three 3 one 4 four}\n} {\n  do_catchsql_test e_update-1.8.$tn.1 $sql [list [expr {$error!=\"\"}] $error]\n  do_execsql_test  e_update-1.8.$tn.2 {SELECT * FROM t3} [list {*}$data]\n  do_test          e_update-1.8.$tn.3 {sqlite3_get_autocommit db} $ac\n}\n\n\n\n# EVIDENCE-OF: R-12123-54095 The table-name specified as part of an\n# UPDATE statement within a trigger body must be unqualified.\n#\n# EVIDENCE-OF: R-43190-62442 In other words, the schema-name. prefix on\n# the table name of the UPDATE is not allowed within triggers.\n#\ndo_update_tests e_update-2.1 -error {\n  qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers\n} {\n  1 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n        UPDATE main.t2 SET a=1, b=2, c=3;\n      END;\n  } {}\n\n  2 {\n      CREATE TRIGGER tr1 BEFORE UPDATE ON t2 BEGIN\n        UPDATE aux.t1 SET a=1, b=2;\n      END;\n  } {}\n\n  3 {\n      CREATE TRIGGER tr1 AFTER DELETE ON t4 BEGIN\n        UPDATE main.t1 SET a=1, b=2;\n      END;\n  } {}\n}\n\n# EVIDENCE-OF: R-06085-13761 Unless the table to which the trigger is\n# attached is in the TEMP database, the table being updated by the\n# trigger program must reside in the same database as it.\n#\ndo_update_tests e_update-2.2 -error {\n  no such table: %s\n} {\n  1 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n        UPDATE t4 SET x=x+1;\n      END;\n      INSERT INTO t1 VALUES(1, 2);\n  } \"main.t4\"\n\n  2 {\n      CREATE TRIGGER aux.tr1 AFTER INSERT ON t5 BEGIN\n        UPDATE t4 SET x=x+1;\n      END;\n      INSERT INTO t5 VALUES(1, 2);\n  } \"aux.t4\"\n}\ndo_execsql_test e_update-2.2.X {\n  DROP TRIGGER tr1;\n  DROP TRIGGER aux.tr1;\n} {}\n\n# EVIDENCE-OF: R-29512-54644 If the table to which the trigger is\n# attached is in the TEMP database, then the unqualified name of the\n# table being updated is resolved in the same way as it is for a\n# top-level statement (by searching first the TEMP database, then the\n# main database, then any other databases in the order they were\n# attached).\n#\ndo_execsql_test e_update-2.3.0 {\n  SELECT 'main', tbl_name FROM main.sqlite_master WHERE type = 'table';\n  SELECT 'temp', tbl_name FROM sqlite_temp_master WHERE type = 'table';\n  SELECT 'aux', tbl_name FROM aux.sqlite_master WHERE type = 'table';\n} [list {*}{\n    main t1\n    main t2\n    main t3\n    main t6\n    temp t4\n    temp t6\n    aux  t1\n    aux  t5\n}]\ndo_execsql_test e_update-2.3.1 {\n  DELETE FROM main.t6;\n  DELETE FROM temp.t6;\n  INSERT INTO main.t6 VALUES(1, 2);\n  INSERT INTO temp.t6 VALUES(1, 2);\n\n  CREATE TRIGGER temp.tr1 AFTER INSERT ON t4 BEGIN\n    UPDATE t6 SET x=x+1;\n  END;\n\n  INSERT INTO t4 VALUES(1, 2);\n  SELECT * FROM main.t6;\n  SELECT * FROM temp.t6;\n} {1 2 2 2}\ndo_execsql_test e_update-2.3.2 {\n  DELETE FROM main.t1;\n  DELETE FROM aux.t1;\n  INSERT INTO main.t1 VALUES(1, 2);\n  INSERT INTO aux.t1 VALUES(1, 2);\n\n  CREATE TRIGGER temp.tr2 AFTER DELETE ON t4 BEGIN\n    UPDATE t1 SET a=a+1;\n  END;\n\n  DELETE FROM t4;\n  SELECT * FROM main.t1;\n  SELECT * FROM aux.t1;\n} {2 2 1 2}\ndo_execsql_test e_update-2.3.3 {\n  DELETE FROM aux.t5;\n  INSERT INTO aux.t5 VALUES(1, 2);\n\n  INSERT INTO t4 VALUES('x', 'y');\n  CREATE TRIGGER temp.tr3 AFTER UPDATE ON t4 BEGIN\n    UPDATE t5 SET a=a+1;\n  END;\n\n  UPDATE t4 SET x=10;\n  SELECT * FROM aux.t5;\n} {2 2}\n\n# EVIDENCE-OF: R-19619-42762 The INDEXED BY and NOT INDEXED clauses are\n# not allowed on UPDATE statements within triggers.\n#\ndo_update_tests e_update-2.4 -error {\n  the %s %s clause is not allowed on UPDATE or DELETE statements within triggers\n} {\n  1 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 INDEXED BY i1 SET a=a+1;\n      END;\n  } {INDEXED BY}\n\n  2 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 NOT INDEXED SET a=a+1;\n      END;\n  } {NOT INDEXED}\n}\n\nifcapable update_delete_limit {\n\n# EVIDENCE-OF: R-57359-59558 The LIMIT and ORDER BY clauses for UPDATE\n# are unsupported within triggers, regardless of the compilation options\n# used to build SQLite.\n#\ndo_update_tests e_update-2.5 -error {\n  near \"%s\": syntax error\n} {\n  1 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 SET a=a+1 LIMIT 10;\n      END;\n  } {LIMIT}\n\n  2 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 SET a=a+1 ORDER BY a LIMIT 10;\n      END;\n  } {ORDER}\n\n  3 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 SET a=a+1 ORDER BY a LIMIT 10 OFFSET 2;\n      END;\n  } {ORDER}\n\n  4 {\n      CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN\n        UPDATE t1 SET a=a+1 LIMIT 10 OFFSET 2;\n      END;\n  } {LIMIT}\n}\n\n# EVIDENCE-OF: R-59581-44104 If SQLite is built with the\n# SQLITE_ENABLE_UPDATE_DELETE_LIMIT compile-time option then the syntax\n# of the UPDATE statement is extended with optional ORDER BY and LIMIT\n# clauses\n#\n# -- syntax diagram update-stmt-limited\n#\ndo_update_tests e_update-3.0 {\n  1   \"UPDATE t1 SET a=b LIMIT 5\"                                    {}\n  2   \"UPDATE t1 SET a=b LIMIT 5-1 OFFSET 2+2\"                       {}\n  3   \"UPDATE t1 SET a=b LIMIT 2+2, 16/4\"                            {}\n  4   \"UPDATE t1 SET a=b ORDER BY a LIMIT 5\"                         {}\n  5   \"UPDATE t1 SET a=b ORDER BY a LIMIT 5-1 OFFSET 2+2\"            {}\n  6   \"UPDATE t1 SET a=b ORDER BY a LIMIT 2+2, 16/4\"                 {}\n  7   \"UPDATE t1 SET a=b WHERE a>2 LIMIT 5\"                          {}\n  8   \"UPDATE t1 SET a=b WHERE a>2 LIMIT 5-1 OFFSET 2+2\"             {}\n  9   \"UPDATE t1 SET a=b WHERE a>2 LIMIT 2+2, 16/4\"                  {}\n  10  \"UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 5\"               {}\n  11  \"UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 5-1 OFFSET 2+2\"  {}\n  12  \"UPDATE t1 SET a=b WHERE a>2 ORDER BY a LIMIT 2+2, 16/4\"       {}\n}\n\ndo_execsql_test e_update-3.1.0 {\n  CREATE TABLE t7(q, r, s);\n  INSERT INTO t7 VALUES(1, 'one',   'X');\n  INSERT INTO t7 VALUES(2, 'two',   'X');\n  INSERT INTO t7 VALUES(3, 'three', 'X');\n  INSERT INTO t7 VALUES(4, 'four',  'X');\n  INSERT INTO t7 VALUES(5, 'five',  'X');\n  INSERT INTO t7 VALUES(6, 'six',   'X');\n  INSERT INTO t7 VALUES(7, 'seven', 'X');\n  INSERT INTO t7 VALUES(8, 'eight', 'X');\n  INSERT INTO t7 VALUES(9, 'nine',  'X');\n  INSERT INTO t7 VALUES(10, 'ten',  'X');\n} {}\n\n# EVIDENCE-OF: R-58862-44169 If an UPDATE statement has a LIMIT clause,\n# the maximum number of rows that will be updated is found by evaluating\n# the accompanying expression and casting it to an integer value.\n#\ndo_update_tests e_update-3.1 -query { SELECT s FROM t7 } {\n  1   \"UPDATE t7 SET s = q LIMIT 5\"            {1 2 3 4 5 X X X X X}\n  2   \"UPDATE t7 SET s = r WHERE q>2 LIMIT 4\"  {1 2 three four five six X X X X}\n  3   \"UPDATE t7 SET s = q LIMIT 0\"            {1 2 three four five six X X X X}\n}\n\n# EVIDENCE-OF: R-63582-45120 A negative value is interpreted as \"no limit\".\n#\ndo_update_tests e_update-3.2 -query { SELECT s FROM t7 } {\n  1   \"UPDATE t7 SET s = q LIMIT -1\"              {1 2 3 4 5 6 7 8 9 10}\n  2   \"UPDATE t7 SET s = r WHERE q>4 LIMIT -1\"  \n      {1 2 3 4 five six seven eight nine ten}\n  3   \"UPDATE t7 SET s = 'X' LIMIT -1\"            {X X X X X X X X X X}\n}\n\n# EVIDENCE-OF: R-18628-11938 If the LIMIT expression evaluates to\n# non-negative value N and the UPDATE statement has an ORDER BY clause,\n# then all rows that would be updated in the absence of the LIMIT clause\n# are sorted according to the ORDER BY and the first N updated.\n#\ndo_update_tests e_update-3.3 -query { SELECT s FROM t7 } {\n  1   \"UPDATE t7 SET s = q ORDER BY r LIMIT 3\"      {X X X 4 5 X X 8 X X}\n  2   \"UPDATE t7 SET s = r ORDER BY r DESC LIMIT 2\" {X two three 4 5 X X 8 X X}\n  3   \"UPDATE t7 SET s = q ORDER BY q DESC LIMIT 5\" {X two three 4 5 6 7 8 9 10}\n\n  X   \"UPDATE t7 SET s = 'X'\"                       {X X X X X X X X X X}\n}\n\n# EVIDENCE-OF: R-30955-38324 If the UPDATE statement also has an OFFSET\n# clause, then it is similarly evaluated and cast to an integer value.\n# If the OFFSET expression evaluates to a non-negative value M, then the\n# first M rows are skipped and the following N rows updated instead.\n#\ndo_update_tests e_update-3.3 -query { SELECT s FROM t7 } {\n  1   \"UPDATE t7 SET s = q ORDER BY q LIMIT 3 OFFSET 2\"  {X X 3 4 5 X X X X X}\n  2   \"UPDATE t7 SET s = q ORDER BY q DESC LIMIT 2, 3 \"  {X X 3 4 5 6 7 8 X X}\n\n  X   \"UPDATE t7 SET s = 'X'\"                       {X X X X X X X X X X}\n}\n\n# EVIDENCE-OF: R-19486-35828 If the UPDATE statement has no ORDER BY\n# clause, then all rows that would be updated in the absence of the\n# LIMIT clause are assembled in an arbitrary order before applying the\n# LIMIT and OFFSET clauses to determine which are actually updated.\n#\n#     In practice, \"arbitrary order\" is rowid order. This is also tested\n#     by e_update-3.2.* above.\n#\ndo_update_tests e_update-3.4 -query { SELECT s FROM t7 } {\n  1   \"UPDATE t7 SET s = q LIMIT 4, 2\"        {X X X X 5 6 X X X X}\n  2   \"UPDATE t7 SET s = q LIMIT 2 OFFSET 7\"  {X X X X 5 6 X 8 9 X}\n}\n\n# EVIDENCE-OF: R-10927-26133 The ORDER BY clause on an UPDATE statement\n# is used only to determine which rows fall within the LIMIT. The order\n# in which rows are modified is arbitrary and is not influenced by the\n# ORDER BY clause.\n#\ndo_execsql_test e_update-3.5.0 {\n  CREATE TABLE t8(x);\n  CREATE TRIGGER tr7 BEFORE UPDATE ON t7 BEGIN\n    INSERT INTO t8 VALUES(old.q);\n  END;\n} {}\ndo_update_tests e_update-3.5 -query { SELECT x FROM t8 ; DELETE FROM t8 } {\n  1   \"UPDATE t7 SET s = q ORDER BY r LIMIT -1\"        {1 2 3 4 5 6 7 8 9 10}\n  2   \"UPDATE t7 SET s = q ORDER BY r ASC LIMIT -1\"    {1 2 3 4 5 6 7 8 9 10}\n  3   \"UPDATE t7 SET s = q ORDER BY r DESC LIMIT -1\"   {1 2 3 4 5 6 7 8 9 10}\n  4   \"UPDATE t7 SET s = q ORDER BY q DESC LIMIT 5\"    {6 7 8 9 10}\n}\n\n\n} ;# ifcapable update_delete_limit\n \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_uri.test",
    "content": "# 2011 May 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_uri\ndo_not_use_codec\ndb close\n\nproc parse_uri {uri} {\n  testvfs tvfs2\n  testvfs tvfs \n  tvfs filter xOpen\n  tvfs script parse_uri_open_cb\n\n  set ::uri_open [list]\n  set DB [sqlite3_open_v2 $uri {\n    SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_WAL\n  } tvfs]\n  set fileName [sqlite3_db_filename $DB main]\n  sqlite3_close $DB\n  forcedelete $fileName\n  tvfs delete\n  tvfs2 delete\n\n  set ::uri_open\n}\nproc parse_uri_open_cb {method file arglist} {\n  set ::uri_open [list $file $arglist]\n}\n\nproc open_uri_error {uri} {\n  set flags {SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_WAL}\n  set DB [sqlite3_open_v2 $uri $flags \"\"]\n  set e [sqlite3_errmsg $DB]\n  sqlite3_close $DB\n  set e\n}\n\n# EVIDENCE-OF: R-35840-33204 If URI filename interpretation is enabled,\n# and the filename argument begins with \"file:\", then the filename is\n# interpreted as a URI.\n#\n# EVIDENCE-OF: R-27632-24205 URI filename interpretation is enabled if\n# the SQLITE_OPEN_URI flag is set in the third argument to\n# sqlite3_open_v2(), or if it has been enabled globally using the\n# SQLITE_CONFIG_URI option with the sqlite3_config() method or by the\n# SQLITE_USE_URI compile-time option.\n#\nif {$tcl_platform(platform) == \"unix\"} {\n  set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE]\n\n  # Tests with SQLITE_CONFIG_URI configured to false. URI intepretation is\n  # only enabled if the SQLITE_OPEN_URI flag is specified.\n  sqlite3_shutdown\n  sqlite3_config_uri 0\n  do_test 1.1 {\n    forcedelete file:test.db test.db\n    set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] \"\"]\n    list [file exists file:test.db] [file exists test.db]\n  } {0 1}\n  do_test 1.2 {\n    forcedelete file:test.db2 test.db2\n    set STMT [sqlite3_prepare $DB \"ATTACH 'file:test.db2' AS aux\" -1 dummy]\n    sqlite3_step $STMT\n    sqlite3_finalize $STMT\n    list [file exists file:test.db2] [file exists test.db2]\n  } {0 1}\n  sqlite3_close $DB\n  do_test 1.3 {\n    forcedelete file:test.db test.db\n    set DB [sqlite3_open_v2 file:test.db [concat $flags] \"\"]\n    list [file exists file:test.db] [file exists test.db]\n  } {1 0}\n  do_test 1.4 {\n    forcedelete file:test.db2 test.db2\n    set STMT [sqlite3_prepare $DB \"ATTACH 'file:test.db2' AS aux\" -1 dummy]\n    sqlite3_step $STMT\n    sqlite3_finalize $STMT\n    list [file exists file:test.db2] [file exists test.db2]\n  } {1 0}\n  sqlite3_close $DB\n\n  # Tests with SQLITE_CONFIG_URI configured to true. URI intepretation is\n  # enabled with or without SQLITE_OPEN_URI.\n  #\n  sqlite3_shutdown\n  sqlite3_config_uri 1\n  do_test 1.5 {\n    forcedelete file:test.db test.db\n    set DB [sqlite3_open_v2 file:test.db [concat $flags SQLITE_OPEN_URI] \"\"]\n    list [file exists file:test.db] [file exists test.db]\n  } {0 1}\n  do_test 1.6 {\n    forcedelete file:test.db2 test.db2\n    set STMT [sqlite3_prepare $DB \"ATTACH 'file:test.db2' AS aux\" -1 dummy]\n    sqlite3_step $STMT\n    sqlite3_finalize $STMT\n    list [file exists file:test.db2] [file exists test.db2]\n  } {0 1}\n  sqlite3_close $DB\n  do_test 1.7 {\n    forcedelete file:test.db test.db\n    set DB [sqlite3_open_v2 file:test.db [concat $flags] \"\"]\n    list [file exists file:test.db] [file exists test.db]\n  } {0 1}\n  do_test 1.8 {\n    forcedelete file:test.db2 test.db2\n    set STMT [sqlite3_prepare $DB \"ATTACH 'file:test.db2' AS aux\" -1 dummy]\n    sqlite3_step $STMT\n    sqlite3_finalize $STMT\n    list [file exists file:test.db2] [file exists test.db2]\n  } {0 1}\n  sqlite3_close $DB\n}\n\n# ensure uri processing enabled for the rest of the tests\nsqlite3_shutdown\nsqlite3_config_uri 1\n\n# EVIDENCE-OF: R-06842-00595 If the URI contains an authority, then it\n# must be either an empty string or the string \"localhost\".\n#\n# EVIDENCE-OF: R-17482-00398 If the authority is not an empty string or\n# \"localhost\", an error is returned to the caller.\n#\nif {$tcl_platform(platform) == \"unix\"} {\n  set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]\n  foreach {tn uri error} \"\n    1  {file://localhost[test_pwd /]test.db}   {not an error}\n    2  {file://[test_pwd /]test.db}            {not an error}\n    3  {file://x[test_pwd /]test.db}           {invalid uri authority: x}\n    4  {file://invalid[test_pwd /]test.db}     {invalid uri authority: invalid}\n  \" {\n    do_test 2.$tn {\n      set DB [sqlite3_open_v2 $uri $flags \"\"]\n      set e [sqlite3_errmsg $DB]\n      sqlite3_close $DB\n      set e\n    } $error\n  }\n}\n\n# EVIDENCE-OF: R-45981-25528 The fragment component of a URI, if\n# present, is ignored.\n#\n#   It is difficult to test that something is ignored correctly. So these tests\n#   just show that adding a fragment does not interfere with the pathname or\n#   parameters passed through to the VFS xOpen() methods.\n#\nforeach {tn uri parse} \"\n  1    {file:test.db#abc}      {[test_pwd / {}]test.db {}}\n  2    {file:test.db?a=b#abc}  {[test_pwd / {}]test.db {a b}}\n  3    {file:test.db?a=b#?c=d} {[test_pwd / {}]test.db {a b}}\n\" {\n  do_filepath_test 3.$tn { parse_uri $uri } $parse\n}\n\n# EVIDENCE-OF: R-62557-09390 SQLite uses the path component of the URI\n# as the name of the disk file which contains the database.\n#\n# EVIDENCE-OF: R-28659-11035 If the path begins with a '/' character,\n# then it is interpreted as an absolute path.\n#\n# EVIDENCE-OF: R-46234-61323 If the path does not begin with a '/'\n# (meaning that the authority section is omitted from the URI) then the\n# path is interpreted as a relative path.\n#\nforeach {tn uri parse} \"\n  1    {file:test.db}             {[test_pwd / {}]test.db {}}\n  2    {file:/test.db}            {/test.db {}}\n  3    {file:///test.db}          {/test.db {}}\n  4    {file://localhost/test.db} {/test.db {}}\n  5    {file:/a/b/c/test.db}      {/a/b/c/test.db {}}\n\" {\n  do_filepath_test 4.$tn { parse_uri $uri } $parse\n}\n\n# EVIDENCE-OF: R-01612-30877 The \"vfs\" parameter may be used to specify\n# the name of a VFS object that provides the operating system interface\n# that should be used to access the database file on disk.\n#\n#   The above is tested by cases 1.* below.\n#\n# EVIDENCE-OF: R-52293-58497 If this option is set to an empty string\n# the default VFS object is used.\n#\n#   The above is tested by cases 2.* below.\n#\n# EVIDENCE-OF: R-31855-18665 If sqlite3_open_v2() is used and the vfs\n# option is present, then the VFS specified by the option takes\n# precedence over the value passed as the fourth parameter to\n# sqlite3_open_v2().\n#\n#   The above is tested by cases 3.* below.\n#\nproc vfs_open_cb {name args} {\n  set ::vfs $name\n}\nforeach {name default} {vfs1 0 vfs2 0 vfs3 1} {\n  testvfs $name -default $default\n  $name filter xOpen\n  $name script [list vfs_open_cb $name]\n}\nforeach {tn uri defvfs vfs} {\n  1.1    \"file:test.db?vfs=vfs1\"    \"\"    vfs1\n  1.2    \"file:test.db?vfs=vfs2\"    \"\"    vfs2\n\n  2.1    \"file:test.db\"             vfs1  vfs1\n  2.2    \"file:test.db?vfs=\"        vfs1  vfs3\n\n  3.1    \"file:test.db?vfs=vfs1\"    vfs2  vfs1\n  3.2    \"file:test.db?vfs=vfs2\"    vfs1  vfs2\n  3.3    \"file:test.db?xvfs=vfs1\"   vfs2  vfs2\n  3.4    \"file:test.db?xvfs=vfs2\"   vfs1  vfs1\n} {\n  do_test 5.$tn {\n    set flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]\n    sqlite3_close [\n      sqlite3_open_v2 $uri $flags $defvfs\n    ]\n    set ::vfs\n  } $vfs\n}\nvfs1 delete\nvfs2 delete\nvfs3 delete\n\n# EVIDENCE-OF: R-48365-36308 Specifying an unknown VFS is an error.\n#\nset flags [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]\ndo_test 6.1 {\n  set DB [sqlite3_open_v2 file:test.db?vfs=nosuchvfs $flags \"\"]\n  set errmsg [sqlite3_errmsg $DB]\n  sqlite3_close $DB\n  set errmsg\n} {no such vfs: nosuchvfs}\n\n\n# EVIDENCE-OF: R-44013-13102 The mode parameter may be set to either\n# \"ro\", \"rw\", \"rwc\", or \"memory\". Attempting to set it to any other\n# value is an error\n#\nsqlite3 db test.db\ndb close\nforeach {tn uri error} \"\n  1    {file:test.db?mode=ro}    {not an error}\n  2    {file:test.db?mode=rw}    {not an error}\n  3    {file:test.db?mode=rwc}   {not an error}\n  4    {file:test.db?mode=Ro}    {no such access mode: Ro}\n  5    {file:test.db?mode=Rw}    {no such access mode: Rw}\n  6    {file:test.db?mode=Rwc}   {no such access mode: Rwc}\n  7    {file:test.db?mode=memory} {not an error}\n  8    {file:test.db?mode=MEMORY} {no such access mode: MEMORY}\n\" {\n  do_test 7.$tn { open_uri_error $uri } $error\n}\n\n\n# EVIDENCE-OF: R-43036-46756 If \"ro\" is specified, then the database is\n# opened for read-only access, just as if the SQLITE_OPEN_READONLY flag\n# had been set in the third argument to sqlite3_open_v2().\n#\n# EVIDENCE-OF: R-40137-26050 If the mode option is set to \"rw\", then the\n# database is opened for read-write (but not create) access, as if\n# SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had been set.\n#\n# EVIDENCE-OF: R-26845-32976 Value \"rwc\" is equivalent to setting both\n# SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE.\n#\nforeach {tn uri read write create} {\n  1    {file:test.db?mode=ro}     1 0 0\n  2    {file:test.db?mode=rw}     1 1 0\n  3    {file:test.db?mode=rwc}    1 1 1\n} {\n  set RES(c,0) {1 {unable to open database file}}\n  set RES(c,1) {0 {}}\n  set RES(w,0) {1 {attempt to write a readonly database}}\n  set RES(w,1) {0 {}}\n  set RES(r,0) {1 {this never happens}}\n  set RES(r,1) {0 {a b}}\n\n  # Test CREATE access:\n  forcedelete test.db\n  do_test 8.$tn.c { list [catch { sqlite3 db $uri } msg] $msg } $RES(c,$create)\n  catch { db close }\n\n  sqlite3 db test.db\n  db eval { CREATE TABLE t1(a, b) ; INSERT INTO t1 VALUES('a', 'b') ;}\n  db close\n  \n  # Test READ access:\n  do_test 8.$tn.r { \n    sqlite3 db $uri\n    catchsql { SELECT * FROM t1 }\n  } $RES(r,$read)\n  \n  # Test WRITE access:\n  do_test 8.$tn.w { \n    sqlite3 db $uri\n    catchsql { INSERT INTO t1 VALUES(1, 2) }\n  } $RES(w,$write)\n\n  catch {db close}\n}\n\n# EVIDENCE-OF: R-20590-08726 It is an error to specify a value for the\n# mode parameter that is less restrictive than that specified by the\n# flags passed in the third parameter to sqlite3_open_v2().\n#\nforcedelete test.db\nsqlite3 db test.db\ndb close\nforeach {tn uri flags error} {\n  1   {file:test.db?mode=ro}   ro    {not an error}\n  2   {file:test.db?mode=ro}   rw    {not an error}\n  3   {file:test.db?mode=ro}   rwc   {not an error}\n\n  4   {file:test.db?mode=rw}   ro    {access mode not allowed: rw}\n  5   {file:test.db?mode=rw}   rw    {not an error}\n  6   {file:test.db?mode=rw}   rwc   {not an error}\n\n  7   {file:test.db?mode=rwc}  ro    {access mode not allowed: rwc}\n  8   {file:test.db?mode=rwc}  rw    {access mode not allowed: rwc}\n  9   {file:test.db?mode=rwc}  rwc   {not an error}\n} {\n  set f(ro)  [list SQLITE_OPEN_READONLY SQLITE_OPEN_URI]\n  set f(rw)  [list SQLITE_OPEN_READWRITE SQLITE_OPEN_URI]\n  set f(rwc) [list SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI]\n\n  set DB [sqlite3_open_v2 $uri $f($flags) \"\"]\n  set e [sqlite3_errmsg $DB]\n  sqlite3_close $DB\n\n  do_test 9.$tn { set e } $error\n}\n\n# EVIDENCE-OF: R-23182-54295 The cache parameter may be set to either\n# \"shared\" or \"private\".\nsqlite3 db test.db\ndb close\nforeach {tn uri error} \"\n  1    {file:test.db?cache=private}    {not an error}\n  2    {file:test.db?cache=shared}     {not an error}\n  3    {file:test.db?cache=yes}        {no such cache mode: yes}\n  4    {file:test.db?cache=}           {no such cache mode: }\n\" {\n  do_test 10.$tn { open_uri_error $uri } $error\n}\n\n# EVIDENCE-OF: R-23027-03515 Setting it to \"shared\" is equivalent to\n# setting the SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed\n# to sqlite3_open_v2().\n#\n# EVIDENCE-OF: R-49793-28525 Setting the cache parameter to \"private\" is\n# equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.\n#\n# EVIDENCE-OF: R-31773-41793 If sqlite3_open_v2() is used and the\n# \"cache\" parameter is present in a URI filename, its value overrides\n# any behavior requested by setting SQLITE_OPEN_PRIVATECACHE or\n# SQLITE_OPEN_SHAREDCACHE flag.\n#\nset orig [sqlite3_enable_shared_cache]\nforeach {tn uri flags shared_default isshared} {\n  1.1   \"file:test.db\"                  \"\"         0    0\n  1.2   \"file:test.db\"                  \"\"         1    1\n  1.3   \"file:test.db\"                  private    0    0\n  1.4   \"file:test.db\"                  private    1    0\n  1.5   \"file:test.db\"                  shared     0    1\n  1.6   \"file:test.db\"                  shared     1    1\n\n  2.1   \"file:test.db?cache=private\"    \"\"         0    0\n  2.2   \"file:test.db?cache=private\"    \"\"         1    0\n  2.3   \"file:test.db?cache=private\"    private    0    0\n  2.4   \"file:test.db?cache=private\"    private    1    0\n  2.5   \"file:test.db?cache=private\"    shared     0    0\n  2.6   \"file:test.db?cache=private\"    shared     1    0\n\n  3.1   \"file:test.db?cache=shared\"     \"\"         0    1\n  3.2   \"file:test.db?cache=shared\"     \"\"         1    1\n  3.3   \"file:test.db?cache=shared\"     private    0    1\n  3.4   \"file:test.db?cache=shared\"     private    1    1\n  3.5   \"file:test.db?cache=shared\"     shared     0    1\n  3.6   \"file:test.db?cache=shared\"     shared     1    1\n} {\n  forcedelete test.db\n  sqlite3_enable_shared_cache 1\n  sqlite3 db test.db\n  sqlite3_enable_shared_cache 0\n\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('ok');\n  }\n\n  unset -nocomplain f\n  set f()        {SQLITE_OPEN_READWRITE SQLITE_OPEN_CREATE SQLITE_OPEN_URI}\n  set f(shared)  [concat $f() SQLITE_OPEN_SHAREDCACHE]\n  set f(private) [concat $f() SQLITE_OPEN_PRIVATECACHE]\n\n  sqlite3_enable_shared_cache $shared_default\n  set DB [sqlite3_open_v2 $uri $f($flags) \"\"]\n\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM t1\" -1 dummy]\n\n  db eval {\n    BEGIN;\n      INSERT INTO t1 VALUES('ko');\n  }\n\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n\n  set RES(0) {not an error}\n  set RES(1) {database table is locked: t1}\n\n  do_test 11.$tn { sqlite3_errmsg $DB } $RES($isshared)\n\n  sqlite3_close $DB\n  db close\n}\nsqlite3_enable_shared_cache $orig\n\n# EVIDENCE-OF: R-63472-46769 Specifying an unknown parameter in the\n# query component of a URI is not an error.\n#\ndo_filepath_test 12.1 {\n  parse_uri file://localhost/test.db?an=unknown&parameter=is&ok=\n} {/test.db {an unknown parameter is ok {}}}\ndo_filepath_test 12.2 {\n  parse_uri file://localhost/test.db?an&unknown&parameter&is&ok\n} {/test.db {an {} unknown {} parameter {} is {} ok {}}}\n\n# EVIDENCE-OF: R-27458-04043 URI hexadecimal escape sequences (%HH) are\n# supported within the path and query components of a URI.\n#\n# EVIDENCE-OF: R-52765-50368 Before the path or query components of a\n# URI filename are interpreted, they are encoded using UTF-8 and all\n# hexadecimal escape sequences replaced by a single byte containing the\n# corresponding octet.\n#\n#   The second of the two statements above is tested by creating a\n#   multi-byte utf-8 character using a sequence of %HH escapes.\n#\nforeach {tn uri parse} \"\n  1  {file:/test.%64%62}                             {/test.db {}}\n  2  {file:/test.db?%68%65%6c%6c%6f=%77%6f%72%6c%64} {/test.db {hello world}}\n  3  {file:/%C3%BF.db}                               {/\\xFF.db {}}\n\" {\n  do_filepath_test 13.$tn { parse_uri $uri } $parse\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_vacuum.test",
    "content": "# 2010 September 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that the \"testable statements\" in \n# the lang_vacuum.html document are correct.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nsqlite3_test_control_pending_byte 0x1000000\n\nproc create_db {{sql \"\"}} {\n  catch { db close }\n  forcedelete test.db\n  sqlite3 db test.db\n\n  db transaction {\n    execsql { PRAGMA page_size = 1024; }\n    execsql $sql\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n      INSERT INTO t1 VALUES(1, randomblob(400));\n      INSERT INTO t1 SELECT a+1,  randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+2,  randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+4,  randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+8,  randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+16, randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+32, randomblob(400) FROM t1;\n      INSERT INTO t1 SELECT a+64, randomblob(400) FROM t1;\n\n      CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);\n      INSERT INTO t2 SELECT * FROM t1;\n    }\n  }\n\n  return [expr {[file size test.db] / 1024}]\n}\n\n# This proc returns the number of contiguous blocks of pages that make up\n# the table or index named by the only argument. For example, if the table\n# occupies database pages 3, 4, 8 and 9, then this command returns 2 (there\n# are 2 fragments - one consisting of pages 3 and 4, the other of fragments\n# 8 and 9).\n#\nproc fragment_count {name} {\n  execsql { CREATE VIRTUAL TABLE temp.stat USING dbstat }\n  set nFrag 1\n  db eval {SELECT pageno FROM stat WHERE name = 't1' ORDER BY pageno} {\n    if {[info exists prevpageno] && $prevpageno != $pageno-1} {\n      incr nFrag\n    }\n    set prevpageno $pageno\n  }\n  execsql { DROP TABLE temp.stat }\n  set nFrag\n}\n\n\n# -- syntax diagram vacuum-stmt\n#\ndo_execsql_test e_vacuum-0.1 { VACUUM } {}\n\n# EVIDENCE-OF: R-51469-36013 Unless SQLite is running in\n# \"auto_vacuum=FULL\" mode, when a large amount of data is deleted from\n# the database file it leaves behind empty space, or \"free\" database\n# pages.\n#\n# EVIDENCE-OF: R-60541-63059 Running VACUUM to rebuild the database\n# reclaims this space and reduces the size of the database file.\n#\nforeach {tn avmode sz} {\n  1 none        7 \n  2 full        8 \n  3 incremental 8\n} {\n  set nPage [create_db \"PRAGMA auto_vacuum = $avmode\"]\n\n  do_execsql_test e_vacuum-1.1.$tn.1 {\n    DELETE FROM t1;\n    DELETE FROM t2;\n  } {}\n\n  if {$avmode == \"full\"} {\n    # This branch tests the \"unless ... auto_vacuum=FULL\" in the requirement\n    # above. If auto_vacuum is set to FULL, then no empty space is left in\n    # the database file.\n    do_execsql_test e_vacuum-1.1.$tn.2 {PRAGMA freelist_count} 0\n  } else {\n    set freelist [expr {$nPage - $sz}]\n    if {$avmode == \"incremental\"} { \n      # The page size is 1024 bytes. Therefore, assuming the database contains\n      # somewhere between 207 and 411 pages (it does), there are 2 pointer-map\n      # pages.\n      incr freelist -2\n    }\n    do_execsql_test e_vacuum-1.1.$tn.3 {PRAGMA freelist_count} $freelist\n    do_execsql_test e_vacuum-1.1.$tn.4 {VACUUM} {}\n  }\n\n  do_test e_vacuum-1.1.$tn.5 { expr {[file size test.db] / 1024} } $sz\n}\n\n# EVIDENCE-OF: R-50943-18433 Frequent inserts, updates, and deletes can\n# cause the database file to become fragmented - where data for a single\n# table or index is scattered around the database file.\n#\n# EVIDENCE-OF: R-05791-54928 Running VACUUM ensures that each table and\n# index is largely stored contiguously within the database file.\n#\n#   e_vacuum-1.2.1 - Perform many INSERT, UPDATE and DELETE ops on table t1.\n#   e_vacuum-1.2.2 - Verify that t1 and its indexes are now quite fragmented.\n#   e_vacuum-1.2.3 - Run VACUUM.\n#   e_vacuum-1.2.4 - Verify that t1 and its indexes are now much \n#                    less fragmented.\n#\nifcapable vtab&&compound {\n  create_db \n  register_dbstat_vtab db\n  do_execsql_test e_vacuum-1.2.1 {\n    DELETE FROM t1 WHERE a%2;\n    INSERT INTO t1 SELECT b, a FROM t2 WHERE a%2;\n    UPDATE t1 SET b=randomblob(600) WHERE (a%2)==0;\n  } {}\n  \n  do_test e_vacuum-1.2.2.1 { expr [fragment_count t1]>100 } 1\n  do_test e_vacuum-1.2.2.2 { expr [fragment_count sqlite_autoindex_t1_1]>100 } 1\n  do_test e_vacuum-1.2.2.3 { expr [fragment_count sqlite_autoindex_t1_2]>100 } 1\n  \n  do_execsql_test e_vacuum-1.2.3 { VACUUM } {}\n  \n  # In practice, the tables and indexes each end up stored as two fragments -\n  # one containing the root page and another containing all other pages.\n  #\n  do_test e_vacuum-1.2.4.1 { fragment_count t1 }                    2\n  do_test e_vacuum-1.2.4.2 { fragment_count sqlite_autoindex_t1_1 } 2\n  do_test e_vacuum-1.2.4.3 { fragment_count sqlite_autoindex_t1_2 } 2\n}\n\n# EVIDENCE-OF: R-20474-44465 Normally, the database page_size and\n# whether or not the database supports auto_vacuum must be configured\n# before the database file is actually created.\n#\ndo_test e_vacuum-1.3.1.1 {\n  create_db \"PRAGMA page_size = 1024 ; PRAGMA auto_vacuum = FULL\"\n  execsql { PRAGMA page_size ; PRAGMA auto_vacuum }\n} {1024 1}\ndo_test e_vacuum-1.3.1.2 {\n  execsql { PRAGMA page_size = 2048 }\n  execsql { PRAGMA auto_vacuum = NONE }\n  execsql { PRAGMA page_size ; PRAGMA auto_vacuum }\n} {1024 1}\n\nif {![nonzero_reserved_bytes]} {\n  # EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,\n  # the page_size and/or auto_vacuum properties of an existing database\n  # may be changed by using the page_size and/or pragma auto_vacuum\n  # pragmas and then immediately VACUUMing the database.\n  #\n  do_test e_vacuum-1.3.2.1 {\n    execsql { PRAGMA journal_mode = delete }\n    execsql { PRAGMA page_size = 2048 }\n    execsql { PRAGMA auto_vacuum = NONE }\n    execsql VACUUM\n    execsql { PRAGMA page_size ; PRAGMA auto_vacuum }\n  } {2048 0}\n  \n  # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the\n  # auto_vacuum support property can be changed using VACUUM.\n  #\n  if {[wal_is_capable]} {\n    do_test e_vacuum-1.3.3.1 {\n      execsql { PRAGMA journal_mode = wal }\n      execsql { PRAGMA page_size ; PRAGMA auto_vacuum }\n    } {2048 0}\n    do_test e_vacuum-1.3.3.2 {\n      execsql { PRAGMA page_size = 1024 }\n      execsql { PRAGMA auto_vacuum = FULL }\n      execsql VACUUM\n      execsql { PRAGMA page_size ; PRAGMA auto_vacuum }\n    } {2048 1}\n  }\n}\n  \n# EVIDENCE-OF: R-55119-57913 By default, VACUUM only works only on the\n# main database.\nforcedelete test.db2\ncreate_db { PRAGMA auto_vacuum = NONE }\ndo_execsql_test e_vacuum-2.1.1 {\n  ATTACH 'test.db2' AS aux;\n  PRAGMA aux.page_size = 1024;\n  CREATE TABLE aux.t3 AS SELECT * FROM t1;\n  DELETE FROM t3;\n} {}\nset original_size [file size test.db2]\n\n# Vacuuming the main database does not affect aux\ndo_execsql_test e_vacuum-2.1.3 { VACUUM } {}\ndo_test e_vacuum-2.1.6 { expr {[file size test.db2]==$::original_size} } 1\n\n# EVIDENCE-OF: R-36598-60500 Attached databases can be vacuumed by\n# appending the appropriate schema-name to the VACUUM statement.\ndo_execsql_test e_vacuum-2.1.7 { VACUUM aux; } {}\ndo_test e_vacuum-2.1.8 { expr {[file size test.db2]<$::original_size} } 1\n\n# EVIDENCE-OF: R-17495-17419 The VACUUM command may change the ROWIDs of\n# entries in any tables that do not have an explicit INTEGER PRIMARY\n# KEY.\n#\n#   Tests e_vacuum-3.1.1 - 3.1.2 demonstrate that rowids can change when\n#   a database is VACUUMed. Tests e_vacuum-3.1.3 - 3.1.4 show that adding\n#   an INTEGER PRIMARY KEY column to a table stops this from happening.\n#\ndo_execsql_test e_vacuum-3.1.1 {\n  CREATE TABLE t4(x);\n  INSERT INTO t4(x) VALUES('x');\n  INSERT INTO t4(x) VALUES('y');\n  INSERT INTO t4(x) VALUES('z');\n  DELETE FROM t4 WHERE x = 'y';\n  SELECT rowid, x FROM t4;\n} {1 x 3 z}\ndo_execsql_test e_vacuum-3.1.2 {\n  VACUUM;\n  SELECT rowid, x FROM t4;\n} {1 x 2 z}\n\ndo_execsql_test e_vacuum-3.1.3 {\n  CREATE TABLE t5(x, y INTEGER PRIMARY KEY);\n  INSERT INTO t5(x) VALUES('x');\n  INSERT INTO t5(x) VALUES('y');\n  INSERT INTO t5(x) VALUES('z');\n  DELETE FROM t5 WHERE x = 'y';\n  SELECT rowid, x FROM t5;\n} {1 x 3 z}\ndo_execsql_test e_vacuum-3.1.4 {\n  VACUUM;\n  SELECT rowid, x FROM t5;\n} {1 x 3 z}\n\n# EVIDENCE-OF: R-49563-33883 A VACUUM will fail if there is an open\n# transaction, or if there are one or more active SQL statements when it\n# is run.\n#\ndo_execsql_test  e_vacuum-3.2.1.1 { BEGIN } {}\ndo_catchsql_test e_vacuum-3.2.1.2 { \n  VACUUM \n} {1 {cannot VACUUM from within a transaction}}\ndo_execsql_test  e_vacuum-3.2.1.3 { COMMIT } {}\ndo_execsql_test  e_vacuum-3.2.1.4 { VACUUM } {}\ndo_execsql_test  e_vacuum-3.2.1.5 { SAVEPOINT x } {}\ndo_catchsql_test e_vacuum-3.2.1.6 { \n  VACUUM \n} {1 {cannot VACUUM from within a transaction}}\ndo_execsql_test  e_vacuum-3.2.1.7 { COMMIT } {}\ndo_execsql_test  e_vacuum-3.2.1.8 { VACUUM } {}\n\ncreate_db\ndo_test e_vacuum-3.2.2.1 {\n  set res \"\"\n  db eval { SELECT a FROM t1 } {\n    if {$a == 10} { set res [catchsql VACUUM] }\n  }\n  set res\n} {1 {cannot VACUUM - SQL statements in progress}}\n\n\n# EVIDENCE-OF: R-55138-13241 An alternative to using the VACUUM command\n# to reclaim space after data has been deleted is auto-vacuum mode,\n# enabled using the auto_vacuum pragma.\n#\ndo_test e_vacuum-3.3.1 {\n  create_db { PRAGMA auto_vacuum = FULL }\n  execsql { PRAGMA auto_vacuum }\n} {1}\n\n# EVIDENCE-OF: R-64844-34873 When auto_vacuum is enabled for a database\n# free pages may be reclaimed after deleting data, causing the file to\n# shrink, without rebuilding the entire database using VACUUM.\n#\ndo_test e_vacuum-3.3.2.1 {\n  create_db { PRAGMA auto_vacuum = FULL }\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n  }\n  expr {[file size test.db] / 1024}\n} {8}\ndo_test e_vacuum-3.3.2.2 {\n  create_db { PRAGMA auto_vacuum = INCREMENTAL }\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    PRAGMA incremental_vacuum;\n  }\n  expr {[file size test.db] / 1024}\n} {8}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_wal.test",
    "content": "# 2011 May 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix e_wal\n\ndb close\ntestvfs oldvfs -iversion 1\n\n\n# EVIDENCE-OF: R-58297-14483 WAL databases can be created, read, and\n# written even if shared memory is unavailable as long as the\n# locking_mode is set to EXCLUSIVE before the first attempted access.\n#\n# EVIDENCE-OF: R-00449-33772 This feature allows WAL databases to be\n# created, read, and written by legacy VFSes that lack the \"version 2\"\n# shared-memory methods xShmMap, xShmLock, xShmBarrier, and xShmUnmap on\n# the sqlite3_io_methods object.\n#\n# 1.1: \"create\" tests.\n# 1.2: \"read\" tests.\n# 1.3: \"write\" tests.\n#\n# All three done with VFS \"oldvfs\", which has iVersion==1 and so does\n# not support shared memory.\n# \nsqlite3 db test.db -vfs oldvfs\ndo_execsql_test 1.1.1 {\n  PRAGMA journal_mode = WAL;\n} {delete}\ndo_execsql_test 1.1.2 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  PRAGMA journal_mode = WAL;\n} {exclusive wal}\ndo_execsql_test 1.1.3 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n} {}\ndo_test 1.1.4 {\n  list [file exists test.db-shm] [file exists test.db-wal]\n} {0 1}\n\ndo_test 1.2.1 {\n  db close\n  sqlite3 db test.db -vfs oldvfs\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ndo_test 1.2.2 {\n  execsql { PRAGMA locking_mode = EXCLUSIVE }\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test 1.2.3 {\n  list [file exists test.db-shm] [file exists test.db-wal]\n} {0 1}\n\ndo_test 1.3.1 {\n  db close\n  sqlite3 db test.db -vfs oldvfs\n  catchsql { INSERT INTO t1 VALUES(3, 4) }\n} {1 {unable to open database file}}\ndo_test 1.3.2 {\n  execsql { PRAGMA locking_mode = EXCLUSIVE }\n  execsql { INSERT INTO t1 VALUES(3, 4) }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test 1.3.3 {\n  list [file exists test.db-shm] [file exists test.db-wal]\n} {0 1}\n\n# EVIDENCE-OF: R-31969-57825 If EXCLUSIVE locking mode is set prior to\n# the first WAL-mode database access, then SQLite never attempts to call\n# any of the shared-memory methods and hence no shared-memory wal-index\n# is ever created.\n#\ndb close\nsqlite3 db test.db\ndo_execsql_test 2.1.1 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  SELECT * FROM t1;\n} {exclusive 1 2 3 4}\ndo_test 2.1.2 {\n  list [file exists test.db-shm] [file exists test.db-wal]\n} {0 1}\n\n# EVIDENCE-OF: R-36328-16367 In that case, the database connection\n# remains in EXCLUSIVE mode as long as the journal mode is WAL; attempts\n# to change the locking mode using \"PRAGMA locking_mode=NORMAL;\" are\n# no-ops.\n#\ndo_execsql_test 2.2.1 {\n  PRAGMA locking_mode = NORMAL;\n  SELECT * FROM t1;\n} {exclusive 1 2 3 4}\ndo_test 2.2.2 {\n  sqlite3 db2 test.db\n  catchsql {SELECT * FROM t1} db2\n} {1 {database is locked}}\ndb2 close\n\n# EVIDENCE-OF: R-63522-46088 The only way to change out of EXCLUSIVE\n# locking mode is to first change out of WAL journal mode.\n#\ndo_execsql_test 2.3.1 {\n  PRAGMA journal_mode = DELETE;\n  SELECT * FROM t1;\n} {delete 1 2 3 4}\ndo_test 2.3.2 {\n  sqlite3 db2 test.db\n  catchsql {SELECT * FROM t1} db2\n} {1 {database is locked}}\ndo_execsql_test 2.3.3 {\n  PRAGMA locking_mode = NORMAL;\n  SELECT * FROM t1;\n} {normal 1 2 3 4}\ndo_test 2.3.4 {\n  sqlite3 db2 test.db\n  catchsql {SELECT * FROM t1} db2\n} {0 {1 2 3 4}}\ndb2 close\ndb close\n\n\n# EVIDENCE-OF: R-57239-11845 If NORMAL locking mode is in effect for the\n# first WAL-mode database access, then the shared-memory wal-index is\n# created.\n#\ndo_test 3.0 {\n  sqlite3 db test.db\n  execsql { PRAGMA journal_mode = WAL }\n  db close\n} {}\ndo_test 3.1 {\n  sqlite3 db test.db\n  execsql { SELECT * FROM t1 }\n  list [file exists test.db-shm] [file exists test.db-wal]\n} {1 1}\n\n# EVIDENCE-OF: R-13779-07711 As long as exactly one connection is using\n# a shared-memory wal-index, the locking mode can be changed freely\n# between NORMAL and EXCLUSIVE.\n#\ndo_execsql_test 3.2.1 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  PRAGMA locking_mode = NORMAL;\n  PRAGMA locking_mode = EXCLUSIVE;\n  INSERT INTO t1 VALUES(5, 6);\n} {exclusive normal exclusive}\ndo_test 3.2.2 {\n  sqlite3 db2 test.db\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database is locked}}\n\n# EVIDENCE-OF: R-10993-11647 It is only when the shared-memory wal-index\n# is omitted, when the locking mode is EXCLUSIVE prior to the first\n# WAL-mode database access, that the locking mode is stuck in EXCLUSIVE.\n#\ndo_execsql_test 3.2.3 {\n  PRAGMA locking_mode = NORMAL;\n  SELECT * FROM t1;\n} {normal 1 2 3 4 5 6}\ndo_test 3.2.4 {\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2 3 4 5 6}}\n\ndo_catchsql_test 3.2.5 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  INSERT INTO t1 VALUES(7, 8);\n} {1 {database is locked}}\n\ndb2 close\n\n# EVIDENCE-OF: R-46197-42811 This means that the underlying VFS must\n# support the \"version 2\" shared-memory.\n#\n# EVIDENCE-OF: R-55316-21772 If the VFS does not support shared-memory\n# methods, then the attempt to open a database that is already in WAL\n# mode, or the attempt convert a database into WAL mode, will fail.\n#\ndb close\ndo_test 3.4.1 {\n  sqlite3 db test.db -vfs oldvfs\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ndb close\ndo_test 3.4.2 {\n  forcedelete test.db2\n  sqlite3 db test.db2 -vfs oldvfs\n  catchsql { PRAGMA journal_mode = WAL }\n} {0 delete}\ndb close\n\n\n# EVIDENCE-OF: R-45540-25505 To prevent older versions of SQLite (prior\n# to version 3.7.0, 2010-07-22) from trying to recover a WAL-mode\n# database (and making matters worse) the database file format version\n# numbers (bytes 18 and 19 in the database header) are increased from 1\n# to 2 in WAL mode.\n#\nreset_db\ndo_execsql_test 4.1.1 { CREATE TABLE t1(x, y) }\ndo_test 4.1.2 { hexio_read test.db 18 2 } {0101}\ndo_execsql_test 4.1.3 { PRAGMA journal_mode = wAL } {wal}\ndo_test 4.1.4 { hexio_read test.db 18 2 } {0202}\n\n\n# EVIDENCE-OF: R-02535-05811 One can explicitly change out of WAL mode\n# using a pragma such as this: PRAGMA journal_mode=DELETE;\n#\ndo_execsql_test 4.2.1 { INSERT INTO t1 VALUES(1, 1); } {}\ndo_test 4.2.2 { file exists test.db-wal } {1}\ndo_execsql_test 4.2.3 { PRAGMA journal_mode = delete } {delete}\ndo_test 4.2.4 { file exists test.db-wal } {0}\n\n# EVIDENCE-OF: R-60175-02388 Deliberately changing out of WAL mode\n# changes the database file format version numbers back to 1 so that\n# older versions of SQLite can once again access the database file.\n#\ndo_test 4.3 { hexio_read test.db 18 2 } {0101}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_walauto.test",
    "content": "# 2014 December 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nset testprefix e_walauto\n\n# Do not run this test on OpenBSD, as it depends on read() and mmap both\n# accessing the same coherent view of the \"test.db-shm\" file. This doesn't\n# work on OpenBSD.\n#\nif {$tcl_platform(os) == \"OpenBSD\"} {\n  finish_test\n  return\n}\n\n# This module uses hard-coded offsets which do not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n\nproc read_nbackfill {} {\n  seek $::shmfd 96\n  binary scan [read $::shmfd 4] n nBackfill\n  set nBackfill\n}\nproc read_mxframe {} {\n  seek $::shmfd 16\n  binary scan [read $::shmfd 4] n mxFrame\n  set mxFrame\n}\n\n# Assuming that the main db for database handle\n#\nproc do_autocommit_threshold_test {tn value} {\n\n  set nBackfillSaved [read_nbackfill]\n  while {1} {\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    if {[read_mxframe] >= $value} break\n  }\n  \n  set nBackfillNew [read_nbackfill]\n  uplevel [list do_test $tn \"expr $nBackfillNew > $nBackfillSaved\" 1]\n}\n\n# EVIDENCE-OF: R-30135-06439 The wal_autocheckpoint pragma can be used\n# to invoke this interface from SQL.\n#\n#   All tests in this file are run twice - once using the\n#   sqlite3_wal_autocheckpoint() API, and once using \"PRAGMA\n#   wal_autocheckpoint\".\n#\nforeach {tn code} {\n  1 {\n    proc autocheckpoint {db value} {\n      uplevel [list $db eval \"PRAGMA wal_autocheckpoint = $value\"]\n    }\n  }\n\n  2 {\n    proc autocheckpoint {db value} {\n      uplevel [list sqlite3_wal_autocheckpoint $db $value]\n      return $value\n    }\n  }\n} {\n\n  eval $code\n\n  reset_db\n  execsql { PRAGMA auto_vacuum = 0 }\n  do_execsql_test 1.$tn.0 { PRAGMA journal_mode = WAL } {wal}\n  do_execsql_test 1.$tn.1 { CREATE TABLE t1(a, b) }\n  set shmfd [open \"test.db-shm\" rb]\n\n  # EVIDENCE-OF: R-41531-51083 Every new database connection defaults to\n  # having the auto-checkpoint enabled with a threshold of 1000 or\n  # SQLITE_DEFAULT_WAL_AUTOCHECKPOINT pages.\n  #\n  do_autocommit_threshold_test 1.$tn.2 1000\n  db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n  do_autocommit_threshold_test 1.$tn.3 1000\n\n  # EVIDENCE-OF: R-38128-34102 The sqlite3_wal_autocheckpoint(D,N) is a\n  # wrapper around sqlite3_wal_hook() that causes any database on database\n  # connection D to automatically checkpoint after committing a\n  # transaction if there are N or more frames in the write-ahead log file.\n  #\n  do_test 1.$tn.4 {\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    autocheckpoint db 100\n  } {100}\n  do_autocommit_threshold_test 1.$tn.5 100\n\n  do_test 1.$tn.6 {\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    autocheckpoint db 500\n  } {500}\n  do_autocommit_threshold_test 1.$tn.7 500\n\n  # EVIDENCE-OF: R-26993-43540 Passing zero or a negative value as the\n  # nFrame parameter disables automatic checkpoints entirely.\n  #\n  do_test 1.$tn.7 {\n    autocheckpoint db 0    ;# Set to zero\n    for {set i 0} {$i < 10000} {incr i} {\n      db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    }\n    expr {[file size test.db-wal] > (5 * 1024 * 1024)}\n  } 1\n  do_test 1.$tn.8 {\n    sqlite3_wal_checkpoint_v2 db truncate\n    file size test.db-wal\n  } 0\n  do_test 1.$tn.9 {\n    autocheckpoint db -4    ;# Set to a negative value\n    for {set i 0} {$i < 10000} {incr i} {\n      db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    }\n    expr {[file size test.db-wal] > (5 * 1024 * 1024)}\n  } 1\n\n  # EVIDENCE-OF: R-10203-42688 The callback registered by this function\n  # replaces any existing callback registered using sqlite3_wal_hook().\n  #\n  set ::wal_hook_callback 0\n  proc wal_hook_callback {args} { incr ::wal_hook_callback ; return 0 }\n  do_test 1.$tn.10.1 {\n    db wal_hook wal_hook_callback\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    set ::wal_hook_callback\n  } 2\n  do_test 1.$tn.10.2 {\n    autocheckpoint db 100\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    set ::wal_hook_callback\n  } 2\n\n  # EVIDENCE-OF: R-17497-43474 Likewise, registering a callback using\n  # sqlite3_wal_hook() disables the automatic checkpoint mechanism\n  # configured by this function.\n  do_test 1.$tn.11.1 {\n    sqlite3_wal_checkpoint_v2 db truncate\n    file size test.db-wal\n  } 0\n  do_test 1.$tn.11.2 {\n    autocheckpoint db 100 \n    for {set i 0} {$i < 1000} {incr i} {\n      db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    }\n    expr {[file size test.db-wal] < (1 * 1024 * 1024)}\n  } 1\n  do_test 1.$tn.11.3 {\n    db wal_hook wal_hook_callback\n    for {set i 0} {$i < 1000} {incr i} {\n      db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    }\n    expr {[file size test.db-wal] < (1 * 1024 * 1024)}\n  } 0\n\n  # EVIDENCE-OF: R-33080-59193 Checkpoints initiated by this mechanism \n  # are PASSIVE.\n  #\n  set ::busy_callback_count 0\n  proc busy_callback {args} {\n    incr ::busy_callback_count\n    return 0\n  }\n  do_test 1.$tn.12.1 {\n    sqlite3_wal_checkpoint_v2 db truncate\n    autocheckpoint db 100 \n    db busy busy_callback\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n  } {}\n  do_test 1.$tn.12.2 {\n    sqlite3 db2 test.db\n    db2 eval { BEGIN; SELECT * FROM t1 LIMIT 10; }\n    read_nbackfill\n  } {0}\n  do_test 1.$tn.12.3 {\n    for {set i 0} {$i < 1000} {incr i} {\n      db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    }\n    read_nbackfill\n  } {2}\n  do_test 1.$tn.12.4 {\n    set ::busy_callback_count\n  } {0}\n  db2 close\n\n  do_test 1.$tn.12.5 {\n    db eval { INSERT INTO t1 VALUES(randomblob(100), randomblob(100)) }\n    read_nbackfill\n  } {1559}\n\n  db close\n  close $shmfd\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_walckpt.test",
    "content": "# 2014 December 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nset testprefix e_walckpt\n\n# The following two commands are used to determine if any of the files\n# \"test.db\", \"test.db2\" and \"test.db3\" are modified by a test case.\n#\n# The [save_db_hashes] command saves a hash of the current contents of\n# all three files in global variables. The [compare_db_hashes] compares\n# the current contents with the saved hashes and returns a list of the\n# files that have changed.\n#\nproc save_db_hashes {} {\n  global H\n  foreach f {test.db test.db2 test.db3} {\n    set H($f) 0\n    catch { set H($f) [md5file $f] }\n  }\n}\nproc compare_db_hashes {} {\n  global H\n  set ret [list]\n  foreach f {test.db test.db2 test.db3} {\n    set expect 0\n    catch { set expect [md5file $f] }\n    if {$H($f) != $expect} { lappend ret $f }\n  }\n  set ret\n}\n\n#-------------------------------------------------------------------------\n# All calls to the [sqlite3_wal_checkpoint_v2] command made within this\n# file use this wrapper. It's sole purpose is to throw an error if the\n# following requirement is violated:\n#\n# EVIDENCE-OF: R-60567-47780 Unless it returns SQLITE_MISUSE, the\n# sqlite3_wal_checkpoint_v2() interface sets the error information that\n# is queried by sqlite3_errcode() and sqlite3_errmsg().\n#\nproc wal_checkpoint_v2 {db args} {\n  set rc [catch {\n    uplevel sqlite3_wal_checkpoint_v2 $db $args\n  } msg]\n\n  set errcode \"SQLITE_OK\"\n  if {$rc} {\n    set errcode [lindex [split $msg \" \"] 0]\n  } elseif { [lindex $msg 0] } {\n    set errcode \"SQLITE_BUSY\"\n  }\n\n  if {$errcode != \"SQLITE_MISUSE\" && [sqlite3_errcode $db] != $errcode} {\n    error \"sqlite3_errcode mismatch! (1) $errcode!=[sqlite3_errcode $db]\"\n  }\n\n  if {$rc==0} {\n    return $msg\n  } else {\n    error $msg\n  }\n}\n\n\n# The following tests are run 3 times, each using a different method of \n# invoking a checkpoint:\n#\n#   1) Using sqlite3_wal_checkpoint_v2()\n#   2) Using \"PRAGMA wal_checkpoint\"\n#   3) Using sqlite3_wal_checkpoint() in place of checkpoint_v2(PASSIVE)\n#\n# Cases (2) and (3) are to show that the following statements are \n# correct, respectively:\n#\n# EVIDENCE-OF: R-36706-10507 The PRAGMA wal_checkpoint command can be\n# used to invoke this interface from SQL.\n#\n# EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is\n# equivalent to\n# sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0).\n# \nforeach {tn script} {\n  1 {\n    proc checkpoint {db mode args} {\n      eval wal_checkpoint_v2 [list $db] [list $mode] $args\n    }\n  }\n\n  2 {\n    proc checkpoint {db mode args} {\n      set sql \"PRAGMA wal_checkpoint = $mode\"\n      if {[llength $args] && [lindex $args 0]!=\"\"} {\n        set sql \"PRAGMA [lindex $args 0].wal_checkpoint = $mode\"\n      }\n      set rc [catch { $db eval $sql } msg]\n      if {$rc} {\n        regsub {database} $msg {database:} msg\n        error \"[sqlite3_errcode $db] - $msg\"\n      }\n      set msg\n    }\n  }\n\n  3 {\n    proc checkpoint {db mode args} {\n      if {$mode == \"passive\"} {\n        set rc [eval sqlite3_wal_checkpoint [list $db] $args]\n        if {$rc != \"SQLITE_OK\"} {\n          error \"$rc - [sqlite3_errmsg $db]\"\n        }\n      } else {\n        eval wal_checkpoint_v2 [list $db] [list $mode] $args\n      }\n    }\n  }\n\n} {\n\n  eval $script\n\n  reset_db\n  forcedelete test.db2 test.db3 test.db4\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    ATTACH 'test.db3' AS aux2;\n    ATTACH 'test.db4' AS aux3;\n    CREATE TABLE t1(x);\n    CREATE TABLE aux.t2(x);\n    CREATE TABLE aux2.t3(x);\n    CREATE TABLE aux3.t4(x);\n    PRAGMA main.journal_mode = WAL;\n    PRAGMA aux.journal_mode = WAL;\n    PRAGMA aux2.journal_mode = WAL;\n    /* Leave aux4 in rollback mode */\n  }\n\n  # EVIDENCE-OF: R-49787-09095 The sqlite3_wal_checkpoint_v2(D,X,M,L,C)\n  # interface runs a checkpoint operation on database X of database\n  # connection D in mode M. Status information is written back into\n  # integers pointed to by L and C.\n  #\n  #     Tests 1, 2 and 3 below verify the \"on database X\" part of the\n  #     above. Other parts of this requirement are tested below.\n  #\n  # EVIDENCE-OF: R-00653-06026 If parameter zDb is NULL or points to a\n  # zero length string, then the specified operation is attempted on all\n  # WAL databases attached to database connection db.\n  #\n  #     Tests 4 and 5 below test this.\n  #\n  foreach {tn2 zDb dblist} {\n    1 main  test.db\n    2 aux   test.db2\n    3 aux2  test.db3\n    4 \"\"    {test.db test.db2 test.db3}\n    5 -     {test.db test.db2 test.db3}\n    6 temp  {}\n  } {\n    do_test $tn.1.$tn2 {\n      execsql {\n        INSERT INTO t1 VALUES(1);\n        INSERT INTO t2 VALUES(2);\n        INSERT INTO t3 VALUES(3);\n      }\n      save_db_hashes\n\n      if {$zDb == \"-\"} {\n        checkpoint db passive\n      } else {\n        checkpoint db passive $zDb\n      }\n\n      compare_db_hashes\n    } $dblist\n  }\n\n  # EVIDENCE-OF: R-38207-48996 If zDb is not NULL (or a zero length\n  # string) and is not the name of any attached database, SQLITE_ERROR is\n  # returned to the caller.\n  do_test $tn.2.1 {\n    list [catch { checkpoint db passive notadb } msg] $msg\n  } {1 {SQLITE_ERROR - unknown database: notadb}}\n\n  # EVIDENCE-OF: R-14303-42483 If database zDb is the name of an attached\n  # database that is not in WAL mode, SQLITE_OK is returned and both\n  # *pnLog and *pnCkpt set to -1.\n  #\n  if {$tn==3} {\n    # With sqlite3_wal_checkpoint() the two output variables cannot be \n    # tested. So just test that no error is returned when attempting to\n    # checkpoint a db in rollback mode.\n    do_test $tn.2.2.a { checkpoint db passive aux3 } {}\n  } else {\n    do_test $tn.2.2.b { checkpoint db passive aux3 } {0 -1 -1}\n  }\n\n  # EVIDENCE-OF: R-62028-47212 All calls obtain an exclusive \"checkpoint\"\n  # lock on the database file.\n  db close\n  testvfs tvfs\n  tvfs filter xShmLock\n  tvfs script filelock\n  proc filelock {method file handle details} {\n    # Test for an exclusive checkpoint lock. A checkpoint lock locks a\n    # single byte starting at offset 1.\n    if {$details == \"1 1 lock exclusive\"} { set ::seen_checkpoint_lock 1 }\n  }\n  sqlite3 db test.db -vfs tvfs\n  do_test $tn.3.1 {\n    execsql { INSERT INTO t1 VALUES('xyz') }\n    unset -nocomplain ::seen_checkpoint_lock\n    checkpoint db passive\n    set ::seen_checkpoint_lock\n  } {1}\n  db close\n  tvfs delete\n  reset_db\n\n\n \n\n  #-----------------------------------------------------------------------\n  # EVIDENCE-OF: R-10421-19736 If any other process is running a\n  # checkpoint operation at the same time, the lock cannot be obtained and\n  # SQLITE_BUSY is returned.\n  #\n  # EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,\n  # it will not be invoked in this case.\n  #\n  testvfs tvfs\n  tvfs filter xWrite\n  sqlite3 db test.db -vfs tvfs\n  sqlite3 db2 test.db -vfs tvfs\n\n  do_test $tn.3.2.1 {\n    db2 eval {\n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(x, y);\n      INSERT INTO t1 VALUES(1,2);\n      INSERT INTO t1 VALUES(3,4);\n      INSERT INTO t1 VALUES(5,6);\n    }\n    file size test.db-wal\n  } [wal_file_size 5 1024]\n\n\n  # Connection [db] runs a checkpoint. During this checkpoint, each\n  # time it calls xWrite() to write a page into the database file, we\n  # attempt to start a checkpoint using [db2]. According to the \n  # first requirement being tested, this should return SQLITE_BUSY. According\n  # to the second, the busy-handler belonging to [db2] should not be\n  # invoked.\n  #\n  set ::write_count 0\n  set ::write_errors [list]\n  proc busy_callback {args} {\n    lappend ::write_errors \"busy handler called!\"\n  }\n  proc write_callback {args} {\n    set rc [catch {checkpoint db2 passive} msg]\n    if {0==[regexp \"database is locked\" $msg] && $msg!=\"1 -1 -1\"} {\n      lappend ::write_errors \"$rc $msg\"\n    } \n    incr ::write_count\n  }\n  db2 busy busy_callback\n  tvfs script write_callback\n\n  do_test $tn.3.2.2 {\n    db eval {SELECT * FROM sqlite_master}\n    checkpoint db full\n    set ::write_count\n  } {2}\n\n  do_test $tn.3.2.3 {\n    set ::write_errors\n  } {}\n\n  db close\n  db2 close\n  tvfs delete\n\n  proc busy_handler {mode busy_handler_mode n} {\n    incr ::busy_handler_counter\n    switch -- $busy_handler_mode {\n      1 {\n        # Do nothing. Do not block.\n        return 1\n      }\n\n      2 {\n        # Close first the reader, then later the writer. Give up before\n        # closing the [db6] reader.\n        if {$n==5}  { catch {db2 eval commit} }\n        if {$n==10} { catch {db3 eval commit} }\n        if {$n==15} { return 1 }\n        return 0\n      }\n\n      3 {\n        # Close first the writer, then later the reader. And finally the \n        # [db6] reader.\n        if {$n==5}  { catch {db2 eval commit} }\n        if {$n==10} { catch {db3 eval commit} }\n        if {$n==15} { catch {db6 eval commit} }\n        return 0\n      }\n    }\n  }\n\n  foreach {mode busy_handler_mode} { \n    passive  1\n    full     1       full     2       full    3\n    restart  1       restart  2       restart  3\n    truncate 1       truncate 2       truncate 3\n  } {\n    set tp \"$tn.$mode.$busy_handler_mode\"\n\n    set ::sync_counter 0\n\n    # Set up a callback function for xSync and xWrite calls made during\n    # the checkpoint.\n    #\n    set ::checkpoint_ongoing 0\n    proc tvfs_callback {method args} {\n      if {$::checkpoint_ongoing==0} return\n\n      set tail [file tail [lindex $args 0]]\n      if {$method == \"xSync\" && $tail == \"test.db\"} {\n        incr ::sync_counter\n      }\n      if {$method == \"xWrite\" && $tail==\"test.db\"} {\n        if {$::write_ok < 0} {\n          set ::write_ok [expr ![catch {db5 eval { BEGIN IMMEDIATE }}]]\n          catch { db5 eval ROLLBACK }\n        }\n        if {$::read_ok < 0} {\n          set ::read_ok [expr ![catch {db5 eval { SELECT * FROM t1 }}]]\n        }\n\n        # If one has not already been opened, open a read-transaction using\n        # connection [db6]\n        catch { db6 eval { BEGIN ; SELECT * FROM sqlite_master } } msg\n      }\n      if {$method == \"xShmLock\" } {\n        set details [lindex $args 2]\n        if {$details == \"0 1 lock exclusive\"} { set ::seen_writer_lock 1 }\n      }\n    }\n\n    catch { db close }\n    forcedelete test.db\n    testvfs tvfs\n    sqlite3 db test.db -vfs tvfs\n    #tvfs filter xSync\n    tvfs script tvfs_callback\n\n    do_execsql_test $tp.0 {\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n      PRAGMA journal_mode = wal;\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      INSERT INTO t1 VALUES(5, 6);\n    } {wal}\n\n    # Open a reader on the current database snapshot.\n    do_test $tp.1 {\n      sqlite3 db2 test.db -vfs tvfs\n      execsql {\n        BEGIN;\n          SELECT * FROM t1 UNION ALL SELECT * FROM t2;\n      } db2\n    } {1 2 3 4 5 6}\n\n    # Open a writer. Write a transaction. Then begin, but do not commit,\n    # a second transaction.\n    do_test $tp.2 {\n      sqlite3 db3 test.db -vfs tvfs\n      execsql {\n        INSERT INTO t2 VALUES(7, 8);\n        BEGIN;\n          INSERT INTO t2 VALUES(9, 10);\n          SELECT * FROM t1 UNION ALL SELECT * FROM t2;\n      } db3\n    } {1 2 3 4 5 6 7 8 9 10}\n\n    sqlite3 db5 test.db -vfs tvfs\n    sqlite3 db6 test.db -vfs tvfs\n\n    # Register a busy-handler with connection [db].\n    #\n    db busy [list busy_handler $mode $busy_handler_mode]\n    set ::sync_counter 0\n    set ::busy_handler_counter 0\n    set ::read_ok -1\n    set ::write_ok -1\n    set ::seen_writer_lock 0\n    \n    set ::checkpoint_ongoing 1\n    do_test $tp.3 {\n      checkpoint db $mode main\n      set {} {}\n    } {}\n    set ::checkpoint_ongoing 0\n    set ::did_restart_blocking [expr {[catch {db6 eval commit}]}]\n\n    if { $mode==\"passive\" } {\n      # EVIDENCE-OF: R-16333-64433 Checkpoint as many frames as possible\n      # without waiting for any database readers or writers to finish, then\n      # sync the database file if all frames in the log were checkpointed.\n      #\n      #   \"As many frames as possible\" means all but the last two transactions\n      #   (the two that write to table t2, of which the scond is unfinished).\n      #   So copying the db file only we see the t1 change, but not the t2\n      #   modifications.\n      #\n      #   The busy handler is not invoked (see below) and the db reader and\n      #   writer are still active - so the checkpointer did not wait for either\n      #   readers or writers. As a result the checkpoint was not finished and\n      #   so the db file is not synced.\n      #\n      # EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked\n      # in the SQLITE_CHECKPOINT_PASSIVE mode.\n      #\n      #   It's not. Test case \"$tp.6\".\n      #\n      do_test $tp.4 {\n        forcecopy test.db abc.db\n        sqlite3 db4 abc.db\n        db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }\n      } {1 2 3 4 5 6}\n      do_test $tp.5 { set ::sync_counter } 0\n      do_test $tp.6 { set ::busy_handler_counter } 0\n      db4 close\n  \n      db2 eval COMMIT\n      db3 eval COMMIT\n  \n      # EVIDENCE-OF: R-65499-53765 On the other hand, passive mode might leave\n      # the checkpoint unfinished if there are concurrent readers or writers.\n      #\n      #   The reader and writer have now dropped their locks. And so a \n      #   checkpoint now is able to checkpoint more frames. Showing that the\n      #   attempt above was left \"unfinished\".\n      #\n      #   Also, because the checkpoint finishes this time, the db is synced.\n      #   Which is part of R-16333-64433 above.\n      #\n      set ::checkpoint_ongoing 1\n      do_test $tp.7 {\n        checkpoint db $mode main\n        forcecopy test.db abc.db\n        sqlite3 db4 abc.db\n        db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }\n      } {1 2 3 4 5 6 7 8 9 10}\n      set ::checkpoint_ongoing 0\n      do_test $tp.7 { set ::sync_counter } 1\n      do_test $tp.8 { set ::busy_handler_counter } 0\n      db4 close\n    }\n\n    if { $mode==\"full\" || $mode==\"restart\" || $mode==\"truncate\" } {\n\n      # EVIDENCE-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and\n      # TRUNCATE modes also obtain the exclusive \"writer\" lock on the \n      # database file.\n      #\n      #   Or at least attempts to obtain.\n      #\n      do_test $tp.9 {\n        set ::seen_writer_lock\n      } {1}\n\n      if {$busy_handler_mode==2 || $busy_handler_mode==3} {\n        # EVIDENCE-OF: R-59171-47567 This mode blocks (it invokes the\n        # busy-handler callback) until there is no database writer and all\n        # readers are reading from the most recent database snapshot.\n        #\n        #   The test below shows that both the reader and writer have \n        #   finished:\n        #\n        #   Also restated by the following two. That both busy_handler_mode\n        #   values 2 and 3 work show that both of the following are true - as\n        #   they release the reader and writer transactions in different\n        #   orders.\n        #\n        # EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained\n        # immediately, and a busy-handler is configured, it is invoked and the\n        # writer lock retried until either the busy-handler returns 0 or the\n        # lock is successfully obtained.\n        #\n        # EVIDENCE-OF: R-48107-00250 The busy-handler is also invoked while\n        # waiting for database readers as described above.\n        #\n        do_test $tp.7 {\n          list [catchsql COMMIT db2] [catchsql COMMIT db3]\n        } [list                                             \\\n            {1 {cannot commit - no transaction is active}}  \\\n            {1 {cannot commit - no transaction is active}}  \\\n        ]\n\n        # EVIDENCE-OF: R-29177-48281 It then checkpoints all frames in the log\n        # file and syncs the database file.\n        #\n        do_test $tp.8 {\n          forcecopy test.db abc.db\n          sqlite3 db4 abc.db\n          db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }\n        } {1 2 3 4 5 6 7 8 9 10}\n        do_test $tp.9 { set ::sync_counter } 1\n        db4 close\n\n        # EVIDENCE-OF: R-51867-44713 This mode blocks new database writers\n        # while it is pending, but new database readers are allowed to continue\n        # unimpeded.\n        #\n        # EVIDENCE-OF: R-47276-58266 Like SQLITE_CHECKPOINT_FULL, this mode\n        # blocks new database writer attempts while it is pending, but does not\n        # impede readers.\n        #\n        #   The first of the above two refers to \"full\" mode. The second\n        #   to \"restart\".\n        #\n        do_test $tp.10.1 {\n          list $::write_ok $::read_ok\n        } {0 1}\n\n        # EVIDENCE-OF: R-12410-31217 This mode works the same way as\n        # SQLITE_CHECKPOINT_FULL with the addition that after checkpointing the\n        # log file it blocks (calls the busy-handler callback) until all\n        # readers are reading from the database file only.\n        #\n        #     The stuff above passed, so the first part of this requirement\n        #     is met. The second part is tested below. If the checkpoint mode\n        #     was \"restart\" or \"truncate\", then the busy-handler will have\n        #     been called to block on wal-file readers.\n        #\n        do_test $tp.11 {\n          set ::did_restart_blocking\n        } [expr {($mode==\"restart\"||$mode==\"truncate\")&&$busy_handler_mode==3}]\n\n        # EVIDENCE-OF: R-44699-57140 This mode works the same way as\n        # SQLITE_CHECKPOINT_RESTART with the addition that it also truncates\n        # the log file to zero bytes just prior to a successful return.\n        if {$mode==\"truncate\" && $busy_handler_mode==3} {\n          do_test $tp.12 {\n            file size test.db-wal\n          } 0\n        }\n      } elseif {$busy_handler_mode==1} {\n\n        # EVIDENCE-OF: R-34519-06271 SQLITE_BUSY is returned in this case.\n        if {$tn!=2} {\n          # ($tn==2) is the loop that uses \"PRAGMA wal_checkpoint\"\n          do_test $tp.13 { sqlite3_errcode db } {SQLITE_BUSY}\n        }\n\n        # EVIDENCE-OF: R-49155-63541 If the busy-handler returns 0 before the\n        # writer lock is obtained or while waiting for database readers, the\n        # checkpoint operation proceeds from that point in the same way as\n        # SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible\n        # without blocking any further.\n        do_test $tp.14 {\n          forcecopy test.db abc.db\n            sqlite3 db4 abc.db\n            db4 eval { SELECT * FROM t1 UNION ALL SELECT * FROM t2 }\n        } {1 2 3 4 5 6}\n        do_test $tp.15 { set ::sync_counter } 0\n        do_test $tp.16 { set ::busy_handler_counter } 1\n        db4 close\n      }\n    }\n\n    db2 close\n    db3 close\n    db5 close\n    db6 close\n  }\n\n  db close\n  tvfs delete\n}\n\n#-----------------------------------------------------------------------\n# EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint\n# mode:\n#\n#   Valid checkpoint modes are 0, 1, 2 and 3.\n#\nsqlite3 db test.db\nforeach {tn mode res} {\n  0 -1001    {1 {SQLITE_MISUSE - not an error}}\n  1 -1       {1 {SQLITE_MISUSE - not an error}}\n  2  0       {0 {0 -1 -1}}\n  3  1       {0 {0 -1 -1}}\n  4  2       {0 {0 -1 -1}}\n  5  3       {0 {0 -1 -1}}\n  6  4       {1 {SQLITE_MISUSE - not an error}}\n  7  114     {1 {SQLITE_MISUSE - not an error}}\n  8  1000000 {1 {SQLITE_MISUSE - not an error}}\n} {\n  do_test 4.$tn {\n    list [catch \"wal_checkpoint_v2 db $mode\" msg] $msg\n  } $res\n}\ndb close\n\nforeach tn {1 2 3} {\n  forcedelete test.db test.db2 test.db3\n  testvfs tvfs\n\n  sqlite3 db test.db -vfs tvfs\n  execsql {\n    ATTACH 'test.db2' AS aux2;\n    ATTACH 'test.db3' AS aux3;\n    PRAGMA main.journal_mode = WAL;\n    PRAGMA aux2.journal_mode = WAL;\n    PRAGMA aux3.journal_mode = WAL;\n\n    CREATE TABLE main.t1(x,y);\n    CREATE TABLE aux2.t2(x,y);\n    CREATE TABLE aux3.t3(x,y);\n\n    INSERT INTO t1 VALUES('a', 'b');\n    INSERT INTO t2 VALUES('a', 'b');\n    INSERT INTO t3 VALUES('a', 'b');\n  }\n  sqlite3 db2 test.db2 -vfs tvfs\n\n  switch -- $tn {\n    1 {\n      # EVIDENCE-OF: R-41299-52117 If no error (SQLITE_BUSY or otherwise) is\n      # encountered while processing the attached databases, SQLITE_OK is\n      # returned.\n      do_test 5.$tn.1 {\n        lindex [wal_checkpoint_v2 db truncate] 0\n      } {0}    ;# 0 -> SQLITE_OK\n      do_test 5.$tn.2 {\n        list [expr [file size test.db-wal]==0]  \\\n             [expr [file size test.db2-wal]==0] \\\n             [expr [file size test.db3-wal]==0]\n      } {1 1 1}\n    }\n\n    2 {\n      # EVIDENCE-OF: R-38578-34175 If an SQLITE_BUSY error is encountered when\n      # processing one or more of the attached WAL databases, the operation is\n      # still attempted on any remaining attached databases and SQLITE_BUSY is\n      # returned at the end.\n      db2 eval { BEGIN; INSERT INTO t2 VALUES('d', 'e'); }\n      do_test 5.$tn.1 {\n        lindex [wal_checkpoint_v2 db truncate] 0\n      } {1}    ;# 1 -> SQLITE_BUSY\n      do_test 5.$tn.2 {\n        list [expr [file size test.db-wal]==0]  \\\n             [expr [file size test.db2-wal]==0] \\\n             [expr [file size test.db3-wal]==0]\n      } {1 0 1}\n      db2 eval ROLLBACK\n    }\n\n    3 {\n      # EVIDENCE-OF: R-38049-07913 If any other error occurs while processing\n      # an attached database, processing is abandoned and the error code is\n      # returned to the caller immediately.\n      tvfs filter xWrite\n      tvfs script inject_ioerr\n      proc inject_ioerr {method file args} {\n        if {[file tail $file]==\"test.db2\"} {\n          return \"SQLITE_IOERR\"\n        }\n        return 0\n      }\n      do_test 5.$tn.1 {\n        list [catch { wal_checkpoint_v2 db truncate } msg] $msg\n      } {1 {SQLITE_IOERR - disk I/O error}}\n      do_test 5.$tn.2 {\n        list [expr [file size test.db-wal]==0]  \\\n             [expr [file size test.db2-wal]==0] \\\n             [expr [file size test.db3-wal]==0]\n      } {1 0 0}\n      tvfs script \"\"\n    }\n  }\n\n  db close\n  db2 close\n}\n\nreset_db\nsqlite3 db2 test.db\n\ndo_test 6.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0; \n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  file size test.db-wal\n} [wal_file_size 3 1024]\n\ndo_test 6.2 {\n  db2 eval { BEGIN; SELECT * FROM t1; }\n  db  eval { INSERT INTO t1 VALUES(3, 4) }\n  file size test.db-wal\n} [wal_file_size 4 1024]\n\n#   At this point the log file contains 4 frames. 3 of which it should\n#   be possible to checkpoint.\n#\n# EVIDENCE-OF: R-16642-42503 If pnLog is not NULL, then *pnLog is set to\n# the total number of frames in the log file or to -1 if the checkpoint\n# could not run because of an error or because the database is not in\n# WAL mode.\n#\n# EVIDENCE-OF: R-10514-25250 If pnCkpt is not NULL,then *pnCkpt is set\n# to the total number of checkpointed frames in the log file (including\n# any that were already checkpointed before the function was called) or\n# to -1 if the checkpoint could not run due to an error or because the\n# database is not in WAL mode.\n#\ndo_test 6.4 {\n  lrange [wal_checkpoint_v2 db passive] 1 2\n} {4 3} \n\n# EVIDENCE-OF: R-37257-17813 Note that upon successful completion of an\n# SQLITE_CHECKPOINT_TRUNCATE, the log file will have been truncated to\n# zero bytes and so both *pnLog and *pnCkpt will be set to zero.\n#\ndo_test 6.5 {\n  db2 eval COMMIT\n  wal_checkpoint_v2 db truncate\n} {0 0 0}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/e_walhook.test",
    "content": "# 2014 December 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nset testprefix e_walhook\n\n\n# EVIDENCE-OF: R-00752-43975 The sqlite3_wal_hook() function is used to\n# register a callback that is invoked each time data is committed to a\n# database in wal mode.\n#\n#   1.1: shows that the wal-hook is not invoked in rollback mode.\n#   1.2: but is invoked in wal mode.\n#\nset ::wal_hook_count 0\nproc my_wal_hook {args} {\n  incr ::wal_hook_count\n  return 0\n}\n\ndo_test 1.1.1 {\n  db wal_hook my_wal_hook\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n  }\n  set ::wal_hook_count\n} 0\ndo_test 1.1.2 {\n  execsql { PRAGMA journal_mode = wal }\n  set ::wal_hook_count\n} 0\n\ndo_test 1.3 {\n  execsql { INSERT INTO t1 VALUES(2) }\n  set wal_hook_count\n} 1\n\ndo_test 1.4 {\n  execsql { \n    BEGIN;\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    COMMIT;\n  }\n  set wal_hook_count\n} 2\n\n# EVIDENCE-OF: R-65366-15139 The callback is invoked by SQLite after the\n# commit has taken place and the associated write-lock on the database\n# released\n#\nset ::read_ok 0\nproc my_wal_hook {args} {\n  sqlite3 db2 test.db\n  if {[db2 eval { SELECT * FROM t1 }] == \"1 2 3 4 5\"} {\n    set ::read_ok 1\n  }\n  db2 close\n}\ndo_test 2.1 {\n  execsql { INSERT INTO t1 VALUES(5) }\n  set ::read_ok\n} 1\n\n# EVIDENCE-OF: R-44294-52863 The third parameter is the name of the\n# database that was written to - either \"main\" or the name of an\n# ATTACH-ed database.\n#\n# EVIDENCE-OF: R-18913-19355 The fourth parameter is the number of pages\n# currently in the write-ahead log file, including those that were just\n# committed.\n#\nset ::wal_hook_args [list]\nproc my_wal_hook {dbname nEntry} {\n  set ::wal_hook_args [list $dbname $nEntry]\n}\nforcedelete test.db2\ndo_test 3.0 {\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE aux.t2(x);\n    PRAGMA aux.journal_mode = wal;\n  }\n} {wal}\n\n# Database \"aux\"\ndo_test 3.1.1 {\n  set wal_hook_args [list]\n  execsql { INSERT INTO t2 VALUES('a') }\n} {}\ndo_test 3.1.2 {\n  set wal_hook_args\n} [list aux [wal_frame_count test.db2-wal 1024]]\n\n# Database \"main\"\ndo_test 3.2.1 {\n  set wal_hook_args [list]\n  execsql { INSERT INTO t1 VALUES(6) }\n} {}\ndo_test 3.1.2 {\n  set wal_hook_args\n} [list main [wal_frame_count test.db-wal 1024]]\n\n# EVIDENCE-OF: R-14034-00929 If an error code is returned, that error\n# will propagate back up through the SQLite code base to cause the\n# statement that provoked the callback to report an error, though the\n# commit will have still occurred.\n#\nproc my_wal_hook {args} { return 1 ;# SQLITE_ERROR }\ndo_catchsql_test 4.1 {\n  INSERT INTO t1 VALUES(7)\n} {1 {SQL logic error}}\n\nproc my_wal_hook {args} { return 5 ;# SQLITE_BUSY }\ndo_catchsql_test 4.2 {\n  INSERT INTO t1 VALUES(8)\n} {1 {database is locked}}\n\nproc my_wal_hook {args} { return 14 ;# SQLITE_CANTOPEN }\ndo_catchsql_test 4.3 {\n  INSERT INTO t1 VALUES(9)\n} {1 {unable to open database file}}\n\ndo_execsql_test 4.4 {\n  SELECT * FROM t1\n} {1 2 3 4 5 6 7 8 9}\n\n# EVIDENCE-OF: R-10466-53920 Calling sqlite3_wal_hook() replaces any\n# previously registered write-ahead log callback.\nset ::old_wal_hook 0\nproc my_old_wal_hook {args} {\n  incr ::old_wal_hook \n  return 0\n}\ndb wal_hook my_old_wal_hook\ndo_test 5.1 {\n  execsql { INSERT INTO t1 VALUES(10) }\n  set ::old_wal_hook\n} {1}\n\n# Replace old_wal_hook. Observe that it is not invoked after it has \n# been replaced.\nproc my_new_wal_hook {args} { return 0 }\ndb wal_hook my_new_wal_hook\ndo_test 5.2 {\n  execsql { INSERT INTO t1 VALUES(11) }\n  set ::old_wal_hook\n} {1}\n\n\n\n# EVIDENCE-OF: R-57445-43425 Note that the sqlite3_wal_autocheckpoint()\n# interface and the wal_autocheckpoint pragma both invoke\n# sqlite3_wal_hook() and will overwrite any prior sqlite3_wal_hook()\n# settings.\n#\nset ::old_wal_hook 0\nproc my_old_wal_hook {args} { incr ::old_wal_hook ; return 0 }\ndb wal_hook my_old_wal_hook\ndo_test 6.1.1 {\n  execsql { INSERT INTO t1 VALUES(12) }\n  set ::old_wal_hook\n} {1}\ndo_test 6.1.2 {\n  execsql { PRAGMA wal_autocheckpoint = 1000 }\n  execsql { INSERT INTO t1 VALUES(12) }\n  set ::old_wal_hook\n} {1}\n\n# EVIDENCE-OF: R-52629-38967 The first parameter passed to the callback\n# function when it is invoked is a copy of the third parameter passed to\n# sqlite3_wal_hook() when registering the callback.\n#\n#    This is tricky to test using the tcl interface. However, the\n#    mechanism used to invoke the tcl script registered as a wal-hook\n#    depends on the context pointer being correctly passed through. And\n#    since multiple different wal-hook scripts have been successfully\n#    invoked by this test script, consider this tested.\n#\n# EVIDENCE-OF: R-23378-42536 The second is a copy of the database\n# handle.\n#\n#    There is an assert() in the C wal-hook used by tclsqlite.c to\n#    prove this. And that hook has been invoked multiple times when\n#    running this script. So consider this requirement tested as well.\n#\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/emptytable.test",
    "content": "# 2017-02-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases to show that a join involving an empty table is very fast.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_execsql_test emptytable-100 {\n  CREATE TABLE t1(a);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n    INSERT INTO t1(a) SELECT x FROM c;\n  CREATE TABLE empty(x);\n  SELECT count(*) FROM t1;\n} {100}\n\n# Interrupt queries after 1M cycles to prevent burning excess CPU\nproc stopDb {args} {\n  db interrupt\n}\ndb progress 1000000 {stopDb}\n\n# Prior to the query planner optimization on 2017-02-15, this query would\n# take a ridiculous amount of time.  If that optimization stops working,\n# the result here will be in interrupt for running too long.\n#\ndo_catchsql_test emptytable-110 {\n  SELECT count(*) FROM t1, t1, t1, t1, t1, t1, empty;\n} {0 0}\n\ndo_catchsql_test emptytable-120 {\n  SELECT count(*) FROM t1, t1 LEFT JOIN empty;\n} {0 10000}\ndo_catchsql_test emptytable-121 {\n  SELECT count(*) FROM t1, t1 LEFT JOIN t1, empty;\n} {0 0}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/enc.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The focus of\n# this file is testing the SQLite routines used for converting between the\n# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and\n# UTF-16be).\n#\n# $Id: enc.test,v 1.7 2007/05/23 16:23:09 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Skip this test if the build does not support multiple encodings.\n#\nifcapable {!utf16} {\n  finish_test\n  return\n}\n\nproc do_bincmp_test {testname got expect} {\n  binary scan $expect \\c* expectvals\n  binary scan $got \\c* gotvals\n  do_test $testname [list set dummy $gotvals] $expectvals\n}\n\n# $utf16 is a UTF-16 encoded string. Swap each pair of bytes around\n# to change the byte-order of the string.\nproc swap_byte_order {utf16} {\n  binary scan $utf16 \\c* ints\n\n  foreach {a b} $ints {\n    lappend ints2 $b\n    lappend ints2 $a\n  }\n\n  return [binary format \\c* $ints2]\n}\n\n#\n# Test that the SQLite routines for converting between UTF encodings\n# produce the same results as their TCL counterparts.\n#\n# $testname is the prefix to be used for the test names.\n# $str is a string to use for testing (encoded in UTF-8, as normal for TCL).\n#\n# The test procedure is:\n# 1. Convert the string from UTF-8 to UTF-16le and check that the TCL and\n#    SQLite routines produce the same results.\n#\n# 2. Convert the string from UTF-8 to UTF-16be and check that the TCL and\n#    SQLite routines produce the same results.\n#\n# 3. Use the SQLite routines to convert the native machine order UTF-16\n#    representation back to the original UTF-8. Check that the result\n#    matches the original representation.\n#\n# 4. Add a byte-order mark to each of the UTF-16 representations and\n#    check that the SQLite routines can convert them back to UTF-8.  For\n#    byte-order mark info, refer to section 3.10 of the unicode standard.\n#\n# 5. Take the byte-order marked UTF-16 strings from step 4 and ensure\n#    that SQLite can convert them both to native byte order UTF-16 \n#    strings, sans BOM.\n#\n# Coverage:\n#\n# sqlite_utf8to16be (step 2)\n# sqlite_utf8to16le (step 1)\n# sqlite_utf16to8 (steps 3, 4)\n# sqlite_utf16to16le (step 5)\n# sqlite_utf16to16be (step 5)\n#\nproc test_conversion {testname str} {\n \n  # Step 1.\n  set utf16le_sqlite3 [test_translate $str UTF8 UTF16LE]\n  set utf16le_tcl [encoding convertto unicode $str]\n  append utf16le_tcl \"\\x00\\x00\"\n  if { $::tcl_platform(byteOrder)!=\"littleEndian\" } {\n    set utf16le_tcl [swap_byte_order $utf16le_tcl]\n  }\n  do_bincmp_test $testname.1 $utf16le_sqlite3 $utf16le_tcl\n  set utf16le $utf16le_tcl\n\n  # Step 2.\n  set utf16be_sqlite3 [test_translate $str UTF8 UTF16BE]\n  set utf16be_tcl [encoding convertto unicode $str]\n  append utf16be_tcl \"\\x00\\x00\"\n  if { $::tcl_platform(byteOrder)==\"littleEndian\" } {\n    set utf16be_tcl [swap_byte_order $utf16be_tcl]\n  }\n  do_bincmp_test $testname.2 $utf16be_sqlite3 $utf16be_tcl\n  set utf16be $utf16be_tcl\n \n  # Step 3.\n  if { $::tcl_platform(byteOrder)==\"littleEndian\" } {\n    set utf16 $utf16le\n  } else {\n    set utf16 $utf16be\n  }\n  set utf8_sqlite3 [test_translate $utf16 UTF16 UTF8]\n  do_bincmp_test $testname.3 $utf8_sqlite3 [binarize $str]\n\n  # Step 4 (little endian).\n  append utf16le_bom \"\\xFF\\xFE\" $utf16le\n  set utf8_sqlite3 [test_translate $utf16le_bom UTF16 UTF8 1]\n  do_bincmp_test $testname.4.le $utf8_sqlite3 [binarize $str]\n\n  # Step 4 (big endian).\n  append utf16be_bom \"\\xFE\\xFF\" $utf16be\n  set utf8_sqlite3 [test_translate $utf16be_bom UTF16 UTF8]\n  do_bincmp_test $testname.4.be $utf8_sqlite3 [binarize $str]\n\n  # Step 5 (little endian to little endian).\n  set utf16_sqlite3 [test_translate $utf16le_bom UTF16LE UTF16LE]\n  do_bincmp_test $testname.5.le.le $utf16_sqlite3 $utf16le\n\n  # Step 5 (big endian to big endian).\n  set utf16_sqlite3 [test_translate $utf16be_bom UTF16 UTF16BE]\n  do_bincmp_test $testname.5.be.be $utf16_sqlite3 $utf16be\n\n  # Step 5 (big endian to little endian).\n  set utf16_sqlite3 [test_translate $utf16be_bom UTF16 UTF16LE]\n  do_bincmp_test $testname.5.be.le $utf16_sqlite3 $utf16le\n\n  # Step 5 (little endian to big endian).\n  set utf16_sqlite3 [test_translate $utf16le_bom UTF16 UTF16BE]\n  do_bincmp_test $testname.5.le.be $utf16_sqlite3 $utf16be\n}\n\ntranslate_selftest\n\ntest_conversion enc-1 \"hello world\"\ntest_conversion enc-2 \"sqlite\"\ntest_conversion enc-3 \"\"\ntest_conversion enc-X \"\\u0100\"\ntest_conversion enc-4 \"\\u1234\"\ntest_conversion enc-5 \"\\u4321abc\"\ntest_conversion enc-6 \"\\u4321\\u1234\"\ntest_conversion enc-7 [string repeat \"abcde\\u00EF\\u00EE\\uFFFCabc\" 100]\ntest_conversion enc-8 [string repeat \"\\u007E\\u007F\\u0080\\u0081\" 100]\ntest_conversion enc-9 [string repeat \"\\u07FE\\u07FF\\u0800\\u0801\\uFFF0\" 100]\ntest_conversion enc-10 [string repeat \"\\uE000\" 100]\n\nproc test_collate {enc zLeft zRight} {\n  return [string compare $zLeft $zRight]\n}\nadd_test_collate $::DB 0 0 1\ndo_test enc-11.1 {\n  execsql {\n    CREATE TABLE ab(a COLLATE test_collate, b);\n    INSERT INTO ab VALUES(CAST (X'C388' AS TEXT), X'888800');\n    INSERT INTO ab VALUES(CAST (X'C0808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808388' AS TEXT), X'888800');\n    CREATE INDEX ab_i ON ab(a, b);\n  }\n} {}\ndo_test enc-11.2 {\n  set cp200 \"\\u00C8\"\n  execsql {\n    SELECT count(*) FROM ab WHERE a = $::cp200;\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/enc2.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The focus of\n# this file is testing the SQLite routines used for converting between the\n# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and\n# UTF-16be).\n#\n# $Id: enc2.test,v 1.29 2007/10/09 08:29:32 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If UTF16 support is disabled, ignore the tests in this file\n#\nifcapable {!utf16} {\n  finish_test\n  return\n}\n\n# The rough organisation of tests in this file is:\n#\n# enc2.1.*: Simple tests with a UTF-8 db.\n# enc2.2.*: Simple tests with a UTF-16LE db.\n# enc2.3.*: Simple tests with a UTF-16BE db.\n# enc2.4.*: Test that attached databases must have the same text encoding\n#           as the main database.\n# enc2.5.*: Test the behavior of the library when a collation sequence is\n#           not available for the most desirable text encoding.\n# enc2.6.*: Similar test for user functions.\n# enc2.7.*: Test that the VerifyCookie opcode protects against assuming the\n#           wrong text encoding for the database.\n# enc2.8.*: Test sqlite3_complete16()\n#\n\ndb close\n\n# Return the UTF-8 representation of the supplied UTF-16 string $str. \nproc utf8 {str} {\n  # If $str ends in two 0x00 0x00 bytes, knock these off before\n  # converting to UTF-8 using TCL.\n  binary scan $str \\c* vals\n  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {\n    set str [binary format \\c* [lrange $vals 0 end-2]]\n  }\n\n  set r [encoding convertfrom unicode $str]\n  return $r\n}\n\n#\n# This proc contains all the tests in this file. It is run\n# three times. Each time the file 'test.db' contains a database\n# with the following contents:\nset dbcontents {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES('one', 'I', 1);\n}\n# This proc tests that we can open and manipulate the test.db \n# database, and that it is possible to retreive values in\n# various text encodings.\n#\nproc run_test_script {t enc} {\n\n# Open the database and pull out a (the) row.\ndo_test $t.1 {\n  sqlite3 db test.db; set DB [sqlite3_connection_pointer db]\n  execsql {SELECT * FROM t1}\n} {one I 1}\n\n# Insert some data\ndo_test $t.2 {\n  execsql {INSERT INTO t1 VALUES('two', 'II', 2);}\n  execsql {SELECT * FROM t1}\n} {one I 1 two II 2}\n\n# Insert some data \ndo_test $t.3 {\n  execsql {\n    INSERT INTO t1 VALUES('three','III',3);\n    INSERT INTO t1 VALUES('four','IV',4);\n    INSERT INTO t1 VALUES('five','V',5);\n  }\n  execsql {SELECT * FROM t1}\n} {one I 1 two II 2 three III 3 four IV 4 five V 5}\n\n# Use the index\ndo_test $t.4 {\n  execsql {\n    SELECT * FROM t1 WHERE a = 'one';\n  }\n} {one I 1}\ndo_test $t.5 {\n  execsql {\n    SELECT * FROM t1 WHERE a = 'four';\n  }\n} {four IV 4}\nifcapable subquery {\n  do_test $t.6 {\n    execsql {\n      SELECT * FROM t1 WHERE a IN ('one', 'two');\n    }\n  } {one I 1 two II 2}\n}\n\n# Now check that we can retrieve data in both UTF-16 and UTF-8\ndo_test $t.7 {\n  set STMT [sqlite3_prepare $DB \"SELECT a FROM t1 WHERE c>3;\" -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_column_text $STMT 0\n} {four}\n\ndo_test $t.8 {\n  sqlite3_step $STMT\n  utf8 [sqlite3_column_text16 $STMT 0]\n} {five}\n\ndo_test $t.9 {\n  sqlite3_finalize $STMT\n} SQLITE_OK\n\nifcapable vacuum {\n  execsql VACUUM\n}\n\ndo_test $t.10 {\n  db eval {PRAGMA encoding}\n} $enc\n\n}\n\n# The three unicode encodings understood by SQLite.\nset encodings [list UTF-8 UTF-16le UTF-16be]\n\nset sqlite_os_trace 0\nset i 1\nforeach enc $encodings {\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval \"PRAGMA encoding = \\\"$enc\\\"\"\n  execsql $dbcontents\n  do_test enc2-$i.0.1 {\n    db eval {PRAGMA encoding}\n  } $enc\n  do_test enc2-$i.0.2 {\n    db eval {PRAGMA encoding=UTF8}\n    db eval {PRAGMA encoding}\n  } $enc\n  do_test enc2-$i.0.3 {\n    db eval {PRAGMA encoding=UTF16le}\n    db eval {PRAGMA encoding}\n  } $enc\n  do_test enc2-$i.0.4 {\n    db eval {PRAGMA encoding=UTF16be}\n    db eval {PRAGMA encoding}\n  } $enc\n\n  db close\n  run_test_script enc2-$i $enc\n  db close\n  incr i\n}\n\n# Test that it is an error to try to attach a database with a different\n# encoding to the main database.\nifcapable attach {\n  do_test enc2-4.1 {\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval \"PRAGMA encoding = 'UTF-8'\"\n    db eval \"CREATE TABLE abc(a, b, c);\"\n  } {}\n  do_test enc2-4.2 {\n    forcedelete test2.db\n    sqlite3 db2 test2.db\n    db2 eval \"PRAGMA encoding = 'UTF-16'\"\n    db2 eval \"CREATE TABLE abc(a, b, c);\"\n  } {}\n  do_test enc2-4.3 {\n    catchsql {\n      ATTACH 'test2.db' as aux;\n    }\n  } {1 {attached databases must use the same text encoding as main database}}\n  db2 close\n  db close\n}\n\n# The following tests - enc2-5.* - test that SQLite selects the correct\n# collation sequence when more than one is available.\n\nset ::values [list one two three four five]\nset ::test_collate_enc INVALID\nproc test_collate {enc lhs rhs} {\n  set ::test_collate_enc $enc\n  set l [lsearch -exact $::values $lhs]\n  set r [lsearch -exact $::values $rhs]\n  set res [expr $l - $r]\n  # puts \"enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res\"\n  return $res\n}\n\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-5.0 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('one');\n    INSERT INTO t5 VALUES('two');\n    INSERT INTO t5 VALUES('five');\n    INSERT INTO t5 VALUES('three');\n    INSERT INTO t5 VALUES('four');\n  }\n} {}\ndo_test enc2-5.1 {\n  add_test_collate $DB 1 1 1\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate;}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-8}\ndo_test enc2-5.2 {\n  add_test_collate $DB 0 1 0\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16LE}\ndo_test enc2-5.3 {\n  add_test_collate $DB 0 0 1\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16BE}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\nexecsql {pragma encoding = 'UTF-16LE'}\ndo_test enc2-5.4 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('one');\n    INSERT INTO t5 VALUES('two');\n    INSERT INTO t5 VALUES('five');\n    INSERT INTO t5 VALUES('three');\n    INSERT INTO t5 VALUES('four');\n  }\n} {}\ndo_test enc2-5.5 {\n  add_test_collate $DB 1 1 1\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16LE}\ndo_test enc2-5.6 {\n  add_test_collate $DB 1 0 1\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16BE}\ndo_test enc2-5.7 {\n  add_test_collate $DB 1 0 0\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-8}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\nexecsql {pragma encoding = 'UTF-16BE'}\ndo_test enc2-5.8 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('one');\n    INSERT INTO t5 VALUES('two');\n    INSERT INTO t5 VALUES('five');\n    INSERT INTO t5 VALUES('three');\n    INSERT INTO t5 VALUES('four');\n  }\n} {}\ndo_test enc2-5.9 {\n  add_test_collate $DB 1 1 1\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16BE}\ndo_test enc2-5.10 {\n  add_test_collate $DB 1 1 0\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16LE}\ndo_test enc2-5.11 {\n  add_test_collate $DB 1 0 0\n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-8}\n\n# Also test that a UTF-16 collation factory works.\ndo_test enc2-5-12 {\n  add_test_collate $DB 0 0 0\n  catchsql {\n    SELECT * FROM t5 ORDER BY 1 COLLATE test_collate\n  }\n} {1 {no such collation sequence: test_collate}}\ndo_test enc2-5.13 {\n  add_test_collate_needed $DB \n  set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate; }]\n  lappend res $::test_collate_enc\n} {one two three four five UTF-16BE}\ndo_test enc2-5.14 {\n  set ::sqlite_last_needed_collation\n} test_collate\n\ndb close\nforcedelete test.db\n\ndo_test enc2-5.15 {\n  sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]\n  add_test_collate_needed $::DB\n  set ::sqlite_last_needed_collation\n} {}\ndo_test enc2-5.16 {\n  execsql {CREATE TABLE t1(a varchar collate test_collate);}\n} {}\ndo_test enc2-5.17 {\n  set ::sqlite_last_needed_collation\n} {test_collate}\n\n# The following tests - enc2-6.* - test that SQLite selects the correct\n# user function when more than one is available.\n\nproc test_function {enc arg} {\n  return \"$enc $arg\"\n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\nexecsql {pragma encoding = 'UTF-8'}\ndo_test enc2-6.0 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('one');\n  }\n} {}\ndo_test enc2-6.1 {\n  add_test_function $DB 1 1 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-8 sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.2 {\n  add_test_function $DB 0 1 0\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16LE sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.3 {\n  add_test_function $DB 0 0 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16BE sqlite}}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\nexecsql {pragma encoding = 'UTF-16LE'}\ndo_test enc2-6.3 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('sqlite');\n  }\n} {}\ndo_test enc2-6.4 {\n  add_test_function $DB 1 1 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16LE sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.5 {\n  add_test_function $DB 0 1 0\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16LE sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.6 {\n  add_test_function $DB 0 0 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16BE sqlite}}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\nexecsql {pragma encoding = 'UTF-16BE'}\ndo_test enc2-6.7 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES('sqlite');\n  }\n} {}\ndo_test enc2-6.8 {\n  add_test_function $DB 1 1 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16BE sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.9 {\n  add_test_function $DB 0 1 0\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16LE sqlite}}\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test enc2-6.10 {\n  add_test_function $DB 0 0 1\n  execsql {\n    SELECT test_function('sqlite')\n  }\n} {{UTF-16BE sqlite}}\n\n\ndb close\nforcedelete test.db\n\n# The following tests - enc2-7.* - function as follows:\n#\n# 1: Open an empty database file assuming UTF-16 encoding.\n# 2: Open the same database with a different handle assuming UTF-8. Create\n#    a table using this handle.\n# 3: Read the sqlite_master table from the first handle. \n# 4: Ensure the first handle recognises the database encoding is UTF-8.\n#\ndo_test enc2-7.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = 'UTF-16';\n    SELECT * FROM sqlite_master;\n  }\n} {}\ndo_test enc2-7.2 {\n  set enc [execsql {\n    PRAGMA encoding;\n  }]\n  string range $enc 0 end-2 ;# Chop off the \"le\" or \"be\"\n} {UTF-16}\ndo_test enc2-7.3 {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA encoding = 'UTF-8';\n    CREATE TABLE abc(a, b, c);\n  } db2\n} {}\ndo_test enc2-7.4 {\n  execsql {\n    SELECT * FROM sqlite_master;\n  }\n} \"table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}\"\ndo_test enc2-7.5 {\n  execsql {\n    PRAGMA encoding;\n  }\n} {UTF-8}\n\ndb close\ndb2 close\n\nproc utf16 {utf8} {\n  set utf16 [encoding convertto unicode $utf8]\n  append utf16 \"\\x00\\x00\"\n  return $utf16\n}\nifcapable {complete} {\n  do_test enc2-8.1 {\n    sqlite3_complete16 [utf16 \"SELECT * FROM t1;\"]\n  } {1}\n  do_test enc2-8.2 {\n    sqlite3_complete16 [utf16 \"SELECT * FROM\"]\n  } {0}\n}\n\n# Test that the encoding of an empty database may still be set after the\n# (empty) schema has been initialized.\nforcedelete test.db\ndo_test enc2-9.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = 'UTF-8';\n    PRAGMA encoding;\n  }\n} {UTF-8}\ndo_test enc2-9.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = 'UTF-16le';\n    PRAGMA encoding;\n  }\n} {UTF-16le}\ndo_test enc2-9.3 {\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM sqlite_master;\n    PRAGMA encoding = 'UTF-8';\n    PRAGMA encoding;\n  }\n} {UTF-8}\ndo_test enc2-9.4 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = 'UTF-16le';\n    CREATE TABLE abc(a, b, c);\n    PRAGMA encoding;\n  }\n} {UTF-16le}\ndo_test enc2-9.5 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA encoding = 'UTF-8';\n    PRAGMA encoding;\n  }\n} {UTF-16le}\n\n# Ticket #1987.\n# Disallow encoding changes once the encoding has been set.\n#\ndo_test enc2-10.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(a);\n    PRAGMA encoding=UTF8;\n    CREATE TABLE t2(b);\n  }\n  db close\n  sqlite3 db test.db\n  db eval {\n    SELECT name FROM sqlite_master\n  }\n} {t1 t2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/enc3.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The focus of this file is testing of the proper handling of conversions\n# to the native text representation.\n#\n# $Id: enc3.test,v 1.8 2008/01/22 01:48:09 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {utf16} {\n  do_test enc3-1.1 {\n    execsql {\n      PRAGMA encoding=utf16le;\n      PRAGMA encoding;\n    }\n  } {UTF-16le}\n}\ndo_test enc3-1.2 {\n  execsql {\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES('abc''123',5);\n    SELECT * FROM t1\n  }\n} {abc'123 5}\ndo_test enc3-1.3 {\n  execsql {\n    SELECT quote(x) || ' ' || quote(y) FROM t1\n  }\n} {{'abc''123' 5}}\nifcapable {bloblit} {\n  do_test enc3-1.4 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(x'616263646566',NULL);\n      SELECT * FROM t1\n    }\n  } {abcdef {}}\n  do_test enc3-1.5 {\n    execsql {\n      SELECT quote(x) || ' ' || quote(y) FROM t1\n    }\n  } {{X'616263646566' NULL}}\n}\nifcapable {bloblit && utf16} {\n  do_test enc3-2.1 {\n    execsql {\n      PRAGMA encoding\n    }\n  } {UTF-16le}\n  do_test enc3-2.2 {\n    execsql {\n      CREATE TABLE t2(a);\n      INSERT INTO t2 VALUES(x'61006200630064006500');\n      SELECT CAST(a AS text) FROM t2 WHERE CAST(a AS text) LIKE 'abc%';\n    }\n  } {abcde}\n  do_test enc3-2.3 {\n    execsql {\n      SELECT CAST(x'61006200630064006500' AS text);\n    }\n  } {abcde}\n  do_test enc3-2.4 {\n    execsql {\n      SELECT rowid FROM t2\n       WHERE CAST(a AS text) LIKE CAST(x'610062002500' AS text);\n    }\n  } {1}\n}\n\n# Try to attach a database with a different encoding.\n#\nifcapable {utf16 && shared_cache} {\n  db close\n  forcedelete test8.db test8.db-journal\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n  sqlite3 dbaux test8.db\n  sqlite3 db test.db\n  db eval {SELECT 1 FROM sqlite_master LIMIT 1}\n  do_test enc3-3.1 {\n    dbaux eval {\n      PRAGMA encoding='utf8';\n      CREATE TABLE t1(x);\n      PRAGMA encoding\n    }\n  } {UTF-8}\n  do_test enc3-3.2 {\n    catchsql {\n      ATTACH 'test.db' AS utf16;\n      SELECT 1 FROM utf16.sqlite_master LIMIT 1;\n    } dbaux\n  } {1 {attached databases must use the same text encoding as main database}}\n  dbaux close\n  forcedelete test8.db test8.db-journal\n  sqlite3_enable_shared_cache $::enable_shared_cache\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/enc4.test",
    "content": "# 2010 Sept 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The focus of\n# this file is testing the SQLite routines used for converting between the\n# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and\n# UTF-16be).\n#\n# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If UTF16 support is disabled, ignore the tests in this file\n#\nifcapable {!utf16} {\n  finish_test\n  return\n}\n\ndb close\n\n# The three unicode encodings understood by SQLite.\nset encodings [list UTF-8 UTF-16le UTF-16be]\n\n# initial value to use in SELECT\nset inits [list 1 1.0 1. 1e0]\n\n# vals\nset vals [list\\\n\"922337203685477580792233720368547758079223372036854775807\"\\\n\"100000000000000000000000000000000000000000000000000000000\"\\\n\"1.0000000000000000000000000000000000000000000000000000000\"\\\n]\n\nset i 1\nforeach enc $encodings {\n\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval \"PRAGMA encoding = \\\"$enc\\\"\"\n\n  do_test enc4-$i.1 {\n    db eval {PRAGMA encoding}\n  } $enc\n\n  set j 1\n  foreach init $inits {\n\n    do_test enc4-$i.$j.2 {\n      set S [sqlite3_prepare_v2 db \"SELECT $init+?\" -1 dummy]\n      sqlite3_expired $S\n    } {0}\n      \n    set k 1\n    foreach val $vals {\n      for {set x 1} {$x<16} {incr x} {\n        set part [expr $init + [string range $val 0 [expr $x-1]]]\n\n        do_realnum_test enc4-$i.$j.$k.3.$x {\n          sqlite3_reset $S\n          sqlite3_bind_text $S 1 $val $x\n          sqlite3_step $S\n          sqlite3_column_text $S 0\n        } [list $part]\n        \n        do_realnum_test enc4-$i.$j.$k.4.$x {\n          sqlite3_reset $S\n          sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]\n          sqlite3_step $S\n          sqlite3_column_text $S 0\n        } [list $part]\n      }\n      \n      incr k\n    }\n\n    do_test enc4-$i.$j.5 {\n      sqlite3_finalize $S\n    } {SQLITE_OK}\n\n    incr j\n  }\n\n  db close\n  incr i\n}\n\nforcedelete test.db\nsqlite3 db test.db\n\ndo_test enc4-4.1 {\n  db eval \"select 1+1.\"\n} {2.0}\n\ndo_test enc4-4.2.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT 1+1.\" -1 dummy]\n  sqlite3_step $S\n  sqlite3_column_text $S 0\n} {2.0}\n\ndo_test enc4-4.2.2 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test enc4-4.3.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT 1+?\" -1 dummy]\n  sqlite3_bind_text $S 1 \"1.\" 2\n  sqlite3_step $S\n  sqlite3_column_text $S 0\n} {2.0}\n\ndo_test enc4-4.3.2 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndo_test enc4-4.4.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT 1+?\" -1 dummy]\n  sqlite3_bind_text $S 1 \"1.0\" 2\n  sqlite3_step $S\n  sqlite3_column_text $S 0\n} {2.0}\n\ndo_test enc4-4.4.2 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndb close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/eqp.test",
    "content": "# 2010 November 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nset testprefix eqp\n\n#-------------------------------------------------------------------------\n#\n# eqp-1.*:        Assorted tests.\n# eqp-2.*:        Tests for single select statements.\n# eqp-3.*:        Select statements that execute sub-selects.\n# eqp-4.*:        Compound select statements.\n# ...\n# eqp-7.*:        \"SELECT count(*) FROM tbl\" statements (VDBE code OP_Count).\n#\n\nproc det {args} { uplevel do_eqp_test $args }\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a INT, b INT, ex TEXT);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n  CREATE TABLE t2(a INT, b INT, ex TEXT);\n  CREATE TABLE t3(a INT, b INT, ex TEXT);\n}\n\ndo_eqp_test 1.2 {\n  SELECT * FROM t2, t1 WHERE t1.a=1 OR t1.b=2;\n} {\n  0 0 1 {SEARCH TABLE t1 USING INDEX i1 (a=?)} \n  0 0 1 {SEARCH TABLE t1 USING INDEX i2 (b=?)} \n  0 1 0 {SCAN TABLE t2}\n}\ndo_eqp_test 1.3 {\n  SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=1 OR t1.b=2;\n} {\n  0 0 0 {SCAN TABLE t2}\n  0 1 1 {SEARCH TABLE t1 USING INDEX i1 (a=?)} \n  0 1 1 {SEARCH TABLE t1 USING INDEX i2 (b=?)} \n}\ndo_eqp_test 1.3 {\n  SELECT a FROM t1 ORDER BY a\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}\n}\ndo_eqp_test 1.4 {\n  SELECT a FROM t1 ORDER BY +a\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndo_eqp_test 1.5 {\n  SELECT a FROM t1 WHERE a=4\n} {\n  0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}\n}\ndo_eqp_test 1.6 {\n  SELECT DISTINCT count(*) FROM t3 GROUP BY a;\n} {\n  0 0 0 {SCAN TABLE t3}\n  0 0 0 {USE TEMP B-TREE FOR GROUP BY}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n}\n\ndo_eqp_test 1.7 {\n  SELECT * FROM t3 JOIN (SELECT 1)\n} {\n  0 0 1 {SCAN SUBQUERY 1}\n  0 1 0 {SCAN TABLE t3}\n}\ndo_eqp_test 1.8 {\n  SELECT * FROM t3 JOIN (SELECT 1 UNION SELECT 2)\n} {\n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}\n  0 0 1 {SCAN SUBQUERY 1}\n  0 1 0 {SCAN TABLE t3}\n}\ndo_eqp_test 1.9 {\n  SELECT * FROM t3 JOIN (SELECT 1 EXCEPT SELECT a FROM t3 LIMIT 17)\n} {\n  3 0 0 {SCAN TABLE t3}\n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (EXCEPT)}\n  0 0 1 {SCAN SUBQUERY 1}\n  0 1 0 {SCAN TABLE t3}\n}\ndo_eqp_test 1.10 {\n  SELECT * FROM t3 JOIN (SELECT 1 INTERSECT SELECT a FROM t3 LIMIT 17)\n} {\n  3 0 0 {SCAN TABLE t3}\n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (INTERSECT)}\n  0 0 1 {SCAN SUBQUERY 1}\n  0 1 0 {SCAN TABLE t3}\n}\n\ndo_eqp_test 1.11 {\n  SELECT * FROM t3 JOIN (SELECT 1 UNION ALL SELECT a FROM t3 LIMIT 17)\n} {\n  3 0 0 {SCAN TABLE t3}\n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION ALL)}\n  0 0 1 {SCAN SUBQUERY 1}\n  0 1 0 {SCAN TABLE t3}\n}\n\n#-------------------------------------------------------------------------\n# Test cases eqp-2.* - tests for single select statements.\n#\ndrop_all_tables\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(x INT, y INT, ex TEXT);\n\n  CREATE TABLE t2(x INT, y INT, ex TEXT);\n  CREATE INDEX t2i1 ON t2(x);\n}\n\ndet 2.2.1 \"SELECT DISTINCT min(x), max(x) FROM t1 GROUP BY x ORDER BY 1\" {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {USE TEMP B-TREE FOR GROUP BY}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndet 2.2.2 \"SELECT DISTINCT min(x), max(x) FROM t2 GROUP BY x ORDER BY 1\" {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndet 2.2.3 \"SELECT DISTINCT * FROM t1\" {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n}\ndet 2.2.4 \"SELECT DISTINCT * FROM t1, t2\" {\n  0 0 0 {SCAN TABLE t1}\n  0 1 1 {SCAN TABLE t2}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n}\ndet 2.2.5 \"SELECT DISTINCT * FROM t1, t2 ORDER BY t1.x\" {\n  0 0 0 {SCAN TABLE t1}\n  0 1 1 {SCAN TABLE t2}\n  0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndet 2.2.6 \"SELECT DISTINCT t2.x FROM t1, t2 ORDER BY t2.x\" {\n  0 0 1 {SCAN TABLE t2 USING COVERING INDEX t2i1}\n  0 1 0 {SCAN TABLE t1}\n}\n\ndet 2.3.1 \"SELECT max(x) FROM t2\" {\n  0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1}\n}\ndet 2.3.2 \"SELECT min(x) FROM t2\" {\n  0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2i1}\n}\ndet 2.3.3 \"SELECT min(x), max(x) FROM t2\" {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}\n}\n\ndet 2.4.1 \"SELECT * FROM t1 WHERE rowid=?\" {\n  0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\n\n\n#-------------------------------------------------------------------------\n# Test cases eqp-3.* - tests for select statements that use sub-selects.\n#\ndo_eqp_test 3.1.1 {\n  SELECT (SELECT x FROM t1 AS sub) FROM t1;\n} {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {EXECUTE SCALAR SUBQUERY 1}\n  1 0 0 {SCAN TABLE t1 AS sub}\n}\ndo_eqp_test 3.1.2 {\n  SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub);\n} {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {EXECUTE SCALAR SUBQUERY 1}\n  1 0 0 {SCAN TABLE t1 AS sub}\n}\ndo_eqp_test 3.1.3 {\n  SELECT * FROM t1 WHERE (SELECT x FROM t1 AS sub ORDER BY y);\n} {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {EXECUTE SCALAR SUBQUERY 1}\n  1 0 0 {SCAN TABLE t1 AS sub}\n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndo_eqp_test 3.1.4 {\n  SELECT * FROM t1 WHERE (SELECT x FROM t2 ORDER BY x);\n} {\n  0 0 0 {SCAN TABLE t1}\n  0 0 0 {EXECUTE SCALAR SUBQUERY 1}\n  1 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1}\n}\n\ndet 3.2.1 {\n  SELECT * FROM (SELECT * FROM t1 ORDER BY x LIMIT 10) ORDER BY y LIMIT 5\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY} \n  0 0 0 {SCAN SUBQUERY 1} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndet 3.2.2 {\n  SELECT * FROM \n    (SELECT * FROM t1 ORDER BY x LIMIT 10) AS x1,\n    (SELECT * FROM t2 ORDER BY x LIMIT 10) AS x2\n  ORDER BY x2.y LIMIT 5\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY} \n  2 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  0 0 0 {SCAN SUBQUERY 1 AS x1} \n  0 1 1 {SCAN SUBQUERY 2 AS x2} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\ndet 3.3.1 {\n  SELECT * FROM t1 WHERE y IN (SELECT y FROM t2)\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 0 0 {EXECUTE LIST SUBQUERY 1} \n  1 0 0 {SCAN TABLE t2}\n}\ndet 3.3.2 {\n  SELECT * FROM t1 WHERE y IN (SELECT y FROM t2 WHERE t1.x!=t2.x)\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 0 0 {EXECUTE CORRELATED LIST SUBQUERY 1} \n  1 0 0 {SCAN TABLE t2}\n}\ndet 3.3.3 {\n  SELECT * FROM t1 WHERE EXISTS (SELECT y FROM t2 WHERE t1.x!=t2.x)\n} {\n  0 0 0 {SCAN TABLE t1} \n  0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 1} \n  1 0 0 {SCAN TABLE t2}\n}\n\n#-------------------------------------------------------------------------\n# Test cases eqp-4.* - tests for composite select statements.\n#\ndo_eqp_test 4.1.1 {\n  SELECT * FROM t1 UNION ALL SELECT * FROM t2\n} {\n  1 0 0 {SCAN TABLE t1} \n  2 0 0 {SCAN TABLE t2} \n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)} \n}\ndo_eqp_test 4.1.2 {\n  SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 2\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2} \n  2 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)} \n}\ndo_eqp_test 4.1.3 {\n  SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 2\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2} \n  2 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)} \n}\ndo_eqp_test 4.1.4 {\n  SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 2\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2} \n  2 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)} \n}\ndo_eqp_test 4.1.5 {\n  SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 2\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2} \n  2 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)} \n}\n\ndo_eqp_test 4.2.2 {\n  SELECT * FROM t1 UNION ALL SELECT * FROM t2 ORDER BY 1\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)} \n}\ndo_eqp_test 4.2.3 {\n  SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY 1\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  2 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION)} \n}\ndo_eqp_test 4.2.4 {\n  SELECT * FROM t1 INTERSECT SELECT * FROM t2 ORDER BY 1\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  2 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (INTERSECT)} \n}\ndo_eqp_test 4.2.5 {\n  SELECT * FROM t1 EXCEPT SELECT * FROM t2 ORDER BY 1\n} {\n  1 0 0 {SCAN TABLE t1} \n  1 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  2 0 0 {SCAN TABLE t2 USING INDEX t2i1} \n  2 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)} \n}\n\ndo_eqp_test 4.3.1 {\n  SELECT x FROM t1 UNION SELECT x FROM t2\n} {\n  1 0 0 {SCAN TABLE t1} \n  2 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1} \n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)} \n}\n\ndo_eqp_test 4.3.2 {\n  SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1\n} {\n  2 0 0 {SCAN TABLE t1} \n  3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1} \n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 USING TEMP B-TREE (UNION)}\n  4 0 0 {SCAN TABLE t1} \n  0 0 0 {COMPOUND SUBQUERIES 1 AND 4 USING TEMP B-TREE (UNION)}\n}\ndo_eqp_test 4.3.3 {\n  SELECT x FROM t1 UNION SELECT x FROM t2 UNION SELECT x FROM t1 ORDER BY 1\n} {\n  2 0 0 {SCAN TABLE t1} \n  2 0 0 {USE TEMP B-TREE FOR ORDER BY} \n  3 0 0 {SCAN TABLE t2 USING COVERING INDEX t2i1} \n  1 0 0 {COMPOUND SUBQUERIES 2 AND 3 (UNION)} \n  4 0 0 {SCAN TABLE t1} \n  4 0 0 {USE TEMP B-TREE FOR ORDER BY} \n  0 0 0 {COMPOUND SUBQUERIES 1 AND 4 (UNION)}\n}\n\n#-------------------------------------------------------------------------\n# This next block of tests verifies that the examples on the \n# lang_explain.html page are correct.\n#\ndrop_all_tables\n\n# EVIDENCE-OF: R-47779-47605 sqlite> EXPLAIN QUERY PLAN SELECT a, b\n# FROM t1 WHERE a=1;\n# 0|0|0|SCAN TABLE t1\n#\ndo_execsql_test 5.1.0 { CREATE TABLE t1(a INT, b INT, ex TEXT) }\ndet 5.1.1 \"SELECT a, b FROM t1 WHERE a=1\" {\n  0 0 0 {SCAN TABLE t1}\n}\n\n# EVIDENCE-OF: R-55852-17599 sqlite> CREATE INDEX i1 ON t1(a);\n# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;\n# 0|0|0|SEARCH TABLE t1 USING INDEX i1\n#\ndo_execsql_test 5.2.0 { CREATE INDEX i1 ON t1(a) }\ndet 5.2.1 \"SELECT a, b FROM t1 WHERE a=1\" {\n  0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}\n}\n\n# EVIDENCE-OF: R-21179-11011 sqlite> CREATE INDEX i2 ON t1(a, b);\n# sqlite> EXPLAIN QUERY PLAN SELECT a, b FROM t1 WHERE a=1;\n# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)\n#\ndo_execsql_test 5.3.0 { CREATE INDEX i2 ON t1(a, b) }\ndet 5.3.1 \"SELECT a, b FROM t1 WHERE a=1\" {\n  0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}\n}\n\n# EVIDENCE-OF: R-09991-48941 sqlite> EXPLAIN QUERY PLAN\n# SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2;\n# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)\n# 0|1|1|SCAN TABLE t2\n#\ndo_execsql_test 5.4.0 {CREATE TABLE t2(c INT, d INT, ex TEXT)}\ndet 5.4.1 \"SELECT t1.a, t2.c FROM t1, t2 WHERE t1.a=1 AND t1.b>2\" {\n  0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)}\n  0 1 1 {SCAN TABLE t2}\n}\n\n# EVIDENCE-OF: R-33626-61085 sqlite> EXPLAIN QUERY PLAN\n# SELECT t1.*, t2.* FROM t2, t1 WHERE t1.a=1 AND t1.b>2;\n# 0|0|1|SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)\n# 0|1|0|SCAN TABLE t2\n#\ndet 5.5 \"SELECT t1.a, t2.c FROM t2, t1 WHERE t1.a=1 AND t1.b>2\" {\n  0 0 1 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=? AND b>?)}\n  0 1 0 {SCAN TABLE t2}\n}\n\n# EVIDENCE-OF: R-04002-25654 sqlite> CREATE INDEX i3 ON t1(b);\n# sqlite> EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a=1 OR b=2;\n# 0|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)\n# 0|0|0|SEARCH TABLE t1 USING INDEX i3 (b=?)\n#\ndo_execsql_test 5.5.0 {CREATE INDEX i3 ON t1(b)}\ndet 5.6.1 \"SELECT a, b FROM t1 WHERE a=1 OR b=2\" {\n  0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}\n  0 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?)}\n}\n\n# EVIDENCE-OF: R-24577-38891 sqlite> EXPLAIN QUERY PLAN\n# SELECT c, d FROM t2 ORDER BY c;\n# 0|0|0|SCAN TABLE t2\n# 0|0|0|USE TEMP B-TREE FOR ORDER BY\n#\ndet 5.7 \"SELECT c, d FROM t2 ORDER BY c\" {\n  0 0 0 {SCAN TABLE t2}\n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n# EVIDENCE-OF: R-58157-12355 sqlite> CREATE INDEX i4 ON t2(c);\n# sqlite> EXPLAIN QUERY PLAN SELECT c, d FROM t2 ORDER BY c;\n# 0|0|0|SCAN TABLE t2 USING INDEX i4\n#\ndo_execsql_test 5.8.0 {CREATE INDEX i4 ON t2(c)}\ndet 5.8.1 \"SELECT c, d FROM t2 ORDER BY c\" {\n  0 0 0 {SCAN TABLE t2 USING INDEX i4}\n}\n\n# EVIDENCE-OF: R-13931-10421 sqlite> EXPLAIN QUERY PLAN SELECT\n# (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2;\n# 0|0|0|SCAN TABLE t2\n# 0|0|0|EXECUTE SCALAR SUBQUERY 1\n# 1|0|0|SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)\n# 0|0|0|EXECUTE CORRELATED SCALAR SUBQUERY 2\n# 2|0|0|SEARCH TABLE t1 USING INDEX i3 (b=?)\n#\ndet 5.9 {\n  SELECT (SELECT b FROM t1 WHERE a=0), (SELECT a FROM t1 WHERE b=t2.c) FROM t2\n} {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX i4}\n  0 0 0 {EXECUTE SCALAR SUBQUERY 1}\n  1 0 0 {SEARCH TABLE t1 USING COVERING INDEX i2 (a=?)}\n  0 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2}\n  2 0 0 {SEARCH TABLE t1 USING INDEX i3 (b=?)}\n}\n\n# EVIDENCE-OF: R-50892-45943 sqlite> EXPLAIN QUERY PLAN\n# SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x;\n# 1|0|0|SCAN TABLE t1 USING COVERING INDEX i2\n# 0|0|0|SCAN SUBQUERY 1\n# 0|0|0|USE TEMP B-TREE FOR GROUP BY\n#\ndet 5.10 {\n  SELECT count(*) FROM (SELECT max(b) AS x FROM t1 GROUP BY a) GROUP BY x\n} {\n  1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}\n  0 0 0 {SCAN SUBQUERY 1}\n  0 0 0 {USE TEMP B-TREE FOR GROUP BY}\n}\n\n# EVIDENCE-OF: R-46219-33846 sqlite> EXPLAIN QUERY PLAN\n# SELECT * FROM (SELECT * FROM t2 WHERE c=1), t1;\n# 0|0|0|SEARCH TABLE t2 USING INDEX i4 (c=?)\n# 0|1|1|SCAN TABLE t1\n#\ndet 5.11 \"SELECT a, b FROM (SELECT * FROM t2 WHERE c=1), t1\" {\n  0 0 0 {SEARCH TABLE t2 USING INDEX i4 (c=?)}\n  0 1 1 {SCAN TABLE t1 USING COVERING INDEX i2}\n}\n\n# EVIDENCE-OF: R-37879-39987 sqlite> EXPLAIN QUERY PLAN\n# SELECT a FROM t1 UNION SELECT c FROM t2;\n# 1|0|0|SCAN TABLE t1\n# 2|0|0|SCAN TABLE t2\n# 0|0|0|COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)\n#\ndet 5.12 \"SELECT a,b FROM t1 UNION SELECT c, 99 FROM t2\" {\n  1 0 0 {SCAN TABLE t1 USING COVERING INDEX i2}\n  2 0 0 {SCAN TABLE t2 USING COVERING INDEX i4}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 USING TEMP B-TREE (UNION)}\n}\n\n# EVIDENCE-OF: R-44864-63011 sqlite> EXPLAIN QUERY PLAN\n# SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1;\n# 1|0|0|SCAN TABLE t1 USING COVERING INDEX i2\n# 2|0|0|SCAN TABLE t2 2|0|0|USE TEMP B-TREE FOR ORDER BY\n# 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)\n#\ndet 5.13 \"SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1\" {\n  1 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}\n  2 0 0 {SCAN TABLE t2}\n  2 0 0 {USE TEMP B-TREE FOR ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)}\n}\n\n\nif {![nonzero_reserved_bytes]} {\n  #-------------------------------------------------------------------------\n  # The following tests - eqp-6.* - test that the example C code on \n  # documentation page eqp.html works. The C code is duplicated in test1.c\n  # and wrapped in Tcl command [print_explain_query_plan] \n  #\n  set boilerplate {\n    proc explain_query_plan {db sql} {\n      set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]\n      print_explain_query_plan $stmt\n      sqlite3_finalize $stmt\n    }\n    sqlite3 db test.db\n    explain_query_plan db {%SQL%}\n    db close\n    exit\n  }\n  \n  # Do a \"Print Explain Query Plan\" test.\n  proc do_peqp_test {tn sql res} {\n    set fd [open script.tcl w]\n    puts $fd [string map [list %SQL% $sql] $::boilerplate]\n    close $fd\n  \n    uplevel do_test $tn [list {\n      set fd [open \"|[info nameofexec] script.tcl\"]\n      set data [read $fd]\n      close $fd\n      set data\n    }] [list $res]\n  }\n  \n  do_peqp_test 6.1 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1\n  } [string trimleft {\n1 0 0 SCAN TABLE t1 USING COVERING INDEX i2\n2 0 0 SCAN TABLE t2\n2 0 0 USE TEMP B-TREE FOR ORDER BY\n0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)\n}]\n}\n\n#-------------------------------------------------------------------------\n# The following tests - eqp-7.* - test that queries that use the OP_Count\n# optimization return something sensible with EQP.\n#\ndrop_all_tables\n\ndo_execsql_test 7.0 {\n  CREATE TABLE t1(a INT, b INT, ex CHAR(100));\n  CREATE TABLE t2(a INT, b INT, ex CHAR(100));\n  CREATE INDEX i1 ON t2(a);\n}\n\ndet 7.1 \"SELECT count(*) FROM t1\" {\n  0 0 0 {SCAN TABLE t1}\n}\n\ndet 7.2 \"SELECT count(*) FROM t2\" {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1}\n}\n\ndo_execsql_test 7.3 {\n  INSERT INTO t1(a,b) VALUES(1, 2);\n  INSERT INTO t1(a,b) VALUES(3, 4);\n\n  INSERT INTO t2(a,b) VALUES(1, 2);\n  INSERT INTO t2(a,b) VALUES(3, 4);\n  INSERT INTO t2(a,b) VALUES(5, 6);\n \n  ANALYZE;\n}\n\ndb close\nsqlite3 db test.db\n\ndet 7.4 \"SELECT count(*) FROM t1\" {\n  0 0 0 {SCAN TABLE t1}\n}\n\ndet 7.5 \"SELECT count(*) FROM t2\" {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX i1}\n}\n\n#-------------------------------------------------------------------------\n# The following tests - eqp-8.* - test that queries that use the OP_Count\n# optimization return something sensible with EQP.\n#\ndrop_all_tables\n\ndo_execsql_test 8.0 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;\n  CREATE TABLE t2(a, b, c);\n}\n\ndet 8.1.1 \"SELECT * FROM t2\" {\n  0 0 0 {SCAN TABLE t2}\n}\n\ndet 8.1.2 \"SELECT * FROM t2 WHERE rowid=?\" {\n  0 0 0 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndet 8.1.3 \"SELECT count(*) FROM t2\" {\n  0 0 0 {SCAN TABLE t2}\n}\n\ndet 8.2.1 \"SELECT * FROM t1\" {\n  0 0 0 {SCAN TABLE t1}\n}\n\ndet 8.2.2 \"SELECT * FROM t1 WHERE b=?\" {\n  0 0 0 {SEARCH TABLE t1 USING PRIMARY KEY (b=?)}\n}\n\ndet 8.2.3 \"SELECT * FROM t1 WHERE b=? AND c=?\" {\n  0 0 0 {SEARCH TABLE t1 USING PRIMARY KEY (b=? AND c=?)}\n}\n\ndet 8.2.4 \"SELECT count(*) FROM t1\" {\n  0 0 0 {SCAN TABLE t1}\n}\n\n\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/errmsg.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that if sqlite3_prepare_v2() is used to prepare a query, the\n# error-message associated with an sqlite3_step() error is available\n# immediately. Whereas if sqlite3_prepare() is used, it is not available\n# until sqlite3_finalize() or sqlite3_reset() has been called.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix errmsg\n\n# Test organization:\n#\n#   errmsg-1.*         User-defined SQL function errors\n#   errmsg-2.*         Errors generated by the VDBE (constraint failures etc.)\n#   errmsg-3.*         SQLITE_SCHEMA and statement recompilation errors.\n#\n\nproc error_messages_worker {prepare sql schema} {\n  set ret [list]\n\n  set stmt [$prepare db $sql -1 dummy]\n  execsql $schema\n  lappend ret [sqlite3_step $stmt]\n  lappend ret [sqlite3_errmsg db]\n  lappend ret [sqlite3_finalize $stmt]\n  lappend ret [sqlite3_errmsg db]\n\n  set ret\n}\n\nproc error_messages_v2 {sql {schema {}}} {\n  error_messages_worker sqlite3_prepare_v2 $sql $schema\n}\n\nproc error_messages {sql {schema {}}} {\n  error_messages_worker sqlite3_prepare $sql $schema\n}\n\nproc sql_error {msg} { error $msg }\ndb func sql_error sql_error\n\n#-------------------------------------------------------------------------\n# Test error messages returned by user-defined SQL functions.\n#\ndo_test 1.1 {\n  error_messages \"SELECT sql_error('custom message')\"\n} [list {*}{\n    SQLITE_ERROR {SQL logic error} \n    SQLITE_ERROR {custom message}\n}]\ndo_test 1.2 {\n  error_messages_v2 \"SELECT sql_error('custom message')\"\n} [list {*}{\n    SQLITE_ERROR {custom message}\n    SQLITE_ERROR {custom message}\n}]\n\n#-------------------------------------------------------------------------\n# Test error messages generated directly by VDBE code (e.g. constraint\n# failures).\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1 VALUES('abc', 'def');\n}\ndo_test 2.2 {\n  error_messages \"INSERT INTO t1 VALUES('ghi', 'def')\"\n} [list {*}{\n    SQLITE_ERROR      {SQL logic error} \n    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}\n}]\nverify_ex_errcode 2.2b SQLITE_CONSTRAINT_UNIQUE\ndo_test 2.3 {\n  error_messages_v2 \"INSERT INTO t1 VALUES('ghi', 'def')\"\n} [list {*}{\n    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}\n    SQLITE_CONSTRAINT {UNIQUE constraint failed: t1.b}\n}]\nverify_ex_errcode 2.3b SQLITE_CONSTRAINT_UNIQUE\n\n#-------------------------------------------------------------------------\n# Test SQLITE_SCHEMA errors. And, for _v2(), test that if the schema\n# change invalidates the SQL statement itself the error message is returned\n# correctly.\n#\ndo_execsql_test 3.1.1 {\n  CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t2 VALUES('abc', 'def');\n}\ndo_test 3.1.2 {\n  error_messages \"SELECT a FROM t2\" \"DROP TABLE t2\"\n} [list {*}{\n    SQLITE_ERROR {SQL logic error} \n    SQLITE_SCHEMA {database schema has changed}\n}]\ndo_execsql_test 3.2.1 {\n  CREATE TABLE t2(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t2 VALUES('abc', 'def');\n}\ndo_test 3.2.2 {\n  error_messages_v2 \"SELECT a FROM t2\" \"DROP TABLE t2\"\n} [list {*}{\n    SQLITE_ERROR {no such table: t2} \n    SQLITE_ERROR {no such table: t2}\n}]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/eval.test",
    "content": "# 2008 July 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file experiments with recursion using the \"test_eval()\" SQL function\n# in order to make sure that SQLite is reentrant.\n#\n# $Id: eval.test,v 1.2 2008/10/13 10:37:50 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table to work with.\n#\ndo_test eval-1.1 {\n  execsql {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY); \n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT x+2 FROM t1;\n    INSERT INTO t1 SELECT x+4 FROM t1;\n    INSERT INTO t1 SELECT x+8 FROM t1;\n    INSERT INTO t1 SELECT x+16 FROM t1;\n    INSERT INTO t1 SELECT x+32 FROM t1;\n    INSERT INTO t1 SELECT x+64 FROM t1;\n    INSERT INTO t1 SELECT x+128 FROM t1;\n    INSERT INTO t1 SELECT x+256 FROM t1;\n    SELECT count(*), max(x) FROM t1;\n  }\n} {512 512}\ndo_test eval-1.2 {\n  execsql {\n    SELECT x, test_eval('SELECT max(x) FROM t1 WHERE x<' || x) FROM t1 LIMIT 5\n  }\n} {1 {} 2 1 3 2 4 3 5 4}\n\n# Delete a row out from under a read cursor in the middle of\n# collecting the arguments for a single row in a result set.\n# Verify that subsequent rows come out as NULL.\n#\ndo_test eval-2.1 {\n  execsql {\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;\n    SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2;\n  }\n} {1 {} {} 2 {} {} 3 {} {} 4 {} {}}\ndo_test eval-2.2 {\n  execsql {\n    SELECT * FROM t2\n  }\n} {}\ndo_test eval-2.3 {\n  execsql {\n    INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;\n    SELECT x, test_eval('DELETE FROM t2 WHERE x='||x), y FROM t2\n     ORDER BY rowid DESC;\n  }\n} {4 {} {} 3 {} {} 2 {} {} 1 {} {}}\ndo_test eval-2.4 {\n  execsql {\n    SELECT * FROM t2\n  }\n} {}\n\n# Modify a row while it is being read.\n#\ndo_test eval-3.1 {\n  execsql {\n    INSERT INTO t2 SELECT x, x+1 FROM t1 WHERE x<5;\n    SELECT x, test_eval('UPDATE t2 SET y=y+100 WHERE x='||x), y FROM t2;\n  }\n} {1 {} 102 2 {} 103 3 {} 104 4 {} 105}\n\ndo_test eval-4.1 {\n  execsql { SELECT test_eval('SELECT \"abcdefghij\"') }\n} {abcdefghij}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/exclusive.test",
    "content": "# 2007 March 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of these tests is exclusive access mode (i.e. the thing activated by \n# \"PRAGMA locking_mode = EXCLUSIVE\").\n#\n# $Id: exclusive.test,v 1.15 2009/06/26 12:30:40 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!pager_pragmas} {\n  finish_test\n  return\n}\n\nforcedelete test2.db-journal\nforcedelete test2.db\nforcedelete test3.db-journal\nforcedelete test3.db\nforcedelete test4.db-journal\nforcedelete test4.db\n\n#----------------------------------------------------------------------\n# Test cases exclusive-1.X test the PRAGMA logic.\n#\ndo_test exclusive-1.0 {\n  execsql {\n    pragma locking_mode;\n    pragma main.locking_mode;\n    pragma temp.locking_mode;\n  } \n} [list normal normal exclusive]\ndo_test exclusive-1.1 {\n  execsql {\n    pragma locking_mode = exclusive;\n  } \n} {exclusive}\ndo_test exclusive-1.2 {\n  execsql {\n    pragma locking_mode;\n    pragma main.locking_mode;\n    pragma temp.locking_mode;\n  } \n} [list exclusive exclusive exclusive]\ndo_test exclusive-1.3 {\n  execsql {\n    pragma locking_mode = normal;\n  } \n} {normal}\ndo_test exclusive-1.4 {\n  execsql {\n    pragma locking_mode;\n    pragma main.locking_mode;\n    pragma temp.locking_mode;\n  } \n} [list normal normal exclusive]\ndo_test exclusive-1.5 {\n  execsql {\n    pragma locking_mode = invalid;\n  } \n} {normal}\ndo_test exclusive-1.6 {\n  execsql {\n    pragma locking_mode;\n    pragma main.locking_mode;\n    pragma temp.locking_mode;\n  } \n} [list normal normal exclusive]\nifcapable attach {\n  do_test exclusive-1.7 {\n    execsql {\n      pragma locking_mode = exclusive;\n      ATTACH 'test2.db' as aux;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma aux.locking_mode;\n    }\n  } {exclusive exclusive}\n  do_test exclusive-1.8 {\n    execsql {\n      pragma main.locking_mode = normal;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma temp.locking_mode;\n      pragma aux.locking_mode;\n    }\n  } [list normal exclusive exclusive]\n  do_test exclusive-1.9 {\n    execsql {\n      pragma locking_mode;\n    }\n  } {exclusive}\n  do_test exclusive-1.10 {\n    execsql {\n      ATTACH 'test3.db' as aux2;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma aux.locking_mode;\n      pragma aux2.locking_mode;\n    }\n  } {normal exclusive exclusive}\n  do_test exclusive-1.11 {\n    execsql {\n      pragma aux.locking_mode = normal;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma aux.locking_mode;\n      pragma aux2.locking_mode;\n    }\n  } {normal normal exclusive}\n  do_test exclusive-1.12 {\n    execsql {\n      pragma locking_mode = normal;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma temp.locking_mode;\n      pragma aux.locking_mode;\n      pragma aux2.locking_mode;\n    }\n  } [list normal exclusive normal normal]\n  do_test exclusive-1.13 {\n    execsql {\n      ATTACH 'test4.db' as aux3;\n    }\n    execsql {\n      pragma main.locking_mode;\n      pragma temp.locking_mode;\n      pragma aux.locking_mode;\n      pragma aux2.locking_mode;\n      pragma aux3.locking_mode;\n    }\n  } [list normal exclusive normal normal normal]\n  \n  do_test exclusive-1.99 {\n    execsql {\n      DETACH aux;\n      DETACH aux2;\n      DETACH aux3;\n    }\n  } {}\n}\n\n#----------------------------------------------------------------------\n# Test cases exclusive-2.X verify that connections in exclusive \n# locking_mode do not relinquish locks.\n#\ndo_test exclusive-2.0 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n    PRAGMA locking_mode = exclusive;\n  }\n} {exclusive}\ndo_test exclusive-2.1 {\n  sqlite3 db2 test.db\n  execsql {\n    INSERT INTO abc VALUES(4, 5, 6);\n    SELECT * FROM abc;\n  } db2\n} {1 2 3 4 5 6}\ndo_test exclusive-2.2 {\n  # This causes connection 'db' (in exclusive mode) to establish \n  # a shared-lock on the db. The other connection should now be\n  # locked out as a writer.\n  execsql {\n    SELECT * FROM abc;\n  } db\n} {1 2 3 4 5 6}\ndo_test exclusive-2.4 {\n  execsql {\n    SELECT * FROM abc;\n  } db2\n} {1 2 3 4 5 6}\ndo_test exclusive-2.5 {\n  catchsql {\n    INSERT INTO abc VALUES(7, 8, 9);\n  } db2\n} {1 {database is locked}}\nsqlite3_soft_heap_limit 0\ndo_test exclusive-2.6 {\n  # Because connection 'db' only has a shared-lock, the other connection\n  # will be able to get a RESERVED, but will fail to upgrade to EXCLUSIVE.\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(7, 8, 9);\n  } db2\n  catchsql {\n    COMMIT\n  } db2\n} {1 {database is locked}}\ndo_test exclusive-2.7 {\n  catchsql {\n    COMMIT\n  } db2\n} {1 {database is locked}}\ndo_test exclusive-2.8 {\n  execsql {\n    ROLLBACK;\n  } db2\n} {}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\ndo_test exclusive-2.9 {\n  # Write the database to establish the exclusive lock with connection 'db.\n  execsql {\n    INSERT INTO abc VALUES(7, 8, 9);\n  } db\n  catchsql {\n    SELECT * FROM abc;\n  } db2\n} {1 {database is locked}}\ndo_test exclusive-2.10 {\n  # Changing the locking-mode does not release any locks.\n  execsql {\n    PRAGMA locking_mode = normal;\n  } db\n  catchsql {\n    SELECT * FROM abc;\n  } db2\n} {1 {database is locked}}\ndo_test exclusive-2.11 {\n  # After changing the locking mode, accessing the db releases locks.\n  execsql {\n    SELECT * FROM abc;\n  } db\n  execsql {\n    SELECT * FROM abc;\n  } db2\n} {1 2 3 4 5 6 7 8 9}\ndb2 close\n\n#----------------------------------------------------------------------\n# Tests exclusive-3.X - test that a connection in exclusive mode \n# truncates instead of deletes the journal file when committing \n# a transaction.\n#\n# These tests are not run on windows because the windows backend\n# opens the journal file for exclusive access, preventing its contents \n# from being inspected externally.\n#\nif {$tcl_platform(platform) != \"windows\"} {\n\n  # Return a list of two booleans (either 0 or 1). The first is true\n  # if the named file exists. The second is true only if the file\n  # exists and the first 28 bytes contain at least one non-zero byte.\n  #\n  proc filestate {fname} {\n    set exists 0\n    set content 0\n    if {[file exists $fname]} {\n      set exists 1\n      set hdr [hexio_read $fname 0 28]\n      set content [expr {0==[string match $hdr [string repeat 0 56]]}]\n    }\n    list $exists $content\n  }\n\n  do_test exclusive-3.0 {\n    filestate test.db-journal\n  } {0 0}\n  do_test exclusive-3.1 {\n    execsql {\n      PRAGMA locking_mode = exclusive;\n      BEGIN;\n      DELETE FROM abc;\n    }\n    filestate test.db-journal\n  } {1 1}\n  do_test exclusive-3.2 {\n    execsql {\n      COMMIT;\n    }\n    filestate test.db-journal\n  } {1 0}\n  do_test exclusive-3.3 {\n    execsql {\n      INSERT INTO abc VALUES('A', 'B', 'C');\n      SELECT * FROM abc;\n    }\n  } {A B C}\n  do_test exclusive-3.4 {\n    execsql {\n      BEGIN;\n      UPDATE abc SET a = 1, b = 2, c = 3;\n      ROLLBACK;\n      SELECT * FROM abc;\n    }\n  } {A B C}\n  do_test exclusive-3.5 {\n    filestate test.db-journal\n  } {1 0}\n  do_test exclusive-3.6 {\n    execsql {\n      PRAGMA locking_mode = normal;\n      SELECT * FROM abc;\n    }\n    filestate test.db-journal\n  } {0 0}\n}\n\n#----------------------------------------------------------------------\n# Tests exclusive-4.X - test that rollback works correctly when\n# in exclusive-access mode.\n#\n\n# The following procedure computes a \"signature\" for table \"t3\".  If\n# T3 changes in any way, the signature should change.  \n#\n# This is used to test ROLLBACK.  We gather a signature for t3, then\n# make lots of changes to t3, then rollback and take another signature.\n# The two signatures should be the same.\n#\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(x) FROM t3}]\n}\n\ndo_test exclusive-4.0 {\n  execsql { PRAGMA locking_mode = exclusive; }\n  execsql { PRAGMA default_cache_size = 10; }\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(x TEXT);\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    COMMIT;\n  }\n  execsql {SELECT count(*) FROM t3;}\n} {32}\n\nset ::X [signature]\ndo_test exclusive-4.1 {\n  execsql {\n    BEGIN;\n    DELETE FROM t3 WHERE random()%10!=0;\n    INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n    INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n    SELECT count(*) FROM t3;\n    ROLLBACK;\n  }\n  signature\n} $::X\n\ndo_test exclusive-4.2 {\n  execsql {\n    BEGIN;\n    DELETE FROM t3 WHERE random()%10!=0;\n    INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n    DELETE FROM t3 WHERE random()%10!=0;\n    INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n    ROLLBACK;\n  }\n  signature\n} $::X\n\ndo_test exclusive-4.3 {\n  execsql {\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;\n  }\n} {}\n\ndo_test exclusive-4.4 {\n  catch {set ::X [signature]}\n} {0}\ndo_test exclusive-4.5 {\n  execsql {\n    PRAGMA locking_mode = NORMAL;\n    DROP TABLE t3;\n    DROP TABLE abc;\n  }\n} {normal}\n\n#----------------------------------------------------------------------\n# Tests exclusive-5.X - test that statement journals are truncated\n# instead of deleted when in exclusive access mode.\n#\n\n# Close and reopen the database so that the temp database is no\n# longer active.\n#\ndb close\nsqlite3 db test.db\n\n# if we're using proxy locks, we use 3 filedescriptors for a db\n# that is open but NOT writing changes, normally\n# sqlite uses 1 (proxy locking adds the conch and the local lock)\nset using_proxy 0\nforeach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n  set using_proxy $value\n}\nset extrafds 0\nif {$using_proxy!=0} {\n  set extrafds 2\n} \n\ndo_test exclusive-5.0 {\n  execsql {\n    CREATE TABLE abc(a UNIQUE, b UNIQUE, c UNIQUE);\n    BEGIN;\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc SELECT a+1, b+1, c+1 FROM abc;\n  }\n} {}\ndo_test exclusive-5.1 {\n  # Three files are open: The db, journal and statement-journal.\n  # (2016-03-04) The statement-journal is now opened lazily\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {2}\ndo_test exclusive-5.2 {\n  execsql {\n    COMMIT;\n  }\n  # One file open: the db.\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {1}\ndo_test exclusive-5.3 {\n  execsql {\n    PRAGMA locking_mode = exclusive;\n    BEGIN;\n    INSERT INTO abc VALUES(5, 6, 7);\n  }\n  # Two files open: the db and journal.\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {2}\ndo_test exclusive-5.4 {\n  execsql {\n    INSERT INTO abc SELECT a+10, b+10, c+10 FROM abc;\n  }\n  # Three files are open: The db, journal and statement-journal.\n  # 2016-03-04: The statement-journal open is deferred\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {2}\ndo_test exclusive-5.5 {\n  execsql {\n    COMMIT;\n  }\n  # Three files are still open: The db, journal and statement-journal.\n  # 2016-03-04: The statement-journal open is deferred\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {2}\ndo_test exclusive-5.6 {\n  execsql {\n    PRAGMA locking_mode = normal;\n    SELECT * FROM abc;\n  }\n} {normal 1 2 3 2 3 4 5 6 7 11 12 13 12 13 14 15 16 17}\ndo_test exclusive-5.7 {\n  # Just the db open.\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds\n} {1}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test exclusive-6.1 {\n  CREATE TABLE t4(a, b);\n  INSERT INTO t4 VALUES('Eden', 1955);\n  BEGIN;\n    INSERT INTO t4 VALUES('Macmillan', 1957);\n    INSERT INTO t4 VALUES('Douglas-Home', 1963);\n    INSERT INTO t4 VALUES('Wilson', 1964);\n}\ndo_test exclusive-6.2 {\n  forcedelete test2.db test2.db-journal\n  copy_file test.db test2.db\n  copy_file test.db-journal test2.db-journal\n  sqlite3 db test2.db\n} {}\n\ndo_execsql_test exclusive-6.3 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  SELECT * FROM t4;\n} {exclusive Eden 1955}\n\ndo_test exclusive-6.4 {\n  db close\n  forcedelete test.db test.db-journal\n  set fd [open test.db-journal w]\n  puts $fd x\n  close $fd\n  sqlite3 db test.db\n} {}\n\ndo_execsql_test exclusive-6.5 {\n  PRAGMA locking_mode = EXCLUSIVE;\n  SELECT * FROM sqlite_master;\n} {exclusive}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/exclusive2.test",
    "content": "# 2007 March 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# $Id: exclusive2.test,v 1.10 2008/11/27 02:22:11 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\nifcapable {!pager_pragmas} {\n  finish_test\n  return\n}\n\n# Tests in this file verify that locking_mode=exclusive causes SQLite to\n# use cached pages even if the database is changed on disk. This doesn't\n# work with mmap.\nif {[permutation]==\"mmap\"} {\n  finish_test\n  return\n}\n\n# This module does not work right if the cache spills at unexpected\n# moments.  So disable the soft-heap-limit.\n#\nsqlite3_soft_heap_limit 0\n\nproc pagerChangeCounter {filename new {fd \"\"}} {\n  if {$fd==\"\"} {\n    set fd [open $filename RDWR]\n    fconfigure $fd -translation binary -encoding binary\n    set needClose 1\n  } else {\n    set needClose 0\n  }\n  if {$new ne \"\"} {\n    seek $fd 24\n    set a [expr {($new&0xFF000000)>>24}]\n    set b [expr {($new&0x00FF0000)>>16}]\n    set c [expr {($new&0x0000FF00)>>8}]\n    set d [expr {($new&0x000000FF)}]\n    puts -nonewline $fd [binary format cccc $a $b $c $d]\n    flush $fd\n  }\n\n  seek $fd 24\n  foreach {a b c d} [list 0 0 0 0] {}\n  binary scan [read $fd 4] cccc a b c d\n  set  ret [expr ($a&0x000000FF)<<24]\n  incr ret [expr ($b&0x000000FF)<<16]\n  incr ret [expr ($c&0x000000FF)<<8]\n  incr ret [expr ($d&0x000000FF)<<0]\n\n  if {$needClose} {close $fd}\n  return $ret\n}\n\nproc readPagerChangeCounter {filename} {\n  set fd [open $filename RDONLY]\n  fconfigure $fd -translation binary -encoding binary\n\n  seek $fd 24\n  foreach {a b c d} [list 0 0 0 0] {}\n  binary scan [read $fd 4] cccc a b c d\n  set  ret [expr ($a&0x000000FF)<<24]\n  incr ret [expr ($b&0x000000FF)<<16]\n  incr ret [expr ($c&0x000000FF)<<8]\n  incr ret [expr ($d&0x000000FF)<<0]\n\n  close $fd\n  return $ret\n}\n\n\nproc t1sig {{db db}} {\n  execsql {SELECT count(*), md5sum(a) FROM t1} $db\n}\ndo_test exclusive2-1.0 {\n  readPagerChangeCounter test.db\n} {0}\n\n#-----------------------------------------------------------------------\n# The following tests - exclusive2-1.X - check that:\n#\n# 1-3:   Build a database with connection 1, calculate a signature.\n# 4-7:   Modify the database using a second connection in a way that\n#        does not modify the freelist, then reset the pager change-counter\n#        to the value it had before the modifications.\n# 8:     Check that using the first connection, the database signature\n#        is still the same. This is because it uses the in-memory cache.\n#        It can't tell the db has changed because we reset the change-counter.\n# 9:     Increment the change-counter.\n# 10:    Ensure that the first connection now sees the updated database. It\n#        sees the change-counter has been incremented and discards the \n#        invalid in-memory cache.\n#\n# This will only work if the database cache is large enough to hold \n# the entire database. In the case of 1024 byte pages, this means\n# the cache size must be at least 17. Otherwise, some pages will be\n# loaded from the database file in step 8.\n#\n# For similar reasons, this test does not work with the memsubsys1 permutation.\n# Permutation memsubsys1 configures the pcache subsystem to use a static\n# allocation of 24 pages (shared between all pagers). This is not enough for\n# this test.\n#\ndo_test exclusive2-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1(a, b) VALUES(randstr(10, 400), 0);\n    INSERT INTO t1(a, b) VALUES(randstr(10, 400), 0);\n    INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;\n    INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;\n    INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;\n    INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;\n    INSERT INTO t1(a, b) SELECT randstr(10, 400), 0 FROM t1;\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {64}\ndo_test exclusive2-1.2.1 {\n  # Make sure the pager cache is large enough to store the \n  # entire database.\n  set nPage [expr [file size test.db]/1024]\n  if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {\n    execsql \"PRAGMA cache_size = $nPage\"\n  }\n  expr {[execsql {PRAGMA cache_size}] >= $nPage}\n} {1}\ndo_test exclusive2-1.2 {\n  set ::sig [t1sig]\n  readPagerChangeCounter test.db\n} {1}\ndo_test exclusive2-1.3 {\n  t1sig\n} $::sig\ndo_test exclusive2-1.4 {\n  sqlite3 db2 test.db\n  t1sig db2\n} $::sig\ndo_test exclusive2-1.5 {\n  execsql {\n    UPDATE t1 SET b=a, a=0;\n  } db2\n  expr {[t1sig db2] eq $::sig}\n} 0\ndo_test exclusive2-1.6 {\n  readPagerChangeCounter test.db\n} {2}\ndo_test exclusive2-1.7 {\n  pagerChangeCounter test.db 1\n} {1}\nif {[permutation] != \"memsubsys1\"} {\n  do_test exclusive2-1.9 {\n    t1sig\n    expr {[t1sig] eq $::sig}\n  } {1}\n}\ndo_test exclusive2-1.10 {\n  pagerChangeCounter test.db 2\n} {2}\ndo_test exclusive2-1.11 {\n  expr {[t1sig] eq $::sig}\n} {0}\ndb2 close\n\n#--------------------------------------------------------------------\n# These tests - exclusive2-2.X - are similar to exclusive2-1.X, \n# except that they are run with locking_mode=EXCLUSIVE.\n#\n# 1-3:   Build a database with exclusive-access connection 1, \n#        calculate a signature.\n# 4:     Corrupt the database by writing 10000 bytes of garbage\n#        starting at the beginning of page 2. Check that connection 1\n#        still works. It should be accessing the in-memory cache.\n# 5-6:   Modify the dataase change-counter. Connection 1 still works\n#        entirely from in-memory cache, because it doesn't check the\n#        change-counter.\n# 7-8    Set the locking-mode back to normal. After the db is unlocked,\n#        SQLite detects the modified change-counter and discards the\n#        in-memory cache. Then it finds the corruption caused in step 4....\n#\n# As above, this test is only applicable if the pager cache is\n# large enough to hold the entire database. With 1024 byte pages,\n# this means 19 pages.  We also need to disable the soft-heap-limit\n# to prevent memory-induced cache spills.\n#\ndo_test exclusive2-2.1 {\n  execsql {PRAGMA cache_size=1000;}\n  execsql {PRAGMA locking_mode = exclusive;}\n  execsql {\n    BEGIN;\n    DELETE FROM t1;\n    INSERT INTO t1(a) VALUES(randstr(10, 400));\n    INSERT INTO t1(a) VALUES(randstr(10, 400));\n    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;\n    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;\n    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;\n    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;\n    INSERT INTO t1(a) SELECT randstr(10, 400) FROM t1;\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {64}\ndo_test exclusive2-2.2.1 {\n  # Make sure the pager cache is large enough to store the \n  # entire database.\n  set nPage [expr [file size test.db]/1024]\n  if {$::SQLITE_DEFAULT_CACHE_SIZE < $nPage} {\n    execsql \"PRAGMA cache_size = $nPage\"\n  }\n  expr {[execsql {PRAGMA cache_size}] >= $nPage}\n} {1}\ndo_test exclusive2-2.2 {\n  set ::sig [t1sig]\n  readPagerChangeCounter test.db\n} {3}\ndo_test exclusive2-2.3 {\n  t1sig\n} $::sig\n\ndo_test exclusive2-2.4 {\n  set ::fd [open test.db RDWR]\n  fconfigure $::fd -translation binary\n  seek $::fd 1024\n  puts -nonewline $::fd [string repeat [binary format c 0] 10000]\n  flush $::fd\n  t1sig\n} $::sig\n\ndo_test exclusive2-2.5 {\n  pagerChangeCounter test.db 5 $::fd\n} {5}\ndo_test exclusive2-2.6 {\n  t1sig\n} $::sig\ndo_test exclusive2-2.7 {\n  execsql {PRAGMA locking_mode = normal}\n  t1sig\n} $::sig\n\ndo_test exclusive2-2.8 {\n  set rc [catch {t1sig} msg]\n  list $rc $msg\n} {1 {database disk image is malformed}}\n\n#--------------------------------------------------------------------\n# These tests - exclusive2-3.X - verify that the pager change-counter\n# is only incremented by the first change when in exclusive access\n# mode. In normal mode, the change-counter is incremented once\n# per write-transaction.\n#\n\ndb close\ncatch {close $::fd}\nforcedelete test.db\nforcedelete test.db-journal\n\ndo_test exclusive2-3.0 {\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a UNIQUE);\n    INSERT INTO t1 VALUES(randstr(200, 200));\n    INSERT INTO t1 VALUES(randstr(200, 200));\n    COMMIT;\n  }\n  readPagerChangeCounter test.db\n} {1}\ndo_test exclusive2-3.1 {\n  execsql {\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {2}\ndo_test exclusive2-3.2 {\n  execsql {\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {3}\ndo_test exclusive2-3.3 {\n  execsql {\n    PRAGMA locking_mode = exclusive;\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {4}\ndo_test exclusive2-3.4 {\n  execsql {\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {4}\ndo_test exclusive2-3.5 {\n  execsql {\n    PRAGMA locking_mode = normal;\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {4}\ndo_test exclusive2-3.6 {\n  execsql {\n    INSERT INTO t1 VALUES(randstr(200, 200));\n  }\n  readPagerChangeCounter test.db\n} {5}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/exec.test",
    "content": "# 2008 Jan 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the sqlite3_exec interface\n#\n# $Id: exec.test,v 1.1 2008/01/21 16:22:46 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test exec-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    SELECT * FROM t1;\n  }\n} {1 2}\ndo_test exec-1.2 {\n  sqlite3_exec db {/* comment */;;; SELECT * FROM t1; /* comment */}\n} {0 {a b 1 2}}\ndo_test exec-1.3 {\n  sqlite3 db2 test.db\n  db2 eval {CREATE TABLE t2(x, y);}\n  db2 close\n  sqlite3_exec db {SELECT * FROM t1}\n} {0 {a b 1 2}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/exists.test",
    "content": "# 2011 April 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the various schema modification statements\n# that feature \"IF EXISTS\" or \"IF NOT EXISTS\" clauses.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\n\n\nforeach jm {rollback wal} {\n  if {![wal_is_capable] && $jm==\"wal\"} continue\n\n  set testprefix exists-$jm\n\n  # This block of tests is targeted at CREATE XXX IF NOT EXISTS statements.\n  #\n  do_multiclient_test tn {\n\n    # TABLE objects.\n    #\n    do_test 1.$tn.1.1 {\n      if {$jm == \"wal\"} { sql2 { PRAGMA journal_mode = WAL } }\n      sql2 { CREATE TABLE t1(x) }\n      sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }\n      sql2 { DROP TABLE t1 }\n      sql1 { CREATE TABLE IF NOT EXISTS t1(a, b) }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }\n    } {t1}\n\n    do_test 1.$tn.1.2 {\n      sql2 { CREATE TABLE t2(x) }\n      sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }\n      sql2 { DROP TABLE t2 }\n      sql1 { CREATE TABLE IF NOT EXISTS t2 AS SELECT * FROM t1 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }\n    } {t1 t2}\n\n\n    # INDEX objects.\n    #\n    do_test 1.$tn.2 {\n      sql2 { CREATE INDEX i1 ON t1(a) }\n      sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }\n      sql2 { DROP INDEX i1 }\n      sql1 { CREATE INDEX IF NOT EXISTS i1 ON t1(a, b) }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }\n    } {i1}\n\n    # VIEW objects.\n    #\n    do_test 1.$tn.3 {\n      sql2 { CREATE VIEW v1 AS SELECT * FROM t1 }\n      sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }\n      sql2 { DROP VIEW v1 }\n      sql1 { CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }\n    } {v1}\n\n    # TRIGGER objects.\n    #\n    do_test $tn.4 {\n      sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }\n  sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }\n      sql2 { DROP TRIGGER tr1 }\n  sql1 { CREATE TRIGGER IF NOT EXISTS tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }\n    } {tr1}\n  }\n\n  # This block of tests is targeted at DROP XXX IF EXISTS statements.\n  #\n  do_multiclient_test tn {\n\n    # TABLE objects.\n    #\n    do_test 2.$tn.1 {\n      if {$jm == \"wal\"} { sql1 { PRAGMA journal_mode = WAL } }\n      sql1 { DROP TABLE IF EXISTS t1 }\n      sql2 { CREATE TABLE t1(x) }\n      sql1 { DROP TABLE IF EXISTS t1 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'table' }\n    } {}\n\n    # INDEX objects.\n    #\n    do_test 2.$tn.2 {\n      sql1 { CREATE TABLE t2(x) }\n      sql1 { DROP INDEX IF EXISTS i2 }\n      sql2 { CREATE INDEX i2 ON t2(x) }\n      sql1 { DROP INDEX IF EXISTS i2 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'index' }\n    } {}\n\n    # VIEW objects.\n    #\n    do_test 2.$tn.3 {\n      sql1 { DROP VIEW IF EXISTS v1 }\n      sql2 { CREATE VIEW v1 AS SELECT * FROM t2 }\n      sql1 { DROP VIEW IF EXISTS v1 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'view' }\n    } {}\n\n    # TRIGGER objects.\n    #\n    do_test 2.$tn.4 {\n      sql1 { DROP TRIGGER IF EXISTS tr1 }\n      sql2 { CREATE TRIGGER tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }\n      sql1 { DROP TRIGGER IF EXISTS tr1 }\n      sql2 { SELECT name FROM sqlite_master WHERE type = 'trigger' }\n    } {}\n  }\n\n  # This block of tests is targeted at DROP XXX IF EXISTS statements with\n  # attached databases.\n  #\n  do_multiclient_test tn {\n\n    forcedelete test.db2\n    do_test 3.$tn.0 {\n      sql1 { ATTACH 'test.db2' AS aux }\n      sql2 { ATTACH 'test.db2' AS aux }\n    } {}\n\n    # TABLE objects.\n    #\n    do_test 3.$tn.1.1 {\n      sql1 { DROP TABLE IF EXISTS aux.t1 }\n      sql2 { CREATE TABLE aux.t1(x) }\n      sql1 { DROP TABLE IF EXISTS aux.t1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }\n    } {}\n    do_test 3.$tn.1.2 {\n      sql1 { DROP TABLE IF EXISTS t1 }\n      sql2 { CREATE TABLE aux.t1(x) }\n      sql1 { DROP TABLE IF EXISTS t1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'table' }\n    } {}\n\n    # INDEX objects.\n    #\n    do_test 3.$tn.2.1 {\n      sql1 { CREATE TABLE aux.t2(x) }\n      sql1 { DROP INDEX IF EXISTS aux.i2 }\n      sql2 { CREATE INDEX aux.i2 ON t2(x) }\n      sql1 { DROP INDEX IF EXISTS aux.i2 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'index' }\n    } {}\n    do_test 3.$tn.2.2 {\n      sql1 { DROP INDEX IF EXISTS i2 }\n      sql2 { CREATE INDEX aux.i2 ON t2(x) }\n      sql1 { DROP INDEX IF EXISTS i2 }\n      sql2 { SELECT * FROM aux.sqlite_master WHERE type = 'index' }\n    } {}\n\n    # VIEW objects.\n    #\n    do_test 3.$tn.3.1 {\n      sql1 { DROP VIEW IF EXISTS aux.v1 }\n      sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }\n      sql1 { DROP VIEW IF EXISTS aux.v1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }\n    } {}\n    do_test 3.$tn.3.2 {\n      sql1 { DROP VIEW IF EXISTS v1 }\n      sql2 { CREATE VIEW aux.v1 AS SELECT * FROM t2 }\n      sql1 { DROP VIEW IF EXISTS v1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'view' }\n    } {}\n\n    # TRIGGER objects.\n    #\n    do_test 3.$tn.4.1 {\n      sql1 { DROP TRIGGER IF EXISTS aux.tr1 }\n      sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }\n      sql1 { DROP TRIGGER IF EXISTS aux.tr1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }\n    } {}\n    do_test 3.$tn.4.2 {\n      sql1 { DROP TRIGGER IF EXISTS tr1 }\n      sql2 { CREATE TRIGGER aux.tr1 AFTER INSERT ON t2 BEGIN SELECT 1; END }\n      sql1 { DROP TRIGGER IF EXISTS tr1 }\n      sql2 { SELECT name FROM aux.sqlite_master WHERE type = 'trigger' }\n    } {}\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/expr.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing expressions.\n#\n# $Id: expr.test,v 1.67 2009/02/04 03:59:25 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table to work with.\n#\nifcapable floatingpoint {\n  execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}\n  execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}\n}\nifcapable !floatingpoint {\n  execsql {CREATE TABLE test1(i1 int, i2 int, t1 text, t2 text)}\n  execsql {INSERT INTO test1 VALUES(1,2,'hello','world')}\n}\n\nproc test_expr {name settings expr result} {\n  do_test $name [format {\n    execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}\n  } $settings $expr] $result\n}\nproc test_realnum_expr {name settings expr result} {\n  do_realnum_test $name [format {\n    execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}\n  } $settings $expr] $result\n}\n\ntest_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30\ntest_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10\ntest_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200\ntest_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0\ntest_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2\ntest_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0\ntest_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0\ntest_expr expr-1.8 {i1=10, i2=20} {i2>i1} 1\ntest_expr expr-1.9 {i1=10, i2=20} {i2>=i1} 1\ntest_expr expr-1.10 {i1=10, i2=20} {i2!=i1} 1\ntest_expr expr-1.11 {i1=10, i2=20} {i2=i1} 0\ntest_expr expr-1.12 {i1=10, i2=20} {i2<>i1} 1\ntest_expr expr-1.13 {i1=10, i2=20} {i2==i1} 0\ntest_expr expr-1.14 {i1=20, i2=20} {i2<i1} 0\ntest_expr expr-1.15 {i1=20, i2=20} {i2<=i1} 1\ntest_expr expr-1.16 {i1=20, i2=20} {i2>i1} 0\ntest_expr expr-1.17 {i1=20, i2=20} {i2>=i1} 1\ntest_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0\ntest_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1\ntest_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0\ntest_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1\nifcapable floatingpoint {\n  test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}\n  test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}\n}\ntest_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}\ntest_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}\ntest_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}\ntest_expr expr-1.27 {i1=1, i2=2} {i1==1 AND i2=2} {1}\ntest_expr expr-1.28 {i1=1, i2=2} {i1=2 AND i2=1} {0}\ntest_expr expr-1.29 {i1=1, i2=2} {i1=1 AND i2=1} {0}\ntest_expr expr-1.30 {i1=1, i2=2} {i1=2 AND i2=2} {0}\ntest_expr expr-1.31 {i1=1, i2=2} {i1==1 OR i2=2} {1}\ntest_expr expr-1.32 {i1=1, i2=2} {i1=2 OR i2=1} {0}\ntest_expr expr-1.33 {i1=1, i2=2} {i1=1 OR i2=1} {1}\ntest_expr expr-1.34 {i1=1, i2=2} {i1=2 OR i2=2} {1}\ntest_expr expr-1.35 {i1=1, i2=2} {i1-i2=-1} {1}\ntest_expr expr-1.36 {i1=1, i2=0} {not i1} {0}\ntest_expr expr-1.37 {i1=1, i2=0} {not i2} {1}\ntest_expr expr-1.38 {i1=1} {-i1} {-1}\ntest_expr expr-1.39 {i1=1} {+i1} {1}\ntest_expr expr-1.40 {i1=1, i2=2} {+(i2+i1)} {3}\ntest_expr expr-1.41 {i1=1, i2=2} {-(i2+i1)} {-3}\ntest_expr expr-1.42 {i1=1, i2=2} {i1|i2} {3}\ntest_expr expr-1.42b {i1=1, i2=2} {4|2} {6}\ntest_expr expr-1.43 {i1=1, i2=2} {i1&i2} {0}\ntest_expr expr-1.43b {i1=1, i2=2} {4&5} {4}\ntest_expr expr-1.44 {i1=1} {~i1} {-2}\ntest_expr expr-1.44b {i1=NULL} {~i1} {{}}\ntest_expr expr-1.45a {i1=1, i2=3} {i1<<i2} {8}\ntest_expr expr-1.45b {i1=1, i2=-3} {i1>>i2} {8}\ntest_expr expr-1.45c {i1=1, i2=0} {i1<<i2} {1}\ntest_expr expr-1.45d {i1=1, i2=62} {i1<<i2} {4611686018427387904}\ntest_expr expr-1.45e {i1=1, i2=63} {i1<<i2} {-9223372036854775808}\ntest_expr expr-1.45f {i1=1, i2=64} {i1<<i2} {0}\ntest_expr expr-1.45g {i1=32, i2=-9223372036854775808} {i1>>i2} {0}\ntest_expr expr-1.46a {i1=32, i2=3} {i1>>i2} {4}\ntest_expr expr-1.46b {i1=32, i2=6} {i1>>i2} {0}\ntest_expr expr-1.46c {i1=-32, i2=3} {i1>>i2} {-4}\ntest_expr expr-1.46d {i1=-32, i2=100} {i1>>i2} {-1}\ntest_expr expr-1.46e {i1=32, i2=-3} {i1>>i2} {256}\ntest_expr expr-1.47 {i1=9999999999, i2=8888888888} {i1<i2} 0\ntest_expr expr-1.48 {i1=9999999999, i2=8888888888} {i1=i2} 0\ntest_expr expr-1.49 {i1=9999999999, i2=8888888888} {i1>i2} 1\ntest_expr expr-1.50 {i1=99999999999, i2=99999999998} {i1<i2} 0\ntest_expr expr-1.51 {i1=99999999999, i2=99999999998} {i1=i2} 0\ntest_expr expr-1.52 {i1=99999999999, i2=99999999998} {i1>i2} 1\ntest_expr expr-1.53 {i1=099999999999, i2=99999999999} {i1<i2} 0\ntest_expr expr-1.54 {i1=099999999999, i2=99999999999} {i1=i2} 1\ntest_expr expr-1.55 {i1=099999999999, i2=99999999999} {i1>i2} 0\ntest_expr expr-1.56 {i1=25, i2=11} {i1%i2} 3\ntest_expr expr-1.58 {i1=NULL, i2=1} {coalesce(i1+i2,99)} 99\ntest_expr expr-1.59 {i1=1, i2=NULL} {coalesce(i1+i2,99)} 99\ntest_expr expr-1.60 {i1=NULL, i2=NULL} {coalesce(i1+i2,99)} 99\ntest_expr expr-1.61 {i1=NULL, i2=1} {coalesce(i1-i2,99)} 99\ntest_expr expr-1.62 {i1=1, i2=NULL} {coalesce(i1-i2,99)} 99\ntest_expr expr-1.63 {i1=NULL, i2=NULL} {coalesce(i1-i2,99)} 99\ntest_expr expr-1.64 {i1=NULL, i2=1} {coalesce(i1*i2,99)} 99\ntest_expr expr-1.65 {i1=1, i2=NULL} {coalesce(i1*i2,99)} 99\ntest_expr expr-1.66 {i1=NULL, i2=NULL} {coalesce(i1*i2,99)} 99\ntest_expr expr-1.67 {i1=NULL, i2=1} {coalesce(i1/i2,99)} 99\ntest_expr expr-1.68 {i1=1, i2=NULL} {coalesce(i1/i2,99)} 99\ntest_expr expr-1.69 {i1=NULL, i2=NULL} {coalesce(i1/i2,99)} 99\ntest_expr expr-1.70 {i1=NULL, i2=1} {coalesce(i1<i2,99)} 99\ntest_expr expr-1.71 {i1=1, i2=NULL} {coalesce(i1>i2,99)} 99\ntest_expr expr-1.72 {i1=NULL, i2=NULL} {coalesce(i1<=i2,99)} 99\ntest_expr expr-1.73 {i1=NULL, i2=1} {coalesce(i1>=i2,99)} 99\ntest_expr expr-1.74 {i1=1, i2=NULL} {coalesce(i1!=i2,99)} 99\ntest_expr expr-1.75 {i1=NULL, i2=NULL} {coalesce(i1==i2,99)} 99\ntest_expr expr-1.76 {i1=NULL, i2=NULL} {coalesce(not i1,99)} 99\ntest_expr expr-1.77 {i1=NULL, i2=NULL} {coalesce(-i1,99)} 99\ntest_expr expr-1.78 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL AND i2=5,99)} 99\ntest_expr expr-1.79 {i1=NULL, i2=NULL} {coalesce(i1 IS NULL OR i2=5,99)} 1\ntest_expr expr-1.80 {i1=NULL, i2=NULL} {coalesce(i1=5 AND i2 IS NULL,99)} 99\ntest_expr expr-1.81 {i1=NULL, i2=NULL} {coalesce(i1=5 OR i2 IS NULL,99)} 1\ntest_expr expr-1.82 {i1=NULL, i2=3} {coalesce(min(i1,i2,1),99)} 99\ntest_expr expr-1.83 {i1=NULL, i2=3} {coalesce(max(i1,i2,1),99)} 99\ntest_expr expr-1.84 {i1=3, i2=NULL} {coalesce(min(i1,i2,1),99)} 99\ntest_expr expr-1.85 {i1=3, i2=NULL} {coalesce(max(i1,i2,1),99)} 99\ntest_expr expr-1.86 {i1=3, i2=8} {5 between i1 and i2} 1\ntest_expr expr-1.87 {i1=3, i2=8} {5 not between i1 and i2} 0\ntest_expr expr-1.88 {i1=3, i2=8} {55 between i1 and i2} 0\ntest_expr expr-1.89 {i1=3, i2=8} {55 not between i1 and i2} 1\ntest_expr expr-1.90 {i1=3, i2=NULL} {5 between i1 and i2} {{}}\ntest_expr expr-1.91 {i1=3, i2=NULL} {5 not between i1 and i2} {{}}\ntest_expr expr-1.92 {i1=3, i2=NULL} {2 between i1 and i2} 0\ntest_expr expr-1.93 {i1=3, i2=NULL} {2 not between i1 and i2} 1\ntest_expr expr-1.94 {i1=NULL, i2=8} {2 between i1 and i2} {{}}\ntest_expr expr-1.95 {i1=NULL, i2=8} {2 not between i1 and i2} {{}}\ntest_expr expr-1.94 {i1=NULL, i2=8} {55 between i1 and i2} 0\ntest_expr expr-1.95 {i1=NULL, i2=8} {55 not between i1 and i2} 1\ntest_expr expr-1.96 {i1=NULL, i2=3} {coalesce(i1<<i2,99)} 99\ntest_expr expr-1.97 {i1=32, i2=NULL} {coalesce(i1>>i2,99)} 99\ntest_expr expr-1.98 {i1=NULL, i2=NULL} {coalesce(i1|i2,99)} 99\ntest_expr expr-1.99 {i1=32, i2=NULL} {coalesce(i1&i2,99)} 99\ntest_expr expr-1.100 {i1=1, i2=''} {i1=i2} 0\ntest_expr expr-1.101 {i1=0, i2=''} {i1=i2} 0\n\n# Check for proper handling of 64-bit integer values.\n#\nif {[working_64bit_int]} {\n  test_expr expr-1.102 {i1=40, i2=1} {i2<<i1} 1099511627776\n}\n\nifcapable floatingpoint {\n  test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0\n  test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0\n  test_expr expr-1.105 {i1=0} {(-9223372036854775808.0 / -1)>1} 1\n}\n\nif {[working_64bit_int]} {\n  test_realnum_expr expr-1.106 {i1=0} {-9223372036854775808/-1} 9.22337203685478e+18\n}\n\ntest_expr expr-1.107 {i1=0} {-9223372036854775808%-1} 0\ntest_expr expr-1.108 {i1=0} {1%0} {{}}\ntest_expr expr-1.109 {i1=0} {1/0} {{}}\n\nif {[working_64bit_int]} {\n  test_expr expr-1.110 {i1=0} {-9223372036854775807/-1} 9223372036854775807\n}\n\ntest_expr expr-1.111 {i1=NULL, i2=8} {i1 IS i2} 0\ntest_expr expr-1.112 {i1=NULL, i2=NULL} {i1 IS i2} 1\ntest_expr expr-1.113 {i1=6, i2=NULL} {i1 IS i2} 0\ntest_expr expr-1.114 {i1=6, i2=6} {i1 IS i2} 1\ntest_expr expr-1.115 {i1=NULL, i2=8} \\\n  {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} no\ntest_expr expr-1.116 {i1=NULL, i2=NULL} \\\n  {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} yes\ntest_expr expr-1.117 {i1=6, i2=NULL} \\\n  {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} no\ntest_expr expr-1.118 {i1=8, i2=8} \\\n  {CASE WHEN i1 IS i2 THEN 'yes' ELSE 'no' END} yes\ntest_expr expr-1.119 {i1=NULL, i2=8} {i1 IS NOT i2} 1\ntest_expr expr-1.120 {i1=NULL, i2=NULL} {i1 IS NOT i2} 0\ntest_expr expr-1.121 {i1=6, i2=NULL} {i1 IS NOT i2} 1\ntest_expr expr-1.122 {i1=6, i2=6} {i1 IS NOT i2} 0\ntest_expr expr-1.123 {i1=NULL, i2=8} \\\n  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes\ntest_expr expr-1.124 {i1=NULL, i2=NULL} \\\n  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no\ntest_expr expr-1.125 {i1=6, i2=NULL} \\\n  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes\ntest_expr expr-1.126 {i1=8, i2=8} \\\n  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no\n\ndo_catchsql_test expr-1.127 {\n  SELECT 1 IS #1;\n} {1 {near \"#1\": syntax error}}\n\nifcapable floatingpoint {if {[working_64bit_int]} {\n  test_expr expr-1.200\\\n      {i1=9223372036854775806, i2=1} {i1+i2}      9223372036854775807\n  test_realnum_expr expr-1.201\\\n      {i1=9223372036854775806, i2=2} {i1+i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.202\\\n      {i1=9223372036854775806, i2=100000} {i1+i2} 9.22337203685488e+18\n  test_realnum_expr expr-1.203\\\n      {i1=9223372036854775807, i2=0} {i1+i2}      9223372036854775807\n  test_realnum_expr expr-1.204\\\n      {i1=9223372036854775807, i2=1} {i1+i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.205\\\n      {i2=9223372036854775806, i1=1} {i1+i2}      9223372036854775807\n  test_realnum_expr expr-1.206\\\n      {i2=9223372036854775806, i1=2} {i1+i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.207\\\n      {i2=9223372036854775806, i1=100000} {i1+i2} 9.22337203685488e+18\n  test_realnum_expr expr-1.208\\\n      {i2=9223372036854775807, i1=0} {i1+i2}      9223372036854775807\n  test_realnum_expr expr-1.209\\\n      {i2=9223372036854775807, i1=1} {i1+i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.210\\\n      {i1=-9223372036854775807, i2=-1} {i1+i2}    -9223372036854775808\n  test_realnum_expr expr-1.211\\\n      {i1=-9223372036854775807, i2=-2} {i1+i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.212\\\n      {i1=-9223372036854775807, i2=-100000} {i1+i2} -9.22337203685488e+18\n  test_realnum_expr expr-1.213\\\n      {i1=-9223372036854775808, i2=0} {i1+i2}     -9223372036854775808\n  test_realnum_expr expr-1.214\\\n      {i1=-9223372036854775808, i2=-1} {i1+i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.215\\\n      {i2=-9223372036854775807, i1=-1} {i1+i2}    -9223372036854775808\n  test_realnum_expr expr-1.216\\\n      {i2=-9223372036854775807, i1=-2} {i1+i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.217\\\n      {i2=-9223372036854775807, i1=-100000} {i1+i2} -9.22337203685488e+18\n  test_realnum_expr expr-1.218\\\n      {i2=-9223372036854775808, i1=0} {i1+i2}     -9223372036854775808\n  test_realnum_expr expr-1.219\\\n      {i2=-9223372036854775808, i1=-1} {i1+i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.220\\\n      {i1=9223372036854775806, i2=-1} {i1-i2}     9223372036854775807\n  test_realnum_expr expr-1.221\\\n      {i1=9223372036854775806, i2=-2} {i1-i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.222\\\n      {i1=9223372036854775806, i2=-100000} {i1-i2} 9.22337203685488e+18\n  test_realnum_expr expr-1.223\\\n      {i1=9223372036854775807, i2=0} {i1-i2}      9223372036854775807\n  test_realnum_expr expr-1.224\\\n      {i1=9223372036854775807, i2=-1} {i1-i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.225\\\n      {i2=-9223372036854775806, i1=1} {i1-i2}      9223372036854775807\n  test_realnum_expr expr-1.226\\\n      {i2=-9223372036854775806, i1=2} {i1-i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.227\\\n      {i2=-9223372036854775806, i1=100000} {i1-i2} 9.22337203685488e+18\n  test_realnum_expr expr-1.228\\\n      {i2=-9223372036854775807, i1=0} {i1-i2}      9223372036854775807\n  test_realnum_expr expr-1.229\\\n      {i2=-9223372036854775807, i1=1} {i1-i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.230\\\n      {i1=-9223372036854775807, i2=1} {i1-i2}    -9223372036854775808\n  test_realnum_expr expr-1.231\\\n      {i1=-9223372036854775807, i2=2} {i1-i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.232\\\n      {i1=-9223372036854775807, i2=100000} {i1-i2} -9.22337203685488e+18\n  test_realnum_expr expr-1.233\\\n      {i1=-9223372036854775808, i2=0} {i1-i2}     -9223372036854775808\n  test_realnum_expr expr-1.234\\\n      {i1=-9223372036854775808, i2=1} {i1-i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.235\\\n      {i2=9223372036854775807, i1=-1} {i1-i2}    -9223372036854775808\n  test_realnum_expr expr-1.236\\\n      {i2=9223372036854775807, i1=-2} {i1-i2}    -9.22337203685478e+18\n  test_realnum_expr expr-1.237\\\n      {i2=9223372036854775807, i1=-100000} {i1-i2} -9.22337203685488e+18\n  test_realnum_expr expr-1.238\\\n      {i2=9223372036854775807, i1=0} {i1-i2}     -9223372036854775807\n  test_realnum_expr expr-1.239\\\n      {i2=9223372036854775807, i1=-1} {i1-i2}    -9223372036854775808\n\n  test_realnum_expr expr-1.250\\\n      {i1=4294967296, i2=2147483648} {i1*i2}      9.22337203685478e+18\n  test_realnum_expr expr-1.251\\\n      {i1=4294967296, i2=2147483647} {i1*i2}      9223372032559808512\n  test_realnum_expr expr-1.252\\\n      {i1=-4294967296, i2=2147483648} {i1*i2}     -9223372036854775808\n  test_realnum_expr expr-1.253\\\n      {i1=-4294967296, i2=2147483647} {i1*i2}     -9223372032559808512\n  test_realnum_expr expr-1.254\\\n      {i1=4294967296, i2=-2147483648} {i1*i2}     -9223372036854775808\n  test_realnum_expr expr-1.255\\\n      {i1=4294967296, i2=-2147483647} {i1*i2}     -9223372032559808512\n  test_realnum_expr expr-1.256\\\n      {i1=-4294967296, i2=-2147483648} {i1*i2}    9.22337203685478e+18\n  test_realnum_expr expr-1.257\\\n      {i1=-4294967296, i2=-2147483647} {i1*i2}    9223372032559808512\n\n  test_realnum_expr expr-1.260\\\n      {i1=3037000500, i2=3037000500} {i1*i2}      9.22337203700025e+18\n  test_realnum_expr expr-1.261\\\n      {i1=3037000500, i2=-3037000500} {i1*i2}     -9.22337203700025e+18\n  test_realnum_expr expr-1.262\\\n      {i1=-3037000500, i2=3037000500} {i1*i2}     -9.22337203700025e+18\n  test_realnum_expr expr-1.263\\\n      {i1=-3037000500, i2=-3037000500} {i1*i2}    9.22337203700025e+18\n\n  test_realnum_expr expr-1.264\\\n      {i1=3037000500, i2=3037000499} {i1*i2}      9223372033963249500\n  test_realnum_expr expr-1.265\\\n      {i1=3037000500, i2=-3037000499} {i1*i2}     -9223372033963249500\n  test_realnum_expr expr-1.266\\\n      {i1=-3037000500, i2=3037000499} {i1*i2}     -9223372033963249500\n  test_realnum_expr expr-1.267\\\n      {i1=-3037000500, i2=-3037000499} {i1*i2}    9223372033963249500\n\n  test_realnum_expr expr-1.268\\\n      {i1=3037000499, i2=3037000500} {i1*i2}      9223372033963249500\n  test_realnum_expr expr-1.269\\\n      {i1=3037000499, i2=-3037000500} {i1*i2}     -9223372033963249500\n  test_realnum_expr expr-1.270\\\n      {i1=-3037000499, i2=3037000500} {i1*i2}     -9223372033963249500\n  test_realnum_expr expr-1.271\\\n      {i1=-3037000499, i2=-3037000500} {i1*i2}    9223372033963249500\n\n}}\n\nifcapable floatingpoint {\n  test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57\n  test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11\n  test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782\n}\nset tcl_precision 15\nifcapable floatingpoint {\n  test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026\n  test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024\n  test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0\n  test_expr expr-2.7 {r1=1.23, r2=2.34} {r2<=r1} 0\n  test_expr expr-2.8 {r1=1.23, r2=2.34} {r2>r1} 1\n  test_expr expr-2.9 {r1=1.23, r2=2.34} {r2>=r1} 1\n  test_expr expr-2.10 {r1=1.23, r2=2.34} {r2!=r1} 1\n  test_expr expr-2.11 {r1=1.23, r2=2.34} {r2=r1} 0\n  test_expr expr-2.12 {r1=1.23, r2=2.34} {r2<>r1} 1\n  test_expr expr-2.13 {r1=1.23, r2=2.34} {r2==r1} 0\n  test_expr expr-2.14 {r1=2.34, r2=2.34} {r2<r1} 0\n  test_expr expr-2.15 {r1=2.34, r2=2.34} {r2<=r1} 1\n  test_expr expr-2.16 {r1=2.34, r2=2.34} {r2>r1} 0\n  test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1\n  test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0\n  test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1\n  test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0\n  test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1\n  test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}\n  test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}\n  test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0\n  test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0\n  test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0\n  test_expr expr-2.26b {r1=1e300, r2=-1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0\n  test_expr expr-2.27 {r1=1.1, r2=0.0} {r1/r2} {{}}\n  test_expr expr-2.28 {r1=1.1, r2=0.0} {r1%r2} {{}}\n}\n\ntest_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1\ntest_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0\ntest_expr expr-3.3 {t1='abc', t2='abc'} {t1<t2} 0\ntest_expr expr-3.4 {t1='abc', t2='xyz'} {t1<=t2} 1\ntest_expr expr-3.5 {t1='xyz', t2='abc'} {t1<=t2} 0\ntest_expr expr-3.6 {t1='abc', t2='abc'} {t1<=t2} 1\ntest_expr expr-3.7 {t1='abc', t2='xyz'} {t1>t2} 0\ntest_expr expr-3.8 {t1='xyz', t2='abc'} {t1>t2} 1\ntest_expr expr-3.9 {t1='abc', t2='abc'} {t1>t2} 0\ntest_expr expr-3.10 {t1='abc', t2='xyz'} {t1>=t2} 0\ntest_expr expr-3.11 {t1='xyz', t2='abc'} {t1>=t2} 1\ntest_expr expr-3.12 {t1='abc', t2='abc'} {t1>=t2} 1\ntest_expr expr-3.13 {t1='abc', t2='xyz'} {t1=t2} 0\ntest_expr expr-3.14 {t1='xyz', t2='abc'} {t1=t2} 0\ntest_expr expr-3.15 {t1='abc', t2='abc'} {t1=t2} 1\ntest_expr expr-3.16 {t1='abc', t2='xyz'} {t1==t2} 0\ntest_expr expr-3.17 {t1='xyz', t2='abc'} {t1==t2} 0\ntest_expr expr-3.18 {t1='abc', t2='abc'} {t1==t2} 1\ntest_expr expr-3.19 {t1='abc', t2='xyz'} {t1<>t2} 1\ntest_expr expr-3.20 {t1='xyz', t2='abc'} {t1<>t2} 1\ntest_expr expr-3.21 {t1='abc', t2='abc'} {t1<>t2} 0\ntest_expr expr-3.22 {t1='abc', t2='xyz'} {t1!=t2} 1\ntest_expr expr-3.23 {t1='xyz', t2='abc'} {t1!=t2} 1\ntest_expr expr-3.24 {t1='abc', t2='abc'} {t1!=t2} 0\ntest_expr expr-3.25 {t1=NULL, t2='hi'} {t1 isnull} 1\ntest_expr expr-3.25b {t1=NULL, t2='hi'} {t1 is null} 1\ntest_expr expr-3.26 {t1=NULL, t2='hi'} {t2 isnull} 0\ntest_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0\ntest_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1\ntest_expr expr-3.28b {t1=NULL, t2='hi'} {t2 is not null} 1\ntest_expr expr-3.29 {t1='xyz', t2='abc'} {t1||t2} {xyzabc}\ntest_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {{}}\ntest_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {{}}\ntest_expr expr-3.32 {t1='xyz', t2='abc'} {t1||' hi '||t2} {{xyz hi abc}}\ntest_expr epxr-3.33 {t1='abc', t2=NULL} {coalesce(t1<t2,99)} 99\ntest_expr epxr-3.34 {t1='abc', t2=NULL} {coalesce(t2<t1,99)} 99\ntest_expr epxr-3.35 {t1='abc', t2=NULL} {coalesce(t1>t2,99)} 99\ntest_expr epxr-3.36 {t1='abc', t2=NULL} {coalesce(t2>t1,99)} 99\ntest_expr epxr-3.37 {t1='abc', t2=NULL} {coalesce(t1<=t2,99)} 99\ntest_expr epxr-3.38 {t1='abc', t2=NULL} {coalesce(t2<=t1,99)} 99\ntest_expr epxr-3.39 {t1='abc', t2=NULL} {coalesce(t1>=t2,99)} 99\ntest_expr epxr-3.40 {t1='abc', t2=NULL} {coalesce(t2>=t1,99)} 99\ntest_expr epxr-3.41 {t1='abc', t2=NULL} {coalesce(t1==t2,99)} 99\ntest_expr epxr-3.42 {t1='abc', t2=NULL} {coalesce(t2==t1,99)} 99\ntest_expr epxr-3.43 {t1='abc', t2=NULL} {coalesce(t1!=t2,99)} 99\ntest_expr epxr-3.44 {t1='abc', t2=NULL} {coalesce(t2!=t1,99)} 99\n\ntest_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0\ntest_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1\ntest_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 0\ntest_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 1\ntest_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 0\ntest_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0\ntest_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0\ntest_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1\ntest_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0\n\nifcapable floatingpoint {\n  test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0\n  test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0\n  test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1\n  test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0\n  test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1\n  test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1\n  test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1\n  test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 1\n  test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1\n  test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0\n  test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0\n}\n\n# CSL is true if LIKE is case sensitive and false if not.\n# NCSL is the opposite.  Use these variables as the result\n# on operations where case makes a difference.\nset CSL $sqlite_options(casesensitivelike)\nset NCSL [expr {!$CSL}]\n\ntest_expr expr-5.1 {t1='abc', t2='xyz'} {t1 LIKE t2} 0\ntest_expr expr-5.2a {t1='abc', t2='abc'} {t1 LIKE t2} 1\ntest_expr expr-5.2b {t1='abc', t2='ABC'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.3a {t1='abc', t2='a_c'} {t1 LIKE t2} 1\ntest_expr expr-5.3b {t1='abc', t2='A_C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.4 {t1='abc', t2='abc_'} {t1 LIKE t2} 0\ntest_expr expr-5.5a {t1='abc', t2='a%c'} {t1 LIKE t2} 1\ntest_expr expr-5.5b {t1='abc', t2='A%C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.5c {t1='abdc', t2='a%c'} {t1 LIKE t2} 1\ntest_expr expr-5.5d {t1='ac', t2='a%c'} {t1 LIKE t2} 1\ntest_expr expr-5.5e {t1='ac', t2='A%C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.6a {t1='abxyzzyc', t2='a%c'} {t1 LIKE t2} 1\ntest_expr expr-5.6b {t1='abxyzzyc', t2='A%C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.7a {t1='abxyzzy', t2='a%c'} {t1 LIKE t2} 0\ntest_expr expr-5.7b {t1='abxyzzy', t2='A%C'} {t1 LIKE t2} 0\ntest_expr expr-5.8a {t1='abxyzzycx', t2='a%c'} {t1 LIKE t2} 0\ntest_expr expr-5.8b {t1='abxyzzycy', t2='a%cx'} {t1 LIKE t2} 0\ntest_expr expr-5.8c {t1='abxyzzycx', t2='A%C'} {t1 LIKE t2} 0\ntest_expr expr-5.8d {t1='abxyzzycy', t2='A%CX'} {t1 LIKE t2} 0\ntest_expr expr-5.9a {t1='abc', t2='a%_c'} {t1 LIKE t2} 1\ntest_expr expr-5.9b {t1='ac', t2='a%_c'} {t1 LIKE t2} 0\ntest_expr expr-5.9c {t1='abc', t2='A%_C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.9d {t1='ac', t2='A%_C'} {t1 LIKE t2} 0\ntest_expr expr-5.10a {t1='abxyzzyc', t2='a%_c'} {t1 LIKE t2} 1\ntest_expr expr-5.10b {t1='abxyzzyc', t2='A%_C'} {t1 LIKE t2} $NCSL\ntest_expr expr-5.11 {t1='abc', t2='xyz'} {t1 NOT LIKE t2} 1\ntest_expr expr-5.12a {t1='abc', t2='abc'} {t1 NOT LIKE t2} 0\ntest_expr expr-5.12b {t1='abc', t2='ABC'} {t1 NOT LIKE t2} $CSL\ntest_expr expr-5.13  {t1='A'}  {t1 LIKE 'A%_'} 0\ntest_expr expr-5.14  {t1='AB'} {t1 LIKE 'A%b' ESCAPE 'b'} 0\n\n# The following tests only work on versions of TCL that support Unicode\n#\nif {\"\\u1234\"!=\"u1234\"} {\n  test_expr expr-5.13a \"t1='a\\u0080c', t2='a_c'\" {t1 LIKE t2} 1\n  test_expr expr-5.13b \"t1='a\\u0080c', t2='A_C'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.14a \"t1='a\\u07FFc', t2='a_c'\" {t1 LIKE t2} 1\n  test_expr expr-5.14b \"t1='a\\u07FFc', t2='A_C'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.15a \"t1='a\\u0800c', t2='a_c'\" {t1 LIKE t2} 1\n  test_expr expr-5.15b \"t1='a\\u0800c', t2='A_C'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.16a \"t1='a\\uFFFFc', t2='a_c'\" {t1 LIKE t2} 1\n  test_expr expr-5.16b \"t1='a\\uFFFFc', t2='A_C'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.17 \"t1='a\\u0080', t2='A__'\" {t1 LIKE t2} 0\n  test_expr expr-5.18 \"t1='a\\u07FF', t2='A__'\" {t1 LIKE t2} 0\n  test_expr expr-5.19 \"t1='a\\u0800', t2='A__'\" {t1 LIKE t2} 0\n  test_expr expr-5.20 \"t1='a\\uFFFF', t2='A__'\" {t1 LIKE t2} 0\n  test_expr expr-5.21a \"t1='ax\\uABCD', t2='a_\\uABCD'\" {t1 LIKE t2} 1\n  test_expr expr-5.21b \"t1='ax\\uABCD', t2='A_\\uABCD'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.22a \"t1='ax\\u1234', t2='a%\\u1234'\" {t1 LIKE t2} 1\n  test_expr expr-5.22b \"t1='ax\\u1234', t2='A%\\u1234'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.23a \"t1='ax\\uFEDC', t2='a_%'\" {t1 LIKE t2} 1\n  test_expr expr-5.23b \"t1='ax\\uFEDC', t2='A_%'\" {t1 LIKE t2} $NCSL\n  test_expr expr-5.24a \"t1='ax\\uFEDCy\\uFEDC', t2='a%\\uFEDC'\" {t1 LIKE t2} 1\n  test_expr expr-5.24b \"t1='ax\\uFEDCy\\uFEDC', t2='A%\\uFEDC'\" {t1 LIKE t2} $NCSL\n}\n\ntest_expr expr-5.54 {t1='abc', t2=NULL} {t1 LIKE t2} {{}}\ntest_expr expr-5.55 {t1='abc', t2=NULL} {t1 NOT LIKE t2} {{}}\ntest_expr expr-5.56 {t1='abc', t2=NULL} {t2 LIKE t1} {{}}\ntest_expr expr-5.57 {t1='abc', t2=NULL} {t2 NOT LIKE t1} {{}}\n\n# LIKE expressions that use ESCAPE characters.\ntest_expr expr-5.58a {t1='abc', t2='a_c'}   {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.58b {t1='abc', t2='A_C'}   {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.59a {t1='a_c', t2='a7_c'}  {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.59b {t1='a_c', t2='A7_C'}  {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.60a {t1='abc', t2='a7_c'}  {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.60b {t1='abc', t2='A7_C'}  {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.61a {t1='a7Xc', t2='a7_c'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.61b {t1='a7Xc', t2='A7_C'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.62a {t1='abcde', t2='a%e'} {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.62b {t1='abcde', t2='A%E'} {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.63a {t1='abcde', t2='a7%e'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.63b {t1='abcde', t2='A7%E'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.64a {t1='a7cde', t2='a7%e'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.64b {t1='a7cde', t2='A7%E'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.65a {t1='a7cde', t2='a77%e'} {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.65b {t1='a7cde', t2='A77%E'} {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.66a {t1='abc7', t2='a%77'} {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.66b {t1='abc7', t2='A%77'} {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.67a {t1='abc_', t2='a%7_'} {t1 LIKE t2 ESCAPE '7'} 1\ntest_expr expr-5.67b {t1='abc_', t2='A%7_'} {t1 LIKE t2 ESCAPE '7'} $NCSL\ntest_expr expr-5.68a {t1='abc7', t2='a%7_'} {t1 LIKE t2 ESCAPE '7'} 0\ntest_expr expr-5.68b {t1='abc7', t2='A%7_'} {t1 LIKE t2 ESCAPE '7'} 0\n\n# These are the same test as the block above, but using a multi-byte \n# character as the escape character.\nif {\"\\u1234\"!=\"u1234\"} {\n  test_expr expr-5.69a \"t1='abc', t2='a_c'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.69b \"t1='abc', t2='A_C'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.70a \"t1='a_c', t2='a\\u1234_c'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.70b \"t1='a_c', t2='A\\u1234_C'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.71a \"t1='abc', t2='a\\u1234_c'\" \\\n       \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.71b \"t1='abc', t2='A\\u1234_C'\" \\\n       \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.72a \"t1='a\\u1234Xc', t2='a\\u1234_c'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.72b \"t1='a\\u1234Xc', t2='A\\u1234_C'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.73a \"t1='abcde', t2='a%e'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.73b \"t1='abcde', t2='A%E'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.74a \"t1='abcde', t2='a\\u1234%e'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.74b \"t1='abcde', t2='A\\u1234%E'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.75a \"t1='a\\u1234cde', t2='a\\u1234%e'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.75b \"t1='a\\u1234cde', t2='A\\u1234%E'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.76a \"t1='a\\u1234cde', t2='a\\u1234\\u1234%e'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.76b \"t1='a\\u1234cde', t2='A\\u1234\\u1234%E'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.77a \"t1='abc\\u1234', t2='a%\\u1234\\u1234'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.77b \"t1='abc\\u1234', t2='A%\\u1234\\u1234'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.78a \"t1='abc_', t2='a%\\u1234_'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 1\n  test_expr expr-5.78b \"t1='abc_', t2='A%\\u1234_'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" $NCSL\n  test_expr expr-5.79a \"t1='abc\\u1234', t2='a%\\u1234_'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n  test_expr expr-5.79b \"t1='abc\\u1234', t2='A%\\u1234_'\" \\\n      \"t1 LIKE t2 ESCAPE '\\u1234'\" 0\n}\n\ntest_expr expr-6.1 {t1='abc', t2='xyz'} {t1 GLOB t2} 0\ntest_expr expr-6.2 {t1='abc', t2='ABC'} {t1 GLOB t2} 0\ntest_expr expr-6.3 {t1='abc', t2='A?C'} {t1 GLOB t2} 0\ntest_expr expr-6.4 {t1='abc', t2='a?c'} {t1 GLOB t2} 1\ntest_expr expr-6.5 {t1='abc', t2='abc?'} {t1 GLOB t2} 0\ntest_expr expr-6.6 {t1='abc', t2='A*C'} {t1 GLOB t2} 0\ntest_expr expr-6.7 {t1='abc', t2='a*c'} {t1 GLOB t2} 1\ntest_expr expr-6.8 {t1='abxyzzyc', t2='a*c'} {t1 GLOB t2} 1\ntest_expr expr-6.9 {t1='abxyzzy', t2='a*c'} {t1 GLOB t2} 0\ntest_expr expr-6.10 {t1='abxyzzycx', t2='a*c'} {t1 GLOB t2} 0\ntest_expr expr-6.11 {t1='abc', t2='xyz'} {t1 NOT GLOB t2} 1\ntest_expr expr-6.12 {t1='abc', t2='abc'} {t1 NOT GLOB t2} 0\ntest_expr expr-6.13 {t1='abc', t2='a[bx]c'} {t1 GLOB t2} 1\ntest_expr expr-6.14 {t1='abc', t2='a[cx]c'} {t1 GLOB t2} 0\ntest_expr expr-6.15 {t1='abc', t2='a[a-d]c'} {t1 GLOB t2} 1\ntest_expr expr-6.16 {t1='abc', t2='a[^a-d]c'} {t1 GLOB t2} 0\ntest_expr expr-6.17 {t1='abc', t2='a[A-Dc]c'} {t1 GLOB t2} 0\ntest_expr expr-6.18 {t1='abc', t2='a[^A-Dc]c'} {t1 GLOB t2} 1\ntest_expr expr-6.19 {t1='abc', t2='a[]b]c'} {t1 GLOB t2} 1\ntest_expr expr-6.20 {t1='abc', t2='a[^]b]c'} {t1 GLOB t2} 0\ntest_expr expr-6.21a {t1='abcdefg', t2='a*[de]g'} {t1 GLOB t2} 0\ntest_expr expr-6.21b {t1='abcdefg', t2='a*[df]g'} {t1 GLOB t2} 1\ntest_expr expr-6.21c {t1='abcdefg', t2='a*[d-h]g'} {t1 GLOB t2} 1\ntest_expr expr-6.21d {t1='abcdefg', t2='a*[b-e]g'} {t1 GLOB t2} 0\ntest_expr expr-6.22a {t1='abcdefg', t2='a*[^de]g'} {t1 GLOB t2} 1\ntest_expr expr-6.22b {t1='abcdefg', t2='a*[^def]g'} {t1 GLOB t2} 0\ntest_expr expr-6.23 {t1='abcdefg', t2='a*?g'} {t1 GLOB t2} 1\ntest_expr expr-6.24 {t1='ac', t2='a*c'} {t1 GLOB t2} 1\ntest_expr expr-6.25 {t1='ac', t2='a*?c'} {t1 GLOB t2} 0\ntest_expr expr-6.26 {t1='a*c', t2='a[*]c'} {t1 GLOB t2} 1\ntest_expr expr-6.27 {t1='a?c', t2='a[?]c'} {t1 GLOB t2} 1\ntest_expr expr-6.28 {t1='a[c', t2='a[[]c'} {t1 GLOB t2} 1\n\n\n# These tests only work on versions of TCL that support Unicode\n#\nif {\"\\u1234\"!=\"u1234\"} {\n  test_expr expr-6.26 \"t1='a\\u0080c', t2='a?c'\" {t1 GLOB t2} 1\n  test_expr expr-6.27 \"t1='a\\u07ffc', t2='a?c'\" {t1 GLOB t2} 1\n  test_expr expr-6.28 \"t1='a\\u0800c', t2='a?c'\" {t1 GLOB t2} 1\n  test_expr expr-6.29 \"t1='a\\uffffc', t2='a?c'\" {t1 GLOB t2} 1\n  test_expr expr-6.30 \"t1='a\\u1234', t2='a?'\" {t1 GLOB t2} 1\n  test_expr expr-6.31 \"t1='a\\u1234', t2='a??'\" {t1 GLOB t2} 0\n  test_expr expr-6.32 \"t1='ax\\u1234', t2='a?\\u1234'\" {t1 GLOB t2} 1\n  test_expr expr-6.33 \"t1='ax\\u1234', t2='a*\\u1234'\" {t1 GLOB t2} 1\n  test_expr expr-6.34 \"t1='ax\\u1234y\\u1234', t2='a*\\u1234'\" {t1 GLOB t2} 1\n  test_expr expr-6.35 \"t1='a\\u1234b', t2='a\\[x\\u1234y\\]b'\" {t1 GLOB t2} 1\n  test_expr expr-6.36 \"t1='a\\u1234b', t2='a\\[\\u1233-\\u1235\\]b'\" {t1 GLOB t2} 1\n  test_expr expr-6.37 \"t1='a\\u1234b', t2='a\\[\\u1234-\\u124f\\]b'\" {t1 GLOB t2} 1\n  test_expr expr-6.38 \"t1='a\\u1234b', t2='a\\[\\u1235-\\u124f\\]b'\" {t1 GLOB t2} 0\n  test_expr expr-6.39 \"t1='a\\u1234b', t2='a\\[a-\\u1235\\]b'\" {t1 GLOB t2} 1\n  test_expr expr-6.40 \"t1='a\\u1234b', t2='a\\[a-\\u1234\\]b'\" {t1 GLOB t2} 1\n  test_expr expr-6.41 \"t1='a\\u1234b', t2='a\\[a-\\u1233\\]b'\" {t1 GLOB t2} 0\n}\n\ntest_expr expr-6.51 {t1='ABC', t2='xyz'} {t1 GLOB t2} 0\ntest_expr expr-6.52 {t1='ABC', t2='abc'} {t1 GLOB t2} 0\ntest_expr expr-6.53 {t1='ABC', t2='a?c'} {t1 GLOB t2} 0\ntest_expr expr-6.54 {t1='ABC', t2='A?C'} {t1 GLOB t2} 1\ntest_expr expr-6.55 {t1='ABC', t2='abc?'} {t1 GLOB t2} 0\ntest_expr expr-6.56 {t1='ABC', t2='a*c'} {t1 GLOB t2} 0\ntest_expr expr-6.57 {t1='ABC', t2='A*C'} {t1 GLOB t2} 1\ntest_expr expr-6.58 {t1='ABxyzzyC', t2='A*C'} {t1 GLOB t2} 1\ntest_expr expr-6.59 {t1='ABxyzzy', t2='A*C'} {t1 GLOB t2} 0\ntest_expr expr-6.60 {t1='ABxyzzyCx', t2='A*C'} {t1 GLOB t2} 0\ntest_expr expr-6.61 {t1='ABC', t2='xyz'} {t1 NOT GLOB t2} 1\ntest_expr expr-6.62 {t1='ABC', t2='ABC'} {t1 NOT GLOB t2} 0\ntest_expr expr-6.63 {t1='ABC', t2='A[Bx]C'} {t1 GLOB t2} 1\ntest_expr expr-6.64 {t1='ABC', t2='A[Cx]C'} {t1 GLOB t2} 0\ntest_expr expr-6.65 {t1='ABC', t2='A[A-D]C'} {t1 GLOB t2} 1\ntest_expr expr-6.66 {t1='ABC', t2='A[^A-D]C'} {t1 GLOB t2} 0\ntest_expr expr-6.67 {t1='ABC', t2='A[a-dC]C'} {t1 GLOB t2} 0\ntest_expr expr-6.68 {t1='ABC', t2='A[^a-dC]C'} {t1 GLOB t2} 1\ntest_expr expr-6.69a {t1='ABC', t2='A[]B]C'} {t1 GLOB t2} 1\ntest_expr expr-6.69b {t1='A]C', t2='A[]B]C'} {t1 GLOB t2} 1\ntest_expr expr-6.70a {t1='ABC', t2='A[^]B]C'} {t1 GLOB t2} 0\ntest_expr expr-6.70b {t1='AxC', t2='A[^]B]C'} {t1 GLOB t2} 1\ntest_expr expr-6.70c {t1='A]C', t2='A[^]B]C'} {t1 GLOB t2} 0\ntest_expr expr-6.71 {t1='ABCDEFG', t2='A*[DE]G'} {t1 GLOB t2} 0\ntest_expr expr-6.72 {t1='ABCDEFG', t2='A*[^DE]G'} {t1 GLOB t2} 1\ntest_expr expr-6.73 {t1='ABCDEFG', t2='A*?G'} {t1 GLOB t2} 1\ntest_expr expr-6.74 {t1='AC', t2='A*C'} {t1 GLOB t2} 1\ntest_expr expr-6.75 {t1='AC', t2='A*?C'} {t1 GLOB t2} 0\n\ntest_expr expr-6.63 {t1=NULL, t2='a*?c'} {t1 GLOB t2} {{}}\ntest_expr expr-6.64 {t1='ac', t2=NULL} {t1 GLOB t2} {{}}\ntest_expr expr-6.65 {t1=NULL, t2='a*?c'} {t1 NOT GLOB t2} {{}}\ntest_expr expr-6.66 {t1='ac', t2=NULL} {t1 NOT GLOB t2} {{}}\n\n# Check that the affinity of a CAST expression is calculated correctly.\nifcapable cast {\n  test_expr expr-6.67 {t1='01', t2=1} {t1 = t2} 0\n  test_expr expr-6.68 {t1='1', t2=1} {t1 = t2} 1\n  test_expr expr-6.69 {t1='01', t2=1} {CAST(t1 AS INTEGER) = t2} 1\n}\n\ntest_expr expr-case.1 {i1=1, i2=2} \\\n\t{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne\ntest_expr expr-case.2 {i1=2, i2=2} \\\n\t{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} eq\ntest_expr expr-case.3 {i1=NULL, i2=2} \\\n\t{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne\ntest_expr expr-case.4 {i1=2, i2=NULL} \\\n\t{CASE WHEN i1 = i2 THEN 'eq' ELSE 'ne' END} ne\ntest_expr expr-case.5 {i1=2} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} two\ntest_expr expr-case.6 {i1=1} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} one\ntest_expr expr-case.7 {i1=2} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error\ntest_expr expr-case.8 {i1=3} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN NULL THEN 'two' ELSE 'error' END} error\ntest_expr expr-case.9 {i1=3} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'error' END} error\ntest_expr expr-case.10 {i1=3} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' END} {{}}\ntest_expr expr-case.11 {i1=null} \\\n\t{CASE i1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 3 END} 3\ntest_expr expr-case.12 {i1=1} \\\n\t{CASE i1 WHEN 1 THEN null WHEN 2 THEN 'two' ELSE 3 END} {{}}\ntest_expr expr-case.13 {i1=7} \\\n\t{ CASE WHEN i1 < 5 THEN 'low' \n\t       WHEN i1 < 10 THEN 'medium' \n               WHEN i1 < 15 THEN 'high' ELSE 'error' END} medium\n\n\n# The sqliteExprIfFalse and sqliteExprIfTrue routines are only\n# executed as part of a WHERE clause.  Create a table suitable\n# for testing these functions.\n#\nexecsql {DROP TABLE test1}\nexecsql {CREATE TABLE test1(a int, b int);}\nfor {set i 1} {$i<=20} {incr i} {\n  execsql \"INSERT INTO test1 VALUES($i,[expr {1<<$i}])\"\n}\nexecsql \"INSERT INTO test1 VALUES(NULL,0)\"\ndo_test expr-7.1 {\n  execsql {SELECT * FROM test1 ORDER BY a}\n} {{} 0 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024 11 2048 12 4096 13 8192 14 16384 15 32768 16 65536 17 131072 18 262144 19 524288 20 1048576}\n\nproc test_expr2 {name expr result} {\n  do_test $name [format {\n    execsql {SELECT a FROM test1 WHERE %s ORDER BY a}\n  } $expr] $result\n}\n\ntest_expr2 expr-7.2  {a<10 AND a>8}                  {9}\ntest_expr2 expr-7.3  {a<=10 AND a>=8}                {8 9 10}\ntest_expr2 expr-7.4  {a>=8 AND a<=10}                {8 9 10}\ntest_expr2 expr-7.5  {a>=20 OR a<=1}                 {1 20}\ntest_expr2 expr-7.6  {b!=4 AND a<=3}                 {1 3}\ntest_expr2 expr-7.7  {b==8 OR b==16 OR b==32}        {3 4 5}\ntest_expr2 expr-7.8  {NOT b<>8 OR b==1024}           {3 10}\ntest_expr2 expr-7.9  {b LIKE '10%'}                  {10 20}\ntest_expr2 expr-7.10 {b LIKE '_4'}                   {6}\ntest_expr2 expr-7.11 {a GLOB '1?'}            {10 11 12 13 14 15 16 17 18 19}\ntest_expr2 expr-7.12 {b GLOB '1*4'}                  {10 14}\ntest_expr2 expr-7.13 {b GLOB '*1[456]'}              {4}\ntest_expr2 expr-7.14 {a ISNULL}                      {{}}\ntest_expr2 expr-7.15 {a NOTNULL AND a<3}             {1 2}\ntest_expr2 expr-7.16 {a AND a<3}                     {1 2}\ntest_expr2 expr-7.17 {NOT a}                         {}\ntest_expr2 expr-7.18 {a==11 OR (b>1000 AND b<2000)}  {10 11}\ntest_expr2 expr-7.19 {a<=1 OR a>=20}                 {1 20}\ntest_expr2 expr-7.20 {a<1 OR a>20}                   {}\ntest_expr2 expr-7.21 {a>19 OR a<1}                   {20}\ntest_expr2 expr-7.22 {a!=1 OR a=100} \\\n                         {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\ntest_expr2 expr-7.23 {(a notnull AND a<4) OR a==8}   {1 2 3 8}\ntest_expr2 expr-7.24 {a LIKE '2_' OR a==8}           {8 20}\ntest_expr2 expr-7.25 {a GLOB '2?' OR a==8}           {8 20}\ntest_expr2 expr-7.26 {a isnull OR a=8}               {{} 8}\ntest_expr2 expr-7.27 {a notnull OR a=8} \\\n                          {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\ntest_expr2 expr-7.28 {a<0 OR b=0} {{}}\ntest_expr2 expr-7.29 {b=0 OR a<0} {{}}\ntest_expr2 expr-7.30 {a<0 AND b=0} {}\ntest_expr2 expr-7.31 {b=0 AND a<0} {}\ntest_expr2 expr-7.32 {a IS NULL AND (a<0 OR b=0)} {{}}\ntest_expr2 expr-7.33 {a IS NULL AND (b=0 OR a<0)} {{}}\ntest_expr2 expr-7.34 {a IS NULL AND (a<0 AND b=0)} {}\ntest_expr2 expr-7.35 {a IS NULL AND (b=0 AND a<0)} {}\ntest_expr2 expr-7.32 {(a<0 OR b=0) AND a IS NULL} {{}}\ntest_expr2 expr-7.33 {(b=0 OR a<0) AND a IS NULL} {{}}\ntest_expr2 expr-7.34 {(a<0 AND b=0) AND a IS NULL} {}\ntest_expr2 expr-7.35 {(b=0 AND a<0) AND a IS NULL} {}\ntest_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}\ntest_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}\ntest_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}\ntest_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}\nifcapable floatingpoint {\n  test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}\n}\ntest_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}\ntest_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}\ntest_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}\ntest_expr2 expr-7.44 {123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a BETWEEN '123a' AND '123b'} {}\ntest_expr2 expr-7.45 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123b')<0} {}\ntest_expr2 expr-7.46 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123z')>0} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\n\ntest_expr2 expr-7.50 {((a between 1 and 2 OR 0) AND 1) OR 0} {1 2}\ntest_expr2 expr-7.51 {((a not between 3 and 100 OR 0) AND 1) OR 0} {1 2}\n\nifcapable subquery {\n  test_expr2 expr-7.52 {((a in (1,2) OR 0) AND 1) OR 0} {1 2}\n  test_expr2 expr-7.53 \\\n      {((a not in (3,4,5,6,7,8,9,10) OR 0) AND a<11) OR 0} {1 2}\n}\ntest_expr2 expr-7.54 {((a>0 OR 0) AND a<3) OR 0} {1 2}\nifcapable subquery {\n  test_expr2 expr-7.55 {((a in (1,2) OR 0) IS NULL AND 1) OR 0} {{}}\n  test_expr2 expr-7.56 \\\n      {((a not in (3,4,5,6,7,8,9,10) IS NULL OR 0) AND 1) OR 0} {{}}\n}\ntest_expr2 expr-7.57 {((a>0 IS NULL OR 0) AND 1) OR 0} {{}}\n\ntest_expr2 expr-7.58  {(a||'')<='1'}                  {1}\n\ntest_expr2 expr-7.59 {LIKE('10%',b)}                  {10 20}\ntest_expr2 expr-7.60 {LIKE('_4',b)}                   {6}\ntest_expr2 expr-7.61 {GLOB('1?',a)}            {10 11 12 13 14 15 16 17 18 19}\ntest_expr2 expr-7.62 {GLOB('1*4',b)}                  {10 14}\ntest_expr2 expr-7.63 {GLOB('*1[456]',b)}              {4}\ntest_expr2 expr-7.64 {b = abs(-2)}                    {1}\ntest_expr2 expr-7.65 {b = abs(+-2)}                   {1}\ntest_expr2 expr-7.66 {b = abs(++-2)}                  {1}\ntest_expr2 expr-7.67 {b = abs(+-+-2)}                 {1}\ntest_expr2 expr-7.68 {b = abs(+-++-2)}                {1}\ntest_expr2 expr-7.69 {b = abs(++++-2)}                {1}\ntest_expr2 expr-7.70 {b = 5 - abs(+3)}                {1}\ntest_expr2 expr-7.71 {b = 5 - abs(-3)}                {1}\nifcapable floatingpoint {\n  test_expr2 expr-7.72 {b = abs(-2.0)}                  {1}\n}\ntest_expr2 expr-7.73 {b = 6 - abs(-a)}                {2}\nifcapable floatingpoint {\n  test_expr2 expr-7.74 {b = abs(8.0)}                   {3}\n}\n\n# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.\n#\nifcapable {floatingpoint} {\n  set sqlite_current_time 1157124849\n  do_test expr-8.1 {\n    execsql {SELECT CURRENT_TIME}\n  } {15:34:09}\n  do_test expr-8.2 {\n    execsql {SELECT CURRENT_DATE}\n  } {2006-09-01}\n  do_test expr-8.3 {\n    execsql {SELECT CURRENT_TIMESTAMP}\n  } {{2006-09-01 15:34:09}}\n}\nifcapable datetime {\n  do_test expr-8.4 {\n    execsql {SELECT CURRENT_TIME==time('now');}\n  } 1\n  do_test expr-8.5 {\n    execsql {SELECT CURRENT_DATE==date('now');}\n  } 1\n  do_test expr-8.6 {\n    execsql {SELECT CURRENT_TIMESTAMP==datetime('now');}\n  } 1\n}\nset sqlite_current_time 0\n\nifcapable floatingpoint {\n  do_test expr-9.1 {\n    execsql {SELECT round(-('-'||'123'))}\n  } 123.0\n}\n\n# Test an error message that can be generated by the LIKE expression\ndo_test expr-10.1 {\n  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE ''}\n} {1 {ESCAPE expression must be a single character}}\ndo_test expr-10.2 {\n  catchsql {SELECT 'abc' LIKE 'abc' ESCAPE 'ab'}\n} {1 {ESCAPE expression must be a single character}}\n\n# If we specify an integer constant that is bigger than the largest\n# possible integer, code the integer as a real number.\n#\ndo_test expr-11.1 {\n  execsql {SELECT typeof(9223372036854775807)}\n} {integer}\ndo_test expr-11.2 {\n  execsql {SELECT typeof(00000009223372036854775807)}\n} {integer}\ndo_test expr-11.3 {\n  execsql {SELECT typeof(+9223372036854775807)}\n} {integer}\ndo_test expr-11.4 {\n  execsql {SELECT typeof(+000000009223372036854775807)}\n} {integer}\ndo_test expr-11.5 {\n  execsql {SELECT typeof(9223372036854775808)}\n} {real}\ndo_test expr-11.6 {\n  execsql {SELECT typeof(00000009223372036854775808)}\n} {real}\ndo_test expr-11.7 {\n  execsql {SELECT typeof(+9223372036854775808)}\n} {real}\ndo_test expr-11.8 {\n  execsql {SELECT typeof(+0000009223372036854775808)}\n} {real}\ndo_test expr-11.11 {\n  execsql {SELECT typeof(-9223372036854775808)}\n} {integer}\ndo_test expr-11.12 {\n  execsql {SELECT typeof(-00000009223372036854775808)}\n} {integer}\nifcapable floatingpoint {\n  do_test expr-11.13 {\n    execsql {SELECT typeof(-9223372036854775809)}\n  } {real}\n  do_test expr-11.14 {\n    execsql {SELECT typeof(-00000009223372036854775809)}\n  } {real}\n}\n\n# These two statements used to leak memory (because of missing %destructor\n# directives in parse.y).\ndo_test expr-12.1 {\n  catchsql {\n    SELECT (CASE a>4 THEN 1 ELSE 0 END) FROM test1;\n  }\n} {1 {near \"THEN\": syntax error}}\ndo_test expr-12.2 {\n  catchsql {\n    SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;\n  }\n} {1 {near \")\": syntax error}}\n\nifcapable floatingpoint {\n  do_realnum_test expr-13.1 {\n    execsql {\n      SELECT 12345678901234567890;\n    }\n  } {1.23456789012346e+19}\n}\n\n# Implicit String->Integer conversion is used when possible.\n#\nif {[working_64bit_int]} {\n  do_test expr-13.2 {\n    execsql {\n      SELECT 0+'9223372036854775807'\n    }\n  } {9223372036854775807}\n  do_test expr-13.3 {\n    execsql {\n      SELECT '9223372036854775807'+0\n    }\n  } {9223372036854775807}\n}\n\n# If the value is too large, use String->Float conversion.\n#\nifcapable floatingpoint {\n  do_realnum_test expr-13.4 {\n    execsql {\n      SELECT 0+'9223372036854775808'\n    }\n  } {9.22337203685478e+18}\n  do_realnum_test expr-13.5 {\n    execsql {\n      SELECT '9223372036854775808'+0\n    }\n  } {9.22337203685478e+18}\n}\n\n# Use String->float conversion if the value is explicitly a floating\n# point value.\n#\ndo_realnum_test expr-13.6 {\n  execsql {\n    SELECT 0+'9223372036854775807.0'\n  }\n} {9.22337203685478e+18}\ndo_realnum_test expr-13.7 {\n  execsql {\n    SELECT '9223372036854775807.0'+0\n  }\n} {9.22337203685478e+18}\n\ndo_execsql_test expr-13.8 {\n  SELECT \"\" <= '';\n} {1}\ndo_execsql_test expr-13.9 {\n  SELECT '' <= \"\";\n} {1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/extension01.test",
    "content": "# 2014-06-16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests for various small extensions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix extension01\n\nload_static_extension db fileio\ndo_test 1.0 {\n  forcedelete file1.txt\n  set out [open ./file1.txt wb]\n  puts -nonewline $out \"This is a text file without a line ending\"\n  close $out\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t1 VALUES(1, readfile('./file1.txt'));\n    SELECT * FROM t1;\n  }\n} {1 {This is a text file without a line ending}}\ndo_test 1.1 {\n  forcedelete file2.txt\n  db nullvalue nil\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));\n    SELECT a, b, typeof(b) FROM t1;\n  }\n} {2 nil null 3 nil null}\n\ndo_test 1.2 {\n  db eval {\n    SELECT writefile('./file2.txt', 'A second test line');\n  }\n} {18}\ndo_test 1.3 {\n  set in [open ./file2.txt rb]\n  set x [read $in]\n  close $in\n  list $x [file size file2.txt]\n} {{A second test line} 18}\n\ndo_test 1.4 {\n  db eval {\n    SELECT writefile('./file2.txt', NULL);\n  }\n} {0}\ndo_test 1.5 {\n  file size ./file2.txt\n} {0}\n\ndo_test 1.6 {\n  if {$::tcl_platform(platform)==\"unix\"} {\n    file attributes ./file2.txt -permissions r--r--r--\n  } else {\n    file attributes ./file2.txt -readonly 1\n  }\n  db eval {\n    SELECT writefile('./file2.txt', 'Another test');\n  }\n} {nil}\ndo_test 1.7 {\n  if {$::tcl_platform(platform)==\"unix\"} {\n    file attributes ./file2.txt -permissions rw-r--r--\n  } else {\n    file attributes ./file2.txt -readonly 0\n  }\n  db eval {\n    SELECT writefile(NULL, 'Another test');\n  }\n} {nil}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/extraquick.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs most of the tests run by veryquick.test except for those\n# that take a long time.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nrun_test_suite extraquick\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fallocate.test",
    "content": "# 2010 July 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nfile_control_chunksize_test db main [expr 1024*1024]\n\ndo_test fallocate-1.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(a, b);\n  }\n  file size test.db\n} [expr 1*1024*1024]\n\ndo_test fallocate-1.2 {\n  execsql { INSERT INTO t1 VALUES(1, zeroblob(1024*900)) }\n  file size test.db\n} [expr 1*1024*1024]\n\ndo_test fallocate-1.3 {\n  execsql { INSERT INTO t1 VALUES(2, zeroblob(1024*900)) }\n  file size test.db\n} [expr 2*1024*1024]\n\ndo_test fallocate-1.4 {\n  execsql { DELETE FROM t1 WHERE a = 1 }\n  file size test.db\n} [expr 1*1024*1024]\n\ndo_test fallocate-1.5 {\n  execsql { DELETE FROM t1 WHERE a = 2 }\n  file size test.db\n} [expr 1*1024*1024]\n\ndo_test fallocate-1.6 {\n  execsql { PRAGMA freelist_count }\n} {0}\n\n# Start a write-transaction and read the \"database file size\" field from\n# the journal file. This field should be set to the number of pages in\n# the database file based on the size of the file on disk, not the actual\n# logical size of the database within the file.\n#\n# We need to check this to verify that if in the unlikely event a rollback\n# causes a database file to grow, the database grows to its previous size\n# on disk, not to the minimum size required to hold the database image.\n#\ndo_test fallocate-1.7 {\n  execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }\n  if {[permutation] != \"inmemory_journal\"\n   && [permutation] != \"atomic-batch-write\"\n  } {\n    hexio_get_int [hexio_read test.db-journal 16 4]\n  } else {\n    set {} 1024\n  }\n} {1024}\ndo_test fallocate-1.8 { execsql { COMMIT } } {}\n\n\n#-------------------------------------------------------------------------\n# The following tests - fallocate-2.* - test that things work in WAL\n# mode as well.\n#\nset skipwaltests [expr {\n  [permutation]==\"journaltest\" || [permutation]==\"inmemory_journal\"\n}]\nifcapable !wal { set skipwaltests 1 }\n\nif {!$skipwaltests} {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  file_control_chunksize_test db main [expr 32*1024]\n  \n  do_test fallocate-2.1 {\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(a, b);\n    }\n    file size test.db\n  } [expr 32*1024]\n  \n  do_test fallocate-2.2 {\n    execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }\n    execsql { PRAGMA wal_checkpoint }\n    file size test.db\n  } [expr 64*1024]\n  \n  do_test fallocate-2.3 {\n    execsql { DELETE FROM t1 }\n    execsql { VACUUM }\n    file size test.db\n  } [expr 64*1024]\n  \n  do_test fallocate-2.4 {\n    execsql { PRAGMA wal_checkpoint }\n    file size test.db\n  } [expr 32*1024]\n  \n  do_test fallocate-2.5 {\n    execsql { \n      INSERT INTO t1 VALUES(2, randomblob(35*1024));\n      PRAGMA wal_checkpoint;\n      INSERT INTO t1 VALUES(3, randomblob(128));\n      DELETE FROM t1 WHERE a = 2;\n      VACUUM;\n    }\n    file size test.db\n  } [expr 64*1024]\n  \n  do_test fallocate-2.6 {\n    sqlite3 db2 test.db\n    execsql { BEGIN ; SELECT count(a) FROM t1 } db2\n    execsql {  \n      INSERT INTO t1 VALUES(4, randomblob(128));\n      PRAGMA wal_checkpoint;\n    }\n    file size test.db\n  } [expr 64*1024]\n  \n  do_test fallocate-2.7 {\n    execsql { SELECT count(b) FROM t1 } db2\n  } {1}\n  \n  do_test fallocate-2.8 {\n    execsql { COMMIT } db2\n    execsql { PRAGMA wal_checkpoint }\n    file size test.db\n  } [expr 32*1024]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/filectrl.test",
    "content": "# 2008 Jan 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: filectrl.test,v 1.2 2008/11/21 00:10:35 aswift Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\ndo_test filectrl-1.1 {\n  file_control_test db\n} {}\ndo_test filectrl-1.2 {\n  db eval {CREATE TEMP TABLE x(y);}\n  file_control_test db\n} {}\ndo_test filectrl-1.3 {\n  db close\n  sqlite3 db :memory:\n  file_control_test db\n} {}\ndo_test filectrl-1.4 {\n  sqlite3 db test.db\n  file_control_lasterrno_test db\n} {}\ndo_test filectrl-1.5 {\n  db close\n  sqlite3 db test_control_lockproxy.db\n  file_control_lockproxy_test db [get_pwd]\n} {}\ndo_test filectrl-1.6 {\n  sqlite3 db test.db\n  set fn [file_control_tempfilename db]\n  set fn\n} {/etilqs_/}\ndb close\nforcedelete .test_control_lockproxy.db-conch test.proxy\nforcedelete test.db test2.db\n\nif {$tcl_platform(platform)==\"windows\"} {\n  do_test filectrl-2.1 {\n    sqlite3 db test2.db\n    set size [file size test2.db]\n    set handle [file_control_win32_get_handle db]\n    db close\n    forcedelete test2.db\n    list $size $handle [expr {$handle != 0}]\n  } {/^0 \\{0 [0-9A-Fa-f]+\\} 1$/}\n\n  do_test filectrl-2.2 {\n    sqlite3 db test2.db\n    execsql {\n      CREATE TABLE t1(x);\n      INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));\n    }\n    set size [file size test2.db]\n    set handle [file_control_win32_get_handle db]\n    db close\n    forcedelete test2.db\n    list $size $handle [expr {$handle != 0}]\n  } {/^1\\d+ \\{0 [0-9A-Fa-f]+\\} 1$/}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/filefmt.test",
    "content": "# 2007 April 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify database file format.\n#\n# $Id: filefmt.test,v 1.3 2009/06/18 11:34:43 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\ndb close\nforcedelete test.db test.db-journal\n\n# Database begins with valid 16-byte header string.\n#\ndo_test filefmt-1.1 {\n  sqlite3 db test.db\n  db eval {CREATE TABLE t1(x)}\n  db close\n  hexio_read test.db 0 16\n} {53514C69746520666F726D6174203300}\n\n# If the 16-byte header is changed, the file will not open\n#\ndo_test filefmt-1.2 {\n  hexio_write test.db 0 54\n  set x [catch {sqlite3 db test.db} err]\n  lappend x $err\n} {0 {}}\ndo_test filefmt-1.3 {\n  catchsql {\n    SELECT count(*) FROM sqlite_master\n  }\n} {1 {file is not a database}}\ndo_test filefmt-1.4 {\n  db close\n  hexio_write test.db 0 53\n  sqlite3 db test.db\n  catchsql {\n    SELECT count(*) FROM sqlite_master\n  }\n} {0 1}\n\n# The page-size is stored at offset 16\n#\nifcapable pager_pragmas {\n  foreach pagesize {512 1024 2048 4096 8192 16384 32768} {\n     if {[info exists SQLITE_MAX_PAGE_SIZE]\n          && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue\n     do_test filefmt-1.5.$pagesize.1 {\n       db close\n       forcedelete test.db\n       sqlite3 db test.db\n       db eval \"PRAGMA auto_vacuum=OFF\"\n       db eval \"PRAGMA page_size=$pagesize\"\n       db eval {CREATE TABLE t1(x)}\n       file size test.db\n     } [expr $pagesize*2]\n     do_test filefmt-1.5.$pagesize.2 {\n       hexio_get_int [hexio_read test.db 16 2]\n     } $pagesize\n  }\n}\n\n# The page-size must be a power of 2\n#\ndo_test filefmt-1.6 {\n  db close\n  hexio_write test.db 16 [hexio_render_int16 1025]\n  sqlite3 db test.db\n  catchsql {\n     SELECT count(*) FROM sqlite_master\n  }\n} {1 {file is not a database}}\n\n\n# The page-size must be at least 512 bytes\n#\ndo_test filefmt-1.7 {\n  db close\n  hexio_write test.db 16 [hexio_render_int16 256]\n  sqlite3 db test.db\n  catchsql {\n     SELECT count(*) FROM sqlite_master\n  }\n} {1 {file is not a database}}\n\n# Usable space per page (page-size minus unused space per page)\n# must be at least 480 bytes\n#\nifcapable pager_pragmas {\n  do_test filefmt-1.8 {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval {PRAGMA page_size=512; CREATE TABLE t1(x)}\n    db close\n    hexio_write test.db 20 21\n    sqlite3 db test.db\n    catchsql {\n       SELECT count(*) FROM sqlite_master\n    }\n  } {1 {file is not a database}}\n}\n\n#-------------------------------------------------------------------------\n# The following block of tests - filefmt-2.* - test that versions 3.7.0\n# and later can read and write databases that have been modified or created\n# by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores\n# the size of the database in the database file header, whereas 3.6.23.1\n# always derives this from the size of the file.\n#\ndb close\nforcedelete test.db\n\nset a_string_counter 1\nproc a_string {n} {\n  incr ::a_string_counter\n  string range [string repeat \"${::a_string_counter}.\" $n] 1 $n\n}\nsqlite3 db test.db\ndb func a_string a_string\n\ndo_execsql_test filefmt-2.1.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA auto_vacuum = 0;\n  CREATE TABLE t1(a);\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1 VALUES(a_string(3000));\n  CREATE TABLE t2(a);\n  INSERT INTO t2 VALUES(1);\n} {}\nif {![nonzero_reserved_bytes]} {\n  do_test filefmt-2.1.2 {\n    hexio_read test.db 28 4\n  } {00000009}\n}\n\ndo_test filefmt-2.1.3 {\n  sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }\n} {}\n\ndo_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {}\nintegrity_check filefmt-2.1.5\ndo_test         filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndb func a_string a_string\n\ndo_execsql_test filefmt-2.2.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA auto_vacuum = 0;\n  CREATE TABLE t1(a);\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1 VALUES(a_string(3000));\n  CREATE TABLE t2(a);\n  INSERT INTO t2 VALUES(1);\n} {}\nif {![nonzero_reserved_bytes]} {\n  do_test filefmt-2.2.2 {\n    hexio_read test.db 28 4\n  } {00000009}\n}\n\ndo_test filefmt-2.2.3 {\n  sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }\n} {}\n\ndo_execsql_test filefmt-2.2.4 { \n  PRAGMA integrity_check;\n  BEGIN;\n    INSERT INTO t2 VALUES(2);\n    SAVEPOINT a;\n      INSERT INTO t2 VALUES(3);\n    ROLLBACK TO a;\n} {ok}\n\nintegrity_check filefmt-2.2.5\ndo_execsql_test filefmt-2.2.6 { COMMIT } {}\ndb close\nsqlite3 db test.db\nintegrity_check filefmt-2.2.7\n\n#--------------------------------------------------------------------------\n# Check that ticket 89b8c9ac54 is fixed. Before the fix, the SELECT \n# statement would return SQLITE_CORRUPT. The database file was not actually\n# corrupted, but SQLite was reporting that it was.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test filefmt-3.1 {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE t1(a, b);\n} {}\ndo_test filefmt-3.2 { \n  sql36231 { DROP TABLE t1 } \n} {}\ndo_execsql_test filefmt-3.3 {\n  SELECT * FROM sqlite_master;\n  PRAGMA integrity_check;\n} {ok}\n\nreset_db\ndo_execsql_test filefmt-4.1 {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE t1(x, y);\n  CREATE TABLE t2(x, y);\n\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100), randomblob(100));\n\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM t1;\n}\n\ndo_test filefmt-4.2 { \n  sql36231 { INSERT INTO t2 SELECT * FROM t1 }\n} {}\n\ndo_test filefmt-4.3 { \n  forcedelete bak.db\n  db backup bak.db\n} {}\n\ndo_test filefmt-4.4 { \n  sqlite3 db2 bak.db\n  db2 eval { PRAGMA integrity_check }\n} {ok}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey1.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fkey1\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\n\n# Create a table and some data to work with.\n#\ndo_test fkey1-1.0 {\n  execsql {\n    CREATE TABLE t1(\n      a INTEGER PRIMARY KEY,\n      b INTEGER\n           REFERENCES t1 ON DELETE CASCADE\n           REFERENCES t2,\n      c TEXT,\n      FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE\n    );\n  }\n} {}\ndo_test fkey1-1.1 {\n  execsql {\n    CREATE TABLE t2(\n      x INTEGER PRIMARY KEY,\n      y TEXT\n    );\n  }\n} {}\ndo_test fkey1-1.2 {\n  execsql {\n    CREATE TABLE t3(\n      a INTEGER REFERENCES t2,\n      b INTEGER REFERENCES t1,\n      FOREIGN KEY (a,b) REFERENCES t2(x,y)\n    );\n  }\n} {}\n\ndo_test fkey1-2.1 {\n  execsql {\n    CREATE TABLE t4(a integer primary key);\n    CREATE TABLE t5(x references t4);\n    CREATE TABLE t6(x references t4);\n    CREATE TABLE t7(x references t4);\n    CREATE TABLE t8(x references t4);\n    CREATE TABLE t9(x references t4);\n    CREATE TABLE t10(x references t4);\n    DROP TABLE t7;\n    DROP TABLE t9;\n    DROP TABLE t5;\n    DROP TABLE t8;\n    DROP TABLE t6;\n    DROP TABLE t10;\n  }\n} {}\n\ndo_test fkey1-3.1 {\n  execsql {\n    CREATE TABLE t5(a PRIMARY KEY, b, c);\n    CREATE TABLE t6(\n      d REFERENCES t5,\n      e REFERENCES t5(c)\n    );\n    PRAGMA foreign_key_list(t6);\n  }\n} [concat                                         \\\n  {0 0 t5 e c {NO ACTION} {NO ACTION} NONE}       \\\n  {1 0 t5 d {} {NO ACTION} {NO ACTION} NONE}      \\\n]\ndo_test fkey1-3.2 {\n  execsql {\n    CREATE TABLE t7(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5(a, b)\n    );\n    PRAGMA foreign_key_list(t7);\n  }\n} [concat                                   \\\n  {0 0 t5 d a {NO ACTION} {NO ACTION} NONE} \\\n  {0 1 t5 e b {NO ACTION} {NO ACTION} NONE} \\\n]\ndo_test fkey1-3.3 {\n  execsql {\n    CREATE TABLE t8(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET NULL\n    );\n    PRAGMA foreign_key_list(t8);\n  }\n} [concat                        \\\n  {0 0 t5 d {} {SET NULL} CASCADE NONE} \\\n  {0 1 t5 e {} {SET NULL} CASCADE NONE} \\\n]\ndo_test fkey1-3.4 {\n  execsql {\n    CREATE TABLE t9(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET DEFAULT\n    );\n    PRAGMA foreign_key_list(t9);\n  }\n} [concat                        \\\n  {0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \\\n  {0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \\\n]\ndo_test fkey1-3.5 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 0 0}\n\n# Stress the dequoting logic.  The first test is not so bad.\ndo_execsql_test fkey1-4.0 {\n  PRAGMA foreign_keys=ON;\n  CREATE TABLE \"xx1\"(\"xx2\" TEXT PRIMARY KEY, \"xx3\" TEXT);\n  INSERT INTO \"xx1\"(\"xx2\",\"xx3\") VALUES('abc','def');\n  CREATE TABLE \"xx4\"(\"xx5\" TEXT REFERENCES \"xx1\" ON DELETE CASCADE);\n  INSERT INTO \"xx4\"(\"xx5\") VALUES('abc');\n  INSERT INTO \"xx1\"(\"xx2\",\"xx3\") VALUES('uvw','xyz');\n  SELECT 1, \"xx5\" FROM \"xx4\";\n  DELETE FROM \"xx1\";\n  SELECT 2, \"xx5\" FROM \"xx4\";\n} {1 abc}\n\n# This case is identical to the previous except the \"xx\" in each name\n# is changed to a single escaped double-quote character.\ndo_execsql_test fkey1-4.1 {\n  PRAGMA foreign_keys=ON;\n  CREATE TABLE \"\"\"1\"(\"\"\"2\" TEXT PRIMARY KEY, \"\"\"3\" TEXT);\n  INSERT INTO \"\"\"1\"(\"\"\"2\",\"\"\"3\") VALUES('abc','def');\n  CREATE TABLE \"\"\"4\"(\"\"\"5\" TEXT REFERENCES \"\"\"1\" ON DELETE CASCADE);\n  INSERT INTO \"\"\"4\"(\"\"\"5\") VALUES('abc');\n  INSERT INTO \"\"\"1\"(\"\"\"2\",\"\"\"3\") VALUES('uvw','xyz');\n  SELECT 1, \"\"\"5\" FROM \"\"\"4\";\n  DELETE FROM \"\"\"1\";\n  SELECT 2, \"\"\"5\" FROM \"\"\"4\";\n} {1 abc}\ndo_execsql_test fkey1-4.2 {\n  PRAGMA table_info=\"\"\"1\";\n} {0 {\"2} TEXT 0 {} 1 1 {\"3} TEXT 0 {} 0}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test fkey1-5.1 {\n  CREATE TABLE t11(\n    x INTEGER PRIMARY KEY, \n    parent REFERENCES t11 ON DELETE CASCADE\n  );\n  INSERT INTO t11 VALUES (1, NULL), (2, 1), (3, 2);\n} {}\n\n# The REPLACE part of this statement deletes the row (2, 1). Then the \n# DELETE CASCADE caused by deleting that row removes the (3, 2) row. Which\n# would have been the parent of the new row being inserted. Causing an\n# FK violation.\n#\ndo_catchsql_test fkey1-5.2 {\n  INSERT OR REPLACE INTO t11 VALUES (2, 3);\n} {1 {FOREIGN KEY constraint failed}}\n\n# A similar test to the above.\ndo_execsql_test fkey1-5.3 {\n  CREATE TABLE Foo (\n    Id INTEGER PRIMARY KEY, \n    ParentId INTEGER REFERENCES Foo(Id) ON DELETE CASCADE, C1\n  );\n  INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (1, null, 'A');\n  INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 1, 'A-2-1');\n  INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (3, 2, 'A-3-2');\n  INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (4, 3, 'A-4-3');\n}\ndo_catchsql_test fkey1-5.4 {\n  INSERT OR REPLACE INTO Foo(Id, ParentId, C1) VALUES (2, 3, 'A-2-3');\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Check that foreign key processing is not fooled by partial indexes\n# on the parent table.\n#\ndo_execsql_test 6.0 {\n  CREATE TABLE p1(x, y);\n  CREATE UNIQUE INDEX p1x ON p1(x) WHERE y<2;\n  INSERT INTO p1 VALUES(1, 1);\n  CREATE TABLE c1(a REFERENCES p1(x));\n}\n\ndo_catchsql_test 6.1 {\n  INSERT INTO c1 VALUES(1);\n} {1 {foreign key mismatch - \"c1\" referencing \"p1\"}}\n\ndo_execsql_test 6.2 {\n  CREATE UNIQUE INDEX p1x2 ON p1(x);\n  INSERT INTO c1 VALUES(1);\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey2.test",
    "content": "# 2009 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey||!trigger} {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test structure:\n#\n# fkey2-1.*: Simple tests to check that immediate and deferred foreign key \n#            constraints work when not inside a transaction.\n#            \n# fkey2-2.*: Tests to verify that deferred foreign keys work inside\n#            explicit transactions (i.e that processing really is deferred).\n#\n# fkey2-3.*: Tests that a statement transaction is rolled back if an\n#            immediate foreign key constraint is violated.\n#\n# fkey2-4.*: Test that FK actions may recurse even when recursive triggers\n#            are disabled.\n#\n# fkey2-5.*: Check that if foreign-keys are enabled, it is not possible\n#            to write to an FK column using the incremental blob API.\n#\n# fkey2-6.*: Test that FK processing is automatically disabled when \n#            running VACUUM.\n#\n# fkey2-7.*: Test using an IPK as the key in the child (referencing) table.\n#\n# fkey2-8.*: Test that enabling/disabling foreign key support while a \n#            transaction is active is not possible.\n#\n# fkey2-9.*: Test SET DEFAULT actions.\n#\n# fkey2-10.*: Test errors.\n#\n# fkey2-11.*: Test CASCADE actions.\n#\n# fkey2-12.*: Test RESTRICT actions.\n#\n# fkey2-13.*: Test that FK processing is performed when a row is REPLACED by\n#             an UPDATE or INSERT statement.\n#\n# fkey2-14.*: Test the ALTER TABLE and DROP TABLE commands.\n#\n# fkey2-15.*: Test that if there are no (known) outstanding foreign key \n#             constraint violations in the database, inserting into a parent\n#             table or deleting from a child table does not cause SQLite\n#             to check if this has repaired an outstanding violation.\n#\n# fkey2-16.*: Test that rows that refer to themselves may be inserted, \n#             updated and deleted.\n#\n# fkey2-17.*: Test that the \"count_changes\" pragma does not interfere with\n#             FK constraint processing.\n# \n# fkey2-18.*: Test that the authorization callback is invoked when processing\n#             FK constraints.\n#\n# fkey2-20.*: Test that ON CONFLICT clauses specified as part of statements\n#             do not affect the operation of FK constraints.\n#\n# fkey2-genfkey.*: Tests that were used with the shell tool .genfkey\n#            command. Recycled to test the built-in implementation.\n#\n# fkey2-dd08e5.*:  Tests to verify that ticket dd08e5a988d00decc4a543daa8d\n#                  has been fixed.\n#\n\n\nexecsql { PRAGMA foreign_keys = on }\n\nset FkeySimpleSchema {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  CREATE TABLE t2(c REFERENCES t1(a) /D/ , d);\n\n  CREATE TABLE t3(a PRIMARY KEY, b);\n  CREATE TABLE t4(c REFERENCES t3 /D/, d);\n\n  CREATE TABLE t7(a, b INTEGER PRIMARY KEY);\n  CREATE TABLE t8(c REFERENCES t7 /D/, d);\n\n  CREATE TABLE t9(a REFERENCES nosuchtable, b);\n  CREATE TABLE t10(a REFERENCES t9(c) /D/, b);\n}\n\n\nset FkeySimpleTests {\n  1.1  \"INSERT INTO t2 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  1.2  \"INSERT INTO t1 VALUES(1, 2)\"      {0 {}}\n  1.3  \"INSERT INTO t2 VALUES(1, 3)\"      {0 {}}\n  1.4  \"INSERT INTO t2 VALUES(2, 4)\"      {1 {FOREIGN KEY constraint failed}}\n  1.5  \"INSERT INTO t2 VALUES(NULL, 4)\"   {0 {}}\n  1.6  \"UPDATE t2 SET c=2 WHERE d=4\"      {1 {FOREIGN KEY constraint failed}}\n  1.7  \"UPDATE t2 SET c=1 WHERE d=4\"      {0 {}}\n  1.9  \"UPDATE t2 SET c=1 WHERE d=4\"      {0 {}}\n  1.10 \"UPDATE t2 SET c=NULL WHERE d=4\"   {0 {}}\n  1.11 \"DELETE FROM t1 WHERE a=1\"         {1 {FOREIGN KEY constraint failed}}\n  1.12 \"UPDATE t1 SET a = 2\"              {1 {FOREIGN KEY constraint failed}}\n  1.13 \"UPDATE t1 SET a = 1\"              {0 {}}\n\n  2.1  \"INSERT INTO t4 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  2.2  \"INSERT INTO t3 VALUES(1, 2)\"      {0 {}}\n  2.3  \"INSERT INTO t4 VALUES(1, 3)\"      {0 {}}\n\n  4.1  \"INSERT INTO t8 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  4.2  \"INSERT INTO t7 VALUES(2, 1)\"      {0 {}}\n  4.3  \"INSERT INTO t8 VALUES(1, 3)\"      {0 {}}\n  4.4  \"INSERT INTO t8 VALUES(2, 4)\"      {1 {FOREIGN KEY constraint failed}}\n  4.5  \"INSERT INTO t8 VALUES(NULL, 4)\"   {0 {}}\n  4.6  \"UPDATE t8 SET c=2 WHERE d=4\"      {1 {FOREIGN KEY constraint failed}}\n  4.7  \"UPDATE t8 SET c=1 WHERE d=4\"      {0 {}}\n  4.9  \"UPDATE t8 SET c=1 WHERE d=4\"      {0 {}}\n  4.10 \"UPDATE t8 SET c=NULL WHERE d=4\"   {0 {}}\n  4.11 \"DELETE FROM t7 WHERE b=1\"         {1 {FOREIGN KEY constraint failed}}\n  4.12 \"UPDATE t7 SET b = 2\"              {1 {FOREIGN KEY constraint failed}}\n  4.13 \"UPDATE t7 SET b = 1\"              {0 {}}\n  4.14 \"INSERT INTO t8 VALUES('a', 'b')\"  {1 {FOREIGN KEY constraint failed}}\n  4.15 \"UPDATE t7 SET b = 5\"              {1 {FOREIGN KEY constraint failed}}\n  4.16 \"UPDATE t7 SET rowid = 5\"          {1 {FOREIGN KEY constraint failed}}\n  4.17 \"UPDATE t7 SET a = 10\"             {0 {}}\n\n  5.1  \"INSERT INTO t9 VALUES(1, 3)\"      {1 {no such table: main.nosuchtable}}\n  5.2  \"INSERT INTO t10 VALUES(1, 3)\"  \n                            {1 {foreign key mismatch - \"t10\" referencing \"t9\"}}\n}\n\ndo_test fkey2-1.1.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  do_test fkey2-1.1.$tn.1 { catchsql $zSql } $res\n  do_test fkey2-1.1.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test fkey2-1.1.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test fkey2-1.1.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test fkey2-1.1.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test fkey2-1.1.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test fkey2-1.1.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\ndrop_all_tables\n\ndo_test fkey2-1.2.0 {\n  execsql [string map {/D/ {DEFERRABLE INITIALLY DEFERRED}} $FkeySimpleSchema]\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  do_test fkey2-1.2.$tn { catchsql $zSql } $res\n  do_test fkey2-1.2.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test fkey2-1.2.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test fkey2-1.2.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test fkey2-1.2.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test fkey2-1.2.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test fkey2-1.2.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\ndrop_all_tables\n\ndo_test fkey2-1.3.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n  execsql { PRAGMA count_changes = 1 }\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  if {$res == \"0 {}\"} { set res {0 1} }\n  do_test fkey2-1.3.$tn { catchsql $zSql } $res\n  do_test fkey2-1.3.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test fkey2-1.3.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test fkey2-1.3.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test fkey2-1.3.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test fkey2-1.3.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test fkey2-1.3.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\nexecsql { PRAGMA count_changes = 0 }\ndrop_all_tables\n\ndo_test fkey2-1.4.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n  execsql { PRAGMA count_changes = 1 }\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  if {$res == \"0 {}\"} { set res {0 1} }\n  execsql BEGIN\n  do_test fkey2-1.4.$tn { catchsql $zSql } $res\n  execsql COMMIT\n}\nexecsql { PRAGMA count_changes = 0 }\ndrop_all_tables\n\n# Special test: When the parent key is an IPK, make sure the affinity of\n# the IPK is not applied to the child key value before it is inserted\n# into the child table.\ndo_test fkey2-1.5.1 {\n  execsql {\n    CREATE TABLE i(i INTEGER PRIMARY KEY);\n    CREATE TABLE j(j REFERENCES i);\n    INSERT INTO i VALUES(35);\n    INSERT INTO j VALUES('35.0');\n    SELECT j, typeof(j) FROM j;\n  }\n} {35.0 text}\ndo_test fkey2-1.5.2 {\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Same test using a regular primary key with integer affinity.\ndrop_all_tables\ndo_test fkey2-1.6.1 {\n  execsql {\n    CREATE TABLE i(i INT UNIQUE);\n    CREATE TABLE j(j REFERENCES i(i));\n    INSERT INTO i VALUES('35.0');\n    INSERT INTO j VALUES('35.0');\n    SELECT j, typeof(j) FROM j;\n    SELECT i, typeof(i) FROM i;\n  }\n} {35.0 text 35 integer}\ndo_test fkey2-1.6.2 {\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Use a collation sequence on the parent key.\ndrop_all_tables\ndo_test fkey2-1.7.1 {\n  execsql {\n    CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY);\n    CREATE TABLE j(j TEXT COLLATE binary REFERENCES i(i));\n    INSERT INTO i VALUES('SQLite');\n    INSERT INTO j VALUES('sqlite');\n  }\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Use the parent key collation even if it is default and the child key\n# has an explicit value.\ndrop_all_tables\ndo_test fkey2-1.7.2 {\n  execsql {\n    CREATE TABLE i(i TEXT PRIMARY KEY);        -- Colseq is \"BINARY\"\n    CREATE TABLE j(j TEXT COLLATE nocase REFERENCES i(i));\n    INSERT INTO i VALUES('SQLite');\n  }\n  catchsql { INSERT INTO j VALUES('sqlite') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-1.7.3 {\n  execsql {\n    INSERT INTO i VALUES('sqlite');\n    INSERT INTO j VALUES('sqlite');\n    DELETE FROM i WHERE i = 'SQLite';\n  }\n  catchsql { DELETE FROM i WHERE i = 'sqlite' }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# This section (test cases fkey2-2.*) contains tests to check that the\n# deferred foreign key constraint logic works.\n#\nproc fkey2-2-test {tn nocommit sql {res {}}} {\n  if {$res eq \"FKV\"} {\n    set expected {1 {FOREIGN KEY constraint failed}}\n  } else {\n    set expected [list 0 $res]\n  }\n  do_test fkey2-2.$tn [list catchsql $sql] $expected\n  if {$nocommit} {\n    do_test fkey2-2.${tn}c {\n      catchsql COMMIT\n    } {1 {FOREIGN KEY constraint failed}}\n  }\n}\n\nfkey2-2-test 1 0 {\n  CREATE TABLE node(\n    nodeid PRIMARY KEY,\n    parent REFERENCES node DEFERRABLE INITIALLY DEFERRED\n  );\n  CREATE TABLE leaf(\n    cellid PRIMARY KEY,\n    parent REFERENCES node DEFERRABLE INITIALLY DEFERRED\n  );\n}\n\nfkey2-2-test 1  0 \"INSERT INTO node VALUES(1, 0)\"       FKV\nfkey2-2-test 2  0 \"BEGIN\"\nfkey2-2-test 3  1   \"INSERT INTO node VALUES(1, 0)\"\nfkey2-2-test 4  0   \"UPDATE node SET parent = NULL\"\nfkey2-2-test 5  0 \"COMMIT\"\nfkey2-2-test 6  0 \"SELECT * FROM node\" {1 {}}\n\nfkey2-2-test 7  0 \"BEGIN\"\nfkey2-2-test 8  1   \"INSERT INTO leaf VALUES('a', 2)\"\nfkey2-2-test 9  1   \"INSERT INTO node VALUES(2, 0)\"\nfkey2-2-test 10 0   \"UPDATE node SET parent = 1 WHERE nodeid = 2\"\nfkey2-2-test 11 0 \"COMMIT\"\nfkey2-2-test 12 0 \"SELECT * FROM node\" {1 {} 2 1}\nfkey2-2-test 13 0 \"SELECT * FROM leaf\" {a 2}\n\nfkey2-2-test 14 0 \"BEGIN\"\nfkey2-2-test 15 1   \"DELETE FROM node WHERE nodeid = 2\"\nfkey2-2-test 16 0   \"INSERT INTO node VALUES(2, NULL)\"\nfkey2-2-test 17 0 \"COMMIT\"\nfkey2-2-test 18 0 \"SELECT * FROM node\" {1 {} 2 {}}\nfkey2-2-test 19 0 \"SELECT * FROM leaf\" {a 2}\n\nfkey2-2-test 20 0 \"BEGIN\"\nfkey2-2-test 21 0   \"INSERT INTO leaf VALUES('b', 1)\"\nfkey2-2-test 22 0   \"SAVEPOINT save\"\nfkey2-2-test 23 0     \"DELETE FROM node WHERE nodeid = 1\"\nfkey2-2-test 24 0   \"ROLLBACK TO save\"\nfkey2-2-test 25 0 \"COMMIT\"\nfkey2-2-test 26 0 \"SELECT * FROM node\" {1 {} 2 {}}\nfkey2-2-test 27 0 \"SELECT * FROM leaf\" {a 2 b 1}\n\nfkey2-2-test 28 0 \"BEGIN\"\nfkey2-2-test 29 0   \"INSERT INTO leaf VALUES('c', 1)\"\nfkey2-2-test 30 0   \"SAVEPOINT save\"\nfkey2-2-test 31 0     \"DELETE FROM node WHERE nodeid = 1\"\nfkey2-2-test 32 1   \"RELEASE save\"\nfkey2-2-test 33 1   \"DELETE FROM leaf WHERE cellid = 'b'\"\nfkey2-2-test 34 0   \"DELETE FROM leaf WHERE cellid = 'c'\"\nfkey2-2-test 35 0 \"COMMIT\"\nfkey2-2-test 36 0 \"SELECT * FROM node\" {2 {}} \nfkey2-2-test 37 0 \"SELECT * FROM leaf\" {a 2}\n\nfkey2-2-test 38 0 \"SAVEPOINT outer\"\nfkey2-2-test 39 1   \"INSERT INTO leaf VALUES('d', 3)\"\nfkey2-2-test 40 1 \"RELEASE outer\"    FKV\nfkey2-2-test 41 1   \"INSERT INTO leaf VALUES('e', 3)\"\nfkey2-2-test 42 0   \"INSERT INTO node VALUES(3, 2)\"\nfkey2-2-test 43 0 \"RELEASE outer\"\n\nfkey2-2-test 44 0 \"SAVEPOINT outer\"\nfkey2-2-test 45 1   \"DELETE FROM node WHERE nodeid=3\"\nfkey2-2-test 47 0   \"INSERT INTO node VALUES(3, 2)\"\nfkey2-2-test 48 0 \"ROLLBACK TO outer\"\nfkey2-2-test 49 0 \"RELEASE outer\"\n\nfkey2-2-test 50 0 \"SAVEPOINT outer\"\nfkey2-2-test 51 1   \"INSERT INTO leaf VALUES('f', 4)\"\nfkey2-2-test 52 1   \"SAVEPOINT inner\"\nfkey2-2-test 53 1     \"INSERT INTO leaf VALUES('g', 4)\"\nfkey2-2-test 54 1  \"RELEASE outer\"   FKV\nfkey2-2-test 55 1   \"ROLLBACK TO inner\"\nfkey2-2-test 56 0  \"COMMIT\"          FKV\nfkey2-2-test 57 0   \"INSERT INTO node VALUES(4, NULL)\"\nfkey2-2-test 58 0 \"RELEASE outer\"\nfkey2-2-test 59 0 \"SELECT * FROM node\" {2 {} 3 2 4 {}}\nfkey2-2-test 60 0 \"SELECT * FROM leaf\" {a 2 d 3 e 3 f 4}\n\n# The following set of tests check that if a statement that affects \n# multiple rows violates some foreign key constraints, then strikes a \n# constraint that causes the statement-transaction to be rolled back, \n# the deferred constraint counter is correctly reset to the value it \n# had before the statement-transaction was opened.\n#\nfkey2-2-test 61 0 \"BEGIN\"\nfkey2-2-test 62 0   \"DELETE FROM leaf\"\nfkey2-2-test 63 0   \"DELETE FROM node\"\nfkey2-2-test 64 1   \"INSERT INTO leaf VALUES('a', 1)\"\nfkey2-2-test 65 1   \"INSERT INTO leaf VALUES('b', 2)\"\nfkey2-2-test 66 1   \"INSERT INTO leaf VALUES('c', 1)\"\ndo_test fkey2-2-test-67 {\n  catchsql          \"INSERT INTO node SELECT parent, 3 FROM leaf\"\n} {1 {UNIQUE constraint failed: node.nodeid}}\nfkey2-2-test 68 0 \"COMMIT\"           FKV\nfkey2-2-test 69 1   \"INSERT INTO node VALUES(1, NULL)\"\nfkey2-2-test 70 0   \"INSERT INTO node VALUES(2, NULL)\"\nfkey2-2-test 71 0 \"COMMIT\"\n\nfkey2-2-test 72 0 \"BEGIN\"\nfkey2-2-test 73 1   \"DELETE FROM node\"\nfkey2-2-test 74 0   \"INSERT INTO node(nodeid) SELECT DISTINCT parent FROM leaf\"\nfkey2-2-test 75 0 \"COMMIT\"\n\n#-------------------------------------------------------------------------\n# Test cases fkey2-3.* test that a program that executes foreign key\n# actions (CASCADE, SET DEFAULT, SET NULL etc.) or tests FK constraints\n# opens a statement transaction if required.\n#\n# fkey2-3.1.*: Test UPDATE statements.\n# fkey2-3.2.*: Test DELETE statements.\n#\ndrop_all_tables\ndo_test fkey2-3.1.1 {\n  execsql {\n    CREATE TABLE ab(a PRIMARY KEY, b);\n    CREATE TABLE cd(\n      c PRIMARY KEY REFERENCES ab ON UPDATE CASCADE ON DELETE CASCADE, \n      d\n    );\n    CREATE TABLE ef(\n      e REFERENCES cd ON UPDATE CASCADE, \n      f, CHECK (e!=5)\n    );\n  }\n} {}\ndo_test fkey2-3.1.2 {\n  execsql {\n    INSERT INTO ab VALUES(1, 'b');\n    INSERT INTO cd VALUES(1, 'd');\n    INSERT INTO ef VALUES(1, 'e');\n  }\n} {}\ndo_test fkey2-3.1.3 {\n  catchsql { UPDATE ab SET a = 5 }\n} {1 {CHECK constraint failed: ef}}\ndo_test fkey2-3.1.4 {\n  execsql { SELECT * FROM ab }\n} {1 b}\ndo_test fkey2-3.1.4 {\n  execsql BEGIN;\n  catchsql { UPDATE ab SET a = 5 }\n} {1 {CHECK constraint failed: ef}}\ndo_test fkey2-3.1.5 {\n  execsql COMMIT;\n  execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }\n} {1 b 1 d 1 e}\n\ndo_test fkey2-3.2.1 {\n  execsql BEGIN;\n  catchsql { DELETE FROM ab }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-3.2.2 {\n  execsql COMMIT\n  execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }\n} {1 b 1 d 1 e}\n\n#-------------------------------------------------------------------------\n# Test cases fkey2-4.* test that recursive foreign key actions \n# (i.e. CASCADE) are allowed even if recursive triggers are disabled.\n#\ndrop_all_tables\ndo_test fkey2-4.1 {\n  execsql {\n    CREATE TABLE t1(\n      node PRIMARY KEY, \n      parent REFERENCES t1 ON DELETE CASCADE\n    );\n    CREATE TABLE t2(node PRIMARY KEY, parent);\n    CREATE TRIGGER t2t AFTER DELETE ON t2 BEGIN\n      DELETE FROM t2 WHERE parent = old.node;\n    END;\n    INSERT INTO t1 VALUES(1, NULL);\n    INSERT INTO t1 VALUES(2, 1);\n    INSERT INTO t1 VALUES(3, 1);\n    INSERT INTO t1 VALUES(4, 2);\n    INSERT INTO t1 VALUES(5, 2);\n    INSERT INTO t1 VALUES(6, 3);\n    INSERT INTO t1 VALUES(7, 3);\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n} {}\ndo_test fkey2-4.2 {\n  execsql { PRAGMA recursive_triggers = off }\n  execsql { \n    BEGIN;\n      DELETE FROM t1 WHERE node = 1;\n      SELECT node FROM t1;\n  }\n} {}\ndo_test fkey2-4.3 {\n  execsql { \n      DELETE FROM t2 WHERE node = 1;\n      SELECT node FROM t2;\n    ROLLBACK;\n  }\n} {4 5 6 7}\ndo_test fkey2-4.4 {\n  execsql { PRAGMA recursive_triggers = on }\n  execsql { \n    BEGIN;\n      DELETE FROM t1 WHERE node = 1;\n      SELECT node FROM t1;\n  }\n} {}\ndo_test fkey2-4.3 {\n  execsql { \n      DELETE FROM t2 WHERE node = 1;\n      SELECT node FROM t2;\n    ROLLBACK;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test cases fkey2-5.* verify that the incremental blob API may not\n# write to a foreign key column while foreign-keys are enabled.\n#\ndrop_all_tables\nifcapable incrblob {\n  do_test fkey2-5.1 {\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1(a));\n      INSERT INTO t1 VALUES('hello', 'world');\n      INSERT INTO t2 VALUES('key', 'hello');\n    }\n  } {}\n  do_test fkey2-5.2 {\n    set rc [catch { set fd [db incrblob t2 b 1] } msg]\n    list $rc $msg\n  } {1 {cannot open foreign key column for writing}}\n  do_test fkey2-5.3 {\n    set rc [catch { set fd [db incrblob -readonly t2 b 1] } msg]\n    close $fd\n    set rc\n  } {0}\n  do_test fkey2-5.4 {\n    execsql { PRAGMA foreign_keys = off }\n    set rc [catch { set fd [db incrblob t2 b 1] } msg]\n    close $fd\n    set rc\n  } {0}\n  do_test fkey2-5.5 {\n    execsql { PRAGMA foreign_keys = on }\n  } {}\n}\n\ndrop_all_tables\nifcapable vacuum {\n  do_test fkey2-6.1 {\n    execsql {\n      CREATE TABLE t1(a REFERENCES t2(c), b);\n      CREATE TABLE t2(c UNIQUE, b);\n      INSERT INTO t2 VALUES(1, 2);\n      INSERT INTO t1 VALUES(1, 2);\n      VACUUM;\n    }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Test that it is possible to use an INTEGER PRIMARY KEY as the child key\n# of a foreign constraint.\n# \ndrop_all_tables\ndo_test fkey2-7.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(c INTEGER PRIMARY KEY REFERENCES t1, b);\n  }\n} {}\ndo_test fkey2-7.2 {\n  catchsql { INSERT INTO t2 VALUES(1, 'A'); }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-7.3 {\n  execsql { \n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(2, 3);\n    INSERT INTO t2 VALUES(1, 'A');\n  }\n} {}\ndo_test fkey2-7.4 {\n  execsql { UPDATE t2 SET c = 2 }\n} {}\ndo_test fkey2-7.5 {\n  catchsql { UPDATE t2 SET c = 3 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-7.6 {\n  catchsql { DELETE FROM t1 WHERE a = 2 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-7.7 {\n  execsql { DELETE FROM t1 WHERE a = 1 }\n} {}\ndo_test fkey2-7.8 {\n  catchsql { UPDATE t1 SET a = 3 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-7.9 {\n  catchsql { UPDATE t2 SET rowid = 3 }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to enable/disable FK support while a\n# transaction is open.\n# \ndrop_all_tables\nproc fkey2-8-test {tn zSql value} {\n  do_test fkey-2.8.$tn.1 [list execsql $zSql] {}\n  do_test fkey-2.8.$tn.2 { execsql \"PRAGMA foreign_keys\" } $value\n}\nfkey2-8-test  1 { PRAGMA foreign_keys = 0     } 0\nfkey2-8-test  2 { PRAGMA foreign_keys = 1     } 1\nfkey2-8-test  3 { BEGIN                       } 1\nfkey2-8-test  4 { PRAGMA foreign_keys = 0     } 1\nfkey2-8-test  5 { COMMIT                      } 1\nfkey2-8-test  6 { PRAGMA foreign_keys = 0     } 0\nfkey2-8-test  7 { BEGIN                       } 0\nfkey2-8-test  8 { PRAGMA foreign_keys = 1     } 0\nfkey2-8-test  9 { COMMIT                      } 0\nfkey2-8-test 10 { PRAGMA foreign_keys = 1     } 1\nfkey2-8-test 11 { PRAGMA foreign_keys = off   } 0\nfkey2-8-test 12 { PRAGMA foreign_keys = on    } 1\nfkey2-8-test 13 { PRAGMA foreign_keys = no    } 0\nfkey2-8-test 14 { PRAGMA foreign_keys = yes   } 1\nfkey2-8-test 15 { PRAGMA foreign_keys = false } 0\nfkey2-8-test 16 { PRAGMA foreign_keys = true  } 1\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-9.*, test SET DEFAULT actions.\n#\ndrop_all_tables\ndo_test fkey2-9.1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t2(\n      c INTEGER PRIMARY KEY,\n      d INTEGER DEFAULT 1 REFERENCES t1 ON DELETE SET DEFAULT\n    );\n    DELETE FROM t1;\n  }\n} {}\ndo_test fkey2-9.1.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t2 VALUES(1, 2);\n    SELECT * FROM t2;\n    DELETE FROM t1 WHERE a = 2;\n    SELECT * FROM t2;\n  }\n} {1 2 1 1}\ndo_test fkey2-9.1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(2, 'two');\n    UPDATE t2 SET d = 2;\n    DELETE FROM t1 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test fkey2-9.1.4 {\n  execsql { SELECT * FROM t1 }\n} {2 two}\ndo_test fkey2-9.1.5 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test fkey2-9.2.1 {\n  execsql {\n    CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c));\n    CREATE TABLE cc(d DEFAULT 3, e DEFAULT 1, f DEFAULT 2,\n        FOREIGN KEY(f, d) REFERENCES pp \n        ON UPDATE SET DEFAULT \n        ON DELETE SET NULL\n    );\n    INSERT INTO pp VALUES(1, 2, 3);\n    INSERT INTO pp VALUES(4, 5, 6);\n    INSERT INTO pp VALUES(7, 8, 9);\n  }\n} {}\ndo_test fkey2-9.2.2 {\n  execsql {\n    INSERT INTO cc VALUES(6, 'A', 5);\n    INSERT INTO cc VALUES(6, 'B', 5);\n    INSERT INTO cc VALUES(9, 'A', 8);\n    INSERT INTO cc VALUES(9, 'B', 8);\n    UPDATE pp SET b = 1 WHERE a = 7;\n    SELECT * FROM cc;\n  }\n} {6 A 5 6 B 5 3 A 2 3 B 2}\ndo_test fkey2-9.2.3 {\n  execsql {\n    DELETE FROM pp WHERE a = 4;\n    SELECT * FROM cc;\n  }\n} {{} A {} {} B {} 3 A 2 3 B 2}\ndo_execsql_test fkey2-9.3.0 {\n  CREATE TABLE t3(x PRIMARY KEY REFERENCES t3 ON DELETE SET NULL);\n  INSERT INTO t3(x) VALUES(12345);\n  DROP TABLE t3;\n} {}\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-10.*, test \"foreign key mismatch\" and \n# other errors.\n#\nset tn 0\nforeach zSql [list {\n  CREATE TABLE p(a PRIMARY KEY, b);\n  CREATE TABLE c(x REFERENCES p(c));\n} {\n  CREATE TABLE c(x REFERENCES v(y));\n  CREATE VIEW v AS SELECT x AS y FROM c;\n} {\n  CREATE TABLE p(a, b, PRIMARY KEY(a, b));\n  CREATE TABLE c(x REFERENCES p);\n} {\n  CREATE TABLE p(a COLLATE binary, b);\n  CREATE UNIQUE INDEX i ON p(a COLLATE nocase);\n  CREATE TABLE c(x REFERENCES p(a));\n}] {\n  drop_all_tables\n  do_test fkey2-10.1.[incr tn] {\n    execsql $zSql\n    catchsql { INSERT INTO c DEFAULT VALUES }\n  } {/1 {foreign key mismatch - \"c\" referencing \".\"}/}\n}\n\n# \"rowid\" cannot be used as part of a child or parent key definition \n# unless it happens to be the name of an explicitly declared column.\n#\ndo_test fkey2-10.2.1 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(c, d, FOREIGN KEY(rowid) REFERENCES t1(a));\n  }\n} {1 {unknown column \"rowid\" in foreign key definition}}\ndo_test fkey2-10.2.2 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(rowid, d, FOREIGN KEY(rowid) REFERENCES t1(a));\n  }\n} {0 {}}\ndo_test fkey2-10.2.1 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));\n    INSERT INTO t1(rowid, a, b) VALUES(1, 1, 1);\n    INSERT INTO t2 VALUES(1, 1);\n  }\n} {1 {foreign key mismatch - \"t2\" referencing \"t1\"}}\ndo_test fkey2-10.2.2 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(rowid PRIMARY KEY, b);\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));\n    INSERT INTO t1(rowid, b) VALUES(1, 1);\n    INSERT INTO t2 VALUES(1, 1);\n  }\n} {0 {}}\n\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-11.*, test CASCADE actions.\n#\ndrop_all_tables\ndo_test fkey2-11.1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, rowid, _rowid_, oid);\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(a) ON UPDATE CASCADE);\n\n    INSERT INTO t1 VALUES(10, 100, 'abc', 'def', 'ghi');\n    INSERT INTO t2 VALUES(10, 100);\n    UPDATE t1 SET a = 15;\n    SELECT * FROM t2;\n  }\n} {15 100}\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-12.*, test RESTRICT actions.\n#\ndrop_all_tables\ndo_test fkey2-12.1.1 {\n  execsql {\n    CREATE TABLE t1(a, b PRIMARY KEY);\n    CREATE TABLE t2(\n      x REFERENCES t1 ON UPDATE RESTRICT DEFERRABLE INITIALLY DEFERRED \n    );\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n  }\n} {}\ndo_test fkey2-12.1.2 { \n  execsql \"BEGIN\"\n  execsql \"INSERT INTO t2 VALUES('two')\"\n} {}\ndo_test fkey2-12.1.3 { \n  execsql \"UPDATE t1 SET b = 'four' WHERE b = 'one'\"\n} {}\ndo_test fkey2-12.1.4 { \n  catchsql \"UPDATE t1 SET b = 'five' WHERE b = 'two'\"\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-12.1.5 { \n  execsql \"DELETE FROM t1 WHERE b = 'two'\"\n} {}\ndo_test fkey2-12.1.6 { \n  catchsql \"COMMIT\"\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-12.1.7 { \n  execsql {\n    INSERT INTO t1 VALUES(2, 'two');\n    COMMIT;\n  }\n} {}\n\ndrop_all_tables\ndo_test fkey2-12.2.1 {\n  execsql {\n    CREATE TABLE t1(x COLLATE NOCASE PRIMARY KEY);\n    CREATE TRIGGER tt1 AFTER DELETE ON t1 \n      WHEN EXISTS ( SELECT 1 FROM t2 WHERE old.x = y )\n    BEGIN\n      INSERT INTO t1 VALUES(old.x);\n    END;\n    CREATE TABLE t2(y REFERENCES t1);\n    INSERT INTO t1 VALUES('A');\n    INSERT INTO t1 VALUES('B');\n    INSERT INTO t2 VALUES('a');\n    INSERT INTO t2 VALUES('b');\n\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\ndo_test fkey2-12.2.2 {\n  execsql { DELETE FROM t1 }\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\ndo_test fkey2-12.2.3 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);\n    INSERT INTO t2 VALUES('a');\n    INSERT INTO t2 VALUES('b');\n  }\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-12.2.4 {\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\n\ndrop_all_tables\ndo_test fkey2-12.3.1 {\n  execsql {\n    CREATE TABLE up(\n      c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,\n      c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,\n      c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,\n      c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,\n      PRIMARY KEY(c34, c35)\n    );\n    CREATE TABLE down(\n      c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,\n      c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,\n      c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,\n      c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,\n      FOREIGN KEY(c39, c38) REFERENCES up ON UPDATE CASCADE\n    );\n  }\n} {}\ndo_test fkey2-12.3.2 {\n  execsql {\n    INSERT INTO up(c34, c35) VALUES('yes', 'no');\n    INSERT INTO down(c39, c38) VALUES('yes', 'no');\n    UPDATE up SET c34 = 'possibly';\n    SELECT c38, c39 FROM down;\n    DELETE FROM down;\n  }\n} {no possibly}\ndo_test fkey2-12.3.3 {\n  catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-12.3.4 {\n  execsql { \n    INSERT INTO up(c34, c35) VALUES('yes', 'no');\n    INSERT INTO down(c39, c38) VALUES('yes', 'no');\n  }\n  catchsql { DELETE FROM up WHERE c34 = 'yes' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-12.3.5 {\n  execsql { \n    DELETE FROM up WHERE c34 = 'possibly';\n    SELECT c34, c35 FROM up;\n    SELECT c39, c38 FROM down;\n  }\n} {yes no yes no}\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-13.*, test that FK processing is performed\n# when rows are REPLACEd.\n#\ndrop_all_tables\ndo_test fkey2-13.1.1 {\n  execsql {\n    CREATE TABLE pp(a UNIQUE, b, c, PRIMARY KEY(b, c));\n    CREATE TABLE cc(d, e, f UNIQUE, FOREIGN KEY(d, e) REFERENCES pp);\n    INSERT INTO pp VALUES(1, 2, 3);\n    INSERT INTO cc VALUES(2, 3, 1);\n  }\n} {}\nforeach {tn stmt} {\n  1   \"REPLACE INTO pp VALUES(1, 4, 5)\"\n  2   \"REPLACE INTO pp(rowid, a, b, c) VALUES(1, 2, 3, 4)\"\n} {\n  do_test fkey2-13.1.$tn.1 {\n    catchsql $stmt\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-13.1.$tn.2 {\n    execsql {\n      SELECT * FROM pp;\n      SELECT * FROM cc;\n    }\n  } {1 2 3 2 3 1}\n  do_test fkey2-13.1.$tn.3 {\n    execsql BEGIN;\n    catchsql $stmt\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-13.1.$tn.4 {\n    execsql {\n      COMMIT;\n      SELECT * FROM pp;\n      SELECT * FROM cc;\n    }\n  } {1 2 3 2 3 1}\n}\ndo_test fkey2-13.1.3 {\n  execsql { \n    REPLACE INTO pp(rowid, a, b, c) VALUES(1, 2, 2, 3);\n    SELECT rowid, * FROM pp;\n    SELECT * FROM cc;\n  }\n} {1 2 2 3 2 3 1}\ndo_test fkey2-13.1.4 {\n  execsql { \n    REPLACE INTO pp(rowid, a, b, c) VALUES(2, 2, 2, 3);\n    SELECT rowid, * FROM pp;\n    SELECT * FROM cc;\n  }\n} {2 2 2 3 2 3 1}\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-14.*, test that the \"DROP TABLE\" and \"ALTER\n# TABLE\" commands work as expected wrt foreign key constraints.\n#\n# fkey2-14.1*: ALTER TABLE ADD COLUMN\n# fkey2-14.2*: ALTER TABLE RENAME TABLE\n# fkey2-14.3*: DROP TABLE\n#\ndrop_all_tables\nifcapable altertable {\n  do_test fkey2-14.1.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      CREATE TABLE t1(a PRIMARY KEY);\n      CREATE TABLE t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test fkey2-14.1.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n  \n  \n  # Test the sqlite_rename_parent() function directly.\n  #\n  proc test_rename_parent {zCreate zOld zNew} {\n    db eval {SELECT sqlite_rename_parent($zCreate, $zOld, $zNew)}\n  }\n  do_test fkey2-14.2.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test fkey2-14.2.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test fkey2-14.2.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test fkey2-14.2.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1);\n      CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);\n      CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)}                     \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test fkey2-14.2.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\")}                    \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test fkey2-14.2.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test fkey2-14.2.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test fkey2-14.2.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n\n  # Repeat for TEMP tables\n  #\n  drop_all_tables\n  do_test fkey2-14.1tmp.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      CREATE TEMP TABLE t1(a PRIMARY KEY);\n      CREATE TEMP TABLE t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1tmp.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1tmp.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test fkey2-14.1tmp.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1tmp.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1tmp.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM temp.sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n\n  do_test fkey2-14.2tmp.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test fkey2-14.2tmp.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test fkey2-14.2tmp.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test fkey2-14.2tmp.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1);\n      CREATE TEMP TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);\n      CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)}                     \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test fkey2-14.2tmp.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM temp.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\")}                    \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test fkey2-14.2tmp.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2tmp.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test fkey2-14.2tmp.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2tmp.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test fkey2-14.2tmp.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n\n  # Repeat for ATTACH-ed tables\n  #\n  drop_all_tables\n  do_test fkey2-14.1aux.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      ATTACH ':memory:' AS aux;\n      CREATE TABLE aux.t1(a PRIMARY KEY);\n      CREATE TABLE aux.t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1aux.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test fkey2-14.1aux.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test fkey2-14.1aux.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1aux.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test fkey2-14.1aux.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM aux.sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n\n  do_test fkey2-14.2aux.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test fkey2-14.2aux.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test fkey2-14.2aux.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test fkey2-14.2aux.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1);\n      CREATE TABLE aux.t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2);\n      CREATE TABLE aux.t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1)}                     \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test fkey2-14.2aux.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\")}                    \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test fkey2-14.2aux.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2aux.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test fkey2-14.2aux.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-14.2aux.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test fkey2-14.2aux.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n}\n\ndo_test fkey-2.14.3.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a, b REFERENCES nosuchtable);\n    DROP TABLE t1;\n  }\n} {}\ndo_test fkey-2.14.3.2 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES('a', 1);\n    CREATE TABLE t2(x REFERENCES t1);\n    INSERT INTO t2 VALUES('a');\n  }\n} {}\ndo_test fkey-2.14.3.3 {\n  catchsql { DROP TABLE t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey-2.14.3.4 {\n  execsql {\n    DELETE FROM t2;\n    DROP TABLE t1;\n  }\n} {}\ndo_test fkey-2.14.3.4 {\n  catchsql { INSERT INTO t2 VALUES('x') }\n} {1 {no such table: main.t1}}\ndo_test fkey-2.14.3.5 {\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES('x');\n  }\n  execsql { INSERT INTO t2 VALUES('x') }\n} {}\ndo_test fkey-2.14.3.6 {\n  catchsql { DROP TABLE t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey-2.14.3.7 {\n  execsql {\n    DROP TABLE t2;\n    DROP TABLE t1;\n  }\n} {}\ndo_test fkey-2.14.3.8 {\n  execsql {\n    CREATE TABLE pp(x, y, PRIMARY KEY(x, y));\n    CREATE TABLE cc(a, b, FOREIGN KEY(a, b) REFERENCES pp(x, z));\n  }\n  catchsql { INSERT INTO cc VALUES(1, 2) }\n} {1 {foreign key mismatch - \"cc\" referencing \"pp\"}}\ndo_test fkey-2.14.3.9 {\n  execsql { DROP TABLE cc }\n} {}\ndo_test fkey-2.14.3.10 {\n  execsql {\n    CREATE TABLE cc(a, b, \n      FOREIGN KEY(a, b) REFERENCES pp DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n  execsql {\n    INSERT INTO pp VALUES('a', 'b');\n    INSERT INTO cc VALUES('a', 'b');\n    BEGIN;\n      DROP TABLE pp;\n      CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c));\n      INSERT INTO pp VALUES(1, 'a', 'b');\n    COMMIT;\n  }\n} {}\ndo_test fkey-2.14.3.11 {\n  execsql { \n    BEGIN;\n      DROP TABLE cc;\n      DROP TABLE pp;\n    COMMIT;\n  }\n} {}\ndo_test fkey-2.14.3.12 {\n  execsql {\n    CREATE TABLE b1(a, b);\n    CREATE TABLE b2(a, b REFERENCES b1);\n    DROP TABLE b1;\n  }\n} {}\ndo_test fkey-2.14.3.13 {\n  execsql {\n    CREATE TABLE b3(a, b REFERENCES b2 DEFERRABLE INITIALLY DEFERRED);\n    DROP TABLE b2;\n  }\n} {}\n\n# Test that nothing goes wrong when dropping a table that refers to a view.\n# Or dropping a view that an existing FK (incorrectly) refers to. Or either\n# of the above scenarios with a virtual table.\ndrop_all_tables\ndo_test fkey-2.14.4.1 {\n  execsql {\n    CREATE TABLE t1(x REFERENCES v); \n    CREATE VIEW v AS SELECT * FROM t1;\n  }\n} {}\ndo_test fkey-2.14.4.2 {\n  execsql {\n    DROP VIEW v;\n  }\n} {}\nifcapable vtab {\n  register_echo_module db\n  do_test fkey-2.14.4.3 {\n    execsql { CREATE VIRTUAL TABLE v USING echo(t1) }\n  } {}\n  do_test fkey-2.14.4.2 {\n    execsql {\n      DROP TABLE v;\n    }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# The following tests, fkey2-15.*, test that unnecessary FK related scans \n# and lookups are avoided when the constraint counters are zero.\n#\ndrop_all_tables\nproc execsqlS {zSql} {\n  set ::sqlite_search_count 0\n  set ::sqlite_found_count 0\n  set res [uplevel [list execsql $zSql]]\n  concat [expr $::sqlite_found_count + $::sqlite_search_count] $res\n}\ndo_test fkey2-15.1.1 {\n  execsql {\n    CREATE TABLE pp(a PRIMARY KEY, b);\n    CREATE TABLE cc(x, y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);\n    INSERT INTO pp VALUES(1, 'one');\n    INSERT INTO pp VALUES(2, 'two');\n    INSERT INTO cc VALUES('neung', 1);\n    INSERT INTO cc VALUES('song', 2);\n  }\n} {}\ndo_test fkey2-15.1.2 {\n  execsqlS { INSERT INTO pp VALUES(3, 'three') }\n} {0}\ndo_test fkey2-15.1.3 {\n  execsql {\n    BEGIN;\n      INSERT INTO cc VALUES('see', 4);    -- Violates deferred constraint\n  }\n  execsqlS { INSERT INTO pp VALUES(5, 'five') }\n} {2}\ndo_test fkey2-15.1.4 {\n  execsql { DELETE FROM cc WHERE x = 'see' }\n  execsqlS { INSERT INTO pp VALUES(6, 'six') }\n} {0}\ndo_test fkey2-15.1.5 {\n  execsql COMMIT\n} {}\ndo_test fkey2-15.1.6 {\n  execsql BEGIN\n  execsqlS {\n    DELETE FROM cc WHERE x = 'neung';\n    ROLLBACK;\n  }\n} {1}\ndo_test fkey2-15.1.7 {\n  execsql { \n    BEGIN;\n    DELETE FROM pp WHERE a = 2;\n  }\n  execsqlS {\n    DELETE FROM cc WHERE x = 'neung';\n    ROLLBACK;\n  }\n} {2}\n\n#-------------------------------------------------------------------------\n# This next block of tests, fkey2-16.*, test that rows that refer to\n# themselves may be inserted and deleted.\n#\nforeach {tn zSchema} {\n  1 { CREATE TABLE self(a INTEGER PRIMARY KEY, b REFERENCES self(a)) }\n  2 { CREATE TABLE self(a PRIMARY KEY, b REFERENCES self(a)) }\n  3 { CREATE TABLE self(a UNIQUE, b INTEGER PRIMARY KEY REFERENCES self(a)) }\n} {\n  drop_all_tables\n  do_test fkey2-16.1.$tn.1 {\n    execsql $zSchema\n    execsql { INSERT INTO self VALUES(13, 13) }\n  } {}\n  do_test fkey2-16.1.$tn.2 {\n    execsql { UPDATE self SET a = 14, b = 14 }\n  } {}\n\n  do_test fkey2-16.1.$tn.3 {\n    catchsql { UPDATE self SET b = 15 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test fkey2-16.1.$tn.4 {\n    catchsql { UPDATE self SET a = 15 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test fkey2-16.1.$tn.5 {\n    catchsql { UPDATE self SET a = 15, b = 16 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test fkey2-16.1.$tn.6 {\n    catchsql { UPDATE self SET a = 17, b = 17 }\n  } {0 {}}\n\n  do_test fkey2-16.1.$tn.7 {\n    execsql { DELETE FROM self }\n  } {}\n  do_test fkey2-16.1.$tn.8 {\n    catchsql { INSERT INTO self VALUES(20, 21) }\n  } {1 {FOREIGN KEY constraint failed}}\n}\n\n#-------------------------------------------------------------------------\n# This next block of tests, fkey2-17.*, tests that if \"PRAGMA count_changes\"\n# is turned on statements that violate immediate FK constraints return\n# SQLITE_CONSTRAINT immediately, not after returning a number of rows.\n# Whereas statements that violate deferred FK constraints return the number\n# of rows before failing.\n#\n# Also test that rows modified by FK actions are not counted in either the\n# returned row count or the values returned by sqlite3_changes(). Like\n# trigger related changes, they are included in sqlite3_total_changes() though.\n#\ndrop_all_tables\ndo_test fkey2-17.1.1 {\n  execsql { PRAGMA count_changes = 1 }\n  execsql { \n    CREATE TABLE one(a, b, c, UNIQUE(b, c));\n    CREATE TABLE two(d, e, f, FOREIGN KEY(e, f) REFERENCES one(b, c));\n    INSERT INTO one VALUES(1, 2, 3);\n  }\n} {1}\ndo_test fkey2-17.1.2 {\n  set STMT [sqlite3_prepare_v2 db \"INSERT INTO two VALUES(4, 5, 6)\" -1 dummy]\n  sqlite3_step $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY\nifcapable autoreset {\n  do_test fkey2-17.1.3 {\n    sqlite3_step $STMT\n  } {SQLITE_CONSTRAINT}\n  verify_ex_errcode fkey2-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY\n} else {\n  do_test fkey2-17.1.3 {\n    sqlite3_step $STMT\n  } {SQLITE_MISUSE}\n}\ndo_test fkey2-17.1.4 {\n  sqlite3_finalize $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey2-17.1.5 {\n  execsql {\n    INSERT INTO one VALUES(2, 3, 4);\n    INSERT INTO one VALUES(3, 4, 5);\n    INSERT INTO two VALUES(1, 2, 3);\n    INSERT INTO two VALUES(2, 3, 4);\n    INSERT INTO two VALUES(3, 4, 5);\n  }\n} {1 1 1 1 1}\ndo_test fkey2-17.1.6 {\n  catchsql {\n    BEGIN;\n      INSERT INTO one VALUES(0, 0, 0);\n      UPDATE two SET e=e+1, f=f+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-17.1.7 {\n  execsql { SELECT * FROM one }\n} {1 2 3 2 3 4 3 4 5 0 0 0}\ndo_test fkey2-17.1.8 {\n  execsql { SELECT * FROM two }\n} {1 2 3 2 3 4 3 4 5}\ndo_test fkey2-17.1.9 {\n  execsql COMMIT\n} {}\ndo_test fkey2-17.1.10 {\n  execsql {\n    CREATE TABLE three(\n      g, h, i, \n      FOREIGN KEY(h, i) REFERENCES one(b, c) DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {}\ndo_test fkey2-17.1.11 {\n  set STMT [sqlite3_prepare_v2 db \"INSERT INTO three VALUES(7, 8, 9)\" -1 dummy]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test fkey2-17.1.12 {\n  sqlite3_column_text $STMT 0\n} {1}\ndo_test fkey2-17.1.13 {\n  sqlite3_step $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey2-17.1.14 {\n  sqlite3_finalize $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY\n\ndrop_all_tables\ndo_test fkey2-17.2.1 {\n  execsql {\n    CREATE TABLE high(\"a'b!\" PRIMARY KEY, b);\n    CREATE TABLE low(\n      c, \n      \"d&6\" REFERENCES high ON UPDATE CASCADE ON DELETE CASCADE\n    );\n  }\n} {}\ndo_test fkey2-17.2.2 {\n  execsql {\n    INSERT INTO high VALUES('a', 'b');\n    INSERT INTO low VALUES('b', 'a');\n  }\n  db changes\n} {1}\nset nTotal [db total_changes]\ndo_test fkey2-17.2.3 {\n  execsql { UPDATE high SET \"a'b!\" = 'c' }\n} {1}\ndo_test fkey2-17.2.4 {\n  db changes\n} {1}\ndo_test fkey2-17.2.5 {\n  expr [db total_changes] - $nTotal\n} {2}\ndo_test fkey2-17.2.6 {\n  execsql { SELECT * FROM high ; SELECT * FROM low }\n} {c b b c}\ndo_test fkey2-17.2.7 {\n  execsql { DELETE FROM high }\n} {1}\ndo_test fkey2-17.2.8 {\n  db changes\n} {1}\ndo_test fkey2-17.2.9 {\n  expr [db total_changes] - $nTotal\n} {4}\ndo_test fkey2-17.2.10 {\n  execsql { SELECT * FROM high ; SELECT * FROM low }\n} {}\nexecsql { PRAGMA count_changes = 0 }\n\n#-------------------------------------------------------------------------\n# Test that the authorization callback works.\n#\n\nifcapable auth {\n  do_test fkey2-18.1 {\n    execsql {\n      CREATE TABLE long(a, b PRIMARY KEY, c);\n      CREATE TABLE short(d, e, f REFERENCES long);\n      CREATE TABLE mid(g, h, i REFERENCES long DEFERRABLE INITIALLY DEFERRED);\n    }\n  } {}\n\n  proc auth {args} {eval lappend ::authargs [lrange $args 0 4]; return SQLITE_OK}\n  db auth auth\n\n  # An insert on the parent table must read the child key of any deferred\n  # foreign key constraints. But not the child key of immediate constraints.\n  set authargs {}\n  do_test fkey2-18.2 {\n    execsql { INSERT INTO long VALUES(1, 2, 3) }\n    set authargs\n  } {SQLITE_INSERT long {} main {} SQLITE_READ mid i main {}}\n\n  # An insert on the child table of an immediate constraint must read the\n  # parent key columns (to see if it is a violation or not).\n  set authargs {}\n  do_test fkey2-18.3 {\n    execsql { INSERT INTO short VALUES(1, 3, 2) }\n    set authargs\n  } {SQLITE_INSERT short {} main {} SQLITE_READ long b main {}}\n  \n  # As must an insert on the child table of a deferred constraint.\n  set authargs {}\n  do_test fkey2-18.4 {\n    execsql { INSERT INTO mid VALUES(1, 3, 2) }\n    set authargs\n  } {SQLITE_INSERT mid {} main {} SQLITE_READ long b main {}}\n\n  do_test fkey2-18.5 {\n    execsql {\n      CREATE TABLE nought(a, b PRIMARY KEY, c);\n      CREATE TABLE cross(d, e, f,\n        FOREIGN KEY(e) REFERENCES nought(b) ON UPDATE CASCADE\n      );\n    }\n    execsql { INSERT INTO nought VALUES(2, 1, 2) }\n    execsql { INSERT INTO cross VALUES(0, 1, 0) }\n    set authargs [list]\n    execsql { UPDATE nought SET b = 5 }\n    set authargs\n  } {SQLITE_UPDATE nought b main {} SQLITE_READ cross e main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_UPDATE cross e main {} SQLITE_READ nought b main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {}}\n\n  do_test fkey2-18.6 {\n    execsql {SELECT * FROM cross}\n  } {0 5 0}\n\n  do_test fkey2-18.7 {\n    execsql {\n      CREATE TABLE one(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE two(b, c REFERENCES one);\n      INSERT INTO one VALUES(101, 102);\n    }\n    set authargs [list]\n    execsql { INSERT INTO two VALUES(100, 101); }\n    set authargs\n  } {SQLITE_INSERT two {} main {} SQLITE_READ one a main {}}\n\n  # Return SQLITE_IGNORE to requests to read from the parent table. This\n  # causes inserts of non-NULL keys into the child table to fail.\n  #\n  rename auth {}\n  proc auth {args} {\n    if {[lindex $args 1] == \"long\"} {return SQLITE_IGNORE}\n    return SQLITE_OK\n  }\n  do_test fkey2-18.8 {\n    catchsql { INSERT INTO short VALUES(1, 3, 2) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-18.9 {\n    execsql { INSERT INTO short VALUES(1, 3, NULL) }\n  } {}\n  do_test fkey2-18.10 {\n    execsql { SELECT * FROM short }\n  } {1 3 2 1 3 {}}\n  do_test fkey2-18.11 {\n    catchsql { UPDATE short SET f = 2 WHERE f IS NULL }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  db auth {}\n  unset authargs\n}\n\n\ndo_test fkey2-19.1 {\n  execsql {\n    CREATE TABLE main(id INTEGER PRIMARY KEY);\n    CREATE TABLE sub(id INT REFERENCES main(id));\n    INSERT INTO main VALUES(1);\n    INSERT INTO main VALUES(2);\n    INSERT INTO sub VALUES(2);\n  }\n} {}\ndo_test fkey2-19.2 {\n  set S [sqlite3_prepare_v2 db \"DELETE FROM main WHERE id = ?\" -1 dummy]\n  sqlite3_bind_int $S 1 2\n  sqlite3_step $S\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-19.2b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey2-19.3 {\n  sqlite3_reset $S\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey2-19.3b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey2-19.4 {\n  sqlite3_bind_int $S 1 1\n  sqlite3_step $S\n} {SQLITE_DONE}\ndo_test fkey2-19.4 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndrop_all_tables\ndo_test fkey2-20.1 {\n  execsql {\n    CREATE TABLE pp(a PRIMARY KEY, b);\n    CREATE TABLE cc(c PRIMARY KEY, d REFERENCES pp);\n  }\n} {}\n\nforeach {tn insert} {\n  1 \"INSERT\"\n  2 \"INSERT OR IGNORE\"\n  3 \"INSERT OR ABORT\"\n  4 \"INSERT OR ROLLBACK\"\n  5 \"INSERT OR REPLACE\"\n  6 \"INSERT OR FAIL\"\n} {\n  do_test fkey2-20.2.$tn.1 {\n    catchsql \"$insert INTO cc VALUES(1, 2)\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.2.$tn.2 {\n    execsql { SELECT * FROM cc }\n  } {}\n  do_test fkey2-20.2.$tn.3 {\n    execsql {\n      BEGIN;\n        INSERT INTO pp VALUES(2, 'two');\n        INSERT INTO cc VALUES(1, 2);\n    }\n    catchsql \"$insert INTO cc VALUES(3, 4)\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.2.$tn.4 {\n    execsql { COMMIT ; SELECT * FROM cc }\n  } {1 2}\n  do_test fkey2-20.2.$tn.5 {\n    execsql { DELETE FROM cc ; DELETE FROM pp }\n  } {}\n}\n\nforeach {tn update} {\n  1 \"UPDATE\"\n  2 \"UPDATE OR IGNORE\"\n  3 \"UPDATE OR ABORT\"\n  4 \"UPDATE OR ROLLBACK\"\n  5 \"UPDATE OR REPLACE\"\n  6 \"UPDATE OR FAIL\"\n} {\n  do_test fkey2-20.3.$tn.1 {\n    execsql {\n      INSERT INTO pp VALUES(2, 'two');\n      INSERT INTO cc VALUES(1, 2);\n    }\n  } {}\n  do_test fkey2-20.3.$tn.2 {\n    catchsql \"$update pp SET a = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.3.$tn.3 {\n    execsql { SELECT * FROM pp }\n  } {2 two}\n  do_test fkey2-20.3.$tn.4 {\n    catchsql \"$update cc SET d = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.3.$tn.5 {\n    execsql { SELECT * FROM cc }\n  } {1 2}\n  do_test fkey2-20.3.$tn.6 {\n    execsql {\n      BEGIN;\n        INSERT INTO pp VALUES(3, 'three');\n    }\n    catchsql \"$update pp SET a = 1 WHERE a = 2\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.3.$tn.7 {\n    execsql { COMMIT ; SELECT * FROM pp }\n  } {2 two 3 three}\n  do_test fkey2-20.3.$tn.8 {\n    execsql {\n      BEGIN;\n        INSERT INTO cc VALUES(2, 2);\n    }\n    catchsql \"$update cc SET d = 1 WHERE c = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test fkey2-20.3.$tn.9 {\n    execsql { COMMIT ; SELECT * FROM cc }\n  } {1 2 2 2}\n  do_test fkey2-20.3.$tn.10 {\n    execsql { DELETE FROM cc ; DELETE FROM pp }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# The following block of tests, those prefixed with \"fkey2-genfkey.\", are \n# the same tests that were used to test the \".genfkey\" command provided \n# by the shell tool. So these tests show that the built-in foreign key \n# implementation is more or less compatible with the triggers generated \n# by genfkey.\n#\ndrop_all_tables\ndo_test fkey2-genfkey.1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));\n    CREATE TABLE t2(e REFERENCES t1, f);\n    CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));\n  }\n} {}\ndo_test fkey2-genfkey.1.2 {\n  catchsql { INSERT INTO t2 VALUES(1, 2) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t2 VALUES(1, 2);\n  }\n} {}\ndo_test fkey2-genfkey.1.4 {\n  execsql { INSERT INTO t2 VALUES(NULL, 3) }\n} {}\ndo_test fkey2-genfkey.1.5 {\n  catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.6 {\n  execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }\n} {}\ndo_test fkey2-genfkey.1.7 {\n  execsql { UPDATE t2 SET e = NULL WHERE f = 3 }\n} {}\ndo_test fkey2-genfkey.1.8 {\n  catchsql { UPDATE t1 SET a = 10 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.9 {\n  catchsql { UPDATE t1 SET a = NULL }\n} {1 {datatype mismatch}}\ndo_test fkey2-genfkey.1.10 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.11 {\n  execsql { UPDATE t2 SET e = NULL }\n} {}\ndo_test fkey2-genfkey.1.12 {\n  execsql { \n    UPDATE t1 SET a = 10;\n    DELETE FROM t1;\n    DELETE FROM t2;\n  }\n} {}\ndo_test fkey2-genfkey.1.13 {\n  execsql {\n    INSERT INTO t3 VALUES(1, NULL, NULL);\n    INSERT INTO t3 VALUES(1, 2, NULL);\n    INSERT INTO t3 VALUES(1, NULL, 3);\n  }\n} {}\ndo_test fkey2-genfkey.1.14 {\n  catchsql { INSERT INTO t3 VALUES(3, 1, 4) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.15 {\n  execsql { \n    INSERT INTO t1 VALUES(1, 1, 4);\n    INSERT INTO t3 VALUES(3, 1, 4);\n  }\n} {}\ndo_test fkey2-genfkey.1.16 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.17 {\n  catchsql { UPDATE t1 SET b = 10}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-genfkey.1.18 {\n  execsql { UPDATE t1 SET a = 10}\n} {}\ndo_test fkey2-genfkey.1.19 {\n  catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}\n} {1 {FOREIGN KEY constraint failed}}\n\ndrop_all_tables\ndo_test fkey2-genfkey.2.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));\n    CREATE TABLE t2(e REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE, f);\n    CREATE TABLE t3(g, h, i, \n        FOREIGN KEY (h, i) \n        REFERENCES t1(b, c) ON UPDATE CASCADE ON DELETE CASCADE\n    );\n  }\n} {}\ndo_test fkey2-genfkey.2.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(4, 'four');\n  }\n} {}\ndo_test fkey2-genfkey.2.3 {\n  execsql {\n    UPDATE t1 SET a = 2 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {2 one 4 four}\ndo_test fkey2-genfkey.2.4 {\n  execsql {\n    DELETE FROM t1 WHERE a = 4;\n    SELECT * FROM t2;\n  }\n} {2 one}\n\ndo_test fkey2-genfkey.2.5 {\n  execsql {\n    INSERT INTO t3 VALUES('hello', 2, 3);\n    UPDATE t1 SET c = 2;\n    SELECT * FROM t3;\n  }\n} {hello 2 2}\ndo_test fkey2-genfkey.2.6 {\n  execsql {\n    DELETE FROM t1;\n    SELECT * FROM t3;\n  }\n} {}\n\ndrop_all_tables\ndo_test fkey2-genfkey.3.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(c, b));\n    CREATE TABLE t2(e REFERENCES t1 ON UPDATE SET NULL ON DELETE SET NULL, f);\n    CREATE TABLE t3(g, h, i, \n        FOREIGN KEY (h, i) \n        REFERENCES t1(b, c) ON UPDATE SET NULL ON DELETE SET NULL\n    );\n  }\n} {}\ndo_test fkey2-genfkey.3.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(4, 'four');\n  }\n} {}\ndo_test fkey2-genfkey.3.3 {\n  execsql {\n    UPDATE t1 SET a = 2 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {{} one 4 four}\ndo_test fkey2-genfkey.3.4 {\n  execsql {\n    DELETE FROM t1 WHERE a = 4;\n    SELECT * FROM t2;\n  }\n} {{} one {} four}\ndo_test fkey2-genfkey.3.5 {\n  execsql {\n    INSERT INTO t3 VALUES('hello', 2, 3);\n    UPDATE t1 SET c = 2;\n    SELECT * FROM t3;\n  }\n} {hello {} {}}\ndo_test fkey2-genfkey.3.6 {\n  execsql {\n    UPDATE t3 SET h = 2, i = 2;\n    DELETE FROM t1;\n    SELECT * FROM t3;\n  }\n} {hello {} {}}\n\n#-------------------------------------------------------------------------\n# Verify that ticket dd08e5a988d00decc4a543daa8dbbfab9c577ad8 has been\n# fixed.\n#\ndo_test fkey2-dd08e5.1.1 {\n  execsql {\n    PRAGMA foreign_keys=ON;\n    CREATE TABLE tdd08(a INTEGER PRIMARY KEY, b);\n    CREATE UNIQUE INDEX idd08 ON tdd08(a,b);\n    INSERT INTO tdd08 VALUES(200,300);\n\n    CREATE TABLE tdd08_b(w,x,y, FOREIGN KEY(x,y) REFERENCES tdd08(a,b));\n    INSERT INTO tdd08_b VALUES(100,200,300);\n  }\n} {}\ndo_test fkey2-dd08e5.1.2 {\n  catchsql {\n    DELETE FROM tdd08;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-dd08e5.1.3 {\n  execsql {\n    SELECT * FROM tdd08;\n  }\n} {200 300}\ndo_test fkey2-dd08e5.1.4 {\n  catchsql {\n    INSERT INTO tdd08_b VALUES(400,500,300);\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-dd08e5.1.5 {\n  catchsql {\n    UPDATE tdd08_b SET x=x+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-dd08e5.1.6 {\n  catchsql {\n    UPDATE tdd08 SET a=a+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba\n# fixed.\n#\ndo_test fkey2-ce7c13.1.1 {\n  execsql {\n    CREATE TABLE tce71(a INTEGER PRIMARY KEY, b);\n    CREATE UNIQUE INDEX ice71 ON tce71(a,b);\n    INSERT INTO tce71 VALUES(100,200);\n    CREATE TABLE tce72(w, x, y, FOREIGN KEY(x,y) REFERENCES tce71(a,b));\n    INSERT INTO tce72 VALUES(300,100,200);\n    UPDATE tce71 set b = 200 where a = 100;\n    SELECT * FROM tce71, tce72;\n  }\n} {100 200 300 100 200}\ndo_test fkey2-ce7c13.1.2 {\n  catchsql {\n    UPDATE tce71 set b = 201 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-ce7c13.1.3 {\n  catchsql {\n    UPDATE tce71 set a = 101 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-ce7c13.1.4 {\n  execsql {\n    CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b));\n    INSERT INTO tce73 VALUES(100,200);\n    CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));\n    INSERT INTO tce74 VALUES(300,100,200);\n    UPDATE tce73 set b = 200 where a = 100;\n    SELECT * FROM tce73, tce74;\n  }\n} {100 200 300 100 200}\ndo_test fkey2-ce7c13.1.5 {\n  catchsql {\n    UPDATE tce73 set b = 201 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey2-ce7c13.1.6 {\n  catchsql {\n    UPDATE tce73 set a = 101 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\n# 2015-04-16:  Foreign key errors propagate back up to the parser.\n#\ndo_test fkey2-20150416-100 {\n  db close\n  sqlite3 db :memory:\n  catchsql {\n    PRAGMA foreign_keys=1;\n    CREATE TABLE t1(x PRIMARY KEY);\n    CREATE TABLE t(y REFERENCES t0(x)ON DELETE SET DEFAULT);\n    CREATE TABLE t0(y REFERENCES t1 ON DELETE SET NULL);\n    REPLACE INTO t1 SELECT(0);CREATE TABLE t2(x);CREATE TABLE t3;\n  }\n} {1 {foreign key mismatch - \"t\" referencing \"t0\"}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey3.test",
    "content": "# 2009 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey||!trigger} {\n  finish_test\n  return\n}\n\nset testprefix fkey3\n\n# Create a table and some data to work with.\n#\ndo_test fkey3-1.1 {\n  execsql {\n    PRAGMA foreign_keys=ON;\n    CREATE TABLE t1(x INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(100);\n    INSERT INTO t1 VALUES(101);\n    CREATE TABLE t2(y INTEGER REFERENCES t1 (x));\n    INSERT INTO t2 VALUES(100);\n    INSERT INTO t2 VALUES(101);\n    SELECT 1, x FROM t1;\n    SELECT 2, y FROM t2;\n  }\n} {1 100 1 101 2 100 2 101}\n\ndo_test fkey3-1.2 {\n  catchsql {\n    DELETE FROM t1 WHERE x=100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test fkey3-1.3 {\n  catchsql {\n    DROP TABLE t1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test fkey3-1.4 {\n  execsql {\n    DROP TABLE t2;\n  }\n} {}\n\ndo_test fkey3-1.5 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\ndo_test fkey3-2.1 {\n  execsql {\n    PRAGMA foreign_keys=ON;\n    CREATE TABLE t1(x INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(100);\n    INSERT INTO t1 VALUES(101);\n    CREATE TABLE t2(y INTEGER PRIMARY KEY REFERENCES t1 (x) ON UPDATE SET NULL);\n  }\n  execsql {\n    INSERT INTO t2 VALUES(100);\n    INSERT INTO t2 VALUES(101);\n    SELECT 1, x FROM t1;\n    SELECT 2, y FROM t2;\n  }\n} {1 100 1 101 2 100 2 101}\n\n\n#-------------------------------------------------------------------------\n# The following tests - fkey-3.* - test some edge cases to do with \n# inserting rows into tables that have foreign keys where the parent\n# table is the same as the child table. Especially cases where the\n# new row being inserted matches itself.\n#\ndo_execsql_test 3.1.1 {\n  CREATE TABLE t3(a, b, c, d, \n    UNIQUE(a, b),\n    FOREIGN KEY(c, d) REFERENCES t3(a, b)\n  );\n  INSERT INTO t3 VALUES(1, 2, 1, 2);\n} {}\ndo_catchsql_test 3.1.2 {\n  INSERT INTO t3 VALUES(NULL, 2, 5, 2);\n} {1 {FOREIGN KEY constraint failed}}\ndo_catchsql_test 3.1.3 {\n  INSERT INTO t3 VALUES(NULL, 3, 5, 2);\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test 3.2.1 {\n  CREATE TABLE t4(a UNIQUE, b REFERENCES t4(a));\n}\ndo_catchsql_test 3.2.2 {\n  INSERT INTO t4 VALUES(NULL, 1);\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test 3.3.1 {\n  CREATE TABLE t5(a INTEGER PRIMARY KEY, b REFERENCES t5(a));\n  INSERT INTO t5 VALUES(NULL, 1);\n} {}\ndo_catchsql_test 3.3.2 {\n  INSERT INTO t5 VALUES(NULL, 3);\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test 3.4.1 {\n  CREATE TABLE t6(a INTEGER PRIMARY KEY, b, c, d,\n    FOREIGN KEY(c, d) REFERENCES t6(a, b)\n  );\n  CREATE UNIQUE INDEX t6i ON t6(b, a);\n}\ndo_execsql_test 3.4.2  { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}\ndo_execsql_test 3.4.3  { INSERT INTO t6 VALUES(2, 'a', 2, 'a');    } {}\ndo_execsql_test 3.4.4  { INSERT INTO t6 VALUES(NULL, 'a', 1, 'a'); } {}\ndo_execsql_test 3.4.5  { INSERT INTO t6 VALUES(5, 'a', 2, 'a'); } {}\ndo_catchsql_test 3.4.6 { \n  INSERT INTO t6 VALUES(NULL, 'a', 65, 'a');    \n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test 3.4.7 {\n  INSERT INTO t6 VALUES(100, 'one', 100, 'one');\n  DELETE FROM t6 WHERE a = 100;\n}\ndo_execsql_test 3.4.8 {\n  INSERT INTO t6 VALUES(100, 'one', 100, 'one');\n  UPDATE t6 SET c = 1, d = 'a' WHERE a = 100;\n  DELETE FROM t6 WHERE a = 100;\n}\n\ndo_execsql_test 3.5.1 {\n  CREATE TABLE t7(a, b, c, d INTEGER PRIMARY KEY,\n    FOREIGN KEY(c, d) REFERENCES t7(a, b)\n  );\n  CREATE UNIQUE INDEX t7i ON t7(a, b);\n}\ndo_execsql_test 3.5.2  { INSERT INTO t7 VALUES('x', 1, 'x', NULL) } {}\ndo_execsql_test 3.5.3  { INSERT INTO t7 VALUES('x', 2, 'x', 2) } {}\ndo_catchsql_test 3.5.4  { \n  INSERT INTO t7 VALUES('x', 450, 'x', NULL);\n} {1 {FOREIGN KEY constraint failed}}\ndo_catchsql_test 3.5.5  { \n  INSERT INTO t7 VALUES('x', 450, 'x', 451);\n} {1 {FOREIGN KEY constraint failed}}\n\n\ndo_execsql_test 3.6.1 {\n  CREATE TABLE t8(a, b, c, d, e, FOREIGN KEY(c, d) REFERENCES t8(a, b));\n  CREATE UNIQUE INDEX t8i1 ON t8(a, b);\n  CREATE UNIQUE INDEX t8i2 ON t8(c);\n  INSERT INTO t8 VALUES(1, 1, 1, 1, 1);\n}\ndo_catchsql_test 3.6.2 { \n  UPDATE t8 SET d = 2; \n} {1 {FOREIGN KEY constraint failed}}\ndo_execsql_test 3.6.3 { UPDATE t8 SET d = 1; }\ndo_execsql_test 3.6.4 { UPDATE t8 SET e = 2; }\n\ndo_catchsql_test 3.6.5 {\n  CREATE TABLE TestTable (\n    id INTEGER PRIMARY KEY,\n    name text,\n    source_id integer not null,\n    parent_id integer,\n\n    foreign key(source_id, parent_id) references TestTable(source_id, id)\n  );\n  CREATE UNIQUE INDEX testindex on TestTable(source_id, id);\n  PRAGMA foreign_keys=1;\n  INSERT INTO TestTable VALUES (1, 'parent', 1, null);\n  INSERT INTO TestTable VALUES (2, 'child', 1, 1);\n  UPDATE TestTable SET parent_id=1000 where id=2;\n} {1 {FOREIGN KEY constraint failed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey4.test",
    "content": "# 2011 Feb 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file test deferred foreign key constraint processing to make\n# sure that when a statement not within BEGIN...END fails a constraint,\n# that statement doesn't hold the transaction open thus allowing\n# a subsequent statement to fail a deferred constraint with impunity.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey||!trigger} {\n  finish_test\n  return\n}\n\n# Create a table and some data to work with.\n#\ndo_test fkey4-1.1 {\n  execsql {\n    PRAGMA foreign_keys = ON;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(c REFERENCES t1 DEFERRABLE INITIALLY DEFERRED, d);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(1,3);\n  }\n} {}\n\ndo_test fkey4-1.2 {\n  set ::DB [sqlite3_connection_pointer db]\n  set ::SQL {INSERT INTO t2 VALUES(2,4)}\n  set ::STMT1 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL]\n  sqlite3_step $::STMT1\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey4-1.2b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey4-1.3 {\n  set ::STMT2 [sqlite3_prepare_v2 $::DB $::SQL -1 TAIL]\n  sqlite3_step $::STMT2\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode fkey4-1.3b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test fkey4-1.4 {\n  db eval {SELECT * FROM t2}\n} {1 3}\nsqlite3_finalize $::STMT1\nsqlite3_finalize $::STMT2\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey5.test",
    "content": "# 2012 December 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests the PRAGMA foreign_key_check command.\n#\n# EVIDENCE-OF: R-15402-03103 PRAGMA schema.foreign_key_check; PRAGMA\n# schema.foreign_key_check(table-name);\n#\n# EVIDENCE-OF: R-23918-17301 The foreign_key_check pragma checks the\n# database, or the table called \"table-name\", for foreign key\n# constraints that are violated and returns one row of output for each\n# violation.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fkey5\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\n\ndo_test fkey5-1.1 {\n  db eval {\n    CREATE TABLE p1(a INTEGER PRIMARY KEY); INSERT INTO p1 VALUES(88),(89);\n    CREATE TABLE p2(a INT PRIMARY KEY); INSERT INTO p2 VALUES(77),(78);\n    CREATE TABLE p3(a TEXT PRIMARY KEY);\n    INSERT INTO p3 VALUES(66),(67),('alpha'),('BRAVO');\n    CREATE TABLE p4(a TEXT PRIMARY KEY COLLATE nocase);\n    INSERT INTO p4 VALUES('alpha'),('BRAVO'),('55'),('Delta'),('ECHO');\n    CREATE TABLE p5(a INTEGER PRIMARY KEY, b, c, UNIQUE(b,c));\n    INSERT INTO p5 VALUES(1,'Alpha','abc'),(2,'beta','def');\n    CREATE TABLE p6(a INTEGER PRIMARY KEY, b TEXT COLLATE nocase,\n                    c TEXT COLLATE rtrim, UNIQUE(b,c));\n    INSERT INTO p6 VALUES(1,'Alpha','abc '),(2,'bETA','def    ');\n\n    CREATE TABLE c1(x INTEGER PRIMARY KEY references p1);\n    CREATE TABLE c2(x INTEGER PRIMARY KEY references p2);\n    CREATE TABLE c3(x INTEGER PRIMARY KEY references p3);\n    CREATE TABLE c4(x INTEGER PRIMARY KEY references p4);\n    CREATE TABLE c5(x INT references p1);\n    CREATE TABLE c6(x INT references p2);\n    CREATE TABLE c7(x INT references p3);\n    CREATE TABLE c8(x INT references p4);\n    CREATE TABLE c9(x TEXT UNIQUE references p1);\n    CREATE TABLE c10(x TEXT UNIQUE references p2);\n    CREATE TABLE c11(x TEXT UNIQUE references p3);\n    CREATE TABLE c12(x TEXT UNIQUE references p4);\n    CREATE TABLE c13(x TEXT COLLATE nocase references p3);\n    CREATE TABLE c14(x TEXT COLLATE nocase references p4);\n    CREATE TABLE c15(x, y, FOREIGN KEY(x,y) REFERENCES p5(b,c));\n    CREATE TABLE c16(x, y, FOREIGN KEY(x,y) REFERENCES p5(c,b));\n    CREATE TABLE c17(x, y, FOREIGN KEY(x,y) REFERENCES p6(b,c));\n    CREATE TABLE c18(x, y, FOREIGN KEY(x,y) REFERENCES p6(c,b));\n    CREATE TABLE c19(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,\n                     FOREIGN KEY(x,y) REFERENCES p5(b,c));\n    CREATE TABLE c20(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,\n                     FOREIGN KEY(x,y) REFERENCES p5(c,b));\n    CREATE TABLE c21(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,\n                     FOREIGN KEY(x,y) REFERENCES p6(b,c));\n    CREATE TABLE c22(x TEXT COLLATE nocase, y TEXT COLLATE rtrim,\n                     FOREIGN KEY(x,y) REFERENCES p6(c,b));\n\n    PRAGMA foreign_key_check;\n  }\n} {}    \ndo_test fkey5-1.2 {\n  db eval {\n    INSERT INTO c1 VALUES(90),(87),(88);\n    PRAGMA foreign_key_check;\n  }\n} {c1 87 p1 0 c1 90 p1 0}\ndo_test fkey5-1.2b {\n  db eval {\n    PRAGMA main.foreign_key_check;\n  }\n} {c1 87 p1 0 c1 90 p1 0}\ndo_test fkey5-1.2c {\n  db eval {\n    PRAGMA temp.foreign_key_check;\n  }\n} {}\ndo_test fkey5-1.3 {\n  db eval {\n    PRAGMA foreign_key_check(c1);\n  }\n} {c1 87 p1 0 c1 90 p1 0}\ndo_test fkey5-1.4 {\n  db eval {\n    PRAGMA foreign_key_check(c2);\n  }\n} {}\ndo_test fkey5-1.5 {\n  db eval {\n    PRAGMA main.foreign_key_check(c2);\n  }\n} {}\ndo_test fkey5-1.6 {\n  catchsql {\n    PRAGMA temp.foreign_key_check(c2);\n  }\n} {1 {no such table: temp.c2}}\n\n# EVIDENCE-OF: R-45728-08709 There are four columns in each result row.\n#\n# EVIDENCE-OF: R-55672-01620 The first column is the name of the table\n# that contains the REFERENCES clause.\n#\n# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row\n# that contains the invalid REFERENCES clause, or NULL if the child\n# table is a WITHOUT ROWID table.\n#\n# The second clause in the previous is tested by fkey5-10.3.\n#\n# EVIDENCE-OF: R-40482-20265 The third column is the name of the table\n# that is referred to.\n#\n# EVIDENCE-OF: R-62839-07969 The fourth column is the index of the\n# specific foreign key constraint that failed.\n#\ndo_test fkey5-2.0 {\n  db eval {\n    INSERT INTO c5 SELECT x FROM c1;\n    DELETE FROM c1;\n    PRAGMA foreign_key_check;\n  }\n} {c5 1 p1 0 c5 3 p1 0}\ndo_test fkey5-2.1 {\n  db eval {\n    PRAGMA foreign_key_check(c5);\n  }\n} {c5 1 p1 0 c5 3 p1 0}\ndo_test fkey5-2.2 {\n  db eval {\n    PRAGMA foreign_key_check(c1);\n  }\n} {}\ndo_execsql_test fkey5-2.3 {\n  PRAGMA foreign_key_list(c5);\n} {0 0 p1 x {} {NO ACTION} {NO ACTION} NONE}\n\ndo_test fkey5-3.0 {\n  db eval {\n    INSERT INTO c9 SELECT x FROM c5;\n    DELETE FROM c5;\n    PRAGMA foreign_key_check;\n  }\n} {c9 1 p1 0 c9 3 p1 0}\ndo_test fkey5-3.1 {\n  db eval {\n    PRAGMA foreign_key_check(c9);\n  }\n} {c9 1 p1 0 c9 3 p1 0}\ndo_test fkey5-3.2 {\n  db eval {\n    PRAGMA foreign_key_check(c5);\n  }\n} {}\n\ndo_test fkey5-4.0 {\n  db eval {\n    DELETE FROM c9;\n    INSERT INTO c2 VALUES(79),(77),(76);\n    PRAGMA foreign_key_check;\n  }\n} {c2 76 p2 0 c2 79 p2 0}\ndo_test fkey5-4.1 {\n  db eval {\n    PRAGMA foreign_key_check(c2);\n  }\n} {c2 76 p2 0 c2 79 p2 0}\ndo_test fkey5-4.2 {\n  db eval {\n    INSERT INTO c6 SELECT x FROM c2;\n    DELETE FROM c2;\n    PRAGMA foreign_key_check;\n  }\n} {c6 1 p2 0 c6 3 p2 0}\ndo_test fkey5-4.3 {\n  db eval {\n    PRAGMA foreign_key_check(c6);\n  }\n} {c6 1 p2 0 c6 3 p2 0}\ndo_test fkey5-4.4 {\n  db eval {\n    INSERT INTO c10 SELECT x FROM c6;\n    DELETE FROM c6;\n    PRAGMA foreign_key_check;\n  }\n} {c10 1 p2 0 c10 3 p2 0}\ndo_test fkey5-4.5 {\n  db eval {\n    PRAGMA foreign_key_check(c10);\n  }\n} {c10 1 p2 0 c10 3 p2 0}\n\ndo_test fkey5-5.0 {\n  db eval {\n    DELETE FROM c10;\n    INSERT INTO c3 VALUES(68),(67),(65);\n    PRAGMA foreign_key_check;\n  }\n} {c3 65 p3 0 c3 68 p3 0}\ndo_test fkey5-5.1 {\n  db eval {\n    PRAGMA foreign_key_check(c3);\n  }\n} {c3 65 p3 0 c3 68 p3 0}\ndo_test fkey5-5.2 {\n  db eval {\n    INSERT INTO c7 SELECT x FROM c3;\n    INSERT INTO c7 VALUES('Alpha'),('alpha'),('foxtrot');\n    DELETE FROM c3;\n    PRAGMA foreign_key_check;\n  }\n} {c7 1 p3 0 c7 3 p3 0 c7 4 p3 0 c7 6 p3 0}\ndo_test fkey5-5.3 {\n  db eval {\n    PRAGMA foreign_key_check(c7);\n  }\n} {c7 1 p3 0 c7 3 p3 0 c7 4 p3 0 c7 6 p3 0}\ndo_test fkey5-5.4 {\n  db eval {\n    INSERT INTO c11 SELECT x FROM c7;\n    DELETE FROM c7;\n    PRAGMA foreign_key_check;\n  }\n} {c11 1 p3 0 c11 3 p3 0 c11 4 p3 0 c11 6 p3 0}\ndo_test fkey5-5.5 {\n  db eval {\n    PRAGMA foreign_key_check(c11);\n  }\n} {c11 1 p3 0 c11 3 p3 0 c11 4 p3 0 c11 6 p3 0}\n\ndo_test fkey5-6.0 {\n  db eval {\n    DELETE FROM c11;\n    INSERT INTO c4 VALUES(54),(55),(56);\n    PRAGMA foreign_key_check;\n  }\n} {c4 54 p4 0 c4 56 p4 0}\ndo_test fkey5-6.1 {\n  db eval {\n    PRAGMA foreign_key_check(c4);\n  }\n} {c4 54 p4 0 c4 56 p4 0}\ndo_test fkey5-6.2 {\n  db eval {\n    INSERT INTO c8 SELECT x FROM c4;\n    INSERT INTO c8 VALUES('Alpha'),('ALPHA'),('foxtrot');\n    DELETE FROM c4;\n    PRAGMA foreign_key_check;\n  }\n} {c8 1 p4 0 c8 3 p4 0 c8 6 p4 0}\ndo_test fkey5-6.3 {\n  db eval {\n    PRAGMA foreign_key_check(c8);\n  }\n} {c8 1 p4 0 c8 3 p4 0 c8 6 p4 0}\ndo_test fkey5-6.4 {\n  db eval {\n    INSERT INTO c12 SELECT x FROM c8;\n    DELETE FROM c8;\n    PRAGMA foreign_key_check;\n  }\n} {c12 1 p4 0 c12 3 p4 0 c12 6 p4 0}\ndo_test fkey5-6.5 {\n  db eval {\n    PRAGMA foreign_key_check(c12);\n  }\n} {c12 1 p4 0 c12 3 p4 0 c12 6 p4 0}\n\ndo_test fkey5-7.1 {\n  set res {}\n  db eval {\n    INSERT OR IGNORE INTO c13 SELECT * FROM c12;\n    INSERT OR IGNORE INTO C14 SELECT * FROM c12;\n    DELETE FROM c12;\n    PRAGMA foreign_key_check;\n  } {\n    lappend res [list $table $rowid $fkid $parent]\n  }\n  lsort $res\n} {{c13 1 0 p3} {c13 2 0 p3} {c13 3 0 p3} {c13 4 0 p3} {c13 5 0 p3} {c13 6 0 p3} {c14 1 0 p4} {c14 3 0 p4} {c14 6 0 p4}}\ndo_test fkey5-7.2 {\n  db eval {\n    PRAGMA foreign_key_check(c14);\n  }\n} {c14 1 p4 0 c14 3 p4 0 c14 6 p4 0}\ndo_test fkey5-7.3 {\n  db eval {\n    PRAGMA foreign_key_check(c13);\n  }\n} {c13 1 p3 0 c13 2 p3 0 c13 3 p3 0 c13 4 p3 0 c13 5 p3 0 c13 6 p3 0}\n\ndo_test fkey5-8.0 {\n  db eval {\n    DELETE FROM c13;\n    DELETE FROM c14;\n    INSERT INTO c19 VALUES('alpha','abc');\n    PRAGMA foreign_key_check(c19);\n  }\n} {c19 1 p5 0}\ndo_test fkey5-8.1 {\n  db eval {\n    DELETE FROM c19;\n    INSERT INTO c19 VALUES('Alpha','abc');\n    PRAGMA foreign_key_check(c19);\n  }\n} {}\ndo_test fkey5-8.2 {\n  db eval {\n    INSERT INTO c20 VALUES('Alpha','abc');\n    PRAGMA foreign_key_check(c20);\n  }\n} {c20 1 p5 0}\ndo_test fkey5-8.3 {\n  db eval {\n    DELETE FROM c20;\n    INSERT INTO c20 VALUES('abc','Alpha');\n    PRAGMA foreign_key_check(c20);\n  }\n} {}\ndo_test fkey5-8.4 {\n  db eval {\n    INSERT INTO c21 VALUES('alpha','abc    ');\n    PRAGMA foreign_key_check(c21);\n  }\n} {}\ndo_test fkey5-8.5 {\n  db eval {\n    DELETE FROM c21;\n    INSERT INTO c19 VALUES('Alpha','abc');\n    PRAGMA foreign_key_check(c21);\n  }\n} {}\ndo_test fkey5-8.6 {\n  db eval {\n    INSERT INTO c22 VALUES('Alpha','abc');\n    PRAGMA foreign_key_check(c22);\n  }\n} {c22 1 p6 0}\ndo_test fkey5-8.7 {\n  db eval {\n    DELETE FROM c22;\n    INSERT INTO c22 VALUES('abc  ','ALPHA');\n    PRAGMA foreign_key_check(c22);\n  }\n} {}\n\n\n#-------------------------------------------------------------------------\n# Tests 9.* verify that missing parent tables are handled correctly.\n#\ndo_execsql_test 9.1.1 {\n  CREATE TABLE k1(x REFERENCES s1);\n  PRAGMA foreign_key_check(k1);\n} {}\ndo_execsql_test 9.1.2 {\n  INSERT INTO k1 VALUES(NULL);\n  PRAGMA foreign_key_check(k1);\n} {}\ndo_execsql_test 9.1.3 {\n  INSERT INTO k1 VALUES(1);\n  PRAGMA foreign_key_check(k1);\n} {k1 2 s1 0}\n\ndo_execsql_test 9.2.1 {\n  CREATE TABLE k2(x, y, FOREIGN KEY(x, y) REFERENCES s1(a, b));\n  PRAGMA foreign_key_check(k2);\n} {}\ndo_execsql_test 9.2 {\n  INSERT INTO k2 VALUES(NULL, 'five');\n  PRAGMA foreign_key_check(k2);\n} {}\ndo_execsql_test 9.3 {\n  INSERT INTO k2 VALUES('one', NULL);\n  PRAGMA foreign_key_check(k2);\n} {}\ndo_execsql_test 9.4 {\n  INSERT INTO k2 VALUES('six', 'seven');\n  PRAGMA foreign_key_check(k2);\n} {k2 3 s1 0}\n\n#-------------------------------------------------------------------------\n# Test using a WITHOUT ROWID table as the child table with an INTEGER \n# PRIMARY KEY as the parent key.\n#\nreset_db\ndo_execsql_test 10.1 {\n  CREATE TABLE p30 (id INTEGER PRIMARY KEY);\n  CREATE TABLE IF NOT EXISTS c30 (\n      line INTEGER, \n      master REFERENCES p30(id), \n      PRIMARY KEY(master)\n  ) WITHOUT ROWID;\n\n  INSERT INTO p30 (id) VALUES (1);\n  INSERT INTO c30 (master, line)  VALUES (1, 999);\n}\ndo_execsql_test 10.2 {\n  PRAGMA foreign_key_check;\n}\n# EVIDENCE-OF: R-00471-55166 The second column is the rowid of the row\n# that contains the invalid REFERENCES clause, or NULL if the child\n# table is a WITHOUT ROWID table.\ndo_execsql_test 10.3 {\n  INSERT INTO c30 VALUES(45, 45);\n  PRAGMA foreign_key_check;\n} {c30 {} p30 0}\n\n#-------------------------------------------------------------------------\n# Test \"foreign key mismatch\" errors.\n#\nreset_db\ndo_execsql_test 11.0 {\n  CREATE TABLE tt(y);\n  CREATE TABLE c11(x REFERENCES tt(y));\n}\ndo_catchsql_test 11.1 {\n  PRAGMA foreign_key_check;\n} {1 {foreign key mismatch - \"c11\" referencing \"tt\"}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey6.test",
    "content": "# 2012 December 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests the PRAGMA defer_foreign_keys and \n# SQLITE_DBSTATUS_DEFERRED_FKS\n#\n# EVIDENCE-OF: R-18981-16292 When the defer_foreign_keys PRAGMA is on,\n# enforcement of all foreign key constraints is delayed until the\n# outermost transaction is committed.\n#\n# EVIDENCE-OF: R-28911-57501 The defer_foreign_keys pragma defaults to\n# OFF so that foreign key constraints are only deferred if they are\n# created as \"DEFERRABLE INITIALLY DEFERRED\".\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fkey6\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\n\ndo_execsql_test fkey6-1.0 {\n  PRAGMA defer_foreign_keys;\n} {0}\n\ndo_execsql_test fkey6-1.1 {\n  PRAGMA foreign_keys=ON;\n  CREATE TABLE t1(x INTEGER PRIMARY KEY);\n  CREATE TABLE t2(y INTEGER PRIMARY KEY,\n          z INTEGER REFERENCES t1(x) DEFERRABLE INITIALLY DEFERRED);\n  CREATE INDEX t2z ON t2(z);\n  CREATE TABLE t3(u INTEGER PRIMARY KEY, v INTEGER REFERENCES t1(x));\n  CREATE INDEX t3v ON t3(v);\n  INSERT INTO t1 VALUES(1),(2),(3),(4),(5);\n  INSERT INTO t2 VALUES(1,1),(2,2);\n  INSERT INTO t3 VALUES(3,3),(4,4);\n} {}\ndo_test fkey6-1.2 {\n  catchsql {DELETE FROM t1 WHERE x=2;}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test fkey6-1.3 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 0 0}\ndo_test fkey6-1.4 {\n  execsql {\n    BEGIN;\n    DELETE FROM t1 WHERE x=1;\n  }\n} {}\ndo_test fkey6-1.5.1 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 1\n} {0 1 0}\ndo_test fkey6-1.5.2 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 1 0}\ndo_test fkey6-1.6 {\n  execsql {\n    ROLLBACK;\n  }\n} {}\ndo_test fkey6-1.7 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 0 0}\ndo_test fkey6-1.8 {\n  execsql {\n    PRAGMA defer_foreign_keys=ON;\n    BEGIN;\n    DELETE FROM t1 WHERE x=3;\n  }\n} {}\ndo_test fkey6-1.9 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 1 0}\n\n# EVIDENCE-OF: R-21752-26913 The defer_foreign_keys pragma is\n# automatically switched off at each COMMIT or ROLLBACK. Hence, the\n# defer_foreign_keys pragma must be separately enabled for each\n# transaction.\ndo_execsql_test fkey6-1.10.1 {\n  PRAGMA defer_foreign_keys;\n  ROLLBACK;\n  PRAGMA defer_foreign_keys;\n  BEGIN;\n  PRAGMA defer_foreign_keys=ON;\n  PRAGMA defer_foreign_keys;\n  COMMIT;\n  PRAGMA defer_foreign_keys;\n  BEGIN;\n} {1 0 1 0}\ndo_test fkey6-1.10.2 {\n  catchsql {DELETE FROM t1 WHERE x=3}\n} {1 {FOREIGN KEY constraint failed}}\ndb eval {ROLLBACK}\n\ndo_test fkey6-1.20 {\n  execsql {\n    BEGIN;\n    DELETE FROM t1 WHERE x=1;\n  }\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 1 0}\ndo_test fkey6-1.21 {\n  execsql {\n    DELETE FROM t2 WHERE y=1;\n  }\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 0 0}\ndo_test fkey6-1.22 {\n  execsql {\n    COMMIT;\n  }\n} {}\n\ndo_execsql_test fkey6-2.1 {\n  CREATE TABLE p1(a PRIMARY KEY);\n  INSERT INTO p1 VALUES('one'), ('two');\n  CREATE TABLE c1(x REFERENCES p1);\n  INSERT INTO c1 VALUES('two'), ('one');\n}\n\ndo_execsql_test fkey6-2.2 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    DELETE FROM p1;\n  ROLLBACK;\n  PRAGMA defer_foreign_keys;\n} {0}\n\ndo_execsql_test fkey6-2.3 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    DROP TABLE p1;\n    PRAGMA vdbe_trace = 0;\n  ROLLBACK;\n  PRAGMA defer_foreign_keys;\n} {0}\n\ndo_execsql_test fkey6-2.4 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    DELETE FROM p1;\n    DROP TABLE c1;\n  COMMIT;\n  PRAGMA defer_foreign_keys;\n} {0}\n\ndo_execsql_test fkey6-2.5 {\n  DROP TABLE p1;\n  CREATE TABLE p1(a PRIMARY KEY);\n  INSERT INTO p1 VALUES('one'), ('two');\n  CREATE TABLE c1(x REFERENCES p1);\n  INSERT INTO c1 VALUES('two'), ('one');\n}\n\ndo_execsql_test fkey6-2.6 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    INSERT INTO c1 VALUES('three');\n    DROP TABLE c1;\n  COMMIT;\n  PRAGMA defer_foreign_keys;\n} {0}\n\n#--------------------------------------------------------------------------\n# Test that defer_foreign_keys disables RESTRICT.\n#\ndo_execsql_test 3.1 {\n  CREATE TABLE p2(a PRIMARY KEY, b);\n  CREATE TABLE c2(x, y REFERENCES p2 ON DELETE RESTRICT ON UPDATE RESTRICT);\n  INSERT INTO p2 VALUES(1, 'one');\n  INSERT INTO p2 VALUES(2, 'two');\n  INSERT INTO c2 VALUES('i', 1);\n}\n\ndo_catchsql_test 3.2.1 {\n  BEGIN;\n    UPDATE p2 SET a=a-1;\n} {1 {FOREIGN KEY constraint failed}}\ndo_execsql_test 3.2.2 { COMMIT }\n\ndo_execsql_test 3.2.3 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    UPDATE p2 SET a=a-1;\n  COMMIT;\n}\n\ndo_execsql_test 3.2.4 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    UPDATE p2 SET a=a-1;\n}\ndo_catchsql_test 3.2.5 {\n  COMMIT;\n} {1 {FOREIGN KEY constraint failed}}\ndo_execsql_test 3.2.6 { ROLLBACK }\n\ndo_execsql_test 3.3.1 {\n  CREATE TRIGGER p2t AFTER DELETE ON p2 BEGIN\n    INSERT INTO p2 VALUES(old.a, 'deleted!');\n  END;\n}\ndo_catchsql_test 3.3.2 {\n  BEGIN;\n    DELETE FROM p2 WHERE a=1;\n} {1 {FOREIGN KEY constraint failed}}\ndo_execsql_test 3.3.3 { COMMIT }\n\ndo_execsql_test 3.3.4 {\n  BEGIN;\n    PRAGMA defer_foreign_keys = 1;\n    DELETE FROM p2 WHERE a=1;\n  COMMIT;\n  SELECT * FROM p2;\n} {0 one 1 deleted!}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey7.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fkey7\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  PRAGMA foreign_keys = 1;\n\n  CREATE TABLE s1(a PRIMARY KEY, b);\n  CREATE TABLE par(a, b REFERENCES s1, c UNIQUE, PRIMARY KEY(a));\n\n  CREATE TABLE c1(a, b REFERENCES par);\n  CREATE TABLE c2(a, b REFERENCES par);\n  CREATE TABLE c3(a, b REFERENCES par(c));\n}\n\nproc auth {op tbl args} {\n  if {$op == \"SQLITE_READ\"} { set ::tbls($tbl) 1 }\n  return \"SQLITE_OK\"\n}\ndb auth auth\ndb cache size 0\nproc do_tblsread_test {tn sql tbllist} {\n  array unset ::tbls\n  uplevel [list execsql $sql]\n  uplevel [list do_test $tn {lsort [array names ::tbls]} $tbllist]\n}\n\ndo_tblsread_test 1.2 { UPDATE par SET b=? WHERE a=? } {par s1}\ndo_tblsread_test 1.3 { UPDATE par SET a=? WHERE b=? } {c1 c2 par}\ndo_tblsread_test 1.4 { UPDATE par SET c=? WHERE b=? } {c3 par}\ndo_tblsread_test 1.5 { UPDATE par SET a=?,b=?,c=? WHERE b=? } {c1 c2 c3 par s1}\n\nifcapable incrblob {\n  do_execsql_test 2.0 {\n    CREATE TABLE pX(x PRIMARY KEY);\n    CREATE TABLE cX(a INTEGER PRIMARY KEY, b REFERENCES pX);\n  }\n  \n  do_catchsql_test 2.1 {\n    INSERT INTO cX VALUES(11, zeroblob(40));\n  } {1 {FOREIGN KEY constraint failed}}\n  \n  do_test 2.2 {\n    set stmt [sqlite3_prepare_v2 db \"INSERT INTO cX VALUES(11, ?)\" -1]\n    sqlite3_bind_zeroblob $stmt 1 45\n    sqlite3_step $stmt\n    sqlite3_finalize $stmt\n  } {SQLITE_CONSTRAINT}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey8.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fkey8\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\ndo_execsql_test 1.0 { PRAGMA foreign_keys = 1; }\n\n\nforeach {tn use_stmt sql schema} {\n  1   1 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1);\n  }\n\n  2.1     0 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE);\n  }\n  2.2   0 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE SET NULL);\n  }\n  2.3   1 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE SET DEFAULT);\n  }\n\n  3   1 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE);\n    CREATE TRIGGER ct1 AFTER DELETE ON c1 BEGIN\n      INSERT INTO p1 VALUES('x');\n    END;\n  }\n\n  4   1 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);\n    CREATE TABLE cc1(d REFERENCES c1);\n  }\n\n  5.1   0 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);\n    CREATE TABLE cc1(d REFERENCES c1 ON DELETE CASCADE);\n  }\n  5.2   0 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);\n    CREATE TABLE cc1(d REFERENCES c1 ON DELETE SET NULL);\n  }\n  5.3   1 \"DELETE FROM p1\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON DELETE CASCADE, c PRIMARY KEY);\n    CREATE TABLE cc1(d REFERENCES c1 ON DELETE SET DEFAULT);\n  }\n\n  6.1   1 \"UPDATE p1 SET a = ?\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON UPDATE SET NULL, c);\n  }\n  6.2   0 \"UPDATE OR IGNORE p1 SET a = ?\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON UPDATE SET NULL, c);\n  }\n  6.3   1 \"UPDATE OR IGNORE p1 SET a = ?\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b REFERENCES p1 ON UPDATE CASCADE, c);\n  }\n  6.4   1 \"UPDATE OR IGNORE p1 SET a = ?\" {\n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(b NOT NULL REFERENCES p1 ON UPDATE SET NULL, c);\n  }\n\n} {\n  drop_all_tables\n  do_test 1.$tn {\n    execsql $schema\n    set stmt [sqlite3_prepare_v2 db $sql -1 dummy]\n    set ret [uses_stmt_journal $stmt]\n    sqlite3_finalize $stmt\n    set ret\n  } $use_stmt\n}\n\n#-------------------------------------------------------------------------\n# The following tests check that foreign key constaint counters are\n# correctly updated for any implicit DELETE operations that occur\n# when a REPLACE command is executed against a WITHOUT ROWID table\n# that has no triggers or auxiliary indexes.\n#\nreset_db\ndo_execsql_test 2.1.0 {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE p1(a PRIMARY KEY, b) WITHOUT ROWID;\n  CREATE TABLE c1(x REFERENCES p1 DEFERRABLE INITIALLY DEFERRED);\n\n  INSERT INTO p1 VALUES(1, 'one');\n  INSERT INTO p1 VALUES(2, 'two');\n  INSERT INTO c1 VALUES(1);\n  INSERT INTO c1 VALUES(2);\n}\n\ndo_catchsql_test 2.1.2 {\n  BEGIN;\n    DELETE FROM p1 WHERE a=1;\n    INSERT OR REPLACE INTO p1 VALUES(2, 'two');\n  COMMIT;\n} {1 {FOREIGN KEY constraint failed}}\n\nreset_db\ndo_execsql_test 2.2.0 {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE p2(a PRIMARY KEY, b);\n  CREATE TABLE c2(\n    x PRIMARY KEY,\n    y REFERENCES p2 DEFERRABLE INITIALLY DEFERRED\n  ) WITHOUT ROWID;\n}\n\ndo_catchsql_test 2.2.1 {\n  BEGIN;\n    INSERT INTO c2 VALUES(13, 13);\n    INSERT OR REPLACE INTO c2 VALUES(13, 13);\n    DELETE FROM c2;\n  COMMIT;\n} {0 {}}\n\nreset_db\ndo_execsql_test 2.3.0 {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE p3(a PRIMARY KEY, b) WITHOUT ROWID;\n  CREATE TABLE c3(x REFERENCES p3);\n\n  INSERT INTO p3 VALUES(1, 'one');\n  INSERT INTO p3 VALUES(2, 'two');\n  INSERT INTO c3 VALUES(1);\n  INSERT INTO c3 VALUES(2);\n\n  CREATE TRIGGER p3d AFTER DELETE ON p3 WHEN old.a=1 BEGIN\n    INSERT OR REPLACE INTO p3 VALUES(2, 'three');\n  END;\n}\n\ndo_catchsql_test 2.3.1 {\n  DELETE FROM p3 WHERE a=1\n} {1 {FOREIGN KEY constraint failed}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fkey_malloc.test",
    "content": "# 2009 September 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !foreignkey||!trigger {\n  finish_test\n  return\n}\nsource $testdir/malloc_common.tcl\n\ndo_malloc_test fkey_malloc-1 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n  CREATE TABLE t2(x REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE);\n} -sqlbody {\n  INSERT INTO t1 VALUES('aaa', 1);\n  INSERT INTO t2 VALUES('aaa');\n  UPDATE t1 SET a = 'bbb';\n  DELETE FROM t1;\n  PRAGMA foreign_key_check;\n}\n\ndo_malloc_test fkey_malloc-2 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(a, b, UNIQUE(a, b));\n} -sqlbody {\n  CREATE TABLE t2(x, y, \n    FOREIGN KEY(x, y) REFERENCES t1(a, b) DEFERRABLE INITIALLY DEFERRED\n  );\n  BEGIN;\n    INSERT INTO t2 VALUES('a', 'b');\n    INSERT INTO t1 VALUES('a', 'b');\n    UPDATE t1 SET a = 'c';\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES('d', 'b');\n    UPDATE t2 SET x = 'c';\n  COMMIT;\n}\n\ndo_malloc_test fkey_malloc-3 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(x INTEGER PRIMARY KEY);\n  CREATE TABLE t2(y DEFAULT 14 REFERENCES t1(x) ON UPDATE SET DEFAULT);\n  CREATE TABLE t3(y REFERENCES t1 ON UPDATE SET NULL);\n  INSERT INTO t1 VALUES(13);\n  INSERT INTO t2 VALUES(13);\n  INSERT INTO t3 VALUES(13);\n} -sqlbody {\n  UPDATE t1 SET x = 14;\n}\n\nproc catch_fk_error {zSql} {\n  set rc [catch {db eval $zSql} msg]\n  if {$rc==0} {\n    return $msg\n  }\n  if {[string match {*foreign key*} $msg]} {\n    return \"\"\n  }\n  if {$msg eq \"out of memory\" \n   || $msg eq \"FOREIGN KEY constraint failed\"\n   || $msg eq \"constraint failed\"\n  } {\n    error 1\n  }\n  error $msg\n}\n\ndo_malloc_test fkey_malloc-4 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE);\n  CREATE TABLE t2(z REFERENCES t1(x), a REFERENCES t1(y));\n  CREATE TABLE t3(x);\n  CREATE TABLE t4(z REFERENCES t3);\n  CREATE TABLE t5(x, y);\n  CREATE TABLE t6(z REFERENCES t5(x));\n  CREATE INDEX i51 ON t5(x);\n  CREATE INDEX i52 ON t5(y, x);\n  INSERT INTO t1 VALUES(1, 2);\n} -tclbody {\n  catch_fk_error {INSERT INTO t2 VALUES(1, 3)}\n  catch_fk_error {INSERT INTO t4 VALUES(2)}\n  catch_fk_error {INSERT INTO t6 VALUES(2)}\n}\n\ndo_malloc_test fkey_malloc-5 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(x, y, PRIMARY KEY(x, y));\n  CREATE TABLE t2(a, b, FOREIGN KEY(a, b) REFERENCES t1 ON UPDATE CASCADE);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t2 VALUES(1, 2);\n} -sqlbody {\n  UPDATE t1 SET x = 5;\n}\n\ndo_malloc_test fkey_malloc-6 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(\n    x PRIMARY KEY, \n    y REFERENCES t1 ON DELETE RESTRICT ON UPDATE SET DEFAULT\n  );\n  INSERT INTO t1 VALUES('abc', 'abc');\n  INSERT INTO t1 VALUES('def', 'def');\n} -sqlbody {\n  INSERT INTO t1 VALUES('ghi', 'ghi');\n  DELETE FROM t1 WHERE rowid>1;\n  UPDATE t1 SET x='jkl', y='jkl';\n}\n\ndo_malloc_test fkey_malloc-7 -sqlprep {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE x(a, b, PRIMARY KEY(a, b));\n  CREATE TABLE y(c, d,\n    FOREIGN KEY(d, c) REFERENCES x DEFERRABLE INITIALLY DEFERRED\n  );\n  CREATE TABLE z(e, f, FOREIGN KEY(e, f) REFERENCES x);\n} -sqlbody {\n  DROP TABLE y;\n  DROP TABLE x;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fordelete.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n# $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix fordelete\n\n# This function returns a list of the tables or indexes opened with \n# OP_OpenWrite instructions when the SQL statement passed as the only \n# argument is executed. If the OPFLAG_FORDELETE flag is specified on\n# the OP_OpenWrite, an asterix is appended to the object name. The list \n# is sorted in [lsort] order before it is returned.\n#\nproc analyze_delete_program {sql} {\n  # Build a map from root page to table/index name.\n  db eval {\n    SELECT name, rootpage FROM sqlite_master\n  } {\n    set T($rootpage) $name\n  }\n  \n  # For each OpenWrite instruction generated for the proposed DELETE\n  # statement, add the following array entries:\n  #\n  #   $M(<cursor number>) -> <object name>\n  #   $O(<object name>)   -> \"*\" | \"\"\n  #\n  # The O() entry is set to \"*\" if the BTREE_FORDELETE flag is specified,\n  # or \"\" otherwise.\n  #\n  db eval \"EXPLAIN $sql\" R {\n    if {$R(opcode)==\"OpenWrite\"} {\n      set root $R(p2)\n      set csr $R(p1)\n      if {[info exists T($root)]} { set M($csr) $T($root) }\n\n      set obj $T($root)\n      set O($obj) \"\"\n      if {\"0x$R(p5)\" & 0x08} { \n        set O($obj) *\n      } else {\n        set O($obj) \"\"\n      }\n    }\n  }\n\n  db eval \"EXPLAIN $sql\" R {\n    if {$R(opcode) == \"Delete\"} {\n      set csr $R(p1)\n      if {[info exists M($csr)]} {\n        set idxdelete [expr {(\"0x$R(p5)\" & 0x04) ? 1 : 0}]\n        if {$idxdelete} {\n          append O($M($csr)) \"+\"\n        }\n      }\n    }\n  }\n\n  set res [list]\n  foreach {k v} [array get O] {\n    lappend res \"${k}${v}\"\n  }\n\n  lsort $res\n}\n\nproc do_adp_test {tn sql res} {\n  uplevel [list do_test $tn [list analyze_delete_program $sql] [list {*}$res]]\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b);\n}\n\nforeach {tn sql res} {\n  1 { DELETE FROM t1 WHERE a=?}          { sqlite_autoindex_t1_1  t1*+ }\n  2 { DELETE FROM t1 WHERE a=? AND b=? } { sqlite_autoindex_t1_1  t1+  }\n  3 { DELETE FROM t1 WHERE a>? }         { sqlite_autoindex_t1_1  t1*+ }\n  4 { DELETE FROM t1 WHERE rowid=? }     { sqlite_autoindex_t1_1*  t1  }\n} {\n  do_adp_test 1.$tn $sql $res\n}\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a, b, c);\n  CREATE INDEX t2a ON t2(a);\n  CREATE INDEX t2b ON t2(b);\n  CREATE INDEX t2c ON t2(c);\n}\nforeach {tn sql res} {\n  1 { DELETE FROM t2 WHERE a=?}          { t2*+ t2a t2b* t2c* }\n  2 { DELETE FROM t2 WHERE a=? AND +b=?} { t2+ t2a t2b* t2c* }\n  3 { DELETE FROM t2 WHERE a=? OR b=?}   { t2 t2a* t2b* t2c* }\n  4 { DELETE FROM t2 WHERE +a=? }        { t2 t2a* t2b* t2c* }\n  5 { DELETE FROM t2 WHERE rowid=? }     { t2 t2a* t2b* t2c* }\n} {\n  do_adp_test 2.$tn $sql $res\n}\n\n#-------------------------------------------------------------------------\n# Test that a record that consists of the bytes:\n#\n#   0x01 0x00\n#\n# is interpreted by OP_Column as a vector of NULL values (assuming the \n# default column values are NULL). Also test that:\n#\n#   0x00\n#\n# is handled in the same way.\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c, d);\n  CREATE TABLE x2(a INTEGER PRIMARY KEY, b, c, d);\n}\n\ndo_test 3.1 {\n  set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x1' }]\n  db eval { \n    BEGIN IMMEDIATE;\n  }\n  set bt [btree_from_db db]\n  set csr [btree_cursor $bt $root 1]\n  btree_insert $csr 5 \"\\000\"\n  btree_close_cursor $csr\n  db eval { COMMIT }\n\n  db eval {\n    SELECT * FROM x1;\n  }\n} {5 {} {} {}}\n\ndo_test 3.2 {\n  set root [db one { SELECT rootpage FROM sqlite_master WHERE name = 'x2' }]\n  db eval { \n    BEGIN IMMEDIATE;\n  }\n  set bt [btree_from_db db]\n  set csr [btree_cursor $bt $root 1]\n  btree_insert $csr 6 \"\\000\"\n  btree_close_cursor $csr\n  db eval { COMMIT }\n\n  db eval {\n    SELECT * FROM x2;\n  }\n} {6 {} {} {}}\n\n\n#-------------------------------------------------------------------------\n#\nreset_db \ndo_execsql_test 4.0 {\n  CREATE TABLE log(x);\n  CREATE TABLE p1(one PRIMARY KEY, two);\n\n  CREATE TRIGGER tr_bd BEFORE DELETE ON p1 BEGIN\n    INSERT INTO log VALUES('delete');\n  END;\n  INSERT INTO p1 VALUES('a', 'A'), ('b', 'B'), ('c', 'C');\n  DELETE FROM p1 WHERE one = 'a';\n}\n\nreset_db\ndo_execsql_test 4.1 {\n  BEGIN TRANSACTION;\n  CREATE TABLE tbl(a PRIMARY KEY, b, c);\n  CREATE TABLE log(a, b, c);\n  INSERT INTO \"tbl\" VALUES(1,2,3);\n  CREATE TRIGGER the_trigger BEFORE DELETE ON tbl BEGIN \n    INSERT INTO log VALUES(1, 2,3);\n  END;\n  COMMIT;\n  DELETE FROM tbl WHERE a=1;\n}\n\nreset_db\ndo_execsql_test 5.1 {\n  PRAGMA foreign_keys = 1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t2(\n      c INTEGER PRIMARY KEY,\n      d INTEGER DEFAULT 1 REFERENCES t1 ON DELETE SET DEFAULT\n  );\n} {}\ndo_execsql_test 5.2 {\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n  INSERT INTO t2 VALUES(1, 2);\n  SELECT * FROM t2;\n} {1 2}\ndo_execsql_test 5.3 {\n  DELETE FROM t1 WHERE a = 2;\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/format4.test",
    "content": "# 2005 December 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that the new serial_type\n# values of 8 (integer 0) and 9 (integer 1) work correctly.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndb eval {PRAGMA legacy_file_format=OFF}\n\n# The size of the database depends on whether or not autovacuum\n# is enabled.\n#\nifcapable autovacuum {\n  if {[db one {PRAGMA auto_vacuum}]} {\n    set small 3072\n    set large 5120\n  } else {\n    set small 2048\n    set large 4096\n  }\n} else {\n  set small 2048\n  set large 4096\n}\n\ndo_test format4-1.1 {\n  execsql {\n    CREATE TABLE t1(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);\n    INSERT INTO t1 VALUES(0,0,0,0,0,0,0,0,0,0);\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n  }\n  file size test.db\n} $small\ndo_test format4-1.2 {\n  execsql {\n    UPDATE t1 SET x0=1, x1=1, x2=1, x3=1, x4=1, x5=1, x6=1, x7=1, x8=1, x9=1\n  }\n  file size test.db\n} $small\ndo_test format4-1.3 {\n  execsql {\n    UPDATE t1 SET x0=2, x1=2, x2=2, x3=2, x4=2, x5=2, x6=2, x7=2, x8=2, x9=2\n  }\n  file size test.db\n} $large\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts-9fd058691.test",
    "content": "# 2011 October 13\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for the FTS SQLite module.\n#\n# This file implements tests to verify that ticket [9fd058691] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset ::testprefix fts3-9fd058691\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE fts USING fts3( tags TEXT);\n  INSERT INTO fts (tags) VALUES ('tag1');\n  SELECT * FROM fts WHERE tags MATCH 'tag1';\n} {tag1}\n\ndo_test 1.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    UPDATE fts SET tags = 'tag1' WHERE rowid = 1;\n    SELECT * FROM fts WHERE tags MATCH 'tag1';\n  }\n} {tag1}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE fts USING fts3(tags TEXT);\n  INSERT INTO fts (docid, tags) VALUES (1, 'tag1');\n  INSERT INTO fts (docid, tags) VALUES (2, NULL);\n  INSERT INTO fts (docid, tags) VALUES (3, 'three');\n} {}\n\ndo_test 2.1 {\n  execsql {\n    UPDATE fts SET tags = 'two' WHERE rowid = 2;\n    SELECT * FROM fts WHERE tags MATCH 'two';\n  }\n} {two}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1a.test",
    "content": "# 2006 September 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS1 module.\n#\n# $Id: fts1a.test,v 1.4 2006/09/28 19:43:32 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(content);\n  INSERT INTO t1(content) VALUES('one');\n  INSERT INTO t1(content) VALUES('two');\n  INSERT INTO t1(content) VALUES('one two');\n  INSERT INTO t1(content) VALUES('three');\n  INSERT INTO t1(content) VALUES('one three');\n  INSERT INTO t1(content) VALUES('two three');\n  INSERT INTO t1(content) VALUES('one two three');\n  INSERT INTO t1(content) VALUES('four');\n  INSERT INTO t1(content) VALUES('one four');\n  INSERT INTO t1(content) VALUES('two four');\n  INSERT INTO t1(content) VALUES('one two four');\n  INSERT INTO t1(content) VALUES('three four');\n  INSERT INTO t1(content) VALUES('one three four');\n  INSERT INTO t1(content) VALUES('two three four');\n  INSERT INTO t1(content) VALUES('one two three four');\n  INSERT INTO t1(content) VALUES('five');\n  INSERT INTO t1(content) VALUES('one five');\n  INSERT INTO t1(content) VALUES('two five');\n  INSERT INTO t1(content) VALUES('one two five');\n  INSERT INTO t1(content) VALUES('three five');\n  INSERT INTO t1(content) VALUES('one three five');\n  INSERT INTO t1(content) VALUES('two three five');\n  INSERT INTO t1(content) VALUES('one two three five');\n  INSERT INTO t1(content) VALUES('four five');\n  INSERT INTO t1(content) VALUES('one four five');\n  INSERT INTO t1(content) VALUES('two four five');\n  INSERT INTO t1(content) VALUES('one two four five');\n  INSERT INTO t1(content) VALUES('three four five');\n  INSERT INTO t1(content) VALUES('one three four five');\n  INSERT INTO t1(content) VALUES('two three four five');\n  INSERT INTO t1(content) VALUES('one two three four five');\n}\n\ndo_test fts1a-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts1a-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts1a-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts1a-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}\n} {7 15 23 31}\ndo_test fts1a-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}\n} {7 15 23 31}\ndo_test fts1a-1.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}\n} {7 15 23 31}\ndo_test fts1a-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}\n} {7 15 23 31}\ndo_test fts1a-1.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}\n} {7 15 23 31}\ndo_test fts1a-1.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}\n} {7 15 23 31}\ndo_test fts1a-1.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}\n} {7 15 23 31}\ndo_test fts1a-1.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '  ONE    Two   three  '}\n} {7 15 23 31}\n\ndo_test fts1a-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one\"'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts1a-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\"'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts1a-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"two one\"'}\n} {}\ndo_test fts1a-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three\"'}\n} {7 15 23 31}\ndo_test fts1a-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two\"'}\n} {}\ndo_test fts1a-2.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three four\"'}\n} {15 31}\ndo_test fts1a-2.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two four\"'}\n} {}\ndo_test fts1a-2.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three five\"'}\n} {21}\ndo_test fts1a-2.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" five'}\n} {21 29}\ndo_test fts1a-2.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\"'}\n} {21 29}\ndo_test fts1a-2.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\" four'}\n} {29}\ndo_test fts1a-2.12 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four \"one three\"'}\n} {29}\ndo_test fts1a-2.13 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" four five'}\n} {29}\n\ndo_test fts1a-3.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts1a-3.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}\n} {1 5 9 13 17 21 25 29}\ndo_test fts1a-3.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}\n} {1 5 9 13 17 21 25 29}\n\ndo_test fts1a-4.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}\n} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}\ndo_test fts1a-4.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\" OR three'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts1a-4.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR \"one two\"'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts1a-4.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts1a-4.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts1a-4.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\ndo_test fts1a-4.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\n\n# Test the ability to handle NULL content\n#\ndo_test fts1a-5.1 {\n  execsql {INSERT INTO t1(content) VALUES(NULL)}\n} {}\ndo_test fts1a-5.2 {\n  set rowid [db last_insert_rowid]\n  execsql {SELECT content FROM t1 WHERE rowid=$rowid}\n} {{}}\ndo_test fts1a-5.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}\n} {}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1b.test",
    "content": "# 2006 September 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS1 module.\n#\n# $Id: fts1b.test,v 1.4 2006/09/18 02:12:48 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Fill the full-text index \"t1\" with phrases in english, spanish,\n# and german.  For the i-th row, fill in the names for the bits\n# that are set in the value of i.  The least significant bit is\n# 1.  For example,  the value 5 is 101 in binary which will be\n# converted to \"one three\" in english.\n#\nproc fill_multilanguage_fulltext_t1 {} {\n  set english {one two three four five}\n  set spanish {un dos tres cuatro cinco}\n  set german {eine zwei drei vier funf}\n  \n  for {set i 1} {$i<=31} {incr i} {\n    set cmd \"INSERT INTO t1 VALUES\"\n    set vset {}\n    foreach lang {english spanish german} {\n      set words {}\n      for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n        if {$k&$i} {lappend words [lindex [set $lang] $j]}\n      }\n      lappend vset \"'$words'\"\n    }\n    set sql \"INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])\"\n    # puts $sql\n    db eval $sql\n  }\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(english,spanish,german);\n}\nfill_multilanguage_fulltext_t1\n\ndo_test fts1b-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts1b-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}\n} {}\ndo_test fts1b-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}\n} {}\ndo_test fts1b-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts1b-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}\n} {7 15 23 31}\ndo_test fts1b-1.6 {\n  execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}\n} {one un eine}\ndo_test fts1b-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"one un\"'}\n} {}\n\ndo_test fts1b-2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t2 USING fts1(from,to);\n    INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');\n    SELECT [from], [to] FROM t2\n  }\n} {{one two three} {four five six}}\n\n\n# Compute an SQL string that contains the words one, two, three,... to\n# describe bits set in the value $i.  Only the lower 5 bits are examined.\n#\nproc wordset {i} {\n  set x {}\n  for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n    if {$k&$i} {lappend x [lindex {one two three four five} $j]}\n  }\n  return '$x'\n}\n\n# Create a new FTS table with three columns:\n#\n#    norm:      words for the bits of rowid\n#    plusone:   words for the bits of rowid+1\n#    invert:    words for the bits of ~rowid\n#\ndb eval {\n   CREATE VIRTUAL TABLE t4 USING fts1([norm],'plusone',\"invert\");\n}\nfor {set i 1} {$i<=15} {incr i} {\n  set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]\n  db eval \"INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);\"\n}\n\ndo_test fts1b-4.1 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts1b-4.2 {\n  execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts1b-4.3 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}\ndo_test fts1b-4.4 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}\n} {2 4 6 8 10 12 14}\ndo_test fts1b-4.5 {\n  execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}\n} {2 4 6 8 10 12 14}\ndo_test fts1b-4.6 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}\n} {1 5 9 13}\ndo_test fts1b-4.7 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts1b-4.8 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}\n} {1 5 9 13}\ndo_test fts1b-4.9 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}\n} {1 3 5 7 9 11 13 15}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1c.test",
    "content": "# 2006 September 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS1 module.\n#\n# $Id: fts1c.test,v 1.11 2006/10/04 17:35:28 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Create a table of sample email data.   The data comes from email\n# archives of Enron executives that was published as part of the\n# litigation against that company.\n#\ndo_test fts1c-1.1 {\n  db eval {\n    CREATE VIRTUAL TABLE email USING fts1([from],[to],subject,body);\n    BEGIN TRANSACTION;\nINSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.\n\nThe volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below: \n\n?\tIf the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.\n?\tIf the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.\n?\tFor all other volumes, the same rounding rules will apply based on the volume increment on the parent product.\n\nPlease see example below:\n\nParent''s Settings:\nMinimum: \t5000\nIncrement:  1000\n\nVolume on Autohedge transaction\t\t\tVolume Hedged\n1      - 2499\t\t\t\t\t\t\t0\n2500 - 5499\t\t\t\t\t\t\t5000\n5500 - 6499\t\t\t\t\t\t\t6000');\nINSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:  \nIf it''s ok with everyone''s needs, I would like to leave @4pm. If you think \nyou will need my assistance past the 4 o''clock hour just let me know;  I''ll \nbe more than willing to stay.');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:\n\nEmployee Name: Christopher F. Calger\nStatus last changed by: Mollie E. Gustafson Ms\nExpense Report Name: CC02.06.02\nReport Total: $3,972.93\nAmount Due Employee: $3,972.93\n\n\nTo approve this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,\n\nCould you print off the current work request report by 1:30 today?\n\nGentlemen,\n\nI''d like to review this today at 1:30 in our office.  Also, could you provide \nme with your activity reports so I can have Julie enter this information.\n\nJD');\nINSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big.... \nhttp://biz.yahoo.com/rf/010129/n29305829.html');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats!  Things seem to be building rapidly now on the Continent.  Mark');\nINSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '\nThe producer lumber pricing sheet.\n -----Original Message-----\nFrom: \tJohnson, Jay  \nSent:\tTuesday, October 16, 2001 3:42 PM\nTo:\tCarter, Karen E.\nSubject:\tFW: Producers Newsletter 9-24-2001\n\n\n\n -----Original Message-----\nFrom: \tDaigre, Sergai  \nSent:\tFriday, September 21, 2001 8:33 PM\nSubject:\tProducers Newsletter 9-24-2001\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would \nbe to offer up the Falcon for their use; however, given the tight time frame \nand your recent visit with Mr. Fox that it would be difficult for either you \nor me to participate.\n\nI spoke to Max and he agrees with this approach.\n\nI hope this meets with your approval.\n\nRegards\nDelainey');\nINSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,\n\nHere is the original memo we discussed earlier.  Please provide any information that you may have.\n\nYour cooperation is greatly appreciated.\n\nThanks,\n\nlachandra.fenceroy@enron.com\n713.853.3884\n877.498.3401 Pager\n\n -----Original Message-----\nFrom: \tBisbee, Joanne  \nSent:\tWednesday, September 26, 2001 7:50 AM\nTo:\tFenceroy, LaChandra\nSubject:\tFW: Bus Applications Meeting Follow Up\n\nLachandra, Please get with David Duff today and see what this is about.  Who are our TW accounting business users?\n\n -----Original Message-----\nFrom: \tKoh, Wendy  \nSent:\tTuesday, September 25, 2001 2:41 PM\nTo:\tBisbee, Joanne\nSubject:\tBus Applications Meeting Follow Up\n\nLisa brought up a TW change effective Nov 1.  It involves eliminating a turnback surcharge.  I have no other information, but you might check with the business folks for any system changes required.\n\nWendy');\nINSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,\n    If Julie''s merit needs to be lump sum, just move it over to that column.  Also, send me Eric Gadd''s sheets as well.  Thanks.\nDan\n\n -----Original Message-----\nFrom: \tFagan, Fran  \nSent:\tThursday, December 20, 2001 11:10 AM\nTo:\tMcCarty, Danny\nSubject:\tworksheets\n\nAs discussed, attached are your sheets for bonus and merit.\n\nThanks,\n\nFran Fagan\nSr. HR Rep\n713.853.5219\n\n\n << File: McCartyMerit.xls >>  << File: mccartyBonusCommercial_UnP.xls >> \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,\n\nPLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER.  SO FAR I HAVE THEM FOR LEAF.  I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH.  ANY QUESTIONS PLEASE GIVE ME A CALL.\n\nBERT');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification:  (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin\n\n\nI spoke with Rickey (boy, is he long-winded!!).  Gave him the name of our \ncredit guy, Russell Diamond.\n\nThank for your help!');\nINSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts.  I will fax these notices to you.');\nINSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --\n\nHere is the information on staffing and outside services.  Call if you need anything else.\n\nJim\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer, \nAttached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages. \nIn addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks. \nGreg Elliott \nIIR, Inc. \n713-783-5147 x 3481 \noutages@industrialinfo.com \nTHE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE.  YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS \nE-MAIL IN ERROR, PLEASE DELETE IT.\n - OUTAGE.dbf \n - 111201R.xls \n - 111201.xls ');\nINSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !\n\nYou are invited to attend the EWS Brown Bag Lunch Series\n\nFeaturing:   RAY BOWEN, COO\n\nTopic:  Enron Industrial Markets\n\nThursday, March 15, 2001\n11:30 am - 12:30 pm\nEB 5 C2\n\n\nYou bring your lunch,           Limited Seating\nWe provide drinks and dessert.          RSVP  x 3-9610');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me.  I bet this is next to the Warick?? Hotel.\n\n\n\n\n\"Immer, Ingrid\" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM\nTo: \"''chris.germany@enron.com''\" <chris.germany@enron.com>\ncc:  \nSubject: About St Pauls\n\n\n\n\n <<About St Pauls.url>>  \n? \n?http://www.stpaulshouston.org/about.html \n\nChris, \n\nI like the looks of this place.? What do you think about going here Christmas \neve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m., \namong others.\n\nLet me know.?? ii \n\n - About St Pauls.url\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder\nAs discussed in the Winter Operations Meeting on Sept.29,2000, \nE-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.  \nMarketers and Poolers can receive gas via Peaking and IBSS nominations(daisy \nchain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.\n');\nINSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', ' \n\nHere is a goody for you');\nINSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification:  (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap       10.000 / Enron ; 110.000 / HPL IFERC\n\nLS HPL LSK IC       30.000 / Enron\n');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-\n\nIs it safe to assume that practice is cancelled for tonight??\n\nSusan Pereira');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this.  I didn''t know how deep to go with the desk.  Do you think this works.\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,\nGive me a call and we will further discuss opportunities on the 13st floor.\n\nThanks,\nJMForney\n3-7160');\nINSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');\nINSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me.  It has plenty of points in it.  If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.\n\nadam\n35227\n\n\n -----Original Message-----\nFrom: \tRoyed, Jeff  \nSent:\tTuesday, September 25, 2001 11:37 AM\nTo:\tBayer, Adam\nSubject:\tCurve Fetch File\n\nLet me know if it works.   It may be required to have a certain version of Oracle for it to work properly.\n\n \n\nJeff Royed\nEnron \nEnergy Operations\nPhone: 713-853-5295');\nINSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,\n\nThe merged reports look great.  I believe the only orientation changes are to \n\"unmerge\" the following six reports:  \n\n31 Keystone Receipts\n15 Questar Pipeline\n40 Rockies Production\n22 West_2\n23 West_3\n25 CIG_WIC\n\nThe orientation of the individual reports should be correct.  Thanks.\n\nMat\n\nPS.  Just a reminder to add the \"*\" by the title of calculated points.');\nINSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000 \n10:08 AM ---------------------------\n\n\n\"Karkour, Randa\" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM\nTo: \"''Agheb (E-mail)\" <Agheb@aol.com>, \"Leila Mankarious (E-mail)\" \n<Leila_Mankarious@mhhs.org>, \"''Marymankarious (E-mail)\" \n<marymankarious@aol.com>, \"Michelle lokay (E-mail)\" <mlokay@enron.com>, \"Ramy \nMankarious (E-mail)\" <Mankarious@aol.com>\ncc:  \n\nSubject: Egyptian Festival\n\n\n <<Egyptian Festival.url>>\n\n http://www.egyptianfestival.com/\n\n - Egyptian Festival.url\n');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................\n\nThanks\n---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000 \n08:39 AM ---------------------------\n   \n\t\n\t\n\tFrom:  William Kelly @ ECT                           12/20/2000 08:31 AM\n\t\n\nTo: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David \nBaumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON\ncc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R \nLilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra \nChavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT \n\nSubject: New EAST books\n\nWe have new book names in TAGG for our intramonth portfolios and it is \nextremely important that any deal booked to the East is communicated quickly \nto someone on my team.  I know it will take some time for the new names to \nsink in and I do not want us to miss any positions or P&L.  \n\nThanks for your help on this.\n\nNew:\nScott Neal :         East Northeast\nDick Jenkins:     East Marketeast\n\nWK \n');\nINSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will \naffect any Inactive Child.\n\nAn inactive Child with links to Parent products will not have their \ncalculated prices updated until the Child product is Activated.\n\nWhen the Child Product is activated, the price will be recalculated and \nupdated BEFORE it is displayed on the web.\n\nThis means that if you are inputting a basis price on a Child product, you \nwill not see the final, calculated price until you Activate the product, at \nwhich time the customer will also see it.\n\nIf you have any questions, please contact the Help Desk on:\n\nAmericas: 713 853 4357\nEurope: + 44 (0) 20 7783 7783\nAsia/Australia: +61 2 9229 2300\n\nDave');\nINSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,\n\nI saw it. Very interesting.\n\nVince\n\n\n\n\n\n\"John H Herbert\" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM\nTo: \"Vince J Kaminski\" <Vince_J_Kaminski@enron.com>\ncc:  \nSubject: Light reading - see pieces beginning on page 7\n\n\nCheers and have a nice weekend,\n\n\nJHHerbert\n\n\n\n\n - gd000728.pdf\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');\nINSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team.  PLEASE DO NOT TAKE, BORROW OR USE this equipment.  Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.\n\nThanks for your understanding in this matter.\n\nT.Jae Black\nEast Power Trading\nAssistant to Kevin Presto\noff. 713-853-5800\nfax 713-646-8272\ncell 713-539-4760');\nINSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,\n\nHave you heard anything more on the 5 X 24s?  We would like to get this \nproduct out ASAP.\n\n\nThanks,\n\nEric');\nINSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]\n[IMAGE][IMAGE][IMAGE] \nDear  SmartReminders Member,\n       [IMAGE]         [IMAGE]        [IMAGE]     [IMAGE]    [IMAGE]    [IMAGE]        [IMAGE]      [IMAGE]     \t\n\n\n  \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nWe respect  your privacy and are a Certified Participant of the BBBOnLine\n Privacy Program.  To be removed from future offers,click  here. \nSmartReminders.com  is a permission based service. To unsubscribe click  here .  ');\nINSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a \"cloud of suspicion\" sort of \nspeak.  He was the one who got into several bad deals and PPA''s in California \nfor CIN, thus he left on a bad note.  Let me know if you need more detail \nthan that, I felt this was the type of info you were looking for.  Thanks!\nBen');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash\nReport Name:   Houston Cellular 8-11-01\nReport Date:   12/13/01\nReport ID:     594D37C9ED2111D5B452\nSubmitted On:  12/13/01\n\nYou are only allowed 2 reports with receipts outstanding.  Your expense reports will not be paid until you meet this requirement.');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI.  the latest broadside against the generators.\n\nSue Mara\nEnron Corp.\nTel: (415) 782-7802\nFax:(415) 782-7854\n----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----\n\n\n\t\"Milner, Marcie\" <MMilner@coral-energy.com> 06/08/2001 11:13 AM \t   To: \"''smara@enron.com''\" <smara@enron.com>  cc:   Subject: CAISO Emergency Motion\t\n\n\nSue, did you see this emergency motion the CAISO filed today?  Apparently\nthey are requesting that FERC discontinue market-based rates immediately and\ngrant refunds plus interest on the difference between cost-based rates and\nmarket revenues received back to May 2000.  They are requesting the\ncommission act within 14 days.  Have you heard anything about what they are\ndoing?\n\nMarcie\n\nhttp://www.caiso.com/docs/2001/06/08/200106081005526469.pdf \n');\nINSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,\n\nWho is General Brinks?\n\nFletch');\nINSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,\n\nHere are the documents that Peter has prepared for Mark Frevert. \n\nNailia\n---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001 \n16:36 ---------------------------\n\n\nNailia Dindarova\n25/06/2001 15:36\nTo: Michael Brown/Enron@EUEnronXGate\ncc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter \nStyles/LON/ECT@ECT \n\nSubject: Documents for Mark Frevert (on EU developments and lessons from \nCalifornia)\n\nMichael,\n\n\nThese are the documents that Peter promised to give to you for Mark Frevert. \nHe has now handed them to him in person but asked me to transmit them \nelectronically to you, as well as Eric and Ross.\n\nNailia\n\n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -\n\nAttached are our comments and suggested changes. Please call to review.\n\nOn the time line for completion, we have four critical steps to complete:\n     Finalize market analysis to refine business case, specifically\n     projected revenue stream\n     Complete counterparty surveying, including targeting 3 CPs for letters\n     of intent\n     Review Enron asset base for potential reuse/ licensing\n     Contract negotiations\n\nJoe will come back to us with an updated time line, but it is my\nexpectation that we are still on the same schedule (we just begun week\nthree) with possibly a week or so slippage.....contract negotiations will\nprobably be the critical path.\n\nWe will send our cut at the actual time line here shortly. Thanks,\n\nPeggy\n\n(See attached file: accenture-dealpoints v2.doc)\n - accenture-dealpoints v2.doc ');\nINSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001 \n03:49 PM ---------------------------\n\n\nThomas A Martin\n10/11/2000 03:55 PM\nTo: Patrick Wade/HOU/ECT@ECT\ncc:  \nSubject: Re: Guadalupe Power Partners LP  \n\nThe deal is physically served at Oasis Waha or Oasis Katy and is priced at \neither HSC, Waha or Katytailgate GD at buyers option three days prior to \nNYMEX  close.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04 \nAM ---------------------------\n\n\nagoddard@nisource.com on 03/08/2001 09:16:57 AM\nTo: \"        -         *Koch, Kent\" <kkoch@nisource.com>, \"        -         \n*Millar, Debra\" <dmillar@nisource.com>, \"        -         *Burke, Lynn\" \n<lburke@nisource.com>\ncc: \"        -         *Heckathorn, Tom\" <theckathorn@nisource.com> \nSubject: Columbia Distribution''s Capacity Available for Release - Sum\n\n\nAttached is Columbia Distribution''s notice of capacity available for release\nfor\nthe summer of 2001 (Apr. 2001 through Oct. 2001).\n\nPlease note that the deadline for bids is 3:00pm EST on March 20, 2001.\n\nIf you have any questions, feel free to contact any of the representatives\nlisted\nat the bottom of the attachment.\n\nAaron Goddard\n\n\n\n\n - 2001Summer.doc\n');\nINSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.  \nCopies will be distributed to Legal and Credit.');\nINSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is : \n713-668-3712...... my cell # is 281-381-7332\n\nthe kid');\nINSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '\n\n-----Original Message-----\nFrom: Punja, Karim \nSent: Thursday, December 13, 2001 2:35 PM\nTo: Richey, Cooper\nSubject: Contact Info\n\n\nCooper,\n\nIts been a real pleasure working with you (even though it was for only a small amount of time)\nI hope we can stay in touch.\n\nHome# 234-0249\nemail: kpunja@hotmail.com\n\nTake Care, \n\nKarim.\n  ');\nINSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.\n\nI haven''t talked to many of you via email recently but I do want to give you\nmy new address for your email file:\n\n    bjm30@earthlink.net\n\nI hope all is well.\n\nBrian McGuinn');\nINSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team.  It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.\n\nShelley');\nINSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', '    Enron Law Conference\n\nSan Antonio, Texas    May 2-4, 2001    Westin Riverwalk\n\n                   See attached memo for more details!!\n\n\n? Registration for the law conference this year will be handled through an \nOnline RSVP Form on the Enron Law Conference Website at \nhttp://lawconference.corp.enron.com.  The website is still under construction \nand will not be available until Thursday, March 15, 2001.  \n\n? We will send you another e-mail to confirm when the Law Conference Website \nis operational. \n\n? Please complete the Online RSVP Form as soon as it is available  and submit \nit no later than Friday, March 30th.  \n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat \nand let him know - we are coming on saturday - i just havent had a chance to \ncall you guys back --  looking forward to it -- i probably need the \ndirections again though');\nINSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,\n\nI''ll get it done today.  \n\nDG    3-9573\n\n\n   \n\t\n\t\n\tFrom:  Bryce Baxter                           06/12/2000 07:15 PM\n\t\n\nTo: Darron C Giron/HOU/ECT@ECT\ncc:  \nSubject: Feedback for Audrey Cook\n\nYou were identified as a reviewer for Audrey Cook.  If possible, could you \ncomplete her feedback by end of business Wednesday?  It will really help me \nin the PRC process to have your input.  Thanks.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,\n\nIn conjunction with the recent movement of several power traders, they are changing the names of their gas books as well.  The names of the new gas books and traders are as follows:\n\nPWR-NG-LT-SPP:  Mike Carson\nPWR-NG-LT-SERC:  Jeff King\n\nIf you need to know their power desk to map their ID to their gas books, those desks are as follows:\n\nEPMI-LT-SPP:  Mike Carson\nEPMI-LT-SERC:  Jeff King\n\nI will be in training this afternoon, but will be back when class is over.  Let me know if you have any questions.\n\nThanks for your help!\nCasey');\nINSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.\n\n\nds\n\n\n  \n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --\n\nIt was an honor and a pleasure to meet both of you yesterday.  I know we will\nhave fun working together on this very special event.\n\nJeff left the jurisprudence luncheon lists for me before he left on vacation.\n I wasn''t sure whether he transmitted them to you as well.  Would you please\nadvise me if you would like them sent to you?  I can email the MS Excel files\nor I can fax the hard copies to you.   Please advise what is most convenient.\n\nI plan to be in town through the holidays and can be reached by phone, email,\nor cell phone at any time.  My cell phone number is 713/705-4829.\n\nThanks again for your interest in the ADL''s work.  Martin.\n\nMartin B. Cominsky\nDirector, Southwest Region\nAnti-Defamation League\n713/627-3490, ext. 122\n713/627-2011 (fax)\nMCominsky@aol.com');\nINSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear.  Is there any possibility for Ben \nRaimer to be Bush''s secretary of HHS?  Just curious about that infamous UTMB \nrumor mill.  Hope things are well, happy holidays.\nPL');\nINSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:\n\nPursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex.  Please let me know if you need anything else.  We look forward to hearing your comments.\n\nMarie\n\nMarie Heard\nSenior Legal Specialist\nEnron North America Corp.\nPhone:  (713) 853-3907\nFax:  (713) 646-3490\nmarie.heard@enron.com\n\n\t\t\t\t ');\nINSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly -  once again thanks so much for your help on this.\n\n           \n\n                                                                     ');\nINSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '\nPlease contact me if you have any questions regarding last weeks prices.\n\nThank you,\nKarolyn Criado\n3-9441\n\n\n \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02.   I would like to take this risk off the books.\n\nIn addition, please find out what a buy-out of VEPCO would cost us.   With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.\n\nWe also need to continue to explore a JEA buy-out.\n\nThanks.');\nINSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg, \n\nI am at home with a sick baby.  (Lots of fun!)  I will call you about this \ntomorrow.\n\nStacy');\nINSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....\n\n w ww.gorelieberman-2000.com/');\nINSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,\n\nI sent you a fax of Kevin Kolb''s comments on the release.  The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).\nThis is assuming we wrap this up on Tuesday.  \n\nPlease email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.\n\nPhillip');\nINSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,\n\nI placed the adjusted L/R Balance on the Enronwest site.  It is under the \"Staff/Kourtney Nelson\".  There are two links:  \n\n1)  \"Adj L_R\" is the same data/format from the weekly strategy meeting. \n2)  \"New Gen 2001_2002\" link has all of the supply side info that is used to calculate the L/R balance\n\t-Please note the Data Flag column, a value of \"3\" indicates the project was cancelled, on hold, etc and is not included in the calc.  \n\nBoth of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please.  Also, James Bruce is working to get his gen report on the web.  That will help with your access to information on new gen.\n\nPlease let me know if you have any questions or feedback,\n\nKourtney\n\n\n\nKourtney Nelson\nFundamental Analysis \nEnron North America\n(503) 464-8280\nkourtney.nelson@enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '\n\n-----Original Message-----\nFrom: Grace, Rebecca M. \nSent: Monday, December 17, 2001 9:44 AM\nTo: Thomas, Paul D.\nCc: Cashion, Jim; Allen, Thresa A.; May, Tom\nSubject: RE: Current Enron TCC Portfolio\n\n\nPaul,\n\nI reviewed NY''s list.  I agree with all of their contracts numbers and mw amounts.\n\nCall if you have any more questions.\n\nRebecca\n\n\n\n -----Original Message-----\nFrom: \tThomas, Paul D.  \nSent:\tMonday, December 17, 2001 9:08 AM\nTo:\tGrace, Rebecca M.\nSubject:\tFW: Current Enron TCC Portfolio\n\n << File: enrontccs.xls >> \nRebecca,\nLet me know if you see any differences.\n\nPaul\nX 3-0403\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Monday, December 17, 2001 9:04 AM\nTo: Ahmed, Naveed\nSubject: FW: Current Enron TCC Portfolio\n\n\n\n\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Thursday, December 13, 2001 10:01 AM\nTo: Baughman, Edward D.\nSubject: Current Enron TCC Portfolio\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy, \nL.P., effective February 1, 2001, with the surviving entity being El Paso \nMerchant Energy, L.P.  We currently have ISDA Master Agreements with both \ncounterparties.  Please see the attached memo regarding the existing Masters \nand let us know which agreement should be terminated.\n\nThanks,\nStephanie\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', ' \n\n -----Original Message-----\nFrom: \tKenne, Dawn C.  \nSent:\tWednesday, February 06, 2002 11:50 AM\nTo:\tKeiser, Kam\nSubject:\tWhat about this too???\n\n\n << File: Netco Trader Matrix.xls >> \n ');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip.  We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request.  Please update per my previous e-mail and forward.\n\nThanks\n\nchris\nx31666');\nINSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend!   Happy Fathers Day!\n\n\nDebra Perlingiere\nEnron North America Corp.\n1400 Smith Street, EB 3885\nHouston, Texas 77002\ndperlin@enron.com\nPhone 713-853-7658\nFax  713-646-3490');\nINSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia  &', 'CALENDAR ENTRY:\tAPPOINTMENT\n\nDescription:\n\tDemo by Martha Janousek of Dashboard & Pipeline Profile / Julia  & Dir Rpts. - 4102\n\nDate:\t\t1/5/2001\nTime:\t\t9:00 AM - 10:00 AM (Central Standard Time)\n\nChairperson:\tOutlook Migration Team\n\nDetailed Description:');\nINSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,\n\nJustin Boyd told me that your can help me with questions regarding Chile.\nWe got a request for guest access through MG.\nThe company is called Escondida and is a subsidiary of BHP Australia.\n\nPlease advise if I can set up a guest account or not.\nF.Y.I.: MG is planning to put a \"in w/h Chile\" contract for Copper on-line as \nsoon as Enron has done the due diligence for this country.\nThanks !\n\n\nBest regards\n\nDiana Seifert\nEOL PCG');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:\n\nStatus last changed by: Barry L. Tycholiz\nExpense Report Name: 121001\nReport Total: $198.98\nAmount Due Employee: $198.98\nAmount Approved: $198.98\nAmount Paid: $0.00\nApproval Status: Approved\nPayment Status: Pending\n\n\nTo review this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:\n\nAustralia:\n1800 678-515\nsupport@palm-au.com\n\nCanada:\n1905 305-6530\nsupport@palm.com\n\nNew Zealand:\n0800 446-398\nsupport@palm-nz.com\n\nU.K.:\n0171 867 0108\neurosupport@palm.3com.com\n\nPlease refer to the Worldwide Customer Support card for a complete technical support contact list.');\nINSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 10:14 AM\nTo:\tStorey, Geoff\nSubject:\tRE: \n\nbp corp\tAlbert LaMore\t281-366-4962\n\nrunning the reports now\n\n\n -----Original Message-----\nFrom: \tStorey, Geoff  \nSent:\tWednesday, October 31, 2001 10:10 AM\nTo:\tQuigley, Dutch\nSubject:\tRE: \n\ngive me a contact over there too\nBP\n\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 9:42 AM\nTo:\tStorey, Geoff\nSubject:\t\n\nCoral\tJeff Whitnah\t713-767-5374\nRelaint\tSteve McGinn\t713-207-4000');\nINSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3;  <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3;  No ancillary schedules awarded.  \nVariances detected.\nVariances detected in Load schedule.\n\n    LOG MESSAGES:\n\nPARSING FILE -->> O:\\Portland\\WestDesk\\California Scheduling\\ISO Final \nSchedules\\2001042203.txt\n\n---- Load Schedule ----\n$$$ Variance found in table tblLoads.\n     Details: (Hour: 3 / Preferred:   1.92 / Final:   1.89)\n  TRANS_TYPE: FINAL\n  LOAD_ID: PGE4\n  MKT_TYPE: 2\n  TRANS_DATE: 4/22/01\n  SC_ID: EPMI\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens. \n\nJohn');\nINSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m.  Sorry I missed you.  (I was in the \nshower).  I have had a shitty week--I suspect my silence (not only to you, \nbut others) after our phone call is a result of the week.  I''m seeing Glen at \n11:15....talk to you');\nINSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '\nThis week''s Lite Bytz presentation will feature the following TOOLZ speaker:\n\nRichard McDougall\nSolaris 8\nThursday, June 7, 2001\n\nIf you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.\n\n*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.\n\nClick below for more details.\n\nhttp://home.enron.com:84/messaging/litebytztoolzprint.jpg');\n    COMMIT;\n  }\n} {}\n\n###############################################################################\n# Everything above just builds an interesting test database.  The actual\n# tests come after this comment.\n###############################################################################\n\ndo_test fts1c-1.2 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark'\n  }\n} {6 17 25 38 40 42 73 74}\ndo_test fts1c-1.3 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan'\n  }\n} {24 40}\ndo_test fts1c-1.4 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark susan'\n  }\n} {40}\ndo_test fts1c-1.5 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan mark'\n  }\n} {40}\ndo_test fts1c-1.6 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '\"mark susan\"'\n  }\n} {}\ndo_test fts1c-1.7 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark -susan'\n  }\n} {6 17 25 38 42 73 74}\ndo_test fts1c-1.8 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '-mark susan'\n  }\n} {24}\ndo_test fts1c-1.9 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark OR susan'\n  }\n} {6 17 24 25 38 40 42 73 74}\n\n# Some simple tests of the automatic \"offsets(email)\" column.  In the sample\n# data set above, only one message, number 20, contains the words\n# \"gas\" and \"reminder\" in both body and subject.\n#\ndo_test fts1c-2.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts1c-2.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}\ndo_test fts1c-2.3 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'body:gas reminder'\n  }\n} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts1c-2.4 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE subject MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8}}\ndo_test fts1c-2.5 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'gas reminder'\n  }\n} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\n\n# Document 32 contains 5 instances of the world \"child\".  But only\n# 3 of them are paired with \"product\".  Make sure only those instances\n# that match the phrase appear in the offsets(email) list.\n#\ndo_test fts1c-3.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'child product' AND +rowid=32\n  }\n} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}\ndo_test fts1c-3.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH '\"child product\"'\n  }\n} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}\n\n# Snippet generator tests\n#\ndo_test fts1c-4.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}\ndo_test fts1c-4.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'christmas candlelight'\n  }\n} {{<b>...</b> place.? What do you think about going here <b>Christmas</b> \neve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m., \namong others. <b>...</b>}}\n\ndo_test fts1c-4.3 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent\n     Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing\n     Contract negotiations <b>...</b>}}\ndo_test fts1c-4.4 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <<<Deal>>> <<<Sheet>>>  intent\n     Review Enron asset base for <<<potential>>> <<<reuse>>>/ licensing\n     Contract negotiations  }}\ndo_test fts1c-4.5 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'first things'\n  }\n} {{Re: <<<First>>> Polish Deal!  Congrats!  <<<Things>>> seem to be building rapidly now on the  }}\ndo_test fts1c-4.6 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'chris is here'\n  }\n} {{<b>chris</b>.germany@enron.com <b>...</b> Sounds good to me.  I bet this <b>is</b> next to the Warick?? Hotel. <b>...</b> place.? What do you think about going <b>here</b> Christmas \neve?? They have an 11:00 a.m. <b>...</b>}}\ndo_test fts1c-4.7 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH '\"pursuant to\"'\n  }\n} {{Erin:\n\n<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to <b>...</b>}}\ndo_test fts1c-4.8 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'ancillary load davis'\n  }\n} {{pete.<b>davis</b>@enron.com <b>...</b> Start Date: 4/22/01; HourAhead hour: 3;  No <b>ancillary</b> schedules awarded.  \nVariances detected.\nVariances detected in <b>Load</b> schedule.\n\n    LOG MESSAGES:\n\nPARSING <b>...</b>}}\n\n# Combinations of AND and OR operators:\n#\ndo_test fts1c-5.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'questar enron OR com'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:  \n\n31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies Production\n22 West_2 <b>...</b>}}\ndo_test fts1c-5.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'enron OR com questar'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:  \n\n31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies Production\n22 West_2 <b>...</b>}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1d.test",
    "content": "# 2006 October 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS1 module, and in particular\n# the Porter stemmer.\n#\n# $Id: fts1d.test,v 1.1 2006/10/01 18:41:21 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\ndo_test fts1d-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts1(content, tokenize porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts1d-1.2 {\n  execsql {\n    SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';\n  }\n} {{<b>running</b> and <b>jumping</b>}}\ndo_test fts1d-1.3 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(2, 'abcdefghijklmnopqrstuvwyxz');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts1d-1.4 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts1d-1.5 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(3, 'The value is 123456789');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'\n  }\n} {3 {The value is <b>123456789</b>}}\ndo_test fts1d-1.6 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'\n  }\n} {3 {The value is <b>123456789</b>}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1e.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing deletions in the FTS1 module.\n#\n# $Id: fts1e.test,v 1.1 2006/10/19 23:28:35 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 30 INSERT and\n# DELETE statements, so that we'll test both the segmentMerge() merge\n# (over the first 16) and the termSelect() merge (over the level-1\n# segment and 14 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  DELETE FROM t1 WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  DELETE FROM t1 WHERE rowid = 22;\n}\n\ndo_test fts1f-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {14}\n\ndo_test fts1e-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {3 5 9 11 15 17 21}\n\ndo_test fts1e-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 11 14 15 18}\n\ndo_test fts1e-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {5 6 12 14 15 20 21}\n\ndo_test fts1e-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {8 9 11 12 14 15}\n\ndo_test fts1e-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {17 18 20 21}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1f.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing updates in the FTS1 module.\n#\n# $Id: fts1f.test,v 1.2 2007/02/23 00:14:06 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 31 INSERT,\n# UPDATE, and DELETE statements, so that we'll test both the\n# segmentMerge() merge (over the first 16) and the termSelect() merge\n# (over the level-1 segment and 15 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  UPDATE t1 SET content = 'update one three' WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  UPDATE t1 SET content = 'update two five' WHERE rowid = 8;\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  UPDATE t1 SET content = 'update' WHERE rowid = 15;\n}\n\ndo_test fts1f-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {16}\n\ndo_test fts1f-2.0 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}\n} {1 8 15}\n\ndo_test fts1f-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 9 11 17 21}\n\ndo_test fts1f-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 8 11 14 18 22}\n\ndo_test fts1f-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {1 5 6 12 14 20 21 22}\n\ndo_test fts1f-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {9 11 12 14}\n\ndo_test fts1f-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {8 17 18 20 21 22}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1i.test",
    "content": "# 2007 January 17\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite fts1 library.  The\n# focus here is testing handling of UPDATE when using UTF-16-encoded\n# databases.\n#\n# $Id: fts1i.test,v 1.2 2007/01/24 03:43:20 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\n# NOTE(shess) Copied from capi3.test.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\ndb eval {\n  PRAGMA encoding = \"UTF-16le\";\n  CREATE VIRTUAL TABLE t1 USING fts1(content);\n}\n\ndo_test fts1i-1.0 {\n  execsql {PRAGMA encoding}\n} {UTF-16le}\n\ndo_test fts1i-1.1 {\n  execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}\n  execsql {SELECT content FROM t1 WHERE rowid = 1}\n} {one}\n\ndo_test fts1i-1.2 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(2, 'two')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 2}\n} {two}\n\ndo_test fts1i-1.3 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(3, 'three')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'trois' WHERE rowid = 3\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 3}\n} {trois}\n\ndo_test fts1i-1.4 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 4}\n} {four}\n\ndo_test fts1i-1.5 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'cinq' WHERE rowid = 5\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 5}\n} {cinq}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1j.test",
    "content": "# 2007 February 6\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  This\n# tests creating fts1 tables in an attached database.\n#\n# $Id: fts1j.test,v 1.1 2007/02/07 01:01:18 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Clean up anything left over from a previous pass.\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db2 test2.db\n\ndb eval {\n  CREATE VIRTUAL TABLE t3 USING fts1(content);\n  INSERT INTO t3 (rowid, content) VALUES(1, \"hello world\");\n}\n\ndb2 eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, \"hello world\");\n  INSERT INTO t1 (rowid, content) VALUES(2, \"hello there\");\n  INSERT INTO t1 (rowid, content) VALUES(3, \"cruel world\");\n}\n\n# This has always worked because the t1_* tables used by fts1 will be\n# the defaults.\ndo_test fts1j-1.1 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\n# Make certain we're detached if there was an error.\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this appears to work fine, but the t2_* tables used\n# by fts1 will be created in database 'main' instead of database\n# 'two'.  It appears to work fine because the tables end up being the\n# defaults, but obviously is badly broken if you hope to use things\n# other than in the exact same ATTACH setup.\ndo_test fts1j-1.2 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    CREATE VIRTUAL TABLE two.t2 USING fts1(content);\n    INSERT INTO t2 (rowid, content) VALUES(1, \"hello world\");\n    INSERT INTO t2 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO t2 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM t2 WHERE t2 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this broke because the fts1 code attempted to create\n# t3_* tables in database 'main', but they already existed.  Normally\n# this wouldn't happen without t3 itself existing, in which case the\n# fts1 code would never be called in the first place.\ndo_test fts1j-1.3 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n\n    CREATE VIRTUAL TABLE two.t3 USING fts1(content);\n    INSERT INTO two.t3 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO two.t3 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';\n\n    DETACH DATABASE two;\n  } db2\n} {2}\ncatch {db eval {DETACH DATABASE two}}\n\ncatch {db2 close}\nforcedelete test2.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1k.test",
    "content": "# 2007 March 28\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing isspace/isalnum/tolower problems with the\n# FTS1 module.  Unfortunately, this code isn't a really principled set\n# of tests, because it is impossible to know where new uses of these\n# functions might appear.\n#\n# $Id: fts1k.test,v 1.2 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Tests that startsWith() (calls isspace, tolower, isalnum) can handle\n# hi-bit chars.  parseSpec() also calls isalnum here.\ndo_test fts1k-1.1 {\n  execsql \"CREATE VIRTUAL TABLE t1 USING fts1(content, \\x80)\"\n} {}\n\n# Additionally tests isspace() call in getToken(), and isalnum() call\n# in tokenListToIdList().\ndo_test fts1k-1.2 {\n  catch {\n    execsql \"CREATE VIRTUAL TABLE t2 USING fts1(content, tokenize \\x80)\"\n  }\n  sqlite3_errmsg $DB\n} \"unknown tokenizer: \\x80\"\n\n# Additionally test final isalnum() in startsWith().\ndo_test fts1k-1.3 {\n  execsql \"CREATE VIRTUAL TABLE t3 USING fts1(content, tokenize\\x80)\"\n} {}\n\n# The snippet-generation code has calls to isspace() which are sort of\n# hard to get to.  It finds convenient breakpoints by starting ~40\n# chars before and after the matched term, and scanning ~10 chars\n# around that position for isspace() characters.  The long word with\n# embedded hi-bit chars causes one of these isspace() calls to be\n# exercised.  The version with a couple extra spaces should cause the\n# other isspace() call to be exercised.  [Both cases have been tested\n# in the debugger, but I'm hoping to continue to catch it if simple\n# constant changes change things slightly.\n#\n# The trailing and leading hi-bit chars help with code which tests for\n# isspace() to coalesce multiple spaces.\n\nset word \"\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80\"\nset phrase1 \"$word $word $word target $word $word $word\"\nset phrase2 \"$word $word $word    target    $word $word $word\"\n\ndb eval {CREATE VIRTUAL TABLE t4 USING fts1(content)}\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase1')\"\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase2')\"\n\ndo_test fts1k-1.4 {\n  execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}\n} {1 111 2 117}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1l.test",
    "content": "# 2007 April 9\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  fts1\n# DELETE handling assumed all fields were non-null.  This was not\n# the intention at all.\n#\n# $Id: fts1l.test,v 1.1 2007/04/09 20:45:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(col_a, col_b);\n\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);\n}\n\ndo_test fts1m-1.0 {\n  execsql {\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {2 2 4}\n\ndo_test fts1m-1.1 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 1;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {1 1 3}\n\ndo_test fts1m-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 2;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 1 2}\n\ndo_test fts1m-1.3 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 3;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 1}\n\ndo_test fts1m-1.4 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 4;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1m.test",
    "content": "# 2007 July 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing the FTS1 module, specifically snippet\n# generation.  Extracted from fts2o.test.\n#\n# $Id: fts1m.test,v 1.1 2007/07/25 00:25:20 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is not defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n#---------------------------------------------------------------------\n# These tests, fts1m-1.*, test that ticket #2429 is fixed.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);\n  INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');\n}\ndo_test fts1m-1.1 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';\n  }\n} {1 {one <b>four</b> two}}\ndo_test fts1m-1.2 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';\n  }\n} {1 {one <b>four</b>}}\ndo_test fts1m-1.3 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';\n  }\n} {1 {one three <b>four</b>}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1n.test",
    "content": "# 2007 July 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing the FTS1 module for errors in the handling\n# of SQLITE_SCHEMA.\n#\n# $Id: fts1n.test,v 1.1 2007/07/25 00:38:06 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is not defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\ndo_test fts1m-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);\n    INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n  }\n} {{one three four} {one four} {one two}}\n\n# This test was crashing at one point.\n#\ndo_test fts1m-1.2 {\n  execsql {\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n    CREATE TABLE t3(a, b, c);\n    SELECT a, b, c FROM t1 WHERE  c  MATCH 'two';\n  }\n} {{one three four} {one four} {one two} {one three four} {one four} {one two}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1o.test",
    "content": "# 2007 July 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing the FTS1 module rename functionality.  Mostly\n# copied from fts2o.test.\n#\n# $Id: fts1o.test,v 1.2 2007/08/30 20:01:33 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is not defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(a, b, c);\n  INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');\n}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts1 table.\n#\ndo_test fts1o-1.1 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {t1 t1_content t1_term}\ndo_test fts1o-1.2 {\n  execsql { ALTER TABLE t1 RENAME to fts_t1; }\n} {}\ndo_test fts1o-1.3 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts1o-1.4 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_term}\n\n# See what happens when renaming the fts1 table fails.\n#\ndo_test fts1o-2.1 {\n  catchsql {\n    CREATE TABLE t1_term(a, b, c);\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\ndo_test fts1o-2.2 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts1o-2.3 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_term t1_term}\n\n# See what happens when renaming the fts1 table fails inside a transaction.\n#\ndo_test fts1o-3.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');\n  }\n} {}\ndo_test fts1o-3.2 {\n  catchsql {\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\n# NOTE(shess) rowid AS rowid to defeat caching.  Otherwise, this\n# seg-faults, I suspect that there's something up with a stale\n# virtual-table reference, but I'm not quite sure how it happens here\n# but not for fts2o.test.\ndo_test fts1o-3.3 {\n  execsql { SELECT rowid AS rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts1o-3.4 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_term t1_term}\ndo_test fts1o-3.5 {\n  execsql COMMIT\n  execsql {SELECT a FROM fts_t1}\n} {{one three four} {one two three}}\ndo_test fts1o-3.6 {\n  execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }\n} {{one three four} {one four} {one four two}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts1 table in an attached \n# database.\n#\nforcedelete test2.db test2.db-journal\n\ndo_test fts1o-4.1 {\n  execsql {\n    DROP TABLE t1_term;\n    ALTER TABLE fts_t1 RENAME to t1;\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n  }\n} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}\n\ndo_test fts1o-4.2 {\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    CREATE VIRTUAL TABLE aux.t1 USING fts1(a, b, c);\n    INSERT INTO aux.t1(a, b, c) VALUES(\n      'neung song sahm', 'neung see', 'neung see song'\n    );\n  }\n} {}\n\ndo_test fts1o-4.3 {\n  execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts1o-4.4 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}\n\ndo_test fts1o-4.5 {\n  execsql { ALTER TABLE aux.t1 RENAME TO t2 }\n} {}\n\ndo_test fts1o-4.6 {\n  execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts1o-4.7 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one four two} {one two three} {one four} {one two}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts1porter.test",
    "content": "# 2006 October 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS1 module, and in particular\n# the Porter stemmer.\n#\n# $Id: fts1porter.test,v 1.5 2006/10/03 19:37:37 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS1 is defined, omit this file.\nifcapable !fts1 {\n  finish_test\n  return\n}\n\n# Test data for the Porter stemmer.  The first word of each line\n# is the input.  The second word is the desired output.\n#\n# This test data is taken from http://www.tartarus.org/martin/PorterStemmer/\n# There is no claim of copyright made on that page, but you should\n# probably contact the author (Martin Porter - the inventor of the\n# Porter Stemmer algorithm) if you want to use this test data in a\n# commerical product of some kind.  The stemmer code in FTS1 is a\n# complete rewrite from scratch based on the algorithm specification\n# and does not contain any code under copyright.\n#\nset porter_test_data {\n    a                    a\n    aaron                aaron\n    abaissiez            abaissiez\n    abandon              abandon\n    abandoned            abandon\n    abase                abas\n    abash                abash\n    abate                abat\n    abated               abat\n    abatement            abat\n    abatements           abat\n    abates               abat\n    abbess               abbess\n    abbey                abbei\n    abbeys               abbei\n    abbominable          abbomin\n    abbot                abbot\n    abbots               abbot\n    abbreviated          abbrevi\n    abed                 ab\n    abel                 abel\n    aberga               aberga\n    abergavenny          abergavenni\n    abet                 abet\n    abetting             abet\n    abhominable          abhomin\n    abhor                abhor\n    abhorr               abhorr\n    abhorred             abhor\n    abhorring            abhor\n    abhors               abhor\n    abhorson             abhorson\n    abide                abid\n    abides               abid\n    abilities            abil\n    ability              abil\n    abject               abject\n    abjectly             abjectli\n    abjects              abject\n    abjur                abjur\n    abjure               abjur\n    able                 abl\n    abler                abler\n    aboard               aboard\n    abode                abod\n    aboded               abod\n    abodements           abod\n    aboding              abod\n    abominable           abomin\n    abominably           abomin\n    abominations         abomin\n    abortive             abort\n    abortives            abort\n    abound               abound\n    abounding            abound\n    about                about\n    above                abov\n    abr                  abr\n    abraham              abraham\n    abram                abram\n    abreast              abreast\n    abridg               abridg\n    abridge              abridg\n    abridged             abridg\n    abridgment           abridg\n    abroach              abroach\n    abroad               abroad\n    abrogate             abrog\n    abrook               abrook\n    abrupt               abrupt\n    abruption            abrupt\n    abruptly             abruptli\n    absence              absenc\n    absent               absent\n    absey                absei\n    absolute             absolut\n    absolutely           absolut\n    absolv               absolv\n    absolver             absolv\n    abstains             abstain\n    abstemious           abstemi\n    abstinence           abstin\n    abstract             abstract\n    absurd               absurd\n    absyrtus             absyrtu\n    abundance            abund\n    abundant             abund\n    abundantly           abundantli\n    abus                 abu\n    abuse                abus\n    abused               abus\n    abuser               abus\n    abuses               abus\n    abusing              abus\n    abutting             abut\n    aby                  abi\n    abysm                abysm\n    ac                   ac\n    academe              academ\n    academes             academ\n    accent               accent\n    accents              accent\n    accept               accept\n    acceptable           accept\n    acceptance           accept\n    accepted             accept\n    accepts              accept\n    access               access\n    accessary            accessari\n    accessible           access\n    accidence            accid\n    accident             accid\n    accidental           accident\n    accidentally         accident\n    accidents            accid\n    accite               accit\n    accited              accit\n    accites              accit\n    acclamations         acclam\n    accommodate          accommod\n    accommodated         accommod\n    accommodation        accommod\n    accommodations       accommod\n    accommodo            accommodo\n    accompanied          accompani\n    accompany            accompani\n    accompanying         accompani\n    accomplices          accomplic\n    accomplish           accomplish\n    accomplished         accomplish\n    accomplishing        accomplish\n    accomplishment       accomplish\n    accompt              accompt\n    accord               accord\n    accordant            accord\n    accorded             accord\n    accordeth            accordeth\n    according            accord\n    accordingly          accordingli\n    accords              accord\n    accost               accost\n    accosted             accost\n    account              account\n    accountant           account\n    accounted            account\n    accounts             account\n    accoutred            accoutr\n    accoutrement         accoutr\n    accoutrements        accoutr\n    accrue               accru\n    accumulate           accumul\n    accumulated          accumul\n    accumulation         accumul\n    accurs               accur\n    accursed             accurs\n    accurst              accurst\n    accus                accu\n    accusation           accus\n    accusations          accus\n    accusative           accus\n    accusativo           accusativo\n    accuse               accus\n    accused              accus\n    accuser              accus\n    accusers             accus\n    accuses              accus\n    accuseth             accuseth\n    accusing             accus\n    accustom             accustom\n    accustomed           accustom\n    ace                  ac\n    acerb                acerb\n    ache                 ach\n    acheron              acheron\n    aches                ach\n    achiev               achiev\n    achieve              achiev\n    achieved             achiev\n    achievement          achiev\n    achievements         achiev\n    achiever             achiev\n    achieves             achiev\n    achieving            achiev\n    achilles             achil\n    aching               ach\n    achitophel           achitophel\n    acknowledg           acknowledg\n    acknowledge          acknowledg\n    acknowledged         acknowledg\n    acknowledgment       acknowledg\n    acknown              acknown\n    acold                acold\n    aconitum             aconitum\n    acordo               acordo\n    acorn                acorn\n    acquaint             acquaint\n    acquaintance         acquaint\n    acquainted           acquaint\n    acquaints            acquaint\n    acquir               acquir\n    acquire              acquir\n    acquisition          acquisit\n    acquit               acquit\n    acquittance          acquitt\n    acquittances         acquitt\n    acquitted            acquit\n    acre                 acr\n    acres                acr\n    across               across\n    act                  act\n    actaeon              actaeon\n    acted                act\n    acting               act\n    action               action\n    actions              action\n    actium               actium\n    active               activ\n    actively             activ\n    activity             activ\n    actor                actor\n    actors               actor\n    acts                 act\n    actual               actual\n    acture               actur\n    acute                acut\n    acutely              acut\n    ad                   ad\n    adage                adag\n    adallas              adalla\n    adam                 adam\n    adamant              adam\n    add                  add\n    added                ad\n    adder                adder\n    adders               adder\n    addeth               addeth\n    addict               addict\n    addicted             addict\n    addiction            addict\n    adding               ad\n    addition             addit\n    additions            addit\n    addle                addl\n    address              address\n    addressing           address\n    addrest              addrest\n    adds                 add\n    adhere               adher\n    adheres              adher\n    adieu                adieu\n    adieus               adieu\n    adjacent             adjac\n    adjoin               adjoin\n    adjoining            adjoin\n    adjourn              adjourn\n    adjudg               adjudg\n    adjudged             adjudg\n    adjunct              adjunct\n    administer           administ\n    administration       administr\n    admir                admir\n    admirable            admir\n    admiral              admir\n    admiration           admir\n    admire               admir\n    admired              admir\n    admirer              admir\n    admiring             admir\n    admiringly           admiringli\n    admission            admiss\n    admit                admit\n    admits               admit\n    admittance           admitt\n    admitted             admit\n    admitting            admit\n    admonish             admonish\n    admonishing          admonish\n    admonishment         admonish\n    admonishments        admonish\n    admonition           admonit\n    ado                  ado\n    adonis               adoni\n    adopt                adopt\n    adopted              adopt\n    adoptedly            adoptedli\n    adoption             adopt\n    adoptious            adopti\n    adopts               adopt\n    ador                 ador\n    adoration            ador\n    adorations           ador\n    adore                ador\n    adorer               ador\n    adores               ador\n    adorest              adorest\n    adoreth              adoreth\n    adoring              ador\n    adorn                adorn\n    adorned              adorn\n    adornings            adorn\n    adornment            adorn\n    adorns               adorn\n    adown                adown\n    adramadio            adramadio\n    adrian               adrian\n    adriana              adriana\n    adriano              adriano\n    adriatic             adriat\n    adsum                adsum\n    adulation            adul\n    adulterate           adulter\n    adulterates          adulter\n    adulterers           adulter\n    adulteress           adulteress\n    adulteries           adulteri\n    adulterous           adulter\n    adultery             adulteri\n    adultress            adultress\n    advanc               advanc\n    advance              advanc\n    advanced             advanc\n    advancement          advanc\n    advancements         advanc\n    advances             advanc\n    advancing            advanc\n    advantage            advantag\n    advantageable        advantag\n    advantaged           advantag\n    advantageous         advantag\n    advantages           advantag\n    advantaging          advantag\n    advent               advent\n    adventur             adventur\n    adventure            adventur\n    adventures           adventur\n    adventuring          adventur\n    adventurous          adventur\n    adventurously        adventur\n    adversaries          adversari\n    adversary            adversari\n    adverse              advers\n    adversely            advers\n    adversities          advers\n    adversity            advers\n    advertis             adverti\n    advertise            advertis\n    advertised           advertis\n    advertisement        advertis\n    advertising          advertis\n    advice               advic\n    advis                advi\n    advise               advis\n    advised              advis\n    advisedly            advisedli\n    advises              advis\n    advisings            advis\n    advocate             advoc\n    advocation           advoc\n    aeacida              aeacida\n    aeacides             aeacid\n    aedile               aedil\n    aediles              aedil\n    aegeon               aegeon\n    aegion               aegion\n    aegles               aegl\n    aemelia              aemelia\n    aemilia              aemilia\n    aemilius             aemiliu\n    aeneas               aenea\n    aeolus               aeolu\n    aer                  aer\n    aerial               aerial\n    aery                 aeri\n    aesculapius          aesculapiu\n    aeson                aeson\n    aesop                aesop\n    aetna                aetna\n    afar                 afar\n    afear                afear\n    afeard               afeard\n    affability           affabl\n    affable              affabl\n    affair               affair\n    affaire              affair\n    affairs              affair\n    affect               affect\n    affectation          affect\n    affectations         affect\n    affected             affect\n    affectedly           affectedli\n    affecteth            affecteth\n    affecting            affect\n    affection            affect\n    affectionate         affection\n    affectionately       affection\n    affections           affect\n    affects              affect\n    affeer               affeer\n    affianc              affianc\n    affiance             affianc\n    affianced            affianc\n    affied               affi\n    affin                affin\n    affined              affin\n    affinity             affin\n    affirm               affirm\n    affirmation          affirm\n    affirmatives         affirm\n    afflict              afflict\n    afflicted            afflict\n    affliction           afflict\n    afflictions          afflict\n    afflicts             afflict\n    afford               afford\n    affordeth            affordeth\n    affords              afford\n    affray               affrai\n    affright             affright\n    affrighted           affright\n    affrights            affright\n    affront              affront\n    affronted            affront\n    affy                 affi\n    afield               afield\n    afire                afir\n    afloat               afloat\n    afoot                afoot\n    afore                afor\n    aforehand            aforehand\n    aforesaid            aforesaid\n    afraid               afraid\n    afresh               afresh\n    afric                afric\n    africa               africa\n    african              african\n    afront               afront\n    after                after\n    afternoon            afternoon\n    afterward            afterward\n    afterwards           afterward\n    ag                   ag\n    again                again\n    against              against\n    agamemmon            agamemmon\n    agamemnon            agamemnon\n    agate                agat\n    agaz                 agaz\n    age                  ag\n    aged                 ag\n    agenor               agenor\n    agent                agent\n    agents               agent\n    ages                 ag\n    aggravate            aggrav\n    aggrief              aggrief\n    agile                agil\n    agincourt            agincourt\n    agitation            agit\n    aglet                aglet\n    agnize               agniz\n    ago                  ago\n    agone                agon\n    agony                agoni\n    agree                agre\n    agreed               agre\n    agreeing             agre\n    agreement            agreement\n    agrees               agre\n    agrippa              agrippa\n    aground              aground\n    ague                 agu\n    aguecheek            aguecheek\n    agued                agu\n    agueface             aguefac\n    agues                agu\n    ah                   ah\n    aha                  aha\n    ahungry              ahungri\n    ai                   ai\n    aialvolio            aialvolio\n    aiaria               aiaria\n    aid                  aid\n    aidance              aidanc\n    aidant               aidant\n    aided                aid\n    aiding               aid\n    aidless              aidless\n    aids                 aid\n    ail                  ail\n    aim                  aim\n    aimed                aim\n    aimest               aimest\n    aiming               aim\n    aims                 aim\n    ainsi                ainsi\n    aio                  aio\n    air                  air\n    aired                air\n    airless              airless\n    airs                 air\n    airy                 airi\n    ajax                 ajax\n    akilling             akil\n    al                   al\n    alabaster            alabast\n    alack                alack\n    alacrity             alacr\n    alarbus              alarbu\n    alarm                alarm\n    alarms               alarm\n    alarum               alarum\n    alarums              alarum\n    alas                 ala\n    alb                  alb\n    alban                alban\n    albans               alban\n    albany               albani\n    albeit               albeit\n    albion               albion\n    alchemist            alchemist\n    alchemy              alchemi\n    alcibiades           alcibiad\n    alcides              alcid\n    alder                alder\n    alderman             alderman\n    aldermen             aldermen\n    ale                  al\n    alecto               alecto\n    alehouse             alehous\n    alehouses            alehous\n    alencon              alencon\n    alengon              alengon\n    aleppo               aleppo\n    ales                 al\n    alewife              alewif\n    alexander            alexand\n    alexanders           alexand\n    alexandria           alexandria\n    alexandrian          alexandrian\n    alexas               alexa\n    alias                alia\n    alice                alic\n    alien                alien\n    aliena               aliena\n    alight               alight\n    alighted             alight\n    alights              alight\n    aliis                alii\n    alike                alik\n    alisander            alisand\n    alive                aliv\n    all                  all\n    alla                 alla\n    allay                allai\n    allayed              allai\n    allaying             allai\n    allayment            allay\n    allayments           allay\n    allays               allai\n    allegation           alleg\n    allegations          alleg\n    allege               alleg\n    alleged              alleg\n    allegiance           allegi\n    allegiant            allegi\n    alley                allei\n    alleys               allei\n    allhallowmas         allhallowma\n    alliance             allianc\n    allicholy            allicholi\n    allied               alli\n    allies               alli\n    alligant             allig\n    alligator            allig\n    allons               allon\n    allot                allot\n    allots               allot\n    allotted             allot\n    allottery            allotteri\n    allow                allow\n    allowance            allow\n    allowed              allow\n    allowing             allow\n    allows               allow\n    allur                allur\n    allure               allur\n    allurement           allur\n    alluring             allur\n    allusion             allus\n    ally                 alli\n    allycholly           allycholli\n    almain               almain\n    almanac              almanac\n    almanack             almanack\n    almanacs             almanac\n    almighty             almighti\n    almond               almond\n    almost               almost\n    alms                 alm\n    almsman              almsman\n    aloes                alo\n    aloft                aloft\n    alone                alon\n    along                along\n    alonso               alonso\n    aloof                aloof\n    aloud                aloud\n    alphabet             alphabet\n    alphabetical         alphabet\n    alphonso             alphonso\n    alps                 alp\n    already              alreadi\n    also                 also\n    alt                  alt\n    altar                altar\n    altars               altar\n    alter                alter\n    alteration           alter\n    altered              alter\n    alters               alter\n    althaea              althaea\n    although             although\n    altitude             altitud\n    altogether           altogeth\n    alton                alton\n    alway                alwai\n    always               alwai\n    am                   am\n    amaimon              amaimon\n    amain                amain\n    amaking              amak\n    amamon               amamon\n    amaz                 amaz\n    amaze                amaz\n    amazed               amaz\n    amazedly             amazedli\n    amazedness           amazed\n    amazement            amaz\n    amazes               amaz\n    amazeth              amazeth\n    amazing              amaz\n    amazon               amazon\n    amazonian            amazonian\n    amazons              amazon\n    ambassador           ambassador\n    ambassadors          ambassador\n    amber                amber\n    ambiguides           ambiguid\n    ambiguities          ambigu\n    ambiguous            ambigu\n    ambition             ambit\n    ambitions            ambit\n    ambitious            ambiti\n    ambitiously          ambiti\n    amble                ambl\n    ambled               ambl\n    ambles               ambl\n    ambling              ambl\n    ambo                 ambo\n    ambuscadoes          ambuscado\n    ambush               ambush\n    amen                 amen\n    amend                amend\n    amended              amend\n    amendment            amend\n    amends               amend\n    amerce               amerc\n    america              america\n    ames                 am\n    amiable              amiabl\n    amid                 amid\n    amidst               amidst\n    amiens               amien\n    amis                 ami\n    amiss                amiss\n    amities              amiti\n    amity                amiti\n    amnipotent           amnipot\n    among                among\n    amongst              amongst\n    amorous              amor\n    amorously            amor\n    amort                amort\n    amount               amount\n    amounts              amount\n    amour                amour\n    amphimacus           amphimacu\n    ample                ampl\n    ampler               ampler\n    amplest              amplest\n    amplified            amplifi\n    amplify              amplifi\n    amply                ampli\n    ampthill             ampthil\n    amurath              amurath\n    amyntas              amynta\n    an                   an\n    anatomiz             anatomiz\n    anatomize            anatom\n    anatomy              anatomi\n    ancestor             ancestor\n    ancestors            ancestor\n    ancestry             ancestri\n    anchises             anchis\n    anchor               anchor\n    anchorage            anchorag\n    anchored             anchor\n    anchoring            anchor\n    anchors              anchor\n    anchovies            anchovi\n    ancient              ancient\n    ancientry            ancientri\n    ancients             ancient\n    ancus                ancu\n    and                  and\n    andirons             andiron\n    andpholus            andpholu\n    andren               andren\n    andrew               andrew\n    andromache           andromach\n    andronici            andronici\n    andronicus           andronicu\n    anew                 anew\n    ang                  ang\n    angel                angel\n    angelica             angelica\n    angelical            angel\n    angelo               angelo\n    angels               angel\n    anger                anger\n    angerly              angerli\n    angers               anger\n    anges                ang\n    angiers              angier\n    angl                 angl\n    anglais              anglai\n    angle                angl\n    angler               angler\n    angleterre           angleterr\n    angliae              anglia\n    angling              angl\n    anglish              anglish\n    angrily              angrili\n    angry                angri\n    anguish              anguish\n    angus                angu\n    animal               anim\n    animals              anim\n    animis               animi\n    anjou                anjou\n    ankle                ankl\n    anna                 anna\n    annals               annal\n    anne                 ann\n    annex                annex\n    annexed              annex\n    annexions            annexion\n    annexment            annex\n    annothanize          annothan\n    announces            announc\n    annoy                annoi\n    annoyance            annoy\n    annoying             annoi\n    annual               annual\n    anoint               anoint\n    anointed             anoint\n    anon                 anon\n    another              anoth\n    anselmo              anselmo\n    answer               answer\n    answerable           answer\n    answered             answer\n    answerest            answerest\n    answering            answer\n    answers              answer\n    ant                  ant\n    ante                 ant\n    antenor              antenor\n    antenorides          antenorid\n    anteroom             anteroom\n    anthem               anthem\n    anthems              anthem\n    anthony              anthoni\n    anthropophagi        anthropophagi\n    anthropophaginian    anthropophaginian\n    antiates             antiat\n    antic                antic\n    anticipate           anticip\n    anticipates          anticip\n    anticipatest         anticipatest\n    anticipating         anticip\n    anticipation         anticip\n    antick               antick\n    anticly              anticli\n    antics               antic\n    antidote             antidot\n    antidotes            antidot\n    antigonus            antigonu\n    antiopa              antiopa\n    antipathy            antipathi\n    antipholus           antipholu\n    antipholuses         antipholus\n    antipodes            antipod\n    antiquary            antiquari\n    antique              antiqu\n    antiquity            antiqu\n    antium               antium\n    antoniad             antoniad\n    antonio              antonio\n    antonius             antoniu\n    antony               antoni\n    antres               antr\n    anvil                anvil\n    any                  ani\n    anybody              anybodi\n    anyone               anyon\n    anything             anyth\n    anywhere             anywher\n    ap                   ap\n    apace                apac\n    apart                apart\n    apartment            apart\n    apartments           apart\n    ape                  ap\n    apemantus            apemantu\n    apennines            apennin\n    apes                 ap\n    apiece               apiec\n    apish                apish\n    apollinem            apollinem\n    apollo               apollo\n    apollodorus          apollodoru\n    apology              apolog\n    apoplex              apoplex\n    apoplexy             apoplexi\n    apostle              apostl\n    apostles             apostl\n    apostrophas          apostropha\n    apoth                apoth\n    apothecary           apothecari\n    appal                appal\n    appall               appal\n    appalled             appal\n    appals               appal\n    apparel              apparel\n    apparell             apparel\n    apparelled           apparel\n    apparent             appar\n    apparently           appar\n    apparition           apparit\n    apparitions          apparit\n    appeach              appeach\n    appeal               appeal\n    appeals              appeal\n    appear               appear\n    appearance           appear\n    appeared             appear\n    appeareth            appeareth\n    appearing            appear\n    appears              appear\n    appeas               appea\n    appease              appeas\n    appeased             appeas\n    appelant             appel\n    appele               appel\n    appelee              appele\n    appeles              appel\n    appelez              appelez\n    appellant            appel\n    appellants           appel\n    appelons             appelon\n    appendix             appendix\n    apperil              apperil\n    appertain            appertain\n    appertaining         appertain\n    appertainings        appertain\n    appertains           appertain\n    appertinent          appertin\n    appertinents         appertin\n    appetite             appetit\n    appetites            appetit\n    applaud              applaud\n    applauded            applaud\n    applauding           applaud\n    applause             applaus\n    applauses            applaus\n    apple                appl\n    apples               appl\n    appletart            appletart\n    appliance            applianc\n    appliances           applianc\n    applications         applic\n    applied              appli\n    applies              appli\n    apply                appli\n    applying             appli\n    appoint              appoint\n    appointed            appoint\n    appointment          appoint\n    appointments         appoint\n    appoints             appoint\n    apprehend            apprehend\n    apprehended          apprehend\n    apprehends           apprehend\n    apprehension         apprehens\n    apprehensions        apprehens\n    apprehensive         apprehens\n    apprendre            apprendr\n    apprenne             apprenn\n    apprenticehood       apprenticehood\n    appris               appri\n    approach             approach\n    approachers          approach\n    approaches           approach\n    approacheth          approacheth\n    approaching          approach\n    approbation          approb\n    approof              approof\n    appropriation        appropri\n    approv               approv\n    approve              approv\n    approved             approv\n    approvers            approv\n    approves             approv\n    appurtenance         appurten\n    appurtenances        appurten\n    apricocks            apricock\n    april                april\n    apron                apron\n    aprons               apron\n    apt                  apt\n    apter                apter\n    aptest               aptest\n    aptly                aptli\n    aptness              apt\n    aqua                 aqua\n    aquilon              aquilon\n    aquitaine            aquitain\n    arabia               arabia\n    arabian              arabian\n    araise               arais\n    arbitrate            arbitr\n    arbitrating          arbitr\n    arbitrator           arbitr\n    arbitrement          arbitr\n    arbors               arbor\n    arbour               arbour\n    arc                  arc\n    arch                 arch\n    archbishop           archbishop\n    archbishopric        archbishopr\n    archdeacon           archdeacon\n    arched               arch\n    archelaus            archelau\n    archer               archer\n    archers              archer\n    archery              archeri\n    archibald            archibald\n    archidamus           archidamu\n    architect            architect\n    arcu                 arcu\n    arde                 ard\n    arden                arden\n    ardent               ardent\n    ardour               ardour\n    are                  ar\n    argal                argal\n    argier               argier\n    argo                 argo\n    argosies             argosi\n    argosy               argosi\n    argu                 argu\n    argue                argu\n    argued               argu\n    argues               argu\n    arguing              argu\n    argument             argument\n    arguments            argument\n    argus                argu\n    ariachne             ariachn\n    ariadne              ariadn\n    ariel                ariel\n    aries                ari\n    aright               aright\n    arinado              arinado\n    arinies              arini\n    arion                arion\n    arise                aris\n    arises               aris\n    ariseth              ariseth\n    arising              aris\n    aristode             aristod\n    aristotle            aristotl\n    arithmetic           arithmet\n    arithmetician        arithmetician\n    ark                  ark\n    arm                  arm\n    arma                 arma\n    armado               armado\n    armadoes             armado\n    armagnac             armagnac\n    arme                 arm\n    armed                arm\n    armenia              armenia\n    armies               armi\n    armigero             armigero\n    arming               arm\n    armipotent           armipot\n    armor                armor\n    armour               armour\n    armourer             armour\n    armourers            armour\n    armours              armour\n    armoury              armouri\n    arms                 arm\n    army                 armi\n    arn                  arn\n    aroint               aroint\n    arose                aros\n    arouse               arous\n    aroused              arous\n    arragon              arragon\n    arraign              arraign\n    arraigned            arraign\n    arraigning           arraign\n    arraignment          arraign\n    arrant               arrant\n    arras                arra\n    array                arrai\n    arrearages           arrearag\n    arrest               arrest\n    arrested             arrest\n    arrests              arrest\n    arriv                arriv\n    arrival              arriv\n    arrivance            arriv\n    arrive               arriv\n    arrived              arriv\n    arrives              arriv\n    arriving             arriv\n    arrogance            arrog\n    arrogancy            arrog\n    arrogant             arrog\n    arrow                arrow\n    arrows               arrow\n    art                  art\n    artemidorus          artemidoru\n    arteries             arteri\n    arthur               arthur\n    article              articl\n    articles             articl\n    articulate           articul\n    artificer            artific\n    artificial           artifici\n    artillery            artilleri\n    artire               artir\n    artist               artist\n    artists              artist\n    artless              artless\n    artois               artoi\n    arts                 art\n    artus                artu\n    arviragus            arviragu\n    as                   as\n    asaph                asaph\n    ascanius             ascaniu\n    ascend               ascend\n    ascended             ascend\n    ascendeth            ascendeth\n    ascends              ascend\n    ascension            ascens\n    ascent               ascent\n    ascribe              ascrib\n    ascribes             ascrib\n    ash                  ash\n    asham                asham\n    ashamed              asham\n    asher                asher\n    ashes                ash\n    ashford              ashford\n    ashore               ashor\n    ashouting            ashout\n    ashy                 ashi\n    asia                 asia\n    aside                asid\n    ask                  ask\n    askance              askanc\n    asked                ask\n    asker                asker\n    asketh               asketh\n    asking               ask\n    asks                 ask\n    aslant               aslant\n    asleep               asleep\n    asmath               asmath\n    asp                  asp\n    aspect               aspect\n    aspects              aspect\n    aspen                aspen\n    aspersion            aspers\n    aspic                aspic\n    aspicious            aspici\n    aspics               aspic\n    aspir                aspir\n    aspiration           aspir\n    aspire               aspir\n    aspiring             aspir\n    asquint              asquint\n    ass                  ass\n    assail               assail\n    assailable           assail\n    assailant            assail\n    assailants           assail\n    assailed             assail\n    assaileth            assaileth\n    assailing            assail\n    assails              assail\n    assassination        assassin\n    assault              assault\n    assaulted            assault\n    assaults             assault\n    assay                assai\n    assaying             assai\n    assays               assai\n    assemblance          assembl\n    assemble             assembl\n    assembled            assembl\n    assemblies           assembl\n    assembly             assembl\n    assent               assent\n    asses                ass\n    assez                assez\n    assign               assign\n    assigned             assign\n    assigns              assign\n    assinico             assinico\n    assist               assist\n    assistance           assist\n    assistances          assist\n    assistant            assist\n    assistants           assist\n    assisted             assist\n    assisting            assist\n    associate            associ\n    associated           associ\n    associates           associ\n    assuage              assuag\n    assubjugate          assubjug\n    assum                assum\n    assume               assum\n    assumes              assum\n    assumption           assumpt\n    assur                assur\n    assurance            assur\n    assure               assur\n    assured              assur\n    assuredly            assuredli\n    assures              assur\n    assyrian             assyrian\n    astonish             astonish\n    astonished           astonish\n    astraea              astraea\n    astray               astrai\n    astrea               astrea\n    astronomer           astronom\n    astronomers          astronom\n    astronomical         astronom\n    astronomy            astronomi\n    asunder              asund\n    at                   at\n    atalanta             atalanta\n    ate                  at\n    ates                 at\n    athenian             athenian\n    athenians            athenian\n    athens               athen\n    athol                athol\n    athversary           athversari\n    athwart              athwart\n    atlas                atla\n    atomies              atomi\n    atomy                atomi\n    atone                aton\n    atonement            aton\n    atonements           aton\n    atropos              atropo\n    attach               attach\n    attached             attach\n    attachment           attach\n    attain               attain\n    attainder            attaind\n    attains              attain\n    attaint              attaint\n    attainted            attaint\n    attainture           attaintur\n    attempt              attempt\n    attemptable          attempt\n    attempted            attempt\n    attempting           attempt\n    attempts             attempt\n    attend               attend\n    attendance           attend\n    attendant            attend\n    attendants           attend\n    attended             attend\n    attendents           attend\n    attendeth            attendeth\n    attending            attend\n    attends              attend\n    attent               attent\n    attention            attent\n    attentive            attent\n    attentivenes         attentiven\n    attest               attest\n    attested             attest\n    attir                attir\n    attire               attir\n    attired              attir\n    attires              attir\n    attorney             attornei\n    attorneyed           attornei\n    attorneys            attornei\n    attorneyship         attorneyship\n    attract              attract\n    attraction           attract\n    attractive           attract\n    attracts             attract\n    attribute            attribut\n    attributed           attribut\n    attributes           attribut\n    attribution          attribut\n    attributive          attribut\n    atwain               atwain\n    au                   au\n    aubrey               aubrei\n    auburn               auburn\n    aucun                aucun\n    audacious            audaci\n    audaciously          audaci\n    audacity             audac\n    audible              audibl\n    audience             audienc\n    audis                audi\n    audit                audit\n    auditor              auditor\n    auditors             auditor\n    auditory             auditori\n    audre                audr\n    audrey               audrei\n    aufidius             aufidiu\n    aufidiuses           aufidius\n    auger                auger\n    aught                aught\n    augment              augment\n    augmentation         augment\n    augmented            augment\n    augmenting           augment\n    augurer              augur\n    augurers             augur\n    augures              augur\n    auguring             augur\n    augurs               augur\n    augury               auguri\n    august               august\n    augustus             augustu\n    auld                 auld\n    aumerle              aumerl\n    aunchient            aunchient\n    aunt                 aunt\n    aunts                aunt\n    auricular            auricular\n    aurora               aurora\n    auspicious           auspici\n    aussi                aussi\n    austere              auster\n    austerely            auster\n    austereness          auster\n    austerity            auster\n    austria              austria\n    aut                  aut\n    authentic            authent\n    author               author\n    authorities          author\n    authority            author\n    authorized           author\n    authorizing          author\n    authors              author\n    autolycus            autolycu\n    autre                autr\n    autumn               autumn\n    auvergne             auvergn\n    avail                avail\n    avails               avail\n    avarice              avaric\n    avaricious           avarici\n    avaunt               avaunt\n    ave                  av\n    aveng                aveng\n    avenge               aveng\n    avenged              aveng\n    averring             aver\n    avert                avert\n    aves                 av\n    avez                 avez\n    avis                 avi\n    avoid                avoid\n    avoided              avoid\n    avoiding             avoid\n    avoids               avoid\n    avoirdupois          avoirdupoi\n    avouch               avouch\n    avouched             avouch\n    avouches             avouch\n    avouchment           avouch\n    avow                 avow\n    aw                   aw\n    await                await\n    awaits               await\n    awak                 awak\n    awake                awak\n    awaked               awak\n    awaken               awaken\n    awakened             awaken\n    awakens              awaken\n    awakes               awak\n    awaking              awak\n    award                award\n    awards               award\n    awasy                awasi\n    away                 awai\n    awe                  aw\n    aweary               aweari\n    aweless              aweless\n    awful                aw\n    awhile               awhil\n    awkward              awkward\n    awl                  awl\n    awooing              awoo\n    awork                awork\n    awry                 awri\n    axe                  ax\n    axle                 axl\n    axletree             axletre\n    ay                   ay\n    aye                  ay\n    ayez                 ayez\n    ayli                 ayli\n    azur                 azur\n    azure                azur\n    b                    b\n    ba                   ba\n    baa                  baa\n    babbl                babbl\n    babble               babbl\n    babbling             babbl\n    babe                 babe\n    babes                babe\n    babies               babi\n    baboon               baboon\n    baboons              baboon\n    baby                 babi\n    babylon              babylon\n    bacare               bacar\n    bacchanals           bacchan\n    bacchus              bacchu\n    bach                 bach\n    bachelor             bachelor\n    bachelors            bachelor\n    back                 back\n    backbite             backbit\n    backbitten           backbitten\n    backing              back\n    backs                back\n    backward             backward\n    backwardly           backwardli\n    backwards            backward\n    bacon                bacon\n    bacons               bacon\n    bad                  bad\n    bade                 bade\n    badge                badg\n    badged               badg\n    badges               badg\n    badly                badli\n    badness              bad\n    baes                 bae\n    baffl                baffl\n    baffle               baffl\n    baffled              baffl\n    bag                  bag\n    baggage              baggag\n    bagot                bagot\n    bagpipe              bagpip\n    bags                 bag\n    bail                 bail\n    bailiff              bailiff\n    baillez              baillez\n    baily                baili\n    baisant              baisant\n    baisees              baise\n    baiser               baiser\n    bait                 bait\n    baited               bait\n    baiting              bait\n    baitings             bait\n    baits                bait\n    bajazet              bajazet\n    bak                  bak\n    bake                 bake\n    baked                bake\n    baker                baker\n    bakers               baker\n    bakes                bake\n    baking               bake\n    bal                  bal\n    balanc               balanc\n    balance              balanc\n    balcony              balconi\n    bald                 bald\n    baldrick             baldrick\n    bale                 bale\n    baleful              bale\n    balk                 balk\n    ball                 ball\n    ballad               ballad\n    ballads              ballad\n    ballast              ballast\n    ballasting           ballast\n    ballet               ballet\n    ballow               ballow\n    balls                ball\n    balm                 balm\n    balms                balm\n    balmy                balmi\n    balsam               balsam\n    balsamum             balsamum\n    balth                balth\n    balthasar            balthasar\n    balthazar            balthazar\n    bames                bame\n    ban                  ban\n    banbury              banburi\n    band                 band\n    bandied              bandi\n    banding              band\n    bandit               bandit\n    banditti             banditti\n    banditto             banditto\n    bands                band\n    bandy                bandi\n    bandying             bandi\n    bane                 bane\n    banes                bane\n    bang                 bang\n    bangor               bangor\n    banish               banish\n    banished             banish\n    banishers            banish\n    banishment           banish\n    banister             banist\n    bank                 bank\n    bankrout             bankrout\n    bankrupt             bankrupt\n    bankrupts            bankrupt\n    banks                bank\n    banner               banner\n    bannerets            banneret\n    banners              banner\n    banning              ban\n    banns                bann\n    banquet              banquet\n    banqueted            banquet\n    banqueting           banquet\n    banquets             banquet\n    banquo               banquo\n    bans                 ban\n    baptism              baptism\n    baptista             baptista\n    baptiz               baptiz\n    bar                  bar\n    barbarian            barbarian\n    barbarians           barbarian\n    barbarism            barbar\n    barbarous            barbar\n    barbary              barbari\n    barbason             barbason\n    barbed               barb\n    barber               barber\n    barbermonger         barbermong\n    bard                 bard\n    bardolph             bardolph\n    bards                bard\n    bare                 bare\n    bared                bare\n    barefac              barefac\n    barefaced            barefac\n    barefoot             barefoot\n    bareheaded           barehead\n    barely               bare\n    bareness             bare\n    barful               bar\n    bargain              bargain\n    bargains             bargain\n    barge                barg\n    bargulus             bargulu\n    baring               bare\n    bark                 bark\n    barking              bark\n    barkloughly          barkloughli\n    barks                bark\n    barky                barki\n    barley               barlei\n    barm                 barm\n    barn                 barn\n    barnacles            barnacl\n    barnardine           barnardin\n    barne                barn\n    barnes               barn\n    barnet               barnet\n    barns                barn\n    baron                baron\n    barons               baron\n    barony               baroni\n    barr                 barr\n    barrabas             barraba\n    barrel               barrel\n    barrels              barrel\n    barren               barren\n    barrenly             barrenli\n    barrenness           barren\n    barricado            barricado\n    barricadoes          barricado\n    barrow               barrow\n    bars                 bar\n    barson               barson\n    barter               barter\n    bartholomew          bartholomew\n    bas                  ba\n    basan                basan\n    base                 base\n    baseless             baseless\n    basely               base\n    baseness             base\n    baser                baser\n    bases                base\n    basest               basest\n    bashful              bash\n    bashfulness          bash\n    basilisco            basilisco\n    basilisk             basilisk\n    basilisks            basilisk\n    basimecu             basimecu\n    basin                basin\n    basingstoke          basingstok\n    basins               basin\n    basis                basi\n    bask                 bask\n    basket               basket\n    baskets              basket\n    bass                 bass\n    bassanio             bassanio\n    basset               basset\n    bassianus            bassianu\n    basta                basta\n    bastard              bastard\n    bastardizing         bastard\n    bastardly            bastardli\n    bastards             bastard\n    bastardy             bastardi\n    basted               bast\n    bastes               bast\n    bastinado            bastinado\n    basting              bast\n    bat                  bat\n    batailles            batail\n    batch                batch\n    bate                 bate\n    bated                bate\n    bates                bate\n    bath                 bath\n    bathe                bath\n    bathed               bath\n    bathing              bath\n    baths                bath\n    bating               bate\n    batler               batler\n    bats                 bat\n    batt                 batt\n    battalia             battalia\n    battalions           battalion\n    batten               batten\n    batter               batter\n    battering            batter\n    batters              batter\n    battery              batteri\n    battle               battl\n    battled              battl\n    battlefield          battlefield\n    battlements          battlement\n    battles              battl\n    batty                batti\n    bauble               baubl\n    baubles              baubl\n    baubling             baubl\n    baulk                baulk\n    bavin                bavin\n    bawcock              bawcock\n    bawd                 bawd\n    bawdry               bawdri\n    bawds                bawd\n    bawdy                bawdi\n    bawl                 bawl\n    bawling              bawl\n    bay                  bai\n    baying               bai\n    baynard              baynard\n    bayonne              bayonn\n    bays                 bai\n    be                   be\n    beach                beach\n    beached              beach\n    beachy               beachi\n    beacon               beacon\n    bead                 bead\n    beaded               bead\n    beadle               beadl\n    beadles              beadl\n    beads                bead\n    beadsmen             beadsmen\n    beagle               beagl\n    beagles              beagl\n    beak                 beak\n    beaks                beak\n    beam                 beam\n    beamed               beam\n    beams                beam\n    bean                 bean\n    beans                bean\n    bear                 bear\n    beard                beard\n    bearded              beard\n    beardless            beardless\n    beards               beard\n    bearer               bearer\n    bearers              bearer\n    bearest              bearest\n    beareth              beareth\n    bearing              bear\n    bears                bear\n    beast                beast\n    beastliest           beastliest\n    beastliness          beastli\n    beastly              beastli\n    beasts               beast\n    beat                 beat\n    beated               beat\n    beaten               beaten\n    beating              beat\n    beatrice             beatric\n    beats                beat\n    beau                 beau\n    beaufort             beaufort\n    beaumond             beaumond\n    beaumont             beaumont\n    beauteous            beauteou\n    beautied             beauti\n    beauties             beauti\n    beautified           beautifi\n    beautiful            beauti\n    beautify             beautifi\n    beauty               beauti\n    beaver               beaver\n    beavers              beaver\n    became               becam\n    because              becaus\n    bechanc              bechanc\n    bechance             bechanc\n    bechanced            bechanc\n    beck                 beck\n    beckon               beckon\n    beckons              beckon\n    becks                beck\n    becom                becom\n    become               becom\n    becomed              becom\n    becomes              becom\n    becoming             becom\n    becomings            becom\n    bed                  bed\n    bedabbled            bedabbl\n    bedash               bedash\n    bedaub               bedaub\n    bedazzled            bedazzl\n    bedchamber           bedchamb\n    bedclothes           bedcloth\n    bedded               bed\n    bedeck               bedeck\n    bedecking            bedeck\n    bedew                bedew\n    bedfellow            bedfellow\n    bedfellows           bedfellow\n    bedford              bedford\n    bedlam               bedlam\n    bedrench             bedrench\n    bedrid               bedrid\n    beds                 bed\n    bedtime              bedtim\n    bedward              bedward\n    bee                  bee\n    beef                 beef\n    beefs                beef\n    beehives             beehiv\n    been                 been\n    beer                 beer\n    bees                 bee\n    beest                beest\n    beetle               beetl\n    beetles              beetl\n    beeves               beev\n    befall               befal\n    befallen             befallen\n    befalls              befal\n    befell               befel\n    befits               befit\n    befitted             befit\n    befitting            befit\n    befor                befor\n    before               befor\n    beforehand           beforehand\n    befortune            befortun\n    befriend             befriend\n    befriended           befriend\n    befriends            befriend\n    beg                  beg\n    began                began\n    beget                beget\n    begets               beget\n    begetting            beget\n    begg                 begg\n    beggar               beggar\n    beggared             beggar\n    beggarly             beggarli\n    beggarman            beggarman\n    beggars              beggar\n    beggary              beggari\n    begging              beg\n    begin                begin\n    beginners            beginn\n    beginning            begin\n    beginnings           begin\n    begins               begin\n    begnawn              begnawn\n    begone               begon\n    begot                begot\n    begotten             begotten\n    begrimed             begrim\n    begs                 beg\n    beguil               beguil\n    beguile              beguil\n    beguiled             beguil\n    beguiles             beguil\n    beguiling            beguil\n    begun                begun\n    behalf               behalf\n    behalfs              behalf\n    behav                behav\n    behaved              behav\n    behavedst            behavedst\n    behavior             behavior\n    behaviors            behavior\n    behaviour            behaviour\n    behaviours           behaviour\n    behead               behead\n    beheaded             behead\n    beheld               beheld\n    behest               behest\n    behests              behest\n    behind               behind\n    behold               behold\n    beholder             behold\n    beholders            behold\n    beholdest            beholdest\n    beholding            behold\n    beholds              behold\n    behoof               behoof\n    behooffull           behoofful\n    behooves             behoov\n    behove               behov\n    behoves              behov\n    behowls              behowl\n    being                be\n    bel                  bel\n    belarius             belariu\n    belch                belch\n    belching             belch\n    beldam               beldam\n    beldame              beldam\n    beldams              beldam\n    belee                bele\n    belgia               belgia\n    belie                beli\n    belied               beli\n    belief               belief\n    beliest              beliest\n    believ               believ\n    believe              believ\n    believed             believ\n    believes             believ\n    believest            believest\n    believing            believ\n    belike               belik\n    bell                 bell\n    bellario             bellario\n    belle                bell\n    bellied              belli\n    bellies              belli\n    bellman              bellman\n    bellona              bellona\n    bellow               bellow\n    bellowed             bellow\n    bellowing            bellow\n    bellows              bellow\n    bells                bell\n    belly                belli\n    bellyful             belly\n    belman               belman\n    belmont              belmont\n    belock               belock\n    belong               belong\n    belonging            belong\n    belongings           belong\n    belongs              belong\n    belov                belov\n    beloved              belov\n    beloving             belov\n    below                below\n    belt                 belt\n    belzebub             belzebub\n    bemadding            bemad\n    bemet                bemet\n    bemete               bemet\n    bemoan               bemoan\n    bemoaned             bemoan\n    bemock               bemock\n    bemoil               bemoil\n    bemonster            bemonst\n    ben                  ben\n    bench                bench\n    bencher              bencher\n    benches              bench\n    bend                 bend\n    bended               bend\n    bending              bend\n    bends                bend\n    bene                 bene\n    beneath              beneath\n    benedicite           benedicit\n    benedick             benedick\n    benediction          benedict\n    benedictus           benedictu\n    benefactors          benefactor\n    benefice             benefic\n    beneficial           benefici\n    benefit              benefit\n    benefited            benefit\n    benefits             benefit\n    benetted             benet\n    benevolence          benevol\n    benevolences         benevol\n    benied               beni\n    benison              benison\n    bennet               bennet\n    bent                 bent\n    bentii               bentii\n    bentivolii           bentivolii\n    bents                bent\n    benumbed             benumb\n    benvolio             benvolio\n    bepaint              bepaint\n    bepray               beprai\n    bequeath             bequeath\n    bequeathed           bequeath\n    bequeathing          bequeath\n    bequest              bequest\n    ber                  ber\n    berard               berard\n    berattle             berattl\n    beray                berai\n    bere                 bere\n    bereave              bereav\n    bereaved             bereav\n    bereaves             bereav\n    bereft               bereft\n    bergamo              bergamo\n    bergomask            bergomask\n    berhym               berhym\n    berhyme              berhym\n    berkeley             berkelei\n    bermoothes           bermooth\n    bernardo             bernardo\n    berod                berod\n    berowne              berown\n    berri                berri\n    berries              berri\n    berrord              berrord\n    berry                berri\n    bertram              bertram\n    berwick              berwick\n    bescreen             bescreen\n    beseech              beseech\n    beseeched            beseech\n    beseechers           beseech\n    beseeching           beseech\n    beseek               beseek\n    beseem               beseem\n    beseemeth            beseemeth\n    beseeming            beseem\n    beseems              beseem\n    beset                beset\n    beshrew              beshrew\n    beside               besid\n    besides              besid\n    besieg               besieg\n    besiege              besieg\n    besieged             besieg\n    beslubber            beslubb\n    besmear              besmear\n    besmeared            besmear\n    besmirch             besmirch\n    besom                besom\n    besort               besort\n    besotted             besot\n    bespake              bespak\n    bespeak              bespeak\n    bespice              bespic\n    bespoke              bespok\n    bespotted            bespot\n    bess                 bess\n    bessy                bessi\n    best                 best\n    bestained            bestain\n    bested               best\n    bestial              bestial\n    bestir               bestir\n    bestirr              bestirr\n    bestow               bestow\n    bestowed             bestow\n    bestowing            bestow\n    bestows              bestow\n    bestraught           bestraught\n    bestrew              bestrew\n    bestrid              bestrid\n    bestride             bestrid\n    bestrides            bestrid\n    bet                  bet\n    betake               betak\n    beteem               beteem\n    bethink              bethink\n    bethought            bethought\n    bethrothed           bethroth\n    bethump              bethump\n    betid                betid\n    betide               betid\n    betideth             betideth\n    betime               betim\n    betimes              betim\n    betoken              betoken\n    betook               betook\n    betossed             betoss\n    betray               betrai\n    betrayed             betrai\n    betraying            betrai\n    betrays              betrai\n    betrims              betrim\n    betroth              betroth\n    betrothed            betroth\n    betroths             betroth\n    bett                 bett\n    betted               bet\n    better               better\n    bettered             better\n    bettering            better\n    betters              better\n    betting              bet\n    bettre               bettr\n    between              between\n    betwixt              betwixt\n    bevel                bevel\n    beverage             beverag\n    bevis                bevi\n    bevy                 bevi\n    bewail               bewail\n    bewailed             bewail\n    bewailing            bewail\n    bewails              bewail\n    beware               bewar\n    bewasted             bewast\n    beweep               beweep\n    bewept               bewept\n    bewet                bewet\n    bewhored             bewhor\n    bewitch              bewitch\n    bewitched            bewitch\n    bewitchment          bewitch\n    bewray               bewrai\n    beyond               beyond\n    bezonian             bezonian\n    bezonians            bezonian\n    bianca               bianca\n    bianco               bianco\n    bias                 bia\n    bibble               bibbl\n    bickerings           bicker\n    bid                  bid\n    bidden               bidden\n    bidding              bid\n    biddings             bid\n    biddy                biddi\n    bide                 bide\n    bides                bide\n    biding               bide\n    bids                 bid\n    bien                 bien\n    bier                 bier\n    bifold               bifold\n    big                  big\n    bigamy               bigami\n    biggen               biggen\n    bigger               bigger\n    bigness              big\n    bigot                bigot\n    bilberry             bilberri\n    bilbo                bilbo\n    bilboes              bilbo\n    bilbow               bilbow\n    bill                 bill\n    billeted             billet\n    billets              billet\n    billiards            billiard\n    billing              bill\n    billow               billow\n    billows              billow\n    bills                bill\n    bin                  bin\n    bind                 bind\n    bindeth              bindeth\n    binding              bind\n    binds                bind\n    biondello            biondello\n    birch                birch\n    bird                 bird\n    birding              bird\n    birdlime             birdlim\n    birds                bird\n    birnam               birnam\n    birth                birth\n    birthday             birthdai\n    birthdom             birthdom\n    birthplace           birthplac\n    birthright           birthright\n    birthrights          birthright\n    births               birth\n    bis                  bi\n    biscuit              biscuit\n    bishop               bishop\n    bishops              bishop\n    bisson               bisson\n    bit                  bit\n    bitch                bitch\n    bite                 bite\n    biter                biter\n    bites                bite\n    biting               bite\n    bits                 bit\n    bitt                 bitt\n    bitten               bitten\n    bitter               bitter\n    bitterest            bitterest\n    bitterly             bitterli\n    bitterness           bitter\n    blab                 blab\n    blabb                blabb\n    blabbing             blab\n    blabs                blab\n    black                black\n    blackamoor           blackamoor\n    blackamoors          blackamoor\n    blackberries         blackberri\n    blackberry           blackberri\n    blacker              blacker\n    blackest             blackest\n    blackfriars          blackfriar\n    blackheath           blackheath\n    blackmere            blackmer\n    blackness            black\n    blacks               black\n    bladder              bladder\n    bladders             bladder\n    blade                blade\n    bladed               blade\n    blades               blade\n    blains               blain\n    blam                 blam\n    blame                blame\n    blamed               blame\n    blameful             blame\n    blameless            blameless\n    blames               blame\n    blanc                blanc\n    blanca               blanca\n    blanch               blanch\n    blank                blank\n    blanket              blanket\n    blanks               blank\n    blaspheme            blasphem\n    blaspheming          blasphem\n    blasphemous          blasphem\n    blasphemy            blasphemi\n    blast                blast\n    blasted              blast\n    blasting             blast\n    blastments           blastment\n    blasts               blast\n    blaz                 blaz\n    blaze                blaze\n    blazes               blaze\n    blazing              blaze\n    blazon               blazon\n    blazoned             blazon\n    blazoning            blazon\n    bleach               bleach\n    bleaching            bleach\n    bleak                bleak\n    blear                blear\n    bleared              blear\n    bleat                bleat\n    bleated              bleat\n    bleats               bleat\n    bled                 bled\n    bleed                bleed\n    bleedest             bleedest\n    bleedeth             bleedeth\n    bleeding             bleed\n    bleeds               bleed\n    blemish              blemish\n    blemishes            blemish\n    blench               blench\n    blenches             blench\n    blend                blend\n    blended              blend\n    blent                blent\n    bless                bless\n    blessed              bless\n    blessedly            blessedli\n    blessedness          blessed\n    blesses              bless\n    blesseth             blesseth\n    blessing             bless\n    blessings            bless\n    blest                blest\n    blew                 blew\n    blind                blind\n    blinded              blind\n    blindfold            blindfold\n    blinding             blind\n    blindly              blindli\n    blindness            blind\n    blinds               blind\n    blink                blink\n    blinking             blink\n    bliss                bliss\n    blist                blist\n    blister              blister\n    blisters             blister\n    blithe               blith\n    blithild             blithild\n    bloat                bloat\n    block                block\n    blockish             blockish\n    blocks               block\n    blois                bloi\n    blood                blood\n    blooded              blood\n    bloodhound           bloodhound\n    bloodied             bloodi\n    bloodier             bloodier\n    bloodiest            bloodiest\n    bloodily             bloodili\n    bloodless            bloodless\n    bloods               blood\n    bloodshed            bloodsh\n    bloodshedding        bloodshed\n    bloodstained         bloodstain\n    bloody               bloodi\n    bloom                bloom\n    blooms               bloom\n    blossom              blossom\n    blossoming           blossom\n    blossoms             blossom\n    blot                 blot\n    blots                blot\n    blotted              blot\n    blotting             blot\n    blount               blount\n    blow                 blow\n    blowed               blow\n    blowers              blower\n    blowest              blowest\n    blowing              blow\n    blown                blown\n    blows                blow\n    blowse               blows\n    blubb                blubb\n    blubber              blubber\n    blubbering           blubber\n    blue                 blue\n    bluecaps             bluecap\n    bluest               bluest\n    blunt                blunt\n    blunted              blunt\n    blunter              blunter\n    bluntest             bluntest\n    blunting             blunt\n    bluntly              bluntli\n    bluntness            blunt\n    blunts               blunt\n    blur                 blur\n    blurr                blurr\n    blurs                blur\n    blush                blush\n    blushes              blush\n    blushest             blushest\n    blushing             blush\n    blust                blust\n    bluster              bluster\n    blusterer            bluster\n    blusters             bluster\n    bo                   bo\n    boar                 boar\n    board                board\n    boarded              board\n    boarding             board\n    boards               board\n    boarish              boarish\n    boars                boar\n    boast                boast\n    boasted              boast\n    boastful             boast\n    boasting             boast\n    boasts               boast\n    boat                 boat\n    boats                boat\n    boatswain            boatswain\n    bob                  bob\n    bobb                 bobb\n    boblibindo           boblibindo\n    bobtail              bobtail\n    bocchus              bocchu\n    bode                 bode\n    boded                bode\n    bodements            bodement\n    bodes                bode\n    bodg                 bodg\n    bodied               bodi\n    bodies               bodi\n    bodiless             bodiless\n    bodily               bodili\n    boding               bode\n    bodkin               bodkin\n    body                 bodi\n    bodykins             bodykin\n    bog                  bog\n    boggle               boggl\n    boggler              boggler\n    bogs                 bog\n    bohemia              bohemia\n    bohemian             bohemian\n    bohun                bohun\n    boil                 boil\n    boiling              boil\n    boils                boil\n    boist                boist\n    boisterous           boister\n    boisterously         boister\n    boitier              boitier\n    bold                 bold\n    bolden               bolden\n    bolder               bolder\n    boldest              boldest\n    boldly               boldli\n    boldness             bold\n    bolds                bold\n    bolingbroke          bolingbrok\n    bolster              bolster\n    bolt                 bolt\n    bolted               bolt\n    bolter               bolter\n    bolters              bolter\n    bolting              bolt\n    bolts                bolt\n    bombard              bombard\n    bombards             bombard\n    bombast              bombast\n    bon                  bon\n    bona                 bona\n    bond                 bond\n    bondage              bondag\n    bonded               bond\n    bondmaid             bondmaid\n    bondman              bondman\n    bondmen              bondmen\n    bonds                bond\n    bondslave            bondslav\n    bone                 bone\n    boneless             boneless\n    bones                bone\n    bonfire              bonfir\n    bonfires             bonfir\n    bonjour              bonjour\n    bonne                bonn\n    bonnet               bonnet\n    bonneted             bonnet\n    bonny                bonni\n    bonos                bono\n    bonto                bonto\n    bonville             bonvil\n    bood                 bood\n    book                 book\n    bookish              bookish\n    books                book\n    boon                 boon\n    boor                 boor\n    boorish              boorish\n    boors                boor\n    boot                 boot\n    booted               boot\n    booties              booti\n    bootless             bootless\n    boots                boot\n    booty                booti\n    bor                  bor\n    bora                 bora\n    borachio             borachio\n    bordeaux             bordeaux\n    border               border\n    bordered             border\n    borderers            border\n    borders              border\n    bore                 bore\n    boreas               borea\n    bores                bore\n    boring               bore\n    born                 born\n    borne                born\n    borough              borough\n    boroughs             borough\n    borrow               borrow\n    borrowed             borrow\n    borrower             borrow\n    borrowing            borrow\n    borrows              borrow\n    bosko                bosko\n    boskos               bosko\n    bosky                boski\n    bosom                bosom\n    bosoms               bosom\n    boson                boson\n    boss                 boss\n    bosworth             bosworth\n    botch                botch\n    botcher              botcher\n    botches              botch\n    botchy               botchi\n    both                 both\n    bots                 bot\n    bottle               bottl\n    bottled              bottl\n    bottles              bottl\n    bottom               bottom\n    bottomless           bottomless\n    bottoms              bottom\n    bouciqualt           bouciqualt\n    bouge                boug\n    bough                bough\n    boughs               bough\n    bought               bought\n    bounce               bounc\n    bouncing             bounc\n    bound                bound\n    bounded              bound\n    bounden              bounden\n    boundeth             boundeth\n    bounding             bound\n    boundless            boundless\n    bounds               bound\n    bounteous            bounteou\n    bounteously          bounteous\n    bounties             bounti\n    bountiful            bounti\n    bountifully          bountifulli\n    bounty               bounti\n    bourbier             bourbier\n    bourbon              bourbon\n    bourchier            bourchier\n    bourdeaux            bourdeaux\n    bourn                bourn\n    bout                 bout\n    bouts                bout\n    bove                 bove\n    bow                  bow\n    bowcase              bowcas\n    bowed                bow\n    bowels               bowel\n    bower                bower\n    bowing               bow\n    bowl                 bowl\n    bowler               bowler\n    bowling              bowl\n    bowls                bowl\n    bows                 bow\n    bowsprit             bowsprit\n    bowstring            bowstr\n    box                  box\n    boxes                box\n    boy                  boi\n    boyet                boyet\n    boyish               boyish\n    boys                 boi\n    brabant              brabant\n    brabantio            brabantio\n    brabble              brabbl\n    brabbler             brabbler\n    brac                 brac\n    brace                brace\n    bracelet             bracelet\n    bracelets            bracelet\n    brach                brach\n    bracy                braci\n    brag                 brag\n    bragg                bragg\n    braggardism          braggard\n    braggards            braggard\n    braggart             braggart\n    braggarts            braggart\n    bragged              brag\n    bragging             brag\n    bragless             bragless\n    brags                brag\n    braid                braid\n    braided              braid\n    brain                brain\n    brained              brain\n    brainford            brainford\n    brainish             brainish\n    brainless            brainless\n    brains               brain\n    brainsick            brainsick\n    brainsickly          brainsickli\n    brake                brake\n    brakenbury           brakenburi\n    brakes               brake\n    brambles             brambl\n    bran                 bran\n    branch               branch\n    branches             branch\n    branchless           branchless\n    brand                brand\n    branded              brand\n    brandish             brandish\n    brandon              brandon\n    brands               brand\n    bras                 bra\n    brass                brass\n    brassy               brassi\n    brat                 brat\n    brats                brat\n    brav                 brav\n    brave                brave\n    braved               brave\n    bravely              brave\n    braver               braver\n    bravery              braveri\n    braves               brave\n    bravest              bravest\n    braving              brave\n    brawl                brawl\n    brawler              brawler\n    brawling             brawl\n    brawls               brawl\n    brawn                brawn\n    brawns               brawn\n    bray                 brai\n    braying              brai\n    braz                 braz\n    brazen               brazen\n    brazier              brazier\n    breach               breach\n    breaches             breach\n    bread                bread\n    breadth              breadth\n    break                break\n    breaker              breaker\n    breakfast            breakfast\n    breaking             break\n    breaks               break\n    breast               breast\n    breasted             breast\n    breasting            breast\n    breastplate          breastplat\n    breasts              breast\n    breath               breath\n    breathe              breath\n    breathed             breath\n    breather             breather\n    breathers            breather\n    breathes             breath\n    breathest            breathest\n    breathing            breath\n    breathless           breathless\n    breaths              breath\n    brecknock            brecknock\n    bred                 bred\n    breech               breech\n    breeches             breech\n    breeching            breech\n    breed                breed\n    breeder              breeder\n    breeders             breeder\n    breeding             breed\n    breeds               breed\n    breese               brees\n    breeze               breez\n    breff                breff\n    bretagne             bretagn\n    brethen              brethen\n    bretheren            bretheren\n    brethren             brethren\n    brevis               brevi\n    brevity              breviti\n    brew                 brew\n    brewage              brewag\n    brewer               brewer\n    brewers              brewer\n    brewing              brew\n    brews                brew\n    briareus             briareu\n    briars               briar\n    brib                 brib\n    bribe                bribe\n    briber               briber\n    bribes               bribe\n    brick                brick\n    bricklayer           bricklay\n    bricks               brick\n    bridal               bridal\n    bride                bride\n    bridegroom           bridegroom\n    bridegrooms          bridegroom\n    brides               bride\n    bridge               bridg\n    bridgenorth          bridgenorth\n    bridges              bridg\n    bridget              bridget\n    bridle               bridl\n    bridled              bridl\n    brief                brief\n    briefer              briefer\n    briefest             briefest\n    briefly              briefli\n    briefness            brief\n    brier                brier\n    briers               brier\n    brigandine           brigandin\n    bright               bright\n    brighten             brighten\n    brightest            brightest\n    brightly             brightli\n    brightness           bright\n    brim                 brim\n    brimful              brim\n    brims                brim\n    brimstone            brimston\n    brinded              brind\n    brine                brine\n    bring                bring\n    bringer              bringer\n    bringeth             bringeth\n    bringing             bring\n    bringings            bring\n    brings               bring\n    brinish              brinish\n    brink                brink\n    brisk                brisk\n    brisky               briski\n    bristle              bristl\n    bristled             bristl\n    bristly              bristli\n    bristol              bristol\n    bristow              bristow\n    britain              britain\n    britaine             britain\n    britaines            britain\n    british              british\n    briton               briton\n    britons              briton\n    brittany             brittani\n    brittle              brittl\n    broach               broach\n    broached             broach\n    broad                broad\n    broader              broader\n    broadsides           broadsid\n    brocas               broca\n    brock                brock\n    brogues              brogu\n    broil                broil\n    broiling             broil\n    broils               broil\n    broke                broke\n    broken               broken\n    brokenly             brokenli\n    broker               broker\n    brokers              broker\n    brokes               broke\n    broking              broke\n    brooch               brooch\n    brooches             brooch\n    brood                brood\n    brooded              brood\n    brooding             brood\n    brook                brook\n    brooks               brook\n    broom                broom\n    broomstaff           broomstaff\n    broth                broth\n    brothel              brothel\n    brother              brother\n    brotherhood          brotherhood\n    brotherhoods         brotherhood\n    brotherly            brotherli\n    brothers             brother\n    broths               broth\n    brought              brought\n    brow                 brow\n    brown                brown\n    browner              browner\n    brownist             brownist\n    browny               browni\n    brows                brow\n    browse               brows\n    browsing             brows\n    bruis                brui\n    bruise               bruis\n    bruised              bruis\n    bruises              bruis\n    bruising             bruis\n    bruit                bruit\n    bruited              bruit\n    brundusium           brundusium\n    brunt                brunt\n    brush                brush\n    brushes              brush\n    brute                brute\n    brutish              brutish\n    brutus               brutu\n    bubble               bubbl\n    bubbles              bubbl\n    bubbling             bubbl\n    bubukles             bubukl\n    buck                 buck\n    bucket               bucket\n    buckets              bucket\n    bucking              buck\n    buckingham           buckingham\n    buckle               buckl\n    buckled              buckl\n    buckler              buckler\n    bucklers             buckler\n    bucklersbury         bucklersburi\n    buckles              buckl\n    buckram              buckram\n    bucks                buck\n    bud                  bud\n    budded               bud\n    budding              bud\n    budge                budg\n    budger               budger\n    budget               budget\n    buds                 bud\n    buff                 buff\n    buffet               buffet\n    buffeting            buffet\n    buffets              buffet\n    bug                  bug\n    bugbear              bugbear\n    bugle                bugl\n    bugs                 bug\n    build                build\n    builded              build\n    buildeth             buildeth\n    building             build\n    buildings            build\n    builds               build\n    built                built\n    bulk                 bulk\n    bulks                bulk\n    bull                 bull\n    bullcalf             bullcalf\n    bullen               bullen\n    bullens              bullen\n    bullet               bullet\n    bullets              bullet\n    bullocks             bullock\n    bulls                bull\n    bully                bulli\n    bulmer               bulmer\n    bulwark              bulwark\n    bulwarks             bulwark\n    bum                  bum\n    bumbast              bumbast\n    bump                 bump\n    bumper               bumper\n    bums                 bum\n    bunch                bunch\n    bunches              bunch\n    bundle               bundl\n    bung                 bung\n    bunghole             bunghol\n    bungle               bungl\n    bunting              bunt\n    buoy                 buoi\n    bur                  bur\n    burbolt              burbolt\n    burd                 burd\n    burden               burden\n    burdened             burden\n    burdening            burden\n    burdenous            burden\n    burdens              burden\n    burgh                burgh\n    burgher              burgher\n    burghers             burgher\n    burglary             burglari\n    burgomasters         burgomast\n    burgonet             burgonet\n    burgundy             burgundi\n    burial               burial\n    buried               buri\n    burier               burier\n    buriest              buriest\n    burly                burli\n    burn                 burn\n    burned               burn\n    burnet               burnet\n    burneth              burneth\n    burning              burn\n    burnish              burnish\n    burns                burn\n    burnt                burnt\n    burr                 burr\n    burrows              burrow\n    burs                 bur\n    burst                burst\n    bursting             burst\n    bursts               burst\n    burthen              burthen\n    burthens             burthen\n    burton               burton\n    bury                 buri\n    burying              buri\n    bush                 bush\n    bushels              bushel\n    bushes               bush\n    bushy                bushi\n    busied               busi\n    busily               busili\n    busines              busin\n    business             busi\n    businesses           busi\n    buskin               buskin\n    busky                buski\n    buss                 buss\n    busses               buss\n    bussing              buss\n    bustle               bustl\n    bustling             bustl\n    busy                 busi\n    but                  but\n    butcheed             butche\n    butcher              butcher\n    butchered            butcher\n    butcheries           butcheri\n    butcherly            butcherli\n    butchers             butcher\n    butchery             butcheri\n    butler               butler\n    butt                 butt\n    butter               butter\n    buttered             butter\n    butterflies          butterfli\n    butterfly            butterfli\n    butterwoman          butterwoman\n    buttery              butteri\n    buttock              buttock\n    buttocks             buttock\n    button               button\n    buttonhole           buttonhol\n    buttons              button\n    buttress             buttress\n    buttry               buttri\n    butts                butt\n    buxom                buxom\n    buy                  bui\n    buyer                buyer\n    buying               bui\n    buys                 bui\n    buzz                 buzz\n    buzzard              buzzard\n    buzzards             buzzard\n    buzzers              buzzer\n    buzzing              buzz\n    by                   by\n    bye                  bye\n    byzantium            byzantium\n    c                    c\n    ca                   ca\n    cabbage              cabbag\n    cabileros            cabilero\n    cabin                cabin\n    cabins               cabin\n    cable                cabl\n    cables               cabl\n    cackling             cackl\n    cacodemon            cacodemon\n    caddis               caddi\n    caddisses            caddiss\n    cade                 cade\n    cadence              cadenc\n    cadent               cadent\n    cades                cade\n    cadmus               cadmu\n    caduceus             caduceu\n    cadwal               cadwal\n    cadwallader          cadwallad\n    caelius              caeliu\n    caelo                caelo\n    caesar               caesar\n    caesarion            caesarion\n    caesars              caesar\n    cage                 cage\n    caged                cage\n    cagion               cagion\n    cain                 cain\n    caithness            caith\n    caitiff              caitiff\n    caitiffs             caitiff\n    caius                caiu\n    cak                  cak\n    cake                 cake\n    cakes                cake\n    calaber              calab\n    calais               calai\n    calamities           calam\n    calamity             calam\n    calchas              calcha\n    calculate            calcul\n    calen                calen\n    calendar             calendar\n    calendars            calendar\n    calf                 calf\n    caliban              caliban\n    calibans             caliban\n    calipolis            calipoli\n    cality               caliti\n    caliver              caliv\n    call                 call\n    callat               callat\n    called               call\n    callet               callet\n    calling              call\n    calls                call\n    calm                 calm\n    calmest              calmest\n    calmly               calmli\n    calmness             calm\n    calms                calm\n    calpurnia            calpurnia\n    calumniate           calumni\n    calumniating         calumni\n    calumnious           calumni\n    calumny              calumni\n    calve                calv\n    calved               calv\n    calves               calv\n    calveskins           calveskin\n    calydon              calydon\n    cam                  cam\n    cambio               cambio\n    cambria              cambria\n    cambric              cambric\n    cambrics             cambric\n    cambridge            cambridg\n    cambyses             cambys\n    came                 came\n    camel                camel\n    camelot              camelot\n    camels               camel\n    camest               camest\n    camillo              camillo\n    camlet               camlet\n    camomile             camomil\n    camp                 camp\n    campeius             campeiu\n    camping              camp\n    camps                camp\n    can                  can\n    canakin              canakin\n    canaries             canari\n    canary               canari\n    cancel               cancel\n    cancell              cancel\n    cancelled            cancel\n    cancelling           cancel\n    cancels              cancel\n    cancer               cancer\n    candidatus           candidatu\n    candied              candi\n    candle               candl\n    candles              candl\n    candlesticks         candlestick\n    candy                candi\n    canidius             canidiu\n    cank                 cank\n    canker               canker\n    cankerblossom        cankerblossom\n    cankers              canker\n    cannibally           cannib\n    cannibals            cannib\n    cannon               cannon\n    cannoneer            cannon\n    cannons              cannon\n    cannot               cannot\n    canon                canon\n    canoniz              canoniz\n    canonize             canon\n    canonized            canon\n    canons               canon\n    canopied             canopi\n    canopies             canopi\n    canopy               canopi\n    canst                canst\n    canstick             canstick\n    canterbury           canterburi\n    cantle               cantl\n    cantons              canton\n    canus                canu\n    canvas               canva\n    canvass              canvass\n    canzonet             canzonet\n    cap                  cap\n    capability           capabl\n    capable              capabl\n    capacities           capac\n    capacity             capac\n    caparison            caparison\n    capdv                capdv\n    cape                 cape\n    capel                capel\n    capels               capel\n    caper                caper\n    capers               caper\n    capet                capet\n    caphis               caphi\n    capilet              capilet\n    capitaine            capitain\n    capital              capit\n    capite               capit\n    capitol              capitol\n    capitulate           capitul\n    capocchia            capocchia\n    capon                capon\n    capons               capon\n    capp                 capp\n    cappadocia           cappadocia\n    capriccio            capriccio\n    capricious           caprici\n    caps                 cap\n    capt                 capt\n    captain              captain\n    captains             captain\n    captainship          captainship\n    captious             captiou\n    captivate            captiv\n    captivated           captiv\n    captivates           captiv\n    captive              captiv\n    captives             captiv\n    captivity            captiv\n    captum               captum\n    capucius             capuciu\n    capulet              capulet\n    capulets             capulet\n    car                  car\n    carack               carack\n    caracks              carack\n    carat                carat\n    caraways             carawai\n    carbonado            carbonado\n    carbuncle            carbuncl\n    carbuncled           carbuncl\n    carbuncles           carbuncl\n    carcanet             carcanet\n    carcase              carcas\n    carcases             carcas\n    carcass              carcass\n    carcasses            carcass\n    card                 card\n    cardecue             cardecu\n    carded               card\n    carders              carder\n    cardinal             cardin\n    cardinally           cardin\n    cardinals            cardin\n    cardmaker            cardmak\n    cards                card\n    carduus              carduu\n    care                 care\n    cared                care\n    career               career\n    careers              career\n    careful              care\n    carefully            carefulli\n    careless             careless\n    carelessly           carelessli\n    carelessness         careless\n    cares                care\n    caret                caret\n    cargo                cargo\n    carl                 carl\n    carlisle             carlisl\n    carlot               carlot\n    carman               carman\n    carmen               carmen\n    carnal               carnal\n    carnally             carnal\n    carnarvonshire       carnarvonshir\n    carnation            carnat\n    carnations           carnat\n    carol                carol\n    carous               carou\n    carouse              carous\n    caroused             carous\n    carouses             carous\n    carousing            carous\n    carp                 carp\n    carpenter            carpent\n    carper               carper\n    carpet               carpet\n    carpets              carpet\n    carping              carp\n    carriage             carriag\n    carriages            carriag\n    carried              carri\n    carrier              carrier\n    carriers             carrier\n    carries              carri\n    carrion              carrion\n    carrions             carrion\n    carry                carri\n    carrying             carri\n    cars                 car\n    cart                 cart\n    carters              carter\n    carthage             carthag\n    carts                cart\n    carv                 carv\n    carve                carv\n    carved               carv\n    carver               carver\n    carves               carv\n    carving              carv\n    cas                  ca\n    casa                 casa\n    casaer               casaer\n    casca                casca\n    case                 case\n    casement             casement\n    casements            casement\n    cases                case\n    cash                 cash\n    cashier              cashier\n    casing               case\n    cask                 cask\n    casket               casket\n    casketed             casket\n    caskets              casket\n    casque               casqu\n    casques              casqu\n    cassado              cassado\n    cassandra            cassandra\n    cassibelan           cassibelan\n    cassio               cassio\n    cassius              cassiu\n    cassocks             cassock\n    cast                 cast\n    castalion            castalion\n    castaway             castawai\n    castaways            castawai\n    casted               cast\n    caster               caster\n    castigate            castig\n    castigation          castig\n    castile              castil\n    castiliano           castiliano\n    casting              cast\n    castle               castl\n    castles              castl\n    casts                cast\n    casual               casual\n    casually             casual\n    casualties           casualti\n    casualty             casualti\n    cat                  cat\n    cataian              cataian\n    catalogue            catalogu\n    cataplasm            cataplasm\n    cataracts            cataract\n    catarrhs             catarrh\n    catastrophe          catastroph\n    catch                catch\n    catcher              catcher\n    catches              catch\n    catching             catch\n    cate                 cate\n    catechising          catechis\n    catechism            catech\n    catechize            catech\n    cater                cater\n    caterpillars         caterpillar\n    caters               cater\n    caterwauling         caterwaul\n    cates                cate\n    catesby              catesbi\n    cathedral            cathedr\n    catlike              catlik\n    catling              catl\n    catlings             catl\n    cato                 cato\n    cats                 cat\n    cattle               cattl\n    caucasus             caucasu\n    caudle               caudl\n    cauf                 cauf\n    caught               caught\n    cauldron             cauldron\n    caus                 cau\n    cause                caus\n    caused               caus\n    causeless            causeless\n    causer               causer\n    causes               caus\n    causest              causest\n    causeth              causeth\n    cautel               cautel\n    cautelous            cautel\n    cautels              cautel\n    cauterizing          cauter\n    caution              caution\n    cautions             caution\n    cavaleiro            cavaleiro\n    cavalery             cavaleri\n    cavaliers            cavali\n    cave                 cave\n    cavern               cavern\n    caverns              cavern\n    caves                cave\n    caveto               caveto\n    caviary              caviari\n    cavil                cavil\n    cavilling            cavil\n    cawdor               cawdor\n    cawdron              cawdron\n    cawing               caw\n    ce                   ce\n    ceas                 cea\n    cease                ceas\n    ceases               ceas\n    ceaseth              ceaseth\n    cedar                cedar\n    cedars               cedar\n    cedius               cediu\n    celebrate            celebr\n    celebrated           celebr\n    celebrates           celebr\n    celebration          celebr\n    celerity             celer\n    celestial            celesti\n    celia                celia\n    cell                 cell\n    cellar               cellar\n    cellarage            cellarag\n    celsa                celsa\n    cement               cement\n    censer               censer\n    censor               censor\n    censorinus           censorinu\n    censur               censur\n    censure              censur\n    censured             censur\n    censurers            censur\n    censures             censur\n    censuring            censur\n    centaur              centaur\n    centaurs             centaur\n    centre               centr\n    cents                cent\n    centuries            centuri\n    centurion            centurion\n    centurions           centurion\n    century              centuri\n    cerberus             cerberu\n    cerecloth            cerecloth\n    cerements            cerement\n    ceremonial           ceremoni\n    ceremonies           ceremoni\n    ceremonious          ceremoni\n    ceremoniously        ceremoni\n    ceremony             ceremoni\n    ceres                cere\n    cerns                cern\n    certain              certain\n    certainer            certain\n    certainly            certainli\n    certainties          certainti\n    certainty            certainti\n    certes               cert\n    certificate          certif\n    certified            certifi\n    certifies            certifi\n    certify              certifi\n    ces                  ce\n    cesario              cesario\n    cess                 cess\n    cesse                cess\n    cestern              cestern\n    cetera               cetera\n    cette                cett\n    chaces               chace\n    chaf                 chaf\n    chafe                chafe\n    chafed               chafe\n    chafes               chafe\n    chaff                chaff\n    chaffless            chaffless\n    chafing              chafe\n    chain                chain\n    chains               chain\n    chair                chair\n    chairs               chair\n    chalic               chalic\n    chalice              chalic\n    chalices             chalic\n    chalk                chalk\n    chalks               chalk\n    chalky               chalki\n    challeng             challeng\n    challenge            challeng\n    challenged           challeng\n    challenger           challeng\n    challengers          challeng\n    challenges           challeng\n    cham                 cham\n    chamber              chamber\n    chamberers           chamber\n    chamberlain          chamberlain\n    chamberlains         chamberlain\n    chambermaid          chambermaid\n    chambermaids         chambermaid\n    chambers             chamber\n    chameleon            chameleon\n    champ                champ\n    champagne            champagn\n    champain             champain\n    champains            champain\n    champion             champion\n    champions            champion\n    chanc                chanc\n    chance               chanc\n    chanced              chanc\n    chancellor           chancellor\n    chances              chanc\n    chandler             chandler\n    chang                chang\n    change               chang\n    changeable           changeabl\n    changed              chang\n    changeful            chang\n    changeling           changel\n    changelings          changel\n    changer              changer\n    changes              chang\n    changest             changest\n    changing             chang\n    channel              channel\n    channels             channel\n    chanson              chanson\n    chant                chant\n    chanticleer          chanticl\n    chanting             chant\n    chantries            chantri\n    chantry              chantri\n    chants               chant\n    chaos                chao\n    chap                 chap\n    chape                chape\n    chapel               chapel\n    chapeless            chapeless\n    chapels              chapel\n    chaplain             chaplain\n    chaplains            chaplain\n    chapless             chapless\n    chaplet              chaplet\n    chapmen              chapmen\n    chaps                chap\n    chapter              chapter\n    character            charact\n    charactered          charact\n    characterless        characterless\n    characters           charact\n    charactery           characteri\n    characts             charact\n    charbon              charbon\n    chare                chare\n    chares               chare\n    charg                charg\n    charge               charg\n    charged              charg\n    chargeful            charg\n    charges              charg\n    chargeth             chargeth\n    charging             charg\n    chariest             chariest\n    chariness            chari\n    charing              chare\n    chariot              chariot\n    chariots             chariot\n    charitable           charit\n    charitably           charit\n    charities            chariti\n    charity              chariti\n    charlemain           charlemain\n    charles              charl\n    charm                charm\n    charmed              charm\n    charmer              charmer\n    charmeth             charmeth\n    charmian             charmian\n    charming             charm\n    charmingly           charmingli\n    charms               charm\n    charneco             charneco\n    charnel              charnel\n    charolois            charoloi\n    charon               charon\n    charter              charter\n    charters             charter\n    chartreux            chartreux\n    chary                chari\n    charybdis            charybdi\n    chas                 cha\n    chase                chase\n    chased               chase\n    chaser               chaser\n    chaseth              chaseth\n    chasing              chase\n    chaste               chast\n    chastely             chast\n    chastis              chasti\n    chastise             chastis\n    chastised            chastis\n    chastisement         chastis\n    chastity             chastiti\n    chat                 chat\n    chatham              chatham\n    chatillon            chatillon\n    chats                chat\n    chatt                chatt\n    chattels             chattel\n    chatter              chatter\n    chattering           chatter\n    chattles             chattl\n    chaud                chaud\n    chaunted             chaunt\n    chaw                 chaw\n    chawdron             chawdron\n    che                  che\n    cheap                cheap\n    cheapen              cheapen\n    cheaper              cheaper\n    cheapest             cheapest\n    cheaply              cheapli\n    cheapside            cheapsid\n    cheat                cheat\n    cheated              cheat\n    cheater              cheater\n    cheaters             cheater\n    cheating             cheat\n    cheats               cheat\n    check                check\n    checked              check\n    checker              checker\n    checking             check\n    checks               check\n    cheek                cheek\n    cheeks               cheek\n    cheer                cheer\n    cheered              cheer\n    cheerer              cheerer\n    cheerful             cheer\n    cheerfully           cheerfulli\n    cheering             cheer\n    cheerless            cheerless\n    cheerly              cheerli\n    cheers               cheer\n    cheese               chees\n    chequer              chequer\n    cher                 cher\n    cherish              cherish\n    cherished            cherish\n    cherisher            cherish\n    cherishes            cherish\n    cherishing           cherish\n    cherries             cherri\n    cherry               cherri\n    cherrypit            cherrypit\n    chertsey             chertsei\n    cherub               cherub\n    cherubims            cherubim\n    cherubin             cherubin\n    cherubins            cherubin\n    cheshu               cheshu\n    chess                chess\n    chest                chest\n    chester              chester\n    chestnut             chestnut\n    chestnuts            chestnut\n    chests               chest\n    chetas               cheta\n    chev                 chev\n    cheval               cheval\n    chevalier            chevali\n    chevaliers           chevali\n    cheveril             cheveril\n    chew                 chew\n    chewed               chew\n    chewet               chewet\n    chewing              chew\n    chez                 chez\n    chi                  chi\n    chick                chick\n    chicken              chicken\n    chickens             chicken\n    chicurmurco          chicurmurco\n    chid                 chid\n    chidden              chidden\n    chide                chide\n    chiders              chider\n    chides               chide\n    chiding              chide\n    chief                chief\n    chiefest             chiefest\n    chiefly              chiefli\n    chien                chien\n    child                child\n    childed              child\n    childeric            childer\n    childhood            childhood\n    childhoods           childhood\n    childing             child\n    childish             childish\n    childishness         childish\n    childlike            childlik\n    childness            child\n    children             children\n    chill                chill\n    chilling             chill\n    chime                chime\n    chimes               chime\n    chimney              chimnei\n    chimneypiece         chimneypiec\n    chimneys             chimnei\n    chimurcho            chimurcho\n    chin                 chin\n    china                china\n    chine                chine\n    chines               chine\n    chink                chink\n    chinks               chink\n    chins                chin\n    chipp                chipp\n    chipper              chipper\n    chips                chip\n    chiron               chiron\n    chirping             chirp\n    chirrah              chirrah\n    chirurgeonly         chirurgeonli\n    chisel               chisel\n    chitopher            chitoph\n    chivalrous           chivalr\n    chivalry             chivalri\n    choice               choic\n    choicely             choic\n    choicest             choicest\n    choir                choir\n    choirs               choir\n    chok                 chok\n    choke                choke\n    choked               choke\n    chokes               choke\n    choking              choke\n    choler               choler\n    choleric             choler\n    cholers              choler\n    chollors             chollor\n    choose               choos\n    chooser              chooser\n    chooses              choos\n    chooseth             chooseth\n    choosing             choos\n    chop                 chop\n    chopine              chopin\n    choplogic            choplog\n    chopp                chopp\n    chopped              chop\n    chopping             chop\n    choppy               choppi\n    chops                chop\n    chopt                chopt\n    chor                 chor\n    choristers           chorist\n    chorus               choru\n    chose                chose\n    chosen               chosen\n    chough               chough\n    choughs              chough\n    chrish               chrish\n    christ               christ\n    christen             christen\n    christendom          christendom\n    christendoms         christendom\n    christening          christen\n    christenings         christen\n    christian            christian\n    christianlike        christianlik\n    christians           christian\n    christmas            christma\n    christom             christom\n    christopher          christoph\n    christophero         christophero\n    chronicle            chronicl\n    chronicled           chronicl\n    chronicler           chronicl\n    chroniclers          chronicl\n    chronicles           chronicl\n    chrysolite           chrysolit\n    chuck                chuck\n    chucks               chuck\n    chud                 chud\n    chuffs               chuff\n    church               church\n    churches             church\n    churchman            churchman\n    churchmen            churchmen\n    churchyard           churchyard\n    churchyards          churchyard\n    churl                churl\n    churlish             churlish\n    churlishly           churlishli\n    churls               churl\n    churn                churn\n    chus                 chu\n    cicatrice            cicatric\n    cicatrices           cicatric\n    cicely               cice\n    cicero               cicero\n    ciceter              cicet\n    ciel                 ciel\n    ciitzens             ciitzen\n    cilicia              cilicia\n    cimber               cimber\n    cimmerian            cimmerian\n    cinable              cinabl\n    cincture             cinctur\n    cinders              cinder\n    cine                 cine\n    cinna                cinna\n    cinque               cinqu\n    cipher               cipher\n    ciphers              cipher\n    circa                circa\n    circe                circ\n    circle               circl\n    circled              circl\n    circlets             circlet\n    circling             circl\n    circuit              circuit\n    circum               circum\n    circumcised          circumcis\n    circumference        circumfer\n    circummur            circummur\n    circumscrib          circumscrib\n    circumscribed        circumscrib\n    circumscription      circumscript\n    circumspect          circumspect\n    circumstance         circumst\n    circumstanced        circumstanc\n    circumstances        circumst\n    circumstantial       circumstanti\n    circumvent           circumv\n    circumvention        circumvent\n    cistern              cistern\n    citadel              citadel\n    cital                cital\n    cite                 cite\n    cited                cite\n    cites                cite\n    cities               citi\n    citing               cite\n    citizen              citizen\n    citizens             citizen\n    cittern              cittern\n    city                 citi\n    civet                civet\n    civil                civil\n    civility             civil\n    civilly              civilli\n    clack                clack\n    clad                 clad\n    claim                claim\n    claiming             claim\n    claims               claim\n    clamb                clamb\n    clamber              clamber\n    clammer              clammer\n    clamor               clamor\n    clamorous            clamor\n    clamors              clamor\n    clamour              clamour\n    clamours             clamour\n    clang                clang\n    clangor              clangor\n    clap                 clap\n    clapp                clapp\n    clapped              clap\n    clapper              clapper\n    clapping             clap\n    claps                clap\n    clare                clare\n    clarence             clarenc\n    claret               claret\n    claribel             claribel\n    clasp                clasp\n    clasps               clasp\n    clatter              clatter\n    claud                claud\n    claudio              claudio\n    claudius             claudiu\n    clause               claus\n    claw                 claw\n    clawed               claw\n    clawing              claw\n    claws                claw\n    clay                 clai\n    clays                clai\n    clean                clean\n    cleanliest           cleanliest\n    cleanly              cleanli\n    cleans               clean\n    cleanse              cleans\n    cleansing            cleans\n    clear                clear\n    clearer              clearer\n    clearest             clearest\n    clearly              clearli\n    clearness            clear\n    clears               clear\n    cleave               cleav\n    cleaving             cleav\n    clef                 clef\n    cleft                cleft\n    cleitus              cleitu\n    clemency             clemenc\n    clement              clement\n    cleomenes            cleomen\n    cleopatpa            cleopatpa\n    cleopatra            cleopatra\n    clepeth              clepeth\n    clept                clept\n    clerestories         clerestori\n    clergy               clergi\n    clergyman            clergyman\n    clergymen            clergymen\n    clerk                clerk\n    clerkly              clerkli\n    clerks               clerk\n    clew                 clew\n    client               client\n    clients              client\n    cliff                cliff\n    clifford             clifford\n    cliffords            clifford\n    cliffs               cliff\n    clifton              clifton\n    climate              climat\n    climature            climatur\n    climb                climb\n    climbed              climb\n    climber              climber\n    climbeth             climbeth\n    climbing             climb\n    climbs               climb\n    clime                clime\n    cling                cling\n    clink                clink\n    clinking             clink\n    clinquant            clinquant\n    clip                 clip\n    clipp                clipp\n    clipper              clipper\n    clippeth             clippeth\n    clipping             clip\n    clipt                clipt\n    clitus               clitu\n    clo                  clo\n    cloak                cloak\n    cloakbag             cloakbag\n    cloaks               cloak\n    clock                clock\n    clocks               clock\n    clod                 clod\n    cloddy               cloddi\n    clodpole             clodpol\n    clog                 clog\n    clogging             clog\n    clogs                clog\n    cloister             cloister\n    cloistress           cloistress\n    cloquence            cloquenc\n    clos                 clo\n    close                close\n    closed               close\n    closely              close\n    closeness            close\n    closer               closer\n    closes               close\n    closest              closest\n    closet               closet\n    closing              close\n    closure              closur\n    cloten               cloten\n    clotens              cloten\n    cloth                cloth\n    clothair             clothair\n    clotharius           clothariu\n    clothe               cloth\n    clothes              cloth\n    clothier             clothier\n    clothiers            clothier\n    clothing             cloth\n    cloths               cloth\n    clotpoles            clotpol\n    clotpoll             clotpol\n    cloud                cloud\n    clouded              cloud\n    cloudiness           cloudi\n    clouds               cloud\n    cloudy               cloudi\n    clout                clout\n    clouted              clout\n    clouts               clout\n    cloven               cloven\n    clover               clover\n    cloves               clove\n    clovest              clovest\n    clowder              clowder\n    clown                clown\n    clownish             clownish\n    clowns               clown\n    cloy                 cloi\n    cloyed               cloi\n    cloying              cloi\n    cloyless             cloyless\n    cloyment             cloyment\n    cloys                cloi\n    club                 club\n    clubs                club\n    cluck                cluck\n    clung                clung\n    clust                clust\n    clusters             cluster\n    clutch               clutch\n    clyster              clyster\n    cneius               cneiu\n    cnemies              cnemi\n    co                   co\n    coach                coach\n    coaches              coach\n    coachmakers          coachmak\n    coact                coact\n    coactive             coactiv\n    coagulate            coagul\n    coal                 coal\n    coals                coal\n    coarse               coars\n    coarsely             coars\n    coast                coast\n    coasting             coast\n    coasts               coast\n    coat                 coat\n    coated               coat\n    coats                coat\n    cobble               cobbl\n    cobbled              cobbl\n    cobbler              cobbler\n    cobham               cobham\n    cobloaf              cobloaf\n    cobweb               cobweb\n    cobwebs              cobweb\n    cock                 cock\n    cockatrice           cockatric\n    cockatrices          cockatric\n    cockle               cockl\n    cockled              cockl\n    cockney              cocknei\n    cockpit              cockpit\n    cocks                cock\n    cocksure             cocksur\n    coctus               coctu\n    cocytus              cocytu\n    cod                  cod\n    codding              cod\n    codling              codl\n    codpiece             codpiec\n    codpieces            codpiec\n    cods                 cod\n    coelestibus          coelestibu\n    coesar               coesar\n    coeur                coeur\n    coffer               coffer\n    coffers              coffer\n    coffin               coffin\n    coffins              coffin\n    cog                  cog\n    cogging              cog\n    cogitation           cogit\n    cogitations          cogit\n    cognition            cognit\n    cognizance           cogniz\n    cogscomb             cogscomb\n    cohabitants          cohabit\n    coher                coher\n    cohere               coher\n    coherence            coher\n    coherent             coher\n    cohorts              cohort\n    coif                 coif\n    coign                coign\n    coil                 coil\n    coin                 coin\n    coinage              coinag\n    coiner               coiner\n    coining              coin\n    coins                coin\n    col                  col\n    colbrand             colbrand\n    colchos              colcho\n    cold                 cold\n    colder               colder\n    coldest              coldest\n    coldly               coldli\n    coldness             cold\n    coldspur             coldspur\n    colebrook            colebrook\n    colic                colic\n    collar               collar\n    collars              collar\n    collateral           collater\n    colleagued           colleagu\n    collect              collect\n    collected            collect\n    collection           collect\n    college              colleg\n    colleges             colleg\n    collied              colli\n    collier              collier\n    colliers             collier\n    collop               collop\n    collusion            collus\n    colme                colm\n    colmekill            colmekil\n    coloquintida         coloquintida\n    color                color\n    colors               color\n    colossus             colossu\n    colour               colour\n    colourable           colour\n    coloured             colour\n    colouring            colour\n    colours              colour\n    colt                 colt\n    colted               colt\n    colts                colt\n    columbine            columbin\n    columbines           columbin\n    colville             colvil\n    com                  com\n    comagene             comagen\n    comart               comart\n    comb                 comb\n    combat               combat\n    combatant            combat\n    combatants           combat\n    combated             combat\n    combating            combat\n    combin               combin\n    combinate            combin\n    combination          combin\n    combine              combin\n    combined             combin\n    combless             combless\n    combustion           combust\n    come                 come\n    comedian             comedian\n    comedians            comedian\n    comedy               comedi\n    comeliness           comeli\n    comely               come\n    comer                comer\n    comers               comer\n    comes                come\n    comest               comest\n    comet                comet\n    cometh               cometh\n    comets               comet\n    comfect              comfect\n    comfit               comfit\n    comfits              comfit\n    comfort              comfort\n    comfortable          comfort\n    comforted            comfort\n    comforter            comfort\n    comforting           comfort\n    comfortless          comfortless\n    comforts             comfort\n    comic                comic\n    comical              comic\n    coming               come\n    comings              come\n    cominius             cominiu\n    comma                comma\n    command              command\n    commande             command\n    commanded            command\n    commander            command\n    commanders           command\n    commanding           command\n    commandment          command\n    commandments         command\n    commands             command\n    comme                comm\n    commenc              commenc\n    commence             commenc\n    commenced            commenc\n    commencement         commenc\n    commences            commenc\n    commencing           commenc\n    commend              commend\n    commendable          commend\n    commendation         commend\n    commendations        commend\n    commended            commend\n    commending           commend\n    commends             commend\n    comment              comment\n    commentaries         commentari\n    commenting           comment\n    comments             comment\n    commerce             commerc\n    commingled           commingl\n    commiseration        commiser\n    commission           commiss\n    commissioners        commission\n    commissions          commiss\n    commit               commit\n    commits              commit\n    committ              committ\n    committed            commit\n    committing           commit\n    commix               commix\n    commixed             commix\n    commixtion           commixt\n    commixture           commixtur\n    commodious           commodi\n    commodities          commod\n    commodity            commod\n    common               common\n    commonalty           commonalti\n    commoner             common\n    commoners            common\n    commonly             commonli\n    commons              common\n    commonweal           commonw\n    commonwealth         commonwealth\n    commotion            commot\n    commotions           commot\n    commune              commun\n    communicat           communicat\n    communicate          commun\n    communication        commun\n    communities          commun\n    community            commun\n    comonty              comonti\n    compact              compact\n    companies            compani\n    companion            companion\n    companions           companion\n    companionship        companionship\n    company              compani\n    compar               compar\n    comparative          compar\n    compare              compar\n    compared             compar\n    comparing            compar\n    comparison           comparison\n    comparisons          comparison\n    compartner           compartn\n    compass              compass\n    compasses            compass\n    compassing           compass\n    compassion           compass\n    compassionate        compassion\n    compeers             compeer\n    compel               compel\n    compell              compel\n    compelled            compel\n    compelling           compel\n    compels              compel\n    compensation         compens\n    competence           compet\n    competency           compet\n    competent            compet\n    competitor           competitor\n    competitors          competitor\n    compil               compil\n    compile              compil\n    compiled             compil\n    complain             complain\n    complainer           complain\n    complainest          complainest\n    complaining          complain\n    complainings         complain\n    complains            complain\n    complaint            complaint\n    complaints           complaint\n    complement           complement\n    complements          complement\n    complete             complet\n    complexion           complexion\n    complexioned         complexion\n    complexions          complexion\n    complices            complic\n    complies             compli\n    compliment           compliment\n    complimental         compliment\n    compliments          compliment\n    complot              complot\n    complots             complot\n    complotted           complot\n    comply               compli\n    compos               compo\n    compose              compos\n    composed             compos\n    composition          composit\n    compost              compost\n    composture           compostur\n    composure            composur\n    compound             compound\n    compounded           compound\n    compounds            compound\n    comprehend           comprehend\n    comprehended         comprehend\n    comprehends          comprehend\n    compremises          compremis\n    compris              compri\n    comprising           compris\n    compromis            compromi\n    compromise           compromis\n    compt                compt\n    comptible            comptibl\n    comptrollers         comptrol\n    compulsatory         compulsatori\n    compulsion           compuls\n    compulsive           compuls\n    compunctious         compuncti\n    computation          comput\n    comrade              comrad\n    comrades             comrad\n    comutual             comutu\n    con                  con\n    concave              concav\n    concavities          concav\n    conceal              conceal\n    concealed            conceal\n    concealing           conceal\n    concealment          conceal\n    concealments         conceal\n    conceals             conceal\n    conceit              conceit\n    conceited            conceit\n    conceitless          conceitless\n    conceits             conceit\n    conceiv              conceiv\n    conceive             conceiv\n    conceived            conceiv\n    conceives            conceiv\n    conceiving           conceiv\n    conception           concept\n    conceptions          concept\n    conceptious          concepti\n    concern              concern\n    concernancy          concern\n    concerneth           concerneth\n    concerning           concern\n    concernings          concern\n    concerns             concern\n    conclave             conclav\n    conclud              conclud\n    conclude             conclud\n    concluded            conclud\n    concludes            conclud\n    concluding           conclud\n    conclusion           conclus\n    conclusions          conclus\n    concolinel           concolinel\n    concord              concord\n    concubine            concubin\n    concupiscible        concupisc\n    concupy              concupi\n    concur               concur\n    concurring           concur\n    concurs              concur\n    condemn              condemn\n    condemnation         condemn\n    condemned            condemn\n    condemning           condemn\n    condemns             condemn\n    condescend           condescend\n    condign              condign\n    condition            condit\n    conditionally        condition\n    conditions           condit\n    condole              condol\n    condolement          condol\n    condoling            condol\n    conduce              conduc\n    conduct              conduct\n    conducted            conduct\n    conducting           conduct\n    conductor            conductor\n    conduit              conduit\n    conduits             conduit\n    conected             conect\n    coney                conei\n    confection           confect\n    confectionary        confectionari\n    confections          confect\n    confederacy          confederaci\n    confederate          confeder\n    confederates         confeder\n    confer               confer\n    conference           confer\n    conferr              conferr\n    conferring           confer\n    confess              confess\n    confessed            confess\n    confesses            confess\n    confesseth           confesseth\n    confessing           confess\n    confession           confess\n    confessions          confess\n    confessor            confessor\n    confidence           confid\n    confident            confid\n    confidently          confid\n    confin               confin\n    confine              confin\n    confined             confin\n    confineless          confineless\n    confiners            confin\n    confines             confin\n    confining            confin\n    confirm              confirm\n    confirmation         confirm\n    confirmations        confirm\n    confirmed            confirm\n    confirmer            confirm\n    confirmers           confirm\n    confirming           confirm\n    confirmities         confirm\n    confirms             confirm\n    confiscate           confisc\n    confiscated          confisc\n    confiscation         confisc\n    confixed             confix\n    conflict             conflict\n    conflicting          conflict\n    conflicts            conflict\n    confluence           confluenc\n    conflux              conflux\n    conform              conform\n    conformable          conform\n    confound             confound\n    confounded           confound\n    confounding          confound\n    confounds            confound\n    confront             confront\n    confronted           confront\n    confus               confu\n    confused             confus\n    confusedly           confusedli\n    confusion            confus\n    confusions           confus\n    confutation          confut\n    confutes             confut\n    congeal              congeal\n    congealed            congeal\n    congealment          congeal\n    congee               conge\n    conger               conger\n    congest              congest\n    congied              congi\n    congratulate         congratul\n    congreeing           congre\n    congreeted           congreet\n    congregate           congreg\n    congregated          congreg\n    congregation         congreg\n    congregations        congreg\n    congruent            congruent\n    congruing            congru\n    conies               coni\n    conjectural          conjectur\n    conjecture           conjectur\n    conjectures          conjectur\n    conjoin              conjoin\n    conjoined            conjoin\n    conjoins             conjoin\n    conjointly           conjointli\n    conjunct             conjunct\n    conjunction          conjunct\n    conjunctive          conjunct\n    conjur               conjur\n    conjuration          conjur\n    conjurations         conjur\n    conjure              conjur\n    conjured             conjur\n    conjurer             conjur\n    conjurers            conjur\n    conjures             conjur\n    conjuring            conjur\n    conjuro              conjuro\n    conn                 conn\n    connected            connect\n    connive              conniv\n    conqu                conqu\n    conquer              conquer\n    conquered            conquer\n    conquering           conquer\n    conqueror            conqueror\n    conquerors           conqueror\n    conquers             conquer\n    conquest             conquest\n    conquests            conquest\n    conquring            conqur\n    conrade              conrad\n    cons                 con\n    consanguineous       consanguin\n    consanguinity        consanguin\n    conscienc            conscienc\n    conscience           conscienc\n    consciences          conscienc\n    conscionable         conscion\n    consecrate           consecr\n    consecrated          consecr\n    consecrations        consecr\n    consent              consent\n    consented            consent\n    consenting           consent\n    consents             consent\n    consequence          consequ\n    consequences         consequ\n    consequently         consequ\n    conserve             conserv\n    conserved            conserv\n    conserves            conserv\n    consider             consid\n    considerance         consider\n    considerate          consider\n    consideration        consider\n    considerations       consider\n    considered           consid\n    considering          consid\n    considerings         consid\n    considers            consid\n    consign              consign\n    consigning           consign\n    consist              consist\n    consisteth           consisteth\n    consisting           consist\n    consistory           consistori\n    consists             consist\n    consolate            consol\n    consolation          consol\n    consonancy           conson\n    consonant            conson\n    consort              consort\n    consorted            consort\n    consortest           consortest\n    conspectuities       conspectu\n    conspir              conspir\n    conspiracy           conspiraci\n    conspirant           conspir\n    conspirator          conspir\n    conspirators         conspir\n    conspire             conspir\n    conspired            conspir\n    conspirers           conspir\n    conspires            conspir\n    conspiring           conspir\n    constable            constabl\n    constables           constabl\n    constance            constanc\n    constancies          constanc\n    constancy            constanc\n    constant             constant\n    constantine          constantin\n    constantinople       constantinopl\n    constantly           constantli\n    constellation        constel\n    constitution         constitut\n    constrain            constrain\n    constrained          constrain\n    constraineth         constraineth\n    constrains           constrain\n    constraint           constraint\n    constring            constr\n    construction         construct\n    construe             constru\n    consul               consul\n    consuls              consul\n    consulship           consulship\n    consulships          consulship\n    consult              consult\n    consulting           consult\n    consults             consult\n    consum               consum\n    consume              consum\n    consumed             consum\n    consumes             consum\n    consuming            consum\n    consummate           consumm\n    consummation         consumm\n    consumption          consumpt\n    consumptions         consumpt\n    contagion            contagion\n    contagious           contagi\n    contain              contain\n    containing           contain\n    contains             contain\n    contaminate          contamin\n    contaminated         contamin\n    contemn              contemn\n    contemned            contemn\n    contemning           contemn\n    contemns             contemn\n    contemplate          contempl\n    contemplation        contempl\n    contemplative        contempl\n    contempt             contempt\n    contemptible         contempt\n    contempts            contempt\n    contemptuous         contemptu\n    contemptuously       contemptu\n    contend              contend\n    contended            contend\n    contending           contend\n    contendon            contendon\n    content              content\n    contenta             contenta\n    contented            content\n    contenteth           contenteth\n    contention           content\n    contentious          contenti\n    contentless          contentless\n    contento             contento\n    contents             content\n    contest              contest\n    contestation         contest\n    continence           contin\n    continency           contin\n    continent            contin\n    continents           contin\n    continu              continu\n    continual            continu\n    continually          continu\n    continuance          continu\n    continuantly         continuantli\n    continuate           continu\n    continue             continu\n    continued            continu\n    continuer            continu\n    continues            continu\n    continuing           continu\n    contract             contract\n    contracted           contract\n    contracting          contract\n    contraction          contract\n    contradict           contradict\n    contradicted         contradict\n    contradiction        contradict\n    contradicts          contradict\n    contraries           contrari\n    contrarieties        contrarieti\n    contrariety          contrarieti\n    contrarious          contrari\n    contrariously        contrari\n    contrary             contrari\n    contre               contr\n    contribution         contribut\n    contributors         contributor\n    contrite             contrit\n    contriv              contriv\n    contrive             contriv\n    contrived            contriv\n    contriver            contriv\n    contrives            contriv\n    contriving           contriv\n    control              control\n    controll             control\n    controller           control\n    controlling          control\n    controlment          control\n    controls             control\n    controversy          controversi\n    contumelious         contumeli\n    contumeliously       contumeli\n    contumely            contum\n    contusions           contus\n    convenience          conveni\n    conveniences         conveni\n    conveniency          conveni\n    convenient           conveni\n    conveniently         conveni\n    convented            convent\n    conventicles         conventicl\n    convents             convent\n    convers              conver\n    conversant           convers\n    conversation         convers\n    conversations        convers\n    converse             convers\n    conversed            convers\n    converses            convers\n    conversing           convers\n    conversion           convers\n    convert              convert\n    converted            convert\n    convertest           convertest\n    converting           convert\n    convertite           convertit\n    convertites          convertit\n    converts             convert\n    convey               convei\n    conveyance           convey\n    conveyances          convey\n    conveyers            convey\n    conveying            convei\n    convict              convict\n    convicted            convict\n    convince             convinc\n    convinced            convinc\n    convinces            convinc\n    convive              conviv\n    convocation          convoc\n    convoy               convoi\n    convulsions          convuls\n    cony                 coni\n    cook                 cook\n    cookery              cookeri\n    cooks                cook\n    cool                 cool\n    cooled               cool\n    cooling              cool\n    cools                cool\n    coop                 coop\n    coops                coop\n    cop                  cop\n    copatain             copatain\n    cope                 cope\n    cophetua             cophetua\n    copied               copi\n    copies               copi\n    copious              copiou\n    copper               copper\n    copperspur           copperspur\n    coppice              coppic\n    copulation           copul\n    copulatives          copul\n    copy                 copi\n    cor                  cor\n    coragio              coragio\n    coral                coral\n    coram                coram\n    corambus             corambu\n    coranto              coranto\n    corantos             coranto\n    corbo                corbo\n    cord                 cord\n    corded               cord\n    cordelia             cordelia\n    cordial              cordial\n    cordis               cordi\n    cords                cord\n    core                 core\n    corin                corin\n    corinth              corinth\n    corinthian           corinthian\n    coriolanus           coriolanu\n    corioli              corioli\n    cork                 cork\n    corky                corki\n    cormorant            cormor\n    corn                 corn\n    cornelia             cornelia\n    cornelius            corneliu\n    corner               corner\n    corners              corner\n    cornerstone          cornerston\n    cornets              cornet\n    cornish              cornish\n    corns                corn\n    cornuto              cornuto\n    cornwall             cornwal\n    corollary            corollari\n    coronal              coron\n    coronation           coron\n    coronet              coronet\n    coronets             coronet\n    corporal             corpor\n    corporals            corpor\n    corporate            corpor\n    corpse               corps\n    corpulent            corpul\n    correct              correct\n    corrected            correct\n    correcting           correct\n    correction           correct\n    correctioner         correction\n    corrects             correct\n    correspondence       correspond\n    correspondent        correspond\n    corresponding        correspond\n    corresponsive        correspons\n    corrigible           corrig\n    corrival             corriv\n    corrivals            corriv\n    corroborate          corrobor\n    corrosive            corros\n    corrupt              corrupt\n    corrupted            corrupt\n    corrupter            corrupt\n    corrupters           corrupt\n    corruptible          corrupt\n    corruptibly          corrupt\n    corrupting           corrupt\n    corruption           corrupt\n    corruptly            corruptli\n    corrupts             corrupt\n    corse                cors\n    corses               cors\n    corslet              corslet\n    cosmo                cosmo\n    cost                 cost\n    costard              costard\n    costermongers        costermong\n    costlier             costlier\n    costly               costli\n    costs                cost\n    cot                  cot\n    cote                 cote\n    coted                cote\n    cotsall              cotsal\n    cotsole              cotsol\n    cotswold             cotswold\n    cottage              cottag\n    cottages             cottag\n    cotus                cotu\n    couch                couch\n    couched              couch\n    couching             couch\n    couchings            couch\n    coude                coud\n    cough                cough\n    coughing             cough\n    could                could\n    couldst              couldst\n    coulter              coulter\n    council              council\n    councillor           councillor\n    councils             council\n    counsel              counsel\n    counsell             counsel\n    counsellor           counsellor\n    counsellors          counsellor\n    counselor            counselor\n    counselors           counselor\n    counsels             counsel\n    count                count\n    counted              count\n    countenanc           countenanc\n    countenance          counten\n    countenances         counten\n    counter              counter\n    counterchange        counterchang\n    countercheck         countercheck\n    counterfeit          counterfeit\n    counterfeited        counterfeit\n    counterfeiting       counterfeit\n    counterfeitly        counterfeitli\n    counterfeits         counterfeit\n    countermand          countermand\n    countermands         countermand\n    countermines         countermin\n    counterpart          counterpart\n    counterpoints        counterpoint\n    counterpois          counterpoi\n    counterpoise         counterpois\n    counters             counter\n    countervail          countervail\n    countess             countess\n    countesses           countess\n    counties             counti\n    counting             count\n    countless            countless\n    countries            countri\n    countrv              countrv\n    country              countri\n    countryman           countryman\n    countrymen           countrymen\n    counts               count\n    county               counti\n    couper               couper\n    couple               coupl\n    coupled              coupl\n    couplement           couplement\n    couples              coupl\n    couplet              couplet\n    couplets             couplet\n    cour                 cour\n    courage              courag\n    courageous           courag\n    courageously         courag\n    courages             courag\n    courier              courier\n    couriers             courier\n    couronne             couronn\n    cours                cour\n    course               cours\n    coursed              cours\n    courser              courser\n    coursers             courser\n    courses              cours\n    coursing             cours\n    court                court\n    courted              court\n    courteous            courteou\n    courteously          courteous\n    courtesan            courtesan\n    courtesies           courtesi\n    courtesy             courtesi\n    courtezan            courtezan\n    courtezans           courtezan\n    courtier             courtier\n    courtiers            courtier\n    courtlike            courtlik\n    courtly              courtli\n    courtney             courtnei\n    courts               court\n    courtship            courtship\n    cousin               cousin\n    cousins              cousin\n    couterfeit           couterfeit\n    coutume              coutum\n    covenant             coven\n    covenants            coven\n    covent               covent\n    coventry             coventri\n    cover                cover\n    covered              cover\n    covering             cover\n    coverlet             coverlet\n    covers               cover\n    covert               covert\n    covertly             covertli\n    coverture            covertur\n    covet                covet\n    coveted              covet\n    coveting             covet\n    covetings            covet\n    covetous             covet\n    covetously           covet\n    covetousness         covet\n    covets               covet\n    cow                  cow\n    coward               coward\n    cowarded             coward\n    cowardice            cowardic\n    cowardly             cowardli\n    cowards              coward\n    cowardship           cowardship\n    cowish               cowish\n    cowl                 cowl\n    cowslip              cowslip\n    cowslips             cowslip\n    cox                  cox\n    coxcomb              coxcomb\n    coxcombs             coxcomb\n    coy                  coi\n    coystrill            coystril\n    coz                  coz\n    cozen                cozen\n    cozenage             cozenag\n    cozened              cozen\n    cozener              cozen\n    cozeners             cozen\n    cozening             cozen\n    coziers              cozier\n    crab                 crab\n    crabbed              crab\n    crabs                crab\n    crack                crack\n    cracked              crack\n    cracker              cracker\n    crackers             cracker\n    cracking             crack\n    cracks               crack\n    cradle               cradl\n    cradled              cradl\n    cradles              cradl\n    craft                craft\n    crafted              craft\n    craftied             crafti\n    craftier             craftier\n    craftily             craftili\n    crafts               craft\n    craftsmen            craftsmen\n    crafty               crafti\n    cram                 cram\n    cramm                cramm\n    cramp                cramp\n    cramps               cramp\n    crams                cram\n    cranking             crank\n    cranks               crank\n    cranmer              cranmer\n    crannied             cranni\n    crannies             cranni\n    cranny               cranni\n    crants               crant\n    crare                crare\n    crash                crash\n    crassus              crassu\n    crav                 crav\n    crave                crave\n    craved               crave\n    craven               craven\n    cravens              craven\n    craves               crave\n    craveth              craveth\n    craving              crave\n    crawl                crawl\n    crawling             crawl\n    crawls               crawl\n    craz                 craz\n    crazed               craze\n    crazy                crazi\n    creaking             creak\n    cream                cream\n    create               creat\n    created              creat\n    creates              creat\n    creating             creat\n    creation             creation\n    creator              creator\n    creature             creatur\n    creatures            creatur\n    credence             credenc\n    credent              credent\n    credible             credibl\n    credit               credit\n    creditor             creditor\n    creditors            creditor\n    credo                credo\n    credulity            credul\n    credulous            credul\n    creed                creed\n    creek                creek\n    creeks               creek\n    creep                creep\n    creeping             creep\n    creeps               creep\n    crept                crept\n    crescent             crescent\n    crescive             cresciv\n    cressets             cresset\n    cressid              cressid\n    cressida             cressida\n    cressids             cressid\n    cressy               cressi\n    crest                crest\n    crested              crest\n    crestfall            crestfal\n    crestless            crestless\n    crests               crest\n    cretan               cretan\n    crete                crete\n    crevice              crevic\n    crew                 crew\n    crews                crew\n    crib                 crib\n    cribb                cribb\n    cribs                crib\n    cricket              cricket\n    crickets             cricket\n    cried                cri\n    criedst              criedst\n    crier                crier\n    cries                cri\n    criest               criest\n    crieth               crieth\n    crime                crime\n    crimeful             crime\n    crimeless            crimeless\n    crimes               crime\n    criminal             crimin\n    crimson              crimson\n    cringe               cring\n    cripple              crippl\n    crisp                crisp\n    crisped              crisp\n    crispian             crispian\n    crispianus           crispianu\n    crispin              crispin\n    critic               critic\n    critical             critic\n    critics              critic\n    croak                croak\n    croaking             croak\n    croaks               croak\n    crocodile            crocodil\n    cromer               cromer\n    cromwell             cromwel\n    crone                crone\n    crook                crook\n    crookback            crookback\n    crooked              crook\n    crooking             crook\n    crop                 crop\n    cropp                cropp\n    crosby               crosbi\n    cross                cross\n    crossed              cross\n    crosses              cross\n    crossest             crossest\n    crossing             cross\n    crossings            cross\n    crossly              crossli\n    crossness            cross\n    crost                crost\n    crotchets            crotchet\n    crouch               crouch\n    crouching            crouch\n    crow                 crow\n    crowd                crowd\n    crowded              crowd\n    crowding             crowd\n    crowds               crowd\n    crowflowers          crowflow\n    crowing              crow\n    crowkeeper           crowkeep\n    crown                crown\n    crowned              crown\n    crowner              crowner\n    crownet              crownet\n    crownets             crownet\n    crowning             crown\n    crowns               crown\n    crows                crow\n    crudy                crudi\n    cruel                cruel\n    cruell               cruell\n    crueller             crueller\n    cruelly              cruelli\n    cruels               cruel\n    cruelty              cruelti\n    crum                 crum\n    crumble              crumbl\n    crumbs               crumb\n    crupper              crupper\n    crusadoes            crusado\n    crush                crush\n    crushed              crush\n    crushest             crushest\n    crushing             crush\n    crust                crust\n    crusts               crust\n    crusty               crusti\n    crutch               crutch\n    crutches             crutch\n    cry                  cry\n    crying               cry\n    crystal              crystal\n    crystalline          crystallin\n    crystals             crystal\n    cub                  cub\n    cubbert              cubbert\n    cubiculo             cubiculo\n    cubit                cubit\n    cubs                 cub\n    cuckold              cuckold\n    cuckoldly            cuckoldli\n    cuckolds             cuckold\n    cuckoo               cuckoo\n    cucullus             cucullu\n    cudgel               cudgel\n    cudgeled             cudgel\n    cudgell              cudgel\n    cudgelling           cudgel\n    cudgels              cudgel\n    cue                  cue\n    cues                 cue\n    cuff                 cuff\n    cuffs                cuff\n    cuique               cuiqu\n    cull                 cull\n    culling              cull\n    cullion              cullion\n    cullionly            cullionli\n    cullions             cullion\n    culpable             culpabl\n    culverin             culverin\n    cum                  cum\n    cumber               cumber\n    cumberland           cumberland\n    cunning              cun\n    cunningly            cunningli\n    cunnings             cun\n    cuore                cuor\n    cup                  cup\n    cupbearer            cupbear\n    cupboarding          cupboard\n    cupid                cupid\n    cupids               cupid\n    cuppele              cuppel\n    cups                 cup\n    cur                  cur\n    curan                curan\n    curate               curat\n    curb                 curb\n    curbed               curb\n    curbing              curb\n    curbs                curb\n    curd                 curd\n    curdied              curdi\n    curds                curd\n    cure                 cure\n    cured                cure\n    cureless             cureless\n    curer                curer\n    cures                cure\n    curfew               curfew\n    curing               cure\n    curio                curio\n    curiosity            curios\n    curious              curiou\n    curiously            curious\n    curl                 curl\n    curled               curl\n    curling              curl\n    curls                curl\n    currance             curranc\n    currants             currant\n    current              current\n    currents             current\n    currish              currish\n    curry                curri\n    curs                 cur\n    curse                curs\n    cursed               curs\n    curses               curs\n    cursies              cursi\n    cursing              curs\n    cursorary            cursorari\n    curst                curst\n    curster              curster\n    curstest             curstest\n    curstness            curst\n    cursy                cursi\n    curtail              curtail\n    curtain              curtain\n    curtains             curtain\n    curtal               curtal\n    curtis               curti\n    curtle               curtl\n    curtsied             curtsi\n    curtsies             curtsi\n    curtsy               curtsi\n    curvet               curvet\n    curvets              curvet\n    cushes               cush\n    cushion              cushion\n    cushions             cushion\n    custalorum           custalorum\n    custard              custard\n    custody              custodi\n    custom               custom\n    customary            customari\n    customed             custom\n    customer             custom\n    customers            custom\n    customs              custom\n    custure              custur\n    cut                  cut\n    cutler               cutler\n    cutpurse             cutpurs\n    cutpurses            cutpurs\n    cuts                 cut\n    cutter               cutter\n    cutting              cut\n    cuttle               cuttl\n    cxsar                cxsar\n    cyclops              cyclop\n    cydnus               cydnu\n    cygnet               cygnet\n    cygnets              cygnet\n    cym                  cym\n    cymbals              cymbal\n    cymbeline            cymbelin\n    cyme                 cyme\n    cynic                cynic\n    cynthia              cynthia\n    cypress              cypress\n    cypriot              cypriot\n    cyprus               cypru\n    cyrus                cyru\n    cytherea             cytherea\n    d                    d\n    dabbled              dabbl\n    dace                 dace\n    dad                  dad\n    daedalus             daedalu\n    daemon               daemon\n    daff                 daff\n    daffed               daf\n    daffest              daffest\n    daffodils            daffodil\n    dagger               dagger\n    daggers              dagger\n    dagonet              dagonet\n    daily                daili\n    daintier             daintier\n    dainties             dainti\n    daintiest            daintiest\n    daintily             daintili\n    daintiness           dainti\n    daintry              daintri\n    dainty               dainti\n    daisied              daisi\n    daisies              daisi\n    daisy                daisi\n    dale                 dale\n    dalliance            dallianc\n    dallied              dalli\n    dallies              dalli\n    dally                dalli\n    dallying             dalli\n    dalmatians           dalmatian\n    dam                  dam\n    damage               damag\n    damascus             damascu\n    damask               damask\n    damasked             damask\n    dame                 dame\n    dames                dame\n    damm                 damm\n    damn                 damn\n    damnable             damnabl\n    damnably             damnabl\n    damnation            damnat\n    damned               damn\n    damns                damn\n    damoiselle           damoisel\n    damon                damon\n    damosella            damosella\n    damp                 damp\n    dams                 dam\n    damsel               damsel\n    damsons              damson\n    dan                  dan\n    danc                 danc\n    dance                danc\n    dancer               dancer\n    dances               danc\n    dancing              danc\n    dandle               dandl\n    dandy                dandi\n    dane                 dane\n    dang                 dang\n    danger               danger\n    dangerous            danger\n    dangerously          danger\n    dangers              danger\n    dangling             dangl\n    daniel               daniel\n    danish               danish\n    dank                 dank\n    dankish              dankish\n    danskers             dansker\n    daphne               daphn\n    dappled              dappl\n    dapples              dappl\n    dar                  dar\n    dardan               dardan\n    dardanian            dardanian\n    dardanius            dardaniu\n    dare                 dare\n    dared                dare\n    dareful              dare\n    dares                dare\n    darest               darest\n    daring               dare\n    darius               dariu\n    dark                 dark\n    darken               darken\n    darkening            darken\n    darkens              darken\n    darker               darker\n    darkest              darkest\n    darkling             darkl\n    darkly               darkli\n    darkness             dark\n    darling              darl\n    darlings             darl\n    darnel               darnel\n    darraign             darraign\n    dart                 dart\n    darted               dart\n    darter               darter\n    dartford             dartford\n    darting              dart\n    darts                dart\n    dash                 dash\n    dashes               dash\n    dashing              dash\n    dastard              dastard\n    dastards             dastard\n    dat                  dat\n    datchet              datchet\n    date                 date\n    dated                date\n    dateless             dateless\n    dates                date\n    daub                 daub\n    daughter             daughter\n    daughters            daughter\n    daunt                daunt\n    daunted              daunt\n    dauntless            dauntless\n    dauphin              dauphin\n    daventry             daventri\n    davy                 davi\n    daw                  daw\n    dawn                 dawn\n    dawning              dawn\n    daws                 daw\n    day                  dai\n    daylight             daylight\n    days                 dai\n    dazzle               dazzl\n    dazzled              dazzl\n    dazzling             dazzl\n    de                   de\n    dead                 dead\n    deadly               deadli\n    deaf                 deaf\n    deafing              deaf\n    deafness             deaf\n    deafs                deaf\n    deal                 deal\n    dealer               dealer\n    dealers              dealer\n    dealest              dealest\n    dealing              deal\n    dealings             deal\n    deals                deal\n    dealt                dealt\n    dean                 dean\n    deanery              deaneri\n    dear                 dear\n    dearer               dearer\n    dearest              dearest\n    dearly               dearli\n    dearness             dear\n    dears                dear\n    dearth               dearth\n    dearths              dearth\n    death                death\n    deathbed             deathb\n    deathful             death\n    deaths               death\n    deathsman            deathsman\n    deathsmen            deathsmen\n    debarred             debar\n    debase               debas\n    debate               debat\n    debated              debat\n    debatement           debat\n    debateth             debateth\n    debating             debat\n    debauch              debauch\n    debile               debil\n    debility             debil\n    debitor              debitor\n    debonair             debonair\n    deborah              deborah\n    debosh               debosh\n    debt                 debt\n    debted               debt\n    debtor               debtor\n    debtors              debtor\n    debts                debt\n    debuty               debuti\n    decay                decai\n    decayed              decai\n    decayer              decay\n    decaying             decai\n    decays               decai\n    deceas               decea\n    decease              deceas\n    deceased             deceas\n    deceit               deceit\n    deceitful            deceit\n    deceits              deceit\n    deceiv               deceiv\n    deceivable           deceiv\n    deceive              deceiv\n    deceived             deceiv\n    deceiver             deceiv\n    deceivers            deceiv\n    deceives             deceiv\n    deceivest            deceivest\n    deceiveth            deceiveth\n    deceiving            deceiv\n    december             decemb\n    decent               decent\n    deceptious           decepti\n    decerns              decern\n    decide               decid\n    decides              decid\n    decimation           decim\n    decipher             deciph\n    deciphers            deciph\n    decision             decis\n    decius               deciu\n    deck                 deck\n    decking              deck\n    decks                deck\n    deckt                deckt\n    declare              declar\n    declares             declar\n    declension           declens\n    declensions          declens\n    declin               declin\n    decline              declin\n    declined             declin\n    declines             declin\n    declining            declin\n    decoct               decoct\n    decorum              decorum\n    decreas              decrea\n    decrease             decreas\n    decreasing           decreas\n    decree               decre\n    decreed              decre\n    decrees              decre\n    decrepit             decrepit\n    dedicate             dedic\n    dedicated            dedic\n    dedicates            dedic\n    dedication           dedic\n    deed                 deed\n    deedless             deedless\n    deeds                deed\n    deem                 deem\n    deemed               deem\n    deep                 deep\n    deeper               deeper\n    deepest              deepest\n    deeply               deepli\n    deeps                deep\n    deepvow              deepvow\n    deer                 deer\n    deesse               deess\n    defac                defac\n    deface               defac\n    defaced              defac\n    defacer              defac\n    defacers             defac\n    defacing             defac\n    defam                defam\n    default              default\n    defeat               defeat\n    defeated             defeat\n    defeats              defeat\n    defeatures           defeatur\n    defect               defect\n    defective            defect\n    defects              defect\n    defence              defenc\n    defences             defenc\n    defend               defend\n    defendant            defend\n    defended             defend\n    defender             defend\n    defenders            defend\n    defending            defend\n    defends              defend\n    defense              defens\n    defensible           defens\n    defensive            defens\n    defer                defer\n    deferr               deferr\n    defiance             defianc\n    deficient            defici\n    defied               defi\n    defies               defi\n    defil                defil\n    defile               defil\n    defiler              defil\n    defiles              defil\n    defiling             defil\n    define               defin\n    definement           defin\n    definite             definit\n    definitive           definit\n    definitively         definit\n    deflow               deflow\n    deflower             deflow\n    deflowered           deflow\n    deform               deform\n    deformed             deform\n    deformities          deform\n    deformity            deform\n    deftly               deftli\n    defunct              defunct\n    defunction           defunct\n    defuse               defus\n    defy                 defi\n    defying              defi\n    degenerate           degener\n    degraded             degrad\n    degree               degre\n    degrees              degre\n    deified              deifi\n    deifying             deifi\n    deign                deign\n    deigned              deign\n    deiphobus            deiphobu\n    deities              deiti\n    deity                deiti\n    deja                 deja\n    deject               deject\n    dejected             deject\n    delabreth            delabreth\n    delay                delai\n    delayed              delai\n    delaying             delai\n    delays               delai\n    delectable           delect\n    deliberate           deliber\n    delicate             delic\n    delicates            delic\n    delicious            delici\n    deliciousness        delici\n    delight              delight\n    delighted            delight\n    delightful           delight\n    delights             delight\n    delinquents          delinqu\n    deliv                deliv\n    deliver              deliv\n    deliverance          deliver\n    delivered            deliv\n    delivering           deliv\n    delivers             deliv\n    delivery             deliveri\n    delphos              delpho\n    deluded              delud\n    deluding             delud\n    deluge               delug\n    delve                delv\n    delver               delver\n    delves               delv\n    demand               demand\n    demanded             demand\n    demanding            demand\n    demands              demand\n    demean               demean\n    demeanor             demeanor\n    demeanour            demeanour\n    demerits             demerit\n    demesnes             demesn\n    demetrius            demetriu\n    demi                 demi\n    demigod              demigod\n    demise               demis\n    demoiselles          demoisel\n    demon                demon\n    demonstrable         demonstr\n    demonstrate          demonstr\n    demonstrated         demonstr\n    demonstrating        demonstr\n    demonstration        demonstr\n    demonstrative        demonstr\n    demure               demur\n    demurely             demur\n    demuring             demur\n    den                  den\n    denay                denai\n    deni                 deni\n    denial               denial\n    denials              denial\n    denied               deni\n    denier               denier\n    denies               deni\n    deniest              deniest\n    denis                deni\n    denmark              denmark\n    dennis               denni\n    denny                denni\n    denote               denot\n    denoted              denot\n    denotement           denot\n    denounc              denounc\n    denounce             denounc\n    denouncing           denounc\n    dens                 den\n    denunciation         denunci\n    deny                 deni\n    denying              deni\n    deo                  deo\n    depart               depart\n    departed             depart\n    departest            departest\n    departing            depart\n    departure            departur\n    depeche              depech\n    depend               depend\n    dependant            depend\n    dependants           depend\n    depended             depend\n    dependence           depend\n    dependences          depend\n    dependency           depend\n    dependent            depend\n    dependents           depend\n    depender             depend\n    depending            depend\n    depends              depend\n    deplore              deplor\n    deploring            deplor\n    depopulate           depopul\n    depos                depo\n    depose               depos\n    deposed              depos\n    deposing             depos\n    depositaries         depositari\n    deprav               deprav\n    depravation          deprav\n    deprave              deprav\n    depraved             deprav\n    depraves             deprav\n    depress              depress\n    depriv               depriv\n    deprive              depriv\n    depth                depth\n    depths               depth\n    deputation           deput\n    depute               deput\n    deputed              deput\n    deputies             deputi\n    deputing             deput\n    deputy               deputi\n    deracinate           deracin\n    derby                derbi\n    dercetas             derceta\n    dere                 dere\n    derides              derid\n    derision             deris\n    deriv                deriv\n    derivation           deriv\n    derivative           deriv\n    derive               deriv\n    derived              deriv\n    derives              deriv\n    derogate             derog\n    derogately           derog\n    derogation           derog\n    des                  de\n    desartless           desartless\n    descant              descant\n    descend              descend\n    descended            descend\n    descending           descend\n    descends             descend\n    descension           descens\n    descent              descent\n    descents             descent\n    describe             describ\n    described            describ\n    describes            describ\n    descried             descri\n    description          descript\n    descriptions         descript\n    descry               descri\n    desdemon             desdemon\n    desdemona            desdemona\n    desert               desert\n    deserts              desert\n    deserv               deserv\n    deserve              deserv\n    deserved             deserv\n    deservedly           deservedli\n    deserver             deserv\n    deservers            deserv\n    deserves             deserv\n    deservest            deservest\n    deserving            deserv\n    deservings           deserv\n    design               design\n    designment           design\n    designments          design\n    designs              design\n    desir                desir\n    desire               desir\n    desired              desir\n    desirers             desir\n    desires              desir\n    desirest             desirest\n    desiring             desir\n    desirous             desir\n    desist               desist\n    desk                 desk\n    desolate             desol\n    desolation           desol\n    desp                 desp\n    despair              despair\n    despairing           despair\n    despairs             despair\n    despatch             despatch\n    desperate            desper\n    desperately          desper\n    desperation          desper\n    despis               despi\n    despise              despis\n    despised             despis\n    despiser             despis\n    despiseth            despiseth\n    despising            despis\n    despite              despit\n    despiteful           despit\n    despoiled            despoil\n    dest                 dest\n    destin               destin\n    destined             destin\n    destinies            destini\n    destiny              destini\n    destitute            destitut\n    destroy              destroi\n    destroyed            destroi\n    destroyer            destroy\n    destroyers           destroy\n    destroying           destroi\n    destroys             destroi\n    destruction          destruct\n    destructions         destruct\n    det                  det\n    detain               detain\n    detains              detain\n    detect               detect\n    detected             detect\n    detecting            detect\n    detection            detect\n    detector             detector\n    detects              detect\n    detention            detent\n    determin             determin\n    determinate          determin\n    determination        determin\n    determinations       determin\n    determine            determin\n    determined           determin\n    determines           determin\n    detest               detest\n    detestable           detest\n    detested             detest\n    detesting            detest\n    detests              detest\n    detract              detract\n    detraction           detract\n    detractions          detract\n    deucalion            deucalion\n    deuce                deuc\n    deum                 deum\n    deux                 deux\n    devant               devant\n    devesting            devest\n    device               devic\n    devices              devic\n    devil                devil\n    devilish             devilish\n    devils               devil\n    devis                devi\n    devise               devis\n    devised              devis\n    devises              devis\n    devising             devis\n    devoid               devoid\n    devonshire           devonshir\n    devote               devot\n    devoted              devot\n    devotion             devot\n    devour               devour\n    devoured             devour\n    devourers            devour\n    devouring            devour\n    devours              devour\n    devout               devout\n    devoutly             devoutli\n    dew                  dew\n    dewberries           dewberri\n    dewdrops             dewdrop\n    dewlap               dewlap\n    dewlapp              dewlapp\n    dews                 dew\n    dewy                 dewi\n    dexter               dexter\n    dexteriously         dexteri\n    dexterity            dexter\n    di                   di\n    diable               diabl\n    diablo               diablo\n    diadem               diadem\n    dial                 dial\n    dialect              dialect\n    dialogue             dialogu\n    dialogued            dialogu\n    dials                dial\n    diameter             diamet\n    diamond              diamond\n    diamonds             diamond\n    dian                 dian\n    diana                diana\n    diaper               diaper\n    dibble               dibbl\n    dic                  dic\n    dice                 dice\n    dicers               dicer\n    dich                 dich\n    dick                 dick\n    dickens              dicken\n    dickon               dickon\n    dicky                dicki\n    dictator             dictat\n    diction              diction\n    dictynna             dictynna\n    did                  did\n    diddle               diddl\n    didest               didest\n    dido                 dido\n    didst                didst\n    die                  die\n    died                 di\n    diedst               diedst\n    dies                 di\n    diest                diest\n    diet                 diet\n    dieted               diet\n    dieter               dieter\n    dieu                 dieu\n    diff                 diff\n    differ               differ\n    difference           differ\n    differences          differ\n    differency           differ\n    different            differ\n    differing            differ\n    differs              differ\n    difficile            difficil\n    difficult            difficult\n    difficulties         difficulti\n    difficulty           difficulti\n    diffidence           diffid\n    diffidences          diffid\n    diffus               diffu\n    diffused             diffus\n    diffusest            diffusest\n    dig                  dig\n    digest               digest\n    digested             digest\n    digestion            digest\n    digestions           digest\n    digg                 digg\n    digging              dig\n    dighton              dighton\n    dignified            dignifi\n    dignifies            dignifi\n    dignify              dignifi\n    dignities            digniti\n    dignity              digniti\n    digress              digress\n    digressing           digress\n    digression           digress\n    digs                 dig\n    digt                 digt\n    dilate               dilat\n    dilated              dilat\n    dilations            dilat\n    dilatory             dilatori\n    dild                 dild\n    dildos               dildo\n    dilemma              dilemma\n    dilemmas             dilemma\n    diligence            dilig\n    diligent             dilig\n    diluculo             diluculo\n    dim                  dim\n    dimension            dimens\n    dimensions           dimens\n    diminish             diminish\n    diminishing          diminish\n    diminution           diminut\n    diminutive           diminut\n    diminutives          diminut\n    dimm                 dimm\n    dimmed               dim\n    dimming              dim\n    dimpled              dimpl\n    dimples              dimpl\n    dims                 dim\n    din                  din\n    dine                 dine\n    dined                dine\n    diner                diner\n    dines                dine\n    ding                 ding\n    dining               dine\n    dinner               dinner\n    dinners              dinner\n    dinnertime           dinnertim\n    dint                 dint\n    diomed               diom\n    diomede              diomed\n    diomedes             diomed\n    dion                 dion\n    dip                  dip\n    dipp                 dipp\n    dipping              dip\n    dips                 dip\n    dir                  dir\n    dire                 dire\n    direct               direct\n    directed             direct\n    directing            direct\n    direction            direct\n    directions           direct\n    directitude          directitud\n    directive            direct\n    directly             directli\n    directs              direct\n    direful              dire\n    direness             dire\n    direst               direst\n    dirge                dirg\n    dirges               dirg\n    dirt                 dirt\n    dirty                dirti\n    dis                  di\n    disability           disabl\n    disable              disabl\n    disabled             disabl\n    disabling            disabl\n    disadvantage         disadvantag\n    disagree             disagre\n    disallow             disallow\n    disanimates          disanim\n    disannul             disannul\n    disannuls            disannul\n    disappointed         disappoint\n    disarm               disarm\n    disarmed             disarm\n    disarmeth            disarmeth\n    disarms              disarm\n    disaster             disast\n    disasters            disast\n    disastrous           disastr\n    disbench             disbench\n    disbranch            disbranch\n    disburdened          disburden\n    disburs              disbur\n    disburse             disburs\n    disbursed            disburs\n    discandy             discandi\n    discandying          discandi\n    discard              discard\n    discarded            discard\n    discase              discas\n    discased             discas\n    discern              discern\n    discerner            discern\n    discerning           discern\n    discernings          discern\n    discerns             discern\n    discharg             discharg\n    discharge            discharg\n    discharged           discharg\n    discharging          discharg\n    discipled            discipl\n    disciples            discipl\n    disciplin            disciplin\n    discipline           disciplin\n    disciplined          disciplin\n    disciplines          disciplin\n    disclaim             disclaim\n    disclaiming          disclaim\n    disclaims            disclaim\n    disclos              disclo\n    disclose             disclos\n    disclosed            disclos\n    discloses            disclos\n    discolour            discolour\n    discoloured          discolour\n    discolours           discolour\n    discomfit            discomfit\n    discomfited          discomfit\n    discomfiture         discomfitur\n    discomfort           discomfort\n    discomfortable       discomfort\n    discommend           discommend\n    disconsolate         disconsol\n    discontent           discont\n    discontented         discont\n    discontentedly       discontentedli\n    discontenting        discont\n    discontents          discont\n    discontinue          discontinu\n    discontinued         discontinu\n    discord              discord\n    discordant           discord\n    discords             discord\n    discourse            discours\n    discoursed           discours\n    discourser           discours\n    discourses           discours\n    discoursive          discours\n    discourtesy          discourtesi\n    discov               discov\n    discover             discov\n    discovered           discov\n    discoverers          discover\n    discoveries          discoveri\n    discovering          discov\n    discovers            discov\n    discovery            discoveri\n    discredit            discredit\n    discredited          discredit\n    discredits           discredit\n    discreet             discreet\n    discreetly           discreetli\n    discretion           discret\n    discretions          discret\n    discuss              discuss\n    disdain              disdain\n    disdained            disdain\n    disdaineth           disdaineth\n    disdainful           disdain\n    disdainfully         disdainfulli\n    disdaining           disdain\n    disdains             disdain\n    disdnguish           disdnguish\n    diseas               disea\n    disease              diseas\n    diseased             diseas\n    diseases             diseas\n    disedg               disedg\n    disembark            disembark\n    disfigure            disfigur\n    disfigured           disfigur\n    disfurnish           disfurnish\n    disgorge             disgorg\n    disgrac              disgrac\n    disgrace             disgrac\n    disgraced            disgrac\n    disgraceful          disgrac\n    disgraces            disgrac\n    disgracing           disgrac\n    disgracious          disgraci\n    disguis              disgui\n    disguise             disguis\n    disguised            disguis\n    disguiser            disguis\n    disguises            disguis\n    disguising           disguis\n    dish                 dish\n    dishabited           dishabit\n    dishclout            dishclout\n    dishearten           dishearten\n    disheartens          dishearten\n    dishes               dish\n    dishonest            dishonest\n    dishonestly          dishonestli\n    dishonesty           dishonesti\n    dishonor             dishonor\n    dishonorable         dishonor\n    dishonors            dishonor\n    dishonour            dishonour\n    dishonourable        dishonour\n    dishonoured          dishonour\n    dishonours           dishonour\n    disinherit           disinherit\n    disinherited         disinherit\n    disjoin              disjoin\n    disjoining           disjoin\n    disjoins             disjoin\n    disjoint             disjoint\n    disjunction          disjunct\n    dislik               dislik\n    dislike              dislik\n    disliken             disliken\n    dislikes             dislik\n    dislimns             dislimn\n    dislocate            disloc\n    dislodg              dislodg\n    disloyal             disloy\n    disloyalty           disloyalti\n    dismal               dismal\n    dismantle            dismantl\n    dismantled           dismantl\n    dismask              dismask\n    dismay               dismai\n    dismayed             dismai\n    dismemb              dismemb\n    dismember            dismemb\n    dismes               dism\n    dismiss              dismiss\n    dismissed            dismiss\n    dismissing           dismiss\n    dismission           dismiss\n    dismount             dismount\n    dismounted           dismount\n    disnatur             disnatur\n    disobedience         disobedi\n    disobedient          disobedi\n    disobey              disobei\n    disobeys             disobei\n    disorb               disorb\n    disorder             disord\n    disordered           disord\n    disorderly           disorderli\n    disorders            disord\n    disparage            disparag\n    disparagement        disparag\n    disparagements       disparag\n    dispark              dispark\n    dispatch             dispatch\n    dispensation         dispens\n    dispense             dispens\n    dispenses            dispens\n    dispers              disper\n    disperse             dispers\n    dispersed            dispers\n    dispersedly          dispersedli\n    dispersing           dispers\n    dispiteous           dispit\n    displac              displac\n    displace             displac\n    displaced            displac\n    displant             displant\n    displanting          displant\n    display              displai\n    displayed            displai\n    displeas             displea\n    displease            displeas\n    displeased           displeas\n    displeasing          displeas\n    displeasure          displeasur\n    displeasures         displeasur\n    disponge             dispong\n    disport              disport\n    disports             disport\n    dispos               dispo\n    dispose              dispos\n    disposed             dispos\n    disposer             dispos\n    disposing            dispos\n    disposition          disposit\n    dispositions         disposit\n    dispossess           dispossess\n    dispossessing        dispossess\n    disprais             disprai\n    dispraise            disprais\n    dispraising          disprais\n    dispraisingly        dispraisingli\n    dispropertied        disproperti\n    disproportion        disproport\n    disproportioned      disproport\n    disprov              disprov\n    disprove             disprov\n    disproved            disprov\n    dispursed            dispurs\n    disputable           disput\n    disputation          disput\n    disputations         disput\n    dispute              disput\n    disputed             disput\n    disputes             disput\n    disputing            disput\n    disquantity          disquant\n    disquiet             disquiet\n    disquietly           disquietli\n    disrelish            disrelish\n    disrobe              disrob\n    disseat              disseat\n    dissemble            dissembl\n    dissembled           dissembl\n    dissembler           dissembl\n    dissemblers          dissembl\n    dissembling          dissembl\n    dissembly            dissembl\n    dissension           dissens\n    dissensions          dissens\n    dissentious          dissenti\n    dissever             dissev\n    dissipation          dissip\n    dissolute            dissolut\n    dissolutely          dissolut\n    dissolution          dissolut\n    dissolutions         dissolut\n    dissolv              dissolv\n    dissolve             dissolv\n    dissolved            dissolv\n    dissolves            dissolv\n    dissuade             dissuad\n    dissuaded            dissuad\n    distaff              distaff\n    distaffs             distaff\n    distain              distain\n    distains             distain\n    distance             distanc\n    distant              distant\n    distaste             distast\n    distasted            distast\n    distasteful          distast\n    distemp              distemp\n    distemper            distemp\n    distemperature       distemperatur\n    distemperatures      distemperatur\n    distempered          distemp\n    distempering         distemp\n    distil               distil\n    distill              distil\n    distillation         distil\n    distilled            distil\n    distills             distil\n    distilment           distil\n    distinct             distinct\n    distinction          distinct\n    distinctly           distinctli\n    distingue            distingu\n    distinguish          distinguish\n    distinguishes        distinguish\n    distinguishment      distinguish\n    distract             distract\n    distracted           distract\n    distractedly         distractedli\n    distraction          distract\n    distractions         distract\n    distracts            distract\n    distrain             distrain\n    distraught           distraught\n    distress             distress\n    distressed           distress\n    distresses           distress\n    distressful          distress\n    distribute           distribut\n    distributed          distribut\n    distribution         distribut\n    distrust             distrust\n    distrustful          distrust\n    disturb              disturb\n    disturbed            disturb\n    disturbers           disturb\n    disturbing           disturb\n    disunite             disunit\n    disvalued            disvalu\n    disvouch             disvouch\n    dit                  dit\n    ditch                ditch\n    ditchers             ditcher\n    ditches              ditch\n    dites                dite\n    ditties              ditti\n    ditty                ditti\n    diurnal              diurnal\n    div                  div\n    dive                 dive\n    diver                diver\n    divers               diver\n    diversely            divers\n    diversity            divers\n    divert               divert\n    diverted             divert\n    diverts              divert\n    dives                dive\n    divest               divest\n    dividable            divid\n    dividant             divid\n    divide               divid\n    divided              divid\n    divides              divid\n    divideth             divideth\n    divin                divin\n    divination           divin\n    divine               divin\n    divinely             divin\n    divineness           divin\n    diviner              divin\n    divines              divin\n    divinest             divinest\n    divining             divin\n    divinity             divin\n    division             divis\n    divisions            divis\n    divorc               divorc\n    divorce              divorc\n    divorced             divorc\n    divorcement          divorc\n    divorcing            divorc\n    divulg               divulg\n    divulge              divulg\n    divulged             divulg\n    divulging            divulg\n    dizy                 dizi\n    dizzy                dizzi\n    do                   do\n    doating              doat\n    dobbin               dobbin\n    dock                 dock\n    docks                dock\n    doct                 doct\n    doctor               doctor\n    doctors              doctor\n    doctrine             doctrin\n    document             document\n    dodge                dodg\n    doe                  doe\n    doer                 doer\n    doers                doer\n    does                 doe\n    doest                doest\n    doff                 doff\n    dog                  dog\n    dogberry             dogberri\n    dogfish              dogfish\n    dogg                 dogg\n    dogged               dog\n    dogs                 dog\n    doigts               doigt\n    doing                do\n    doings               do\n    doit                 doit\n    doits                doit\n    dolabella            dolabella\n    dole                 dole\n    doleful              dole\n    doll                 doll\n    dollar               dollar\n    dollars              dollar\n    dolor                dolor\n    dolorous             dolor\n    dolour               dolour\n    dolours              dolour\n    dolphin              dolphin\n    dolt                 dolt\n    dolts                dolt\n    domestic             domest\n    domestics            domest\n    dominance            domin\n    dominations          domin\n    dominator            domin\n    domine               domin\n    domineer             domin\n    domineering          domin\n    dominical            domin\n    dominion             dominion\n    dominions            dominion\n    domitius             domitiu\n    dommelton            dommelton\n    don                  don\n    donalbain            donalbain\n    donation             donat\n    donc                 donc\n    doncaster            doncast\n    done                 done\n    dong                 dong\n    donn                 donn\n    donne                donn\n    donner               donner\n    donnerai             donnerai\n    doom                 doom\n    doomsday             doomsdai\n    door                 door\n    doorkeeper           doorkeep\n    doors                door\n    dorcas               dorca\n    doreus               doreu\n    doricles             doricl\n    dormouse             dormous\n    dorothy              dorothi\n    dorset               dorset\n    dorsetshire          dorsetshir\n    dost                 dost\n    dotage               dotag\n    dotant               dotant\n    dotard               dotard\n    dotards              dotard\n    dote                 dote\n    doted                dote\n    doters               doter\n    dotes                dote\n    doteth               doteth\n    doth                 doth\n    doting               dote\n    double               doubl\n    doubled              doubl\n    doubleness           doubl\n    doubler              doubler\n    doublet              doublet\n    doublets             doublet\n    doubling             doubl\n    doubly               doubli\n    doubt                doubt\n    doubted              doubt\n    doubtful             doubt\n    doubtfully           doubtfulli\n    doubting             doubt\n    doubtless            doubtless\n    doubts               doubt\n    doug                 doug\n    dough                dough\n    doughty              doughti\n    doughy               doughi\n    douglas              dougla\n    dout                 dout\n    doute                dout\n    douts                dout\n    dove                 dove\n    dovehouse            dovehous\n    dover                dover\n    doves                dove\n    dow                  dow\n    dowager              dowag\n    dowdy                dowdi\n    dower                dower\n    dowerless            dowerless\n    dowers               dower\n    dowlas               dowla\n    dowle                dowl\n    down                 down\n    downfall             downfal\n    downright            downright\n    downs                down\n    downstairs           downstair\n    downtrod             downtrod\n    downward             downward\n    downwards            downward\n    downy                downi\n    dowries              dowri\n    dowry                dowri\n    dowsabel             dowsabel\n    doxy                 doxi\n    dozed                doze\n    dozen                dozen\n    dozens               dozen\n    dozy                 dozi\n    drab                 drab\n    drabbing             drab\n    drabs                drab\n    drachma              drachma\n    drachmas             drachma\n    draff                draff\n    drag                 drag\n    dragg                dragg\n    dragged              drag\n    dragging             drag\n    dragon               dragon\n    dragonish            dragonish\n    dragons              dragon\n    drain                drain\n    drained              drain\n    drains               drain\n    drake                drake\n    dram                 dram\n    dramatis             dramati\n    drank                drank\n    draught              draught\n    draughts             draught\n    drave                drave\n    draw                 draw\n    drawbridge           drawbridg\n    drawer               drawer\n    drawers              drawer\n    draweth              draweth\n    drawing              draw\n    drawling             drawl\n    drawn                drawn\n    draws                draw\n    drayman              drayman\n    draymen              draymen\n    dread                dread\n    dreaded              dread\n    dreadful             dread\n    dreadfully           dreadfulli\n    dreading             dread\n    dreads               dread\n    dream                dream\n    dreamer              dreamer\n    dreamers             dreamer\n    dreaming             dream\n    dreams               dream\n    dreamt               dreamt\n    drearning            drearn\n    dreary               dreari\n    dreg                 dreg\n    dregs                dreg\n    drench               drench\n    drenched             drench\n    dress                dress\n    dressed              dress\n    dresser              dresser\n    dressing             dress\n    dressings            dress\n    drest                drest\n    drew                 drew\n    dribbling            dribbl\n    dried                dri\n    drier                drier\n    dries                dri\n    drift                drift\n    drily                drili\n    drink                drink\n    drinketh             drinketh\n    drinking             drink\n    drinkings            drink\n    drinks               drink\n    driv                 driv\n    drive                drive\n    drivelling           drivel\n    driven               driven\n    drives               drive\n    driveth              driveth\n    driving              drive\n    drizzle              drizzl\n    drizzled             drizzl\n    drizzles             drizzl\n    droit                droit\n    drollery             drolleri\n    dromio               dromio\n    dromios              dromio\n    drone                drone\n    drones               drone\n    droop                droop\n    droopeth             droopeth\n    drooping             droop\n    droops               droop\n    drop                 drop\n    dropheir             dropheir\n    droplets             droplet\n    dropp                dropp\n    dropper              dropper\n    droppeth             droppeth\n    dropping             drop\n    droppings            drop\n    drops                drop\n    dropsied             dropsi\n    dropsies             dropsi\n    dropsy               dropsi\n    dropt                dropt\n    dross                dross\n    drossy               drossi\n    drought              drought\n    drove                drove\n    droven               droven\n    drovier              drovier\n    drown                drown\n    drowned              drown\n    drowning             drown\n    drowns               drown\n    drows                drow\n    drowse               drows\n    drowsily             drowsili\n    drowsiness           drowsi\n    drowsy               drowsi\n    drudge               drudg\n    drudgery             drudgeri\n    drudges              drudg\n    drug                 drug\n    drugg                drugg\n    drugs                drug\n    drum                 drum\n    drumble              drumbl\n    drummer              drummer\n    drumming             drum\n    drums                drum\n    drunk                drunk\n    drunkard             drunkard\n    drunkards            drunkard\n    drunken              drunken\n    drunkenly            drunkenli\n    drunkenness          drunken\n    dry                  dry\n    dryness              dryness\n    dst                  dst\n    du                   du\n    dub                  dub\n    dubb                 dubb\n    ducat                ducat\n    ducats               ducat\n    ducdame              ducdam\n    duchess              duchess\n    duchies              duchi\n    duchy                duchi\n    duck                 duck\n    ducking              duck\n    ducks                duck\n    dudgeon              dudgeon\n    due                  due\n    duellist             duellist\n    duello               duello\n    duer                 duer\n    dues                 due\n    duff                 duff\n    dug                  dug\n    dugs                 dug\n    duke                 duke\n    dukedom              dukedom\n    dukedoms             dukedom\n    dukes                duke\n    dulcet               dulcet\n    dulche               dulch\n    dull                 dull\n    dullard              dullard\n    duller               duller\n    dullest              dullest\n    dulling              dull\n    dullness             dull\n    dulls                dull\n    dully                dulli\n    dulness              dul\n    duly                 duli\n    dumain               dumain\n    dumb                 dumb\n    dumbe                dumb\n    dumbly               dumbl\n    dumbness             dumb\n    dump                 dump\n    dumps                dump\n    dun                  dun\n    duncan               duncan\n    dung                 dung\n    dungeon              dungeon\n    dungeons             dungeon\n    dunghill             dunghil\n    dunghills            dunghil\n    dungy                dungi\n    dunnest              dunnest\n    dunsinane            dunsinan\n    dunsmore             dunsmor\n    dunstable            dunstabl\n    dupp                 dupp\n    durance              duranc\n    during               dure\n    durst                durst\n    dusky                duski\n    dust                 dust\n    dusted               dust\n    dusty                dusti\n    dutch                dutch\n    dutchman             dutchman\n    duteous              duteou\n    duties               duti\n    dutiful              duti\n    duty                 duti\n    dwarf                dwarf\n    dwarfish             dwarfish\n    dwell                dwell\n    dwellers             dweller\n    dwelling             dwell\n    dwells               dwell\n    dwelt                dwelt\n    dwindle              dwindl\n    dy                   dy\n    dye                  dye\n    dyed                 dy\n    dyer                 dyer\n    dying                dy\n    e                    e\n    each                 each\n    eager                eager\n    eagerly              eagerli\n    eagerness            eager\n    eagle                eagl\n    eagles               eagl\n    eaning               ean\n    eanlings             eanl\n    ear                  ear\n    earing               ear\n    earl                 earl\n    earldom              earldom\n    earlier              earlier\n    earliest             earliest\n    earliness            earli\n    earls                earl\n    early                earli\n    earn                 earn\n    earned               earn\n    earnest              earnest\n    earnestly            earnestli\n    earnestness          earnest\n    earns                earn\n    ears                 ear\n    earth                earth\n    earthen              earthen\n    earthlier            earthlier\n    earthly              earthli\n    earthquake           earthquak\n    earthquakes          earthquak\n    earthy               earthi\n    eas                  ea\n    ease                 eas\n    eased                eas\n    easeful              eas\n    eases                eas\n    easier               easier\n    easiest              easiest\n    easiliest            easiliest\n    easily               easili\n    easiness             easi\n    easing               eas\n    east                 east\n    eastcheap            eastcheap\n    easter               easter\n    eastern              eastern\n    eastward             eastward\n    easy                 easi\n    eat                  eat\n    eaten                eaten\n    eater                eater\n    eaters               eater\n    eating               eat\n    eats                 eat\n    eaux                 eaux\n    eaves                eav\n    ebb                  ebb\n    ebbing               eb\n    ebbs                 ebb\n    ebon                 ebon\n    ebony                eboni\n    ebrew                ebrew\n    ecce                 ecc\n    echapper             echapp\n    echo                 echo\n    echoes               echo\n    eclips               eclip\n    eclipse              eclips\n    eclipses             eclips\n    ecolier              ecoli\n    ecoutez              ecoutez\n    ecstacy              ecstaci\n    ecstasies            ecstasi\n    ecstasy              ecstasi\n    ecus                 ecu\n    eden                 eden\n    edg                  edg\n    edgar                edgar\n    edge                 edg\n    edged                edg\n    edgeless             edgeless\n    edges                edg\n    edict                edict\n    edicts               edict\n    edifice              edific\n    edifices             edific\n    edified              edifi\n    edifies              edifi\n    edition              edit\n    edm                  edm\n    edmund               edmund\n    edmunds              edmund\n    edmundsbury          edmundsburi\n    educate              educ\n    educated             educ\n    education            educ\n    edward               edward\n    eel                  eel\n    eels                 eel\n    effect               effect\n    effected             effect\n    effectless           effectless\n    effects              effect\n    effectual            effectu\n    effectually          effectu\n    effeminate           effemin\n    effigies             effigi\n    effus                effu\n    effuse               effus\n    effusion             effus\n    eftest               eftest\n    egal                 egal\n    egally               egal\n    eget                 eget\n    egeus                egeu\n    egg                  egg\n    eggs                 egg\n    eggshell             eggshel\n    eglamour             eglamour\n    eglantine            eglantin\n    egma                 egma\n    ego                  ego\n    egregious            egregi\n    egregiously          egregi\n    egress               egress\n    egypt                egypt\n    egyptian             egyptian\n    egyptians            egyptian\n    eie                  eie\n    eight                eight\n    eighteen             eighteen\n    eighth               eighth\n    eightpenny           eightpenni\n    eighty               eighti\n    eisel                eisel\n    either               either\n    eject                eject\n    eke                  ek\n    el                   el\n    elbe                 elb\n    elbow                elbow\n    elbows               elbow\n    eld                  eld\n    elder                elder\n    elders               elder\n    eldest               eldest\n    eleanor              eleanor\n    elect                elect\n    elected              elect\n    election             elect\n    elegancy             eleg\n    elegies              elegi\n    element              element\n    elements             element\n    elephant             eleph\n    elephants            eleph\n    elevated             elev\n    eleven               eleven\n    eleventh             eleventh\n    elf                  elf\n    elflocks             elflock\n    eliads               eliad\n    elinor               elinor\n    elizabeth            elizabeth\n    ell                  ell\n    elle                 ell\n    ellen                ellen\n    elm                  elm\n    eloquence            eloqu\n    eloquent             eloqu\n    else                 els\n    elsewhere            elsewher\n    elsinore             elsinor\n    eltham               eltham\n    elves                elv\n    elvish               elvish\n    ely                  eli\n    elysium              elysium\n    em                   em\n    emballing            embal\n    embalm               embalm\n    embalms              embalm\n    embark               embark\n    embarked             embark\n    embarquements        embarqu\n    embassade            embassad\n    embassage            embassag\n    embassies            embassi\n    embassy              embassi\n    embattailed          embattail\n    embattl              embattl\n    embattle             embattl\n    embay                embai\n    embellished          embellish\n    embers               ember\n    emblaze              emblaz\n    emblem               emblem\n    emblems              emblem\n    embodied             embodi\n    embold               embold\n    emboldens            embolden\n    emboss               emboss\n    embossed             emboss\n    embounded            embound\n    embowel              embowel\n    embowell             embowel\n    embrac               embrac\n    embrace              embrac\n    embraced             embrac\n    embracement          embrac\n    embracements         embrac\n    embraces             embrac\n    embracing            embrac\n    embrasures           embrasur\n    embroider            embroid\n    embroidery           embroideri\n    emhracing            emhrac\n    emilia               emilia\n    eminence             emin\n    eminent              emin\n    eminently            emin\n    emmanuel             emmanuel\n    emnity               emniti\n    empale               empal\n    emperal              emper\n    emperess             emperess\n    emperial             emperi\n    emperor              emperor\n    empery               emperi\n    emphasis             emphasi\n    empire               empir\n    empirics             empir\n    empiricutic          empiricut\n    empleached           empleach\n    employ               emploi\n    employed             emploi\n    employer             employ\n    employment           employ\n    employments          employ\n    empoison             empoison\n    empress              empress\n    emptied              empti\n    emptier              emptier\n    empties              empti\n    emptiness            empti\n    empty                empti\n    emptying             empti\n    emulate              emul\n    emulation            emul\n    emulations           emul\n    emulator             emul\n    emulous              emul\n    en                   en\n    enact                enact\n    enacted              enact\n    enacts               enact\n    enactures            enactur\n    enamell              enamel\n    enamelled            enamel\n    enamour              enamour\n    enamoured            enamour\n    enanmour             enanmour\n    encamp               encamp\n    encamped             encamp\n    encave               encav\n    enceladus            enceladu\n    enchaf               enchaf\n    enchafed             enchaf\n    enchant              enchant\n    enchanted            enchant\n    enchanting           enchant\n    enchantingly         enchantingli\n    enchantment          enchant\n    enchantress          enchantress\n    enchants             enchant\n    enchas               encha\n    encircle             encircl\n    encircled            encircl\n    enclos               enclo\n    enclose              enclos\n    enclosed             enclos\n    encloses             enclos\n    encloseth            encloseth\n    enclosing            enclos\n    enclouded            encloud\n    encompass            encompass\n    encompassed          encompass\n    encompasseth         encompasseth\n    encompassment        encompass\n    encore               encor\n    encorporal           encorpor\n    encount              encount\n    encounter            encount\n    encountered          encount\n    encounters           encount\n    encourage            encourag\n    encouraged           encourag\n    encouragement        encourag\n    encrimsoned          encrimson\n    encroaching          encroach\n    encumb               encumb\n    end                  end\n    endamage             endamag\n    endamagement         endamag\n    endanger             endang\n    endart               endart\n    endear               endear\n    endeared             endear\n    endeavour            endeavour\n    endeavours           endeavour\n    ended                end\n    ender                ender\n    ending               end\n    endings              end\n    endite               endit\n    endless              endless\n    endow                endow\n    endowed              endow\n    endowments           endow\n    endows               endow\n    ends                 end\n    endu                 endu\n    endue                endu\n    endur                endur\n    endurance            endur\n    endure               endur\n    endured              endur\n    endures              endur\n    enduring             endur\n    endymion             endymion\n    eneas                enea\n    enemies              enemi\n    enemy                enemi\n    enernies             enerni\n    enew                 enew\n    enfeebled            enfeebl\n    enfeebles            enfeebl\n    enfeoff              enfeoff\n    enfetter             enfett\n    enfoldings           enfold\n    enforc               enforc\n    enforce              enforc\n    enforced             enforc\n    enforcedly           enforcedli\n    enforcement          enforc\n    enforces             enforc\n    enforcest            enforcest\n    enfranched           enfranch\n    enfranchis           enfranchi\n    enfranchise          enfranchis\n    enfranchised         enfranchis\n    enfranchisement      enfranchis\n    enfreed              enfre\n    enfreedoming         enfreedom\n    engag                engag\n    engage               engag\n    engaged              engag\n    engagements          engag\n    engaging             engag\n    engaol               engaol\n    engend               engend\n    engender             engend\n    engenders            engend\n    engilds              engild\n    engine               engin\n    engineer             engin\n    enginer              engin\n    engines              engin\n    engirt               engirt\n    england              england\n    english              english\n    englishman           englishman\n    englishmen           englishmen\n    engluts              englut\n    englutted            englut\n    engraffed            engraf\n    engraft              engraft\n    engrafted            engraft\n    engrav               engrav\n    engrave              engrav\n    engross              engross\n    engrossed            engross\n    engrossest           engrossest\n    engrossing           engross\n    engrossments         engross\n    enguard              enguard\n    enigma               enigma\n    enigmatical          enigmat\n    enjoin               enjoin\n    enjoined             enjoin\n    enjoy                enjoi\n    enjoyed              enjoi\n    enjoyer              enjoy\n    enjoying             enjoi\n    enjoys               enjoi\n    enkindle             enkindl\n    enkindled            enkindl\n    enlard               enlard\n    enlarg               enlarg\n    enlarge              enlarg\n    enlarged             enlarg\n    enlargement          enlarg\n    enlargeth            enlargeth\n    enlighten            enlighten\n    enlink               enlink\n    enmesh               enmesh\n    enmities             enmiti\n    enmity               enmiti\n    ennoble              ennobl\n    ennobled             ennobl\n    enobarb              enobarb\n    enobarbus            enobarbu\n    enon                 enon\n    enormity             enorm\n    enormous             enorm\n    enough               enough\n    enow                 enow\n    enpatron             enpatron\n    enpierced            enpierc\n    enquir               enquir\n    enquire              enquir\n    enquired             enquir\n    enrag                enrag\n    enrage               enrag\n    enraged              enrag\n    enrages              enrag\n    enrank               enrank\n    enrapt               enrapt\n    enrich               enrich\n    enriched             enrich\n    enriches             enrich\n    enridged             enridg\n    enrings              enr\n    enrob                enrob\n    enrobe               enrob\n    enroll               enrol\n    enrolled             enrol\n    enrooted             enroot\n    enrounded            enround\n    enschedul            enschedul\n    ensconce             ensconc\n    ensconcing           ensconc\n    enseamed             enseam\n    ensear               ensear\n    enseigne             enseign\n    enseignez            enseignez\n    ensemble             ensembl\n    enshelter            enshelt\n    enshielded           enshield\n    enshrines            enshrin\n    ensign               ensign\n    ensigns              ensign\n    enskied              enski\n    ensman               ensman\n    ensnare              ensnar\n    ensnared             ensnar\n    ensnareth            ensnareth\n    ensteep              ensteep\n    ensu                 ensu\n    ensue                ensu\n    ensued               ensu\n    ensues               ensu\n    ensuing              ensu\n    enswathed            enswath\n    ent                  ent\n    entail               entail\n    entame               entam\n    entangled            entangl\n    entangles            entangl\n    entendre             entendr\n    enter                enter\n    entered              enter\n    entering             enter\n    enterprise           enterpris\n    enterprises          enterpris\n    enters               enter\n    entertain            entertain\n    entertained          entertain\n    entertainer          entertain\n    entertaining         entertain\n    entertainment        entertain\n    entertainments       entertain\n    enthrall             enthral\n    enthralled           enthral\n    enthron              enthron\n    enthroned            enthron\n    entice               entic\n    enticements          entic\n    enticing             entic\n    entire               entir\n    entirely             entir\n    entitle              entitl\n    entitled             entitl\n    entitling            entitl\n    entomb               entomb\n    entombed             entomb\n    entrails             entrail\n    entrance             entranc\n    entrances            entranc\n    entrap               entrap\n    entrapp              entrapp\n    entre                entr\n    entreat              entreat\n    entreated            entreat\n    entreaties           entreati\n    entreating           entreat\n    entreatments         entreat\n    entreats             entreat\n    entreaty             entreati\n    entrench             entrench\n    entry                entri\n    entwist              entwist\n    envelop              envelop\n    envenom              envenom\n    envenomed            envenom\n    envenoms             envenom\n    envied               envi\n    envies               envi\n    envious              enviou\n    enviously            envious\n    environ              environ\n    environed            environ\n    envoy                envoi\n    envy                 envi\n    envying              envi\n    enwheel              enwheel\n    enwombed             enwomb\n    enwraps              enwrap\n    ephesian             ephesian\n    ephesians            ephesian\n    ephesus              ephesu\n    epicure              epicur\n    epicurean            epicurean\n    epicures             epicur\n    epicurism            epicur\n    epicurus             epicuru\n    epidamnum            epidamnum\n    epidaurus            epidauru\n    epigram              epigram\n    epilepsy             epilepsi\n    epileptic            epilept\n    epilogue             epilogu\n    epilogues            epilogu\n    epistles             epistl\n    epistrophus          epistrophu\n    epitaph              epitaph\n    epitaphs             epitaph\n    epithet              epithet\n    epitheton            epitheton\n    epithets             epithet\n    epitome              epitom\n    equal                equal\n    equalities           equal\n    equality             equal\n    equall               equal\n    equally              equal\n    equalness            equal\n    equals               equal\n    equinoctial          equinocti\n    equinox              equinox\n    equipage             equipag\n    equity               equiti\n    equivocal            equivoc\n    equivocate           equivoc\n    equivocates          equivoc\n    equivocation         equivoc\n    equivocator          equivoc\n    er                   er\n    erbear               erbear\n    erbearing            erbear\n    erbears              erbear\n    erbeat               erbeat\n    erblows              erblow\n    erboard              erboard\n    erborne              erborn\n    ercame               ercam\n    ercast               ercast\n    ercharg              ercharg\n    ercharged            ercharg\n    ercharging           ercharg\n    ercles               ercl\n    ercome               ercom\n    ercover              ercov\n    ercrows              ercrow\n    erdoing              erdo\n    ere                  er\n    erebus               erebu\n    erect                erect\n    erected              erect\n    erecting             erect\n    erection             erect\n    erects               erect\n    erewhile             erewhil\n    erflourish           erflourish\n    erflow               erflow\n    erflowing            erflow\n    erflows              erflow\n    erfraught            erfraught\n    erga                 erga\n    ergalled             ergal\n    erglanced            erglanc\n    ergo                 ergo\n    ergone               ergon\n    ergrow               ergrow\n    ergrown              ergrown\n    ergrowth             ergrowth\n    erhang               erhang\n    erhanging            erhang\n    erhasty              erhasti\n    erhear               erhear\n    erheard              erheard\n    eringoes             eringo\n    erjoy                erjoi\n    erleap               erleap\n    erleaps              erleap\n    erleavens            erleaven\n    erlook               erlook\n    erlooking            erlook\n    ermaster             ermast\n    ermengare            ermengar\n    ermount              ermount\n    ern                  ern\n    ernight              ernight\n    eros                 ero\n    erpaid               erpaid\n    erparted             erpart\n    erpast               erpast\n    erpays               erpai\n    erpeer               erpeer\n    erperch              erperch\n    erpicturing          erpictur\n    erpingham            erpingham\n    erposting            erpost\n    erpow                erpow\n    erpress              erpress\n    erpressed            erpress\n    err                  err\n    errand               errand\n    errands              errand\n    errant               errant\n    errate               errat\n    erraught             erraught\n    erreaches            erreach\n    erred                er\n    errest               errest\n    erring               er\n    erroneous            erron\n    error                error\n    errors               error\n    errs                 err\n    errule               errul\n    errun                errun\n    erset                erset\n    ershade              ershad\n    ershades             ershad\n    ershine              ershin\n    ershot               ershot\n    ersized              ersiz\n    erskip               erskip\n    erslips              erslip\n    erspreads            erspread\n    erst                 erst\n    erstare              erstar\n    erstep               erstep\n    erstunk              erstunk\n    ersway               erswai\n    ersways              erswai\n    erswell              erswel\n    erta                 erta\n    ertake               ertak\n    erteemed             erteem\n    erthrow              erthrow\n    erthrown             erthrown\n    erthrows             erthrow\n    ertook               ertook\n    ertop                ertop\n    ertopping            ertop\n    ertrip               ertrip\n    erturn               erturn\n    erudition            erudit\n    eruption             erupt\n    eruptions            erupt\n    ervalues             ervalu\n    erwalk               erwalk\n    erwatch              erwatch\n    erween               erween\n    erweens              erween\n    erweigh              erweigh\n    erweighs             erweigh\n    erwhelm              erwhelm\n    erwhelmed            erwhelm\n    erworn               erworn\n    es                   es\n    escalus              escalu\n    escap                escap\n    escape               escap\n    escaped              escap\n    escapes              escap\n    eschew               eschew\n    escoted              escot\n    esill                esil\n    especial             especi\n    especially           especi\n    esperance            esper\n    espials              espial\n    espied               espi\n    espies               espi\n    espous               espou\n    espouse              espous\n    espy                 espi\n    esquire              esquir\n    esquires             esquir\n    essay                essai\n    essays               essai\n    essence              essenc\n    essential            essenti\n    essentially          essenti\n    esses                ess\n    essex                essex\n    est                  est\n    establish            establish\n    established          establish\n    estate               estat\n    estates              estat\n    esteem               esteem\n    esteemed             esteem\n    esteemeth            esteemeth\n    esteeming            esteem\n    esteems              esteem\n    estimable            estim\n    estimate             estim\n    estimation           estim\n    estimations          estim\n    estime               estim\n    estranged            estrang\n    estridge             estridg\n    estridges            estridg\n    et                   et\n    etc                  etc\n    etceteras            etcetera\n    ete                  et\n    eternal              etern\n    eternally            etern\n    eterne               etern\n    eternity             etern\n    eterniz              eterniz\n    etes                 et\n    ethiop               ethiop\n    ethiope              ethiop\n    ethiopes             ethiop\n    ethiopian            ethiopian\n    etna                 etna\n    eton                 eton\n    etre                 etr\n    eunuch               eunuch\n    eunuchs              eunuch\n    euphrates            euphrat\n    euphronius           euphroniu\n    euriphile            euriphil\n    europa               europa\n    europe               europ\n    ev                   ev\n    evade                evad\n    evades               evad\n    evans                evan\n    evasion              evas\n    evasions             evas\n    eve                  ev\n    even                 even\n    evening              even\n    evenly               evenli\n    event                event\n    eventful             event\n    events               event\n    ever                 ever\n    everlasting          everlast\n    everlastingly        everlastingli\n    evermore             evermor\n    every                everi\n    everyone             everyon\n    everything           everyth\n    everywhere           everywher\n    evidence             evid\n    evidences            evid\n    evident              evid\n    evil                 evil\n    evilly               evilli\n    evils                evil\n    evitate              evit\n    ewe                  ew\n    ewer                 ewer\n    ewers                ewer\n    ewes                 ew\n    exact                exact\n    exacted              exact\n    exactest             exactest\n    exacting             exact\n    exaction             exact\n    exactions            exact\n    exactly              exactli\n    exacts               exact\n    exalt                exalt\n    exalted              exalt\n    examin               examin\n    examination          examin\n    examinations         examin\n    examine              examin\n    examined             examin\n    examines             examin\n    exampl               exampl\n    example              exampl\n    exampled             exampl\n    examples             exampl\n    exasperate           exasper\n    exasperates          exasper\n    exceed               exce\n    exceeded             exceed\n    exceedeth            exceedeth\n    exceeding            exceed\n    exceedingly          exceedingli\n    exceeds              exce\n    excel                excel\n    excelled             excel\n    excellence           excel\n    excellencies         excel\n    excellency           excel\n    excellent            excel\n    excellently          excel\n    excelling            excel\n    excels               excel\n    except               except\n    excepted             except\n    excepting            except\n    exception            except\n    exceptions           except\n    exceptless           exceptless\n    excess               excess\n    excessive            excess\n    exchang              exchang\n    exchange             exchang\n    exchanged            exchang\n    exchequer            exchequ\n    exchequers           exchequ\n    excite               excit\n    excited              excit\n    excitements          excit\n    excites              excit\n    exclaim              exclaim\n    exclaims             exclaim\n    exclamation          exclam\n    exclamations         exclam\n    excludes             exclud\n    excommunicate        excommun\n    excommunication      excommun\n    excrement            excrement\n    excrements           excrement\n    excursion            excurs\n    excursions           excurs\n    excus                excu\n    excusable            excus\n    excuse               excus\n    excused              excus\n    excuses              excus\n    excusez              excusez\n    excusing             excus\n    execrable            execr\n    execrations          execr\n    execute              execut\n    executed             execut\n    executing            execut\n    execution            execut\n    executioner          execution\n    executioners         execution\n    executor             executor\n    executors            executor\n    exempt               exempt\n    exempted             exempt\n    exequies             exequi\n    exercise             exercis\n    exercises            exercis\n    exeter               exet\n    exeunt               exeunt\n    exhal                exhal\n    exhalation           exhal\n    exhalations          exhal\n    exhale               exhal\n    exhales              exhal\n    exhaust              exhaust\n    exhibit              exhibit\n    exhibiters           exhibit\n    exhibition           exhibit\n    exhort               exhort\n    exhortation          exhort\n    exigent              exig\n    exil                 exil\n    exile                exil\n    exiled               exil\n    exion                exion\n    exist                exist\n    exists               exist\n    exit                 exit\n    exits                exit\n    exorciser            exorcis\n    exorcisms            exorc\n    exorcist             exorcist\n    expect               expect\n    expectance           expect\n    expectancy           expect\n    expectation          expect\n    expectations         expect\n    expected             expect\n    expecters            expect\n    expecting            expect\n    expects              expect\n    expedience           expedi\n    expedient            expedi\n    expediently          expedi\n    expedition           expedit\n    expeditious          expediti\n    expel                expel\n    expell               expel\n    expelling            expel\n    expels               expel\n    expend               expend\n    expense              expens\n    expenses             expens\n    experienc            experienc\n    experience           experi\n    experiences          experi\n    experiment           experi\n    experimental         experiment\n    experiments          experi\n    expert               expert\n    expertness           expert\n    expiate              expiat\n    expiation            expiat\n    expir                expir\n    expiration           expir\n    expire               expir\n    expired              expir\n    expires              expir\n    expiring             expir\n    explication          explic\n    exploit              exploit\n    exploits             exploit\n    expos                expo\n    expose               expos\n    exposing             expos\n    exposition           exposit\n    expositor            expositor\n    expostulate          expostul\n    expostulation        expostul\n    exposture            expostur\n    exposure             exposur\n    expound              expound\n    expounded            expound\n    express              express\n    expressed            express\n    expresseth           expresseth\n    expressing           express\n    expressive           express\n    expressly            expressli\n    expressure           expressur\n    expuls               expul\n    expulsion            expuls\n    exquisite            exquisit\n    exsufflicate         exsuffl\n    extant               extant\n    extemporal           extempor\n    extemporally         extempor\n    extempore            extempor\n    extend               extend\n    extended             extend\n    extends              extend\n    extent               extent\n    extenuate            extenu\n    extenuated           extenu\n    extenuates           extenu\n    extenuation          extenu\n    exterior             exterior\n    exteriorly           exteriorli\n    exteriors            exterior\n    extermin             extermin\n    extern               extern\n    external             extern\n    extinct              extinct\n    extincted            extinct\n    extincture           extinctur\n    extinguish           extinguish\n    extirp               extirp\n    extirpate            extirp\n    extirped             extirp\n    extol                extol\n    extoll               extol\n    extolment            extol\n    exton                exton\n    extort               extort\n    extorted             extort\n    extortion            extort\n    extortions           extort\n    extra                extra\n    extract              extract\n    extracted            extract\n    extracting           extract\n    extraordinarily      extraordinarili\n    extraordinary        extraordinari\n    extraught            extraught\n    extravagancy         extravag\n    extravagant          extravag\n    extreme              extrem\n    extremely            extrem\n    extremes             extrem\n    extremest            extremest\n    extremities          extrem\n    extremity            extrem\n    exuent               exuent\n    exult                exult\n    exultation           exult\n    ey                   ey\n    eyas                 eya\n    eyases               eyas\n    eye                  ey\n    eyeball              eyebal\n    eyeballs             eyebal\n    eyebrow              eyebrow\n    eyebrows             eyebrow\n    eyed                 ei\n    eyeless              eyeless\n    eyelid               eyelid\n    eyelids              eyelid\n    eyes                 ey\n    eyesight             eyesight\n    eyestrings           eyestr\n    eying                ei\n    eyne                 eyn\n    eyrie                eyri\n    fa                   fa\n    fabian               fabian\n    fable                fabl\n    fables               fabl\n    fabric               fabric\n    fabulous             fabul\n    fac                  fac\n    face                 face\n    faced                face\n    facere               facer\n    faces                face\n    faciant              faciant\n    facile               facil\n    facility             facil\n    facinerious          facineri\n    facing               face\n    facit                facit\n    fact                 fact\n    faction              faction\n    factionary           factionari\n    factions             faction\n    factious             factiou\n    factor               factor\n    factors              factor\n    faculties            faculti\n    faculty              faculti\n    fade                 fade\n    faded                fade\n    fadeth               fadeth\n    fadge                fadg\n    fading               fade\n    fadings              fade\n    fadom                fadom\n    fadoms               fadom\n    fagot                fagot\n    fagots               fagot\n    fail                 fail\n    failing              fail\n    fails                fail\n    fain                 fain\n    faint                faint\n    fainted              faint\n    fainter              fainter\n    fainting             faint\n    faintly              faintli\n    faintness            faint\n    faints               faint\n    fair                 fair\n    fairer               fairer\n    fairest              fairest\n    fairies              fairi\n    fairing              fair\n    fairings             fair\n    fairly               fairli\n    fairness             fair\n    fairs                fair\n    fairwell             fairwel\n    fairy                fairi\n    fais                 fai\n    fait                 fait\n    faites               fait\n    faith                faith\n    faithful             faith\n    faithfull            faithful\n    faithfully           faithfulli\n    faithless            faithless\n    faiths               faith\n    faitors              faitor\n    fal                  fal\n    falchion             falchion\n    falcon               falcon\n    falconbridge         falconbridg\n    falconer             falcon\n    falconers            falcon\n    fall                 fall\n    fallacy              fallaci\n    fallen               fallen\n    falleth              falleth\n    falliable            falliabl\n    fallible             fallibl\n    falling              fall\n    fallow               fallow\n    fallows              fallow\n    falls                fall\n    fally                falli\n    falorous             falor\n    false                fals\n    falsehood            falsehood\n    falsely              fals\n    falseness            fals\n    falser               falser\n    falsify              falsifi\n    falsing              fals\n    falstaff             falstaff\n    falstaffs            falstaff\n    falter               falter\n    fam                  fam\n    fame                 fame\n    famed                fame\n    familiar             familiar\n    familiarity          familiar\n    familiarly           familiarli\n    familiars            familiar\n    family               famili\n    famine               famin\n    famish               famish\n    famished             famish\n    famous               famou\n    famoused             famous\n    famously             famous\n    fan                  fan\n    fanatical            fanat\n    fancies              fanci\n    fancy                fanci\n    fane                 fane\n    fanes                fane\n    fang                 fang\n    fangled              fangl\n    fangless             fangless\n    fangs                fang\n    fann                 fann\n    fanning              fan\n    fans                 fan\n    fantasied            fantasi\n    fantasies            fantasi\n    fantastic            fantast\n    fantastical          fantast\n    fantastically        fantast\n    fantasticoes         fantastico\n    fantasy              fantasi\n    fap                  fap\n    far                  far\n    farborough           farborough\n    farced               farc\n    fardel               fardel\n    fardels              fardel\n    fare                 fare\n    fares                fare\n    farewell             farewel\n    farewells            farewel\n    fariner              farin\n    faring               fare\n    farm                 farm\n    farmer               farmer\n    farmhouse            farmhous\n    farms                farm\n    farre                farr\n    farrow               farrow\n    farther              farther\n    farthest             farthest\n    farthing             farth\n    farthingale          farthingal\n    farthingales         farthingal\n    farthings            farth\n    fartuous             fartuou\n    fas                  fa\n    fashion              fashion\n    fashionable          fashion\n    fashioning           fashion\n    fashions             fashion\n    fast                 fast\n    fasted               fast\n    fasten               fasten\n    fastened             fasten\n    faster               faster\n    fastest              fastest\n    fasting              fast\n    fastly               fastli\n    fastolfe             fastolf\n    fasts                fast\n    fat                  fat\n    fatal                fatal\n    fatally              fatal\n    fate                 fate\n    fated                fate\n    fates                fate\n    father               father\n    fathered             father\n    fatherless           fatherless\n    fatherly             fatherli\n    fathers              father\n    fathom               fathom\n    fathomless           fathomless\n    fathoms              fathom\n    fatigate             fatig\n    fatness              fat\n    fats                 fat\n    fatted               fat\n    fatter               fatter\n    fattest              fattest\n    fatting              fat\n    fatuus               fatuu\n    fauconbridge         fauconbridg\n    faulconbridge        faulconbridg\n    fault                fault\n    faultiness           faulti\n    faultless            faultless\n    faults               fault\n    faulty               faulti\n    fausse               fauss\n    fauste               faust\n    faustuses            faustus\n    faut                 faut\n    favor                favor\n    favorable            favor\n    favorably            favor\n    favors               favor\n    favour               favour\n    favourable           favour\n    favoured             favour\n    favouredly           favouredli\n    favourer             favour\n    favourers            favour\n    favouring            favour\n    favourite            favourit\n    favourites           favourit\n    favours              favour\n    favout               favout\n    fawn                 fawn\n    fawneth              fawneth\n    fawning              fawn\n    fawns                fawn\n    fay                  fai\n    fe                   fe\n    fealty               fealti\n    fear                 fear\n    feared               fear\n    fearest              fearest\n    fearful              fear\n    fearfull             fearful\n    fearfully            fearfulli\n    fearfulness          fear\n    fearing              fear\n    fearless             fearless\n    fears                fear\n    feast                feast\n    feasted              feast\n    feasting             feast\n    feasts               feast\n    feat                 feat\n    feated               feat\n    feater               feater\n    feather              feather\n    feathered            feather\n    feathers             feather\n    featly               featli\n    feats                feat\n    featur               featur\n    feature              featur\n    featured             featur\n    featureless          featureless\n    features             featur\n    february             februari\n    fecks                feck\n    fed                  fed\n    fedary               fedari\n    federary             federari\n    fee                  fee\n    feeble               feebl\n    feebled              feebl\n    feebleness           feebl\n    feebling             feebl\n    feebly               feebli\n    feed                 feed\n    feeder               feeder\n    feeders              feeder\n    feedeth              feedeth\n    feeding              feed\n    feeds                feed\n    feel                 feel\n    feeler               feeler\n    feeling              feel\n    feelingly            feelingli\n    feels                feel\n    fees                 fee\n    feet                 feet\n    fehemently           fehement\n    feign                feign\n    feigned              feign\n    feigning             feign\n    feil                 feil\n    feith                feith\n    felicitate           felicit\n    felicity             felic\n    fell                 fell\n    fellest              fellest\n    fellies              felli\n    fellow               fellow\n    fellowly             fellowli\n    fellows              fellow\n    fellowship           fellowship\n    fellowships          fellowship\n    fells                fell\n    felon                felon\n    felonious            feloni\n    felony               feloni\n    felt                 felt\n    female               femal\n    females              femal\n    feminine             feminin\n    fen                  fen\n    fenc                 fenc\n    fence                fenc\n    fencer               fencer\n    fencing              fenc\n    fends                fend\n    fennel               fennel\n    fenny                fenni\n    fens                 fen\n    fenton               fenton\n    fer                  fer\n    ferdinand            ferdinand\n    fere                 fere\n    fernseed             fernse\n    ferrara              ferrara\n    ferrers              ferrer\n    ferret               ferret\n    ferry                ferri\n    ferryman             ferryman\n    fertile              fertil\n    fertility            fertil\n    fervency             fervenc\n    fervour              fervour\n    fery                 feri\n    fest                 fest\n    feste                fest\n    fester               fester\n    festinate            festin\n    festinately          festin\n    festival             festiv\n    festivals            festiv\n    fet                  fet\n    fetch                fetch\n    fetches              fetch\n    fetching             fetch\n    fetlock              fetlock\n    fetlocks             fetlock\n    fett                 fett\n    fetter               fetter\n    fettering            fetter\n    fetters              fetter\n    fettle               fettl\n    feu                  feu\n    feud                 feud\n    fever                fever\n    feverous             fever\n    fevers               fever\n    few                  few\n    fewer                fewer\n    fewest               fewest\n    fewness              few\n    fickle               fickl\n    fickleness           fickl\n    fico                 fico\n    fiction              fiction\n    fiddle               fiddl\n    fiddler              fiddler\n    fiddlestick          fiddlestick\n    fidele               fidel\n    fidelicet            fidelicet\n    fidelity             fidel\n    fidius               fidiu\n    fie                  fie\n    field                field\n    fielded              field\n    fields               field\n    fiend                fiend\n    fiends               fiend\n    fierce               fierc\n    fiercely             fierc\n    fierceness           fierc\n    fiery                fieri\n    fife                 fife\n    fifes                fife\n    fifteen              fifteen\n    fifteens             fifteen\n    fifteenth            fifteenth\n    fifth                fifth\n    fifty                fifti\n    fiftyfold            fiftyfold\n    fig                  fig\n    fight                fight\n    fighter              fighter\n    fightest             fightest\n    fighteth             fighteth\n    fighting             fight\n    fights               fight\n    figo                 figo\n    figs                 fig\n    figur                figur\n    figure               figur\n    figured              figur\n    figures              figur\n    figuring             figur\n    fike                 fike\n    fil                  fil\n    filberts             filbert\n    filch                filch\n    filches              filch\n    filching             filch\n    file                 file\n    filed                file\n    files                file\n    filial               filial\n    filius               filiu\n    fill                 fill\n    filled               fill\n    fillet               fillet\n    filling              fill\n    fillip               fillip\n    fills                fill\n    filly                filli\n    film                 film\n    fils                 fil\n    filth                filth\n    filths               filth\n    filthy               filthi\n    fin                  fin\n    finally              final\n    finch                finch\n    find                 find\n    finder               finder\n    findeth              findeth\n    finding              find\n    findings             find\n    finds                find\n    fine                 fine\n    fineless             fineless\n    finely               fine\n    finem                finem\n    fineness             fine\n    finer                finer\n    fines                fine\n    finest               finest\n    fing                 fing\n    finger               finger\n    fingering            finger\n    fingers              finger\n    fingre               fingr\n    fingres              fingr\n    finical              finic\n    finish               finish\n    finished             finish\n    finisher             finish\n    finless              finless\n    finn                 finn\n    fins                 fin\n    finsbury             finsburi\n    fir                  fir\n    firago               firago\n    fire                 fire\n    firebrand            firebrand\n    firebrands           firebrand\n    fired                fire\n    fires                fire\n    firework             firework\n    fireworks            firework\n    firing               fire\n    firk                 firk\n    firm                 firm\n    firmament            firmament\n    firmly               firmli\n    firmness             firm\n    first                first\n    firstlings           firstl\n    fish                 fish\n    fisher               fisher\n    fishermen            fishermen\n    fishers              fisher\n    fishes               fish\n    fishified            fishifi\n    fishmonger           fishmong\n    fishpond             fishpond\n    fisnomy              fisnomi\n    fist                 fist\n    fisting              fist\n    fists                fist\n    fistula              fistula\n    fit                  fit\n    fitchew              fitchew\n    fitful               fit\n    fitly                fitli\n    fitment              fitment\n    fitness              fit\n    fits                 fit\n    fitted               fit\n    fitter               fitter\n    fittest              fittest\n    fitteth              fitteth\n    fitting              fit\n    fitzwater            fitzwat\n    five                 five\n    fivepence            fivep\n    fives                five\n    fix                  fix\n    fixed                fix\n    fixes                fix\n    fixeth               fixeth\n    fixing               fix\n    fixture              fixtur\n    fl                   fl\n    flag                 flag\n    flagging             flag\n    flagon               flagon\n    flagons              flagon\n    flags                flag\n    flail                flail\n    flakes               flake\n    flaky                flaki\n    flam                 flam\n    flame                flame\n    flamen               flamen\n    flamens              flamen\n    flames               flame\n    flaming              flame\n    flaminius            flaminiu\n    flanders             flander\n    flannel              flannel\n    flap                 flap\n    flaring              flare\n    flash                flash\n    flashes              flash\n    flashing             flash\n    flask                flask\n    flat                 flat\n    flatly               flatli\n    flatness             flat\n    flats                flat\n    flatt                flatt\n    flatter              flatter\n    flattered            flatter\n    flatterer            flatter\n    flatterers           flatter\n    flatterest           flatterest\n    flatteries           flatteri\n    flattering           flatter\n    flatters             flatter\n    flattery             flatteri\n    flaunts              flaunt\n    flavio               flavio\n    flavius              flaviu\n    flaw                 flaw\n    flaws                flaw\n    flax                 flax\n    flaxen               flaxen\n    flay                 flai\n    flaying              flai\n    flea                 flea\n    fleance              fleanc\n    fleas                flea\n    flecked              fleck\n    fled                 fled\n    fledge               fledg\n    flee                 flee\n    fleec                fleec\n    fleece               fleec\n    fleeces              fleec\n    fleer                fleer\n    fleering             fleer\n    fleers               fleer\n    fleet                fleet\n    fleeter              fleeter\n    fleeting             fleet\n    fleming              fleme\n    flemish              flemish\n    flesh                flesh\n    fleshes              flesh\n    fleshly              fleshli\n    fleshment            fleshment\n    fleshmonger          fleshmong\n    flew                 flew\n    flexible             flexibl\n    flexure              flexur\n    flibbertigibbet      flibbertigibbet\n    flickering           flicker\n    flidge               flidg\n    fliers               flier\n    flies                fli\n    flieth               flieth\n    flight               flight\n    flights              flight\n    flighty              flighti\n    flinch               flinch\n    fling                fling\n    flint                flint\n    flints               flint\n    flinty               flinti\n    flirt                flirt\n    float                float\n    floated              float\n    floating             float\n    flock                flock\n    flocks               flock\n    flood                flood\n    floodgates           floodgat\n    floods               flood\n    floor                floor\n    flora                flora\n    florence             florenc\n    florentine           florentin\n    florentines          florentin\n    florentius           florentiu\n    florizel             florizel\n    flote                flote\n    floulish             floulish\n    flour                flour\n    flourish             flourish\n    flourishes           flourish\n    flourisheth          flourisheth\n    flourishing          flourish\n    flout                flout\n    flouted              flout\n    flouting             flout\n    flouts               flout\n    flow                 flow\n    flowed               flow\n    flower               flower\n    flowerets            floweret\n    flowers              flower\n    flowing              flow\n    flown                flown\n    flows                flow\n    fluellen             fluellen\n    fluent               fluent\n    flung                flung\n    flush                flush\n    flushing             flush\n    fluster              fluster\n    flute                flute\n    flutes               flute\n    flutter              flutter\n    flux                 flux\n    fluxive              fluxiv\n    fly                  fly\n    flying               fly\n    fo                   fo\n    foal                 foal\n    foals                foal\n    foam                 foam\n    foamed               foam\n    foaming              foam\n    foams                foam\n    foamy                foami\n    fob                  fob\n    focative             foc\n    fodder               fodder\n    foe                  foe\n    foeman               foeman\n    foemen               foemen\n    foes                 foe\n    fog                  fog\n    foggy                foggi\n    fogs                 fog\n    foh                  foh\n    foi                  foi\n    foil                 foil\n    foiled               foil\n    foils                foil\n    foin                 foin\n    foining              foin\n    foins                foin\n    fois                 foi\n    foison               foison\n    foisons              foison\n    foist                foist\n    foix                 foix\n    fold                 fold\n    folded               fold\n    folds                fold\n    folio                folio\n    folk                 folk\n    folks                folk\n    follies              folli\n    follow               follow\n    followed             follow\n    follower             follow\n    followers            follow\n    followest            followest\n    following            follow\n    follows              follow\n    folly                folli\n    fond                 fond\n    fonder               fonder\n    fondly               fondli\n    fondness             fond\n    font                 font\n    fontibell            fontibel\n    food                 food\n    fool                 fool\n    fooleries            fooleri\n    foolery              fooleri\n    foolhardy            foolhardi\n    fooling              fool\n    foolish              foolish\n    foolishly            foolishli\n    foolishness          foolish\n    fools                fool\n    foot                 foot\n    football             footbal\n    footboy              footboi\n    footboys             footboi\n    footed               foot\n    footfall             footfal\n    footing              foot\n    footman              footman\n    footmen              footmen\n    footpath             footpath\n    footsteps            footstep\n    footstool            footstool\n    fopp                 fopp\n    fopped               fop\n    foppery              fopperi\n    foppish              foppish\n    fops                 fop\n    for                  for\n    forage               forag\n    foragers             forag\n    forbade              forbad\n    forbear              forbear\n    forbearance          forbear\n    forbears             forbear\n    forbid               forbid\n    forbidden            forbidden\n    forbiddenly          forbiddenli\n    forbids              forbid\n    forbod               forbod\n    forborne             forborn\n    forc                 forc\n    force                forc\n    forced               forc\n    forceful             forc\n    forceless            forceless\n    forces               forc\n    forcible             forcibl\n    forcibly             forcibl\n    forcing              forc\n    ford                 ford\n    fordid               fordid\n    fordo                fordo\n    fordoes              fordo\n    fordone              fordon\n    fore                 fore\n    forecast             forecast\n    forefather           forefath\n    forefathers          forefath\n    forefinger           forefing\n    forego               forego\n    foregone             foregon\n    forehand             forehand\n    forehead             forehead\n    foreheads            forehead\n    forehorse            forehors\n    foreign              foreign\n    foreigner            foreign\n    foreigners           foreign\n    foreknowing          foreknow\n    foreknowledge        foreknowledg\n    foremost             foremost\n    forenamed            forenam\n    forenoon             forenoon\n    forerun              forerun\n    forerunner           forerunn\n    forerunning          forerun\n    foreruns             forerun\n    foresaid             foresaid\n    foresaw              foresaw\n    foresay              foresai\n    foresee              forese\n    foreseeing           forese\n    foresees             forese\n    foreshow             foreshow\n    foreskirt            foreskirt\n    forespent            foresp\n    forest               forest\n    forestall            forestal\n    forestalled          forestal\n    forester             forest\n    foresters            forest\n    forests              forest\n    foretell             foretel\n    foretelling          foretel\n    foretells            foretel\n    forethink            forethink\n    forethought          forethought\n    foretold             foretold\n    forever              forev\n    foreward             foreward\n    forewarn             forewarn\n    forewarned           forewarn\n    forewarning          forewarn\n    forfeit              forfeit\n    forfeited            forfeit\n    forfeiters           forfeit\n    forfeiting           forfeit\n    forfeits             forfeit\n    forfeiture           forfeitur\n    forfeitures          forfeitur\n    forfend              forfend\n    forfended            forfend\n    forg                 forg\n    forgave              forgav\n    forge                forg\n    forged               forg\n    forgeries            forgeri\n    forgery              forgeri\n    forges               forg\n    forget               forget\n    forgetful            forget\n    forgetfulness        forget\n    forgetive            forget\n    forgets              forget\n    forgetting           forget\n    forgive              forgiv\n    forgiven             forgiven\n    forgiveness          forgiv\n    forgo                forgo\n    forgoing             forgo\n    forgone              forgon\n    forgot               forgot\n    forgotten            forgotten\n    fork                 fork\n    forked               fork\n    forks                fork\n    forlorn              forlorn\n    form                 form\n    formal               formal\n    formally             formal\n    formed               form\n    former               former\n    formerly             formerli\n    formless             formless\n    forms                form\n    fornication          fornic\n    fornications         fornic\n    fornicatress         fornicatress\n    forres               forr\n    forrest              forrest\n    forsake              forsak\n    forsaken             forsaken\n    forsaketh            forsaketh\n    forslow              forslow\n    forsook              forsook\n    forsooth             forsooth\n    forspent             forspent\n    forspoke             forspok\n    forswear             forswear\n    forswearing          forswear\n    forswore             forswor\n    forsworn             forsworn\n    fort                 fort\n    forted               fort\n    forth                forth\n    forthcoming          forthcom\n    forthlight           forthlight\n    forthright           forthright\n    forthwith            forthwith\n    fortification        fortif\n    fortifications       fortif\n    fortified            fortifi\n    fortifies            fortifi\n    fortify              fortifi\n    fortinbras           fortinbra\n    fortitude            fortitud\n    fortnight            fortnight\n    fortress             fortress\n    fortresses           fortress\n    forts                fort\n    fortun               fortun\n    fortuna              fortuna\n    fortunate            fortun\n    fortunately          fortun\n    fortune              fortun\n    fortuned             fortun\n    fortunes             fortun\n    fortward             fortward\n    forty                forti\n    forum                forum\n    forward              forward\n    forwarding           forward\n    forwardness          forward\n    forwards             forward\n    forwearied           forweari\n    fosset               fosset\n    fost                 fost\n    foster               foster\n    fostered             foster\n    fought               fought\n    foughten             foughten\n    foul                 foul\n    fouler               fouler\n    foulest              foulest\n    foully               foulli\n    foulness             foul\n    found                found\n    foundation           foundat\n    foundations          foundat\n    founded              found\n    founder              founder\n    fount                fount\n    fountain             fountain\n    fountains            fountain\n    founts               fount\n    four                 four\n    fourscore            fourscor\n    fourteen             fourteen\n    fourth               fourth\n    foutra               foutra\n    fowl                 fowl\n    fowler               fowler\n    fowling              fowl\n    fowls                fowl\n    fox                  fox\n    foxes                fox\n    foxship              foxship\n    fracted              fract\n    fraction             fraction\n    fractions            fraction\n    fragile              fragil\n    fragment             fragment\n    fragments            fragment\n    fragrant             fragrant\n    frail                frail\n    frailer              frailer\n    frailties            frailti\n    frailty              frailti\n    fram                 fram\n    frame                frame\n    framed               frame\n    frames               frame\n    frampold             frampold\n    fran                 fran\n    francais             francai\n    france               franc\n    frances              franc\n    franchise            franchis\n    franchised           franchis\n    franchisement        franchis\n    franchises           franchis\n    franciae             francia\n    francis              franci\n    francisca            francisca\n    franciscan           franciscan\n    francisco            francisco\n    frank                frank\n    franker              franker\n    frankfort            frankfort\n    franklin             franklin\n    franklins            franklin\n    frankly              frankli\n    frankness            frank\n    frantic              frantic\n    franticly            franticli\n    frateretto           frateretto\n    fratrum              fratrum\n    fraud                fraud\n    fraudful             fraud\n    fraught              fraught\n    fraughtage           fraughtag\n    fraughting           fraught\n    fray                 frai\n    frays                frai\n    freckl               freckl\n    freckled             freckl\n    freckles             freckl\n    frederick            frederick\n    free                 free\n    freed                freed\n    freedom              freedom\n    freedoms             freedom\n    freehearted          freeheart\n    freelier             freelier\n    freely               freeli\n    freeman              freeman\n    freemen              freemen\n    freeness             freeness\n    freer                freer\n    frees                free\n    freestone            freeston\n    freetown             freetown\n    freeze               freez\n    freezes              freez\n    freezing             freez\n    freezings            freez\n    french               french\n    frenchman            frenchman\n    frenchmen            frenchmen\n    frenchwoman          frenchwoman\n    frenzy               frenzi\n    frequent             frequent\n    frequents            frequent\n    fresh                fresh\n    fresher              fresher\n    freshes              fresh\n    freshest             freshest\n    freshly              freshli\n    freshness            fresh\n    fret                 fret\n    fretful              fret\n    frets                fret\n    fretted              fret\n    fretten              fretten\n    fretting             fret\n    friar                friar\n    friars               friar\n    friday               fridai\n    fridays              fridai\n    friend               friend\n    friended             friend\n    friending            friend\n    friendless           friendless\n    friendliness         friendli\n    friendly             friendli\n    friends              friend\n    friendship           friendship\n    friendships          friendship\n    frieze               friez\n    fright               fright\n    frighted             fright\n    frightened           frighten\n    frightful            fright\n    frighting            fright\n    frights              fright\n    fringe               fring\n    fringed              fring\n    frippery             fripperi\n    frisk                frisk\n    fritters             fritter\n    frivolous            frivol\n    fro                  fro\n    frock                frock\n    frog                 frog\n    frogmore             frogmor\n    froissart            froissart\n    frolic               frolic\n    from                 from\n    front                front\n    fronted              front\n    frontier             frontier\n    frontiers            frontier\n    fronting             front\n    frontlet             frontlet\n    fronts               front\n    frost                frost\n    frosts               frost\n    frosty               frosti\n    froth                froth\n    froward              froward\n    frown                frown\n    frowning             frown\n    frowningly           frowningli\n    frowns               frown\n    froze                froze\n    frozen               frozen\n    fructify             fructifi\n    frugal               frugal\n    fruit                fruit\n    fruiterer            fruiter\n    fruitful             fruit\n    fruitfully           fruitfulli\n    fruitfulness         fruit\n    fruition             fruition\n    fruitless            fruitless\n    fruits               fruit\n    frush                frush\n    frustrate            frustrat\n    frutify              frutifi\n    fry                  fry\n    fubb                 fubb\n    fuel                 fuel\n    fugitive             fugit\n    fulfil               fulfil\n    fulfill              fulfil\n    fulfilling           fulfil\n    fulfils              fulfil\n    full                 full\n    fullam               fullam\n    fuller               fuller\n    fullers              fuller\n    fullest              fullest\n    fullness             full\n    fully                fulli\n    fulness              ful\n    fulsome              fulsom\n    fulvia               fulvia\n    fum                  fum\n    fumble               fumbl\n    fumbles              fumbl\n    fumblest             fumblest\n    fumbling             fumbl\n    fume                 fume\n    fumes                fume\n    fuming               fume\n    fumiter              fumit\n    fumitory             fumitori\n    fun                  fun\n    function             function\n    functions            function\n    fundamental          fundament\n    funeral              funer\n    funerals             funer\n    fur                  fur\n    furbish              furbish\n    furies               furi\n    furious              furiou\n    furlongs             furlong\n    furnace              furnac\n    furnaces             furnac\n    furnish              furnish\n    furnished            furnish\n    furnishings          furnish\n    furniture            furnitur\n    furnival             furniv\n    furor                furor\n    furr                 furr\n    furrow               furrow\n    furrowed             furrow\n    furrows              furrow\n    furth                furth\n    further              further\n    furtherance          further\n    furtherer            further\n    furthermore          furthermor\n    furthest             furthest\n    fury                 furi\n    furze                furz\n    furzes               furz\n    fust                 fust\n    fustian              fustian\n    fustilarian          fustilarian\n    fusty                fusti\n    fut                  fut\n    future               futur\n    futurity             futur\n    g                    g\n    gabble               gabbl\n    gaberdine            gaberdin\n    gabriel              gabriel\n    gad                  gad\n    gadding              gad\n    gads                 gad\n    gadshill             gadshil\n    gag                  gag\n    gage                 gage\n    gaged                gage\n    gagg                 gagg\n    gaging               gage\n    gagne                gagn\n    gain                 gain\n    gained               gain\n    gainer               gainer\n    gaingiving           gaingiv\n    gains                gain\n    gainsaid             gainsaid\n    gainsay              gainsai\n    gainsaying           gainsai\n    gainsays             gainsai\n    gainst               gainst\n    gait                 gait\n    gaited               gait\n    galathe              galath\n    gale                 gale\n    galen                galen\n    gales                gale\n    gall                 gall\n    gallant              gallant\n    gallantly            gallantli\n    gallantry            gallantri\n    gallants             gallant\n    galled               gall\n    gallery              galleri\n    galley               gallei\n    galleys              gallei\n    gallia               gallia\n    gallian              gallian\n    galliard             galliard\n    galliasses           galliass\n    gallimaufry          gallimaufri\n    galling              gall\n    gallons              gallon\n    gallop               gallop\n    galloping            gallop\n    gallops              gallop\n    gallow               gallow\n    galloway             gallowai\n    gallowglasses        gallowglass\n    gallows              gallow\n    gallowses            gallows\n    galls                gall\n    gallus               gallu\n    gam                  gam\n    gambol               gambol\n    gambold              gambold\n    gambols              gambol\n    gamboys              gamboi\n    game                 game\n    gamers               gamer\n    games                game\n    gamesome             gamesom\n    gamester             gamest\n    gaming               game\n    gammon               gammon\n    gamut                gamut\n    gan                  gan\n    gangren              gangren\n    ganymede             ganymed\n    gaol                 gaol\n    gaoler               gaoler\n    gaolers              gaoler\n    gaols                gaol\n    gap                  gap\n    gape                 gape\n    gapes                gape\n    gaping               gape\n    gar                  gar\n    garb                 garb\n    garbage              garbag\n    garboils             garboil\n    garcon               garcon\n    gard                 gard\n    garde                gard\n    garden               garden\n    gardener             garden\n    gardeners            garden\n    gardens              garden\n    gardez               gardez\n    gardiner             gardin\n    gardon               gardon\n    gargantua            gargantua\n    gargrave             gargrav\n    garish               garish\n    garland              garland\n    garlands             garland\n    garlic               garlic\n    garment              garment\n    garments             garment\n    garmet               garmet\n    garner               garner\n    garners              garner\n    garnish              garnish\n    garnished            garnish\n    garret               garret\n    garrison             garrison\n    garrisons            garrison\n    gart                 gart\n    garter               garter\n    garterd              garterd\n    gartering            garter\n    garters              garter\n    gascony              gasconi\n    gash                 gash\n    gashes               gash\n    gaskins              gaskin\n    gasp                 gasp\n    gasping              gasp\n    gasted               gast\n    gastness             gast\n    gat                  gat\n    gate                 gate\n    gated                gate\n    gates                gate\n    gath                 gath\n    gather               gather\n    gathered             gather\n    gathering            gather\n    gathers              gather\n    gatories             gatori\n    gatory               gatori\n    gaud                 gaud\n    gaudeo               gaudeo\n    gaudy                gaudi\n    gauge                gaug\n    gaul                 gaul\n    gaultree             gaultre\n    gaunt                gaunt\n    gauntlet             gauntlet\n    gauntlets            gauntlet\n    gav                  gav\n    gave                 gave\n    gavest               gavest\n    gawded               gawd\n    gawds                gawd\n    gawsey               gawsei\n    gay                  gai\n    gayness              gay\n    gaz                  gaz\n    gaze                 gaze\n    gazed                gaze\n    gazer                gazer\n    gazers               gazer\n    gazes                gaze\n    gazeth               gazeth\n    gazing               gaze\n    gear                 gear\n    geck                 geck\n    geese                gees\n    geffrey              geffrei\n    geld                 geld\n    gelded               geld\n    gelding              geld\n    gelida               gelida\n    gelidus              gelidu\n    gelt                 gelt\n    gem                  gem\n    geminy               gemini\n    gems                 gem\n    gen                  gen\n    gender               gender\n    genders              gender\n    general              gener\n    generally            gener\n    generals             gener\n    generation           gener\n    generations          gener\n    generative           gener\n    generosity           generos\n    generous             gener\n    genitive             genit\n    genitivo             genitivo\n    genius               geniu\n    gennets              gennet\n    genoa                genoa\n    genoux               genoux\n    gens                 gen\n    gent                 gent\n    gentilhomme          gentilhomm\n    gentility            gentil\n    gentle               gentl\n    gentlefolks          gentlefolk\n    gentleman            gentleman\n    gentlemanlike        gentlemanlik\n    gentlemen            gentlemen\n    gentleness           gentl\n    gentler              gentler\n    gentles              gentl\n    gentlest             gentlest\n    gentlewoman          gentlewoman\n    gentlewomen          gentlewomen\n    gently               gentli\n    gentry               gentri\n    george               georg\n    gerard               gerard\n    germaines            germain\n    germains             germain\n    german               german\n    germane              german\n    germans              german\n    germany              germani\n    gertrude             gertrud\n    gest                 gest\n    gests                gest\n    gesture              gestur\n    gestures             gestur\n    get                  get\n    getrude              getrud\n    gets                 get\n    getter               getter\n    getting              get\n    ghastly              ghastli\n    ghost                ghost\n    ghosted              ghost\n    ghostly              ghostli\n    ghosts               ghost\n    gi                   gi\n    giant                giant\n    giantess             giantess\n    giantlike            giantlik\n    giants               giant\n    gib                  gib\n    gibber               gibber\n    gibbet               gibbet\n    gibbets              gibbet\n    gibe                 gibe\n    giber                giber\n    gibes                gibe\n    gibing               gibe\n    gibingly             gibingli\n    giddily              giddili\n    giddiness            giddi\n    giddy                giddi\n    gift                 gift\n    gifts                gift\n    gig                  gig\n    giglets              giglet\n    giglot               giglot\n    gilbert              gilbert\n    gild                 gild\n    gilded               gild\n    gilding              gild\n    gilliams             gilliam\n    gillian              gillian\n    gills                gill\n    gillyvors            gillyvor\n    gilt                 gilt\n    gimmal               gimmal\n    gimmers              gimmer\n    gin                  gin\n    ging                 ging\n    ginger               ginger\n    gingerbread          gingerbread\n    gingerly             gingerli\n    ginn                 ginn\n    gins                 gin\n    gioucestershire      gioucestershir\n    gipes                gipe\n    gipsies              gipsi\n    gipsy                gipsi\n    gird                 gird\n    girded               gird\n    girdle               girdl\n    girdled              girdl\n    girdles              girdl\n    girdling             girdl\n    girl                 girl\n    girls                girl\n    girt                 girt\n    girth                girth\n    gis                  gi\n    giv                  giv\n    give                 give\n    given                given\n    giver                giver\n    givers               giver\n    gives                give\n    givest               givest\n    giveth               giveth\n    giving               give\n    givings              give\n    glad                 glad\n    gladded              glad\n    gladding             glad\n    gladly               gladli\n    gladness             glad\n    glamis               glami\n    glanc                glanc\n    glance               glanc\n    glanced              glanc\n    glances              glanc\n    glancing             glanc\n    glanders             glander\n    glansdale            glansdal\n    glare                glare\n    glares               glare\n    glass                glass\n    glasses              glass\n    glassy               glassi\n    glaz                 glaz\n    glazed               glaze\n    gleams               gleam\n    glean                glean\n    gleaned              glean\n    gleaning             glean\n    gleeful              gleeful\n    gleek                gleek\n    gleeking             gleek\n    gleeks               gleek\n    glend                glend\n    glendower            glendow\n    glib                 glib\n    glide                glide\n    glided               glide\n    glides               glide\n    glideth              glideth\n    gliding              glide\n    glimmer              glimmer\n    glimmering           glimmer\n    glimmers             glimmer\n    glimpse              glimps\n    glimpses             glimps\n    glist                glist\n    glistening           glisten\n    glister              glister\n    glistering           glister\n    glisters             glister\n    glitt                glitt\n    glittering           glitter\n    globe                globe\n    globes               globe\n    glooming             gloom\n    gloomy               gloomi\n    glories              glori\n    glorified            glorifi\n    glorify              glorifi\n    glorious             gloriou\n    gloriously           glorious\n    glory                glori\n    glose                glose\n    gloss                gloss\n    glosses              gloss\n    glou                 glou\n    glouceste            gloucest\n    gloucester           gloucest\n    gloucestershire      gloucestershir\n    glove                glove\n    glover               glover\n    gloves               glove\n    glow                 glow\n    glowed               glow\n    glowing              glow\n    glowworm             glowworm\n    gloz                 gloz\n    gloze                gloze\n    glozes               gloze\n    glu                  glu\n    glue                 glue\n    glued                glu\n    glues                glue\n    glut                 glut\n    glutt                glutt\n    glutted              glut\n    glutton              glutton\n    gluttoning           glutton\n    gluttony             gluttoni\n    gnarled              gnarl\n    gnarling             gnarl\n    gnat                 gnat\n    gnats                gnat\n    gnaw                 gnaw\n    gnawing              gnaw\n    gnawn                gnawn\n    gnaws                gnaw\n    go                   go\n    goad                 goad\n    goaded               goad\n    goads                goad\n    goal                 goal\n    goat                 goat\n    goatish              goatish\n    goats                goat\n    gobbets              gobbet\n    gobbo                gobbo\n    goblet               goblet\n    goblets              goblet\n    goblin               goblin\n    goblins              goblin\n    god                  god\n    godded               god\n    godden               godden\n    goddess              goddess\n    goddesses            goddess\n    goddild              goddild\n    godfather            godfath\n    godfathers           godfath\n    godhead              godhead\n    godlike              godlik\n    godliness            godli\n    godly                godli\n    godmother            godmoth\n    gods                 god\n    godson               godson\n    goer                 goer\n    goers                goer\n    goes                 goe\n    goest                goest\n    goeth                goeth\n    goffe                goff\n    gogs                 gog\n    going                go\n    gold                 gold\n    golden               golden\n    goldenly             goldenli\n    goldsmith            goldsmith\n    goldsmiths           goldsmith\n    golgotha             golgotha\n    goliases             golias\n    goliath              goliath\n    gon                  gon\n    gondola              gondola\n    gondolier            gondoli\n    gone                 gone\n    goneril              goneril\n    gong                 gong\n    gonzago              gonzago\n    gonzalo              gonzalo\n    good                 good\n    goodfellow           goodfellow\n    goodlier             goodlier\n    goodliest            goodliest\n    goodly               goodli\n    goodman              goodman\n    goodness             good\n    goodnight            goodnight\n    goodrig              goodrig\n    goods                good\n    goodwife             goodwif\n    goodwill             goodwil\n    goodwin              goodwin\n    goodwins             goodwin\n    goodyear             goodyear\n    goodyears            goodyear\n    goose                goos\n    gooseberry           gooseberri\n    goosequills          goosequil\n    goot                 goot\n    gor                  gor\n    gorbellied           gorbelli\n    gorboduc             gorboduc\n    gordian              gordian\n    gore                 gore\n    gored                gore\n    gorg                 gorg\n    gorge                gorg\n    gorgeous             gorgeou\n    gorget               gorget\n    gorging              gorg\n    gorgon               gorgon\n    gormandize           gormand\n    gormandizing         gormand\n    gory                 gori\n    gosling              gosl\n    gospel               gospel\n    gospels              gospel\n    goss                 goss\n    gossamer             gossam\n    gossip               gossip\n    gossiping            gossip\n    gossiplike           gossiplik\n    gossips              gossip\n    got                  got\n    goth                 goth\n    goths                goth\n    gotten               gotten\n    gourd                gourd\n    gout                 gout\n    gouts                gout\n    gouty                gouti\n    govern               govern\n    governance           govern\n    governed             govern\n    governess            gover\n    government           govern\n    governor             governor\n    governors            governor\n    governs              govern\n    gower                gower\n    gown                 gown\n    gowns                gown\n    grac                 grac\n    grace                grace\n    graced               grace\n    graceful             grace\n    gracefully           gracefulli\n    graceless            graceless\n    graces               grace\n    gracing              grace\n    gracious             graciou\n    graciously           gracious\n    gradation            gradat\n    graff                graff\n    graffing             graf\n    graft                graft\n    grafted              graft\n    grafters             grafter\n    grain                grain\n    grained              grain\n    grains               grain\n    gramercies           gramerci\n    gramercy             gramerci\n    grammar              grammar\n    grand                grand\n    grandam              grandam\n    grandame             grandam\n    grandchild           grandchild\n    grande               grand\n    grandeur             grandeur\n    grandfather          grandfath\n    grandjurors          grandjuror\n    grandmother          grandmoth\n    grandpre             grandpr\n    grandsir             grandsir\n    grandsire            grandsir\n    grandsires           grandsir\n    grange               grang\n    grant                grant\n    granted              grant\n    granting             grant\n    grants               grant\n    grape                grape\n    grapes               grape\n    grapple              grappl\n    grapples             grappl\n    grappling            grappl\n    grasp                grasp\n    grasped              grasp\n    grasps               grasp\n    grass                grass\n    grasshoppers         grasshopp\n    grassy               grassi\n    grate                grate\n    grated               grate\n    grateful             grate\n    grates               grate\n    gratiano             gratiano\n    gratify              gratifi\n    gratii               gratii\n    gratillity           gratil\n    grating              grate\n    gratis               grati\n    gratitude            gratitud\n    gratulate            gratul\n    grav                 grav\n    grave                grave\n    gravediggers         gravedigg\n    gravel               gravel\n    graveless            graveless\n    gravell              gravel\n    gravely              grave\n    graven               graven\n    graveness            grave\n    graver               graver\n    graves               grave\n    gravest              gravest\n    gravestone           graveston\n    gravities            graviti\n    gravity              graviti\n    gravy                gravi\n    gray                 grai\n    graymalkin           graymalkin\n    graz                 graz\n    graze                graze\n    grazed               graze\n    grazing              graze\n    grease               greas\n    greases              greas\n    greasily             greasili\n    greasy               greasi\n    great                great\n    greater              greater\n    greatest             greatest\n    greatly              greatli\n    greatness            great\n    grecian              grecian\n    grecians             grecian\n    gree                 gree\n    greece               greec\n    greed                greed\n    greedily             greedili\n    greediness           greedi\n    greedy               greedi\n    greeing              gree\n    greek                greek\n    greekish             greekish\n    greeks               greek\n    green                green\n    greener              greener\n    greenly              greenli\n    greens               green\n    greensleeves         greensleev\n    greenwich            greenwich\n    greenwood            greenwood\n    greet                greet\n    greeted              greet\n    greeting             greet\n    greetings            greet\n    greets               greet\n    greg                 greg\n    gregory              gregori\n    gremio               gremio\n    grew                 grew\n    grey                 grei\n    greybeard            greybeard\n    greybeards           greybeard\n    greyhound            greyhound\n    greyhounds           greyhound\n    grief                grief\n    griefs               grief\n    griev                griev\n    grievance            grievanc\n    grievances           grievanc\n    grieve               griev\n    grieved              griev\n    grieves              griev\n    grievest             grievest\n    grieving             griev\n    grievingly           grievingli\n    grievous             grievou\n    grievously           grievous\n    griffin              griffin\n    griffith             griffith\n    grim                 grim\n    grime                grime\n    grimly               grimli\n    grin                 grin\n    grind                grind\n    grinding             grind\n    grindstone           grindston\n    grinning             grin\n    grip                 grip\n    gripe                gripe\n    gripes               gripe\n    griping              gripe\n    grise                grise\n    grisly               grisli\n    grissel              grissel\n    grize                grize\n    grizzle              grizzl\n    grizzled             grizzl\n    groan                groan\n    groaning             groan\n    groans               groan\n    groat                groat\n    groats               groat\n    groin                groin\n    groom                groom\n    grooms               groom\n    grop                 grop\n    groping              grope\n    gros                 gro\n    gross                gross\n    grosser              grosser\n    grossly              grossli\n    grossness            gross\n    ground               ground\n    grounded             ground\n    groundlings          groundl\n    grounds              ground\n    grove                grove\n    grovel               grovel\n    grovelling           grovel\n    groves               grove\n    grow                 grow\n    groweth              groweth\n    growing              grow\n    grown                grown\n    grows                grow\n    growth               growth\n    grub                 grub\n    grubb                grubb\n    grubs                grub\n    grudge               grudg\n    grudged              grudg\n    grudges              grudg\n    grudging             grudg\n    gruel                gruel\n    grumble              grumbl\n    grumblest            grumblest\n    grumbling            grumbl\n    grumblings           grumbl\n    grumio               grumio\n    grund                grund\n    grunt                grunt\n    gualtier             gualtier\n    guard                guard\n    guardage             guardag\n    guardant             guardant\n    guarded              guard\n    guardian             guardian\n    guardians            guardian\n    guards               guard\n    guardsman            guardsman\n    gud                  gud\n    gudgeon              gudgeon\n    guerdon              guerdon\n    guerra               guerra\n    guess                guess\n    guesses              guess\n    guessingly           guessingli\n    guest                guest\n    guests               guest\n    guiana               guiana\n    guichard             guichard\n    guide                guid\n    guided               guid\n    guider               guider\n    guiderius            guideriu\n    guides               guid\n    guiding              guid\n    guidon               guidon\n    guienne              guienn\n    guil                 guil\n    guildenstern         guildenstern\n    guilders             guilder\n    guildford            guildford\n    guildhall            guildhal\n    guile                guil\n    guiled               guil\n    guileful             guil\n    guilfords            guilford\n    guilt                guilt\n    guiltian             guiltian\n    guiltier             guiltier\n    guiltily             guiltili\n    guiltiness           guilti\n    guiltless            guiltless\n    guilts               guilt\n    guilty               guilti\n    guinea               guinea\n    guinever             guinev\n    guise                guis\n    gul                  gul\n    gules                gule\n    gulf                 gulf\n    gulfs                gulf\n    gull                 gull\n    gulls                gull\n    gum                  gum\n    gumm                 gumm\n    gums                 gum\n    gun                  gun\n    gunner               gunner\n    gunpowder            gunpowd\n    guns                 gun\n    gurnet               gurnet\n    gurney               gurnei\n    gust                 gust\n    gusts                gust\n    gusty                gusti\n    guts                 gut\n    gutter               gutter\n    guy                  gui\n    guynes               guyn\n    guysors              guysor\n    gypsy                gypsi\n    gyve                 gyve\n    gyved                gyve\n    gyves                gyve\n    h                    h\n    ha                   ha\n    haberdasher          haberdash\n    habiliment           habili\n    habiliments          habili\n    habit                habit\n    habitation           habit\n    habited              habit\n    habits               habit\n    habitude             habitud\n    hack                 hack\n    hacket               hacket\n    hackney              hacknei\n    hacks                hack\n    had                  had\n    hadst                hadst\n    haec                 haec\n    haeres               haer\n    hag                  hag\n    hagar                hagar\n    haggard              haggard\n    haggards             haggard\n    haggish              haggish\n    haggled              haggl\n    hags                 hag\n    hail                 hail\n    hailed               hail\n    hailstone            hailston\n    hailstones           hailston\n    hair                 hair\n    hairless             hairless\n    hairs                hair\n    hairy                hairi\n    hal                  hal\n    halberd              halberd\n    halberds             halberd\n    halcyon              halcyon\n    hale                 hale\n    haled                hale\n    hales                hale\n    half                 half\n    halfcan              halfcan\n    halfpence            halfpenc\n    halfpenny            halfpenni\n    halfpennyworth       halfpennyworth\n    halfway              halfwai\n    halidom              halidom\n    hall                 hall\n    halloa               halloa\n    halloing             hallo\n    hallond              hallond\n    halloo               halloo\n    hallooing            halloo\n    hallow               hallow\n    hallowed             hallow\n    hallowmas            hallowma\n    hallown              hallown\n    hals                 hal\n    halt                 halt\n    halter               halter\n    halters              halter\n    halting              halt\n    halts                halt\n    halves               halv\n    ham                  ham\n    hames                hame\n    hamlet               hamlet\n    hammer               hammer\n    hammered             hammer\n    hammering            hammer\n    hammers              hammer\n    hamper               hamper\n    hampton              hampton\n    hams                 ham\n    hamstring            hamstr\n    hand                 hand\n    handed               hand\n    handful              hand\n    handicraft           handicraft\n    handicraftsmen       handicraftsmen\n    handing              hand\n    handiwork            handiwork\n    handkercher          handkerch\n    handkerchers         handkerch\n    handkerchief         handkerchief\n    handle               handl\n    handled              handl\n    handles              handl\n    handless             handless\n    handlest             handlest\n    handling             handl\n    handmaid             handmaid\n    handmaids            handmaid\n    hands                hand\n    handsaw              handsaw\n    handsome             handsom\n    handsomely           handsom\n    handsomeness         handsom\n    handwriting          handwrit\n    handy                handi\n    hang                 hang\n    hanged               hang\n    hangers              hanger\n    hangeth              hangeth\n    hanging              hang\n    hangings             hang\n    hangman              hangman\n    hangmen              hangmen\n    hangs                hang\n    hannibal             hannib\n    hap                  hap\n    hapless              hapless\n    haply                hapli\n    happ                 happ\n    happen               happen\n    happened             happen\n    happier              happier\n    happies              happi\n    happiest             happiest\n    happily              happili\n    happiness            happi\n    happy                happi\n    haps                 hap\n    harbinger            harbing\n    harbingers           harbing\n    harbor               harbor\n    harbour              harbour\n    harbourage           harbourag\n    harbouring           harbour\n    harbours             harbour\n    harcourt             harcourt\n    hard                 hard\n    harder               harder\n    hardest              hardest\n    hardiest             hardiest\n    hardiment            hardiment\n    hardiness            hardi\n    hardly               hardli\n    hardness             hard\n    hardocks             hardock\n    hardy                hardi\n    hare                 hare\n    harelip              harelip\n    hares                hare\n    harfleur             harfleur\n    hark                 hark\n    harlot               harlot\n    harlotry             harlotri\n    harlots              harlot\n    harm                 harm\n    harmed               harm\n    harmful              harm\n    harming              harm\n    harmless             harmless\n    harmonious           harmoni\n    harmony              harmoni\n    harms                harm\n    harness              har\n    harp                 harp\n    harper               harper\n    harpier              harpier\n    harping              harp\n    harpy                harpi\n    harried              harri\n    harrow               harrow\n    harrows              harrow\n    harry                harri\n    harsh                harsh\n    harshly              harshli\n    harshness            harsh\n    hart                 hart\n    harts                hart\n    harum                harum\n    harvest              harvest\n    has                  ha\n    hast                 hast\n    haste                hast\n    hasted               hast\n    hasten               hasten\n    hastes               hast\n    hastily              hastili\n    hasting              hast\n    hastings             hast\n    hasty                hasti\n    hat                  hat\n    hatch                hatch\n    hatches              hatch\n    hatchet              hatchet\n    hatching             hatch\n    hatchment            hatchment\n    hate                 hate\n    hated                hate\n    hateful              hate\n    hater                hater\n    haters               hater\n    hates                hate\n    hateth               hateth\n    hatfield             hatfield\n    hath                 hath\n    hating               hate\n    hatred               hatr\n    hats                 hat\n    haud                 haud\n    hauf                 hauf\n    haught               haught\n    haughtiness          haughti\n    haughty              haughti\n    haunch               haunch\n    haunches             haunch\n    haunt                haunt\n    haunted              haunt\n    haunting             haunt\n    haunts               haunt\n    hautboy              hautboi\n    hautboys             hautboi\n    have                 have\n    haven                haven\n    havens               haven\n    haver                haver\n    having               have\n    havings              have\n    havior               havior\n    haviour              haviour\n    havoc                havoc\n    hawk                 hawk\n    hawking              hawk\n    hawks                hawk\n    hawthorn             hawthorn\n    hawthorns            hawthorn\n    hay                  hai\n    hazard               hazard\n    hazarded             hazard\n    hazards              hazard\n    hazel                hazel\n    hazelnut             hazelnut\n    he                   he\n    head                 head\n    headborough          headborough\n    headed               head\n    headier              headier\n    heading              head\n    headland             headland\n    headless             headless\n    headlong             headlong\n    heads                head\n    headsman             headsman\n    headstrong           headstrong\n    heady                headi\n    heal                 heal\n    healed               heal\n    healing              heal\n    heals                heal\n    health               health\n    healthful            health\n    healths              health\n    healthsome           healthsom\n    healthy              healthi\n    heap                 heap\n    heaping              heap\n    heaps                heap\n    hear                 hear\n    heard                heard\n    hearer               hearer\n    hearers              hearer\n    hearest              hearest\n    heareth              heareth\n    hearing              hear\n    hearings             hear\n    heark                heark\n    hearken              hearken\n    hearkens             hearken\n    hears                hear\n    hearsay              hearsai\n    hearse               hears\n    hearsed              hears\n    hearst               hearst\n    heart                heart\n    heartache            heartach\n    heartbreak           heartbreak\n    heartbreaking        heartbreak\n    hearted              heart\n    hearten              hearten\n    hearth               hearth\n    hearths              hearth\n    heartily             heartili\n    heartiness           hearti\n    heartless            heartless\n    heartlings           heartl\n    heartly              heartli\n    hearts               heart\n    heartsick            heartsick\n    heartstrings         heartstr\n    hearty               hearti\n    heat                 heat\n    heated               heat\n    heath                heath\n    heathen              heathen\n    heathenish           heathenish\n    heating              heat\n    heats                heat\n    heauties             heauti\n    heav                 heav\n    heave                heav\n    heaved               heav\n    heaven               heaven\n    heavenly             heavenli\n    heavens              heaven\n    heaves               heav\n    heavier              heavier\n    heaviest             heaviest\n    heavily              heavili\n    heaviness            heavi\n    heaving              heav\n    heavings             heav\n    heavy                heavi\n    hebona               hebona\n    hebrew               hebrew\n    hecate               hecat\n    hectic               hectic\n    hector               hector\n    hectors              hector\n    hecuba               hecuba\n    hedg                 hedg\n    hedge                hedg\n    hedgehog             hedgehog\n    hedgehogs            hedgehog\n    hedges               hedg\n    heed                 heed\n    heeded               heed\n    heedful              heed\n    heedfull             heedful\n    heedfully            heedfulli\n    heedless             heedless\n    heel                 heel\n    heels                heel\n    hefted               heft\n    hefts                heft\n    heifer               heifer\n    heifers              heifer\n    heigh                heigh\n    height               height\n    heighten             heighten\n    heinous              heinou\n    heinously            heinous\n    heir                 heir\n    heiress              heiress\n    heirless             heirless\n    heirs                heir\n    held                 held\n    helen                helen\n    helena               helena\n    helenus              helenu\n    helias               helia\n    helicons             helicon\n    hell                 hell\n    hellespont           hellespont\n    hellfire             hellfir\n    hellish              hellish\n    helm                 helm\n    helmed               helm\n    helmet               helmet\n    helmets              helmet\n    helms                helm\n    help                 help\n    helper               helper\n    helpers              helper\n    helpful              help\n    helping              help\n    helpless             helpless\n    helps                help\n    helter               helter\n    hem                  hem\n    heme                 heme\n    hemlock              hemlock\n    hemm                 hemm\n    hemp                 hemp\n    hempen               hempen\n    hems                 hem\n    hen                  hen\n    hence                henc\n    henceforth           henceforth\n    henceforward         henceforward\n    henchman             henchman\n    henri                henri\n    henricus             henricu\n    henry                henri\n    hens                 hen\n    hent                 hent\n    henton               henton\n    her                  her\n    herald               herald\n    heraldry             heraldri\n    heralds              herald\n    herb                 herb\n    herbert              herbert\n    herblets             herblet\n    herbs                herb\n    herculean            herculean\n    hercules             hercul\n    herd                 herd\n    herds                herd\n    herdsman             herdsman\n    herdsmen             herdsmen\n    here                 here\n    hereabout            hereabout\n    hereabouts           hereabout\n    hereafter            hereaft\n    hereby               herebi\n    hereditary           hereditari\n    hereford             hereford\n    herefordshire        herefordshir\n    herein               herein\n    hereof               hereof\n    heresies             heresi\n    heresy               heresi\n    heretic              heret\n    heretics             heret\n    hereto               hereto\n    hereupon             hereupon\n    heritage             heritag\n    heritier             heriti\n    hermes               herm\n    hermia               hermia\n    hermione             hermion\n    hermit               hermit\n    hermitage            hermitag\n    hermits              hermit\n    herne                hern\n    hero                 hero\n    herod                herod\n    herods               herod\n    heroes               hero\n    heroic               heroic\n    heroical             heroic\n    herring              her\n    herrings             her\n    hers                 her\n    herself              herself\n    hesperides           hesperid\n    hesperus             hesperu\n    hest                 hest\n    hests                hest\n    heure                heur\n    heureux              heureux\n    hew                  hew\n    hewgh                hewgh\n    hewing               hew\n    hewn                 hewn\n    hews                 hew\n    hey                  hei\n    heyday               heydai\n    hibocrates           hibocr\n    hic                  hic\n    hiccups              hiccup\n    hick                 hick\n    hid                  hid\n    hidden               hidden\n    hide                 hide\n    hideous              hideou\n    hideously            hideous\n    hideousness          hideous\n    hides                hide\n    hidest               hidest\n    hiding               hide\n    hie                  hie\n    hied                 hi\n    hiems                hiem\n    hies                 hi\n    hig                  hig\n    high                 high\n    higher               higher\n    highest              highest\n    highly               highli\n    highmost             highmost\n    highness             high\n    hight                hight\n    highway              highwai\n    highways             highwai\n    hilding              hild\n    hildings             hild\n    hill                 hill\n    hillo                hillo\n    hilloa               hilloa\n    hills                hill\n    hilt                 hilt\n    hilts                hilt\n    hily                 hili\n    him                  him\n    himself              himself\n    hinc                 hinc\n    hinckley             hincklei\n    hind                 hind\n    hinder               hinder\n    hindered             hinder\n    hinders              hinder\n    hindmost             hindmost\n    hinds                hind\n    hing                 hing\n    hinge                hing\n    hinges               hing\n    hint                 hint\n    hip                  hip\n    hipp                 hipp\n    hipparchus           hipparchu\n    hippolyta            hippolyta\n    hips                 hip\n    hir                  hir\n    hire                 hire\n    hired                hire\n    hiren                hiren\n    hirtius              hirtiu\n    his                  hi\n    hisperia             hisperia\n    hiss                 hiss\n    hisses               hiss\n    hissing              hiss\n    hist                 hist\n    historical           histor\n    history              histori\n    hit                  hit\n    hither               hither\n    hitherto             hitherto\n    hitherward           hitherward\n    hitherwards          hitherward\n    hits                 hit\n    hitting              hit\n    hive                 hive\n    hives                hive\n    hizzing              hizz\n    ho                   ho\n    hoa                  hoa\n    hoar                 hoar\n    hoard                hoard\n    hoarded              hoard\n    hoarding             hoard\n    hoars                hoar\n    hoarse               hoars\n    hoary                hoari\n    hob                  hob\n    hobbididence         hobbidid\n    hobby                hobbi\n    hobbyhorse           hobbyhors\n    hobgoblin            hobgoblin\n    hobnails             hobnail\n    hoc                  hoc\n    hod                  hod\n    hodge                hodg\n    hog                  hog\n    hogs                 hog\n    hogshead             hogshead\n    hogsheads            hogshead\n    hois                 hoi\n    hoise                hois\n    hoist                hoist\n    hoisted              hoist\n    hoists               hoist\n    holborn              holborn\n    hold                 hold\n    holden               holden\n    holder               holder\n    holdeth              holdeth\n    holdfast             holdfast\n    holding              hold\n    holds                hold\n    hole                 hole\n    holes                hole\n    holidam              holidam\n    holidame             holidam\n    holiday              holidai\n    holidays             holidai\n    holier               holier\n    holiest              holiest\n    holily               holili\n    holiness             holi\n    holla                holla\n    holland              holland\n    hollander            holland\n    hollanders           holland\n    holloa               holloa\n    holloaing            holloa\n    hollow               hollow\n    hollowly             hollowli\n    hollowness           hollow\n    holly                holli\n    holmedon             holmedon\n    holofernes           holofern\n    holp                 holp\n    holy                 holi\n    homage               homag\n    homager              homag\n    home                 home\n    homely               home\n    homes                home\n    homespuns            homespun\n    homeward             homeward\n    homewards            homeward\n    homicide             homicid\n    homicides            homicid\n    homily               homili\n    hominem              hominem\n    hommes               homm\n    homo                 homo\n    honest               honest\n    honester             honest\n    honestest            honestest\n    honestly             honestli\n    honesty              honesti\n    honey                honei\n    honeycomb            honeycomb\n    honeying             honei\n    honeyless            honeyless\n    honeysuckle          honeysuckl\n    honeysuckles         honeysuckl\n    honi                 honi\n    honneur              honneur\n    honor                honor\n    honorable            honor\n    honorably            honor\n    honorato             honorato\n    honors               honor\n    honour               honour\n    honourable           honour\n    honourably           honour\n    honoured             honour\n    honourest            honourest\n    honourible           honour\n    honouring            honour\n    honours              honour\n    hoo                  hoo\n    hood                 hood\n    hooded               hood\n    hoodman              hoodman\n    hoods                hood\n    hoodwink             hoodwink\n    hoof                 hoof\n    hoofs                hoof\n    hook                 hook\n    hooking              hook\n    hooks                hook\n    hoop                 hoop\n    hoops                hoop\n    hoot                 hoot\n    hooted               hoot\n    hooting              hoot\n    hoots                hoot\n    hop                  hop\n    hope                 hope\n    hopeful              hope\n    hopeless             hopeless\n    hopes                hope\n    hopest               hopest\n    hoping               hope\n    hopkins              hopkin\n    hoppedance           hopped\n    hor                  hor\n    horace               horac\n    horatio              horatio\n    horizon              horizon\n    horn                 horn\n    hornbook             hornbook\n    horned               horn\n    horner               horner\n    horning              horn\n    hornpipes            hornpip\n    horns                horn\n    horologe             horolog\n    horrible             horribl\n    horribly             horribl\n    horrid               horrid\n    horrider             horrid\n    horridly             horridli\n    horror               horror\n    horrors              horror\n    hors                 hor\n    horse                hors\n    horseback            horseback\n    horsed               hors\n    horsehairs           horsehair\n    horseman             horseman\n    horsemanship         horsemanship\n    horsemen             horsemen\n    horses               hors\n    horseway             horsewai\n    horsing              hors\n    hortensio            hortensio\n    hortensius           hortensiu\n    horum                horum\n    hose                 hose\n    hospitable           hospit\n    hospital             hospit\n    hospitality          hospit\n    host                 host\n    hostage              hostag\n    hostages             hostag\n    hostess              hostess\n    hostile              hostil\n    hostility            hostil\n    hostilius            hostiliu\n    hosts                host\n    hot                  hot\n    hotly                hotli\n    hotspur              hotspur\n    hotter               hotter\n    hottest              hottest\n    hound                hound\n    hounds               hound\n    hour                 hour\n    hourly               hourli\n    hours                hour\n    hous                 hou\n    house                hous\n    household            household\n    householder          household\n    householders         household\n    households           household\n    housekeeper          housekeep\n    housekeepers         housekeep\n    housekeeping         housekeep\n    houseless            houseless\n    houses               hous\n    housewife            housewif\n    housewifery          housewiferi\n    housewives           housew\n    hovel                hovel\n    hover                hover\n    hovered              hover\n    hovering             hover\n    hovers               hover\n    how                  how\n    howbeit              howbeit\n    howe                 how\n    howeer               howeer\n    however              howev\n    howl                 howl\n    howled               howl\n    howlet               howlet\n    howling              howl\n    howls                howl\n    howsoe               howso\n    howsoever            howsoev\n    howsome              howsom\n    hoxes                hox\n    hoy                  hoi\n    hoyday               hoydai\n    hubert               hubert\n    huddled              huddl\n    huddling             huddl\n    hue                  hue\n    hued                 hu\n    hues                 hue\n    hug                  hug\n    huge                 huge\n    hugely               huge\n    hugeness             huge\n    hugg                 hugg\n    hugger               hugger\n    hugh                 hugh\n    hugs                 hug\n    hujus                huju\n    hulk                 hulk\n    hulks                hulk\n    hull                 hull\n    hulling              hull\n    hullo                hullo\n    hum                  hum\n    human                human\n    humane               human\n    humanely             human\n    humanity             human\n    humble               humbl\n    humbled              humbl\n    humbleness           humbl\n    humbler              humbler\n    humbles              humbl\n    humblest             humblest\n    humbling             humbl\n    humbly               humbl\n    hume                 hume\n    humh                 humh\n    humidity             humid\n    humility             humil\n    humming              hum\n    humor                humor\n    humorous             humor\n    humors               humor\n    humour               humour\n    humourists           humourist\n    humours              humour\n    humphrey             humphrei\n    humphry              humphri\n    hums                 hum\n    hundred              hundr\n    hundreds             hundr\n    hundredth            hundredth\n    hung                 hung\n    hungarian            hungarian\n    hungary              hungari\n    hunger               hunger\n    hungerford           hungerford\n    hungerly             hungerli\n    hungry               hungri\n    hunt                 hunt\n    hunted               hunt\n    hunter               hunter\n    hunters              hunter\n    hunteth              hunteth\n    hunting              hunt\n    huntington           huntington\n    huntress             huntress\n    hunts                hunt\n    huntsman             huntsman\n    huntsmen             huntsmen\n    hurdle               hurdl\n    hurl                 hurl\n    hurling              hurl\n    hurls                hurl\n    hurly                hurli\n    hurlyburly           hurlyburli\n    hurricano            hurricano\n    hurricanoes          hurricano\n    hurried              hurri\n    hurries              hurri\n    hurry                hurri\n    hurt                 hurt\n    hurting              hurt\n    hurtled              hurtl\n    hurtless             hurtless\n    hurtling             hurtl\n    hurts                hurt\n    husband              husband\n    husbanded            husband\n    husbandless          husbandless\n    husbandry            husbandri\n    husbands             husband\n    hush                 hush\n    hushes               hush\n    husht                husht\n    husks                husk\n    huswife              huswif\n    huswifes             huswif\n    hutch                hutch\n    hybla                hybla\n    hydra                hydra\n    hyen                 hyen\n    hymen                hymen\n    hymenaeus            hymenaeu\n    hymn                 hymn\n    hymns                hymn\n    hyperboles           hyperbol\n    hyperbolical         hyperbol\n    hyperion             hyperion\n    hypocrisy            hypocrisi\n    hypocrite            hypocrit\n    hypocrites           hypocrit\n    hyrcan               hyrcan\n    hyrcania             hyrcania\n    hyrcanian            hyrcanian\n    hyssop               hyssop\n    hysterica            hysterica\n    i                    i\n    iachimo              iachimo\n    iaculis              iaculi\n    iago                 iago\n    iament               iament\n    ibat                 ibat\n    icarus               icaru\n    ice                  ic\n    iceland              iceland\n    ici                  ici\n    icicle               icicl\n    icicles              icicl\n    icy                  ici\n    idea                 idea\n    ideas                idea\n    idem                 idem\n    iden                 iden\n    ides                 id\n    idiot                idiot\n    idiots               idiot\n    idle                 idl\n    idleness             idl\n    idles                idl\n    idly                 idli\n    idol                 idol\n    idolatrous           idolatr\n    idolatry             idolatri\n    ield                 ield\n    if                   if\n    ifs                  if\n    ignis                igni\n    ignoble              ignobl\n    ignobly              ignobl\n    ignominious          ignomini\n    ignominy             ignomini\n    ignomy               ignomi\n    ignorance            ignor\n    ignorant             ignor\n    ii                   ii\n    iii                  iii\n    iiii                 iiii\n    il                   il\n    ilbow                ilbow\n    ild                  ild\n    ilion                ilion\n    ilium                ilium\n    ill                  ill\n    illegitimate         illegitim\n    illiterate           illiter\n    illness              ill\n    illo                 illo\n    ills                 ill\n    illume               illum\n    illumin              illumin\n    illuminate           illumin\n    illumineth           illumineth\n    illusion             illus\n    illusions            illus\n    illustrate           illustr\n    illustrated          illustr\n    illustrious          illustri\n    illyria              illyria\n    illyrian             illyrian\n    ils                  il\n    im                   im\n    image                imag\n    imagery              imageri\n    images               imag\n    imagin               imagin\n    imaginary            imaginari\n    imagination          imagin\n    imaginations         imagin\n    imagine              imagin\n    imagining            imagin\n    imaginings           imagin\n    imbar                imbar\n    imbecility           imbecil\n    imbrue               imbru\n    imitari              imitari\n    imitate              imit\n    imitated             imit\n    imitation            imit\n    imitations           imit\n    immaculate           immacul\n    immanity             imman\n    immask               immask\n    immaterial           immateri\n    immediacy            immediaci\n    immediate            immedi\n    immediately          immedi\n    imminence            immin\n    imminent             immin\n    immoderate           immoder\n    immoderately         immoder\n    immodest             immodest\n    immoment             immoment\n    immortal             immort\n    immortaliz           immortaliz\n    immortally           immort\n    immur                immur\n    immured              immur\n    immures              immur\n    imogen               imogen\n    imp                  imp\n    impaint              impaint\n    impair               impair\n    impairing            impair\n    impale               impal\n    impaled              impal\n    impanelled           impanel\n    impart               impart\n    imparted             impart\n    impartial            imparti\n    impartment           impart\n    imparts              impart\n    impasted             impast\n    impatience           impati\n    impatient            impati\n    impatiently          impati\n    impawn               impawn\n    impeach              impeach\n    impeached            impeach\n    impeachment          impeach\n    impeachments         impeach\n    impedes              imped\n    impediment           impedi\n    impediments          impedi\n    impenetrable         impenetr\n    imperator            imper\n    imperceiverant       imperceiver\n    imperfect            imperfect\n    imperfection         imperfect\n    imperfections        imperfect\n    imperfectly          imperfectli\n    imperial             imperi\n    imperious            imperi\n    imperiously          imperi\n    impertinency         impertin\n    impertinent          impertin\n    impeticos            impetico\n    impetuosity          impetuos\n    impetuous            impetu\n    impieties            impieti\n    impiety              impieti\n    impious              impiou\n    implacable           implac\n    implements           implement\n    implies              impli\n    implor               implor\n    implorators          implor\n    implore              implor\n    implored             implor\n    imploring            implor\n    impon                impon\n    import               import\n    importance           import\n    importancy           import\n    important            import\n    importantly          importantli\n    imported             import\n    importeth            importeth\n    importing            import\n    importless           importless\n    imports              import\n    importun             importun\n    importunacy          importunaci\n    importunate          importun\n    importune            importun\n    importunes           importun\n    importunity          importun\n    impos                impo\n    impose               impos\n    imposed              impos\n    imposition           imposit\n    impositions          imposit\n    impossibilities      imposs\n    impossibility        imposs\n    impossible           imposs\n    imposthume           imposthum\n    impostor             impostor\n    impostors            impostor\n    impotence            impot\n    impotent             impot\n    impounded            impound\n    impregnable          impregn\n    imprese              impres\n    impress              impress\n    impressed            impress\n    impressest           impressest\n    impression           impress\n    impressure           impressur\n    imprimendum          imprimendum\n    imprimis             imprimi\n    imprint              imprint\n    imprinted            imprint\n    imprison             imprison\n    imprisoned           imprison\n    imprisoning          imprison\n    imprisonment         imprison\n    improbable           improb\n    improper             improp\n    improve              improv\n    improvident          improvid\n    impudence            impud\n    impudency            impud\n    impudent             impud\n    impudently           impud\n    impudique            impudiqu\n    impugn               impugn\n    impugns              impugn\n    impure               impur\n    imputation           imput\n    impute               imput\n    in                   in\n    inaccessible         inaccess\n    inaidable            inaid\n    inaudible            inaud\n    inauspicious         inauspici\n    incaged              incag\n    incantations         incant\n    incapable            incap\n    incardinate          incardin\n    incarnadine          incarnadin\n    incarnate            incarn\n    incarnation          incarn\n    incens               incen\n    incense              incens\n    incensed             incens\n    incensement          incens\n    incenses             incens\n    incensing            incens\n    incertain            incertain\n    incertainties        incertainti\n    incertainty          incertainti\n    incessant            incess\n    incessantly          incessantli\n    incest               incest\n    incestuous           incestu\n    inch                 inch\n    incharitable         incharit\n    inches               inch\n    incidency            incid\n    incident             incid\n    incision             incis\n    incite               incit\n    incites              incit\n    incivil              incivil\n    incivility           incivil\n    inclin               inclin\n    inclinable           inclin\n    inclination          inclin\n    incline              inclin\n    inclined             inclin\n    inclines             inclin\n    inclining            inclin\n    inclips              inclip\n    include              includ\n    included             includ\n    includes             includ\n    inclusive            inclus\n    incomparable         incompar\n    incomprehensible     incomprehens\n    inconsiderate        inconsider\n    inconstancy          inconst\n    inconstant           inconst\n    incontinency         incontin\n    incontinent          incontin\n    incontinently        incontin\n    inconvenience        inconveni\n    inconveniences       inconveni\n    inconvenient         inconveni\n    incony               inconi\n    incorporate          incorpor\n    incorps              incorp\n    incorrect            incorrect\n    increas              increa\n    increase             increas\n    increases            increas\n    increaseth           increaseth\n    increasing           increas\n    incredible           incred\n    incredulous          incredul\n    incur                incur\n    incurable            incur\n    incurr               incurr\n    incurred             incur\n    incursions           incurs\n    ind                  ind\n    inde                 ind\n    indebted             indebt\n    indeed               inde\n    indent               indent\n    indented             indent\n    indenture            indentur\n    indentures           indentur\n    index                index\n    indexes              index\n    india                india\n    indian               indian\n    indict               indict\n    indicted             indict\n    indictment           indict\n    indies               indi\n    indifferency         indiffer\n    indifferent          indiffer\n    indifferently        indiffer\n    indigent             indig\n    indigest             indigest\n    indigested           indigest\n    indign               indign\n    indignation          indign\n    indignations         indign\n    indigne              indign\n    indignities          indign\n    indignity            indign\n    indirect             indirect\n    indirection          indirect\n    indirections         indirect\n    indirectly           indirectli\n    indiscreet           indiscreet\n    indiscretion         indiscret\n    indispos             indispo\n    indisposition        indisposit\n    indissoluble         indissolubl\n    indistinct           indistinct\n    indistinguish        indistinguish\n    indistinguishable    indistinguish\n    indited              indit\n    individable          individ\n    indrench             indrench\n    indu                 indu\n    indubitate           indubit\n    induc                induc\n    induce               induc\n    induced              induc\n    inducement           induc\n    induction            induct\n    inductions           induct\n    indue                indu\n    indued               indu\n    indues               indu\n    indulgence           indulg\n    indulgences          indulg\n    indulgent            indulg\n    indurance            indur\n    industrious          industri\n    industriously        industri\n    industry             industri\n    inequality           inequ\n    inestimable          inestim\n    inevitable           inevit\n    inexecrable          inexecr\n    inexorable           inexor\n    inexplicable         inexplic\n    infallible           infal\n    infallibly           infal\n    infamonize           infamon\n    infamous             infam\n    infamy               infami\n    infancy              infanc\n    infant               infant\n    infants              infant\n    infect               infect\n    infected             infect\n    infecting            infect\n    infection            infect\n    infections           infect\n    infectious           infecti\n    infectiously         infecti\n    infects              infect\n    infer                infer\n    inference            infer\n    inferior             inferior\n    inferiors            inferior\n    infernal             infern\n    inferr               inferr\n    inferreth            inferreth\n    inferring            infer\n    infest               infest\n    infidel              infidel\n    infidels             infidel\n    infinite             infinit\n    infinitely           infinit\n    infinitive           infinit\n    infirm               infirm\n    infirmities          infirm\n    infirmity            infirm\n    infixed              infix\n    infixing             infix\n    inflam               inflam\n    inflame              inflam\n    inflaming            inflam\n    inflammation         inflamm\n    inflict              inflict\n    infliction           inflict\n    influence            influenc\n    influences           influenc\n    infold               infold\n    inform               inform\n    informal             inform\n    information          inform\n    informations         inform\n    informed             inform\n    informer             inform\n    informs              inform\n    infortunate          infortun\n    infring              infr\n    infringe             infring\n    infringed            infring\n    infus                infu\n    infuse               infus\n    infused              infus\n    infusing             infus\n    infusion             infus\n    ingener              ingen\n    ingenious            ingeni\n    ingeniously          ingeni\n    inglorious           inglori\n    ingots               ingot\n    ingraffed            ingraf\n    ingraft              ingraft\n    ingrate              ingrat\n    ingrated             ingrat\n    ingrateful           ingrat\n    ingratitude          ingratitud\n    ingratitudes         ingratitud\n    ingredient           ingredi\n    ingredients          ingredi\n    ingross              ingross\n    inhabit              inhabit\n    inhabitable          inhabit\n    inhabitants          inhabit\n    inhabited            inhabit\n    inhabits             inhabit\n    inhearse             inhears\n    inhearsed            inhears\n    inherent             inher\n    inherit              inherit\n    inheritance          inherit\n    inherited            inherit\n    inheriting           inherit\n    inheritor            inheritor\n    inheritors           inheritor\n    inheritrix           inheritrix\n    inherits             inherit\n    inhibited            inhibit\n    inhibition           inhibit\n    inhoop               inhoop\n    inhuman              inhuman\n    iniquities           iniqu\n    iniquity             iniqu\n    initiate             initi\n    injointed            injoint\n    injunction           injunct\n    injunctions          injunct\n    injur                injur\n    injure               injur\n    injurer              injur\n    injuries             injuri\n    injurious            injuri\n    injury               injuri\n    injustice            injustic\n    ink                  ink\n    inkhorn              inkhorn\n    inkle                inkl\n    inkles               inkl\n    inkling              inkl\n    inky                 inki\n    inlaid               inlaid\n    inland               inland\n    inlay                inlai\n    inly                 inli\n    inmost               inmost\n    inn                  inn\n    inner                inner\n    innkeeper            innkeep\n    innocence            innoc\n    innocency            innoc\n    innocent             innoc\n    innocents            innoc\n    innovation           innov\n    innovator            innov\n    inns                 inn\n    innumerable          innumer\n    inoculate            inocul\n    inordinate           inordin\n    inprimis             inprimi\n    inquir               inquir\n    inquire              inquir\n    inquiry              inquiri\n    inquisition          inquisit\n    inquisitive          inquisit\n    inroads              inroad\n    insane               insan\n    insanie              insani\n    insatiate            insati\n    insconce             insconc\n    inscrib              inscrib\n    inscription          inscript\n    inscriptions         inscript\n    inscroll             inscrol\n    inscrutable          inscrut\n    insculp              insculp\n    insculpture          insculptur\n    insensible           insens\n    inseparable          insepar\n    inseparate           insepar\n    insert               insert\n    inserted             insert\n    inset                inset\n    inshell              inshel\n    inshipp              inshipp\n    inside               insid\n    insinewed            insinew\n    insinuate            insinu\n    insinuateth          insinuateth\n    insinuating          insinu\n    insinuation          insinu\n    insisted             insist\n    insisting            insist\n    insisture            insistur\n    insociable           insoci\n    insolence            insol\n    insolent             insol\n    insomuch             insomuch\n    inspir               inspir\n    inspiration          inspir\n    inspirations         inspir\n    inspire              inspir\n    inspired             inspir\n    install              instal\n    installed            instal\n    instalment           instal\n    instance             instanc\n    instances            instanc\n    instant              instant\n    instantly            instantli\n    instate              instat\n    instead              instead\n    insteeped            insteep\n    instigate            instig\n    instigated           instig\n    instigation          instig\n    instigations         instig\n    instigator           instig\n    instinct             instinct\n    instinctively        instinct\n    institute            institut\n    institutions         institut\n    instruct             instruct\n    instructed           instruct\n    instruction          instruct\n    instructions         instruct\n    instructs            instruct\n    instrument           instrument\n    instrumental         instrument\n    instruments          instrument\n    insubstantial        insubstanti\n    insufficience        insuffici\n    insufficiency        insuffici\n    insult               insult\n    insulted             insult\n    insulting            insult\n    insultment           insult\n    insults              insult\n    insupportable        insupport\n    insuppressive        insuppress\n    insurrection         insurrect\n    insurrections        insurrect\n    int                  int\n    integer              integ\n    integritas           integrita\n    integrity            integr\n    intellect            intellect\n    intellects           intellect\n    intellectual         intellectu\n    intelligence         intellig\n    intelligencer        intelligenc\n    intelligencing       intelligenc\n    intelligent          intellig\n    intelligis           intelligi\n    intelligo            intelligo\n    intemperance         intemper\n    intemperate          intemper\n    intend               intend\n    intended             intend\n    intendeth            intendeth\n    intending            intend\n    intendment           intend\n    intends              intend\n    intenible            inten\n    intent               intent\n    intention            intent\n    intentively          intent\n    intents              intent\n    inter                inter\n    intercept            intercept\n    intercepted          intercept\n    intercepter          intercept\n    interception         intercept\n    intercepts           intercept\n    intercession         intercess\n    intercessors         intercessor\n    interchained         interchain\n    interchang           interchang\n    interchange          interchang\n    interchangeably      interchang\n    interchangement      interchang\n    interchanging        interchang\n    interdiction         interdict\n    interest             interest\n    interim              interim\n    interims             interim\n    interior             interior\n    interjections        interject\n    interjoin            interjoin\n    interlude            interlud\n    intermingle          intermingl\n    intermission         intermiss\n    intermissive         intermiss\n    intermit             intermit\n    intermix             intermix\n    intermixed           intermix\n    interpose            interpos\n    interposer           interpos\n    interposes           interpos\n    interpret            interpret\n    interpretation       interpret\n    interpreted          interpret\n    interpreter          interpret\n    interpreters         interpret\n    interprets           interpret\n    interr               interr\n    interred             inter\n    interrogatories      interrogatori\n    interrupt            interrupt\n    interrupted          interrupt\n    interrupter          interrupt\n    interruptest         interruptest\n    interruption         interrupt\n    interrupts           interrupt\n    intertissued         intertissu\n    intervallums         intervallum\n    interview            interview\n    intestate            intest\n    intestine            intestin\n    intil                intil\n    intimate             intim\n    intimation           intim\n    intitled             intitl\n    intituled            intitul\n    into                 into\n    intolerable          intoler\n    intoxicates          intox\n    intreasured          intreasur\n    intreat              intreat\n    intrench             intrench\n    intrenchant          intrench\n    intricate            intric\n    intrinse             intrins\n    intrinsicate         intrins\n    intrude              intrud\n    intruder             intrud\n    intruding            intrud\n    intrusion            intrus\n    inundation           inund\n    inure                inur\n    inurn                inurn\n    invade               invad\n    invades              invad\n    invasion             invas\n    invasive             invas\n    invectively          invect\n    invectives           invect\n    inveigled            inveigl\n    invent               invent\n    invented             invent\n    invention            invent\n    inventions           invent\n    inventor             inventor\n    inventorially        inventori\n    inventoried          inventori\n    inventors            inventor\n    inventory            inventori\n    inverness            inver\n    invert               invert\n    invest               invest\n    invested             invest\n    investing            invest\n    investments          invest\n    inveterate           inveter\n    invincible           invinc\n    inviolable           inviol\n    invised              invis\n    invisible            invis\n    invitation           invit\n    invite               invit\n    invited              invit\n    invites              invit\n    inviting             invit\n    invitis              inviti\n    invocate             invoc\n    invocation           invoc\n    invoke               invok\n    invoked              invok\n    invulnerable         invulner\n    inward               inward\n    inwardly             inwardli\n    inwardness           inward\n    inwards              inward\n    ionia                ionia\n    ionian               ionian\n    ipse                 ips\n    ipswich              ipswich\n    ira                  ira\n    irae                 ira\n    iras                 ira\n    ire                  ir\n    ireful               ir\n    ireland              ireland\n    iris                 iri\n    irish                irish\n    irishman             irishman\n    irishmen             irishmen\n    irks                 irk\n    irksome              irksom\n    iron                 iron\n    irons                iron\n    irreconcil           irreconcil\n    irrecoverable        irrecover\n    irregular            irregular\n    irregulous           irregul\n    irreligious          irreligi\n    irremovable          irremov\n    irreparable          irrepar\n    irresolute           irresolut\n    irrevocable          irrevoc\n    is                   is\n    isabel               isabel\n    isabella             isabella\n    isbel                isbel\n    isbels               isbel\n    iscariot             iscariot\n    ise                  is\n    ish                  ish\n    isidore              isidor\n    isis                 isi\n    island               island\n    islander             island\n    islanders            island\n    islands              island\n    isle                 isl\n    isles                isl\n    israel               israel\n    issu                 issu\n    issue                issu\n    issued               issu\n    issueless            issueless\n    issues               issu\n    issuing              issu\n    ist                  ist\n    ista                 ista\n    it                   it\n    italian              italian\n    italy                itali\n    itch                 itch\n    itches               itch\n    itching              itch\n    item                 item\n    items                item\n    iteration            iter\n    ithaca               ithaca\n    its                  it\n    itself               itself\n    itshall              itshal\n    iv                   iv\n    ivory                ivori\n    ivy                  ivi\n    iwis                 iwi\n    ix                   ix\n    j                    j\n    jacet                jacet\n    jack                 jack\n    jackanapes           jackanap\n    jacks                jack\n    jacksauce            jacksauc\n    jackslave            jackslav\n    jacob                jacob\n    jade                 jade\n    jaded                jade\n    jades                jade\n    jail                 jail\n    jakes                jake\n    jamany               jamani\n    james                jame\n    jamy                 jami\n    jane                 jane\n    jangled              jangl\n    jangling             jangl\n    january              januari\n    janus                janu\n    japhet               japhet\n    jaquenetta           jaquenetta\n    jaques               jaqu\n    jar                  jar\n    jarring              jar\n    jars                 jar\n    jarteer              jarteer\n    jasons               jason\n    jaunce               jaunc\n    jauncing             jaunc\n    jaundice             jaundic\n    jaundies             jaundi\n    jaw                  jaw\n    jawbone              jawbon\n    jaws                 jaw\n    jay                  jai\n    jays                 jai\n    jc                   jc\n    je                   je\n    jealous              jealou\n    jealousies           jealousi\n    jealousy             jealousi\n    jeer                 jeer\n    jeering              jeer\n    jelly                jelli\n    jenny                jenni\n    jeopardy             jeopardi\n    jephtha              jephtha\n    jephthah             jephthah\n    jerkin               jerkin\n    jerkins              jerkin\n    jerks                jerk\n    jeronimy             jeronimi\n    jerusalem            jerusalem\n    jeshu                jeshu\n    jesses               jess\n    jessica              jessica\n    jest                 jest\n    jested               jest\n    jester               jester\n    jesters              jester\n    jesting              jest\n    jests                jest\n    jesu                 jesu\n    jesus                jesu\n    jet                  jet\n    jets                 jet\n    jew                  jew\n    jewel                jewel\n    jeweller             jewel\n    jewels               jewel\n    jewess               jewess\n    jewish               jewish\n    jewry                jewri\n    jews                 jew\n    jezebel              jezebel\n    jig                  jig\n    jigging              jig\n    jill                 jill\n    jills                jill\n    jingling             jingl\n    joan                 joan\n    job                  job\n    jockey               jockei\n    jocund               jocund\n    jog                  jog\n    jogging              jog\n    john                 john\n    johns                john\n    join                 join\n    joinder              joinder\n    joined               join\n    joiner               joiner\n    joineth              joineth\n    joins                join\n    joint                joint\n    jointed              joint\n    jointing             joint\n    jointly              jointli\n    jointress            jointress\n    joints               joint\n    jointure             jointur\n    jollity              jolliti\n    jolly                jolli\n    jolt                 jolt\n    joltheads            jolthead\n    jordan               jordan\n    joseph               joseph\n    joshua               joshua\n    jot                  jot\n    jour                 jour\n    jourdain             jourdain\n    journal              journal\n    journey              journei\n    journeying           journei\n    journeyman           journeyman\n    journeymen           journeymen\n    journeys             journei\n    jove                 jove\n    jovem                jovem\n    jovial               jovial\n    jowl                 jowl\n    jowls                jowl\n    joy                  joi\n    joyed                joi\n    joyful               joy\n    joyfully             joyfulli\n    joyless              joyless\n    joyous               joyou\n    joys                 joi\n    juan                 juan\n    jud                  jud\n    judas                juda\n    judases              judas\n    jude                 jude\n    judg                 judg\n    judge                judg\n    judged               judg\n    judgement            judgement\n    judges               judg\n    judgest              judgest\n    judging              judg\n    judgment             judgment\n    judgments            judgment\n    judicious            judici\n    jug                  jug\n    juggle               juggl\n    juggled              juggl\n    juggler              juggler\n    jugglers             juggler\n    juggling             juggl\n    jugs                 jug\n    juice                juic\n    juiced               juic\n    jul                  jul\n    jule                 jule\n    julia                julia\n    juliet               juliet\n    julietta             julietta\n    julio                julio\n    julius               juliu\n    july                 juli\n    jump                 jump\n    jumpeth              jumpeth\n    jumping              jump\n    jumps                jump\n    june                 june\n    junes                june\n    junior               junior\n    junius               juniu\n    junkets              junket\n    juno                 juno\n    jupiter              jupit\n    jure                 jure\n    jurement             jurement\n    jurisdiction         jurisdict\n    juror                juror\n    jurors               juror\n    jury                 juri\n    jurymen              jurymen\n    just                 just\n    justeius             justeiu\n    justest              justest\n    justice              justic\n    justicer             justic\n    justicers            justic\n    justices             justic\n    justification        justif\n    justified            justifi\n    justify              justifi\n    justle               justl\n    justled              justl\n    justles              justl\n    justling             justl\n    justly               justli\n    justness             just\n    justs                just\n    jutting              jut\n    jutty                jutti\n    juvenal              juven\n    kam                  kam\n    kate                 kate\n    kated                kate\n    kates                kate\n    katharine            katharin\n    katherina            katherina\n    katherine            katherin\n    kecksies             kecksi\n    keech                keech\n    keel                 keel\n    keels                keel\n    keen                 keen\n    keenness             keen\n    keep                 keep\n    keepdown             keepdown\n    keeper               keeper\n    keepers              keeper\n    keepest              keepest\n    keeping              keep\n    keeps                keep\n    keiser               keiser\n    ken                  ken\n    kendal               kendal\n    kennel               kennel\n    kent                 kent\n    kentish              kentish\n    kentishman           kentishman\n    kentishmen           kentishmen\n    kept                 kept\n    kerchief             kerchief\n    kerely               kere\n    kern                 kern\n    kernal               kernal\n    kernel               kernel\n    kernels              kernel\n    kerns                kern\n    kersey               kersei\n    kettle               kettl\n    kettledrum           kettledrum\n    kettledrums          kettledrum\n    key                  kei\n    keys                 kei\n    kibe                 kibe\n    kibes                kibe\n    kick                 kick\n    kicked               kick\n    kickshaws            kickshaw\n    kickshawses          kickshaws\n    kicky                kicki\n    kid                  kid\n    kidney               kidnei\n    kikely               kike\n    kildare              kildar\n    kill                 kill\n    killed               kill\n    killer               killer\n    killeth              killeth\n    killing              kill\n    killingworth         killingworth\n    kills                kill\n    kiln                 kiln\n    kimbolton            kimbolton\n    kin                  kin\n    kind                 kind\n    kinder               kinder\n    kindest              kindest\n    kindle               kindl\n    kindled              kindl\n    kindless             kindless\n    kindlier             kindlier\n    kindling             kindl\n    kindly               kindli\n    kindness             kind\n    kindnesses           kind\n    kindred              kindr\n    kindreds             kindr\n    kinds                kind\n    kine                 kine\n    king                 king\n    kingdom              kingdom\n    kingdoms             kingdom\n    kingly               kingli\n    kings                king\n    kinred               kinr\n    kins                 kin\n    kinsman              kinsman\n    kinsmen              kinsmen\n    kinswoman            kinswoman\n    kirtle               kirtl\n    kirtles              kirtl\n    kiss                 kiss\n    kissed               kiss\n    kisses               kiss\n    kissing              kiss\n    kitchen              kitchen\n    kitchens             kitchen\n    kite                 kite\n    kites                kite\n    kitten               kitten\n    kj                   kj\n    kl                   kl\n    klll                 klll\n    knack                knack\n    knacks               knack\n    knapp                knapp\n    knav                 knav\n    knave                knave\n    knaveries            knaveri\n    knavery              knaveri\n    knaves               knave\n    knavish              knavish\n    knead                knead\n    kneaded              knead\n    kneading             knead\n    knee                 knee\n    kneel                kneel\n    kneeling             kneel\n    kneels               kneel\n    knees                knee\n    knell                knell\n    knew                 knew\n    knewest              knewest\n    knife                knife\n    knight               knight\n    knighted             knight\n    knighthood           knighthood\n    knighthoods          knighthood\n    knightly             knightli\n    knights              knight\n    knit                 knit\n    knits                knit\n    knitters             knitter\n    knitteth             knitteth\n    knives               knive\n    knobs                knob\n    knock                knock\n    knocking             knock\n    knocks               knock\n    knog                 knog\n    knoll                knoll\n    knot                 knot\n    knots                knot\n    knotted              knot\n    knotty               knotti\n    know                 know\n    knower               knower\n    knowest              knowest\n    knowing              know\n    knowingly            knowingli\n    knowings             know\n    knowledge            knowledg\n    known                known\n    knows                know\n    l                    l\n    la                   la\n    laban                laban\n    label                label\n    labell               label\n    labienus             labienu\n    labio                labio\n    labor                labor\n    laboring             labor\n    labors               labor\n    labour               labour\n    laboured             labour\n    labourer             labour\n    labourers            labour\n    labouring            labour\n    labours              labour\n    laboursome           laboursom\n    labras               labra\n    labyrinth            labyrinth\n    lac                  lac\n    lace                 lace\n    laced                lace\n    lacedaemon           lacedaemon\n    laces                lace\n    lacies               laci\n    lack                 lack\n    lackbeard            lackbeard\n    lacked               lack\n    lackey               lackei\n    lackeying            lackei\n    lackeys              lackei\n    lacking              lack\n    lacks                lack\n    lad                  lad\n    ladder               ladder\n    ladders              ladder\n    lade                 lade\n    laden                laden\n    ladies               ladi\n    lading               lade\n    lads                 lad\n    lady                 ladi\n    ladybird             ladybird\n    ladyship             ladyship\n    ladyships            ladyship\n    laer                 laer\n    laertes              laert\n    lafeu                lafeu\n    lag                  lag\n    lagging              lag\n    laid                 laid\n    lain                 lain\n    laissez              laissez\n    lake                 lake\n    lakes                lake\n    lakin                lakin\n    lam                  lam\n    lamb                 lamb\n    lambert              lambert\n    lambkin              lambkin\n    lambkins             lambkin\n    lambs                lamb\n    lame                 lame\n    lamely               lame\n    lameness             lame\n    lament               lament\n    lamentable           lament\n    lamentably           lament\n    lamentation          lament\n    lamentations         lament\n    lamented             lament\n    lamenting            lament\n    lamentings           lament\n    laments              lament\n    lames                lame\n    laming               lame\n    lammas               lamma\n    lammastide           lammastid\n    lamound              lamound\n    lamp                 lamp\n    lampass              lampass\n    lamps                lamp\n    lanc                 lanc\n    lancaster            lancast\n    lance                lanc\n    lances               lanc\n    lanceth              lanceth\n    lanch                lanch\n    land                 land\n    landed               land\n    landing              land\n    landless             landless\n    landlord             landlord\n    landmen              landmen\n    lands                land\n    lane                 lane\n    lanes                lane\n    langage              langag\n    langley              langlei\n    langton              langton\n    language             languag\n    languageless         languageless\n    languages            languag\n    langues              langu\n    languish             languish\n    languished           languish\n    languishes           languish\n    languishing          languish\n    languishings         languish\n    languishment         languish\n    languor              languor\n    lank                 lank\n    lantern              lantern\n    lanterns             lantern\n    lanthorn             lanthorn\n    lap                  lap\n    lapis                lapi\n    lapland              lapland\n    lapp                 lapp\n    laps                 lap\n    lapse                laps\n    lapsed               laps\n    lapsing              laps\n    lapwing              lapw\n    laquais              laquai\n    larded               lard\n    larder               larder\n    larding              lard\n    lards                lard\n    large                larg\n    largely              larg\n    largeness            larg\n    larger               larger\n    largess              largess\n    largest              largest\n    lark                 lark\n    larks                lark\n    larron               larron\n    lartius              lartiu\n    larum                larum\n    larums               larum\n    las                  la\n    lascivious           lascivi\n    lash                 lash\n    lass                 lass\n    lasses               lass\n    last                 last\n    lasted               last\n    lasting              last\n    lastly               lastli\n    lasts                last\n    latch                latch\n    latches              latch\n    late                 late\n    lated                late\n    lately               late\n    later                later\n    latest               latest\n    lath                 lath\n    latin                latin\n    latten               latten\n    latter               latter\n    lattice              lattic\n    laud                 laud\n    laudable             laudabl\n    laudis               laudi\n    laugh                laugh\n    laughable            laughabl\n    laughed              laugh\n    laugher              laugher\n    laughest             laughest\n    laughing             laugh\n    laughs               laugh\n    laughter             laughter\n    launce               launc\n    launcelot            launcelot\n    launces              launc\n    launch               launch\n    laund                laund\n    laundress            laundress\n    laundry              laundri\n    laur                 laur\n    laura                laura\n    laurel               laurel\n    laurels              laurel\n    laurence             laurenc\n    laus                 lau\n    lavache              lavach\n    lave                 lave\n    lavee                lave\n    lavender             lavend\n    lavina               lavina\n    lavinia              lavinia\n    lavish               lavish\n    lavishly             lavishli\n    lavolt               lavolt\n    lavoltas             lavolta\n    law                  law\n    lawful               law\n    lawfully             lawfulli\n    lawless              lawless\n    lawlessly            lawlessli\n    lawn                 lawn\n    lawns                lawn\n    lawrence             lawrenc\n    laws                 law\n    lawyer               lawyer\n    lawyers              lawyer\n    lay                  lai\n    layer                layer\n    layest               layest\n    laying               lai\n    lays                 lai\n    lazar                lazar\n    lazars               lazar\n    lazarus              lazaru\n    lazy                 lazi\n    lc                   lc\n    ld                   ld\n    ldst                 ldst\n    le                   le\n    lead                 lead\n    leaden               leaden\n    leader               leader\n    leaders              leader\n    leadest              leadest\n    leading              lead\n    leads                lead\n    leaf                 leaf\n    leagu                leagu\n    league               leagu\n    leagued              leagu\n    leaguer              leaguer\n    leagues              leagu\n    leah                 leah\n    leak                 leak\n    leaky                leaki\n    lean                 lean\n    leander              leander\n    leaner               leaner\n    leaning              lean\n    leanness             lean\n    leans                lean\n    leap                 leap\n    leaped               leap\n    leaping              leap\n    leaps                leap\n    leapt                leapt\n    lear                 lear\n    learn                learn\n    learned              learn\n    learnedly            learnedli\n    learning             learn\n    learnings            learn\n    learns               learn\n    learnt               learnt\n    leas                 lea\n    lease                leas\n    leases               leas\n    leash                leash\n    leasing              leas\n    least                least\n    leather              leather\n    leathern             leathern\n    leav                 leav\n    leave                leav\n    leaven               leaven\n    leavening            leaven\n    leaver               leaver\n    leaves               leav\n    leaving              leav\n    leavy                leavi\n    lecher               lecher\n    lecherous            lecher\n    lechers              lecher\n    lechery              lecheri\n    lecon                lecon\n    lecture              lectur\n    lectures             lectur\n    led                  led\n    leda                 leda\n    leech                leech\n    leeches              leech\n    leek                 leek\n    leeks                leek\n    leer                 leer\n    leers                leer\n    lees                 lee\n    leese                lees\n    leet                 leet\n    leets                leet\n    left                 left\n    leg                  leg\n    legacies             legaci\n    legacy               legaci\n    legate               legat\n    legatine             legatin\n    lege                 lege\n    legerity             leger\n    leges                lege\n    legg                 legg\n    legion               legion\n    legions              legion\n    legitimate           legitim\n    legitimation         legitim\n    legs                 leg\n    leicester            leicest\n    leicestershire       leicestershir\n    leiger               leiger\n    leigers              leiger\n    leisure              leisur\n    leisurely            leisur\n    leisures             leisur\n    leman                leman\n    lemon                lemon\n    lena                 lena\n    lend                 lend\n    lender               lender\n    lending              lend\n    lendings             lend\n    lends                lend\n    length               length\n    lengthen             lengthen\n    lengthens            lengthen\n    lengths              length\n    lenity               leniti\n    lennox               lennox\n    lent                 lent\n    lenten               lenten\n    lentus               lentu\n    leo                  leo\n    leon                 leon\n    leonardo             leonardo\n    leonati              leonati\n    leonato              leonato\n    leonatus             leonatu\n    leontes              leont\n    leopard              leopard\n    leopards             leopard\n    leper                leper\n    leperous             leper\n    lepidus              lepidu\n    leprosy              leprosi\n    lequel               lequel\n    lers                 ler\n    les                  le\n    less                 less\n    lessen               lessen\n    lessens              lessen\n    lesser               lesser\n    lesson               lesson\n    lessoned             lesson\n    lessons              lesson\n    lest                 lest\n    lestrake             lestrak\n    let                  let\n    lethargied           lethargi\n    lethargies           lethargi\n    lethargy             lethargi\n    lethe                leth\n    lets                 let\n    lett                 lett\n    letter               letter\n    letters              letter\n    letting              let\n    lettuce              lettuc\n    leur                 leur\n    leve                 leve\n    level                level\n    levell               level\n    levelled             level\n    levels               level\n    leven                leven\n    levers               lever\n    leviathan            leviathan\n    leviathans           leviathan\n    levied               levi\n    levies               levi\n    levity               leviti\n    levy                 levi\n    levying              levi\n    lewd                 lewd\n    lewdly               lewdli\n    lewdness             lewd\n    lewdsters            lewdster\n    lewis                lewi\n    liable               liabl\n    liar                 liar\n    liars                liar\n    libbard              libbard\n    libelling            libel\n    libels               libel\n    liberal              liber\n    liberality           liber\n    liberte              libert\n    liberties            liberti\n    libertine            libertin\n    libertines           libertin\n    liberty              liberti\n    library              librari\n    libya                libya\n    licence              licenc\n    licens               licen\n    license              licens\n    licentious           licenti\n    lichas               licha\n    licio                licio\n    lick                 lick\n    licked               lick\n    licker               licker\n    lictors              lictor\n    lid                  lid\n    lids                 lid\n    lie                  lie\n    lied                 li\n    lief                 lief\n    liefest              liefest\n    liege                lieg\n    liegeman             liegeman\n    liegemen             liegemen\n    lien                 lien\n    lies                 li\n    liest                liest\n    lieth                lieth\n    lieu                 lieu\n    lieutenant           lieuten\n    lieutenantry         lieutenantri\n    lieutenants          lieuten\n    lieve                liev\n    life                 life\n    lifeblood            lifeblood\n    lifeless             lifeless\n    lifelings            lifel\n    lift                 lift\n    lifted               lift\n    lifter               lifter\n    lifteth              lifteth\n    lifting              lift\n    lifts                lift\n    lig                  lig\n    ligarius             ligariu\n    liggens              liggen\n    light                light\n    lighted              light\n    lighten              lighten\n    lightens             lighten\n    lighter              lighter\n    lightest             lightest\n    lightly              lightli\n    lightness            light\n    lightning            lightn\n    lightnings           lightn\n    lights               light\n    lik                  lik\n    like                 like\n    liked                like\n    likeliest            likeliest\n    likelihood           likelihood\n    likelihoods          likelihood\n    likely               like\n    likeness             like\n    liker                liker\n    likes                like\n    likest               likest\n    likewise             likewis\n    liking               like\n    likings              like\n    lilies               lili\n    lily                 lili\n    lim                  lim\n    limander             limand\n    limb                 limb\n    limbeck              limbeck\n    limbecks             limbeck\n    limber               limber\n    limbo                limbo\n    limbs                limb\n    lime                 lime\n    limed                lime\n    limehouse            limehous\n    limekilns            limekiln\n    limit                limit\n    limitation           limit\n    limited              limit\n    limits               limit\n    limn                 limn\n    limp                 limp\n    limping              limp\n    limps                limp\n    lin                  lin\n    lincoln              lincoln\n    lincolnshire         lincolnshir\n    line                 line\n    lineal               lineal\n    lineally             lineal\n    lineament            lineament\n    lineaments           lineament\n    lined                line\n    linen                linen\n    linens               linen\n    lines                line\n    ling                 ling\n    lingare              lingar\n    linger               linger\n    lingered             linger\n    lingers              linger\n    linguist             linguist\n    lining               line\n    link                 link\n    links                link\n    linsey               linsei\n    linstock             linstock\n    linta                linta\n    lion                 lion\n    lionel               lionel\n    lioness              lioness\n    lions                lion\n    lip                  lip\n    lipp                 lipp\n    lips                 lip\n    lipsbury             lipsburi\n    liquid               liquid\n    liquor               liquor\n    liquorish            liquorish\n    liquors              liquor\n    lirra                lirra\n    lisbon               lisbon\n    lisp                 lisp\n    lisping              lisp\n    list                 list\n    listen               listen\n    listening            listen\n    lists                list\n    literatured          literatur\n    lither               lither\n    litter               litter\n    little               littl\n    littlest             littlest\n    liv                  liv\n    live                 live\n    lived                live\n    livelier             liveli\n    livelihood           livelihood\n    livelong             livelong\n    lively               live\n    liver                liver\n    liveries             liveri\n    livers               liver\n    livery               liveri\n    lives                live\n    livest               livest\n    liveth               liveth\n    livia                livia\n    living               live\n    livings              live\n    lizard               lizard\n    lizards              lizard\n    ll                   ll\n    lll                  lll\n    llous                llou\n    lnd                  lnd\n    lo                   lo\n    loa                  loa\n    loach                loach\n    load                 load\n    loaden               loaden\n    loading              load\n    loads                load\n    loaf                 loaf\n    loam                 loam\n    loan                 loan\n    loath                loath\n    loathe               loath\n    loathed              loath\n    loather              loather\n    loathes              loath\n    loathing             loath\n    loathly              loathli\n    loathness            loath\n    loathsome            loathsom\n    loathsomeness        loathsom\n    loathsomest          loathsomest\n    loaves               loav\n    lob                  lob\n    lobbies              lobbi\n    lobby                lobbi\n    local                local\n    lochaber             lochab\n    lock                 lock\n    locked               lock\n    locking              lock\n    lockram              lockram\n    locks                lock\n    locusts              locust\n    lode                 lode\n    lodg                 lodg\n    lodge                lodg\n    lodged               lodg\n    lodgers              lodger\n    lodges               lodg\n    lodging              lodg\n    lodgings             lodg\n    lodovico             lodovico\n    lodowick             lodowick\n    lofty                lofti\n    log                  log\n    logger               logger\n    loggerhead           loggerhead\n    loggerheads          loggerhead\n    loggets              logget\n    logic                logic\n    logs                 log\n    loins                loin\n    loiter               loiter\n    loiterer             loiter\n    loiterers            loiter\n    loitering            loiter\n    lolling              loll\n    lolls                loll\n    lombardy             lombardi\n    london               london\n    londoners            london\n    lone                 lone\n    loneliness           loneli\n    lonely               lone\n    long                 long\n    longaville           longavil\n    longboat             longboat\n    longed               long\n    longer               longer\n    longest              longest\n    longeth              longeth\n    longing              long\n    longings             long\n    longly               longli\n    longs                long\n    longtail             longtail\n    loo                  loo\n    loof                 loof\n    look                 look\n    looked               look\n    looker               looker\n    lookers              looker\n    lookest              lookest\n    looking              look\n    looks                look\n    loon                 loon\n    loop                 loop\n    loos                 loo\n    loose                loos\n    loosed               loos\n    loosely              loos\n    loosen               loosen\n    loosing              loos\n    lop                  lop\n    lopp                 lopp\n    loquitur             loquitur\n    lord                 lord\n    lorded               lord\n    lording              lord\n    lordings             lord\n    lordliness           lordli\n    lordly               lordli\n    lords                lord\n    lordship             lordship\n    lordships            lordship\n    lorenzo              lorenzo\n    lorn                 lorn\n    lorraine             lorrain\n    lorship              lorship\n    los                  lo\n    lose                 lose\n    loser                loser\n    losers               loser\n    loses                lose\n    losest               losest\n    loseth               loseth\n    losing               lose\n    loss                 loss\n    losses               loss\n    lost                 lost\n    lot                  lot\n    lots                 lot\n    lott                 lott\n    lottery              lotteri\n    loud                 loud\n    louder               louder\n    loudly               loudli\n    lour                 lour\n    loureth              loureth\n    louring              lour\n    louse                lous\n    louses               lous\n    lousy                lousi\n    lout                 lout\n    louted               lout\n    louts                lout\n    louvre               louvr\n    lov                  lov\n    love                 love\n    loved                love\n    lovedst              lovedst\n    lovel                lovel\n    lovelier             loveli\n    loveliness           loveli\n    lovell               lovel\n    lovely               love\n    lover                lover\n    lovered              lover\n    lovers               lover\n    loves                love\n    lovest               lovest\n    loveth               loveth\n    loving               love\n    lovingly             lovingli\n    low                  low\n    lowe                 low\n    lower                lower\n    lowest               lowest\n    lowing               low\n    lowliness            lowli\n    lowly                lowli\n    lown                 lown\n    lowness              low\n    loyal                loyal\n    loyally              loyal\n    loyalties            loyalti\n    loyalty              loyalti\n    lozel                lozel\n    lt                   lt\n    lubber               lubber\n    lubberly             lubberli\n    luc                  luc\n    luccicos             luccico\n    luce                 luce\n    lucentio             lucentio\n    luces                luce\n    lucetta              lucetta\n    luciana              luciana\n    lucianus             lucianu\n    lucifer              lucif\n    lucifier             lucifi\n    lucilius             luciliu\n    lucina               lucina\n    lucio                lucio\n    lucius               luciu\n    luck                 luck\n    luckier              luckier\n    luckiest             luckiest\n    luckily              luckili\n    luckless             luckless\n    lucky                lucki\n    lucre                lucr\n    lucrece              lucrec\n    lucretia             lucretia\n    lucullius            luculliu\n    lucullus             lucullu\n    lucy                 luci\n    lud                  lud\n    ludlow               ludlow\n    lug                  lug\n    lugg                 lugg\n    luggage              luggag\n    luke                 luke\n    lukewarm             lukewarm\n    lull                 lull\n    lulla                lulla\n    lullaby              lullabi\n    lulls                lull\n    lumbert              lumbert\n    lump                 lump\n    lumpish              lumpish\n    luna                 luna\n    lunacies             lunaci\n    lunacy               lunaci\n    lunatic              lunat\n    lunatics             lunat\n    lunes                lune\n    lungs                lung\n    lupercal             luperc\n    lurch                lurch\n    lure                 lure\n    lurk                 lurk\n    lurketh              lurketh\n    lurking              lurk\n    lurks                lurk\n    luscious             lusciou\n    lush                 lush\n    lust                 lust\n    lusted               lust\n    luster               luster\n    lustful              lust\n    lustier              lustier\n    lustiest             lustiest\n    lustig               lustig\n    lustihood            lustihood\n    lustily              lustili\n    lustre               lustr\n    lustrous             lustrou\n    lusts                lust\n    lusty                lusti\n    lute                 lute\n    lutes                lute\n    lutestring           lutestr\n    lutheran             lutheran\n    luxurious            luxuri\n    luxuriously          luxuri\n    luxury               luxuri\n    ly                   ly\n    lycaonia             lycaonia\n    lycurguses           lycurgus\n    lydia                lydia\n    lye                  lye\n    lyen                 lyen\n    lying                ly\n    lym                  lym\n    lymoges              lymog\n    lynn                 lynn\n    lysander             lysand\n    m                    m\n    ma                   ma\n    maan                 maan\n    mab                  mab\n    macbeth              macbeth\n    maccabaeus           maccabaeu\n    macdonwald           macdonwald\n    macduff              macduff\n    mace                 mace\n    macedon              macedon\n    maces                mace\n    machiavel            machiavel\n    machination          machin\n    machinations         machin\n    machine              machin\n    mack                 mack\n    macmorris            macmorri\n    maculate             macul\n    maculation           macul\n    mad                  mad\n    madam                madam\n    madame               madam\n    madams               madam\n    madcap               madcap\n    madded               mad\n    madding              mad\n    made                 made\n    madeira              madeira\n    madly                madli\n    madman               madman\n    madmen               madmen\n    madness              mad\n    madonna              madonna\n    madrigals            madrig\n    mads                 mad\n    maecenas             maecena\n    maggot               maggot\n    maggots              maggot\n    magic                magic\n    magical              magic\n    magician             magician\n    magistrate           magistr\n    magistrates          magistr\n    magnanimity          magnanim\n    magnanimous          magnanim\n    magni                magni\n    magnifi              magnifi\n    magnificence         magnific\n    magnificent          magnific\n    magnifico            magnifico\n    magnificoes          magnifico\n    magnus               magnu\n    mahomet              mahomet\n    mahu                 mahu\n    maid                 maid\n    maiden               maiden\n    maidenhead           maidenhead\n    maidenheads          maidenhead\n    maidenhood           maidenhood\n    maidenhoods          maidenhood\n    maidenliest          maidenliest\n    maidenly             maidenli\n    maidens              maiden\n    maidhood             maidhood\n    maids                maid\n    mail                 mail\n    mailed               mail\n    mails                mail\n    maim                 maim\n    maimed               maim\n    maims                maim\n    main                 main\n    maincourse           maincours\n    maine                main\n    mainly               mainli\n    mainmast             mainmast\n    mains                main\n    maintain             maintain\n    maintained           maintain\n    maintains            maintain\n    maintenance          mainten\n    mais                 mai\n    maison               maison\n    majestas             majesta\n    majestee             majeste\n    majestic             majest\n    majestical           majest\n    majestically         majest\n    majesties            majesti\n    majesty              majesti\n    major                major\n    majority             major\n    mak                  mak\n    make                 make\n    makeless             makeless\n    maker                maker\n    makers               maker\n    makes                make\n    makest               makest\n    maketh               maketh\n    making               make\n    makings              make\n    mal                  mal\n    mala                 mala\n    maladies             maladi\n    malady               maladi\n    malapert             malapert\n    malcolm              malcolm\n    malcontent           malcont\n    malcontents          malcont\n    male                 male\n    maledictions         maledict\n    malefactions         malefact\n    malefactor           malefactor\n    malefactors          malefactor\n    males                male\n    malevolence          malevol\n    malevolent           malevol\n    malhecho             malhecho\n    malice               malic\n    malicious            malici\n    maliciously          malici\n    malign               malign\n    malignancy           malign\n    malignant            malign\n    malignantly          malignantli\n    malkin               malkin\n    mall                 mall\n    mallard              mallard\n    mallet               mallet\n    mallows              mallow\n    malmsey              malmsei\n    malt                 malt\n    maltworms            maltworm\n    malvolio             malvolio\n    mamillius            mamilliu\n    mammering            mammer\n    mammet               mammet\n    mammets              mammet\n    mammock              mammock\n    man                  man\n    manacle              manacl\n    manacles             manacl\n    manage               manag\n    managed              manag\n    manager              manag\n    managing             manag\n    manakin              manakin\n    manchus              manchu\n    mandate              mandat\n    mandragora           mandragora\n    mandrake             mandrak\n    mandrakes            mandrak\n    mane                 mane\n    manent               manent\n    manes                mane\n    manet                manet\n    manfully             manfulli\n    mangle               mangl\n    mangled              mangl\n    mangles              mangl\n    mangling             mangl\n    mangy                mangi\n    manhood              manhood\n    manhoods             manhood\n    manifest             manifest\n    manifested           manifest\n    manifests            manifest\n    manifold             manifold\n    manifoldly           manifoldli\n    manka                manka\n    mankind              mankind\n    manlike              manlik\n    manly                manli\n    mann                 mann\n    manna                manna\n    manner               manner\n    mannerly             mannerli\n    manners              manner\n    manningtree          manningtre\n    mannish              mannish\n    manor                manor\n    manors               manor\n    mans                 man\n    mansion              mansion\n    mansionry            mansionri\n    mansions             mansion\n    manslaughter         manslaught\n    mantle               mantl\n    mantled              mantl\n    mantles              mantl\n    mantua               mantua\n    mantuan              mantuan\n    manual               manual\n    manure               manur\n    manured              manur\n    manus                manu\n    many                 mani\n    map                  map\n    mapp                 mapp\n    maps                 map\n    mar                  mar\n    marble               marbl\n    marbled              marbl\n    marcade              marcad\n    marcellus            marcellu\n    march                march\n    marches              march\n    marcheth             marcheth\n    marching             march\n    marchioness          marchio\n    marchpane            marchpan\n    marcians             marcian\n    marcius              marciu\n    marcus               marcu\n    mardian              mardian\n    mare                 mare\n    mares                mare\n    marg                 marg\n    margarelon           margarelon\n    margaret             margaret\n    marge                marg\n    margent              margent\n    margery              margeri\n    maria                maria\n    marian               marian\n    mariana              mariana\n    maries               mari\n    marigold             marigold\n    mariner              marin\n    mariners             marin\n    maritime             maritim\n    marjoram             marjoram\n    mark                 mark\n    marked               mark\n    market               market\n    marketable           market\n    marketplace          marketplac\n    markets              market\n    marking              mark\n    markman              markman\n    marks                mark\n    marl                 marl\n    marle                marl\n    marmoset             marmoset\n    marquess             marquess\n    marquis              marqui\n    marr                 marr\n    marriage             marriag\n    marriages            marriag\n    married              marri\n    marries              marri\n    marring              mar\n    marrow               marrow\n    marrowless           marrowless\n    marrows              marrow\n    marry                marri\n    marrying             marri\n    mars                 mar\n    marseilles           marseil\n    marsh                marsh\n    marshal              marshal\n    marshalsea           marshalsea\n    marshalship          marshalship\n    mart                 mart\n    marted               mart\n    martem               martem\n    martext              martext\n    martial              martial\n    martin               martin\n    martino              martino\n    martius              martiu\n    martlemas            martlema\n    martlet              martlet\n    marts                mart\n    martyr               martyr\n    martyrs              martyr\n    marullus             marullu\n    marv                 marv\n    marvel               marvel\n    marvell              marvel\n    marvellous           marvel\n    marvellously         marvel\n    marvels              marvel\n    mary                 mari\n    mas                  ma\n    masculine            masculin\n    masham               masham\n    mask                 mask\n    masked               mask\n    masker               masker\n    maskers              masker\n    masking              mask\n    masks                mask\n    mason                mason\n    masonry              masonri\n    masons               mason\n    masque               masqu\n    masquers             masquer\n    masques              masqu\n    masquing             masqu\n    mass                 mass\n    massacre             massacr\n    massacres            massacr\n    masses               mass\n    massy                massi\n    mast                 mast\n    mastcr               mastcr\n    master               master\n    masterdom            masterdom\n    masterest            masterest\n    masterless           masterless\n    masterly             masterli\n    masterpiece          masterpiec\n    masters              master\n    mastership           mastership\n    mastic               mastic\n    mastiff              mastiff\n    mastiffs             mastiff\n    masts                mast\n    match                match\n    matches              match\n    matcheth             matcheth\n    matching             match\n    matchless            matchless\n    mate                 mate\n    mated                mate\n    mater                mater\n    material             materi\n    mates                mate\n    mathematics          mathemat\n    matin                matin\n    matron               matron\n    matrons              matron\n    matter               matter\n    matters              matter\n    matthew              matthew\n    mattock              mattock\n    mattress             mattress\n    mature               matur\n    maturity             matur\n    maud                 maud\n    maudlin              maudlin\n    maugre               maugr\n    maul                 maul\n    maund                maund\n    mauri                mauri\n    mauritania           mauritania\n    mauvais              mauvai\n    maw                  maw\n    maws                 maw\n    maxim                maxim\n    may                  mai\n    mayday               maydai\n    mayest               mayest\n    mayor                mayor\n    maypole              maypol\n    mayst                mayst\n    maz                  maz\n    maze                 maze\n    mazed                maze\n    mazes                maze\n    mazzard              mazzard\n    me                   me\n    meacock              meacock\n    mead                 mead\n    meadow               meadow\n    meadows              meadow\n    meads                mead\n    meagre               meagr\n    meal                 meal\n    meals                meal\n    mealy                meali\n    mean                 mean\n    meanders             meander\n    meaner               meaner\n    meanest              meanest\n    meaneth              meaneth\n    meaning              mean\n    meanings             mean\n    meanly               meanli\n    means                mean\n    meant                meant\n    meantime             meantim\n    meanwhile            meanwhil\n    measles              measl\n    measur               measur\n    measurable           measur\n    measure              measur\n    measured             measur\n    measureless          measureless\n    measures             measur\n    measuring            measur\n    meat                 meat\n    meats                meat\n    mechanic             mechan\n    mechanical           mechan\n    mechanicals          mechan\n    mechanics            mechan\n    mechante             mechant\n    med                  med\n    medal                medal\n    meddle               meddl\n    meddler              meddler\n    meddling             meddl\n    mede                 mede\n    medea                medea\n    media                media\n    mediation            mediat\n    mediators            mediat\n    medice               medic\n    medicinal            medicin\n    medicine             medicin\n    medicines            medicin\n    meditate             medit\n    meditates            medit\n    meditating           medit\n    meditation           medit\n    meditations          medit\n    mediterranean        mediterranean\n    mediterraneum        mediterraneum\n    medlar               medlar\n    medlars              medlar\n    meed                 meed\n    meeds                meed\n    meek                 meek\n    meekly               meekli\n    meekness             meek\n    meet                 meet\n    meeter               meeter\n    meetest              meetest\n    meeting              meet\n    meetings             meet\n    meetly               meetli\n    meetness             meet\n    meets                meet\n    meg                  meg\n    mehercle             mehercl\n    meilleur             meilleur\n    meiny                meini\n    meisen               meisen\n    melancholies         melancholi\n    melancholy           melancholi\n    melford              melford\n    mell                 mell\n    mellifluous          melliflu\n    mellow               mellow\n    mellowing            mellow\n    melodious            melodi\n    melody               melodi\n    melt                 melt\n    melted               melt\n    melteth              melteth\n    melting              melt\n    melts                melt\n    melun                melun\n    member               member\n    members              member\n    memento              memento\n    memorable            memor\n    memorandums          memorandum\n    memorial             memori\n    memorials            memori\n    memories             memori\n    memoriz              memoriz\n    memorize             memor\n    memory               memori\n    memphis              memphi\n    men                  men\n    menac                menac\n    menace               menac\n    menaces              menac\n    menaphon             menaphon\n    menas                mena\n    mend                 mend\n    mended               mend\n    mender               mender\n    mending              mend\n    mends                mend\n    menecrates           menecr\n    menelaus             menelau\n    menenius             meneniu\n    mental               mental\n    menteith             menteith\n    mention              mention\n    mentis               menti\n    menton               menton\n    mephostophilus       mephostophilu\n    mer                  mer\n    mercatante           mercatant\n    mercatio             mercatio\n    mercenaries          mercenari\n    mercenary            mercenari\n    mercer               mercer\n    merchandise          merchandis\n    merchandized         merchand\n    merchant             merchant\n    merchants            merchant\n    mercies              merci\n    merciful             merci\n    mercifully           mercifulli\n    merciless            merciless\n    mercurial            mercuri\n    mercuries            mercuri\n    mercury              mercuri\n    mercutio             mercutio\n    mercy                merci\n    mere                 mere\n    mered                mere\n    merely               mere\n    merest               merest\n    meridian             meridian\n    merit                merit\n    merited              merit\n    meritorious          meritori\n    merits               merit\n    merlin               merlin\n    mermaid              mermaid\n    mermaids             mermaid\n    merops               merop\n    merrier              merrier\n    merriest             merriest\n    merrily              merrili\n    merriman             merriman\n    merriment            merriment\n    merriments           merriment\n    merriness            merri\n    merry                merri\n    mervailous           mervail\n    mes                  me\n    mesh                 mesh\n    meshes               mesh\n    mesopotamia          mesopotamia\n    mess                 mess\n    message              messag\n    messages             messag\n    messala              messala\n    messaline            messalin\n    messenger            messeng\n    messengers           messeng\n    messes               mess\n    messina              messina\n    met                  met\n    metal                metal\n    metals               metal\n    metamorphis          metamorphi\n    metamorphoses        metamorphos\n    metaphor             metaphor\n    metaphysical         metaphys\n    metaphysics          metaphys\n    mete                 mete\n    metellus             metellu\n    meteor               meteor\n    meteors              meteor\n    meteyard             meteyard\n    metheglin            metheglin\n    metheglins           metheglin\n    methink              methink\n    methinks             methink\n    method               method\n    methods              method\n    methought            methought\n    methoughts           methought\n    metre                metr\n    metres               metr\n    metropolis           metropoli\n    mette                mett\n    mettle               mettl\n    mettled              mettl\n    meus                 meu\n    mew                  mew\n    mewed                mew\n    mewling              mewl\n    mexico               mexico\n    mi                   mi\n    mice                 mice\n    michael              michael\n    michaelmas           michaelma\n    micher               micher\n    miching              mich\n    mickle               mickl\n    microcosm            microcosm\n    mid                  mid\n    midas                mida\n    middest              middest\n    middle               middl\n    middleham            middleham\n    midnight             midnight\n    midriff              midriff\n    midst                midst\n    midsummer            midsumm\n    midway               midwai\n    midwife              midwif\n    midwives             midwiv\n    mienne               mienn\n    might                might\n    mightful             might\n    mightier             mightier\n    mightiest            mightiest\n    mightily             mightili\n    mightiness           mighti\n    mightst              mightst\n    mighty               mighti\n    milan                milan\n    milch                milch\n    mild                 mild\n    milder               milder\n    mildest              mildest\n    mildew               mildew\n    mildews              mildew\n    mildly               mildli\n    mildness             mild\n    mile                 mile\n    miles                mile\n    milford              milford\n    militarist           militarist\n    military             militari\n    milk                 milk\n    milking              milk\n    milkmaid             milkmaid\n    milks                milk\n    milksops             milksop\n    milky                milki\n    mill                 mill\n    mille                mill\n    miller               miller\n    milliner             millin\n    million              million\n    millioned            million\n    millions             million\n    mills                mill\n    millstones           millston\n    milo                 milo\n    mimic                mimic\n    minc                 minc\n    mince                minc\n    minces               minc\n    mincing              minc\n    mind                 mind\n    minded               mind\n    minding              mind\n    mindless             mindless\n    minds                mind\n    mine                 mine\n    mineral              miner\n    minerals             miner\n    minerva              minerva\n    mines                mine\n    mingle               mingl\n    mingled              mingl\n    mingling             mingl\n    minikin              minikin\n    minim                minim\n    minime               minim\n    minimo               minimo\n    minimus              minimu\n    mining               mine\n    minion               minion\n    minions              minion\n    minist               minist\n    minister             minist\n    ministers            minist\n    ministration         ministr\n    minnow               minnow\n    minnows              minnow\n    minola               minola\n    minority             minor\n    minos                mino\n    minotaurs            minotaur\n    minstrel             minstrel\n    minstrels            minstrel\n    minstrelsy           minstrelsi\n    mint                 mint\n    mints                mint\n    minute               minut\n    minutely             minut\n    minutes              minut\n    minx                 minx\n    mio                  mio\n    mir                  mir\n    mirable              mirabl\n    miracle              miracl\n    miracles             miracl\n    miraculous           miracul\n    miranda              miranda\n    mire                 mire\n    mirror               mirror\n    mirrors              mirror\n    mirth                mirth\n    mirthful             mirth\n    miry                 miri\n    mis                  mi\n    misadventur          misadventur\n    misadventure         misadventur\n    misanthropos         misanthropo\n    misapplied           misappli\n    misbecame            misbecam\n    misbecom             misbecom\n    misbecome            misbecom\n    misbegot             misbegot\n    misbegotten          misbegotten\n    misbeliever          misbeliev\n    misbelieving         misbeliev\n    misbhav              misbhav\n    miscall              miscal\n    miscalled            miscal\n    miscarried           miscarri\n    miscarries           miscarri\n    miscarry             miscarri\n    miscarrying          miscarri\n    mischance            mischanc\n    mischances           mischanc\n    mischief             mischief\n    mischiefs            mischief\n    mischievous          mischiev\n    misconceived         misconceiv\n    misconst             misconst\n    misconster           misconst\n    misconstruction      misconstruct\n    misconstrued         misconstru\n    misconstrues         misconstru\n    miscreant            miscreant\n    miscreate            miscreat\n    misdeed              misde\n    misdeeds             misde\n    misdemean            misdemean\n    misdemeanours        misdemeanour\n    misdoubt             misdoubt\n    misdoubteth          misdoubteth\n    misdoubts            misdoubt\n    misenum              misenum\n    miser                miser\n    miserable            miser\n    miserably            miser\n    misericorde          misericord\n    miseries             miseri\n    misers               miser\n    misery               miseri\n    misfortune           misfortun\n    misfortunes          misfortun\n    misgive              misgiv\n    misgives             misgiv\n    misgiving            misgiv\n    misgoverned          misgovern\n    misgovernment        misgovern\n    misgraffed           misgraf\n    misguide             misguid\n    mishap               mishap\n    mishaps              mishap\n    misheard             misheard\n    misinterpret         misinterpret\n    mislead              mislead\n    misleader            mislead\n    misleaders           mislead\n    misleading           mislead\n    misled               misl\n    mislike              mislik\n    misord               misord\n    misplac              misplac\n    misplaced            misplac\n    misplaces            misplac\n    mispris              mispri\n    misprised            mispris\n    misprision           mispris\n    misprizing           mispriz\n    misproud             misproud\n    misquote             misquot\n    misreport            misreport\n    miss                 miss\n    missed               miss\n    misses               miss\n    misshap              misshap\n    misshapen            misshapen\n    missheathed          missheath\n    missing              miss\n    missingly            missingli\n    missions             mission\n    missive              missiv\n    missives             missiv\n    misspoke             misspok\n    mist                 mist\n    mista                mista\n    mistak               mistak\n    mistake              mistak\n    mistaken             mistaken\n    mistakes             mistak\n    mistaketh            mistaketh\n    mistaking            mistak\n    mistakings           mistak\n    mistemp              mistemp\n    mistempered          mistemp\n    misterm              misterm\n    mistful              mist\n    misthink             misthink\n    misthought           misthought\n    mistletoe            mistleto\n    mistook              mistook\n    mistreadings         mistread\n    mistress             mistress\n    mistresses           mistress\n    mistresss            mistresss\n    mistriship           mistriship\n    mistrust             mistrust\n    mistrusted           mistrust\n    mistrustful          mistrust\n    mistrusting          mistrust\n    mists                mist\n    misty                misti\n    misus                misu\n    misuse               misus\n    misused              misus\n    misuses              misus\n    mites                mite\n    mithridates          mithrid\n    mitigate             mitig\n    mitigation           mitig\n    mix                  mix\n    mixed                mix\n    mixture              mixtur\n    mixtures             mixtur\n    mm                   mm\n    mnd                  mnd\n    moan                 moan\n    moans                moan\n    moat                 moat\n    moated               moat\n    mobled               mobl\n    mock                 mock\n    mockable             mockabl\n    mocker               mocker\n    mockeries            mockeri\n    mockers              mocker\n    mockery              mockeri\n    mocking              mock\n    mocks                mock\n    mockvater            mockvat\n    mockwater            mockwat\n    model                model\n    modena               modena\n    moderate             moder\n    moderately           moder\n    moderation           moder\n    modern               modern\n    modest               modest\n    modesties            modesti\n    modestly             modestli\n    modesty              modesti\n    modicums             modicum\n    modo                 modo\n    module               modul\n    moe                  moe\n    moi                  moi\n    moiety               moieti\n    moist                moist\n    moisten              moisten\n    moisture             moistur\n    moldwarp             moldwarp\n    mole                 mole\n    molehill             molehil\n    moles                mole\n    molest               molest\n    molestation          molest\n    mollification        mollif\n    mollis               molli\n    molten               molten\n    molto                molto\n    mome                 mome\n    moment               moment\n    momentary            momentari\n    moming               mome\n    mon                  mon\n    monachum             monachum\n    monarch              monarch\n    monarchies           monarchi\n    monarchize           monarch\n    monarcho             monarcho\n    monarchs             monarch\n    monarchy             monarchi\n    monast               monast\n    monastery            monasteri\n    monastic             monast\n    monday               mondai\n    monde                mond\n    money                monei\n    moneys               monei\n    mong                 mong\n    monger               monger\n    mongers              monger\n    monging              mong\n    mongrel              mongrel\n    mongrels             mongrel\n    mongst               mongst\n    monk                 monk\n    monkey               monkei\n    monkeys              monkei\n    monks                monk\n    monmouth             monmouth\n    monopoly             monopoli\n    mons                 mon\n    monsieur             monsieur\n    monsieurs            monsieur\n    monster              monster\n    monsters             monster\n    monstrous            monstrou\n    monstrously          monstrous\n    monstrousness        monstrous\n    monstruosity         monstruos\n    montacute            montacut\n    montage              montag\n    montague             montagu\n    montagues            montagu\n    montano              montano\n    montant              montant\n    montez               montez\n    montferrat           montferrat\n    montgomery           montgomeri\n    month                month\n    monthly              monthli\n    months               month\n    montjoy              montjoi\n    monument             monument\n    monumental           monument\n    monuments            monument\n    mood                 mood\n    moods                mood\n    moody                moodi\n    moon                 moon\n    moonbeams            moonbeam\n    moonish              moonish\n    moonlight            moonlight\n    moons                moon\n    moonshine            moonshin\n    moonshines           moonshin\n    moor                 moor\n    moorfields           moorfield\n    moors                moor\n    moorship             moorship\n    mop                  mop\n    mope                 mope\n    moping               mope\n    mopping              mop\n    mopsa                mopsa\n    moral                moral\n    moraler              moral\n    morality             moral\n    moralize             moral\n    mordake              mordak\n    more                 more\n    moreover             moreov\n    mores                more\n    morgan               morgan\n    mori                 mori\n    morisco              morisco\n    morn                 morn\n    morning              morn\n    mornings             morn\n    morocco              morocco\n    morris               morri\n    morrow               morrow\n    morrows              morrow\n    morsel               morsel\n    morsels              morsel\n    mort                 mort\n    mortal               mortal\n    mortality            mortal\n    mortally             mortal\n    mortals              mortal\n    mortar               mortar\n    mortgaged            mortgag\n    mortified            mortifi\n    mortifying           mortifi\n    mortimer             mortim\n    mortimers            mortim\n    mortis               morti\n    mortise              mortis\n    morton               morton\n    mose                 mose\n    moss                 moss\n    mossgrown            mossgrown\n    most                 most\n    mote                 mote\n    moth                 moth\n    mother               mother\n    mothers              mother\n    moths                moth\n    motion               motion\n    motionless           motionless\n    motions              motion\n    motive               motiv\n    motives              motiv\n    motley               motlei\n    mots                 mot\n    mought               mought\n    mould                mould\n    moulded              mould\n    mouldeth             mouldeth\n    moulds               mould\n    mouldy               mouldi\n    moult                moult\n    moulten              moulten\n    mounch               mounch\n    mounseur             mounseur\n    mounsieur            mounsieur\n    mount                mount\n    mountain             mountain\n    mountaineer          mountain\n    mountaineers         mountain\n    mountainous          mountain\n    mountains            mountain\n    mountant             mountant\n    mountanto            mountanto\n    mountebank           mountebank\n    mountebanks          mountebank\n    mounted              mount\n    mounteth             mounteth\n    mounting             mount\n    mounts               mount\n    mourn                mourn\n    mourned              mourn\n    mourner              mourner\n    mourners             mourner\n    mournful             mourn\n    mournfully           mournfulli\n    mourning             mourn\n    mourningly           mourningli\n    mournings            mourn\n    mourns               mourn\n    mous                 mou\n    mouse                mous\n    mousetrap            mousetrap\n    mousing              mous\n    mouth                mouth\n    mouthed              mouth\n    mouths               mouth\n    mov                  mov\n    movables             movabl\n    move                 move\n    moveable             moveabl\n    moveables            moveabl\n    moved                move\n    mover                mover\n    movers               mover\n    moves                move\n    moveth               moveth\n    moving               move\n    movingly             movingli\n    movousus             movousu\n    mow                  mow\n    mowbray              mowbrai\n    mower                mower\n    mowing               mow\n    mows                 mow\n    moy                  moi\n    moys                 moi\n    moyses               moys\n    mrs                  mr\n    much                 much\n    muck                 muck\n    mud                  mud\n    mudded               mud\n    muddied              muddi\n    muddy                muddi\n    muffins              muffin\n    muffl                muffl\n    muffle               muffl\n    muffled              muffl\n    muffler              muffler\n    muffling             muffl\n    mugger               mugger\n    mugs                 mug\n    mulberries           mulberri\n    mulberry             mulberri\n    mule                 mule\n    mules                mule\n    muleteers            mulet\n    mulier               mulier\n    mulieres             mulier\n    muliteus             muliteu\n    mull                 mull\n    mulmutius            mulmutiu\n    multiplied           multipli\n    multiply             multipli\n    multiplying          multipli\n    multipotent          multipot\n    multitude            multitud\n    multitudes           multitud\n    multitudinous        multitudin\n    mum                  mum\n    mumble               mumbl\n    mumbling             mumbl\n    mummers              mummer\n    mummy                mummi\n    mun                  mun\n    munch                munch\n    muniments            muniment\n    munition             munit\n    murd                 murd\n    murder               murder\n    murdered             murder\n    murderer             murder\n    murderers            murder\n    murdering            murder\n    murderous            murder\n    murders              murder\n    mure                 mure\n    murk                 murk\n    murkiest             murkiest\n    murky                murki\n    murmur               murmur\n    murmurers            murmur\n    murmuring            murmur\n    murrain              murrain\n    murray               murrai\n    murrion              murrion\n    murther              murther\n    murtherer            murther\n    murtherers           murther\n    murthering           murther\n    murtherous           murther\n    murthers             murther\n    mus                  mu\n    muscadel             muscadel\n    muscovites           muscovit\n    muscovits            muscovit\n    muscovy              muscovi\n    muse                 muse\n    muses                muse\n    mush                 mush\n    mushrooms            mushroom\n    music                music\n    musical              music\n    musician             musician\n    musicians            musician\n    musics               music\n    musing               muse\n    musings              muse\n    musk                 musk\n    musket               musket\n    muskets              musket\n    muskos               musko\n    muss                 muss\n    mussel               mussel\n    mussels              mussel\n    must                 must\n    mustachio            mustachio\n    mustard              mustard\n    mustardseed          mustardse\n    muster               muster\n    mustering            muster\n    musters              muster\n    musty                musti\n    mutability           mutabl\n    mutable              mutabl\n    mutation             mutat\n    mutations            mutat\n    mute                 mute\n    mutes                mute\n    mutest               mutest\n    mutine               mutin\n    mutineer             mutin\n    mutineers            mutin\n    mutines              mutin\n    mutinies             mutini\n    mutinous             mutin\n    mutiny               mutini\n    mutius               mutiu\n    mutter               mutter\n    muttered             mutter\n    mutton               mutton\n    muttons              mutton\n    mutual               mutual\n    mutualities          mutual\n    mutually             mutual\n    muzzl                muzzl\n    muzzle               muzzl\n    muzzled              muzzl\n    mv                   mv\n    mww                  mww\n    my                   my\n    mynheers             mynheer\n    myrmidon             myrmidon\n    myrmidons            myrmidon\n    myrtle               myrtl\n    myself               myself\n    myst                 myst\n    mysteries            mysteri\n    mystery              mysteri\n    n                    n\n    nag                  nag\n    nage                 nage\n    nags                 nag\n    naiads               naiad\n    nail                 nail\n    nails                nail\n    nak                  nak\n    naked                nake\n    nakedness            naked\n    nal                  nal\n    nam                  nam\n    name                 name\n    named                name\n    nameless             nameless\n    namely               name\n    names                name\n    namest               namest\n    naming               name\n    nan                  nan\n    nance                nanc\n    nap                  nap\n    nape                 nape\n    napes                nape\n    napkin               napkin\n    napkins              napkin\n    naples               napl\n    napless              napless\n    napping              nap\n    naps                 nap\n    narbon               narbon\n    narcissus            narcissu\n    narines              narin\n    narrow               narrow\n    narrowly             narrowli\n    naso                 naso\n    nasty                nasti\n    nathaniel            nathaniel\n    natifs               natif\n    nation               nation\n    nations              nation\n    native               nativ\n    nativity             nativ\n    natur                natur\n    natural              natur\n    naturalize           natur\n    naturally            natur\n    nature               natur\n    natured              natur\n    natures              natur\n    natus                natu\n    naught               naught\n    naughtily            naughtili\n    naughty              naughti\n    navarre              navarr\n    nave                 nave\n    navel                navel\n    navigation           navig\n    navy                 navi\n    nay                  nai\n    nayward              nayward\n    nayword              nayword\n    nazarite             nazarit\n    ne                   ne\n    neaf                 neaf\n    neamnoins            neamnoin\n    neanmoins            neanmoin\n    neapolitan           neapolitan\n    neapolitans          neapolitan\n    near                 near\n    nearer               nearer\n    nearest              nearest\n    nearly               nearli\n    nearness             near\n    neat                 neat\n    neatly               neatli\n    neb                  neb\n    nebour               nebour\n    nebuchadnezzar       nebuchadnezzar\n    nec                  nec\n    necessaries          necessari\n    necessarily          necessarili\n    necessary            necessari\n    necessitied          necess\n    necessities          necess\n    necessity            necess\n    neck                 neck\n    necklace             necklac\n    necks                neck\n    nectar               nectar\n    ned                  ned\n    nedar                nedar\n    need                 need\n    needed               need\n    needer               needer\n    needful              need\n    needfull             needful\n    needing              need\n    needle               needl\n    needles              needl\n    needless             needless\n    needly               needli\n    needs                need\n    needy                needi\n    neer                 neer\n    neeze                neez\n    nefas                nefa\n    negation             negat\n    negative             neg\n    negatives            neg\n    neglect              neglect\n    neglected            neglect\n    neglecting           neglect\n    neglectingly         neglectingli\n    neglection           neglect\n    negligence           neglig\n    negligent            neglig\n    negotiate            negoti\n    negotiations         negoti\n    negro                negro\n    neigh                neigh\n    neighbors            neighbor\n    neighbour            neighbour\n    neighbourhood        neighbourhood\n    neighbouring         neighbour\n    neighbourly          neighbourli\n    neighbours           neighbour\n    neighing             neigh\n    neighs               neigh\n    neither              neither\n    nell                 nell\n    nemean               nemean\n    nemesis              nemesi\n    neoptolemus          neoptolemu\n    nephew               nephew\n    nephews              nephew\n    neptune              neptun\n    ner                  ner\n    nereides             nereid\n    nerissa              nerissa\n    nero                 nero\n    neroes               nero\n    ners                 ner\n    nerve                nerv\n    nerves               nerv\n    nervii               nervii\n    nervy                nervi\n    nessus               nessu\n    nest                 nest\n    nestor               nestor\n    nests                nest\n    net                  net\n    nether               nether\n    netherlands          netherland\n    nets                 net\n    nettle               nettl\n    nettled              nettl\n    nettles              nettl\n    neuter               neuter\n    neutral              neutral\n    nev                  nev\n    never                never\n    nevil                nevil\n    nevils               nevil\n    new                  new\n    newborn              newborn\n    newer                newer\n    newest               newest\n    newgate              newgat\n    newly                newli\n    newness              new\n    news                 new\n    newsmongers          newsmong\n    newt                 newt\n    newts                newt\n    next                 next\n    nibbling             nibbl\n    nicanor              nicanor\n    nice                 nice\n    nicely               nice\n    niceness             nice\n    nicer                nicer\n    nicety               niceti\n    nicholas             nichola\n    nick                 nick\n    nickname             nicknam\n    nicks                nick\n    niece                niec\n    nieces               niec\n    niggard              niggard\n    niggarding           niggard\n    niggardly            niggardli\n    nigh                 nigh\n    night                night\n    nightcap             nightcap\n    nightcaps            nightcap\n    nighted              night\n    nightgown            nightgown\n    nightingale          nightingal\n    nightingales         nightingal\n    nightly              nightli\n    nightmare            nightmar\n    nights               night\n    nightwork            nightwork\n    nihil                nihil\n    nile                 nile\n    nill                 nill\n    nilus                nilu\n    nimble               nimbl\n    nimbleness           nimbl\n    nimbler              nimbler\n    nimbly               nimbl\n    nine                 nine\n    nineteen             nineteen\n    ning                 ning\n    ningly               ningli\n    ninny                ninni\n    ninth                ninth\n    ninus                ninu\n    niobe                niob\n    niobes               niob\n    nip                  nip\n    nipp                 nipp\n    nipping              nip\n    nipple               nippl\n    nips                 nip\n    nit                  nit\n    nly                  nly\n    nnight               nnight\n    nnights              nnight\n    no                   no\n    noah                 noah\n    nob                  nob\n    nobility             nobil\n    nobis                nobi\n    noble                nobl\n    nobleman             nobleman\n    noblemen             noblemen\n    nobleness            nobl\n    nobler               nobler\n    nobles               nobl\n    noblesse             nobless\n    noblest              noblest\n    nobly                nobli\n    nobody               nobodi\n    noces                noce\n    nod                  nod\n    nodded               nod\n    nodding              nod\n    noddle               noddl\n    noddles              noddl\n    noddy                noddi\n    nods                 nod\n    noes                 noe\n    nointed              noint\n    nois                 noi\n    noise                nois\n    noiseless            noiseless\n    noisemaker           noisemak\n    noises               nois\n    noisome              noisom\n    nole                 nole\n    nominate             nomin\n    nominated            nomin\n    nomination           nomin\n    nominativo           nominativo\n    non                  non\n    nonage               nonag\n    nonce                nonc\n    none                 none\n    nonino               nonino\n    nonny                nonni\n    nonpareil            nonpareil\n    nonsuits             nonsuit\n    nony                 noni\n    nook                 nook\n    nooks                nook\n    noon                 noon\n    noonday              noondai\n    noontide             noontid\n    nor                  nor\n    norbery              norberi\n    norfolk              norfolk\n    norman               norman\n    normandy             normandi\n    normans              norman\n    north                north\n    northampton          northampton\n    northamptonshire     northamptonshir\n    northerly            northerli\n    northern             northern\n    northgate            northgat\n    northumberland       northumberland\n    northumberlands      northumberland\n    northward            northward\n    norway               norwai\n    norways              norwai\n    norwegian            norwegian\n    norweyan             norweyan\n    nos                  no\n    nose                 nose\n    nosegays             nosegai\n    noseless             noseless\n    noses                nose\n    noster               noster\n    nostra               nostra\n    nostril              nostril\n    nostrils             nostril\n    not                  not\n    notable              notabl\n    notably              notabl\n    notary               notari\n    notch                notch\n    note                 note\n    notebook             notebook\n    noted                note\n    notedly              notedli\n    notes                note\n    notest               notest\n    noteworthy           noteworthi\n    nothing              noth\n    nothings             noth\n    notice               notic\n    notify               notifi\n    noting               note\n    notion               notion\n    notorious            notori\n    notoriously          notori\n    notre                notr\n    notwithstanding      notwithstand\n    nought               nought\n    noun                 noun\n    nouns                noun\n    nourish              nourish\n    nourished            nourish\n    nourisher            nourish\n    nourishes            nourish\n    nourisheth           nourisheth\n    nourishing           nourish\n    nourishment          nourish\n    nous                 nou\n    novel                novel\n    novelties            novelti\n    novelty              novelti\n    noverbs              noverb\n    novi                 novi\n    novice               novic\n    novices              novic\n    novum                novum\n    now                  now\n    nowhere              nowher\n    noyance              noyanc\n    ns                   ns\n    nt                   nt\n    nubibus              nubibu\n    numa                 numa\n    numb                 numb\n    number               number\n    numbered             number\n    numbering            number\n    numberless           numberless\n    numbers              number\n    numbness             numb\n    nun                  nun\n    nuncio               nuncio\n    nuncle               nuncl\n    nunnery              nunneri\n    nuns                 nun\n    nuntius              nuntiu\n    nuptial              nuptial\n    nurs                 nur\n    nurse                nurs\n    nursed               nurs\n    nurser               nurser\n    nursery              nurseri\n    nurses               nurs\n    nurseth              nurseth\n    nursh                nursh\n    nursing              nurs\n    nurtur               nurtur\n    nurture              nurtur\n    nut                  nut\n    nuthook              nuthook\n    nutmeg               nutmeg\n    nutmegs              nutmeg\n    nutriment            nutriment\n    nuts                 nut\n    nutshell             nutshel\n    ny                   ny\n    nym                  nym\n    nymph                nymph\n    nymphs               nymph\n    o                    o\n    oak                  oak\n    oaken                oaken\n    oaks                 oak\n    oared                oar\n    oars                 oar\n    oatcake              oatcak\n    oaten                oaten\n    oath                 oath\n    oathable             oathabl\n    oaths                oath\n    oats                 oat\n    ob                   ob\n    obduracy             obduraci\n    obdurate             obdur\n    obedience            obedi\n    obedient             obedi\n    obeisance            obeis\n    oberon               oberon\n    obey                 obei\n    obeyed               obei\n    obeying              obei\n    obeys                obei\n    obidicut             obidicut\n    object               object\n    objected             object\n    objections           object\n    objects              object\n    oblation             oblat\n    oblations            oblat\n    obligation           oblig\n    obligations          oblig\n    obliged              oblig\n    oblique              obliqu\n    oblivion             oblivion\n    oblivious            oblivi\n    obloquy              obloqui\n    obscene              obscen\n    obscenely            obscen\n    obscur               obscur\n    obscure              obscur\n    obscured             obscur\n    obscurely            obscur\n    obscures             obscur\n    obscuring            obscur\n    obscurity            obscur\n    obsequies            obsequi\n    obsequious           obsequi\n    obsequiously         obsequi\n    observ               observ\n    observance           observ\n    observances          observ\n    observancy           observ\n    observant            observ\n    observants           observ\n    observation          observ\n    observe              observ\n    observed             observ\n    observer             observ\n    observers            observ\n    observing            observ\n    observingly          observingli\n    obsque               obsqu\n    obstacle             obstacl\n    obstacles            obstacl\n    obstinacy            obstinaci\n    obstinate            obstin\n    obstinately          obstin\n    obstruct             obstruct\n    obstruction          obstruct\n    obstructions         obstruct\n    obtain               obtain\n    obtained             obtain\n    obtaining            obtain\n    occasion             occas\n    occasions            occas\n    occident             occid\n    occidental           occident\n    occulted             occult\n    occupat              occupat\n    occupation           occup\n    occupations          occup\n    occupied             occupi\n    occupies             occupi\n    occupy               occupi\n    occurrence           occurr\n    occurrences          occurr\n    occurrents           occurr\n    ocean                ocean\n    oceans               ocean\n    octavia              octavia\n    octavius             octaviu\n    ocular               ocular\n    od                   od\n    odd                  odd\n    oddest               oddest\n    oddly                oddli\n    odds                 odd\n    ode                  od\n    odes                 od\n    odious               odiou\n    odoriferous          odorifer\n    odorous              odor\n    odour                odour\n    odours               odour\n    ods                  od\n    oeillades            oeillad\n    oes                  oe\n    oeuvres              oeuvr\n    of                   of\n    ofephesus            ofephesu\n    off                  off\n    offal                offal\n    offence              offenc\n    offenceful           offenc\n    offences             offenc\n    offend               offend\n    offended             offend\n    offendendo           offendendo\n    offender             offend\n    offenders            offend\n    offendeth            offendeth\n    offending            offend\n    offendress           offendress\n    offends              offend\n    offense              offens\n    offenseless          offenseless\n    offenses             offens\n    offensive            offens\n    offer                offer\n    offered              offer\n    offering             offer\n    offerings            offer\n    offers               offer\n    offert               offert\n    offic                offic\n    office               offic\n    officed              offic\n    officer              offic\n    officers             offic\n    offices              offic\n    official             offici\n    officious            offici\n    offspring            offspr\n    oft                  oft\n    often                often\n    oftener              often\n    oftentimes           oftentim\n    oh                   oh\n    oil                  oil\n    oils                 oil\n    oily                 oili\n    old                  old\n    oldcastle            oldcastl\n    olden                olden\n    older                older\n    oldest               oldest\n    oldness              old\n    olive                oliv\n    oliver               oliv\n    olivers              oliv\n    olives               oliv\n    olivia               olivia\n    olympian             olympian\n    olympus              olympu\n    oman                 oman\n    omans                oman\n    omen                 omen\n    ominous              omin\n    omission             omiss\n    omit                 omit\n    omittance            omitt\n    omitted              omit\n    omitting             omit\n    omne                 omn\n    omnes                omn\n    omnipotent           omnipot\n    on                   on\n    once                 onc\n    one                  on\n    ones                 on\n    oneyers              oney\n    ongles               ongl\n    onion                onion\n    onions               onion\n    only                 onli\n    onset                onset\n    onward               onward\n    onwards              onward\n    oo                   oo\n    ooze                 ooz\n    oozes                ooz\n    oozy                 oozi\n    op                   op\n    opal                 opal\n    ope                  op\n    open                 open\n    opener               open\n    opening              open\n    openly               openli\n    openness             open\n    opens                open\n    operant              oper\n    operate              oper\n    operation            oper\n    operations           oper\n    operative            oper\n    opes                 op\n    oph                  oph\n    ophelia              ophelia\n    opinion              opinion\n    opinions             opinion\n    opportune            opportun\n    opportunities        opportun\n    opportunity          opportun\n    oppos                oppo\n    oppose               oppos\n    opposed              oppos\n    opposeless           opposeless\n    opposer              oppos\n    opposers             oppos\n    opposes              oppos\n    opposing             oppos\n    opposite             opposit\n    opposites            opposit\n    opposition           opposit\n    oppositions          opposit\n    oppress              oppress\n    oppressed            oppress\n    oppresses            oppress\n    oppresseth           oppresseth\n    oppressing           oppress\n    oppression           oppress\n    oppressor            oppressor\n    opprest              opprest\n    opprobriously        opprobri\n    oppugnancy           oppugn\n    opulency             opul\n    opulent              opul\n    or                   or\n    oracle               oracl\n    oracles              oracl\n    orange               orang\n    oration              orat\n    orator               orat\n    orators              orat\n    oratory              oratori\n    orb                  orb\n    orbed                orb\n    orbs                 orb\n    orchard              orchard\n    orchards             orchard\n    ord                  ord\n    ordain               ordain\n    ordained             ordain\n    ordaining            ordain\n    order                order\n    ordered              order\n    ordering             order\n    orderless            orderless\n    orderly              orderli\n    orders               order\n    ordinance            ordin\n    ordinant             ordin\n    ordinaries           ordinari\n    ordinary             ordinari\n    ordnance             ordnanc\n    ords                 ord\n    ordure               ordur\n    ore                  or\n    organ                organ\n    organs               organ\n    orgillous            orgil\n    orient               orient\n    orifex               orifex\n    origin               origin\n    original             origin\n    orisons              orison\n    ork                  ork\n    orlando              orlando\n    orld                 orld\n    orleans              orlean\n    ornament             ornament\n    ornaments            ornament\n    orodes               orod\n    orphan               orphan\n    orphans              orphan\n    orpheus              orpheu\n    orsino               orsino\n    ort                  ort\n    orthography          orthographi\n    orts                 ort\n    oscorbidulchos       oscorbidulcho\n    osier                osier\n    osiers               osier\n    osprey               osprei\n    osr                  osr\n    osric                osric\n    ossa                 ossa\n    ost                  ost\n    ostent               ostent\n    ostentare            ostentar\n    ostentation          ostent\n    ostents              ostent\n    ostler               ostler\n    ostlers              ostler\n    ostrich              ostrich\n    osw                  osw\n    oswald               oswald\n    othello              othello\n    other                other\n    othergates           otherg\n    others               other\n    otherwhere           otherwher\n    otherwhiles          otherwhil\n    otherwise            otherwis\n    otter                otter\n    ottoman              ottoman\n    ottomites            ottomit\n    oublie               oubli\n    ouches               ouch\n    ought                ought\n    oui                  oui\n    ounce                ounc\n    ounces               ounc\n    ouphes               ouph\n    our                  our\n    ours                 our\n    ourself              ourself\n    ourselves            ourselv\n    ousel                ousel\n    out                  out\n    outbids              outbid\n    outbrave             outbrav\n    outbraves            outbrav\n    outbreak             outbreak\n    outcast              outcast\n    outcries             outcri\n    outcry               outcri\n    outdar               outdar\n    outdare              outdar\n    outdares             outdar\n    outdone              outdon\n    outfac               outfac\n    outface              outfac\n    outfaced             outfac\n    outfacing            outfac\n    outfly               outfli\n    outfrown             outfrown\n    outgo                outgo\n    outgoes              outgo\n    outgrown             outgrown\n    outjest              outjest\n    outlaw               outlaw\n    outlawry             outlawri\n    outlaws              outlaw\n    outliv               outliv\n    outlive              outliv\n    outlives             outliv\n    outliving            outliv\n    outlook              outlook\n    outlustres           outlustr\n    outpriz              outpriz\n    outrage              outrag\n    outrageous           outrag\n    outrages             outrag\n    outran               outran\n    outright             outright\n    outroar              outroar\n    outrun               outrun\n    outrunning           outrun\n    outruns              outrun\n    outscold             outscold\n    outscorn             outscorn\n    outsell              outsel\n    outsells             outsel\n    outside              outsid\n    outsides             outsid\n    outspeaks            outspeak\n    outsport             outsport\n    outstare             outstar\n    outstay              outstai\n    outstood             outstood\n    outstretch           outstretch\n    outstretched         outstretch\n    outstrike            outstrik\n    outstrip             outstrip\n    outstripped          outstrip\n    outswear             outswear\n    outvenoms            outvenom\n    outward              outward\n    outwardly            outwardli\n    outwards             outward\n    outwear              outwear\n    outweighs            outweigh\n    outwent              outwent\n    outworn              outworn\n    outworths            outworth\n    oven                 oven\n    over                 over\n    overawe              overaw\n    overbear             overbear\n    overblown            overblown\n    overboard            overboard\n    overbold             overbold\n    overborne            overborn\n    overbulk             overbulk\n    overbuys             overbui\n    overcame             overcam\n    overcast             overcast\n    overcharg            overcharg\n    overcharged          overcharg\n    overcome             overcom\n    overcomes            overcom\n    overdone             overdon\n    overearnest          overearnest\n    overfar              overfar\n    overflow             overflow\n    overflown            overflown\n    overglance           overgl\n    overgo               overgo\n    overgone             overgon\n    overgorg             overgorg\n    overgrown            overgrown\n    overhead             overhead\n    overhear             overhear\n    overheard            overheard\n    overhold             overhold\n    overjoyed            overjoi\n    overkind             overkind\n    overland             overland\n    overleather          overleath\n    overlive             overl\n    overlook             overlook\n    overlooking          overlook\n    overlooks            overlook\n    overmaster           overmast\n    overmounting         overmount\n    overmuch             overmuch\n    overpass             overpass\n    overpeer             overp\n    overpeering          overp\n    overplus             overplu\n    overrul              overrul\n    overrun              overrun\n    overscutch           overscutch\n    overset              overset\n    overshades           overshad\n    overshine            overshin\n    overshines           overshin\n    overshot             overshot\n    oversights           oversight\n    overspread           overspread\n    overstain            overstain\n    overswear            overswear\n    overt                overt\n    overta               overta\n    overtake             overtak\n    overtaketh           overtaketh\n    overthrow            overthrow\n    overthrown           overthrown\n    overthrows           overthrow\n    overtook             overtook\n    overtopp             overtopp\n    overture             overtur\n    overturn             overturn\n    overwatch            overwatch\n    overween             overween\n    overweening          overween\n    overweigh            overweigh\n    overwhelm            overwhelm\n    overwhelming         overwhelm\n    overworn             overworn\n    ovid                 ovid\n    ovidius              ovidiu\n    ow                   ow\n    owe                  ow\n    owed                 ow\n    owedst               owedst\n    owen                 owen\n    owes                 ow\n    owest                owest\n    oweth                oweth\n    owing                ow\n    owl                  owl\n    owls                 owl\n    own                  own\n    owner                owner\n    owners               owner\n    owning               own\n    owns                 own\n    owy                  owi\n    ox                   ox\n    oxen                 oxen\n    oxford               oxford\n    oxfordshire          oxfordshir\n    oxlips               oxlip\n    oyes                 oy\n    oyster               oyster\n    p                    p\n    pabble               pabbl\n    pabylon              pabylon\n    pac                  pac\n    pace                 pace\n    paced                pace\n    paces                pace\n    pacified             pacifi\n    pacify               pacifi\n    pacing               pace\n    pack                 pack\n    packet               packet\n    packets              packet\n    packhorses           packhors\n    packing              pack\n    packings             pack\n    packs                pack\n    packthread           packthread\n    pacorus              pacoru\n    paction              paction\n    pad                  pad\n    paddle               paddl\n    paddling             paddl\n    paddock              paddock\n    padua                padua\n    pagan                pagan\n    pagans               pagan\n    page                 page\n    pageant              pageant\n    pageants             pageant\n    pages                page\n    pah                  pah\n    paid                 paid\n    pail                 pail\n    pailfuls             pail\n    pails                pail\n    pain                 pain\n    pained               pain\n    painful              pain\n    painfully            painfulli\n    pains                pain\n    paint                paint\n    painted              paint\n    painter              painter\n    painting             paint\n    paintings            paint\n    paints               paint\n    pair                 pair\n    paired               pair\n    pairs                pair\n    pajock               pajock\n    pal                  pal\n    palabras             palabra\n    palace               palac\n    palaces              palac\n    palamedes            palamed\n    palate               palat\n    palates              palat\n    palatine             palatin\n    palating             palat\n    pale                 pale\n    paled                pale\n    paleness             pale\n    paler                paler\n    pales                pale\n    palestine            palestin\n    palfrey              palfrei\n    palfreys             palfrei\n    palisadoes           palisado\n    pall                 pall\n    pallabris            pallabri\n    pallas               palla\n    pallets              pallet\n    palm                 palm\n    palmer               palmer\n    palmers              palmer\n    palms                palm\n    palmy                palmi\n    palpable             palpabl\n    palsied              palsi\n    palsies              palsi\n    palsy                palsi\n    palt                 palt\n    palter               palter\n    paltry               paltri\n    paly                 pali\n    pamp                 pamp\n    pamper               pamper\n    pamphlets            pamphlet\n    pan                  pan\n    pancackes            pancack\n    pancake              pancak\n    pancakes             pancak\n    pandar               pandar\n    pandars              pandar\n    pandarus             pandaru\n    pander               pander\n    panderly             panderli\n    panders              pander\n    pandulph             pandulph\n    panel                panel\n    pang                 pang\n    panging              pang\n    pangs                pang\n    pannier              pannier\n    pannonians           pannonian\n    pansa                pansa\n    pansies              pansi\n    pant                 pant\n    pantaloon            pantaloon\n    panted               pant\n    pantheon             pantheon\n    panther              panther\n    panthino             panthino\n    panting              pant\n    pantingly            pantingli\n    pantler              pantler\n    pantry               pantri\n    pants                pant\n    pap                  pap\n    papal                papal\n    paper                paper\n    papers               paper\n    paphlagonia          paphlagonia\n    paphos               papho\n    papist               papist\n    paps                 pap\n    par                  par\n    parable              parabl\n    paracelsus           paracelsu\n    paradise             paradis\n    paradox              paradox\n    paradoxes            paradox\n    paragon              paragon\n    paragons             paragon\n    parallel             parallel\n    parallels            parallel\n    paramour             paramour\n    paramours            paramour\n    parapets             parapet\n    paraquito            paraquito\n    parasite             parasit\n    parasites            parasit\n    parca                parca\n    parcel               parcel\n    parcell              parcel\n    parcels              parcel\n    parch                parch\n    parched              parch\n    parching             parch\n    parchment            parchment\n    pard                 pard\n    pardon               pardon\n    pardona              pardona\n    pardoned             pardon\n    pardoner             pardon\n    pardoning            pardon\n    pardonne             pardonn\n    pardonner            pardonn\n    pardonnez            pardonnez\n    pardons              pardon\n    pare                 pare\n    pared                pare\n    parel                parel\n    parent               parent\n    parentage            parentag\n    parents              parent\n    parfect              parfect\n    paring               pare\n    parings              pare\n    paris                pari\n    parish               parish\n    parishioners         parishion\n    parisians            parisian\n    paritors             paritor\n    park                 park\n    parks                park\n    parle                parl\n    parler               parler\n    parles               parl\n    parley               parlei\n    parlez               parlez\n    parliament           parliament\n    parlors              parlor\n    parlour              parlour\n    parlous              parlou\n    parmacity            parmac\n    parolles             parol\n    parricide            parricid\n    parricides           parricid\n    parrot               parrot\n    parrots              parrot\n    parsley              parslei\n    parson               parson\n    part                 part\n    partake              partak\n    partaken             partaken\n    partaker             partak\n    partakers            partak\n    parted               part\n    parthia              parthia\n    parthian             parthian\n    parthians            parthian\n    parti                parti\n    partial              partial\n    partialize           partial\n    partially            partial\n    participate          particip\n    participation        particip\n    particle             particl\n    particular           particular\n    particularities      particular\n    particularize        particular\n    particularly         particularli\n    particulars          particular\n    parties              parti\n    parting              part\n    partisan             partisan\n    partisans            partisan\n    partition            partit\n    partizan             partizan\n    partlet              partlet\n    partly               partli\n    partner              partner\n    partners             partner\n    partridge            partridg\n    parts                part\n    party                parti\n    pas                  pa\n    pash                 pash\n    pashed               pash\n    pashful              pash\n    pass                 pass\n    passable             passabl\n    passado              passado\n    passage              passag\n    passages             passag\n    passant              passant\n    passed               pass\n    passenger            passeng\n    passengers           passeng\n    passes               pass\n    passeth              passeth\n    passing              pass\n    passio               passio\n    passion              passion\n    passionate           passion\n    passioning           passion\n    passions             passion\n    passive              passiv\n    passport             passport\n    passy                passi\n    past                 past\n    paste                past\n    pasterns             pastern\n    pasties              pasti\n    pastime              pastim\n    pastimes             pastim\n    pastoral             pastor\n    pastorals            pastor\n    pastors              pastor\n    pastry               pastri\n    pasture              pastur\n    pastures             pastur\n    pasty                pasti\n    pat                  pat\n    patay                patai\n    patch                patch\n    patchery             patcheri\n    patches              patch\n    pate                 pate\n    pated                pate\n    patent               patent\n    patents              patent\n    paternal             patern\n    pates                pate\n    path                 path\n    pathetical           pathet\n    paths                path\n    pathway              pathwai\n    pathways             pathwai\n    patience             patienc\n    patient              patient\n    patiently            patient\n    patients             patient\n    patines              patin\n    patrician            patrician\n    patricians           patrician\n    patrick              patrick\n    patrimony            patrimoni\n    patroclus            patroclu\n    patron               patron\n    patronage            patronag\n    patroness            patro\n    patrons              patron\n    patrum               patrum\n    patter               patter\n    pattern              pattern\n    patterns             pattern\n    pattle               pattl\n    pauca                pauca\n    paucas               pauca\n    paul                 paul\n    paulina              paulina\n    paunch               paunch\n    paunches             paunch\n    pause                paus\n    pauser               pauser\n    pauses               paus\n    pausingly            pausingli\n    pauvres              pauvr\n    pav                  pav\n    paved                pave\n    pavement             pavement\n    pavilion             pavilion\n    pavilions            pavilion\n    pavin                pavin\n    paw                  paw\n    pawn                 pawn\n    pawns                pawn\n    paws                 paw\n    pax                  pax\n    pay                  pai\n    payest               payest\n    paying               pai\n    payment              payment\n    payments             payment\n    pays                 pai\n    paysan               paysan\n    paysans              paysan\n    pe                   pe\n    peace                peac\n    peaceable            peaceabl\n    peaceably            peaceabl\n    peaceful             peac\n    peacemakers          peacemak\n    peaces               peac\n    peach                peach\n    peaches              peach\n    peacock              peacock\n    peacocks             peacock\n    peak                 peak\n    peaking              peak\n    peal                 peal\n    peals                peal\n    pear                 pear\n    peard                peard\n    pearl                pearl\n    pearls               pearl\n    pears                pear\n    peas                 pea\n    peasant              peasant\n    peasantry            peasantri\n    peasants             peasant\n    peascod              peascod\n    pease                peas\n    peaseblossom         peaseblossom\n    peat                 peat\n    peaten               peaten\n    peating              peat\n    pebble               pebbl\n    pebbled              pebbl\n    pebbles              pebbl\n    peck                 peck\n    pecks                peck\n    peculiar             peculiar\n    pecus                pecu\n    pedant               pedant\n    pedantical           pedant\n    pedascule            pedascul\n    pede                 pede\n    pedestal             pedest\n    pedigree             pedigre\n    pedlar               pedlar\n    pedlars              pedlar\n    pedro                pedro\n    peds                 ped\n    peel                 peel\n    peep                 peep\n    peeped               peep\n    peeping              peep\n    peeps                peep\n    peer                 peer\n    peereth              peereth\n    peering              peer\n    peerless             peerless\n    peers                peer\n    peesel               peesel\n    peevish              peevish\n    peevishly            peevishli\n    peflur               peflur\n    peg                  peg\n    pegasus              pegasu\n    pegs                 peg\n    peise                peis\n    peised               peis\n    peize                peiz\n    pelf                 pelf\n    pelican              pelican\n    pelion               pelion\n    pell                 pell\n    pella                pella\n    pelleted             pellet\n    peloponnesus         peloponnesu\n    pelt                 pelt\n    pelting              pelt\n    pembroke             pembrok\n    pen                  pen\n    penalties            penalti\n    penalty              penalti\n    penance              penanc\n    pence                penc\n    pencil               pencil\n    pencill              pencil\n    pencils              pencil\n    pendant              pendant\n    pendent              pendent\n    pendragon            pendragon\n    pendulous            pendul\n    penelope             penelop\n    penetrable           penetr\n    penetrate            penetr\n    penetrative          penetr\n    penitence            penit\n    penitent             penit\n    penitential          penitenti\n    penitently           penit\n    penitents            penit\n    penker               penker\n    penknife             penknif\n    penn                 penn\n    penned               pen\n    penning              pen\n    pennons              pennon\n    penny                penni\n    pennyworth           pennyworth\n    pennyworths          pennyworth\n    pens                 pen\n    pense                pens\n    pension              pension\n    pensioners           pension\n    pensive              pensiv\n    pensived             pensiv\n    pensively            pensiv\n    pent                 pent\n    pentecost            pentecost\n    penthesilea          penthesilea\n    penthouse            penthous\n    penurious            penuri\n    penury               penuri\n    peopl                peopl\n    people               peopl\n    peopled              peopl\n    peoples              peopl\n    pepin                pepin\n    pepper               pepper\n    peppercorn           peppercorn\n    peppered             pepper\n    per                  per\n    peradventure         peradventur\n    peradventures        peradventur\n    perceiv              perceiv\n    perceive             perceiv\n    perceived            perceiv\n    perceives            perceiv\n    perceiveth           perceiveth\n    perch                perch\n    perchance            perchanc\n    percies              perci\n    percussion           percuss\n    percy                perci\n    perdie               perdi\n    perdita              perdita\n    perdition            perdit\n    perdonato            perdonato\n    perdu                perdu\n    perdurable           perdur\n    perdurably           perdur\n    perdy                perdi\n    pere                 pere\n    peregrinate          peregrin\n    peremptorily         peremptorili\n    peremptory           peremptori\n    perfect              perfect\n    perfected            perfect\n    perfecter            perfect\n    perfectest           perfectest\n    perfection           perfect\n    perfections          perfect\n    perfectly            perfectli\n    perfectness          perfect\n    perfidious           perfidi\n    perfidiously         perfidi\n    perforce             perforc\n    perform              perform\n    performance          perform\n    performances         perform\n    performed            perform\n    performer            perform\n    performers           perform\n    performing           perform\n    performs             perform\n    perfum               perfum\n    perfume              perfum\n    perfumed             perfum\n    perfumer             perfum\n    perfumes             perfum\n    perge                perg\n    perhaps              perhap\n    periapts             periapt\n    perigort             perigort\n    perigouna            perigouna\n    peril                peril\n    perilous             peril\n    perils               peril\n    period               period\n    periods              period\n    perish               perish\n    perished             perish\n    perishest            perishest\n    perisheth            perisheth\n    perishing            perish\n    periwig              periwig\n    perjur               perjur\n    perjure              perjur\n    perjured             perjur\n    perjuries            perjuri\n    perjury              perjuri\n    perk                 perk\n    perkes               perk\n    permafoy             permafoi\n    permanent            perman\n    permission           permiss\n    permissive           permiss\n    permit               permit\n    permitted            permit\n    pernicious           pernici\n    perniciously         pernici\n    peroration           peror\n    perpend              perpend\n    perpendicular        perpendicular\n    perpendicularly      perpendicularli\n    perpetual            perpetu\n    perpetually          perpetu\n    perpetuity           perpetu\n    perplex              perplex\n    perplexed            perplex\n    perplexity           perplex\n    pers                 per\n    persecuted           persecut\n    persecutions         persecut\n    persecutor           persecutor\n    perseus              perseu\n    persever             persev\n    perseverance         persever\n    persevers            persev\n    persia               persia\n    persian              persian\n    persist              persist\n    persisted            persist\n    persistency          persist\n    persistive           persist\n    persists             persist\n    person               person\n    personae             persona\n    personage            personag\n    personages           personag\n    personal             person\n    personally           person\n    personate            person\n    personated           person\n    personates           person\n    personating          person\n    persons              person\n    perspective          perspect\n    perspectively        perspect\n    perspectives         perspect\n    perspicuous          perspicu\n    persuade             persuad\n    persuaded            persuad\n    persuades            persuad\n    persuading           persuad\n    persuasion           persuas\n    persuasions          persuas\n    pert                 pert\n    pertain              pertain\n    pertaining           pertain\n    pertains             pertain\n    pertaunt             pertaunt\n    pertinent            pertin\n    pertly               pertli\n    perturb              perturb\n    perturbation         perturb\n    perturbations        perturb\n    perturbed            perturb\n    perus                peru\n    perusal              perus\n    peruse               perus\n    perused              perus\n    perusing             perus\n    perverse             pervers\n    perversely           pervers\n    perverseness         pervers\n    pervert              pervert\n    perverted            pervert\n    peseech              peseech\n    pest                 pest\n    pester               pester\n    pestiferous          pestifer\n    pestilence           pestil\n    pestilent            pestil\n    pet                  pet\n    petar                petar\n    peter                peter\n    petit                petit\n    petition             petit\n    petitionary          petitionari\n    petitioner           petition\n    petitioners          petition\n    petitions            petit\n    peto                 peto\n    petrarch             petrarch\n    petruchio            petruchio\n    petter               petter\n    petticoat            petticoat\n    petticoats           petticoat\n    pettiness            petti\n    pettish              pettish\n    pettitoes            pettito\n    petty                petti\n    peu                  peu\n    pew                  pew\n    pewter               pewter\n    pewterer             pewter\n    phaethon             phaethon\n    phaeton              phaeton\n    phantasime           phantasim\n    phantasimes          phantasim\n    phantasma            phantasma\n    pharamond            pharamond\n    pharaoh              pharaoh\n    pharsalia            pharsalia\n    pheasant             pheasant\n    pheazar              pheazar\n    phebe                phebe\n    phebes               phebe\n    pheebus              pheebu\n    pheeze               pheez\n    phibbus              phibbu\n    philadelphos         philadelpho\n    philario             philario\n    philarmonus          philarmonu\n    philemon             philemon\n    philip               philip\n    philippan            philippan\n    philippe             philipp\n    philippi             philippi\n    phillida             phillida\n    philo                philo\n    philomel             philomel\n    philomela            philomela\n    philosopher          philosoph\n    philosophers         philosoph\n    philosophical        philosoph\n    philosophy           philosophi\n    philostrate          philostr\n    philotus             philotu\n    phlegmatic           phlegmat\n    phoebe               phoeb\n    phoebus              phoebu\n    phoenicia            phoenicia\n    phoenicians          phoenician\n    phoenix              phoenix\n    phorbus              phorbu\n    photinus             photinu\n    phrase               phrase\n    phraseless           phraseless\n    phrases              phrase\n    phrygia              phrygia\n    phrygian             phrygian\n    phrynia              phrynia\n    physic               physic\n    physical             physic\n    physician            physician\n    physicians           physician\n    physics              physic\n    pia                  pia\n    pibble               pibbl\n    pible                pibl\n    picardy              picardi\n    pick                 pick\n    pickaxe              pickax\n    pickaxes             pickax\n    pickbone             pickbon\n    picked               pick\n    pickers              picker\n    picking              pick\n    pickle               pickl\n    picklock             picklock\n    pickpurse            pickpurs\n    picks                pick\n    pickt                pickt\n    pickthanks           pickthank\n    pictur               pictur\n    picture              pictur\n    pictured             pictur\n    pictures             pictur\n    pid                  pid\n    pie                  pie\n    piec                 piec\n    piece                piec\n    pieces               piec\n    piecing              piec\n    pied                 pi\n    piedness             pied\n    pier                 pier\n    pierc                pierc\n    pierce               pierc\n    pierced              pierc\n    pierces              pierc\n    pierceth             pierceth\n    piercing             pierc\n    piercy               pierci\n    piers                pier\n    pies                 pi\n    piety                pieti\n    pig                  pig\n    pigeon               pigeon\n    pigeons              pigeon\n    pight                pight\n    pigmy                pigmi\n    pigrogromitus        pigrogromitu\n    pike                 pike\n    pikes                pike\n    pil                  pil\n    pilate               pilat\n    pilates              pilat\n    pilchers             pilcher\n    pile                 pile\n    piles                pile\n    pilf                 pilf\n    pilfering            pilfer\n    pilgrim              pilgrim\n    pilgrimage           pilgrimag\n    pilgrims             pilgrim\n    pill                 pill\n    pillage              pillag\n    pillagers            pillag\n    pillar               pillar\n    pillars              pillar\n    pillicock            pillicock\n    pillory              pillori\n    pillow               pillow\n    pillows              pillow\n    pills                pill\n    pilot                pilot\n    pilots               pilot\n    pimpernell           pimpernel\n    pin                  pin\n    pinch                pinch\n    pinched              pinch\n    pinches              pinch\n    pinching             pinch\n    pindarus             pindaru\n    pine                 pine\n    pined                pine\n    pines                pine\n    pinfold              pinfold\n    pining               pine\n    pinion               pinion\n    pink                 pink\n    pinn                 pinn\n    pinnace              pinnac\n    pins                 pin\n    pinse                pins\n    pint                 pint\n    pintpot              pintpot\n    pioned               pion\n    pioneers             pioneer\n    pioner               pioner\n    pioners              pioner\n    pious                piou\n    pip                  pip\n    pipe                 pipe\n    piper                piper\n    pipers               piper\n    pipes                pipe\n    piping               pipe\n    pippin               pippin\n    pippins              pippin\n    pirate               pirat\n    pirates              pirat\n    pisa                 pisa\n    pisanio              pisanio\n    pish                 pish\n    pismires             pismir\n    piss                 piss\n    pissing              piss\n    pistol               pistol\n    pistols              pistol\n    pit                  pit\n    pitch                pitch\n    pitched              pitch\n    pitcher              pitcher\n    pitchers             pitcher\n    pitchy               pitchi\n    piteous              piteou\n    piteously            piteous\n    pitfall              pitfal\n    pith                 pith\n    pithless             pithless\n    pithy                pithi\n    pitie                piti\n    pitied               piti\n    pities               piti\n    pitiful              piti\n    pitifully            pitifulli\n    pitiless             pitiless\n    pits                 pit\n    pittance             pittanc\n    pittie               pitti\n    pittikins            pittikin\n    pity                 piti\n    pitying              piti\n    pius                 piu\n    plac                 plac\n    place                place\n    placed               place\n    placentio            placentio\n    places               place\n    placeth              placeth\n    placid               placid\n    placing              place\n    plack                plack\n    placket              placket\n    plackets             placket\n    plagu                plagu\n    plague               plagu\n    plagued              plagu\n    plagues              plagu\n    plaguing             plagu\n    plaguy               plagui\n    plain                plain\n    plainer              plainer\n    plainest             plainest\n    plaining             plain\n    plainings            plain\n    plainly              plainli\n    plainness            plain\n    plains               plain\n    plainsong            plainsong\n    plaintful            plaint\n    plaintiff            plaintiff\n    plaintiffs           plaintiff\n    plaints              plaint\n    planched             planch\n    planet               planet\n    planetary            planetari\n    planets              planet\n    planks               plank\n    plant                plant\n    plantage             plantag\n    plantagenet          plantagenet\n    plantagenets         plantagenet\n    plantain             plantain\n    plantation           plantat\n    planted              plant\n    planteth             planteth\n    plants               plant\n    plash                plash\n    plashy               plashi\n    plast                plast\n    plaster              plaster\n    plasterer            plaster\n    plat                 plat\n    plate                plate\n    plated               plate\n    plates               plate\n    platform             platform\n    platforms            platform\n    plats                plat\n    platted              plat\n    plausible            plausibl\n    plausive             plausiv\n    plautus              plautu\n    play                 plai\n    played               plai\n    player               player\n    players              player\n    playeth              playeth\n    playfellow           playfellow\n    playfellows          playfellow\n    playhouse            playhous\n    playing              plai\n    plays                plai\n    plea                 plea\n    pleach               pleach\n    pleached             pleach\n    plead                plead\n    pleaded              plead\n    pleader              pleader\n    pleaders             pleader\n    pleading             plead\n    pleads               plead\n    pleas                plea\n    pleasance            pleasanc\n    pleasant             pleasant\n    pleasantly           pleasantli\n    please               pleas\n    pleased              pleas\n    pleaser              pleaser\n    pleasers             pleaser\n    pleases              pleas\n    pleasest             pleasest\n    pleaseth             pleaseth\n    pleasing             pleas\n    pleasure             pleasur\n    pleasures            pleasur\n    plebeians            plebeian\n    plebeii              plebeii\n    plebs                pleb\n    pledge               pledg\n    pledges              pledg\n    pleines              plein\n    plenitude            plenitud\n    plenteous            plenteou\n    plenteously          plenteous\n    plenties             plenti\n    plentiful            plenti\n    plentifully          plentifulli\n    plenty               plenti\n    pless                pless\n    plessed              pless\n    plessing             pless\n    pliant               pliant\n    plied                pli\n    plies                pli\n    plight               plight\n    plighted             plight\n    plighter             plighter\n    plod                 plod\n    plodded              plod\n    plodders             plodder\n    plodding             plod\n    plods                plod\n    plood                plood\n    ploody               ploodi\n    plot                 plot\n    plots                plot\n    plotted              plot\n    plotter              plotter\n    plough               plough\n    ploughed             plough\n    ploughman            ploughman\n    ploughmen            ploughmen\n    plow                 plow\n    plows                plow\n    pluck                pluck\n    plucked              pluck\n    plucker              plucker\n    plucking             pluck\n    plucks               pluck\n    plue                 plue\n    plum                 plum\n    plume                plume\n    plumed               plume\n    plumes               plume\n    plummet              plummet\n    plump                plump\n    plumpy               plumpi\n    plums                plum\n    plung                plung\n    plunge               plung\n    plunged              plung\n    plural               plural\n    plurisy              plurisi\n    plus                 plu\n    pluto                pluto\n    plutus               plutu\n    ply                  ply\n    po                   po\n    pocket               pocket\n    pocketing            pocket\n    pockets              pocket\n    pocky                pocki\n    pody                 podi\n    poem                 poem\n    poesy                poesi\n    poet                 poet\n    poetical             poetic\n    poetry               poetri\n    poets                poet\n    poictiers            poictier\n    poinards             poinard\n    poins                poin\n    point                point\n    pointblank           pointblank\n    pointed              point\n    pointing             point\n    points               point\n    pois                 poi\n    poise                pois\n    poising              pois\n    poison               poison\n    poisoned             poison\n    poisoner             poison\n    poisoning            poison\n    poisonous            poison\n    poisons              poison\n    poke                 poke\n    poking               poke\n    pol                  pol\n    polack               polack\n    polacks              polack\n    poland               poland\n    pold                 pold\n    pole                 pole\n    poleaxe              poleax\n    polecat              polecat\n    polecats             polecat\n    polemon              polemon\n    poles                pole\n    poli                 poli\n    policies             polici\n    policy               polici\n    polish               polish\n    polished             polish\n    politic              polit\n    politician           politician\n    politicians          politician\n    politicly            politicli\n    polixenes            polixen\n    poll                 poll\n    polluted             pollut\n    pollution            pollut\n    polonius             poloniu\n    poltroons            poltroon\n    polusion             polus\n    polydamus            polydamu\n    polydore             polydor\n    polyxena             polyxena\n    pomander             pomand\n    pomegranate          pomegran\n    pomewater            pomewat\n    pomfret              pomfret\n    pomgarnet            pomgarnet\n    pommel               pommel\n    pomp                 pomp\n    pompeius             pompeiu\n    pompey               pompei\n    pompion              pompion\n    pompous              pompou\n    pomps                pomp\n    pond                 pond\n    ponder               ponder\n    ponderous            ponder\n    ponds                pond\n    poniard              poniard\n    poniards             poniard\n    pont                 pont\n    pontic               pontic\n    pontifical           pontif\n    ponton               ponton\n    pooh                 pooh\n    pool                 pool\n    poole                pool\n    poop                 poop\n    poor                 poor\n    poorer               poorer\n    poorest              poorest\n    poorly               poorli\n    pop                  pop\n    pope                 pope\n    popedom              popedom\n    popilius             popiliu\n    popingay             popingai\n    popish               popish\n    popp                 popp\n    poppy                poppi\n    pops                 pop\n    popular              popular\n    popularity           popular\n    populous             popul\n    porch                porch\n    porches              porch\n    pore                 pore\n    poring               pore\n    pork                 pork\n    porn                 porn\n    porpentine           porpentin\n    porridge             porridg\n    porringer            porring\n    port                 port\n    portable             portabl\n    portage              portag\n    portal               portal\n    portance             portanc\n    portcullis           portculli\n    portend              portend\n    portends             portend\n    portent              portent\n    portentous           portent\n    portents             portent\n    porter               porter\n    porters              porter\n    portia               portia\n    portion              portion\n    portly               portli\n    portotartarossa      portotartarossa\n    portrait             portrait\n    portraiture          portraitur\n    ports                port\n    portugal             portug\n    pose                 pose\n    posied               posi\n    posies               posi\n    position             posit\n    positive             posit\n    positively           posit\n    posse                poss\n    possess              possess\n    possessed            possess\n    possesses            possess\n    possesseth           possesseth\n    possessing           possess\n    possession           possess\n    possessions          possess\n    possessor            possessor\n    posset               posset\n    possets              posset\n    possibilities        possibl\n    possibility          possibl\n    possible             possibl\n    possibly             possibl\n    possitable           possit\n    post                 post\n    poste                post\n    posted               post\n    posterior            posterior\n    posteriors           posterior\n    posterity            poster\n    postern              postern\n    posterns             postern\n    posters              poster\n    posthorse            posthors\n    posthorses           posthors\n    posthumus            posthumu\n    posting              post\n    postmaster           postmast\n    posts                post\n    postscript           postscript\n    posture              postur\n    postures             postur\n    posy                 posi\n    pot                  pot\n    potable              potabl\n    potations            potat\n    potato               potato\n    potatoes             potato\n    potch                potch\n    potency              potenc\n    potent               potent\n    potentates           potent\n    potential            potenti\n    potently             potent\n    potents              potent\n    pothecary            pothecari\n    pother               pother\n    potion               potion\n    potions              potion\n    potpan               potpan\n    pots                 pot\n    potter               potter\n    potting              pot\n    pottle               pottl\n    pouch                pouch\n    poulter              poulter\n    poultice             poultic\n    poultney             poultnei\n    pouncet              pouncet\n    pound                pound\n    pounds               pound\n    pour                 pour\n    pourest              pourest\n    pouring              pour\n    pourquoi             pourquoi\n    pours                pour\n    pout                 pout\n    poverty              poverti\n    pow                  pow\n    powd                 powd\n    powder               powder\n    power                power\n    powerful             power\n    powerfully           powerfulli\n    powerless            powerless\n    powers               power\n    pox                  pox\n    poys                 poi\n    poysam               poysam\n    prabbles             prabbl\n    practic              practic\n    practice             practic\n    practiced            practic\n    practicer            practic\n    practices            practic\n    practicing           practic\n    practis              practi\n    practisants          practis\n    practise             practis\n    practiser            practis\n    practisers           practis\n    practises            practis\n    practising           practis\n    praeclarissimus      praeclarissimu\n    praemunire           praemunir\n    praetor              praetor\n    praetors             praetor\n    pragging             prag\n    prague               pragu\n    prain                prain\n    prains               prain\n    prais                prai\n    praise               prais\n    praised              prais\n    praises              prais\n    praisest             praisest\n    praiseworthy         praiseworthi\n    praising             prais\n    prancing             pranc\n    prank                prank\n    pranks               prank\n    prat                 prat\n    prate                prate\n    prated               prate\n    prater               prater\n    prating              prate\n    prattle              prattl\n    prattler             prattler\n    prattling            prattl\n    prave                prave\n    prawls               prawl\n    prawns               prawn\n    pray                 prai\n    prayer               prayer\n    prayers              prayer\n    praying              prai\n    prays                prai\n    pre                  pre\n    preach               preach\n    preached             preach\n    preachers            preacher\n    preaches             preach\n    preaching            preach\n    preachment           preachment\n    pread                pread\n    preambulate          preambul\n    precedence           preced\n    precedent            preced\n    preceding            preced\n    precept              precept\n    preceptial           precepti\n    precepts             precept\n    precinct             precinct\n    precious             preciou\n    preciously           precious\n    precipice            precipic\n    precipitating        precipit\n    precipitation        precipit\n    precise              precis\n    precisely            precis\n    preciseness          precis\n    precisian            precisian\n    precor               precor\n    precurse             precurs\n    precursors           precursor\n    predeceased          predeceas\n    predecessor          predecessor\n    predecessors         predecessor\n    predestinate         predestin\n    predicament          predica\n    predict              predict\n    prediction           predict\n    predictions          predict\n    predominance         predomin\n    predominant          predomin\n    predominate          predomin\n    preeches             preech\n    preeminence          preemin\n    preface              prefac\n    prefer               prefer\n    preferment           prefer\n    preferments          prefer\n    preferr              preferr\n    preferreth           preferreth\n    preferring           prefer\n    prefers              prefer\n    prefiguring          prefigur\n    prefix               prefix\n    prefixed             prefix\n    preformed            preform\n    pregnancy            pregnanc\n    pregnant             pregnant\n    pregnantly           pregnantli\n    prejudicates         prejud\n    prejudice            prejudic\n    prejudicial          prejudici\n    prelate              prelat\n    premeditated         premedit\n    premeditation        premedit\n    premised             premis\n    premises             premis\n    prenez               prenez\n    prenominate          prenomin\n    prentice             prentic\n    prentices            prentic\n    preordinance         preordin\n    prepar               prepar\n    preparation          prepar\n    preparations         prepar\n    prepare              prepar\n    prepared             prepar\n    preparedly           preparedli\n    prepares             prepar\n    preparing            prepar\n    prepost              prepost\n    preposterous         preposter\n    preposterously       preposter\n    prerogatifes         prerogatif\n    prerogative          prerog\n    prerogatived         prerogativ\n    presage              presag\n    presagers            presag\n    presages             presag\n    presageth            presageth\n    presaging            presag\n    prescience           prescienc\n    prescribe            prescrib\n    prescript            prescript\n    prescription         prescript\n    prescriptions        prescript\n    prescripts           prescript\n    presence             presenc\n    presences            presenc\n    present              present\n    presentation         present\n    presented            present\n    presenter            present\n    presenters           present\n    presenteth           presenteth\n    presenting           present\n    presently            present\n    presentment          present\n    presents             present\n    preserv              preserv\n    preservation         preserv\n    preservative         preserv\n    preserve             preserv\n    preserved            preserv\n    preserver            preserv\n    preservers           preserv\n    preserving           preserv\n    president            presid\n    press                press\n    pressed              press\n    presser              presser\n    presses              press\n    pressing             press\n    pressure             pressur\n    pressures            pressur\n    prest                prest\n    prester              prester\n    presume              presum\n    presumes             presum\n    presuming            presum\n    presumption          presumpt\n    presumptuous         presumptu\n    presuppos            presuppo\n    pret                 pret\n    pretence             pretenc\n    pretences            pretenc\n    pretend              pretend\n    pretended            pretend\n    pretending           pretend\n    pretense             pretens\n    pretext              pretext\n    pretia               pretia\n    prettier             prettier\n    prettiest            prettiest\n    prettily             prettili\n    prettiness           pretti\n    pretty               pretti\n    prevail              prevail\n    prevailed            prevail\n    prevaileth           prevaileth\n    prevailing           prevail\n    prevailment          prevail\n    prevails             prevail\n    prevent              prevent\n    prevented            prevent\n    prevention           prevent\n    preventions          prevent\n    prevents             prevent\n    prey                 prei\n    preyful              prey\n    preys                prei\n    priam                priam\n    priami               priami\n    priamus              priamu\n    pribbles             pribbl\n    price                price\n    prick                prick\n    pricked              prick\n    pricket              pricket\n    pricking             prick\n    pricks               prick\n    pricksong            pricksong\n    pride                pride\n    prides               pride\n    pridge               pridg\n    prie                 prie\n    pried                pri\n    prief                prief\n    pries                pri\n    priest               priest\n    priesthood           priesthood\n    priests              priest\n    prig                 prig\n    primal               primal\n    prime                prime\n    primer               primer\n    primero              primero\n    primest              primest\n    primitive            primit\n    primo                primo\n    primogenity          primogen\n    primrose             primros\n    primroses            primros\n    primy                primi\n    prince               princ\n    princely             princ\n    princes              princ\n    princess             princess\n    principal            princip\n    principalities       princip\n    principality         princip\n    principle            principl\n    principles           principl\n    princox              princox\n    prings               pring\n    print                print\n    printed              print\n    printing             print\n    printless            printless\n    prints               print\n    prioress             prioress\n    priories             priori\n    priority             prioriti\n    priory               priori\n    priscian             priscian\n    prison               prison\n    prisoner             prison\n    prisoners            prison\n    prisonment           prison\n    prisonnier           prisonni\n    prisons              prison\n    pristine             pristin\n    prithe               prith\n    prithee              prithe\n    privacy              privaci\n    private              privat\n    privately            privat\n    privates             privat\n    privilage            privilag\n    privileg             privileg\n    privilege            privileg\n    privileged           privileg\n    privileges           privileg\n    privilegio           privilegio\n    privily              privili\n    privity              priviti\n    privy                privi\n    priz                 priz\n    prize                prize\n    prized               prize\n    prizer               prizer\n    prizes               prize\n    prizest              prizest\n    prizing              prize\n    pro                  pro\n    probable             probabl\n    probal               probal\n    probation            probat\n    proceed              proce\n    proceeded            proceed\n    proceeders           proceed\n    proceeding           proceed\n    proceedings          proceed\n    proceeds             proce\n    process              process\n    procession           process\n    proclaim             proclaim\n    proclaimed           proclaim\n    proclaimeth          proclaimeth\n    proclaims            proclaim\n    proclamation         proclam\n    proclamations        proclam\n    proconsul            proconsul\n    procrastinate        procrastin\n    procreant            procreant\n    procreants           procreant\n    procreation          procreat\n    procrus              procru\n    proculeius           proculeiu\n    procur               procur\n    procurator           procur\n    procure              procur\n    procured             procur\n    procures             procur\n    procuring            procur\n    prodigal             prodig\n    prodigality          prodig\n    prodigally           prodig\n    prodigals            prodig\n    prodigies            prodigi\n    prodigious           prodigi\n    prodigiously         prodigi\n    prodigy              prodigi\n    proditor             proditor\n    produc               produc\n    produce              produc\n    produced             produc\n    produces             produc\n    producing            produc\n    proface              profac\n    profan               profan\n    profanation          profan\n    profane              profan\n    profaned             profan\n    profanely            profan\n    profaneness          profan\n    profaners            profan\n    profaning            profan\n    profess              profess\n    professed            profess\n    professes            profess\n    profession           profess\n    professions          profess\n    professors           professor\n    proffer              proffer\n    proffered            proffer\n    profferer            proffer\n    proffers             proffer\n    proficient           profici\n    profit               profit\n    profitable           profit\n    profitably           profit\n    profited             profit\n    profiting            profit\n    profitless           profitless\n    profits              profit\n    profound             profound\n    profoundest          profoundest\n    profoundly           profoundli\n    progenitors          progenitor\n    progeny              progeni\n    progne               progn\n    prognosticate        prognost\n    prognostication      prognost\n    progress             progress\n    progression          progress\n    prohibit             prohibit\n    prohibition          prohibit\n    project              project\n    projection           project\n    projects             project\n    prolixious           prolixi\n    prolixity            prolix\n    prologue             prologu\n    prologues            prologu\n    prolong              prolong\n    prolongs             prolong\n    promethean           promethean\n    prometheus           prometheu\n    promis               promi\n    promise              promis\n    promised             promis\n    promises             promis\n    promiseth            promiseth\n    promising            promis\n    promontory           promontori\n    promotion            promot\n    promotions           promot\n    prompt               prompt\n    prompted             prompt\n    promptement          promptement\n    prompter             prompter\n    prompting            prompt\n    prompts              prompt\n    prompture            promptur\n    promulgate           promulg\n    prone                prone\n    prononcer            prononc\n    prononcez            prononcez\n    pronoun              pronoun\n    pronounc             pronounc\n    pronounce            pronounc\n    pronounced           pronounc\n    pronouncing          pronounc\n    pronouns             pronoun\n    proof                proof\n    proofs               proof\n    prop                 prop\n    propagate            propag\n    propagation          propag\n    propend              propend\n    propension           propens\n    proper               proper\n    properer             proper\n    properly             properli\n    propertied           properti\n    properties           properti\n    property             properti\n    prophecies           propheci\n    prophecy             propheci\n    prophesied           prophesi\n    prophesier           prophesi\n    prophesy             prophesi\n    prophesying          prophesi\n    prophet              prophet\n    prophetess           prophetess\n    prophetic            prophet\n    prophetically        prophet\n    prophets             prophet\n    propinquity          propinqu\n    propontic            propont\n    proportion           proport\n    proportionable       proportion\n    proportions          proport\n    propos               propo\n    propose              propos\n    proposed             propos\n    proposer             propos\n    proposes             propos\n    proposing            propos\n    proposition          proposit\n    propositions         proposit\n    propounded           propound\n    propp                propp\n    propre               propr\n    propriety            proprieti\n    props                prop\n    propugnation         propugn\n    prorogue             prorogu\n    prorogued            prorogu\n    proscription         proscript\n    proscriptions        proscript\n    prose                prose\n    prosecute            prosecut\n    prosecution          prosecut\n    proselytes           proselyt\n    proserpina           proserpina\n    prosp                prosp\n    prospect             prospect\n    prosper              prosper\n    prosperity           prosper\n    prospero             prospero\n    prosperous           prosper\n    prosperously         prosper\n    prospers             prosper\n    prostitute           prostitut\n    prostrate            prostrat\n    protect              protect\n    protected            protect\n    protection           protect\n    protector            protector\n    protectors           protector\n    protectorship        protectorship\n    protectress          protectress\n    protects             protect\n    protest              protest\n    protestation         protest\n    protestations        protest\n    protested            protest\n    protester            protest\n    protesting           protest\n    protests             protest\n    proteus              proteu\n    protheus             protheu\n    protract             protract\n    protractive          protract\n    proud                proud\n    prouder              prouder\n    proudest             proudest\n    proudlier            proudlier\n    proudly              proudli\n    prouds               proud\n    prov                 prov\n    provand              provand\n    prove                prove\n    proved               prove\n    provender            provend\n    proverb              proverb\n    proverbs             proverb\n    proves               prove\n    proveth              proveth\n    provide              provid\n    provided             provid\n    providence           provid\n    provident            provid\n    providently          provid\n    provider             provid\n    provides             provid\n    province             provinc\n    provinces            provinc\n    provincial           provinci\n    proving              prove\n    provision            provis\n    proviso              proviso\n    provocation          provoc\n    provok               provok\n    provoke              provok\n    provoked             provok\n    provoker             provok\n    provokes             provok\n    provoketh            provoketh\n    provoking            provok\n    provost              provost\n    prowess              prowess\n    prudence             prudenc\n    prudent              prudent\n    prun                 prun\n    prune                prune\n    prunes               prune\n    pruning              prune\n    pry                  pry\n    prying               pry\n    psalm                psalm\n    psalmist             psalmist\n    psalms               psalm\n    psalteries           psalteri\n    ptolemies            ptolemi\n    ptolemy              ptolemi\n    public               public\n    publican             publican\n    publication          public\n    publicly             publicli\n    publicola            publicola\n    publish              publish\n    published            publish\n    publisher            publish\n    publishing           publish\n    publius              publiu\n    pucelle              pucel\n    puck                 puck\n    pudder               pudder\n    pudding              pud\n    puddings             pud\n    puddle               puddl\n    puddled              puddl\n    pudency              pudenc\n    pueritia             pueritia\n    puff                 puff\n    puffing              puf\n    puffs                puff\n    pugging              pug\n    puis                 pui\n    puissance            puissanc\n    puissant             puissant\n    puke                 puke\n    puking               puke\n    pulcher              pulcher\n    puling               pule\n    pull                 pull\n    puller               puller\n    pullet               pullet\n    pulling              pull\n    pulls                pull\n    pulpit               pulpit\n    pulpiter             pulpit\n    pulpits              pulpit\n    pulse                puls\n    pulsidge             pulsidg\n    pump                 pump\n    pumpion              pumpion\n    pumps                pump\n    pun                  pun\n    punched              punch\n    punish               punish\n    punished             punish\n    punishes             punish\n    punishment           punish\n    punishments          punish\n    punk                 punk\n    punto                punto\n    puny                 puni\n    pupil                pupil\n    pupils               pupil\n    puppet               puppet\n    puppets              puppet\n    puppies              puppi\n    puppy                puppi\n    pur                  pur\n    purblind             purblind\n    purchas              purcha\n    purchase             purchas\n    purchased            purchas\n    purchases            purchas\n    purchaseth           purchaseth\n    purchasing           purchas\n    pure                 pure\n    purely               pure\n    purer                purer\n    purest               purest\n    purg                 purg\n    purgation            purgat\n    purgative            purg\n    purgatory            purgatori\n    purge                purg\n    purged               purg\n    purgers              purger\n    purging              purg\n    purifies             purifi\n    purifying            purifi\n    puritan              puritan\n    purity               puriti\n    purlieus             purlieu\n    purple               purpl\n    purpled              purpl\n    purples              purpl\n    purport              purport\n    purpos               purpo\n    purpose              purpos\n    purposed             purpos\n    purposely            purpos\n    purposes             purpos\n    purposeth            purposeth\n    purposing            purpos\n    purr                 purr\n    purs                 pur\n    purse                purs\n    pursents             pursent\n    purses               purs\n    pursu                pursu\n    pursue               pursu\n    pursued              pursu\n    pursuers             pursuer\n    pursues              pursu\n    pursuest             pursuest\n    pursueth             pursueth\n    pursuing             pursu\n    pursuit              pursuit\n    pursuivant           pursuiv\n    pursuivants          pursuiv\n    pursy                pursi\n    purus                puru\n    purveyor             purveyor\n    push                 push\n    pushes               push\n    pusillanimity        pusillanim\n    put                  put\n    putrefy              putrefi\n    putrified            putrifi\n    puts                 put\n    putter               putter\n    putting              put\n    puttock              puttock\n    puzzel               puzzel\n    puzzle               puzzl\n    puzzled              puzzl\n    puzzles              puzzl\n    py                   py\n    pygmalion            pygmalion\n    pygmies              pygmi\n    pygmy                pygmi\n    pyramid              pyramid\n    pyramides            pyramid\n    pyramids             pyramid\n    pyramis              pyrami\n    pyramises            pyramis\n    pyramus              pyramu\n    pyrenean             pyrenean\n    pyrrhus              pyrrhu\n    pythagoras           pythagora\n    qu                   qu\n    quadrangle           quadrangl\n    quae                 quae\n    quaff                quaff\n    quaffing             quaf\n    quagmire             quagmir\n    quail                quail\n    quailing             quail\n    quails               quail\n    quaint               quaint\n    quaintly             quaintli\n    quak                 quak\n    quake                quak\n    quakes               quak\n    qualification        qualif\n    qualified            qualifi\n    qualifies            qualifi\n    qualify              qualifi\n    qualifying           qualifi\n    qualite              qualit\n    qualities            qualiti\n    quality              qualiti\n    qualm                qualm\n    qualmish             qualmish\n    quam                 quam\n    quand                quand\n    quando               quando\n    quantities           quantiti\n    quantity             quantiti\n    quare                quar\n    quarrel              quarrel\n    quarrell             quarrel\n    quarreller           quarrel\n    quarrelling          quarrel\n    quarrelous           quarrel\n    quarrels             quarrel\n    quarrelsome          quarrelsom\n    quarries             quarri\n    quarry               quarri\n    quart                quart\n    quarter              quarter\n    quartered            quarter\n    quartering           quarter\n    quarters             quarter\n    quarts               quart\n    quasi                quasi\n    quat                 quat\n    quatch               quatch\n    quay                 quai\n    que                  que\n    quean                quean\n    queas                quea\n    queasiness           queasi\n    queasy               queasi\n    queen                queen\n    queens               queen\n    quell                quell\n    queller              queller\n    quench               quench\n    quenched             quench\n    quenching            quench\n    quenchless           quenchless\n    quern                quern\n    quest                quest\n    questant             questant\n    question             question\n    questionable         question\n    questioned           question\n    questioning          question\n    questionless         questionless\n    questions            question\n    questrists           questrist\n    quests               quest\n    queubus              queubu\n    qui                  qui\n    quick                quick\n    quicken              quicken\n    quickens             quicken\n    quicker              quicker\n    quicklier            quicklier\n    quickly              quickli\n    quickness            quick\n    quicksand            quicksand\n    quicksands           quicksand\n    quicksilverr         quicksilverr\n    quid                 quid\n    quiddities           quidditi\n    quiddits             quiddit\n    quier                quier\n    quiet                quiet\n    quieter              quieter\n    quietly              quietli\n    quietness            quiet\n    quietus              quietu\n    quill                quill\n    quillets             quillet\n    quills               quill\n    quilt                quilt\n    quinapalus           quinapalu\n    quince               quinc\n    quinces              quinc\n    quintain             quintain\n    quintessence         quintess\n    quintus              quintu\n    quip                 quip\n    quips                quip\n    quire                quir\n    quiring              quir\n    quirk                quirk\n    quirks               quirk\n    quis                 qui\n    quit                 quit\n    quite                quit\n    quits                quit\n    quittance            quittanc\n    quitted              quit\n    quitting             quit\n    quiver               quiver\n    quivering            quiver\n    quivers              quiver\n    quo                  quo\n    quod                 quod\n    quoifs               quoif\n    quoint               quoint\n    quoit                quoit\n    quoits               quoit\n    quondam              quondam\n    quoniam              quoniam\n    quote                quot\n    quoted               quot\n    quotes               quot\n    quoth                quoth\n    quotidian            quotidian\n    r                    r\n    rabbit               rabbit\n    rabble               rabbl\n    rabblement           rabblement\n    race                 race\n    rack                 rack\n    rackers              racker\n    racket               racket\n    rackets              racket\n    racking              rack\n    racks                rack\n    radiance             radianc\n    radiant              radiant\n    radish               radish\n    rafe                 rafe\n    raft                 raft\n    rag                  rag\n    rage                 rage\n    rages                rage\n    rageth               rageth\n    ragg                 ragg\n    ragged               rag\n    raggedness           ragged\n    raging               rage\n    ragozine             ragozin\n    rags                 rag\n    rah                  rah\n    rail                 rail\n    railed               rail\n    railer               railer\n    railest              railest\n    raileth              raileth\n    railing              rail\n    rails                rail\n    raiment              raiment\n    rain                 rain\n    rainbow              rainbow\n    raineth              raineth\n    raining              rain\n    rainold              rainold\n    rains                rain\n    rainy                raini\n    rais                 rai\n    raise                rais\n    raised               rais\n    raises               rais\n    raising              rais\n    raisins              raisin\n    rak                  rak\n    rake                 rake\n    rakers               raker\n    rakes                rake\n    ral                  ral\n    rald                 rald\n    ralph                ralph\n    ram                  ram\n    rambures             rambur\n    ramm                 ramm\n    rampallian           rampallian\n    rampant              rampant\n    ramping              ramp\n    rampir               rampir\n    ramps                ramp\n    rams                 ram\n    ramsey               ramsei\n    ramston              ramston\n    ran                  ran\n    rance                ranc\n    rancorous            rancor\n    rancors              rancor\n    rancour              rancour\n    random               random\n    rang                 rang\n    range                rang\n    ranged               rang\n    rangers              ranger\n    ranges               rang\n    ranging              rang\n    rank                 rank\n    ranker               ranker\n    rankest              rankest\n    ranking              rank\n    rankle               rankl\n    rankly               rankli\n    rankness             rank\n    ranks                rank\n    ransack              ransack\n    ransacking           ransack\n    ransom               ransom\n    ransomed             ransom\n    ransoming            ransom\n    ransomless           ransomless\n    ransoms              ransom\n    rant                 rant\n    ranting              rant\n    rap                  rap\n    rape                 rape\n    rapes                rape\n    rapier               rapier\n    rapiers              rapier\n    rapine               rapin\n    raps                 rap\n    rapt                 rapt\n    rapture              raptur\n    raptures             raptur\n    rar                  rar\n    rare                 rare\n    rarely               rare\n    rareness             rare\n    rarer                rarer\n    rarest               rarest\n    rarities             rariti\n    rarity               rariti\n    rascal               rascal\n    rascalliest          rascalliest\n    rascally             rascal\n    rascals              rascal\n    rased                rase\n    rash                 rash\n    rasher               rasher\n    rashly               rashli\n    rashness             rash\n    rat                  rat\n    ratcatcher           ratcatch\n    ratcliff             ratcliff\n    rate                 rate\n    rated                rate\n    rately               rate\n    rates                rate\n    rather               rather\n    ratherest            ratherest\n    ratified             ratifi\n    ratifiers            ratifi\n    ratify               ratifi\n    rating               rate\n    rational             ration\n    ratolorum            ratolorum\n    rats                 rat\n    ratsbane             ratsban\n    rattle               rattl\n    rattles              rattl\n    rattling             rattl\n    rature               ratur\n    raught               raught\n    rav                  rav\n    rave                 rave\n    ravel                ravel\n    raven                raven\n    ravening             raven\n    ravenous             raven\n    ravens               raven\n    ravenspurgh          ravenspurgh\n    raves                rave\n    ravin                ravin\n    raving               rave\n    ravish               ravish\n    ravished             ravish\n    ravisher             ravish\n    ravishing            ravish\n    ravishments          ravish\n    raw                  raw\n    rawer                rawer\n    rawly                rawli\n    rawness              raw\n    ray                  rai\n    rayed                rai\n    rays                 rai\n    raz                  raz\n    raze                 raze\n    razed                raze\n    razes                raze\n    razeth               razeth\n    razing               raze\n    razor                razor\n    razorable            razor\n    razors               razor\n    razure               razur\n    re                   re\n    reach                reach\n    reaches              reach\n    reacheth             reacheth\n    reaching             reach\n    read                 read\n    reader               reader\n    readiest             readiest\n    readily              readili\n    readiness            readi\n    reading              read\n    readins              readin\n    reads                read\n    ready                readi\n    real                 real\n    really               realli\n    realm                realm\n    realms               realm\n    reap                 reap\n    reapers              reaper\n    reaping              reap\n    reaps                reap\n    rear                 rear\n    rears                rear\n    rearward             rearward\n    reason               reason\n    reasonable           reason\n    reasonably           reason\n    reasoned             reason\n    reasoning            reason\n    reasonless           reasonless\n    reasons              reason\n    reave                reav\n    rebate               rebat\n    rebato               rebato\n    rebeck               rebeck\n    rebel                rebel\n    rebell               rebel\n    rebelling            rebel\n    rebellion            rebellion\n    rebellious           rebelli\n    rebels               rebel\n    rebound              rebound\n    rebuk                rebuk\n    rebuke               rebuk\n    rebukeable           rebuk\n    rebuked              rebuk\n    rebukes              rebuk\n    rebus                rebu\n    recall               recal\n    recant               recant\n    recantation          recant\n    recanter             recant\n    recanting            recant\n    receipt              receipt\n    receipts             receipt\n    receiv               receiv\n    receive              receiv\n    received             receiv\n    receiver             receiv\n    receives             receiv\n    receivest            receivest\n    receiveth            receiveth\n    receiving            receiv\n    receptacle           receptacl\n    rechate              rechat\n    reciprocal           reciproc\n    reciprocally         reciproc\n    recite               recit\n    recited              recit\n    reciterai            reciterai\n    reck                 reck\n    recking              reck\n    reckless             reckless\n    reckon               reckon\n    reckoned             reckon\n    reckoning            reckon\n    reckonings           reckon\n    recks                reck\n    reclaim              reclaim\n    reclaims             reclaim\n    reclusive            reclus\n    recognizance         recogniz\n    recognizances        recogniz\n    recoil               recoil\n    recoiling            recoil\n    recollected          recollect\n    recomforted          recomfort\n    recomforture         recomfortur\n    recommend            recommend\n    recommended          recommend\n    recommends           recommend\n    recompens            recompen\n    recompense           recompens\n    reconcil             reconcil\n    reconcile            reconcil\n    reconciled           reconcil\n    reconcilement        reconcil\n    reconciler           reconcil\n    reconciles           reconcil\n    reconciliation       reconcili\n    record               record\n    recordation          record\n    recorded             record\n    recorder             record\n    recorders            record\n    records              record\n    recount              recount\n    recounted            recount\n    recounting           recount\n    recountments         recount\n    recounts             recount\n    recourse             recours\n    recov                recov\n    recover              recov\n    recoverable          recover\n    recovered            recov\n    recoveries           recoveri\n    recovers             recov\n    recovery             recoveri\n    recreant             recreant\n    recreants            recreant\n    recreate             recreat\n    recreation           recreat\n    rectify              rectifi\n    rector               rector\n    rectorship           rectorship\n    recure               recur\n    recured              recur\n    red                  red\n    redbreast            redbreast\n    redder               redder\n    reddest              reddest\n    rede                 rede\n    redeem               redeem\n    redeemed             redeem\n    redeemer             redeem\n    redeeming            redeem\n    redeems              redeem\n    redeliver            redeliv\n    redemption           redempt\n    redime               redim\n    redness              red\n    redoubled            redoubl\n    redoubted            redoubt\n    redound              redound\n    redress              redress\n    redressed            redress\n    redresses            redress\n    reduce               reduc\n    reechy               reechi\n    reed                 reed\n    reeds                reed\n    reek                 reek\n    reeking              reek\n    reeks                reek\n    reeky                reeki\n    reel                 reel\n    reeleth              reeleth\n    reeling              reel\n    reels                reel\n    refell               refel\n    refer                refer\n    reference            refer\n    referr               referr\n    referred             refer\n    refigured            refigur\n    refin                refin\n    refined              refin\n    reflect              reflect\n    reflecting           reflect\n    reflection           reflect\n    reflex               reflex\n    reform               reform\n    reformation          reform\n    reformed             reform\n    refractory           refractori\n    refrain              refrain\n    refresh              refresh\n    refreshing           refresh\n    reft                 reft\n    refts                reft\n    refuge               refug\n    refus                refu\n    refusal              refus\n    refuse               refus\n    refused              refus\n    refusest             refusest\n    refusing             refus\n    reg                  reg\n    regal                regal\n    regalia              regalia\n    regan                regan\n    regard               regard\n    regardance           regard\n    regarded             regard\n    regardfully          regardfulli\n    regarding            regard\n    regards              regard\n    regenerate           regener\n    regent               regent\n    regentship           regentship\n    regia                regia\n    regiment             regiment\n    regiments            regiment\n    regina               regina\n    region               region\n    regions              region\n    regist               regist\n    register             regist\n    registers            regist\n    regreet              regreet\n    regreets             regreet\n    regress              regress\n    reguerdon            reguerdon\n    regular              regular\n    rehears              rehear\n    rehearsal            rehears\n    rehearse             rehears\n    reign                reign\n    reigned              reign\n    reignier             reignier\n    reigning             reign\n    reigns               reign\n    rein                 rein\n    reinforc             reinforc\n    reinforce            reinforc\n    reinforcement        reinforc\n    reins                rein\n    reiterate            reiter\n    reject               reject\n    rejected             reject\n    rejoic               rejoic\n    rejoice              rejoic\n    rejoices             rejoic\n    rejoiceth            rejoiceth\n    rejoicing            rejoic\n    rejoicingly          rejoicingli\n    rejoindure           rejoindur\n    rejourn              rejourn\n    rel                  rel\n    relapse              relaps\n    relate               relat\n    relates              relat\n    relation             relat\n    relations            relat\n    relative             rel\n    releas               relea\n    release              releas\n    released             releas\n    releasing            releas\n    relent               relent\n    relenting            relent\n    relents              relent\n    reliances            relianc\n    relics               relic\n    relief               relief\n    reliev               reliev\n    relieve              reliev\n    relieved             reliev\n    relieves             reliev\n    relieving            reliev\n    religion             religion\n    religions            religion\n    religious            religi\n    religiously          religi\n    relinquish           relinquish\n    reliques             reliqu\n    reliquit             reliquit\n    relish               relish\n    relume               relum\n    rely                 reli\n    relying              reli\n    remain               remain\n    remainder            remaind\n    remainders           remaind\n    remained             remain\n    remaineth            remaineth\n    remaining            remain\n    remains              remain\n    remark               remark\n    remarkable           remark\n    remediate            remedi\n    remedied             remedi\n    remedies             remedi\n    remedy               remedi\n    rememb               rememb\n    remember             rememb\n    remembered           rememb\n    remembers            rememb\n    remembrance          remembr\n    remembrancer         remembranc\n    remembrances         remembr\n    remercimens          remercimen\n    remiss               remiss\n    remission            remiss\n    remissness           remiss\n    remit                remit\n    remnant              remnant\n    remnants             remnant\n    remonstrance         remonstr\n    remorse              remors\n    remorseful           remors\n    remorseless          remorseless\n    remote               remot\n    remotion             remot\n    remov                remov\n    remove               remov\n    removed              remov\n    removedness          removed\n    remover              remov\n    removes              remov\n    removing             remov\n    remunerate           remuner\n    remuneration         remuner\n    rence                renc\n    rend                 rend\n    render               render\n    rendered             render\n    renders              render\n    rendezvous           rendezv\n    renegado             renegado\n    renege               reneg\n    reneges              reneg\n    renew                renew\n    renewed              renew\n    renewest             renewest\n    renounce             renounc\n    renouncement         renounc\n    renouncing           renounc\n    renowmed             renowm\n    renown               renown\n    renowned             renown\n    rent                 rent\n    rents                rent\n    repaid               repaid\n    repair               repair\n    repaired             repair\n    repairing            repair\n    repairs              repair\n    repass               repass\n    repast               repast\n    repasture            repastur\n    repay                repai\n    repaying             repai\n    repays               repai\n    repeal               repeal\n    repealing            repeal\n    repeals              repeal\n    repeat               repeat\n    repeated             repeat\n    repeating            repeat\n    repeats              repeat\n    repel                repel\n    repent               repent\n    repentance           repent\n    repentant            repent\n    repented             repent\n    repenting            repent\n    repents              repent\n    repetition           repetit\n    repetitions          repetit\n    repin                repin\n    repine               repin\n    repining             repin\n    replant              replant\n    replenish            replenish\n    replenished          replenish\n    replete              replet\n    replication          replic\n    replied              repli\n    replies              repli\n    repliest             repliest\n    reply                repli\n    replying             repli\n    report               report\n    reported             report\n    reporter             report\n    reportest            reportest\n    reporting            report\n    reportingly          reportingli\n    reports              report\n    reposal              repos\n    repose               repos\n    reposeth             reposeth\n    reposing             repos\n    repossess            repossess\n    reprehend            reprehend\n    reprehended          reprehend\n    reprehending         reprehend\n    represent            repres\n    representing         repres\n    reprieve             repriev\n    reprieves            repriev\n    reprisal             repris\n    reproach             reproach\n    reproaches           reproach\n    reproachful          reproach\n    reproachfully        reproachfulli\n    reprobate            reprob\n    reprobation          reprob\n    reproof              reproof\n    reprov               reprov\n    reprove              reprov\n    reproveable          reprov\n    reproves             reprov\n    reproving            reprov\n    repugn               repugn\n    repugnancy           repugn\n    repugnant            repugn\n    repulse              repuls\n    repulsed             repuls\n    repurchas            repurcha\n    repured              repur\n    reputation           reput\n    repute               reput\n    reputed              reput\n    reputeless           reputeless\n    reputes              reput\n    reputing             reput\n    request              request\n    requested            request\n    requesting           request\n    requests             request\n    requiem              requiem\n    requir               requir\n    require              requir\n    required             requir\n    requires             requir\n    requireth            requireth\n    requiring            requir\n    requisite            requisit\n    requisites           requisit\n    requit               requit\n    requital             requit\n    requite              requit\n    requited             requit\n    requites             requit\n    rer                  rer\n    rere                 rere\n    rers                 rer\n    rescu                rescu\n    rescue               rescu\n    rescued              rescu\n    rescues              rescu\n    rescuing             rescu\n    resemblance          resembl\n    resemble             resembl\n    resembled            resembl\n    resembles            resembl\n    resembleth           resembleth\n    resembling           resembl\n    reserv               reserv\n    reservation          reserv\n    reserve              reserv\n    reserved             reserv\n    reserves             reserv\n    reside               resid\n    residence            resid\n    resident             resid\n    resides              resid\n    residing             resid\n    residue              residu\n    resign               resign\n    resignation          resign\n    resist               resist\n    resistance           resist\n    resisted             resist\n    resisting            resist\n    resists              resist\n    resolute             resolut\n    resolutely           resolut\n    resolutes            resolut\n    resolution           resolut\n    resolv               resolv\n    resolve              resolv\n    resolved             resolv\n    resolvedly           resolvedli\n    resolves             resolv\n    resolveth            resolveth\n    resort               resort\n    resorted             resort\n    resounding           resound\n    resounds             resound\n    respeaking           respeak\n    respect              respect\n    respected            respect\n    respecting           respect\n    respective           respect\n    respectively         respect\n    respects             respect\n    respice              respic\n    respite              respit\n    respites             respit\n    responsive           respons\n    respose              respos\n    ress                 ress\n    rest                 rest\n    rested               rest\n    resteth              resteth\n    restful              rest\n    resting              rest\n    restitution          restitut\n    restless             restless\n    restor               restor\n    restoration          restor\n    restorative          restor\n    restore              restor\n    restored             restor\n    restores             restor\n    restoring            restor\n    restrain             restrain\n    restrained           restrain\n    restraining          restrain\n    restrains            restrain\n    restraint            restraint\n    rests                rest\n    resty                resti\n    resum                resum\n    resume               resum\n    resumes              resum\n    resurrections        resurrect\n    retail               retail\n    retails              retail\n    retain               retain\n    retainers            retain\n    retaining            retain\n    retell               retel\n    retention            retent\n    retentive            retent\n    retinue              retinu\n    retir                retir\n    retire               retir\n    retired              retir\n    retirement           retir\n    retires              retir\n    retiring             retir\n    retold               retold\n    retort               retort\n    retorts              retort\n    retourne             retourn\n    retract              retract\n    retreat              retreat\n    retrograde           retrograd\n    rets                 ret\n    return               return\n    returned             return\n    returnest            returnest\n    returneth            returneth\n    returning            return\n    returns              return\n    revania              revania\n    reveal               reveal\n    reveals              reveal\n    revel                revel\n    reveler              revel\n    revell               revel\n    reveller             revel\n    revellers            revel\n    revelling            revel\n    revelry              revelri\n    revels               revel\n    reveng               reveng\n    revenge              reveng\n    revenged             reveng\n    revengeful           reveng\n    revengement          reveng\n    revenger             reveng\n    revengers            reveng\n    revenges             reveng\n    revenging            reveng\n    revengingly          revengingli\n    revenue              revenu\n    revenues             revenu\n    reverb               reverb\n    reverberate          reverber\n    reverbs              reverb\n    reverenc             reverenc\n    reverence            rever\n    reverend             reverend\n    reverent             rever\n    reverently           rever\n    revers               rever\n    reverse              revers\n    reversion            revers\n    reverted             revert\n    review               review\n    reviewest            reviewest\n    revil                revil\n    revile               revil\n    revisits             revisit\n    reviv                reviv\n    revive               reviv\n    revives              reviv\n    reviving             reviv\n    revok                revok\n    revoke               revok\n    revokement           revok\n    revolt               revolt\n    revolted             revolt\n    revolting            revolt\n    revolts              revolt\n    revolution           revolut\n    revolutions          revolut\n    revolve              revolv\n    revolving            revolv\n    reward               reward\n    rewarded             reward\n    rewarder             reward\n    rewarding            reward\n    rewards              reward\n    reword               reword\n    reworded             reword\n    rex                  rex\n    rey                  rei\n    reynaldo             reynaldo\n    rford                rford\n    rful                 rful\n    rfull                rfull\n    rhapsody             rhapsodi\n    rheims               rheim\n    rhenish              rhenish\n    rhesus               rhesu\n    rhetoric             rhetor\n    rheum                rheum\n    rheumatic            rheumat\n    rheums               rheum\n    rheumy               rheumi\n    rhinoceros           rhinocero\n    rhodes               rhode\n    rhodope              rhodop\n    rhubarb              rhubarb\n    rhym                 rhym\n    rhyme                rhyme\n    rhymers              rhymer\n    rhymes               rhyme\n    rhyming              rhyme\n    rialto               rialto\n    rib                  rib\n    ribald               ribald\n    riband               riband\n    ribands              riband\n    ribaudred            ribaudr\n    ribb                 ribb\n    ribbed               rib\n    ribbon               ribbon\n    ribbons              ribbon\n    ribs                 rib\n    rice                 rice\n    rich                 rich\n    richard              richard\n    richer               richer\n    riches               rich\n    richest              richest\n    richly               richli\n    richmond             richmond\n    richmonds            richmond\n    rid                  rid\n    riddance             riddanc\n    ridden               ridden\n    riddle               riddl\n    riddles              riddl\n    riddling             riddl\n    ride                 ride\n    rider                rider\n    riders               rider\n    rides                ride\n    ridest               ridest\n    rideth               rideth\n    ridge                ridg\n    ridges               ridg\n    ridiculous           ridicul\n    riding               ride\n    rids                 rid\n    rien                 rien\n    ries                 ri\n    rifle                rifl\n    rift                 rift\n    rifted               rift\n    rig                  rig\n    rigg                 rigg\n    riggish              riggish\n    right                right\n    righteous            righteou\n    righteously          righteous\n    rightful             right\n    rightfully           rightfulli\n    rightly              rightli\n    rights               right\n    rigol                rigol\n    rigorous             rigor\n    rigorously           rigor\n    rigour               rigour\n    ril                  ril\n    rim                  rim\n    rin                  rin\n    rinaldo              rinaldo\n    rind                 rind\n    ring                 ring\n    ringing              ring\n    ringleader           ringlead\n    ringlets             ringlet\n    rings                ring\n    ringwood             ringwood\n    riot                 riot\n    rioter               rioter\n    rioting              riot\n    riotous              riotou\n    riots                riot\n    rip                  rip\n    ripe                 ripe\n    ripely               ripe\n    ripen                ripen\n    ripened              ripen\n    ripeness             ripe\n    ripening             ripen\n    ripens               ripen\n    riper                riper\n    ripest               ripest\n    riping               ripe\n    ripp                 ripp\n    ripping              rip\n    rise                 rise\n    risen                risen\n    rises                rise\n    riseth               riseth\n    rish                 rish\n    rising               rise\n    rite                 rite\n    rites                rite\n    rivage               rivag\n    rival                rival\n    rivality             rival\n    rivall               rival\n    rivals               rival\n    rive                 rive\n    rived                rive\n    rivelled             rivel\n    river                river\n    rivers               river\n    rivet                rivet\n    riveted              rivet\n    rivets               rivet\n    rivo                 rivo\n    rj                   rj\n    rless                rless\n    road                 road\n    roads                road\n    roam                 roam\n    roaming              roam\n    roan                 roan\n    roar                 roar\n    roared               roar\n    roarers              roarer\n    roaring              roar\n    roars                roar\n    roast                roast\n    roasted              roast\n    rob                  rob\n    roba                 roba\n    robas                roba\n    robb                 robb\n    robbed               rob\n    robber               robber\n    robbers              robber\n    robbery              robberi\n    robbing              rob\n    robe                 robe\n    robed                robe\n    robert               robert\n    robes                robe\n    robin                robin\n    robs                 rob\n    robustious           robusti\n    rochester            rochest\n    rochford             rochford\n    rock                 rock\n    rocks                rock\n    rocky                rocki\n    rod                  rod\n    rode                 rode\n    roderigo             roderigo\n    rods                 rod\n    roe                  roe\n    roes                 roe\n    roger                roger\n    rogero               rogero\n    rogue                rogu\n    roguery              rogueri\n    rogues               rogu\n    roguish              roguish\n    roi                  roi\n    roisting             roist\n    roll                 roll\n    rolled               roll\n    rolling              roll\n    rolls                roll\n    rom                  rom\n    romage               romag\n    roman                roman\n    romano               romano\n    romanos              romano\n    romans               roman\n    rome                 rome\n    romeo                romeo\n    romish               romish\n    rondure              rondur\n    ronyon               ronyon\n    rood                 rood\n    roof                 roof\n    roofs                roof\n    rook                 rook\n    rooks                rook\n    rooky                rooki\n    room                 room\n    rooms                room\n    root                 root\n    rooted               root\n    rootedly             rootedli\n    rooteth              rooteth\n    rooting              root\n    roots                root\n    rope                 rope\n    ropery               roperi\n    ropes                rope\n    roping               rope\n    ros                  ro\n    rosalind             rosalind\n    rosalinda            rosalinda\n    rosalinde            rosalind\n    rosaline             rosalin\n    roscius              rosciu\n    rose                 rose\n    rosed                rose\n    rosemary             rosemari\n    rosencrantz          rosencrantz\n    roses                rose\n    ross                 ross\n    rosy                 rosi\n    rot                  rot\n    rote                 rote\n    roted                rote\n    rother               rother\n    rotherham            rotherham\n    rots                 rot\n    rotted               rot\n    rotten               rotten\n    rottenness           rotten\n    rotting              rot\n    rotundity            rotund\n    rouen                rouen\n    rough                rough\n    rougher              rougher\n    roughest             roughest\n    roughly              roughli\n    roughness            rough\n    round                round\n    rounded              round\n    roundel              roundel\n    rounder              rounder\n    roundest             roundest\n    rounding             round\n    roundly              roundli\n    rounds               round\n    roundure             roundur\n    rous                 rou\n    rouse                rous\n    roused               rous\n    rousillon            rousillon\n    rously               rousli\n    roussi               roussi\n    rout                 rout\n    routed               rout\n    routs                rout\n    rove                 rove\n    rover                rover\n    row                  row\n    rowel                rowel\n    rowland              rowland\n    rowlands             rowland\n    roy                  roi\n    royal                royal\n    royalize             royal\n    royally              royal\n    royalties            royalti\n    royalty              royalti\n    roynish              roynish\n    rs                   rs\n    rt                   rt\n    rub                  rub\n    rubb                 rubb\n    rubbing              rub\n    rubbish              rubbish\n    rubies               rubi\n    rubious              rubiou\n    rubs                 rub\n    ruby                 rubi\n    rud                  rud\n    rudand               rudand\n    rudder               rudder\n    ruddiness            ruddi\n    ruddock              ruddock\n    ruddy                ruddi\n    rude                 rude\n    rudely               rude\n    rudeness             rude\n    ruder                ruder\n    rudesby              rudesbi\n    rudest               rudest\n    rudiments            rudiment\n    rue                  rue\n    rued                 ru\n    ruff                 ruff\n    ruffian              ruffian\n    ruffians             ruffian\n    ruffle               ruffl\n    ruffling             ruffl\n    ruffs                ruff\n    rug                  rug\n    rugby                rugbi\n    rugemount            rugemount\n    rugged               rug\n    ruin                 ruin\n    ruinate              ruinat\n    ruined               ruin\n    ruining              ruin\n    ruinous              ruinou\n    ruins                ruin\n    rul                  rul\n    rule                 rule\n    ruled                rule\n    ruler                ruler\n    rulers               ruler\n    rules                rule\n    ruling               rule\n    rumble               rumbl\n    ruminaies            ruminai\n    ruminat              ruminat\n    ruminate             rumin\n    ruminated            rumin\n    ruminates            rumin\n    rumination           rumin\n    rumor                rumor\n    rumour               rumour\n    rumourer             rumour\n    rumours              rumour\n    rump                 rump\n    run                  run\n    runagate             runag\n    runagates            runag\n    runaway              runawai\n    runaways             runawai\n    rung                 rung\n    runn                 runn\n    runner               runner\n    runners              runner\n    running              run\n    runs                 run\n    rupture              ruptur\n    ruptures             ruptur\n    rural                rural\n    rush                 rush\n    rushes               rush\n    rushing              rush\n    rushling             rushl\n    rushy                rushi\n    russet               russet\n    russia               russia\n    russian              russian\n    russians             russian\n    rust                 rust\n    rusted               rust\n    rustic               rustic\n    rustically           rustic\n    rustics              rustic\n    rustle               rustl\n    rustling             rustl\n    rusts                rust\n    rusty                rusti\n    rut                  rut\n    ruth                 ruth\n    ruthful              ruth\n    ruthless             ruthless\n    rutland              rutland\n    ruttish              ruttish\n    ry                   ry\n    rye                  rye\n    rything              ryth\n    s                    s\n    sa                   sa\n    saba                 saba\n    sabbath              sabbath\n    sable                sabl\n    sables               sabl\n    sack                 sack\n    sackbuts             sackbut\n    sackcloth            sackcloth\n    sacked               sack\n    sackerson            sackerson\n    sacks                sack\n    sacrament            sacrament\n    sacred               sacr\n    sacrific             sacrif\n    sacrifice            sacrific\n    sacrificers          sacrific\n    sacrifices           sacrific\n    sacrificial          sacrifici\n    sacrificing          sacrif\n    sacrilegious         sacrilegi\n    sacring              sacr\n    sad                  sad\n    sadder               sadder\n    saddest              saddest\n    saddle               saddl\n    saddler              saddler\n    saddles              saddl\n    sadly                sadli\n    sadness              sad\n    saf                  saf\n    safe                 safe\n    safeguard            safeguard\n    safely               safe\n    safer                safer\n    safest               safest\n    safeties             safeti\n    safety               safeti\n    saffron              saffron\n    sag                  sag\n    sage                 sage\n    sagittary            sagittari\n    said                 said\n    saidst               saidst\n    sail                 sail\n    sailing              sail\n    sailmaker            sailmak\n    sailor               sailor\n    sailors              sailor\n    sails                sail\n    sain                 sain\n    saint                saint\n    sainted              saint\n    saintlike            saintlik\n    saints               saint\n    saith                saith\n    sake                 sake\n    sakes                sake\n    sala                 sala\n    salad                salad\n    salamander           salamand\n    salary               salari\n    sale                 sale\n    salerio              salerio\n    salicam              salicam\n    salique              saliqu\n    salisbury            salisburi\n    sall                 sall\n    sallet               sallet\n    sallets              sallet\n    sallies              salli\n    sallow               sallow\n    sally                salli\n    salmon               salmon\n    salmons              salmon\n    salt                 salt\n    salter               salter\n    saltiers             saltier\n    saltness             salt\n    saltpetre            saltpetr\n    salutation           salut\n    salutations          salut\n    salute               salut\n    saluted              salut\n    salutes              salut\n    saluteth             saluteth\n    salv                 salv\n    salvation            salvat\n    salve                salv\n    salving              salv\n    same                 same\n    samingo              samingo\n    samp                 samp\n    sampire              sampir\n    sample               sampl\n    sampler              sampler\n    sampson              sampson\n    samson               samson\n    samsons              samson\n    sancta               sancta\n    sanctified           sanctifi\n    sanctifies           sanctifi\n    sanctify             sanctifi\n    sanctimonies         sanctimoni\n    sanctimonious        sanctimoni\n    sanctimony           sanctimoni\n    sanctities           sanctiti\n    sanctity             sanctiti\n    sanctuarize          sanctuar\n    sanctuary            sanctuari\n    sand                 sand\n    sandal               sandal\n    sandbag              sandbag\n    sanded               sand\n    sands                sand\n    sandy                sandi\n    sandys               sandi\n    sang                 sang\n    sanguine             sanguin\n    sanguis              sangui\n    sanity               saniti\n    sans                 san\n    santrailles          santrail\n    sap                  sap\n    sapient              sapient\n    sapit                sapit\n    sapless              sapless\n    sapling              sapl\n    sapphire             sapphir\n    sapphires            sapphir\n    saracens             saracen\n    sarcenet             sarcenet\n    sard                 sard\n    sardians             sardian\n    sardinia             sardinia\n    sardis               sardi\n    sarum                sarum\n    sat                  sat\n    satan                satan\n    satchel              satchel\n    sate                 sate\n    sated                sate\n    satiate              satiat\n    satiety              satieti\n    satin                satin\n    satire               satir\n    satirical            satir\n    satis                sati\n    satisfaction         satisfact\n    satisfied            satisfi\n    satisfies            satisfi\n    satisfy              satisfi\n    satisfying           satisfi\n    saturday             saturdai\n    saturdays            saturdai\n    saturn               saturn\n    saturnine            saturnin\n    saturninus           saturninu\n    satyr                satyr\n    satyrs               satyr\n    sauc                 sauc\n    sauce                sauc\n    sauced               sauc\n    saucers              saucer\n    sauces               sauc\n    saucily              saucili\n    sauciness            sauci\n    saucy                sauci\n    sauf                 sauf\n    saunder              saunder\n    sav                  sav\n    savage               savag\n    savagely             savag\n    savageness           savag\n    savagery             savageri\n    savages              savag\n    save                 save\n    saved                save\n    saves                save\n    saving               save\n    saviour              saviour\n    savory               savori\n    savour               savour\n    savouring            savour\n    savours              savour\n    savoury              savouri\n    savoy                savoi\n    saw                  saw\n    sawed                saw\n    sawest               sawest\n    sawn                 sawn\n    sawpit               sawpit\n    saws                 saw\n    sawyer               sawyer\n    saxons               saxon\n    saxony               saxoni\n    saxton               saxton\n    say                  sai\n    sayest               sayest\n    saying               sai\n    sayings              sai\n    says                 sai\n    sayst                sayst\n    sblood               sblood\n    sc                   sc\n    scab                 scab\n    scabbard             scabbard\n    scabs                scab\n    scaffold             scaffold\n    scaffoldage          scaffoldag\n    scal                 scal\n    scald                scald\n    scalded              scald\n    scalding             scald\n    scale                scale\n    scaled               scale\n    scales               scale\n    scaling              scale\n    scall                scall\n    scalp                scalp\n    scalps               scalp\n    scaly                scali\n    scamble              scambl\n    scambling            scambl\n    scamels              scamel\n    scan                 scan\n    scandal              scandal\n    scandaliz            scandaliz\n    scandalous           scandal\n    scandy               scandi\n    scann                scann\n    scant                scant\n    scanted              scant\n    scanter              scanter\n    scanting             scant\n    scantling            scantl\n    scants               scant\n    scap                 scap\n    scape                scape\n    scaped               scape\n    scapes               scape\n    scapeth              scapeth\n    scar                 scar\n    scarce               scarc\n    scarcely             scarc\n    scarcity             scarciti\n    scare                scare\n    scarecrow            scarecrow\n    scarecrows           scarecrow\n    scarf                scarf\n    scarfed              scarf\n    scarfs               scarf\n    scaring              scare\n    scarlet              scarlet\n    scarr                scarr\n    scarre               scarr\n    scars                scar\n    scarus               scaru\n    scath                scath\n    scathe               scath\n    scathful             scath\n    scatt                scatt\n    scatter              scatter\n    scattered            scatter\n    scattering           scatter\n    scatters             scatter\n    scelera              scelera\n    scelerisque          scelerisqu\n    scene                scene\n    scenes               scene\n    scent                scent\n    scented              scent\n    scept                scept\n    scepter              scepter\n    sceptre              sceptr\n    sceptred             sceptr\n    sceptres             sceptr\n    schedule             schedul\n    schedules            schedul\n    scholar              scholar\n    scholarly            scholarli\n    scholars             scholar\n    school               school\n    schoolboy            schoolboi\n    schoolboys           schoolboi\n    schoolfellows        schoolfellow\n    schooling            school\n    schoolmaster         schoolmast\n    schoolmasters        schoolmast\n    schools              school\n    sciatica             sciatica\n    sciaticas            sciatica\n    science              scienc\n    sciences             scienc\n    scimitar             scimitar\n    scion                scion\n    scions               scion\n    scissors             scissor\n    scoff                scoff\n    scoffer              scoffer\n    scoffing             scof\n    scoffs               scoff\n    scoggin              scoggin\n    scold                scold\n    scolding             scold\n    scolds               scold\n    sconce               sconc\n    scone                scone\n    scope                scope\n    scopes               scope\n    scorch               scorch\n    scorched             scorch\n    score                score\n    scored               score\n    scores               score\n    scoring              score\n    scorn                scorn\n    scorned              scorn\n    scornful             scorn\n    scornfully           scornfulli\n    scorning             scorn\n    scorns               scorn\n    scorpion             scorpion\n    scorpions            scorpion\n    scot                 scot\n    scotch               scotch\n    scotches             scotch\n    scotland             scotland\n    scots                scot\n    scottish             scottish\n    scoundrels           scoundrel\n    scour                scour\n    scoured              scour\n    scourg               scourg\n    scourge              scourg\n    scouring             scour\n    scout                scout\n    scouts               scout\n    scowl                scowl\n    scrap                scrap\n    scrape               scrape\n    scraping             scrape\n    scraps               scrap\n    scratch              scratch\n    scratches            scratch\n    scratching           scratch\n    scream               scream\n    screams              scream\n    screech              screech\n    screeching           screech\n    screen               screen\n    screens              screen\n    screw                screw\n    screws               screw\n    scribbl              scribbl\n    scribbled            scribbl\n    scribe               scribe\n    scribes              scribe\n    scrimers             scrimer\n    scrip                scrip\n    scrippage            scrippag\n    scripture            scriptur\n    scriptures           scriptur\n    scrivener            scriven\n    scroll               scroll\n    scrolls              scroll\n    scroop               scroop\n    scrowl               scrowl\n    scroyles             scroyl\n    scrubbed             scrub\n    scruple              scrupl\n    scruples             scrupl\n    scrupulous           scrupul\n    scuffles             scuffl\n    scuffling            scuffl\n    scullion             scullion\n    sculls               scull\n    scum                 scum\n    scurril              scurril\n    scurrility           scurril\n    scurrilous           scurril\n    scurvy               scurvi\n    scuse                scuse\n    scut                 scut\n    scutcheon            scutcheon\n    scutcheons           scutcheon\n    scylla               scylla\n    scythe               scyth\n    scythed              scyth\n    scythia              scythia\n    scythian             scythian\n    sdeath               sdeath\n    se                   se\n    sea                  sea\n    seacoal              seacoal\n    seafaring            seafar\n    seal                 seal\n    sealed               seal\n    sealing              seal\n    seals                seal\n    seam                 seam\n    seamen               seamen\n    seamy                seami\n    seaport              seaport\n    sear                 sear\n    searce               searc\n    search               search\n    searchers            searcher\n    searches             search\n    searcheth            searcheth\n    searching            search\n    seared               sear\n    seas                 sea\n    seasick              seasick\n    seaside              seasid\n    season               season\n    seasoned             season\n    seasons              season\n    seat                 seat\n    seated               seat\n    seats                seat\n    sebastian            sebastian\n    second               second\n    secondarily          secondarili\n    secondary            secondari\n    seconded             second\n    seconds              second\n    secrecy              secreci\n    secret               secret\n    secretaries          secretari\n    secretary            secretari\n    secretly             secretli\n    secrets              secret\n    sect                 sect\n    sectary              sectari\n    sects                sect\n    secundo              secundo\n    secure               secur\n    securely             secur\n    securing             secur\n    security             secur\n    sedg                 sedg\n    sedge                sedg\n    sedges               sedg\n    sedgy                sedgi\n    sedition             sedit\n    seditious            sediti\n    seduc                seduc\n    seduce               seduc\n    seduced              seduc\n    seducer              seduc\n    seducing             seduc\n    see                  see\n    seed                 seed\n    seeded               seed\n    seedness             seed\n    seeds                seed\n    seedsman             seedsman\n    seein                seein\n    seeing               see\n    seek                 seek\n    seeking              seek\n    seeks                seek\n    seel                 seel\n    seeling              seel\n    seely                seeli\n    seem                 seem\n    seemed               seem\n    seemers              seemer\n    seemest              seemest\n    seemeth              seemeth\n    seeming              seem\n    seemingly            seemingli\n    seemly               seemli\n    seems                seem\n    seen                 seen\n    seer                 seer\n    sees                 see\n    seese                sees\n    seest                seest\n    seethe               seeth\n    seethes              seeth\n    seething             seeth\n    seeting              seet\n    segregation          segreg\n    seigneur             seigneur\n    seigneurs            seigneur\n    seiz                 seiz\n    seize                seiz\n    seized               seiz\n    seizes               seiz\n    seizeth              seizeth\n    seizing              seiz\n    seizure              seizur\n    seld                 seld\n    seldom               seldom\n    select               select\n    seleucus             seleucu\n    self                 self\n    selfsame             selfsam\n    sell                 sell\n    seller               seller\n    selling              sell\n    sells                sell\n    selves               selv\n    semblable            semblabl\n    semblably            semblabl\n    semblance            semblanc\n    semblances           semblanc\n    semblative           sembl\n    semi                 semi\n    semicircle           semicircl\n    semiramis            semirami\n    semper               semper\n    sempronius           semproniu\n    senate               senat\n    senator              senat\n    senators             senat\n    send                 send\n    sender               sender\n    sendeth              sendeth\n    sending              send\n    sends                send\n    seneca               seneca\n    senior               senior\n    seniory              seniori\n    senis                seni\n    sennet               sennet\n    senoys               senoi\n    sense                sens\n    senseless            senseless\n    senses               sens\n    sensible             sensibl\n    sensibly             sensibl\n    sensual              sensual\n    sensuality           sensual\n    sent                 sent\n    sentenc              sentenc\n    sentence             sentenc\n    sentences            sentenc\n    sententious          sententi\n    sentinel             sentinel\n    sentinels            sentinel\n    separable            separ\n    separate             separ\n    separated            separ\n    separates            separ\n    separation           separ\n    septentrion          septentrion\n    sepulchre            sepulchr\n    sepulchres           sepulchr\n    sepulchring          sepulchr\n    sequel               sequel\n    sequence             sequenc\n    sequent              sequent\n    sequest              sequest\n    sequester            sequest\n    sequestration        sequestr\n    sere                 sere\n    serenis              sereni\n    serge                serg\n    sergeant             sergeant\n    serious              seriou\n    seriously            serious\n    sermon               sermon\n    sermons              sermon\n    serpent              serpent\n    serpentine           serpentin\n    serpents             serpent\n    serpigo              serpigo\n    serv                 serv\n    servant              servant\n    servanted            servant\n    servants             servant\n    serve                serv\n    served               serv\n    server               server\n    serves               serv\n    serveth              serveth\n    service              servic\n    serviceable          servic\n    services             servic\n    servile              servil\n    servility            servil\n    servilius            serviliu\n    serving              serv\n    servingman           servingman\n    servingmen           servingmen\n    serviteur            serviteur\n    servitor             servitor\n    servitors            servitor\n    servitude            servitud\n    sessa                sessa\n    session              session\n    sessions             session\n    sestos               sesto\n    set                  set\n    setebos              setebo\n    sets                 set\n    setter               setter\n    setting              set\n    settle               settl\n    settled              settl\n    settlest             settlest\n    settling             settl\n    sev                  sev\n    seven                seven\n    sevenfold            sevenfold\n    sevennight           sevennight\n    seventeen            seventeen\n    seventh              seventh\n    seventy              seventi\n    sever                sever\n    several              sever\n    severally            sever\n    severals             sever\n    severe               sever\n    severed              sever\n    severely             sever\n    severest             severest\n    severing             sever\n    severity             sever\n    severn               severn\n    severs               sever\n    sew                  sew\n    seward               seward\n    sewer                sewer\n    sewing               sew\n    sex                  sex\n    sexes                sex\n    sexton               sexton\n    sextus               sextu\n    seymour              seymour\n    seyton               seyton\n    sfoot                sfoot\n    sh                   sh\n    shackle              shackl\n    shackles             shackl\n    shade                shade\n    shades               shade\n    shadow               shadow\n    shadowed             shadow\n    shadowing            shadow\n    shadows              shadow\n    shadowy              shadowi\n    shady                shadi\n    shafalus             shafalu\n    shaft                shaft\n    shafts               shaft\n    shag                 shag\n    shak                 shak\n    shake                shake\n    shaked               shake\n    shaken               shaken\n    shakes               shake\n    shaking              shake\n    shales               shale\n    shall                shall\n    shallenge            shalleng\n    shallow              shallow\n    shallowest           shallowest\n    shallowly            shallowli\n    shallows             shallow\n    shalt                shalt\n    sham                 sham\n    shambles             shambl\n    shame                shame\n    shamed               shame\n    shameful             shame\n    shamefully           shamefulli\n    shameless            shameless\n    shames               shame\n    shamest              shamest\n    shaming              shame\n    shank                shank\n    shanks               shank\n    shap                 shap\n    shape                shape\n    shaped               shape\n    shapeless            shapeless\n    shapen               shapen\n    shapes               shape\n    shaping              shape\n    shar                 shar\n    shard                shard\n    sharded              shard\n    shards               shard\n    share                share\n    shared               share\n    sharers              sharer\n    shares               share\n    sharing              share\n    shark                shark\n    sharp                sharp\n    sharpen              sharpen\n    sharpened            sharpen\n    sharpens             sharpen\n    sharper              sharper\n    sharpest             sharpest\n    sharply              sharpli\n    sharpness            sharp\n    sharps               sharp\n    shatter              shatter\n    shav                 shav\n    shave                shave\n    shaven               shaven\n    shaw                 shaw\n    she                  she\n    sheaf                sheaf\n    sheal                sheal\n    shear                shear\n    shearers             shearer\n    shearing             shear\n    shearman             shearman\n    shears               shear\n    sheath               sheath\n    sheathe              sheath\n    sheathed             sheath\n    sheathes             sheath\n    sheathing            sheath\n    sheaved              sheav\n    sheaves              sheav\n    shed                 shed\n    shedding             shed\n    sheds                shed\n    sheen                sheen\n    sheep                sheep\n    sheepcote            sheepcot\n    sheepcotes           sheepcot\n    sheeps               sheep\n    sheepskins           sheepskin\n    sheer                sheer\n    sheet                sheet\n    sheeted              sheet\n    sheets               sheet\n    sheffield            sheffield\n    shelf                shelf\n    shell                shell\n    shells               shell\n    shelt                shelt\n    shelter              shelter\n    shelters             shelter\n    shelves              shelv\n    shelving             shelv\n    shelvy               shelvi\n    shent                shent\n    shepherd             shepherd\n    shepherdes           shepherd\n    shepherdess          shepherdess\n    shepherdesses        shepherdess\n    shepherds            shepherd\n    sher                 sher\n    sheriff              sheriff\n    sherris              sherri\n    shes                 she\n    sheweth              sheweth\n    shield               shield\n    shielded             shield\n    shields              shield\n    shift                shift\n    shifted              shift\n    shifting             shift\n    shifts               shift\n    shilling             shill\n    shillings            shill\n    shin                 shin\n    shine                shine\n    shines               shine\n    shineth              shineth\n    shining              shine\n    shins                shin\n    shiny                shini\n    ship                 ship\n    shipboard            shipboard\n    shipman              shipman\n    shipmaster           shipmast\n    shipmen              shipmen\n    shipp                shipp\n    shipped              ship\n    shipping             ship\n    ships                ship\n    shipt                shipt\n    shipwreck            shipwreck\n    shipwrecking         shipwreck\n    shipwright           shipwright\n    shipwrights          shipwright\n    shire                shire\n    shirley              shirlei\n    shirt                shirt\n    shirts               shirt\n    shive                shive\n    shiver               shiver\n    shivering            shiver\n    shivers              shiver\n    shoal                shoal\n    shoals               shoal\n    shock                shock\n    shocks               shock\n    shod                 shod\n    shoe                 shoe\n    shoeing              shoe\n    shoemaker            shoemak\n    shoes                shoe\n    shog                 shog\n    shone                shone\n    shook                shook\n    shoon                shoon\n    shoot                shoot\n    shooter              shooter\n    shootie              shooti\n    shooting             shoot\n    shoots               shoot\n    shop                 shop\n    shops                shop\n    shore                shore\n    shores               shore\n    shorn                shorn\n    short                short\n    shortcake            shortcak\n    shorten              shorten\n    shortened            shorten\n    shortens             shorten\n    shorter              shorter\n    shortly              shortli\n    shortness            short\n    shot                 shot\n    shotten              shotten\n    shoughs              shough\n    should               should\n    shoulder             shoulder\n    shouldering          shoulder\n    shoulders            shoulder\n    shouldst             shouldst\n    shout                shout\n    shouted              shout\n    shouting             shout\n    shouts               shout\n    shov                 shov\n    shove                shove\n    shovel               shovel\n    shovels              shovel\n    show                 show\n    showed               show\n    shower               shower\n    showers              shower\n    showest              showest\n    showing              show\n    shown                shown\n    shows                show\n    shreds               shred\n    shrew                shrew\n    shrewd               shrewd\n    shrewdly             shrewdli\n    shrewdness           shrewd\n    shrewish             shrewish\n    shrewishly           shrewishli\n    shrewishness         shrewish\n    shrews               shrew\n    shrewsbury           shrewsburi\n    shriek               shriek\n    shrieking            shriek\n    shrieks              shriek\n    shrieve              shriev\n    shrift               shrift\n    shrill               shrill\n    shriller             shriller\n    shrills              shrill\n    shrilly              shrilli\n    shrimp               shrimp\n    shrine               shrine\n    shrink               shrink\n    shrinking            shrink\n    shrinks              shrink\n    shriv                shriv\n    shrive               shrive\n    shriver              shriver\n    shrives              shrive\n    shriving             shrive\n    shroud               shroud\n    shrouded             shroud\n    shrouding            shroud\n    shrouds              shroud\n    shrove               shrove\n    shrow                shrow\n    shrows               shrow\n    shrub                shrub\n    shrubs               shrub\n    shrug                shrug\n    shrugs               shrug\n    shrunk               shrunk\n    shudd                shudd\n    shudders             shudder\n    shuffl               shuffl\n    shuffle              shuffl\n    shuffled             shuffl\n    shuffling            shuffl\n    shun                 shun\n    shunless             shunless\n    shunn                shunn\n    shunned              shun\n    shunning             shun\n    shuns                shun\n    shut                 shut\n    shuts                shut\n    shuttle              shuttl\n    shy                  shy\n    shylock              shylock\n    si                   si\n    sibyl                sibyl\n    sibylla              sibylla\n    sibyls               sibyl\n    sicil                sicil\n    sicilia              sicilia\n    sicilian             sicilian\n    sicilius             siciliu\n    sicils               sicil\n    sicily               sicili\n    sicinius             siciniu\n    sick                 sick\n    sicken               sicken\n    sickens              sicken\n    sicker               sicker\n    sickle               sickl\n    sicklemen            sicklemen\n    sicklied             sickli\n    sickliness           sickli\n    sickly               sickli\n    sickness             sick\n    sicles               sicl\n    sicyon               sicyon\n    side                 side\n    sided                side\n    sides                side\n    siege                sieg\n    sieges               sieg\n    sienna               sienna\n    sies                 si\n    sieve                siev\n    sift                 sift\n    sifted               sift\n    sigeia               sigeia\n    sigh                 sigh\n    sighed               sigh\n    sighing              sigh\n    sighs                sigh\n    sight                sight\n    sighted              sight\n    sightless            sightless\n    sightly              sightli\n    sights               sight\n    sign                 sign\n    signal               signal\n    signet               signet\n    signieur             signieur\n    significant          signific\n    significants         signific\n    signified            signifi\n    signifies            signifi\n    signify              signifi\n    signifying           signifi\n    signior              signior\n    signiories           signiori\n    signiors             signior\n    signiory             signiori\n    signor               signor\n    signories            signori\n    signs                sign\n    signum               signum\n    silenc               silenc\n    silence              silenc\n    silenced             silenc\n    silencing            silenc\n    silent               silent\n    silently             silent\n    silius               siliu\n    silk                 silk\n    silken               silken\n    silkman              silkman\n    silks                silk\n    silliest             silliest\n    silliness            silli\n    silling              sill\n    silly                silli\n    silva                silva\n    silver               silver\n    silvered             silver\n    silverly             silverli\n    silvia               silvia\n    silvius              silviu\n    sima                 sima\n    simile               simil\n    similes              simil\n    simois               simoi\n    simon                simon\n    simony               simoni\n    simp                 simp\n    simpcox              simpcox\n    simple               simpl\n    simpleness           simpl\n    simpler              simpler\n    simples              simpl\n    simplicity           simplic\n    simply               simpli\n    simular              simular\n    simulation           simul\n    sin                  sin\n    since                sinc\n    sincere              sincer\n    sincerely            sincer\n    sincerity            sincer\n    sinel                sinel\n    sinew                sinew\n    sinewed              sinew\n    sinews               sinew\n    sinewy               sinewi\n    sinful               sin\n    sinfully             sinfulli\n    sing                 sing\n    singe                sing\n    singeing             sing\n    singer               singer\n    singes               sing\n    singeth              singeth\n    singing              sing\n    single               singl\n    singled              singl\n    singleness           singl\n    singly               singli\n    sings                sing\n    singular             singular\n    singulariter         singularit\n    singularities        singular\n    singularity          singular\n    singuled             singul\n    sinister             sinist\n    sink                 sink\n    sinking              sink\n    sinks                sink\n    sinn                 sinn\n    sinner               sinner\n    sinners              sinner\n    sinning              sin\n    sinon                sinon\n    sins                 sin\n    sip                  sip\n    sipping              sip\n    sir                  sir\n    sire                 sire\n    siren                siren\n    sirrah               sirrah\n    sirs                 sir\n    sist                 sist\n    sister               sister\n    sisterhood           sisterhood\n    sisterly             sisterli\n    sisters              sister\n    sit                  sit\n    sith                 sith\n    sithence             sithenc\n    sits                 sit\n    sitting              sit\n    situate              situat\n    situation            situat\n    situations           situat\n    siward               siward\n    six                  six\n    sixpence             sixpenc\n    sixpences            sixpenc\n    sixpenny             sixpenni\n    sixteen              sixteen\n    sixth                sixth\n    sixty                sixti\n    siz                  siz\n    size                 size\n    sizes                size\n    sizzle               sizzl\n    skains               skain\n    skamble              skambl\n    skein                skein\n    skelter              skelter\n    skies                ski\n    skilful              skil\n    skilfully            skilfulli\n    skill                skill\n    skilless             skilless\n    skillet              skillet\n    skillful             skill\n    skills               skill\n    skim                 skim\n    skimble              skimbl\n    skin                 skin\n    skinker              skinker\n    skinny               skinni\n    skins                skin\n    skip                 skip\n    skipp                skipp\n    skipper              skipper\n    skipping             skip\n    skirmish             skirmish\n    skirmishes           skirmish\n    skirr                skirr\n    skirted              skirt\n    skirts               skirt\n    skittish             skittish\n    skulking             skulk\n    skull                skull\n    skulls               skull\n    sky                  sky\n    skyey                skyei\n    skyish               skyish\n    slab                 slab\n    slack                slack\n    slackly              slackli\n    slackness            slack\n    slain                slain\n    slake                slake\n    sland                sland\n    slander              slander\n    slandered            slander\n    slanderer            slander\n    slanderers           slander\n    slandering           slander\n    slanderous           slander\n    slanders             slander\n    slash                slash\n    slaught              slaught\n    slaughter            slaughter\n    slaughtered          slaughter\n    slaughterer          slaughter\n    slaughterman         slaughterman\n    slaughtermen         slaughtermen\n    slaughterous         slaughter\n    slaughters           slaughter\n    slave                slave\n    slaver               slaver\n    slavery              slaveri\n    slaves               slave\n    slavish              slavish\n    slay                 slai\n    slayeth              slayeth\n    slaying              slai\n    slays                slai\n    sleave               sleav\n    sledded              sled\n    sleek                sleek\n    sleekly              sleekli\n    sleep                sleep\n    sleeper              sleeper\n    sleepers             sleeper\n    sleepest             sleepest\n    sleeping             sleep\n    sleeps               sleep\n    sleepy               sleepi\n    sleeve               sleev\n    sleeves              sleev\n    sleid                sleid\n    sleided              sleid\n    sleight              sleight\n    sleights             sleight\n    slender              slender\n    slenderer            slender\n    slenderly            slenderli\n    slept                slept\n    slew                 slew\n    slewest              slewest\n    slice                slice\n    slid                 slid\n    slide                slide\n    slides               slide\n    sliding              slide\n    slight               slight\n    slighted             slight\n    slightest            slightest\n    slightly             slightli\n    slightness           slight\n    slights              slight\n    slily                slili\n    slime                slime\n    slimy                slimi\n    slings               sling\n    slink                slink\n    slip                 slip\n    slipp                slipp\n    slipper              slipper\n    slippers             slipper\n    slippery             slipperi\n    slips                slip\n    slish                slish\n    slit                 slit\n    sliver               sliver\n    slobb                slobb\n    slomber              slomber\n    slop                 slop\n    slope                slope\n    slops                slop\n    sloth                sloth\n    slothful             sloth\n    slough               slough\n    slovenly             slovenli\n    slovenry             slovenri\n    slow                 slow\n    slower               slower\n    slowly               slowli\n    slowness             slow\n    slubber              slubber\n    slug                 slug\n    sluggard             sluggard\n    sluggardiz           sluggardiz\n    sluggish             sluggish\n    sluic                sluic\n    slumb                slumb\n    slumber              slumber\n    slumbers             slumber\n    slumbery             slumberi\n    slunk                slunk\n    slut                 slut\n    sluts                slut\n    sluttery             slutteri\n    sluttish             sluttish\n    sluttishness         sluttish\n    sly                  sly\n    slys                 sly\n    smack                smack\n    smacking             smack\n    smacks               smack\n    small                small\n    smaller              smaller\n    smallest             smallest\n    smallness            small\n    smalus               smalu\n    smart                smart\n    smarting             smart\n    smartly              smartli\n    smatch               smatch\n    smatter              smatter\n    smear                smear\n    smell                smell\n    smelling             smell\n    smells               smell\n    smelt                smelt\n    smil                 smil\n    smile                smile\n    smiled               smile\n    smiles               smile\n    smilest              smilest\n    smilets              smilet\n    smiling              smile\n    smilingly            smilingli\n    smirch               smirch\n    smirched             smirch\n    smit                 smit\n    smite                smite\n    smites               smite\n    smith                smith\n    smithfield           smithfield\n    smock                smock\n    smocks               smock\n    smok                 smok\n    smoke                smoke\n    smoked               smoke\n    smokes               smoke\n    smoking              smoke\n    smoky                smoki\n    smooth               smooth\n    smoothed             smooth\n    smoothing            smooth\n    smoothly             smoothli\n    smoothness           smooth\n    smooths              smooth\n    smote                smote\n    smoth                smoth\n    smother              smother\n    smothered            smother\n    smothering           smother\n    smug                 smug\n    smulkin              smulkin\n    smutch               smutch\n    snaffle              snaffl\n    snail                snail\n    snails               snail\n    snake                snake\n    snakes               snake\n    snaky                snaki\n    snap                 snap\n    snapp                snapp\n    snapper              snapper\n    snar                 snar\n    snare                snare\n    snares               snare\n    snarl                snarl\n    snarleth             snarleth\n    snarling             snarl\n    snatch               snatch\n    snatchers            snatcher\n    snatches             snatch\n    snatching            snatch\n    sneak                sneak\n    sneaking             sneak\n    sneap                sneap\n    sneaping             sneap\n    sneck                sneck\n    snip                 snip\n    snipe                snipe\n    snipt                snipt\n    snore                snore\n    snores               snore\n    snoring              snore\n    snorting             snort\n    snout                snout\n    snow                 snow\n    snowballs            snowbal\n    snowed               snow\n    snowy                snowi\n    snuff                snuff\n    snuffs               snuff\n    snug                 snug\n    so                   so\n    soak                 soak\n    soaking              soak\n    soaks                soak\n    soar                 soar\n    soaring              soar\n    soars                soar\n    sob                  sob\n    sobbing              sob\n    sober                sober\n    soberly              soberli\n    sobriety             sobrieti\n    sobs                 sob\n    sociable             sociabl\n    societies            societi\n    society              societi\n    socks                sock\n    socrates             socrat\n    sod                  sod\n    sodden               sodden\n    soe                  soe\n    soever               soever\n    soft                 soft\n    soften               soften\n    softens              soften\n    softer               softer\n    softest              softest\n    softly               softli\n    softness             soft\n    soil                 soil\n    soiled               soil\n    soilure              soilur\n    soit                 soit\n    sojourn              sojourn\n    sol                  sol\n    sola                 sola\n    solace               solac\n    solanio              solanio\n    sold                 sold\n    soldat               soldat\n    solder               solder\n    soldest              soldest\n    soldier              soldier\n    soldiers             soldier\n    soldiership          soldiership\n    sole                 sole\n    solely               sole\n    solem                solem\n    solemn               solemn\n    solemness            solem\n    solemnities          solemn\n    solemnity            solemn\n    solemniz             solemniz\n    solemnize            solemn\n    solemnized           solemn\n    solemnly             solemnli\n    soles                sole\n    solicit              solicit\n    solicitation         solicit\n    solicited            solicit\n    soliciting           solicit\n    solicitings          solicit\n    solicitor            solicitor\n    solicits             solicit\n    solid                solid\n    solidares            solidar\n    solidity             solid\n    solinus              solinu\n    solitary             solitari\n    solomon              solomon\n    solon                solon\n    solum                solum\n    solus                solu\n    solyman              solyman\n    some                 some\n    somebody             somebodi\n    someone              someon\n    somerset             somerset\n    somerville           somervil\n    something            someth\n    sometime             sometim\n    sometimes            sometim\n    somever              somev\n    somewhat             somewhat\n    somewhere            somewher\n    somewhither          somewhith\n    somme                somm\n    son                  son\n    sonance              sonanc\n    song                 song\n    songs                song\n    sonnet               sonnet\n    sonneting            sonnet\n    sonnets              sonnet\n    sons                 son\n    sont                 sont\n    sonties              sonti\n    soon                 soon\n    sooner               sooner\n    soonest              soonest\n    sooth                sooth\n    soothe               sooth\n    soothers             soother\n    soothing             sooth\n    soothsay             soothsai\n    soothsayer           soothsay\n    sooty                sooti\n    sop                  sop\n    sophister            sophist\n    sophisticated        sophist\n    sophy                sophi\n    sops                 sop\n    sorcerer             sorcer\n    sorcerers            sorcer\n    sorceress            sorceress\n    sorceries            sorceri\n    sorcery              sorceri\n    sore                 sore\n    sorel                sorel\n    sorely               sore\n    sorer                sorer\n    sores                sore\n    sorrier              sorrier\n    sorriest             sorriest\n    sorrow               sorrow\n    sorrowed             sorrow\n    sorrowest            sorrowest\n    sorrowful            sorrow\n    sorrowing            sorrow\n    sorrows              sorrow\n    sorry                sorri\n    sort                 sort\n    sortance             sortanc\n    sorted               sort\n    sorting              sort\n    sorts                sort\n    sossius              sossiu\n    sot                  sot\n    soto                 soto\n    sots                 sot\n    sottish              sottish\n    soud                 soud\n    sought               sought\n    soul                 soul\n    sould                sould\n    soulless             soulless\n    souls                soul\n    sound                sound\n    sounded              sound\n    sounder              sounder\n    soundest             soundest\n    sounding             sound\n    soundless            soundless\n    soundly              soundli\n    soundness            sound\n    soundpost            soundpost\n    sounds               sound\n    sour                 sour\n    source               sourc\n    sources              sourc\n    sourest              sourest\n    sourly               sourli\n    sours                sour\n    sous                 sou\n    souse                sous\n    south                south\n    southam              southam\n    southampton          southampton\n    southerly            southerli\n    southern             southern\n    southward            southward\n    southwark            southwark\n    southwell            southwel\n    souviendrai          souviendrai\n    sov                  sov\n    sovereign            sovereign\n    sovereignest         sovereignest\n    sovereignly          sovereignli\n    sovereignty          sovereignti\n    sovereignvours       sovereignvour\n    sow                  sow\n    sowing               sow\n    sowl                 sowl\n    sowter               sowter\n    space                space\n    spaces               space\n    spacious             spaciou\n    spade                spade\n    spades               spade\n    spain                spain\n    spak                 spak\n    spake                spake\n    spakest              spakest\n    span                 span\n    spangle              spangl\n    spangled             spangl\n    spaniard             spaniard\n    spaniel              spaniel\n    spaniels             spaniel\n    spanish              spanish\n    spann                spann\n    spans                span\n    spar                 spar\n    spare                spare\n    spares               spare\n    sparing              spare\n    sparingly            sparingli\n    spark                spark\n    sparkle              sparkl\n    sparkles             sparkl\n    sparkling            sparkl\n    sparks               spark\n    sparrow              sparrow\n    sparrows             sparrow\n    sparta               sparta\n    spartan              spartan\n    spavin               spavin\n    spavins              spavin\n    spawn                spawn\n    speak                speak\n    speaker              speaker\n    speakers             speaker\n    speakest             speakest\n    speaketh             speaketh\n    speaking             speak\n    speaks               speak\n    spear                spear\n    speargrass           speargrass\n    spears               spear\n    special              special\n    specialities         special\n    specially            special\n    specialties          specialti\n    specialty            specialti\n    specify              specifi\n    speciously           specious\n    spectacle            spectacl\n    spectacled           spectacl\n    spectacles           spectacl\n    spectators           spectat\n    spectatorship        spectatorship\n    speculation          specul\n    speculations         specul\n    speculative          specul\n    sped                 sped\n    speech               speech\n    speeches             speech\n    speechless           speechless\n    speed                speed\n    speeded              speed\n    speedier             speedier\n    speediest            speediest\n    speedily             speedili\n    speediness           speedi\n    speeding             speed\n    speeds               speed\n    speedy               speedi\n    speens               speen\n    spell                spell\n    spelling             spell\n    spells               spell\n    spelt                spelt\n    spencer              spencer\n    spend                spend\n    spendest             spendest\n    spending             spend\n    spends               spend\n    spendthrift          spendthrift\n    spent                spent\n    sperato              sperato\n    sperm                sperm\n    spero                spero\n    sperr                sperr\n    spher                spher\n    sphere               sphere\n    sphered              sphere\n    spheres              sphere\n    spherical            spheric\n    sphery               spheri\n    sphinx               sphinx\n    spice                spice\n    spiced               spice\n    spicery              spiceri\n    spices               spice\n    spider               spider\n    spiders              spider\n    spied                spi\n    spies                spi\n    spieth               spieth\n    spightfully          spightfulli\n    spigot               spigot\n    spill                spill\n    spilling             spill\n    spills               spill\n    spilt                spilt\n    spilth               spilth\n    spin                 spin\n    spinii               spinii\n    spinners             spinner\n    spinster             spinster\n    spinsters            spinster\n    spire                spire\n    spirit               spirit\n    spirited             spirit\n    spiritless           spiritless\n    spirits              spirit\n    spiritual            spiritu\n    spiritualty          spiritualti\n    spirt                spirt\n    spit                 spit\n    spital               spital\n    spite                spite\n    spited               spite\n    spiteful             spite\n    spites               spite\n    spits                spit\n    spitted              spit\n    spitting             spit\n    splay                splai\n    spleen               spleen\n    spleenful            spleen\n    spleens              spleen\n    spleeny              spleeni\n    splendour            splendour\n    splenitive           splenit\n    splinter             splinter\n    splinters            splinter\n    split                split\n    splits               split\n    splitted             split\n    splitting            split\n    spoil                spoil\n    spoils               spoil\n    spok                 spok\n    spoke                spoke\n    spoken               spoken\n    spokes               spoke\n    spokesman            spokesman\n    sponge               spong\n    spongy               spongi\n    spoon                spoon\n    spoons               spoon\n    sport                sport\n    sportful             sport\n    sporting             sport\n    sportive             sportiv\n    sports               sport\n    spot                 spot\n    spotless             spotless\n    spots                spot\n    spotted              spot\n    spousal              spousal\n    spouse               spous\n    spout                spout\n    spouting             spout\n    spouts               spout\n    sprag                sprag\n    sprang               sprang\n    sprat                sprat\n    sprawl               sprawl\n    spray                sprai\n    sprays               sprai\n    spread               spread\n    spreading            spread\n    spreads              spread\n    sprighted            spright\n    sprightful           spright\n    sprightly            sprightli\n    sprigs               sprig\n    spring               spring\n    springe              spring\n    springes             spring\n    springeth            springeth\n    springhalt           springhalt\n    springing            spring\n    springs              spring\n    springtime           springtim\n    sprinkle             sprinkl\n    sprinkles            sprinkl\n    sprite               sprite\n    sprited              sprite\n    spritely             sprite\n    sprites              sprite\n    spriting             sprite\n    sprout               sprout\n    spruce               spruce\n    sprung               sprung\n    spun                 spun\n    spur                 spur\n    spurio               spurio\n    spurn                spurn\n    spurns               spurn\n    spurr                spurr\n    spurrer              spurrer\n    spurring             spur\n    spurs                spur\n    spy                  spy\n    spying               spy\n    squabble             squabbl\n    squadron             squadron\n    squadrons            squadron\n    squand               squand\n    squar                squar\n    square               squar\n    squarer              squarer\n    squares              squar\n    squash               squash\n    squeak               squeak\n    squeaking            squeak\n    squeal               squeal\n    squealing            squeal\n    squeezes             squeez\n    squeezing            squeez\n    squele               squel\n    squier               squier\n    squints              squint\n    squiny               squini\n    squire               squir\n    squires              squir\n    squirrel             squirrel\n    st                   st\n    stab                 stab\n    stabb                stabb\n    stabbed              stab\n    stabbing             stab\n    stable               stabl\n    stableness           stabl\n    stables              stabl\n    stablish             stablish\n    stablishment         stablish\n    stabs                stab\n    stacks               stack\n    staff                staff\n    stafford             stafford\n    staffords            stafford\n    staffordshire        staffordshir\n    stag                 stag\n    stage                stage\n    stages               stage\n    stagger              stagger\n    staggering           stagger\n    staggers             stagger\n    stags                stag\n    staid                staid\n    staider              staider\n    stain                stain\n    stained              stain\n    staines              stain\n    staineth             staineth\n    staining             stain\n    stainless            stainless\n    stains               stain\n    stair                stair\n    stairs               stair\n    stake                stake\n    stakes               stake\n    stale                stale\n    staled               stale\n    stalk                stalk\n    stalking             stalk\n    stalks               stalk\n    stall                stall\n    stalling             stall\n    stalls               stall\n    stamford             stamford\n    stammer              stammer\n    stamp                stamp\n    stamped              stamp\n    stamps               stamp\n    stanch               stanch\n    stanchless           stanchless\n    stand                stand\n    standard             standard\n    standards            standard\n    stander              stander\n    standers             stander\n    standest             standest\n    standeth             standeth\n    standing             stand\n    stands               stand\n    staniel              staniel\n    stanley              stanlei\n    stanze               stanz\n    stanzo               stanzo\n    stanzos              stanzo\n    staple               stapl\n    staples              stapl\n    star                 star\n    stare                stare\n    stared               stare\n    stares               stare\n    staring              stare\n    starings             stare\n    stark                stark\n    starkly              starkli\n    starlight            starlight\n    starling             starl\n    starr                starr\n    starry               starri\n    stars                star\n    start                start\n    started              start\n    starting             start\n    startingly           startingli\n    startle              startl\n    startles             startl\n    starts               start\n    starv                starv\n    starve               starv\n    starved              starv\n    starvelackey         starvelackei\n    starveling           starvel\n    starveth             starveth\n    starving             starv\n    state                state\n    statelier            stateli\n    stately              state\n    states               state\n    statesman            statesman\n    statesmen            statesmen\n    statilius            statiliu\n    station              station\n    statist              statist\n    statists             statist\n    statue               statu\n    statues              statu\n    stature              statur\n    statures             statur\n    statute              statut\n    statutes             statut\n    stave                stave\n    staves               stave\n    stay                 stai\n    stayed               stai\n    stayest              stayest\n    staying              stai\n    stays                stai\n    stead                stead\n    steaded              stead\n    steadfast            steadfast\n    steadier             steadier\n    steads               stead\n    steal                steal\n    stealer              stealer\n    stealers             stealer\n    stealing             steal\n    steals               steal\n    stealth              stealth\n    stealthy             stealthi\n    steed                steed\n    steeds               steed\n    steel                steel\n    steeled              steel\n    steely               steeli\n    steep                steep\n    steeped              steep\n    steeple              steepl\n    steeples             steepl\n    steeps               steep\n    steepy               steepi\n    steer                steer\n    steerage             steerag\n    steering             steer\n    steers               steer\n    stelled              stell\n    stem                 stem\n    stemming             stem\n    stench               stench\n    step                 step\n    stepdame             stepdam\n    stephano             stephano\n    stephen              stephen\n    stepmothers          stepmoth\n    stepp                stepp\n    stepping             step\n    steps                step\n    sterile              steril\n    sterility            steril\n    sterling             sterl\n    stern                stern\n    sternage             sternag\n    sterner              sterner\n    sternest             sternest\n    sternness            stern\n    steterat             steterat\n    stew                 stew\n    steward              steward\n    stewards             steward\n    stewardship          stewardship\n    stewed               stew\n    stews                stew\n    stick                stick\n    sticking             stick\n    stickler             stickler\n    sticks               stick\n    stiff                stiff\n    stiffen              stiffen\n    stiffly              stiffli\n    stifle               stifl\n    stifled              stifl\n    stifles              stifl\n    stigmatic            stigmat\n    stigmatical          stigmat\n    stile                stile\n    still                still\n    stiller              stiller\n    stillest             stillest\n    stillness            still\n    stilly               stilli\n    sting                sting\n    stinging             sting\n    stingless            stingless\n    stings               sting\n    stink                stink\n    stinking             stink\n    stinkingly           stinkingli\n    stinks               stink\n    stint                stint\n    stinted              stint\n    stints               stint\n    stir                 stir\n    stirr                stirr\n    stirred              stir\n    stirrer              stirrer\n    stirrers             stirrer\n    stirreth             stirreth\n    stirring             stir\n    stirrup              stirrup\n    stirrups             stirrup\n    stirs                stir\n    stitchery            stitcheri\n    stitches             stitch\n    stithied             stithi\n    stithy               stithi\n    stoccadoes           stoccado\n    stoccata             stoccata\n    stock                stock\n    stockfish            stockfish\n    stocking             stock\n    stockings            stock\n    stockish             stockish\n    stocks               stock\n    stog                 stog\n    stogs                stog\n    stoics               stoic\n    stokesly             stokesli\n    stol                 stol\n    stole                stole\n    stolen               stolen\n    stolest              stolest\n    stomach              stomach\n    stomachers           stomach\n    stomaching           stomach\n    stomachs             stomach\n    ston                 ston\n    stone                stone\n    stonecutter          stonecutt\n    stones               stone\n    stonish              stonish\n    stony                stoni\n    stood                stood\n    stool                stool\n    stools               stool\n    stoop                stoop\n    stooping             stoop\n    stoops               stoop\n    stop                 stop\n    stope                stope\n    stopp                stopp\n    stopped              stop\n    stopping             stop\n    stops                stop\n    stor                 stor\n    store                store\n    storehouse           storehous\n    storehouses          storehous\n    stores               store\n    stories              stori\n    storm                storm\n    stormed              storm\n    storming             storm\n    storms               storm\n    stormy               stormi\n    story                stori\n    stoup                stoup\n    stoups               stoup\n    stout                stout\n    stouter              stouter\n    stoutly              stoutli\n    stoutness            stout\n    stover               stover\n    stow                 stow\n    stowage              stowag\n    stowed               stow\n    strachy              strachi\n    stragglers           straggler\n    straggling           straggl\n    straight             straight\n    straightest          straightest\n    straightway          straightwai\n    strain               strain\n    strained             strain\n    straining            strain\n    strains              strain\n    strait               strait\n    straited             strait\n    straiter             straiter\n    straitly             straitli\n    straitness           strait\n    straits              strait\n    strand               strand\n    strange              strang\n    strangely            strang\n    strangeness          strang\n    stranger             stranger\n    strangers            stranger\n    strangest            strangest\n    strangle             strangl\n    strangled            strangl\n    strangler            strangler\n    strangles            strangl\n    strangling           strangl\n    strappado            strappado\n    straps               strap\n    stratagem            stratagem\n    stratagems           stratagem\n    stratford            stratford\n    strato               strato\n    straw                straw\n    strawberries         strawberri\n    strawberry           strawberri\n    straws               straw\n    strawy               strawi\n    stray                strai\n    straying             strai\n    strays               strai\n    streak               streak\n    streaks              streak\n    stream               stream\n    streamers            streamer\n    streaming            stream\n    streams              stream\n    streching            strech\n    street               street\n    streets              street\n    strength             strength\n    strengthen           strengthen\n    strengthened         strengthen\n    strengthless         strengthless\n    strengths            strength\n    stretch              stretch\n    stretched            stretch\n    stretches            stretch\n    stretching           stretch\n    strew                strew\n    strewing             strew\n    strewings            strew\n    strewments           strewment\n    stricken             stricken\n    strict               strict\n    stricter             stricter\n    strictest            strictest\n    strictly             strictli\n    stricture            strictur\n    stride               stride\n    strides              stride\n    striding             stride\n    strife               strife\n    strifes              strife\n    strik                strik\n    strike               strike\n    strikers             striker\n    strikes              strike\n    strikest             strikest\n    striking             strike\n    string               string\n    stringless           stringless\n    strings              string\n    strip                strip\n    stripes              stripe\n    stripling            stripl\n    striplings           stripl\n    stripp               stripp\n    stripping            strip\n    striv                striv\n    strive               strive\n    strives              strive\n    striving             strive\n    strok                strok\n    stroke               stroke\n    strokes              stroke\n    strond               strond\n    stronds              strond\n    strong               strong\n    stronger             stronger\n    strongest            strongest\n    strongly             strongli\n    strooke              strook\n    strossers            strosser\n    strove               strove\n    strown               strown\n    stroy                stroi\n    struck               struck\n    strucken             strucken\n    struggle             struggl\n    struggles            struggl\n    struggling           struggl\n    strumpet             strumpet\n    strumpeted           strumpet\n    strumpets            strumpet\n    strung               strung\n    strut                strut\n    struts               strut\n    strutted             strut\n    strutting            strut\n    stubble              stubbl\n    stubborn             stubborn\n    stubbornest          stubbornest\n    stubbornly           stubbornli\n    stubbornness         stubborn\n    stuck                stuck\n    studded              stud\n    student              student\n    students             student\n    studied              studi\n    studies              studi\n    studious             studiou\n    studiously           studious\n    studs                stud\n    study                studi\n    studying             studi\n    stuff                stuff\n    stuffing             stuf\n    stuffs               stuff\n    stumble              stumbl\n    stumbled             stumbl\n    stumblest            stumblest\n    stumbling            stumbl\n    stump                stump\n    stumps               stump\n    stung                stung\n    stupefy              stupefi\n    stupid               stupid\n    stupified            stupifi\n    stuprum              stuprum\n    sturdy               sturdi\n    sty                  sty\n    styga                styga\n    stygian              stygian\n    styl                 styl\n    style                style\n    styx                 styx\n    su                   su\n    sub                  sub\n    subcontracted        subcontract\n    subdu                subdu\n    subdue               subdu\n    subdued              subdu\n    subduements          subduement\n    subdues              subdu\n    subduing             subdu\n    subject              subject\n    subjected            subject\n    subjection           subject\n    subjects             subject\n    submerg              submerg\n    submission           submiss\n    submissive           submiss\n    submit               submit\n    submits              submit\n    submitting           submit\n    suborn               suborn\n    subornation          suborn\n    suborned             suborn\n    subscrib             subscrib\n    subscribe            subscrib\n    subscribed           subscrib\n    subscribes           subscrib\n    subscription         subscript\n    subsequent           subsequ\n    subsidies            subsidi\n    subsidy              subsidi\n    subsist              subsist\n    subsisting           subsist\n    substance            substanc\n    substances           substanc\n    substantial          substanti\n    substitute           substitut\n    substituted          substitut\n    substitutes          substitut\n    substitution         substitut\n    subtile              subtil\n    subtilly             subtilli\n    subtle               subtl\n    subtleties           subtleti\n    subtlety             subtleti\n    subtly               subtli\n    subtractors          subtractor\n    suburbs              suburb\n    subversion           subvers\n    subverts             subvert\n    succedant            succed\n    succeed              succe\n    succeeded            succeed\n    succeeders           succeed\n    succeeding           succeed\n    succeeds             succe\n    success              success\n    successantly         successantli\n    successes            success\n    successful           success\n    successfully         successfulli\n    succession           success\n    successive           success\n    successively         success\n    successor            successor\n    successors           successor\n    succour              succour\n    succours             succour\n    such                 such\n    suck                 suck\n    sucker               sucker\n    suckers              sucker\n    sucking              suck\n    suckle               suckl\n    sucks                suck\n    sudden               sudden\n    suddenly             suddenli\n    sue                  sue\n    sued                 su\n    suerly               suerli\n    sues                 sue\n    sueth                sueth\n    suff                 suff\n    suffer               suffer\n    sufferance           suffer\n    sufferances          suffer\n    suffered             suffer\n    suffering            suffer\n    suffers              suffer\n    suffic               suffic\n    suffice              suffic\n    sufficed             suffic\n    suffices             suffic\n    sufficeth            sufficeth\n    sufficiency          suffici\n    sufficient           suffici\n    sufficiently         suffici\n    sufficing            suffic\n    sufficit             sufficit\n    suffigance           suffig\n    suffocate            suffoc\n    suffocating          suffoc\n    suffocation          suffoc\n    suffolk              suffolk\n    suffrage             suffrag\n    suffrages            suffrag\n    sug                  sug\n    sugar                sugar\n    sugarsop             sugarsop\n    suggest              suggest\n    suggested            suggest\n    suggesting           suggest\n    suggestion           suggest\n    suggestions          suggest\n    suggests             suggest\n    suis                 sui\n    suit                 suit\n    suitable             suitabl\n    suited               suit\n    suiting              suit\n    suitor               suitor\n    suitors              suitor\n    suits                suit\n    suivez               suivez\n    sullen               sullen\n    sullens              sullen\n    sullied              sulli\n    sullies              sulli\n    sully                sulli\n    sulph                sulph\n    sulpherous           sulpher\n    sulphur              sulphur\n    sulphurous           sulphur\n    sultan               sultan\n    sultry               sultri\n    sum                  sum\n    sumless              sumless\n    summ                 summ\n    summa                summa\n    summary              summari\n    summer               summer\n    summers              summer\n    summit               summit\n    summon               summon\n    summoners            summon\n    summons              summon\n    sumpter              sumpter\n    sumptuous            sumptuou\n    sumptuously          sumptuous\n    sums                 sum\n    sun                  sun\n    sunbeams             sunbeam\n    sunburning           sunburn\n    sunburnt             sunburnt\n    sund                 sund\n    sunday               sundai\n    sundays              sundai\n    sunder               sunder\n    sunders              sunder\n    sundry               sundri\n    sung                 sung\n    sunk                 sunk\n    sunken               sunken\n    sunny                sunni\n    sunrising            sunris\n    suns                 sun\n    sunset               sunset\n    sunshine             sunshin\n    sup                  sup\n    super                super\n    superficial          superfici\n    superficially        superfici\n    superfluity          superflu\n    superfluous          superflu\n    superfluously        superflu\n    superflux            superflux\n    superior             superior\n    supernal             supern\n    supernatural         supernatur\n    superpraise          superprais\n    superscript          superscript\n    superscription       superscript\n    superserviceable     superservic\n    superstition         superstit\n    superstitious        superstiti\n    superstitiously      superstiti\n    supersubtle          supersubtl\n    supervise            supervis\n    supervisor           supervisor\n    supp                 supp\n    supper               supper\n    suppers              supper\n    suppertime           suppertim\n    supping              sup\n    supplant             supplant\n    supple               suppl\n    suppler              suppler\n    suppliance           supplianc\n    suppliant            suppliant\n    suppliants           suppliant\n    supplicant           supplic\n    supplication         supplic\n    supplications        supplic\n    supplie              suppli\n    supplied             suppli\n    supplies             suppli\n    suppliest            suppliest\n    supply               suppli\n    supplyant            supplyant\n    supplying            suppli\n    supplyment           supplyment\n    support              support\n    supportable          support\n    supportance          support\n    supported            support\n    supporter            support\n    supporters           support\n    supporting           support\n    supportor            supportor\n    suppos               suppo\n    supposal             suppos\n    suppose              suppos\n    supposed             suppos\n    supposes             suppos\n    supposest            supposest\n    supposing            suppos\n    supposition          supposit\n    suppress             suppress\n    suppressed           suppress\n    suppresseth          suppresseth\n    supremacy            supremaci\n    supreme              suprem\n    sups                 sup\n    sur                  sur\n    surance              suranc\n    surcease             surceas\n    surd                 surd\n    sure                 sure\n    surecard             surecard\n    surely               sure\n    surer                surer\n    surest               surest\n    sureties             sureti\n    surety               sureti\n    surfeit              surfeit\n    surfeited            surfeit\n    surfeiter            surfeit\n    surfeiting           surfeit\n    surfeits             surfeit\n    surge                surg\n    surgeon              surgeon\n    surgeons             surgeon\n    surgere              surger\n    surgery              surgeri\n    surges               surg\n    surly                surli\n    surmis               surmi\n    surmise              surmis\n    surmised             surmis\n    surmises             surmis\n    surmount             surmount\n    surmounted           surmount\n    surmounts            surmount\n    surnam               surnam\n    surname              surnam\n    surnamed             surnam\n    surpasseth           surpasseth\n    surpassing           surpass\n    surplice             surplic\n    surplus              surplu\n    surpris              surpri\n    surprise             surpris\n    surprised            surpris\n    surrender            surrend\n    surrey               surrei\n    surreys              surrei\n    survey               survei\n    surveyest            surveyest\n    surveying            survei\n    surveyor             surveyor\n    surveyors            surveyor\n    surveys              survei\n    survive              surviv\n    survives             surviv\n    survivor             survivor\n    susan                susan\n    suspect              suspect\n    suspected            suspect\n    suspecting           suspect\n    suspects             suspect\n    suspend              suspend\n    suspense             suspens\n    suspicion            suspicion\n    suspicions           suspicion\n    suspicious           suspici\n    suspiration          suspir\n    suspire              suspir\n    sust                 sust\n    sustain              sustain\n    sustaining           sustain\n    sutler               sutler\n    sutton               sutton\n    suum                 suum\n    swabber              swabber\n    swaddling            swaddl\n    swag                 swag\n    swagg                swagg\n    swagger              swagger\n    swaggerer            swagger\n    swaggerers           swagger\n    swaggering           swagger\n    swain                swain\n    swains               swain\n    swallow              swallow\n    swallowed            swallow\n    swallowing           swallow\n    swallows             swallow\n    swam                 swam\n    swan                 swan\n    swans                swan\n    sward                sward\n    sware                sware\n    swarm                swarm\n    swarming             swarm\n    swart                swart\n    swarth               swarth\n    swarths              swarth\n    swarthy              swarthi\n    swashers             swasher\n    swashing             swash\n    swath                swath\n    swathing             swath\n    swathling            swathl\n    sway                 swai\n    swaying              swai\n    sways                swai\n    swear                swear\n    swearer              swearer\n    swearers             swearer\n    swearest             swearest\n    swearing             swear\n    swearings            swear\n    swears               swear\n    sweat                sweat\n    sweaten              sweaten\n    sweating             sweat\n    sweats               sweat\n    sweaty               sweati\n    sweep                sweep\n    sweepers             sweeper\n    sweeps               sweep\n    sweet                sweet\n    sweeten              sweeten\n    sweetens             sweeten\n    sweeter              sweeter\n    sweetest             sweetest\n    sweetheart           sweetheart\n    sweeting             sweet\n    sweetly              sweetli\n    sweetmeats           sweetmeat\n    sweetness            sweet\n    sweets               sweet\n    swell                swell\n    swelling             swell\n    swellings            swell\n    swells               swell\n    swelter              swelter\n    sweno                sweno\n    swept                swept\n    swerve               swerv\n    swerver              swerver\n    swerving             swerv\n    swift                swift\n    swifter              swifter\n    swiftest             swiftest\n    swiftly              swiftli\n    swiftness            swift\n    swill                swill\n    swills               swill\n    swim                 swim\n    swimmer              swimmer\n    swimmers             swimmer\n    swimming             swim\n    swims                swim\n    swine                swine\n    swineherds           swineherd\n    swing                swing\n    swinge               swing\n    swinish              swinish\n    swinstead            swinstead\n    switches             switch\n    swits                swit\n    switzers             switzer\n    swol                 swol\n    swoll                swoll\n    swoln                swoln\n    swoon                swoon\n    swooned              swoon\n    swooning             swoon\n    swoons               swoon\n    swoop                swoop\n    swoopstake           swoopstak\n    swor                 swor\n    sword                sword\n    sworder              sworder\n    swords               sword\n    swore                swore\n    sworn                sworn\n    swounded             swound\n    swounds              swound\n    swum                 swum\n    swung                swung\n    sy                   sy\n    sycamore             sycamor\n    sycorax              sycorax\n    sylla                sylla\n    syllable             syllabl\n    syllables            syllabl\n    syllogism            syllog\n    symbols              symbol\n    sympathise           sympathis\n    sympathiz            sympathiz\n    sympathize           sympath\n    sympathized          sympath\n    sympathy             sympathi\n    synagogue            synagogu\n    synod                synod\n    synods               synod\n    syracuse             syracus\n    syracusian           syracusian\n    syracusians          syracusian\n    syria                syria\n    syrups               syrup\n    t                    t\n    ta                   ta\n    taber                taber\n    table                tabl\n    tabled               tabl\n    tables               tabl\n    tablet               tablet\n    tabor                tabor\n    taborer              tabor\n    tabors               tabor\n    tabourines           tabourin\n    taciturnity          taciturn\n    tack                 tack\n    tackle               tackl\n    tackled              tackl\n    tackles              tackl\n    tackling             tackl\n    tacklings            tackl\n    taddle               taddl\n    tadpole              tadpol\n    taffeta              taffeta\n    taffety              taffeti\n    tag                  tag\n    tagrag               tagrag\n    tah                  tah\n    tail                 tail\n    tailor               tailor\n    tailors              tailor\n    tails                tail\n    taint                taint\n    tainted              taint\n    tainting             taint\n    taints               taint\n    tainture             taintur\n    tak                  tak\n    take                 take\n    taken                taken\n    taker                taker\n    takes                take\n    takest               takest\n    taketh               taketh\n    taking               take\n    tal                  tal\n    talbot               talbot\n    talbotites           talbotit\n    talbots              talbot\n    tale                 tale\n    talent               talent\n    talents              talent\n    taleporter           taleport\n    tales                tale\n    talk                 talk\n    talked               talk\n    talker               talker\n    talkers              talker\n    talkest              talkest\n    talking              talk\n    talks                talk\n    tall                 tall\n    taller               taller\n    tallest              tallest\n    tallies              talli\n    tallow               tallow\n    tally                talli\n    talons               talon\n    tam                  tam\n    tambourines          tambourin\n    tame                 tame\n    tamed                tame\n    tamely               tame\n    tameness             tame\n    tamer                tamer\n    tames                tame\n    taming               tame\n    tamora               tamora\n    tamworth             tamworth\n    tan                  tan\n    tang                 tang\n    tangle               tangl\n    tangled              tangl\n    tank                 tank\n    tanlings             tanl\n    tann                 tann\n    tanned               tan\n    tanner               tanner\n    tanquam              tanquam\n    tanta                tanta\n    tantaene             tantaen\n    tap                  tap\n    tape                 tape\n    taper                taper\n    tapers               taper\n    tapestries           tapestri\n    tapestry             tapestri\n    taphouse             taphous\n    tapp                 tapp\n    tapster              tapster\n    tapsters             tapster\n    tar                  tar\n    tardied              tardi\n    tardily              tardili\n    tardiness            tardi\n    tardy                tardi\n    tarentum             tarentum\n    targe                targ\n    targes               targ\n    target               target\n    targets              target\n    tarpeian             tarpeian\n    tarquin              tarquin\n    tarquins             tarquin\n    tarr                 tarr\n    tarre                tarr\n    tarriance            tarrianc\n    tarried              tarri\n    tarries              tarri\n    tarry                tarri\n    tarrying             tarri\n    tart                 tart\n    tartar               tartar\n    tartars              tartar\n    tartly               tartli\n    tartness             tart\n    task                 task\n    tasker               tasker\n    tasking              task\n    tasks                task\n    tassel               tassel\n    taste                tast\n    tasted               tast\n    tastes               tast\n    tasting              tast\n    tatt                 tatt\n    tatter               tatter\n    tattered             tatter\n    tatters              tatter\n    tattle               tattl\n    tattling             tattl\n    tattlings            tattl\n    taught               taught\n    taunt                taunt\n    taunted              taunt\n    taunting             taunt\n    tauntingly           tauntingli\n    taunts               taunt\n    taurus               tauru\n    tavern               tavern\n    taverns              tavern\n    tavy                 tavi\n    tawdry               tawdri\n    tawny                tawni\n    tax                  tax\n    taxation             taxat\n    taxations            taxat\n    taxes                tax\n    taxing               tax\n    tc                   tc\n    te                   te\n    teach                teach\n    teacher              teacher\n    teachers             teacher\n    teaches              teach\n    teachest             teachest\n    teacheth             teacheth\n    teaching             teach\n    team                 team\n    tear                 tear\n    tearful              tear\n    tearing              tear\n    tears                tear\n    tearsheet            tearsheet\n    teat                 teat\n    tedious              tediou\n    tediously            tedious\n    tediousness          tedious\n    teem                 teem\n    teeming              teem\n    teems                teem\n    teen                 teen\n    teeth                teeth\n    teipsum              teipsum\n    telamon              telamon\n    telamonius           telamoniu\n    tell                 tell\n    teller               teller\n    telling              tell\n    tells                tell\n    tellus               tellu\n    temp                 temp\n    temper               temper\n    temperality          temper\n    temperance           temper\n    temperate            temper\n    temperately          temper\n    tempers              temper\n    tempest              tempest\n    tempests             tempest\n    tempestuous          tempestu\n    temple               templ\n    temples              templ\n    temporal             tempor\n    temporary            temporari\n    temporiz             temporiz\n    temporize            tempor\n    temporizer           tempor\n    temps                temp\n    tempt                tempt\n    temptation           temptat\n    temptations          temptat\n    tempted              tempt\n    tempter              tempter\n    tempters             tempter\n    tempteth             tempteth\n    tempting             tempt\n    tempts               tempt\n    ten                  ten\n    tenable              tenabl\n    tenant               tenant\n    tenantius            tenantiu\n    tenantless           tenantless\n    tenants              tenant\n    tench                tench\n    tend                 tend\n    tendance             tendanc\n    tended               tend\n    tender               tender\n    tendered             tender\n    tenderly             tenderli\n    tenderness           tender\n    tenders              tender\n    tending              tend\n    tends                tend\n    tenedos              tenedo\n    tenement             tenement\n    tenements            tenement\n    tenfold              tenfold\n    tennis               tenni\n    tenour               tenour\n    tenours              tenour\n    tens                 ten\n    tent                 tent\n    tented               tent\n    tenth                tenth\n    tenths               tenth\n    tents                tent\n    tenure               tenur\n    tenures              tenur\n    tercel               tercel\n    tereus               tereu\n    term                 term\n    termagant            termag\n    termed               term\n    terminations         termin\n    termless             termless\n    terms                term\n    terra                terra\n    terrace              terrac\n    terram               terram\n    terras               terra\n    terre                terr\n    terrene              terren\n    terrestrial          terrestri\n    terrible             terribl\n    terribly             terribl\n    territories          territori\n    territory            territori\n    terror               terror\n    terrors              terror\n    tertian              tertian\n    tertio               tertio\n    test                 test\n    testament            testament\n    tested               test\n    tester               tester\n    testern              testern\n    testify              testifi\n    testimonied          testimoni\n    testimonies          testimoni\n    testimony            testimoni\n    testiness            testi\n    testril              testril\n    testy                testi\n    tetchy               tetchi\n    tether               tether\n    tetter               tetter\n    tevil                tevil\n    tewksbury            tewksburi\n    text                 text\n    tgv                  tgv\n    th                   th\n    thaes                thae\n    thames               thame\n    than                 than\n    thane                thane\n    thanes               thane\n    thank                thank\n    thanked              thank\n    thankful             thank\n    thankfully           thankfulli\n    thankfulness         thank\n    thanking             thank\n    thankings            thank\n    thankless            thankless\n    thanks               thank\n    thanksgiving         thanksgiv\n    thasos               thaso\n    that                 that\n    thatch               thatch\n    thaw                 thaw\n    thawing              thaw\n    thaws                thaw\n    the                  the\n    theatre              theatr\n    theban               theban\n    thebes               thebe\n    thee                 thee\n    theft                theft\n    thefts               theft\n    thein                thein\n    their                their\n    theirs               their\n    theise               theis\n    them                 them\n    theme                theme\n    themes               theme\n    themselves           themselv\n    then                 then\n    thence               thenc\n    thenceforth          thenceforth\n    theoric              theoric\n    there                there\n    thereabout           thereabout\n    thereabouts          thereabout\n    thereafter           thereaft\n    thereat              thereat\n    thereby              therebi\n    therefore            therefor\n    therein              therein\n    thereof              thereof\n    thereon              thereon\n    thereto              thereto\n    thereunto            thereunto\n    thereupon            thereupon\n    therewith            therewith\n    therewithal          therewith\n    thersites            thersit\n    these                these\n    theseus              theseu\n    thessalian           thessalian\n    thessaly             thessali\n    thetis               theti\n    thews                thew\n    they                 thei\n    thick                thick\n    thicken              thicken\n    thickens             thicken\n    thicker              thicker\n    thickest             thickest\n    thicket              thicket\n    thickskin            thickskin\n    thief                thief\n    thievery             thieveri\n    thieves              thiev\n    thievish             thievish\n    thigh                thigh\n    thighs               thigh\n    thimble              thimbl\n    thimbles             thimbl\n    thin                 thin\n    thine                thine\n    thing                thing\n    things               thing\n    think                think\n    thinkest             thinkest\n    thinking             think\n    thinkings            think\n    thinks               think\n    thinkst              thinkst\n    thinly               thinli\n    third                third\n    thirdly              thirdli\n    thirds               third\n    thirst               thirst\n    thirsting            thirst\n    thirsts              thirst\n    thirsty              thirsti\n    thirteen             thirteen\n    thirties             thirti\n    thirtieth            thirtieth\n    thirty               thirti\n    this                 thi\n    thisby               thisbi\n    thisne               thisn\n    thistle              thistl\n    thistles             thistl\n    thither              thither\n    thitherward          thitherward\n    thoas                thoa\n    thomas               thoma\n    thorn                thorn\n    thorns               thorn\n    thorny               thorni\n    thorough             thorough\n    thoroughly           thoroughli\n    those                those\n    thou                 thou\n    though               though\n    thought              thought\n    thoughtful           thought\n    thoughts             thought\n    thousand             thousand\n    thousands            thousand\n    thracian             thracian\n    thraldom             thraldom\n    thrall               thrall\n    thralled             thrall\n    thralls              thrall\n    thrash               thrash\n    thrasonical          thrason\n    thread               thread\n    threadbare           threadbar\n    threaden             threaden\n    threading            thread\n    threat               threat\n    threaten             threaten\n    threatening          threaten\n    threatens            threaten\n    threatest            threatest\n    threats              threat\n    three                three\n    threefold            threefold\n    threepence           threepenc\n    threepile            threepil\n    threes               three\n    threescore           threescor\n    thresher             thresher\n    threshold            threshold\n    threw                threw\n    thrice               thrice\n    thrift               thrift\n    thriftless           thriftless\n    thrifts              thrift\n    thrifty              thrifti\n    thrill               thrill\n    thrilling            thrill\n    thrills              thrill\n    thrive               thrive\n    thrived              thrive\n    thrivers             thriver\n    thrives              thrive\n    thriving             thrive\n    throat               throat\n    throats              throat\n    throbbing            throb\n    throbs               throb\n    throca               throca\n    throe                throe\n    throes               throe\n    thromuldo            thromuldo\n    thron                thron\n    throne               throne\n    throned              throne\n    thrones              throne\n    throng               throng\n    thronging            throng\n    throngs              throng\n    throstle             throstl\n    throttle             throttl\n    through              through\n    throughfare          throughfar\n    throughfares         throughfar\n    throughly            throughli\n    throughout           throughout\n    throw                throw\n    thrower              thrower\n    throwest             throwest\n    throwing             throw\n    thrown               thrown\n    throws               throw\n    thrum                thrum\n    thrumm               thrumm\n    thrush               thrush\n    thrust               thrust\n    thrusteth            thrusteth\n    thrusting            thrust\n    thrusts              thrust\n    thumb                thumb\n    thumbs               thumb\n    thump                thump\n    thund                thund\n    thunder              thunder\n    thunderbolt          thunderbolt\n    thunderbolts         thunderbolt\n    thunderer            thunder\n    thunders             thunder\n    thunderstone         thunderston\n    thunderstroke        thunderstrok\n    thurio               thurio\n    thursday             thursdai\n    thus                 thu\n    thwack               thwack\n    thwart               thwart\n    thwarted             thwart\n    thwarting            thwart\n    thwartings           thwart\n    thy                  thy\n    thyme                thyme\n    thymus               thymu\n    thyreus              thyreu\n    thyself              thyself\n    ti                   ti\n    tib                  tib\n    tiber                tiber\n    tiberio              tiberio\n    tibey                tibei\n    ticed                tice\n    tick                 tick\n    tickl                tickl\n    tickle               tickl\n    tickled              tickl\n    tickles              tickl\n    tickling             tickl\n    ticklish             ticklish\n    tiddle               tiddl\n    tide                 tide\n    tides                tide\n    tidings              tide\n    tidy                 tidi\n    tie                  tie\n    tied                 ti\n    ties                 ti\n    tiff                 tiff\n    tiger                tiger\n    tigers               tiger\n    tight                tight\n    tightly              tightli\n    tike                 tike\n    til                  til\n    tile                 tile\n    till                 till\n    tillage              tillag\n    tilly                tilli\n    tilt                 tilt\n    tilter               tilter\n    tilth                tilth\n    tilting              tilt\n    tilts                tilt\n    tiltyard             tiltyard\n    tim                  tim\n    timandra             timandra\n    timber               timber\n    time                 time\n    timeless             timeless\n    timelier             timeli\n    timely               time\n    times                time\n    timon                timon\n    timor                timor\n    timorous             timor\n    timorously           timor\n    tinct                tinct\n    tincture             tinctur\n    tinctures            tinctur\n    tinder               tinder\n    tingling             tingl\n    tinker               tinker\n    tinkers              tinker\n    tinsel               tinsel\n    tiny                 tini\n    tip                  tip\n    tipp                 tipp\n    tippling             tippl\n    tips                 tip\n    tipsy                tipsi\n    tiptoe               tipto\n    tir                  tir\n    tire                 tire\n    tired                tire\n    tires                tire\n    tirest               tirest\n    tiring               tire\n    tirra                tirra\n    tirrits              tirrit\n    tis                  ti\n    tish                 tish\n    tisick               tisick\n    tissue               tissu\n    titan                titan\n    titania              titania\n    tithe                tith\n    tithed               tith\n    tithing              tith\n    titinius             titiniu\n    title                titl\n    titled               titl\n    titleless            titleless\n    titles               titl\n    tittle               tittl\n    tittles              tittl\n    titular              titular\n    titus                titu\n    tn                   tn\n    to                   to\n    toad                 toad\n    toads                toad\n    toadstool            toadstool\n    toast                toast\n    toasted              toast\n    toasting             toast\n    toasts               toast\n    toaze                toaz\n    toby                 tobi\n    tock                 tock\n    tod                  tod\n    today                todai\n    todpole              todpol\n    tods                 tod\n    toe                  toe\n    toes                 toe\n    tofore               tofor\n    toge                 toge\n    toged                toge\n    together             togeth\n    toil                 toil\n    toiled               toil\n    toiling              toil\n    toils                toil\n    token                token\n    tokens               token\n    told                 told\n    toledo               toledo\n    tolerable            toler\n    toll                 toll\n    tolling              toll\n    tom                  tom\n    tomb                 tomb\n    tombe                tomb\n    tombed               tomb\n    tombless             tombless\n    tomboys              tomboi\n    tombs                tomb\n    tomorrow             tomorrow\n    tomyris              tomyri\n    ton                  ton\n    tongs                tong\n    tongu                tongu\n    tongue               tongu\n    tongued              tongu\n    tongueless           tongueless\n    tongues              tongu\n    tonight              tonight\n    too                  too\n    took                 took\n    tool                 tool\n    tools                tool\n    tooth                tooth\n    toothache            toothach\n    toothpick            toothpick\n    toothpicker          toothpick\n    top                  top\n    topas                topa\n    topful               top\n    topgallant           topgal\n    topless              topless\n    topmast              topmast\n    topp                 topp\n    topping              top\n    topple               toppl\n    topples              toppl\n    tops                 top\n    topsail              topsail\n    topsy                topsi\n    torch                torch\n    torchbearer          torchbear\n    torchbearers         torchbear\n    torcher              torcher\n    torches              torch\n    torchlight           torchlight\n    tore                 tore\n    torment              torment\n    tormenta             tormenta\n    tormente             torment\n    tormented            torment\n    tormenting           torment\n    tormentors           tormentor\n    torments             torment\n    torn                 torn\n    torrent              torrent\n    tortive              tortiv\n    tortoise             tortois\n    tortur               tortur\n    torture              tortur\n    tortured             tortur\n    torturer             tortur\n    torturers            tortur\n    tortures             tortur\n    torturest            torturest\n    torturing            tortur\n    toryne               toryn\n    toss                 toss\n    tossed               toss\n    tosseth              tosseth\n    tossing              toss\n    tot                  tot\n    total                total\n    totally              total\n    tott                 tott\n    tottered             totter\n    totters              totter\n    tou                  tou\n    touch                touch\n    touched              touch\n    touches              touch\n    toucheth             toucheth\n    touching             touch\n    touchstone           touchston\n    tough                tough\n    tougher              tougher\n    toughness            tough\n    touraine             tourain\n    tournaments          tournament\n    tours                tour\n    tous                 tou\n    tout                 tout\n    touze                touz\n    tow                  tow\n    toward               toward\n    towardly             towardli\n    towards              toward\n    tower                tower\n    towering             tower\n    towers               tower\n    town                 town\n    towns                town\n    township             township\n    townsman             townsman\n    townsmen             townsmen\n    towton               towton\n    toy                  toi\n    toys                 toi\n    trace                trace\n    traces               trace\n    track                track\n    tract                tract\n    tractable            tractabl\n    trade                trade\n    traded               trade\n    traders              trader\n    trades               trade\n    tradesman            tradesman\n    tradesmen            tradesmen\n    trading              trade\n    tradition            tradit\n    traditional          tradit\n    traduc               traduc\n    traduced             traduc\n    traducement          traduc\n    traffic              traffic\n    traffickers          traffick\n    traffics             traffic\n    tragedian            tragedian\n    tragedians           tragedian\n    tragedies            tragedi\n    tragedy              tragedi\n    tragic               tragic\n    tragical             tragic\n    trail                trail\n    train                train\n    trained              train\n    training             train\n    trains               train\n    trait                trait\n    traitor              traitor\n    traitorly            traitorli\n    traitorous           traitor\n    traitorously         traitor\n    traitors             traitor\n    traitress            traitress\n    traject              traject\n    trammel              trammel\n    trample              trampl\n    trampled             trampl\n    trampling            trampl\n    tranc                tranc\n    trance               tranc\n    tranio               tranio\n    tranquil             tranquil\n    tranquillity         tranquil\n    transcendence        transcend\n    transcends           transcend\n    transferred          transfer\n    transfigur           transfigur\n    transfix             transfix\n    transform            transform\n    transformation       transform\n    transformations      transform\n    transformed          transform\n    transgress           transgress\n    transgresses         transgress\n    transgressing        transgress\n    transgression        transgress\n    translate            translat\n    translated           translat\n    translates           translat\n    translation          translat\n    transmigrates        transmigr\n    transmutation        transmut\n    transparent          transpar\n    transport            transport\n    transportance        transport\n    transported          transport\n    transporting         transport\n    transports           transport\n    transpose            transpos\n    transshape           transshap\n    trap                 trap\n    trapp                trapp\n    trappings            trap\n    traps                trap\n    trash                trash\n    travail              travail\n    travails             travail\n    travel               travel\n    traveler             travel\n    traveling            travel\n    travell              travel\n    travelled            travel\n    traveller            travel\n    travellers           travel\n    travellest           travellest\n    travelling           travel\n    travels              travel\n    travers              traver\n    traverse             travers\n    tray                 trai\n    treacherous          treacher\n    treacherously        treacher\n    treachers            treacher\n    treachery            treacheri\n    tread                tread\n    treading             tread\n    treads               tread\n    treason              treason\n    treasonable          treason\n    treasonous           treason\n    treasons             treason\n    treasure             treasur\n    treasurer            treasur\n    treasures            treasur\n    treasuries           treasuri\n    treasury             treasuri\n    treat                treat\n    treaties             treati\n    treatise             treatis\n    treats               treat\n    treaty               treati\n    treble               trebl\n    trebled              trebl\n    trebles              trebl\n    trebonius            treboniu\n    tree                 tree\n    trees                tree\n    tremble              trembl\n    trembled             trembl\n    trembles             trembl\n    tremblest            tremblest\n    trembling            trembl\n    tremblingly          tremblingli\n    tremor               tremor\n    trempling            trempl\n    trench               trench\n    trenchant            trenchant\n    trenched             trench\n    trencher             trencher\n    trenchering          trencher\n    trencherman          trencherman\n    trenchers            trencher\n    trenches             trench\n    trenching            trench\n    trent                trent\n    tres                 tre\n    trespass             trespass\n    trespasses           trespass\n    tressel              tressel\n    tresses              tress\n    treys                trei\n    trial                trial\n    trials               trial\n    trib                 trib\n    tribe                tribe\n    tribes               tribe\n    tribulation          tribul\n    tribunal             tribun\n    tribune              tribun\n    tribunes             tribun\n    tributaries          tributari\n    tributary            tributari\n    tribute              tribut\n    tributes             tribut\n    trice                trice\n    trick                trick\n    tricking             trick\n    trickling            trickl\n    tricks               trick\n    tricksy              tricksi\n    trident              trident\n    tried                tri\n    trier                trier\n    trifle               trifl\n    trifled              trifl\n    trifler              trifler\n    trifles              trifl\n    trifling             trifl\n    trigon               trigon\n    trill                trill\n    trim                 trim\n    trimly               trimli\n    trimm                trimm\n    trimmed              trim\n    trimming             trim\n    trims                trim\n    trinculo             trinculo\n    trinculos            trinculo\n    trinkets             trinket\n    trip                 trip\n    tripartite           tripartit\n    tripe                tripe\n    triple               tripl\n    triplex              triplex\n    tripoli              tripoli\n    tripolis             tripoli\n    tripp                tripp\n    tripping             trip\n    trippingly           trippingli\n    trips                trip\n    tristful             trist\n    triton               triton\n    triumph              triumph\n    triumphant           triumphant\n    triumphantly         triumphantli\n    triumpher            triumpher\n    triumphers           triumpher\n    triumphing           triumph\n    triumphs             triumph\n    triumvir             triumvir\n    triumvirate          triumvir\n    triumvirs            triumvir\n    triumviry            triumviri\n    trivial              trivial\n    troat                troat\n    trod                 trod\n    trodden              trodden\n    troiant              troiant\n    troien               troien\n    troilus              troilu\n    troiluses            troilus\n    trojan               trojan\n    trojans              trojan\n    troll                troll\n    tromperies           tromperi\n    trompet              trompet\n    troop                troop\n    trooping             troop\n    troops               troop\n    trop                 trop\n    trophies             trophi\n    trophy               trophi\n    tropically           tropic\n    trot                 trot\n    troth                troth\n    trothed              troth\n    troths               troth\n    trots                trot\n    trotting             trot\n    trouble              troubl\n    troubled             troubl\n    troubler             troubler\n    troubles             troubl\n    troublesome          troublesom\n    troublest            troublest\n    troublous            troublou\n    trough               trough\n    trout                trout\n    trouts               trout\n    trovato              trovato\n    trow                 trow\n    trowel               trowel\n    trowest              trowest\n    troy                 troi\n    troyan               troyan\n    troyans              troyan\n    truant               truant\n    truce                truce\n    truckle              truckl\n    trudge               trudg\n    true                 true\n    trueborn             trueborn\n    truepenny            truepenni\n    truer                truer\n    truest               truest\n    truie                truie\n    trull                trull\n    trulls               trull\n    truly                truli\n    trump                trump\n    trumpery             trumperi\n    trumpet              trumpet\n    trumpeter            trumpet\n    trumpeters           trumpet\n    trumpets             trumpet\n    truncheon            truncheon\n    truncheoners         truncheon\n    trundle              trundl\n    trunk                trunk\n    trunks               trunk\n    trust                trust\n    trusted              trust\n    truster              truster\n    trusters             truster\n    trusting             trust\n    trusts               trust\n    trusty               trusti\n    truth                truth\n    truths               truth\n    try                  try\n    ts                   ts\n    tu                   tu\n    tuae                 tuae\n    tub                  tub\n    tubal                tubal\n    tubs                 tub\n    tuck                 tuck\n    tucket               tucket\n    tuesday              tuesdai\n    tuft                 tuft\n    tufts                tuft\n    tug                  tug\n    tugg                 tugg\n    tugging              tug\n    tuition              tuition\n    tullus               tullu\n    tully                tulli\n    tumble               tumbl\n    tumbled              tumbl\n    tumbler              tumbler\n    tumbling             tumbl\n    tumult               tumult\n    tumultuous           tumultu\n    tun                  tun\n    tune                 tune\n    tuneable             tuneabl\n    tuned                tune\n    tuners               tuner\n    tunes                tune\n    tunis                tuni\n    tuns                 tun\n    tupping              tup\n    turban               turban\n    turbans              turban\n    turbulence           turbul\n    turbulent            turbul\n    turd                 turd\n    turf                 turf\n    turfy                turfi\n    turk                 turk\n    turkey               turkei\n    turkeys              turkei\n    turkish              turkish\n    turks                turk\n    turlygod             turlygod\n    turmoil              turmoil\n    turmoiled            turmoil\n    turn                 turn\n    turnbull             turnbul\n    turncoat             turncoat\n    turncoats            turncoat\n    turned               turn\n    turneth              turneth\n    turning              turn\n    turnips              turnip\n    turns                turn\n    turph                turph\n    turpitude            turpitud\n    turquoise            turquois\n    turret               turret\n    turrets              turret\n    turtle               turtl\n    turtles              turtl\n    turvy                turvi\n    tuscan               tuscan\n    tush                 tush\n    tut                  tut\n    tutor                tutor\n    tutored              tutor\n    tutors               tutor\n    tutto                tutto\n    twain                twain\n    twang                twang\n    twangling            twangl\n    twas                 twa\n    tway                 twai\n    tweaks               tweak\n    tween                tween\n    twelfth              twelfth\n    twelve               twelv\n    twelvemonth          twelvemonth\n    twentieth            twentieth\n    twenty               twenti\n    twere                twere\n    twice                twice\n    twig                 twig\n    twiggen              twiggen\n    twigs                twig\n    twilight             twilight\n    twill                twill\n    twilled              twill\n    twin                 twin\n    twine                twine\n    twink                twink\n    twinkle              twinkl\n    twinkled             twinkl\n    twinkling            twinkl\n    twinn                twinn\n    twins                twin\n    twire                twire\n    twist                twist\n    twisted              twist\n    twit                 twit\n    twits                twit\n    twitting             twit\n    twixt                twixt\n    two                  two\n    twofold              twofold\n    twopence             twopenc\n    twopences            twopenc\n    twos                 two\n    twould               twould\n    tyb                  tyb\n    tybalt               tybalt\n    tybalts              tybalt\n    tyburn               tyburn\n    tying                ty\n    tyke                 tyke\n    tymbria              tymbria\n    type                 type\n    types                type\n    typhon               typhon\n    tyrannical           tyrann\n    tyrannically         tyrann\n    tyrannize            tyrann\n    tyrannous            tyrann\n    tyranny              tyranni\n    tyrant               tyrant\n    tyrants              tyrant\n    tyrian               tyrian\n    tyrrel               tyrrel\n    u                    u\n    ubique               ubiqu\n    udders               udder\n    udge                 udg\n    uds                  ud\n    uglier               uglier\n    ugliest              ugliest\n    ugly                 ugli\n    ulcer                ulcer\n    ulcerous             ulcer\n    ulysses              ulyss\n    um                   um\n    umber                umber\n    umbra                umbra\n    umbrage              umbrag\n    umfrevile            umfrevil\n    umpire               umpir\n    umpires              umpir\n    un                   un\n    unable               unabl\n    unaccommodated       unaccommod\n    unaccompanied        unaccompani\n    unaccustom           unaccustom\n    unaching             unach\n    unacquainted         unacquaint\n    unactive             unact\n    unadvis              unadvi\n    unadvised            unadvis\n    unadvisedly          unadvisedli\n    unagreeable          unagre\n    unanel               unanel\n    unanswer             unansw\n    unappeas             unappea\n    unapproved           unapprov\n    unapt                unapt\n    unaptness            unapt\n    unarm                unarm\n    unarmed              unarm\n    unarms               unarm\n    unassail             unassail\n    unassailable         unassail\n    unattainted          unattaint\n    unattempted          unattempt\n    unattended           unattend\n    unauspicious         unauspici\n    unauthorized         unauthor\n    unavoided            unavoid\n    unawares             unawar\n    unback               unback\n    unbak                unbak\n    unbanded             unband\n    unbar                unbar\n    unbarb               unbarb\n    unbashful            unbash\n    unbated              unbat\n    unbatter             unbatt\n    unbecoming           unbecom\n    unbefitting          unbefit\n    unbegot              unbegot\n    unbegotten           unbegotten\n    unbelieved           unbeliev\n    unbend               unbend\n    unbent               unbent\n    unbewail             unbewail\n    unbid                unbid\n    unbidden             unbidden\n    unbind               unbind\n    unbinds              unbind\n    unbitted             unbit\n    unbless              unbless\n    unblest              unblest\n    unbloodied           unbloodi\n    unblown              unblown\n    unbodied             unbodi\n    unbolt               unbolt\n    unbolted             unbolt\n    unbonneted           unbonnet\n    unbookish            unbookish\n    unborn               unborn\n    unbosom              unbosom\n    unbound              unbound\n    unbounded            unbound\n    unbow                unbow\n    unbowed              unbow\n    unbrac               unbrac\n    unbraced             unbrac\n    unbraided            unbraid\n    unbreathed           unbreath\n    unbred               unbr\n    unbreech             unbreech\n    unbridled            unbridl\n    unbroke              unbrok\n    unbruis              unbrui\n    unbruised            unbruis\n    unbuckle             unbuckl\n    unbuckles            unbuckl\n    unbuckling           unbuckl\n    unbuild              unbuild\n    unburden             unburden\n    unburdens            unburden\n    unburied             unburi\n    unburnt              unburnt\n    unburthen            unburthen\n    unbutton             unbutton\n    unbuttoning          unbutton\n    uncapable            uncap\n    uncape               uncap\n    uncase               uncas\n    uncasing             uncas\n    uncaught             uncaught\n    uncertain            uncertain\n    uncertainty          uncertainti\n    unchain              unchain\n    unchanging           unchang\n    uncharge             uncharg\n    uncharged            uncharg\n    uncharitably         uncharit\n    unchary              unchari\n    unchaste             unchast\n    uncheck              uncheck\n    unchilded            unchild\n    uncivil              uncivil\n    unclaim              unclaim\n    unclasp              unclasp\n    uncle                uncl\n    unclean              unclean\n    uncleanliness        uncleanli\n    uncleanly            uncleanli\n    uncleanness          unclean\n    uncles               uncl\n    unclew               unclew\n    unclog               unclog\n    uncoined             uncoin\n    uncolted             uncolt\n    uncomeliness         uncomeli\n    uncomfortable        uncomfort\n    uncompassionate      uncompassion\n    uncomprehensive      uncomprehens\n    unconfinable         unconfin\n    unconfirm            unconfirm\n    unconfirmed          unconfirm\n    unconquer            unconqu\n    unconquered          unconqu\n    unconsidered         unconsid\n    unconstant           unconst\n    unconstrain          unconstrain\n    unconstrained        unconstrain\n    uncontemn            uncontemn\n    uncontroll           uncontrol\n    uncorrected          uncorrect\n    uncounted            uncount\n    uncouple             uncoupl\n    uncourteous          uncourt\n    uncouth              uncouth\n    uncover              uncov\n    uncovered            uncov\n    uncropped            uncrop\n    uncross              uncross\n    uncrown              uncrown\n    unction              unction\n    unctuous             unctuou\n    uncuckolded          uncuckold\n    uncurable            uncur\n    uncurbable           uncurb\n    uncurbed             uncurb\n    uncurls              uncurl\n    uncurrent            uncurr\n    uncurse              uncurs\n    undaunted            undaunt\n    undeaf               undeaf\n    undeck               undeck\n    undeeded             undeed\n    under                under\n    underbearing         underbear\n    underborne           underborn\n    undercrest           undercrest\n    underfoot            underfoot\n    undergo              undergo\n    undergoes            undergo\n    undergoing           undergo\n    undergone            undergon\n    underground          underground\n    underhand            underhand\n    underlings           underl\n    undermine            undermin\n    underminers          undermin\n    underneath           underneath\n    underprizing         underpr\n    underprop            underprop\n    understand           understand\n    understandeth        understandeth\n    understanding        understand\n    understandings       understand\n    understands          understand\n    understood           understood\n    underta              underta\n    undertake            undertak\n    undertakeing         undertak\n    undertaker           undertak\n    undertakes           undertak\n    undertaking          undertak\n    undertakings         undertak\n    undertook            undertook\n    undervalu            undervalu\n    undervalued          undervalu\n    underwent            underw\n    underwrit            underwrit\n    underwrite           underwrit\n    undescried           undescri\n    undeserved           undeserv\n    undeserver           undeserv\n    undeservers          undeserv\n    undeserving          undeserv\n    undetermin           undetermin\n    undid                undid\n    undinted             undint\n    undiscernible        undiscern\n    undiscover           undiscov\n    undishonoured        undishonour\n    undispos             undispo\n    undistinguishable    undistinguish\n    undistinguished      undistinguish\n    undividable          undivid\n    undivided            undivid\n    undivulged           undivulg\n    undo                 undo\n    undoes               undo\n    undoing              undo\n    undone               undon\n    undoubted            undoubt\n    undoubtedly          undoubtedli\n    undream              undream\n    undress              undress\n    undressed            undress\n    undrown              undrown\n    unduteous            undut\n    undutiful            unduti\n    une                  un\n    uneared              unear\n    unearned             unearn\n    unearthly            unearthli\n    uneasines            uneasin\n    uneasy               uneasi\n    uneath               uneath\n    uneducated           uneduc\n    uneffectual          uneffectu\n    unelected            unelect\n    unequal              unequ\n    uneven               uneven\n    unexamin             unexamin\n    unexecuted           unexecut\n    unexpected           unexpect\n    unexperienc          unexperienc\n    unexperient          unexperi\n    unexpressive         unexpress\n    unfair               unfair\n    unfaithful           unfaith\n    unfallible           unfal\n    unfam                unfam\n    unfashionable        unfashion\n    unfasten             unfasten\n    unfather             unfath\n    unfathered           unfath\n    unfed                unf\n    unfeed               unfe\n    unfeeling            unfeel\n    unfeigned            unfeign\n    unfeignedly          unfeignedli\n    unfellowed           unfellow\n    unfelt               unfelt\n    unfenced             unfenc\n    unfilial             unfili\n    unfill               unfil\n    unfinish             unfinish\n    unfirm               unfirm\n    unfit                unfit\n    unfitness            unfit\n    unfix                unfix\n    unfledg              unfledg\n    unfold               unfold\n    unfolded             unfold\n    unfoldeth            unfoldeth\n    unfolding            unfold\n    unfolds              unfold\n    unfool               unfool\n    unforc               unforc\n    unforced             unforc\n    unforfeited          unforfeit\n    unfortified          unfortifi\n    unfortunate          unfortun\n    unfought             unfought\n    unfrequented         unfrequ\n    unfriended           unfriend\n    unfurnish            unfurnish\n    ungain               ungain\n    ungalled             ungal\n    ungart               ungart\n    ungarter             ungart\n    ungenitur            ungenitur\n    ungentle             ungentl\n    ungentleness         ungentl\n    ungently             ungent\n    ungird               ungird\n    ungodly              ungodli\n    ungor                ungor\n    ungot                ungot\n    ungotten             ungotten\n    ungovern             ungovern\n    ungracious           ungraci\n    ungrateful           ungrat\n    ungravely            ungrav\n    ungrown              ungrown\n    unguarded            unguard\n    unguem               unguem\n    unguided             unguid\n    unhack               unhack\n    unhair               unhair\n    unhallow             unhallow\n    unhallowed           unhallow\n    unhand               unhand\n    unhandled            unhandl\n    unhandsome           unhandsom\n    unhang               unhang\n    unhappied            unhappi\n    unhappily            unhappili\n    unhappiness          unhappi\n    unhappy              unhappi\n    unhardened           unharden\n    unharm               unharm\n    unhatch              unhatch\n    unheard              unheard\n    unhearts             unheart\n    unheedful            unheed\n    unheedfully          unheedfulli\n    unheedy              unheedi\n    unhelpful            unhelp\n    unhidden             unhidden\n    unholy               unholi\n    unhop                unhop\n    unhopefullest        unhopefullest\n    unhorse              unhors\n    unhospitable         unhospit\n    unhous               unhou\n    unhoused             unhous\n    unhurtful            unhurt\n    unicorn              unicorn\n    unicorns             unicorn\n    unimproved           unimprov\n    uninhabitable        uninhabit\n    uninhabited          uninhabit\n    unintelligent        unintellig\n    union                union\n    unions               union\n    unite                unit\n    united               unit\n    unity                uniti\n    universal            univers\n    universe             univers\n    universities         univers\n    university           univers\n    unjointed            unjoint\n    unjust               unjust\n    unjustice            unjustic\n    unjustly             unjustli\n    unkennel             unkennel\n    unkept               unkept\n    unkind               unkind\n    unkindest            unkindest\n    unkindly             unkindli\n    unkindness           unkind\n    unking               unk\n    unkinglike           unkinglik\n    unkiss               unkiss\n    unknit               unknit\n    unknowing            unknow\n    unknown              unknown\n    unlace               unlac\n    unlaid               unlaid\n    unlawful             unlaw\n    unlawfully           unlawfulli\n    unlearn              unlearn\n    unlearned            unlearn\n    unless               unless\n    unlesson             unlesson\n    unletter             unlett\n    unlettered           unlett\n    unlick               unlick\n    unlike               unlik\n    unlikely             unlik\n    unlimited            unlimit\n    unlineal             unlin\n    unlink               unlink\n    unload               unload\n    unloaded             unload\n    unloading            unload\n    unloads              unload\n    unlock               unlock\n    unlocks              unlock\n    unlook               unlook\n    unlooked             unlook\n    unloos               unloo\n    unloose              unloos\n    unlov                unlov\n    unloving             unlov\n    unluckily            unluckili\n    unlucky              unlucki\n    unmade               unmad\n    unmake               unmak\n    unmanly              unmanli\n    unmann               unmann\n    unmanner             unmann\n    unmannerd            unmannerd\n    unmannerly           unmannerli\n    unmarried            unmarri\n    unmask               unmask\n    unmasked             unmask\n    unmasking            unmask\n    unmasks              unmask\n    unmast               unmast\n    unmatch              unmatch\n    unmatchable          unmatch\n    unmatched            unmatch\n    unmeasurable         unmeasur\n    unmeet               unmeet\n    unmellowed           unmellow\n    unmerciful           unmerci\n    unmeritable          unmerit\n    unmeriting           unmerit\n    unminded             unmind\n    unmindfull           unmindful\n    unmingled            unmingl\n    unmitigable          unmitig\n    unmitigated          unmitig\n    unmix                unmix\n    unmoan               unmoan\n    unmov                unmov\n    unmoved              unmov\n    unmoving             unmov\n    unmuffles            unmuffl\n    unmuffling           unmuffl\n    unmusical            unmus\n    unmuzzle             unmuzzl\n    unmuzzled            unmuzzl\n    unnatural            unnatur\n    unnaturally          unnatur\n    unnaturalness        unnatur\n    unnecessarily        unnecessarili\n    unnecessary          unnecessari\n    unneighbourly        unneighbourli\n    unnerved             unnerv\n    unnoble              unnobl\n    unnoted              unnot\n    unnumb               unnumb\n    unnumber             unnumb\n    unowed               unow\n    unpack               unpack\n    unpaid               unpaid\n    unparagon            unparagon\n    unparallel           unparallel\n    unpartial            unparti\n    unpath               unpath\n    unpaved              unpav\n    unpay                unpai\n    unpeaceable          unpeac\n    unpeg                unpeg\n    unpeople             unpeopl\n    unpeopled            unpeopl\n    unperfect            unperfect\n    unperfectness        unperfect\n    unpick               unpick\n    unpin                unpin\n    unpink               unpink\n    unpitied             unpiti\n    unpitifully          unpitifulli\n    unplagu              unplagu\n    unplausive           unplaus\n    unpleas              unplea\n    unpleasant           unpleas\n    unpleasing           unpleas\n    unpolicied           unpolici\n    unpolish             unpolish\n    unpolished           unpolish\n    unpolluted           unpollut\n    unpossess            unpossess\n    unpossessing         unpossess\n    unpossible           unposs\n    unpractis            unpracti\n    unpregnant           unpregn\n    unpremeditated       unpremedit\n    unprepar             unprepar\n    unprepared           unprepar\n    unpress              unpress\n    unprevailing         unprevail\n    unprevented          unprev\n    unpriz               unpriz\n    unprizable           unpriz\n    unprofitable         unprofit\n    unprofited           unprofit\n    unproper             unprop\n    unproperly           unproperli\n    unproportion         unproport\n    unprovide            unprovid\n    unprovided           unprovid\n    unprovident          unprovid\n    unprovokes           unprovok\n    unprun               unprun\n    unpruned             unprun\n    unpublish            unpublish\n    unpurged             unpurg\n    unpurpos             unpurpo\n    unqualitied          unqual\n    unqueen              unqueen\n    unquestion           unquest\n    unquestionable       unquestion\n    unquiet              unquiet\n    unquietly            unquietli\n    unquietness          unquiet\n    unraised             unrais\n    unrak                unrak\n    unread               unread\n    unready              unreadi\n    unreal               unreal\n    unreasonable         unreason\n    unreasonably         unreason\n    unreclaimed          unreclaim\n    unreconciled         unreconcil\n    unreconciliable      unreconcili\n    unrecounted          unrecount\n    unrecuring           unrecur\n    unregarded           unregard\n    unregist             unregist\n    unrelenting          unrel\n    unremovable          unremov\n    unremovably          unremov\n    unreprievable        unrepriev\n    unresolv             unresolv\n    unrespected          unrespect\n    unrespective         unrespect\n    unrest               unrest\n    unrestor             unrestor\n    unrestrained         unrestrain\n    unreveng             unreveng\n    unreverend           unreverend\n    unreverent           unrever\n    unrevers             unrev\n    unrewarded           unreward\n    unrighteous          unright\n    unrightful           unright\n    unripe               unrip\n    unripp               unripp\n    unrivall             unrival\n    unroll               unrol\n    unroof               unroof\n    unroosted            unroost\n    unroot               unroot\n    unrough              unrough\n    unruly               unruli\n    unsafe               unsaf\n    unsaluted            unsalut\n    unsanctified         unsanctifi\n    unsatisfied          unsatisfi\n    unsavoury            unsavouri\n    unsay                unsai\n    unscalable           unscal\n    unscann              unscann\n    unscarr              unscarr\n    unschool             unschool\n    unscorch             unscorch\n    unscour              unscour\n    unscratch            unscratch\n    unseal               unseal\n    unseam               unseam\n    unsearch             unsearch\n    unseason             unseason\n    unseasonable         unseason\n    unseasonably         unseason\n    unseasoned           unseason\n    unseconded           unsecond\n    unsecret             unsecret\n    unseduc              unseduc\n    unseeing             unse\n    unseeming            unseem\n    unseemly             unseemli\n    unseen               unseen\n    unseminar            unseminar\n    unseparable          unsepar\n    unserviceable        unservic\n    unset                unset\n    unsettle             unsettl\n    unsettled            unsettl\n    unsever              unsev\n    unsex                unsex\n    unshak               unshak\n    unshaked             unshak\n    unshaken             unshaken\n    unshaped             unshap\n    unshapes             unshap\n    unsheath             unsheath\n    unsheathe            unsheath\n    unshorn              unshorn\n    unshout              unshout\n    unshown              unshown\n    unshrinking          unshrink\n    unshrubb             unshrubb\n    unshunn              unshunn\n    unshunnable          unshunn\n    unsifted             unsift\n    unsightly            unsightli\n    unsinew              unsinew\n    unsisting            unsist\n    unskilful            unskil\n    unskilfully          unskilfulli\n    unskillful           unskil\n    unslipping           unslip\n    unsmirched           unsmirch\n    unsoil               unsoil\n    unsolicited          unsolicit\n    unsorted             unsort\n    unsought             unsought\n    unsound              unsound\n    unsounded            unsound\n    unspeak              unspeak\n    unspeakable          unspeak\n    unspeaking           unspeak\n    unsphere             unspher\n    unspoke              unspok\n    unspoken             unspoken\n    unspotted            unspot\n    unsquar              unsquar\n    unstable             unstabl\n    unstaid              unstaid\n    unstain              unstain\n    unstained            unstain\n    unstanched           unstanch\n    unstate              unstat\n    unsteadfast          unsteadfast\n    unstooping           unstoop\n    unstringed           unstring\n    unstuff              unstuff\n    unsubstantial        unsubstanti\n    unsuitable           unsuit\n    unsuiting            unsuit\n    unsullied            unsulli\n    unsunn               unsunn\n    unsur                unsur\n    unsure               unsur\n    unsuspected          unsuspect\n    unsway               unswai\n    unswayable           unsway\n    unswayed             unswai\n    unswear              unswear\n    unswept              unswept\n    unsworn              unsworn\n    untainted            untaint\n    untalk               untalk\n    untangle             untangl\n    untangled            untangl\n    untasted             untast\n    untaught             untaught\n    untempering          untemp\n    untender             untend\n    untent               untent\n    untented             untent\n    unthankful           unthank\n    unthankfulness       unthank\n    unthink              unthink\n    unthought            unthought\n    unthread             unthread\n    unthrift             unthrift\n    unthrifts            unthrift\n    unthrifty            unthrifti\n    untie                unti\n    untied               unti\n    until                until\n    untimber             untimb\n    untimely             untim\n    untir                untir\n    untirable            untir\n    untired              untir\n    untitled             untitl\n    unto                 unto\n    untold               untold\n    untouch              untouch\n    untoward             untoward\n    untowardly           untowardli\n    untraded             untrad\n    untrain              untrain\n    untrained            untrain\n    untread              untread\n    untreasur            untreasur\n    untried              untri\n    untrimmed            untrim\n    untrod               untrod\n    untrodden            untrodden\n    untroubled           untroubl\n    untrue               untru\n    untrussing           untruss\n    untruth              untruth\n    untruths             untruth\n    untucked             untuck\n    untun                untun\n    untune               untun\n    untuneable           untun\n    untutor              untutor\n    untutored            untutor\n    untwine              untwin\n    unurg                unurg\n    unus                 unu\n    unused               unus\n    unusual              unusu\n    unvalued             unvalu\n    unvanquish           unvanquish\n    unvarnish            unvarnish\n    unveil               unveil\n    unveiling            unveil\n    unvenerable          unvener\n    unvex                unvex\n    unviolated           unviol\n    unvirtuous           unvirtu\n    unvisited            unvisit\n    unvulnerable         unvulner\n    unwares              unwar\n    unwarily             unwarili\n    unwash               unwash\n    unwatch              unwatch\n    unwearied            unweari\n    unwed                unw\n    unwedgeable          unwedg\n    unweeded             unweed\n    unweighed            unweigh\n    unweighing           unweigh\n    unwelcome            unwelcom\n    unwept               unwept\n    unwhipp              unwhipp\n    unwholesome          unwholesom\n    unwieldy             unwieldi\n    unwilling            unwil\n    unwillingly          unwillingli\n    unwillingness        unwilling\n    unwind               unwind\n    unwiped              unwip\n    unwise               unwis\n    unwisely             unwis\n    unwish               unwish\n    unwished             unwish\n    unwitted             unwit\n    unwittingly          unwittingli\n    unwonted             unwont\n    unwooed              unwoo\n    unworthier           unworthi\n    unworthiest          unworthiest\n    unworthily           unworthili\n    unworthiness         unworthi\n    unworthy             unworthi\n    unwrung              unwrung\n    unyok                unyok\n    unyoke               unyok\n    up                   up\n    upbraid              upbraid\n    upbraided            upbraid\n    upbraidings          upbraid\n    upbraids             upbraid\n    uphoarded            uphoard\n    uphold               uphold\n    upholdeth            upholdeth\n    upholding            uphold\n    upholds              uphold\n    uplift               uplift\n    uplifted             uplift\n    upmost               upmost\n    upon                 upon\n    upper                upper\n    uprear               uprear\n    upreared             uprear\n    upright              upright\n    uprighteously        upright\n    uprightness          upright\n    uprise               upris\n    uprising             upris\n    uproar               uproar\n    uproars              uproar\n    uprous               uprou\n    upshoot              upshoot\n    upshot               upshot\n    upside               upsid\n    upspring             upspr\n    upstairs             upstair\n    upstart              upstart\n    upturned             upturn\n    upward               upward\n    upwards              upward\n    urchin               urchin\n    urchinfield          urchinfield\n    urchins              urchin\n    urg                  urg\n    urge                 urg\n    urged                urg\n    urgent               urgent\n    urges                urg\n    urgest               urgest\n    urging               urg\n    urinal               urin\n    urinals              urin\n    urine                urin\n    urn                  urn\n    urns                 urn\n    urs                  ur\n    ursa                 ursa\n    ursley               urslei\n    ursula               ursula\n    urswick              urswick\n    us                   us\n    usage                usag\n    usance               usanc\n    usances              usanc\n    use                  us\n    used                 us\n    useful               us\n    useless              useless\n    user                 user\n    uses                 us\n    usest                usest\n    useth                useth\n    usher                usher\n    ushered              usher\n    ushering             usher\n    ushers               usher\n    using                us\n    usual                usual\n    usually              usual\n    usurer               usur\n    usurers              usur\n    usuries              usuri\n    usuring              usur\n    usurp                usurp\n    usurpation           usurp\n    usurped              usurp\n    usurper              usurp\n    usurpers             usurp\n    usurping             usurp\n    usurpingly           usurpingli\n    usurps               usurp\n    usury                usuri\n    ut                   ut\n    utensil              utensil\n    utensils             utensil\n    utility              util\n    utmost               utmost\n    utt                  utt\n    utter                utter\n    utterance            utter\n    uttered              utter\n    uttereth             uttereth\n    uttering             utter\n    utterly              utterli\n    uttermost            uttermost\n    utters               utter\n    uy                   uy\n    v                    v\n    va                   va\n    vacancy              vacanc\n    vacant               vacant\n    vacation             vacat\n    vade                 vade\n    vagabond             vagabond\n    vagabonds            vagabond\n    vagram               vagram\n    vagrom               vagrom\n    vail                 vail\n    vailed               vail\n    vailing              vail\n    vaillant             vaillant\n    vain                 vain\n    vainer               vainer\n    vainglory            vainglori\n    vainly               vainli\n    vainness             vain\n    vais                 vai\n    valanc               valanc\n    valance              valanc\n    vale                 vale\n    valence              valenc\n    valentine            valentin\n    valentinus           valentinu\n    valentio             valentio\n    valeria              valeria\n    valerius             valeriu\n    vales                vale\n    valiant              valiant\n    valiantly            valiantli\n    valiantness          valiant\n    validity             valid\n    vallant              vallant\n    valley               vallei\n    valleys              vallei\n    vally                valli\n    valor                valor\n    valorous             valor\n    valorously           valor\n    valour               valour\n    valu                 valu\n    valuation            valuat\n    value                valu\n    valued               valu\n    valueless            valueless\n    values               valu\n    valuing              valu\n    vane                 vane\n    vanish               vanish\n    vanished             vanish\n    vanishes             vanish\n    vanishest            vanishest\n    vanishing            vanish\n    vanities             vaniti\n    vanity               vaniti\n    vanquish             vanquish\n    vanquished           vanquish\n    vanquisher           vanquish\n    vanquishest          vanquishest\n    vanquisheth          vanquisheth\n    vant                 vant\n    vantage              vantag\n    vantages             vantag\n    vantbrace            vantbrac\n    vapians              vapian\n    vapor                vapor\n    vaporous             vapor\n    vapour               vapour\n    vapours              vapour\n    vara                 vara\n    variable             variabl\n    variance             varianc\n    variation            variat\n    variations           variat\n    varied               vari\n    variest              variest\n    variety              varieti\n    varld                varld\n    varlet               varlet\n    varletry             varletri\n    varlets              varlet\n    varletto             varletto\n    varnish              varnish\n    varrius              varriu\n    varro                varro\n    vary                 vari\n    varying              vari\n    vassal               vassal\n    vassalage            vassalag\n    vassals              vassal\n    vast                 vast\n    vastidity            vastid\n    vasty                vasti\n    vat                  vat\n    vater                vater\n    vaudemont            vaudemont\n    vaughan              vaughan\n    vault                vault\n    vaultages            vaultag\n    vaulted              vault\n    vaulting             vault\n    vaults               vault\n    vaulty               vaulti\n    vaumond              vaumond\n    vaunt                vaunt\n    vaunted              vaunt\n    vaunter              vaunter\n    vaunting             vaunt\n    vauntingly           vauntingli\n    vaunts               vaunt\n    vauvado              vauvado\n    vaux                 vaux\n    vaward               vaward\n    ve                   ve\n    veal                 veal\n    vede                 vede\n    vehemence            vehem\n    vehemency            vehem\n    vehement             vehement\n    vehor                vehor\n    veil                 veil\n    veiled               veil\n    veiling              veil\n    vein                 vein\n    veins                vein\n    vell                 vell\n    velure               velur\n    velutus              velutu\n    velvet               velvet\n    vendible             vendibl\n    venerable            vener\n    venereal             vener\n    venetia              venetia\n    venetian             venetian\n    venetians            venetian\n    veneys               venei\n    venge                veng\n    vengeance            vengeanc\n    vengeances           vengeanc\n    vengeful             veng\n    veni                 veni\n    venial               venial\n    venice               venic\n    venison              venison\n    venit                venit\n    venom                venom\n    venomous             venom\n    venomously           venom\n    vent                 vent\n    ventages             ventag\n    vented               vent\n    ventidius            ventidiu\n    ventricle            ventricl\n    vents                vent\n    ventur               ventur\n    venture              ventur\n    ventured             ventur\n    ventures             ventur\n    venturing            ventur\n    venturous            ventur\n    venue                venu\n    venus                venu\n    venuto               venuto\n    ver                  ver\n    verb                 verb\n    verba                verba\n    verbal               verbal\n    verbatim             verbatim\n    verbosity            verbos\n    verdict              verdict\n    verdun               verdun\n    verdure              verdur\n    vere                 vere\n    verefore             verefor\n    verg                 verg\n    verge                verg\n    vergers              verger\n    verges               verg\n    verier               verier\n    veriest              veriest\n    verified             verifi\n    verify               verifi\n    verily               verili\n    veritable            verit\n    verite               verit\n    verities             veriti\n    verity               veriti\n    vermilion            vermilion\n    vermin               vermin\n    vernon               vernon\n    verona               verona\n    veronesa             veronesa\n    versal               versal\n    verse                vers\n    verses               vers\n    versing              vers\n    vert                 vert\n    very                 veri\n    vesper               vesper\n    vessel               vessel\n    vessels              vessel\n    vestal               vestal\n    vestments            vestment\n    vesture              vestur\n    vetch                vetch\n    vetches              vetch\n    veux                 veux\n    vex                  vex\n    vexation             vexat\n    vexations            vexat\n    vexed                vex\n    vexes                vex\n    vexest               vexest\n    vexeth               vexeth\n    vexing               vex\n    vi                   vi\n    via                  via\n    vial                 vial\n    vials                vial\n    viand                viand\n    viands               viand\n    vic                  vic\n    vicar                vicar\n    vice                 vice\n    vicegerent           viceger\n    vicentio             vicentio\n    viceroy              viceroi\n    viceroys             viceroi\n    vices                vice\n    vici                 vici\n    vicious              viciou\n    viciousness          vicious\n    vict                 vict\n    victims              victim\n    victor               victor\n    victoress            victoress\n    victories            victori\n    victorious           victori\n    victors              victor\n    victory              victori\n    victual              victual\n    victuall             victual\n    victuals             victual\n    videlicet            videlicet\n    video                video\n    vides                vide\n    videsne              videsn\n    vidi                 vidi\n    vie                  vie\n    vied                 vi\n    vienna               vienna\n    view                 view\n    viewest              viewest\n    vieweth              vieweth\n    viewing              view\n    viewless             viewless\n    views                view\n    vigil                vigil\n    vigilance            vigil\n    vigilant             vigil\n    vigitant             vigit\n    vigour               vigour\n    vii                  vii\n    viii                 viii\n    vile                 vile\n    vilely               vile\n    vileness             vile\n    viler                viler\n    vilest               vilest\n    vill                 vill\n    village              villag\n    villager             villag\n    villagery            villageri\n    villages             villag\n    villain              villain\n    villainies           villaini\n    villainous           villain\n    villainously         villain\n    villains             villain\n    villainy             villaini\n    villanies            villani\n    villanous            villan\n    villany              villani\n    villiago             villiago\n    villian              villian\n    villianda            villianda\n    villians             villian\n    vinaigre             vinaigr\n    vincentio            vincentio\n    vincere              vincer\n    vindicative          vindic\n    vine                 vine\n    vinegar              vinegar\n    vines                vine\n    vineyard             vineyard\n    vineyards            vineyard\n    vint                 vint\n    vintner              vintner\n    viol                 viol\n    viola                viola\n    violate              violat\n    violated             violat\n    violates             violat\n    violation            violat\n    violator             violat\n    violence             violenc\n    violent              violent\n    violenta             violenta\n    violenteth           violenteth\n    violently            violent\n    violet               violet\n    violets              violet\n    viper                viper\n    viperous             viper\n    vipers               viper\n    vir                  vir\n    virgilia             virgilia\n    virgin               virgin\n    virginal             virgin\n    virginalling         virginal\n    virginity            virgin\n    virginius            virginiu\n    virgins              virgin\n    virgo                virgo\n    virtue               virtu\n    virtues              virtu\n    virtuous             virtuou\n    virtuously           virtuous\n    visag                visag\n    visage               visag\n    visages              visag\n    visard               visard\n    viscount             viscount\n    visible              visibl\n    visibly              visibl\n    vision               vision\n    visions              vision\n    visit                visit\n    visitation           visit\n    visitations          visit\n    visited              visit\n    visiting             visit\n    visitings            visit\n    visitor              visitor\n    visitors             visitor\n    visits               visit\n    visor                visor\n    vita                 vita\n    vitae                vita\n    vital                vital\n    vitement             vitement\n    vitruvio             vitruvio\n    vitx                 vitx\n    viva                 viva\n    vivant               vivant\n    vive                 vive\n    vixen                vixen\n    viz                  viz\n    vizaments            vizament\n    vizard               vizard\n    vizarded             vizard\n    vizards              vizard\n    vizor                vizor\n    vlouting             vlout\n    vocation             vocat\n    vocativo             vocativo\n    vocatur              vocatur\n    voce                 voce\n    voic                 voic\n    voice                voic\n    voices               voic\n    void                 void\n    voided               void\n    voiding              void\n    voke                 voke\n    volable              volabl\n    volant               volant\n    volivorco            volivorco\n    volley               vollei\n    volquessen           volquessen\n    volsce               volsc\n    volsces              volsc\n    volscian             volscian\n    volscians            volscian\n    volt                 volt\n    voltemand            voltemand\n    volubility           volubl\n    voluble              volubl\n    volume               volum\n    volumes              volum\n    volumnia             volumnia\n    volumnius            volumniu\n    voluntaries          voluntari\n    voluntary            voluntari\n    voluptuously         voluptu\n    voluptuousness       voluptu\n    vomissement          vomiss\n    vomit                vomit\n    vomits               vomit\n    vor                  vor\n    vore                 vore\n    vortnight            vortnight\n    vot                  vot\n    votaries             votari\n    votarist             votarist\n    votarists            votarist\n    votary               votari\n    votre                votr\n    vouch                vouch\n    voucher              voucher\n    vouchers             voucher\n    vouches              vouch\n    vouching             vouch\n    vouchsaf             vouchsaf\n    vouchsafe            vouchsaf\n    vouchsafed           vouchsaf\n    vouchsafes           vouchsaf\n    vouchsafing          vouchsaf\n    voudrais             voudrai\n    vour                 vour\n    vous                 vou\n    voutsafe             voutsaf\n    vow                  vow\n    vowed                vow\n    vowel                vowel\n    vowels               vowel\n    vowing               vow\n    vows                 vow\n    vox                  vox\n    voyage               voyag\n    voyages              voyag\n    vraiment             vraiment\n    vulcan               vulcan\n    vulgar               vulgar\n    vulgarly             vulgarli\n    vulgars              vulgar\n    vulgo                vulgo\n    vulnerable           vulner\n    vulture              vultur\n    vultures             vultur\n    vurther              vurther\n    w                    w\n    wad                  wad\n    waddled              waddl\n    wade                 wade\n    waded                wade\n    wafer                wafer\n    waft                 waft\n    waftage              waftag\n    wafting              waft\n    wafts                waft\n    wag                  wag\n    wage                 wage\n    wager                wager\n    wagers               wager\n    wages                wage\n    wagging              wag\n    waggish              waggish\n    waggling             waggl\n    waggon               waggon\n    waggoner             waggon\n    wagon                wagon\n    wagoner              wagon\n    wags                 wag\n    wagtail              wagtail\n    wail                 wail\n    wailful              wail\n    wailing              wail\n    wails                wail\n    wain                 wain\n    wainropes            wainrop\n    wainscot             wainscot\n    waist                waist\n    wait                 wait\n    waited               wait\n    waiter               waiter\n    waiteth              waiteth\n    waiting              wait\n    waits                wait\n    wak                  wak\n    wake                 wake\n    waked                wake\n    wakefield            wakefield\n    waken                waken\n    wakened              waken\n    wakes                wake\n    wakest               wakest\n    waking               wake\n    wales                wale\n    walk                 walk\n    walked               walk\n    walking              walk\n    walks                walk\n    wall                 wall\n    walled               wall\n    wallet               wallet\n    wallets              wallet\n    wallon               wallon\n    walloon              walloon\n    wallow               wallow\n    walls                wall\n    walnut               walnut\n    walter               walter\n    wan                  wan\n    wand                 wand\n    wander               wander\n    wanderer             wander\n    wanderers            wander\n    wandering            wander\n    wanders              wander\n    wands                wand\n    wane                 wane\n    waned                wane\n    wanes                wane\n    waning               wane\n    wann                 wann\n    want                 want\n    wanted               want\n    wanteth              wanteth\n    wanting              want\n    wanton               wanton\n    wantonly             wantonli\n    wantonness           wanton\n    wantons              wanton\n    wants                want\n    wappen               wappen\n    war                  war\n    warble               warbl\n    warbling             warbl\n    ward                 ward\n    warded               ward\n    warden               warden\n    warder               warder\n    warders              warder\n    wardrobe             wardrob\n    wardrop              wardrop\n    wards                ward\n    ware                 ware\n    wares                ware\n    warily               warili\n    warkworth            warkworth\n    warlike              warlik\n    warm                 warm\n    warmed               warm\n    warmer               warmer\n    warming              warm\n    warms                warm\n    warmth               warmth\n    warn                 warn\n    warned               warn\n    warning              warn\n    warnings             warn\n    warns                warn\n    warp                 warp\n    warped               warp\n    warr                 warr\n    warrant              warrant\n    warranted            warrant\n    warranteth           warranteth\n    warrantise           warrantis\n    warrantize           warrant\n    warrants             warrant\n    warranty             warranti\n    warren               warren\n    warrener             warren\n    warring              war\n    warrior              warrior\n    warriors             warrior\n    wars                 war\n    wart                 wart\n    warwick              warwick\n    warwickshire         warwickshir\n    wary                 wari\n    was                  wa\n    wash                 wash\n    washed               wash\n    washer               washer\n    washes               wash\n    washford             washford\n    washing              wash\n    wasp                 wasp\n    waspish              waspish\n    wasps                wasp\n    wassail              wassail\n    wassails             wassail\n    wast                 wast\n    waste                wast\n    wasted               wast\n    wasteful             wast\n    wasters              waster\n    wastes               wast\n    wasting              wast\n    wat                  wat\n    watch                watch\n    watched              watch\n    watchers             watcher\n    watches              watch\n    watchful             watch\n    watching             watch\n    watchings            watch\n    watchman             watchman\n    watchmen             watchmen\n    watchword            watchword\n    water                water\n    waterdrops           waterdrop\n    watered              water\n    waterfly             waterfli\n    waterford            waterford\n    watering             water\n    waterish             waterish\n    waterpots            waterpot\n    waterrugs            waterrug\n    waters               water\n    waterton             waterton\n    watery               wateri\n    wav                  wav\n    wave                 wave\n    waved                wave\n    waver                waver\n    waverer              waver\n    wavering             waver\n    waves                wave\n    waving               wave\n    waw                  waw\n    wawl                 wawl\n    wax                  wax\n    waxed                wax\n    waxen                waxen\n    waxes                wax\n    waxing               wax\n    way                  wai\n    waylaid              waylaid\n    waylay               waylai\n    ways                 wai\n    wayward              wayward\n    waywarder            wayward\n    waywardness          wayward\n    we                   we\n    weak                 weak\n    weaken               weaken\n    weakens              weaken\n    weaker               weaker\n    weakest              weakest\n    weakling             weakl\n    weakly               weakli\n    weakness             weak\n    weal                 weal\n    wealsmen             wealsmen\n    wealth               wealth\n    wealthiest           wealthiest\n    wealthily            wealthili\n    wealthy              wealthi\n    wealtlly             wealtlli\n    wean                 wean\n    weapon               weapon\n    weapons              weapon\n    wear                 wear\n    wearer               wearer\n    wearers              wearer\n    wearied              weari\n    wearies              weari\n    weariest             weariest\n    wearily              wearili\n    weariness            weari\n    wearing              wear\n    wearisome            wearisom\n    wears                wear\n    weary                weari\n    weasel               weasel\n    weather              weather\n    weathercock          weathercock\n    weathers             weather\n    weav                 weav\n    weave                weav\n    weaver               weaver\n    weavers              weaver\n    weaves               weav\n    weaving              weav\n    web                  web\n    wed                  wed\n    wedded               wed\n    wedding              wed\n    wedg                 wedg\n    wedged               wedg\n    wedges               wedg\n    wedlock              wedlock\n    wednesday            wednesdai\n    weed                 weed\n    weeded               weed\n    weeder               weeder\n    weeding              weed\n    weeds                weed\n    weedy                weedi\n    week                 week\n    weeke                week\n    weekly               weekli\n    weeks                week\n    ween                 ween\n    weening              ween\n    weep                 weep\n    weeper               weeper\n    weeping              weep\n    weepingly            weepingli\n    weepings             weep\n    weeps                weep\n    weet                 weet\n    weigh                weigh\n    weighed              weigh\n    weighing             weigh\n    weighs               weigh\n    weight               weight\n    weightier            weightier\n    weightless           weightless\n    weights              weight\n    weighty              weighti\n    weird                weird\n    welcom               welcom\n    welcome              welcom\n    welcomer             welcom\n    welcomes             welcom\n    welcomest            welcomest\n    welfare              welfar\n    welkin               welkin\n    well                 well\n    wells                well\n    welsh                welsh\n    welshman             welshman\n    welshmen             welshmen\n    welshwomen           welshwomen\n    wench                wench\n    wenches              wench\n    wenching             wench\n    wend                 wend\n    went                 went\n    wept                 wept\n    weraday              weradai\n    were                 were\n    wert                 wert\n    west                 west\n    western              western\n    westminster          westminst\n    westmoreland         westmoreland\n    westward             westward\n    wet                  wet\n    wether               wether\n    wetting              wet\n    wezand               wezand\n    whale                whale\n    whales               whale\n    wharf                wharf\n    wharfs               wharf\n    what                 what\n    whate                whate\n    whatever             whatev\n    whatsoe              whatso\n    whatsoever           whatsoev\n    whatsome             whatsom\n    whe                  whe\n    wheat                wheat\n    wheaten              wheaten\n    wheel                wheel\n    wheeling             wheel\n    wheels               wheel\n    wheer                wheer\n    wheeson              wheeson\n    wheezing             wheez\n    whelk                whelk\n    whelks               whelk\n    whelm                whelm\n    whelp                whelp\n    whelped              whelp\n    whelps               whelp\n    when                 when\n    whenas               whena\n    whence               whenc\n    whencesoever         whencesoev\n    whene                whene\n    whenever             whenev\n    whensoever           whensoev\n    where                where\n    whereabout           whereabout\n    whereas              wherea\n    whereat              whereat\n    whereby              wherebi\n    wherefore            wherefor\n    wherein              wherein\n    whereinto            whereinto\n    whereof              whereof\n    whereon              whereon\n    whereout             whereout\n    whereso              whereso\n    wheresoe             whereso\n    wheresoever          wheresoev\n    wheresome            wheresom\n    whereto              whereto\n    whereuntil           whereuntil\n    whereunto            whereunto\n    whereupon            whereupon\n    wherever             wherev\n    wherewith            wherewith\n    wherewithal          wherewith\n    whet                 whet\n    whether              whether\n    whetstone            whetston\n    whetted              whet\n    whew                 whew\n    whey                 whei\n    which                which\n    whiff                whiff\n    whiffler             whiffler\n    while                while\n    whiles               while\n    whilst               whilst\n    whin                 whin\n    whine                whine\n    whined               whine\n    whinid               whinid\n    whining              whine\n    whip                 whip\n    whipp                whipp\n    whippers             whipper\n    whipping             whip\n    whips                whip\n    whipster             whipster\n    whipstock            whipstock\n    whipt                whipt\n    whirl                whirl\n    whirled              whirl\n    whirligig            whirligig\n    whirling             whirl\n    whirlpool            whirlpool\n    whirls               whirl\n    whirlwind            whirlwind\n    whirlwinds           whirlwind\n    whisp                whisp\n    whisper              whisper\n    whispering           whisper\n    whisperings          whisper\n    whispers             whisper\n    whist                whist\n    whistle              whistl\n    whistles             whistl\n    whistling            whistl\n    whit                 whit\n    white                white\n    whitehall            whitehal\n    whitely              white\n    whiteness            white\n    whiter               whiter\n    whites               white\n    whitest              whitest\n    whither              whither\n    whiting              white\n    whitmore             whitmor\n    whitsters            whitster\n    whitsun              whitsun\n    whittle              whittl\n    whizzing             whizz\n    who                  who\n    whoa                 whoa\n    whoe                 whoe\n    whoever              whoever\n    whole                whole\n    wholesom             wholesom\n    wholesome            wholesom\n    wholly               wholli\n    whom                 whom\n    whoobub              whoobub\n    whoop                whoop\n    whooping             whoop\n    whor                 whor\n    whore                whore\n    whoremaster          whoremast\n    whoremasterly        whoremasterli\n    whoremonger          whoremong\n    whores               whore\n    whoreson             whoreson\n    whoresons            whoreson\n    whoring              whore\n    whorish              whorish\n    whose                whose\n    whoso                whoso\n    whosoe               whoso\n    whosoever            whosoev\n    why                  why\n    wi                   wi\n    wick                 wick\n    wicked               wick\n    wickednes            wickedn\n    wickedness           wicked\n    wicket               wicket\n    wicky                wicki\n    wid                  wid\n    wide                 wide\n    widens               widen\n    wider                wider\n    widow                widow\n    widowed              widow\n    widower              widow\n    widowhood            widowhood\n    widows               widow\n    wield                wield\n    wife                 wife\n    wight                wight\n    wights               wight\n    wild                 wild\n    wildcats             wildcat\n    wilder               wilder\n    wilderness           wilder\n    wildest              wildest\n    wildfire             wildfir\n    wildly               wildli\n    wildness             wild\n    wilds                wild\n    wiles                wile\n    wilful               wil\n    wilfull              wilful\n    wilfully             wilfulli\n    wilfulnes            wilfuln\n    wilfulness           wil\n    will                 will\n    willed               will\n    willers              willer\n    willeth              willeth\n    william              william\n    williams             william\n    willing              will\n    willingly            willingli\n    willingness          willing\n    willoughby           willoughbi\n    willow               willow\n    wills                will\n    wilt                 wilt\n    wiltshire            wiltshir\n    wimpled              wimpl\n    win                  win\n    wince                winc\n    winch                winch\n    winchester           winchest\n    wincot               wincot\n    wind                 wind\n    winded               wind\n    windgalls            windgal\n    winding              wind\n    windlasses           windlass\n    windmill             windmil\n    window               window\n    windows              window\n    windpipe             windpip\n    winds                wind\n    windsor              windsor\n    windy                windi\n    wine                 wine\n    wing                 wing\n    winged               wing\n    wingfield            wingfield\n    wingham              wingham\n    wings                wing\n    wink                 wink\n    winking              wink\n    winks                wink\n    winner               winner\n    winners              winner\n    winning              win\n    winnow               winnow\n    winnowed             winnow\n    winnows              winnow\n    wins                 win\n    winter               winter\n    winterly             winterli\n    winters              winter\n    wip                  wip\n    wipe                 wipe\n    wiped                wipe\n    wipes                wipe\n    wiping               wipe\n    wire                 wire\n    wires                wire\n    wiry                 wiri\n    wisdom               wisdom\n    wisdoms              wisdom\n    wise                 wise\n    wiselier             wiseli\n    wisely               wise\n    wiser                wiser\n    wisest               wisest\n    wish                 wish\n    wished               wish\n    wisher               wisher\n    wishers              wisher\n    wishes               wish\n    wishest              wishest\n    wisheth              wisheth\n    wishful              wish\n    wishing              wish\n    wishtly              wishtli\n    wisp                 wisp\n    wist                 wist\n    wit                  wit\n    witb                 witb\n    witch                witch\n    witchcraft           witchcraft\n    witches              witch\n    witching             witch\n    with                 with\n    withal               withal\n    withdraw             withdraw\n    withdrawing          withdraw\n    withdrawn            withdrawn\n    withdrew             withdrew\n    wither               wither\n    withered             wither\n    withering            wither\n    withers              wither\n    withheld             withheld\n    withhold             withhold\n    withholds            withhold\n    within               within\n    withold              withold\n    without              without\n    withstand            withstand\n    withstanding         withstand\n    withstood            withstood\n    witless              witless\n    witness              wit\n    witnesses            wit\n    witnesseth           witnesseth\n    witnessing           wit\n    wits                 wit\n    witted               wit\n    wittenberg           wittenberg\n    wittiest             wittiest\n    wittily              wittili\n    witting              wit\n    wittingly            wittingli\n    wittol               wittol\n    wittolly             wittolli\n    witty                witti\n    wiv                  wiv\n    wive                 wive\n    wived                wive\n    wives                wive\n    wiving               wive\n    wizard               wizard\n    wizards              wizard\n    wo                   wo\n    woe                  woe\n    woeful               woeful\n    woefull              woeful\n    woefullest           woefullest\n    woes                 woe\n    woful                woful\n    wolf                 wolf\n    wolfish              wolfish\n    wolsey               wolsei\n    wolves               wolv\n    wolvish              wolvish\n    woman                woman\n    womanhood            womanhood\n    womanish             womanish\n    womankind            womankind\n    womanly              womanli\n    womb                 womb\n    wombs                womb\n    womby                wombi\n    women                women\n    won                  won\n    woncot               woncot\n    wond                 wond\n    wonder               wonder\n    wondered             wonder\n    wonderful            wonder\n    wonderfully          wonderfulli\n    wondering            wonder\n    wonders              wonder\n    wondrous             wondrou\n    wondrously           wondrous\n    wont                 wont\n    wonted               wont\n    woo                  woo\n    wood                 wood\n    woodbine             woodbin\n    woodcock             woodcock\n    woodcocks            woodcock\n    wooden               wooden\n    woodland             woodland\n    woodman              woodman\n    woodmonger           woodmong\n    woods                wood\n    woodstock            woodstock\n    woodville            woodvil\n    wooed                woo\n    wooer                wooer\n    wooers               wooer\n    wooes                wooe\n    woof                 woof\n    wooing               woo\n    wooingly             wooingli\n    wool                 wool\n    woollen              woollen\n    woolly               woolli\n    woolsack             woolsack\n    woolsey              woolsei\n    woolward             woolward\n    woos                 woo\n    wor                  wor\n    worcester            worcest\n    word                 word\n    words                word\n    wore                 wore\n    worins               worin\n    work                 work\n    workers              worker\n    working              work\n    workings             work\n    workman              workman\n    workmanly            workmanli\n    workmanship          workmanship\n    workmen              workmen\n    works                work\n    worky                worki\n    world                world\n    worldlings           worldl\n    worldly              worldli\n    worlds               world\n    worm                 worm\n    worms                worm\n    wormwood             wormwood\n    wormy                wormi\n    worn                 worn\n    worried              worri\n    worries              worri\n    worry                worri\n    worrying             worri\n    worse                wors\n    worser               worser\n    worship              worship\n    worshipful           worship\n    worshipfully         worshipfulli\n    worshipp             worshipp\n    worshipper           worshipp\n    worshippers          worshipp\n    worshippest          worshippest\n    worships             worship\n    worst                worst\n    worsted              worst\n    wort                 wort\n    worth                worth\n    worthied             worthi\n    worthier             worthier\n    worthies             worthi\n    worthiest            worthiest\n    worthily             worthili\n    worthiness           worthi\n    worthless            worthless\n    worths               worth\n    worthy               worthi\n    worts                wort\n    wot                  wot\n    wots                 wot\n    wotting              wot\n    wouid                wouid\n    would                would\n    wouldest             wouldest\n    wouldst              wouldst\n    wound                wound\n    wounded              wound\n    wounding             wound\n    woundings            wound\n    woundless            woundless\n    wounds               wound\n    wouns                woun\n    woven                woven\n    wow                  wow\n    wrack                wrack\n    wrackful             wrack\n    wrangle              wrangl\n    wrangler             wrangler\n    wranglers            wrangler\n    wrangling            wrangl\n    wrap                 wrap\n    wrapp                wrapp\n    wraps                wrap\n    wrapt                wrapt\n    wrath                wrath\n    wrathful             wrath\n    wrathfully           wrathfulli\n    wraths               wrath\n    wreak                wreak\n    wreakful             wreak\n    wreaks               wreak\n    wreath               wreath\n    wreathed             wreath\n    wreathen             wreathen\n    wreaths              wreath\n    wreck                wreck\n    wrecked              wreck\n    wrecks               wreck\n    wren                 wren\n    wrench               wrench\n    wrenching            wrench\n    wrens                wren\n    wrest                wrest\n    wrested              wrest\n    wresting             wrest\n    wrestle              wrestl\n    wrestled             wrestl\n    wrestler             wrestler\n    wrestling            wrestl\n    wretch               wretch\n    wretchcd             wretchcd\n    wretched             wretch\n    wretchedness         wretched\n    wretches             wretch\n    wring                wring\n    wringer              wringer\n    wringing             wring\n    wrings               wring\n    wrinkle              wrinkl\n    wrinkled             wrinkl\n    wrinkles             wrinkl\n    wrist                wrist\n    wrists               wrist\n    writ                 writ\n    write                write\n    writer               writer\n    writers              writer\n    writes               write\n    writhled             writhl\n    writing              write\n    writings             write\n    writs                writ\n    written              written\n    wrong                wrong\n    wronged              wrong\n    wronger              wronger\n    wrongful             wrong\n    wrongfully           wrongfulli\n    wronging             wrong\n    wrongly              wrongli\n    wrongs               wrong\n    wronk                wronk\n    wrote                wrote\n    wroth                wroth\n    wrought              wrought\n    wrung                wrung\n    wry                  wry\n    wrying               wry\n    wt                   wt\n    wul                  wul\n    wye                  wye\n    x                    x\n    xanthippe            xanthipp\n    xi                   xi\n    xii                  xii\n    xiii                 xiii\n    xiv                  xiv\n    xv                   xv\n    y                    y\n    yard                 yard\n    yards                yard\n    yare                 yare\n    yarely               yare\n    yarn                 yarn\n    yaughan              yaughan\n    yaw                  yaw\n    yawn                 yawn\n    yawning              yawn\n    ycleped              yclepe\n    ycliped              yclipe\n    ye                   ye\n    yea                  yea\n    yead                 yead\n    year                 year\n    yearly               yearli\n    yearn                yearn\n    yearns               yearn\n    years                year\n    yeas                 yea\n    yeast                yeast\n    yedward              yedward\n    yell                 yell\n    yellow               yellow\n    yellowed             yellow\n    yellowing            yellow\n    yellowness           yellow\n    yellows              yellow\n    yells                yell\n    yelping              yelp\n    yeoman               yeoman\n    yeomen               yeomen\n    yerk                 yerk\n    yes                  ye\n    yesterday            yesterdai\n    yesterdays           yesterdai\n    yesternight          yesternight\n    yesty                yesti\n    yet                  yet\n    yew                  yew\n    yicld                yicld\n    yield                yield\n    yielded              yield\n    yielder              yielder\n    yielders             yielder\n    yielding             yield\n    yields               yield\n    yok                  yok\n    yoke                 yoke\n    yoked                yoke\n    yokefellow           yokefellow\n    yokes                yoke\n    yoketh               yoketh\n    yon                  yon\n    yond                 yond\n    yonder               yonder\n    yongrey              yongrei\n    yore                 yore\n    yorick               yorick\n    york                 york\n    yorkists             yorkist\n    yorks                york\n    yorkshire            yorkshir\n    you                  you\n    young                young\n    younger              younger\n    youngest             youngest\n    youngling            youngl\n    younglings           youngl\n    youngly              youngli\n    younker              younker\n    your                 your\n    yours                your\n    yourself             yourself\n    yourselves           yourselv\n    youth                youth\n    youthful             youth\n    youths               youth\n    youtli               youtli\n    zanies               zani\n    zany                 zani\n    zeal                 zeal\n    zealous              zealou\n    zeals                zeal\n    zed                  zed\n    zenelophon           zenelophon\n    zenith               zenith\n    zephyrs              zephyr\n    zir                  zir\n    zo                   zo\n    zodiac               zodiac\n    zodiacs              zodiac\n    zone                 zone\n    zounds               zound\n    zwagger              zwagger\n}                         \n\n# Create a full-text index to use for testing the stemmer.\n#\ndb close\nsqlite3 db :memory:\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts1(word, tokenize Porter);\n}\n\nforeach {pfrom pto} $porter_test_data {\n  do_test fts1porter-$pfrom {\n    execsql {\n      DELETE FROM t1_term;\n      DELETE FROM t1_content;\n      INSERT INTO t1(word) VALUES($pfrom);\n      SELECT term FROM t1_term;\n    }\n  } $pto\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2.test",
    "content": "# 2008 July 22\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n# $Id: fts2.test,v 1.2 2008/07/23 18:17:32 drh Exp $\n\nproc lshift {lvar} {\n  upvar $lvar l\n  set ret [lindex $l 0]\n  set l [lrange $l 1 end]\n  return $ret\n}\nwhile {[set arg [lshift argv]] != \"\"} {\n  switch -- $arg {\n    -sharedpagercache {\n      sqlite3_enable_shared_cache 1\n    }\n    -soak {\n       set G(issoak) 1\n    }\n    default {\n      set argv [linsert $argv 0 $arg]\n      break\n    }\n  }\n}\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  return\n}\nrename finish_test really_finish_test\nproc finish_test {} {}\nset G(isquick) 1\n\nset EXCLUDE {\n  fts2.test\n}\n\n# Files to include in the test.  If this list is empty then everything\n# that is not in the EXCLUDE list is run.\n#\nset INCLUDE {\n}\n\nforeach testfile [lsort -dictionary [glob $testdir/fts2*.test]] {\n  set tail [file tail $testfile]\n  if {[lsearch -exact $EXCLUDE $tail]>=0} continue\n  if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue\n  source $testfile\n  catch {db close}\n  if {$sqlite_open_file_count>0} {\n    puts \"$tail did not close all files: $sqlite_open_file_count\"\n    fail_test $tail\n    set sqlite_open_file_count 0\n  }\n}\n\nset sqlite_open_file_count 0\nreally_finish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2a.test",
    "content": "# 2006 September 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS2 module.\n#\n# $Id: fts2a.test,v 1.2 2007/05/21 21:59:18 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1(content) VALUES('one');\n  INSERT INTO t1(content) VALUES('two');\n  INSERT INTO t1(content) VALUES('one two');\n  INSERT INTO t1(content) VALUES('three');\n  INSERT INTO t1(content) VALUES('one three');\n  INSERT INTO t1(content) VALUES('two three');\n  INSERT INTO t1(content) VALUES('one two three');\n  INSERT INTO t1(content) VALUES('four');\n  INSERT INTO t1(content) VALUES('one four');\n  INSERT INTO t1(content) VALUES('two four');\n  INSERT INTO t1(content) VALUES('one two four');\n  INSERT INTO t1(content) VALUES('three four');\n  INSERT INTO t1(content) VALUES('one three four');\n  INSERT INTO t1(content) VALUES('two three four');\n  INSERT INTO t1(content) VALUES('one two three four');\n  INSERT INTO t1(content) VALUES('five');\n  INSERT INTO t1(content) VALUES('one five');\n  INSERT INTO t1(content) VALUES('two five');\n  INSERT INTO t1(content) VALUES('one two five');\n  INSERT INTO t1(content) VALUES('three five');\n  INSERT INTO t1(content) VALUES('one three five');\n  INSERT INTO t1(content) VALUES('two three five');\n  INSERT INTO t1(content) VALUES('one two three five');\n  INSERT INTO t1(content) VALUES('four five');\n  INSERT INTO t1(content) VALUES('one four five');\n  INSERT INTO t1(content) VALUES('two four five');\n  INSERT INTO t1(content) VALUES('one two four five');\n  INSERT INTO t1(content) VALUES('three four five');\n  INSERT INTO t1(content) VALUES('one three four five');\n  INSERT INTO t1(content) VALUES('two three four five');\n  INSERT INTO t1(content) VALUES('one two three four five');\n}\n\ndo_test fts2a-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts2a-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts2a-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts2a-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}\n} {7 15 23 31}\ndo_test fts2a-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}\n} {7 15 23 31}\ndo_test fts2a-1.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}\n} {7 15 23 31}\ndo_test fts2a-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}\n} {7 15 23 31}\ndo_test fts2a-1.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}\n} {7 15 23 31}\ndo_test fts2a-1.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}\n} {7 15 23 31}\ndo_test fts2a-1.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}\n} {7 15 23 31}\ndo_test fts2a-1.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '  ONE    Two   three  '}\n} {7 15 23 31}\n\ndo_test fts2a-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one\"'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts2a-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\"'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts2a-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"two one\"'}\n} {}\ndo_test fts2a-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three\"'}\n} {7 15 23 31}\ndo_test fts2a-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two\"'}\n} {}\ndo_test fts2a-2.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three four\"'}\n} {15 31}\ndo_test fts2a-2.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two four\"'}\n} {}\ndo_test fts2a-2.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three five\"'}\n} {21}\ndo_test fts2a-2.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" five'}\n} {21 29}\ndo_test fts2a-2.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\"'}\n} {21 29}\ndo_test fts2a-2.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\" four'}\n} {29}\ndo_test fts2a-2.12 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four \"one three\"'}\n} {29}\ndo_test fts2a-2.13 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" four five'}\n} {29}\n\ndo_test fts2a-3.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts2a-3.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}\n} {1 5 9 13 17 21 25 29}\ndo_test fts2a-3.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}\n} {1 5 9 13 17 21 25 29}\n\ndo_test fts2a-4.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}\n} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}\ndo_test fts2a-4.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\" OR three'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts2a-4.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR \"one two\"'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts2a-4.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts2a-4.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts2a-4.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\ndo_test fts2a-4.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\n\n# Test the ability to handle NULL content\n#\ndo_test fts2a-5.1 {\n  execsql {INSERT INTO t1(content) VALUES(NULL)}\n} {}\ndo_test fts2a-5.2 {\n  set rowid [db last_insert_rowid]\n  execsql {SELECT content FROM t1 WHERE rowid=$rowid}\n} {{}}\ndo_test fts2a-5.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}\n} {}\n\n# Test the ability to handle non-positive rowids\n#\ndo_test fts2a-6.0 {\n  execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}\n} {}\ndo_test fts2a-6.1 {\n  execsql {SELECT content FROM t1 WHERE rowid = 0}\n} {{four five}}\ndo_test fts2a-6.2 {\n  execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}\n} {}\ndo_test fts2a-6.3 {\n  execsql {SELECT content FROM t1 WHERE rowid = -1}\n} {{three four}}\ndo_test fts2a-6.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}\n} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2b.test",
    "content": "# 2006 September 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS2 module.\n#\n# $Id: fts2b.test,v 1.1 2006/10/19 23:36:26 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Fill the full-text index \"t1\" with phrases in english, spanish,\n# and german.  For the i-th row, fill in the names for the bits\n# that are set in the value of i.  The least significant bit is\n# 1.  For example,  the value 5 is 101 in binary which will be\n# converted to \"one three\" in english.\n#\nproc fill_multilanguage_fulltext_t1 {} {\n  set english {one two three four five}\n  set spanish {un dos tres cuatro cinco}\n  set german {eine zwei drei vier funf}\n  \n  for {set i 1} {$i<=31} {incr i} {\n    set cmd \"INSERT INTO t1 VALUES\"\n    set vset {}\n    foreach lang {english spanish german} {\n      set words {}\n      for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n        if {$k&$i} {lappend words [lindex [set $lang] $j]}\n      }\n      lappend vset \"'$words'\"\n    }\n    set sql \"INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])\"\n    # puts $sql\n    db eval $sql\n  }\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(english,spanish,german);\n}\nfill_multilanguage_fulltext_t1\n\ndo_test fts2b-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts2b-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}\n} {}\ndo_test fts2b-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}\n} {}\ndo_test fts2b-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts2b-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}\n} {7 15 23 31}\ndo_test fts2b-1.6 {\n  execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}\n} {one un eine}\ndo_test fts2b-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"one un\"'}\n} {}\n\ndo_test fts2b-2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t2 USING fts2(from,to);\n    INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');\n    SELECT [from], [to] FROM t2\n  }\n} {{one two three} {four five six}}\n\n\n# Compute an SQL string that contains the words one, two, three,... to\n# describe bits set in the value $i.  Only the lower 5 bits are examined.\n#\nproc wordset {i} {\n  set x {}\n  for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n    if {$k&$i} {lappend x [lindex {one two three four five} $j]}\n  }\n  return '$x'\n}\n\n# Create a new FTS table with three columns:\n#\n#    norm:      words for the bits of rowid\n#    plusone:   words for the bits of rowid+1\n#    invert:    words for the bits of ~rowid\n#\ndb eval {\n   CREATE VIRTUAL TABLE t4 USING fts2([norm],'plusone',\"invert\");\n}\nfor {set i 1} {$i<=15} {incr i} {\n  set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]\n  db eval \"INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);\"\n}\n\ndo_test fts2b-4.1 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts2b-4.2 {\n  execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts2b-4.3 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}\ndo_test fts2b-4.4 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}\n} {2 4 6 8 10 12 14}\ndo_test fts2b-4.5 {\n  execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}\n} {2 4 6 8 10 12 14}\ndo_test fts2b-4.6 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}\n} {1 5 9 13}\ndo_test fts2b-4.7 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts2b-4.8 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}\n} {1 5 9 13}\ndo_test fts2b-4.9 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}\n} {1 3 5 7 9 11 13 15}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2c.test",
    "content": "# 2006 September 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS2 module.\n#\n# $Id: fts2c.test,v 1.1 2006/10/19 23:36:26 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Create a table of sample email data.   The data comes from email\n# archives of Enron executives that was published as part of the\n# litigation against that company.\n#\ndo_test fts2c-1.1 {\n  db eval {\n    CREATE VIRTUAL TABLE email USING fts2([from],[to],subject,body);\n    BEGIN TRANSACTION;\nINSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.\n\nThe volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below: \n\n?\tIf the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.\n?\tIf the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.\n?\tFor all other volumes, the same rounding rules will apply based on the volume increment on the parent product.\n\nPlease see example below:\n\nParent''s Settings:\nMinimum: \t5000\nIncrement:  1000\n\nVolume on Autohedge transaction\t\t\tVolume Hedged\n1      - 2499\t\t\t\t\t\t\t0\n2500 - 5499\t\t\t\t\t\t\t5000\n5500 - 6499\t\t\t\t\t\t\t6000');\nINSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:  \nIf it''s ok with everyone''s needs, I would like to leave @4pm. If you think \nyou will need my assistance past the 4 o''clock hour just let me know;  I''ll \nbe more than willing to stay.');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:\n\nEmployee Name: Christopher F. Calger\nStatus last changed by: Mollie E. Gustafson Ms\nExpense Report Name: CC02.06.02\nReport Total: $3,972.93\nAmount Due Employee: $3,972.93\n\n\nTo approve this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,\n\nCould you print off the current work request report by 1:30 today?\n\nGentlemen,\n\nI''d like to review this today at 1:30 in our office.  Also, could you provide \nme with your activity reports so I can have Julie enter this information.\n\nJD');\nINSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big.... \nhttp://biz.yahoo.com/rf/010129/n29305829.html');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats!  Things seem to be building rapidly now on the Continent.  Mark');\nINSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '\nThe producer lumber pricing sheet.\n -----Original Message-----\nFrom: \tJohnson, Jay  \nSent:\tTuesday, October 16, 2001 3:42 PM\nTo:\tCarter, Karen E.\nSubject:\tFW: Producers Newsletter 9-24-2001\n\n\n\n -----Original Message-----\nFrom: \tDaigre, Sergai  \nSent:\tFriday, September 21, 2001 8:33 PM\nSubject:\tProducers Newsletter 9-24-2001\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would \nbe to offer up the Falcon for their use; however, given the tight time frame \nand your recent visit with Mr. Fox that it would be difficult for either you \nor me to participate.\n\nI spoke to Max and he agrees with this approach.\n\nI hope this meets with your approval.\n\nRegards\nDelainey');\nINSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,\n\nHere is the original memo we discussed earlier.  Please provide any information that you may have.\n\nYour cooperation is greatly appreciated.\n\nThanks,\n\nlachandra.fenceroy@enron.com\n713.853.3884\n877.498.3401 Pager\n\n -----Original Message-----\nFrom: \tBisbee, Joanne  \nSent:\tWednesday, September 26, 2001 7:50 AM\nTo:\tFenceroy, LaChandra\nSubject:\tFW: Bus Applications Meeting Follow Up\n\nLachandra, Please get with David Duff today and see what this is about.  Who are our TW accounting business users?\n\n -----Original Message-----\nFrom: \tKoh, Wendy  \nSent:\tTuesday, September 25, 2001 2:41 PM\nTo:\tBisbee, Joanne\nSubject:\tBus Applications Meeting Follow Up\n\nLisa brought up a TW change effective Nov 1.  It involves eliminating a turnback surcharge.  I have no other information, but you might check with the business folks for any system changes required.\n\nWendy');\nINSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,\n    If Julie''s merit needs to be lump sum, just move it over to that column.  Also, send me Eric Gadd''s sheets as well.  Thanks.\nDan\n\n -----Original Message-----\nFrom: \tFagan, Fran  \nSent:\tThursday, December 20, 2001 11:10 AM\nTo:\tMcCarty, Danny\nSubject:\tworksheets\n\nAs discussed, attached are your sheets for bonus and merit.\n\nThanks,\n\nFran Fagan\nSr. HR Rep\n713.853.5219\n\n\n << File: McCartyMerit.xls >>  << File: mccartyBonusCommercial_UnP.xls >> \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,\n\nPLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER.  SO FAR I HAVE THEM FOR LEAF.  I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH.  ANY QUESTIONS PLEASE GIVE ME A CALL.\n\nBERT');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification:  (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin\n\n\nI spoke with Rickey (boy, is he long-winded!!).  Gave him the name of our \ncredit guy, Russell Diamond.\n\nThank for your help!');\nINSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts.  I will fax these notices to you.');\nINSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --\n\nHere is the information on staffing and outside services.  Call if you need anything else.\n\nJim\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer, \nAttached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages. \nIn addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks. \nGreg Elliott \nIIR, Inc. \n713-783-5147 x 3481 \noutages@industrialinfo.com \nTHE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE.  YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS \nE-MAIL IN ERROR, PLEASE DELETE IT.\n - OUTAGE.dbf \n - 111201R.xls \n - 111201.xls ');\nINSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !\n\nYou are invited to attend the EWS Brown Bag Lunch Series\n\nFeaturing:   RAY BOWEN, COO\n\nTopic:  Enron Industrial Markets\n\nThursday, March 15, 2001\n11:30 am - 12:30 pm\nEB 5 C2\n\n\nYou bring your lunch,           Limited Seating\nWe provide drinks and dessert.          RSVP  x 3-9610');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me.  I bet this is next to the Warick?? Hotel.\n\n\n\n\n\"Immer, Ingrid\" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM\nTo: \"''chris.germany@enron.com''\" <chris.germany@enron.com>\ncc:  \nSubject: About St Pauls\n\n\n\n\n <<About St Pauls.url>>  \n? \n?http://www.stpaulshouston.org/about.html \n\nChris, \n\nI like the looks of this place.? What do you think about going here Christmas \neve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m., \namong others.\n\nLet me know.?? ii \n\n - About St Pauls.url\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder\nAs discussed in the Winter Operations Meeting on Sept.29,2000, \nE-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.  \nMarketers and Poolers can receive gas via Peaking and IBSS nominations(daisy \nchain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.\n');\nINSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', ' \n\nHere is a goody for you');\nINSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification:  (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap       10.000 / Enron ; 110.000 / HPL IFERC\n\nLS HPL LSK IC       30.000 / Enron\n');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-\n\nIs it safe to assume that practice is cancelled for tonight??\n\nSusan Pereira');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this.  I didn''t know how deep to go with the desk.  Do you think this works.\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,\nGive me a call and we will further discuss opportunities on the 13st floor.\n\nThanks,\nJMForney\n3-7160');\nINSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');\nINSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me.  It has plenty of points in it.  If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.\n\nadam\n35227\n\n\n -----Original Message-----\nFrom: \tRoyed, Jeff  \nSent:\tTuesday, September 25, 2001 11:37 AM\nTo:\tBayer, Adam\nSubject:\tCurve Fetch File\n\nLet me know if it works.   It may be required to have a certain version of Oracle for it to work properly.\n\n \n\nJeff Royed\nEnron \nEnergy Operations\nPhone: 713-853-5295');\nINSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,\n\nThe merged reports look great.  I believe the only orientation changes are to \n\"unmerge\" the following six reports:  \n\n31 Keystone Receipts\n15 Questar Pipeline\n40 Rockies Production\n22 West_2\n23 West_3\n25 CIG_WIC\n\nThe orientation of the individual reports should be correct.  Thanks.\n\nMat\n\nPS.  Just a reminder to add the \"*\" by the title of calculated points.');\nINSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000 \n10:08 AM ---------------------------\n\n\n\"Karkour, Randa\" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM\nTo: \"''Agheb (E-mail)\" <Agheb@aol.com>, \"Leila Mankarious (E-mail)\" \n<Leila_Mankarious@mhhs.org>, \"''Marymankarious (E-mail)\" \n<marymankarious@aol.com>, \"Michelle lokay (E-mail)\" <mlokay@enron.com>, \"Ramy \nMankarious (E-mail)\" <Mankarious@aol.com>\ncc:  \n\nSubject: Egyptian Festival\n\n\n <<Egyptian Festival.url>>\n\n http://www.egyptianfestival.com/\n\n - Egyptian Festival.url\n');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................\n\nThanks\n---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000 \n08:39 AM ---------------------------\n   \n\t\n\t\n\tFrom:  William Kelly @ ECT                           12/20/2000 08:31 AM\n\t\n\nTo: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David \nBaumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON\ncc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R \nLilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra \nChavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT \n\nSubject: New EAST books\n\nWe have new book names in TAGG for our intramonth portfolios and it is \nextremely important that any deal booked to the East is communicated quickly \nto someone on my team.  I know it will take some time for the new names to \nsink in and I do not want us to miss any positions or P&L.  \n\nThanks for your help on this.\n\nNew:\nScott Neal :         East Northeast\nDick Jenkins:     East Marketeast\n\nWK \n');\nINSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will \naffect any Inactive Child.\n\nAn inactive Child with links to Parent products will not have their \ncalculated prices updated until the Child product is Activated.\n\nWhen the Child Product is activated, the price will be recalculated and \nupdated BEFORE it is displayed on the web.\n\nThis means that if you are inputting a basis price on a Child product, you \nwill not see the final, calculated price until you Activate the product, at \nwhich time the customer will also see it.\n\nIf you have any questions, please contact the Help Desk on:\n\nAmericas: 713 853 4357\nEurope: + 44 (0) 20 7783 7783\nAsia/Australia: +61 2 9229 2300\n\nDave');\nINSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,\n\nI saw it. Very interesting.\n\nVince\n\n\n\n\n\n\"John H Herbert\" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM\nTo: \"Vince J Kaminski\" <Vince_J_Kaminski@enron.com>\ncc:  \nSubject: Light reading - see pieces beginning on page 7\n\n\nCheers and have a nice weekend,\n\n\nJHHerbert\n\n\n\n\n - gd000728.pdf\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');\nINSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team.  PLEASE DO NOT TAKE, BORROW OR USE this equipment.  Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.\n\nThanks for your understanding in this matter.\n\nT.Jae Black\nEast Power Trading\nAssistant to Kevin Presto\noff. 713-853-5800\nfax 713-646-8272\ncell 713-539-4760');\nINSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,\n\nHave you heard anything more on the 5 X 24s?  We would like to get this \nproduct out ASAP.\n\n\nThanks,\n\nEric');\nINSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]\n[IMAGE][IMAGE][IMAGE] \nDear  SmartReminders Member,\n       [IMAGE]         [IMAGE]        [IMAGE]     [IMAGE]    [IMAGE]    [IMAGE]        [IMAGE]      [IMAGE]     \t\n\n\n  \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nWe respect  your privacy and are a Certified Participant of the BBBOnLine\n Privacy Program.  To be removed from future offers,click  here. \nSmartReminders.com  is a permission based service. To unsubscribe click  here .  ');\nINSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a \"cloud of suspicion\" sort of \nspeak.  He was the one who got into several bad deals and PPA''s in California \nfor CIN, thus he left on a bad note.  Let me know if you need more detail \nthan that, I felt this was the type of info you were looking for.  Thanks!\nBen');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash\nReport Name:   Houston Cellular 8-11-01\nReport Date:   12/13/01\nReport ID:     594D37C9ED2111D5B452\nSubmitted On:  12/13/01\n\nYou are only allowed 2 reports with receipts outstanding.  Your expense reports will not be paid until you meet this requirement.');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI.  the latest broadside against the generators.\n\nSue Mara\nEnron Corp.\nTel: (415) 782-7802\nFax:(415) 782-7854\n----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----\n\n\n\t\"Milner, Marcie\" <MMilner@coral-energy.com> 06/08/2001 11:13 AM \t   To: \"''smara@enron.com''\" <smara@enron.com>  cc:   Subject: CAISO Emergency Motion\t\n\n\nSue, did you see this emergency motion the CAISO filed today?  Apparently\nthey are requesting that FERC discontinue market-based rates immediately and\ngrant refunds plus interest on the difference between cost-based rates and\nmarket revenues received back to May 2000.  They are requesting the\ncommission act within 14 days.  Have you heard anything about what they are\ndoing?\n\nMarcie\n\nhttp://www.caiso.com/docs/2001/06/08/200106081005526469.pdf \n');\nINSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,\n\nWho is General Brinks?\n\nFletch');\nINSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,\n\nHere are the documents that Peter has prepared for Mark Frevert. \n\nNailia\n---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001 \n16:36 ---------------------------\n\n\nNailia Dindarova\n25/06/2001 15:36\nTo: Michael Brown/Enron@EUEnronXGate\ncc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter \nStyles/LON/ECT@ECT \n\nSubject: Documents for Mark Frevert (on EU developments and lessons from \nCalifornia)\n\nMichael,\n\n\nThese are the documents that Peter promised to give to you for Mark Frevert. \nHe has now handed them to him in person but asked me to transmit them \nelectronically to you, as well as Eric and Ross.\n\nNailia\n\n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -\n\nAttached are our comments and suggested changes. Please call to review.\n\nOn the time line for completion, we have four critical steps to complete:\n     Finalize market analysis to refine business case, specifically\n     projected revenue stream\n     Complete counterparty surveying, including targeting 3 CPs for letters\n     of intent\n     Review Enron asset base for potential reuse/ licensing\n     Contract negotiations\n\nJoe will come back to us with an updated time line, but it is my\nexpectation that we are still on the same schedule (we just begun week\nthree) with possibly a week or so slippage.....contract negotiations will\nprobably be the critical path.\n\nWe will send our cut at the actual time line here shortly. Thanks,\n\nPeggy\n\n(See attached file: accenture-dealpoints v2.doc)\n - accenture-dealpoints v2.doc ');\nINSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001 \n03:49 PM ---------------------------\n\n\nThomas A Martin\n10/11/2000 03:55 PM\nTo: Patrick Wade/HOU/ECT@ECT\ncc:  \nSubject: Re: Guadalupe Power Partners LP  \n\nThe deal is physically served at Oasis Waha or Oasis Katy and is priced at \neither HSC, Waha or Katytailgate GD at buyers option three days prior to \nNYMEX  close.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04 \nAM ---------------------------\n\n\nagoddard@nisource.com on 03/08/2001 09:16:57 AM\nTo: \"        -         *Koch, Kent\" <kkoch@nisource.com>, \"        -         \n*Millar, Debra\" <dmillar@nisource.com>, \"        -         *Burke, Lynn\" \n<lburke@nisource.com>\ncc: \"        -         *Heckathorn, Tom\" <theckathorn@nisource.com> \nSubject: Columbia Distribution''s Capacity Available for Release - Sum\n\n\nAttached is Columbia Distribution''s notice of capacity available for release\nfor\nthe summer of 2001 (Apr. 2001 through Oct. 2001).\n\nPlease note that the deadline for bids is 3:00pm EST on March 20, 2001.\n\nIf you have any questions, feel free to contact any of the representatives\nlisted\nat the bottom of the attachment.\n\nAaron Goddard\n\n\n\n\n - 2001Summer.doc\n');\nINSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.  \nCopies will be distributed to Legal and Credit.');\nINSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is : \n713-668-3712...... my cell # is 281-381-7332\n\nthe kid');\nINSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '\n\n-----Original Message-----\nFrom: Punja, Karim \nSent: Thursday, December 13, 2001 2:35 PM\nTo: Richey, Cooper\nSubject: Contact Info\n\n\nCooper,\n\nIts been a real pleasure working with you (even though it was for only a small amount of time)\nI hope we can stay in touch.\n\nHome# 234-0249\nemail: kpunja@hotmail.com\n\nTake Care, \n\nKarim.\n  ');\nINSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.\n\nI haven''t talked to many of you via email recently but I do want to give you\nmy new address for your email file:\n\n    bjm30@earthlink.net\n\nI hope all is well.\n\nBrian McGuinn');\nINSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team.  It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.\n\nShelley');\nINSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', '    Enron Law Conference\n\nSan Antonio, Texas    May 2-4, 2001    Westin Riverwalk\n\n                   See attached memo for more details!!\n\n\n? Registration for the law conference this year will be handled through an \nOnline RSVP Form on the Enron Law Conference Website at \nhttp://lawconference.corp.enron.com.  The website is still under construction \nand will not be available until Thursday, March 15, 2001.  \n\n? We will send you another e-mail to confirm when the Law Conference Website \nis operational. \n\n? Please complete the Online RSVP Form as soon as it is available  and submit \nit no later than Friday, March 30th.  \n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat \nand let him know - we are coming on saturday - i just havent had a chance to \ncall you guys back --  looking forward to it -- i probably need the \ndirections again though');\nINSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,\n\nI''ll get it done today.  \n\nDG    3-9573\n\n\n   \n\t\n\t\n\tFrom:  Bryce Baxter                           06/12/2000 07:15 PM\n\t\n\nTo: Darron C Giron/HOU/ECT@ECT\ncc:  \nSubject: Feedback for Audrey Cook\n\nYou were identified as a reviewer for Audrey Cook.  If possible, could you \ncomplete her feedback by end of business Wednesday?  It will really help me \nin the PRC process to have your input.  Thanks.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,\n\nIn conjunction with the recent movement of several power traders, they are changing the names of their gas books as well.  The names of the new gas books and traders are as follows:\n\nPWR-NG-LT-SPP:  Mike Carson\nPWR-NG-LT-SERC:  Jeff King\n\nIf you need to know their power desk to map their ID to their gas books, those desks are as follows:\n\nEPMI-LT-SPP:  Mike Carson\nEPMI-LT-SERC:  Jeff King\n\nI will be in training this afternoon, but will be back when class is over.  Let me know if you have any questions.\n\nThanks for your help!\nCasey');\nINSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.\n\n\nds\n\n\n  \n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --\n\nIt was an honor and a pleasure to meet both of you yesterday.  I know we will\nhave fun working together on this very special event.\n\nJeff left the jurisprudence luncheon lists for me before he left on vacation.\n I wasn''t sure whether he transmitted them to you as well.  Would you please\nadvise me if you would like them sent to you?  I can email the MS Excel files\nor I can fax the hard copies to you.   Please advise what is most convenient.\n\nI plan to be in town through the holidays and can be reached by phone, email,\nor cell phone at any time.  My cell phone number is 713/705-4829.\n\nThanks again for your interest in the ADL''s work.  Martin.\n\nMartin B. Cominsky\nDirector, Southwest Region\nAnti-Defamation League\n713/627-3490, ext. 122\n713/627-2011 (fax)\nMCominsky@aol.com');\nINSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear.  Is there any possibility for Ben \nRaimer to be Bush''s secretary of HHS?  Just curious about that infamous UTMB \nrumor mill.  Hope things are well, happy holidays.\nPL');\nINSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:\n\nPursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex.  Please let me know if you need anything else.  We look forward to hearing your comments.\n\nMarie\n\nMarie Heard\nSenior Legal Specialist\nEnron North America Corp.\nPhone:  (713) 853-3907\nFax:  (713) 646-3490\nmarie.heard@enron.com\n\n\t\t\t\t ');\nINSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly -  once again thanks so much for your help on this.\n\n           \n\n                                                                     ');\nINSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '\nPlease contact me if you have any questions regarding last weeks prices.\n\nThank you,\nKarolyn Criado\n3-9441\n\n\n \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02.   I would like to take this risk off the books.\n\nIn addition, please find out what a buy-out of VEPCO would cost us.   With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.\n\nWe also need to continue to explore a JEA buy-out.\n\nThanks.');\nINSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg, \n\nI am at home with a sick baby.  (Lots of fun!)  I will call you about this \ntomorrow.\n\nStacy');\nINSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....\n\n w ww.gorelieberman-2000.com/');\nINSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,\n\nI sent you a fax of Kevin Kolb''s comments on the release.  The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).\nThis is assuming we wrap this up on Tuesday.  \n\nPlease email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.\n\nPhillip');\nINSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,\n\nI placed the adjusted L/R Balance on the Enronwest site.  It is under the \"Staff/Kourtney Nelson\".  There are two links:  \n\n1)  \"Adj L_R\" is the same data/format from the weekly strategy meeting. \n2)  \"New Gen 2001_2002\" link has all of the supply side info that is used to calculate the L/R balance\n\t-Please note the Data Flag column, a value of \"3\" indicates the project was cancelled, on hold, etc and is not included in the calc.  \n\nBoth of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please.  Also, James Bruce is working to get his gen report on the web.  That will help with your access to information on new gen.\n\nPlease let me know if you have any questions or feedback,\n\nKourtney\n\n\n\nKourtney Nelson\nFundamental Analysis \nEnron North America\n(503) 464-8280\nkourtney.nelson@enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '\n\n-----Original Message-----\nFrom: Grace, Rebecca M. \nSent: Monday, December 17, 2001 9:44 AM\nTo: Thomas, Paul D.\nCc: Cashion, Jim; Allen, Thresa A.; May, Tom\nSubject: RE: Current Enron TCC Portfolio\n\n\nPaul,\n\nI reviewed NY''s list.  I agree with all of their contracts numbers and mw amounts.\n\nCall if you have any more questions.\n\nRebecca\n\n\n\n -----Original Message-----\nFrom: \tThomas, Paul D.  \nSent:\tMonday, December 17, 2001 9:08 AM\nTo:\tGrace, Rebecca M.\nSubject:\tFW: Current Enron TCC Portfolio\n\n << File: enrontccs.xls >> \nRebecca,\nLet me know if you see any differences.\n\nPaul\nX 3-0403\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Monday, December 17, 2001 9:04 AM\nTo: Ahmed, Naveed\nSubject: FW: Current Enron TCC Portfolio\n\n\n\n\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Thursday, December 13, 2001 10:01 AM\nTo: Baughman, Edward D.\nSubject: Current Enron TCC Portfolio\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy, \nL.P., effective February 1, 2001, with the surviving entity being El Paso \nMerchant Energy, L.P.  We currently have ISDA Master Agreements with both \ncounterparties.  Please see the attached memo regarding the existing Masters \nand let us know which agreement should be terminated.\n\nThanks,\nStephanie\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', ' \n\n -----Original Message-----\nFrom: \tKenne, Dawn C.  \nSent:\tWednesday, February 06, 2002 11:50 AM\nTo:\tKeiser, Kam\nSubject:\tWhat about this too???\n\n\n << File: Netco Trader Matrix.xls >> \n ');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip.  We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request.  Please update per my previous e-mail and forward.\n\nThanks\n\nchris\nx31666');\nINSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend!   Happy Fathers Day!\n\n\nDebra Perlingiere\nEnron North America Corp.\n1400 Smith Street, EB 3885\nHouston, Texas 77002\ndperlin@enron.com\nPhone 713-853-7658\nFax  713-646-3490');\nINSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia  &', 'CALENDAR ENTRY:\tAPPOINTMENT\n\nDescription:\n\tDemo by Martha Janousek of Dashboard & Pipeline Profile / Julia  & Dir Rpts. - 4102\n\nDate:\t\t1/5/2001\nTime:\t\t9:00 AM - 10:00 AM (Central Standard Time)\n\nChairperson:\tOutlook Migration Team\n\nDetailed Description:');\nINSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,\n\nJustin Boyd told me that your can help me with questions regarding Chile.\nWe got a request for guest access through MG.\nThe company is called Escondida and is a subsidiary of BHP Australia.\n\nPlease advise if I can set up a guest account or not.\nF.Y.I.: MG is planning to put a \"in w/h Chile\" contract for Copper on-line as \nsoon as Enron has done the due diligence for this country.\nThanks !\n\n\nBest regards\n\nDiana Seifert\nEOL PCG');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:\n\nStatus last changed by: Barry L. Tycholiz\nExpense Report Name: 121001\nReport Total: $198.98\nAmount Due Employee: $198.98\nAmount Approved: $198.98\nAmount Paid: $0.00\nApproval Status: Approved\nPayment Status: Pending\n\n\nTo review this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:\n\nAustralia:\n1800 678-515\nsupport@palm-au.com\n\nCanada:\n1905 305-6530\nsupport@palm.com\n\nNew Zealand:\n0800 446-398\nsupport@palm-nz.com\n\nU.K.:\n0171 867 0108\neurosupport@palm.3com.com\n\nPlease refer to the Worldwide Customer Support card for a complete technical support contact list.');\nINSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 10:14 AM\nTo:\tStorey, Geoff\nSubject:\tRE: \n\nbp corp\tAlbert LaMore\t281-366-4962\n\nrunning the reports now\n\n\n -----Original Message-----\nFrom: \tStorey, Geoff  \nSent:\tWednesday, October 31, 2001 10:10 AM\nTo:\tQuigley, Dutch\nSubject:\tRE: \n\ngive me a contact over there too\nBP\n\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 9:42 AM\nTo:\tStorey, Geoff\nSubject:\t\n\nCoral\tJeff Whitnah\t713-767-5374\nRelaint\tSteve McGinn\t713-207-4000');\nINSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3;  <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3;  No ancillary schedules awarded.  \nVariances detected.\nVariances detected in Load schedule.\n\n    LOG MESSAGES:\n\nPARSING FILE -->> O:\\Portland\\WestDesk\\California Scheduling\\ISO Final \nSchedules\\2001042203.txt\n\n---- Load Schedule ----\n$$$ Variance found in table tblLoads.\n     Details: (Hour: 3 / Preferred:   1.92 / Final:   1.89)\n  TRANS_TYPE: FINAL\n  LOAD_ID: PGE4\n  MKT_TYPE: 2\n  TRANS_DATE: 4/22/01\n  SC_ID: EPMI\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens. \n\nJohn');\nINSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m.  Sorry I missed you.  (I was in the \nshower).  I have had a shitty week--I suspect my silence (not only to you, \nbut others) after our phone call is a result of the week.  I''m seeing Glen at \n11:15....talk to you');\nINSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '\nThis week''s Lite Bytz presentation will feature the following TOOLZ speaker:\n\nRichard McDougall\nSolaris 8\nThursday, June 7, 2001\n\nIf you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.\n\n*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.\n\nClick below for more details.\n\nhttp://home.enron.com:84/messaging/litebytztoolzprint.jpg');\n    COMMIT;\n  }\n} {}\n\n###############################################################################\n# Everything above just builds an interesting test database.  The actual\n# tests come after this comment.\n###############################################################################\n\ndo_test fts2c-1.2 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark'\n  }\n} {6 17 25 38 40 42 73 74}\ndo_test fts2c-1.3 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan'\n  }\n} {24 40}\ndo_test fts2c-1.4 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark susan'\n  }\n} {40}\ndo_test fts2c-1.5 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan mark'\n  }\n} {40}\ndo_test fts2c-1.6 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '\"mark susan\"'\n  }\n} {}\ndo_test fts2c-1.7 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark -susan'\n  }\n} {6 17 25 38 42 73 74}\ndo_test fts2c-1.8 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '-mark susan'\n  }\n} {24}\ndo_test fts2c-1.9 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark OR susan'\n  }\n} {6 17 24 25 38 40 42 73 74}\n\n# Some simple tests of the automatic \"offsets(email)\" column.  In the sample\n# data set above, only one message, number 20, contains the words\n# \"gas\" and \"reminder\" in both body and subject.\n#\ndo_test fts2c-2.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts2c-2.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}\ndo_test fts2c-2.3 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'body:gas reminder'\n  }\n} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts2c-2.4 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE subject MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8}}\ndo_test fts2c-2.5 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'gas reminder'\n  }\n} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\n\n# Document 32 contains 5 instances of the world \"child\".  But only\n# 3 of them are paired with \"product\".  Make sure only those instances\n# that match the phrase appear in the offsets(email) list.\n#\ndo_test fts2c-3.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'child product' AND +rowid=32\n  }\n} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}\ndo_test fts2c-3.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH '\"child product\"'\n  }\n} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}\n\n# Snippet generator tests\n#\ndo_test fts2c-4.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}\ndo_test fts2c-4.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'christmas candlelight'\n  }\n} {{<b>...</b> place.? What do you think about going here <b>Christmas</b> \neve?? They have an 11:00 a.m. service and a <b>candlelight</b> service at 5:00 p.m., \namong others. <b>...</b>}}\n\ndo_test fts2c-4.3 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <b>Deal</b> <b>Sheet</b> <b>...</b> intent\n     Review Enron asset base for <b>potential</b> <b>reuse</b>/ licensing\n     Contract negotiations <b>...</b>}}\ndo_test fts2c-4.4 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <<<Deal>>> <<<Sheet>>>  intent\n     Review Enron asset base for <<<potential>>> <<<reuse>>>/ licensing\n     Contract negotiations  }}\ndo_test fts2c-4.5 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'first things'\n  }\n} {{Re: <<<First>>> Polish Deal!  Congrats!  <<<Things>>> seem to be building rapidly now on the  }}\ndo_test fts2c-4.6 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'chris is here'\n  }\n} {{<b>chris</b>.germany@enron.com <b>...</b> Sounds good to me.  I bet this <b>is</b> next to the Warick?? Hotel. <b>...</b> place.? What do you think about going <b>here</b> Christmas \neve?? They have an 11:00 a.m. <b>...</b>}}\ndo_test fts2c-4.7 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH '\"pursuant to\"'\n  }\n} {{Erin:\n\n<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to <b>...</b>}}\ndo_test fts2c-4.8 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'ancillary load davis'\n  }\n} {{pete.<b>davis</b>@enron.com <b>...</b> Start Date: 4/22/01; HourAhead hour: 3;  No <b>ancillary</b> schedules awarded.  \nVariances detected.\nVariances detected in <b>Load</b> schedule.\n\n    LOG MESSAGES:\n\nPARSING <b>...</b>}}\n\n# Combinations of AND and OR operators:\n#\ndo_test fts2c-5.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'questar enron OR com'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:  \n\n31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies Production\n22 West_2 <b>...</b>}}\ndo_test fts2c-5.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'enron OR com questar'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b> <b>...</b> six reports:  \n\n31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies Production\n22 West_2 <b>...</b>}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2d.test",
    "content": "# 2006 October 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS2 module, and in particular\n# the Porter stemmer.\n#\n# $Id: fts2d.test,v 1.1 2006/10/19 23:36:26 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\ndo_test fts2d-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts2d-1.2 {\n  execsql {\n    SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';\n  }\n} {{<b>running</b> and <b>jumping</b>}}\ndo_test fts2d-1.3 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(2, 'abcdefghijklmnopqrstuvwyxz');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts2d-1.4 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts2d-1.5 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(3, 'The value is 123456789');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'\n  }\n} {3 {The value is <b>123456789</b>}}\ndo_test fts2d-1.6 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'\n  }\n} {3 {The value is <b>123456789</b>}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2e.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing deletions in the FTS2 module.\n#\n# $Id: fts2e.test,v 1.1 2006/10/19 23:36:26 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 30 INSERT and\n# DELETE statements, so that we'll test both the segmentMerge() merge\n# (over the first 16) and the termSelect() merge (over the level-1\n# segment and 14 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  DELETE FROM t1 WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  DELETE FROM t1 WHERE rowid = 22;\n}\n\ndo_test fts2f-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {14}\n\ndo_test fts2e-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {3 5 9 11 15 17 21}\n\ndo_test fts2e-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 11 14 15 18}\n\ndo_test fts2e-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {5 6 12 14 15 20 21}\n\ndo_test fts2e-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {8 9 11 12 14 15}\n\ndo_test fts2e-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {17 18 20 21}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2f.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing updates in the FTS2 module.\n#\n# $Id: fts2f.test,v 1.2 2007/02/23 00:14:06 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 31 INSERT,\n# UPDATE, and DELETE statements, so that we'll test both the\n# segmentMerge() merge (over the first 16) and the termSelect() merge\n# (over the level-1 segment and 15 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  UPDATE t1 SET content = 'update one three' WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  UPDATE t1 SET content = 'update two five' WHERE rowid = 8;\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  UPDATE t1 SET content = 'update' WHERE rowid = 15;\n}\n\ndo_test fts2f-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {16}\n\ndo_test fts2f-2.0 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}\n} {1 8 15}\n\ndo_test fts2f-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 9 11 17 21}\n\ndo_test fts2f-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 8 11 14 18 22}\n\ndo_test fts2f-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {1 5 6 12 14 20 21 22}\n\ndo_test fts2f-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {9 11 12 14}\n\ndo_test fts2f-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {8 17 18 20 21 22}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2g.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing handling of edge cases for various doclist\n# merging functions in the FTS2 module query logic.\n#\n# $Id: fts2g.test,v 1.3 2007/11/16 00:23:08 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');\n}\n\n# No hits at all.  Returns empty doclists from termSelect().\ndo_test fts2g-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}\n} {}\n\n# Empty left in docListExceptMerge().\ndo_test fts2g-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}\n} {}\n\n# Empty right in docListExceptMerge().\ndo_test fts2g-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}\n} {1}\n\n# Empty left in docListPhraseMerge().\ndo_test fts2g-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"this something\"'}\n} {}\n\n# Empty right in docListPhraseMerge().\ndo_test fts2g-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"something is\"'}\n} {}\n\n# Empty left in docListOrMerge().\ndo_test fts2g-1.6 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}\n} {1}\n\n# Empty right in docListOrMerge().\ndo_test fts2g-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}\n} {1}\n\n# Empty left in docListAndMerge().\ndo_test fts2g-1.8 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}\n} {}\n\n# Empty right in docListAndMerge().\ndo_test fts2g-1.9 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}\n} {}\n\n# No support for all-except queries.\ndo_test fts2g-1.10 {\n  catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}\n} {1 {SQL logic error}}\n\n# Test that docListOrMerge() correctly handles reaching the end of one\n# doclist before it reaches the end of the other.\ndo_test fts2g-1.11 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}\n} {1 2}\ndo_test fts2g-1.12 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}\n} {1 2}\n\n# Empty left and right in docListOrMerge().  Each term matches neither\n# row, and when combined there was an assertion failure.\ndo_test fts2g-1.13 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2h.test",
    "content": "# 2006 October 31 (scaaarey)\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# here is testing correct handling of excessively long terms.\n#\n# $Id: fts2h.test,v 1.1 2006/11/29 21:03:01 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Generate a term of len copies of char.\nproc bigterm {char len} {\n  for {set term \"\"} {$len>0} {incr len -1} {\n    append term $char\n  }\n  return $term\n}\n\n# Generate a document of bigterms based on characters from the list\n# chars.\nproc bigtermdoc {chars len} {\n  set doc \"\"\n  foreach char $chars {\n    append doc \" \" [bigterm $char $len]\n  }\n  return $doc\n}\n\nset len 5000\nset doc1 [bigtermdoc {a b c d} $len]\nset doc2 [bigtermdoc {b d e f} $len]\nset doc3 [bigtermdoc {a c e} $len]\n\nset aterm [bigterm a $len]\nset bterm [bigterm b $len]\nset xterm [bigterm x $len]\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, $doc1);\n  INSERT INTO t1 (rowid, content) VALUES(2, $doc2);\n  INSERT INTO t1 (rowid, content) VALUES(3, $doc3);\n}\n\n# No hits at all.  Returns empty doclists from termSelect().\ndo_test fts2h-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}\n} {}\n\ndo_test fts2h-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}\n} {1 3}\n\ndo_test fts2h-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}\n} {}\n\ndo_test fts2h-1.3 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'\"\n} {1 3}\n\ndo_test fts2h-1.4 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"$aterm $bterm\\\"'\"\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2i.test",
    "content": "# 2007 January 17\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite fts2 library.  The\n# focus here is testing handling of UPDATE when using UTF-16-encoded\n# databases.\n#\n# $Id: fts2i.test,v 1.2 2007/01/24 03:46:35 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\n# NOTE(shess) Copied from capi3.test.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\ndb eval {\n  PRAGMA encoding = \"UTF-16le\";\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n}\n\ndo_test fts2i-1.0 {\n  execsql {PRAGMA encoding}\n} {UTF-16le}\n\ndo_test fts2i-1.1 {\n  execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}\n  execsql {SELECT content FROM t1 WHERE rowid = 1}\n} {one}\n\ndo_test fts2i-1.2 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(2, 'two')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 2}\n} {two}\n\ndo_test fts2i-1.3 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(3, 'three')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'trois' WHERE rowid = 3\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 3}\n} {trois}\n\ndo_test fts2i-1.4 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 4}\n} {four}\n\ndo_test fts2i-1.5 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'cinq' WHERE rowid = 5\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 5}\n} {cinq}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2j.test",
    "content": "# 2007 February 6\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  This\n# tests creating fts2 tables in an attached database.\n#\n# $Id: fts2j.test,v 1.1 2007/02/07 01:01:18 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Clean up anything left over from a previous pass.\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db2 test2.db\n\ndb eval {\n  CREATE VIRTUAL TABLE t3 USING fts2(content);\n  INSERT INTO t3 (rowid, content) VALUES(1, \"hello world\");\n}\n\ndb2 eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, \"hello world\");\n  INSERT INTO t1 (rowid, content) VALUES(2, \"hello there\");\n  INSERT INTO t1 (rowid, content) VALUES(3, \"cruel world\");\n}\n\n# This has always worked because the t1_* tables used by fts2 will be\n# the defaults.\ndo_test fts2j-1.1 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\n# Make certain we're detached if there was an error.\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this appears to work fine, but the t2_* tables used\n# by fts2 will be created in database 'main' instead of database\n# 'two'.  It appears to work fine because the tables end up being the\n# defaults, but obviously is badly broken if you hope to use things\n# other than in the exact same ATTACH setup.\ndo_test fts2j-1.2 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    CREATE VIRTUAL TABLE two.t2 USING fts2(content);\n    INSERT INTO t2 (rowid, content) VALUES(1, \"hello world\");\n    INSERT INTO t2 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO t2 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM t2 WHERE t2 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this broke because the fts2 code attempted to create\n# t3_* tables in database 'main', but they already existed.  Normally\n# this wouldn't happen without t3 itself existing, in which case the\n# fts2 code would never be called in the first place.\ndo_test fts2j-1.3 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n\n    CREATE VIRTUAL TABLE two.t3 USING fts2(content);\n    INSERT INTO two.t3 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO two.t3 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';\n\n    DETACH DATABASE two;\n  } db2\n} {2}\ncatch {db eval {DETACH DATABASE two}}\n\ncatch {db2 close}\nforcedelete test2.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2k.test",
    "content": "# 2007 March 9\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  These\n# make sure that fts2 insertion buffering is fully transparent when\n# using transactions.\n#\n# $Id: fts2k.test,v 1.2 2007/08/10 23:47:04 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, \"hello world\");\n  INSERT INTO t1 (rowid, content) VALUES(2, \"hello there\");\n  INSERT INTO t1 (rowid, content) VALUES(3, \"cruel world\");\n}\n\n# Test that possibly-buffered inserts went through after commit.\ndo_test fts2k-1.1 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(4, \"false world\");\n    INSERT INTO t1 (rowid, content) VALUES(5, \"false door\");\n    COMMIT TRANSACTION;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4}\n\n# Test that buffered inserts are seen by selects in the same\n# transaction.\ndo_test fts2k-1.2 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(6, \"another world\");\n    INSERT INTO t1 (rowid, content) VALUES(7, \"another test\");\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n    COMMIT TRANSACTION;\n  }\n} {1 3 4 6}\n\n# Test that buffered inserts are seen within a transaction.  This is\n# really the same test as 1.2.\ndo_test fts2k-1.3 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(8, \"second world\");\n    INSERT INTO t1 (rowid, content) VALUES(9, \"second sight\");\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n    ROLLBACK TRANSACTION;\n  }\n} {1 3 4 6 8}\n\n# Double-check that the previous result doesn't persist past the\n# rollback!\ndo_test fts2k-1.4 {\n  execsql {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4 6}\n\n# Test it all together.\ndo_test fts2k-1.5 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(10, \"second world\");\n    INSERT INTO t1 (rowid, content) VALUES(11, \"second sight\");\n    ROLLBACK TRANSACTION;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4 6}\n\n# Test that the obvious case works.\ndo_test fts2k-1.6 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 (rowid, content) VALUES(12, \"third world\");\n    COMMIT;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'third';\n  }\n} {12}\n\n# This is exactly the same as the previous test, except that older\n# code loses the INSERT due to an SQLITE_SCHEMA error.\ndo_test fts2k-1.7 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 (rowid, content) VALUES(13, \"third dimension\");\n    CREATE TABLE x (c);\n    COMMIT;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';\n  }\n} {13}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2l.test",
    "content": "# 2007 March 28\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing isspace/isalnum/tolower problems with the\n# FTS2 module.  Unfortunately, this code isn't a really principled set\n# of tests, because it is impossible to know where new uses of these\n# functions might appear.\n#\n# $Id: fts2l.test,v 1.2 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# Tests that startsWith() (calls isspace, tolower, isalnum) can handle\n# hi-bit chars.  parseSpec() also calls isalnum here.\ndo_test fts2l-1.1 {\n  execsql \"CREATE VIRTUAL TABLE t1 USING fts2(content, \\x80)\"\n} {}\n\n# Additionally tests isspace() call in getToken(), and isalnum() call\n# in tokenListToIdList().\ndo_test fts2l-1.2 {\n  catch {\n    execsql \"CREATE VIRTUAL TABLE t2 USING fts2(content, tokenize \\x80)\"\n  }\n  sqlite3_errmsg $DB\n} \"unknown tokenizer: \\x80\"\n\n# Additionally test final isalnum() in startsWith().\ndo_test fts2l-1.3 {\n  execsql \"CREATE VIRTUAL TABLE t3 USING fts2(content, tokenize\\x80)\"\n} {}\n\n# The snippet-generation code has calls to isspace() which are sort of\n# hard to get to.  It finds convenient breakpoints by starting ~40\n# chars before and after the matched term, and scanning ~10 chars\n# around that position for isspace() characters.  The long word with\n# embedded hi-bit chars causes one of these isspace() calls to be\n# exercised.  The version with a couple extra spaces should cause the\n# other isspace() call to be exercised.  [Both cases have been tested\n# in the debugger, but I'm hoping to continue to catch it if simple\n# constant changes change things slightly.\n#\n# The trailing and leading hi-bit chars help with code which tests for\n# isspace() to coalesce multiple spaces.\n\nset word \"\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80\"\nset phrase1 \"$word $word $word target $word $word $word\"\nset phrase2 \"$word $word $word    target    $word $word $word\"\n\ndb eval {CREATE VIRTUAL TABLE t4 USING fts2(content)}\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase1')\"\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase2')\"\n\ndo_test fts2l-1.4 {\n  execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}\n} {1 111 2 117}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2m.test",
    "content": "# 2007 April 9\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  fts2\n# DELETE handling assumed all fields were non-null.  This was not\n# the intention at all.\n#\n# $Id: fts2m.test,v 1.1 2007/04/09 20:45:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(col_a, col_b);\n\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);\n}\n\ndo_test fts2m-1.0 {\n  execsql {\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {2 2 4}\n\ndo_test fts2m-1.1 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 1;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {1 1 3}\n\ndo_test fts2m-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 2;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 1 2}\n\ndo_test fts2m-1.3 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 3;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 1}\n\ndo_test fts2m-1.4 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 4;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2n.test",
    "content": "# 2007 April 26\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements tests for prefix-searching in the fts2\n# component of the SQLite library.\n#\n# $Id: fts2n.test,v 1.2 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n# A large string to prime the pump with.\nset text {\n  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas\n  iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam\n  sed turpis posuere placerat. Curabitur et lorem in lorem porttitor\n  aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit\n  ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra\n  at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,\n  ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at\n  luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu\n  lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse\n  potenti. Cum sociis natoque penatibus et magnis dis parturient\n  montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,\n  suscipit nec, consequat quis, risus.\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n\n  INSERT INTO t1(rowid, c) VALUES(1, $text);\n  INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');\n}\n\n# Exact match\ndo_test fts2n-1.1 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'\"\n} {1}\n\n# And a prefix\ndo_test fts2n-1.2 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'\"\n} {1}\n\n# Prefix includes exact match\ndo_test fts2n-1.3 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'\"\n} {1}\n\n# Make certain everything isn't considered a prefix!\ndo_test fts2n-1.4 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lore'\"\n} {}\n\n# Prefix across multiple rows.\ndo_test fts2n-1.5 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'\"\n} {1 2}\n\n# Likewise, with multiple hits in one document.\ndo_test fts2n-1.6 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'l*'\"\n} {1 2}\n\n# Prefix which should only hit one document.\ndo_test fts2n-1.7 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'\"\n} {2}\n\n# * not at end is dropped.\ndo_test fts2n-1.8 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'\"\n} {}\n\n# Stand-alone * is dropped.\ndo_test fts2n-1.9 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '*'\"\n} {}\n\n# Phrase-query prefix.\ndo_test fts2n-1.10 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"lovely r*\\\"'\"\n} {2}\ndo_test fts2n-1.11 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"lovely r\\\"'\"\n} {}\n\n# Phrase query with multiple prefix matches.\ndo_test fts2n-1.12 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"a* l*\\\"'\"\n} {1 2}\n\n# Phrase query with multiple prefix matches.\ndo_test fts2n-1.13 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"a* l* row\\\"'\"\n} {2}\n\n\n\n\n# Test across updates (and, by implication, deletes).\n\n# Version of text without \"lorem\".\nregsub -all {[Ll]orem} $text '' ntext\n\ndb eval {\n  CREATE VIRTUAL TABLE t2 USING fts2(c);\n\n  INSERT INTO t2(rowid, c) VALUES(1, $text);\n  INSERT INTO t2(rowid, c) VALUES(2, 'Another lovely row');\n  UPDATE t2 SET c = $ntext WHERE rowid = 1;\n}\n\n# Can't see lorem as an exact match.\ndo_test fts2n-2.1 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'\"\n} {}\n\n# Can't see a prefix of lorem, either.\ndo_test fts2n-2.2 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'\"\n} {}\n\n# Can see lovely in the other document.\ndo_test fts2n-2.3 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'\"\n} {2}\n\n# Can still see other hits.\ndo_test fts2n-2.4 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'l*'\"\n} {1 2}\n\n# Prefix which should only hit one document.\ndo_test fts2n-2.5 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lov*'\"\n} {2}\n\n\n\n# Test with a segment which will have multiple levels in the tree.\n\n# Build a big document with lots of unique terms.\nset bigtext $text\nforeach c {a b c d e} {\n  regsub -all {[A-Za-z]+} $bigtext \"&$c\" t\n  append bigtext $t\n}\n\n# Populate a table with many copies of the big document, so that we\n# can test the number of hits found.  Populate $ret with the expected\n# hit counts for each row.  offsets() returns 4 elements for every\n# hit.  We'll have 6 hits for row 1, 1 for row 2, and 6*(2^5)==192 for\n# $bigtext.\nset ret {6 1}\ndb eval {\n  BEGIN;\n  CREATE VIRTUAL TABLE t3 USING fts2(c);\n\n  INSERT INTO t3(rowid, c) VALUES(1, $text);\n  INSERT INTO t3(rowid, c) VALUES(2, 'Another lovely row');\n}\nfor {set i 0} {$i<100} {incr i} {\n  db eval {INSERT INTO t3(rowid, c) VALUES(3+$i, $bigtext)}\n  lappend ret 192\n}\ndb eval {COMMIT;}\n\n# Test that we get the expected number of hits.\ndo_test fts2n-3.1 {\n  set t {}\n  db eval {SELECT offsets(t3) as o FROM t3 WHERE t3 MATCH 'l*'} {\n    set l [llength $o]\n    lappend t [expr {$l/4}]\n  }\n  set t\n} $ret\n\n# TODO(shess) It would be useful to test a couple edge cases, but I\n# don't know if we have the precision to manage it from here at this\n# time.  Prefix hits can cross leaves, which the code above _should_\n# hit by virtue of size.  There are two variations on this.  If the\n# tree is 2 levels high, the code will find the leaf-node extent\n# directly, but if its higher, the code will have to follow two\n# separate interior branches down the tree.  Both should be tested.\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2o.test",
    "content": "# 2007 June 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS2 module.\n#\n# $Id: fts2o.test,v 1.4 2007/07/02 10:16:50 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is not defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n#---------------------------------------------------------------------\n# These tests, fts2o-1.*, test that ticket #2429 is fixed.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);\n  INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');\n}\ndo_test fts2o-1.1 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';\n  }\n} {1 {one <b>four</b> two}}\ndo_test fts2o-1.2 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';\n  }\n} {1 {one <b>four</b>}}\ndo_test fts2o-1.3 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';\n  }\n} {1 {one three <b>four</b>}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts2 table.\n#\ndo_test fts2o-2.1 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {t1 t1_content t1_segments t1_segdir}\ndo_test fts2o-2.2 {\n  execsql { ALTER TABLE t1 RENAME to fts_t1; }\n} {}\ndo_test fts2o-2.3 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts2o-2.4 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir}\n\n# See what happens when renaming the fts2 table fails.\n#\ndo_test fts2o-2.5 {\n  catchsql {\n    CREATE TABLE t1_segdir(a, b, c);\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\ndo_test fts2o-2.6 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts2o-2.7 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}\n\n# See what happens when renaming the fts2 table fails inside a transaction.\n#\ndo_test fts2o-2.8 {\n  execsql {\n    BEGIN;\n    INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');\n  }\n} {}\ndo_test fts2o-2.9 {\n  catchsql {\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\ndo_test fts2o-2.10 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts2o-2.11 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}\ndo_test fts2o-2.12 {\n  execsql COMMIT\n  execsql {SELECT a FROM fts_t1}\n} {{one three four} {one two three}}\ndo_test fts2o-2.12 {\n  execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }\n} {{one three four} {one four} {one four two}}\n\n#-------------------------------------------------------------------\n# Close, delete and reopen the database. The following test should \n# be run on an initially empty db.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndo_test fts2o-3.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts2(a, b, c);\n    INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n  }\n} {{one three four} {one four} {one two}}\n\n# This test was crashing at one point.\n#\ndo_test fts2o-3.2 {\n  execsql {\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n    CREATE TABLE t3(a, b, c);\n    SELECT a, b, c FROM t1 WHERE  c  MATCH 'two';\n  }\n} {{one three four} {one four} {one two} {one three four} {one four} {one two}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts2 table in an attached \n# database.\n#\nforcedelete test2.db test2.db-journal\n\ndo_test fts2o-3.1 {\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    CREATE VIRTUAL TABLE aux.t1 USING fts2(a, b, c);\n    INSERT INTO aux.t1(a, b, c) VALUES(\n      'neung song sahm', 'neung see', 'neung see song'\n    );\n  }\n} {}\n\ndo_test fts2o-3.2 {\n  execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts2o-3.3 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one two}}\n\ndo_test fts2o-3.4 {\n  execsql { ALTER TABLE aux.t1 RENAME TO t2 }\n} {}\n\ndo_test fts2o-3.2 {\n  execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts2o-3.3 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one two}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2p.test",
    "content": "# 2008 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file exercises some new testing functions in the FTS2 module,\n# and then uses them to do some basic tests that FTS2 is internally\n# working as expected.\n#\n# $Id: fts2p.test,v 1.1 2008/07/22 23:32:28 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is not defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Probe to see if support for these functions is compiled in.\n# TODO(shess): Change main.mk to do the right thing and remove this test.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'x');\n}\n\nset s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}\nset r {1 {unable to use function dump_terms in the requested context}}\nif {[catchsql $s]==$r} {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Test that the new functions give appropriate errors.\ndo_test fts2p-0.0 {\n  catchsql {\n    SELECT dump_terms(t1, 1) FROM t1 LIMIT 1;\n  }\n} {1 {dump_terms: incorrect arguments}}\n\ndo_test fts2p-0.1 {\n  catchsql {\n    SELECT dump_terms(t1, 0, 0, 0) FROM t1 LIMIT 1;\n  }\n} {1 {dump_terms: incorrect arguments}}\n\ndo_test fts2p-0.2 {\n  catchsql {\n    SELECT dump_terms(1, t1) FROM t1 LIMIT 1;\n  }\n} {1 {unable to use function dump_terms in the requested context}}\n\ndo_test fts2p-0.3 {\n  catchsql {\n    SELECT dump_terms(t1, 16, 16) FROM t1 LIMIT 1;\n  }\n} {1 {dump_terms: segment not found}}\n\ndo_test fts2p-0.4 {\n  catchsql {\n    SELECT dump_doclist(t1) FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: incorrect arguments}}\n\ndo_test fts2p-0.5 {\n  catchsql {\n    SELECT dump_doclist(t1, NULL) FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: empty second argument}}\n\ndo_test fts2p-0.6 {\n  catchsql {\n    SELECT dump_doclist(t1, '') FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: empty second argument}}\n\ndo_test fts2p-0.7 {\n  catchsql {\n    SELECT dump_doclist(t1, 'a', 0) FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: incorrect arguments}}\n\ndo_test fts2p-0.8 {\n  catchsql {\n    SELECT dump_doclist(t1, 'a', 0, 0, 0) FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: incorrect arguments}}\n\ndo_test fts2p-0.9 {\n  catchsql {\n    SELECT dump_doclist(t1, 'a', 16, 16) FROM t1 LIMIT 1;\n  }\n} {1 {dump_doclist: segment not found}}\n\n#*************************************************************************\n# Utility function to check for the expected terms in the segment\n# level/index.  _all version does same but for entire index.\nproc check_terms {test level index terms} {\n  # TODO(shess): Figure out why uplevel in do_test can't catch\n  # $level and $index directly.\n  set ::level $level\n  set ::index $index\n  do_test $test.terms {\n    execsql {\n      SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;\n    }\n  } [list $terms]\n}\nproc check_terms_all {test terms} {\n  do_test $test.terms {\n    execsql {\n      SELECT dump_terms(t1) FROM t1 LIMIT 1;\n    }\n  } [list $terms]\n}\n\n# Utility function to check for the expected doclist for the term in\n# segment level/index.  _all version does same for entire index.\nproc check_doclist {test level index term doclist} {\n  # TODO(shess): Again, why can't the non-:: versions work?\n  set ::term $term\n  set ::level $level\n  set ::index $index\n  do_test $test {\n    execsql {\n      SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;\n    }\n  } [list $doclist]\n}\nproc check_doclist_all {test term doclist} {\n  set ::term $term\n  do_test $test {\n    execsql {\n      SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;\n    }\n  } [list $doclist]\n}\n\n#*************************************************************************\n# Test the segments resulting from straight-forward inserts.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n}\n\n# Check for expected segments and expected matches.\ndo_test fts2p-1.0.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2}\ndo_test fts2p-1.0.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\n# Check the specifics of the segments constructed.\n# Logical view of entire index.\ncheck_terms_all   fts2p-1.0.1   {a is test that this was}\ncheck_doclist_all fts2p-1.0.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts2p-1.0.1.2 is {[1 0[1]] [3 0[1]]}\ncheck_doclist_all fts2p-1.0.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts2p-1.0.1.4 that {[2 0[0]]}\ncheck_doclist_all fts2p-1.0.1.5 this {[1 0[0]] [3 0[0]]}\ncheck_doclist_all fts2p-1.0.1.6 was {[2 0[1]]}\n\n# Segment 0,0\ncheck_terms   fts2p-1.0.2   0 0 {a is test this}\ncheck_doclist fts2p-1.0.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts2p-1.0.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts2p-1.0.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts2p-1.0.2.4 0 0 this {[1 0[0]]}\n\n# Segment 0,1\ncheck_terms   fts2p-1.0.3   0 1 {a test that was}\ncheck_doclist fts2p-1.0.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts2p-1.0.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts2p-1.0.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts2p-1.0.3.4 0 1 was {[2 0[1]]}\n\n# Segment 0,2\ncheck_terms   fts2p-1.0.4   0 2 {a is test this}\ncheck_doclist fts2p-1.0.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts2p-1.0.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts2p-1.0.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts2p-1.0.4.4 0 2 this {[3 0[0]]}\n\n#*************************************************************************\n# Test the segments resulting from inserts followed by a delete.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE rowid = 1;\n}\n\ndo_test fts2p-1.1.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2 0 3}\ndo_test fts2p-1.1.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}\n\ncheck_terms_all fts2p-1.1.1 {a is test that this was}\ncheck_doclist_all fts2p-1.1.1.1 a {[2 0[2]] [3 0[2]]}\ncheck_doclist_all fts2p-1.1.1.2 is {[3 0[1]]}\ncheck_doclist_all fts2p-1.1.1.3 test {[2 0[3]] [3 0[3]]}\ncheck_doclist_all fts2p-1.1.1.4 that {[2 0[0]]}\ncheck_doclist_all fts2p-1.1.1.5 this {[3 0[0]]}\ncheck_doclist_all fts2p-1.1.1.6 was {[2 0[1]]}\n\ncheck_terms fts2p-1.1.2 0 0 {a is test this}\ncheck_doclist fts2p-1.1.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts2p-1.1.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts2p-1.1.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts2p-1.1.2.4 0 0 this {[1 0[0]]}\n\ncheck_terms fts2p-1.1.3 0 1 {a test that was}\ncheck_doclist fts2p-1.1.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts2p-1.1.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts2p-1.1.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts2p-1.1.3.4 0 1 was {[2 0[1]]}\n\ncheck_terms fts2p-1.1.4 0 2 {a is test this}\ncheck_doclist fts2p-1.1.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts2p-1.1.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts2p-1.1.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts2p-1.1.4.4 0 2 this {[3 0[0]]}\n\ncheck_terms fts2p-1.1.5 0 3 {a is test this}\ncheck_doclist fts2p-1.1.5.1 0 3 a {[1]}\ncheck_doclist fts2p-1.1.5.2 0 3 is {[1]}\ncheck_doclist fts2p-1.1.5.3 0 3 test {[1]}\ncheck_doclist fts2p-1.1.5.4 0 3 this {[1]}\n\n#*************************************************************************\n# Test results when all references to certain tokens are deleted.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE rowid IN (1,3);\n}\n\n# Still 4 segments because 0,3 will contain deletes for rowid 1 and 3.\ndo_test fts2p-1.2.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2 0 3}\ndo_test fts2p-1.2.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts2p-1.2.1 {a is test that this was}\ncheck_doclist_all fts2p-1.2.1.1 a {[2 0[2]]}\ncheck_doclist_all fts2p-1.2.1.2 is {}\ncheck_doclist_all fts2p-1.2.1.3 test {[2 0[3]]}\ncheck_doclist_all fts2p-1.2.1.4 that {[2 0[0]]}\ncheck_doclist_all fts2p-1.2.1.5 this {}\ncheck_doclist_all fts2p-1.2.1.6 was {[2 0[1]]}\n\ncheck_terms fts2p-1.2.2 0 0 {a is test this}\ncheck_doclist fts2p-1.2.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts2p-1.2.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts2p-1.2.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts2p-1.2.2.4 0 0 this {[1 0[0]]}\n\ncheck_terms fts2p-1.2.3 0 1 {a test that was}\ncheck_doclist fts2p-1.2.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts2p-1.2.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts2p-1.2.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts2p-1.2.3.4 0 1 was {[2 0[1]]}\n\ncheck_terms fts2p-1.2.4 0 2 {a is test this}\ncheck_doclist fts2p-1.2.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts2p-1.2.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts2p-1.2.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts2p-1.2.4.4 0 2 this {[3 0[0]]}\n\ncheck_terms fts2p-1.2.5 0 3 {a is test this}\ncheck_doclist fts2p-1.2.5.1 0 3 a {[1] [3]}\ncheck_doclist fts2p-1.2.5.2 0 3 is {[1] [3]}\ncheck_doclist fts2p-1.2.5.3 0 3 test {[1] [3]}\ncheck_doclist fts2p-1.2.5.4 0 3 this {[1] [3]}\n\n#*************************************************************************\n# Test results when everything is optimized manually.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE rowid IN (1,3);\n  DROP TABLE IF EXISTS t1old;\n  ALTER TABLE t1 RENAME TO t1old;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;\n  DROP TABLE t1old;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts2p-1.3.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts2p-1.3.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts2p-1.3.1 {a test that was}\ncheck_doclist_all fts2p-1.3.1.1 a {[2 0[2]]}\ncheck_doclist_all fts2p-1.3.1.2 test {[2 0[3]]}\ncheck_doclist_all fts2p-1.3.1.3 that {[2 0[0]]}\ncheck_doclist_all fts2p-1.3.1.4 was {[2 0[1]]}\n\ncheck_terms fts2p-1.3.2 0 0 {a test that was}\ncheck_doclist fts2p-1.3.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts2p-1.3.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts2p-1.3.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts2p-1.3.2.4 0 0 was {[2 0[1]]}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2q.test",
    "content": "# 2008 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing the FTS2 module's optimize() function.\n#\n# $Id: fts2q.test,v 1.2 2008/07/22 23:49:44 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is not defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Probe to see if support for the FTS2 dump_* functions is compiled in.\n# TODO(shess): Change main.mk to do the right thing and remove this test.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'x');\n}\n\nset s {SELECT dump_terms(t1, 1) FROM t1 LIMIT 1}\nset r {1 {unable to use function dump_terms in the requested context}}\nif {[catchsql $s]==$r} {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Utility function to check for the expected terms in the segment\n# level/index.  _all version does same but for entire index.\nproc check_terms {test level index terms} {\n  # TODO(shess): Figure out why uplevel in do_test can't catch\n  # $level and $index directly.\n  set ::level $level\n  set ::index $index\n  do_test $test.terms {\n    execsql {\n      SELECT dump_terms(t1, $::level, $::index) FROM t1 LIMIT 1;\n    }\n  } [list $terms]\n}\nproc check_terms_all {test terms} {\n  do_test $test.terms {\n    execsql {\n      SELECT dump_terms(t1) FROM t1 LIMIT 1;\n    }\n  } [list $terms]\n}\n\n# Utility function to check for the expected doclist for the term in\n# segment level/index.  _all version does same for entire index.\nproc check_doclist {test level index term doclist} {\n  # TODO(shess): Again, why can't the non-:: versions work?\n  set ::term $term\n  set ::level $level\n  set ::index $index\n  do_test $test {\n    execsql {\n      SELECT dump_doclist(t1, $::term, $::level, $::index) FROM t1 LIMIT 1;\n    }\n  } [list $doclist]\n}\nproc check_doclist_all {test term doclist} {\n  set ::term $term\n  do_test $test {\n    execsql {\n      SELECT dump_doclist(t1, $::term) FROM t1 LIMIT 1;\n    }\n  } [list $doclist]\n}\n\n#*************************************************************************\n# Test results when all rows are deleted and one is added back.\n# Previously older segments would continue to exist, but now the index\n# should be dropped when the table is empty.  The results should look\n# exactly like we never added the earlier rows in the first place.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table.\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n}\n\n# Should be a single initial segment.\ndo_test fts2q-1.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts2q-1.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}\n\ncheck_terms_all fts2q-1.1 {a is test this}\ncheck_doclist_all fts2q-1.1.1 a {[1 0[2]]}\ncheck_doclist_all fts2q-1.1.2 is {[1 0[1]]}\ncheck_doclist_all fts2q-1.1.3 test {[1 0[3]]}\ncheck_doclist_all fts2q-1.1.4 this {[1 0[0]]}\n\ncheck_terms   fts2q-1.2   0 0 {a is test this}\ncheck_doclist fts2q-1.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts2q-1.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts2q-1.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts2q-1.2.4 0 0 this {[1 0[0]]}\n\n#*************************************************************************\n# Test results when everything is optimized manually.\n# NOTE(shess): This is a copy of fts2c-1.3.  I've pulled a copy here\n# because fts2q-2 and fts2q-3 should have identical results.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE rowid IN (1,3);\n  DROP TABLE IF EXISTS t1old;\n  ALTER TABLE t1 RENAME TO t1old;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) SELECT rowid, c FROM t1old;\n  DROP TABLE t1old;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts2q-2.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts2q-2.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts2q-2.1 {a test that was}\ncheck_doclist_all fts2q-2.1.1 a {[2 0[2]]}\ncheck_doclist_all fts2q-2.1.2 test {[2 0[3]]}\ncheck_doclist_all fts2q-2.1.3 that {[2 0[0]]}\ncheck_doclist_all fts2q-2.1.4 was {[2 0[1]]}\n\ncheck_terms fts2q-2.2 0 0 {a test that was}\ncheck_doclist fts2q-2.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts2q-2.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts2q-2.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts2q-2.2.4 0 0 was {[2 0[1]]}\n\n#*************************************************************************\n# Test results when everything is optimized via optimize().\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE rowid IN (1,3);\n  SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts2q-3.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts2q-3.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts2q-3.1 {a test that was}\ncheck_doclist_all fts2q-3.1.1 a {[2 0[2]]}\ncheck_doclist_all fts2q-3.1.2 test {[2 0[3]]}\ncheck_doclist_all fts2q-3.1.3 that {[2 0[0]]}\ncheck_doclist_all fts2q-3.1.4 was {[2 0[1]]}\n\ncheck_terms fts2q-3.2 0 0 {a test that was}\ncheck_doclist fts2q-3.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts2q-3.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts2q-3.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts2q-3.2.4 0 0 was {[2 0[1]]}\n\n#*************************************************************************\n# Test optimize() against a table involving segment merges.\n# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE\n# statements generates a segment.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n\n  UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test' WHERE rowid = 3;\n}\n\n# 2 segments in level 0, 1 in level 1 (18 segments created, 16\n# merged).\ndo_test fts2q-4.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 1 0}\n\ndo_test fts2q-4.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\ncheck_terms_all fts2q-4.1      {a four is one test that this three two was}\ncheck_doclist_all fts2q-4.1.1  a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts2q-4.1.2  four {}\ncheck_doclist_all fts2q-4.1.3  is {[1 0[1]] [3 0[1]]}\ncheck_doclist_all fts2q-4.1.4  one {}\ncheck_doclist_all fts2q-4.1.5  test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts2q-4.1.6  that {[2 0[0]]}\ncheck_doclist_all fts2q-4.1.7  this {[1 0[0]] [3 0[0]]}\ncheck_doclist_all fts2q-4.1.8  three {}\ncheck_doclist_all fts2q-4.1.9  two {}\ncheck_doclist_all fts2q-4.1.10 was {[2 0[1]]}\n\ncheck_terms fts2q-4.2     0 0 {a four test that was}\ncheck_doclist fts2q-4.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts2q-4.2.2 0 0 four {[2]}\ncheck_doclist fts2q-4.2.3 0 0 test {[2 0[3]]}\ncheck_doclist fts2q-4.2.4 0 0 that {[2 0[0]]}\ncheck_doclist fts2q-4.2.5 0 0 was {[2 0[1]]}\n\ncheck_terms fts2q-4.3     0 1 {a four is test this}\ncheck_doclist fts2q-4.3.1 0 1 a {[3 0[2]]}\ncheck_doclist fts2q-4.3.2 0 1 four {[3]}\ncheck_doclist fts2q-4.3.3 0 1 is {[3 0[1]]}\ncheck_doclist fts2q-4.3.4 0 1 test {[3 0[3]]}\ncheck_doclist fts2q-4.3.5 0 1 this {[3 0[0]]}\n\ncheck_terms fts2q-4.4      1 0 {a four is one test that this three two was}\ncheck_doclist fts2q-4.4.1  1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist fts2q-4.4.2  1 0 four {[1] [2 0[4]] [3 0[4]]}\ncheck_doclist fts2q-4.4.3  1 0 is {[1 0[1]] [3 0[1]]}\ncheck_doclist fts2q-4.4.4  1 0 one {[1] [2] [3]}\ncheck_doclist fts2q-4.4.5  1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist fts2q-4.4.6  1 0 that {[2 0[0]]}\ncheck_doclist fts2q-4.4.7  1 0 this {[1 0[0]] [3 0[0]]}\ncheck_doclist fts2q-4.4.8  1 0 three {[1] [2] [3]}\ncheck_doclist fts2q-4.4.9  1 0 two {[1] [2] [3]}\ncheck_doclist fts2q-4.4.10 1 0 was {[2 0[1]]}\n\n# Optimize should leave the result in the level of the highest-level\n# prior segment.\ndo_test fts2q-4.5 {\n  execsql {\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index optimized} 1 0}\n\n# Identical to fts2q-4.matches.\ndo_test fts2q-4.5.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY rowid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\ncheck_terms_all fts2q-4.5.1     {a is test that this was}\ncheck_doclist_all fts2q-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts2q-4.5.1.2 is {[1 0[1]] [3 0[1]]}\ncheck_doclist_all fts2q-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts2q-4.5.1.4 that {[2 0[0]]}\ncheck_doclist_all fts2q-4.5.1.5 this {[1 0[0]] [3 0[0]]}\ncheck_doclist_all fts2q-4.5.1.6 was {[2 0[1]]}\n\ncheck_terms fts2q-4.5.2     1 0 {a is test that this was}\ncheck_doclist fts2q-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist fts2q-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]}\ncheck_doclist fts2q-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist fts2q-4.5.2.4 1 0 that {[2 0[0]]}\ncheck_doclist fts2q-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]}\ncheck_doclist fts2q-4.5.2.6 1 0 was {[2 0[1]]}\n\n# Re-optimizing does nothing.\ndo_test fts2q-5.0 {\n  execsql {\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index already optimal} 1 0}\n\n# Even if we move things around, still does nothing.\ndo_test fts2q-5.1 {\n  execsql {\n    UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index already optimal} 2 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2r.test",
    "content": "# 2008 July 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# These tests exercise the various types of fts2 cursors.\n#\n# $Id: fts2r.test,v 1.1 2008/07/29 20:38:18 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is not defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Test table scan (QUERY_GENERIC).  This kind of query happens for\n# queries with no WHERE clause, or for WHERE clauses which cannot be\n# satisfied by an index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n}\n\ndo_test fts2e-1.1 {\n  execsql {\n    SELECT rowid FROM t1 ORDER BY rowid;\n  }\n} {1 2 3}\n\ndo_test fts2e-1.2 {\n  execsql {\n    SELECT rowid FROM t1 WHERE c LIKE '%test' ORDER BY rowid;\n  }\n} {1 2 3}\n\ndo_test fts2e-1.3 {\n  execsql {\n    SELECT rowid FROM t1 WHERE c LIKE 'That%' ORDER BY rowid;\n  }\n} {2}\n\n#*************************************************************************\n# Test lookup by rowid (QUERY_ROWID).  This kind of query happens for\n# queries which select by the rowid implicit index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);\n  INSERT INTO t2 VALUES (null, 10);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');\n  INSERT INTO t2 VALUES (null, 5);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');\n  INSERT INTO t2 VALUES (null, 20);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');\n}\n\n# TODO(shess): This actually is doing QUERY_GENERIC?  I'd have\n# expected QUERY_ROWID in this case, as for a very large table the\n# full scan is less efficient.\ndo_test fts2e-2.1 {\n  execsql {\n    SELECT rowid FROM t1 WHERE rowid in (1, 2, 10);\n  }\n} {1 2}\n\ndo_test fts2e-2.2 {\n  execsql {\n    SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight;\n  }\n} {2 5 1 10 3 20}\n\ndo_test fts2e-2.3 {\n  execsql {\n    SELECT t1.rowid, weight FROM t1, t2\n           WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight;\n  }\n} {1 10 3 20}\n\n#*************************************************************************\n# Test lookup by MATCH (QUERY_FULLTEXT).  This is the fulltext index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t1 USING fts2(c);\n  CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);\n  INSERT INTO t2 VALUES (null, 10);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');\n  INSERT INTO t2 VALUES (null, 5);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'That was a test');\n  INSERT INTO t2 VALUES (null, 20);\n  INSERT INTO t1 (rowid, c) VALUES (last_insert_rowid(), 'This is a test');\n}\n\ndo_test fts2e-3.1 {\n  execsql {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'this' ORDER BY rowid;\n  }\n} {1 3}\n\ndo_test fts2e-3.2 {\n  execsql {\n    SELECT t1.rowid, weight FROM t1, t2\n     WHERE t1 MATCH 'this' AND t1.rowid = t2.id ORDER BY weight;\n  }\n} {1 10 3 20}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts2token.test",
    "content": "# 2007 June 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library. The focus \n# of this script is testing the pluggable tokeniser feature of the \n# FTS2 module.\n#\n# $Id: fts2token.test,v 1.3 2007/06/25 12:05:40 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS2 is defined, omit this file.\nifcapable !fts2 {\n  finish_test\n  return\n}\n\nproc escape_string {str} {\n  set out \"\"\n  foreach char [split $str \"\"] {\n    scan $char %c i\n    if {$i<=127} {\n      append out $char\n    } else {\n      append out [format {\\x%.4x} $i]\n    }\n  }\n  set out\n}\n\n#--------------------------------------------------------------------------\n# Test cases fts2token-1.* are the warm-body test for the SQL scalar\n# function fts2_tokenizer(). The procedure is as follows:\n#\n#   1: Verify that there is no such fts2 tokenizer as 'blah'.\n#\n#   2: Query for the built-in tokenizer 'simple'. Insert a copy of the\n#      retrieved value as tokenizer 'blah'.\n#\n#   3: Test that the value returned for tokenizer 'blah' is now the\n#      same as that retrieved for 'simple'.\n#\n#   4: Test that it is now possible to create an fts2 table using \n#      tokenizer 'blah' (it was not possible in step 1).\n#\n#   5: Test that the table created to use tokenizer 'blah' is usable.\n#\ndo_test fts2token-1.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);\n  }\n} {1 {unknown tokenizer: blah}}\ndo_test fts2token-1.2 {\n  execsql {\n    SELECT fts2_tokenizer('blah', fts2_tokenizer('simple')) IS NULL;\n  }\n} {0}\ndo_test fts2token-1.3 {\n  execsql {\n    SELECT fts2_tokenizer('blah') == fts2_tokenizer('simple');\n  }\n} {1}\ndo_test fts2token-1.4 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING fts2(content, tokenize blah);\n  }\n} {0 {}}\ndo_test fts2token-1.5 {\n  execsql {\n    INSERT INTO t1(content) VALUES('There was movement at the station');\n    INSERT INTO t1(content) VALUES('For the word has passed around');\n    INSERT INTO t1(content) VALUES('That the colt from ol regret had got away');\n    SELECT content FROM t1 WHERE content MATCH 'movement'\n  }\n} {{There was movement at the station}}\n\n#--------------------------------------------------------------------------\n# Test cases fts2token-2.* test error cases in the scalar function based\n# API for getting and setting tokenizers.\n#\ndo_test fts2token-2.1 {\n  catchsql {\n    SELECT fts2_tokenizer('nosuchtokenizer');\n  }\n} {1 {unknown tokenizer: nosuchtokenizer}}\n\n#--------------------------------------------------------------------------\n# Test cases fts2token-3.* test the three built-in tokenizers with a\n# simple input string via the built-in test function. This is as much\n# to test the test function as the tokenizer implementations.\n#\ndo_test fts2token-3.1 {\n  execsql {\n    SELECT fts2_tokenizer_test('simple', 'I don''t see how');\n  }\n} {{0 i I 1 don don 2 t t 3 see see 4 how how}}\ndo_test fts2token-3.2 {\n  execsql {\n    SELECT fts2_tokenizer_test('porter', 'I don''t see how');\n  }\n} {{0 i I 1 don don 2 t t 3 see see 4 how how}}\nifcapable icu {\n  do_test fts2token-3.3 {\n    execsql {\n      SELECT fts2_tokenizer_test('icu', 'I don''t see how');\n    }\n  } {{0 i I 1 don't don't 2 see see 3 how how}}\n}\n\n#--------------------------------------------------------------------------\n# Test cases fts2token-4.* test the ICU tokenizer. In practice, this\n# tokenizer only has two modes - \"thai\" and \"everybody else\". Some other\n# Asian languages (Lao, Khmer etc.) require the same special treatment as \n# Thai, but ICU doesn't support them yet.\n#\nifcapable icu {\n\n  proc do_icu_test {name locale input output} {\n    set ::out [db eval { SELECT fts2_tokenizer_test('icu', $locale, $input) }]\n    do_test $name {\n      lindex $::out 0\n    } $output\n  }\n  \n  do_icu_test fts2token-4.1 en_US  {}   {}\n  do_icu_test fts2token-4.2 en_US {Test cases fts2} [list \\\n    0 test Test 1 cases cases 2 fts2 fts2\n  ]\n\n  # The following test shows that ICU is smart enough to recognise\n  # Thai chararacters, even when the locale is set to English/United \n  # States.\n  #\n  set input \"\\u0e2d\\u0e30\\u0e44\\u0e23\\u0e19\\u0e30\\u0e04\\u0e23\\u0e31\\u0e1a\"\n  set output    \"0 \\u0e2d\\u0e30\\u0e44\\u0e23 \\u0e2d\\u0e30\\u0e44\\u0e23 \"\n  append output \"1 \\u0e19\\u0e30 \\u0e19\\u0e30 \"\n  append output \"2 \\u0e04\\u0e23\\u0e31\\u0e1a \\u0e04\\u0e23\\u0e31\\u0e1a\"\n\n  do_icu_test fts2token-4.3 th_TH  $input $output\n  do_icu_test fts2token-4.4 en_US  $input $output\n\n  # ICU handles an unknown locale by falling back to the default.\n  # So this is not an error.\n  do_icu_test fts2token-4.5 MiddleOfTheOcean  $input $output\n\n  set    longtoken \"AReallyReallyLongTokenOneThatWillSurelyRequire\"\n  append longtoken \"AReallocInTheIcuTokenizerCode\"\n\n  set    input \"short tokens then \"\n  append input $longtoken\n  set    output \"0 short short \"\n  append output \"1 tokens tokens \"\n  append output \"2 then then \"\n  append output \"3 [string tolower $longtoken] $longtoken\"\n\n  do_icu_test fts2token-4.6 MiddleOfTheOcean  $input $output\n  do_icu_test fts2token-4.7 th_TH  $input $output\n  do_icu_test fts2token-4.8 en_US  $input $output\n}\n\ndo_test fts2token-internal {\n  execsql { SELECT fts2_tokenizer_internal_test() }\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3.test",
    "content": "# 2007 November 23\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n# $Id: fts3.test,v 1.2 2008/07/23 18:17:32 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nifcapable fts3 {\n  run_test_suite fts3\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3_common.tcl",
    "content": "# 2009 November 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains common code used the fts3 tests. At one point\n# equivalent functionality was implemented in C code. But it is easier\n# to use Tcl.\n#\n\n#-------------------------------------------------------------------------\n# INSTRUCTIONS\n#\n# The following commands are available:\n#\n#   fts3_build_db_1 N\n#     Using database handle [db] create an FTS4 table named t1 and populate\n#     it with N rows of data. N must be less than 10,000. Refer to the\n#     header comments above the proc implementation below for details.\n#\n#   fts3_build_db_2 N\n#     Using database handle [db] create an FTS4 table named t2 and populate\n#     it with N rows of data. N must be less than 100,000. Refer to the\n#     header comments above the proc implementation below for details.\n#\n#   fts3_integrity_check TBL\n#     TBL must be an FTS table in the database currently opened by handle\n#     [db]. This proc loads and tokenizes all documents within the table,\n#     then checks that the current contents of the FTS index matches the\n#     results.\n#\n#   fts3_terms TBL WHERE\n#     Todo.\n#\n#   fts3_doclist TBL TERM WHERE\n#     Todo.\n#\n#\n#\n\n#-------------------------------------------------------------------------\n# USAGE: fts3_build_db_1 SWITCHES N\n#\n# Build a sample FTS table in the database opened by database connection \n# [db]. The name of the new table is \"t1\".\n#\nproc fts3_build_db_1 {args} {\n\n  set default(-module) fts4\n\n  set nArg [llength $args]\n  if {($nArg%2)==0} {\n    error \"wrong # args: should be \\\"fts3_build_db_1 ?switches? n\\\"\"\n  }\n\n  set n [lindex $args [expr $nArg-1]]\n  array set opts [array get default]\n  array set opts [lrange $args 0 [expr $nArg-2]]\n  foreach k [array names opts] {\n    if {0==[info exists default($k)]} { error \"unknown option: $k\" }\n  }\n\n  if {$n > 10000} {error \"n must be <= 10000\"}\n  db eval \"CREATE VIRTUAL TABLE t1 USING $opts(-module) (x, y)\"\n\n  set xwords [list zero one two three four five six seven eight nine ten]\n  set ywords [list alpha beta gamma delta epsilon zeta eta theta iota kappa]\n\n  for {set i 0} {$i < $n} {incr i} {\n    set x \"\"\n    set y \"\"\n\n    set x [list]\n    lappend x [lindex $xwords [expr ($i / 1000) % 10]]\n    lappend x [lindex $xwords [expr ($i / 100)  % 10]]\n    lappend x [lindex $xwords [expr ($i / 10)   % 10]]\n    lappend x [lindex $xwords [expr ($i / 1)   % 10]]\n\n    set y [list]\n    lappend y [lindex $ywords [expr ($i / 1000) % 10]]\n    lappend y [lindex $ywords [expr ($i / 100)  % 10]]\n    lappend y [lindex $ywords [expr ($i / 10)   % 10]]\n    lappend y [lindex $ywords [expr ($i / 1)   % 10]]\n\n    db eval { INSERT INTO t1(docid, x, y) VALUES($i, $x, $y) }\n  }\n}\n\n#-------------------------------------------------------------------------\n# USAGE: fts3_build_db_2 N ARGS\n#\n# Build a sample FTS table in the database opened by database connection \n# [db]. The name of the new table is \"t2\".\n#\nproc fts3_build_db_2 {args} {\n\n  set default(-module) fts4\n  set default(-extra)   \"\"\n\n  set nArg [llength $args]\n  if {($nArg%2)==0} {\n    error \"wrong # args: should be \\\"fts3_build_db_1 ?switches? n\\\"\"\n  }\n\n  set n [lindex $args [expr $nArg-1]]\n  array set opts [array get default]\n  array set opts [lrange $args 0 [expr $nArg-2]]\n  foreach k [array names opts] {\n    if {0==[info exists default($k)]} { error \"unknown option: $k\" }\n  }\n\n  if {$n > 100000} {error \"n must be <= 100000\"}\n\n  set sql \"CREATE VIRTUAL TABLE t2 USING $opts(-module) (content\"\n  if {$opts(-extra) != \"\"} {\n    append sql \", \" $opts(-extra)\n  }\n  append sql \")\"\n  db eval $sql\n\n  set chars [list a b c d e f g h  i j k l m n o p  q r s t u v w x  y z \"\"]\n\n  for {set i 0} {$i < $n} {incr i} {\n    set word \"\"\n    set nChar [llength $chars]\n    append word [lindex $chars [expr {($i / 1)   % $nChar}]]\n    append word [lindex $chars [expr {($i / $nChar)  % $nChar}]]\n    append word [lindex $chars [expr {($i / ($nChar*$nChar)) % $nChar}]]\n\n    db eval { INSERT INTO t2(docid, content) VALUES($i, $word) }\n  }\n}\n\n#-------------------------------------------------------------------------\n# USAGE: fts3_integrity_check TBL\n#\n# This proc is used to verify that the full-text index is consistent with\n# the contents of the fts3 table. In other words, it checks that the\n# data in the %_contents table matches that in the %_segdir and %_segments \n# tables.\n#\n# This is not an efficient procedure. It uses a lot of memory and a lot\n# of CPU. But it is better than not checking at all.\n#\n# The procedure is:\n#\n#   1) Read the entire full-text index from the %_segdir and %_segments\n#      tables into memory. For each entry in the index, the following is\n#      done:\n#\n#          set C($iDocid,$iCol,$iPosition) $zTerm\n#\n#   2) Iterate through each column of each row of the %_content table. \n#      Tokenize all documents, and check that for each token there is\n#      a corresponding entry in the $C array. After checking a token,\n#      [unset] the $C array entry.\n#\n#   3) Check that array $C is now empty.\n#      \n#\nproc fts3_integrity_check {tbl} {\n\n  fts3_read2 $tbl 1 A\n\n  foreach zTerm [array names A] {\n    #puts $zTerm\n    foreach doclist $A($zTerm) {\n      set docid 0\n      while {[string length $doclist]>0} {\n        set iCol 0\n        set iPos 0\n        set lPos [list]\n        set lCol [list]\n\n        # First varint of a doclist-entry is the docid. Delta-compressed\n        # with respect to the docid of the previous entry.\n        #\n        incr docid [gobble_varint doclist]\n        if {[info exists D($zTerm,$docid)]} {\n          while {[set iDelta [gobble_varint doclist]] != 0} {}\n          continue\n        }\n        set D($zTerm,$docid) 1\n\n        # Gobble varints until the 0x00 that terminates the doclist-entry\n        # is found.\n        while {[set iDelta [gobble_varint doclist]] > 0} {\n          if {$iDelta == 1} {\n            set iCol [gobble_varint doclist]\n            set iPos 0\n          } else {\n            incr iPos $iDelta\n            incr iPos -2\n            set C($docid,$iCol,$iPos) $zTerm\n          }\n        }\n      }\n    }\n  }\n\n  foreach key [array names C] {\n    #puts \"$key -> $C($key)\"\n  }\n\n\n  db eval \"SELECT * FROM ${tbl}_content\" E {\n    set iCol 0\n    set iDoc $E(docid)\n    foreach col [lrange $E(*) 1 end] {\n      set c $E($col)\n      set sql {SELECT fts3_tokenizer_test('simple', $c)}\n\n      foreach {pos term dummy} [db one $sql] {\n        if {![info exists C($iDoc,$iCol,$pos)]} {\n          set es \"Error at docid=$iDoc col=$iCol pos=$pos. Index is missing\"\n          lappend errors $es\n        } else {\n          if {[string compare $C($iDoc,$iCol,$pos) $term]} {\n            set    es \"Error at docid=$iDoc col=$iCol pos=$pos. Index \"\n            append es \"has \\\"$C($iDoc,$iCol,$pos)\\\", document has \\\"$term\\\"\"\n            lappend errors $es\n          }\n          unset C($iDoc,$iCol,$pos)\n        }\n      }\n      incr iCol\n    }\n  }\n\n  foreach c [array names C] {\n    lappend errors \"Bad index entry: $c -> $C($c)\"\n  }\n\n  if {[info exists errors]} { return [join $errors \"\\n\"] }\n  return \"ok\"\n}\n\n# USAGE: fts3_terms TBL WHERE\n#\n# Argument TBL must be the name of an FTS3 table. Argument WHERE is an\n# SQL expression that will be used as the WHERE clause when scanning\n# the %_segdir table. As in the following query:\n#\n#   \"SELECT * FROM ${TBL}_segdir WHERE ${WHERE}\"\n#\n# This function returns a list of all terms present in the segments\n# selected by the statement above.\n#\nproc fts3_terms {tbl where} {\n  fts3_read $tbl $where a\n  return [lsort [array names a]]\n}\n\n\n# USAGE: fts3_doclist TBL TERM WHERE\n#\n# Argument TBL must be the name of an FTS3 table. TERM is a term that may\n# or may not be present in the table. Argument WHERE is used to select a \n# subset of the b-tree segments in the associated full-text index as \n# described above for [fts3_terms].\n#\n# This function returns the results of merging the doclists associated\n# with TERM in the selected segments. Each doclist is an element of the\n# returned list. Each doclist is formatted as follows:\n#\n#   [$docid ?$col[$off1 $off2...]?...]\n#\n# The formatting is odd for a Tcl command in order to be compatible with\n# the original C-language implementation. If argument WHERE is \"1\", then \n# any empty doclists are omitted from the returned list.\n#\nproc fts3_doclist {tbl term where} {\n  fts3_read $tbl $where a\n\n\n  foreach doclist $a($term) {\n    set docid 0\n\n    while {[string length $doclist]>0} {\n      set iCol 0\n      set iPos 0\n      set lPos [list]\n      set lCol [list]\n      incr docid [gobble_varint doclist]\n  \n      while {[set iDelta [gobble_varint doclist]] > 0} {\n        if {$iDelta == 1} {\n          lappend lCol [list $iCol $lPos]\n          set iPos 0\n          set lPos [list]\n          set iCol [gobble_varint doclist]\n        } else {\n          incr iPos $iDelta\n          incr iPos -2\n          lappend lPos $iPos\n        }\n      }\n  \n      if {[llength $lPos]>0} {\n        lappend lCol [list $iCol $lPos]\n      }\n  \n      if {$where != \"1\" || [llength $lCol]>0} {\n        set ret($docid) $lCol\n      } else {\n        unset -nocomplain ret($docid)\n      }\n    }\n  }\n\n  set lDoc [list]\n  foreach docid [lsort -integer [array names ret]] {\n    set lCol [list]\n    set cols \"\"\n    foreach col $ret($docid) {\n      foreach {iCol lPos} $col {}\n      append cols \" $iCol\\[[join $lPos { }]\\]\"\n    }\n    lappend lDoc \"\\[${docid}${cols}\\]\"\n  }\n\n  join $lDoc \" \"\n}\n\n###########################################################################\n\nproc gobble_varint {varname} {\n  upvar $varname blob\n  set n [read_fts3varint $blob ret]\n  set blob [string range $blob $n end]\n  return $ret\n}\nproc gobble_string {varname nLength} {\n  upvar $varname blob\n  set ret [string range $blob 0 [expr $nLength-1]]\n  set blob [string range $blob $nLength end]\n  return $ret\n}\n\n# The argument is a blob of data representing an FTS3 segment leaf. \n# Return a list consisting of alternating terms (strings) and doclists\n# (blobs of data).\n#\nproc fts3_readleaf {blob} {\n  set zPrev \"\"\n  set terms [list]\n\n  while {[string length $blob] > 0} {\n    set nPrefix [gobble_varint blob]\n    set nSuffix [gobble_varint blob]\n\n    set zTerm [string range $zPrev 0 [expr $nPrefix-1]]\n    append zTerm [gobble_string blob $nSuffix]\n    set nDoclist [gobble_varint blob]\n    set doclist [gobble_string blob $nDoclist]\n\n    lappend terms $zTerm $doclist\n    set zPrev $zTerm\n  }\n\n  return $terms\n}\n\nproc fts3_read2 {tbl where varname} {\n  upvar $varname a\n  array unset a\n  db eval \" SELECT start_block, leaves_end_block, root \n            FROM ${tbl}_segdir WHERE $where\n            ORDER BY level ASC, idx DESC\n  \" {\n    set c 0\n    binary scan $root c c\n    if {$c==0} {\n      foreach {t d} [fts3_readleaf $root] { lappend a($t) $d }\n    } else {\n      db eval \" SELECT block \n                FROM ${tbl}_segments \n                WHERE blockid>=$start_block AND blockid<=$leaves_end_block\n                ORDER BY blockid\n      \" {\n        foreach {t d} [fts3_readleaf $block] { lappend a($t) $d }\n      }\n    }\n  }\n}\n\nproc fts3_read {tbl where varname} {\n  upvar $varname a\n  array unset a\n  db eval \" SELECT start_block, leaves_end_block, root \n            FROM ${tbl}_segdir WHERE $where\n            ORDER BY level DESC, idx ASC\n  \" {\n    if {$start_block == 0} {\n      foreach {t d} [fts3_readleaf $root] { lappend a($t) $d }\n    } else {\n      db eval \" SELECT block \n                FROM ${tbl}_segments \n                WHERE blockid>=$start_block AND blockid<$leaves_end_block\n                ORDER BY blockid\n      \" {\n        foreach {t d} [fts3_readleaf $block] { lappend a($t) $d }\n\n      }\n    }\n  }\n}\n\n##########################################################################\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3aa.test",
    "content": "# 2006 September 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n# $Id: fts3aa.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3aa\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1(content) VALUES('one');\n  INSERT INTO t1(content) VALUES('two');\n  INSERT INTO t1(content) VALUES('one two');\n  INSERT INTO t1(content) VALUES('three');\n  INSERT INTO t1(content) VALUES('one three');\n  INSERT INTO t1(content) VALUES('two three');\n  INSERT INTO t1(content) VALUES('one two three');\n  INSERT INTO t1(content) VALUES('four');\n  INSERT INTO t1(content) VALUES('one four');\n  INSERT INTO t1(content) VALUES('two four');\n  INSERT INTO t1(content) VALUES('one two four');\n  INSERT INTO t1(content) VALUES('three four');\n  INSERT INTO t1(content) VALUES('one three four');\n  INSERT INTO t1(content) VALUES('two three four');\n  INSERT INTO t1(content) VALUES('one two three four');\n  INSERT INTO t1(content) VALUES('five');\n  INSERT INTO t1(content) VALUES('one five');\n  INSERT INTO t1(content) VALUES('two five');\n  INSERT INTO t1(content) VALUES('one two five');\n  INSERT INTO t1(content) VALUES('three five');\n  INSERT INTO t1(content) VALUES('one three five');\n  INSERT INTO t1(content) VALUES('two three five');\n  INSERT INTO t1(content) VALUES('one two three five');\n  INSERT INTO t1(content) VALUES('four five');\n  INSERT INTO t1(content) VALUES('one four five');\n  INSERT INTO t1(content) VALUES('two four five');\n  INSERT INTO t1(content) VALUES('one two four five');\n  INSERT INTO t1(content) VALUES('three four five');\n  INSERT INTO t1(content) VALUES('one three four five');\n  INSERT INTO t1(content) VALUES('two three four five');\n  INSERT INTO t1(content) VALUES('one two three four five');\n}\n\ndo_test fts3aa-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts3aa-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts3aa-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts3aa-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two three'}\n} {7 15 23 31}\ndo_test fts3aa-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one three two'}\n} {7 15 23 31}\ndo_test fts3aa-1.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two three one'}\n} {7 15 23 31}\ndo_test fts3aa-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two one three'}\n} {7 15 23 31}\ndo_test fts3aa-1.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three one two'}\n} {7 15 23 31}\ndo_test fts3aa-1.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three two one'}\n} {7 15 23 31}\ndo_test fts3aa-1.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two THREE'}\n} {7 15 23 31}\ndo_test fts3aa-1.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '  ONE    Two   three  '}\n} {7 15 23 31}\n\ndo_test fts3aa-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one\"'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts3aa-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\"'}\n} {3 7 11 15 19 23 27 31}\ndo_test fts3aa-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"two one\"'}\n} {}\ndo_test fts3aa-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three\"'}\n} {7 15 23 31}\ndo_test fts3aa-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two\"'}\n} {}\ndo_test fts3aa-2.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two three four\"'}\n} {15 31}\ndo_test fts3aa-2.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three two four\"'}\n} {}\ndo_test fts3aa-2.8 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three five\"'}\n} {21}\ndo_test fts3aa-2.9 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" five'}\n} {21 29}\ndo_test fts3aa-2.10 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\"'}\n} {21 29}\ndo_test fts3aa-2.11 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five \"one three\" four'}\n} {29}\ndo_test fts3aa-2.12 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five four \"one three\"'}\n} {29}\ndo_test fts3aa-2.13 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one three\" four five'}\n} {29}\n\ndo_test fts3aa-3.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts3aa-3.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one -two'}\n} {1 5 9 13 17 21 25 29}\ndo_test fts3aa-3.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '-two one'}\n} {1 5 9 13 17 21 25 29}\n\ndo_test fts3aa-4.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one OR two'}\n} {1 2 3 5 6 7 9 10 11 13 14 15 17 18 19 21 22 23 25 26 27 29 30 31}\ndo_test fts3aa-4.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH '\"one two\" OR three'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts3aa-4.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR \"one two\"'}\n} {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}\ndo_test fts3aa-4.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts3aa-4.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR two one'}\n} {3 5 7 11 13 15 19 21 23 27 29 31}\ndo_test fts3aa-4.6 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one two OR three OR four'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\ndo_test fts3aa-4.7 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two OR three OR four one'}\n} {3 5 7 9 11 13 15 19 21 23 25 27 29 31}\n\n# Test the ability to handle NULL content\n#\ndo_test fts3aa-5.1 {\n  execsql {INSERT INTO t1(content) VALUES(NULL)}\n} {}\ndo_test fts3aa-5.2 {\n  set rowid [db last_insert_rowid]\n  execsql {SELECT content FROM t1 WHERE rowid=$rowid}\n} {{}}\ndo_test fts3aa-5.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}\n} {}\n\n# Test the ability to handle non-positive rowids\n#\ndo_test fts3aa-6.0 {\n  execsql {INSERT INTO t1(rowid, content) VALUES(0, 'four five')}\n} {}\ndo_test fts3aa-6.1 {\n  execsql {SELECT content FROM t1 WHERE rowid = 0}\n} {{four five}}\ndo_test fts3aa-6.2 {\n  execsql {INSERT INTO t1(rowid, content) VALUES(-1, 'three four')}\n} {}\ndo_test fts3aa-6.3 {\n  execsql {SELECT content FROM t1 WHERE rowid = -1}\n} {{three four}}\ndo_test fts3aa-6.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'four'}\n} {-1 0 8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31}\n\n# Test creation of FTS3 and FTS4 tables with columns that contain\n# an \"=\" character.\n#\ndo_execsql_test fts3aa-7.1 {\n  CREATE VIRTUAL TABLE t2 USING fts3(xyz=abc);\n  SELECT xyz FROM t2;\n} {}\ndo_catchsql_test fts3aa-7.2 {\n  CREATE VIRTUAL TABLE t3 USING fts4(xyz=abc);\n} {1 {unrecognized parameter: xyz=abc}}\ndo_catchsql_test fts3aa-7.3 {\n  CREATE VIRTUAL TABLE t3 USING fts4(xyz = abc);\n} {1 {unrecognized parameter: xyz = abc}}\n\ndo_execsql_test fts3aa-7.4 {\n  CREATE VIRTUAL TABLE t3 USING fts3(tokenize=simple, tokenize=simple);\n  SELECT tokenize FROM t3;\n} {}\ndo_catchsql_test fts3aa-7.5 {\n  CREATE VIRTUAL TABLE t4 USING fts4(tokenize=simple, tokenize=simple);\n} {1 {unrecognized parameter: tokenize=simple}}\n\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE t0 USING fts4(order=desc);\n  BEGIN;\n  INSERT INTO t0(rowid, content) VALUES(1, 'abc');\n  UPDATE t0 SET docid=5 WHERE docid=1;\n  INSERT INTO t0(rowid, content) VALUES(6, 'abc');\n}\ndo_execsql_test 8.1 {\n  SELECT docid FROM t0 WHERE t0 MATCH 'abc';\n} {6 5}\ndo_execsql_test 8.2 {\n  SELECT docid FROM t0 WHERE t0 MATCH '\"abc abc\"';\n} {}\ndo_execsql_test 8.3 { COMMIT }\ndo_execsql_test 8.4 {\n  SELECT docid FROM t0 WHERE t0 MATCH 'abc';\n} {6 5}\ndo_execsql_test 8.5 {\n  SELECT docid FROM t0 WHERE t0 MATCH '\"abc abc\"';\n} {}\n\ndo_execsql_test 9.1 {\n  CREATE VIRTUAL TABLE t9 USING fts4(a, \"\", '---');\n}\ndo_execsql_test 9.2 {\n  CREATE VIRTUAL TABLE t10 USING fts3(<, b, c);\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ab.test",
    "content": "# 2006 September 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n# $Id: fts3ab.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Fill the full-text index \"t1\" with phrases in english, spanish,\n# and german.  For the i-th row, fill in the names for the bits\n# that are set in the value of i.  The least significant bit is\n# 1.  For example,  the value 5 is 101 in binary which will be\n# converted to \"one three\" in english.\n#\nproc fill_multilanguage_fulltext_t1 {} {\n  set english {one two three four five}\n  set spanish {un dos tres cuatro cinco}\n  set german {eine zwei drei vier funf}\n  \n  for {set i 1} {$i<=31} {incr i} {\n    set cmd \"INSERT INTO t1 VALUES\"\n    set vset {}\n    foreach lang {english spanish german} {\n      set words {}\n      for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n        if {$k&$i} {lappend words [lindex [set $lang] $j]}\n      }\n      lappend vset \"'$words'\"\n    }\n    set sql \"INSERT INTO t1(english,spanish,german) VALUES([join $vset ,])\"\n    # puts $sql\n    db eval $sql\n  }\n}\n\n# Construct a full-text search table containing five keywords:\n# one, two, three, four, and five, in various combinations.  The\n# rowid for each will be a bitmask for the elements it contains.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(english,spanish,german);\n}\nfill_multilanguage_fulltext_t1\n\ndo_test fts3ab-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE english MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts3ab-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE spanish MATCH 'one'}\n} {}\ndo_test fts3ab-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE german MATCH 'one'}\n} {}\ndo_test fts3ab-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one'}\n} {1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31}\ndo_test fts3ab-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'one dos drei'}\n} {7 15 23 31}\ndo_test fts3ab-1.6 {\n  execsql {SELECT english, spanish, german FROM t1 WHERE rowid=1}\n} {one un eine}\ndo_test fts3ab-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"one un\"'}\n} {}\n\ndo_test fts3ab-2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t2 USING fts3(from,to);\n    INSERT INTO t2([from],[to]) VALUES ('one two three', 'four five six');\n    SELECT [from], [to] FROM t2\n  }\n} {{one two three} {four five six}}\n\n\n# Compute an SQL string that contains the words one, two, three,... to\n# describe bits set in the value $i.  Only the lower 5 bits are examined.\n#\nproc wordset {i} {\n  set x {}\n  for {set j 0; set k 1} {$j<5} {incr j; incr k $k} {\n    if {$k&$i} {lappend x [lindex {one two three four five} $j]}\n  }\n  return '$x'\n}\n\n# Create a new FTS table with three columns:\n#\n#    norm:      words for the bits of rowid\n#    plusone:   words for the bits of rowid+1\n#    invert:    words for the bits of ~rowid\n#\ndb eval {\n   CREATE VIRTUAL TABLE t4 USING fts3([norm],'plusone',\"invert\");\n}\nfor {set i 1} {$i<=15} {incr i} {\n  set vset [list [wordset $i] [wordset [expr {$i+1}]] [wordset [expr {~$i}]]]\n  db eval \"INSERT INTO t4(norm,plusone,invert) VALUES([join $vset ,]);\"\n}\n\ndo_test fts3ab-4.1 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts3ab-4.2 {\n  execsql {SELECT rowid FROM t4 WHERE norm MATCH 'one'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts3ab-4.3 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'one'}\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}\ndo_test fts3ab-4.4 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:one'}\n} {2 4 6 8 10 12 14}\ndo_test fts3ab-4.5 {\n  execsql {SELECT rowid FROM t4 WHERE plusone MATCH 'one'}\n} {2 4 6 8 10 12 14}\ndo_test fts3ab-4.6 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one plusone:two'}\n} {1 5 9 13}\ndo_test fts3ab-4.7 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'norm:one two'}\n} {1 3 5 7 9 11 13 15}\ndo_test fts3ab-4.8 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'plusone:two norm:one'}\n} {1 5 9 13}\ndo_test fts3ab-4.9 {\n  execsql {SELECT rowid FROM t4 WHERE t4 MATCH 'two norm:one'}\n} {1 3 5 7 9 11 13 15}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ac.test",
    "content": "# 2006 September 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n# $Id: fts3ac.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Create a table of sample email data.   The data comes from email\n# archives of Enron executives that was published as part of the\n# litigation against that company.\n#\ndo_test fts3ac-1.1 {\n  db eval {\n    CREATE VIRTUAL TABLE email USING fts3([from],[to],subject,body);\n    BEGIN TRANSACTION;\nINSERT INTO email([from],[to],subject,body) VALUES('savita.puthigai@enron.com', 'traders.eol@enron.com, traders.eol@enron.com', 'EnronOnline- Change to Autohedge', 'Effective Monday, October 22, 2001 the following changes will be made to the Autohedge functionality on EnronOnline.\n\nThe volume on the hedge will now respect the minimum volume and volume increment settings on the parent product. See rules below: \n\n?\tIf the transaction volume on the child is less than half of the parent''s minimum volume no hedge will occur.\n?\tIf the transaction volume on the child is more than half the parent''s minimum volume but less than half the volume increment on the parent, the hedge will volume will be the parent''s minimum volume.\n?\tFor all other volumes, the same rounding rules will apply based on the volume increment on the parent product.\n\nPlease see example below:\n\nParent''s Settings:\nMinimum: \t5000\nIncrement:  1000\n\nVolume on Autohedge transaction\t\t\tVolume Hedged\n1      - 2499\t\t\t\t\t\t\t0\n2500 - 5499\t\t\t\t\t\t\t5000\n5500 - 6499\t\t\t\t\t\t\t6000');\nINSERT INTO email([from],[to],subject,body) VALUES('dana.davis@enron.com', 'laynie.east@enron.com, lisa.king@enron.com, lisa.best@enron.com,', 'Leaving Early', 'FYI:  \nIf it''s ok with everyone''s needs, I would like to leave @4pm. If you think \nyou will need my assistance past the 4 o''clock hour just let me know;  I''ll \nbe more than willing to stay.');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'louise.kitchen@enron.com', '<<Concur Expense Document>> - CC02.06.02', 'The following expense report is ready for approval:\n\nEmployee Name: Christopher F. Calger\nStatus last changed by: Mollie E. Gustafson Ms\nExpense Report Name: CC02.06.02\nReport Total: $3,972.93\nAmount Due Employee: $3,972.93\n\n\nTo approve this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('jeff.duff@enron.com', 'julie.johnson@enron.com', 'Work request', 'Julie,\n\nCould you print off the current work request report by 1:30 today?\n\nGentlemen,\n\nI''d like to review this today at 1:30 in our office.  Also, could you provide \nme with your activity reports so I can have Julie enter this information.\n\nJD');\nINSERT INTO email([from],[to],subject,body) VALUES('v.weldon@enron.com', 'gary.l.carrier@usa.dupont.com, scott.joyce@bankofamerica.com', 'Enron News', 'This could turn into something big.... \nhttp://biz.yahoo.com/rf/010129/n29305829.html');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.haedicke@enron.com', 'paul.simons@enron.com', 'Re: First Polish Deal!', 'Congrats!  Things seem to be building rapidly now on the Continent.  Mark');\nINSERT INTO email([from],[to],subject,body) VALUES('e..carter@enron.com', 't..robinson@enron.com', 'FW: Producers Newsletter 9-24-2001', '\nThe producer lumber pricing sheet.\n -----Original Message-----\nFrom: \tJohnson, Jay  \nSent:\tTuesday, October 16, 2001 3:42 PM\nTo:\tCarter, Karen E.\nSubject:\tFW: Producers Newsletter 9-24-2001\n\n\n\n -----Original Message-----\nFrom: \tDaigre, Sergai  \nSent:\tFriday, September 21, 2001 8:33 PM\nSubject:\tProducers Newsletter 9-24-2001\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('david.delainey@enron.com', 'kenneth.lay@enron.com', 'Greater Houston Partnership', 'Ken, in response to the letter from Mr Miguel San Juan, my suggestion would \nbe to offer up the Falcon for their use; however, given the tight time frame \nand your recent visit with Mr. Fox that it would be difficult for either you \nor me to participate.\n\nI spoke to Max and he agrees with this approach.\n\nI hope this meets with your approval.\n\nRegards\nDelainey');\nINSERT INTO email([from],[to],subject,body) VALUES('lachandra.fenceroy@enron.com', 'lindy.donoho@enron.com', 'FW: Bus Applications Meeting Follow Up', 'Lindy,\n\nHere is the original memo we discussed earlier.  Please provide any information that you may have.\n\nYour cooperation is greatly appreciated.\n\nThanks,\n\nlachandra.fenceroy@enron.com\n713.853.3884\n877.498.3401 Pager\n\n -----Original Message-----\nFrom: \tBisbee, Joanne  \nSent:\tWednesday, September 26, 2001 7:50 AM\nTo:\tFenceroy, LaChandra\nSubject:\tFW: Bus Applications Meeting Follow Up\n\nLachandra, Please get with David Duff today and see what this is about.  Who are our TW accounting business users?\n\n -----Original Message-----\nFrom: \tKoh, Wendy  \nSent:\tTuesday, September 25, 2001 2:41 PM\nTo:\tBisbee, Joanne\nSubject:\tBus Applications Meeting Follow Up\n\nLisa brought up a TW change effective Nov 1.  It involves eliminating a turnback surcharge.  I have no other information, but you might check with the business folks for any system changes required.\n\nWendy');\nINSERT INTO email([from],[to],subject,body) VALUES('danny.mccarty@enron.com', 'fran.fagan@enron.com', 'RE: worksheets', 'Fran,\n    If Julie''s merit needs to be lump sum, just move it over to that column.  Also, send me Eric Gadd''s sheets as well.  Thanks.\nDan\n\n -----Original Message-----\nFrom: \tFagan, Fran  \nSent:\tThursday, December 20, 2001 11:10 AM\nTo:\tMcCarty, Danny\nSubject:\tworksheets\n\nAs discussed, attached are your sheets for bonus and merit.\n\nThanks,\n\nFran Fagan\nSr. HR Rep\n713.853.5219\n\n\n << File: McCartyMerit.xls >>  << File: mccartyBonusCommercial_UnP.xls >> \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('bert.meyers@enron.com', 'shift.dl-portland@enron.com', 'OCTOBER SCHEDULE', 'TEAM,\n\nPLEASE SEND ME ANY REQUESTS THAT YOU HAVE FOR OCTOBER.  SO FAR I HAVE THEM FOR LEAF.  I WOULD LIKE TO HAVE IT DONE BY THE 15TH OF THE MONTH.  ANY QUESTIONS PLEASE GIVE ME A CALL.\n\nBERT');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'john.arnold@enron.com, bilal.bajwa@enron.com, john.griffith@enron.com,', 'TRV Notification:  (NG - PROPT P/L - 09/27/2001)', 'The report named: NG - PROPT P/L <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=11&report_name=NG+-+PROPT+P/L&category_cd=5&category_name=FINANCIAL&toc_hide=1&sTV1=5&TV1Exp=Y&current_efct_date=09/27/2001>, published as of 09/27/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('patrice.mims@enron.com', 'calvin.eakins@enron.com', 'Re: Small business supply assistance', 'Hi Calvin\n\n\nI spoke with Rickey (boy, is he long-winded!!).  Gave him the name of our \ncredit guy, Russell Diamond.\n\nThank for your help!');\nINSERT INTO email([from],[to],subject,body) VALUES('legal <.hall@enron.com>', 'stephanie.panus@enron.com', 'Termination update', 'City of Vernon and Salt River Project terminated their contracts.  I will fax these notices to you.');\nINSERT INTO email([from],[to],subject,body) VALUES('d..steffes@enron.com', 'richard.shapiro@enron.com', 'EES / ENA Government Affairs Staffing & Outside Services', 'Rick --\n\nHere is the information on staffing and outside services.  Call if you need anything else.\n\nJim\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('gelliott@industrialinfo.com', 'pcopello@industrialinfo.com', 'ECAAR (Gavin), WSCC (Diablo Canyon), & NPCC (Seabrook)', 'Dear Power Outage Database Customer, \nAttached you will find an excel document. The outages contained within are forced or rescheduled outages. Your daily delivery will still contain these outages. \nIn addition to the two excel documents, there is a dbf file that is formatted like your daily deliveries you receive nightly. This will enable you to load the data into your regular database. Any questions please let me know. Thanks. \nGreg Elliott \nIIR, Inc. \n713-783-5147 x 3481 \noutages@industrialinfo.com \nTHE INFORMATION CONTAINED IN THIS E-MAIL IS LEGALLY PRIVILEGED AND CONFIDENTIAL INFORMATION INTENDED ONLY FOR THE USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE.  YOU ARE HEREBY NOTIFIED THAT ANY DISSEMINATION, DISTRIBUTION, OR COPY OF THIS E-MAIL TO UNAUTHORIZED ENTITIES IS STRICTLY PROHIBITED. IF YOU HAVE RECEIVED THIS \nE-MAIL IN ERROR, PLEASE DELETE IT.\n - OUTAGE.dbf \n - 111201R.xls \n - 111201.xls ');\nINSERT INTO email([from],[to],subject,body) VALUES('enron.announcements@enron.com', 'all_ena_egm_eim@enron.com', 'EWS Brown Bag', 'MARK YOUR LUNCH CALENDARS NOW !\n\nYou are invited to attend the EWS Brown Bag Lunch Series\n\nFeaturing:   RAY BOWEN, COO\n\nTopic:  Enron Industrial Markets\n\nThursday, March 15, 2001\n11:30 am - 12:30 pm\nEB 5 C2\n\n\nYou bring your lunch,           Limited Seating\nWe provide drinks and dessert.          RSVP  x 3-9610');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.germany@enron.com', 'ingrid.immer@williams.com', 'Re: About St Pauls', 'Sounds good to me.  I bet this is next to the Warick?? Hotel.\n\n\n\n\n\"Immer, Ingrid\" <Ingrid.Immer@Williams.com> on 12/21/2000 11:48:47 AM\nTo: \"''chris.germany@enron.com''\" <chris.germany@enron.com>\ncc:  \nSubject: About St Pauls\n\n\n\n\n <<About St Pauls.url>>  \n? \n?http://www.stpaulshouston.org/about.html \n\nChris, \n\nI like the looks of this place.? What do you think about going here Christmas \neve?? They have an 11:00 a.m. service and a candlelight service at 5:00 p.m., \namong others.\n\nLet me know.?? ii \n\n - About St Pauls.url\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('nas@cpuc.ca.gov', 'skatz@sempratrading.com, kmccrea@sablaw.com, thompson@wrightlaw.com,', 'Reply Brief filed July 31, 2000', ' - CPUC01-#76371-v1-Revised_Reply_Brief__Due_today_7_31_.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('gascontrol@aglresources.com', 'dscott4@enron.com, lcampbel@enron.com', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder', 'Alert Posted 10:00 AM November 20,2000: E-GAS Request Reminder\nAs discussed in the Winter Operations Meeting on Sept.29,2000, \nE-Gas(Emergency Gas) will not be offered this winter as a service from AGLC.  \nMarketers and Poolers can receive gas via Peaking and IBSS nominations(daisy \nchain) from other marketers up to the 6 p.m. Same Day 2 nomination cycle.\n');\nINSERT INTO email([from],[to],subject,body) VALUES('dutch.quigley@enron.com', 'rwolkwitz@powermerchants.com', '', ' \n\nHere is a goody for you');\nINSERT INTO email([from],[to],subject,body) VALUES('ryan.o''rourke@enron.com', 'k..allen@enron.com, randy.bhatia@enron.com, frank.ermis@enron.com,', 'TRV Notification:  (West VaR - 11/07/2001)', 'The report named: West VaR <http://trv.corp.enron.com/linkFromExcel.asp?report_cd=36&report_name=West+VaR&category_cd=2&category_name=WEST&toc_hide=1&sTV1=2&TV1Exp=Y&current_efct_date=11/07/2001>, published as of 11/07/2001 is now available for viewing on the website.');\nINSERT INTO email([from],[to],subject,body) VALUES('mjones7@txu.com', 'cstone1@txu.com, ggreen2@txu.com, timpowell@txu.com,', 'Enron / HPL Actuals for July 10, 2000', 'Teco Tap       10.000 / Enron ; 110.000 / HPL IFERC\n\nLS HPL LSK IC       30.000 / Enron\n');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.pereira@enron.com', 'kkw816@aol.com', 'soccer practice', 'Kathy-\n\nIs it safe to assume that practice is cancelled for tonight??\n\nSusan Pereira');\nINSERT INTO email([from],[to],subject,body) VALUES('mark.whitt@enron.com', 'barry.tycholiz@enron.com', 'Huber Internal Memo', 'Please look at this.  I didn''t know how deep to go with the desk.  Do you think this works.\n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('m..forney@enron.com', 'george.phillips@enron.com', '', 'George,\nGive me a call and we will further discuss opportunities on the 13st floor.\n\nThanks,\nJMForney\n3-7160');\nINSERT INTO email([from],[to],subject,body) VALUES('brad.mckay@enron.com', 'angusmcka@aol.com', 'Re: (no subject)', 'not yet');\nINSERT INTO email([from],[to],subject,body) VALUES('adam.bayer@enron.com', 'jonathan.mckay@enron.com', 'FW: Curve Fetch File', 'Here is the curve fetch file sent to me.  It has plenty of points in it.  If you give me a list of which ones you need we may be able to construct a secondary worksheet to vlookup the values.\n\nadam\n35227\n\n\n -----Original Message-----\nFrom: \tRoyed, Jeff  \nSent:\tTuesday, September 25, 2001 11:37 AM\nTo:\tBayer, Adam\nSubject:\tCurve Fetch File\n\nLet me know if it works.   It may be required to have a certain version of Oracle for it to work properly.\n\n \n\nJeff Royed\nEnron \nEnergy Operations\nPhone: 713-853-5295');\nINSERT INTO email([from],[to],subject,body) VALUES('matt.smith@enron.com', 'yan.wang@enron.com', 'Report Formats', 'Yan,\n\nThe merged reports look great.  I believe the only orientation changes are to \n\"unmerge\" the following six reports:  \n\n31 Keystone Receipts\n15 Questar Pipeline\n40 Rockies Production\n22 West_2\n23 West_3\n25 CIG_WIC\n\nThe orientation of the individual reports should be correct.  Thanks.\n\nMat\n\nPS.  Just a reminder to add the \"*\" by the title of calculated points.');\nINSERT INTO email([from],[to],subject,body) VALUES('michelle.lokay@enron.com', 'jimboman@bigfoot.com', 'Egyptian Festival', '---------------------- Forwarded by Michelle Lokay/ET&S/Enron on 09/07/2000 \n10:08 AM ---------------------------\n\n\n\"Karkour, Randa\" <Randa.Karkour@COMPAQ.com> on 09/07/2000 09:01:04 AM\nTo: \"''Agheb (E-mail)\" <Agheb@aol.com>, \"Leila Mankarious (E-mail)\" \n<Leila_Mankarious@mhhs.org>, \"''Marymankarious (E-mail)\" \n<marymankarious@aol.com>, \"Michelle lokay (E-mail)\" <mlokay@enron.com>, \"Ramy \nMankarious (E-mail)\" <Mankarious@aol.com>\ncc:  \n\nSubject: Egyptian Festival\n\n\n <<Egyptian Festival.url>>\n\n http://www.egyptianfestival.com/\n\n - Egyptian Festival.url\n');\nINSERT INTO email([from],[to],subject,body) VALUES('errol.mclaughlin@enron.com', 'sherry.dawson@enron.com', 'Urgent!!! --- New EAST books', 'This has to be done..................................\n\nThanks\n---------------------- Forwarded by Errol McLaughlin/Corp/Enron on 12/20/2000 \n08:39 AM ---------------------------\n   \n\t\n\t\n\tFrom:  William Kelly @ ECT                           12/20/2000 08:31 AM\n\t\n\nTo: Kam Keiser/HOU/ECT@ECT, Darron C Giron/HOU/ECT@ECT, David \nBaumbach/HOU/ECT@ECT, Errol McLaughlin/Corp/Enron@ENRON\ncc: Kimat Singla/HOU/ECT@ECT, Kulvinder Fowler/NA/Enron@ENRON, Kyle R \nLilly/HOU/ECT@ECT, Jeff Royed/Corp/Enron@ENRON, Alejandra \nChavez/NA/Enron@ENRON, Crystal Hyde/HOU/ECT@ECT \n\nSubject: New EAST books\n\nWe have new book names in TAGG for our intramonth portfolios and it is \nextremely important that any deal booked to the East is communicated quickly \nto someone on my team.  I know it will take some time for the new names to \nsink in and I do not want us to miss any positions or P&L.  \n\nThanks for your help on this.\n\nNew:\nScott Neal :         East Northeast\nDick Jenkins:     East Marketeast\n\nWK \n');\nINSERT INTO email([from],[to],subject,body) VALUES('david.forster@enron.com', 'eol.wide@enron.com', 'Change to Stack Manager', 'Effective immediately, there is a change to the Stack Manager which will \naffect any Inactive Child.\n\nAn inactive Child with links to Parent products will not have their \ncalculated prices updated until the Child product is Activated.\n\nWhen the Child Product is activated, the price will be recalculated and \nupdated BEFORE it is displayed on the web.\n\nThis means that if you are inputting a basis price on a Child product, you \nwill not see the final, calculated price until you Activate the product, at \nwhich time the customer will also see it.\n\nIf you have any questions, please contact the Help Desk on:\n\nAmericas: 713 853 4357\nEurope: + 44 (0) 20 7783 7783\nAsia/Australia: +61 2 9229 2300\n\nDave');\nINSERT INTO email([from],[to],subject,body) VALUES('vince.kaminski@enron.com', 'jhh1@email.msn.com', 'Re: Light reading - see pieces beginning on page 7', 'John,\n\nI saw it. Very interesting.\n\nVince\n\n\n\n\n\n\"John H Herbert\" <jhh1@email.msn.com> on 07/28/2000 08:38:08 AM\nTo: \"Vince J Kaminski\" <Vince_J_Kaminski@enron.com>\ncc:  \nSubject: Light reading - see pieces beginning on page 7\n\n\nCheers and have a nice weekend,\n\n\nJHHerbert\n\n\n\n\n - gd000728.pdf\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('matthew.lenhart@enron.com', 'mmmarcantel@equiva.com', 'RE:', 'i will try to line up a pig for you ');\nINSERT INTO email([from],[to],subject,body) VALUES('jae.black@enron.com', 'claudette.harvey@enron.com, chaun.roberts@enron.com, judy.martinez@enron.com,', 'Disaster Recovery Equipment', 'As a reminder...there are several pieces of equipment that are set up on the 30th Floor, as well as on our floor, for the Disaster Recovery Team.  PLEASE DO NOT TAKE, BORROW OR USE this equipment.  Should you need to use another computer system, other than yours, or make conference calls please work with your Assistant to help find or set up equipment for you to use.\n\nThanks for your understanding in this matter.\n\nT.Jae Black\nEast Power Trading\nAssistant to Kevin Presto\noff. 713-853-5800\nfax 713-646-8272\ncell 713-539-4760');\nINSERT INTO email([from],[to],subject,body) VALUES('eric.bass@enron.com', 'dale.neuner@enron.com', '5 X 24', 'Dale,\n\nHave you heard anything more on the 5 X 24s?  We would like to get this \nproduct out ASAP.\n\n\nThanks,\n\nEric');\nINSERT INTO email([from],[to],subject,body) VALUES('messenger@smartreminders.com', 'm..tholt@enron.com', '10% Coupon - PrintPal Printer Cartridges - 100% Guaranteed', '[IMAGE]\n[IMAGE][IMAGE][IMAGE] \nDear  SmartReminders Member,\n       [IMAGE]         [IMAGE]        [IMAGE]     [IMAGE]    [IMAGE]    [IMAGE]        [IMAGE]      [IMAGE]     \t\n\n\n  \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nWe respect  your privacy and are a Certified Participant of the BBBOnLine\n Privacy Program.  To be removed from future offers,click  here. \nSmartReminders.com  is a permission based service. To unsubscribe click  here .  ');\nINSERT INTO email([from],[to],subject,body) VALUES('benjamin.rogers@enron.com', 'mark.bernstein@enron.com', '', 'The guy you are talking about left CIN under a \"cloud of suspicion\" sort of \nspeak.  He was the one who got into several bad deals and PPA''s in California \nfor CIN, thus he left on a bad note.  Let me know if you need more detail \nthan that, I felt this was the type of info you were looking for.  Thanks!\nBen');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'michelle.cash@enron.com', 'Expense Report Receipts Not Received', 'Employee Name: Michelle Cash\nReport Name:   Houston Cellular 8-11-01\nReport Date:   12/13/01\nReport ID:     594D37C9ED2111D5B452\nSubmitted On:  12/13/01\n\nYou are only allowed 2 reports with receipts outstanding.  Your expense reports will not be paid until you meet this requirement.');\nINSERT INTO email([from],[to],subject,body) VALUES('susan.mara@enron.com', 'ray.alvarez@enron.com, mark.palmer@enron.com, karen.denne@enron.com,', 'CAISO Emergency Motion -- to discontinue market-based rates for', 'FYI.  the latest broadside against the generators.\n\nSue Mara\nEnron Corp.\nTel: (415) 782-7802\nFax:(415) 782-7854\n----- Forwarded by Susan J Mara/NA/Enron on 06/08/2001 12:24 PM -----\n\n\n\t\"Milner, Marcie\" <MMilner@coral-energy.com> 06/08/2001 11:13 AM \t   To: \"''smara@enron.com''\" <smara@enron.com>  cc:   Subject: CAISO Emergency Motion\t\n\n\nSue, did you see this emergency motion the CAISO filed today?  Apparently\nthey are requesting that FERC discontinue market-based rates immediately and\ngrant refunds plus interest on the difference between cost-based rates and\nmarket revenues received back to May 2000.  They are requesting the\ncommission act within 14 days.  Have you heard anything about what they are\ndoing?\n\nMarcie\n\nhttp://www.caiso.com/docs/2001/06/08/200106081005526469.pdf \n');\nINSERT INTO email([from],[to],subject,body) VALUES('fletcher.sturm@enron.com', 'eloy.escobar@enron.com', 'Re: General Brinks Position Meeting', 'Eloy,\n\nWho is General Brinks?\n\nFletch');\nINSERT INTO email([from],[to],subject,body) VALUES('nailia.dindarova@enron.com', 'richard.shapiro@enron.com', 'Documents for Mark Frevert (on EU developments and lessons from', 'Rick,\n\nHere are the documents that Peter has prepared for Mark Frevert. \n\nNailia\n---------------------- Forwarded by Nailia Dindarova/LON/ECT on 25/06/2001 \n16:36 ---------------------------\n\n\nNailia Dindarova\n25/06/2001 15:36\nTo: Michael Brown/Enron@EUEnronXGate\ncc: Ross Sankey/Enron@EUEnronXGate, Eric Shaw/ENRON@EUEnronXGate, Peter \nStyles/LON/ECT@ECT \n\nSubject: Documents for Mark Frevert (on EU developments and lessons from \nCalifornia)\n\nMichael,\n\n\nThese are the documents that Peter promised to give to you for Mark Frevert. \nHe has now handed them to him in person but asked me to transmit them \nelectronically to you, as well as Eric and Ross.\n\nNailia\n\n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('peggy.a.kostial@accenture.com', 'dave.samuels@enron.com', 'EOL-Accenture Deal Sheet', 'Dave -\n\nAttached are our comments and suggested changes. Please call to review.\n\nOn the time line for completion, we have four critical steps to complete:\n     Finalize market analysis to refine business case, specifically\n     projected revenue stream\n     Complete counterparty surveying, including targeting 3 CPs for letters\n     of intent\n     Review Enron asset base for potential reuse/ licensing\n     Contract negotiations\n\nJoe will come back to us with an updated time line, but it is my\nexpectation that we are still on the same schedule (we just begun week\nthree) with possibly a week or so slippage.....contract negotiations will\nprobably be the critical path.\n\nWe will send our cut at the actual time line here shortly. Thanks,\n\nPeggy\n\n(See attached file: accenture-dealpoints v2.doc)\n - accenture-dealpoints v2.doc ');\nINSERT INTO email([from],[to],subject,body) VALUES('thomas.martin@enron.com', 'thomas.martin@enron.com', 'Re: Guadalupe Power Partners LP', '---------------------- Forwarded by Thomas A Martin/HOU/ECT on 03/20/2001 \n03:49 PM ---------------------------\n\n\nThomas A Martin\n10/11/2000 03:55 PM\nTo: Patrick Wade/HOU/ECT@ECT\ncc:  \nSubject: Re: Guadalupe Power Partners LP  \n\nThe deal is physically served at Oasis Waha or Oasis Katy and is priced at \neither HSC, Waha or Katytailgate GD at buyers option three days prior to \nNYMEX  close.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('judy.townsend@enron.com', 'dan.junek@enron.com, chris.germany@enron.com', 'Columbia Distribution''s Capacity Available for Release - Sum', '---------------------- Forwarded by Judy Townsend/HOU/ECT on 03/09/2001 11:04 \nAM ---------------------------\n\n\nagoddard@nisource.com on 03/08/2001 09:16:57 AM\nTo: \"        -         *Koch, Kent\" <kkoch@nisource.com>, \"        -         \n*Millar, Debra\" <dmillar@nisource.com>, \"        -         *Burke, Lynn\" \n<lburke@nisource.com>\ncc: \"        -         *Heckathorn, Tom\" <theckathorn@nisource.com> \nSubject: Columbia Distribution''s Capacity Available for Release - Sum\n\n\nAttached is Columbia Distribution''s notice of capacity available for release\nfor\nthe summer of 2001 (Apr. 2001 through Oct. 2001).\n\nPlease note that the deadline for bids is 3:00pm EST on March 20, 2001.\n\nIf you have any questions, feel free to contact any of the representatives\nlisted\nat the bottom of the attachment.\n\nAaron Goddard\n\n\n\n\n - 2001Summer.doc\n');\nINSERT INTO email([from],[to],subject,body) VALUES('rhonda.denton@enron.com', 'tim.belden@enron.com, dana.davis@enron.com, genia.fitzgerald@enron.com,', 'Split Rock Energy LLC', 'We have received the executed EEI contract from this CP dated 12/12/2000.  \nCopies will be distributed to Legal and Credit.');\nINSERT INTO email([from],[to],subject,body) VALUES('kerrymcelroy@dwt.com', 'jack.speer@alcoa.com, crow@millernash.com, michaelearly@earthlink.net,', 'Oral Argument Request', ' - Oral Argument Request.doc');\nINSERT INTO email([from],[to],subject,body) VALUES('mike.carson@enron.com', 'rlmichaelis@hormel.com', '', 'Did you come in town this wk end..... My new number at our house is : \n713-668-3712...... my cell # is 281-381-7332\n\nthe kid');\nINSERT INTO email([from],[to],subject,body) VALUES('cooper.richey@enron.com', 'trycooper@hotmail.com', 'FW: Contact Info', '\n\n-----Original Message-----\nFrom: Punja, Karim \nSent: Thursday, December 13, 2001 2:35 PM\nTo: Richey, Cooper\nSubject: Contact Info\n\n\nCooper,\n\nIts been a real pleasure working with you (even though it was for only a small amount of time)\nI hope we can stay in touch.\n\nHome# 234-0249\nemail: kpunja@hotmail.com\n\nTake Care, \n\nKarim.\n  ');\nINSERT INTO email([from],[to],subject,body) VALUES('bjm30@earthlink.net', 'mcguinn.k@enron.com, mcguinn.ian@enron.com, mcguinn.stephen@enron.com,', 'email address change', 'Hello all.\n\nI haven''t talked to many of you via email recently but I do want to give you\nmy new address for your email file:\n\n    bjm30@earthlink.net\n\nI hope all is well.\n\nBrian McGuinn');\nINSERT INTO email([from],[to],subject,body) VALUES('shelley.corman@enron.com', 'steve.hotte@enron.com', 'Flat Panels', 'Can you please advise what is going on with the flat panels that we had planned to distribute to our gas logistics team.  It was in the budget and we had the okay, but now I''m hearing there is some hold-up & the units are stored on 44.\n\nShelley');\nINSERT INTO email([from],[to],subject,body) VALUES('sara.davidson@enron.com', 'john.schwartzenburg@enron.com, scott.dieball@enron.com, recipients@enron.com,', '2001 Enron Law Conference (Distribution List 2)', '    Enron Law Conference\n\nSan Antonio, Texas    May 2-4, 2001    Westin Riverwalk\n\n                   See attached memo for more details!!\n\n\n? Registration for the law conference this year will be handled through an \nOnline RSVP Form on the Enron Law Conference Website at \nhttp://lawconference.corp.enron.com.  The website is still under construction \nand will not be available until Thursday, March 15, 2001.  \n\n? We will send you another e-mail to confirm when the Law Conference Website \nis operational. \n\n? Please complete the Online RSVP Form as soon as it is available  and submit \nit no later than Friday, March 30th.  \n\n\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('tori.kuykendall@enron.com', 'heath.b.taylor@accenture.com', 'Re:', 'hey - thats funny about john - he definitely remembers him - i''ll call pat \nand let him know - we are coming on saturday - i just havent had a chance to \ncall you guys back --  looking forward to it -- i probably need the \ndirections again though');\nINSERT INTO email([from],[to],subject,body) VALUES('darron.giron@enron.com', 'bryce.baxter@enron.com', 'Re: Feedback for Audrey Cook', 'Bryce,\n\nI''ll get it done today.  \n\nDG    3-9573\n\n\n   \n\t\n\t\n\tFrom:  Bryce Baxter                           06/12/2000 07:15 PM\n\t\n\nTo: Darron C Giron/HOU/ECT@ECT\ncc:  \nSubject: Feedback for Audrey Cook\n\nYou were identified as a reviewer for Audrey Cook.  If possible, could you \ncomplete her feedback by end of business Wednesday?  It will really help me \nin the PRC process to have your input.  Thanks.\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('casey.evans@enron.com', 'stephanie.sever@enron.com', 'Gas EOL ID', 'Stephanie,\n\nIn conjunction with the recent movement of several power traders, they are changing the names of their gas books as well.  The names of the new gas books and traders are as follows:\n\nPWR-NG-LT-SPP:  Mike Carson\nPWR-NG-LT-SERC:  Jeff King\n\nIf you need to know their power desk to map their ID to their gas books, those desks are as follows:\n\nEPMI-LT-SPP:  Mike Carson\nEPMI-LT-SERC:  Jeff King\n\nI will be in training this afternoon, but will be back when class is over.  Let me know if you have any questions.\n\nThanks for your help!\nCasey');\nINSERT INTO email([from],[to],subject,body) VALUES('darrell.schoolcraft@enron.com', 'david.roensch@enron.com, kimberly.watson@enron.com, michelle.lokay@enron.com,', 'Postings', 'Please see the attached.\n\n\nds\n\n\n  \n\n ');\nINSERT INTO email([from],[to],subject,body) VALUES('mcominsky@aol.com', 'cpatman@bracepatt.com, james_derrick@enron.com', 'Jurisprudence Luncheon', 'Carrin & Jim --\n\nIt was an honor and a pleasure to meet both of you yesterday.  I know we will\nhave fun working together on this very special event.\n\nJeff left the jurisprudence luncheon lists for me before he left on vacation.\n I wasn''t sure whether he transmitted them to you as well.  Would you please\nadvise me if you would like them sent to you?  I can email the MS Excel files\nor I can fax the hard copies to you.   Please advise what is most convenient.\n\nI plan to be in town through the holidays and can be reached by phone, email,\nor cell phone at any time.  My cell phone number is 713/705-4829.\n\nThanks again for your interest in the ADL''s work.  Martin.\n\nMartin B. Cominsky\nDirector, Southwest Region\nAnti-Defamation League\n713/627-3490, ext. 122\n713/627-2011 (fax)\nMCominsky@aol.com');\nINSERT INTO email([from],[to],subject,body) VALUES('phillip.love@enron.com', 'todagost@utmb.edu, gbsonnta@utmb.edu', 'New President', 'I had a little bird put a word in my ear.  Is there any possibility for Ben \nRaimer to be Bush''s secretary of HHS?  Just curious about that infamous UTMB \nrumor mill.  Hope things are well, happy holidays.\nPL');\nINSERT INTO email([from],[to],subject,body) VALUES('marie.heard@enron.com', 'ehamilton@fna.com', 'ISDA Master Agreement', 'Erin:\n\nPursuant to your request, attached are the Schedule to the ISDA Master Agreement, together with Paragraph 13 to the ISDA Credit Support Annex.  Please let me know if you need anything else.  We look forward to hearing your comments.\n\nMarie\n\nMarie Heard\nSenior Legal Specialist\nEnron North America Corp.\nPhone:  (713) 853-3907\nFax:  (713) 646-3490\nmarie.heard@enron.com\n\n\t\t\t\t ');\nINSERT INTO email([from],[to],subject,body) VALUES('andrea.ring@enron.com', 'beverly.beaty@enron.com', 'Re: Tennessee Buy - Louis Dreyfus', 'Beverly -  once again thanks so much for your help on this.\n\n           \n\n                                                                     ');\nINSERT INTO email([from],[to],subject,body) VALUES('karolyn.criado@enron.com', 'j..bonin@enron.com, felicia.case@enron.com, b..clapp@enron.com,', 'Price List week of Oct. 8-9, 2001', '\nPlease contact me if you have any questions regarding last weeks prices.\n\nThank you,\nKarolyn Criado\n3-9441\n\n\n \n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.presto@enron.com', 'edward.baughman@enron.com, billy.braddock@enron.com', 'Associated', 'Please begin working on filling our Associated short position in 02.   I would like to take this risk off the books.\n\nIn addition, please find out what a buy-out of VEPCO would cost us.   With Rogers transitioning to run our retail risk management, I would like to clean up our customer positions.\n\nWe also need to continue to explore a JEA buy-out.\n\nThanks.');\nINSERT INTO email([from],[to],subject,body) VALUES('stacy.dickson@enron.com', 'gregg.penman@enron.com', 'RE: Constellation TC 5-7-01', 'Gregg, \n\nI am at home with a sick baby.  (Lots of fun!)  I will call you about this \ntomorrow.\n\nStacy');\nINSERT INTO email([from],[to],subject,body) VALUES('joe.quenet@enron.com', 'dfincher@utilicorp.com', '', 'hey big guy.....check this out.....\n\n w ww.gorelieberman-2000.com/');\nINSERT INTO email([from],[to],subject,body) VALUES('k..allen@enron.com', 'jacqestc@aol.com', '', 'Jacques,\n\nI sent you a fax of Kevin Kolb''s comments on the release.  The payoff on the note would be $36,248 ($36090(principal) + $158 (accrued interest)).\nThis is assuming we wrap this up on Tuesday.  \n\nPlease email to confirm that their changes are ok so I can set up a meeting on Tuesday to reach closure.\n\nPhillip');\nINSERT INTO email([from],[to],subject,body) VALUES('kourtney.nelson@enron.com', 'mike.swerzbin@enron.com', 'Adjusted L/R Balance', 'Mike,\n\nI placed the adjusted L/R Balance on the Enronwest site.  It is under the \"Staff/Kourtney Nelson\".  There are two links:  \n\n1)  \"Adj L_R\" is the same data/format from the weekly strategy meeting. \n2)  \"New Gen 2001_2002\" link has all of the supply side info that is used to calculate the L/R balance\n\t-Please note the Data Flag column, a value of \"3\" indicates the project was cancelled, on hold, etc and is not included in the calc.  \n\nBoth of these sheets are interactive Excel spreadsheets and thus you can play around with the data as you please.  Also, James Bruce is working to get his gen report on the web.  That will help with your access to information on new gen.\n\nPlease let me know if you have any questions or feedback,\n\nKourtney\n\n\n\nKourtney Nelson\nFundamental Analysis \nEnron North America\n(503) 464-8280\nkourtney.nelson@enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('d..thomas@enron.com', 'naveed.ahmed@enron.com', 'FW: Current Enron TCC Portfolio', '\n\n-----Original Message-----\nFrom: Grace, Rebecca M. \nSent: Monday, December 17, 2001 9:44 AM\nTo: Thomas, Paul D.\nCc: Cashion, Jim; Allen, Thresa A.; May, Tom\nSubject: RE: Current Enron TCC Portfolio\n\n\nPaul,\n\nI reviewed NY''s list.  I agree with all of their contracts numbers and mw amounts.\n\nCall if you have any more questions.\n\nRebecca\n\n\n\n -----Original Message-----\nFrom: \tThomas, Paul D.  \nSent:\tMonday, December 17, 2001 9:08 AM\nTo:\tGrace, Rebecca M.\nSubject:\tFW: Current Enron TCC Portfolio\n\n << File: enrontccs.xls >> \nRebecca,\nLet me know if you see any differences.\n\nPaul\nX 3-0403\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Monday, December 17, 2001 9:04 AM\nTo: Ahmed, Naveed\nSubject: FW: Current Enron TCC Portfolio\n\n\n\n\n-----Original Message-----\nFrom: Thomas, Paul D. \nSent: Thursday, December 13, 2001 10:01 AM\nTo: Baughman, Edward D.\nSubject: Current Enron TCC Portfolio\n\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('stephanie.panus@enron.com', 'william.bradford@enron.com, debbie.brackett@enron.com,', 'Coastal Merchant Energy/El Paso Merchant Energy', 'Coastal Merchant Energy, L.P. merged with and into El Paso Merchant Energy, \nL.P., effective February 1, 2001, with the surviving entity being El Paso \nMerchant Energy, L.P.  We currently have ISDA Master Agreements with both \ncounterparties.  Please see the attached memo regarding the existing Masters \nand let us know which agreement should be terminated.\n\nThanks,\nStephanie\n');\nINSERT INTO email([from],[to],subject,body) VALUES('kam.keiser@enron.com', 'c..kenne@enron.com', 'RE: What about this too???', ' \n\n -----Original Message-----\nFrom: \tKenne, Dawn C.  \nSent:\tWednesday, February 06, 2002 11:50 AM\nTo:\tKeiser, Kam\nSubject:\tWhat about this too???\n\n\n << File: Netco Trader Matrix.xls >> \n ');\nINSERT INTO email([from],[to],subject,body) VALUES('chris.meyer@enron.com', 'joe.parks@enron.com', 'Centana', 'Talked to Chip.  We do need Cash Committe approval given the netting feature of your deal, which means Batch Funding Request.  Please update per my previous e-mail and forward.\n\nThanks\n\nchris\nx31666');\nINSERT INTO email([from],[to],subject,body) VALUES('debra.perlingiere@enron.com', 'jworman@academyofhealth.com', '', 'Have a great weekend!   Happy Fathers Day!\n\n\nDebra Perlingiere\nEnron North America Corp.\n1400 Smith Street, EB 3885\nHouston, Texas 77002\ndperlin@enron.com\nPhone 713-853-7658\nFax  713-646-3490');\nINSERT INTO email([from],[to],subject,body) VALUES('outlook.team@enron.com', '', 'Demo by Martha Janousek of Dashboard & Pipeline Profile / Julia  &', 'CALENDAR ENTRY:\tAPPOINTMENT\n\nDescription:\n\tDemo by Martha Janousek of Dashboard & Pipeline Profile / Julia  & Dir Rpts. - 4102\n\nDate:\t\t1/5/2001\nTime:\t\t9:00 AM - 10:00 AM (Central Standard Time)\n\nChairperson:\tOutlook Migration Team\n\nDetailed Description:');\nINSERT INTO email([from],[to],subject,body) VALUES('diana.seifert@enron.com', 'mark.taylor@enron.com', 'Guest access Chile', 'Hello Mark,\n\nJustin Boyd told me that your can help me with questions regarding Chile.\nWe got a request for guest access through MG.\nThe company is called Escondida and is a subsidiary of BHP Australia.\n\nPlease advise if I can set up a guest account or not.\nF.Y.I.: MG is planning to put a \"in w/h Chile\" contract for Copper on-line as \nsoon as Enron has done the due diligence for this country.\nThanks !\n\n\nBest regards\n\nDiana Seifert\nEOL PCG');\nINSERT INTO email([from],[to],subject,body) VALUES('enron_update@concureworkplace.com', 'mark.whitt@enron.com', '<<Concur Expense Document>> - 121001', 'The Approval status has changed on the following report:\n\nStatus last changed by: Barry L. Tycholiz\nExpense Report Name: 121001\nReport Total: $198.98\nAmount Due Employee: $198.98\nAmount Approved: $198.98\nAmount Paid: $0.00\nApproval Status: Approved\nPayment Status: Pending\n\n\nTo review this expense report, click on the following link for Concur Expense.\nhttp://expensexms.enron.com');\nINSERT INTO email([from],[to],subject,body) VALUES('kevin.hyatt@enron.com', '', 'Technical Support', 'Outside the U.S., please refer to the list below:\n\nAustralia:\n1800 678-515\nsupport@palm-au.com\n\nCanada:\n1905 305-6530\nsupport@palm.com\n\nNew Zealand:\n0800 446-398\nsupport@palm-nz.com\n\nU.K.:\n0171 867 0108\neurosupport@palm.3com.com\n\nPlease refer to the Worldwide Customer Support card for a complete technical support contact list.');\nINSERT INTO email([from],[to],subject,body) VALUES('geoff.storey@enron.com', 'dutch.quigley@enron.com', 'RE:', 'duke contact?\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 10:14 AM\nTo:\tStorey, Geoff\nSubject:\tRE: \n\nbp corp\tAlbert LaMore\t281-366-4962\n\nrunning the reports now\n\n\n -----Original Message-----\nFrom: \tStorey, Geoff  \nSent:\tWednesday, October 31, 2001 10:10 AM\nTo:\tQuigley, Dutch\nSubject:\tRE: \n\ngive me a contact over there too\nBP\n\n\n -----Original Message-----\nFrom: \tQuigley, Dutch  \nSent:\tWednesday, October 31, 2001 9:42 AM\nTo:\tStorey, Geoff\nSubject:\t\n\nCoral\tJeff Whitnah\t713-767-5374\nRelaint\tSteve McGinn\t713-207-4000');\nINSERT INTO email([from],[to],subject,body) VALUES('pete.davis@enron.com', 'pete.davis@enron.com', 'Start Date: 4/22/01; HourAhead hour: 3;  <CODESITE>', 'Start Date: 4/22/01; HourAhead hour: 3;  No ancillary schedules awarded.  \nVariances detected.\nVariances detected in Load schedule.\n\n    LOG MESSAGES:\n\nPARSING FILE -->> O:\\Portland\\WestDesk\\California Scheduling\\ISO Final \nSchedules\\2001042203.txt\n\n---- Load Schedule ----\n$$$ Variance found in table tblLoads.\n     Details: (Hour: 3 / Preferred:   1.92 / Final:   1.89)\n  TRANS_TYPE: FINAL\n  LOAD_ID: PGE4\n  MKT_TYPE: 2\n  TRANS_DATE: 4/22/01\n  SC_ID: EPMI\n\n');\nINSERT INTO email([from],[to],subject,body) VALUES('john.postlethwaite@enron.com', 'john.zufferli@enron.com', 'Reference', 'John, hope things are going well up there for you. The big day is almost here for you and Jessica. I was wondering if I could use your name as a job reference if need be. I am just trying to get everything in order just in case something happens. \n\nJohn');\nINSERT INTO email([from],[to],subject,body) VALUES('jeffrey.shankman@enron.com', 'lschiffm@jonesday.com', 'Re:', 'I saw you called on the cell this a.m.  Sorry I missed you.  (I was in the \nshower).  I have had a shitty week--I suspect my silence (not only to you, \nbut others) after our phone call is a result of the week.  I''m seeing Glen at \n11:15....talk to you');\nINSERT INTO email([from],[to],subject,body) VALUES('litebytz@enron.com', '', 'Lite Bytz RSVP', '\nThis week''s Lite Bytz presentation will feature the following TOOLZ speaker:\n\nRichard McDougall\nSolaris 8\nThursday, June 7, 2001\n\nIf you have not already signed up, please RSVP via email to litebytz@enron.com by the end of the day Tuesday, June 5, 2001.\n\n*Remember: this is now a Brown Bag Event--so bring your lunch and we will provide cookies and drinks.\n\nClick below for more details.\n\nhttp://home.enron.com:84/messaging/litebytztoolzprint.jpg');\n    COMMIT;\n  }\n} {}\n\n###############################################################################\n# Everything above just builds an interesting test database.  The actual\n# tests come after this comment.\n###############################################################################\n\ndo_test fts3ac-1.2 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark'\n  }\n} {6 17 25 38 40 42 73 74}\ndo_test fts3ac-1.3 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan'\n  }\n} {24 40}\ndo_test fts3ac-1.4 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark susan'\n  }\n} {40}\ndo_test fts3ac-1.5 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'susan mark'\n  }\n} {40}\ndo_test fts3ac-1.6 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '\"mark susan\"'\n  }\n} {}\ndo_test fts3ac-1.7 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark -susan'\n  }\n} {6 17 25 38 42 73 74}\ndo_test fts3ac-1.8 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH '-mark susan'\n  }\n} {24}\ndo_test fts3ac-1.9 {\n  execsql {\n    SELECT rowid FROM email WHERE email MATCH 'mark OR susan'\n  }\n} {6 17 24 25 38 40 42 73 74}\n\n# Some simple tests of the automatic \"offsets(email)\" column.  In the sample\n# data set above, only one message, number 20, contains the words\n# \"gas\" and \"reminder\" in both body and subject.\n#\ndo_test fts3ac-2.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts3ac-2.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8 3 1 54 8}}\ndo_test fts3ac-2.3 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE email MATCH 'body:gas reminder'\n  }\n} {20 {2 1 54 8 3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\ndo_test fts3ac-2.4 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE subject MATCH 'gas reminder'\n  }\n} {20 {2 0 42 3 2 1 54 8}}\ndo_test fts3ac-2.5 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'gas reminder'\n  }\n} {20 {3 0 42 3 3 1 54 8 3 0 129 3 3 0 143 3 3 0 240 3}}\n\n# Document 32 contains 5 instances of the world \"child\".  But only\n# 3 of them are paired with \"product\".  Make sure only those instances\n# that match the phrase appear in the offsets(email) list.\n#\ndo_test fts3ac-3.1 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH 'child product' AND +rowid=32\n  }\n} {32 {3 0 94 5 3 0 114 5 3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7 3 1 493 7}}\ndo_test fts3ac-3.2 {\n  execsql {\n    SELECT rowid, offsets(email) FROM email\n     WHERE body MATCH '\"child product\"'\n  }\n} {32 {3 0 207 5 3 1 213 7 3 0 245 5 3 1 251 7 3 0 409 5 3 1 415 7}}\n\n# Snippet generator tests\n#\ndo_test fts3ac-4.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'subject:gas reminder'\n  }\n} {{Alert Posted 10:00 AM November 20,2000: E-<b>GAS</b> Request <b>Reminder</b>}}\ndo_test fts3ac-4.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'christmas candlelight'\n  }\n} {{<b>...</b>here <b>Christmas</b> \neve?? They have an 11:00 a.m. service and a <b>candlelight</b> service<b>...</b>}}\n\ndo_test fts3ac-4.3 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <b>Deal</b> <b>Sheet</b><b>...</b>asset base for <b>potential</b> <b>reuse</b>/ licensing\n     Contract negotiations<b>...</b>}}\ndo_test fts3ac-4.4 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'deal sheet potential reuse'\n  }\n} {{EOL-Accenture <<<Deal>>> <<<Sheet>>> asset base for <<<potential>>> <<<reuse>>>/ licensing\n     Contract negotiations }}\ndo_test fts3ac-4.5 {\n  execsql {\n    SELECT snippet(email,'<<<','>>>',' ') FROM email\n     WHERE email MATCH 'first things'\n  }\n} {{Re: <<<First>>> Polish Deal! Congrats!  <<<Things>>> seem to be building rapidly now }}\ndo_test fts3ac-4.6 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'chris is here'\n  }\n} {{<b>...</b><b>chris</b>.germany@enron.com'\" <<b>chris</b><b>...</b>bet this <b>is</b> next to<b>...</b>about going <b>here</b> Christmas \neve<b>...</b>}}\ndo_test fts3ac-4.7 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH '\"pursuant to\"'\n  }\n} {{Erin:\n\n<b>Pursuant</b> <b>to</b> your request, attached are the Schedule to the ISDA Master Agreement, together<b>...</b>}}\ndo_test fts3ac-4.8 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'ancillary load davis'\n  }\n} {{pete.<b>davis</b>@enron.com<b>...</b>3;  No <b>ancillary</b> schedules awarded<b>...</b>detected in <b>Load</b> schedule.\n\n    LOG<b>...</b>}}\n\n# Combinations of AND and OR operators:\n#\ndo_test fts3ac-5.1 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'questar enron OR com'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies<b>...</b>}}\n\ndo_test fts3ac-5.2 {\n  execsql {\n    SELECT snippet(email) FROM email\n     WHERE email MATCH 'enron OR com questar'\n  }\n} {{matt.smith@<b>enron</b>.<b>com</b><b>...</b>31 Keystone Receipts\n15 <b>Questar</b> Pipeline\n40 Rockies<b>...</b>}}\n\n#-------------------------------------------------------------------------\n# Test a problem reported on the mailing list.\n#\ndo_test fts3ac-6.1 {\n  execsql {\n    CREATE VIRTUAL TABLE ft USING fts3(one, two);\n    INSERT INTO ft VALUES('', 'foo');\n    INSERT INTO ft VALUES('foo', 'foo');\n    SELECT offsets(ft) FROM ft WHERE ft MATCH 'foo';\n  }\n} {{1 0 0 3} {0 0 0 3 1 0 0 3}}\ndo_test fts3ac-6.2 {\n  execsql {\n    DELETE FROM ft WHERE one = 'foo';\n    SELECT offsets(ft) FROM ft WHERE ft MATCH 'foo';\n  }\n} {{1 0 0 3}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ad.test",
    "content": "# 2006 October 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module, and in particular\n# the Porter stemmer.\n#\n# $Id: fts3ad.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_test fts3ad-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts3ad-1.2 {\n  execsql {\n    SELECT snippet(t1) FROM t1 WHERE t1 MATCH 'run jump';\n  }\n} {{<b>running</b> and <b>jumping</b>}}\ndo_test fts3ad-1.3 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(2, 'abcdefghijklmnopqrstuvwyxz');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts3ad-1.4 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH 'abcdefghijXXXXqrstuvwyxz'\n  }\n} {2 <b>abcdefghijklmnopqrstuvwyxz</b>}\ndo_test fts3ad-1.5 {\n  execsql {\n    INSERT INTO t1(rowid, content) \n          VALUES(3, 'The value is 123456789');\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123789'\n  }\n} {3 {The value is <b>123456789</b>}}\ndo_test fts3ad-1.6 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE t1 MATCH '123000000789'\n  }\n} {3 {The value is <b>123456789</b>}}\n\ndo_test fts3ad-2.1 {\n  execsql {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize    porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts3ad-2.2 {\n  execsql {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize=   porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts3ad-2.3 {\n  execsql {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize=   simple);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {}\ndo_test fts3ad-2.4 {\n  execsql {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(content,   tokenize=   porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\ndo_test fts3ad-2.5 {\n  execsql {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(content,\t   tokenize =   porter);\n    INSERT INTO t1(rowid, content) VALUES(1, 'running and jumping');\n    SELECT rowid FROM t1 WHERE content MATCH 'run jump';\n  }\n} {1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ae.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing deletions in the FTS3 module.\n#\n# $Id: fts3ae.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 30 INSERT and\n# DELETE statements, so that we'll test both the segmentMerge() merge\n# (over the first 16) and the termSelect() merge (over the level-1\n# segment and 14 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  DELETE FROM t1 WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  DELETE FROM t1 WHERE rowid = 22;\n}\n\ndo_test fts3ae-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {14}\n\ndo_test fts3ae-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {3 5 9 11 15 17 21}\n\ndo_test fts3ae-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 11 14 15 18}\n\ndo_test fts3ae-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {5 6 12 14 15 20 21}\n\ndo_test fts3ae-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {8 9 11 12 14 15}\n\ndo_test fts3ae-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {17 18 20 21}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3af.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing updates in the FTS3 module.\n#\n# $Id: fts3af.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Construct a full-text search table containing keywords which are the\n# ordinal numbers of the bit positions set for a sequence of integers,\n# which are used for the rowid.  There are a total of 31 INSERT,\n# UPDATE, and DELETE statements, so that we'll test both the\n# segmentMerge() merge (over the first 16) and the termSelect() merge\n# (over the level-1 segment and 15 level-0 segments).\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'one');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'two');\n  INSERT INTO t1 (rowid, content) VALUES(3, 'one two');\n  INSERT INTO t1 (rowid, content) VALUES(4, 'three');\n  INSERT INTO t1 (rowid, content) VALUES(5, 'one three');\n  INSERT INTO t1 (rowid, content) VALUES(6, 'two three');\n  INSERT INTO t1 (rowid, content) VALUES(7, 'one two three');\n  DELETE FROM t1 WHERE rowid = 4;\n  INSERT INTO t1 (rowid, content) VALUES(8, 'four');\n  UPDATE t1 SET content = 'update one three' WHERE rowid = 1;\n  INSERT INTO t1 (rowid, content) VALUES(9, 'one four');\n  INSERT INTO t1 (rowid, content) VALUES(10, 'two four');\n  DELETE FROM t1 WHERE rowid = 7;\n  INSERT INTO t1 (rowid, content) VALUES(11, 'one two four');\n  INSERT INTO t1 (rowid, content) VALUES(12, 'three four');\n  INSERT INTO t1 (rowid, content) VALUES(13, 'one three four');\n  DELETE FROM t1 WHERE rowid = 10;\n  INSERT INTO t1 (rowid, content) VALUES(14, 'two three four');\n  INSERT INTO t1 (rowid, content) VALUES(15, 'one two three four');\n  UPDATE t1 SET content = 'update two five' WHERE rowid = 8;\n  INSERT INTO t1 (rowid, content) VALUES(16, 'five');\n  DELETE FROM t1 WHERE rowid = 13;\n  INSERT INTO t1 (rowid, content) VALUES(17, 'one five');\n  INSERT INTO t1 (rowid, content) VALUES(18, 'two five');\n  INSERT INTO t1 (rowid, content) VALUES(19, 'one two five');\n  DELETE FROM t1 WHERE rowid = 16;\n  INSERT INTO t1 (rowid, content) VALUES(20, 'three five');\n  INSERT INTO t1 (rowid, content) VALUES(21, 'one three five');\n  INSERT INTO t1 (rowid, content) VALUES(22, 'two three five');\n  DELETE FROM t1 WHERE rowid = 19;\n  UPDATE t1 SET content = 'update' WHERE rowid = 15;\n}\n\ndo_test fts3af-1.1 {\n  execsql {SELECT COUNT(*) FROM t1}\n} {16}\n\ndo_test fts3af-2.0 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'update'}\n} {1 8 15}\n\ndo_test fts3af-2.1 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'one'}\n} {1 3 5 9 11 17 21}\n\ndo_test fts3af-2.2 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'two'}\n} {2 3 6 8 11 14 18 22}\n\ndo_test fts3af-2.3 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'three'}\n} {1 5 6 12 14 20 21 22}\n\ndo_test fts3af-2.4 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'four'}\n} {9 11 12 14}\n\ndo_test fts3af-2.5 {\n  execsql {SELECT rowid FROM t1 WHERE content MATCH 'five'}\n} {8 17 18 20 21 22}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ag.test",
    "content": "# 2006 October 19\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing handling of edge cases for various doclist\n# merging functions in the FTS3 module query logic.\n#\n# $Id: fts3ag.test,v 1.2 2007/11/16 00:23:08 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, 'this is a test');\n  INSERT INTO t1 (rowid, content) VALUES(2, 'also a test');\n}\n\n# No hits at all.  Returns empty doclists from termSelect().\ndo_test fts3ag-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}\n} {}\n\n# Empty left in docListExceptMerge().\ndo_test fts3ag-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this something'}\n} {}\n\n# Empty right in docListExceptMerge().\ndo_test fts3ag-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this -something'}\n} {1}\n\n# Empty left in docListPhraseMerge().\ndo_test fts3ag-1.4 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"this something\"'}\n} {}\n\n# Empty right in docListPhraseMerge().\ndo_test fts3ag-1.5 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH '\"something is\"'}\n} {}\n\n# Empty left in docListOrMerge().\ndo_test fts3ag-1.6 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR this'}\n} {1}\n\n# Empty right in docListOrMerge().\ndo_test fts3ag-1.7 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR something'}\n} {1}\n\n# Empty left in docListAndMerge().\ndo_test fts3ag-1.8 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something this'}\n} {}\n\n# Empty right in docListAndMerge().\ndo_test fts3ag-1.9 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this something'}\n} {}\n\n# No support for all-except queries.\ndo_test fts3ag-1.10 {\n  catchsql {SELECT rowid FROM t1 WHERE t1 MATCH '-this -something'}\n} {1 {malformed MATCH expression: [-this -something]}}\n\n# Test that docListOrMerge() correctly handles reaching the end of one\n# doclist before it reaches the end of the other.\ndo_test fts3ag-1.11 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'this OR also'}\n} {1 2}\ndo_test fts3ag-1.12 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'also OR this'}\n} {1 2}\n\n# Empty left and right in docListOrMerge().  Each term matches neither\n# row, and when combined there was an assertion failure.\ndo_test fts3ag-1.13 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something OR nothing'}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ah.test",
    "content": "# 2006 October 31 \n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# here is testing correct handling of very long terms.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Generate a document of bigterms based on characters from the list\n# chars.\nproc bigtermdoc {chars len} {\n  set doc \"\"\n  foreach char $chars {\n    append doc \" \" [string repeat $char $len]\n  }\n  return $doc\n}\n\nset len 5000\nset doc1 [bigtermdoc {a b c d} $len]\nset doc2 [bigtermdoc {b d e f} $len]\nset doc3 [bigtermdoc {a c e} $len]\n\nset aterm [string repeat a $len]\nset bterm [string repeat b $len]\nset xterm [string repeat x $len]\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, $doc1);\n  INSERT INTO t1 (rowid, content) VALUES(2, $doc2);\n  INSERT INTO t1 (rowid, content) VALUES(3, $doc3);\n}\n\n# No hits at all.  Returns empty doclists from termSelect().\ndo_test fts3ah-1.1 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'something'}\n} {}\n\ndo_test fts3ah-1.2 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $aterm}\n} {1 3}\n\ndo_test fts3ah-1.3 {\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH $xterm}\n} {}\n\ndo_test fts3ah-1.4 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '$aterm -$xterm'\"\n} {1 3}\n\ndo_test fts3ah-1.5 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"$aterm $bterm\\\"'\"\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ai.test",
    "content": "# 2007 January 17\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite fts3 library.  The\n# focus here is testing handling of UPDATE when using UTF-16-encoded\n# databases.\n#\n# $Id: fts3ai.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nifcapable !utf16 {\n  finish_test\n  return\n}\n\n# Return the UTF-16 representation of the supplied UTF-8 string $str.\n# If $nt is true, append two 0x00 bytes as a nul terminator.\n# NOTE(shess) Copied from capi3.test.\nproc utf16 {str {nt 1}} {\n  set r [encoding convertto unicode $str]\n  if {$nt} {\n    append r \"\\x00\\x00\"\n  }\n  return $r\n}\n\ndb eval {\n  PRAGMA encoding = \"UTF-16le\";\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n}\n\ndo_test fts3ai-1.0 {\n  execsql {PRAGMA encoding}\n} {UTF-16le}\n\ndo_test fts3ai-1.1 {\n  execsql {INSERT INTO t1 (rowid, content) VALUES(1, 'one')}\n  execsql {SELECT content FROM t1 WHERE rowid = 1}\n} {one}\n\ndo_test fts3ai-1.2 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(2, 'two')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 2}\n} {two}\n\ndo_test fts3ai-1.3 {\n  set sql \"INSERT INTO t1 (rowid, content) VALUES(3, 'three')\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'trois' WHERE rowid = 3\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 3}\n} {trois}\n\ndo_test fts3ai-1.4 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(4, 'four')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 4}\n} {four}\n\ndo_test fts3ai-1.5 {\n  set sql16 [utf16 {INSERT INTO t1 (rowid, content) VALUES(5, 'five')}]\n  set STMT [sqlite3_prepare16 $DB $sql16 -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  set sql \"UPDATE t1 SET content = 'cinq' WHERE rowid = 5\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n  sqlite3_finalize $STMT\n  execsql {SELECT content FROM t1 WHERE rowid = 5}\n} {cinq}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3aj.test",
    "content": "# 2007 February 6\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  This\n# tests creating fts3 tables in an attached database.\n#\n# $Id: fts3aj.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Clean up anything left over from a previous pass.\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db2 test2.db\n\ndb eval {\n  CREATE VIRTUAL TABLE t3 USING fts3(content);\n  INSERT INTO t3 (rowid, content) VALUES(1, \"hello world\");\n}\n\ndb2 eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, \"hello world\");\n  INSERT INTO t1 (rowid, content) VALUES(2, \"hello there\");\n  INSERT INTO t1 (rowid, content) VALUES(3, \"cruel world\");\n}\n\n# This has always worked because the t1_* tables used by fts3 will be\n# the defaults.\ndo_test fts3aj-1.1 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\n# Make certain we're detached if there was an error.\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this appears to work fine, but the t2_* tables used\n# by fts3 will be created in database 'main' instead of database\n# 'two'.  It appears to work fine because the tables end up being the\n# defaults, but obviously is badly broken if you hope to use things\n# other than in the exact same ATTACH setup.\ndo_test fts3aj-1.2 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n    CREATE VIRTUAL TABLE two.t2 USING fts3(content);\n    INSERT INTO t2 (rowid, content) VALUES(1, \"hello world\");\n    INSERT INTO t2 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO t2 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM t2 WHERE t2 MATCH 'hello';\n    DETACH DATABASE two;\n  }\n} {1 2}\ncatch {db eval {DETACH DATABASE two}}\n\n# In older code, this broke because the fts3 code attempted to create\n# t3_* tables in database 'main', but they already existed.  Normally\n# this wouldn't happen without t3 itself existing, in which case the\n# fts3 code would never be called in the first place.\ndo_test fts3aj-1.3 {\n  execsql {\n    ATTACH DATABASE 'test2.db' AS two;\n\n    CREATE VIRTUAL TABLE two.t3 USING fts3(content);\n    INSERT INTO two.t3 (rowid, content) VALUES(2, \"hello there\");\n    INSERT INTO two.t3 (rowid, content) VALUES(3, \"cruel world\");\n    SELECT rowid FROM two.t3 WHERE t3 MATCH 'hello';\n\n    DETACH DATABASE two;\n  } db2\n} {2}\ncatch {db eval {DETACH DATABASE two}}\n\ncatch {db2 close}\nforcedelete test2.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ak.test",
    "content": "# 2007 March 9\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  These\n# make sure that fts3 insertion buffering is fully transparent when\n# using transactions.\n#\n# $Id: fts3ak.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1 (rowid, content) VALUES(1, \"hello world\");\n  INSERT INTO t1 (rowid, content) VALUES(2, \"hello there\");\n  INSERT INTO t1 (rowid, content) VALUES(3, \"cruel world\");\n}\n\n# Test that possibly-buffered inserts went through after commit.\ndo_test fts3ak-1.1 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(4, \"false world\");\n    INSERT INTO t1 (rowid, content) VALUES(5, \"false door\");\n    COMMIT TRANSACTION;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4}\n\n# Test that buffered inserts are seen by selects in the same\n# transaction.\ndo_test fts3ak-1.2 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(6, \"another world\");\n    INSERT INTO t1 (rowid, content) VALUES(7, \"another test\");\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n    COMMIT TRANSACTION;\n  }\n} {1 3 4 6}\n\n# Test that buffered inserts are seen within a transaction.  This is\n# really the same test as 1.2.\ndo_test fts3ak-1.3 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(8, \"second world\");\n    INSERT INTO t1 (rowid, content) VALUES(9, \"second sight\");\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n    ROLLBACK TRANSACTION;\n  }\n} {1 3 4 6 8}\n\n# Double-check that the previous result doesn't persist past the\n# rollback!\ndo_test fts3ak-1.4 {\n  execsql {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4 6}\n\n# Test it all together.\ndo_test fts3ak-1.5 {\n  execsql {\n    BEGIN TRANSACTION;\n    INSERT INTO t1 (rowid, content) VALUES(10, \"second world\");\n    INSERT INTO t1 (rowid, content) VALUES(11, \"second sight\");\n    ROLLBACK TRANSACTION;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n  }\n} {1 3 4 6}\n\n# Test that the obvious case works.\ndo_test fts3ak-1.6 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 (rowid, content) VALUES(12, \"third world\");\n    COMMIT;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'third';\n  }\n} {12}\n\n# This is exactly the same as the previous test, except that older\n# code loses the INSERT due to an SQLITE_SCHEMA error.\ndo_test fts3ak-1.7 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 (rowid, content) VALUES(13, \"third dimension\");\n    CREATE TABLE x (c);\n    COMMIT;\n    SELECT rowid FROM t1 WHERE t1 MATCH 'dimension';\n  }\n} {13}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3al.test",
    "content": "# 2007 March 28\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing isspace/isalnum/tolower problems with the\n# FTS3 module.  Unfortunately, this code isn't a really principled set\n# of tests, because it is impossible to know where new uses of these\n# functions might appear.\n#\n# $Id: fts3al.test,v 1.2 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Tests that startsWith() (calls isspace, tolower, isalnum) can handle\n# hi-bit chars.  parseSpec() also calls isalnum here.\ndo_test fts3al-1.1 {\n  execsql \"CREATE VIRTUAL TABLE t1 USING fts3(content, \\x80)\"\n} {}\n\n# Additionally tests isspace() call in getToken(), and isalnum() call\n# in tokenListToIdList().\ndo_test fts3al-1.2 {\n  catch {\n    execsql \"CREATE VIRTUAL TABLE t2 USING fts3(content, tokenize \\x80)\"\n  }\n  sqlite3_errmsg $DB\n} \"unknown tokenizer: \\x80\"\n\n# Additionally test final isalnum() in startsWith().\ndo_test fts3al-1.3 {\n  execsql \"CREATE VIRTUAL TABLE t3 USING fts3(content, tokenize\\x80)\"\n} {}\n\n# The snippet-generation code has calls to isspace() which are sort of\n# hard to get to.  It finds convenient breakpoints by starting ~40\n# chars before and after the matched term, and scanning ~10 chars\n# around that position for isspace() characters.  The long word with\n# embedded hi-bit chars causes one of these isspace() calls to be\n# exercised.  The version with a couple extra spaces should cause the\n# other isspace() call to be exercised.  [Both cases have been tested\n# in the debugger, but I'm hoping to continue to catch it if simple\n# constant changes change things slightly.\n#\n# The trailing and leading hi-bit chars help with code which tests for\n# isspace() to coalesce multiple spaces.\n#\n# UPDATE: The above is no longer true; there is no such code in fts3.\n# But leave the test in just the same.\n# \n\nset word \"\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80xxxxx\\x80\"\nset phrase1 \"$word $word $word target $word $word $word\"\nset phrase2 \"$word $word $word    target    $word $word $word\"\n\ndb eval {CREATE VIRTUAL TABLE t4 USING fts3(content)}\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase1')\"\ndb eval \"INSERT INTO t4 (content) VALUES ('$phrase2')\"\n\ndo_test fts3al-1.4 {\n  execsql {SELECT rowid, length(snippet(t4)) FROM t4 WHERE t4 MATCH 'target'}\n} {1 241 2 247}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3am.test",
    "content": "# 2007 April 9\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  fts3\n# DELETE handling assumed all fields were non-null.  This was not\n# the intention at all.\n#\n# $Id: fts3am.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(col_a, col_b);\n\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(1, 'testing', 'testing');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(2, 'only a', null);\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(3, null, 'only b');\n  INSERT INTO t1(rowid, col_a, col_b) VALUES(4, null, null);\n}\n\ndo_test fts3am-1.0 {\n  execsql {\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {2 2 4}\n\ndo_test fts3am-1.1 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 1;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {1 1 3}\n\ndo_test fts3am-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 2;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 1 2}\n\ndo_test fts3am-1.3 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 3;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 1}\n\ndo_test fts3am-1.4 {\n  execsql {\n    DELETE FROM t1 WHERE rowid = 4;\n    SELECT COUNT(col_a), COUNT(col_b), COUNT(*) FROM t1;\n  }\n} {0 0 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3an.test",
    "content": "# 2007 April 26\n#\n# The author disclaims copyright to this source code.\n#\n#*************************************************************************\n# This file implements tests for prefix-searching in the fts3\n# component of the SQLite library.\n#\n# $Id: fts3an.test,v 1.2 2007/12/13 21:54:11 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# A large string to prime the pump with.\nset text {\n  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas\n  iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam\n  sed turpis posuere placerat. Curabitur et lorem in lorem porttitor\n  aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit\n  ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra\n  at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,\n  ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at\n  luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu\n  lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse\n  potenti. Cum sociis natoque penatibus et magnis dis parturient\n  montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,\n  suscipit nec, consequat quis, risus.\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n\n  INSERT INTO t1(rowid, c) VALUES(1, $text);\n  INSERT INTO t1(rowid, c) VALUES(2, 'Another lovely row');\n}\n\n# Exact match\ndo_test fts3an-1.1 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lorem'\"\n} {1}\n\n# And a prefix\ndo_test fts3an-1.2 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lore*'\"\n} {1}\n\n# Prefix includes exact match\ndo_test fts3an-1.3 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lorem*'\"\n} {1}\n\n# Make certain everything isn't considered a prefix!\ndo_test fts3an-1.4 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lore'\"\n} {}\n\n# Prefix across multiple rows.\ndo_test fts3an-1.5 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lo*'\"\n} {1 2}\n\n# Likewise, with multiple hits in one document.\ndo_test fts3an-1.6 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'l*'\"\n} {1 2}\n\n# Prefix which should only hit one document.\ndo_test fts3an-1.7 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lov*'\"\n} {2}\n\n# * not at end is dropped.\ndo_test fts3an-1.8 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'lo *'\"\n} {}\n\n# Stand-alone * is dropped.\ndo_test fts3an-1.9 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '*'\"\n} {}\n\n# Phrase-query prefix.\ndo_test fts3an-1.10 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"lovely r*\\\"'\"\n} {2}\ndo_test fts3an-1.11 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"lovely r\\\"'\"\n} {}\n\n# Phrase query with multiple prefix matches.\ndo_test fts3an-1.12 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"a* l*\\\"'\"\n} {1 2}\n\n# Phrase query with multiple prefix matches.\ndo_test fts3an-1.13 {\n  execsql \"SELECT rowid FROM t1 WHERE t1 MATCH '\\\"a* l* row\\\"'\"\n} {2}\n\n\n\n\n# Test across updates (and, by implication, deletes).\n\n# Version of text without \"lorem\".\nregsub -all {[Ll]orem} $text '' ntext\n\ndb eval {\n  CREATE VIRTUAL TABLE t2 USING fts3(c);\n\n  INSERT INTO t2(rowid, c) VALUES(1, $text);\n  INSERT INTO t2(rowid, c) VALUES(2, 'Another lovely row');\n  UPDATE t2 SET c = $ntext WHERE rowid = 1;\n}\n\n# Can't see lorem as an exact match.\ndo_test fts3an-2.1 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lorem'\"\n} {}\n\n# Can't see a prefix of lorem, either.\ndo_test fts3an-2.2 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lore*'\"\n} {}\n\n# Can see lovely in the other document.\ndo_test fts3an-2.3 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lo*'\"\n} {2}\n\n# Can still see other hits.\ndo_test fts3an-2.4 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'l*'\"\n} {1 2}\n\n# Prefix which should only hit one document.\ndo_test fts3an-2.5 {\n  execsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'lov*'\"\n} {2}\n\n\n\n# Test with a segment which will have multiple levels in the tree.\n\n# Build a big document with lots of unique terms.\nset bigtext $text\nforeach c {a b c d e} {\n  regsub -all {[A-Za-z]+} $bigtext \"&$c\" t\n  append bigtext $t\n}\n\n# Populate a table with many copies of the big document, so that we\n# can test the number of hits found.  Populate $ret with the expected\n# hit counts for each row.  offsets() returns 4 elements for every\n# hit.  We'll have 6 hits for row 1, 1 for row 2, and 6*(2^5)==192 for\n# $bigtext.\nset ret {6 1}\ndb eval {\n  BEGIN;\n  CREATE VIRTUAL TABLE t3 USING fts3(c);\n\n  INSERT INTO t3(rowid, c) VALUES(1, $text);\n  INSERT INTO t3(rowid, c) VALUES(2, 'Another lovely row');\n}\nfor {set i 0} {$i<68} {incr i} {\n  db eval {INSERT INTO t3(rowid, c) VALUES(3+$i, $bigtext)}\n  lappend ret 192\n}\ndb eval {COMMIT;}\n\n# Test that we get the expected number of hits.\ndo_test fts3an-3.1 {\n  set t {}\n  db eval {SELECT offsets(t3) as o FROM t3 WHERE t3 MATCH 'l*'} {\n    set l [llength $o]\n    lappend t [expr {$l/4}]\n  }\n  set t\n} $ret\n\n# Test a boundary condition: More than 2^16 terms that match a searched for\n# prefix in a single segment.\n#\nputs \"This next test can take a little while (~ 30 seconds)...\"\ndo_test fts3an-4.1 {\n  execsql { CREATE VIRTUAL TABLE ft USING fts3(x) }\n  execsql BEGIN\n    execsql { INSERT INTO ft VALUES(NULL) }\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#      2\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#      4\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#      8\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#     16\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#     32\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#     64\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#    128\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#    256\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#    512\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#   1024\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#   2048\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#   4096\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#   8192\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#  16384\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#  32768\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;#  65536\n    execsql { INSERT INTO ft SELECT * FROM ft }     ;# 131072\n  execsql COMMIT\n  execsql { UPDATE ft SET x = 'abc' || rowid }\n  execsql { SELECT count(*) FROM ft WHERE x MATCH 'abc*' }\n} {131072}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3ao.test",
    "content": "# 2007 June 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n# $Id: fts3ao.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset ::testprefix fts3ao\n\n#---------------------------------------------------------------------\n# These tests, fts3ao-1.*, test that ticket #2429 is fixed.\n#\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);\n  INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one four two');\n}\ndo_test fts3ao-1.1 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE c MATCH 'four';\n  }\n} {1 {one <b>four</b> two}}\ndo_test fts3ao-1.2 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE b MATCH 'four';\n  }\n} {1 {one <b>four</b>}}\ndo_test fts3ao-1.3 {\n  execsql {\n    SELECT rowid, snippet(t1) FROM t1 WHERE a MATCH 'four';\n  }\n} {1 {one three <b>four</b>}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts3 table.\n#\ndo_test fts3ao-2.1 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {t1 t1_content t1_segments t1_segdir}\ndo_test fts3ao-2.2 {\n  execsql { ALTER TABLE t1 RENAME to fts_t1; }\n} {}\ndo_test fts3ao-2.3 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts3ao-2.4 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir}\n\n# See what happens when renaming the fts3 table fails.\n#\ndo_test fts3ao-2.5 {\n  catchsql {\n    CREATE TABLE t1_segdir(a, b, c);\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\ndo_test fts3ao-2.6 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts3ao-2.7 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}\n\n# See what happens when renaming the fts3 table fails inside a transaction.\n#\ndo_test fts3ao-2.8 {\n  execsql {\n    BEGIN;\n    INSERT INTO fts_t1(a, b, c) VALUES('one two three', 'one four', 'one two');\n  }\n} {}\ndo_test fts3ao-2.9 {\n  catchsql {\n    ALTER TABLE fts_t1 RENAME to t1;\n  }\n} {1 {SQL logic error}}\ndo_test fts3ao-2.10 {\n  execsql { SELECT rowid, snippet(fts_t1) FROM fts_t1 WHERE a MATCH 'four'; }\n} {1 {one three <b>four</b>}}\ndo_test fts3ao-2.11 {\n  execsql { SELECT tbl_name FROM sqlite_master WHERE type = 'table'}\n} {fts_t1 fts_t1_content fts_t1_segments fts_t1_segdir t1_segdir}\ndo_test fts3ao-2.12 {\n  execsql COMMIT\n  execsql {SELECT a FROM fts_t1}\n} {{one three four} {one two three}}\ndo_test fts3ao-2.12 {\n  execsql { SELECT a, b, c FROM fts_t1 WHERE c MATCH 'four'; }\n} {{one three four} {one four} {one four two}}\n\n#-------------------------------------------------------------------\n# Close, delete and reopen the database. The following test should \n# be run on an initially empty db.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndo_test fts3ao-3.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(a, b, c);\n    INSERT INTO t1(a, b, c) VALUES('one three four', 'one four', 'one two');\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n  }\n} {{one three four} {one four} {one two}}\n\n# This test was crashing at one point.\n#\ndo_test fts3ao-3.2 {\n  execsql {\n    SELECT a, b, c FROM t1 WHERE c MATCH 'two';\n    CREATE TABLE t3(a, b, c);\n    SELECT a, b, c FROM t1 WHERE  c  MATCH 'two';\n  }\n} {{one three four} {one four} {one two} {one three four} {one four} {one two}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts3 table in an attached \n# database.\n#\nforcedelete test2.db test2.db-journal\n\ndo_test fts3ao-3.1 {\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c);\n    INSERT INTO aux.t1(a, b, c) VALUES(\n      'neung song sahm', 'neung see', 'neung see song'\n    );\n  }\n} {}\n\ndo_test fts3ao-3.2 {\n  execsql { SELECT a, b, c FROM aux.t1 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts3ao-3.3 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one two}}\n\ndo_test fts3ao-3.4 {\n  execsql { ALTER TABLE aux.t1 RENAME TO t2 }\n} {}\n\ndo_test fts3ao-3.2 {\n  execsql { SELECT a, b, c FROM t2 WHERE a MATCH 'song'; }\n} {{neung song sahm} {neung see} {neung see song}}\n\ndo_test fts3ao-3.3 {\n  execsql { SELECT a, b, c FROM t1 WHERE c MATCH 'two'; }\n} {{one three four} {one four} {one two}}\n\n#---------------------------------------------------------------------\n# Test that it is possible to rename an fts3 table within a \n# transaction.\n#\ndo_test fts3ao-4.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t4 USING fts3;\n    INSERT INTO t4 VALUES('the quick brown fox');\n  }\n} {}\ndo_test fts3ao-4.2 {\n  execsql {\n    BEGIN;\n      INSERT INTO t4 VALUES('jumped over the');\n  }\n} {}\ndo_test fts3ao-4.3 { execsql { ALTER TABLE t4 RENAME TO t5; } } {}\ndo_test fts3ao-4.4 { execsql { INSERT INTO t5 VALUES('lazy dog'); } } {}\ndo_test fts3ao-4.5 { execsql COMMIT } {}\ndo_test fts3ao-4.6 {\n  execsql { SELECT * FROM t5 }\n} {{the quick brown fox} {jumped over the} {lazy dog}}\ndo_test fts3ao-4.7 {\n  execsql {\n    BEGIN;\n      INSERT INTO t5 VALUES('Down came a jumbuck to drink at that billabong');\n      ALTER TABLE t5 RENAME TO t6;\n      INSERT INTO t6 VALUES('Down came the troopers, one, two, three');\n    ROLLBACK;\n    SELECT * FROM t5;\n  }\n} {{the quick brown fox} {jumped over the} {lazy dog}}\ndo_execsql_test fts3ao-4.8 {\n  SELECT snippet(t5, '[', ']') FROM t5 WHERE t5 MATCH 'the'\n} {{[the] quick brown fox} {jumped over [the]}}\n\n# Test that it is possible to rename an FTS4 table. Renaming an FTS4 table\n# involves renaming the extra %_docsize and %_stat tables.\n#\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE t7 USING FTS4;\n  INSERT INTO t7 VALUES('coined by a German clinician');\n  SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';\n  SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';\n} {6 0}\ndo_execsql_test 5.2 {\n  ALTER TABLE t7 RENAME TO t8;\n  SELECT count(*) FROM sqlite_master WHERE name LIKE 't7%';\n  SELECT count(*) FROM sqlite_master WHERE name LIKE 't8%';\n} {0 6}\n\n# At one point this was causing a memory leak.\n#\nforeach {tn sql} {\n  1 {}\n  2 { INSERT INTO ft(ft) VALUES('merge=2,2'); }\n} {\n  reset_db\n  do_execsql_test 6.$tn.1 \"\n    CREATE TABLE t1(x);\n    CREATE VIRTUAL TABLE ft USING fts3;\n    INSERT INTO ft VALUES('hello world');\n    $sql\n  \"\n\n  db close\n  sqlite3 db test.db\n  do_execsql_test 6.$tn.2 { SELECT * FROM t1 } {}\n\n  do_test 6.$tn.3 {\n    sqlite3 db2 test.db\n    db2 eval { DROP TABLE t1 }\n    db2 close\n    set stmt [sqlite3_prepare db { SELECT * FROM ft } -1 dummy]\n    sqlite3_finalize $stmt\n  } {SQLITE_OK}\n  db close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3atoken.test",
    "content": "# 2007 June 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library. The focus \n# of this script is testing the pluggable tokeniser feature of the \n# FTS3 module.\n#\n# $Id: fts3atoken.test,v 1.1 2007/08/20 17:38:42 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset ::testprefix fts3atoken\n\nproc escape_string {str} {\n  set out \"\"\n  foreach char [split $str \"\"] {\n    scan $char %c i\n    if {$i<=127} {\n      append out $char\n    } else {\n      append out [format {\\x%.4x} $i]\n    }\n  }\n  set out\n}\n\n#--------------------------------------------------------------------------\n# Test cases fts3atoken-1.* are the warm-body test for the SQL scalar\n# function fts3_tokenizer(). The procedure is as follows:\n#\n#   1: Verify that there is no such fts3 tokenizer as 'blah'.\n#\n#   2: Query for the built-in tokenizer 'simple'. Insert a copy of the\n#      retrieved value as tokenizer 'blah'.\n#\n#   3: Test that the value returned for tokenizer 'blah' is now the\n#      same as that retrieved for 'simple'.\n#\n#   4: Test that it is now possible to create an fts3 table using \n#      tokenizer 'blah' (it was not possible in step 1).\n#\n#   5: Test that the table created to use tokenizer 'blah' is usable.\n#\nsqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1\ndo_test fts3atoken-1.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);\n  }\n} {1 {unknown tokenizer: blah}}\ndo_test fts3atoken-1.2 {\n  execsql {\n    SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;\n  }\n} {0}\ndo_test fts3atoken-1.3 {\n  execsql {\n    SELECT fts3_tokenizer('blah') == fts3_tokenizer('simple');\n  }\n} {1}\ndo_test fts3atoken-1.4 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(content, tokenize blah);\n  }\n} {0 {}}\ndo_test fts3atoken-1.5 {\n  execsql {\n    INSERT INTO t1(content) VALUES('There was movement at the station');\n    INSERT INTO t1(content) VALUES('For the word has passed around');\n    INSERT INTO t1(content) VALUES('That the colt from ol regret had got');\n    SELECT content FROM t1 WHERE content MATCH 'movement'\n  }\n} {{There was movement at the station}}\n\nsqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 0\ndo_catchsql_test 1.6 {\n  SELECT fts3_tokenizer('blah', fts3_tokenizer('simple')) IS NULL;\n} {1 {fts3tokenize disabled}}\n\n\n#--------------------------------------------------------------------------\n# Test cases fts3atoken-2.* test error cases in the scalar function based\n# API for getting and setting tokenizers.\n#\ndo_test fts3atoken-2.1 {\n  catchsql {\n    SELECT fts3_tokenizer('nosuchtokenizer');\n  }\n} {1 {unknown tokenizer: nosuchtokenizer}}\n\n#--------------------------------------------------------------------------\n# Test cases fts3atoken-3.* test the three built-in tokenizers with a\n# simple input string via the built-in test function. This is as much\n# to test the test function as the tokenizer implementations.\n#\ndo_test fts3atoken-3.1 {\n  execsql {\n    SELECT fts3_tokenizer_test('simple', 'I don''t see how');\n  }\n} {{0 i I 1 don don 2 t t 3 see see 4 how how}}\ndo_test fts3atoken-3.2 {\n  execsql {\n    SELECT fts3_tokenizer_test('porter', 'I don''t see how');\n  }\n} {{0 i I 1 don don 2 t t 3 see see 4 how how}}\nifcapable icu {\n  do_test fts3atoken-3.3 {\n    execsql {\n      SELECT fts3_tokenizer_test('icu', 'I don''t see how');\n    }\n  } {{0 i I 1 don't don't 2 see see 3 how how}}\n}\n\n#--------------------------------------------------------------------------\n# Test cases fts3atoken-4.* test the ICU tokenizer. In practice, this\n# tokenizer only has two modes - \"thai\" and \"everybody else\". Some other\n# Asian languages (Lao, Khmer etc.) require the same special treatment as \n# Thai, but ICU doesn't support them yet.\n#\nifcapable icu {\n\n  proc do_icu_test {name locale input output} {\n    set ::out [db eval { SELECT fts3_tokenizer_test('icu', $locale, $input) }]\n    do_test $name {\n      lindex $::out 0\n    } $output\n  }\n  \n  do_icu_test fts3atoken-4.1 en_US  {}   {}\n  do_icu_test fts3atoken-4.2 en_US {Test cases fts3} [list \\\n    0 test Test 1 cases cases 2 fts3 fts3\n  ]\n\n  # The following test shows that ICU is smart enough to recognise\n  # Thai chararacters, even when the locale is set to English/United \n  # States.\n  #\n  set input \"\\u0e2d\\u0e30\\u0e44\\u0e23\\u0e19\\u0e30\\u0e04\\u0e23\\u0e31\\u0e1a\"\n  set output    \"0 \\u0e2d\\u0e30\\u0e44\\u0e23 \\u0e2d\\u0e30\\u0e44\\u0e23 \"\n  append output \"1 \\u0e19\\u0e30 \\u0e19\\u0e30 \"\n  append output \"2 \\u0e04\\u0e23\\u0e31\\u0e1a \\u0e04\\u0e23\\u0e31\\u0e1a\"\n\n  do_icu_test fts3atoken-4.3 th_TH  $input $output\n  do_icu_test fts3atoken-4.4 en_US  $input $output\n\n  # ICU handles an unknown locale by falling back to the default.\n  # So this is not an error.\n  do_icu_test fts3atoken-4.5 MiddleOfTheOcean  $input $output\n\n  set    longtoken \"AReallyReallyLongTokenOneThatWillSurelyRequire\"\n  append longtoken \"AReallocInTheIcuTokenizerCode\"\n\n  set    input \"short tokens then \"\n  append input $longtoken\n  set    output \"0 short short \"\n  append output \"1 tokens tokens \"\n  append output \"2 then then \"\n  append output \"3 [string tolower $longtoken] $longtoken\"\n\n  do_icu_test fts3atoken-4.6 MiddleOfTheOcean  $input $output\n  do_icu_test fts3atoken-4.7 th_TH  $input $output\n  do_icu_test fts3atoken-4.8 en_US  $input $output\n\n  do_execsql_test 5.1 {\n    CREATE VIRTUAL TABLE x1 USING fts3(name,TOKENIZE icu en_US);\n    insert into x1 (name) values (NULL);\n    insert into x1 (name) values (NULL);\n    delete from x1;\n  }\n\n  proc cp_to_str {codepoint_list} {\n    set fmt [string repeat %c [llength $codepoint_list]]\n    eval [list format $fmt] $codepoint_list\n  }\n\n  do_test 5.2 {\n    set str [cp_to_str {19968 26085 32822 32645 27874 23433 20986}]\n    execsql { INSERT INTO x1 VALUES($str) }\n  } {}\n}\n\ndo_test fts3atoken-internal {\n  execsql { SELECT fts3_tokenizer_internal_test() }\n} {ok}\n\n#-------------------------------------------------------------------------\n# Test empty tokenizer names.\n#\ndo_catchsql_test 6.1.1 {\n  CREATE VIRTUAL TABLE t3 USING fts4(tokenize=\"\");\n} {1 {unknown tokenizer: }}\ndo_catchsql_test 6.1.2 {\n  CREATE VIRTUAL TABLE t3 USING fts4(tokenize=);\n} {1 {unknown tokenizer: }}\ndo_catchsql_test 6.1.3 {\n  CREATE VIRTUAL TABLE t3 USING fts4(tokenize=\"   \");\n} {1 {unknown tokenizer:    }}\n\ndo_catchsql_test 6.2.1 {\n  SELECT fts3_tokenizer(NULL);\n} {1 {unknown tokenizer: }}\n\nsqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1\ndo_catchsql_test 6.2.2 {\n  SELECT fts3_tokenizer(NULL, X'1234567812345678');\n} {1 {argument type mismatch}}\ndo_catchsql_test 6.2.3 {\n  SELECT fts3_tokenizer(NULL, X'12345678');\n} {1 {argument type mismatch}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3auto.test",
    "content": "# 2011 June 10\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build does not include FTS3, skip the tests in this file.\n#\nifcapable !fts3 { finish_test ; return }\nsource $testdir/fts3_common.tcl\nsource $testdir/malloc_common.tcl\n\nset testprefix fts3auto\nset sfep $sqlite_fts3_enable_parentheses\nset sqlite_fts3_enable_parentheses 1\n\n#--------------------------------------------------------------------------\n# Start of Tcl infrastructure used by tests. The entry points are:\n#\n#   do_fts3query_test\n#   fts3_make_deferrable\n#   fts3_zero_long_segments \n#\n\n#\n#    do_fts3query_test TESTNAME ?OPTIONS? TABLE MATCHEXPR\n#\n# This proc runs several test cases on FTS3/4 table $TABLE using match\n# expression $MATCHEXPR. All documents in $TABLE must be formatted so that\n# they can be \"tokenized\" using the Tcl list commands (llength, lindex etc.).\n# The name and column names used by $TABLE must not require any quoting or\n# escaping when used in SQL statements.\n#\n# $MATCHINFO may be any expression accepted by the FTS4 MATCH operator, \n# except that the \"<column-name>:token\" syntax is not supported. Tcl list\n# commands are used to tokenize the expression. Any parenthesis must appear\n# either as separate list elements, or as the first (for opening) or last\n# (for closing) character of a list element. i.e. the expression \"(a OR b)c\"\n# will not be parsed correctly, but \"( a OR b) c\" will.\n#\n# Available OPTIONS are:\n#\n#     -deferred TOKENLIST\n#\n# If the \"deferred\" option is supplied, it is passed a list of tokens that\n# are deferred by FTS and result in the relevant matchinfo() stats being an\n# approximation. \n#\nset sqlite_fts3_enable_parentheses 1\nproc do_fts3query_test {tn args} {\n\n  set nArg [llength $args]\n  if {$nArg < 2 || ($nArg % 2)} {\n    set cmd do_fts3query_test\n    error \"wrong # args: should be \\\"$cmd ?-deferred LIST? TABLE MATCHEXPR\\\"\"\n  }\n  set tbl   [lindex $args [expr $nArg-2]]\n  set match [lindex $args [expr $nArg-1]]\n  set deferred [list]\n\n  foreach {k v} [lrange $args 0 [expr $nArg-3]] {\n    switch -- $k {\n      -deferred {\n        ifcapable fts4_deferred { set deferred $v }\n      }\n      default {\n        error \"bad option \\\"$k\\\": must be -deferred\"\n      }\n    }\n  }\n\n  get_near_results $tbl $match $deferred aHit\n  get_near_results $tbl [string map {AND OR} $match] $deferred aMatchinfo\n\n  set matchinfo_asc [list]\n  foreach docid [lsort -integer -incr [array names aHit]] {\n    lappend matchinfo_asc $docid $aMatchinfo($docid)\n  }\n  set matchinfo_desc [list]\n  foreach docid [lsort -integer -decr [array names aHit]] {\n    lappend matchinfo_desc $docid $aMatchinfo($docid)\n  }\n\n  set title \"(\\\"$match\\\" -> [llength [array names aHit]] rows)\"\n\n  do_execsql_test $tn$title.1 \"\n    SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid ASC\n  \" [lsort -integer -incr [array names aHit]] \n\n  do_execsql_test $tn$title.2 \"\n    SELECT docid FROM $tbl WHERE $tbl MATCH '$match' ORDER BY docid DESC\n  \" [lsort -integer -decr [array names aHit]] \n\n  do_execsql_test $tn$title.3 \"\n    SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl \n    WHERE $tbl MATCH '$match' ORDER BY docid DESC\n  \" $matchinfo_desc\n\n  do_execsql_test $tn$title.4 \"\n    SELECT docid, mit(matchinfo($tbl, 'x')) FROM $tbl \n    WHERE $tbl MATCH '$match' ORDER BY docid ASC\n  \" $matchinfo_asc\n}\n\n#    fts3_make_deferrable TABLE TOKEN ?NROW?\n#\nproc fts3_make_deferrable {tbl token {nRow 0}} {\n\n  set stmt [sqlite3_prepare db \"SELECT * FROM $tbl\" -1 dummy]\n  set name [sqlite3_column_name $stmt 0]\n  sqlite3_finalize $stmt\n\n  if {$nRow==0} {\n    set nRow [db one \"SELECT count(*) FROM $tbl\"]\n  }\n  set pgsz [db one \"PRAGMA page_size\"]\n  execsql BEGIN\n  for {set i 0} {$i < ($nRow * $pgsz * 1.2)/100} {incr i} {\n    set doc [string repeat \"$token \" 100]\n    execsql \"INSERT INTO $tbl ($name) VALUES(\\$doc)\"\n  }\n  execsql \"INSERT INTO $tbl ($name) VALUES('aaaaaaa ${token}aaaaa')\"\n  execsql COMMIT\n\n  return [expr $nRow*$pgsz]\n}\n\n#    fts3_zero_long_segments TABLE ?LIMIT?\n#\nproc fts3_zero_long_segments {tbl limit} {\n  execsql \" \n    UPDATE ${tbl}_segments \n    SET block = zeroblob(length(block)) \n    WHERE length(block)>$limit\n  \"\n  return [db changes]\n}\n\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\nproc fix_phrase_expr {cols expr colfiltervar} {\n  upvar $colfiltervar iColFilter\n\n  set out [list]\n  foreach t $expr {\n    if {[string match *:* $t]} {\n      set col [lindex [split $t :] 0]\n      set t   [lindex [split $t :] 1]\n      set iCol [lsearch $cols $col]\n      if {$iCol<0} { error \"unknown column: $col\" }\n      if {$iColFilter < 0} {\n        set iColFilter $iCol\n      } elseif {$iColFilter != $iCol} {\n        set iColFilter [llength $cols]\n      }\n    }\n    lappend out $t\n  }\n\n  return $out\n}\n\nproc fix_near_expr {cols expr colfiltervar} { \n  upvar $colfiltervar iColFilter\n \n  set iColFilter -1\n\n  set out [list]\n  lappend out [fix_phrase_expr $cols [lindex $expr 0] iColFilter]\n  foreach {a b} [lrange $expr 1 end] {\n    if {[string match -nocase near $a]}   { set a 10 }\n    if {[string match -nocase near/* $a]} { set a [string range $a 5 end] }\n    lappend out $a\n    lappend out [fix_phrase_expr $cols $b iColFilter]\n  }\n  return $out\n}\n\nproc get_single_near_results {tbl expr deferred arrayvar nullvar} {\n  upvar $arrayvar aMatchinfo\n  upvar $nullvar nullentry\n  catch {array unset aMatchinfo}\n\n  set cols [list]\n  set miss [list]\n  db eval \"PRAGMA table_info($tbl)\" A { lappend cols $A(name) ; lappend miss 0 }\n  set expr [fix_near_expr $cols $expr iColFilter]\n\n  # Calculate the expected results using [fts3_near_match]. The following\n  # loop populates the \"hits\" and \"counts\" arrays as follows:\n  # \n  #   1. For each document in the table that matches the NEAR expression,\n  #      hits($docid) is set to 1. The set of docids that match the expression\n  #      can therefore be found using [array names hits].\n  #\n  #   2. For each column of each document in the table, counts($docid,$iCol)\n  #      is set to the -phrasecountvar output.\n  #\n  set res [list]\n  catch { array unset hits }\n  db eval \"SELECT docid, * FROM $tbl\" d {\n    set iCol 0\n    foreach col [lrange $d(*) 1 end] {\n      set docid $d(docid)\n      if {$iColFilter<0 || $iCol==$iColFilter} {\n        set hit [fts3_near_match $d($col) $expr -p counts($docid,$iCol)]\n        if {$hit} { set hits($docid) 1 }\n      } else {\n        set counts($docid,$iCol) $miss\n      }\n      incr iCol\n    }\n  }\n  set nPhrase [expr ([llength $expr]+1)/2]\n  set nCol $iCol\n\n  # This block populates the nHit and nDoc arrays. For each phrase/column\n  # in the query/table, array elements are set as follows:\n  #\n  #   nHit($iPhrase,$iCol) - Total number of hits for phrase $iPhrase in \n  #                          column $iCol.\n  #\n  #   nDoc($iPhrase,$iCol) - Number of documents with at least one hit for\n  #                          phrase $iPhrase in column $iCol.\n  #\n  for {set iPhrase 0} {$iPhrase < $nPhrase} {incr iPhrase} {\n    for {set iCol 0} {$iCol < $nCol} {incr iCol} {\n      set nHit($iPhrase,$iCol) 0\n      set nDoc($iPhrase,$iCol) 0\n    }\n  }\n  foreach key [array names counts] {\n    set iCol [lindex [split $key ,] 1]\n    set iPhrase 0\n    foreach c $counts($key) {\n      if {$c>0} { incr nDoc($iPhrase,$iCol) 1 }\n      incr nHit($iPhrase,$iCol) $c\n      incr iPhrase\n    }\n  }\n\n  if {[llength $deferred] && [llength $expr]==1} {\n    set phrase [lindex $expr 0]\n    set rewritten [list]\n    set partial 0\n    foreach tok $phrase {\n      if {[lsearch $deferred $tok]>=0} {\n        lappend rewritten *\n      } else {\n        lappend rewritten $tok\n        set partial 1\n      }\n    }\n    if {$partial==0} {\n      set tblsize [db one \"SELECT count(*) FROM $tbl\"]\n      for {set iCol 0} {$iCol < $nCol} {incr iCol} {\n        set nHit(0,$iCol) $tblsize\n        set nDoc(0,$iCol) $tblsize\n      }\n    } elseif {$rewritten != $phrase} {\n      while {[lindex $rewritten end] == \"*\"} {\n        set rewritten [lrange $rewritten 0 end-1]\n      }\n      while {[lindex $rewritten 0] == \"*\"} {\n        set rewritten [lrange $rewritten 1 end]\n      }\n      get_single_near_results $tbl [list $rewritten] {} aRewrite nullentry\n      foreach docid [array names hits] {\n        set aMatchinfo($docid) $aRewrite($docid)\n      }\n      return\n    }\n  }\n\n  # Set up the aMatchinfo array. For each document, set aMatchinfo($docid) to\n  # contain the output of matchinfo('x') for the document.\n  #\n  foreach docid [array names hits] {\n    set mi [list]\n    for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {\n      for {set iCol 0} {$iCol<$nCol} {incr iCol} {\n        lappend mi [lindex $counts($docid,$iCol) $iPhrase]\n        lappend mi $nHit($iPhrase,$iCol)\n        lappend mi $nDoc($iPhrase,$iCol)\n      }\n    }\n    set aMatchinfo($docid) $mi\n  }\n\n  # Set up the nullentry output.\n  #\n  set nullentry [list]\n  for {set iPhrase 0} {$iPhrase<$nPhrase} {incr iPhrase} {\n    for {set iCol 0} {$iCol<$nCol} {incr iCol} {\n      lappend nullentry 0 $nHit($iPhrase,$iCol) $nDoc($iPhrase,$iCol)\n    }\n  }\n}\n\n\nproc matching_brackets {expr} {\n  if {[string range $expr 0 0]!=\"(\" || [string range $expr end end] !=\")\"} { \n    return 0 \n  }\n\n  set iBracket 1\n  set nExpr [string length $expr]\n  for {set i 1} {$iBracket && $i < $nExpr} {incr i} {\n    set c [string range $expr $i $i]\n    if {$c == \"(\"} {incr iBracket}\n    if {$c == \")\"} {incr iBracket -1}\n  }\n\n  return [expr ($iBracket==0 && $i==$nExpr)]\n}\n\nproc get_near_results {tbl expr deferred arrayvar {nullvar \"\"}} {\n  upvar $arrayvar aMatchinfo\n  if {$nullvar != \"\"} { upvar $nullvar nullentry }\n\n  set expr [string trim $expr]\n  while { [matching_brackets $expr] } {\n    set expr [string trim [string range $expr 1 end-1]]\n  }\n\n  set prec(NOT) 1\n  set prec(AND) 2\n  set prec(OR)  3\n\n  set currentprec 0\n  set iBracket 0\n  set expr_length [llength $expr]\n  for {set i 0} {$i < $expr_length} {incr i} {\n    set op [lindex $expr $i]\n    if {$iBracket==0 && [info exists prec($op)] && $prec($op)>=$currentprec } {\n      set opidx $i\n      set currentprec $prec($op)\n    } else {\n      for {set j 0} {$j < [string length $op]} {incr j} {\n        set c [string range $op $j $j]\n        if {$c == \"(\"} { incr iBracket +1 }\n        if {$c == \")\"} { incr iBracket -1 }\n      }\n    }\n  }\n  if {$iBracket!=0} { error \"mismatched brackets in: $expr\" }\n\n  if {[info exists opidx]==0} {\n    get_single_near_results $tbl $expr $deferred aMatchinfo nullentry\n  } else {\n    set eLeft  [lrange $expr 0 [expr $opidx-1]]\n    set eRight [lrange $expr [expr $opidx+1] end]\n\n    get_near_results $tbl $eLeft  $deferred aLeft  nullleft\n    get_near_results $tbl $eRight $deferred aRight nullright\n\n    switch -- [lindex $expr $opidx] {\n      \"NOT\" {\n        foreach hit [array names aLeft] {\n          if {0==[info exists aRight($hit)]} {\n            set aMatchinfo($hit) $aLeft($hit)\n          }\n        }\n        set nullentry $nullleft\n      }\n\n      \"AND\" {\n        foreach hit [array names aLeft] {\n          if {[info exists aRight($hit)]} {\n            set aMatchinfo($hit) [concat $aLeft($hit) $aRight($hit)]\n          }\n        }\n        set nullentry [concat $nullleft $nullright]\n      }\n\n      \"OR\" {\n        foreach hit [array names aLeft] {\n          if {[info exists aRight($hit)]} {\n            set aMatchinfo($hit) [concat $aLeft($hit) $aRight($hit)]\n            unset aRight($hit)\n          } else {\n            set aMatchinfo($hit) [concat $aLeft($hit) $nullright]\n          }\n        }\n        foreach hit [array names aRight] {\n          set aMatchinfo($hit) [concat $nullleft $aRight($hit)]\n        }\n\n        set nullentry [concat $nullleft $nullright]\n      }\n    }\n  }\n}\n\n\n# End of test procs. Actual tests are below this line.\n#--------------------------------------------------------------------------\n\n#--------------------------------------------------------------------------\n# The following test cases - fts3auto-1.* - focus on testing the Tcl \n# command [fts3_near_match], which is used by other tests in this file.\n#\nproc test_fts3_near_match {tn doc expr res} {\n  fts3_near_match $doc $expr -phrasecountvar p\n  uplevel do_test [list $tn] [list [list set {} $p]] [list $res]\n}\n\ntest_fts3_near_match 1.1.1 {a b c a b} a                   {2}\ntest_fts3_near_match 1.1.2 {a b c a b} {a 5 b 6 c}         {2 2 1}\ntest_fts3_near_match 1.1.3 {a b c a b} {\"a b\"}             {2}\ntest_fts3_near_match 1.1.4 {a b c a b} {\"b c\"}             {1}\ntest_fts3_near_match 1.1.5 {a b c a b} {\"c c\"}             {0}\n\ntest_fts3_near_match 1.2.1 \"a b c d e f g\" {b 2 f}         {0 0}\ntest_fts3_near_match 1.2.2 \"a b c d e f g\" {b 3 f}         {1 1}\ntest_fts3_near_match 1.2.3 \"a b c d e f g\" {f 2 b}         {0 0}\ntest_fts3_near_match 1.2.4 \"a b c d e f g\" {f 3 b}         {1 1}\ntest_fts3_near_match 1.2.5 \"a b c d e f g\" {\"a b\" 2 \"f g\"} {0 0}\ntest_fts3_near_match 1.2.6 \"a b c d e f g\" {\"a b\" 3 \"f g\"} {1 1}\n\nset A \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\ntest_fts3_near_match 1.3.1 $A {\"c d\" 5 \"i j\" 1 \"e f\"}      {0 0 0}\ntest_fts3_near_match 1.3.2 $A {\"c d\" 5 \"i j\" 2 \"e f\"}      {1 1 1}\n\n#--------------------------------------------------------------------------\n# Test cases fts3auto-2.* run some simple tests using the \n# [do_fts3query_test] proc.\n#\nforeach {tn create} {\n  1    \"fts4(a, b)\"\n  2    \"fts4(a, b, order=DESC)\"\n  3    \"fts4(a, b, order=ASC)\"\n  4    \"fts4(a, b, prefix=1)\"\n  5    \"fts4(a, b, order=DESC, prefix=1)\"\n  6    \"fts4(a, b, order=ASC, prefix=1)\"\n} {\n  do_test 2.$tn.1 {\n    catchsql { DROP TABLE t1 }\n    execsql  \"CREATE VIRTUAL TABLE t1 USING $create\"\n    for {set i 0} {$i<32} {incr i} {\n      set doc [list]\n      if {$i&0x01} {lappend doc one}\n      if {$i&0x02} {lappend doc two}\n      if {$i&0x04} {lappend doc three}\n      if {$i&0x08} {lappend doc four}\n      if {$i&0x10} {lappend doc five}\n      execsql { INSERT INTO t1 VALUES($doc, null) }\n    }\n  } {}\n\n  foreach {tn2 expr} {\n    1     {one}\n    2     {one NEAR/1 five}\n    3     {t*}\n    4     {t* NEAR/0 five}\n    5     {o* NEAR/1 f*}\n    6     {one NEAR five NEAR two NEAR four NEAR three}\n    7     {one NEAR xyz}\n    8     {one OR two}\n    9     {one AND two}\n    10    {one NOT two}\n    11    {one AND two OR three}\n    12    {three OR one AND two}\n    13    {(three OR one) AND two}\n    14    {(three OR one) AND two NOT (five NOT four)}\n    15    {\"one two\"}\n    16    {\"one two\" NOT \"three four\"}\n  } {\n    do_fts3query_test 2.$tn.2.$tn2 t1 $expr\n  }\n}\n\n#--------------------------------------------------------------------------\n# Some test cases involving deferred tokens.\n#\n\nforeach {tn create} {\n  1    \"fts4(x)\"\n  2    \"fts4(x, order=DESC)\"\n} {\n  catchsql { DROP TABLE t1 }\n  execsql  \"CREATE VIRTUAL TABLE t1 USING $create\"\n  do_execsql_test 3.$tn.1 {\n    INSERT INTO t1(docid, x) VALUES(-2, 'a b c d e f g h i j k');\n    INSERT INTO t1(docid, x) VALUES(-1, 'b c d e f g h i j k a');\n    INSERT INTO t1(docid, x) VALUES(0, 'c d e f g h i j k a b');\n    INSERT INTO t1(docid, x) VALUES(1, 'd e f g h i j k a b c');\n    INSERT INTO t1(docid, x) VALUES(2, 'e f g h i j k a b c d');\n    INSERT INTO t1(docid, x) VALUES(3, 'f g h i j k a b c d e');\n    INSERT INTO t1(docid, x) VALUES(4, 'a c e g i k');\n    INSERT INTO t1(docid, x) VALUES(5, 'a d g j');\n    INSERT INTO t1(docid, x) VALUES(6, 'c a b');\n  }\n\n  set limit [fts3_make_deferrable t1 c]\n\n  do_fts3query_test 3.$tn.2.1 t1 {a OR c}\n\n  ifcapable fts4_deferred {\n    do_test 3.$tn.3 { fts3_zero_long_segments t1 $limit } {1}\n  }\n\n  foreach {tn2 expr def} {\n    1     {a NEAR c}            {}\n    2     {a AND c}             c\n    3     {\"a c\"}               c\n    4     {\"c a\"}               c\n    5     {\"a c\" NEAR/1 g}      {}\n    6     {\"a c\" NEAR/0 g}      {}\n  } {\n    do_fts3query_test 3.$tn.4.$tn2 -deferred $def t1 $expr\n  }\n}\n\n#--------------------------------------------------------------------------\n# \nforeach {tn create} {\n  1    \"fts4(x, y)\"\n  2    \"fts4(x, y, order=DESC)\"\n  3    \"fts4(x, y, order=DESC, prefix=2)\"\n} {\n\n  execsql [subst {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING $create;\n    INSERT INTO t1 VALUES('one two five four five', '');\n    INSERT INTO t1 VALUES('', 'one two five four five');\n    INSERT INTO t1 VALUES('one two', 'five four five');\n  }]\n\n  do_fts3query_test 4.$tn.1.1 t1 {one AND five}\n  do_fts3query_test 4.$tn.1.2 t1 {one NEAR five}\n  do_fts3query_test 4.$tn.1.3 t1 {one NEAR/1 five}\n  do_fts3query_test 4.$tn.1.4 t1 {one NEAR/2 five}\n  do_fts3query_test 4.$tn.1.5 t1 {one NEAR/3 five}\n\n  do_test 4.$tn.2 { \n    set limit [fts3_make_deferrable t1 five]\n    execsql { INSERT INTO t1(t1) VALUES('optimize') }\n    ifcapable fts4_deferred {\n      expr {[fts3_zero_long_segments t1 $limit]>0}\n    } else {\n      expr 1\n    }\n  } {1}\n\n  do_fts3query_test 4.$tn.3.1 -deferred five t1 {one AND five}\n  do_fts3query_test 4.$tn.3.2 -deferred five t1 {one NEAR five}\n  do_fts3query_test 4.$tn.3.3 -deferred five t1 {one NEAR/1 five}\n  do_fts3query_test 4.$tn.3.4 -deferred five t1 {one NEAR/2 five}\n\n  do_fts3query_test 4.$tn.3.5 -deferred five t1 {one NEAR/3 five}\n\n  do_fts3query_test 4.$tn.4.1 -deferred fi* t1 {on* AND fi*}\n  do_fts3query_test 4.$tn.4.2 -deferred fi* t1 {on* NEAR fi*}\n  do_fts3query_test 4.$tn.4.3 -deferred fi* t1 {on* NEAR/1 fi*}\n  do_fts3query_test 4.$tn.4.4 -deferred fi* t1 {on* NEAR/2 fi*}\n  do_fts3query_test 4.$tn.4.5 -deferred fi* t1 {on* NEAR/3 fi*}\n}\n\n#--------------------------------------------------------------------------\n# The following test cases - fts3auto-5.* - focus on using prefix indexes.\n#\nset chunkconfig [fts3_configure_incr_load 1 1]\nforeach {tn create pending} {\n  1    \"fts4(a, b)\"                                  1\n  2    \"fts4(a, b, order=ASC, prefix=1)\"             1\n  3    \"fts4(a, b, order=ASC,  prefix=\\\"1,3\\\")\"      0\n  4    \"fts4(a, b, order=DESC, prefix=\\\"2,4\\\")\"      0\n  5    \"fts4(a, b, order=DESC, prefix=\\\"1\\\")\"        0\n  6    \"fts4(a, b, order=ASC,  prefix=\\\"1,3\\\")\"      0\n} {\n\n  execsql [subst {\n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING $create;\n  }]\n\n  if {$pending} {execsql BEGIN}\n\n  foreach {a b} {\n    \"the song of songs which is solomons\"\n    \"let him kiss me with the kisses of his mouth for thy love is better than wine\"\n    \"because of the savour of thy good ointments thy name is as ointment poured forth therefore do the virgins love thee\"\n    \"draw me we will run after thee the king hath brought me into his chambers we will be glad and rejoice in thee we will remember thy love more than wine the upright love thee\"\n    \"i am black but comely o ye daughters of jerusalem as the tents of kedar as the curtains of solomon\"\n    \"look not upon me because i am black because the sun hath looked upon me my mothers children were angry with me they made me the keeper of the vineyards but mine own vineyard have i not kept\"\n    \"tell me o thou whom my soul loveth where thou feedest where thou makest thy flock to rest at noon for why should i be as one that turneth aside by the flocks of thy companions?\"\n    \"if thou know not o thou fairest among women go thy way forth by the footsteps of the flock and feed thy kids beside the shepherds tents\"\n    \"i have compared thee o my love to a company of horses in pharaohs chariots\"\n    \"thy cheeks are comely with rows of jewels thy neck with chains of gold\"\n    \"we will make thee borders of gold with studs of silver\"\n    \"while the king sitteth at his table my spikenard sendeth forth the smell thereof\"\n    \"a bundle of myrrh is my wellbeloved unto me he shall lie all night betwixt my breasts\"\n    \"my beloved is unto me as a cluster of camphire in the vineyards of en gedi\"\n    \"behold thou art fair my love behold thou art fair thou hast doves eyes\"\n    \"behold thou art fair my beloved yea pleasant also our bed is green\"\n    \"the beams of our house are cedar and our rafters of fir\"\n  } {\n    execsql {INSERT INTO t1(a, b) VALUES($a, $b)}\n  }\n\n\n  do_fts3query_test 5.$tn.1.1 t1 {s*}\n  do_fts3query_test 5.$tn.1.2 t1 {so*}\n  do_fts3query_test 5.$tn.1.3 t1 {\"s* o*\"}\n  do_fts3query_test 5.$tn.1.4 t1 {b* NEAR/3 a*}\n  do_fts3query_test 5.$tn.1.5 t1 {a*}\n  do_fts3query_test 5.$tn.1.6 t1 {th* NEAR/5 a* NEAR/5 w*}\n  do_fts3query_test 5.$tn.1.7 t1 {\"b* th* art* fair*\"}\n\n  if {$pending} {execsql COMMIT}\n}\neval fts3_configure_incr_load $chunkconfig\n\nforeach {tn pending create} {\n  1    0 \"fts4(a, b, c, d)\"\n  2    1 \"fts4(a, b, c, d)\"\n  3    0 \"fts4(a, b, c, d, order=DESC)\"\n  4    1 \"fts4(a, b, c, d, order=DESC)\"\n} {\n  execsql [subst {\n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING $create;\n  }]\n\n\n  if {$pending} { execsql BEGIN }\n\n  foreach {a b c d} {\n    \"A B C\" \"D E F\" \"G H I\" \"J K L\"\n    \"B C D\" \"E F G\" \"H I J\" \"K L A\"\n    \"C D E\" \"F G H\" \"I J K\" \"L A B\"\n    \"D E F\" \"G H I\" \"J K L\" \"A B C\"\n    \"E F G\" \"H I J\" \"K L A\" \"B C D\"\n    \"F G H\" \"I J K\" \"L A B\" \"C D E\"\n  } {\n    execsql { INSERT INTO t1 VALUES($a, $b, $c, $d) }\n  }\n\n  do_fts3query_test 6.$tn.1 t1 {b:G}\n  do_fts3query_test 6.$tn.2 t1 {b:G AND c:I}\n  do_fts3query_test 6.$tn.3 t1 {b:G NEAR c:I}\n  do_fts3query_test 6.$tn.4 t1 {a:C OR b:G OR c:K OR d:C}\n\n  do_fts3query_test 6.$tn.5 t1 {a:G OR b:G}\n\n  catchsql { COMMIT }\n}\n\nforeach {tn create} {\n  1    \"fts4(x)\"\n  2    \"fts4(x, order=DESC)\"\n} {\n  execsql [subst {\n    DROP TABLE IF EXISTS t1;\n    CREATE VIRTUAL TABLE t1 USING $create;\n  }]\n\n  foreach {x} {\n    \"F E N O T K X V A X I E X A P G Q V H U\"\n    \"R V A E T C V Q N I E L O N U G J K L U\"\n    \"U Y I G W M V F J L X I D C H F P J Q B\"\n    \"S G D Z X R P G S S Y B K A S G A I L L\"\n    \"L S I C H T Z S R Q P R N K J X L F M J\"\n    \"C C C D P X B Z C M A D A C X S B T X V\"\n    \"W Y J M D R G V R K B X S A W R I T N C\"\n    \"P K L W T M S P O Y Y V V O E H Q A I R\"\n    \"C D Y I C Z F H J C O Y A Q F L S B D K\"\n    \"P G S C Y C Y V I M B D S Z D D Y W I E\"\n    \"Z K Z U E E S F Y X T U A L W O U J C Q\"\n    \"P A T Z S W L P L Q V Y Y I P W U X S S\"\n    \"I U I H U O F Z F R H R F T N D X A G M\"\n    \"N A B M S H K X S O Y D T X S B R Y H Z\"\n    \"L U D A S K I L S V Z J P U B E B Y H M\"\n  } {\n    execsql { INSERT INTO t1 VALUES($x) }\n  }\n\n  # Add extra documents to the database such that token \"B\" will be considered\n  # deferrable if considering the other tokens means that 2 or fewer documents\n  # will be loaded into memory.\n  #\n  fts3_make_deferrable t1 B 2\n\n  # B is not deferred in either of the first two tests below, since filtering\n  # on \"M\" or \"D\" returns 10 documents or so. But filtering on \"M * D\" only\n  # returns 2, so B is deferred in this case.\n  #\n  do_fts3query_test 7.$tn.1             t1 {\"M B\"}\n  do_fts3query_test 7.$tn.2             t1 {\"B D\"}\n  do_fts3query_test 7.$tn.3 -deferred B t1 {\"M B D\"}\n}\n\nset sqlite_fts3_enable_parentheses $sfep\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3aux1.test",
    "content": "# 2011 January 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3 { finish_test ; return }\nset ::testprefix fts3aux1\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4;\n  INSERT INTO t1 VALUES('one two three four');\n  INSERT INTO t1 VALUES('three four five six');\n  INSERT INTO t1 VALUES('one three five seven');\n\n  CREATE VIRTUAL TABLE terms USING fts4aux(t1);\n  SELECT term, documents, occurrences FROM terms WHERE col = '*';\n} {\n  five  2 2     four  2 2     one   2 2     seven 1 1 \n  six   1 1     three 3 3     two   1 1\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1 VALUES('one one one three three three');\n  SELECT term, documents, occurrences FROM terms WHERE col = '*';\n} { \n  five  2 2     four  2 2     one   3 5     seven 1 1 \n  six   1 1     three 4 6     two   1 1\n}\n\ndo_execsql_test 1.3.1 { DELETE FROM t1; }\ndo_execsql_test 1.3.2 {\n  SELECT term, documents, occurrences FROM terms WHERE col = '*';\n}\n\ndo_execsql_test 1.4 {\n  INSERT INTO t1 VALUES('a b a b a b a');\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  SELECT term, documents, occurrences FROM terms WHERE col = '*';\n} {a 256 1024    b 256 768}\n\n#-------------------------------------------------------------------------\n# The following tests verify that the fts4aux module uses the full-text\n# index to reduce the number of rows scanned in the following circumstances:\n#\n#   * when there is equality comparison against the term column using the \n#     BINARY collating sequence. \n#\n#   * when there is a range constraint on the term column using the BINARY \n#     collating sequence. \n#\n# And also uses the full-text index to optimize ORDER BY clauses of the \n# form \"ORDER BY term ASC\" or equivalent.\n#\n# Test organization is:\n#\n#   fts3aux1-2.1.*: equality constraints.\n#   fts3aux1-2.2.*: range constraints.\n#   fts3aux1-2.3.*: ORDER BY optimization.\n# \n\ndo_execsql_test 2.0 {\n  DROP TABLE t1;\n  DROP TABLE terms;\n\n  CREATE VIRTUAL TABLE x1 USING fts4(x);\n  INSERT INTO x1(x1) VALUES('nodesize=24');\n  CREATE VIRTUAL TABLE terms USING fts4aux(x1);\n\n  CREATE VIEW terms_v AS \n  SELECT term, documents, occurrences FROM terms WHERE col = '*';\n\n  INSERT INTO x1 VALUES('braes brag bragged bragger bragging');\n  INSERT INTO x1 VALUES('brags braid braided braiding braids');\n  INSERT INTO x1 VALUES('brain brainchild brained braining brains');\n  INSERT INTO x1 VALUES('brainstem brainstems brainstorm brainstorms'); \n}\n\nproc rec {varname x} {\n  global $varname\n  incr $varname\n  return 1\n}\ndb func rec rec\n\n# Use EQP to show that the WHERE expression \"term='braid'\" uses a different\n# index number (1) than \"+term='braid'\" (0).\n#\ndo_execsql_test 2.1.1.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term='braid'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:} }\ndo_execsql_test 2.1.1.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term='braid'\n} {0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}}\n\n# Now show that using \"term='braid'\" means the virtual table returns\n# only 1 row to SQLite, but \"+term='braid'\" means all 19 are returned.\n#\ndo_test 2.1.2.1 {\n  set cnt 0\n  execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND term='braid' }\n  set cnt\n} {1}\ndo_test 2.1.2.2 {\n  set cnt 0\n  execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND +term='braid' }\n  set cnt\n} {19}\n\n# Similar to the test immediately above, but using a term (\"breakfast\") that \n# is not featured in the dataset.\n#\ndo_test 2.1.3.1 {\n  set cnt 0\n  execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND term='breakfast' }\n  set cnt\n} {0}\ndo_test 2.1.3.2 {\n  set cnt 0\n  execsql { SELECT * FROM terms_v WHERE rec('cnt', term) AND +term='breakfast' }\n  set cnt\n} {19}\n\ndo_execsql_test 2.1.4.1 { SELECT * FROM terms_v WHERE term='braid' } {braid 1 1}\ndo_execsql_test 2.1.4.2 { SELECT * FROM terms_v WHERE +term='braid'} {braid 1 1}\ndo_execsql_test 2.1.4.3 { SELECT * FROM terms_v WHERE term='breakfast'  } {}\ndo_execsql_test 2.1.4.4 { SELECT * FROM terms_v WHERE +term='breakfast' } {}\n\ndo_execsql_test 2.1.4.5 { SELECT * FROM terms_v WHERE term='cba'  } {}\ndo_execsql_test 2.1.4.6 { SELECT * FROM terms_v WHERE +term='cba' } {}\ndo_execsql_test 2.1.4.7 { SELECT * FROM terms_v WHERE term='abc'  } {}\ndo_execsql_test 2.1.4.8 { SELECT * FROM terms_v WHERE +term='abc' } {}\n\n# Special case: term=NULL\n#\ndo_execsql_test 2.1.5 { SELECT * FROM terms WHERE term=NULL } {}\n\ndo_execsql_test 2.2.1.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term>'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 2:} }\ndo_execsql_test 2.2.1.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term>'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }\n\ndo_execsql_test 2.2.1.3 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term<'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 4:} }\ndo_execsql_test 2.2.1.4 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term<'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }\n\ndo_execsql_test 2.2.1.5 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE term BETWEEN 'brags' AND 'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 6:} }\ndo_execsql_test 2.2.1.6 {\n  EXPLAIN QUERY PLAN SELECT * FROM terms WHERE +term BETWEEN 'brags' AND 'brain'\n} { 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} }\n\ndo_test 2.2.2.1 {\n  set cnt 0\n  execsql { SELECT * FROM terms WHERE rec('cnt', term) AND term>'brain' }\n  set cnt\n} {18}\ndo_test 2.2.2.2 {\n  set cnt 0\n  execsql { SELECT * FROM terms WHERE rec('cnt', term) AND +term>'brain' }\n  set cnt\n} {38}\ndo_execsql_test 2.2.2.3 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term>'brain'\n} {\n  brainchild 1 1 brained 1 1 braining 1 1 brains 1 1 \n  brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\ndo_execsql_test 2.2.2.4 {\n  SELECT term, documents, occurrences FROM terms_v WHERE +term>'brain'\n} {\n  brainchild 1 1 brained 1 1 braining 1 1 brains 1 1 \n  brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\ndo_execsql_test 2.2.2.5 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term>='brain'\n} {\n  brain 1 1\n  brainchild 1 1 brained 1 1 braining 1 1 brains 1 1 \n  brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\ndo_execsql_test 2.2.2.6 {\n  SELECT term, documents, occurrences FROM terms_v WHERE +term>='brain'\n} {\n  brain 1 1\n  brainchild 1 1 brained 1 1 braining 1 1 brains 1 1 \n  brainstem 1 1 brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\n\ndo_execsql_test 2.2.2.7 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term>='abc'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 \n  bragging 1 1 brags 1 1 braid 1 1 braided 1 1 \n  braiding 1 1 braids 1 1 brain 1 1 brainchild 1 1 \n  brained 1 1 braining 1 1 brains 1 1 brainstem 1 1 \n  brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\ndo_execsql_test 2.2.2.8 {\n  SELECT term, documents, occurrences FROM terms_v WHERE +term>='abc'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 \n  bragging 1 1 brags 1 1 braid 1 1 braided 1 1 \n  braiding 1 1 braids 1 1 brain 1 1 brainchild 1 1 \n  brained 1 1 braining 1 1 brains 1 1 brainstem 1 1 \n  brainstems 1 1 brainstorm 1 1 brainstorms 1 1\n}\n\ndo_execsql_test 2.2.2.9 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term>='brainstorms'\n} {brainstorms 1 1}\ndo_execsql_test 2.2.2.10 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term>='brainstorms'\n} {brainstorms 1 1}\ndo_execsql_test 2.2.2.11 { SELECT * FROM terms_v WHERE term>'brainstorms' } {}\ndo_execsql_test 2.2.2.12 { SELECT * FROM terms_v WHERE term>'brainstorms' } {}\n\ndo_execsql_test 2.2.2.13 { SELECT * FROM terms_v WHERE term>'cba' } {}\ndo_execsql_test 2.2.2.14 { SELECT * FROM terms_v WHERE term>'cba' } {}\n\ndo_test 2.2.3.1 {\n  set cnt 0\n  execsql { SELECT * FROM terms WHERE rec('cnt', term) AND term<'brain' }\n  set cnt\n} {22}\ndo_test 2.2.3.2 {\n  set cnt 0\n  execsql { SELECT * FROM terms WHERE rec('cnt', term) AND +term<'brain' }\n  set cnt\n} {38}\ndo_execsql_test 2.2.3.3 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term<'brain'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1 \n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n}\ndo_execsql_test 2.2.3.4 {\n  SELECT term, documents, occurrences FROM terms_v WHERE +term<'brain'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1 \n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n}\ndo_execsql_test 2.2.3.5 {\n  SELECT term, documents, occurrences FROM terms_v WHERE term<='brain'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1 \n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n  brain 1 1\n}\ndo_execsql_test 2.2.3.6 {\n  SELECT term, documents, occurrences FROM terms_v WHERE +term<='brain'\n} {\n  braes 1 1 brag 1 1 bragged 1 1 bragger 1 1 bragging 1 1 \n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n  brain 1 1\n}\n\ndo_test 2.2.4.1 {\n  set cnt 0\n  execsql { \n    SELECT term, documents, occurrences FROM terms \n    WHERE rec('cnt', term) AND term BETWEEN 'brags' AND 'brain' \n  }\n  set cnt\n} {12}\ndo_test 2.2.4.2 {\n  set cnt 0\n  execsql { \n    SELECT term, documents, occurrences FROM terms \n    WHERE rec('cnt', term) AND +term BETWEEN 'brags' AND 'brain' \n  }\n  set cnt\n} {38}\ndo_execsql_test 2.2.4.3 {\n  SELECT term, documents, occurrences FROM terms_v \n  WHERE rec('cnt', term) AND term BETWEEN 'brags' AND 'brain' \n} {\n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1 brain 1 1 \n}\ndo_execsql_test 2.2.4.4 {\n  SELECT term, documents, occurrences FROM terms_v \n  WHERE rec('cnt', term) AND +term BETWEEN 'brags' AND 'brain' \n} {\n  brags 1 1 braid 1 1 braided 1 1 braiding 1 1 braids 1 1 brain 1 1 \n}\ndo_execsql_test 2.2.4.5 {\n  SELECT term, documents, occurrences FROM terms_v \n  WHERE rec('cnt', term) AND term > 'brags' AND term < 'brain' \n} {\n  braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n}\ndo_execsql_test 2.2.4.6 {\n  SELECT term, documents, occurrences FROM terms_v \n  WHERE rec('cnt', term) AND +term > 'brags' AND +term < 'brain' \n} {\n  braid 1 1 braided 1 1 braiding 1 1 braids 1 1\n}\n\n# Check that \"ORDER BY term ASC\" and equivalents are sorted by the\n# virtual table implementation. Any other ORDER BY clause requires\n# SQLite to sort results using a temporary b-tree.\n#\nforeach {tn sort orderby} {\n  1    0    \"ORDER BY term ASC\"\n  2    0    \"ORDER BY term\"\n  3    1    \"ORDER BY term DESC\"\n  4    1    \"ORDER BY documents ASC\"\n  5    1    \"ORDER BY documents\"\n  6    1    \"ORDER BY documents DESC\"\n  7    1    \"ORDER BY occurrences ASC\"\n  8    1    \"ORDER BY occurrences\"\n  9    1    \"ORDER BY occurrences DESC\"\n} {\n\n  set res [list 0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:}]\n  if {$sort} { lappend res 0 0 0 {USE TEMP B-TREE FOR ORDER BY} }\n\n  set sql \"SELECT * FROM terms $orderby\"\n  do_execsql_test 2.3.1.$tn \"EXPLAIN QUERY PLAN $sql\" $res\n}\n\n#-------------------------------------------------------------------------\n# The next set of tests, fts3aux1-3.*, test error conditions in the \n# fts4aux module. Except, fault injection testing (OOM, IO error etc.) is \n# done in fts3fault2.test\n#\n\ndo_execsql_test 3.1.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4;\n}\n\ndo_catchsql_test 3.1.2 {\n  CREATE VIRTUAL TABLE terms2 USING fts4aux;\n} {1 {invalid arguments to fts4aux constructor}}\ndo_catchsql_test 3.1.3 {\n  CREATE VIRTUAL TABLE terms2 USING fts4aux(t2, t2);\n} {1 {invalid arguments to fts4aux constructor}}\n\ndo_execsql_test 3.2.1 {\n  CREATE VIRTUAL TABLE terms3 USING fts4aux(does_not_exist)\n}\ndo_catchsql_test 3.2.2 {\n  SELECT * FROM terms3\n} {1 {SQL logic error}}\ndo_catchsql_test 3.2.3 {\n  SELECT * FROM terms3 WHERE term = 'abc'\n} {1 {SQL logic error}}\n\ndo_catchsql_test 3.3.1 {\n  INSERT INTO terms VALUES(1,2,3);\n} {1 {table terms may not be modified}}\ndo_catchsql_test 3.3.2 {\n  DELETE FROM terms\n} {1 {table terms may not be modified}}\ndo_catchsql_test 3.3.3 {\n  UPDATE terms set documents = documents+1;\n} {1 {table terms may not be modified}}\n\n\n#-------------------------------------------------------------------------\n# The following tests - fts4aux-4.* - test that joins work with fts4aux\n# tables. And that fts4aux provides reasonably sane cost information via\n# xBestIndex to the query planner.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE x1 USING fts4(x);\n  CREATE VIRTUAL TABLE terms USING fts4aux(x1);\n  CREATE TABLE x2(y);\n  CREATE TABLE x3(y);\n  CREATE INDEX i1 ON x3(y);\n\n  INSERT INTO x1 VALUES('a b c d e');\n  INSERT INTO x1 VALUES('f g h i j');\n  INSERT INTO x1 VALUES('k k l l a');\n\n  INSERT INTO x2 SELECT term FROM terms WHERE col = '*';\n  INSERT INTO x3 SELECT term FROM terms WHERE col = '*';\n}\n\nproc do_plansql_test {tn sql r} {\n  uplevel do_execsql_test $tn [list \"EXPLAIN QUERY PLAN $sql ; $sql\"] [list $r]\n}\n\ndo_plansql_test 4.2 {\n  SELECT y FROM x2, terms WHERE y = term AND col = '*'\n} {\n  0 0 0 {SCAN TABLE x2} \n  0 1 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:} \n  a b c d e f g h i j k l\n}\n\ndo_plansql_test 4.3 {\n  SELECT y FROM terms, x2 WHERE y = term AND col = '*'\n} {\n  0 0 1 {SCAN TABLE x2} \n  0 1 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 1:} \n  a b c d e f g h i j k l\n}\n\ndo_plansql_test 4.4 {\n  SELECT y FROM x3, terms WHERE y = term AND col = '*'\n} {\n  0 0 1 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} \n  0 1 0 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?)}\n  a b c d e f g h i j k l\n}\n\ndo_plansql_test 4.5 {\n  SELECT y FROM terms, x3 WHERE y = term AND occurrences>1 AND col = '*'\n} {\n  0 0 0 {SCAN TABLE terms VIRTUAL TABLE INDEX 0:} \n  0 1 1 {SEARCH TABLE x3 USING COVERING INDEX i1 (y=?)}\n  a k l\n}\n\n#-------------------------------------------------------------------------\n# The following tests check that fts4aux can handle an fts table with an\n# odd name (one that requires quoting for use in SQL statements). And that\n# the argument to the fts4aux constructor is properly dequoted before use.\n#\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE \"abc '!' def\" USING fts4(x, y);\n  INSERT INTO \"abc '!' def\" VALUES('XX', 'YY');\n\n  CREATE VIRTUAL TABLE terms3 USING fts4aux(\"abc '!' def\");\n  SELECT * FROM terms3;\n} {xx * 1 1 xx 0 1 1 yy * 1 1 yy 1 1 1}\n\ndo_execsql_test 5.2 {\n  CREATE VIRTUAL TABLE \"%%^^%%\" USING fts4aux('abc ''!'' def');\n  SELECT * FROM \"%%^^%%\";\n} {xx * 1 1 xx 0 1 1 yy * 1 1 yy 1 1 1}\n\n#-------------------------------------------------------------------------\n# Test that we can create an fts4aux table in the temp database.\n#\nforcedelete test.db2\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts4(x, y);\n  INSERT INTO ft1 VALUES('a b', 'c d');\n  INSERT INTO ft1 VALUES('e e', 'c d');\n  INSERT INTO ft1 VALUES('a a', 'b b');\n  CREATE VIRTUAL TABLE temp.aux1 USING fts4aux(main, ft1);\n  SELECT * FROM aux1;\n} {\n    a * 2 3 a 0 2 3 \n    b * 2 3 b 0 1 1 b 1 1 2 \n    c * 2 2 c 1 2 2 \n    d * 2 2 d 1 2 2 \n    e * 1 2 e 0 1 2\n}\n\ndo_execsql_test 6.2 {\n  ATTACH 'test.db2' AS att;\n  CREATE VIRTUAL TABLE att.ft1 USING fts4(x, y);\n  INSERT INTO att.ft1 VALUES('v w', 'x y');\n  INSERT INTO att.ft1 VALUES('z z', 'x y');\n  INSERT INTO att.ft1 VALUES('v v', 'w w');\n  CREATE VIRTUAL TABLE temp.aux2 USING fts4aux(att, ft1);\n  SELECT * FROM aux2;\n} {\n    v * 2 3 v 0 2 3 \n    w * 2 3 w 0 1 1 w 1 1 2 \n    x * 2 2 x 1 2 2 \n    y * 2 2 y 1 2 2 \n    z * 1 2 z 0 1 2\n}\n\nforeach {tn q res1 res2} {\n  1  { SELECT * FROM %%% WHERE term = 'a' } {a * 2 3 a 0 2 3} {}\n  2  { SELECT * FROM %%% WHERE term = 'x' } {} {x * 2 2 x 1 2 2} \n\n  3  { SELECT * FROM %%% WHERE term >= 'y' } \n     {} {y * 2 2 y 1 2 2 z * 1 2 z 0 1 2}\n\n  4  { SELECT * FROM %%% WHERE term <= 'c' } \n     {a * 2 3 a 0 2 3 b * 2 3 b 0 1 1 b 1 1 2 c * 2 2 c 1 2 2} {}\n} {\n  set sql1 [string map {%%% aux1} $q]\n  set sql2 [string map {%%% aux2} $q]\n\n  do_execsql_test 7.$tn.1 $sql1 $res1\n  do_execsql_test 7.$tn.2 $sql2 $res2\n}\n\ndo_test 8.1 {\n  catchsql { CREATE VIRTUAL TABLE att.aux3 USING fts4aux(main, ft1) }\n} {1 {invalid arguments to fts4aux constructor}}\n\ndo_test 8.2 {\n  execsql {DETACH att}\n  catchsql { SELECT * FROM aux2 }\n} {1 {SQL logic error}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3aux2.test",
    "content": "# 2011 January 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3 { finish_test ; return }\nset ::testprefix fts3aux2\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=l);\n  INSERT INTO t1(a, b, l) VALUES\n    ('zero zero', 'zero zero', 0),\n    ('one two', 'three four', 1),\n    ('five six', 'seven eight', 2)\n  ;\n  CREATE VIRTUAL TABLE terms USING fts4aux(t1);\n} {}\n\ndo_execsql_test 1.2.1 {\n  SELECT term, documents, occurrences, languageid FROM terms WHERE col = '*';\n} {zero 1 4 0}\n\ndo_execsql_test 1.2.2 {\n  SELECT * FROM terms;\n} {zero * 1 4 zero 0 1 2 zero 1 1 2}\n\ndo_execsql_test 1.2.3 {\n  SELECT * FROM terms WHERE languageid='';\n} {}\n\ndo_execsql_test 1.2.4 {\n  SELECT * FROM terms WHERE languageid=-1;\n} {}\n\ndo_execsql_test 1.2.5 {\n  SELECT * FROM terms WHERE languageid=9223372036854775807;\n} {}\n\ndo_execsql_test 1.2.6 {\n  SELECT * FROM terms WHERE languageid=-9223372036854775808;\n} {}\n\ndo_execsql_test 1.2.7 {\n  SELECT * FROM terms WHERE languageid=NULL;\n} {}\n\ndo_execsql_test 1.3.1 {\n  SELECT term, documents, occurrences, languageid \n  FROM terms WHERE col = '*' AND languageid=1;\n} {\n  four 1 1 1 one 1 1 1 three 1 1 1 two 1 1 1 \n}\n\ndo_execsql_test 1.3.2 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid=1;\n} {\n  four * 1 1 1   four 1 1 1 1 \n  one * 1 1 1    one 0 1 1 1 \n  three * 1 1 1  three 1 1 1 1 \n  two * 1 1 1    two 0 1 1 1 \n}\n\ndo_execsql_test 1.3.3 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid=1 AND term='zero'\n} {\n}\n\ndo_execsql_test 1.3.4 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid='1' AND term='two'\n} {\n  two * 1 1 1    two 0 1 1 1 \n}\n\ndo_execsql_test 1.3.5 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid='+1' AND term>'four'\n} {\n  one * 1 1 1    one 0 1 1 1 \n  three * 1 1 1  three 1 1 1 1 \n  two * 1 1 1    two 0 1 1 1 \n}\n\ndo_execsql_test 1.4.1 {\n  SELECT term, documents, occurrences, languageid \n  FROM terms WHERE col = '*' AND languageid=2;\n} {\n  eight 1 1 2 five 1 1 2 seven 1 1 2 six 1 1 2\n}\n\ndo_execsql_test 1.4.2 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid=2;\n} {\n  eight * 1 1 2    eight 1 1 1 2 \n  five * 1 1 2     five 0 1 1 2 \n  seven * 1 1 2    seven 1 1 1 2 \n  six * 1 1 2      six 0 1 1 2\n}\n\ndo_execsql_test 1.4.3 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE languageid=2 AND term='five';\n} {\n  five * 1 1 2     five 0 1 1 2 \n}\n\ndo_execsql_test 1.4.4 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE term='five' AND languageid=2 \n} {\n  five * 1 1 2     five 0 1 1 2 \n}\n\ndo_execsql_test 1.4.5 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE term>='seven' AND languageid=2\n} {\n  seven * 1 1 2    seven 1 1 1 2 \n  six * 1 1 2      six 0 1 1 2\n}\n\ndo_execsql_test 1.4.6 {\n  SELECT term, col, documents, occurrences, languageid \n  FROM terms WHERE term>='e' AND term<'seven' AND languageid=2\n} {\n  eight * 1 1 2    eight 1 1 1 2 \n  five * 1 1 2     five 0 1 1 2 \n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3b.test",
    "content": "# 2007 August 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  This\n# script tests for the fts2 rowid-versus-vacuum problem (ticket #2566).\n#\n# $Id: fts3b.test,v 1.3 2007/09/13 18:14:49 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (c) VALUES('this is a test');\n  INSERT INTO t1 (c) VALUES('that was a test');\n  INSERT INTO t1 (c) VALUES('this is fun');\n  DELETE FROM t1 WHERE c = 'that was a test';\n}\n\n# Baseline test.\ndo_test fts3b-1.1 {\n  execsql {\n    SELECT rowid FROM t1 WHERE c MATCH 'this';\n  }\n} {1 3}\n\ndb eval {VACUUM}\n\n# The VACUUM renumbered the t1_content table in fts2, which breaks\n# this.\ndo_test fts3b-1.2 {\n  execsql {\n    SELECT rowid FROM t1 WHERE c MATCH 'this';\n  }\n} {1 3}\n\n# The t2 table is unfortunately pretty contrived.  We need documents\n# that are bigger than ROOT_MAX (1024) to force segments out of the\n# segdir and into %_segments.  We also need to force segment merging\n# to generate a hole in the %_segments table, which needs more than 16\n# docs.  Beyond that, to test correct operation of BLOCK_SELECT_STMT,\n# we need to merge a mult-level tree, which is where the 10,000 comes\n# from.  Which is slow, thus the set of transactions, with the 500\n# being a number such that 10,000/500 > 16.\nset text {\n  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas\n  iaculis mollis ipsum. Praesent rhoncus placerat justo. Duis non quam\n  sed turpis posuere placerat. Curabitur et lorem in lorem porttitor\n  aliquet. Pellentesque bibendum tincidunt diam. Vestibulum blandit\n  ante nec elit. In sapien diam, facilisis eget, dictum sed, viverra\n  at, felis. Vestibulum magna. Sed magna dolor, vestibulum rhoncus,\n  ornare vel, vulputate sit amet, felis. Integer malesuada, tellus at\n  luctus gravida, diam nunc porta nibh, nec imperdiet massa metus eu\n  lectus. Aliquam nisi. Nunc fringilla nulla at lectus. Suspendisse\n  potenti. Cum sociis natoque penatibus et magnis dis parturient\n  montes, nascetur ridiculus mus. Pellentesque odio nulla, feugiat eu,\n  suscipit nec, consequat quis, risus.\n}\nappend text $text\n\ndb eval {CREATE VIRTUAL TABLE t2 USING fts3(c)}\nset res {}\ndb eval {BEGIN}\nfor {set ii 0} {$ii<10000} {incr ii} {\n  db eval {INSERT INTO t2 (c) VALUES ($text)}\n  lappend res [expr {$ii+1}]\n  if {($ii%500)==0} {\n    db eval {\n      COMMIT;\n      BEGIN;\n    }\n  }\n}\ndb eval {COMMIT}\n\ndo_test fts3b-2.1 {\n  execsql {\n    SELECT rowid FROM t2 WHERE c MATCH 'lorem';\n  }\n} $res\n\ndb eval {VACUUM}\n\n# The VACUUM renumbered the t2_segment table in fts2, which would\n# break the following.\ndo_test fts3b-2.2 {\n  execsql {\n    SELECT rowid FROM t2 WHERE c MATCH 'lorem';\n  }\n} $res\n\n# Since fts3 is already an API break, I've marked the table-named\n# column HIDDEN.\n\ndb eval {\n  CREATE VIRTUAL TABLE t3 USING fts3(c);\n  INSERT INTO t3 (c) VALUES('this is a test');\n  INSERT INTO t3 (c) VALUES('that was a test');\n  INSERT INTO t3 (c) VALUES('this is fun');\n  DELETE FROM t3 WHERE c = 'that was a test';\n}\n\n# Test that the table-named column still works.\ndo_test fts3b-3.1 {\n  execsql {\n    SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'test';\n  }\n} {{this is a <b>test</b>}}\n\n# Test that the column doesn't appear when selecting all columns.\ndo_test fts3b-3.2 {\n  execsql {\n    SELECT * FROM t3 WHERE rowid = 1;\n  }\n} {{this is a test}}\n\n# Test that the column doesn't conflict with inserts that don't name\n# columns.\ndo_test fts3b-3.3 {\n  execsql {\n    INSERT INTO t3 VALUES ('another test');\n  }\n} {}\n\n# fts3 adds a new implicit column, docid, which acts as an alias for\n# rowid.\n\ndb eval {\n  CREATE VIRTUAL TABLE t4 USING fts3(c);\n  INSERT INTO t4 (c) VALUES('this is a test');\n  INSERT INTO t4 (c) VALUES('that was a test');\n  INSERT INTO t4 (c) VALUES('this is fun');\n  DELETE FROM t4 WHERE c = 'that was a test';\n}\n\n# Test that docid is present and identical to rowid.\ndo_test fts3b-4.1 {\n  execsql {\n    SELECT rowid FROM t4 WHERE rowid <> docid;\n  }\n} {}\n\n# Test that docid is hidden.\ndo_test fts3b-4.2 {\n  execsql {\n    SELECT * FROM t4 WHERE rowid = 1;\n  }\n} {{this is a test}}\n\n# Test that docid can be selected.\ndo_test fts3b-4.3 {\n  execsql {\n    SELECT docid, * FROM t4 WHERE rowid = 1;\n  }\n} {1 {this is a test}}\n\n# Test that docid can be used in WHERE.\ndo_test fts3b-4.4 {\n  execsql {\n    SELECT docid, * FROM t4 WHERE docid = 1;\n  }\n} {1 {this is a test}}\n\n# Test that the column doesn't conflict with inserts that don't name\n# columns.  [Yes, this is the same as fts3b-3.3, here just in case the\n# goals of that test change.]\ndo_test fts3b-4.5 {\n  execsql {\n    INSERT INTO t4 VALUES ('another test');\n  }\n} {}\n\n# Test that the docid can be forced on insert.\ndo_test fts3b-4.6 {\n  execsql {\n    INSERT INTO t4 (docid, c) VALUES (10, 'yet another test');\n    SELECT * FROM t4 WHERE docid = 10;\n  }\n} {{yet another test}}\n\n# Test that rowid can also be forced.\ndo_test fts3b-4.7 {\n  execsql {\n    INSERT INTO t4 (docid, c) VALUES (12, 'still testing');\n    SELECT * FROM t4 WHERE docid = 12;\n  }\n} {{still testing}}\n\n# If an insert tries to set both docid and rowid, require an error.\ndo_test fts3b-4.8 {\n  catchsql {\n    INSERT INTO t4 (rowid, docid, c) VALUES (14, 15, 'bad test');\n    SELECT * FROM t4 WHERE docid = 14;\n  }\n} {1 {SQL logic error}}\n\ndo_test fts3b-4.9 {\n  execsql { SELECT docid FROM t4 WHERE t4 MATCH 'testing' }\n} {12}\ndo_test fts3b-4.10 {\n  execsql { \n    UPDATE t4 SET docid = 14 WHERE docid = 12;\n    SELECT docid FROM t4 WHERE t4 MATCH 'testing';\n  }\n} {14}\ndo_test fts3b-4.11 {\n  execsql { SELECT * FROM t4 WHERE rowid = 14; }\n} {{still testing}}\ndo_test fts3b-4.12 {\n  execsql { SELECT * FROM t4 WHERE rowid = 12; }\n} {}\ndo_test fts3b-4.13 {\n  execsql { SELECT docid FROM t4 WHERE t4 MATCH 'still'; }\n} {14}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3c.test",
    "content": "# 2008 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file exercises some new testing functions in the FTS3 module,\n# and then uses them to do some basic tests that FTS3 is internally\n# working as expected.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Utility function to check for the expected terms in the segment\n# level/index.  _all version does same but for entire index.\nproc check_terms {test level index terms} {\n  set where \"level = $level AND idx = $index\"\n  do_test $test.terms [list fts3_terms t1 $where] $terms\n}\nproc check_terms_all {test terms} {\n  do_test $test.terms [list fts3_terms t1 1] $terms\n}\n\n# Utility function to check for the expected doclist for the term in\n# segment level/index.  _all version does same for entire index.\nproc check_doclist {test level index term doclist} {\n  set where \"level = $level AND idx = $index\"\n  do_test $test [list fts3_doclist t1 $term $where] $doclist\n}\nproc check_doclist_all {test term doclist} {\n  do_test $test [list fts3_doclist t1 $term 1] $doclist\n}\n\n#*************************************************************************\n# Test the segments resulting from straight-forward inserts.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n}\n\n# Check for expected segments and expected matches.\ndo_test fts3c-1.0.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2}\ndo_test fts3c-1.0.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\n# Check the specifics of the segments constructed.\n# Logical view of entire index.\ncheck_terms_all   fts3c-1.0.1   {a is test that this was}\ncheck_doclist_all fts3c-1.0.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts3c-1.0.1.2 is {[1 0[1]] [3 0[1]]}\ncheck_doclist_all fts3c-1.0.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts3c-1.0.1.4 that {[2 0[0]]}\ncheck_doclist_all fts3c-1.0.1.5 this {[1 0[0]] [3 0[0]]}\ncheck_doclist_all fts3c-1.0.1.6 was {[2 0[1]]}\n\n# Segment 0,0\ncheck_terms   fts3c-1.0.2   0 0 {a is test this}\ncheck_doclist fts3c-1.0.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts3c-1.0.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts3c-1.0.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts3c-1.0.2.4 0 0 this {[1 0[0]]}\n\n# Segment 0,1\ncheck_terms   fts3c-1.0.3   0 1 {a test that was}\ncheck_doclist fts3c-1.0.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts3c-1.0.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts3c-1.0.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts3c-1.0.3.4 0 1 was {[2 0[1]]}\n\n# Segment 0,2\ncheck_terms   fts3c-1.0.4   0 2 {a is test this}\ncheck_doclist fts3c-1.0.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts3c-1.0.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts3c-1.0.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts3c-1.0.4.4 0 2 this {[3 0[0]]}\n\n#*************************************************************************\n# Test the segments resulting from inserts followed by a delete.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE docid = 1;\n}\n\ndo_test fts3c-1.1.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2 0 3}\ndo_test fts3c-1.1.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}\n\ncheck_terms_all fts3c-1.1.1 {a is test that this was}\ncheck_doclist_all fts3c-1.1.1.1 a {[2 0[2]] [3 0[2]]}\ncheck_doclist_all fts3c-1.1.1.2 is {[3 0[1]]}\ncheck_doclist_all fts3c-1.1.1.3 test {[2 0[3]] [3 0[3]]}\ncheck_doclist_all fts3c-1.1.1.4 that {[2 0[0]]}\ncheck_doclist_all fts3c-1.1.1.5 this {[3 0[0]]}\ncheck_doclist_all fts3c-1.1.1.6 was {[2 0[1]]}\n\ncheck_terms fts3c-1.1.2 0 0 {a is test this}\ncheck_doclist fts3c-1.1.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts3c-1.1.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts3c-1.1.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts3c-1.1.2.4 0 0 this {[1 0[0]]}\n\ncheck_terms fts3c-1.1.3 0 1 {a test that was}\ncheck_doclist fts3c-1.1.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts3c-1.1.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts3c-1.1.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts3c-1.1.3.4 0 1 was {[2 0[1]]}\n\ncheck_terms fts3c-1.1.4 0 2 {a is test this}\ncheck_doclist fts3c-1.1.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts3c-1.1.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts3c-1.1.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts3c-1.1.4.4 0 2 this {[3 0[0]]}\n\ncheck_terms fts3c-1.1.5 0 3 {a is test this}\ncheck_doclist fts3c-1.1.5.1 0 3 a {[1]}\ncheck_doclist fts3c-1.1.5.2 0 3 is {[1]}\ncheck_doclist fts3c-1.1.5.3 0 3 test {[1]}\ncheck_doclist fts3c-1.1.5.4 0 3 this {[1]}\n\n#*************************************************************************\n# Test results when all references to certain tokens are deleted.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE docid IN (1,3);\n}\n\n# Still 4 segments because 0,3 will contain deletes for docid 1 and 3.\ndo_test fts3c-1.2.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 0 2 0 3}\ndo_test fts3c-1.2.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts3c-1.2.1 {a is test that this was}\ncheck_doclist_all fts3c-1.2.1.1 a {[2 0[2]]}\ncheck_doclist_all fts3c-1.2.1.2 is {}\ncheck_doclist_all fts3c-1.2.1.3 test {[2 0[3]]}\ncheck_doclist_all fts3c-1.2.1.4 that {[2 0[0]]}\ncheck_doclist_all fts3c-1.2.1.5 this {}\ncheck_doclist_all fts3c-1.2.1.6 was {[2 0[1]]}\n\ncheck_terms fts3c-1.2.2 0 0 {a is test this}\ncheck_doclist fts3c-1.2.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts3c-1.2.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts3c-1.2.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts3c-1.2.2.4 0 0 this {[1 0[0]]}\n\ncheck_terms fts3c-1.2.3 0 1 {a test that was}\ncheck_doclist fts3c-1.2.3.1 0 1 a {[2 0[2]]}\ncheck_doclist fts3c-1.2.3.2 0 1 test {[2 0[3]]}\ncheck_doclist fts3c-1.2.3.3 0 1 that {[2 0[0]]}\ncheck_doclist fts3c-1.2.3.4 0 1 was {[2 0[1]]}\n\ncheck_terms fts3c-1.2.4 0 2 {a is test this}\ncheck_doclist fts3c-1.2.4.1 0 2 a {[3 0[2]]}\ncheck_doclist fts3c-1.2.4.2 0 2 is {[3 0[1]]}\ncheck_doclist fts3c-1.2.4.3 0 2 test {[3 0[3]]}\ncheck_doclist fts3c-1.2.4.4 0 2 this {[3 0[0]]}\n\ncheck_terms fts3c-1.2.5 0 3 {a is test this}\ncheck_doclist fts3c-1.2.5.1 0 3 a {[1] [3]}\ncheck_doclist fts3c-1.2.5.2 0 3 is {[1] [3]}\ncheck_doclist fts3c-1.2.5.3 0 3 test {[1] [3]}\ncheck_doclist fts3c-1.2.5.4 0 3 this {[1] [3]}\n\n#*************************************************************************\n# Test results when everything is optimized manually.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE docid IN (1,3);\n  DROP TABLE IF EXISTS t1old;\n  ALTER TABLE t1 RENAME TO t1old;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) SELECT docid, c FROM t1old;\n  DROP TABLE t1old;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts3c-1.3.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts3c-1.3.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts3c-1.3.1 {a test that was}\ncheck_doclist_all fts3c-1.3.1.1 a {[2 0[2]]}\ncheck_doclist_all fts3c-1.3.1.2 test {[2 0[3]]}\ncheck_doclist_all fts3c-1.3.1.3 that {[2 0[0]]}\ncheck_doclist_all fts3c-1.3.1.4 was {[2 0[1]]}\n\ncheck_terms fts3c-1.3.2 0 0 {a test that was}\ncheck_doclist fts3c-1.3.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts3c-1.3.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts3c-1.3.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts3c-1.3.2.4 0 0 was {[2 0[1]]}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3comp1.test",
    "content": "# 2011 January 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3 { finish_test ; return }\nset ::testprefix fts3comp1\n\n# Create a pretend compression system. \n#\n# Each time the [zip] function is called, an entry is added to the ::strings\n# array mapping from an integer key to the string argument to zip. The key\n# is returned. Later on, when the key is passed to [unzip], the original\n# string is retrieved from the ::strings array and returned.\n#\nset next_x 0\nproc zip {x} {\n incr ::next_x\n set ::strings($::next_x) $x\n return $::next_x\n}\nproc unzip {x} {\n  return $::strings($x)\n}\n\nforeach {tn zip unzip} {\n  1   zip   unzip\n  2   {z.i.p!!}    {un \"zip\"}\n} {\n\n  set next_x 0\n  catch {db close}\n  forcedelete test.db\n  sqlite3 db test.db\n  db func $zip zip\n  db func $unzip unzip\n  \n  # Create a table that uses zip/unzip. Check that content inserted into\n  # the table can be read back (using a full-scan query). Check that the\n  # underlying %_content table contains the compressed (integer) values.\n  #\n  do_execsql_test 1.$tn.0 \"\n    CREATE VIRTUAL TABLE t1 USING fts4(\n      a, b, \n      compress='$zip', uncompress='$unzip'\n    );\n  \"\n  do_execsql_test 1.$tn.1 {\n    INSERT INTO t1 VALUES('one two three', 'two four six');\n    SELECT a, b FROM t1;\n  } {{one two three} {two four six}}\n  do_execsql_test 1.$tn.2 {\n    SELECT c0a, c1b FROM t1_content;\n  } {1 2}\n  \n  # Insert another row and check that it can be read back. Also that the\n  # %_content table still contains all compressed content. This time, try\n  # full-text index and by-docid queries too.\n  #\n  do_execsql_test 1.$tn.3 {\n    INSERT INTO t1 VALUES('three six nine', 'four eight twelve');\n    SELECT a, b FROM t1;\n  } {{one two three} {two four six} {three six nine} {four eight twelve}}\n  do_execsql_test 1.$tn.4 {\n    SELECT c0a, c1b FROM t1_content;\n  } {1 2 3 4}\n  \n  do_execsql_test 1.$tn.5 {\n    SELECT a, b FROM t1 WHERE docid = 2\n  } {{three six nine} {four eight twelve}}\n  do_execsql_test 1.$tn.6 {\n    SELECT a, b FROM t1 WHERE t1 MATCH 'two'\n  } {{one two three} {two four six}}\n  \n  # Delete a row and check that the full-text index is correctly updated.\n  # Inspect the full-text index using an fts4aux table.\n  #\n  do_execsql_test 1.$tn.7 {\n    CREATE VIRTUAL TABLE terms USING fts4aux(t1);\n    SELECT term, documents, occurrences FROM terms WHERE col = '*';\n  } {\n    eight 1 1    four 2 2    nine 1 1    one 1 1 \n    six 2 2      three 2 2   twelve 1 1  two 1 2\n  }\n  do_execsql_test 1.$tn.8 {\n    DELETE FROM t1 WHERE docid = 1;\n    SELECT term, documents, occurrences FROM terms WHERE col = '*';\n  } {\n    eight 1 1   four 1 1    nine 1 1 \n    six 1 1     three 1 1   twelve 1 1\n  }\n  do_execsql_test 1.$tn.9 { SELECT c0a, c1b FROM t1_content } {3 4}\n}\n\n# Test that is an error to specify just one of compress and uncompress.\n#\ndo_catchsql_test 2.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(x, compress=zip)\n} {1 {missing uncompress parameter in fts4 constructor}}\ndo_catchsql_test 2.2 {\n  CREATE VIRTUAL TABLE t2 USING fts4(x, uncompress=unzip)\n} {1 {missing compress parameter in fts4 constructor}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3conf.test",
    "content": "# 2011 April 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3conf\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n\nproc fts3_integrity {tn db tbl} {\n\n  if {[sqlite3_get_autocommit $db]==0} {\n    error \"fts3_integrity does not work with an open transaction\"\n  }\n\n  set sql [db one {SELECT sql FROM sqlite_master WHERE name = $tbl}]\n  regexp -nocase {[^(]* using (.*)} $sql -> tail\n  set cols [list]\n  $db eval \"PRAGMA table_info($tbl)\" {\n    lappend cols $name\n  }\n  set cols [join [concat docid $cols] ,]\n\n  $db eval [subst {\n    CREATE VIRTUAL TABLE fts3check USING fts4term($tbl);\n    CREATE VIRTUAL TABLE temp.fts3check2 USING $tail;\n    INSERT INTO temp.fts3check2($cols) SELECT docid, * FROM $tbl;\n    CREATE VIRTUAL TABLE temp.fts3check3 USING fts4term(fts3check2);\n  }]\n\n  set m1 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check}]\n  set m2 [$db one {SELECT md5sum(term, docid, col, pos) FROM fts3check3}]\n\n  $db eval {\n    DROP TABLE fts3check;\n    DROP TABLE temp.fts3check2;\n    DROP TABLE temp.fts3check3;\n  }\n  \n  uplevel [list do_test $tn [list set {} $m1] $m2]\n}\n\ndo_execsql_test 1.0.1 {\n  CREATE VIRTUAL TABLE t1 USING fts3(x);\n  INSERT INTO t1(rowid, x) VALUES(1, 'a b c d');\n  INSERT INTO t1(rowid, x) VALUES(2, 'e f g h');\n\n  CREATE TABLE source(a, b);\n  INSERT INTO source VALUES(4, 'z');\n  INSERT INTO source VALUES(2, 'y');\n}\ndb_save_and_close\n\nset T1 \"INTO t1(rowid, x) VALUES(1, 'x')\"\nset T2 \"INTO t1(rowid, x) SELECT * FROM source\"\n\nset T3 \"t1 SET docid = 2 WHERE docid = 1\"\nset T4 \"t1 SET docid = CASE WHEN docid = 1 THEN 4 ELSE 3 END WHERE docid <=2\"\n\nforeach {tn sql uses constraint data} [subst {\n  1    \"INSERT OR ROLLBACK $T1\"   0 1 {{a b c d} {e f g h}}\n  2    \"INSERT OR ABORT    $T1\"   0 1 {{a b c d} {e f g h} {i j k l}}\n  3    \"INSERT OR FAIL     $T1\"   0 1 {{a b c d} {e f g h} {i j k l}}\n  4    \"INSERT OR IGNORE   $T1\"   0 0 {{a b c d} {e f g h} {i j k l}}\n  5    \"INSERT OR REPLACE  $T1\"   0 0 {x {e f g h} {i j k l}}\n\n  6    \"INSERT OR ROLLBACK $T2\"   1 1 {{a b c d} {e f g h}}\n  7    \"INSERT OR ABORT    $T2\"   1 1 {{a b c d} {e f g h} {i j k l}}\n  8    \"INSERT OR FAIL     $T2\"   1 1 {{a b c d} {e f g h} {i j k l} z}\n  9    \"INSERT OR IGNORE   $T2\"   1 0 {{a b c d} {e f g h} {i j k l} z}\n  10   \"INSERT OR REPLACE  $T2\"   1 0 {{a b c d} y {i j k l} z}\n\n  11   \"UPDATE OR ROLLBACK $T3\"   0 1 {{a b c d} {e f g h}}\n  12   \"UPDATE OR ABORT    $T3\"   0 1 {{a b c d} {e f g h} {i j k l}}\n  13   \"UPDATE OR FAIL     $T3\"   0 1 {{a b c d} {e f g h} {i j k l}}\n  14   \"UPDATE OR IGNORE   $T3\"   0 0 {{a b c d} {e f g h} {i j k l}}\n  15   \"UPDATE OR REPLACE  $T3\"   0 0 {{a b c d} {i j k l}}\n\n  16   \"UPDATE OR ROLLBACK $T4\"   1 1 {{a b c d} {e f g h}}\n  17   \"UPDATE OR ABORT    $T4\"   1 1 {{a b c d} {e f g h} {i j k l}}\n  18   \"UPDATE OR FAIL     $T4\"   1 1 {{e f g h} {i j k l} {a b c d}}\n  19   \"UPDATE OR IGNORE   $T4\"   1 0 {{e f g h} {i j k l} {a b c d}}\n  20   \"UPDATE OR REPLACE  $T4\"   1 0 {{e f g h} {a b c d}}\n}] {\n  db_restore_and_reopen\n  execsql { \n    BEGIN;\n      INSERT INTO t1(rowid, x) VALUES(3, 'i j k l');\n  }\n  set R(0) {0 {}}\n  set R(1) {1 {constraint failed}}\n  do_catchsql_test 1.$tn.1 $sql $R($constraint)\n  do_catchsql_test 1.$tn.2 { SELECT * FROM t1 } [list 0 $data]\n  catchsql COMMIT\n\n  fts3_integrity 1.$tn.3 db t1\n\n  do_test 1.$tn.4 [list sql_uses_stmt db $sql] $uses\n}\n\ndo_execsql_test 2.1.1 {\n  DELETE FROM t1;\n  BEGIN;\n    INSERT INTO t1 VALUES('a b c');\n    SAVEPOINT a;\n      INSERT INTO t1 VALUES('x y z');\n    ROLLBACK TO a;\n  COMMIT;\n}\nfts3_integrity 2.1.2 db t1\n\ndo_catchsql_test 2.2.1 {\n  DELETE FROM t1;\n  BEGIN;\n    INSERT INTO t1(docid, x) VALUES(0, 'a b c');\n    INSERT INTO t1(docid, x) VALUES(1, 'a b c');\n    REPLACE INTO t1(docid, x) VALUES('zero', 'd e f');\n} {1 {datatype mismatch}}\ndo_execsql_test 2.2.2 { COMMIT }\ndo_execsql_test 2.2.3 { SELECT * FROM t1 } {{a b c} {a b c}}\nfts3_integrity 2.2.4 db t1\n\nif {$tcl_platform(byteOrder)==\"littleEndian\"} {\n  do_execsql_test 3.1 {\n    CREATE VIRTUAL TABLE t3 USING fts4;\n    REPLACE INTO t3(docid, content) VALUES (1, 'one two');\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'\n  } {X'0100000002000000'}\n  \n  do_execsql_test 3.2 {\n    REPLACE INTO t3(docid, content) VALUES (2, 'one two three four');\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'four'\n  } {X'0200000003000000'}\n  \n  do_execsql_test 3.3 {\n    REPLACE INTO t3(docid, content) VALUES (1, 'one two three four five six');\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'\n  } {X'0200000005000000'}\n  \n  do_execsql_test 3.4 {\n    UPDATE OR REPLACE t3 SET docid = 2 WHERE docid=1;\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'\n  } {X'0100000006000000'}\n  \n  do_execsql_test 3.5 {\n    UPDATE OR REPLACE t3 SET docid = 3 WHERE docid=2;\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'six'\n  } {X'0100000006000000'}\n  \n  do_execsql_test 3.6 {\n    REPLACE INTO t3(docid, content) VALUES (3, 'one two');\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'\n  } {X'0100000002000000'}\n  \n  do_execsql_test 3.7 {\n    REPLACE INTO t3(docid, content) VALUES(NULL,'one two three four');\n    REPLACE INTO t3(docid, content) VALUES(NULL,'one two three four five six');\n    SELECT docid FROM t3;\n  } {3 4 5}\n  \n  do_execsql_test 3.8 {\n    UPDATE OR REPLACE t3 SET docid = 5, content='three four' WHERE docid = 4;\n    SELECT quote(matchinfo(t3, 'na')) FROM t3 WHERE t3 MATCH 'one'\n  } {X'0200000002000000'}\n}\n\n#-------------------------------------------------------------------------\n# Test that the xSavepoint is invoked correctly if the first write \n# operation within a transaction is to a virtual table. \n# \ndo_catchsql_test 4.1.1 {\n  CREATE VIRTUAL TABLE t0 USING fts4;\n  BEGIN;\n    INSERT INTO t0(rowid, content) SELECT\n      1, 'abc' UNION ALL SELECT\n      2, 'def' UNION ALL SELECT\n      1, 'ghi';\n} {1 {constraint failed}}\ndo_execsql_test 4.1.2 {\n  COMMIT;\n}\ndo_execsql_test 4.1.3 {\n  SELECT * FROM t0 WHERE t0 MATCH 'abc';\n  INSERT INTO t0(t0) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 4.2.1 {\n  CREATE VIRTUAL TABLE t01 USING fts4;\n  BEGIN;\n    SAVEPOINT abc;\n      INSERT INTO t01 VALUES('a b c');\n    ROLLBACK TO abc;\n  COMMIT;\n}\ndo_execsql_test 4.2.2 {\n  SELECT * FROM t01 WHERE t01 MATCH 'b';\n  INSERT INTO t01(t01) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 4.3.1 {\n  CREATE VIRTUAL TABLE t02 USING fts4;\n  INSERT INTO t01 VALUES('1 1 1');\n  INSERT INTO t02 VALUES('2 2 2');\n  BEGIN;\n    SAVEPOINT abc;\n      INSERT INTO t01 VALUES('a b c');\n      INSERT INTO t02 VALUES('a b c');\n    ROLLBACK TO abc;\n  COMMIT;\n}\ndo_execsql_test 4.3.2 {\n  SELECT * FROM t01 WHERE t01 MATCH 'b';\n  INSERT INTO t01(t01) VALUES('integrity-check');\n} {}\n\ndo_execsql_test 4.4.1 {\n  CREATE TABLE A(ID INTEGER PRIMARY KEY, AnotherID INTEGER, Notes TEXT);\n  CREATE VIRTUAL TABLE AFTS USING FTS4 (Notes);\n  CREATE TRIGGER A_DeleteTrigger AFTER DELETE ON A FOR EACH ROW BEGIN \n    DELETE FROM AFTS WHERE rowid=OLD.ID; \n  END;\n  CREATE TABLE B(ID INTEGER PRIMARY KEY,Notes TEXT);\n  CREATE VIRTUAL TABLE BFTS USING FTS3 (Notes);\n  CREATE TRIGGER B_DeleteTrigger AFTER DELETE ON B FOR EACH ROW BEGIN \n    DELETE FROM BFTS WHERE rowid=OLD.ID; \n  END;\n}\n\t\t\ndo_execsql_test 4.4.2 {\n  BEGIN TRANSACTION;\n    DELETE FROM A WHERE AnotherID=1;\n    DELETE FROM B WHERE ID=1;\n  COMMIT;\n}\n\t\t\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3corrupt.test",
    "content": "# 2010 October 27\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that the FTS3 extension does not crash when it encounters a\n# corrupt data structure on disk.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\nset ::testprefix fts3corrupt\n\n\n# Test that a doclist with a length field that indicates that the doclist\n# extends past the end of the node on which it resides is correctly identified\n# as database corruption.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  INSERT INTO t1 VALUES('hello');\n} {}\ndo_test fts3corrupt-1.1 {\n  set blob [db one {SELECT root from t1_segdir}]\n  set blob [binary format a7ca* $blob 24 [string range $blob 8 end]]\n  execsql { UPDATE t1_segdir SET root = $blob }\n} {}\ndo_test fts3corrupt-1.2 {\n  foreach w {a b c d e f g h i j k l m n o} {\n    execsql { INSERT INTO t1 VALUES($w) }\n  }\n} {}\ndo_catchsql_test 1.3 {\n  INSERT INTO t1 VALUES('world');\n} {1 {database disk image is malformed}}\ndo_test 1.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\ndo_execsql_test 1.4 { \n  DROP TABLE t1;\n} \n\n# This block of tests checks that corruption is correctly detected if the\n# length field of a term on a leaf node indicates that the term extends past\n# the end of the node on which it resides. There are two cases:\n#\n#   1. The first term on the node.\n#   2. The second or subsequent term on the node (prefix compressed term).\n#\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  BEGIN;\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t1 VALUES('hello');\n  COMMIT;\n} {}\ndo_test fts3corrupt-2.1 {\n  set blob [db one {SELECT root from t1_segdir}]\n  set blob [binary format a*a* \"\\x00\\x7F\" [string range $blob 2 end]]\n  execsql { UPDATE t1_segdir SET root = $blob }\n} {}\ndo_catchsql_test 2.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'hello'\n} {1 {database disk image is malformed}}\ndo_test 2.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\n\ndo_execsql_test 3.0 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  BEGIN;\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t1 VALUES('world');\n  COMMIT;\n} {}\ndo_test fts3corrupt-3.1 {\n  set blob [db one {SELECT quote(root) from t1_segdir}]\n  set blob [binary format a11a*a* $blob \"\\x7F\" [string range $blob 12 end]]\n  execsql { UPDATE t1_segdir SET root = $blob }\n} {}\ndo_catchsql_test 3.2 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'world'\n} {1 {database disk image is malformed}}\ndo_test 3.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\n\n\ndo_execsql_test 4.0 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  INSERT INTO t1(t1) VALUES('nodesize=24');\n}\ndo_test fts3corrupt-4.1 {\n  execsql BEGIN\n  foreach s {\n     \"amxtvoo adqwroyhz auq aithtir avniqnuynvf axp ahibayfynig agbicpm\"\n     \"ajdtebs anteaxr aieynenwmd awpl alo akxcrwow aoxftge aoqvgul\"\n     \"amcfvdr auz apu aebelm ahuxyz aqc asyafdb agulvhvqu\"\n     \"apepwfyz azkhdvkw aenyelxzbk aslnitbyet aycdsdcpgr aqzzdbc agfi axnypydou\"\n     \"aaqrzzcm apcxdxo atumltzj aevvivo aodknoft aqoyytoz alobx apldt\"\n  } {\n    execsql { INSERT INTO t1 VALUES($s) }\n  }\n  execsql COMMIT\n} {}\n\ndo_catchsql_test 4.2 {\n  UPDATE t1_segdir SET root = X'FFFFFFFFFFFFFFFF';\n  SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n} {1 {database disk image is malformed}}\ndo_test 4.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\n\nset    blob [binary format cca*cca*cca*cca*cca*cca*cca*cca*cca*cca*a* \\\n  22 120 [string repeat a 120]  \\\n  22 120 [string repeat b 120]  \\\n  22 120 [string repeat c 120]  \\\n  22 120 [string repeat d 120]  \\\n  22 120 [string repeat e 120]  \\\n  22 120 [string repeat f 120]  \\\n  22 120 [string repeat g 120]  \\\n  22 120 [string repeat h 120]  \\\n  22 120 [string repeat i 120]  \\\n  22 120 [string repeat j 120]  \\\n  \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\"\n]\n\ndo_catchsql_test 4.3 {\n  UPDATE t1_segdir SET root = $blob;\n  SELECT rowid FROM t1 WHERE t1 MATCH 'world';\n} {1 {database disk image is malformed}}\ndo_test 4.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\n\n# Test a special kind of corruption, where the %_stat table contains\n# an invalid entry. At one point this could lead to a division-by-zero\n# error in fts4.\n#\ndo_execsql_test 5.0 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts4;\n}\ndo_test 5.1 {\n  db func nn nn\n  execsql BEGIN\n  execsql { INSERT INTO t1 VALUES('one') }\n  execsql { INSERT INTO t1 VALUES('two') }\n  execsql { INSERT INTO t1 VALUES('three') }\n  execsql { INSERT INTO t1 VALUES('four') }\n  execsql COMMIT\n} {}\ndo_catchsql_test 5.2 {\n  UPDATE t1_stat SET value = X'0000';\n  SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*';\n} {1 {database disk image is malformed}}\ndo_test 5.2.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\ndo_catchsql_test 5.3 {\n  UPDATE t1_stat SET value = NULL;\n  SELECT matchinfo(t1, 'nxa') FROM t1 WHERE t1 MATCH 't*';\n} {1 {database disk image is malformed}}\ndo_test 5.3.1 { sqlite3_extended_errcode db } SQLITE_CORRUPT_VTAB\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3corrupt2.test",
    "content": "# 2010 October 30\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that the FTS3 extension does not crash when it encounters a\n# corrupt data structure on disk.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\nset ::testprefix fts3corrupt2\n\nset data [list]\nlappend data {*}{\n   \"amxtvoo adqwroyhz auq aithtir avniqnuynvf axp ahibayfynig agbicpm\"\n   \"ajdtebs anteaxr aieynenwmd awpl alo akxcrwow aoxftge aoqvgul\"\n   \"amcfvdr auz apu aebelm ahuxyz aqc asyafdb agulvhvqu\"\n   \"apepwfyz azkhdvkw aenyelxzbk aslnitbyet aycdsdcpgr aqzzdbc agfi axnypydou\"\n   \"aaqrzzcm apcxdxo atumltzj aevvivo aodknoft aqoyytoz alobx apldt\"\n   \"adjllxlhnmj aiuhvuj adwppceuht atvj azrsam ahkjqdhny audlqxr aotgcd\"\n   \"aira azflsceos awj auzbobfkc awmezplr aeh awec ahndxlmv\"\n   \"aydwnied alk auoap agihyqeix aymqxzajnl aydwnied aojkarx agbo\"\n   \"ahajsmcl anvx amdhjm aoptsj agugzjjm apkevm acnj acjg\"\n   \"amwtkw aogttbykvt aubwrfqnbjf ajow agsj aerkqzjdqst anenlvbalkn arfajzzgckx\"\n   \"adqqqofkmz amjpavjuhw aqgehgnb awvvxlbtqzn agstqko akmkzehyh atagzey agwja\"\n   \"amag ahe autkllywhr avnk atmt akn anvdh aixfrv\"\n   \"aqdyerbws avefykly awl azaduojgzo anxfsmw axpt abgbvk ati\"\n   \"attyqkwz aiweypiczul afy asitaqbczhh aitxisizpv auhviq aibql ajfqc\"\n   \"aylzprtmta aiuemihqrpi awluvgsw ampbuy axlifpzfqr aems aoaxwads apianfn\"\n   \"aodrkijelq acdb aaserrdxm aqyasgofqu aevvivo afi apmwu aeoqysl\"\n   \"amqnk ankaotm ayfy ajcupeeoc advcbukan aucahlwnyk adbfyo azqjpeant\"\n   \"afczpp asqrs ahslvda akhlf aiqgdp atyd aznuglxqbrg awirndrh\"\n   \"aqhiajp amxeazb asxuehg akod axvolvsp agcz asmovmohy acmqa\"\n   \"avvomv aafms ashuaec arevx audtq alrwqhjvao avgsgpg ajbrctpsel\"\n   \"atxoirr ayopboobqdu ajunntua arh aernimxid aipljda aglo aefk\"\n   \"aonxf acmnnkna abgviaswe aulvcbv axp apemgakpzo aibql acioaid\"\n   \"axo alrwqhjvao ayqounftdzl azmoakdyh apajze ajk artvy apxiamy\"\n   \"ayjafsraz addjj agsj asejtziqws acatvhegu aoxdjqblsvv aekdmmbs aaobe\"\n   \"abjjvzubkwt alczv ati awz auyxgcxeb aymjoym anqoukprtyt atwfhpmbooh\"\n   \"ajfqz aethlgir aclcx aowlyvetby aproqm afjlqtkv anebfy akzrcpfrrvw\"\n   \"aoledfotm aiwlfm aeejlaej anz abgbvk aktfn aayoh anpywgdvgz\"\n   \"acvmldguld asdvz aqb aeomsyzyu aggylhprbdz asrfkwz auipybpsn agsnszzfb\"\n}\n\ndo_test fts3corrupt2-1.0 {\n  execsql BEGIN\n  execsql { CREATE VIRTUAL TABLE t2 USING FTS3(a, b); }\n  execsql { INSERT INTO t2(t2) VALUES('nodesize=32') }\n  foreach d $data {\n    execsql { INSERT INTO t2 VALUES($d, $d) }\n  }\n  execsql COMMIT\n  execsql { SELECT count(*) FROM t2_segments }\n} {163}\n\nproc set_byte {blob byte val} {\n  binary format a*ca*                         \\\n      [string range $blob 0 [expr $byte-1]]   \\\n      $val                                    \\\n      [string range $blob [expr $byte+1] end] \\\n}\n\nset tn 0\nset c 256\nforeach {rowid sz blob} [\n  db eval {SELECT rowid, length(block), block FROM t2_segments}\n] {\n  incr tn\n  set c [expr (($c+255)%256)]\n  for {set i 0} {$i < $sz} {incr i} {\n    set b2 [set_byte $blob $i $c]\n    execsql { UPDATE t2_segments SET block = $b2 WHERE rowid = $rowid }\n    do_test fts3corrupt2-1.$tn.$i {\n      catchsql { SELECT * FROM t2 WHERE t2 MATCH 'a*' }\n      set {} {}\n    } {}\n  }\n  execsql { UPDATE t2_segments SET block = $blob WHERE rowid = $rowid }\n}\n\nforeach c {50 100 150 200 250} {\n  foreach {rowid sz blob} [\n    db eval {SELECT rowid, length(root), root FROM t2_segdir}\n  ] {\n    incr tn\n    for {set i 0} {$i < $sz} {incr i} {\n      set b2 [set_byte $blob $i $c]\n      execsql { UPDATE t2_segdir SET root = $b2 WHERE rowid = $rowid }\n      do_test fts3corrupt2-2.$c.$tn.$i {\n        catchsql { SELECT * FROM t2 WHERE t2 MATCH 'a*' }\n        set {} {}\n      } {}\n    }\n    execsql { UPDATE t2_segdir SET root = $blob WHERE rowid = $rowid }\n  }\n}\n\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3corrupt3.test",
    "content": "# 2010 October 27\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that the FTS3 extension does not crash when it encounters a\n# corrupt data structure on disk.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\nset ::testprefix fts3corrupt3\n\n#-------------------------------------------------------------------------\n# Test that fts3 does not choke on an oversized varint.\n#\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 512;\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  BEGIN;\n    INSERT INTO t1 VALUES('one');\n    INSERT INTO t1 VALUES('one');\n    INSERT INTO t1 VALUES('one');\n  COMMIT;\n}\ndo_execsql_test 1.1 {\n  SELECT quote(root) from t1_segdir;\n} {X'00036F6E6509010200010200010200'}\ndo_execsql_test 1.2 {\n  UPDATE t1_segdir SET root = X'00036F6E650EFFFFFFFFFFFFFFFFFFFFFFFF0200';\n}\ndo_catchsql_test 1.3 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'one'\n} {0 -1}\n\n#-------------------------------------------------------------------------\n# Interior node with the prefix or suffix count of an entry set to a\n# negative value.\n#\nset doc1 [string repeat \"x \" 600]\nset doc2 [string repeat \"y \" 600]\nset doc3 [string repeat \"z \" 600]\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t2 USING fts3;\n  BEGIN;\n    INSERT INTO t2 VALUES($doc1);\n    INSERT INTO t2 VALUES($doc2);\n    INSERT INTO t2 VALUES($doc3);\n  COMMIT;\n}\ndo_execsql_test 2.1 {\n  SELECT quote(root) from t2_segdir;\n} {X'0101017900017A'}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3cov.test",
    "content": "# 2009 December 03\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file are structural coverage tests for FTS3.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build does not include FTS3, skip the tests in this file.\n#\nifcapable !fts3 { finish_test ; return }\nsource $testdir/fts3_common.tcl\nsource $testdir/malloc_common.tcl\n\nset DO_MALLOC_TEST 0\nset testprefix fts3cov\n\n#--------------------------------------------------------------------------\n# When it first needs to read a block from the %_segments table, the FTS3 \n# module compiles an SQL statement for that purpose. The statement is \n# stored and reused each subsequent time a block is read. This test case \n# tests the effects of an OOM error occuring while compiling the statement.\n#\n# Similarly, when FTS3 first needs to scan through a set of segment leaves\n# to find a set of documents that matches a term, it allocates a string\n# containing the text of the required SQL, and compiles one or more \n# statements to traverse the leaves. This test case tests that OOM errors\n# that occur while allocating this string and statement are handled correctly\n# also.\n#\ndo_test fts3cov-1.1 {\n  execsql { \n    CREATE VIRTUAL TABLE t1 USING fts3(x);\n    INSERT INTO t1(t1) VALUES('nodesize=24');\n    BEGIN;\n      INSERT INTO t1 VALUES('Is the night chilly and dark?');\n      INSERT INTO t1 VALUES('The night is chilly, but not dark.');\n      INSERT INTO t1 VALUES('The thin gray cloud is spread on high,');\n      INSERT INTO t1 VALUES('It covers but not hides the sky.');\n    COMMIT;\n    SELECT count(*)>0 FROM t1_segments;\n  }\n} {1}\n\nset DO_MALLOC_TEST 1\ndo_restart_select_test fts3cov-1.2 {\n  SELECT docid FROM t1 WHERE t1 MATCH 'chilly';\n} {1 2}\nset DO_MALLOC_TEST 0\n\n#--------------------------------------------------------------------------\n# When querying the full-text index, if an expected internal node block is \n# missing from the %_segments table, or if a NULL value is stored in the \n# %_segments table instead of a binary blob, database corruption should be \n# reported.\n#\n# Even with tiny 24 byte nodes, it takes a fair bit of data to produce a\n# segment b-tree that uses the %_segments table to store internal nodes. \n#\ndo_test fts3cov-2.1 {\n  execsql {\n    INSERT INTO t1(t1) VALUES('nodesize=24');\n    BEGIN;\n      INSERT INTO t1 VALUES('The moon is behind, and at the full;');\n      INSERT INTO t1 VALUES('And yet she looks both small and dull.');\n      INSERT INTO t1 VALUES('The night is chill, the cloud is gray:');\n      INSERT INTO t1 VALUES('''T is a month before the month of May,');\n      INSERT INTO t1 VALUES('And the Spring comes slowly up this way.');\n      INSERT INTO t1 VALUES('The lovely lady, Christabel,');\n      INSERT INTO t1 VALUES('Whom her father loves so well,');\n      INSERT INTO t1 VALUES('What makes her in the wood so late,');\n      INSERT INTO t1 VALUES('A furlong from the castle gate?');\n      INSERT INTO t1 VALUES('She had dreams all yesternight');\n      INSERT INTO t1 VALUES('Of her own betrothed knight;');\n      INSERT INTO t1 VALUES('And she in the midnight wood will pray');\n      INSERT INTO t1 VALUES('For the weal of her lover that''s far away.');\n    COMMIT;\n  }\n  execsql {\n    INSERT INTO t1(t1) VALUES('optimize');\n    SELECT substr(hex(root), 1, 2) FROM t1_segdir;\n  }\n} {03}\n\n# Test the \"missing entry\" case:\ndo_test fts3cov-2.2 {\n  set root [db one {SELECT root FROM t1_segdir}]\n  read_fts3varint [string range $root 1 end] left_child\n  execsql { DELETE FROM t1_segments WHERE blockid = $left_child }\n} {}\ndo_error_test fts3cov-2.3 {\n  SELECT * FROM t1 WHERE t1 MATCH 'c*'\n} {SQL logic error}\n\n# Test the \"replaced with NULL\" case:\ndo_test fts3cov-2.4 {\n  execsql { INSERT INTO t1_segments VALUES($left_child, NULL) }\n} {}\ndo_error_test fts3cov-2.5 {\n  SELECT * FROM t1 WHERE t1 MATCH 'cloud'\n} {SQL logic error}\n\n#--------------------------------------------------------------------------\n# The following tests are to test the effects of OOM errors while storing\n# terms in the pending-hash table. Specifically, while creating doclist\n# blobs to store in the table. More specifically, to test OOM errors while\n# appending column numbers to doclists. For example, if a doclist consists\n# of:\n#\n#   <docid> <column 0 offset-list> 0x01 <column N> <column N offset-list>\n#\n# The following tests check that malloc errors encountered while appending\n# the \"0x01 <column N>\" data to the dynamically growable blob used to \n# accumulate the doclist in memory are handled correctly.\n#\ndo_test fts3cov-3.1 {\n  set cols [list]\n  set vals [list]\n  for {set i 0} {$i < 120} {incr i} {\n    lappend cols \"col$i\"\n    lappend vals \"'word'\"\n  }\n  execsql \"CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])\"\n} {}\nset DO_MALLOC_TEST 1 \ndo_write_test fts3cov-3.2 t2_content \"\n  INSERT INTO t2(docid, [join $cols ,]) VALUES(1, [join $vals ,])\n\"\ndo_write_test fts3cov-3.3 t2_content \"\n  INSERT INTO t2(docid, [join $cols ,]) VALUES(200, [join $vals ,])\n\"\ndo_write_test fts3cov-3.4 t2_content \"\n  INSERT INTO t2(docid, [join $cols ,]) VALUES(60000, [join $vals ,])\n\"\n\n#-------------------------------------------------------------------------\n# If too much data accumulates in the pending-terms hash table, it is\n# flushed to the database automatically, even if the transaction has not\n# finished. The following tests check the effects of encountering an OOM \n# while doing this.\n#\ndo_test fts3cov-4.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t3 USING fts3(x);\n    INSERT INTO t3(t3) VALUES('nodesize=24');\n    INSERT INTO t3(t3) VALUES('maxpending=100');\n  }\n} {}\nset DO_MALLOC_TEST 1 \ndo_write_test fts3cov-4.2 t3_content {\n  INSERT INTO t3(docid, x)\n    SELECT 1, 'Then Christabel stretched forth her hand,' UNION ALL\n    SELECT 3, 'And comforted fair Geraldine:'             UNION ALL\n    SELECT 4, '''O well, bright dame, may you command'    UNION ALL\n    SELECT 5, 'The service of Sir Leoline;'               UNION ALL\n    SELECT 2, 'And gladly our stout chivalry'             UNION ALL\n    SELECT 7, 'Will he send forth, and friends withal,'   UNION ALL\n    SELECT 8, 'To guide and guard you safe and free'      UNION ALL\n    SELECT 6, 'Home to your noble father''s hall.'''\n}\n\n#-------------------------------------------------------------------------\n# When building the internal tree structure for each segment b-tree, FTS3\n# assumes that the content of each internal node will be less than\n# $nodesize bytes, where $nodesize is the advisory node size. If this turns\n# out to be untrue, then an extra buffer must be malloc'd for each term.\n# This test case tests these paths and the effects of said mallocs failing\n# by inserting insert a document with some fairly large terms into a\n# full-text table with a very small node-size. \n#\n# Test this handling of large terms in three contexts:\n#\n#   1. When flushing the pending-terms table.\n#   2. When optimizing the data structures using the INSERT syntax. \n#   2. When optimizing the data structures using the deprecated SELECT syntax. \n#\ndo_test fts3cov-5.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t4 USING fts3(x);\n    INSERT INTO t4(t4) VALUES('nodesize=24');\n  }\n} {}\nset DO_MALLOC_TEST 1\n\n# Test when flushing pending-terms table.\ndo_write_test fts3cov-5.2 t4_content {\n  INSERT INTO t4\n    SELECT 'ItisanancientMarinerAndhestoppethoneofthreeAA' UNION ALL\n    SELECT 'ItisanancientMarinerAndhestoppethoneofthreeBB' UNION ALL\n    SELECT 'ItisanancientMarinerAndhestoppethoneofthreeCC' UNION ALL\n    SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstAA' UNION ALL\n    SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstBB' UNION ALL\n    SELECT 'BythylonggreybeardandglitteringeyeNowwhereforestoppstCC'\n}\n\n# Test when optimizing via INSERT.\ndo_test fts3cov-5.3 { execsql { INSERT INTO t4 VALUES('extra!') } } {}\ndo_write_test fts3cov-5.2 t4_segments { INSERT INTO t4(t4) VALUES('optimize') }\n\n# Test when optimizing via SELECT.\ndo_test fts3cov-5.5 { execsql { INSERT INTO t4 VALUES('more extra!') } } {}\ndo_write_test fts3cov-5.6 t4_segments {\n  SELECT * FROM (SELECT optimize(t4) FROM t4 LIMIT 1)\n  EXCEPT SELECT 'Index optimized'\n}\n\n#-------------------------------------------------------------------------\n# When merging all segments at a given level to create a single segment\n# at level+1, FTS3 runs a query of the form:\n#\n#   SELECT count(*) FROM %_segdir WHERE level = ?\n#\n# The query is compiled the first time this operation is required and\n# reused thereafter. This test aims to test the effects of an OOM while\n# preparing and executing this query for the first time.\n#\n# Then, keep inserting rows into the table so that the effects of an OOM\n# while re-executing the same query can also be tested.\n#\ndo_test fts3cov-6.1 {\n  execsql { CREATE VIRTUAL TABLE t5 USING fts3(x) }\n  for {set i 0} {$i<16} {incr i} { execsql \"INSERT INTO t5 VALUES('term$i')\" }\n  execsql { SELECT count(*) FROM t5_segdir }\n} {16}\n\n# First time.\ndb close\nsqlite3 db test.db\ndo_write_test fts3cov-6.2 t5_content {\n  INSERT INTO t5 VALUES('segment number 16!');\n}\n\n# Second time.\ndo_test fts3cov-6.3 {\n  for {set i 1} {$i<16} {incr i} { execsql \"INSERT INTO t5 VALUES('term$i')\" }\n  execsql { SELECT count(*) FROM t5_segdir }\n} {17}\ndo_write_test fts3cov-6.4 t5_content {\n  INSERT INTO t5 VALUES('segment number 16!');\n}\n\n#-------------------------------------------------------------------------\n# Update the docid of a row. Test this in two scenarios:\n#\n#   1. When the row being updated is the only row in the table.\n#   2. When it is not.\n#\n# The two cases above take different paths because in case 1 all data \n# structures can simply be emptied before inserting the new row record.\n# In case 2, the data structures actually have to be updated.\n#\ndo_test fts3cov-7.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t7 USING fts3(a, b, c);\n    INSERT INTO t7 VALUES('A', 'B', 'C');\n    UPDATE t7 SET docid = 5;\n    SELECT docid, * FROM t7;\n  }\n} {5 A B C}\ndo_test fts3cov-7.2 {\n  execsql {\n    INSERT INTO t7 VALUES('D', 'E', 'F');\n    UPDATE t7 SET docid = 1 WHERE docid = 6;\n    SELECT docid, * FROM t7;\n  }\n} {1 D E F 5 A B C}\n\n#-------------------------------------------------------------------------\n# If a set of documents are modified within a transaction, the \n# pending-terms table must be flushed each time a document with a docid\n# less than or equal to the previous docid is modified. \n#\n# This test checks the effects of an OOM error occuring when the \n# pending-terms table is flushed for this reason as part of a DELETE \n# statement.\n#\ndo_malloc_test fts3cov-8 -sqlprep {\n  BEGIN;\n    CREATE VIRTUAL TABLE t8 USING fts3;\n    INSERT INTO t8 VALUES('the output of each batch run');\n    INSERT INTO t8 VALUES('(possibly a day''s work)');\n    INSERT INTO t8 VALUES('was written to two separate disks');\n  COMMIT;\n} -sqlbody {\n  BEGIN;\n    DELETE FROM t8 WHERE rowid = 3;\n    DELETE FROM t8 WHERE rowid = 2;\n    DELETE FROM t8 WHERE rowid = 1;\n  COMMIT;\n}\n\n#-------------------------------------------------------------------------\n# Test some branches in the code that handles \"special\" inserts like:\n#\n#   INSERT INTO t1(t1) VALUES('optimize');\n#\n# Also test that an optimize (INSERT method) works on an empty table.\n#\nset DO_MALLOC_TEST 0\ndo_test fts3cov-9.1 {\n  execsql { CREATE VIRTUAL TABLE xx USING fts3 }\n} {}\ndo_error_test fts3cov-9.2 {\n  INSERT INTO xx(xx) VALUES('optimise');   -- British spelling\n} {SQL logic error}\ndo_error_test fts3cov-9.3 {\n  INSERT INTO xx(xx) VALUES('short');\n} {SQL logic error}\ndo_error_test fts3cov-9.4 {\n  INSERT INTO xx(xx) VALUES('waytoolongtobecorrect');\n} {SQL logic error}\ndo_test fts3cov-9.5 {\n  execsql { INSERT INTO xx(xx) VALUES('optimize') }\n} {}\n\n#-------------------------------------------------------------------------\n# Test that a table can be optimized in the middle of a transaction when\n# the pending-terms table is non-empty. This case involves some extra\n# branches because data must be read not only from the database, but\n# also from the pending-terms table.\n#\ndo_malloc_test fts3cov-10 -sqlprep {\n  CREATE VIRTUAL TABLE t10 USING fts3;\n  INSERT INTO t10 VALUES('Optimising images for the web is a tricky business');\n  BEGIN;\n    INSERT INTO t10 VALUES('You have to get the right balance between');\n} -sqlbody {\n  INSERT INTO t10(t10) VALUES('optimize');\n}\n\n#-------------------------------------------------------------------------\n# Test a full-text query for a term that was once in the index, but is\n# no longer.\n#\ndo_test fts3cov-11.1 {\n  execsql { \n    CREATE VIRTUAL TABLE xx USING fts3;\n    INSERT INTO xx VALUES('one two three');\n    INSERT INTO xx VALUES('four five six');\n    DELETE FROM xx WHERE docid = 1;\n  }\n  execsql { SELECT * FROM xx WHERE xx MATCH 'two' }\n} {}\n\n\ndo_malloc_test fts3cov-12 -sqlprep {\n  CREATE VIRTUAL TABLE t12 USING fts3;\n  INSERT INTO t12 VALUES('is one of the two togther');\n  BEGIN;\n    INSERT INTO t12 VALUES('one which was appropriate at the time');\n} -sqlbody {\n  SELECT * FROM t12 WHERE t12 MATCH 'one'\n}\n\ndo_malloc_test fts3cov-13 -sqlprep {\n  PRAGMA encoding = 'UTF-16';\n  CREATE VIRTUAL TABLE t13 USING fts3;\n  INSERT INTO t13 VALUES('two scalar functions');\n  INSERT INTO t13 VALUES('scalar two functions');\n  INSERT INTO t13 VALUES('functions scalar two');\n} -sqlbody {\n  SELECT snippet(t13, '%%', '%%', '#') FROM t13 WHERE t13 MATCH 'two';\n  SELECT snippet(t13, '%%', '%%') FROM t13 WHERE t13 MATCH 'two';\n  SELECT snippet(t13, '%%') FROM t13 WHERE t13 MATCH 'two';\n}\n\ndo_execsql_test 14.0 {\n  CREATE VIRTUAL TABLE t14 USING fts4(a, b);\n  INSERT INTO t14 VALUES('one two three', 'one three four');\n  INSERT INTO t14 VALUES('a b c', 'd e a');\n}\ndo_execsql_test 14.1 {\n  SELECT rowid FROM t14 WHERE t14 MATCH '\"one two three\"'\n} {1}\ndo_execsql_test 14.2 {\n  SELECT rowid FROM t14 WHERE t14 MATCH '\"one four\"'\n} {}\ndo_execsql_test 14.3 {\n  SELECT rowid FROM t14 WHERE t14 MATCH '\"e a\"'\n} {2}\ndo_execsql_test 14.5 {\n  SELECT rowid FROM t14 WHERE t14 MATCH '\"e b\"'\n} {}\ndo_catchsql_test 14.6 {\n  SELECT rowid FROM t14 WHERE rowid MATCH 'one'\n} {1 {unable to use function MATCH in the requested context}}\ndo_catchsql_test 14.7 {\n  SELECT rowid FROM t14 WHERE docid MATCH 'one'\n} {1 {unable to use function MATCH in the requested context}}\n\ndo_execsql_test 15.0 {\n  CREATE VIRTUAL TABLE t15 USING fts4(a, b, c);\n  INSERT INTO t15 VALUES('abc def ghi', 'abc2 def2 ghi2', 'abc3 def3 ghi3');\n  INSERT INTO t15 VALUES('abc2 def2 ghi2', 'abc2 def2 ghi2', 'abc def3 ghi3');\n}\ndo_execsql_test 15.1 {\n  SELECT rowid FROM t15 WHERE t15 MATCH '\"abc* def2\"'\n} {1 2}\n\n# Test a corruption case.\n#\ndo_execsql_test 16.1 {\n  CREATE VIRTUAL TABLE t16 USING fts4;\n  INSERT INTO t16 VALUES('theoretical work to examine the relationship');\n  INSERT INTO t16 VALUES('solution of our problems on the invisible');\n  DELETE FROM t16_content WHERE rowid = 2;\n}\ndo_catchsql_test 16.2 {\n  SELECT * FROM t16 WHERE t16 MATCH 'invisible'\n} {1 {database disk image is malformed}}\n\n# And another corruption test case.\n#\ndo_execsql_test 17.1 {\n  CREATE VIRTUAL TABLE t17 USING fts4;\n  INSERT INTO t17(content) VALUES('one one one');\n  UPDATE t17_segdir SET root = X'00036F6E65FFFFFFFFFFFFFFFFFFFFFF02030300'\n} {}\ndo_catchsql_test 17.2 {\n  SELECT * FROM t17 WHERE t17 MATCH 'one'\n} {1 {database disk image is malformed}}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3d.test",
    "content": "# 2008 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this script is testing the FTS3 module's optimize() function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Utility function to check for the expected terms in the segment\n# level/index.  _all version does same but for entire index.\nproc check_terms {test level index terms} {\n  set where \"level = $level AND idx = $index\"\n  do_test $test.terms [list fts3_terms t1 $where] $terms\n}\nproc check_terms_all {test terms} {\n  do_test $test.terms [list fts3_terms t1 1] $terms\n}\n\n# Utility function to check for the expected doclist for the term in\n# segment level/index.  _all version does same for entire index.\nproc check_doclist {test level index term doclist} {\n  set where \"level = $level AND idx = $index\"\n  do_test $test.doclist [list fts3_doclist t1 $term $where] $doclist\n}\nproc check_doclist_all {test term doclist} {\n  do_test $test.doclist [list fts3_doclist t1 $term 1] $doclist\n}\n\n#*************************************************************************\n# Test results when all rows are deleted and one is added back.\n# Previously older segments would continue to exist, but now the index\n# should be dropped when the table is empty.  The results should look\n# exactly like we never added the earlier rows in the first place.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE 1=1; -- Delete each row rather than dropping table.\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n}\n\n# Should be a single initial segment.\ndo_test fts3d-1.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts3d-1.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}}\n\ncheck_terms_all fts3d-1.1 {a is test this}\ncheck_doclist_all fts3d-1.1.1 a {[1 0[2]]}\ncheck_doclist_all fts3d-1.1.2 is {[1 0[1]]}\ncheck_doclist_all fts3d-1.1.3 test {[1 0[3]]}\ncheck_doclist_all fts3d-1.1.4 this {[1 0[0]]}\n\ncheck_terms   fts3d-1.2   0 0 {a is test this}\ncheck_doclist fts3d-1.2.1 0 0 a {[1 0[2]]}\ncheck_doclist fts3d-1.2.2 0 0 is {[1 0[1]]}\ncheck_doclist fts3d-1.2.3 0 0 test {[1 0[3]]}\ncheck_doclist fts3d-1.2.4 0 0 this {[1 0[0]]}\n\n#*************************************************************************\n# Test results when everything is optimized manually.\n# NOTE(shess): This is a copy of fts3c-1.3.  I've pulled a copy here\n# because fts3d-2 and fts3d-3 should have identical results.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE docid IN (1,3);\n  DROP TABLE IF EXISTS t1old;\n  ALTER TABLE t1 RENAME TO t1old;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) SELECT docid, c FROM t1old;\n  DROP TABLE t1old;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts3d-2.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts3d-2.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts3d-2.1 {a test that was}\ncheck_doclist_all fts3d-2.1.1 a {[2 0[2]]}\ncheck_doclist_all fts3d-2.1.2 test {[2 0[3]]}\ncheck_doclist_all fts3d-2.1.3 that {[2 0[0]]}\ncheck_doclist_all fts3d-2.1.4 was {[2 0[1]]}\n\ncheck_terms fts3d-2.2 0 0 {a test that was}\ncheck_doclist fts3d-2.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts3d-2.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts3d-2.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts3d-2.2.4 0 0 was {[2 0[1]]}\n\n#*************************************************************************\n# Test results when everything is optimized via optimize().\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n  DELETE FROM t1 WHERE docid IN (1,3);\n  SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n}\n\n# Should be a single optimal segment with the same logical results.\ndo_test fts3d-3.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0}\ndo_test fts3d-3.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} {{0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4}}\n\ncheck_terms_all fts3d-3.1 {a test that was}\ncheck_doclist_all fts3d-3.1.1 a {[2 0[2]]}\ncheck_doclist_all fts3d-3.1.2 test {[2 0[3]]}\ncheck_doclist_all fts3d-3.1.3 that {[2 0[0]]}\ncheck_doclist_all fts3d-3.1.4 was {[2 0[1]]}\n\ncheck_terms fts3d-3.2 0 0 {a test that was}\ncheck_doclist fts3d-3.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts3d-3.2.2 0 0 test {[2 0[3]]}\ncheck_doclist fts3d-3.2.3 0 0 that {[2 0[0]]}\ncheck_doclist fts3d-3.2.4 0 0 was {[2 0[1]]}\n\n#*************************************************************************\n# Test optimize() against a table involving segment merges.\n# NOTE(shess): Since there's no transaction, each of the INSERT/UPDATE\n# statements generates a segment.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n\n  INSERT INTO t1 (rowid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (rowid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (rowid, c) VALUES (3, 'This is a test');\n\n  UPDATE t1 SET c = 'This is a test one' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test one' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test one' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test two' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test two' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test two' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test three' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test three' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test three' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test four' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test four' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test four' WHERE rowid = 3;\n\n  UPDATE t1 SET c = 'This is a test' WHERE rowid = 1;\n  UPDATE t1 SET c = 'That was a test' WHERE rowid = 2;\n  UPDATE t1 SET c = 'This is a test' WHERE rowid = 3;\n}\n\n# 2 segments in level 0, 1 in level 1 (18 segments created, 16\n# merged).\ndo_test fts3d-4.segments {\n  execsql {\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {0 0 0 1 1 0}\n\ndo_test fts3d-4.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\ndb eval {SELECT c FROM t1 }\ncheck_terms_all fts3d-4.1      {a four is test that this was}\ncheck_doclist_all fts3d-4.1.1  a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts3d-4.1.2  four {}\ncheck_doclist_all fts3d-4.1.3  is {[1 0[1]] [3 0[1]]}\n#check_doclist_all fts3d-4.1.4  one {}\ncheck_doclist_all fts3d-4.1.5  test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts3d-4.1.6  that {[2 0[0]]}\ncheck_doclist_all fts3d-4.1.7  this {[1 0[0]] [3 0[0]]}\n#check_doclist_all fts3d-4.1.8  three {}\n#check_doclist_all fts3d-4.1.9  two {}\ncheck_doclist_all fts3d-4.1.10 was {[2 0[1]]}\n\ncheck_terms fts3d-4.2     0 0 {a four test that was}\ncheck_doclist fts3d-4.2.1 0 0 a {[2 0[2]]}\ncheck_doclist fts3d-4.2.2 0 0 four {[2]}\ncheck_doclist fts3d-4.2.3 0 0 test {[2 0[3]]}\ncheck_doclist fts3d-4.2.4 0 0 that {[2 0[0]]}\ncheck_doclist fts3d-4.2.5 0 0 was {[2 0[1]]}\n\ncheck_terms fts3d-4.3     0 1 {a four is test this}\ncheck_doclist fts3d-4.3.1 0 1 a {[3 0[2]]}\ncheck_doclist fts3d-4.3.2 0 1 four {[3]}\ncheck_doclist fts3d-4.3.3 0 1 is {[3 0[1]]}\ncheck_doclist fts3d-4.3.4 0 1 test {[3 0[3]]}\ncheck_doclist fts3d-4.3.5 0 1 this {[3 0[0]]}\n\ncheck_terms fts3d-4.4      1 0 {a four is test that this was}\ncheck_doclist fts3d-4.4.1  1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist fts3d-4.4.2  1 0 four {[2 0[4]] [3 0[4]]}\ncheck_doclist fts3d-4.4.3  1 0 is {[1 0[1]] [3 0[1]]}\n#check_doclist fts3d-4.4.4  1 0 one {[1] [2] [3]}\ncheck_doclist fts3d-4.4.5  1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist fts3d-4.4.6  1 0 that {[2 0[0]]}\ncheck_doclist fts3d-4.4.7  1 0 this {[1 0[0]] [3 0[0]]}\n#check_doclist fts3d-4.4.8  1 0 three {[1] [2] [3]}\n#check_doclist fts3d-4.4.9  1 0 two {[1] [2] [3]}\ncheck_doclist fts3d-4.4.10 1 0 was {[2 0[1]]}\n\n# Optimize should leave the result in the level of the highest-level\n# prior segment.\ndo_test fts3d-4.5 {\n  execsql {\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index optimized} 1 0}\n\n# Identical to fts3d-4.matches.\ndo_test fts3d-4.5.matches {\n  execsql {\n    SELECT OFFSETS(t1) FROM t1\n     WHERE t1 MATCH 'this OR that OR was OR a OR is OR test' ORDER BY docid;\n  }\n} [list {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4} \\\n        {0 1 0 4 0 2 5 3 0 3 9 1 0 5 11 4} \\\n        {0 0 0 4 0 4 5 2 0 3 8 1 0 5 10 4}]\n\ncheck_terms_all fts3d-4.5.1     {a is test that this was}\ncheck_doclist_all fts3d-4.5.1.1 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist_all fts3d-4.5.1.2 is {[1 0[1]] [3 0[1]]}\ncheck_doclist_all fts3d-4.5.1.3 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist_all fts3d-4.5.1.4 that {[2 0[0]]}\ncheck_doclist_all fts3d-4.5.1.5 this {[1 0[0]] [3 0[0]]}\ncheck_doclist_all fts3d-4.5.1.6 was {[2 0[1]]}\n\ncheck_terms fts3d-4.5.2     1 0 {a is test that this was}\ncheck_doclist fts3d-4.5.2.1 1 0 a {[1 0[2]] [2 0[2]] [3 0[2]]}\ncheck_doclist fts3d-4.5.2.2 1 0 is {[1 0[1]] [3 0[1]]}\ncheck_doclist fts3d-4.5.2.3 1 0 test {[1 0[3]] [2 0[3]] [3 0[3]]}\ncheck_doclist fts3d-4.5.2.4 1 0 that {[2 0[0]]}\ncheck_doclist fts3d-4.5.2.5 1 0 this {[1 0[0]] [3 0[0]]}\ncheck_doclist fts3d-4.5.2.6 1 0 was {[2 0[1]]}\n\n# Re-optimizing does nothing.\ndo_test fts3d-5.0 {\n  execsql {\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index already optimal} 1 0}\n\n# Even if we move things around, still does nothing.\ndo_test fts3d-5.1 {\n  execsql {\n    UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;\n    SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;\n    SELECT level, idx FROM t1_segdir ORDER BY level, idx;\n  }\n} {{Index already optimal} 2 0}\n\n\n# ALTER TABLE RENAME should work regardless of the database encoding.\n#\ndo_test fts3d-6.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF8;\n    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {fts_content fts_segdir fts_segments}\ndo_test fts3d-6.1 {\n  db eval {\n    ALTER TABLE fts RENAME TO xyz;\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {xyz_content xyz_segdir xyz_segments}\ndo_test fts3d-6.2 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF16le;\n    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {fts_content fts_segdir fts_segments}\ndo_test fts3d-6.3 {\n  db eval {\n    ALTER TABLE fts RENAME TO xyz;\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {xyz_content xyz_segdir xyz_segments}\ndo_test fts3d-6.4 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF16be;\n    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {fts_content fts_segdir fts_segments}\ndo_test fts3d-6.5 {\n  db eval {\n    ALTER TABLE fts RENAME TO xyz;\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {xyz_content xyz_segdir xyz_segments}\n\n# ALTER TABLE RENAME on an FTS3 table following an incr-merge op.\n#\ndo_test fts3d-6.6 {\n  execsql { INSERT INTO xyz(xyz) VALUES('merge=2,2') }\n  sqlite3 db test.db\n  execsql { \n    ALTER TABLE xyz RENAME TO ott;\n    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;\n  }\n} {ott_content ott_segdir ott_segments ott_stat}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3defer.test",
    "content": "# 2010 October 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nifcapable !fts3||!fts4_deferred {\n  finish_test\n  return\n}\n\nset sqlite_fts3_enable_parentheses 1\n\nset fts3_simple_deferred_tokens_only 1\n\nset ::testprefix fts3defer\n\n#--------------------------------------------------------------------------\n# Test cases fts3defer-1.* are the \"warm body\" cases. The database contains\n# one row with 15000 instances of the token \"a\". This makes the doclist for\n# \"a\" so large that FTS3 will avoid loading it in most cases.\n#\n# To show this, test cases fts3defer-1.2.* execute a bunch of FTS3 queries\n# involving token \"a\". Then, fts3defer-1.3.* replaces the doclist for token\n# \"a\" with all zeroes and fts3defer-1.4.* repeats the tests from 1.2. If\n# the tests still work, we can conclude that the doclist for \"a\" was not\n# used.\n# \n\nset aaa [string repeat \"a \" 15000]\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4;\n  BEGIN;\n    INSERT INTO t1 VALUES('this is a dog');\n    INSERT INTO t1 VALUES('an instance of a phrase');\n    INSERT INTO t1 VALUES('an instance of a longer phrase');\n    INSERT INTO t1 VALUES($aaa);\n  COMMIT;\n} {}\n\nset tests {\n  1  {SELECT rowid FROM t1 WHERE t1 MATCH '\"a dog\"'}                 {1}\n  2  {SELECT rowid FROM t1 WHERE t1 MATCH '\"is a dog\"'}              {1}\n  3  {SELECT rowid FROM t1 WHERE t1 MATCH '\"a longer phrase\"'}       {3}\n  4  {SELECT snippet(t1) FROM t1 WHERE t1 MATCH '\"a longer phrase\"'}  \n     {\"an instance of <b>a</b> <b>longer</b> <b>phrase</b>\"}\n  5  {SELECT rowid FROM t1 WHERE t1 MATCH 'a dog'}                   {1}\n}\n\ndo_select_tests 1.2 $tests\n\ndo_execsql_test 1.3 {\n  SELECT count(*) FROM t1_segments WHERE length(block)>10000;\n  UPDATE t1_segments \n    SET block = zeroblob(length(block)) \n    WHERE length(block)>10000;\n} {1}\n\ndo_select_tests 1.4 $tests\n\n# Drop the table. It is corrupt now anyhow, so not useful for subsequent tests.\n#\ndo_execsql_test 1.5 { DROP TABLE t1 }\n\n#--------------------------------------------------------------------------\n# These tests - fts3defer-2.* - are more rigorous. They test that for a\n# variety of queries, FTS3 and FTS4 return the same results. And that \n# zeroing the very large doclists that FTS4 does not load does not change\n# the results.\n#\n# They use the following pseudo-randomly generated document data. The\n# tokens \"zm\" and \"jk\" are especially common in this dataset. Additionally,\n# two documents are added to the pseudo-random data before it is loaded\n# into FTS4 containing 100,000 instances of the \"zm\" and \"jk\" tokens. This\n# makes the doclists for those tokens so large that FTS4 avoids loading them\n# into memory if possible.\n#\nset data [list]\nlappend data [string repeat \"zm \" 100000]\nlappend data [string repeat \"jk \" 100000]\nlappend data {*}{\n  \"zm zm agmckuiu uhzq nsab jk rrkx duszemmzl hyq jk\"\n  \"jk uhzq zm zm rgpzmlnmd zm zk jk jk zm\"\n  \"duszemmzl zm jk xldlpy zm jk sbptoa xh jk xldlpy\"\n  \"zm xh zm xqf azavwm jk jk trqd rgpzmlnmd jk\"\n  \"zm vwq urvysbnykk ubwrfqnbjf zk lsz jk doiwavhwwo jk jk\"\n  \"jk xduvfhk orpfawpx zkhdvkw jk mjpavjuhw zm jk duszemmzl zm\"\n  \"jk igju jk jk zm hmjf xh zm gwdfhwurx zk\"\n  \"vgsld jk jk zm hrlipdm jn zm zsmhnf vgsld duszemmzl\"\n  \"gtuiexzsu aayxpmve zm zm zm drir scpgna xh azavwm uhzq\"\n  \"farlehdhq hkfoudzftq igju duszemmzl xnxhf ewle zm hrlipdm urvysbnykk kn\"\n  \"xnxhf jk jk agmckuiu duszemmzl jk zm zm jk vgsld\"\n  \"zm zm zm jk jk urvysbnykk ogttbykvt zm zm jk\"\n  \"iasrqgqv zm azavwm zidhxhbtv jk jk mjpavjuhw zm zm ajmvcydy\"\n  \"rgpzmlnmd tmt mjpavjuhw xh igju jk azavwm fibokdry vgsld ofm\"\n  \"zm jk vgsld jk xh jk csjqxhgj drir jk pmrb\"\n  \"xh jk jk zm rrkx duszemmzl mjpavjuhw xldlpy igju zm\"\n  \"jk hkfoudzftq zf rrkx wdmy jupk jk zm urvysbnykk npywgdvgz\"\n  \"zm jk zm zm zhbrzadb uenvbm aayxpmve urvysbnykk duszemmzl jk\"\n  \"uenvbm jk zm fxw xh bdilwmjw mjpavjuhw uv jk zm\"\n  \"nk jk bnhc pahlds jk igju dzadnqzprr jk jk jk\"\n  \"uhzq uv zm duszemmzl tlqix jk jk xh jk zm\"\n  \"jk zm agmckuiu urvysbnykk jk jk zm zm jk jk\"\n  \"azavwm mjpavjuhw lsgshn trqd xldlpy ogyavjvv agmckuiu ryvwwhlbc jk jk\"\n  \"tmt jk zk zm azavwm ofm acpgim bvgimjik iasrqgqv wuvajhwqz\"\n  \"igju ogyavjvv xrbdak rrkx fibokdry zf ujfhmrllq jk zm hxgwvib\"\n  \"zm pahlds jk uenvbm aayxpmve iaf hmjf xph vnlyvtkgx zm\"\n  \"jk xnxhf igju jk xh jk nvfasfh zm js jk\"\n  \"zm zm rwaj igju xr rrkx xnxhf nvfasfh skxbsqzvmt xatbxeqq\"\n  \"vgsld zm ujfhmrllq uhzq ogyavjvv nsab azavwm zm vgsld jmfiqhwnjg\"\n  \"ymjoym duszemmzl urvysbnykk azavwm jk jmfiqhwnjg bu qcdziqomqk vnlyvtkgx\"\n  \"zm nbilqcnz dzadnqzprr xh bkfgzsxn urvysbnykk xrujfzxqf zm zf agmckuiu\"\n  \"jk urvysbnykk nvfasfh zf xh zm zm qcdziqomqk qvxtclg wdmy\"\n  \"fibokdry jk urvysbnykk jk xr osff zm cvnnsl zm vgsld\"\n  \"jk mjpavjuhw hkfoudzftq jk zm xh xqf urvysbnykk jk iasrqgqv\"\n  \"jk csjqxhgj duszemmzl iasrqgqv aayxpmve zm brsuoqww jk qpmhtvl wluvgsw\"\n  \"jk mj azavwm jk zm jn dzadnqzprr zm jk uhzq\"\n  \"zk xqf jupk fxw nbilqcnz zm jk jcpiwj tznlvbfcv nvfasfh\"\n  \"jk jcpiwj zm xnxhf zm mjpavjuhw mj drir pa pvjrjlas\"\n  \"duszemmzl dzadnqzprr jk swc duszemmzl tmt jk jk pahlds jk\"\n  \"zk zm jk zm zm eczkjblu zm hi pmrb jk\"\n  \"azavwm zm iz agmckuiu jk sntk jk duszemmzl duszemmzl zm\"\n  \"jk zm jk eczkjblu urvysbnykk sk gnl jk ttvgf hmjf\"\n  \"jk bnhc jjrxpjkb mjpavjuhw fibokdry igju jk zm zm xh\"\n  \"wxe ogttbykvt uhzq xr iaf zf urvysbnykk aayxpmve oacaxgjoo mjpavjuhw\"\n  \"gazrt jk ephknonq myjp uenvbm wuvajhwqz jk zm xnxhf nvfasfh\"\n  \"zm aayxpmve csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm\"\n  \"sokcyf zm ogyavjvv jk zm fibokdry zm jk igju igju\"\n  \"vgsld bvgimjik xuprtlyle jk akmikrqyt jk aayxpmve hkfoudzftq ddjj ithtir\"\n  \"zm uhzq ovkyevlgv zk uenvbm csjqxhgj jk vgsld pgybs jk\"\n  \"zm agmckuiu zexh fibokdry jk uhzq bu tugflixoex xnxhf sk\"\n  \"zm zf uenvbm jk azavwm zm zm agmckuiu zm jk\"\n  \"rrkx jk zf jt zm oacaxgjoo fibokdry wdmy igju csjqxhgj\"\n  \"hi igju zm jk zidhxhbtv dzadnqzprr jk jk trqd duszemmzl\"\n  \"zm zm mjpavjuhw xrbdak qrvbjruc jk qzzqdxq guwq cvnnsl zm\"\n  \"ithtir jk jk qcdziqomqk zm farlehdhq zm zm xrbdak jk\"\n  \"ixfipk csjqxhgj azavwm sokcyf ttvgf vgsld jk sk xh zk\"\n  \"nvfasfh azavwm zm zm zm fxw nvfasfh zk gnl trqd\"\n  \"zm fibokdry csjqxhgj ofm dzadnqzprr jk akmikrqyt orpfawpx duszemmzl vwq\"\n  \"csjqxhgj jk jk vgsld urvysbnykk jk nxum jk jk nxum\"\n  \"zm hkfoudzftq jk ryvwwhlbc mjpavjuhw ephknonq jk zm ogyavjvv zm\"\n  \"lwa hi xnxhf qdyerbws zk njtc jk uhzq zm jk\"\n  \"trqd zm dzadnqzprr zm urvysbnykk jk lsz jk mjpavjuhw cmnnkna\"\n  \"duszemmzl zk jk jk fibokdry jseuhjnzo zm aayxpmve zk jk\"\n  \"fibokdry jk sviq qvxtclg wdmy jk doiwavhwwo zexh jk zm\"\n  \"jupk zm xh jk mjpavjuhw zm jk nsab npywgdvgz duszemmzl\"\n  \"zm igju zm zm nvfasfh eh hkfoudzftq fibokdry fxw xkblf\"\n  \"jk zm jk jk zm xh zk abthnzcv zf csjqxhgj\"\n  \"zm zm jk nkaotm urvysbnykk sbptoa bq jk ktxdty ubwrfqnbjf\"\n  \"nvfasfh aayxpmve xdcuz zm tugflixoex jcpiwj zm mjpavjuhw fibokdry doiwavhwwo\"\n  \"iaf jk mjpavjuhw zm duszemmzl jk jk uhzq pahlds fibokdry\"\n  \"ddjj zk azavwm jk swc zm gjtexkv jk xh jk\"\n  \"igju jk csjqxhgj zm jk dzadnqzprr duszemmzl ulvcbv jk jk\"\n  \"jk fibokdry zm csjqxhgj jn zm zm zm zf uhzq\"\n  \"duszemmzl jk xkblf zk hrlipdm aayxpmve uenvbm uhzq jk zf\"\n  \"dzadnqzprr jk zm zdu nvfasfh zm jk urvysbnykk hmjf jk\"\n  \"jk aayxpmve aserrdxm acpgim fibokdry jk drir wxe brsuoqww rrkx\"\n  \"uhzq csjqxhgj nvfasfh jk rrkx qbamok trqd uenvbm sntk zm\"\n  \"ps azavwm zkhdvkw jk zm jk jk zm csjqxhgj xedlrcfo\"\n  \"jk jk ogyavjvv jk zm farlehdhq duszemmzl jk agitgxamxe jk\"\n  \"qzzqdxq rwaj jk jk zm xqf jk uenvbm jk zk\"\n  \"zm hxgwvib akmikrqyt zf agmckuiu uenvbm bq npywgdvgz azavwm jk\"\n  \"zf jmfiqhwnjg js igju zm aayxpmve zm mbxnljomiv csjqxhgj nvfasfh\"\n  \"zm jk jk gazrt jk jk lkc jk nvfasfh jk\"\n  \"xldlpy orpfawpx zkhdvkw jk zm igju zm urvysbnykk dzadnqzprr mbxnljomiv\"\n  \"urvysbnykk jk zk igju zm uenvbm jk zm ithtir jk\"\n  \"zm zk zm zf ofm zm xdcuz dzadnqzprr zm vgsld\"\n  \"sbptoa jk tugflixoex jk zm zm vgsld zm xh zm\"\n  \"uhzq jk zk evvivo vgsld vniqnuynvf agmckuiu jk zm zm\"\n  \"zm nvfasfh zm zm zm abthnzcv uenvbm jk zk dzadnqzprr\"\n  \"zm azavwm igju qzzqdxq jk xnxhf abthnzcv jk nvfasfh zm\"\n  \"qbamok fxw vgsld igju cmnnkna xnxhf vniqnuynvf zk xh zm\"\n  \"nvfasfh zk zm mjpavjuhw dzadnqzprr jk jk duszemmzl xldlpy nvfasfh\"\n  \"xnxhf sviq nsab npywgdvgz osff vgsld farlehdhq fibokdry wjbkhzsa hhac\"\n  \"zm azavwm scpgna jk jk bq jk duszemmzl fibokdry ovkyevlgv\"\n  \"csjqxhgj zm jk jk duszemmzl zk xh zm jk zf\"\n  \"urvysbnykk dzadnqzprr csjqxhgj mjpavjuhw ubwrfqnbjf nkaotm jk jk zm drir\"\n  \"nvfasfh xh igju zm wluvgsw jk zm srwwnezqk ewle ovnq\"\n  \"jk nvfasfh eh ktxdty urvysbnykk vgsld zm jk eh uenvbm\"\n  \"orpfawpx pahlds jk uhzq hi zm zm zf jk dzadnqzprr\"\n  \"srwwnezqk csjqxhgj rbwzuf nvfasfh jcpiwj xldlpy nvfasfh jk vgsld wjybxmieki\"\n}\n\nproc add_empty_records {n} {\n  execsql BEGIN\n  for {set i 0} {$i < $n} {incr i} {\n    execsql { INSERT INTO t1 VALUES('') }\n  }\n  execsql COMMIT\n}\n\n\n#set e [list]\n#foreach d $data {set e [concat $e $d]}\n#puts [lsort -unique $e]\n#exit\n\nset zero_long_doclists {\n  UPDATE t1_segments SET block=zeroblob(length(block)) WHERE length(block)>10000\n}\n\nforeach {tn setup} {\n  1 {\n    set dmt_modes 0\n    execsql { CREATE VIRTUAL TABLE t1 USING FTS3 }\n    foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }\n  }\n  2 {\n    set dmt_modes 0\n    execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }\n    foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }\n  }\n  3 {\n    set dmt_modes {0 1 2}\n    execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }\n    foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }\n    add_empty_records 1000\n    execsql $zero_long_doclists\n  }\n  4 {\n    set dmt_modes 0\n    execsql { CREATE VIRTUAL TABLE t1 USING FTS4 }\n    foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }\n    add_empty_records 1000\n    execsql \"INSERT INTO t1(t1) VALUES('optimize')\"\n    execsql $zero_long_doclists\n  }\n  5 {\n    set dmt_modes 0\n    execsql { CREATE VIRTUAL TABLE t1 USING FTS4(matchinfo=fts3) }\n    foreach doc $data { execsql { INSERT INTO t1 VALUES($doc) } }\n    add_empty_records 1000\n    execsql $zero_long_doclists\n  }\n} {\n\n  execsql { DROP TABLE IF EXISTS t1 }\n  eval $setup\n  set ::testprefix fts3defer-2.$tn\n  set DO_MALLOC_TEST 0\n\n  do_execsql_test 0 { \n    SELECT count(*) FROM t1_segments WHERE length(block)>10000 \n  } {2}\n\n  do_select_test 1.1 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'jk xnxhf'\n  } {13 29 40 47 48 52 63 92}\n  do_select_test 1.2 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'jk eh'\n  } {100}\n  do_select_test 1.3 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf'\n  } {7 70 98}\n  do_select_test 1.4 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl jk'\n  } {3 5 8 10 13 18 20 23 32 37 41 43 55 60 65 67 72 74 76 81 94 96 97}\n  do_select_test 1.5 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'ubwrfqnbjf jk'\n  } {7 70 98}\n  do_select_test 1.6 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'jk ubwrfqnbjf jk jk jk jk'\n  } {7 70 98}\n  do_select_test 1.7 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'zm xnxhf'\n  } {12 13 29 30 40 47 48 52 63 92 93}\n  do_select_test 1.8 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'zm eh'\n  } {68 100}\n  do_select_test 1.9 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'zm ubwrfqnbjf'\n  } {7 70 98}\n  do_select_test 1.10 {\n    SELECT rowid FROM t1 WHERE t1 MATCH 'z* vgsld'\n  } {10 13 17 31 35 51 58 88 89 90 93 100}\n\n  if { $fts3_simple_deferred_tokens_only==0 } {\n    do_select_test 1.11 {\n      SELECT rowid FROM t1 \n      WHERE t1 MATCH '(\n        zdu OR zexh OR zf OR zhbrzadb OR zidhxhbtv OR \n        zk OR zkhdvkw OR zm OR zsmhnf\n      ) vgsld'\n    } {10 13 17 31 35 51 58 88 89 90 93 100}\n  }\n\n  do_select_test 2.1 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm agmckuiu\"'\n  } {3 24 52 53}\n  do_select_test 2.2 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm zf\"'\n  } {33 53 75 88 101}\n  do_select_test 2.3 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm aayxpmve\"'\n  } {48 65 84}\n  do_select_test 2.4 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"aayxpmve zm\"'\n  } {11 37 84}\n  do_select_test 2.5 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"jk azavwm\"'\n  } {16 53}\n  do_select_test 2.6 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"xh jk jk\"'\n  } {18}\n  do_select_test 2.7 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm jk vgsld\"'\n  } {13 17}\n  do_select_test 2.8 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm jk vgsld lkjlkjlkj\"'\n  } {}\n\n  do_select_test 3.1 {\n    SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '\"zm agmckuiu\"'\n  } {\n    {zm [zm] [agmckuiu] uhzq nsab jk rrkx duszemmzl hyq jk} \n    {jk [zm] [agmckuiu] urvysbnykk jk jk zm zm jk jk} \n    {[zm] [agmckuiu] zexh fibokdry jk uhzq bu tugflixoex xnxhf sk} \n    {zm zf uenvbm jk azavwm zm [zm] [agmckuiu] zm jk}\n  }\n\n  do_select_test 3.2 {\n    SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'xnxhf jk'\n  } {\n    {[xnxhf] [jk] [jk] agmckuiu duszemmzl [jk] zm zm [jk] vgsld} \n    {[jk] [xnxhf] igju [jk] xh [jk] nvfasfh zm js [jk]} \n    {[jk] jcpiwj zm [xnxhf] zm mjpavjuhw mj drir pa pvjrjlas} \n    {gazrt [jk] ephknonq myjp uenvbm wuvajhwqz [jk] zm [xnxhf] nvfasfh} \n    {zm aayxpmve csjqxhgj [xnxhf] xr [jk] aayxpmve [xnxhf] zm zm} \n    {zm agmckuiu zexh fibokdry [jk] uhzq bu tugflixoex [xnxhf] sk} \n    {lwa hi [xnxhf] qdyerbws zk njtc [jk] uhzq zm [jk]} \n    {zm azavwm igju qzzqdxq [jk] [xnxhf] abthnzcv [jk] nvfasfh zm}\n  }\n\n  do_select_test 4.1 {\n    SELECT offsets(t1) FROM t1 WHERE t1 MATCH '\"jk uenvbm\"'\n  } {\n    {0 0 10 2 0 1 13 6} {0 0 26 2 0 1 29 6}\n  }\n\n  do_select_test 4.2 {\n    SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'duszemmzl jk fibokdry'\n  } {\n    {0 2 3 8 0 1 36 2 0 0 58 9} \n    {0 0 0 9 0 1 13 2 0 1 16 2 0 2 19 8 0 1 53 2} \n    {0 1 4 2 0 0 20 9 0 1 30 2 0 1 33 2 0 2 48 8} \n    {0 1 17 2 0 1 20 2 0 1 26 2 0 0 29 9 0 2 39 8}\n  }\n\n  do_select_test 4.3 {\n    SELECT offsets(t1) FROM t1 \n    WHERE t1 MATCH 'vgsld (hrlipdm OR (aapmve NEAR duszemmzl))'\n  } {{0 0 0 5 0 1 15 7 0 0 36 5}}\n\n  # The following block of tests runs normally with FTS3 or FTS4 without the\n  # long doclists zeroed. And with OOM-injection for FTS4 with long doclists\n  # zeroed. Change this by messing with the [set dmt_modes] commands above.\n  #\n  foreach DO_MALLOC_TEST $dmt_modes {\n    \n    # Phrase search.\n    #\n    do_select_test 5.$DO_MALLOC_TEST.1 {\n      SELECT rowid FROM t1 WHERE t1 MATCH '\"jk mjpavjuhw\"'\n    } {8 15 36 64 67 72}\n\n    # Multiple tokens search.\n    do_select_test 5.$DO_MALLOC_TEST.2 {\n      SELECT rowid FROM t1 WHERE t1 MATCH 'duszemmzl zm'\n    } {3 5 8 10 12 13 18 20 23 37 43 55 60 65 67 72 74 81 94 96 97}\n\n    # snippet() function with phrase.\n    do_select_test 5.$DO_MALLOC_TEST.3 {\n      SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH '\"zm aayxpmve\"'\n    } {\n      {[zm] [aayxpmve] csjqxhgj xnxhf xr jk aayxpmve xnxhf zm zm} \n      {duszemmzl zk jk jk fibokdry jseuhjnzo [zm] [aayxpmve] zk jk} \n      {zf jmfiqhwnjg js igju [zm] [aayxpmve] zm mbxnljomiv csjqxhgj nvfasfh}\n    }\n    \n    # snippet() function with multiple tokens.\n    do_select_test 5.$DO_MALLOC_TEST.4 {\n      SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'zm zhbrzadb'\n    } {\n      {[zm] jk [zm] [zm] [zhbrzadb] uenvbm aayxpmve urvysbnykk duszemmzl jk}\n    }\n    \n    # snippet() function with phrase.\n    do_select_test 5.$DO_MALLOC_TEST.5 {\n      SELECT offsets(t1) FROM t1 WHERE t1 MATCH '\"zm aayxpmve\"'\n    } {\n      {0 0 0 2 0 1 3 8} {0 0 38 2 0 1 41 8} {0 0 22 2 0 1 25 8}\n    }\n    \n    # snippet() function with multiple tokens.\n    do_select_test 5.$DO_MALLOC_TEST.6 {\n      SELECT offsets(t1) FROM t1 WHERE t1 MATCH 'zm zhbrzadb'\n    } {\n      {0 0 0 2 0 0 6 2 0 0 9 2 0 1 12 8}\n    }\n\n    set DO_MALLOC_TEST 0\n  }\n\n  do_select_test 6.1 {\n    SELECT rowid FROM t1 \n    WHERE t1 MATCH 'vgsld (hrlipdm OR (aayxpmve duszemmzl))'\n  } {10}\n  do_select_test 6.2.1 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"jk xduvfhk\"'\n  } {8}\n  do_select_test 6.2.2 {\n    SELECT rowid FROM t1 WHERE t1 MATCH '\"zm azavwm\"'\n  } {15 26 92 96}\n  if {$fts3_simple_deferred_tokens_only==0} {\n    do_select_test 6.2.3 {\n      SELECT rowid FROM t1 WHERE t1 MATCH '\"jk xduvfhk\" OR \"zm azavwm\"'\n    } {8 15 26 92 96}\n  }\n\n  if {$tn>1} {\n    # These tests will not work with $tn==1, as in this case table t1 is\n    # created using FTS3. The ^ syntax is only available with FTS4 tables.\n    #\n    do_select_test 7.1 {\n      SELECT rowid FROM t1 WHERE t1 MATCH '^zm mjpavjuhw'\n    } {56 62}\n    do_select_test 7.2 {\n      SELECT rowid FROM t1 WHERE t1 MATCH '^azavwm zm'\n    } {43}\n  }\n}\n\nset testprefix fts3defer\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE x1 USING fts4(a, b);\n  INSERT INTO x1 VALUES('a b c', 'd e f');\n  INSERT INTO x1 SELECT * FROM x1;\n  INSERT INTO x1 SELECT * FROM x1;\n  INSERT INTO x1 SELECT * FROM x1;\n  INSERT INTO x1 SELECT * FROM x1;\n}\ndo_execsql_test 3.2 \"\n  INSERT INTO x1 VALUES(\n    '[string repeat {d } 3000]', '[string repeat {f } 30000]'\n  );\n  INSERT INTO x1(x1) VALUES('optimize');\n\"\n\ndo_execsql_test 3.3 {\n  SELECT count(*) FROM x1 WHERE x1 MATCH '\"d e f\"'\n} {16}\n\n# At one point the following was causing a floating-point exception.\n#\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE x2 USING FTS4(x);\n  BEGIN;\n  INSERT INTO x2 VALUES('m m m m m m m m m m m m m m m m m m m m m m m m m m');\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 SELECT * FROM x2;\n  INSERT INTO x2 VALUES('a b c d e f g h i j k l m n o p q r s t u v w x y m');\n  COMMIT;\n}\ndo_execsql_test 4.2 {\n  SELECT * FROM x2 WHERE x2 MATCH 'a b c d e f g h i j k l m n o p q r s';\n} {{a b c d e f g h i j k l m n o p q r s t u v w x y m}}\n\nset tokenizers {1 simple}\nifcapable icu { lappend tokenizers 2 {icu en_US} }\nforeach {tn tokenizer} $tokenizers {\n  do_execsql_test 5.$tn.1 \"\n    CREATE VIRTUAL TABLE x3 USING FTS4(a, b, TOKENIZE $tokenizer)\n  \"\n  do_execsql_test 5.$tn.2 {\n    BEGIN;\n    INSERT INTO x3 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 SELECT * FROM x3;\n    INSERT INTO x3 VALUES('a b c', NULL);\n    INSERT INTO x3 VALUES('a x c', NULL);\n    COMMIT;\n\n    SELECT * FROM x3 WHERE x3 MATCH 'a b';\n  } {{a b c} {}}\n\n  do_execsql_test 5.$tn.3 { DROP TABLE x3 }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3defer2.test",
    "content": "# 2010 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !fts3||!fts4_deferred {\n  finish_test \n  return\n}\n\nset testprefix fts3defer2\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\n#-----------------------------------------------------------------------------\n# This block of tests - fts3defer2-1.* - test the interaction of deferred NEAR\n# expressions and the snippet, offsets and matchinfo functions.\n# \ndo_execsql_test 1.1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4;\n}\ndo_execsql_test 1.1.2 \"INSERT INTO t1 VALUES('[string repeat {a } 20000]')\"\ndo_execsql_test 1.1.3 \"INSERT INTO t1 VALUES('[string repeat {z } 20000]')\"\ndo_execsql_test 1.1.4 {\n  INSERT INTO t1 VALUES('a b c d e f a x y');\n  INSERT INTO t1 VALUES('');\n  INSERT INTO t1 VALUES('');\n  INSERT INTO t1 VALUES('');\n  INSERT INTO t1 VALUES('');\n  INSERT INTO t1 VALUES('');\n  INSERT INTO t1(t1) VALUES('optimize');\n}\ndo_execsql_test 1.1.4 {\n  SELECT count(*) FROM t1_segments WHERE length(block)>10000;\n  UPDATE t1_segments SET block = zeroblob(length(block)) WHERE length(block)>10000;\n} {2}\n\ndo_execsql_test 1.2.0 {\n  SELECT content FROM t1 WHERE t1 MATCH 'f (e a)';\n} {{a b c d e f a x y}}\n\ndo_execsql_test 1.2.1 {\n  SELECT content FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';\n} {{a b c d e f a x y}}\n\n\ndo_execsql_test 1.2.2 {\n  SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))\n  FROM t1 WHERE t1 MATCH 'f (e NEAR/2 a)';\n} [list                              \\\n   {a b c d [e] [f] [a] x y}         \\\n   {0 1 8 1 0 0 10 1 0 2 12 1}       \\\n   [list 3 1   1 1 1   1 1 1   1 1 1   8 5001 9]\n]\n\ndo_execsql_test 1.2.3 {\n  SELECT snippet(t1, '[', ']'), offsets(t1), mit(matchinfo(t1, 'pcxnal'))\n  FROM t1 WHERE t1 MATCH 'f (e NEAR/3 a)';\n} [list                                 \\\n   {[a] b c d [e] [f] [a] x y}          \\\n   {0 2 0 1 0 1 8 1 0 0 10 1 0 2 12 1}  \\\n   [list 3 1   1 1 1   1 1 1   2 2 1   8 5001 9]\n]\n\ndo_execsql_test 1.3.1 { DROP TABLE t1 }\n\n#-----------------------------------------------------------------------------\n# Test cases fts3defer2-2.* focus specifically on the matchinfo function.\n# \ndo_execsql_test 2.1.1 \"CREATE VIRTUAL TABLE t2 USING fts4\"\ndo_execsql_test 2.1.2 \"INSERT INTO t2 VALUES('[string repeat {a } 10000]')\"\ndo_execsql_test 2.1.3 \"INSERT INTO t2 VALUES('b [string repeat {z } 10000]')\"\ndo_execsql_test 2.1.4 [string repeat \"INSERT INTO t2 VALUES('x');\" 50]\ndo_execsql_test 2.1.5 {\n  INSERT INTO t2 VALUES('a b c d e f g z');\n  INSERT INTO t2 VALUES('a b c d e f g');\n}\nforeach {tn sql} {\n  1 {}\n  2 { INSERT INTO t2(t2) VALUES('optimize') }\n  3 { UPDATE t2_segments SET block = zeroblob(length(block)) \n      WHERE length(block)>10000;\n  }\n} {\n  execsql $sql\n\n  do_execsql_test 2.2.$tn.1 {\n    SELECT mit(matchinfo(t2, 'pcxnal')) FROM t2 WHERE t2 MATCH 'a b';\n  } [list                                          \\\n    [list 2 1  1 54 54  1 3 3  54 372 8]        \\\n    [list 2 1  1 54 54  1 3 3  54 372 7]        \\\n  ]\n\n  do_execsql_test 2.2.$tn.2 {\n    SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g z';\n  } [list                                       \\\n    [list 1 2 2  1 54 54]                       \\\n  ]\n\n  set sqlite_fts3_enable_parentheses 1\n  do_execsql_test 2.2.$tn.3 {\n    SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'g OR (g z)';\n  } [list                                       \\\n    [list 1 2 2  1 2 2   1 54 54]               \\\n    [list 1 2 2  1 2 2   0 54 54]               \\\n  ]\n  set sqlite_fts3_enable_parentheses 0\n\n  do_execsql_test 2.2.$tn.4 {\n    SELECT mit(matchinfo(t2, 'x')) FROM t2 WHERE t2 MATCH 'e \"g z\"';\n  } [list                                       \\\n    [list 1 2 2  1 2 2]                         \\\n  ]\n}\n\ndo_execsql_test 2.3.1 {\n  CREATE VIRTUAL TABLE t3 USING fts4;\n  INSERT INTO t3 VALUES('a b c d e f');\n  INSERT INTO t3 VALUES('x b c d e f');\n  INSERT INTO t3 VALUES('d e f a b c');\n  INSERT INTO t3 VALUES('b c d e f');\n  INSERT INTO t3 VALUES('');\n  INSERT INTO t3 VALUES('');\n  INSERT INTO t3 VALUES('');\n  INSERT INTO t3 VALUES('');\n  INSERT INTO t3 VALUES('');\n  INSERT INTO t3 VALUES('');\n}\ndo_execsql_test 2.3.2 \"\n  INSERT INTO t3 VALUES('f e d c b [string repeat {a } 10000]')\n\"\nforeach {tn sql} {\n  1 {}\n  2 { INSERT INTO t3(t3) VALUES('optimize') }\n  3 { UPDATE t3_segments SET block = zeroblob(length(block)) \n      WHERE length(block)>10000;\n  }\n} {\n  execsql $sql\n  do_execsql_test 2.4.$tn {\n    SELECT docid, mit(matchinfo(t3, 'pcxnal')) FROM t3 WHERE t3 MATCH '\"a b c\"';\n  } {1 {1 1 1 4 4 11 912 6} 3 {1 1 1 4 4 11 912 6}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3defer3.test",
    "content": "# 2010 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains a very simple test to show that the deferred tokens\n# optimization is doing something.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !fts3||!fts4_deferred {\n  finish_test \n  return\n}\nset testprefix fts3defer3\n\nset nDoclist 3204\nset nDoc     800\n\n# Set up a database that contains 800 rows. Each row contains the document\n# \"b b\", except for the row with docid=200, which contains \"a b\". Hence\n# token \"b\" is extremely common and token \"a\" is not.\n#\ndo_test 1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts4;\n      BEGIN;\n  }\n  for {set i 1} {$i <= $nDoc} {incr i} {\n    set document \"b b\"\n    if {$i==200} { set document \"a b\" }\n    execsql { INSERT INTO t1 (docid, content) VALUES($i, $document) }\n  }\n  execsql COMMIT\n} {}\n\n# Check that the db contains two doclists. A small one for \"a\" and a \n# larger one for \"b\".\n#\ndo_execsql_test 1.2 {\n  SELECT blockid, length(block) FROM t1_segments;\n} [list 1 8 2 $nDoclist]\n\n# Query for 'a b'. Although this test doesn't prove so, token \"b\" will \n# be deferred because of the very large associated doclist.\n#\ndo_execsql_test 1.3 {\n  SELECT docid, content FROM t1 WHERE t1 MATCH 'a b';\n} {200 {a b}}\n\n# Zero out the doclist for token \"b\" within the database file. Now the \n# only queries that use token \"b\" that will work are those that defer\n# it. Any query that tries to use the doclist belonging to token \"b\"\n# will fail.\n#\ndo_test 1.4 {\n  set fd [db incrblob t1_segments block 2]\n  puts -nonewline $fd [string repeat \"\\00\" $nDoclist]\n  close $fd\n} {}\n\n# The first two queries succeed, as they defer token \"b\". The last one\n# fails, as it tries to load the corrupt doclist.\n#\ndo_execsql_test 1.5 {\n  SELECT docid, content FROM t1 WHERE t1 MATCH 'a b';\n} {200 {a b}}\ndo_execsql_test 1.6 {\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'a b';\n} {1}\ndo_catchsql_test 1.7 {\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'b';\n} {1 {database disk image is malformed}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3drop.test",
    "content": "# 2011 October 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module. More specifically,\n# that DROP TABLE commands can co-exist with savepoints inside transactions.\n# See ticket [48f299634a] for details.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3drop\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE f1 USING fts3;\n  INSERT INTO f1 VALUES('a b c');\n}\n\ndo_execsql_test 1.2 {\n  BEGIN;\n    INSERT INTO f1 VALUES('d e f');\n    SAVEPOINT one;\n      INSERT INTO f1 VALUES('g h i');\n      DROP TABLE f1;\n    ROLLBACK TO one;\n  COMMIT;\n}\n\ndo_execsql_test 1.3 {\n  SELECT * FROM f1;\n} {{a b c} {d e f}}\n\ndo_execsql_test 1.4 {\n  BEGIN;\n    INSERT INTO f1 VALUES('g h i');\n    SAVEPOINT one;\n      INSERT INTO f1 VALUES('j k l');\n      DROP TABLE f1;\n    RELEASE one;\n  ROLLBACK;\n}\n\ndo_execsql_test 1.5 {\n  SELECT * FROM f1;\n} {{a b c} {d e f}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3e.test",
    "content": "# 2008 July 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# These tests exercise the various types of fts3 cursors.\n#\n# $Id: fts3e.test,v 1.1 2008/07/29 20:24:46 shess Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#*************************************************************************\n# Test table scan (QUERY_GENERIC).  This kind of query happens for\n# queries with no WHERE clause, or for WHERE clauses which cannot be\n# satisfied by an index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  INSERT INTO t1 (docid, c) VALUES (1, 'This is a test');\n  INSERT INTO t1 (docid, c) VALUES (2, 'That was a test');\n  INSERT INTO t1 (docid, c) VALUES (3, 'This is a test');\n}\n\ndo_test fts3e-1.1 {\n  execsql {\n    SELECT docid FROM t1 ORDER BY docid;\n  }\n} {1 2 3}\n\ndo_test fts3e-1.2 {\n  execsql {\n    SELECT docid FROM t1 WHERE c LIKE '%test' ORDER BY docid;\n  }\n} {1 2 3}\n\ndo_test fts3e-1.3 {\n  execsql {\n    SELECT docid FROM t1 WHERE c LIKE 'That%' ORDER BY docid;\n  }\n} {2}\n\n#*************************************************************************\n# Test lookup by docid (QUERY_DOCID).  This kind of query happens for\n# queries which select by the docid/rowid implicit index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);\n  INSERT INTO t2 VALUES (null, 10);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');\n  INSERT INTO t2 VALUES (null, 5);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test');\n  INSERT INTO t2 VALUES (null, 20);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');\n}\n\n# TODO(shess): This actually is doing QUERY_GENERIC?  I'd have\n# expected QUERY_DOCID in this case, as for a very large table the\n# full scan is less efficient.\ndo_test fts3e-2.1 {\n  execsql {\n    SELECT docid FROM t1 WHERE docid in (1, 2, 10);\n    SELECT rowid FROM t1 WHERE rowid in (1, 2, 10);\n  }\n} {1 2 1 2}\n\ndo_test fts3e-2.2 {\n  execsql {\n    SELECT docid, weight FROM t1, t2 WHERE t2.id = t1.docid ORDER BY weight;\n    SELECT t1.rowid, weight FROM t1, t2 WHERE t2.id = t1.rowid ORDER BY weight;\n  }\n} {2 5 1 10 3 20 2 5 1 10 3 20}\n\ndo_test fts3e-2.3 {\n  execsql {\n    SELECT docid, weight FROM t1, t2\n           WHERE t2.weight>5 AND t2.id = t1.docid ORDER BY weight;\n    SELECT t1.rowid, weight FROM t1, t2\n           WHERE t2.weight>5 AND t2.id = t1.rowid ORDER BY weight;\n  }\n} {1 10 3 20 1 10 3 20}\n\n#*************************************************************************\n# Test lookup by MATCH (QUERY_FULLTEXT).  This is the fulltext index.\ndb eval {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t1 USING fts3(c);\n  CREATE TABLE t2(id INTEGER PRIMARY KEY AUTOINCREMENT, weight INTEGER UNIQUE);\n  INSERT INTO t2 VALUES (null, 10);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');\n  INSERT INTO t2 VALUES (null, 5);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'That was a test');\n  INSERT INTO t2 VALUES (null, 20);\n  INSERT INTO t1 (docid, c) VALUES (last_insert_rowid(), 'This is a test');\n}\n\ndo_test fts3e-3.1 {\n  execsql {\n    SELECT docid FROM t1 WHERE t1 MATCH 'this' ORDER BY docid;\n  }\n} {1 3}\n\ndo_test fts3e-3.2 {\n  execsql {\n    SELECT docid, weight FROM t1, t2\n     WHERE t1 MATCH 'this' AND t1.docid = t2.id ORDER BY weight;\n  }\n} {1 10 3 20}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3expr.test",
    "content": "# 2006 September 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n# $Id: fts3expr.test,v 1.9 2009/07/28 16:44:26 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset sqlite_fts3_enable_parentheses 1\n\nproc test_fts3expr {expr} {\n  db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}\n}\n\ndo_test fts3expr-1.0 {\n  test_fts3expr \"abcd\"\n} {PHRASE 3 0 abcd}\ndo_test fts3expr-1.1 {\n  test_fts3expr \" tag \"\n} {PHRASE 3 0 tag}\n\ndo_test fts3expr-1.2 {\n  test_fts3expr \"ab AND cd\"\n} {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.2.1 {\n  test_fts3expr \"ab cd\"\n} {AND {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.3 {\n  test_fts3expr \"ab OR cd\"\n} {OR {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.4 {\n  test_fts3expr \"ab NOT cd\"\n} {NOT {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.5 {\n  test_fts3expr \"ab NEAR cd\"\n} {NEAR/10 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.1 {\n  test_fts3expr \"ab NEAR/5 cd\"\n} {NEAR/5 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.2 {\n  test_fts3expr \"ab NEAR/87654321 cd\"\n} {NEAR/87654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.3 {\n  test_fts3expr \"ab NEAR/7654321 cd\"\n} {NEAR/7654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.4 {\n  test_fts3expr \"ab NEAR/654321 cd\"\n} {NEAR/654321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.5 {\n  test_fts3expr \"ab NEAR/54321 cd\"\n} {NEAR/54321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.6 {\n  test_fts3expr \"ab NEAR/4321 cd\"\n} {NEAR/4321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.7 {\n  test_fts3expr \"ab NEAR/321 cd\"\n} {NEAR/321 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\ndo_test fts3expr-1.6.8 {\n  test_fts3expr \"ab NEAR/21 cd\"\n} {NEAR/21 {PHRASE 3 0 ab} {PHRASE 3 0 cd}}\n\ndo_test fts3expr-1.7 {\n  test_fts3expr {\"one two three\"}\n} {PHRASE 3 0 one two three}\ndo_test fts3expr-1.8.1 {\n  test_fts3expr {zero \"one two three\" four}\n} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}\ndo_test fts3expr-1.8.2 {\n  test_fts3expr {zero AND \"one two three\" four}\n} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}\ndo_test fts3expr-1.8.3 {\n  test_fts3expr {zero \"one two three\" AND four}\n} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}\ndo_test fts3expr-1.8.4 {\n  test_fts3expr {zero AND \"one two three\" AND four}\n} {AND {AND {PHRASE 3 0 zero} {PHRASE 3 0 one two three}} {PHRASE 3 0 four}}\ndo_test fts3expr-1.9.1 {\n  test_fts3expr {\"one* two three\"}\n} {PHRASE 3 0 one+ two three}\ndo_test fts3expr-1.9.2 {\n  test_fts3expr {\"one two* three\"}\n} {PHRASE 3 0 one two+ three}\ndo_test fts3expr-1.9.3 {\n  test_fts3expr {\"one* two* three\"}\n} {PHRASE 3 0 one+ two+ three}\ndo_test fts3expr-1.9.4 {\n  test_fts3expr {\"one two three*\"}\n} {PHRASE 3 0 one two three+}\ndo_test fts3expr-1.9.5 {\n  test_fts3expr {\"one* two three*\"}\n} {PHRASE 3 0 one+ two three+}\ndo_test fts3expr-1.9.6 {\n  test_fts3expr {\"one two* three*\"}\n} {PHRASE 3 0 one two+ three+}\ndo_test fts3expr-1.9.7 {\n  test_fts3expr {\"one* two* three*\"}\n} {PHRASE 3 0 one+ two+ three+}\n\ndo_test fts3expr-1.10 {\n  test_fts3expr {one* two}\n} {AND {PHRASE 3 0 one+} {PHRASE 3 0 two}}\ndo_test fts3expr-1.11 {\n  test_fts3expr {one two*}\n} {AND {PHRASE 3 0 one} {PHRASE 3 0 two+}}\n\ndo_test fts3expr-1.14 {\n  test_fts3expr {a:one two}\n} {AND {PHRASE 0 0 one} {PHRASE 3 0 two}}\ndo_test fts3expr-1.15.1 {\n  test_fts3expr {one b:two}\n} {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}\ndo_test fts3expr-1.15.2 {\n  test_fts3expr {one B:two}\n} {AND {PHRASE 3 0 one} {PHRASE 1 0 two}}\n\ndo_test fts3expr-1.16 {\n  test_fts3expr {one AND two AND three AND four AND five}\n} [list AND \\\n        [list AND \\\n              [list AND \\\n                    [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n                    {PHRASE 3 0 three} \\\n              ] \\\n              {PHRASE 3 0 four} \\\n        ] \\\n        {PHRASE 3 0 five} \\\n  ]\ndo_test fts3expr-1.17 {\n  test_fts3expr {(one AND two) AND ((three AND four) AND five)}\n} [list AND \\\n        [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.18 {\n  test_fts3expr {(one AND two) OR ((three AND four) AND five)}\n} [list OR \\\n        [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.19 {\n  test_fts3expr {(one AND two) AND ((three AND four) OR five)}\n} [list AND \\\n        [list AND {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list OR \\\n              [list AND {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.20 {\n  test_fts3expr {(one OR two) AND ((three OR four) AND five)}\n} [list AND \\\n        [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.21 {\n  test_fts3expr {(one OR two) AND ((three NOT four) AND five)}\n} [list AND \\\n        [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list NOT {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.22 {\n  test_fts3expr {(one OR two) NOT ((three OR four) AND five)}\n} [list NOT \\\n        [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.23 {\n  test_fts3expr {(((((one OR two))))) NOT (((((three OR four))) AND five))}\n} [list NOT \\\n        [list OR {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.24 {\n  test_fts3expr {one NEAR two}\n} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]\ndo_test fts3expr-1.25 {\n  test_fts3expr {(one NEAR two)}\n} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]\ndo_test fts3expr-1.26 {\n  test_fts3expr {((((((one NEAR two))))))}\n} [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}]\ndo_test fts3expr-1.27 {\n  test_fts3expr {(one NEAR two) OR ((three OR four) AND five)}\n} [list OR \\\n        [list NEAR/10 {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\ndo_test fts3expr-1.28 {\n  test_fts3expr {(one NEAR/321 two) OR ((three OR four) AND five)}\n} [list OR \\\n        [list NEAR/321 {PHRASE 3 0 one} {PHRASE 3 0 two}] \\\n        [list AND \\\n              [list OR {PHRASE 3 0 three} {PHRASE 3 0 four}] \\\n             {PHRASE 3 0 five} \\\n        ] \\\n  ]\n\nproc strip_phrase_data {L} {\n  if {[lindex $L 0] eq \"PHRASE\"} {\n    return [lrange $L 3 end]\n  }\n  return [list \\\n    [lindex $L 0] \\\n    [strip_phrase_data [lindex $L 1]] \\\n    [strip_phrase_data [lindex $L 2]] \\\n  ]\n}\nproc test_fts3expr2 {expr} {\n  strip_phrase_data [\n    db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}\n  ]\n}\ndo_test fts3expr-2.1 {\n  test_fts3expr2 \"ab OR cd AND ef\"\n} {OR ab {AND cd ef}}\ndo_test fts3expr-2.2 {\n  test_fts3expr2 \"cd AND ef OR ab\"\n} {OR {AND cd ef} ab}\ndo_test fts3expr-2.3 {\n  test_fts3expr2 \"ab AND cd AND ef OR gh\"\n} {OR {AND {AND ab cd} ef} gh}\ndo_test fts3expr-2.4 {\n  test_fts3expr2 \"ab AND cd OR ef AND gh\"\n} {OR {AND ab cd} {AND ef gh}}\ndo_test fts3expr-2.5 {\n  test_fts3expr2 \"ab cd\"\n} {AND ab cd}\n\ndo_test fts3expr-3.1 {\n  test_fts3expr2 \"(ab OR cd) AND ef\"\n} {AND {OR ab cd} ef}\ndo_test fts3expr-3.2 {\n  test_fts3expr2 \"ef AND (ab OR cd)\"\n} {AND ef {OR ab cd}}\ndo_test fts3expr-3.3 {\n  test_fts3expr2 \"(ab OR cd)\"\n} {OR ab cd}\ndo_test fts3expr-3.4 {\n  test_fts3expr2 \"(((ab OR cd)))\"\n} {OR ab cd}\n\ndo_test fts3expr-3.5 {\n  test_fts3expr2 \"one AND (two NEAR three)\"\n} {AND one {NEAR/10 two three}}\ndo_test fts3expr-3.6 {\n  test_fts3expr2 \"one (two NEAR three)\"\n} {AND one {NEAR/10 two three}}\ndo_test fts3expr-3.7 {\n  test_fts3expr2 \"(two NEAR three) one\"\n} {AND {NEAR/10 two three} one}\ndo_test fts3expr-3.8 {\n  test_fts3expr2 \"(two NEAR three) AND one\"\n} {AND {NEAR/10 two three} one}\ndo_test fts3expr-3.9 {\n  test_fts3expr2 \"(two NEAR three) (four five)\"\n} {AND {NEAR/10 two three} {AND four five}}\ndo_test fts3expr-3.10 {\n  test_fts3expr2 \"(two NEAR three) AND (four five)\"\n} {AND {NEAR/10 two three} {AND four five}}\ndo_test fts3expr-3.11 {\n  test_fts3expr2 \"(two NEAR three) (four NEAR five)\"\n} {AND {NEAR/10 two three} {NEAR/10 four five}}\ndo_test fts3expr-3.12 {\n  test_fts3expr2 \"(two NEAR three) OR (four NEAR five)\"\n} {OR {NEAR/10 two three} {NEAR/10 four five}}\n\ndo_test fts3expr-3.13 {\n  test_fts3expr2 \"(two NEAR/1a three)\"\n} {AND {AND {AND two near} 1a} three}\n\ndo_test fts3expr-3.14 {\n  test_fts3expr2 \"(two NEAR// three)\"\n} {AND {AND two near} three}\ndo_test fts3expr-3.15 {\n  test_fts3expr2 \"(two NEAR/: three)\"\n} {AND {AND two near} three}\n\ndo_test fts3expr-3.16 {\n  test_fts3expr2 \"(two NEAR three)OR(four NEAR five)\"\n} {OR {NEAR/10 two three} {NEAR/10 four five}}\ndo_test fts3expr-3.17 {\n  test_fts3expr2 \"(two NEAR three)OR\\\"four five\\\"\"\n} {OR {NEAR/10 two three} {four five}}\ndo_test fts3expr-3.18 {\n  test_fts3expr2 \"one \\u0080wo\"\n} \"AND one \\u0080wo\"\n\n\n\n#------------------------------------------------------------------------\n# The following tests, fts3expr-4.*, test the parsers response to syntax\n# errors in query expressions. This is done using a real fts3 table and\n# MATCH clauses, not the parser test interface.\n# \ndo_test fts3expr-4.1 {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts3(a, b, c) }\n} {}\n\n# Mismatched parenthesis:\ndo_test fts3expr-4.2.1 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world))' }\n} {1 {malformed MATCH expression: [example AND (hello OR world))]}}\ndo_test fts3expr-4.2.2 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example AND (hello OR world' }\n} {1 {malformed MATCH expression: [example AND (hello OR world]}}\ndo_test fts3expr-4.2.3 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello' }\n} {1 {malformed MATCH expression: [(hello]}}\ndo_test fts3expr-4.2.4 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH '(' }\n} {1 {malformed MATCH expression: [(]}}\ndo_test fts3expr-4.2.5 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH ')' }\n} {1 {malformed MATCH expression: [)]}}\n\ndo_test fts3expr-4.2.6 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example (hello world' }\n} {1 {malformed MATCH expression: [example (hello world]}}\n\n# Unterminated quotation marks:\ndo_test fts3expr-4.3.1 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR \"hello world' }\n} {1 {malformed MATCH expression: [example OR \"hello world]}}\ndo_test fts3expr-4.3.2 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'example OR hello world\"' }\n} {1 {malformed MATCH expression: [example OR hello world\"]}}\n\n# Binary operators without the required operands.\ndo_test fts3expr-4.4.1 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'OR hello world' }\n} {1 {malformed MATCH expression: [OR hello world]}}\ndo_test fts3expr-4.4.2 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'hello world OR' }\n} {1 {malformed MATCH expression: [hello world OR]}}\ndo_test fts3expr-4.4.3 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (hello world OR) two' }\n} {1 {malformed MATCH expression: [one (hello world OR) two]}}\ndo_test fts3expr-4.4.4 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one (OR hello world) two' }\n} {1 {malformed MATCH expression: [one (OR hello world) two]}}\n\n# NEAR operators with something other than phrases as arguments.\ndo_test fts3expr-4.5.1 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH '(hello OR world) NEAR one' }\n} {1 {malformed MATCH expression: [(hello OR world) NEAR one]}}\ndo_test fts3expr-4.5.2 {\n  catchsql { SELECT * FROM t1 WHERE t1 MATCH 'one NEAR (hello OR world)' }\n} {1 {malformed MATCH expression: [one NEAR (hello OR world)]}}\n\n#------------------------------------------------------------------------\n# The following OOM tests are designed to cover cases in fts3_expr.c.\n# \nsource $testdir/malloc_common.tcl\ndo_malloc_test fts3expr-malloc-1 -sqlbody {\n  SELECT fts3_exprtest('simple', 'a b c \"d e f\"', 'a', 'b', 'c')\n}\ndo_malloc_test fts3expr-malloc-2 -tclprep {\n  set sqlite_fts3_enable_parentheses 0\n} -sqlbody {\n  SELECT fts3_exprtest('simple', 'a -b', 'a', 'b', 'c')\n} -cleanup {\n  set sqlite_fts3_enable_parentheses 1\n}\n\n#------------------------------------------------------------------------\n# The following tests are not very important. They cover error handling\n# cases in the test code, which makes test coverage easier to measure.\n# \ndo_test fts3expr-5.1 {\n  catchsql { SELECT fts3_exprtest('simple', 'a b') }\n} {1 {Usage: fts3_exprtest(tokenizer, expr, col1, ...}}\ndo_test fts3expr-5.2 {\n  catchsql { SELECT fts3_exprtest('doesnotexist', 'a b', 'c') }\n} {1 {No such tokenizer module}}\ndo_test fts3expr-5.3 {\n  catchsql { SELECT fts3_exprtest('simple', 'a b OR', 'c') }\n} {1 {Error parsing expression}}\n\n#------------------------------------------------------------------------\n# The next set of tests verifies that things actually work as they are\n# supposed to when using the new syntax.\n# \ndo_test fts3expr-6.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(a);\n  }\n  for {set ii 1} {$ii < 32} {incr ii} {\n    set v [list]\n    if {$ii & 1}  { lappend v one }\n    if {$ii & 2}  { lappend v two }\n    if {$ii & 4}  { lappend v three }\n    if {$ii & 8}  { lappend v four }\n    if {$ii & 16} { lappend v five }\n    execsql { INSERT INTO t1 VALUES($v) }\n  }\n\n  execsql {SELECT rowid FROM t1 WHERE t1 MATCH 'five four one' ORDER BY rowid}\n} {25 27 29 31}\n\nforeach {id expr res} {\n\n  2 \"five four NOT one\" {24 26 28 30}\n\n  3 \"five AND four OR one\" \n      {1 3 5 7 9 11 13 15 17 19 21 23 24 25 26 27 28 29 30 31}\n\n  4 \"five AND (four OR one)\" {17 19 21 23 24 25 26 27 28 29 30 31}\n\n  5 \"five NOT (four OR one)\" {16 18 20 22}\n\n  6 \"(five NOT (four OR one)) OR (five AND (four OR one))\"\n      {16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\n\n  7 \"(five OR one) AND two AND three\" {7 15 22 23 30 31}\n\n  8 \"five OR one AND two AND three\" \n    {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\n\n  9 \"five OR one two three\" \n    {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\n\n  10 \"five OR \\\"one two three\\\"\" \n    {7 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\n\n  11 \"one two OR four five NOT three\" {3 7 11 15 19 23 24 25 26 27 31}\n\n  12 \"(one two OR four five) NOT three\" {3 11 19 24 25 26 27}\n\n  13 \"((((((one two OR four five)))))) NOT three\" {3 11 19 24 25 26 27}\n\n} {\n  do_test fts3expr-6.1.$id {\n    execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }\n  } $res\n}\n\nset sqlite_fts3_enable_parentheses 0\nforeach {id expr res} {\n  1 \"one -two three\"  {5 13 21 29}\n  2 \"-two one three\"  {5 13 21 29}\n  3 \"one three -two\"  {5 13 21 29}\n  4 \"-one -two three\" {4 12 20 28}\n  5 \"three -one -two\" {4 12 20 28}\n  6 \"-one three -two\" {4 12 20 28}\n} {\n  do_test fts3expr-6.2.$id {\n    execsql { SELECT rowid FROM t1 WHERE t1 MATCH $expr ORDER BY rowid }\n  } $res\n}\nset sqlite_fts3_enable_parentheses 1\n\ndo_test fts3expr-7.1 {\n  execsql {\n    CREATE VIRTUAL TABLE test USING fts3 (keyword);\n    INSERT INTO test VALUES ('abc');\n    SELECT * FROM test WHERE keyword MATCH '\"\"';\n  }\n} {}\n\n\ndo_test fts3expr-8.0 { test_fts3expr \"(blah)\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.1 { test_fts3expr \"(blah.)\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.2 { test_fts3expr \"(blah,)\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.3 { test_fts3expr \"(blah!)\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.4 { test_fts3expr \"(blah-)\" } {PHRASE 3 0 blah}\n\ndo_test fts3expr-8.5 { test_fts3expr \"((blah.))\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.6 { test_fts3expr \"(((blah,)))\" } {PHRASE 3 0 blah}\ndo_test fts3expr-8.7 { test_fts3expr \"((((blah!))))\" } {PHRASE 3 0 blah}\n\ndo_test fts3expr-8.8 { test_fts3expr \"(,(blah-),)\" } {PHRASE 3 0 blah}\n\nset sqlite_fts3_enable_parentheses 0\n\ndo_test fts3expr-9.1 {\n  test_fts3expr \"f (e NEAR/2 a)\"\n} {AND {PHRASE 3 0 f} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}}\n\ndo_test fts3expr-10.1 { test_fts3expr \"abc *\" } {PHRASE 3 0 abc}\ndo_test fts3expr-10.2 { test_fts3expr \"*\" } {}\ndo_test fts3expr-10.3 { test_fts3expr \"abc*\" } {PHRASE 3 0 abc+}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3expr2.test",
    "content": "# 2009 January 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module syntax parser.\n#\n# $Id: fts3expr2.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Test overview:\n# \n#   The tests in this file are pseudo-randomly generated. They test\n#   the fts3 match expression parser via the test interface\n#   SQL function \"fts3_exprtest\" (see comments in fts3_expr.c).\n#\n#   Each test case works as follows:\n#   \n#     1. A random expression tree is generated using proc [random_expr_tree].\n#     2. The expression tree is converted to the text of an equivalent\n#        fts3 expression using proc [tree_to_expr].\n#     3. The test SQL function \"fts3_exprtest\" is used to parse the \n#        expression text generated in step (2), returning a parsed expression\n#        tree.\n#     4. Test that the tree returned in step (3) matches that generated in \n#        step (1).\n#\n#   In step (2), 4 different fts3 expressions are created from each \n#   expression tree by varying the following boolean properties:\n#\n#     * Whether or not superflous parenthesis are included. i.e. if\n#       \"a OR b AND (c OR d)\" or \"a OR (b AND (c OR d))\" is generated.\n#\n#     * Whether or not explict AND operators are used. i.e. if\n#     \"a OR b AND c\" or \"a OR b c\" is generated.\n#\n\nset sqlite_fts3_enable_parentheses 1\n\nproc strip_phrase_data {L} {\n  if {[lindex $L 0] eq \"PHRASE\"} {\n    return [list P [lrange $L 3 end]]\n  }\n  return [list \\\n    [lindex $L 0] \\\n    [strip_phrase_data [lindex $L 1]] \\\n    [strip_phrase_data [lindex $L 2]] \\\n  ]\n}\nproc test_fts3expr2 {expr} {\n  strip_phrase_data [\n    db one {SELECT fts3_exprtest('simple', $expr, 'a', 'b', 'c')}\n  ]\n}\n\nproc rnd {nMax} { expr {int(rand()*$nMax)} }\n\nproc random_phrase {} {\n  set phrases [list one two three four \"one two\" \"three four\"]\n  list P [lindex $phrases [rnd [llength $phrases]]]\n}\n\n# Generate and return a pseudo-random expression tree. Using the same \n# format returned by the [test_fts3expr2] proc.\n#\nproc random_expr_tree {iHeight} {\n  if {$iHeight==0 || [rnd 3]==0} {\n    return [random_phrase]\n  }\n\n  set operators [list NEAR NOT AND OR]\n  set op [lindex $operators [rnd 4]]\n\n  if {$op eq \"NEAR\"} {\n    set iDistance [rnd 15]\n    return [list $op/$iDistance [random_phrase] [random_phrase]]\n  }\n\n  set iNH [expr {$iHeight - 1}]\n  return [list $op [random_expr_tree $iNH] [random_expr_tree $iNH]]\n}\n\n# Given an expression tree, generate a corresponding expression.\n#\nproc tree_to_expr {tree all_brackets implicit_and} {\n  set prec(NOT) 2\n  set prec(AND) 3\n  set prec()    3\n  set prec(OR)  4\n\n  set op [lindex $tree 0]\n\n  if {$op eq \"P\"} {\n    set phrase [lindex $tree 1]\n    if {[llength $phrase]>1} {\n      return \"\\\"$phrase\\\"\"\n    } else {\n      return $phrase\n    }\n  }\n\n  if {$op eq \"NEAR/10\"} {\n    set op \"NEAR\"\n  }\n  if {$op eq \"AND\" && $implicit_and} {\n    set op \"\"\n  }\n\n  set lhs [lindex $tree 1]\n  set rhs [lindex $tree 2]\n  set zLeft  [tree_to_expr $lhs $all_brackets $implicit_and]\n  set zRight [tree_to_expr $rhs $all_brackets $implicit_and]\n\n  set iPrec 5\n  set iLeftPrec 0\n  set iRightPrec 0\n\n  catch {set iPrec      $prec($op)}\n  catch {set iLeftPrec  $prec([lindex $lhs 0])}\n  catch {set iRightPrec $prec([lindex $rhs 0])}\n\n  if {$iLeftPrec > $iPrec || $all_brackets} {\n    set zLeft \"($zLeft)\"\n  } \n  if {$iRightPrec >= $iPrec || $all_brackets} {\n    set zRight \"($zRight)\"\n  } \n\n  return \"$zLeft $op $zRight\"\n}\n\nproc do_exprparse_test {name expr tree} {\n  uplevel do_test $name [list \"test_fts3expr2 {$expr}\"] [list $tree]\n}\n\nfor {set iTest 1} {$iTest<500} {incr iTest} {\n  set t [random_expr_tree 4]\n\n  set e1 [tree_to_expr $t 0 0]\n  set e2 [tree_to_expr $t 0 1]\n  set e3 [tree_to_expr $t 1 0]\n  set e4 [tree_to_expr $t 1 1]\n\n  do_exprparse_test fts3expr2-$iTest.1 $e1 $t\n  do_exprparse_test fts3expr2-$iTest.2 $e2 $t\n  do_exprparse_test fts3expr2-$iTest.3 $e3 $t\n  do_exprparse_test fts3expr2-$iTest.4 $e4 $t\n}\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3expr3.test",
    "content": "# 2009 January 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the part of the FTS3 expression\n# parser that rebalances large expressions.\n#\n# $Id: fts3expr2.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix fts3expr3\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset sqlite_fts3_enable_parentheses 1\n\nproc strip_phrase_data {L} {\n  if {[lindex $L 0] eq \"PHRASE\"} {\n    return [list P [lrange $L 3 end]]\n  }\n  return [list \\\n    [lindex $L 0] \\\n    [strip_phrase_data [lindex $L 1]] \\\n    [strip_phrase_data [lindex $L 2]] \\\n  ]\n}\nproc test_fts3expr2 {expr} {\n  strip_phrase_data [\n    db one {SELECT fts3_exprtest_rebalance('simple', $expr, 'a', 'b', 'c')}\n  ]\n}\n\nproc balanced_exprtree_structure {nEntry} {\n  set L [list]\n  for {set i 1} {$i <= $nEntry} {incr i} {\n    lappend L xxx\n  }\n  while {[llength $L] > 1} {\n    set N [list]\n    if {[llength $L] % 2} {\n      foreach {a b} [lrange $L 0 end-1] { lappend N [list AND $a $b] }\n      lappend N [lindex $L end]\n    } else {\n      foreach {a b} $L { lappend N [list AND $a $b] }\n    }\n    set L $N\n  }\n  return [lindex $L 0]\n}\n\nproc balanced_and_tree {nEntry} {\n  set query [balanced_exprtree_structure $nEntry]\n  if {$query == \"xxx\"} {\n    return \"P 1\"\n  }\n  for {set i 1} {$i <= $nEntry} {incr i} {\n    regsub xxx $query \"{P $i}\" query\n  }\n  return $query\n}\n\nproc random_tree_structure {nEntry bParen op} {\n  set query xxx\n  for {set i 1} {$i < $nEntry} {incr i} {\n    set x1 [expr int(rand()*4.0)]\n    set x2 [expr int(rand()*2.0)]\n    if {$x1==0 && $bParen} {\n      set query \"($query)\"\n    }\n    if {$x2} {\n      set query \"xxx $op $query\"\n    } else {\n      set query \"$query $op xxx\"\n    }\n  }\n  return $query\n}\n\nproc random_and_query {nEntry {bParen 0}} {\n  set query [random_tree_structure $nEntry $bParen AND]\n  for {set i 1} {$i <= $nEntry} {incr i} {\n    regsub xxx $query $i query\n  }\n  return $query\n}\n\nproc random_or_query {nEntry} {\n  set query [random_tree_structure $nEntry 1 OR]\n  for {set i 1} {$i <= $nEntry} {incr i} {\n    regsub xxx $query $i query\n  }\n  return $query\n}\n\nproc random_andor_query {nEntry} {\n  set query [random_tree_structure $nEntry 1 AND]\n  for {set i 1} {$i <= $nEntry} {incr i} {\n    regsub xxx $query \"([random_or_query $nEntry])\" query\n  }\n  return $query\n}\n\nproc balanced_andor_tree {nEntry} {\n  set tree [balanced_exprtree_structure $nEntry]\n  set node \"{[balanced_and_tree $nEntry]}\"\n  regsub -all AND $node OR node\n  regsub -all xxx $tree $node tree\n  return $tree\n}\n\nif 1 {\n\n# Test that queries like \"1 AND 2 AND 3 AND 4...\" are transformed to \n# balanced trees by FTS.\n#\nfor {set i 1} {$i < 100} {incr i} {\n  do_test 1.$i {\n    test_fts3expr2 [random_and_query $i]\n  } [balanced_and_tree $i]\n}\n\n# Same again, except with parenthesis inserted at arbitrary points.\n#\nfor {set i 1} {$i < 100} {incr i} {\n  do_test 2.$i {\n    test_fts3expr2 [random_and_query $i 1]\n  } [balanced_and_tree $i]\n}\n\n# Now attempt to balance two AND trees joined by an OR.\n#\nfor {set i 1} {$i < 100} {incr i} {\n  do_test 3.$i {\n    test_fts3expr2 \"[random_and_query $i 1] OR [random_and_query $i 1]\"\n  } [list OR [balanced_and_tree $i] [balanced_and_tree $i]]\n}\n\n# Try trees of AND nodes with leaves that are themselves trees of OR nodes.\n#\nfor {set i 2} {$i < 64} {incr i 4} {\n  do_test 3.$i {\n    test_fts3expr2 [random_andor_query $i]\n  } [balanced_andor_tree $i]\n}\n\n# These exceed the depth limit. \n#\nfor {set i 65} {$i < 70} {incr i} {\n  do_test 3.$i {\n    list [catch {test_fts3expr2 [random_andor_query $i]} msg] $msg\n  } {1 {Error parsing expression}}\n}\n\n# This also exceeds the depth limit. \n#\n\ndo_test 4.1.1 {\n  set q \"1\"\n  for {set i 2} {$i < 5000} {incr i} {\n    append q \" AND $i\"\n  }\n  list [catch {test_fts3expr2 $q} msg] $msg\n} {1 {Error parsing expression}}\ndo_test 4.1.2 {\n  set q \"1\"\n  for {set i 2} {$i < 4000} {incr i} {\n    append q \" AND $i\"\n  }\n  catch {test_fts3expr2 $q}\n} {0}\n\nproc create_toggle_tree {nDepth} {\n  if {$nDepth == 0} { return xxx }\n  set nNew [expr $nDepth-1]\n  if {$nDepth % 2} {\n    return \"([create_toggle_tree $nNew]) OR ([create_toggle_tree $nNew])\"\n  }\n  return \"([create_toggle_tree $nNew]) AND ([create_toggle_tree $nNew])\"\n}\n\ndo_test 4.2 {\n  list [catch {test_fts3expr2 [create_toggle_tree 17]} msg] $msg\n} {1 {Error parsing expression}}\n\nset query [random_andor_query 12]\nset result [balanced_andor_tree 12]\ndo_faultsim_test fts3expr3-fault-1 -faults oom-* -body {\n  test_fts3expr2 $::query\n} -test {\n  faultsim_test_result [list 0 $::result]\n}\n\n}\n\n#-------------------------------------------------------------------\n\nforeach {tn expr res} {\n  1 {1 OR 2 OR 3 OR 4}           {OR {OR {P 1} {P 2}} {OR {P 3} {P 4}}} \n  2 {1 OR (2 AND 3 AND 4 AND 5)} \n    {OR {P 1} {AND {AND {P 2} {P 3}} {AND {P 4} {P 5}}}}\n  3 {(2 AND 3 AND 4 AND 5) OR 1} \n    {OR {AND {AND {P 2} {P 3}} {AND {P 4} {P 5}}} {P 1}}\n\n  4 {1 AND (2 OR 3 OR 4 OR 5)} \n    {AND {P 1} {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}}}\n  5 {(2 OR 3 OR 4 OR 5) AND 1} \n    {AND {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}} {P 1}}\n\n  6 {(2 OR 3 OR 4 OR 5) NOT 1} \n    {NOT {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}} {P 1}}\n\n  7 {1 NOT (2 OR 3 OR 4 OR 5)} \n    {NOT {P 1} {OR {OR {P 2} {P 3}} {OR {P 4} {P 5}}}}\n\n  8 {(1 OR 2 OR 3 OR 4) NOT (5 AND 6 AND 7 AND 8)}\n    {NOT {OR {OR {P 1} {P 2}} {OR {P 3} {P 4}}} {AND {AND {P 5} {P 6}} {AND {P 7} {P 8}}}}\n} {\n  do_test 5.1.$tn {\n    test_fts3expr2 $expr\n  } $res\n}\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3expr4.test",
    "content": "# 2014 May 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3expr4\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3||!icu {\n  finish_test\n  return\n}\n\nset sqlite_fts3_enable_parentheses 1\n\nproc test_fts3expr {tokenizer expr} {\n  db one {SELECT fts3_exprtest($tokenizer, $expr, 'a', 'b', 'c')}\n}\n\nproc do_icu_expr_test {tn expr res} {\n  uplevel [list do_test $tn [list test_fts3expr icu $expr] [list {*}$res]]\n}\n\nproc do_simple_expr_test {tn expr res} {\n  uplevel [list do_test $tn [list test_fts3expr simple $expr] [list {*}$res]]\n}\n\n#-------------------------------------------------------------------------\n#\ndo_icu_expr_test 1.1 \"abcd\"    {PHRASE 3 0 abcd}\ndo_icu_expr_test 1.2 \" tag \"   {PHRASE 3 0 tag}\ndo_icu_expr_test 1.3 {\"x y z\"} {PHRASE 3 0 x y z}\ndo_icu_expr_test 1.4 {x OR y}       {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}\ndo_icu_expr_test 1.5 {(x OR y)}     {OR {PHRASE 3 0 x} {PHRASE 3 0 y}}\ndo_icu_expr_test 1.6 { \"(x OR y)\" } {PHRASE 3 0 ( x or y )}\n\n# In \"col:word\", if \"col\" is not the name of a column, the entire thing\n# is passed to the tokenizer.\n#\ndo_icu_expr_test 1.7 {a:word} {PHRASE 0 0 word}\ndo_icu_expr_test 1.8 {d:word} {PHRASE 3 0 d:word}\n\nset sqlite_fts3_enable_parentheses 0\n\ndo_icu_expr_test 2.1 {\n  f (e NEAR/2 a)\n} {AND {AND {AND {PHRASE 3 0 f} {PHRASE 3 0 (}} {NEAR/2 {PHRASE 3 0 e} {PHRASE 3 0 a}}} {PHRASE 3 0 )}}\n\n#-------------------------------------------------------------------------\n#\ndo_simple_expr_test 3.1 {*lOl* *h4h*} {\n  AND {PHRASE 3 0 lol+} {PHRASE 3 0 h4h+}\n}\n\ndo_icu_expr_test 3.2 {*lOl* *h4h*} {\n  AND {AND {AND {PHRASE 3 0 *} {PHRASE 3 0 lol+}} {PHRASE 3 0 *}} {PHRASE 3 0 h4h+}\n}\n\ndo_simple_expr_test 3.3 { * }    { }\ndo_simple_expr_test 3.4 { *a }   { PHRASE 3 0 a }\ndo_simple_expr_test 3.5 { a*b }  { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }\ndo_simple_expr_test 3.6 { *a*b } { AND {PHRASE 3 0 a+} {PHRASE 3 0 b} }\ndo_simple_expr_test 3.7 { *\"abc\" } { PHRASE 3 0 abc }\ndo_simple_expr_test 3.8 { \"abc\"* } { PHRASE 3 0 abc }\ndo_simple_expr_test 3.8 { \"ab*c\" } { PHRASE 3 0 ab+ c }\n\ndo_icu_expr_test    3.9 { \"ab*c\" } { PHRASE 3 0 ab+ * c }\ndo_icu_expr_test    3.10 { ab*c } { AND {PHRASE 3 0 ab+} {PHRASE 3 0 c}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3expr5.test",
    "content": "# 2006 September 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3expr5\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Various forms of empty phrase expressions.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t0 USING fts3(x);\n  SELECT rowid FROM t0 WHERE x MATCH '';\n} {}\ndo_execsql_test 1.1 {\n  SELECT rowid FROM t0 WHERE x MATCH '\"\"';\n} {}\ndo_execsql_test 1.2 {\n  SELECT rowid FROM t0 WHERE x MATCH '\"\" \"\"';\n} {}\ndo_execsql_test 1.3 {\n  SELECT rowid FROM t0 WHERE x MATCH '\"\" OR \"\"';\n} {}\ndo_execsql_test 1.4 {\n  SELECT rowid FROM t0 WHERE x MATCH '\"\" NOT \"\"';\n} {}\ndo_execsql_test 1.5 {\n  SELECT rowid FROM t0 WHERE x MATCH '\"\"\"\"';\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3fault.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix fts3fault\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\n# Test error handling in the sqlite3Fts3Init() function. This is the \n# function that registers the FTS3 module and various support functions\n# with SQLite.\n#\ndo_faultsim_test 1 -body { \n  sqlite3 db test.db \n  expr 0\n} -test {\n  catch { db close }\n}\n\n# Test error handling in an \"ALTER TABLE ... RENAME TO\" statement on an\n# FTS3 table. Specifically, test renaming the table within a transaction\n# after it has been written to.\n#\nfaultsim_delete_and_reopen\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3;\n  INSERT INTO t1 VALUES('test renaming the table');\n  INSERT INTO t1 VALUES(' after it has been written');\n}\ndo_faultsim_test 2 -prep { \n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES('registers the FTS3 module');\n      INSERT INTO t1 VALUES('various support functions');\n  }\n} -body {\n  execsql { ALTER TABLE t1 RENAME TO t2 }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\n# Test error handling in the special case where a single prefix query \n# matches terms that reside on a large range of leaf nodes.\n#\ndo_test fts3fault-3.0 {\n  sqlite3 db test.db\n  execsql { CREATE VIRTUAL TABLE t3 USING fts4; }\n  execsql { INSERT INTO t3(t3) VALUES('nodesize=50') }\n  execsql { BEGIN }\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql { INSERT INTO t3 VALUES('aaa' || $i) }\n  }\n  execsql { COMMIT }\n} {}\n\ndo_faultsim_test 3 -faults oom-transient -prep { \n  sqlite3 db test.db\n  execsql { SELECT * FROM t3 WHERE t3 MATCH 'x' }\n} -body {\n  execsql { SELECT count(rowid) FROM t3 WHERE t3 MATCH 'aa*' }\n} -test {\n  faultsim_test_result {0 1000} \n}\n\ndo_test fts3fault-4.0 {\n  faultsim_delete_and_reopen\n  execsql { \n    CREATE VIRTUAL TABLE t4 USING fts4; \n    INSERT INTO t4 VALUES('The British Government called on');\n    INSERT INTO t4 VALUES('as pesetas then became much');\n  }\n} {}\nfaultsim_save_and_close\ndo_faultsim_test 4 -prep { \n  faultsim_restore_and_reopen\n  execsql { SELECT content FROM t4 }\n} -body {\n  execsql { SELECT optimize(t4) FROM t4 LIMIT 1 }\n} -test {\n  faultsim_test_result {0 {{Index optimized}}}\n}\n\ndo_test fts3fault-5.0 {\n  faultsim_delete_and_reopen\n  execsql { \n    CREATE VIRTUAL TABLE t5 USING fts4; \n    INSERT INTO t5 VALUES('The British Government called on');\n    INSERT INTO t5 VALUES('as pesetas then became much');\n  }\n} {}\nfaultsim_save_and_close\ndo_faultsim_test 5 -prep { \n  faultsim_restore_and_reopen\n  execsql { \n    BEGIN;\n      INSERT INTO t5 VALUES('influential in shaping his future outlook');\n      INSERT INTO t5 VALUES('might be acceptable to the British electorate');\n  }\n} -body {\n  execsql { SELECT rowid FROM t5 WHERE t5 MATCH 'british' }\n} -test {\n  faultsim_test_result {0 {1 4}}\n}\n\ndo_test fts3fault-6.0 {\n  faultsim_delete_and_reopen\n  execsql { CREATE VIRTUAL TABLE t6 USING fts4 }\n} {}\nfaultsim_save_and_close\ndo_faultsim_test 6 -prep { \n  faultsim_restore_and_reopen\n  execsql { SELECT rowid FROM t6 }\n} -body {\n  execsql { DROP TABLE t6 }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n# Test various malloc failures while processing FTS4 parameters.\n#\ndo_faultsim_test 7.1 -prep { \n  faultsim_delete_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchinfo=fts3) }\n} -test {\n  faultsim_test_result {0 {}}\n}\ndo_faultsim_test 7.2 -prep { \n  faultsim_delete_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchinfo=fs3) }\n} -test {\n  faultsim_test_result {1 {unrecognized matchinfo: fs3}} \\\n                       {1 {vtable constructor failed: t1}} \\\n                       {1 {SQL logic error}}\n}\ndo_faultsim_test 7.3 -prep { \n  faultsim_delete_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, matchnfo=fts3) }\n} -test {\n  faultsim_test_result {1 {unrecognized parameter: matchnfo=fts3}} \\\n                       {1 {vtable constructor failed: t1}} \\\n                       {1 {SQL logic error}}\n}\n\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\n\ndo_test 8.0 {\n  faultsim_delete_and_reopen\n  execsql { CREATE VIRTUAL TABLE t8 USING fts4 }\n  execsql \"INSERT INTO t8 VALUES('a b c')\"\n  execsql \"INSERT INTO t8 VALUES('b b b')\"\n  execsql \"INSERT INTO t8 VALUES('[string repeat {c } 50000]')\"\n  execsql \"INSERT INTO t8 VALUES('d d d')\"\n  execsql \"INSERT INTO t8 VALUES('e e e')\"\n  execsql \"INSERT INTO t8(t8) VALUES('optimize')\"\n  faultsim_save_and_close\n} {}\n\nifcapable fts4_deferred {\n  do_faultsim_test 8.1 -faults oom-t* -prep { \n    faultsim_restore_and_reopen\n    db func mit mit\n  } -body {\n    execsql { SELECT mit(matchinfo(t8, 'x')) FROM t8 WHERE t8 MATCH 'a b c' }\n  } -test {\n    faultsim_test_result {0 {{1 1 1 1 4 2 1 5 5}}}\n  }\n}\n\ndo_faultsim_test 8.2 -faults oom-t* -prep { \n  faultsim_restore_and_reopen\n  db func mit mit\n} -body {\n  execsql { SELECT mit(matchinfo(t8, 's')) FROM t8 WHERE t8 MATCH 'a b c' }\n} -test {\n  faultsim_test_result {0 3}\n}\ndo_faultsim_test 8.3 -prep { \n  faultsim_restore_and_reopen\n  db func mit mit\n} -body {\n  execsql { SELECT mit(matchinfo(t8, 'a')) FROM t8 WHERE t8 MATCH 'a b c' }\n} -test {\n  faultsim_test_result {0 10002}\n}\ndo_faultsim_test 8.4 -prep { \n  faultsim_restore_and_reopen\n  db func mit mit\n} -body {\n  execsql { SELECT mit(matchinfo(t8, 'l')) FROM t8 WHERE t8 MATCH 'a b c' }\n} -test {\n  faultsim_test_result {0 3}\n}\n\ndo_test 9.0 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE VIRTUAL TABLE t9 USING fts4(tokenize=porter);\n    INSERT INTO t9 VALUES(\n      'this record is used toooooooooooooooooooooooooooooooooooooo try to'\n    );\n    SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to*';\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test 9.1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to*' }\n} -test {\n  faultsim_test_result {0 {{0 0 20 39 0 0 64 2}}}\n}\n\ndo_faultsim_test 10.1 -prep {\n  faultsim_delete_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=d) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3fault2.test",
    "content": "# 2011 February 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix fts3fault2\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\ndo_test 1.0 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts4(x);\n    INSERT INTO t1 VALUES('a b c');\n    INSERT INTO t1 VALUES('c d e');\n    CREATE VIRTUAL TABLE terms USING fts4aux(t1);\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 1.1 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql \"CREATE VIRTUAL TABLE terms2 USING fts4aux(t1)\"\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 1.2 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql \"SELECT * FROM terms\"\n} -test {\n  faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 2 2 c 0 2 2 d * 1 1 d 0 1 1 e * 1 1 e 0 1 1}}\n}\n\ndo_faultsim_test 1.3 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql \"SELECT * FROM terms WHERE term>'a' AND TERM < 'd'\"\n} -test {\n  faultsim_test_result {0 {b * 1 1 b 0 1 1 c * 2 2 c 0 2 2}}\n}\n\ndo_faultsim_test 1.4 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql \"SELECT * FROM terms WHERE term='c'\"\n} -test {\n  faultsim_test_result {0 {c * 2 2 c 0 2 2}}\n}\n\ndo_test 2.0 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE VIRTUAL TABLE tx USING fts4(a, b);\n    INSERT INTO tx VALUES('a b c', 'x y z');\n    CREATE VIRTUAL TABLE terms2 USING fts4aux(tx);\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 2.1 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql \"SELECT * FROM terms2\"\n} -test {\n  faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}}\n}\n\ndo_faultsim_test 3.0 -faults oom* -prep {\n  faultsim_delete_and_reopen\n  db eval { CREATE TABLE 'xx yy'(a, b); }\n} -body {\n  execsql {\n    CREATE VIRTUAL TABLE tt USING fts4(content=\"xx yy\");\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 3.1 -faults oom* -prep {\n  faultsim_delete_and_reopen\n  db func zip zip\n  db func unzip unzip\n} -body {\n  execsql {\n    CREATE VIRTUAL TABLE tt USING fts4(compress=zip, uncompress=unzip);\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test 4.0 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE VIRTUAL TABLE ft USING fts4(a, b);\n    INSERT INTO ft VALUES('U U T C O', 'F N D E S');\n    INSERT INTO ft VALUES('P H X G B', 'I D M R U');\n    INSERT INTO ft VALUES('P P X D M', 'Y V N T C');\n    INSERT INTO ft VALUES('Z L Q O W', 'D F U N Q');\n    INSERT INTO ft VALUES('A J D U P', 'C H M Q E');\n    INSERT INTO ft VALUES('P S A O H', 'S Z C W D');\n    INSERT INTO ft VALUES('T B N L W', 'C A K T I');\n    INSERT INTO ft VALUES('K E Z L O', 'L L Y C E');\n    INSERT INTO ft VALUES('C R E S V', 'Q V F W P');\n    INSERT INTO ft VALUES('S K H G W', 'R W Q F G');\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test 4.1 -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql { INSERT INTO ft(ft) VALUES('rebuild') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nifcapable fts3_unicode {\n  do_test 5.0 {\n    faultsim_delete_and_reopen\n    execsql {\n      CREATE VIRTUAL TABLE ft USING fts4(a, tokenize=unicode61);\n    }\n    faultsim_save_and_close\n  } {}\n  \n  do_faultsim_test 5.1 -faults oom* -prep {\n    faultsim_restore_and_reopen\n    db eval {SELECT * FROM sqlite_master}\n  } -body {\n    execsql { INSERT INTO ft VALUES('the quick brown fox'); }\n    execsql { INSERT INTO ft VALUES(\n       'theunusuallylongtokenthatjustdragsonandonandonandthendragsonsomemoreeof'\n      );\n    }\n    execsql { SELECT docid FROM ft WHERE ft MATCH 'th*' }\n  } -test {\n    faultsim_test_result {0 {1 2}}\n  }\n}\n\nreset_db\ndo_test 6.0 {\n  execsql {\n    CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);\n    INSERT INTO t6(docid, x) VALUES(-1,'a b');\n    INSERT INTO t6(docid, x) VALUES(1, 'b');\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 6.1 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  db eval {SELECT * FROM sqlite_master}\n} -body {\n  execsql { SELECT docid FROM t6 WHERE t6 MATCH '\"a* b\"' }\n} -test {\n  faultsim_test_result {0 -1}\n}\n\n#-------------------------------------------------------------------------\n# Inject faults into a query for an N-byte prefix that uses a prefix=N+1\n# index.\nreset_db\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE t7 USING fts4(x,prefix=2);\n  INSERT INTO t7 VALUES('the quick brown fox');\n  INSERT INTO t7 VALUES('jumped over the');\n  INSERT INTO t7 VALUES('lazy dog');\n}\ndo_faultsim_test 7.1 -faults oom* -body {\n  execsql { SELECT docid FROM t7 WHERE t7 MATCH 't*' }\n} -test {\n  faultsim_test_result {0 {1 2}}\n}\n\n#-------------------------------------------------------------------------\n# Inject faults into a opening an existing fts3 table that has been \n# upgraded to add an %_stat table.\n#\nreset_db\ndo_execsql_test 8.0 {\n  CREATE VIRTUAL TABLE t8 USING fts3;\n  INSERT INTO t8 VALUES('the quick brown fox');\n  INSERT INTO t8 VALUES('jumped over the');\n  INSERT INTO t8 VALUES('lazy dog');\n  INSERT INTO t8(t8) VALUES('automerge=8');\n  SELECT name FROM sqlite_master WHERE name LIKE 't8%';\n} {\n  t8 t8_content t8_segments t8_segdir t8_stat\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 8.1 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO t8 VALUES('one two three') }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_faultsim_test 8.2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { ALTER TABLE t8 RENAME TO t8ii }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\nreset_db\nset chunkconfig [fts3_configure_incr_load 1 1]\ndo_execsql_test 9.0 {\n  PRAGMA page_size = 512;\n  CREATE VIRTUAL TABLE t9 USING fts3;\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50\n  )\n  INSERT INTO t9 SELECT 'one two three' FROM s;\n}\n\ndo_faultsim_test 8.2 -faults io* -body {\n  execsql { SELECT count(*) FROM t9 WHERE t9 MATCH '\"one two three\"' }\n} -test {\n  faultsim_test_result {0 50}\n}\n\neval fts3_configure_incr_load $chunkconfig\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3first.test",
    "content": "# 2011 October 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset testprefix fts3first\n\nproc lreverse {L} {\n  set res [list]\n  for {set ii [expr [llength $L]-1]} {$ii>=0} {incr ii -1} {\n    lappend res [lindex $L $ii]\n  }\n  set res\n}\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE x1 USING FTS4(a, b, c);\n  INSERT INTO x1(docid,a,b,c) VALUES(0, 'K H D S T', 'V M N Y K', 'S Z N Q S');\n  INSERT INTO x1(docid,a,b,c) VALUES(1, 'K N J L W', 'S Z W J Q', 'D U W S E');\n  INSERT INTO x1(docid,a,b,c) VALUES(2, 'B P M O I', 'R P H W S', 'R J L L E');\n  INSERT INTO x1(docid,a,b,c) VALUES(3, 'U R Q M L', 'M J K A V', 'Q W J T J');\n  INSERT INTO x1(docid,a,b,c) VALUES(4, 'N J C Y N', 'R U D X V', 'B O U A Q');\n  INSERT INTO x1(docid,a,b,c) VALUES(5, 'Q L X L U', 'I F N X S', 'U Q A N Y');\n  INSERT INTO x1(docid,a,b,c) VALUES(6, 'M R G U T', 'U V I Q P', 'X Y D L S');\n  INSERT INTO x1(docid,a,b,c) VALUES(7, 'D Y P O I', 'X J P K R', 'V O T H V');\n  INSERT INTO x1(docid,a,b,c) VALUES(8, 'R Y D L R', 'U U E S J', 'N W L M R');\n  INSERT INTO x1(docid,a,b,c) VALUES(9, 'Z P F N P', 'W A X D U', 'V A E Q A');\n  INSERT INTO x1(docid,a,b,c) VALUES(10, 'Q I A Q M', 'N D K H C', 'A H T Q Z');\n  INSERT INTO x1(docid,a,b,c) VALUES(11, 'T E R Q B', 'C I B C B', 'F Z U W R');\n  INSERT INTO x1(docid,a,b,c) VALUES(12, 'E S V U W', 'T P F W H', 'A M D J Q');\n  INSERT INTO x1(docid,a,b,c) VALUES(13, 'X S B X Y', 'U D N D P', 'X Z Y G F');\n  INSERT INTO x1(docid,a,b,c) VALUES(14, 'K H A B L', 'S R C C Z', 'D W E H J');\n  INSERT INTO x1(docid,a,b,c) VALUES(15, 'C E U C C', 'W F M N M', 'T Z U X T');\n  INSERT INTO x1(docid,a,b,c) VALUES(16, 'Q G C G H', 'H N N B H', 'B Q I H Y');\n  INSERT INTO x1(docid,a,b,c) VALUES(17, 'Q T S K B', 'W B D Y N', 'V J P E C');\n  INSERT INTO x1(docid,a,b,c) VALUES(18, 'A J M O Q', 'L G Y Y A', 'G N M R N');\n  INSERT INTO x1(docid,a,b,c) VALUES(19, 'T R Y P Y', 'N V Y B X', 'L Z T N T');\n\n  CREATE VIRTUAL TABLE x2 USING FTS4(a, b, c, order=DESC);\n  INSERT INTO x2(docid, a, b, c) SELECT docid, a, b, c FROM x1;\n}\n\n\n# Test queries.\n#\nforeach x {1 2} {\n  foreach {tn match res} {\n    1  \"^K\"              {0 1 14}\n    2  \"^S\"              {0 1 14}\n    3  \"^W\"              {9 15 17}\n    4  \"^J\"              {}\n    5  \"^E\"              {12}\n    6  \"V ^-E\"           {0 3 4 6 7 9 17 19}\n    7  \"V -^E\"           {0 3 4 6 7 9 17 19}\n    8  \"^-E V\"           {0 3 4 6 7 9 17 19}\n    9  \"-^E V\"           {0 3 4 6 7 9 17 19}\n    10 \"V\"               {0 3 4 6 7 9 12 17 19}\n\n    11 {\"^K H\"}          {0 14}\n    12 {\"K H\"}           {0 10 14}\n    13 {\"K ^H\"}          {}\n  } {\n    set rev [lreverse $res]\n    do_execsql_test 1.$x.$tn.1 {SELECT docid FROM x1 WHERE x1 MATCH $match} $res\n    do_execsql_test 1.$x.$tn.2 {SELECT docid FROM x2 WHERE x2 MATCH $match} $rev\n  }\n\n  do_execsql_test 1.$x.[expr $tn+1] { \n    INSERT INTO x1(x1) VALUES('optimize');\n    INSERT INTO x2(x2) VALUES('optimize');\n  } {}\n}\n\n# Test the snippet() function.\n#\nforeach {tn match res} {\n  1  {^K}    {{[K] H D S T} {[K] N J L W} {[K] H A B L}}\n  2  {^X}    {{[X] Y D L S} {[X] J P K R} {[X] S B X Y}}\n  3  {^X Y}  {{[X] [Y] D L S} {D [Y] P O I...[X] J P K R} {[X] S B X [Y]}}\n} {\n  set rev [lreverse $res]\n\n  do_execsql_test 1.3.$tn.1 {\n    SELECT snippet(x1, '[', ']', '...') FROM x1 WHERE x1 MATCH $match\n  } $res\n\n  do_execsql_test 1.3.$tn.2 {\n    SELECT snippet(x2, '[', ']', '...') FROM x2 WHERE x2 MATCH $match\n  } $rev\n}\n\n# Test matchinfo().\n#\nforeach {tn match res} {\n  1  {^K}    {\n                {1 3 3 0 0 0 0 0 0}\n                {1 3 3 0 0 0 0 0 0}\n                {1 3 3 0 0 0 0 0 0}\n             }\n  2  {^X}    {\n                {0 1 1 0 1 1 1 2 2}\n                {0 1 1 1 1 1 0 2 2}\n                {1 1 1 0 1 1 1 2 2}\n             }\n  3  {^X Y}  {\n                {0 1 1 0 1 1 1 2 2 0 6 5 0 5 4 1 4 4} \n                {0 1 1 1 1 1 0 2 2 1 6 5 0 5 4 0 4 4} \n                {1 1 1 0 1 1 1 2 2 1 6 5 0 5 4 1 4 4}\n             }\n} {\n  set rev [lreverse $res]\n\n  do_execsql_test 1.3.$tn.1 {\n    SELECT mit(matchinfo(x1, 'x')) FROM x1 WHERE x1 MATCH $match\n  } $res\n  do_execsql_test 1.3.$tn.2 {\n    SELECT mit(matchinfo(x2, 'x')) FROM x2 WHERE x2 MATCH $match\n  } $rev\n}\n\n# Test that ^ is ignored for FTS3 tables.\n#\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE x3 USING fts3;\n  INSERT INTO x3 VALUES('A B C');\n  INSERT INTO x3 VALUES('B A C');\n\n  CREATE VIRTUAL TABLE x4 USING fts4;\n  INSERT INTO x4 VALUES('A B C');\n  INSERT INTO x4 VALUES('B A C');\n}\n\ndo_execsql_test 2.2.1 {\n  SELECT * FROM x3 WHERE x3 MATCH '^A';\n} {{A B C} {B A C}}\ndo_execsql_test 2.2.2 {\n  SELECT * FROM x4 WHERE x4 MATCH '^A';\n} {{A B C}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3join.test",
    "content": "# 2014 January 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix fts3join\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft1 USING fts4(x);\n  INSERT INTO ft1 VALUES('aaa aaa');\n  INSERT INTO ft1 VALUES('aaa bbb');\n  INSERT INTO ft1 VALUES('bbb aaa');\n  INSERT INTO ft1 VALUES('bbb bbb');\n\n  CREATE TABLE t1(id, y);\n  INSERT INTO t1 VALUES(1, 'aaa');\n  INSERT INTO t1 VALUES(2, 'bbb');\n}\n\ndo_execsql_test 1.1 {\n  SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1;\n} {1 2 3}\n\ndo_execsql_test 1.2 {\n  SELECT docid FROM ft1, t1 WHERE ft1 MATCH y AND id=1 ORDER BY docid;\n} {1 2 3}\n\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE ft2 USING fts4(x);\n  CREATE VIRTUAL TABLE ft3 USING fts4(y);\n\n  INSERT INTO ft2 VALUES('abc');\n  INSERT INTO ft2 VALUES('def');\n  INSERT INTO ft3 VALUES('ghi');\n  INSERT INTO ft3 VALUES('abc');\n}\n\ndo_execsql_test 2.1 { SELECT * FROM ft2, ft3 WHERE x MATCH y; } {abc abc}\ndo_execsql_test 2.2 { SELECT * FROM ft2, ft3 WHERE y MATCH x; } {abc abc}\ndo_execsql_test 2.3 { SELECT * FROM ft3, ft2 WHERE x MATCH y; } {abc abc}\ndo_execsql_test 2.4 { SELECT * FROM ft3, ft2 WHERE y MATCH x; } {abc abc}\n\ndo_catchsql_test 2.5 { \n  SELECT * FROM ft3, ft2 WHERE y MATCH x AND x MATCH y; \n} {1 {unable to use function MATCH in the requested context}}\n\ndo_execsql_test 3.0 {\n  CREATE VIRTUAL TABLE vt USING fts3(x);\n  INSERT INTO vt VALUES('abc');\n  INSERT INTO vt VALUES('xyz');\n\n  CREATE TABLE tt(a INTEGER PRIMARY KEY);\n  INSERT INTO tt VALUES(1), (2);\n}\n\ndo_execsql_test 3.1 {\n  SELECT * FROM tt LEFT JOIN (\n    SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc'\n  ) ON tt.a = rrr\n} {1 1 abc 2 {} {}}\n\ndo_execsql_test 3.2 {\n  SELECT * FROM tt LEFT JOIN vt ON (vt MATCH 'abc')\n} {1 abc 2 abc}\n\n#-------------------------------------------------------------------------\n# Test that queries of the form found in test case 4.2 use an automatic\n# index to avoid running multiple fts queries.\n#\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE ft4 USING fts3(x);\n  CREATE TABLE t4(y, z);\n  CREATE INDEX t4y ON t1(y);\n}\n\ndo_eqp_test 4.2 {\n  SELECT * FROM t4 LEFT JOIN (\n      SELECT docid, * FROM ft4 WHERE ft4 MATCH ?\n  ) AS rr ON t4.rowid=rr.docid \n  WHERE t4.y = ?;\n} {\n  1 0 0 {SCAN TABLE ft4 VIRTUAL TABLE INDEX 3:} \n  0 0 0 {SCAN TABLE t4}\n  0 1 1 {SEARCH SUBQUERY 1 AS rr USING AUTOMATIC COVERING INDEX (docid=?)}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3malloc.test",
    "content": "# 2009 October 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests to verify that malloc() errors that occur\n# within the FTS3 module code are handled correctly. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3 { finish_test ; return }\nsource $testdir/malloc_common.tcl\nsource $testdir/fts3_common.tcl\n\n# Ensure the lookaside buffer is disabled for these tests.\n#\nsqlite3 db test.db\nsqlite3_db_config_lookaside db 0 0 0\n\nset sqlite_fts3_enable_parentheses 1\nset DO_MALLOC_TEST 1\n\n# Test organization:\n#\n# fts3_malloc-1.*: Test OOM during CREATE and DROP table statements.\n# fts3_malloc-2.*: Test OOM during SELECT operations.\n# fts3_malloc-3.*: Test OOM during SELECT operations with a larger database.\n# fts3_malloc-4.*: Test OOM during database write operations.\n# fts3_malloc-5.*: Test that a couple of memory leaks that could follow\n#                  OOM in tokenizer code have been fixed.\n#\n\n\nproc normal_list {l} {\n  set ret [list]\n  foreach elem $l {lappend ret $elem}\n  set ret\n}\n\ndo_write_test fts3_malloc-1.1 sqlite_master {\n  CREATE VIRTUAL TABLE ft1 USING fts3(a, b)\n}\ndo_write_test fts3_malloc-1.2 sqlite_master {\n  CREATE VIRTUAL TABLE ft2 USING fts3([a], [b]);\n}\ndo_write_test fts3_malloc-1.3 sqlite_master {\n  CREATE VIRTUAL TABLE ft3 USING fts3('a', \"b\");\n}\ndo_write_test fts3_malloc-1.4 sqlite_master {\n  CREATE VIRTUAL TABLE ft4 USING fts3(`a`, 'fred''s column');\n}\ndo_error_test fts3_malloc-1.5 {\n  CREATE VIRTUAL TABLE ft5 USING fts3(a, b, tokenize unknown)\n} {unknown tokenizer: unknown}\ndo_write_test fts3_malloc-1.6 sqlite_master {\n  CREATE VIRTUAL TABLE ft6 USING fts3(a, b, tokenize porter)\n}\ndo_write_test fts3_malloc-1.7 sqlite_master {\n  CREATE VIRTUAL TABLE ft7 USING fts4(a, b, notindexed=b)\n}\n\n# Test the xConnect/xDisconnect methods:\n#db eval { ATTACH 'test2.db' AS aux }\n#do_write_test fts3_malloc-1.6 aux.sqlite_master {\n#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);\n#}\n#do_write_test fts3_malloc-1.6 aux.sqlite_master {\n#  CREATE VIRTUAL TABLE aux.ft7 USING fts3(a, b, c);\n#}\n\n\n\ndo_test fts3_malloc-2.0 {\n  execsql { \n    DROP TABLE ft1;\n    DROP TABLE ft2;\n    DROP TABLE ft3;\n    DROP TABLE ft4;\n    DROP TABLE ft6;\n    DROP TABLE ft7;\n  }\n  execsql { CREATE VIRTUAL TABLE ft USING fts3(a, b) }\n  for {set ii 1} {$ii < 32} {incr ii} {\n    set a [list]\n    set b [list]\n    if {$ii & 0x01} {lappend a one   ; lappend b neung}\n    if {$ii & 0x02} {lappend a two   ; lappend b song }\n    if {$ii & 0x04} {lappend a three ; lappend b sahm }\n    if {$ii & 0x08} {lappend a four  ; lappend b see  }\n    if {$ii & 0x10} {lappend a five  ; lappend b hah  }\n    execsql { INSERT INTO ft VALUES($a, $b) }\n  }\n} {}\n\nforeach {tn sql result} {\n  1 \"SELECT count(*) FROM sqlite_master\" {5}\n  2 \"SELECT * FROM ft WHERE docid = 1\"   {one neung}\n  3 \"SELECT * FROM ft WHERE docid = 2\"   {two song}\n  4 \"SELECT * FROM ft WHERE docid = 3\"   {{one two} {neung song}}\n\n  5 \"SELECT a FROM ft\" {\n    {one}                     {two}                 {one two}\n    {three}                   {one three}           {two three}     \n    {one two three}           {four}                {one four} \n    {two four}                {one two four}        {three four}   \n    {one three four}          {two three four}      {one two three four}  \n    {five}                    {one five}            {two five}            \n    {one two five}            {three five}          {one three five} \n    {two three five}          {one two three five}  {four five}\n    {one four five}           {two four five}       {one two four five}\n    {three four five}         {one three four five} {two three four five}\n    {one two three four five}\n  }\n\n  6 \"SELECT a FROM ft WHERE a MATCH 'one'\" {\n    {one} {one two} {one three} {one two three}\n    {one four} {one two four} {one three four} {one two three four}\n    {one five} {one two five} {one three five} {one two three five}\n    {one four five} {one two four five} \n    {one three four five} {one two three four five}\n  }\n\n  7 \"SELECT a FROM ft WHERE a MATCH 'o*'\" {\n    {one} {one two} {one three} {one two three}\n    {one four} {one two four} {one three four} {one two three four}\n    {one five} {one two five} {one three five} {one two three five}\n    {one four five} {one two four five} \n    {one three four five} {one two three four five}\n  }\n\n  8 \"SELECT a FROM ft WHERE a MATCH 'o* t*'\" {\n    {one two}             {one three}           {one two three} \n    {one two four}        {one three four}      {one two three four} \n    {one two five}        {one three five}      {one two three five} \n    {one two four five}   {one three four five} {one two three four five}\n  }\n\n  9 \"SELECT a FROM ft WHERE a MATCH '\\\"o* t*\\\"'\" {\n    {one two}             {one three}           {one two three} \n    {one two four}        {one three four}      {one two three four} \n    {one two five}        {one three five}      {one two three five} \n    {one two four five}   {one three four five} {one two three four five}\n  }\n\n  10 {SELECT a FROM ft WHERE a MATCH '\"o* f*\"'} {\n    {one four}            {one five}            {one four five}\n  }\n\n  11 {SELECT a FROM ft WHERE a MATCH '\"one two three\"'} {\n    {one two three}\n    {one two three four}  \n    {one two three five}\n    {one two three four five}\n  }\n\n  12 {SELECT a FROM ft WHERE a MATCH '\"two three four\"'} {\n    {two three four}\n    {one two three four}\n    {two three four five}\n    {one two three four five}\n  }\n\n  12 {SELECT a FROM ft WHERE a MATCH '\"two three\" five'} {\n    {two three five}         {one two three five}\n    {two three four five}    {one two three four five}\n  }\n\n  13 {SELECT a FROM ft WHERE ft MATCH '\"song sahm\" hah'} {\n    {two three five}         {one two three five}\n    {two three four five}    {one two three four five}\n  }\n\n  14 {SELECT a FROM ft WHERE b MATCH 'neung'} {\n    {one}                    {one two} \n    {one three}              {one two three}\n    {one four}               {one two four} \n    {one three four}         {one two three four}\n    {one five}               {one two five} \n    {one three five}         {one two three five}\n    {one four five}          {one two four five} \n    {one three four five}    {one two three four five}\n  }\n\n  15 {SELECT a FROM ft WHERE b MATCH '\"neung song sahm\"'} {\n    {one two three}          {one two three four}  \n    {one two three five}     {one two three four five}\n  }\n\n  16 {SELECT a FROM ft WHERE b MATCH 'hah \"song sahm\"'} {\n    {two three five}         {one two three five}\n    {two three four five}    {one two three four five}\n  }\n\n  17 {SELECT a FROM ft WHERE b MATCH 'song OR sahm'} {\n    {two}                     {one two}             {three}\n    {one three}               {two three}           {one two three}\n    {two four}                {one two four}        {three four}   \n    {one three four}          {two three four}      {one two three four}  \n    {two five}                {one two five}        {three five}\n    {one three five}          {two three five}      {one two three five}\n    {two four five}           {one two four five}   {three four five}\n    {one three four five}     {two three four five} {one two three four five}\n  }\n\n  18 {SELECT a FROM ft WHERE a MATCH 'three NOT two'} {\n    {three}                   {one three}           {three four}   \n    {one three four}          {three five}          {one three five}\n    {three four five}         {one three four five}\n  }\n\n  19 {SELECT a FROM ft WHERE b MATCH 'sahm NOT song'} {\n    {three}                   {one three}           {three four}   \n    {one three four}          {three five}          {one three five}\n    {three four five}         {one three four five}\n  }\n\n  20 {SELECT a FROM ft WHERE ft MATCH 'sahm NOT song'} {\n    {three}                   {one three}           {three four}   \n    {one three four}          {three five}          {one three five}\n    {three four five}         {one three four five}\n  }\n\n  21 {SELECT a FROM ft WHERE b MATCH 'neung NEAR song NEAR sahm'} {\n    {one two three}           {one two three four}  \n    {one two three five}      {one two three four five}\n  }\n\n} {\n  set result [normal_list $result]\n  do_select_test fts3_malloc-2.$tn $sql $result\n}\n\ndo_test fts3_malloc-3.0 {\n  execsql BEGIN\n  for {set ii 32} {$ii < 1024} {incr ii} {\n    set a [list]\n    set b [list]\n    if {$ii & 0x0001} {lappend a one   ; lappend b neung }\n    if {$ii & 0x0002} {lappend a two   ; lappend b song  }\n    if {$ii & 0x0004} {lappend a three ; lappend b sahm  }\n    if {$ii & 0x0008} {lappend a four  ; lappend b see   }\n    if {$ii & 0x0010} {lappend a five  ; lappend b hah   }\n    if {$ii & 0x0020} {lappend a six   ; lappend b hok   }\n    if {$ii & 0x0040} {lappend a seven ; lappend b jet   }\n    if {$ii & 0x0080} {lappend a eight ; lappend b bairt }\n    if {$ii & 0x0100} {lappend a nine  ; lappend b gow   }\n    if {$ii & 0x0200} {lappend a ten   ; lappend b sip   }\n    execsql { INSERT INTO ft VALUES($a, $b) }\n  }\n  execsql COMMIT\n} {}\nforeach {tn sql result} {\n  1 \"SELECT count(*) FROM ft\" {1023}\n\n  2 \"SELECT a FROM ft WHERE a MATCH 'one two three four five six seven eight'\" {\n     {one two three four five six seven eight}\n     {one two three four five six seven eight nine}\n     {one two three four five six seven eight ten}\n     {one two three four five six seven eight nine ten}\n  }\n\n  3 {SELECT count(*), sum(docid) FROM ft WHERE a MATCH 'o*'} {\n    512 262144\n  }\n\n  4 {SELECT count(*), sum(docid) FROM ft WHERE a MATCH '\"two three four\"'} {\n    128 66368\n  }\n} {\n  set result [normal_list $result]\n  do_select_test fts3_malloc-3.$tn $sql $result\n}\n\ndo_test fts3_malloc-4.0 {\n  execsql { DELETE FROM ft WHERE docid>=32 }\n} {}\nforeach {tn sql} {\n  1 \"DELETE FROM ft WHERE ft MATCH 'one'\"\n  2 \"DELETE FROM ft WHERE ft MATCH 'three'\"\n  3 \"DELETE FROM ft WHERE ft MATCH 'five'\"\n} {\n  do_write_test fts3_malloc-4.1.$tn ft_content $sql\n}\ndo_test fts3_malloc-4.2 {\n  execsql { SELECT a FROM ft }\n} {two four {two four}}\n\ndo_write_test fts3_malloc-5.1 ft_content {\n  INSERT INTO ft VALUES('short alongertoken reallyquitealotlongerimeanit andthistokenisjustsolongthatonemightbeforgivenforimaginingthatitwasmerelyacontrivedexampleandnotarealtoken', 'cynics!')\n}\ndo_test fts3_malloc-5.2 {\n  execsql { CREATE VIRTUAL TABLE ft8 USING fts3(x, tokenize porter) }\n} {}\n\ndo_write_test fts3_malloc-5.3 ft_content {\n  INSERT INTO ft8 VALUES('short alongertoken reallyquitealotlongerimeanit andthistokenisjustsolongthatonemightbeforgivenforimaginingthatitwasmerelyacontrivedexampleandnotarealtoken')\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3matchinfo.test",
    "content": "# 2010 November 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for the FTS3 module. The focus\n# of this file is tables created with the \"matchinfo=fts3\" option.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\nset testprefix fts3matchinfo\nset sqlite_fts3_enable_parentheses 0\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts4(matchinfo=fts3);\n  SELECT name FROM sqlite_master WHERE type = 'table';\n} {t1 t1_content t1_segments t1_segdir t1_stat}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1(content) VALUES('I wandered lonely as a cloud');\n  INSERT INTO t1(content) VALUES('That floats on high o''er vales and hills,');\n  INSERT INTO t1(content) VALUES('When all at once I saw a crowd,');\n  INSERT INTO t1(content) VALUES('A host, of golden daffodils,');\n  SELECT mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'I';\n} {{1 1 1 2 2} {1 1 1 2 2}}\n\n# Now create an FTS4 table that does not specify matchinfo=fts3.\n#\ndo_execsql_test 1.2 {\n  CREATE VIRTUAL TABLE t2 USING fts4;\n  INSERT INTO t2 SELECT * FROM t1;\n  SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I';\n} {{1 1 1 2 2} {1 1 1 2 2}}\n\n# Test some syntax-error handling.\n#\ndo_catchsql_test 2.0 {\n  CREATE VIRTUAL TABLE x1 USING fts4(matchinfo=fs3);\n} {1 {unrecognized matchinfo: fs3}}\ndo_catchsql_test 2.1 {\n  CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3);\n} {1 {unrecognized parameter: mtchinfo=fts3}}\ndo_catchsql_test 2.2 {\n  CREATE VIRTUAL TABLE x2 USING fts4(matchinfo=fts5);\n} {1 {unrecognized matchinfo: fts5}}\n\n# Check that with fts3, the \"=\" character is permitted in column definitions.\n#\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t3 USING fts3(mtchinfo=fts3);\n  INSERT INTO t3(mtchinfo) VALUES('Beside the lake, beneath the trees');\n  SELECT mtchinfo FROM t3;\n} {{Beside the lake, beneath the trees}}\n\ndo_execsql_test 3.2 {\n  CREATE VIRTUAL TABLE xx USING FTS4;\n}\ndo_execsql_test 3.3 {\n  SELECT * FROM xx WHERE xx MATCH 'abc';\n}\ndo_execsql_test 3.4 {\n  SELECT * FROM xx WHERE xx MATCH 'a b c';\n}\n\n\n#--------------------------------------------------------------------------\n# Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.\n#\n# The first argument - $tn - is a test identifier. This may be either a\n# full identifier (i.e. \"fts3matchinfo-1.1\") or, if global var $testprefix\n# is set, just the numeric component (i.e. \"1.1\").\n#\n# The second argument is the name of an FTSX table. The third is the \n# full text of a WHERE/MATCH expression to query the table for \n# (i.e. \"t1 MATCH 'abc'\"). The final argument - $results - should be a\n# key-value list (serialized array) with matchinfo() format specifiers\n# as keys, and the results of executing the statement:\n#\n#   SELECT matchinfo($tbl, '$key') FROM $tbl WHERE $expr\n#\n# For example:\n#\n#   CREATE VIRTUAL TABLE t1 USING fts4;\n#   INSERT INTO t1 VALUES('abc');\n#   INSERT INTO t1 VALUES('def');\n#   INSERT INTO t1 VALUES('abc abc');\n#\n#   do_matchinfo_test 1.1 t1 \"t1 MATCH 'abc'\" {\n#     n {3 3}\n#     p {1 1}\n#     c {1 1}\n#     x {{1 3 2} {2 3 2}}\n#   }\n#\n# If the $results list contains keys mapped to \"-\" instead of a matchinfo()\n# result, then this command computes the expected results based on other\n# mappings to test the matchinfo() function. For example, the command above\n# could be changed to:\n#\n#   do_matchinfo_test 1.1 t1 \"t1 MATCH 'abc'\" {\n#     n {3 3} p {1 1} c {1 1} x {{1 3 2} {2 3 2}}\n#     pcx -\n#   }\n#\n# And this command would compute the expected results for matchinfo(t1, 'pcx')\n# based on the results of matchinfo(t1, 'p'), matchinfo(t1, 'c') and \n# matchinfo(t1, 'x') in order to test 'pcx'.\n#\nproc do_matchinfo_test {tn tbl expr results} {\n\n  foreach {fmt res} $results {\n    if {$res == \"-\"} continue\n    set resarray($fmt) $res\n  }\n\n  set nRow 0\n  foreach {fmt res} [array get resarray] {\n    if {[llength $res]>$nRow} { set nRow [llength $res] }\n  }\n\n  # Construct expected results for any formats for which the caller \n  # supplied result is \"-\".\n  #\n  foreach {fmt res} $results {\n    if {$res == \"-\"} {\n      set res [list]\n      for {set iRow 0} {$iRow<$nRow} {incr iRow} {\n        set rowres [list]\n        foreach c [split $fmt \"\"] {\n          set rowres [concat $rowres [lindex $resarray($c) $iRow]]\n        }\n        lappend res $rowres\n      }\n      set resarray($fmt) $res\n    }\n  }\n\n  # Test each matchinfo() request individually.\n  #\n  foreach {fmt res} [array get resarray] {\n    set sql \"SELECT mit(matchinfo($tbl, '$fmt')) FROM $tbl WHERE $expr\"\n    do_execsql_test $tn.$fmt $sql [normalize2 $res]\n  }\n\n  # Test them all executed together (multiple invocations of matchinfo()).\n  #\n  set exprlist [list]\n  foreach {format res} [array get resarray] {\n    lappend exprlist \"mit(matchinfo($tbl, '$format'))\"\n  }\n  set allres [list]\n  for {set iRow 0} {$iRow<$nRow} {incr iRow} {\n    foreach {format res} [array get resarray] {\n      lappend allres [lindex $res $iRow]\n    }\n  }\n  set sql \"SELECT [join $exprlist ,] FROM $tbl WHERE $expr\"\n  do_execsql_test $tn.multi $sql [normalize2 $allres]\n}\nproc normalize2 {list_of_lists} {\n  set res [list]\n  foreach elem $list_of_lists {\n    lappend res [list {*}$elem]\n  }\n  return $res\n}\n\n\ndo_execsql_test 4.1.0 {\n  CREATE VIRTUAL TABLE t4 USING fts4(x, y);\n  INSERT INTO t4 VALUES('a b c d e', 'f g h i j');\n  INSERT INTO t4 VALUES('f g h i j', 'a b c d e');\n}\n\ndo_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {\n  p {3 3}\n  c {2 2}\n  x {\n    {1 1 1   0 1 1   1 1 1   0 1 1   1 1 1   0 1 1}\n    {0 1 1   1 1 1   0 1 1   1 1 1   0 1 1   1 1 1}\n  }\n  n {2 2}\n  l {{5 5} {5 5}}\n  a {{5 5} {5 5}}\n\n  s {{3 0} {0 3}}\n\n  xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -\n  xpxsscplax -\n}\n\ndo_matchinfo_test 4.1.2 t4 {t4 MATCH '\"g h i\"'} {\n  p {1 1}\n  c {2 2}\n  x {\n    {0 1 1   1 1 1}\n    {1 1 1   0 1 1}\n  }\n  n {2 2}\n  l {{5 5} {5 5}}\n  a {{5 5} {5 5}}\n\n  s {{0 1} {1 0}}\n\n  xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -\n  sxsxs -\n}\n\ndo_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'}     { s {{2 0} {0 2}} }\ndo_matchinfo_test 4.1.4 t4 {t4 MATCH '\"a b\" c'} { s {{2 0} {0 2}} }\ndo_matchinfo_test 4.1.5 t4 {t4 MATCH 'a \"b c\"'} { s {{2 0} {0 2}} }\ndo_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'}     { s {{1 0} {0 1}} }\ndo_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} {\n  x { \n    {0 1 1  1 1 1  0 0 0  0 0 0} \n    {1 1 1  0 1 1  0 0 0  0 0 0}\n  }\n}\ndo_matchinfo_test 4.1.8 t4 {t4 MATCH 'f -abcd'} {\n  x { \n    {0 1 1  1 1 1}\n    {1 1 1  0 1 1}\n  }\n}\n\ndo_execsql_test 4.2.0 {\n  CREATE VIRTUAL TABLE t5 USING fts4;\n  INSERT INTO t5 VALUES('a a a a a');\n  INSERT INTO t5 VALUES('a b a b a');\n  INSERT INTO t5 VALUES('c b c b c');\n  INSERT INTO t5 VALUES('x x x x x');\n}\ndo_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'}         { \n  x {{5 8 2   5 8 2} {3 8 2   3 8 2}}\n  s {2 1} \n}\ndo_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_test 4.2.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\ndo_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1} }\n\ndo_execsql_test 4.3.0 \"INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')\";\n\n# It used to be that the second 'a' token would be deferred. That doesn't\n# work any longer.\nif 0 {\n  do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { \n    x {{5 8 2   5 5 5} {3 8 2   3 5 5}}\n    s {2 1} \n  }\n}\n\ndo_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_test 4.3.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\ndo_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'}      { s {1 2 1 1} }\n\ndo_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') }\n\nifcapable fts4_deferred {\n  do_execsql_test 4.4.0.2 {\n    UPDATE t5_segments \n    SET block = zeroblob(length(block)) \n    WHERE length(block)>10000;\n  }\n}\n\ndo_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'}         { s {2 1} }\ndo_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'}         { s {2} }\ndo_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'}       { s {3} }\ndo_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'}       { s {3 1} }\ndo_matchinfo_test 4.4.5 t5 {t5 MATCH '\"a b\" \"a b\"'} { s {2} }\n\ndo_execsql_test 4.5.0 {\n  CREATE VIRTUAL TABLE t6 USING fts4(a, b, c);\n  INSERT INTO t6 VALUES('a', 'b', 'c');\n}\ndo_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'}       { s {{1 1 1}} }\n\n\n#-------------------------------------------------------------------------\n# Check the following restrictions:\n#\n#   + Matchinfo flags 'a', 'l' and 'n' can only be used with fts4, not fts3.\n#   + Matchinfo flag 'l' cannot be used with matchinfo=fts3.\n#\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE t7 USING fts3(a, b);\n  INSERT INTO t7 VALUES('u v w', 'x y z');\n\n  CREATE VIRTUAL TABLE t8 USING fts4(a, b, matchinfo=fts3);\n  INSERT INTO t8 VALUES('u v w', 'x y z');\n}\n\ndo_catchsql_test 5.2.1 { \n  SELECT matchinfo(t7, 'a') FROM t7 WHERE t7 MATCH 'x y'\n} {1 {unrecognized matchinfo request: a}}\ndo_catchsql_test 5.2.2 { \n  SELECT matchinfo(t7, 'l') FROM t7 WHERE t7 MATCH 'x y'\n} {1 {unrecognized matchinfo request: l}}\ndo_catchsql_test 5.2.3 { \n  SELECT matchinfo(t7, 'n') FROM t7 WHERE t7 MATCH 'x y'\n} {1 {unrecognized matchinfo request: n}}\n\ndo_catchsql_test 5.3.1 { \n  SELECT matchinfo(t8, 'l') FROM t8 WHERE t8 MATCH 'x y'\n} {1 {unrecognized matchinfo request: l}}\n\n#-------------------------------------------------------------------------\n# Test that the offsets() function handles corruption in the %_content\n# table correctly.\n#\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE t9 USING fts4;\n  INSERT INTO t9 VALUES(\n    'this record is used to try to dectect corruption'\n  );\n  SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to';\n} {{0 0 20 2 0 0 27 2}}\n\ndo_catchsql_test 6.2 {\n  UPDATE t9_content SET c0content = 'this record is used to'; \n  SELECT offsets(t9) FROM t9 WHERE t9 MATCH 'to';\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n# Test the outcome of matchinfo() when used within a query that does not\n# use the full-text index (i.e. lookup by rowid or full-table scan).\n#\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE t10 USING fts4;\n  INSERT INTO t10 VALUES('first record');\n  INSERT INTO t10 VALUES('second record');\n}\ndo_execsql_test 7.2 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10;\n} {blob 0 blob 0}\ndo_execsql_test 7.3 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) FROM t10 WHERE docid=1;\n} {blob 0}\ndo_execsql_test 7.4 {\n  SELECT typeof(matchinfo(t10)), length(matchinfo(t10)) \n  FROM t10 WHERE t10 MATCH 'record'\n} {blob 20 blob 20}\n\n#-------------------------------------------------------------------------\n# Test a special case - matchinfo('nxa') with many zero length documents. \n# Special because \"x\" internally uses a statement used by both \"n\" and \"a\". \n# This was causing a problem at one point in the obscure case where the\n# total number of bytes of data stored in an fts3 table was greater than\n# the number of rows. i.e. when the following query returns true:\n#\n#   SELECT sum(length(content)) < count(*) FROM fts4table;\n#\ndo_execsql_test 8.1 {\n  CREATE VIRTUAL TABLE t11 USING fts4;\n  INSERT INTO t11(t11) VALUES('nodesize=24');\n  INSERT INTO t11 VALUES('quitealongstringoftext');\n  INSERT INTO t11 VALUES('anotherquitealongstringoftext');\n  INSERT INTO t11 VALUES('athirdlongstringoftext');\n  INSERT INTO t11 VALUES('andonemoreforgoodluck');\n}\ndo_test 8.2 {\n  for {set i 0} {$i < 200} {incr i} {\n    execsql { INSERT INTO t11 VALUES('') }\n  }\n  execsql { INSERT INTO t11(t11) VALUES('optimize') }\n} {}\ndo_execsql_test 8.3 {\n  SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'\n} {{204 1 3 3 0} {204 1 3 3 0} {204 1 3 3 0}}\n\n# Corruption related tests.\ndo_execsql_test  8.4.1.1 { UPDATE t11_stat SET value = X'0000'; }\ndo_catchsql_test 8.5.1.2 {\n  SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'\n} {1 {database disk image is malformed}}\n\ndo_execsql_test  8.4.2.1 { UPDATE t11_stat SET value = X'00'; }\ndo_catchsql_test 8.5.2.2 {\n  SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'\n} {1 {database disk image is malformed}}\n\ndo_execsql_test  8.4.3.1 { UPDATE t11_stat SET value = NULL; }\ndo_catchsql_test 8.5.3.2 {\n  SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'\n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 8.1 {\n  CREATE VIRTUAL TABLE t12 USING fts4;\n  INSERT INTO t12 VALUES('a b c d');\n  SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';\n} {{0 0 0 0 0 0 1 1 1}}\ndo_execsql_test 8.2 {\n  INSERT INTO t12 VALUES('a d c d');\n  SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';\n} {\n  {0 1 1 0 1 1 1 2 2} {1 1 1 1 1 1 1 2 2}\n}\ndo_execsql_test 8.3 {\n  INSERT INTO t12 VALUES('a d d a');\n  SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';\n} {\n  {0 3 2 0 3 2 1 4 3} {1 3 2 1 3 2 1 4 3} {2 3 2 2 3 2 2 4 3}\n}\n\ndo_execsql_test 9.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts4;\n  INSERT INTO ft2 VALUES('a b c d e');\n  INSERT INTO ft2 VALUES('f a b c d');\n  SELECT snippet(ft2, '[', ']', '', -1, 1) FROM ft2 WHERE ft2 MATCH 'c';\n} {{[c]} {[c]}}\n\n#---------------------------------------------------------------------------\n# Test for a memory leak\n#\ndo_execsql_test 10.1 {\n  DROP TABLE t10;\n  CREATE VIRTUAL TABLE t10 USING fts4(idx, value);\n  INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');\n  SELECT docId, t10.*\n    FROM t10\n    JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x\n   WHERE t10 MATCH x.idx\n     AND matchinfo(t10) not null\n   GROUP BY docId\n   ORDER BY 1;\n} {1 1 one 2 2 two 3 3 three}\n  \n#---------------------------------------------------------------------------\n# Test the 'y' matchinfo flag\n#\nset sqlite_fts3_enable_parentheses 1\nreset_db\ndo_execsql_test 11.0 {\n  CREATE VIRTUAL TABLE tt USING fts3(x, y);\n  INSERT INTO tt VALUES('c d a c d d', 'e a g b d a');   -- 1\n  INSERT INTO tt VALUES('c c g a e b', 'c g d g e c');   -- 2\n  INSERT INTO tt VALUES('b e f d e g', 'b a c b c g');   -- 3\n  INSERT INTO tt VALUES('a c f f g d', 'd b f d e g');   -- 4\n  INSERT INTO tt VALUES('g a c f c f', 'd g g b c c');   -- 5\n  INSERT INTO tt VALUES('g a c e b b', 'd b f b g g');   -- 6\n  INSERT INTO tt VALUES('f d a a f c', 'e e a d c f');   -- 7\n  INSERT INTO tt VALUES('a c b b g f', 'a b a e d f');   -- 8\n  INSERT INTO tt VALUES('b a f e c c', 'f d b b a b');   -- 9\n  INSERT INTO tt VALUES('f d c e a c', 'f a f a a f');   -- 10\n}\n\ndb func mit mit\nforeach {tn expr res} {\n  1 \"a\" {\n      1 {1 2}   2 {1 0}   3 {0 1}   4 {1 0}   5 {1 0}\n      6 {1 0}   7 {2 1}   8 {1 2}   9 {1 1}  10 {1 3}\n  }\n\n  2 \"b\" {\n      1 {0 1}   2 {1 0}   3 {1 2}   4 {0 1}   5 {0 1}\n      6 {2 2}             8 {2 1}   9 {1 3}            \n  }\n\n  3 \"y:a\" {\n      1 {0 2}             3 {0 1}                    \n                7 {0 1}   8 {0 2}   9 {0 1}  10 {0 3}\n  }\n\n  4 \"x:a\" {\n      1 {1 0}   2 {1 0}             4 {1 0}   5 {1 0}\n      6 {1 0}   7 {2 0}   8 {1 0}   9 {1 0}  10 {1 0}\n  }\n\n  5 \"a OR b\" {\n      1 {1 2 0 1}   2 {1 0 1 0}   3 {0 1 1 2}   4 {1 0 0 1}   5 {1 0 0 1}\n      6 {1 0 2 2}   7 {2 1 0 0}   8 {1 2 2 1}   9 {1 1 1 3}  10 {1 3 0 0}\n  }\n\n  6 \"a AND b\" {\n      1 {1 2 0 1}   2 {1 0 1 0}   3 {0 1 1 2}   4 {1 0 0 1}   5 {1 0 0 1}\n      6 {1 0 2 2}                 8 {1 2 2 1}   9 {1 1 1 3}              \n  }\n\n  7 \"a OR (a AND b)\" {\n      1 {1 2 1 2 0 1}   2 {1 0 1 0 1 0}   3 {0 1 0 1 1 2}   4 {1 0 1 0 0 1}   \n      5 {1 0 1 0 0 1}   6 {1 0 1 0 2 2}   7 {2 1 0 0 0 0}   8 {1 2 1 2 2 1}   \n      9 {1 1 1 1 1 3}  10 {1 3 0 0 0 0}\n  }\n\n} {\n  do_execsql_test 11.1.$tn.1  {\n    SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr\n  } $res\n\n  set r2 [list]\n  foreach {rowid L} $res {\n    lappend r2 $rowid\n    set M [list]\n    foreach {a b} $L {\n      lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]\n    }\n    lappend r2 $M\n  }\n\n  do_execsql_test 11.1.$tn.2  {\n    SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr\n  } $r2\n\n  do_execsql_test 11.1.$tn.2  {\n    SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr\n  } $r2\n}\nset sqlite_fts3_enable_parentheses 0\n\n#---------------------------------------------------------------------------\n# Test the 'b' matchinfo flag\n#\nset sqlite_fts3_enable_parentheses 1\nreset_db\ndb func mit mit\n\ndo_test 12.0 {\n  set cols [list]\n  for {set i 0} {$i < 50} {incr i} { lappend cols \"c$i\" }\n  execsql \"CREATE VIRTUAL TABLE tt USING fts3([join $cols ,])\"\n} {}\n\ndo_execsql_test 12.1 {\n  INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');\n  SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';\n} [list [list [expr 1<<4] [expr 1<<(45-32)]]]\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3misc.test",
    "content": "# 2017 March 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3misc\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# A self-join.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3(a, b);\n  INSERT INTO t1 VALUES('one', 'i');\n  INSERT INTO t1 VALUES('one', 'ii');\n  INSERT INTO t1 VALUES('two', 'i');\n  INSERT INTO t1 VALUES('two', 'ii');\n}\n\ndo_execsql_test 1.1 {\n  SELECT a.a, b.b FROM t1 a, t1 b WHERE a.t1 MATCH 'two' AND b.t1 MATCH 'i'\n} {two i two i two i two i}\n\n#-------------------------------------------------------------------------\n# FTS tables with 128 or more columns.\n#\nproc v1 {v} {\n  set vector [list a b c d e f g h]\n  set res [list]\n  for {set i 0} {$i<8} {incr i} {\n    if {$v & (1 << $i)} { lappend res [lindex $vector $i] }\n  }\n  set res\n}\nproc v2 {v} {\n  set vector [list d e f g h i j k]\n  set res [list]\n  for {set i 0} {$i<8} {incr i} {\n    if {$v & (1 << $i)} { lappend res [lindex $vector $i] }\n  }\n  set res\n}\ndb func v1 v1\ndb func v2 v2\n\ndo_test 2.0 {\n  set cols [list]\n  for {set i 0} {$i<200} {incr i} {\n    lappend cols \"c$i\"\n  }\n  execsql \"CREATE VIRTUAL TABLE t2 USING fts3([join $cols ,])\"\n  execsql {\n    WITH data(i) AS (\n      SELECT 1 UNION ALL SELECT i+1 FROM data WHERE i<200\n    )\n    INSERT INTO t2(c198, c199) SELECT v1(i), v2(i) FROM data;\n  }\n} {}\ndo_execsql_test 2.1 {\n  SELECT rowid FROM t2 WHERE t2 MATCH '\"a b c\"'\n} {\n  7 15 23 31 39 47 55 63 71 79 87 95 103 111 \n  119 127 135 143 151 159 167 175 183 191 199\n}\ndo_execsql_test 2.2 {\n  SELECT rowid FROM t2 WHERE t2 MATCH '\"g h i\"'\n} {\n  56 57 58 59 60 61 62 63 120 121 122 123 124 \n  125 126 127 184 185 186 187 188 189 190 191\n}\ndo_execsql_test 2.3 {\n  SELECT rowid FROM t2 WHERE t2 MATCH '\"i h\"'\n} {\n}\ndo_execsql_test 2.4 {\n  SELECT rowid FROM t2 WHERE t2 MATCH '\"f e\"'\n} {\n}\ndo_execsql_test 2.5 {\n  SELECT rowid FROM t2 WHERE t2 MATCH '\"e f\"'\n} {\n  6 7 14 15 22 23 30 31 38 39 46 47 48 49 50 51 52 53 54 55 56 \n  57 58 59 60 61 62 63 70 71 78 79 86 87 94 95 102 103 110 \n  111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127\n  134 135 142 143 150 151 158 159 166 167 174 175 176 177 178 179 180 \n  181 182 183 184 185 186 187 188 189 190 191 198 199\n}\n\n#-------------------------------------------------------------------------\n# Range constraints on the docid using non-integer values.\n#\ndo_execsql_test 2.6 {\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN NULL AND 45;\n} {}\ndo_execsql_test 2.7 {\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN 11.5 AND 48.2;\n} {\n  14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 \n  29 30 31 34 35 38 39 42 43 46 47 48\n}\ndo_execsql_test 2.8 {\n  SELECT rowid FROM t2 WHERE t2 MATCH 'e' AND rowid BETWEEN '11.5' AND '48.2';\n} {\n  14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 \n  29 30 31 34 35 38 39 42 43 46 47 48\n}\n\n#-------------------------------------------------------------------------\n# Phrase query tests. \n#\ndo_execsql_test 3.1.1 {\n  CREATE VIRTUAL TABLE t3 USING fts3;\n  INSERT INTO t3 VALUES('a b c');\n  INSERT INTO t3 VALUES('d e f');\n  INSERT INTO t3 VALUES('a b d');\n  INSERT INTO t3 VALUES('1 2 3 4 5 6 7 8 9 10 11');\n}\ndo_execsql_test 3.1.2 {\n  SELECT * FROM t3 WHERE t3 MATCH '\"a b x y\"' ORDER BY docid DESC\n}\ndo_execsql_test 3.1.3 {\n  SELECT * FROM t3 WHERE t3 MATCH '\"a b c\" OR \"a b x y\"' ORDER BY docid DESC\n} {{a b c}}\ndo_execsql_test 3.1.4 {\n  SELECT * FROM t3 WHERE t3 MATCH '\"a* b* x* a*\"'\n}\ndo_execsql_test 3.1.5 {\n  SELECT rowid FROM t3 WHERE t3 MATCH '\"2 3 4 5 6 7 8 9\"'\n} {4}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nifcapable fts4_deferred {\n  do_execsql_test 4.0 {\n    PRAGMA page_size = 512;\n    CREATE VIRTUAL TABLE t4 USING fts4;\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<8000 )\n    INSERT INTO t4 SELECT 'a b c a b c a b c' FROM s;\n  }\n  do_execsql_test 4.1 {\n    SELECT count(*) FROM t4 WHERE t4 MATCH '\"a b c\" OR \"c a b\"'\n  } {8000}\n  do_execsql_test 4.2 {\n    SELECT quote(value) from t4_stat where id=0\n  } {X'C03EC0B204C0A608'}\n  do_execsql_test 4.3 {\n    UPDATE t4_stat SET value = X'C03EC0B204C0A60800' WHERE id=0;\n  }\n  do_catchsql_test 4.4 {\n    SELECT count(*) FROM t4 WHERE t4 MATCH '\"a b c\" OR \"c a b\"'\n  } {1 {database disk image is malformed}}\n  do_execsql_test 4.5 {\n    UPDATE t4_stat SET value = X'00C03EC0B204C0A608' WHERE id=0;\n  }\n  do_catchsql_test 4.6 {\n    SELECT count(*) FROM t4 WHERE t4 MATCH '\"a b c\" OR \"c a b\"'\n  } {1 {database disk image is malformed}}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 5.0 {\n  CREATE VIRTUAL TABLE t5 USING fts4;\n  INSERT INTO t5 VALUES('a x x x x b x x x x c');\n  INSERT INTO t5 VALUES('a x x x x b x x x x c');\n  INSERT INTO t5 VALUES('a x x x x b x x x x c');\n}\ndo_execsql_test 5.1 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/4 b NEAR/4 c'\n} {1 2 3}\ndo_execsql_test 5.2 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/3 b NEAR/4 c'\n} {}\ndo_execsql_test 5.3 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'a NEAR/4 b NEAR/3 c'\n} {}\ndo_execsql_test 5.4 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'y NEAR/4 b NEAR/4 c'\n} {}\ndo_execsql_test 5.5 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'x OR a NEAR/3 b NEAR/3 c'\n} {1 2 3}\ndo_execsql_test 5.5 {\n  SELECT rowid FROM t5 WHERE t5 MATCH 'x OR y NEAR/3 b NEAR/3 c'\n} {1 2 3}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 6.0 {\n  CREATE VIRTUAL TABLE t6 USING fts4;\n\n  BEGIN;\n  WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000)\n    INSERT INTO t6 SELECT 'x x x x x x x x x x x' FROM s;\n\n  INSERT INTO t6 VALUES('x x x x x x x x x x x A');\n  INSERT INTO t6 VALUES('x x x x x x x x x x x B');\n  INSERT INTO t6 VALUES('x x x x x x x x x x x A');\n  INSERT INTO t6 VALUES('x x x x x x x x x x x B');\n\n  WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50000)\n    INSERT INTO t6 SELECT 'x x x x x x x x x x x' FROM s;\n  COMMIT;\n}\ndo_execsql_test 6.1 {\n  SELECT rowid FROM t6 WHERE t6 MATCH 'b OR \"x a\"'\n} {50001 50002 50003 50004}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3near.test",
    "content": "\n# 2007 October 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# $Id: fts3near.test,v 1.3 2009/01/02 17:33:46 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndb eval {\n  CREATE VIRTUAL TABLE t1 USING fts3(content);\n  INSERT INTO t1(content) VALUES('one three four five');\n  INSERT INTO t1(content) VALUES('two three four five');\n  INSERT INTO t1(content) VALUES('one two three four five');\n}\n\ndo_test fts3near-1.1 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/0 three'}\n} {1}\ndo_test fts3near-1.2 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/1 two'}\n} {3}\ndo_test fts3near-1.3 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR/1 three'}\n} {1 3}\ndo_test fts3near-1.4 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'three NEAR/1 one'}\n} {1 3}\ndo_test fts3near-1.5 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH '\"one two\" NEAR/1 five'}\n} {}\ndo_test fts3near-1.6 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH '\"one two\" NEAR/2 five'}\n} {3}\ndo_test fts3near-1.7 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR four'}\n} {1 3}\ndo_test fts3near-1.8 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'four NEAR three'}\n} {1 2 3}\ndo_test fts3near-1.9 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH '\"four five\" NEAR/0 three'}\n} {1 2 3}\ndo_test fts3near-1.10 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH '\"four five\" NEAR/2 one'}\n} {1 3}\ndo_test fts3near-1.11 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH '\"four five\" NEAR/1 one'}\n} {1}\ndo_test fts3near-1.12 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'five NEAR/1 \"two three\"'}\n} {2 3} \ndo_test fts3near-1.13 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR five'}\n} {1 3} \n\ndo_test fts3near-1.14 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'four NEAR four'}\n} {} \ndo_test fts3near-1.15 {\n  execsql {SELECT docid FROM t1 WHERE content MATCH 'one NEAR two NEAR one'}\n} {3} \n\ndo_test fts3near-1.16 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH '\"one three\" NEAR/0 \"four five\"'\n  }\n} {1} \ndo_test fts3near-1.17 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH '\"four five\" NEAR/0 \"one three\"'\n  }\n} {1} \n\n\n# Output format of the offsets() function:\n#\n#     <column number> <term number> <starting offset> <number of bytes>\n#\ndb eval {\n  INSERT INTO t1(content) VALUES('A X B C D A B');\n}\ndo_test fts3near-2.1 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/0 B'\n  }\n} {{0 0 10 1 0 1 12 1}}\ndo_test fts3near-2.2 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'B NEAR/0 A'\n  }\n} {{0 1 10 1 0 0 12 1}}\ndo_test fts3near-2.3 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH '\"C D\" NEAR/0 A'\n  }\n} {{0 0 6 1 0 1 8 1 0 2 10 1}}\ndo_test fts3near-2.4 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/0 \"C D\"'\n  }\n} {{0 1 6 1 0 2 8 1 0 0 10 1}}\ndo_test fts3near-2.5 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR A'\n  }\n} {{0 0 0 1 0 1 0 1 0 0 10 1 0 1 10 1}}\ndo_test fts3near-2.6 {\n  execsql {\n    INSERT INTO t1 VALUES('A A A');\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR/2 A';\n  }\n} [list [list 0 0 0 1   0 1 0 1   0 0 2 1   0 1 2 1   0 0 4 1   0 1 4 1]]\ndo_test fts3near-2.7 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('A A A A');\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'A NEAR A NEAR A';\n  }\n} [list [list \\\n    0 0 0 1   0 1 0 1   0 2 0 1   0 0 2 1   \\\n    0 1 2 1   0 2 2 1   0 0 4 1   0 1 4 1   \\\n    0 2 4 1   0 0 6 1   0 1 6 1   0 2 6 1   \\\n]]\n\ndb eval {\n  DELETE FROM t1;\n  INSERT INTO t1(content) VALUES(\n    'one two three two four six three six nine four eight twelve'\n  );\n}\n\ndo_test fts3near-3.1 {\n  execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/1 one'}\n} {{0 1 0 3 0 0 8 5}}\ndo_test fts3near-3.2 {\n  execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'one NEAR/1 three'}\n} {{0 0 0 3 0 1 8 5}}\ndo_test fts3near-3.3 {\n  execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/1 two'}\n} {{0 1 4 3 0 0 8 5 0 1 14 3}}\ndo_test fts3near-3.4 {\n  execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/2 two'}\n} {{0 1 4 3 0 0 8 5 0 1 14 3 0 0 27 5}}\ndo_test fts3near-3.5 {\n  execsql {SELECT offsets(t1) FROM t1 WHERE content MATCH 'two NEAR/2 three'}\n} {{0 0 4 3 0 1 8 5 0 0 14 3 0 1 27 5}}\ndo_test fts3near-3.6 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH 'three NEAR/0 \"two four\"'\n  }\n} {{0 0 8 5 0 1 14 3 0 2 18 4}}\ndo_test fts3near-3.7 {\n  execsql {\n    SELECT offsets(t1) FROM t1 WHERE content MATCH '\"two four\" NEAR/0 three'}\n} {{0 2 8 5 0 0 14 3 0 1 18 4}}\n\ndb eval {\n  INSERT INTO t1(content) VALUES('\n    This specification defines Cascading Style Sheets, level 2 (CSS2). CSS2 is a style sheet language that allows authors and users to attach style (e.g., fonts, spacing, and aural cues) to structured documents (e.g., HTML documents and XML applications). By separating the presentation style of documents from the content of documents, CSS2 simplifies Web authoring and site maintenance.\n\n    CSS2 builds on CSS1 (see [CSS1]) and, with very few exceptions, all valid CSS1 style sheets are valid CSS2 style sheets. CSS2 supports media-specific style sheets so that authors may tailor the presentation of their documents to visual browsers, aural devices, printers, braille devices, handheld devices, etc. This specification also supports content positioning, downloadable fonts, table layout, features for internationalization, automatic counters and numbering, and some properties related to user interface.\n  ') \n}\ndo_test fts3near-4.1 {\n  execsql {\n    SELECT snippet(t1) FROM t1 WHERE content MATCH 'specification NEAR supports'\n  }\n} {{<b>...</b>braille devices, handheld devices, etc. This <b>specification</b> also <b>supports</b> content positioning, downloadable fonts, table layout<b>...</b>}}\n\ndo_test fts3near-5.1 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification attach'\n  }\n} {2}\ndo_test fts3near-5.2 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification NEAR attach'\n  }\n} {}\ndo_test fts3near-5.3 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/18 attach'\n  }\n} {}\ndo_test fts3near-5.4 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/19 attach'\n  }\n} {2}\ndo_test fts3near-5.5 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/000018 attach'\n  }\n} {}\ndo_test fts3near-5.6 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'specification NEAR/000019 attach'\n  }\n} {2}\n\ndb eval {\n  INSERT INTO t1 VALUES('\n      abbrev aberrations abjurations aboding abr abscesses absolutistic\n      abstention abuses acanthuses acceptance acclaimers accomplish\n      accoutring accusation acetonic acid acolytes acquitting acrylonitrile\n      actives acyclic addicted adenoid adjacently adjusting admissible\n      adoption adulated advantaging advertisers aedes aerogramme aetiology\n      affiliative afforest afterclap agamogenesis aggrade agings agonize\n      agron ailurophile airfreight airspeed alarmists alchemizing\n      alexandrines alien aliped all allergenic allocator allowances almost\n      alphabetizes altho alvine amaurosis ambles ameliorate amicability amnio\n      amour ampicillin amusement anadromous analogues anarchy anchormen\n      anecdota aneurin angst animating anlage announcements anodized\n      answerable antemeridian anthracene antiabortionist anticlimaxes\n      antifriction antimitotic antiphon antiques antithetic anviled\n      apatosaurus aphrodisia apodal aposiopesis apparatus appendectomies\n      applications appraisingly appropriate apteryx arabinose\n      arboricultural archdeaconates archipelago ardently arguers armadillo\n      arnicas arrayed arrowy arthroscope artisans ascensive ashier\n      aspersorium assail assentor assignees assonants astereognosis\n      astringency astutest atheistical atomize attachment attenuates\n      attrahent audibility augite auricle auteurists autobus autolysis\n      autosome avenge avidest aw awl ayes babirusa backbeats backgrounder\n      backseat backswings baddie bagnios baked balefuller ballista balmily\n      bandbox bandylegged bankruptcy baptism barbering bargain barneys\n      barracuda barterer bashes bassists bathers batterer bavardage\n      beachfront beanstalk beauteous become bedim bedtimes beermats begat\n      begun belabors bellarmine belongings bending benthos bereavements\n      besieger bestialized betide bevels biases bicarbonates bidentate bigger\n      bile billow bine biodynamics biomedicine biotites birding bisection\n      bitingly bkg blackheads blaeberry blanking blatherer bleeper blindage\n      blithefulness blockish bloodstreams bloused blubbing bluestocking\n      blurted boatbill bobtailed boffo bold boltrope bondservant bonks\n      bookbinding bookworm booting borating boscages botchers bougainvillea\n      bounty bowlegged boyhood bracketed brainstorm brandishes\n      braunschweigers brazilin breakneck breathlessness brewage bridesmaids\n      brighter brisker broader brokerages bronziest browband brunets bryology\n      bucking budlike bugleweed bulkily bulling bummer bunglers bureau burgs\n      burrito bushfire buss butlery buttressing bylines cabdriver cached\n      cadaverousnesses cafeterias cakewalk calcifies calendula callboy calms\n      calyptra camisoles camps candelabrum caned cannolis canoodling cantors\n      cape caponize capsuling caracoled carbolics carcase carditis caretakers\n      carnallite carousel carrageenan cartels carves cashbook castanets\n      casuistry catalyzer catchers categorizations cathexis caucuses\n      causeway cavetto cede cella cementite centenary centrals ceramics ceria\n      cervixes chafferer chalcopyrites chamfers change chaotically\n      characteristically charivari chases chatterer cheats cheeks chef\n      chemurgy chetah chickaree chigoes chillies chinning chirp chive\n      chloroforms chokebore choplogic chorioids chromatic chronically\n      chubbiest chunder chutzpah cimetidine cinque circulated circumscribe\n      cirrose citrin claddagh clamorousness clapperboards classicalism\n      clauses cleanse clemency clicker clinchers cliquiest clods closeting\n      cloudscape clucking cnidarian coalfish coatrack coca cockfights coddled\n      coeducation coexistence cognitively coiffed colatitude collage\n      collections collinear colonelcy colorimetric columelliform combos\n      comforters commence commercialist commit commorancy communized compar\n      compendiously complainers compliance composition comprised comradery\n      concelebrants concerted conciliation concourses condensate\n      condonations confab confessionals confirmed conforming congeal\n      congregant conjectured conjurers connoisseurs conscripting\n      conservator consolable conspired constricting consuls contagious\n      contemporaneity contesters continuities contractors contrarian\n      contrive convalescents convents convexly convulsed cooncan coparcenary\n      coprolite copyreader cordially corklike cornflour coroner corralling\n      corrigible corsages cosies cosmonauts costumer cottontails counselings\n      counterclaim counterpane countertenors courageously couth coveting\n      coworker cozier cracklings crampon crappies craved cream credenzas\n      crematoriums cresol cricoid crinkle criterion crocodile crore crossover\n      crowded cruelest crunch cruzeiros cryptomeria cubism cuesta culprit\n      cumquat cupped curdle curly cursoring curvy customized cutting cyclamens\n      cylindrical cytaster dachshund daikon damages damselfly dangling\n      darkest databanks dauphine dazzling deadpanned deathday debauchers\n      debunking decameter decedents decibel decisions declinations\n      decomposition decoratively decretive deduct deescalated defecating\n      deferentially definiendum defluxion defrocks degrade deice dekaliters\n      deli delinquencies deludedly demarcates demineralizers demodulating\n      demonstrabilities demurred deniabilities denouncement denudation\n      departure deplorable deposing depredatory deputizes derivational\n      desalinization descriptors desexes desisted despising destitute\n      detectability determiner detoxifying devalued devilries devotions\n      dextrous diagenesis dialling diaphoresis diazonium dickeys diddums\n      differencing dig dignified dildo dimetric dineric dinosaurs diplodocus\n      directer dirty disagrees disassembler disburses disclosures\n      disconcerts discountability discrete disembarrass disenthrone\n      disgruntled dishpans disintegrators dislodged disobedient\n      dispassionate dispiritednesses dispraised disqualifying\n      dissatisfying dissidence dissolvers distich distracting distrusts\n      ditto diverse divineness dizzily dockyard dodgers doggish doited dom\n      dominium doohickey doozie dorsum doubleheaders dourer downbeats\n      downshifted doyennes draftsman dramatic drawling dredge drifter\n      drivelines droopier drowsed drunkards dubiosities duding dulcifying\n      dumpcart duodecillion durable duteous dyed dysgenic eagles earplugs\n      earwitness ebonite echoers economical ectothermous edibility educates\n      effected effigies eggbeaters egresses ejaculates elasticize elector\n      electrodynamometer electrophorus elem eligibly eloped emaciating\n      embarcaderos embezzlers embosses embryectomy emfs emotionalizing\n      empiricist emu enamels enchained encoded encrusts endeavored endogamous\n      endothelioma energizes engager engrosses enl enologist enrolls ensphere\n      enters entirety entrap entryways envies eosinophil epicentral\n      epigrammatized episodic epochs equestrian equitably erect ernes\n      errorless escalated eschatology espaliers essonite estop eternity\n      ethnologically eudemonics euphonious euthenist evangelizations\n      eventuality evilest evulsion examinee exceptionably exciter\n      excremental execrably exemplars exhalant exhorter exocrine exothermic\n      expected expends explainable exploratory expostulatory expunges\n      extends externals extorts extrapolative extrorse eyebolt eyra\n      facetiously factor faeries fairings fallacies falsities fancifulness\n      fantasticalness farmhouse fascinate fatalistically fattener fave\n      fearlessly featly federates feints fellowman fencers ferny\n      fertilenesses feta feudality fibers fictionalize fiefs fightback\n      filefish filmier finaglers fingerboards finochio firefly firmament\n      fishmeal fitted fjords flagitiousnesses flamen flaps flatfooting\n      flauntier fleapit fleshes flickertail flints floaty floorboards\n      floristic flow fluffily fluorescein flutes flyspecks foetal folderols\n      followable foolhardier footlockers foppish forceless foredo foreknows\n      foreseeing foretaste forgather forlorn formidableness fortalice\n      forwarding founding foxhunting fragmentarily frangipani fray freeform\n      freezable freshening fridges frilliest frizzed frontbench frottages\n      fruitcake fryable fugleman fulminated functionalists fungoid furfuran\n      furtive fussy fwd gadolinium galabias gallinaceous galvanism gamers\n      gangland gaoling garganey garrisoning gasp gate gauger gayety geed\n      geminately generalissimos genii gentled geochronology geomorphic\n      geriatricians gesellschaft ghat gibbeting giggles gimps girdlers\n      glabella glaive glassfuls gleefully glistered globetrotted glorifier\n      gloving glutathione glyptodont goaled gobsmacked goggliest golliwog\n      goobers gooseberries gormandizer gouramis grabbier gradually grampuses\n      grandmothers granulated graptolite gratuitously gravitates greaten\n      greenmailer greys grills grippers groan gropingly grounding groveling\n      grueled grunter guardroom guggle guineas gummed gunnysacks gushingly\n      gutturals gynecoid gyrostabilizer habitudes haemophilia hailer hairs\n      halest hallow halters hamsters handhelds handsaw hangup haranguer\n      hardheartedness harlotry harps hashing hated hauntingly hayrack\n      headcases headphone headword heartbreakers heaters hebephrenia\n      hedonist heightening heliozoan helots hemelytron hemorrhagic hent\n      herbicides hereunto heroines heteroclitics heterotrophs hexers\n      hidebound hies hightails hindmost hippopotomonstrosesquipedalian\n      histologist hittable hobbledehoys hogans holdings holocrine homegirls\n      homesteader homogeneousness homopolar honeys hoodwinks hoovered\n      horizontally horridness horseshoers hospitalization hotdogging houri\n      housemate howitzers huffier humanist humid humors huntress husbandmen\n      hyaenas hydride hydrokinetics hydroponically hygrothermograph\n      hyperbolically hypersensitiveness hypnogogic hypodermically\n      hypothermia iatrochemistry ichthyological idealist ideograms idling\n      igniting illegal illuminatingly ilmenite imbibing immateriality\n      immigrating immortalizes immures imparts impeder imperfection\n      impersonated implant implying imposition imprecating imprimis\n      improvising impv inanenesses inaugurate incapably incentivize\n      incineration incloses incomparableness inconsequential incorporate\n      incrementing incumbered indecorous indentation indicative indignities\n      indistinguishably indoors indulges ineducation inerrable\n      inexperienced infants infestations infirmnesses inflicting\n      infracostal ingathered ingressions inheritances iniquity\n      injuriousnesses innervated inoculates inquisitionist insectile\n      insiders insolate inspirers instatement instr insulates intactness\n      intellects intensifies intercalations intercontinental interferon\n      interlarded intermarrying internalizing interpersonally\n      interrelatednesses intersperse interviewees intolerance\n      intransigents introducing intubates invades inventing inveterate\n      invocate iodides irenicism ironsmith irreducibly irresistibility\n      irriguous isobarisms isometrically issuable itineracies jackdaws\n      jaggery jangling javelins jeeringly jeremiad jeweler jigsawing jitter\n      jocosity jokester jot jowls judicative juicy jungly jurists juxtaposed\n      kalpa karstify keddah kendo kermesses keynote kibbutznik kidnaper\n      kilogram kindred kingpins kissers klatch kneads knobbed knowingest\n      kookaburras kruller labefaction labyrinths lacquer laddered lagoons\n      lambency laminates lancinate landscapist lankiness lapse larked lasso\n      laterite laudableness laundrywomen lawgiver laypersons leafhoppers\n      leapfrogs leaven leeches legated legislature leitmotifs lenients\n      leprous letterheads levelling lexicographically liberalists\n      librettist licorice lifesaving lightheadedly likelier limekiln limped\n      lines linkers lipoma liquidator listeners litharge litmus\n      liverishnesses loamier lobeline locative locutionary loggier loiterer\n      longevity loomed loping lotion louts lowboys luaus lucrativeness lulus\n      lumpier lungi lush luthern lymphangial lythraceous machinists maculate\n      maggot magnetochemistry maharani maimers majored malaprops malignants\n      maloti mammary manchineel manfully manicotti manipulativenesses\n      mansards manufactories maraschino margin markdown marooning marshland\n      mascaraing massaging masticate matchmark matings mattes mausoleum\n      mayflies mealworm meataxe medevaced medievalist meetings megavitamin\n      melded melodramatic memorableness mendaciousnesses mensurable\n      mercenaries mere meronymous mesmerizes mestee metallurgical\n      metastasize meterages meticulosity mewed microbe microcrystalline\n      micromanager microsporophyll midiron miffed milder militiamen\n      millesimal milometer mincing mingily minims minstrelsy mires\n      misanthropic miscalculate miscomprehended misdefines misery mishears\n      misled mispickel misrepresent misspending mistranslate miswriting\n      mixologists mobilizers moderators modulate mojo mollies momentum monde\n      monied monocles monographs monophyletic monotonousness moocher\n      moorages morality morion mortally moseyed motherly motorboat mouldering\n      mousers moveables mucky mudslides mulatto multicellularity\n      multipartite multivalences mundanities murkiest mushed muskiness\n      mutability mutisms mycelia myosotis mythicist nacred namable napkin\n      narghile nastiness nattering nauseations nearliest necessitate\n      necrophobia neg negotiators neologizes nephrotomy netiquette\n      neurophysiology newbie newspaper niccolite nielsbohriums nightlong\n      nincompoops nitpicked nix noddling nomadize nonadhesive noncandidates\n      nonconducting nondigestible nones nongreasy nonjoinder nonoccurrence\n      nonporousness nonrestrictive nonstaining nonuniform nooses northwards\n      nostalgic notepaper nourishment noyades nuclides numberless numskulls\n      nutmegged nymphaea oatmeal obis objurgators oblivious obsequiousness\n      obsoletism obtruding occlusions ocher octettes odeums offcuts\n      officiation ogival oilstone olestras omikron oncogenesis onsetting\n      oomphs openly ophthalmoscope opposites optimum orangutans\n      orchestrations ordn organophosphates origin ornithosis orthognathous\n      oscillatory ossuaries ostracized ounce outbreaks outearning outgrows\n      outlived outpoints outrunning outspends outwearing overabound\n      overbalance overcautious overcrowds overdubbing overexpanding\n      overgraze overindustrialize overlearning overoptimism overproducing\n      overripe overshadowing overspreading overstuff overtones overwind ow\n      oxidizing pacer packs paganish painstakingly palate palette pally\n      palsying pandemic panhandled pantheism papaws papped parading\n      parallelize paranoia parasitically pardners parietal parodied pars\n      participator partridgeberry passerines password pastors\n      paterfamiliases patination patrolman paunch pawnshops peacekeeper\n      peatbog peculator pedestrianism peduncles pegboard pellucidnesses\n      pendency penitentiary penstock pentylenetetrazol peptidase perched\n      perennial performing perigynous peripheralize perjurer permissively\n      perpetuals persistency perspicuously perturbingly pesky petcock\n      petrologists pfennige pharmacies phenformin philanderers\n      philosophically phonecards phosgenes photocomposer photogenic photons\n      phototype phylloid physiotherapeutics picadores pickup pieces pigging\n      pilaster pillion pimples pinioned pinpricks pipers pirogi pit\n      pitifullest pizza placental plainly planing plasmin platforming\n      playacts playwrights plectra pleurisy plopped plug plumule plussed\n      poaches poetasters pointless polarize policyholder polkaed\n      polyadelphous polygraphing polyphonous pomace ponderers pooch poplar\n      porcelains portableness portly positioning postage posthumously\n      postponed potages potholed poulard powdering practised pranksters\n      preadapt preassigning precentors precipitous preconditions predefined\n      predictors preengage prefers prehumans premedical prenotification\n      preplanning prepuberty presbytery presentation presidia prestissimo\n      preterites prevailer prewarmed priding primitively principalships\n      prisage privileged probed prochurch proctoscope products proficients\n      prognathism prohibiting proletarianisms prominence promulgates\n      proofreading property proportions prorate proselytize prosthesis\n      proteins prototypic provenances provitamin prudish pseudonymities\n      psychoanalysts psychoneuroses psychrometer publishable pufferies\n      pullet pulses punchy punkins purchased purities pursers pushover\n      putridity pylons pyrogenous pzazz quadricepses quaff qualmish quarriers\n      quasilinear queerness questionnaires quieten quintals quislings quoits\n      rabidness racketeers radiative radioisotope radiotherapists ragingly\n      rainband rakishness rampagers rands raped rare raspy ratiocinator\n      rattlebrain ravening razz reactivation readoption realm reapportioning\n      reasoning reattempts rebidding rebuts recapitulatory receptiveness\n      recipes reckonings recognizee recommendatory reconciled reconnoiters\n      recontaminated recoupments recruits recumbently redact redefine\n      redheaded redistributable redraw redwing reeled reenlistment reexports\n      refiles reflate reflowing refortified refried refuses regelate\n      registrant regretting rehabilitative reigning reinduced reinstalled\n      reinvesting rejoining relations relegates religiosities reluctivity\n      remastered reminisce remodifying remounted rends renovate reordered\n      repartee repel rephrase replicate repossessing reprint reprogramed\n      repugnantly requiter rescheduling resegregate resettled residually\n      resold resourcefulness respondent restating restrainedly resubmission\n      resurveyed retaliating retiarius retorsion retreated retrofitting\n      returning revanchism reverberated reverted revitalization\n      revolutionize rewind rhapsodizing rhizogenic rhythms ricketinesses\n      ridicule righteous rilles rinks rippliest ritualize riyals roast rockery\n      roguish romanizations rookiest roquelaure rotation rotundity rounder\n      routinizing rubberize rubricated ruefully ruining rummaged runic\n      russets ruttish sackers sacrosanctly safeguarding said salaciousness\n      salinity salsas salutatorians sampan sandbag saned santonin\n      saprophagous sarnies satem saturant savaged sawbucks scablike scalp\n      scant scared scatter schedulers schizophrenics schnauzers schoolmarms\n      scintillae scleroses scoped scotched scram scratchiness screwball\n      scripting scrubwomen scrutinizing scumbled scuttled seals seasickness\n      seccos secretions secularizing seditiousnesses seeking segregators\n      seize selfish semeiology seminarian semitropical sensate sensors\n      sentimo septicemic sequentially serener serine serums\n      sesquicentennials seventeen sexiest sforzandos shadowing shallot\n      shampooing sharking shearer sheered shelters shifter shiner shipper\n      shitted shoaled shofroth shorebirds shortsightedly showboated shrank\n      shrines shucking shuttlecocks sickeningly sideling sidewise sigil\n      signifiers siliceous silty simony simulative singled sinkings sirrah\n      situps skateboarder sketchpad skim skirmished skulkers skywalk slander\n      slating sleaziest sleepyheads slicking slink slitting slot slub\n      slumlords smallest smattered smilier smokers smriti snailfish snatch\n      snides snitching snooze snowblowers snub soapboxing socialite sockeyes\n      softest sold solicitings solleret sombreros somnolencies sons sopor\n      sorites soubrette soupspoon southpaw spaces spandex sparkers spatially\n      speccing specking spectroscopists speedsters spermatics sphincter\n      spiffied spindlings spirals spitball splayfeet splitter spokeswomen\n      spooled sportily spousals sprightliness sprogs spurner squalene\n      squattered squelches squirms stablish staggerings stalactitic stamp\n      stands starflower starwort stations stayed steamroll steeplebush\n      stemmatics stepfathers stereos steroid sticks stillage stinker\n      stirringly stockpiling stomaching stopcock stormers strabismuses\n      strainer strappado strawberries streetwise striae strikeouts strives\n      stroppiest stubbed study stunting style suavity subchloride subdeb\n      subfields subjoin sublittoral subnotebooks subprograms subside\n      substantial subtenants subtreasuries succeeding sucked sufferers\n      sugarier sulfaguanidine sulphating summerhouse sunbonnets sunned\n      superagency supercontinent superheroes supernatural superscribing\n      superthin supplest suppositive surcease surfs surprise survey\n      suspiration svelte swamplands swashes sweatshop swellhead swindling\n      switching sworn syllabuses sympathetics synchrocyclotron syndic\n      synonymously syringed tablatures tabulation tackling taiga takas talker\n      tamarisks tangential tans taproom tarpapers taskmaster tattiest\n      tautologically taxied teacup tearjerkers technocracies teepee\n      telegenic telephony telexed temperaments temptress tenderizing tensed\n      tenuring tergal terned terror testatrices tetherball textile thatched\n      their theorem thereof thermometers thewy thimerosal thirsty\n      thoroughwort threateningly thrived through thumbnails thwacks\n      ticketing tie til timekeepers timorousness tinkers tippers tisane\n      titrating toastmaster toff toking tomb tongs toolmakings topes topple\n      torose tortilla totalizing touchlines tousling townsmen trachea\n      tradeable tragedienne traitorous trances transcendentalists\n      transferrable tranship translating transmogrifying transportable\n      transvestism traumatize treachery treed trenail tressing tribeswoman\n      trichromatism triennials trikes trims triplicate tristich trivializes\n      trombonist trots trouts trued trunnion tryster tubes tulle tundras turban\n      turgescence turnround tutelar tweedinesses twill twit tympanum typists\n      tzarists ulcered ultramodern umbles unaccountability unamended\n      unassertivenesses unbanned unblocked unbundled uncertified unclaimed\n      uncoated unconcerns unconvinced uncrossing undefined underbodice\n      underemphasize undergrowth underpayment undershirts understudy\n      underwritten undissolved unearthed unentered unexpended unfeeling\n      unforeseen unfussy unhair unhinges unifilar unimproved uninvitingly\n      universalization unknowns unlimbering unman unmet unnaturalness\n      unornament unperturbed unprecedentedly unproportionate unread\n      unreflecting unreproducible unripe unsatisfying unseaworthiness\n      unsharable unsociable unstacking unsubtly untactfully untied untruest\n      unveils unwilled unyokes upheave upraised upstart upwind urethrae\n      urtexts usurers uvula vacillators vailed validation valvule vanities\n      varia variously vassaled vav veggies velours venerator ventrals\n      verbalizes verification vernacularized verticality vestigially via\n      vicariously victoriousness viewpoint villainies vines violoncellist\n      virtual viscus vital vitrify viviparous vocalizers voidable volleys\n      volutes vouches vulcanology wackos waggery wainwrights waling wallowing\n      wanking wardroom warmup wartiest washwoman watchman watermarks waverer\n      wayzgoose weariest weatherstripped weediness weevil welcomed\n      wentletrap whackers wheatworm whelp whf whinged whirl whistles whithers\n      wholesomeness whosoever widows wikiup willowier windburned windsail\n      wingspread winterkilled wisecracking witchgrass witling wobbliest\n      womanliness woodcut woodworking woozy working worldwide worthiest\n      wrappings wretched writhe wynd xylophone yardarm yea yelped yippee yoni\n      yuks zealotry zigzagger zitherists zoologists zygosis');\n}\n\ndo_test fts3near-6.1 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'abbrev zygosis'\n  }\n} {3}\ndo_test fts3near-6.2 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR zygosis'\n  }\n} {}\ndo_test fts3near-6.3 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/100 zygosis'\n  }\n} {}\ndo_test fts3near-6.4 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/1000 zygosis'\n  }\n} {}\ndo_test fts3near-6.5 {\n  execsql {\n    SELECT docid FROM t1 WHERE content MATCH 'abbrev NEAR/10000 zygosis'\n  }\n} {3}\n\n# Ticket 38b1ae018f.\n#\ndo_execsql_test fts3near-7.1 {\n  CREATE VIRTUAL TABLE x USING fts4(y,z);\n  INSERT INTO x VALUES('aaa bbb ccc ddd', 'bbb ddd aaa ccc');\n  SELECT * FROM x where y MATCH 'bbb NEAR/6 aaa';\n} {{aaa bbb ccc ddd} {bbb ddd aaa ccc}}\n\ndo_execsql_test fts3near-7.2 {\n  CREATE VIRTUAL TABLE t2 USING fts4(a, b);\n  INSERT INTO t2 VALUES('A B C', 'A D E');\n  SELECT * FROM t2 where t2 MATCH 'a:A NEAR E'\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3offsets.test",
    "content": "# 2010 November 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\n\nset testprefix fts3offsets\nset sqlite_fts3_enable_parentheses 1\n\nproc extract {offsets text} {\n  set res \"\"\n\n  set off [list]\n  foreach {t i s n} $offsets {\n    lappend off [list $s $n]\n  }\n  set off [lsort -integer -index 0 $off]\n\n  set iOff 0\n  foreach e $off {\n    foreach {s n} $e {}\n    append res [string range $text $iOff $s-1]\n    append res \"(\"\n    append res [string range $text $s [expr $s+$n-1]]\n    append res \")\"\n    set iOff [expr $s+$n]\n  }\n  append res [string range $text $iOff end]\n  \n  set res\n}\ndb func extract extract\n\n\ndo_execsql_test 1.1.0 {\n  CREATE VIRTUAL TABLE xx USING fts3(x);\n  INSERT INTO xx VALUES('A x x x B C x x');\n  INSERT INTO xx VALUES('A B C x B x x C');\n  INSERT INTO xx VALUES('A x x B C x x x');\n}\ndo_execsql_test 1.1.1 {\n  SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';\n} {\n  1 {(A) x x x (B) (C) x x} \n  2 {(A) (B) (C) x (B) x x C} \n  3 {(A) x x (B) (C) x x x}\n}\n\ndo_execsql_test 1.2 {\n  DELETE FROM xx;\n  INSERT INTO xx VALUES('A x x x B C x x');\n  INSERT INTO xx VALUES('A x x C x x x C');\n  INSERT INTO xx VALUES('A x x B C x x x');\n}\ndo_execsql_test 1.2.1 {\n  SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';\n} {\n  1 {(A) x x x (B) (C) x x}\n  2 {(A) x x C x x x C} \n  3 {(A) x x (B) (C) x x x}\n}\n\ndo_execsql_test 1.3 {\n  DELETE FROM xx;\n  INSERT INTO xx(rowid, x) VALUES(1, 'A B C');\n  INSERT INTO xx(rowid, x) VALUES(2, 'A x');\n  INSERT INTO xx(rowid, x) VALUES(3, 'A B C');\n  INSERT INTO xx(rowid, x) VALUES(4, 'A B C x x x x x x x B');\n  INSERT INTO xx(rowid, x) VALUES(5, 'A x x x x x x x x x C');\n  INSERT INTO xx(rowid, x) VALUES(6, 'A x x x x x x x x x x x B');\n  INSERT INTO xx(rowid, x) VALUES(7, 'A B C');\n}\ndo_execsql_test 1.3.1 {\n  SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)';\n} {\n  1 {(A) (B) (C)}\n  2 {(A) x}\n  3 {(A) (B) (C)}\n  4 {(A) (B) (C) x x x x x x x B}\n  5 {(A) x x x x x x x x x C}\n  6 {(A) x x x x x x x x x x x B} \n  7 {(A) (B) (C)}\n}\n\n\ndo_execsql_test 1.4 {\n  DELETE FROM xx;\n  INSERT INTO xx(rowid, x) VALUES(7, 'A B C');\n  INSERT INTO xx(rowid, x) VALUES(6, 'A x');\n  INSERT INTO xx(rowid, x) VALUES(5, 'A B C');\n  INSERT INTO xx(rowid, x) VALUES(4, 'A B C x x x x x x x B');\n  INSERT INTO xx(rowid, x) VALUES(3, 'A x x x x x x x x x C');\n  INSERT INTO xx(rowid, x) VALUES(2, 'A x x x x x x x x x x x B');\n  INSERT INTO xx(rowid, x) VALUES(1, 'A B C');\n}\ndo_execsql_test 1.4.1 {\n  SELECT oid,extract(offsets(xx), x) FROM xx WHERE xx MATCH 'a OR (b NEAR/1 c)'\n  ORDER BY docid DESC;\n} {\n  7 {(A) (B) (C)}\n  6 {(A) x}\n  5 {(A) (B) (C)}\n  4 {(A) (B) (C) x x x x x x x B}\n  3 {(A) x x x x x x x x x C}\n  2 {(A) x x x x x x x x x x x B} \n  1 {(A) (B) (C)}\n}\n\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3prefix.test",
    "content": "# 2011 May 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3prefix\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# This proc tests that the prefixes index appears to represent the same content\n# as the terms index.\n#\nproc fts3_terms_and_prefixes {db tbl prefixlengths} {\n\n  set iIndex 0\n  foreach len $prefixlengths {\n    incr iIndex\n    $db eval {\n      DROP TABLE IF EXISTS fts3check1;\n      DROP TABLE IF EXISTS fts3check2;\n    }\n    $db eval \"CREATE VIRTUAL TABLE fts3check1 USING fts4term($tbl, 0);\"\n    $db eval \"CREATE VIRTUAL TABLE fts3check2 USING fts4term($tbl, $iIndex);\"\n\n    $db eval {\n      DROP TABLE IF EXISTS temp.terms;\n      DROP TABLE IF EXISTS temp.prefixes;\n      CREATE TEMP TABLE terms AS SELECT * FROM fts3check1;\n      CREATE TEMP TABLE prefixes AS SELECT * FROM fts3check2;\n      CREATE INDEX temp.idx ON prefixes(term);\n      DROP TABLE fts3check1;\n      DROP TABLE fts3check2;\n    }\n\n    set nExpect 0\n    $db eval { SELECT term, docid, col, pos FROM temp.terms } a {\n      if {[string length $a(term)]<$len} continue\n      incr nExpect\n      set prefix [string range $a(term) 0 [expr $len-1]]\n      set r [$db one { \n        SELECT count(*) FROM temp.prefixes WHERE \n        term = $prefix AND docid = $a(docid) AND col = $a(col) AND pos = $a(pos)\n      }]\n      if {$r != 1} {\n        error \"$t, $a(docid), $a(col), $a(pos)\"\n      }\n    }\n\n    set nCount [$db one {SELECT count(*) FROM temp.prefixes}]\n    if {$nCount != $nExpect} {\n      error \"prefixes.count(*) is $nCount expected $nExpect\"\n    }\n  \n    execsql { DROP TABLE temp.prefixes }\n    execsql { DROP TABLE temp.terms }\n\n    set list [list]\n    $db eval \"\n      SELECT sum( 1 << (16*(level%1024)) ) AS total, (level/1024) AS tree \n      FROM ${tbl}_segdir GROUP BY tree\n    \" {\n      lappend list [list $total $tree]\n    }\n\n    if { [lsort -integer -index 0 $list] != [lsort -integer -index 1 $list] } {\n      error \"inconsistent tree structures: $list\"\n    }\n  }\n\n  return \"\"\n}\nproc fts3_tap_test {tn db tbl lens} {\n  uplevel [list do_test $tn [list fts3_terms_and_prefixes $db $tbl $lens] \"\"]\n}\n\n#-------------------------------------------------------------------------\n# Test cases 1.* are a sanity check. They test that the prefixes index is\n# being constructed correctly for the simplest possible case.\n#\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix='1,3,6');\n\n  CREATE VIRTUAL TABLE p1 USING fts4term(t1, 1);\n  CREATE VIRTUAL TABLE p2 USING fts4term(t1, 2);\n  CREATE VIRTUAL TABLE p3 USING fts4term(t1, 3);\n  CREATE VIRTUAL TABLE terms USING fts4term(t1);\n}\ndo_execsql_test 1.2 {\n  INSERT INTO t1 VALUES('sqlite mysql firebird');\n}\ndo_execsql_test 1.3.1 { SELECT term FROM p1 } {f m s}\ndo_execsql_test 1.3.2 { SELECT term FROM p2 } {fir mys sql}\ndo_execsql_test 1.3.3 { SELECT term FROM p3 } {firebi sqlite}\ndo_execsql_test 1.4 {\n  SELECT term FROM terms;\n} {firebird mysql sqlite}\n\nfts3_tap_test 1.5 db t1 {1 3 6}\n\n#-------------------------------------------------------------------------\n# A slightly more complicated dataset. This test also verifies that DELETE\n# operations do not corrupt the prefixes index.\n#\ndo_execsql_test 2.1 {\n  INSERT INTO t1 VALUES('FTS3 and FTS4 are an SQLite virtual table modules');\n  INSERT INTO t1 VALUES('that allows users to perform full-text searches on');\n  INSERT INTO t1 VALUES('a set of documents. The most common (and');\n  INSERT INTO t1 VALUES('effective) way to describe full-text searches is');\n  INSERT INTO t1 VALUES('\"what Google, Yahoo and Altavista do with');\n  INSERT INTO t1 VALUES('documents placed on the World Wide Web\". Users');\n  INSERT INTO t1 VALUES('input a term, or series of terms, perhaps');\n  INSERT INTO t1 VALUES('connected by a binary operator or grouped together');\n  INSERT INTO t1 VALUES('into a phrase, and the full-text query system');\n  INSERT INTO t1 VALUES('finds the set of documents that best matches those');\n  INSERT INTO t1 VALUES('terms considering the operators and groupings the');\n  INSERT INTO t1 VALUES('user has specified. This article describes the');\n  INSERT INTO t1 VALUES('deployment and usage of FTS3 and FTS4.');\n  INSERT INTO t1 VALUES('FTS1 and FTS2 are obsolete full-text search');\n  INSERT INTO t1 VALUES('modules for SQLite. There are known issues with');\n  INSERT INTO t1 VALUES('these older modules and their use should be');\n  INSERT INTO t1 VALUES('avoided. Portions of the original FTS3 code were');\n  INSERT INTO t1 VALUES('contributed to the SQLite project by Scott Hess of');\n  INSERT INTO t1 VALUES('Google. It is now developed and maintained as part');\n  INSERT INTO t1 VALUES('of SQLite. ');\n}\nfts3_tap_test 2.2 db t1 {1 3 6}\ndo_execsql_test 2.3 { DELETE FROM t1 WHERE docid%2; }\nfts3_tap_test 2.4 db t1 {1 3 6}\n\ndo_execsql_test 2.5 { INSERT INTO t1(t1) VALUES('optimize') }\nfts3_tap_test 2.6 db t1 {1 3 6}\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(prefix='1,2,3');\n  INSERT INTO t2 VALUES('On 12 September the wind direction turned and');\n  INSERT INTO t2 VALUES('William''s fleet sailed. A storm blew up and the');\n  INSERT INTO t2 VALUES('fleet was forced to take shelter at');\n  INSERT INTO t2 VALUES('Saint-Valery-sur-Somme and again wait for the wind');\n  INSERT INTO t2 VALUES('to change. On 27 September the Norman fleet');\n  INSERT INTO t2 VALUES('finally set sail, landing in England at Pevensey');\n  INSERT INTO t2 VALUES('Bay (Sussex) on 28 September. William then moved');\n  INSERT INTO t2 VALUES('to Hastings, a few miles to the east, where he');\n  INSERT INTO t2 VALUES('built a prefabricated wooden castle for a base of');\n  INSERT INTO t2 VALUES('operations. From there, he ravaged the hinterland');\n  INSERT INTO t2 VALUES('and waited for Harold''s return from the north.');\n  INSERT INTO t2 VALUES('On 12 September the wind direction turned and');\n  INSERT INTO t2 VALUES('William''s fleet sailed. A storm blew up and the');\n  INSERT INTO t2 VALUES('fleet was forced to take shelter at');\n  INSERT INTO t2 VALUES('Saint-Valery-sur-Somme and again wait for the wind');\n  INSERT INTO t2 VALUES('to change. On 27 September the Norman fleet');\n  INSERT INTO t2 VALUES('finally set sail, landing in England at Pevensey');\n  INSERT INTO t2 VALUES('Bay (Sussex) on 28 September. William then moved');\n  INSERT INTO t2 VALUES('to Hastings, a few miles to the east, where he');\n  INSERT INTO t2 VALUES('built a prefabricated wooden castle for a base of');\n  INSERT INTO t2 VALUES('operations. From there, he ravaged the hinterland');\n  INSERT INTO t2 VALUES('and waited for Harold''s return from the north.');\n}\n\nfts3_tap_test 3.2 db t2 {1 2 3}\ndo_execsql_test 3.3 { SELECT optimize(t2) FROM t2 LIMIT 1 } {{Index optimized}}\nfts3_tap_test 3.4 db t2 {1 2 3}\n\n\n#-------------------------------------------------------------------------\n# Simple tests for reading the prefix-index.\n#\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE t3 USING fts4(prefix=\"1,4\");\n  INSERT INTO t3 VALUES('one two three');\n  INSERT INTO t3 VALUES('four five six');\n  INSERT INTO t3 VALUES('seven eight nine');\n}\ndo_execsql_test 4.2 {\n  SELECT * FROM t3 WHERE t3 MATCH 'f*'\n} {{four five six}}\ndo_execsql_test 4.3 {\n  SELECT * FROM t3 WHERE t3 MATCH 'four*'\n} {{four five six}}\ndo_execsql_test 4.4 {\n  SELECT * FROM t3 WHERE t3 MATCH 's*'\n} {{four five six} {seven eight nine}}\ndo_execsql_test 4.5 {\n  SELECT * FROM t3 WHERE t3 MATCH 'sev*'\n} {{seven eight nine}}\ndo_execsql_test 4.6 {\n  SELECT * FROM t3 WHERE t3 MATCH 'one*'\n} {{one two three}}\n\n#-------------------------------------------------------------------------\n# Syntax tests.\n#\ndo_catchsql_test 5.1 {\n  CREATE VIRTUAL TABLE t4 USING fts4(prefix=\"abc\");\n} {1 {error parsing prefix parameter: abc}}\ndo_catchsql_test 5.2 {\n  CREATE VIRTUAL TABLE t4 USING fts4(prefix=\"\");\n} {0 {}}\ndo_catchsql_test 5.3 {\n  CREATE VIRTUAL TABLE t5 USING fts4(prefix=\"-1\");\n} {1 {error parsing prefix parameter: -1}}\n\n#-------------------------------------------------------------------------\n# Prefix indexes of size 0 are ignored. Demonstrate this by showing that\n# adding prefix=0 does not change the contents of the %_segdir table.\n#\nreset_db\ndo_execsql_test 6.1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix=0);\n  CREATE VIRTUAL TABLE t2 USING fts4;\n  INSERT INTO t1 VALUES('Twas Mulga Bill, from Eaglehawk, ');\n  INSERT INTO t2 VALUES('Twas Mulga Bill, from Eaglehawk, ');\n} {}\ndo_execsql_test 6.1.2 {\n  SELECT md5sum(quote(root)) FROM t1_segdir;\n} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]\n\nreset_db\ndo_execsql_test 6.2.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix=\"1,0,2\");\n  CREATE VIRTUAL TABLE t2 USING fts4(prefix=\"1,2\");\n  INSERT INTO t1 VALUES('that caught the cycling craze;');\n  INSERT INTO t2 VALUES('that caught the cycling craze;');\n} {}\ndo_execsql_test 6.2.2 {\n  SELECT md5sum(quote(root)) FROM t1_segdir;\n} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]\n\nreset_db\ndo_execsql_test 6.3.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix=\"1,3,2\");\n  CREATE VIRTUAL TABLE t2 USING fts4(prefix=\"1,2\");\n  INSERT INTO t1 VALUES('He turned away the good old horse');\n  INSERT INTO t2 VALUES('He turned away the good old horse');\n} {}\ndo_test 6.3.2 {\n  set one [db eval {SELECT md5sum(quote(root)) FROM t1_segdir}]\n  set two [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]\n  expr {$one == $two}\n} 0\n\nreset_db\ndo_execsql_test 6.4.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix=\"1,600,2\");\n  CREATE VIRTUAL TABLE t2 USING fts4(prefix=\"1,2\");\n  INSERT INTO t1 VALUES('that served him many days;');\n  INSERT INTO t2 VALUES('that served him many days;');\n} {}\ndo_execsql_test 6.4.2 {\n  SELECT md5sum(quote(root)) FROM t1_segdir;\n} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]\n\nreset_db\ndo_execsql_test 6.5.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(prefix=\"2147483647,2147483648,2147483649\");\n  CREATE VIRTUAL TABLE t2 USING fts4(prefix=);\n  INSERT INTO t1 VALUES('He dressed himself in cycling clothes');\n  INSERT INTO t2 VALUES('He dressed himself in cycling clothes');\n} {}\ndo_execsql_test 6.5.2 {\n  SELECT md5sum(quote(root)) FROM t1_segdir;\n} [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}]\n\n\ndo_execsql_test 7.0 {\n  CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC);\n  INSERT INTO t6(docid, x) VALUES(-1,'a b');\n  INSERT INTO t6(docid, x) VALUES(1, 'b');\n}\ndo_execsql_test 7.1 {\n  SELECT docid FROM t6 WHERE t6 MATCH '\"a* b\"';\n} {-1}\ndo_execsql_test 7.2 {\n  SELECT docid FROM t6 WHERE t6 MATCH 'a*';\n} {-1}\ndo_execsql_test 7.3 {\n  SELECT docid FROM t6 WHERE t6 MATCH 'a* b';\n} {-1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3prefix2.test",
    "content": "# 2012 January 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3prefix2\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 { PRAGMA page_size = 512 }\ndo_execsql_test 1.1 { \n  CREATE VIRTUAL TABLE t1 USING fts4(x, prefix=\"2,3\");\n\n  BEGIN;\n    INSERT INTO t1 VALUES('T TX T TX T TX T TX T TX');\n    INSERT INTO t1 SELECT * FROM t1;                       -- 2\n    INSERT INTO t1 SELECT * FROM t1;                       -- 4\n    INSERT INTO t1 SELECT * FROM t1;                       -- 8\n    INSERT INTO t1 SELECT * FROM t1;                       -- 16\n    INSERT INTO t1 SELECT * FROM t1;                       -- 32\n    INSERT INTO t1 SELECT * FROM t1;                       -- 64\n    INSERT INTO t1 SELECT * FROM t1;                       -- 128\n    INSERT INTO t1 SELECT * FROM t1;                       -- 256\n    INSERT INTO t1 SELECT * FROM t1;                       -- 512\n    INSERT INTO t1 SELECT * FROM t1;                       -- 1024\n    INSERT INTO t1 SELECT * FROM t1;                       -- 2048\n  COMMIT;\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t1 SELECT * FROM t1 LIMIT 10;\n  INSERT INTO t1 SELECT * FROM t1 LIMIT 10;\n  INSERT INTO t1 SELECT * FROM t1 LIMIT 10;\n  DELETE FROM t1 WHERE docid > 5;\n}\n\ndo_execsql_test 1.3 {\n  SELECT * FROM t1 WHERE t1 MATCH 'T*';\n} {\n  {T TX T TX T TX T TX T TX}\n  {T TX T TX T TX T TX T TX}\n  {T TX T TX T TX T TX T TX}\n  {T TX T TX T TX T TX T TX}\n  {T TX T TX T TX T TX T TX}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3query.test",
    "content": "# 2009 December 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests of fts3 queries that have been useful during\n# the development process as well as some that have been useful in tracking\n# down bugs. They are not focused on any particular functionality.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build does not include FTS3, skip the tests in this file.\n#\nifcapable !fts3 { finish_test ; return }\nsource $testdir/malloc_common.tcl\nsource $testdir/fts3_common.tcl\nset DO_MALLOC_TEST 0\n\nset testprefix fts3query\n\ndo_test fts3query-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts3(x);\n    BEGIN;\n      INSERT INTO t1 VALUES('The source code for SQLite is in the public');\n  }\n} {}\n\ndo_select_test fts3query-1.2 {\n  SELECT * FROM t1;\n} {{The source code for SQLite is in the public}}\ndo_select_test fts3query-1.3 {\n  SELECT * FROM t1 WHERE t1 MATCH 'sqlite'\n} {{The source code for SQLite is in the public}}\n\ndo_test fts3query-1.4 { execsql {COMMIT} } {}\n\ndo_select_test fts3query-1.5 {\n  SELECT * FROM t1;\n} {{The source code for SQLite is in the public}}\ndo_select_test fts3query-1.6 {\n  SELECT * FROM t1 WHERE t1 MATCH 'sqlite'\n} {{The source code for SQLite is in the public}}\n\n\nset sqlite_fts3_enable_parentheses 1\ndo_test fts3query-2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE zoink USING fts3;\n    INSERT INTO zoink VALUES('The apple falls far from the tree');\n  }\n} {}\ndo_test fts3query-2.2 {\n  execsql {\n    SELECT docid FROM zoink WHERE zoink MATCH '(apple oranges) AND apple'\n  }\n} {}\ndo_test fts3query-2.3 {\n  execsql {\n    SELECT docid FROM zoink WHERE zoink MATCH 'apple AND (oranges apple)'\n  }\n} {}\nset sqlite_fts3_enable_parentheses 0\n\ndo_test fts3query-3.1 {\n  execsql {\n    CREATE VIRTUAL TABLE foobar using FTS3(description, tokenize porter);\n    INSERT INTO foobar (description) values ('\n      Filed under: Emerging Technologies, EV/Plug-in, Hybrid, Chevrolet, GM, \n      ZENN 2011 Chevy Volt - Click above for high-res image gallery There are \n      16 days left in the month of December. Besides being time for most \n      Americans to kick their Christmas shopping sessions into high gear and\n      start planning their resolutions for 2010, it also means that there''s\n      precious little time for EEStor to \"deliver functional technology\" to\n      Zenn Motors as promised. Still, the promises held out by the secretive\n      company are too great for us to forget about entirely. We''d love for\n      EEStor''s claims to be independently verified and proven accurate, as\n      would just about anyone else looking to break free of petroleum in fav\n    '); \n  }\n} {}\n\ndo_test fts3query-3.2 {\n  execsql { SELECT docid FROM foobar WHERE description MATCH '\"high sp d\"' }\n} {}\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\ndo_test fts3query-3.3 {\n  execsql { SELECT mit(matchinfo(foobar)) FROM foobar WHERE foobar MATCH 'the' }\n} {{1 1 3 3 1}}\n\n# The following tests check that ticket 775b39dd3c has been fixed.\n#\ndo_test fts3query-4.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(number INTEGER PRIMARY KEY, date);\n    CREATE INDEX i1 ON t1(date);\n    CREATE VIRTUAL TABLE ft USING fts3(title);\n    CREATE TABLE bt(title);\n  }\n} {}\ndo_eqp_test fts3query-4.2 {\n  SELECT t1.number FROM t1, ft WHERE t1.number=ft.rowid ORDER BY t1.date\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1} \n  0 1 1 {SCAN TABLE ft VIRTUAL TABLE INDEX 1:}\n}\ndo_eqp_test fts3query-4.3 {\n  SELECT t1.number FROM ft, t1 WHERE t1.number=ft.rowid ORDER BY t1.date\n} {\n  0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1} \n  0 1 0 {SCAN TABLE ft VIRTUAL TABLE INDEX 1:}\n}\ndo_eqp_test fts3query-4.4 {\n  SELECT t1.number FROM t1, bt WHERE t1.number=bt.rowid ORDER BY t1.date\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1} \n  0 1 1 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?)}\n}\ndo_eqp_test fts3query-4.5 {\n  SELECT t1.number FROM bt, t1 WHERE t1.number=bt.rowid ORDER BY t1.date\n} {\n  0 0 1 {SCAN TABLE t1 USING COVERING INDEX i1} \n  0 1 0 {SEARCH TABLE bt USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\n\n# Test that calling matchinfo() with the wrong number of arguments, or with\n# an invalid argument returns an error.\n#\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE t2 USING FTS4;\n  INSERT INTO t2 VALUES('it was the first time in history');\n}\ndo_select_tests 5.2 -errorformat {\n  wrong number of arguments to function %s()\n} {\n  1 \"SELECT matchinfo() FROM t2 WHERE t2 MATCH 'history'\"       matchinfo\n  3 \"SELECT snippet(t2, 1, 2, 3, 4, 5, 6) FROM t2 WHERE t2 MATCH 'history'\" \n    snippet\n}\ndo_select_tests 5.3 -errorformat {\n  illegal first argument to %s\n} {\n  1 \"SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'\" matchinfo\n  2 \"SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'\"   offsets\n  3 \"SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'\"   snippet\n  4 \"SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'\"  optimize\n}\ndo_execsql_test 5.4.0 { UPDATE t2_content SET c0content = X'1234' }\ndo_select_tests 5.4 -errorformat {\n  illegal first argument to %s\n} {\n  1 \"SELECT matchinfo(content) FROM t2 WHERE t2 MATCH 'history'\" matchinfo\n  2 \"SELECT offsets(content) FROM t2 WHERE t2 MATCH 'history'\"   offsets\n  3 \"SELECT snippet(content) FROM t2 WHERE t2 MATCH 'history'\"   snippet\n  4 \"SELECT optimize(content) FROM t2 WHERE t2 MATCH 'history'\"  optimize\n}\ndo_catchsql_test 5.5.1 {\n  SELECT matchinfo(t2, 'abcd') FROM t2 WHERE t2 MATCH 'history'\n} {1 {unrecognized matchinfo request: d}}\n\ndo_execsql_test 5.5 { DROP TABLE t2 }\n\n\n# Test the snippet() function with 1 to 6 arguments.\n# \ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE t3 USING FTS4(a, b);\n  INSERT INTO t3 VALUES('no gestures', 'another intriguing discovery by observing the hand gestures (called beats) people make while speaking. Research has shown that such gestures do more than add visual emphasis to our words (many people gesture while they''re on the telephone, for example); it seems they actually help our brains find words');\n}\ndo_select_tests 6.2 {\n  1 \"SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'gestures'\"\n  {{<b>...</b>hand <b>gestures</b> (called beats) people make while speaking. Research has shown that such <b>gestures</b> do<b>...</b>}}\n\n  2 \"SELECT snippet(t3, 'XXX') FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{<b>...</b>hand XXXgestures</b> (called beats) people make while speaking. Research has shown that such XXXgestures</b> do<b>...</b>}}\n\n  3 \"SELECT snippet(t3, 'XXX', 'YYY') FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{<b>...</b>hand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY do<b>...</b>}}\n\n  4 \"SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ') FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}\n\n  5 \"SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1) FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{ZZZhand XXXgesturesYYY (called beats) people make while speaking. Research has shown that such XXXgesturesYYY doZZZ}}\n\n  6 \"SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 0) FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{no XXXgesturesYYY}}\n\n  7 \"SELECT snippet(t3, 'XXX', 'YYY', 'ZZZ', 1, 5) FROM t3 WHERE t3 MATCH 'gestures'\" \n  {{ZZZthe hand XXXgesturesYYY (called beatsZZZ}}\n}\n\n# Test some range queries on the rowid field.\n# \ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE ft4 USING fts4(x);\n  CREATE TABLE t4(x);\n}\n\nset SMALLINT -9223372036854775808\nset LARGEINT  9223372036854775807\ndo_test 7.2 {\n  db transaction {\n    foreach {iFirst nEntry} [subst {\n      0                      100\n      $SMALLINT              100\n      [expr $LARGEINT - 99]  100\n    }] {\n      for {set i 0} {$i < $nEntry} {incr i} {\n        set iRowid [expr $i + $iFirst]\n        execsql {\n          INSERT INTO ft4(rowid, x) VALUES($iRowid, 'x y z');\n          INSERT INTO  t4(rowid, x) VALUES($iRowid, 'x y z');\n        }\n      }\n    }\n  }\n} {}\n\nforeach {tn iFirst iLast} [subst {\n  1   5 10\n  2   $SMALLINT [expr $SMALLINT+5]\n  3   $SMALLINT [expr $SMALLINT+50]\n  4   [expr $LARGEINT-5] $LARGEINT\n  5   $LARGEINT $LARGEINT\n  6   $SMALLINT $LARGEINT\n  7   $SMALLINT $SMALLINT\n  8   $LARGEINT $SMALLINT\n}] {\n  set res [db eval { \n    SELECT rowid FROM t4 WHERE rowid BETWEEN $iFirst AND $iLast \n  } ]\n\n  do_execsql_test 7.2.$tn.1.[llength $res] {\n    SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast\n  } $res\n  set res [db eval { \n    SELECT rowid FROM t4 WHERE rowid BETWEEN $iFirst AND $iLast \n     ORDER BY +rowid DESC\n  } ]\n  do_execsql_test 7.2.$tn.2.[llength $res] {\n    SELECT rowid FROM ft4 WHERE rowid BETWEEN $iFirst AND $iLast\n    ORDER BY rowid DESC\n  } $res\n}\n\nforeach ii [db eval {SELECT rowid FROM t4}] {\n  set res1 [db eval {SELECT rowid FROM t4 WHERE rowid > $ii}]\n  set res2 [db eval {SELECT rowid FROM t4 WHERE rowid < $ii}]\n  set res1s [db eval {SELECT rowid FROM t4 WHERE rowid > $ii ORDER BY +rowid DESC}]\n  set res2s [db eval {SELECT rowid FROM t4 WHERE rowid < $ii ORDER BY +rowid DESC}]\n\n  do_execsql_test 7.3.$ii.1 {\n    SELECT rowid FROM ft4 WHERE rowid > $ii\n  } $res1\n\n  do_execsql_test 7.3.$ii.2 {\n    SELECT rowid FROM ft4 WHERE rowid < $ii\n  } $res2\n\n  do_execsql_test 7.3.$ii.3 {\n    SELECT rowid FROM ft4 WHERE rowid > $ii ORDER BY rowid DESC\n  } $res1s\n\n  do_execsql_test 7.3.$ii.4 {\n    SELECT rowid FROM ft4 WHERE rowid < $ii ORDER BY rowid DESC\n  } $res2s\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3rank.test",
    "content": "# 2017 October 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3expr5\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ninstall_fts3_rank_function db\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3(a, b);\n  INSERT INTO t1 VALUES('one two', 'one');\n  INSERT INTO t1 VALUES('one two', 'three');\n  INSERT INTO t1 VALUES('one two', 'two');\n}\n\ndo_execsql_test 1.1 {\n  SELECT * FROM t1 WHERE t1 MATCH 'one' \n  ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid\n} {\n  {one two} one\n  {one two} three\n  {one two} two\n}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1 WHERE t1 MATCH 'two' \n  ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid\n} {\n  {one two} two\n  {one two} one\n  {one two} three\n}\n\ndo_catchsql_test 1.3 {\n  SELECT * FROM t1 ORDER BY rank(matchinfo(t1), 1.0, 1.0) DESC, rowid\n} {1 {invalid matchinfo blob passed to function rank()}}\n\ndo_catchsql_test 1.4 {\n  SELECT * FROM t1 ORDER BY rank(x'0000000000000000') DESC, rowid\n} {0 {{one two} one {one two} three {one two} two}}\n\ndo_catchsql_test 1.5 {\n  SELECT * FROM t1 ORDER BY rank(x'0100000001000000') DESC, rowid\n} {1 {invalid matchinfo blob passed to function rank()}}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3rnd.test",
    "content": "# 2009 December 03\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Brute force (random data) tests for FTS3.\n#\n\n#-------------------------------------------------------------------------\n#\n# The FTS3 tests implemented in this file focus on testing that FTS3\n# returns the correct set of documents for various types of full-text\n# query. This is done using pseudo-randomly generated data and queries.\n# The expected result of each query is calculated using Tcl code.\n#\n#   1. The database is initialized to contain a single table with three\n#      columns. 100 rows are inserted into the table. Each of the three\n#      values in each row is a document consisting of between 0 and 100\n#      terms. Terms are selected from a vocabulary of $G(nVocab) terms.\n#\n#   2. The following is performed 100 times:\n#\n#      a. A row is inserted into the database. The row contents are \n#         generated as in step 1. The docid is a pseudo-randomly selected\n#         value between 0 and 1000000.\n# \n#      b. A psuedo-randomly selected row is updated. One of its columns is\n#         set to contain a new document generated in the same way as the\n#         documents in step 1.\n# \n#      c. A psuedo-randomly selected row is deleted.\n# \n#      d. For each of several types of fts3 queries, 10 SELECT queries\n#         of the form:\n# \n#           SELECT docid FROM <tbl> WHERE <tbl> MATCH '<query>'\n# \n#         are evaluated. The results are compared to those calculated by\n#         Tcl code in this file. The patterns used for the different query\n#         types are:\n# \n#           1.  query = <term>\n#           2.  query = <prefix>\n#           3.  query = \"<term> <term>\"\n#           4.  query = \"<term> <term> <term>\"\n#           5.  query = \"<prefix> <prefix> <prefix>\"\n#           6.  query = <term> NEAR <term>\n#           7.  query = <term> NEAR/11 <term> NEAR/11 <term>\n#           8.  query = <term> OR <term>\n#           9.  query = <term> NOT <term>\n#           10. query = <term> AND <term>\n#           11. query = <term> NEAR <term> OR <term> NEAR <term>\n#           12. query = <term> NEAR <term> NOT <term> NEAR <term>\n#           13. query = <term> NEAR <term> AND <term> NEAR <term>\n# \n#         where <term> is a term psuedo-randomly selected from the vocabulary\n#         and prefix is the first 2 characters of such a term followed by\n#         a \"*\" character.\n#     \n#      Every second iteration, steps (a) through (d) above are performed\n#      within a single transaction. This forces the queries in (d) to\n#      read data from both the database and the in-memory hash table\n#      that caches the full-text index entries created by steps (a), (b)\n#      and (c) until the transaction is committed.\n#\n# The procedure above is run 5 times, using advisory fts3 node sizes of 50,\n# 500, 1000 and 2000 bytes.\n#\n# After the test using an advisory node-size of 50, an OOM test is run using\n# the database. This test is similar to step (d) above, except that it tests\n# the effects of transient and persistent OOM conditions encountered while\n# executing each query.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build does not include FTS3, skip the tests in this file.\n#\nifcapable !fts3 { finish_test ; return }\nsource $testdir/fts3_common.tcl\nsource $testdir/malloc_common.tcl\n\nset G(nVocab) 100\n\nset nVocab 100\nset lVocab [list]\n\nexpr srand(0)\n\n# Generate a vocabulary of nVocab words. Each word is 3 characters long.\n#\nset lChar {a b c d e f g h i j k l m n o p q r s t u v w x y z}\nfor {set i 0} {$i < $nVocab} {incr i} {\n  set len [expr int(rand()*3)+2]\n  set    word [lindex $lChar [expr int(rand()*26)]]\n  append word [lindex $lChar [expr int(rand()*26)]]\n  if {$len>2} { append word [lindex $lChar [expr int(rand()*26)]] }\n  if {$len>3} { append word [lindex $lChar [expr int(rand()*26)]] }\n  lappend lVocab $word\n}\n\nproc random_term {} {\n  lindex $::lVocab [expr {int(rand()*$::nVocab)}]\n}\n\n# Return a document consisting of $nWord arbitrarily selected terms\n# from the $::lVocab list.\n#\nproc generate_doc {nWord} {\n  set doc [list]\n  for {set i 0} {$i < $nWord} {incr i} {\n    lappend doc [random_term]\n  }\n  return $doc\n}\n\n\n\n# Primitives to update the table.\n#\nunset -nocomplain t1\nproc insert_row {rowid} {\n  set a [generate_doc [expr int((rand()*100))]]\n  set b [generate_doc [expr int((rand()*100))]]\n  set c [generate_doc [expr int((rand()*100))]]\n  execsql { INSERT INTO t1(docid, a, b, c) VALUES($rowid, $a, $b, $c) }\n  set ::t1($rowid) [list $a $b $c]\n}\nproc delete_row {rowid} {\n  execsql { DELETE FROM t1 WHERE rowid = $rowid }\n  catch {unset ::t1($rowid)}\n}\nproc update_row {rowid} {\n  set cols {a b c}\n  set iCol [expr int(rand()*3)]\n  set doc  [generate_doc [expr int((rand()*100))]]\n  lset ::t1($rowid) $iCol $doc\n  execsql \"UPDATE t1 SET [lindex $cols $iCol] = \\$doc WHERE rowid = \\$rowid\"\n}\n\nproc simple_phrase {zPrefix} {\n  set ret [list]\n\n  set reg [string map {* {[^ ]*}} $zPrefix]\n  set reg \" $reg \"\n\n  foreach key [lsort -integer [array names ::t1]] {\n    set value $::t1($key)\n    set cnt [list]\n    foreach col $value {\n      if {[regexp $reg \" $col \"]} { lappend ret $key ; break }\n    }\n  }\n\n  #lsort -uniq -integer $ret\n  set ret\n}\n\n# This [proc] is used to test the FTS3 matchinfo() function.\n# \nproc simple_token_matchinfo {zToken bDesc} {\n\n  set nDoc(0) 0\n  set nDoc(1) 0\n  set nDoc(2) 0\n  set nHit(0) 0\n  set nHit(1) 0\n  set nHit(2) 0\n\n  set dir -inc\n  if {$bDesc} { set dir -dec }\n\n  foreach key [array names ::t1] {\n    set value $::t1($key)\n    set a($key) [list]\n    foreach i {0 1 2} col $value {\n      set hit [llength [lsearch -all $col $zToken]]\n      lappend a($key) $hit\n      incr nHit($i) $hit\n      if {$hit>0} { incr nDoc($i) }\n    }\n  }\n\n  set ret [list]\n  foreach docid [lsort -integer $dir [array names a]] {\n    if { [lindex [lsort -integer $a($docid)] end] } {\n      set matchinfo [list 1 3]\n      foreach i {0 1 2} hit $a($docid) {\n        lappend matchinfo $hit $nHit($i) $nDoc($i)\n      }\n      lappend ret $docid $matchinfo\n    }\n  }\n\n  set ret\n} \n\nproc simple_near {termlist nNear} {\n  set ret [list]\n\n  foreach {key value} [array get ::t1] {\n    foreach v $value {\n\n      set l [lsearch -exact -all $v [lindex $termlist 0]]\n      foreach T [lrange $termlist 1 end] {\n        set l2 [list]\n        foreach i $l {\n          set iStart [expr $i - $nNear - 1]\n          set iEnd [expr $i + $nNear + 1]\n          if {$iStart < 0} {set iStart 0}\n          foreach i2 [lsearch -exact -all [lrange $v $iStart $iEnd] $T] {\n            incr i2 $iStart\n            if {$i2 != $i} { lappend l2 $i2 } \n          }\n        }\n        set l [lsort -uniq -integer $l2]\n      }\n\n      if {[llength $l]} {\n#puts \"MATCH($key): $v\"\n        lappend ret $key\n      } \n    }\n  }\n\n  lsort -unique -integer $ret\n}\n\n# The following three procs:\n# \n#   setup_not A B\n#   setup_or  A B\n#   setup_and A B\n#\n# each take two arguments. Both arguments must be lists of integer values\n# sorted by value. The return value is the list produced by evaluating\n# the equivalent of \"A op B\", where op is the FTS3 operator NOT, OR or\n# AND.\n#\nproc setop_not {A B} {\n  foreach b $B { set n($b) {} }\n  set ret [list]\n  foreach a $A { if {![info exists n($a)]} {lappend ret $a} }\n  return $ret\n}\nproc setop_or {A B} {\n  lsort -integer -uniq [concat $A $B]\n}\nproc setop_and {A B} {\n  foreach b $B { set n($b) {} }\n  set ret [list]\n  foreach a $A { if {[info exists n($a)]} {lappend ret $a} }\n  return $ret\n}\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\nset sqlite_fts3_enable_parentheses 1\n\nproc do_orderbydocid_test {tn sql res} {\n  uplevel [list do_select_test $tn.asc \"$sql ORDER BY docid ASC\" $res]\n  uplevel [list do_select_test $tn.desc \"$sql ORDER BY docid DESC\" \\\n    [lsort -int -dec $res]\n  ]\n}\n\nset NUM_TRIALS 100\n\nforeach {nodesize order} {\n  50    DESC\n  50    ASC\n  500   ASC\n  1000  DESC\n  2000  ASC\n} {\n  catch { array unset ::t1 }\n  set testname \"$nodesize/$order\"\n\n  # Create the FTS3 table. Populate it (and the Tcl array) with 100 rows.\n  #\n  db transaction {\n    catchsql { DROP TABLE t1 }\n    execsql \"CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, order=$order)\"\n    execsql \"INSERT INTO t1(t1) VALUES('nodesize=$nodesize')\"\n    for {set i 0} {$i < 100} {incr i} { insert_row $i }\n  }\n  \n  for {set iTest 1} {$iTest <= $NUM_TRIALS} {incr iTest} {\n    catchsql COMMIT\n\n    set DO_MALLOC_TEST 0\n    set nRep 10\n    if {$iTest==100 && $nodesize==50} { \n      set DO_MALLOC_TEST 1 \n      set nRep 2\n    }\n\n    set ::testprefix fts3rnd-1.$testname.$iTest\n  \n    # Delete one row, update one row and insert one row.\n    #\n    set rows [array names ::t1]\n    set nRow [llength $rows]\n    set iUpdate [lindex $rows [expr {int(rand()*$nRow)}]]\n    set iDelete $iUpdate\n    while {$iDelete == $iUpdate} {\n      set iDelete [lindex $rows [expr {int(rand()*$nRow)}]]\n    }\n    set iInsert $iUpdate\n    while {[info exists ::t1($iInsert)]} {\n      set iInsert [expr {int(rand()*1000000)}]\n    }\n    execsql BEGIN\n      insert_row $iInsert\n      update_row $iUpdate\n      delete_row $iDelete\n    if {0==($iTest%2)} { execsql COMMIT }\n\n    if {0==($iTest%2)} { \n      #do_test 0 { fts3_integrity_check t1 } ok \n    }\n\n    # Pick 10 terms from the vocabulary. Check that the results of querying\n    # the database for the set of documents containing each of these terms\n    # is the same as the result obtained by scanning the contents of the Tcl \n    # array for each term.\n    #\n    for {set i 0} {$i < 10} {incr i} {\n      set term [random_term]\n      do_select_test 1.$i.asc {\n        SELECT docid, mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH $term\n        ORDER BY docid ASC\n      } [simple_token_matchinfo $term 0]\n      do_select_test 1.$i.desc {\n        SELECT docid, mit(matchinfo(t1)) FROM t1 WHERE t1 MATCH $term\n        ORDER BY docid DESC\n      } [simple_token_matchinfo $term 1]\n    }\n\n    # This time, use the first two characters of each term as a term prefix\n    # to query for. Test that querying the Tcl array produces the same results\n    # as querying the FTS3 table for the prefix.\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set prefix [string range [random_term] 0 end-1]\n      set match \"${prefix}*\"\n      do_orderbydocid_test 2.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match\n      } [simple_phrase $match]\n    }\n\n    # Similar to the above, except for phrase queries.\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set term [list [random_term] [random_term]]\n      set match \"\\\"$term\\\"\"\n      do_orderbydocid_test 3.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match\n      } [simple_phrase $term]\n    }\n\n    # Three word phrases.\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set term [list [random_term] [random_term] [random_term]]\n      set match \"\\\"$term\\\"\"\n      do_orderbydocid_test 4.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match\n      } [simple_phrase $term]\n    }\n\n    # Three word phrases made up of term-prefixes.\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set    query \"[string range [random_term] 0 end-1]* \"\n      append query \"[string range [random_term] 0 end-1]* \"\n      append query \"[string range [random_term] 0 end-1]*\"\n\n      set match \"\\\"$query\\\"\"\n      do_orderbydocid_test 5.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match\n      } [simple_phrase $query]\n    }\n\n    # A NEAR query with terms as the arguments:\n    #\n    #     ... MATCH '$term1 NEAR $term2' ...\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set terms [list [random_term] [random_term]]\n      set match [join $terms \" NEAR \"]\n      do_orderbydocid_test 6.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match \n      } [simple_near $terms 10]\n    }\n\n    # A 3-way NEAR query with terms as the arguments.\n    #\n    for {set i 0} {$i < $nRep} {incr i} {\n      set terms [list [random_term] [random_term] [random_term]]\n      set nNear 11\n      set match [join $terms \" NEAR/$nNear \"]\n      do_orderbydocid_test 7.$i {\n        SELECT docid FROM t1 WHERE t1 MATCH $match\n      } [simple_near $terms $nNear]\n    }\n    \n    # Set operations on simple term queries.\n    #\n    foreach {tn op proc} {\n      8  OR  setop_or\n      9  NOT setop_not\n      10 AND setop_and\n    } {\n      for {set i 0} {$i < $nRep} {incr i} {\n        set term1 [random_term]\n        set term2 [random_term]\n        set match \"$term1 $op $term2\"\n        do_orderbydocid_test $tn.$i {\n          SELECT docid FROM t1 WHERE t1 MATCH $match\n        } [$proc [simple_phrase $term1] [simple_phrase $term2]]\n      }\n    }\n \n    # Set operations on NEAR queries.\n    #\n    foreach {tn op proc} {\n      11 OR  setop_or\n      12 NOT setop_not\n      13 AND setop_and\n    } {\n      for {set i 0} {$i < $nRep} {incr i} {\n        set term1 [random_term]\n        set term2 [random_term]\n        set term3 [random_term]\n        set term4 [random_term]\n        set match \"$term1 NEAR $term2 $op $term3 NEAR $term4\"\n        do_orderbydocid_test $tn.$i {\n          SELECT docid FROM t1 WHERE t1 MATCH $match\n        } [$proc                                  \\\n            [simple_near [list $term1 $term2] 10] \\\n            [simple_near [list $term3 $term4] 10]\n          ]\n      }\n    }\n\n    catchsql COMMIT\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3shared.test",
    "content": "#\n# 2010 September 17\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the interactions between the FTS3/4 module \n# and shared-cache mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !fts3||!shared_cache {\n  finish_test\n  return\n}\nset ::testprefix fts3shared\n\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Open two connections to the database in shared-cache mode.\n#\nsqlite3 db test.db\nsqlite3 db2 test.db\n\n# Create a virtual FTS3 table. Populate it with some initial data.\n#\ndo_execsql_test fts3shared-1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts3(x);\n  BEGIN;\n  INSERT INTO t1 VALUES('We listened and looked sideways up!');\n  INSERT INTO t1 VALUES('Fear at my heart, as at a cup,');\n  INSERT INTO t1 VALUES('My life-blood seemed to sip!');\n  INSERT INTO t1 VALUES('The stars were dim, and thick the night');\n  COMMIT;\n} {}\n\n# Open a write transaction and insert rows into the FTS3 table. This takes\n# a write-lock on the underlying t1_content table.\n#\ndo_execsql_test fts3shared-1.2 {\n  BEGIN;\n    INSERT INTO t1 VALUES('The steersman''s face by his lamp gleamed white;');\n} {}\n\n# Now try a SELECT on the full-text table. This particular SELECT does not\n# read data from the %_content table. But it still attempts to obtain a lock\n# on that table and so the SELECT fails.\n#\ndo_test fts3shared-1.3 {\n  catchsql {  \n    BEGIN;\n      SELECT rowid FROM t1 WHERE t1 MATCH 'stars' \n  } db2\n} {1 {database table is locked}}\n\n# Verify that the first connection can commit its transaction.\n#\ndo_test fts3shared-1.4 { sqlite3_get_autocommit db } 0\ndo_execsql_test fts3shared-1.5 { COMMIT } {}\ndo_test fts3shared-1.6 { sqlite3_get_autocommit db } 1\n\n# Verify that the second connection still has an open transaction.\n#\ndo_test fts3shared-1.6 { sqlite3_get_autocommit db2 } 0\n\ndb close\ndb2 close\n\n#-------------------------------------------------------------------------\n# The following tests - fts3shared-2.* - test that unless FTS is bypassed\n# and the underlying tables accessed directly, it is not possible for an\n# SQLITE_LOCKED error to be enountered when committing an FTS transaction.\n#\n# Any SQLITE_LOCKED error should be returned when the fts4 (or fts4aux)\n# table is first read/written within a transaction, not later on.\n#\nset LOCKED {1 {database table is locked}}\nforcedelete test.db\nsqlite3 dbR test.db\nsqlite3 dbW test.db\ndo_test 2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts4;\n    CREATE TABLE t2ext(a, b);\n    CREATE VIRTUAL TABLE t2 USING fts4(content=t2ext);\n    CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);\n    CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);\n\n    INSERT INTO t1   VALUES('a b c');\n    INSERT INTO t2(rowid, a, b) VALUES(1, 'd e f', 'g h i');\n  } dbW\n} {}\n\n# Test that once [dbW] has written to the FTS table, no client may read\n# from the FTS or fts4aux table.\ndo_test 2.2.1 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES('j k l');\n  } dbW\n  execsql BEGIN dbR\n} {}\ndo_test 2.2.2 { catchsql \"SELECT * FROM t1 WHERE rowid=1\"          dbR } $LOCKED\ndo_test 2.2.3 { catchsql \"SELECT * FROM t1 WHERE t1 MATCH 'a'\"     dbR } $LOCKED\ndo_test 2.2.4 { catchsql \"SELECT rowid FROM t1 WHERE t1 MATCH 'a'\" dbR } $LOCKED\ndo_test 2.2.5 { catchsql \"SELECT * FROM t1\"                        dbR } $LOCKED\ndo_test 2.2.6 { catchsql \"SELECT * FROM t1aux\"                     dbR } $LOCKED\ndo_test 2.2.7 { execsql COMMIT dbW } {}\ndo_test 2.2.8 { execsql COMMIT dbR } {}\n\n# Same test as 2.2.*, except with a content= table.\n#\ndo_test 2.3.1 {\n  execsql {\n    BEGIN;\n      INSERT INTO t2(rowid, a, b) VALUES(2, 'j k l', 'm n o');\n  } dbW\n  execsql BEGIN dbR\n} {}\ndo_test 2.3.3 { catchsql \"SELECT * FROM t2 WHERE t2 MATCH 'a'\"     dbR } $LOCKED\ndo_test 2.3.4 { catchsql \"SELECT rowid FROM t2 WHERE t2 MATCH 'a'\" dbR } $LOCKED\ndo_test 2.3.6 { catchsql \"SELECT * FROM t2aux\"                     dbR } $LOCKED\ndo_test 2.3.7 { execsql COMMIT dbW } {}\ndo_test 2.3.8 { execsql COMMIT dbR } {}\n\n# Test that once a connection has read from the FTS or fts4aux table, \n# another connection may not write to the FTS table.\n#\nforeach {tn sql} {\n  1 \"SELECT * FROM t1 WHERE rowid=1\"\n  2 \"SELECT * FROM t1 WHERE t1 MATCH 'a'\" \n  3 \"SELECT rowid FROM t1 WHERE t1 MATCH 'a'\"\n  4 \"SELECT * FROM t1\"\n  5 \"SELECT * FROM t1aux\"\n} {\n\n  do_test 2.4.$tn {\n    execsql BEGIN dbR\n    execsql $::sql dbR\n    execsql BEGIN dbW\n    catchsql \"INSERT INTO t1 VALUES('p q r')\" dbW\n  } $LOCKED\n\n  execsql ROLLBACK dbR \n  execsql ROLLBACK dbW \n}\n\n# Same test as 2.4.*, except with a content= table.\n#\nforeach {tn sql} {\n  2 \"SELECT * FROM t2 WHERE t2 MATCH 'a'\" \n  3 \"SELECT rowid FROM t2 WHERE t2 MATCH 'a'\"\n  5 \"SELECT * FROM t2aux\"\n} {\n\n  do_test 2.5.$tn {\n    execsql BEGIN dbR\n    execsql $::sql dbR\n    execsql BEGIN dbW\n    catchsql \"INSERT INTO t2(rowid, a, b) VALUES(3, 's t u', 'v w x')\" dbW\n  } $LOCKED\n\n  execsql ROLLBACK dbR \n  execsql ROLLBACK dbW \n}\n\ndbW close\ndbR close\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3snippet.test",
    "content": "# 2010 January 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# The tests in this file test the FTS3 auxillary functions offsets(), \n# snippet() and matchinfo() work. At time of writing, running this file \n# provides full coverage of fts3_snippet.c.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3snippet\n\n# If SQLITE_ENABLE_FTS3 is not defined, omit this file.\nifcapable !fts3 { finish_test ; return }\nsource $testdir/fts3_common.tcl\n\nset sqlite_fts3_enable_parentheses 1\nset DO_MALLOC_TEST 0\n\n# Transform the list $L to its \"normal\" form. So that it can be compared to\n# another list with the same set of elements using [string compare].\n#\nproc normalize {L} {\n  set ret [list]\n  foreach l $L {lappend ret $l}\n  return $ret\n}\n\nproc do_offsets_test {name expr args} {\n  set result [list]\n  foreach a $args {\n    lappend result [normalize $a]\n  }\n  do_select_test $name {\n    SELECT offsets(ft) FROM ft WHERE ft MATCH $expr\n  } $result\n}\n  \n# Document text used by a few tests. Contains the English names of all\n# integers between 1 and 300.\n#\nset numbers [normalize {\n  one two three four five six seven eight nine ten eleven twelve thirteen\n  fourteen fifteen sixteen seventeen eighteen nineteen twenty twentyone\n  twentytwo twentythree twentyfour twentyfive twentysix twentyseven\n  twentyeight twentynine thirty thirtyone thirtytwo thirtythree thirtyfour\n  thirtyfive thirtysix thirtyseven thirtyeight thirtynine forty fortyone\n  fortytwo fortythree fortyfour fortyfive fortysix fortyseven fortyeight\n  fortynine fifty fiftyone fiftytwo fiftythree fiftyfour fiftyfive fiftysix\n  fiftyseven fiftyeight fiftynine sixty sixtyone sixtytwo sixtythree sixtyfour\n  sixtyfive sixtysix sixtyseven sixtyeight sixtynine seventy seventyone\n  seventytwo seventythree seventyfour seventyfive seventysix seventyseven\n  seventyeight seventynine eighty eightyone eightytwo eightythree eightyfour\n  eightyfive eightysix eightyseven eightyeight eightynine ninety ninetyone\n  ninetytwo ninetythree ninetyfour ninetyfive ninetysix ninetyseven\n  ninetyeight ninetynine onehundred onehundredone onehundredtwo\n  onehundredthree onehundredfour onehundredfive onehundredsix onehundredseven\n  onehundredeight onehundrednine onehundredten onehundredeleven\n  onehundredtwelve onehundredthirteen onehundredfourteen onehundredfifteen\n  onehundredsixteen onehundredseventeen onehundredeighteen onehundrednineteen\n  onehundredtwenty onehundredtwentyone onehundredtwentytwo\n  onehundredtwentythree onehundredtwentyfour onehundredtwentyfive\n  onehundredtwentysix onehundredtwentyseven onehundredtwentyeight\n  onehundredtwentynine onehundredthirty onehundredthirtyone\n  onehundredthirtytwo onehundredthirtythree onehundredthirtyfour\n  onehundredthirtyfive onehundredthirtysix onehundredthirtyseven\n  onehundredthirtyeight onehundredthirtynine onehundredforty\n  onehundredfortyone onehundredfortytwo onehundredfortythree\n  onehundredfortyfour onehundredfortyfive onehundredfortysix\n  onehundredfortyseven onehundredfortyeight onehundredfortynine\n  onehundredfifty onehundredfiftyone onehundredfiftytwo onehundredfiftythree\n  onehundredfiftyfour onehundredfiftyfive onehundredfiftysix\n  onehundredfiftyseven onehundredfiftyeight onehundredfiftynine\n  onehundredsixty onehundredsixtyone onehundredsixtytwo onehundredsixtythree\n  onehundredsixtyfour onehundredsixtyfive onehundredsixtysix\n  onehundredsixtyseven onehundredsixtyeight onehundredsixtynine\n  onehundredseventy onehundredseventyone onehundredseventytwo\n  onehundredseventythree onehundredseventyfour onehundredseventyfive\n  onehundredseventysix onehundredseventyseven onehundredseventyeight\n  onehundredseventynine onehundredeighty onehundredeightyone\n  onehundredeightytwo onehundredeightythree onehundredeightyfour\n  onehundredeightyfive onehundredeightysix onehundredeightyseven\n  onehundredeightyeight onehundredeightynine onehundredninety\n  onehundredninetyone onehundredninetytwo onehundredninetythree\n  onehundredninetyfour onehundredninetyfive onehundredninetysix\n  onehundredninetyseven onehundredninetyeight onehundredninetynine twohundred\n  twohundredone twohundredtwo twohundredthree twohundredfour twohundredfive\n  twohundredsix twohundredseven twohundredeight twohundrednine twohundredten\n  twohundredeleven twohundredtwelve twohundredthirteen twohundredfourteen\n  twohundredfifteen twohundredsixteen twohundredseventeen twohundredeighteen\n  twohundrednineteen twohundredtwenty twohundredtwentyone twohundredtwentytwo\n  twohundredtwentythree twohundredtwentyfour twohundredtwentyfive\n  twohundredtwentysix twohundredtwentyseven twohundredtwentyeight\n  twohundredtwentynine twohundredthirty twohundredthirtyone\n  twohundredthirtytwo twohundredthirtythree twohundredthirtyfour\n  twohundredthirtyfive twohundredthirtysix twohundredthirtyseven\n  twohundredthirtyeight twohundredthirtynine twohundredforty\n  twohundredfortyone twohundredfortytwo twohundredfortythree\n  twohundredfortyfour twohundredfortyfive twohundredfortysix\n  twohundredfortyseven twohundredfortyeight twohundredfortynine\n  twohundredfifty twohundredfiftyone twohundredfiftytwo twohundredfiftythree\n  twohundredfiftyfour twohundredfiftyfive twohundredfiftysix\n  twohundredfiftyseven twohundredfiftyeight twohundredfiftynine\n  twohundredsixty twohundredsixtyone twohundredsixtytwo twohundredsixtythree\n  twohundredsixtyfour twohundredsixtyfive twohundredsixtysix\n  twohundredsixtyseven twohundredsixtyeight twohundredsixtynine\n  twohundredseventy twohundredseventyone twohundredseventytwo\n  twohundredseventythree twohundredseventyfour twohundredseventyfive\n  twohundredseventysix twohundredseventyseven twohundredseventyeight\n  twohundredseventynine twohundredeighty twohundredeightyone\n  twohundredeightytwo twohundredeightythree twohundredeightyfour\n  twohundredeightyfive twohundredeightysix twohundredeightyseven\n  twohundredeightyeight twohundredeightynine twohundredninety\n  twohundredninetyone twohundredninetytwo twohundredninetythree\n  twohundredninetyfour twohundredninetyfive twohundredninetysix\n  twohundredninetyseven twohundredninetyeight twohundredninetynine\n  threehundred\n}]\n\nforeach {DO_MALLOC_TEST enc} {\n  0 utf8\n  1 utf8\n  1 utf16\n} {\n\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n  db eval \"PRAGMA encoding = \\\"$enc\\\"\"\n\n  # Set variable $T to the test name prefix for this iteration of the loop.\n  #\n  set T \"fts3snippet-1.$enc\"\n\n  ##########################################################################\n  # Test the offset function.\n  #\n  do_test $T.1.1 {\n    execsql {\n      CREATE VIRTUAL TABLE ft USING fts3;\n      INSERT INTO ft VALUES('xxx xxx xxx xxx');\n    }\n  } {}\n  do_offsets_test $T.1.2 {xxx} {0 0 0 3 0 0 4 3 0 0 8 3 0 0 12 3}\n  do_offsets_test $T.1.3 {\"xxx xxx\"} {\n      0 0  0 3     0 0  4 3     0 1  4 3     0 0  8 3 \n      0 1  8 3     0 1 12 3\n  }\n  do_offsets_test $T.1.4 {\"xxx xxx\" xxx} {\n      0 0  0 3     0 2  0 3     0 0  4 3     0 1  4 3 \n      0 2  4 3     0 0  8 3     0 1  8 3     0 2  8 3 \n      0 1 12 3     0 2 12 3\n  }\n  do_offsets_test $T.1.5 {xxx \"xxx xxx\"} {\n      0 0  0 3     0 1  0 3     0 0  4 3     0 1  4 3 \n      0 2  4 3     0 0  8 3     0 1  8 3     0 2  8 3 \n      0 0 12 3     0 2 12 3\n  }\n\n  do_test $T.2.1 {\n    set v1 [lrange $numbers 0 99]\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3(a, b);\n      INSERT INTO ft VALUES($v1, $numbers);\n      INSERT INTO ft VALUES($v1, NULL);\n    }\n  } {}\n\n  set off [string first \"twohundred \" $numbers]\n  do_offsets_test $T.2.1 {twohundred} [list 1 0 $off 10]\n\n  set off [string first \"onehundred \" $numbers]\n  do_offsets_test $T.2.2 {onehundred} \\\n    [list 0 0 $off 10 1 0 $off 10] [list 0 0 $off 10]\n\n  # Test a corruption case:\n  execsql { UPDATE ft_content SET c1b = 'hello world' WHERE c1b = $numbers }\n  do_error_test $T.2.3 {\n    SELECT offsets(ft) FROM ft WHERE ft MATCH 'onehundred'\n  } {database disk image is malformed}\n  \n  ##########################################################################\n  # Test the snippet function.\n  #\n  proc do_snippet_test {name expr iCol nTok args} {\n    set res [list]\n    foreach a $args { lappend res [string trim $a] }\n    do_select_test $name {\n      SELECT snippet(ft,'{','}','...',$iCol,$nTok) FROM ft WHERE ft MATCH $expr\n    } $res\n  }\n  do_test $T.3.1 {\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3;\n      INSERT INTO ft VALUES('one two three four five six seven eight nine ten');\n    }\n  } {}\n  do_snippet_test $T.3.2  one    0 5 \"{one} two three four five...\"\n  do_snippet_test $T.3.3  two    0 5 \"one {two} three four five...\"\n  do_snippet_test $T.3.4  three  0 5 \"one two {three} four five...\"\n  do_snippet_test $T.3.5  four   0 5 \"...two three {four} five six...\"\n  do_snippet_test $T.3.6  five   0 5 \"...three four {five} six seven...\"\n  do_snippet_test $T.3.7  six    0 5 \"...four five {six} seven eight...\"\n  do_snippet_test $T.3.8  seven  0 5 \"...five six {seven} eight nine...\"\n  do_snippet_test $T.3.9  eight  0 5 \"...six seven {eight} nine ten\"\n  do_snippet_test $T.3.10 nine   0 5 \"...six seven eight {nine} ten\"\n  do_snippet_test $T.3.11 ten    0 5 \"...six seven eight nine {ten}\"\n  \n  do_test $T.4.1 {\n    execsql {\n      INSERT INTO ft VALUES(\n           'one two three four five '\n        || 'six seven eight nine ten '\n        || 'eleven twelve thirteen fourteen fifteen '\n        || 'sixteen seventeen eighteen nineteen twenty '\n        || 'one two three four five '\n        || 'six seven eight nine ten '\n        || 'eleven twelve thirteen fourteen fifteen '\n        || 'sixteen seventeen eighteen nineteen twenty'\n      );\n    }\n  } {}\n  \n  do_snippet_test $T.4.2 {one nine} 0 5 {\n     {one} two three...eight {nine} ten\n  } {\n     {one} two three...eight {nine} ten...\n  }\n  \n  do_snippet_test $T.4.3 {one nine} 0 -5 {\n     {one} two three four five...six seven eight {nine} ten\n  } {\n     {one} two three four five...seven eight {nine} ten eleven...\n  }\n  do_snippet_test $T.4.3 {one nineteen} 0 -5 {\n     ...eighteen {nineteen} twenty {one} two...\n  }\n  do_snippet_test $T.4.4 {two nineteen} 0 -5 {\n     ...eighteen {nineteen} twenty one {two}...\n  }\n  do_snippet_test $T.4.5 {three nineteen} 0 -5 {\n     ...{nineteen} twenty one two {three}...\n  }\n  \n  do_snippet_test $T.4.6 {four nineteen} 0 -5 {\n     ...two three {four} five six...seventeen eighteen {nineteen} twenty one...\n  }\n  do_snippet_test $T.4.7 {four NEAR nineteen} 0 -5 {\n     ...seventeen eighteen {nineteen} twenty one...two three {four} five six...\n  }\n  \n  do_snippet_test $T.4.8 {four nineteen} 0 5 {\n     ...three {four} five...eighteen {nineteen} twenty...\n  }\n  do_snippet_test $T.4.9 {four NEAR nineteen} 0 5 {\n     ...eighteen {nineteen} twenty...three {four} five...\n  }\n  do_snippet_test $T.4.10 {four NEAR nineteen} 0 -5 {\n     ...seventeen eighteen {nineteen} twenty one...two three {four} five six...\n  }\n  do_snippet_test $T.4.11 {four NOT (nineteen twentyone)} 0 5 {\n     ...two three {four} five six...\n  } {\n     ...two three {four} five six...\n  }\n  do_snippet_test $T.4.12 {four OR nineteen NEAR twentyone} 0 5 {\n     ...two three {four} five six...\n  } {\n     ...two three {four} five six...\n  }\n  \n  do_test $T.5.1 {\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3(a, b, c);\n      INSERT INTO ft VALUES(\n        'one two three four five', \n        'four five six seven eight', \n        'seven eight nine ten eleven'\n      );\n    }\n  } {}\n  \n  do_snippet_test $T.5.2 {five} -1 3 {...three four {five}}\n  do_snippet_test $T.5.3 {five}  0 3 {...three four {five}}\n  do_snippet_test $T.5.4 {five}  1 3 {four {five} six...}\n  do_snippet_test $T.5.5 {five}  2 3 {seven eight nine...}\n  \n  do_test $T.5.6 {\n    execsql { UPDATE ft SET b = NULL }\n  } {}\n  \n  do_snippet_test $T.5.7  {five} -1 3 {...three four {five}}\n  do_snippet_test $T.5.8  {five}  0 3 {...three four {five}}\n  do_snippet_test $T.5.9  {five}  1 3 {}\n  do_snippet_test $T.5.10 {five}  2 3 {seven eight nine...}\n  \n  do_snippet_test $T.5.11 {one \"seven eight nine\"} -1 -3 {\n    {one} two three...{seven} {eight} {nine}...\n  }\n\n  do_test $T.6.1 {\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3(x);\n      INSERT INTO ft VALUES($numbers);\n    }\n  } {}\n  do_snippet_test $T.6.2 {\n    one fifty onehundred onehundredfifty twohundredfifty threehundred\n  } -1 4 {\n    {one}...{fifty}...{onehundred}...{onehundredfifty}...\n  }\n  do_snippet_test $T.6.3 {\n    one fifty onehundred onehundredfifty twohundredfifty threehundred\n  } -1 -4 {\n    {one} two three four...fortyeight fortynine {fifty} fiftyone...ninetyeight ninetynine {onehundred} onehundredone...onehundredfortyeight onehundredfortynine {onehundredfifty} onehundredfiftyone...\n  }\n\n  do_test $T.7.1 {\n    execsql {\n      BEGIN;\n        DROP TABLE IF EXISTS ft;\n        CREATE VIRTUAL TABLE ft USING fts3(x);\n    }\n    set testresults [list]\n    for {set i 1} {$i < 150} {incr i} {\n      set commas [string repeat , $i]\n      execsql {INSERT INTO ft VALUES('one' || $commas || 'two')}\n      lappend testresults \"{one}$commas{two}\"\n    }\n    execsql COMMIT\n  } {}\n  eval [list do_snippet_test $T.7.2 {one two} -1 3] $testresults\n  \n  ##########################################################################\n  # Test the matchinfo function.\n  #\n  proc mit {blob} {\n    set scan(littleEndian) i*\n    set scan(bigEndian) I*\n    binary scan $blob $scan($::tcl_platform(byteOrder)) r\n    return $r\n  }\n  db func mit mit\n  proc do_matchinfo_test {name expr args} {\n    set res [list]\n    foreach a $args { lappend res [normalize $a] }\n    do_select_test $name {\n      SELECT mit(matchinfo(ft)) FROM ft WHERE ft MATCH $expr\n    } $res\n  }\n  do_test $T.8.1 {\n    set ten {one two three four five six seven eight nine ten}\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3;\n      INSERT INTO ft VALUES($ten);\n      INSERT INTO ft VALUES($ten || ' ' || $ten);\n    }\n  } {}\n  \n  do_matchinfo_test $T.8.2 \"one\" {1 1  1 3 2} {1 1  2 3 2}\n  do_matchinfo_test $T.8.3 \"one NEAR/3 ten\" {2 1  1 1 1 1 1 1}\n  do_matchinfo_test $T.8.4 \"five NEAR/4 ten\" \\\n    {2 1  1 3 2  1 3 2} {2 1  2 3 2  2 3 2}\n  do_matchinfo_test $T.8.5 \"six NEAR/3 ten NEAR/3 two\" \\\n    {3 1  1 1 1  1 1 1  1 1 1}\n  do_matchinfo_test $T.8.6 \"five NEAR/4 ten NEAR/3 two\" \\\n    {3 1  2 2 1  1 1 1  1 1 1}\n\n  do_test $T.9.1 {\n    execsql {\n      DROP TABLE IF EXISTS ft;\n      CREATE VIRTUAL TABLE ft USING fts3(x, y);\n    }\n    foreach n {1 2 3} {\n      set v1 [lrange $numbers 0 [expr $n*100]]\n      set v2 [string trim [string repeat \"$numbers \" $n]]\n      set docid [expr $n * 1000000]\n      execsql { INSERT INTO ft(docid, x, y) VALUES($docid, $v1, $v2) }\n    }\n  } {}\n  do_matchinfo_test $T.9.2 {two*}     \\\n    { 1 2    1   105 3   101 606 3}   \\\n    { 1 2    3   105 3   202 606 3}   \\\n    { 1 2    101 105 3   303 606 3}\n\n  do_matchinfo_test $T.9.4 {\"one* two*\"}  \\\n    { 1 2    1 5 3   2 12 3}              \\\n    { 1 2    2 5 3   4 12 3}              \\\n    { 1 2    2 5 3   6 12 3}\n\n  do_matchinfo_test $T.9.5 {twohundredfifty}  \\\n    { 1 2    0 1 1   1 6 3}                   \\\n    { 1 2    0 1 1   2 6 3}                   \\\n    { 1 2    1 1 1   3 6 3}\n\n  do_matchinfo_test $T.9.6 {\"threehundred one\"} \\\n    { 1 2    0 0 0   1 3 2}                     \\\n    { 1 2    0 0 0   2 3 2}\n\n  do_matchinfo_test $T.9.7 {one OR fivehundred} \\\n    { 2 2    1 3 3   1 6 3   0 0 0   0 0 0 }    \\\n    { 2 2    1 3 3   2 6 3   0 0 0   0 0 0 }    \\\n    { 2 2    1 3 3   3 6 3   0 0 0   0 0 0 }\n\n  do_matchinfo_test $T.9.8 {two OR \"threehundred one\"} \\\n    { 2 2    1 3 3   1 6 3   0 0 0   0 3 2 }           \\\n    { 2 2    1 3 3   2 6 3   0 0 0   1 3 2 }           \\\n    { 2 2    1 3 3   3 6 3   0 0 0   2 3 2 }\n\n  do_select_test $T.9.9 {\n    SELECT mit(matchinfo(ft)), mit(matchinfo(ft))\n    FROM ft WHERE ft MATCH 'two OR \"threehundred one\"' \n  } [normalize {\n    {2 2 1 3 3 1 6 3 0 0 0 0 3 2}\n    {2 2 1 3 3 1 6 3 0 0 0 0 3 2}\n    {2 2 1 3 3 2 6 3 0 0 0 1 3 2}\n    {2 2 1 3 3 2 6 3 0 0 0 1 3 2}\n    {2 2 1 3 3 3 6 3 0 0 0 2 3 2}          \n    {2 2 1 3 3 3 6 3 0 0 0 2 3 2}\n  }]\n\n  # EVIDENCE-OF: R-40630-02268 If used within a SELECT that uses the\n  # \"query by rowid\" or \"linear scan\" strategies, then the snippet and\n  # offsets both return an empty string, and the matchinfo function\n  # returns a blob value zero bytes in size.\n  #\n  set r 1000000                   ;# A rowid that exists in table ft\n  do_select_test $T.10.0 { SELECT rowid FROM ft WHERE rowid = $r } $r\n  do_select_test $T.10.1 {\n    SELECT length(offsets(ft)), typeof(offsets(ft)) FROM ft;\n  } {0 text 0 text 0 text}\n  do_select_test $T.10.2 {\n    SELECT length(offsets(ft)), typeof(offsets(ft)) FROM ft WHERE rowid = $r\n  } {0 text}\n  do_select_test $T.10.3 {\n    SELECT length(snippet(ft)), typeof(snippet(ft)) FROM ft;\n  } {0 text 0 text 0 text}\n  do_select_test $T.10.4 {\n    SELECT length(snippet(ft)), typeof(snippet(ft)) FROM ft WHERE rowid = $r;\n  } {0 text}\n  do_select_test $T.10.5 {\n    SELECT length(matchinfo(ft)), typeof(matchinfo(ft)) FROM ft;\n  } {0 blob 0 blob 0 blob}\n  do_select_test $T.10.6 {\n    SELECT length(matchinfo(ft)), typeof(matchinfo(ft)) FROM ft WHERE rowid = $r\n  } {0 blob}\n}\n\n#-------------------------------------------------------------------------\n# Test an interaction between the snippet() function and OR clauses.\n#\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4;\n  INSERT INTO t2 VALUES('one two three four five');\n  INSERT INTO t2 VALUES('two three four five one');\n  INSERT INTO t2 VALUES('three four five one two');\n  INSERT INTO t2 VALUES('four five one two three');\n  INSERT INTO t2 VALUES('five one two three four');\n}\n\ndo_execsql_test 2.2 {\n  SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)'\n} {\n  {[one] two three [four] five}\n  {two three [four] five [one]}\n  {three [four] five [one] two}\n  {[four] five [one] two three}\n  {five [one] two three [four]}\n}\n\ndo_execsql_test 2.3 {\n  SELECT snippet(t2, '[', ']') FROM t2 \n  WHERE t2 MATCH 'one OR (four AND six)' \n  ORDER BY docid DESC\n} {\n  {five [one] two three [four]}\n  {[four] five [one] two three}\n  {three [four] five [one] two}\n  {two three [four] five [one]}\n  {[one] two three [four] five}\n}\n\ndo_execsql_test 2.4 {\n  INSERT INTO t2 VALUES('six');\n}\n\ndo_execsql_test 2.5 {\n  SELECT snippet(t2, '[', ']') FROM t2 WHERE t2 MATCH 'one OR (four AND six)'\n} {\n  {[one] two three [four] five}\n  {two three [four] five [one]}\n  {three [four] five [one] two}\n  {[four] five [one] two three}\n  {five [one] two three [four]}\n}\n\ndo_execsql_test 2.6 {\n  SELECT snippet(t2, '[', ']') FROM t2 \n  WHERE t2 MATCH 'one OR (four AND six)' \n  ORDER BY docid DESC\n} {\n  {five [one] two three [four]}\n  {[four] five [one] two three}\n  {three [four] five [one] two}\n  {two three [four] five [one]}\n  {[one] two three [four] five}\n}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 3 {\n  CREATE VIRTUAL TABLE t3 USING fts4;\n  INSERT INTO t3 VALUES('[one two three]');\n}\ndo_execsql_test 3.1 {\n  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one';\n} {{[<b>one</b> two three]}}\ndo_execsql_test 3.2 {\n  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'two';\n} {{[one <b>two</b> three]}}\ndo_execsql_test 3.3 {\n  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'three';\n} {{[one two <b>three</b>]}}\ndo_execsql_test 3.4 {\n  SELECT snippet(t3) FROM t3 WHERE t3 MATCH 'one OR two OR three';\n} {{[<b>one</b> <b>two</b> <b>three</b>]}}\n\n#-------------------------------------------------------------------------\n# Request a snippet 0 tokens in size. This is always an empty string.\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE t4 USING fts4;\n  INSERT INTO t4 VALUES('a b c d');\n  SELECT snippet(t4, '[', ']', '...', 0, 0) FROM t4 WHERE t4 MATCH 'b';\n} {{}}\n\ndo_test 4.2 {\n  set x35 [string trim [string repeat \"x \" 35]]\n  execsql \"INSERT INTO t4 VALUES('$x35 E $x35 F $x35 G $x35');\"\n  llength [db one {\n    SELECT snippet(t4, '', '', '', 0, 64) FROM t4 WHERE t4 MATCH 'E'\n  }]\n} {64}\n\n\n\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3sort.test",
    "content": "# 2011 May 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n\nproc build_database {nRow param} {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  set vocab [list    aa ab ac   ba bb bc    ca cb cc   da]\n  expr srand(0)\n\n  execsql \"CREATE VIRTUAL TABLE t1 USING fts4($param)\"\n  for {set i 0} {$i < $nRow} {incr i} {\n    set v [expr int(rand()*1000000)]\n    set doc [list]\n    for {set div 1} {$div < 1000000} {set div [expr $div*10]} {\n      lappend doc [lindex $vocab [expr ($v/$div) % 10]]\n    }\n    execsql { INSERT INTO t1 VALUES($doc) }\n  }\n}\n\nset testprefix fts3sort\n\nunset -nocomplain CONTROL\nforeach {t param} {\n  1     \"\"\n  2     \"order=asc\"\n  3     \"order=desc\"\n} {\n\n  set testprefix fts3sort-1.$t\n\n  set nRow 1000\n  do_test 1.0 {\n    build_database $nRow $param\n    execsql { SELECT count(*) FROM t1 }\n  } $nRow\n  \n  foreach {tn query} {\n  1   \"SELECT docid, * FROM t1\"\n  2   \"SELECT docid, * FROM t1 WHERE t1 MATCH 'aa'\"\n  3   \"SELECT docid, * FROM t1 WHERE t1 MATCH 'a*'\"\n  4   \"SELECT docid, quote(matchinfo(t1)) FROM t1 WHERE t1 MATCH 'a*'\"\n  5   \"SELECT docid, quote(matchinfo(t1,'pcnxals')) FROM t1 WHERE t1 MATCH 'b*'\"\n  6   \"SELECT docid, * FROM t1 WHERE t1 MATCH 'a* b* c*'\"\n  7   \"SELECT docid, * FROM t1 WHERE t1 MATCH 'aa OR da'\"\n  8   \"SELECT docid, * FROM t1 WHERE t1 MATCH 'nosuchtoken'\"\n  9   \"SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa OR da'\"\n  10  \"SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa OR nosuchtoken'\"\n  11  \"SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH 'aa NEAR bb'\"\n  12  \"SELECT docid, snippet(t1) FROM t1 WHERE t1 MATCH '\\\"aa bb\\\"'\"\n  13  \"SELECT docid, content FROM t1 WHERE t1 MATCH 'aa NEAR/2 bb NEAR/3 cc'\"\n  14  \"SELECT docid, content FROM t1 WHERE t1 MATCH '\\\"aa bb cc\\\"'\"\n  } {\n  \n    unset -nocomplain A B C D\n    set A_list [list]\n    set B_list [list]\n    set C_list [list]\n    set D_list [list]\n  \n    unset -nocomplain X\n    db eval \"$query ORDER BY rowid ASC\"  X  { \n      set A($X(docid)) [array get X] \n      lappend A_list $X(docid)\n    }\n    unset -nocomplain X\n    db eval \"$query ORDER BY rowid DESC\" X  { \n      set B($X(docid)) [array get X] \n      lappend B_list $X(docid)\n    }\n    unset -nocomplain X\n    db eval \"$query ORDER BY docid ASC\"  X  { \n      set C($X(docid)) [array get X] \n      lappend C_list $X(docid)\n    }\n    unset -nocomplain X\n    db eval \"$query ORDER BY docid DESC\" X  { \n      set D($X(docid)) [array get X] \n      lappend D_list $X(docid)\n    }\n  \n    do_test $tn.1 { set A_list } [lsort -integer -increasing $A_list]\n    do_test $tn.2 { set B_list } [lsort -integer -decreasing $B_list]\n    do_test $tn.3 { set C_list } [lsort -integer -increasing $C_list]\n    do_test $tn.4 { set D_list } [lsort -integer -decreasing $D_list]\n  \n    unset -nocomplain DATA\n    unset -nocomplain X\n    db eval \"$query\" X  { \n      set DATA($X(docid)) [array get X] \n    }\n  \n    do_test $tn.5 { lsort [array get A] } [lsort [array get DATA]]\n    do_test $tn.6 { lsort [array get B] } [lsort [array get DATA]]\n    do_test $tn.7 { lsort [array get C] } [lsort [array get DATA]]\n    do_test $tn.8 { lsort [array get D] } [lsort [array get DATA]]\n\n    if {[info exists CONTROL($tn)]} {\n      do_test $tn.9 { set CONTROL($tn) } [lsort [array get DATA]]\n    } else {\n      set CONTROL($tn) [lsort [array get DATA]]\n    }\n  }\n}\nunset -nocomplain CONTROL\n\nset testprefix fts3sort\n\n#-------------------------------------------------------------------------\n# Tests for parsing the \"order=asc\" and \"order=desc\" directives.\n#\nforeach {tn param res} {\n  1 \"order=asc\"             {0 {}}\n  2 \"order=desc\"            {0 {}}\n  3 \"order=dec\"             {1 {unrecognized order: dec}}\n  4 \"order=xxx, order=asc\"  {1 {unrecognized order: xxx}}\n  5 \"order=desc, order=asc\" {0 {}}\n  6 \"order=xxxx, order=asc\" {1 {unrecognized order: xxxx}}\n  7 \"order=desk\"            {1 {unrecognized order: desk}}\n} {\n  execsql { DROP TABLE IF EXISTS t1 }\n  do_catchsql_test 2.1.$tn \"\n    CREATE VIRTUAL TABLE t1 USING fts4(a, b, $param)\n  \" $res\n}\n\ndo_execsql_test 2.2 {\n  BEGIN;\n    CREATE VIRTUAL TABLE t2 USING fts4(order=desc);\n    INSERT INTO t2 VALUES('aa bb');\n    INSERT INTO t2 VALUES('bb cc');\n    INSERT INTO t2 VALUES('cc aa');\n    SELECT docid FROM t2 WHERE t2 MATCH 'aa';\n  END;\n} {3 1}\ndo_execsql_test 2.3 {\n  SELECT docid FROM t2 WHERE t2 MATCH 'aa';\n} {3 1}\ndo_execsql_test 2.4 {\n  SELECT docid FROM t2 WHERE t2 MATCH 'aa' ORDER BY content;\n} {1 3}\n\n#-------------------------------------------------------------------------\n# Test that ticket [56be976859] has been fixed.\n#\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t3 USING fts4(x, order=DESC);\n  INSERT INTO t3(docid, x) VALUES(113382409004785664, 'aa');\n  INSERT INTO t3(docid, x) VALUES(1, 'ab');\n  SELECT rowid FROM t3 WHERE x MATCH 'a*' ORDER BY docid DESC;\n} {113382409004785664 1}\ndo_execsql_test 3.2 {\n  CREATE VIRTUAL TABLE t4 USING fts4(x);\n  INSERT INTO t4(docid, x) VALUES(-113382409004785664, 'aa');\n  INSERT INTO t4(docid, x) VALUES(1, 'ab');\n  SELECT rowid FROM t4 WHERE x MATCH 'a*';\n} {-113382409004785664 1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3tok1.test",
    "content": "# 2013 April 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the \"fts3tokenize\" virtual table\n# that is part of the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3 { finish_test ; return }\nset ::testprefix fts3tok1\n\n#-------------------------------------------------------------------------\n# Simple test cases. Using the default (simple) tokenizer.\n#\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts3tokenize(simple);\n  CREATE VIRTUAL TABLE t2 USING fts3tokenize();\n  CREATE VIRTUAL TABLE t3 USING fts3tokenize(simple, '', 'xyz ');\n}\n\nforeach {tn tbl} {1 t1 2 t2 3 t3} {\n  do_execsql_test 1.$tn.1 \"SELECT * FROM $tbl WHERE input = 'one two three'\" {\n    {one two three} one   0  3 0 \n    {one two three} two   4  7 1 \n    {one two three} three 8 13 2\n  }\n\n  do_execsql_test 1.$tn.2 \"\n    SELECT token FROM $tbl WHERE input = 'OnE tWo tHrEe'\n  \" {\n    one two three\n  }\n}\n\ndo_execsql_test 1.4 {\n  SELECT token FROM t3 WHERE input = '1x2x3x'\n} {1 2 3}\n\ndo_execsql_test 1.5 {\n  SELECT token FROM t1 WHERE input = '1x2x3x'\n} {1x2x3x}\n\ndo_execsql_test 1.6 {\n  SELECT token FROM t3 WHERE input = '1''2x3x'\n} {1'2 3}\n\ndo_execsql_test 1.7 {\n  SELECT token FROM t3 WHERE input = ''\n} {}\n\ndo_execsql_test 1.8 {\n  SELECT token FROM t3 WHERE input = NULL\n} {}\n\ndo_execsql_test 1.9 {\n  SELECT * FROM t3 WHERE input = 123\n} {123 123 0 3 0}\n\ndo_execsql_test 1.10 {\n  SELECT * FROM t1 WHERE input = 'a b c' AND token = 'b';\n} {\n  {a b c} b 2 3 1\n}\n\ndo_execsql_test 1.11 {\n  SELECT * FROM t1 WHERE token = 'b' AND input = 'a b c';\n} {\n  {a b c} b 2 3 1\n}\n\ndo_execsql_test 1.12 {\n  SELECT * FROM t1 WHERE input < 'b' AND input = 'a b c';\n} {\n  {a b c} a 0 1 0 \n  {a b c} b 2 3 1 \n  {a b c} c 4 5 2\n}\n\ndo_execsql_test 1.13.1 {\n  CREATE TABLE c1(x);\n  INSERT INTO c1(x) VALUES('a b c');\n  INSERT INTO c1(x) VALUES('d e f');\n}\ndo_execsql_test 1.13.2 {\n  SELECT * FROM c1, t1 WHERE input = x AND c1.rowid=t1.rowid;\n} {\n  {a b c} {a b c} a 0 1 0 \n  {d e f} {d e f} e 2 3 1 \n}\n\n\n#-------------------------------------------------------------------------\n# Error cases.\n#\ndo_catchsql_test 2.0 {\n  CREATE VIRTUAL TABLE tX USING fts3tokenize(nosuchtokenizer);\n} {1 {unknown tokenizer: nosuchtokenizer}}\n\ndo_catchsql_test 2.1 {\n  CREATE VIRTUAL TABLE t4 USING fts3tokenize;\n  SELECT * FROM t4;\n} {1 {SQL logic error}}\n\ndo_catchsql_test 2.2 {\n  CREATE VIRTUAL TABLE t USING fts4(tokenize=simple\"\"); \n} {0 {}}\n\nifcapable fts3_unicode {\n  do_catchsql_test 2.3 {\n    CREATE VIRTUAL TABLE u USING fts4(tokenize=unicode61\"\"); \n  } {1 {unknown tokenizer}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3tok_err.test",
    "content": "# 2013 April 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the \"fts3tokenize\" virtual table\n# that is part of the FTS3 module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !fts3 { finish_test ; return }\nset ::testprefix fts3tok_err\n\n\nfaultsim_save_and_close\ndo_faultsim_test fts3tok_err-1 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize(\"simple\"); }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\ndo_test fts3tok_err-2.prep {\n  faultsim_delete_and_reopen \n  execsql { CREATE VIRTUAL TABLE t1 USING fts3tokenize(\"simple\"); }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test fts3tok_err-2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT token FROM t1 WHERE input = 'A galaxy far, far away' } \n} -test {\n  faultsim_test_result {0 {a galaxy far far away}} \n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts3varint.test",
    "content": "# 2007 November 23\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n# $Id: fts3.test,v 1.2 2008/07/23 18:17:32 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts3varint\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nproc test_list {list} {\n  foreach n $list { fts3_test_varint $n }\n}\n\nproc do_fts3_varint_test {tn list} {\n  uplevel [list do_test $tn [list test_list $list] {}]\n}\n\ndo_fts3_varint_test 1.0 {\n  1 10 100 1000 10000 100000 1000000 \n  10000000 100000000 1000000000 10000000000\n  100000000000 1000000000000 10000000000000\n}\n\ndo_fts3_varint_test 1.1 {\n  -1 -10 -100 -1000 -10000 -100000 -1000000 \n  -10000000 -100000000 -1000000000 -10000000000\n  -100000000000 -1000000000000 -10000000000000\n}\n\ndo_fts3_varint_test 2.0 { 0 1 2 }\ndo_fts3_varint_test 2.1 { 1 2 3 }\ndo_fts3_varint_test 2.2 { 3 4 5 }\ndo_fts3_varint_test 2.3 { 7 8 9 }\ndo_fts3_varint_test 2.4 { 15 16 17 }\ndo_fts3_varint_test 2.5 { 31 32 33 }\ndo_fts3_varint_test 2.6 { 63 64 65 }\ndo_fts3_varint_test 2.7 { 127 128 129 }\ndo_fts3_varint_test 2.8 { 255 256 257 }\ndo_fts3_varint_test 2.9 { 511 512 513 }\ndo_fts3_varint_test 2.10 { 1023 1024 1025 }\ndo_fts3_varint_test 2.11 { 2047 2048 2049 }\ndo_fts3_varint_test 2.12 { 4095 4096 4097 }\ndo_fts3_varint_test 2.13 { 8191 8192 8193 }\ndo_fts3_varint_test 2.14 { 16383 16384 16385 }\ndo_fts3_varint_test 2.15 { 32767 32768 32769 }\ndo_fts3_varint_test 2.16 { 65535 65536 65537 }\ndo_fts3_varint_test 2.17 { 131071 131072 131073 }\ndo_fts3_varint_test 2.18 { 262143 262144 262145 }\ndo_fts3_varint_test 2.19 { 524287 524288 524289 }\ndo_fts3_varint_test 2.20 { 1048575 1048576 1048577 }\ndo_fts3_varint_test 2.21 { 2097151 2097152 2097153 }\ndo_fts3_varint_test 2.22 { 4194303 4194304 4194305 }\ndo_fts3_varint_test 2.23 { 8388607 8388608 8388609 }\ndo_fts3_varint_test 2.24 { 16777215 16777216 16777217 }\ndo_fts3_varint_test 2.25 { 33554431 33554432 33554433 }\ndo_fts3_varint_test 2.26 { 67108863 67108864 67108865 }\ndo_fts3_varint_test 2.27 { 134217727 134217728 134217729 }\ndo_fts3_varint_test 2.28 { 268435455 268435456 268435457 }\ndo_fts3_varint_test 2.29 { 536870911 536870912 536870913 }\ndo_fts3_varint_test 2.30 { 1073741823 1073741824 1073741825 }\ndo_fts3_varint_test 2.31 { 2147483647 2147483648 2147483649 }\ndo_fts3_varint_test 2.32 { 4294967295 4294967296 4294967297 }\ndo_fts3_varint_test 2.33 { 8589934591 8589934592 8589934593 }\ndo_fts3_varint_test 2.34 { 17179869183 17179869184 17179869185 }\ndo_fts3_varint_test 2.35 { 34359738367 34359738368 34359738369 }\ndo_fts3_varint_test 2.36 { 68719476735 68719476736 68719476737 }\ndo_fts3_varint_test 2.37 { 137438953471 137438953472 137438953473 }\ndo_fts3_varint_test 2.38 { 274877906943 274877906944 274877906945 }\ndo_fts3_varint_test 2.39 { 549755813887 549755813888 549755813889 }\ndo_fts3_varint_test 2.40 { 1099511627775 1099511627776 1099511627777 }\ndo_fts3_varint_test 2.41 { 2199023255551 2199023255552 2199023255553 }\ndo_fts3_varint_test 2.42 { 4398046511103 4398046511104 4398046511105 }\ndo_fts3_varint_test 2.43 { 8796093022207 8796093022208 8796093022209 }\ndo_fts3_varint_test 2.44 { 17592186044415 17592186044416 17592186044417 }\ndo_fts3_varint_test 2.45 { 35184372088831 35184372088832 35184372088833 }\ndo_fts3_varint_test 2.46 { 70368744177663 70368744177664 70368744177665 }\ndo_fts3_varint_test 2.47 { 140737488355327 140737488355328 140737488355329 }\ndo_fts3_varint_test 2.48 { 281474976710655 281474976710656 281474976710657 }\ndo_fts3_varint_test 2.49 { 562949953421311 562949953421312 562949953421313 }\ndo_fts3_varint_test 2.50 { 1125899906842623 1125899906842624 1125899906842625 }\ndo_fts3_varint_test 2.51 { 2251799813685247 2251799813685248 2251799813685249 }\ndo_fts3_varint_test 2.52 { 4503599627370495 4503599627370496 4503599627370497 }\ndo_fts3_varint_test 2.53 { 9007199254740991 9007199254740992 9007199254740993 }\ndo_fts3_varint_test 2.54 { \n    18014398509481983 18014398509481984 18014398509481985 }\ndo_fts3_varint_test 2.55 { \n    36028797018963967 36028797018963968 36028797018963969 }\ndo_fts3_varint_test 2.56 { \n    72057594037927935 72057594037927936 72057594037927937 }\ndo_fts3_varint_test 2.57 { \n    144115188075855871 144115188075855872 144115188075855873 }\ndo_fts3_varint_test 2.58 { \n    288230376151711743 288230376151711744 288230376151711745 }\ndo_fts3_varint_test 2.59 { \n    576460752303423487 576460752303423488 576460752303423489 }\ndo_fts3_varint_test 2.60 { \n    1152921504606846975 1152921504606846976 1152921504606846977 }\ndo_fts3_varint_test 2.61 { \n    2305843009213693951 2305843009213693952 2305843009213693953 }\ndo_fts3_varint_test 2.62 { \n    4611686018427387903 4611686018427387904 4611686018427387905 }\ndo_fts3_varint_test 2.63 { \n    9223372036854775807 9223372036854775808 9223372036854775809 }\n\ndo_fts3_varint_test 3.0 { 18446744073709551615 -18446744073709551615 }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4aa.test",
    "content": "# 2010 February 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS4 module.\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Create the fts_kjv_genesis procedure which fills and FTS3/4 table with\n# the complete text of the Book of Genesis.\n#\nsource $testdir/genesis.tcl\n\n# The following is a list of queries to perform against the above\n# FTS3/FTS4 database.  We will be trying these queries in various\n# configurations to ensure that they always return the same answers.\n#\nset fts4aa_queries {\n  {abraham}\n  {the king}\n  {\"the king\"}\n  {abraham OR joseph}\n  {ab* OR jos*}\n  {lived t*}\n  {spake hebrew}\n  {melchizedek}\n  {t* melchizedek}\n  {melchizedek t*}\n}\nunset -nocomplain fts4aa_res\n\n# Set up the baseline results\n#\ndo_test fts4aa-1.0 {\n  db eval {\n    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);\n  }\n  fts_kjv_genesis\n  foreach q $::fts4aa_queries {\n    set r [db eval {SELECT docid FROM t1 WHERE words MATCH $q ORDER BY docid}]\n    set ::fts4aa_res($q) $r\n  }\n} {}\n\n# Legacy test cases\n#\ndo_test fts4aa-1.1 {\n  db eval {\n    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize\n  }\n} {}\ndo_test fts4aa-1.2 {\n  db eval {\n    SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1\n  }\n} {}\n\nproc mit {blob} {\n  set scan(littleEndian) i*\n  set scan(bigEndian) I*\n  binary scan $blob $scan($::tcl_platform(byteOrder)) r\n  return $r\n}\ndb func mit mit\n\ndo_test fts4aa-1.3 {\n  db eval {\n    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1 WHERE t1 MATCH 'melchizedek';\n  }\n} {1014018 {1 1 1 1 1 1533 25 20}}\ndo_test fts4aa-1.4 {\n  db eval {\n    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1\n     WHERE t1 MATCH 'spake hebrew'\n     ORDER BY docid;\n  }\n} {1039014 {2 1 1 40 40 1 6 6 1533 25 42} 1039017 {2 1 1 40 40 1 6 6 1533 25 26}}\ndo_test fts4aa-1.5 {\n  db eval {\n    SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1\n     WHERE t1 MATCH 'laban overtook jacob'\n     ORDER BY docid;\n  }\n} {1031025 {3 1 2 54 46 1 3 3 2 181 160 1533 25 24}}\n\ndo_test fts4aa-1.6 {\n  db eval {\n    DELETE FROM t1 WHERE docid!=1050026;\n    SELECT hex(size) FROM t1_docsize;\n    SELECT hex(value) FROM t1_stat;\n  }\n} {17 01176F}\n\ndo_test fts4aa-1.7 {\n  db eval {\n    SELECT docid FROM t1 EXCEPT SELECT docid FROM t1_docsize\n  }\n} {}\ndo_test fts4aa-1.8 {\n  db eval {\n    SELECT docid FROM t1_docsize EXCEPT SELECT docid FROM t1\n  }\n} {}\nifcapable fts4_deferred {\n  do_test fts4aa-1.9 {\n    # Note: Token 'in' is being deferred in the following query. \n    db eval {\n      SELECT docid, mit(matchinfo(t1, 'pcxnal')) FROM t1\n       WHERE t1 MATCH 'joseph died in egypt'\n       ORDER BY docid;\n    }\n  } {1050026 {4 1 1 1 1 1 1 1 2 1 1 1 1 1 1 23 23}}\n}\n\n# Should get the same search results from FTS3\n#\ndo_test fts4aa-2.0 {\n  db eval {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3(words, tokenize porter);\n  }\n  fts_kjv_genesis\n} {}\nunset -nocomplain ii\nset ii 0\nforeach {q r} [array get fts4aa_res] {\n  incr ii\n  do_test fts4aa-2.$ii {\n    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}\n  } $r\n}\n\n# Should get the same search results when the page size is very large\n#\ndo_test fts4aa-3.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=65536;\n    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);\n  }\n  fts_kjv_genesis\n} {}\nunset -nocomplain ii\nset ii 0\nforeach {q r} [array get fts4aa_res] {\n  incr ii\n  do_test fts4aa-3.$ii {\n    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}\n  } $r\n}\n\n# Should get the same search results when an authorizer prevents\n# all PRAGMA statements.\n#\nproc no_pragma_auth {code arg1 arg2 arg3 arg4 args} {\n  if {$code==\"SQLITE_PRAGMA\"} {return SQLITE_DENY}\n  return SQLITE_OK;\n}\ndo_test fts4aa-4.0 {\n  db auth ::no_pragma_auth\n  db eval {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter);\n  }\n  fts_kjv_genesis\n} {}\nunset -nocomplain ii\nset ii 0\nforeach {q r} [array get fts4aa_res] {\n  incr ii\n  do_test fts4aa-4.$ii {\n    db eval {SELECT docid FROM t1 WHERE words MATCH $::q ORDER BY docid}\n  } $r\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4check.test",
    "content": "# 2012 March 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library. The\n# focus of this script is testing the FTS 'integrity-check' function,\n# used to check if the current FTS index accurately reflects the content\n# of the table.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4check\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Run the integrity-check on FTS table $tbl using database handle $db. If\n# the integrity-check passes, return \"ok\". Otherwise, throw an exception.\n#\nproc fts_integrity {db tbl} {\n  $db eval \"INSERT INTO $tbl ($tbl) VALUES('integrity-check')\"\n  return \"ok\"\n}\n\n#-------------------------------------------------------------------------\n# Test cases 1.*\n#\n#   1.0: Build a reasonably sized FTS table (5000 rows).\n#\n#   1.1: Run the integrity check code to check it passes.\n#\n#   1.2: Make a series of minor changes to the underlying FTS data structures\n#        (e.g. delete or insert a row from the %_content table). Check that\n#        this causes the integrity-check code to fail.\n#\n\n# Build an FTS table and check the integrity-check passes.\n#\ndo_test 1.0 { fts3_build_db_1 5000 } {}\ndo_test 1.1 { fts_integrity db t1 } {ok}\n\n# Mess around with the underlying tables. Check that this causes the\n# integrity-check test to fail.\n#\nforeach {tn disruption} {\n  1 {\n    INSERT INTO t1_content(docid, c0x, c1y) VALUES(NULL, 'a', 'b');\n  }\n  2 {\n    DELETE FROM t1_content WHERE docid = (SELECT max(docid) FROM t1_content);\n  }\n  3 {\n    DELETE FROM t1_segdir WHERE level=0 AND idx=(\n      SELECT max(idx) FROM t1_segdir WHERE level=0\n    );\n  }\n} {\n  do_execsql_test  1.2.1.$tn \"BEGIN; $disruption\"\n  do_catchsql_test 1.2.2.$tn {\n    INSERT INTO t1 (t1) VALUES('integrity-check')\n  } {1 {database disk image is malformed}}\n  do_execsql_test  1.2.3.$tn \"ROLLBACK\"\n}\n\ndo_test 1.3 { fts_integrity db t1 } {ok}\n\n#-------------------------------------------------------------------------\n# Test cases 2.*\n#\n#   2.0: Build a reasonably sized FTS table (20000 rows) that includes\n#        prefix indexes.\n#\n#   2.1: Run the integrity check code to check it passes.\n#\n#   2.2: Make a series of minor changes to the underlying FTS data structures\n#        (e.g. delete or insert a row from the %_content table). Check that\n#        this causes the integrity-check code to fail.\n#\n\ndo_test 2.0 { fts3_build_db_2 -extra {prefix=\"3,1\"} 20000 } {}\ndo_test 2.1 { fts_integrity db t2 } {ok}\nforeach {tn disruption} {\n  1 {\n    INSERT INTO t2_content VALUES(NULL, 'xyz')\n  }\n  3 {\n    DELETE FROM t2_segdir WHERE level=0 AND idx=(\n      SELECT max(idx) FROM t2_segdir WHERE level=1024\n    );\n  }\n} {\n  do_execsql_test  2.2.1.$tn \"BEGIN; $disruption\"\n  do_catchsql_test 2.2.2.$tn {\n    INSERT INTO t2 (t2) VALUES('integrity-check')\n  } {1 {database disk image is malformed}}\n  do_execsql_test  2.2.3.$tn \"ROLLBACK\"\n}\n\n\n#-------------------------------------------------------------------------\n# Test cases 3.*\n#\n#   3.0: Build a reasonably sized FTS table (5000 rows) that includes\n#        prefix indexes and uses the languageid= feature.\n#\n#   3.1: Run the integrity check code to check it passes.\n#\n#   3.2: Make a series of minor changes to the underlying FTS data structures\n#        (e.g. delete or insert a row from the %_content table). Check that\n#        this causes the integrity-check code to fail.\n#\ndo_test 3.0 {\n  reset_db\n  fts3_build_db_1 5000\n  execsql {\n    CREATE VIRTUAL TABLE t3 USING fts4(x, y, prefix=\"2,3\", languageid=langid);\n  }\n  foreach docid [execsql {SELECT docid FROM t1 ORDER BY 1 ASC}] {\n    execsql {\n      INSERT INTO t3(x, y, langid) \n      SELECT x, y, (docid%9)*4 FROM t1 WHERE docid=$docid;\n    }\n  }\n} {}\ndo_test 3.1 { fts_integrity db t3 } {ok}\n\nforeach {tn disruption} {\n  1 {\n    INSERT INTO t3_content(c0x, c1y, langid) VALUES(NULL, 'a', 0);\n  }\n  2 {\n    UPDATE t3_content SET langid=langid+1 WHERE rowid = (\n      SELECT max(rowid) FROM t3_content\n    )\n  }\n} {\n  do_execsql_test  3.2.1.$tn \"BEGIN; $disruption\"\n  do_catchsql_test 3.2.2.$tn {\n    INSERT INTO t3 (t3) VALUES('integrity-check')\n  } {1 {database disk image is malformed}}\n  do_execsql_test  3.2.3.$tn \"ROLLBACK\"\n}\n\n#--------------------------------------------------------------------------\n# Test case 4.*\n#\n# Test that the integrity-check works if there are \"notindexed\" columns.\n#\ndo_execsql_test 4.0 {\n  CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b);\n  INSERT INTO t4 VALUES('text one', 'text two', 'text three');\n  INSERT INTO t4(t4) VALUES('integrity-check');\n}\n\ndo_execsql_test 4.1 {\n  PRAGMA writable_schema = 1;\n  UPDATE sqlite_master \n    SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)' \n    WHERE name = 't4';\n}\n\ndo_test 4.2 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    INSERT INTO t4(t4) VALUES('integrity-check');\n  }\n} {1 {database disk image is malformed}}\nreset_db\n\n#--------------------------------------------------------------------------\n# Test case 5.*\n#\n# Test that the integrity-check works if there is uncommitted data.\n#\ndo_execsql_test 5.0 {\n  BEGIN;\n  CREATE VIRTUAL TABLE t5 USING fts4(a, prefix=\"1,2,3\");\n  INSERT INTO t5 VALUES('And down by Kosiosko, where the reed-banks sweep');\n  INSERT INTO t5 VALUES('and sway, and the rolling plains are wide, the');\n  INSERT INTO t5 VALUES('man from snowy river is a household name today,');\n  INSERT INTO t5 VALUES('and the stockmen tell the story of his ride');\n}\n\ndo_execsql_test 5.1 {\n  INSERT INTO t5(t5) VALUES('integrity-check');\n} {}\n\ndo_catchsql_test 5.2 {\n  INSERT INTO t5_content VALUES(5, 'his hardy mountain pony');\n  INSERT INTO t5(t5) VALUES('integrity-check');\n} {1 {database disk image is malformed}}\n\ndo_execsql_test 5.3 ROLLBACK\n\ndo_execsql_test 5.4 {\n  CREATE VIRTUAL TABLE t5 USING fts4(a, prefix=\"1,2,3\");\n  INSERT INTO t5(t5) VALUES('integrity-check');\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4content.test",
    "content": "# 2011 October 03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the content=xxx FTS4 option.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix fts4content\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test organization:\n#   \n#   1.* - Warm-body tests.\n#\n#   2.* - Querying a content=xxx FTS table.\n#\n#   3.* - Writing to a content=xxx FTS table.\n#\n#   4.* - The \"INSERT INTO fts(fts) VALUES('rebuild')\" command.\n#\n#   5.* - Check that CREATE TABLE, DROP TABLE and ALTER TABLE correctly\n#         ignore any %_content table when used with the content=xxx option.\n#\n#   6.* - Test the effects of messing with the schema of table xxx after\n#         creating a content=xxx FTS index.\n#   \n#   7.* - Test that if content=xxx is specified and table xxx does not\n#         exist, the FTS table can still be used for INSERT and some\n#         SELECT statements.\n#\n#   8.* - Test that if the content=xxx and prefix options are used together,\n#         the 'rebuild' command still works.\n#\n#   9.* - Test using content=xxx where xxx is a virtual table.\n#\n#   11.* - Test that circular references (e.g. \"t1(content=t1)\") are\n#          detected.\n#\n\ndo_execsql_test 1.1.1 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES('w x', 'x y', 'y z');\n  CREATE VIRTUAL TABLE ft1 USING fts4(content=t1);\n}\n\ndo_execsql_test 1.1.2 {\n  PRAGMA table_info(ft1);\n} {\n  0 a {} 0 {} 0 \n  1 b {} 0 {} 0 \n  2 c {} 0 {} 0\n}\n\ndo_execsql_test 1.1.3 { SELECT *, rowid FROM ft1 } {{w x} {x y} {y z} 1}\ndo_execsql_test 1.1.4 { SELECT a, c FROM ft1 WHERE rowid=1 } {{w x} {y z}}\n\ndo_execsql_test 1.1.5 { INSERT INTO ft1(ft1) VALUES('rebuild') } {}\ndo_execsql_test 1.1.6 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'x' } {1}\ndo_execsql_test 1.1.7 { SELECT rowid FROM ft1 WHERE ft1 MATCH 'a' } {}\n\ndo_execsql_test 1.2.1 {\n  DROP TABLE ft1;\n  CREATE VIRTUAL TABLE ft1 USING fts4(content=t1, b);\n  PRAGMA table_info(ft1);\n} {\n  0 b {} 0 {} 0 \n}\ndo_execsql_test 1.2.2 { \n  SELECT *, rowid FROM ft1 \n} {{x y} 1}\n\n#-------------------------------------------------------------------------\n# The following block of tests - 2.* - test that a content=xxx FTS table\n# can be queried. Also tested are cases where rows identified in the FTS\n# are missing from the content table, and cases where the index is \n# inconsistent with the content table.\n# \ndo_execsql_test 2.0 {\n  CREATE TABLE t2(x);\n  INSERT INTO t2 VALUES('O S W W F U C R Q I C N P Z Y Y E Y Y E');  -- 1\n  INSERT INTO t2 VALUES('Y X U V L B E H Y J C Y A I A P V F V K');  -- 2\n  INSERT INTO t2 VALUES('P W I N J H I I N I F B K D U Q B Z S F');  -- 3\n  INSERT INTO t2 VALUES('N R O R H J R H G M D I U U B O M P A U');  -- 4\n  INSERT INTO t2 VALUES('Y O V O G T P N G T N F I V B U M J M G');  -- 5\n  INSERT INTO t2 VALUES('J O B N K N E C H Z R K J O U G M K L S');  -- 6\n  INSERT INTO t2 VALUES('S Z S R I Q U A P W R X H K C Z U L S P');  -- 7\n  INSERT INTO t2 VALUES('J C H N R C K R V N M O F Z M Z A I H W');  -- 8\n  INSERT INTO t2 VALUES('O Y G I S J U U W O D Z F J K N R P R L');  -- 9\n  INSERT INTO t2 VALUES('B G L K U R U P V X Z I H V R W C Q A S');  -- 10\n  INSERT INTO t2 VALUES('T F T J F F Y V F W N X K Q A Y L X W G');  -- 11\n  INSERT INTO t2 VALUES('C J U H B Q X L C M M Y E G V F W V Z C');  -- 12\n  INSERT INTO t2 VALUES('B W L T F S G X D P H N G M R I O A X I');  -- 13\n  INSERT INTO t2 VALUES('N G Y O K Q K Z N M H U J E D H U W R K');  -- 14\n  INSERT INTO t2 VALUES('U D T R U Y F J D S J X E H Q G V A S Z');  -- 15\n  INSERT INTO t2 VALUES('M I W P J S H R J D Q I C G P C T P H R');  -- 16\n  INSERT INTO t2 VALUES('J M N I S L X Q C A B F C B Y D H V R J');  -- 17\n  INSERT INTO t2 VALUES('F V Z W J Q L P X Y E W B U Q N H X K T');  -- 18\n  INSERT INTO t2 VALUES('R F S R Y O F Q E I E G H C B H R X Y N');  -- 19\n  INSERT INTO t2 VALUES('U Q Q Q T E P D M F X P J G H X C Q D L');  -- 20\n}\n\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE ft2 USING fts4(content=t2);\n  INSERT INTO ft2(ft2) VALUES('rebuild');\n\n  -- Modify the backing table a bit: Row 17 is missing and the contents \n  -- of row 20 do not match the FTS index contents. \n  DELETE FROM t2 WHERE rowid = 17;\n  UPDATE t2 SET x = 'a b c d e f g h i j' WHERE rowid = 20;\n}\n\nforeach {tn match rowidlist} {\n  1   {S}        {1 3 6 7 9 10 13 15 16 17 19}\n  2   {\"S R\"}    {7 19}\n  3   {\"N K N\"}  {6}\n  4   {\"Q Q\"}    {20}\n  5   {\"B Y D\"}  {17}\n} {\n  do_execsql_test 2.2.1.$tn {\n    SELECT rowid FROM ft2 WHERE ft2 MATCH $match\n  } $rowidlist\n\n  do_execsql_test 2.2.2.$tn {\n    SELECT docid FROM ft2 WHERE ft2 MATCH $match\n  } $rowidlist\n}\n\nforeach {tn match result} {\n  1   {\"N K N\"}  {{J O B N K N E C H Z R K J O U G M K L S}}\n  2   {\"Q Q\"}    {{a b c d e f g h i j}}\n  3   {\"B Y D\"}  {{}}\n} {\n  do_execsql_test 2.3.$tn {\n    SELECT * FROM ft2 WHERE ft2 MATCH $match\n  } $result\n}\n\nforeach {tn match result} {\n  1   {\"N K N\"}  {{..O B [N] [K] [N] E..}}\n  2   {\"B Y D\"}  {{}}\n  3   {\"Q Q\"}    {{a [b] [c] [d] e f..}}\n} {\n  do_execsql_test 2.4.$tn {\n    SELECT snippet(ft2, '[', ']', '..', -1, 6) FROM ft2 WHERE ft2 MATCH $match\n  } $result\n}\n\nforeach {tn match result} {\n  1   {\"N K N\"}  {{0 0 6 1 0 1 8 1 0 2 10 1}}\n  2   {\"B Y D\"}  {{}}\n  3   {\"Q Q\"}    {{0 0 2 1 0 0 4 1 0 1 4 1 0 1 6 1}}\n  4   {\"Q D L\"}  {{}}\n} {\n  do_execsql_test 2.5.$tn {\n    SELECT offsets(ft2) FROM ft2 WHERE ft2 MATCH $match\n  } $result\n}\n\n#-------------------------------------------------------------------------\n# The following block of tests - 3.* - test that the FTS index can be\n# modified by writing to the table. But that this has no effect on the \n# content table.\n# \n\ndo_execsql_test 3.1 {\n  CREATE TABLE t3(x, y);\n  CREATE VIRTUAL TABLE ft3 USING fts4(content=t3);\n}\n\ndo_catchsql_test 3.1.1 {\n  INSERT INTO ft3 VALUES('a b c', 'd e f');\n} {1 {constraint failed}}\ndo_execsql_test 3.1.2 {\n  INSERT INTO ft3(docid, x, y) VALUES(21, 'a b c', 'd e f');\n  SELECT rowid FROM ft3 WHERE ft3 MATCH '\"a b c\"';\n} {21}\ndo_execsql_test 3.1.3 { SELECT * FROM t3 } {}\n\n# This DELETE does not work, since there is no row in [t3] to base the\n# DELETE on. So the SELECT on [ft3] still returns rowid 21.\ndo_execsql_test 3.1.4 { \n  DELETE FROM ft3;\n  SELECT rowid FROM ft3 WHERE ft3 MATCH '\"a b c\"';\n} {21}\n\n# If the row is added to [t3] before the DELETE on [ft3], it works.\ndo_execsql_test 3.1.5 {\n  INSERT INTO t3(rowid, x, y) VALUES(21, 'a b c', 'd e f');\n  DELETE FROM ft3;\n  SELECT rowid FROM ft3 WHERE ft3 MATCH '\"a b c\"';\n} {}\ndo_execsql_test 3.1.6 { SELECT rowid FROM t3 } {21}\n\ndo_execsql_test 3.2.1 {\n  INSERT INTO ft3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H');\n  INSERT INTO ft3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K');\n  INSERT INTO ft3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C');\n  INSERT INTO ft3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C');\n  INSERT INTO ft3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C');\n  INSERT INTO ft3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y');\n  INSERT INTO ft3(rowid, x, y) VALUES(6, 'I Q I S P', 'D R O Q B');\n  INSERT INTO ft3(rowid, x, y) VALUES(7, 'T K T Z J', 'B W D G O');\n  INSERT INTO ft3(rowid, x, y) VALUES(8, 'Y K F X T', 'D F G V G');\n  INSERT INTO ft3(rowid, x, y) VALUES(9, 'E L E T L', 'P W N F Z');\n  INSERT INTO ft3(rowid, x, y) VALUES(10, 'O G J G X', 'G J F E P');\n  INSERT INTO ft3(rowid, x, y) VALUES(11, 'O L N N Z', 'K E Z F D');\n  INSERT INTO ft3(rowid, x, y) VALUES(12, 'R Z M R J', 'X G I M Z');\n  INSERT INTO ft3(rowid, x, y) VALUES(13, 'L X N N X', 'R R N S T');\n  INSERT INTO ft3(rowid, x, y) VALUES(14, 'F L B J H', 'K W F L C');\n  INSERT INTO ft3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U');\n  INSERT INTO ft3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K');\n  INSERT INTO ft3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N');\n  INSERT INTO ft3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V');\n  INSERT INTO ft3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O');\n}\n\nforeach {tn match rowidlist} {\n  1   \"N A\"    {5 19}\n  2   \"x:O\"    {1 2 10 11 17}\n  3   \"y:O\"    {0 2 6 7 18 19}\n} {\n  set res [list]\n  foreach rowid $rowidlist { lappend res $rowid {} {} }\n\n  do_execsql_test 3.2.2.$tn {\n    SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n  do_execsql_test 3.2.3.$tn {\n    SELECT docid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n}\n\ndo_execsql_test 3.3.1 {\n  INSERT INTO t3(rowid, x, y) VALUES(0, 'R T M S M', 'A F O K H');\n  INSERT INTO t3(rowid, x, y) VALUES(1, 'C Z J O X', 'U S Q D K');\n  INSERT INTO t3(rowid, x, y) VALUES(2, 'N G H P O', 'N O P O C');\n  INSERT INTO t3(rowid, x, y) VALUES(3, 'V H S D R', 'K N G E C');\n  INSERT INTO t3(rowid, x, y) VALUES(4, 'J T R V U', 'U X S L C');\n  INSERT INTO t3(rowid, x, y) VALUES(5, 'N A Y N G', 'X D G P Y');\n  UPDATE ft3 SET x = y, y = x;\n  DELETE FROM t3;\n}\n\nforeach {tn match rowidlist} {\n  1   \"N A\"    {5 19}\n  2   \"x:O\"    {0 2 10 11 17}\n  3   \"y:O\"    {1 2 6 7 18 19}\n} {\n  set res [list]\n  foreach rowid $rowidlist { lappend res $rowid {} {} }\n\n  do_execsql_test 3.3.2.$tn {\n    SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n  do_execsql_test 3.3.3.$tn {\n    SELECT docid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n}\n\ndo_execsql_test 3.3.1 {\n  INSERT INTO t3(rowid, x, y) VALUES(15, 'P E B M V', 'E A A B U');\n  INSERT INTO t3(rowid, x, y) VALUES(16, 'V E C F P', 'L U T V K');\n  INSERT INTO t3(rowid, x, y) VALUES(17, 'T N O Z N', 'T P Q X N');\n  INSERT INTO t3(rowid, x, y) VALUES(18, 'V W U W R', 'H O A A V');\n  INSERT INTO t3(rowid, x, y) VALUES(19, 'A H N L F', 'I G H B O');\n  DELETE FROM ft3;\n}\n\nforeach {tn match rowidlist} {\n  1   \"N A\"    {5}\n  2   \"x:O\"    {0 2 10 11}\n  3   \"y:O\"    {1 2 6 7}\n} {\n  set res [list]\n  foreach rowid $rowidlist { lappend res $rowid {} {} }\n\n  do_execsql_test 3.3.2.$tn {\n    SELECT rowid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n  do_execsql_test 3.3.3.$tn {\n    SELECT docid, * FROM ft3 WHERE ft3 MATCH $match\n  } $res\n}\n\n\n#-------------------------------------------------------------------------\n# Test cases 4.* test the 'rebuild' command. On content=xxx and regular\n# FTS tables.\n# \ndo_execsql_test 4.0 {\n  CREATE TABLE t4(x);\n  CREATE VIRTUAL TABLE ft4 USING fts4(content=t4);\n  CREATE VIRTUAL TABLE ft4x USING fts4(x);\n}\n\ndo_execsql_test 4.1.1 {\n  INSERT INTO ft4x(ft4x) VALUES('rebuild');\n  INSERT INTO ft4(ft4) VALUES('rebuild');\n} {}\ndo_execsql_test 4.1.2 {\n  SELECT id, quote(value) FROM ft4_stat\n} {0 X'000000'}\ndo_execsql_test 4.1.3 {\n  SELECT id, quote(value) FROM ft4x_stat\n} {0 X'000000'}\n\ndo_execsql_test 4.2.1 {\n  INSERT INTO ft4x VALUES('M G M F T');\n  INSERT INTO ft4x VALUES('Z Q C A U');\n  INSERT INTO ft4x VALUES('N L L V');\n  INSERT INTO ft4x VALUES('T F D X D');\n  INSERT INTO ft4x VALUES('Z H I S D');\n\n  SELECT id, quote(value) FROM ft4x_stat\n} {0 X'05182B'}\n\ndo_execsql_test 4.2.2 {\n  INSERT INTO ft4(rowid, x) SELECT rowid, * FROM ft4x;\n  SELECT id, quote(value) FROM ft4_stat\n} {0 X'05182B'}\n\ndo_execsql_test 4.2.3 {\n  SELECT docid, quote(size) FROM ft4_docsize\n} {1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}\n\ndo_execsql_test 4.2.4 {\n  INSERT INTO ft4x(ft4x) VALUES('rebuild');\n  SELECT id, quote(value) FROM ft4x_stat;\n  SELECT docid, quote(size) FROM ft4x_docsize\n} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}\n\ndo_execsql_test 4.2.5 {\n  INSERT INTO ft4(ft4) VALUES('rebuild');\n  SELECT id, quote(value) FROM ft4_stat;\n  SELECT docid, quote(size) FROM ft4_docsize\n} {0 X'000000'}\n\ndo_execsql_test 4.2.6 {\n  INSERT INTO t4(rowid, x) SELECT rowid, x FROM ft4x;\n  INSERT INTO ft4(ft4) VALUES('rebuild');\n  SELECT id, quote(value) FROM ft4_stat;\n  SELECT docid, quote(size) FROM ft4_docsize\n} {0 X'05182B' 1 X'05' 2 X'05' 3 X'04' 4 X'05' 5 X'05'}\n\n\n#-------------------------------------------------------------------------\n# Test cases 5.* test that the following commands do not create/move or\n# delete a %_content table when used with a content=xxx FTS table.\n# \ndo_execsql_test 5.1.1 {\n  CREATE TABLE t5(a, b, c, d);\n  CREATE VIRTUAL TABLE ft5 USING fts4(content=t5);\n  SELECT name FROM sqlite_master WHERE name LIKE '%t5%';\n} {\n  t5 ft5 ft5_segments ft5_segdir \n  sqlite_autoindex_ft5_segdir_1 ft5_docsize ft5_stat\n}\ndo_execsql_test 5.1.2 {\n  ALTER TABLE ft5 RENAME TO ft6;\n  SELECT name FROM sqlite_master WHERE name LIKE '%t5%';\n} {\n  t5\n}\ndo_execsql_test 5.1.3 {\n  SELECT name FROM sqlite_master WHERE name LIKE '%t6%';\n} {\n  ft6 ft6_segments ft6_segdir \n  sqlite_autoindex_ft6_segdir_1 ft6_docsize ft6_stat\n}\ndo_execsql_test 5.1.4 {\n  INSERT INTO t5 VALUES('a', 'b', 'c', 'd');\n  INSERT INTO ft6(ft6) VALUES('rebuild');\n  SELECT rowid FROM ft6 WHERE ft6 MATCH 'b';\n} {1}\ndo_execsql_test 5.1.5 {\n  DROP TABLE ft6;\n  SELECT * FROM t5;\n} {a b c d}\ndo_execsql_test 5.1.6 {\n  SELECT name FROM sqlite_master WHERE name LIKE '%t6%';\n} {\n}\ndo_execsql_test 5.1.7 {\n  CREATE VIRTUAL TABLE ft5 USING fts4(content=t5);\n  CREATE TABLE t5_content(a, b);\n  DROP TABLE ft5;\n  SELECT name FROM sqlite_master WHERE name LIKE '%t5%';\n} {\n  t5 t5_content\n}\n\n#-------------------------------------------------------------------------\n# Test cases 6.* test \n# \ndo_catchsql_test 6.1.1 {\n  CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);\n} {1 {no such table: main.t7}}\n\ndo_execsql_test 6.2.1 {\n  CREATE TABLE t7(one, two);\n  CREATE VIRTUAL TABLE ft7 USING fts4(content=t7);\n  INSERT INTO t7 VALUES('A B', 'B A');\n  INSERT INTO t7 VALUES('C D', 'A A');\n  SELECT * FROM ft7;\n} {\n  {A B} {B A} {C D} {A A}\n}\n\ndo_catchsql_test 6.2.2 {\n  DROP TABLE t7;\n  SELECT * FROM ft7;\n} {1 {SQL logic error}}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test 6.2.3 {\n  SELECT name FROM sqlite_master WHERE name LIKE '%t7%'\n} {\n  ft7 ft7_segments ft7_segdir sqlite_autoindex_ft7_segdir_1 \n  ft7_docsize ft7_stat\n}\ndo_catchsql_test 6.2.4 {\n  SELECT * FROM ft7;\n} {1 {no such table: main.t7}}\ndo_execsql_test 6.2.5 {\n  CREATE TABLE t7(x, y);\n  INSERT INTO t7 VALUES('A B', 'B A');\n  INSERT INTO t7 VALUES('C D', 'A A');\n  SELECT * FROM ft7;\n} {\n  {A B} {B A} {C D} {A A}\n}\n\ndo_execsql_test 6.2.6 {\n  INSERT INTO ft7(ft7) VALUES('rebuild');\n  SELECT rowid FROM ft7 WHERE ft7 MATCH '\"A A\"';\n} {2}\n\ndo_execsql_test 6.2.7 {\n  DROP TABLE t7;\n  CREATE TABLE t7(x);\n}\ndo_catchsql_test 6.2.8 {\n  SELECT * FROM ft7 WHERE ft7 MATCH '\"A A\"';\n} {1 {SQL logic error}}\ndo_catchsql_test 6.2.9 {\n  SELECT * FROM ft7 WHERE ft7 MATCH '\"A A\"';\n} {1 {SQL logic error}}\n\ndb close\nsqlite3 db test.db\ndo_catchsql_test 6.2.10 {\n  SELECT rowid FROM ft7 WHERE ft7 MATCH '\"A A\"';\n} {0 2}\ndo_catchsql_test 6.2.11 {\n  SELECT rowid, * FROM ft7 WHERE ft7 MATCH '\"A A\"';\n} {0 {2 {}}}\n\n#-------------------------------------------------------------------------\n# Test cases 7.*\n# \ndo_execsql_test 7.1.1 {\n  CREATE VIRTUAL TABLE ft8 USING fts4(content=nosuchtable, x);\n  INSERT INTO ft8(docid, x) VALUES(13, 'U O N X G');\n  INSERT INTO ft8(docid, x) VALUES(14, 'C J J U B');\n  INSERT INTO ft8(docid, x) VALUES(15, 'N J Y G X');\n  INSERT INTO ft8(docid, x) VALUES(16, 'R Y D O R');\n  INSERT INTO ft8(docid, x) VALUES(17, 'I Y T Q O');\n}\n\ndo_execsql_test 7.1.2 {\n  SELECT docid FROM ft8 WHERE ft8 MATCH 'N';\n} {13 15}\n\ndo_execsql_test 7.2.1 {\n  CREATE VIRTUAL TABLE ft9 USING fts4(content=, x);\n  INSERT INTO ft9(docid, x) VALUES(13, 'U O N X G');\n  INSERT INTO ft9(docid, x) VALUES(14, 'C J J U B');\n  INSERT INTO ft9(docid, x) VALUES(15, 'N J Y G X');\n  INSERT INTO ft9(docid, x) VALUES(16, 'R Y D O R');\n  INSERT INTO ft9(docid, x) VALUES(17, 'I Y T Q O');\n}\ndo_execsql_test 7.2.2 {\n  SELECT docid FROM ft9 WHERE ft9 MATCH 'N';\n} {13 15}\ndo_execsql_test 7.2.3 {\n  SELECT name FROM sqlite_master WHERE name LIKE 'ft9_%';\n} {ft9_segments ft9_segdir ft9_docsize ft9_stat}\n\ndo_catchsql_test 7.2.4 {\n  SELECT * FROM ft9 WHERE ft9 MATCH 'N';\n} {1 {SQL logic error}}\n\n#-------------------------------------------------------------------------\n# Test cases 8.*\n# \ndo_execsql_test 8.1 {\n  CREATE TABLE t10(a, b);\n  INSERT INTO t10 VALUES(\n      'abasia abasic abask', 'Abassin abastardize abatable');\n  INSERT INTO t10 VALUES(\n      'abate abatement abater', 'abatis abatised abaton');\n  INSERT INTO t10 VALUES(\n      'abator abattoir Abatua', 'abature abave abaxial');\n\n  CREATE VIRTUAL TABLE ft10 USING fts4(content=t10, prefix=\"2,4\", a, b);\n}\n\ndo_execsql_test 8.2 { SELECT * FROM ft10 WHERE a MATCH 'ab*';          }\ndo_execsql_test 8.3 { INSERT INTO ft10(ft10) VALUES('rebuild');        }\ndo_execsql_test 8.4 { SELECT rowid FROM ft10 WHERE a MATCH 'ab*';      } {1 2 3}\ndo_execsql_test 8.5 { SELECT rowid FROM ft10 WHERE b MATCH 'abav*';    } {3}\ndo_execsql_test 8.6 { SELECT rowid FROM ft10 WHERE ft10 MATCH 'abas*'; } {1}\n\n#-------------------------------------------------------------------------\n# Test cases 9.*\n# \nreset_db\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_execsql_test 9.1 {\n  CREATE TABLE tbl1(a, b);\n  INSERT INTO tbl1 VALUES('a b', 'c d');\n  INSERT INTO tbl1 VALUES('e f', 'a b');\n  CREATE VIRTUAL TABLE e1 USING echo(tbl1);\n  CREATE VIRTUAL TABLE ft1 USING fts4(content=e1);\n  INSERT INTO ft1(ft1) VALUES('rebuild');\n}\n\ndo_execsql_test 9.2 {\n  SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'e'\n} {2 {e f} {a b}}\n\ndo_execsql_test 9.3 {\n  SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'\n} {1 {a b} {c d} 2 {e f} {a b}}\n\ndo_execsql_test 9.4 { \n  DELETE FROM ft1 WHERE docid=1;\n}\n\ndo_execsql_test 9.5 {\n  SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'\n} {2 {e f} {a b}}\n\ndo_execsql_test 9.6 {\n  INSERT INTO ft1(ft1) VALUES('rebuild');\n  SELECT rowid, * FROM ft1 WHERE ft1 MATCH 'a'\n} {1 {a b} {c d} 2 {e f} {a b}}\n\n\n#-------------------------------------------------------------------------\n# Test cases 10.*\n# \nreset_db\nregister_fs_module [sqlite3_connection_pointer db]\n\nproc write_file {path text} {\n  set fd [open $path w]\n  puts -nonewline $fd $text\n  close $fd\n}\n\nwrite_file t1.txt {a b c d e f g h i j k l m n o p q r s t u v w x y z}\nwrite_file t2.txt {a b c d e f g h i j k l m a b c d e f g h i j k l m}\nwrite_file t3.txt {n o p q r s t u v w x y z n o p q r s t u v w x y z}\n\ndo_execsql_test 10.1 {\n  CREATE TABLE idx(id INTEGER PRIMARY KEY, path TEXT);\n  INSERT INTO idx VALUES (1, 't1.txt');\n  INSERT INTO idx VALUES (2, 't2.txt');\n  INSERT INTO idx VALUES (3, 't3.txt');\n\n  CREATE VIRTUAL TABLE vt USING fs(idx);\n  SELECT path, data FROM vt;\n} {\n  1 {a b c d e f g h i j k l m n o p q r s t u v w x y z} \n  2 {a b c d e f g h i j k l m a b c d e f g h i j k l m}\n  3 {n o p q r s t u v w x y z n o p q r s t u v w x y z}\n}\n\ndo_execsql_test 10.2 {\n  SELECT path, data FROM vt WHERE rowid = 2;\n} {\n  2 {a b c d e f g h i j k l m a b c d e f g h i j k l m}\n}\n\ndo_execsql_test 10.3 {\n  CREATE VIRTUAL TABLE ft USING fts4(content=vt);\n  INSERT INTO ft(ft) VALUES('rebuild');\n}\n\ndo_execsql_test 10.4 {\n  SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e'\n} {\n  {...c d [e] f g...} {...c d [e] f g...}\n}\n\ndo_execsql_test 10.5 {\n  SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 't'\n} {\n  {...r s [t] u v...} {...r s [t] u v...}\n}\n\ndo_execsql_test 10.6 { DELETE FROM ft WHERE docid=2 }\n\ndo_execsql_test 10.7 {\n  SELECT snippet(ft, '[', ']', '...', -1, 5) FROM ft WHERE ft MATCH 'e'\n} {\n  {...c d [e] f g...}\n}\n\n#-------------------------------------------------------------------------\n# Test cases 11.*\n# \nreset_db\n\ndo_catchsql_test 11.1 {\n  CREATE VIRTUAL TABLE x1 USING fts4(content=x1);\n} {1 {vtable constructor called recursively: x1}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4docid.test",
    "content": "# 2012 March 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4docid\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Initialize a table with pseudo-randomly generated data.\n#\ndo_execsql_test 1.0 { CREATE VIRTUAL TABLE t1 USING fts4; }\ndo_test 1.1 {\n  foreach {docid content} {\n    0  {F N K B T I K V B A}    1  {D M J E S P H E L O}\n    2  {W U T Q T Q T L H G}    3  {D W H M B R S Z B K}\n    4  {F Q I N P Q J L Z D}    5  {J O Q E Y A O E L B}\n    6  {O V R A C R K C Y H}    7  {Z J H T Q Q O R A G}\n    8  {L K J W G D Y W B M}    9  {K E Y I A Q R Q T S}\n    10 {N P H Y Z M R T I C}    11 {E X H O I S E S Z F}\n    12 {B Y Q T J X C L L J}    13 {Q D C U U A Q E Z U}\n    14 {S I T C J R X S J M}    15 {M X M K E X L H Q Y}\n    16 {O W E I C H U Y S Y}    17 {P V V E M T H C C S}\n    18 {L Y A M I E N M X O}    19 {S Y R U L S Q Y F P}\n    20 {U J S T T J J S V X}    21 {T E I W P O V A A P}\n    22 {W D K H D H F G O J}    23 {T X Y P G M J U I L}\n    24 {F V X E B C N B K W}    25 {E B A Y N N T Z I C}\n    26 {G E E B C P U D H G}    27 {J D J K N S B Q T M}\n    28 {Q T G M D O D Y V G}    29 {P X W I W V P W Z G}\n  } {\n    execsql { INSERT INTO t1(docid, content) VALUES($docid, $content) }\n  }\n} {}\n\n# Quick test regarding affinites and the docid/rowid column.\ndo_execsql_test 2.1.1 { SELECT docid FROM t1 WHERE docid = 5 } {5}\ndo_execsql_test 2.1.2 { SELECT docid FROM t1 WHERE docid = '5' } {5}\ndo_execsql_test 2.1.3 { SELECT docid FROM t1 WHERE docid = +5 } {5}\ndo_execsql_test 2.1.4 { SELECT docid FROM t1 WHERE docid = +'5' } {5}\ndo_execsql_test 2.1.5 { SELECT docid FROM t1 WHERE docid < 5 } {0 1 2 3 4}\ndo_execsql_test 2.1.6 { SELECT docid FROM t1 WHERE docid < '5' } {0 1 2 3 4}\n\ndo_execsql_test 2.2.1 { SELECT rowid FROM t1 WHERE rowid = 5 } {5}\ndo_execsql_test 2.2.2 { SELECT rowid FROM t1 WHERE rowid = '5' } {5}\ndo_execsql_test 2.2.3 { SELECT rowid FROM t1 WHERE rowid = +5 } {5}\ndo_execsql_test 2.2.4 { SELECT rowid FROM t1 WHERE rowid = +'5' } {5}\ndo_execsql_test 2.2.5 { SELECT rowid FROM t1 WHERE rowid < 5 } {0 1 2 3 4}\ndo_execsql_test 2.2.6 { SELECT rowid FROM t1 WHERE rowid < '5' } {0 1 2 3 4}\n\n#-------------------------------------------------------------------------\n# Now test a bunch of full-text queries featuring range constraints on\n# the docid field. Each query is run so that the range constraint:\n#\n#   * is on the docid field,\n#   * is on the docid field with a unary +,\n#   * is on the rowid field,\n#   * is on the rowid field with a unary +.\n#\n# Queries are run with both \"ORDER BY docid DESC\" and \"ORDER BY docid ASC\"\n# clauses.\n#\nforeach {tn where result} {\n  1 {WHERE t1 MATCH 'O' AND xxx < 17}                {1 5 6 7 11 16}\n  2 {WHERE t1 MATCH 'O' AND xxx < 4123456789123456}  {1 5 6 7 11 16 18 21 22 28}\n  3 {WHERE t1 MATCH 'O' AND xxx < 1}                 {}\n  4 {WHERE t1 MATCH 'O' AND xxx < -4123456789123456} {}\n\n  5 {WHERE t1 MATCH 'O' AND xxx > 17}                {18 21 22 28}\n  6 {WHERE t1 MATCH 'O' AND xxx > 4123456789123456}  {}\n  7 {WHERE t1 MATCH 'O' AND xxx > 1}                 {5 6 7 11 16 18 21 22 28}\n  8 {WHERE t1 MATCH 'O' AND xxx > -4123456789123456} {1 5 6 7 11 16 18 21 22 28}\n\n  9 {WHERE t1 MATCH '\"Q T\"' AND xxx < 27}  {2 9 12}\n  10 {WHERE t1 MATCH '\"Q T\"' AND xxx <= 27} {2 9 12 27}\n  11 {WHERE t1 MATCH '\"Q T\"' AND xxx > 27}  {28}\n  12 {WHERE t1 MATCH '\"Q T\"' AND xxx >= 27} {27 28}\n} {\n  foreach {tn2 ref order} {\n    1  docid \"ORDER BY docid ASC\"\n    2 +docid \"ORDER BY docid ASC\"\n    3  rowid \"ORDER BY docid ASC\"\n    4 +rowid \"ORDER BY docid ASC\"\n\n    5  docid \"ORDER BY docid DESC\"\n    6 +docid \"ORDER BY docid DESC\"\n    7  rowid \"ORDER BY docid DESC\"\n    8 +rowid \"ORDER BY docid DESC\"\n  } {\n    set w [string map \"xxx $ref\" $where]\n    set q \"SELECT docid FROM t1 $w $order\"\n\n    if {$tn2<5} {\n      set r [lsort -integer -increasing $result] \n    } else {\n      set r [lsort -integer -decreasing $result] \n    }\n\n    do_execsql_test 3.$tn.$tn2 $q $r\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4growth.test",
    "content": "# 2014 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS4 module.\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts4growth\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nsource $testdir/genesis.tcl\n\ndo_execsql_test 1.1 { CREATE VIRTUAL TABLE x1 USING fts3; }\n\ndo_test 1.2 {\n  foreach L {\n    {\"See here, young man,\" said Mulga Bill, \"from Walgett to the sea,}\n    {From Conroy's Gap to Castlereagh, there's none can ride like me.}\n    {I'm good all round at everything as everybody knows,}\n    {Although I'm not the one to talk -- I hate a man that blows.}\n  } {\n    execsql { INSERT INTO x1 VALUES($L) }\n  }\n  execsql { SELECT end_block, length(root) FROM x1_segdir }\n} {{0 114} 114 {0 118} 118 {0 95} 95 {0 115} 115}\n\ndo_execsql_test 1.3 {\n  INSERT INTO x1(x1) VALUES('optimize');\n  SELECT level, end_block, length(root) FROM x1_segdir;\n} {0 {0 394} 394}\n\ndo_test 1.4 {\n  foreach L {\n    {But riding is my special gift, my chiefest, sole delight;}\n    {Just ask a wild duck can it swim, a wildcat can it fight.}\n    {There's nothing clothed in hair or hide, or built of flesh or steel,}\n    {There's nothing walks or jumps, or runs, on axle, hoof, or wheel,}\n    {But what I'll sit, while hide will hold and girths and straps are tight:}\n    {I'll ride this here two-wheeled concern right straight away at sight.\"}\n  } {\n    execsql { INSERT INTO x1 VALUES($L) }\n  }\n  execsql { \n    INSERT INTO x1(x1) VALUES('merge=4,4');\n    SELECT level, end_block, length(root) FROM x1_segdir;\n  }\n} {1 {224 921} 2}\n\ndo_execsql_test 1.5 {\n  SELECT length(block) FROM x1_segments;\n} {921 {}}\n\ndo_test 1.6 {\n  foreach L {\n    {'Twas Mulga Bill, from Eaglehawk, that sought his own abode,}\n    {That perched above Dead Man's Creek, beside the mountain road.}\n    {He turned the cycle down the hill and mounted for the fray,}\n    {But 'ere he'd gone a dozen yards it bolted clean away.}\n\n    {It left the track, and through the trees, just like a silver steak,}\n    {It whistled down the awful slope towards the Dead Man's Creek.}\n    {It shaved a stump by half an inch, it dodged a big white-box:}\n    {The very wallaroos in fright went scrambling up the rocks,}\n\n    {The wombats hiding in their caves dug deeper underground,}\n    {As Mulga Bill, as white as chalk, sat tight to every bound.}\n    {It struck a stone and gave a spring that cleared a fallen tree,}\n    {It raced beside a precipice as close as close could be;}\n\n    {And then as Mulga Bill let out one last despairing shriek}\n    {It made a leap of twenty feet into the Dead Man's Creek.}\n    {It shaved a stump by half an inch, it dodged a big white-box:}\n    {The very wallaroos in fright went scrambling up the rocks,}\n    {The wombats hiding in their caves dug deeper underground,}\n  } {\n    execsql { INSERT INTO x1 VALUES($L) }\n  }\n  execsql { \n    SELECT level, end_block, length(root) FROM x1_segdir;\n  }\n} {1 {224 921} 2 1 {226 1230} 7 0 {0 98} 98}\n\ndo_execsql_test 1.7 {\n  SELECT sum(length(block)) FROM x1_segments WHERE blockid IN (224,225,226)\n} {1230}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 2.1 { \n  CREATE TABLE t1(docid, words);\n  CREATE VIRTUAL TABLE x2 USING fts4;\n}\nfts_kjv_genesis \ndo_test 2.2 {\n  foreach id [db eval {SELECT docid FROM t1}] {\n    execsql {\n      INSERT INTO x2(docid, content) SELECT $id, words FROM t1 WHERE docid=$id\n    }\n  }\n  foreach id [db eval {SELECT docid FROM t1}] {\n    execsql {\n      INSERT INTO x2(docid, content) SELECT NULL, words FROM t1 WHERE docid=$id\n    }\n    if {[db one {SELECT count(*) FROM x2_segdir WHERE level<2}]==2} break\n  }\n} {}\n\ndo_execsql_test 2.3 { \n  SELECT count(*) FROM x2_segdir WHERE level=2;\n  SELECT count(*) FROM x2_segdir WHERE level=3;\n} {6 0}\n\ndo_execsql_test 2.4 { \n  INSERT INTO x2(x2) VALUES('merge=4,4');\n  SELECT count(*) FROM x2_segdir WHERE level=2;\n  SELECT count(*) FROM x2_segdir WHERE level=3;\n} {6 1}\n\ndo_execsql_test 2.5 { \n  SELECT end_block FROM x2_segdir WHERE level=3;\n  INSERT INTO x2(x2) VALUES('merge=4,4');\n  SELECT end_block FROM x2_segdir WHERE level=3;\n  INSERT INTO x2(x2) VALUES('merge=4,4');\n  SELECT end_block FROM x2_segdir WHERE level=3;\n} {{5588 -3950} {5588 -11766} {5588 -15541}}\n\ndo_execsql_test 2.6 {\n  SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE \n    blockid BETWEEN start_block AND leaves_end_block\n    AND level=3\n} {15541}\n\ndo_execsql_test 2.7 { \n  INSERT INTO x2(x2) VALUES('merge=1000,4');\n  SELECT end_block FROM x2_segdir WHERE level=3;\n} {{5588 127563}}\n\ndo_execsql_test 2.8 {\n  SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE \n    blockid BETWEEN start_block AND leaves_end_block\n    AND level=3\n} {127563}\n\n#--------------------------------------------------------------------------\n# Test that delete markers are removed from FTS segments when possible.\n# It is only possible to remove delete markers when the output of the\n# merge operation will become the oldest segment in the index.\n#\n#   3.1 - when the oldest segment is created by an 'optimize'.\n#   3.2 - when the oldest segment is created by an incremental merge.\n#   3.3 - by a crisis merge.\n#\n\nproc insert_doc {args} {\n  foreach iDoc $args {\n    set L [lindex {\n      {In your eagerness to engage the Trojans,}\n      {don’t any of you charge ahead of others,}\n      {trusting in your strength and horsemanship.}\n      {And don’t lag behind. That will hurt our charge.}\n      {Any man whose chariot confronts an enemy’s}\n      {should thrust with his spear at him from there.}\n      {That’s the most effective tactic, the way}\n      {men wiped out city strongholds long ago —}\n      {their chests full of that style and spirit.}\n    } [expr $iDoc%9]]\n    execsql { REPLACE INTO x3(docid, content) VALUES($iDoc, $L) }\n  }\n}\n\nproc delete_doc {args} {\n  foreach iDoc $args {\n    execsql { DELETE FROM x3 WHERE docid = $iDoc }\n  }\n}\n\nproc second {x} { lindex $x 1 }\ndb func second second\n\ndo_execsql_test 3.0 { CREATE VIRTUAL TABLE x3 USING fts4 }\n\ndo_test 3.1.1 {\n  db transaction { insert_doc 1 2 3 4 5 6 }\n  execsql { SELECT level, idx, second(end_block) FROM x3_segdir }\n} {0 0 412}\ndo_test 3.1.2 {\n  delete_doc 1 2 3 4 5 6\n  execsql { SELECT count(*) FROM x3_segdir }\n} {0}\ndo_test 3.1.3 {\n  db transaction { \n    insert_doc 1 2 3 4 5 6 7 8 9\n    delete_doc 9 8 7\n  }\n  execsql { SELECT level, idx, second(end_block) FROM x3_segdir }\n} {0 0 591 0 1 65 0 2 72 0 3 76}\ndo_test 3.1.4 {\n  execsql { INSERT INTO x3(x3) VALUES('optimize') }\n  execsql { SELECT level, idx, second(end_block) FROM x3_segdir }\n} {0 0 412}\n\ndo_test 3.2.1 {\n  execsql { DELETE FROM x3 }\n  insert_doc 8 7 6 5 4 3 2 1\n  delete_doc 7 8\n  execsql { SELECT count(*) FROM x3_segdir }\n} {10}\ndo_test 3.2.2 {\n  execsql { INSERT INTO x3(x3) VALUES('merge=500,10') }\n  execsql { SELECT level, idx, second(end_block) FROM x3_segdir }\n} {1 0 412}\n\n# This assumes the crisis merge happens when there are already 16 \n# segments and one more is added.\n#\ndo_test 3.3.1 {\n  execsql { DELETE FROM x3 }\n  insert_doc 1 2 3 4 5 6  7 8 9 10 11\n  delete_doc 11 10 9 8 7\n  execsql { SELECT count(*) FROM x3_segdir }\n} {16}\n\ndo_test 3.3.2 {\n  insert_doc 12\n  execsql { SELECT level, idx, second(end_block) FROM x3_segdir WHERE level=1 }\n} {1 0 412}\n\n#--------------------------------------------------------------------------\n# Check a theory on a bug in fts4 - that segments with idx==0 were not \n# being incrementally merged correctly. Theory turned out to be false.\n#\ndo_execsql_test 4.1 {\n  DROP TABLE IF EXISTS x4;\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(docid, words);\n  CREATE VIRTUAL TABLE x4 USING fts4(words);\n}\ndo_test 4.2 {\n  fts_kjv_genesis \n  execsql { INSERT INTO x4 SELECT words FROM t1 }\n  execsql { INSERT INTO x4 SELECT words FROM t1 }\n} {}\n\ndo_execsql_test 4.3 {\n  SELECT level, idx, second(end_block) FROM x4_segdir \n} {0 0 117483 0 1 118006}\n\ndo_execsql_test 4.4 {\n  INSERT INTO x4(x4) VALUES('merge=10,2');\n  SELECT count(*) FROM x4_segdir;\n} {3}\n\ndo_execsql_test 4.5 {\n  INSERT INTO x4(x4) VALUES('merge=10,2');\n  SELECT count(*) FROM x4_segdir;\n} {3}\n\ndo_execsql_test 4.6 {\n  INSERT INTO x4(x4) VALUES('merge=1000,2');\n  SELECT count(*) FROM x4_segdir;\n} {1}\n\n\n\n#--------------------------------------------------------------------------\n# Check that segments are not promoted if the \"end_block\" field does not\n# contain a size.\n#\ndo_execsql_test 5.1 {\n  DROP TABLE IF EXISTS x2;\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(docid, words);\n  CREATE VIRTUAL TABLE x2 USING fts4;\n}\nfts_kjv_genesis \n\nproc first {L} {lindex $L 0}\ndb func first first\n\ndo_test 5.2 {\n  foreach r [db eval { SELECT rowid FROM t1 }] {\n    execsql {\n      INSERT INTO x2(docid, content) SELECT docid, words FROM t1 WHERE rowid=$r\n    }\n  }\n  foreach d [db eval { SELECT docid FROM t1 LIMIT -1 OFFSET 20 }] {\n    execsql { DELETE FROM x2 WHERE docid = $d }\n  }\n\n  execsql {\n    INSERT INTO x2(x2) VALUES('optimize');\n    SELECT level, idx, end_block FROM x2_segdir\n  }\n} {2 0 {752 1926}}\n\ndo_execsql_test 5.3 {\n  UPDATE x2_segdir SET end_block = CAST( first(end_block) AS INTEGER );\n  SELECT end_block, typeof(end_block) FROM x2_segdir;\n} {752 integer}\n\ndo_execsql_test 5.4 {\n  INSERT INTO x2 SELECT words FROM t1 LIMIT 50;\n  SELECT level, idx, end_block FROM x2_segdir\n} {2 0 752 0 0 {758 5174}}\n\ndo_execsql_test 5.5 {\n  UPDATE x2_segdir SET end_block = end_block || ' 1926' WHERE level=2;\n  INSERT INTO x2 SELECT words FROM t1 LIMIT 40;\n  SELECT level, idx, end_block FROM x2_segdir\n} {0 0 {752 1926} 0 1 {758 5174} 0 2 {763 4170}}\n\nproc t1_to_x2 {} {\n  foreach id [db eval {SELECT docid FROM t1 LIMIT 2}] {\n    execsql {\n      DELETE FROM x2 WHERE docid=$id;\n      INSERT INTO x2(docid, content) SELECT $id, words FROM t1 WHERE docid=$id;\n    }\n  }\n}\n\n#--------------------------------------------------------------------------\n# Check that segments created by auto-merge are not promoted until they\n# are completed.\n#\n\ndo_execsql_test 6.1 {\n  CREATE VIRTUAL TABLE x5 USING fts4;\n  INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 0;\n  INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 25;\n  INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 50;\n  INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 75;\n  SELECT count(*) FROM x5_segdir\n} {4}\n\ndo_execsql_test 6.2 {\n  INSERT INTO x5(x5) VALUES('merge=2,4');\n  SELECT level, idx, end_block FROM x5_segdir;\n} {0 0 {10 9216} 0 1 {21 9330} 0 2 {31 8850} 0 3 {40 8689} 1 0 {1320 -3117}}\n\ndo_execsql_test 6.3 {\n  INSERT INTO x5 SELECT words FROM t1 LIMIT 100 OFFSET 100;\n  SELECT level, idx, end_block FROM x5_segdir;\n} {\n  0 0 {10 9216} 0 1 {21 9330} 0 2 {31 8850} \n  0 3 {40 8689} 1 0 {1320 -3117} 0 4 {1329 8297}\n}\n\ndo_execsql_test 6.4 {\n  INSERT INTO x5(x5) VALUES('merge=200,4');\n  SELECT level, idx, end_block FROM x5_segdir;\n} {0 0 {1329 8297} 1 0 {1320 28009}}\n\ndo_execsql_test 6.5 {\n  INSERT INTO x5 SELECT words FROM t1;\n  SELECT level, idx, end_block FROM x5_segdir;\n} {\n  0 1 {1329 8297} 0 0 {1320 28009} 0 2 {1449 118006}\n}\n\n#--------------------------------------------------------------------------\n# Ensure that if part of an incremental merge is performed by an old\n# version that does not support storing segment sizes in the end_block\n# field, no size is stored in the final segment (as it would be incorrect).\n#\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE x6 USING fts4;\n  INSERT INTO x6 SELECT words FROM t1;\n  INSERT INTO x6 SELECT words FROM t1;\n  INSERT INTO x6 SELECT words FROM t1;\n  INSERT INTO x6 SELECT words FROM t1;\n  INSERT INTO x6 SELECT words FROM t1;\n  INSERT INTO x6 SELECT words FROM t1;\n  SELECT level, idx, end_block FROM x6_segdir;\n} {\n  0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006} \n  0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}\n}\n\ndo_execsql_test 7.2 {\n  INSERT INTO x6(x6) VALUES('merge=25,4');\n  SELECT level, idx, end_block FROM x6_segdir;\n} {\n  0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006} \n  0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}\n  1 0 {23694 -69477}\n}\n\ndo_execsql_test 7.3 {\n  UPDATE x6_segdir SET end_block = first(end_block) WHERE level=1;\n  SELECT level, idx, end_block FROM x6_segdir;\n} {\n  0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006} \n  0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}\n  1 0 23694\n}\n\ndo_execsql_test 7.4 {\n  INSERT INTO x6(x6) VALUES('merge=25,4');\n  SELECT level, idx, end_block FROM x6_segdir;\n} {\n  0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006} \n  0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}\n  1 0 23694\n}\n\ndo_execsql_test 7.5 {\n  INSERT INTO x6(x6) VALUES('merge=2500,4');\n  SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;\n} {\n  1 0 719 1171 23694\n}\n\ndo_execsql_test 7.6 {\n  INSERT INTO x6(x6) VALUES('merge=2500,2');\n  SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;\n} {\n  1 0 719 1171 23694\n}\n\ndo_execsql_test 7.7 {\n  SELECT sum(length(block)) FROM x6_segments \n} {635247}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4growth2.test",
    "content": "# 2014 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the FTS4 module.\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix fts4growth2\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nsource $testdir/genesis.tcl\n\ndo_execsql_test 1.0 { CREATE TABLE t1(docid, words); }\nfts_kjv_genesis \n\nproc structure {} {\n  puts [ db eval {SELECT level, count(*) FROM x1_segdir GROUP BY level} ]\n}\n\nproc tt {val} {\n  execsql {\n    DELETE FROM x1 \n      WHERE docid IN (SELECT docid FROM t1 WHERE (rowid-1)%4==$val+0);\n  }\n  execsql {\n    INSERT INTO x1(docid, content) \n      SELECT docid, words FROM t1 WHERE (rowid%4)==$val+0;\n  }\n}\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE x1 USING fts4;\n  INSERT INTO x1(x1) VALUES('automerge=2');\n}\n\ndo_test 1.2 {\n  for {set i 0} {$i < 40} {incr i} {\n    tt 0 ; tt 1 ; tt 2 ; tt 3\n  }\n  execsql { \n    SELECT max(level) FROM x1_segdir; \n    SELECT count(*) FROM x1_segdir WHERE level=2;\n  }\n} {2 1}\n\ndo_test 1.3 {\n  for {set i 0} {$i < 40} {incr i} {\n    tt 0 ; tt 1 ; tt 2 ; tt 3\n  }\n  execsql { \n    SELECT max(level) FROM x1_segdir; \n    SELECT count(*) FROM x1_segdir WHERE level=2;\n  }\n} {2 1}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 2.1 {\n  DELETE FROM t1 WHERE rowid>16;\n  DROP TABLE IF EXISTS x1;\n  CREATE VIRTUAL TABLE x1 USING fts4;\n}\n\ndb func second second\nproc second {L} {lindex $L 1}\n\nfor {set tn 0} {$tn < 40} {incr tn} {\n  do_test 2.2.$tn {\n    for {set i 0} {$i < 100} {incr i} {\n      tt 0 ; tt 1 ; tt 2 ; tt 3\n    }\n    execsql { SELECT max(level) FROM x1_segdir }\n  } {1}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4incr.test",
    "content": "# 2012 March 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4incr\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Create the fts_kjv_genesis procedure which fills and FTS3/4 table \n# with the complete text of the Book of Genesis.\n#\nsource $testdir/genesis.tcl\n\ndo_test 1.0 {\n  execsql { CREATE VIRTUAL TABLE t1 USING fts4(words) }\n  fts_kjv_genesis\n} {}\n\ndo_execsql_test 1.1 {\n  SELECT min(docid), max(docid) FROM t1;\n} {1001001 1050026}\n\nforeach {tn q res} {\n  1 { SELECT count(*) FROM t1 WHERE t1 MATCH 'and' AND docid < 1010000} 224\n  2 { SELECT count(*) FROM t1 WHERE t1 MATCH '\"in the\"' AND docid < 1010000} 47\n  3 { SELECT count(*) FROM t1 WHERE t1 MATCH '\"And God\"' AND docid < 1010000} 33\n  4 { SELECT count(*) FROM t1 WHERE t1 \n      MATCH '\"land of canaan\"' AND docid < 1030000 } 7\n} {\n  foreach s {0 1} {\n    execsql \"INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')\"\n    do_execsql_test 2.$tn.$s $q $res\n    set t($s) [lindex [time [list execsql $q] 100] 0]\n  }\n  if {0} {\n    puts \"with optimization: $t(0)    without: $t(1)\"\n  }\n}\n\ndo_test 2.1 {\n  execsql {\n    CREATE VIRTUAL TABLE t2 USING fts4(order=DESC);\n  }\n  set num [list one two three four five six seven eight nine ten]\n  execsql BEGIN\n  for {set i 0} {$i < 10000} {incr i} {\n    set x \"[lindex $num [expr $i%10]] zero\"\n    execsql { INSERT INTO t2(docid, content) VALUES($i, $x) }\n  }\n  execsql COMMIT\n  execsql { INSERT INTO t2(t2) VALUES('optimize') }\n} {}\n\ndo_execsql_test 2.2 {\n  SELECT count(*) FROM t2 WHERE t2 MATCH '\"never zero\"'\n} {0}\n\ndo_execsql_test 2.3 {\n  SELECT count(*) FROM t2 WHERE t2 MATCH '\"two zero\"'\n} {1000}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4langid.test",
    "content": "# 2012 March 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the languageid=xxx FTS4 option.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset ::testprefix fts4langid\n\n#---------------------------------------------------------------------------\n# Test plan:\n#\n#   1.* - Warm-body tests created for specific purposes during development.\n#         Passing these doesn't really prove much.\n#\n#   2.1.* - Test that FTS queries only ever return rows associated with\n#           the requested language.\n#\n#   2.2.* - Same as 2.1.*, after an 'optimize' command.\n#\n#   2.3.* - Same as 2.1.*, after a 'rebuild' command.\n#\n#   3.* - Tests with content= tables. Both where there is a real \n#         underlying content table and where there is not.\n#\n#   4.* - Test that if one is provided, the tokenizer xLanguage method\n#         is called to configure the tokenizer before tokenizing query\n#         or document text.\n#\n#   5.* - Test the fts4aux table when the associated FTS4 table contains\n#         multiple languages.\n#\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(a, b, languageid=lang_id);\n}\n\ndo_execsql_test 1.2 {\n  SELECT sql FROM sqlite_master WHERE name = 't1_content';\n} {{CREATE TABLE 't1_content'(docid INTEGER PRIMARY KEY, 'c0a', 'c1b', langid)}}\n\ndo_execsql_test 1.3 {SELECT docid FROM t1} {}\ndo_execsql_test 1.4 {SELECT lang_id FROM t1} {}\n\ndo_execsql_test 1.5 {INSERT INTO t1(a, b) VALUES('aaa', 'bbb')}\ndo_execsql_test 1.6 {SELECT lang_id FROM t1 } {0}\n\ndo_execsql_test 1.7 {INSERT INTO t1(a, b, lang_id) VALUES('aaa', 'bbb', 4)}\ndo_execsql_test 1.8 {SELECT lang_id FROM t1 } {0 4}\n\ndo_execsql_test 1.9  {INSERT INTO t1(a, b, lang_id) VALUES('aaa', 'bbb', 'xyz')}\ndo_execsql_test 1.10 {SELECT lang_id FROM t1} {0 4 0}\n\ndo_execsql_test 1.11 {\n  CREATE VIRTUAL TABLE t2 USING fts4;\n  INSERT INTO t2 VALUES('abc');\n} \ndo_execsql_test 1.12 { SELECT rowid FROM t2 WHERE content MATCH 'abc' } 1\n\ndo_execsql_test 1.13 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(languageid=lang_id);\n  INSERT INTO t1(content)          VALUES('a b c');\n  INSERT INTO t1(content, lang_id) VALUES('a b c', 1);\n}\n\ndo_execsql_test 1.14 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'b';\n} {1}\ndo_execsql_test 1.15 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'b' AND lang_id = 0;\n} {1}\n\ndo_execsql_test 1.16 {\n  SELECT rowid FROM t1 WHERE t1 MATCH 'b' AND lang_id = 1;\n} {2}\n\ndo_catchsql_test 1.17 {\n  INSERT INTO t1(content, lang_id) VALUES('123', -1);\n} {1 {constraint failed}}\n\ndo_execsql_test 1.18 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(languageid=lang_id);\n  INSERT INTO t1(content, lang_id) VALUES('A', 13);\n  INSERT INTO t1(content, lang_id) VALUES('B', 13);\n  INSERT INTO t1(content, lang_id) VALUES('C', 13);\n  INSERT INTO t1(content, lang_id) VALUES('D', 13);\n  INSERT INTO t1(content, lang_id) VALUES('E', 13);\n  INSERT INTO t1(content, lang_id) VALUES('F', 13);\n  INSERT INTO t1(content, lang_id) VALUES('G', 13);\n  INSERT INTO t1(content, lang_id) VALUES('H', 13);\n  INSERT INTO t1(content, lang_id) VALUES('I', 13);\n  INSERT INTO t1(content, lang_id) VALUES('J', 13);\n  INSERT INTO t1(content, lang_id) VALUES('K', 13);\n  INSERT INTO t1(content, lang_id) VALUES('L', 13);\n  INSERT INTO t1(content, lang_id) VALUES('M', 13);\n  INSERT INTO t1(content, lang_id) VALUES('N', 13);\n  INSERT INTO t1(content, lang_id) VALUES('O', 13);\n  INSERT INTO t1(content, lang_id) VALUES('P', 13);\n  INSERT INTO t1(content, lang_id) VALUES('Q', 13);\n  INSERT INTO t1(content, lang_id) VALUES('R', 13);\n  INSERT INTO t1(content, lang_id) VALUES('S', 13);\n  SELECT rowid FROM t1 WHERE t1 MATCH 'A';\n} {}\n\n\n#-------------------------------------------------------------------------\n# Test cases 2.*\n#\nproc build_multilingual_db_1 {db} {\n  $db eval { CREATE VIRTUAL TABLE t2 USING fts4(x, y, languageid=l) }\n\n  set xwords [list zero one two three four five six seven eight nine ten]\n  set ywords [list alpha beta gamma delta epsilon zeta eta theta iota kappa]\n\n  for {set i 0} {$i < 1000} {incr i} {\n    set iLangid [expr $i%9]\n    set x \"\"\n    set y \"\"\n\n    set x [list]\n    lappend x [lindex $xwords [expr ($i / 1000) % 10]]\n    lappend x [lindex $xwords [expr ($i / 100)  % 10]]\n    lappend x [lindex $xwords [expr ($i / 10)   % 10]]\n    lappend x [lindex $xwords [expr ($i / 1)   % 10]]\n\n    set y [list]\n    lappend y [lindex $ywords [expr ($i / 1000) % 10]]\n    lappend y [lindex $ywords [expr ($i / 100)  % 10]]\n    lappend y [lindex $ywords [expr ($i / 10)   % 10]]\n    lappend y [lindex $ywords [expr ($i / 1)   % 10]]\n\n    $db eval { INSERT INTO t2(docid, x, y, l) VALUES($i, $x, $y, $iLangid) }\n  }\n\n  $db eval {\n    CREATE TABLE data(x, y, l);\n    INSERT INTO data(rowid, x, y, l) SELECT docid, x, y, l FROM t2;\n  }\n}\n\nproc rowid_list_set_langid {langid} {\n  set ::rowid_list_langid $langid\n}\nproc rowid_list {pattern} {\n  set langid $::rowid_list_langid\n  set res [list]\n  db eval {SELECT rowid, x, y FROM data WHERE l = $langid ORDER BY rowid ASC} {\n    if {[string match \"*$pattern*\" $x] || [string match \"*$pattern*\" $y]} {\n      lappend res $rowid\n    }\n  }\n  return $res\n}\n\nproc or_merge_list {list1 list2} {\n  set res [list]\n\n  set i1 0\n  set i2 0\n\n  set n1 [llength $list1]\n  set n2 [llength $list2]\n\n  while {$i1 < $n1 && $i2 < $n2} {\n    set e1 [lindex $list1 $i1]\n    set e2 [lindex $list2 $i2]\n\n    if {$e1==$e2} {\n      lappend res $e1\n      incr i1\n      incr i2\n    } elseif {$e1 < $e2} {\n      lappend res $e1\n      incr i1\n    } else {\n      lappend res $e2\n      incr i2\n    }\n  }\n\n  concat $res [lrange $list1 $i1 end] [lrange $list2 $i2 end]\n}\n\nproc or_merge_lists {args} {\n  set res [lindex $args 0]\n  for {set i 1} {$i < [llength $args]} {incr i} {\n    set res [or_merge_list $res [lindex $args $i]]\n  }\n  set res\n}\n\nproc and_merge_list {list1 list2} {\n  foreach i $list2 { set a($i) 1 }\n  set res [list]\n  foreach i $list1 {\n    if {[info exists a($i)]} {lappend res $i}\n  }\n  set res\n}\n\n\nproc and_merge_lists {args} {\n  set res [lindex $args 0]\n  for {set i 1} {$i < [llength $args]} {incr i} {\n    set res [and_merge_list $res [lindex $args $i]]\n  }\n  set res\n}\n\nproc filter_list {list langid} {\n  set res [list]\n  foreach i $list {\n    if {($i % 9) == $langid} {lappend res $i}\n  }\n  set res\n}\n\ndo_test 2.0 { \n  reset_db\n  build_multilingual_db_1 db\n} {}\n\nproc do_test_query1 {tn query res_script} {\n  for {set langid 0} {$langid < 10} {incr langid} {\n    rowid_list_set_langid $langid\n    set res [eval $res_script]\n\n    set actual [\n      execsql {SELECT docid FROM t2 WHERE t2 MATCH $query AND l = $langid}\n    ]\n    do_test $tn.$langid [list set {} $actual] $res\n  }\n}\n\n# Run some queries. \ndo_test_query1 2.1.1  {delta}          { rowid_list delta }\ndo_test_query1 2.1.2  {\"zero one two\"} { rowid_list \"zero one two\" }\ndo_test_query1 2.1.3  {zero one two} {\n  and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]\n}\ndo_test_query1 2.1.4  {\"zero one\" OR \"one two\"} {\n  or_merge_lists [rowid_list \"zero one\"] [rowid_list \"one two\"]\n}\n\n# Now try the same tests as above, but after running the 'optimize'\n# command on the FTS table.\n#\ndo_execsql_test 2.2 {\n  INSERT INTO t2(t2) VALUES('optimize');\n  SELECT count(*) FROM t2_segdir;\n} {9}\ndo_test_query1 2.2.1 {delta}          { rowid_list delta }\ndo_test_query1 2.2.2 {\"zero one two\"} { rowid_list \"zero one two\" }\ndo_test_query1 2.2.3 {zero one two} {\n  and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]\n}\ndo_test_query1 2.2.4 {\"zero one\" OR \"one two\"} {\n  or_merge_lists [rowid_list \"zero one\"] [rowid_list \"one two\"]\n}\n\n# And rebuild.\n#\ndo_test 2.3 { \n  reset_db\n  build_multilingual_db_1 db\n  execsql { INSERT INTO t2(t2) VALUES('rebuild') }\n} {}\ndo_test_query1 2.3.1 {delta}          { rowid_list delta }\ndo_test_query1 2.3.2 {\"zero one two\"} { rowid_list \"zero one two\" }\ndo_test_query1 2.3.3 {zero one two} {\n  and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]\n}\ndo_test_query1 2.3.4 {\"zero one\" OR \"one two\"} {\n  or_merge_lists [rowid_list \"zero one\"] [rowid_list \"one two\"]\n}\n\n#-------------------------------------------------------------------------\n# Test cases 3.*\n#\ndo_test 3.0 {\n  reset_db\n  build_multilingual_db_1 db\n  execsql {\n    CREATE TABLE t3_data(l, x, y);\n    INSERT INTO t3_data(rowid, l, x, y) SELECT docid, l, x, y FROM t2;\n    DROP TABLE t2;\n  }\n} {}\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(content=t3_data, languageid=l);\n  INSERT INTO t2(t2) VALUES('rebuild');\n}\n\ndo_test_query1 3.1.1 {delta}          { rowid_list delta }\ndo_test_query1 3.1.2 {\"zero one two\"} { rowid_list \"zero one two\" }\ndo_test_query1 3.1.3 {zero one two} {\n  and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]\n}\ndo_test_query1 3.1.4 {\"zero one\" OR \"one two\"} {\n  or_merge_lists [rowid_list \"zero one\"] [rowid_list \"one two\"]\n}\n\ndo_execsql_test 3.2.1 {\n  DROP TABLE t2;\n  CREATE VIRTUAL TABLE t2 USING fts4(x, y, languageid=l, content=nosuchtable);\n}\n\ndo_execsql_test 3.2.2 {\n  INSERT INTO t2(docid, x, y, l) SELECT rowid, x, y, l FROM t3_data;\n}\n\ndo_execsql_test 3.2.3 {\n  DROP TABLE t3_data;\n}\n\ndo_test_query1 3.3.1 {delta}          { rowid_list delta }\ndo_test_query1 3.3.2 {\"zero one two\"} { rowid_list \"zero one two\" }\ndo_test_query1 3.3.3 {zero one two} {\n  and_merge_lists [rowid_list zero] [rowid_list one] [rowid_list two]\n}\ndo_test_query1 3.3.4 {\"zero one\" OR \"one two\"} {\n  or_merge_lists [rowid_list \"zero one\"] [rowid_list \"one two\"]\n}\n\ndo_execsql_test 3.4 {\n  CREATE TABLE t8c(a, b);\n  CREATE VIRTUAL TABLE t8 USING fts4(content=t8c, languageid=langid);\n  INSERT INTO t8(docid, a, b) VALUES(-1, 'one two three', 'x y z');\n  SELECT docid FROM t8 WHERE t8 MATCH 'one x' AND langid=0\n} {-1}\n\n#-------------------------------------------------------------------------\n# Test cases 4.*\n#\nproc build_multilingual_db_2 {db} {\n  $db eval {\n    CREATE VIRTUAL TABLE t4 USING fts4(\n        tokenize=testtokenizer, \n        languageid=lid\n    );\n  }\n  for {set i 0} {$i < 50} {incr i} {\n    execsql { \n      INSERT INTO t4(docid, content, lid) VALUES($i, 'The Quick Brown Fox', $i) \n    }\n  }\n}\n\ndo_test 4.1.0 {\n  reset_db\n  set ptr [fts3_test_tokenizer]\n  sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1\n  execsql { SELECT fts3_tokenizer('testtokenizer', $ptr) }\n  build_multilingual_db_2 db\n} {}\ndo_execsql_test 4.1.1 {\n  SELECT docid FROM t4 WHERE t4 MATCH 'quick';\n} {0}\ndo_execsql_test 4.1.2 {\n  SELECT docid FROM t4 WHERE t4 MATCH 'quick' AND lid=1;\n} {}\ndo_execsql_test 4.1.3 {\n  SELECT docid FROM t4 WHERE t4 MATCH 'Quick' AND lid=1;\n} {1}\nfor {set i 0} {$i < 50} {incr i} {\n  do_execsql_test 4.1.4.$i {\n    SELECT count(*) FROM t4 WHERE t4 MATCH 'fox' AND lid=$i;\n  } [expr 0==($i%2)]\n}\ndo_catchsql_test 4.1.5 {\n  INSERT INTO t4(content, lid) VALUES('hello world', 101)\n} {1 {SQL logic error}}\n\n#-------------------------------------------------------------------------\n# Test cases 5.*\n#\n# The following test cases are designed to detect a 32-bit overflow bug\n# that existed at one point.\n#\nproc build_multilingual_db_3 {db} {\n  $db eval {\n    CREATE VIRTUAL TABLE t5 USING fts4(languageid=lid);\n  }\n  set languages [list 0 1 2 [expr 1<<30]]\n\n  foreach lid $languages {\n    execsql {\n      INSERT INTO t5(docid, content, lid) VALUES(\n          $lid, 'My language is ' || $lid, $lid\n      ) \n    }\n  }\n}\n\ndo_test 5.1.0 {\n  reset_db\n  build_multilingual_db_3 db\n} {}\n\ndo_execsql_test 5.1.1 {\n  SELECT level FROM t5_segdir;\n} [list 0 1024 2048 [expr 1<<40]]\n\ndo_execsql_test 5.1.2 {SELECT docid FROM t5 WHERE t5 MATCH 'language'} 0\nforeach langid [list 0 1 2 [expr 1<<30]] {\n  do_execsql_test 5.2.$langid { \n    SELECT docid FROM t5 WHERE t5 MATCH 'language' AND lid = $langid\n  } $langid\n}\n\nset lid [expr 1<<30]\ndo_execsql_test 5.3.1 {\n  CREATE VIRTUAL TABLE t6 USING fts4(languageid=lid);\n  INSERT INTO t6 VALUES('I belong to language 0!');\n}\ndo_test 5.3.2 {\n  for {set i 0} {$i < 20} {incr i} {\n    execsql {\n      INSERT INTO t6(content, lid) VALUES(\n        'I (row '||$i||') belong to langauge N!', $lid\n      );\n    }\n  }\n  execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' }\n} {1}\n\ndo_test 5.3.3 {\n  execsql { SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid}\n} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21}\n\ndo_execsql_test 5.3.4 { INSERT INTO t6(t6) VALUES('optimize') } {}\ndo_execsql_test 5.3.5 { SELECT docid FROM t6 WHERE t6 MATCH 'belong' } {1}\ndo_execsql_test 5.3.6 { \n  SELECT docid FROM t6 WHERE t6 MATCH 'belong' AND lid=$lid\n} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21}\n\n\nset lid [expr 1<<30]\nforeach lid [list 4 [expr 1<<30]] {\n  do_execsql_test 5.4.$lid.1 {\n    DELETE FROM t6;\n    SELECT count(*) FROM t6_segdir;\n    SELECT count(*) FROM t6_segments;\n  } {0 0}\n  do_execsql_test 5.4.$lid.2 {\n    INSERT INTO t6(content, lid) VALUES('zero zero zero', $lid);\n    INSERT INTO t6(content, lid) VALUES('zero zero one', $lid);\n    INSERT INTO t6(content, lid) VALUES('zero one zero', $lid);\n    INSERT INTO t6(content, lid) VALUES('zero one one', $lid);\n    INSERT INTO t6(content, lid) VALUES('one zero zero', $lid);\n    INSERT INTO t6(content, lid) VALUES('one zero one', $lid);\n    INSERT INTO t6(content, lid) VALUES('one one zero', $lid);\n    INSERT INTO t6(content, lid) VALUES('one one one', $lid);\n\n    SELECT docid FROM t6 WHERE t6 MATCH '\"zero zero\"' AND lid=$lid;\n  } {1 2 5}\n\n  do_execsql_test 5.4.$lid.3 {\n    SELECT count(*) FROM t6_segdir;\n    SELECT count(*) FROM t6_segments;\n  } {8 0}\n\n  do_execsql_test 5.4.$lid.4 {\n    INSERT INTO t6(t6) VALUES('merge=100,3');\n    INSERT INTO t6(t6) VALUES('merge=100,3');\n    SELECT docid FROM t6 WHERE t6 MATCH '\"zero zero\"' AND lid=$lid;\n  } {1 2 5}\n\n  do_execsql_test 5.4.$lid.5 {\n    SELECT count(*) FROM t6_segdir;\n    SELECT count(*) FROM t6_segments;\n  } {1 2}\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4lastrowid.test",
    "content": "# 2017 Feb 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests of the last_insert_rowid functionality with fts4.\n#\n\nset testdir [file dirname $argv0]\nsource [file join [file dirname [info script]] tester.tcl]\nset testprefix fts4lastrowid\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE t1 USING fts4(str);\n}\n\ndo_execsql_test 1.1 {\n  INSERT INTO t1 VALUES('one string');\n  INSERT INTO t1 VALUES('two string');\n  INSERT INTO t1 VALUES('three string');\n  SELECT last_insert_rowid();\n} {3}\n\ndo_execsql_test 1.2 {\n  BEGIN;\n    INSERT INTO t1 VALUES('one string');\n    INSERT INTO t1 VALUES('two string');\n    INSERT INTO t1 VALUES('three string');\n  COMMIT;\n  SELECT last_insert_rowid();\n} {6}\n\ndo_execsql_test 1.3 {\n  INSERT INTO t1(rowid, str) VALUES(-22, 'some more text');\n  SELECT last_insert_rowid();\n} {-22}\n\ndo_execsql_test 1.4 {\n  BEGIN;\n    INSERT INTO t1(rowid, str) VALUES(45, 'some more text');\n    INSERT INTO t1(rowid, str) VALUES(46, 'some more text');\n    INSERT INTO t1(rowid, str) VALUES(222, 'some more text');\n    SELECT last_insert_rowid();\n  COMMIT;\n  SELECT last_insert_rowid();\n} {222 222}\n\ndo_execsql_test 1.5 {\n  CREATE TABLE x1(x);\n  INSERT INTO x1 VALUES('john'), ('paul'), ('george'), ('ringo');\n  INSERT INTO t1 SELECT x FROM x1;\n  SELECT last_insert_rowid();\n} {226}\n\ndo_execsql_test 1.6 {\n  INSERT INTO t1(rowid, str) SELECT rowid+10, x FROM x1;\n  SELECT last_insert_rowid();\n} {14}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4merge.test",
    "content": "# 2012 March 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the incremental merge function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nproc fts3_integrity_check {tbl} {\n  db eval \"INSERT INTO $tbl ($tbl) VALUES('integrity-check')\"\n  return \"ok\"\n}\n\nforeach mod {fts3 fts4} {\n  set ::testprefix fts4merge-$mod\n  reset_db\n\n  #-------------------------------------------------------------------------\n  # Test cases 1.*\n  #\n  do_test 1.0 { fts3_build_db_1 -module $mod 1004 } {}\n  do_test 1.1 { fts3_integrity_check t1 } {ok}\n  do_execsql_test 1.1 { \n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level \n  } {\n    0 {0 1 2 3 4 5 6 7 8 9 10 11} \n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}\n    2 {0 1 2}\n  }\n  \n  for {set i 0} {$i<20} {incr i} {\n    do_execsql_test 1.2.$i.1 { INSERT INTO t1(t1) VALUES('merge=1') }\n    do_test 1.2.$i.2 { fts3_integrity_check t1 } ok\n    do_execsql_test 1.2.$i.3 { \n      SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'\n    } {123 132 213 231 312 321}\n  }\n  \n  do_execsql_test 1.3 { \n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level \n  } {\n    2 {0 1 2 3}\n  }\n  \n  for {set i 0} {$i<100} {incr i} {\n    do_execsql_test 1.4.$i { INSERT INTO t1(t1) VALUES('merge=1,4') }\n    do_test 1.4.$i.2 { fts3_integrity_check t1 } ok\n    do_execsql_test 1.4.$i.3 { \n      SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'\n    } {123 132 213 231 312 321}\n  }\n  \n  do_execsql_test 1.5 { \n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level \n  } {\n    3 0\n  }\n  \n  #-------------------------------------------------------------------------\n  # Test cases 2.* test that errors in the xxx part of the 'merge=xxx' are\n  # handled correctly.\n  #\n  do_execsql_test 2.0 \"CREATE VIRTUAL TABLE t2 USING $mod\"\n  \n  foreach {tn arg} {\n    1   {merge=abc}\n    2   {merge=%%%}\n    3   {merge=,}\n    4   {merge=5,}\n    5   {merge=6,%}\n    6   {merge=6,six}\n    7   {merge=6,1}\n  } {\n    do_catchsql_test 2.$tn { \n      INSERT INTO t2(t2) VALUES($arg);\n    } {1 {SQL logic error}}\n  }\n  \n  #-------------------------------------------------------------------------\n  # Test cases 3.*\n  #\n  do_test 3.0 { \n    reset_db\n    execsql { PRAGMA page_size = 512 }\n    fts3_build_db_2 -module $mod 30040 \n  } {}\n  do_test 3.1 { fts3_integrity_check t2 } {ok}\n  \n  do_execsql_test 3.2 { \n    SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level \n  } {\n    0 {0 1 2 3 4 5 6} \n    1 {0 1 2 3 4} \n    2 {0 1 2 3 4} \n    3 {0 1 2 3 4 5 6}\n  }\n  \n  do_execsql_test 3.3 { \n    INSERT INTO t2(t2) VALUES('merge=1000000,2');\n    SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level \n  } {\n    4 0\n  }\n  \n  #-------------------------------------------------------------------------\n  # Test cases 4.*\n  #\n  reset_db\n  do_execsql_test 4.1 \"\n    PRAGMA page_size = 512;\n    CREATE VIRTUAL TABLE t4 USING $mod;\n    PRAGMA main.page_size;\n  \" {512}\n  \n  do_test 4.2 {\n    foreach x {a c b d e f g h i j k l m n o p} {\n      execsql \"INSERT INTO t4 VALUES('[string repeat $x 600]')\"\n    }\n    execsql {SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level}\n  } {0 {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}}\n  \n  foreach {tn expect} {\n    1  \"0 {0 1 2 3 4 5 6 7 8 9 10 11 12 13} 1 0\"\n    2  \"0 {0 1 2 3 4 5 6 7 8 9 10 11 12}    1 0\"\n    3  \"0 {0 1 2 3 4 5 6 7 8 9 10 11}       1 0\"\n    4  \"0 {0 1 2 3 4 5 6 7 8 9 10}          1 0\"\n    5  \"0 {0 1 2 3 4 5 6 7 8 9}             1 0\"\n    6  \"0 {0 1 2 3 4 5 6 7 8}               1 0\"\n    7  \"0 {0 1 2 3 4 5 6 7}                 1 0\"\n    8  \"0 {0 1 2 3 4 5 6}                   1 0\"\n    9  \"0 {0 1 2 3 4 5}                     1 0\"\n  } {\n    do_execsql_test 4.3.$tn {\n      INSERT INTO t4(t4) VALUES('merge=1,16');\n      SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;\n    } $expect\n  }\n  \n  do_execsql_test 4.4.1 {\n    SELECT quote(value) FROM t4_stat WHERE rowid=1\n  } {X'0006'}\n  \n  do_execsql_test 4.4.2 {\n    DELETE FROM t4_stat WHERE rowid=1;\n    INSERT INTO t4(t4) VALUES('merge=1,12');\n    SELECT level, group_concat(idx, ' ') FROM t4_segdir GROUP BY level;\n  } \"0 {0 1 2 3 4 5}                     1 0\"\n  \n  \n  #-------------------------------------------------------------------------\n  # Test cases 5.*\n  #\n  # Test that if a crisis-merge occurs that disrupts an ongoing incremental\n  # merge, the next call to \"merge=A,B\" identifies this and starts a new\n  # incremental merge. There are two scenarios:\n  #\n  #   * There are less segments on the input level that the disrupted\n  #     incremental merge operated on, or\n  #   \n  #   * Sufficient segments exist on the input level but the segments \n  #     contain keys smaller than the largest key in the potential output \n  #     segment.\n  # \n  do_test 5.1 {\n    reset_db\n    fts3_build_db_1 -module $mod 1000\n  } {}\n  \n  do_execsql_test 5.2 {\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n  } {\n    0 {0 1 2 3 4 5 6 7} \n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13} \n    2 {0 1 2}\n  }\n  \n  do_execsql_test 5.3 {\n    INSERT INTO t1(t1) VALUES('merge=1,5');\n    INSERT INTO t1(t1) VALUES('merge=1,5');\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n  } {\n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14} \n    2 {0 1 2 3}\n  }\n  \n  do_execsql_test 5.4 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}\n  do_test 5.5 {\n    foreach docid [execsql {SELECT docid FROM t1}] {\n      execsql {INSERT INTO t1 SELECT * FROM t1 WHERE docid=$docid}\n    }\n  } {}\n  \n  do_execsql_test 5.6 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}\n  \n  do_execsql_test 5.7 {\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n    SELECT quote(value) from t1_stat WHERE rowid=1;\n  } {\n    0 {0 1 2 3 4 5 6 7} \n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12} \n    2 {0 1 2 3 4 5 6 7} \n    X'010F'\n  }\n  \n  do_execsql_test 5.8 {\n    INSERT INTO t1(t1) VALUES('merge=1,6');\n    INSERT INTO t1(t1) VALUES('merge=1,6');\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n    SELECT quote(value) from t1_stat WHERE rowid=1;\n  } {\n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13} \n    2 {0 1 2 3 4 5 6 7 8} X'010E'\n  }\n  \n  do_test 5.8.1 { fts3_integrity_check t1 } ok\n  \n  do_test 5.9 {\n    set L [expr 16*16*7 + 16*3 + 12]\n    foreach docid [execsql {\n        SELECT docid FROM t1 UNION ALL SELECT docid FROM t1 LIMIT $L\n    }] {\n      execsql {INSERT INTO t1 SELECT * FROM t1 WHERE docid=$docid}\n    }\n  } {}\n  \n  do_execsql_test 5.10 {\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n    SELECT quote(value) from t1_stat WHERE rowid=1;\n  } {\n    0 {0 1 2 3 4 5 6 7 8 9 10 11} 1 0 2 0 3 0 X'010E'\n  }\n  \n  do_execsql_test 5.11 {\n    INSERT INTO t1(t1) VALUES('merge=1,6');\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;\n    SELECT quote(value) from t1_stat WHERE rowid=1;\n  } {\n    1 {0 1} 2 0 3 0 X'010E'\n  }\n  \n  #-------------------------------------------------------------------------\n  # Test cases 6.*\n  #\n  # At one point the following test caused an assert() to fail (because the\n  # second 'merge=1,2' operation below actually \"merges\" a single input\n  # segment, which was unexpected).\n  #\n  do_test 6.1 {\n    reset_db\n    set a [string repeat a 900]\n    set b [string repeat b 900]\n    set c [string repeat c 900]\n    set d [string repeat d 900]\n\n    execsql \"CREATE VIRTUAL TABLE t1 USING $mod\"\n    execsql {\n      BEGIN;\n        INSERT INTO t1 VALUES($a);\n        INSERT INTO t1 VALUES($b);\n      COMMIT;\n      BEGIN;\n        INSERT INTO t1 VALUES($c);\n        INSERT INTO t1 VALUES($d);\n      COMMIT;\n    }\n  \n    execsql {\n      INSERT INTO t1(t1) VALUES('merge=1,2');\n      INSERT INTO t1(t1) VALUES('merge=1,2');\n    }\n  } {}\n  \n  #-------------------------------------------------------------------------\n  # Test cases 7.*\n  #\n  # Test that the value returned by sqlite3_total_changes() increases by\n  # 1 following a no-op \"merge=A,B\", or by more than 1 if actual work is\n  # performed.\n  #\n  do_test 7.0 {\n    reset_db\n    fts3_build_db_1 -module $mod 1000\n  } {}\n  \n  do_execsql_test 7.1 {\n    SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level\n  } {\n    0 {0 1 2 3 4 5 6 7} \n    1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13} \n    2 {0 1 2}\n  }\n  do_test 7.2 {\n    set x [db total_changes]\n    execsql { INSERT INTO t1(t1) VALUES('merge=2,10') }\n    expr { ([db total_changes] - $x)>1 }\n  } {1}\n  do_test 7.3 {\n    set x [db total_changes]\n    execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }\n    expr { ([db total_changes] - $x)>1 }\n  } {1}\n  do_test 7.4 {\n    set x [db total_changes]\n    execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }\n    expr { ([db total_changes] - $x)>1 }\n  } {0}\n  do_test 7.5 {\n    set x [db total_changes]\n    execsql { INSERT INTO t1(t1) VALUES('merge=200,10') }\n    expr { ([db total_changes] - $x)>1 }\n  } {0}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4merge2.test",
    "content": "\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix fts4merge2\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_test 1.0 {\n  fts3_build_db_1 1000\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 1.1 -faults oom-* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO t1(t1) VALUES('merge=32,4') }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\ndo_faultsim_test 1.2 -faults oom-t* -prep {\n  if {$iFail<100} {set iFail 803}\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO t1(t1) VALUES('merge=1,2') }\n  execsql { INSERT INTO t1(t1) VALUES('merge=1,2') }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4merge3.test",
    "content": "# 2012 March 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the incremental merge function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/bc_common.tcl\n\nset ::testprefix fts4merge3\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nif {\"\" == [bc_find_binaries backcompat.test]} {\n  finish_test\n  return\n}\n\ndb close\ndo_all_bc_test {\n\n  sql2 { PRAGMA page_size = 512 }\n  if { 0==[catch { sql2 { CREATE VIRTUAL TABLE x USING fts4 } } ] } {\n\n    # Build a large database.\n    set msg \"this takes around 12 seconds\"\n    do_test \"1.1 ($msg)\" { fts3_build_db_2 20000 } {}\n\n    # Run some queries on it, using the old and new versions.\n    do_test 1.2 { sql1 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" } {1485}\n    do_test 1.3 { sql2 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" } {1485}\n\n    do_test 1.4 {\n      set x [sql2 \"PRAGMA page_count\"]\n      expr {$x>=1284 && $x<=1286}\n    } {1}\n    do_test 1.5 { sql2 { \n      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1\n    } } [list 0 15    1 1     2 14    3 4]\n\n    # Run some incr-merge operations on the db.\n    for {set i 0} {$i<10} {incr i} {\n      do_test 1.6.$i.1 { sql1 { INSERT INTO t2(t2) VALUES('merge=2,2') } } {}\n      do_test 1.6.$i.2 { \n        sql2 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" \n      } {1485}\n    }\n\n    do_test 1.7 { sql2 { \n      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1\n    } } {2 15 3 5}\n\n    # Using the old connection, insert many rows. \n    do_test 1.8 {\n      for {set i 0} {$i < 1500} {incr i} {\n        sql2 \"INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i\"\n      }\n    } {}\n\n    do_test 1.9 { sql2 { \n      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1\n    } } [list  0 12  1 13  2 4  3 6]\n\n    # Run a big incr-merge operation on the db.\n    do_test 1.10 { sql1 { INSERT INTO t2(t2) VALUES('merge=2000,2') } } {}\n    do_test 1.11 { \n      sql2 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" \n    } {1485 21485}\n\n    do_test 1.12 {\n      for {set i 0} {$i < 1500} {incr i} {\n        sql2 \"INSERT INTO t2 SELECT content FROM t2 WHERE docid = $i\"\n      }\n    } {}\n    do_test 1.13 { \n      sql2 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" \n    } {1485 21485 22985}\n\n    do_test 1.14 { \n      sql2 \"INSERT INTO t2(t2) VALUES('optimize')\"\n      sql2 \"SELECT docid FROM t2 WHERE t2 MATCH 'abc'\" \n    } {1485 21485 22985}\n\n    do_test 1.15 { sql2 { \n      SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1\n    } } {4 1}\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4merge4.test",
    "content": "# 2013 May 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4merge4\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\ndo_execsql_test 1.1 { CREATE VIRTUAL TABLE t1 USING fts4 }\n\ndo_test 1.2 {\n  for {set i 0} {$i < 2000} {incr i} {\n    execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}\n  }\n} {}\n\ndo_test 1.3 {\n  execsql BEGIN\n  for {set i 0} {$i < 2000} {incr i} {\n    execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}\n  }\n  execsql {\n    INSERT INTO t1(t1) VALUES('merge=8,50');\n    COMMIT\n  }\n} {}\n\nreset_db\ndo_execsql_test 2.0 { CREATE VIRTUAL TABLE t1 USING fts4 }\ndo_test 2.1 {\n  for {set i 0} {$i < 2000} {incr i} {\n    execsql {INSERT INTO t1 VALUES('a b c d e f g h i j k l');}\n  }\n} {}\ndo_execsql_test 2.2 { SELECT count(*) FROM t1_segdir; } 35\ndo_execsql_test 2.3 { INSERT INTO t1(t1) VALUES('optimize') } {}\ndo_execsql_test 2.4 { SELECT count(*) FROM t1_segdir; } 1\n\n#-------------------------------------------------------------------------\n# Now test that the automerge=? option appears to work.\n#\ndo_execsql_test 2.1 { CREATE VIRTUAL TABLE t2 USING fts4; }\n\nset doc \"\"\nforeach c1 \"a b c d e f g h i j\" {\n  foreach c2 \"a b c d e f g h i j\" {\n    foreach c3 \"a b c d e f g h i j\" {\n      lappend doc \"$c1$c2$c3\"\n    }\n  }\n}\nset doc [string repeat $doc 10]\n\nforeach {tn am expected} {\n  1 {automerge=2} {1 1   2 1   4 1   6 1}\n  2 {automerge=4} {1 2   2 1   3 1}\n  3 {automerge=8} {0 4   1 3   2 1}\n  4 {automerge=1} {0 4   1 3   2 1}\n} {\n  foreach {tn2 openclose} {1 {} 2 { db close ; sqlite3 db test.db }} {\n    do_test 2.2.$tn.$tn2 {\n      execsql { DELETE FROM t2 }\n      execsql { INSERT INTO t2(t2) VALUES($am) };\n\n      eval $openclose\n  \n      for {set i 0} {$i < 100} {incr i} {\n        execsql { \n          BEGIN;\n            INSERT INTO t2 VALUES($doc);\n            INSERT INTO t2 VALUES($doc);\n            INSERT INTO t2 VALUES($doc);\n            INSERT INTO t2 VALUES($doc);\n            INSERT INTO t2 VALUES($doc);\n          COMMIT;\n        }\n      }\n  \n      execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }\n    } [list {*}$expected]\n  }\n}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4noti.test",
    "content": "# 2013 June 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the notindexed=xxx FTS4 option.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix fts4noti\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------------\n# Test that typos in \"notindexed=\" column names are detected.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE cc(a, b, c);\n}\nforeach {tn arg res} {\n  1 \"(b, c, notindexed=a)\"                  {1 {no such column: a}}\n  2 \"(a, b, notindexed=a)\"                                   {0 {}}\n  3 \"(a, b, notindexed=a, notindexed=a)\"                     {0 {}}\n  4 \"(notindexed=a, a, b)\"                                   {0 {}}\n  5 \"(notindexed=a, notindexed=b, notindexed=c, a, b, c, d)\" {0 {}}\n  6 \"(notindexed=a, notindexed=B, notindexed=c, a, b, c, d)\" {0 {}}\n  7 \"(notindexed=a, notindexed=b, notindexed=c, a, B, c, d)\" {0 {}}\n  8 \"(notindexed=d, content=cc)\" {1 {no such column: d}}\n  9 \"(notindexed=a, content=cc)\" {0 {}}\n  10 \"(notindexed=a, notindexed=b, a)\" {1 {no such column: b}}\n  11 \"(notindexed=a, notindexed=b, b)\" {1 {no such column: a}}\n} {\n  do_catchsql_test 1.$tn \"CREATE VIRTUAL TABLE t1 USING fts4 $arg\" $res\n  if {[lindex $res 0]==0} { execsql \"DROP TABLE t1\" }\n}\n\ndo_execsql_test 1.x { SELECT name FROM sqlite_master } {cc}\n\n\n#-------------------------------------------------------------------------\n# Test that notindexed columns are not indexed.\n#\nforeach {tn schema} {\n  1 { \n    CREATE VIRTUAL TABLE t1 USING fts4(a, b, c, notindexed=b); \n  }\n  2 { \n    CREATE TABLE c1(a, b, c);\n    INSERT INTO c1 VALUES('one two', 'three four', 'five six');\n    INSERT INTO c1 VALUES('three four', 'five six', 'one two');\n    CREATE VIRTUAL TABLE t1 USING fts4(content=c1, notindexed=b); \n  }\n  3 { \n    CREATE VIRTUAL TABLE t1 USING fts4(content=\"\", a, b, c, notindexed=b); \n  }\n} {\n  execsql $schema\n\n  do_execsql_test 2.$tn.1 {\n    INSERT INTO t1(docid,a,b,c) VALUES(1, 'one two', 'three four', 'five six');\n    INSERT INTO t1(docid,a,b,c) VALUES(2, 'three four', 'five six', 'one two');\n  }\n\n  do_execsql_test 2.$tn.2 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}\n  do_execsql_test 2.$tn.3 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}\n  do_execsql_test 2.$tn.4 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}\n\n  do_execsql_test 2.$tn.5 { INSERT INTO t1(t1) VALUES('optimize') }\n\n  do_execsql_test 2.$tn.6 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}\n  do_execsql_test 2.$tn.7 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}\n  do_execsql_test 2.$tn.8 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}\n\n  if {$tn!=3} {\n    do_execsql_test 2.$tn.9 { INSERT INTO t1(t1) VALUES('rebuild') }\n  \n    do_execsql_test 2.$tn.10 { SELECT docid FROM t1 WHERE t1 MATCH 'one' } {1 2}\n    do_execsql_test 2.$tn.11 { SELECT docid FROM t1 WHERE t1 MATCH 'three' } {2}\n    do_execsql_test 2.$tn.12 { SELECT docid FROM t1 WHERE t1 MATCH 'five' } {1}\n  \n    do_execsql_test 2.$tn.13 { \n      SELECT a,b,c FROM t1 WHERE docid=1\n    } {{one two} {three four} {five six}}\n    do_execsql_test 2.$tn.14 { \n      SELECT a,b,c FROM t1 WHERE docid=2\n    } {{three four} {five six} {one two}}\n  }\n\n  do_execsql_test 2.x { DROP TABLE t1 }\n}\n\n#-------------------------------------------------------------------------\n# Test that notindexed columns are not scanned for deferred tokens.\n#\n\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(x, y, notindexed=x);\n}\ndo_test 3.2 {\n  set v [string repeat \" 1\" 50000]\n  set v1 \"x $v\"\n  set v2 \"y $v\"\n  execsql { \n    INSERT INTO t2 VALUES(1, 'x y z');\n    INSERT INTO t2 VALUES(2, $v1);\n    INSERT INTO t2 VALUES(3, $v2);\n    INSERT INTO t2 VALUES(4, $v2);\n    INSERT INTO t2 VALUES(5, $v2);\n    INSERT INTO t2 VALUES(6, $v2);\n  }\n} {}\n\ndo_execsql_test 3.3 { SELECT x FROM t2 WHERE t2 MATCH '2' } {}\ndo_execsql_test 3.4 { SELECT x FROM t2 WHERE t2 MATCH '1' } {2 3 4 5 6}\ndo_execsql_test 3.5 { SELECT x FROM t2 WHERE t2 MATCH 'x' } {1 2}\ndo_execsql_test 3.6 { SELECT x FROM t2 WHERE t2 MATCH 'x 1' } {2}\n\ndo_execsql_test 3.x { DROP TABLE t2 }\n  \n#-------------------------------------------------------------------------\n# Test that the types of notindexed columns are not modified.\n#\ndo_execsql_test 4.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(poi, addr, notindexed=poi);\n  INSERT INTO t2 VALUES(114, 'x x x');\n  INSERT INTO t2 VALUES(X'1234', 'y y y');\n  INSERT INTO t2 VALUES(NULL, 'z z z');\n  INSERT INTO t2 VALUES(113.2, 'w w w');\n  INSERT INTO t2 VALUES('poi', 'v v v');\n}\ndo_execsql_test 4.2 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'x' } {integer}\ndo_execsql_test 4.3 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'y' } {blob}\ndo_execsql_test 4.4 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'z' } {null}\ndo_execsql_test 4.5 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'w' } {real}\ndo_execsql_test 4.6 { SELECT typeof(poi) FROM t2 WHERE t2 MATCH 'v' } {text}\n\ndo_execsql_test 4.x { DROP TABLE t2 }\n\n#-------------------------------------------------------------------------\n# Test that multiple notindexed options on a single table work as expected.\n#\ndo_execsql_test 5.1 {\n  CREATE VIRTUAL TABLE t2 USING fts4(\n      notindexed=\"three\", one, two, three, notindexed=\"one\",\n  );\n  INSERT INTO t2 VALUES('a', 'b', 'c');\n  INSERT INTO t2 VALUES('c', 'a', 'b');\n  INSERT INTO t2 VALUES('b', 'c', 'a');\n}\ndo_execsql_test 5.2 { SELECT docid FROM t2 WHERE t2 MATCH 'a' } {2}\ndo_execsql_test 5.3 { SELECT docid FROM t2 WHERE t2 MATCH 'b' } {1}\ndo_execsql_test 5.4 { SELECT docid FROM t2 WHERE t2 MATCH 'c' } {3}\n\ndo_execsql_test 5.x { DROP TABLE t2 }\n\n#-------------------------------------------------------------------------\n# Check that if an indexed column name is a prefix of a notindexed column\n# name, the column is still correctly tokenized. This was a problem at one\n# point.\ndo_execsql_test 6.1.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(\n    poiCategory, poiCategoryId, notindexed=poiCategoryId\n  );\n  INSERT INTO t1(poiCategory, poiCategoryId) values (\"Restaurant\", 6021);\n}\n\ndo_execsql_test 6.1.2 {\n  SELECT * FROM t1 WHERE t1 MATCH 'restaurant';\n} { Restaurant 6021 }\ndo_execsql_test 6.1.3 {\n  SELECT * FROM t1 WHERE t1 MATCH 're*';\n} { Restaurant 6021 }\ndo_execsql_test 6.1.4 {\n  SELECT * FROM t1 WHERE t1 MATCH '6021';\n} {}\ndo_execsql_test 6.1.5 {\n  SELECT * FROM t1 WHERE t1 MATCH '60*';\n} {}\n\ndo_execsql_test 6.2.1 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(\n    poiCategory, poiCategoryId, notindexed=poiCategory\n  );\n  INSERT INTO t1(poiCategory, poiCategoryId) values (\"Restaurant\", 6021);\n}\n\ndo_execsql_test 6.2.2 {\n  SELECT * FROM t1 WHERE t1 MATCH 'restaurant';\n} {}\ndo_execsql_test 6.2.3 {\n  SELECT * FROM t1 WHERE t1 MATCH 're*';\n} {}\ndo_execsql_test 6.2.4 {\n  SELECT * FROM t1 WHERE t1 MATCH '6021';\n} { Restaurant 6021 }\ndo_execsql_test 6.2.5 {\n  SELECT * FROM t1 WHERE t1 MATCH '60*';\n} { Restaurant 6021 }\n\ndo_execsql_test 6.3.1 {\n  DROP TABLE t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(abc, ab, a, notindexed=abc);\n  CREATE VIRTUAL TABLE t2 USING fts4(a, ab, abc, notindexed=abc);\n\n  INSERT INTO t1 VALUES('no', 'yes', 'yep');\n  INSERT INTO t2 VALUES('yep', 'yes', 'no');\n\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'no';\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'yes';\n  SELECT count(*) FROM t1 WHERE t1 MATCH 'yep';\n\n  SELECT count(*) FROM t2 WHERE t2 MATCH 'no';\n  SELECT count(*) FROM t2 WHERE t2 MATCH 'yes';\n  SELECT count(*) FROM t2 WHERE t2 MATCH 'yep';\n} {0 1 1 0 1 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4onepass.test",
    "content": "# 2015 Sep 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4onepass\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE ft USING fts3;\n  INSERT INTO ft(rowid, content) VALUES(1, '1 2 3');\n  INSERT INTO ft(rowid, content) VALUES(2, '4 5 6');\n  INSERT INTO ft(rowid, content) VALUES(3, '7 8 9');\n}\n\n#-------------------------------------------------------------------------\n# Check that UPDATE and DELETE statements that feature \"WHERE rowid=?\" or \n# or \"WHERE docid=?\" clauses do not use statement journals. But that other\n# DELETE and UPDATE statements do.\n#\n# Note: \"MATCH ? AND docid=?\" does use a statement journal.\n#\nforeach {tn sql uses} {\n  1.1 { DELETE FROM ft } 1\n  1.2 { DELETE FROM ft WHERE docid=? } 0\n  1.3 { DELETE FROM ft WHERE rowid=? } 0\n  1.4 { DELETE FROM ft WHERE ft MATCH '1' } 1\n  1.5 { DELETE FROM ft WHERE ft MATCH '1' AND docid=? } 1\n  1.6 { DELETE FROM ft WHERE ft MATCH '1' AND rowid=? } 1\n\n  2.1 { UPDATE ft SET content='a b c' } 1\n  2.2 { UPDATE ft SET content='a b c' WHERE docid=? } 0\n  2.3 { UPDATE ft SET content='a b c' WHERE rowid=? } 0\n  2.4 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' } 1\n  2.5 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND docid=? } 1\n  2.6 { UPDATE ft SET content='a b c' WHERE ft MATCH '1' AND rowid=? } 1\n} {\n  do_test 1.$tn { sql_uses_stmt db $sql } $uses\n}\n\n#-------------------------------------------------------------------------\n# Check that putting a \"DELETE/UPDATE ... WHERE rowid=?\" statement in a\n# trigger program does not prevent the VM from using a statement \n# transaction. Even if the calling statement cannot hit a constraint.\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(x);\n\n  CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN\n    DELETE FROM ft WHERE rowid=new.x;\n  END;\n\n  CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN\n    UPDATE ft SET content = 'a b c' WHERE rowid=old.x;\n  END;\n\n  CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN\n    DELETE FROM ft WHERE rowid=old.x;\n  END;\n}\n\nforeach {tn sql uses} {\n  1 { INSERT INTO t1 VALUES(1)      } 1\n  2 { DELETE FROM t1 WHERE x=4      } 1\n  3 { UPDATE t1 SET x=10 WHERE x=11 } 1\n} {\n  do_test 2.$tn { sql_uses_stmt db $sql } $uses\n}\n\n#-------------------------------------------------------------------------\n# Test that an \"UPDATE ... WHERE rowid=?\" works and does not corrupt the\n# index when it strikes a constraint. Both inside and outside a \n# transaction.\n#\nforeach {tn tcl1 tcl2}  {\n  1 {} {}\n\n  2 {\n    execsql BEGIN\n  } {\n    if {[sqlite3_get_autocommit db]==1} { error \"transaction rolled back!\" }\n    execsql COMMIT\n  }\n} {\n\n  do_execsql_test 3.$tn.0 {\n    DROP TABLE IF EXISTS ft2;\n    CREATE VIRTUAL TABLE ft2 USING fts4;\n    INSERT INTO ft2(rowid, content) VALUES(1, 'a b c');\n    INSERT INTO ft2(rowid, content) VALUES(2, 'a b d');\n    INSERT INTO ft2(rowid, content) VALUES(3, 'a b e');\n  }\n\n  eval $tcl1\n  foreach {tn2 sql content} {\n    1 { UPDATE ft2 SET docid=2 WHERE docid=1 }\n      { 1 {a b c} 2 {a b d} 3 {a b e} }\n\n    2 { \n      INSERT INTO ft2(rowid, content) VALUES(4, 'a b f');\n      UPDATE ft2 SET docid=5 WHERE docid=4;\n      UPDATE ft2 SET docid=3 WHERE docid=5;\n    } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    3 {\n      UPDATE ft2 SET docid=3 WHERE docid=4;           -- matches 0 rows\n      UPDATE ft2 SET docid=2 WHERE docid=3;\n    } { 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    4 {\n      INSERT INTO ft2(rowid, content) VALUES(4, 'a b g');\n      UPDATE ft2 SET docid=-1 WHERE docid=4;\n      UPDATE ft2 SET docid=3 WHERE docid=-1;\n    } {-1 {a b g} 1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n\n    5 {\n      DELETE FROM ft2 WHERE rowid=451;\n      DELETE FROM ft2 WHERE rowid=-1;\n      UPDATE ft2 SET docid = 2 WHERE docid = 1;\n    } {1 {a b c} 2 {a b d} 3 {a b e} 5 {a b f} }\n  } {\n    do_catchsql_test 3.$tn.$tn2.a $sql {1 {constraint failed}}\n    do_execsql_test  3.$tn.$tn2.b { SELECT rowid, content FROM ft2 } $content\n    do_execsql_test  3.$tn.$tn2.c { \n      INSERT INTO ft2(ft2) VALUES('integrity-check');\n    }\n  }\n  eval $tcl2\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4opt.test",
    "content": "# 2016 March 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/fts3_common.tcl\nset ::testprefix fts4opt\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Create the fts_kjv_genesis procedure which fills and FTS3/4 table \n# with the complete text of the Book of Genesis.\n#\nsource $testdir/genesis.tcl\n\ndo_execsql_test 1.0 { CREATE TABLE t1(docid, words) }\nfts_kjv_genesis\n\n#-------------------------------------------------------------------------\n# Argument $db is an open database handle. $tbl is the name of an FTS3/4\n# table with the database. This command rearranges the contents of the\n# %_segdir table so that all segments within each index are on the same\n# level. This means that the 'merge' command can then be used for an\n# incremental optimize routine.\n#\nproc prepare_for_optimize {db tbl} {\n  $db eval [string map [list % $tbl] {\n    BEGIN;\n      CREATE TEMP TABLE tmp_segdir(\n        level, idx, start_block, leaves_end_block, end_block, root\n      );\n\n      INSERT INTO temp.tmp_segdir \n        SELECT \n        1024*(o.level / 1024) + 32,                                -- level\n        sum(o.level<i.level OR (o.level=i.level AND o.idx>i.idx)), -- idx\n        o.start_block, o.leaves_end_block, o.end_block, o.root     -- other\n        FROM %_segdir o, %_segdir i \n        WHERE (o.level / 1024) = (i.level / 1024)\n        GROUP BY o.level, o.idx;\n  \n      DELETE FROM %_segdir;\n      INSERT INTO %_segdir SELECT * FROM temp.tmp_segdir;\n      DROP TABLE temp.tmp_segdir;\n  \n    COMMIT;\n  }]\n}\n\ndo_test 1.1 {\n  execsql { CREATE VIRTUAL TABLE t2 USING fts4(words, prefix=\"1,2,3\") }\n  foreach {docid words} [db eval { SELECT * FROM t1 }] {\n    execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }\n  }\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT level, count(*) FROM t2_segdir GROUP BY level\n} {\n  0    13    1 15    2 5 \n  1024 13 1025 15 1026 5 \n  2048 13 2049 15 2050 5 \n  3072 13 3073 15 3074 5\n}\n\ndo_execsql_test 1.3 { INSERT INTO t2(t2) VALUES('integrity-check') }\nprepare_for_optimize db t2\ndo_execsql_test 1.4 { INSERT INTO t2(t2) VALUES('integrity-check') }\n\ndo_execsql_test 1.5 {\n  SELECT level, count(*) FROM t2_segdir GROUP BY level\n} {\n  32   33 \n  1056 33 \n  2080 33 \n  3104 33\n}\n\ndo_test 1.6 {\n  while 1 {\n    set tc1 [db total_changes]\n    execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }\n    set tc2 [db total_changes]\n    if {($tc2 - $tc1) < 2} break\n  }\n  execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }\n} {33 1 1057 1 2081 1 3105 1}\ndo_execsql_test 1.7 { INSERT INTO t2(t2) VALUES('integrity-check') }\n\ndo_execsql_test 1.8 {\n  INSERT INTO t2(words) SELECT words FROM t1;\n  SELECT level, count(*) FROM t2_segdir GROUP BY level;\n} {0 2 1024 2 2048 2 3072 2}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 2.0 {\n  DELETE FROM t2;\n}\ndo_test 2.1 {\n  foreach {docid words} [db eval { SELECT * FROM t1 }] {\n    execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }\n  }\n\n  set i 0\n  foreach {docid words} [db eval { SELECT * FROM t1 }] {\n    if {[incr i] % 2} { execsql { DELETE FROM t2 WHERE docid = $docid } }\n  }\n\n  set i 0\n  foreach {docid words} [db eval { SELECT * FROM t1 }] {\n    if {[incr i] % 3} {\n      execsql { INSERT OR REPLACE INTO t2(docid, words) VALUES($docid, $words) }\n    }\n  }\n} {}\n\ndo_execsql_test 2.2 {\n  SELECT level, count(*) FROM t2_segdir GROUP BY level\n} {\n  0    10    1 15    2 12 \n  1024 10 1025 15 1026 12 \n  2048 10 2049 15 2050 12 \n  3072 10 3073 15 3074 12\n}\n\ndo_execsql_test 2.3 { INSERT INTO t2(t2) VALUES('integrity-check') }\nprepare_for_optimize db t2\ndo_execsql_test 2.4 { INSERT INTO t2(t2) VALUES('integrity-check') }\n\ndo_execsql_test 2.5 {\n  SELECT level, count(*) FROM t2_segdir GROUP BY level\n} {\n    32 37 \n  1056 37 \n  2080 37 \n  3104 37\n}\n\ndo_test 2.6 {\n  while 1 {\n    set tc1 [db total_changes]\n    execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }\n    set tc2 [db total_changes]\n    if {($tc2 - $tc1) < 2} break\n  }\n  execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }\n} {33 1 1057 1 2081 1 3105 1}\ndo_execsql_test 2.7 { INSERT INTO t2(t2) VALUES('integrity-check') }\n\ndo_execsql_test 2.8 {\n  INSERT INTO t2(words) SELECT words FROM t1;\n  SELECT level, count(*) FROM t2_segdir GROUP BY level;\n} {0 2 1024 2 2048 2 3072 2}\n\n#-------------------------------------------------------------------------\n# Check that 'optimize' works when there is data in the in-memory hash\n# table, but no segments at all on disk.\n#\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE fts USING fts4 (t);\n  INSERT INTO fts (fts) VALUES ('optimize');\n}\ndo_execsql_test 3.2 {\n  INSERT INTO fts(fts) VALUES('integrity-check');\n  SELECT count(*) FROM fts_segdir;\n} {0}\ndo_execsql_test 3.3 {\n  BEGIN;\n  INSERT INTO fts (rowid, t) VALUES (2, 'test');\n  INSERT INTO fts (fts) VALUES ('optimize');\n  COMMIT;\n  SELECT level, idx FROM fts_segdir;\n} {0 0}\ndo_execsql_test 3.4 {\n  INSERT INTO fts(fts) VALUES('integrity-check');\n  SELECT rowid FROM fts WHERE fts MATCH 'test';\n} {2}\ndo_execsql_test 3.5 {\n  INSERT INTO fts (fts) VALUES ('optimize');\n  INSERT INTO fts(fts) VALUES('integrity-check');\n}\ndo_test 3.6 {\n  set c1 [db total_changes]\n  execsql { INSERT INTO fts (fts) VALUES ('optimize') }\n  expr {[db total_changes] - $c1}\n} {1}\ndo_test 3.7 {\n  execsql { INSERT INTO fts (rowid, t) VALUES (3, 'xyz') }\n  set c1 [db total_changes]\n  execsql { INSERT INTO fts (fts) VALUES ('optimize') }\n  expr {([db total_changes] - $c1) > 1}\n} {1}\ndo_test 3.8 {\n  set c1 [db total_changes]\n  execsql { INSERT INTO fts (fts) VALUES ('optimize') }\n  expr {[db total_changes] - $c1}\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fts4unicode.test",
    "content": "# 2012 May 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# The tests in this file focus on testing the \"unicode\" FTS tokenizer.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !fts3_unicode { finish_test ; return }\nset ::testprefix fts4unicode\n\nproc do_unicode_token_test {tn input res} {\n  set input [string map {' ''} $input]\n  uplevel [list do_execsql_test $tn \"\n    SELECT fts3_tokenizer_test('unicode61', 'remove_diacritics=0', '$input');\n  \" [list [list {*}$res]]]\n}\n\nproc do_unicode_token_test2 {tn input res} {\n  set input [string map {' ''} $input]\n  uplevel [list do_execsql_test $tn \"\n    SELECT fts3_tokenizer_test('unicode61', '$input');\n  \" [list [list {*}$res]]]\n}\n\nproc do_unicode_token_test3 {tn args} {\n  set res   [lindex $args end]\n  set sql \"SELECT fts3_tokenizer_test('unicode61'\"\n  foreach a [lrange $args 0 end-1] {\n    append sql \", '\"\n    append sql [string map {' ''} $a]\n    append sql \"'\"\n  }\n  append sql \")\"\n  uplevel [list do_execsql_test $tn $sql [list [list {*}$res]]]\n}\n\ndo_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D}\n\ndo_unicode_token_test 1.1 \"\\uC4 \\uD6 \\uDC\" \\\n    \"0 \\uE4 \\uC4 1 \\uF6 \\uD6 2 \\uFC \\uDC\"\n\ndo_unicode_token_test 1.2 \"x\\uC4x x\\uD6x x\\uDCx\" \\\n    \"0 x\\uE4x x\\uC4x 1 x\\uF6x x\\uD6x 2 x\\uFCx x\\uDCx\"\n\n# 0x00DF is a small \"sharp s\". 0x1E9E is a capital sharp s.\ndo_unicode_token_test 1.3 \"\\uDF\" \"0 \\uDF \\uDF\"\ndo_unicode_token_test 1.4 \"\\u1E9E\" \"0 \\uDF \\u1E9E\"\n\ndo_unicode_token_test 1.5 \"The quick brown fox\" {\n  0 the The 1 quick quick 2 brown brown 3 fox fox\n}\ndo_unicode_token_test 1.6 \"The\\u00bfquick\\u224ebrown\\u2263fox\" {\n  0 the The 1 quick quick 2 brown brown 3 fox fox\n}\n\ndo_unicode_token_test2 1.7  {a B c D} {0 a a 1 b B 2 c c 3 d D}\ndo_unicode_token_test2 1.8  \"\\uC4 \\uD6 \\uDC\" \"0 a \\uC4 1 o \\uD6 2 u \\uDC\"\n\ndo_unicode_token_test2 1.9  \"x\\uC4x x\\uD6x x\\uDCx\" \\\n    \"0 xax x\\uC4x 1 xox x\\uD6x 2 xux x\\uDCx\"\n\n# Check that diacritics are removed if remove_diacritics=1 is specified.\n# And that they do not break tokens.\ndo_unicode_token_test2 1.10 \"xx\\u0301xx\" \"0 xxxx xx\\u301xx\"\n\n# Title-case mappings work\ndo_unicode_token_test 1.11 \"\\u01c5\" \"0 \\u01c6 \\u01c5\"\n\n#-------------------------------------------------------------------------\n#\nset docs [list {\n  Enhance the INSERT syntax to allow multiple rows to be inserted via the\n  VALUES clause.\n} {\n  Enhance the CREATE VIRTUAL TABLE command to support the IF NOT EXISTS clause.\n} {\n  Added the sqlite3_stricmp() interface as a counterpart to sqlite3_strnicmp().\n} {\n  Added the sqlite3_db_readonly() interface.\n} {\n  Added the SQLITE_FCNTL_PRAGMA file control, giving VFS implementations the\n  ability to add new PRAGMA statements or to override built-in PRAGMAs.  \n} {\n  Queries of the form: \"SELECT max(x), y FROM table\" returns the value of y on\n  the same row that contains the maximum x value.\n} {\n  Added support for the FTS4 languageid option.\n} {\n  Documented support for the FTS4 content option. This feature has actually\n  been in the code since version 3.7.9 but is only now considered to be\n  officially supported.  \n} {\n  Pending statements no longer block ROLLBACK. Instead, the pending statement\n  will return SQLITE_ABORT upon next access after the ROLLBACK.  \n} {\n  Improvements to the handling of CSV inputs in the command-line shell\n} {\n  Fix a bug introduced in version 3.7.10 that might cause a LEFT JOIN to be\n  incorrectly converted into an INNER JOIN if the WHERE clause indexable terms\n  connected by OR.  \n}]\n\nset map(a) [list \"\\u00C4\" \"\\u00E4\"]  ; # LATIN LETTER A WITH DIAERESIS\nset map(e) [list \"\\u00CB\" \"\\u00EB\"]  ; # LATIN LETTER E WITH DIAERESIS\nset map(i) [list \"\\u00CF\" \"\\u00EF\"]  ; # LATIN LETTER I WITH DIAERESIS\nset map(o) [list \"\\u00D6\" \"\\u00F6\"]  ; # LATIN LETTER O WITH DIAERESIS\nset map(u) [list \"\\u00DC\" \"\\u00FC\"]  ; # LATIN LETTER U WITH DIAERESIS\nset map(y) [list \"\\u0178\" \"\\u00FF\"]  ; # LATIN LETTER Y WITH DIAERESIS\nset map(h) [list \"\\u1E26\" \"\\u1E27\"]  ; # LATIN LETTER H WITH DIAERESIS\nset map(w) [list \"\\u1E84\" \"\\u1E85\"]  ; # LATIN LETTER W WITH DIAERESIS\nset map(x) [list \"\\u1E8C\" \"\\u1E8D\"]  ; # LATIN LETTER X WITH DIAERESIS\nforeach k [array names map] {\n  lappend mappings [string toupper $k] [lindex $map($k) 0] \n  lappend mappings $k [lindex $map($k) 1]\n}\nproc mapdoc {doc} { \n  set doc [regsub -all {[[:space:]]+} $doc \" \"]\n  string map $::mappings [string trim $doc] \n}\n\ndo_test 2.0 {\n  execsql { CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61, x); }\n  foreach doc $docs {\n    set d [mapdoc $doc]\n    execsql { INSERT INTO t2 VALUES($d) }\n  }\n} {}\n\ndo_test 2.1 {\n  set q [mapdoc \"row\"]\n  execsql { SELECT * FROM t2 WHERE t2 MATCH $q }\n} [list [mapdoc {\n  Queries of the form: \"SELECT max(x), y FROM table\" returns the value of y on\n  the same row that contains the maximum x value.\n}]]\n\nforeach {tn query snippet} {\n  2 \"row\" {\n     ...returns the value of y on the same [row] that contains \n     the maximum x value.\n  }\n  3 \"ROW\" {\n     ...returns the value of y on the same [row] that contains \n     the maximum x value.\n  }\n  4 \"rollback\" {\n     ...[ROLLBACK]. Instead, the pending statement\n     will return SQLITE_ABORT upon next access after the [ROLLBACK].\n  }\n  5 \"rOllback\" {\n     ...[ROLLBACK]. Instead, the pending statement\n     will return SQLITE_ABORT upon next access after the [ROLLBACK].\n  }\n  6 \"lang*\" {\n     Added support for the FTS4 [languageid] option.\n  }\n} {\n  do_test 2.$tn {\n    set q [mapdoc $query]\n    execsql { SELECT snippet(t2, '[', ']', '...') FROM t2 WHERE t2 MATCH $q }\n  } [list [mapdoc $snippet]]\n}\n\n#-------------------------------------------------------------------------\n# Make sure the unicode61 tokenizer does not crash if it is passed a \n# NULL pointer.\nreset_db\ndo_execsql_test 3.1 {\n  CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x, y);\n  INSERT INTO t1 VALUES(NULL, 'a b c');\n}\n\ndo_execsql_test 3.2 {\n  SELECT snippet(t1, '[', ']') FROM t1 WHERE t1 MATCH 'b'\n} {{a [b] c}}\n\ndo_execsql_test 3.3 {\n  BEGIN;\n  DELETE FROM t1;\n  INSERT INTO t1 VALUES('b b b b b b b b b b b', 'b b b b b b b b b b b b b');\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 VALUES('a b c', NULL);\n  INSERT INTO t1 VALUES('a x c', NULL);\n  COMMIT;\n}\n\ndo_execsql_test 3.4 {\n  SELECT * FROM t1 WHERE t1 MATCH 'a b';\n} {{a b c} {}}\n\n#-------------------------------------------------------------------------\n#\nreset_db\n\ndo_test 4.1 {\n  set a \"abc\\uFFFEdef\"\n  set b \"abc\\uD800def\"\n  set c \"\\uFFFEdef\"\n  set d \"\\uD800def\"\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61, x);\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n} {}\n\ndo_test 4.2 {\n  set a [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0x62}]\n  set b [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0x62}]\n  set c [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]\n  set d [binary format c* {0x61 0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF 0x62}]\n  execsql {\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n} {}\n\ndo_test 4.3 {\n  set a [binary format c* {0xF7 0xBF 0xBF 0xBF}]\n  set b [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF}]\n  set c [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF}]\n  set d [binary format c* {0xF7 0xBF 0xBF 0xBF 0xBF 0xBF 0xBF}]\n  execsql {\n    INSERT INTO t1 VALUES($a);\n    INSERT INTO t1 VALUES($b);\n    INSERT INTO t1 VALUES($c);\n    INSERT INTO t1 VALUES($d);\n  }\n} {}\n\n#-------------------------------------------------------------------------\n\ndo_unicode_token_test3 5.1 {tokenchars=} {\n  sqlite3_reset sqlite3_column_int\n} {\n  0 sqlite3 sqlite3 \n  1 reset reset \n  2 sqlite3 sqlite3 \n  3 column column \n  4 int int\n}\n\ndo_unicode_token_test3 5.2 {tokenchars=_} {\n  sqlite3_reset sqlite3_column_int\n} {\n  0 sqlite3_reset sqlite3_reset \n  1 sqlite3_column_int sqlite3_column_int\n}\n\ndo_unicode_token_test3 5.3 {separators=xyz} {\n  Laotianxhorseyrunszfast\n} {\n  0 laotian Laotian\n  1 horse horse\n  2 runs runs\n  3 fast fast\n}\n\ndo_unicode_token_test3 5.4 {tokenchars=xyz} {\n  Laotianxhorseyrunszfast\n} {\n  0 laotianxhorseyrunszfast Laotianxhorseyrunszfast\n}\n\ndo_unicode_token_test3 5.5 {tokenchars=_} {separators=zyx} {\n  sqlite3_resetxsqlite3_column_intyhonda_phantom\n} {\n  0 sqlite3_reset sqlite3_reset \n  1 sqlite3_column_int sqlite3_column_int\n  2 honda_phantom honda_phantom\n}\n\ndo_unicode_token_test3 5.6 \"separators=\\u05D1\" \"abc\\u05D1def\" {\n  0 abc abc 1 def def\n}\n\ndo_unicode_token_test3 5.7                             \\\n  \"tokenchars=\\u2444\\u2445\"                            \\\n  \"separators=\\u05D0\\u05D1\\u05D2\"                      \\\n  \"\\u2444fre\\u2445sh\\u05D0water\\u05D2fish.\\u2445timer\" \\\n  [list                                                \\\n    0 \\u2444fre\\u2445sh \\u2444fre\\u2445sh              \\\n    1 water water                                      \\\n    2 fish fish                                        \\\n    3 \\u2445timer \\u2445timer                          \\\n  ]\n\n# Check that it is not possible to add a standalone diacritic codepoint \n# to either separators or tokenchars.\ndo_unicode_token_test3 5.8 \"separators=\\u0301\" \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"0 helloworld hello\\u0301world 1 helloworld helloworld\"\n\ndo_unicode_token_test3 5.9 \"tokenchars=\\u0301\" \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"0 helloworld hello\\u0301world 1 helloworld helloworld\"\n\ndo_unicode_token_test3 5.10 \"separators=\\u0301\" \\\n  \"remove_diacritics=0\"                        \\\n  \"hello\\u0301world \\u0301helloworld\"          \\\n  \"0 hello\\u0301world hello\\u0301world 1 helloworld helloworld\"\n\ndo_unicode_token_test3 5.11 \"tokenchars=\\u0301\" \\\n  \"remove_diacritics=0\"                         \\\n  \"hello\\u0301world \\u0301helloworld\"           \\\n  \"0 hello\\u0301world hello\\u0301world 1 helloworld helloworld\"\n\n\n#-------------------------------------------------------------------------\n\nproc do_tokenize {tokenizer txt} {\n  set res [list]\n  foreach {a b c} [db one {SELECT fts3_tokenizer_test($tokenizer, $txt)}] {\n    lappend res $b\n  }\n  set res\n}\n\n# Argument $lCodepoint must be a list of codepoints (integers) that \n# correspond to whitespace characters. This command creates a string\n# $W from the codepoints, then tokenizes \"${W}hello{$W}world${W}\" \n# using tokenizer $tokenizer. The test passes if the tokenizer successfully\n# extracts the two 5 character tokens.\n#\nproc do_isspace_test {tn tokenizer lCp} {\n  set whitespace [format [string repeat %c [llength $lCp]] {*}$lCp] \n  set txt \"${whitespace}hello${whitespace}world${whitespace}\"\n  uplevel [list do_test $tn [list do_tokenize $tokenizer $txt] {hello world}]\n}\n\nset tokenizers [list unicode61]\nifcapable icu { lappend tokenizers icu }\n\n# Some tests to check that the tokenizers can both identify white-space \n# codepoints. All codepoints tested below are of type \"Zs\" in the\n# UnicodeData.txt file.\n#\n# Note that codepoint 6158 has changed from Zs to Cf in recent versions\n# of UnicodeData.txt.  So take that into account for the \"icu\" tests.\n#\nforeach T $tokenizers {\n  do_isspace_test 6.$T.1 $T    32\n  do_isspace_test 6.$T.2 $T    160\n  do_isspace_test 6.$T.3 $T    5760\n  if {$T!=\"icu\"} {\n    do_isspace_test 6.$T.4 $T    6158\n  }\n  do_isspace_test 6.$T.5 $T    8192\n  do_isspace_test 6.$T.6 $T    8193\n  do_isspace_test 6.$T.7 $T    8194\n  do_isspace_test 6.$T.8 $T    8195\n  do_isspace_test 6.$T.9 $T    8196\n  do_isspace_test 6.$T.10 $T    8197\n  do_isspace_test 6.$T.11 $T    8198\n  do_isspace_test 6.$T.12 $T    8199\n  do_isspace_test 6.$T.13 $T    8200\n  do_isspace_test 6.$T.14 $T    8201\n  do_isspace_test 6.$T.15 $T    8202\n  if {$T!=\"icu\"} {\n    do_isspace_test 6.$T.16 $T    8239\n  }\n  do_isspace_test 6.$T.17 $T    8287\n  do_isspace_test 6.$T.18 $T   12288\n\n  if {$T!=\"icu\"} {\n    do_isspace_test 6.$T.19 $T   {32 160 5760 6158}\n  } else {\n    do_isspace_test 6.$T.19 $T   {32 160 5760 8192}\n  }\n  do_isspace_test 6.$T.20 $T   {8192 8193 8194 8195}\n  do_isspace_test 6.$T.21 $T   {8196 8197 8198 8199}\n  do_isspace_test 6.$T.22 $T   {8200 8201 8202 8239}\n  do_isspace_test 6.$T.23 $T   {8287 12288}\n}\n\n#-------------------------------------------------------------------------\n# Test that the private use ranges are treated as alphanumeric.\n#\nforeach {tn1 c} {\n  1 \\ue000 2 \\ue001 3 \\uf000 4 \\uf8fe 5 \\uf8ff\n} {\n  foreach {tn2 config res} {\n    1 \"\"             \"0 hello*world hello*world\"\n    2 \"separators=*\" \"0 hello hello 1 world world\"\n  } {\n    set config [string map [list * $c] $config]\n    set input  [string map [list * $c] \"hello*world\"]\n    set output [string map [list * $c] $res]\n    do_unicode_token_test3 7.$tn1.$tn2 {*}$config $input $output\n  }\n}\n\n#-------------------------------------------------------------------------\n# Cursory test of remove_diacritics=0.\n#\n# 00C4;LATIN CAPITAL LETTER A WITH DIAERESIS\n# 00D6;LATIN CAPITAL LETTER O WITH DIAERESIS\n# 00E4;LATIN SMALL LETTER A WITH DIAERESIS\n# 00F6;LATIN SMALL LETTER O WITH DIAERESIS\n#\ndo_execsql_test 8.1.1 \"\n  CREATE VIRTUAL TABLE t3 USING fts4(tokenize=unicode61 'remove_diacritics=1');\n  INSERT INTO t3 VALUES('o');\n  INSERT INTO t3 VALUES('a');\n  INSERT INTO t3 VALUES('O');\n  INSERT INTO t3 VALUES('A');\n  INSERT INTO t3 VALUES('\\xD6');\n  INSERT INTO t3 VALUES('\\xC4');\n  INSERT INTO t3 VALUES('\\xF6');\n  INSERT INTO t3 VALUES('\\xE4');\n\"\ndo_execsql_test 8.1.2 {\n  SELECT rowid FROM t3 WHERE t3 MATCH 'o';\n} {1 3 5 7}\ndo_execsql_test 8.1.3 {\n  SELECT rowid FROM t3 WHERE t3 MATCH 'a';\n} {2 4 6 8}\ndo_execsql_test 8.2.1 {\n  CREATE VIRTUAL TABLE t4 USING fts4(tokenize=unicode61 \"remove_diacritics=0\");\n  INSERT INTO t4 SELECT * FROM t3;\n}\ndo_execsql_test 8.2.2 {\n  SELECT rowid FROM t4 WHERE t4 MATCH 'o';\n} {1 3}\ndo_execsql_test 8.2.3 {\n  SELECT rowid FROM t4 WHERE t4 MATCH 'a';\n} {2 4}\n\n#-------------------------------------------------------------------------\n#\nforeach {tn sql} {\n  1 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 [tokenchars= .]);\n    CREATE VIRTUAL TABLE t6 USING fts4(\n        tokenize=unicode61 [tokenchars==\"] \"tokenchars=[]\");\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 [separators=x\\xC4]);\n  }\n  2 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 \"tokenchars= .\");\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 \"tokenchars=[=\"\"]\");\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 \"separators=x\\xC4\");\n  }\n  3 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 'tokenchars= .');\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 'tokenchars==\"[]');\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 'separators=x\\xC4');\n  }\n  4 {\n    CREATE VIRTUAL TABLE t5 USING fts4(tokenize=unicode61 `tokenchars= .`);\n    CREATE VIRTUAL TABLE t6 USING fts4(tokenize=unicode61 `tokenchars=[=\"]`);\n    CREATE VIRTUAL TABLE t7 USING fts4(tokenize=unicode61 `separators=x\\xC4`);\n  }\n} {\n  do_execsql_test 9.$tn.0 { \n    DROP TABLE IF EXISTS t5;\n    DROP TABLE IF EXISTS t5aux;\n    DROP TABLE IF EXISTS t6;\n    DROP TABLE IF EXISTS t6aux;\n    DROP TABLE IF EXISTS t7;\n    DROP TABLE IF EXISTS t7aux;\n  }\n  do_execsql_test 9.$tn.1 $sql\n\n  do_execsql_test 9.$tn.2 {\n    CREATE VIRTUAL TABLE t5aux USING fts4aux(t5);\n    INSERT INTO t5 VALUES('one two three/four.five.six');\n    SELECT * FROM t5aux;\n  } {\n    four.five.six   * 1 1 four.five.six   0 1 1 \n    {one two three} * 1 1 {one two three} 0 1 1\n  }\n\n  do_execsql_test 9.$tn.3 {\n    CREATE VIRTUAL TABLE t6aux USING fts4aux(t6);\n    INSERT INTO t6 VALUES('alpha=beta\"gamma/delta[epsilon]zeta');\n    SELECT * FROM t6aux;\n  } {\n    {alpha=beta\"gamma}   * 1 1 {alpha=beta\"gamma} 0 1 1 \n    {delta[epsilon]zeta} * 1 1 {delta[epsilon]zeta} 0 1 1\n  }\n\n  do_execsql_test 9.$tn.4 {\n    CREATE VIRTUAL TABLE t7aux USING fts4aux(t7);\n    INSERT INTO t7 VALUES('alephxbeth\\xC4gimel');\n    SELECT * FROM t7aux;\n  } {\n    aleph * 1 1 aleph 0 1 1 \n    beth  * 1 1 beth  0 1 1 \n    gimel * 1 1 gimel 0 1 1\n  }\n}\n\n# Check that multiple options are handled correctly.\n#\ndo_execsql_test 10.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE VIRTUAL TABLE t1 USING fts4(tokenize=unicode61\n    \"tokenchars=xyz\" \"tokenchars=.=\" \"separators=.=\" \"separators=xy\"\n    \"separators=a\" \"separators=a\" \"tokenchars=a\" \"tokenchars=a\"\n  );\n\n  INSERT INTO t1 VALUES('oneatwoxthreeyfour');\n  INSERT INTO t1 VALUES('a.single=word');\n  CREATE VIRTUAL TABLE t1aux USING fts4aux(t1);\n  SELECT * FROM t1aux;\n} {\n  .single=word * 1 1 .single=word 0 1 1 \n  four         * 1 1 four         0 1 1 \n  one          * 1 1 one          0 1 1 \n  three        * 1 1 three        0 1 1 \n  two          * 1 1 two          0 1 1\n}\n\n# Test that case folding happens after tokenization, not before.\n#\ndo_execsql_test 10.2 {\n  DROP TABLE IF EXISTS t2;\n  CREATE VIRTUAL TABLE t2 USING fts4(tokenize=unicode61 \"separators=aB\");\n  INSERT INTO t2 VALUES('oneatwoBthree');\n  INSERT INTO t2 VALUES('onebtwoAthree');\n  CREATE VIRTUAL TABLE t2aux USING fts4aux(t2);\n  SELECT * FROM t2aux;\n} {\n  one           * 1 1 one           0 1 1 \n  onebtwoathree * 1 1 onebtwoathree 0 1 1 \n  three         * 1 1 three         0 1 1 \n  two           * 1 1 two           0 1 1\n}\n\n# Test that the tokenchars and separators options work with the \n# fts3tokenize table.\n#\ndo_execsql_test 11.1 {\n  CREATE VIRTUAL TABLE ft1 USING fts3tokenize(\n    \"unicode61\", \"tokenchars=@.\", \"separators=1234567890\"\n  );\n  SELECT token FROM ft1 WHERE input = 'berlin@street123sydney.road';\n} {\n  berlin@street sydney.road\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/full.test",
    "content": "# 2012 September 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs the \"full\" test suite. It is a peer of the quick.test\n# and all.test scripts.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nrun_test_suite full\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/func.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing built-in functions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix func\n\n# Create a table to work with.\n#\ndo_test func-0.0 {\n  execsql {CREATE TABLE tbl1(t1 text)}\n  foreach word {this program is free software} {\n    execsql \"INSERT INTO tbl1 VALUES('$word')\"\n  }\n  execsql {SELECT t1 FROM tbl1 ORDER BY t1}\n} {free is program software this}\ndo_test func-0.1 {\n  execsql {\n     CREATE TABLE t2(a);\n     INSERT INTO t2 VALUES(1);\n     INSERT INTO t2 VALUES(NULL);\n     INSERT INTO t2 VALUES(345);\n     INSERT INTO t2 VALUES(NULL);\n     INSERT INTO t2 VALUES(67890);\n     SELECT * FROM t2;\n  }\n} {1 {} 345 {} 67890}\n\n# Check out the length() function\n#\ndo_test func-1.0 {\n  execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}\n} {4 2 7 8 4}\ndo_test func-1.1 {\n  set r [catch {execsql {SELECT length(*) FROM tbl1 ORDER BY t1}} msg]\n  lappend r $msg\n} {1 {wrong number of arguments to function length()}}\ndo_test func-1.2 {\n  set r [catch {execsql {SELECT length(t1,5) FROM tbl1 ORDER BY t1}} msg]\n  lappend r $msg\n} {1 {wrong number of arguments to function length()}}\ndo_test func-1.3 {\n  execsql {SELECT length(t1), count(*) FROM tbl1 GROUP BY length(t1)\n           ORDER BY length(t1)}\n} {2 1 4 2 7 1 8 1}\ndo_test func-1.4 {\n  execsql {SELECT coalesce(length(a),-1) FROM t2}\n} {1 -1 3 -1 5}\n\n# Check out the substr() function\n#\ndo_test func-2.0 {\n  execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}\n} {fr is pr so th}\ndo_test func-2.1 {\n  execsql {SELECT substr(t1,2,1) FROM tbl1 ORDER BY t1}\n} {r s r o h}\ndo_test func-2.2 {\n  execsql {SELECT substr(t1,3,3) FROM tbl1 ORDER BY t1}\n} {ee {} ogr ftw is}\ndo_test func-2.3 {\n  execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}\n} {e s m e s}\ndo_test func-2.4 {\n  execsql {SELECT substr(t1,-1,2) FROM tbl1 ORDER BY t1}\n} {e s m e s}\ndo_test func-2.5 {\n  execsql {SELECT substr(t1,-2,1) FROM tbl1 ORDER BY t1}\n} {e i a r i}\ndo_test func-2.6 {\n  execsql {SELECT substr(t1,-2,2) FROM tbl1 ORDER BY t1}\n} {ee is am re is}\ndo_test func-2.7 {\n  execsql {SELECT substr(t1,-4,2) FROM tbl1 ORDER BY t1}\n} {fr {} gr wa th}\ndo_test func-2.8 {\n  execsql {SELECT t1 FROM tbl1 ORDER BY substr(t1,2,20)}\n} {this software free program is}\ndo_test func-2.9 {\n  execsql {SELECT substr(a,1,1) FROM t2}\n} {1 {} 3 {} 6}\ndo_test func-2.10 {\n  execsql {SELECT substr(a,2,2) FROM t2}\n} {{} {} 45 {} 78}\n\n# Only do the following tests if TCL has UTF-8 capabilities\n#\nif {\"\\u1234\"!=\"u1234\"} {\n\n# Put some UTF-8 characters in the database\n#\ndo_test func-3.0 {\n  execsql {DELETE FROM tbl1}\n  foreach word \"contains UTF-8 characters hi\\u1234ho\" {\n    execsql \"INSERT INTO tbl1 VALUES('$word')\"\n  }\n  execsql {SELECT t1 FROM tbl1 ORDER BY t1}\n} \"UTF-8 characters contains hi\\u1234ho\"\ndo_test func-3.1 {\n  execsql {SELECT length(t1) FROM tbl1 ORDER BY t1}\n} {5 10 8 5}\ndo_test func-3.2 {\n  execsql {SELECT substr(t1,1,2) FROM tbl1 ORDER BY t1}\n} {UT ch co hi}\ndo_test func-3.3 {\n  execsql {SELECT substr(t1,1,3) FROM tbl1 ORDER BY t1}\n} \"UTF cha con hi\\u1234\"\ndo_test func-3.4 {\n  execsql {SELECT substr(t1,2,2) FROM tbl1 ORDER BY t1}\n} \"TF ha on i\\u1234\"\ndo_test func-3.5 {\n  execsql {SELECT substr(t1,2,3) FROM tbl1 ORDER BY t1}\n} \"TF- har ont i\\u1234h\"\ndo_test func-3.6 {\n  execsql {SELECT substr(t1,3,2) FROM tbl1 ORDER BY t1}\n} \"F- ar nt \\u1234h\"\ndo_test func-3.7 {\n  execsql {SELECT substr(t1,4,2) FROM tbl1 ORDER BY t1}\n} \"-8 ra ta ho\"\ndo_test func-3.8 {\n  execsql {SELECT substr(t1,-1,1) FROM tbl1 ORDER BY t1}\n} \"8 s s o\"\ndo_test func-3.9 {\n  execsql {SELECT substr(t1,-3,2) FROM tbl1 ORDER BY t1}\n} \"F- er in \\u1234h\"\ndo_test func-3.10 {\n  execsql {SELECT substr(t1,-4,3) FROM tbl1 ORDER BY t1}\n} \"TF- ter ain i\\u1234h\"\ndo_test func-3.99 {\n  execsql {DELETE FROM tbl1}\n  foreach word {this program is free software} {\n    execsql \"INSERT INTO tbl1 VALUES('$word')\"\n  }\n  execsql {SELECT t1 FROM tbl1}\n} {this program is free software}\n\n} ;# End \\u1234!=u1234\n\n# Test the abs() and round() functions.\n#\nifcapable !floatingpoint {\n  do_test func-4.1 {\n    execsql {\n      CREATE TABLE t1(a,b,c);\n      INSERT INTO t1 VALUES(1,2,3);\n      INSERT INTO t1 VALUES(2,12345678901234,-1234567890);\n      INSERT INTO t1 VALUES(3,-2,-5);\n    }\n    catchsql {SELECT abs(a,b) FROM t1}\n  } {1 {wrong number of arguments to function abs()}}\n}\nifcapable floatingpoint {\n  do_test func-4.1 {\n    execsql {\n      CREATE TABLE t1(a,b,c);\n      INSERT INTO t1 VALUES(1,2,3);\n      INSERT INTO t1 VALUES(2,1.2345678901234,-12345.67890);\n      INSERT INTO t1 VALUES(3,-2,-5);\n    }\n    catchsql {SELECT abs(a,b) FROM t1}\n  } {1 {wrong number of arguments to function abs()}}\n}\ndo_test func-4.2 {\n  catchsql {SELECT abs() FROM t1}\n} {1 {wrong number of arguments to function abs()}}\nifcapable floatingpoint {\n  do_test func-4.3 {\n    catchsql {SELECT abs(b) FROM t1 ORDER BY a}\n  } {0 {2 1.2345678901234 2}}\n  do_test func-4.4 {\n    catchsql {SELECT abs(c) FROM t1 ORDER BY a}\n  } {0 {3 12345.6789 5}}\n}\nifcapable !floatingpoint {\n  if {[working_64bit_int]} {\n    do_test func-4.3 {\n      catchsql {SELECT abs(b) FROM t1 ORDER BY a}\n    } {0 {2 12345678901234 2}}\n  }\n  do_test func-4.4 {\n    catchsql {SELECT abs(c) FROM t1 ORDER BY a}\n  } {0 {3 1234567890 5}}\n}\ndo_test func-4.4.1 {\n  execsql {SELECT abs(a) FROM t2}\n} {1 {} 345 {} 67890}\ndo_test func-4.4.2 {\n  execsql {SELECT abs(t1) FROM tbl1}\n} {0.0 0.0 0.0 0.0 0.0}\n\nifcapable floatingpoint {\n  do_test func-4.5 {\n    catchsql {SELECT round(a,b,c) FROM t1}\n  } {1 {wrong number of arguments to function round()}}\n  do_test func-4.6 {\n    catchsql {SELECT round(b,2) FROM t1 ORDER BY b}\n  } {0 {-2.0 1.23 2.0}}\n  do_test func-4.7 {\n    catchsql {SELECT round(b,0) FROM t1 ORDER BY a}\n  } {0 {2.0 1.0 -2.0}}\n  do_test func-4.8 {\n    catchsql {SELECT round(c) FROM t1 ORDER BY a}\n  } {0 {3.0 -12346.0 -5.0}}\n  do_test func-4.9 {\n    catchsql {SELECT round(c,a) FROM t1 ORDER BY a}\n  } {0 {3.0 -12345.68 -5.0}}\n  do_test func-4.10 {\n    catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}\n  } {0 {x3.0y x-12345.68y x-5.0y}}\n  do_test func-4.11 {\n    catchsql {SELECT round() FROM t1 ORDER BY a}\n  } {1 {wrong number of arguments to function round()}}\n  do_test func-4.12 {\n    execsql {SELECT coalesce(round(a,2),'nil') FROM t2}\n  } {1.0 nil 345.0 nil 67890.0}\n  do_test func-4.13 {\n    execsql {SELECT round(t1,2) FROM tbl1}\n  } {0.0 0.0 0.0 0.0 0.0}\n  do_test func-4.14 {\n    execsql {SELECT typeof(round(5.1,1));}\n  } {real}\n  do_test func-4.15 {\n    execsql {SELECT typeof(round(5.1));}\n  } {real}\n  do_test func-4.16 {\n    catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b}\n  } {0 {-2.0 1.23 2.0}}\n  # Verify some values reported on the mailing list.\n  # Some of these fail on MSVC builds with 64-bit\n  # long doubles, but not on GCC builds with 80-bit\n  # long doubles.\n  for {set i 1} {$i<999} {incr i} {\n    set x1 [expr 40222.5 + $i]\n    set x2 [expr 40223.0 + $i]\n    do_test func-4.17.$i {\n      execsql {SELECT round($x1);}\n    } $x2\n  }\n  for {set i 1} {$i<999} {incr i} {\n    set x1 [expr 40222.05 + $i]\n    set x2 [expr 40222.10 + $i]\n    do_test func-4.18.$i {\n      execsql {SELECT round($x1,1);}\n    } $x2\n  }\n  do_test func-4.20 {\n    execsql {SELECT round(40223.4999999999);}\n  } {40223.0}\n  do_test func-4.21 {\n    execsql {SELECT round(40224.4999999999);}\n  } {40224.0}\n  do_test func-4.22 {\n    execsql {SELECT round(40225.4999999999);}\n  } {40225.0}\n  for {set i 1} {$i<10} {incr i} {\n    do_test func-4.23.$i {\n      execsql {SELECT round(40223.4999999999,$i);}\n    } {40223.5}\n    do_test func-4.24.$i {\n      execsql {SELECT round(40224.4999999999,$i);}\n    } {40224.5}\n    do_test func-4.25.$i {\n      execsql {SELECT round(40225.4999999999,$i);}\n    } {40225.5}\n  }\n  for {set i 10} {$i<32} {incr i} {\n    do_test func-4.26.$i {\n      execsql {SELECT round(40223.4999999999,$i);}\n    } {40223.4999999999}\n    do_test func-4.27.$i {\n      execsql {SELECT round(40224.4999999999,$i);}\n    } {40224.4999999999}\n    do_test func-4.28.$i {\n      execsql {SELECT round(40225.4999999999,$i);}\n    } {40225.4999999999}\n  }\n  do_test func-4.29 {\n    execsql {SELECT round(1234567890.5);}\n  } {1234567891.0}\n  do_test func-4.30 {\n    execsql {SELECT round(12345678901.5);}\n  } {12345678902.0}\n  do_test func-4.31 {\n    execsql {SELECT round(123456789012.5);}\n  } {123456789013.0}\n  do_test func-4.32 {\n    execsql {SELECT round(1234567890123.5);}\n  } {1234567890124.0}\n  do_test func-4.33 {\n    execsql {SELECT round(12345678901234.5);}\n  } {12345678901235.0}\n  do_test func-4.34 {\n    execsql {SELECT round(1234567890123.35,1);}\n  } {1234567890123.4}\n  do_test func-4.35 {\n    execsql {SELECT round(1234567890123.445,2);}\n  } {1234567890123.45}\n  do_test func-4.36 {\n    execsql {SELECT round(99999999999994.5);}\n  } {99999999999995.0}\n  do_test func-4.37 {\n    execsql {SELECT round(9999999999999.55,1);}\n  } {9999999999999.6}\n  do_test func-4.38 {\n    execsql {SELECT round(9999999999999.556,2);}\n  } {9999999999999.56}\n}\n\n# Test the upper() and lower() functions\n#\ndo_test func-5.1 {\n  execsql {SELECT upper(t1) FROM tbl1}\n} {THIS PROGRAM IS FREE SOFTWARE}\ndo_test func-5.2 {\n  execsql {SELECT lower(upper(t1)) FROM tbl1}\n} {this program is free software}\ndo_test func-5.3 {\n  execsql {SELECT upper(a), lower(a) FROM t2}\n} {1 1 {} {} 345 345 {} {} 67890 67890}\nifcapable !icu {\n  do_test func-5.4 {\n    catchsql {SELECT upper(a,5) FROM t2}\n  } {1 {wrong number of arguments to function upper()}}\n}\ndo_test func-5.5 {\n  catchsql {SELECT upper(*) FROM t2}\n} {1 {wrong number of arguments to function upper()}}\n\n# Test the coalesce() and nullif() functions\n#\ndo_test func-6.1 {\n  execsql {SELECT coalesce(a,'xyz') FROM t2}\n} {1 xyz 345 xyz 67890}\ndo_test func-6.2 {\n  execsql {SELECT coalesce(upper(a),'nil') FROM t2}\n} {1 nil 345 nil 67890}\ndo_test func-6.3 {\n  execsql {SELECT coalesce(nullif(1,1),'nil')}\n} {nil}\ndo_test func-6.4 {\n  execsql {SELECT coalesce(nullif(1,2),'nil')}\n} {1}\ndo_test func-6.5 {\n  execsql {SELECT coalesce(nullif(1,NULL),'nil')}\n} {1}\n\n\n# Test the last_insert_rowid() function\n#\ndo_test func-7.1 {\n  execsql {SELECT last_insert_rowid()}\n} [db last_insert_rowid]\n\n# Tests for aggregate functions and how they handle NULLs.\n#\nifcapable floatingpoint {\n  do_test func-8.1 {\n    ifcapable explain {\n      execsql {EXPLAIN SELECT sum(a) FROM t2;}\n    }\n    execsql {\n      SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2;\n    }\n  } {68236 3 22745.33 1 67890 5}\n}\nifcapable !floatingpoint {\n  do_test func-8.1 {\n    ifcapable explain {\n      execsql {EXPLAIN SELECT sum(a) FROM t2;}\n    }\n    execsql {\n      SELECT sum(a), count(a), avg(a), min(a), max(a), count(*) FROM t2;\n    }\n  } {68236 3 22745.0 1 67890 5}\n}\ndo_test func-8.2 {\n  execsql {\n    SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t2;\n  }\n} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}\n\nifcapable tempdb {\n  do_test func-8.3 {\n    execsql {\n      CREATE TEMP TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC;\n      SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;\n    }\n  } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}\n} else {\n  do_test func-8.3 {\n    execsql {\n      CREATE TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC;\n      SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;\n    }\n  } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}\n}\ndo_test func-8.4 {\n  execsql {\n    SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3;\n  }\n} {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP}\nifcapable compound {\n  do_test func-8.5 {\n    execsql {\n      SELECT sum(x) FROM (SELECT '9223372036' || '854775807' AS x\n                          UNION ALL SELECT -9223372036854775807)\n    }\n  } {0}\n  do_test func-8.6 {\n    execsql {\n      SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775807' AS x\n                          UNION ALL SELECT -9223372036854775807)\n    }\n  } {integer}\n  do_test func-8.7 {\n    execsql {\n      SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775808' AS x\n                          UNION ALL SELECT -9223372036854775807)\n    }\n  } {real}\nifcapable floatingpoint {\n  do_test func-8.8 {\n    execsql {\n      SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x\n                          UNION ALL SELECT -9223372036850000000)\n    }\n  } {1}\n}\nifcapable !floatingpoint {\n  do_test func-8.8 {\n    execsql {\n      SELECT sum(x)>0 FROM (SELECT '9223372036' || '854775808' AS x\n                          UNION ALL SELECT -9223372036850000000)\n    }\n  } {1}\n}\n}\n\n# How do you test the random() function in a meaningful, deterministic way?\n#\ndo_test func-9.1 {\n  execsql {\n    SELECT random() is not null;\n  }\n} {1}\ndo_test func-9.2 {\n  execsql {\n    SELECT typeof(random());\n  }\n} {integer}\ndo_test func-9.3 {\n  execsql {\n    SELECT randomblob(32) is not null;\n  }\n} {1}\ndo_test func-9.4 {\n  execsql {\n    SELECT typeof(randomblob(32));\n  }\n} {blob}\ndo_test func-9.5 {\n  execsql {\n    SELECT length(randomblob(32)), length(randomblob(-5)),\n           length(randomblob(2000))\n  }\n} {32 1 2000}\n\n# The \"hex()\" function was added in order to be able to render blobs\n# generated by randomblob().  So this seems like a good place to test\n# hex().\n#\nifcapable bloblit {\n  do_test func-9.10 {\n    execsql {SELECT hex(x'00112233445566778899aAbBcCdDeEfF')}\n  } {00112233445566778899AABBCCDDEEFF}\n}\nset encoding [db one {PRAGMA encoding}]\nif {$encoding==\"UTF-16le\"} {\n  do_test func-9.11-utf16le {\n    execsql {SELECT hex(replace('abcdefg','ef','12'))}\n  } {6100620063006400310032006700}\n  do_test func-9.12-utf16le {\n    execsql {SELECT hex(replace('abcdefg','','12'))}\n  } {6100620063006400650066006700}\n  do_test func-9.13-utf16le {\n    execsql {SELECT hex(replace('aabcdefg','a','aaa'))}\n  } {610061006100610061006100620063006400650066006700}\n} elseif {$encoding==\"UTF-8\"} {\n  do_test func-9.11-utf8 {\n    execsql {SELECT hex(replace('abcdefg','ef','12'))}\n  } {61626364313267}\n  do_test func-9.12-utf8 {\n    execsql {SELECT hex(replace('abcdefg','','12'))}\n  } {61626364656667}\n  do_test func-9.13-utf8 {\n    execsql {SELECT hex(replace('aabcdefg','a','aaa'))}\n  } {616161616161626364656667}\n}\n  \n# Use the \"sqlite_register_test_function\" TCL command which is part of\n# the text fixture in order to verify correct operation of some of\n# the user-defined SQL function APIs that are not used by the built-in\n# functions.\n#\nset ::DB [sqlite3_connection_pointer db]\nsqlite_register_test_function $::DB testfunc\ndo_test func-10.1 {\n  catchsql {\n    SELECT testfunc(NULL,NULL);\n  }\n} {1 {first argument should be one of: int int64 string double null value}}\ndo_test func-10.2 {\n  execsql {\n    SELECT testfunc(\n     'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n     'int', 1234\n    );\n  }\n} {1234}\ndo_test func-10.3 {\n  execsql {\n    SELECT testfunc(\n     'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n     'string', NULL\n    );\n  }\n} {{}}\n\nifcapable floatingpoint {\n  do_test func-10.4 {\n    execsql {\n      SELECT testfunc(\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'double', 1.234\n      );\n    }\n  } {1.234}\n  do_test func-10.5 {\n    execsql {\n      SELECT testfunc(\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'int', 1234,\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'string', NULL,\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'double', 1.234,\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'int', 1234,\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'string', NULL,\n       'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n       'double', 1.234\n      );\n    }\n  } {1.234}\n}\n\n# Test the built-in sqlite_version(*) SQL function.\n#\ndo_test func-11.1 {\n  execsql {\n    SELECT sqlite_version(*);\n  }\n} [sqlite3 -version]\n\n# Test that destructors passed to sqlite3 by calls to sqlite3_result_text()\n# etc. are called. These tests use two special user-defined functions\n# (implemented in func.c) only available in test builds. \n#\n# Function test_destructor() takes one argument and returns a copy of the\n# text form of that argument. A destructor is associated with the return\n# value. Function test_destructor_count() returns the number of outstanding\n# destructor calls for values returned by test_destructor().\n#\nif {[db eval {PRAGMA encoding}]==\"UTF-8\"} {\n  do_test func-12.1-utf8 {\n    execsql {\n      SELECT test_destructor('hello world'), test_destructor_count();\n    }\n  } {{hello world} 1}\n} else {\n    ifcapable {utf16} {\n      do_test func-12.1-utf16 {\n        execsql {\n          SELECT test_destructor16('hello world'), test_destructor_count();\n        }\n      } {{hello world} 1}\n    }\n}\ndo_test func-12.2 {\n  execsql {\n    SELECT test_destructor_count();\n  }\n} {0}\ndo_test func-12.3 {\n  execsql {\n    SELECT test_destructor('hello')||' world'\n  }\n} {{hello world}}\ndo_test func-12.4 {\n  execsql {\n    SELECT test_destructor_count();\n  }\n} {0}\ndo_test func-12.5 {\n  execsql {\n    CREATE TABLE t4(x);\n    INSERT INTO t4 VALUES(test_destructor('hello'));\n    INSERT INTO t4 VALUES(test_destructor('world'));\n    SELECT min(test_destructor(x)), max(test_destructor(x)) FROM t4;\n  }\n} {hello world}\ndo_test func-12.6 {\n  execsql {\n    SELECT test_destructor_count();\n  }\n} {0}\ndo_test func-12.7 {\n  execsql {\n    DROP TABLE t4;\n  }\n} {}\n\n\n# Test that the auxdata API for scalar functions works. This test uses\n# a special user-defined function only available in test builds,\n# test_auxdata(). Function test_auxdata() takes any number of arguments.\ndo_test func-13.1 {\n  execsql {\n    SELECT test_auxdata('hello world');\n  }\n} {0}\n\ndo_test func-13.2 {\n  execsql {\n    CREATE TABLE t4(a, b);\n    INSERT INTO t4 VALUES('abc', 'def');\n    INSERT INTO t4 VALUES('ghi', 'jkl');\n  }\n} {}\ndo_test func-13.3 {\n  execsql {\n    SELECT test_auxdata('hello world') FROM t4;\n  }\n} {0 1}\ndo_test func-13.4 {\n  execsql {\n    SELECT test_auxdata('hello world', 123) FROM t4;\n  }\n} {{0 0} {1 1}}\ndo_test func-13.5 {\n  execsql {\n    SELECT test_auxdata('hello world', a) FROM t4;\n  }\n} {{0 0} {1 0}}\ndo_test func-13.6 {\n  execsql {\n    SELECT test_auxdata('hello'||'world', a) FROM t4;\n  }\n} {{0 0} {1 0}}\n\n# Test that auxilary data is preserved between calls for SQL variables.\ndo_test func-13.7 {\n  set DB [sqlite3_connection_pointer db]\n  set sql \"SELECT test_auxdata( ? , a ) FROM t4;\"\n  set STMT [sqlite3_prepare $DB $sql -1 TAIL]\n  sqlite3_bind_text $STMT 1 hello\\000 -1\n  set res [list]\n  while { \"SQLITE_ROW\"==[sqlite3_step $STMT] } {\n    lappend res [sqlite3_column_text $STMT 0]\n  }\n  lappend res [sqlite3_finalize $STMT]\n} {{0 0} {1 0} SQLITE_OK}\n\n# Test that auxiliary data is discarded when a statement is reset.\ndo_execsql_test 13.8.1 {\n  SELECT test_auxdata('constant') FROM t4;\n} {0 1}\ndo_execsql_test 13.8.2 {\n  SELECT test_auxdata('constant') FROM t4;\n} {0 1}\ndb cache flush\ndo_execsql_test 13.8.3 {\n  SELECT test_auxdata('constant') FROM t4;\n} {0 1}\nset V \"one\"\ndo_execsql_test 13.8.4 {\n  SELECT test_auxdata($V), $V FROM t4;\n} {0 one 1 one}\nset V \"two\"\ndo_execsql_test 13.8.5 {\n  SELECT test_auxdata($V), $V FROM t4;\n} {0 two 1 two}\ndb cache flush\nset V \"three\"\ndo_execsql_test 13.8.6 {\n  SELECT test_auxdata($V), $V FROM t4;\n} {0 three 1 three}\n\n\n# Make sure that a function with a very long name is rejected\ndo_test func-14.1 {\n  catch {\n    db function [string repeat X 254] {return \"hello\"}\n  } \n} {0}\ndo_test func-14.2 {\n  catch {\n    db function [string repeat X 256] {return \"hello\"}\n  }\n} {1}\n\ndo_test func-15.1 {\n  catchsql {select test_error(NULL)}\n} {1 {}}\ndo_test func-15.2 {\n  catchsql {select test_error('this is the error message')}\n} {1 {this is the error message}}\ndo_test func-15.3 {\n  catchsql {select test_error('this is the error message',12)}\n} {1 {this is the error message}}\ndo_test func-15.4 {\n  db errorcode\n} {12}\n\n# Test the quote function for BLOB and NULL values.\ndo_test func-16.1 {\n  execsql {\n    CREATE TABLE tbl2(a, b);\n  }\n  set STMT [sqlite3_prepare $::DB \"INSERT INTO tbl2 VALUES(?, ?)\" -1 TAIL]\n  sqlite3_bind_blob $::STMT 1 abc 3\n  sqlite3_step $::STMT\n  sqlite3_finalize $::STMT\n  execsql {\n    SELECT quote(a), quote(b) FROM tbl2;\n  }\n} {X'616263' NULL}\n\n# Correctly handle function error messages that include %.  Ticket #1354\n#\ndo_test func-17.1 {\n  proc testfunc1 args {error \"Error %d with %s percents %p\"}\n  db function testfunc1 ::testfunc1\n  catchsql {\n    SELECT testfunc1(1,2,3);\n  }\n} {1 {Error %d with %s percents %p}}\n\n# The SUM function should return integer results when all inputs are integer.\n#\ndo_test func-18.1 {\n  execsql {\n    CREATE TABLE t5(x);\n    INSERT INTO t5 VALUES(1);\n    INSERT INTO t5 VALUES(-99);\n    INSERT INTO t5 VALUES(10000);\n    SELECT sum(x) FROM t5;\n  }\n} {9902}\nifcapable floatingpoint {\n  do_test func-18.2 {\n    execsql {\n      INSERT INTO t5 VALUES(0.0);\n      SELECT sum(x) FROM t5;\n    }\n  } {9902.0}\n}\n\n# The sum of nothing is NULL.  But the sum of all NULLs is NULL.\n#\n# The TOTAL of nothing is 0.0.\n#\ndo_test func-18.3 {\n  execsql {\n    DELETE FROM t5;\n    SELECT sum(x), total(x) FROM t5;\n  }\n} {{} 0.0}\ndo_test func-18.4 {\n  execsql {\n    INSERT INTO t5 VALUES(NULL);\n    SELECT sum(x), total(x) FROM t5\n  }\n} {{} 0.0}\ndo_test func-18.5 {\n  execsql {\n    INSERT INTO t5 VALUES(NULL);\n    SELECT sum(x), total(x) FROM t5\n  }\n} {{} 0.0}\ndo_test func-18.6 {\n  execsql {\n    INSERT INTO t5 VALUES(123);\n    SELECT sum(x), total(x) FROM t5\n  }\n} {123 123.0}\n\n# Ticket #1664, #1669, #1670, #1674: An integer overflow on SUM causes\n# an error. The non-standard TOTAL() function continues to give a helpful\n# result.\n#\ndo_test func-18.10 {\n  execsql {\n    CREATE TABLE t6(x INTEGER);\n    INSERT INTO t6 VALUES(1);\n    INSERT INTO t6 VALUES(1<<62);\n    SELECT sum(x) - ((1<<62)+1) from t6;\n  }\n} 0\ndo_test func-18.11 {\n  execsql {\n    SELECT typeof(sum(x)) FROM t6\n  }\n} integer\nifcapable floatingpoint {\n  do_test func-18.12 {\n    catchsql {\n      INSERT INTO t6 VALUES(1<<62);\n      SELECT sum(x) - ((1<<62)*2.0+1) from t6;\n    }\n  } {1 {integer overflow}}\n  do_test func-18.13 {\n    execsql {\n      SELECT total(x) - ((1<<62)*2.0+1) FROM t6\n    }\n  } 0.0\n}\nifcapable !floatingpoint {\n  do_test func-18.12 {\n    catchsql {\n      INSERT INTO t6 VALUES(1<<62);\n      SELECT sum(x) - ((1<<62)*2+1) from t6;\n    }\n  } {1 {integer overflow}}\n  do_test func-18.13 {\n    execsql {\n      SELECT total(x) - ((1<<62)*2+1) FROM t6\n    }\n  } 0.0\n}\nif {[working_64bit_int]} {\n  do_test func-18.14 {\n    execsql {\n      SELECT sum(-9223372036854775805);\n    }\n  } -9223372036854775805\n}\nifcapable compound&&subquery {\n\ndo_test func-18.15 {\n  catchsql {\n    SELECT sum(x) FROM \n       (SELECT 9223372036854775807 AS x UNION ALL\n        SELECT 10 AS x);\n  }\n} {1 {integer overflow}}\nif {[working_64bit_int]} {\n  do_test func-18.16 {\n    catchsql {\n      SELECT sum(x) FROM \n         (SELECT 9223372036854775807 AS x UNION ALL\n          SELECT -10 AS x);\n    }\n  } {0 9223372036854775797}\n  do_test func-18.17 {\n    catchsql {\n      SELECT sum(x) FROM \n         (SELECT -9223372036854775807 AS x UNION ALL\n          SELECT 10 AS x);\n    }\n  } {0 -9223372036854775797}\n}\ndo_test func-18.18 {\n  catchsql {\n    SELECT sum(x) FROM \n       (SELECT -9223372036854775807 AS x UNION ALL\n        SELECT -10 AS x);\n  }\n} {1 {integer overflow}}\ndo_test func-18.19 {\n  catchsql {\n    SELECT sum(x) FROM (SELECT 9 AS x UNION ALL SELECT -10 AS x);\n  }\n} {0 -1}\ndo_test func-18.20 {\n  catchsql {\n    SELECT sum(x) FROM (SELECT -9 AS x UNION ALL SELECT 10 AS x);\n  }\n} {0 1}\ndo_test func-18.21 {\n  catchsql {\n    SELECT sum(x) FROM (SELECT -10 AS x UNION ALL SELECT 9 AS x);\n  }\n} {0 -1}\ndo_test func-18.22 {\n  catchsql {\n    SELECT sum(x) FROM (SELECT 10 AS x UNION ALL SELECT -9 AS x);\n  }\n} {0 1}\n\n} ;# ifcapable compound&&subquery\n\n# Integer overflow on abs()\n#\nif {[working_64bit_int]} {\n  do_test func-18.31 {\n    catchsql {\n      SELECT abs(-9223372036854775807);\n    }\n  } {0 9223372036854775807}\n}\ndo_test func-18.32 {\n  catchsql {\n    SELECT abs(-9223372036854775807-1);\n  }\n} {1 {integer overflow}}\n\n# The MATCH function exists but is only a stub and always throws an error.\n#\ndo_test func-19.1 {\n  execsql {\n    SELECT match(a,b) FROM t1 WHERE 0;\n  }\n} {}\ndo_test func-19.2 {\n  catchsql {\n    SELECT 'abc' MATCH 'xyz';\n  }\n} {1 {unable to use function MATCH in the requested context}}\ndo_test func-19.3 {\n  catchsql {\n    SELECT 'abc' NOT MATCH 'xyz';\n  }\n} {1 {unable to use function MATCH in the requested context}}\ndo_test func-19.4 {\n  catchsql {\n    SELECT match(1,2,3);\n  }\n} {1 {wrong number of arguments to function match()}}\n\n# Soundex tests.\n#\nif {![catch {db eval {SELECT soundex('hello')}}]} {\n  set i 0\n  foreach {name sdx} {\n    euler        E460\n    EULER        E460\n    Euler        E460\n    ellery       E460\n    gauss        G200\n    ghosh        G200\n    hilbert      H416\n    Heilbronn    H416\n    knuth        K530\n    kant         K530\n    Lloyd        L300\n    LADD         L300\n    Lukasiewicz  L222\n    Lissajous    L222\n    A            A000\n    12345        ?000\n  } {\n    incr i\n    do_test func-20.$i {\n      execsql {SELECT soundex($name)}\n    } $sdx\n  }\n}\n\n# Tests of the REPLACE function.\n#\ndo_test func-21.1 {\n  catchsql {\n    SELECT replace(1,2);\n  }\n} {1 {wrong number of arguments to function replace()}}\ndo_test func-21.2 {\n  catchsql {\n    SELECT replace(1,2,3,4);\n  }\n} {1 {wrong number of arguments to function replace()}}\ndo_test func-21.3 {\n  execsql {\n    SELECT typeof(replace(\"This is the main test string\", NULL, \"ALT\"));\n  }\n} {null}\ndo_test func-21.4 {\n  execsql {\n    SELECT typeof(replace(NULL, \"main\", \"ALT\"));\n  }\n} {null}\ndo_test func-21.5 {\n  execsql {\n    SELECT typeof(replace(\"This is the main test string\", \"main\", NULL));\n  }\n} {null}\ndo_test func-21.6 {\n  execsql {\n    SELECT replace(\"This is the main test string\", \"main\", \"ALT\");\n  }\n} {{This is the ALT test string}}\ndo_test func-21.7 {\n  execsql {\n    SELECT replace(\"This is the main test string\", \"main\", \"larger-main\");\n  }\n} {{This is the larger-main test string}}\ndo_test func-21.8 {\n  execsql {\n    SELECT replace(\"aaaaaaa\", \"a\", \"0123456789\");\n  }\n} {0123456789012345678901234567890123456789012345678901234567890123456789}\n\nifcapable tclvar {\n  do_test func-21.9 {\n    # Attempt to exploit a buffer-overflow that at one time existed \n    # in the REPLACE function. \n    set ::str \"[string repeat A 29998]CC[string repeat A 35537]\"\n    set ::rep [string repeat B 65536]\n    execsql {\n      SELECT LENGTH(REPLACE($::str, 'C', $::rep));\n    }\n  } [expr 29998 + 2*65536 + 35537]\n}\n\n# Tests for the TRIM, LTRIM and RTRIM functions.\n#\ndo_test func-22.1 {\n  catchsql {SELECT trim(1,2,3)}\n} {1 {wrong number of arguments to function trim()}}\ndo_test func-22.2 {\n  catchsql {SELECT ltrim(1,2,3)}\n} {1 {wrong number of arguments to function ltrim()}}\ndo_test func-22.3 {\n  catchsql {SELECT rtrim(1,2,3)}\n} {1 {wrong number of arguments to function rtrim()}}\ndo_test func-22.4 {\n  execsql {SELECT trim('  hi  ');}\n} {hi}\ndo_test func-22.5 {\n  execsql {SELECT ltrim('  hi  ');}\n} {{hi  }}\ndo_test func-22.6 {\n  execsql {SELECT rtrim('  hi  ');}\n} {{  hi}}\ndo_test func-22.7 {\n  execsql {SELECT trim('  hi  ','xyz');}\n} {{  hi  }}\ndo_test func-22.8 {\n  execsql {SELECT ltrim('  hi  ','xyz');}\n} {{  hi  }}\ndo_test func-22.9 {\n  execsql {SELECT rtrim('  hi  ','xyz');}\n} {{  hi  }}\ndo_test func-22.10 {\n  execsql {SELECT trim('xyxzy  hi  zzzy','xyz');}\n} {{  hi  }}\ndo_test func-22.11 {\n  execsql {SELECT ltrim('xyxzy  hi  zzzy','xyz');}\n} {{  hi  zzzy}}\ndo_test func-22.12 {\n  execsql {SELECT rtrim('xyxzy  hi  zzzy','xyz');}\n} {{xyxzy  hi  }}\ndo_test func-22.13 {\n  execsql {SELECT trim('  hi  ','');}\n} {{  hi  }}\nif {[db one {PRAGMA encoding}]==\"UTF-8\"} {\n  do_test func-22.14 {\n    execsql {SELECT hex(trim(x'c280e1bfbff48fbfbf6869',x'6162e1bfbfc280'))}\n  } {F48FBFBF6869}\n  do_test func-22.15 {\n    execsql {SELECT hex(trim(x'6869c280e1bfbff48fbfbf61',\n                             x'6162e1bfbfc280f48fbfbf'))}\n  } {6869}\n  do_test func-22.16 {\n    execsql {SELECT hex(trim(x'ceb1ceb2ceb3',x'ceb1'));}\n  } {CEB2CEB3}\n}\ndo_test func-22.20 {\n  execsql {SELECT typeof(trim(NULL));}\n} {null}\ndo_test func-22.21 {\n  execsql {SELECT typeof(trim(NULL,'xyz'));}\n} {null}\ndo_test func-22.22 {\n  execsql {SELECT typeof(trim('hello',NULL));}\n} {null}\n\n# This is to test the deprecated sqlite3_aggregate_count() API.\n#\nifcapable deprecated {\n  do_test func-23.1 {\n    sqlite3_create_aggregate db\n    execsql {\n      SELECT legacy_count() FROM t6;\n    }\n  } {3}\n}\n\n# The group_concat() function.\n#\ndo_test func-24.1 {\n  execsql {\n    SELECT group_concat(t1) FROM tbl1\n  }\n} {this,program,is,free,software}\ndo_test func-24.2 {\n  execsql {\n    SELECT group_concat(t1,' ') FROM tbl1\n  }\n} {{this program is free software}}\ndo_test func-24.3 {\n  execsql {\n    SELECT group_concat(t1,' ' || rowid || ' ') FROM tbl1\n  }\n} {{this 2 program 3 is 4 free 5 software}}\ndo_test func-24.4 {\n  execsql {\n    SELECT group_concat(NULL,t1) FROM tbl1\n  }\n} {{}}\ndo_test func-24.5 {\n  execsql {\n    SELECT group_concat(t1,NULL) FROM tbl1\n  }\n} {thisprogramisfreesoftware}\ndo_test func-24.6 {\n  execsql {\n    SELECT 'BEGIN-'||group_concat(t1) FROM tbl1\n  }\n} {BEGIN-this,program,is,free,software}\n\n# Ticket #3179:  Make sure aggregate functions can take many arguments.\n# None of the built-in aggregates do this, so use the md5sum() from the\n# test extensions.\n#\nunset -nocomplain midargs\nset midargs {}\nunset -nocomplain midres\nset midres {}\nunset -nocomplain result\nfor {set i 1} {$i<[sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1]} {incr i} {\n  append midargs ,'/$i'\n  append midres /$i\n  set result [md5 \\\n     \"this${midres}program${midres}is${midres}free${midres}software${midres}\"]\n  set sql \"SELECT md5sum(t1$midargs) FROM tbl1\"\n  do_test func-24.7.$i {\n     db eval $::sql\n  } $result\n}\n\n# Ticket #3806.  If the initial string in a group_concat is an empty\n# string, the separator that follows should still be present.\n#\ndo_test func-24.8 {\n  execsql {\n    SELECT group_concat(CASE t1 WHEN 'this' THEN '' ELSE t1 END) FROM tbl1\n  }\n} {,program,is,free,software}\ndo_test func-24.9 {\n  execsql {\n    SELECT group_concat(CASE WHEN t1!='software' THEN '' ELSE t1 END) FROM tbl1\n  }\n} {,,,,software}\n\n# Ticket #3923.  Initial empty strings have a separator.  But initial\n# NULLs do not.\n#\ndo_test func-24.10 {\n  execsql {\n    SELECT group_concat(CASE t1 WHEN 'this' THEN null ELSE t1 END) FROM tbl1\n  }\n} {program,is,free,software}\ndo_test func-24.11 {\n  execsql {\n   SELECT group_concat(CASE WHEN t1!='software' THEN null ELSE t1 END) FROM tbl1\n  }\n} {software}\ndo_test func-24.12 {\n  execsql {\n    SELECT group_concat(CASE t1 WHEN 'this' THEN ''\n                          WHEN 'program' THEN null ELSE t1 END) FROM tbl1\n  }\n} {,is,free,software}\n# Tests to verify ticket http://www.sqlite.org/src/tktview/55746f9e65f8587c0\ndo_test func-24.13 {\n  execsql {\n    SELECT typeof(group_concat(x)) FROM (SELECT '' AS x);\n  }\n} {text}\ndo_test func-24.14 {\n  execsql {\n    SELECT typeof(group_concat(x,''))\n      FROM (SELECT '' AS x UNION ALL SELECT '');\n  }\n} {text}\n\n\n# Use the test_isolation function to make sure that type conversions\n# on function arguments do not effect subsequent arguments.\n#\ndo_test func-25.1 {\n  execsql {SELECT test_isolation(t1,t1) FROM tbl1}\n} {this program is free software}\n\n# Try to misuse the sqlite3_create_function() interface.  Verify that\n# errors are returned.\n#\ndo_test func-26.1 {\n  abuse_create_function db\n} {}\n\n# The previous test (func-26.1) registered a function with a very long\n# function name that takes many arguments and always returns NULL.  Verify\n# that this function works correctly.\n#\ndo_test func-26.2 {\n  set a {}\n  for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG} {incr i} {\n    lappend a $i\n  }\n  db eval \"\n     SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);\n  \"\n} {{}}\ndo_test func-26.3 {\n  set a {}\n  for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG+1} {incr i} {\n    lappend a $i\n  }\n  catchsql \"\n     SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);\n  \"\n} {1 {too many arguments on function nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789}}\ndo_test func-26.4 {\n  set a {}\n  for {set i 1} {$i<=$::SQLITE_MAX_FUNCTION_ARG-1} {incr i} {\n    lappend a $i\n  }\n  catchsql \"\n     SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789([join $a ,]);\n  \"\n} {1 {wrong number of arguments to function nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789()}}\ndo_test func-26.5 {\n  catchsql \"\n     SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678a(0);\n  \"\n} {1 {no such function: nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_12345678a}}\ndo_test func-26.6 {\n  catchsql \"\n     SELECT nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789a(0);\n  \"\n} {1 {no such function: nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789a}}\n\ndo_test func-27.1 {\n  catchsql {SELECT coalesce()}\n} {1 {wrong number of arguments to function coalesce()}}\ndo_test func-27.2 {\n  catchsql {SELECT coalesce(1)}\n} {1 {wrong number of arguments to function coalesce()}}\ndo_test func-27.3 {\n  catchsql {SELECT coalesce(1,2)}\n} {0 1}\n\n# Ticket 2d401a94287b5\n# Unknown function in a DEFAULT expression causes a segfault.\n#\ndo_test func-28.1 {\n  db eval {\n    CREATE TABLE t28(x, y DEFAULT(nosuchfunc(1)));\n  }\n  catchsql {\n    INSERT INTO t28(x) VALUES(1);\n  }\n} {1 {unknown function: nosuchfunc()}}\n\n# Verify that the length() and typeof() functions do not actually load\n# the content of their argument.\n#\ndo_test func-29.1 {\n  db eval {\n    CREATE TABLE t29(id INTEGER PRIMARY KEY, x, y);\n    INSERT INTO t29 VALUES(1, 2, 3), (2, NULL, 4), (3, 4.5, 5);\n    INSERT INTO t29 VALUES(4, randomblob(1000000), 6);\n    INSERT INTO t29 VALUES(5, \"hello\", 7);\n  }\n  db close\n  sqlite3 db test.db\n  sqlite3_db_status db CACHE_MISS 1\n  db eval {SELECT typeof(x), length(x), typeof(y) FROM t29 ORDER BY id}\n} {integer 1 integer null {} integer real 3 integer blob 1000000 integer text 5 integer}\ndo_test func-29.2 {\n  set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]\n  if {$x<5} {set x 1}\n  set x\n} {1}\ndo_test func-29.3 {\n  db close\n  sqlite3 db test.db\n  sqlite3_db_status db CACHE_MISS 1\n  db eval {SELECT typeof(+x) FROM t29 ORDER BY id}\n} {integer null real blob text}\nif {[permutation] != \"mmap\"} {\n  ifcapable !direct_read {\n    do_test func-29.4 {\n      set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]\n      if {$x>100} {set x many}\n      set x\n    } {many}\n  }\n}\ndo_test func-29.5 {\n  db close\n  sqlite3 db test.db\n  sqlite3_db_status db CACHE_MISS 1\n  db eval {SELECT sum(length(x)) FROM t29}\n} {1000009}\ndo_test func-29.6 {\n  set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1]\n  if {$x<5} {set x 1}\n  set x\n} {1}\n\n# The OP_Column opcode has an optimization that avoids loading content\n# for fields with content-length=0 when the content offset is on an overflow\n# page.  Make sure the optimization works.\n#\ndo_execsql_test func-29.10 {\n  CREATE TABLE t29b(a,b,c,d,e,f,g,h,i);\n  INSERT INTO t29b \n   VALUES(1, hex(randomblob(2000)), null, 0, 1, '', zeroblob(0),'x',x'01');\n  SELECT typeof(c), typeof(d), typeof(e), typeof(f),\n         typeof(g), typeof(h), typeof(i) FROM t29b;\n} {null integer integer text blob text blob}\ndo_execsql_test func-29.11 {\n  SELECT length(f), length(g), length(h), length(i) FROM t29b;\n} {0 0 1 1}\ndo_execsql_test func-29.12 {\n  SELECT quote(f), quote(g), quote(h), quote(i) FROM t29b;\n} {'' X'' 'x' X'01'}\n\n# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric\n# unicode code point corresponding to the first character of the string\n# X.\n#\n# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a\n# string composed of characters having the unicode code point values of\n# integers X1 through XN, respectively.\n#\ndo_execsql_test func-30.1 {SELECT unicode('$');} 36\ndo_execsql_test func-30.2 [subst {SELECT unicode('\\u00A2');}] 162\ndo_execsql_test func-30.3 [subst {SELECT unicode('\\u20AC');}] 8364\ndo_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\\u00A2\\u20AC}]\n\nfor {set i 1} {$i<0xd800} {incr i 13} {\n  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i\n}\nfor {set i 57344} {$i<=0xfffd} {incr i 17} {\n  if {$i==0xfeff} continue\n  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i\n}\nfor {set i 65536} {$i<=0x10ffff} {incr i 139} {\n  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i\n}\n\n# Test char().\n#\ndo_execsql_test func-31.1 { \n  SELECT char(), length(char()), typeof(char()) \n} {{} 0 text}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/func2.test",
    "content": "# 2009 November 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing built-in functions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test plan:\n#\n#   func2-1.*: substr implementation (ascii)\n#   func2-2.*: substr implementation (utf8)\n#   func2-3.*: substr implementation (blob)\n#\n\nproc bin_to_hex {blob} {\n  set bytes {}\n  binary scan $blob \\c* bytes\n  set bytes2 [list]\n  foreach b $bytes {lappend bytes2 [format %02X [expr $b & 0xFF]]}\n  join $bytes2 {}\n}\n\n#----------------------------------------------------------------------------\n# Test cases func2-1.*: substr implementation (ascii)\n#\n\ndo_test func2-1.1 {\n  execsql {SELECT 'Supercalifragilisticexpialidocious'}\n} {Supercalifragilisticexpialidocious}\n\n# substr(x,y), substr(x,y,z)\ndo_test func2-1.2.1 {\n  catchsql {SELECT SUBSTR()}\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-1.2.2 {\n  catchsql {SELECT SUBSTR('Supercalifragilisticexpialidocious')}\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-1.2.3 {\n  catchsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1,1,1)}\n} {1 {wrong number of arguments to function SUBSTR()}}\n\n# p1 is 1-indexed\ndo_test func2-1.3 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0)}\n} {Supercalifragilisticexpialidocious}\ndo_test func2-1.4 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1)}\n} {Supercalifragilisticexpialidocious}\ndo_test func2-1.5 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2)}\n} {upercalifragilisticexpialidocious}\ndo_test func2-1.6 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30)}\n} {cious}\ndo_test func2-1.7 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34)}\n} {s}\ndo_test func2-1.8 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35)}\n} {{}}\ndo_test func2-1.9 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36)}\n} {{}}\n\n# if p1<0, start from right\ndo_test func2-1.10 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -0)}\n} {Supercalifragilisticexpialidocious}\ndo_test func2-1.11 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1)}\n} {s}\ndo_test func2-1.12 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -2)}\n} {us}\ndo_test func2-1.13 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -30)}\n} {rcalifragilisticexpialidocious}\ndo_test func2-1.14 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34)}\n} {Supercalifragilisticexpialidocious}\ndo_test func2-1.15 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35)}\n} {Supercalifragilisticexpialidocious}\ndo_test func2-1.16 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36)}\n} {Supercalifragilisticexpialidocious}\n\n# p1 is 1-indexed, p2 length to return\ndo_test func2-1.17.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 1)}\n} {{}}\ndo_test func2-1.17.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 2)}\n} {S}\ndo_test func2-1.18 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, 1)}\n} {S}\ndo_test func2-1.19.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 0)}\n} {{}}\ndo_test func2-1.19.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 1)}\n} {u}\ndo_test func2-1.19.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 2)}\n} {up}\ndo_test func2-1.20 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, 1)}\n} {c}\ndo_test func2-1.21 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34, 1)}\n} {s}\ndo_test func2-1.22 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35, 1)}\n} {{}}\ndo_test func2-1.23 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, 1)}\n} {{}}\n\n# if p1<0, start from right, p2 length to return\ndo_test func2-1.24 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -0, 1)}\n} {{}}\ndo_test func2-1.25.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 0)}\n} {{}}\ndo_test func2-1.25.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 1)}\n} {s}\ndo_test func2-1.25.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -1, 2)}\n} {s}\ndo_test func2-1.26 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -2, 1)}\n} {u}\ndo_test func2-1.27 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -30, 1)}\n} {r}\ndo_test func2-1.28.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 0)}\n} {{}}\ndo_test func2-1.28.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 1)}\n} {S}\ndo_test func2-1.28.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -34, 2)}\n} {Su}\ndo_test func2-1.29.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35, 1)}\n} {{}}\ndo_test func2-1.29.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -35, 2)}\n} {S}\ndo_test func2-1.30.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 0)}\n} {{}}\ndo_test func2-1.30.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 1)}\n} {{}}\ndo_test func2-1.30.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 2)}\n} {{}}\ndo_test func2-1.30.3 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', -36, 3)}\n} {S}\n\n# p1 is 1-indexed, p2 length to return, p2<0 return p2 chars before p1\ndo_test func2-1.31.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, 0)}\n} {{}}\ndo_test func2-1.31.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, -1)}\n} {{}}\ndo_test func2-1.31.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 0, -2)}\n} {{}}\ndo_test func2-1.32.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, 0)}\n} {{}}\ndo_test func2-1.32.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 1, -1)}\n} {{}}\ndo_test func2-1.33.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, 0)}\n} {{}}\ndo_test func2-1.33.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, -1)}\n} {S}\ndo_test func2-1.33.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 2, -2)}\n} {S}\ndo_test func2-1.34.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, 0)}\n} {{}}\ndo_test func2-1.34.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, -1)}\n} {u}\ndo_test func2-1.34.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 3, -2)}\n} {Su}\ndo_test func2-1.35.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, -1)}\n} {o}\ndo_test func2-1.35.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 30, -2)}\n} {do}\ndo_test func2-1.36 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 34, -1)}\n} {u}\ndo_test func2-1.37 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 35, -1)}\n} {s}\ndo_test func2-1.38.0 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, 0)}\n} {{}}\ndo_test func2-1.38.1 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, -1)}\n} {{}}\ndo_test func2-1.38.2 {\n  execsql {SELECT SUBSTR('Supercalifragilisticexpialidocious', 36, -2)}\n} {s}\n\n\n#----------------------------------------------------------------------------\n# Test cases func2-2.*: substr implementation (utf8)\n#\n\n# Only do the following tests if TCL has UTF-8 capabilities\n#\nif {\"\\u1234\"!=\"u1234\"} {\n\ndo_test func2-2.1.1 {\n  execsql \"SELECT 'hi\\u1234ho'\"\n} \"hi\\u1234ho\"\n\n# substr(x,y), substr(x,y,z)\ndo_test func2-2.1.2 {\n  catchsql \"SELECT SUBSTR()\"\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-2.1.3 {\n  catchsql \"SELECT SUBSTR('hi\\u1234ho')\"\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-2.1.4 {\n  catchsql \"SELECT SUBSTR('hi\\u1234ho', 1,1,1)\"\n} {1 {wrong number of arguments to function SUBSTR()}}\n\ndo_test func2-2.2.0 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 0)\"\n} {{}}\ndo_test func2-2.2.1 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 1)\"\n} {{}}\ndo_test func2-2.2.2 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 2)\"\n} \"h\"\ndo_test func2-2.2.3 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 3)\"\n} \"hi\"\ndo_test func2-2.2.4 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 4)\"\n} \"hi\\u1234\"\ndo_test func2-2.2.5 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 5)\"\n} \"hi\\u1234h\"\ndo_test func2-2.2.6 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 0, 6)\"\n} \"hi\\u1234ho\"\n\ndo_test func2-2.3.0 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 0)\"\n} {{}}\ndo_test func2-2.3.1 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 1)\"\n} \"h\"\ndo_test func2-2.3.2 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 2)\"\n} \"hi\"\ndo_test func2-2.3.3 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 3)\"\n} \"hi\\u1234\"\ndo_test func2-2.3.4 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 4)\"\n} \"hi\\u1234h\"\ndo_test func2-2.3.5 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 5)\"\n} \"hi\\u1234ho\"\ndo_test func2-2.3.6 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 1, 6)\"\n} \"hi\\u1234ho\"\n\ndo_test func2-2.4.0 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 3, 0)\"\n} {{}}\ndo_test func2-2.4.1 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 3, 1)\"\n} \"\\u1234\"\ndo_test func2-2.4.2 {\n  execsql \"SELECT SUBSTR('hi\\u1234ho', 3, 2)\"\n} \"\\u1234h\"\n\ndo_test func2-2.5.0 {\n  execsql \"SELECT SUBSTR('\\u1234', 0, 0)\"\n} {{}}\ndo_test func2-2.5.1 {\n  execsql \"SELECT SUBSTR('\\u1234', 0, 1)\"\n} {{}}\ndo_test func2-2.5.2 {\n  execsql \"SELECT SUBSTR('\\u1234', 0, 2)\"\n} \"\\u1234\"\ndo_test func2-2.5.3 {\n  execsql \"SELECT SUBSTR('\\u1234', 0, 3)\"\n} \"\\u1234\"\n\ndo_test func2-2.6.0 {\n  execsql \"SELECT SUBSTR('\\u1234', 1, 0)\"\n} {{}}\ndo_test func2-2.6.1 {\n  execsql \"SELECT SUBSTR('\\u1234', 1, 1)\"\n} \"\\u1234\"\ndo_test func2-2.6.2 {\n  execsql \"SELECT SUBSTR('\\u1234', 1, 2)\"\n} \"\\u1234\"\ndo_test func2-2.6.3 {\n  execsql \"SELECT SUBSTR('\\u1234', 1, 3)\"\n} \"\\u1234\"\n\ndo_test func2-2.7.0 {\n  execsql \"SELECT SUBSTR('\\u1234', 2, 0)\"\n} {{}}\ndo_test func2-2.7.1 {\n  execsql \"SELECT SUBSTR('\\u1234', 2, 1)\"\n} {{}}\ndo_test func2-2.7.2 {\n  execsql \"SELECT SUBSTR('\\u1234', 2, 2)\"\n} {{}}\n\ndo_test func2-2.8.0 {\n  execsql \"SELECT SUBSTR('\\u1234', -1, 0)\"\n} {{}}\ndo_test func2-2.8.1 {\n  execsql \"SELECT SUBSTR('\\u1234', -1, 1)\"\n} \"\\u1234\"\ndo_test func2-2.8.2 {\n  execsql \"SELECT SUBSTR('\\u1234', -1, 2)\"\n} \"\\u1234\"\ndo_test func2-2.8.3 {\n  execsql \"SELECT SUBSTR('\\u1234', -1, 3)\"\n} \"\\u1234\"\n\n} ;# End \\u1234!=u1234\n\n#----------------------------------------------------------------------------\n# Test cases func2-3.*: substr implementation (blob)\n#\n\nifcapable {!bloblit} {\n  finish_test\n  return\n}\n\ndo_test func2-3.1.1 {\n  set blob [execsql \"SELECT x'1234'\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\n\n# substr(x,y), substr(x,y,z)\ndo_test func2-3.1.2 {\n  catchsql {SELECT SUBSTR()}\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-3.1.3 {\n  catchsql {SELECT SUBSTR(x'1234')}\n} {1 {wrong number of arguments to function SUBSTR()}}\ndo_test func2-3.1.4 {\n  catchsql {SELECT SUBSTR(x'1234', 1,1,1)}\n} {1 {wrong number of arguments to function SUBSTR()}}\n\ndo_test func2-3.2.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 0, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.2.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 0, 1)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.2.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 0, 2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.2.3 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 0, 3)\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\n\ndo_test func2-3.3.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.3.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, 1)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.3.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, 2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\ndo_test func2-3.3.3 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, 3)\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\n\ndo_test func2-3.4.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.4.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, 1)\"]\n  bin_to_hex [lindex $blob 0]\n} \"34\"\ndo_test func2-3.4.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, 2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"34\"\ndo_test func2-3.4.3 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, 3)\"]\n  bin_to_hex [lindex $blob 0]\n} \"34\"\n\ndo_test func2-3.5.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.5.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, 1)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.5.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, 2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\ndo_test func2-3.5.3 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, 3)\"]\n  bin_to_hex [lindex $blob 0]\n} \"1234\"\n\ndo_test func2-3.6.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.6.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, -1)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.6.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, -2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.6.3 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -1, -3)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\n\ndo_test func2-3.7.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.7.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, -1)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.7.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', -2, -2)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\n\ndo_test func2-3.8.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.8.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, -1)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.8.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 1, -2)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\n\ndo_test func2-3.9.0 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 2, 0)\"]\n  bin_to_hex [lindex $blob 0]\n} {}\ndo_test func2-3.9.1 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 2, -1)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\ndo_test func2-3.9.2 {\n  set blob [execsql \"SELECT SUBSTR(x'1234', 2, -2)\"]\n  bin_to_hex [lindex $blob 0]\n} \"12\"\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/func3.test",
    "content": "# 2010 August 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus of this file is testing that destructor functions associated\n# with functions created using sqlite3_create_function_v2() is \n# correctly invoked.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\nifcapable utf16 {\n  do_test func3-1.1 {\n    set destroyed 0\n    proc destroy {} { set ::destroyed 1 }\n    sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy\n    set destroyed\n  } 0\n  do_test func3-1.2 {\n    sqlite3_create_function_v2 db f2 -1 utf8 -func f2\n    set destroyed\n  } 0\n  do_test func3-1.3 {\n    sqlite3_create_function_v2 db f2 -1 utf16le -func f2\n    set destroyed\n  } 0\n  do_test func3-1.4 {\n    sqlite3_create_function_v2 db f2 -1 utf16be -func f2\n    set destroyed\n  } 1\n}\n\ndo_test func3-2.1 {\n  set destroyed 0\n  proc destroy {} { set ::destroyed 1 }\n  sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy\n  set destroyed\n} 0\ndo_test func3-2.2 {\n  sqlite3_create_function_v2 db f3 -1 utf8 -func f3\n  set destroyed\n} 1\n\ndo_test func3-3.1 {\n  set destroyed 0\n  proc destroy {} { set ::destroyed 1 }\n  sqlite3_create_function_v2 db f3 -1 any -func f3 -destroy destroy\n  set destroyed\n} 0\ndo_test func3-3.2 {\n  db close\n  set destroyed\n} 1\n\nsqlite3 db test.db\ndo_test func3-4.1 {\n  set destroyed 0\n  set rc [catch { \n    sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy\n  } msg]\n  list $rc $msg\n} {1 SQLITE_MISUSE}\ndo_test func3-4.2 { set destroyed } 1\n\n# EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns\n# argument X unchanged.\n#\ndo_execsql_test func3-5.1 {\n  SELECT likelihood(9223372036854775807, 0.5);\n} {9223372036854775807}\ndo_execsql_test func3-5.2 {\n  SELECT likelihood(-9223372036854775808, 0.5);\n} {-9223372036854775808}\ndo_execsql_test func3-5.3 {\n  SELECT likelihood(14.125, 0.5);\n} {14.125}\ndo_execsql_test func3-5.4 {\n  SELECT likelihood(NULL, 0.5);\n} {{}}\ndo_execsql_test func3-5.5 {\n  SELECT likelihood('test-string', 0.5);\n} {test-string}\ndo_execsql_test func3-5.6 {\n  SELECT quote(likelihood(x'010203000405', 0.5));\n} {X'010203000405'}\n\n# EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a\n# floating point constant between 0.0 and 1.0, inclusive.\n#\ndo_execsql_test func3-5.7 {\n  SELECT likelihood(123, 1.0), likelihood(456, 0.0);\n} {123 456}\ndo_test func3-5.8 {\n  catchsql {\n    SELECT likelihood(123, 1.000001);\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\ndo_test func3-5.9 {\n  catchsql {\n    SELECT likelihood(123, -0.000001);\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\ndo_test func3-5.10 {\n  catchsql {\n    SELECT likelihood(123, 0.5+0.3);\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\n\n# EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that\n# the code generator optimizes away so that it consumes no CPU cycles\n# during run-time (that is, during calls to sqlite3_step()).\n#\ndo_test func3-5.20 {\n  db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)}\n} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]\n\n\n# EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the\n# argument X unchanged.\n#\ndo_execsql_test func3-5.30 {\n  SELECT unlikely(9223372036854775807);\n} {9223372036854775807}\ndo_execsql_test func3-5.31 {\n  SELECT unlikely(-9223372036854775808);\n} {-9223372036854775808}\ndo_execsql_test func3-5.32 {\n  SELECT unlikely(14.125);\n} {14.125}\ndo_execsql_test func3-5.33 {\n  SELECT unlikely(NULL);\n} {{}}\ndo_execsql_test func3-5.34 {\n  SELECT unlikely('test-string');\n} {test-string}\ndo_execsql_test func3-5.35 {\n  SELECT quote(unlikely(x'010203000405'));\n} {X'010203000405'}\n\n# EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that\n# the code generator optimizes away so that it consumes no CPU cycles at\n# run-time (that is, during calls to sqlite3_step()).\n#\ndo_test func3-5.39 {\n  db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}\n} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]\n\n\n# EVIDENCE-OF: R-23735-03107 The likely(X) function returns the argument\n# X unchanged.\n#\ndo_execsql_test func3-5.50 {\n  SELECT likely(9223372036854775807);\n} {9223372036854775807}\ndo_execsql_test func3-5.51 {\n  SELECT likely(-9223372036854775808);\n} {-9223372036854775808}\ndo_execsql_test func3-5.52 {\n  SELECT likely(14.125);\n} {14.125}\ndo_execsql_test func3-5.53 {\n  SELECT likely(NULL);\n} {{}}\ndo_execsql_test func3-5.54 {\n  SELECT likely('test-string');\n} {test-string}\ndo_execsql_test func3-5.55 {\n  SELECT quote(likely(x'010203000405'));\n} {X'010203000405'}\n\n# EVIDENCE-OF: R-43464-09689 The likely(X) function is a no-op that the\n# code generator optimizes away so that it consumes no CPU cycles at\n# run-time (that is, during calls to sqlite3_step()).\n#\ndo_test func3-5.59 {\n  db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))}\n} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/func4.test",
    "content": "# 2013 March 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus of\n# this file is testing the tointeger() and toreal() functions.\n#\n# Several of the toreal() tests are disabled on platforms where floating\n# point precision is not high enough to represent their constant integer\n# expression arguments as double precision floating point values.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset saved_tcl_precision $tcl_precision\nset tcl_precision 0\nload_static_extension db totype\n\nset highPrecision(1) [expr \\\n    {[db eval {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}]\n\ndo_execsql_test func4-1.1 {\n  SELECT tointeger(NULL);\n} {{}}\ndo_execsql_test func4-1.2 {\n  SELECT tointeger('');\n} {{}}\ndo_execsql_test func4-1.3 {\n  SELECT tointeger('   ');\n} {{}}\ndo_execsql_test func4-1.4 {\n  SELECT tointeger('1234');\n} {1234}\ndo_execsql_test func4-1.5 {\n  SELECT tointeger('   1234');\n} {{}}\ndo_execsql_test func4-1.6 {\n  SELECT tointeger('bad');\n} {{}}\ndo_execsql_test func4-1.7 {\n  SELECT tointeger('0xBAD');\n} {{}}\ndo_execsql_test func4-1.8 {\n  SELECT tointeger('123BAD');\n} {{}}\ndo_execsql_test func4-1.9 {\n  SELECT tointeger('0x123BAD');\n} {{}}\ndo_execsql_test func4-1.10 {\n  SELECT tointeger('123NO');\n} {{}}\ndo_execsql_test func4-1.11 {\n  SELECT tointeger('0x123NO');\n} {{}}\ndo_execsql_test func4-1.12 {\n  SELECT tointeger('-0x1');\n} {{}}\ndo_execsql_test func4-1.13 {\n  SELECT tointeger('-0x0');\n} {{}}\ndo_execsql_test func4-1.14 {\n  SELECT tointeger('0x0');\n} {{}}\ndo_execsql_test func4-1.15 {\n  SELECT tointeger('0x1');\n} {{}}\ndo_execsql_test func4-1.16 {\n  SELECT tointeger(-1);\n} {-1}\ndo_execsql_test func4-1.17 {\n  SELECT tointeger(-0);\n} {0}\ndo_execsql_test func4-1.18 {\n  SELECT tointeger(0);\n} {0}\ndo_execsql_test func4-1.19 {\n  SELECT tointeger(1);\n} {1}\ndo_execsql_test func4-1.20 {\n  SELECT tointeger(-1.79769313486232e308 - 1);\n} {{}}\ndo_execsql_test func4-1.21 {\n  SELECT tointeger(-1.79769313486232e308);\n} {{}}\ndo_execsql_test func4-1.22 {\n  SELECT tointeger(-1.79769313486232e308 + 1);\n} {{}}\ndo_execsql_test func4-1.23 {\n  SELECT tointeger(-9223372036854775808 - 1);\n} {-9223372036854775808}\ndo_execsql_test func4-1.24 {\n  SELECT tointeger(-9223372036854775808);\n} {-9223372036854775808}\ndo_execsql_test func4-1.25 {\n  SELECT tointeger(-9223372036854775808 + 1);\n} {-9223372036854775807}\ndo_execsql_test func4-1.26 {\n  SELECT tointeger(-9223372036854775807 - 1);\n} {-9223372036854775808}\ndo_execsql_test func4-1.27 {\n  SELECT tointeger(-9223372036854775807);\n} {-9223372036854775807}\ndo_execsql_test func4-1.28 {\n  SELECT tointeger(-9223372036854775807 + 1);\n} {-9223372036854775806}\ndo_execsql_test func4-1.29 {\n  SELECT tointeger(-2147483648 - 1);\n} {-2147483649}\ndo_execsql_test func4-1.30 {\n  SELECT tointeger(-2147483648);\n} {-2147483648}\ndo_execsql_test func4-1.31 {\n  SELECT tointeger(-2147483648 + 1);\n} {-2147483647}\ndo_execsql_test func4-1.32 {\n  SELECT tointeger(2147483647 - 1);\n} {2147483646}\ndo_execsql_test func4-1.33 {\n  SELECT tointeger(2147483647);\n} {2147483647}\ndo_execsql_test func4-1.34 {\n  SELECT tointeger(2147483647 + 1);\n} {2147483648}\ndo_execsql_test func4-1.35 {\n  SELECT tointeger(9223372036854775807 - 1);\n} {9223372036854775806}\ndo_execsql_test func4-1.36 {\n  SELECT tointeger(9223372036854775807);\n} {9223372036854775807}\nif {$highPrecision(1)} {\n  do_execsql_test func4-1.37 {\n    SELECT tointeger(9223372036854775807 + 1);\n  } {{}}\n}\ndo_execsql_test func4-1.38 {\n  SELECT tointeger(1.79769313486232e308 - 1);\n} {{}}\ndo_execsql_test func4-1.39 {\n  SELECT tointeger(1.79769313486232e308);\n} {{}}\ndo_execsql_test func4-1.40 {\n  SELECT tointeger(1.79769313486232e308 + 1);\n} {{}}\ndo_execsql_test func4-1.41 {\n  SELECT tointeger(4503599627370496 - 1);\n} {4503599627370495}\ndo_execsql_test func4-1.42 {\n  SELECT tointeger(4503599627370496);\n} {4503599627370496}\ndo_execsql_test func4-1.43 {\n  SELECT tointeger(4503599627370496 + 1);\n} {4503599627370497}\ndo_execsql_test func4-1.44 {\n  SELECT tointeger(9007199254740992 - 1);\n} {9007199254740991}\ndo_execsql_test func4-1.45 {\n  SELECT tointeger(9007199254740992);\n} {9007199254740992}\ndo_execsql_test func4-1.46 {\n  SELECT tointeger(9007199254740992 + 1);\n} {9007199254740993}\ndo_execsql_test func4-1.47 {\n  SELECT tointeger(9223372036854775807 - 1);\n} {9223372036854775806}\ndo_execsql_test func4-1.48 {\n  SELECT tointeger(9223372036854775807);\n} {9223372036854775807}\nif {$highPrecision(1)} {\n  do_execsql_test func4-1.49 {\n    SELECT tointeger(9223372036854775807 + 1);\n  } {{}}\n  do_execsql_test func4-1.50 {\n    SELECT tointeger(9223372036854775808 - 1);\n  } {{}}\n  do_execsql_test func4-1.51 {\n    SELECT tointeger(9223372036854775808);\n  } {{}}\n  do_execsql_test func4-1.52 {\n    SELECT tointeger(9223372036854775808 + 1);\n  } {{}}\n}\ndo_execsql_test func4-1.53 {\n  SELECT tointeger(18446744073709551616 - 1);\n} {{}}\ndo_execsql_test func4-1.54 {\n  SELECT tointeger(18446744073709551616);\n} {{}}\ndo_execsql_test func4-1.55 {\n  SELECT tointeger(18446744073709551616 + 1);\n} {{}}\n\nifcapable floatingpoint {\n  set highPrecision(2) [expr \\\n      {[db eval {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}]\n\n  do_execsql_test func4-2.1 {\n    SELECT toreal(NULL);\n  } {{}}\n  do_execsql_test func4-2.2 {\n    SELECT toreal('');\n  } {{}}\n  do_execsql_test func4-2.3 {\n    SELECT toreal('   ');\n  } {{}}\n  do_execsql_test func4-2.4 {\n    SELECT toreal('1234');\n  } {1234.0}\n  do_execsql_test func4-2.5 {\n    SELECT toreal('   1234');\n  } {{}}\n  do_execsql_test func4-2.6 {\n    SELECT toreal('bad');\n  } {{}}\n  do_execsql_test func4-2.7 {\n    SELECT toreal('0xBAD');\n  } {{}}\n  do_execsql_test func4-2.8 {\n    SELECT toreal('123BAD');\n  } {{}}\n  do_execsql_test func4-2.9 {\n    SELECT toreal('0x123BAD');\n  } {{}}\n  do_execsql_test func4-2.10 {\n    SELECT toreal('123NO');\n  } {{}}\n  do_execsql_test func4-2.11 {\n    SELECT toreal('0x123NO');\n  } {{}}\n  do_execsql_test func4-2.12 {\n    SELECT toreal('-0x1');\n  } {{}}\n  do_execsql_test func4-2.13 {\n    SELECT toreal('-0x0');\n  } {{}}\n  do_execsql_test func4-2.14 {\n    SELECT toreal('0x0');\n  } {{}}\n  do_execsql_test func4-2.15 {\n    SELECT toreal('0x1');\n  } {{}}\n  do_execsql_test func4-2.16 {\n    SELECT toreal(-1);\n  } {-1.0}\n  do_execsql_test func4-2.17 {\n    SELECT toreal(-0);\n  } {0.0}\n  do_execsql_test func4-2.18 {\n    SELECT toreal(0);\n  } {0.0}\n  do_execsql_test func4-2.19 {\n    SELECT toreal(1);\n  } {1.0}\n  do_execsql_test func4-2.20 {\n    SELECT toreal(-1.79769313486232e308 - 1);\n  } {-Inf}\n  do_execsql_test func4-2.21 {\n    SELECT toreal(-1.79769313486232e308);\n  } {-Inf}\n  do_execsql_test func4-2.22 {\n    SELECT toreal(-1.79769313486232e308 + 1);\n  } {-Inf}\n  do_execsql_test func4-2.23 {\n    SELECT toreal(-9223372036854775808 - 1);\n  } {-9.223372036854776e+18}\n  do_execsql_test func4-2.24 {\n    SELECT toreal(-9223372036854775808);\n  } {-9.223372036854776e+18}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-2.25 {\n      SELECT toreal(-9223372036854775808 + 1);\n    } {{}}\n  }\n  do_execsql_test func4-2.26 {\n    SELECT toreal(-9223372036854775807 - 1);\n  } {-9.223372036854776e+18}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-2.27 {\n      SELECT toreal(-9223372036854775807);\n    } {{}}\n    do_execsql_test func4-2.28 {\n      SELECT toreal(-9223372036854775807 + 1);\n    } {{}}\n  }\n  do_execsql_test func4-2.29 {\n    SELECT toreal(-2147483648 - 1);\n  } {-2147483649.0}\n  do_execsql_test func4-2.30 {\n    SELECT toreal(-2147483648);\n  } {-2147483648.0}\n  do_execsql_test func4-2.31 {\n    SELECT toreal(-2147483648 + 1);\n  } {-2147483647.0}\n  do_execsql_test func4-2.32 {\n    SELECT toreal(2147483647 - 1);\n  } {2147483646.0}\n  do_execsql_test func4-2.33 {\n    SELECT toreal(2147483647);\n  } {2147483647.0}\n  do_execsql_test func4-2.34 {\n    SELECT toreal(2147483647 + 1);\n  } {2147483648.0}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-2.35 {\n      SELECT toreal(9223372036854775807 - 1);\n    } {{}}\n    if {$highPrecision(1)} {\n      do_execsql_test func4-2.36 {\n        SELECT toreal(9223372036854775807);\n      } {{}}\n    }\n  }\n  do_execsql_test func4-2.37 {\n    SELECT toreal(9223372036854775807 + 1);\n  } {9.223372036854776e+18}\n  do_execsql_test func4-2.38 {\n    SELECT toreal(1.79769313486232e308 - 1);\n  } {Inf}\n  do_execsql_test func4-2.39 {\n    SELECT toreal(1.79769313486232e308);\n  } {Inf}\n  do_execsql_test func4-2.40 {\n    SELECT toreal(1.79769313486232e308 + 1);\n  } {Inf}\n  do_execsql_test func4-2.41 {\n    SELECT toreal(4503599627370496 - 1);\n  } {4503599627370495.0}\n  do_execsql_test func4-2.42 {\n    SELECT toreal(4503599627370496);\n  } {4503599627370496.0}\n  do_execsql_test func4-2.43 {\n    SELECT toreal(4503599627370496 + 1);\n  } {4503599627370497.0}\n  do_execsql_test func4-2.44 {\n    SELECT toreal(9007199254740992 - 1);\n  } {9007199254740991.0}\n  do_execsql_test func4-2.45 {\n    SELECT toreal(9007199254740992);\n  } {9007199254740992.0}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-2.46 {\n      SELECT toreal(9007199254740992 + 1);\n    } {{}}\n  }\n  do_execsql_test func4-2.47 {\n    SELECT toreal(9007199254740992 + 2);\n  } {9007199254740994.0}\n  do_execsql_test func4-2.48 {\n    SELECT toreal(tointeger(9223372036854775808) - 1);\n  } {{}}\n  if {$highPrecision(1)} {\n    do_execsql_test func4-2.49 {\n      SELECT toreal(tointeger(9223372036854775808));\n    } {{}}\n    do_execsql_test func4-2.50 {\n      SELECT toreal(tointeger(9223372036854775808) + 1);\n    } {{}}\n  }\n  do_execsql_test func4-2.51 {\n    SELECT toreal(tointeger(18446744073709551616) - 1);\n  } {{}}\n  do_execsql_test func4-2.52 {\n    SELECT toreal(tointeger(18446744073709551616));\n  } {{}}\n  do_execsql_test func4-2.53 {\n    SELECT toreal(tointeger(18446744073709551616) + 1);\n  } {{}}\n}\n\nifcapable check {\n  do_execsql_test func4-3.1 {\n    CREATE TABLE t1(\n      x INTEGER CHECK(tointeger(x) IS NOT NULL)\n    );\n  } {}\n  do_test func4-3.2 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (NULL);\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.3 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (NULL);\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.4 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.5 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('bad');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.6 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('1234bad');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.7 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('1234.56bad');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.8 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (1234);\n    }\n  } {0 {}}\n  do_test func4-3.9 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (1234.56);\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.10 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('1234');\n    }\n  } {0 {}}\n  do_test func4-3.11 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('1234.56');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.12 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (ZEROBLOB(4));\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.13 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (X'');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.14 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (X'1234');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.15 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (X'12345678');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.16 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('1234.00');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  do_test func4-3.17 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES (1234.00);\n    }\n  } {0 {}}\n  do_test func4-3.18 {\n    catchsql {\n      INSERT INTO t1 (x) VALUES ('-9223372036854775809');\n    }\n  } {1 {CHECK constraint failed: t1}}\n  if {$highPrecision(1)} {\n    do_test func4-3.19 {\n      catchsql {\n        INSERT INTO t1 (x) VALUES (9223372036854775808);\n      }\n    } {1 {CHECK constraint failed: t1}}\n  }\n  do_execsql_test func4-3.20 {\n    SELECT x FROM t1 ORDER BY x;\n  } {1234 1234 1234}\n\n  ifcapable floatingpoint {\n    do_execsql_test func4-4.1 {\n      CREATE TABLE t2(\n        x REAL CHECK(toreal(x) IS NOT NULL)\n      );\n    } {}\n    do_test func4-4.2 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (NULL);\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.3 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (NULL);\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.4 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.5 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('bad');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.6 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('1234bad');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.7 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('1234.56bad');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.8 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (1234);\n      }\n    } {0 {}}\n    do_test func4-4.9 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (1234.56);\n      }\n    } {0 {}}\n    do_test func4-4.10 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('1234');\n      }\n    } {0 {}}\n    do_test func4-4.11 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES ('1234.56');\n      }\n    } {0 {}}\n    do_test func4-4.12 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (ZEROBLOB(4));\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.13 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (X'');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.14 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (X'1234');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_test func4-4.15 {\n      catchsql {\n        INSERT INTO t2 (x) VALUES (X'12345678');\n      }\n    } {1 {CHECK constraint failed: t2}}\n    do_execsql_test func4-4.16 {\n      SELECT x FROM t2 ORDER BY x;\n    } {1234.0 1234.0 1234.56 1234.56}\n  }\n}\n\nifcapable floatingpoint {\n  do_execsql_test func4-5.1 {\n    SELECT tointeger(toreal('1234'));\n  } {1234}\n  do_execsql_test func4-5.2 {\n    SELECT tointeger(toreal(-1));\n  } {-1}\n  do_execsql_test func4-5.3 {\n    SELECT tointeger(toreal(-0));\n  } {0}\n  do_execsql_test func4-5.4 {\n    SELECT tointeger(toreal(0));\n  } {0}\n  do_execsql_test func4-5.5 {\n    SELECT tointeger(toreal(1));\n  } {1}\n  do_execsql_test func4-5.6 {\n    SELECT tointeger(toreal(-9223372036854775808 - 1));\n  } {-9223372036854775808}\n  do_execsql_test func4-5.7 {\n    SELECT tointeger(toreal(-9223372036854775808));\n  } {-9223372036854775808}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-5.8 {\n      SELECT tointeger(toreal(-9223372036854775808 + 1));\n    } {{}}\n  }\n  do_execsql_test func4-5.9 {\n    SELECT tointeger(toreal(-2147483648 - 1));\n  } {-2147483649}\n  do_execsql_test func4-5.10 {\n    SELECT tointeger(toreal(-2147483648));\n  } {-2147483648}\n  do_execsql_test func4-5.11 {\n    SELECT tointeger(toreal(-2147483648 + 1));\n  } {-2147483647}\n  do_execsql_test func4-5.12 {\n    SELECT tointeger(toreal(2147483647 - 1));\n  } {2147483646}\n  do_execsql_test func4-5.13 {\n    SELECT tointeger(toreal(2147483647));\n  } {2147483647}\n  do_execsql_test func4-5.14 {\n    SELECT tointeger(toreal(2147483647 + 1));\n  } {2147483648}\n  do_execsql_test func4-5.15 {\n    SELECT tointeger(toreal(9223372036854775807 - 1));\n  } {{}}\n  if {$highPrecision(1)} {\n    do_execsql_test func4-5.16 {\n      SELECT tointeger(toreal(9223372036854775807));\n    } {{}}\n    do_execsql_test func4-5.17 {\n      SELECT tointeger(toreal(9223372036854775807 + 1));\n    } {{}}\n  }\n  do_execsql_test func4-5.18 {\n    SELECT tointeger(toreal(4503599627370496 - 1));\n  } {4503599627370495}\n  do_execsql_test func4-5.19 {\n    SELECT tointeger(toreal(4503599627370496));\n  } {4503599627370496}\n  do_execsql_test func4-5.20 {\n    SELECT tointeger(toreal(4503599627370496 + 1));\n  } {4503599627370497}\n  do_execsql_test func4-5.21 {\n    SELECT tointeger(toreal(9007199254740992 - 1));\n  } {9007199254740991}\n  do_execsql_test func4-5.22 {\n    SELECT tointeger(toreal(9007199254740992));\n  } {9007199254740992}\n  if {$highPrecision(2)} {\n    do_execsql_test func4-5.23 {\n      SELECT tointeger(toreal(9007199254740992 + 1));\n    } {{}}\n  }\n  do_execsql_test func4-5.24 {\n    SELECT tointeger(toreal(9007199254740992 + 2));\n  } {9007199254740994}\n  if {$highPrecision(1)} {\n    do_execsql_test func4-5.25 {\n      SELECT tointeger(toreal(9223372036854775808 - 1));\n    } {{}}\n    do_execsql_test func4-5.26 {\n      SELECT tointeger(toreal(9223372036854775808));\n    } {{}}\n    do_execsql_test func4-5.27 {\n      SELECT tointeger(toreal(9223372036854775808 + 1));\n    } {{}}\n  }\n  do_execsql_test func4-5.28 {\n    SELECT tointeger(toreal(18446744073709551616 - 1));\n  } {{}}\n  do_execsql_test func4-5.29 {\n    SELECT tointeger(toreal(18446744073709551616));\n  } {{}}\n  do_execsql_test func4-5.30 {\n    SELECT tointeger(toreal(18446744073709551616 + 1));\n  } {{}}\n}\n\nfor {set i 0} {$i < 10} {incr i} {\n  if {$i == 8} continue\n  do_execsql_test func4-6.1.$i.1 [subst {\n    SELECT tointeger(x'[string repeat 01 $i]');\n  }] {{}}\n  ifcapable floatingpoint {\n    do_execsql_test func4-6.1.$i.2 [subst {\n      SELECT toreal(x'[string repeat 01 $i]');\n    }] {{}}\n  }\n}\n\ndo_execsql_test func4-6.2.1 {\n  SELECT tointeger(x'0102030405060708');\n} {578437695752307201}\ndo_execsql_test func4-6.2.2 {\n  SELECT tointeger(x'0807060504030201');\n} {72623859790382856}\n\nifcapable floatingpoint {\n  do_execsql_test func4-6.3.1 {\n    SELECT toreal(x'ffefffffffffffff');\n  } {-1.7976931348623157e+308}\n  do_execsql_test func4-6.3.2 {\n    SELECT toreal(x'8010000000000000');\n  } {-2.2250738585072014e-308}\n  do_execsql_test func4-6.3.3 {\n    SELECT toreal(x'c000000000000000');\n  } {-2.0}\n  do_execsql_test func4-6.3.4 {\n    SELECT toreal(x'bff0000000000000');\n  } {-1.0}\n  do_execsql_test func4-6.3.5 {\n    SELECT toreal(x'8000000000000000');\n  } {-0.0}\n  do_execsql_test func4-6.3.6 {\n    SELECT toreal(x'0000000000000000');\n  } {0.0}\n  do_execsql_test func4-6.3.7 {\n    SELECT toreal(x'3ff0000000000000');\n  } {1.0}\n  do_execsql_test func4-6.3.8 {\n    SELECT toreal(x'4000000000000000');\n  } {2.0}\n  do_execsql_test func4-6.3.9 {\n    SELECT toreal(x'0010000000000000');\n  } {2.2250738585072014e-308}\n  do_execsql_test func4-6.3.10 {\n    SELECT toreal(x'7fefffffffffffff');\n  } {1.7976931348623157e+308}\n  do_execsql_test func4-6.3.11 {\n    SELECT toreal(x'8000000000000001');\n  } {-5e-324}\n  do_execsql_test func4-6.3.12 {\n    SELECT toreal(x'800fffffffffffff');\n  } {-2.225073858507201e-308}\n  do_execsql_test func4-6.3.13 {\n    SELECT toreal(x'0000000000000001');\n  } {5e-324}\n  do_execsql_test func4-6.3.14 {\n    SELECT toreal(x'000fffffffffffff');\n  } {2.225073858507201e-308}\n  do_execsql_test func4-6.3.15 {\n    SELECT toreal(x'fff0000000000000');\n  } {-Inf}\n  do_execsql_test func4-6.3.16 {\n    SELECT toreal(x'7ff0000000000000');\n  } {Inf}\n  do_execsql_test func4-6.3.17 {\n    SELECT toreal(x'fff8000000000000');\n  } {{}}\n  do_execsql_test func4-6.3.18 {\n    SELECT toreal(x'fff0000000000001');\n  } {{}}\n  do_execsql_test func4-6.3.19 {\n    SELECT toreal(x'fff7ffffffffffff');\n  } {{}}\n  do_execsql_test func4-6.3.20 {\n    SELECT toreal(x'7ff0000000000001');\n  } {{}}\n  do_execsql_test func4-6.3.21 {\n    SELECT toreal(x'7ff7ffffffffffff');\n  } {{}}\n  do_execsql_test func4-6.3.22 {\n    SELECT toreal(x'fff8000000000001');\n  } {{}}\n  do_execsql_test func4-6.3.23 {\n    SELECT toreal(x'ffffffffffffffff');\n  } {{}}\n  do_execsql_test func4-6.3.24 {\n    SELECT toreal(x'7ff8000000000000');\n  } {{}}\n  do_execsql_test func4-6.3.25 {\n    SELECT toreal(x'7fffffffffffffff');\n  } {{}}\n}\n\nset tcl_precision $saved_tcl_precision\nunset saved_tcl_precision\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/func5.test",
    "content": "# 2013-11-21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Testing of function factoring and the SQLITE_DETERMINISTIC flag.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Verify that constant string expressions that get factored into initializing\n# code are not reused between function parameters and other values in the\n# VDBE program, as the function might have changed the encoding.\n#\ndo_execsql_test func5-1.1 {\n  PRAGMA encoding=UTF16le;\n  CREATE TABLE t1(x,a,b,c);\n  INSERT INTO t1 VALUES(1,'ab','cd',1);\n  INSERT INTO t1 VALUES(2,'gh','ef',5);\n  INSERT INTO t1 VALUES(3,'pqr','fuzzy',99);\n  INSERT INTO t1 VALUES(4,'abcdefg','xy',22);\n  INSERT INTO t1 VALUES(5,'shoe','mayer',2953);\n  SELECT x FROM t1 WHERE c=instr('abcdefg',b) OR a='abcdefg' ORDER BY +x;\n} {2 4}\ndo_execsql_test func5-1.2 {\n  SELECT x FROM t1 WHERE a='abcdefg' OR c=instr('abcdefg',b) ORDER BY +x;\n} {2 4}\n\n# Verify that SQLITE_DETERMINISTIC functions get factored out of the\n# evaluation loop whereas non-deterministic functions do not.  counter1()\n# is marked as non-deterministic and so is not factored out of the loop,\n# and it really is non-deterministic, returning a different result each\n# time.  But counter2() is marked as deterministic, so it does get factored\n# out of the loop.  counter2() has the same implementation as counter1(),\n# returning a different result on each invocation, but because it is \n# only invoked once outside of the loop, it appears to return the same\n# result multiple times.\n#\ndo_execsql_test func5-2.1 {\n  CREATE TABLE t2(x,y);\n  INSERT INTO t2 VALUES(1,2),(3,4),(5,6),(7,8);\n  SELECT x, y FROM t2 WHERE x+5=5+x ORDER BY +x;\n} {1 2 3 4 5 6 7 8}\nsqlite3_create_function db\ndo_execsql_test func5-2.2 {\n  SELECT x, y FROM t2\n   WHERE x+counter1('hello')=counter1('hello')+x\n   ORDER BY +x;\n} {}\ndo_execsql_test func5-2.3 {\n  SELECT x, y FROM t2\n   WHERE x+counter2('hello')=counter2('hello')+x\n   ORDER BY +x;\n} {1 2 3 4 5 6 7 8}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz-oss1.test",
    "content": "# 2012 May 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n# NB:  Portions of this file are extracted from open-source projects\n# covered by permissive licenses.  Use of this file for testing is clearly\n# allowed.  However, do not incorporate the text of this one file into\n# end-products without checking the licenses on the open-source projects\n# from which this code was extracted.  This warning applies to this one\n# file only - not the bulk of the SQLite source code and tests.\n#\n#***********************************************************************\n#\n# This file contains large and complex schemas obtained from open-source\n# software projects.  The schemas are parsed just to make sure that nothing\n# breaks in the parser logic.\n#\n# These tests merely verify that the parse occurs without error.\n# No attempt is made to verify correct operation of the resulting schema\n# and statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Schema and query extracted from Skrooge.org.  \n#\ndo_test fuzz-oss1-skrooge {\n  db eval {\nCREATE TABLE parameters (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_uuid_parent TEXT NOT NULL DEFAULT '',t_name TEXT NOT NULL,t_value TEXT NOT NULL DEFAULT '',b_blob BLOB,d_lastmodifdate DATE NOT NULL DEFAULT CURRENT_TIMESTAMP,i_tmp INTEGER NOT NULL DEFAULT 0);\nCREATE TABLE doctransaction (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_mode VARCHAR(1) DEFAULT 'U' CHECK (t_mode IN ('U', 'R')),d_date DATE NOT NULL,t_savestep VARCHAR(1) DEFAULT 'N' CHECK (t_savestep IN ('Y', 'N')),i_parent INTEGER, t_refreshviews VARCHAR(1) DEFAULT 'Y' CHECK (t_refreshviews IN ('Y', 'N')));\nCREATE TABLE doctransactionitem (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, rd_doctransaction_id INTEGER NOT NULL,i_object_id INTEGER NOT NULL,t_object_table TEXT NOT NULL,t_action VARCHAR(1) DEFAULT 'I' CHECK (t_action IN ('I', 'U', 'D')),t_sqlorder TEXT NOT NULL DEFAULT '');\nCREATE TABLE doctransactionmsg (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, rd_doctransaction_id INTEGER NOT NULL,t_message TEXT NOT NULL DEFAULT '',t_popup VARCHAR(1) DEFAULT 'Y' CHECK (t_popup IN ('Y', 'N')));\nCREATE TABLE unit(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_symbol TEXT NOT NULL DEFAULT '',t_country TEXT NOT NULL DEFAULT '',t_type VARCHAR(1) NOT NULL DEFAULT 'C' CHECK (t_type IN ('1', '2', 'C', 'S', 'I', 'O')),t_internet_code TEXT NOT NULL DEFAULT '',i_nbdecimal INT NOT NULL DEFAULT 2,rd_unit_id INTEGER NOT NULL DEFAULT 0, t_source TEXT NOT NULL DEFAULT '');\nCREATE TABLE unitvalue(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rd_unit_id INTEGER NOT NULL,d_date DATE NOT NULL,f_quantity FLOAT NOT NULL CHECK (f_quantity>=0));\nCREATE TABLE bank (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_bank_number TEXT NOT NULL DEFAULT '',t_icon TEXT NOT NULL DEFAULT '');\nCREATE TABLE interest(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rd_account_id INTEGER NOT NULL,d_date DATE NOT NULL,f_rate FLOAT NOT NULL CHECK (f_rate>=0),t_income_value_date_mode VARCHAR(1) NOT NULL DEFAULT 'F' CHECK (t_income_value_date_mode IN ('F', '0', '1', '2', '3', '4', '5')),t_expenditure_value_date_mode VARCHAR(1) NOT NULL DEFAULT 'F' CHECK (t_expenditure_value_date_mode IN ('F', '0', '1', '2', '3', '4', '5')),t_base VARCHAR(3) NOT NULL DEFAULT '24' CHECK (t_base IN ('24', '360', '365')));\nCREATE TABLE operation(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,i_group_id INTEGER NOT NULL DEFAULT 0,i_number INTEGER DEFAULT 0 CHECK (i_number>=0),d_date DATE NOT NULL DEFAULT '0000-00-00',rd_account_id INTEGER NOT NULL,t_mode TEXT NOT NULL DEFAULT '',r_payee_id INTEGER NOT NULL DEFAULT 0,t_comment TEXT NOT NULL DEFAULT '',rc_unit_id INTEGER NOT NULL,t_status VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_status IN ('N', 'P', 'Y')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),t_imported VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_imported IN ('Y', 'N', 'P', 'T')),t_template VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_template IN ('Y', 'N')),t_import_id TEXT NOT NULL DEFAULT '',i_tmp INTEGER NOT NULL DEFAULT 0,r_recurrentoperation_id INTEGER NOT NULL DEFAULT 0);\nCREATE TABLE operationbalance(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,f_balance FLOAT NOT NULL DEFAULT 0,r_operation_id INTEGER NOT NULL);\nCREATE TABLE refund (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_comment TEXT NOT NULL DEFAULT '',t_close VARCHAR(1) DEFAULT 'N' CHECK (t_close IN ('Y', 'N')));\nCREATE TABLE payee (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '',t_address TEXT NOT NULL DEFAULT '', t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')));\nCREATE TABLE suboperation(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_comment TEXT NOT NULL DEFAULT '',rd_operation_id INTEGER NOT NULL,r_category_id INTEGER NOT NULL DEFAULT 0,f_value FLOAT NOT NULL DEFAULT 0.0,i_tmp INTEGER NOT NULL DEFAULT 0,r_refund_id INTEGER NOT NULL DEFAULT 0, t_formula TEXT NOT NULL DEFAULT '');\nCREATE TABLE rule (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_description TEXT NOT NULL DEFAULT '',t_definition TEXT NOT NULL DEFAULT '',t_action_description TEXT NOT NULL DEFAULT '',t_action_definition TEXT NOT NULL DEFAULT '',t_action_type VARCHAR(1) DEFAULT 'S' CHECK (t_action_type IN ('S', 'U', 'A')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),f_sortorder FLOAT);\nCREATE TABLE budget (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rc_category_id INTEGER NOT NULL DEFAULT 0,t_including_subcategories TEXT NOT NULL DEFAULT 'N' CHECK (t_including_subcategories IN ('Y', 'N')),f_budgeted FLOAT NOT NULL DEFAULT 0.0,f_budgeted_modified FLOAT NOT NULL DEFAULT 0.0,f_transferred FLOAT NOT NULL DEFAULT 0.0,i_year INTEGER NOT NULL DEFAULT 2010,i_month INTEGER NOT NULL DEFAULT 0 CHECK (i_month>=0 AND i_month<=12));\nCREATE TABLE budgetcategory(id INTEGER NOT NULL DEFAULT 0,id_category INTEGER NOT NULL DEFAULT 0);\nCREATE TABLE budgetrule (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,rc_category_id INTEGER NOT NULL DEFAULT 0,t_category_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_category_condition IN ('Y', 'N')),t_year_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_year_condition IN ('Y', 'N')),i_year INTEGER NOT NULL DEFAULT 2010,i_month INTEGER NOT NULL DEFAULT 0 CHECK (i_month>=0 AND i_month<=12),t_month_condition TEXT NOT NULL DEFAULT 'Y' CHECK (t_month_condition IN ('Y', 'N')),i_condition INTEGER NOT NULL DEFAULT 0 CHECK (i_condition IN (-1,0,1)),f_quantity FLOAT NOT NULL DEFAULT 0.0,t_absolute TEXT NOT NULL DEFAULT 'Y' CHECK (t_absolute IN ('Y', 'N')),rc_category_id_target INTEGER NOT NULL DEFAULT 0,t_category_target TEXT NOT NULL DEFAULT 'Y' CHECK (t_category_target IN ('Y', 'N')),t_rule TEXT NOT NULL DEFAULT 'N' CHECK (t_rule IN ('N', 'C', 'Y')));\nCREATE TABLE \"recurrentoperation\" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,d_date DATE NOT NULL DEFAULT '0000-00-00',rd_operation_id INTEGER NOT NULL,i_period_increment INTEGER NOT NULL DEFAULT 1 CHECK (i_period_increment>=0),t_period_unit TEXT NOT NULL DEFAULT 'M' CHECK (t_period_unit IN ('D', 'W', 'M', 'Y')),t_auto_write VARCHAR(1) DEFAULT 'Y' CHECK (t_auto_write IN ('Y', 'N')),i_auto_write_days INTEGER NOT NULL DEFAULT 5 CHECK (i_auto_write_days>=0),t_warn VARCHAR(1) DEFAULT 'Y' CHECK (t_warn IN ('Y', 'N')),i_warn_days INTEGER NOT NULL DEFAULT 5 CHECK (i_warn_days>=0),t_times VARCHAR(1) DEFAULT 'N' CHECK (t_times IN ('Y', 'N')),i_nb_times INTEGER NOT NULL DEFAULT 1 CHECK (i_nb_times>=0));\nCREATE TABLE \"category\" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '' CHECK (t_name NOT LIKE '% > %'),t_fullname TEXT,rd_category_id INT,t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')));\nCREATE TABLE \"account\"(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL,t_number TEXT NOT NULL DEFAULT '',t_agency_number TEXT NOT NULL DEFAULT '',t_agency_address TEXT NOT NULL DEFAULT '',t_comment TEXT NOT NULL DEFAULT '',t_close VARCHAR(1) DEFAULT 'N' CHECK (t_close IN ('Y', 'N')),t_type VARCHAR(1) NOT NULL DEFAULT 'C' CHECK (t_type IN ('C', 'D', 'A', 'I', 'L', 'W', 'O')),t_bookmarked VARCHAR(1) NOT NULL DEFAULT 'N' CHECK (t_bookmarked IN ('Y', 'N')),rd_bank_id INTEGER NOT NULL);\nCREATE TABLE \"node\" (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,t_name TEXT NOT NULL DEFAULT '' CHECK (t_name NOT LIKE '% > %'),t_fullname TEXT,t_icon TEXT DEFAULT '',f_sortorder FLOAT,t_autostart VARCHAR(1) DEFAULT 'N' CHECK (t_autostart IN ('Y', 'N')),t_data TEXT,rd_node_id INT CONSTRAINT fk_id REFERENCES node(id) ON DELETE CASCADE);\nCREATE TABLE vm_category_display_tmp(\n  id INT,\n  t_name TEXT,\n  t_fullname TEXT,\n  rd_category_id INT,\n  t_bookmarked TEXT,\n  i_NBOPERATIONS,\n  f_REALCURRENTAMOUNT\n);\nCREATE TABLE vm_budget_tmp(\n  id INT,\n  rc_category_id INT,\n  t_including_subcategories TEXT,\n  f_budgeted REAL,\n  f_budgeted_modified REAL,\n  f_transferred REAL,\n  i_year INT,\n  i_month INT,\n  t_CATEGORY,\n  t_PERIOD,\n  f_CURRENTAMOUNT,\n  t_RULES\n);\nCREATE INDEX idx_doctransaction_parent ON doctransaction (i_parent);\nCREATE INDEX idx_doctransactionitem_i_object_id ON doctransactionitem (i_object_id);\nCREATE INDEX idx_doctransactionitem_t_object_table ON doctransactionitem (t_object_table);\nCREATE INDEX idx_doctransactionitem_t_action ON doctransactionitem (t_action);\nCREATE INDEX idx_doctransactionitem_rd_doctransaction_id ON doctransactionitem (rd_doctransaction_id);\nCREATE INDEX idx_doctransactionitem_optimization ON doctransactionitem (rd_doctransaction_id, i_object_id, t_object_table, t_action, id);\nCREATE INDEX idx_unit_unit_id ON unitvalue(rd_unit_id);\nCREATE INDEX idx_account_bank_id ON account(rd_bank_id);\nCREATE INDEX idx_account_type ON account(t_type);\nCREATE INDEX idx_category_category_id ON category(rd_category_id);\nCREATE INDEX idx_category_t_fullname ON category(t_fullname);\nCREATE INDEX idx_operation_account_id ON operation (rd_account_id);\nCREATE INDEX idx_operation_tmp1_found_transfert ON operation (rc_unit_id, d_date);\nCREATE INDEX idx_operation_grouped_operation_id ON operation (i_group_id);\nCREATE INDEX idx_operation_i_number ON operation (i_number);\nCREATE INDEX idx_operation_i_tmp ON operation (i_tmp);\nCREATE INDEX idx_operation_rd_account_id ON operation (rd_account_id);\nCREATE INDEX idx_operation_rc_unit_id ON operation (rc_unit_id);\nCREATE INDEX idx_operation_t_status ON operation (t_status);\nCREATE INDEX idx_operation_t_import_id ON operation (t_import_id);\nCREATE INDEX idx_operation_t_template ON operation (t_template);\nCREATE INDEX idx_operation_d_date ON operation (d_date);\nCREATE INDEX idx_operationbalance_operation_id ON operationbalance (r_operation_id);\nCREATE INDEX idx_suboperation_operation_id ON suboperation (rd_operation_id);\nCREATE INDEX idx_suboperation_i_tmp ON suboperation (i_tmp);\nCREATE INDEX idx_suboperation_category_id ON suboperation (r_category_id);\nCREATE INDEX idx_suboperation_refund_id_id ON suboperation (r_refund_id);\nCREATE INDEX idx_recurrentoperation_rd_operation_id ON recurrentoperation (rd_operation_id);\nCREATE INDEX idx_refund_close ON refund(t_close);\nCREATE INDEX idx_interest_account_id ON interest (rd_account_id);\nCREATE INDEX idx_rule_action_type ON rule(t_action_type);\nCREATE INDEX idx_budget_category_id ON budget(rc_category_id);\nCREATE INDEX idx_budgetcategory_id ON budgetcategory (id);\nCREATE INDEX idx_budgetcategory_id_category ON budgetcategory (id_category);\nCREATE UNIQUE INDEX uidx_parameters_uuid_parent_name ON parameters (t_uuid_parent, t_name);\nCREATE UNIQUE INDEX uidx_node_parent_id_name ON node(t_name,rd_node_id);\nCREATE UNIQUE INDEX uidx_node_fullname ON node(t_fullname);\nCREATE UNIQUE INDEX uidx_unit_name ON unit(t_name);\nCREATE UNIQUE INDEX uidx_unit_symbol ON unit(t_symbol);\nCREATE UNIQUE INDEX uidx_unitvalue ON unitvalue(d_date,rd_unit_id);\nCREATE UNIQUE INDEX uidx_bank_name ON bank(t_name);\nCREATE UNIQUE INDEX uidx_account_name ON account(t_name);\nCREATE UNIQUE INDEX uidx_category_parent_id_name ON category(t_name,rd_category_id);\nCREATE UNIQUE INDEX uidx_category_fullname ON  category(t_fullname);\nCREATE UNIQUE INDEX uidx_refund_name ON refund(t_name);\nCREATE UNIQUE INDEX uidx_payee_name ON payee(t_name);\nCREATE UNIQUE INDEX uidx_interest ON interest(d_date,rd_account_id);\nCREATE UNIQUE INDEX uidx_budget ON budget(i_year,i_month, rc_category_id);\nCREATE VIEW v_node AS SELECT * from node;\nCREATE VIEW v_node_displayname AS SELECT *, t_fullname AS t_displayname from node;\nCREATE VIEW v_parameters_displayname AS SELECT *, t_name AS t_displayname from parameters;\nCREATE TRIGGER fkdc_parameters_parameters_uuid BEFORE DELETE ON parameters FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'parameters'; END;\nCREATE TRIGGER fkdc_node_parameters_uuid BEFORE DELETE ON node FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'node'; END;\nCREATE TRIGGER cpt_node_fullname1 AFTER INSERT ON node BEGIN UPDATE node SET t_fullname=CASE WHEN new.rd_node_id IS NULL OR new.rd_node_id='' OR new.rd_node_id=0 THEN new.t_name ELSE (SELECT c.t_fullname from node c where c.id=new.rd_node_id)||' > '||new.t_name END WHERE id=new.id;END;\nCREATE TRIGGER cpt_node_fullname2 AFTER UPDATE OF t_name, rd_node_id ON node BEGIN UPDATE node SET t_fullname=CASE WHEN new.rd_node_id IS NULL OR new.rd_node_id='' OR new.rd_node_id=0 THEN new.t_name ELSE (SELECT c.t_fullname from node c where c.id=new.rd_node_id)||' > '||new.t_name END WHERE id=new.id;UPDATE node SET t_name=t_name WHERE rd_node_id=new.id;END;\nCREATE TRIGGER fki_account_bank_rd_bank_id_id BEFORE INSERT ON account FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (bank est utilisé par account)\nNom de la contrainte : fki_account_bank_rd_bank_id_id')   WHERE NEW.rd_bank_id!=0 AND NEW.rd_bank_id!='' AND (SELECT id FROM bank WHERE id = NEW.rd_bank_id) IS NULL; END;\nCREATE TRIGGER fku_account_bank_rd_bank_id_id BEFORE UPDATE ON account FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (bank est utilisé par account)\nNom de la contrainte : fku_account_bank_rd_bank_id_id')       WHERE NEW.rd_bank_id!=0 AND NEW.rd_bank_id!='' AND (SELECT id FROM bank WHERE id = NEW.rd_bank_id) IS NULL; END;\nCREATE TRIGGER fkdc_bank_account_id_rd_bank_id BEFORE DELETE ON bank FOR EACH ROW BEGIN     DELETE FROM account WHERE account.rd_bank_id = OLD.id; END;\nCREATE TRIGGER fki_budget_category_rc_category_id_id BEFORE INSERT ON budget FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budget)\nNom de la contrainte : fki_budget_category_rc_category_id_id')   WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;\nCREATE TRIGGER fku_budget_category_rc_category_id_id BEFORE UPDATE ON budget FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budget)\nNom de la contrainte : fku_budget_category_rc_category_id_id')       WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;\nCREATE TRIGGER fkd_budget_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budget)\nNom de la contrainte : fkd_budget_category_rc_category_id_id')     WHERE (SELECT rc_category_id FROM budget WHERE rc_category_id = OLD.id) IS NOT NULL; END;\nCREATE TRIGGER fki_budgetrule_category_rc_category_id_id BEFORE INSERT ON budgetrule FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budgetrule)\nNom de la contrainte : fki_budgetrule_category_rc_category_id_id')   WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;\nCREATE TRIGGER fku_budgetrule_category_rc_category_id_id BEFORE UPDATE ON budgetrule FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budgetrule)\nNom de la contrainte : fku_budgetrule_category_rc_category_id_id')       WHERE NEW.rc_category_id!=0 AND NEW.rc_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id) IS NULL; END;\nCREATE TRIGGER fkd_budgetrule_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budgetrule)\nNom de la contrainte : fkd_budgetrule_category_rc_category_id_id')     WHERE (SELECT rc_category_id FROM budgetrule WHERE rc_category_id = OLD.id) IS NOT NULL; END;\nCREATE TRIGGER fki_budgetrule_category_rc_category_id_target_id BEFORE INSERT ON budgetrule FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par budgetrule)\nNom de la contrainte : fki_budgetrule_category_rc_category_id_target_id')   WHERE NEW.rc_category_id_target!=0 AND NEW.rc_category_id_target!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id_target) IS NULL; END;\nCREATE TRIGGER fku_budgetrule_category_rc_category_id_target_id BEFORE UPDATE ON budgetrule FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par budgetrule)\nNom de la contrainte : fku_budgetrule_category_rc_category_id_target_id')       WHERE NEW.rc_category_id_target!=0 AND NEW.rc_category_id_target!='' AND (SELECT id FROM category WHERE id = NEW.rc_category_id_target) IS NULL; END;\nCREATE TRIGGER fkd_budgetrule_category_rc_category_id_target_id BEFORE DELETE ON category FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par budgetrule)\nNom de la contrainte : fkd_budgetrule_category_rc_category_id_target_id')     WHERE (SELECT rc_category_id_target FROM budgetrule WHERE rc_category_id_target = OLD.id) IS NOT NULL; END;\nCREATE TRIGGER fki_category_category_rd_category_id_id BEFORE INSERT ON category FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par category)\nNom de la contrainte : fki_category_category_rd_category_id_id')   WHERE NEW.rd_category_id!=0 AND NEW.rd_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rd_category_id) IS NULL; END;\nCREATE TRIGGER fku_category_category_rd_category_id_id BEFORE UPDATE ON category FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par category)\nNom de la contrainte : fku_category_category_rd_category_id_id')       WHERE NEW.rd_category_id!=0 AND NEW.rd_category_id!='' AND (SELECT id FROM category WHERE id = NEW.rd_category_id) IS NULL; END;\nCREATE TRIGGER fkdc_category_category_id_rd_category_id BEFORE DELETE ON category FOR EACH ROW BEGIN     DELETE FROM category WHERE category.rd_category_id = OLD.id; END;\nCREATE TRIGGER fki_doctransactionitem_doctransaction_rd_doctransaction_id_id BEFORE INSERT ON doctransactionitem FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (doctransaction est utilisé par doctransactionitem)\nNom de la contrainte : fki_doctransactionitem_doctransaction_rd_doctransaction_id_id')   WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;\nCREATE TRIGGER fku_doctransactionitem_doctransaction_rd_doctransaction_id_id BEFORE UPDATE ON doctransactionitem FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (doctransaction est utilisé par doctransactionitem)\nNom de la contrainte : fku_doctransactionitem_doctransaction_rd_doctransaction_id_id')       WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;\nCREATE TRIGGER fkdc_doctransaction_doctransactionitem_id_rd_doctransaction_id BEFORE DELETE ON doctransaction FOR EACH ROW BEGIN     DELETE FROM doctransactionitem WHERE doctransactionitem.rd_doctransaction_id = OLD.id; END;\nCREATE TRIGGER fki_doctransactionmsg_doctransaction_rd_doctransaction_id_id BEFORE INSERT ON doctransactionmsg FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (doctransaction est utilisé par doctransactionmsg)\nNom de la contrainte : fki_doctransactionmsg_doctransaction_rd_doctransaction_id_id')   WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;\nCREATE TRIGGER fku_doctransactionmsg_doctransaction_rd_doctransaction_id_id BEFORE UPDATE ON doctransactionmsg FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (doctransaction est utilisé par doctransactionmsg)\nNom de la contrainte : fku_doctransactionmsg_doctransaction_rd_doctransaction_id_id')       WHERE NEW.rd_doctransaction_id!=0 AND NEW.rd_doctransaction_id!='' AND (SELECT id FROM doctransaction WHERE id = NEW.rd_doctransaction_id) IS NULL; END;\nCREATE TRIGGER fkdc_doctransaction_doctransactionmsg_id_rd_doctransaction_id BEFORE DELETE ON doctransaction FOR EACH ROW BEGIN     DELETE FROM doctransactionmsg WHERE doctransactionmsg.rd_doctransaction_id = OLD.id; END;\nCREATE TRIGGER fki_interest_account_rd_account_id_id BEFORE INSERT ON interest FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (account est utilisé par interest)\nNom de la contrainte : fki_interest_account_rd_account_id_id')   WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;\nCREATE TRIGGER fku_interest_account_rd_account_id_id BEFORE UPDATE ON interest FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (account est utilisé par interest)\nNom de la contrainte : fku_interest_account_rd_account_id_id')       WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;\nCREATE TRIGGER fkdc_account_interest_id_rd_account_id BEFORE DELETE ON account FOR EACH ROW BEGIN     DELETE FROM interest WHERE interest.rd_account_id = OLD.id; END;\nCREATE TRIGGER fki_node_node_rd_node_id_id BEFORE INSERT ON node FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (node est utilisé par node)\nNom de la contrainte : fki_node_node_rd_node_id_id')   WHERE NEW.rd_node_id!=0 AND NEW.rd_node_id!='' AND (SELECT id FROM node WHERE id = NEW.rd_node_id) IS NULL; END;\nCREATE TRIGGER fku_node_node_rd_node_id_id BEFORE UPDATE ON node FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (node est utilisé par node)\nNom de la contrainte : fku_node_node_rd_node_id_id')       WHERE NEW.rd_node_id!=0 AND NEW.rd_node_id!='' AND (SELECT id FROM node WHERE id = NEW.rd_node_id) IS NULL; END;\nCREATE TRIGGER fkdc_node_node_id_rd_node_id BEFORE DELETE ON node FOR EACH ROW BEGIN     DELETE FROM node WHERE node.rd_node_id = OLD.id; END;\nCREATE TRIGGER fki_operation_account_rd_account_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (account est utilisé par operation)\nNom de la contrainte : fki_operation_account_rd_account_id_id')   WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;\nCREATE TRIGGER fku_operation_account_rd_account_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (account est utilisé par operation)\nNom de la contrainte : fku_operation_account_rd_account_id_id')       WHERE NEW.rd_account_id!=0 AND NEW.rd_account_id!='' AND (SELECT id FROM account WHERE id = NEW.rd_account_id) IS NULL; END;\nCREATE TRIGGER fkdc_account_operation_id_rd_account_id BEFORE DELETE ON account FOR EACH ROW BEGIN     DELETE FROM operation WHERE operation.rd_account_id = OLD.id; END;\nCREATE TRIGGER fki_operation_payee_r_payee_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (payee est utilisé par operation)\nNom de la contrainte : fki_operation_payee_r_payee_id_id')   WHERE NEW.r_payee_id!=0 AND NEW.r_payee_id!='' AND (SELECT id FROM payee WHERE id = NEW.r_payee_id) IS NULL; END;\nCREATE TRIGGER fku_operation_payee_r_payee_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (payee est utilisé par operation)\nNom de la contrainte : fku_operation_payee_r_payee_id_id')       WHERE NEW.r_payee_id!=0 AND NEW.r_payee_id!='' AND (SELECT id FROM payee WHERE id = NEW.r_payee_id) IS NULL; END;\nCREATE TRIGGER fkd_operation_payee_r_payee_id_id BEFORE DELETE ON payee FOR EACH ROW BEGIN     UPDATE operation SET r_payee_id=0 WHERE r_payee_id=OLD.id; END;\nCREATE TRIGGER fki_operation_unit_rc_unit_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par operation)\nNom de la contrainte : fki_operation_unit_rc_unit_id_id')   WHERE NEW.rc_unit_id!=0 AND NEW.rc_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rc_unit_id) IS NULL; END;\nCREATE TRIGGER fku_operation_unit_rc_unit_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par operation)\nNom de la contrainte : fku_operation_unit_rc_unit_id_id')       WHERE NEW.rc_unit_id!=0 AND NEW.rc_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rc_unit_id) IS NULL; END;\nCREATE TRIGGER fkd_operation_unit_rc_unit_id_id BEFORE DELETE ON unit FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de détruire un objet (unit est utilisé par operation)\nNom de la contrainte : fkd_operation_unit_rc_unit_id_id')     WHERE (SELECT rc_unit_id FROM operation WHERE rc_unit_id = OLD.id) IS NOT NULL; END;\nCREATE TRIGGER fki_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE INSERT ON operation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (recurrentoperation est utilisé par operation)\nNom de la contrainte : fki_operation_recurrentoperation_r_recurrentoperation_id_id')   WHERE NEW.r_recurrentoperation_id!=0 AND NEW.r_recurrentoperation_id!='' AND (SELECT id FROM recurrentoperation WHERE id = NEW.r_recurrentoperation_id) IS NULL; END;\nCREATE TRIGGER fku_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE UPDATE ON operation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (recurrentoperation est utilisé par operation)\nNom de la contrainte : fku_operation_recurrentoperation_r_recurrentoperation_id_id')       WHERE NEW.r_recurrentoperation_id!=0 AND NEW.r_recurrentoperation_id!='' AND (SELECT id FROM recurrentoperation WHERE id = NEW.r_recurrentoperation_id) IS NULL; END;\nCREATE TRIGGER fkd_operation_recurrentoperation_r_recurrentoperation_id_id BEFORE DELETE ON recurrentoperation FOR EACH ROW BEGIN     UPDATE operation SET r_recurrentoperation_id=0 WHERE r_recurrentoperation_id=OLD.id; END;\nCREATE TRIGGER fki_operationbalance_operation_r_operation_id_id BEFORE INSERT ON operationbalance FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par operationbalance)\nNom de la contrainte : fki_operationbalance_operation_r_operation_id_id')   WHERE NEW.r_operation_id!=0 AND NEW.r_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.r_operation_id) IS NULL; END;\nCREATE TRIGGER fku_operationbalance_operation_r_operation_id_id BEFORE UPDATE ON operationbalance FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par operationbalance)\nNom de la contrainte : fku_operationbalance_operation_r_operation_id_id')       WHERE NEW.r_operation_id!=0 AND NEW.r_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.r_operation_id) IS NULL; END;\nCREATE TRIGGER fkd_operationbalance_operation_r_operation_id_id BEFORE DELETE ON operation FOR EACH ROW BEGIN     UPDATE operationbalance SET r_operation_id=0 WHERE r_operation_id=OLD.id; END;\nCREATE TRIGGER fki_recurrentoperation_operation_rd_operation_id_id BEFORE INSERT ON recurrentoperation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par recurrentoperation)\nNom de la contrainte : fki_recurrentoperation_operation_rd_operation_id_id')   WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;\nCREATE TRIGGER fku_recurrentoperation_operation_rd_operation_id_id BEFORE UPDATE ON recurrentoperation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par recurrentoperation)\nNom de la contrainte : fku_recurrentoperation_operation_rd_operation_id_id')       WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;\nCREATE TRIGGER fkdc_operation_recurrentoperation_id_rd_operation_id BEFORE DELETE ON operation FOR EACH ROW BEGIN     DELETE FROM recurrentoperation WHERE recurrentoperation.rd_operation_id = OLD.id; END;\nCREATE TRIGGER fki_suboperation_operation_rd_operation_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (operation est utilisé par suboperation)\nNom de la contrainte : fki_suboperation_operation_rd_operation_id_id')   WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;\nCREATE TRIGGER fku_suboperation_operation_rd_operation_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (operation est utilisé par suboperation)\nNom de la contrainte : fku_suboperation_operation_rd_operation_id_id')       WHERE NEW.rd_operation_id!=0 AND NEW.rd_operation_id!='' AND (SELECT id FROM operation WHERE id = NEW.rd_operation_id) IS NULL; END;\nCREATE TRIGGER fkdc_operation_suboperation_id_rd_operation_id BEFORE DELETE ON operation FOR EACH ROW BEGIN     DELETE FROM suboperation WHERE suboperation.rd_operation_id = OLD.id; END;\nCREATE TRIGGER fki_suboperation_category_r_category_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (category est utilisé par suboperation)\nNom de la contrainte : fki_suboperation_category_r_category_id_id')   WHERE NEW.r_category_id!=0 AND NEW.r_category_id!='' AND (SELECT id FROM category WHERE id = NEW.r_category_id) IS NULL; END;\nCREATE TRIGGER fku_suboperation_category_r_category_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (category est utilisé par suboperation)\nNom de la contrainte : fku_suboperation_category_r_category_id_id')       WHERE NEW.r_category_id!=0 AND NEW.r_category_id!='' AND (SELECT id FROM category WHERE id = NEW.r_category_id) IS NULL; END;\nCREATE TRIGGER fkd_suboperation_category_r_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN     UPDATE suboperation SET r_category_id=0 WHERE r_category_id=OLD.id; END;\nCREATE TRIGGER fki_suboperation_refund_r_refund_id_id BEFORE INSERT ON suboperation FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (refund est utilisé par suboperation)\nNom de la contrainte : fki_suboperation_refund_r_refund_id_id')   WHERE NEW.r_refund_id!=0 AND NEW.r_refund_id!='' AND (SELECT id FROM refund WHERE id = NEW.r_refund_id) IS NULL; END;\nCREATE TRIGGER fku_suboperation_refund_r_refund_id_id BEFORE UPDATE ON suboperation FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (refund est utilisé par suboperation)\nNom de la contrainte : fku_suboperation_refund_r_refund_id_id')       WHERE NEW.r_refund_id!=0 AND NEW.r_refund_id!='' AND (SELECT id FROM refund WHERE id = NEW.r_refund_id) IS NULL; END;\nCREATE TRIGGER fkd_suboperation_refund_r_refund_id_id BEFORE DELETE ON refund FOR EACH ROW BEGIN     UPDATE suboperation SET r_refund_id=0 WHERE r_refund_id=OLD.id; END;\nCREATE TRIGGER fki_unit_unit_rd_unit_id_id BEFORE INSERT ON unit FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par unit)\nNom de la contrainte : fki_unit_unit_rd_unit_id_id')   WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;\nCREATE TRIGGER fku_unit_unit_rd_unit_id_id BEFORE UPDATE ON unit FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par unit)\nNom de la contrainte : fku_unit_unit_rd_unit_id_id')       WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;\nCREATE TRIGGER fkdc_unit_unit_id_rd_unit_id BEFORE DELETE ON unit FOR EACH ROW BEGIN     DELETE FROM unit WHERE unit.rd_unit_id = OLD.id; END;\nCREATE TRIGGER fki_unitvalue_unit_rd_unit_id_id BEFORE INSERT ON unitvalue FOR EACH ROW BEGIN   SELECT RAISE(ABORT, 'Impossible d''ajouter un objet (unit est utilisé par unitvalue)\nNom de la contrainte : fki_unitvalue_unit_rd_unit_id_id')   WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;\nCREATE TRIGGER fku_unitvalue_unit_rd_unit_id_id BEFORE UPDATE ON unitvalue FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de modifier un objet (unit est utilisé par unitvalue)\nNom de la contrainte : fku_unitvalue_unit_rd_unit_id_id')       WHERE NEW.rd_unit_id!=0 AND NEW.rd_unit_id!='' AND (SELECT id FROM unit WHERE id = NEW.rd_unit_id) IS NULL; END;\nCREATE TRIGGER fkdc_unit_unitvalue_id_rd_unit_id BEFORE DELETE ON unit FOR EACH ROW BEGIN     DELETE FROM unitvalue WHERE unitvalue.rd_unit_id = OLD.id; END;\nCREATE TRIGGER fkd_vm_budget_tmp_category_rc_category_id_id BEFORE DELETE ON category FOR EACH ROW BEGIN     SELECT RAISE(ABORT, 'Impossible de détruire un objet (category est utilisé par vm_budget_tmp)\nNom de la contrainte : fkd_vm_budget_tmp_category_rc_category_id_id')     WHERE (SELECT rc_category_id FROM vm_budget_tmp WHERE rc_category_id = OLD.id) IS NOT NULL; END;\nCREATE TRIGGER fkdc_category_vm_category_display_tmp_id_rd_category_id BEFORE DELETE ON category FOR EACH ROW BEGIN     DELETE FROM vm_category_display_tmp WHERE vm_category_display_tmp.rd_category_id = OLD.id; END;\nCREATE VIEW v_unit_displayname AS SELECT *, t_name||' ('||t_symbol||')' AS t_displayname FROM unit;\nCREATE VIEW v_unit_tmp1 AS SELECT *,(SELECT count(*) FROM unitvalue s WHERE s.rd_unit_id=unit.id) AS i_NBVALUES, (CASE WHEN unit.rd_unit_id=0 THEN '' ELSE (SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=unit.rd_unit_id) END) AS t_UNIT,(CASE unit.t_type WHEN '1' THEN 'Monnaie principale' WHEN '2' THEN 'Monnaie secondaire' WHEN 'C' THEN 'Monnaie' WHEN 'S' THEN 'Action' WHEN 'I' THEN 'Indice' ELSE 'Objet' END) AS t_TYPENLS, (SELECT MIN(s.d_date) FROM  unitvalue s WHERE s.rd_unit_id=unit.id) AS d_MINDATE, (SELECT MAX(s.d_date) FROM  unitvalue s WHERE s.rd_unit_id=unit.id) AS d_MAXDATE from unit;\nCREATE VIEW v_unit_tmp2 AS SELECT *,CASE WHEN v_unit_tmp1.t_type='1' THEN 1 ELSE IFNULL((SELECT s.f_quantity FROM unitvalue s WHERE s.rd_unit_id=v_unit_tmp1.id AND s.d_date=v_unit_tmp1.d_MAXDATE),1) END AS f_LASTVALUE from v_unit_tmp1;\nCREATE VIEW v_unit AS SELECT *,v_unit_tmp2.f_LASTVALUE*IFNULL((SELECT s2.f_LASTVALUE FROM v_unit_tmp2 s2 WHERE s2.id=v_unit_tmp2.rd_unit_id) , 1) AS f_CURRENTAMOUNT from v_unit_tmp2;\nCREATE VIEW v_unitvalue_displayname AS SELECT *, (SELECT t_displayname FROM v_unit_displayname WHERE unitvalue.rd_unit_id=v_unit_displayname.id)||' '||STRFTIME('%d/%m/%Y',d_date) AS t_displayname FROM unitvalue;\nCREATE VIEW v_unitvalue AS SELECT * FROM unitvalue;\nCREATE VIEW v_suboperation AS SELECT * FROM suboperation;\nCREATE VIEW v_operation_numbers AS SELECT DISTINCT i_number, rd_account_id FROM operation;\nCREATE VIEW v_operation_next_numbers AS SELECT T1.i_number+1 AS i_number FROM v_operation_numbers AS T1 LEFT OUTER JOIN v_operation_numbers T2 ON T2.rd_account_id=T1.rd_account_id AND T2.i_number=T1.i_number+1 WHERE T1.i_number!=0 AND (T2.i_number IS NULL) ORDER BY T1.i_number;\nCREATE VIEW v_operation_tmp1 AS SELECT *,(SELECT t_name FROM payee s WHERE s.id=operation.r_payee_id) AS t_PAYEE,(SELECT TOTAL(s.f_value) FROM suboperation s WHERE s.rd_operation_id=operation.ID) AS f_QUANTITY,(SELECT count(*) FROM suboperation s WHERE s.rd_operation_id=operation.ID) AS i_NBSUBCATEGORY FROM operation;\nCREATE VIEW v_operation AS SELECT *,(SELECT s.id FROM suboperation s WHERE s.rd_operation_id=v_operation_tmp1.id AND ABS(s.f_value)=(SELECT MAX(ABS(s2.f_value)) FROM suboperation s2 WHERE s2.rd_operation_id=v_operation_tmp1.id)) AS i_MOSTIMPSUBOP,((SELECT s.f_CURRENTAMOUNT FROM v_unit s WHERE s.id=v_operation_tmp1.rc_unit_id)*v_operation_tmp1.f_QUANTITY) AS f_CURRENTAMOUNT, (CASE WHEN v_operation_tmp1.i_group_id<>0 AND EXISTS (SELECT 1 FROM account a WHERE v_operation_tmp1.rd_account_id=a.id AND a.t_type<>'L') AND EXISTS (SELECT 1 FROM v_operation_tmp1 op2, account a WHERE op2.i_group_id=v_operation_tmp1.i_group_id AND op2.rd_account_id=a.id AND a.t_type<>'L' AND op2.rc_unit_id=v_operation_tmp1.rc_unit_id AND op2.f_QUANTITY=-v_operation_tmp1.f_QUANTITY) THEN 'Y' ELSE 'N' END) AS t_TRANSFER FROM v_operation_tmp1;\nCREATE VIEW v_operation_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||IFNULL(t_PAYEE,'')||' '||v_operation.f_CURRENTAMOUNT||' '||(SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=v_operation.rc_unit_id) AS t_displayname FROM v_operation;\nCREATE VIEW v_operation_delete AS SELECT *, (CASE WHEN t_status='Y' THEN 'Vous n''êtes pas autorisé à détruire cette opération car en état « rapproché »' END) t_delete_message FROM operation;\nCREATE VIEW v_account AS SELECT *,(SELECT MAX(s.d_date) FROM  interest s WHERE s.rd_account_id=account.id) AS d_MAXDATE, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=account.id AND s.t_template='N') AS f_CURRENTAMOUNT FROM account;\nCREATE VIEW v_account_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM operation WHERE rd_account_id=account.id AND d_date<>'0000-00-00' AND t_template='N' AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce compte car il contient des opérations rapprochées' END) t_delete_message FROM account;\nCREATE VIEW v_bank_displayname AS SELECT *, t_name AS t_displayname FROM bank;\nCREATE VIEW v_account_displayname AS SELECT *, (SELECT t_displayname FROM v_bank_displayname WHERE account.rd_bank_id=v_bank_displayname.id)||'-'||t_name AS t_displayname FROM account;\nCREATE VIEW v_bank AS SELECT *,(SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_account s WHERE s.rd_bank_id=bank.id) AS f_CURRENTAMOUNT FROM bank;\nCREATE VIEW v_category_displayname AS SELECT *, t_fullname AS t_displayname FROM category;\nCREATE VIEW v_category AS SELECT * FROM category;\nCREATE VIEW v_recurrentoperation AS SELECT *,i_period_increment||' '||(CASE t_period_unit WHEN 'Y' THEN 'année(s)' WHEN 'M' THEN 'mois' WHEN 'W' THEN 'semaine(s)' ELSE 'jour(s)' END) AS t_PERIODNLS FROM recurrentoperation;\nCREATE VIEW v_recurrentoperation_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||SUBSTR((SELECT t_displayname FROM v_operation_displayname WHERE v_operation_displayname.id=v_recurrentoperation.rd_operation_id), 11) AS t_displayname FROM v_recurrentoperation;\nCREATE VIEW v_unitvalue_display AS SELECT *,IFNULL((SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=(SELECT s2.rd_unit_id FROM unit s2 WHERE s2.id=unitvalue.rd_unit_id)),'') AS t_UNIT,STRFTIME('%Y-%m',unitvalue.d_date) AS d_DATEMONTH,STRFTIME('%Y',unitvalue.d_date) AS d_DATEYEAR FROM unitvalue;\nCREATE VIEW v_suboperation_display AS SELECT *,IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=v_suboperation.r_category_id),'') AS t_CATEGORY, IFNULL((SELECT s.t_name FROM refund s WHERE s.id=v_suboperation.r_refund_id),'') AS t_REFUND, (CASE WHEN v_suboperation.f_value>=0 THEN v_suboperation.f_value ELSE 0 END) AS f_VALUE_INCOME, (CASE WHEN v_suboperation.f_value<=0 THEN v_suboperation.f_value ELSE 0 END) AS f_VALUE_EXPENSE FROM v_suboperation;\nCREATE VIEW v_suboperation_displayname AS SELECT *, t_CATEGORY||' : '||f_value AS t_displayname FROM v_suboperation_display;\nCREATE VIEW v_operation_display_all AS SELECT *,(SELECT s.t_name FROM account s WHERE s.id=v_operation.rd_account_id) AS t_ACCOUNT,(SELECT (CASE WHEN s.t_symbol!='' THEN s.t_symbol ELSE s.t_name END) FROM unit s WHERE s.id=v_operation.rc_unit_id) AS t_UNIT,(SELECT s.t_CATEGORY FROM v_suboperation_display s WHERE s.id=v_operation.i_MOSTIMPSUBOP) AS t_CATEGORY,(SELECT s.t_REFUND FROM v_suboperation_display s WHERE s.id=v_operation.i_MOSTIMPSUBOP) AS t_REFUND,(CASE WHEN v_operation.f_QUANTITY<0 THEN '-' WHEN v_operation.f_QUANTITY=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE, (CASE WHEN v_operation.f_QUANTITY<=0 THEN 'Dépense' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS, STRFTIME('%Y-W%W',v_operation.d_date) AS d_DATEWEEK,STRFTIME('%Y-%m',v_operation.d_date) AS d_DATEMONTH,STRFTIME('%Y',v_operation.d_date)||'-Q'||(CASE WHEN STRFTIME('%m',v_operation.d_date)<='03' THEN '1' WHEN STRFTIME('%m',v_operation.d_date)<='06' THEN '2' WHEN STRFTIME('%m',v_operation.d_date)<='09' THEN '3' ELSE '4' END) AS d_DATEQUARTER, STRFTIME('%Y',v_operation.d_date)||'-S'||(CASE WHEN STRFTIME('%m',v_operation.d_date)<='06' THEN '1' ELSE '2' END) AS d_DATESEMESTER, STRFTIME('%Y',v_operation.d_date) AS d_DATEYEAR, (SELECT count(*) FROM v_recurrentoperation s WHERE s.rd_operation_id=v_operation.id) AS i_NBRECURRENT,  (CASE WHEN v_operation.f_QUANTITY>=0 THEN v_operation.f_QUANTITY ELSE 0 END) AS f_QUANTITY_INCOME, (CASE WHEN v_operation.f_QUANTITY<=0 THEN v_operation.f_QUANTITY ELSE 0 END) AS f_QUANTITY_EXPENSE, (SELECT o2.f_balance FROM operationbalance o2 WHERE o2.r_operation_id=v_operation.id ) AS f_BALANCE, (CASE WHEN v_operation.f_QUANTITY>=0 THEN v_operation.f_CURRENTAMOUNT ELSE 0 END) AS f_CURRENTAMOUNT_INCOME, (CASE WHEN v_operation.f_QUANTITY<=0 THEN v_operation.f_CURRENTAMOUNT ELSE 0 END) AS f_CURRENTAMOUNT_EXPENSE FROM v_operation;\nCREATE VIEW v_operation_template_display AS SELECT * FROM v_operation_display_all WHERE t_template='Y';\nCREATE VIEW v_operation_display AS SELECT * FROM v_operation_display_all WHERE d_date!='0000-00-00' AND t_template='N';\nCREATE VIEW v_unit_display AS SELECT *,(SELECT TOTAL(o.f_QUANTITY) FROM v_operation_display o WHERE o.rc_unit_id=v_unit.id) AS f_QUANTITYOWNED FROM v_unit;\nCREATE VIEW v_account_display AS SELECT (CASE t_type WHEN 'C' THEN 'Courant' WHEN 'D' THEN 'Carte de crédit' WHEN 'A' THEN 'Actif' WHEN 'I' THEN 'Investissement' WHEN 'W' THEN 'Portefeuille' WHEN 'L' THEN 'Prêt' WHEN 'O' THEN 'Autre' END) AS t_TYPENLS,bank.t_name  AS t_BANK,bank.t_bank_number AS t_BANK_NUMBER,bank.t_icon AS t_ICON,v_account.*,(v_account.f_CURRENTAMOUNT/(SELECT u.f_CURRENTAMOUNT FROM v_unit u, operation s WHERE u.id=s.rc_unit_id AND s.rd_account_id=v_account.id AND s.d_date='0000-00-00')) AS f_QUANTITY, (SELECT (CASE WHEN u.t_symbol!='' THEN u.t_symbol ELSE u.t_name END) FROM unit u, operation s WHERE u.id=s.rc_unit_id AND s.rd_account_id=v_account.id AND s.d_date='0000-00-00') AS t_UNIT, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.t_status!='N' AND s.t_template='N') AS f_CHECKED, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.t_status='N' AND s.t_template='N') AS f_COMING_SOON, (SELECT TOTAL(s.f_CURRENTAMOUNT) FROM v_operation s WHERE s.rd_account_id=v_account.id AND s.d_date<=date('now') AND s.t_template='N') AS f_TODAYAMOUNT, (SELECT count(*) FROM v_operation_display s WHERE s.rd_account_id=v_account.id) AS i_NBOPERATIONS, IFNULL((SELECT s.f_rate FROM interest s WHERE s.rd_account_id=v_account.id AND s.d_date=v_account.d_MAXDATE),0) AS f_RATE FROM v_account, bank WHERE bank.id=v_account.rd_bank_id;\nCREATE VIEW v_operation_consolidated AS SELECT (SELECT s.t_TYPENLS FROM v_account_display s WHERE s.id=op.rd_account_id) AS t_ACCOUNTTYPE,(SELECT u.t_TYPENLS FROM v_unit u WHERE u.id=op.rc_unit_id) AS t_UNITTYPE,sop.id AS i_SUBOPID, sop.r_refund_id AS r_refund_id, (CASE WHEN sop.t_comment='' THEN op.t_comment ELSE sop.t_comment END) AS t_REALCOMMENT, sop.t_CATEGORY AS t_REALCATEGORY, sop.t_REFUND AS t_REALREFUND, sop.r_category_id AS i_IDCATEGORY, (CASE WHEN sop.f_value<0 THEN '-' WHEN sop.f_value=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE, (CASE WHEN sop.f_value<0 THEN 'Dépense' WHEN sop.f_value=0 THEN '' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS, sop.f_value AS f_REALQUANTITY, sop.f_VALUE_INCOME AS f_REALQUANTITY_INCOME, sop.f_VALUE_EXPENSE AS f_REALQUANTITY_EXPENSE, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_value) AS f_REALCURRENTAMOUNT, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_VALUE_INCOME) AS f_REALCURRENTAMOUNT_INCOME, ((SELECT u.f_CURRENTAMOUNT FROM v_unit u WHERE u.id=op.rc_unit_id)*sop.f_VALUE_EXPENSE) AS f_REALCURRENTAMOUNT_EXPENSE, op.* FROM v_operation_display_all AS op, v_suboperation_display AS sop WHERE op.t_template='N' AND sop.rd_operation_id=op.ID;\nCREATE VIEW v_operation_prop AS SELECT p.id AS i_PROPPID, p.t_name AS i_PROPPNAME, p.t_value AS i_PROPVALUE, op.* FROM v_operation_consolidated AS op LEFT OUTER JOIN parameters AS p ON p.t_uuid_parent=op.id||'-operation';\nCREATE VIEW v_refund_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM v_operation_consolidated WHERE r_refund_id=refund.id AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce suiveur car utilisé par des opérations rapprochées' END) t_delete_message FROM refund;\nCREATE VIEW v_refund AS SELECT *, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE o.r_refund_id=refund.id) AS f_CURRENTAMOUNT FROM refund;\nCREATE VIEW v_refund_display AS SELECT *,(SELECT MIN(o.d_date) FROM v_operation_consolidated o WHERE o.r_refund_id=v_refund.id) AS d_FIRSTDATE, (SELECT MAX(o.d_date) FROM v_operation_consolidated o WHERE o.r_refund_id=v_refund.id) AS d_LASTDATE  FROM v_refund;\nCREATE VIEW v_refund_displayname AS SELECT *, t_name AS t_displayname FROM refund;\nCREATE VIEW v_payee_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM operation WHERE r_payee_id=payee.id AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire ce tiers car utilisé par des opérations rapprochées' END) t_delete_message FROM payee;\nCREATE VIEW v_payee AS SELECT *, (SELECT TOTAL(o.f_CURRENTAMOUNT) FROM v_operation o WHERE o.r_payee_id=payee.id AND o.t_template='N') AS f_CURRENTAMOUNT FROM payee;\nCREATE VIEW v_payee_display AS SELECT *  FROM v_payee;\nCREATE VIEW v_payee_displayname AS SELECT *, t_name AS t_displayname FROM payee;\nCREATE VIEW v_category_delete AS SELECT *, (CASE WHEN EXISTS(SELECT 1 FROM v_operation_consolidated WHERE (t_REALCATEGORY=category.t_fullname OR t_REALCATEGORY like category.t_fullname||'%') AND t_status='Y') THEN 'Vous n''êtes pas autorisé à détruire cette catégorie car utilisée par des opérations rapprochées' END) t_delete_message FROM category;\nCREATE VIEW v_category_display_tmp AS SELECT *,(SELECT count(distinct(so.rd_operation_id)) FROM operation o, suboperation so WHERE so.rd_operation_id=o.id AND so.r_category_id=v_category.ID AND o.t_template='N') AS i_NBOPERATIONS, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE o.i_IDCATEGORY=v_category.ID) AS f_REALCURRENTAMOUNT FROM v_category;\nCREATE VIEW v_category_display AS SELECT *,f_REALCURRENTAMOUNT+(SELECT TOTAL(c.f_REALCURRENTAMOUNT) FROM vm_category_display_tmp c WHERE c.t_fullname LIKE vm_category_display_tmp.t_fullname||' > %') AS f_SUMCURRENTAMOUNT, i_NBOPERATIONS+(SELECT CAST(TOTAL(c.i_NBOPERATIONS) AS INTEGER) FROM vm_category_display_tmp c WHERE c.t_fullname like vm_category_display_tmp.t_fullname||' > %') AS i_SUMNBOPERATIONS, (CASE WHEN t_bookmarked='Y' THEN 'Y' WHEN EXISTS(SELECT 1 FROM category c WHERE c.t_bookmarked='Y' AND c.t_fullname like vm_category_display_tmp.t_fullname||' > %') THEN 'C' ELSE 'N' END) AS t_HASBOOKMARKEDCHILD, (CASE WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT<0 THEN '-' WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT=0 THEN '' ELSE '+' END) AS t_TYPEEXPENSE,(CASE WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT<0 THEN 'Dépense' WHEN vm_category_display_tmp.f_REALCURRENTAMOUNT=0 THEN '' ELSE 'Revenu' END) AS t_TYPEEXPENSENLS FROM vm_category_display_tmp;\nCREATE VIEW v_recurrentoperation_display AS SELECT rop.*, op.t_ACCOUNT, op.i_number, op.t_mode, op.i_group_id, op.t_TRANSFER, op.t_PAYEE, op.t_comment, op.t_CATEGORY, op.t_status, op.f_CURRENTAMOUNT FROM v_recurrentoperation rop, v_operation_display_all AS op WHERE rop.rd_operation_id=op.ID;\nCREATE VIEW v_rule AS SELECT *,(SELECT COUNT(1) FROM rule r WHERE r.f_sortorder<=rule.f_sortorder) AS i_ORDER FROM rule;\nCREATE VIEW v_rule_displayname AS SELECT *, t_definition AS t_displayname FROM rule;\nCREATE VIEW v_interest AS SELECT *,(SELECT s.t_name FROM account s WHERE s.id=interest.rd_account_id) AS t_ACCOUNT  FROM interest;\nCREATE VIEW v_interest_displayname AS SELECT *, STRFTIME('%d/%m/%Y',d_date)||' '||f_rate||'%' AS t_displayname FROM interest;\nCREATE VIEW v_budgetrule AS SELECT *, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budgetrule.rc_category_id),'') AS t_CATEGORYCONDITION, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budgetrule.rc_category_id_target),'') AS t_CATEGORY, (CASE WHEN budgetrule.i_condition=-1 THEN 'Négatif' WHEN budgetrule.i_condition=1 THEN 'Positif' WHEN budgetrule.i_condition=0 THEN 'Tous' END) AS t_WHENNLS, f_quantity||(CASE WHEN budgetrule.t_absolute='N' THEN '%' ELSE (SELECT t_symbol FROM unit WHERE t_type='1') END) AS t_WHATNLS,(CASE WHEN budgetrule.t_rule='N' THEN 'Suivant' WHEN budgetrule.t_rule='C' THEN 'Courant' WHEN budgetrule.t_rule='Y' THEN 'Année' END) AS t_RULENLS FROM budgetrule;\nCREATE VIEW v_budgetrule_display AS SELECT *  FROM v_budgetrule;\nCREATE VIEW v_budgetrule_displayname AS SELECT *, t_WHENNLS||' '||t_WHATNLS||' '||t_RULENLS||' '||t_CATEGORY AS t_displayname FROM v_budgetrule;\nCREATE VIEW v_budget_tmp AS SELECT *, IFNULL((SELECT s.t_fullname FROM category s WHERE s.id=budget.rc_category_id),'') AS t_CATEGORY, (i_year||(CASE WHEN i_month=0 THEN '' WHEN i_month<10 THEN '-0'||i_month ELSE '-'||i_month END)) AS t_PERIOD, (SELECT TOTAL(o.f_REALCURRENTAMOUNT) FROM v_operation_consolidated o WHERE STRFTIME('%Y', o.d_date)=i_year AND (i_month=0 OR STRFTIME('%m', o.d_date)=i_month) AND o.i_IDCATEGORY IN (SELECT b2.id_category FROM budgetcategory b2 WHERE b2.id=budget.id)) AS f_CURRENTAMOUNT, (SELECT GROUP_CONCAT(v_budgetrule_displayname.t_displayname,',') FROM v_budgetrule_displayname WHERE (v_budgetrule_displayname.t_year_condition='N' OR budget.i_year=v_budgetrule_displayname.i_year) AND (v_budgetrule_displayname.t_month_condition='N' OR budget.i_month=v_budgetrule_displayname.i_month) AND (v_budgetrule_displayname.t_category_condition='N' OR budget.rc_category_id=v_budgetrule_displayname.rc_category_id) ORDER BY v_budgetrule_displayname.t_absolute DESC, v_budgetrule_displayname.id) AS t_RULES FROM budget;\nCREATE VIEW v_budget AS SELECT *, (f_CURRENTAMOUNT-f_budgeted_modified) AS f_DELTABEFORETRANSFER, (f_CURRENTAMOUNT-f_budgeted_modified-f_transferred) AS f_DELTA FROM v_budget_tmp;\nCREATE VIEW v_budget_display AS SELECT *, (f_CURRENTAMOUNT-f_budgeted_modified) AS f_DELTABEFORETRANSFER, (f_CURRENTAMOUNT-f_budgeted_modified-f_transferred) AS f_DELTA FROM vm_budget_tmp;\nCREATE VIEW v_budget_displayname AS SELECT *, t_CATEGORY||' '||t_PERIOD||' '||f_budgeted_modified AS t_displayname FROM v_budget;\nCREATE TRIGGER fkdc_bank_parameters_uuid BEFORE DELETE ON bank FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'bank'; END;\nCREATE TRIGGER fkdc_account_parameters_uuid BEFORE DELETE ON account FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'account'; END;\nCREATE TRIGGER fkdc_unit_parameters_uuid BEFORE DELETE ON unit FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'unit'; END;\nCREATE TRIGGER fkdc_unitvalue_parameters_uuid BEFORE DELETE ON unitvalue FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'unitvalue'; END;\nCREATE TRIGGER fkdc_category_parameters_uuid BEFORE DELETE ON category FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'category'; END;\nCREATE TRIGGER fkdc_operation_parameters_uuid BEFORE DELETE ON operation FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'operation'; END;\nCREATE TRIGGER fkdc_interest_parameters_uuid BEFORE DELETE ON interest FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'interest'; END;\nCREATE TRIGGER fkdc_suboperation_parameters_uuid BEFORE DELETE ON suboperation FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'suboperation'; END;\nCREATE TRIGGER fkdc_refund_parameters_uuid BEFORE DELETE ON refund FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'refund'; END;\nCREATE TRIGGER fkdc_payee_parameters_uuid BEFORE DELETE ON payee FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'payee'; END;\nCREATE TRIGGER fkdc_recurrentoperation_parameters_uuid BEFORE DELETE ON recurrentoperation FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'recurrentoperation'; END;\nCREATE TRIGGER fkdc_rule_parameters_uuid BEFORE DELETE ON rule FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'rule'; END;\nCREATE TRIGGER fkdc_budget_parameters_uuid BEFORE DELETE ON budget FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'budget'; END;\nCREATE TRIGGER fkdc_budgetrule_parameters_uuid BEFORE DELETE ON budgetrule FOR EACH ROW BEGIN     DELETE FROM parameters WHERE parameters.t_uuid_parent=OLD.id||'-'||'budgetrule'; END;\nCREATE TRIGGER cpt_category_fullname1 AFTER INSERT ON category BEGIN UPDATE category SET t_fullname=CASE WHEN rd_category_id IS NULL OR rd_category_id='' OR rd_category_id=0 THEN new.t_name ELSE (SELECT c.t_fullname FROM category c WHERE c.id=new.rd_category_id)||' > '||new.t_name END WHERE id=new.id;END;\nCREATE TRIGGER cpt_category_fullname2 AFTER UPDATE OF t_name, rd_category_id ON category BEGIN UPDATE category SET t_fullname=CASE WHEN rd_category_id IS NULL OR rd_category_id='' OR rd_category_id=0 THEN new.t_name ELSE (SELECT c.t_fullname FROM category c WHERE c.id=new.rd_category_id)||' > '||new.t_name END WHERE id=new.id;UPDATE category SET t_name=t_name WHERE rd_category_id=new.id;END;\nCREATE TRIGGER fkdc_category_delete BEFORE DELETE ON category FOR EACH ROW BEGIN     UPDATE suboperation SET r_category_id=OLD.rd_category_id WHERE r_category_id=OLD.id; END;\nexplain\n       SELECT TOTAL(f_CURRENTAMOUNT), d_DATEMONTH\n       from v_operation_display\n       WHERE d_DATEMONTH IN ('2012-05', '2012-04')\n       group by d_DATEMONTH, t_TYPEEXPENSE;\n  }\n} {/.* Goto .*/}\n\n# The next test requires FTS4\nifcapable !fts3 {\n  finish_test\n  return\n}\n\n# Taken from the gnome-shell project\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_test fuzz-oss1-gnomeshell {\n  db eval {\nCREATE TABLE Resource (ID INTEGER NOT NULL PRIMARY KEY, Uri TEXT NOT\nNULL, UNIQUE (Uri));\nCREATE VIRTUAL TABLE fts USING fts4;\nCREATE TABLE \"mfo:Action\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mfo:Enclosure\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:remoteLink\" INTEGER, \"mfo:remoteLink:graph\" INTEGER,\n\"mfo:groupDefault\" INTEGER, \"mfo:groupDefault:graph\" INTEGER,\n\"mfo:localLink\" INTEGER, \"mfo:localLink:graph\" INTEGER, \"mfo:optional\"\nINTEGER, \"mfo:optional:graph\" INTEGER);\nCREATE TABLE \"mfo:FeedChannel\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:updatedTime\" INTEGER, \"mfo:updatedTime:graph\" INTEGER,\n\"mfo:updatedTime:localDate\" INTEGER, \"mfo:updatedTime:localTime\"\nINTEGER, \"mfo:unreadCount\" INTEGER, \"mfo:unreadCount:graph\" INTEGER,\n\"mfo:totalCount\" INTEGER, \"mfo:totalCount:graph\" INTEGER, \"mfo:action\"\nINTEGER, \"mfo:action:graph\" INTEGER, \"mfo:type\" INTEGER,\n\"mfo:type:graph\" INTEGER);\nCREATE TABLE \"mfo:FeedElement\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:image\" TEXT COLLATE NOCASE, \"mfo:image:graph\" INTEGER,\n\"mfo:feedSettings\" INTEGER, \"mfo:feedSettings:graph\" INTEGER);\nCREATE TABLE \"mfo:FeedMessage\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:downloadedTime\" INTEGER, \"mfo:downloadedTime:graph\" INTEGER,\n\"mfo:downloadedTime:localDate\" INTEGER, \"mfo:downloadedTime:localTime\"\nINTEGER);\nCREATE TABLE \"mfo:FeedMessage_mfo:enclosureList\" (ID INTEGER NOT NULL,\n\"mfo:enclosureList\" INTEGER NOT NULL, \"mfo:enclosureList:graph\"\nINTEGER);\nCREATE TABLE \"mfo:FeedSettings\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:updateInterval\" INTEGER, \"mfo:updateInterval:graph\" INTEGER,\n\"mfo:expiryInterval\" INTEGER, \"mfo:expiryInterval:graph\" INTEGER,\n\"mfo:downloadPath\" TEXT COLLATE NOCASE, \"mfo:downloadPath:graph\"\nINTEGER, \"mfo:downloadFlag\" INTEGER, \"mfo:downloadFlag:graph\" INTEGER,\n\"mfo:maxSize\" INTEGER, \"mfo:maxSize:graph\" INTEGER);\nCREATE TABLE \"mfo:FeedType\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mfo:name\" TEXT COLLATE NOCASE, \"mfo:name:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoBoundingBox\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:GeoBoundingBox_mlo:bbNorthWest\" (ID INTEGER NOT\nNULL, \"mlo:bbNorthWest\" INTEGER NOT NULL, \"mlo:bbNorthWest:graph\"\nINTEGER);\nCREATE TABLE \"mlo:GeoBoundingBox_mlo:bbSouthEast\" (ID INTEGER NOT\nNULL, \"mlo:bbSouthEast\" INTEGER NOT NULL, \"mlo:bbSouthEast:graph\"\nINTEGER);\nCREATE TABLE \"mlo:GeoLocation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:GeoLocation_mlo:asBoundingBox\" (ID INTEGER NOT NULL,\n\"mlo:asBoundingBox\" INTEGER NOT NULL, \"mlo:asBoundingBox:graph\"\nINTEGER);\nCREATE TABLE \"mlo:GeoLocation_mlo:asGeoPoint\" (ID INTEGER NOT NULL,\n\"mlo:asGeoPoint\" INTEGER NOT NULL, \"mlo:asGeoPoint:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoLocation_mlo:asPostalAddress\" (ID INTEGER NOT\nNULL, \"mlo:asPostalAddress\" INTEGER NOT NULL,\n\"mlo:asPostalAddress:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:GeoPoint_mlo:address\" (ID INTEGER NOT NULL,\n\"mlo:address\" TEXT NOT NULL, \"mlo:address:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:altitude\" (ID INTEGER NOT NULL,\n\"mlo:altitude\" REAL NOT NULL, \"mlo:altitude:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:city\" (ID INTEGER NOT NULL, \"mlo:city\"\nTEXT NOT NULL, \"mlo:city:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:country\" (ID INTEGER NOT NULL,\n\"mlo:country\" TEXT NOT NULL, \"mlo:country:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:latitude\" (ID INTEGER NOT NULL,\n\"mlo:latitude\" REAL NOT NULL, \"mlo:latitude:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:longitude\" (ID INTEGER NOT NULL,\n\"mlo:longitude\" REAL NOT NULL, \"mlo:longitude:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:state\" (ID INTEGER NOT NULL,\n\"mlo:state\" TEXT NOT NULL, \"mlo:state:graph\" INTEGER);\nCREATE TABLE \"mlo:GeoPoint_mlo:timestamp\" (ID INTEGER NOT NULL,\n\"mlo:timestamp\" INTEGER NOT NULL, \"mlo:timestamp:graph\" INTEGER,\n\"mlo:timestamp:localDate\" INTEGER NOT NULL, \"mlo:timestamp:localTime\"\nINTEGER NOT NULL);\nCREATE TABLE \"mlo:GeoSphere\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:GeoSphere_mlo:radius\" (ID INTEGER NOT NULL,\n\"mlo:radius\" REAL NOT NULL, \"mlo:radius:graph\" INTEGER);\nCREATE TABLE \"mlo:Landmark\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:LandmarkCategory\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:LandmarkCategory_mlo:isRemovable\" (ID INTEGER NOT\nNULL, \"mlo:isRemovable\" INTEGER NOT NULL, \"mlo:isRemovable:graph\"\nINTEGER);\nCREATE TABLE \"mlo:Landmark_mlo:belongsToCategory\" (ID INTEGER NOT\nNULL, \"mlo:belongsToCategory\" INTEGER NOT NULL,\n\"mlo:belongsToCategory:graph\" INTEGER);\nCREATE TABLE \"mlo:Landmark_mlo:poiLocation\" (ID INTEGER NOT NULL,\n\"mlo:poiLocation\" INTEGER NOT NULL, \"mlo:poiLocation:graph\" INTEGER);\nCREATE TABLE \"mlo:LocationBoundingBox\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:LocationBoundingBox_mlo:boxEastLimit\" (ID INTEGER\nNOT NULL, \"mlo:boxEastLimit\" INTEGER NOT NULL,\n\"mlo:boxEastLimit:graph\" INTEGER);\nCREATE TABLE \"mlo:LocationBoundingBox_mlo:boxNorthLimit\" (ID INTEGER\nNOT NULL, \"mlo:boxNorthLimit\" INTEGER NOT NULL,\n\"mlo:boxNorthLimit:graph\" INTEGER);\nCREATE TABLE \"mlo:LocationBoundingBox_mlo:boxSouthWestCorner\" (ID\nINTEGER NOT NULL, \"mlo:boxSouthWestCorner\" INTEGER NOT NULL,\n\"mlo:boxSouthWestCorner:graph\" INTEGER);\nCREATE TABLE \"mlo:LocationBoundingBox_mlo:boxVerticalLimit\" (ID\nINTEGER NOT NULL, \"mlo:boxVerticalLimit\" INTEGER NOT NULL,\n\"mlo:boxVerticalLimit:graph\" INTEGER);\nCREATE TABLE \"mlo:PointOfInterest\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:Route\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mlo:Route_mlo:endTime\" (ID INTEGER NOT NULL,\n\"mlo:endTime\" INTEGER NOT NULL, \"mlo:endTime:graph\" INTEGER,\n\"mlo:endTime:localDate\" INTEGER NOT NULL, \"mlo:endTime:localTime\"\nINTEGER NOT NULL);\nCREATE TABLE \"mlo:Route_mlo:routeDetails\" (ID INTEGER NOT NULL,\n\"mlo:routeDetails\" TEXT NOT NULL, \"mlo:routeDetails:graph\" INTEGER);\nCREATE TABLE \"mlo:Route_mlo:startTime\" (ID INTEGER NOT NULL,\n\"mlo:startTime\" INTEGER NOT NULL, \"mlo:startTime:graph\" INTEGER,\n\"mlo:startTime:localDate\" INTEGER NOT NULL, \"mlo:startTime:localTime\"\nINTEGER NOT NULL);\nCREATE TABLE \"mto:DownloadTransfer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mto:State\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mto:SyncTransfer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mto:Transfer\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mto:transferState\" INTEGER, \"mto:transferState:graph\" INTEGER,\n\"mto:method\" INTEGER, \"mto:method:graph\" INTEGER, \"mto:created\"\nINTEGER, \"mto:created:graph\" INTEGER, \"mto:created:localDate\" INTEGER,\n\"mto:created:localTime\" INTEGER, \"mto:account\" TEXT COLLATE NOCASE,\n\"mto:account:graph\" INTEGER, \"mto:starter\" INTEGER,\n\"mto:starter:graph\" INTEGER, \"mto:agent\" INTEGER, \"mto:agent:graph\"\nINTEGER);\nCREATE TABLE \"mto:TransferElement\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"mto:source\" INTEGER, \"mto:source:graph\" INTEGER, \"mto:destination\"\nINTEGER, \"mto:destination:graph\" INTEGER, \"mto:startedTime\" INTEGER,\n\"mto:startedTime:graph\" INTEGER, \"mto:startedTime:localDate\" INTEGER,\n\"mto:startedTime:localTime\" INTEGER, \"mto:completedTime\" INTEGER,\n\"mto:completedTime:graph\" INTEGER, \"mto:completedTime:localDate\"\nINTEGER, \"mto:completedTime:localTime\" INTEGER, \"mto:state\" INTEGER,\n\"mto:state:graph\" INTEGER);\nCREATE TABLE \"mto:TransferMethod\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mto:Transfer_mto:transferList\" (ID INTEGER NOT NULL,\n\"mto:transferList\" INTEGER NOT NULL, \"mto:transferList:graph\"\nINTEGER);\nCREATE TABLE \"mto:Transfer_mto:transferPrivacyLevel\" (ID INTEGER NOT\nNULL, \"mto:transferPrivacyLevel\" TEXT NOT NULL,\n\"mto:transferPrivacyLevel:graph\" INTEGER);\nCREATE TABLE \"mto:UploadTransfer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"mto:UploadTransfer_mto:transferCategory\" (ID INTEGER NOT\nNULL, \"mto:transferCategory\" TEXT NOT NULL,\n\"mto:transferCategory:graph\" INTEGER);\nCREATE TABLE \"mtp:ScanType\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nao:Property\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nao:propertyName\" TEXT COLLATE NOCASE, \"nao:propertyName:graph\"\nINTEGER, \"nao:propertyValue\" TEXT COLLATE NOCASE,\n\"nao:propertyValue:graph\" INTEGER);\nCREATE TABLE \"nao:Tag\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nao:prefLabel\" TEXT COLLATE NOCASE, \"nao:prefLabel:graph\" INTEGER,\n\"nao:description\" TEXT COLLATE NOCASE, \"nao:description:graph\"\nINTEGER);\nCREATE TABLE \"nao:Tag_tracker:isDefaultTag\" (ID INTEGER NOT NULL,\n\"tracker:isDefaultTag\" INTEGER NOT NULL, \"tracker:isDefaultTag:graph\"\nINTEGER);\nCREATE TABLE \"nao:Tag_tracker:tagRelatedTo\" (ID INTEGER NOT NULL,\n\"tracker:tagRelatedTo\" INTEGER NOT NULL, \"tracker:tagRelatedTo:graph\"\nINTEGER);\nCREATE TABLE \"ncal:AccessClassification\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Alarm\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:repeat\" INTEGER, \"ncal:repeat:graph\" INTEGER);\nCREATE TABLE \"ncal:AlarmAction\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Alarm_ncal:action\" (ID INTEGER NOT NULL,\n\"ncal:action\" INTEGER NOT NULL, \"ncal:action:graph\" INTEGER);\nCREATE TABLE \"ncal:Attachment\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:attachmentUri\" INTEGER, \"ncal:attachmentUri:graph\" INTEGER,\n\"ncal:fmttype\" TEXT COLLATE NOCASE, \"ncal:fmttype:graph\" INTEGER,\n\"ncal:encoding\" INTEGER, \"ncal:encoding:graph\" INTEGER,\n\"ncal:attachmentContent\" TEXT COLLATE NOCASE,\n\"ncal:attachmentContent:graph\" INTEGER);\nCREATE TABLE \"ncal:AttachmentEncoding\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Attendee\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:delegatedTo\" INTEGER, \"ncal:delegatedTo:graph\" INTEGER,\n\"ncal:delegatedFrom\" INTEGER, \"ncal:delegatedFrom:graph\" INTEGER,\n\"ncal:cutype\" INTEGER, \"ncal:cutype:graph\" INTEGER, \"ncal:member\"\nINTEGER, \"ncal:member:graph\" INTEGER, \"ncal:role\" INTEGER,\n\"ncal:role:graph\" INTEGER, \"ncal:rsvp\" INTEGER, \"ncal:rsvp:graph\"\nINTEGER, \"ncal:partstat\" INTEGER, \"ncal:partstat:graph\" INTEGER);\nCREATE TABLE \"ncal:AttendeeOrOrganizer\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"ncal:dir\" INTEGER, \"ncal:dir:graph\" INTEGER,\n\"ncal:involvedContact\" INTEGER, \"ncal:involvedContact:graph\" INTEGER,\n\"ncal:sentBy\" INTEGER, \"ncal:sentBy:graph\" INTEGER);\nCREATE TABLE \"ncal:AttendeeRole\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:BydayRulePart\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:BydayRulePart_ncal:bydayModifier\" (ID INTEGER NOT\nNULL, \"ncal:bydayModifier\" INTEGER NOT NULL,\n\"ncal:bydayModifier:graph\" INTEGER);\nCREATE TABLE \"ncal:BydayRulePart_ncal:bydayWeekday\" (ID INTEGER NOT\nNULL, \"ncal:bydayWeekday\" INTEGER NOT NULL, \"ncal:bydayWeekday:graph\"\nINTEGER);\nCREATE TABLE \"ncal:Calendar\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:method\" TEXT COLLATE NOCASE, \"ncal:method:graph\" INTEGER,\n\"ncal:calscale\" INTEGER, \"ncal:calscale:graph\" INTEGER, \"ncal:prodid\"\nTEXT COLLATE NOCASE, \"ncal:prodid:graph\" INTEGER, \"ncal:version\" TEXT\nCOLLATE NOCASE, \"ncal:version:graph\" INTEGER);\nCREATE TABLE \"ncal:CalendarDataObject\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:CalendarScale\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:CalendarUserType\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Calendar_ncal:component\" (ID INTEGER NOT NULL,\n\"ncal:component\" INTEGER NOT NULL, \"ncal:component:graph\" INTEGER);\nCREATE TABLE \"ncal:Event\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:eventStatus\" INTEGER, \"ncal:eventStatus:graph\" INTEGER,\n\"ncal:transp\" INTEGER, \"ncal:transp:graph\" INTEGER);\nCREATE TABLE \"ncal:EventStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Freebusy\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:FreebusyPeriod\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:fbtype\" INTEGER, \"ncal:fbtype:graph\" INTEGER);\nCREATE TABLE \"ncal:FreebusyType\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Freebusy_ncal:freebusy\" (ID INTEGER NOT NULL,\n\"ncal:freebusy\" INTEGER NOT NULL, \"ncal:freebusy:graph\" INTEGER);\nCREATE TABLE \"ncal:Journal\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:journalStatus\" INTEGER, \"ncal:journalStatus:graph\" INTEGER);\nCREATE TABLE \"ncal:JournalStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:NcalDateTime\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:ncalTimezone\" INTEGER, \"ncal:ncalTimezone:graph\" INTEGER,\n\"ncal:date\" INTEGER, \"ncal:date:graph\" INTEGER, \"ncal:date:localDate\"\nINTEGER, \"ncal:date:localTime\" INTEGER, \"ncal:dateTime\" INTEGER,\n\"ncal:dateTime:graph\" INTEGER, \"ncal:dateTime:localDate\" INTEGER,\n\"ncal:dateTime:localTime\" INTEGER);\nCREATE TABLE \"ncal:NcalPeriod\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:periodBegin\" INTEGER, \"ncal:periodBegin:graph\" INTEGER,\n\"ncal:periodBegin:localDate\" INTEGER, \"ncal:periodBegin:localTime\"\nINTEGER, \"ncal:periodDuration\" INTEGER, \"ncal:periodDuration:graph\"\nINTEGER, \"ncal:periodEnd\" INTEGER, \"ncal:periodEnd:graph\" INTEGER,\n\"ncal:periodEnd:localDate\" INTEGER, \"ncal:periodEnd:localTime\"\nINTEGER);\nCREATE TABLE \"ncal:NcalTimeEntity\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Organizer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:ParticipationStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:RecurrenceFrequency\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:RecurrenceIdentifier\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"ncal:range\" INTEGER, \"ncal:range:graph\" INTEGER,\n\"ncal:recurrenceIdDateTime\" INTEGER, \"ncal:recurrenceIdDateTime:graph\"\nINTEGER);\nCREATE TABLE \"ncal:RecurrenceIdentifierRange\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:RecurrenceRule\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:until\" INTEGER, \"ncal:until:graph\" INTEGER,\n\"ncal:until:localDate\" INTEGER, \"ncal:until:localTime\" INTEGER,\n\"ncal:wkst\" INTEGER, \"ncal:wkst:graph\" INTEGER, \"ncal:interval\"\nINTEGER, \"ncal:interval:graph\" INTEGER, \"ncal:count\" INTEGER,\n\"ncal:count:graph\" INTEGER, \"ncal:freq\" INTEGER, \"ncal:freq:graph\"\nINTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:byday\" (ID INTEGER NOT NULL,\n\"ncal:byday\" INTEGER NOT NULL, \"ncal:byday:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:byhour\" (ID INTEGER NOT NULL,\n\"ncal:byhour\" INTEGER NOT NULL, \"ncal:byhour:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:byminute\" (ID INTEGER NOT NULL,\n\"ncal:byminute\" INTEGER NOT NULL, \"ncal:byminute:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:bymonth\" (ID INTEGER NOT NULL,\n\"ncal:bymonth\" INTEGER NOT NULL, \"ncal:bymonth:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:bymonthday\" (ID INTEGER NOT\nNULL, \"ncal:bymonthday\" INTEGER NOT NULL, \"ncal:bymonthday:graph\"\nINTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:bysecond\" (ID INTEGER NOT NULL,\n\"ncal:bysecond\" INTEGER NOT NULL, \"ncal:bysecond:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:bysetpos\" (ID INTEGER NOT NULL,\n\"ncal:bysetpos\" INTEGER NOT NULL, \"ncal:bysetpos:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:byweekno\" (ID INTEGER NOT NULL,\n\"ncal:byweekno\" INTEGER NOT NULL, \"ncal:byweekno:graph\" INTEGER);\nCREATE TABLE \"ncal:RecurrenceRule_ncal:byyearday\" (ID INTEGER NOT\nNULL, \"ncal:byyearday\" INTEGER NOT NULL, \"ncal:byyearday:graph\"\nINTEGER);\nCREATE TABLE \"ncal:RequestStatus\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:statusDescription\" TEXT COLLATE NOCASE,\n\"ncal:statusDescription:graph\" INTEGER, \"ncal:returnStatus\" TEXT\nCOLLATE NOCASE, \"ncal:returnStatus:graph\" INTEGER,\n\"ncal:requestStatusData\" TEXT COLLATE NOCASE,\n\"ncal:requestStatusData:graph\" INTEGER);\nCREATE TABLE \"ncal:TimeTransparency\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Timezone\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:tzurl\" INTEGER, \"ncal:tzurl:graph\" INTEGER, \"ncal:standard\"\nINTEGER, \"ncal:standard:graph\" INTEGER, \"ncal:daylight\" INTEGER,\n\"ncal:daylight:graph\" INTEGER, \"ncal:tzid\" TEXT COLLATE NOCASE,\n\"ncal:tzid:graph\" INTEGER);\nCREATE TABLE \"ncal:TimezoneObservance\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"ncal:tzoffsetfrom\" TEXT COLLATE NOCASE,\n\"ncal:tzoffsetfrom:graph\" INTEGER, \"ncal:tzoffsetto\" TEXT COLLATE\nNOCASE, \"ncal:tzoffsetto:graph\" INTEGER, \"ncal:tzname\" TEXT COLLATE\nNOCASE, \"ncal:tzname:graph\" INTEGER);\nCREATE TABLE \"ncal:Todo\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:percentComplete\" INTEGER, \"ncal:percentComplete:graph\" INTEGER,\n\"ncal:completed\" INTEGER, \"ncal:completed:graph\" INTEGER,\n\"ncal:completed:localDate\" INTEGER, \"ncal:completed:localTime\"\nINTEGER, \"ncal:todoStatus\" INTEGER, \"ncal:todoStatus:graph\" INTEGER,\n\"ncal:due\" INTEGER, \"ncal:due:graph\" INTEGER);\nCREATE TABLE \"ncal:TodoStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:Trigger\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:related\" INTEGER, \"ncal:related:graph\" INTEGER,\n\"ncal:triggerDateTime\" INTEGER, \"ncal:triggerDateTime:graph\" INTEGER,\n\"ncal:triggerDateTime:localDate\" INTEGER,\n\"ncal:triggerDateTime:localTime\" INTEGER, \"ncal:triggerDuration\"\nINTEGER, \"ncal:triggerDuration:graph\" INTEGER);\nCREATE TABLE \"ncal:TriggerRelation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"ncal:UnionParentClass\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"ncal:lastModified\" INTEGER, \"ncal:lastModified:graph\" INTEGER,\n\"ncal:lastModified:localDate\" INTEGER, \"ncal:lastModified:localTime\"\nINTEGER, \"ncal:trigger\" INTEGER, \"ncal:trigger:graph\" INTEGER,\n\"ncal:created\" INTEGER, \"ncal:created:graph\" INTEGER,\n\"ncal:created:localDate\" INTEGER, \"ncal:created:localTime\" INTEGER,\n\"ncal:url\" INTEGER, \"ncal:url:graph\" INTEGER, \"ncal:comment\" TEXT\nCOLLATE NOCASE, \"ncal:comment:graph\" INTEGER, \"ncal:summaryAltRep\"\nINTEGER, \"ncal:summaryAltRep:graph\" INTEGER, \"ncal:priority\" INTEGER,\n\"ncal:priority:graph\" INTEGER, \"ncal:location\" TEXT COLLATE NOCASE,\n\"ncal:location:graph\" INTEGER, \"ncal:uid\" TEXT COLLATE NOCASE,\n\"ncal:uid:graph\" INTEGER, \"ncal:requestStatus\" INTEGER,\n\"ncal:requestStatus:graph\" INTEGER, \"ncal:recurrenceId\" INTEGER,\n\"ncal:recurrenceId:graph\" INTEGER, \"ncal:dtstamp\" INTEGER,\n\"ncal:dtstamp:graph\" INTEGER, \"ncal:dtstamp:localDate\" INTEGER,\n\"ncal:dtstamp:localTime\" INTEGER, \"ncal:class\" INTEGER,\n\"ncal:class:graph\" INTEGER, \"ncal:organizer\" INTEGER,\n\"ncal:organizer:graph\" INTEGER, \"ncal:dtend\" INTEGER,\n\"ncal:dtend:graph\" INTEGER, \"ncal:summary\" TEXT COLLATE NOCASE,\n\"ncal:summary:graph\" INTEGER, \"ncal:descriptionAltRep\" INTEGER,\n\"ncal:descriptionAltRep:graph\" INTEGER, \"ncal:commentAltRep\" INTEGER,\n\"ncal:commentAltRep:graph\" INTEGER, \"ncal:sequence\" INTEGER,\n\"ncal:sequence:graph\" INTEGER, \"ncal:contact\" TEXT COLLATE NOCASE,\n\"ncal:contact:graph\" INTEGER, \"ncal:contactAltRep\" INTEGER,\n\"ncal:contactAltRep:graph\" INTEGER, \"ncal:locationAltRep\" INTEGER,\n\"ncal:locationAltRep:graph\" INTEGER, \"ncal:geo\" INTEGER,\n\"ncal:geo:graph\" INTEGER, \"ncal:resourcesAltRep\" INTEGER,\n\"ncal:resourcesAltRep:graph\" INTEGER, \"ncal:dtstart\" INTEGER,\n\"ncal:dtstart:graph\" INTEGER, \"ncal:description\" TEXT COLLATE NOCASE,\n\"ncal:description:graph\" INTEGER, \"ncal:relatedToSibling\" TEXT COLLATE\nNOCASE, \"ncal:relatedToSibling:graph\" INTEGER, \"ncal:duration\"\nINTEGER, \"ncal:duration:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:attach\" (ID INTEGER NOT NULL,\n\"ncal:attach\" INTEGER NOT NULL, \"ncal:attach:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:attendee\" (ID INTEGER NOT\nNULL, \"ncal:attendee\" INTEGER NOT NULL, \"ncal:attendee:graph\"\nINTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:categories\" (ID INTEGER NOT\nNULL, \"ncal:categories\" TEXT NOT NULL, \"ncal:categories:graph\"\nINTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:exdate\" (ID INTEGER NOT NULL,\n\"ncal:exdate\" INTEGER NOT NULL, \"ncal:exdate:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:exrule\" (ID INTEGER NOT NULL,\n\"ncal:exrule\" INTEGER NOT NULL, \"ncal:exrule:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:hasAlarm\" (ID INTEGER NOT\nNULL, \"ncal:hasAlarm\" INTEGER NOT NULL, \"ncal:hasAlarm:graph\"\nINTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:ncalRelation\" (ID INTEGER NOT\nNULL, \"ncal:ncalRelation\" TEXT NOT NULL, \"ncal:ncalRelation:graph\"\nINTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:rdate\" (ID INTEGER NOT NULL,\n\"ncal:rdate\" INTEGER NOT NULL, \"ncal:rdate:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:relatedToChild\" (ID INTEGER\nNOT NULL, \"ncal:relatedToChild\" TEXT NOT NULL,\n\"ncal:relatedToChild:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:relatedToParent\" (ID INTEGER\nNOT NULL, \"ncal:relatedToParent\" TEXT NOT NULL,\n\"ncal:relatedToParent:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:resources\" (ID INTEGER NOT\nNULL, \"ncal:resources\" TEXT NOT NULL, \"ncal:resources:graph\" INTEGER);\nCREATE TABLE \"ncal:UnionParentClass_ncal:rrule\" (ID INTEGER NOT NULL,\n\"ncal:rrule\" INTEGER NOT NULL, \"ncal:rrule:graph\" INTEGER);\nCREATE TABLE \"ncal:Weekday\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:Affiliation\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:department\" TEXT COLLATE NOCASE, \"nco:department:graph\" INTEGER,\n\"nco:org\" INTEGER, \"nco:org:graph\" INTEGER, \"nco:role\" TEXT COLLATE\nNOCASE, \"nco:role:graph\" INTEGER);\nCREATE TABLE \"nco:Affiliation_nco:title\" (ID INTEGER NOT NULL,\n\"nco:title\" TEXT NOT NULL, \"nco:title:graph\" INTEGER);\nCREATE TABLE \"nco:AuthorizationStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:BbsNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:CarPhoneNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:CellPhoneNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:Contact\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:fullname\" TEXT COLLATE NOCASE, \"nco:fullname:graph\" INTEGER,\n\"nco:key\" INTEGER, \"nco:key:graph\" INTEGER, \"nco:contactUID\" TEXT\nCOLLATE NOCASE, \"nco:contactUID:graph\" INTEGER, \"nco:contactLocalUID\"\nTEXT COLLATE NOCASE, \"nco:contactLocalUID:graph\" INTEGER,\n\"nco:hasLocation\" INTEGER, \"nco:hasLocation:graph\" INTEGER,\n\"nco:nickname\" TEXT COLLATE NOCASE, \"nco:nickname:graph\" INTEGER,\n\"nco:representative\" INTEGER, \"nco:representative:graph\" INTEGER,\n\"nco:photo\" INTEGER, \"nco:photo:graph\" INTEGER, \"nco:birthDate\"\nINTEGER, \"nco:birthDate:graph\" INTEGER, \"nco:birthDate:localDate\"\nINTEGER, \"nco:birthDate:localTime\" INTEGER, \"nco:sound\" INTEGER,\n\"nco:sound:graph\" INTEGER);\nCREATE TABLE \"nco:ContactGroup\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:contactGroupName\" TEXT COLLATE NOCASE,\n\"nco:contactGroupName:graph\" INTEGER);\nCREATE TABLE \"nco:ContactList\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:ContactListDataObject\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:ContactList_nco:containsContact\" (ID INTEGER NOT\nNULL, \"nco:containsContact\" INTEGER NOT NULL,\n\"nco:containsContact:graph\" INTEGER);\nCREATE TABLE \"nco:ContactMedium\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:contactMediumComment\" TEXT COLLATE NOCASE,\n\"nco:contactMediumComment:graph\" INTEGER);\nCREATE TABLE \"nco:Contact_ncal:anniversary\" (ID INTEGER NOT NULL,\n\"ncal:anniversary\" INTEGER NOT NULL, \"ncal:anniversary:graph\"\nINTEGER);\nCREATE TABLE \"nco:Contact_ncal:birthday\" (ID INTEGER NOT NULL,\n\"ncal:birthday\" INTEGER NOT NULL, \"ncal:birthday:graph\" INTEGER);\nCREATE TABLE \"nco:Contact_nco:belongsToGroup\" (ID INTEGER NOT NULL,\n\"nco:belongsToGroup\" INTEGER NOT NULL, \"nco:belongsToGroup:graph\"\nINTEGER);\nCREATE TABLE \"nco:Contact_nco:note\" (ID INTEGER NOT NULL, \"nco:note\"\nTEXT NOT NULL, \"nco:note:graph\" INTEGER);\nCREATE TABLE \"nco:Contact_scal:anniversary\" (ID INTEGER NOT NULL,\n\"scal:anniversary\" INTEGER NOT NULL, \"scal:anniversary:graph\"\nINTEGER);\nCREATE TABLE \"nco:Contact_scal:birthday\" (ID INTEGER NOT NULL,\n\"scal:birthday\" INTEGER NOT NULL, \"scal:birthday:graph\" INTEGER);\nCREATE TABLE \"nco:DomesticDeliveryAddress\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:EmailAddress\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:emailAddress\" TEXT COLLATE NOCASE UNIQUE,\n\"nco:emailAddress:graph\" INTEGER);\nCREATE TABLE \"nco:FaxNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:Gender\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:IMAccount\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:imAccountAddress\" INTEGER UNIQUE, \"nco:imAccountAddress:graph\"\nINTEGER, \"nco:imAccountType\" TEXT COLLATE NOCASE,\n\"nco:imAccountType:graph\" INTEGER, \"nco:imDisplayName\" TEXT COLLATE\nNOCASE, \"nco:imDisplayName:graph\" INTEGER, \"nco:imEnabled\" INTEGER,\n\"nco:imEnabled:graph\" INTEGER);\nCREATE TABLE \"nco:IMAccount_nco:hasIMContact\" (ID INTEGER NOT NULL,\n\"nco:hasIMContact\" INTEGER NOT NULL, \"nco:hasIMContact:graph\"\nINTEGER);\nCREATE TABLE \"nco:IMAddress\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:imID\" TEXT COLLATE NOCASE, \"nco:imID:graph\" INTEGER,\n\"nco:imNickname\" TEXT COLLATE NOCASE, \"nco:imNickname:graph\" INTEGER,\n\"nco:imAvatar\" INTEGER, \"nco:imAvatar:graph\" INTEGER, \"nco:imProtocol\"\nTEXT COLLATE NOCASE, \"nco:imProtocol:graph\" INTEGER,\n\"nco:imStatusMessage\" TEXT COLLATE NOCASE,\n\"nco:imStatusMessage:graph\" INTEGER, \"nco:imPresence\" INTEGER,\n\"nco:imPresence:graph\" INTEGER, \"nco:presenceLastModified\" INTEGER,\n\"nco:presenceLastModified:graph\" INTEGER,\n\"nco:presenceLastModified:localDate\" INTEGER,\n\"nco:presenceLastModified:localTime\" INTEGER,\n\"nco:imAddressAuthStatusFrom\" INTEGER,\n\"nco:imAddressAuthStatusFrom:graph\" INTEGER,\n\"nco:imAddressAuthStatusTo\" INTEGER, \"nco:imAddressAuthStatusTo:graph\"\nINTEGER);\nCREATE TABLE \"nco:IMAddress_nco:imCapability\" (ID INTEGER NOT NULL,\n\"nco:imCapability\" INTEGER NOT NULL, \"nco:imCapability:graph\"\nINTEGER);\nCREATE TABLE \"nco:IMCapability\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:InternationalDeliveryAddress\" (ID INTEGER NOT NULL\nPRIMARY KEY);\nCREATE TABLE \"nco:IsdnNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:MessagingNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:ModemNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:OrganizationContact\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nco:logo\" INTEGER, \"nco:logo:graph\" INTEGER);\nCREATE TABLE \"nco:PagerNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:ParcelDeliveryAddress\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:PcsNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:PersonContact\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:nameFamily\" TEXT COLLATE NOCASE, \"nco:nameFamily:graph\" INTEGER,\n\"nco:nameGiven\" TEXT COLLATE NOCASE, \"nco:nameGiven:graph\" INTEGER,\n\"nco:nameAdditional\" TEXT COLLATE NOCASE, \"nco:nameAdditional:graph\"\nINTEGER, \"nco:nameHonorificSuffix\" TEXT COLLATE NOCASE,\n\"nco:nameHonorificSuffix:graph\" INTEGER, \"nco:nameHonorificPrefix\"\nTEXT COLLATE NOCASE, \"nco:nameHonorificPrefix:graph\" INTEGER,\n\"nco:hobby\" TEXT COLLATE NOCASE, \"nco:hobby:graph\" INTEGER,\n\"nco:gender\" INTEGER, \"nco:gender:graph\" INTEGER);\nCREATE TABLE \"nco:PersonContact_nco:hasAffiliation\" (ID INTEGER NOT\nNULL, \"nco:hasAffiliation\" INTEGER NOT NULL,\n\"nco:hasAffiliation:graph\" INTEGER);\nCREATE TABLE \"nco:PhoneNumber\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:phoneNumber\" TEXT COLLATE NOCASE, \"nco:phoneNumber:graph\"\nINTEGER);\nCREATE TABLE \"nco:PostalAddress\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:region\" TEXT COLLATE NOCASE, \"nco:region:graph\" INTEGER,\n\"nco:country\" TEXT COLLATE NOCASE, \"nco:country:graph\" INTEGER,\n\"nco:extendedAddress\" TEXT COLLATE NOCASE,\n\"nco:extendedAddress:graph\" INTEGER, \"nco:addressLocation\" INTEGER,\n\"nco:addressLocation:graph\" INTEGER, \"nco:streetAddress\" TEXT COLLATE\nNOCASE, \"nco:streetAddress:graph\" INTEGER, \"nco:postalcode\" TEXT\nCOLLATE NOCASE, \"nco:postalcode:graph\" INTEGER, \"nco:locality\" TEXT\nCOLLATE NOCASE, \"nco:locality:graph\" INTEGER, \"nco:county\" TEXT\nCOLLATE NOCASE, \"nco:county:graph\" INTEGER, \"nco:district\" TEXT\nCOLLATE NOCASE, \"nco:district:graph\" INTEGER, \"nco:pobox\" TEXT\nCOLLATE NOCASE, \"nco:pobox:graph\" INTEGER);\nCREATE TABLE \"nco:PresenceStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:Role\" (ID INTEGER NOT NULL PRIMARY KEY, \"nco:video\"\nINTEGER, \"nco:video:graph\" INTEGER);\nCREATE TABLE \"nco:Role_nco:blogUrl\" (ID INTEGER NOT NULL,\n\"nco:blogUrl\" INTEGER NOT NULL, \"nco:blogUrl:graph\" INTEGER);\nCREATE TABLE \"nco:Role_nco:foafUrl\" (ID INTEGER NOT NULL,\n\"nco:foafUrl\" INTEGER NOT NULL, \"nco:foafUrl:graph\" INTEGER);\nCREATE TABLE \"nco:Role_nco:hasContactMedium\" (ID INTEGER NOT NULL,\n\"nco:hasContactMedium\" INTEGER NOT NULL, \"nco:hasContactMedium:graph\"\nINTEGER);\nCREATE TABLE \"nco:Role_nco:hasEmailAddress\" (ID INTEGER NOT NULL,\n\"nco:hasEmailAddress\" INTEGER NOT NULL, \"nco:hasEmailAddress:graph\"\nINTEGER);\nCREATE TABLE \"nco:Role_nco:hasIMAddress\" (ID INTEGER NOT NULL,\n\"nco:hasIMAddress\" INTEGER NOT NULL, \"nco:hasIMAddress:graph\"\nINTEGER);\nCREATE TABLE \"nco:Role_nco:hasPhoneNumber\" (ID INTEGER NOT NULL,\n\"nco:hasPhoneNumber\" INTEGER NOT NULL, \"nco:hasPhoneNumber:graph\"\nINTEGER);\nCREATE TABLE \"nco:Role_nco:hasPostalAddress\" (ID INTEGER NOT NULL,\n\"nco:hasPostalAddress\" INTEGER NOT NULL, \"nco:hasPostalAddress:graph\"\nINTEGER);\nCREATE TABLE \"nco:Role_nco:url\" (ID INTEGER NOT NULL, \"nco:url\"\nINTEGER NOT NULL, \"nco:url:graph\" INTEGER);\nCREATE TABLE \"nco:Role_nco:websiteUrl\" (ID INTEGER NOT NULL,\n\"nco:websiteUrl\" INTEGER NOT NULL, \"nco:websiteUrl:graph\" INTEGER);\nCREATE TABLE \"nco:VideoTelephoneNumber\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nco:VoicePhoneNumber\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nco:voiceMail\" INTEGER, \"nco:voiceMail:graph\" INTEGER);\nCREATE TABLE \"nfo:Application\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Archive\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:uncompressedSize\" INTEGER, \"nfo:uncompressedSize:graph\" INTEGER);\nCREATE TABLE \"nfo:ArchiveItem\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:isPasswordProtected\" INTEGER, \"nfo:isPasswordProtected:graph\"\nINTEGER);\nCREATE TABLE \"nfo:Attachment\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Audio\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:channels\" INTEGER, \"nfo:channels:graph\" INTEGER,\n\"nfo:sideChannels\" INTEGER, \"nfo:sideChannels:graph\" INTEGER,\n\"nfo:lfeChannels\" INTEGER, \"nfo:lfeChannels:graph\" INTEGER,\n\"nfo:sampleCount\" INTEGER, \"nfo:sampleCount:graph\" INTEGER,\n\"nfo:bitsPerSample\" INTEGER, \"nfo:bitsPerSample:graph\" INTEGER,\n\"nfo:frontChannels\" INTEGER, \"nfo:frontChannels:graph\" INTEGER,\n\"nfo:sampleRate\" REAL, \"nfo:sampleRate:graph\" INTEGER,\n\"nfo:averageAudioBitrate\" REAL, \"nfo:averageAudioBitrate:graph\"\nINTEGER, \"nfo:rearChannels\" INTEGER, \"nfo:rearChannels:graph\" INTEGER,\n\"nfo:gain\" INTEGER, \"nfo:gain:graph\" INTEGER, \"nfo:peakGain\" INTEGER,\n\"nfo:peakGain:graph\" INTEGER, \"nfo:audioOffset\" REAL,\n\"nfo:audioOffset:graph\" INTEGER);\nCREATE TABLE \"nfo:Bookmark\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:bookmarks\" INTEGER, \"nfo:bookmarks:graph\" INTEGER,\n\"nfo:characterPosition\" INTEGER, \"nfo:characterPosition:graph\"\nINTEGER, \"nfo:pageNumber\" INTEGER, \"nfo:pageNumber:graph\" INTEGER,\n\"nfo:streamPosition\" INTEGER, \"nfo:streamPosition:graph\" INTEGER,\n\"nfo:streamDuration\" INTEGER, \"nfo:streamDuration:graph\" INTEGER);\nCREATE TABLE \"nfo:BookmarkFolder\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:BookmarkFolder_nfo:containsBookmark\" (ID INTEGER NOT\nNULL, \"nfo:containsBookmark\" INTEGER NOT NULL,\n\"nfo:containsBookmark:graph\" INTEGER);\nCREATE TABLE \"nfo:BookmarkFolder_nfo:containsBookmarkFolder\" (ID\nINTEGER NOT NULL, \"nfo:containsBookmarkFolder\" INTEGER NOT NULL,\n\"nfo:containsBookmarkFolder:graph\" INTEGER);\nCREATE TABLE \"nfo:CompressionType\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Cursor\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:DataContainer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:DeletedResource\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:originalLocation\" TEXT COLLATE NOCASE,\n\"nfo:originalLocation:graph\" INTEGER, \"nfo:deletionDate\" INTEGER,\n\"nfo:deletionDate:graph\" INTEGER, \"nfo:deletionDate:localDate\"\nINTEGER, \"nfo:deletionDate:localTime\" INTEGER);\nCREATE TABLE \"nfo:Document\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:tableOfContents\" TEXT COLLATE NOCASE,\n\"nfo:tableOfContents:graph\" INTEGER);\nCREATE TABLE \"nfo:EmbeddedFileDataObject\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nfo:encoding\" TEXT COLLATE NOCASE, \"nfo:encoding:graph\"\nINTEGER);\nCREATE TABLE \"nfo:Equipment\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:manufacturer\" TEXT COLLATE NOCASE, \"nfo:manufacturer:graph\"\nINTEGER, \"nfo:model\" TEXT COLLATE NOCASE, \"nfo:model:graph\" INTEGER,\n\"nfo:equipmentSoftware\" TEXT COLLATE NOCASE,\n\"nfo:equipmentSoftware:graph\" INTEGER);\nCREATE TABLE \"nfo:Executable\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:FileDataObject\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:fileLastAccessed\" INTEGER, \"nfo:fileLastAccessed:graph\" INTEGER,\n\"nfo:fileLastAccessed:localDate\" INTEGER,\n\"nfo:fileLastAccessed:localTime\" INTEGER, \"nfo:fileCreated\" INTEGER,\n\"nfo:fileCreated:graph\" INTEGER, \"nfo:fileCreated:localDate\" INTEGER,\n\"nfo:fileCreated:localTime\" INTEGER, \"nfo:fileSize\" INTEGER,\n\"nfo:fileSize:graph\" INTEGER, \"nfo:permissions\" TEXT COLLATE NOCASE,\n\"nfo:permissions:graph\" INTEGER, \"nfo:fileName\" TEXT COLLATE NOCASE,\n\"nfo:fileName:graph\" INTEGER, \"nfo:hasHash\" INTEGER,\n\"nfo:hasHash:graph\" INTEGER, \"nfo:fileOwner\" INTEGER,\n\"nfo:fileOwner:graph\" INTEGER, \"nfo:fileLastModified\" INTEGER,\n\"nfo:fileLastModified:graph\" INTEGER, \"nfo:fileLastModified:localDate\"\nINTEGER, \"nfo:fileLastModified:localTime\" INTEGER);\nCREATE TABLE \"nfo:FileHash\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:hashValue\" TEXT COLLATE NOCASE, \"nfo:hashValue:graph\" INTEGER,\n\"nfo:hashAlgorithm\" TEXT COLLATE NOCASE, \"nfo:hashAlgorithm:graph\"\nINTEGER);\nCREATE TABLE \"nfo:Filesystem\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:FilesystemImage\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Folder\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Font\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:fontFamily\" TEXT COLLATE NOCASE, \"nfo:fontFamily:graph\" INTEGER,\n\"nfo:foundry\" INTEGER, \"nfo:foundry:graph\" INTEGER);\nCREATE TABLE \"nfo:HardDiskPartition\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:HelpDocument\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:HtmlDocument\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Icon\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Image\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:verticalResolution\" INTEGER, \"nfo:verticalResolution:graph\"\nINTEGER, \"nfo:horizontalResolution\" INTEGER,\n\"nfo:horizontalResolution:graph\" INTEGER, \"nfo:orientation\" INTEGER,\n\"nfo:orientation:graph\" INTEGER);\nCREATE TABLE \"nfo:Image_nfo:depicts\" (ID INTEGER NOT NULL,\n\"nfo:depicts\" INTEGER NOT NULL, \"nfo:depicts:graph\" INTEGER);\nCREATE TABLE \"nfo:Image_nfo:hasRegionOfInterest\" (ID INTEGER NOT NULL,\n\"nfo:hasRegionOfInterest\" INTEGER NOT NULL,\n\"nfo:hasRegionOfInterest:graph\" INTEGER);\nCREATE TABLE \"nfo:Media\" (ID INTEGER NOT NULL PRIMARY KEY, \"nfo:count\"\nINTEGER, \"nfo:count:graph\" INTEGER, \"nfo:duration\" INTEGER,\n\"nfo:duration:graph\" INTEGER, \"nfo:compressionType\" INTEGER,\n\"nfo:compressionType:graph\" INTEGER, \"nfo:hasMediaStream\" INTEGER,\n\"nfo:hasMediaStream:graph\" INTEGER, \"nfo:bitDepth\" INTEGER,\n\"nfo:bitDepth:graph\" INTEGER, \"nfo:codec\" TEXT COLLATE NOCASE,\n\"nfo:codec:graph\" INTEGER, \"nfo:encodedBy\" TEXT COLLATE NOCASE,\n\"nfo:encodedBy:graph\" INTEGER, \"nfo:bitrateType\" TEXT COLLATE NOCASE,\n\"nfo:bitrateType:graph\" INTEGER, \"nfo:averageBitrate\" REAL,\n\"nfo:averageBitrate:graph\" INTEGER, \"nfo:genre\" TEXT COLLATE NOCASE,\n\"nfo:genre:graph\" INTEGER, \"nfo:equipment\" INTEGER,\n\"nfo:equipment:graph\" INTEGER, \"nfo:lastPlayedPosition\" INTEGER,\n\"nfo:lastPlayedPosition:graph\" INTEGER, \"nmm:genre\" TEXT COLLATE\nNOCASE, \"nmm:genre:graph\" INTEGER, \"nmm:skipCounter\" INTEGER,\n\"nmm:skipCounter:graph\" INTEGER, \"nmm:dlnaProfile\" TEXT COLLATE\nNOCASE, \"nmm:dlnaProfile:graph\" INTEGER, \"nmm:dlnaMime\" TEXT COLLATE\nNOCASE, \"nmm:dlnaMime:graph\" INTEGER, \"nmm:uPnPShared\" INTEGER,\n\"nmm:uPnPShared:graph\" INTEGER, \"mtp:credits\" TEXT COLLATE NOCASE,\n\"mtp:credits:graph\" INTEGER, \"mtp:creator\" TEXT COLLATE NOCASE,\n\"mtp:creator:graph\" INTEGER);\nCREATE TABLE \"nfo:MediaFileListEntry\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nfo:listPosition\" REAL, \"nfo:listPosition:graph\" INTEGER,\n\"nfo:entryUrl\" TEXT COLLATE NOCASE, \"nfo:entryUrl:graph\" INTEGER);\nCREATE TABLE \"nfo:MediaList\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:entryCounter\" INTEGER, \"nfo:entryCounter:graph\" INTEGER,\n\"nfo:listDuration\" INTEGER, \"nfo:listDuration:graph\" INTEGER);\nCREATE TABLE \"nfo:MediaList_nfo:hasMediaFileListEntry\" (ID INTEGER NOT\nNULL, \"nfo:hasMediaFileListEntry\" INTEGER NOT NULL,\n\"nfo:hasMediaFileListEntry:graph\" INTEGER);\nCREATE TABLE \"nfo:MediaList_nfo:mediaListEntry\" (ID INTEGER NOT NULL,\n\"nfo:mediaListEntry\" INTEGER NOT NULL, \"nfo:mediaListEntry:graph\"\nINTEGER);\nCREATE TABLE \"nfo:MediaStream\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Media_mtp:hidden\" (ID INTEGER NOT NULL, \"mtp:hidden\"\nINTEGER NOT NULL, \"mtp:hidden:graph\" INTEGER);\nCREATE TABLE \"nfo:Media_nmm:alternativeMedia\" (ID INTEGER NOT NULL,\n\"nmm:alternativeMedia\" INTEGER NOT NULL, \"nmm:alternativeMedia:graph\"\nINTEGER);\nCREATE TABLE \"nfo:MindMap\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Note\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:OperatingSystem\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Orientation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:PaginatedTextDocument\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nfo:pageCount\" INTEGER, \"nfo:pageCount:graph\" INTEGER);\nCREATE TABLE \"nfo:PlainTextDocument\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Presentation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:RasterImage\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:RegionOfInterest\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:regionOfInterestX\" REAL, \"nfo:regionOfInterestX:graph\" INTEGER,\n\"nfo:regionOfInterestY\" REAL, \"nfo:regionOfInterestY:graph\" INTEGER,\n\"nfo:regionOfInterestWidth\" REAL, \"nfo:regionOfInterestWidth:graph\"\nINTEGER, \"nfo:regionOfInterestHeight\" REAL,\n\"nfo:regionOfInterestHeight:graph\" INTEGER, \"nfo:regionOfInterestType\"\nINTEGER, \"nfo:regionOfInterestType:graph\" INTEGER, \"nfo:roiRefersTo\"\nINTEGER, \"nfo:roiRefersTo:graph\" INTEGER);\nCREATE TABLE \"nfo:RegionOfInterestContent\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:RemoteDataObject\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:RemotePortAddress\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Software\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:conflicts\" INTEGER, \"nfo:conflicts:graph\" INTEGER,\n\"nfo:supercedes\" INTEGER, \"nfo:supercedes:graph\" INTEGER,\n\"nfo:softwareIcon\" INTEGER, \"nfo:softwareIcon:graph\" INTEGER,\n\"nfo:softwareCmdLine\" TEXT COLLATE NOCASE,\n\"nfo:softwareCmdLine:graph\" INTEGER);\nCREATE TABLE \"nfo:SoftwareApplication\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:SoftwareCategory\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:softwareCategoryIcon\" INTEGER, \"nfo:softwareCategoryIcon:graph\"\nINTEGER);\nCREATE TABLE \"nfo:SoftwareItem\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:SoftwareService\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:SourceCode\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:commentCharacterCount\" INTEGER, \"nfo:commentCharacterCount:graph\"\nINTEGER, \"nfo:programmingLanguage\" TEXT COLLATE NOCASE,\n\"nfo:programmingLanguage:graph\" INTEGER, \"nfo:definesClass\" TEXT\nCOLLATE NOCASE, \"nfo:definesClass:graph\" INTEGER,\n\"nfo:definesFunction\" TEXT COLLATE NOCASE,\n\"nfo:definesFunction:graph\" INTEGER, \"nfo:definesGlobalVariable\" TEXT\nCOLLATE NOCASE, \"nfo:definesGlobalVariable:graph\" INTEGER);\nCREATE TABLE \"nfo:Spreadsheet\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:TextDocument\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:wordCount\" INTEGER, \"nfo:wordCount:graph\" INTEGER,\n\"nfo:lineCount\" INTEGER, \"nfo:lineCount:graph\" INTEGER,\n\"nfo:characterCount\" INTEGER, \"nfo:characterCount:graph\" INTEGER);\nCREATE TABLE \"nfo:Trash\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:VectorImage\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nfo:Video\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:frameRate\" REAL, \"nfo:frameRate:graph\" INTEGER, \"nfo:frameCount\"\nINTEGER, \"nfo:frameCount:graph\" INTEGER, \"nfo:averageVideoBitrate\"\nREAL, \"nfo:averageVideoBitrate:graph\" INTEGER);\nCREATE TABLE \"nfo:Visual\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nie:contentCreated\" INTEGER, \"nie:contentCreated:graph\" INTEGER,\n\"nie:contentCreated:localDate\" INTEGER, \"nie:contentCreated:localTime\"\nINTEGER, \"nfo:aspectRatio\" REAL, \"nfo:aspectRatio:graph\" INTEGER,\n\"nfo:heading\" REAL, \"nfo:heading:graph\" INTEGER, \"nfo:tilt\" REAL,\n\"nfo:tilt:graph\" INTEGER, \"nfo:interlaceMode\" INTEGER,\n\"nfo:interlaceMode:graph\" INTEGER, \"nfo:height\" INTEGER,\n\"nfo:height:graph\" INTEGER, \"nfo:width\" INTEGER, \"nfo:width:graph\"\nINTEGER, \"nfo:colorDepth\" INTEGER, \"nfo:colorDepth:graph\" INTEGER);\nCREATE TABLE \"nfo:WebHistory\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nfo:domain\" TEXT COLLATE NOCASE, \"nfo:domain:graph\" INTEGER,\n\"nfo:uri\" TEXT COLLATE NOCASE, \"nfo:uri:graph\" INTEGER);\nCREATE TABLE \"nfo:Website\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nid3:ID3Audio\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nid3:title\" TEXT COLLATE NOCASE, \"nid3:title:graph\" INTEGER,\n\"nid3:albumTitle\" TEXT COLLATE NOCASE, \"nid3:albumTitle:graph\"\nINTEGER, \"nid3:contentType\" TEXT COLLATE NOCASE,\n\"nid3:contentType:graph\" INTEGER, \"nid3:length\" INTEGER,\n\"nid3:length:graph\" INTEGER, \"nid3:recordingYear\" INTEGER,\n\"nid3:recordingYear:graph\" INTEGER, \"nid3:trackNumber\" TEXT COLLATE\nNOCASE, \"nid3:trackNumber:graph\" INTEGER, \"nid3:partOfSet\" TEXT\nCOLLATE NOCASE, \"nid3:partOfSet:graph\" INTEGER, \"nid3:comments\" TEXT\nCOLLATE NOCASE, \"nid3:comments:graph\" INTEGER);\nCREATE TABLE \"nid3:ID3Audio_nid3:leadArtist\" (ID INTEGER NOT NULL,\n\"nid3:leadArtist\" INTEGER NOT NULL, \"nid3:leadArtist:graph\" INTEGER);\nCREATE TABLE \"nie:DataObject\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nie:url\" TEXT COLLATE NOCASE UNIQUE, \"nie:url:graph\" INTEGER,\n\"nie:byteSize\" INTEGER, \"nie:byteSize:graph\" INTEGER,\n\"nie:interpretedAs\" INTEGER, \"nie:interpretedAs:graph\" INTEGER,\n\"nie:lastRefreshed\" INTEGER, \"nie:lastRefreshed:graph\" INTEGER,\n\"nie:lastRefreshed:localDate\" INTEGER, \"nie:lastRefreshed:localTime\"\nINTEGER, \"nie:created\" INTEGER, \"nie:created:graph\" INTEGER,\n\"nie:created:localDate\" INTEGER, \"nie:created:localTime\" INTEGER,\n\"nfo:belongsToContainer\" INTEGER, \"nfo:belongsToContainer:graph\"\nINTEGER, \"tracker:available\" INTEGER, \"tracker:available:graph\"\nINTEGER);\nCREATE TABLE \"nie:DataObject_nie:dataSource\" (ID INTEGER NOT NULL,\n\"nie:dataSource\" INTEGER NOT NULL, \"nie:dataSource:graph\" INTEGER);\nCREATE TABLE \"nie:DataObject_nie:isPartOf\" (ID INTEGER NOT NULL,\n\"nie:isPartOf\" INTEGER NOT NULL, \"nie:isPartOf:graph\" INTEGER);\nCREATE TABLE \"nie:DataSource\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nie:InformationElement\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nie:title\" TEXT COLLATE NOCASE, \"nie:title:graph\" INTEGER,\n\"nie:contentLastModified\" INTEGER, \"nie:contentLastModified:graph\"\nINTEGER, \"nie:contentLastModified:localDate\" INTEGER,\n\"nie:contentLastModified:localTime\" INTEGER, \"nie:subject\" TEXT\nCOLLATE NOCASE, \"nie:subject:graph\" INTEGER, \"nie:mimeType\" TEXT\nCOLLATE NOCASE, \"nie:mimeType:graph\" INTEGER, \"nie:language\" TEXT\nCOLLATE NOCASE, \"nie:language:graph\" INTEGER, \"nie:plainTextContent\"\nTEXT COLLATE NOCASE, \"nie:plainTextContent:graph\" INTEGER,\n\"nie:legal\" TEXT COLLATE NOCASE, \"nie:legal:graph\" INTEGER,\n\"nie:generator\" TEXT COLLATE NOCASE, \"nie:generator:graph\" INTEGER,\n\"nie:description\" TEXT COLLATE NOCASE, \"nie:description:graph\"\nINTEGER, \"nie:disclaimer\" TEXT COLLATE NOCASE, \"nie:disclaimer:graph\"\nINTEGER, \"nie:depends\" INTEGER, \"nie:depends:graph\" INTEGER,\n\"nie:links\" INTEGER, \"nie:links:graph\" INTEGER, \"nie:copyright\" TEXT\nCOLLATE NOCASE, \"nie:copyright:graph\" INTEGER, \"nie:comment\" TEXT\nCOLLATE NOCASE, \"nie:comment:graph\" INTEGER, \"nie:isStoredAs\"\nINTEGER, \"nie:isStoredAs:graph\" INTEGER, \"nie:version\" TEXT COLLATE\nNOCASE, \"nie:version:graph\" INTEGER, \"nie:contentCreated\" INTEGER,\n\"nie:contentCreated:graph\" INTEGER, \"nie:contentCreated:localDate\"\nINTEGER, \"nie:contentCreated:localTime\" INTEGER, \"nie:contentAccessed\"\nINTEGER, \"nie:contentAccessed:graph\" INTEGER,\n\"nie:contentAccessed:localDate\" INTEGER,\n\"nie:contentAccessed:localTime\" INTEGER, \"nie:license\" TEXT COLLATE\nNOCASE, \"nie:license:graph\" INTEGER, \"nie:identifier\" TEXT COLLATE\nNOCASE, \"nie:identifier:graph\" INTEGER, \"nie:licenseType\" TEXT\nCOLLATE NOCASE, \"nie:licenseType:graph\" INTEGER, \"nie:characterSet\"\nTEXT COLLATE NOCASE, \"nie:characterSet:graph\" INTEGER,\n\"nie:contentSize\" INTEGER, \"nie:contentSize:graph\" INTEGER,\n\"nie:rootElementOf\" INTEGER, \"nie:rootElementOf:graph\" INTEGER,\n\"nie:usageCounter\" INTEGER, \"nie:usageCounter:graph\" INTEGER,\n\"nco:publisher\" INTEGER, \"nco:publisher:graph\" INTEGER,\n\"nfo:isContentEncrypted\" INTEGER, \"nfo:isContentEncrypted:graph\"\nINTEGER, \"slo:location\" INTEGER, \"slo:location:graph\" INTEGER,\n\"nfo:isBootable\" INTEGER, \"nfo:isBootable:graph\" INTEGER, \"osinfo:id\"\nTEXT COLLATE NOCASE, \"osinfo:id:graph\" INTEGER, \"osinfo:mediaId\" TEXT\nCOLLATE NOCASE, \"osinfo:mediaId:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_mlo:location\" (ID INTEGER NOT\nNULL, \"mlo:location\" INTEGER NOT NULL, \"mlo:location:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nao:hasProperty\" (ID INTEGER NOT\nNULL, \"nao:hasProperty\" INTEGER NOT NULL, \"nao:hasProperty:graph\"\nINTEGER);\nCREATE TABLE \"nie:InformationElement_nco:contributor\" (ID INTEGER NOT\nNULL, \"nco:contributor\" INTEGER NOT NULL, \"nco:contributor:graph\"\nINTEGER);\nCREATE TABLE \"nie:InformationElement_nco:creator\" (ID INTEGER NOT\nNULL, \"nco:creator\" INTEGER NOT NULL, \"nco:creator:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nie:hasLogicalPart\" (ID INTEGER\nNOT NULL, \"nie:hasLogicalPart\" INTEGER NOT NULL,\n\"nie:hasLogicalPart:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nie:hasPart\" (ID INTEGER NOT\nNULL, \"nie:hasPart\" INTEGER NOT NULL, \"nie:hasPart:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nie:informationElementDate\" (ID\nINTEGER NOT NULL, \"nie:informationElementDate\" INTEGER NOT NULL,\n\"nie:informationElementDate:graph\" INTEGER,\n\"nie:informationElementDate:localDate\" INTEGER NOT NULL,\n\"nie:informationElementDate:localTime\" INTEGER NOT NULL);\nCREATE TABLE \"nie:InformationElement_nie:isLogicalPartOf\" (ID INTEGER\nNOT NULL, \"nie:isLogicalPartOf\" INTEGER NOT NULL,\n\"nie:isLogicalPartOf:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nie:keyword\" (ID INTEGER NOT\nNULL, \"nie:keyword\" TEXT NOT NULL, \"nie:keyword:graph\" INTEGER);\nCREATE TABLE \"nie:InformationElement_nie:relatedTo\" (ID INTEGER NOT\nNULL, \"nie:relatedTo\" INTEGER NOT NULL, \"nie:relatedTo:graph\"\nINTEGER);\nCREATE TABLE \"nmm:AnalogRadio\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:modulation\" INTEGER, \"nmm:modulation:graph\" INTEGER,\n\"nmm:frequency\" INTEGER, \"nmm:frequency:graph\" INTEGER);\nCREATE TABLE \"nmm:Artist\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:artistName\" TEXT COLLATE NOCASE, \"nmm:artistName:graph\"\nINTEGER);\nCREATE TABLE \"nmm:DigitalRadio\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:streamingBitrate\" INTEGER, \"nmm:streamingBitrate:graph\" INTEGER,\n\"nmm:encoding\" TEXT COLLATE NOCASE, \"nmm:encoding:graph\" INTEGER,\n\"nmm:protocol\" TEXT COLLATE NOCASE, \"nmm:protocol:graph\" INTEGER);\nCREATE TABLE \"nmm:Flash\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmm:ImageList\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmm:MeteringMode\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmm:MusicAlbum\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nie:title\" TEXT COLLATE NOCASE, \"nie:title:graph\" INTEGER,\n\"nmm:albumTrackCount\" INTEGER, \"nmm:albumTrackCount:graph\" INTEGER,\n\"nmm:albumTitle\" TEXT COLLATE NOCASE, \"nmm:albumTitle:graph\" INTEGER,\n\"nmm:albumDuration\" INTEGER, \"nmm:albumDuration:graph\" INTEGER,\n\"nmm:albumGain\" INTEGER, \"nmm:albumGain:graph\" INTEGER,\n\"nmm:albumPeakGain\" INTEGER, \"nmm:albumPeakGain:graph\" INTEGER);\nCREATE TABLE \"nmm:MusicAlbumDisc\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:albumDiscAlbum\" INTEGER, \"nmm:albumDiscAlbum:graph\" INTEGER,\n\"nmm:musicCDIdentifier\" TEXT COLLATE NOCASE,\n\"nmm:musicCDIdentifier:graph\" INTEGER, \"nmm:setNumber\" INTEGER,\n\"nmm:setNumber:graph\" INTEGER);\nCREATE TABLE \"nmm:MusicAlbum_nmm:albumArtist\" (ID INTEGER NOT NULL,\n\"nmm:albumArtist\" INTEGER NOT NULL, \"nmm:albumArtist:graph\" INTEGER);\nCREATE TABLE \"nmm:MusicPiece\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nie:title\" TEXT COLLATE NOCASE, \"nie:title:graph\" INTEGER,\n\"nmm:musicAlbum\" INTEGER, \"nmm:musicAlbum:graph\" INTEGER,\n\"nmm:musicAlbumDisc\" INTEGER, \"nmm:musicAlbumDisc:graph\" INTEGER,\n\"nmm:beatsPerMinute\" INTEGER, \"nmm:beatsPerMinute:graph\" INTEGER,\n\"nmm:performer\" INTEGER, \"nmm:performer:graph\" INTEGER, \"nmm:composer\"\nINTEGER, \"nmm:composer:graph\" INTEGER, \"nmm:lyricist\" INTEGER,\n\"nmm:lyricist:graph\" INTEGER, \"nmm:trackNumber\" INTEGER,\n\"nmm:trackNumber:graph\" INTEGER,\n\"nmm:internationalStandardRecordingCode\" TEXT COLLATE NOCASE,\n\"nmm:internationalStandardRecordingCode:graph\" INTEGER);\nCREATE TABLE \"nmm:MusicPiece_nmm:lyrics\" (ID INTEGER NOT NULL,\n\"nmm:lyrics\" INTEGER NOT NULL, \"nmm:lyrics:graph\" INTEGER);\nCREATE TABLE \"nmm:Photo\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:exposureTime\" REAL, \"nmm:exposureTime:graph\" INTEGER, \"nmm:flash\"\nINTEGER, \"nmm:flash:graph\" INTEGER, \"nmm:fnumber\" REAL,\n\"nmm:fnumber:graph\" INTEGER, \"nmm:focalLength\" REAL,\n\"nmm:focalLength:graph\" INTEGER, \"nmm:isoSpeed\" REAL,\n\"nmm:isoSpeed:graph\" INTEGER, \"nmm:meteringMode\" INTEGER,\n\"nmm:meteringMode:graph\" INTEGER, \"nmm:whiteBalance\" INTEGER,\n\"nmm:whiteBalance:graph\" INTEGER, \"nmm:isCropped\" INTEGER,\n\"nmm:isCropped:graph\" INTEGER, \"nmm:isColorCorrected\" INTEGER,\n\"nmm:isColorCorrected:graph\" INTEGER);\nCREATE TABLE \"nmm:Playlist\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmm:RadioModulation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmm:RadioStation\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:radioIcon\" INTEGER, \"nmm:radioIcon:graph\" INTEGER, \"nmm:radioPTY\"\nINTEGER, \"nmm:radioPTY:graph\" INTEGER);\nCREATE TABLE \"nmm:RadioStation_nmm:carrier\" (ID INTEGER NOT NULL,\n\"nmm:carrier\" INTEGER NOT NULL, \"nmm:carrier:graph\" INTEGER);\nCREATE TABLE \"nmm:SynchronizedText\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:isForHearingImpaired\" INTEGER, \"nmm:isForHearingImpaired:graph\"\nINTEGER);\nCREATE TABLE \"nmm:Video\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmm:videoAlbum\" INTEGER, \"nmm:videoAlbum:graph\" INTEGER,\n\"nmm:isSeries\" INTEGER, \"nmm:isSeries:graph\" INTEGER, \"nmm:season\"\nINTEGER, \"nmm:season:graph\" INTEGER, \"nmm:episodeNumber\" INTEGER,\n\"nmm:episodeNumber:graph\" INTEGER, \"nmm:runTime\" INTEGER,\n\"nmm:runTime:graph\" INTEGER, \"nmm:synopsis\" TEXT COLLATE NOCASE,\n\"nmm:synopsis:graph\" INTEGER, \"nmm:MPAARating\" TEXT COLLATE NOCASE,\n\"nmm:MPAARating:graph\" INTEGER, \"nmm:category\" TEXT COLLATE NOCASE,\n\"nmm:category:graph\" INTEGER, \"nmm:producedBy\" INTEGER,\n\"nmm:producedBy:graph\" INTEGER, \"nmm:hasSubtitle\" INTEGER,\n\"nmm:hasSubtitle:graph\" INTEGER, \"nmm:isContentEncrypted\" INTEGER,\n\"nmm:isContentEncrypted:graph\" INTEGER, \"mtp:fourCC\" TEXT COLLATE\nNOCASE, \"mtp:fourCC:graph\" INTEGER, \"mtp:waveformat\" TEXT COLLATE\nNOCASE, \"mtp:waveformat:graph\" INTEGER);\nCREATE TABLE \"nmm:Video_mtp:scantype\" (ID INTEGER NOT NULL,\n\"mtp:scantype\" INTEGER NOT NULL, \"mtp:scantype:graph\" INTEGER);\nCREATE TABLE \"nmm:Video_nmm:director\" (ID INTEGER NOT NULL,\n\"nmm:director\" INTEGER NOT NULL, \"nmm:director:graph\" INTEGER);\nCREATE TABLE \"nmm:Video_nmm:leadActor\" (ID INTEGER NOT NULL,\n\"nmm:leadActor\" INTEGER NOT NULL, \"nmm:leadActor:graph\" INTEGER);\nCREATE TABLE \"nmm:Video_nmm:subtitle\" (ID INTEGER NOT NULL,\n\"nmm:subtitle\" INTEGER NOT NULL, \"nmm:subtitle:graph\" INTEGER);\nCREATE TABLE \"nmm:WhiteBalance\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:Attachment\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:Call\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:sentDate\" INTEGER, \"nmo:sentDate:graph\" INTEGER,\n\"nmo:sentDate:localDate\" INTEGER, \"nmo:sentDate:localTime\" INTEGER,\n\"nmo:duration\" INTEGER, \"nmo:duration:graph\" INTEGER);\nCREATE TABLE \"nmo:CommunicationChannel\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nmo:lastMessageDate\" INTEGER, \"nmo:lastMessageDate:graph\"\nINTEGER, \"nmo:lastMessageDate:localDate\" INTEGER,\n\"nmo:lastMessageDate:localTime\" INTEGER,\n\"nmo:lastSuccessfulMessageDate\" INTEGER,\n\"nmo:lastSuccessfulMessageDate:graph\" INTEGER,\n\"nmo:lastSuccessfulMessageDate:localDate\" INTEGER,\n\"nmo:lastSuccessfulMessageDate:localTime\" INTEGER);\nCREATE TABLE \"nmo:CommunicationChannel_nmo:hasParticipant\" (ID INTEGER\nNOT NULL, \"nmo:hasParticipant\" INTEGER NOT NULL,\n\"nmo:hasParticipant:graph\" INTEGER);\nCREATE TABLE \"nmo:Conversation\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:DeliveryStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:Email\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:hasContent\" INTEGER, \"nmo:hasContent:graph\" INTEGER,\n\"nmo:isFlagged\" INTEGER, \"nmo:isFlagged:graph\" INTEGER, \"nmo:isRecent\"\nINTEGER, \"nmo:isRecent:graph\" INTEGER, \"nmo:status\" TEXT COLLATE\nNOCASE, \"nmo:status:graph\" INTEGER, \"nmo:responseType\" TEXT COLLATE\nNOCASE, \"nmo:responseType:graph\" INTEGER);\nCREATE TABLE \"nmo:Email_nmo:contentMimeType\" (ID INTEGER NOT NULL,\n\"nmo:contentMimeType\" TEXT NOT NULL, \"nmo:contentMimeType:graph\"\nINTEGER);\nCREATE TABLE \"nmo:IMMessage\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:MMSMessage\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:mmsHasContent\" INTEGER, \"nmo:mmsHasContent:graph\" INTEGER);\nCREATE TABLE \"nmo:MailAccount\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:accountName\" TEXT COLLATE NOCASE, \"nmo:accountName:graph\"\nINTEGER, \"nmo:accountDisplayName\" TEXT COLLATE NOCASE,\n\"nmo:accountDisplayName:graph\" INTEGER, \"nmo:fromAddress\" INTEGER,\n\"nmo:fromAddress:graph\" INTEGER, \"nmo:signature\" TEXT COLLATE NOCASE,\n\"nmo:signature:graph\" INTEGER);\nCREATE TABLE \"nmo:MailFolder\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:folderName\" TEXT COLLATE NOCASE, \"nmo:folderName:graph\" INTEGER,\n\"nmo:serverCount\" INTEGER, \"nmo:serverCount:graph\" INTEGER,\n\"nmo:serverUnreadCount\" INTEGER, \"nmo:serverUnreadCount:graph\"\nINTEGER);\nCREATE TABLE \"nmo:MailboxDataObject\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:Message\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:sentDate\" INTEGER, \"nmo:sentDate:graph\" INTEGER,\n\"nmo:sentDate:localDate\" INTEGER, \"nmo:sentDate:localTime\" INTEGER,\n\"nmo:from\" INTEGER, \"nmo:from:graph\" INTEGER, \"nmo:isAnswered\"\nINTEGER, \"nmo:isAnswered:graph\" INTEGER, \"nmo:isDeleted\" INTEGER,\n\"nmo:isDeleted:graph\" INTEGER, \"nmo:isDraft\" INTEGER,\n\"nmo:isDraft:graph\" INTEGER, \"nmo:isRead\" INTEGER, \"nmo:isRead:graph\"\nINTEGER, \"nmo:isSent\" INTEGER, \"nmo:isSent:graph\" INTEGER,\n\"nmo:isEmergency\" INTEGER, \"nmo:isEmergency:graph\" INTEGER,\n\"nmo:htmlMessageContent\" TEXT COLLATE NOCASE,\n\"nmo:htmlMessageContent:graph\" INTEGER, \"nmo:messageId\" TEXT COLLATE\nNOCASE, \"nmo:messageId:graph\" INTEGER, \"nmo:messageSubject\" TEXT\nCOLLATE NOCASE, \"nmo:messageSubject:graph\" INTEGER,\n\"nmo:receivedDate\" INTEGER, \"nmo:receivedDate:graph\" INTEGER,\n\"nmo:receivedDate:localDate\" INTEGER, \"nmo:receivedDate:localTime\"\nINTEGER, \"nmo:replyTo\" INTEGER, \"nmo:replyTo:graph\" INTEGER,\n\"nmo:sender\" INTEGER, \"nmo:sender:graph\" INTEGER, \"nmo:conversation\"\nINTEGER, \"nmo:conversation:graph\" INTEGER, \"nmo:communicationChannel\"\nINTEGER, \"nmo:communicationChannel:graph\" INTEGER,\n\"nmo:deliveryStatus\" INTEGER, \"nmo:deliveryStatus:graph\" INTEGER,\n\"nmo:reportDelivery\" INTEGER, \"nmo:reportDelivery:graph\" INTEGER,\n\"nmo:sentWithReportRead\" INTEGER, \"nmo:sentWithReportRead:graph\"\nINTEGER, \"nmo:reportReadStatus\" INTEGER, \"nmo:reportReadStatus:graph\"\nINTEGER, \"nmo:mustAnswerReportRead\" INTEGER,\n\"nmo:mustAnswerReportRead:graph\" INTEGER, \"nmo:mmsId\" TEXT COLLATE\nNOCASE, \"nmo:mmsId:graph\" INTEGER);\nCREATE TABLE \"nmo:MessageHeader\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:headerName\" TEXT COLLATE NOCASE, \"nmo:headerName:graph\" INTEGER,\n\"nmo:headerValue\" TEXT COLLATE NOCASE, \"nmo:headerValue:graph\"\nINTEGER);\nCREATE TABLE \"nmo:Message_nmo:bcc\" (ID INTEGER NOT NULL, \"nmo:bcc\"\nINTEGER NOT NULL, \"nmo:bcc:graph\" INTEGER);\nCREATE TABLE \"nmo:Message_nmo:cc\" (ID INTEGER NOT NULL, \"nmo:cc\"\nINTEGER NOT NULL, \"nmo:cc:graph\" INTEGER);\nCREATE TABLE \"nmo:Message_nmo:hasAttachment\" (ID INTEGER NOT NULL,\n\"nmo:hasAttachment\" INTEGER NOT NULL, \"nmo:hasAttachment:graph\"\nINTEGER);\nCREATE TABLE \"nmo:Message_nmo:inReplyTo\" (ID INTEGER NOT NULL,\n\"nmo:inReplyTo\" INTEGER NOT NULL, \"nmo:inReplyTo:graph\" INTEGER);\nCREATE TABLE \"nmo:Message_nmo:messageHeader\" (ID INTEGER NOT NULL,\n\"nmo:messageHeader\" INTEGER NOT NULL, \"nmo:messageHeader:graph\"\nINTEGER);\nCREATE TABLE \"nmo:Message_nmo:recipient\" (ID INTEGER NOT NULL,\n\"nmo:recipient\" INTEGER NOT NULL, \"nmo:recipient:graph\" INTEGER);\nCREATE TABLE \"nmo:Message_nmo:references\" (ID INTEGER NOT NULL,\n\"nmo:references\" INTEGER NOT NULL, \"nmo:references:graph\" INTEGER);\nCREATE TABLE \"nmo:Message_nmo:to\" (ID INTEGER NOT NULL, \"nmo:to\"\nINTEGER NOT NULL, \"nmo:to:graph\" INTEGER);\nCREATE TABLE \"nmo:MimePart\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:charSet\" TEXT COLLATE NOCASE, \"nmo:charSet:graph\" INTEGER,\n\"nmo:contentId\" TEXT COLLATE NOCASE, \"nmo:contentId:graph\" INTEGER,\n\"nmo:contentTransferEncoding\" TEXT COLLATE NOCASE,\n\"nmo:contentTransferEncoding:graph\" INTEGER, \"nmo:contentDescription\"\nTEXT COLLATE NOCASE, \"nmo:contentDescription:graph\" INTEGER,\n\"nmo:contentDisposition\" TEXT COLLATE NOCASE,\n\"nmo:contentDisposition:graph\" INTEGER);\nCREATE TABLE \"nmo:MimePart_nmo:mimeHeader\" (ID INTEGER NOT NULL,\n\"nmo:mimeHeader\" INTEGER NOT NULL, \"nmo:mimeHeader:graph\" INTEGER);\nCREATE TABLE \"nmo:Multipart\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:Multipart_nmo:partBoundary\" (ID INTEGER NOT NULL,\n\"nmo:partBoundary\" TEXT NOT NULL, \"nmo:partBoundary:graph\" INTEGER);\nCREATE TABLE \"nmo:PermanentChannel\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:PhoneMessage\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"nmo:fromVCard\" INTEGER, \"nmo:fromVCard:graph\" INTEGER, \"nmo:encoding\"\nTEXT COLLATE NOCASE, \"nmo:encoding:graph\" INTEGER,\n\"nmo:phoneMessageId\" INTEGER, \"nmo:phoneMessageId:graph\" INTEGER,\n\"nmo:validityPeriod\" INTEGER, \"nmo:validityPeriod:graph\" INTEGER);\nCREATE TABLE \"nmo:PhoneMessageFolder\" (ID INTEGER NOT NULL PRIMARY\nKEY, \"nmo:phoneMessageFolderId\" TEXT COLLATE NOCASE,\n\"nmo:phoneMessageFolderId:graph\" INTEGER);\nCREATE TABLE \"nmo:PhoneMessageFolder_nmo:containsPhoneMessage\" (ID\nINTEGER NOT NULL, \"nmo:containsPhoneMessage\" INTEGER NOT NULL,\n\"nmo:containsPhoneMessage:graph\" INTEGER);\nCREATE TABLE \"nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder\"\n(ID INTEGER NOT NULL, \"nmo:containsPhoneMessageFolder\" INTEGER NOT\nNULL, \"nmo:containsPhoneMessageFolder:graph\" INTEGER);\nCREATE TABLE \"nmo:PhoneMessage_nmo:toVCard\" (ID INTEGER NOT NULL,\n\"nmo:toVCard\" INTEGER NOT NULL, \"nmo:toVCard:graph\" INTEGER);\nCREATE TABLE \"nmo:ReportReadStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:SMSMessage\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:TransientChannel\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nmo:VOIPCall\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"nrl:InverseFunctionalProperty\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"osinfo:Installer\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"poi:ObjectOfInterest\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"rdf:Property\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"rdfs:domain\" INTEGER, \"rdfs:domain:graph\" INTEGER, \"rdfs:range\"\nINTEGER, \"rdfs:range:graph\" INTEGER, \"tracker:indexed\" INTEGER,\n\"tracker:indexed:graph\" INTEGER, \"tracker:secondaryIndex\" INTEGER,\n\"tracker:secondaryIndex:graph\" INTEGER, \"tracker:fulltextIndexed\"\nINTEGER, \"tracker:fulltextIndexed:graph\" INTEGER,\n\"tracker:fulltextNoLimit\" INTEGER, \"tracker:fulltextNoLimit:graph\"\nINTEGER, \"tracker:transient\" INTEGER, \"tracker:transient:graph\"\nINTEGER, \"tracker:weight\" INTEGER, \"tracker:weight:graph\" INTEGER,\n\"tracker:defaultValue\" TEXT COLLATE NOCASE,\n\"tracker:defaultValue:graph\" INTEGER, \"nrl:maxCardinality\" INTEGER,\n\"nrl:maxCardinality:graph\" INTEGER, \"tracker:writeback\" INTEGER,\n\"tracker:writeback:graph\" INTEGER, \"tracker:forceJournal\" INTEGER,\n\"tracker:forceJournal:graph\" INTEGER);\nCREATE TABLE \"rdf:Property_rdfs:subPropertyOf\" (ID INTEGER NOT NULL,\n\"rdfs:subPropertyOf\" INTEGER NOT NULL, \"rdfs:subPropertyOf:graph\"\nINTEGER);\nCREATE TABLE \"rdfs:Class\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"tracker:notify\" INTEGER, \"tracker:notify:graph\" INTEGER);\nCREATE TABLE \"rdfs:Class_rdfs:subClassOf\" (ID INTEGER NOT NULL,\n\"rdfs:subClassOf\" INTEGER NOT NULL, \"rdfs:subClassOf:graph\" INTEGER);\nCREATE TABLE \"rdfs:Class_tracker:domainIndex\" (ID INTEGER NOT NULL,\n\"tracker:domainIndex\" INTEGER NOT NULL, \"tracker:domainIndex:graph\"\nINTEGER);\nCREATE TABLE \"rdfs:Literal\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"rdfs:Resource\" (ID INTEGER NOT NULL PRIMARY KEY,\nAvailable INTEGER NOT NULL, \"rdfs:comment\" TEXT COLLATE NOCASE,\n\"rdfs:comment:graph\" INTEGER, \"rdfs:label\" TEXT COLLATE NOCASE,\n\"rdfs:label:graph\" INTEGER, \"tracker:added\" INTEGER,\n\"tracker:added:graph\" INTEGER, \"tracker:added:localDate\" INTEGER,\n\"tracker:added:localTime\" INTEGER, \"tracker:modified\" INTEGER,\n\"tracker:modified:graph\" INTEGER, \"tracker:damaged\" INTEGER,\n\"tracker:damaged:graph\" INTEGER, \"dc:title\" TEXT COLLATE NOCASE,\n\"dc:title:graph\" INTEGER, \"dc:creator\" TEXT COLLATE NOCASE,\n\"dc:creator:graph\" INTEGER, \"dc:subject\" TEXT COLLATE NOCASE,\n\"dc:subject:graph\" INTEGER, \"dc:description\" TEXT COLLATE NOCASE,\n\"dc:description:graph\" INTEGER, \"dc:publisher\" TEXT COLLATE NOCASE,\n\"dc:publisher:graph\" INTEGER, \"dc:type\" TEXT COLLATE NOCASE,\n\"dc:type:graph\" INTEGER, \"dc:format\" TEXT COLLATE NOCASE,\n\"dc:format:graph\" INTEGER, \"dc:identifier\" TEXT COLLATE NOCASE,\n\"dc:identifier:graph\" INTEGER, \"dc:language\" TEXT COLLATE NOCASE,\n\"dc:language:graph\" INTEGER, \"dc:coverage\" TEXT COLLATE NOCASE,\n\"dc:coverage:graph\" INTEGER, \"dc:rights\" TEXT COLLATE NOCASE,\n\"dc:rights:graph\" INTEGER, \"nao:identifier\" TEXT COLLATE NOCASE,\n\"nao:identifier:graph\" INTEGER, \"nao:numericRating\" REAL,\n\"nao:numericRating:graph\" INTEGER, \"nao:lastModified\" INTEGER,\n\"nao:lastModified:graph\" INTEGER, \"nao:lastModified:localDate\"\nINTEGER, \"nao:lastModified:localTime\" INTEGER);\nCREATE TABLE \"rdfs:Resource_dc:contributor\" (ID INTEGER NOT NULL,\n\"dc:contributor\" TEXT NOT NULL, \"dc:contributor:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_dc:date\" (ID INTEGER NOT NULL, \"dc:date\"\nINTEGER NOT NULL, \"dc:date:graph\" INTEGER, \"dc:date:localDate\" INTEGER\nNOT NULL, \"dc:date:localTime\" INTEGER NOT NULL);\nCREATE TABLE \"rdfs:Resource_dc:relation\" (ID INTEGER NOT NULL,\n\"dc:relation\" TEXT NOT NULL, \"dc:relation:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_dc:source\" (ID INTEGER NOT NULL,\n\"dc:source\" INTEGER NOT NULL, \"dc:source:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_nao:deprecated\" (ID INTEGER NOT NULL,\n\"nao:deprecated\" INTEGER NOT NULL, \"nao:deprecated:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_nao:hasTag\" (ID INTEGER NOT NULL,\n\"nao:hasTag\" INTEGER NOT NULL, \"nao:hasTag:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_nao:isRelated\" (ID INTEGER NOT NULL,\n\"nao:isRelated\" INTEGER NOT NULL, \"nao:isRelated:graph\" INTEGER);\nCREATE TABLE \"rdfs:Resource_rdf:type\" (ID INTEGER NOT NULL, \"rdf:type\"\nINTEGER NOT NULL, \"rdf:type:graph\" INTEGER);\nCREATE TABLE \"scal:AccessLevel\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:AttendanceStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:Attendee\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:attendanceStatus\" INTEGER, \"scal:attendanceStatus:graph\"\nINTEGER, \"scal:attendeeRole\" INTEGER, \"scal:attendeeRole:graph\"\nINTEGER, \"scal:attendeeContact\" INTEGER, \"scal:attendeeContact:graph\"\nINTEGER, \"scal:rsvp\" INTEGER, \"scal:rsvp:graph\" INTEGER,\n\"scal:calendarUserType\" INTEGER, \"scal:calendarUserType:graph\"\nINTEGER);\nCREATE TABLE \"scal:AttendeeRole\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:Attendee_scal:delegated-from\" (ID INTEGER NOT NULL,\n\"scal:delegated-from\" INTEGER NOT NULL, \"scal:delegated-from:graph\"\nINTEGER);\nCREATE TABLE \"scal:Attendee_scal:delegated-to\" (ID INTEGER NOT NULL,\n\"scal:delegated-to\" INTEGER NOT NULL, \"scal:delegated-to:graph\"\nINTEGER);\nCREATE TABLE \"scal:Attendee_scal:member\" (ID INTEGER NOT NULL,\n\"scal:member\" INTEGER NOT NULL, \"scal:member:graph\" INTEGER);\nCREATE TABLE \"scal:Attendee_scal:sent-by\" (ID INTEGER NOT NULL,\n\"scal:sent-by\" INTEGER NOT NULL, \"scal:sent-by:graph\" INTEGER);\nCREATE TABLE \"scal:Calendar\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:CalendarAlarm\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:alarmOffset\" INTEGER, \"scal:alarmOffset:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarAlarm_scal:alarmAttendee\" (ID INTEGER NOT\nNULL, \"scal:alarmAttendee\" INTEGER NOT NULL,\n\"scal:alarmAttendee:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:textLocation\" INTEGER, \"scal:textLocation:graph\" INTEGER,\n\"scal:resources\" TEXT COLLATE NOCASE, \"scal:resources:graph\" INTEGER,\n\"scal:transparency\" INTEGER, \"scal:transparency:graph\" INTEGER,\n\"scal:calendarItemAlarm\" INTEGER, \"scal:calendarItemAlarm:graph\"\nINTEGER, \"scal:start\" INTEGER, \"scal:start:graph\" INTEGER, \"scal:end\"\nINTEGER, \"scal:end:graph\" INTEGER, \"scal:isAllDay\" INTEGER,\n\"scal:isAllDay:graph\" INTEGER, \"scal:priority\" INTEGER,\n\"scal:priority:graph\" INTEGER, \"scal:rdate\" INTEGER,\n\"scal:rdate:graph\" INTEGER, \"scal:exceptionRDate\" INTEGER,\n\"scal:exceptionRDate:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:access\" (ID INTEGER NOT NULL,\n\"scal:access\" INTEGER NOT NULL, \"scal:access:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:attachment\" (ID INTEGER NOT NULL,\n\"scal:attachment\" INTEGER NOT NULL, \"scal:attachment:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:attendee\" (ID INTEGER NOT NULL,\n\"scal:attendee\" INTEGER NOT NULL, \"scal:attendee:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:belongsToCalendar\" (ID INTEGER\nNOT NULL, \"scal:belongsToCalendar\" INTEGER NOT NULL,\n\"scal:belongsToCalendar:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:contact\" (ID INTEGER NOT NULL,\n\"scal:contact\" INTEGER NOT NULL, \"scal:contact:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarItem_scal:rrule\" (ID INTEGER NOT NULL,\n\"scal:rrule\" INTEGER NOT NULL, \"scal:rrule:graph\" INTEGER);\nCREATE TABLE \"scal:CalendarUserType\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:Event\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:eventStatus\" INTEGER, \"scal:eventStatus:graph\" INTEGER);\nCREATE TABLE \"scal:EventStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:Journal\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:journalStatus\" INTEGER, \"scal:journalStatus:graph\" INTEGER);\nCREATE TABLE \"scal:JournalStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:RSVPValues\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:RecurrenceRule\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:recurrencePattern\" TEXT COLLATE NOCASE,\n\"scal:recurrencePattern:graph\" INTEGER, \"scal:recurrenceStartDate\"\nINTEGER, \"scal:recurrenceStartDate:graph\" INTEGER, \"scal:exception\"\nINTEGER, \"scal:exception:graph\" INTEGER);\nCREATE TABLE \"scal:TimePoint\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:dateTime\" INTEGER, \"scal:dateTime:graph\" INTEGER,\n\"scal:dateTime:localDate\" INTEGER, \"scal:dateTime:localTime\" INTEGER,\n\"scal:TimeZone\" TEXT COLLATE NOCASE, \"scal:TimeZone:graph\" INTEGER);\nCREATE TABLE \"scal:Todo\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"scal:todoStatus\" INTEGER, \"scal:todoStatus:graph\" INTEGER, \"scal:due\"\nINTEGER, \"scal:due:graph\" INTEGER, \"scal:completed\" INTEGER,\n\"scal:completed:graph\" INTEGER, \"scal:percentComplete\" INTEGER,\n\"scal:percentComplete:graph\" INTEGER);\nCREATE TABLE \"scal:TodoStatus\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"scal:TransparencyValues\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"slo:GeoLocation\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"slo:latitude\" REAL, \"slo:latitude:graph\" INTEGER, \"slo:longitude\"\nREAL, \"slo:longitude:graph\" INTEGER, \"slo:verticalAccuracy\" REAL,\n\"slo:verticalAccuracy:graph\" INTEGER, \"slo:horizontalAccuracy\" REAL,\n\"slo:horizontalAccuracy:graph\" INTEGER, \"slo:altitude\" REAL,\n\"slo:altitude:graph\" INTEGER, \"slo:boundingLatitudeMin\" REAL,\n\"slo:boundingLatitudeMin:graph\" INTEGER, \"slo:boundingLatitudeMax\"\nREAL, \"slo:boundingLatitudeMax:graph\" INTEGER,\n\"slo:boundingLongitudeMin\" REAL, \"slo:boundingLongitudeMin:graph\"\nINTEGER, \"slo:boundingLongitudeMax\" REAL,\n\"slo:boundingLongitudeMax:graph\" INTEGER, \"slo:radius\" REAL,\n\"slo:radius:graph\" INTEGER, \"slo:timestamp\" INTEGER,\n\"slo:timestamp:graph\" INTEGER, \"slo:timestamp:localDate\" INTEGER,\n\"slo:timestamp:localTime\" INTEGER, \"slo:postalAddress\" INTEGER,\n\"slo:postalAddress:graph\" INTEGER);\nCREATE TABLE \"slo:Landmark\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"slo:iconUrl\" INTEGER, \"slo:iconUrl:graph\" INTEGER);\nCREATE TABLE \"slo:LandmarkCategory\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"slo:isRemovable\" INTEGER, \"slo:isRemovable:graph\" INTEGER,\n\"slo:categoryIconUrl\" INTEGER, \"slo:categoryIconUrl:graph\" INTEGER);\nCREATE TABLE \"slo:Landmark_slo:belongsToCategory\" (ID INTEGER NOT\nNULL, \"slo:belongsToCategory\" INTEGER NOT NULL,\n\"slo:belongsToCategory:graph\" INTEGER);\nCREATE TABLE \"slo:Landmark_slo:hasContact\" (ID INTEGER NOT NULL,\n\"slo:hasContact\" INTEGER NOT NULL, \"slo:hasContact:graph\" INTEGER);\nCREATE TABLE \"slo:Route\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"slo:startTime\" INTEGER, \"slo:startTime:graph\" INTEGER,\n\"slo:startTime:localDate\" INTEGER, \"slo:startTime:localTime\" INTEGER,\n\"slo:endTime\" INTEGER, \"slo:endTime:graph\" INTEGER,\n\"slo:endTime:localDate\" INTEGER, \"slo:endTime:localTime\" INTEGER);\nCREATE TABLE \"slo:Route_slo:routeDetails\" (ID INTEGER NOT NULL,\n\"slo:routeDetails\" TEXT NOT NULL, \"slo:routeDetails:graph\" INTEGER);\nCREATE TABLE \"tracker:Namespace\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"tracker:prefix\" TEXT COLLATE NOCASE, \"tracker:prefix:graph\"\nINTEGER);\nCREATE TABLE \"tracker:Ontology\" (ID INTEGER NOT NULL PRIMARY KEY);\nCREATE TABLE \"tracker:Volume\" (ID INTEGER NOT NULL PRIMARY KEY,\n\"tracker:isMounted\" INTEGER, \"tracker:isMounted:graph\" INTEGER,\n\"tracker:unmountDate\" INTEGER, \"tracker:unmountDate:graph\" INTEGER,\n\"tracker:unmountDate:localDate\" INTEGER,\n\"tracker:unmountDate:localTime\" INTEGER, \"tracker:mountPoint\" INTEGER,\n\"tracker:mountPoint:graph\" INTEGER, \"tracker:isRemovable\" INTEGER,\n\"tracker:isRemovable:graph\" INTEGER, \"tracker:isOptical\" INTEGER,\n\"tracker:isOptical:graph\" INTEGER);\nCREATE UNIQUE INDEX \"mfo:FeedMessage_mfo:enclosureList_ID_ID\" ON\n\"mfo:FeedMessage_mfo:enclosureList\" (ID, \"mfo:enclosureList\");\nCREATE UNIQUE INDEX \"mlo:GeoBoundingBox_mlo:bbNorthWest_ID_ID\" ON\n\"mlo:GeoBoundingBox_mlo:bbNorthWest\" (ID, \"mlo:bbNorthWest\");\nCREATE UNIQUE INDEX \"mlo:GeoBoundingBox_mlo:bbSouthEast_ID_ID\" ON\n\"mlo:GeoBoundingBox_mlo:bbSouthEast\" (ID, \"mlo:bbSouthEast\");\nCREATE INDEX \"mlo:GeoLocation_mlo:asBoundingBox_ID\" ON\n\"mlo:GeoLocation_mlo:asBoundingBox\" (ID);\nCREATE UNIQUE INDEX \"mlo:GeoLocation_mlo:asBoundingBox_ID_ID\" ON\n\"mlo:GeoLocation_mlo:asBoundingBox\" (\"mlo:asBoundingBox\", ID);\nCREATE INDEX \"mlo:GeoLocation_mlo:asGeoPoint_ID\" ON\n\"mlo:GeoLocation_mlo:asGeoPoint\" (ID);\nCREATE UNIQUE INDEX \"mlo:GeoLocation_mlo:asGeoPoint_ID_ID\" ON\n\"mlo:GeoLocation_mlo:asGeoPoint\" (\"mlo:asGeoPoint\", ID);\nCREATE INDEX \"mlo:GeoLocation_mlo:asPostalAddress_ID\" ON\n\"mlo:GeoLocation_mlo:asPostalAddress\" (ID);\nCREATE UNIQUE INDEX \"mlo:GeoLocation_mlo:asPostalAddress_ID_ID\" ON\n\"mlo:GeoLocation_mlo:asPostalAddress\" (\"mlo:asPostalAddress\", ID);\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:address_ID_ID\" ON\n\"mlo:GeoPoint_mlo:address\" (ID, \"mlo:address\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:altitude_ID_ID\" ON\n\"mlo:GeoPoint_mlo:altitude\" (ID, \"mlo:altitude\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:city_ID_ID\" ON\n\"mlo:GeoPoint_mlo:city\" (ID, \"mlo:city\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:country_ID_ID\" ON\n\"mlo:GeoPoint_mlo:country\" (ID, \"mlo:country\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:latitude_ID_ID\" ON\n\"mlo:GeoPoint_mlo:latitude\" (ID, \"mlo:latitude\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:longitude_ID_ID\" ON\n\"mlo:GeoPoint_mlo:longitude\" (ID, \"mlo:longitude\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:state_ID_ID\" ON\n\"mlo:GeoPoint_mlo:state\" (ID, \"mlo:state\");\nCREATE UNIQUE INDEX \"mlo:GeoPoint_mlo:timestamp_ID_ID\" ON\n\"mlo:GeoPoint_mlo:timestamp\" (ID, \"mlo:timestamp\");\nCREATE UNIQUE INDEX \"mlo:GeoSphere_mlo:radius_ID_ID\" ON\n\"mlo:GeoSphere_mlo:radius\" (ID, \"mlo:radius\");\nCREATE UNIQUE INDEX \"mlo:LandmarkCategory_mlo:isRemovable_ID_ID\" ON\n\"mlo:LandmarkCategory_mlo:isRemovable\" (ID, \"mlo:isRemovable\");\nCREATE UNIQUE INDEX \"mlo:Landmark_mlo:belongsToCategory_ID_ID\" ON\n\"mlo:Landmark_mlo:belongsToCategory\" (ID, \"mlo:belongsToCategory\");\nCREATE UNIQUE INDEX \"mlo:Landmark_mlo:poiLocation_ID_ID\" ON\n\"mlo:Landmark_mlo:poiLocation\" (ID, \"mlo:poiLocation\");\nCREATE UNIQUE INDEX \"mlo:LocationBoundingBox_mlo:boxEastLimit_ID_ID\"\nON \"mlo:LocationBoundingBox_mlo:boxEastLimit\" (ID,\n\"mlo:boxEastLimit\");\nCREATE UNIQUE INDEX \"mlo:LocationBoundingBox_mlo:boxNorthLimit_ID_ID\"\nON \"mlo:LocationBoundingBox_mlo:boxNorthLimit\" (ID,\n\"mlo:boxNorthLimit\");\nCREATE UNIQUE INDEX\n\"mlo:LocationBoundingBox_mlo:boxSouthWestCorner_ID_ID\" ON\n\"mlo:LocationBoundingBox_mlo:boxSouthWestCorner\" (ID,\n\"mlo:boxSouthWestCorner\");\nCREATE UNIQUE INDEX\n\"mlo:LocationBoundingBox_mlo:boxVerticalLimit_ID_ID\" ON\n\"mlo:LocationBoundingBox_mlo:boxVerticalLimit\" (ID,\n\"mlo:boxVerticalLimit\");\nCREATE UNIQUE INDEX \"mlo:Route_mlo:endTime_ID_ID\" ON\n\"mlo:Route_mlo:endTime\" (ID, \"mlo:endTime\");\nCREATE UNIQUE INDEX \"mlo:Route_mlo:routeDetails_ID_ID\" ON\n\"mlo:Route_mlo:routeDetails\" (ID, \"mlo:routeDetails\");\nCREATE UNIQUE INDEX \"mlo:Route_mlo:startTime_ID_ID\" ON\n\"mlo:Route_mlo:startTime\" (ID, \"mlo:startTime\");\nCREATE UNIQUE INDEX \"mto:Transfer_mto:transferList_ID_ID\" ON\n\"mto:Transfer_mto:transferList\" (ID, \"mto:transferList\");\nCREATE UNIQUE INDEX \"mto:Transfer_mto:transferPrivacyLevel_ID_ID\" ON\n\"mto:Transfer_mto:transferPrivacyLevel\" (ID,\n\"mto:transferPrivacyLevel\");\nCREATE UNIQUE INDEX \"mto:UploadTransfer_mto:transferCategory_ID_ID\" ON\n\"mto:UploadTransfer_mto:transferCategory\" (ID,\n\"mto:transferCategory\");\nCREATE UNIQUE INDEX \"nao:Tag_tracker:isDefaultTag_ID_ID\" ON\n\"nao:Tag_tracker:isDefaultTag\" (ID, \"tracker:isDefaultTag\");\nCREATE UNIQUE INDEX \"nao:Tag_tracker:tagRelatedTo_ID_ID\" ON\n\"nao:Tag_tracker:tagRelatedTo\" (ID, \"tracker:tagRelatedTo\");\nCREATE UNIQUE INDEX \"ncal:Alarm_ncal:action_ID_ID\" ON\n\"ncal:Alarm_ncal:action\" (ID, \"ncal:action\");\nCREATE UNIQUE INDEX \"ncal:BydayRulePart_ncal:bydayModifier_ID_ID\" ON\n\"ncal:BydayRulePart_ncal:bydayModifier\" (ID, \"ncal:bydayModifier\");\nCREATE UNIQUE INDEX \"ncal:BydayRulePart_ncal:bydayWeekday_ID_ID\" ON\n\"ncal:BydayRulePart_ncal:bydayWeekday\" (ID, \"ncal:bydayWeekday\");\nCREATE UNIQUE INDEX \"ncal:Calendar_ncal:component_ID_ID\" ON\n\"ncal:Calendar_ncal:component\" (ID, \"ncal:component\");\nCREATE UNIQUE INDEX \"ncal:Freebusy_ncal:freebusy_ID_ID\" ON\n\"ncal:Freebusy_ncal:freebusy\" (ID, \"ncal:freebusy\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:byday_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:byday\" (ID, \"ncal:byday\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:byhour_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:byhour\" (ID, \"ncal:byhour\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:byminute_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:byminute\" (ID, \"ncal:byminute\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:bymonth_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:bymonth\" (ID, \"ncal:bymonth\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:bymonthday_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:bymonthday\" (ID, \"ncal:bymonthday\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:bysecond_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:bysecond\" (ID, \"ncal:bysecond\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:bysetpos_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:bysetpos\" (ID, \"ncal:bysetpos\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:byweekno_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:byweekno\" (ID, \"ncal:byweekno\");\nCREATE UNIQUE INDEX \"ncal:RecurrenceRule_ncal:byyearday_ID_ID\" ON\n\"ncal:RecurrenceRule_ncal:byyearday\" (ID, \"ncal:byyearday\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:attach_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:attach\" (ID, \"ncal:attach\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:attendee_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:attendee\" (ID, \"ncal:attendee\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:categories_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:categories\" (ID, \"ncal:categories\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:exdate_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:exdate\" (ID, \"ncal:exdate\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:exrule_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:exrule\" (ID, \"ncal:exrule\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:hasAlarm_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:hasAlarm\" (ID, \"ncal:hasAlarm\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:ncalRelation_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:ncalRelation\" (ID, \"ncal:ncalRelation\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:rdate_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:rdate\" (ID, \"ncal:rdate\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:relatedToChild_ID_ID\"\nON \"ncal:UnionParentClass_ncal:relatedToChild\" (ID,\n\"ncal:relatedToChild\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:relatedToParent_ID_ID\"\nON \"ncal:UnionParentClass_ncal:relatedToParent\" (ID,\n\"ncal:relatedToParent\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:resources_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:resources\" (ID, \"ncal:resources\");\nCREATE UNIQUE INDEX \"ncal:UnionParentClass_ncal:rrule_ID_ID\" ON\n\"ncal:UnionParentClass_ncal:rrule\" (ID, \"ncal:rrule\");\nCREATE UNIQUE INDEX \"nco:Affiliation_nco:title_ID_ID\" ON\n\"nco:Affiliation_nco:title\" (ID, \"nco:title\");\nCREATE UNIQUE INDEX \"nco:ContactList_nco:containsContact_ID_ID\" ON\n\"nco:ContactList_nco:containsContact\" (ID, \"nco:containsContact\");\nCREATE UNIQUE INDEX \"nco:Contact_ncal:anniversary_ID_ID\" ON\n\"nco:Contact_ncal:anniversary\" (ID, \"ncal:anniversary\");\nCREATE UNIQUE INDEX \"nco:Contact_ncal:birthday_ID_ID\" ON\n\"nco:Contact_ncal:birthday\" (ID, \"ncal:birthday\");\nCREATE UNIQUE INDEX \"nco:Contact_nco:belongsToGroup_ID_ID\" ON\n\"nco:Contact_nco:belongsToGroup\" (ID, \"nco:belongsToGroup\");\nCREATE UNIQUE INDEX \"nco:Contact_nco:note_ID_ID\" ON\n\"nco:Contact_nco:note\" (ID, \"nco:note\");\nCREATE UNIQUE INDEX \"nco:Contact_scal:anniversary_ID_ID\" ON\n\"nco:Contact_scal:anniversary\" (ID, \"scal:anniversary\");\nCREATE UNIQUE INDEX \"nco:Contact_scal:birthday_ID_ID\" ON\n\"nco:Contact_scal:birthday\" (ID, \"scal:birthday\");\nCREATE UNIQUE INDEX \"nco:IMAccount_nco:hasIMContact_ID_ID\" ON\n\"nco:IMAccount_nco:hasIMContact\" (ID, \"nco:hasIMContact\");\nCREATE UNIQUE INDEX \"nco:IMAddress_nco:imCapability_ID_ID\" ON\n\"nco:IMAddress_nco:imCapability\" (ID, \"nco:imCapability\");\nCREATE UNIQUE INDEX \"nco:PersonContact_nco:hasAffiliation_ID_ID\" ON\n\"nco:PersonContact_nco:hasAffiliation\" (ID, \"nco:hasAffiliation\");\nCREATE INDEX \"nco:PersonContact_nco:nameFamily\" ON \"nco:PersonContact\"\n(\"nco:nameFamily\");\nCREATE INDEX \"nco:PhoneNumber_nco:phoneNumber\" ON \"nco:PhoneNumber\"\n(\"nco:phoneNumber\");\nCREATE UNIQUE INDEX \"nco:Role_nco:blogUrl_ID_ID\" ON\n\"nco:Role_nco:blogUrl\" (ID, \"nco:blogUrl\");\nCREATE UNIQUE INDEX \"nco:Role_nco:foafUrl_ID_ID\" ON\n\"nco:Role_nco:foafUrl\" (ID, \"nco:foafUrl\");\nCREATE UNIQUE INDEX \"nco:Role_nco:hasContactMedium_ID_ID\" ON\n\"nco:Role_nco:hasContactMedium\" (ID, \"nco:hasContactMedium\");\nCREATE INDEX \"nco:Role_nco:hasEmailAddress_ID\" ON\n\"nco:Role_nco:hasEmailAddress\" (ID);\nCREATE UNIQUE INDEX \"nco:Role_nco:hasEmailAddress_ID_ID\" ON\n\"nco:Role_nco:hasEmailAddress\" (\"nco:hasEmailAddress\", ID);\nCREATE UNIQUE INDEX \"nco:Role_nco:hasIMAddress_ID_ID\" ON\n\"nco:Role_nco:hasIMAddress\" (ID, \"nco:hasIMAddress\");\nCREATE UNIQUE INDEX \"nco:Role_nco:hasPhoneNumber_ID_ID\" ON\n\"nco:Role_nco:hasPhoneNumber\" (ID, \"nco:hasPhoneNumber\");\nCREATE INDEX \"nco:Role_nco:hasPostalAddress_ID\" ON\n\"nco:Role_nco:hasPostalAddress\" (ID);\nCREATE UNIQUE INDEX \"nco:Role_nco:hasPostalAddress_ID_ID\" ON\n\"nco:Role_nco:hasPostalAddress\" (\"nco:hasPostalAddress\", ID);\nCREATE UNIQUE INDEX \"nco:Role_nco:url_ID_ID\" ON \"nco:Role_nco:url\"\n(ID, \"nco:url\");\nCREATE UNIQUE INDEX \"nco:Role_nco:websiteUrl_ID_ID\" ON\n\"nco:Role_nco:websiteUrl\" (ID, \"nco:websiteUrl\");\nCREATE UNIQUE INDEX\n\"nfo:BookmarkFolder_nfo:containsBookmarkFolder_ID_ID\" ON\n\"nfo:BookmarkFolder_nfo:containsBookmarkFolder\" (ID,\n\"nfo:containsBookmarkFolder\");\nCREATE UNIQUE INDEX \"nfo:BookmarkFolder_nfo:containsBookmark_ID_ID\" ON\n\"nfo:BookmarkFolder_nfo:containsBookmark\" (ID,\n\"nfo:containsBookmark\");\nCREATE INDEX \"nfo:FileDataObject_nfo:fileLastModified\" ON\n\"nfo:FileDataObject\" (\"nfo:fileLastModified\");\nCREATE UNIQUE INDEX \"nfo:Image_nfo:depicts_ID_ID\" ON\n\"nfo:Image_nfo:depicts\" (ID, \"nfo:depicts\");\nCREATE UNIQUE INDEX \"nfo:Image_nfo:hasRegionOfInterest_ID_ID\" ON\n\"nfo:Image_nfo:hasRegionOfInterest\" (ID, \"nfo:hasRegionOfInterest\");\nCREATE UNIQUE INDEX \"nfo:MediaList_nfo:hasMediaFileListEntry_ID_ID\" ON\n\"nfo:MediaList_nfo:hasMediaFileListEntry\" (ID,\n\"nfo:hasMediaFileListEntry\");\nCREATE UNIQUE INDEX \"nfo:MediaList_nfo:mediaListEntry_ID_ID\" ON\n\"nfo:MediaList_nfo:mediaListEntry\" (ID, \"nfo:mediaListEntry\");\nCREATE UNIQUE INDEX \"nfo:Media_mtp:hidden_ID_ID\" ON\n\"nfo:Media_mtp:hidden\" (ID, \"mtp:hidden\");\nCREATE UNIQUE INDEX \"nfo:Media_nmm:alternativeMedia_ID_ID\" ON\n\"nfo:Media_nmm:alternativeMedia\" (ID, \"nmm:alternativeMedia\");\nCREATE INDEX \"nfo:Visual_nie:contentCreated\" ON \"nfo:Visual\"\n(\"nie:contentCreated\");\nCREATE UNIQUE INDEX \"nid3:ID3Audio_nid3:leadArtist_ID_ID\" ON\n\"nid3:ID3Audio_nid3:leadArtist\" (ID, \"nid3:leadArtist\");\nCREATE UNIQUE INDEX \"nie:DataObject_nie:dataSource_ID_ID\" ON\n\"nie:DataObject_nie:dataSource\" (ID, \"nie:dataSource\");\nCREATE UNIQUE INDEX \"nie:DataObject_nie:isPartOf_ID_ID\" ON\n\"nie:DataObject_nie:isPartOf\" (ID, \"nie:isPartOf\");\nCREATE INDEX \"nie:DataObject_nie:url\" ON \"nie:DataObject\" (\"nie:url\");\nCREATE INDEX \"nie:InformationElement_mlo:location_ID\" ON\n\"nie:InformationElement_mlo:location\" (ID);\nCREATE UNIQUE INDEX \"nie:InformationElement_mlo:location_ID_ID\" ON\n\"nie:InformationElement_mlo:location\" (\"mlo:location\", ID);\nCREATE UNIQUE INDEX \"nie:InformationElement_nao:hasProperty_ID_ID\" ON\n\"nie:InformationElement_nao:hasProperty\" (ID, \"nao:hasProperty\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nco:contributor_ID_ID\" ON\n\"nie:InformationElement_nco:contributor\" (ID, \"nco:contributor\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nco:creator_ID_ID\" ON\n\"nie:InformationElement_nco:creator\" (ID, \"nco:creator\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nie:hasLogicalPart_ID_ID\"\nON \"nie:InformationElement_nie:hasLogicalPart\" (ID,\n\"nie:hasLogicalPart\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nie:hasPart_ID_ID\" ON\n\"nie:InformationElement_nie:hasPart\" (ID, \"nie:hasPart\");\nCREATE UNIQUE INDEX\n\"nie:InformationElement_nie:informationElementDate_ID_ID\" ON\n\"nie:InformationElement_nie:informationElementDate\" (ID,\n\"nie:informationElementDate\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nie:isLogicalPartOf_ID_ID\"\nON \"nie:InformationElement_nie:isLogicalPartOf\" (ID,\n\"nie:isLogicalPartOf\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nie:keyword_ID_ID\" ON\n\"nie:InformationElement_nie:keyword\" (ID, \"nie:keyword\");\nCREATE UNIQUE INDEX \"nie:InformationElement_nie:relatedTo_ID_ID\" ON\n\"nie:InformationElement_nie:relatedTo\" (ID, \"nie:relatedTo\");\nCREATE INDEX \"nie:InformationElement_slo:location\" ON\n\"nie:InformationElement\" (\"slo:location\");\nCREATE INDEX \"nmm:Artist_nmm:artistName\" ON \"nmm:Artist\" (\"nmm:artistName\");\nCREATE INDEX \"nmm:MusicAlbum_nie:title\" ON \"nmm:MusicAlbum\" (\"nie:title\");\nCREATE UNIQUE INDEX \"nmm:MusicAlbum_nmm:albumArtist_ID_ID\" ON\n\"nmm:MusicAlbum_nmm:albumArtist\" (ID, \"nmm:albumArtist\");\nCREATE INDEX \"nmm:MusicPiece_nie:title\" ON \"nmm:MusicPiece\" (\"nie:title\");\nCREATE UNIQUE INDEX \"nmm:MusicPiece_nmm:lyrics_ID_ID\" ON\n\"nmm:MusicPiece_nmm:lyrics\" (ID, \"nmm:lyrics\");\nCREATE INDEX \"nmm:MusicPiece_nmm:musicAlbum\" ON \"nmm:MusicPiece\"\n(\"nmm:musicAlbum\");\nCREATE INDEX \"nmm:MusicPiece_nmm:performer\" ON \"nmm:MusicPiece\"\n(\"nmm:performer\");\nCREATE UNIQUE INDEX \"nmm:RadioStation_nmm:carrier_ID_ID\" ON\n\"nmm:RadioStation_nmm:carrier\" (ID, \"nmm:carrier\");\nCREATE UNIQUE INDEX \"nmm:Video_mtp:scantype_ID_ID\" ON\n\"nmm:Video_mtp:scantype\" (ID, \"mtp:scantype\");\nCREATE UNIQUE INDEX \"nmm:Video_nmm:director_ID_ID\" ON\n\"nmm:Video_nmm:director\" (ID, \"nmm:director\");\nCREATE UNIQUE INDEX \"nmm:Video_nmm:leadActor_ID_ID\" ON\n\"nmm:Video_nmm:leadActor\" (ID, \"nmm:leadActor\");\nCREATE UNIQUE INDEX \"nmm:Video_nmm:subtitle_ID_ID\" ON\n\"nmm:Video_nmm:subtitle\" (ID, \"nmm:subtitle\");\nCREATE INDEX \"nmo:Call_nmo:sentDate\" ON \"nmo:Call\" (\"nmo:sentDate\");\nCREATE INDEX \"nmo:CommunicationChannel_nmo:hasParticipant_ID\" ON\n\"nmo:CommunicationChannel_nmo:hasParticipant\" (ID);\nCREATE UNIQUE INDEX\n\"nmo:CommunicationChannel_nmo:hasParticipant_ID_ID\" ON\n\"nmo:CommunicationChannel_nmo:hasParticipant\" (\"nmo:hasParticipant\",\nID);\nCREATE INDEX \"nmo:CommunicationChannel_nmo:lastMessageDate\" ON\n\"nmo:CommunicationChannel\" (\"nmo:lastMessageDate\");\nCREATE UNIQUE INDEX \"nmo:Email_nmo:contentMimeType_ID_ID\" ON\n\"nmo:Email_nmo:contentMimeType\" (ID, \"nmo:contentMimeType\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:bcc_ID_ID\" ON\n\"nmo:Message_nmo:bcc\" (ID, \"nmo:bcc\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:cc_ID_ID\" ON \"nmo:Message_nmo:cc\"\n(ID, \"nmo:cc\");\nCREATE INDEX \"nmo:Message_nmo:communicationChannel\" ON \"nmo:Message\"\n(\"nmo:communicationChannel\", \"nmo:receivedDate\");\nCREATE INDEX \"nmo:Message_nmo:conversation\" ON \"nmo:Message\"\n(\"nmo:conversation\");\nCREATE INDEX \"nmo:Message_nmo:from\" ON \"nmo:Message\" (\"nmo:from\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:hasAttachment_ID_ID\" ON\n\"nmo:Message_nmo:hasAttachment\" (ID, \"nmo:hasAttachment\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:inReplyTo_ID_ID\" ON\n\"nmo:Message_nmo:inReplyTo\" (ID, \"nmo:inReplyTo\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:messageHeader_ID_ID\" ON\n\"nmo:Message_nmo:messageHeader\" (ID, \"nmo:messageHeader\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:recipient_ID_ID\" ON\n\"nmo:Message_nmo:recipient\" (ID, \"nmo:recipient\");\nCREATE UNIQUE INDEX \"nmo:Message_nmo:references_ID_ID\" ON\n\"nmo:Message_nmo:references\" (ID, \"nmo:references\");\nCREATE INDEX \"nmo:Message_nmo:sender\" ON \"nmo:Message\" (\"nmo:sender\");\nCREATE INDEX \"nmo:Message_nmo:sentDate\" ON \"nmo:Message\" (\"nmo:sentDate\");\nCREATE INDEX \"nmo:Message_nmo:to_ID\" ON \"nmo:Message_nmo:to\" (ID);\nCREATE UNIQUE INDEX \"nmo:Message_nmo:to_ID_ID\" ON \"nmo:Message_nmo:to\"\n(\"nmo:to\", ID);\nCREATE UNIQUE INDEX \"nmo:MimePart_nmo:mimeHeader_ID_ID\" ON\n\"nmo:MimePart_nmo:mimeHeader\" (ID, \"nmo:mimeHeader\");\nCREATE UNIQUE INDEX \"nmo:Multipart_nmo:partBoundary_ID_ID\" ON\n\"nmo:Multipart_nmo:partBoundary\" (ID, \"nmo:partBoundary\");\nCREATE UNIQUE INDEX\n\"nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder_ID_ID\" ON\n\"nmo:PhoneMessageFolder_nmo:containsPhoneMessageFolder\" (ID,\n\"nmo:containsPhoneMessageFolder\");\nCREATE UNIQUE INDEX\n\"nmo:PhoneMessageFolder_nmo:containsPhoneMessage_ID_ID\" ON\n\"nmo:PhoneMessageFolder_nmo:containsPhoneMessage\" (ID,\n\"nmo:containsPhoneMessage\");\nCREATE UNIQUE INDEX \"nmo:PhoneMessage_nmo:toVCard_ID_ID\" ON\n\"nmo:PhoneMessage_nmo:toVCard\" (ID, \"nmo:toVCard\");\nCREATE UNIQUE INDEX \"rdf:Property_rdfs:subPropertyOf_ID_ID\" ON\n\"rdf:Property_rdfs:subPropertyOf\" (ID, \"rdfs:subPropertyOf\");\nCREATE UNIQUE INDEX \"rdfs:Class_rdfs:subClassOf_ID_ID\" ON\n\"rdfs:Class_rdfs:subClassOf\" (ID, \"rdfs:subClassOf\");\nCREATE UNIQUE INDEX \"rdfs:Class_tracker:domainIndex_ID_ID\" ON\n\"rdfs:Class_tracker:domainIndex\" (ID, \"tracker:domainIndex\");\nCREATE UNIQUE INDEX \"rdfs:Resource_dc:contributor_ID_ID\" ON\n\"rdfs:Resource_dc:contributor\" (ID, \"dc:contributor\");\nCREATE UNIQUE INDEX \"rdfs:Resource_dc:date_ID_ID\" ON\n\"rdfs:Resource_dc:date\" (ID, \"dc:date\");\nCREATE UNIQUE INDEX \"rdfs:Resource_dc:relation_ID_ID\" ON\n\"rdfs:Resource_dc:relation\" (ID, \"dc:relation\");\nCREATE UNIQUE INDEX \"rdfs:Resource_dc:source_ID_ID\" ON\n\"rdfs:Resource_dc:source\" (ID, \"dc:source\");\nCREATE UNIQUE INDEX \"rdfs:Resource_nao:deprecated_ID_ID\" ON\n\"rdfs:Resource_nao:deprecated\" (ID, \"nao:deprecated\");\nCREATE INDEX \"rdfs:Resource_nao:hasTag_ID\" ON \"rdfs:Resource_nao:hasTag\" (ID);\nCREATE UNIQUE INDEX \"rdfs:Resource_nao:hasTag_ID_ID\" ON\n\"rdfs:Resource_nao:hasTag\" (\"nao:hasTag\", ID);\nCREATE UNIQUE INDEX \"rdfs:Resource_nao:isRelated_ID_ID\" ON\n\"rdfs:Resource_nao:isRelated\" (ID, \"nao:isRelated\");\nCREATE UNIQUE INDEX \"rdfs:Resource_rdf:type_ID_ID\" ON\n\"rdfs:Resource_rdf:type\" (ID, \"rdf:type\");\nCREATE INDEX \"rdfs:Resource_tracker:added\" ON \"rdfs:Resource\" (\"tracker:added\");\nCREATE UNIQUE INDEX \"scal:Attendee_scal:delegated-from_ID_ID\" ON\n\"scal:Attendee_scal:delegated-from\" (ID, \"scal:delegated-from\");\nCREATE UNIQUE INDEX \"scal:Attendee_scal:delegated-to_ID_ID\" ON\n\"scal:Attendee_scal:delegated-to\" (ID, \"scal:delegated-to\");\nCREATE UNIQUE INDEX \"scal:Attendee_scal:member_ID_ID\" ON\n\"scal:Attendee_scal:member\" (ID, \"scal:member\");\nCREATE UNIQUE INDEX \"scal:Attendee_scal:sent-by_ID_ID\" ON\n\"scal:Attendee_scal:sent-by\" (ID, \"scal:sent-by\");\nCREATE UNIQUE INDEX \"scal:CalendarAlarm_scal:alarmAttendee_ID_ID\" ON\n\"scal:CalendarAlarm_scal:alarmAttendee\" (ID, \"scal:alarmAttendee\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:access_ID_ID\" ON\n\"scal:CalendarItem_scal:access\" (ID, \"scal:access\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:attachment_ID_ID\" ON\n\"scal:CalendarItem_scal:attachment\" (ID, \"scal:attachment\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:attendee_ID_ID\" ON\n\"scal:CalendarItem_scal:attendee\" (ID, \"scal:attendee\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:belongsToCalendar_ID_ID\"\nON \"scal:CalendarItem_scal:belongsToCalendar\" (ID,\n\"scal:belongsToCalendar\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:contact_ID_ID\" ON\n\"scal:CalendarItem_scal:contact\" (ID, \"scal:contact\");\nCREATE UNIQUE INDEX \"scal:CalendarItem_scal:rrule_ID_ID\" ON\n\"scal:CalendarItem_scal:rrule\" (ID, \"scal:rrule\");\nCREATE INDEX \"slo:GeoLocation_slo:postalAddress\" ON \"slo:GeoLocation\"\n(\"slo:postalAddress\");\nCREATE UNIQUE INDEX \"slo:Landmark_slo:belongsToCategory_ID_ID\" ON\n\"slo:Landmark_slo:belongsToCategory\" (ID, \"slo:belongsToCategory\");\nCREATE UNIQUE INDEX \"slo:Landmark_slo:hasContact_ID_ID\" ON\n\"slo:Landmark_slo:hasContact\" (ID, \"slo:hasContact\");\nCREATE UNIQUE INDEX \"slo:Route_slo:routeDetails_ID_ID\" ON\n\"slo:Route_slo:routeDetails\" (ID, \"slo:routeDetails\");\n\nEXPLAIN SELECT \"1_u\", (SELECT \"nco:fullname\" FROM \"nco:Contact\" WHERE\nID = \"1_u\") COLLATE NOCASE, (SELECT \"nco:nameFamily\" FROM\n\"nco:PersonContact\" WHERE ID = \"1_u\") COLLATE NOCASE, (SELECT\n\"nco:nameGiven\" FROM \"nco:PersonContact\" WHERE ID = \"1_u\")\nCOLLATE NOCASE, (SELECT \"nco:nameAdditional\" FROM\n\"nco:PersonContact\" WHERE ID = \"1_u\") COLLATE NOCASE, (SELECT\n\"nco:nameHonorificPrefix\" FROM \"nco:PersonContact\" WHERE ID =\n\"1_u\") COLLATE NOCASE, (SELECT \"nco:nameHonorificSuffix\" FROM\n\"nco:PersonContact\" WHERE ID = \"1_u\") COLLATE NOCASE, (SELECT\n\"nco:nickname\" FROM \"nco:Contact\" WHERE ID = \"1_u\") COLLATE\nNOCASE, strftime(\"%s\",(SELECT \"nco:birthDate\" FROM\n\"nco:Contact\" WHERE ID = \"1_u\")), (SELECT \"nie:url\" FROM\n\"nie:DataObject\" WHERE ID = (SELECT \"nco:photo\" FROM\n\"nco:Contact\" WHERE ID = \"1_u\")) COLLATE NOCASE, (SELECT\nGROUP_CONCAT(\"2_u\"||? COLLATE NOCASE||COALESCE((SELECT\n\"nco:imProtocol\" FROM \"nco:IMAddress\" WHERE ID = \"3_u\") COLLATE\nNOCASE, ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT\n\"nco:imID\" FROM \"nco:IMAddress\" WHERE ID = \"3_u\") COLLATE\nNOCASE, ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT\n\"nco:imNickname\" FROM \"nco:IMAddress\" WHERE ID = \"3_u\") COLLATE\nNOCASE, ? COLLATE NOCASE), '\\n') FROM (SELECT\n\"nco:PersonContact_nco:hasAffiliation2\".\"nco:hasAffiliation\" AS\n\"2_u\", \"nco:Role_nco:hasIMAddress3\".\"nco:hasIMAddress\" AS\n\"3_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation2\",\n\"nco:Role_nco:hasIMAddress\" AS \"nco:Role_nco:hasIMAddress3\" WHERE\n\"1_u\" = \"nco:PersonContact_nco:hasAffiliation2\".\"ID\" AND\n\"nco:PersonContact_nco:hasAffiliation2\".\"nco:hasAffiliation\" =\n\"nco:Role_nco:hasIMAddress3\".\"ID\")), (SELECT\nGROUP_CONCAT(\"2_u\"||? COLLATE NOCASE||(SELECT \"nco:phoneNumber\"\nFROM \"nco:PhoneNumber\" WHERE ID = \"4_u\") COLLATE NOCASE, '\\n')\nFROM (SELECT \"nco:PersonContact_nco:hasAffiliation4\".\"nco:hasAffiliation\"\nAS \"2_u\", \"nco:Role_nco:hasPhoneNumber5\".\"nco:hasPhoneNumber\" AS\n\"4_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation4\",\n\"nco:Role_nco:hasPhoneNumber\" AS \"nco:Role_nco:hasPhoneNumber5\"\nWHERE \"1_u\" = \"nco:PersonContact_nco:hasAffiliation4\".\"ID\" AND\n\"nco:PersonContact_nco:hasAffiliation4\".\"nco:hasAffiliation\" =\n\"nco:Role_nco:hasPhoneNumber5\".\"ID\")), (SELECT\nGROUP_CONCAT(\"2_u\"||? COLLATE NOCASE||(SELECT \"nco:emailAddress\"\nFROM \"nco:EmailAddress\" WHERE ID = \"5_u\") COLLATE NOCASE, ',')\nFROM (SELECT \"nco:PersonContact_nco:hasAffiliation6\".\"nco:hasAffiliation\"\nAS \"2_u\", \"nco:Role_nco:hasEmailAddress7\".\"nco:hasEmailAddress\"\nAS \"5_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation6\",\n\"nco:Role_nco:hasEmailAddress\" AS \"nco:Role_nco:hasEmailAddress7\"\nWHERE \"1_u\" = \"nco:PersonContact_nco:hasAffiliation6\".\"ID\" AND\n\"nco:PersonContact_nco:hasAffiliation6\".\"nco:hasAffiliation\" =\n\"nco:Role_nco:hasEmailAddress7\".\"ID\")), (SELECT\nGROUP_CONCAT(\"2_u\"||? COLLATE NOCASE||COALESCE((SELECT\nGROUP_CONCAT((SELECT Uri FROM Resource WHERE ID =\n\"nco:blogUrl\"),',') FROM \"nco:Role_nco:blogUrl\" WHERE ID =\n\"2_u\"), ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT\nGROUP_CONCAT((SELECT Uri FROM Resource WHERE ID =\n\"nco:websiteUrl\"),',') FROM \"nco:Role_nco:websiteUrl\" WHERE ID =\n\"2_u\"), ? COLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT\nGROUP_CONCAT((SELECT Uri FROM Resource WHERE ID = \"nco:url\"),',')\nFROM \"nco:Role_nco:url\" WHERE ID = \"2_u\"), ? COLLATE NOCASE),\n'\\n') FROM (SELECT\n\"nco:PersonContact_nco:hasAffiliation8\".\"nco:hasAffiliation\" AS\n\"2_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation8\" WHERE \"1_u\" =\n\"nco:PersonContact_nco:hasAffiliation8\".\"ID\")), (SELECT\nGROUP_CONCAT(\"6_u\", ',') FROM (SELECT\n\"rdfs:Resource_nao:hasTag9\".\"nao:hasTag\" AS \"6_u\" FROM\n\"rdfs:Resource_nao:hasTag\" AS \"rdfs:Resource_nao:hasTag9\" WHERE\n\"1_u\" = \"rdfs:Resource_nao:hasTag9\".\"ID\")), (SELECT Uri FROM\nResource WHERE ID = \"1_u\"), (SELECT GROUP_CONCAT(\"2_u\"||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:role\" FROM \"nco:Affiliation\" WHERE\nID = \"2_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:department\" FROM \"nco:Affiliation\"\nWHERE ID = \"2_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT GROUP_CONCAT(\"nco:title\",',') FROM\n\"nco:Affiliation_nco:title\" WHERE ID = \"2_u\"), ? COLLATE NOCASE),\n'\\n') FROM (SELECT\n\"nco:PersonContact_nco:hasAffiliation10\".\"nco:hasAffiliation\" AS\n\"2_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation10\" WHERE \"1_u\" =\n\"nco:PersonContact_nco:hasAffiliation10\".\"ID\")), (SELECT\nGROUP_CONCAT(\"nco:note\",',') FROM \"nco:Contact_nco:note\" WHERE ID\n= \"1_u\"), (SELECT \"nco:gender\" FROM \"nco:PersonContact\" WHERE ID\n= \"1_u\"), (SELECT GROUP_CONCAT(\"2_u\"||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:pobox\" FROM \"nco:PostalAddress\"\nWHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:district\" FROM \"nco:PostalAddress\"\nWHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:county\" FROM \"nco:PostalAddress\"\nWHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:locality\" FROM \"nco:PostalAddress\"\nWHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE NOCASE)||? COLLATE\nNOCASE||COALESCE((SELECT \"nco:postalcode\" FROM\n\"nco:PostalAddress\" WHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE\nNOCASE)||? COLLATE NOCASE||COALESCE((SELECT \"nco:streetAddress\"\nFROM \"nco:PostalAddress\" WHERE ID = \"7_u\") COLLATE NOCASE, ?\nCOLLATE NOCASE)||? COLLATE NOCASE||COALESCE((SELECT Uri FROM\nResource WHERE ID = (SELECT \"nco:addressLocation\" FROM\n\"nco:PostalAddress\" WHERE ID = \"7_u\")), ? COLLATE NOCASE)||?\nCOLLATE NOCASE||COALESCE((SELECT \"nco:extendedAddress\" FROM\n\"nco:PostalAddress\" WHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE\nNOCASE)||? COLLATE NOCASE||COALESCE((SELECT \"nco:country\" FROM\n\"nco:PostalAddress\" WHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE\nNOCASE)||? COLLATE NOCASE||COALESCE((SELECT \"nco:region\" FROM\n\"nco:PostalAddress\" WHERE ID = \"7_u\") COLLATE NOCASE, ? COLLATE\nNOCASE), '\\n') FROM (SELECT\n\"nco:PersonContact_nco:hasAffiliation11\".\"nco:hasAffiliation\" AS\n\"2_u\", \"nco:Role_nco:hasPostalAddress12\".\"nco:hasPostalAddress\"\nAS \"7_u\" FROM \"nco:PersonContact_nco:hasAffiliation\" AS\n\"nco:PersonContact_nco:hasAffiliation11\",\n\"nco:Role_nco:hasPostalAddress\" AS\n\"nco:Role_nco:hasPostalAddress12\" WHERE \"1_u\" =\n\"nco:PersonContact_nco:hasAffiliation11\".\"ID\" AND\n\"nco:PersonContact_nco:hasAffiliation11\".\"nco:hasAffiliation\" =\n\"nco:Role_nco:hasPostalAddress12\".\"ID\")), (SELECT\nGROUP_CONCAT(\"10_u\" COLLATE NOCASE, ',') FROM (SELECT\n\"nie:InformationElement_nao:hasProperty13\".\"nao:hasProperty\" AS\n\"8_u\", \"nao:Property14\".\"nao:propertyName\" AS \"9_u\",\n\"nao:Property14\".\"nao:propertyValue\" AS \"10_u\" FROM\n\"nie:InformationElement_nao:hasProperty\" AS\n\"nie:InformationElement_nao:hasProperty13\", \"nao:Property\" AS\n\"nao:Property14\" WHERE \"1_u\" =\n\"nie:InformationElement_nao:hasProperty13\".\"ID\" AND\n\"nie:InformationElement_nao:hasProperty13\".\"nao:hasProperty\" =\n\"nao:Property14\".\"ID\" AND \"9_u\" IS NOT NULL AND \"10_u\" IS NOT\nNULL AND (\"9_u\" COLLATE NOCASE = ? COLLATE NOCASE))) FROM (SELECT\n\"nco:PersonContact1\".\"ID\" AS \"1_u\" FROM \"nco:PersonContact\" AS\n\"nco:PersonContact1\") ORDER BY \"1_u\";\n  }\n} {/.* Goto .*/}\n\n# Crash reported by OSS-FUZZ on 2016-11-10\ndo_catchsql_test fuzz-oss1-detach {\n  DETACH x IS #1;\n} {1 {near \"#1\": syntax error}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz.test",
    "content": "# 2007 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is generating semi-random strings of SQL\n# (a.k.a. \"fuzz\") and sending it into the parser to try to \n# generate errors.\n#\n# The tests in this file are really about testing fuzzily generated\n# SQL parse-trees. The majority of the fuzzily generated SQL is \n# valid as far as the parser is concerned. \n#\n# The most complicated trees are for SELECT statements.\n#\n# $Id: fuzz.test,v 1.19 2009/04/28 11:10:39 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::REPEATS 5000\n\n# If running quick.test, don't do so many iterations.\nif {[info exists ::G(isquick)]} {\n  if {$::G(isquick)} { set ::REPEATS 20 }\n}\n\nsource $testdir/fuzz_common.tcl\nexpr srand(0)\n\n#----------------------------------------------------------------\n# These tests caused errors that were first caught by the tests\n# in this file. They are still here.\ndo_test fuzz-1.1 {\n  execsql {\n    SELECT 'abc' LIKE X'ABCD';\n  }\n} {0}\ndo_test fuzz-1.2 {\n  execsql {\n    SELECT 'abc' LIKE zeroblob(10);\n  }\n} {0}\ndo_test fuzz-1.3 {\n  execsql {\n    SELECT zeroblob(10) LIKE 'abc';\n  }\n} {0}\ndo_test fuzz-1.4 {\n  execsql {\n    SELECT (- -21) % NOT (456 LIKE zeroblob(10));\n  }\n} {0}\ndo_test fuzz-1.5 {\n  execsql {\n    SELECT (SELECT (\n        SELECT (SELECT -2147483648) FROM (SELECT 1) ORDER BY 1\n    ))\n  }\n} {-2147483648}\ndo_test fuzz-1.6 {\n  execsql {\n    SELECT 'abc', zeroblob(1) FROM (SELECT 1) ORDER BY 1\n  }\n} [execsql {SELECT 'abc', zeroblob(1)}]\n\ndo_test fuzz-1.7 {\n  execsql {\n    SELECT ( SELECT zeroblob(1000) FROM ( \n      SELECT * FROM (SELECT 'first') ORDER BY NOT 'in') \n    )\n  }\n} [execsql {SELECT zeroblob(1000)}]\n\ndo_test fuzz-1.8 {\n  # Problems with opcode OP_ToText (did not account for MEM_Zero).\n  # Also MemExpandBlob() was marking expanded blobs as nul-terminated.\n  # They are not.\n  execsql {\n    SELECT CAST(zeroblob(1000) AS text);\n  }\n} {{}}\n\ndo_test fuzz-1.9 {\n  # This was causing a NULL pointer dereference of Expr.pList.\n  execsql {\n    SELECT 1 FROM (SELECT * FROM sqlite_master WHERE random())\n  }\n} {}\n\ndo_test fuzz-1.10 {\n  # Bug in calculation of Parse.ckOffset causing an assert() \n  # to fail. Probably harmless.\n  execsql {\n    SELECT coalesce(1, substr( 1, 2, length('in' IN (SELECT 1))))\n  }\n} {1}\n\ndo_test fuzz-1.11 {\n  # The literals (A, B, C, D) are not important, they are just used\n  # to make the EXPLAIN output easier to read.\n  #\n  # The problem here is that the EXISTS(...) expression leaves an\n  # extra value on the VDBE stack. This is confusing the parent and\n  # leads to an assert() failure when OP_Insert encounters an integer\n  # when it expects a record blob.\n  #\n  # Update: Any query with (LIMIT 0) was leaking stack.\n  #\n  execsql {\n    SELECT 'A' FROM (SELECT 'B') ORDER BY EXISTS (\n      SELECT 'C' FROM (SELECT 'D' LIMIT 0)\n    )\n  }\n} {A}\n\ndo_test fuzz-1.12.1 {\n  # Create a table with a single row.\n  execsql {\n    CREATE TABLE abc(b);\n    INSERT INTO abc VALUES('ABCDE');\n  }\n\n  # The following query was crashing. The later subquery (in the FROM)\n  # clause was flattened into the parent, but the code was not repairng\n  # the \"b\" reference in the other sub-query. When the query was executed,\n  # that \"b\" refered to a non-existant vdbe table-cursor.\n  #\n  execsql {\n    SELECT 1 IN ( SELECT b UNION SELECT 1 ) FROM (SELECT b FROM abc);\n  }\n} {1}\ndo_test fuzz-1.12.2 {\n  # Clean up after the previous query.\n  execsql {\n    DROP TABLE abc;\n  }\n} {}\n\n\ndo_test fuzz-1.13 {\n  # The problem here was that when there were more expressions in\n  # the ORDER BY list than the result-set list. The temporary b-tree\n  # used for sorting was being misconfigured in this case.\n  #\n  execsql {\n    SELECT 'abcd' UNION SELECT 'efgh' ORDER BY 1 ASC, 1 ASC;\n  }\n} {abcd efgh}\n\ndo_test fuzz-1.14.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(123, 456, 789);\n  }\n \n  # The [a] reference in the sub-select was causing a problem. Because\n  # the internal walkSelectExpr() function was not considering compound\n  # SELECT operators.\n  execsql {\n    SELECT 1 FROM abc\n    GROUP BY c HAVING EXISTS (SELECT a UNION SELECT 123);\n  }\n} {1}\ndo_test fuzz-1.14.2 {\n  execsql {\n    DROP TABLE abc;\n  }\n} {}\n\n# Making sure previously discovered errors have been fixed.\n#\ndo_test fuzz-1.15 {\n  execsql {\n    SELECT hex(CAST(zeroblob(1000) AS integer))\n  }\n} {30}\n\ndo_test fuzz-1.16.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE def(a, b, c);\n    CREATE TABLE ghi(a, b, c);\n  }\n} {}\ndo_test fuzz-1.16.2 {\n  catchsql {\n    SELECT DISTINCT EXISTS(\n       SELECT 1\n       FROM (\n         SELECT C FROM (SELECT 1)\n       )\n       WHERE (SELECT c)\n    )\n    FROM abc\n  }\n} {0 {}}\ndo_test fuzz-1.16.3 {\n  catchsql {\n    SELECT DISTINCT substr(-456 ISNULL,zeroblob(1000), EXISTS(\n         SELECT DISTINCT EXISTS(\n           SELECT DISTINCT b FROM abc\n           ORDER BY EXISTS (\n             SELECT DISTINCT 2147483647 UNION ALL SELECT -2147483648\n           ) ASC\n         )\n         FROM (\n           SELECT c, c FROM (\n             SELECT 456, 'injection' ORDER BY 56.1 ASC, -56.1 DESC\n           )\n         )\n         GROUP BY (SELECT ALL (SELECT DISTINCT 'hardware')) \n         HAVING (\n           SELECT DISTINCT c\n           FROM (\n             SELECT ALL -2147483648, 'experiments'\n             ORDER BY -56.1 ASC, -56.1 DESC\n           )\n           GROUP BY (SELECT DISTINCT 456) IN \n                   (SELECT DISTINCT 'injection') NOT IN (SELECT ALL -456)\n           HAVING EXISTS (\n             SELECT ALL 'injection'\n           )\n         )\n         UNION ALL\n         SELECT a IN (\n           SELECT -2147483647\n           UNION ALL\n           SELECT ALL 'injection'\n         )\n         FROM sqlite_master\n       ) -- end EXISTS\n    ) /* end SUBSTR() */, c NOTNULL ISNULL\n    FROM abc\n    ORDER BY CAST(-56.1 AS blob) ASC\n  }\n} {0 {}}\ndo_test fuzz-1.16.4 {\n  execsql {\n    DROP TABLE abc; DROP TABLE def; DROP TABLE ghi;\n  }\n} {}\n\ndo_test fuzz-1.17 {\n  catchsql {\n    SELECT 'hardware', 56.1 NOTNULL, random()&0\n    FROM (\n       SELECT ALL lower(~ EXISTS (\n           SELECT 1 NOT IN (SELECT ALL 1)\n       )), CAST(456 AS integer), -2147483647\n       FROM (\n         SELECT DISTINCT -456, CAST(1 AS integer) ISNULL\n         FROM (SELECT ALL 2147483647, typeof(2147483649))\n       )\n    )\n    GROUP BY CAST(CAST('experiments' AS blob) AS blob)\n    HAVING random()\n  }\n} {0 {hardware 1 0}}\n\ndo_test fuzz-1.18 {\n  catchsql {\n     SELECT -2147483649 << upper('fault' NOT IN (\n        SELECT ALL (\n           SELECT ALL -1\n           ORDER BY -2147483649\n           LIMIT (\n              SELECT ALL (\n                 SELECT 0 EXCEPT SELECT DISTINCT 'experiments' ORDER BY 1 ASC\n              )\n           )\n           OFFSET EXISTS (\n              SELECT ALL \n                  (SELECT ALL -2147483648) NOT IN (\n                     SELECT ALL 123456789.1234567899\n                  ) IN (SELECT 2147483649) \n              FROM sqlite_master\n           ) NOT IN (SELECT ALL 'The')\n        )\n     ))\n  }\n} {0 {{}}}\n\n# At one point the following INSERT statement caused an assert() to fail.\n# \ndo_test fuzz-1.19 {\n  execsql { CREATE TABLE t1(a) }\n  catchsql {\n    INSERT INTO t1 VALUES( \n      CASE WHEN NULL THEN NULL ELSE ( SELECT 0 ORDER BY 456 ) END \n    )\n  }\n} {1 {1st ORDER BY term out of range - should be between 1 and 1}}\ndo_test fuzz-1.20 {\n  execsql { DROP TABLE t1 }\n} {}\n\n#----------------------------------------------------------------\n# Test some fuzzily generated expressions.\n#\ndo_fuzzy_test fuzz-2 -template  { SELECT [Expr] }\n\ndo_test fuzz-3.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE def(a, b, c);\n    CREATE TABLE ghi(a, b, c);\n  }\n} {}\nset ::TableList  [list abc def ghi]\n\n#----------------------------------------------------------------\n# Test some fuzzily generated SELECT statements.\n#\ndo_fuzzy_test fuzz-3.2 -template  {[Select]}\n\n#----------------------------------------------------------------\n# Insert a small amount of data into the database and then run \n# some more generated SELECT statements.\n#\ndo_test fuzz-4.1 {\n  execsql {\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(4, 5, 6);\n    INSERT INTO abc VALUES(7, 8, 9);\n    INSERT INTO def VALUES(1, 2, 3);\n    INSERT INTO def VALUES(4, 5, 6);\n    INSERT INTO def VALUES(7, 8, 9);\n    INSERT INTO ghi VALUES(1, 2, 3);\n    INSERT INTO ghi VALUES(4, 5, 6);\n    INSERT INTO ghi VALUES(7, 8, 9);\n    CREATE INDEX abc_i ON abc(a, b, c);\n    CREATE INDEX def_i ON def(c, a, b);\n    CREATE INDEX ghi_i ON ghi(b, c, a);\n  }\n} {}\ndo_fuzzy_test fuzz-4.2 -template {[Select]}\n\n#----------------------------------------------------------------\n# Test some fuzzy INSERT statements:\n#\ndo_test         fuzz-5.1 {execsql BEGIN} {}\ndo_fuzzy_test   fuzz-5.2 -template  {[Insert]} -errorlist table\nintegrity_check fuzz-5.2.integrity\ndo_test         fuzz-5.3 {execsql COMMIT} {}\nintegrity_check fuzz-5.4.integrity\n\n#----------------------------------------------------------------\n# Now that there is data in the database, run some more SELECT \n# statements\n#\nset ::ColumnList [list a b c]\nset E {{no such col} {ambiguous column name}}\ndo_fuzzy_test fuzz-6.1 -template {[Select]} -errorlist $E\n\n#----------------------------------------------------------------\n# Run some SELECTs, INSERTs, UPDATEs and DELETEs in a transaction.\n#\nset E {{no such col} {ambiguous column name} {table}}\ndo_test         fuzz-7.1 {execsql BEGIN} {}\ndo_fuzzy_test   fuzz-7.2 -template {[Statement]} -errorlist $E\nintegrity_check fuzz-7.3.integrity\ndo_test         fuzz-7.4 {execsql COMMIT} {}\nintegrity_check fuzz-7.5.integrity\n\n#----------------------------------------------------------------\n# Many CREATE and DROP TABLE statements:\n#\nset E [list table duplicate {no such col} {ambiguous column name} {use DROP}]\ndo_fuzzy_test fuzz-8.1 -template {[CreateOrDropTableOrView]} -errorlist $E\n\nclose $::log\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz2.test",
    "content": "# 2007 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# This file checks error recovery from malformed SQL strings.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\nproc fuzzcatch {sql} {\n  return [lindex [catchsql $sql] 0]\n}\n\ndo_test fuzz2-1.1 {\n  fuzzcatch {SELECT ALL \"AAAAAA\" . * GROUP BY LIMIT round(1), #12}\n} {1}\ndo_test fuzz2-2.0 {\n  fuzzcatch {SELECT + #100}\n} {1}\ndo_test fuzz2-2.1 {\n  fuzzcatch {SELECT 1 WHERE ( #61 NOT MATCH ROUND( 1 ) )}\n} {1}\ndo_test fuzz2-2.2 {\n  fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN \n    ( \"AAAAAA\" NOTNULL <= x'414141414141' IS NULL , ( ROUND ( 1.0 ) ) )}\n} {1}\ndo_test fuzz2-2.3 {\n  fuzzcatch {INSERT OR REPLACE INTO AAAAAA . \"AAAAAA\" ( \"AAAAAA\" ) SELECT DISTINCT * , ( SELECT #252 IN ( SELECT DISTINCT AAAAAA . * ) )}\n} {1}\ndo_test fuzz2-2.4 {\n  fuzzcatch {SELECT 1 LIMIT NOT #59 COLLATE AAAAAA NOT IN round(1.0)}\n} {1}\ndo_test fuzz2-2.5 {\n  fuzzcatch {SELECT( #239 )}\n} {1}\ndo_test fuzz2-2.6 {\n  fuzzcatch {DELETE FROM AAAAAA WHERE #65 NOT NULL}\n} {1}\ndo_test fuzz2-2.7 {\n  fuzzcatch {ATTACH ROUND( 1.0 ) in  AAAAAA . \"AAAAAA\" AS #122 ISNULL}\n} {1}\ndo_test fuzz2-2.8 {\n  fuzzcatch {SELECT 1 LIMIT  #122 ISNULL}\n} {1}\ndo_test fuzz2-2.9 {\n  fuzzcatch {CREATE VIEW AAAAAA . \"AAAAAA\" AS SELECT DISTINCT #162 IS NULL \"AAAAAA\"}\n} {1}\ndo_test fuzz2-2.10 {\n  fuzzcatch {DELETE FROM AAAAAA WHERE #202 IS NOT NULL ISNULL}\n} {1}\ndo_test fuzz2-2.11 {\n  fuzzcatch {UPDATE OR IGNORE \"AAAAAA\" . \"AAAAAA\" SET \"AAAAAA\" = NOT #96}\n} {1}\ndo_test fuzz2-2.12 {\n  fuzzcatch {SELECT - #196}\n} {1}\n\nifcapable {trigger} {  # Only do the following tests if triggers are enabled\n\ndo_test fuzz2-3.0 {\n  fuzzcatch {CREATE TRIGGER \"AAAAAA\" . \"AAAAAA\" AFTER UPDATE OF \"AAAAAA\" , \"AAAAAA\" ON \"AAAAAA\" . \"AAAAAA\" FOR EACH ROW BEGIN UPDATE AAAAAA SET \"AAAAAA\" = #162;  END}\n} {1}\ndo_test fuzz2-3.1 {\n  fuzzcatch {CREATE TRIGGER IF NOT EXISTS \"AAAAAA\" UPDATE ON \"AAAAAA\" . AAAAAA FOR EACH ROW BEGIN DELETE FROM \"AAAAAA\" ; INSERT INTO AAAAAA ( \"AAAAAA\" ) SELECT DISTINCT \"AAAAAA\" \"AAAAAA\" , #167 AAAAAA , \"AAAAAA\" . * ORDER BY \"AAAAAA\" ASC , x'414141414141' BETWEEN RAISE ( FAIL , \"AAAAAA\" ) AND AAAAAA ( * ) NOT NULL DESC LIMIT AAAAAA ; REPLACE INTO AAAAAA ( AAAAAA ) VALUES ( AAAAAA ( * ) ) ; END}\n} {1}\ndo_test fuzz2-3.2 {\n  fuzzcatch {CREATE TEMP TRIGGER IF NOT EXISTS AAAAAA . \"AAAAAA\" BEFORE UPDATE OF \"AAAAAA\" ON AAAAAA . \"AAAAAA\" BEGIN SELECT ALL * , #175 \"AAAAAA\" FROM \"AAAAAA\" . AAAAAA;  END}\n} {1}\n\n} ;# End of ifcapable {trigger}\n\ndo_test fuzz2-4.0 {\n  fuzzcatch {ATTACH DATABASE #168 AS whatever}\n} {1}\ndo_test fuzz2-4.1 {\n  fuzzcatch {DETACH #133}\n} {1}\ndo_test fuzz2-5.0 {\n  fuzzcatch {SELECT 1 LIMIT ( SELECT DISTINCT * , AAAAAA , * , AAAAAA , \"AAAAAA\" . * FROM \"AAAAAA\" ON ROUND( 1 ) COLLATE AAAAAA OR \"AAAAAA\" USING ( AAAAAA , \"AAAAAA\" ) WHERE ROUND( 1 ) GROUP BY ORDER BY #84 ASC , #44 DESC , ( SELECT \"AAAAAA\" . * , \"AAAAAA\" . * FROM , ( ) \"AAAAAA\" USING ( )}\n} {1}\ndo_test fuzz2-5.1 {\n  fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + \"AAAAAA\" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT \"AAAAAA\" . * , * , * WHERE ( SELECT ALL AAAAAA AS \"AAAAAA\" HAVING CAST ( \"AAAAAA\" . \"AAAAAA\" . \"AAAAAA\" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( \"AAAAAA\" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY \"AAAAAA\" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , \"AAAAAA\" ) , CAST ( ~ \"AAAAAA\" . AAAAAA AS \"AAAAAA\" AAAAAA \"AAAAAA\" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . \"AAAAAA\" . \"AAAAAA\" ) ) NOTNULL NOT NULL}\n} {1}\ndo_test fuzz2-5.2 {\n  fuzzcatch {SELECT 1 WHERE 1 == AAAAAA ( * ) BETWEEN + - ~ + \"AAAAAA\" . AAAAAA | RAISE ( IGNORE ) COLLATE AAAAAA NOT IN ( SELECT DISTINCT \"AAAAAA\" . * , * , * WHERE ( SELECT ALL AAAAAA AS \"AAAAAA\" HAVING CAST ( \"AAAAAA\" . \"AAAAAA\" . \"AAAAAA\" AS AAAAAA ) ORDER BY , , IS NULL ASC , ~ AND DESC LIMIT ( ( \"AAAAAA\" ) NOT BETWEEN ( ) NOT IN ( ) AND AAAAAA ( ) IS NOT NULL ) OFFSET AAAAAA ( ALL , , ) ) GROUP BY ORDER BY \"AAAAAA\" . AAAAAA ASC , NULL IN ( SELECT UNION ALL SELECT ALL WHERE HAVING ORDER BY LIMIT UNION SELECT DISTINCT FROM ( ) WHERE + HAVING >> ORDER BY LIMIT . . , \"AAAAAA\" ) , CAST ( ~ \"AAAAAA\" . AAAAAA AS \"AAAAAA\" AAAAAA \"AAAAAA\" ( + 4294967295 , - 4294967296.0 ) ) ASC LIMIT AAAAAA INTERSECT SELECT ALL * GROUP BY , AAAAAA ( DISTINCT , ) != #241 NOT IN ( , , ) , , CTIME_KW HAVING AAAAAA ORDER BY #103 DESC , #81 ASC LIMIT AAAAAA OFFSET ~ AAAAAA ( ALL AAAAAA . AAAAAA >= AAAAAA . \"AAAAAA\" . \"AAAAAA\" ) ) NOTNULL NOT NULL}\n} {1}\ndo_test fuzz2-5.3 {\n  fuzzcatch {UPDATE \"AAAAAA\" SET \"AAAAAA\" = - EXISTS ( SELECT DISTINCT * , * ORDER BY #202 ASC , #147 , ~ AAAAAA . \"AAAAAA\" ASC LIMIT AAAAAA . \"AAAAAA\" , RAISE ( ABORT , AAAAAA ) UNION ALL SELECT DISTINCT AAAAAA . * , * FROM ( SELECT DISTINCT}\n} {1}\ndo_test fuzz2-5.4 {\n  fuzzcatch {REPLACE INTO AAAAAA SELECT DISTINCT \"AAAAAA\" . * WHERE AAAAAA ( AAAAAA ( ) ) GROUP BY AAAAAA . AAAAAA . \"AAAAAA\" IN \"AAAAAA\" | AAAAAA ( ALL , ) ORDER BY #238, #92 DESC LIMIT 0 OFFSET - RAISE ( IGNORE ) NOT NULL > RAISE ( IGNORE ) IS NULL}\n} {1}\ndo_test fuzz2-5.5 {\n  fuzzcatch {SELECT ALL * GROUP BY EXISTS ( SELECT \"AAAAAA\" . * , AAAAAA ( * ) AS AAAAAA FROM \"AAAAAA\" . \"AAAAAA\" AS \"AAAAAA\" USING ( AAAAAA , \"AAAAAA\" , \"AAAAAA\" ) WHERE AAAAAA ( DISTINCT ) - RAISE ( FAIL , \"AAAAAA\" ) HAVING \"AAAAAA\" . \"AAAAAA\" . AAAAAA ORDER BY #182 , #55 ) BETWEEN EXISTS ( SELECT ALL * FROM ( ( }\n} {1}\n\n# Test cases discovered by Michal Zalewski on 2015-01-03 and reported on the\n# sqlite-users mailing list.  All of these cases cause segfaults in \n# SQLite 3.8.7.4 and earlier.\n#\ndo_test fuzz2-6.1 {\n  catchsql {SELECT n()AND+#0;}\n} {1 {near \"#0\": syntax error}}\ndo_test fuzz2-6.2 {\n  catchsql {SELECT strftime()}\n} {0 {{}}}\ndo_test fuzz2-6.3 {\n  catchsql {DETACH(SELECT group_concat(q));}\n} {1 {no such column: q}}\ndo_test fuzz2-6.4a {\n  db eval {DROP TABLE IF EXISTS t0; CREATE TABLE t0(t);}\n  catchsql {INSERT INTO t0 SELECT strftime();}\n} {0 {}}\ndo_test fuzz2-6.4b {\n  db eval {SELECT quote(t) FROM t0} \n} {NULL}\n\n# Another test case discovered by Michal Zalewski, this on on 2015-01-22.\n# Ticket 32b63d542433ca6757cd695aca42addf8ed67aa6\n#\ndo_test fuzz2-7.1 {\n  catchsql {select e.*,0 from(s,(L))e;}\n} {1 {no such table: s}}\ndo_test fuzz2-7.2 {\n  catchsql {SELECT c.* FROM (a,b) AS c}\n} {1 {no such table: a}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz3.test",
    "content": "# 2007 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The focus\n# of this file is checking the libraries response to subtly corrupting\n# the database file by changing the values of pseudo-randomly selected\n# bytes.\n#\n# $Id: fuzz3.test,v 1.3 2009/01/05 17:19:03 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# These tests deal with corrupt database files\n#\ndatabase_may_be_corrupt\ntest_set_config_pagecache 0 0\n\n\nexpr srand(123)\n\nproc rstring {n} {\n  set str s\n  while {[string length $str] < $n} {\n    append str [expr rand()]\n  }\n  return [string range $str 0 $n]\n}\n\n# Return a randomly generated SQL literal.\n#\nproc rvalue {} {\n  switch -- [expr int(rand()*5)] {\n    0 { # SQL NULL value.\n      return NULL \n    }\n    1 { # Integer value.\n      return [expr int(rand()*1024)] \n    }\n    2 { # Real value.\n      return [expr rand()] \n    }\n    3 { # String value.\n      set n [expr int(rand()*2500)]\n      return \"'[rstring $n]'\"\n    }\n    4 { # Blob value.\n      set n [expr int(rand()*2500)]\n      return \"CAST('[rstring $n]' AS BLOB)\"\n    }\n  }\n}\n\nproc db_checksum {} {\n  set    cksum [execsql { SELECT md5sum(a, b, c) FROM t1 }]\n  append cksum [execsql { SELECT md5sum(d, e, f) FROM t2 }]\n  set cksum\n}\n\n# Modify a single byte in the file 'test.db' using tcl IO commands. The\n# argument value, which must be an integer, determines both the offset of\n# the byte that is modified, and the value that it is set to. The lower\n# 8 bits of iMod determine the new byte value. The offset of the byte\n# modified is the value of ($iMod >> 8).\n#\n# The return value is the iMod value required to restore the file\n# to its original state. The command:\n#\n#   modify_database [modify_database $x]\n#\n# leaves the file in the same state as it was in at the start of the\n# command (assuming that the file is at least ($x>>8) bytes in size).\n#\nproc modify_database {iMod} {\n  set blob [binary format c [expr {$iMod&0xFF}]]\n  set offset [expr {$iMod>>8}]\n\n  set fd [open test.db r+]\n  fconfigure $fd -encoding binary -translation binary\n  seek $fd $offset\n  set old_blob [read $fd 1]\n  seek $fd $offset\n  puts -nonewline $fd $blob\n  close $fd\n\n  binary scan $old_blob c iOld\n  return [expr {($offset<<8) + ($iOld&0xFF)}]\n}\n\nproc purge_pcache {} {\n  ifcapable !memorymanage {\n    db close\n    sqlite3 db test.db\n  } else {\n    sqlite3_release_memory 10000000\n  }\n  if {[lindex [pcache_stats] 1] != 0} {\n    error \"purge_pcache failed: [pcache_stats]\"\n  }\n}\n\n# This block creates a database to work with. \n#\ndo_test fuzz3-1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(d, e, f);\n    CREATE INDEX i1 ON t1(a, b, c);\n    CREATE INDEX i2 ON t2(d, e, f);\n  }\n  for {set i 0} {$i < 50} {incr i} {\n    execsql \"INSERT INTO t1 VALUES([rvalue], [rvalue], [rvalue])\"\n    execsql \"INSERT INTO t2 VALUES([rvalue], [rvalue], [rvalue])\"\n  }\n  execsql COMMIT\n} {}\n\nset ::cksum [db_checksum]\ndo_test fuzz3-2 {\n  db_checksum\n} $::cksum\n\nfor {set ii 0} {$ii < 5000} {incr ii} {\n  purge_pcache\n\n  # Randomly modify a single byte of the database file somewhere within\n  # the first 100KB of the file.\n  set iNew [expr int(rand()*5*1024*256)]\n  set iOld [modify_database $iNew]\n\n  set iTest 0\n  foreach sql {\n    {SELECT * FROM t2 ORDER BY d}      \n    {SELECT * FROM t1}                 \n    {SELECT * FROM t2}                 \n    {SELECT * FROM t1 ORDER BY a}      \n    {SELECT * FROM t1 WHERE a = (SELECT a FROM t1 WHERE rowid=25)} \n    {SELECT * FROM t2 WHERE d = (SELECT d FROM t2 WHERE rowid=1)}  \n    {SELECT * FROM t2 WHERE d = (SELECT d FROM t2 WHERE rowid=50)} \n    {PRAGMA integrity_check}           \n  } {\n    do_test fuzz3-$ii.$iNew.[incr iTest] {\n      foreach {rc msg} [catchsql $sql] {}\n      if {$rc == 0 \n       || $msg eq \"database or disk is full\"\n       || $msg eq \"database disk image is malformed\"\n       || $msg eq \"file is not a database\"\n       || [string match \"malformed database schema*\" $msg]\n      } {\n        set msg ok\n      }\n      set msg\n    } {ok}\n  }\n\n  # Restore the original database file content. Test that the correct \n  # checksum is now returned.\n  #\n  purge_pcache\n  modify_database $iOld\n  do_test fuzz3-$ii.$iNew.[incr iTest] {\n    db_checksum\n  } $::cksum\n}\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz_common.tcl",
    "content": "# 2007 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: fuzz_common.tcl,v 1.2 2009/01/05 19:36:30 drh Exp $\n\nproc fuzz {TemplateList} {\n  set n [llength $TemplateList]\n  set i [expr {int(rand()*$n)}]\n  set r [uplevel 1 subst -novar [list [lindex $TemplateList $i]]]\n\n  string map {\"\\n\" \" \"} $r\n}\n\n# Fuzzy generation primitives:\n#\n#     Literal\n#     UnaryOp\n#     BinaryOp\n#     Expr\n#     Table\n#     Select\n#     Insert\n#\n\n# Returns a string representing an SQL literal.\n#\nproc Literal {} {\n  set TemplateList {\n    456 0 -456 1 -1 \n    2147483648 2147483647 2147483649 -2147483647 -2147483648 -2147483649\n    'The' 'first' 'experiments' 'in' 'hardware' 'fault' 'injection'\n    zeroblob(1000)\n    NULL\n    56.1 -56.1\n    123456789.1234567899\n  }\n  fuzz $TemplateList\n}\n\n# Returns a string containing an SQL unary operator (e.g. \"+\" or \"NOT\").\n#\nproc UnaryOp {} {\n  set TemplateList {+ - NOT ~}\n  fuzz $TemplateList\n}\n\n# Returns a string containing an SQL binary operator (e.g. \"*\" or \"/\").\n#\nproc BinaryOp {} {\n  set TemplateList {\n    || * / % + - << >> & | < <= > >= = == != <> AND OR\n    LIKE GLOB {NOT LIKE}\n  }\n  fuzz $TemplateList\n}\n\n# Return the complete text of an SQL expression.\n#\nset ::ExprDepth 0\nproc Expr { {c {}} } {\n  incr ::ExprDepth\n\n  set TemplateList [concat $c $c $c {[Literal]}]\n  if {$::ExprDepth < 3} {\n    lappend TemplateList \\\n      {[Expr $c] [BinaryOp] [Expr $c]}                              \\\n      {[UnaryOp] [Expr $c]}                                         \\\n      {[Expr $c] ISNULL}                                            \\\n      {[Expr $c] NOTNULL}                                           \\\n      {CAST([Expr $c] AS blob)}                                     \\\n      {CAST([Expr $c] AS text)}                                     \\\n      {CAST([Expr $c] AS integer)}                                  \\\n      {CAST([Expr $c] AS real)}                                     \\\n      {abs([Expr])}                                                 \\\n      {coalesce([Expr], [Expr])}                                    \\\n      {hex([Expr])}                                                 \\\n      {length([Expr])}                                              \\\n      {lower([Expr])}                                               \\\n      {upper([Expr])}                                               \\\n      {quote([Expr])}                                               \\\n      {random()}                                                    \\\n      {randomblob(min(max([Expr],1), 500))}                         \\\n      {typeof([Expr])}                                              \\\n      {substr([Expr],[Expr],[Expr])}                                \\\n      {CASE WHEN [Expr $c] THEN [Expr $c] ELSE [Expr $c] END}       \\\n      {[Literal]} {[Literal]} {[Literal]}                           \\\n      {[Literal]} {[Literal]} {[Literal]}                           \\\n      {[Literal]} {[Literal]} {[Literal]}                           \\\n      {[Literal]} {[Literal]} {[Literal]}\n  }\n  if {$::SelectDepth < 4} {\n    lappend TemplateList \\\n      {([Select 1])}                       \\\n      {[Expr $c] IN ([Select 1])}          \\\n      {[Expr $c] NOT IN ([Select 1])}      \\\n      {EXISTS ([Select 1])}                \\\n  } \n  set res [fuzz $TemplateList]\n  incr ::ExprDepth -1\n  return $res\n}\n\n# Return a valid table name.\n#\nset ::TableList [list]\nproc Table {} {\n  set TemplateList [concat sqlite_master $::TableList]\n  fuzz $TemplateList\n}\n\n# Return one of:\n#\n#     \"SELECT DISTINCT\", \"SELECT ALL\" or \"SELECT\"\n#\nproc SelectKw {} {\n  set TemplateList {\n    \"SELECT DISTINCT\"\n    \"SELECT ALL\"\n    \"SELECT\"\n  }\n  fuzz $TemplateList\n}\n\n# Return a result set for a SELECT statement.\n#\nproc ResultSet {{nRes 0} {c \"\"}} {\n  if {$nRes == 0} {\n    set nRes [expr {rand()*2 + 1}]\n  }\n\n  set aRes [list]\n  for {set ii 0} {$ii < $nRes} {incr ii} {\n    lappend aRes [Expr $c]\n  }\n\n  join $aRes \", \"\n}\n\nset ::SelectDepth 0\nset ::ColumnList [list]\nproc SimpleSelect {{nRes 0}} {\n\n  set TemplateList {\n      {[SelectKw] [ResultSet $nRes]}\n  }\n\n  # The ::SelectDepth variable contains the number of ancestor SELECT\n  # statements (i.e. for a top level SELECT it is set to 0, for a\n  # sub-select 1, for a sub-select of a sub-select 2 etc.).\n  #\n  # If this is already greater than 3, do not generate a complicated\n  # SELECT statement. This tends to cause parser stack overflow (too\n  # boring to bother with).\n  #\n  if {$::SelectDepth < 4} {\n    lappend TemplateList \\\n        {[SelectKw] [ResultSet $nRes $::ColumnList] FROM ([Select])}     \\\n        {[SelectKw] [ResultSet $nRes] FROM ([Select])}                   \\\n        {[SelectKw] [ResultSet $nRes $::ColumnList] FROM [Table]}        \\\n        {\n             [SelectKw] [ResultSet $nRes $::ColumnList] \n             FROM ([Select]) \n             GROUP BY [Expr]\n             HAVING [Expr]\n        }                                                                \\\n\n    if {0 == $nRes} {\n      lappend TemplateList                                               \\\n          {[SelectKw] * FROM ([Select])}                                 \\\n          {[SelectKw] * FROM [Table]}                                    \\\n          {[SelectKw] * FROM [Table] WHERE [Expr $::ColumnList]}         \\\n          {\n             [SelectKw] * \n             FROM [Table],[Table] AS t2 \n             WHERE [Expr $::ColumnList] \n          } {\n             [SelectKw] * \n             FROM [Table] LEFT OUTER JOIN [Table] AS t2 \n             ON [Expr $::ColumnList]\n             WHERE [Expr $::ColumnList] \n          }\n    }\n  } \n\n  fuzz $TemplateList\n}\n\n# Return a SELECT statement.\n#\n# If boolean parameter $isExpr is set to true, make sure the\n# returned SELECT statement returns a single column of data.\n#\nproc Select {{nMulti 0}} {\n  set TemplateList {\n    {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} \n    {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} \n    {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} \n    {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} {[SimpleSelect $nMulti]} \n    {[SimpleSelect $nMulti] ORDER BY [Expr] DESC}\n    {[SimpleSelect $nMulti] ORDER BY [Expr] ASC}\n    {[SimpleSelect $nMulti] ORDER BY [Expr] ASC, [Expr] DESC}\n    {[SimpleSelect $nMulti] ORDER BY [Expr] LIMIT [Expr] OFFSET [Expr]}\n  }\n\n  if {$::SelectDepth < 4} {\n    if {$nMulti == 0} {\n      set nMulti [expr {(rand()*2)+1}]\n    }\n    lappend TemplateList                                             \\\n        {[SimpleSelect $nMulti] UNION     [Select $nMulti]}          \\\n        {[SimpleSelect $nMulti] UNION ALL [Select $nMulti]}          \\\n        {[SimpleSelect $nMulti] EXCEPT    [Select $nMulti]}          \\\n        {[SimpleSelect $nMulti] INTERSECT [Select $nMulti]}\n  }\n\n  incr ::SelectDepth\n  set res [fuzz $TemplateList]\n  incr ::SelectDepth -1\n  set res\n}\n\n# Generate and return a fuzzy INSERT statement.\n#\nproc Insert {} {\n  set TemplateList {\n      {INSERT INTO [Table] VALUES([Expr], [Expr], [Expr]);}\n      {INSERT INTO [Table] VALUES([Expr], [Expr], [Expr], [Expr]);}\n      {INSERT INTO [Table] VALUES([Expr], [Expr]);}\n  }\n  fuzz $TemplateList\n}\n\nproc Column {} {\n  fuzz $::ColumnList\n}\n\n# Generate and return a fuzzy UPDATE statement.\n#\nproc Update {} {\n  set TemplateList {\n    {UPDATE [Table] \n     SET [Column] = [Expr $::ColumnList] \n     WHERE [Expr $::ColumnList]}\n  }\n  fuzz $TemplateList\n}\n\nproc Delete {} {\n  set TemplateList {\n    {DELETE FROM [Table] WHERE [Expr $::ColumnList]}\n  }\n  fuzz $TemplateList\n}\n\nproc Statement {} {\n  set TemplateList {\n    {[Update]}\n    {[Insert]}\n    {[Select]}\n    {[Delete]}\n  }\n  fuzz $TemplateList\n}\n\n# Return an identifier. This just chooses randomly from a fixed set\n# of strings.\nproc Identifier {} {\n  set TemplateList {\n    This just chooses randomly a fixed \n    We would also thank the developers \n    for their analysis Samba\n  }\n  fuzz $TemplateList\n}\n\nproc Check {} {\n  # Use a large value for $::SelectDepth, because sub-selects are\n  # not allowed in expressions used by CHECK constraints.\n  #\n  set sd $::SelectDepth \n  set ::SelectDepth 500\n  set TemplateList {\n    {}\n    {CHECK ([Expr])}\n  }\n  set res [fuzz $TemplateList]\n  set ::SelectDepth $sd\n  set res\n}\n\nproc Coltype {} {\n  set TemplateList {\n    {INTEGER PRIMARY KEY}\n    {VARCHAR [Check]}\n    {PRIMARY KEY}\n  }\n  fuzz $TemplateList\n}\n\nproc DropTable {} {\n  set TemplateList {\n    {DROP TABLE IF EXISTS [Identifier]}\n  }\n  fuzz $TemplateList\n}\n\nproc CreateView {} {\n  set TemplateList {\n    {CREATE VIEW [Identifier] AS [Select]}\n  }\n  fuzz $TemplateList\n}\nproc DropView {} {\n  set TemplateList {\n    {DROP VIEW IF EXISTS [Identifier]}\n  }\n  fuzz $TemplateList\n}\n\nproc CreateTable {} {\n  set TemplateList {\n    {CREATE TABLE [Identifier]([Identifier] [Coltype], [Identifier] [Coltype])}\n    {CREATE TEMP TABLE [Identifier]([Identifier] [Coltype])}\n  }\n  fuzz $TemplateList\n}\n\nproc CreateOrDropTableOrView {} {\n  set TemplateList {\n    {[CreateTable]}\n    {[DropTable]}\n    {[CreateView]}\n    {[DropView]}\n  }\n  fuzz $TemplateList\n}\n\n########################################################################\n\nset ::log [open fuzzy.log w]\n\n#\n# Usage: do_fuzzy_test <testname> ?<options>?\n# \n#     -template\n#     -errorlist\n#     -repeats\n#     \nproc do_fuzzy_test {testname args} {\n  set ::fuzzyopts(-errorlist) [list]\n  set ::fuzzyopts(-repeats) $::REPEATS\n  array set ::fuzzyopts $args\n\n  lappend ::fuzzyopts(-errorlist) {parser stack overflow} \n  lappend ::fuzzyopts(-errorlist) {ORDER BY}\n  lappend ::fuzzyopts(-errorlist) {GROUP BY}\n  lappend ::fuzzyopts(-errorlist) {datatype mismatch}\n\n  for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {\n    do_test ${testname}.$ii {\n      set ::sql [subst $::fuzzyopts(-template)]\n      puts $::log $::sql\n      flush $::log\n      set rc [catch {execsql $::sql} msg]\n      set e 1\n      if {$rc} {\n        set e 0\n        foreach error $::fuzzyopts(-errorlist) {\n          if {[string first $error $msg]>=0} {\n            set e 1\n            break\n          }\n        }\n      }\n      if {$e == 0} {\n        puts \"\"\n        puts $::sql\n        puts $msg\n      }\n      set e\n    } {1}\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzz_malloc.test",
    "content": "#\n# 2007 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests malloc failures in concert with fuzzy SQL generation.\n#\n# $Id: fuzz_malloc.test,v 1.10 2008/08/20 16:35:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !memdebug {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\nsource $testdir/fuzz_common.tcl\n\nif {[info exists G(isquick)]} {\n  set ::REPEATS 20\n} elseif {[info exists G(issoak)]} {\n  set ::REPEATS 100\n} else {\n  set ::REPEATS 40\n}\n\n#\n# Usage: do_fuzzy_malloc_test <testname> ?<options>?\n# \n#     -template\n#     -sqlprep\n#     -repeats\n#     \nproc do_fuzzy_malloc_test {testname args} {\n  set ::fuzzyopts(-repeats) $::REPEATS\n  set ::fuzzyopts(-sqlprep) {}\n  array set ::fuzzyopts $args\n\n  sqlite3_memdebug_fail -1\n  db close\n  delete_file test.db test.db-journal\n  sqlite3 db test.db\n  set ::prep $::fuzzyopts(-sqlprep)\n  execsql $::prep\n  set jj 0\n  for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} {\n    expr srand($jj)\n    incr jj\n    set ::sql [subst $::fuzzyopts(-template)]\n    # puts fuzyy-sql=\\[$::sql\\]; flush stdout\n    foreach {rc res} [catchsql \"$::sql\"] {}\n    if {$rc==0} {\n      do_malloc_test $testname-$ii -sqlbody $::sql -sqlprep $::prep\n    } else {\n      incr ii -1\n    }\n  }\n}\n\n#----------------------------------------------------------------\n# Test malloc failure during parsing (and execution) of a fuzzily \n# generated expressions.\n#\ndo_fuzzy_malloc_test fuzzy_malloc-1 -template {Select [Expr]}\ndo_fuzzy_malloc_test fuzzy_malloc-2 -template {[Select]}\n\nset ::SQLPREP {\n  BEGIN;\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE def(a, b, c);\n    CREATE TABLE ghi(a, b, c);\n    INSERT INTO abc VALUES(1.5, 3, 'a short string');\n    INSERT INTO def VALUES(NULL, X'ABCDEF', \n        'a longer string. Long enough that it doesn''t fit in Mem.zShort');\n    INSERT INTO ghi VALUES(zeroblob(1000), 'hello world', -1257900987654321);\n  COMMIT;\n}\nset ::TableList  [list abc def ghi]\nset ::ColumnList [list a b c]\n\ndo_fuzzy_malloc_test fuzzy_malloc-3 \\\n  -template {[Select]}              \\\n  -sqlprep $::SQLPREP\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzzcheck.c",
    "content": "/*\n** 2015-05-25\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This is a utility program designed to aid running regressions tests on\n** the SQLite library using data from an external fuzzer, such as American\n** Fuzzy Lop (AFL) (http://lcamtuf.coredump.cx/afl/).\n**\n** This program reads content from an SQLite database file with the following\n** schema:\n**\n**     CREATE TABLE db(\n**       dbid INTEGER PRIMARY KEY, -- database id\n**       dbcontent BLOB            -- database disk file image\n**     );\n**     CREATE TABLE xsql(\n**       sqlid INTEGER PRIMARY KEY,   -- SQL script id\n**       sqltext TEXT                 -- Text of SQL statements to run\n**     );\n**     CREATE TABLE IF NOT EXISTS readme(\n**       msg TEXT -- Human-readable description of this test collection\n**     );\n**\n** For each database file in the DB table, the SQL text in the XSQL table\n** is run against that database.  All README.MSG values are printed prior\n** to the start of the test (unless the --quiet option is used).  If the\n** DB table is empty, then all entries in XSQL are run against an empty\n** in-memory database.\n**\n** This program is looking for crashes, assertion faults, and/or memory leaks.\n** No attempt is made to verify the output.  The assumption is that either all\n** of the database files or all of the SQL statements are malformed inputs,\n** generated by a fuzzer, that need to be checked to make sure they do not\n** present a security risk.\n**\n** This program also includes some command-line options to help with \n** creation and maintenance of the source content database.  The command\n**\n**     ./fuzzcheck database.db --load-sql FILE...\n**\n** Loads all FILE... arguments into the XSQL table.  The --load-db option\n** works the same but loads the files into the DB table.  The -m option can\n** be used to initialize the README table.  The \"database.db\" file is created\n** if it does not previously exist.  Example:\n**\n**     ./fuzzcheck new.db --load-sql *.sql\n**     ./fuzzcheck new.db --load-db *.db\n**     ./fuzzcheck new.db -m 'New test cases'\n**\n** The three commands above will create the \"new.db\" file and initialize all\n** tables.  Then do \"./fuzzcheck new.db\" to run the tests.\n**\n** DEBUGGING HINTS:\n**\n** If fuzzcheck does crash, it can be run in the debugger and the content\n** of the global variable g.zTextName[] will identify the specific XSQL and\n** DB values that were running when the crash occurred.\n*/\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <ctype.h>\n#include \"sqlite3.h\"\n#define ISSPACE(X) isspace((unsigned char)(X))\n#define ISDIGIT(X) isdigit((unsigned char)(X))\n\n\n#ifdef __unix__\n# include <signal.h>\n# include <unistd.h>\n#endif\n\n#ifdef SQLITE_OSS_FUZZ\n# include <stddef.h>\n# include <stdint.h>\n#endif\n\n/*\n** Files in the virtual file system.\n*/\ntypedef struct VFile VFile;\nstruct VFile {\n  char *zFilename;        /* Filename.  NULL for delete-on-close. From malloc() */\n  int sz;                 /* Size of the file in bytes */\n  int nRef;               /* Number of references to this file */\n  unsigned char *a;       /* Content of the file.  From malloc() */\n};\ntypedef struct VHandle VHandle;\nstruct VHandle {\n  sqlite3_file base;      /* Base class.  Must be first */\n  VFile *pVFile;          /* The underlying file */\n};\n\n/*\n** The value of a database file template, or of an SQL script\n*/\ntypedef struct Blob Blob;\nstruct Blob {\n  Blob *pNext;            /* Next in a list */\n  int id;                 /* Id of this Blob */\n  int seq;                /* Sequence number */\n  int sz;                 /* Size of this Blob in bytes */\n  unsigned char a[1];     /* Blob content.  Extra space allocated as needed. */\n};\n\n/*\n** Maximum number of files in the in-memory virtual filesystem.\n*/\n#define MX_FILE  10\n\n/*\n** Maximum allowed file size\n*/\n#define MX_FILE_SZ 10000000\n\n/*\n** All global variables are gathered into the \"g\" singleton.\n*/\nstatic struct GlobalVars {\n  const char *zArgv0;              /* Name of program */\n  VFile aFile[MX_FILE];            /* The virtual filesystem */\n  int nDb;                         /* Number of template databases */\n  Blob *pFirstDb;                  /* Content of first template database */\n  int nSql;                        /* Number of SQL scripts */\n  Blob *pFirstSql;                 /* First SQL script */\n  unsigned int uRandom;            /* Seed for the SQLite PRNG */\n  char zTestName[100];             /* Name of current test */\n} g;\n\n/*\n** Print an error message and quit.\n*/\nstatic void fatalError(const char *zFormat, ...){\n  va_list ap;\n  if( g.zTestName[0] ){\n    fprintf(stderr, \"%s (%s): \", g.zArgv0, g.zTestName);\n  }else{\n    fprintf(stderr, \"%s: \", g.zArgv0);\n  }\n  va_start(ap, zFormat);\n  vfprintf(stderr, zFormat, ap);\n  va_end(ap);\n  fprintf(stderr, \"\\n\");\n  exit(1);\n}\n\n/*\n** Timeout handler\n*/\n#ifdef __unix__\nstatic void timeoutHandler(int NotUsed){\n  (void)NotUsed;\n  fatalError(\"timeout\\n\");\n}\n#endif\n\n/*\n** Set the an alarm to go off after N seconds.  Disable the alarm\n** if N==0\n*/\nstatic void setAlarm(int N){\n#ifdef __unix__\n  alarm(N);\n#else\n  (void)N;\n#endif\n}\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** This an SQL progress handler.  After an SQL statement has run for\n** many steps, we want to interrupt it.  This guards against infinite\n** loops from recursive common table expressions.\n**\n** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used.\n** In that case, hitting the progress handler is a fatal error.\n*/\nstatic int progressHandler(void *pVdbeLimitFlag){\n  if( *(int*)pVdbeLimitFlag ) fatalError(\"too many VDBE cycles\");\n  return 1;\n}\n#endif\n\n/*\n** Reallocate memory.  Show and error and quit if unable.\n*/\nstatic void *safe_realloc(void *pOld, int szNew){\n  void *pNew = realloc(pOld, szNew<=0 ? 1 : szNew);\n  if( pNew==0 ) fatalError(\"unable to realloc for %d bytes\", szNew);\n  return pNew;\n}\n\n/*\n** Initialize the virtual file system.\n*/\nstatic void formatVfs(void){\n  int i;\n  for(i=0; i<MX_FILE; i++){\n    g.aFile[i].sz = -1;\n    g.aFile[i].zFilename = 0;\n    g.aFile[i].a = 0;\n    g.aFile[i].nRef = 0;\n  }\n}\n\n\n/*\n** Erase all information in the virtual file system.\n*/\nstatic void reformatVfs(void){\n  int i;\n  for(i=0; i<MX_FILE; i++){\n    if( g.aFile[i].sz<0 ) continue;\n    if( g.aFile[i].zFilename ){\n      free(g.aFile[i].zFilename);\n      g.aFile[i].zFilename = 0;\n    }\n    if( g.aFile[i].nRef>0 ){\n      fatalError(\"file %d still open.  nRef=%d\", i, g.aFile[i].nRef);\n    }\n    g.aFile[i].sz = -1;\n    free(g.aFile[i].a);\n    g.aFile[i].a = 0;\n    g.aFile[i].nRef = 0;\n  }\n}\n\n/*\n** Find a VFile by name\n*/\nstatic VFile *findVFile(const char *zName){\n  int i;\n  if( zName==0 ) return 0;\n  for(i=0; i<MX_FILE; i++){\n    if( g.aFile[i].zFilename==0 ) continue;   \n    if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i];\n  }\n  return 0;\n}\n\n/*\n** Find a VFile by name.  Create it if it does not already exist and\n** initialize it to the size and content given.\n**\n** Return NULL only if the filesystem is full.\n*/\nstatic VFile *createVFile(const char *zName, int sz, unsigned char *pData){\n  VFile *pNew = findVFile(zName);\n  int i;\n  if( pNew ) return pNew;\n  for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}\n  if( i>=MX_FILE ) return 0;\n  pNew = &g.aFile[i];\n  if( zName ){\n    int nName = (int)strlen(zName)+1;\n    pNew->zFilename = safe_realloc(0, nName);\n    memcpy(pNew->zFilename, zName, nName);\n  }else{\n    pNew->zFilename = 0;\n  }\n  pNew->nRef = 0;\n  pNew->sz = sz;\n  pNew->a = safe_realloc(0, sz);\n  if( sz>0 ) memcpy(pNew->a, pData, sz);\n  return pNew;\n}\n\n\n/*\n** Implementation of the \"readfile(X)\" SQL function.  The entire content\n** of the file named X is read and returned as a BLOB.  NULL is returned\n** if the file does not exist or is unreadable.\n*/\nstatic void readfileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zName;\n  FILE *in;\n  long nIn;\n  void *pBuf;\n\n  zName = (const char*)sqlite3_value_text(argv[0]);\n  if( zName==0 ) return;\n  in = fopen(zName, \"rb\");\n  if( in==0 ) return;\n  fseek(in, 0, SEEK_END);\n  nIn = ftell(in);\n  rewind(in);\n  pBuf = sqlite3_malloc64( nIn );\n  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){\n    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);\n  }else{\n    sqlite3_free(pBuf);\n  }\n  fclose(in);\n}\n\n/*\n** Implementation of the \"writefile(X,Y)\" SQL function.  The argument Y\n** is written into file X.  The number of bytes written is returned.  Or\n** NULL is returned if something goes wrong, such as being unable to open\n** file X for writing.\n*/\nstatic void writefileFunc(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  FILE *out;\n  const char *z;\n  sqlite3_int64 rc;\n  const char *zFile;\n\n  (void)argc;\n  zFile = (const char*)sqlite3_value_text(argv[0]);\n  if( zFile==0 ) return;\n  out = fopen(zFile, \"wb\");\n  if( out==0 ) return;\n  z = (const char*)sqlite3_value_blob(argv[1]);\n  if( z==0 ){\n    rc = 0;\n  }else{\n    rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);\n  }\n  fclose(out);\n  sqlite3_result_int64(context, rc);\n}\n\n\n/*\n** Load a list of Blob objects from the database\n*/\nstatic void blobListLoadFromDb(\n  sqlite3 *db,             /* Read from this database */\n  const char *zSql,        /* Query used to extract the blobs */\n  int onlyId,              /* Only load where id is this value */\n  int *pN,                 /* OUT: Write number of blobs loaded here */\n  Blob **ppList            /* OUT: Write the head of the blob list here */\n){\n  Blob head;\n  Blob *p;\n  sqlite3_stmt *pStmt;\n  int n = 0;\n  int rc;\n  char *z2;\n\n  if( onlyId>0 ){\n    z2 = sqlite3_mprintf(\"%s WHERE rowid=%d\", zSql, onlyId);\n  }else{\n    z2 = sqlite3_mprintf(\"%s\", zSql);\n  }\n  rc = sqlite3_prepare_v2(db, z2, -1, &pStmt, 0);\n  sqlite3_free(z2);\n  if( rc ) fatalError(\"%s\", sqlite3_errmsg(db));\n  head.pNext = 0;\n  p = &head;\n  while( SQLITE_ROW==sqlite3_step(pStmt) ){\n    int sz = sqlite3_column_bytes(pStmt, 1);\n    Blob *pNew = safe_realloc(0, sizeof(*pNew)+sz );\n    pNew->id = sqlite3_column_int(pStmt, 0);\n    pNew->sz = sz;\n    pNew->seq = n++;\n    pNew->pNext = 0;\n    memcpy(pNew->a, sqlite3_column_blob(pStmt,1), sz);\n    pNew->a[sz] = 0;\n    p->pNext = pNew;\n    p = pNew;\n  }\n  sqlite3_finalize(pStmt);\n  *pN = n;\n  *ppList = head.pNext;\n}\n\n/*\n** Free a list of Blob objects\n*/\nstatic void blobListFree(Blob *p){\n  Blob *pNext;\n  while( p ){\n    pNext = p->pNext;\n    free(p);\n    p = pNext;\n  }\n}\n\n\n/* Return the current wall-clock time */\nstatic sqlite3_int64 timeOfDay(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n/* Methods for the VHandle object\n*/\nstatic int inmemClose(sqlite3_file *pFile){\n  VHandle *p = (VHandle*)pFile;\n  VFile *pVFile = p->pVFile;\n  pVFile->nRef--;\n  if( pVFile->nRef==0 && pVFile->zFilename==0 ){\n    pVFile->sz = -1;\n    free(pVFile->a);\n    pVFile->a = 0;\n  }\n  return SQLITE_OK;\n}\nstatic int inmemRead(\n  sqlite3_file *pFile,   /* Read from this open file */\n  void *pData,           /* Store content in this buffer */\n  int iAmt,              /* Bytes of content */\n  sqlite3_int64 iOfst    /* Start reading here */\n){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( iOfst<0 || iOfst>=pVFile->sz ){\n    memset(pData, 0, iAmt);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  if( iOfst+iAmt>pVFile->sz ){\n    memset(pData, 0, iAmt);\n    iAmt = (int)(pVFile->sz - iOfst);\n    memcpy(pData, pVFile->a, iAmt);\n    return SQLITE_IOERR_SHORT_READ;\n  }\n  memcpy(pData, pVFile->a + iOfst, iAmt);\n  return SQLITE_OK;\n}\nstatic int inmemWrite(\n  sqlite3_file *pFile,   /* Write to this file */\n  const void *pData,     /* Content to write */\n  int iAmt,              /* bytes to write */\n  sqlite3_int64 iOfst    /* Start writing here */\n){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( iOfst+iAmt > pVFile->sz ){\n    if( iOfst+iAmt >= MX_FILE_SZ ){\n      return SQLITE_FULL;\n    }\n    pVFile->a = safe_realloc(pVFile->a, (int)(iOfst+iAmt));\n    if( iOfst > pVFile->sz ){\n      memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz));\n    }\n    pVFile->sz = (int)(iOfst + iAmt);\n  }\n  memcpy(pVFile->a + iOfst, pData, iAmt);\n  return SQLITE_OK;\n}\nstatic int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){\n  VHandle *pHandle = (VHandle*)pFile;\n  VFile *pVFile = pHandle->pVFile;\n  if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize;\n  return SQLITE_OK;\n}\nstatic int inmemSync(sqlite3_file *pFile, int flags){\n  return SQLITE_OK;\n}\nstatic int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){\n  *pSize = ((VHandle*)pFile)->pVFile->sz;\n  return SQLITE_OK;\n}\nstatic int inmemLock(sqlite3_file *pFile, int type){\n  return SQLITE_OK;\n}\nstatic int inmemUnlock(sqlite3_file *pFile, int type){\n  return SQLITE_OK;\n}\nstatic int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){\n  *pOut = 0;\n  return SQLITE_OK;\n}\nstatic int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){\n  return SQLITE_NOTFOUND;\n}\nstatic int inmemSectorSize(sqlite3_file *pFile){\n  return 512;\n}\nstatic int inmemDeviceCharacteristics(sqlite3_file *pFile){\n  return\n      SQLITE_IOCAP_SAFE_APPEND |\n      SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |\n      SQLITE_IOCAP_POWERSAFE_OVERWRITE;\n}\n\n\n/* Method table for VHandle\n*/\nstatic sqlite3_io_methods VHandleMethods = {\n  /* iVersion  */    1,\n  /* xClose    */    inmemClose,\n  /* xRead     */    inmemRead,\n  /* xWrite    */    inmemWrite,\n  /* xTruncate */    inmemTruncate,\n  /* xSync     */    inmemSync,\n  /* xFileSize */    inmemFileSize,\n  /* xLock     */    inmemLock,\n  /* xUnlock   */    inmemUnlock,\n  /* xCheck... */    inmemCheckReservedLock,\n  /* xFileCtrl */    inmemFileControl,\n  /* xSectorSz */    inmemSectorSize,\n  /* xDevchar  */    inmemDeviceCharacteristics,\n  /* xShmMap   */    0,\n  /* xShmLock  */    0,\n  /* xShmBarrier */  0,\n  /* xShmUnmap */    0,\n  /* xFetch    */    0,\n  /* xUnfetch  */    0\n};\n\n/*\n** Open a new file in the inmem VFS.  All files are anonymous and are\n** delete-on-close.\n*/\nstatic int inmemOpen(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  sqlite3_file *pFile,\n  int openFlags,\n  int *pOutFlags\n){\n  VFile *pVFile = createVFile(zFilename, 0, (unsigned char*)\"\");\n  VHandle *pHandle = (VHandle*)pFile;\n  if( pVFile==0 ){\n    return SQLITE_FULL;\n  }\n  pHandle->pVFile = pVFile;\n  pVFile->nRef++;\n  pFile->pMethods = &VHandleMethods;\n  if( pOutFlags ) *pOutFlags = openFlags;\n  return SQLITE_OK;\n}\n\n/*\n** Delete a file by name\n*/\nstatic int inmemDelete(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int syncdir\n){\n  VFile *pVFile = findVFile(zFilename);\n  if( pVFile==0 ) return SQLITE_OK;\n  if( pVFile->nRef==0 ){\n    free(pVFile->zFilename);\n    pVFile->zFilename = 0;\n    pVFile->sz = -1;\n    free(pVFile->a);\n    pVFile->a = 0;\n    return SQLITE_OK;\n  }\n  return SQLITE_IOERR_DELETE;\n}\n\n/* Check for the existance of a file\n*/\nstatic int inmemAccess(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int flags,\n  int *pResOut\n){\n  VFile *pVFile = findVFile(zFilename);\n  *pResOut =  pVFile!=0;\n  return SQLITE_OK;\n}\n\n/* Get the canonical pathname for a file\n*/\nstatic int inmemFullPathname(\n  sqlite3_vfs *pVfs,\n  const char *zFilename,\n  int nOut,\n  char *zOut\n){\n  sqlite3_snprintf(nOut, zOut, \"%s\", zFilename);\n  return SQLITE_OK;\n}\n\n/* Always use the same random see, for repeatability.\n*/\nstatic int inmemRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){\n  memset(zBuf, 0, nBuf);\n  memcpy(zBuf, &g.uRandom, nBuf<sizeof(g.uRandom) ? nBuf : sizeof(g.uRandom));\n  return nBuf;\n}\n\n/*\n** Register the VFS that reads from the g.aFile[] set of files.\n*/\nstatic void inmemVfsRegister(int makeDefault){\n  static sqlite3_vfs inmemVfs;\n  sqlite3_vfs *pDefault = sqlite3_vfs_find(0);\n  inmemVfs.iVersion = 3;\n  inmemVfs.szOsFile = sizeof(VHandle);\n  inmemVfs.mxPathname = 200;\n  inmemVfs.zName = \"inmem\";\n  inmemVfs.xOpen = inmemOpen;\n  inmemVfs.xDelete = inmemDelete;\n  inmemVfs.xAccess = inmemAccess;\n  inmemVfs.xFullPathname = inmemFullPathname;\n  inmemVfs.xRandomness = inmemRandomness;\n  inmemVfs.xSleep = pDefault->xSleep;\n  inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;\n  sqlite3_vfs_register(&inmemVfs, makeDefault);\n};\n\n/*\n** Allowed values for the runFlags parameter to runSql()\n*/\n#define SQL_TRACE  0x0001     /* Print each SQL statement as it is prepared */\n#define SQL_OUTPUT 0x0002     /* Show the SQL output */\n\n/*\n** Run multiple commands of SQL.  Similar to sqlite3_exec(), but does not\n** stop if an error is encountered.\n*/\nstatic void runSql(sqlite3 *db, const char *zSql, unsigned  runFlags){\n  const char *zMore;\n  sqlite3_stmt *pStmt;\n\n  while( zSql && zSql[0] ){\n    zMore = 0;\n    pStmt = 0;\n    sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);\n    if( zMore==zSql ) break;\n    if( runFlags & SQL_TRACE ){\n      const char *z = zSql;\n      int n;\n      while( z<zMore && ISSPACE(z[0]) ) z++;\n      n = (int)(zMore - z);\n      while( n>0 && ISSPACE(z[n-1]) ) n--;\n      if( n==0 ) break;\n      if( pStmt==0 ){\n        printf(\"TRACE: %.*s (error: %s)\\n\", n, z, sqlite3_errmsg(db));\n      }else{\n        printf(\"TRACE: %.*s\\n\", n, z);\n      }\n    }\n    zSql = zMore;\n    if( pStmt ){\n      if( (runFlags & SQL_OUTPUT)==0 ){\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){}\n      }else{\n        int nCol = -1;\n        while( SQLITE_ROW==sqlite3_step(pStmt) ){\n          int i;\n          if( nCol<0 ){\n            nCol = sqlite3_column_count(pStmt);\n          }else if( nCol>0 ){\n            printf(\"--------------------------------------------\\n\");\n          }\n          for(i=0; i<nCol; i++){\n            int eType = sqlite3_column_type(pStmt,i);\n            printf(\"%s = \", sqlite3_column_name(pStmt,i));\n            switch( eType ){\n              case SQLITE_NULL: {\n                printf(\"NULL\\n\");\n                break;\n              }\n              case SQLITE_INTEGER: {\n                printf(\"INT %s\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_FLOAT: {\n                printf(\"FLOAT %s\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_TEXT: {\n                printf(\"TEXT [%s]\\n\", sqlite3_column_text(pStmt,i));\n                break;\n              }\n              case SQLITE_BLOB: {\n                printf(\"BLOB (%d bytes)\\n\", sqlite3_column_bytes(pStmt,i));\n                break;\n              }\n            }\n          }\n        }\n      }         \n      sqlite3_finalize(pStmt);\n    }\n  }\n}\n\n/*\n** Rebuild the database file.\n**\n**    (1)  Remove duplicate entries\n**    (2)  Put all entries in order\n**    (3)  Vacuum\n*/\nstatic void rebuild_database(sqlite3 *db){\n  int rc;\n  rc = sqlite3_exec(db, \n     \"BEGIN;\\n\"\n     \"CREATE TEMP TABLE dbx AS SELECT DISTINCT dbcontent FROM db;\\n\"\n     \"DELETE FROM db;\\n\"\n     \"INSERT INTO db(dbid, dbcontent) SELECT NULL, dbcontent FROM dbx ORDER BY 2;\\n\"\n     \"DROP TABLE dbx;\\n\"\n     \"CREATE TEMP TABLE sx AS SELECT DISTINCT sqltext FROM xsql;\\n\"\n     \"DELETE FROM xsql;\\n\"\n     \"INSERT INTO xsql(sqlid,sqltext) SELECT NULL, sqltext FROM sx ORDER BY 2;\\n\"\n     \"DROP TABLE sx;\\n\"\n     \"COMMIT;\\n\"\n     \"PRAGMA page_size=1024;\\n\"\n     \"VACUUM;\\n\", 0, 0, 0);\n  if( rc ) fatalError(\"cannot rebuild: %s\", sqlite3_errmsg(db));\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic int integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( ISDIGIT(zArg[0]) ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  if( v>0x7fffffff ) fatalError(\"parameter too large - max 2147483648\");\n  return (int)(isNeg? -v : v);\n}\n\n/*\n** Print sketchy documentation for this utility program\n*/\nstatic void showHelp(void){\n  printf(\"Usage: %s [options] SOURCE-DB ?ARGS...?\\n\", g.zArgv0);\n  printf(\n\"Read databases and SQL scripts from SOURCE-DB and execute each script against\\n\"\n\"each database, checking for crashes and memory leaks.\\n\"\n\"Options:\\n\"\n\"  --cell-size-check    Set the PRAGMA cell_size_check=ON\\n\"\n\"  --dbid N             Use only the database where dbid=N\\n\"\n\"  --export-db DIR      Write databases to files(s) in DIR. Works with --dbid\\n\"\n\"  --export-sql DIR     Write SQL to file(s) in DIR. Also works with --sqlid\\n\"\n\"  --help               Show this help text\\n\"\n\"  -q|--quiet           Reduced output\\n\"\n\"  --limit-mem N        Limit memory used by test SQLite instance to N bytes\\n\"\n\"  --limit-vdbe         Panic if any test runs for more than 100,000 cycles\\n\"\n\"  --load-sql ARGS...   Load SQL scripts fro files into SOURCE-DB\\n\"\n\"  --load-db ARGS...    Load template databases from files into SOURCE_DB\\n\"\n\"  -m TEXT              Add a description to the database\\n\"\n\"  --native-vfs         Use the native VFS for initially empty database files\\n\"\n\"  --native-malloc      Turn off MEMSYS3/5 and Lookaside\\n\"\n\"  --oss-fuzz           Enable OSS-FUZZ testing\\n\"\n\"  --prng-seed N        Seed value for the PRGN inside of SQLite\\n\"\n\"  --rebuild            Rebuild and vacuum the database file\\n\"\n\"  --result-trace       Show the results of each SQL command\\n\"\n\"  --sqlid N            Use only SQL where sqlid=N\\n\"\n\"  --timeout N          Abort if any single test needs more than N seconds\\n\"\n\"  -v|--verbose         Increased output.  Repeat for more output.\\n\"\n  );\n}\n\nint main(int argc, char **argv){\n  sqlite3_int64 iBegin;        /* Start time of this program */\n  int quietFlag = 0;           /* True if --quiet or -q */\n  int verboseFlag = 0;         /* True if --verbose or -v */\n  char *zInsSql = 0;           /* SQL statement for --load-db or --load-sql */\n  int iFirstInsArg = 0;        /* First argv[] to use for --load-db or --load-sql */\n  sqlite3 *db = 0;             /* The open database connection */\n  sqlite3_stmt *pStmt;         /* A prepared statement */\n  int rc;                      /* Result code from SQLite interface calls */\n  Blob *pSql;                  /* For looping over SQL scripts */\n  Blob *pDb;                   /* For looping over template databases */\n  int i;                       /* Loop index for the argv[] loop */\n  int onlySqlid = -1;          /* --sqlid */\n  int onlyDbid = -1;           /* --dbid */\n  int nativeFlag = 0;          /* --native-vfs */\n  int rebuildFlag = 0;         /* --rebuild */\n  int vdbeLimitFlag = 0;       /* --limit-vdbe */\n  int timeoutTest = 0;         /* undocumented --timeout-test flag */\n  int runFlags = 0;            /* Flags sent to runSql() */\n  char *zMsg = 0;              /* Add this message */\n  int nSrcDb = 0;              /* Number of source databases */\n  char **azSrcDb = 0;          /* Array of source database names */\n  int iSrcDb;                  /* Loop over all source databases */\n  int nTest = 0;               /* Total number of tests performed */\n  char *zDbName = \"\";          /* Appreviated name of a source database */\n  const char *zFailCode = 0;   /* Value of the TEST_FAILURE environment variable */\n  int cellSzCkFlag = 0;        /* --cell-size-check */\n  int sqlFuzz = 0;             /* True for SQL fuzz testing. False for DB fuzz */\n  int iTimeout = 120;          /* Default 120-second timeout */\n  int nMem = 0;                /* Memory limit */\n  int nMemThisDb = 0;          /* Memory limit set by the CONFIG table */\n  char *zExpDb = 0;            /* Write Databases to files in this directory */\n  char *zExpSql = 0;           /* Write SQL to files in this directory */\n  void *pHeap = 0;             /* Heap for use by SQLite */\n  int ossFuzz = 0;             /* enable OSS-FUZZ testing */\n  int ossFuzzThisDb = 0;       /* ossFuzz value for this particular database */\n  int nativeMalloc = 0;        /* Turn off MEMSYS3/5 and lookaside if true */\n  sqlite3_vfs *pDfltVfs;       /* The default VFS */\n\n  iBegin = timeOfDay();\n#ifdef __unix__\n  signal(SIGALRM, timeoutHandler);\n#endif\n  g.zArgv0 = argv[0];\n  zFailCode = getenv(\"TEST_FAILURE\");\n  pDfltVfs = sqlite3_vfs_find(0);\n  inmemVfsRegister(1);\n  for(i=1; i<argc; i++){\n    const char *z = argv[i];\n    if( z[0]=='-' ){\n      z++;\n      if( z[0]=='-' ) z++;\n      if( strcmp(z,\"cell-size-check\")==0 ){\n        cellSzCkFlag = 1;\n      }else\n      if( strcmp(z,\"dbid\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        onlyDbid = integerValue(argv[++i]);\n      }else\n      if( strcmp(z,\"export-db\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        zExpDb = argv[++i];\n      }else\n      if( strcmp(z,\"export-sql\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        zExpSql = argv[++i];\n      }else\n      if( strcmp(z,\"help\")==0 ){\n        showHelp();\n        return 0;\n      }else\n      if( strcmp(z,\"limit-mem\")==0 ){\n#if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5)\n        fatalError(\"the %s option requires -DSQLITE_ENABLE_MEMSYS5 or _MEMSYS3\",\n                   argv[i]);\n#else\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        nMem = integerValue(argv[++i]);\n#endif\n      }else\n      if( strcmp(z,\"limit-vdbe\")==0 ){\n        vdbeLimitFlag = 1;\n      }else\n      if( strcmp(z,\"load-sql\")==0 ){\n        zInsSql = \"INSERT INTO xsql(sqltext) VALUES(CAST(readfile(?1) AS text))\";\n        iFirstInsArg = i+1;\n        break;\n      }else\n      if( strcmp(z,\"load-db\")==0 ){\n        zInsSql = \"INSERT INTO db(dbcontent) VALUES(readfile(?1))\";\n        iFirstInsArg = i+1;\n        break;\n      }else\n      if( strcmp(z,\"m\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        zMsg = argv[++i];\n      }else\n      if( strcmp(z,\"native-malloc\")==0 ){\n        nativeMalloc = 1;\n      }else\n      if( strcmp(z,\"native-vfs\")==0 ){\n        nativeFlag = 1;\n      }else\n      if( strcmp(z,\"oss-fuzz\")==0 ){\n        ossFuzz = 1;\n      }else\n      if( strcmp(z,\"prng-seed\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        g.uRandom = atoi(argv[++i]);\n      }else\n      if( strcmp(z,\"quiet\")==0 || strcmp(z,\"q\")==0 ){\n        quietFlag = 1;\n        verboseFlag = 0;\n      }else\n      if( strcmp(z,\"rebuild\")==0 ){\n        rebuildFlag = 1;\n      }else\n      if( strcmp(z,\"result-trace\")==0 ){\n        runFlags |= SQL_OUTPUT;\n      }else\n      if( strcmp(z,\"sqlid\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        onlySqlid = integerValue(argv[++i]);\n      }else\n      if( strcmp(z,\"timeout\")==0 ){\n        if( i>=argc-1 ) fatalError(\"missing arguments on %s\", argv[i]);\n        iTimeout = integerValue(argv[++i]);\n      }else\n      if( strcmp(z,\"timeout-test\")==0 ){\n        timeoutTest = 1;\n#ifndef __unix__\n        fatalError(\"timeout is not available on non-unix systems\");\n#endif\n      }else\n      if( strcmp(z,\"verbose\")==0 || strcmp(z,\"v\")==0 ){\n        quietFlag = 0;\n        verboseFlag++;\n        if( verboseFlag>1 ) runFlags |= SQL_TRACE;\n      }else\n      {\n        fatalError(\"unknown option: %s\", argv[i]);\n      }\n    }else{\n      nSrcDb++;\n      azSrcDb = safe_realloc(azSrcDb, nSrcDb*sizeof(azSrcDb[0]));\n      azSrcDb[nSrcDb-1] = argv[i];\n    }\n  }\n  if( nSrcDb==0 ) fatalError(\"no source database specified\");\n  if( nSrcDb>1 ){\n    if( zMsg ){\n      fatalError(\"cannot change the description of more than one database\");\n    }\n    if( zInsSql ){\n      fatalError(\"cannot import into more than one database\");\n    }\n  }\n\n  /* Process each source database separately */\n  for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){\n    rc = sqlite3_open_v2(azSrcDb[iSrcDb], &db,\n                         SQLITE_OPEN_READWRITE, pDfltVfs->zName);\n    if( rc ){\n      fatalError(\"cannot open source database %s - %s\",\n      azSrcDb[iSrcDb], sqlite3_errmsg(db));\n    }\n    rc = sqlite3_exec(db,\n       \"CREATE TABLE IF NOT EXISTS db(\\n\"\n       \"  dbid INTEGER PRIMARY KEY, -- database id\\n\"\n       \"  dbcontent BLOB            -- database disk file image\\n\"\n       \");\\n\"\n       \"CREATE TABLE IF NOT EXISTS xsql(\\n\"\n       \"  sqlid INTEGER PRIMARY KEY,   -- SQL script id\\n\"\n       \"  sqltext TEXT                 -- Text of SQL statements to run\\n\"\n       \");\"\n       \"CREATE TABLE IF NOT EXISTS readme(\\n\"\n       \"  msg TEXT -- Human-readable description of this file\\n\"\n       \");\", 0, 0, 0);\n    if( rc ) fatalError(\"cannot create schema: %s\", sqlite3_errmsg(db));\n    if( zMsg ){\n      char *zSql;\n      zSql = sqlite3_mprintf(\n               \"DELETE FROM readme; INSERT INTO readme(msg) VALUES(%Q)\", zMsg);\n      rc = sqlite3_exec(db, zSql, 0, 0, 0);\n      sqlite3_free(zSql);\n      if( rc ) fatalError(\"cannot change description: %s\", sqlite3_errmsg(db));\n    }\n    ossFuzzThisDb = ossFuzz;\n\n    /* If the CONFIG(name,value) table exists, read db-specific settings\n    ** from that table */\n    if( sqlite3_table_column_metadata(db,0,\"config\",0,0,0,0,0,0)==SQLITE_OK ){\n      rc = sqlite3_prepare_v2(db, \"SELECT name, value FROM config\", -1, &pStmt, 0);\n      if( rc ) fatalError(\"cannot prepare query of CONFIG table: %s\",\n                          sqlite3_errmsg(db));\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        const char *zName = (const char *)sqlite3_column_text(pStmt,0);\n        if( zName==0 ) continue;\n        if( strcmp(zName, \"oss-fuzz\")==0 ){\n          ossFuzzThisDb = sqlite3_column_int(pStmt,1);\n          if( verboseFlag ) printf(\"Config: oss-fuzz=%d\\n\", ossFuzzThisDb);\n        }\n        if( strcmp(zName, \"limit-mem\")==0 && !nativeMalloc ){\n#if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5)\n          fatalError(\"the limit-mem option requires -DSQLITE_ENABLE_MEMSYS5\"\n                     \" or _MEMSYS3\");\n#else\n          nMemThisDb = sqlite3_column_int(pStmt,1);\n          if( verboseFlag ) printf(\"Config: limit-mem=%d\\n\", nMemThisDb);\n#endif\n        }\n      }\n      sqlite3_finalize(pStmt);\n    }\n\n    if( zInsSql ){\n      sqlite3_create_function(db, \"readfile\", 1, SQLITE_UTF8, 0,\n                              readfileFunc, 0, 0);\n      rc = sqlite3_prepare_v2(db, zInsSql, -1, &pStmt, 0);\n      if( rc ) fatalError(\"cannot prepare statement [%s]: %s\",\n                          zInsSql, sqlite3_errmsg(db));\n      rc = sqlite3_exec(db, \"BEGIN\", 0, 0, 0);\n      if( rc ) fatalError(\"cannot start a transaction\");\n      for(i=iFirstInsArg; i<argc; i++){\n        sqlite3_bind_text(pStmt, 1, argv[i], -1, SQLITE_STATIC);\n        sqlite3_step(pStmt);\n        rc = sqlite3_reset(pStmt);\n        if( rc ) fatalError(\"insert failed for %s\", argv[i]);\n      }\n      sqlite3_finalize(pStmt);\n      rc = sqlite3_exec(db, \"COMMIT\", 0, 0, 0);\n      if( rc ) fatalError(\"cannot commit the transaction: %s\", sqlite3_errmsg(db));\n      rebuild_database(db);\n      sqlite3_close(db);\n      return 0;\n    }\n    rc = sqlite3_exec(db, \"PRAGMA query_only=1;\", 0, 0, 0);\n    if( rc ) fatalError(\"cannot set database to query-only\");\n    if( zExpDb!=0 || zExpSql!=0 ){\n      sqlite3_create_function(db, \"writefile\", 2, SQLITE_UTF8, 0,\n                              writefileFunc, 0, 0);\n      if( zExpDb!=0 ){\n        const char *zExDb = \n          \"SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent),\"\n          \"       dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)\"\n          \"  FROM db WHERE ?2<0 OR dbid=?2;\";\n        rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0);\n        if( rc ) fatalError(\"cannot prepare statement [%s]: %s\",\n                            zExDb, sqlite3_errmsg(db));\n        sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb),\n                            SQLITE_STATIC, SQLITE_UTF8);\n        sqlite3_bind_int(pStmt, 2, onlyDbid);\n        while( sqlite3_step(pStmt)==SQLITE_ROW ){\n          printf(\"write db-%d (%d bytes) into %s\\n\",\n             sqlite3_column_int(pStmt,1),\n             sqlite3_column_int(pStmt,3),\n             sqlite3_column_text(pStmt,2));\n        }\n        sqlite3_finalize(pStmt);\n      }\n      if( zExpSql!=0 ){\n        const char *zExSql = \n          \"SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext),\"\n          \"       sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)\"\n          \"  FROM xsql WHERE ?2<0 OR sqlid=?2;\";\n        rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0);\n        if( rc ) fatalError(\"cannot prepare statement [%s]: %s\",\n                            zExSql, sqlite3_errmsg(db));\n        sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql),\n                            SQLITE_STATIC, SQLITE_UTF8);\n        sqlite3_bind_int(pStmt, 2, onlySqlid);\n        while( sqlite3_step(pStmt)==SQLITE_ROW ){\n          printf(\"write sql-%d (%d bytes) into %s\\n\",\n             sqlite3_column_int(pStmt,1),\n             sqlite3_column_int(pStmt,3),\n             sqlite3_column_text(pStmt,2));\n        }\n        sqlite3_finalize(pStmt);\n      }\n      sqlite3_close(db);\n      return 0;\n    }\n  \n    /* Load all SQL script content and all initial database images from the\n    ** source db\n    */\n    blobListLoadFromDb(db, \"SELECT sqlid, sqltext FROM xsql\", onlySqlid,\n                           &g.nSql, &g.pFirstSql);\n    if( g.nSql==0 ) fatalError(\"need at least one SQL script\");\n    blobListLoadFromDb(db, \"SELECT dbid, dbcontent FROM db\", onlyDbid,\n                       &g.nDb, &g.pFirstDb);\n    if( g.nDb==0 ){\n      g.pFirstDb = safe_realloc(0, sizeof(Blob));\n      memset(g.pFirstDb, 0, sizeof(Blob));\n      g.pFirstDb->id = 1;\n      g.pFirstDb->seq = 0;\n      g.nDb = 1;\n      sqlFuzz = 1;\n    }\n  \n    /* Print the description, if there is one */\n    if( !quietFlag ){\n      zDbName = azSrcDb[iSrcDb];\n      i = (int)strlen(zDbName) - 1;\n      while( i>0 && zDbName[i-1]!='/' && zDbName[i-1]!='\\\\' ){ i--; }\n      zDbName += i;\n      sqlite3_prepare_v2(db, \"SELECT msg FROM readme\", -1, &pStmt, 0);\n      if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){\n        printf(\"%s: %s\\n\", zDbName, sqlite3_column_text(pStmt,0));\n      }\n      sqlite3_finalize(pStmt);\n    }\n\n    /* Rebuild the database, if requested */\n    if( rebuildFlag ){\n      if( !quietFlag ){\n        printf(\"%s: rebuilding... \", zDbName);\n        fflush(stdout);\n      }\n      rebuild_database(db);\n      if( !quietFlag ) printf(\"done\\n\");\n    }\n  \n    /* Close the source database.  Verify that no SQLite memory allocations are\n    ** outstanding.\n    */\n    sqlite3_close(db);\n    if( sqlite3_memory_used()>0 ){\n      fatalError(\"SQLite has memory in use before the start of testing\");\n    }\n\n    /* Limit available memory, if requested */\n    sqlite3_shutdown();\n    if( nMemThisDb>0 && !nativeMalloc ){\n      pHeap = realloc(pHeap, nMemThisDb);\n      if( pHeap==0 ){\n        fatalError(\"failed to allocate %d bytes of heap memory\", nMem);\n      }\n      sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMemThisDb, 128);\n    }\n\n    /* Disable lookaside with the --native-malloc option */\n    if( nativeMalloc ){\n      sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);\n    }\n  \n    /* Reset the in-memory virtual filesystem */\n    formatVfs();\n    \n    /* Run a test using each SQL script against each database.\n    */\n    if( !verboseFlag && !quietFlag ) printf(\"%s:\", zDbName);\n    for(pSql=g.pFirstSql; pSql; pSql=pSql->pNext){\n      for(pDb=g.pFirstDb; pDb; pDb=pDb->pNext){\n        int openFlags;\n        const char *zVfs = \"inmem\";\n        sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, \"sqlid=%d,dbid=%d\",\n                         pSql->id, pDb->id);\n        if( verboseFlag ){\n          printf(\"%s\\n\", g.zTestName);\n          fflush(stdout);\n        }else if( !quietFlag ){\n          static int prevAmt = -1;\n          int idx = pSql->seq*g.nDb + pDb->id - 1;\n          int amt = idx*10/(g.nDb*g.nSql);\n          if( amt!=prevAmt ){\n            printf(\" %d%%\", amt*10);\n            fflush(stdout);\n            prevAmt = amt;\n          }\n        }\n        createVFile(\"main.db\", pDb->sz, pDb->a);\n        sqlite3_randomness(0,0);\n        if( ossFuzzThisDb ){\n#ifndef SQLITE_OSS_FUZZ\n          fatalError(\"--oss-fuzz not supported: recompile with -DSQLITE_OSS_FUZZ\");\n#else\n          extern int LLVMFuzzerTestOneInput(const uint8_t*, size_t);\n          LLVMFuzzerTestOneInput((const uint8_t*)pSql->a, (size_t)pSql->sz);\n#endif\n        }else{\n          openFlags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;\n          if( nativeFlag && pDb->sz==0 ){\n            openFlags |= SQLITE_OPEN_MEMORY;\n            zVfs = 0;\n          }\n          rc = sqlite3_open_v2(\"main.db\", &db, openFlags, zVfs);\n          if( rc ) fatalError(\"cannot open inmem database\");\n          sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 100000000);\n          sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 50);\n          if( cellSzCkFlag ) runSql(db, \"PRAGMA cell_size_check=ON\", runFlags);\n          setAlarm(iTimeout);\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n          if( sqlFuzz || vdbeLimitFlag ){\n            sqlite3_progress_handler(db, 100000, progressHandler, &vdbeLimitFlag);\n          }\n#endif\n          do{\n            runSql(db, (char*)pSql->a, runFlags);\n          }while( timeoutTest );\n          setAlarm(0);\n          sqlite3_exec(db, \"PRAGMA temp_store_directory=''\", 0, 0, 0);\n          sqlite3_close(db);\n        }\n        if( sqlite3_memory_used()>0 ){\n           fatalError(\"memory leak: %lld bytes outstanding\",\n                      sqlite3_memory_used());\n        }\n        reformatVfs();\n        nTest++;\n        g.zTestName[0] = 0;\n\n        /* Simulate an error if the TEST_FAILURE environment variable is \"5\".\n        ** This is used to verify that automated test script really do spot\n        ** errors that occur in this test program.\n        */\n        if( zFailCode ){\n          if( zFailCode[0]=='5' && zFailCode[1]==0 ){\n            fatalError(\"simulated failure\");\n          }else if( zFailCode[0]!=0 ){\n            /* If TEST_FAILURE is something other than 5, just exit the test\n            ** early */\n            printf(\"\\nExit early due to TEST_FAILURE being set\\n\");\n            iSrcDb = nSrcDb-1;\n            goto sourcedb_cleanup;\n          }\n        }\n      }\n    }\n    if( !quietFlag && !verboseFlag ){\n      printf(\" 100%% - %d tests\\n\", g.nDb*g.nSql);\n    }\n  \n    /* Clean up at the end of processing a single source database\n    */\n  sourcedb_cleanup:\n    blobListFree(g.pFirstSql);\n    blobListFree(g.pFirstDb);\n    reformatVfs();\n \n  } /* End loop over all source databases */\n\n  if( !quietFlag ){\n    sqlite3_int64 iElapse = timeOfDay() - iBegin;\n    printf(\"fuzzcheck: 0 errors out of %d tests in %d.%03d seconds\\n\"\n           \"SQLite %s %s\\n\",\n           nTest, (int)(iElapse/1000), (int)(iElapse%1000),\n           sqlite3_libversion(), sqlite3_sourceid());\n  }\n  free(azSrcDb);\n  free(pHeap);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzzer1.test",
    "content": "# 2011 March 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for TCL interface to the\n# SQLite library. \n#\n# The focus of the tests is the word-fuzzer virtual table.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nset ::testprefix fuzzer1\nload_static_extension db fuzzer\n\n# Check configuration errors.\n#\ndo_catchsql_test fuzzer1-1.1 {\n  CREATE VIRTUAL TABLE f USING fuzzer;\n} {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}}\n\ndo_catchsql_test fuzzer1-1.2 {\n  CREATE VIRTUAL TABLE f USING fuzzer(one, two);\n} {1 {fuzzer: wrong number of CREATE VIRTUAL TABLE arguments}}\n\ndo_catchsql_test fuzzer1-1.3 {\n  CREATE VIRTUAL TABLE f USING fuzzer(nosuchtable);\n} {1 {fuzzer: no such table: main.nosuchtable}}\n\ndo_catchsql_test fuzzer1-1.4 {\n  CREATE TEMP TABLE nosuchtable(a, b, c, d);\n  CREATE VIRTUAL TABLE f USING fuzzer(nosuchtable);\n} {1 {fuzzer: no such table: main.nosuchtable}}\n\ndo_catchsql_test fuzzer1-1.5 {\n  DROP TABLE temp.nosuchtable;\n  CREATE TABLE nosuchtable(a, b, c, d);\n  CREATE VIRTUAL TABLE temp.f USING fuzzer(nosuchtable);\n} {1 {fuzzer: no such table: temp.nosuchtable}}\n\ndo_catchsql_test fuzzer1-1.6 {\n  DROP TABLE IF EXISTS f_rules;\n  CREATE TABLE f_rules(a, b, c);\n  CREATE VIRTUAL TABLE f USING fuzzer(f_rules);\n} {1 {fuzzer: f_rules has 3 columns, expected 4}}\n\ndo_catchsql_test fuzzer1-1.7 {\n  DROP TABLE IF EXISTS f_rules;\n  CREATE TABLE f_rules(a, b, c, d, e);\n  CREATE VIRTUAL TABLE f USING fuzzer(f_rules);\n} {1 {fuzzer: f_rules has 5 columns, expected 4}}\n\n\ndo_execsql_test fuzzer1-2.1 {\n  CREATE TABLE f1_rules(ruleset DEFAULT 0, cfrom, cto, cost);\n  INSERT INTO f1_rules(cfrom, cto, cost) VALUES('e','a',1);\n  INSERT INTO f1_rules(cfrom, cto, cost) VALUES('a','e',10);\n  INSERT INTO f1_rules(cfrom, cto, cost) VALUES('e','o',100);\n\n  CREATE VIRTUAL TABLE f1 USING fuzzer(f1_rules);\n} {}\n\ndo_execsql_test fuzzer1-2.1 {\n    SELECT word, distance FROM f1 WHERE word MATCH 'abcde'\n} {\n  abcde 0   abcda 1   ebcde 10 \n  ebcda 11  abcdo 100 ebcdo 110 \n  obcde 110 obcda 111 obcdo 210\n}\n\ndo_execsql_test fuzzer1-2.4 {\n  INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'b','x',1);\n  INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'d','y',10);\n  INSERT INTO f1_rules(ruleset, cfrom, cto, cost) VALUES(1,'y','z',100);\n\n  DROP TABLE f1;\n  CREATE VIRTUAL TABLE f1 USING fuzzer(f1_rules);\n} {}\n\ndo_execsql_test fuzzer1-2.5 {\n  SELECT word, distance FROM f1 WHERE word MATCH 'abcde'\n} {\n  abcde 0   abcda 1   ebcde 10 \n  ebcda 11  abcdo 100 ebcdo 110 \n  obcde 110 obcda 111 obcdo 210\n}\n\ndo_execsql_test fuzzer1-2.6 {\n  SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND ruleset=0\n} {\n  abcde 0   abcda 1   ebcde 10 \n  ebcda 11  abcdo 100 ebcdo 110 \n  obcde 110 obcda 111 obcdo 210\n}\n\ndo_execsql_test fuzzer1-2.7 {\n  SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND ruleset=1\n} {\n  abcde 0 axcde 1 abcye 10 \n  axcye 11 abcze 110 axcze 111\n}\n\ndo_test fuzzer1-1.8 {\n  db eval {\n    SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND distance<100\n  }\n} {abcde 0 abcda 1 ebcde 10 ebcda 11}\ndo_test fuzzer1-1.9 {\n  db eval {\n    SELECT word, distance FROM f1 WHERE word MATCH 'abcde' AND distance<=100\n  }\n} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100}\ndo_test fuzzer1-1.10 {\n  db eval {\n    SELECT word, distance FROM f1\n     WHERE word MATCH 'abcde' AND distance<100 AND ruleset=0\n  }\n} {abcde 0 abcda 1 ebcde 10 ebcda 11}\ndo_test fuzzer1-1.11 {\n  db eval {\n    SELECT word, distance FROM f1\n    WHERE word MATCH 'abcde' AND distance<=100 AND ruleset=0\n  }\n} {abcde 0 abcda 1 ebcde 10 ebcda 11 abcdo 100}\ndo_test fuzzer1-1.12 {\n  db eval {\n    SELECT word, distance FROM f1\n     WHERE word MATCH 'abcde' AND distance<11 AND ruleset=1\n  }\n} {abcde 0 axcde 1 abcye 10}\ndo_test fuzzer1-1.13 {\n  db eval {\n    SELECT word, distance FROM f1\n    WHERE word MATCH 'abcde' AND distance<=11 AND ruleset=1\n  }\n} {abcde 0 axcde 1 abcye 10 axcye 11}\ndo_test fuzzer1-1.14 {\n  catchsql {INSERT INTO f1 VALUES(1)}\n} {1 {table f1 may not be modified}}\ndo_test fuzzer1-1.15 {\n  catchsql {DELETE FROM f1}\n} {1 {table f1 may not be modified}}\ndo_test fuzzer1-1.16 {\n  catchsql {UPDATE f1 SET rowid=rowid+10000}\n} {1 {table f1 may not be modified}}\n\n\ndo_test fuzzer1-2.0 {\n  execsql {\n    -- costs based on English letter frequencies\n    CREATE TEMP TABLE f2_rules(ruleset DEFAULT 0, cFrom, cTo, cost);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','e',24);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','o',47);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','u',50);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','a',23);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','i',33);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','o',37);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','e',33);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','y',33);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','a',41);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','e',46);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','u',57);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('u','o',58);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('y','i',33);\n\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('t','th',70);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('th','t',66);\n \n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('a','',84);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','b',106);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('b','',106);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','c',94);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('c','',94);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','d',89);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('d','',89);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','e',83);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('e','',83);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','f',97);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('f','',97);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','g',99);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('g','',99);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','h',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('h','',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','i',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('i','',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','j',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('j','',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','k',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('k','',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','l',89);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('l','',89);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','m',96);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('m','',96);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','n',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('n','',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','o',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('o','',85);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','p',100);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('p','',100);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','q',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('q','',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','r',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('r','',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','s',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('s','',86);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','t',84);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('t','',84);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','u',94);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('u','',94);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','v',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('v','',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','w',96);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('w','',96);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','x',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('x','',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','y',100);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('y','',100);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('','z',120);\n    INSERT INTO f2_rules(cFrom,cTo,cost) VALUES('z','',120);\n    INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)\n      SELECT 1, cFrom, cTo, 100 FROM f2_rules WHERE ruleset=0;\n    INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)\n      SELECT 2, cFrom, cTo, 200-cost FROM f2_rules WHERE ruleset=0;\n    INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)\n      SELECT 3, cFrom, cTo, cost FROM f2_rules WHERE ruleset=0;\n    INSERT INTO f2_rules(ruleset,cFrom,cTo,cost)\n      VALUES(3, 'mallard','duck',50),\n            (3, 'duck', 'mallard', 50),\n            (3, 'rock', 'stone', 50),\n            (3, 'stone', 'rock', 50);\n\n\n    CREATE VIRTUAL TABLE temp.f2 USING fuzzer(f2_rules);\n\n    -- Street names for the 28269 ZIPCODE.\n    --\n    CREATE TEMP TABLE streetname(n TEXT UNIQUE);\n    INSERT INTO streetname VALUES('abbotsinch');\n    INSERT INTO streetname VALUES('abbottsgate');\n    INSERT INTO streetname VALUES('abbywood');\n    INSERT INTO streetname VALUES('abner');\n    INSERT INTO streetname VALUES('acacia ridge');\n    INSERT INTO streetname VALUES('acorn creek');\n    INSERT INTO streetname VALUES('acorn forest');\n    INSERT INTO streetname VALUES('adel');\n    INSERT INTO streetname VALUES('ainslie');\n    INSERT INTO streetname VALUES('airways');\n    INSERT INTO streetname VALUES('alabaster');\n    INSERT INTO streetname VALUES('alba');\n    INSERT INTO streetname VALUES('albertine');\n    INSERT INTO streetname VALUES('alden glen');\n    INSERT INTO streetname VALUES('alderson');\n    INSERT INTO streetname VALUES('allen');\n    INSERT INTO streetname VALUES('allen a brown');\n    INSERT INTO streetname VALUES('allness glen');\n    INSERT INTO streetname VALUES('aloysia');\n    INSERT INTO streetname VALUES('alpine');\n    INSERT INTO streetname VALUES('alwyn');\n    INSERT INTO streetname VALUES('amaranthus');\n    INSERT INTO streetname VALUES('amber glen');\n    INSERT INTO streetname VALUES('amber leigh way');\n    INSERT INTO streetname VALUES('amber meadows');\n    INSERT INTO streetname VALUES('amberway');\n    INSERT INTO streetname VALUES('ame');\n    INSERT INTO streetname VALUES('amesbury hill');\n    INSERT INTO streetname VALUES('anderson');\n    INSERT INTO streetname VALUES('andrew thomas');\n    INSERT INTO streetname VALUES('anduin falls');\n    INSERT INTO streetname VALUES('ankeny');\n    INSERT INTO streetname VALUES('annandale');\n    INSERT INTO streetname VALUES('annbick');\n    INSERT INTO streetname VALUES('antelope');\n    INSERT INTO streetname VALUES('anzack');\n    INSERT INTO streetname VALUES('apple glen');\n    INSERT INTO streetname VALUES('applevalley');\n    INSERT INTO streetname VALUES('appley mead');\n    INSERT INTO streetname VALUES('aragorn');\n    INSERT INTO streetname VALUES('arbor creek');\n    INSERT INTO streetname VALUES('arbor day');\n    INSERT INTO streetname VALUES('arbor meadows');\n    INSERT INTO streetname VALUES('arbor spring');\n    INSERT INTO streetname VALUES('arborview');\n    INSERT INTO streetname VALUES('arklow');\n    INSERT INTO streetname VALUES('armitage');\n    INSERT INTO streetname VALUES('arvin');\n    INSERT INTO streetname VALUES('ash cove');\n    INSERT INTO streetname VALUES('ashford leigh');\n    INSERT INTO streetname VALUES('ashmont');\n    INSERT INTO streetname VALUES('atlas');\n    INSERT INTO streetname VALUES('atwater');\n    INSERT INTO streetname VALUES('auburn hill');\n    INSERT INTO streetname VALUES('aulton link');\n    INSERT INTO streetname VALUES('austin dekota');\n    INSERT INTO streetname VALUES('austin knoll');\n    INSERT INTO streetname VALUES('auten');\n    INSERT INTO streetname VALUES('autumn harvest');\n    INSERT INTO streetname VALUES('autumn oak');\n    INSERT INTO streetname VALUES('autumn ridge');\n    INSERT INTO streetname VALUES('avalon forest');\n    INSERT INTO streetname VALUES('avalon loop');\n    INSERT INTO streetname VALUES('avon farm');\n    INSERT INTO streetname VALUES('avonhurst');\n    INSERT INTO streetname VALUES('avonlea');\n    INSERT INTO streetname VALUES('aynrand');\n    INSERT INTO streetname VALUES('azure valley');\n    INSERT INTO streetname VALUES('baberton');\n    INSERT INTO streetname VALUES('baffin');\n    INSERT INTO streetname VALUES('baggins');\n    INSERT INTO streetname VALUES('balata');\n    INSERT INTO streetname VALUES('ballantray');\n    INSERT INTO streetname VALUES('ballston');\n    INSERT INTO streetname VALUES('balsam tree');\n    INSERT INTO streetname VALUES('bambi');\n    INSERT INTO streetname VALUES('banwell');\n    INSERT INTO streetname VALUES('barbee');\n    INSERT INTO streetname VALUES('barefoot forest');\n    INSERT INTO streetname VALUES('barnview');\n    INSERT INTO streetname VALUES('baroda');\n    INSERT INTO streetname VALUES('barson');\n    INSERT INTO streetname VALUES('baskerville');\n    INSERT INTO streetname VALUES('battle creek');\n    INSERT INTO streetname VALUES('baucom');\n    INSERT INTO streetname VALUES('bay pines');\n    INSERT INTO streetname VALUES('beaker');\n    INSERT INTO streetname VALUES('beard');\n    INSERT INTO streetname VALUES('beardsley');\n    INSERT INTO streetname VALUES('bearoak');\n    INSERT INTO streetname VALUES('beauvista');\n    INSERT INTO streetname VALUES('beaver creek');\n    INSERT INTO streetname VALUES('beaver hollow');\n    INSERT INTO streetname VALUES('bedlington');\n    INSERT INTO streetname VALUES('beech cove');\n    INSERT INTO streetname VALUES('beech crest');\n    INSERT INTO streetname VALUES('beith');\n    INSERT INTO streetname VALUES('bell glen');\n    INSERT INTO streetname VALUES('bellmore');\n    INSERT INTO streetname VALUES('bells mill');\n    INSERT INTO streetname VALUES('bellville');\n    INSERT INTO streetname VALUES('belmar place');\n    INSERT INTO streetname VALUES('bembridge');\n    INSERT INTO streetname VALUES('bennett neely');\n    INSERT INTO streetname VALUES('bentgrass run');\n    INSERT INTO streetname VALUES('benthaven');\n    INSERT INTO streetname VALUES('bernardy');\n    INSERT INTO streetname VALUES('bernbrook shadow');\n    INSERT INTO streetname VALUES('berrybrook');\n    INSERT INTO streetname VALUES('berrybush');\n    INSERT INTO streetname VALUES('berwick');\n    INSERT INTO streetname VALUES('betterton');\n    INSERT INTO streetname VALUES('bickham');\n    INSERT INTO streetname VALUES('billingham');\n    INSERT INTO streetname VALUES('birchcroft');\n    INSERT INTO streetname VALUES('birchstone');\n    INSERT INTO streetname VALUES('birdwell');\n    INSERT INTO streetname VALUES('bisaner');\n    INSERT INTO streetname VALUES('bitterbush');\n    INSERT INTO streetname VALUES('bitterroot');\n    INSERT INTO streetname VALUES('black fox');\n    INSERT INTO streetname VALUES('black maple');\n    INSERT INTO streetname VALUES('black trail');\n    INSERT INTO streetname VALUES('blackbird');\n    INSERT INTO streetname VALUES('blake a dare');\n    INSERT INTO streetname VALUES('blasdell');\n    INSERT INTO streetname VALUES('blue aster');\n    INSERT INTO streetname VALUES('blue finch');\n    INSERT INTO streetname VALUES('blue lilac');\n    INSERT INTO streetname VALUES('blue sky');\n    INSERT INTO streetname VALUES('blue tick');\n    INSERT INTO streetname VALUES('bob beatty');\n    INSERT INTO streetname VALUES('bobcat');\n    INSERT INTO streetname VALUES('bolton');\n    INSERT INTO streetname VALUES('boomerang');\n    INSERT INTO streetname VALUES('boulder');\n    INSERT INTO streetname VALUES('boxer');\n    INSERT INTO streetname VALUES('boxmeer');\n    INSERT INTO streetname VALUES('brachnell view');\n    INSERT INTO streetname VALUES('bradford lake');\n    INSERT INTO streetname VALUES('bradwell');\n    INSERT INTO streetname VALUES('brady');\n    INSERT INTO streetname VALUES('braids bend');\n    INSERT INTO streetname VALUES('bralers');\n    INSERT INTO streetname VALUES('brandie glen');\n    INSERT INTO streetname VALUES('brandy ridge');\n    INSERT INTO streetname VALUES('brandybuck');\n    INSERT INTO streetname VALUES('branthurst');\n    INSERT INTO streetname VALUES('brassy creek');\n    INSERT INTO streetname VALUES('brathay');\n    INSERT INTO streetname VALUES('brawer farm');\n    INSERT INTO streetname VALUES('breezy morn');\n    INSERT INTO streetname VALUES('brenda');\n    INSERT INTO streetname VALUES('brenly');\n    INSERT INTO streetname VALUES('brenock');\n    INSERT INTO streetname VALUES('brianwood');\n    INSERT INTO streetname VALUES('briar rose');\n    INSERT INTO streetname VALUES('briarcrest');\n    INSERT INTO streetname VALUES('briarthorne');\n    INSERT INTO streetname VALUES('brick dust');\n    INSERT INTO streetname VALUES('bridgepath');\n    INSERT INTO streetname VALUES('bridle ridge');\n    INSERT INTO streetname VALUES('briggs');\n    INSERT INTO streetname VALUES('brightleaf');\n    INSERT INTO streetname VALUES('brigstock');\n    INSERT INTO streetname VALUES('broad ridge');\n    INSERT INTO streetname VALUES('brock');\n    INSERT INTO streetname VALUES('brockhampton');\n    INSERT INTO streetname VALUES('broken pine');\n    INSERT INTO streetname VALUES('brompton');\n    INSERT INTO streetname VALUES('brook falls');\n    INSERT INTO streetname VALUES('brookings');\n    INSERT INTO streetname VALUES('browne');\n    INSERT INTO streetname VALUES('brownes creek');\n    INSERT INTO streetname VALUES('brownes ferry');\n    INSERT INTO streetname VALUES('brownestone view');\n    INSERT INTO streetname VALUES('brumit');\n    INSERT INTO streetname VALUES('bryn athyn');\n    INSERT INTO streetname VALUES('buck');\n    INSERT INTO streetname VALUES('bucklebury');\n    INSERT INTO streetname VALUES('buckminister');\n    INSERT INTO streetname VALUES('buckspring');\n    INSERT INTO streetname VALUES('burch');\n    INSERT INTO streetname VALUES('burch shire');\n    INSERT INTO streetname VALUES('burkston');\n    INSERT INTO streetname VALUES('burmith');\n    INSERT INTO streetname VALUES('burnaby');\n    INSERT INTO streetname VALUES('butterfly');\n    INSERT INTO streetname VALUES('cabin creek');\n    INSERT INTO streetname VALUES('cairns mill');\n    INSERT INTO streetname VALUES('callender');\n    INSERT INTO streetname VALUES('cambellton');\n    INSERT INTO streetname VALUES('cambridge bay');\n    INSERT INTO streetname VALUES('canary');\n    INSERT INTO streetname VALUES('canbury');\n    INSERT INTO streetname VALUES('candle leaf');\n    INSERT INTO streetname VALUES('canipe');\n    INSERT INTO streetname VALUES('canipe farm');\n    INSERT INTO streetname VALUES('cannon');\n    INSERT INTO streetname VALUES('canopy');\n    INSERT INTO streetname VALUES('canso');\n    INSERT INTO streetname VALUES('canterbrook');\n    INSERT INTO streetname VALUES('cardinal glen');\n    INSERT INTO streetname VALUES('cardinal point');\n    INSERT INTO streetname VALUES('cardinals nest');\n    INSERT INTO streetname VALUES('carlota');\n    INSERT INTO streetname VALUES('carmathen');\n    INSERT INTO streetname VALUES('carver');\n    INSERT INTO streetname VALUES('carver pond');\n    INSERT INTO streetname VALUES('casa loma');\n    INSERT INTO streetname VALUES('caselton');\n    INSERT INTO streetname VALUES('castello');\n    INSERT INTO streetname VALUES('castle ridge');\n    INSERT INTO streetname VALUES('castleglen');\n    INSERT INTO streetname VALUES('castlemaine');\n    INSERT INTO streetname VALUES('cavett');\n    INSERT INTO streetname VALUES('caymus');\n    INSERT INTO streetname VALUES('cedardale ridge');\n    INSERT INTO streetname VALUES('cedarhurst');\n    INSERT INTO streetname VALUES('cemkey way');\n    INSERT INTO streetname VALUES('cerise');\n    INSERT INTO streetname VALUES('chaceview');\n    INSERT INTO streetname VALUES('chadsworth');\n    INSERT INTO streetname VALUES('chadwell');\n    INSERT INTO streetname VALUES('champions crest');\n    INSERT INTO streetname VALUES('chandler haven');\n    INSERT INTO streetname VALUES('chapel crossing');\n    INSERT INTO streetname VALUES('chapel ridge');\n    INSERT INTO streetname VALUES('charles crawford');\n    INSERT INTO streetname VALUES('charminster');\n    INSERT INTO streetname VALUES('chasewind');\n    INSERT INTO streetname VALUES('chavel');\n    INSERT INTO streetname VALUES('chelsea jade');\n    INSERT INTO streetname VALUES('chestnut knoll');\n    INSERT INTO streetname VALUES('cheviot');\n    INSERT INTO streetname VALUES('chickadee');\n    INSERT INTO streetname VALUES('chidley');\n    INSERT INTO streetname VALUES('chimney ridge');\n    INSERT INTO streetname VALUES('chimney springs');\n    INSERT INTO streetname VALUES('chinaberry');\n    INSERT INTO streetname VALUES('chinemist');\n    INSERT INTO streetname VALUES('chinquapin');\n    INSERT INTO streetname VALUES('chiswell');\n    INSERT INTO streetname VALUES('christenbury');\n    INSERT INTO streetname VALUES('christenbury hills');\n    INSERT INTO streetname VALUES('churchill');\n    INSERT INTO streetname VALUES('cindy');\n    INSERT INTO streetname VALUES('cinnamon teal');\n    INSERT INTO streetname VALUES('citadel');\n    INSERT INTO streetname VALUES('clare olivia');\n    INSERT INTO streetname VALUES('clarke creek');\n    INSERT INTO streetname VALUES('clarke ridge');\n    INSERT INTO streetname VALUES('clear day');\n    INSERT INTO streetname VALUES('clear stream');\n    INSERT INTO streetname VALUES('cleve brown');\n    INSERT INTO streetname VALUES('cliff cameron');\n    INSERT INTO streetname VALUES('cliffvale');\n    INSERT INTO streetname VALUES('cloverside');\n    INSERT INTO streetname VALUES('clymer');\n    INSERT INTO streetname VALUES('coatbridge');\n    INSERT INTO streetname VALUES('cobble glen');\n    INSERT INTO streetname VALUES('cochran farm');\n    INSERT INTO streetname VALUES('cochrane');\n    INSERT INTO streetname VALUES('coleridge');\n    INSERT INTO streetname VALUES('coleshire');\n    INSERT INTO streetname VALUES('collins');\n    INSERT INTO streetname VALUES('colvard');\n    INSERT INTO streetname VALUES('colvard park');\n    INSERT INTO streetname VALUES('condor');\n    INSERT INTO streetname VALUES('conner ridge');\n    INSERT INTO streetname VALUES('connery');\n    INSERT INTO streetname VALUES('cooper run');\n    INSERT INTO streetname VALUES('coopers ridge');\n    INSERT INTO streetname VALUES('copper hill');\n    INSERT INTO streetname VALUES('coppermine');\n    INSERT INTO streetname VALUES('cornelia');\n    INSERT INTO streetname VALUES('corner');\n    INSERT INTO streetname VALUES('cornerstone');\n    INSERT INTO streetname VALUES('cottage oaks');\n    INSERT INTO streetname VALUES('cougar');\n    INSERT INTO streetname VALUES('coves end');\n    INSERT INTO streetname VALUES('cragland');\n    INSERT INTO streetname VALUES('crail');\n    INSERT INTO streetname VALUES('cranberry nook');\n    INSERT INTO streetname VALUES('crawford brook');\n    INSERT INTO streetname VALUES('crayton');\n    INSERT INTO streetname VALUES('creek breeze');\n    INSERT INTO streetname VALUES('crescent ridge');\n    INSERT INTO streetname VALUES('crescent view');\n    INSERT INTO streetname VALUES('cresta');\n    INSERT INTO streetname VALUES('crestfield');\n    INSERT INTO streetname VALUES('crestland');\n    INSERT INTO streetname VALUES('crestwick');\n    INSERT INTO streetname VALUES('crisfield');\n    INSERT INTO streetname VALUES('crisp wood');\n    INSERT INTO streetname VALUES('croft haven');\n    INSERT INTO streetname VALUES('crofton springs');\n    INSERT INTO streetname VALUES('cross');\n    INSERT INTO streetname VALUES('crosspoint center');\n    INSERT INTO streetname VALUES('crownvista');\n    INSERT INTO streetname VALUES('crystal arms');\n    INSERT INTO streetname VALUES('crystal crest');\n    INSERT INTO streetname VALUES('crystal leaf');\n    INSERT INTO streetname VALUES('cunningham park');\n    INSERT INTO streetname VALUES('cypress pond');\n    INSERT INTO streetname VALUES('daffodil');\n    INSERT INTO streetname VALUES('daisyfield');\n    INSERT INTO streetname VALUES('dalecrest');\n    INSERT INTO streetname VALUES('dannelly park');\n    INSERT INTO streetname VALUES('daphne');\n    INSERT INTO streetname VALUES('daria');\n    INSERT INTO streetname VALUES('dartmouth');\n    INSERT INTO streetname VALUES('datha');\n    INSERT INTO streetname VALUES('david cox');\n    INSERT INTO streetname VALUES('davis');\n    INSERT INTO streetname VALUES('davis crossing');\n    INSERT INTO streetname VALUES('davis lake');\n    INSERT INTO streetname VALUES('davis ridge');\n    INSERT INTO streetname VALUES('dawnmist');\n    INSERT INTO streetname VALUES('daybreak');\n    INSERT INTO streetname VALUES('dearmon');\n    INSERT INTO streetname VALUES('dearview');\n    INSERT INTO streetname VALUES('deaton hill');\n    INSERT INTO streetname VALUES('deer cross');\n    INSERT INTO streetname VALUES('deerton');\n    INSERT INTO streetname VALUES('degrasse');\n    INSERT INTO streetname VALUES('delamere');\n    INSERT INTO streetname VALUES('dellfield');\n    INSERT INTO streetname VALUES('dellinger');\n    INSERT INTO streetname VALUES('demington');\n    INSERT INTO streetname VALUES('denmeade');\n    INSERT INTO streetname VALUES('derita');\n    INSERT INTO streetname VALUES('derita woods');\n    INSERT INTO streetname VALUES('deruyter');\n    INSERT INTO streetname VALUES('dervish');\n    INSERT INTO streetname VALUES('devas');\n    INSERT INTO streetname VALUES('devon croft');\n    INSERT INTO streetname VALUES('devonbridge');\n    INSERT INTO streetname VALUES('devongate');\n    INSERT INTO streetname VALUES('devonhill');\n    INSERT INTO streetname VALUES('dewmorn');\n    INSERT INTO streetname VALUES('distribution center');\n    INSERT INTO streetname VALUES('dominion crest');\n    INSERT INTO streetname VALUES('dominion green');\n    INSERT INTO streetname VALUES('dominion village');\n    INSERT INTO streetname VALUES('dorshire');\n    INSERT INTO streetname VALUES('double creek crossing');\n    INSERT INTO streetname VALUES('dow');\n    INSERT INTO streetname VALUES('downfield wood');\n    INSERT INTO streetname VALUES('downing creek');\n    INSERT INTO streetname VALUES('driscol');\n    INSERT INTO streetname VALUES('driwood');\n    INSERT INTO streetname VALUES('dry brook');\n    INSERT INTO streetname VALUES('dumont');\n    INSERT INTO streetname VALUES('dunblane');\n    INSERT INTO streetname VALUES('dunfield');\n    INSERT INTO streetname VALUES('dunoon');\n    INSERT INTO streetname VALUES('dunslow');\n    INSERT INTO streetname VALUES('dunstaff');\n    INSERT INTO streetname VALUES('durham');\n    INSERT INTO streetname VALUES('durston');\n    INSERT INTO streetname VALUES('dusty cedar');\n    INSERT INTO streetname VALUES('dusty trail');\n    INSERT INTO streetname VALUES('dutchess');\n    INSERT INTO streetname VALUES('duxford');\n    INSERT INTO streetname VALUES('eagle creek');\n    INSERT INTO streetname VALUES('eagles field');\n    INSERT INTO streetname VALUES('eargle');\n    INSERT INTO streetname VALUES('earlswood');\n    INSERT INTO streetname VALUES('early mist');\n    INSERT INTO streetname VALUES('earthenware');\n    INSERT INTO streetname VALUES('eastfield park');\n    INSERT INTO streetname VALUES('eastfield village');\n    INSERT INTO streetname VALUES('easy');\n    INSERT INTO streetname VALUES('eben');\n    INSERT INTO streetname VALUES('edgepine');\n    INSERT INTO streetname VALUES('edgewier');\n    INSERT INTO streetname VALUES('edinburgh');\n    INSERT INTO streetname VALUES('edinmeadow');\n    INSERT INTO streetname VALUES('edmonton');\n    INSERT INTO streetname VALUES('edwin jones');\n    INSERT INTO streetname VALUES('elberon');\n    INSERT INTO streetname VALUES('elderslie');\n    INSERT INTO streetname VALUES('elementary view');\n    INSERT INTO streetname VALUES('elendil');\n    INSERT INTO streetname VALUES('elizabeth');\n    INSERT INTO streetname VALUES('elm cove');\n    INSERT INTO streetname VALUES('elrond');\n    INSERT INTO streetname VALUES('elsenham');\n    INSERT INTO streetname VALUES('elven');\n    INSERT INTO streetname VALUES('emma lynn');\n    INSERT INTO streetname VALUES('english setter');\n    INSERT INTO streetname VALUES('enoch');\n    INSERT INTO streetname VALUES('equipment');\n    INSERT INTO streetname VALUES('ernest russell');\n    INSERT INTO streetname VALUES('ernie');\n    INSERT INTO streetname VALUES('esmeralda');\n    INSERT INTO streetname VALUES('evergreen hollow');\n    INSERT INTO streetname VALUES('eversfield');\n    INSERT INTO streetname VALUES('ewen');\n    INSERT INTO streetname VALUES('ewert cut');\n    INSERT INTO streetname VALUES('exbury');\n    INSERT INTO streetname VALUES('fair grounds park');\n    INSERT INTO streetname VALUES('fairbourne');\n    INSERT INTO streetname VALUES('fairchase');\n    INSERT INTO streetname VALUES('faircreek');\n    INSERT INTO streetname VALUES('fairglen');\n    INSERT INTO streetname VALUES('fairlea');\n    INSERT INTO streetname VALUES('fairmead');\n    INSERT INTO streetname VALUES('fairmeadows');\n    INSERT INTO streetname VALUES('fairstone');\n    INSERT INTO streetname VALUES('fairvista');\n    INSERT INTO streetname VALUES('fairway point');\n    INSERT INTO streetname VALUES('falconcrest');\n    INSERT INTO streetname VALUES('falls ridge');\n    INSERT INTO streetname VALUES('falmouth');\n    INSERT INTO streetname VALUES('far west');\n    INSERT INTO streetname VALUES('farlow');\n    INSERT INTO streetname VALUES('farris wheel');\n    INSERT INTO streetname VALUES('fawndale');\n    INSERT INTO streetname VALUES('feather bend');\n    INSERT INTO streetname VALUES('fernledge');\n    INSERT INTO streetname VALUES('fernmoss');\n    INSERT INTO streetname VALUES('ferrell commons');\n    INSERT INTO streetname VALUES('fieldstone');\n    INSERT INTO streetname VALUES('fillian');\n    INSERT INTO streetname VALUES('fincher');\n    INSERT INTO streetname VALUES('foggy meadow');\n    INSERT INTO streetname VALUES('fordyce');\n    INSERT INTO streetname VALUES('forest grove');\n    INSERT INTO streetname VALUES('forest path');\n    INSERT INTO streetname VALUES('forestridge commons');\n    INSERT INTO streetname VALUES('forestrock');\n    INSERT INTO streetname VALUES('fortunes ridge');\n    INSERT INTO streetname VALUES('founders club');\n    INSERT INTO streetname VALUES('fountaingrass');\n    INSERT INTO streetname VALUES('fox chase');\n    INSERT INTO streetname VALUES('fox glen');\n    INSERT INTO streetname VALUES('fox hill');\n    INSERT INTO streetname VALUES('fox point');\n    INSERT INTO streetname VALUES('fox trot');\n    INSERT INTO streetname VALUES('foxbriar');\n    INSERT INTO streetname VALUES('frank little');\n    INSERT INTO streetname VALUES('franzia');\n    INSERT INTO streetname VALUES('french woods');\n    INSERT INTO streetname VALUES('frostmoor');\n    INSERT INTO streetname VALUES('frye');\n    INSERT INTO streetname VALUES('furlong');\n    INSERT INTO streetname VALUES('galena view');\n    INSERT INTO streetname VALUES('gallery pointe');\n    INSERT INTO streetname VALUES('gammon');\n    INSERT INTO streetname VALUES('garden grove');\n    INSERT INTO streetname VALUES('gardendale');\n    INSERT INTO streetname VALUES('garganey');\n    INSERT INTO streetname VALUES('garnet field');\n    INSERT INTO streetname VALUES('garrison');\n    INSERT INTO streetname VALUES('garvin');\n    INSERT INTO streetname VALUES('garvis');\n    INSERT INTO streetname VALUES('gaskill');\n    INSERT INTO streetname VALUES('gemstone');\n    INSERT INTO streetname VALUES('gibbon');\n    INSERT INTO streetname VALUES('gibbon terrace');\n    INSERT INTO streetname VALUES('gibbons link');\n    INSERT INTO streetname VALUES('gillman');\n    INSERT INTO streetname VALUES('gladwood');\n    INSERT INTO streetname VALUES('gladwyne');\n    INSERT INTO streetname VALUES('glamorgan');\n    INSERT INTO streetname VALUES('glaze');\n    INSERT INTO streetname VALUES('glen brook');\n    INSERT INTO streetname VALUES('glen cove');\n    INSERT INTO streetname VALUES('glen hope');\n    INSERT INTO streetname VALUES('glen manor');\n    INSERT INTO streetname VALUES('glen olden');\n    INSERT INTO streetname VALUES('glencairn');\n    INSERT INTO streetname VALUES('glendock');\n    INSERT INTO streetname VALUES('glenolden');\n    INSERT INTO streetname VALUES('glenover');\n    INSERT INTO streetname VALUES('glenshire');\n    INSERT INTO streetname VALUES('glenstone');\n    INSERT INTO streetname VALUES('gold dust');\n    INSERT INTO streetname VALUES('golden pond');\n    INSERT INTO streetname VALUES('goldenblush');\n    INSERT INTO streetname VALUES('goldenfield');\n    INSERT INTO streetname VALUES('goose landing');\n    INSERT INTO streetname VALUES('gorham gate');\n    INSERT INTO streetname VALUES('grabill');\n    INSERT INTO streetname VALUES('graburns ford');\n    INSERT INTO streetname VALUES('graham');\n    INSERT INTO streetname VALUES('grahamson');\n    INSERT INTO streetname VALUES('granard');\n    INSERT INTO streetname VALUES('grand teton');\n    INSERT INTO streetname VALUES('grande heights');\n    INSERT INTO streetname VALUES('grandeur');\n    INSERT INTO streetname VALUES('granite creek');\n    INSERT INTO streetname VALUES('grasset');\n    INSERT INTO streetname VALUES('graypark');\n    INSERT INTO streetname VALUES('grays ridge');\n    INSERT INTO streetname VALUES('great bear');\n    INSERT INTO streetname VALUES('green clover');\n    INSERT INTO streetname VALUES('green hedge');\n    INSERT INTO streetname VALUES('green meadow');\n    INSERT INTO streetname VALUES('green pasture');\n    INSERT INTO streetname VALUES('greene');\n    INSERT INTO streetname VALUES('greenloch');\n    INSERT INTO streetname VALUES('greenock ridge');\n    INSERT INTO streetname VALUES('greenware');\n    INSERT INTO streetname VALUES('greenway village');\n    INSERT INTO streetname VALUES('grenelefe village');\n    INSERT INTO streetname VALUES('grey dogwood');\n    INSERT INTO streetname VALUES('greyhound');\n    INSERT INTO streetname VALUES('greylock ridge');\n    INSERT INTO streetname VALUES('grosbeak');\n    INSERT INTO streetname VALUES('grove');\n    INSERT INTO streetname VALUES('groveton');\n    INSERT INTO streetname VALUES('groveview');\n    INSERT INTO streetname VALUES('hackberry creek');\n    INSERT INTO streetname VALUES('hackberry grove');\n    INSERT INTO streetname VALUES('hackett');\n    INSERT INTO streetname VALUES('haddington');\n    INSERT INTO streetname VALUES('hagler');\n    INSERT INTO streetname VALUES('halcott');\n    INSERT INTO streetname VALUES('half dome');\n    INSERT INTO streetname VALUES('hallam');\n    INSERT INTO streetname VALUES('hamilton russell');\n    INSERT INTO streetname VALUES('hampton place');\n    INSERT INTO streetname VALUES('hankins');\n    INSERT INTO streetname VALUES('harburn forest');\n    INSERT INTO streetname VALUES('harringham');\n    INSERT INTO streetname VALUES('harrington woods');\n    INSERT INTO streetname VALUES('harris corners');\n    INSERT INTO streetname VALUES('harris cove');\n    INSERT INTO streetname VALUES('harris glen');\n    INSERT INTO streetname VALUES('harris hill');\n    INSERT INTO streetname VALUES('harris oak');\n    INSERT INTO streetname VALUES('harris pointe');\n    INSERT INTO streetname VALUES('harris pond');\n    INSERT INTO streetname VALUES('harris ridge');\n    INSERT INTO streetname VALUES('harris technology');\n    INSERT INTO streetname VALUES('harris woods');\n    INSERT INTO streetname VALUES('hartfield downs');\n    INSERT INTO streetname VALUES('hattie little');\n    INSERT INTO streetname VALUES('hatwynn');\n    INSERT INTO streetname VALUES('hawkins');\n    INSERT INTO streetname VALUES('hawksnest');\n    INSERT INTO streetname VALUES('haybridge');\n    INSERT INTO streetname VALUES('hayden');\n    INSERT INTO streetname VALUES('hazelcroft');\n    INSERT INTO streetname VALUES('hazlitt');\n    INSERT INTO streetname VALUES('hazy valley');\n    INSERT INTO streetname VALUES('hearst');\n    INSERT INTO streetname VALUES('heathcrest');\n    INSERT INTO streetname VALUES('heathcroft');\n    INSERT INTO streetname VALUES('hedge maple');\n    INSERT INTO streetname VALUES('hedgecrest');\n    INSERT INTO streetname VALUES('hedingham');\n    INSERT INTO streetname VALUES('heman');\n    INSERT INTO streetname VALUES('henderson');\n    INSERT INTO streetname VALUES('henderson oaks');\n    INSERT INTO streetname VALUES('henderson valley');\n    INSERT INTO streetname VALUES('hendry');\n    INSERT INTO streetname VALUES('heritage hills');\n    INSERT INTO streetname VALUES('heritage woods');\n    INSERT INTO streetname VALUES('heron cove');\n    INSERT INTO streetname VALUES('heron glen');\n    INSERT INTO streetname VALUES('hewitt');\n    INSERT INTO streetname VALUES('hey rock');\n    INSERT INTO streetname VALUES('heysham');\n    INSERT INTO streetname VALUES('hickory cove');\n    INSERT INTO streetname VALUES('hidden meadow');\n    INSERT INTO streetname VALUES('high glen');\n    INSERT INTO streetname VALUES('high laurel');\n    INSERT INTO streetname VALUES('high valley');\n    INSERT INTO streetname VALUES('highcroft');\n    INSERT INTO streetname VALUES('highland');\n    INSERT INTO streetname VALUES('highland commons');\n    INSERT INTO streetname VALUES('highland creek');\n    INSERT INTO streetname VALUES('highland glen');\n    INSERT INTO streetname VALUES('highland park');\n    INSERT INTO streetname VALUES('highlander');\n    INSERT INTO streetname VALUES('highstream');\n    INSERT INTO streetname VALUES('hilltop');\n    INSERT INTO streetname VALUES('hobbitshire');\n    INSERT INTO streetname VALUES('hoffman');\n    INSERT INTO streetname VALUES('hogans way');\n    INSERT INTO streetname VALUES('holbert');\n    INSERT INTO streetname VALUES('hollow ridge');\n    INSERT INTO streetname VALUES('holly vista');\n    INSERT INTO streetname VALUES('hollywood');\n    INSERT INTO streetname VALUES('hoover');\n    INSERT INTO streetname VALUES('hopkins');\n    INSERT INTO streetname VALUES('horace mann');\n    INSERT INTO streetname VALUES('hornbeam');\n    INSERT INTO streetname VALUES('horse pasture');\n    INSERT INTO streetname VALUES('hosta');\n    INSERT INTO streetname VALUES('howard');\n    INSERT INTO streetname VALUES('hubbard');\n    INSERT INTO streetname VALUES('hubbard falls');\n    INSERT INTO streetname VALUES('hubbard woods');\n    INSERT INTO streetname VALUES('hucks');\n    INSERT INTO streetname VALUES('hunters creek');\n    INSERT INTO streetname VALUES('hunters pointe');\n    INSERT INTO streetname VALUES('hunters spring');\n    INSERT INTO streetname VALUES('hunters whip');\n    INSERT INTO streetname VALUES('huntmeadow');\n    INSERT INTO streetname VALUES('hutchison mcdonald');\n    INSERT INTO streetname VALUES('ingleton');\n    INSERT INTO streetname VALUES('insdale');\n    INSERT INTO streetname VALUES('interstate 85 service');\n    INSERT INTO streetname VALUES('iola');\n    INSERT INTO streetname VALUES('iredell');\n    INSERT INTO streetname VALUES('iron brigade');\n    INSERT INTO streetname VALUES('irwin valley');\n    INSERT INTO streetname VALUES('irwin wood');\n    INSERT INTO streetname VALUES('ivy brook');\n    INSERT INTO streetname VALUES('ivy ridge');\n    INSERT INTO streetname VALUES('jack russell');\n    INSERT INTO streetname VALUES('jackson');\n    INSERT INTO streetname VALUES('jacob martin');\n    INSERT INTO streetname VALUES('jamison');\n    INSERT INTO streetname VALUES('jane');\n    INSERT INTO streetname VALUES('jaspar crest');\n    INSERT INTO streetname VALUES('jessica');\n    INSERT INTO streetname VALUES('jimmy oehler');\n    INSERT INTO streetname VALUES('jocelyn');\n    INSERT INTO streetname VALUES('johnston mill');\n    INSERT INTO streetname VALUES('johnston oehler');\n    INSERT INTO streetname VALUES('judal');\n    INSERT INTO streetname VALUES('junipeous');\n    INSERT INTO streetname VALUES('juniper');\n    INSERT INTO streetname VALUES('juniperus');\n    INSERT INTO streetname VALUES('kalispell');\n    INSERT INTO streetname VALUES('karylsturn');\n    INSERT INTO streetname VALUES('katelyn');\n    INSERT INTO streetname VALUES('kayron');\n    INSERT INTO streetname VALUES('keaton');\n    INSERT INTO streetname VALUES('keble');\n    INSERT INTO streetname VALUES('keels');\n    INSERT INTO streetname VALUES('keith');\n    INSERT INTO streetname VALUES('keithwood');\n    INSERT INTO streetname VALUES('kelden walker');\n    INSERT INTO streetname VALUES('kelsey emma');\n    INSERT INTO streetname VALUES('kendrick');\n    INSERT INTO streetname VALUES('kenmont');\n    INSERT INTO streetname VALUES('kennerly cove');\n    INSERT INTO streetname VALUES('kenninghall');\n    INSERT INTO streetname VALUES('kent village');\n    INSERT INTO streetname VALUES('kestral ridge');\n    INSERT INTO streetname VALUES('kestrel');\n    INSERT INTO streetname VALUES('kilmartin');\n    INSERT INTO streetname VALUES('kilty');\n    INSERT INTO streetname VALUES('kinglet');\n    INSERT INTO streetname VALUES('kingsland');\n    INSERT INTO streetname VALUES('kingsnorth');\n    INSERT INTO streetname VALUES('kinsmore');\n    INSERT INTO streetname VALUES('kirkgard');\n    INSERT INTO streetname VALUES('kirkmont');\n    INSERT INTO streetname VALUES('knightsgate');\n    INSERT INTO streetname VALUES('kobuk');\n    INSERT INTO streetname VALUES('kotlik');\n    INSERT INTO streetname VALUES('kotz');\n    INSERT INTO streetname VALUES('kyndall walk');\n    INSERT INTO streetname VALUES('laborde');\n    INSERT INTO streetname VALUES('lady bank');\n    INSERT INTO streetname VALUES('lagrande');\n    INSERT INTO streetname VALUES('lake');\n    INSERT INTO streetname VALUES('lakeridge commons');\n    INSERT INTO streetname VALUES('lakeview');\n    INSERT INTO streetname VALUES('lakewood edge');\n    INSERT INTO streetname VALUES('lakota');\n    INSERT INTO streetname VALUES('lambrook');\n    INSERT INTO streetname VALUES('lampkin');\n    INSERT INTO streetname VALUES('lampkin park');\n    INSERT INTO streetname VALUES('langham');\n    INSERT INTO streetname VALUES('lanzerac manor');\n    INSERT INTO streetname VALUES('larkmead forest');\n    INSERT INTO streetname VALUES('lattice');\n    INSERT INTO streetname VALUES('laurel crest');\n    INSERT INTO streetname VALUES('laurel ridge');\n    INSERT INTO streetname VALUES('laurel run');\n    INSERT INTO streetname VALUES('laurenfield');\n    INSERT INTO streetname VALUES('laveta');\n    INSERT INTO streetname VALUES('lazy day');\n    INSERT INTO streetname VALUES('leawood run');\n    INSERT INTO streetname VALUES('lee marie');\n    INSERT INTO streetname VALUES('legacy lake');\n    INSERT INTO streetname VALUES('legacy park');\n    INSERT INTO streetname VALUES('legato');\n    INSERT INTO streetname VALUES('legolas');\n    INSERT INTO streetname VALUES('leigh glen');\n    INSERT INTO streetname VALUES('lence');\n    INSERT INTO streetname VALUES('lenox hill');\n    INSERT INTO streetname VALUES('leonine');\n    INSERT INTO streetname VALUES('leslie');\n    INSERT INTO streetname VALUES('lester hill');\n    INSERT INTO streetname VALUES('levisey');\n    INSERT INTO streetname VALUES('liberty bell');\n    INSERT INTO streetname VALUES('linden berry');\n    INSERT INTO streetname VALUES('lisbon');\n    INSERT INTO streetname VALUES('little stoney');\n    INSERT INTO streetname VALUES('livengood');\n    INSERT INTO streetname VALUES('lochway');\n    INSERT INTO streetname VALUES('lockman');\n    INSERT INTO streetname VALUES('loganville');\n    INSERT INTO streetname VALUES('lone tree');\n    INSERT INTO streetname VALUES('long creek park');\n    INSERT INTO streetname VALUES('long forest');\n    INSERT INTO streetname VALUES('looking glass');\n    INSERT INTO streetname VALUES('lookout point');\n    INSERT INTO streetname VALUES('lowen');\n    INSERT INTO streetname VALUES('lusby');\n    INSERT INTO streetname VALUES('lyleton');\n    INSERT INTO streetname VALUES('lynn lee');\n    INSERT INTO streetname VALUES('lynnewood glen');\n    INSERT INTO streetname VALUES('machrie');\n    INSERT INTO streetname VALUES('mackinac');\n    INSERT INTO streetname VALUES('maddox');\n    INSERT INTO streetname VALUES('madison park');\n    INSERT INTO streetname VALUES('mallard');\n    INSERT INTO streetname VALUES('mallard cove');\n    INSERT INTO streetname VALUES('mallard forest');\n    INSERT INTO streetname VALUES('mallard grove');\n    INSERT INTO streetname VALUES('mallard hill');\n    INSERT INTO streetname VALUES('mallard park');\n    INSERT INTO streetname VALUES('mallard ridge');\n    INSERT INTO streetname VALUES('mallard view');\n    INSERT INTO streetname VALUES('manbey');\n    INSERT INTO streetname VALUES('manning');\n    INSERT INTO streetname VALUES('mantario');\n    INSERT INTO streetname VALUES('maple');\n    INSERT INTO streetname VALUES('maple cove');\n    INSERT INTO streetname VALUES('maple park');\n    INSERT INTO streetname VALUES('marathon hill');\n    INSERT INTO streetname VALUES('marbury');\n    INSERT INTO streetname VALUES('marett');\n    INSERT INTO streetname VALUES('marigold');\n    INSERT INTO streetname VALUES('marionwood');\n    INSERT INTO streetname VALUES('marshbank');\n    INSERT INTO streetname VALUES('mason');\n    INSERT INTO streetname VALUES('mayapple');\n    INSERT INTO streetname VALUES('maylandia');\n    INSERT INTO streetname VALUES('mayspring');\n    INSERT INTO streetname VALUES('mcadam');\n    INSERT INTO streetname VALUES('mcchesney');\n    INSERT INTO streetname VALUES('mccurdy');\n    INSERT INTO streetname VALUES('mcgrath');\n    INSERT INTO streetname VALUES('mckendree');\n    INSERT INTO streetname VALUES('mclaughlin');\n    INSERT INTO streetname VALUES('mctaggart');\n    INSERT INTO streetname VALUES('meadow green');\n    INSERT INTO streetname VALUES('meadow knoll');\n    INSERT INTO streetname VALUES('meadow post');\n    INSERT INTO streetname VALUES('meadowmont');\n    INSERT INTO streetname VALUES('meadowmont view');\n    INSERT INTO streetname VALUES('meadowview hills');\n    INSERT INTO streetname VALUES('melshire');\n    INSERT INTO streetname VALUES('melstrand');\n    INSERT INTO streetname VALUES('mentone');\n    INSERT INTO streetname VALUES('meridale crossing');\n    INSERT INTO streetname VALUES('merion hills');\n    INSERT INTO streetname VALUES('merlot');\n    INSERT INTO streetname VALUES('mersham');\n    INSERT INTO streetname VALUES('metromont');\n    INSERT INTO streetname VALUES('metromont industrial');\n    INSERT INTO streetname VALUES('michaw');\n    INSERT INTO streetname VALUES('milhaven');\n    INSERT INTO streetname VALUES('milhof');\n    INSERT INTO streetname VALUES('millstream ridge');\n    INSERT INTO streetname VALUES('mineral ridge');\n    INSERT INTO streetname VALUES('mint thistle');\n    INSERT INTO streetname VALUES('mintleaf');\n    INSERT INTO streetname VALUES('mintvale');\n    INSERT INTO streetname VALUES('misty');\n    INSERT INTO streetname VALUES('misty arbor');\n    INSERT INTO streetname VALUES('misty creek');\n    INSERT INTO streetname VALUES('misty oaks');\n    INSERT INTO streetname VALUES('misty wood');\n    INSERT INTO streetname VALUES('mitzi deborah');\n    INSERT INTO streetname VALUES('mobile');\n    INSERT INTO streetname VALUES('molly elizabeth');\n    INSERT INTO streetname VALUES('monmouth');\n    INSERT INTO streetname VALUES('montrose');\n    INSERT INTO streetname VALUES('moonlight');\n    INSERT INTO streetname VALUES('moose');\n    INSERT INTO streetname VALUES('morning dew');\n    INSERT INTO streetname VALUES('morningsong');\n    INSERT INTO streetname VALUES('morningview');\n    INSERT INTO streetname VALUES('morsey');\n    INSERT INTO streetname VALUES('moss glen');\n    INSERT INTO streetname VALUES('mossy bank');\n    INSERT INTO streetname VALUES('motor sport');\n    INSERT INTO streetname VALUES('mountain laurel');\n    INSERT INTO streetname VALUES('mourning dove');\n    INSERT INTO streetname VALUES('mozart');\n    INSERT INTO streetname VALUES('munsing');\n    INSERT INTO streetname VALUES('murray');\n    INSERT INTO streetname VALUES('nathan');\n    INSERT INTO streetname VALUES('netherhall');\n    INSERT INTO streetname VALUES('netherton');\n    INSERT INTO streetname VALUES('neuhoff');\n    INSERT INTO streetname VALUES('nevin');\n    INSERT INTO streetname VALUES('nevin brook');\n    INSERT INTO streetname VALUES('nevin glen');\n    INSERT INTO streetname VALUES('nevin place');\n    INSERT INTO streetname VALUES('new england');\n    INSERT INTO streetname VALUES('new house');\n    INSERT INTO streetname VALUES('newbary');\n    INSERT INTO streetname VALUES('newchurch');\n    INSERT INTO streetname VALUES('newfane');\n    INSERT INTO streetname VALUES('newgard');\n    INSERT INTO streetname VALUES('nicholas');\n    INSERT INTO streetname VALUES('nicole');\n    INSERT INTO streetname VALUES('nobility');\n    INSERT INTO streetname VALUES('norcroft');\n    INSERT INTO streetname VALUES('northridge');\n    INSERT INTO streetname VALUES('northside');\n    INSERT INTO streetname VALUES('northwoods business');\n    INSERT INTO streetname VALUES('norway');\n    INSERT INTO streetname VALUES('nottinghill');\n    INSERT INTO streetname VALUES('numenore');\n    INSERT INTO streetname VALUES('nyewood');\n    INSERT INTO streetname VALUES('oak');\n    INSERT INTO streetname VALUES('oak cove');\n    INSERT INTO streetname VALUES('oak pasture');\n    INSERT INTO streetname VALUES('oakburn');\n    INSERT INTO streetname VALUES('oakwinds');\n    INSERT INTO streetname VALUES('oakwood');\n    INSERT INTO streetname VALUES('obrien');\n    INSERT INTO streetname VALUES('ocala');\n    INSERT INTO streetname VALUES('old bridge');\n    INSERT INTO streetname VALUES('old fox');\n    INSERT INTO streetname VALUES('old potters');\n    INSERT INTO streetname VALUES('old statesville');\n    INSERT INTO streetname VALUES('old steine');\n    INSERT INTO streetname VALUES('old stoney creek');\n    INSERT INTO streetname VALUES('old sugar creek');\n    INSERT INTO streetname VALUES('old timber');\n    INSERT INTO streetname VALUES('old wagon');\n    INSERT INTO streetname VALUES('old willow');\n    INSERT INTO streetname VALUES('oldenway');\n    INSERT INTO streetname VALUES('oneida');\n    INSERT INTO streetname VALUES('ontario');\n    INSERT INTO streetname VALUES('oriole');\n    INSERT INTO streetname VALUES('orofino');\n    INSERT INTO streetname VALUES('orr');\n    INSERT INTO streetname VALUES('osage');\n    INSERT INTO streetname VALUES('osceola');\n    INSERT INTO streetname VALUES('osprey knoll');\n    INSERT INTO streetname VALUES('oxford hill');\n    INSERT INTO streetname VALUES('painted fern');\n    INSERT INTO streetname VALUES('painted pony');\n    INSERT INTO streetname VALUES('paisley');\n    INSERT INTO streetname VALUES('pale moss');\n    INSERT INTO streetname VALUES('palladium');\n    INSERT INTO streetname VALUES('palmutum');\n    INSERT INTO streetname VALUES('palustris');\n    INSERT INTO streetname VALUES('panglemont');\n    INSERT INTO streetname VALUES('panther');\n    INSERT INTO streetname VALUES('panthersville');\n    INSERT INTO streetname VALUES('paper whites');\n    INSERT INTO streetname VALUES('park');\n    INSERT INTO streetname VALUES('parker green');\n    INSERT INTO streetname VALUES('parkhouse');\n    INSERT INTO streetname VALUES('passour ridge');\n    INSERT INTO streetname VALUES('pasture view');\n    INSERT INTO streetname VALUES('patricia ann');\n    INSERT INTO streetname VALUES('patton');\n    INSERT INTO streetname VALUES('patton ridge');\n    INSERT INTO streetname VALUES('pawpaw');\n    INSERT INTO streetname VALUES('peach');\n    INSERT INTO streetname VALUES('peakwood');\n    INSERT INTO streetname VALUES('pebble creek');\n    INSERT INTO streetname VALUES('pecan cove');\n    INSERT INTO streetname VALUES('pedigree');\n    INSERT INTO streetname VALUES('pelorus');\n    INSERT INTO streetname VALUES('penmore');\n    INSERT INTO streetname VALUES('pensfold');\n    INSERT INTO streetname VALUES('pepperstone');\n    INSERT INTO streetname VALUES('peregrine');\n    INSERT INTO streetname VALUES('periwinkle');\n    INSERT INTO streetname VALUES('perkins');\n    INSERT INTO streetname VALUES('pete brown');\n    INSERT INTO streetname VALUES('phillips');\n    INSERT INTO streetname VALUES('pickway');\n    INSERT INTO streetname VALUES('piercy woods');\n    INSERT INTO streetname VALUES('pierpoint');\n    INSERT INTO streetname VALUES('pine');\n    INSERT INTO streetname VALUES('pine branch');\n    INSERT INTO streetname VALUES('pine meadow');\n    INSERT INTO streetname VALUES('pineleaf');\n    INSERT INTO streetname VALUES('pinewood');\n    INSERT INTO streetname VALUES('pintail');\n    INSERT INTO streetname VALUES('pipestone');\n    INSERT INTO streetname VALUES('placer maple');\n    INSERT INTO streetname VALUES('plover');\n    INSERT INTO streetname VALUES('plum');\n    INSERT INTO streetname VALUES('po box');\n    INSERT INTO streetname VALUES('pochard');\n    INSERT INTO streetname VALUES('pointview');\n    INSERT INTO streetname VALUES('polk and white');\n    INSERT INTO streetname VALUES('pond valley');\n    INSERT INTO streetname VALUES('pondridge');\n    INSERT INTO streetname VALUES('pope farm');\n    INSERT INTO streetname VALUES('poplar grove');\n    INSERT INTO streetname VALUES('poplar springs');\n    INSERT INTO streetname VALUES('portola');\n    INSERT INTO streetname VALUES('potters glen');\n    INSERT INTO streetname VALUES('powatan');\n    INSERT INTO streetname VALUES('prairie valley');\n    INSERT INTO streetname VALUES('prescott');\n    INSERT INTO streetname VALUES('presmann');\n    INSERT INTO streetname VALUES('prestigious');\n    INSERT INTO streetname VALUES('princess');\n    INSERT INTO streetname VALUES('prosperity');\n    INSERT INTO streetname VALUES('prosperity church');\n    INSERT INTO streetname VALUES('prosperity commons');\n    INSERT INTO streetname VALUES('prosperity park');\n    INSERT INTO streetname VALUES('prosperity point');\n    INSERT INTO streetname VALUES('prosperity ridge');\n    INSERT INTO streetname VALUES('prosperity view');\n    INSERT INTO streetname VALUES('purple finch');\n    INSERT INTO streetname VALUES('quail');\n    INSERT INTO streetname VALUES('queensbury');\n    INSERT INTO streetname VALUES('quinn');\n    INSERT INTO streetname VALUES('racine');\n    INSERT INTO streetname VALUES('radbourne');\n    INSERT INTO streetname VALUES('raddington');\n    INSERT INTO streetname VALUES('raku');\n    INSERT INTO streetname VALUES('rancliffe');\n    INSERT INTO streetname VALUES('ravencrest');\n    INSERT INTO streetname VALUES('reames');\n    INSERT INTO streetname VALUES('rebecca run');\n    INSERT INTO streetname VALUES('red bluff');\n    INSERT INTO streetname VALUES('red clay');\n    INSERT INTO streetname VALUES('red clover');\n    INSERT INTO streetname VALUES('red rose');\n    INSERT INTO streetname VALUES('red shed');\n    INSERT INTO streetname VALUES('red tail');\n    INSERT INTO streetname VALUES('redbridge');\n    INSERT INTO streetname VALUES('redstart');\n    INSERT INTO streetname VALUES('redstone view');\n    INSERT INTO streetname VALUES('reedmont');\n    INSERT INTO streetname VALUES('reeves');\n    INSERT INTO streetname VALUES('regal');\n    INSERT INTO streetname VALUES('reinbeck');\n    INSERT INTO streetname VALUES('retriever');\n    INSERT INTO streetname VALUES('ribbonwalk');\n    INSERT INTO streetname VALUES('richardson park');\n    INSERT INTO streetname VALUES('richfield');\n    INSERT INTO streetname VALUES('riddings');\n    INSERT INTO streetname VALUES('ridge');\n    INSERT INTO streetname VALUES('ridge cliff');\n    INSERT INTO streetname VALUES('ridge path');\n    INSERT INTO streetname VALUES('ridge peak');\n    INSERT INTO streetname VALUES('ridgefield');\n    INSERT INTO streetname VALUES('ridgeline');\n    INSERT INTO streetname VALUES('ridgeview commons');\n    INSERT INTO streetname VALUES('riley');\n    INSERT INTO streetname VALUES('riley woods');\n    INSERT INTO streetname VALUES('rillet');\n    INSERT INTO streetname VALUES('rindle');\n    INSERT INTO streetname VALUES('rivendell');\n    INSERT INTO streetname VALUES('robin');\n    INSERT INTO streetname VALUES('robins nest');\n    INSERT INTO streetname VALUES('robur');\n    INSERT INTO streetname VALUES('robyns glen');\n    INSERT INTO streetname VALUES('rock stream');\n    INSERT INTO streetname VALUES('rockwell');\n    INSERT INTO streetname VALUES('rockwell church');\n    INSERT INTO streetname VALUES('rocky brook');\n    INSERT INTO streetname VALUES('rocky ford club');\n    INSERT INTO streetname VALUES('rotary');\n    INSERT INTO streetname VALUES('rouda');\n    INSERT INTO streetname VALUES('royal bluff');\n    INSERT INTO streetname VALUES('royal celadon');\n    INSERT INTO streetname VALUES('rubin lura');\n    INSERT INTO streetname VALUES('runswyck');\n    INSERT INTO streetname VALUES('ruth ferrell');\n    INSERT INTO streetname VALUES('ruth polk');\n    INSERT INTO streetname VALUES('ryan jay');\n    INSERT INTO streetname VALUES('sackett');\n    INSERT INTO streetname VALUES('saddle pace');\n    INSERT INTO streetname VALUES('saddle run');\n    INSERT INTO streetname VALUES('saddle trail');\n    INSERT INTO streetname VALUES('saguaro');\n    INSERT INTO streetname VALUES('saint audrey');\n    INSERT INTO streetname VALUES('saint bernard');\n    INSERT INTO streetname VALUES('saint frances');\n    INSERT INTO streetname VALUES('sam roper');\n    INSERT INTO streetname VALUES('samara');\n    INSERT INTO streetname VALUES('sanders creek');\n    INSERT INTO streetname VALUES('saquache');\n    INSERT INTO streetname VALUES('sarnia');\n    INSERT INTO streetname VALUES('savannah springs');\n    INSERT INTO streetname VALUES('sawgrass ridge');\n    INSERT INTO streetname VALUES('saxonbury');\n    INSERT INTO streetname VALUES('scotch moss');\n    INSERT INTO streetname VALUES('seasons');\n    INSERT INTO streetname VALUES('serenity');\n    INSERT INTO streetname VALUES('seths');\n    INSERT INTO streetname VALUES('shadow lawn');\n    INSERT INTO streetname VALUES('shadow oaks');\n    INSERT INTO streetname VALUES('shadow pine');\n    INSERT INTO streetname VALUES('shadyside');\n    INSERT INTO streetname VALUES('shallow oak');\n    INSERT INTO streetname VALUES('shelley');\n    INSERT INTO streetname VALUES('shining oak');\n    INSERT INTO streetname VALUES('ship');\n    INSERT INTO streetname VALUES('shore haven');\n    INSERT INTO streetname VALUES('shuman');\n    INSERT INTO streetname VALUES('sidney');\n    INSERT INTO streetname VALUES('silver birch');\n    INSERT INTO streetname VALUES('silvermere');\n    INSERT INTO streetname VALUES('simonton');\n    INSERT INTO streetname VALUES('singing hills');\n    INSERT INTO streetname VALUES('singing oak');\n    INSERT INTO streetname VALUES('sipes');\n    INSERT INTO streetname VALUES('six point');\n    INSERT INTO streetname VALUES('skycrest');\n    INSERT INTO streetname VALUES('skyline');\n    INSERT INTO streetname VALUES('small');\n    INSERT INTO streetname VALUES('smith corners');\n    INSERT INTO streetname VALUES('smithwood');\n    INSERT INTO streetname VALUES('snow hill');\n    INSERT INTO streetname VALUES('soapstone');\n    INSERT INTO streetname VALUES('sobeck');\n    INSERT INTO streetname VALUES('socata');\n    INSERT INTO streetname VALUES('solace');\n    INSERT INTO streetname VALUES('solway');\n    INSERT INTO streetname VALUES('song sparrow');\n    INSERT INTO streetname VALUES('sorrento');\n    INSERT INTO streetname VALUES('spector');\n    INSERT INTO streetname VALUES('spin drift');\n    INSERT INTO streetname VALUES('spring crest');\n    INSERT INTO streetname VALUES('spring lee');\n    INSERT INTO streetname VALUES('spring park');\n    INSERT INTO streetname VALUES('spring terrace');\n    INSERT INTO streetname VALUES('spring trace');\n    INSERT INTO streetname VALUES('springhaven');\n    INSERT INTO streetname VALUES('squirrel trail');\n    INSERT INTO streetname VALUES('stardust');\n    INSERT INTO streetname VALUES('stargaze');\n    INSERT INTO streetname VALUES('starita');\n    INSERT INTO streetname VALUES('starmount');\n    INSERT INTO streetname VALUES('statesville');\n    INSERT INTO streetname VALUES('steed');\n    INSERT INTO streetname VALUES('steelewood');\n    INSERT INTO streetname VALUES('steepleglen');\n    INSERT INTO streetname VALUES('stephens farm');\n    INSERT INTO streetname VALUES('stewarton');\n    INSERT INTO streetname VALUES('stone park');\n    INSERT INTO streetname VALUES('stonebrook');\n    INSERT INTO streetname VALUES('stonefield');\n    INSERT INTO streetname VALUES('stoneglen');\n    INSERT INTO streetname VALUES('stonemarsh');\n    INSERT INTO streetname VALUES('stoney garden');\n    INSERT INTO streetname VALUES('stoney run');\n    INSERT INTO streetname VALUES('stoney valley');\n    INSERT INTO streetname VALUES('stoneykirk');\n    INSERT INTO streetname VALUES('stream bank');\n    INSERT INTO streetname VALUES('stream ridge');\n    INSERT INTO streetname VALUES('suburban');\n    INSERT INTO streetname VALUES('suffield');\n    INSERT INTO streetname VALUES('sugar creek');\n    INSERT INTO streetname VALUES('sugarberry');\n    INSERT INTO streetname VALUES('sugarstone');\n    INSERT INTO streetname VALUES('summer creek');\n    INSERT INTO streetname VALUES('summer valley');\n    INSERT INTO streetname VALUES('summercrest');\n    INSERT INTO streetname VALUES('summercroft');\n    INSERT INTO streetname VALUES('summerford');\n    INSERT INTO streetname VALUES('summergold');\n    INSERT INTO streetname VALUES('sunbeam');\n    INSERT INTO streetname VALUES('sunbridge');\n    INSERT INTO streetname VALUES('sunpath');\n    INSERT INTO streetname VALUES('sunset');\n    INSERT INTO streetname VALUES('sunset ridge');\n    INSERT INTO streetname VALUES('sunstone');\n    INSERT INTO streetname VALUES('suntrace');\n    INSERT INTO streetname VALUES('sunwalk');\n    INSERT INTO streetname VALUES('sutters hill');\n    INSERT INTO streetname VALUES('suttonview');\n    INSERT INTO streetname VALUES('swallow tail');\n    INSERT INTO streetname VALUES('swanston');\n    INSERT INTO streetname VALUES('sweet grove');\n    INSERT INTO streetname VALUES('sweet rose');\n    INSERT INTO streetname VALUES('sweetbriar ridge');\n    INSERT INTO streetname VALUES('sweetfield');\n    INSERT INTO streetname VALUES('sydney overlook');\n    INSERT INTO streetname VALUES('sylvan');\n    INSERT INTO streetname VALUES('symphony woods');\n    INSERT INTO streetname VALUES('tallia');\n    INSERT INTO streetname VALUES('tallu');\n    INSERT INTO streetname VALUES('talwyn');\n    INSERT INTO streetname VALUES('tanager');\n    INSERT INTO streetname VALUES('tanager park');\n    INSERT INTO streetname VALUES('tangley');\n    INSERT INTO streetname VALUES('taranasay');\n    INSERT INTO streetname VALUES('tarby');\n    INSERT INTO streetname VALUES('tarland');\n    INSERT INTO streetname VALUES('tarpway');\n    INSERT INTO streetname VALUES('tauten');\n    INSERT INTO streetname VALUES('taymouth');\n    INSERT INTO streetname VALUES('ten trees');\n    INSERT INTO streetname VALUES('terrace view');\n    INSERT INTO streetname VALUES('terrier');\n    INSERT INTO streetname VALUES('tesh');\n    INSERT INTO streetname VALUES('teton');\n    INSERT INTO streetname VALUES('tewkesbury');\n    INSERT INTO streetname VALUES('thelema');\n    INSERT INTO streetname VALUES('thistle bloom');\n    INSERT INTO streetname VALUES('thistledown');\n    INSERT INTO streetname VALUES('thomas ridge');\n    INSERT INTO streetname VALUES('thornbrook');\n    INSERT INTO streetname VALUES('tifton grass');\n    INSERT INTO streetname VALUES('tigerton');\n    INSERT INTO streetname VALUES('tomsie efird');\n    INSERT INTO streetname VALUES('tor');\n    INSERT INTO streetname VALUES('torphin');\n    INSERT INTO streetname VALUES('torrence');\n    INSERT INTO streetname VALUES('towering pine');\n    INSERT INTO streetname VALUES('towhee');\n    INSERT INTO streetname VALUES('toxaway');\n    INSERT INTO streetname VALUES('tracy glenn');\n    INSERT INTO streetname VALUES('tradition view');\n    INSERT INTO streetname VALUES('trailer');\n    INSERT INTO streetname VALUES('transport');\n    INSERT INTO streetname VALUES('trehurst');\n    INSERT INTO streetname VALUES('trexler');\n    INSERT INTO streetname VALUES('trillium fields');\n    INSERT INTO streetname VALUES('trimbach');\n    INSERT INTO streetname VALUES('tucker');\n    INSERT INTO streetname VALUES('tullamore');\n    INSERT INTO streetname VALUES('tullock creek');\n    INSERT INTO streetname VALUES('tunston');\n    INSERT INTO streetname VALUES('tupelo');\n    INSERT INTO streetname VALUES('turnabout');\n    INSERT INTO streetname VALUES('turney');\n    INSERT INTO streetname VALUES('turtle cross');\n    INSERT INTO streetname VALUES('turtleback');\n    INSERT INTO streetname VALUES('twelvestone');\n    INSERT INTO streetname VALUES('twin');\n    INSERT INTO streetname VALUES('twin brook');\n    INSERT INTO streetname VALUES('twin lakes');\n    INSERT INTO streetname VALUES('twisted pine');\n    INSERT INTO streetname VALUES('tyler finley');\n    INSERT INTO streetname VALUES('university station');\n    INSERT INTO streetname VALUES('uphill');\n    INSERT INTO streetname VALUES('valeview');\n    INSERT INTO streetname VALUES('valhalla');\n    INSERT INTO streetname VALUES('van');\n    INSERT INTO streetname VALUES('vance davis');\n    INSERT INTO streetname VALUES('vanhoy');\n    INSERT INTO streetname VALUES('veckman');\n    INSERT INTO streetname VALUES('victoria');\n    INSERT INTO streetname VALUES('victory');\n    INSERT INTO streetname VALUES('village glen');\n    INSERT INTO streetname VALUES('vireo');\n    INSERT INTO streetname VALUES('viscount');\n    INSERT INTO streetname VALUES('voeltz');\n    INSERT INTO streetname VALUES('wade e morgan');\n    INSERT INTO streetname VALUES('wake');\n    INSERT INTO streetname VALUES('wales');\n    INSERT INTO streetname VALUES('wallace ridge');\n    INSERT INTO streetname VALUES('waltham');\n    INSERT INTO streetname VALUES('wanamassa');\n    INSERT INTO streetname VALUES('warbler wood');\n    INSERT INTO streetname VALUES('washington');\n    INSERT INTO streetname VALUES('water');\n    INSERT INTO streetname VALUES('waterelm');\n    INSERT INTO streetname VALUES('waterford hills');\n    INSERT INTO streetname VALUES('waterford valley');\n    INSERT INTO streetname VALUES('waterloo');\n    INSERT INTO streetname VALUES('waterton leas');\n    INSERT INTO streetname VALUES('waverly lynn');\n    INSERT INTO streetname VALUES('waverlyglen');\n    INSERT INTO streetname VALUES('wayside');\n    INSERT INTO streetname VALUES('westbury lake');\n    INSERT INTO streetname VALUES('westray');\n    INSERT INTO streetname VALUES('whistlers chase');\n    INSERT INTO streetname VALUES('whistley green');\n    INSERT INTO streetname VALUES('whistling oak');\n    INSERT INTO streetname VALUES('whitcomb');\n    INSERT INTO streetname VALUES('white aspen');\n    INSERT INTO streetname VALUES('white cascade');\n    INSERT INTO streetname VALUES('white mist');\n    INSERT INTO streetname VALUES('white rock');\n    INSERT INTO streetname VALUES('white stag');\n    INSERT INTO streetname VALUES('whitegate');\n    INSERT INTO streetname VALUES('whitehill');\n    INSERT INTO streetname VALUES('whitetail');\n    INSERT INTO streetname VALUES('whitewood');\n    INSERT INTO streetname VALUES('wilburn park');\n    INSERT INTO streetname VALUES('wild garden');\n    INSERT INTO streetname VALUES('wild rose');\n    INSERT INTO streetname VALUES('wilkins terrace');\n    INSERT INTO streetname VALUES('william ficklen');\n    INSERT INTO streetname VALUES('wiltshire ridge');\n    INSERT INTO streetname VALUES('windchase');\n    INSERT INTO streetname VALUES('winding jordan');\n    INSERT INTO streetname VALUES('windy meadow');\n    INSERT INTO streetname VALUES('winghaven');\n    INSERT INTO streetname VALUES('wingmont');\n    INSERT INTO streetname VALUES('winslow');\n    INSERT INTO streetname VALUES('winter pine');\n    INSERT INTO streetname VALUES('winter view');\n    INSERT INTO streetname VALUES('wolf creek');\n    INSERT INTO streetname VALUES('wondering oak');\n    INSERT INTO streetname VALUES('woodard');\n    INSERT INTO streetname VALUES('woodfire');\n    INSERT INTO streetname VALUES('woodland commons');\n    INSERT INTO streetname VALUES('woodland hills');\n    INSERT INTO streetname VALUES('woodnotch');\n    INSERT INTO streetname VALUES('woodstone');\n    INSERT INTO streetname VALUES('worsley');\n    INSERT INTO streetname VALUES('wren creek');\n    INSERT INTO streetname VALUES('wrens nest');\n    INSERT INTO streetname VALUES('wrexham');\n    INSERT INTO streetname VALUES('wt harris');\n    INSERT INTO streetname VALUES('wylie meadow');\n    INSERT INTO streetname VALUES('wynborough');\n    INSERT INTO streetname VALUES('wynbrook');\n    INSERT INTO streetname VALUES('wyndham hill');\n    INSERT INTO streetname VALUES('yandem');\n    INSERT INTO streetname VALUES('yellow rose');\n    INSERT INTO streetname VALUES('yellow spaniel');\n    INSERT INTO streetname VALUES('yorkford');\n    INSERT INTO streetname VALUES('ziegler');\n    INSERT INTO streetname VALUES('zion renaissance');\n\n    SELECT count(*) FROM streetname;\n  }\n} {1228}\n\ndo_test fuzzer1-2.1 {\n  execsql {\n    SELECT n, distance FROM f2, streetname\n     WHERE f2.word MATCH 'wersley'\n       AND f2.distance<=150\n       AND f2.word=streetname.n\n  }\n} {worsley 37}\ndo_test fuzzer1-2.2 {\n  execsql {\n    SELECT n, distance FROM f2, streetname\n     WHERE f2.word MATCH 'testledown'\n       AND f2.distance<=150\n       AND f2.word=streetname.n\n  }\n} {thistledown 103}\ndo_test fuzzer1-2.3 {\n  execsql {\n    SELECT DISTINCT streetname.n FROM f2, streetname\n     WHERE f2.word MATCH 'tayle'\n       AND f2.distance<=200\n       AND streetname.n>=f2.word AND streetname.n<=(f2.word || x'F7BFBFBF')\n  }\n} {{tyler finley} trailer taymouth steelewood tallia tallu talwyn thelema}\ndo_test fuzzer1-2.4 {\n  execsql {\n    SELECT DISTINCT streetname.n\n      FROM f2 JOIN streetname\n        ON (streetname.n>=f2.word AND streetname.n<=(f2.word || 'zzzzzz'))\n     WHERE f2.word MATCH 'duck'\n       AND f2.distance<150\n       AND f2.ruleset=3\n     ORDER BY 1\n  }\n} {mallard {mallard cove} {mallard forest} {mallard grove} {mallard hill} {mallard park} {mallard ridge} {mallard view}}\ndo_test fuzzer1-2.5 {\n  execsql {\n    SELECT DISTINCT streetname.n\n      FROM f2 JOIN streetname\n        ON (streetname.n>=f2.word AND streetname.n<=(f2.word || 'zzzzzz'))\n     WHERE f2.word MATCH 'duck'\n       AND f2.distance<150\n       AND f2.ruleset=2\n     ORDER BY 1\n  }\n} {}\n\nforcedelete test.db2\ndo_execsql_test fuzzer1-4.1 {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE aux.f3_rules(ruleset, cfrom, cto, cost);\n  INSERT INTO f3_rules(ruleset, cfrom, cto, cost) VALUES(0, 'x','y', 10);\n  INSERT INTO f3_rules(ruleset, cfrom, cto, cost) VALUES(1, 'a','b', 10);\n  CREATE VIRTUAL TABLE aux.f3 USING fuzzer(f3_rules);\n  SELECT word FROM f3 WHERE word MATCH 'ax'\n} {ax ay}\n\n#-------------------------------------------------------------------------\n#\n#  1.5.1 - Check things work with a fuzzer data table name that requires\n#          quoting. Also that NULL entries in the \"from\" column of the\n#          data table are treated as zero length strings ('').\n#\n#  1.5.2 - Check that no-op rules (i.e. C->C) are ignored. Test NULL in\n#          the \"to\" column of a fuzzer data table.\n#  \n#  1.5.3 - Test out-of-range values for the cost field of the data table.\n#\n#  1.5.4 - Test out-of-range values for the string fields of the data table.\n#\n#  1.5.5 - Test out-of-range values for the ruleset field of the data table.\n#\ndo_execsql_test 5.1 {\n  CREATE TABLE \"fuzzer [x] rules table\"(a, b, c, d);\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, NULL, 'abc', 10);\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n  SELECT word, distance FROM x WHERE word MATCH '123' LIMIT 4;\n} {123 0 abc123 10 1abc23 10 12abc3 10}\n\ndo_execsql_test 5.2 {\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, 'x', NULL, 20);\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, NULL, NULL, 10);\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, 'x', 'x', 10);\n\n  DROP TABLE x;\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n\n  SELECT word, distance FROM x WHERE word MATCH 'xx';\n} {xx 0 x 20 {} 40}\n\ndo_execsql_test 5.3.1 {\n  DROP TABLE IF EXISTS x;\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, 'c', 'd', 1001);\n}\ndo_catchsql_test 5.3.2 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: cost must be between 1 and 1000}}\n\ndo_execsql_test 5.3.3 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, 'd', 'c', 0);\n}\ndo_catchsql_test 5.3.4 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: cost must be between 1 and 1000}}\n\ndo_execsql_test 5.3.5 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(0, 'd', 'c', -20);\n}\ndo_catchsql_test 5.3.6 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: cost must be between 1 and 1000}}\n\ndo_execsql_test 5.4.1 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(\n    0, 'x', '12345678901234567890123456789012345678901234567890', 2\n  );\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n  SELECT word FROM x WHERE word MATCH 'x';\n} {x 12345678901234567890123456789012345678901234567890}\n\ndo_execsql_test 5.4.2 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(\n    0, 'x', '123456789012345678901234567890123456789012345678901', 2\n  );\n} \ndo_catchsql_test 5.4.3 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: maximum string length is 50}}\n\ndo_execsql_test 5.4.4 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(\n    0, '123456789012345678901234567890123456789012345678901', 'x', 2\n  );\n} \ndo_catchsql_test 5.4.5 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: maximum string length is 50}}\n\ndo_execsql_test 5.5.1 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES(-1, 'x', 'y', 2);\n} \ndo_catchsql_test 5.5.2 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: ruleset must be between 0 and 2147483647}}\n\ndo_execsql_test 5.5.3 {\n  DROP TABLE IF EXISTS x;\n  DELETE FROM \"fuzzer [x] rules table\";\n  INSERT INTO \"fuzzer [x] rules table\" VALUES((1<<32)+100, 'x', 'y', 2);\n} \ndo_catchsql_test 5.5.4 {\n  CREATE VIRTUAL TABLE x USING fuzzer('fuzzer [x] rules table');\n} {1 {fuzzer: ruleset must be between 0 and 2147483647}}\n\n#-------------------------------------------------------------------------\n# Test using different types of quotes with CREATE VIRTUAL TABLE \n# arguments.\n#\ndo_execsql_test 7.1 {\n  CREATE TABLE [x2 \"rules] (a, b, c, d);\n  INSERT INTO [x2 \"rules] VALUES(0, 'a', 'b', 5);\n}\nforeach {tn sql} {\n  1 { CREATE VIRTUAL TABLE x2 USING fuzzer( [x2 \"rules] ) }\n  2 { CREATE VIRTUAL TABLE x2 USING fuzzer( \"x2 \"\"rules\" ) }\n  3 { CREATE VIRTUAL TABLE x2 USING fuzzer( 'x2 \"rules' ) }\n  4 { CREATE VIRTUAL TABLE x2 USING fuzzer( `x2 \"rules` ) }\n} {\n  do_execsql_test 7.2.$tn.1 { DROP TABLE IF EXISTS x2 }\n  do_execsql_test 7.2.$tn.2 $sql\n  do_execsql_test 7.2.$tn.3 { \n    SELECT word FROM x2 WHERE word MATCH 'aaa' \n  } {aaa baa aba aab bab abb bba bbb}\n}\n\n#-------------------------------------------------------------------------\n# Test using a fuzzer table in different contexts.\n#\ndo_execsql_test 8.1 {\n  CREATE TABLE x3_rules(rule_set, cFrom, cTo, cost);\n  INSERT INTO x3_rules VALUES(2, 'a', 'x', 10);\n  INSERT INTO x3_rules VALUES(2, 'a', 'y',  9);\n  INSERT INTO x3_rules VALUES(2, 'a', 'z',  8);\n  CREATE VIRTUAL TABLE x3 USING fuzzer(x3_rules);\n}\n\ndo_execsql_test 8.2.1 {\n  SELECT cFrom, cTo, word \n    FROM x3_rules CROSS JOIN x3 \n    WHERE word MATCH 'a' AND cost=distance AND ruleset=2\n    ORDER BY +cTo;\n} {a x x a y y a z z}\n\ndo_execsql_test 8.2.2 {\n  SELECT cFrom, cTo, word \n    FROM x3 CROSS JOIN x3_rules\n    WHERE word MATCH 'a' AND cost=distance AND ruleset=2\n    ORDER BY +cTo DESC\n} {a z z a y y a x x}\n\ndo_execsql_test 8.2.3 {\n  SELECT cFrom, cTo, word \n    FROM x3_rules, x3 \n    WHERE word MATCH 'a' AND cost=distance AND ruleset=2\n    ORDER BY +cTo DESC;\n} {a z z a y y a x x}\n\ndo_execsql_test 8.2.4 {\n  SELECT cFrom, cTo, word \n    FROM x3, x3_rules\n    WHERE word MATCH 'a' AND cost=distance AND ruleset=2\n    ORDER BY +cTo DESC;\n} {a z z a y y a x x}\n\ndo_execsql_test 8.2.5 {\n  CREATE INDEX i1 ON x3_rules(cost);\n  SELECT cFrom, cTo, word \n    FROM x3_rules, x3 \n    WHERE word MATCH 'a' AND cost=distance AND ruleset=2\n    ORDER BY +cTo DESC;\n} {a z z a y y a x x}\n\ndo_execsql_test 8.2.5 {\n  SELECT word FROM x3_rules, x3 WHERE word MATCH x3_rules.cFrom AND ruleset=2\n} {a z y x a z y x a z y x}\n\ndo_execsql_test 8.2.6 {\n  SELECT word FROM x3_rules, x3 \n  WHERE word MATCH x3_rules.cFrom \n    AND ruleset=2 \n    AND x3_rules.cost=8;\n} {a z y x}\n\ndo_execsql_test 8.2.7 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i2 ON t1(b);\n  SELECT word, distance FROM x3, t1 \n    WHERE x3.word MATCH t1.a AND ruleset=2 AND distance=t1.b;\n} {}\n\ndo_execsql_test 8.2.8 {\n  INSERT INTO x3_rules VALUES(1, 'a', 't',  5);\n  INSERT INTO x3_rules VALUES(1, 'a', 'u',  4);\n  INSERT INTO x3_rules VALUES(1, 'a', 'v',  3);\n  DROP TABLE x3;\n  CREATE VIRTUAL TABLE x3 USING fuzzer(x3_rules);\n  SELECT * FROM x3_rules;\n} {\n  2 a x 10 \n  2 a y 9 \n  2 a z 8 \n  1 a t 5 \n  1 a u 4 \n  1 a v 3\n}\n\ndo_catchsql_test 8.2.9 {\n  SELECT word FROM x3 WHERE ruleset=2 AND word MATCH 'a' AND WORD MATCH 'b';\n} {1 {unable to use function MATCH in the requested context}}\n\ndo_execsql_test 8.2.10 {\n  SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a'\n} {a v u t}\n\n# The term \"ruleset<=1\" is not handled by the fuzzer module. Instead, it\n# is handled by SQLite, which assumes that all rows have a NULL value in\n# the ruleset column. Since NULL<=1 is never true, this query returns\n# no rows.\ndo_execsql_test 8.2.11 {\n  SELECT word FROM x3 WHERE ruleset<=1 AND word MATCH 'a'\n} {}\n\ndo_execsql_test 8.2.12 {\n  SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY distance ASC;\n} {a v u t}\n\ndo_execsql_test 8.2.13 {\n  SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY distance DESC;\n} {t u v a}\n\ndo_execsql_test 8.2.13 {\n  SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY word ASC;\n} {a t u v}\n\ndo_execsql_test 8.2.14 {\n  SELECT word FROM x3 WHERE ruleset=1 AND word MATCH 'a' ORDER BY word DESC;\n} {v u t a}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 9.1 {\n  CREATE TABLE x4_rules(a, b, c, d);\n  INSERT INTO x4_rules VALUES(0, 'a', 'b', 10);\n  INSERT INTO x4_rules VALUES(0, 'a', 'c', 11);\n  INSERT INTO x4_rules VALUES(0, 'bx', 'zz', 20);\n  INSERT INTO x4_rules VALUES(0, 'cx', 'yy', 15);\n  INSERT INTO x4_rules VALUES(0, 'zz', '!!', 50);\n  CREATE VIRTUAL TABLE x4 USING fuzzer(x4_rules);\n}\n\ndo_execsql_test 9.2 {\n  SELECT word, distance FROM x4 WHERE word MATCH 'ax';\n} {ax 0 bx 10 cx 11 yy 26 zz 30 !! 80}\n\n\ndo_execsql_test 10.1 {\n  CREATE TABLE x5_rules(a, b, c, d);\n  CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules);\n}\n\ndo_execsql_test 10.2 {\n  SELECT word, distance FROM x5 WHERE word MATCH \n    'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa' || \n    'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa' || \n    'aaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaaXaaaaaaaaa'\n} {}\n\ndo_execsql_test 10.3 {\n  INSERT INTO x5_rules VALUES(0, 'a', '0.1.2.3.4.5.6.7.8.9.a', 1);\n  DROP TABLE x5;\n  CREATE VIRTUAL TABLE x5 USING fuzzer(x5_rules);\n  SELECT length(word) FROM x5 WHERE word MATCH 'a' LIMIT 50;\n} {1 21 41 61 81}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzzer2.test",
    "content": "# 2016 February 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The focus of the tests is the word-fuzzer virtual table. The tests\n# in this file are slower than those in fuzzer1.test. So this file does\n# not run as part of veryquick.test etc.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nset ::testprefix fuzzer2\nload_static_extension db fuzzer\n\n#-------------------------------------------------------------------------\n# This test uses a fuzzer table with many rules. There is one rule to\n# map each possible two character string, where characters are lower-case\n# letters used in the English language, to all other possible two character\n# strings. In total, (26^4)-(26^2) mappings (the subtracted term represents\n# the no-op mappings discarded automatically by the fuzzer).\n#\n#\ndo_execsql_test 1.1.1 {\n  DROP TABLE IF EXISTS x1;\n  DROP TABLE IF EXISTS x1_rules;\n  CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);\n}\nputs \"This test is slow - perhaps around 7 seconds on an average pc\"\ndo_test 1.1.2 {\n  set LETTERS {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n  set cost 1\n  db transaction {\n    foreach c1 $LETTERS { \n      foreach c2 $LETTERS { \n        foreach c3 $LETTERS { \n          foreach c4 $LETTERS { \n            db eval {INSERT INTO x1_rules VALUES(0, $c1||$c2, $c3||$c4, $cost)}\n            set cost [expr ($cost%1000) + 1]\n          }\n        }\n      }\n    }\n    db eval {UPDATE x1_rules SET cost = 20 WHERE cost<20 AND cFrom!='xx'}\n  }\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT count(*) FROM x1_rules WHERE cTo!=cFrom;\n} [expr 26*26*26*26 - 26*26]\n\ndo_execsql_test 1.2.1 {\n  CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);\n  SELECT word FROM x1 WHERE word MATCH 'xx' LIMIT 10;\n} {xx hw hx hy hz ia ib ic id ie}\ndo_execsql_test 1.2.2 {\n  SELECT cTo FROM x1_rules WHERE cFrom='xx' \n  ORDER BY cost asc, rowid asc LIMIT 9;\n} {hw hx hy hz ia ib ic id ie}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/fuzzerfault.test",
    "content": "# 2012 February 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for TCL interface to the\n# SQLite library. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !vtab { finish_test ; return }\nset ::testprefix fuzzerfault\n\nload_static_extension db fuzzer\n\ndo_test 1-pre1 {\n  execsql {\n    CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);\n    INSERT INTO x1_rules VALUES(0, 'a', 'b', 1);\n    INSERT INTO x1_rules VALUES(0, 'a', 'c', 2);\n    INSERT INTO x1_rules VALUES(0, 'a', 'd', 3);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test 1 -prep {\n  faultsim_restore_and_reopen\n  load_static_extension db fuzzer\n} -body {\n  execsql { \n    CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);\n    SELECT word FROM x1 WHERE word MATCH 'xax';\n  }\n} -test {\n  faultsim_test_result {0 {xax xbx xcx xdx}}               \\\n                       {1 {vtable constructor failed: x1}}\n}\n\ndo_test 2-pre1 {\n  faultsim_delete_and_reopen\n  load_static_extension db fuzzer\n  execsql {\n    CREATE TABLE x2_rules(ruleset, cFrom, cTo, cost);\n    INSERT INTO x2_rules VALUES(0, 'a', 'x', 1);\n    INSERT INTO x2_rules VALUES(0, 'b', 'x', 2);\n    INSERT INTO x2_rules VALUES(0, 'c', 'x', 3);\n    CREATE VIRTUAL TABLE x2 USING fuzzer(x2_rules);\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 2 -prep {\n  faultsim_restore_and_reopen\n  load_static_extension db fuzzer\n} -body {\n  execsql { \n    SELECT count(*) FROM x2 WHERE word MATCH 'abc';\n  }\n} -test {\n  faultsim_test_result {0 8} {1 {vtable constructor failed: x2}}\n}\n\ndo_test 3-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE x1_rules(ruleset, cFrom, cTo, cost);\n    INSERT INTO x1_rules VALUES(0, 'a', \n      '123456789012345678901234567890a1234567890123456789', 10\n    );\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 3 -prep {\n  faultsim_restore_and_reopen\n  load_static_extension db fuzzer\n} -body {\n  execsql { \n    CREATE VIRTUAL TABLE x1 USING fuzzer(x1_rules);\n    SELECT count(*) FROM (SELECT * FROM x1 WHERE word MATCH 'a' LIMIT 2);\n  }\n} -test {\n  faultsim_test_result {0 2} {1 {vtable constructor failed: x1}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/gcfault.test",
    "content": "# 2016 December 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing OOM error handling within the built-in \n# group_concat() function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix gcfault\n\n\nforeach {enc} {\n  utf16\n  utf8\n} {\n  reset_db\n  sqlite3_db_config_lookaside db 0 0 0\n  execsql \"PRAGMA encoding = $enc\"\n\n  do_execsql_test 1.$enc.1 {\n    CREATE TABLE s(i, s);\n    INSERT INTO s VALUES(1, ',0123456789,');\n    INSERT INTO s VALUES(2, X'2c303132333435363738392c');\n\n    CREATE TABLE e(e);\n    INSERT INTO e VALUES('v1'), ('v2');\n  } {}\n\n  do_faultsim_test 1.$enc.1 -faults oom* -body {\n    execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=1)) FROM e }\n  }\n\n  do_faultsim_test 1.$enc.2 -faults oom-t* -body {\n    execsql { SELECT group_concat(e, (SELECT s FROM s WHERE i=2)) FROM e }\n  }\n\n  do_faultsim_test 1.$enc.3 -faults oom-t* -prep {\n    set ::STMT [sqlite3_prepare db {SELECT group_concat(e, ?) FROM e} -1 dummy]\n    sqlite3_bind_text $::STMT 1 \",0123456789,\" 12\n  } -body {\n    while { \"SQLITE_ROW\"==[sqlite3_step $::STMT] } { }\n  } -test {\n    sqlite3_finalize $::STMT\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/genesis.tcl",
    "content": "# 2010 February 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements a TCL function that fills an FTS table with\n# lots of content useful for testing.  This routine is broken out into\n# a separate file to facilitate its use by multiple test scripts.\n#\n\n# The fts_kjv_genesis routine is already loaded.  This script is a no-op.\nif {[lsearch [info procs] fts_kjv_genesis]>=0} return\n\n# This procedure fills an existing FTS3/FTS4 table with many entries.\n# The table needs to have a single column (other than docid) named \"words\".\n#\nproc fts_kjv_genesis {} {\ndb eval {\nBEGIN TRANSACTION;\nINSERT INTO t1(docid,words) VALUES(1001001,'In the beginning God created the heaven and the earth.');\nINSERT INTO t1(docid,words) VALUES(1001002,'And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.');\nINSERT INTO t1(docid,words) VALUES(1001003,'And God said, Let there be light: and there was light.');\nINSERT INTO t1(docid,words) VALUES(1001004,'And God saw the light, that it was good: and God divided the light from the darkness.');\nINSERT INTO t1(docid,words) VALUES(1001005,'And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.');\nINSERT INTO t1(docid,words) VALUES(1001006,'And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.');\nINSERT INTO t1(docid,words) VALUES(1001007,'And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001008,'And God called the firmament Heaven. And the evening and the morning were the second day.');\nINSERT INTO t1(docid,words) VALUES(1001009,'And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001010,'And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.');\nINSERT INTO t1(docid,words) VALUES(1001011,'And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001012,'And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.');\nINSERT INTO t1(docid,words) VALUES(1001013,'And the evening and the morning were the third day.');\nINSERT INTO t1(docid,words) VALUES(1001014,'And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:');\nINSERT INTO t1(docid,words) VALUES(1001015,'And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001016,'And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.');\nINSERT INTO t1(docid,words) VALUES(1001017,'And God set them in the firmament of the heaven to give light upon the earth,');\nINSERT INTO t1(docid,words) VALUES(1001018,'And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.');\nINSERT INTO t1(docid,words) VALUES(1001019,'And the evening and the morning were the fourth day.');\nINSERT INTO t1(docid,words) VALUES(1001020,'And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.');\nINSERT INTO t1(docid,words) VALUES(1001021,'And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.');\nINSERT INTO t1(docid,words) VALUES(1001022,'And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.');\nINSERT INTO t1(docid,words) VALUES(1001023,'And the evening and the morning were the fifth day.');\nINSERT INTO t1(docid,words) VALUES(1001024,'And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001025,'And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.');\nINSERT INTO t1(docid,words) VALUES(1001026,'And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1001027,'So God created man in his own image, in the image of God created he him; male and female created he them.');\nINSERT INTO t1(docid,words) VALUES(1001028,'And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1001029,'And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.');\nINSERT INTO t1(docid,words) VALUES(1001030,'And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so.');\nINSERT INTO t1(docid,words) VALUES(1001031,'And God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day.');\nINSERT INTO t1(docid,words) VALUES(1002001,'Thus the heavens and the earth were finished, and all the host of them.');\nINSERT INTO t1(docid,words) VALUES(1002002,'And on the seventh day God ended his work which he had made; and he rested on the seventh day from all his work which he had made.');\nINSERT INTO t1(docid,words) VALUES(1002003,'And God blessed the seventh day, and sanctified it: because that in it he had rested from all his work which God created and made.');\nINSERT INTO t1(docid,words) VALUES(1002004,'These are the generations of the heavens and of the earth when they were created, in the day that the LORD God made the earth and the heavens,');\nINSERT INTO t1(docid,words) VALUES(1002005,'And every plant of the field before it was in the earth, and every herb of the field before it grew: for the LORD God had not caused it to rain upon the earth, and there was not a man to till the ground.');\nINSERT INTO t1(docid,words) VALUES(1002006,'But there went up a mist from the earth, and watered the whole face of the ground.');\nINSERT INTO t1(docid,words) VALUES(1002007,'And the LORD God formed man of the dust of the ground, and breathed into his nostrils the breath of life; and man became a living soul.');\nINSERT INTO t1(docid,words) VALUES(1002008,'And the LORD God planted a garden eastward in Eden; and there he put the man whom he had formed.');\nINSERT INTO t1(docid,words) VALUES(1002009,'And out of the ground made the LORD God to grow every tree that is pleasant to the sight, and good for food; the tree of life also in the midst of the garden, and the tree of knowledge of good and evil.');\nINSERT INTO t1(docid,words) VALUES(1002010,'And a river went out of Eden to water the garden; and from thence it was parted, and became into four heads.');\nINSERT INTO t1(docid,words) VALUES(1002011,'The name of the first is Pison: that is it which compasseth the whole land of Havilah, where there is gold;');\nINSERT INTO t1(docid,words) VALUES(1002012,'And the gold of that land is good: there is bdellium and the onyx stone.');\nINSERT INTO t1(docid,words) VALUES(1002013,'And the name of the second river is Gihon: the same is it that compasseth the whole land of Ethiopia.');\nINSERT INTO t1(docid,words) VALUES(1002014,'And the name of the third river is Hiddekel: that is it which goeth toward the east of Assyria. And the fourth river is Euphrates.');\nINSERT INTO t1(docid,words) VALUES(1002015,'And the LORD God took the man, and put him into the garden of Eden to dress it and to keep it.');\nINSERT INTO t1(docid,words) VALUES(1002016,'And the LORD God commanded the man, saying, Of every tree of the garden thou mayest freely eat:');\nINSERT INTO t1(docid,words) VALUES(1002017,'But of the tree of the knowledge of good and evil, thou shalt not eat of it: for in the day that thou eatest thereof thou shalt surely die.');\nINSERT INTO t1(docid,words) VALUES(1002018,'And the LORD God said, It is not good that the man should be alone; I will make him an help meet for him.');\nINSERT INTO t1(docid,words) VALUES(1002019,'And out of the ground the LORD God formed every beast of the field, and every fowl of the air; and brought them unto Adam to see what he would call them: and whatsoever Adam called every living creature, that was the name thereof.');\nINSERT INTO t1(docid,words) VALUES(1002020,'And Adam gave names to all cattle, and to the fowl of the air, and to every beast of the field; but for Adam there was not found an help meet for him.');\nINSERT INTO t1(docid,words) VALUES(1002021,'And the LORD God caused a deep sleep to fall upon Adam, and he slept: and he took one of his ribs, and closed up the flesh instead thereof;');\nINSERT INTO t1(docid,words) VALUES(1002022,'And the rib, which the LORD God had taken from man, made he a woman, and brought her unto the man.');\nINSERT INTO t1(docid,words) VALUES(1002023,'And Adam said, This is now bone of my bones, and flesh of my flesh: she shall be called Woman, because she was taken out of Man.');\nINSERT INTO t1(docid,words) VALUES(1002024,'Therefore shall a man leave his father and his mother, and shall cleave unto his wife: and they shall be one flesh.');\nINSERT INTO t1(docid,words) VALUES(1002025,'And they were both naked, the man and his wife, and were not ashamed.');\nINSERT INTO t1(docid,words) VALUES(1003001,'Now the serpent was more subtil than any beast of the field which the LORD God had made. And he said unto the woman, Yea, hath God said, Ye shall not eat of every tree of the garden?');\nINSERT INTO t1(docid,words) VALUES(1003002,'And the woman said unto the serpent, We may eat of the fruit of the trees of the garden:');\nINSERT INTO t1(docid,words) VALUES(1003003,'But of the fruit of the tree which is in the midst of the garden, God hath said, Ye shall not eat of it, neither shall ye touch it, lest ye die.');\nINSERT INTO t1(docid,words) VALUES(1003004,'And the serpent said unto the woman, Ye shall not surely die:');\nINSERT INTO t1(docid,words) VALUES(1003005,'For God doth know that in the day ye eat thereof, then your eyes shall be opened, and ye shall be as gods, knowing good and evil.');\nINSERT INTO t1(docid,words) VALUES(1003006,'And when the woman saw that the tree was good for food, and that it was pleasant to the eyes, and a tree to be desired to make one wise, she took of the fruit thereof, and did eat, and gave also unto her husband with her; and he did eat.');\nINSERT INTO t1(docid,words) VALUES(1003007,'And the eyes of them both were opened, and they knew that they were naked; and they sewed fig leaves together, and made themselves aprons.');\nINSERT INTO t1(docid,words) VALUES(1003008,'And they heard the voice of the LORD God walking in the garden in the cool of the day: and Adam and his wife hid themselves from the presence of the LORD God amongst the trees of the garden.');\nINSERT INTO t1(docid,words) VALUES(1003009,'And the LORD God called unto Adam, and said unto him, Where art thou?');\nINSERT INTO t1(docid,words) VALUES(1003010,'And he said, I heard thy voice in the garden, and I was afraid, because I was naked; and I hid myself.');\nINSERT INTO t1(docid,words) VALUES(1003011,'And he said, Who told thee that thou wast naked? Hast thou eaten of the tree, whereof I commanded thee that thou shouldest not eat?');\nINSERT INTO t1(docid,words) VALUES(1003012,'And the man said, The woman whom thou gavest to be with me, she gave me of the tree, and I did eat.');\nINSERT INTO t1(docid,words) VALUES(1003013,'And the LORD God said unto the woman, What is this that thou hast done? And the woman said, The serpent beguiled me, and I did eat.');\nINSERT INTO t1(docid,words) VALUES(1003014,'And the LORD God said unto the serpent, Because thou hast done this, thou art cursed above all cattle, and above every beast of the field; upon thy belly shalt thou go, and dust shalt thou eat all the days of thy life:');\nINSERT INTO t1(docid,words) VALUES(1003015,'And I will put enmity between thee and the woman, and between thy seed and her seed; it shall bruise thy head, and thou shalt bruise his heel.');\nINSERT INTO t1(docid,words) VALUES(1003016,'Unto the woman he said, I will greatly multiply thy sorrow and thy conception; in sorrow thou shalt bring forth children; and thy desire shall be to thy husband, and he shall rule over thee.');\nINSERT INTO t1(docid,words) VALUES(1003017,'And unto Adam he said, Because thou hast hearkened unto the voice of thy wife, and hast eaten of the tree, of which I commanded thee, saying, Thou shalt not eat of it: cursed is the ground for thy sake; in sorrow shalt thou eat of it all the days of thy life;');\nINSERT INTO t1(docid,words) VALUES(1003018,'Thorns also and thistles shall it bring forth to thee; and thou shalt eat the herb of the field;');\nINSERT INTO t1(docid,words) VALUES(1003019,'In the sweat of thy face shalt thou eat bread, till thou return unto the ground; for out of it wast thou taken: for dust thou art, and unto dust shalt thou return.');\nINSERT INTO t1(docid,words) VALUES(1003020,'And Adam called his wife''s name Eve; because she was the mother of all living.');\nINSERT INTO t1(docid,words) VALUES(1003021,'Unto Adam also and to his wife did the LORD God make coats of skins, and clothed them.');\nINSERT INTO t1(docid,words) VALUES(1003022,'And the LORD God said, Behold, the man is become as one of us, to know good and evil: and now, lest he put forth his hand, and take also of the tree of life, and eat, and live for ever:');\nINSERT INTO t1(docid,words) VALUES(1003023,'Therefore the LORD God sent him forth from the garden of Eden, to till the ground from whence he was taken.');\nINSERT INTO t1(docid,words) VALUES(1003024,'So he drove out the man; and he placed at the east of the garden of Eden Cherubims, and a flaming sword which turned every way, to keep the way of the tree of life.');\nINSERT INTO t1(docid,words) VALUES(1004001,'And Adam knew Eve his wife; and she conceived, and bare Cain, and said, I have gotten a man from the LORD.');\nINSERT INTO t1(docid,words) VALUES(1004002,'And she again bare his brother Abel. And Abel was a keeper of sheep, but Cain was a tiller of the ground.');\nINSERT INTO t1(docid,words) VALUES(1004003,'And in process of time it came to pass, that Cain brought of the fruit of the ground an offering unto the LORD.');\nINSERT INTO t1(docid,words) VALUES(1004004,'And Abel, he also brought of the firstlings of his flock and of the fat thereof. And the LORD had respect unto Abel and to his offering:');\nINSERT INTO t1(docid,words) VALUES(1004005,'But unto Cain and to his offering he had not respect. And Cain was very wroth, and his countenance fell.');\nINSERT INTO t1(docid,words) VALUES(1004006,'And the LORD said unto Cain, Why art thou wroth? and why is thy countenance fallen?');\nINSERT INTO t1(docid,words) VALUES(1004007,'If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him.');\nINSERT INTO t1(docid,words) VALUES(1004008,'And Cain talked with Abel his brother: and it came to pass, when they were in the field, that Cain rose up against Abel his brother, and slew him.');\nINSERT INTO t1(docid,words) VALUES(1004009,'And the LORD said unto Cain, Where is Abel thy brother? And he said, I know not: Am I my brother''s keeper?');\nINSERT INTO t1(docid,words) VALUES(1004010,'And he said, What hast thou done? the voice of thy brother''s blood crieth unto me from the ground.');\nINSERT INTO t1(docid,words) VALUES(1004011,'And now art thou cursed from the earth, which hath opened her mouth to receive thy brother''s blood from thy hand;');\nINSERT INTO t1(docid,words) VALUES(1004012,'When thou tillest the ground, it shall not henceforth yield unto thee her strength; a fugitive and a vagabond shalt thou be in the earth.');\nINSERT INTO t1(docid,words) VALUES(1004013,'And Cain said unto the LORD, My punishment is greater than I can bear.');\nINSERT INTO t1(docid,words) VALUES(1004014,'Behold, thou hast driven me out this day from the face of the earth; and from thy face shall I be hid; and I shall be a fugitive and a vagabond in the earth; and it shall come to pass, that every one that findeth me shall slay me.');\nINSERT INTO t1(docid,words) VALUES(1004015,'And the LORD said unto him, Therefore whosoever slayeth Cain, vengeance shall be taken on him sevenfold. And the LORD set a mark upon Cain, lest any finding him should kill him.');\nINSERT INTO t1(docid,words) VALUES(1004016,'And Cain went out from the presence of the LORD, and dwelt in the land of Nod, on the east of Eden.');\nINSERT INTO t1(docid,words) VALUES(1004017,'And Cain knew his wife; and she conceived, and bare Enoch: and he builded a city, and called the name of the city, after the name of his son, Enoch.');\nINSERT INTO t1(docid,words) VALUES(1004018,'And unto Enoch was born Irad: and Irad begat Mehujael: and Mehujael begat Methusael: and Methusael begat Lamech.');\nINSERT INTO t1(docid,words) VALUES(1004019,'And Lamech took unto him two wives: the name of the one was Adah, and the name of the other Zillah.');\nINSERT INTO t1(docid,words) VALUES(1004020,'And Adah bare Jabal: he was the father of such as dwell in tents, and of such as have cattle.');\nINSERT INTO t1(docid,words) VALUES(1004021,'And his brother''s name was Jubal: he was the father of all such as handle the harp and organ.');\nINSERT INTO t1(docid,words) VALUES(1004022,'And Zillah, she also bare Tubalcain, an instructer of every artificer in brass and iron: and the sister of Tubalcain was Naamah.');\nINSERT INTO t1(docid,words) VALUES(1004023,'And Lamech said unto his wives, Adah and Zillah, Hear my voice; ye wives of Lamech, hearken unto my speech: for I have slain a man to my wounding, and a young man to my hurt.');\nINSERT INTO t1(docid,words) VALUES(1004024,'If Cain shall be avenged sevenfold, truly Lamech seventy and sevenfold.');\nINSERT INTO t1(docid,words) VALUES(1004025,'And Adam knew his wife again; and she bare a son, and called his name Seth: For God, said she, hath appointed me another seed instead of Abel, whom Cain slew.');\nINSERT INTO t1(docid,words) VALUES(1004026,'And to Seth, to him also there was born a son; and he called his name Enos: then began men to call upon the name of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1005001,'This is the book of the generations of Adam. In the day that God created man, in the likeness of God made he him;');\nINSERT INTO t1(docid,words) VALUES(1005002,'Male and female created he them; and blessed them, and called their name Adam, in the day when they were created.');\nINSERT INTO t1(docid,words) VALUES(1005003,'And Adam lived an hundred and thirty years, and begat a son in his own likeness, and after his image; and called his name Seth:');\nINSERT INTO t1(docid,words) VALUES(1005004,'And the days of Adam after he had begotten Seth were eight hundred years: and he begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005005,'And all the days that Adam lived were nine hundred and thirty years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005006,'And Seth lived an hundred and five years, and begat Enos:');\nINSERT INTO t1(docid,words) VALUES(1005007,'And Seth lived after he begat Enos eight hundred and seven years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005008,'And all the days of Seth were nine hundred and twelve years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005009,'And Enos lived ninety years, and begat Cainan:');\nINSERT INTO t1(docid,words) VALUES(1005010,'And Enos lived after he begat Cainan eight hundred and fifteen years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005011,'And all the days of Enos were nine hundred and five years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005012,'And Cainan lived seventy years and begat Mahalaleel:');\nINSERT INTO t1(docid,words) VALUES(1005013,'And Cainan lived after he begat Mahalaleel eight hundred and forty years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005014,'And all the days of Cainan were nine hundred and ten years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005015,'And Mahalaleel lived sixty and five years, and begat Jared:');\nINSERT INTO t1(docid,words) VALUES(1005016,'And Mahalaleel lived after he begat Jared eight hundred and thirty years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005017,'And all the days of Mahalaleel were eight hundred ninety and five years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005018,'And Jared lived an hundred sixty and two years, and he begat Enoch:');\nINSERT INTO t1(docid,words) VALUES(1005019,'And Jared lived after he begat Enoch eight hundred years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005020,'And all the days of Jared were nine hundred sixty and two years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005021,'And Enoch lived sixty and five years, and begat Methuselah:');\nINSERT INTO t1(docid,words) VALUES(1005022,'And Enoch walked with God after he begat Methuselah three hundred years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005023,'And all the days of Enoch were three hundred sixty and five years:');\nINSERT INTO t1(docid,words) VALUES(1005024,'And Enoch walked with God: and he was not; for God took him.');\nINSERT INTO t1(docid,words) VALUES(1005025,'And Methuselah lived an hundred eighty and seven years, and begat Lamech.');\nINSERT INTO t1(docid,words) VALUES(1005026,'And Methuselah lived after he begat Lamech seven hundred eighty and two years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005027,'And all the days of Methuselah were nine hundred sixty and nine years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005028,'And Lamech lived an hundred eighty and two years, and begat a son:');\nINSERT INTO t1(docid,words) VALUES(1005029,'And he called his name Noah, saying, This same shall comfort us concerning our work and toil of our hands, because of the ground which the LORD hath cursed.');\nINSERT INTO t1(docid,words) VALUES(1005030,'And Lamech lived after he begat Noah five hundred ninety and five years, and begat sons and daughters:');\nINSERT INTO t1(docid,words) VALUES(1005031,'And all the days of Lamech were seven hundred seventy and seven years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1005032,'And Noah was five hundred years old: and Noah begat Shem, Ham, and Japheth.');\nINSERT INTO t1(docid,words) VALUES(1006001,'And it came to pass, when men began to multiply on the face of the earth, and daughters were born unto them,');\nINSERT INTO t1(docid,words) VALUES(1006002,'That the sons of God saw the daughters of men that they were fair; and they took them wives of all which they chose.');\nINSERT INTO t1(docid,words) VALUES(1006003,'And the LORD said, My spirit shall not always strive with man, for that he also is flesh: yet his days shall be an hundred and twenty years.');\nINSERT INTO t1(docid,words) VALUES(1006004,'There were giants in the earth in those days; and also after that, when the sons of God came in unto the daughters of men, and they bare children to them, the same became mighty men which were of old, men of renown.');\nINSERT INTO t1(docid,words) VALUES(1006005,'And God saw that the wickedness of man was great in the earth, and that every imagination of the thoughts of his heart was only evil continually.');\nINSERT INTO t1(docid,words) VALUES(1006006,'And it repented the LORD that he had made man on the earth, and it grieved him at his heart.');\nINSERT INTO t1(docid,words) VALUES(1006007,'And the LORD said, I will destroy man whom I have created from the face of the earth; both man, and beast, and the creeping thing, and the fowls of the air; for it repenteth me that I have made them.');\nINSERT INTO t1(docid,words) VALUES(1006008,'But Noah found grace in the eyes of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1006009,'These are the generations of Noah: Noah was a just man and perfect in his generations, and Noah walked with God.');\nINSERT INTO t1(docid,words) VALUES(1006010,'And Noah begat three sons, Shem, Ham, and Japheth.');\nINSERT INTO t1(docid,words) VALUES(1006011,'The earth also was corrupt before God, and the earth was filled with violence.');\nINSERT INTO t1(docid,words) VALUES(1006012,'And God looked upon the earth, and, behold, it was corrupt; for all flesh had corrupted his way upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1006013,'And God said unto Noah, The end of all flesh is come before me; for the earth is filled with violence through them; and, behold, I will destroy them with the earth.');\nINSERT INTO t1(docid,words) VALUES(1006014,'Make thee an ark of gopher wood; rooms shalt thou make in the ark, and shalt pitch it within and without with pitch.');\nINSERT INTO t1(docid,words) VALUES(1006015,'And this is the fashion which thou shalt make it of: The length of the ark shall be three hundred cubits, the breadth of it fifty cubits, and the height of it thirty cubits.');\nINSERT INTO t1(docid,words) VALUES(1006016,'A window shalt thou make to the ark, and in a cubit shalt thou finish it above; and the door of the ark shalt thou set in the side thereof; with lower, second, and third stories shalt thou make it.');\nINSERT INTO t1(docid,words) VALUES(1006017,'And, behold, I, even I, do bring a flood of waters upon the earth, to destroy all flesh, wherein is the breath of life, from under heaven; and every thing that is in the earth shall die.');\nINSERT INTO t1(docid,words) VALUES(1006018,'But with thee will I establish my covenant; and thou shalt come into the ark, thou, and thy sons, and thy wife, and thy sons'' wives with thee.');\nINSERT INTO t1(docid,words) VALUES(1006019,'And of every living thing of all flesh, two of every sort shalt thou bring into the ark, to keep them alive with thee; they shall be male and female.');\nINSERT INTO t1(docid,words) VALUES(1006020,'Of fowls after their kind, and of cattle after their kind, of every creeping thing of the earth after his kind, two of every sort shall come unto thee, to keep them alive.');\nINSERT INTO t1(docid,words) VALUES(1006021,'And take thou unto thee of all food that is eaten, and thou shalt gather it to thee; and it shall be for food for thee, and for them.');\nINSERT INTO t1(docid,words) VALUES(1006022,'Thus did Noah; according to all that God commanded him, so did he.');\nINSERT INTO t1(docid,words) VALUES(1007001,'And the LORD said unto Noah, Come thou and all thy house into the ark; for thee have I seen righteous before me in this generation.');\nINSERT INTO t1(docid,words) VALUES(1007002,'Of every clean beast thou shalt take to thee by sevens, the male and his female: and of beasts that are not clean by two, the male and his female.');\nINSERT INTO t1(docid,words) VALUES(1007003,'Of fowls also of the air by sevens, the male and the female; to keep seed alive upon the face of all the earth.');\nINSERT INTO t1(docid,words) VALUES(1007004,'For yet seven days, and I will cause it to rain upon the earth forty days and forty nights; and every living substance that I have made will I destroy from off the face of the earth.');\nINSERT INTO t1(docid,words) VALUES(1007005,'And Noah did according unto all that the LORD commanded him.');\nINSERT INTO t1(docid,words) VALUES(1007006,'And Noah was six hundred years old when the flood of waters was upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1007007,'And Noah went in, and his sons, and his wife, and his sons'' wives with him, into the ark, because of the waters of the flood.');\nINSERT INTO t1(docid,words) VALUES(1007008,'Of clean beasts, and of beasts that are not clean, and of fowls, and of every thing that creepeth upon the earth,');\nINSERT INTO t1(docid,words) VALUES(1007009,'There went in two and two unto Noah into the ark, the male and the female, as God had commanded Noah.');\nINSERT INTO t1(docid,words) VALUES(1007010,'And it came to pass after seven days, that the waters of the flood were upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1007011,'In the six hundredth year of Noah''s life, in the second month, the seventeenth day of the month, the same day were all the fountains of the great deep broken up, and the windows of heaven were opened.');\nINSERT INTO t1(docid,words) VALUES(1007012,'And the rain was upon the earth forty days and forty nights.');\nINSERT INTO t1(docid,words) VALUES(1007013,'In the selfsame day entered Noah, and Shem, and Ham, and Japheth, the sons of Noah, and Noah''s wife, and the three wives of his sons with them, into the ark;');\nINSERT INTO t1(docid,words) VALUES(1007014,'They, and every beast after his kind, and all the cattle after their kind, and every creeping thing that creepeth upon the earth after his kind, and every fowl after his kind, every bird of every sort.');\nINSERT INTO t1(docid,words) VALUES(1007015,'And they went in unto Noah into the ark, two and two of all flesh, wherein is the breath of life.');\nINSERT INTO t1(docid,words) VALUES(1007016,'And they that went in, went in male and female of all flesh, as God had commanded him: and the LORD shut him in.');\nINSERT INTO t1(docid,words) VALUES(1007017,'And the flood was forty days upon the earth; and the waters increased, and bare up the ark, and it was lift up above the earth.');\nINSERT INTO t1(docid,words) VALUES(1007018,'And the waters prevailed, and were increased greatly upon the earth; and the ark went upon the face of the waters.');\nINSERT INTO t1(docid,words) VALUES(1007019,'And the waters prevailed exceedingly upon the earth; and all the high hills, that were under the whole heaven, were covered.');\nINSERT INTO t1(docid,words) VALUES(1007020,'Fifteen cubits upward did the waters prevail; and the mountains were covered.');\nINSERT INTO t1(docid,words) VALUES(1007021,'And all flesh died that moved upon the earth, both of fowl, and of cattle, and of beast, and of every creeping thing that creepeth upon the earth, and every man:');\nINSERT INTO t1(docid,words) VALUES(1007022,'All in whose nostrils was the breath of life, of all that was in the dry land, died.');\nINSERT INTO t1(docid,words) VALUES(1007023,'And every living substance was destroyed which was upon the face of the ground, both man, and cattle, and the creeping things, and the fowl of the heaven; and they were destroyed from the earth: and Noah only remained alive, and they that were with him in the ark.');\nINSERT INTO t1(docid,words) VALUES(1007024,'And the waters prevailed upon the earth an hundred and fifty days.');\nINSERT INTO t1(docid,words) VALUES(1008001,'And God remembered Noah, and every living thing, and all the cattle that was with him in the ark: and God made a wind to pass over the earth, and the waters asswaged;');\nINSERT INTO t1(docid,words) VALUES(1008002,'The fountains also of the deep and the windows of heaven were stopped, and the rain from heaven was restrained;');\nINSERT INTO t1(docid,words) VALUES(1008003,'And the waters returned from off the earth continually: and after the end of the hundred and fifty days the waters were abated.');\nINSERT INTO t1(docid,words) VALUES(1008004,'And the ark rested in the seventh month, on the seventeenth day of the month, upon the mountains of Ararat.');\nINSERT INTO t1(docid,words) VALUES(1008005,'And the waters decreased continually until the tenth month: in the tenth month, on the first day of the month, were the tops of the mountains seen.');\nINSERT INTO t1(docid,words) VALUES(1008006,'And it came to pass at the end of forty days, that Noah opened the window of the ark which he had made:');\nINSERT INTO t1(docid,words) VALUES(1008007,'And he sent forth a raven, which went forth to and fro, until the waters were dried up from off the earth.');\nINSERT INTO t1(docid,words) VALUES(1008008,'Also he sent forth a dove from him, to see if the waters were abated from off the face of the ground;');\nINSERT INTO t1(docid,words) VALUES(1008009,'But the dove found no rest for the sole of her foot, and she returned unto him into the ark, for the waters were on the face of the whole earth: then he put forth his hand, and took her, and pulled her in unto him into the ark.');\nINSERT INTO t1(docid,words) VALUES(1008010,'And he stayed yet other seven days; and again he sent forth the dove out of the ark;');\nINSERT INTO t1(docid,words) VALUES(1008011,'And the dove came in to him in the evening; and, lo, in her mouth was an olive leaf pluckt off: so Noah knew that the waters were abated from off the earth.');\nINSERT INTO t1(docid,words) VALUES(1008012,'And he stayed yet other seven days; and sent forth the dove; which returned not again unto him any more.');\nINSERT INTO t1(docid,words) VALUES(1008013,'And it came to pass in the six hundredth and first year, in the first month, the first day of the month, the waters were dried up from off the earth: and Noah removed the covering of the ark, and looked, and, behold, the face of the ground was dry.');\nINSERT INTO t1(docid,words) VALUES(1008014,'And in the second month, on the seven and twentieth day of the month, was the earth dried.');\nINSERT INTO t1(docid,words) VALUES(1008015,'And God spake unto Noah, saying,');\nINSERT INTO t1(docid,words) VALUES(1008016,'Go forth of the ark, thou, and thy wife, and thy sons, and thy sons'' wives with thee.');\nINSERT INTO t1(docid,words) VALUES(1008017,'Bring forth with thee every living thing that is with thee, of all flesh, both of fowl, and of cattle, and of every creeping thing that creepeth upon the earth; that they may breed abundantly in the earth, and be fruitful, and multiply upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1008018,'And Noah went forth, and his sons, and his wife, and his sons'' wives with him:');\nINSERT INTO t1(docid,words) VALUES(1008019,'Every beast, every creeping thing, and every fowl, and whatsoever creepeth upon the earth, after their kinds, went forth out of the ark.');\nINSERT INTO t1(docid,words) VALUES(1008020,'And Noah builded an altar unto the LORD; and took of every clean beast, and of every clean fowl, and offered burnt offerings on the altar.');\nINSERT INTO t1(docid,words) VALUES(1008021,'And the LORD smelled a sweet savour; and the LORD said in his heart, I will not again curse the ground any more for man''s sake; for the imagination of man''s heart is evil from his youth; neither will I again smite any more every thing living, as I have done.');\nINSERT INTO t1(docid,words) VALUES(1008022,'While the earth remaineth, seedtime and harvest, and cold and heat, and summer and winter, and day and night shall not cease.');\nINSERT INTO t1(docid,words) VALUES(1009001,'And God blessed Noah and his sons, and said unto them, Be fruitful, and multiply, and replenish the earth.');\nINSERT INTO t1(docid,words) VALUES(1009002,'And the fear of you and the dread of you shall be upon every beast of the earth, and upon every fowl of the air, upon all that moveth upon the earth, and upon all the fishes of the sea; into your hand are they delivered.');\nINSERT INTO t1(docid,words) VALUES(1009003,'Every moving thing that liveth shall be meat for you; even as the green herb have I given you all things.');\nINSERT INTO t1(docid,words) VALUES(1009004,'But flesh with the life thereof, which is the blood thereof, shall ye not eat.');\nINSERT INTO t1(docid,words) VALUES(1009005,'And surely your blood of your lives will I require; at the hand of every beast will I require it, and at the hand of man; at the hand of every man''s brother will I require the life of man.');\nINSERT INTO t1(docid,words) VALUES(1009006,'Whoso sheddeth man''s blood, by man shall his blood be shed: for in the image of God made he man.');\nINSERT INTO t1(docid,words) VALUES(1009007,'And you, be ye fruitful, and multiply; bring forth abundantly in the earth, and multiply therein.');\nINSERT INTO t1(docid,words) VALUES(1009008,'And God spake unto Noah, and to his sons with him, saying,');\nINSERT INTO t1(docid,words) VALUES(1009009,'And I, behold, I establish my covenant with you, and with your seed after you;');\nINSERT INTO t1(docid,words) VALUES(1009010,'And with every living creature that is with you, of the fowl, of the cattle, and of every beast of the earth with you; from all that go out of the ark, to every beast of the earth.');\nINSERT INTO t1(docid,words) VALUES(1009011,'And I will establish my covenant with you, neither shall all flesh be cut off any more by the waters of a flood; neither shall there any more be a flood to destroy the earth.');\nINSERT INTO t1(docid,words) VALUES(1009012,'And God said, This is the token of the covenant which I make between me and you and every living creature that is with you, for perpetual generations:');\nINSERT INTO t1(docid,words) VALUES(1009013,'I do set my bow in the cloud, and it shall be for a token of a covenant between me and the earth.');\nINSERT INTO t1(docid,words) VALUES(1009014,'And it shall come to pass, when I bring a cloud over the earth, that the bow shall be seen in the cloud:');\nINSERT INTO t1(docid,words) VALUES(1009015,'And I will remember my covenant, which is between me and you and every living creature of all flesh; and the waters shall no more become a flood to destroy all flesh.');\nINSERT INTO t1(docid,words) VALUES(1009016,'And the bow shall be in the cloud; and I will look upon it, that I may remember the everlasting covenant between God and every living creature of all flesh that is upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1009017,'And God said unto Noah, This is the token of the covenant, which I have established between me and all flesh that is upon the earth.');\nINSERT INTO t1(docid,words) VALUES(1009018,'And the sons of Noah, that went forth of the ark, were Shem, and Ham, and Japheth: and Ham is the father of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1009019,'These are the three sons of Noah: and of them was the whole earth overspread.');\nINSERT INTO t1(docid,words) VALUES(1009020,'And Noah began to be an husbandman, and he planted a vineyard:');\nINSERT INTO t1(docid,words) VALUES(1009021,'And he drank of the wine, and was drunken; and he was uncovered within his tent.');\nINSERT INTO t1(docid,words) VALUES(1009022,'And Ham, the father of Canaan, saw the nakedness of his father, and told his two brethren without.');\nINSERT INTO t1(docid,words) VALUES(1009023,'And Shem and Japheth took a garment, and laid it upon both their shoulders, and went backward, and covered the nakedness of their father; and their faces were backward, and they saw not their father''s nakedness.');\nINSERT INTO t1(docid,words) VALUES(1009024,'And Noah awoke from his wine, and knew what his younger son had done unto him.');\nINSERT INTO t1(docid,words) VALUES(1009025,'And he said, Cursed be Canaan; a servant of servants shall he be unto his brethren.');\nINSERT INTO t1(docid,words) VALUES(1009026,'And he said, Blessed be the LORD God of Shem; and Canaan shall be his servant.');\nINSERT INTO t1(docid,words) VALUES(1009027,'God shall enlarge Japheth, and he shall dwell in the tents of Shem; and Canaan shall be his servant.');\nINSERT INTO t1(docid,words) VALUES(1009028,'And Noah lived after the flood three hundred and fifty years.');\nINSERT INTO t1(docid,words) VALUES(1009029,'And all the days of Noah were nine hundred and fifty years: and he died.');\nINSERT INTO t1(docid,words) VALUES(1010001,'Now these are the generations of the sons of Noah, Shem, Ham, and Japheth: and unto them were sons born after the flood.');\nINSERT INTO t1(docid,words) VALUES(1010002,'The sons of Japheth; Gomer, and Magog, and Madai, and Javan, and Tubal, and Meshech, and Tiras.');\nINSERT INTO t1(docid,words) VALUES(1010003,'And the sons of Gomer; Ashkenaz, and Riphath, and Togarmah.');\nINSERT INTO t1(docid,words) VALUES(1010004,'And the sons of Javan; Elishah, and Tarshish, Kittim, and Dodanim.');\nINSERT INTO t1(docid,words) VALUES(1010005,'By these were the isles of the Gentiles divided in their lands; every one after his tongue, after their families, in their nations.');\nINSERT INTO t1(docid,words) VALUES(1010006,'And the sons of Ham; Cush, and Mizraim, and Phut, and Canaan.');\nINSERT INTO t1(docid,words) VALUES(1010007,'And the sons of Cush; Seba, and Havilah, and Sabtah, and Raamah, and Sabtechah: and the sons of Raamah; Sheba, and Dedan.');\nINSERT INTO t1(docid,words) VALUES(1010008,'And Cush begat Nimrod: he began to be a mighty one in the earth.');\nINSERT INTO t1(docid,words) VALUES(1010009,'He was a mighty hunter before the LORD: wherefore it is said, Even as Nimrod the mighty hunter before the LORD.');\nINSERT INTO t1(docid,words) VALUES(1010010,'And the beginning of his kingdom was Babel, and Erech, and Accad, and Calneh, in the land of Shinar.');\nINSERT INTO t1(docid,words) VALUES(1010011,'Out of that land went forth Asshur, and builded Nineveh, and the city Rehoboth, and Calah,');\nINSERT INTO t1(docid,words) VALUES(1010012,'And Resen between Nineveh and Calah: the same is a great city.');\nINSERT INTO t1(docid,words) VALUES(1010013,'And Mizraim begat Ludim, and Anamim, and Lehabim, and Naphtuhim,');\nINSERT INTO t1(docid,words) VALUES(1010014,'And Pathrusim, and Casluhim, (out of whom came Philistim,) and Caphtorim.');\nINSERT INTO t1(docid,words) VALUES(1010015,'And Canaan begat Sidon his first born, and Heth,');\nINSERT INTO t1(docid,words) VALUES(1010016,'And the Jebusite, and the Amorite, and the Girgasite,');\nINSERT INTO t1(docid,words) VALUES(1010017,'And the Hivite, and the Arkite, and the Sinite,');\nINSERT INTO t1(docid,words) VALUES(1010018,'And the Arvadite, and the Zemarite, and the Hamathite: and afterward were the families of the Canaanites spread abroad.');\nINSERT INTO t1(docid,words) VALUES(1010019,'And the border of the Canaanites was from Sidon, as thou comest to Gerar, unto Gaza; as thou goest, unto Sodom, and Gomorrah, and Admah, and Zeboim, even unto Lasha.');\nINSERT INTO t1(docid,words) VALUES(1010020,'These are the sons of Ham, after their families, after their tongues, in their countries, and in their nations.');\nINSERT INTO t1(docid,words) VALUES(1010021,'Unto Shem also, the father of all the children of Eber, the brother of Japheth the elder, even to him were children born.');\nINSERT INTO t1(docid,words) VALUES(1010022,'The children of Shem; Elam, and Asshur, and Arphaxad, and Lud, and Aram.');\nINSERT INTO t1(docid,words) VALUES(1010023,'And the children of Aram; Uz, and Hul, and Gether, and Mash.');\nINSERT INTO t1(docid,words) VALUES(1010024,'And Arphaxad begat Salah; and Salah begat Eber.');\nINSERT INTO t1(docid,words) VALUES(1010025,'And unto Eber were born two sons: the name of one was Peleg; for in his days was the earth divided; and his brother''s name was Joktan.');\nINSERT INTO t1(docid,words) VALUES(1010026,'And Joktan begat Almodad, and Sheleph, and Hazarmaveth, and Jerah,');\nINSERT INTO t1(docid,words) VALUES(1010027,'And Hadoram, and Uzal, and Diklah,');\nINSERT INTO t1(docid,words) VALUES(1010028,'And Obal, and Abimael, and Sheba,');\nINSERT INTO t1(docid,words) VALUES(1010029,'And Ophir, and Havilah, and Jobab: all these were the sons of Joktan.');\nINSERT INTO t1(docid,words) VALUES(1010030,'And their dwelling was from Mesha, as thou goest unto Sephar a mount of the east.');\nINSERT INTO t1(docid,words) VALUES(1010031,'These are the sons of Shem, after their families, after their tongues, in their lands, after their nations.');\nINSERT INTO t1(docid,words) VALUES(1010032,'These are the families of the sons of Noah, after their generations, in their nations: and by these were the nations divided in the earth after the flood.');\nINSERT INTO t1(docid,words) VALUES(1011001,'And the whole earth was of one language, and of one speech.');\nINSERT INTO t1(docid,words) VALUES(1011002,'And it came to pass, as they journeyed from the east, that they found a plain in the land of Shinar; and they dwelt there.');\nINSERT INTO t1(docid,words) VALUES(1011003,'And they said one to another, Go to, let us make brick, and burn them thoroughly. And they had brick for stone, and slime had they for morter.');\nINSERT INTO t1(docid,words) VALUES(1011004,'And they said, Go to, let us build us a city and a tower, whose top may reach unto heaven; and let us make us a name, lest we be scattered abroad upon the face of the whole earth.');\nINSERT INTO t1(docid,words) VALUES(1011005,'And the LORD came down to see the city and the tower, which the children of men builded.');\nINSERT INTO t1(docid,words) VALUES(1011006,'And the LORD said, Behold, the people is one, and they have all one language; and this they begin to do: and now nothing will be restrained from them, which they have imagined to do.');\nINSERT INTO t1(docid,words) VALUES(1011007,'Go to, let us go down, and there confound their language, that they may not understand one another''s speech.');\nINSERT INTO t1(docid,words) VALUES(1011008,'So the LORD scattered them abroad from thence upon the face of all the earth: and they left off to build the city.');\nINSERT INTO t1(docid,words) VALUES(1011009,'Therefore is the name of it called Babel; because the LORD did there confound the language of all the earth: and from thence did the LORD scatter them abroad upon the face of all the earth.');\nINSERT INTO t1(docid,words) VALUES(1011010,'These are the generations of Shem: Shem was an hundred years old, and begat Arphaxad two years after the flood:');\nINSERT INTO t1(docid,words) VALUES(1011011,'And Shem lived after he begat Arphaxad five hundred years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011012,'And Arphaxad lived five and thirty years, and begat Salah:');\nINSERT INTO t1(docid,words) VALUES(1011013,'And Arphaxad lived after he begat Salah four hundred and three years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011014,'And Salah lived thirty years, and begat Eber:');\nINSERT INTO t1(docid,words) VALUES(1011015,'And Salah lived after he begat Eber four hundred and three years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011016,'And Eber lived four and thirty years, and begat Peleg:');\nINSERT INTO t1(docid,words) VALUES(1011017,'And Eber lived after he begat Peleg four hundred and thirty years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011018,'And Peleg lived thirty years, and begat Reu:');\nINSERT INTO t1(docid,words) VALUES(1011019,'And Peleg lived after he begat Reu two hundred and nine years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011020,'And Reu lived two and thirty years, and begat Serug:');\nINSERT INTO t1(docid,words) VALUES(1011021,'And Reu lived after he begat Serug two hundred and seven years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011022,'And Serug lived thirty years, and begat Nahor:');\nINSERT INTO t1(docid,words) VALUES(1011023,'And Serug lived after he begat Nahor two hundred years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011024,'And Nahor lived nine and twenty years, and begat Terah:');\nINSERT INTO t1(docid,words) VALUES(1011025,'And Nahor lived after he begat Terah an hundred and nineteen years, and begat sons and daughters.');\nINSERT INTO t1(docid,words) VALUES(1011026,'And Terah lived seventy years, and begat Abram, Nahor, and Haran.');\nINSERT INTO t1(docid,words) VALUES(1011027,'Now these are the generations of Terah: Terah begat Abram, Nahor, and Haran; and Haran begat Lot.');\nINSERT INTO t1(docid,words) VALUES(1011028,'And Haran died before his father Terah in the land of his nativity, in Ur of the Chaldees.');\nINSERT INTO t1(docid,words) VALUES(1011029,'And Abram and Nahor took them wives: the name of Abram''s wife was Sarai; and the name of Nahor''s wife, Milcah, the daughter of Haran, the father of Milcah, and the father of Iscah.');\nINSERT INTO t1(docid,words) VALUES(1011030,'But Sarai was barren; she had no child.');\nINSERT INTO t1(docid,words) VALUES(1011031,'And Terah took Abram his son, and Lot the son of Haran his son''s son, and Sarai his daughter in law, his son Abram''s wife; and they went forth with them from Ur of the Chaldees, to go into the land of Canaan; and they came unto Haran, and dwelt there.');\nINSERT INTO t1(docid,words) VALUES(1011032,'And the days of Terah were two hundred and five years: and Terah died in Haran.');\nINSERT INTO t1(docid,words) VALUES(1012001,'Now the LORD had said unto Abram, Get thee out of thy country, and from thy kindred, and from thy father''s house, unto a land that I will shew thee:');\nINSERT INTO t1(docid,words) VALUES(1012002,'And I will make of thee a great nation, and I will bless thee, and make thy name great; and thou shalt be a blessing:');\nINSERT INTO t1(docid,words) VALUES(1012003,'And I will bless them that bless thee, and curse him that curseth thee: and in thee shall all families of the earth be blessed.');\nINSERT INTO t1(docid,words) VALUES(1012004,'So Abram departed, as the LORD had spoken unto him; and Lot went with him: and Abram was seventy and five years old when he departed out of Haran.');\nINSERT INTO t1(docid,words) VALUES(1012005,'And Abram took Sarai his wife, and Lot his brother''s son, and all their substance that they had gathered, and the souls that they had gotten in Haran; and they went forth to go into the land of Canaan; and into the land of Canaan they came.');\nINSERT INTO t1(docid,words) VALUES(1012006,'And Abram passed through the land unto the place of Sichem, unto the plain of Moreh. And the Canaanite was then in the land.');\nINSERT INTO t1(docid,words) VALUES(1012007,'And the LORD appeared unto Abram, and said, Unto thy seed will I give this land: and there builded he an altar unto the LORD, who appeared unto him.');\nINSERT INTO t1(docid,words) VALUES(1012008,'And he removed from thence unto a mountain on the east of Bethel, and pitched his tent, having Bethel on the west, and Hai on the east: and there he builded an altar unto the LORD, and called upon the name of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1012009,'And Abram journeyed, going on still toward the south.');\nINSERT INTO t1(docid,words) VALUES(1012010,'And there was a famine in the land: and Abram went down into Egypt to sojourn there; for the famine was grievous in the land.');\nINSERT INTO t1(docid,words) VALUES(1012011,'And it came to pass, when he was come near to enter into Egypt, that he said unto Sarai his wife, Behold now, I know that thou art a fair woman to look upon:');\nINSERT INTO t1(docid,words) VALUES(1012012,'Therefore it shall come to pass, when the Egyptians shall see thee, that they shall say, This is his wife: and they will kill me, but they will save thee alive.');\nINSERT INTO t1(docid,words) VALUES(1012013,'Say, I pray thee, thou art my sister: that it may be well with me for thy sake; and my soul shall live because of thee.');\nINSERT INTO t1(docid,words) VALUES(1012014,'And it came to pass, that, when Abram was come into Egypt, the Egyptians beheld the woman that she was very fair.');\nINSERT INTO t1(docid,words) VALUES(1012015,'The princes also of Pharaoh saw her, and commended her before Pharaoh: and the woman was taken into Pharaoh''s house.');\nINSERT INTO t1(docid,words) VALUES(1012016,'And he entreated Abram well for her sake: and he had sheep, and oxen, and he asses, and menservants, and maidservants, and she asses, and camels.');\nINSERT INTO t1(docid,words) VALUES(1012017,'And the LORD plagued Pharaoh and his house with great plagues because of Sarai Abram''s wife.');\nINSERT INTO t1(docid,words) VALUES(1012018,'And Pharaoh called Abram and said, What is this that thou hast done unto me? why didst thou not tell me that she was thy wife?');\nINSERT INTO t1(docid,words) VALUES(1012019,'Why saidst thou, She is my sister? so I might have taken her to me to wife: now therefore behold thy wife, take her, and go thy way.');\nINSERT INTO t1(docid,words) VALUES(1012020,'And Pharaoh commanded his men concerning him: and they sent him away, and his wife, and all that he had.');\nINSERT INTO t1(docid,words) VALUES(1013001,'And Abram went up out of Egypt, he, and his wife, and all that he had, and Lot with him, into the south.');\nINSERT INTO t1(docid,words) VALUES(1013002,'And Abram was very rich in cattle, in silver, and in gold.');\nINSERT INTO t1(docid,words) VALUES(1013003,'And he went on his journeys from the south even to Bethel, unto the place where his tent had been at the beginning, between Bethel and Hai;');\nINSERT INTO t1(docid,words) VALUES(1013004,'Unto the place of the altar, which he had make there at the first: and there Abram called on the name of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1013005,'And Lot also, which went with Abram, had flocks, and herds, and tents.');\nINSERT INTO t1(docid,words) VALUES(1013006,'And the land was not able to bear them, that they might dwell together: for their substance was great, so that they could not dwell together.');\nINSERT INTO t1(docid,words) VALUES(1013007,'And there was a strife between the herdmen of Abram''s cattle and the herdmen of Lot''s cattle: and the Canaanite and the Perizzite dwelled then in the land.');\nINSERT INTO t1(docid,words) VALUES(1013008,'And Abram said unto Lot, Let there be no strife, I pray thee, between me and thee, and between my herdmen and thy herdmen; for we be brethren.');\nINSERT INTO t1(docid,words) VALUES(1013009,'Is not the whole land before thee? separate thyself, I pray thee, from me: if thou wilt take the left hand, then I will go to the right; or if thou depart to the right hand, then I will go to the left.');\nINSERT INTO t1(docid,words) VALUES(1013010,'And Lot lifted up his eyes, and beheld all the plain of Jordan, that it was well watered every where, before the LORD destroyed Sodom and Gomorrah, even as the garden of the LORD, like the land of Egypt, as thou comest unto Zoar.');\nINSERT INTO t1(docid,words) VALUES(1013011,'Then Lot chose him all the plain of Jordan; and Lot journeyed east: and they separated themselves the one from the other.');\nINSERT INTO t1(docid,words) VALUES(1013012,'Abram dwelled in the land of Canaan, and Lot dwelled in the cities of the plain, and pitched his tent toward Sodom.');\nINSERT INTO t1(docid,words) VALUES(1013013,'But the men of Sodom were wicked and sinners before the LORD exceedingly.');\nINSERT INTO t1(docid,words) VALUES(1013014,'And the LORD said unto Abram, after that Lot was separated from him, Lift up now thine eyes, and look from the place where thou art northward, and southward, and eastward, and westward:');\nINSERT INTO t1(docid,words) VALUES(1013015,'For all the land which thou seest, to thee will I give it, and to thy seed for ever.');\nINSERT INTO t1(docid,words) VALUES(1013016,'And I will make thy seed as the dust of the earth: so that if a man can number the dust of the earth, then shall thy seed also be numbered.');\nINSERT INTO t1(docid,words) VALUES(1013017,'Arise, walk through the land in the length of it and in the breadth of it; for I will give it unto thee.');\nINSERT INTO t1(docid,words) VALUES(1013018,'Then Abram removed his tent, and came and dwelt in the plain of Mamre, which is in Hebron, and built there an altar unto the LORD.');\nINSERT INTO t1(docid,words) VALUES(1014001,'And it came to pass in the days of Amraphel king of Shinar, Arioch king of Ellasar, Chedorlaomer king of Elam, and Tidal king of nations;');\nINSERT INTO t1(docid,words) VALUES(1014002,'That these made war with Bera king of Sodom, and with Birsha king of Gomorrah, Shinab king of Admah, and Shemeber king of Zeboiim, and the king of Bela, which is Zoar.');\nINSERT INTO t1(docid,words) VALUES(1014003,'All these were joined together in the vale of Siddim, which is the salt sea.');\nINSERT INTO t1(docid,words) VALUES(1014004,'Twelve years they served Chedorlaomer, and in the thirteenth year they rebelled.');\nINSERT INTO t1(docid,words) VALUES(1014005,'And in the fourteenth year came Chedorlaomer, and the kings that were with him, and smote the Rephaims in Ashteroth Karnaim, and the Zuzims in Ham, and the Emins in Shaveh Kiriathaim,');\nINSERT INTO t1(docid,words) VALUES(1014006,'And the Horites in their mount Seir, unto Elparan, which is by the wilderness.');\nINSERT INTO t1(docid,words) VALUES(1014007,'And they returned, and came to Enmishpat, which is Kadesh, and smote all the country of the Amalekites, and also the Amorites, that dwelt in Hazezontamar.');\nINSERT INTO t1(docid,words) VALUES(1014008,'And there went out the king of Sodom, and the king of Gomorrah, and the king of Admah, and the king of Zeboiim, and the king of Bela (the same is Zoar;) and they joined battle with them in the vale of Siddim;');\nINSERT INTO t1(docid,words) VALUES(1014009,'With Chedorlaomer the king of Elam, and with Tidal king of nations, and Amraphel king of Shinar, and Arioch king of Ellasar; four kings with five.');\nINSERT INTO t1(docid,words) VALUES(1014010,'And the vale of Siddim was full of slimepits; and the kings of Sodom and Gomorrah fled, and fell there; and they that remained fled to the mountain.');\nINSERT INTO t1(docid,words) VALUES(1014011,'And they took all the goods of Sodom and Gomorrah, and all their victuals, and went their way.');\nINSERT INTO t1(docid,words) VALUES(1014012,'And they took Lot, Abram''s brother''s son, who dwelt in Sodom, and his goods, and departed.');\nINSERT INTO t1(docid,words) VALUES(1014013,'And there came one that had escaped, and told Abram the Hebrew; for he dwelt in the plain of Mamre the Amorite, brother of Eshcol, and brother of Aner: and these were confederate with Abram.');\nINSERT INTO t1(docid,words) VALUES(1014014,'And when Abram heard that his brother was taken captive, he armed his trained servants, born in his own house, three hundred and eighteen, and pursued them unto Dan.');\nINSERT INTO t1(docid,words) VALUES(1014015,'And he divided himself against them, he and his servants, by night, and smote them, and pursued them unto Hobah, which is on the left hand of Damascus.');\nINSERT INTO t1(docid,words) VALUES(1014016,'And he brought back all the goods, and also brought again his brother Lot, and his goods, and the women also, and the people.');\nINSERT INTO t1(docid,words) VALUES(1014017,'And the king of Sodom went out to meet him after his return from the slaughter of Chedorlaomer, and of the kings that were with him, at the valley of Shaveh, which is the king''s dale.');\nINSERT INTO t1(docid,words) VALUES(1014018,'And Melchizedek king of Salem brought forth bread and wine: and he was the priest of the most high God.');\nINSERT INTO t1(docid,words) VALUES(1014019,'And he blessed him, and said, Blessed be Abram of the most high God, possessor of heaven and earth:');\nINSERT INTO t1(docid,words) VALUES(1014020,'And blessed be the most high God, which hath delivered thine enemies into thy hand. And he gave him tithes of all.');\nINSERT INTO t1(docid,words) VALUES(1014021,'And the king of Sodom said unto Abram, Give me the persons, and take the goods to thyself.');\nINSERT INTO t1(docid,words) VALUES(1014022,'And Abram said to the king of Sodom, I have lift up mine hand unto the LORD, the most high God, the possessor of heaven and earth,');\nINSERT INTO t1(docid,words) VALUES(1014023,'That I will not take from a thread even to a shoelatchet, and that I will not take any thing that is thine, lest thou shouldest say, I have made Abram rich:');\nINSERT INTO t1(docid,words) VALUES(1014024,'Save only that which the young men have eaten, and the portion of the men which went with me, Aner, Eshcol, and Mamre; let them take their portion.');\nINSERT INTO t1(docid,words) VALUES(1015001,'After these things the word of the LORD came unto Abram in a vision, saying, Fear not, Abram: I am thy shield, and thy exceeding great reward.');\nINSERT INTO t1(docid,words) VALUES(1015002,'And Abram said, LORD God, what wilt thou give me, seeing I go childless, and the steward of my house is this Eliezer of Damascus?');\nINSERT INTO t1(docid,words) VALUES(1015003,'And Abram said, Behold, to me thou hast given no seed: and, lo, one born in my house is mine heir.');\nINSERT INTO t1(docid,words) VALUES(1015004,'And, behold, the word of the LORD came unto him, saying, This shall not be thine heir; but he that shall come forth out of thine own bowels shall be thine heir.');\nINSERT INTO t1(docid,words) VALUES(1015005,'And he brought him forth abroad, and said, Look now toward heaven, and tell the stars, if thou be able to number them: and he said unto him, So shall thy seed be.');\nINSERT INTO t1(docid,words) VALUES(1015006,'And he believed in the LORD; and he counted it to him for righteousness.');\nINSERT INTO t1(docid,words) VALUES(1015007,'And he said unto him, I am the LORD that brought thee out of Ur of the Chaldees, to give thee this land to inherit it.');\nINSERT INTO t1(docid,words) VALUES(1015008,'And he said, LORD God, whereby shall I know that I shall inherit it?');\nINSERT INTO t1(docid,words) VALUES(1015009,'And he said unto him, Take me an heifer of three years old, and a she goat of three years old, and a ram of three years old, and a turtledove, and a young pigeon.');\nINSERT INTO t1(docid,words) VALUES(1015010,'And he took unto him all these, and divided them in the midst, and laid each piece one against another: but the birds divided he not.');\nINSERT INTO t1(docid,words) VALUES(1015011,'And when the fowls came down upon the carcases, Abram drove them away.');\nINSERT INTO t1(docid,words) VALUES(1015012,'And when the sun was going down, a deep sleep fell upon Abram; and, lo, an horror of great darkness fell upon him.');\nINSERT INTO t1(docid,words) VALUES(1015013,'And he said unto Abram, Know of a surety that thy seed shall be a stranger in a land that is not their''s, and shall serve them; and they shall afflict them four hundred years;');\nINSERT INTO t1(docid,words) VALUES(1015014,'And also that nation, whom they shall serve, will I judge: and afterward shall they come out with great substance.');\nINSERT INTO t1(docid,words) VALUES(1015015,'And thou shalt go to thy fathers in peace; thou shalt be buried in a good old age.');\nINSERT INTO t1(docid,words) VALUES(1015016,'But in the fourth generation they shall come hither again: for the iniquity of the Amorites is not yet full.');\nINSERT INTO t1(docid,words) VALUES(1015017,'And it came to pass, that, when the sun went down, and it was dark, behold a smoking furnace, and a burning lamp that passed between those pieces.');\nINSERT INTO t1(docid,words) VALUES(1015018,'In the same day the LORD made a covenant with Abram, saying, Unto thy seed have I given this land, from the river of Egypt unto the great river, the river Euphrates:');\nINSERT INTO t1(docid,words) VALUES(1015019,'The Kenites, and the Kenizzites, and the Kadmonites,');\nINSERT INTO t1(docid,words) VALUES(1015020,'And the Hittites, and the Perizzites, and the Rephaims,');\nINSERT INTO t1(docid,words) VALUES(1015021,'And the Amorites, and the Canaanites, and the Girgashites, and the Jebusites.');\nINSERT INTO t1(docid,words) VALUES(1016001,'Now Sarai Abram''s wife bare him no children: and she had an handmaid, an Egyptian, whose name was Hagar.');\nINSERT INTO t1(docid,words) VALUES(1016002,'And Sarai said unto Abram, Behold now, the LORD hath restrained me from bearing: I pray thee, go in unto my maid; it may be that I may obtain children by her. And Abram hearkened to the voice of Sarai.');\nINSERT INTO t1(docid,words) VALUES(1016003,'And Sarai Abram''s wife took Hagar her maid the Egyptian, after Abram had dwelt ten years in the land of Canaan, and gave her to her husband Abram to be his wife.');\nINSERT INTO t1(docid,words) VALUES(1016004,'And he went in unto Hagar, and she conceived: and when she saw that she had conceived, her mistress was despised in her eyes.');\nINSERT INTO t1(docid,words) VALUES(1016005,'And Sarai said unto Abram, My wrong be upon thee: I have given my maid into thy bosom; and when she saw that she had conceived, I was despised in her eyes: the LORD judge between me and thee.');\nINSERT INTO t1(docid,words) VALUES(1016006,'But Abram said unto Sarai, Behold, thy maid is in thine hand; do to her as it pleaseth thee. And when Sarai dealt hardly with her, she fled from her face.');\nINSERT INTO t1(docid,words) VALUES(1016007,'And the angel of the LORD found her by a fountain of water in the wilderness, by the fountain in the way to Shur.');\nINSERT INTO t1(docid,words) VALUES(1016008,'And he said, Hagar, Sarai''s maid, whence camest thou? and whither wilt thou go? And she said, I flee from the face of my mistress Sarai.');\nINSERT INTO t1(docid,words) VALUES(1016009,'And the angel of the LORD said unto her, Return to thy mistress, and submit thyself under her hands.');\nINSERT INTO t1(docid,words) VALUES(1016010,'And the angel of the LORD said unto her, I will multiply thy seed exceedingly, that it shall not be numbered for multitude.');\nINSERT INTO t1(docid,words) VALUES(1016011,'And the angel of the LORD said unto her, Behold, thou art with child and shalt bear a son, and shalt call his name Ishmael; because the LORD hath heard thy affliction.');\nINSERT INTO t1(docid,words) VALUES(1016012,'And he will be a wild man; his hand will be against every man, and every man''s hand against him; and he shall dwell in the presence of all his brethren.');\nINSERT INTO t1(docid,words) VALUES(1016013,'And she called the name of the LORD that spake unto her, Thou God seest me: for she said, Have I also here looked after him that seeth me?');\nINSERT INTO t1(docid,words) VALUES(1016014,'Wherefore the well was called Beerlahairoi; behold, it is between Kadesh and Bered.');\nINSERT INTO t1(docid,words) VALUES(1016015,'And Hagar bare Abram a son: and Abram called his son''s name, which Hagar bare, Ishmael.');\nINSERT INTO t1(docid,words) VALUES(1016016,'And Abram was fourscore and six years old, when Hagar bare Ishmael to Abram.');\nINSERT INTO t1(docid,words) VALUES(1017001,'And when Abram was ninety years old and nine, the LORD appeared to Abram, and said unto him, I am the Almighty God; walk before me, and be thou perfect.');\nINSERT INTO t1(docid,words) VALUES(1017002,'And I will make my covenant between me and thee, and will multiply thee exceedingly.');\nINSERT INTO t1(docid,words) VALUES(1017003,'And Abram fell on his face: and God talked with him, saying,');\nINSERT INTO t1(docid,words) VALUES(1017004,'As for me, behold, my covenant is with thee, and thou shalt be a father of many nations.');\nINSERT INTO t1(docid,words) VALUES(1017005,'Neither shall thy name any more be called Abram, but thy name shall be Abraham; for a father of many nations have I made thee.');\nINSERT INTO t1(docid,words) VALUES(1017006,'And I will make thee exceeding fruitful, and I will make nations of thee, and kings shall come out of thee.');\nINSERT INTO t1(docid,words) VALUES(1017007,'And I will establish my covenant between me and thee and thy seed after thee in their generations for an everlasting covenant, to be a God unto thee, and to thy seed after thee.');\nINSERT INTO t1(docid,words) VALUES(1017008,'And I will give unto thee, and to thy seed after thee, the land wherein thou art a stranger, all the land of Canaan, for an everlasting possession; and I will be their God.');\nINSERT INTO t1(docid,words) VALUES(1017009,'And God said unto Abraham, Thou shalt keep my covenant therefore, thou, and thy seed after thee in their generations.');\nINSERT INTO t1(docid,words) VALUES(1017010,'This is my covenant, which ye shall keep, between me and you and thy seed after thee; Every man child among you shall be circumcised.');\nINSERT INTO t1(docid,words) VALUES(1017011,'And ye shall circumcise the flesh of your foreskin; and it shall be a token of the covenant betwixt me and you.');\nINSERT INTO t1(docid,words) VALUES(1017012,'And he that is eight days old shall be circumcised among you, every man child in your generations, he that is born in the house, or bought with money of any stranger, which is not of thy seed.');\nINSERT INTO t1(docid,words) VALUES(1017013,'He that is born in thy house, and he that is bought with thy money, must needs be circumcised: and my covenant shall be in your flesh for an everlasting covenant.');\nINSERT INTO t1(docid,words) VALUES(1017014,'And the uncircumcised man child whose flesh of his foreskin is not circumcised, that soul shall be cut off from his people; he hath broken my covenant.');\nINSERT INTO t1(docid,words) VALUES(1017015,'And God said unto Abraham, As for Sarai thy wife, thou shalt not call her name Sarai, but Sarah shall her name be.');\nINSERT INTO t1(docid,words) VALUES(1017016,'And I will bless her, and give thee a son also of her: yea, I will bless her, and she shall be a mother of nations; kings of people shall be of her.');\nINSERT INTO t1(docid,words) VALUES(1017017,'Then Abraham fell upon his face, and laughed, and said in his heart, Shall a child be born unto him that is an hundred years old? and shall Sarah, that is ninety years old, bear?');\nINSERT INTO t1(docid,words) VALUES(1017018,'And Abraham said unto God, O that Ishmael might live before thee!');\nINSERT INTO t1(docid,words) VALUES(1017019,'And God said, Sarah thy wife shall bear thee a son indeed; and thou shalt call his name Isaac: and I will establish my covenant with him for an everlasting covenant, and with his seed after him.');\nINSERT INTO t1(docid,words) VALUES(1017020,'And as for Ishmael, I have heard thee: Behold, I have blessed him, and will make him fruitful, and will multiply him exceedingly; twelve princes shall he beget, and I will make him a great nation.');\nINSERT INTO t1(docid,words) VALUES(1017021,'But my covenant will I establish with Isaac, which Sarah shall bear unto thee at this set time in the next year.');\nINSERT INTO t1(docid,words) VALUES(1017022,'And he left off talking with him, and God went up from Abraham.');\nINSERT INTO t1(docid,words) VALUES(1017023,'And Abraham took Ishmael his son, and all that were born in his house, and all that were bought with his money, every male among the men of Abraham''s house; and circumcised the flesh of their foreskin in the selfsame day, as God had said unto him.');\nINSERT INTO t1(docid,words) VALUES(1017024,'And Abraham was ninety years old and nine, when he was circumcised in the flesh of his foreskin.');\nINSERT INTO t1(docid,words) VALUES(1017025,'And Ishmael his son was thirteen years old, when he was circumcised in the flesh of his foreskin.');\nINSERT INTO t1(docid,words) VALUES(1017026,'In the selfsame day was Abraham circumcised, and Ishmael his son.');\nINSERT INTO t1(docid,words) VALUES(1017027,'And all the men of his house, born in the house, and bought with money of the stranger, were circumcised with him.');\nINSERT INTO t1(docid,words) VALUES(1018001,'And the LORD appeared unto him in the plains of Mamre: and he sat in the tent door in the heat of the day;');\nINSERT INTO t1(docid,words) VALUES(1018002,'And he lift up his eyes and looked, and, lo, three men stood by him: and when he saw them, he ran to meet them from the tent door, and bowed himself toward the ground,');\nINSERT INTO t1(docid,words) VALUES(1018003,'And said, My LORD, if now I have found favour in thy sight, pass not away, I pray thee, from thy servant:');\nINSERT INTO t1(docid,words) VALUES(1018004,'Let a little water, I pray you, be fetched, and wash your feet, and rest yourselves under the tree:');\nINSERT INTO t1(docid,words) VALUES(1018005,'And I will fetch a morsel of bread, and comfort ye your hearts; after that ye shall pass on: for therefore are ye come to your servant. And they said, So do, as thou hast said.');\nINSERT INTO t1(docid,words) VALUES(1018006,'And Abraham hastened into the tent unto Sarah, and said, Make ready quickly three measures of fine meal, knead it, and make cakes upon the hearth.');\nINSERT INTO t1(docid,words) VALUES(1018007,'And Abraham ran unto the herd, and fetcht a calf tender and good, and gave it unto a young man; and he hasted to dress it.');\nINSERT INTO t1(docid,words) VALUES(1018008,'And he took butter, and milk, and the calf which he had dressed, and set it before them; and he stood by them under the tree, and they did eat.');\nINSERT INTO t1(docid,words) VALUES(1018009,'And they said unto him, Where is Sarah thy wife? And he said, Behold, in the tent.');\nINSERT INTO t1(docid,words) VALUES(1018010,'And he said, I will certainly return unto thee according to the time of life; and, lo, Sarah thy wife shall have a son. And Sarah heard it in the tent door, which was behind him.');\nINSERT INTO t1(docid,words) VALUES(1018011,'Now Abraham and Sarah were old and well stricken in age; and it ceased to be with Sarah after the manner of women.');\nINSERT INTO t1(docid,words) VALUES(1018012,'Therefore Sarah laughed within herself, saying, After I am waxed old shall I have pleasure, my lord being old also?');\nINSERT INTO t1(docid,words) VALUES(1018013,'And the LORD said unto Abraham, Wherefore did Sarah laugh, saying, Shall I of a surety bear a child, which am old?');\nINSERT INTO t1(docid,words) VALUES(1018014,'Is any thing too hard for the LORD? At the time appointed I will return unto thee, according to the time of life, and Sarah shall have a son.');\nINSERT INTO t1(docid,words) VALUES(1018015,'Then Sarah denied, saying, I laughed not; for she was afraid. And he said, Nay; but thou didst laugh.');\nINSERT INTO t1(docid,words) VALUES(1018016,'And the men rose up from thence, and looked toward Sodom: and Abraham went with them to bring them on the way.');\nINSERT INTO t1(docid,words) VALUES(1018017,'And the LORD said, Shall I hide from Abraham that thing which I do;');\nINSERT INTO t1(docid,words) VALUES(1018018,'Seeing that Abraham shall surely become a great and mighty nation, and all the nations of the earth shall be blessed in him?');\nINSERT INTO t1(docid,words) VALUES(1018019,'For I know him, that he will command his children and his household after him, and they shall keep the way of the LORD, to do justice and judgment; that the LORD may bring upon Abraham that which he hath spoken of him.');\nINSERT INTO t1(docid,words) VALUES(1018020,'And the LORD said, Because the cry of Sodom and Gomorrah is great, and because their sin is very grievous;');\nINSERT INTO t1(docid,words) VALUES(1018021,'I will go down now, and see whether they have done altogether according to the cry of it, which is come unto me; and if not, I will know.');\nINSERT INTO t1(docid,words) VALUES(1018022,'And the men turned their faces from thence, and went toward Sodom: but Abraham stood yet before the LORD.');\nINSERT INTO t1(docid,words) VALUES(1018023,'And Abraham drew near, and said, Wilt thou also destroy the righteous with the wicked?');\nINSERT INTO t1(docid,words) VALUES(1018024,'Peradventure there be fifty righteous within the city: wilt thou also destroy and not spare the place for the fifty righteous that are therein?');\nINSERT INTO t1(docid,words) VALUES(1018025,'That be far from thee to do after this manner, to slay the righteous with the wicked: and that the righteous should be as the wicked, that be far from thee: Shall not the Judge of all the earth do right?');\nINSERT INTO t1(docid,words) VALUES(1018026,'And the LORD said, If I find in Sodom fifty righteous within the city, then I will spare all the place for their sakes.');\nINSERT INTO t1(docid,words) VALUES(1018027,'And Abraham answered and said, Behold now, I have taken upon me to speak unto the LORD, which am but dust and ashes:');\nINSERT INTO t1(docid,words) VALUES(1018028,'Peradventure there shall lack five of the fifty righteous: wilt thou destroy all the city for lack of five? And he said, If I find there forty and five, I will not destroy it.');\nINSERT INTO t1(docid,words) VALUES(1018029,'And he spake unto him yet again, and said, Peradventure there shall be forty found there. And he said, I will not do it for forty''s sake.');\nINSERT INTO t1(docid,words) VALUES(1018030,'And he said unto him, Oh let not the LORD be angry, and I will speak: Peradventure there shall thirty be found there. And he said, I will not do it, if I find thirty there.');\nINSERT INTO t1(docid,words) VALUES(1018031,'And he said, Behold now, I have taken upon me to speak unto the LORD: Peradventure there shall be twenty found there. And he said, I will not destroy it for twenty''s sake.');\nINSERT INTO t1(docid,words) VALUES(1018032,'And he said, Oh let not the LORD be angry, and I will speak yet but this once: Peradventure ten shall be found there. And he said, I will not destroy it for ten''s sake.');\nINSERT INTO t1(docid,words) VALUES(1018033,'And the LORD went his way, as soon as he had left communing with Abraham: and Abraham returned unto his place.');\nINSERT INTO t1(docid,words) VALUES(1019001,'And there came two angels to Sodom at even; and Lot sat in the gate of Sodom: and Lot seeing them rose up to meet them; and he bowed himself with his face toward the ground;');\nINSERT INTO t1(docid,words) VALUES(1019002,'And he said, Behold now, my lords, turn in, I pray you, into your servant''s house, and tarry all night, and wash your feet, and ye shall rise up early, and go on your ways. And they said, Nay; but we will abide in the street all night.');\nINSERT INTO t1(docid,words) VALUES(1019003,'And he pressed upon them greatly; and they turned in unto him, and entered into his house; and he made them a feast, and did bake unleavened bread, and they did eat.');\nINSERT INTO t1(docid,words) VALUES(1019004,'But before they lay down, the men of the city, even the men of Sodom, compassed the house round, both old and young, all the people from every quarter:');\nINSERT INTO t1(docid,words) VALUES(1019005,'And they called unto Lot, and said unto him, Where are the men which came in to thee this night? bring them out unto us, that we may know them.');\nINSERT INTO t1(docid,words) VALUES(1019006,'And Lot went out at the door unto them, and shut the door after him,');\nINSERT INTO t1(docid,words) VALUES(1019007,'And said, I pray you, brethren, do not so wickedly.');\nINSERT INTO t1(docid,words) VALUES(1019008,'Behold now, I have two daughters which have not known man; let me, I pray you, bring them out unto you, and do ye to them as is good in your eyes: only unto these men do nothing; for therefore came they under the shadow of my roof.');\nINSERT INTO t1(docid,words) VALUES(1019009,'And they said, Stand back. And they said again, This one fellow came in to sojourn, and he will needs be a judge: now will we deal worse with thee, than with them. And they pressed sore upon the man, even Lot, and came near to break the door.');\nINSERT INTO t1(docid,words) VALUES(1019010,'But the men put forth their hand, and pulled Lot into the house to them, and shut to the door.');\nINSERT INTO t1(docid,words) VALUES(1019011,'And they smote the men that were at the door of the house with blindness, both small and great: so that they wearied themselves to find the door.');\nINSERT INTO t1(docid,words) VALUES(1019012,'And the men said unto Lot, Hast thou here any besides? son in law, and thy sons, and thy daughters, and whatsoever thou hast in the city, bring them out of this place:');\nINSERT INTO t1(docid,words) VALUES(1019013,'For we will destroy this place, because the cry of them is waxen great before the face of the LORD; and the LORD hath sent us to destroy it.');\nINSERT INTO t1(docid,words) VALUES(1019014,'And Lot went out, and spake unto his sons in law, which married his daughters, and said, Up, get you out of this place; for the LORD will destroy this city. But he seemed as one that mocked unto his sons in law.');\nINSERT INTO t1(docid,words) VALUES(1019015,'And when the morning arose, then the angels hastened Lot, saying, Arise, take thy wife, and thy two daughters, which are here; lest thou be consumed in the iniquity of the city.');\nINSERT INTO t1(docid,words) VALUES(1019016,'And while he lingered, the men laid hold upon his hand, and upon the hand of his wife, and upon the hand of his two daughters; the LORD being merciful unto him: and they brought him forth, and set him without the city.');\nINSERT INTO t1(docid,words) VALUES(1019017,'And it came to pass, when they had brought them forth abroad, that he said, Escape for thy life; look not behind thee, neither stay thou in all the plain; escape to the mountain, lest thou be consumed.');\nINSERT INTO t1(docid,words) VALUES(1019018,'And Lot said unto them, Oh, not so, my LORD:');\nINSERT INTO t1(docid,words) VALUES(1019019,'Behold now, thy servant hath found grace in thy sight, and thou hast magnified thy mercy, which thou hast shewed unto me in saving my life; and I cannot escape to the mountain, lest some evil take me, and I die:');\nINSERT INTO t1(docid,words) VALUES(1019020,'Behold now, this city is near to flee unto, and it is a little one: Oh, let me escape thither, (is it not a little one?) and my soul shall live.');\nINSERT INTO t1(docid,words) VALUES(1019021,'And he said unto him, See, I have accepted thee concerning this thing also, that I will not overthrow this city, for the which thou hast spoken.');\nINSERT INTO t1(docid,words) VALUES(1019022,'Haste thee, escape thither; for I cannot do anything till thou be come thither. Therefore the name of the city was called Zoar.');\nINSERT INTO t1(docid,words) VALUES(1019023,'The sun was risen upon the earth when Lot entered into Zoar.');\nINSERT INTO t1(docid,words) VALUES(1019024,'Then the LORD rained upon Sodom and upon Gomorrah brimstone and fire from the LORD out of heaven;');\nINSERT INTO t1(docid,words) VALUES(1019025,'And he overthrew those cities, and all the plain, and all the inhabitants of the cities, and that which grew upon the ground.');\nINSERT INTO t1(docid,words) VALUES(1019026,'But his wife looked back from behind him, and she became a pillar of salt.');\nINSERT INTO t1(docid,words) VALUES(1019027,'And Abraham gat up early in the morning to the place where he stood before the LORD:');\nINSERT INTO t1(docid,words) VALUES(1019028,'And he looked toward Sodom and Gomorrah, and toward all the land of the plain, and beheld, and, lo, the smoke of the country went up as the smoke of a furnace.');\nINSERT INTO t1(docid,words) VALUES(1019029,'And it came to pass, when God destroyed the cities of the plain, that God remembered Abraham, and sent Lot out of the midst of the overthrow, when he overthrew the cities in the which Lot dwelt.');\nINSERT INTO t1(docid,words) VALUES(1019030,'And Lot went up out of Zoar, and dwelt in the mountain, and his two daughters with him; for he feared to dwell in Zoar: and he dwelt in a cave, he and his two daughters.');\nINSERT INTO t1(docid,words) VALUES(1019031,'And the firstborn said unto the younger, Our father is old, and there is not a man in the earth to come in unto us after the manner of all the earth:');\nINSERT INTO t1(docid,words) VALUES(1019032,'Come, let us make our father drink wine, and we will lie with him, that we may preserve seed of our father.');\nINSERT INTO t1(docid,words) VALUES(1019033,'And they made their father drink wine that night: and the firstborn went in, and lay with her father; and he perceived not when she lay down, nor when she arose.');\nINSERT INTO t1(docid,words) VALUES(1019034,'And it came to pass on the morrow, that the firstborn said unto the younger, Behold, I lay yesternight with my father: let us make him drink wine this night also; and go thou in, and lie with him, that we may preserve seed of our father.');\nINSERT INTO t1(docid,words) VALUES(1019035,'And they made their father drink wine that night also: and the younger arose, and lay with him; and he perceived not when she lay down, nor when she arose.');\nINSERT INTO t1(docid,words) VALUES(1019036,'Thus were both the daughters of Lot with child by their father.');\nINSERT INTO t1(docid,words) VALUES(1019037,'And the first born bare a son, and called his name Moab: the same is the father of the Moabites unto this day.');\nINSERT INTO t1(docid,words) VALUES(1019038,'And the younger, she also bare a son, and called his name Benammi: the same is the father of the children of Ammon unto this day.');\nINSERT INTO t1(docid,words) VALUES(1020001,'And Abraham journeyed from thence toward the south country, and dwelled between Kadesh and Shur, and sojourned in Gerar.');\nINSERT INTO t1(docid,words) VALUES(1020002,'And Abraham said of Sarah his wife, She is my sister: and Abimelech king of Gerar sent, and took Sarah.');\nINSERT INTO t1(docid,words) VALUES(1020003,'But God came to Abimelech in a dream by night, and said to him, Behold, thou art but a dead man, for the woman which thou hast taken; for she is a man''s wife.');\nINSERT INTO t1(docid,words) VALUES(1020004,'But Abimelech had not come near her: and he said, LORD, wilt thou slay also a righteous nation?');\nINSERT INTO t1(docid,words) VALUES(1020005,'Said he not unto me, She is my sister? and she, even she herself said, He is my brother: in the integrity of my heart and innocency of my hands have I done this.');\nINSERT INTO t1(docid,words) VALUES(1020006,'And God said unto him in a dream, Yea, I know that thou didst this in the integrity of thy heart; for I also withheld thee from sinning against me: therefore suffered I thee not to touch her.');\nINSERT INTO t1(docid,words) VALUES(1020007,'Now therefore restore the man his wife; for he is a prophet, and he shall pray for thee, and thou shalt live: and if thou restore her not, know thou that thou shalt surely die, thou, and all that are thine.');\nINSERT INTO t1(docid,words) VALUES(1020008,'Therefore Abimelech rose early in the morning, and called all his servants, and told all these things in their ears: and the men were sore afraid.');\nINSERT INTO t1(docid,words) VALUES(1020009,'Then Abimelech called Abraham, and said unto him, What hast thou done unto us? and what have I offended thee, that thou hast brought on me and on my kingdom a great sin? thou hast done deeds unto me that ought not to be done.');\nINSERT INTO t1(docid,words) VALUES(1020010,'And Abimelech said unto Abraham, What sawest thou, that thou hast done this thing?');\nINSERT INTO t1(docid,words) VALUES(1020011,'And Abraham said, Because I thought, Surely the fear of God is not in this place; and they will slay me for my wife''s sake.');\nINSERT INTO t1(docid,words) VALUES(1020012,'And yet indeed she is my sister; she is the daughter of my father, but not the daughter of my mother; and she became my wife.');\nINSERT INTO t1(docid,words) VALUES(1020013,'And it came to pass, when God caused me to wander from my father''s house, that I said unto her, This is thy kindness which thou shalt shew unto me; at every place whither we shall come, say of me, He is my brother.');\nINSERT INTO t1(docid,words) VALUES(1020014,'And Abimelech took sheep, and oxen, and menservants, and womenservants, and gave them unto Abraham, and restored him Sarah his wife.');\nINSERT INTO t1(docid,words) VALUES(1020015,'And Abimelech said, Behold, my land is before thee: dwell where it pleaseth thee.');\nINSERT INTO t1(docid,words) VALUES(1020016,'And unto Sarah he said, Behold, I have given thy brother a thousand pieces of silver: behold, he is to thee a covering of the eyes, unto all that are with thee, and with all other: thus she was reproved.');\nINSERT INTO t1(docid,words) VALUES(1020017,'So Abraham prayed unto God: and God healed Abimelech, and his wife, and his maidservants; and they bare children.');\nINSERT INTO t1(docid,words) VALUES(1020018,'For the LORD had fast closed up all the wombs of the house of Abimelech, because of Sarah Abraham''s wife.');\nINSERT INTO t1(docid,words) VALUES(1021001,'And the LORD visited Sarah as he had said, and the LORD did unto Sarah as he had spoken.');\nINSERT INTO t1(docid,words) VALUES(1021002,'For Sarah conceived, and bare Abraham a son in his old age, at the set time of which God had spoken to him.');\nINSERT INTO t1(docid,words) VALUES(1021003,'And Abraham called the name of his son that was born unto him, whom Sarah bare to him, Isaac.');\nINSERT INTO t1(docid,words) VALUES(1021004,'And Abraham circumcised his son Isaac being eight days old, as God had commanded him.');\nINSERT INTO t1(docid,words) VALUES(1021005,'And Abraham was an hundred years old, when his son Isaac was born unto him.');\nINSERT INTO t1(docid,words) VALUES(1021006,'And Sarah said, God hath made me to laugh, so that all that hear will laugh with me.');\nINSERT INTO t1(docid,words) VALUES(1021007,'And she said, Who would have said unto Abraham, that Sarah should have given children suck? for I have born him a son in his old age.');\nINSERT INTO t1(docid,words) VALUES(1021008,'And the child grew, and was weaned: and Abraham made a great feast the same day that Isaac was weaned.');\nINSERT INTO t1(docid,words) VALUES(1021009,'And Sarah saw the son of Hagar the Egyptian, which she had born unto Abraham, mocking.');\nINSERT INTO t1(docid,words) VALUES(1021010,'Wherefore she said unto Abraham, Cast out this bondwoman and her son: for the son of this bondwoman shall not be heir with my son, even with Isaac.');\nINSERT INTO t1(docid,words) VALUES(1021011,'And the thing was very grievous in Abraham''s sight because of his son.');\nINSERT INTO t1(docid,words) VALUES(1021012,'And God said unto Abraham, Let it not be grievous in thy sight because of the lad, and because of thy bondwoman; in all that Sarah hath said unto thee, hearken unto her voice; for in Isaac shall thy seed be called.');\nINSERT INTO t1(docid,words) VALUES(1021013,'And also of the son of the bondwoman will I make a nation, because he is thy seed.');\nINSERT INTO t1(docid,words) VALUES(1021014,'And Abraham rose up early in the morning, and took bread, and a bottle of water, and gave it unto Hagar, putting it on her shoulder, and the child, and sent her away: and she departed, and wandered in the wilderness of Beersheba.');\nINSERT INTO t1(docid,words) VALUES(1021015,'And the water was spent in the bottle, and she cast the child under one of the shrubs.');\nINSERT INTO t1(docid,words) VALUES(1021016,'And she went, and sat her down over against him a good way off, as it were a bow shot: for she said, Let me not see the death of the child. And she sat over against him, and lift up her voice, and wept.');\nINSERT INTO t1(docid,words) VALUES(1021017,'And God heard the voice of the lad; and the angel of God called to Hagar out of heaven, and said unto her, What aileth thee, Hagar? fear not; for God hath heard the voice of the lad where he is.');\nINSERT INTO t1(docid,words) VALUES(1021018,'Arise, lift up the lad, and hold him in thine hand; for I will make him a great nation.');\nINSERT INTO t1(docid,words) VALUES(1021019,'And God opened her eyes, and she saw a well of water; and she went, and filled the bottle with water, and gave the lad drink.');\nINSERT INTO t1(docid,words) VALUES(1021020,'And God was with the lad; and he grew, and dwelt in the wilderness, and became an archer.');\nINSERT INTO t1(docid,words) VALUES(1021021,'And he dwelt in the wilderness of Paran: and his mother took him a wife out of the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1021022,'And it came to pass at that time, that Abimelech and Phichol the chief captain of his host spake unto Abraham, saying, God is with thee in all that thou doest:');\nINSERT INTO t1(docid,words) VALUES(1021023,'Now therefore swear unto me here by God that thou wilt not deal falsely with me, nor with my son, nor with my son''s son: but according to the kindness that I have done unto thee, thou shalt do unto me, and to the land wherein thou hast sojourned.');\nINSERT INTO t1(docid,words) VALUES(1021024,'And Abraham said, I will swear.');\nINSERT INTO t1(docid,words) VALUES(1021025,'And Abraham reproved Abimelech because of a well of water, which Abimelech''s servants had violently taken away.');\nINSERT INTO t1(docid,words) VALUES(1021026,'And Abimelech said, I wot not who hath done this thing; neither didst thou tell me, neither yet heard I of it, but to day.');\nINSERT INTO t1(docid,words) VALUES(1021027,'And Abraham took sheep and oxen, and gave them unto Abimelech; and both of them made a covenant.');\nINSERT INTO t1(docid,words) VALUES(1021028,'And Abraham set seven ewe lambs of the flock by themselves.');\nINSERT INTO t1(docid,words) VALUES(1021029,'And Abimelech said unto Abraham, What mean these seven ewe lambs which thou hast set by themselves?');\nINSERT INTO t1(docid,words) VALUES(1021030,'And he said, For these seven ewe lambs shalt thou take of my hand, that they may be a witness unto me, that I have digged this well.');\nINSERT INTO t1(docid,words) VALUES(1021031,'Wherefore he called that place Beersheba; because there they sware both of them.');\nINSERT INTO t1(docid,words) VALUES(1021032,'Thus they made a covenant at Beersheba: then Abimelech rose up, and Phichol the chief captain of his host, and they returned into the land of the Philistines.');\nINSERT INTO t1(docid,words) VALUES(1021033,'And Abraham planted a grove in Beersheba, and called there on the name of the LORD, the everlasting God.');\nINSERT INTO t1(docid,words) VALUES(1021034,'And Abraham sojourned in the Philistines'' land many days.');\nINSERT INTO t1(docid,words) VALUES(1022001,'And it came to pass after these things, that God did tempt Abraham, and said unto him, Abraham: and he said, Behold, here I am.');\nINSERT INTO t1(docid,words) VALUES(1022002,'And he said, Take now thy son, thine only son Isaac, whom thou lovest, and get thee into the land of Moriah; and offer him there for a burnt offering upon one of the mountains which I will tell thee of.');\nINSERT INTO t1(docid,words) VALUES(1022003,'And Abraham rose up early in the morning, and saddled his ass, and took two of his young men with him, and Isaac his son, and clave the wood for the burnt offering, and rose up, and went unto the place of which God had told him.');\nINSERT INTO t1(docid,words) VALUES(1022004,'Then on the third day Abraham lifted up his eyes, and saw the place afar off.');\nINSERT INTO t1(docid,words) VALUES(1022005,'And Abraham said unto his young men, Abide ye here with the ass; and I and the lad will go yonder and worship, and come again to you.');\nINSERT INTO t1(docid,words) VALUES(1022006,'And Abraham took the wood of the burnt offering, and laid it upon Isaac his son; and he took the fire in his hand, and a knife; and they went both of them together.');\nINSERT INTO t1(docid,words) VALUES(1022007,'And Isaac spake unto Abraham his father, and said, My father: and he said, Here am I, my son. And he said, Behold the fire and the wood: but where is the lamb for a burnt offering?');\nINSERT INTO t1(docid,words) VALUES(1022008,'And Abraham said, My son, God will provide himself a lamb for a burnt offering: so they went both of them together.');\nINSERT INTO t1(docid,words) VALUES(1022009,'And they came to the place which God had told him of; and Abraham built an altar there, and laid the wood in order, and bound Isaac his son, and laid him on the altar upon the wood.');\nINSERT INTO t1(docid,words) VALUES(1022010,'And Abraham stretched forth his hand, and took the knife to slay his son.');\nINSERT INTO t1(docid,words) VALUES(1022011,'And the angel of the LORD called unto him out of heaven, and said, Abraham, Abraham: and he said, Here am I.');\nINSERT INTO t1(docid,words) VALUES(1022012,'And he said, Lay not thine hand upon the lad, neither do thou any thing unto him: for now I know that thou fearest God, seeing thou hast not withheld thy son, thine only son from me.');\nINSERT INTO t1(docid,words) VALUES(1022013,'And Abraham lifted up his eyes, and looked, and behold behind him a ram caught in a thicket by his horns: and Abraham went and took the ram, and offered him up for a burnt offering in the stead of his son.');\nINSERT INTO t1(docid,words) VALUES(1022014,'And Abraham called the name of that place Jehovahjireh: as it is said to this day, In the mount of the LORD it shall be seen.');\nINSERT INTO t1(docid,words) VALUES(1022015,'And the angel of the LORD called unto Abraham out of heaven the second time,');\nINSERT INTO t1(docid,words) VALUES(1022016,'And said, By myself have I sworn, saith the LORD, for because thou hast done this thing, and hast not withheld thy son, thine only son:');\nINSERT INTO t1(docid,words) VALUES(1022017,'That in blessing I will bless thee, and in multiplying I will multiply thy seed as the stars of the heaven, and as the sand which is upon the sea shore; and thy seed shall possess the gate of his enemies;');\nINSERT INTO t1(docid,words) VALUES(1022018,'And in thy seed shall all the nations of the earth be blessed; because thou hast obeyed my voice.');\nINSERT INTO t1(docid,words) VALUES(1022019,'So Abraham returned unto his young men, and they rose up and went together to Beersheba; and Abraham dwelt at Beersheba.');\nINSERT INTO t1(docid,words) VALUES(1022020,'And it came to pass after these things, that it was told Abraham, saying, Behold, Milcah, she hath also born children unto thy brother Nahor;');\nINSERT INTO t1(docid,words) VALUES(1022021,'Huz his firstborn, and Buz his brother, and Kemuel the father of Aram,');\nINSERT INTO t1(docid,words) VALUES(1022022,'And Chesed, and Hazo, and Pildash, and Jidlaph, and Bethuel.');\nINSERT INTO t1(docid,words) VALUES(1022023,'And Bethuel begat Rebekah: these eight Milcah did bear to Nahor, Abraham''s brother.');\nINSERT INTO t1(docid,words) VALUES(1022024,'And his concubine, whose name was Reumah, she bare also Tebah, and Gaham, and Thahash, and Maachah.');\nINSERT INTO t1(docid,words) VALUES(1023001,'And Sarah was an hundred and seven and twenty years old: these were the years of the life of Sarah.');\nINSERT INTO t1(docid,words) VALUES(1023002,'And Sarah died in Kirjatharba; the same is Hebron in the land of Canaan: and Abraham came to mourn for Sarah, and to weep for her.');\nINSERT INTO t1(docid,words) VALUES(1023003,'And Abraham stood up from before his dead, and spake unto the sons of Heth, saying,');\nINSERT INTO t1(docid,words) VALUES(1023004,'I am a stranger and a sojourner with you: give me a possession of a buryingplace with you, that I may bury my dead out of my sight.');\nINSERT INTO t1(docid,words) VALUES(1023005,'And the children of Heth answered Abraham, saying unto him,');\nINSERT INTO t1(docid,words) VALUES(1023006,'Hear us, my lord: thou art a mighty prince among us: in the choice of our sepulchres bury thy dead; none of us shall withhold from thee his sepulchre, but that thou mayest bury thy dead.');\nINSERT INTO t1(docid,words) VALUES(1023007,'And Abraham stood up, and bowed himself to the people of the land, even to the children of Heth.');\nINSERT INTO t1(docid,words) VALUES(1023008,'And he communed with them, saying, If it be your mind that I should bury my dead out of my sight; hear me, and intreat for me to Ephron the son of Zohar,');\nINSERT INTO t1(docid,words) VALUES(1023009,'That he may give me the cave of Machpelah, which he hath, which is in the end of his field; for as much money as it is worth he shall give it me for a possession of a buryingplace amongst you.');\nINSERT INTO t1(docid,words) VALUES(1023010,'And Ephron dwelt among the children of Heth: and Ephron the Hittite answered Abraham in the audience of the children of Heth, even of all that went in at the gate of his city, saying,');\nINSERT INTO t1(docid,words) VALUES(1023011,'Nay, my lord, hear me: the field give I thee, and the cave that is therein, I give it thee; in the presence of the sons of my people give I it thee: bury thy dead.');\nINSERT INTO t1(docid,words) VALUES(1023012,'And Abraham bowed down himself before the people of the land.');\nINSERT INTO t1(docid,words) VALUES(1023013,'And he spake unto Ephron in the audience of the people of the land, saying, But if thou wilt give it, I pray thee, hear me: I will give thee money for the field; take it of me, and I will bury my dead there.');\nINSERT INTO t1(docid,words) VALUES(1023014,'And Ephron answered Abraham, saying unto him,');\nINSERT INTO t1(docid,words) VALUES(1023015,'My lord, hearken unto me: the land is worth four hundred shekels of silver; what is that betwixt me and thee? bury therefore thy dead.');\nINSERT INTO t1(docid,words) VALUES(1023016,'And Abraham hearkened unto Ephron; and Abraham weighed to Ephron the silver, which he had named in the audience of the sons of Heth, four hundred shekels of silver, current money with the merchant.');\nINSERT INTO t1(docid,words) VALUES(1023017,'And the field of Ephron which was in Machpelah, which was before Mamre, the field, and the cave which was therein, and all the trees that were in the field, that were in all the borders round about, were made sure');\nINSERT INTO t1(docid,words) VALUES(1023018,'Unto Abraham for a possession in the presence of the children of Heth, before all that went in at the gate of his city.');\nINSERT INTO t1(docid,words) VALUES(1023019,'And after this, Abraham buried Sarah his wife in the cave of the field of Machpelah before Mamre: the same is Hebron in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1023020,'And the field, and the cave that is therein, were made sure unto Abraham for a possession of a buryingplace by the sons of Heth.');\nINSERT INTO t1(docid,words) VALUES(1024001,'And Abraham was old, and well stricken in age: and the LORD had blessed Abraham in all things.');\nINSERT INTO t1(docid,words) VALUES(1024002,'And Abraham said unto his eldest servant of his house, that ruled over all that he had, Put, I pray thee, thy hand under my thigh:');\nINSERT INTO t1(docid,words) VALUES(1024003,'And I will make thee swear by the LORD, the God of heaven, and the God of the earth, that thou shalt not take a wife unto my son of the daughters of the Canaanites, among whom I dwell:');\nINSERT INTO t1(docid,words) VALUES(1024004,'But thou shalt go unto my country, and to my kindred, and take a wife unto my son Isaac.');\nINSERT INTO t1(docid,words) VALUES(1024005,'And the servant said unto him, Peradventure the woman will not be willing to follow me unto this land: must I needs bring thy son again unto the land from whence thou camest?');\nINSERT INTO t1(docid,words) VALUES(1024006,'And Abraham said unto him, Beware thou that thou bring not my son thither again.');\nINSERT INTO t1(docid,words) VALUES(1024007,'The LORD God of heaven, which took me from my father''s house, and from the land of my kindred, and which spake unto me, and that sware unto me, saying, Unto thy seed will I give this land; he shall send his angel before thee, and thou shalt take a wife unto my son from thence.');\nINSERT INTO t1(docid,words) VALUES(1024008,'And if the woman will not be willing to follow thee, then thou shalt be clear from this my oath: only bring not my son thither again.');\nINSERT INTO t1(docid,words) VALUES(1024009,'And the servant put his hand under the thigh of Abraham his master, and sware to him concerning that matter.');\nINSERT INTO t1(docid,words) VALUES(1024010,'And the servant took ten camels of the camels of his master, and departed; for all the goods of his master were in his hand: and he arose, and went to Mesopotamia, unto the city of Nahor.');\nINSERT INTO t1(docid,words) VALUES(1024011,'And he made his camels to kneel down without the city by a well of water at the time of the evening, even the time that women go out to draw water.');\nINSERT INTO t1(docid,words) VALUES(1024012,'And he said O LORD God of my master Abraham, I pray thee, send me good speed this day, and shew kindness unto my master Abraham.');\nINSERT INTO t1(docid,words) VALUES(1024013,'Behold, I stand here by the well of water; and the daughters of the men of the city come out to draw water:');\nINSERT INTO t1(docid,words) VALUES(1024014,'And let it come to pass, that the damsel to whom I shall say, Let down thy pitcher, I pray thee, that I may drink; and she shall say, Drink, and I will give thy camels drink also: let the same be she that thou hast appointed for thy servant Isaac; and thereby shall I know that thou hast shewed kindness unto my master.');\nINSERT INTO t1(docid,words) VALUES(1024015,'And it came to pass, before he had done speaking, that, behold, Rebekah came out, who was born to Bethuel, son of Milcah, the wife of Nahor, Abraham''s brother, with her pitcher upon her shoulder.');\nINSERT INTO t1(docid,words) VALUES(1024016,'And the damsel was very fair to look upon, a virgin, neither had any man known her: and she went down to the well, and filled her pitcher, and came up.');\nINSERT INTO t1(docid,words) VALUES(1024017,'And the servant ran to meet her, and said, Let me, I pray thee, drink a little water of thy pitcher.');\nINSERT INTO t1(docid,words) VALUES(1024018,'And she said, Drink, my lord: and she hasted, and let down her pitcher upon her hand, and gave him drink.');\nINSERT INTO t1(docid,words) VALUES(1024019,'And when she had done giving him drink, she said, I will draw water for thy camels also, until they have done drinking.');\nINSERT INTO t1(docid,words) VALUES(1024020,'And she hasted, and emptied her pitcher into the trough, and ran again unto the well to draw water, and drew for all his camels.');\nINSERT INTO t1(docid,words) VALUES(1024021,'And the man wondering at her held his peace, to wit whether the LORD had made his journey prosperous or not.');\nINSERT INTO t1(docid,words) VALUES(1024022,'And it came to pass, as the camels had done drinking, that the man took a golden earring of half a shekel weight, and two bracelets for her hands of ten shekels weight of gold;');\nINSERT INTO t1(docid,words) VALUES(1024023,'And said, Whose daughter art thou? tell me, I pray thee: is there room in thy father''s house for us to lodge in?');\nINSERT INTO t1(docid,words) VALUES(1024024,'And she said unto him, I am the daughter of Bethuel the son of Milcah, which she bare unto Nahor.');\nINSERT INTO t1(docid,words) VALUES(1024025,'She said moreover unto him, We have both straw and provender enough, and room to lodge in.');\nINSERT INTO t1(docid,words) VALUES(1024026,'And the man bowed down his head, and worshipped the LORD.');\nINSERT INTO t1(docid,words) VALUES(1024027,'And he said, Blessed be the LORD God of my master Abraham, who hath not left destitute my master of his mercy and his truth: I being in the way, the LORD led me to the house of my master''s brethren.');\nINSERT INTO t1(docid,words) VALUES(1024028,'And the damsel ran, and told them of her mother''s house these things.');\nINSERT INTO t1(docid,words) VALUES(1024029,'And Rebekah had a brother, and his name was Laban: and Laban ran out unto the man, unto the well.');\nINSERT INTO t1(docid,words) VALUES(1024030,'And it came to pass, when he saw the earring and bracelets upon his sister''s hands, and when he heard the words of Rebekah his sister, saying, Thus spake the man unto me; that he came unto the man; and, behold, he stood by the camels at the well.');\nINSERT INTO t1(docid,words) VALUES(1024031,'And he said, Come in, thou blessed of the LORD; wherefore standest thou without? for I have prepared the house, and room for the camels.');\nINSERT INTO t1(docid,words) VALUES(1024032,'And the man came into the house: and he ungirded his camels, and gave straw and provender for the camels, and water to wash his feet, and the men''s feet that were with him.');\nINSERT INTO t1(docid,words) VALUES(1024033,'And there was set meat before him to eat: but he said, I will not eat, until I have told mine errand. And he said, Speak on.');\nINSERT INTO t1(docid,words) VALUES(1024034,'And he said, I am Abraham''s servant.');\nINSERT INTO t1(docid,words) VALUES(1024035,'And the LORD hath blessed my master greatly; and he is become great: and he hath given him flocks, and herds, and silver, and gold, and menservants, and maidservants, and camels, and asses.');\nINSERT INTO t1(docid,words) VALUES(1024036,'And Sarah my master''s wife bare a son to my master when she was old: and unto him hath he given all that he hath.');\nINSERT INTO t1(docid,words) VALUES(1024037,'And my master made me swear, saying, Thou shalt not take a wife to my son of the daughters of the Canaanites, in whose land I dwell:');\nINSERT INTO t1(docid,words) VALUES(1024038,'But thou shalt go unto my father''s house, and to my kindred, and take a wife unto my son.');\nINSERT INTO t1(docid,words) VALUES(1024039,'And I said unto my master, Peradventure the woman will not follow me.');\nINSERT INTO t1(docid,words) VALUES(1024040,'And he said unto me, The LORD, before whom I walk, will send his angel with thee, and prosper thy way; and thou shalt take a wife for my son of my kindred, and of my father''s house:');\nINSERT INTO t1(docid,words) VALUES(1024041,'Then shalt thou be clear from this my oath, when thou comest to my kindred; and if they give not thee one, thou shalt be clear from my oath.');\nINSERT INTO t1(docid,words) VALUES(1024042,'And I came this day unto the well, and said, O LORD God of my master Abraham, if now thou do prosper my way which I go:');\nINSERT INTO t1(docid,words) VALUES(1024043,'Behold, I stand by the well of water; and it shall come to pass, that when the virgin cometh forth to draw water, and I say to her, Give me, I pray thee, a little water of thy pitcher to drink;');\nINSERT INTO t1(docid,words) VALUES(1024044,'And she say to me, Both drink thou, and I will also draw for thy camels: let the same be the woman whom the LORD hath appointed out for my master''s son.');\nINSERT INTO t1(docid,words) VALUES(1024045,'And before I had done speaking in mine heart, behold, Rebekah came forth with her pitcher on her shoulder; and she went down unto the well, and drew water: and I said unto her, Let me drink, I pray thee.');\nINSERT INTO t1(docid,words) VALUES(1024046,'And she made haste, and let down her pitcher from her shoulder, and said, Drink, and I will give thy camels drink also: so I drank, and she made the camels drink also.');\nINSERT INTO t1(docid,words) VALUES(1024047,'And I asked her, and said, Whose daughter art thou? And she said, the daughter of Bethuel, Nahor''s son, whom Milcah bare unto him: and I put the earring upon her face, and the bracelets upon her hands.');\nINSERT INTO t1(docid,words) VALUES(1024048,'And I bowed down my head, and worshipped the LORD, and blessed the LORD God of my master Abraham, which had led me in the right way to take my master''s brother''s daughter unto his son.');\nINSERT INTO t1(docid,words) VALUES(1024049,'And now if ye will deal kindly and truly with my master, tell me: and if not, tell me; that I may turn to the right hand, or to the left.');\nINSERT INTO t1(docid,words) VALUES(1024050,'Then Laban and Bethuel answered and said, The thing proceedeth from the LORD: we cannot speak unto thee bad or good.');\nINSERT INTO t1(docid,words) VALUES(1024051,'Behold, Rebekah is before thee, take her, and go, and let her be thy master''s son''s wife, as the LORD hath spoken.');\nINSERT INTO t1(docid,words) VALUES(1024052,'And it came to pass, that, when Abraham''s servant heard their words, he worshipped the LORD, bowing himself to the earth.');\nINSERT INTO t1(docid,words) VALUES(1024053,'And the servant brought forth jewels of silver, and jewels of gold, and raiment, and gave them to Rebekah: he gave also to her brother and to her mother precious things.');\nINSERT INTO t1(docid,words) VALUES(1024054,'And they did eat and drink, he and the men that were with him, and tarried all night; and they rose up in the morning, and he said, Send me away unto my master.');\nINSERT INTO t1(docid,words) VALUES(1024055,'And her brother and her mother said, Let the damsel abide with us a few days, at the least ten; after that she shall go.');\nINSERT INTO t1(docid,words) VALUES(1024056,'And he said unto them, Hinder me not, seeing the LORD hath prospered my way; send me away that I may go to my master.');\nINSERT INTO t1(docid,words) VALUES(1024057,'And they said, We will call the damsel, and enquire at her mouth.');\nINSERT INTO t1(docid,words) VALUES(1024058,'And they called Rebekah, and said unto her, Wilt thou go with this man? And she said, I will go.');\nINSERT INTO t1(docid,words) VALUES(1024059,'And they sent away Rebekah their sister, and her nurse, and Abraham''s servant, and his men.');\nINSERT INTO t1(docid,words) VALUES(1024060,'And they blessed Rebekah, and said unto her, Thou art our sister, be thou the mother of thousands of millions, and let thy seed possess the gate of those which hate them.');\nINSERT INTO t1(docid,words) VALUES(1024061,'And Rebekah arose, and her damsels, and they rode upon the camels, and followed the man: and the servant took Rebekah, and went his way.');\nINSERT INTO t1(docid,words) VALUES(1024062,'And Isaac came from the way of the well Lahairoi; for he dwelt in the south country.');\nINSERT INTO t1(docid,words) VALUES(1024063,'And Isaac went out to meditate in the field at the eventide: and he lifted up his eyes, and saw, and, behold, the camels were coming.');\nINSERT INTO t1(docid,words) VALUES(1024064,'And Rebekah lifted up her eyes, and when she saw Isaac, she lighted off the camel.');\nINSERT INTO t1(docid,words) VALUES(1024065,'For she had said unto the servant, What man is this that walketh in the field to meet us? And the servant had said, It is my master: therefore she took a vail, and covered herself.');\nINSERT INTO t1(docid,words) VALUES(1024066,'And the servant told Isaac all things that he had done.');\nINSERT INTO t1(docid,words) VALUES(1024067,'And Isaac brought her into his mother Sarah''s tent, and took Rebekah, and she became his wife; and he loved her: and Isaac was comforted after his mother''s death.');\nINSERT INTO t1(docid,words) VALUES(1025001,'Then again Abraham took a wife, and her name was Keturah.');\nINSERT INTO t1(docid,words) VALUES(1025002,'And she bare him Zimran, and Jokshan, and Medan, and Midian, and Ishbak, and Shuah.');\nINSERT INTO t1(docid,words) VALUES(1025003,'And Jokshan begat Sheba, and Dedan. And the sons of Dedan were Asshurim, and Letushim, and Leummim.');\nINSERT INTO t1(docid,words) VALUES(1025004,'And the sons of Midian; Ephah, and Epher, and Hanoch, and Abidah, and Eldaah. All these were the children of Keturah.');\nINSERT INTO t1(docid,words) VALUES(1025005,'And Abraham gave all that he had unto Isaac.');\nINSERT INTO t1(docid,words) VALUES(1025006,'But unto the sons of the concubines, which Abraham had, Abraham gave gifts, and sent them away from Isaac his son, while he yet lived, eastward, unto the east country.');\nINSERT INTO t1(docid,words) VALUES(1025007,'And these are the days of the years of Abraham''s life which he lived, an hundred threescore and fifteen years.');\nINSERT INTO t1(docid,words) VALUES(1025008,'Then Abraham gave up the ghost, and died in a good old age, an old man, and full of years; and was gathered to his people.');\nINSERT INTO t1(docid,words) VALUES(1025009,'And his sons Isaac and Ishmael buried him in the cave of Machpelah, in the field of Ephron the son of Zohar the Hittite, which is before Mamre;');\nINSERT INTO t1(docid,words) VALUES(1025010,'The field which Abraham purchased of the sons of Heth: there was Abraham buried, and Sarah his wife.');\nINSERT INTO t1(docid,words) VALUES(1025011,'And it came to pass after the death of Abraham, that God blessed his son Isaac; and Isaac dwelt by the well Lahairoi.');\nINSERT INTO t1(docid,words) VALUES(1025012,'Now these are the generations of Ishmael, Abraham''s son, whom Hagar the Egyptian, Sarah''s handmaid, bare unto Abraham:');\nINSERT INTO t1(docid,words) VALUES(1025013,'And these are the names of the sons of Ishmael, by their names, according to their generations: the firstborn of Ishmael, Nebajoth; and Kedar, and Adbeel, and Mibsam,');\nINSERT INTO t1(docid,words) VALUES(1025014,'And Mishma, and Dumah, and Massa,');\nINSERT INTO t1(docid,words) VALUES(1025015,'Hadar, and Tema, Jetur, Naphish, and Kedemah:');\nINSERT INTO t1(docid,words) VALUES(1025016,'These are the sons of Ishmael, and these are their names, by their towns, and by their castles; twelve princes according to their nations.');\nINSERT INTO t1(docid,words) VALUES(1025017,'And these are the years of the life of Ishmael, an hundred and thirty and seven years: and he gave up the ghost and died; and was gathered unto his people.');\nINSERT INTO t1(docid,words) VALUES(1025018,'And they dwelt from Havilah unto Shur, that is before Egypt, as thou goest toward Assyria: and he died in the presence of all his brethren.');\nINSERT INTO t1(docid,words) VALUES(1025019,'And these are the generations of Isaac, Abraham''s son: Abraham begat Isaac:');\nINSERT INTO t1(docid,words) VALUES(1025020,'And Isaac was forty years old when he took Rebekah to wife, the daughter of Bethuel the Syrian of Padanaram, the sister to Laban the Syrian.');\nINSERT INTO t1(docid,words) VALUES(1025021,'And Isaac intreated the LORD for his wife, because she was barren: and the LORD was intreated of him, and Rebekah his wife conceived.');\nINSERT INTO t1(docid,words) VALUES(1025022,'And the children struggled together within her; and she said, If it be so, why am I thus? And she went to enquire of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1025023,'And the LORD said unto her, Two nations are in thy womb, and two manner of people shall be separated from thy bowels; and the one people shall be stronger than the other people; and the elder shall serve the younger.');\nINSERT INTO t1(docid,words) VALUES(1025024,'And when her days to be delivered were fulfilled, behold, there were twins in her womb.');\nINSERT INTO t1(docid,words) VALUES(1025025,'And the first came out red, all over like an hairy garment; and they called his name Esau.');\nINSERT INTO t1(docid,words) VALUES(1025026,'And after that came his brother out, and his hand took hold on Esau''s heel; and his name was called Jacob: and Isaac was threescore years old when she bare them.');\nINSERT INTO t1(docid,words) VALUES(1025027,'And the boys grew: and Esau was a cunning hunter, a man of the field; and Jacob was a plain man, dwelling in tents.');\nINSERT INTO t1(docid,words) VALUES(1025028,'And Isaac loved Esau, because he did eat of his venison: but Rebekah loved Jacob.');\nINSERT INTO t1(docid,words) VALUES(1025029,'And Jacob sod pottage: and Esau came from the field, and he was faint:');\nINSERT INTO t1(docid,words) VALUES(1025030,'And Esau said to Jacob, Feed me, I pray thee, with that same red pottage; for I am faint: therefore was his name called Edom.');\nINSERT INTO t1(docid,words) VALUES(1025031,'And Jacob said, Sell me this day thy birthright.');\nINSERT INTO t1(docid,words) VALUES(1025032,'And Esau said, Behold, I am at the point to die: and what profit shall this birthright do to me?');\nINSERT INTO t1(docid,words) VALUES(1025033,'And Jacob said, Swear to me this day; and he sware unto him: and he sold his birthright unto Jacob.');\nINSERT INTO t1(docid,words) VALUES(1025034,'Then Jacob gave Esau bread and pottage of lentiles; and he did eat and drink, and rose up, and went his way: thus Esau despised his birthright.');\nINSERT INTO t1(docid,words) VALUES(1026001,'And there was a famine in the land, beside the first famine that was in the days of Abraham. And Isaac went unto Abimelech king of the Philistines unto Gerar.');\nINSERT INTO t1(docid,words) VALUES(1026002,'And the LORD appeared unto him, and said, Go not down into Egypt; dwell in the land which I shall tell thee of:');\nINSERT INTO t1(docid,words) VALUES(1026003,'Sojourn in this land, and I will be with thee, and will bless thee; for unto thee, and unto thy seed, I will give all these countries, and I will perform the oath which I sware unto Abraham thy father;');\nINSERT INTO t1(docid,words) VALUES(1026004,'And I will make thy seed to multiply as the stars of heaven, and will give unto thy seed all these countries; and in thy seed shall all the nations of the earth be blessed;');\nINSERT INTO t1(docid,words) VALUES(1026005,'Because that Abraham obeyed my voice, and kept my charge, my commandments, my statutes, and my laws.');\nINSERT INTO t1(docid,words) VALUES(1026006,'And Isaac dwelt in Gerar:');\nINSERT INTO t1(docid,words) VALUES(1026007,'And the men of the place asked him of his wife; and he said, She is my sister: for he feared to say, She is my wife; lest, said he, the men of the place should kill me for Rebekah; because she was fair to look upon.');\nINSERT INTO t1(docid,words) VALUES(1026008,'And it came to pass, when he had been there a long time, that Abimelech king of the Philistines looked out at a window, and saw, and, behold, Isaac was sporting with Rebekah his wife.');\nINSERT INTO t1(docid,words) VALUES(1026009,'And Abimelech called Isaac, and said, Behold, of a surety she is thy wife; and how saidst thou, She is my sister? And Isaac said unto him, Because I said, Lest I die for her.');\nINSERT INTO t1(docid,words) VALUES(1026010,'And Abimelech said, What is this thou hast done unto us? one of the people might lightly have lien with thy wife, and thou shouldest have brought guiltiness upon us.');\nINSERT INTO t1(docid,words) VALUES(1026011,'And Abimelech charged all his people, saying, He that toucheth this man or his wife shall surely be put to death.');\nINSERT INTO t1(docid,words) VALUES(1026012,'Then Isaac sowed in that land, and received in the same year an hundredfold: and the LORD blessed him.');\nINSERT INTO t1(docid,words) VALUES(1026013,'And the man waxed great, and went forward, and grew until he became very great:');\nINSERT INTO t1(docid,words) VALUES(1026014,'For he had possession of flocks, and possession of herds, and great store of servants: and the Philistines envied him.');\nINSERT INTO t1(docid,words) VALUES(1026015,'For all the wells which his father''s servants had digged in the days of Abraham his father, the Philistines had stopped them, and filled them with earth.');\nINSERT INTO t1(docid,words) VALUES(1026016,'And Abimelech said unto Isaac, Go from us; for thou art much mightier than we.');\nINSERT INTO t1(docid,words) VALUES(1026017,'And Isaac departed thence, and pitched his tent in the valley of Gerar, and dwelt there.');\nINSERT INTO t1(docid,words) VALUES(1026018,'And Isaac digged again the wells of water, which they had digged in the days of Abraham his father; for the Philistines had stopped them after the death of Abraham: and he called their names after the names by which his father had called them.');\nINSERT INTO t1(docid,words) VALUES(1026019,'And Isaac''s servants digged in the valley, and found there a well of springing water.');\nINSERT INTO t1(docid,words) VALUES(1026020,'And the herdmen of Gerar did strive with Isaac''s herdmen, saying, The water is ours: and he called the name of the well Esek; because they strove with him.');\nINSERT INTO t1(docid,words) VALUES(1026021,'And they digged another well, and strove for that also: and he called the name of it Sitnah.');\nINSERT INTO t1(docid,words) VALUES(1026022,'And he removed from thence, and digged another well; and for that they strove not: and he called the name of it Rehoboth; and he said, For now the LORD hath made room for us, and we shall be fruitful in the land.');\nINSERT INTO t1(docid,words) VALUES(1026023,'And he went up from thence to Beersheba.');\nINSERT INTO t1(docid,words) VALUES(1026024,'And the LORD appeared unto him the same night, and said, I am the God of Abraham thy father: fear not, for I am with thee, and will bless thee, and multiply thy seed for my servant Abraham''s sake.');\nINSERT INTO t1(docid,words) VALUES(1026025,'And he builded an altar there, and called upon the name of the LORD, and pitched his tent there: and there Isaac''s servants digged a well.');\nINSERT INTO t1(docid,words) VALUES(1026026,'Then Abimelech went to him from Gerar, and Ahuzzath one of his friends, and Phichol the chief captain of his army.');\nINSERT INTO t1(docid,words) VALUES(1026027,'And Isaac said unto them, Wherefore come ye to me, seeing ye hate me, and have sent me away from you?');\nINSERT INTO t1(docid,words) VALUES(1026028,'And they said, We saw certainly that the LORD was with thee: and we said, Let there be now an oath betwixt us, even betwixt us and thee, and let us make a covenant with thee;');\nINSERT INTO t1(docid,words) VALUES(1026029,'That thou wilt do us no hurt, as we have not touched thee, and as we have done unto thee nothing but good, and have sent thee away in peace: thou art now the blessed of the LORD.');\nINSERT INTO t1(docid,words) VALUES(1026030,'And he made them a feast, and they did eat and drink.');\nINSERT INTO t1(docid,words) VALUES(1026031,'And they rose up betimes in the morning, and sware one to another: and Isaac sent them away, and they departed from him in peace.');\nINSERT INTO t1(docid,words) VALUES(1026032,'And it came to pass the same day, that Isaac''s servants came, and told him concerning the well which they had digged, and said unto him, We have found water.');\nINSERT INTO t1(docid,words) VALUES(1026033,'And he called it Shebah: therefore the name of the city is Beersheba unto this day.');\nINSERT INTO t1(docid,words) VALUES(1026034,'And Esau was forty years old when he took to wife Judith the daughter of Beeri the Hittite, and Bashemath the daughter of Elon the Hittite:');\nINSERT INTO t1(docid,words) VALUES(1026035,'Which were a grief of mind unto Isaac and to Rebekah.');\nINSERT INTO t1(docid,words) VALUES(1027001,'And it came to pass, that when Isaac was old, and his eyes were dim, so that he could not see, he called Esau his eldest son, and said unto him, My son: and he said unto him, Behold, here am I.');\nINSERT INTO t1(docid,words) VALUES(1027002,'And he said, Behold now, I am old, I know not the day of my death:');\nINSERT INTO t1(docid,words) VALUES(1027003,'Now therefore take, I pray thee, thy weapons, thy quiver and thy bow, and go out to the field, and take me some venison;');\nINSERT INTO t1(docid,words) VALUES(1027004,'And make me savoury meat, such as I love, and bring it to me, that I may eat; that my soul may bless thee before I die.');\nINSERT INTO t1(docid,words) VALUES(1027005,'And Rebekah heard when Isaac spake to Esau his son. And Esau went to the field to hunt for venison, and to bring it.');\nINSERT INTO t1(docid,words) VALUES(1027006,'And Rebekah spake unto Jacob her son, saying, Behold, I heard thy father speak unto Esau thy brother, saying,');\nINSERT INTO t1(docid,words) VALUES(1027007,'Bring me venison, and make me savoury meat, that I may eat, and bless thee before the LORD before my death.');\nINSERT INTO t1(docid,words) VALUES(1027008,'Now therefore, my son, obey my voice according to that which I command thee.');\nINSERT INTO t1(docid,words) VALUES(1027009,'Go now to the flock, and fetch me from thence two good kids of the goats; and I will make them savoury meat for thy father, such as he loveth:');\nINSERT INTO t1(docid,words) VALUES(1027010,'And thou shalt bring it to thy father, that he may eat, and that he may bless thee before his death.');\nINSERT INTO t1(docid,words) VALUES(1027011,'And Jacob said to Rebekah his mother, Behold, Esau my brother is a hairy man, and I am a smooth man:');\nINSERT INTO t1(docid,words) VALUES(1027012,'My father peradventure will feel me, and I shall seem to him as a deceiver; and I shall bring a curse upon me, and not a blessing.');\nINSERT INTO t1(docid,words) VALUES(1027013,'And his mother said unto him, Upon me be thy curse, my son: only obey my voice, and go fetch me them.');\nINSERT INTO t1(docid,words) VALUES(1027014,'And he went, and fetched, and brought them to his mother: and his mother made savoury meat, such as his father loved.');\nINSERT INTO t1(docid,words) VALUES(1027015,'And Rebekah took goodly raiment of her eldest son Esau, which were with her in the house, and put them upon Jacob her younger son:');\nINSERT INTO t1(docid,words) VALUES(1027016,'And she put the skins of the kids of the goats upon his hands, and upon the smooth of his neck:');\nINSERT INTO t1(docid,words) VALUES(1027017,'And she gave the savoury meat and the bread, which she had prepared, into the hand of her son Jacob.');\nINSERT INTO t1(docid,words) VALUES(1027018,'And he came unto his father, and said, My father: and he said, Here am I; who art thou, my son?');\nINSERT INTO t1(docid,words) VALUES(1027019,'And Jacob said unto his father, I am Esau thy first born; I have done according as thou badest me: arise, I pray thee, sit and eat of my venison, that thy soul may bless me.');\nINSERT INTO t1(docid,words) VALUES(1027020,'And Isaac said unto his son, How is it that thou hast found it so quickly, my son? And he said, Because the LORD thy God brought it to me.');\nINSERT INTO t1(docid,words) VALUES(1027021,'And Isaac said unto Jacob, Come near, I pray thee, that I may feel thee, my son, whether thou be my very son Esau or not.');\nINSERT INTO t1(docid,words) VALUES(1027022,'And Jacob went near unto Isaac his father; and he felt him, and said, The voice is Jacob''s voice, but the hands are the hands of Esau.');\nINSERT INTO t1(docid,words) VALUES(1027023,'And he discerned him not, because his hands were hairy, as his brother Esau''s hands: so he blessed him.');\nINSERT INTO t1(docid,words) VALUES(1027024,'And he said, Art thou my very son Esau? And he said, I am.');\nINSERT INTO t1(docid,words) VALUES(1027025,'And he said, Bring it near to me, and I will eat of my son''s venison, that my soul may bless thee. And he brought it near to him, and he did eat: and he brought him wine and he drank.');\nINSERT INTO t1(docid,words) VALUES(1027026,'And his father Isaac said unto him, Come near now, and kiss me, my son.');\nINSERT INTO t1(docid,words) VALUES(1027027,'And he came near, and kissed him: and he smelled the smell of his raiment, and blessed him, and said, See, the smell of my son is as the smell of a field which the LORD hath blessed:');\nINSERT INTO t1(docid,words) VALUES(1027028,'Therefore God give thee of the dew of heaven, and the fatness of the earth, and plenty of corn and wine:');\nINSERT INTO t1(docid,words) VALUES(1027029,'Let people serve thee, and nations bow down to thee: be lord over thy brethren, and let thy mother''s sons bow down to thee: cursed be every one that curseth thee, and blessed be he that blesseth thee.');\nINSERT INTO t1(docid,words) VALUES(1027030,'And it came to pass, as soon as Isaac had made an end of blessing Jacob, and Jacob was yet scarce gone out from the presence of Isaac his father, that Esau his brother came in from his hunting.');\nINSERT INTO t1(docid,words) VALUES(1027031,'And he also had made savoury meat, and brought it unto his father, and said unto his father, Let my father arise, and eat of his son''s venison, that thy soul may bless me.');\nINSERT INTO t1(docid,words) VALUES(1027032,'And Isaac his father said unto him, Who art thou? And he said, I am thy son, thy firstborn Esau.');\nINSERT INTO t1(docid,words) VALUES(1027033,'And Isaac trembled very exceedingly, and said, Who? where is he that hath taken venison, and brought it me, and I have eaten of all before thou camest, and have blessed him? yea, and he shall be blessed.');\nINSERT INTO t1(docid,words) VALUES(1027034,'And when Esau heard the words of his father, he cried with a great and exceeding bitter cry, and said unto his father, Bless me, even me also, O my father.');\nINSERT INTO t1(docid,words) VALUES(1027035,'And he said, Thy brother came with subtilty, and hath taken away thy blessing.');\nINSERT INTO t1(docid,words) VALUES(1027036,'And he said, Is not he rightly named Jacob? for he hath supplanted me these two times: he took away my birthright; and, behold, now he hath taken away my blessing. And he said, Hast thou not reserved a blessing for me?');\nINSERT INTO t1(docid,words) VALUES(1027037,'And Isaac answered and said unto Esau, Behold, I have made him thy lord, and all his brethren have I given to him for servants; and with corn and wine have I sustained him: and what shall I do now unto thee, my son?');\nINSERT INTO t1(docid,words) VALUES(1027038,'And Esau said unto his father, Hast thou but one blessing, my father? bless me, even me also, O my father. And Esau lifted up his voice, and wept.');\nINSERT INTO t1(docid,words) VALUES(1027039,'And Isaac his father answered and said unto him, Behold, thy dwelling shall be the fatness of the earth, and of the dew of heaven from above;');\nINSERT INTO t1(docid,words) VALUES(1027040,'And by thy sword shalt thou live, and shalt serve thy brother; and it shall come to pass when thou shalt have the dominion, that thou shalt break his yoke from off thy neck.');\nINSERT INTO t1(docid,words) VALUES(1027041,'And Esau hated Jacob because of the blessing wherewith his father blessed him: and Esau said in his heart, The days of mourning for my father are at hand; then will I slay my brother Jacob.');\nINSERT INTO t1(docid,words) VALUES(1027042,'And these words of Esau her elder son were told to Rebekah: and she sent and called Jacob her younger son, and said unto him, Behold, thy brother Esau, as touching thee, doth comfort himself, purposing to kill thee.');\nINSERT INTO t1(docid,words) VALUES(1027043,'Now therefore, my son, obey my voice; arise, flee thou to Laban my brother to Haran;');\nINSERT INTO t1(docid,words) VALUES(1027044,'And tarry with him a few days, until thy brother''s fury turn away;');\nINSERT INTO t1(docid,words) VALUES(1027045,'Until thy brother''s anger turn away from thee, and he forget that which thou hast done to him: then I will send, and fetch thee from thence: why should I be deprived also of you both in one day?');\nINSERT INTO t1(docid,words) VALUES(1027046,'And Rebekah said to Isaac, I am weary of my life because of the daughters of Heth: if Jacob take a wife of the daughters of Heth, such as these which are of the daughters of the land, what good shall my life do me?');\nINSERT INTO t1(docid,words) VALUES(1028001,'And Isaac called Jacob, and blessed him, and charged him, and said unto him, Thou shalt not take a wife of the daughters of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1028002,'Arise, go to Padanaram, to the house of Bethuel thy mother''s father; and take thee a wife from thence of the daughers of Laban thy mother''s brother.');\nINSERT INTO t1(docid,words) VALUES(1028003,'And God Almighty bless thee, and make thee fruitful, and multiply thee, that thou mayest be a multitude of people;');\nINSERT INTO t1(docid,words) VALUES(1028004,'And give thee the blessing of Abraham, to thee, and to thy seed with thee; that thou mayest inherit the land wherein thou art a stranger, which God gave unto Abraham.');\nINSERT INTO t1(docid,words) VALUES(1028005,'And Isaac sent away Jacob: and he went to Padanaram unto Laban, son of Bethuel the Syrian, the brother of Rebekah, Jacob''s and Esau''s mother.');\nINSERT INTO t1(docid,words) VALUES(1028006,'When Esau saw that Isaac had blessed Jacob, and sent him away to Padanaram, to take him a wife from thence; and that as he blessed him he gave him a charge, saying, Thou shalt not take a wife of the daughers of Canaan;');\nINSERT INTO t1(docid,words) VALUES(1028007,'And that Jacob obeyed his father and his mother, and was gone to Padanaram;');\nINSERT INTO t1(docid,words) VALUES(1028008,'And Esau seeing that the daughters of Canaan pleased not Isaac his father;');\nINSERT INTO t1(docid,words) VALUES(1028009,'Then went Esau unto Ishmael, and took unto the wives which he had Mahalath the daughter of Ishmael Abraham''s son, the sister of Nebajoth, to be his wife.');\nINSERT INTO t1(docid,words) VALUES(1028010,'And Jacob went out from Beersheba, and went toward Haran.');\nINSERT INTO t1(docid,words) VALUES(1028011,'And he lighted upon a certain place, and tarried there all night, because the sun was set; and he took of the stones of that place, and put them for his pillows, and lay down in that place to sleep.');\nINSERT INTO t1(docid,words) VALUES(1028012,'And he dreamed, and behold a ladder set up on the earth, and the top of it reached to heaven: and behold the angels of God ascending and descending on it.');\nINSERT INTO t1(docid,words) VALUES(1028013,'And, behold, the LORD stood above it, and said, I am the LORD God of Abraham thy father, and the God of Isaac: the land whereon thou liest, to thee will I give it, and to thy seed;');\nINSERT INTO t1(docid,words) VALUES(1028014,'And thy seed shall be as the dust of the earth, and thou shalt spread abroad to the west, and to the east, and to the north, and to the south: and in thee and in thy seed shall all the families of the earth be blessed.');\nINSERT INTO t1(docid,words) VALUES(1028015,'And, behold, I am with thee, and will keep thee in all places whither thou goest, and will bring thee again into this land; for I will not leave thee, until I have done that which I have spoken to thee of.');\nINSERT INTO t1(docid,words) VALUES(1028016,'And Jacob awaked out of his sleep, and he said, Surely the LORD is in this place; and I knew it not.');\nINSERT INTO t1(docid,words) VALUES(1028017,'And he was afraid, and said, How dreadful is this place! this is none other but the house of God, and this is the gate of heaven.');\nINSERT INTO t1(docid,words) VALUES(1028018,'And Jacob rose up early in the morning, and took the stone that he had put for his pillows, and set it up for a pillar, and poured oil upon the top of it.');\nINSERT INTO t1(docid,words) VALUES(1028019,'And he called the name of that place Bethel: but the name of that city was called Luz at the first.');\nINSERT INTO t1(docid,words) VALUES(1028020,'And Jacob vowed a vow, saying, If God will be with me, and will keep me in this way that I go, and will give me bread to eat, and raiment to put on,');\nINSERT INTO t1(docid,words) VALUES(1028021,'So that I come again to my father''s house in peace; then shall the LORD be my God:');\nINSERT INTO t1(docid,words) VALUES(1028022,'And this stone, which I have set for a pillar, shall be God''s house: and of all that thou shalt give me I will surely give the tenth unto thee.');\nINSERT INTO t1(docid,words) VALUES(1029001,'Then Jacob went on his journey, and came into the land of the people of the east.');\nINSERT INTO t1(docid,words) VALUES(1029002,'And he looked, and behold a well in the field, and, lo, there were three flocks of sheep lying by it; for out of that well they watered the flocks: and a great stone was upon the well''s mouth.');\nINSERT INTO t1(docid,words) VALUES(1029003,'And thither were all the flocks gathered: and they rolled the stone from the well''s mouth, and watered the sheep, and put the stone again upon the well''s mouth in his place.');\nINSERT INTO t1(docid,words) VALUES(1029004,'And Jacob said unto them, My brethren, whence be ye? And they said, Of Haran are we.');\nINSERT INTO t1(docid,words) VALUES(1029005,'And he said unto them, Know ye Laban the son of Nahor? And they said, We know him.');\nINSERT INTO t1(docid,words) VALUES(1029006,'And he said unto them, Is he well? And they said, He is well: and, behold, Rachel his daughter cometh with the sheep.');\nINSERT INTO t1(docid,words) VALUES(1029007,'And he said, Lo, it is yet high day, neither is it time that the cattle should be gathered together: water ye the sheep, and go and feed them.');\nINSERT INTO t1(docid,words) VALUES(1029008,'And they said, We cannot, until all the flocks be gathered together, and till they roll the stone from the well''s mouth; then we water the sheep.');\nINSERT INTO t1(docid,words) VALUES(1029009,'And while he yet spake with them, Rachel came with her father''s sheep; for she kept them.');\nINSERT INTO t1(docid,words) VALUES(1029010,'And it came to pass, when Jacob saw Rachel the daughter of Laban his mother''s brother, and the sheep of Laban his mother''s brother, that Jacob went near, and rolled the stone from the well''s mouth, and watered the flock of Laban his mother''s brother.');\nINSERT INTO t1(docid,words) VALUES(1029011,'And Jacob kissed Rachel, and lifted up his voice, and wept.');\nINSERT INTO t1(docid,words) VALUES(1029012,'And Jacob told Rachel that he was her father''s brother, and that he was Rebekah''s son: and she ran and told her father.');\nINSERT INTO t1(docid,words) VALUES(1029013,'And it came to pass, when Laban heard the tidings of Jacob his sister''s son, that he ran to meet him, and embraced him, and kissed him, and brought him to his house. And he told Laban all these things.');\nINSERT INTO t1(docid,words) VALUES(1029014,'And Laban said to him, Surely thou art my bone and my flesh. And he abode with him the space of a month.');\nINSERT INTO t1(docid,words) VALUES(1029015,'And Laban said unto Jacob, Because thou art my brother, shouldest thou therefore serve me for nought? tell me, what shall thy wages be?');\nINSERT INTO t1(docid,words) VALUES(1029016,'And Laban had two daughters: the name of the elder was Leah, and the name of the younger was Rachel.');\nINSERT INTO t1(docid,words) VALUES(1029017,'Leah was tender eyed; but Rachel was beautiful and well favoured.');\nINSERT INTO t1(docid,words) VALUES(1029018,'And Jacob loved Rachel; and said, I will serve thee seven years for Rachel thy younger daughter.');\nINSERT INTO t1(docid,words) VALUES(1029019,'And Laban said, It is better that I give her to thee, than that I should give her to another man: abide with me.');\nINSERT INTO t1(docid,words) VALUES(1029020,'And Jacob served seven years for Rachel; and they seemed unto him but a few days, for the love he had to her.');\nINSERT INTO t1(docid,words) VALUES(1029021,'And Jacob said unto Laban, Give me my wife, for my days are fulfilled, that I may go in unto her.');\nINSERT INTO t1(docid,words) VALUES(1029022,'And Laban gathered together all the men of the place, and made a feast.');\nINSERT INTO t1(docid,words) VALUES(1029023,'And it came to pass in the evening, that he took Leah his daughter, and brought her to him; and he went in unto her.');\nINSERT INTO t1(docid,words) VALUES(1029024,'And Laban gave unto his daughter Leah Zilpah his maid for an handmaid.');\nINSERT INTO t1(docid,words) VALUES(1029025,'And it came to pass, that in the morning, behold, it was Leah: and he said to Laban, What is this thou hast done unto me? did not I serve with thee for Rachel? wherefore then hast thou beguiled me?');\nINSERT INTO t1(docid,words) VALUES(1029026,'And Laban said, It must not be so done in our country, to give the younger before the firstborn.');\nINSERT INTO t1(docid,words) VALUES(1029027,'Fulfil her week, and we will give thee this also for the service which thou shalt serve with me yet seven other years.');\nINSERT INTO t1(docid,words) VALUES(1029028,'And Jacob did so, and fulfilled her week: and he gave him Rachel his daughter to wife also.');\nINSERT INTO t1(docid,words) VALUES(1029029,'And Laban gave to Rachel his daughter Bilhah his handmaid to be her maid.');\nINSERT INTO t1(docid,words) VALUES(1029030,'And he went in also unto Rachel, and he loved also Rachel more than Leah, and served with him yet seven other years.');\nINSERT INTO t1(docid,words) VALUES(1029031,'And when the LORD saw that Leah was hated, he opened her womb: but Rachel was barren.');\nINSERT INTO t1(docid,words) VALUES(1029032,'And Leah conceived, and bare a son, and she called his name Reuben: for she said, Surely the LORD hath looked upon my affliction; now therefore my husband will love me.');\nINSERT INTO t1(docid,words) VALUES(1029033,'And she conceived again, and bare a son; and said, Because the LORD hath heard I was hated, he hath therefore given me this son also: and she called his name Simeon.');\nINSERT INTO t1(docid,words) VALUES(1029034,'And she conceived again, and bare a son; and said, Now this time will my husband be joined unto me, because I have born him three sons: therefore was his name called Levi.');\nINSERT INTO t1(docid,words) VALUES(1029035,'And she conceived again, and bare a son: and she said, Now will I praise the LORD: therefore she called his name Judah; and left bearing.');\nINSERT INTO t1(docid,words) VALUES(1030001,'And when Rachel saw that she bare Jacob no children, Rachel envied her sister; and said unto Jacob, Give me children, or else I die.');\nINSERT INTO t1(docid,words) VALUES(1030002,'And Jacob''s anger was kindled against Rachel: and he said, Am I in God''s stead, who hath withheld from thee the fruit of the womb?');\nINSERT INTO t1(docid,words) VALUES(1030003,'And she said, Behold my maid Bilhah, go in unto her; and she shall bear upon my knees, that I may also have children by her.');\nINSERT INTO t1(docid,words) VALUES(1030004,'And she gave him Bilhah her handmaid to wife: and Jacob went in unto her.');\nINSERT INTO t1(docid,words) VALUES(1030005,'And Bilhah conceived, and bare Jacob a son.');\nINSERT INTO t1(docid,words) VALUES(1030006,'And Rachel said, God hath judged me, and hath also heard my voice, and hath given me a son: therefore called she his name Dan.');\nINSERT INTO t1(docid,words) VALUES(1030007,'And Bilhah Rachel''s maid conceived again, and bare Jacob a second son.');\nINSERT INTO t1(docid,words) VALUES(1030008,'And Rachel said, With great wrestlings have I wrestled with my sister, and I have prevailed: and she called his name Naphtali.');\nINSERT INTO t1(docid,words) VALUES(1030009,'When Leah saw that she had left bearing, she took Zilpah her maid, and gave her Jacob to wife.');\nINSERT INTO t1(docid,words) VALUES(1030010,'And Zilpah Leah''s maid bare Jacob a son.');\nINSERT INTO t1(docid,words) VALUES(1030011,'And Leah said, A troop cometh: and she called his name Gad.');\nINSERT INTO t1(docid,words) VALUES(1030012,'And Zilpah Leah''s maid bare Jacob a second son.');\nINSERT INTO t1(docid,words) VALUES(1030013,'And Leah said, Happy am I, for the daughters will call me blessed: and she called his name Asher.');\nINSERT INTO t1(docid,words) VALUES(1030014,'And Reuben went in the days of wheat harvest, and found mandrakes in the field, and brought them unto his mother Leah. Then Rachel said to Leah, Give me, I pray thee, of thy son''s mandrakes.');\nINSERT INTO t1(docid,words) VALUES(1030015,'And she said unto her, Is it a small matter that thou hast taken my husband? and wouldest thou take away my son''s mandrakes also? And Rachel said, Therefore he shall lie with thee to night for thy son''s mandrakes.');\nINSERT INTO t1(docid,words) VALUES(1030016,'And Jacob came out of the field in the evening, and Leah went out to meet him, and said, Thou must come in unto me; for surely I have hired thee with my son''s mandrakes. And he lay with her that night.');\nINSERT INTO t1(docid,words) VALUES(1030017,'And God hearkened unto Leah, and she conceived, and bare Jacob the fifth son.');\nINSERT INTO t1(docid,words) VALUES(1030018,'And Leah said, God hath given me my hire, because I have given my maiden to my husband: and she called his name Issachar.');\nINSERT INTO t1(docid,words) VALUES(1030019,'And Leah conceived again, and bare Jacob the sixth son.');\nINSERT INTO t1(docid,words) VALUES(1030020,'And Leah said, God hath endued me with a good dowry; now will my husband dwell with me, because I have born him six sons: and she called his name Zebulun.');\nINSERT INTO t1(docid,words) VALUES(1030021,'And afterwards she bare a daughter, and called her name Dinah.');\nINSERT INTO t1(docid,words) VALUES(1030022,'And God remembered Rachel, and God hearkened to her, and opened her womb.');\nINSERT INTO t1(docid,words) VALUES(1030023,'And she conceived, and bare a son; and said, God hath taken away my reproach:');\nINSERT INTO t1(docid,words) VALUES(1030024,'And she called his name Joseph; and said, The LORD shall add to me another son.');\nINSERT INTO t1(docid,words) VALUES(1030025,'And it came to pass, when Rachel had born Joseph, that Jacob said unto Laban, Send me away, that I may go unto mine own place, and to my country.');\nINSERT INTO t1(docid,words) VALUES(1030026,'Give me my wives and my children, for whom I have served thee, and let me go: for thou knowest my service which I have done thee.');\nINSERT INTO t1(docid,words) VALUES(1030027,'And Laban said unto him, I pray thee, if I have found favour in thine eyes, tarry: for I have learned by experience that the LORD hath blessed me for thy sake.');\nINSERT INTO t1(docid,words) VALUES(1030028,'And he said, Appoint me thy wages, and I will give it.');\nINSERT INTO t1(docid,words) VALUES(1030029,'And he said unto him, Thou knowest how I have served thee, and how thy cattle was with me.');\nINSERT INTO t1(docid,words) VALUES(1030030,'For it was little which thou hadst before I came, and it is now increased unto a multitude; and the LORD hath blessed thee since my coming: and now when shall I provide for mine own house also?');\nINSERT INTO t1(docid,words) VALUES(1030031,'And he said, What shall I give thee? And Jacob said, Thou shalt not give me any thing: if thou wilt do this thing for me, I will again feed and keep thy flock.');\nINSERT INTO t1(docid,words) VALUES(1030032,'I will pass through all thy flock to day, removing from thence all the speckled and spotted cattle, and all the brown cattle among the sheep, and the spotted and speckled among the goats: and of such shall be my hire.');\nINSERT INTO t1(docid,words) VALUES(1030033,'So shall my righteousness answer for me in time to come, when it shall come for my hire before thy face: every one that is not speckled and spotted among the goats, and brown among the sheep, that shall be counted stolen with me.');\nINSERT INTO t1(docid,words) VALUES(1030034,'And Laban said, Behold, I would it might be according to thy word.');\nINSERT INTO t1(docid,words) VALUES(1030035,'And he removed that day the he goats that were ringstraked and spotted, and all the she goats that were speckled and spotted, and every one that had some white in it, and all the brown among the sheep, and gave them into the hand of his sons.');\nINSERT INTO t1(docid,words) VALUES(1030036,'And he set three days'' journey betwixt himself and Jacob: and Jacob fed the rest of Laban''s flocks.');\nINSERT INTO t1(docid,words) VALUES(1030037,'And Jacob took him rods of green poplar, and of the hazel and chesnut tree; and pilled white strakes in them, and made the white appear which was in the rods.');\nINSERT INTO t1(docid,words) VALUES(1030038,'And he set the rods which he had pilled before the flocks in the gutters in the watering troughs when the flocks came to drink, that they should conceive when they came to drink.');\nINSERT INTO t1(docid,words) VALUES(1030039,'And the flocks conceived before the rods, and brought forth cattle ringstraked, speckled, and spotted.');\nINSERT INTO t1(docid,words) VALUES(1030040,'And Jacob did separate the lambs, and set the faces of the flocks toward the ringstraked, and all the brown in the flock of Laban; and he put his own flocks by themselves, and put them not unto Laban''s cattle.');\nINSERT INTO t1(docid,words) VALUES(1030041,'And it came to pass, whensoever the stronger cattle did conceive, that Jacob laid the rods before the eyes of the cattle in the gutters, that they might conceive among the rods.');\nINSERT INTO t1(docid,words) VALUES(1030042,'But when the cattle were feeble, he put them not in: so the feebler were Laban''s, and the stronger Jacob''s.');\nINSERT INTO t1(docid,words) VALUES(1030043,'And the man increased exceedingly, and had much cattle, and maidservants, and menservants, and camels, and asses.');\nINSERT INTO t1(docid,words) VALUES(1031001,'And he heard the words of Laban''s sons, saying, Jacob hath taken away all that was our father''s; and of that which was our father''s hath he gotten all this glory.');\nINSERT INTO t1(docid,words) VALUES(1031002,'And Jacob beheld the countenance of Laban, and, behold, it was not toward him as before.');\nINSERT INTO t1(docid,words) VALUES(1031003,'And the LORD said unto Jacob, Return unto the land of thy fathers, and to thy kindred; and I will be with thee.');\nINSERT INTO t1(docid,words) VALUES(1031004,'And Jacob sent and called Rachel and Leah to the field unto his flock,');\nINSERT INTO t1(docid,words) VALUES(1031005,'And said unto them, I see your father''s countenance, that it is not toward me as before; but the God of my father hath been with me.');\nINSERT INTO t1(docid,words) VALUES(1031006,'And ye know that with all my power I have served your father.');\nINSERT INTO t1(docid,words) VALUES(1031007,'And your father hath deceived me, and changed my wages ten times; but God suffered him not to hurt me.');\nINSERT INTO t1(docid,words) VALUES(1031008,'If he said thus, The speckled shall be thy wages; then all the cattle bare speckled: and if he said thus, The ringstraked shall be thy hire; then bare all the cattle ringstraked.');\nINSERT INTO t1(docid,words) VALUES(1031009,'Thus God hath taken away the cattle of your father, and given them to me.');\nINSERT INTO t1(docid,words) VALUES(1031010,'And it came to pass at the time that the cattle conceived, that I lifted up mine eyes, and saw in a dream, and, behold, the rams which leaped upon the cattle were ringstraked, speckled, and grisled.');\nINSERT INTO t1(docid,words) VALUES(1031011,'And the angel of God spake unto me in a dream, saying, Jacob: And I said, Here am I.');\nINSERT INTO t1(docid,words) VALUES(1031012,'And he said, Lift up now thine eyes, and see, all the rams which leap upon the cattle are ringstraked, speckled, and grisled: for I have seen all that Laban doeth unto thee.');\nINSERT INTO t1(docid,words) VALUES(1031013,'I am the God of Bethel, where thou anointedst the pillar, and where thou vowedst a vow unto me: now arise, get thee out from this land, and return unto the land of thy kindred.');\nINSERT INTO t1(docid,words) VALUES(1031014,'And Rachel and Leah answered and said unto him, Is there yet any portion or inheritance for us in our father''s house?');\nINSERT INTO t1(docid,words) VALUES(1031015,'Are we not counted of him strangers? for he hath sold us, and hath quite devoured also our money.');\nINSERT INTO t1(docid,words) VALUES(1031016,'For all the riches which God hath taken from our father, that is ours, and our children''s: now then, whatsoever God hath said unto thee, do.');\nINSERT INTO t1(docid,words) VALUES(1031017,'Then Jacob rose up, and set his sons and his wives upon camels;');\nINSERT INTO t1(docid,words) VALUES(1031018,'And he carried away all his cattle, and all his goods which he had gotten, the cattle of his getting, which he had gotten in Padanaram, for to go to Isaac his father in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1031019,'And Laban went to shear his sheep: and Rachel had stolen the images that were her father''s.');\nINSERT INTO t1(docid,words) VALUES(1031020,'And Jacob stole away unawares to Laban the Syrian, in that he told him not that he fled.');\nINSERT INTO t1(docid,words) VALUES(1031021,'So he fled with all that he had; and he rose up, and passed over the river, and set his face toward the mount Gilead.');\nINSERT INTO t1(docid,words) VALUES(1031022,'And it was told Laban on the third day that Jacob was fled.');\nINSERT INTO t1(docid,words) VALUES(1031023,'And he took his brethren with him, and pursued after him seven days'' journey; and they overtook him in the mount Gilead.');\nINSERT INTO t1(docid,words) VALUES(1031024,'And God came to Laban the Syrian in a dream by night, and said unto him, Take heed that thou speak not to Jacob either good or bad.');\nINSERT INTO t1(docid,words) VALUES(1031025,'Then Laban overtook Jacob. Now Jacob had pitched his tent in the mount: and Laban with his brethren pitched in the mount of Gilead.');\nINSERT INTO t1(docid,words) VALUES(1031026,'And Laban said to Jacob, What hast thou done, that thou hast stolen away unawares to me, and carried away my daughters, as captives taken with the sword?');\nINSERT INTO t1(docid,words) VALUES(1031027,'Wherefore didst thou flee away secretly, and steal away from me; and didst not tell me, that I might have sent thee away with mirth, and with songs, with tabret, and with harp?');\nINSERT INTO t1(docid,words) VALUES(1031028,'And hast not suffered me to kiss my sons and my daughters? thou hast now done foolishly in so doing.');\nINSERT INTO t1(docid,words) VALUES(1031029,'It is in the power of my hand to do you hurt: but the God of your father spake unto me yesternight, saying, Take thou heed that thou speak not to Jacob either good or bad.');\nINSERT INTO t1(docid,words) VALUES(1031030,'And now, though thou wouldest needs be gone, because thou sore longedst after thy father''s house, yet wherefore hast thou stolen my gods?');\nINSERT INTO t1(docid,words) VALUES(1031031,'And Jacob answered and said to Laban, Because I was afraid: for I said, Peradventure thou wouldest take by force thy daughters from me.');\nINSERT INTO t1(docid,words) VALUES(1031032,'With whomsoever thou findest thy gods, let him not live: before our brethren discern thou what is thine with me, and take it to thee. For Jacob knew not that Rachel had stolen them.');\nINSERT INTO t1(docid,words) VALUES(1031033,'And Laban went into Jacob''s tent, and into Leah''s tent, and into the two maidservants'' tents; but he found them not. Then went he out of Leah''s tent, and entered into Rachel''s tent.');\nINSERT INTO t1(docid,words) VALUES(1031034,'Now Rachel had taken the images, and put them in the camel''s furniture, and sat upon them. And Laban searched all the tent, but found them not.');\nINSERT INTO t1(docid,words) VALUES(1031035,'And she said to her father, Let it not displease my lord that I cannot rise up before thee; for the custom of women is upon me. And he searched but found not the images.');\nINSERT INTO t1(docid,words) VALUES(1031036,'And Jacob was wroth, and chode with Laban: and Jacob answered and said to Laban, What is my trespass? what is my sin, that thou hast so hotly pursued after me?');\nINSERT INTO t1(docid,words) VALUES(1031037,'Whereas thou hast searched all my stuff, what hast thou found of all thy household stuff? set it here before my brethren and thy brethren, that they may judge betwixt us both.');\nINSERT INTO t1(docid,words) VALUES(1031038,'This twenty years have I been with thee; thy ewes and thy she goats have not cast their young, and the rams of thy flock have I not eaten.');\nINSERT INTO t1(docid,words) VALUES(1031039,'That which was torn of beasts I brought not unto thee; I bare the loss of it; of my hand didst thou require it, whether stolen by day, or stolen by night.');\nINSERT INTO t1(docid,words) VALUES(1031040,'Thus I was; in the day the drought consumed me, and the frost by night; and my sleep departed from mine eyes.');\nINSERT INTO t1(docid,words) VALUES(1031041,'Thus have I been twenty years in thy house; I served thee fourteen years for thy two daughters, and six years for thy cattle: and thou hast changed my wages ten times.');\nINSERT INTO t1(docid,words) VALUES(1031042,'Except the God of my father, the God of Abraham, and the fear of Isaac, had been with me, surely thou hadst sent me away now empty. God hath seen mine affliction and the labour of my hands, and rebuked thee yesternight.');\nINSERT INTO t1(docid,words) VALUES(1031043,'And Laban answered and said unto Jacob, These daughters are my daughters, and these children are my children, and these cattle are my cattle, and all that thou seest is mine: and what can I do this day unto these my daughters, or unto their children which they have born?');\nINSERT INTO t1(docid,words) VALUES(1031044,'Now therefore come thou, let us make a covenant, I and thou; and let it be for a witness between me and thee.');\nINSERT INTO t1(docid,words) VALUES(1031045,'And Jacob took a stone, and set it up for a pillar.');\nINSERT INTO t1(docid,words) VALUES(1031046,'And Jacob said unto his brethren, Gather stones; and they took stones, and made an heap: and they did eat there upon the heap.');\nINSERT INTO t1(docid,words) VALUES(1031047,'And Laban called it Jegarsahadutha: but Jacob called it Galeed.');\nINSERT INTO t1(docid,words) VALUES(1031048,'And Laban said, This heap is a witness between me and thee this day. Therefore was the name of it called Galeed;');\nINSERT INTO t1(docid,words) VALUES(1031049,'And Mizpah; for he said, The LORD watch between me and thee, when we are absent one from another.');\nINSERT INTO t1(docid,words) VALUES(1031050,'If thou shalt afflict my daughters, or if thou shalt take other wives beside my daughters, no man is with us; see, God is witness betwixt me and thee.');\nINSERT INTO t1(docid,words) VALUES(1031051,'And Laban said to Jacob, Behold this heap, and behold this pillar, which I have cast betwixt me and thee:');\nINSERT INTO t1(docid,words) VALUES(1031052,'This heap be witness, and this pillar be witness, that I will not pass over this heap to thee, and that thou shalt not pass over this heap and this pillar unto me, for harm.');\nINSERT INTO t1(docid,words) VALUES(1031053,'The God of Abraham, and the God of Nahor, the God of their father, judge betwixt us. And Jacob sware by the fear of his father Isaac.');\nINSERT INTO t1(docid,words) VALUES(1031054,'Then Jacob offered sacrifice upon the mount, and called his brethren to eat bread: and they did eat bread, and tarried all night in the mount.');\nINSERT INTO t1(docid,words) VALUES(1031055,'And early in the morning Laban rose up, and kissed his sons and his daughters, and blessed them: and Laban departed, and returned unto his place.');\nINSERT INTO t1(docid,words) VALUES(1032001,'And Jacob went on his way, and the angels of God met him.');\nINSERT INTO t1(docid,words) VALUES(1032002,'And when Jacob saw them, he said, This is God''s host: and he called the name of that place Mahanaim.');\nINSERT INTO t1(docid,words) VALUES(1032003,'And Jacob sent messengers before him to Esau his brother unto the land of Seir, the country of Edom.');\nINSERT INTO t1(docid,words) VALUES(1032004,'And he commanded them, saying, Thus shall ye speak unto my lord Esau; Thy servant Jacob saith thus, I have sojourned with Laban, and stayed there until now:');\nINSERT INTO t1(docid,words) VALUES(1032005,'And I have oxen, and asses, flocks, and menservants, and womenservants: and I have sent to tell my lord, that I may find grace in thy sight.');\nINSERT INTO t1(docid,words) VALUES(1032006,'And the messengers returned to Jacob, saying, We came to thy brother Esau, and also he cometh to meet thee, and four hundred men with him.');\nINSERT INTO t1(docid,words) VALUES(1032007,'Then Jacob was greatly afraid and distressed: and he divided the people that was with him, and the flocks, and herds, and the camels, into two bands;');\nINSERT INTO t1(docid,words) VALUES(1032008,'And said, If Esau come to the one company, and smite it, then the other company which is left shall escape.');\nINSERT INTO t1(docid,words) VALUES(1032009,'And Jacob said, O God of my father Abraham, and God of my father Isaac, the LORD which saidst unto me, Return unto thy country, and to thy kindred, and I will deal well with thee:');\nINSERT INTO t1(docid,words) VALUES(1032010,'I am not worthy of the least of all the mercies, and of all the truth, which thou hast shewed unto thy servant; for with my staff I passed over this Jordan; and now I am become two bands.');\nINSERT INTO t1(docid,words) VALUES(1032011,'Deliver me, I pray thee, from the hand of my brother, from the hand of Esau: for I fear him, lest he will come and smite me, and the mother with the children.');\nINSERT INTO t1(docid,words) VALUES(1032012,'And thou saidst, I will surely do thee good, and make thy seed as the sand of the sea, which cannot be numbered for multitude.');\nINSERT INTO t1(docid,words) VALUES(1032013,'And he lodged there that same night; and took of that which came to his hand a present for Esau his brother;');\nINSERT INTO t1(docid,words) VALUES(1032014,'Two hundred she goats, and twenty he goats, two hundred ewes, and twenty rams,');\nINSERT INTO t1(docid,words) VALUES(1032015,'Thirty milch camels with their colts, forty kine, and ten bulls, twenty she asses, and ten foals.');\nINSERT INTO t1(docid,words) VALUES(1032016,'And he delivered them into the hand of his servants, every drove by themselves; and said unto his servants, Pass over before me, and put a space betwixt drove and drove.');\nINSERT INTO t1(docid,words) VALUES(1032017,'And he commanded the foremost, saying, When Esau my brother meeteth thee, and asketh thee, saying, Whose art thou? and whither goest thou? and whose are these before thee?');\nINSERT INTO t1(docid,words) VALUES(1032018,'Then thou shalt say, They be thy servant Jacob''s; it is a present sent unto my lord Esau: and, behold, also he is behind us.');\nINSERT INTO t1(docid,words) VALUES(1032019,'And so commanded he the second, and the third, and all that followed the droves, saying, On this manner shall ye speak unto Esau, when ye find him.');\nINSERT INTO t1(docid,words) VALUES(1032020,'And say ye moreover, Behold, thy servant Jacob is behind us. For he said, I will appease him with the present that goeth before me, and afterward I will see his face; peradventure he will accept of me.');\nINSERT INTO t1(docid,words) VALUES(1032021,'So went the present over before him: and himself lodged that night in the company.');\nINSERT INTO t1(docid,words) VALUES(1032022,'And he rose up that night, and took his two wives, and his two womenservants, and his eleven sons, and passed over the ford Jabbok.');\nINSERT INTO t1(docid,words) VALUES(1032023,'And he took them, and sent them over the brook, and sent over that he had.');\nINSERT INTO t1(docid,words) VALUES(1032024,'And Jacob was left alone; and there wrestled a man with him until the breaking of the day.');\nINSERT INTO t1(docid,words) VALUES(1032025,'And when he saw that he prevailed not against him, he touched the hollow of his thigh; and the hollow of Jacob''s thigh was out of joint, as he wrestled with him.');\nINSERT INTO t1(docid,words) VALUES(1032026,'And he said, Let me go, for the day breaketh. And he said, I will not let thee go, except thou bless me.');\nINSERT INTO t1(docid,words) VALUES(1032027,'And he said unto him, What is thy name? And he said, Jacob.');\nINSERT INTO t1(docid,words) VALUES(1032028,'And he said, Thy name shall be called no more Jacob, but Israel: for as a prince hast thou power with God and with men, and hast prevailed.');\nINSERT INTO t1(docid,words) VALUES(1032029,'And Jacob asked him, and said, Tell me, I pray thee, thy name. And he said, Wherefore is it that thou dost ask after my name? And he blessed him there.');\nINSERT INTO t1(docid,words) VALUES(1032030,'And Jacob called the name of the place Peniel: for I have seen God face to face, and my life is preserved.');\nINSERT INTO t1(docid,words) VALUES(1032031,'And as he passed over Penuel the sun rose upon him, and he halted upon his thigh.');\nINSERT INTO t1(docid,words) VALUES(1032032,'Therefore the children of Israel eat not of the sinew which shrank, which is upon the hollow of the thigh, unto this day: because he touched the hollow of Jacob''s thigh in the sinew that shrank.');\nINSERT INTO t1(docid,words) VALUES(1033001,'And Jacob lifted up his eyes, and looked, and, behold, Esau came, and with him four hundred men. And he divided the children unto Leah, and unto Rachel, and unto the two handmaids.');\nINSERT INTO t1(docid,words) VALUES(1033002,'And he put the handmaids and their children foremost, and Leah and her children after, and Rachel and Joseph hindermost.');\nINSERT INTO t1(docid,words) VALUES(1033003,'And he passed over before them, and bowed himself to the ground seven times, until he came near to his brother.');\nINSERT INTO t1(docid,words) VALUES(1033004,'And Esau ran to meet him, and embraced him, and fell on his neck, and kissed him: and they wept.');\nINSERT INTO t1(docid,words) VALUES(1033005,'And he lifted up his eyes, and saw the women and the children; and said, Who are those with thee? And he said, The children which God hath graciously given thy servant.');\nINSERT INTO t1(docid,words) VALUES(1033006,'Then the handmaidens came near, they and their children, and they bowed themselves.');\nINSERT INTO t1(docid,words) VALUES(1033007,'And Leah also with her children came near, and bowed themselves: and after came Joseph near and Rachel, and they bowed themselves.');\nINSERT INTO t1(docid,words) VALUES(1033008,'And he said, What meanest thou by all this drove which I met? And he said, These are to find grace in the sight of my lord.');\nINSERT INTO t1(docid,words) VALUES(1033009,'And Esau said, I have enough, my brother; keep that thou hast unto thyself.');\nINSERT INTO t1(docid,words) VALUES(1033010,'And Jacob said, Nay, I pray thee, if now I have found grace in thy sight, then receive my present at my hand: for therefore I have seen thy face, as though I had seen the face of God, and thou wast pleased with me.');\nINSERT INTO t1(docid,words) VALUES(1033011,'Take, I pray thee, my blessing that is brought to thee; because God hath dealt graciously with me, and because I have enough. And he urged him, and he took it.');\nINSERT INTO t1(docid,words) VALUES(1033012,'And he said, Let us take our journey, and let us go, and I will go before thee.');\nINSERT INTO t1(docid,words) VALUES(1033013,'And he said unto him, My lord knoweth that the children are tender, and the flocks and herds with young are with me: and if men should overdrive them one day, all the flock will die.');\nINSERT INTO t1(docid,words) VALUES(1033014,'Let my lord, I pray thee, pass over before his servant: and I will lead on softly, according as the cattle that goeth before me and the children be able to endure, until I come unto my lord unto Seir.');\nINSERT INTO t1(docid,words) VALUES(1033015,'And Esau said, Let me now leave with thee some of the folk that are with me. And he said, What needeth it? let me find grace in the sight of my lord.');\nINSERT INTO t1(docid,words) VALUES(1033016,'So Esau returned that day on his way unto Seir.');\nINSERT INTO t1(docid,words) VALUES(1033017,'And Jacob journeyed to Succoth, and built him an house, and made booths for his cattle: therefore the name of the place is called Succoth.');\nINSERT INTO t1(docid,words) VALUES(1033018,'And Jacob came to Shalem, a city of Shechem, which is in the land of Canaan, when he came from Padanaram; and pitched his tent before the city.');\nINSERT INTO t1(docid,words) VALUES(1033019,'And he bought a parcel of a field, where he had spread his tent, at the hand of the children of Hamor, Shechem''s father, for an hundred pieces of money.');\nINSERT INTO t1(docid,words) VALUES(1033020,'And he erected there an altar, and called it EleloheIsrael.');\nINSERT INTO t1(docid,words) VALUES(1034001,'And Dinah the daughter of Leah, which she bare unto Jacob, went out to see the daughters of the land.');\nINSERT INTO t1(docid,words) VALUES(1034002,'And when Shechem the son of Hamor the Hivite, prince of the country, saw her, he took her, and lay with her, and defiled her.');\nINSERT INTO t1(docid,words) VALUES(1034003,'And his soul clave unto Dinah the daughter of Jacob, and he loved the damsel, and spake kindly unto the damsel.');\nINSERT INTO t1(docid,words) VALUES(1034004,'And Shechem spake unto his father Hamor, saying, Get me this damsel to wife.');\nINSERT INTO t1(docid,words) VALUES(1034005,'And Jacob heard that he had defiled Dinah his daughter: now his sons were with his cattle in the field: and Jacob held his peace until they were come.');\nINSERT INTO t1(docid,words) VALUES(1034006,'And Hamor the father of Shechem went out unto Jacob to commune with him.');\nINSERT INTO t1(docid,words) VALUES(1034007,'And the sons of Jacob came out of the field when they heard it: and the men were grieved, and they were very wroth, because he had wrought folly in Israel in lying with Jacob''s daughter: which thing ought not to be done.');\nINSERT INTO t1(docid,words) VALUES(1034008,'And Hamor communed with them, saying, The soul of my son Shechem longeth for your daughter: I pray you give her him to wife.');\nINSERT INTO t1(docid,words) VALUES(1034009,'And make ye marriages with us, and give your daughters unto us, and take our daughters unto you.');\nINSERT INTO t1(docid,words) VALUES(1034010,'And ye shall dwell with us: and the land shall be before you; dwell and trade ye therein, and get you possessions therein.');\nINSERT INTO t1(docid,words) VALUES(1034011,'And Shechem said unto her father and unto her brethren, Let me find grace in your eyes, and what ye shall say unto me I will give.');\nINSERT INTO t1(docid,words) VALUES(1034012,'Ask me never so much dowry and gift, and I will give according as ye shall say unto me: but give me the damsel to wife.');\nINSERT INTO t1(docid,words) VALUES(1034013,'And the sons of Jacob answered Shechem and Hamor his father deceitfully, and said, because he had defiled Dinah their sister:');\nINSERT INTO t1(docid,words) VALUES(1034014,'And they said unto them, We cannot do this thing, to give our sister to one that is uncircumcised; for that were a reproach unto us:');\nINSERT INTO t1(docid,words) VALUES(1034015,'But in this will we consent unto you: If ye will be as we be, that every male of you be circumcised;');\nINSERT INTO t1(docid,words) VALUES(1034016,'Then will we give our daughters unto you, and we will take your daughters to us, and we will dwell with you, and we will become one people.');\nINSERT INTO t1(docid,words) VALUES(1034017,'But if ye will not hearken unto us, to be circumcised; then will we take our daughter, and we will be gone.');\nINSERT INTO t1(docid,words) VALUES(1034018,'And their words pleased Hamor, and Shechem Hamor''s son.');\nINSERT INTO t1(docid,words) VALUES(1034019,'And the young man deferred not to do the thing, because he had delight in Jacob''s daughter: and he was more honourable than all the house of his father.');\nINSERT INTO t1(docid,words) VALUES(1034020,'And Hamor and Shechem his son came unto the gate of their city, and communed with the men of their city, saying,');\nINSERT INTO t1(docid,words) VALUES(1034021,'These men are peaceable with us; therefore let them dwell in the land, and trade therein; for the land, behold, it is large enough for them; let us take their daughters to us for wives, and let us give them our daughters.');\nINSERT INTO t1(docid,words) VALUES(1034022,'Only herein will the men consent unto us for to dwell with us, to be one people, if every male among us be circumcised, as they are circumcised.');\nINSERT INTO t1(docid,words) VALUES(1034023,'Shall not their cattle and their substance and every beast of their''s be our''s? only let us consent unto them, and they will dwell with us.');\nINSERT INTO t1(docid,words) VALUES(1034024,'And unto Hamor and unto Shechem his son hearkened all that went out of the gate of his city; and every male was circumcised, all that went out of the gate of his city.');\nINSERT INTO t1(docid,words) VALUES(1034025,'And it came to pass on the third day, when they were sore, that two of the sons of Jacob, Simeon and Levi, Dinah''s brethren, took each man his sword, and came upon the city boldly, and slew all the males.');\nINSERT INTO t1(docid,words) VALUES(1034026,'And they slew Hamor and Shechem his son with the edge of the sword, and took Dinah out of Shechem''s house, and went out.');\nINSERT INTO t1(docid,words) VALUES(1034027,'The sons of Jacob came upon the slain, and spoiled the city, because they had defiled their sister.');\nINSERT INTO t1(docid,words) VALUES(1034028,'They took their sheep, and their oxen, and their asses, and that which was in the city, and that which was in the field,');\nINSERT INTO t1(docid,words) VALUES(1034029,'And all their wealth, and all their little ones, and their wives took they captive, and spoiled even all that was in the house.');\nINSERT INTO t1(docid,words) VALUES(1034030,'And Jacob said to Simeon and Levi, Ye have troubled me to make me to stink among the inhabitants of the land, among the Canaanites and the Perizzites: and I being few in number, they shall gather themselves together against me, and slay me; and I shall be destroyed, I and my house.');\nINSERT INTO t1(docid,words) VALUES(1034031,'And they said, Should he deal with our sister as with an harlot?');\nINSERT INTO t1(docid,words) VALUES(1035001,'And God said unto Jacob, Arise, go up to Bethel, and dwell there: and make there an altar unto God, that appeared unto thee when thou fleddest from the face of Esau thy brother.');\nINSERT INTO t1(docid,words) VALUES(1035002,'Then Jacob said unto his household, and to all that were with him, Put away the strange gods that are among you, and be clean, and change your garments:');\nINSERT INTO t1(docid,words) VALUES(1035003,'And let us arise, and go up to Bethel; and I will make there an altar unto God, who answered me in the day of my distress, and was with me in the way which I went.');\nINSERT INTO t1(docid,words) VALUES(1035004,'And they gave unto Jacob all the strange gods which were in their hand, and all their earrings which were in their ears; and Jacob hid them under the oak which was by Shechem.');\nINSERT INTO t1(docid,words) VALUES(1035005,'And they journeyed: and the terror of God was upon the cities that were round about them, and they did not pursue after the sons of Jacob.');\nINSERT INTO t1(docid,words) VALUES(1035006,'So Jacob came to Luz, which is in the land of Canaan, that is, Bethel, he and all the people that were with him.');\nINSERT INTO t1(docid,words) VALUES(1035007,'And he built there an altar, and called the place Elbethel: because there God appeared unto him, when he fled from the face of his brother.');\nINSERT INTO t1(docid,words) VALUES(1035008,'But Deborah Rebekah''s nurse died, and she was buried beneath Bethel under an oak: and the name of it was called Allonbachuth.');\nINSERT INTO t1(docid,words) VALUES(1035009,'And God appeared unto Jacob again, when he came out of Padanaram, and blessed him.');\nINSERT INTO t1(docid,words) VALUES(1035010,'And God said unto him, Thy name is Jacob: thy name shall not be called any more Jacob, but Israel shall be thy name: and he called his name Israel.');\nINSERT INTO t1(docid,words) VALUES(1035011,'And God said unto him, I am God Almighty: be fruitful and multiply; a nation and a company of nations shall be of thee, and kings shall come out of thy loins;');\nINSERT INTO t1(docid,words) VALUES(1035012,'And the land which I gave Abraham and Isaac, to thee I will give it, and to thy seed after thee will I give the land.');\nINSERT INTO t1(docid,words) VALUES(1035013,'And God went up from him in the place where he talked with him.');\nINSERT INTO t1(docid,words) VALUES(1035014,'And Jacob set up a pillar in the place where he talked with him, even a pillar of stone: and he poured a drink offering thereon, and he poured oil thereon.');\nINSERT INTO t1(docid,words) VALUES(1035015,'And Jacob called the name of the place where God spake with him, Bethel.');\nINSERT INTO t1(docid,words) VALUES(1035016,'And they journeyed from Bethel; and there was but a little way to come to Ephrath: and Rachel travailed, and she had hard labour.');\nINSERT INTO t1(docid,words) VALUES(1035017,'And it came to pass, when she was in hard labour, that the midwife said unto her, Fear not; thou shalt have this son also.');\nINSERT INTO t1(docid,words) VALUES(1035018,'And it came to pass, as her soul was in departing, (for she died) that she called his name Benoni: but his father called him Benjamin.');\nINSERT INTO t1(docid,words) VALUES(1035019,'And Rachel died, and was buried in the way to Ephrath, which is Bethlehem.');\nINSERT INTO t1(docid,words) VALUES(1035020,'And Jacob set a pillar upon her grave: that is the pillar of Rachel''s grave unto this day.');\nINSERT INTO t1(docid,words) VALUES(1035021,'And Israel journeyed, and spread his tent beyond the tower of Edar.');\nINSERT INTO t1(docid,words) VALUES(1035022,'And it came to pass, when Israel dwelt in that land, that Reuben went and lay with Bilhah his father''s concubine: and Israel heard it. Now the sons of Jacob were twelve:');\nINSERT INTO t1(docid,words) VALUES(1035023,'The sons of Leah; Reuben, Jacob''s firstborn, and Simeon, and Levi, and Judah, and Issachar, and Zebulun:');\nINSERT INTO t1(docid,words) VALUES(1035024,'The sons of Rachel; Joseph, and Benjamin:');\nINSERT INTO t1(docid,words) VALUES(1035025,'And the sons of Bilhah, Rachel''s handmaid; Dan, and Naphtali:');\nINSERT INTO t1(docid,words) VALUES(1035026,'And the sons of Zilpah, Leah''s handmaid: Gad, and Asher: these are the sons of Jacob, which were born to him in Padanaram.');\nINSERT INTO t1(docid,words) VALUES(1035027,'And Jacob came unto Isaac his father unto Mamre, unto the city of Arbah, which is Hebron, where Abraham and Isaac sojourned.');\nINSERT INTO t1(docid,words) VALUES(1035028,'And the days of Isaac were an hundred and fourscore years.');\nINSERT INTO t1(docid,words) VALUES(1035029,'And Isaac gave up the ghost, and died, and was gathered unto his people, being old and full of days: and his sons Esau and Jacob buried him.');\nINSERT INTO t1(docid,words) VALUES(1036001,'Now these are the generations of Esau, who is Edom.');\nINSERT INTO t1(docid,words) VALUES(1036002,'Esau took his wives of the daughters of Canaan; Adah the daughter of Elon the Hittite, and Aholibamah the daughter of Anah the daughter of Zibeon the Hivite;');\nINSERT INTO t1(docid,words) VALUES(1036003,'And Bashemath Ishmael''s daughter, sister of Nebajoth.');\nINSERT INTO t1(docid,words) VALUES(1036004,'And Adah bare to Esau Eliphaz; and Bashemath bare Reuel;');\nINSERT INTO t1(docid,words) VALUES(1036005,'And Aholibamah bare Jeush, and Jaalam, and Korah: these are the sons of Esau, which were born unto him in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1036006,'And Esau took his wives, and his sons, and his daughters, and all the persons of his house, and his cattle, and all his beasts, and all his substance, which he had got in the land of Canaan; and went into the country from the face of his brother Jacob.');\nINSERT INTO t1(docid,words) VALUES(1036007,'For their riches were more than that they might dwell together; and the land wherein they were strangers could not bear them because of their cattle.');\nINSERT INTO t1(docid,words) VALUES(1036008,'Thus dwelt Esau in mount Seir: Esau is Edom.');\nINSERT INTO t1(docid,words) VALUES(1036009,'And these are the generations of Esau the father of the Edomites in mount Seir:');\nINSERT INTO t1(docid,words) VALUES(1036010,'These are the names of Esau''s sons; Eliphaz the son of Adah the wife of Esau, Reuel the son of Bashemath the wife of Esau.');\nINSERT INTO t1(docid,words) VALUES(1036011,'And the sons of Eliphaz were Teman, Omar, Zepho, and Gatam, and Kenaz.');\nINSERT INTO t1(docid,words) VALUES(1036012,'And Timna was concubine to Eliphaz Esau''s son; and she bare to Eliphaz Amalek: these were the sons of Adah Esau''s wife.');\nINSERT INTO t1(docid,words) VALUES(1036013,'And these are the sons of Reuel; Nahath, and Zerah, Shammah, and Mizzah: these were the sons of Bashemath Esau''s wife.');\nINSERT INTO t1(docid,words) VALUES(1036014,'And these were the sons of Aholibamah, the daughter of Anah the daughter of Zibeon, Esau''s wife: and she bare to Esau Jeush, and Jaalam, and Korah.');\nINSERT INTO t1(docid,words) VALUES(1036015,'These were dukes of the sons of Esau: the sons of Eliphaz the firstborn son of Esau; duke Teman, duke Omar, duke Zepho, duke Kenaz,');\nINSERT INTO t1(docid,words) VALUES(1036016,'Duke Korah, duke Gatam, and duke Amalek: these are the dukes that came of Eliphaz in the land of Edom; these were the sons of Adah.');\nINSERT INTO t1(docid,words) VALUES(1036017,'And these are the sons of Reuel Esau''s son; duke Nahath, duke Zerah, duke Shammah, duke Mizzah: these are the dukes that came of Reuel in the land of Edom; these are the sons of Bashemath Esau''s wife.');\nINSERT INTO t1(docid,words) VALUES(1036018,'And these are the sons of Aholibamah Esau''s wife; duke Jeush, duke Jaalam, duke Korah: these were the dukes that came of Aholibamah the daughter of Anah, Esau''s wife.');\nINSERT INTO t1(docid,words) VALUES(1036019,'These are the sons of Esau, who is Edom, and these are their dukes.');\nINSERT INTO t1(docid,words) VALUES(1036020,'These are the sons of Seir the Horite, who inhabited the land; Lotan, and Shobal, and Zibeon, and Anah,');\nINSERT INTO t1(docid,words) VALUES(1036021,'And Dishon, and Ezer, and Dishan: these are the dukes of the Horites, the children of Seir in the land of Edom.');\nINSERT INTO t1(docid,words) VALUES(1036022,'And the children of Lotan were Hori and Hemam; and Lotan''s sister was Timna.');\nINSERT INTO t1(docid,words) VALUES(1036023,'And the children of Shobal were these; Alvan, and Manahath, and Ebal, Shepho, and Onam.');\nINSERT INTO t1(docid,words) VALUES(1036024,'And these are the children of Zibeon; both Ajah, and Anah: this was that Anah that found the mules in the wilderness, as he fed the asses of Zibeon his father.');\nINSERT INTO t1(docid,words) VALUES(1036025,'And the children of Anah were these; Dishon, and Aholibamah the daughter of Anah.');\nINSERT INTO t1(docid,words) VALUES(1036026,'And these are the children of Dishon; Hemdan, and Eshban, and Ithran, and Cheran.');\nINSERT INTO t1(docid,words) VALUES(1036027,'The children of Ezer are these; Bilhan, and Zaavan, and Akan.');\nINSERT INTO t1(docid,words) VALUES(1036028,'The children of Dishan are these; Uz, and Aran.');\nINSERT INTO t1(docid,words) VALUES(1036029,'These are the dukes that came of the Horites; duke Lotan, duke Shobal, duke Zibeon, duke Anah,');\nINSERT INTO t1(docid,words) VALUES(1036030,'Duke Dishon, duke Ezer, duke Dishan: these are the dukes that came of Hori, among their dukes in the land of Seir.');\nINSERT INTO t1(docid,words) VALUES(1036031,'And these are the kings that reigned in the land of Edom, before there reigned any king over the children of Israel.');\nINSERT INTO t1(docid,words) VALUES(1036032,'And Bela the son of Beor reigned in Edom: and the name of his city was Dinhabah.');\nINSERT INTO t1(docid,words) VALUES(1036033,'And Bela died, and Jobab the son of Zerah of Bozrah reigned in his stead.');\nINSERT INTO t1(docid,words) VALUES(1036034,'And Jobab died, and Husham of the land of Temani reigned in his stead.');\nINSERT INTO t1(docid,words) VALUES(1036035,'And Husham died, and Hadad the son of Bedad, who smote Midian in the field of Moab, reigned in his stead: and the name of his city was Avith.');\nINSERT INTO t1(docid,words) VALUES(1036036,'And Hadad died, and Samlah of Masrekah reigned in his stead.');\nINSERT INTO t1(docid,words) VALUES(1036037,'And Samlah died, and Saul of Rehoboth by the river reigned in his stead.');\nINSERT INTO t1(docid,words) VALUES(1036038,'And Saul died, and Baalhanan the son of Achbor reigned in his stead.');\nINSERT INTO t1(docid,words) VALUES(1036039,'And Baalhanan the son of Achbor died, and Hadar reigned in his stead: and the name of his city was Pau; and his wife''s name was Mehetabel, the daughter of Matred, the daughter of Mezahab.');\nINSERT INTO t1(docid,words) VALUES(1036040,'And these are the names of the dukes that came of Esau, according to their families, after their places, by their names; duke Timnah, duke Alvah, duke Jetheth,');\nINSERT INTO t1(docid,words) VALUES(1036041,'Duke Aholibamah, duke Elah, duke Pinon,');\nINSERT INTO t1(docid,words) VALUES(1036042,'Duke Kenaz, duke Teman, duke Mibzar,');\nINSERT INTO t1(docid,words) VALUES(1036043,'Duke Magdiel, duke Iram: these be the dukes of Edom, according to their habitations in the land of their possession: he is Esau the father of the Edomites.');\nINSERT INTO t1(docid,words) VALUES(1037001,'And Jacob dwelt in the land wherein his father was a stranger, in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1037002,'These are the generations of Jacob. Joseph, being seventeen years old, was feeding the flock with his brethren; and the lad was with the sons of Bilhah, and with the sons of Zilpah, his father''s wives: and Joseph brought unto his father their evil report.');\nINSERT INTO t1(docid,words) VALUES(1037003,'Now Israel loved Joseph more than all his children, because he was the son of his old age: and he made him a coat of many colours.');\nINSERT INTO t1(docid,words) VALUES(1037004,'And when his brethren saw that their father loved him more than all his brethren, they hated him, and could not speak peaceably unto him.');\nINSERT INTO t1(docid,words) VALUES(1037005,'And Joseph dreamed a dream, and he told it his brethren: and they hated him yet the more.');\nINSERT INTO t1(docid,words) VALUES(1037006,'And he said unto them, Hear, I pray you, this dream which I have dreamed:');\nINSERT INTO t1(docid,words) VALUES(1037007,'For, behold, we were binding sheaves in the field, and, lo, my sheaf arose, and also stood upright; and, behold, your sheaves stood round about, and made obeisance to my sheaf.');\nINSERT INTO t1(docid,words) VALUES(1037008,'And his brethren said to him, Shalt thou indeed reign over us? or shalt thou indeed have dominion over us? And they hated him yet the more for his dreams, and for his words.');\nINSERT INTO t1(docid,words) VALUES(1037009,'And he dreamed yet another dream, and told it his brethren, and said, Behold, I have dreamed a dream more; and, behold, the sun and the moon and the eleven stars made obeisance to me.');\nINSERT INTO t1(docid,words) VALUES(1037010,'And he told it to his father, and to his brethren: and his father rebuked him, and said unto him, What is this dream that thou hast dreamed? Shall I and thy mother and thy brethren indeed come to bow down ourselves to thee to the earth?');\nINSERT INTO t1(docid,words) VALUES(1037011,'And his brethren envied him; but his father observed the saying.');\nINSERT INTO t1(docid,words) VALUES(1037012,'And his brethren went to feed their father''s flock in Shechem.');\nINSERT INTO t1(docid,words) VALUES(1037013,'And Israel said unto Joseph, Do not thy brethren feed the flock in Shechem? come, and I will send thee unto them. And he said to him, Here am I.');\nINSERT INTO t1(docid,words) VALUES(1037014,'And he said to him, Go, I pray thee, see whether it be well with thy brethren, and well with the flocks; and bring me word again. So he sent him out of the vale of Hebron, and he came to Shechem.');\nINSERT INTO t1(docid,words) VALUES(1037015,'And a certain man found him, and, behold, he was wandering in the field: and the man asked him, saying, What seekest thou?');\nINSERT INTO t1(docid,words) VALUES(1037016,'And he said, I seek my brethren: tell me, I pray thee, where they feed their flocks.');\nINSERT INTO t1(docid,words) VALUES(1037017,'And the man said, They are departed hence; for I heard them say, Let us go to Dothan. And Joseph went after his brethren, and found them in Dothan.');\nINSERT INTO t1(docid,words) VALUES(1037018,'And when they saw him afar off, even before he came near unto them, they conspired against him to slay him.');\nINSERT INTO t1(docid,words) VALUES(1037019,'And they said one to another, Behold, this dreamer cometh.');\nINSERT INTO t1(docid,words) VALUES(1037020,'Come now therefore, and let us slay him, and cast him into some pit, and we will say, Some evil beast hath devoured him: and we shall see what will become of his dreams.');\nINSERT INTO t1(docid,words) VALUES(1037021,'And Reuben heard it, and he delivered him out of their hands; and said, Let us not kill him.');\nINSERT INTO t1(docid,words) VALUES(1037022,'And Reuben said unto them, Shed no blood, but cast him into this pit that is in the wilderness, and lay no hand upon him; that he might rid him out of their hands, to deliver him to his father again.');\nINSERT INTO t1(docid,words) VALUES(1037023,'And it came to pass, when Joseph was come unto his brethren, that they stript Joseph out of his coat, his coat of many colours that was on him;');\nINSERT INTO t1(docid,words) VALUES(1037024,'And they took him, and cast him into a pit: and the pit was empty, there was no water in it.');\nINSERT INTO t1(docid,words) VALUES(1037025,'And they sat down to eat bread: and they lifted up their eyes and looked, and, behold, a company of Ishmeelites came from Gilead with their camels bearing spicery and balm and myrrh, going to carry it down to Egypt.');\nINSERT INTO t1(docid,words) VALUES(1037026,'And Judah said unto his brethren, What profit is it if we slay our brother, and conceal his blood?');\nINSERT INTO t1(docid,words) VALUES(1037027,'Come, and let us sell him to the Ishmeelites, and let not our hand be upon him; for he is our brother and our flesh. And his brethren were content.');\nINSERT INTO t1(docid,words) VALUES(1037028,'Then there passed by Midianites merchantmen; and they drew and lifted up Joseph out of the pit, and sold Joseph to the Ishmeelites for twenty pieces of silver: and they brought Joseph into Egypt.');\nINSERT INTO t1(docid,words) VALUES(1037029,'And Reuben returned unto the pit; and, behold, Joseph was not in the pit; and he rent his clothes.');\nINSERT INTO t1(docid,words) VALUES(1037030,'And he returned unto his brethren, and said, The child is not; and I, whither shall I go?');\nINSERT INTO t1(docid,words) VALUES(1037031,'And they took Joseph''s coat, and killed a kid of the goats, and dipped the coat in the blood;');\nINSERT INTO t1(docid,words) VALUES(1037032,'And they sent the coat of many colours, and they brought it to their father; and said, This have we found: know now whether it be thy son''s coat or no.');\nINSERT INTO t1(docid,words) VALUES(1037033,'And he knew it, and said, It is my son''s coat; an evil beast hath devoured him; Joseph is without doubt rent in pieces.');\nINSERT INTO t1(docid,words) VALUES(1037034,'And Jacob rent his clothes, and put sackcloth upon his loins, and mourned for his son many days.');\nINSERT INTO t1(docid,words) VALUES(1037035,'And all his sons and all his daughters rose up to comfort him; but he refused to be comforted; and he said, For I will go down into the grave unto my son mourning. Thus his father wept for him.');\nINSERT INTO t1(docid,words) VALUES(1037036,'And the Midianites sold him into Egypt unto Potiphar, an officer of Pharaoh''s, and captain of the guard.');\nINSERT INTO t1(docid,words) VALUES(1038001,'And it came to pass at that time, that Judah went down from his brethren, and turned in to a certain Adullamite, whose name was Hirah.');\nINSERT INTO t1(docid,words) VALUES(1038002,'And Judah saw there a daughter of a certain Canaanite, whose name was Shuah; and he took her, and went in unto her.');\nINSERT INTO t1(docid,words) VALUES(1038003,'And she conceived, and bare a son; and he called his name Er.');\nINSERT INTO t1(docid,words) VALUES(1038004,'And she conceived again, and bare a son; and she called his name Onan.');\nINSERT INTO t1(docid,words) VALUES(1038005,'And she yet again conceived, and bare a son; and called his name Shelah: and he was at Chezib, when she bare him.');\nINSERT INTO t1(docid,words) VALUES(1038006,'And Judah took a wife for Er his firstborn, whose name was Tamar.');\nINSERT INTO t1(docid,words) VALUES(1038007,'And Er, Judah''s firstborn, was wicked in the sight of the LORD; and the LORD slew him.');\nINSERT INTO t1(docid,words) VALUES(1038008,'And Judah said unto Onan, Go in unto thy brother''s wife, and marry her, and raise up seed to thy brother.');\nINSERT INTO t1(docid,words) VALUES(1038009,'And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother''s wife, that he spilled it on the ground, lest that he should give seed to his brother.');\nINSERT INTO t1(docid,words) VALUES(1038010,'And the thing which he did displeased the LORD: wherefore he slew him also.');\nINSERT INTO t1(docid,words) VALUES(1038011,'Then said Judah to Tamar his daughter in law, Remain a widow at thy father''s house, till Shelah my son be grown: for he said, Lest peradventure he die also, as his brethren did. And Tamar went and dwelt in her father''s house.');\nINSERT INTO t1(docid,words) VALUES(1038012,'And in process of time the daughter of Shuah Judah''s wife died; and Judah was comforted, and went up unto his sheepshearers to Timnath, he and his friend Hirah the Adullamite.');\nINSERT INTO t1(docid,words) VALUES(1038013,'And it was told Tamar, saying, Behold thy father in law goeth up to Timnath to shear his sheep.');\nINSERT INTO t1(docid,words) VALUES(1038014,'And she put her widow''s garments off from her, and covered her with a vail, and wrapped herself, and sat in an open place, which is by the way to Timnath; for she saw that Shelah was grown, and she was not given unto him to wife.');\nINSERT INTO t1(docid,words) VALUES(1038015,'When Judah saw her, he thought her to be an harlot; because she had covered her face.');\nINSERT INTO t1(docid,words) VALUES(1038016,'And he turned unto her by the way, and said, Go to, I pray thee, let me come in unto thee; (for he knew not that she was his daughter in law.) And she said, What wilt thou give me, that thou mayest come in unto me?');\nINSERT INTO t1(docid,words) VALUES(1038017,'And he said, I will send thee a kid from the flock. And she said, Wilt thou give me a pledge, till thou send it?');\nINSERT INTO t1(docid,words) VALUES(1038018,'And he said, What pledge shall I give thee? And she said, Thy signet, and thy bracelets, and thy staff that is in thine hand. And he gave it her, and came in unto her, and she conceived by him.');\nINSERT INTO t1(docid,words) VALUES(1038019,'And she arose, and went away, and laid by her vail from her, and put on the garments of her widowhood.');\nINSERT INTO t1(docid,words) VALUES(1038020,'And Judah sent the kid by the hand of his friend the Adullamite, to receive his pledge from the woman''s hand: but he found her not.');\nINSERT INTO t1(docid,words) VALUES(1038021,'Then he asked the men of that place, saying, Where is the harlot, that was openly by the way side? And they said, There was no harlot in this place.');\nINSERT INTO t1(docid,words) VALUES(1038022,'And he returned to Judah, and said, I cannot find her; and also the men of the place said, that there was no harlot in this place.');\nINSERT INTO t1(docid,words) VALUES(1038023,'And Judah said, Let her take it to her, lest we be shamed: behold, I sent this kid, and thou hast not found her.');\nINSERT INTO t1(docid,words) VALUES(1038024,'And it came to pass about three months after, that it was told Judah, saying, Tamar thy daughter in law hath played the harlot; and also, behold, she is with child by whoredom. And Judah said, Bring her forth, and let her be burnt.');\nINSERT INTO t1(docid,words) VALUES(1038025,'When she was brought forth, she sent to her father in law, saying, By the man, whose these are, am I with child: and she said, Discern, I pray thee, whose are these, the signet, and bracelets, and staff.');\nINSERT INTO t1(docid,words) VALUES(1038026,'And Judah acknowledged them, and said, She hath been more righteous than I; because that I gave her not to Shelah my son. And he knew her again no more.');\nINSERT INTO t1(docid,words) VALUES(1038027,'And it came to pass in the time of her travail, that, behold, twins were in her womb.');\nINSERT INTO t1(docid,words) VALUES(1038028,'And it came to pass, when she travailed, that the one put out his hand: and the midwife took and bound upon his hand a scarlet thread, saying, This came out first.');\nINSERT INTO t1(docid,words) VALUES(1038029,'And it came to pass, as he drew back his hand, that, behold, his brother came out: and she said, How hast thou broken forth? this breach be upon thee: therefore his name was called Pharez.');\nINSERT INTO t1(docid,words) VALUES(1038030,'And afterward came out his brother, that had the scarlet thread upon his hand: and his name was called Zarah.');\nINSERT INTO t1(docid,words) VALUES(1039001,'And Joseph was brought down to Egypt; and Potiphar, an officer of Pharaoh, captain of the guard, an Egyptian, bought him of the hands of the Ishmeelites, which had brought him down thither.');\nINSERT INTO t1(docid,words) VALUES(1039002,'And the LORD was with Joseph, and he was a prosperous man; and he was in the house of his master the Egyptian.');\nINSERT INTO t1(docid,words) VALUES(1039003,'And his master saw that the LORD was with him, and that the LORD made all that he did to prosper in his hand.');\nINSERT INTO t1(docid,words) VALUES(1039004,'And Joseph found grace in his sight, and he served him: and he made him overseer over his house, and all that he had he put into his hand.');\nINSERT INTO t1(docid,words) VALUES(1039005,'And it came to pass from the time that he had made him overseer in his house, and over all that he had, that the LORD blessed the Egyptian''s house for Joseph''s sake; and the blessing of the LORD was upon all that he had in the house, and in the field.');\nINSERT INTO t1(docid,words) VALUES(1039006,'And he left all that he had in Joseph''s hand; and he knew not ought he had, save the bread which he did eat. And Joseph was a goodly person, and well favoured.');\nINSERT INTO t1(docid,words) VALUES(1039007,'And it came to pass after these things, that his master''s wife cast her eyes upon Joseph; and she said, Lie with me.');\nINSERT INTO t1(docid,words) VALUES(1039008,'But he refused, and said unto his master''s wife, Behold, my master wotteth not what is with me in the house, and he hath committed all that he hath to my hand;');\nINSERT INTO t1(docid,words) VALUES(1039009,'There is none greater in this house than I; neither hath he kept back any thing from me but thee, because thou art his wife: how then can I do this great wickedness, and sin against God?');\nINSERT INTO t1(docid,words) VALUES(1039010,'And it came to pass, as she spake to Joseph day by day, that he hearkened not unto her, to lie by her, or to be with her.');\nINSERT INTO t1(docid,words) VALUES(1039011,'And it came to pass about this time, that Joseph went into the house to do his business; and there was none of the men of the house there within.');\nINSERT INTO t1(docid,words) VALUES(1039012,'And she caught him by his garment, saying, Lie with me: and he left his garment in her hand, and fled, and got him out.');\nINSERT INTO t1(docid,words) VALUES(1039013,'And it came to pass, when she saw that he had left his garment in her hand, and was fled forth,');\nINSERT INTO t1(docid,words) VALUES(1039014,'That she called unto the men of her house, and spake unto them, saying, See, he hath brought in an Hebrew unto us to mock us; he came in unto me to lie with me, and I cried with a loud voice:');\nINSERT INTO t1(docid,words) VALUES(1039015,'And it came to pass, when he heard that I lifted up my voice and cried, that he left his garment with me, and fled, and got him out.');\nINSERT INTO t1(docid,words) VALUES(1039016,'And she laid up his garment by her, until his lord came home.');\nINSERT INTO t1(docid,words) VALUES(1039017,'And she spake unto him according to these words, saying, The Hebrew servant, which thou hast brought unto us, came in unto me to mock me:');\nINSERT INTO t1(docid,words) VALUES(1039018,'And it came to pass, as I lifted up my voice and cried, that he left his garment with me, and fled out.');\nINSERT INTO t1(docid,words) VALUES(1039019,'And it came to pass, when his master heard the words of his wife, which she spake unto him, saying, After this manner did thy servant to me; that his wrath was kindled.');\nINSERT INTO t1(docid,words) VALUES(1039020,'And Joseph''s master took him, and put him into the prison, a place where the king''s prisoners were bound: and he was there in the prison.');\nINSERT INTO t1(docid,words) VALUES(1039021,'But the LORD was with Joseph, and shewed him mercy, and gave him favour in the sight of the keeper of the prison.');\nINSERT INTO t1(docid,words) VALUES(1039022,'And the keeper of the prison committed to Joseph''s hand all the prisoners that were in the prison; and whatsoever they did there, he was the doer of it.');\nINSERT INTO t1(docid,words) VALUES(1039023,'The keeper of the prison looked not to any thing that was under his hand; because the LORD was with him, and that which he did, the LORD made it to prosper.');\nINSERT INTO t1(docid,words) VALUES(1040001,'And it came to pass after these things, that the butler of the king of Egypt and his baker had offended their lord the king of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1040002,'And Pharaoh was wroth against two of his officers, against the chief of the butlers, and against the chief of the bakers.');\nINSERT INTO t1(docid,words) VALUES(1040003,'And he put them in ward in the house of the captain of the guard, into the prison, the place where Joseph was bound.');\nINSERT INTO t1(docid,words) VALUES(1040004,'And the captain of the guard charged Joseph with them, and he served them: and they continued a season in ward.');\nINSERT INTO t1(docid,words) VALUES(1040005,'And they dreamed a dream both of them, each man his dream in one night, each man according to the interpretation of his dream, the butler and the baker of the king of Egypt, which were bound in the prison.');\nINSERT INTO t1(docid,words) VALUES(1040006,'And Joseph came in unto them in the morning, and looked upon them, and, behold, they were sad.');\nINSERT INTO t1(docid,words) VALUES(1040007,'And he asked Pharaoh''s officers that were with him in the ward of his lord''s house, saying, Wherefore look ye so sadly to day?');\nINSERT INTO t1(docid,words) VALUES(1040008,'And they said unto him, We have dreamed a dream, and there is no interpreter of it. And Joseph said unto them, Do not interpretations belong to God? tell me them, I pray you.');\nINSERT INTO t1(docid,words) VALUES(1040009,'And the chief butler told his dream to Joseph, and said to him, In my dream, behold, a vine was before me;');\nINSERT INTO t1(docid,words) VALUES(1040010,'And in the vine were three branches: and it was as though it budded, and her blossoms shot forth; and the clusters thereof brought forth ripe grapes:');\nINSERT INTO t1(docid,words) VALUES(1040011,'And Pharaoh''s cup was in my hand: and I took the grapes, and pressed them into Pharaoh''s cup, and I gave the cup into Pharaoh''s hand.');\nINSERT INTO t1(docid,words) VALUES(1040012,'And Joseph said unto him, This is the interpretation of it: The three branches are three days:');\nINSERT INTO t1(docid,words) VALUES(1040013,'Yet within three days shall Pharaoh lift up thine head, and restore thee unto thy place: and thou shalt deliver Pharaoh''s cup into his hand, after the former manner when thou wast his butler.');\nINSERT INTO t1(docid,words) VALUES(1040014,'But think on me when it shall be well with thee, and shew kindness, I pray thee, unto me, and make mention of me unto Pharaoh, and bring me out of this house:');\nINSERT INTO t1(docid,words) VALUES(1040015,'For indeed I was stolen away out of the land of the Hebrews: and here also have I done nothing that they should put me into the dungeon.');\nINSERT INTO t1(docid,words) VALUES(1040016,'When the chief baker saw that the interpretation was good, he said unto Joseph, I also was in my dream, and, behold, I had three white baskets on my head:');\nINSERT INTO t1(docid,words) VALUES(1040017,'And in the uppermost basket there was of all manner of bakemeats for Pharaoh; and the birds did eat them out of the basket upon my head.');\nINSERT INTO t1(docid,words) VALUES(1040018,'And Joseph answered and said, This is the interpretation thereof: The three baskets are three days:');\nINSERT INTO t1(docid,words) VALUES(1040019,'Yet within three days shall Pharaoh lift up thy head from off thee, and shall hang thee on a tree; and the birds shall eat thy flesh from off thee.');\nINSERT INTO t1(docid,words) VALUES(1040020,'And it came to pass the third day, which was Pharaoh''s birthday, that he made a feast unto all his servants: and he lifted up the head of the chief butler and of the chief baker among his servants.');\nINSERT INTO t1(docid,words) VALUES(1040021,'And he restored the chief butler unto his butlership again; and he gave the cup into Pharaoh''s hand:');\nINSERT INTO t1(docid,words) VALUES(1040022,'But he hanged the chief baker: as Joseph had interpreted to them.');\nINSERT INTO t1(docid,words) VALUES(1040023,'Yet did not the chief butler remember Joseph, but forgat him.');\nINSERT INTO t1(docid,words) VALUES(1041001,'And it came to pass at the end of two full years, that Pharaoh dreamed: and, behold, he stood by the river.');\nINSERT INTO t1(docid,words) VALUES(1041002,'And, behold, there came up out of the river seven well favoured kine and fatfleshed; and they fed in a meadow.');\nINSERT INTO t1(docid,words) VALUES(1041003,'And, behold, seven other kine came up after them out of the river, ill favoured and leanfleshed; and stood by the other kine upon the brink of the river.');\nINSERT INTO t1(docid,words) VALUES(1041004,'And the ill favoured and leanfleshed kine did eat up the seven well favoured and fat kine. So Pharaoh awoke.');\nINSERT INTO t1(docid,words) VALUES(1041005,'And he slept and dreamed the second time: and, behold, seven ears of corn came up upon one stalk, rank and good.');\nINSERT INTO t1(docid,words) VALUES(1041006,'And, behold, seven thin ears and blasted with the east wind sprung up after them.');\nINSERT INTO t1(docid,words) VALUES(1041007,'And the seven thin ears devoured the seven rank and full ears. And Pharaoh awoke, and, behold, it was a dream.');\nINSERT INTO t1(docid,words) VALUES(1041008,'And it came to pass in the morning that his spirit was troubled; and he sent and called for all the magicians of Egypt, and all the wise men thereof: and Pharaoh told them his dream; but there was none that could interpret them unto Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1041009,'Then spake the chief butler unto Pharaoh, saying, I do remember my faults this day:');\nINSERT INTO t1(docid,words) VALUES(1041010,'Pharaoh was wroth with his servants, and put me in ward in the captain of the guard''s house, both me and the chief baker:');\nINSERT INTO t1(docid,words) VALUES(1041011,'And we dreamed a dream in one night, I and he; we dreamed each man according to the interpretation of his dream.');\nINSERT INTO t1(docid,words) VALUES(1041012,'And there was there with us a young man, an Hebrew, servant to the captain of the guard; and we told him, and he interpreted to us our dreams; to each man according to his dream he did interpret.');\nINSERT INTO t1(docid,words) VALUES(1041013,'And it came to pass, as he interpreted to us, so it was; me he restored unto mine office, and him he hanged.');\nINSERT INTO t1(docid,words) VALUES(1041014,'Then Pharaoh sent and called Joseph, and they brought him hastily out of the dungeon: and he shaved himself, and changed his raiment, and came in unto Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1041015,'And Pharaoh said unto Joseph, I have dreamed a dream, and there is none that can interpret it: and I have heard say of thee, that thou canst understand a dream to interpret it.');\nINSERT INTO t1(docid,words) VALUES(1041016,'And Joseph answered Pharaoh, saying, It is not in me: God shall give Pharaoh an answer of peace.');\nINSERT INTO t1(docid,words) VALUES(1041017,'And Pharaoh said unto Joseph, In my dream, behold, I stood upon the bank of the river:');\nINSERT INTO t1(docid,words) VALUES(1041018,'And, behold, there came up out of the river seven kine, fatfleshed and well favoured; and they fed in a meadow:');\nINSERT INTO t1(docid,words) VALUES(1041019,'And, behold, seven other kine came up after them, poor and very ill favoured and leanfleshed, such as I never saw in all the land of Egypt for badness:');\nINSERT INTO t1(docid,words) VALUES(1041020,'And the lean and the ill favoured kine did eat up the first seven fat kine:');\nINSERT INTO t1(docid,words) VALUES(1041021,'And when they had eaten them up, it could not be known that they had eaten them; but they were still ill favoured, as at the beginning. So I awoke.');\nINSERT INTO t1(docid,words) VALUES(1041022,'And I saw in my dream, and, behold, seven ears came up in one stalk, full and good:');\nINSERT INTO t1(docid,words) VALUES(1041023,'And, behold, seven ears, withered, thin, and blasted with the east wind, sprung up after them:');\nINSERT INTO t1(docid,words) VALUES(1041024,'And the thin ears devoured the seven good ears: and I told this unto the magicians; but there was none that could declare it to me.');\nINSERT INTO t1(docid,words) VALUES(1041025,'And Joseph said unto Pharaoh, The dream of Pharaoh is one: God hath shewed Pharaoh what he is about to do.');\nINSERT INTO t1(docid,words) VALUES(1041026,'The seven good kine are seven years; and the seven good ears are seven years: the dream is one.');\nINSERT INTO t1(docid,words) VALUES(1041027,'And the seven thin and ill favoured kine that came up after them are seven years; and the seven empty ears blasted with the east wind shall be seven years of famine.');\nINSERT INTO t1(docid,words) VALUES(1041028,'This is the thing which I have spoken unto Pharaoh: What God is about to do he sheweth unto Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1041029,'Behold, there come seven years of great plenty throughout all the land of Egypt:');\nINSERT INTO t1(docid,words) VALUES(1041030,'And there shall arise after them seven years of famine; and all the plenty shall be forgotten in the land of Egypt; and the famine shall consume the land;');\nINSERT INTO t1(docid,words) VALUES(1041031,'And the plenty shall not be known in the land by reason of that famine following; for it shall be very grievous.');\nINSERT INTO t1(docid,words) VALUES(1041032,'And for that the dream was doubled unto Pharaoh twice; it is because the thing is established by God, and God will shortly bring it to pass.');\nINSERT INTO t1(docid,words) VALUES(1041033,'Now therefore let Pharaoh look out a man discreet and wise, and set him over the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041034,'Let Pharaoh do this, and let him appoint officers over the land, and take up the fifth part of the land of Egypt in the seven plenteous years.');\nINSERT INTO t1(docid,words) VALUES(1041035,'And let them gather all the food of those good years that come, and lay up corn under the hand of Pharaoh, and let them keep food in the cities.');\nINSERT INTO t1(docid,words) VALUES(1041036,'And that food shall be for store to the land against the seven years of famine, which shall be in the land of Egypt; that the land perish not through the famine.');\nINSERT INTO t1(docid,words) VALUES(1041037,'And the thing was good in the eyes of Pharaoh, and in the eyes of all his servants.');\nINSERT INTO t1(docid,words) VALUES(1041038,'And Pharaoh said unto his servants, Can we find such a one as this is, a man in whom the Spirit of God is?');\nINSERT INTO t1(docid,words) VALUES(1041039,'And Pharaoh said unto Joseph, Forasmuch as God hath shewed thee all this, there is none so discreet and wise as thou art:');\nINSERT INTO t1(docid,words) VALUES(1041040,'Thou shalt be over my house, and according unto thy word shall all my people be ruled: only in the throne will I be greater than thou.');\nINSERT INTO t1(docid,words) VALUES(1041041,'And Pharaoh said unto Joseph, See, I have set thee over all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041042,'And Pharaoh took off his ring from his hand, and put it upon Joseph''s hand, and arrayed him in vestures of fine linen, and put a gold chain about his neck;');\nINSERT INTO t1(docid,words) VALUES(1041043,'And he made him to ride in the second chariot which he had; and they cried before him, Bow the knee: and he made him ruler over all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041044,'And Pharaoh said unto Joseph, I am Pharaoh, and without thee shall no man lift up his hand or foot in all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041045,'And Pharaoh called Joseph''s name Zaphnathpaaneah; and he gave him to wife Asenath the daughter of Potipherah priest of On. And Joseph went out over all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041046,'And Joseph was thirty years old when he stood before Pharaoh king of Egypt. And Joseph went out from the presence of Pharaoh, and went throughout all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041047,'And in the seven plenteous years the earth brought forth by handfuls.');\nINSERT INTO t1(docid,words) VALUES(1041048,'And he gathered up all the food of the seven years, which were in the land of Egypt, and laid up the food in the cities: the food of the field, which was round about every city, laid he up in the same.');\nINSERT INTO t1(docid,words) VALUES(1041049,'And Joseph gathered corn as the sand of the sea, very much, until he left numbering; for it was without number.');\nINSERT INTO t1(docid,words) VALUES(1041050,'And unto Joseph were born two sons before the years of famine came, which Asenath the daughter of Potipherah priest of On bare unto him.');\nINSERT INTO t1(docid,words) VALUES(1041051,'And Joseph called the name of the firstborn Manasseh: For God, said he, hath made me forget all my toil, and all my father''s house.');\nINSERT INTO t1(docid,words) VALUES(1041052,'And the name of the second called he Ephraim: For God hath caused me to be fruitful in the land of my affliction.');\nINSERT INTO t1(docid,words) VALUES(1041053,'And the seven years of plenteousness, that was in the land of Egypt, were ended.');\nINSERT INTO t1(docid,words) VALUES(1041054,'And the seven years of dearth began to come, according as Joseph had said: and the dearth was in all lands; but in all the land of Egypt there was bread.');\nINSERT INTO t1(docid,words) VALUES(1041055,'And when all the land of Egypt was famished, the people cried to Pharaoh for bread: and Pharaoh said unto all the Egyptians, Go unto Joseph; what he saith to you, do.');\nINSERT INTO t1(docid,words) VALUES(1041056,'And the famine was over all the face of the earth: and Joseph opened all the storehouses, and sold unto the Egyptians; and the famine waxed sore in the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1041057,'And all countries came into Egypt to Joseph for to buy corn; because that the famine was so sore in all lands.');\nINSERT INTO t1(docid,words) VALUES(1042001,'Now when Jacob saw that there was corn in Egypt, Jacob said unto his sons, Why do ye look one upon another?');\nINSERT INTO t1(docid,words) VALUES(1042002,'And he said, Behold, I have heard that there is corn in Egypt: get you down thither, and buy for us from thence; that we may live, and not die.');\nINSERT INTO t1(docid,words) VALUES(1042003,'And Joseph''s ten brethren went down to buy corn in Egypt.');\nINSERT INTO t1(docid,words) VALUES(1042004,'But Benjamin, Joseph''s brother, Jacob sent not with his brethren; for he said, Lest peradventure mischief befall him.');\nINSERT INTO t1(docid,words) VALUES(1042005,'And the sons of Israel came to buy corn among those that came: for the famine was in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1042006,'And Joseph was the governor over the land, and he it was that sold to all the people of the land: and Joseph''s brethren came, and bowed down themselves before him with their faces to the earth.');\nINSERT INTO t1(docid,words) VALUES(1042007,'And Joseph saw his brethren, and he knew them, but made himself strange unto them, and spake roughly unto them; and he said unto them, Whence come ye? And they said, From the land of Canaan to buy food.');\nINSERT INTO t1(docid,words) VALUES(1042008,'And Joseph knew his brethren, but they knew not him.');\nINSERT INTO t1(docid,words) VALUES(1042009,'And Joseph remembered the dreams which he dreamed of them, and said unto them, Ye are spies; to see the nakedness of the land ye are come.');\nINSERT INTO t1(docid,words) VALUES(1042010,'And they said unto him, Nay, my lord, but to buy food are thy servants come.');\nINSERT INTO t1(docid,words) VALUES(1042011,'We are all one man''s sons; we are true men, thy servants are no spies.');\nINSERT INTO t1(docid,words) VALUES(1042012,'And he said unto them, Nay, but to see the nakedness of the land ye are come.');\nINSERT INTO t1(docid,words) VALUES(1042013,'And they said, Thy servants are twelve brethren, the sons of one man in the land of Canaan; and, behold, the youngest is this day with our father, and one is not.');\nINSERT INTO t1(docid,words) VALUES(1042014,'And Joseph said unto them, That is it that I spake unto you, saying, Ye are spies:');\nINSERT INTO t1(docid,words) VALUES(1042015,'Hereby ye shall be proved: By the life of Pharaoh ye shall not go forth hence, except your youngest brother come hither.');\nINSERT INTO t1(docid,words) VALUES(1042016,'Send one of you, and let him fetch your brother, and ye shall be kept in prison, that your words may be proved, whether there be any truth in you: or else by the life of Pharaoh surely ye are spies.');\nINSERT INTO t1(docid,words) VALUES(1042017,'And he put them all together into ward three days.');\nINSERT INTO t1(docid,words) VALUES(1042018,'And Joseph said unto them the third day, This do, and live; for I fear God:');\nINSERT INTO t1(docid,words) VALUES(1042019,'If ye be true men, let one of your brethren be bound in the house of your prison: go ye, carry corn for the famine of your houses:');\nINSERT INTO t1(docid,words) VALUES(1042020,'But bring your youngest brother unto me; so shall your words be verified, and ye shall not die. And they did so.');\nINSERT INTO t1(docid,words) VALUES(1042021,'And they said one to another, We are verily guilty concerning our brother, in that we saw the anguish of his soul, when he besought us, and we would not hear; therefore is this distress come upon us.');\nINSERT INTO t1(docid,words) VALUES(1042022,'And Reuben answered them, saying, Spake I not unto you, saying, Do not sin against the child; and ye would not hear? therefore, behold, also his blood is required.');\nINSERT INTO t1(docid,words) VALUES(1042023,'And they knew not that Joseph understood them; for he spake unto them by an interpreter.');\nINSERT INTO t1(docid,words) VALUES(1042024,'And he turned himself about from them, and wept; and returned to them again, and communed with them, and took from them Simeon, and bound him before their eyes.');\nINSERT INTO t1(docid,words) VALUES(1042025,'Then Joseph commanded to fill their sacks with corn, and to restore every man''s money into his sack, and to give them provision for the way: and thus did he unto them.');\nINSERT INTO t1(docid,words) VALUES(1042026,'And they laded their asses with the corn, and departed thence.');\nINSERT INTO t1(docid,words) VALUES(1042027,'And as one of them opened his sack to give his ass provender in the inn, he espied his money; for, behold, it was in his sack''s mouth.');\nINSERT INTO t1(docid,words) VALUES(1042028,'And he said unto his brethren, My money is restored; and, lo, it is even in my sack: and their heart failed them, and they were afraid, saying one to another, What is this that God hath done unto us?');\nINSERT INTO t1(docid,words) VALUES(1042029,'And they came unto Jacob their father unto the land of Canaan, and told him all that befell unto them; saying,');\nINSERT INTO t1(docid,words) VALUES(1042030,'The man, who is the lord of the land, spake roughly to us, and took us for spies of the country.');\nINSERT INTO t1(docid,words) VALUES(1042031,'And we said unto him, We are true men; we are no spies:');\nINSERT INTO t1(docid,words) VALUES(1042032,'We be twelve brethren, sons of our father; one is not, and the youngest is this day with our father in the land of Canaan.');\nINSERT INTO t1(docid,words) VALUES(1042033,'And the man, the lord of the country, said unto us, Hereby shall I know that ye are true men; leave one of your brethren here with me, and take food for the famine of your households, and be gone:');\nINSERT INTO t1(docid,words) VALUES(1042034,'And bring your youngest brother unto me: then shall I know that ye are no spies, but that ye are true men: so will I deliver you your brother, and ye shall traffick in the land.');\nINSERT INTO t1(docid,words) VALUES(1042035,'And it came to pass as they emptied their sacks, that, behold, every man''s bundle of money was in his sack: and when both they and their father saw the bundles of money, they were afraid.');\nINSERT INTO t1(docid,words) VALUES(1042036,'And Jacob their father said unto them, Me have ye bereaved of my children: Joseph is not, and Simeon is not, and ye will take Benjamin away: all these things are against me.');\nINSERT INTO t1(docid,words) VALUES(1042037,'And Reuben spake unto his father, saying, Slay my two sons, if I bring him not to thee: deliver him into my hand, and I will bring him to thee again.');\nINSERT INTO t1(docid,words) VALUES(1042038,'And he said, My son shall not go down with you; for his brother is dead, and he is left alone: if mischief befall him by the way in the which ye go, then shall ye bring down my gray hairs with sorrow to the grave.');\nINSERT INTO t1(docid,words) VALUES(1043001,'And the famine was sore in the land.');\nINSERT INTO t1(docid,words) VALUES(1043002,'And it came to pass, when they had eaten up the corn which they had brought out of Egypt, their father said unto them, Go again, buy us a little food.');\nINSERT INTO t1(docid,words) VALUES(1043003,'And Judah spake unto him, saying, The man did solemnly protest unto us, saying, Ye shall not see my face, except your brother be with you.');\nINSERT INTO t1(docid,words) VALUES(1043004,'If thou wilt send our brother with us, we will go down and buy thee food:');\nINSERT INTO t1(docid,words) VALUES(1043005,'But if thou wilt not send him, we will not go down: for the man said unto us, Ye shall not see my face, except your brother be with you.');\nINSERT INTO t1(docid,words) VALUES(1043006,'And Israel said, Wherefore dealt ye so ill with me, as to tell the man whether ye had yet a brother?');\nINSERT INTO t1(docid,words) VALUES(1043007,'And they said, The man asked us straitly of our state, and of our kindred, saying, Is your father yet alive? have ye another brother? and we told him according to the tenor of these words: could we certainly know that he would say, Bring your brother down?');\nINSERT INTO t1(docid,words) VALUES(1043008,'And Judah said unto Israel his father, Send the lad with me, and we will arise and go; that we may live, and not die, both we, and thou, and also our little ones.');\nINSERT INTO t1(docid,words) VALUES(1043009,'I will be surety for him; of my hand shalt thou require him: if I bring him not unto thee, and set him before thee, then let me bear the blame for ever:');\nINSERT INTO t1(docid,words) VALUES(1043010,'For except we had lingered, surely now we had returned this second time.');\nINSERT INTO t1(docid,words) VALUES(1043011,'And their father Israel said unto them, If it must be so now, do this; take of the best fruits in the land in your vessels, and carry down the man a present, a little balm, and a little honey, spices, and myrrh, nuts, and almonds:');\nINSERT INTO t1(docid,words) VALUES(1043012,'And take double money in your hand; and the money that was brought again in the mouth of your sacks, carry it again in your hand; peradventure it was an oversight:');\nINSERT INTO t1(docid,words) VALUES(1043013,'Take also your brother, and arise, go again unto the man:');\nINSERT INTO t1(docid,words) VALUES(1043014,'And God Almighty give you mercy before the man, that he may send away your other brother, and Benjamin. If I be bereaved of my children, I am bereaved.');\nINSERT INTO t1(docid,words) VALUES(1043015,'And the men took that present, and they took double money in their hand and Benjamin; and rose up, and went down to Egypt, and stood before Joseph.');\nINSERT INTO t1(docid,words) VALUES(1043016,'And when Joseph saw Benjamin with them, he said to the ruler of his house, Bring these men home, and slay, and make ready; for these men shall dine with me at noon.');\nINSERT INTO t1(docid,words) VALUES(1043017,'And the man did as Joseph bade; and the man brought the men into Joseph''s house.');\nINSERT INTO t1(docid,words) VALUES(1043018,'And the men were afraid, because they were brought into Joseph''s house; and they said, Because of the money that was returned in our sacks at the first time are we brought in; that he may seek occasion against us, and fall upon us, and take us for bondmen, and our asses.');\nINSERT INTO t1(docid,words) VALUES(1043019,'And they came near to the steward of Joseph''s house, and they communed with him at the door of the house,');\nINSERT INTO t1(docid,words) VALUES(1043020,'And said, O sir, we came indeed down at the first time to buy food:');\nINSERT INTO t1(docid,words) VALUES(1043021,'And it came to pass, when we came to the inn, that we opened our sacks, and, behold, every man''s money was in the mouth of his sack, our money in full weight: and we have brought it again in our hand.');\nINSERT INTO t1(docid,words) VALUES(1043022,'And other money have we brought down in our hands to buy food: we cannot tell who put our money in our sacks.');\nINSERT INTO t1(docid,words) VALUES(1043023,'And he said, Peace be to you, fear not: your God, and the God of your father, hath given you treasure in your sacks: I had your money. And he brought Simeon out unto them.');\nINSERT INTO t1(docid,words) VALUES(1043024,'And the man brought the men into Joseph''s house, and gave them water, and they washed their feet; and he gave their asses provender.');\nINSERT INTO t1(docid,words) VALUES(1043025,'And they made ready the present against Joseph came at noon: for they heard that they should eat bread there.');\nINSERT INTO t1(docid,words) VALUES(1043026,'And when Joseph came home, they brought him the present which was in their hand into the house, and bowed themselves to him to the earth.');\nINSERT INTO t1(docid,words) VALUES(1043027,'And he asked them of their welfare, and said, Is your father well, the old man of whom ye spake? Is he yet alive?');\nINSERT INTO t1(docid,words) VALUES(1043028,'And they answered, Thy servant our father is in good health, he is yet alive. And they bowed down their heads, and made obeisance.');\nINSERT INTO t1(docid,words) VALUES(1043029,'And he lifted up his eyes, and saw his brother Benjamin, his mother''s son, and said, Is this your younger brother, of whom ye spake unto me? And he said, God be gracious unto thee, my son.');\nINSERT INTO t1(docid,words) VALUES(1043030,'And Joseph made haste; for his bowels did yearn upon his brother: and he sought where to weep; and he entered into his chamber, and wept there.');\nINSERT INTO t1(docid,words) VALUES(1043031,'And he washed his face, and went out, and refrained himself, and said, Set on bread.');\nINSERT INTO t1(docid,words) VALUES(1043032,'And they set on for him by himself, and for them by themselves, and for the Egyptians, which did eat with him, by themselves: because the Egyptians might not eat bread with the Hebrews; for that is an abomination unto the Egyptians.');\nINSERT INTO t1(docid,words) VALUES(1043033,'And they sat before him, the firstborn according to his birthright, and the youngest according to his youth: and the men marvelled one at another.');\nINSERT INTO t1(docid,words) VALUES(1043034,'And he took and sent messes unto them from before him: but Benjamin''s mess was five times so much as any of their''s. And they drank, and were merry with him.');\nINSERT INTO t1(docid,words) VALUES(1044001,'And he commanded the steward of his house, saying, Fill the men''s sacks with food, as much as they can carry, and put every man''s money in his sack''s mouth.');\nINSERT INTO t1(docid,words) VALUES(1044002,'And put my cup, the silver cup, in the sack''s mouth of the youngest, and his corn money. And he did according to the word that Joseph had spoken.');\nINSERT INTO t1(docid,words) VALUES(1044003,'As soon as the morning was light, the men were sent away, they and their asses.');\nINSERT INTO t1(docid,words) VALUES(1044004,'And when they were gone out of the city, and not yet far off, Joseph said unto his steward, Up, follow after the men; and when thou dost overtake them, say unto them, Wherefore have ye rewarded evil for good?');\nINSERT INTO t1(docid,words) VALUES(1044005,'Is not this it in which my lord drinketh, and whereby indeed he divineth? ye have done evil in so doing.');\nINSERT INTO t1(docid,words) VALUES(1044006,'And he overtook them, and he spake unto them these same words.');\nINSERT INTO t1(docid,words) VALUES(1044007,'And they said unto him, Wherefore saith my lord these words? God forbid that thy servants should do according to this thing:');\nINSERT INTO t1(docid,words) VALUES(1044008,'Behold, the money, which we found in our sacks'' mouths, we brought again unto thee out of the land of Canaan: how then should we steal out of thy lord''s house silver or gold?');\nINSERT INTO t1(docid,words) VALUES(1044009,'With whomsoever of thy servants it be found, both let him die, and we also will be my lord''s bondmen.');\nINSERT INTO t1(docid,words) VALUES(1044010,'And he said, Now also let it be according unto your words: he with whom it is found shall be my servant; and ye shall be blameless.');\nINSERT INTO t1(docid,words) VALUES(1044011,'Then they speedily took down every man his sack to the ground, and opened every man his sack.');\nINSERT INTO t1(docid,words) VALUES(1044012,'And he searched, and began at the eldest, and left at the youngest: and the cup was found in Benjamin''s sack.');\nINSERT INTO t1(docid,words) VALUES(1044013,'Then they rent their clothes, and laded every man his ass, and returned to the city.');\nINSERT INTO t1(docid,words) VALUES(1044014,'And Judah and his brethren came to Joseph''s house; for he was yet there: and they fell before him on the ground.');\nINSERT INTO t1(docid,words) VALUES(1044015,'And Joseph said unto them, What deed is this that ye have done? wot ye not that such a man as I can certainly divine?');\nINSERT INTO t1(docid,words) VALUES(1044016,'And Judah said, What shall we say unto my lord? what shall we speak? or how shall we clear ourselves? God hath found out the iniquity of thy servants: behold, we are my lord''s servants, both we, and he also with whom the cup is found.');\nINSERT INTO t1(docid,words) VALUES(1044017,'And he said, God forbid that I should do so: but the man in whose hand the cup is found, he shall be my servant; and as for you, get you up in peace unto your father.');\nINSERT INTO t1(docid,words) VALUES(1044018,'Then Judah came near unto him, and said, Oh my lord, let thy servant, I pray thee, speak a word in my lord''s ears, and let not thine anger burn against thy servant: for thou art even as Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1044019,'My lord asked his servants, saying, Have ye a father, or a brother?');\nINSERT INTO t1(docid,words) VALUES(1044020,'And we said unto my lord, We have a father, an old man, and a child of his old age, a little one; and his brother is dead, and he alone is left of his mother, and his father loveth him.');\nINSERT INTO t1(docid,words) VALUES(1044021,'And thou saidst unto thy servants, Bring him down unto me, that I may set mine eyes upon him.');\nINSERT INTO t1(docid,words) VALUES(1044022,'And we said unto my lord, The lad cannot leave his father: for if he should leave his father, his father would die.');\nINSERT INTO t1(docid,words) VALUES(1044023,'And thou saidst unto thy servants, Except your youngest brother come down with you, ye shall see my face no more.');\nINSERT INTO t1(docid,words) VALUES(1044024,'And it came to pass when we came up unto thy servant my father, we told him the words of my lord.');\nINSERT INTO t1(docid,words) VALUES(1044025,'And our father said, Go again, and buy us a little food.');\nINSERT INTO t1(docid,words) VALUES(1044026,'And we said, We cannot go down: if our youngest brother be with us, then will we go down: for we may not see the man''s face, except our youngest brother be with us.');\nINSERT INTO t1(docid,words) VALUES(1044027,'And thy servant my father said unto us, Ye know that my wife bare me two sons:');\nINSERT INTO t1(docid,words) VALUES(1044028,'And the one went out from me, and I said, Surely he is torn in pieces; and I saw him not since:');\nINSERT INTO t1(docid,words) VALUES(1044029,'And if ye take this also from me, and mischief befall him, ye shall bring down my gray hairs with sorrow to the grave.');\nINSERT INTO t1(docid,words) VALUES(1044030,'Now therefore when I come to thy servant my father, and the lad be not with us; seeing that his life is bound up in the lad''s life;');\nINSERT INTO t1(docid,words) VALUES(1044031,'It shall come to pass, when he seeth that the lad is not with us, that he will die: and thy servants shall bring down the gray hairs of thy servant our father with sorrow to the grave.');\nINSERT INTO t1(docid,words) VALUES(1044032,'For thy servant became surety for the lad unto my father, saying, If I bring him not unto thee, then I shall bear the blame to my father for ever.');\nINSERT INTO t1(docid,words) VALUES(1044033,'Now therefore, I pray thee, let thy servant abide instead of the lad a bondman to my lord; and let the lad go up with his brethren.');\nINSERT INTO t1(docid,words) VALUES(1044034,'For how shall I go up to my father, and the lad be not with me? lest peradventure I see the evil that shall come on my father.');\nINSERT INTO t1(docid,words) VALUES(1045001,'Then Joseph could not refrain himself before all them that stood by him; and he cried, Cause every man to go out from me. And there stood no man with him, while Joseph made himself known unto his brethren.');\nINSERT INTO t1(docid,words) VALUES(1045002,'And he wept aloud: and the Egyptians and the house of Pharaoh heard.');\nINSERT INTO t1(docid,words) VALUES(1045003,'And Joseph said unto his brethren, I am Joseph; doth my father yet live? And his brethren could not answer him; for they were troubled at his presence.');\nINSERT INTO t1(docid,words) VALUES(1045004,'And Joseph said unto his brethren, Come near to me, I pray you. And they came near. And he said, I am Joseph your brother, whom ye sold into Egypt.');\nINSERT INTO t1(docid,words) VALUES(1045005,'Now therefore be not grieved, nor angry with yourselves, that ye sold me hither: for God did send me before you to preserve life.');\nINSERT INTO t1(docid,words) VALUES(1045006,'For these two years hath the famine been in the land: and yet there are five years, in the which there shall neither be earing nor harvest.');\nINSERT INTO t1(docid,words) VALUES(1045007,'And God sent me before you to preserve you a posterity in the earth, and to save your lives by a great deliverance.');\nINSERT INTO t1(docid,words) VALUES(1045008,'So now it was not you that sent me hither, but God: and he hath made me a father to Pharaoh, and lord of all his house, and a ruler throughout all the land of Egypt.');\nINSERT INTO t1(docid,words) VALUES(1045009,'Haste ye, and go up to my father, and say unto him, Thus saith thy son Joseph, God hath made me lord of all Egypt: come down unto me, tarry not:');\nINSERT INTO t1(docid,words) VALUES(1045010,'And thou shalt dwell in the land of Goshen, and thou shalt be near unto me, thou, and thy children, and thy children''s children, and thy flocks, and thy herds, and all that thou hast:');\nINSERT INTO t1(docid,words) VALUES(1045011,'And there will I nourish thee; for yet there are five years of famine; lest thou, and thy household, and all that thou hast, come to poverty.');\nINSERT INTO t1(docid,words) VALUES(1045012,'And, behold, your eyes see, and the eyes of my brother Benjamin, that it is my mouth that speaketh unto you.');\nINSERT INTO t1(docid,words) VALUES(1045013,'And ye shall tell my father of all my glory in Egypt, and of all that ye have seen; and ye shall haste and bring down my father hither.');\nINSERT INTO t1(docid,words) VALUES(1045014,'And he fell upon his brother Benjamin''s neck, and wept; and Benjamin wept upon his neck.');\nINSERT INTO t1(docid,words) VALUES(1045015,'Moreover he kissed all his brethren, and wept upon them: and after that his brethren talked with him.');\nINSERT INTO t1(docid,words) VALUES(1045016,'And the fame thereof was heard in Pharaoh''s house, saying, Joseph''s brethren are come: and it pleased Pharaoh well, and his servants.');\nINSERT INTO t1(docid,words) VALUES(1045017,'And Pharaoh said unto Joseph, Say unto thy brethren, This do ye; lade your beasts, and go, get you unto the land of Canaan;');\nINSERT INTO t1(docid,words) VALUES(1045018,'And take your father and your households, and come unto me: and I will give you the good of the land of Egypt, and ye shall eat the fat of the land.');\nINSERT INTO t1(docid,words) VALUES(1045019,'Now thou art commanded, this do ye; take you wagons out of the land of Egypt for your little ones, and for your wives, and bring your father, and come.');\nINSERT INTO t1(docid,words) VALUES(1045020,'Also regard not your stuff; for the good of all the land of Egypt is your''s.');\nINSERT INTO t1(docid,words) VALUES(1045021,'And the children of Israel did so: and Joseph gave them wagons, according to the commandment of Pharaoh, and gave them provision for the way.');\nINSERT INTO t1(docid,words) VALUES(1045022,'To all of them he gave each man changes of raiment; but to Benjamin he gave three hundred pieces of silver, and five changes of raiment.');\nINSERT INTO t1(docid,words) VALUES(1045023,'And to his father he sent after this manner; ten asses laden with the good things of Egypt, and ten she asses laden with corn and bread and meat for his father by the way.');\nINSERT INTO t1(docid,words) VALUES(1045024,'So he sent his brethren away, and they departed: and he said unto them, See that ye fall not out by the way.');\nINSERT INTO t1(docid,words) VALUES(1045025,'And they went up out of Egypt, and came into the land of Canaan unto Jacob their father,');\nINSERT INTO t1(docid,words) VALUES(1045026,'And told him, saying, Joseph is yet alive, and he is governor over all the land of Egypt. And Jacob''s heart fainted, for he believed them not.');\nINSERT INTO t1(docid,words) VALUES(1045027,'And they told him all the words of Joseph, which he had said unto them: and when he saw the wagons which Joseph had sent to carry him, the spirit of Jacob their father revived:');\nINSERT INTO t1(docid,words) VALUES(1045028,'And Israel said, It is enough; Joseph my son is yet alive: I will go and see him before I die.');\nINSERT INTO t1(docid,words) VALUES(1046001,'And Israel took his journey with all that he had, and came to Beersheba, and offered sacrifices unto the God of his father Isaac.');\nINSERT INTO t1(docid,words) VALUES(1046002,'And God spake unto Israel in the visions of the night, and said, Jacob, Jacob. And he said, Here am I.');\nINSERT INTO t1(docid,words) VALUES(1046003,'And he said, I am God, the God of thy father: fear not to go down into Egypt; for I will there make of thee a great nation:');\nINSERT INTO t1(docid,words) VALUES(1046004,'I will go down with thee into Egypt; and I will also surely bring thee up again: and Joseph shall put his hand upon thine eyes.');\nINSERT INTO t1(docid,words) VALUES(1046005,'And Jacob rose up from Beersheba: and the sons of Israel carried Jacob their father, and their little ones, and their wives, in the wagons which Pharaoh had sent to carry him.');\nINSERT INTO t1(docid,words) VALUES(1046006,'And they took their cattle, and their goods, which they had gotten in the land of Canaan, and came into Egypt, Jacob, and all his seed with him:');\nINSERT INTO t1(docid,words) VALUES(1046007,'His sons, and his sons'' sons with him, his daughters, and his sons'' daughters, and all his seed brought he with him into Egypt.');\nINSERT INTO t1(docid,words) VALUES(1046008,'And these are the names of the children of Israel, which came into Egypt, Jacob and his sons: Reuben, Jacob''s firstborn.');\nINSERT INTO t1(docid,words) VALUES(1046009,'And the sons of Reuben; Hanoch, and Phallu, and Hezron, and Carmi.');\nINSERT INTO t1(docid,words) VALUES(1046010,'And the sons of Simeon; Jemuel, and Jamin, and Ohad, and Jachin, and Zohar, and Shaul the son of a Canaanitish woman.');\nINSERT INTO t1(docid,words) VALUES(1046011,'And the sons of Levi; Gershon, Kohath, and Merari.');\nINSERT INTO t1(docid,words) VALUES(1046012,'And the sons of Judah; Er, and Onan, and Shelah, and Pharez, and Zarah: but Er and Onan died in the land of Canaan. And the sons of Pharez were Hezron and Hamul.');\nINSERT INTO t1(docid,words) VALUES(1046013,'And the sons of Issachar; Tola, and Phuvah, and Job, and Shimron.');\nINSERT INTO t1(docid,words) VALUES(1046014,'And the sons of Zebulun; Sered, and Elon, and Jahleel.');\nINSERT INTO t1(docid,words) VALUES(1046015,'These be the sons of Leah, which she bare unto Jacob in Padanaram, with his daughter Dinah: all the souls of his sons and his daughters were thirty and three.');\nINSERT INTO t1(docid,words) VALUES(1046016,'And the sons of Gad; Ziphion, and Haggi, Shuni, and Ezbon, Eri, and Arodi, and Areli.');\nINSERT INTO t1(docid,words) VALUES(1046017,'And the sons of Asher; Jimnah, and Ishuah, and Isui, and Beriah, and Serah their sister: and the sons of Beriah; Heber, and Malchiel.');\nINSERT INTO t1(docid,words) VALUES(1046018,'These are the sons of Zilpah, whom Laban gave to Leah his daughter, and these she bare unto Jacob, even sixteen souls.');\nINSERT INTO t1(docid,words) VALUES(1046019,'The sons of Rachel Jacob''s wife; Joseph, and Benjamin.');\nINSERT INTO t1(docid,words) VALUES(1046020,'And unto Joseph in the land of Egypt were born Manasseh and Ephraim, which Asenath the daughter of Potipherah priest of On bare unto him.');\nINSERT INTO t1(docid,words) VALUES(1046021,'And the sons of Benjamin were Belah, and Becher, and Ashbel, Gera, and Naaman, Ehi, and Rosh, Muppim, and Huppim, and Ard.');\nINSERT INTO t1(docid,words) VALUES(1046022,'These are the sons of Rachel, which were born to Jacob: all the souls were fourteen.');\nINSERT INTO t1(docid,words) VALUES(1046023,'And the sons of Dan; Hushim.');\nINSERT INTO t1(docid,words) VALUES(1046024,'And the sons of Naphtali; Jahzeel, and Guni, and Jezer, and Shillem.');\nINSERT INTO t1(docid,words) VALUES(1046025,'These are the sons of Bilhah, which Laban gave unto Rachel his daughter, and she bare these unto Jacob: all the souls were seven.');\nINSERT INTO t1(docid,words) VALUES(1046026,'All the souls that came with Jacob into Egypt, which came out of his loins, besides Jacob''s sons'' wives, all the souls were threescore and six;');\nINSERT INTO t1(docid,words) VALUES(1046027,'And the sons of Joseph, which were born him in Egypt, were two souls: all the souls of the house of Jacob, which came into Egypt, were threescore and ten.');\nINSERT INTO t1(docid,words) VALUES(1046028,'And he sent Judah before him unto Joseph, to direct his face unto Goshen; and they came into the land of Goshen.');\nINSERT INTO t1(docid,words) VALUES(1046029,'And Joseph made ready his chariot, and went up to meet Israel his father, to Goshen, and presented himself unto him; and he fell on his neck, and wept on his neck a good while.');\nINSERT INTO t1(docid,words) VALUES(1046030,'And Israel said unto Joseph, Now let me die, since I have seen thy face, because thou art yet alive.');\nINSERT INTO t1(docid,words) VALUES(1046031,'And Joseph said unto his brethren, and unto his father''s house, I will go up, and shew Pharaoh, and say unto him, My brethren, and my father''s house, which were in the land of Canaan, are come unto me;');\nINSERT INTO t1(docid,words) VALUES(1046032,'And the men are shepherds, for their trade hath been to feed cattle; and they have brought their flocks, and their herds, and all that they have.');\nINSERT INTO t1(docid,words) VALUES(1046033,'And it shall come to pass, when Pharaoh shall call you, and shall say, What is your occupation?');\nINSERT INTO t1(docid,words) VALUES(1046034,'That ye shall say, Thy servants'' trade hath been about cattle from our youth even until now, both we, and also our fathers: that ye may dwell in the land of Goshen; for every shepherd is an abomination unto the Egyptians.');\nINSERT INTO t1(docid,words) VALUES(1047001,'Then Joseph came and told Pharaoh, and said, My father and my brethren, and their flocks, and their herds, and all that they have, are come out of the land of Canaan; and, behold, they are in the land of Goshen.');\nINSERT INTO t1(docid,words) VALUES(1047002,'And he took some of his brethren, even five men, and presented them unto Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1047003,'And Pharaoh said unto his brethren, What is your occupation? And they said unto Pharaoh, Thy servants are shepherds, both we, and also our fathers.');\nINSERT INTO t1(docid,words) VALUES(1047004,'They said morever unto Pharaoh, For to sojourn in the land are we come; for thy servants have no pasture for their flocks; for the famine is sore in the land of Canaan: now therefore, we pray thee, let thy servants dwell in the land of Goshen.');\nINSERT INTO t1(docid,words) VALUES(1047005,'And Pharaoh spake unto Joseph, saying, Thy father and thy brethren are come unto thee:');\nINSERT INTO t1(docid,words) VALUES(1047006,'The land of Egypt is before thee; in the best of the land make thy father and brethren to dwell; in the land of Goshen let them dwell: and if thou knowest any men of activity among them, then make them rulers over my cattle.');\nINSERT INTO t1(docid,words) VALUES(1047007,'And Joseph brought in Jacob his father, and set him before Pharaoh: and Jacob blessed Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1047008,'And Pharaoh said unto Jacob, How old art thou?');\nINSERT INTO t1(docid,words) VALUES(1047009,'And Jacob said unto Pharaoh, The days of the years of my pilgrimage are an hundred and thirty years: few and evil have the days of the years of my life been, and have not attained unto the days of the years of the life of my fathers in the days of their pilgrimage.');\nINSERT INTO t1(docid,words) VALUES(1047010,'And Jacob blessed Pharaoh, and went out from before Pharaoh.');\nINSERT INTO t1(docid,words) VALUES(1047011,'And Joseph placed his father and his brethren, and gave them a possession in the land of Egypt, in the best of the land, in the land of Rameses, as Pharaoh had commanded.');\nINSERT INTO t1(docid,words) VALUES(1047012,'And Joseph nourished his father, and his brethren, and all his father''s household, with bread, according to their families.');\nINSERT INTO t1(docid,words) VALUES(1047013,'And there was no bread in all the land; for the famine was very sore, so that the land of Egypt and all the land of Canaan fainted by reason of the famine.');\nINSERT INTO t1(docid,words) VALUES(1047014,'And Joseph gathered up all the money that was found in the land of Egypt, and in the land of Canaan, for the corn which they bought: and Joseph brought the money into Pharaoh''s house.');\nINSERT INTO t1(docid,words) VALUES(1047015,'And when money failed in the land of Egypt, and in the land of Canaan, all the Egyptians came unto Joseph, and said, Give us bread: for why should we die in thy presence? for the money faileth.');\nINSERT INTO t1(docid,words) VALUES(1047016,'And Joseph said, Give your cattle; and I will give you for your cattle, if money fail.');\nINSERT INTO t1(docid,words) VALUES(1047017,'And they brought their cattle unto Joseph: and Joseph gave them bread in exchange for horses, and for the flocks, and for the cattle of the herds, and for the asses: and he fed them with bread for all their cattle for that year.');\nINSERT INTO t1(docid,words) VALUES(1047018,'When that year was ended, they came unto him the second year, and said unto him, We will not hide it from my lord, how that our money is spent; my lord also hath our herds of cattle; there is not ought left in the sight of my lord, but our bodies, and our lands:');\nINSERT INTO t1(docid,words) VALUES(1047019,'Wherefore shall we die before thine eyes, both we and our land? buy us and our land for bread, and we and our land will be servants unto Pharaoh: and give us seed, that we may live, and not die, that the land be not desolate.');\nINSERT INTO t1(docid,words) VALUES(1047020,'And Joseph bought all the land of Egypt for Pharaoh; for the Egyptians sold every man his field, because the famine prevailed over them: so the land became Pharaoh''s.');\nINSERT INTO t1(docid,words) VALUES(1047021,'And as for the people, he removed them to cities from one end of the borders of Egypt even to the other end thereof.');\nINSERT INTO t1(docid,words) VALUES(1047022,'Only the land of the priests bought he not; for the priests had a portion assigned them of Pharaoh, and did eat their portion which Pharaoh gave them: wherefore they sold not their lands.');\nINSERT INTO t1(docid,words) VALUES(1047023,'Then Joseph said unto the people, Behold, I have bought you this day and your land for Pharaoh: lo, here is seed for you, and ye shall sow the land.');\nINSERT INTO t1(docid,words) VALUES(1047024,'And it shall come to pass in the increase, that ye shall give the fifth part unto Pharaoh, and four parts shall be your own, for seed of the field, and for your food, and for them of your households, and for food for your little ones.');\nINSERT INTO t1(docid,words) VALUES(1047025,'And they said, Thou hast saved our lives: let us find grace in the sight of my lord, and we will be Pharaoh''s servants.');\nINSERT INTO t1(docid,words) VALUES(1047026,'And Joseph made it a law over the land of Egypt unto this day, that Pharaoh should have the fifth part, except the land of the priests only, which became not Pharaoh''s.');\nINSERT INTO t1(docid,words) VALUES(1047027,'And Israel dwelt in the land of Egypt, in the country of Goshen; and they had possessions therein, and grew, and multiplied exceedingly.');\nINSERT INTO t1(docid,words) VALUES(1047028,'And Jacob lived in the land of Egypt seventeen years: so the whole age of Jacob was an hundred forty and seven years.');\nINSERT INTO t1(docid,words) VALUES(1047029,'And the time drew nigh that Israel must die: and he called his son Joseph, and said unto him, If now I have found grace in thy sight, put, I pray thee, thy hand under my thigh, and deal kindly and truly with me; bury me not, I pray thee, in Egypt:');\nINSERT INTO t1(docid,words) VALUES(1047030,'But I will lie with my fathers, and thou shalt carry me out of Egypt, and bury me in their buryingplace. And he said, I will do as thou hast said.');\nINSERT INTO t1(docid,words) VALUES(1047031,'And he said, Swear unto me. And he sware unto him. And Israel bowed himself upon the bed''s head.');\nINSERT INTO t1(docid,words) VALUES(1048001,'And it came to pass after these things, that one told Joseph, Behold, thy father is sick: and he took with him his two sons, Manasseh and Ephraim.');\nINSERT INTO t1(docid,words) VALUES(1048002,'And one told Jacob, and said, Behold, thy son Joseph cometh unto thee: and Israel strengthened himself, and sat upon the bed.');\nINSERT INTO t1(docid,words) VALUES(1048003,'And Jacob said unto Joseph, God Almighty appeared unto me at Luz in the land of Canaan, and blessed me,');\nINSERT INTO t1(docid,words) VALUES(1048004,'And said unto me, Behold, I will make thee fruitful, and multiply thee, and I will make of thee a multitude of people; and will give this land to thy seed after thee for an everlasting possession.');\nINSERT INTO t1(docid,words) VALUES(1048005,'And now thy two sons, Ephraim and Manasseh, which were born unto thee in the land of Egypt before I came unto thee into Egypt, are mine; as Reuben and Simeon, they shall be mine.');\nINSERT INTO t1(docid,words) VALUES(1048006,'And thy issue, which thou begettest after them, shall be thine, and shall be called after the name of their brethren in their inheritance.');\nINSERT INTO t1(docid,words) VALUES(1048007,'And as for me, when I came from Padan, Rachel died by me in the land of Canaan in the way, when yet there was but a little way to come unto Ephrath: and I buried her there in the way of Ephrath; the same is Bethlehem.');\nINSERT INTO t1(docid,words) VALUES(1048008,'And Israel beheld Joseph''s sons, and said, Who are these?');\nINSERT INTO t1(docid,words) VALUES(1048009,'And Joseph said unto his father, They are my sons, whom God hath given me in this place. And he said, Bring them, I pray thee, unto me, and I will bless them.');\nINSERT INTO t1(docid,words) VALUES(1048010,'Now the eyes of Israel were dim for age, so that he could not see. And he brought them near unto him; and he kissed them, and embraced them.');\nINSERT INTO t1(docid,words) VALUES(1048011,'And Israel said unto Joseph, I had not thought to see thy face: and, lo, God hath shewed me also thy seed.');\nINSERT INTO t1(docid,words) VALUES(1048012,'And Joseph brought them out from between his knees, and he bowed himself with his face to the earth.');\nINSERT INTO t1(docid,words) VALUES(1048013,'And Joseph took them both, Ephraim in his right hand toward Israel''s left hand, and Manasseh in his left hand toward Israel''s right hand, and brought them near unto him.');\nINSERT INTO t1(docid,words) VALUES(1048014,'And Israel stretched out his right hand, and laid it upon Ephraim''s head, who was the younger, and his left hand upon Manasseh''s head, guiding his hands wittingly; for Manasseh was the firstborn.');\nINSERT INTO t1(docid,words) VALUES(1048015,'And he blessed Joseph, and said, God, before whom my fathers Abraham and Isaac did walk, the God which fed me all my life long unto this day,');\nINSERT INTO t1(docid,words) VALUES(1048016,'The Angel which redeemed me from all evil, bless the lads; and let my name be named on them, and the name of my fathers Abraham and Isaac; and let them grow into a multitude in the midst of the earth.');\nINSERT INTO t1(docid,words) VALUES(1048017,'And when Joseph saw that his father laid his right hand upon the head of Ephraim, it displeased him: and he held up his father''s hand, to remove it from Ephraim''s head unto Manasseh''s head.');\nINSERT INTO t1(docid,words) VALUES(1048018,'And Joseph said unto his father, Not so, my father: for this is the firstborn; put thy right hand upon his head.');\nINSERT INTO t1(docid,words) VALUES(1048019,'And his father refused, and said, I know it, my son, I know it: he also shall become a people, and he also shall be great: but truly his younger brother shall be greater than he, and his seed shall become a multitude of nations.');\nINSERT INTO t1(docid,words) VALUES(1048020,'And he blessed them that day, saying, In thee shall Israel bless, saying, God make thee as Ephraim and as Manasseh: and he set Ephraim before Manasseh.');\nINSERT INTO t1(docid,words) VALUES(1048021,'And Israel said unto Joseph, Behold, I die: but God shall be with you, and bring you again unto the land of your fathers.');\nINSERT INTO t1(docid,words) VALUES(1048022,'Moreover I have given to thee one portion above thy brethren, which I took out of the hand of the Amorite with my sword and with my bow.');\nINSERT INTO t1(docid,words) VALUES(1049001,'And Jacob called unto his sons, and said, Gather yourselves together, that I may tell you that which shall befall you in the last days.');\nINSERT INTO t1(docid,words) VALUES(1049002,'Gather yourselves together, and hear, ye sons of Jacob; and hearken unto Israel your father.');\nINSERT INTO t1(docid,words) VALUES(1049003,'Reuben, thou art my firstborn, my might, and the beginning of my strength, the excellency of dignity, and the excellency of power:');\nINSERT INTO t1(docid,words) VALUES(1049004,'Unstable as water, thou shalt not excel; because thou wentest up to thy father''s bed; then defiledst thou it: he went up to my couch.');\nINSERT INTO t1(docid,words) VALUES(1049005,'Simeon and Levi are brethren; instruments of cruelty are in their habitations.');\nINSERT INTO t1(docid,words) VALUES(1049006,'O my soul, come not thou into their secret; unto their assembly, mine honour, be not thou united: for in their anger they slew a man, and in their selfwill they digged down a wall.');\nINSERT INTO t1(docid,words) VALUES(1049007,'Cursed be their anger, for it was fierce; and their wrath, for it was cruel: I will divide them in Jacob, and scatter them in Israel.');\nINSERT INTO t1(docid,words) VALUES(1049008,'Judah, thou art he whom thy brethren shall praise: thy hand shall be in the neck of thine enemies; thy father''s children shall bow down before thee.');\nINSERT INTO t1(docid,words) VALUES(1049009,'Judah is a lion''s whelp: from the prey, my son, thou art gone up: he stooped down, he couched as a lion, and as an old lion; who shall rouse him up?');\nINSERT INTO t1(docid,words) VALUES(1049010,'The sceptre shall not depart from Judah, nor a lawgiver from between his feet, until Shiloh come; and unto him shall the gathering of the people be.');\nINSERT INTO t1(docid,words) VALUES(1049011,'Binding his foal unto the vine, and his ass''s colt unto the choice vine; he washed his garments in wine, and his clothes in the blood of grapes:');\nINSERT INTO t1(docid,words) VALUES(1049012,'His eyes shall be red with wine, and his teeth white with milk.');\nINSERT INTO t1(docid,words) VALUES(1049013,'Zebulun shall dwell at the haven of the sea; and he shall be for an haven of ships; and his border shall be unto Zidon.');\nINSERT INTO t1(docid,words) VALUES(1049014,'Issachar is a strong ass couching down between two burdens:');\nINSERT INTO t1(docid,words) VALUES(1049015,'And he saw that rest was good, and the land that it was pleasant; and bowed his shoulder to bear, and became a servant unto tribute.');\nINSERT INTO t1(docid,words) VALUES(1049016,'Dan shall judge his people, as one of the tribes of Israel.');\nINSERT INTO t1(docid,words) VALUES(1049017,'Dan shall be a serpent by the way, an adder in the path, that biteth the horse heels, so that his rider shall fall backward.');\nINSERT INTO t1(docid,words) VALUES(1049018,'I have waited for thy salvation, O LORD.');\nINSERT INTO t1(docid,words) VALUES(1049019,'Gad, a troop shall overcome him: but he shall overcome at the last.');\nINSERT INTO t1(docid,words) VALUES(1049020,'Out of Asher his bread shall be fat, and he shall yield royal dainties.');\nINSERT INTO t1(docid,words) VALUES(1049021,'Naphtali is a hind let loose: he giveth goodly words.');\nINSERT INTO t1(docid,words) VALUES(1049022,'Joseph is a fruitful bough, even a fruitful bough by a well; whose branches run over the wall:');\nINSERT INTO t1(docid,words) VALUES(1049023,'The archers have sorely grieved him, and shot at him, and hated him:');\nINSERT INTO t1(docid,words) VALUES(1049024,'But his bow abode in strength, and the arms of his hands were made strong by the hands of the mighty God of Jacob; (from thence is the shepherd, the stone of Israel:)');\nINSERT INTO t1(docid,words) VALUES(1049025,'Even by the God of thy father, who shall help thee; and by the Almighty, who shall bless thee with blessings of heaven above, blessings of the deep that lieth under, blessings of the breasts, and of the womb:');\nINSERT INTO t1(docid,words) VALUES(1049026,'The blessings of thy father have prevailed above the blessings of my progenitors unto the utmost bound of the everlasting hills: they shall be on the head of Joseph, and on the crown of the head of him that was separate from his brethren.');\nINSERT INTO t1(docid,words) VALUES(1049027,'Benjamin shall ravin as a wolf: in the morning he shall devour the prey, and at night he shall divide the spoil.');\nINSERT INTO t1(docid,words) VALUES(1049028,'All these are the twelve tribes of Israel: and this is it that their father spake unto them, and blessed them; every one according to his blessing he blessed them.');\nINSERT INTO t1(docid,words) VALUES(1049029,'And he charged them, and said unto them, I am to be gathered unto my people: bury me with my fathers in the cave that is in the field of Ephron the Hittite,');\nINSERT INTO t1(docid,words) VALUES(1049030,'In the cave that is in the field of Machpelah, which is before Mamre, in the land of Canaan, which Abraham bought with the field of Ephron the Hittite for a possession of a buryingplace.');\nINSERT INTO t1(docid,words) VALUES(1049031,'There they buried Abraham and Sarah his wife; there they buried Isaac and Rebekah his wife; and there I buried Leah.');\nINSERT INTO t1(docid,words) VALUES(1049032,'The purchase of the field and of the cave that is therein was from the children of Heth.');\nINSERT INTO t1(docid,words) VALUES(1049033,'And when Jacob had made an end of commanding his sons, he gathered up his feet into the bed, and yielded up the ghost, and was gathered unto his people.');\nINSERT INTO t1(docid,words) VALUES(1050001,'And Joseph fell upon his father''s face, and wept upon him, and kissed him.');\nINSERT INTO t1(docid,words) VALUES(1050002,'And Joseph commanded his servants the physicians to embalm his father: and the physicians embalmed Israel.');\nINSERT INTO t1(docid,words) VALUES(1050003,'And forty days were fulfilled for him; for so are fulfilled the days of those which are embalmed: and the Egyptians mourned for him threescore and ten days.');\nINSERT INTO t1(docid,words) VALUES(1050004,'And when the days of his mourning were past, Joseph spake unto the house of Pharaoh, saying, If now I have found grace in your eyes, speak, I pray you, in the ears of Pharaoh, saying,');\nINSERT INTO t1(docid,words) VALUES(1050005,'My father made me swear, saying, Lo, I die: in my grave which I have digged for me in the land of Canaan, there shalt thou bury me. Now therefore let me go up, I pray thee, and bury my father, and I will come again.');\nINSERT INTO t1(docid,words) VALUES(1050006,'And Pharaoh said, Go up, and bury thy father, according as he made thee swear.');\nINSERT INTO t1(docid,words) VALUES(1050007,'And Joseph went up to bury his father: and with him went up all the servants of Pharaoh, the elders of his house, and all the elders of the land of Egypt,');\nINSERT INTO t1(docid,words) VALUES(1050008,'And all the house of Joseph, and his brethren, and his father''s house: only their little ones, and their flocks, and their herds, they left in the land of Goshen.');\nINSERT INTO t1(docid,words) VALUES(1050009,'And there went up with him both chariots and horsemen: and it was a very great company.');\nINSERT INTO t1(docid,words) VALUES(1050010,'And they came to the threshingfloor of Atad, which is beyond Jordan, and there they mourned with a great and very sore lamentation: and he made a mourning for his father seven days.');\nINSERT INTO t1(docid,words) VALUES(1050011,'And when the inhabitants of the land, the Canaanites, saw the mourning in the floor of Atad, they said, This is a grievous mourning to the Egyptians: wherefore the name of it was called Abelmizraim, which is beyond Jordan.');\nINSERT INTO t1(docid,words) VALUES(1050012,'And his sons did unto him according as he commanded them:');\nINSERT INTO t1(docid,words) VALUES(1050013,'For his sons carried him into the land of Canaan, and buried him in the cave of the field of Machpelah, which Abraham bought with the field for a possession of a buryingplace of Ephron the Hittite, before Mamre.');\nINSERT INTO t1(docid,words) VALUES(1050014,'And Joseph returned into Egypt, he, and his brethren, and all that went up with him to bury his father, after he had buried his father.');\nINSERT INTO t1(docid,words) VALUES(1050015,'And when Joseph''s brethren saw that their father was dead, they said, Joseph will peradventure hate us, and will certainly requite us all the evil which we did unto him.');\nINSERT INTO t1(docid,words) VALUES(1050016,'And they sent a messenger unto Joseph, saying, Thy father did command before he died, saying,');\nINSERT INTO t1(docid,words) VALUES(1050017,'So shall ye say unto Joseph, Forgive, I pray thee now, the trespass of thy brethren, and their sin; for they did unto thee evil: and now, we pray thee, forgive the trespass of the servants of the God of thy father. And Joseph wept when they spake unto him.');\nINSERT INTO t1(docid,words) VALUES(1050018,'And his brethren also went and fell down before his face; and they said, Behold, we be thy servants.');\nINSERT INTO t1(docid,words) VALUES(1050019,'And Joseph said unto them, Fear not: for am I in the place of God?');\nINSERT INTO t1(docid,words) VALUES(1050020,'But as for you, ye thought evil against me; but God meant it unto good, to bring to pass, as it is this day, to save much people alive.');\nINSERT INTO t1(docid,words) VALUES(1050021,'Now therefore fear ye not: I will nourish you, and your little ones. And he comforted them, and spake kindly unto them.');\nINSERT INTO t1(docid,words) VALUES(1050022,'And Joseph dwelt in Egypt, he, and his father''s house: and Joseph lived an hundred and ten years.');\nINSERT INTO t1(docid,words) VALUES(1050023,'And Joseph saw Ephraim''s children of the third generation: the children also of Machir the son of Manasseh were brought up upon Joseph''s knees.');\nINSERT INTO t1(docid,words) VALUES(1050024,'And Joseph said unto his brethren, I die: and God will surely visit you, and bring you out of this land unto the land which he sware to Abraham, to Isaac, and to Jacob.');\nINSERT INTO t1(docid,words) VALUES(1050025,'And Joseph took an oath of the children of Israel, saying, God will surely visit you, and ye shall carry up my bones from hence.');\nINSERT INTO t1(docid,words) VALUES(1050026,'So Joseph died, being an hundred and ten years old: and they embalmed him, and he was put in a coffin in Egypt.');\nCOMMIT;\n}\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/having.test",
    "content": "# 2017 April 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the HAVING->WHERE optimization.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix having\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t2(c, d);\n\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(2, 2);\n  INSERT INTO t1 VALUES(1, 3);\n  INSERT INTO t1 VALUES(2, 4);\n  INSERT INTO t1 VALUES(1, 5);\n  INSERT INTO t1 VALUES(2, 6);\n} {}\n\nforeach {tn sql res} {\n  1 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2\" {2 12}\n  2 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2 AND sum(b)>10\" {2 12}\n  3 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING sum(b)>12\" {}\n} {\n  do_execsql_test 1.$tn $sql $res\n}\n\n# Run an EXPLAIN command for both SQL statements. Return true if \n# the outputs are identical, or false otherwise.\n#\nproc compare_vdbe {sql1 sql2} {\n  set r1 [list]\n  set r2 [list]\n  db eval \"explain $sql1\" { lappend r1 $opcode $p1 $p2 $p3 $p4 $p5}\n  db eval \"explain $sql2\" { lappend r2 $opcode $p1 $p2 $p3 $p4 $p5}\n  return [expr {$r1==$r2}]\n}\n\nproc do_compare_vdbe_test {tn sql1 sql2 res} {\n  uplevel [list do_test $tn [list compare_vdbe $sql1 $sql2] $res]\n}\n\n#-------------------------------------------------------------------------\n# Test that various statements that are eligible for the optimization\n# produce the same VDBE code as optimizing by hand does.\n#\nforeach {tn sql1 sql2} {\n  1 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING a=2\"\n    \"SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a\"\n\n  2 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING sum(b)>5 AND a=2\"\n    \"SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a HAVING sum(b)>5\"\n\n  3 \"SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING a=2\"\n    \"SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a COLLATE binary\"\n\n  5 \"SELECT a, sum(b) FROM t1 GROUP BY a COLLATE binary HAVING 0\"\n    \"SELECT a, sum(b) FROM t1 WHERE 0 GROUP BY a COLLATE binary\"\n\n  6 \"SELECT count(*) FROM t1,t2 WHERE a=c GROUP BY b, d HAVING b=d\"\n    \"SELECT count(*) FROM t1,t2 WHERE a=c AND b=d GROUP BY b, d\"\n\n  7 {\n      SELECT count(*) FROM t1,t2 WHERE a=c GROUP BY b, d \n      HAVING b=d COLLATE nocase\n    } {\n      SELECT count(*) FROM t1,t2 WHERE a=c AND b=d COLLATE nocase \n      GROUP BY b, d\n    }\n\n  8 \"SELECT a, sum(b) FROM t1 GROUP BY a||b HAVING substr(a||b, 1, 1)='a'\"\n    \"SELECT a, sum(b) FROM t1 WHERE substr(a||b, 1, 1)='a' GROUP BY a||b\"\n} {\n  do_compare_vdbe_test 2.$tn $sql1 $sql2 1\n}\n\n# The (4) test in the above set used to generate identical bytecode, but\n# that is no longer the case.  The byte code is equivalent, though.\n#\ndo_execsql_test 2.4a {\n  SELECT x,y FROM (\n    SELECT a AS x, sum(b) AS y FROM t1 \n    GROUP BY a\n  ) WHERE x BETWEEN 2 AND 9999\n} {2 12}\ndo_execsql_test 2.4b {\n  SELECT x,y FROM (\n    SELECT a AS x, sum(b) AS y FROM t1 \n    WHERE x BETWEEN 2 AND 9999 \n    GROUP BY a\n  )\n} {2 12}\n\n\n#-------------------------------------------------------------------------\n# 1: Test that the optimization is only applied if the GROUP BY term\n#    uses BINARY collation.\n#\n# 2: Not applied if there is a non-deterministic function in the HAVING\n#    term.\n#\nforeach {tn sql1 sql2} {\n  1 \"SELECT a, sum(b) FROM t1 GROUP BY a COLLATE nocase HAVING a=2\"\n    \"SELECT a, sum(b) FROM t1 WHERE a=2 GROUP BY a COLLATE nocase\"\n\n  2 \"SELECT a, sum(b) FROM t1 GROUP BY a HAVING randomblob(a)<X'88'\"\n    \"SELECT a, sum(b) FROM t1 WHERE randomblob(a)<X'88' GROUP BY a\"\n} {\n  do_compare_vdbe_test 3.$tn $sql1 $sql2 0\n}\n\n\n#-------------------------------------------------------------------------\n# Test that non-deterministic functions disqualify a term from being\n# moved from the HAVING to WHERE clause.\n#\ndo_execsql_test 4.1 {\n  CREATE TABLE t3(a, b);\n  INSERT INTO t3 VALUES(1, 1);\n  INSERT INTO t3 VALUES(1, 2);\n  INSERT INTO t3 VALUES(1, 3);\n  INSERT INTO t3 VALUES(2, 1);\n  INSERT INTO t3 VALUES(2, 2);\n  INSERT INTO t3 VALUES(2, 3);\n}\n\nproc nondeter {args} {\n  incr ::nondeter_ret\n  expr {$::nondeter_ret % 2}\n}\ndb func nondeter nondeter\n\nset ::nondeter_ret 0\ndo_execsql_test 4.2 {\n  SELECT a, sum(b) FROM t3 GROUP BY a HAVING nondeter(a)\n} {1 6}\n\n# If the term where moved, the query above would return the same\n# result as the following. But it does not.\n#\nset ::nondeter_ret 0\ndo_execsql_test 4.3 {\n  SELECT a, sum(b) FROM t3 WHERE nondeter(a) GROUP BY a\n} {1 4 2 2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/hexlit.test",
    "content": "# 2014-07-23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for hexadecimal literals\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc hexlit1 {tnum val ans} {\n  do_execsql_test hexlit-$tnum \"SELECT $val\" $ans\n}\n\nhexlit1 100 0x0 0\nhexlit1 101 0x0000000000000000000000000000000000000000000001 1\nhexlit1 102 0x2 2\nhexlit1 103 0x4 4\nhexlit1 104 0x8 8\nhexlit1 105 0x00000000000000000000000000000000000000000000010 16\nhexlit1 103 0x20 32\nhexlit1 106 0x40 64\nhexlit1 107 0x80 128\nhexlit1 108 0x100 256\nhexlit1 109 0x200 512\nhexlit1 110 0X400 1024\nhexlit1 111 0x800 2048\nhexlit1 112 0x1000 4096\nhexlit1 113 0x2000 8192\nhexlit1 114 0x4000 16384\nhexlit1 115 0x8000 32768\nhexlit1 116 0x10000 65536\nhexlit1 117 0x20000 131072\nhexlit1 118 0x40000 262144\nhexlit1 119 0x80000 524288\nhexlit1 120 0x100000 1048576\nhexlit1 121 0x200000 2097152\nhexlit1 122 0x400000 4194304\nhexlit1 123 0x800000 8388608\nhexlit1 124 0x1000000 16777216\nhexlit1 125 0x2000000 33554432\nhexlit1 126 0x4000000 67108864\nhexlit1 127 0x8000000 134217728\nhexlit1 128 0x10000000 268435456\nhexlit1 129 0x20000000 536870912\nhexlit1 130 0x40000000 1073741824\nhexlit1 131 0x80000000 2147483648\nhexlit1 132 0x100000000 4294967296\nhexlit1 133 0x200000000 8589934592\nhexlit1 134 0x400000000 17179869184\nhexlit1 135 0x800000000 34359738368\nhexlit1 136 0x1000000000 68719476736\nhexlit1 137 0x2000000000 137438953472\nhexlit1 138 0x4000000000 274877906944\nhexlit1 139 0x8000000000 549755813888\nhexlit1 140 0x10000000000 1099511627776\nhexlit1 141 0x20000000000 2199023255552\nhexlit1 142 0x40000000000 4398046511104\nhexlit1 143 0x80000000000 8796093022208\nhexlit1 144 0x100000000000 17592186044416\nhexlit1 145 0x200000000000 35184372088832\nhexlit1 146 0x400000000000 70368744177664\nhexlit1 147 0x800000000000 140737488355328\nhexlit1 148 0x1000000000000 281474976710656\nhexlit1 149 0x2000000000000 562949953421312\nhexlit1 150 0x4000000000000 1125899906842624\nhexlit1 151 0x8000000000000 2251799813685248\nhexlit1 152 0x10000000000000 4503599627370496\nhexlit1 153 0x20000000000000 9007199254740992\nhexlit1 154 0x40000000000000 18014398509481984\nhexlit1 155 0x80000000000000 36028797018963968\nhexlit1 156 0x100000000000000 72057594037927936\nhexlit1 157 0x200000000000000 144115188075855872\nhexlit1 158 0x400000000000000 288230376151711744\nhexlit1 159 0x800000000000000 576460752303423488\nhexlit1 160 0X1000000000000000 1152921504606846976\nhexlit1 161 0x2000000000000000 2305843009213693952\nhexlit1 162 0X4000000000000000 4611686018427387904\nhexlit1 163 0x8000000000000000 -9223372036854775808\nhexlit1 164 0XFFFFFFFFFFFFFFFF -1\n\nfor {set n 1} {$n < 0x10} {incr n} {\n  hexlit1 200.$n.1 0X[format %03X $n] $n\n  hexlit1 200.$n.2 0x[format %03X $n] $n\n  hexlit1 200.$n.3 0X[format %03x $n] $n\n  hexlit1 200.$n.4 0x[format %03x $n] $n\n}\n\n# String literals that look like hex do not get cast or coerced.\n#\ndo_execsql_test hexlit-300 {\n  CREATE TABLE t1(x INT, y REAL);\n  INSERT INTO t1 VALUES('1234','4567'),('0x1234','0x4567');\n  SELECT typeof(x), x, typeof(y), y, '#' FROM t1 ORDER BY rowid;\n} {integer 1234 real 4567.0 # text 0x1234 text 0x4567 #}\ndo_execsql_test hexlit-301 {\n  SELECT CAST('0x1234' AS INTEGER);\n} {0}\n\n# Oversized hex literals are rejected\n#\ndo_catchsql_test hexlist-400 {\n  SELECT 0x10000000000000000;\n} {1 {hex literal too big: 0x10000000000000000}}\ndo_catchsql_test hexlist-401 {\n  SELECT DISTINCT 0x10000000000000000;\n} {1 {hex literal too big: 0x10000000000000000}}\ndo_catchsql_test hexlist-402 {\n  SELECT DISTINCT -0x08000000000000000;\n} {1 {hex literal too big: -0x08000000000000000}}\ndo_catchsql_test hexlist-410 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1+0x10000000000000000);\n} {1 {hex literal too big: 0x10000000000000000}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/hidden.test",
    "content": "# 2015 November 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the __hidden__ hack.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix hidden\n\nifcapable !hiddencolumns {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(__hidden__a, b);\n  INSERT INTO t1 VALUES('1');\n  INSERT INTO t1(__hidden__a, b) VALUES('x', 'y');\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1;\n} {1 y}\n\ndo_execsql_test 1.3 {\n  SELECT __hidden__a, * FROM t1;\n} {{} 1 x y}\n\nforeach {tn view} {\n  1 { CREATE VIEW v1(a, b, __hidden__c) AS SELECT a, b, c FROM x1 }\n  2 { CREATE VIEW v1 AS SELECT a, b, c AS __hidden__c FROM x1 }\n} {\n  do_execsql_test 2.$tn.1 {\n    DROP TABLE IF EXISTS x1;\n    CREATE TABLE x1(a, b, c);\n    INSERT INTO x1 VALUES(1, 2, 3);\n  }\n\n  catchsql { DROP VIEW v1 }\n  execsql $view\n\n  do_execsql_test 2.$tn.2 {\n    SELECT a, b, __hidden__c FROM v1;\n  } {1 2 3}\n  \n  do_execsql_test 2.$tn.3 {\n    SELECT * FROM v1;\n  } {1 2}\n  \n  do_execsql_test 2.$tn.4 {\n    CREATE TRIGGER tr1 INSTEAD OF INSERT ON v1 BEGIN\n      INSERT INTO x1 VALUES(new.a, new.b, new.__hidden__c);\n    END;\n  \n    INSERT INTO v1 VALUES(4, 5);\n    SELECT * FROM x1;\n  } {1 2 3 4 5 {}}\n  \n  do_execsql_test 2.$tn.5 {\n    INSERT INTO v1(a, b, __hidden__c) VALUES(7, 8, 9);\n    SELECT * FROM x1;\n  } {1 2 3 4 5 {} 7 8 9}\n}\n\n#-------------------------------------------------------------------------\n# Test INSERT INTO ... SELECT ... statements that write to tables with\n# hidden columns.\n#\ndo_execsql_test 3.1 {\n  CREATE TABLE t4(a, __hidden__b, c);\n  INSERT INTO t4 SELECT 1, 2;\n  SELECT a, __hidden__b, c FROM t4;\n} {1 {} 2}\n\ndo_execsql_test 3.2.1 {\n  CREATE TABLE t5(__hidden__a, b, c);\n  CREATE TABLE t6(__hidden__a, b, c);\n  INSERT INTO t6(__hidden__a, b, c) VALUES(1, 2, 3);\n  INSERT INTO t6(__hidden__a, b, c) VALUES(4, 5, 6);\n  INSERT INTO t6(__hidden__a, b, c) VALUES(7, 8, 9);\n}\n\ndo_execsql_test 3.2.2 {\n  INSERT INTO t5 SELECT * FROM t6;\n  SELECT * FROM t5;\n} {2 3   5 6   8 9}\n\ndo_execsql_test 3.2.3 {\n  SELECT __hidden__a FROM t5;\n} {{} {} {}}\n\n\ndo_execsql_test 3.3.1 {\n  CREATE TABLE t5a(a, b, __hidden__c);\n  CREATE TABLE t6a(a, b, __hidden__c);\n  INSERT INTO t6a(a, b, __hidden__c) VALUES(1, 2, 3);\n  INSERT INTO t6a(a, b, __hidden__c) VALUES(4, 5, 6);\n  INSERT INTO t6a(a, b, __hidden__c) VALUES(7, 8, 9);\n}\n\ndo_execsql_test 3.3.2 {\n  INSERT INTO t5a SELECT * FROM t6a;\n  SELECT * FROM t5a;\n} {1 2   4 5   7 8}\n\ndo_execsql_test 3.3.3 {\n  SELECT __hidden__c FROM t5a;\n} {{} {} {}}\n\ndo_execsql_test 3.4.1 {\n  CREATE TABLE t5b(a, __hidden__b, c);\n  CREATE TABLE t6b(a, b, __hidden__c);\n  INSERT INTO t6b(a, b, __hidden__c) VALUES(1, 2, 3);\n  INSERT INTO t6b(a, b, __hidden__c) VALUES(4, 5, 6);\n  INSERT INTO t6b(a, b, __hidden__c) VALUES(7, 8, 9);\n}\n\ndo_execsql_test 3.4.2 {\n  INSERT INTO t5b SELECT * FROM t6b;\n  SELECT * FROM t5b;\n} {1 2   4 5   7 8}\n\ndo_execsql_test 3.4.3 {\n  SELECT __hidden__b FROM t5b;\n} {{} {} {}}\n\n#-------------------------------------------------------------------------\n# Test VACUUM\n#\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE t1(a, __hidden__b, c UNIQUE);\n  INSERT INTO t1(a, __hidden__b, c) VALUES(1, 2, 3);\n  INSERT INTO t1(a, __hidden__b, c) VALUES(4, 5, 6);\n  INSERT INTO t1(a, __hidden__b, c) VALUES(7, 8, 9);\n  DELETE FROM t1 WHERE __hidden__b = 5;\n  SELECT rowid, a, __hidden__b, c FROM t1;\n} {1 1 2 3   3 7 8 9}\ndo_execsql_test 4.2 {\n  VACUUM;\n  SELECT rowid, a, __hidden__b, c FROM t1;\n} {1 1 2 3   3 7 8 9}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/hook.test",
    "content": "# 2004 Jan 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for TCL interface to the\n# SQLite library. \n#\n# The focus of the tests in this file is the  following interface:\n#\n#      sqlite_commit_hook    (tests hook-1..hook-3 inclusive)\n#      sqlite_update_hook    (tests hook-4-*)\n#      sqlite_rollback_hook  (tests hook-5.*)\n#\n# $Id: hook.test,v 1.15 2009/04/07 14:14:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix hook\n\ndo_test hook-1.2 {\n  db commit_hook\n} {}\n\n\ndo_test hook-3.1 {\n  set commit_cnt 0\n  proc commit_hook {} {\n    incr ::commit_cnt\n    return 0\n  }\n  db commit_hook ::commit_hook\n  db commit_hook\n} {::commit_hook}\ndo_test hook-3.2 {\n  set commit_cnt\n} {0}\ndo_test hook-3.3 {\n  execsql {\n    CREATE TABLE t2(a,b);\n  }\n  set commit_cnt\n} {1}\ndo_test hook-3.4 {\n  execsql {\n    INSERT INTO t2 VALUES(1,2);\n    INSERT INTO t2 SELECT a+1, b+1 FROM t2;\n    INSERT INTO t2 SELECT a+2, b+2 FROM t2;\n  }\n  set commit_cnt\n} {4}\ndo_test hook-3.5 {\n  set commit_cnt {}\n  proc commit_hook {} {\n    set ::commit_cnt [execsql {SELECT * FROM t2}]\n    return 0\n  }\n  execsql {\n    INSERT INTO t2 VALUES(5,6);\n  }\n  set commit_cnt\n} {1 2 2 3 3 4 4 5 5 6}\ndo_test hook-3.6 {\n  set commit_cnt {}\n  proc commit_hook {} {\n    set ::commit_cnt [execsql {SELECT * FROM t2}] \n    return 1\n  }\n  catchsql {\n    INSERT INTO t2 VALUES(6,7);\n  }\n} {1 {constraint failed}}\nverify_ex_errcode hook-3.6b SQLITE_CONSTRAINT_COMMITHOOK\ndo_test hook-3.7 {\n  set ::commit_cnt\n} {1 2 2 3 3 4 4 5 5 6 6 7}\ndo_test hook-3.8 {\n  execsql {SELECT * FROM t2}\n} {1 2 2 3 3 4 4 5 5 6}\n\n# Test turnning off the commit hook\n#\ndo_test hook-3.9 {\n  db commit_hook {}\n  set ::commit_cnt {}\n  execsql {\n    INSERT INTO t2 VALUES(7,8);\n  }\n  set ::commit_cnt\n} {}\n\n# Ticket #3564.\n#\ndo_test hook-3.10 {\n  forcedelete test2.db test2.db-journal\n  sqlite3 db2 test2.db\n  proc commit_hook {} {\n    set y [db2 one {SELECT y FROM t3 WHERE y>10}]\n    return [expr {$y>10}]\n  }\n  db2 eval {CREATE TABLE t3(x,y)}\n  db2 commit_hook commit_hook\n  catchsql {INSERT INTO t3 VALUES(1,2)} db2\n  catchsql {INSERT INTO t3 VALUES(11,12)} db2\n  catchsql {INSERT INTO t3 VALUES(3,4)} db2\n  db2 eval {\n    SELECT * FROM t3 ORDER BY x;\n  }\n} {1 2 3 4}\ndb2 close\n\n\n#----------------------------------------------------------------------------\n# Tests for the update-hook.\n#\n# 4.1.* - Very simple tests. Test that the update hook is invoked correctly \n#         for INSERT, DELETE and UPDATE statements, including DELETE \n#         statements with no WHERE clause.\n# 4.2.* - Check that the update-hook is invoked for rows modified by trigger\n#         bodies. Also that the database name is correctly reported when \n#         an attached database is modified.\n# 4.3.* - Do some sorting, grouping, compound queries, population and \n#         depopulation of indices, to make sure the update-hook is not \n#         invoked incorrectly.\n#\n# EVIDENCE-OF: R-21999-45122 The sqlite3_update_hook() interface\n# registers a callback function with the database connection identified\n# by the first argument to be invoked whenever a row is updated,\n# inserted or deleted in a rowid table.\n\n# Simple tests\ndo_test hook-4.1.1a {\n  catchsql {\n    DROP TABLE t1;\n  }\n  unset -nocomplain ::update_hook\n  set ::update_hook {}\n  db update_hook [list lappend ::update_hook]\n  #\n  # EVIDENCE-OF: R-52223-27275 The update hook is not invoked when\n  # internal system tables are modified (i.e. sqlite_master and\n  # sqlite_sequence).\n  #\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t1w(a INT PRIMARY KEY, b) WITHOUT ROWID;\n  }\n  set ::update_hook\n} {}\ndo_test hook-4.1.1b {\n  execsql {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t1w SELECT * FROM t1;\n  }\n} {}\n\n# EVIDENCE-OF: R-15506-57666 The second callback argument is one of\n# SQLITE_INSERT, SQLITE_DELETE, or SQLITE_UPDATE, depending on the\n# operation that caused the callback to be invoked.\n#\n# EVIDENCE-OF: R-29213-61195 The third and fourth arguments to the\n# callback contain pointers to the database and table name containing\n# the affected row.\n#\n# EVIDENCE-OF: R-30809-57812 The final callback parameter is the rowid\n# of the row.\n#\ndo_test hook-4.1.2 {\n  set ::update_hook {}\n  execsql {\n    INSERT INTO t1 VALUES(4, 'four');\n    DELETE FROM t1 WHERE b = 'two';\n    UPDATE t1 SET b = '' WHERE a = 1 OR a = 3;\n    DELETE FROM t1 WHERE 1; -- Avoid the truncate optimization (for now)\n  }\n  set ::update_hook\n} [list \\\n    INSERT main t1 4 \\\n    DELETE main t1 2 \\\n    UPDATE main t1 1 \\\n    UPDATE main t1 3 \\\n    DELETE main t1 1 \\\n    DELETE main t1 3 \\\n    DELETE main t1 4 \\\n]\n\n# EVIDENCE-OF: R-61808-14344 The sqlite3_update_hook() interface does\n# not fire callbacks for changes to a WITHOUT ROWID table.\n#\n# EVIDENCE-OF: R-33257-44249 The update hook is not invoked when WITHOUT\n# ROWID tables are modified.\n#\ndo_test hook-4.1.2w {\n  set ::update_hook {}\n  execsql {\n    INSERT INTO t1w VALUES(4, 'four');\n    DELETE FROM t1w WHERE b = 'two';\n    UPDATE t1w SET b = '' WHERE a = 1 OR a = 3;\n    DELETE FROM t1w WHERE 1; -- Avoid the truncate optimization (for now)\n  }\n  set ::update_hook\n} {}\n\nifcapable trigger {\n  # Update hook is not invoked for changes to sqlite_master\n  #\n  do_test hook-4.1.3 {\n    set ::update_hook {}\n    execsql {\n      CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT RAISE(IGNORE); END;\n    }\n    set ::update_hook\n  } {}\n  do_test hook-4.1.4 {\n    set ::update_hook {}\n    execsql {\n      DROP TRIGGER r1;\n    }\n    set ::update_hook\n  } {}\n  \n  set ::update_hook {}\n  do_test hook-4.2.1 {\n    catchsql {\n      DROP TABLE t2;\n    }\n    execsql {\n      CREATE TABLE t2(c INTEGER PRIMARY KEY, d);\n      CREATE TRIGGER t1_trigger AFTER INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(new.a, new.b);\n        UPDATE t2 SET d = d || ' via trigger' WHERE new.a = c;\n        DELETE FROM t2 WHERE new.a = c;\n      END;\n    }\n  } {}\n  do_test hook-4.2.2 {\n    execsql {\n      INSERT INTO t1 VALUES(1, 'one');\n      INSERT INTO t1 VALUES(2, 'two');\n    }\n    set ::update_hook\n  } [list \\\n      INSERT main t1 1 \\\n      INSERT main t2 1 \\\n      UPDATE main t2 1 \\\n      DELETE main t2 1 \\\n      INSERT main t1 2 \\\n      INSERT main t2 2 \\\n      UPDATE main t2 2 \\\n      DELETE main t2 2 \\\n  ]\n} else {\n  execsql {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n  }\n}\n\n# Update-hook + ATTACH\nset ::update_hook {}\nifcapable attach {\n  do_test hook-4.2.3 {\n    forcedelete test2.db\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b);\n      INSERT INTO aux.t3 SELECT * FROM t1;\n      UPDATE t3 SET b = 'two or so' WHERE a = 2;\n      DELETE FROM t3 WHERE 1; -- Avoid the truncate optimization (for now)\n    }\n    set ::update_hook\n  } [list \\\n      INSERT aux t3 1 \\\n      INSERT aux t3 2 \\\n      UPDATE aux t3 2 \\\n      DELETE aux t3 1 \\\n      DELETE aux t3 2 \\\n  ]\n}\n\nifcapable trigger {\n  execsql {\n    DROP TRIGGER t1_trigger;\n  }\n}\n\n# Test that other vdbe operations involving btree structures do not \n# incorrectly invoke the update-hook.\nset ::update_hook {}\ndo_test hook-4.3.1 {\n  execsql {\n    CREATE INDEX t1_i ON t1(b);\n    INSERT INTO t1 VALUES(3, 'three');\n    UPDATE t1 SET b = '';\n    DELETE FROM t1 WHERE a > 1;\n  }\n  set ::update_hook\n} [list \\\n    INSERT main t1 3 \\\n    UPDATE main t1 1 \\\n    UPDATE main t1 2 \\\n    UPDATE main t1 3 \\\n    DELETE main t1 2 \\\n    DELETE main t1 3 \\\n]\nset ::update_hook {}\nifcapable compound&&attach {\n  do_test hook-4.3.2 {\n    execsql {\n      SELECT * FROM t1 UNION SELECT * FROM t3;\n      SELECT * FROM t1 UNION ALL SELECT * FROM t3;\n      SELECT * FROM t1 INTERSECT SELECT * FROM t3;\n      SELECT * FROM t1 EXCEPT SELECT * FROM t3;\n      SELECT * FROM t1 ORDER BY b;\n      SELECT * FROM t1 GROUP BY b;\n    }\n    set ::update_hook\n  } [list]\n}\n\ndo_test hook-4.4 {\n  execsql {\n    CREATE TABLE t4(a UNIQUE, b);\n    INSERT INTO t4 VALUES(1, 'a');\n    INSERT INTO t4 VALUES(2, 'b');\n  }\n  set ::update_hook [list]\n  execsql {\n    REPLACE INTO t4 VALUES(1, 'c');\n  }\n  set ::update_hook\n} [list INSERT main t4 3 ]\ndo_execsql_test hook-4.4.1 {\n  SELECT * FROM t4 ORDER BY a;\n} {1 c 2 b}\ndo_test hook-4.4.2 {\n  set ::update_hook [list]\n  execsql {\n    PRAGMA recursive_triggers = on;\n    REPLACE INTO t4 VALUES(1, 'd');\n  }\n  set ::update_hook\n} [list INSERT main t4 4 ]\ndo_execsql_test hook-4.4.3 {\n  SELECT * FROM t4 ORDER BY a;\n} {1 d 2 b}\n\ndb update_hook {}\n#\n#----------------------------------------------------------------------------\n\n#----------------------------------------------------------------------------\n# Test the rollback-hook. The rollback-hook is a bit more complicated than\n# either the commit or update hooks because a rollback can happen \n# explicitly (an sql ROLLBACK statement) or implicitly (a constraint or \n# error condition).\n#\n# hook-5.1.* - Test explicit rollbacks.\n# hook-5.2.* - Test implicit rollbacks caused by constraint failure.\n#\n# hook-5.3.* - Test implicit rollbacks caused by IO errors.\n# hook-5.4.* - Test implicit rollbacks caused by malloc() failure.\n# hook-5.5.* - Test hot-journal rollbacks. Or should the rollback hook \n#              not be called for these?\n#\n\ndo_test hook-5.0 {\n  # Configure the rollback hook to increment global variable \n  # $::rollback_hook each time it is invoked.\n  set ::rollback_hook 0\n  db rollback_hook [list incr ::rollback_hook]\n} {}\n\n# Test explicit rollbacks. Not much can really go wrong here.\n#\ndo_test hook-5.1.1 {\n  set ::rollback_hook 0\n  execsql {\n    BEGIN;\n    ROLLBACK;\n  }\n  set ::rollback_hook\n} {1}\n\n# Test implicit rollbacks caused by constraints.\n#\ndo_test hook-5.2.1 {\n  set ::rollback_hook 0\n  catchsql {\n    DROP TABLE t1;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES('one', 'I');\n    INSERT INTO t1 VALUES('one', 'I');\n  }\n  set ::rollback_hook\n} {1}\ndo_test hook-5.2.2 {\n  # Check that the INSERT transaction above really was rolled back.\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {1}\n\n#\n# End rollback-hook testing.\n#----------------------------------------------------------------------------\n\n#----------------------------------------------------------------------------\n# Test that if a commit-hook returns non-zero (causing a rollback), the\n# rollback-hook is invoked.\n#\nproc commit_hook {} {\n  lappend ::hooks COMMIT\n  return 1\n}\nproc rollback_hook {} {\n  lappend ::hooks ROLLBACK\n}\ndo_test hook-6.1 {\n  set ::hooks [list]\n  db commit_hook commit_hook\n  db rollback_hook rollback_hook\n  catchsql {\n    BEGIN;\n      INSERT INTO t1 VALUES('two', 'II');\n    COMMIT;\n  }\n  execsql { SELECT * FROM t1 }\n} {one I}\ndo_test hook-6.2 {\n  set ::hooks\n} {COMMIT ROLLBACK}\nunset ::hooks\n\n#----------------------------------------------------------------------------\n# The following tests - hook-7.* - test the pre-update hook.\n#\nifcapable !preupdate {\n  finish_test\n  return\n}\n#\n# 7.1.1 - INSERT statement.\n# 7.1.2 - INSERT INTO ... SELECT statement.\n# 7.1.3 - REPLACE INTO ... (rowid conflict)\n# 7.1.4 - REPLACE INTO ... (other index conflicts)\n# 7.1.5 - REPLACE INTO ... (both rowid and other index conflicts)\n#\n# 7.2.1 - DELETE statement.\n# 7.2.2 - DELETE statement that uses the truncate optimization.\n#\n# 7.3.1 - UPDATE statement.\n# 7.3.2 - UPDATE statement that modifies the rowid.\n# 7.3.3 - UPDATE OR REPLACE ... (rowid conflict).\n# 7.3.4 - UPDATE OR REPLACE ... (other index conflicts)\n# 7.3.4 - UPDATE OR REPLACE ... (both rowid and other index conflicts)\n#\n# 7.4.1 - Test that the pre-update-hook is invoked only once if a row being\n#         deleted is removed by a BEFORE trigger.\n#\n# 7.4.2 - Test that the pre-update-hook is invoked if a BEFORE trigger \n#         removes a row being updated. In this case the update hook should\n#         be invoked with SQLITE_INSERT as the opcode when inserting the\n#         new version of the row.\n#         \n# TODO: Short records (those created before a column is added to a table \n#       using ALTER TABLE)\n#\n\nproc do_preupdate_test {tn sql x} {\n  set X [list]\n  foreach elem $x {lappend X $elem}\n  uplevel do_test $tn [list \"\n    set ::preupdate \\[list\\]\n    execsql { $sql }\n    set ::preupdate\n  \"] [list $X]\n}\n\nproc preupdate_hook {args} {\n  set type [lindex $args 0]\n  eval lappend ::preupdate $args\n  if {$type != \"INSERT\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      lappend ::preupdate [db preupdate old $i]\n    }\n  }\n  if {$type != \"DELETE\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      set rc [catch { db preupdate new $i } v]\n      lappend ::preupdate $v\n    }\n  }\n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndb preupdate hook preupdate_hook\n\n# Set up a schema to use for tests 7.1.* to 7.3.*.\ndo_execsql_test 7.0 { \n  CREATE TABLE t1(a, b); \n  CREATE TABLE t2(x, y); \n  CREATE TABLE t3(i, j, UNIQUE(i));\n\n  INSERT INTO t2 VALUES('a', 'b');\n  INSERT INTO t2 VALUES('c', 'd');\n\n  INSERT INTO t3 VALUES(4, 16);\n  INSERT INTO t3 VALUES(5, 25);\n  INSERT INTO t3 VALUES(6, 36);\n} \n\ndo_preupdate_test 7.1.1 {\n  INSERT INTO t1 VALUES('x', 'y')\n} {INSERT main t1 1 1  x y}\n\n# 7.1.2.1 does not use the xfer optimization. 7.1.2.2 does.\ndo_preupdate_test 7.1.2.1 {\n  INSERT INTO t1 SELECT y, x FROM t2;\n} {INSERT main t1 2 2 b a   INSERT main t1 3 3 d c}\ndo_preupdate_test 7.1.2.2 {\n  INSERT INTO t1 SELECT * FROM t2;\n} {INSERT main t1 4 4 a b   INSERT main t1 5 5 c d}\n\ndo_preupdate_test 7.1.3 {\n  REPLACE INTO t1(rowid, a, b) VALUES(1, 1, 1);\n} {\n  DELETE main t1 1 1   x y\n  INSERT main t1 1 1   1 1\n}\n\ndo_preupdate_test 7.1.4 {\n  REPLACE INTO t3 VALUES(4, NULL);\n} {\n  DELETE main t3 1 1   4 16\n  INSERT main t3 4 4   4 {}\n}\n\ndo_preupdate_test 7.1.5 {\n  REPLACE INTO t3(rowid, i, j) VALUES(2, 6, NULL);\n} {\n  DELETE main t3 2 2  5 25\n  DELETE main t3 3 3  6 36\n  INSERT main t3 2 2  6 {}\n}\n\ndo_execsql_test 7.2.0 { SELECT rowid FROM t1 } {1 2 3 4 5}\n\ndo_preupdate_test 7.2.1 {\n  DELETE FROM t1 WHERE rowid = 3\n} {\n  DELETE main t1 3 3  d c\n}\ndo_preupdate_test 7.2.2 {\n  DELETE FROM t1\n} {\n  DELETE main t1 1 1   1 1\n  DELETE main t1 2 2   b a\n  DELETE main t1 4 4   a b\n  DELETE main t1 5 5   c d\n}\n\ndo_execsql_test 7.3.0 { \n  DELETE FROM t1;\n  DELETE FROM t2;\n  DELETE FROM t3;\n\n  INSERT INTO t2 VALUES('a', 'b');\n  INSERT INTO t2 VALUES('c', 'd');\n\n  INSERT INTO t3 VALUES(4, 16);\n  INSERT INTO t3 VALUES(5, 25);\n  INSERT INTO t3 VALUES(6, 36);\n}\n\ndo_preupdate_test 7.3.1 {\n  UPDATE t2 SET y = y||y;\n} {\n  UPDATE main t2 1 1   a b  a bb\n  UPDATE main t2 2 2   c d  c dd\n}\n\ndo_preupdate_test 7.3.2 {\n  UPDATE t2 SET rowid = rowid-1;\n} {\n  UPDATE main t2 1 0   a bb  a bb\n  UPDATE main t2 2 1   c dd  c dd\n}\n\ndo_preupdate_test 7.3.3 {\n  UPDATE OR REPLACE t2 SET rowid = 1 WHERE x = 'a'\n} {\n  DELETE main t2 1 1   c dd\n  UPDATE main t2 0 1   a bb  a bb\n}\n\ndo_preupdate_test 7.3.4.1 {\n  UPDATE OR REPLACE t3 SET i = 5 WHERE i = 6\n} {\n  DELETE main t3 2 2   5 25\n  UPDATE main t3 3 3   6 36  5 36\n}\n\ndo_execsql_test 7.3.4.2 {\n  INSERT INTO t3 VALUES(10, 100);\n  SELECT rowid, * FROM t3;\n} {1 4 16   3 5 36   4 10 100}\n\ndo_preupdate_test 7.3.5 {\n  UPDATE OR REPLACE t3 SET rowid = 1, i = 5 WHERE j = 100;\n} {\n  DELETE main t3 1 1    4  16\n  DELETE main t3 3 3    5  36\n  UPDATE main t3 4 1   10 100  5 100\n}\n\ndo_execsql_test 7.4.1.0 {\n  CREATE TABLE t4(a, b);\n  INSERT INTO t4 VALUES('a', 1);\n  INSERT INTO t4 VALUES('b', 2);\n  INSERT INTO t4 VALUES('c', 3);\n\n  CREATE TRIGGER t4t BEFORE DELETE ON t4 BEGIN\n    DELETE FROM t4 WHERE b = 1;\n  END;\n}\n\ndo_preupdate_test 7.4.1.1 {\n  DELETE FROM t4 WHERE b = 3\n} {\n  DELETE main t4 1 1   a 1\n  DELETE main t4 3 3   c 3\n}\n\ndo_execsql_test 7.4.1.2 {\n  INSERT INTO t4(rowid, a, b) VALUES(1, 'a', 1);\n  INSERT INTO t4(rowid, a, b) VALUES(3, 'c', 3);\n}\ndo_preupdate_test 7.4.1.3 {\n  DELETE FROM t4 WHERE b = 1\n} {\n  DELETE main t4 1 1   a 1\n}\n\ndo_execsql_test 7.4.2.0 {\n  CREATE TABLE t5(a, b);\n  INSERT INTO t5 VALUES('a', 1);\n  INSERT INTO t5 VALUES('b', 2);\n  INSERT INTO t5 VALUES('c', 3);\n\n  CREATE TRIGGER t5t BEFORE UPDATE ON t5 BEGIN\n    DELETE FROM t5 WHERE b = 1;\n  END;\n}\ndo_preupdate_test 7.4.2.1 {\n  UPDATE t5 SET b = 4 WHERE a = 'c'\n} {\n  DELETE main t5 1 1   a 1\n  UPDATE main t5 3 3   c 3  c 4\n}\n\ndo_execsql_test 7.4.2.2 {\n  INSERT INTO t5(rowid, a, b) VALUES(1, 'a', 1);\n}\n\ndo_preupdate_test 7.4.2.3 {\n  UPDATE t5 SET b = 5 WHERE a = 'a'\n} {\n  DELETE main t5 1 1   a 1\n}\n\ndo_execsql_test 7.5.1.0 {\n  CREATE TABLE t7(a, b);\n  INSERT INTO t7 VALUES('one', 'two');\n  INSERT INTO t7 VALUES('three', 'four');\n  ALTER TABLE t7 ADD COLUMN c DEFAULT NULL;\n}\n\ndo_preupdate_test 7.5.1.1 {\n  DELETE FROM t7 WHERE a = 'one'\n} {\n  DELETE main t7 1 1   one two {}\n}\n\ndo_preupdate_test 7.5.1.2 {\n  UPDATE t7 SET b = 'five'\n} {\n  UPDATE main t7 2 2   three four {}  three five {}\n}\n\ndo_execsql_test 7.5.2.0 {\n  CREATE TABLE t8(a, b);\n  INSERT INTO t8 VALUES('one', 'two');\n  INSERT INTO t8 VALUES('three', 'four');\n  ALTER TABLE t8 ADD COLUMN c DEFAULT 'xxx';\n}\n\nif 0 {\n  # At time of writing, these two are broken. They demonstrate that the\n  # sqlite3_preupdate_old() method does not handle the case where ALTER TABLE\n  # has been used to add a column with a default value other than NULL.\n  #\n  do_preupdate_test 7.5.2.1 {\n    DELETE FROM t8 WHERE a = 'one'\n  } {\n    DELETE main t8 1 1   one two xxx\n  }\n  do_preupdate_test 7.5.2.2 {\n    UPDATE t8 SET b = 'five'\n  } {\n    UPDATE main t8 2 2   three four xxx  three five xxx\n  }\n}\n\n# This block of tests verifies that IPK values are correctly reported\n# by the sqlite3_preupdate_old() and sqlite3_preupdate_new() functions.\n#\ndo_execsql_test 7.6.1 { CREATE TABLE t9(a, b INTEGER PRIMARY KEY, c) }\ndo_preupdate_test 7.6.2 {\n  INSERT INTO t9 VALUES(1, 2, 3);\n  UPDATE t9 SET b = b+1, c = c+1;\n  DELETE FROM t9 WHERE a = 1;\n} {\n  INSERT main t9 2 2   1 2 3\n  UPDATE main t9 2 3   1 2 3   1 3 4\n  DELETE main t9 3 3   1 3 4\n}\n\n#--------------------------------------------------------------------------\n# Test that the sqlite3_preupdate_depth() API seems to work.\n#\nproc preupdate_hook {args} {\n  set type [lindex $args 0]\n  eval lappend ::preupdate $args\n  eval lappend ::preupdate [db preupdate depth]\n\n  if {$type != \"INSERT\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      lappend ::preupdate [db preupdate old $i]\n    }\n  }\n  if {$type != \"DELETE\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      set rc [catch { db preupdate new $i } v]\n      lappend ::preupdate $v\n    }\n  }\n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndb preupdate hook preupdate_hook\n\ndo_execsql_test 7.6.1 { \n  CREATE TABLE t1(x PRIMARY KEY);\n  CREATE TABLE t2(x PRIMARY KEY);\n  CREATE TABLE t3(x PRIMARY KEY);\n  CREATE TABLE t4(x PRIMARY KEY);\n\n  CREATE TRIGGER a AFTER INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;\n  CREATE TRIGGER b AFTER INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;\n  CREATE TRIGGER c AFTER INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;\n\n  CREATE TRIGGER d AFTER UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;\n  CREATE TRIGGER e AFTER UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;\n  CREATE TRIGGER f AFTER UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;\n\n  CREATE TRIGGER g AFTER DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;\n  CREATE TRIGGER h AFTER DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;\n  CREATE TRIGGER i AFTER DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;\n}\n\ndo_preupdate_test 7.6.2 {\n  INSERT INTO t1 VALUES('xyz');\n} {\n  INSERT main t1 1 1   0      xyz\n  INSERT main t2 1 1   1      xyz\n  INSERT main t3 1 1   2      xyz\n  INSERT main t4 1 1   3      xyz\n}\ndo_preupdate_test 7.6.3 {\n  UPDATE t1 SET x = 'abc';\n} {\n  UPDATE main t1 1 1   0      xyz abc\n  UPDATE main t2 1 1   1      xyz abc\n  UPDATE main t3 1 1   2      xyz abc\n  UPDATE main t4 1 1   3      xyz abc\n}\ndo_preupdate_test 7.6.4 {\n  DELETE FROM t1 WHERE 1;\n} {\n  DELETE main t1 1 1   0      abc\n  DELETE main t2 1 1   1      abc\n  DELETE main t3 1 1   2      abc\n  DELETE main t4 1 1   3      abc\n}\n\ndo_execsql_test 7.6.5 { \n  DROP TRIGGER a; DROP TRIGGER b; DROP TRIGGER c;\n  DROP TRIGGER d; DROP TRIGGER e; DROP TRIGGER f;\n  DROP TRIGGER g; DROP TRIGGER h; DROP TRIGGER i;\n\n  CREATE TRIGGER a BEFORE INSERT ON t1 BEGIN INSERT INTO t2 VALUES(new.x); END;\n  CREATE TRIGGER b BEFORE INSERT ON t2 BEGIN INSERT INTO t3 VALUES(new.x); END;\n  CREATE TRIGGER c BEFORE INSERT ON t3 BEGIN INSERT INTO t4 VALUES(new.x); END;\n\n  CREATE TRIGGER d BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET x = new.x; END;\n  CREATE TRIGGER e BEFORE UPDATE ON t2 BEGIN UPDATE t3 SET x = new.x; END;\n  CREATE TRIGGER f BEFORE UPDATE ON t3 BEGIN UPDATE t4 SET x = new.x; END;\n\n  CREATE TRIGGER g BEFORE DELETE ON t1 BEGIN DELETE FROM t2 WHERE 1; END;\n  CREATE TRIGGER h BEFORE DELETE ON t2 BEGIN DELETE FROM t3 WHERE 1; END;\n  CREATE TRIGGER i BEFORE DELETE ON t3 BEGIN DELETE FROM t4 WHERE 1; END;\n}\n\ndo_preupdate_test 7.6.6 {\n  INSERT INTO t1 VALUES('xyz');\n} {\n  INSERT main t4 1 1   3      xyz\n  INSERT main t3 1 1   2      xyz\n  INSERT main t2 1 1   1      xyz\n  INSERT main t1 1 1   0      xyz\n}\ndo_preupdate_test 7.6.3 {\n  UPDATE t1 SET x = 'abc';\n} {\n  UPDATE main t4 1 1   3      xyz abc\n  UPDATE main t3 1 1   2      xyz abc\n  UPDATE main t2 1 1   1      xyz abc\n  UPDATE main t1 1 1   0      xyz abc\n}\ndo_preupdate_test 7.6.4 {\n  DELETE FROM t1 WHERE 1;\n} {\n  DELETE main t4 1 1   3      abc\n  DELETE main t3 1 1   2      abc\n  DELETE main t2 1 1   1      abc\n  DELETE main t1 1 1   0      abc\n}\n\n# No preupdate callbacks for modifying sqlite_master.\ndo_preupdate_test 8.1 { CREATE TABLE x1(x, y); } { }\ndo_preupdate_test 8.2 { ALTER TABLE x1 ADD COLUMN z } { }\ndo_preupdate_test 8.3 { ALTER TABLE x1 RENAME TO y1 } { }\ndo_preupdate_test 8.4 { CREATE INDEX y1x ON y1(x) } { }\ndo_preupdate_test 8.5 { CREATE VIEW v1 AS SELECT * FROM y1 } { }\ndo_preupdate_test 8.6 { DROP TABLE y1 } { }\n\n#-------------------------------------------------------------------------\nreset_db\ndb preupdate hook preupdate_hook\ndo_execsql_test 9.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n  CREATE TABLE t2(a, b INTEGER PRIMARY KEY);\n}\ndo_preupdate_test 9.1 {\n  INSERT INTO t1 VALUES(456, NULL, NULL);\n} {\n  INSERT main t1 456 456  0  456 {} {}\n}\ndo_execsql_test 9.2 {\n  ALTER TABLE t1 ADD COLUMN d;\n}\ndo_preupdate_test 9.3 {\n  INSERT INTO t1(a, b, c) VALUES(457, NULL, NULL);\n} {\n  INSERT main t1 457 457  0  457 {} {} {}\n}\ndo_preupdate_test 9.4 {\n  DELETE FROM t1 WHERE a=456\n} {\n  DELETE main t1 456 456  0  456 {} {} {}\n}\ndo_preupdate_test 9.5 {\n  INSERT INTO t2 DEFAULT VALUES;\n} {\n  INSERT main t2 1 1  0  {} 1\n} \ndo_preupdate_test 9.6 {\n  INSERT INTO t1 DEFAULT VALUES;\n} {\n  INSERT main t1 458 458  0  458 {} {} {}\n} \n\n\ndo_execsql_test 10.0 {\n  CREATE TABLE t3(a, b INTEGER PRIMARY KEY);\n}\ndo_preupdate_test 10.1 {\n  INSERT INTO t3 DEFAULT VALUES\n} {\n  INSERT main t3 1 1 0 {} 1\n}\ndo_execsql_test 10.2 { SELECT * FROM t3 } {{} 1}\ndo_preupdate_test 10.3 {\n  DELETE FROM t3 WHERE b=1\n} {DELETE main t3 1 1 0 {} 1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/hook2.test",
    "content": "# 2017 Jan 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The tests in this file focus on the pre-update hook.\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix hook2\n\nifcapable !preupdate {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\nproc do_preupdate_test {tn sql x} {\n  set X [list]\n  foreach elem $x {lappend X $elem}\n  uplevel do_test $tn [list \"\n    set ::preupdate \\[list\\]\n    execsql { $sql }\n    set ::preupdate\n  \"] [list $X]\n}\n\nproc preupdate_hook {args} {\n  set type [lindex $args 0]\n  eval lappend ::preupdate $args\n  if {$type != \"INSERT\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      lappend ::preupdate [db preupdate old $i]\n    }\n  }\n  if {$type != \"DELETE\"} {\n    for {set i 0} {$i < [db preupdate count]} {incr i} {\n      set rc [catch { db preupdate new $i } v]\n      lappend ::preupdate $v\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Simple tests - INSERT, UPDATE and DELETE on a WITHOUT ROWID table.\n#\ndb preupdate hook preupdate_hook\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID;\n}\ndo_preupdate_test 1.1 {\n  INSERT INTO t1 VALUES('one', 1);\n} {\n  INSERT main t1 0 0  one 1\n}\ndo_preupdate_test 1.2 {\n  UPDATE t1 SET b=2 WHERE a='one';\n} {\n  UPDATE main t1 0 0  one 1 one 2\n}\ndo_preupdate_test 1.3 {\n  DELETE FROM t1 WHERE a='one';\n} {\n  DELETE main t1 0 0  one 2\n}\n\n#-------------------------------------------------------------------------\n# Some more complex tests for the pre-update callback on WITHOUT ROWID\n# tables.\n#\n#   2.1.1 - INSERT statement.\n#   2.1.2 - INSERT INTO ... SELECT statement.\n#   2.1.3 - REPLACE INTO ... (PK conflict)\n#   2.1.4 - REPLACE INTO ... (other index conflicts)\n#   2.1.5 - REPLACE INTO ... (both PK and other index conflicts)\n#\n#   2.2.1 - DELETE statement.\n#   2.2.2 - DELETE statement that uses the truncate optimization.\n#\n#   2.3.1 - UPDATE statement.\n#   2.3.2 - UPDATE statement that modifies the PK.\n#   2.3.3 - UPDATE OR REPLACE ... (PK conflict).\n#   2.3.4 - UPDATE OR REPLACE ... (other index conflicts)\n#   2.3.4 - UPDATE OR REPLACE ... (both PK and other index conflicts)\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;\n  CREATE UNIQUE INDEX t2a ON t2(a);\n}\n\ndo_preupdate_test 2.1.1 {\n  INSERT INTO t2(b, c) VALUES(1, 1);\n} {\n  INSERT main t2 0 0  4 1 1\n}\n\ndo_execsql_test 2.1.2.0 {\n  CREATE TABLE d1(a DEFAULT 4, b, c, PRIMARY KEY(b, c)) WITHOUT ROWID;\n  CREATE UNIQUE INDEX d1a ON d1(a);\n  INSERT INTO d1 VALUES(1, 2, 3);\n  INSERT INTO d1 VALUES(11, 12, 13);\n}\ndo_preupdate_test 2.1.2.1 {\n  INSERT INTO t2 SELECT * FROM d1;\n} {\n  INSERT main t2 0 0  1 2 3\n  INSERT main t2 0 0  11 12 13\n}\ndo_preupdate_test 2.1.2.2 {\n  INSERT INTO t2 SELECT a+20, b+20, c+20 FROM d1;\n} {\n  INSERT main t2 0 0  21 22 23\n  INSERT main t2 0 0  31 32 33\n}\ndo_execsql_test 2.1.2.3 {\n  SELECT * FROM t2 ORDER BY b, c;\n} {\n  4 1 1\n  1 2 3\n  11 12 13\n  21 22 23\n  31 32 33\n}\ndo_preupdate_test 2.1.3 {\n  REPLACE INTO t2 VALUES(45, 22, 23);\n} {\n  DELETE main t2 0 0 21 22 23\n  INSERT main t2 0 0 45 22 23\n}\ndo_preupdate_test 2.1.4 {\n  REPLACE INTO t2 VALUES(11, 100, 100);\n} {\n  DELETE main t2 0 0 11 12 13\n  INSERT main t2 0 0 11 100 100\n}\ndo_preupdate_test 2.1.5 {\n  REPLACE INTO t2(c, b) VALUES(33, 32)\n} {\n  DELETE main t2 0 0 4 1 1 \n  DELETE main t2 0 0 31 32 33\n  INSERT main t2 0 0 4 32 33\n}\n\ndo_execsql_test 2.2.0 {\n  SELECT * FROM t2 ORDER BY b,c;\n} {\n  1    2   3 \n  45  22  23 \n  4   32  33 \n  11 100 100\n}\ndo_preupdate_test 2.2.1 {\n  DELETE FROM t2 WHERE b=22;\n} {\n  DELETE main t2 0 0  45 22 23\n}\ndo_preupdate_test 2.2.2 {\n  DELETE FROM t2;\n} {\n  DELETE main t2 0 0 1 2 3 \n  DELETE main t2 0 0 4 32 33 \n  DELETE main t2 0 0 11 100 100\n}\n\ndo_execsql_test 2.3.0 {\n  CREATE TABLE t3(x, y PRIMARY KEY, z UNIQUE) WITHOUT ROWID;\n  INSERT INTO t3 VALUES('a', 'b', 'c');\n  INSERT INTO t3 VALUES('d', 'e', 'f');\n\n  INSERT INTO t3 VALUES(1, 1, 1);\n  INSERT INTO t3 VALUES(2, 2, 2);\n  INSERT INTO t3 VALUES(3, 3, 3);\n}\n\ndo_preupdate_test 2.3.1 {\n  UPDATE t3 SET x=4 WHERE y IN ('b', 'e', 'x');\n} {\n  UPDATE main t3 0 0  a b c   4 b c\n  UPDATE main t3 0 0  d e f   4 e f\n}\n\ndo_preupdate_test 2.3.2 {\n  UPDATE t3 SET y=y||y WHERE z IN('c', 'f');\n} {\n  UPDATE main t3 0 0  4 b c   4 bb c\n  UPDATE main t3 0 0  4 e f   4 ee f\n}\n\ndo_preupdate_test 2.3.3 {\n  UPDATE OR REPLACE t3 SET y='bb' WHERE z='f'\n} {\n  DELETE main t3 0 0  4 bb c\n  UPDATE main t3 0 0  4 ee f   4 bb f\n}\n\ndo_preupdate_test 2.3.4 {\n  UPDATE OR REPLACE t3 SET z=2 WHERE y=1;\n} {\n  DELETE main t3 0 0  2 2 2\n  UPDATE main t3 0 0  1 1 1  1 1 2\n}\n\ndo_preupdate_test 2.3.5 {\n  UPDATE OR REPLACE t3 SET z=2, y='bb' WHERE y=3;\n} {\n  DELETE main t3 0 0  1 1 2\n  DELETE main t3 0 0  4 bb f\n  UPDATE main t3 0 0  3 3 3  3 bb 2\n}\n  \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/icu.test",
    "content": "# 2007 May 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: icu.test,v 1.2 2008/07/12 14:52:20 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !icu {\n  finish_test\n  return\n}\n\n# Create a table to work with.\n#\nexecsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}\nexecsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}\nproc test_expr {name settings expr result} {\n  do_test $name [format {\n    lindex [db eval {\n      BEGIN; \n      UPDATE test1 SET %s; \n      SELECT %s FROM test1; \n      ROLLBACK;\n    }] 0\n  } $settings $expr] $result\n}\n\n# Tests of the REGEXP operator.\n#\ntest_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'}  1\ntest_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'}  1\ntest_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'}   0\ntest_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1\ntest_expr icu-1.5 {i1=NULL}    {i1 REGEXP '.ell.*'} {}\n\n# Some non-ascii characters with defined case mappings\n#\nset ::EGRAVE \"\\xC8\"\nset ::egrave \"\\xE8\"\n\nset ::OGRAVE \"\\xD2\"\nset ::ograve \"\\xF2\"\n\n# That German letter that looks a bit like a B. The\n# upper-case version of which is \"SS\" (two characters).\n#\nset ::szlig \"\\xDF\" \n\n# Tests of the upper()/lower() functions.\n#\ntest_expr icu-2.1 {i1='HellO WorlD'} {upper(i1)} {HELLO WORLD}\ntest_expr icu-2.2 {i1='HellO WorlD'} {lower(i1)} {hello world}\ntest_expr icu-2.3 {i1=$::egrave} {lower(i1)}     $::egrave\ntest_expr icu-2.4 {i1=$::egrave} {upper(i1)}     $::EGRAVE\ntest_expr icu-2.5 {i1=$::ograve} {lower(i1)}     $::ograve\ntest_expr icu-2.6 {i1=$::ograve} {upper(i1)}     $::OGRAVE\ntest_expr icu-2.3 {i1=$::EGRAVE} {lower(i1)}     $::egrave\ntest_expr icu-2.4 {i1=$::EGRAVE} {upper(i1)}     $::EGRAVE\ntest_expr icu-2.5 {i1=$::OGRAVE} {lower(i1)}     $::ograve\ntest_expr icu-2.6 {i1=$::OGRAVE} {upper(i1)}     $::OGRAVE\n\ntest_expr icu-2.7 {i1=$::szlig} {upper(i1)}      \"SS\"\ntest_expr icu-2.8 {i1='SS'} {lower(i1)}          \"ss\"\n\ndo_execsql_test icu-2.9 {\n  SELECT upper(char(0xfb04,0xfb04,0xfb04,0xfb04));\n} {FFLFFLFFLFFL}\n\n# In turkish (locale=\"tr_TR\"), the lower case version of I\n# is \"small dotless i\" (code point 0x131 (decimal 305)).\n#\nset ::small_dotless_i \"\\u0131\"\ntest_expr icu-3.1 {i1='I'} {lower(i1)}           \"i\"\ntest_expr icu-3.2 {i1='I'} {lower(i1, 'tr_tr')}  $::small_dotless_i\ntest_expr icu-3.3 {i1='I'} {lower(i1, 'en_AU')}  \"i\"\n\n#--------------------------------------------------------------------\n# Test the collation sequence function.\n#\ndo_test icu-4.1 {\n  execsql {\n    CREATE TABLE fruit(name);\n    INSERT INTO fruit VALUES('plum');\n    INSERT INTO fruit VALUES('cherry');\n    INSERT INTO fruit VALUES('apricot');\n    INSERT INTO fruit VALUES('peach');\n    INSERT INTO fruit VALUES('chokecherry');\n    INSERT INTO fruit VALUES('yamot');\n  }\n} {}\ndo_test icu-4.2 {\n  execsql {\n    SELECT icu_load_collation('en_US', 'AmericanEnglish');\n    SELECT icu_load_collation('lt_LT', 'Lithuanian');\n  }\n  execsql {\n    SELECT name FROM fruit ORDER BY name COLLATE AmericanEnglish ASC;\n  }\n} {apricot cherry chokecherry peach plum yamot}\n\n\n# Test collation using Lithuanian rules. In the Lithuanian\n# alphabet, \"y\" comes right after \"i\".\n#\ndo_test icu-4.3 {\n  execsql {\n    SELECT name FROM fruit ORDER BY name COLLATE Lithuanian ASC;\n  }\n} {apricot cherry chokecherry yamot peach plum}\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to call the ICU regex() function with \n# anything other than exactly two arguments. See also:\n#\n#   http://src.chromium.org/viewvc/chrome/trunk/src/third_party/sqlite/icu-regexp.patch?revision=34807&view=markup\n#\ndo_catchsql_test icu-5.1 { SELECT regexp('a[abc]c.*', 'abc') } {0 1}\ndo_catchsql_test icu-5.2 { \n  SELECT regexp('a[abc]c.*') \n} {1 {wrong number of arguments to function regexp()}}\ndo_catchsql_test icu-5.3 { \n  SELECT regexp('a[abc]c.*', 'abc', 'c') \n} {1 {wrong number of arguments to function regexp()}}\ndo_catchsql_test icu-5.4 { \n  SELECT 'abc' REGEXP 'a[abc]c.*'\n} {0 1}\ndo_catchsql_test icu-5.4 { SELECT 'abc' REGEXP }    {1 {near \" \": syntax error}}\ndo_catchsql_test icu-5.5 { SELECT 'abc' REGEXP, 1 } {1 {near \",\": syntax error}}\n\n\ndo_malloc_test icu-6.10 -sqlbody {\n  SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04));\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ieee754.test",
    "content": "# 2015-11-06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Tests of the iee754 extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nload_static_extension db ieee754\n\nforeach {id float rep} {\n   1       1.0                            1,0\n   2       2.0                            2,0\n   3       0.5                            1,-1\n   4       1.5                            3,-1\n   5       0.0                            0,-1075\n   6       4.9406564584124654e-324        4503599627370497,-1075\n   7       2.2250738585072009e-308        9007199254740991,-1075\n   8       2.2250738585072014e-308        1,-1022\n} {\n  do_test ieee754-100-$id-1 {\n    db eval \"SELECT ieee754($float);\"\n  } \"ieee754($rep)\"\n  do_test ieee754-100-$id-2 {\n    db eval \"SELECT ieee754($rep)==$float;\"\n  } {1}\n  if {$float!=0.0} {\n    do_test ieee754-100-$id-3 {\n      db eval \"SELECT ieee754(-$float);\"\n    } \"ieee754(-$rep)\"\n    do_test ieee754-100-$id-4 {\n      db eval \"SELECT ieee754(-$rep)==-$float;\"\n    } {1}\n  }\n}\n\ndo_test ieee754-110 {\n  string tolower [\n    db eval {SELECT ieee754(1,1024), ieee754(4503599627370495,972);}\n  ]\n} {inf 1.79769313486232e+308}\ndo_test ieee754-111 {\n  string tolower [\n    db eval {SELECT ieee754(-1,1024), ieee754(-4503599627370495,972);}\n  ]\n} {-inf -1.79769313486232e+308}\ndo_execsql_test ieee754-112 {\n  SELECT ieee754(4503599627370495,973) is null;\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/imposter1.test",
    "content": "# 2015-01-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests for SQLite library.\n#\n# The focus of this file is adding extra entries in the symbol table\n# using sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER) and verifying that\n# SQLite handles those as expected.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix imposter\n\n# Create a bunch of data to sort against\n#\ndo_test imposter-1.0 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d NOT NULL);\n    CREATE INDEX t1b ON t1(b);\n    CREATE UNIQUE INDEX t1c ON t1(c);\n    WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<30)\n      INSERT INTO t1(a,b,c,d) SELECT i,1000+i,2000+i,3000+i FROM c;\n  }\n  set t1_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1'}]\n  set t1b_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1b'}]\n  set t1c_root [db one {SELECT rootpage FROM sqlite_master WHERE name='t1c'}]\n\n  # Create an imposter table that uses the same b-tree as t1 but which does\n  # not have the indexes\n  #\n  sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $t1_root\n  db eval {CREATE TABLE xt1(a,b,c,d)}\n\n  # And create an imposter table for the t1c index.\n  sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 1 $t1c_root\n  db eval {CREATE TABLE xt1c(c,rowid,PRIMARY KEY(c,rowid))WITHOUT ROWID;}\n\n  # Go out of imposter mode for now.\n  sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 0\n\n  # Create triggers to record changes to xt1.\n  #\n  db eval {\n    CREATE TEMP TABLE chnglog(desc TEXT);\n    CREATE TEMP TRIGGER xt1_del AFTER DELETE ON xt1 BEGIN\n      INSERT INTO chnglog VALUES(\n           printf('DELETE t1: rowid=%d, a=%s, b=%s, c=%s, d=%s',\n                  old.rowid, quote(old.a), quote(old.b), quote(old.c),\n                  quote(old.d)));\n    END;\n    CREATE TEMP TRIGGER xt1_ins AFTER INSERT ON xt1 BEGIN\n      INSERT INTO chnglog VALUES(\n           printf('INSERT t1:  rowid=%d, a=%s, b=%s, c=%s, d=%s',\n                  new.rowid, quote(new.a), quote(new.b), quote(new.c),\n                  quote(new.d)));\n    END;\n  }\n} {}\n\n# The xt1 table has separate xt1.rowid and xt1.a columns.  The xt1.rowid\n# column corresponds to t1.rowid and t1.a, but the xt1.a column is always\n# NULL\n#\ndo_execsql_test imposter-1.1 {\n  SELECT rowid FROM xt1 WHERE a IS NOT NULL;\n} {}\ndo_execsql_test imposter-1.2 {\n  SELECT a,b,c,d FROM t1 EXCEPT SELECT rowid,b,c,d FROM xt1;\n  SELECT rowid,b,c,d FROM xt1 EXCEPT SELECT a,b,c,d FROM t1;\n} {}\n\n\n# Make changes via the xt1 shadow table.  This will not update the\n# indexes on t1 nor check the uniqueness constraint on t1.c nor check\n# the NOT NULL constraint on t1.d, resulting in a logically inconsistent\n# database.\n#\ndo_execsql_test imposter-1.3 {\n  DELETE FROM xt1 WHERE rowid=5;\n  INSERT INTO xt1(rowid,a,b,c,d) VALUES(99,'hello',1099,2022,NULL);\n  SELECT * FROM chnglog ORDER BY rowid;\n} [list \\\n  {DELETE t1: rowid=5, a=NULL, b=1005, c=2005, d=3005} \\\n  {INSERT t1:  rowid=99, a='hello', b=1099, c=2022, d=NULL} \\\n]\n\ndo_execsql_test imposter-1.4a {\n  PRAGMA integrity_check;\n} {/NULL value in t1.d/}\ndo_execsql_test imposter-1.4b {\n  PRAGMA integrity_check;\n} {/row # missing from index t1b/}\ndo_execsql_test imposter-1.4c {\n  PRAGMA integrity_check;\n} {/row # missing from index t1c/}\n\n# Cleanup the corruption.\n# Then demonstrate that the xt1c imposter table can insert non-unique\n# and NULL values into the UNIQUE index.\n#\ndo_execsql_test imposter-2.0 {\n  DELETE FROM t1;\n  WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)\n   INSERT INTO t1(a,b,c,d) SELECT i,i,i,i FROM c;\n  UPDATE xt1c SET c=NULL WHERE rowid=5;\n  PRAGMA integrity_check;\n} {/row # missing from index t1c/}\n\ndo_execsql_test imposter-2.1 {\n  DELETE FROM t1;\n  WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10)\n   INSERT INTO t1(a,b,c,d) SELECT i,i,i,i FROM c;\n  UPDATE xt1c SET c=99 WHERE rowid IN (5,7,9);\n  SELECT c FROM t1 ORDER BY c;\n} {1 2 3 4 6 8 10 99 99 99}\ndo_execsql_test imposter-2.2 {\n  UPDATE xt1 SET c=99 WHERE rowid IN (5,7,9);\n  PRAGMA integrity_check;\n} {/non-unique entry in index t1c/}\n\n# Erase the imposter tables\n#\ndo_test imposter-3.1 {\n  sqlite3_test_control SQLITE_TESTCTRL_IMPOSTER db main 0 1\n  db eval {\n    DELETE FROM t1 WHERE rowid IN (5,7,9);\n    PRAGMA integrity_check;\n  }\n} {ok}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/in.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the IN and BETWEEN operator.\n#\n# $Id: in.test,v 1.22 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Generate the test data we will need for the first squences of tests.\n#\ndo_test in-1.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a int, b int);\n  }\n  for {set i 1} {$i<=10} {incr i} {\n    execsql \"INSERT INTO t1 VALUES($i,[expr {1<<$i}])\"\n  }\n  execsql {\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {10}\n\n# Do basic testing of BETWEEN.\n#\ndo_test in-1.1 {\n  execsql {SELECT a FROM t1 WHERE b BETWEEN 10 AND 50 ORDER BY a}\n} {4 5}\ndo_test in-1.2 {\n  execsql {SELECT a FROM t1 WHERE b NOT BETWEEN 10 AND 50 ORDER BY a}\n} {1 2 3 6 7 8 9 10}\ndo_test in-1.3 {\n  execsql {SELECT a FROM t1 WHERE b BETWEEN a AND a*5 ORDER BY a}\n} {1 2 3 4}\ndo_test in-1.4 {\n  execsql {SELECT a FROM t1 WHERE b NOT BETWEEN a AND a*5 ORDER BY a}\n} {5 6 7 8 9 10}\ndo_test in-1.6 {\n  execsql {SELECT a FROM t1 WHERE b BETWEEN a AND a*5 OR b=512 ORDER BY a}\n} {1 2 3 4 9}\ndo_test in-1.7 {\n  execsql {SELECT a+ 100*(a BETWEEN 1 and 3) FROM t1 ORDER BY b}\n} {101 102 103 4 5 6 7 8 9 10}\n\n# The rest of this file concentrates on testing the IN operator.\n# Skip this if the library is compiled with SQLITE_OMIT_SUBQUERY \n# (because the IN operator is unavailable).\n#\nifcapable !subquery {\n  finish_test\n  return\n}\n\n# Testing of the IN operator using static lists on the right-hand side.\n#\ndo_test in-2.1 {\n  execsql {SELECT a FROM t1 WHERE b IN (8,12,16,24,32) ORDER BY a}\n} {3 4 5}\ndo_test in-2.2 {\n  execsql {SELECT a FROM t1 WHERE b NOT IN (8,12,16,24,32) ORDER BY a}\n} {1 2 6 7 8 9 10}\ndo_test in-2.3 {\n  execsql {SELECT a FROM t1 WHERE b IN (8,12,16,24,32) OR b=512 ORDER BY a}\n} {3 4 5 9}\ndo_test in-2.4 {\n  execsql {SELECT a FROM t1 WHERE b NOT IN (8,12,16,24,32) OR b=512 ORDER BY a}\n} {1 2 6 7 8 9 10}\ndo_test in-2.5 {\n  execsql {SELECT a+100*(b IN (8,16,24)) FROM t1 ORDER BY b}\n} {1 2 103 104 5 6 7 8 9 10}\n\ndo_test in-2.6 {\n  execsql {SELECT a FROM t1 WHERE b IN (b+8,64)}\n} {6}\ndo_test in-2.7 {\n  execsql {SELECT a FROM t1 WHERE b IN (max(5,10,b),20)}\n} {4 5 6 7 8 9 10}\ndo_test in-2.8 {\n  execsql {SELECT a FROM t1 WHERE b IN (8*2,64/2) ORDER BY b}\n} {4 5}\ndo_test in-2.9 {\n  execsql {SELECT a FROM t1 WHERE b IN (max(5,10),20)}\n} {}\ndo_test in-2.10 {\n  execsql {SELECT a FROM t1 WHERE min(0,b IN (a,30))}\n} {}\ndo_test in-2.11 {\n  set v [catch {execsql {SELECT a FROM t1 WHERE c IN (10,20)}} msg]\n  lappend v $msg\n} {1 {no such column: c}}\n\n# Testing the IN operator where the right-hand side is a SELECT\n#\ndo_test in-3.1 {\n  execsql {\n    SELECT a FROM t1\n    WHERE b IN (SELECT b FROM t1 WHERE a<5)\n    ORDER BY a\n  }\n} {1 2 3 4}\ndo_test in-3.2 {\n  execsql {\n    SELECT a FROM t1\n    WHERE b IN (SELECT b FROM t1 WHERE a<5) OR b==512\n    ORDER BY a\n  }\n} {1 2 3 4 9}\ndo_test in-3.3 {\n  execsql {\n    SELECT a + 100*(b IN (SELECT b FROM t1 WHERE a<5)) FROM t1 ORDER BY b\n  }\n} {101 102 103 104 5 6 7 8 9 10}\n\n# Make sure the UPDATE and DELETE commands work with IN-SELECT\n#\ndo_test in-4.1 {\n  execsql {\n    UPDATE t1 SET b=b*2 \n    WHERE b IN (SELECT b FROM t1 WHERE a>8)\n  }\n  execsql {SELECT b FROM t1 ORDER BY b}\n} {2 4 8 16 32 64 128 256 1024 2048}\ndo_test in-4.2 {\n  execsql {\n    DELETE FROM t1 WHERE b IN (SELECT b FROM t1 WHERE a>8)\n  }\n  execsql {SELECT a FROM t1 ORDER BY a}\n} {1 2 3 4 5 6 7 8}\ndo_test in-4.3 {\n  execsql {\n    DELETE FROM t1 WHERE b NOT IN (SELECT b FROM t1 WHERE a>4)\n  }\n  execsql {SELECT a FROM t1 ORDER BY a}\n} {5 6 7 8}\n\n# Do an IN with a constant RHS but where the RHS has many, many\n# elements.  We need to test that collisions in the hash table\n# are resolved properly.\n#\ndo_test in-5.1 {\n  execsql {\n    INSERT INTO t1 VALUES('hello', 'world');\n    SELECT * FROM t1\n    WHERE a IN (\n       'Do','an','IN','with','a','constant','RHS','but','where','the',\n       'has','many','elements','We','need','to','test','that',\n       'collisions','hash','table','are','resolved','properly',\n       'This','in-set','contains','thirty','one','entries','hello');\n  }\n} {hello world}\n\n# Make sure the IN operator works with INTEGER PRIMARY KEY fields.\n#\ndo_test in-6.1 {\n  execsql {\n    CREATE TABLE ta(a INTEGER PRIMARY KEY, b);\n    INSERT INTO ta VALUES(1,1);\n    INSERT INTO ta VALUES(2,2);\n    INSERT INTO ta VALUES(3,3);\n    INSERT INTO ta VALUES(4,4);\n    INSERT INTO ta VALUES(6,6);\n    INSERT INTO ta VALUES(8,8);\n    INSERT INTO ta VALUES(10,\n       'This is a key that is long enough to require a malloc in the VDBE');\n    SELECT * FROM ta WHERE a<10;\n  }\n} {1 1 2 2 3 3 4 4 6 6 8 8}\ndo_test in-6.2 {\n  execsql {\n    CREATE TABLE tb(a INTEGER PRIMARY KEY, b);\n    INSERT INTO tb VALUES(1,1);\n    INSERT INTO tb VALUES(2,2);\n    INSERT INTO tb VALUES(3,3);\n    INSERT INTO tb VALUES(5,5);\n    INSERT INTO tb VALUES(7,7);\n    INSERT INTO tb VALUES(9,9);\n    INSERT INTO tb VALUES(11,\n       'This is a key that is long enough to require a malloc in the VDBE');\n    SELECT * FROM tb WHERE a<10;\n  }\n} {1 1 2 2 3 3 5 5 7 7 9 9}\ndo_test in-6.3 {\n  execsql {\n    SELECT a FROM ta WHERE b IN (SELECT a FROM tb);\n  }\n} {1 2 3}\ndo_test in-6.4 {\n  execsql {\n    SELECT a FROM ta WHERE b NOT IN (SELECT a FROM tb);\n  }\n} {4 6 8 10}\ndo_test in-6.5 {\n  execsql {\n    SELECT a FROM ta WHERE b IN (SELECT b FROM tb);\n  }\n} {1 2 3 10}\ndo_test in-6.6 {\n  execsql {\n    SELECT a FROM ta WHERE b NOT IN (SELECT b FROM tb);\n  }\n} {4 6 8}\ndo_test in-6.7 {\n  execsql {\n    SELECT a FROM ta WHERE a IN (SELECT a FROM tb);\n  }\n} {1 2 3}\ndo_test in-6.8 {\n  execsql {\n    SELECT a FROM ta WHERE a NOT IN (SELECT a FROM tb);\n  }\n} {4 6 8 10}\ndo_test in-6.9 {\n  execsql {\n    SELECT a FROM ta WHERE a IN (SELECT b FROM tb);\n  }\n} {1 2 3}\ndo_test in-6.10 {\n  execsql {\n    SELECT a FROM ta WHERE a NOT IN (SELECT b FROM tb);\n  }\n} {4 6 8 10}\n\n# Tests of IN operator against empty sets.  (Ticket #185)\n#\ndo_test in-7.1 {\n  execsql {\n    SELECT a FROM t1 WHERE a IN ();\n  }\n} {}\ndo_test in-7.2 {\n  execsql {\n    SELECT a FROM t1 WHERE a IN (5);\n  }\n} {5}\ndo_test in-7.3 {\n  execsql {\n    SELECT a FROM t1 WHERE a NOT IN () ORDER BY a;\n  }\n} {5 6 7 8 hello}\ndo_test in-7.4 {\n  execsql {\n    SELECT a FROM t1 WHERE a IN (5) AND b IN ();\n  }\n} {}\ndo_test in-7.5 {\n  execsql {\n    SELECT a FROM t1 WHERE a IN (5) AND b NOT IN ();\n  }\n} {5}\ndo_test in-7.6.1 {\n  execsql {\n    SELECT a FROM ta WHERE a IN ();\n  }\n} {}\ndo_test in-7.6.2 {\n  db status step\n} {0}\ndo_test in-7.7 {\n  execsql {\n    SELECT a FROM ta WHERE a NOT IN ();\n  }\n} {1 2 3 4 6 8 10}\n\ndo_test in-7.8.1 {\n  execsql {\n    SELECT * FROM ta LEFT JOIN tb ON (ta.b=tb.b) WHERE ta.a IN ();\n  }\n} {}\ndo_test in-7.8.2 {\n  db status step\n} {0}\n\ndo_test in-8.1 {\n  execsql {\n    SELECT b FROM t1 WHERE a IN ('hello','there')\n  }\n} {world}\ndo_test in-8.2 {\n  execsql {\n    SELECT b FROM t1 WHERE a IN (\"hello\",'there')\n  }\n} {world}\n\n# Test constructs of the form:  expr IN tablename\n#\ndo_test in-9.1 {\n  execsql {\n    CREATE TABLE t4 AS SELECT a FROM tb;\n    SELECT * FROM t4;    \n  }\n} {1 2 3 5 7 9 11}\ndo_test in-9.2 {\n  execsql {\n    SELECT b FROM t1 WHERE a IN t4;\n  }\n} {32 128}\ndo_test in-9.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a NOT IN t4;\n  }\n} {64 256 world}\ndo_test in-9.4 {\n  catchsql {\n    SELECT b FROM t1 WHERE a NOT IN tb;\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\n\n# IN clauses in CHECK constraints.  Ticket #1645\n#\ndo_test in-10.1 {\n  execsql {\n    CREATE TABLE t5(\n      a INTEGER,\n      CHECK( a IN (111,222,333) )\n    );\n    INSERT INTO t5 VALUES(111);\n    SELECT * FROM t5;\n  }\n} {111}\ndo_test in-10.2 {\n  catchsql {\n    INSERT INTO t5 VALUES(4);\n  }\n} {1 {CHECK constraint failed: t5}}\n\n# Ticket #1821\n#\n# Type affinity applied to the right-hand side of an IN operator.\n#\ndo_test in-11.1 {\n  execsql {\n    CREATE TABLE t6(a,b NUMERIC);\n    INSERT INTO t6 VALUES(1,2);\n    INSERT INTO t6 VALUES(2,3);\n    SELECT * FROM t6 WHERE b IN (2);\n  }\n} {1 2}\ndo_test in-11.2 {\n  # The '2' should be coerced into 2 because t6.b is NUMERIC\n  execsql {\n    SELECT * FROM t6 WHERE b IN ('2');\n  }\n} {1 2}\ndo_test in-11.3 {\n  # No coercion should occur here because of the unary + before b.\n  execsql {\n    SELECT * FROM t6 WHERE +b IN ('2');\n  }\n} {}\ndo_test in-11.4 {\n  # No coercion because column a as affinity NONE\n  execsql {\n    SELECT * FROM t6 WHERE a IN ('2');\n  }\n} {}\ndo_test in-11.5 {\n  execsql {\n    SELECT * FROM t6 WHERE a IN (2);\n  }\n} {2 3}\ndo_test in-11.6 {\n  # No coercion because column a as affinity NONE\n  execsql {\n    SELECT * FROM t6 WHERE +a IN ('2');\n  }\n} {}\n\n# Test error conditions with expressions of the form IN(<compound select>).\n#\nifcapable compound {\ndo_test in-12.1 {\n  execsql {\n    CREATE TABLE t2(a, b, c);\n    CREATE TABLE t3(a, b, c);\n  }\n} {}\ndo_test in-12.2 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION ALL SELECT a, b FROM t2\n    );\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_test in-12.3 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION SELECT a, b FROM t2\n    );\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_test in-12.4 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 EXCEPT SELECT a, b FROM t2\n    );\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_test in-12.5 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 INTERSECT SELECT a, b FROM t2\n    );\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_test in-12.6 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION ALL SELECT a FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test in-12.7 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION SELECT a FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test in-12.8 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 EXCEPT SELECT a FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}\ndo_test in-12.9 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 INTERSECT SELECT a FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}\n}\n\nifcapable compound {\ndo_test in-12.10 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a FROM t3 UNION ALL SELECT a, b FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test in-12.11 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a FROM t3 UNION SELECT a, b FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test in-12.12 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a FROM t3 EXCEPT SELECT a, b FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}\ndo_test in-12.13 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a FROM t3 INTERSECT SELECT a, b FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}\ndo_test in-12.14 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION ALL SELECT a, b FROM t2\n    );\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_test in-12.15 {\n  catchsql {\n    SELECT * FROM t2 WHERE a IN (\n      SELECT a, b FROM t3 UNION ALL SELECT a FROM t2\n    );\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\n}; #ifcapable compound\n\n\n#------------------------------------------------------------------------\n# The following tests check that NULL is handled correctly when it \n# appears as part of a set of values on the right-hand side of an\n# IN or NOT IN operator.\n#\n# When it appears in such a set, NULL is handled as an \"unknown value\".\n# If, because of the unknown value in the set, the result of the expression \n# cannot be determined, then it itself evaluates to NULL.\n#\n\n# Warm body test to demonstrate the principles being tested:\n#\ndo_test in-13.1 {\n  db nullvalue \"null\"\n  execsql { SELECT \n    1 IN (NULL, 1, 2),     -- The value 1 is a member of the set, return true.\n    3 IN (NULL, 1, 2),     -- Ambiguous, return NULL.\n    1 NOT IN (NULL, 1, 2), -- The value 1 is a member of the set, return false.\n    3 NOT IN (NULL, 1, 2)  -- Ambiguous, return NULL.\n  }\n} {1 null 0 null}\n\ndo_test in-13.2 {\n  execsql { \n    CREATE TABLE t7(a, b, c NOT NULL);\n    INSERT INTO t7 VALUES(1,    1, 1);\n    INSERT INTO t7 VALUES(2,    2, 2);\n    INSERT INTO t7 VALUES(3,    3, 3);\n    INSERT INTO t7 VALUES(NULL, 4, 4);\n    INSERT INTO t7 VALUES(NULL, 5, 5);\n  }\n} {}\n\ndo_test in-13.3 {\n  execsql { SELECT 2 IN (SELECT a FROM t7) }\n} {1}\ndo_test in-13.4 {\n  execsql { SELECT 6 IN (SELECT a FROM t7) }\n} {null}\n\ndo_test in-13.5 {\n  execsql { SELECT 2 IN (SELECT b FROM t7) }\n} {1}\ndo_test in-13.6 {\n  execsql { SELECT 6 IN (SELECT b FROM t7) }\n} {0}\n\ndo_test in-13.7 {\n  execsql { SELECT 2 IN (SELECT c FROM t7) }\n} {1}\ndo_test in-13.8 {\n  execsql { SELECT 6 IN (SELECT c FROM t7) }\n} {0}\n\ndo_test in-13.9 {\n  execsql {\n    SELECT\n      2 NOT IN (SELECT a FROM t7),\n      6 NOT IN (SELECT a FROM t7),\n      2 NOT IN (SELECT b FROM t7),\n      6 NOT IN (SELECT b FROM t7),\n      2 NOT IN (SELECT c FROM t7),\n      6 NOT IN (SELECT c FROM t7)\n  } \n} {0 null 0 1 0 1}\n\ndo_test in-13.10 {\n  execsql { \n    SELECT b IN (\n      SELECT inside.a \n      FROM t7 AS inside \n      WHERE inside.b BETWEEN outside.b+1 AND outside.b+2\n    )\n    FROM t7 AS outside ORDER BY b;\n  }\n} {0 null null null 0}\n\ndo_test in-13.11 {\n  execsql {\n    SELECT b NOT IN (\n      SELECT inside.a \n      FROM t7 AS inside \n      WHERE inside.b BETWEEN outside.b+1 AND outside.b+2\n    )\n    FROM t7 AS outside ORDER BY b;\n  }\n} {1 null null null 1}\n\ndo_test in-13.12 {\n  execsql {\n    CREATE INDEX i1 ON t7(a);\n    CREATE INDEX i2 ON t7(b);\n    CREATE INDEX i3 ON t7(c);\n  }\n  execsql {\n    SELECT\n      2 IN (SELECT a FROM t7),\n      6 IN (SELECT a FROM t7),\n      2 IN (SELECT b FROM t7),\n      6 IN (SELECT b FROM t7),\n      2 IN (SELECT c FROM t7),\n      6 IN (SELECT c FROM t7)\n  } \n} {1 null 1 0 1 0}\n\ndo_test in-13.13 {\n  execsql {\n    SELECT\n      2 NOT IN (SELECT a FROM t7),\n      6 NOT IN (SELECT a FROM t7),\n      2 NOT IN (SELECT b FROM t7),\n      6 NOT IN (SELECT b FROM t7),\n      2 NOT IN (SELECT c FROM t7),\n      6 NOT IN (SELECT c FROM t7)\n  } \n} {0 null 0 1 0 1}\n\ndo_test in-13.14 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE a(id INTEGER);\n    INSERT INTO a VALUES(1);\n    INSERT INTO a VALUES(2);\n    INSERT INTO a VALUES(3);\n    CREATE TABLE b(id INTEGER);\n    INSERT INTO b VALUES(NULL);\n    INSERT INTO b VALUES(3);\n    INSERT INTO b VALUES(4);\n    INSERT INTO b VALUES(5);\n    COMMIT;\n    SELECT * FROM a WHERE id NOT IN (SELECT id FROM b);\n  }\n} {}\ndo_test in-13.14 {\n  execsql {\n    CREATE INDEX i5 ON b(id);\n    SELECT * FROM a WHERE id NOT IN (SELECT id FROM b);\n  }\n} {}\n\ndo_test in-13.15 {\n  catchsql {\n    SELECT 0 WHERE (SELECT 0,0) OR (0 IN (1,2));\n  }\n} {1 {sub-select returns 2 columns - expected 1}}\n\n\ndo_test in-13.X {\n  db nullvalue \"\"\n} {}\n\n# At one point the following was causing valgrind to report a \"jump\n# depends on unitialized location\" problem.\n#\ndo_execsql_test in-14.0 {\n  CREATE TABLE c1(a);\n  INSERT INTO c1 VALUES(1), (2), (4), (3);\n}\ndo_execsql_test in-14.1 {\n  SELECT * FROM c1 WHERE a IN (SELECT a FROM c1) ORDER BY 1\n} {1 2 3 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/in2.test",
    "content": "# 2007 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests a special case in the b-tree code that can be\n# hit by the \"IN\" operator (or EXISTS, NOT IN, etc.).\n#\n# $Id: in2.test,v 1.3 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test in2-1 {\n  execsql {\n    CREATE TABLE a(i INTEGER PRIMARY KEY, a);\n  }\n} {}\n\nset ::N 2000\n\ndo_test in2-2 {\n  db transaction {\n    for {set ::ii 0} {$::ii < $::N} {incr ::ii} {\n      execsql {INSERT INTO a VALUES($::ii, $::ii)}\n    }\n    execsql {INSERT INTO a VALUES(4000, '')}\n\n    for {set ::ii 0} {$::ii < $::N} {incr ::ii} {\n      set ::t [format \"x%04d\" $ii]\n      execsql {INSERT INTO a VALUES(NULL, $::t)}\n    }\n  }\n} {}\n\n# Each iteration of this loop builds a slightly different b-tree to\n# evaluate the \"IN (...)\" operator in the SQL statement. The contents\n# of the b-tree are (in sorted order):\n#\n#     $::ii integers.\n#     a string of zero length.\n#     $::N short strings.\n#\n# Records are inserted in sorted order.\n#\n# The string of zero-length is stored in a b-tree cell with 3 bytes\n# of payload. Moving this cell from a leaf node to a internal node \n# during b-tree balancing was causing an assertion failure. \n#\n# This bug only applied to b-trees generated to evaluate IN (..) \n# clauses, as it is impossible for persistent b-trees (SQL tables + \n# indices) to contain cells smaller than 4 bytes.\n#\nfor {set ::ii 3} {$::ii < $::N} {incr ::ii} {\n  do_test in2-$::ii {\n    execsql {\n      SELECT 1 IN (SELECT a FROM a WHERE (i < $::ii) OR (i >= $::N))\n    }\n  } {1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/in3.test",
    "content": "# 2007 November 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests the optimisations made in November 2007 of expressions \n# of the following form:\n#\n#     <value> IN (SELECT <column> FROM <table>)\n#\n# $Id: in3.test,v 1.5 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\n# Return the number of OpenEphemeral instructions used in the\n# implementation of the sql statement passed as a an argument.\n#\nproc nEphemeral {sql} {\n  set nEph 0\n  foreach op [execsql \"EXPLAIN $sql\"] {\n    if {$op eq \"OpenEphemeral\"} {incr nEph}\n  }\n  set nEph\n}\n\n# This proc works the same way as execsql, except that the number\n# of OpenEphemeral instructions used in the implementation of the\n# statement is inserted into the start of the returned list.\n#\nproc exec_neph {sql} {\n  return [concat [nEphemeral $sql] [execsql $sql]]\n}\n\ndo_test in3-1.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n  }\n} {}\n\n# All of these queries should avoid using a temp-table:\n#\ndo_test in3-1.2 {\n  exec_neph { SELECT rowid FROM t1 WHERE rowid IN (SELECT rowid FROM t1); }\n} {0 1 2 3}\ndo_test in3-1.3 {\n  exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1); }\n} {0 1 3 5}\ndo_test in3-1.4 {\n  exec_neph { SELECT rowid FROM t1 WHERE rowid+0 IN (SELECT rowid FROM t1); }\n} {0 1 2 3}\ndo_test in3-1.5 {\n  exec_neph { SELECT a FROM t1 WHERE a+0 IN (SELECT a FROM t1); }\n} {0 1 3 5}\n\n# Because none of the sub-select queries in the following statements\n# match the pattern (\"SELECT <column> FROM <table>\"), the following do \n# require a temp table.\n#\ndo_test in3-1.6 {\n  exec_neph { SELECT rowid FROM t1 WHERE rowid IN (SELECT rowid+0 FROM t1); }\n} {1 1 2 3}\ndo_test in3-1.7 {\n  exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a+0 FROM t1); }\n} {1 1 3 5}\ndo_test in3-1.8 {\n  exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 WHERE 1); }\n} {1 1 3 5}\ndo_test in3-1.9 {\n  exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 GROUP BY a); }\n} {1 1 3 5}\n\n# This should not use a temp-table. Even though the sub-select does\n# not exactly match the pattern \"SELECT <column> FROM <table>\", in\n# this case the ORDER BY is a no-op and can be ignored.\ndo_test in3-1.10 {\n  exec_neph { SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a); }\n} {0 1 3 5}\n\n# These do use the temp-table. Adding the LIMIT clause means the \n# ORDER BY cannot be ignored.\ndo_test in3-1.11 {\n  exec_neph {SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a LIMIT 1)}\n} {1 1}\ndo_test in3-1.12 {\n  exec_neph {\n    SELECT a FROM t1 WHERE a IN (SELECT a FROM t1 ORDER BY a LIMIT 1 OFFSET 1)\n  }\n} {1 3}\n\n# Has to use a temp-table because of the compound sub-select.\n#\nifcapable compound {\n  do_test in3-1.13 {\n    exec_neph {\n      SELECT a FROM t1 WHERE a IN (\n        SELECT a FROM t1 UNION ALL SELECT a FROM t1\n      )\n    }\n  } {1 1 3 5}\n}\n\n# The first of these queries has to use the temp-table, because the \n# collation sequence used for the index on \"t1.a\" does not match the\n# collation sequence used by the \"IN\" comparison. The second does not\n# require a temp-table, because the collation sequences match.\n#\ndo_test in3-1.14 {\n  exec_neph { SELECT a FROM t1 WHERE a COLLATE nocase IN (SELECT a FROM t1) }\n} {1 1 3 5}\ndo_test in3-1.15 {\n  exec_neph { SELECT a FROM t1 WHERE a COLLATE binary IN (SELECT a FROM t1) }\n} {0 1 3 5}\n\n# Neither of these queries require a temp-table. The collation sequence\n# makes no difference when using a rowid.\n#\ndo_test in3-1.16 {\n  exec_neph {SELECT a FROM t1 WHERE a COLLATE nocase IN (SELECT rowid FROM t1)}\n} {0 1 3}\ndo_test in3-1.17 {\n  exec_neph {SELECT a FROM t1 WHERE a COLLATE binary IN (SELECT rowid FROM t1)}\n} {0 1 3}\n\n# The following tests - in3.2.* - test a bug that was difficult to track\n# down during development. They are not particularly well focused.\n#\ndo_test in3-2.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(w int, x int, y int);\n    CREATE TABLE t2(p int, q int, r int, s int);\n  }\n  for {set i 1} {$i<=100} {incr i} {\n    set w $i\n    set x [expr {int(log($i)/log(2))}]\n    set y [expr {$i*$i + 2*$i + 1}]\n    execsql \"INSERT INTO t1 VALUES($w,$x,$y)\"\n  }\n  set maxy [execsql {select max(y) from t1}]\n  db eval { INSERT INTO t2 SELECT 101-w, x, $maxy+1-y, y FROM t1 }\n} {}\ndo_test in3-2.2 {\n  execsql {\n    SELECT rowid \n    FROM t1 \n    WHERE rowid IN (SELECT rowid FROM t1 WHERE rowid IN (1, 2));\n  }\n} {1 2}\ndo_test in3-2.3 {\n  execsql {\n    select rowid from t1 where rowid IN (-1,2,4)\n  }\n} {2 4}\ndo_test in3-2.4 {\n  execsql {\n    SELECT rowid FROM t1 WHERE rowid IN \n       (select rowid from t1 where rowid IN (-1,2,4))\n  }\n} {2 4}\n\n#-------------------------------------------------------------------------\n# This next block of tests - in3-3.* - verify that column affinity is\n# correctly handled in cases where an index might be used to optimise\n# an IN (SELECT) expression.\n#\ndo_test in3-3.1 {\n  catch {execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n  }}\n\n  execsql {\n\n    CREATE TABLE t1(a BLOB, b NUMBER ,c TEXT);\n    CREATE UNIQUE INDEX t1_i1 ON t1(a);        /* no affinity */\n    CREATE UNIQUE INDEX t1_i2 ON t1(b);        /* numeric affinity */\n    CREATE UNIQUE INDEX t1_i3 ON t1(c);        /* text affinity */\n\n    CREATE TABLE t2(x BLOB, y NUMBER, z TEXT);\n    CREATE UNIQUE INDEX t2_i1 ON t2(x);        /* no affinity */\n    CREATE UNIQUE INDEX t2_i2 ON t2(y);        /* numeric affinity */\n    CREATE UNIQUE INDEX t2_i3 ON t2(z);        /* text affinity */\n\n    INSERT INTO t1 VALUES(1, 1, 1);\n    INSERT INTO t2 VALUES('1', '1', '1');\n  }\n} {}\n\ndo_test in3-3.2 {\n  # No affinity is applied before comparing \"x\" and \"a\". Therefore\n  # the index can be used (the comparison is false, text!=number).\n  exec_neph { SELECT x IN (SELECT a FROM t1) FROM t2 }\n} {0 0}\ndo_test in3-3.3 {\n  # Logically, numeric affinity is applied to both sides before \n  # the comparison.  Therefore it is possible to use index t1_i2.\n  exec_neph { SELECT x IN (SELECT b FROM t1) FROM t2 }\n} {0 1}\ndo_test in3-3.4 {\n  # No affinity is applied before the comparison takes place. Making\n  # it possible to use index t1_i3.\n  exec_neph { SELECT x IN (SELECT c FROM t1) FROM t2 }\n} {0 1}\n\ndo_test in3-3.5 {\n  # Numeric affinity should be applied to each side before the comparison\n  # takes place. Therefore we cannot use index t1_i1, which has no affinity.\n  exec_neph { SELECT y IN (SELECT a FROM t1) FROM t2 }\n} {1 1}\ndo_test in3-3.6 {\n  # Numeric affinity is applied to both sides before \n  # the comparison.  Therefore it is possible to use index t1_i2.\n  exec_neph { SELECT y IN (SELECT b FROM t1) FROM t2 }\n} {0 1}\ndo_test in3-3.7 {\n  # Numeric affinity is applied before the comparison takes place. \n  # Making it impossible to use index t1_i3.\n  exec_neph { SELECT y IN (SELECT c FROM t1) FROM t2 }\n} {1 1}\n\n#---------------------------------------------------------------------\n#\n# Test using a multi-column index.\n#\ndo_test in3-4.1 {\n  execsql {\n    CREATE TABLE t3(a, b, c);\n    CREATE UNIQUE INDEX t3_i ON t3(b, a);\n  }\n\n  execsql {\n    INSERT INTO t3 VALUES(1, 'numeric', 2);\n    INSERT INTO t3 VALUES(2, 'text', 2);\n    INSERT INTO t3 VALUES(3, 'real', 2);\n    INSERT INTO t3 VALUES(4, 'none', 2);\n  }\n} {}\ndo_test in3-4.2 {\n  exec_neph { SELECT 'text' IN (SELECT b FROM t3) }\n} {0 1}\ndo_test in3-4.3 {\n  exec_neph { SELECT 'TEXT' COLLATE nocase IN (SELECT b FROM t3) }\n} {1 1}\ndo_test in3-4.4 {\n  # A temp table must be used because t3_i.b is not guaranteed to be unique.\n  exec_neph { SELECT b FROM t3 WHERE b IN (SELECT b FROM t3) }\n} {1 none numeric real text}\ndo_test in3-4.5 {\n  execsql { CREATE UNIQUE INDEX t3_i2 ON t3(b) }\n  exec_neph { SELECT b FROM t3 WHERE b IN (SELECT b FROM t3) }\n} {0 none numeric real text}\ndo_test in3-4.6 {\n  execsql { DROP INDEX t3_i2 }\n} {}\n\n# The following two test cases verify that ticket #2991 has been fixed.\n#\ndo_test in3-5.1 {\n  execsql {\n    CREATE TABLE Folders(\n      folderid INTEGER PRIMARY KEY, \n      parentid INTEGER, \n      rootid INTEGER, \n      path VARCHAR(255)\n    );\n  }\n} {}\ndo_test in3-5.2 {\n  catchsql {\n    DELETE FROM Folders WHERE folderid IN\n    (SELECT folderid FROM Folder WHERE path LIKE 'C:\\MP3\\Albums\\' || '%');\n  }\n} {1 {no such table: Folder}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/in4.test",
    "content": "# 2008 September 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: in4.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test in4-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a);\n  }\n} {}\ndo_test in4-1.2 {\n  execsql {\n    SELECT * FROM t1 WHERE a IN ('aaa', 'bbb', 'ccc');\n  }\n} {}\ndo_test in4-1.3 {\n  execsql {\n    INSERT INTO t1 VALUES('aaa', 1);\n    INSERT INTO t1 VALUES('ddd', 2);\n    INSERT INTO t1 VALUES('ccc', 3);\n    INSERT INTO t1 VALUES('eee', 4);\n    SELECT b FROM t1 WHERE a IN ('aaa', 'bbb', 'ccc');\n  }\n} {1 3}\ndo_test in4-1.4 {\n  execsql {\n    SELECT a FROM t1 WHERE rowid IN (1, 3);\n  }\n} {aaa ccc}\ndo_test in4-1.5 {\n  execsql {\n    SELECT a FROM t1 WHERE rowid IN ();\n  }\n} {}\ndo_test in4-1.6 {\n  execsql {\n    SELECT a FROM t1 WHERE a IN ('ddd');\n  }\n} {ddd}\n\ndo_test in4-2.1 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t2 VALUES(-1, '-one');\n    INSERT INTO t2 VALUES(0, 'zero');\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(2, 'two');\n    INSERT INTO t2 VALUES(3, 'three');\n  }\n} {}\n\ndo_test in4-2.2 {\n  execsql { SELECT b FROM t2 WHERE a IN (0, 2) }\n} {zero two}\n\ndo_test in4-2.3 {\n  execsql { SELECT b FROM t2 WHERE a IN (2, 0) }\n} {zero two}\n\ndo_test in4-2.4 {\n  execsql { SELECT b FROM t2 WHERE a IN (2, -1) }\n} {-one two}\n\ndo_test in4-2.5 {\n  execsql { SELECT b FROM t2 WHERE a IN (NULL, 3) }\n} {three}\n\ndo_test in4-2.6 {\n  execsql { SELECT b FROM t2 WHERE a IN (1.0, 2.1) }\n} {one}\n\ndo_test in4-2.7 {\n  execsql { SELECT b FROM t2 WHERE a IN ('1', '2') }\n} {one two}\n\ndo_test in4-2.8 {\n  execsql { SELECT b FROM t2 WHERE a IN ('', '0.0.0', '2') }\n} {two}\n\n# The following block of tests test expressions of the form:\n#\n#    <expr> IN ()\n#\n# i.e. IN expressions with a literal empty set. \n# \n# This has led to crashes on more than one occasion. Test case in4-3.2 \n# was added in reponse to a bug reported on the mailing list on 11/7/2008.\n# See also tickets #3602 and #185.\n#\ndo_test in4-3.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(x, id);\n    CREATE TABLE t2(x, id);\n    INSERT INTO t1 VALUES(NULL, NULL);\n    INSERT INTO t1 VALUES(0, NULL);\n    INSERT INTO t1 VALUES(1, 3);\n    INSERT INTO t1 VALUES(2, 4);\n    INSERT INTO t1 VALUES(3, 5);\n    INSERT INTO t1 VALUES(4, 6);\n    INSERT INTO t2 VALUES(0, NULL);\n    INSERT INTO t2 VALUES(4, 1);\n    INSERT INTO t2 VALUES(NULL, 1);\n    INSERT INTO t2 VALUES(NULL, NULL);\n  }\n} {}\ndo_test in4-3.2 {\n  execsql {\n    SELECT x FROM t1 WHERE id IN () AND x IN (SELECT x FROM t2 WHERE id=1)\n  }\n} {}\ndo_test in4-3.3 {\n  execsql {\n    CREATE TABLE t3(x, y, z);\n    CREATE INDEX t3i1 ON t3(x, y);\n    INSERT INTO t3 VALUES(1, 1, 1);\n    INSERT INTO t3 VALUES(10, 10, 10);\n  }\n  execsql { SELECT * FROM t3 WHERE x IN () }\n} {}\ndo_test in4-3.4 {\n  execsql { SELECT * FROM t3 WHERE x = 10 AND y IN () }\n} {}\ndo_test in4-3.5 {\n  execsql { SELECT * FROM t3 WHERE x IN () AND y = 10 }\n} {}\ndo_test in4-3.6 {\n  execsql { SELECT * FROM t3 WHERE x IN () OR x = 10 }\n} {10 10 10}\ndo_test in4-3.7 {\n  execsql { SELECT * FROM t3 WHERE y IN () }\n} {}\ndo_test in4-3.8 {\n  execsql { SELECT x IN() AS a FROM t3 WHERE a }\n} {}\ndo_test in4-3.9 {\n  execsql { SELECT x IN() AS a FROM t3 WHERE NOT a }\n} {0 0}\ndo_test in4-3.10 {\n  execsql { SELECT * FROM t3 WHERE oid IN () }\n} {}\ndo_test in4-3.11 {\n  execsql { SELECT * FROM t3 WHERE x IN (1, 2) OR y IN ()}\n} {1 1 1}\ndo_test in4-3.12 {\n  execsql { SELECT * FROM t3 WHERE x IN (1, 2) AND y IN ()}\n} {}\n\n# Tests for \"... IN (?)\" and \"... NOT IN (?)\".  In other words, tests\n# for when the RHS of IN is a single expression.  This should work the\n# same as the == and <> operators.\n#\ndo_execsql_test in4-3.21 {\n  SELECT * FROM t3 WHERE x=10 AND y IN (10);\n} {10 10 10}\ndo_execsql_test in4-3.22 {\n  SELECT * FROM t3 WHERE x IN (10) AND y=10;\n} {10 10 10}\ndo_execsql_test in4-3.23 {\n  SELECT * FROM t3 WHERE x IN (10) AND y IN (10);\n} {10 10 10}\ndo_execsql_test in4-3.24 {\n  SELECT * FROM t3 WHERE x=1 AND y NOT IN (10);\n} {1 1 1}\ndo_execsql_test in4-3.25 {\n  SELECT * FROM t3 WHERE x  NOT IN (10) AND y=1;\n} {1 1 1}\ndo_execsql_test in4-3.26 {\n  SELECT * FROM t3 WHERE x NOT IN (10) AND y NOT IN (10);\n} {1 1 1}\n\n# The query planner recognizes that \"x IN (?)\" only generates a\n# single match and can use this information to optimize-out ORDER BY\n# clauses.\n#\ndo_execsql_test in4-3.31 {\n  DROP INDEX t3i1;\n  CREATE UNIQUE INDEX t3xy ON t3(x,y);\n\n  SELECT *, '|' FROM t3 A, t3 B\n   WHERE A.x=10 AND A.y IN (10)\n     AND B.x=1 AND B.y IN (1);\n} {10 10 10 1 1 1 |}\ndo_execsql_test in4-3.32 {\n  EXPLAIN QUERY PLAN\n  SELECT *, '|' FROM t3 A, t3 B\n   WHERE A.x=10 AND A.y IN (10)\n     AND B.x=1 AND B.y IN (1);\n} {~/B-TREE/}  ;# No separate sorting pass\ndo_execsql_test in4-3.33 {\n  SELECT *, '|' FROM t3 A, t3 B\n   WHERE A.x IN (10) AND A.y=10\n     AND B.x IN (1) AND B.y=1;\n} {10 10 10 1 1 1 |}\ndo_execsql_test in4-3.34 {\n  EXPLAIN QUERY PLAN\n  SELECT *, '|' FROM t3 A, t3 B\n   WHERE A.x IN (10) AND A.y=10\n     AND B.x IN (1) AND B.y=1;\n} {~/B-TREE/}  ;# No separate sorting pass\n\n# An expression of the form \"x IN (?,?)\" creates an ephemeral table to\n# hold the list of values on the RHS.  But \"x IN (?)\" does not create\n# an ephemeral table.\n#\ndo_execsql_test in4-3.41 {\n  SELECT * FROM t3 WHERE x IN (10,11);\n} {10 10 10}\ndo_execsql_test in4-3.42 {\n  EXPLAIN\n  SELECT * FROM t3 WHERE x IN (10,11);\n} {/OpenEphemeral/}\ndo_execsql_test in4-3.43 {\n  SELECT * FROM t3 WHERE x IN (10);\n} {10 10 10}\ndo_execsql_test in4-3.44 {\n  EXPLAIN\n  SELECT * FROM t3 WHERE x IN (10);\n} {~/OpenEphemeral/}\ndo_execsql_test in4-3.45 {\n  SELECT * FROM t3 WHERE x NOT IN (10,11,99999);\n} {1 1 1}\ndo_execsql_test in4-3.46 {\n  EXPLAIN\n  SELECT * FROM t3 WHERE x NOT IN (10,11,99999);\n} {/OpenEphemeral/}\ndo_execsql_test in4-3.47 {\n  SELECT * FROM t3 WHERE x NOT IN (10);\n} {1 1 1}\ndo_execsql_test in4-3.48 {\n  EXPLAIN\n  SELECT * FROM t3 WHERE x NOT IN (10);\n} {~/OpenEphemeral/}\n\n# Make sure that when \"x IN (?)\" is converted into \"x==?\" that collating\n# sequence and affinity computations do not get messed up.\n#\ndo_execsql_test in4-4.1 {\n  CREATE TABLE t4a(a TEXT, b TEXT COLLATE nocase, c);\n  INSERT INTO t4a VALUES('ABC','abc',1);\n  INSERT INTO t4a VALUES('def','xyz',2);\n  INSERT INTO t4a VALUES('ghi','ghi',3);\n  SELECT c FROM t4a WHERE a=b ORDER BY c;\n} {3}\ndo_execsql_test in4-4.2 {\n  SELECT c FROM t4a WHERE b=a ORDER BY c;\n} {1 3}\ndo_execsql_test in4-4.3 {\n  SELECT c FROM t4a WHERE (a||'')=b ORDER BY c;\n} {1 3}\ndo_execsql_test in4-4.4 {\n  SELECT c FROM t4a WHERE (a||'')=(b||'') ORDER BY c;\n} {3}\ndo_execsql_test in4-4.5 {\n  SELECT c FROM t4a WHERE a IN (b) ORDER BY c;\n} {3}\ndo_execsql_test in4-4.6 {\n  SELECT c FROM t4a WHERE (a||'') IN (b) ORDER BY c;\n} {3}\n\n\ndo_execsql_test in4-4.11 {\n  CREATE TABLE t4b(a TEXT, b NUMERIC, c);\n  INSERT INTO t4b VALUES('1.0',1,4);\n  SELECT c FROM t4b WHERE a=b;\n} {4}\ndo_execsql_test in4-4.12 {\n  SELECT c FROM t4b WHERE b=a;\n} {4}\ndo_execsql_test in4-4.13 {\n  SELECT c FROM t4b WHERE +a=b;\n} {4}\ndo_execsql_test in4-4.14 {\n  SELECT c FROM t4b WHERE a=+b;\n} {}\ndo_execsql_test in4-4.15 {\n  SELECT c FROM t4b WHERE +b=a;\n} {}\ndo_execsql_test in4-4.16 {\n  SELECT c FROM t4b WHERE b=+a;\n} {4}\ndo_execsql_test in4-4.17 {\n  SELECT c FROM t4b WHERE a IN (b);\n} {}\ndo_execsql_test in4-4.18 {\n  SELECT c FROM t4b WHERE b IN (a);\n} {4}\ndo_execsql_test in4-4.19 {\n  SELECT c FROM t4b WHERE +b IN (a);\n} {}\n\ndo_execsql_test in4-5.1 {\n  CREATE TABLE t5(c INTEGER PRIMARY KEY, d TEXT COLLATE nocase);\n  INSERT INTO t5 VALUES(17, 'fuzz');\n  SELECT 1 FROM t5 WHERE 'fuzz' IN (d);  -- match\n  SELECT 2 FROM t5 WHERE 'FUZZ' IN (d);  -- no match\n  SELECT 3 FROM t5 WHERE d IN ('fuzz');  -- match\n  SELECT 4 FROM t5 WHERE d IN ('FUZZ');  -- match\n} {1 3 4}\n\n# An expression of the form \"x IN (y)\" can be used as \"x=y\" by the\n# query planner when computing transitive constraints or to run the\n# query using an index on y.\n#\ndo_execsql_test in4-6.1 {\n  CREATE TABLE t6a(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t6a VALUES(1,2),(3,4),(5,6);\n  CREATE TABLE t6b(c INTEGER PRIMARY KEY, d);\n  INSERT INTO t6b VALUES(4,44),(5,55),(6,66);\n\n  SELECT * FROM t6a, t6b WHERE a=3 AND b IN (c);\n} {3 4 4 44}\ndo_execsql_test in4-6.1-eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t6a, t6b WHERE a=3 AND b IN (c);\n} {~/SCAN/}\ndo_execsql_test in4-6.2 {\n  SELECT * FROM t6a, t6b WHERE a=3 AND c IN (b);\n} {3 4 4 44}\ndo_execsql_test in4-6.2-eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t6a, t6b WHERE a=3 AND c IN (b);\n} {~/SCAN/}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/in5.test",
    "content": "# 2012 September 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix in5\n\ndo_test in5-1.1 {\n  execsql {\n    CREATE TABLE t1x(x INTEGER PRIMARY KEY);\n    INSERT INTO t1x VALUES(1),(3),(5),(7),(9);\n    CREATE TABLE t1y(y INTEGER UNIQUE);\n    INSERT INTO t1y VALUES(2),(4),(6),(8);\n    CREATE TABLE t1z(z TEXT UNIQUE);\n    INSERT INTO t1z VALUES('a'),('c'),('e'),('g');\n    CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT, d TEXT);\n    INSERT INTO t2 VALUES(1,2,'a','12a'),(1,2,'b','12b'),\n                         (2,3,'g','23g'),(3,5,'c','35c'),\n                         (4,6,'h','46h'),(5,6,'e','56e');\n    CREATE TABLE t3x AS SELECT x FROM t1x;\n    CREATE TABLE t3y AS SELECT y FROM t1y;\n    CREATE TABLE t3z AS SELECT z FROM t1z;\n    SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY c;\n  }\n} {12a 56e}\ndo_test in5-1.2 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;\n  }\n} {23g}\ndo_test in5-1.3 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t3x AND b IN t3y AND c IN t3z ORDER BY d;\n  }\n} {12a 56e}\n\n\ndo_test in5-2.1 {\n  execsql {\n    CREATE INDEX t2abc ON t2(a,b,c);\n    SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;\n  }\n} {12a 56e}\ndo_test in5-2.2 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;\n  }\n} {23g}\ndo_test in5-2.3 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z\n  }]\n} {0}\ndo_test in5-2.4 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t3x AND b IN t3y AND c IN t3z ORDER BY d;\n  }\n} {12a 56e}\ndo_test in5-2.5.1 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t3x AND b IN t1y AND c IN t1z\n  }]\n} {1}\ndo_test in5-2.5.2 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t3y AND c IN t1z\n  }]\n} {1}\ndo_test in5-2.5.3 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t3z\n  }]\n} {1}\n\ndo_test in5-3.1 {\n  execsql {\n    DROP INDEX t2abc;\n    CREATE INDEX t2ab ON t2(a,b);\n    SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;\n  }\n} {12a 56e}\ndo_test in5-3.2 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;\n  }\n} {23g}\ndo_test in5-3.3 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z\n  }]\n} {0}\n\ndo_test in5-4.1 {\n  execsql {\n    DROP INDEX t2ab;\n    CREATE INDEX t2abcd ON t2(a,b,c,d);\n    SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;\n  }\n} {12a 56e}\ndo_test in5-4.2 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;\n  }\n} {23g}\ndo_test in5-4.3 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z\n  }]\n} {0}\n\n\ndo_test in5-5.1 {\n  execsql {\n    DROP INDEX t2abcd;\n    CREATE INDEX t2cbad ON t2(c,b,a,d);\n    SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z ORDER BY d;\n  }\n} {12a 56e}\ndo_test in5-5.2 {\n  execsql {\n    SELECT d FROM t2 WHERE a IN t1y AND b IN t1x AND c IN t1z ORDER BY d;\n  }\n} {23g}\ndo_test in5-5.3 {\n  regexp {OpenEphemeral} [db eval {\n    EXPLAIN SELECT d FROM t2 WHERE a IN t1x AND b IN t1y AND c IN t1z\n  }]\n} {0}\n\n#-------------------------------------------------------------------------\n# At one point SQLite was removing the DISTINCT keyword from expressions\n# similar to:\n#\n#   <expr1> IN (SELECT DISTINCT <expr2> FROM...)\n#\n# However, there are a few obscure cases where this is incorrect. For\n# example, if the SELECT features a LIMIT clause, or if the collation\n# sequence or affinity used by the DISTINCT does not match the one used\n# by the IN(...) expression.\n#\ndo_execsql_test 6.1.1 {\n  CREATE TABLE t1(a COLLATE nocase);\n  INSERT INTO t1 VALUES('one');\n  INSERT INTO t1 VALUES('ONE');\n}\ndo_execsql_test 6.1.2 {\n  SELECT count(*) FROM t1 WHERE a COLLATE BINARY IN (SELECT DISTINCT a FROM t1)\n} {1}\n\ndo_execsql_test 6.2.1 {\n  CREATE TABLE t3(a, b);\n  INSERT INTO t3 VALUES(1, 1);\n  INSERT INTO t3 VALUES(1, 2);\n  INSERT INTO t3 VALUES(1, 3);\n  INSERT INTO t3 VALUES(2, 4);\n  INSERT INTO t3 VALUES(2, 5);\n  INSERT INTO t3 VALUES(2, 6);\n  INSERT INTO t3 VALUES(3, 7);\n  INSERT INTO t3 VALUES(3, 8);\n  INSERT INTO t3 VALUES(3, 9);\n}\ndo_execsql_test 6.2.2 {\n  SELECT count(*) FROM t3 WHERE b IN (SELECT DISTINCT a FROM t3 LIMIT 5);\n} {3}\ndo_execsql_test 6.2.3 {\n  SELECT count(*) FROM t3 WHERE b IN (SELECT          a FROM t3 LIMIT 5);\n} {2}\n\ndo_execsql_test 6.3.1 {\n  CREATE TABLE x1(a);\n  CREATE TABLE x2(b);\n  INSERT INTO x1 VALUES(1), (1), (2);\n  INSERT INTO x2 VALUES(1), (2);\n  SELECT count(*) FROM x2 WHERE b IN (SELECT DISTINCT a FROM x1 LIMIT 2);\n} {2}\n\n#-------------------------------------------------------------------------\n# Test to confirm that bug [5e3c886796e5] is fixed.\n#\ndo_execsql_test 7.1 {\n  CREATE TABLE y1(a, b);\n  CREATE TABLE y2(c);\n\n  INSERT INTO y1 VALUES(1,     'one');\n  INSERT INTO y1 VALUES('two', 'two');\n  INSERT INTO y1 VALUES(3,     'three');\n\n  INSERT INTO y2 VALUES('one');\n  INSERT INTO y2 VALUES('two');\n  INSERT INTO y2 VALUES('three');\n} {}\n\ndo_execsql_test 7.2.1 {\n  SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);\n} {1 3}\ndo_execsql_test 7.2.2 {\n  SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);\n} {two}\n\ndo_execsql_test 7.3.1 {\n  CREATE INDEX y2c ON y2(c);\n  SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);\n} {1 3}\ndo_execsql_test 7.3.2 {\n  SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);\n} {two}\n\n#-------------------------------------------------------------------------\n# Tests to confirm that indexes on the rowid column do not confuse\n# the query planner. See ticket [0eab1ac7591f511d].\n#\ndo_execsql_test 8.0 {\n  CREATE TABLE n1(a INTEGER PRIMARY KEY, b VARCHAR(500));\n  CREATE UNIQUE INDEX n1a ON n1(a);\n}\n\ndo_execsql_test 8.1 {\n  SELECT count(*) FROM n1 WHERE a IN (1, 2, 3)\n} 0\ndo_execsql_test 8.2 {\n  SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)\n} 0\ndo_execsql_test 8.3 {\n  INSERT INTO n1 VALUES(1, NULL), (2, NULL), (3, NULL);\n  SELECT count(*) FROM n1 WHERE a IN (1, 2, 3)\n} 3\ndo_execsql_test 8.4 {\n  SELECT count(*) FROM n1 WHERE a IN (SELECT +a FROM n1)\n} 3\n\n#-------------------------------------------------------------------------\n# Test that ticket 61fe97454c is fixed.\n#\ndo_execsql_test 9.0 {\n  CREATE TABLE t9(a INTEGER PRIMARY KEY);\n  INSERT INTO t9 VALUES (44), (45);\n}\ndo_execsql_test 9.1 {\n  SELECT * FROM t9 WHERE a IN (44, 45, 44, 45)\n} {44 45}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblob.test",
    "content": "# 2007 May 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: incrblob.test,v 1.24 2009/06/19 22:23:42 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!autovacuum || !pragma || !incrblob} {\n  finish_test\n  return\n}\n\ndo_test incrblob-1.1 {\n  execsql {\n    CREATE TABLE blobs(k PRIMARY KEY, v BLOB);\n    INSERT INTO blobs VALUES('one', X'0102030405060708090A');\n    INSERT INTO blobs VALUES('two', X'0A090807060504030201');\n  }\n} {}\n\ndo_test incrblob-1.2.1 {\n  set ::blob [db incrblob blobs v 1]\n  string match incrblob_* $::blob\n} {1}\nunset -nocomplain data\ndo_test incrblob-1.2.2 {\n  binary scan [read $::blob] c* data\n  set data\n} {1 2 3 4 5 6 7 8 9 10}\ndo_test incrblob-1.2.3 {\n  seek $::blob 0\n  puts -nonewline $::blob \"1234567890\"\n  flush $::blob\n} {}\ndo_test incrblob-1.2.4 {\n  seek $::blob 0\n  binary scan [read $::blob] c* data\n  set data\n} {49 50 51 52 53 54 55 56 57 48}\ndo_test incrblob-1.2.5 {\n  close $::blob\n} {}\ndo_test incrblob-1.2.6 {\n  execsql {\n    SELECT v FROM blobs WHERE rowid = 1;\n  }\n} {1234567890}\n\n#--------------------------------------------------------------------\n# Test cases incrblob-1.3.X check that it is possible to read and write\n# regions of a blob that lie on overflow pages.\n#\ndo_test incrblob-1.3.1 {\n  set ::str \"[string repeat . 10000]\"\n  execsql {\n    INSERT INTO blobs(rowid, k, v) VALUES(3, 'three', $::str);\n  }\n} {}\n\ndo_test incrblob-1.3.2 {\n  set ::blob [db incrblob blobs v 3]\n  seek $::blob 8500\n  read $::blob 10\n} {..........}\ndo_test incrblob-1.3.3 {\n  seek $::blob 8500\n  puts -nonewline $::blob 1234567890\n} {}\ndo_test incrblob-1.3.4 {\n  seek $::blob 8496\n  read $::blob 10\n} {....123456}\ndo_test incrblob-1.3.10 {\n  close $::blob\n} {}\n\n#------------------------------------------------------------------------\n# incrblob-2.*: \n#\n# Test that the following operations use ptrmap pages to reduce\n# unnecessary reads:\n#\n#     * Reading near the end of a blob,\n#     * Writing near the end of a blob, and\n#     * SELECT a column value that is located on an overflow page.\n#\nproc nRead {db} {\n  set bt [btree_from_db $db]\n  db_enter $db\n  array set stats [btree_pager_stats $bt]\n  db_leave $db\n  return $stats(read)\n}\nproc nWrite {db} {\n  set bt [btree_from_db $db]\n  db_enter $db\n  array set stats [btree_pager_stats $bt]\n  db_leave $db\n  return $stats(write)\n}\n\nsqlite3_soft_heap_limit 0\n\nforeach AutoVacuumMode [list 0 1] {\n\n  if {$AutoVacuumMode>0} {\n    ifcapable !autovacuum {\n      break\n    }\n  }\n\n  db close\n  forcedelete test.db test.db-journal\n\n  sqlite3 db test.db\n  execsql \"PRAGMA mmap_size = 0\"\n  execsql \"PRAGMA auto_vacuum = $AutoVacuumMode\"\n\n  # Extra value added to size answers\n  set ib2_extra 0\n  if {$AutoVacuumMode} {incr ib2_extra}\n  if {[nonzero_reserved_bytes]} {incr ib2_extra}\n\n  do_test incrblob-2.$AutoVacuumMode.1 {\n    set ::str [string repeat abcdefghij 2900]\n    execsql {\n      BEGIN;\n      CREATE TABLE blobs(k PRIMARY KEY, v BLOB, i INTEGER);\n      DELETE FROM blobs;\n      INSERT INTO blobs VALUES('one', $::str || randstr(500,500), 45);\n      COMMIT;\n    }\n    expr [file size test.db]/1024\n  } [expr 31 + $ib2_extra]\n\n  ifcapable autovacuum {\n    do_test incrblob-2.$AutoVacuumMode.2 {\n      execsql {\n        PRAGMA auto_vacuum;\n      }\n    } $AutoVacuumMode\n  }\n\n  do_test incrblob-2.$AutoVacuumMode.3 {\n    # Open and close the db to make sure the page cache is empty.\n    db close\n    sqlite3 db test.db\n    execsql \"PRAGMA mmap_size = 0\"\n  \n    # Read the last 20 bytes of the blob via a blob handle.\n    set ::blob [db incrblob blobs v 1]\n    seek $::blob -20 end\n    set ::fragment [read $::blob]\n    close $::blob\n  \n    # If the database is not in auto-vacuum mode, the whole of\n    # the overflow-chain must be scanned. In auto-vacuum mode,\n    # sqlite uses the ptrmap pages to avoid reading the other pages.\n    #\n    nRead db\n  } [expr $AutoVacuumMode ? 4 : 30+$ib2_extra]\n\n  do_test incrblob-2.$AutoVacuumMode.4 {\n    string range [db one {SELECT v FROM blobs}] end-19 end\n  } $::fragment\n\n  do_test incrblob-2.$AutoVacuumMode.5 {\n    # Open and close the db to make sure the page cache is empty.\n    db close\n    sqlite3 db test.db\n    execsql \"PRAGMA mmap_size = 0\"\n  \n    # Write the second-to-last 20 bytes of the blob via a blob handle.\n    #\n    set ::blob [db incrblob blobs v 1]\n    seek $::blob -40 end\n    puts -nonewline $::blob \"1234567890abcdefghij\"\n    flush $::blob\n  \n    # If the database is not in auto-vacuum mode, the whole of\n    # the overflow-chain must be scanned. In auto-vacuum mode,\n    # sqlite uses the ptrmap pages to avoid reading the other pages.\n    #\n    nRead db\n  } [expr $AutoVacuumMode ? 4 : 30 + $ib2_extra]\n\n  # Pages 1 (the write-counter) and 32 (the blob data) were written.\n  do_test incrblob-2.$AutoVacuumMode.6 {\n    close $::blob\n    nWrite db\n  } 2\n\n  do_test incrblob-2.$AutoVacuumMode.7 {\n    string range [db one {SELECT v FROM blobs}] end-39 end-20\n  } \"1234567890abcdefghij\"\n\n  do_test incrblob-2.$AutoVacuumMode.8 {\n    # Open and close the db to make sure the page cache is empty.\n    db close\n    sqlite3 db test.db\n    execsql { PRAGMA mmap_size = 0 }\n\n    execsql { SELECT i FROM blobs } \n  } {45}\n\n  do_test incrblob-2.$AutoVacuumMode.9 {\n    nRead db\n  } [expr $AutoVacuumMode ? 4 : 30 + $ib2_extra]\n}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\n#------------------------------------------------------------------------\n# incrblob-3.*: \n#\n# Test the outcome of trying to write to a read-only blob handle.\n#\ndo_test incrblob-3.1 {\n  set ::blob [db incrblob -readonly blobs v 1]\n  seek $::blob -40 end\n  read $::blob 20\n} \"1234567890abcdefghij\"\ndo_test incrblob-3.2 {\n  seek $::blob 0\n  set rc [catch {\n    puts -nonewline $::blob \"helloworld\"\n  } msg]\n  close $::blob\n  list $rc $msg\n} \"1 {channel \\\"$::blob\\\" wasn't opened for writing}\"\n\ndo_test incrblob-3.3 {\n  set ::blob [db incrblob -readonly blobs v 1]\n  seek $::blob -40 end\n  read $::blob 20\n} \"1234567890abcdefghij\"\ndo_test incrblob-3.4 {\n  set rc [catch {\n    sqlite3_blob_write $::blob 20 \"qwertyuioplkjhgfds\" \n  } msg]\n  list $rc $msg\n} {1 SQLITE_READONLY}\ncatch {close $::blob}\n\n#------------------------------------------------------------------------\n# incrblob-4.*: \n#\n# Try a couple of error conditions:\n#\n#     4.1 - Attempt to open a row that does not exist.\n#     4.2 - Attempt to open a column that does not exist.\n#     4.3 - Attempt to open a table that does not exist.\n#     4.4 - Attempt to open a database that does not exist.\n#\n#     4.5 - Attempt to open an integer\n#     4.6 - Attempt to open a real value\n#     4.7 - Attempt to open an SQL null\n#\n#     4.8 - Attempt to open an indexed column for writing\n#     4.9 - Attempt to open an indexed column for reading (this works)\n#\n#     4.11 - Attempt to open a column of a view.\n#     4.12 - Attempt to open a column of a virtual table.\n#\ndo_test incrblob-4.1 {\n  set rc [catch {\n    set ::blob [db incrblob blobs v 2]\n  } msg ] \n  list $rc $msg\n} {1 {no such rowid: 2}}\ndo_test incrblob-4.2 {\n  set rc [catch {\n    set ::blob [db incrblob blobs blue 1]\n  } msg ] \n  list $rc $msg\n} {1 {no such column: \"blue\"}}\ndo_test incrblob-4.3 {\n  set rc [catch {\n    set ::blob [db incrblob nosuchtable blue 1]\n  } msg ]\n  list $rc $msg\n} {1 {no such table: main.nosuchtable}}\ndo_test incrblob-4.4 {\n  set rc [catch {\n    set ::blob [db incrblob nosuchdb blobs v 1]\n  } msg ] \n  list $rc $msg\n} {1 {no such table: nosuchdb.blobs}}\n\ndo_test incrblob-4.5 {\n  set rc [catch {\n    set ::blob [db incrblob blobs i 1]\n  } msg ] \n  list $rc $msg\n} {1 {cannot open value of type integer}}\ndo_test incrblob-4.6 {\n  execsql {\n    INSERT INTO blobs(k, v, i) VALUES(123, 567.765, NULL);\n  }\n  set rc [catch {\n    set ::blob [db incrblob blobs v 2]\n  } msg ] \n  list $rc $msg\n} {1 {cannot open value of type real}}\ndo_test incrblob-4.7 {\n  set rc [catch {\n    set ::blob [db incrblob blobs i 2]\n  } msg ] \n  list $rc $msg\n} {1 {cannot open value of type null}}\n\ndo_test incrblob-4.8.1 {\n  execsql {\n    INSERT INTO blobs(k, v, i) VALUES(X'010203040506070809', 'hello', 'world');\n  }\n  set rc [catch {\n    set ::blob [db incrblob blobs k 3]\n  } msg ] \n  list $rc $msg\n} {1 {cannot open indexed column for writing}}\ndo_test incrblob-4.8.2 {\n  execsql {\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t3 VALUES(1, 2);\n  }\n  set rc [catch {\n    set ::blob [db incrblob -readonly t3 a 1]\n  } msg ] \n  list $rc $msg\n} {1 {cannot open value of type null}}\ndo_test incrblob-4.8.3 {\n  set rc [catch {\n    set ::blob [db incrblob -readonly t3 rowid 1]\n  } msg ] \n  list $rc $msg\n} {1 {no such column: \"rowid\"}}\n\ndo_test incrblob-4.9.1 {\n  set rc [catch {\n    set ::blob [db incrblob -readonly blobs k 3]\n  } msg]\n} {0}\ndo_test incrblob-4.9.2 {\n  binary scan [read $::blob] c* c\n  close $::blob\n  set c\n} {1 2 3 4 5 6 7 8 9}\n\ndo_test incrblob-4.10 {\n  set ::blob [db incrblob -readonly blobs k 3]\n  set rc [catch { sqlite3_blob_read $::blob 10 100 } msg]\n  list $rc $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob-4.10.2 {\n  close $::blob\n} {}\n\nifcapable view {\n  do_test incrblob-4.11 {\n    execsql { CREATE VIEW blobs_view AS SELECT k, v, i FROM blobs }\n    set rc [catch { db incrblob blobs_view v 3 } msg]\n    list $rc $msg\n  } {1 {cannot open view: blobs_view}}\n}\nifcapable vtab {\n  register_echo_module [sqlite3_connection_pointer db]\n  do_test incrblob-4.12 {\n    execsql { CREATE VIRTUAL TABLE blobs_echo USING echo(blobs) }\n    set rc [catch { db incrblob blobs_echo v 3 } msg]\n    list $rc $msg\n  } {1 {cannot open virtual table: blobs_echo}}\n}\n\n\n#------------------------------------------------------------------------\n# incrblob-5.*: \n#\n#     Test that opening a blob in an attached database works.\n#\nifcapable attach {\n  do_test incrblob-5.1 {\n    forcedelete test2.db test2.db-journal\n    set ::size [expr [file size $::cmdlinearg(INFO_SCRIPT)]]\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.files(name, text);\n      INSERT INTO aux.files VALUES('this one', zeroblob($::size));\n    }\n    set fd  [db incrblob aux files text 1]\n    fconfigure $fd -translation binary\n    set fd2 [open $::cmdlinearg(INFO_SCRIPT)]\n    fconfigure $fd2 -translation binary\n    puts -nonewline $fd [read $fd2]\n    close $fd\n    close $fd2\n    set ::text [db one {select text from aux.files}]\n    string length $::text\n  } [file size $::cmdlinearg(INFO_SCRIPT)]\n  do_test incrblob-5.2 {\n    set fd2 [open $::cmdlinearg(INFO_SCRIPT)]\n    fconfigure $fd2 -translation binary\n    set ::data [read $fd2]\n    close $fd2\n    set ::data\n  } $::text\n}\n\n# free memory\nunset -nocomplain ::data\nunset -nocomplain ::text\n\n#------------------------------------------------------------------------\n# incrblob-6.*: \n#\n#     Test that opening a blob for write-access is impossible if\n#     another connection has the database RESERVED lock.\n#\n#     Then test that blob writes that take place inside of a\n#     transaction are not visible to external connections until\n#     after the transaction is commited and the blob channel \n#     closed.\n#\n#     This test does not work with the \"memsubsys1\" configuration.\n#     Permutation memsubsys1 configures a very small static allocation \n#     for use as page-cache memory. This causes SQLite to upgrade\n#     to an exclusive lock when writing earlier than usual, which\n#     makes some of these tests fail.\n#\nsqlite3_soft_heap_limit 0\nif {[permutation] != \"memsubsys1\"} {\n  do_test incrblob-6.1 {\n    sqlite3 db2 test.db\n    execsql {\n      BEGIN;\n      INSERT INTO blobs(k, v, i) VALUES('a', 'different', 'connection');\n    } db2\n  } {}\n  do_test incrblob-6.2 {\n    execsql {\n      SELECT rowid FROM blobs ORDER BY rowid\n    }\n  } {1 2 3}\n  do_test incrblob-6.3 {\n    set rc [catch {\n      db incrblob blobs v 1\n    } msg]\n    list $rc $msg\n  } {1 {database is locked}}\n  do_test incrblob-6.4 {\n    set rc [catch {\n      db incrblob blobs v 3\n    } msg]\n    list $rc $msg\n  } {1 {database is locked}}\n  do_test incrblob-6.5 {\n    set ::blob [db incrblob -readonly blobs v 3]\n    read $::blob\n  } {hello}\n  do_test incrblob-6.6 {\n    close $::blob\n  } {}\n  \n  do_test incrblob-6.7 {\n    set ::blob [db2 incrblob blobs i 4]\n    gets $::blob\n  } {connection}\n  do_test incrblob-6.8 {\n    tell $::blob\n  } {10}\n  do_test incrblob-6.9 {\n    seek $::blob 0\n    puts -nonewline $::blob \"invocation\"\n    flush $::blob\n  } {}\n  \n  # At this point commit should be illegal (because \n  # there is an open blob channel).\n  #\n  do_test incrblob-6.11 {\n    catchsql {\n      COMMIT;\n    } db2\n  } {1 {cannot commit transaction - SQL statements in progress}}\n  \n  do_test incrblob-6.12 {\n    execsql {\n      SELECT * FROM blobs WHERE rowid = 4;\n    }\n  } {}\n  do_test incrblob-6.13 {\n    close $::blob\n  } {}\n  do_test incrblob-6.14 {\n    catchsql {\n      COMMIT;\n    } db2\n  } {0 {}}\n  do_test incrblob-6.15 {\n    execsql {\n      SELECT * FROM blobs WHERE rowid = 4;\n    }\n  } {a different invocation}\n  db2 close\n}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\n#-----------------------------------------------------------------------\n# The following tests verify the behavior of the incremental IO\n# APIs in the following cases:\n#\n#     7.1 A row that containing an open blob is modified.\n#\n#     7.2 A CREATE TABLE requires that an overflow page that is part\n#         of an open blob is moved.\n#\n#     7.3 An INCREMENTAL VACUUM moves an overflow page that is part\n#         of an open blob.\n#\n# In the first case above, correct behavior is for all subsequent\n# read/write operations on the blob-handle to return SQLITE_ABORT.\n# More accurately, blob-handles are invalidated whenever the table\n# they belong to is written to.\n#\n# The second two cases have no external effect. They are testing\n# that the internal cache of overflow page numbers is correctly\n# invalidated.\n#\ndo_test incrblob-7.1.0 {\n  execsql {\n    BEGIN;\n    DROP TABLE blobs;\n    CREATE TABLE t1 (a, b, c, d BLOB);\n    INSERT INTO t1(a, b, c, d) VALUES(1, 2, 3, 4);\n    COMMIT;\n  }\n} {}\n\nforeach {tn arg} {1 \"\" 2 -readonly} {\n\n  execsql {\n    UPDATE t1 SET d = zeroblob(10000);\n  }\n\n  do_test incrblob-7.1.$tn.1 {\n    set ::b [eval db incrblob $arg t1 d 1]\n    binary scan [sqlite3_blob_read $::b 5000 5] c* c\n    set c\n  } {0 0 0 0 0}\n  do_test incrblob-7.1.$tn.2 {\n    execsql {\n      UPDATE t1 SET d = 15;\n    }\n  } {}\n  do_test incrblob-7.1.$tn.3 {\n    set rc [catch { sqlite3_blob_read $::b 5000 5 } msg]\n    list $rc $msg\n  } {1 SQLITE_ABORT}\n  do_test incrblob-7.1.$tn.4 {\n    execsql {\n      SELECT d FROM t1;\n    }\n  } {15}\n  do_test incrblob-7.1.$tn.5 {\n    set rc [catch { close $::b } msg]\n    list $rc $msg\n  } {0 {}}\n  do_test incrblob-7.1.$tn.6 {\n    execsql {\n      SELECT d FROM t1;\n    }\n  } {15}\n\n}\n\nset fd [open $::cmdlinearg(INFO_SCRIPT)]\nfconfigure $fd -translation binary\nset ::data [read $fd 14000]\nclose $fd\n\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndo_test incrblob-7.2.1 {\n  execsql {\n    PRAGMA auto_vacuum = \"incremental\";\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);        -- root@page3\n    INSERT INTO t1 VALUES(123, $::data);\n  }\n  set ::b [db incrblob -readonly t1 b 123]\n  fconfigure $::b -translation binary\n  read $::b\n} $::data\ndo_test incrblob-7.2.2 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);        -- root@page4\n  }\n  seek $::b 0\n  read $::b\n} $::data\ndo_test incrblob-7.2.3 {\n  close $::b\n  execsql {\n    SELECT rootpage FROM sqlite_master;\n  }\n} {3 4}\n\nset ::otherdata \"[string range $::data 0 1000][string range $::data 1001 end]\"\ndo_test incrblob-7.3.1 {\n  execsql {\n    INSERT INTO t2 VALUES(456, $::otherdata);\n  }\n  set ::b [db incrblob -readonly t2 b 456]\n  fconfigure $::b -translation binary\n  read $::b\n} $::otherdata\ndo_test incrblob-7.3.2 {\n  expr [file size test.db]/1024\n} 30\ndo_test incrblob-7.3.3 {\n  execsql {\n    DELETE FROM t1 WHERE a = 123;\n    PRAGMA INCREMENTAL_VACUUM(0);\n  }\n  seek $::b 0\n  read $::b\n} $::otherdata\n\n# Attempt to write on a read-only blob.  Make sure the error code\n# gets set.  Ticket #2464.\n#\ndo_test incrblob-7.4 {\n  set rc [catch {sqlite3_blob_write $::b 10 HELLO} msg]\n  lappend rc $msg\n} {1 SQLITE_READONLY}\ndo_test incrblob-7.5 {\n  sqlite3_errcode db\n} {SQLITE_READONLY}\ndo_test incrblob-7.6 {\n  sqlite3_errmsg db\n} {attempt to write a readonly database}\n\n# Test that if either the \"offset\" or \"amount\" arguments to\n# sqlite3_blob_write() are less than zero, SQLITE_ERROR is returned.\n# \ndo_test incrblob-8.1 {\n  execsql { INSERT INTO t1 VALUES(314159, 'sqlite') }\n  set ::b [db incrblob t1 b 314159]\n  fconfigure $::b -translation binary\n  set rc [catch {sqlite3_blob_write $::b 10 HELLO -1} msg]\n  lappend rc $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob-8.2 {\n  sqlite3_errcode db\n} {SQLITE_ERROR}\ndo_test incrblob-8.3 {\n  set rc [catch {sqlite3_blob_write $::b -1 HELLO 5} msg]\n  lappend rc $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob-8.4 {\n  sqlite3_errcode db\n} {SQLITE_ERROR}\ndo_test incrblob-8.5 {\n  execsql {SELECT b FROM t1 WHERE a = 314159}\n} {sqlite}\ndo_test incrblob-8.6 {\n  set rc [catch {sqlite3_blob_write $::b 0 etilqs 6} msg]\n  lappend rc $msg\n} {0 {}}\ndo_test incrblob-8.7 {\n  execsql {SELECT b FROM t1 WHERE a = 314159}\n} {etilqs}\n\n# The following test case exposes an instance in the blob code where\n# an error message was set using a call similar to sqlite3_mprintf(zErr),\n# where zErr is an arbitrary string. This is no good if the string contains\n# characters that can be mistaken for printf() formatting directives.\n#\ndo_test incrblob-9.1 {\n  list [catch { db incrblob t1 \"A tricky column name %s%s\" 1 } msg] $msg\n} {1 {no such column: \"A tricky column name %s%s\"}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblob2.test",
    "content": "# 2008 June 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that it is possible to have two open blob handles on a single\n# blob object.\n#\n# $Id: incrblob2.test,v 1.11 2009/06/29 06:00:37 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!autovacuum || !pragma || !incrblob} {\n  finish_test\n  return\n}\n\ndo_test incrblob2-1.0 {\n  execsql {\n    CREATE TABLE blobs(id INTEGER PRIMARY KEY, data BLOB);\n    INSERT INTO blobs VALUES(NULL, zeroblob(5000));\n    INSERT INTO blobs VALUES(NULL, zeroblob(5000));\n    INSERT INTO blobs VALUES(NULL, zeroblob(5000));\n    INSERT INTO blobs VALUES(NULL, zeroblob(5000));\n  }\n} {}\n\nforeach iOffset [list 0 256 4094] {\n  do_test incrblob2-1.$iOffset.1 {\n    set fd [db incrblob blobs data 1]\n    puts $fd \"[string repeat x $iOffset]SQLite version 3.6.0\"\n    close $fd\n  } {}\n  \n  do_test incrblob2-1.$iOffset.2 {\n    set fd1 [db incrblob blobs data 1]\n    set fd2 [db incrblob blobs data 1]\n    fconfigure $fd1 -buffering none\n    fconfigure $fd2 -buffering none\n    if {$iOffset != 0} {\n      seek $fd2 $iOffset start\n      seek $fd1 $iOffset start\n    }\n    read $fd1 6\n  } {SQLite}\n  \n  do_test incrblob2-1.$iOffset.3 {\n    read $fd2 6\n  } {SQLite}\n  \n  do_test incrblob2-1.$iOffset.4 {\n    seek $fd2 $iOffset start\n    seek $fd1 $iOffset start\n    puts -nonewline $fd2 \"etiLQS\"\n  } {}\n\n  \n  do_test incrblob2-1.$iOffset.5 {\n    seek $fd1 $iOffset start\n    read $fd1 6\n  } {etiLQS}\n  \n  do_test incrblob2-1.$iOffset.6 {\n    seek $fd2 $iOffset start\n    read $fd2 6\n  } {etiLQS}\n  \n  do_test incrblob2-1.$iOffset.7 {\n    seek $fd1 $iOffset start\n    read $fd1 6\n  } {etiLQS}\n  \n  do_test incrblob2-1.$iOffset.8 {\n    close $fd1\n    close $fd2\n  } {}\n}\n\n#--------------------------------------------------------------------------\n\nforeach iOffset [list 0 256 4094] {\n\n  do_test incrblob2-2.$iOffset.1 {\n    set fd1 [db incrblob blobs data 1]\n    seek $fd1 [expr $iOffset - 5000] end\n    fconfigure $fd1 -buffering none\n\n    set fd2 [db incrblob blobs data 1]\n    seek $fd2 [expr $iOffset - 5000] end\n    fconfigure $fd2 -buffering none\n\n    puts -nonewline $fd1 \"123456\"\n  } {}\n  \n  do_test incrblob2-2.$iOffset.2 {\n    read $fd2 6\n  } {123456}\n\n  do_test incrblob2-2.$iOffset.3 {\n    close $fd1\n    close $fd2\n  } {}\n}\n\ndo_test incrblob2-3.1 {\n  set fd1 [db incrblob blobs data 1]\n  fconfigure $fd1 -buffering none\n} {}\ndo_test incrblob2-3.2 {\n  execsql {\n    INSERT INTO blobs VALUES(5, zeroblob(10240));\n  }\n} {}\ndo_test incrblob2-3.3 {\n  set rc [catch { read $fd1 6 } msg]\n  list $rc $msg\n} {0 123456}\ndo_test incrblob2-3.4 {\n  close $fd1\n} {}\n\n#--------------------------------------------------------------------------\n# The following tests - incrblob2-4.* - test that blob handles are \n# invalidated at the correct times.\n#\ndo_test incrblob2-4.1 {\n  unset -nocomplain data\n  db eval BEGIN\n  db eval { CREATE TABLE t1(id INTEGER PRIMARY KEY, data BLOB); }\n  for {set ii 1} {$ii < 100} {incr ii} {\n    set data [string repeat \"blob$ii\" 500]\n    db eval { INSERT INTO t1 VALUES($ii, $data) }\n  }\n  db eval COMMIT\n} {}\n\nproc aborted_handles {} {\n  global handles\n\n  set aborted {}\n  for {set ii 1} {$ii < 100} {incr ii} {\n    set str \"blob$ii\"\n    set nByte [string length $str]\n    set iOffset [expr $nByte * $ii * 2]\n\n    set rc [catch {sqlite3_blob_read $handles($ii) $iOffset $nByte} msg]\n    if {$rc && $msg eq \"SQLITE_ABORT\"} {\n      lappend aborted $ii\n    } else {\n      if {$rc || $msg ne $str} {\n        error \"blob $ii: $msg\"\n      }\n    }\n  }\n  set aborted\n}\n\ndo_test incrblob2-4.2 {\n  for {set ii 1} {$ii < 100} {incr ii} {\n    set handles($ii) [db incrblob t1 data $ii]\n  }\n  aborted_handles\n} {}\n\n# Update row 3. This should abort handle 3 but leave all others untouched.\n#\ndo_test incrblob2-4.3 {\n  db eval {UPDATE t1 SET data = data || '' WHERE id = 3}\n  aborted_handles\n} {3}\n\n# Test that a write to handle 3 also returns SQLITE_ABORT.\n#\ndo_test incrblob2-4.3.1 {\n  set rc [catch {sqlite3_blob_write $::handles(3) 10 HELLO} msg]\n  list $rc $msg\n} {1 SQLITE_ABORT}\n\n# Delete row 14. This should abort handle 6 but leave all others untouched.\n#\ndo_test incrblob2-4.4 {\n  db eval {DELETE FROM t1 WHERE id = 14}\n  aborted_handles\n} {3 14}\n\n# Change the rowid of row 15 to 102. Should abort handle 15.\n#\ndo_test incrblob2-4.5 {\n  db eval {UPDATE t1 SET id = 102 WHERE id = 15}\n  aborted_handles\n} {3 14 15}\n\n# Clobber row 92 using INSERT OR REPLACE.\n#\ndo_test incrblob2-4.6 {\n  db eval {INSERT OR REPLACE INTO t1 VALUES(92, zeroblob(1000))}\n  aborted_handles\n} {3 14 15 92}\n\n# Clobber row 65 using UPDATE OR REPLACE on row 35. This should abort \n# handles 35 and 65.\n#\ndo_test incrblob2-4.7 {\n  db eval {UPDATE OR REPLACE t1 SET id = 65 WHERE id = 35}\n  aborted_handles\n} {3 14 15 35 65 92}\n\n# Insert a couple of new rows. This should not invalidate any handles.\n#\ndo_test incrblob2-4.9 {\n  db eval {INSERT INTO t1 SELECT NULL, data FROM t1}\n  aborted_handles\n} {3 14 15 35 65 92}\n\n# Delete all rows from 1 to 25. This should abort all handles up to 25.\n#\ndo_test incrblob2-4.9 {\n  db eval {DELETE FROM t1 WHERE id >=1 AND id <= 25}\n  aborted_handles\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 35 65 92}\n\n# Delete the whole table (this will use sqlite3BtreeClearTable()). All handles\n# should now be aborted.\n#\ndo_test incrblob2-4.10 {\n  db eval {DELETE FROM t1}\n  aborted_handles\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99}\n\ndo_test incrblob2-4.1.X {\n  for {set ii 1} {$ii < 100} {incr ii} {\n    close $handles($ii) \n  }\n} {}\n\n#--------------------------------------------------------------------------\n# The following tests - incrblob2-5.* - test that in shared cache an open\n# blob handle counts as a read-lock on its table.\n#\nifcapable shared_cache {\n  db close\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n  do_test incrblob2-5.1 {\n    sqlite3 db test.db\n    sqlite3 db2 test.db\n\n    execsql {\n      INSERT INTO t1 VALUES(1, 'abcde');\n    }\n  } {}\n\n  do_test incrblob2-5.2 {\n    catchsql { INSERT INTO t1 VALUES(2, 'fghij') } db2\n  } {0 {}}\n\n  do_test incrblob2-5.3 {\n    set blob [db incrblob t1 data 1]\n    catchsql { INSERT INTO t1 VALUES(3, 'klmno') } db2\n  } {1 {database table is locked}}\n\n  do_test incrblob2-5.4 {\n    close $blob\n    execsql BEGIN db2\n    catchsql { INSERT INTO t1 VALUES(4, 'pqrst') } db2\n  } {0 {}}\n\n  do_test incrblob2-5.5 {\n    set rc [catch { db incrblob -readonly t1 data 1 } msg]\n    list $rc $msg\n  } {1 {database table is locked: t1}}\n\n  do_test incrblob2-5.6 {\n    execsql { PRAGMA read_uncommitted=1 }\n    set blob [db incrblob -readonly t1 data 4]\n    read $blob\n  } {pqrst}\n\n  do_test incrblob2-5.7 {\n    catchsql { INSERT INTO t1 VALUES(3, 'klmno') } db2\n  } {0 {}}\n\n  do_test incrblob2-5.8 {\n    close $blob\n  } {}\n\n  db2 close\n  db close\n  sqlite3_enable_shared_cache $::enable_shared_cache\n}\n\n#--------------------------------------------------------------------------\n# The following tests - incrblob2-6.* - test a specific scenario that might\n# be causing an error.\n#\nsqlite3 db test.db\ndo_test incrblob2-6.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1, zeroblob(100));\n  }\n  \n  set rdHandle [db incrblob -readonly t1 data 1]\n  set wrHandle [db incrblob t1 data 1]\n\n  sqlite3_blob_read $rdHandle 0 100\n\n  sqlite3_blob_write $wrHandle 0 ABCDEF\n\n  close $wrHandle\n  close $rdHandle\n} {}\n\ndo_test incrblob2-6.2 {\n  set rdHandle [db incrblob -readonly t1 data 1]\n  sqlite3_blob_read $rdHandle 0 2\n} {AB}\n\nif {$::tcl_platform(pointerSize)>=8} {\n  do_test incrblob2-6.2b {\n    set rc [catch {\n      # Prior to 2015-02-07, the following caused a segfault due to\n      # integer overflow.\n      sqlite3_blob_read $rdHandle 2147483647 2147483647\n    } errmsg]\n    if {[string match {out of memory in *test_blob.c} $errmsg]} {\n      set errmsg SQLITE_ERROR\n    }\n    lappend rc $errmsg\n  } {1 SQLITE_ERROR}\n}\ndo_test incrblob2-6.2c {\n  set rc [catch {\n    # Prior to 2015-02-07, the following caused a segfault due to\n    # integer overflow.\n    sqlite3_blob_read $rdHandle 2147483647 100\n  } errmsg]\n  lappend rc $errmsg\n} {1 SQLITE_ERROR}\n\ndo_test incrblob2-6.3 {\n  set wrHandle [db incrblob t1 data 1]\n  sqlite3_blob_write $wrHandle 0 ZZZZZZZZZZ\n  sqlite3_blob_read $rdHandle 2 4\n} {ZZZZ}\n\ndo_test incrblob2-6.3b {\n  set rc [catch {\n    # Prior to 2015-02-07, the following caused a segfault due to\n    # integer overflow.\n    sqlite3_blob_write $wrHandle 2147483647 YYYYYYYYYYYYYYYYYY\n  } errmsg]\n  lappend rc $errmsg\n} {1 SQLITE_ERROR}\ndo_test incrblob2-6.3c {\n  sqlite3_blob_read $rdHandle 2 4\n} {ZZZZ}\n\n\ndo_test incrblob2-6.4 {\n  close $wrHandle\n  close $rdHandle\n} {}\n\nsqlite3_memory_highwater 1\ndo_test incrblob2-7.1 {\n  db eval {\n    CREATE TABLE t2(B BLOB);\n    INSERT INTO t2 VALUES(zeroblob(10 * 1024 * 1024)); \n  }\n  expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}\n} {1}\n\ndo_test incrblob2-7.2 {\n  set h [db incrblob t2 B 1]\n  expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}\n} {1}\n\ndo_test incrblob2-7.3 {\n  seek $h 0 end\n  tell $h\n} [expr 10 * 1024 * 1024]\n\ndo_test incrblob2-7.4 {\n  expr {[sqlite3_memory_highwater]<(5 * 1024 * 1024)}\n} {1}\n\ndo_test incrblob2-7.5 {\n  close $h\n} {}\n\n#---------------------------------------------------------------------------\n# The following tests, incrblob2-8.*, test that nothing terrible happens\n# when a statement transaction is rolled back while there are open \n# incremental-blob handles. At one point an assert() was failing when\n# this was attempted.\n#\ndo_test incrblob2-8.1 {\n  execsql BEGIN\n  set h [db incrblob t2 B 1]\n  set rc [catch {\n    db eval {SELECT rowid FROM t2} { execsql \"DROP TABLE t2\" }\n  } msg] \n  list $rc $msg\n} {1 {database table is locked}}\ndo_test incrblob2-8.2 {\n  close $h\n  execsql COMMIT\n} {}\ndo_test incrblob2-8.3 {\n  execsql {\n    CREATE TABLE t3(a INTEGER UNIQUE, b TEXT);\n    INSERT INTO t3 VALUES(1, 'aaaaaaaaaaaaaaaaaaaa');\n    INSERT INTO t3 VALUES(2, 'bbbbbbbbbbbbbbbbbbbb');\n    INSERT INTO t3 VALUES(3, 'cccccccccccccccccccc');\n    INSERT INTO t3 VALUES(4, 'dddddddddddddddddddd');\n    INSERT INTO t3 VALUES(5, 'eeeeeeeeeeeeeeeeeeee');\n  }\n} {}\ndo_test incrblob2-8.4 {\n  execsql BEGIN\n  set h [db incrblob t3 b 3]\n  sqlite3_blob_read $h 0 20\n} {cccccccccccccccccccc}\ndo_test incrblob2-8.5 {\n  catchsql {UPDATE t3 SET a = 6 WHERE a > 3}\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test incrblob2-8.6 {\n  catchsql {UPDATE t3 SET a = 6 WHERE a > 3}\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test incrblob2-8.7 {\n  sqlite3_blob_read $h 0 20\n} {cccccccccccccccccccc}\ndo_test incrblob2-8.8 {\n  catchsql {UPDATE t3 SET a = 6 WHERE a = 3 OR a = 5}\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test incrblob2-8.9 {\n  set rc [catch {sqlite3_blob_read $h 0 20} msg]\n  list $rc $msg\n} {1 SQLITE_ABORT}\ndo_test incrblob2-8.X {\n  close $h\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblob3.test",
    "content": "# 2010 October 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nsqlite3 db test.db\nsqlite3_db_config_lookaside db 0 0 0\n\ndo_execsql_test incrblob3-1.1 {\n  CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);\n  INSERT INTO blobs VALUES(1, zeroblob(100));\n  INSERT INTO blobs VALUES(2, zeroblob(100));\n} {}\n\n# Test the sqlite3_blob_reopen()/read()/write() functions.\n#\ndo_test incrblob3-1.2 {\n  set ::blob [db incrblob blobs v 1]\n  puts $::blob \"hello world\"\n} {}\n\ndo_test incrblob3-1.3 {\n  sqlite3_blob_reopen $::blob 2\n  puts $::blob \"world hello\"\n} {}\n\ndo_test incrblob3-1.4 {\n  sqlite3_blob_reopen $::blob 1\n  gets $::blob\n} {hello world}\n\ndo_test incrblob3-1.5 {\n  sqlite3_blob_reopen $::blob 2\n  gets $::blob\n} {world hello}\n\ndo_test incrblob3-1.6 { close $::blob } {}\n\n# Test some error conditions.\n#\n#   incrblob3-2.1: Attempting to reopen a row that does not exist.\n#   incrblob3-2.2: Attempting to reopen a row that does not contain a blob\n#                  or text value.\n#\ndo_test incrblob3-2.1.1 {\n  set ::blob [db incrblob blobs v 1]\n  list [catch {sqlite3_blob_reopen $::blob 3} msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-2.1.2 {\n  list [sqlite3_errcode db] [sqlite3_errmsg db]\n} {SQLITE_ERROR {no such rowid: 3}}\ndo_test incrblob3-2.1.3 {\n  list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg\n} {1 SQLITE_ABORT}\ndo_test incrblob3-2.1.4 { close $::blob } {}\n\ndo_execsql_test incrblob3-2.2.1 {\n  INSERT INTO blobs VALUES(3, 42);\n  INSERT INTO blobs VALUES(4, 54.4);\n  INSERT INTO blobs VALUES(5, NULL);\n}\nforeach {tn rowid type} {\n  1 3 integer\n  2 4 real\n  3 5 null\n} {\n  do_test incrblob3-2.2.$tn.1 {\n    set ::blob [db incrblob blobs v 1]\n    list [catch {sqlite3_blob_reopen $::blob $rowid} msg] $msg\n  } {1 SQLITE_ERROR}\n  do_test incrblob3-2.2.$tn.2 {\n    list [sqlite3_errcode db] [sqlite3_errmsg db]\n  } \"SQLITE_ERROR {cannot open value of type $type}\"\n\n  do_test incrblob3-2.2.$tn.3 {\n    list [catch {sqlite3_blob_reopen $::blob 1} msg] $msg\n  } {1 SQLITE_ABORT}\n  do_test incrblob3-2.2.$tn.4 {\n    list [catch {sqlite3_blob_read $::blob 0 10} msg] $msg\n  } {1 SQLITE_ABORT}\n  do_test incrblob3-2.2.$tn.5 {\n    list [catch {sqlite3_blob_write $::blob 0 \"abcd\"} msg] $msg\n  } {1 SQLITE_ABORT}\n  do_test incrblob3-2.2.$tn.6 {\n    sqlite3_blob_bytes $::blob\n  } {0}\n\n  do_test incrblob3-2.2.$tn.7 { close $::blob } {}\n}\n\n# Test that passing NULL to sqlite3_blob_XXX() APIs returns SQLITE_MISUSE.\n#\n#   incrblob3-3.1: sqlite3_blob_reopen()\n#   incrblob3-3.2: sqlite3_blob_read()\n#   incrblob3-3.3: sqlite3_blob_write()\n#   incrblob3-3.4: sqlite3_blob_bytes()\n#\ndo_test incrblob3-3.1 {\n  list [catch {sqlite3_blob_reopen {} 3} msg] $msg\n} {1 SQLITE_MISUSE}\n\ndo_test incrblob3-3.2 {\n  list [catch {sqlite3_blob_read {} 0 10} msg] $msg\n} {1 SQLITE_MISUSE}\n\ndo_test incrblob3-3.3 {\n  list [catch {sqlite3_blob_write {} 0 \"abcd\"} msg] $msg\n} {1 SQLITE_MISUSE}\n\ndo_test incrblob3-3.4 { sqlite3_blob_bytes {} } {0}\n\ndo_test incrblob3-3.5 { sqlite3_blob_close {} } {}\n\n# Test out-of-range reading and writing\n#\ndo_test incrblob3-4.1 {\n  set ::blob [db incrblob blobs v 1]\n  sqlite3_blob_bytes $::blob\n} {100}\ndo_test incrblob3-4.2 {\n  list [catch { sqlite3_blob_read $::blob -1 10 } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-4.3 {\n  list [catch { sqlite3_blob_read $::blob 0 -10 } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-4.4 {\n  list [catch { sqlite3_blob_read $::blob 95 10 } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-4.5 {\n  list [catch { sqlite3_blob_write $::blob -1 \"abcdefghij\" 10 } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-4.6 {\n  list [catch { sqlite3_blob_write $::blob 0 \"abcdefghij\" -10 } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test incrblob3-4.7 {\n  list [catch { sqlite3_blob_write $::blob 95 \"abcdefghij\" } msg] $msg\n} {1 SQLITE_ERROR}\n\ndo_test incrblob3-4.8 { close $::blob } {}\n\n# Test that modifying the row a blob handle points to aborts the blob.\n#\ndo_test incrblob3-5.1 {\n  set ::blob [db incrblob blobs v 1]\n  sqlite3_blob_bytes $::blob\n} {100}\ndo_test incrblob3-5.2 {\n  execsql { UPDATE blobs SET v = '123456789012345678901234567890' WHERE k = 1 }\n  list [catch { sqlite3_blob_read $::blob 0 10 } msg] $msg\n} {1 SQLITE_ABORT}\n\n# Test various errors that can occur in sqlite3_blob_open():\n#\n#   1. Trying to open a virtual table column.\n#   2. Trying to open a view column.\n#   3. Trying to open a column that does not exist.\n#   4. Trying to open a read/write handle on an indexed column.\n#   5. Trying to open a read/write handle on the child key of an FK constraint.\n#\nifcapable fts3 {\n  do_test incrblob3-6.1 {\n    execsql {\n      CREATE VIRTUAL TABLE ft USING fts3;\n      INSERT INTO ft VALUES('rules to open a column to which');\n    }\n\n    list [catch { db incrblob ft content 1 } msg] $msg\n  } {1 {cannot open virtual table: ft}}\n}\nifcapable view {\n  do_test incrblob3-6.2 {\n    execsql { CREATE VIEW v1 AS SELECT * FROM blobs }\n    list [catch { db incrblob v1 content 1 } msg] $msg\n  } {1 {cannot open view: v1}}\n}\n\ndo_test incrblob3-6.3 {\n  list [catch { db incrblob blobs content 1 } msg] $msg\n} {1 {no such column: \"content\"}}\n\ndo_test incrblob3-6.4.1 {\n  execsql { \n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(b);\n    INSERT INTO t1 VALUES(zeroblob(100), zeroblob(100));\n  }\n  list [catch { db incrblob t1 b 1 } msg] $msg\n} {1 {cannot open indexed column for writing}}\ndo_test incrblob3-6.4.2 {\n  set ::blob [db incrblob t1 a 1]\n  close $::blob\n} {}\ndo_test incrblob3-6.4.3 {\n  set ::blob [db incrblob -readonly t1 b 1]\n  close $::blob\n} {}\n\ndo_test incrblob3-6.5.1 {\n  execsql { \n    CREATE TABLE p1(a PRIMARY KEY);\n    CREATE TABLE c1(a, b REFERENCES p1);\n    PRAGMA foreign_keys = 1;\n    INSERT INTO p1 VALUES(zeroblob(100));\n    INSERT INTO c1 VALUES(zeroblob(100), zeroblob(100));\n  }\n  list [catch { db incrblob c1 b 1 } msg] $msg\n} {1 {cannot open foreign key column for writing}}\n\ndo_test incrblob3-6.5.2 {\n  set ::blob [db incrblob c1 a 1]\n  close $::blob\n} {}\ndo_test incrblob3-6.5.3 {\n  set ::blob [db incrblob -readonly c1 b 1]\n  close $::blob\n} {}\ndo_test incrblob3-6.5.4 {\n  execsql { PRAGMA foreign_keys = 0 }\n  set ::blob [db incrblob c1 b 1]\n  close $::blob\n} {}\n\n\n# Test that sqlite3_blob_open() handles transient and persistent schema \n# errors correctly.\n#\ndo_test incrblob3-7.1 {\n  sqlite3 db2 test.db\n  sqlite3_db_config_lookaside db2 0 0 0\n  execsql { CREATE TABLE t2(x) } db2\n  set ::blob [db incrblob blobs v 1]\n  close $::blob\n} {}\ndb2 close\n\ntestvfs tvfs -default 1\ntvfs filter xAccess\ntvfs script access_method\n\nproc access_method {args} {\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n\n  set dbversion [hexio_get_int [hexio_read test.db 24 4]]\n  incr dbversion\n  hexio_write test.db 24 [hexio_render_int32 $dbversion]\n\n  return \"\"\n}\n\ndo_test incrblob3-7.2 {\n  sqlite3 db test.db \n  sqlite3_db_config_lookaside db 0 0 0\n  list [catch {db incrblob blobs v 1} msg] $msg\n} {1 {database schema has changed}}\ndb close\ntvfs delete\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblob4.test",
    "content": "# 2012 March 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!incrblob} { finish_test ; return }\nset testprefix incrblob4\n\nproc create_t1 {} {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(k INTEGER PRIMARY KEY, v);\n  }\n}\n\nproc populate_t1 {} {\n  set data [list a b c d e f g h i j k l m n o p q r s t u v w x y z]\n  foreach d $data {\n    set blob [string repeat $d 900]\n    execsql { INSERT INTO t1(v) VALUES($blob) }\n  }\n}\n\n\ndo_test 1.1 { \n  create_t1\n  populate_t1 \n} {}\n\ndo_test 1.2 {\n  set blob [db incrblob t1 v 5]\n  read $blob 10\n} {eeeeeeeeee}\n\ndo_test 1.3 {\n  execsql { DELETE FROM t1 }\n  populate_t1\n} {}\n\n\n\ndo_test 2.1 { \n  reset_db\n  create_t1\n  populate_t1 \n} {}\n\ndo_test 2.2 {\n  set blob [db incrblob t1 v 10]\n  read $blob 10\n} {jjjjjjjjjj}\n\ndo_test 2.3 {\n  set new [string repeat % 900]\n  execsql { DELETE FROM t1 WHERE k=10 }\n  execsql { DELETE FROM t1 WHERE k=9 }\n  execsql { INSERT INTO t1(v) VALUES($new) }\n} {}\n\n\n\ndo_test 3.1 {\n  reset_db\n  create_t1\n  populate_t1 \n} {}\n\ndo_test 3.2 {\n  set blob [db incrblob t1 v 20]\n  read $blob 10\n} {tttttttttt}\n\ndo_test 3.3 {\n  set new [string repeat % 900]\n  execsql { UPDATE t1 SET v = $new WHERE k = 20 }\n  execsql { DELETE FROM t1 WHERE k=19 }\n  execsql { INSERT INTO t1(v) VALUES($new) }\n} {}\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to DROP a table with an incremental blob\n# cursor open on it.\n#\ndo_execsql_test 4.1 {\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t2 VALUES(456, '0123456789');\n}\ndo_test 4.2 {\n  set blob [db incrblob -readonly t2 b 456]\n  read $blob 5\n} {01234}\ndo_catchsql_test 4.3 {\n  DROP TABLE t2\n} {1 {database table is locked}}\ndo_test 4.4 {\n  sqlite3_extended_errcode db\n} {SQLITE_LOCKED}\nclose $blob\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblob_err.test",
    "content": "# 2007 May 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: incrblob_err.test,v 1.14 2008/07/18 17:16:27 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix incrblob_err\n\nifcapable {!incrblob  || !memdebug || !tclvar} {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\n\nunset -nocomplain ::fd ::data\nset ::fd [open $::cmdlinearg(INFO_SCRIPT)]\nset ::data [read $::fd]\nclose $::fd\n\ndo_malloc_test 1 -tclprep {\n  set bytes [file size $::cmdlinearg(INFO_SCRIPT)]\n  execsql {\n    CREATE TABLE blobs(k, v BLOB);\n    INSERT INTO blobs VALUES(1, zeroblob($::bytes));\n  }\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  fconfigure $::blob -translation binary\n  set rc [catch {puts -nonewline $::blob $::data}]\n  if {$rc} { error \"out of memory\" }\n} \n\ndo_malloc_test 2 -tclprep {\n  execsql {\n    CREATE TABLE blobs(k, v BLOB);\n    INSERT INTO blobs VALUES(1, $::data);\n  }\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  set rc [catch {set ::r [read $::blob]}]\n  if {$rc} { \n    error \"out of memory\" \n  } elseif {$::r ne $::data} {\n    error \"Bad data read...\"\n  }\n}\n\ndo_malloc_test 3 -tclprep {\n  execsql {\n    CREATE TABLE blobs(k, v BLOB);\n    INSERT INTO blobs VALUES(1, $::data);\n  }\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  set rc [catch {set ::r [read $::blob]}]\n  if {$rc} { \n    error \"out of memory\" \n  } elseif {$::r ne $::data} {\n    error \"Bad data read...\"\n  }\n  set rc [catch {close $::blob}]\n  if {$rc} { \n    error \"out of memory\" \n  }\n}\n\ndo_ioerr_test incrblob_err-4 -cksum 1 -sqlprep {\n  CREATE TABLE blobs(k, v BLOB);\n  INSERT INTO blobs VALUES(1, $::data);\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  read $::blob\n}\n\ndo_ioerr_test incrblob_err-5 -cksum 1 -sqlprep {\n  CREATE TABLE blobs(k, v BLOB);\n  INSERT INTO blobs VALUES(1, zeroblob(length(CAST($::data AS BLOB))));\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  fconfigure $::blob -translation binary\n  puts -nonewline $::blob $::data\n  close $::blob\n}\n\ndo_ioerr_test incrblob_err-6 -cksum 1 -sqlprep {\n  CREATE TABLE blobs(k, v BLOB);\n  INSERT INTO blobs VALUES(1, $::data || $::data || $::data);\n} -tclbody {\n  set ::blob [db incrblob blobs v 1]\n  fconfigure $::blob -translation binary\n  seek $::blob -20 end\n  puts -nonewline $::blob \"12345678900987654321\"\n  close $::blob\n}\n\ndo_ioerr_test incrblob_err-7 -cksum 1 -sqlprep {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);\n  INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));\n} -tclbody {\n  # Read some data from the end of the large blob inserted into table \n  # \"blobs\". This forces the IO error to occur while reading a pointer\n  # map page for the purposes of seeking to the end of the blob.\n  #\n  sqlite3 db2 test.db\n  set ::blob [db2 incrblob blobs v 1]\n  sqlite3_blob_read $::blob [expr 500*1020-20] 20\n  close $::blob\n}\ncatch {db2 close}\n\ndo_ioerr_test incrblob_err-8 -cksum 1 -sqlprep {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE blobs(k INTEGER PRIMARY KEY, v BLOB);\n  INSERT INTO blobs VALUES(1, zeroblob(500 * 1020));\n} -tclbody {\n  # Read some data from the end of the large blob inserted into table \n  # \"blobs\". This forces the IO error to occur while reading a pointer\n  # map page for the purposes of seeking to the end of the blob.\n  #\n  sqlite3 db2 test.db\n  set ::blob [db2 incrblob blobs v 1]\n  sqlite3_blob_write $::blob [expr 500*1020-20] 12345678900987654321\n  close $::blob\n}\n\ncatch {db2 close}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrblobfault.test",
    "content": "# 2010 October 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix incrblobfault\n\ndo_execsql_test 1.0 {\n  CREATE TABLE blob(x INTEGER PRIMARY KEY, v BLOB);\n  INSERT INTO blob VALUES(1, 'hello world');\n  INSERT INTO blob VALUES(2, 'world hello');\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n  INSERT INTO blob SELECT NULL, v FROM blob;\n}\n\ndo_faultsim_test 1 -prep {\n  sqlite3 db test.db\n  set ::blob [db incrblob blob v 1]\n} -body {\n  if {[catch {sqlite3_blob_reopen $::blob 1000}]} {\n    error [sqlite3_errmsg db]\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  close $::blob\n}\n\ndo_faultsim_test 2 -prep {\n  sqlite3 db test.db\n  set ::blob [db incrblob blob v 1]\n} -body {\n  if {[catch {sqlite3_blob_reopen $::blob -1}]} {\n    error [sqlite3_errmsg db]\n  }\n} -test {\n  faultsim_test_result {1 {no such rowid: -1}} {1 {disk I/O error}}\n  close $::blob\n}\n\ndo_faultsim_test 3 -prep {\n  sqlite3 db test.db\n} -body {\n  set ::blob [db incrblob blob v 1]\n  gets $::blob\n} -test {\n  faultsim_test_result {0 {hello world}}\n  catch { close $::blob }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrcorrupt.test",
    "content": "# 2001 October 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that \"PRAGMA incremental_vacuum\" detects and reports database\n# corruption properly. And that \"PRAGMA auto_vacuum = INCREMENTAL\"\n# does as well.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix incrcorrupt\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  PRAGMA auto_vacuum = 2;\n  CREATE TABLE t1(a PRIMARY KEY, b);\n\n  WITH data(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM data\n  )\n  INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;\n  PRAGMA page_count;\n} {24}\n\ndo_execsql_test 1.1 {\n  PRAGMA incremental_vacuum;\n} {}\n\ndo_test 1.2 {\n  db_save\n  hexio_write test.db 36 00000019\n  catchsql { PRAGMA incremental_vacuum; }\n} {1 {database disk image is malformed}}\n\ndo_test 1.3 {\n  set stmt [sqlite3_prepare_v2 db \"PRAGMA incremental_vacuum\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_CORRUPT}\ndo_test 1.4 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 1.5 { sqlite3_errmsg db } {database disk image is malformed}\ndo_test 1.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}\ndo_test 1.7 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 1.8 { sqlite3_errmsg db } {database disk image is malformed}\n\ndo_test 1.9 {\n  set stmt [sqlite3_prepare_v2 db \"PRAGMA incremental_vacuum\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_CORRUPT}\ndo_test 1.10 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 1.11 { sqlite3_errmsg db } {database disk image is malformed}\n\ndo_test 1.12 {\n  set stmt2 [sqlite3_prepare_v2 db \"SELECT 1\" -1 dummy]\n  sqlite3_finalize $stmt2\n} {SQLITE_OK}\ndo_test 1.13 { sqlite3_errcode db } {SQLITE_OK}\ndo_test 1.14 { sqlite3_errmsg db } {not an error}\n\ndo_test 1.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}\ndo_test 1.16 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 1.17 { sqlite3_errmsg db } {database disk image is malformed}\n\n#-------------------------------------------------------------------------\n#\nreset_db\n\ndo_execsql_test 2.1 {\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE t1(a PRIMARY KEY, b);\n  WITH data(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM data\n  )\n  INSERT INTO t1 SELECT i, randomblob(600) FROM data LIMIT 20;\n  PRAGMA page_count;\n} {24}\n\ndo_test 2.2 {\n  db_save\n  set fd [open test.db r+]\n  chan truncate $fd [expr 22*1024]\n  close $fd\n  catchsql { PRAGMA incremental_vacuum; }\n} {1 {database disk image is malformed}}\n\ndo_test 2.3 {\n  set stmt [sqlite3_prepare_v2 db \"PRAGMA auto_vacuum = INCREMENTAL\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_CORRUPT}\ndo_test 2.4 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 2.5 { sqlite3_errmsg db } {database disk image is malformed}\ndo_test 2.6 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}\ndo_test 2.7 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 2.8 { sqlite3_errmsg db } {database disk image is malformed}\n\ndo_test 2.9 {\n  set stmt [sqlite3_prepare_v2 db \"PRAGMA auto_vacuum = INCREMENTAL\" -1 dummy]\n  sqlite3_step $stmt\n} {SQLITE_CORRUPT}\ndo_test 2.10 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 2.11 { sqlite3_errmsg db } {database disk image is malformed}\n\ndo_test 2.12 {\n  set stmt2 [sqlite3_prepare_v2 db \"SELECT 1\" -1 dummy]\n  sqlite3_finalize $stmt2\n} {SQLITE_OK}\ndo_test 2.13 { sqlite3_errcode db } {SQLITE_OK}\ndo_test 2.14 { sqlite3_errmsg db } {not an error}\n\ndo_test 2.15 { sqlite3_finalize $stmt } {SQLITE_CORRUPT}\ndo_test 2.16 { sqlite3_errcode db } {SQLITE_CORRUPT}\ndo_test 2.17 { sqlite3_errmsg db } {database disk image is malformed}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrvacuum.test",
    "content": "# 2007 April 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the incremental vacuum feature.\n#\n# Note: There are also some tests for incremental vacuum and IO \n# errors in incrvacuum_ioerr.test.\n#\n# $Id: incrvacuum.test,v 1.23 2009/02/18 20:31:18 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum || !pragma} {\n  finish_test\n  return\n}\n\n#---------------------------------------------------------------------\n# Test the pragma on an empty database.\n#\ndo_test incrvacuum-1.1 {\n  execsql {\n    pragma auto_vacuum;\n  }\n} $sqlite_options(default_autovacuum)\ndo_test incrvacuum-1.2.0 {\n  # File size is sometimes 1 instead of 0 due to the hack we put in\n  # to work around ticket #3260.  Search for comments on #3260 in\n  # os_unix.c.\n  expr {[file size test.db] > 1}\n} {0}\ndo_test incrvacuum-1.2 {\n  # This command will create the database.\n  execsql {\n    pragma auto_vacuum = 'full';\n    pragma auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-1.2.1 {\n  expr {[file size test.db] > 0}\n} {1}\ndo_test incrvacuum-1.3 {\n  execsql {\n    pragma auto_vacuum = 'incremental';\n    pragma auto_vacuum;\n  }\n} {2}\ndo_test incrvacuum-1.4 {\n  # In this case the invalid value is ignored and the auto_vacuum\n  # setting remains unchanged.\n  execsql {\n    pragma auto_vacuum = 'invalid';\n    pragma auto_vacuum;\n  }\n} {2}\ndo_test incrvacuum-1.5 {\n  execsql {\n    pragma auto_vacuum = 1;\n    pragma auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-1.6 {\n  execsql {\n    pragma auto_vacuum = '2';\n    pragma auto_vacuum;\n  }\n} {2}\ndo_test incrvacuum-1.7 {\n  # Invalid value. auto_vacuum setting remains unchanged.\n  execsql {\n    pragma auto_vacuum = 5;\n    pragma auto_vacuum;\n  }\n} {2}\n\n#---------------------------------------------------------------------\n# Test the pragma on a non-empty database. It is possible to toggle\n# the connection between \"full\" and \"incremental\" mode, but not to\n# change from either of these to \"none\", or from \"none\" to \"full\" or\n# \"incremental\".\n#\ndo_test incrvacuum-2.1 {\n  execsql {\n    pragma auto_vacuum = 1;\n    CREATE TABLE abc(a, b, c);\n  }\n} {}\ndo_test incrvacuum-2.2 {\n  execsql {\n    pragma auto_vacuum = 'none';\n    pragma auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-2.2.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    pragma auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-2.3 {\n  execsql {\n    pragma auto_vacuum = 'incremental';\n    pragma auto_vacuum;\n  }\n} {2}\ndo_test incrvacuum-2.4 {\n  execsql {\n    pragma auto_vacuum = 'full';\n    pragma auto_vacuum;\n  }\n} {1}\n\n#---------------------------------------------------------------------\n# Test that when the auto_vacuum mode is \"incremental\", the database\n# does not shrink when pages are removed from it. But it does if\n# the mode is set to \"full\".\n#\ndo_test incrvacuum-3.1 {\n  execsql {\n    pragma auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-3.2 {\n  set ::str [string repeat 1234567890 110]\n  execsql {\n    PRAGMA auto_vacuum = 2;\n    BEGIN;\n    CREATE TABLE tbl2(str);\n    INSERT INTO tbl2 VALUES($::str);\n    COMMIT;\n  }\n  # 5 pages:\n  #\n  #   1 -> database header\n  #   2 -> first back-pointer page\n  #   3 -> table abc\n  #   4 -> table tbl2\n  #   5 -> table tbl2 overflow page.\n  #\n  expr {[file size test.db] / 1024}\n} {5}\ndo_test incrvacuum-3.3 {\n  execsql {\n    DROP TABLE abc;\n    DELETE FROM tbl2;\n  }\n  expr {[file size test.db] / 1024}\n} {5}\ndo_test incrvacuum-3.4 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    INSERT INTO tbl2 VALUES('hello world');\n  }\n  expr {[file size test.db] / 1024}\n} {3}\n\n#---------------------------------------------------------------------\n# Try to run a very simple incremental vacuum. Also verify that \n# PRAGMA incremental_vacuum is a harmless no-op against a database that\n# does not support auto-vacuum.\n#\ndo_test incrvacuum-4.1 {\n  set ::str [string repeat 1234567890 110]\n  execsql {\n    PRAGMA auto_vacuum = 2;\n    INSERT INTO tbl2 VALUES($::str);\n    CREATE TABLE tbl1(a, b, c);\n  }\n  expr {[file size test.db] / 1024}\n} {5}\ndo_test incrvacuum-4.2 {\n  execsql {\n    DELETE FROM tbl2;\n    DROP TABLE tbl1;\n  }\n  expr {[file size test.db] / 1024}\n} {5}\ndo_test incrvacuum-4.3 {\n  set ::nStep 0\n  db eval {pragma incremental_vacuum(10)} {\n    incr ::nStep\n  }\n  list [expr {[file size test.db] / 1024}] $::nStep\n} {3 2}\n\n#---------------------------------------------------------------------\n# The following tests - incrvacuum-5.* - test incremental vacuum\n# from within a transaction.\n#\ndo_test incrvacuum-5.1.1 {\n  expr {[file size test.db] / 1024}\n} {3}\ndo_test incrvacuum-5.1.2 {\n  execsql {\n    BEGIN;\n    DROP TABLE tbl2;\n    PRAGMA incremental_vacuum;\n    COMMIT;\n  }\n  expr {[file size test.db] / 1024}\n} {1}\n\ndo_test incrvacuum-5.2.1 {\n  set ::str [string repeat abcdefghij 110]\n  execsql {\n    BEGIN;\n    CREATE TABLE tbl1(a);\n    INSERT INTO tbl1 VALUES($::str);\n    PRAGMA incremental_vacuum;                 -- this is a no-op.\n    COMMIT;\n  }\n  expr {[file size test.db] / 1024}\n} {4}\ndo_test incrvacuum-5.2.2 {\n  set ::str [string repeat abcdefghij 110]\n  execsql {\n    BEGIN;\n    INSERT INTO tbl1 VALUES($::str);\n    INSERT INTO tbl1 SELECT * FROM tbl1;\n    DELETE FROM tbl1 WHERE oid%2;        -- Put 2 overflow pages on free-list.\n    COMMIT;\n  }\n  expr {[file size test.db] / 1024}\n} {7}\ndo_test incrvacuum-5.2.3 {\n  execsql {\n    BEGIN;\n    PRAGMA incremental_vacuum;           -- Vacuum up the two pages.\n    CREATE TABLE tbl2(b);                -- Use one free page as a table root.\n    INSERT INTO tbl2 VALUES('a nice string');\n    COMMIT;\n  }\n  expr {[file size test.db] / 1024}\n} {6}\ndo_test incrvacuum-5.2.4 {\n  execsql {\n    SELECT * FROM tbl2;\n  }\n} {{a nice string}}\ndo_test incrvacuum-5.2.5 {\n  execsql {\n    DROP TABLE tbl1;\n    DROP TABLE tbl2;\n    PRAGMA incremental_vacuum;\n  }\n  expr {[file size test.db] / 1024}\n} {1}\n\n\n# Test cases incrvacuum-5.3.* use the following list as input data.\n# Two new databases are opened, one with incremental vacuum enabled,\n# the other with no auto-vacuum completely disabled. After executing\n# each element of the following list on both databases, test that\n# the integrity-check passes and the contents of each are identical.\n# \nset TestScriptList [list {\n  BEGIN;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE INDEX t1_i ON t1(a);\n  CREATE INDEX t2_i ON t2(a);\n} {\n  INSERT INTO t1 VALUES($::str1, $::str2);\n  INSERT INTO t1 VALUES($::str1||$::str2, $::str2||$::str1);\n  INSERT INTO t2 SELECT b, a FROM t1;\n  INSERT INTO t2 SELECT a, b FROM t1;\n  INSERT INTO t1 SELECT b, a FROM t2;\n  UPDATE t2 SET b = '';\n  PRAGMA incremental_vacuum;\n} {\n  UPDATE t2 SET b = (SELECT b FROM t1 WHERE t1.oid = t2.oid);\n  PRAGMA incremental_vacuum;\n} {\n  CREATE TABLE t3(a, b);\n  INSERT INTO t3 SELECT * FROM t2;\n  DROP TABLE t2;\n  PRAGMA incremental_vacuum;\n} {\n  CREATE INDEX t3_i ON t3(a);\n  COMMIT;\n} {\n  BEGIN;\n  DROP INDEX t3_i;\n  PRAGMA incremental_vacuum;\n  INSERT INTO t3 VALUES('hello', 'world');\n  ROLLBACK;\n} {\n  INSERT INTO t3 VALUES('hello', 'world');\n}\n]\n\n# If this build omits subqueries, step 2 in the above list will not\n# work. Replace it with \"\" in this case. \n#\nifcapable !subquery { lset TestScriptList 2 \"\" }\n\n# Compare the contents of databases $A and $B.\n#\nproc compare_dbs {A B tname} {\n  set tbl_list [execsql {\n    SELECT tbl_name FROM sqlite_master WHERE type = 'table'\n  } $A]\n\n  do_test ${tname}.1 [subst {\n    execsql {\n      SELECT tbl_name FROM sqlite_master WHERE type = 'table'\n    } $B\n  }] $tbl_list\n\n  set tn 1\n  foreach tbl $tbl_list {\n    set control [execsql \"SELECT * FROM $tbl\" $A]\n    do_test ${tname}.[incr tn] [subst {\n      execsql \"SELECT * FROM $tbl\" $B\n    }] $control\n  }\n}\n\nset ::str1 [string repeat abcdefghij 130]\nset ::str2 [string repeat 1234567890 105]\n\nforcedelete test1.db test1.db-journal test2.db test2.db-journal\nsqlite3 db1 test1.db\nsqlite3 db2 test2.db\nexecsql { PRAGMA auto_vacuum = 'none' } db1\nexecsql { PRAGMA auto_vacuum = 'incremental' } db2\n\nset tn 1\nforeach sql $::TestScriptList {\n  execsql $sql db1\n  execsql $sql db2\n\n  compare_dbs db1 db2 incrvacuum-5.3.${tn}\n  do_test incrvacuum-5.3.${tn}.integrity1 {\n    execsql { PRAGMA integrity_check; } db1\n  } {ok}\n  do_test incrvacuum-5.3.${tn}.integrity2 {\n    execsql { PRAGMA integrity_check; } db2\n  } {ok}\n  incr tn\n}\ndb1 close\ndb2 close\n#\n# End of test cases 5.3.*\n\n#---------------------------------------------------------------------\n# The following tests - incrvacuum-6.* - test running incremental \n# vacuum while another statement (a read) is being executed.\n#\nfor {set jj 0} {$jj < 10} {incr jj} {\n  # Build some test data. Two tables are created in an empty\n  # database. tbl1 data is a contiguous block starting at page 5 (pages\n  # 3 and 4 are the table roots). tbl2 is a contiguous block starting \n  # right after tbl1.\n  #\n  # Then drop tbl1 so that when an incr vacuum is run the pages\n  # of tbl2 have to be moved to fill the gap.\n  #\n  do_test incrvacuum-6.${jj}.1 {\n    execsql {\n      DROP TABLE IF EXISTS tbl1;\n      DROP TABLE IF EXISTS tbl2;\n      PRAGMA incremental_vacuum;\n      CREATE TABLE tbl1(a, b);\n      CREATE TABLE tbl2(a, b);\n      BEGIN;\n    }\n    for {set ii 0} {$ii < 1000} {incr ii} {\n      db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}\n    }\n    execsql {\n      INSERT INTO tbl2 SELECT * FROM tbl1;\n      COMMIT;\n      DROP TABLE tbl1;\n    }\n    expr {[file size test.db] / 1024}\n  } {36}\n\n  # Run a linear scan query on tbl2. After reading ($jj*100) rows, \n  # run the incremental vacuum to shrink the database.\n  #\n  do_test incrvacuum-6.${jj}.2 {\n    set ::nRow 0\n    db eval {SELECT a FROM tbl2} {} {\n      if {$a == [expr $jj*100]} {\n        db eval {PRAGMA incremental_vacuum}\n      }\n      incr ::nRow\n    }\n    list [expr {[file size test.db] / 1024}] $nRow\n  } {19 1000}\n}\n\n#---------------------------------------------------------------------\n# This test - incrvacuum-7.* - is to check that the database can be\n# written in the middle of an incremental vacuum.\n#\nset ::iWrite 1\nwhile 1 {\n  do_test incrvacuum-7.${::iWrite}.1 {\n    execsql {\n      DROP TABLE IF EXISTS tbl1;\n      DROP TABLE IF EXISTS tbl2;\n      PRAGMA incremental_vacuum;\n      CREATE TABLE tbl1(a, b);\n      CREATE TABLE tbl2(a, b);\n      BEGIN;\n    }\n    for {set ii 0} {$ii < 1000} {incr ii} {\n      db eval {INSERT INTO tbl1 VALUES($ii, $ii || $ii)}\n    }\n    execsql {\n      INSERT INTO tbl2 SELECT * FROM tbl1;\n      COMMIT;\n      DROP TABLE tbl1;\n    }\n    expr {[file size test.db] / 1024}\n  } {36}\n\n  do_test incrvacuum-7.${::iWrite}.2 {\n    set ::nRow 0\n    db eval {PRAGMA incremental_vacuum} {\n      incr ::nRow\n      if {$::nRow == $::iWrite} {\n        db eval {\n          CREATE TABLE tbl1(a, b);\n          INSERT INTO tbl1 VALUES('hello', 'world');\n        }\n      }\n    }\n    list [expr {[file size test.db] / 1024}]\n  } {20}\n\n  do_test incrvacuum-7.${::iWrite}.3 {\n    execsql {\n      SELECT * FROM tbl1;\n    }\n  } {hello world}\n\n  if {$::nRow == $::iWrite} break\n  incr ::iWrite\n}\n\n#---------------------------------------------------------------------\n# This test - incrvacuum-8.* - is to check that nothing goes wrong\n# with an incremental-vacuum if it is the first statement executed\n# after an existing database is opened.\n#\n# At one point, this would always return SQLITE_SCHEMA (which \n# causes an infinite loop in tclsqlite.c if using the Tcl interface).\n#\ndo_test incrvacuum-8.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA incremental_vacuum(50);\n  }\n} {}\n\n#---------------------------------------------------------------------\n# At one point this test case was causing an assert() to fail.\n#\ndo_test incrvacuum-9.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n\n  execsql {\n    PRAGMA auto_vacuum = 'incremental';\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n    INSERT INTO t2 VALUES(randstr(500,500),randstr(500,500),randstr(500,500));\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n    INSERT INTO t1 SELECT a||a, b||b, c||c FROM t1;\n  }\n} {}\n\ndo_test incrvacuum-9.2 {\n  execsql {\n    PRAGMA synchronous = 'OFF';\n    BEGIN;\n    UPDATE t1 SET a = a, b = b, c = c;\n    DROP TABLE t2;\n    PRAGMA incremental_vacuum(10);\n    ROLLBACK;\n  }\n} {}\n\ndo_test incrvacuum-9.3 {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    UPDATE t1 SET a = a, b = b, c = c;\n    DROP TABLE t2;\n    PRAGMA incremental_vacuum(10);\n    ROLLBACK;\n  }\n} {}\n\n#---------------------------------------------------------------------\n# Test that the parameter to the incremental_vacuum pragma works. That\n# is, if the user executes \"PRAGMA incremental_vacuum(N)\", at most\n# N pages are vacuumed.\n#\ndo_test incrvacuum-10.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n  }\n  expr [file size test.db] / 1024\n} {29}\n\ndo_test incrvacuum-10.2 {\n  execsql {\n    PRAGMA incremental_vacuum(1);\n  }\n  expr [file size test.db] / 1024\n} {28}\n\ndo_test incrvacuum-10.3 {\n  execsql {\n    PRAGMA incremental_vacuum(5);\n  }\n  expr [file size test.db] / 1024\n} {23}\n\ndo_test incrvacuum-10.4 {\n  execsql {\n    PRAGMA incremental_vacuum('1');\n  }\n  expr [file size test.db] / 1024\n} {22}\n\ndo_test incrvacuum-10.5 {\n  execsql {\n    PRAGMA incremental_vacuum(\"+3\");\n  }\n  expr [file size test.db] / 1024\n} {19}\n\ndo_test incrvacuum-10.6 {\n  execsql {\n    PRAGMA incremental_vacuum = 1;\n  }\n  expr [file size test.db] / 1024\n} {18}\n\ndo_test incrvacuum-10.7 {\n  # Use a really big number as an argument to incremetal_vacuum. Should\n  # be interpreted as \"free all possible space\".\n  execsql {\n    PRAGMA incremental_vacuum(2147483649);\n  }\n  expr [file size test.db] / 1024\n} {1}\n\ndo_test incrvacuum-10.8 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(hex(randomblob(1000)));\n    DROP TABLE t1;\n  }\n  # A negative number means free all possible space.\n  execsql {\n    PRAGMA incremental_vacuum=-1;\n  }\n  expr [file size test.db] / 1024\n} {1}\n\n#----------------------------------------------------------------\n# Test that if we set the auto_vacuum mode to 'incremental', then\n# create a database, thereafter that database defaults to incremental \n# vacuum mode.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\nifcapable default_autovacuum {\n  do_test incrvacuum-11.1-av-dflt-on {\n    execsql {\n      PRAGMA auto_vacuum;\n    }\n  } $AUTOVACUUM\n} else {\n  do_test incrvacuum-11.1-av-dflt-off {\n    execsql {\n      PRAGMA auto_vacuum;\n    }\n  } {0}\n}\ndo_test incrvacuum-11.2 {\n  execsql {\n    PRAGMA auto_vacuum = incremental;\n  }\n} {}\ndo_test incrvacuum-11.3 {\n  execsql {\n    PRAGMA auto_vacuum;\n  }\n} {2}\ndo_test incrvacuum-11.4 {\n  # The database has now been created.\n  expr {[file size test.db]>0}\n} {1}\ndo_test incrvacuum-11.5 {\n  # Close and reopen the connection.\n  db close\n  sqlite3 db test.db\n\n  # Test we are still in incremental vacuum mode.\n  execsql { PRAGMA auto_vacuum; }\n} {2}\ndo_test incrvacuum-11.6 {\n  execsql {\n    PRAGMA auto_vacuum = 'full';\n    PRAGMA auto_vacuum;\n  }\n} {1}\ndo_test incrvacuum-11.7 {\n  # Close and reopen the connection.\n  db close\n  sqlite3 db test.db\n\n  # Test we are still in \"full\" auto-vacuum mode.\n  execsql { PRAGMA auto_vacuum; }\n} {1}\n\n#----------------------------------------------------------------------\n# Special case: What happens if the database is locked when a \"PRAGMA\n# auto_vacuum = XXX\" statement is executed.\n#\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndo_test incrvacuum-12.1 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n  }\n  expr {[file size test.db]>0}\n} {1}\n\n# Try to change the auto-vacuum from \"full\" to \"incremental\" while the\n# database is locked. Nothing should change.\n#\ndo_test incrvacuum-12.2 {\n  sqlite3 db2 test.db\n  execsql { BEGIN EXCLUSIVE; } db2\n  catchsql { PRAGMA auto_vacuum = 2; }\n} {1 {database is locked}}\n\ndo_test incrvacuum-12.3 {\n  execsql { ROLLBACK; } db2\n  execsql { PRAGMA auto_vacuum }\n} {2}   ;# Still 2 because PRAGMA auto_vacuum setting held in case of vacuum\ndo_test incrvacuum-12.4 {\n  db close\n  sqlite3 db test.db\n  execsql { PRAGMA auto_vacuum }\n} {1}   ;# Revert to 1 because the database file did not change\n\ndo_test incrvacuum-12.5 {\n  execsql { SELECT * FROM sqlite_master }\n  execsql { PRAGMA auto_vacuum }\n} {1}\n\n#----------------------------------------------------------------------\n# Special case #2: What if one process prepares a \"PRAGMA auto_vacuum = XXX\"\n# statement when the database is empty, but doesn't execute it until\n# after some other process has created the database.\n#\ndb2 close\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db  ;  set ::DB [sqlite3_connection_pointer db]\nsqlite3 db2 test.db\n\ndo_test incrvacuum-13.1 {\n  # File size is sometimes 1 instead of 0 due to the hack we put in\n  # to work around ticket #3260.  Search for comments on #3260 in\n  # os_unix.c.\n  expr {[file size test.db]>1}\n} {0}\ndo_test incrvacuum-13.2 {\n  set ::STMT [sqlite3_prepare $::DB {PRAGMA auto_vacuum = 2} -1 DUMMY]\n  execsql {\n    PRAGMA auto_vacuum = none;\n    PRAGMA default_cache_size = 1024;\n    PRAGMA auto_vacuum;\n  } db2\n} {0}\ndo_test incrvacuum-13.3 {\n  expr {[file size test.db]>0}\n} {1}\ndo_test incrvacuum-13.4 {\n  set rc [sqlite3_step $::STMT]\n  list $rc [sqlite3_finalize $::STMT]\n} {SQLITE_DONE SQLITE_OK}\ndo_test incrvacuum-13.5 {\n  execsql {\n    PRAGMA auto_vacuum;\n  }\n} {0}\n\n\n# Verify that the incremental_vacuum pragma fails gracefully if it\n# is used against an invalid database file.\n#\nif {[permutation] == \"\"} {\n  do_test incrvacuum-14.1 {\n    set out [open invalid.db w]\n    puts $out \"This is not an SQLite database file\"\n    close $out\n    sqlite3 db3 invalid.db\n    catchsql {\n      PRAGMA incremental_vacuum(10);\n    } db3\n  } {1 {file is not a database}}\n  db3 close\n}\n\ndo_test incrvacuum-15.1 {\n  db close\n  db2 close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  set str [string repeat \"abcdefghij\" 500]\n\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA auto_vacuum = incremental;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES('a', $str);\n    INSERT INTO t1 VALUES('b', $str);\n    INSERT INTO t1 VALUES('c', $str);\n    INSERT INTO t1 VALUES('d', $str);\n    INSERT INTO t1 VALUES('e', $str);\n    INSERT INTO t1 VALUES('f', $str);\n    INSERT INTO t1 VALUES('g', $str);\n    INSERT INTO t1 VALUES('h', $str);\n    INSERT INTO t1 VALUES('i', $str);\n    INSERT INTO t1 VALUES('j', $str);\n    INSERT INTO t1 VALUES('j', $str);\n\n    CREATE TABLE t2(x PRIMARY KEY, y);\n    INSERT INTO t2 VALUES('a', $str);\n    INSERT INTO t2 VALUES('b', $str);\n    INSERT INTO t2 VALUES('c', $str);\n    INSERT INTO t2 VALUES('d', $str);\n\n    BEGIN;\n      DELETE FROM t2;\n      PRAGMA incremental_vacuum;\n  }\n\n  catchsql {INSERT INTO t2 SELECT * FROM t1}\n\n  execsql { \n    COMMIT;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrvacuum2.test",
    "content": "# 2007 May 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the incremental vacuum feature.\n#\n# $Id: incrvacuum2.test,v 1.6 2009/07/25 13:42:50 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum || !pragma} {\n  finish_test\n  return\n}\n\nset testprefix incrvacuum2\n\n# Create a database in incremental vacuum mode that has many\n# pages on the freelist.\n#\ndo_test incrvacuum2-1.1 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA auto_vacuum=incremental;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(zeroblob(30000));\n    DELETE FROM t1;\n  }\n  file size test.db\n} {32768}\n\n# Vacuum off a single page.\n#\ndo_test incrvacuum2-1.2 {\n  execsql {\n    PRAGMA incremental_vacuum(1);\n  }\n  file size test.db\n} {31744}\n\n# Vacuum off five pages\n#\ndo_test incrvacuum2-1.3 {\n  execsql {\n    PRAGMA incremental_vacuum(5);\n  }\n  file size test.db\n} {26624}\n\n# Vacuum off all the rest\n#\ndo_test incrvacuum2-1.4 {\n  execsql {\n    PRAGMA incremental_vacuum(1000);\n  }\n  file size test.db\n} {3072}\n\n# Make sure incremental vacuum works on attached databases.\n#\nifcapable attach {\n  do_test incrvacuum2-2.1 {\n    forcedelete test2.db test2.db-journal\n    execsql {\n      ATTACH DATABASE 'test2.db' AS aux;\n      PRAGMA aux.auto_vacuum=incremental;\n      CREATE TABLE aux.t2(x);\n      INSERT INTO t2 VALUES(zeroblob(30000));\n      INSERT INTO t1 SELECT * FROM t2;\n      DELETE FROM t2;\n      DELETE FROM t1;\n    }\n    list [file size test.db] [file size test2.db]\n  } {32768 32768}\n  do_test incrvacuum2-2.2 {\n    execsql {\n      PRAGMA aux.incremental_vacuum(1)\n    }\n    list [file size test.db] [file size test2.db]\n  } {32768 31744}\n  do_test incrvacuum2-2.3 {\n    execsql {\n      PRAGMA aux.incremental_vacuum(5)\n    }\n    list [file size test.db] [file size test2.db]\n  } {32768 26624}\n  do_test incrvacuum2-2.4 {\n    execsql {\n      PRAGMA main.incremental_vacuum(5)\n    }\n    list [file size test.db] [file size test2.db]\n  } {27648 26624}\n  do_test incrvacuum2-2.5 {\n    execsql {\n      PRAGMA aux.incremental_vacuum\n    }\n    list [file size test.db] [file size test2.db]\n  } {27648 3072}\n  do_test incrvacuum2-2.6 {\n    execsql {\n      PRAGMA incremental_vacuum(1)\n    }\n    list [file size test.db] [file size test2.db]\n  } {26624 3072}\n}\n\ndo_test incrvacuum2-3.1 {\n  execsql {\n    PRAGMA auto_vacuum = 'full';\n    BEGIN;\n    CREATE TABLE abc(a);\n    INSERT INTO abc VALUES(randstr(1500,1500));\n    COMMIT;\n  }\n} {}\ndo_test incrvacuum2-3.2 {\n  execsql {\n    BEGIN;\n    DELETE FROM abc;\n    PRAGMA incremental_vacuum;\n    COMMIT;\n  }\n} {}\n\nintegrity_check incrvacuum2-3.3\n\nif {[wal_is_capable]} {\n  # At one point, when a specific page was being extracted from the b-tree\n  # free-list (e.g. during an incremental-vacuum), all trunk pages that\n  # occurred before the specific page in the free-list trunk were being\n  # written to the journal or wal file. This is not necessary. Only the \n  # extracted page and the page that contains the pointer to it need to\n  # be journalled.\n  #\n  # This problem was fixed by [d03d63d77e] (just before 3.7.6 release).\n  #\n  # This test case builds a database containing many free pages. Then runs\n  # \"PRAGMA incremental_vacuum(1)\" until the db contains zero free pages.\n  # Each \"PRAGMA incremental_vacuum(1)\" should modify at most 4 pages. The\n  # worst case is when a trunk page is removed from the end of the db file.\n  # In this case pages written are:\n  #\n  #   1. The previous trunk page (that contains a pointer to the recycled\n  #      trunk page), and\n  #   2. The leaf page transformed into a trunk page to replace the recycled\n  #      page, and\n  #   3. The trunk page that contained a pointer to the leaf page used \n  #      in (2), and\n  #   4. Page 1. Page 1 is always updated, even in WAL mode, since it contains\n  #      the \"number of free-list pages\" field.\n  #\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  do_execsql_test 4.1 {\n    PRAGMA page_size = 512;\n    PRAGMA auto_vacuum = 2;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(400));\n    INSERT INTO t1 SELECT * FROM t1;            --    2\n    INSERT INTO t1 SELECT * FROM t1;            --    4\n    INSERT INTO t1 SELECT * FROM t1;            --    8\n    INSERT INTO t1 SELECT * FROM t1;            --   16\n    INSERT INTO t1 SELECT * FROM t1;            --   32\n    INSERT INTO t1 SELECT * FROM t1;            --  128\n    INSERT INTO t1 SELECT * FROM t1;            --  256\n    INSERT INTO t1 SELECT * FROM t1;            --  512\n    INSERT INTO t1 SELECT * FROM t1;            -- 1024\n    INSERT INTO t1 SELECT * FROM t1;            -- 2048\n    INSERT INTO t1 SELECT * FROM t1;            -- 4096\n    INSERT INTO t1 SELECT * FROM t1;            -- 8192\n    DELETE FROM t1 WHERE oid>512;\n    DELETE FROM t1;\n  }\n\n  do_test 4.2 {\n    execsql { \n      PRAGMA journal_mode = WAL;\n      PRAGMA incremental_vacuum(1);\n    }\n  } {wal}\n  do_test 4.2.1 {\n    execsql { PRAGMA wal_checkpoint }\n    file size test.db-wal\n  } [expr {32+2*(512+24)}]\n\n  do_test 4.3 {\n    db close\n    sqlite3 db test.db\n    set maxsz 0\n    while {[file size test.db] > [expr 512*3]} {\n      execsql { PRAGMA journal_mode = WAL }\n      execsql { PRAGMA wal_checkpoint }\n      execsql { PRAGMA incremental_vacuum(1) }\n      set newsz [file size test.db-wal]\n      if {$newsz>$maxsz} {set maxsz $newsz}\n    }\n    set maxsz \n  } [expr {32+3*(512+24)}]\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrvacuum3.test",
    "content": "# 2013 Feb 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for the SQLite library, focusing\n# on the incremental vacuum feature.\n#\n# The tests in this file were added at the same time as optimizations \n# were made to:\n#\n#   * Truncate the database after a rollback mode commit, and\n#\n#   * Avoid moving pages to locations from which they may need to be moved\n#     a second time if an incremental-vacuum proccess is allowed to vacuum\n#     the entire database.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix incrvacuum3\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum || !pragma} {\n  finish_test\n  return\n}\n\nproc check_on_disk {} {\n\n  # Copy the wal and journal files for database \"test.db\" to \"test2.db\".\n  forcedelete test2.db test2.db-journal test2.db-wal\n  if {[file exists test.db-journal]} { \n    forcecopy test.db-journal test2.db-journal \n  }\n  if {[file exists test.db-wal]} { \n    forcecopy test.db-wal test2.db-wal \n  }\n\n  # Now copy the database file itself. Do this using open/read/puts\n  # instead of the [file copy] command in order to avoid attempting\n  # to read the 512 bytes begining at offset $sqlite_pending_byte.\n  #\n  set sz [file size test.db]\n  set fd [open test.db]\n  set fd2 [open test2.db w]\n  fconfigure $fd  -encoding binary -translation binary\n  fconfigure $fd2 -encoding binary -translation binary\n  if {$sz>$::sqlite_pending_byte} {\n    puts -nonewline $fd2 [read $fd $::sqlite_pending_byte]\n    seek $fd [expr $::sqlite_pending_byte+512]\n    seek $fd2 [expr $::sqlite_pending_byte+512]\n  }\n  puts -nonewline $fd2 [read $fd]\n  close $fd2\n  close $fd\n\n  # Open \"test2.db\" and check it is Ok.\n  sqlite3 dbcheck test2.db\n  set ret [dbcheck eval { PRAGMA integrity_check }]\n  dbcheck close\n  set ret\n}\n\n# Run these tests once in rollback journal mode, and once in wal mode.\n#\nforeach {T jrnl_mode} {\n  1 delete\n  2 wal\n} {\n  catch { db close }\n  forcedelete test.db test.db-journal test.db-wal\n  sqlite3 db test.db\n  db eval {\n    PRAGMA cache_size = 5;\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 2;\n  }\n  db eval \"PRAGMA journal_mode = $jrnl_mode\"\n  \n  foreach {tn sql} {\n    1 {\n      CREATE TABLE t1(x UNIQUE);\n      INSERT INTO t1 VALUES(randomblob(400));\n      INSERT INTO t1 VALUES(randomblob(400));\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    --   4\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    --   8\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  16\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  32\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  64\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 128\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 256\n    }\n  \n    2 {\n      DELETE FROM t1 WHERE rowid%8;\n    }\n  \n    3 { \n      BEGIN;\n        PRAGMA incremental_vacuum = 100;\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  64\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 128\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 256\n      ROLLBACK;\n    }\n  \n    4 { \n      BEGIN;\n        SAVEPOINT one;\n          PRAGMA incremental_vacuum = 100;\n          SAVEPOINT two;\n            INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  64\n            INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 128\n            INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 256\n    }\n  \n    5 {   ROLLBACK to two }\n  \n    6 { ROLLBACK to one }\n  \n    7 { \n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  64\n        PRAGMA incremental_vacuum = 1000;\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 128\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    -- 256\n      ROLLBACK;\n    }\n  \n    8 { \n      BEGIN;\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  64\n        PRAGMA incremental_vacuum = 1000;\n        INSERT INTO t1 SELECT randomblob(400) FROM t1;    --  128\n      COMMIT;\n    }\n  } {\n    do_execsql_test $T.1.$tn.1 $sql\n    do_execsql_test $T.1.$tn.2 {PRAGMA integrity_check} ok\n    do_test         $T.1.$tn.3 { check_on_disk }        ok\n  }\n\n  do_execsql_test $T.1.x.1 { PRAGMA freelist_count   } 0\n  do_execsql_test $T.1.x.2 { SELECT count(*) FROM t1 } 128\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/incrvacuum_ioerr.test",
    "content": "# 2001 October 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# such as writes failing because the disk is full.\n# \n# The tests in this file use special facilities that are only\n# available in the SQLite test fixture.\n#\n# $Id: incrvacuum_ioerr.test,v 1.6 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If this build of the library does not support auto-vacuum, omit this\n# whole file.\nifcapable {!autovacuum} {\n  finish_test\n  return\n}\n\ndo_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {\n  PRAGMA auto_vacuum = 'incremental';\n  CREATE TABLE abc(a);\n  INSERT INTO abc VALUES(randstr(1500,1500));\n} -sqlbody {\n  BEGIN;\n  CREATE TABLE abc2(a);\n  DELETE FROM abc;\n  PRAGMA incremental_vacuum;\n  COMMIT;\n} \n\n# do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {\n#   db eval {\n#     PRAGMA auto_vacuum = 'full';\n#     PRAGMA cache_size = 10;\n#     BEGIN;\n#     CREATE TABLE abc(a, UNIQUE(a));\n#   }\n#   for {set ii 0} {$ii < 25} {incr ii} {\n#     db eval {INSERT INTO abc VALUES(randstr(1500,1500))}\n#   }\n#   db eval COMMIT\n# } -sqlbody {\n#   BEGIN;\n#   DELETE FROM abc WHERE (oid%3)==0;\n#   INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;\n#   CREATE INDEX abc_i ON abc(a);\n#   DELETE FROM abc WHERE (oid%2)==0;\n#   DROP INDEX abc_i;\n#   COMMIT;\n# }\n\ndo_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {\n  db eval {\n    PRAGMA auto_vacuum = 'full';\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE abc(a, UNIQUE(a));\n  }\n  for {set ii 0} {$ii < 25} {incr ii} {\n    db eval {INSERT INTO abc VALUES(randstr(1500,1500))}\n  }\n  db eval COMMIT\n} -sqlbody {\n  BEGIN;\n  PRAGMA incremental_vacuum;\n  DELETE FROM abc WHERE (oid%3)==0;\n  PRAGMA incremental_vacuum;\n  INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;\n  PRAGMA incremental_vacuum;\n  CREATE INDEX abc_i ON abc(a);\n  DELETE FROM abc WHERE (oid%2)==0;\n  PRAGMA incremental_vacuum;\n  DROP INDEX abc_i;\n  PRAGMA incremental_vacuum;\n  COMMIT;\n}\n\ndo_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {\n  db eval {\n    PRAGMA auto_vacuum = 'incremental';\n    BEGIN;\n    CREATE TABLE a(i integer, b blob);\n    INSERT INTO a VALUES(1, randstr(1500,1500));\n    INSERT INTO a VALUES(2, randstr(1500,1500));\n  }\n  db eval COMMIT\n  db eval {DELETE FROM a WHERE oid}\n} -sqlbody {\n  PRAGMA incremental_vacuum(5);\n} -cleanup {\n  sqlite3 db test.db\n  integrity_check incrvacuum-ioerr-2.$n.integritycheck\n  db close\n}\n\n\nifcapable shared_cache {\n\n  catch { db close }\n  forcedelete test.db\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n  \n  # Create two connections to a single shared-cache:\n  #\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n  \n  # Create a database with around 20 free pages.\n  #\n  do_test incrvacuum-ioerr-4.0 {\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA locking_mode = exclusive;\n      PRAGMA auto_vacuum = 'incremental';\n      BEGIN;\n      CREATE TABLE a(i integer, b blob);\n    } db1\n    for {set ii 0} {$ii < 20} {incr ii} {\n      execsql { INSERT INTO a VALUES($ii, randstr(800,1500)); } db1\n    }\n    execsql COMMIT db1\n    execsql {DELETE FROM a WHERE oid} db1\n  } {}\n  \n  set ::rc 1\n  for {set iTest 1} {$::rc && $iTest<2000} {incr iTest} {\n  \n    # Figure out how big the database is and how many free pages it\n    # has before running incremental-vacuum.\n    #\n    set nFree [execsql {pragma freelist_count} db1]\n    set nPage [execsql {pragma page_count} db1]\n    puts \"nFree=$nFree nPage=$nPage\"\n  \n    # Now run incremental-vacuum to vacuum 5 pages from the db file.\n    # The iTest'th I/O call is set to fail.\n    #\n    set ::sqlite_io_error_pending $iTest\n    set ::sqlite_io_error_persist 1\n    do_test incrvacuum-ioerr-4.$iTest.1 {\n      set ::rc [catch {execsql {pragma incremental_vacuum(5)} db1} msg]\n      expr {$::rc==0 || $msg eq \"disk I/O error\"}\n    } {1}\n  \n    set ::sqlite_io_error_pending 0\n    set ::sqlite_io_error_persist 0\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_hardhit 0\n  \n    set nFree2 [execsql {pragma freelist_count} db1]\n    set nPage2 [execsql {pragma page_count} db1]\n  \n    do_test incrvacuum-ioerr-4.$iTest.2 {\n      set shrink [expr {$nPage-$nPage2}]\n      expr {$shrink==0 || $shrink==5 || ($nFree<5 && $shrink==$nFree)}\n    } {1}\n  \n    do_test incrvacuum-ioerr-4.$iTest.3 {\n      expr {$nPage - $nPage2}\n    } [expr {$nFree - $nFree2}]\n  }\n  \n  # Close the two database connections and restore the default\n  # shared-cache mode setting.\n  #\n  db1 close\n  db2 close\n  sqlite3_enable_shared_cache $::enable_shared_cache\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE INDEX statement.\n#\n# $Id: index.test,v 1.43 2008/01/16 18:20:42 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a basic index and verify it is added to sqlite_master\n#\ndo_test index-1.1 {\n  execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}\n  execsql {CREATE INDEX index1 ON test1(f1)}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {index1 test1}\ndo_test index-1.1b {\n  execsql {SELECT name, sql, tbl_name, type FROM sqlite_master \n           WHERE name='index1'}\n} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}\ndo_test index-1.1c {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT name, sql, tbl_name, type FROM sqlite_master \n           WHERE name='index1'}\n} {index1 {CREATE INDEX index1 ON test1(f1)} test1 index}\ndo_test index-1.1d {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {index1 test1}\n\n# Verify that the index dies with the table\n#\ndo_test index-1.2 {\n  execsql {DROP TABLE test1}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {}\n\n# Try adding an index to a table that does not exist\n#\ndo_test index-2.1 {\n  set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg]\n  lappend v $msg\n} {1 {no such table: main.test1}}\n\n# Try adding an index on a column of a table where the table\n# exists but the column does not.\n#\ndo_test index-2.1b {\n  execsql {CREATE TABLE test1(f1 int, f2 int, f3 int)}\n  set v [catch {execsql {CREATE INDEX index1 ON test1(f4)}} msg]\n  lappend v $msg\n} {1 {no such column: f4}}\n\n# Try an index with some columns that match and others that do now.\n#\ndo_test index-2.2 {\n  set v [catch {execsql {CREATE INDEX index1 ON test1(f1, f2, f4, f3)}} msg]\n  execsql {DROP TABLE test1}\n  lappend v $msg\n} {1 {no such column: f4}}\n\n# Try creating a bunch of indices on the same table\n#\nset r {}\nfor {set i 1} {$i<100} {incr i} {\n  lappend r [format index%02d $i]\n}\ndo_test index-3.1 {\n  execsql {CREATE TABLE test1(f1 int, f2 int, f3 int, f4 int, f5 int)}\n  for {set i 1} {$i<100} {incr i} {\n    set sql \"CREATE INDEX [format index%02d $i] ON test1(f[expr {($i%5)+1}])\"\n    execsql $sql\n  }\n  execsql {SELECT name FROM sqlite_master \n           WHERE type='index' AND tbl_name='test1'\n           ORDER BY name}\n} $r\nintegrity_check index-3.2.1\nifcapable {reindex} {\n  do_test index-3.2.2 {\n    execsql REINDEX\n  } {}\n}\nintegrity_check index-3.2.3\n\n\n# Verify that all the indices go away when we drop the table.\n#\ndo_test index-3.3 {\n  execsql {DROP TABLE test1}\n  execsql {SELECT name FROM sqlite_master \n           WHERE type='index' AND tbl_name='test1'\n           ORDER BY name}\n} {}\n\n# Create a table and insert values into that table.  Then create\n# an index on that table.  Verify that we can select values\n# from the table correctly using the index.\n#\n# Note that the index names \"index9\" and \"indext\" are chosen because\n# they both have the same hash.\n#\ndo_test index-4.1 {\n  execsql {CREATE TABLE test1(cnt int, power int)}\n  for {set i 1} {$i<20} {incr i} {\n    execsql \"INSERT INTO test1 VALUES($i,[expr {1<<$i}])\"\n  }\n  execsql {CREATE INDEX index9 ON test1(cnt)}\n  execsql {CREATE INDEX indext ON test1(power)}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {index9 indext test1}\ndo_test index-4.2 {\n  execsql {SELECT cnt FROM test1 WHERE power=4}\n} {2}\ndo_test index-4.3 {\n  execsql {SELECT cnt FROM test1 WHERE power=1024}\n} {10}\ndo_test index-4.4 {\n  execsql {SELECT power FROM test1 WHERE cnt=6}\n} {64}\ndo_test index-4.5 {\n  execsql {DROP INDEX indext}\n  execsql {SELECT power FROM test1 WHERE cnt=6}\n} {64}\ndo_test index-4.6 {\n  execsql {SELECT cnt FROM test1 WHERE power=1024}\n} {10}\ndo_test index-4.7 {\n  execsql {CREATE INDEX indext ON test1(cnt)}\n  execsql {SELECT power FROM test1 WHERE cnt=6}\n} {64}\ndo_test index-4.8 {\n  execsql {SELECT cnt FROM test1 WHERE power=1024}\n} {10}\ndo_test index-4.9 {\n  execsql {DROP INDEX index9}\n  execsql {SELECT power FROM test1 WHERE cnt=6}\n} {64}\ndo_test index-4.10 {\n  execsql {SELECT cnt FROM test1 WHERE power=1024}\n} {10}\ndo_test index-4.11 {\n  execsql {DROP INDEX indext}\n  execsql {SELECT power FROM test1 WHERE cnt=6}\n} {64}\ndo_test index-4.12 {\n  execsql {SELECT cnt FROM test1 WHERE power=1024}\n} {10}\ndo_test index-4.13 {\n  execsql {DROP TABLE test1}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {}\nintegrity_check index-4.14\n\n# Do not allow indices to be added to sqlite_master\n#\ndo_test index-5.1 {\n  set v [catch {execsql {CREATE INDEX index1 ON sqlite_master(name)}} msg]\n  lappend v $msg\n} {1 {table sqlite_master may not be indexed}}\ndo_test index-5.2 {\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Do not allow indices with duplicate names to be added\n#\ndo_test index-6.1 {\n  execsql {CREATE TABLE test1(f1 int, f2 int)}\n  execsql {CREATE TABLE test2(g1 real, g2 real)}\n  execsql {CREATE INDEX index1 ON test1(f1)}\n  set v [catch {execsql {CREATE INDEX index1 ON test2(g1)}} msg]\n  lappend v $msg\n} {1 {index index1 already exists}}\ndo_test index-6.1.1 {\n  catchsql {CREATE INDEX [index1] ON test2(g1)}\n} {1 {index index1 already exists}}\ndo_test index-6.1b {\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {index1 test1 test2}\ndo_test index-6.1c {\n  catchsql {CREATE INDEX IF NOT EXISTS index1 ON test1(f1)}\n} {0 {}}\ndo_test index-6.2 {\n  set v [catch {execsql {CREATE INDEX test1 ON test2(g1)}} msg]\n  lappend v $msg\n} {1 {there is already a table named test1}}\ndo_test index-6.2b {\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {index1 test1 test2}\ndo_test index-6.3 {\n  execsql {DROP TABLE test1}\n  execsql {DROP TABLE test2}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {}\ndo_test index-6.4 {\n  execsql {\n    CREATE TABLE test1(a,b);\n    CREATE INDEX index1 ON test1(a);\n    CREATE INDEX index2 ON test1(b);\n    CREATE INDEX index3 ON test1(a,b);\n    DROP TABLE test1;\n    SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name;\n  }\n} {}\nintegrity_check index-6.5\n\n\n# Create a primary key\n#\ndo_test index-7.1 {\n  execsql {CREATE TABLE test1(f1 int, f2 int primary key)}\n  for {set i 1} {$i<20} {incr i} {\n    execsql \"INSERT INTO test1 VALUES($i,[expr {1<<$i}])\"\n  }\n  execsql {SELECT count(*) FROM test1}\n} {19}\ndo_test index-7.2 {\n  execsql {SELECT f1 FROM test1 WHERE f2=65536}\n} {16}\ndo_test index-7.3 {\n  execsql {\n    SELECT name FROM sqlite_master \n    WHERE type='index' AND tbl_name='test1'\n  }\n} {sqlite_autoindex_test1_1}\ndo_test index-7.4 {\n  execsql {DROP table test1}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\nintegrity_check index-7.5\n\n# Make sure we cannot drop a non-existant index.\n#\ndo_test index-8.1 {\n  set v [catch {execsql {DROP INDEX index1}} msg]\n  lappend v $msg\n} {1 {no such index: index1}}\n\n# Make sure we don't actually create an index when the EXPLAIN keyword\n# is used.\n#\ndo_test index-9.1 {\n  execsql {CREATE TABLE tab1(a int)}\n  ifcapable {explain} {\n    execsql {EXPLAIN CREATE INDEX idx1 ON tab1(a)}\n  }\n  execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1'}\n} {tab1}\ndo_test index-9.2 {\n  execsql {CREATE INDEX idx1 ON tab1(a)}\n  execsql {SELECT name FROM sqlite_master WHERE tbl_name='tab1' ORDER BY name}\n} {idx1 tab1}\nintegrity_check index-9.3\n\n# Allow more than one entry with the same key.\n#\ndo_test index-10.0 {\n  execsql {\n    CREATE TABLE t1(a int, b int);\n    CREATE INDEX i1 ON t1(a);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(2,4);\n    INSERT INTO t1 VALUES(3,8);\n    INSERT INTO t1 VALUES(1,12);\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {2 12}\ndo_test index-10.1 {\n  execsql {\n    SELECT b FROM t1 WHERE a=2 ORDER BY b;\n  }\n} {4}\ndo_test index-10.2 {\n  execsql {\n    DELETE FROM t1 WHERE b=12;\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {2}\ndo_test index-10.3 {\n  execsql {\n    DELETE FROM t1 WHERE b=2;\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {}\ndo_test index-10.4 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES (1,1);\n    INSERT INTO t1 VALUES (1,2);\n    INSERT INTO t1 VALUES (1,3);\n    INSERT INTO t1 VALUES (1,4);\n    INSERT INTO t1 VALUES (1,5);\n    INSERT INTO t1 VALUES (1,6);\n    INSERT INTO t1 VALUES (1,7);\n    INSERT INTO t1 VALUES (1,8);\n    INSERT INTO t1 VALUES (1,9);\n    INSERT INTO t1 VALUES (2,0);\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {1 2 3 4 5 6 7 8 9}\ndo_test index-10.5 {\n  ifcapable subquery {\n    execsql { DELETE FROM t1 WHERE b IN (2, 4, 6, 8); }\n  } else {\n    execsql { DELETE FROM t1 WHERE b = 2 OR b = 4 OR b = 6 OR b = 8; }\n  }\n  execsql {\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {1 3 5 7 9}\ndo_test index-10.6 {\n  execsql {\n    DELETE FROM t1 WHERE b>2;\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {1}\ndo_test index-10.7 {\n  execsql {\n    DELETE FROM t1 WHERE b=1;\n    SELECT b FROM t1 WHERE a=1 ORDER BY b;\n  }\n} {}\ndo_test index-10.8 {\n  execsql {\n    SELECT b FROM t1 ORDER BY b;\n  }\n} {0}\nintegrity_check index-10.9\n\n# Automatically create an index when we specify a primary key.\n#\ndo_test index-11.1 {\n  execsql {\n    CREATE TABLE t3(\n      a text,\n      b int,\n      c float,\n      PRIMARY KEY(b)\n    );\n  }\n  for {set i 1} {$i<=50} {incr i} {\n    execsql \"INSERT INTO t3 VALUES('x${i}x',$i,0.$i)\"\n  }\n  set sqlite_search_count 0\n  concat [execsql {SELECT c FROM t3 WHERE b==10}] $sqlite_search_count\n} {0.1 2}\nintegrity_check index-11.2\n\n\n# Numeric strings should compare as if they were numbers.  So even if the\n# strings are not character-by-character the same, if they represent the\n# same number they should compare equal to one another.  Verify that this\n# is true in indices.\n#\n# Updated for sqlite3 v3: SQLite will now store these values as numbers\n# (because the affinity of column a is NUMERIC) so the quirky\n# representations are not retained. i.e. '+1.0' becomes '1'.\ndo_test index-12.1 {\n  execsql {\n    CREATE TABLE t4(a NUM,b);\n    INSERT INTO t4 VALUES('0.0',1);\n    INSERT INTO t4 VALUES('0.00',2);\n    INSERT INTO t4 VALUES('abc',3);\n    INSERT INTO t4 VALUES('-1.0',4);\n    INSERT INTO t4 VALUES('+1.0',5);\n    INSERT INTO t4 VALUES('0',6);\n    INSERT INTO t4 VALUES('00000',7);\n    SELECT a FROM t4 ORDER BY b;\n  }\n} {0 0 abc -1 1 0 0}\ndo_test index-12.2 {\n  execsql {\n    SELECT a FROM t4 WHERE a==0 ORDER BY b\n  }\n} {0 0 0 0}\ndo_test index-12.3 {\n  execsql {\n    SELECT a FROM t4 WHERE a<0.5 ORDER BY b\n  }\n} {0 0 -1 0 0}\ndo_test index-12.4 {\n  execsql {\n    SELECT a FROM t4 WHERE a>-0.5 ORDER BY b\n  }\n} {0 0 abc 1 0 0}\ndo_test index-12.5 {\n  execsql {\n    CREATE INDEX t4i1 ON t4(a);\n    SELECT a FROM t4 WHERE a==0 ORDER BY b\n  }\n} {0 0 0 0}\ndo_test index-12.6 {\n  execsql {\n    SELECT a FROM t4 WHERE a<0.5 ORDER BY b\n  }\n} {0 0 -1 0 0}\ndo_test index-12.7 {\n  execsql {\n    SELECT a FROM t4 WHERE a>-0.5 ORDER BY b\n  }\n} {0 0 abc 1 0 0}\nintegrity_check index-12.8\n\n# Make sure we cannot drop an automatically created index.\n#\ndo_test index-13.1 {\n  execsql {\n   CREATE TABLE t5(\n      a int UNIQUE,\n      b float PRIMARY KEY,\n      c varchar(10),\n      UNIQUE(a,c)\n   );\n   INSERT INTO t5 VALUES(1,2,3);\n   SELECT * FROM t5;\n  }\n} {1 2.0 3}\ndo_test index-13.2 {\n  set ::idxlist [execsql {\n    SELECT name FROM sqlite_master WHERE type=\"index\" AND tbl_name=\"t5\";\n  }]\n  llength $::idxlist\n} {3}\nfor {set i 0} {$i<[llength $::idxlist]} {incr i} {\n  do_test index-13.3.$i {\n    catchsql \"\n      DROP INDEX '[lindex $::idxlist $i]';\n    \"\n  } {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}\n}\ndo_test index-13.4 {\n  execsql {\n    INSERT INTO t5 VALUES('a','b','c');\n    SELECT * FROM t5;\n  }\n} {1 2.0 3 a b c}\nintegrity_check index-13.5\n\n# Check the sort order of data in an index.\n#\ndo_test index-14.1 {\n  execsql {\n    CREATE TABLE t6(a,b,c);\n    CREATE INDEX t6i1 ON t6(a,b);\n    INSERT INTO t6 VALUES('','',1);\n    INSERT INTO t6 VALUES('',NULL,2);\n    INSERT INTO t6 VALUES(NULL,'',3);\n    INSERT INTO t6 VALUES('abc',123,4);\n    INSERT INTO t6 VALUES(123,'abc',5);\n    SELECT c FROM t6 ORDER BY a,b;\n  }\n} {3 5 2 1 4}\ndo_test index-14.2 {\n  execsql {\n    SELECT c FROM t6 WHERE a='';\n  }\n} {2 1}\ndo_test index-14.3 {\n  execsql {\n    SELECT c FROM t6 WHERE b='';\n  }\n} {1 3}\ndo_test index-14.4 {\n  execsql {\n    SELECT c FROM t6 WHERE a>'';\n  }\n} {4}\ndo_test index-14.5 {\n  execsql {\n    SELECT c FROM t6 WHERE a>='';\n  }\n} {2 1 4}\ndo_test index-14.6 {\n  execsql {\n    SELECT c FROM t6 WHERE a>123;\n  }\n} {2 1 4}\ndo_test index-14.7 {\n  execsql {\n    SELECT c FROM t6 WHERE a>=123;\n  }\n} {5 2 1 4}\ndo_test index-14.8 {\n  execsql {\n    SELECT c FROM t6 WHERE a<'abc';\n  }\n} {5 2 1}\ndo_test index-14.9 {\n  execsql {\n    SELECT c FROM t6 WHERE a<='abc';\n  }\n} {5 2 1 4}\ndo_test index-14.10 {\n  execsql {\n    SELECT c FROM t6 WHERE a<='';\n  }\n} {5 2 1}\ndo_test index-14.11 {\n  execsql {\n    SELECT c FROM t6 WHERE a<'';\n  }\n} {5}\nintegrity_check index-14.12\n\ndo_test index-15.1 {\n  execsql {\n    DELETE FROM t1;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test index-15.2 {\n  execsql {\n    INSERT INTO t1 VALUES('1.234e5',1);\n    INSERT INTO t1 VALUES('12.33e04',2);\n    INSERT INTO t1 VALUES('12.35E4',3);\n    INSERT INTO t1 VALUES('12.34e',4);\n    INSERT INTO t1 VALUES('12.32e+4',5);\n    INSERT INTO t1 VALUES('12.36E+04',6);\n    INSERT INTO t1 VALUES('12.36E+',7);\n    INSERT INTO t1 VALUES('+123.10000E+0003',8);\n    INSERT INTO t1 VALUES('+',9);\n    INSERT INTO t1 VALUES('+12347.E+02',10);\n    INSERT INTO t1 VALUES('+12347E+02',11);\n    INSERT INTO t1 VALUES('+.125E+04',12);\n    INSERT INTO t1 VALUES('-.125E+04',13);\n    INSERT INTO t1 VALUES('.125E+0',14);\n    INSERT INTO t1 VALUES('.125',15);\n    SELECT b FROM t1 ORDER BY a, b;\n  }\n} {13 14 15 12 8 5 2 1 3 6 10 11 9 4 7}\ndo_test index-15.3 {\n  execsql {\n    SELECT b FROM t1 WHERE typeof(a) IN ('integer','real') ORDER BY b;\n  }\n} {1 2 3 5 6 8 10 11 12 13 14 15}\nintegrity_check index-15.4\n\n# The following tests - index-16.* - test that when a table definition\n# includes qualifications that specify the same constraint twice only a\n# single index is generated to enforce the constraint.\n#\n# For example: \"CREATE TABLE abc( x PRIMARY KEY, UNIQUE(x) );\"\n#\ndo_test index-16.1 {\n  execsql {\n    CREATE TABLE t7(c UNIQUE PRIMARY KEY);\n    SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {1}\ndo_test index-16.2 {\n  execsql {\n    DROP TABLE t7;\n    CREATE TABLE t7(c UNIQUE PRIMARY KEY);\n    SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {1}\ndo_test index-16.3 {\n  execsql {\n    DROP TABLE t7;\n    CREATE TABLE t7(c PRIMARY KEY, UNIQUE(c) );\n    SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {1}\ndo_test index-16.4 {\n  execsql {\n    DROP TABLE t7;\n    CREATE TABLE t7(c, d , UNIQUE(c, d), PRIMARY KEY(c, d) );\n    SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {1}\ndo_test index-16.5 {\n  execsql {\n    DROP TABLE t7;\n    CREATE TABLE t7(c, d , UNIQUE(c), PRIMARY KEY(c, d) );\n    SELECT count(*) FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {2}\n\n# Test that automatically create indices are named correctly. The current\n# convention is: \"sqlite_autoindex_<table name>_<integer>\"\n#\n# Then check that it is an error to try to drop any automtically created\n# indices.\ndo_test index-17.1 {\n  execsql {\n    DROP TABLE t7;\n    CREATE TABLE t7(c, d UNIQUE, UNIQUE(c), PRIMARY KEY(c, d) );\n    SELECT name FROM sqlite_master WHERE tbl_name = 't7' AND type = 'index';\n  }\n} {sqlite_autoindex_t7_1 sqlite_autoindex_t7_2 sqlite_autoindex_t7_3}\ndo_test index-17.2 {\n  catchsql {\n    DROP INDEX sqlite_autoindex_t7_1;\n  }\n} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}\ndo_test index-17.3 {\n  catchsql {\n    DROP INDEX IF EXISTS sqlite_autoindex_t7_1;\n  }\n} {1 {index associated with UNIQUE or PRIMARY KEY constraint cannot be dropped}}\ndo_test index-17.4 {\n  catchsql {\n    DROP INDEX IF EXISTS no_such_index;\n  }\n} {0 {}}\n\n\n# The following tests ensure that it is not possible to explicitly name\n# a schema object with a name beginning with \"sqlite_\". Granted that is a\n# little outside the focus of this test scripts, but this has got to be\n# tested somewhere.\ndo_test index-18.1 {\n  catchsql {\n    CREATE TABLE sqlite_t1(a, b, c);\n  }\n} {1 {object name reserved for internal use: sqlite_t1}}\ndo_test index-18.2 {\n  catchsql {\n    CREATE INDEX sqlite_i1 ON t7(c);\n  }\n} {1 {object name reserved for internal use: sqlite_i1}}\nifcapable view {\ndo_test index-18.3 {\n  catchsql {\n    CREATE VIEW sqlite_v1 AS SELECT * FROM t7;\n  }\n} {1 {object name reserved for internal use: sqlite_v1}}\n} ;# ifcapable view\nifcapable {trigger} {\n  do_test index-18.4 {\n    catchsql {\n      CREATE TRIGGER sqlite_tr1 BEFORE INSERT ON t7 BEGIN SELECT 1; END;\n    }\n  } {1 {object name reserved for internal use: sqlite_tr1}}\n}\ndo_test index-18.5 {\n  execsql {\n    DROP TABLE t7;\n  }\n} {}\n\n# These tests ensure that if multiple table definition constraints are\n# implemented by a single indice, the correct ON CONFLICT policy applies.\nifcapable conflict {\n  do_test index-19.1 {\n    execsql {\n      CREATE TABLE t7(a UNIQUE PRIMARY KEY);\n      CREATE TABLE t8(a UNIQUE PRIMARY KEY ON CONFLICT ROLLBACK);\n      INSERT INTO t7 VALUES(1);\n      INSERT INTO t8 VALUES(1);\n    }\n  } {}\n  do_test index-19.2 {\n    catchsql {\n      BEGIN;\n      INSERT INTO t7 VALUES(1);\n    }\n  } {1 {UNIQUE constraint failed: t7.a}}\n  do_test index-19.3 {\n    catchsql {\n      BEGIN;\n    }\n  } {1 {cannot start a transaction within a transaction}}\n  do_test index-19.4 {\n    catchsql {\n      INSERT INTO t8 VALUES(1);\n    }\n  } {1 {UNIQUE constraint failed: t8.a}}\n  do_test index-19.5 {\n    catchsql {\n      BEGIN;\n      COMMIT;\n    }\n  } {0 {}}\n  do_test index-19.6 {\n    catchsql {\n      DROP TABLE t7;\n      DROP TABLE t8;\n      CREATE TABLE t7(\n         a PRIMARY KEY ON CONFLICT FAIL, \n         UNIQUE(a) ON CONFLICT IGNORE\n      );\n    }\n  } {1 {conflicting ON CONFLICT clauses specified}}\n} ; # end of \"ifcapable conflict\" block\n\nifcapable {reindex} {\n  do_test index-19.7 {\n    execsql REINDEX\n  } {}\n}\nintegrity_check index-19.8\n\n# Drop index with a quoted name.  Ticket #695.\n#\ndo_test index-20.1 {\n  execsql {\n    CREATE INDEX \"t6i2\" ON t6(c);\n    DROP INDEX \"t6i2\";\n  }\n} {}\ndo_test index-20.2 {\n  execsql {\n    DROP INDEX \"t6i1\";\n  }\n} {}\n\n# Try to create a TEMP index on a non-TEMP table. */\n#\ndo_test index-21.1 {\n  catchsql {\n     CREATE INDEX temp.i21 ON t6(c);\n  }\n} {1 {cannot create a TEMP index on non-TEMP table \"t6\"}}\ndo_test index-21.2 {\n  catchsql {\n     CREATE TEMP TABLE t6(x);\n     INSERT INTO temp.t6 values(1),(5),(9);\n     CREATE INDEX temp.i21 ON t6(x);\n     SELECT x FROM t6 ORDER BY x DESC;\n  }\n} {0 {9 5 1}}\n\n   \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index2.test",
    "content": "# 2005-01-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE INDEX statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table with a large number of columns\n#\ndo_test index2-1.1 {\n  set sql {CREATE TABLE t1(}\n  for {set i 1} {$i<1000} {incr i} {\n    append sql \"c$i,\"\n  }\n  append sql \"c1000);\"\n  execsql $sql\n} {}\ndo_test index2-1.2 {\n  set sql {INSERT INTO t1 VALUES(}\n  for {set i 1} {$i<1000} {incr i} {\n    append sql $i,\n  }\n  append sql {1000);}\n  execsql $sql\n} {}\ndo_test index2-1.3 {\n  execsql {SELECT c123 FROM t1}\n} 123\ndo_test index2-1.4 {\n  execsql BEGIN\n  for {set j 1} {$j<=100} {incr j} {\n    set sql {INSERT INTO t1 VALUES(}\n    for {set i 1} {$i<1000} {incr i} {\n      append sql [expr {$j*10000+$i}],\n    }\n    append sql \"[expr {$j*10000+1000}]);\"\n    execsql $sql\n  }\n  execsql COMMIT\n  execsql {SELECT count(*) FROM t1}\n} 101\ndo_test index2-1.5 {\n  execsql {SELECT round(sum(c1000)) FROM t1}\n} {50601000.0}\n\n# Create indices with many columns\n#\ndo_test index2-2.1 {\n  set sql \"CREATE INDEX t1i1 ON t1(\"\n  for {set i 1} {$i<1000} {incr i} {\n    append sql c$i,\n  }\n  append sql c1000)\n  execsql $sql\n} {}\ndo_test index2-2.2 {\n  ifcapable explain {\n    execsql {EXPLAIN SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5}\n  }\n  execsql {SELECT c9 FROM t1 ORDER BY c1, c2, c3, c4, c5, c6 LIMIT 5}\n} {9 10009 20009 30009 40009}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index3.test",
    "content": "# 2005-02-14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE INDEX statement.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Ticket #1115.  Make sure that when a UNIQUE index is created on a\n# non-unique column (or columns) that it fails and that it leaves no\n# residue behind.\n#\ndo_test index3-1.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1;\n  }\n} {1 1}\ndo_test index3-1.2 {\n  catchsql {\n    BEGIN;\n    CREATE UNIQUE INDEX i1 ON t1(a);\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test index3-1.3 {\n  catchsql COMMIT;\n} {0 {}}\nintegrity_check index3-1.4\n\n# Backwards compatibility test:\n#\n# Verify that CREATE INDEX statements that use strings instead of \n# identifiers for the the column names continue to work correctly.\n# This is undocumented behavior retained for backwards compatiblity.\n#\ndo_execsql_test index3-2.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a, b, c, d, e, \n                  PRIMARY KEY('a'), UNIQUE('b' COLLATE nocase DESC));\n  CREATE INDEX t1c ON t1('c');\n  CREATE INDEX t1d ON t1('d' COLLATE binary ASC);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<30)\n    INSERT INTO t1(a,b,c,d,e) \n      SELECT x, printf('ab%03xxy',x), x, x, x FROM c;\n} {}\ndo_execsql_test index3-2.2 {\n  SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;\n} {5}\ndo_execsql_test index3-2.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b='ab005xy' COLLATE nocase;\n} {/USING INDEX/}\ndo_execsql_test index3-2.3 {\n  SELECT name FROM sqlite_master WHERE tbl_name='t1' ORDER BY name\n} {sqlite_autoindex_t1_1 sqlite_autoindex_t1_2 t1 t1c t1d}\ndo_execsql_test index3-2.4 {\n  CREATE TABLE t2a(a integer, b, PRIMARY KEY(a));\n  CREATE TABLE t2b(\"a\" integer, b, PRIMARY KEY(\"a\"));\n  CREATE TABLE t2c([a] integer, b, PRIMARY KEY([a]));\n  CREATE TABLE t2d('a' integer, b, PRIMARY KEY('a'));\n}\ndo_execsql_test index3-2.5 {\n  SELECT name FROM sqlite_master WHERE tbl_name LIKE 't2_' ORDER BY name\n} {t2a t2b t2c t2d}\n \n\n\n\n\n# This test corrupts the database file so it must be the last test\n# in the series.\n#\ndo_test index3-99.1 {\n  execsql {\n    PRAGMA writable_schema=on;\n    UPDATE sqlite_master SET sql='nonsense' WHERE name='t1d'\n  }\n  db close\n  catch { sqlite3 db test.db }\n  catchsql { DROP INDEX t1c }\n} {1 {malformed database schema (t1d)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index4.test",
    "content": "# 2011 July 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE INDEX statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix index4\n\ndo_execsql_test 1.1 {\n  BEGIN;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(102));\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     2\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     4\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     8\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --    16\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --    32\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --    64\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --   128\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --   256\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --   512\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --  1024\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --  2048\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --  4096\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     --  8192\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     -- 16384\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     -- 32768\n    INSERT INTO t1 SELECT randomblob(102) FROM t1;     -- 65536\n  COMMIT;\n}\n\ndo_execsql_test 1.2 {\n  CREATE INDEX i1 ON t1(x);\n}\ndo_execsql_test 1.3 {\n  PRAGMA integrity_check \n} {ok}\n\n# The same test again - this time with limited memory.\n#\nifcapable memorymanage {\n  set soft_limit [sqlite3_soft_heap_limit 50000]\n\n  db close\n  sqlite3 db test.db\n\n  do_execsql_test 1.4 {\n    PRAGMA cache_size = 10;\n    CREATE INDEX i2 ON t1(x);\n  }\n  do_execsql_test 1.5 {\n    PRAGMA integrity_check \n  } {ok}\n\n  sqlite3_soft_heap_limit $soft_limit\n}\n\n\ndo_execsql_test 1.6 {\n  BEGIN;\n    DROP TABLE t1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('a');\n    INSERT INTO t1 VALUES('b');\n    INSERT INTO t1 VALUES('c');\n    INSERT INTO t1 VALUES('d');\n    INSERT INTO t1 VALUES('e');\n    INSERT INTO t1 VALUES('f');\n    INSERT INTO t1 VALUES('g');\n    INSERT INTO t1 VALUES(NULL);\n    INSERT INTO t1 SELECT randomblob(1202) FROM t1;     --    16\n    INSERT INTO t1 SELECT randomblob(2202) FROM t1;     --    32\n    INSERT INTO t1 SELECT randomblob(3202) FROM t1;     --    64\n    INSERT INTO t1 SELECT randomblob(4202) FROM t1;     --   128\n    INSERT INTO t1 SELECT randomblob(5202) FROM t1;     --   256\n  COMMIT;\n  CREATE INDEX i1 ON t1(x); \n  PRAGMA integrity_check\n} {ok}\n\ndo_execsql_test 1.7 {\n  BEGIN;\n    DROP TABLE t1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('a');\n  COMMIT;\n  CREATE INDEX i1 ON t1(x); \n  PRAGMA integrity_check\n} {ok}\n\ndo_execsql_test 1.8 {\n  BEGIN;\n    DROP TABLE t1;\n    CREATE TABLE t1(x);\n  COMMIT;\n  CREATE INDEX i1 ON t1(x); \n  PRAGMA integrity_check\n} {ok}\n\ndo_execsql_test 2.1 {\n  BEGIN;\n    CREATE TABLE t2(x);\n    INSERT INTO t2 VALUES(14);\n    INSERT INTO t2 VALUES(35);\n    INSERT INTO t2 VALUES(15);\n    INSERT INTO t2 VALUES(35);\n    INSERT INTO t2 VALUES(16);\n  COMMIT;\n}\ndo_catchsql_test 2.2 {\n  CREATE UNIQUE INDEX i3 ON t2(x);\n} {1 {UNIQUE constraint failed: t2.x}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index5.test",
    "content": "# 2012 August 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix index5\n\ndo_test 1.1 {\n  if {[permutation]==\"memsubsys1\"} {\n    execsql { PRAGMA auto_vacuum = 0; }\n  }\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);\n    BEGIN;\n  }\n  for {set i 0} {$i < 100000} {incr i} {\n    execsql { INSERT INTO t1 VALUES(randstr(100,100)) }\n  }\n  execsql COMMIT\n  execsql { \n    CREATE INDEX i1 ON t1(x);\n    DROP INDEX I1;\n    PRAGMA main.page_size;\n  }\n} {1024}\n\ndb close\ntestvfs tvfs\ntvfs filter xWrite\ntvfs script write_cb\nproc write_cb {xCall file handle iOfst args} {\n  if {[file tail $file]==\"test.db\"} {\n    lappend ::write_list [expr $iOfst/1024 + 1]\n  }\n}\n\ndo_test 1.2 {\n  sqlite3 db test.db -vfs tvfs\n  set ::write_list [list]\n  execsql { CREATE INDEX i1 ON t1(x) }\n} {}\n\ndo_test 1.3 {\n  set nForward 0\n  set nBackward 0\n  set nNoncont 0\n  set iPrev [lindex $::write_list 0]\n  for {set i 1} {$i < [llength $::write_list]} {incr i} {\n    set iNext [lindex $::write_list $i]\n    if {$iNext==($iPrev+1)} {\n      incr nForward\n    } elseif {$iNext==($iPrev-1)} { \n      incr nBackward \n    } else {\n      incr nNoncont\n    }\n    set iPrev $iNext\n  }\n  if {0} {\n    puts -nonewline \\\n        \" (forward=$nForward, back=$nBackward, noncontiguous=$nNoncont)\"\n  }\n\n  expr {$nForward > 2*($nBackward + $nNoncont)}\n} {1}\ndb close\ntvfs delete\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index6.test",
    "content": "# 2013-07-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases for partial indices\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nload_static_extension db wholenumber;\ndo_test index6-1.1 {\n  # Able to parse and manage partial indices\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL;\n    CREATE INDEX t1b ON t1(b) WHERE b>10;\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    INSERT INTO t1(a,b,c)\n       SELECT CASE WHEN value%3!=0 THEN value END, value, value\n         FROM nums WHERE value<=20;\n    SELECT count(a), count(b) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {14 20 ok}\n\n# Make sure the count(*) optimization works correctly with\n# partial indices.  Ticket [a5c8ed66cae16243be6] 2013-10-03.\n#\ndo_execsql_test index6-1.1.1 {\n  SELECT count(*) FROM t1;\n} {20}\n\n# Error conditions during parsing...\n#\ndo_test index6-1.2 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE x IS NOT NULL;\n  }\n} {1 {no such column: x}}\ndo_test index6-1.3 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE EXISTS(SELECT * FROM t1);\n  }\n} {1 {subqueries prohibited in partial index WHERE clauses}}\ndo_test index6-1.4 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a!=?1;\n  }\n} {1 {parameters prohibited in partial index WHERE clauses}}\ndo_test index6-1.5 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a!=random();\n  }\n} {1 {non-deterministic functions prohibited in partial index WHERE clauses}}\ndo_test index6-1.6 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a NOT LIKE 'abc%';\n  }\n} {0 {}}\ndo_execsql_test index6-1.7 {\n  DROP INDEX IF EXISTS bad1;\n}\n\ndo_test index6-1.10 {\n  execsql {\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 20 t1a {14 1} t1b {10 1} ok}\n\n# STAT1 shows the partial indices have a reduced number of\n# rows.\n#\ndo_test index6-1.11 {\n  execsql {\n    UPDATE t1 SET a=b;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 20 t1a {20 1} t1b {10 1} ok}\n\ndo_test index6-1.11 {\n  execsql {\n    UPDATE t1 SET a=NULL WHERE b%3!=0;\n    UPDATE t1 SET b=b+100;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 20 t1a {6 1} t1b {20 1} ok}\n\ndo_test index6-1.12 {\n  execsql {\n    UPDATE t1 SET a=CASE WHEN b%3!=0 THEN b END;\n    UPDATE t1 SET b=b-100;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 20 t1a {13 1} t1b {10 1} ok}\n\ndo_test index6-1.13 {\n  execsql {\n    DELETE FROM t1 WHERE b BETWEEN 8 AND 12;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 15 t1a {10 1} t1b {8 1} ok}\n\ndo_test index6-1.14 {\n  execsql {\n    REINDEX;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {{} 15 t1a {10 1} t1b {8 1} ok}\n\ndo_test index6-1.15 {\n  execsql {\n    CREATE INDEX t1c ON t1(c);\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1a {10 1} t1b {8 1} t1c {15 1} ok}\n\n# Queries use partial indices as appropriate times.\n#\ndo_test index6-2.1 {\n  execsql {\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2(a,b) SELECT value, value FROM nums WHERE value<1000;\n    UPDATE t2 SET a=NULL WHERE b%2==0;\n    CREATE INDEX t2a1 ON t2(a) WHERE a IS NOT NULL;\n    SELECT count(*) FROM t2 WHERE a IS NOT NULL;\n  }\n} {500}\ndo_test index6-2.2 {\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t2 WHERE a=5;\n  }\n} {/.* TABLE t2 USING INDEX t2a1 .*/}\nifcapable stat4||stat3 {\n  execsql ANALYZE\n  do_test index6-2.3stat4 {\n    execsql {\n      EXPLAIN QUERY PLAN\n      SELECT * FROM t2 WHERE a IS NOT NULL;\n    }\n  } {/.* TABLE t2 USING INDEX t2a1 .*/}\n} else {\n  do_test index6-2.3stat4 {\n    execsql {\n      EXPLAIN QUERY PLAN\n      SELECT * FROM t2 WHERE a IS NOT NULL AND a>0;\n    }\n  } {/.* TABLE t2 USING INDEX t2a1 .*/}\n}\ndo_test index6-2.4 {\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t2 WHERE a IS NULL;\n  }\n} {~/.*INDEX t2a1.*/}\n\ndo_execsql_test index6-2.101 {\n  DROP INDEX t2a1;\n  UPDATE t2 SET a=b, b=b+10000;\n  SELECT b FROM t2 WHERE a=15;\n} {10015}\ndo_execsql_test index6-2.102 {\n  CREATE INDEX t2a2 ON t2(a) WHERE a<100 OR a>200;\n  SELECT b FROM t2 WHERE a=15;\n  PRAGMA integrity_check;\n} {10015 ok}\ndo_execsql_test index6-2.102eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=15;\n} {~/.*INDEX t2a2.*/}\ndo_execsql_test index6-2.103 {\n  SELECT b FROM t2 WHERE a=15 AND a<100;\n} {10015}\ndo_execsql_test index6-2.103eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=15 AND a<100;\n} {/.*INDEX t2a2.*/}\ndo_execsql_test index6-2.104 {\n  SELECT b FROM t2 WHERE a=515 AND a>200;\n} {10515}\ndo_execsql_test index6-2.104eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=515 AND a>200;\n} {/.*INDEX t2a2.*/}\n\n# Partial UNIQUE indices\n#\ndo_execsql_test index6-3.1 {\n  CREATE TABLE t3(a,b);\n  INSERT INTO t3 SELECT value, value FROM nums WHERE value<200;\n  UPDATE t3 SET a=999 WHERE b%5!=0;\n  CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;\n} {}\ndo_test index6-3.2 {\n  # unable to insert a duplicate row a-value that is not 999.\n  catchsql {\n    INSERT INTO t3(a,b) VALUES(150, 'test1');\n  }\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test index6-3.3 {\n  # can insert multiple rows with a==999 because such rows are not\n  # part of the unique index.\n  catchsql {\n    INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');\n  }\n} {0 {}}\ndo_execsql_test index6-3.4 {\n  SELECT count(*) FROM t3 WHERE a=999;\n} {162}\nintegrity_check index6-3.5\n\ndo_execsql_test index6-4.0 {\n  VACUUM;\n  PRAGMA integrity_check;\n} {ok}\n\n# Silently ignore database name qualifiers in partial indices.\n#\ndo_execsql_test index6-5.0 {\n  CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;\n                               /* ^^^^^-- ignored */\n  ANALYZE;\n  SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;\n  SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';\n} {6 6}\n\n# Test case for ticket [2ea3e9fe6379fc3f6ce7e090ce483c1a3a80d6c9] from\n# 2014-04-13: Partial index causes assertion fault on UPDATE OR REPLACE.\n#\ndo_execsql_test index6-6.0 {\n  CREATE TABLE t6(a,b);\n  CREATE UNIQUE INDEX t6ab ON t1(a,b);\n  CREATE INDEX t6b ON t6(b) WHERE b=1;\n  INSERT INTO t6(a,b) VALUES(123,456);\n  SELECT * FROM t6;\n} {123 456}\ndo_execsql_test index6-6.1 {\n  UPDATE OR REPLACE t6 SET b=789;\n  SELECT * FROM t6;\n} {123 789}\ndo_execsql_test index6-6.2 {\n  PRAGMA integrity_check;\n} {ok}\n\n# Test case for ticket [2326c258d02ead33d69faa63de8f4686b9b1b9d9] on\n# 2015-02-24.  Any use of a partial index qualifying constraint inside\n# the ON clause of a LEFT JOIN was causing incorrect results for all\n# versions of SQLite 3.8.0 through 3.8.8.\n#\ndo_execsql_test index6-7.0 {\n  CREATE TABLE t7a(x);\n  CREATE TABLE t7b(y);\n  INSERT INTO t7a(x) VALUES(1);\n  CREATE INDEX t7ax ON t7a(x) WHERE x=99;\n  PRAGMA automatic_index=OFF;\n  SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;\n} {1 {}}\ndo_execsql_test index6-7.1 {\n  INSERT INTO t7b(y) VALUES(2);\n  SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;\n} {}\ndo_execsql_test index6-7.2 {\n  INSERT INTO t7a(x) VALUES(99);\n  SELECT * FROM t7a LEFT JOIN t7b ON (x=99) ORDER BY x;\n} {1 {} 99 2}\ndo_execsql_test index6-7.3 {\n  SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;\n} {99 2}\ndo_execsql_test index6-7.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t7a JOIN t7b ON (x=99) ORDER BY x;\n} {/USING COVERING INDEX t7ax/}\n\n\ndo_execsql_test index6-8.0 {\n  CREATE TABLE t8a(a,b);\n  CREATE TABLE t8b(x,y);\n  CREATE INDEX i8c ON t8b(y) WHERE x = 'value';\n\n  INSERT INTO t8a VALUES(1, 'one');\n  INSERT INTO t8a VALUES(2, 'two');\n  INSERT INTO t8a VALUES(3, 'three');\n\n  INSERT INTO t8b VALUES('value', 1);\n  INSERT INTO t8b VALUES('dummy', 2);\n  INSERT INTO t8b VALUES('value', 3);\n  INSERT INTO t8b VALUES('dummy', 4);\n} {}\n\ndo_eqp_test index6-8.1 {\n  SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)\n} {\n  0 0 0 {SCAN TABLE t8a} \n  0 1 1 {SEARCH TABLE t8b USING INDEX i8c (y=?)}\n}\n\ndo_execsql_test index6-8.2 {\n  SELECT * FROM t8a LEFT JOIN t8b ON (x = 'value' AND y = a)\n} {\n  1 one value 1 \n  2 two {} {} \n  3 three value 3\n}\n\n# 2015-06-11.  Assertion fault found by AFL\n#\ndo_execsql_test index6-9.1 {\n  CREATE TABLE t9(a int, b int, c int);\n  CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);\n  INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5),(NULL,7,3);\n  UPDATE t9 SET b=c WHERE a in (10,12,20);\n  SELECT a,b,c,'|' FROM t9 ORDER BY a;\n} {{} 7 3 | 1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}\ndo_execsql_test index6-9.2 {\n  DROP TABLE t9;\n  CREATE TABLE t9(a int, b int, c int, PRIMARY KEY(a)) WITHOUT ROWID;\n  CREATE INDEX t9ca ON t9(c,a) WHERE a in (10,12,20);\n  INSERT INTO t9 VALUES(1,1,9),(10,2,35),(11,15,82),(20,19,5);\n  UPDATE t9 SET b=c WHERE a in (10,12,20);\n  SELECT a,b,c,'|' FROM t9 ORDER BY a;\n} {1 1 9 | 10 35 35 | 11 15 82 | 20 5 5 |}\n\n# AND-connected terms in the WHERE clause of a partial index\n#\ndo_execsql_test index6-10.1 {\n  CREATE TABLE t10(a,b,c,d,e INTEGER PRIMARY KEY);\n  INSERT INTO t10 VALUES\n    (1,2,3,4,5),\n    (2,3,4,5,6),\n    (3,4,5,6,7),\n    (1,2,3,8,9);\n  CREATE INDEX t10x ON t10(d) WHERE a=1 AND b=2 AND c=3;\n  SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;\n} {5 9}\ndo_execsql_test index6-10.1eqp {\n  EXPLAIN QUERY PLAN\n  SELECT e FROM t10 WHERE a=1 AND b=2 AND c=3 ORDER BY d;\n} {/USING INDEX t10x/}\ndo_execsql_test index6-10.2 {\n  SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;\n} {9 5}\ndo_execsql_test index6-10.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT e FROM t10 WHERE c=3 AND 2=b AND a=1 ORDER BY d DESC;\n} {/USING INDEX t10x/}\ndo_execsql_test index6-10.3 {\n  SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;\n} {9 5}\ndo_execsql_test index6-10.3eqp {\n  EXPLAIN QUERY PLAN\n  SELECT e FROM t10 WHERE a=1 AND b=2 ORDER BY d DESC;\n} {~/USING INDEX t10x/}\n\n# A partial index will be used for a full table scan, where possible\ndo_execsql_test index6-11.1 {\n  CREATE TABLE t11(a,b,c);\n  CREATE INDEX t11x ON t11(a) WHERE b<>99;\n  EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99;\n} {/USING INDEX t11x/}\ndo_execsql_test index6-11.2 {\n  EXPLAIN QUERY PLAN SELECT a FROM t11 WHERE b<>99 AND c<>98;\n} {/USING INDEX t11x/}\n  \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index7.test",
    "content": "# 2013-11-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases for partial indices in WITHOUT ROWID tables\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# Capture the output of a pragma in a TEMP table.\n#\nproc capture_pragma {db tabname sql} {\n  $db eval \"DROP TABLE IF EXISTS temp.$tabname\"\n  set once 1\n  $db eval $sql x {\n    if {$once} {\n      set once 0\n      set ins \"INSERT INTO $tabname VALUES\"\n      set crtab \"CREATE TEMP TABLE $tabname \"\n      set sep \"(\"\n      foreach col $x(*) {\n        append ins ${sep}\\$x($col)\n        append crtab ${sep}\\\"$col\\\"\n        set sep ,\n      }\n      append ins )\n      append crtab )\n      $db eval $crtab\n    }\n    $db eval $ins\n  }\n}\n\n\nload_static_extension db wholenumber;\ndo_test index7-1.1 {\n  # Able to parse and manage partial indices\n  execsql {\n    CREATE TABLE t1(a,b,c PRIMARY KEY) WITHOUT rowid;\n    CREATE INDEX t1a ON t1(a) WHERE a IS NOT NULL;\n    CREATE INDEX t1b ON t1(b) WHERE b>10;\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    INSERT INTO t1(a,b,c)\n       SELECT CASE WHEN value%3!=0 THEN value END, value, value\n         FROM nums WHERE value<=20;\n    SELECT count(a), count(b) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {14 20 ok}\n\n# (The \"partial\" column of the PRAGMA index_list output is...)\n# EVIDENCE-OF: R-34457-09668 \"1\" if the index is a partial index and \"0\"\n# if not.\n#\ndo_test index7-1.1a {\n  capture_pragma db out {PRAGMA index_list(t1)}\n  db eval {SELECT \"name\", \"partial\", '|' FROM out ORDER BY \"name\"}\n} {sqlite_autoindex_t1_1 0 | t1a 1 | t1b 1 |}\n\n# Make sure the count(*) optimization works correctly with\n# partial indices.  Ticket [a5c8ed66cae16243be6] 2013-10-03.\n#\ndo_execsql_test index7-1.1.1 {\n  SELECT count(*) FROM t1;\n} {20}\n\n# Error conditions during parsing...\n#\ndo_test index7-1.2 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE x IS NOT NULL;\n  }\n} {1 {no such column: x}}\ndo_test index7-1.3 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE EXISTS(SELECT * FROM t1);\n  }\n} {1 {subqueries prohibited in partial index WHERE clauses}}\ndo_test index7-1.4 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a!=?1;\n  }\n} {1 {parameters prohibited in partial index WHERE clauses}}\ndo_test index7-1.5 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a!=random();\n  }\n} {1 {non-deterministic functions prohibited in partial index WHERE clauses}}\ndo_test index7-1.6 {\n  catchsql {\n    CREATE INDEX bad1 ON t1(a,b) WHERE a NOT LIKE 'abc%';\n  }\n} {0 {}}\ndo_execsql_test index7-1.7 {\n  INSERT INTO t1(a,b,c)\n     VALUES('abcde',1,101),('abdef',2,102),('xyz',3,103),('abcz',4,104);\n  SELECT c FROM t1 WHERE a NOT LIKE 'abc%' AND a=7 ORDER BY +b;\n} {7}\ndo_execsql_test index7-1.7eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t1 WHERE a NOT LIKE 'abc%' AND a=7 ORDER BY +b;\n} {/SEARCH TABLE t1 USING COVERING INDEX bad1 /}\ndo_execsql_test index7-1.8 {\n  DELETE FROM t1 WHERE c>=101;\n  DROP INDEX IF EXISTS bad1;\n} {}\n\ndo_test index7-1.10 {\n  execsql {\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {20 1} t1a {14 1} t1b {10 1} ok}\n\n# STAT1 shows the partial indices have a reduced number of\n# rows.\n#\ndo_test index7-1.11 {\n  execsql {\n    UPDATE t1 SET a=b;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {20 1} t1a {20 1} t1b {10 1} ok}\n\ndo_test index7-1.11b {\n  execsql {\n    UPDATE t1 SET a=NULL WHERE b%3!=0;\n    UPDATE t1 SET b=b+100;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {20 1} t1a {6 1} t1b {20 1} ok}\n\ndo_test index7-1.12 {\n  execsql {\n    UPDATE t1 SET a=CASE WHEN b%3!=0 THEN b END;\n    UPDATE t1 SET b=b-100;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {20 1} t1a {13 1} t1b {10 1} ok}\n\ndo_test index7-1.13 {\n  execsql {\n    DELETE FROM t1 WHERE b BETWEEN 8 AND 12;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {15 1} t1a {10 1} t1b {8 1} ok}\n\ndo_test index7-1.14 {\n  execsql {\n    REINDEX;\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {15 1} t1a {10 1} t1b {8 1} ok}\n\ndo_test index7-1.15 {\n  execsql {\n    CREATE INDEX t1c ON t1(c);\n    ANALYZE;\n    SELECT idx, stat FROM sqlite_stat1 ORDER BY idx;\n    PRAGMA integrity_check;\n  }\n} {t1 {15 1} t1a {10 1} t1b {8 1} t1c {15 1} ok}\n\n# Queries use partial indices as appropriate times.\n#\ndo_test index7-2.1 {\n  execsql {\n    CREATE TABLE t2(a,b PRIMARY KEY) without rowid;\n    INSERT INTO t2(a,b) SELECT value, value FROM nums WHERE value<1000;\n    UPDATE t2 SET a=NULL WHERE b%5==0;\n    CREATE INDEX t2a1 ON t2(a) WHERE a IS NOT NULL;\n    SELECT count(*) FROM t2 WHERE a IS NOT NULL;\n  }\n} {800}\ndo_test index7-2.2 {\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t2 WHERE a=5;\n  }\n} {/.* TABLE t2 USING COVERING INDEX t2a1 .*/}\nifcapable stat4||stat3 {\n  do_test index7-2.3stat4 {\n    execsql {\n      EXPLAIN QUERY PLAN\n      SELECT * FROM t2 WHERE a IS NOT NULL;\n    }\n  } {/.* TABLE t2 USING COVERING INDEX t2a1 .*/}\n} else {\n  do_test index7-2.3stat4 {\n    execsql {\n      EXPLAIN QUERY PLAN\n      SELECT * FROM t2 WHERE a IS NOT NULL AND a>0;\n    }\n  } {/.* TABLE t2 USING COVERING INDEX t2a1 .*/}\n}\ndo_test index7-2.4 {\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t2 WHERE a IS NULL;\n  }\n} {~/.*INDEX t2a1.*/}\n\ndo_execsql_test index7-2.101 {\n  DROP INDEX t2a1;\n  UPDATE t2 SET a=b, b=b+10000;\n  SELECT b FROM t2 WHERE a=15;\n} {10015}\ndo_execsql_test index7-2.102 {\n  CREATE INDEX t2a2 ON t2(a) WHERE a<100 OR a>200;\n  SELECT b FROM t2 WHERE a=15;\n  PRAGMA integrity_check;\n} {10015 ok}\ndo_execsql_test index7-2.102eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=15;\n} {~/.*INDEX t2a2.*/}\ndo_execsql_test index7-2.103 {\n  SELECT b FROM t2 WHERE a=15 AND a<100;\n} {10015}\ndo_execsql_test index7-2.103eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=15 AND a<100;\n} {/.*INDEX t2a2.*/}\ndo_execsql_test index7-2.104 {\n  SELECT b FROM t2 WHERE a=515 AND a>200;\n} {10515}\ndo_execsql_test index7-2.104eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b FROM t2 WHERE a=515 AND a>200;\n} {/.*INDEX t2a2.*/}\n\n# Partial UNIQUE indices\n#\ndo_execsql_test index7-3.1 {\n  CREATE TABLE t3(a,b PRIMARY KEY) without rowid;\n  INSERT INTO t3 SELECT value, value FROM nums WHERE value<200;\n  UPDATE t3 SET a=999 WHERE b%5!=0;\n  CREATE UNIQUE INDEX t3a ON t3(a) WHERE a<>999;\n} {}\ndo_test index7-3.2 {\n  # unable to insert a duplicate row a-value that is not 999.\n  catchsql {\n    INSERT INTO t3(a,b) VALUES(150, 'test1');\n  }\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test index7-3.3 {\n  # can insert multiple rows with a==999 because such rows are not\n  # part of the unique index.\n  catchsql {\n    INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');\n  }\n} {0 {}}\ndo_execsql_test index7-3.4 {\n  SELECT count(*) FROM t3 WHERE a=999;\n} {162}\nintegrity_check index7-3.5\n\ndo_execsql_test index7-4.0 {\n  VACUUM;\n  PRAGMA integrity_check;\n} {ok}\n\n# Silently ignore database name qualifiers in partial indices.\n#\ndo_execsql_test index7-5.0 {\n  CREATE INDEX t3b ON t3(b) WHERE xyzzy.t3.b BETWEEN 5 AND 10;\n                               /* ^^^^^-- ignored */\n  ANALYZE;\n  SELECT count(*) FROM t3 WHERE t3.b BETWEEN 5 AND 10;\n  SELECT stat+0 FROM sqlite_stat1 WHERE idx='t3b';\n} {6 6}\n\n# Verify that the problem identified by ticket [98d973b8f5] has been fixed.\n#\ndo_execsql_test index7-6.1 {\n  CREATE TABLE t5(a, b);\n  CREATE TABLE t4(c, d);\n  INSERT INTO t5 VALUES(1, 'xyz');\n  INSERT INTO t4 VALUES('abc', 'not xyz');\n  SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';\n} {\n  1 xyz abc {not xyz}\n}\ndo_execsql_test index7-6.2 {\n  CREATE INDEX i4 ON t4(c) WHERE d='xyz';\n  SELECT * FROM (SELECT * FROM t5 WHERE a=1 AND b='xyz'), t4 WHERE c='abc';\n} {\n  1 xyz abc {not xyz}\n}\ndo_execsql_test index7-6.3 {\n  CREATE VIEW v4 AS SELECT * FROM t4;\n  INSERT INTO t4 VALUES('def', 'xyz');\n  SELECT * FROM v4 WHERE d='xyz' AND c='def'\n} {\n  def xyz\n}\ndo_eqp_test index7-6.4 {\n  SELECT * FROM v4 WHERE d='xyz' AND c='def'\n} {\n  0 0 0 {SEARCH TABLE t4 USING INDEX i4 (c=?)}\n}\ndo_catchsql_test index7-6.5 {\n  CREATE INDEX t5a ON t5(a) WHERE a=#1;\n} {1 {near \"#1\": syntax error}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index8.test",
    "content": "# 2016-07-27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases for ORDER BY and LIMIT on an index scan.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Performance regression reported at\n# http://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg98615.html\n#\n# Caused by the ORDER BY LIMIT optionation for check-in\n# https://sqlite.org/src/info/bf46179d44843769\n#\n# Fixed on approximately 2016-07-27 by changes that compute a better score\n# for index scans by taking into account WHERE clause constraints that can\n# be handled by the index and do not require a table lookup.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a,b,c,d);\n  WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<100)\n  INSERT INTO t1(a,b,c,d)\n     SELECT x/10, x%10, x%19, x FROM c;\n  CREATE INDEX t1abc ON t1(a,b,c);\n  SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;\n} {0 4 4 4 2 3 4 23}\n\n# Prior to the fix, the following EQP would show a table scan and a sort\n# rather than an index scan.\n#\ndo_execsql_test 1.0eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;\n} {/SCAN TABLE t1 USING INDEX t1abc/}\n\n# If we change the index so that it no longer covers the WHERE clause,\n# then we should (correctly) revert to using a table scan.\n#\ndo_execsql_test 1.1 {\n  DROP INDEX t1abc;\n  CREATE INDEX t1abd ON t1(a,b,d);\n  SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;\n} {0 4 4 4 2 3 4 23}\ndo_execsql_test 1.1eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE c=4 ORDER BY a, b LIMIT 2;\n} {~/USING INDEX/}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/index9.test",
    "content": "# 2017 Jun 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that partial indexes work with bound variables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix index9\n\nproc sqluses {sql} {\n  array unset ::T\n  uplevel [list db eval \"EXPLAIN $sql\" a {\n    if {$a(opcode)==\"OpenRead\"} { set ::T($a(p2)) 1 }\n  }]\n\n  set in [join [array names ::T] ,]\n  db eval \"SELECT name FROM sqlite_master WHERE rootpage IN ($in) ORDER BY 1\"\n}\n\nproc do_sqluses_test {tn sql objects} {\n  uplevel [list do_test $tn [list sqluses $sql] $objects]\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y);\n  CREATE INDEX t1x ON t1(x) WHERE y=45;\n}\nset y [expr 45]\ndo_sqluses_test 1.1 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1 t1x}\nset y [expr 45.1]\ndo_sqluses_test 1.2 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}\nset y [expr 44]\ndo_sqluses_test 1.3 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}\nunset -nocomplain y\ndo_sqluses_test 1.4 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}\nset y [string range \"45\" 0 end]\ndo_sqluses_test 1.5 { SELECT * FROM t1 WHERE x=? AND y=$y } {t1}\n\ndo_execsql_test 2.0 {\n  CREATE INDEX t1x2 ON t1(x) WHERE y=-20111000111\n}\ndo_sqluses_test 2.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr -20111000111]\ndo_sqluses_test 2.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x2}\nset y [expr -20111000110]\ndo_sqluses_test 2.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr -20111000112]\ndo_sqluses_test 2.4 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\n\ndo_execsql_test 3.0 {\n  CREATE INDEX t1x3 ON t1(x) WHERE y=9223372036854775807\n}\nset y [expr 9223372036854775807]\ndo_sqluses_test 3.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x3}\nset y [expr 9223372036854775808]\ndo_sqluses_test 3.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr 9223372036854775806]\ndo_sqluses_test 3.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\ndb cache flush\nsqlite3_db_config db QPSG 1\nset y [expr 9223372036854775807]\ndo_sqluses_test 3.4 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr 9223372036854775808]\ndo_sqluses_test 3.5 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nsqlite3_db_config db QPSG 0\ndb cache flush\n\n\ndo_execsql_test 4.0 {\n  CREATE INDEX t1x4 ON t1(x) WHERE y=-9223372036854775808\n}\nset y [expr -9223372036854775808]\ndo_sqluses_test 4.1 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1 t1x4}\nset y [expr -9223372036854775807]\ndo_sqluses_test 4.2 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr -9223372036854775809]\ndo_sqluses_test 4.3 { SELECT * FROM t1 WHERE y=$y ORDER BY x } {t1}\nset y [expr -9223372036854775808]\ndo_sqluses_test 4.4 { SELECT * FROM t1 WHERE $y=y ORDER BY x } {t1 t1x4}\ndb cache flush\nsqlite3_db_config db QPSG 1\ndo_sqluses_test 4.5 { SELECT * FROM t1 WHERE $y=y ORDER BY x } {t1}\nsqlite3_db_config db QPSG 0\ndb cache flush\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/indexedby.test",
    "content": "# 2008-10-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix indexedby\n\n# Create a schema with some indexes.\n#\ndo_test indexedby-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n\n    CREATE TABLE t2(c, d);\n    CREATE INDEX i3 ON t2(c);\n    CREATE INDEX i4 ON t2(d);\n\n    CREATE TABLE t3(e PRIMARY KEY, f);\n\n    CREATE VIEW v1 AS SELECT * FROM t1;\n  }\n} {}\n\n# Explain Query Plan\n#\nproc EQP {sql} {\n  uplevel \"execsql {EXPLAIN QUERY PLAN $sql}\"\n}\n\n# These tests are to check that \"EXPLAIN QUERY PLAN\" is working as expected.\n#\ndo_execsql_test indexedby-1.2 {\n  EXPLAIN QUERY PLAN select * from t1 WHERE a = 10; \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-1.3 {\n  EXPLAIN QUERY PLAN select * from t1 ; \n} {0 0 0 {SCAN TABLE t1}}\ndo_execsql_test indexedby-1.4 {\n  EXPLAIN QUERY PLAN select * from t1, t2 WHERE c = 10; \n} {\n  0 0 1 {SEARCH TABLE t2 USING INDEX i3 (c=?)} \n  0 1 0 {SCAN TABLE t1}\n}\n\n# Parser tests. Test that an INDEXED BY or NOT INDEX clause can be \n# attached to a table in the FROM clause, but not to a sub-select or\n# SQL view. Also test that specifying an index that does not exist or\n# is attached to a different table is detected as an error.\n#\n# EVIDENCE-OF: R-07004-11522 -- syntax diagram qualified-table-name\n# \n# EVIDENCE-OF: R-58230-57098 The \"INDEXED BY index-name\" phrase\n# specifies that the named index must be used in order to look up values\n# on the preceding table.\n#\ndo_test indexedby-2.1 {\n  execsql { SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'}\n} {}\ndo_test indexedby-2.1b {\n  execsql { SELECT * FROM main.t1 NOT INDEXED WHERE a = 'one' AND b = 'two'}\n} {}\ndo_test indexedby-2.2 {\n  execsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'}\n} {}\ndo_test indexedby-2.2b {\n  execsql { SELECT * FROM main.t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'}\n} {}\ndo_test indexedby-2.3 {\n  execsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'}\n} {}\n# EVIDENCE-OF: R-44699-55558 The INDEXED BY clause does not give the\n# optimizer hints about which index to use; it gives the optimizer a\n# requirement of which index to use.\n# EVIDENCE-OF: R-15800-25719 If index-name does not exist or cannot be\n# used for the query, then the preparation of the SQL statement fails.\n#\ndo_test indexedby-2.4 {\n  catchsql { SELECT * FROM t1 INDEXED BY i3 WHERE a = 'one' AND b = 'two'}\n} {1 {no such index: i3}}\n\n# EVIDENCE-OF: R-62112-42456 If the query optimizer is unable to use the\n# index specified by the INDEX BY clause, then the query will fail with\n# an error.\ndo_test indexedby-2.4.1 {\n  catchsql { SELECT b FROM t1 INDEXED BY i1 WHERE b = 'two' }\n} {1 {no query solution}}\n\ndo_test indexedby-2.5 {\n  catchsql { SELECT * FROM t1 INDEXED BY i5 WHERE a = 'one' AND b = 'two'}\n} {1 {no such index: i5}}\ndo_test indexedby-2.6 {\n  catchsql { SELECT * FROM t1 INDEXED BY WHERE a = 'one' AND b = 'two'}\n} {1 {near \"WHERE\": syntax error}}\ndo_test indexedby-2.7 {\n  catchsql { SELECT * FROM v1 INDEXED BY i1 WHERE a = 'one' }\n} {1 {no such index: i1}}\n\n\n# Tests for single table cases.\n#\n# EVIDENCE-OF: R-37002-28871 The \"NOT INDEXED\" clause specifies that no\n# index shall be used when accessing the preceding table, including\n# implied indices create by UNIQUE and PRIMARY KEY constraints. However,\n# the rowid can still be used to look up entries even when \"NOT INDEXED\"\n# is specified.\n#\ndo_execsql_test indexedby-3.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE a = 'one' AND b = 'two'\n} {/SEARCH TABLE t1 USING INDEX/}\ndo_execsql_test indexedby-3.1.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE a = 'one' AND b = 'two'\n} {0 0 0 {SCAN TABLE t1}}\ndo_execsql_test indexedby-3.1.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE rowid=1\n} {/SEARCH TABLE t1 USING INTEGER PRIMARY KEY .rowid=/}\n\n\ndo_execsql_test indexedby-3.2 {\n  EXPLAIN QUERY PLAN \n  SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' AND b = 'two'\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-3.3 {\n  EXPLAIN QUERY PLAN \n  SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' AND b = 'two'\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}\ndo_test indexedby-3.4 {\n  catchsql { SELECT * FROM t1 INDEXED BY i2 WHERE a = 'one' }\n} {1 {no query solution}}\ndo_test indexedby-3.5 {\n  catchsql { SELECT * FROM t1 INDEXED BY i2 ORDER BY a }\n} {1 {no query solution}}\ndo_test indexedby-3.6 {\n  catchsql { SELECT * FROM t1 INDEXED BY i1 WHERE a = 'one' }\n} {0 {}}\ndo_test indexedby-3.7 {\n  catchsql { SELECT * FROM t1 INDEXED BY i1 ORDER BY a }\n} {0 {}}\n\ndo_execsql_test indexedby-3.8 {\n  EXPLAIN QUERY PLAN \n  SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 ORDER BY e \n} {0 0 0 {SCAN TABLE t3 USING INDEX sqlite_autoindex_t3_1}}\ndo_execsql_test indexedby-3.9 {\n  EXPLAIN QUERY PLAN \n  SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE e = 10 \n} {0 0 0 {SEARCH TABLE t3 USING INDEX sqlite_autoindex_t3_1 (e=?)}}\ndo_test indexedby-3.10 {\n  catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_1 WHERE f = 10 }\n} {1 {no query solution}}\ndo_test indexedby-3.11 {\n  catchsql { SELECT * FROM t3 INDEXED BY sqlite_autoindex_t3_2 WHERE f = 10 }\n} {1 {no such index: sqlite_autoindex_t3_2}}\n\n# Tests for multiple table cases.\n#\ndo_execsql_test indexedby-4.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE a = c \n} {\n  0 0 0 {SCAN TABLE t1} \n  0 1 1 {SEARCH TABLE t2 USING INDEX i3 (c=?)}\n}\ndo_execsql_test indexedby-4.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 INDEXED BY i1, t2 WHERE a = c \n} {\n  0 0 1 {SCAN TABLE t2} \n  0 1 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}\n}\ndo_test indexedby-4.3 {\n  catchsql {\n    SELECT * FROM t1 INDEXED BY i1, t2 INDEXED BY i3 WHERE a=c\n  }\n} {1 {no query solution}}\ndo_test indexedby-4.4 {\n  catchsql {\n    SELECT * FROM t2 INDEXED BY i3, t1 INDEXED BY i1 WHERE a=c\n  }\n} {1 {no query solution}}\n\n# Test embedding an INDEXED BY in a CREATE VIEW statement. This block\n# also tests that nothing bad happens if an index refered to by\n# a CREATE VIEW statement is dropped and recreated.\n#\ndo_execsql_test indexedby-5.1 {\n  CREATE VIEW v2 AS SELECT * FROM t1 INDEXED BY i1 WHERE a > 5;\n  EXPLAIN QUERY PLAN SELECT * FROM v2 \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}\ndo_execsql_test indexedby-5.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM v2 WHERE b = 10 \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}\ndo_test indexedby-5.3 {\n  execsql { DROP INDEX i1 }\n  catchsql { SELECT * FROM v2 }\n} {1 {no such index: i1}}\ndo_test indexedby-5.4 {\n  # Recreate index i1 in such a way as it cannot be used by the view query.\n  execsql { CREATE INDEX i1 ON t1(b) }\n  catchsql { SELECT * FROM v2 }\n} {1 {no query solution}}\ndo_test indexedby-5.5 {\n  # Drop and recreate index i1 again. This time, create it so that it can\n  # be used by the query.\n  execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(a) }\n  catchsql { SELECT * FROM v2 }\n} {0 {}}\n\n# Test that \"NOT INDEXED\" may use the rowid index, but not others.\n# \ndo_execsql_test indexedby-6.1 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 10 ORDER BY rowid \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}\ndo_execsql_test indexedby-6.2 {\n  EXPLAIN QUERY PLAN SELECT * FROM t1 NOT INDEXED WHERE b = 10 ORDER BY rowid \n} {0 0 0 {SCAN TABLE t1}}\n\n# EVIDENCE-OF: R-40297-14464 The INDEXED BY phrase forces the SQLite\n# query planner to use a particular named index on a DELETE, SELECT, or\n# UPDATE statement.\n#\n# Test that \"INDEXED BY\" can be used in a DELETE statement.\n# \ndo_execsql_test indexedby-7.1 {\n  EXPLAIN QUERY PLAN DELETE FROM t1 WHERE a = 5 \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-7.2 {\n  EXPLAIN QUERY PLAN DELETE FROM t1 NOT INDEXED WHERE a = 5 \n} {0 0 0 {SCAN TABLE t1}}\ndo_execsql_test indexedby-7.3 {\n  EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5 \n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-7.4 {\n  EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i1 WHERE a = 5 AND b = 10\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-7.5 {\n  EXPLAIN QUERY PLAN DELETE FROM t1 INDEXED BY i2 WHERE a = 5 AND b = 10\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}\ndo_test indexedby-7.6 {\n  catchsql { DELETE FROM t1 INDEXED BY i2 WHERE a = 5}\n} {1 {no query solution}}\n\n# Test that \"INDEXED BY\" can be used in an UPDATE statement.\n# \ndo_execsql_test indexedby-8.1 {\n  EXPLAIN QUERY PLAN UPDATE t1 SET rowid=rowid+1 WHERE a = 5 \n} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-8.2 {\n  EXPLAIN QUERY PLAN UPDATE t1 NOT INDEXED SET rowid=rowid+1 WHERE a = 5 \n} {0 0 0 {SCAN TABLE t1}}\ndo_execsql_test indexedby-8.3 {\n  EXPLAIN QUERY PLAN UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5 \n} {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-8.4 {\n  EXPLAIN QUERY PLAN \n  UPDATE t1 INDEXED BY i1 SET rowid=rowid+1 WHERE a = 5 AND b = 10\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_execsql_test indexedby-8.5 {\n  EXPLAIN QUERY PLAN \n  UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5 AND b = 10\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (b=?)}}\ndo_test indexedby-8.6 {\n  catchsql { UPDATE t1 INDEXED BY i2 SET rowid=rowid+1 WHERE a = 5}\n} {1 {no query solution}}\n\n# Test that bug #3560 is fixed.\n#\ndo_test indexedby-9.1 {\n  execsql {\n    CREATE TABLE maintable( id integer);\n    CREATE TABLE joinme(id_int integer, id_text text);\n    CREATE INDEX joinme_id_text_idx on joinme(id_text);\n    CREATE INDEX joinme_id_int_idx on joinme(id_int);\n  }\n} {}\ndo_test indexedby-9.2 {\n  catchsql {\n    select * from maintable as m inner join\n    joinme as j indexed by joinme_id_text_idx\n    on ( m.id  = j.id_int)\n  }\n} {1 {no query solution}}\ndo_test indexedby-9.3 {\n  catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx }\n} {1 {no query solution}}\n\n# Make sure we can still create tables, indices, and columns whose name\n# is \"indexed\".\n#\ndo_test indexedby-10.1 {\n  execsql {\n    CREATE TABLE indexed(x,y);\n    INSERT INTO indexed VALUES(1,2);\n    SELECT * FROM indexed;\n  }\n} {1 2}\ndo_test indexedby-10.2 {\n  execsql {\n    CREATE INDEX i10 ON indexed(x);\n    SELECT * FROM indexed indexed by i10 where x>0;\n  }\n} {1 2}\ndo_test indexedby-10.3 {\n  execsql {\n    DROP TABLE indexed;\n    CREATE TABLE t10(indexed INTEGER);\n    INSERT INTO t10 VALUES(1);\n    CREATE INDEX indexed ON t10(indexed);\n    SELECT * FROM t10 indexed by indexed WHERE indexed>0\n  }\n} {1}\n\n#-------------------------------------------------------------------------\n# Ensure that the rowid at the end of each index entry may be used\n# for equality constraints in the same way as other indexed fields.\n#\ndo_execsql_test 11.1 {\n  CREATE TABLE x1(a, b TEXT);\n  CREATE INDEX x1i ON x1(a, b);\n  INSERT INTO x1 VALUES(1, 1);\n  INSERT INTO x1 VALUES(1, 1);\n  INSERT INTO x1 VALUES(1, 1);\n  INSERT INTO x1 VALUES(1, 1);\n}\ndo_execsql_test 11.2 {\n  SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid=3;\n} {1 1 3}\ndo_execsql_test 11.3 {\n  SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3';\n} {1 1 3}\ndo_execsql_test 11.4 {\n  SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3.0';\n} {1 1 3}\ndo_eqp_test 11.5 {\n  SELECT a,b,rowid FROM x1 INDEXED BY x1i WHERE a=1 AND b=1 AND rowid='3.0';\n} {0 0 0 {SEARCH TABLE x1 USING COVERING INDEX x1i (a=? AND b=? AND rowid=?)}}\n\ndo_execsql_test 11.6 {\n  CREATE TABLE x2(c INTEGER PRIMARY KEY, a, b TEXT);\n  CREATE INDEX x2i ON x2(a, b);\n  INSERT INTO x2 VALUES(1, 1, 1);\n  INSERT INTO x2 VALUES(2, 1, 1);\n  INSERT INTO x2 VALUES(3, 1, 1);\n  INSERT INTO x2 VALUES(4, 1, 1);\n}\ndo_execsql_test 11.7 {\n  SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c=3;\n} {1 1 3}\ndo_execsql_test 11.8 {\n  SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3';\n} {1 1 3}\ndo_execsql_test 11.9 {\n  SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3.0';\n} {1 1 3}\ndo_eqp_test 11.10 {\n  SELECT a,b,c FROM x2 INDEXED BY x2i WHERE a=1 AND b=1 AND c='3.0';\n} {0 0 0 {SEARCH TABLE x2 USING COVERING INDEX x2i (a=? AND b=? AND rowid=?)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/indexexpr1.test",
    "content": "# 2015-08-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing indexes on expressions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test indexexpr1-100 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1(a,b,c)\n      /*  123456789 123456789 123456789 123456789 123456789 123456789 */ \n  VALUES('In_the_beginning_was_the_Word',1,1),\n        ('and_the_Word_was_with_God',1,2),\n        ('and_the_Word_was_God',1,3),\n        ('The_same_was_in_the_beginning_with_God',2,1),\n        ('All_things_were_made_by_him',3,1),\n        ('and_without_him_was_not_any_thing_made_that_was_made',3,2);\n  CREATE INDEX t1a1 ON t1(substr(a,1,12));\n} {}\ndo_execsql_test indexexpr1-110 {\n  SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;\n} {1 2 | 1 3 |}\ndo_execsql_test indexexpr1-110eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;\n} {/USING INDEX t1a1/}\ndo_execsql_test indexexpr1-120 {\n  SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;\n} {1 2 | 1 3 |}\ndo_execsql_test indexexpr1-120eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;\n} {/USING INDEX t1a1/}\n\ndo_execsql_test indexexpr1-130 {\n  CREATE INDEX t1ba ON t1(b,substr(a,2,3),c);\n  SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;\n} {2 3}\ndo_execsql_test indexexpr1-130eqp {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;\n} {/USING INDEX t1ba/}\n\ndo_execsql_test indexexpr1-140 {\n  SELECT rowid, substr(a,b,3), '|' FROM t1 ORDER BY 2;\n} {1 In_ | 2 and | 3 and | 6 d_w | 4 he_ | 5 l_t |}\ndo_execsql_test indexexpr1-141 {\n  CREATE INDEX t1abx ON t1(substr(a,b,3));\n  SELECT rowid FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +rowid;\n} {1 2 3}\ndo_execsql_test indexexpr1-141eqp {\n  EXPLAIN QUERY PLAN\n  SELECT rowid FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +rowid;\n} {/USING INDEX t1abx/}\ndo_execsql_test indexexpr1-142 {\n  SELECT rowid FROM t1 WHERE +substr(a,b,3)<='and' ORDER BY +rowid;\n} {1 2 3}\ndo_execsql_test indexexpr1-150 {\n  SELECT rowid FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')\n   ORDER BY +rowid;\n} {2 3 5}\ndo_execsql_test indexexpr1-150eqp {\n  EXPLAIN QUERY PLAN\n  SELECT rowid FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')\n   ORDER BY +rowid;\n} {/USING INDEX t1abx/}\n\ndo_execsql_test indexexpr1-160 {\n  ALTER TABLE t1 ADD COLUMN d;\n  UPDATE t1 SET d=length(a);\n  CREATE INDEX t1a2 ON t1(SUBSTR(a, 27, 3)) WHERE d>=29;\n  SELECT rowid, b, c FROM t1\n   WHERE substr(a,27,3)=='ord' AND d>=29;\n} {1 1 1}\ndo_execsql_test indexexpr1-160eqp {\n  EXPLAIN QUERY PLAN\n  SELECT rowid, b, c FROM t1\n   WHERE substr(a,27,3)=='ord' AND d>=29;\n} {/USING INDEX t1a2/}\n\n# ORDER BY using an indexed expression\n#\ndo_execsql_test indexexpr1-170 {\n  CREATE INDEX t1alen ON t1(length(a));\n  SELECT length(a) FROM t1 ORDER BY length(a);\n} {20 25 27 29 38 52}\ndo_execsql_test indexexpr1-170eqp {\n  EXPLAIN QUERY PLAN\n  SELECT length(a) FROM t1 ORDER BY length(a);\n} {/SCAN TABLE t1 USING INDEX t1alen/}\ndo_execsql_test indexexpr1-171 {\n  SELECT length(a) FROM t1 ORDER BY length(a) DESC;\n} {52 38 29 27 25 20}\ndo_execsql_test indexexpr1-171eqp {\n  EXPLAIN QUERY PLAN\n  SELECT length(a) FROM t1 ORDER BY length(a) DESC;\n} {/SCAN TABLE t1 USING INDEX t1alen/}\n\ndo_execsql_test indexexpr1-200 {\n  DROP TABLE t1;\n  CREATE TABLE t1(id ANY PRIMARY KEY, a,b,c) WITHOUT ROWID;\n  INSERT INTO t1(id,a,b,c)\n  VALUES(1,'In_the_beginning_was_the_Word',1,1),\n        (2,'and_the_Word_was_with_God',1,2),\n        (3,'and_the_Word_was_God',1,3),\n        (4,'The_same_was_in_the_beginning_with_God',2,1),\n        (5,'All_things_were_made_by_him',3,1),\n        (6,'and_without_him_was_not_any_thing_made_that_was_made',3,2);\n  CREATE INDEX t1a1 ON t1(substr(a,1,12));\n} {}\ndo_execsql_test indexexpr1-210 {\n  SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;\n} {1 2 | 1 3 |}\ndo_execsql_test indexexpr1-210eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b, c, '|' FROM t1 WHERE substr(a,1,12)=='and_the_Word' ORDER BY b, c;\n} {/USING INDEX t1a1/}\ndo_execsql_test indexexpr1-220 {\n  SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;\n} {1 2 | 1 3 |}\ndo_execsql_test indexexpr1-220eqp {\n  EXPLAIN QUERY PLAN\n  SELECT b, c, '|' FROM t1 WHERE 'and_the_Word'==substr(a,1,12) ORDER BY b, c;\n} {/USING INDEX t1a1/}\n\ndo_execsql_test indexexpr1-230 {\n  CREATE INDEX t1ba ON t1(b,substr(a,2,3),c);\n  SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;\n} {2 3}\ndo_execsql_test indexexpr1-230eqp {\n  EXPLAIN QUERY PLAN\n  SELECT c FROM t1 WHERE b=1 AND substr(a,2,3)='nd_' ORDER BY c;\n} {/USING INDEX t1ba/}\n\ndo_execsql_test indexexpr1-240 {\n  SELECT id, substr(a,b,3), '|' FROM t1 ORDER BY 2;\n} {1 In_ | 2 and | 3 and | 6 d_w | 4 he_ | 5 l_t |}\ndo_execsql_test indexexpr1-241 {\n  CREATE INDEX t1abx ON t1(substr(a,b,3));\n  SELECT id FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +id;\n} {1 2 3}\ndo_execsql_test indexexpr1-241eqp {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t1 WHERE substr(a,b,3)<='and' ORDER BY +id;\n} {/USING INDEX t1abx/}\ndo_execsql_test indexexpr1-242 {\n  SELECT id FROM t1 WHERE +substr(a,b,3)<='and' ORDER BY +id;\n} {1 2 3}\ndo_execsql_test indexexpr1-250 {\n  SELECT id FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')\n   ORDER BY +id;\n} {2 3 5}\ndo_execsql_test indexexpr1-250eqp {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t1 WHERE substr(a,b,3) IN ('and','l_t','xyz')\n   ORDER BY +id;\n} {/USING INDEX t1abx/}\n\ndo_execsql_test indexexpr1-260 {\n  ALTER TABLE t1 ADD COLUMN d;\n  UPDATE t1 SET d=length(a);\n  CREATE INDEX t1a2 ON t1(SUBSTR(a, 27, 3)) WHERE d>=29;\n  SELECT id, b, c FROM t1\n   WHERE substr(a,27,3)=='ord' AND d>=29;\n} {1 1 1}\ndo_execsql_test indexexpr1-260eqp {\n  EXPLAIN QUERY PLAN\n  SELECT id, b, c FROM t1\n   WHERE substr(a,27,3)=='ord' AND d>=29;\n} {/USING INDEX t1a2/}\n\n\ndo_catchsql_test indexexpr1-300 {\n  CREATE TABLE t2(a,b,c); INSERT INTO t2 VALUES(1,2,3);\n  CREATE INDEX t2x1 ON t2(a,b+random());\n} {1 {non-deterministic functions prohibited in index expressions}}\ndo_catchsql_test indexexpr1-301 {\n  CREATE INDEX t2x1 ON t2(julianday('now',a));\n} {1 {non-deterministic function in index expression or CHECK constraint}}\ndo_catchsql_test indexexpr1-310 {\n  CREATE INDEX t2x2 ON t2(a,b+(SELECT 15));\n} {1 {subqueries prohibited in index expressions}}\ndo_catchsql_test indexexpr1-320 {\n  CREATE TABLE e1(x,y,UNIQUE(y,substr(x,1,5)));\n} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}\ndo_catchsql_test indexexpr1-330 {\n  CREATE TABLE e1(x,y,PRIMARY KEY(y,substr(x,1,5)));\n} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}\ndo_catchsql_test indexexpr1-331 {\n  CREATE TABLE e1(x,y,PRIMARY KEY(y,substr(x,1,5))) WITHOUT ROWID;\n} {1 {expressions prohibited in PRIMARY KEY and UNIQUE constraints}}\ndo_catchsql_test indexexpr1-340 {\n  CREATE TABLE e1(x,y,FOREIGN KEY(substr(y,1,5)) REFERENCES t1);\n} {1 {near \"(\": syntax error}}\n\ndo_execsql_test indexexpr1-400 {\n  CREATE TABLE t3(a,b,c);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<30)\n  INSERT INTO t3(a,b,c)\n    SELECT x, printf('ab%04xyz',x), random() FROM c;\n  CREATE UNIQUE INDEX t3abc ON t3(CAST(a AS text), b, substr(c,1,3));\n  SELECT a FROM t3 WHERE CAST(a AS text)<='10' ORDER BY +a;\n  PRAGMA integrity_check;\n} {1 10 ok}\ndo_catchsql_test indexexpr1-410 {\n  INSERT INTO t3 SELECT * FROM t3 WHERE rowid=10;\n} {1 {UNIQUE constraint failed: index 't3abc'}}\n\ndo_execsql_test indexexpr1-500 {\n  CREATE TABLE t5(a);\n  CREATE TABLE cnt(x);\n  WITH RECURSIVE\n    c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<5)\n  INSERT INTO cnt(x) SELECT x FROM c;\n  INSERT INTO t5(a) SELECT printf('abc%03dxyz',x) FROM cnt;\n  CREATE INDEX t5ax ON t5( substr(a,4,3) );\n} {}\ndo_execsql_test indexexpr1-510 {\n  -- The use of the \"k\" alias in the WHERE clause is technically\n  -- illegal, but SQLite allows it for historical reasons.  In this\n  -- test and the next, verify that \"k\" can be used by the t5ax index\n  SELECT substr(a,4,3) AS k FROM cnt, t5 WHERE k=printf('%03d',x);\n} {001 002 003 004 005}\ndo_execsql_test indexexpr1-510eqp {\n  EXPLAIN QUERY PLAN\n  SELECT substr(a,4,3) AS k FROM cnt, t5 WHERE k=printf('%03d',x);\n} {/USING INDEX t5ax/}\n\n# Skip-scan on an indexed expression\n#\ndo_execsql_test indexexpr1-600 {\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t4(a,b,c,d,e,f,g,h,i);\n  CREATE INDEX t4all ON t4(a,b,c<d,e,f,i,h);\n  INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);\n  ANALYZE;\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1\n    VALUES('t4','t4all','600000 160000 40000 10000 2000 600 100 40 10');\n  ANALYZE sqlite_master;\n  SELECT i FROM t4 WHERE e=5;\n} {9}\n\n# Indexed expressions on both sides of an == in a WHERE clause.\n#\ndo_execsql_test indexexpr1-700 {\n  DROP TABLE IF EXISTS t7;\n  CREATE TABLE t7(a,b,c);\n  INSERT INTO t7(a,b,c) VALUES(1,2,2),('abc','def','def'),(4,5,6);\n  CREATE INDEX t7b ON t7(+b);\n  CREATE INDEX t7c ON t7(+c);\n  SELECT *, '|' FROM t7 WHERE +b=+c ORDER BY +a;\n} {1 2 2 | abc def def |}\ndo_execsql_test indexexpr1-710 {\n  CREATE TABLE t71(a,b,c);\n  CREATE INDEX t71bc ON t71(b+c);\n  CREATE TABLE t72(x,y,z);\n  CREATE INDEX t72yz ON t72(y+z);\n  INSERT INTO t71(a,b,c) VALUES(1,11,2),(2,7,15),(3,5,4);\n  INSERT INTO t72(x,y,z) VALUES(1,10,3),(2,8,14),(3,9,9);\n  SELECT a, x, '|' FROM t71, t72\n   WHERE b+c=y+z\n  ORDER BY +a, +x;\n} {1 1 | 2 2 |}\n\n# Collating sequences on indexes of expressions\n#\ndo_execsql_test indexexpr1-800 {\n  DROP TABLE IF EXISTS t8;\n  CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT);\n  CREATE UNIQUE INDEX t8bx ON t8(substr(b,2,4) COLLATE nocase);\n  INSERT INTO t8(a,b) VALUES(1,'Alice'),(2,'Bartholemew'),(3,'Cynthia');\n  SELECT * FROM t8 WHERE substr(b,2,4)='ARTH' COLLATE nocase;\n} {2 Bartholemew}\ndo_catchsql_test indexexpr1-810 {\n  INSERT INTO t8(a,b) VALUES(4,'BARTHMERE');\n} {1 {UNIQUE constraint failed: index 't8bx'}}\ndo_catchsql_test indexexpr1-820 {\n  DROP INDEX t8bx;\n  CREATE UNIQUE INDEX t8bx ON t8(substr(b,2,4) COLLATE rtrim);\n  INSERT INTO t8(a,b) VALUES(4,'BARTHMERE');\n} {0 {}}\n\n# Check that PRAGMA integrity_check works correctly on a\n# UNIQUE index that includes rowid and expression terms.\n#\ndo_execsql_test indexexpr1-900 {\n  CREATE TABLE t9(a,b,c,d);\n  CREATE UNIQUE INDEX t9x1 ON t9(c,abs(d),b);\n  INSERT INTO t9(rowid,a,b,c,d) VALUES(1,2,3,4,5);\n  INSERT INTO t9(rowid,a,b,c,d) VALUES(2,NULL,NULL,NULL,NULL);\n  INSERT INTO t9(rowid,a,b,c,d) VALUES(3,NULL,NULL,NULL,NULL);\n  INSERT INTO t9(rowid,a,b,c,d) VALUES(4,5,6,7,8);\n  PRAGMA integrity_check;\n} {ok}\ndo_catchsql_test indexexpr1-910 {\n  INSERT INTO t9(a,b,c,d) VALUES(5,6,7,-8);\n} {1 {UNIQUE constraint failed: index 't9x1'}}\n\n# Test cases derived from a NEVER() maro failure discovered by\n# Jonathan Metzman using AFL\n#\ndo_execsql_test indexexpr1-1000 {\n  DROP TABLE IF EXISTS t0;\n  CREATE TABLE t0(a,b,t);\n  CREATE INDEX i ON t0(a in(0,1));\n  INSERT INTO t0 VALUES(0,1,2),(2,3,4),(5,6,7);\n  UPDATE t0 SET b=99 WHERE (a in(0,1))=0;\n  SELECT *, '|' FROM t0 ORDER BY +a;\n} {0 1 2 | 2 99 4 | 5 99 7 |}\ndo_execsql_test indexexpr1-1010 {\n  UPDATE t0 SET b=88 WHERE (a in(0,1))=1;\n  SELECT *, '|' FROM t0 ORDER BY +a;\n} {0 88 2 | 2 99 4 | 5 99 7 |}\n\n# 2016-10-10\n# Make sure indexes on expressions skip over initial NULL values in the\n# index as they are suppose to do.\n# Ticket https://www.sqlite.org/src/tktview/4baa46491212947\n#\ndo_execsql_test indexexpr1-1100 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(NULL),(1);\n  SELECT '1:', typeof(a), a FROM t1 WHERE a<10;\n  SELECT '2:', typeof(a), a FROM t1 WHERE a+0<10;\n  CREATE INDEX t1x1 ON t1(a);\n  CREATE INDEX t1x2 ON t1(a+0);\n  SELECT '3:', typeof(a), a FROM t1 WHERE a<10;\n  SELECT '4:', typeof(a), a FROM t1 WHERE a+0<10;\n} {1: integer 1 2: integer 1 3: integer 1 4: integer 1}\n\ndo_execsql_test indexexpr1-1200 {\n  CREATE TABLE t10(a int, b int, c int, d int);\n  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 2, 2);\n  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 0, 0);\n  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 1, 1);\n  INSERT INTO t10(a, b, c, d) VALUES(1, 1, 1, 1);\n  INSERT INTO t10(a, b, c, d) VALUES(1, 1, 0, 0);\n  INSERT INTO t10(a, b, c, d) VALUES(2, 2, 0, 0);\n\n  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;\n} {\n  0 0 0 2 0 4 2 0 2 2 4 0\n}\ndo_execsql_test indexexpr1-1200.1 {\n  CREATE INDEX t10_ab ON t10(a+b);\n}\ndo_execsql_test indexexpr1-1200.2 {\n  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;\n} {\n  0 0 0 2 0 4 2 0 2 2 4 0\n}\ndo_execsql_test indexexpr1-1200.3 {\n  CREATE INDEX t10_abcd ON t10(a+b,c+d);\n}\ndo_execsql_test indexexpr1-1200.4 {\n  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;\n} {\n  0 0 0 2 0 4 2 0 2 2 4 0\n}\n\n# Ticket https://www.sqlite.org/src/tktview/eb703ba7b50c1a\n# Incorrect result using an index on an expression with a collating function\n#\ndo_execsql_test indexexpr1-1300.1 {\n  CREATE TABLE t1300(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1300 VALUES(1,'coffee'),(2,'COFFEE'),(3,'stress'),(4,'STRESS');\n  CREATE INDEX t1300bexpr ON t1300( substr(b,4) );\n  SELECT a FROM t1300 WHERE substr(b,4)='ess' COLLATE nocase ORDER BY +a;\n} {3 4}\n\n# Ticket https://sqlite.org/src/tktview/aa98619a\n# Assertion fault using an index on a constant\n#\ndo_execsql_test indexexpr1-1400 {\n  CREATE TABLE t1400(x TEXT);\n  CREATE INDEX t1400x ON t1400(1);  -- Index on a constant\n  SELECT 1 IN (SELECT 2) FROM t1400;\n} {}\ndo_execsql_test indexexpr1-1410 {\n  INSERT INTO t1400 VALUES('a'),('b');\n  SELECT 1 IN (SELECT 2) FROM t1400;\n} {0 0}\ndo_execsql_test indexexpr1-1420 {\n  SELECT 1 IN (SELECT 2 UNION ALL SELECT 1) FROM t1400;\n} {1 1}\ndo_execsql_test indexexpr1-1430 {\n  DROP INDEX t1400x;\n  CREATE INDEX t1400x ON t1400(abs(15+3));\n  SELECT abs(15+3) IN (SELECT 17 UNION ALL SELECT 18) FROM t1;\n} {1 1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/indexexpr2.test",
    "content": "# 2017 April 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix indexexpr2\n\ndo_execsql_test 1 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n  INSERT INTO t1 VALUES(3, 'three');\n\n  CREATE INDEX i1 ON t1(b || 'x');\n}\n\ndo_execsql_test 1.1 {\n  SELECT 'TWOX' == (b || 'x') FROM t1 WHERE (b || 'x')>'onex'\n} {0 0}\n\ndo_execsql_test 1.2 {\n  SELECT 'TWOX' == (b || 'x') COLLATE nocase  FROM t1 WHERE (b || 'x')>'onex'\n} {0 1}\n\ndo_execsql_test 2.0 {\n  CREATE INDEX i2 ON t1(a+1);\n}\n\ndo_execsql_test 2.1 {\n  SELECT a+1, quote(a+1) FROM t1 ORDER BY 1;\n} {2 2 3 3 4 4}\n\n#-------------------------------------------------------------------------\n# At one point SQLite was incorrectly using indexes on expressions to\n# optimize ORDER BY and GROUP BY clauses even when the collation\n# sequences of the query and index did not match (ticket [e20dd54ab0e4]).\n# The following tests - 3.* - attempt to verify that this has been fixed.\n#\n\nreset_db\ndo_execsql_test 3.1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n} {}\n\ndo_eqp_test 3.1.1 {\n  SELECT b FROM t1 WHERE b IS NOT NULL AND a IS NULL \n  GROUP BY b COLLATE nocase\n  ORDER BY b COLLATE nocase;\n} {/USE TEMP B-TREE FOR GROUP BY/}\n\ndo_execsql_test 3.2.0 {\n  CREATE TABLE t2(x);\n\n  INSERT INTO t2 VALUES('.ABC');\n  INSERT INTO t2 VALUES('.abcd');\n  INSERT INTO t2 VALUES('.defg');\n  INSERT INTO t2 VALUES('.DEF');\n} {}\n\ndo_execsql_test 3.2.1 {\n  SELECT x FROM t2 ORDER BY substr(x, 2) COLLATE nocase;\n} {\n  .ABC .abcd .DEF .defg\n}\n\ndo_execsql_test 3.2.2 {\n  CREATE INDEX i2 ON t2( substr(x, 2) );\n  SELECT x FROM t2 ORDER BY substr(x, 2) COLLATE nocase;\n} {\n  .ABC .abcd .DEF .defg\n}\n\ndo_execsql_test 3.3.0 {\n  CREATE TABLE t3(x);\n}\n\nifcapable json1 {\n  do_eqp_test 3.3.1 {\n    SELECT json_extract(x, '$.b') FROM t2 \n    WHERE json_extract(x, '$.b') IS NOT NULL AND json_extract(x, '$.a') IS NULL \n    GROUP BY json_extract(x, '$.b') COLLATE nocase\n    ORDER BY json_extract(x, '$.b') COLLATE nocase;\n  } {\n    0 0 0 {SCAN TABLE t2} \n    0 0 0 {USE TEMP B-TREE FOR GROUP BY}\n  }\n  \n  do_execsql_test 3.3.2 {\n    CREATE INDEX i3 ON t3(json_extract(x, '$.a'), json_extract(x, '$.b'));\n  } {}\n  \n  do_eqp_test 3.3.3 {\n    SELECT json_extract(x, '$.b') FROM t3 \n    WHERE json_extract(x, '$.b') IS NOT NULL AND json_extract(x, '$.a') IS NULL \n    GROUP BY json_extract(x, '$.b') COLLATE nocase\n    ORDER BY json_extract(x, '$.b') COLLATE nocase;\n  } {\n    0 0 0 {SEARCH TABLE t3 USING INDEX i3 (<expr>=?)} \n    0 0 0 {USE TEMP B-TREE FOR GROUP BY}\n  }\n}\n\ndo_execsql_test 3.4.0 {\n  CREATE TABLE t4(a, b);\n  INSERT INTO t4 VALUES('.ABC', 1);\n  INSERT INTO t4 VALUES('.abc', 2);\n  INSERT INTO t4 VALUES('.ABC', 3);\n  INSERT INTO t4 VALUES('.abc', 4);\n}\n\ndo_execsql_test 3.4.1 {\n  SELECT * FROM t4 \n  WHERE substr(a, 2) = 'abc' COLLATE NOCASE\n  ORDER BY substr(a, 2), b;\n} {\n  .ABC 1   .ABC 3   .abc 2   .abc 4\n}\n\ndo_execsql_test 3.4.2 {\n  CREATE INDEX i4 ON t4( substr(a, 2) COLLATE NOCASE, b );\n  SELECT * FROM t4 \n  WHERE substr(a, 2) = 'abc' COLLATE NOCASE\n  ORDER BY substr(a, 2), b;\n} {\n  .ABC 1   .ABC 3   .abc 2   .abc 4\n}\n\ndo_execsql_test 3.4.3 {\n  DROP INDEX i4;\n  UPDATE t4 SET a = printf('%s%d',a,b);\n  SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;\n} {.ABC1 1 .abc2 2 .ABC3 3 .abc4 4}\ndo_execsql_test 3.4.4 {\n  SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE binary;\n} {.ABC1 1 .ABC3 3 .abc2 2 .abc4 4}\n\ndo_execsql_test 3.4.5 {\n  CREATE INDEX i4 ON t4( Substr(a,-2) COLLATE nocase );\n  SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;\n} {.ABC1 1 .abc2 2 .ABC3 3 .abc4 4}\ndo_execsql_test 3.4.5eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE nocase;\n} {/SCAN TABLE t4 USING INDEX i4/}\ndo_execsql_test 3.4.6 {\n  SELECT * FROM t4 ORDER BY Substr(a,-2) COLLATE binary;\n} {.ABC1 1 .ABC3 3 .abc2 2 .abc4 4}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/indexfault.test",
    "content": "# 2011 August 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nifcapable !mergesort {\n  finish_test\n  return\n}\n\nset testprefix indexfault\n\n# Set up the custom fault-injector. This is further configured by using\n# different values for $::custom_filter and different implementations\n# of Tcl proc [xCustom] for each test case.\n#\nproc install_custom_faultsim {} {\n  set ::FAULTSIM(custom)            [list      \\\n    -injectinstall   custom_injectinstall    \\\n    -injectstart     custom_injectstart      \\\n    -injectstop      custom_injectstop       \\\n    -injecterrlist   {{1 {disk I/O error}}}  \\\n    -injectuninstall custom_injectuninstall  \\\n  ]\n  proc custom_injectinstall {} {\n    testvfs shmfault -default true\n    shmfault filter $::custom_filter\n    shmfault script xCustom\n  }\n  proc custom_injectuninstall {} {\n    catch {db  close}\n    catch {db2 close}\n    shmfault delete\n  }\n  set ::custom_ifail -1\n  set ::custom_nfail -1\n  proc custom_injectstart {iFail} {\n    set ::custom_ifail $iFail\n    set ::custom_nfail 0\n  }\n  proc custom_injectstop {} {\n    set ::custom_ifail -1\n    return $::custom_nfail\n  }\n}\nproc uninstall_custom_faultsim {} {\n  unset -nocomplain ::FAULTSIM(custom)\n}\n\n\n#-------------------------------------------------------------------------\n# These tests - indexfault-1.* - Build an index on a smallish table with\n# all different kinds of fault-injection. The CREATE INDEX is run once\n# with default options and once with a 50KB soft-heap-limit.\n#\ndo_execsql_test 1.0 {\n  BEGIN;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(202));\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --     2\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --     4\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --     8\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --    16\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --    32\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --    64\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --   128\n    INSERT INTO t1 SELECT randomblob(202) FROM t1;     --   256\n  COMMIT;\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 1.1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE INDEX i1 ON t1(x) }\n  faultsim_test_result {0 {}} \n  faultsim_integrity_check\n}\nifcapable memorymanage {\n  set soft_limit [sqlite3_soft_heap_limit 50000]\n  do_faultsim_test 2.1 -prep {\n    faultsim_restore_and_reopen\n  } -body {\n    execsql { CREATE INDEX i1 ON t1(x) }\n    faultsim_test_result {0 {}} \n  }\n  sqlite3_soft_heap_limit $soft_limit\n}\n\n#-------------------------------------------------------------------------\n# These are similar to the indexfault-1.* tests, except they create an\n# index with more than one column.\n#\nsqlite3 db test.db\ndo_execsql_test 2.0 {\n  BEGIN;\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(t,u,v,w,x,y,z);\n    INSERT INTO t1 VALUES(\n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30)\n    );\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 2\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 4\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 8\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 16\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 32\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 64\n    INSERT INTO t1 SELECT \n      randomblob(30), randomblob(30), randomblob(30), randomblob(30),\n      randomblob(30), randomblob(30), randomblob(30) FROM t1;         -- 128\n  COMMIT;\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 2.1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }\n  faultsim_test_result {0 {}} \n  faultsim_integrity_check\n}\nifcapable memorymanage {\n  set soft_limit [sqlite3_soft_heap_limit 50000]\n  do_faultsim_test 2.2 -prep {\n    faultsim_restore_and_reopen\n  } -body {\n    execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }\n    faultsim_test_result {0 {}} \n  }\n  sqlite3_soft_heap_limit $soft_limit\n}\n\n#-------------------------------------------------------------------------\n# The following tests - indexfault-2.* - all attempt to build a index\n# on table t1 in the main database with injected IO errors. Individual\n# test cases work as follows:\n#\n#   3.1: IO errors injected into xOpen() calls.\n#   3.2: As 7.1, but with a low (50KB) soft-heap-limit.\n#\n#   3.3: IO errors injected into the first 200 write() calls made on the\n#        second temporary file.\n#   3.4: As 7.3, but with a low (50KB) soft-heap-limit.\n#\n#   3.5: After a certain amount of data has been read from the main database\n#        file (and written into the temporary b-tree), sqlite3_release_memory()\n#        is called to free as much memory as possible. This causes the temp\n#        b-tree to be flushed to disk. So that before its contents can be \n#        transfered to a PMA they must be read back from disk - creating extra\n#        opportunities for IO errors.\n#\ninstall_custom_faultsim\n\n# Set up a table to build indexes on. Save the setup using the \n# [faultsim_save_and_close] mechanism.\n# \nsqlite3 db test.db\ndo_execsql_test 3.0 {\n  BEGIN;\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(11000));\n    INSERT INTO t1 SELECT randomblob(11001) FROM t1;     --     2\n    INSERT INTO t1 SELECT randomblob(11002) FROM t1;     --     4\n    INSERT INTO t1 SELECT randomblob(11003) FROM t1;     --     8\n    INSERT INTO t1 SELECT randomblob(11004) FROM t1;     --    16\n    INSERT INTO t1 SELECT randomblob(11005) FROM t1;     --    32\n    INSERT INTO t1 SELECT randomblob(11006) FROM t1;     --    64\n    INSERT INTO t1 SELECT randomblob(11007) FROM t1;     --   128\n    INSERT INTO t1 SELECT randomblob(11008) FROM t1;     --   256\n    INSERT INTO t1 SELECT randomblob(11009) FROM t1;     --   512\n  COMMIT;\n}\nfaultsim_save_and_close\n\nset ::custom_filter xOpen\nproc xCustom {args} {\n  incr ::custom_ifail -1\n  if {$::custom_ifail==0} {\n    incr ::custom_nfail\n    return \"SQLITE_IOERR\"\n  }\n  return \"SQLITE_OK\"\n}\ndo_faultsim_test 3.1 -faults custom -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE INDEX i1 ON t1(x) }\n  faultsim_test_result {0 {}} \n}\nifcapable memorymanage {\n  set soft_limit [sqlite3_soft_heap_limit 50000]\n  do_faultsim_test 3.2 -faults custom -prep {\n    faultsim_restore_and_reopen\n  } -body {\n    execsql { CREATE INDEX i1 ON t1(x) }\n    faultsim_test_result {0 {}} \n  }\n  sqlite3_soft_heap_limit $soft_limit\n}\n\nset ::custom_filter {xOpen xWrite}\nproc xCustom {method args} {\n  if {$method == \"xOpen\"} {\n    if {[lindex $args 0] == \"\"} {\n      incr ::nTmpOpen 1\n      if {$::nTmpOpen == 3} { return \"failme\" }\n    }\n    return \"SQLITE_OK\"\n  }\n  if {$::custom_ifail<200 && [lindex $args 1] == \"failme\"} {\n    incr ::custom_ifail -1\n    if {$::custom_ifail==0} {\n      incr ::custom_nfail\n      return \"SQLITE_IOERR\"\n    }\n  }\n  return \"SQLITE_OK\"\n}\n\ndo_faultsim_test 3.3 -faults custom -prep {\n  faultsim_restore_and_reopen\n  set ::nTmpOpen 0\n} -body {\n  execsql { CREATE INDEX i1 ON t1(x) }\n  faultsim_test_result {0 {}} \n}\n\nifcapable memorymanage {\n  set soft_limit [sqlite3_soft_heap_limit 50000]\n  do_faultsim_test 3.4 -faults custom -prep {\n    faultsim_restore_and_reopen\n    set ::nTmpOpen 0\n  } -body {\n    execsql { CREATE INDEX i1 ON t1(x) }\n    faultsim_test_result {0 {}} \n  }\n  sqlite3_soft_heap_limit $soft_limit\n}\n\nuninstall_custom_faultsim\n\n#-------------------------------------------------------------------------\n# Test 4: After a certain amount of data has been read from the main database\n# file (and written into the temporary b-tree), sqlite3_release_memory() is\n# called to free as much memory as possible. This causes the temp b-tree to be\n# flushed to disk. So that before its contents can be transfered to a PMA they\n# must be read back from disk - creating extra opportunities for IO errors.\n# \ninstall_custom_faultsim\n\ncatch { db close }\nforcedelete test.db\nsqlite3 db test.db\n\ndo_execsql_test 4.0 {\n  BEGIN;\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(11000));\n    INSERT INTO t1 SELECT randomblob(11001) FROM t1;     --     2\n    INSERT INTO t1 SELECT randomblob(11002) FROM t1;     --     4\n    INSERT INTO t1 SELECT randomblob(11003) FROM t1;     --     8\n    INSERT INTO t1 SELECT randomblob(11004) FROM t1;     --    16\n    INSERT INTO t1 SELECT randomblob(11005) FROM t1;     --    32\n    INSERT INTO t1 SELECT randomblob(11005) FROM t1;     --    64\n  COMMIT;\n}\nfaultsim_save_and_close\n\ntestvfs tvfs \ntvfs script xRead\ntvfs filter xRead\nset ::nRead 0\nproc xRead {method file args} {\n  if {[file tail $file] == \"test.db\"} { incr ::nRead }\n}\n\ndo_test 4.1 {\n  sqlite3 db test.db -vfs tvfs\n  execsql { CREATE INDEX i1 ON t1(x) }\n} {}\n\ndb close\ntvfs delete\n\nset ::custom_filter xRead\nproc xCustom {method file args} {\n  incr ::nReadCall\n  if {$::nReadCall >= ($::nRead/5)} {\n    if {$::nReadCall == ($::nRead/5)} {\n      set nByte [sqlite3_release_memory [expr 64*1024*1024]]\n      sqlite3_soft_heap_limit 20000\n    }\n    if {$file == \"\"} {\n      incr ::custom_ifail -1\n      if {$::custom_ifail==0} {\n        incr ::custom_nfail\n        return \"SQLITE_IOERR\"\n      }\n    }\n  }\n  return \"SQLITE_OK\"\n}\n\ndo_faultsim_test 4.2 -faults custom -prep {\n  faultsim_restore_and_reopen\n  set ::nReadCall 0\n  sqlite3_soft_heap_limit 0\n} -body {\n  execsql { CREATE INDEX i1 ON t1(x) }\n  faultsim_test_result {0 {}} \n}\n\nuninstall_custom_faultsim\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/init.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the effects of a failure in \n# sqlite3_initialize().\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nif {[db eval {SELECT sqlite_compileoption_used('THREADSAFE=0')}]} {\n  finish_test\n  return\n}\n\ndb close\n\nforeach {t failed rc started} {\n  1.1 {}       SQLITE_OK    {mutex mem pcache}\n  1.2 {mutex}  SQLITE_ERROR {}\n  1.3 {mem}    SQLITE_ERROR {mutex}\n  1.4 {pcache} SQLITE_ERROR {mutex mem}\n} {\n  do_test init-$t.1 {\n    eval init_wrapper_install $failed\n    sqlite3_initialize\n  } $rc\n  do_test init-$t.2 {\n    init_wrapper_query\n  } $started\n  do_test init-$t.3 {\n    sqlite3_shutdown\n    init_wrapper_query\n  } {}\n  do_test init-$t.4 {\n    sqlite3_initialize\n  } $rc\n  do_test init-$t.5 {\n    init_wrapper_query\n  } $started\n  do_test init-$t.6 {\n    init_wrapper_clear\n    sqlite3_initialize\n  } SQLITE_OK\n  do_test init-$t.7 {\n    init_wrapper_query\n  } {mutex mem pcache}\n  do_test init-$t.8 {\n    init_wrapper_uninstall\n  } {}\n}\n\nsource $testdir/malloc_common.tcl\nif {$MEMDEBUG} {\n  do_malloc_test init-2 -tclprep {\n    db close\n    init_wrapper_install\n  } -tclbody {\n    set rc [sqlite3_initialize]\n    if {[string match \"SQLITE*NOMEM\" $rc]} {error \"out of memory\"}\n  } -cleanup {\n    set zRepeat \"transient\"\n    if {$::iRepeat} {set zRepeat \"persistent\"}\n    do_test init-2.$zRepeat.$::n.x {\n      init_wrapper_clear\n      sqlite3_initialize\n    } SQLITE_OK\n    init_wrapper_uninstall\n  }\n}\n\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/insert.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the INSERT statement.\n#\n# $Id: insert.test,v 1.31 2007/04/05 11:25:59 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Try to insert into a non-existant table.\n#\ndo_test insert-1.1 {\n  set v [catch {execsql {INSERT INTO test1 VALUES(1,2,3)}} msg]\n  lappend v $msg\n} {1 {no such table: test1}}\n\n# Try to insert into sqlite_master\n#\ndo_test insert-1.2 {\n  set v [catch {execsql {INSERT INTO sqlite_master VALUES(1,2,3,4)}} msg]\n  lappend v $msg\n} {1 {table sqlite_master may not be modified}}\n\n# Try to insert the wrong number of entries.\n#\ndo_test insert-1.3 {\n  execsql {CREATE TABLE test1(one int, two int, three int)}\n  set v [catch {execsql {INSERT INTO test1 VALUES(1,2)}} msg]\n  lappend v $msg\n} {1 {table test1 has 3 columns but 2 values were supplied}}\ndo_test insert-1.3b {\n  set v [catch {execsql {INSERT INTO test1 VALUES(1,2,3,4)}} msg]\n  lappend v $msg\n} {1 {table test1 has 3 columns but 4 values were supplied}}\ndo_test insert-1.3c {\n  set v [catch {execsql {INSERT INTO test1(one,two) VALUES(1,2,3,4)}} msg]\n  lappend v $msg\n} {1 {4 values for 2 columns}}\ndo_test insert-1.3d {\n  set v [catch {execsql {INSERT INTO test1(one,two) VALUES(1)}} msg]\n  lappend v $msg\n} {1 {1 values for 2 columns}}\n\n# Try to insert into a non-existant column of a table.\n#\ndo_test insert-1.4 {\n  set v [catch {execsql {INSERT INTO test1(one,four) VALUES(1,2)}} msg]\n  lappend v $msg\n} {1 {table test1 has no column named four}}\n\n# Make sure the inserts actually happen\n#\ndo_test insert-1.5 {\n  execsql {INSERT INTO test1 VALUES(1,2,3)}\n  execsql {SELECT * FROM test1}\n} {1 2 3}\ndo_test insert-1.5b {\n  execsql {INSERT INTO test1 VALUES(4,5,6)}\n  execsql {SELECT * FROM test1 ORDER BY one}\n} {1 2 3 4 5 6}\ndo_test insert-1.5c {\n  execsql {INSERT INTO test1 VALUES(7,8,9)}\n  execsql {SELECT * FROM test1 ORDER BY one}\n} {1 2 3 4 5 6 7 8 9}\n\ndo_test insert-1.6 {\n  execsql {DELETE FROM test1}\n  execsql {INSERT INTO test1(one,two) VALUES(1,2)}\n  execsql {SELECT * FROM test1 ORDER BY one}\n} {1 2 {}}\ndo_test insert-1.6b {\n  execsql {INSERT INTO test1(two,three) VALUES(5,6)}\n  execsql {SELECT * FROM test1 ORDER BY one}\n} {{} 5 6 1 2 {}}\ndo_test insert-1.6c {\n  execsql {INSERT INTO test1(three,one) VALUES(7,8)}\n  execsql {SELECT * FROM test1 ORDER BY one}\n} {{} 5 6 1 2 {} 8 {} 7}\n\n# A table to use for testing default values\n#\ndo_test insert-2.1 {\n  execsql {\n    CREATE TABLE test2(\n      f1 int default -111, \n      f2 real default +4.32,\n      f3 int default +222,\n      f4 int default 7.89\n    )\n  }\n  execsql {SELECT * from test2}\n} {}\ndo_test insert-2.2 {\n  execsql {INSERT INTO test2(f1,f3) VALUES(+10,-10)}\n  execsql {SELECT * FROM test2}\n} {10 4.32 -10 7.89}\ndo_test insert-2.3 {\n  execsql {INSERT INTO test2(f2,f4) VALUES(1.23,-3.45)}\n  execsql {SELECT * FROM test2 WHERE f1==-111}\n} {-111 1.23 222 -3.45}\ndo_test insert-2.4 {\n  execsql {INSERT INTO test2(f1,f2,f4) VALUES(77,+1.23,3.45)}\n  execsql {SELECT * FROM test2 WHERE f1==77}\n} {77 1.23 222 3.45}\ndo_test insert-2.10 {\n  execsql {\n    DROP TABLE test2;\n    CREATE TABLE test2(\n      f1 int default 111, \n      f2 real default -4.32,\n      f3 text default hi,\n      f4 text default 'abc-123',\n      f5 varchar(10)\n    )\n  }\n  execsql {SELECT * from test2}\n} {}\ndo_test insert-2.11 {\n  execsql {INSERT INTO test2(f2,f4) VALUES(-2.22,'hi!')}\n  execsql {SELECT * FROM test2}\n} {111 -2.22 hi hi! {}}\ndo_test insert-2.12 {\n  execsql {INSERT INTO test2(f1,f5) VALUES(1,'xyzzy')}\n  execsql {SELECT * FROM test2 ORDER BY f1}\n} {1 -4.32 hi abc-123 xyzzy 111 -2.22 hi hi! {}}\n\n# Do additional inserts with default values, but this time\n# on a table that has indices.  In particular we want to verify\n# that the correct default values are inserted into the indices.\n#\ndo_test insert-3.1 {\n  execsql {\n    DELETE FROM test2;\n    CREATE INDEX index9 ON test2(f1,f2);\n    CREATE INDEX indext ON test2(f4,f5);\n    SELECT * from test2;\n  }\n} {}\n\n# Update for sqlite3 v3:\n# Change the 111 to '111' in the following two test cases, because\n# the default value is being inserted as a string. TODO: It shouldn't be.\ndo_test insert-3.2 {\n  execsql {INSERT INTO test2(f2,f4) VALUES(-3.33,'hum')}\n  execsql {SELECT * FROM test2 WHERE f1='111' AND f2=-3.33}\n} {111 -3.33 hi hum {}}\ndo_test insert-3.3 {\n  execsql {INSERT INTO test2(f1,f2,f5) VALUES(22,-4.44,'wham')}\n  execsql {SELECT * FROM test2 WHERE f1='111' AND f2=-3.33}\n} {111 -3.33 hi hum {}}\ndo_test insert-3.4 {\n  execsql {SELECT * FROM test2 WHERE f1=22 AND f2=-4.44}\n} {22 -4.44 hi abc-123 wham}\nifcapable {reindex} {\n  do_test insert-3.5 {\n    execsql REINDEX\n  } {}\n}\nintegrity_check insert-3.5\n\n# Test of expressions in the VALUES clause\n#\ndo_test insert-4.1 {\n  execsql {\n    CREATE TABLE t3(a,b,c);\n    INSERT INTO t3 VALUES(1+2+3,4,5);\n    SELECT * FROM t3;\n  }\n} {6 4 5}\ndo_test insert-4.2 {\n  ifcapable subquery {\n    execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,5,6);}\n  } else {\n    set maxa [execsql {SELECT max(a) FROM t3}]\n    execsql \"INSERT INTO t3 VALUES($maxa+1,5,6);\"\n  }\n  execsql {\n    SELECT * FROM t3 ORDER BY a;\n  }\n} {6 4 5 7 5 6}\nifcapable subquery {\n  do_test insert-4.3 {\n    catchsql {\n      INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1,t3.a,6);\n      SELECT * FROM t3 ORDER BY a;\n    }\n  } {1 {no such column: t3.a}}\n}\ndo_test insert-4.4 {\n  ifcapable subquery {\n    execsql {INSERT INTO t3 VALUES((SELECT b FROM t3 WHERE a=0),6,7);}\n  } else {\n    set b [execsql {SELECT b FROM t3 WHERE a = 0}]\n    if {$b==\"\"} {set b NULL}\n    execsql \"INSERT INTO t3 VALUES($b,6,7);\"\n  }\n  execsql {\n    SELECT * FROM t3 ORDER BY a;\n  }\n} {{} 6 7 6 4 5 7 5 6}\ndo_test insert-4.5 {\n  execsql {\n    SELECT b,c FROM t3 WHERE a IS NULL;\n  }\n} {6 7}\ndo_test insert-4.6 {\n  catchsql {\n    INSERT INTO t3 VALUES(notafunc(2,3),2,3);\n  }\n} {1 {no such function: notafunc}}\ndo_test insert-4.7 {\n  execsql {\n    INSERT INTO t3 VALUES(min(1,2,3),max(1,2,3),99);\n    SELECT * FROM t3 WHERE c=99;\n  }\n} {1 3 99}\n\n# Test the ability to insert from a temporary table into itself.\n# Ticket #275.\n#\nifcapable tempdb {\n  do_test insert-5.1 {\n    execsql {\n      CREATE TEMP TABLE t4(x);\n      INSERT INTO t4 VALUES(1);\n      SELECT * FROM t4;\n    }\n  } {1}\n  do_test insert-5.2 {\n    execsql {\n      INSERT INTO t4 SELECT x+1 FROM t4;\n      SELECT * FROM t4;\n    }\n  } {1 2}\n  ifcapable {explain} {\n    do_test insert-5.3 {\n      # verify that a temporary table is used to copy t4 to t4\n      set x [execsql {\n        EXPLAIN INSERT INTO t4 SELECT x+2 FROM t4;\n      }]\n      expr {[lsearch $x OpenEphemeral]>0}\n    } {1}\n  }\n  \n  do_test insert-5.4 {\n    # Verify that table \"test1\" begins on page 3.  This should be the same\n    # page number used by \"t4\" above.\n    #\n    # Update for v3 - the first table now begins on page 2 of each file, not 3.\n    execsql {\n      SELECT rootpage FROM sqlite_master WHERE name='test1';\n    }\n  } [expr $AUTOVACUUM?3:2]\n  do_test insert-5.5 {\n    # Verify that \"t4\" begins on page 3.\n    #\n    # Update for v3 - the first table now begins on page 2 of each file, not 3.\n    execsql {\n      SELECT rootpage FROM sqlite_temp_master WHERE name='t4';\n    }\n  } {2}\n  do_test insert-5.6 {\n    # This should not use an intermediate temporary table.\n    execsql {\n      INSERT INTO t4 SELECT one FROM test1 WHERE three=7;\n      SELECT * FROM t4\n    }\n  } {1 2 8}\n  ifcapable {explain} {\n    do_test insert-5.7 {\n      # verify that no temporary table is used to copy test1 to t4\n      set x [execsql {\n        EXPLAIN INSERT INTO t4 SELECT one FROM test1;\n      }]\n      expr {[lsearch $x OpenTemp]>0}\n    } {0}\n  }\n}\n\n# Ticket #334:  REPLACE statement corrupting indices.\n#\nifcapable conflict {\n  # The REPLACE command is not available if SQLITE_OMIT_CONFLICT is \n  # defined at compilation time.\n  do_test insert-6.1 {\n    execsql {\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n      INSERT INTO t1 VALUES(1,2);\n      INSERT INTO t1 VALUES(2,3);\n      SELECT b FROM t1 WHERE b=2;\n    }\n  } {2}\n  do_test insert-6.2 {\n    execsql {\n      REPLACE INTO t1 VALUES(1,4);\n      SELECT b FROM t1 WHERE b=2;\n    }\n  } {}\n  do_test insert-6.3 {\n    execsql {\n      UPDATE OR REPLACE t1 SET a=2 WHERE b=4;\n      SELECT * FROM t1 WHERE b=4;\n    }\n  } {2 4}\n  do_test insert-6.4 {\n    execsql {\n      SELECT * FROM t1 WHERE b=3;\n    }\n  } {}\n  ifcapable {reindex} {\n    do_test insert-6.5 {\n      execsql REINDEX\n    } {}\n  }\n  do_test insert-6.6 {\n    execsql {\n      DROP TABLE t1;\n    }\n  } {}\n}\n\n# Test that the special optimization for queries of the form \n# \"SELECT max(x) FROM tbl\" where there is an index on tbl(x) works with \n# INSERT statments.\ndo_test insert-7.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    CREATE INDEX i1 ON t1(a);\n  }\n} {}\ndo_test insert-7.2 {\n  execsql {\n    INSERT INTO t1 SELECT max(a) FROM t1;\n  }\n} {}\ndo_test insert-7.3 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} {1 2 2}\n\n# Ticket #1140:  Check for an infinite loop in the algorithm that tests\n# to see if the right-hand side of an INSERT...SELECT references the left-hand\n# side.\n#\nifcapable subquery&&compound {\n  do_test insert-8.1 {\n    execsql {\n      INSERT INTO t3 SELECT * FROM (SELECT * FROM t3 UNION ALL SELECT 1,2,3)\n    }\n  } {}\n}\n\n# Make sure the rowid cache in the VDBE is reset correctly when\n# an explicit rowid is given.\n#\ndo_test insert-9.1 {\n  execsql {\n    CREATE TABLE t5(x);\n    INSERT INTO t5 VALUES(1);\n    INSERT INTO t5 VALUES(2);\n    INSERT INTO t5 VALUES(3);\n    INSERT INTO t5(rowid, x) SELECT nullif(x*2+10,14), x+100 FROM t5;\n    SELECT rowid, x FROM t5;\n  }\n} {1 1 2 2 3 3 12 101 13 102 16 103}\ndo_test insert-9.2 {\n  execsql {\n    CREATE TABLE t6(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t6 VALUES(1,1);\n    INSERT INTO t6 VALUES(2,2);\n    INSERT INTO t6 VALUES(3,3);\n    INSERT INTO t6 SELECT nullif(y*2+10,14), y+100 FROM t6;\n    SELECT x, y FROM t6;\n  }\n} {1 1 2 2 3 3 12 101 13 102 16 103}\n\n# Multiple VALUES clauses\n#\nifcapable compound {\n  do_test insert-10.1 {\n    execsql {\n      CREATE TABLE t10(a,b,c);\n      INSERT INTO t10 VALUES(1,2,3), (4,5,6), (7,8,9);\n      SELECT * FROM t10;\n    }\n  } {1 2 3 4 5 6 7 8 9}\n  do_test insert-10.2 {\n    catchsql {\n      INSERT INTO t10 VALUES(11,12,13), (14,15), (16,17,28);\n    }\n  } {1 {all VALUES must have the same number of terms}}\n}\n\n# Need for the OP_SoftNull opcode\n#\ndo_execsql_test insert-11.1 {\n  CREATE TABLE t11a AS SELECT '123456789' AS x;\n  CREATE TABLE t11b (a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t11b SELECT x, x, x FROM t11a;\n  SELECT quote(a), quote(b), quote(c) FROM t11b;\n} {123456789 '123456789' '123456789'}\n\n\n# More columns of input than there are columns in the table.\n# Ticket http://www.sqlite.org/src/info/e9654505cfda9361\n#\ndo_execsql_test insert-12.1 {\n  CREATE TABLE t12a(a,b,c,d,e,f,g);\n  INSERT INTO t12a VALUES(101,102,103,104,105,106,107);\n  CREATE TABLE t12b(x);\n  INSERT INTO t12b(x,rowid,x,x,x,x,x) SELECT * FROM t12a;\n  SELECT rowid, x FROM t12b;\n} {102 101}\ndo_execsql_test insert-12.2 {\n  CREATE TABLE tab1( value INTEGER);\n  INSERT INTO tab1 (value, _rowid_) values( 11, 1);\n  INSERT INTO tab1 (value, _rowid_) SELECT 22,999;\n  SELECT * FROM tab1;\n} {11 22}\ndo_execsql_test insert-12.3 {\n  CREATE TABLE t12c(a, b DEFAULT 'xyzzy', c);\n  INSERT INTO t12c(a, rowid, c) SELECT 'one', 999, 'two';\n  SELECT * FROM t12c;\n} {one xyzzy two}\n\n\nintegrity_check insert-99.0\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/insert2.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the INSERT statement that takes is\n# result from a SELECT.\n#\n# $Id: insert2.test,v 1.19 2008/01/16 18:20:42 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix insert2\n\n# Create some tables with data that we can select against\n#\ndo_test insert2-1.0 {\n  execsql {CREATE TABLE d1(n int, log int);}\n  for {set i 1} {$i<=20} {incr i} {\n    for {set j 0} {(1<<$j)<$i} {incr j} {}\n    execsql \"INSERT INTO d1 VALUES($i,$j)\"\n  }\n  execsql {SELECT * FROM d1 ORDER BY n}\n} {1 0 2 1 3 2 4 2 5 3 6 3 7 3 8 3 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 5 18 5 19 5 20 5}\n\n# Insert into a new table from the old one.\n#\ndo_test insert2-1.1.1 {\n  execsql {\n    CREATE TABLE t1(log int, cnt int);\n    PRAGMA count_changes=on;\n  }\n  ifcapable explain {\n    execsql {\n      EXPLAIN INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;\n    }\n  }\n  execsql {\n    INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;\n  }\n} {6}\ndo_test insert2-1.1.2 {\n  db changes\n} {6}\ndo_test insert2-1.1.3 {\n  execsql {SELECT * FROM t1 ORDER BY log}\n} {0 1 1 1 2 2 3 4 4 8 5 4}\n\nifcapable compound {\ndo_test insert2-1.2.1 {\n  catch {execsql {DROP TABLE t1}}\n  execsql {\n    CREATE TABLE t1(log int, cnt int);\n    INSERT INTO t1 \n       SELECT log, count(*) FROM d1 GROUP BY log\n       EXCEPT SELECT n-1,log FROM d1;\n  }\n} {4}\ndo_test insert2-1.2.2 {\n  execsql {\n    SELECT * FROM t1 ORDER BY log;\n  }\n} {0 1 3 4 4 8 5 4}\ndo_test insert2-1.3.1 {\n  catch {execsql {DROP TABLE t1}}\n  execsql {\n    CREATE TABLE t1(log int, cnt int);\n    PRAGMA count_changes=off;\n    INSERT INTO t1 \n       SELECT log, count(*) FROM d1 GROUP BY log\n       INTERSECT SELECT n-1,log FROM d1;\n  }\n} {}\ndo_test insert2-1.3.2 {\n  execsql {\n    SELECT * FROM t1 ORDER BY log;\n  }\n} {1 1 2 2}\n} ;# ifcapable compound\nexecsql {PRAGMA count_changes=off;}\n\ndo_test insert2-1.4 {\n  catch {execsql {DROP TABLE t1}}\n  set r [execsql {\n    CREATE TABLE t1(log int, cnt int);\n    CREATE INDEX i1 ON t1(log);\n    CREATE INDEX i2 ON t1(cnt);\n    INSERT INTO t1 SELECT log, count() FROM d1 GROUP BY log;\n    SELECT * FROM t1 ORDER BY log;\n  }]\n  lappend r [execsql {SELECT cnt FROM t1 WHERE log=3}]\n  lappend r [execsql {SELECT log FROM t1 WHERE cnt=4 ORDER BY log}]\n} {0 1 1 1 2 2 3 4 4 8 5 4 4 {3 5}}\n\ndo_test insert2-2.0 {\n  execsql {\n    CREATE TABLE t3(a,b,c);\n    CREATE TABLE t4(x,y);\n    INSERT INTO t4 VALUES(1,2);\n    SELECT * FROM t4;\n  }\n} {1 2}\ndo_test insert2-2.1 {\n  execsql {\n    INSERT INTO t3(a,c) SELECT * FROM t4;\n    SELECT * FROM t3;\n  }\n} {1 {} 2}\ndo_test insert2-2.2 {\n  execsql {\n    DELETE FROM t3;\n    INSERT INTO t3(c,b) SELECT * FROM t4;\n    SELECT * FROM t3;\n  }\n} {{} 2 1}\ndo_test insert2-2.3 {\n  execsql {\n    DELETE FROM t3;\n    INSERT INTO t3(c,a,b) SELECT x, 'hi', y FROM t4;\n    SELECT * FROM t3;\n  }\n} {hi 2 1}\n\nintegrity_check insert2-3.0\n\n# File table t4 with lots of data\n#\ndo_test insert2-3.1 {\n  execsql {\n    SELECT * from t4;\n  }\n} {1 2}\ndo_test insert2-3.2 {\n  set x [db total_changes]\n  execsql {\n    BEGIN;\n    INSERT INTO t4 VALUES(2,4);\n    INSERT INTO t4 VALUES(3,6);\n    INSERT INTO t4 VALUES(4,8);\n    INSERT INTO t4 VALUES(5,10);\n    INSERT INTO t4 VALUES(6,12);\n    INSERT INTO t4 VALUES(7,14);\n    INSERT INTO t4 VALUES(8,16);\n    INSERT INTO t4 VALUES(9,18);\n    INSERT INTO t4 VALUES(10,20);\n    COMMIT;\n  }\n  expr [db total_changes] - $x\n} {9}\ndo_test insert2-3.2.1 {\n  execsql {\n    SELECT count(*) FROM t4;\n  }\n} {10}\ndo_test insert2-3.3 {\n  ifcapable subquery {\n    execsql {\n      BEGIN;\n      INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;\n      INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;\n      INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;\n      INSERT INTO t4 SELECT x+(SELECT max(x) FROM t4),y FROM t4;\n      COMMIT;\n      SELECT count(*) FROM t4;\n    }\n  } else {\n    db function max_x_t4 {execsql {SELECT max(x) FROM t4}}\n    execsql {\n      BEGIN;\n      INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;\n      INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;\n      INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;\n      INSERT INTO t4 SELECT x+max_x_t4() ,y FROM t4;\n      COMMIT;\n      SELECT count(*) FROM t4;\n    }\n  }\n} {160}\ndo_test insert2-3.4 {\n  execsql {\n    BEGIN;\n    UPDATE t4 SET y='lots of data for the row where x=' || x\n                     || ' and y=' || y || ' - even more data to fill space';\n    COMMIT;\n    SELECT count(*) FROM t4;\n  }\n} {160}\ndo_test insert2-3.5 {\n  ifcapable subquery {\n    execsql {\n      BEGIN;\n      INSERT INTO t4 SELECT x+(SELECT max(x)+1 FROM t4),y FROM t4;\n      SELECT count(*) from t4;\n      ROLLBACK;\n    }\n  } else {\n    execsql {\n      BEGIN;\n      INSERT INTO t4 SELECT x+max_x_t4()+1,y FROM t4;\n      SELECT count(*) from t4;\n      ROLLBACK;\n    }\n  }\n} {320}\ndo_test insert2-3.6 {\n  execsql {\n    SELECT count(*) FROM t4;\n  }\n} {160}\ndo_test insert2-3.7 {\n  execsql {\n    BEGIN;\n    DELETE FROM t4 WHERE x!=123;\n    SELECT count(*) FROM t4;\n    ROLLBACK;\n  }\n} {1}\ndo_test insert2-3.8 {\n  db changes\n} {159}\nintegrity_check insert2-3.9\n\n# Ticket #901\n#\nifcapable tempdb {\n  do_test insert2-4.1 {\n    execsql {\n      CREATE TABLE Dependencies(depId integer primary key,\n        class integer, name str, flag str);\n      CREATE TEMPORARY TABLE DepCheck(troveId INT, depNum INT,\n        flagCount INT, isProvides BOOL, class INTEGER, name STRING,\n        flag STRING);\n      INSERT INTO DepCheck \n         VALUES(-1, 0, 1, 0, 2, 'libc.so.6', 'GLIBC_2.0');\n      INSERT INTO Dependencies \n         SELECT DISTINCT \n             NULL, \n             DepCheck.class, \n             DepCheck.name, \n             DepCheck.flag \n         FROM DepCheck LEFT OUTER JOIN Dependencies ON \n             DepCheck.class == Dependencies.class AND \n             DepCheck.name == Dependencies.name AND \n             DepCheck.flag == Dependencies.flag \n         WHERE \n             Dependencies.depId is NULL;\n    };\n  } {}\n}\n\n#--------------------------------------------------------------------\n# Test that the INSERT works when the SELECT statement (a) references\n# the table being inserted into and (b) is optimized to use an index\n# only.\ndo_test insert2-5.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES(1, 2);\n    CREATE INDEX t2i1 ON t2(a);\n    INSERT INTO t2 SELECT a, 3 FROM t2 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {1 2 1 3}\nifcapable subquery {\n  do_test insert2-5.2 {\n    execsql {\n      INSERT INTO t2 SELECT (SELECT a FROM t2), 4;\n      SELECT * FROM t2;\n    }\n  } {1 2 1 3 1 4}\n}\n\ndo_execsql_test 6.0 { \n  CREATE TABLE t5(a, b, c DEFAULT 'c', d);\n}\ndo_execsql_test 6.1 {\n  INSERT INTO t5(a) SELECT 456 UNION ALL SELECT 123 ORDER BY 1;\n  SELECT * FROM t5 ORDER BY rowid;\n} {123 {} c {}   456 {} c {}}\n\nifcapable fts3 {\n  do_execsql_test 6.2 {\n    CREATE VIRTUAL TABLE t0 USING fts4(a);\n  }\n  do_execsql_test 6.3 {\n    INSERT INTO t0 SELECT 0 UNION SELECT 0 AS 'x' ORDER BY x;\n    SELECT * FROM t0;\n  } {0}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/insert3.test",
    "content": "# 2005 January 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing corner cases of the INSERT statement.\n#\n# $Id: insert3.test,v 1.9 2009/04/23 14:58:40 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# All the tests in this file require trigger support\n#\nifcapable {trigger} {\n\n# Create a table and a corresponding insert trigger.  Do a self-insert\n# into the table.\n#\ndo_test insert3-1.0 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    CREATE TABLE log(x UNIQUE, y);\n    CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN\n      UPDATE log SET y=y+1 WHERE x=new.a;\n      INSERT OR IGNORE INTO log VALUES(new.a, 1);\n    END;\n    INSERT INTO t1 VALUES('hello','world');\n    INSERT INTO t1 VALUES(5,10);\n    SELECT * FROM log ORDER BY x;\n  }\n} {5 1 hello 1}\ndo_test insert3-1.1 {\n  execsql {\n    INSERT INTO t1 SELECT a, b+10 FROM t1;\n    SELECT * FROM log ORDER BY x;\n  }\n} {5 2 hello 2}\ndo_test insert3-1.2 {\n  execsql {\n    CREATE TABLE log2(x PRIMARY KEY,y);\n    CREATE TRIGGER r2 BEFORE INSERT ON t1 BEGIN\n      UPDATE log2 SET y=y+1 WHERE x=new.b;\n      INSERT OR IGNORE INTO log2 VALUES(new.b,1);\n    END;\n    INSERT INTO t1 VALUES(453,'hi');\n    SELECT * FROM log ORDER BY x;\n  }\n} {5 2 453 1 hello 2}\ndo_test insert3-1.3 {\n  execsql {\n    SELECT * FROM log2 ORDER BY x;\n  }\n} {hi 1}\nifcapable compound {\n  do_test insert3-1.4.1 {\n    execsql {\n      INSERT INTO t1 SELECT * FROM t1;\n      SELECT 'a:', x, y FROM log UNION ALL \n          SELECT 'b:', x, y FROM log2 ORDER BY x;\n    }\n  } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}\n  do_test insert3-1.4.2 {\n    execsql {\n      SELECT 'a:', x, y FROM log UNION ALL \n          SELECT 'b:', x, y FROM log2 ORDER BY x, y;\n    }\n  } {a: 5 4 b: 10 2 b: 20 1 a: 453 2 a: hello 4 b: hi 2 b: world 1}\n  do_test insert3-1.5 {\n    execsql {\n      INSERT INTO t1(a) VALUES('xyz');\n      SELECT * FROM log ORDER BY x;\n    }\n  } {5 4 453 2 hello 4 xyz 1}\n}\n\ndo_test insert3-2.1 {\n  execsql {\n    CREATE TABLE t2(\n      a INTEGER PRIMARY KEY,\n      b DEFAULT 'b',\n      c DEFAULT 'c'\n    );\n    CREATE TABLE t2dup(a,b,c);\n    CREATE TRIGGER t2r1 BEFORE INSERT ON t2 BEGIN\n      INSERT INTO t2dup(a,b,c) VALUES(new.a,new.b,new.c);\n    END;\n    INSERT INTO t2(a) VALUES(123);\n    INSERT INTO t2(b) VALUES(234);\n    INSERT INTO t2(c) VALUES(345);\n    SELECT * FROM t2dup;\n  }\n} {123 b c -1 234 c -1 b 345}\ndo_test insert3-2.2 {\n  execsql {\n    DELETE FROM t2dup;\n    INSERT INTO t2(a) SELECT 1 FROM t1 LIMIT 1;\n    INSERT INTO t2(b) SELECT 987 FROM t1 LIMIT 1;\n    INSERT INTO t2(c) SELECT 876 FROM t1 LIMIT 1;\n    SELECT * FROM t2dup;\n  }\n} {1 b c -1 987 c -1 b 876}\n\n# Test for proper detection of malformed WHEN clauses on INSERT triggers.\n#\ndo_test insert3-3.1 {\n  execsql {\n    CREATE TABLE t3(a,b,c);\n    CREATE TRIGGER t3r1 BEFORE INSERT on t3 WHEN nosuchcol BEGIN\n      SELECT 'illegal WHEN clause';\n    END;\n  }\n} {}\ndo_test insert3-3.2 {\n  catchsql {\n    INSERT INTO t3 VALUES(1,2,3)\n  }\n} {1 {no such column: nosuchcol}}\ndo_test insert3-3.3 {\n  execsql {\n    CREATE TABLE t4(a,b,c);\n    CREATE TRIGGER t4r1 AFTER INSERT on t4 WHEN nosuchcol BEGIN\n      SELECT 'illegal WHEN clause';\n    END;\n  }\n} {}\ndo_test insert3-3.4 {\n  catchsql {\n    INSERT INTO t4 VALUES(1,2,3)\n  }\n} {1 {no such column: nosuchcol}}\n\n} ;# ifcapable {trigger}\n\n# Tests for the INSERT INTO ... DEFAULT VALUES construct\n#\ndo_test insert3-3.5 {\n  execsql {\n    CREATE TABLE t5(\n      a INTEGER PRIMARY KEY,\n      b DEFAULT 'xyz'\n    );\n    INSERT INTO t5 DEFAULT VALUES;\n    SELECT * FROM t5;\n  }\n} {1 xyz}\ndo_test insert3-3.6 {\n  execsql {\n    INSERT INTO t5 DEFAULT VALUES;\n    SELECT * FROM t5;\n  }\n} {1 xyz 2 xyz}\n\nifcapable bloblit {\n  do_test insert3-3.7 {\n    execsql {\n      CREATE TABLE t6(x,y DEFAULT 4.3, z DEFAULT x'6869');\n      INSERT INTO t6 DEFAULT VALUES;\n      SELECT * FROM t6;\n    }\n  } {{} 4.3 hi}\n}\n\nforeach tab [db eval {SELECT name FROM sqlite_master WHERE type = 'table'}] {\n  db eval \"DROP TABLE $tab\"\n}\ndb close\nsqlite3 db test.db\n\n#-------------------------------------------------------------------------\n# While developing tests for a different feature (savepoint) the following\n# sequence was found to cause an assert() in btree.c to fail. These\n# tests are included to ensure that that bug is fixed.\n#\ndo_test insert3-4.1 {\n  execsql { \n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(a, b);\n    BEGIN;\n    INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));\n  }\n  set r \"randstr(10,400)\"\n  for {set ii 0} {$ii < 10} {incr ii} {\n    execsql \"INSERT INTO t1 SELECT $r, $r, $r FROM t1\"\n  }\n  execsql { COMMIT }\n} {}\ndo_test insert3-4.2 {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;\n      DELETE FROM t1 WHERE rowid%2;\n      INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;\n    COMMIT;\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/insert4.test",
    "content": "# 2007 January 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the INSERT transfer optimization.\n#\n# $Id: insert4.test,v 1.10 2008/01/21 16:22:46 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix insert4\n\nifcapable !view||!subquery {\n  finish_test\n  return\n}\n\n# The sqlite3_xferopt_count variable is incremented whenever the \n# insert transfer optimization applies.\n#\n# This procedure runs a test to see if the sqlite3_xferopt_count is\n# set to N.\n#\nproc xferopt_test {testname N} {\n  do_test $testname {set ::sqlite3_xferopt_count} $N\n}\n\n# Create tables used for testing.\n#\nexecsql {\n  PRAGMA legacy_file_format = 0;\n  CREATE TABLE t1(a int, b int, check(b>a));\n  CREATE TABLE t2(x int, y int);\n  CREATE VIEW v2 AS SELECT y, x FROM t2;\n  CREATE TABLE t3(a int, b int);\n}\n\n# Ticket #2252.  Make sure the an INSERT from identical tables\n# does not violate constraints.\n#\ndo_test insert4-1.1 {\n  set sqlite3_xferopt_count 0\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(9,1);\n  }\n  catchsql {\n    INSERT INTO t1 SELECT * FROM t2;\n  }\n} {1 {CHECK constraint failed: t1}}\nxferopt_test insert4-1.2 0\ndo_test insert4-1.3 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {}\n\n# Tests to make sure that the transfer optimization is not occurring\n# when it is not a valid optimization.\n#\n# The SELECT must be against a real table.\ndo_test insert4-2.1.1 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 SELECT 4, 8;\n    SELECT * FROM t1;\n  }\n} {4 8}\nxferopt_test insert4-2.1.2  0\ndo_test insert4-2.2.1 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 SELECT * FROM v2;\n    SELECT * FROM t1;\n  }\n} {0 {1 9}}\nxferopt_test insert4-2.2.2 0\n\n# Do not run the transfer optimization if there is a LIMIT clause\n#\ndo_test insert4-2.3.1 {\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(9,1);\n    INSERT INTO t2 SELECT y, x FROM t2;\n    INSERT INTO t3 SELECT * FROM t2 LIMIT 1;\n    SELECT * FROM t3;\n  }\n} {9 1}\nxferopt_test insert4-2.3.2  0\ndo_test insert4-2.3.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 SELECT * FROM t2 LIMIT 1;\n    SELECT * FROM t1;\n  }\n} {1 {CHECK constraint failed: t1}}\nxferopt_test insert4-2.3.4 0\n\n# Do not run the transfer optimization if there is a DISTINCT\n#\ndo_test insert4-2.4.1 {\n  execsql {\n    DELETE FROM t3;\n    INSERT INTO t3 SELECT DISTINCT * FROM t2;\n    SELECT * FROM t3;\n  }\n} {9 1 1 9}\nxferopt_test insert4-2.4.2 0\ndo_test insert4-2.4.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 SELECT DISTINCT * FROM t2;\n  }\n} {1 {CHECK constraint failed: t1}}\nxferopt_test insert4-2.4.4 0\n\n# The following procedure constructs two tables then tries to transfer\n# data from one table to the other.  Checks are made to make sure the\n# transfer is successful and that the transfer optimization was used or\n# not, as appropriate.\n#\n#     xfer_check TESTID  XFER-USED   INIT-DATA   DEST-SCHEMA   SRC-SCHEMA \n#\n# The TESTID argument is the symbolic name for this test.  The XFER-USED\n# argument is true if the transfer optimization should be employed and\n# false if not.  INIT-DATA is a single row of data that is to be \n# transfered.  DEST-SCHEMA and SRC-SCHEMA are table declarations for\n# the destination and source tables.\n#\nproc xfer_check {testid xferused initdata destschema srcschema} {\n  execsql \"CREATE TABLE dest($destschema)\"\n  execsql \"CREATE TABLE src($srcschema)\"\n  execsql \"INSERT INTO src VALUES([join $initdata ,])\"\n  set ::sqlite3_xferopt_count 0\n  do_test $testid.1 {\n    execsql {\n      INSERT INTO dest SELECT * FROM src;\n      SELECT * FROM dest;\n    }\n  } $initdata\n  do_test $testid.2 {\n    set ::sqlite3_xferopt_count\n  } $xferused\n  execsql {\n    DROP TABLE dest;\n    DROP TABLE src;\n  }\n}\n\n\n# Do run the transfer optimization if tables have identical\n# CHECK constraints.\n#\nxfer_check insert4-3.1 1 {1 9} \\\n    {a int, b int CHECK(b>a)} \\\n    {x int, y int CHECK(y>x)}\nxfer_check insert4-3.2 1 {1 9} \\\n    {a int, b int CHECK(b>a)} \\\n    {x int CHECK(y>x), y int}\n\n# Do run the transfer optimization if the destination table lacks\n# any CHECK constraints regardless of whether or not there are CHECK\n# constraints on the source table.\n#\nxfer_check insert4-3.3 1 {1 9} \\\n    {a int, b int} \\\n    {x int, y int CHECK(y>x)}\n\n# Do run the transfer optimization if the destination table omits\n# NOT NULL constraints that the source table has.\n#\nxfer_check insert4-3.4 0 {1 9} \\\n    {a int, b int CHECK(b>a)} \\\n    {x int, y int}\n\n# Do not run the optimization if the destination has NOT NULL\n# constraints that the source table lacks.\n#\nxfer_check insert4-3.5 0 {1 9} \\\n    {a int, b int NOT NULL} \\\n    {x int, y int}\nxfer_check insert4-3.6 0 {1 9} \\\n    {a int, b int NOT NULL} \\\n    {x int NOT NULL, y int}\nxfer_check insert4-3.7 0 {1 9} \\\n    {a int NOT NULL, b int NOT NULL} \\\n    {x int NOT NULL, y int}\nxfer_check insert4-3.8 0 {1 9} \\\n    {a int NOT NULL, b int} \\\n    {x int, y int}\n\n\n# Do run the transfer optimization if the destination table and\n# source table have the same NOT NULL constraints or if the \n# source table has extra NOT NULL constraints.\n#\nxfer_check insert4-3.9 1 {1 9} \\\n    {a int, b int} \\\n    {x int NOT NULL, y int}\nxfer_check insert4-3.10 1 {1 9} \\\n    {a int, b int} \\\n    {x int NOT NULL, y int NOT NULL}\nxfer_check insert4-3.11 1 {1 9} \\\n    {a int NOT NULL, b int} \\\n    {x int NOT NULL, y int NOT NULL}\nxfer_check insert4-3.12 1 {1 9} \\\n    {a int, b int NOT NULL} \\\n    {x int NOT NULL, y int NOT NULL}\n\n# Do not run the optimization if any corresponding table\n# columns have different affinities.\n#\nxfer_check insert4-3.20 0 {1 9} \\\n    {a text, b int} \\\n    {x int, b int}\nxfer_check insert4-3.21 0 {1 9} \\\n    {a int, b int} \\\n    {x text, b int}\n\n# \"int\" and \"integer\" are equivalent so the optimization should\n# run here.\n#\nxfer_check insert4-3.22 1 {1 9} \\\n    {a int, b int} \\\n    {x integer, b int}\n\n# Ticket #2291.\n#\n\ndo_test insert4-4.1a {\n  execsql {CREATE TABLE t4(a, b, UNIQUE(a,b))}\n} {}\nifcapable vacuum {\n  do_test insert4-4.1b {\n    execsql {\n      INSERT INTO t4 VALUES(NULL,0);\n      INSERT INTO t4 VALUES(NULL,1);\n      INSERT INTO t4 VALUES(NULL,1);\n      VACUUM;   \n    }\n  } {}\n}\n\n# Check some error conditions:\n#\ndo_test insert4-5.1 {\n  # Table does not exist.\n  catchsql { INSERT INTO t2 SELECT a, b FROM nosuchtable }\n} {1 {no such table: nosuchtable}}\ndo_test insert4-5.2 {\n  # Number of columns does not match.\n  catchsql { \n    CREATE TABLE t5(a, b, c);\n    INSERT INTO t4 SELECT * FROM t5;\n  }\n} {1 {table t4 has 2 columns but 3 values were supplied}}\n\ndo_test insert4-6.1 {\n  set ::sqlite3_xferopt_count 0\n  execsql {\n    CREATE INDEX t2_i2 ON t2(x, y COLLATE nocase); \n    CREATE INDEX t2_i1 ON t2(x ASC, y DESC);\n    CREATE INDEX t3_i1 ON t3(a, b);\n    INSERT INTO t2 SELECT * FROM t3;\n  }\n  set ::sqlite3_xferopt_count\n} {0}\ndo_test insert4-6.2 {\n  set ::sqlite3_xferopt_count 0\n  execsql {\n    DROP INDEX t2_i2;\n    INSERT INTO t2 SELECT * FROM t3;\n  }\n  set ::sqlite3_xferopt_count\n} {0}\ndo_test insert4-6.3 {\n  set ::sqlite3_xferopt_count 0\n  execsql {\n    DROP INDEX t2_i1;\n    CREATE INDEX t2_i1 ON t2(x ASC, y ASC);\n    INSERT INTO t2 SELECT * FROM t3;\n  }\n  set ::sqlite3_xferopt_count\n} {1}\ndo_test insert4-6.4 {\n  set ::sqlite3_xferopt_count 0\n  execsql {\n    DROP INDEX t2_i1;\n    CREATE INDEX t2_i1 ON t2(x ASC, y COLLATE RTRIM);\n    INSERT INTO t2 SELECT * FROM t3;\n  }\n  set ::sqlite3_xferopt_count\n} {0}\n\n\ndo_test insert4-6.5 {\n  execsql {\n    CREATE TABLE t6a(x CHECK( x<>'abc' ));\n    INSERT INTO t6a VALUES('ABC');\n    SELECT * FROM t6a;\n  }\n} {ABC}\ndo_test insert4-6.6 {\n  execsql {\n    CREATE TABLE t6b(x CHECK( x<>'abc' COLLATE nocase ));\n  }\n  catchsql {\n    INSERT INTO t6b SELECT * FROM t6a;\n  }\n} {1 {CHECK constraint failed: t6b}}\ndo_test insert4-6.7 {\n  execsql {\n    DROP TABLE t6b;\n    CREATE TABLE t6b(x CHECK( x COLLATE nocase <>'abc' ));\n  }\n  catchsql {\n    INSERT INTO t6b SELECT * FROM t6a;\n  }\n} {1 {CHECK constraint failed: t6b}}\n\n# Ticket [6284df89debdfa61db8073e062908af0c9b6118e]\n# Disable the xfer optimization if the destination table contains\n# a foreign key constraint\n#\nifcapable foreignkey {\n  do_test insert4-7.1 {\n    set ::sqlite3_xferopt_count 0\n    execsql {\n      CREATE TABLE t7a(x INTEGER PRIMARY KEY); INSERT INTO t7a VALUES(123);\n      CREATE TABLE t7b(y INTEGER REFERENCES t7a);\n      CREATE TABLE t7c(z INT);  INSERT INTO t7c VALUES(234);\n      INSERT INTO t7b SELECT * FROM t7c;\n      SELECT * FROM t7b;\n    }\n  } {234}\n  do_test insert4-7.2 {\n    set ::sqlite3_xferopt_count\n  } {1}\n  do_test insert4-7.3 {\n    set ::sqlite3_xferopt_count 0\n    execsql {\n      DELETE FROM t7b;\n      PRAGMA foreign_keys=ON;\n    }\n    catchsql {\n      INSERT INTO t7b SELECT * FROM t7c;\n    }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test insert4-7.4 {\n    execsql {SELECT * FROM t7b}\n  } {}\n  do_test insert4-7.5 {\n    set ::sqlite3_xferopt_count\n  } {0}\n  do_test insert4-7.6 {\n    set ::sqlite3_xferopt_count 0\n    execsql {\n      DELETE FROM t7b; DELETE FROM t7c;\n      INSERT INTO t7c VALUES(123);\n      INSERT INTO t7b SELECT * FROM t7c;\n      SELECT * FROM t7b;\n    }\n  } {123}\n  do_test insert4-7.7 {\n    set ::sqlite3_xferopt_count\n  } {0}\n  do_test insert4-7.7 {\n    set ::sqlite3_xferopt_count 0\n    execsql {\n      PRAGMA foreign_keys=OFF;\n      DELETE FROM t7b;\n      INSERT INTO t7b SELECT * FROM t7c;\n      SELECT * FROM t7b;\n    }\n  } {123}\n  do_test insert4-7.8 {\n    set ::sqlite3_xferopt_count\n  } {1}\n}\n\n# Ticket [676bc02b87176125635cb174d110b431581912bb]\n# Make sure INTEGER PRIMARY KEY ON CONFLICT ... works with the xfer\n# optimization.\n#\ndo_test insert4-8.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT REPLACE, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.2 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);\n    CREATE TABLE t2(x, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.3 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT IGNORE, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 2}\ndo_test insert4-8.4 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);\n    CREATE TABLE t2(x, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 2}\ndo_test insert4-8.5 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT FAIL, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT FAIL, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(-99,100);\n    INSERT INTO t2 VALUES(1,3);\n    SELECT * FROM t1;\n  }\n  catchsql {\n    INSERT INTO t1 SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test insert4-8.6 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {-99 100 1 2} \ndo_test insert4-8.7 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ABORT, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ABORT, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(-99,100);\n    INSERT INTO t2 VALUES(1,3);\n    SELECT * FROM t1;\n  }\n  catchsql {\n    INSERT INTO t1 SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test insert4-8.8 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {1 2} \ndo_test insert4-8.9 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t2 VALUES(-99,100);\n    INSERT INTO t2 VALUES(1,3);\n    SELECT * FROM t1;\n  }\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(2,3);\n    INSERT INTO t1 SELECT * FROM t2;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test insert4-8.10 {\n  catchsql {COMMIT}\n} {1 {cannot commit - no transaction is active}}\ndo_test insert4-8.11 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {1 2} \n\ndo_test insert4-8.21 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT REPLACE, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT REPLACE, y);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.22 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT IGNORE, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT IGNORE, y);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.23 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ABORT, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ABORT, y);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.24 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT FAIL, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT FAIL, y);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\ndo_test insert4-8.25 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, b);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY ON CONFLICT ROLLBACK, y);\n    INSERT INTO t2 VALUES(1,3);\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {1 3}\n\ndo_catchsql_test insert4-9.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1(x) VALUES(5 COLLATE xyzzy) UNION SELECT 0;\n} {1 {no such collation sequence: xyzzy}}\n\n#-------------------------------------------------------------------------\n# Check that running an integrity-check does not disable the xfer \n# optimization for tables with CHECK constraints.\n#\ndo_execsql_test 10.1 {\n  CREATE TABLE t8(\n    rid INTEGER,\n    pid INTEGER,\n    mid INTEGER,\n    px INTEGER DEFAULT(0) CHECK(px IN(0, 1))\n  );\n  CREATE TEMP TABLE x(\n    rid INTEGER,\n    pid INTEGER,\n    mid INTEGER,\n    px INTEGER DEFAULT(0) CHECK(px IN(0, 1))\n  );\n}\ndo_test 10.2 {\n  set sqlite3_xferopt_count 0\n  execsql { INSERT INTO x SELECT * FROM t8 }\n  set sqlite3_xferopt_count\n} {1}\n\ndo_test 10.3 {\n  execsql { PRAGMA integrity_check }\n  set sqlite3_xferopt_count 0\n  execsql { INSERT INTO x     SELECT * FROM t8 }\n  set sqlite3_xferopt_count\n} {1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/insert5.test",
    "content": "# 2007 November 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file ensure that a temporary table is used\n# when required by an \"INSERT INTO ... SELECT ...\" statement.\n#\n# $Id: insert5.test,v 1.5 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\n# Return true if the compilation of the sql passed as an argument \n# includes the opcode OpenEphemeral. An \"INSERT INTO ... SELECT\"\n# statement includes such an opcode if a temp-table is used\n# to store intermediate results.\n# \nproc uses_temp_table {sql} {\n  return [expr {[lsearch [execsql \"EXPLAIN $sql\"] OpenEphemeral]>=0}]\n}\n\n# Construct the sample database.\n#\ndo_test insert5-1.0 {\n  forcedelete test2.db test2.db-journal\n  execsql {\n    CREATE TABLE MAIN(Id INTEGER, Id1 INTEGER); \n    CREATE TABLE B(Id INTEGER, Id1 INTEGER); \n    CREATE VIEW v1 AS SELECT * FROM B;\n    CREATE VIEW v2 AS SELECT * FROM MAIN;\n    INSERT INTO MAIN(Id,Id1) VALUES(2,3); \n    INSERT INTO B(Id,Id1) VALUES(2,3); \n  }\n} {}\n\n# Run the query.\n#\nifcapable compound {\n  do_test insert5-1.1 {\n    execsql {\n      INSERT INTO B \n        SELECT * FROM B UNION ALL \n        SELECT * FROM MAIN WHERE exists (select * FROM B WHERE B.Id = MAIN.Id);\n      SELECT * FROM B;\n    }\n  } {2 3 2 3 2 3}\n} else {\n  do_test insert5-1.1 {\n    execsql {\n      INSERT INTO B SELECT * FROM B;\n      INSERT INTO B\n        SELECT * FROM MAIN WHERE exists (select * FROM B WHERE B.Id = MAIN.Id);\n      SELECT * FROM B;\n    }\n  } {2 3 2 3 2 3}\n}\ndo_test insert5-2.1 {\n  uses_temp_table { INSERT INTO b SELECT * FROM main }\n} {0}\ndo_test insert5-2.2 {\n  uses_temp_table { INSERT INTO b SELECT * FROM b }\n} {1}\ndo_test insert5-2.3 {\n  uses_temp_table { INSERT INTO b SELECT (SELECT id FROM b), id1 FROM main }\n} {1}\ndo_test insert5-2.4 {\n  uses_temp_table { INSERT INTO b SELECT id1, (SELECT id FROM b) FROM main }\n} {1}\ndo_test insert5-2.5 {\n  uses_temp_table { \n    INSERT INTO b \n      SELECT * FROM main WHERE id = (SELECT id1 FROM b WHERE main.id = b.id) }\n} {1}\ndo_test insert5-2.6 {\n  uses_temp_table { INSERT INTO b SELECT * FROM v1 }\n} {1}\ndo_test insert5-2.7 {\n  uses_temp_table { INSERT INTO b SELECT * FROM v2 }\n} {0}\ndo_test insert5-2.8 {\n  uses_temp_table { \n    INSERT INTO b \n    SELECT * FROM main WHERE id > 10 AND max(id1, (SELECT id FROM b)) > 10;\n  }\n} {1}\n\n# UPDATE: Using a column from the outer query (main.id) in the GROUP BY\n# or ORDER BY of a sub-query is no longer supported.\n#\n# do_test insert5-2.9 {\n#   uses_temp_table { \n#     INSERT INTO b \n#     SELECT * FROM main \n#     WHERE id > 10 AND (SELECT count(*) FROM v2 GROUP BY main.id)\n#   }\n# } {}\ndo_test insert5-2.9 {\n  catchsql { \n    INSERT INTO b \n    SELECT * FROM main \n    WHERE id > 10 AND (SELECT count(*) FROM v2 GROUP BY main.id)\n  }\n} {1 {no such column: main.id}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/instr.test",
    "content": "# 2012 October 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the built-in INSTR() functions.\n#\n# EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first\n# occurrence of string Y within string X and returns the number of prior\n# characters plus 1, or 0 if Y is nowhere found within X.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table to work with.\n#\ndo_test instr-1.1 {\n  db eval {SELECT instr('abcdefg','a');}\n} {1}\ndo_test instr-1.2 {\n  db eval {SELECT instr('abcdefg','b');}\n} {2}\ndo_test instr-1.3 {\n  db eval {SELECT instr('abcdefg','c');}\n} {3}\ndo_test instr-1.4 {\n  db eval {SELECT instr('abcdefg','d');}\n} {4}\ndo_test instr-1.5 {\n  db eval {SELECT instr('abcdefg','e');}\n} {5}\ndo_test instr-1.6 {\n  db eval {SELECT instr('abcdefg','f');}\n} {6}\ndo_test instr-1.7 {\n  db eval {SELECT instr('abcdefg','g');}\n} {7}\ndo_test instr-1.8 {\n  db eval {SELECT instr('abcdefg','h');}\n} {0}\ndo_test instr-1.9 {\n  db eval {SELECT instr('abcdefg','abcdefg');}\n} {1}\ndo_test instr-1.10 {\n  db eval {SELECT instr('abcdefg','abcdefgh');}\n} {0}\ndo_test instr-1.11 {\n  db eval {SELECT instr('abcdefg','bcdefg');}\n} {2}\ndo_test instr-1.12 {\n  db eval {SELECT instr('abcdefg','bcdefgh');}\n} {0}\ndo_test instr-1.13 {\n  db eval {SELECT instr('abcdefg','cdefg');}\n} {3}\ndo_test instr-1.14 {\n  db eval {SELECT instr('abcdefg','cdefgh');}\n} {0}\ndo_test instr-1.15 {\n  db eval {SELECT instr('abcdefg','defg');}\n} {4}\ndo_test instr-1.16 {\n  db eval {SELECT instr('abcdefg','defgh');}\n} {0}\ndo_test instr-1.17 {\n  db eval {SELECT instr('abcdefg','efg');}\n} {5}\ndo_test instr-1.18 {\n  db eval {SELECT instr('abcdefg','efgh');}\n} {0}\ndo_test instr-1.19 {\n  db eval {SELECT instr('abcdefg','fg');}\n} {6}\ndo_test instr-1.20 {\n  db eval {SELECT instr('abcdefg','fgh');}\n} {0}\ndo_test instr-1.21 {\n  db eval {SELECT coalesce(instr('abcdefg',NULL),'nil');}\n} {nil}\ndo_test instr-1.22 {\n  db eval {SELECT coalesce(instr(NULL,'x'),'nil');}\n} {nil}\ndo_test instr-1.23 {\n  db eval {SELECT instr(12345,34);}\n} {3}\ndo_test instr-1.24 {\n  db eval {SELECT instr(123456.78,34);}\n} {3}\ndo_test instr-1.25 {\n  db eval {SELECT instr(123456.78,x'3334');}\n} {3}\ndo_test instr-1.26 {\n  db eval {SELECT instr('äbcdefg','efg');}\n} {5}\ndo_test instr-1.27 {\n  db eval {SELECT instr('€xyzzy','xyz');}\n} {2}\ndo_test instr-1.28 {\n  db eval {SELECT instr('abc€xyzzy','xyz');}\n} {5}\ndo_test instr-1.29 {\n  db eval {SELECT instr('abc€xyzzy','€xyz');}\n} {4}\ndo_test instr-1.30 {\n  db eval {SELECT instr('abc€xyzzy','c€xyz');}\n} {3}\ndo_test instr-1.31 {\n  db eval {SELECT instr(x'0102030405',x'01');}\n} {1}\ndo_test instr-1.32 {\n  db eval {SELECT instr(x'0102030405',x'02');}\n} {2}\ndo_test instr-1.33 {\n  db eval {SELECT instr(x'0102030405',x'03');}\n} {3}\ndo_test instr-1.34 {\n  db eval {SELECT instr(x'0102030405',x'04');}\n} {4}\ndo_test instr-1.35 {\n  db eval {SELECT instr(x'0102030405',x'05');}\n} {5}\ndo_test instr-1.36 {\n  db eval {SELECT instr(x'0102030405',x'06');}\n} {0}\ndo_test instr-1.37 {\n  db eval {SELECT instr(x'0102030405',x'0102030405');}\n} {1}\ndo_test instr-1.38 {\n  db eval {SELECT instr(x'0102030405',x'02030405');}\n} {2}\ndo_test instr-1.39 {\n  db eval {SELECT instr(x'0102030405',x'030405');}\n} {3}\ndo_test instr-1.40 {\n  db eval {SELECT instr(x'0102030405',x'0405');}\n} {4}\ndo_test instr-1.41 {\n  db eval {SELECT instr(x'0102030405',x'0506');}\n} {0}\ndo_test instr-1.42 {\n  db eval {SELECT instr(x'0102030405',x'');}\n} {1}\ndo_test instr-1.43 {\n  db eval {SELECT instr(x'',x'');}\n} {1}\ndo_test instr-1.44 {\n  db eval {SELECT instr('','');}\n} {1}\ndo_test instr-1.45 {\n  db eval {SELECT instr('abcdefg','');}\n} {1}\nunset -nocomplain longstr\nset longstr abcdefghijklmonpqrstuvwxyz\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\nappend longstr $longstr\n# puts [string length $longstr]\nappend longstr Xabcde\ndo_test instr-1.46 {\n  db eval {SELECT instr($longstr,'X');}\n} {106497}\ndo_test instr-1.47 {\n  db eval {SELECT instr($longstr,'Y');}\n} {0}\ndo_test instr-1.48 {\n  db eval {SELECT instr($longstr,'Xa');}\n} {106497}\ndo_test instr-1.49 {\n  db eval {SELECT instr($longstr,'zXa');}\n} {106496}\nset longstr [string map {a ä} $longstr]\ndo_test instr-1.50 {\n  db eval {SELECT instr($longstr,'X');}\n} {106497}\ndo_test instr-1.51 {\n  db eval {SELECT instr($longstr,'Y');}\n} {0}\ndo_test instr-1.52 {\n  db eval {SELECT instr($longstr,'Xä');}\n} {106497}\ndo_test instr-1.53 {\n  db eval {SELECT instr($longstr,'zXä');}\n} {106496}\ndo_test instr-1.54 {\n  db eval {SELECT instr(x'78c3a4e282ac79','x');}\n} {1}\ndo_test instr-1.55 {\n  db eval {SELECT instr(x'78c3a4e282ac79','y');}\n} {4}\n\n# EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then\n# instr(X,Y) returns one more than the number bytes prior to the first\n# occurrence of Y, or 0 if Y does not occur anywhere within X.\n#\ndo_test instr-1.56.1 {\n  db eval {SELECT instr(x'78c3a4e282ac79',x'79');}\n} {7}\ndo_test instr-1.56.2 {\n  db eval {SELECT instr(x'78c3a4e282ac79',x'7a');}\n} {0}\ndo_test instr-1.56.3 {\n  db eval {SELECT instr(x'78c3a4e282ac79',x'78');}\n} {1}\ndo_test instr-1.56.3 {\n  db eval {SELECT instr(x'78c3a4e282ac79',x'a4');}\n} {3}\n\n# EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are\n# non-NULL and are not BLOBs then both are interpreted as strings.\n#\ndo_test instr-1.57.1 {\n  db eval {SELECT instr('xä€y',x'79');}\n} {4}\ndo_test instr-1.57.2 {\n  db eval {SELECT instr('xä€y',x'a4');}\n} {0}\ndo_test instr-1.57.3 {\n  db eval {SELECT instr(x'78c3a4e282ac79','y');}\n} {4}\n\n# EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y)\n# then the result is NULL.\n#\ndo_execsql_test instr-1.60 {\n  SELECT coalesce(instr(NULL,'abc'), 999);\n} {999}\ndo_execsql_test instr-1.61 {\n  SELECT coalesce(instr('abc',NULL), 999);\n} {999}\ndo_execsql_test instr-1.62 {\n  SELECT coalesce(instr(NULL,NULL), 999);\n} {999}\n\ndo_execsql_test instr-1.63 {\n  SELECT instr(X'', 'abc')\n} 0\ndo_execsql_test instr-1.64 {\n  CREATE TABLE x1(a, b);\n  INSERT INTO x1 VALUES(X'', 'abc');\n  SELECT instr(a, b) FROM x1;\n} 0\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/instrfault.test",
    "content": "# 2016 November 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing OOM error handling within the built-in \n# INSTR() function.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix instrfault\n\n# Use big NEEDLE and HAYSTACK strings. Strings so large they cannot\n# use lookaside buffers.\n#\nset ::NEEDLE [string repeat \"abcdefghijklmnopqrstuvwxyz\" 10]\nset ::HAYSTACK \"[string repeat 123 10]$NEEDLE[string repeat 456 10]\"\n\nforeach {enc} {\n  utf8\n  utf16\n} {\n  reset_db\n  sqlite3_db_config_lookaside db 0 0 0\n\n  execsql \"PRAGMA encoding = $enc\"\n  do_execsql_test 1.$enc.1 {\n    CREATE TABLE t1(n, h);\n    INSERT INTO t1 VALUES($::NEEDLE, $::HAYSTACK);\n  } {}\n\n  do_faultsim_test 1.$enc.1 -faults oom-t* -prep {\n    execsql { SELECT instr(h, n) FROM t1 }\n  } -body {\n    execsql { SELECT instr(h, n) FROM t1 }\n  } -test {\n    faultsim_test_result {0 31}\n  }\n\n  do_faultsim_test 1.$enc.2 -faults oom-t* -prep {\n    execsql { SELECT instr($::HAYSTACK, $::NEEDLE) FROM t1 }\n  } -body {\n    execsql { SELECT instr($::HAYSTACK, $::NEEDLE) FROM t1 }\n  } -test {\n    faultsim_test_result {0 31}\n  }\n\n  do_faultsim_test 1.$enc.3 -faults oom-t* -prep {\n    set ::stmt [sqlite3_prepare_v2 db \"SELECT instr(?, ?)\" -1 dummy]\n    sqlite3_bind_text $::stmt 1 $::HAYSTACK [string length $::HAYSTACK]\n    sqlite3_bind_text $::stmt 2 $::NEEDLE [string length $::NEEDLE]\n  } -body {\n    set rc [sqlite3_step $::stmt]\n    if {$rc==\"SQLITE_NOMEM\"} { error \"out of memory\" }\n    sqlite3_column_int $::stmt 0\n  } -test {\n    faultsim_test_result {0 31}\n    sqlite3_finalize $::stmt\n  }\n\n  do_faultsim_test 1.$enc.4 -faults oom-t* -prep {\n    set ::stmt [sqlite3_prepare_v2 db \"SELECT instr(?, ?)\" -1 dummy]\n    sqlite3_bind_blob $::stmt 1 $::HAYSTACK [string length $::HAYSTACK]\n    sqlite3_bind_text $::stmt 2 $::NEEDLE [string length $::NEEDLE]\n  } -body {\n    set rc [sqlite3_step $::stmt]\n    if {$rc==\"SQLITE_NOMEM\"} { error \"out of memory\" }\n    sqlite3_column_int $::stmt 0\n  } -test {\n    faultsim_test_result {0 31}\n    sqlite3_finalize $::stmt\n  }\n\n  do_execsql_test 1.$enc.5.0 {\n    CREATE TABLE h1(a, b);\n    INSERT INTO h1 VALUES('abcdefg%200hijkl', randomblob(200));\n    INSERT INTO h1 SELECT b, a FROM h1;\n  }\n  do_faultsim_test 1.$enc.5 -faults oom-t* -body {\n    execsql { SELECT rowid FROM h1 WHERE instr(a,b) }\n  } -test {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/intarray.test",
    "content": "# 2009 November 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the \"intarray\" object implemented\n# in test_intarray.c.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  return\n}\n\ndo_test intarray-1.0 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  }\n  for {set i 1} {$i<=999} {incr i} {\n    set b [format {x%03d} $i]\n    db eval {INSERT INTO t1(a,b) VALUES($i,$b)}\n  }\n  db eval {\n    CREATE TABLE t2(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t2 SELECT * FROM t1;\n    SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a\n  }\n} {x012 x034 x056 x078}\n\ndo_test intarray-1.1 {\n  set ia1 [sqlite3_intarray_create db ia1]\n  set ia2 [sqlite3_intarray_create db ia2]\n  set ia3 [sqlite3_intarray_create db ia3]\n  set ia4 [sqlite3_intarray_create db ia4]\n  db eval {\n    SELECT type, name FROM temp.sqlite_master\n     ORDER BY name\n  }\n} {table ia1 table ia2 table ia3 table ia4}\n\ndo_test intarray-1.2 {\n  db eval {\n    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a\n  }\n} {}\n\ndo_test intarray-1.3 {\n  sqlite3_intarray_bind $ia3 45 123 678\n  db eval {\n    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a\n  }\n} {x045 x123 x678}\n\ndo_test intarray-1.4 {\n  db eval {\n    SELECT count(b) FROM t1 WHERE a NOT IN ia3 ORDER BY a\n  }\n} {996}\n\n#explain {SELECT b FROM t1 WHERE a NOT IN ia3}\n\ndo_test intarray-1.5 {\n  set cmd sqlite3_intarray_bind\n  lappend cmd $ia1\n  for {set i 1} {$i<=999} {incr i} {\n    lappend cmd $i\n    lappend cmd [expr {$i+1000}]\n    lappend cmd [expr {$i+2000}]\n  }\n  eval $cmd\n  db eval {\n    REPLACE INTO t1 SELECT * FROM t2;\n    DELETE FROM t1 WHERE a NOT IN ia1;\n    SELECT count(*) FROM t1;\n  }\n} {999}\n\ndo_test intarray-1.6 {\n  db eval {\n    DELETE FROM t1 WHERE a IN ia1;\n    SELECT count(*) FROM t1;\n  }\n} {0}\n\ndo_test intarray-2.1 {\n  db eval {\n    CREATE TEMP TABLE t3(p,q);\n    INSERT INTO t3 SELECT * FROM t2;\n    SELECT count(*) FROM t3 WHERE p IN ia1;\n  }\n} {999}\n\ndo_test intarray-2.2 {\n  set ia5 [sqlite3_intarray_create db ia5]\n  db eval {\n    SELECT count(*) FROM t3 WHERE p IN ia1;\n  }\n} {999}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/interrupt.test",
    "content": "# 2004 Feb 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the sqlite_interrupt() API.\n#\n# $Id: interrupt.test,v 1.16 2008/01/16 17:46:38 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset DB [sqlite3_connection_pointer db]\n\n# This routine attempts to execute the sql in $sql.  It triggers an\n# interrupt at progressively later and later points during the processing\n# and checks to make sure SQLITE_INTERRUPT is returned.  Eventually,\n# the routine completes successfully.\n#\nproc interrupt_test {testid sql result {initcnt 0}} {\n  set orig_sum [cksum]\n  set i $initcnt\n  while 1 {\n    incr i\n    set ::sqlite_interrupt_count $i\n    do_test $testid.$i.1 [format {\n      set ::r [catchsql %s]\n      set ::code [db errorcode]\n      expr {$::code==0 || $::code==9}\n    } [list $sql]] 1\n    if {$::code==9} {\n      do_test $testid.$i.2 {\n        cksum\n      } $orig_sum\n    } else {\n      do_test $testid.$i.99 {\n        set ::r\n      } [list 0 $result]\n      break\n    }\n  }\n  set ::sqlite_interrupt_count 0\n}\n\ndo_test interrupt-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    SELECT name FROM sqlite_master;\n  }\n} {t1}\ninterrupt_test interrupt-1.2 {DROP TABLE t1} {}\ndo_test interrupt-1.3 {\n  execsql {\n    SELECT name FROM sqlite_master;\n  }\n} {}\nintegrity_check interrupt-1.4\n\ndo_test interrrupt-2.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,randstr(300,400));\n    INSERT INTO t1 SELECT a+1, randstr(300,400) FROM t1;\n    INSERT INTO t1 SELECT a+2, a || '-' || b FROM t1;\n    INSERT INTO t1 SELECT a+4, a || '-' || b FROM t1;\n    INSERT INTO t1 SELECT a+8, a || '-' || b FROM t1;\n    INSERT INTO t1 SELECT a+16, a || '-' || b FROM t1;\n    INSERT INTO t1 SELECT a+32, a || '-' || b FROM t1;\n    COMMIT;\n    UPDATE t1 SET b=substr(b,-5,5);\n    SELECT count(*) from t1;\n  }\n} 64\nset origsize [file size test.db]\nset cksum [db eval {SELECT md5sum(a || b) FROM t1}]\nifcapable {vacuum} {\n  interrupt_test interrupt-2.2 {VACUUM} {} 100\n}\ndo_test interrupt-2.3 {\n  execsql {\n    SELECT md5sum(a || b) FROM t1;\n  }\n} $cksum\nifcapable {vacuum && !default_autovacuum} {\n  do_test interrupt-2.4 {\n    expr {$::origsize>[file size test.db]}\n  } 1\n}\nifcapable {explain} {\n  do_test interrupt-2.5 {\n    set sql {EXPLAIN SELECT max(a,b), a, b FROM t1}\n    execsql $sql\n    set rc [catch {db eval $sql {sqlite3_interrupt $DB}} msg]\n    lappend rc $msg\n  } {1 interrupted}\n}\nintegrity_check interrupt-2.6\n\n# Ticket #594.  If an interrupt occurs in the middle of a transaction\n# and that transaction is later rolled back, the internal schema tables do\n# not reset.\n#\n# UPDATE: Interrupting a DML statement in the middle of a transaction now\n# causes the transaction to roll back. Leaving the transaction open after\n# an SQL statement was interrupted halfway through risks database corruption.\n#\nifcapable tempdb {\n  for {set i 1} {$i<50} {incr i 5} {\n    do_test interrupt-3.$i.1 {\n      execsql {\n        BEGIN;\n        CREATE TEMP TABLE t2(x,y);\n        SELECT name FROM sqlite_temp_master;\n      }\n    } {t2}\n    do_test interrupt-3.$i.2 {\n      set ::sqlite_interrupt_count $::i\n      catchsql {\n        INSERT INTO t2 SELECT * FROM t1;\n      }\n    } {1 interrupted}\n    do_test interrupt-3.$i.3 {\n      execsql {\n        SELECT name FROM temp.sqlite_master;\n      }\n    } {}\n    do_test interrupt-3.$i.4 {\n      catchsql {\n        ROLLBACK\n      }\n    } {1 {cannot rollback - no transaction is active}}\n    do_test interrupt-3.$i.5 {\n      catchsql {SELECT name FROM sqlite_temp_master};\n      execsql {\n        SELECT name FROM temp.sqlite_master;\n      }\n    } {}\n  }\n}\n\n# There are reports of a memory leak if an interrupt occurs during\n# the beginning of a complex query - before the first callback.  We\n# will try to reproduce it here:\n#\nexecsql {\n  CREATE TABLE t2(a,b,c);\n  INSERT INTO t2 SELECT round(a/10), randstr(50,80), randstr(50,60) FROM t1;\n}\nset sql {\n  SELECT max(min(b,c)), min(max(b,c)), a FROM t2 GROUP BY a ORDER BY a;\n}\nset sqlite_interrupt_count 1000000\nexecsql $sql\nset max_count [expr {1000000-$sqlite_interrupt_count}]\nfor {set i 1} {$i<$max_count-5} {incr i 1} {\n  do_test interrupt-4.$i.1 {\n    set ::sqlite_interrupt_count $::i\n    catchsql $sql\n  } {1 interrupted}\n}\n\nif {0} {  # This doesn't work anymore since the collation factor is\n          # no longer called during schema parsing.\n# Interrupt during parsing\n#\ndo_test interrupt-5.1 {\n  proc fake_interrupt {args} {\n    db collate fake_collation no-op\n    sqlite3_interrupt db\n    return SQLITE_OK\n  }\n  db collation_needed fake_interrupt\n  catchsql {\n    CREATE INDEX fake ON fake1(a COLLATE fake_collation, b, c DESC);\n  }\n} {1 interrupt}\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/interrupt2.test",
    "content": "# 2016 Aug 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is using the sqlite_interrupt() API to \n# interrupt WAL checkpoint operations.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nset testprefix interrupt2\n\nif {[permutation]==\"journaltest\" || [permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\ndb close\ntestvfs tvfs -default 1\n\ntvfs filter xWrite\ntvfs script write_cb\n\nset ::trigger_interrupt 0\nproc write_cb {method args} {\n  set filename [lindex $args 0]\n  if {[file tail $filename]==\"test.db\" && $::trigger_interrupt} {\n    if {$::trigger_interrupt} {\n      incr ::trigger_interrupt -1\n      if {$::trigger_interrupt==0} { sqlite3_interrupt db }\n    }\n  }\n  return 0\n}\n\nsqlite3 db test.db \ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX t1a ON t1(a);\n  CREATE INDEX t1b ON t1(b);\n  PRAGMA journal_mode = wal;\n\n  WITH ii(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM ii WHERE i<1000 )\n  INSERT INTO t1 SELECT i, i FROM ii;\n} {wal}\n\nforeach idelay {\n  5\n  10\n  15\n  20\n} {\n\n  set ::trigger_interrupt $idelay\n  do_catchsql_test 1.$idelay.1 { PRAGMA wal_checkpoint; } {1 interrupted}\n  do_execsql_test  1.$idelay.2 { SELECT count(*) FROM t1 } 1000\n\n  set ::trigger_interrupt $idelay\n  do_test 1.$idelay.3 { \n    list [catch { sqlite3_wal_checkpoint_v2 db truncate } msg] $msg\n  } {1 {SQLITE_INTERRUPT - interrupted}}\n  do_execsql_test  1.$idelay.4 { SELECT count(*) FROM t1 } 1000\n}\n\n#-------------------------------------------------------------------------\n# Check that if there are other SQL statements running, a checkpoint does\n# not clear the isInterrupted flag.\n#\ndo_execsql_test 2.0 {\n  CREATE TEMP TABLE z1(a, b);\n  INSERT INTO z1 SELECT * FROM t1;\n}\n\ndo_test 2.1 {\n  set i 10\n  set res [list [catch {\n    set i 10\n    db eval {SELECT * FROM z1} {\n      incr i -1\n      if {$i==0} {\n        set ::trigger_interrupt 10\n        set cres [catch { sqlite3_wal_checkpoint_v2 db truncate } msg] \n        lappend cres $msg\n      }\n    }\n  } msg] $msg]\n\n  list $cres $res\n} {{1 {SQLITE_INTERRUPT - interrupted}} {1 interrupted}}\n\ndo_execsql_test 2.0 {\n  SELECT count(*) FROM t1\n  UNION ALL\n  SELECT count(*) FROM z1\n} {1000 1000}\n\n#-------------------------------------------------------------------------\n# Check the effect of an interrupt during sqlite3_close().\n#\ndb_save_and_close\n\ndb_restore_and_reopen\ndo_test 3.1.1 {\n  set ::trigger_interrupt 10\n  db eval { SELECT * FROM sqlite_master }\n  db close\n  set {} {}\n} {}\ndo_test 3.1.2 {\n  list [file exists test.db] [file exists test.db-wal]\n} {1 1}\n\ndb_restore_and_reopen\ndo_test 3.2.1 {\n  db eval { SELECT * FROM sqlite_master }\n  db close\n  set {} {}\n} {}\ndo_test 3.2.2 {\n  list [file exists test.db] [file exists test.db-wal]\n} {1 0}\n\n#-------------------------------------------------------------------------\n# Check the effect of an interrupt during an automatic checkpoint\n#\ndb_restore_and_reopen\ndo_test 4.0 { \n  execsql { PRAGMA wal_autocheckpoint = 10 }\n  set ::trigger_interrupt 10\n  execsql { CREATE TABLE t2(x, y) }\n} {}\n\n# The auto-checkpoint in test 4.0 should have been interrupted. So this\n# db write should cause the wal file to grow.\ndo_test 4.1 {\n  set nFrame1 [wal_frame_count test.db-wal 1024]\n  execsql { CREATE TABLE t3(x, y) }\n  set nFrame2 [wal_frame_count test.db-wal 1024]\n  expr $nFrame2 > $nFrame1\n} {1}\n\n# The auto-checkpoint in test 4.0 should not have been interrupted. So \n# this db write should not cause the wal file to grow.\ndo_test 4.2 {\n  set nFrame1 [wal_frame_count test.db-wal 1024]\n  execsql { CREATE TABLE t4(x, y) }\n  set nFrame2 [wal_frame_count test.db-wal 1024]\n  expr $nFrame2 == $nFrame1\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/intpkey.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the special processing associated\n# with INTEGER PRIMARY KEY columns.\n#\n# $Id: intpkey.test,v 1.24 2007/11/29 17:43:28 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table with a primary key and a datatype other than\n# integer\n#\ndo_test intpkey-1.0 {\n  execsql {\n    CREATE TABLE t1(a TEXT PRIMARY KEY, b, c);\n  }\n} {}\n\n# There should be an index associated with the primary key\n#\ndo_test intpkey-1.1 {\n  execsql {\n    SELECT name FROM sqlite_master\n    WHERE type='index' AND tbl_name='t1';\n  }\n} {sqlite_autoindex_t1_1}\n\n# Now create a table with an integer primary key and verify that\n# there is no associated index.\n#\ndo_test intpkey-1.2 {\n  execsql {\n    DROP TABLE t1;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    SELECT name FROM sqlite_master\n      WHERE type='index' AND tbl_name='t1';\n  }\n} {}\n\n# Insert some records into the new table.  Specify the primary key\n# and verify that the key is used as the record number.\n#\ndo_test intpkey-1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(5,'hello','world');\n  }\n  db last_insert_rowid\n} {5}\ndo_test intpkey-1.4 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {5 hello world}\ndo_test intpkey-1.5 {\n  execsql {\n    SELECT rowid, * FROM t1;\n  }\n} {5 5 hello world}\n\n# Attempting to insert a duplicate primary key should give a constraint\n# failure.\n#\ndo_test intpkey-1.6 {\n  set r [catch {execsql {\n     INSERT INTO t1 VALUES(5,'second','entry');\n  }} msg]\n  lappend r $msg\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test intpkey-1.7 {\n  execsql {\n    SELECT rowid, * FROM t1;\n  }\n} {5 5 hello world}\ndo_test intpkey-1.8 {\n  set r [catch {execsql {\n     INSERT INTO t1 VALUES(6,'second','entry');\n  }} msg]\n  lappend r $msg\n} {0 {}}\ndo_test intpkey-1.8.1 {\n  db last_insert_rowid\n} {6}\ndo_test intpkey-1.9 {\n  execsql {\n    SELECT rowid, * FROM t1;\n  }\n} {5 5 hello world 6 6 second entry}\n\n# A ROWID is automatically generated for new records that do not specify\n# the integer primary key.\n#\ndo_test intpkey-1.10 {\n  execsql {\n    INSERT INTO t1(b,c) VALUES('one','two');\n    SELECT b FROM t1 ORDER BY b;\n  }\n} {hello one second}\n\n# Try to change the ROWID for the new entry.\n#\ndo_test intpkey-1.11 {\n  execsql {\n    UPDATE t1 SET a=4 WHERE b='one';\n    SELECT * FROM t1;\n  }\n} {4 one two 5 hello world 6 second entry}\n\n# Make sure SELECT statements are able to use the primary key column\n# as an index.\n#\ndo_test intpkey-1.12.1 {\n  execsql {\n    SELECT * FROM t1 WHERE a==4;\n  }\n} {4 one two}\ndo_test intpkey-1.12.2 {\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t1 WHERE a==4;\n  }\n} {/SEARCH TABLE t1 /}\n\n# Try to insert a non-integer value into the primary key field.  This\n# should result in a data type mismatch.\n#\ndo_test intpkey-1.13.1 {\n  set r [catch {execsql {\n    INSERT INTO t1 VALUES('x','y','z');\n  }} msg]\n  lappend r $msg\n} {1 {datatype mismatch}}\ndo_test intpkey-1.13.2 {\n  set r [catch {execsql {\n    INSERT INTO t1 VALUES('','y','z');\n  }} msg]\n  lappend r $msg\n} {1 {datatype mismatch}}\ndo_test intpkey-1.14 {\n  set r [catch {execsql {\n    INSERT INTO t1 VALUES(3.4,'y','z');\n  }} msg]\n  lappend r $msg\n} {1 {datatype mismatch}}\ndo_test intpkey-1.15 {\n  set r [catch {execsql {\n    INSERT INTO t1 VALUES(-3,'y','z');\n  }} msg]\n  lappend r $msg\n} {0 {}}\ndo_test intpkey-1.16 {\n  execsql {SELECT * FROM t1}\n} {-3 y z 4 one two 5 hello world 6 second entry}\n\n#### INDICES\n# Check to make sure indices work correctly with integer primary keys\n#\ndo_test intpkey-2.1 {\n  execsql {\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b=='y'\n  }\n} {-3 y z}\ndo_test intpkey-2.1.1 {\n  execsql {\n    SELECT * FROM t1 WHERE b=='y' AND rowid<0\n  }\n} {-3 y z}\ndo_test intpkey-2.1.2 {\n  execsql {\n    SELECT * FROM t1 WHERE b=='y' AND rowid<0 AND rowid>=-20\n  }\n} {-3 y z}\ndo_test intpkey-2.1.3 {\n  execsql {\n    SELECT * FROM t1 WHERE b>='y'\n  }\n} {-3 y z}\ndo_test intpkey-2.1.4 {\n  execsql {\n    SELECT * FROM t1 WHERE b>='y' AND rowid<10\n  }\n} {-3 y z}\n\ndo_test intpkey-2.2 {\n  execsql {\n    UPDATE t1 SET a=8 WHERE b=='y';\n    SELECT * FROM t1 WHERE b=='y';\n  }\n} {8 y z}\ndo_test intpkey-2.3 {\n  execsql {\n    SELECT rowid, * FROM t1;\n  }\n} {4 4 one two 5 5 hello world 6 6 second entry 8 8 y z}\ndo_test intpkey-2.4 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE b<'second'\n  }\n} {5 5 hello world 4 4 one two}\ndo_test intpkey-2.4.1 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE 'second'>b\n  }\n} {5 5 hello world 4 4 one two}\ndo_test intpkey-2.4.2 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE 8>rowid AND 'second'>b\n  }\n} {4 4 one two 5 5 hello world}\ndo_test intpkey-2.4.3 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE 8>rowid AND 'second'>b AND 0<rowid\n  }\n} {4 4 one two 5 5 hello world}\ndo_test intpkey-2.5 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE b>'a'\n  }\n} {5 5 hello world 4 4 one two 6 6 second entry 8 8 y z}\ndo_test intpkey-2.6 {\n  execsql {\n    DELETE FROM t1 WHERE rowid=4;\n    SELECT * FROM t1 WHERE b>'a';\n  }\n} {5 hello world 6 second entry 8 y z}\ndo_test intpkey-2.7 {\n  execsql {\n    UPDATE t1 SET a=-4 WHERE rowid=8;\n    SELECT * FROM t1 WHERE b>'a';\n  }\n} {5 hello world 6 second entry -4 y z}\ndo_test intpkey-2.7 {\n  execsql {\n    SELECT * FROM t1\n  }\n} {-4 y z 5 hello world 6 second entry}\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# Create indices that include the integer primary key as one of their\n# columns.\n#\ndo_test intpkey-3.1 {\n  execsql {\n    CREATE INDEX i2 ON t1(a);\n  }\n} {}\ndo_test intpkey-3.2 {\n  count {\n    SELECT * FROM t1 WHERE a=5;\n  }\n} {5 hello world 0}\ndo_test intpkey-3.3 {\n  count {\n    SELECT * FROM t1 WHERE a>4 AND a<6;\n  }\n} {5 hello world 2}\ndo_test intpkey-3.4 {\n  count {\n    SELECT * FROM t1 WHERE b>='hello' AND b<'hello2';\n  }\n} {5 hello world 3}\ndo_test intpkey-3.5 {\n  execsql {\n    CREATE INDEX i3 ON t1(c,a);\n  }\n} {}\ndo_test intpkey-3.6 {\n  count {\n    SELECT * FROM t1 WHERE c=='world';\n  }\n} {5 hello world 3}\ndo_test intpkey-3.7 {\n  execsql {INSERT INTO t1 VALUES(11,'hello','world')}\n  count {\n    SELECT * FROM t1 WHERE c=='world';\n  }\n} {5 hello world 11 hello world 5}\ndo_test intpkey-3.8 {\n  count {\n    SELECT * FROM t1 WHERE c=='world' AND a>7;\n  }\n} {11 hello world 3}\ndo_test intpkey-3.9 {\n  count {\n    SELECT * FROM t1 WHERE 7<a;\n  }\n} {11 hello world 1}\n\n# Test inequality constraints on integer primary keys and rowids\n#\ndo_test intpkey-4.1 {\n  count {\n    SELECT * FROM t1 WHERE 11=rowid\n  }\n} {11 hello world 0}\ndo_test intpkey-4.2 {\n  count {\n    SELECT * FROM t1 WHERE 11=rowid AND b=='hello'\n  }\n} {11 hello world 0}\ndo_test intpkey-4.3 {\n  count {\n    SELECT * FROM t1 WHERE 11=rowid AND b=='hello' AND c IS NOT NULL;\n  }\n} {11 hello world 0}\ndo_test intpkey-4.4 {\n  count {\n    SELECT * FROM t1 WHERE rowid==11\n  }\n} {11 hello world 0}\ndo_test intpkey-4.5 {\n  count {\n    SELECT * FROM t1 WHERE oid==11 AND b=='hello'\n  }\n} {11 hello world 0}\ndo_test intpkey-4.6 {\n  count {\n    SELECT * FROM t1 WHERE a==11 AND b=='hello' AND c IS NOT NULL;\n  }\n} {11 hello world 0}\n\ndo_test intpkey-4.7 {\n  count {\n    SELECT * FROM t1 WHERE 8<rowid;\n  }\n} {11 hello world 1}\ndo_test intpkey-4.8 {\n  count {\n    SELECT * FROM t1 WHERE 8<rowid AND 11>=oid;\n  }\n} {11 hello world 1}\ndo_test intpkey-4.9 {\n  count {\n    SELECT * FROM t1 WHERE 11<=_rowid_ AND 12>=a;\n  }\n} {11 hello world 1}\ndo_test intpkey-4.10 {\n  count {\n    SELECT * FROM t1 WHERE 0>=_rowid_;\n  }\n} {-4 y z 1}\ndo_test intpkey-4.11 {\n  count {\n    SELECT * FROM t1 WHERE a<0;\n  }\n} {-4 y z 1}\ndo_test intpkey-4.12 {\n  count {\n    SELECT * FROM t1 WHERE a<0 AND a>10;\n  }\n} {1}\n\n# Make sure it is OK to insert a rowid of 0\n#\ndo_test intpkey-5.1 {\n  execsql {\n    INSERT INTO t1 VALUES(0,'zero','entry');\n  }\n  count {\n    SELECT * FROM t1 WHERE a=0;\n  }\n} {0 zero entry 0}\ndo_test intpkey-5.2 {\n  execsql {\n    SELECT rowid, a FROM t1 ORDER BY rowid\n  }\n} {-4 -4 0 0 5 5 6 6 11 11}\n\n# Test the ability of the COPY command to put data into a\n# table that contains an integer primary key.\n#\n# COPY command has been removed.  But we retain these tests so\n# that the tables will contain the right data for tests that follow.\n#\ndo_test intpkey-6.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(20,'b-20','c-20');\n    INSERT INTO t1 VALUES(21,'b-21','c-21');\n    INSERT INTO t1 VALUES(22,'b-22','c-22');\n    COMMIT;\n    SELECT * FROM t1 WHERE a>=20;\n  }\n} {20 b-20 c-20 21 b-21 c-21 22 b-22 c-22}\ndo_test intpkey-6.2 {\n  execsql {\n    SELECT * FROM t1 WHERE b=='hello'\n  }\n} {5 hello world 11 hello world}\ndo_test intpkey-6.3 {\n  execsql {\n    DELETE FROM t1 WHERE b='b-21';\n    SELECT * FROM t1 WHERE b=='b-21';\n  }\n} {}\ndo_test intpkey-6.4 {\n  execsql {\n    SELECT * FROM t1 WHERE a>=20\n  }\n} {20 b-20 c-20 22 b-22 c-22}\n\n# Do an insert of values with the columns specified out of order.\n#\ndo_test intpkey-7.1 {\n  execsql {\n    INSERT INTO t1(c,b,a) VALUES('row','new',30);\n    SELECT * FROM t1 WHERE rowid>=30;\n  }\n} {30 new row}\ndo_test intpkey-7.2 {\n  execsql {\n    SELECT * FROM t1 WHERE rowid>20;\n  }\n} {22 b-22 c-22 30 new row}\n\n# Do an insert from a select statement.\n#\ndo_test intpkey-8.1 {\n  execsql {\n    CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z);\n    INSERT INTO t2 SELECT * FROM t1;\n    SELECT rowid FROM t2;\n  }\n} {-4 0 5 6 11 20 22 30}\ndo_test intpkey-8.2 {\n  execsql {\n    SELECT x FROM t2;\n  }\n} {-4 0 5 6 11 20 22 30}\n\ndo_test intpkey-9.1 {\n  execsql {\n    UPDATE t1 SET c='www' WHERE c='world';\n    SELECT rowid, a, c FROM t1 WHERE c=='www';\n  }\n} {5 5 www 11 11 www}\n\n\n# Check insert of NULL for primary key\n#\ndo_test intpkey-10.1 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(x INTEGER PRIMARY KEY, y, z);\n    INSERT INTO t2 VALUES(NULL, 1, 2);\n    SELECT * from t2;\n  }\n} {1 1 2}\ndo_test intpkey-10.2 {\n  execsql {\n    INSERT INTO t2 VALUES(NULL, 2, 3);\n    SELECT * from t2 WHERE x=2;\n  }\n} {2 2 3}\ndo_test intpkey-10.3 {\n  execsql {\n    INSERT INTO t2 SELECT NULL, z, y FROM t2;\n    SELECT * FROM t2;\n  }\n} {1 1 2 2 2 3 3 2 1 4 3 2}\n\n# This tests checks to see if a floating point number can be used\n# to reference an integer primary key.\n#\ndo_test intpkey-11.1 {\n  execsql {\n    SELECT b FROM t1 WHERE a=2.0+3.0;\n  }\n} {hello}\ndo_test intpkey-11.1 {\n  execsql {\n    SELECT b FROM t1 WHERE a=2.0+3.5;\n  }\n} {}\n\nintegrity_check intpkey-12.1\n\n# Try to use a string that looks like a floating point number as\n# an integer primary key.  This should actually work when the floating\n# point value can be rounded to an integer without loss of data.\n#\ndo_test intpkey-13.1 {\n  execsql {\n    SELECT * FROM t1 WHERE a=1;\n  }\n} {}\ndo_test intpkey-13.2 {\n  execsql {\n    INSERT INTO t1 VALUES('1.0',2,3);\n    SELECT * FROM t1 WHERE a=1;\n  }\n} {1 2 3}\ndo_test intpkey-13.3 {\n  catchsql {\n    INSERT INTO t1 VALUES('1.5',3,4);\n  }\n} {1 {datatype mismatch}}\nifcapable {bloblit} {\n  do_test intpkey-13.4 {\n    catchsql {\n      INSERT INTO t1 VALUES(x'123456',3,4);\n    }\n  } {1 {datatype mismatch}}\n}\ndo_test intpkey-13.5 {\n  catchsql {\n    INSERT INTO t1 VALUES('+1234567890',3,4);\n  }\n} {0 {}}\n\n# Compare an INTEGER PRIMARY KEY against a TEXT expression. The INTEGER\n# affinity should be applied to the text value before the comparison\n# takes place.\n#\ndo_test intpkey-14.1 {\n  execsql {\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER, c TEXT);\n    INSERT INTO t3 VALUES(1, 1, 'one');\n    INSERT INTO t3 VALUES(2, 2, '2');\n    INSERT INTO t3 VALUES(3, 3, 3);\n  }\n} {}\ndo_test intpkey-14.2 {\n  execsql {\n    SELECT * FROM t3 WHERE a>2;\n  }\n} {3 3 3}\ndo_test intpkey-14.3 {\n  execsql {\n    SELECT * FROM t3 WHERE a>'2';\n  }\n} {3 3 3}\ndo_test intpkey-14.4 {\n  execsql {\n    SELECT * FROM t3 WHERE a<'2';\n  }\n} {1 1 one}\ndo_test intpkey-14.5 {\n  execsql {\n    SELECT * FROM t3 WHERE a<c;\n  }\n} {1 1 one}\ndo_test intpkey-14.6 {\n  execsql {\n    SELECT * FROM t3 WHERE a=c;\n  }\n} {2 2 2 3 3 3}\n\n# Check for proper handling of primary keys greater than 2^31.\n# Ticket #1188\n#\ndo_test intpkey-15.1 {\n  execsql {\n    INSERT INTO t1 VALUES(2147483647, 'big-1', 123);\n    SELECT * FROM t1 WHERE a>2147483648;\n  }\n} {}\ndo_test intpkey-15.2 {\n  execsql {\n    INSERT INTO t1 VALUES(NULL, 'big-2', 234);\n    SELECT b FROM t1 WHERE a>=2147483648;\n  }\n} {big-2}\ndo_test intpkey-15.3 {\n  execsql {\n    SELECT b FROM t1 WHERE a>2147483648;\n  }\n} {}\ndo_test intpkey-15.4 {\n  execsql {\n    SELECT b FROM t1 WHERE a>=2147483647;\n  }\n} {big-1 big-2}\ndo_test intpkey-15.5 {\n  execsql {\n    SELECT b FROM t1 WHERE a<2147483648;\n  }\n} {y zero 2 hello second hello b-20 b-22 new 3 big-1}\ndo_test intpkey-15.6 {\n  execsql {\n    SELECT b FROM t1 WHERE a<12345678901;\n  }\n} {y zero 2 hello second hello b-20 b-22 new 3 big-1 big-2}\ndo_test intpkey-15.7 {\n  execsql {\n    SELECT b FROM t1 WHERE a>12345678901;\n  }\n} {}\n\n# 2016-04-18 ticket https://www.sqlite.org/src/tktview/7d7525cb01b68712495d3a\n# Be sure to escape quoted typenames.\n#\ndo_execsql_test intpkey-16.0 {\n  CREATE TABLE t16a(id \"INTEGER\" PRIMARY KEY AUTOINCREMENT, b [TEXT], c `INT`);\n} {}\ndo_execsql_test intpkey-16.1 {\n  PRAGMA table_info=t16a;\n} {0 id INTEGER 0 {} 1 1 b TEXT 0 {} 0 2 c INT 0 {} 0}\n\n# 2016-05-06 ticket https://www.sqlite.org/src/tktview/16c9801ceba4923939085\n# When the schema contains an index on the IPK and no other index\n# and a WHERE clause on a delete uses an OR where both sides referencing\n# the IPK, then it is possible that the OP_Delete will fail because there\n# deferred seek of the OP_Seek is not resolved prior to reaching the OP_Delete.\n#\ndo_execsql_test intpkey-17.0 {\n  CREATE TABLE t17(x INTEGER PRIMARY KEY, y TEXT);\n  INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');\n  CREATE INDEX t17x ON t17(x);\n  DELETE FROM t17 WHERE x=99 OR x<130;\n  SELECT * FROM t17;\n} {248 giraffe}\ndo_execsql_test intpkey-17.1 {\n  DROP INDEX t17x;\n  DELETE FROM t17;\n  INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');\n  CREATE UNIQUE INDEX t17x ON t17(abs(x));\n  DELETE FROM t17 WHERE abs(x) IS NULL OR abs(x)<130;\n  SELECT * FROM t17;\n} {248 giraffe}\ndo_execsql_test intpkey-17.2 {\n  DELETE FROM t17;\n  INSERT INTO t17(x,y) VALUES(123,'elephant'),(248,'giraffe');\n  UPDATE t17 SET y='ostrich' WHERE abs(x)=248;\n  SELECT * FROM t17 ORDER BY +x;\n} {123 elephant 248 ostrich}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/io.test",
    "content": "# 2007 August 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing some specific characteristics of the \n# IO traffic generated by SQLite (making sure SQLite is not writing out\n# more database pages than it has to, stuff like that).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix io\n\ndb close\nsqlite3_simulate_device\nsqlite3 db test.db -vfs devsym\n\n# Test summary:\n#\n# io-1.* -  Test that quick-balance does not journal pages unnecessarily.\n#\n# io-2.* -  Test the \"atomic-write optimization\".\n#\n# io-3.* -  Test the IO traffic enhancements triggered when the \n#           IOCAP_SEQUENTIAL device capability flag is set (no \n#           fsync() calls on the journal file).\n#\n# io-4.* -  Test the IO traffic enhancements triggered when the \n#           IOCAP_SAFE_APPEND device capability flag is set (fewer \n#           fsync() calls on the journal file, no need to set nRec\n#           field in the single journal header).\n#\n# io-5.* -  Test that the default page size is selected and used \n#           correctly.\n#\n# io-6.* -  Test that the pager-cache is not being flushed unnecessarily \n#           after a transaction that uses the special atomic-write path\n#           is committed.\n#           \n\nset ::nWrite 0\nproc nWrite {db} {\n  set bt [btree_from_db $db]\n  db_enter $db\n  array set stats [btree_pager_stats $bt]\n  db_leave $db\n  set res [expr $stats(write) - $::nWrite]\n  set ::nWrite $stats(write)\n  set res\n}\n\nset ::nSync 0\nproc nSync {} {\n  set res [expr {$::sqlite_sync_count - $::nSync}]\n  set ::nSync $::sqlite_sync_count\n  set res\n}\n\ndo_test io-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = OFF;\n    PRAGMA page_size = 1024;\n    CREATE TABLE abc(a,b);\n  }\n  nWrite db\n} {2}\n\n# Insert into the table 4 records of aproximately 240 bytes each.\n# This should completely fill the root-page of the table. Each\n# INSERT causes 2 db pages to be written - the root-page of \"abc\"\n# and page 1 (db change-counter page).\ndo_test io-1.2 {\n  set ret [list]\n  execsql { INSERT INTO abc VALUES(1,randstr(230,230)); }\n  lappend ret [nWrite db]\n  execsql { INSERT INTO abc VALUES(2,randstr(230,230)); }\n  lappend ret [nWrite db]\n  execsql { INSERT INTO abc VALUES(3,randstr(230,230)); }\n  lappend ret [nWrite db]\n  execsql { INSERT INTO abc VALUES(4,randstr(230,230)); }\n  lappend ret [nWrite db]\n} {2 2 2 2}\n\n# Insert another 240 byte record. This causes two leaf pages\n# to be added to the root page of abc. 4 pages in total\n# are written to the db file - the two leaf pages, the root\n# of abc and the change-counter page.\ndo_test io-1.3 {\n  execsql { INSERT INTO abc VALUES(5,randstr(230,230)); }\n  nWrite db\n} {4}\n\n# Insert another 3 240 byte records. After this, the tree consists of \n# the root-node, which is close to empty, and two leaf pages, both of \n# which are full. \ndo_test io-1.4 {\n  set ret [list]\n  execsql { INSERT INTO abc VALUES(6,randstr(230,230)); }\n  lappend ret [nWrite db]\n  execsql { INSERT INTO abc VALUES(7,randstr(230,230)); }\n  lappend ret [nWrite db]\n  execsql { INSERT INTO abc VALUES(8,randstr(230,230)); }\n  lappend ret [nWrite db]\n} {2 2 2}\n\n# This insert should use the quick-balance trick to add a third leaf\n# to the b-tree used to store table abc. It should only be necessary to\n# write to 3 pages to do this: the change-counter, the root-page and\n# the new leaf page.\ndo_test io-1.5 {\n  execsql { INSERT INTO abc VALUES(9,randstr(230,230)); }\n  nWrite db\n} {3}\n\nifcapable atomicwrite {\n\n#----------------------------------------------------------------------\n# Test cases io-2.* test the atomic-write optimization.\n#\ndo_test io-2.1 {\n  execsql { DELETE FROM abc; VACUUM; }\n} {}\n\n# Clear the write and sync counts.\nnWrite db ; nSync\n\n# The following INSERT updates 2 pages and requires 4 calls to fsync():\n#\n#   1) The directory in which the journal file is created,\n#   2) The journal file (to sync the page data),\n#   3) The journal file (to sync the journal file header),\n#   4) The database file.\n#\ndo_test io-2.2 {\n  execsql { INSERT INTO abc VALUES(1, 2) }\n  list [nWrite db] [nSync]\n} {2 4}\n\n# Set the device-characteristic mask to include the SQLITE_IOCAP_ATOMIC,\n# then do another INSERT similar to the one in io-2.2. This should\n# only write 1 page and require a single fsync().\n# \n# The single fsync() is the database file. Only one page is reported as\n# written because page 1 - the change-counter page - is written using\n# an out-of-band method that bypasses the write counter.\n#\n# UPDATE: As of [05f98d4eec] (adding SQLITE_DBSTATUS_CACHE_WRITE), the\n# second write is also counted. So this now reports two writes and a\n# single fsync.\n#\nsqlite3_simulate_device -char atomic\ndo_test io-2.3 {\n  execsql { INSERT INTO abc VALUES(3, 4) }\n  list [nWrite db] [nSync]\n} {2 1}\n\n# Test that the journal file is not created and the change-counter is\n# updated when the atomic-write optimization is used.\n#\ndo_test io-2.4.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(5, 6);\n  }\n  sqlite3 db2 test.db -vfs devsym\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4}\ndo_test io-2.4.2 {\n  file exists test.db-journal\n} {0}\ndo_test io-2.4.3 {\n  execsql { COMMIT }\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4 5 6}\ndb2 close\n\n# Test that the journal file is created and sync()d if the transaction\n# modifies more than one database page, even if the IOCAP_ATOMIC flag\n# is set.\n#\ndo_test io-2.5.1 {\n  execsql { CREATE TABLE def(d, e) }\n  nWrite db ; nSync\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(7, 8);\n  }\n  file exists test.db-journal\n} {0}\ndo_test io-2.5.2 {\n  execsql { INSERT INTO def VALUES('a', 'b'); }\n  file exists test.db-journal\n} {1}\ndo_test io-2.5.3 {\n  execsql { COMMIT }\n  list [nWrite db] [nSync]\n} {3 4}\n\n# Test that the journal file is created and sync()d if the transaction\n# modifies a single database page and also appends a page to the file.\n# Internally, this case is handled differently to the one above. The\n# journal file is not actually created until the 'COMMIT' statement\n# is executed.\n#\n# Changed 2010-03-27:  The size of the database is now stored in \n# bytes 28..31 and so when a page is added to the database, page 1\n# is immediately modified and the journal file immediately comes into\n# existence.  To fix this test, the BEGIN is changed into a a\n# BEGIN IMMEDIATE and the INSERT is omitted.\n#\ndo_test io-2.6.1 {\n  execsql {\n    BEGIN IMMEDIATE;\n    -- INSERT INTO abc VALUES(9, randstr(1000,1000));\n  }\n  file exists test.db-journal\n} {0}\ndo_test io-2.6.2 {\n  # Create a file at \"test.db-journal\". This will prevent SQLite from\n  # opening the journal for exclusive access. As a result, the COMMIT\n  # should fail with SQLITE_CANTOPEN and the transaction rolled back.\n  #\n  file mkdir test.db-journal\n  catchsql {\n    INSERT INTO abc VALUES(9, randstr(1000,1000));\n    COMMIT\n  }\n} {1 {unable to open database file}}\ndo_test io-2.6.3 {\n  forcedelete test.db-journal\n  catchsql { COMMIT }\n} {0 {}}\ndo_test io-2.6.4 {\n  execsql { SELECT * FROM abc }\n} {1 2 3 4 5 6 7 8}\n\n# Test that if the database modification is part of multi-file commit,\n# the journal file is always created. In this case, the journal file\n# is created during execution of the COMMIT statement, so we have to\n# use the same technique to check that it is created as in the above \n# block.\nforcedelete test2.db test2.db-journal\nifcapable attach {\n  do_test io-2.7.1 {\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.page_size = 1024;\n      CREATE TABLE aux.abc2(a, b);\n      BEGIN;\n      INSERT INTO abc VALUES(9, 10);\n    }\n    file exists test.db-journal\n  } {0}\n  do_test io-2.7.2 {\n    execsql { INSERT INTO abc2 SELECT * FROM abc }\n    file exists test2.db-journal\n  } {0}\n  do_test io-2.7.3 {\n    execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }\n  } {1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10}\n  do_test io-2.7.4 {\n    file mkdir test2.db-journal\n    catchsql { COMMIT }\n  } {1 {unable to open database file}}\n  do_test io-2.7.5 {\n    forcedelete test2.db-journal\n    catchsql { COMMIT }\n  } {1 {cannot commit - no transaction is active}}\n  do_test io-2.7.6 {\n    execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 }\n  } {1 2 3 4 5 6 7 8}\n}\n\n# Try an explicit ROLLBACK before the journal file is created.\n#\ndo_test io-2.8.1 {\n  execsql {\n    BEGIN;\n    DELETE FROM abc;\n  }\n  file exists test.db-journal\n} {0}\ndo_test io-2.8.2 {\n  execsql { SELECT * FROM abc }\n} {}\ndo_test io-2.8.3 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM abc;\n  }\n} {1 2 3 4 5 6 7 8}\n\n# Test that the atomic write optimisation is not enabled if the sector\n# size is larger than the page-size.\n#\ndo_test io-2.9.1 {\n  db close\n  sqlite3 db test.db\n  sqlite3_simulate_device -char atomic -sectorsize 2048\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(9, 10);\n  }\n  file exists test.db-journal\n} {1}\ndo_test io-2.9.2 {\n  execsql { ROLLBACK; }\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db -vfs devsym\n  execsql {\n    PRAGMA auto_vacuum = OFF;\n    PRAGMA page_size = 2048;\n    CREATE TABLE abc(a, b);\n  }\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(9, 10);\n  }\n  file exists test.db-journal\n} {0}\ndo_test io-2.9.3 {\n  execsql { COMMIT }\n} {}\n\n# Test a couple of the more specific IOCAP_ATOMIC flags \n# (i.e IOCAP_ATOMIC2K etc.).\n#\ndo_test io-2.10.1 {\n  sqlite3_simulate_device -char atomic1k\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(11, 12);\n  }\n  file exists test.db-journal\n} {1}\ndo_test io-2.10.2 {\n  execsql { ROLLBACK }\n  sqlite3_simulate_device -char atomic2k\n  execsql {\n    BEGIN;\n    INSERT INTO abc VALUES(11, 12);\n  }\n  file exists test.db-journal\n} {0}\ndo_test io-2.10.3 {\n  execsql { ROLLBACK }\n} {}\n\ndo_test io-2.11.0 {\n  execsql { \n    PRAGMA locking_mode = exclusive;\n    PRAGMA locking_mode;\n  }\n} {exclusive exclusive}\ndo_test io-2.11.1 {\n  execsql { \n    INSERT INTO abc VALUES(11, 12);\n  }\n  file exists test.db-journal\n} {0}\n\ndo_test io-2.11.2 {\n  execsql { \n    PRAGMA locking_mode = normal;\n    INSERT INTO abc VALUES(13, 14);\n  }\n  file exists test.db-journal\n} {0}\n\n} ;# /* ifcapable atomicwrite */\n\n#----------------------------------------------------------------------\n# Test cases io-3.* test the IOCAP_SEQUENTIAL optimization.\n#\nsqlite3_simulate_device -char sequential -sectorsize 0\nifcapable pager_pragmas {\n  do_test io-3.1 {\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db -vfs devsym\n    db eval {\n      PRAGMA auto_vacuum=OFF;\n    }\n    # File size might be 1 due to the hack to work around ticket #3260.\n    # Search for #3260 in os_unix.c for additional information.\n    expr {[file size test.db]>1}\n  } {0}\n  do_test io-3.2 {\n    execsql { CREATE TABLE abc(a, b) }\n    nSync\n    execsql {\n      PRAGMA temp_store = memory;\n      PRAGMA cache_size = 10;\n      BEGIN;\n      INSERT INTO abc VALUES('hello', 'world');\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n      INSERT INTO abc SELECT * FROM abc;\n    }\n    # File has grown - showing there was a cache-spill - but there \n    # have been no calls to fsync(). The file is probably about 30KB.\n    # But some VFS implementations (symbian) buffer writes so the actual\n    # size may be a little less than that. So this test case just tests\n    # that the file is now greater than 20000 bytes in size.\n    list [expr [file size test.db]>20000] [nSync]\n  } {1 0}\n  do_test io-3.3 {\n    # The COMMIT requires a single fsync() - to the database file.\n    execsql { COMMIT }\n    list [file size test.db] [nSync]\n  } \"[expr {[nonzero_reserved_bytes]?40960:39936}] 1\"\n}\n\n#----------------------------------------------------------------------\n# Test cases io-4.* test the IOCAP_SAFE_APPEND optimization.\n#\nsqlite3_simulate_device -char safe_append\n\n# With the SAFE_APPEND flag set, simple transactions require 3, rather\n# than 4, calls to fsync(). The fsync() calls are on:\n#\n#   1) The directory in which the journal file is created, (unix only)\n#   2) The journal file (to sync the page data),\n#   3) The database file.\n#\n# Normally, when the SAFE_APPEND flag is not set, there is another fsync()\n# on the journal file between steps (2) and (3) above.\n#\nset expected_sync_count 2\nif {$::tcl_platform(platform)==\"unix\"} {\n  ifcapable dirsync {\n    incr expected_sync_count\n  }\n}\n\ndo_test io-4.1 {\n  execsql { DELETE FROM abc }\n  nSync\n  execsql { INSERT INTO abc VALUES('a', 'b') }\n  nSync\n} $expected_sync_count\n\n# With SAFE_APPEND set, the nRec field of the journal file header should\n# be set to 0xFFFFFFFF before the first journal sync. The nRec field\n# occupies bytes 8-11 of the journal file.\n#\ndo_test io-4.2.1 {\n  execsql { BEGIN }\n  execsql { INSERT INTO abc VALUES('c', 'd') }\n  file exists test.db-journal\n} {1}\nif {$::tcl_platform(platform)==\"unix\"} {\n  do_test io-4.2.2 {\n    hexio_read test.db-journal 8 4\n  } {FFFFFFFF}\n}\ndo_test io-4.2.3 {\n  execsql { COMMIT }\n  nSync\n} $expected_sync_count\nsqlite3_simulate_device -char safe_append\n\n# With SAFE_APPEND set, there should only ever be one journal-header\n# written to the database, even though the sync-mode is \"full\".\n#\ndo_test io-4.3.1 {\n  execsql {\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n  }\n  expr {[file size test.db]/1024}\n} {43}\nifcapable pager_pragmas {\n  do_test io-4.3.2 {\n    execsql {\n      PRAGMA synchronous = full;\n      PRAGMA cache_size = 10;\n      PRAGMA synchronous;\n    }\n  } {2}\n}\ndo_test io-4.3.3 {\n  execsql {\n    BEGIN;\n    UPDATE abc SET a = 'x';\n  }\n  file exists test.db-journal\n} {1}\nif {$tcl_platform(platform) != \"symbian\"} {\n  # This test is not run on symbian because the file-buffer makes it\n  # difficult to predict the exact size of the file as reported by \n  # [file size].\n  do_test io-4.3.4 {\n    # The UPDATE statement in the statement above modifies 41 pages \n    # (all pages in the database except page 1 and the root page of \n    # abc). Because the cache_size is set to 10, this must have required\n    # at least 4 cache-spills. If there were no journal headers written\n    # to the journal file after the cache-spill, then the size of the\n    # journal file is give by:\n    #\n    #    <jrnl file size> = <jrnl header size> + nPage * (<page-size> + 8)\n    #\n    # If the journal file contains additional headers, this formula\n    # will not predict the size of the journal file.\n    #\n    file size test.db-journal\n  } [expr 512 + (1024+8)*41]\n}\n\n#----------------------------------------------------------------------\n# Test cases io-5.* test that the default page size is selected and\n# used correctly.\n#\nset tn 0\nforeach {char                 sectorsize pgsize} {\n         {}                     512      1024\n         {}                    1024      1024\n         {}                    2048      2048\n         {}                    8192      8192\n         {}                   16384      8192\n         {atomic}               512      8192\n         {atomic512}            512      1024\n         {atomic2K}             512      2048\n         {atomic2K}            4096      4096\n         {atomic2K atomic}      512      8192\n         {atomic64K}            512      1024\n} {\n  incr tn\n  if {$pgsize>$::SQLITE_MAX_PAGE_SIZE} continue\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3_simulate_device -char $char -sectorsize $sectorsize\n  sqlite3 db test.db -vfs devsym\n  db eval {\n    PRAGMA auto_vacuum=OFF;\n  }\n  ifcapable !atomicwrite {\n    if {[regexp {^atomic} $char]} continue\n  }\n  do_test io-5.$tn {\n    execsql {\n      CREATE TABLE abc(a, b, c);\n    }\n    expr {[file size test.db]/2}\n  } $pgsize\n}\n\n#----------------------------------------------------------------------\n#\ndo_test io-6.1 {\n  db close\n  sqlite3_simulate_device -char atomic\n  forcedelete test.db\n  sqlite3 db test.db -vfs devsym\n  execsql {\n    PRAGMA mmap_size = 0;\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 2000;\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(x);\n    CREATE TABLE t3(x);\n    CREATE INDEX i3 ON t3(x);\n    INSERT INTO t3 VALUES(randomblob(100));\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n    INSERT INTO t3 SELECT randomblob(100) FROM t3;\n  }\n\n  db_save_and_close\n} {}\n\nforeach {tn sql} {\n  1 { BEGIN;\n        INSERT INTO t1 VALUES('123');\n        INSERT INTO t2 VALUES('456');\n      COMMIT;\n  }\n  2 { BEGIN;\n        INSERT INTO t1 VALUES('123');\n      COMMIT;\n  }\n} {\n\n  # These tests don't work with memsubsys1, as it causes the effective page\n  # cache size to become too small to hold the entire db in memory.\n  if {[permutation] == \"memsubsys1\"} continue\n\n  db_restore\n  sqlite3 db test.db -vfs devsym\n  execsql {\n    PRAGMA cache_size = 2000;\n    PRAGMA mmap_size = 0;\n    SELECT x FROM t3 ORDER BY rowid;\n    SELECT x FROM t3 ORDER BY x;\n  }\n  do_execsql_test 6.2.$tn.1 { PRAGMA integrity_check } {ok}\n  do_execsql_test 6.2.$tn.2 $sql\n\n  # Corrupt the database file on disk. This should not matter for the\n  # purposes of the following \"PRAGMA integrity_check\", as the entire\n  # database should be cached in the pager-cache. If corruption is\n  # reported, it indicates that executing $sql caused the pager cache\n  # to be flushed. Which is a bug.\n  hexio_write test.db [expr 1024 * 5] [string repeat 00 2048]\n  do_execsql_test 6.2.$tn.3 { PRAGMA integrity_check } {ok}\n  db close\n}\n\nsqlite3_simulate_device -char {} -sectorsize 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr.test",
    "content": "# 2001 October 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# such as writes failing because the disk is full.\n# \n# The tests in this file use special facilities that are only\n# available in the SQLite test fixture.\n#\n# $Id: ioerr.test,v 1.43 2009/04/06 17:50:03 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error\n# on the 8th IO operation in the SQL script below doesn't report an error.\n#\n# This is because the 8th IO call attempts to read page 2 of the database\n# file when the file on disk is only 1 page. The pager layer detects that\n# this has happened and suppresses the error returned by the OS layer.\n#\ndo_ioerr_test ioerr-1 -erc 1 -ckrefcount 1 -sqlprep {\n  SELECT * FROM sqlite_master;\n} -sqlbody {\n  CREATE TABLE t1(a,b,c);\n  SELECT * FROM sqlite_master;\n  BEGIN TRANSACTION;\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(4,5,6);\n  ROLLBACK;\n  SELECT * FROM t1;\n  BEGIN TRANSACTION;\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(4,5,6);\n  COMMIT;\n  SELECT * FROM t1;\n  DELETE FROM t1 WHERE a<100;\n} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 4 : 0]\n\n# Test for IO errors during a VACUUM. \n#\n# The first IO call is excluded from the test. This call attempts to read\n# the file-header of the temporary database used by VACUUM. Since the\n# database doesn't exist at that point, the IO error is not detected.\n# \n# Additionally, if auto-vacuum is enabled, the 12th IO error is not \n# detected. Same reason as the 8th in the test case above.\n# \nifcapable vacuum {\n  do_ioerr_test ioerr-2 -cksum true -ckrefcount true -sqlprep { \n    BEGIN; \n    CREATE TABLE t1(a, b, c); \n    INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50)); \n    INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1; \n    INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    CREATE TABLE t3 AS SELECT * FROM t1;\n    COMMIT;\n    DROP TABLE t2;\n  } -sqlbody {\n    VACUUM;\n  } -exclude [list \\\n      1 [expr [string match [execsql {pragma auto_vacuum}] 1]?9:-1]]\n}\n\ndo_ioerr_test ioerr-3 -ckrefcount true -tclprep {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE abc(a);\n    INSERT INTO abc VALUES(randstr(1500,1500)); -- Page 4 is overflow\n  }\n  for {set i 0} {$i<150} {incr i} {\n    execsql {\n      INSERT INTO abc VALUES(randstr(100,100)); \n    }\n  }\n  execsql COMMIT\n} -sqlbody {\n  CREATE TABLE abc2(a);\n  BEGIN;\n  DELETE FROM abc WHERE length(a)>100;\n  UPDATE abc SET a = randstr(90,90);\n  COMMIT;\n  CREATE TABLE abc3(a);\n} \n\n# Test IO errors that can occur retrieving a record header that flows over\n# onto an overflow page.\ndo_ioerr_test ioerr-4 -ckrefcount true -tclprep {\n  set sql \"CREATE TABLE abc(a1\"\n  for {set i 2} {$i<1300} {incr i} {\n    append sql \", a$i\"\n  }\n  append sql \");\"\n  execsql $sql\n  execsql {INSERT INTO abc (a1) VALUES(NULL)}\n} -sqlbody {\n SELECT * FROM abc;\n}\n\n\n# Test IO errors that may occur during a multi-file commit.\n#\n# Tests 8 and 17 are excluded when auto-vacuum is enabled for the same \n# reason as in test cases ioerr-1.XXX\nifcapable attach {\n  set ex \"\"\n  if {[string match [execsql {pragma auto_vacuum}] 1]} {\n    set ex [list 4 17]\n  }\n  do_ioerr_test ioerr-5 -restoreprng 0 -ckrefcount true -sqlprep {\n    ATTACH 'test2.db' AS test2;\n  } -sqlbody {\n    BEGIN;\n    CREATE TABLE t1(a,b,c);\n    CREATE TABLE test2.t2(a,b,c);\n    COMMIT;\n  } -exclude $ex\n}\n\n# Test IO errors when replaying two hot journals from a 2-file \n# transaction. This test only runs on UNIX.\n#\n# It cannot be run under the \"exclusive\" permutation. In that case, the\n# locks held by the connection in the local (this) process prevent a \n# second connection from attempting the multi-file transaction.\n#\nifcapable crashtest&&attach {\n  if {![catch {sqlite3 -has-codec} r] && !$r && [permutation]!=\"exclusive\"} {\n    do_ioerr_test ioerr-6 -ckrefcount true -tclprep {\n      execsql {\n        ATTACH 'test2.db' as aux;\n        CREATE TABLE tx(a, b);\n        CREATE TABLE aux.ty(a, b);\n      }\n      set rc [crashsql -delay 2 -file test2.db-journal {\n        ATTACH 'test2.db' as aux;\n        PRAGMA cache_size = 10;\n        BEGIN;\n        CREATE TABLE aux.t2(a, b, c);\n        CREATE TABLE t1(a, b, c);\n        COMMIT;\n      }]\n      if {$rc!=\"1 {child process exited abnormally}\"} {\n        error \"Wrong error message: $rc\"\n      }\n    } -sqlbody {\n      SELECT * FROM sqlite_master;\n      SELECT * FROM aux.sqlite_master;\n    }\n  }\n} \n\n# Test handling of IO errors that occur while rolling back hot journal\n# files.\n#\n# These tests can't be run on windows because the windows version of \n# SQLite holds a mandatory exclusive lock on journal files it has open.\n#\nif {$tcl_platform(platform)!=\"windows\"} {\n  do_ioerr_test ioerr-7 -tclprep {\n    db close\n    sqlite3 db2 test2.db\n    db2 eval {\n      PRAGMA synchronous = 0;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      BEGIN;\n      INSERT INTO t1 VALUES(3, 4);\n    }\n    forcecopy test2.db test.db\n    forcecopy test2.db-journal test.db-journal\n    db2 close\n  } -tclbody {\n    sqlite3 db test.db\n    db eval {\n      SELECT * FROM t1;\n    }\n  } -exclude 1\n}\n\n# For test coverage:  Cause an I/O failure while trying to read a\n# short field (one that fits into a Mem buffer without mallocing\n# for space).\n#\ndo_ioerr_test ioerr-8 -ckrefcount true -tclprep {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);\n  }\n  db close\n  sqlite3 db test.db\n} -sqlbody {\n  SELECT c FROM t1;\n}\n\n# For test coverage: Cause an IO error whilst reading the master-journal\n# name from a journal file.\nif {$tcl_platform(platform)==\"unix\"} {\n  do_ioerr_test ioerr-9 -ckrefcount true -tclprep {\n    execsql {\n      CREATE TABLE t1(a,b,c);\n      INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);\n      BEGIN;\n      INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2);\n    }\n    forcecopy test.db-journal test2.db-journal\n    execsql {\n      COMMIT;\n    }\n    forcecopy test2.db-journal test.db-journal\n    set f [open test.db-journal a]\n    fconfigure $f -encoding binary\n    puts -nonewline $f \"hello\"\n    puts -nonewline $f \"\\x00\\x00\\x00\\x05\\x01\\x02\\x03\\x04\"\n    puts -nonewline $f \"\\xd9\\xd5\\x05\\xf9\\x20\\xa1\\x63\\xd7\"\n    close $f\n  } -sqlbody {\n    SELECT a FROM t1;\n  }\n}\n\n# For test coverage: Cause an IO error during statement playback (i.e. \n# a constraint).\ndo_ioerr_test ioerr-10 -ckrefcount true -tclprep {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n  }\n  for {set i 0} {$i < 500} {incr i} {\n    execsql {INSERT INTO t1 VALUES(:i, 'hello world');}\n  }\n  execsql {\n    COMMIT;\n  }\n} -tclbody {\n\n  catch {execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES('abc', 123);\n    INSERT INTO t1 VALUES('def', 123);\n    INSERT INTO t1 VALUES('ghi', 123);\n    INSERT INTO t1 SELECT (a+500)%900, 'good string' FROM t1;\n  }} msg\n\n  if {$msg != \"UNIQUE constraint failed: t1.a\"} {\n    error $msg\n  }\n}\n\n# Assertion fault bug reported by alex dimitrov.\n#\ndo_ioerr_test ioerr-11 -ckrefcount true -erc 1 -sqlprep {\n   CREATE TABLE A(Id INTEGER, Name TEXT);\n   INSERT INTO A(Id, Name) VALUES(1, 'Name');\n} -sqlbody {\n   UPDATE A SET Id = 2, Name = 'Name2' WHERE Id = 1;\n}\n\n# Test that an io error encountered in a sync() caused by a call to\n# sqlite3_release_memory() is handled Ok. Only try this if \n# memory-management is enabled.\n#\nifcapable memorymanage {\n  do_ioerr_test memmanage-ioerr1 -ckrefcount true -sqlprep {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(randstr(50,50), randstr(100,100), randstr(10,10));\n    INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(9,9), randstr(90,90) FROM t1;\n  } -tclbody {\n    sqlite3_release_memory \n  } -sqlbody {\n    COMMIT;\n  }\n}\n\nifcapable pager_pragmas&&autovacuum {\n  do_ioerr_test ioerr-12 -ckrefcount true -erc 1 -sqlprep {\n     PRAGMA page_size = 512;\n     PRAGMA auto_vacuum = incremental;\n     CREATE TABLE t1(x);\n     INSERT INTO t1 VALUES( randomblob(1   * (512-4)) );\n     INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );\n     INSERT INTO t1 VALUES( randomblob(2   * (512-4)) );\n     INSERT INTO t1 VALUES( randomblob(110 * (512-4)) );\n     INSERT INTO t1 VALUES( randomblob(3 * (512-4)) );\n     DELETE FROM t1 WHERE rowid = 3;\n     PRAGMA incremental_vacuum = 2;\n     DELETE FROM t1 WHERE rowid = 1;\n  } -sqlbody {\n     PRAGMA incremental_vacuum = 1;\n  }\n}\n\n# Usually, after a new page is allocated from the end of the file, it does\n# not need to be written to the journal. The exception is when the new page\n# shares its sector with an existing page that does need to be journalled.\n# This test case provokes this condition to test for the sake of coverage\n# that an IO error while journalling the coresident page is handled correctly.\n#\nsqlite3_simulate_device -char {} -sectorsize 2048\ndo_ioerr_test ioerr-12 -ckrefcount true -erc 1 -tclprep {\n  db close\n  sqlite3 db test.db -vfs devsym\n\n  # Create a test database. Page 2 is the root page of table t1. The only\n  # row inserted into t1 has an overflow page - page 3. Page 3 will be\n  # coresident on the 2048 byte sector with the next page to be allocated.\n  # \n  db eval { PRAGMA page_size = 1024 }\n  db eval { CREATE TABLE t1(x) }\n  db eval { INSERT INTO t1 VALUES(randomblob(1100)); }\n} -tclbody {\n  db eval { INSERT INTO t1 VALUES(randomblob(2000)); }\n}\nsqlite3_simulate_device -char {} -sectorsize 0\ncatch {db close}\n\ndo_ioerr_test ioerr-13 -ckrefcount true -erc 1 -sqlprep {\n  PRAGMA auto_vacuum = incremental;\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(x);\n  INSERT INTO t2 VALUES(randomblob(1500));\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t1 VALUES(randomblob(20));\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;             /* 64 entries in t1 */\n  INSERT INTO t1 SELECT x FROM t1 LIMIT 14;    /* 78 entries in t1 */\n  DELETE FROM t2 WHERE rowid = 3;\n} -sqlbody {\n  -- This statement uses the balance_quick() optimization. The new page\n  -- is appended to the database file. But the overflow page used by\n  -- the new record will be positioned near the start of the database\n  -- file, in the gap left by the \"DELETE FROM t2 WHERE rowid=3\" statement\n  -- above.\n  --\n  -- The point of this is that the statement wil need to update two pointer\n  -- map pages. Which introduces another opportunity for an IO error.\n  --\n  INSERT INTO t1 VALUES(randomblob(2000));\n}\n\ndo_ioerr_test ioerr-14 -ckrefcount true -erc 1 -sqlprep {\n  PRAGMA auto_vacuum = incremental;\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(x);\n  INSERT INTO t2 VALUES(randomblob(1500));\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n  INSERT INTO t2 SELECT randomblob(1500) FROM t2;\n\n  -- This statement inserts a row into t1 with an overflow page at the\n  -- end of the file. A long way from its parent (the root of t1).\n  INSERT INTO t1 VALUES(randomblob(1500));\n  DELETE FROM t2 WHERE rowid<10;\n} -sqlbody {\n  -- This transaction will cause the root-page of table t1 to divide\n  -- (by calling balance_deeper()). When it does, the \"parent\" page of the\n  -- overflow page inserted in the -sqlprep block above will change and\n  -- the corresponding pointer map page be updated. This test case attempts\n  -- to cause an IO error during the pointer map page update.\n  --\n  BEGIN;\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  INSERT INTO t1 VALUES(randomblob(100));\n  COMMIT;\n}\n\ndo_ioerr_test ioerr-15 -tclprep {\n  db eval {\n    BEGIN;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(a);\n    CREATE INDEX i1 ON t1(a);\n    CREATE TABLE t2(a);\n  }\n  for {set ii 1} {$ii < 100} {incr ii} {\n    set v [string range [string repeat [format %.3d $ii] 200] 0 220]\n    db eval {INSERT INTO t1 VALUES($v)}\n  }\n  db eval {\n    DELETE FROM t1 WHERE oid > 85;\n    COMMIT;\n  }\n} -sqlbody {\n  BEGIN;\n  INSERT INTO t2 VALUES(randstr(22000,22000));\n  DELETE FROM t1 WHERE oid = 83;\n  COMMIT;\n} \n\n# This test verifies that IO errors that occur within the obscure branch\n# of code executed by tkt3762.test are correctly reported.\n#\nifcapable vacuum&&autovacuum&&pragma {\n  do_ioerr_test ioerr-16 -erc 1 -ckrefcount 1 -sqlprep {\n    PRAGMA auto_vacuum=INCREMENTAL;\n    PRAGMA page_size=1024;\n    BEGIN;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    DELETE FROM t1 WHERE rowid>202;\n    COMMIT;\n    VACUUM;\n    PRAGMA cache_size = 10;\n    BEGIN;\n    DELETE FROM t1 WHERE rowid IN (10,11,12) ;\n  } -sqlbody {\n    PRAGMA incremental_vacuum(10);\n    COMMIT;\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr2.test",
    "content": "# 2007 April 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# such as writes failing because the disk is full.\n# \n# The tests in this file use special facilities that are only\n# available in the SQLite test fixture.\n#\n# $Id: ioerr2.test,v 1.12 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !integrityck {\n  finish_test\n  return\n}\n\ndo_test ioerr2-1.1 {\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA default_cache_size = 10;\n    CREATE TABLE t1(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t1 VALUES(randstr(400,400),randstr(400,400));\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 2\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 4\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 8\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 16\n    INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) FROM t1; -- 32\n  }\n} {}\n\nset ::cksum [execsql {SELECT md5sum(a, b) FROM t1}]\nproc check_db {testname} {\n\n  # Make sure no I/O errors are simulated in this proc.\n  set ::sqlite_io_error_hit 0\n  set ::sqlite_io_error_persist 0\n  set ::sqlite_io_error_pending 0\n\n  # Run an integrity-check. If \"disk I/O error\" is returned, the\n  # pager must be in error state. In this case open a new database\n  # connection. Otherwise, try a ROLLBACK, in case a transaction \n  # is still active.\n  set rc [catch {execsql {PRAGMA integrity_check}} msg]\n  if {$rc && ($msg eq \"disk I/O error\" || $msg eq \"database is locked\")} {\n    db close\n    sqlite3 db test.db\n    set refcnt 0\n  } else {\n    if {$rc || $msg ne \"ok\"} {\n      error $msg\n    }\n    catch {execsql ROLLBACK}\n  }\n\n  # Check that the database checksum is still $::cksum, and that\n  # the integrity-check passes.\n  set ck [execsql {SELECT md5sum(a, b) FROM t1}]\n  do_test ${testname}.cksum [list set ck $ck] $::cksum\n  integrity_check ${testname}.integrity\n  do_test ${testname}.refcnt {\n    lindex [sqlite3_pager_refcounts db] 0\n  } 0\n}\n\ncheck_db ioerr2-2\n\nset sql {\n  PRAGMA cache_size = 10;\n  PRAGMA default_cache_size = 10;\n  BEGIN;\n  DELETE FROM t1 WHERE (oid%7)==0;\n  INSERT INTO t1 SELECT randstr(400,400), randstr(400,400) \n    WHERE (random()%7)==0;\n  UPDATE t1 SET a = randstr(400,400), b = randstr(400,400) \n    WHERE (random()%7)==0;\n  ROLLBACK;\n}\n\nforeach bPersist [list 0 1] {\n  set ::go 1\n  for {set ::N 1} {$::go} {incr ::N} {\n    db close\n    sqlite3 db test.db\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_persist $bPersist\n    set ::sqlite_io_error_pending $::N\n\n    foreach {::go res} [catchsql $sql] {}\n    check_db ioerr2-3.$bPersist.$::N\n  }\n}\nforeach bPersist [list 0 1] {\n  set ::go 1\n  for {set ::N 1} {$::go} {incr ::N} {\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_persist $bPersist\n    set ::sqlite_io_error_pending $::N\n\n    foreach {::go res} [catchsql $sql] {}\n    check_db ioerr2-4.[expr {$bPersist+2}].$::N\n  }\n}\n\n# When this test was written, an IO error within the UPDATE statement caused\n# a rollback, which tripped all read-cursors, causing the outer SELECT to\n# fail with \"abort due to ROLLBACK\". Now, the loop continues until the UPDATE\n# is run successfully. At this point the next IO error occurs within the \n# SELECT - throwing the \"disk I/O error\" that the test case now expects.\n#\ndo_test ioerr2-5 {\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    PRAGMA temp_store = memory;\n  }\n  set ::sqlite_io_error_persist 0\n  set ::go 1\n  set rc [catch {\n    for {set ::N 2} {$::N<200} {incr ::N} {\n      db eval {SELECT * FROM t1 WHERE rowid IN (1, 5, 10, 15, 20)} {\n        set ::sqlite_io_error_hit 0\n        set ::sqlite_io_error_pending $::N\n        set sql {UPDATE t2 SET b = randstr(400,400)}\n        foreach {::go res} [catchsql $sql] {}\n      }\n    }\n  } msg]\n  list $rc $msg\n} {1 {disk I/O error}} ;# used to be \"{1 {abort due to ROLLBACK}}\"\n\nif {$::tcl_platform(platform) == \"unix\"} {\n  # Cause the call to xAccess used by [pragma temp_store_directory] to\n  # determine if the specified directory is writable to fail. This causes\n  # SQLite to report \"not a writable directory\", which is probably the\n  # right answer.\n  #\n  do_test ioerr2-6 {\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_pending 1\n    catchsql {PRAGMA temp_store_directory = '/tmp/'}\n  } {1 {not a writable directory}}\n}\n\ndo_ioerr_test ioerr2-7 -persist 0 -sqlprep {\n  PRAGMA cache_size = 10;\n  PRAGMA auto_vacuum = 1;\n  CREATE TABLE ab(a, b);\n  CREATE TABLE de(d, e);\n  INSERT INTO ab VALUES(1, randstr(200,200));\n  INSERT INTO ab SELECT a+1, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+2, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+4, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+8, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+16, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+32, randstr(200,200) FROM ab;\n  INSERT INTO ab SELECT a+64, randstr(200,200) FROM ab;\n  INSERT INTO de SELECT * FROM ab;\n} -sqlbody {\n  BEGIN;\n  UPDATE ab SET b = randstr(200,200);\n  UPDATE de SET e = randstr(200,200) WHERE d = (SELECT max(d) FROM de);\n  DELETE FROM ab;\n  COMMIT;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr3.test",
    "content": "# 2007 December 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# in conjunction with very small soft-heap-limit values.\n#\n# $Id: ioerr3.test,v 1.2 2008/01/19 23:50:26 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_ioerr_test ioerr3-1 -sqlprep {\n  CREATE TABLE t1(id INTEGER, name TEXT);\n} -tclbody {\n  sqlite3_soft_heap_limit 8192\n  db cache size 0\n  execsql BEGIN\n  for {set ii 0} {$ii < 100} {incr ii} {\n    execsql {\n      INSERT INTO t1(id, name) VALUES (1,\n'A1234567890B1234567890C1234567890D1234567890E1234567890F1234567890G1234567890H1234567890I1234567890J1234567890K1234567890L1234567890M1234567890N1234567890O1234567890P1234567890Q1234567890R1234567890'\n      );\n    }\n  }\n  execsql COMMIT\n}\n\ndo_ioerr_test ioerr3-2 -sqlbody {\n  CREATE TEMP TABLE t1(x,y);\n}\n\nsqlite3_soft_heap_limit 0\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr4.test",
    "content": "# 2007 December 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing for correct handling of I/O errors\n# during incremental vacuum with a shared cache.\n#\n# $Id: ioerr4.test,v 1.2 2008/05/08 01:11:42 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This test requires both shared cache and incremental vacuum.\n#\nifcapable {!shared_cache || !autovacuum} {\n  finish_test\n  return\n}\n\n# Enable shared cache mode and incremental vacuum.\n#\ndo_test ioerr4-1.1 {\n  db close\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n} {0}\ndo_test ioerr4-1.2 {\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  db eval {\n    PRAGMA auto_vacuum=INCREMENTAL;\n    CREATE TABLE a(i INTEGER, b BLOB);\n  }\n  db2 eval {\n    SELECT name FROM sqlite_master\n  }\n} {a}\ndo_test ioerr4-1.3 {\n  db eval {\n    PRAGMA auto_vacuum;\n  }\n} {2}\n\n# Insert and delete many records in order to put lots of pages\n# on the freelist.\n#\ndo_test ioerr4-1.4 {\n  db eval {\n    INSERT INTO a VALUES(1, zeroblob(2000));\n    INSERT INTO a VALUES(2, zeroblob(2000));\n    INSERT INTO a SELECT i+2, zeroblob(2000) FROM a;\n    INSERT INTO a SELECT i+4, zeroblob(2000) FROM a;\n    INSERT INTO a SELECT i+8, zeroblob(2000) FROM a;\n    INSERT INTO a SELECT i+16, zeroblob(2000) FROM a;\n    SELECT count(*) FROM a;\n  }\n} {32}\ndo_test ioerr4-1.5 {\n  db eval {\n    PRAGMA freelist_count\n  }\n} {0}\ndo_test ioerr4-1.6 {\n  db eval {\n    DELETE FROM a;\n    PRAGMA freelist_count;\n  }\n} {64}\n\n# Set up for an I/O error on incremental vacuum\n# with two connections on shared cache.\n#\ndb close\ndb2 close\nforcecopy test.db test.db-bu\ndo_ioerr_test ioerr4-2 -tclprep {\n  catch {db2 close}\n  db close\n  forcedelete test.db test.db-journal\n  forcecopy test.db-bu test.db\n  sqlite3_enable_shared_cache 1\n  set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]\n  db eval {PRAGMA auto_vacuum=INCREMENTAL}\n  sqlite3 db2 test.db\n} -tclbody {\n  db eval {PRAGMA incremental_vacuum(5)}\n}\n\ndb2 close\nforcedelete test.db-bu\nsqlite3_enable_shared_cache $::enable_shared_cache\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr5.test",
    "content": "# 2008 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests that if sqlite3_release_memory() is called to reclaim\n# memory from a pager that is in the error-state, SQLite does not \n# incorrectly write dirty pages out to the database (not safe to do\n# once the pager is in error state).\n#\n# $Id: ioerr5.test,v 1.5 2008/08/28 18:35:34 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !memorymanage||!shared_cache {\n  finish_test\n  return\n}\n\ndb close\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\nset ::soft_limit [sqlite3_soft_heap_limit 1048576]\n\n# This procedure prepares, steps and finalizes an SQL statement via the\n# UTF-16 APIs. The text representation of an SQLite error code is returned\n# (\"SQLITE_OK\", \"SQLITE_IOERR\" etc.). The actual results returned by the\n# SQL statement, if it is a SELECT, are not available.\n#\n# This can be useful for testing because it forces SQLite to make an extra \n# call to sqlite3_malloc() when translating from the supplied UTF-16 to\n# the UTF-8 encoding used internally.\n#\nproc dosql16 {zSql {db db}} {\n  set sql [encoding convertto unicode $zSql]\n  append sql \"\\00\\00\"\n  set stmt [sqlite3_prepare16 $db $sql -1 {}]\n  sqlite3_step $stmt\n  set rc [sqlite3_finalize $stmt]\n}\n\nproc compilesql16 {zSql {db db}} {\n  set sql [encoding convertto unicode $zSql]\n  append sql \"\\00\\00\"\n  set stmt [sqlite3_prepare16 $db $sql -1 {}]\n  set rc [sqlite3_finalize $stmt]\n}\n\n# Open two database connections (handle db and db2) to database \"test.db\".\n#\nproc opendatabases {} {\n  catch {db close}\n  catch {db2 close}\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  db2 cache size 0\n  db cache size 0\n  execsql {\n    pragma page_size=512;\n    pragma auto_vacuum=2;\n    pragma cache_size=16;\n  }\n}\n\n# Open two database connections and create a single table in the db.\n#\ndo_test ioerr5-1.0 {\n  opendatabases\n  execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }\n} {}\n\nforeach locking_mode {normal exclusive} {\n  set nPage 2\n  for {set iFail 1} {$iFail<200} {incr iFail} {\n    sqlite3_soft_heap_limit 1048576\n    opendatabases\n    execsql { pragma locking_mode=exclusive }\n    set nRow [db one {SELECT count(*) FROM a}]\n  \n    # Dirty (at least) one of the pages in the cache.\n    do_test ioerr5-1.$locking_mode-$iFail.1 {\n      execsql {\n        BEGIN EXCLUSIVE;\n        INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');\n      }\n    } {}\n\n    # Open a read-only cursor on table \"a\". If the COMMIT below is\n    # interrupted by a persistent IO error, the pager will transition to \n    # PAGER_ERROR state. If there are no other read-only cursors open,\n    # from there the pager immediately discards all cached data and \n    # switches to PAGER_OPEN state. This read-only cursor stops that\n    # from happening, leaving the pager stuck in PAGER_ERROR state.\n    #\n    set channel [db incrblob -readonly a Name [db last_insert_rowid]]\n  \n    # Now try to commit the transaction. Cause an IO error to occur\n    # within this operation, which moves the pager into the error state.\n    #\n    set ::sqlite_io_error_persist 1\n    set ::sqlite_io_error_pending $iFail\n    do_test ioerr5-1.$locking_mode-$iFail.2 {\n      set rc [catchsql {COMMIT}]\n      list\n    } {}\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_persist 0\n    set ::sqlite_io_error_pending 0\n  \n    # Read the contents of the database file into a Tcl variable.\n    #\n    set fd [open test.db]\n    fconfigure $fd -translation binary -encoding binary\n    set zDatabase [read $fd]\n    close $fd\n\n    # Set a very low soft-limit and then try to compile an SQL statement \n    # from UTF-16 text. To do this, SQLite will need to reclaim memory\n    # from the pager that is in error state. Including that associated\n    # with the dirty page.\n    #\n    do_test ioerr5-1.$locking_mode-$iFail.3 {\n      sqlite3_soft_heap_limit 1024\n      compilesql16 \"SELECT 10\"\n    } {SQLITE_OK}\n\n    close $channel\n\n    # Ensure that nothing was written to the database while reclaiming\n    # memory from the pager in error state.\n    #\n    do_test ioerr5-1.$locking_mode-$iFail.4 {\n      set fd [open test.db]\n      fconfigure $fd -translation binary -encoding binary\n      set zDatabase2 [read $fd]\n      close $fd\n      expr {$zDatabase eq $zDatabase2}\n    } {1}\n\n    if {$rc eq [list 0 {}]} {\n      do_test ioerr5.1-$locking_mode-$iFail.3 {\n        execsql { SELECT count(*) FROM a }\n      } [expr $nRow+1]\n      break\n    }\n  }\n}\n\n# Make sure this test script doesn't leave any files open.\n#\ndo_test ioerr5-1.X {\n  catch { db close }\n  catch { db2 close }\n  set sqlite_open_file_count\n} 0\n\ndo_test ioerr5-2.0 {\n  sqlite3 db test.db\n  execsql { CREATE INDEX i1 ON a(id, name); }\n} {}\n\nforeach locking_mode {exclusive normal} {\n  for {set iFail 1} {$iFail<200} {incr iFail} {\n    sqlite3_soft_heap_limit 1048576\n    opendatabases\n    execsql { pragma locking_mode=exclusive }\n    set nRow [db one {SELECT count(*) FROM a}]\n  \n    do_test ioerr5-2.$locking_mode-$iFail.1 {\n      execsql {\n        BEGIN EXCLUSIVE;\n        INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');\n      }\n    } {}\n\n    set ::sqlite_io_error_persist 1\n    set ::sqlite_io_error_pending $iFail\n\n    sqlite3_release_memory 10000\n\n    set error_hit $::sqlite_io_error_hit\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_persist 0\n    set ::sqlite_io_error_pending 0\n    if {$error_hit} {\n      do_test ioerr5-2.$locking_mode-$iFail.3a {\n        catchsql COMMIT\n      } {1 {disk I/O error}}\n    } else {\n      do_test ioerr5-2.$locking_mode-$iFail.3b {\n        execsql COMMIT\n      } {}\n      break\n    }\n  }\n}\n\n# Make sure this test script doesn't leave any files open.\n#\ndo_test ioerr5-2.X {\n  catch { db close }\n  catch { db2 close }\n  set sqlite_open_file_count\n} 0\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nsqlite3_soft_heap_limit $::soft_limit\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ioerr6.test",
    "content": "# 2012 December 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix ioerr6\n\nifcapable !atomicwrite {\n  puts \"skipping tests - not compiled with SQLITE_ENABLE_ATOMIC_WRITE...\"\n  finish_test\n  return\n}\n\nif {[permutation]==\"inmemory_journal\"} {\n  # These tests will not work with in-memory journals (as persistent VFS\n  # errors commencing after a transaction has started to write to the db\n  # cannot be recovered from).\n  finish_test\n  return\n}\n\nfaultsim_save_and_close\n\ndo_test 1.1 {\n  testvfs shmfault -default true\n  shmfault devchar atomic\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(2, 4);\n    INSERT INTO t1 VALUES(3, 6);\n    INSERT INTO t1 VALUES(4, 8);\n  }\n\n  # Cause the first call to xWrite() to fail with SQLITE_FULL.\n  shmfault full 2 1\n  catchsql { INSERT INTO t1 VALUES(5, 10) }\n} {1 {database or disk is full}}\n\ndo_test 1.2 {\n  execsql { PRAGMA integrity_check }\n} {ok}\n\ndb close\nshmfault delete\n\ndo_faultsim_test 2 -faults full* -prep {\n  shmfault devchar atomic\n  faultsim_restore\n  sqlite3 db test.db\n} -body {\n  db eval {\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES('abc');\n  }\n} -test {\n  set res [db one { PRAGMA integrity_check }]\n  if {$res != \"ok\"} {\n    error \"integrity check: $res\"\n  }\n}\n\ndo_faultsim_test 3 -faults full* -prep {\n  shmfault devchar atomic\n  faultsim_restore\n  sqlite3 db test.db\n} -body {\n  db eval {\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(x);\n  }\n} -test {\n  db eval { CREATE TABLE t3(x) }\n  if {[db one { PRAGMA integrity_check }] != \"ok\"} {\n    error \"integrity check failed\"\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join.test",
    "content": "# 2002-05-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for joins, including outer joins.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test join-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(2,3,4);\n    INSERT INTO t1 VALUES(3,4,5);\n    SELECT * FROM t1;\n  }  \n} {1 2 3 2 3 4 3 4 5}\ndo_test join-1.2 {\n  execsql {\n    CREATE TABLE t2(b,c,d);\n    INSERT INTO t2 VALUES(1,2,3);\n    INSERT INTO t2 VALUES(2,3,4);\n    INSERT INTO t2 VALUES(3,4,5);\n    SELECT * FROM t2;\n  }  \n} {1 2 3 2 3 4 3 4 5}\n\n# A FROM clause of the form:  \"<table>, <table> ON <expr>\" is not\n# allowed by the SQLite syntax diagram, nor by any other SQL database\n# engine that we are aware of.  Nevertheless, historic versions of\n# SQLite have allowed it.  We need to continue to support it moving\n# forward to prevent breakage of legacy applications.  Though, we will\n# not advertise it as being supported.\n#\ndo_execsql_test join-1.2.1 {\n  SELECT t1.rowid, t2.rowid, '|' FROM t1, t2 ON t1.a=t2.b;\n} {1 1 | 2 2 | 3 3 |}\n\ndo_test join-1.3 {\n  execsql2 {\n    SELECT * FROM t1 NATURAL JOIN t2;\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test join-1.3.1 {\n  execsql2 {\n    SELECT * FROM t2 NATURAL JOIN t1;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test join-1.3.2 {\n  execsql2 {\n    SELECT * FROM t2 AS x NATURAL JOIN t1;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test join-1.3.3 {\n  execsql2 {\n    SELECT * FROM t2 NATURAL JOIN t1 AS y;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test join-1.3.4 {\n  execsql {\n    SELECT b FROM t1 NATURAL JOIN t2;\n  }\n} {2 3}\n\n# ticket #3522\ndo_test join-1.3.5 {\n  execsql2 {\n    SELECT t2.* FROM t2 NATURAL JOIN t1\n  }\n} {b 2 c 3 d 4 b 3 c 4 d 5}\ndo_test join-1.3.6 {\n  execsql2 {\n    SELECT xyzzy.* FROM t2 AS xyzzy NATURAL JOIN t1\n  }\n} {b 2 c 3 d 4 b 3 c 4 d 5}\ndo_test join-1.3.7 {\n  execsql2 {\n    SELECT t1.* FROM t2 NATURAL JOIN t1\n  }\n} {a 1 b 2 c 3 a 2 b 3 c 4}\ndo_test join-1.3.8 {\n  execsql2 {\n    SELECT xyzzy.* FROM t2 NATURAL JOIN t1 AS xyzzy\n  }\n} {a 1 b 2 c 3 a 2 b 3 c 4}\ndo_test join-1.3.9 {\n  execsql2 {\n    SELECT aaa.*, bbb.* FROM t2 AS aaa NATURAL JOIN t1 AS bbb\n  }\n} {b 2 c 3 d 4 a 1 b 2 c 3 b 3 c 4 d 5 a 2 b 3 c 4}\ndo_test join-1.3.10 {\n  execsql2 {\n    SELECT t1.*, t2.* FROM t2 NATURAL JOIN t1\n  }\n} {a 1 b 2 c 3 b 2 c 3 d 4 a 2 b 3 c 4 b 3 c 4 d 5}\n\n\ndo_test join-1.4.1 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test join-1.4.2 {\n  execsql2 {\n    SELECT * FROM t1 AS x INNER JOIN t2 USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test join-1.4.3 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 AS y USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test join-1.4.4 {\n  execsql2 {\n    SELECT * FROM t1 AS x INNER JOIN t2 AS y USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test join-1.4.5 {\n  execsql {\n    SELECT b FROM t1 JOIN t2 USING(b);\n  }\n} {2 3}\n\n# Ticket #3522\ndo_test join-1.4.6 {\n  execsql2 {\n    SELECT t1.* FROM t1 JOIN t2 USING(b);\n  }\n} {a 1 b 2 c 3 a 2 b 3 c 4}\ndo_test join-1.4.7 {\n  execsql2 {\n    SELECT t2.* FROM t1 JOIN t2 USING(b);\n  }\n} {b 2 c 3 d 4 b 3 c 4 d 5}\n\ndo_test join-1.5 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(b);\n  }\n} {a 1 b 2 c 3 c 3 d 4 a 2 b 3 c 4 c 4 d 5}\ndo_test join-1.6 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(c);\n  }\n} {a 1 b 2 c 3 b 2 d 4 a 2 b 3 c 4 b 3 d 5}\ndo_test join-1.7 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(c,b);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\n\ndo_test join-1.8 {\n  execsql {\n    SELECT * FROM t1 NATURAL CROSS JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test join-1.9 {\n  execsql {\n    SELECT * FROM t1 CROSS JOIN t2 USING(b,c);\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test join-1.10 {\n  execsql {\n    SELECT * FROM t1 NATURAL INNER JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test join-1.11 {\n  execsql {\n    SELECT * FROM t1 INNER JOIN t2 USING(b,c);\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test join-1.12 {\n  execsql {\n    SELECT * FROM t1 natural inner join t2;\n  }\n} {1 2 3 4 2 3 4 5}\n\nifcapable subquery {\n  do_test join-1.13 {\n    execsql2 {\n      SELECT * FROM t1 NATURAL JOIN \n        (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as t3\n    }\n  } {a 1 b 2 c 3 d 4 e 5}\n  do_test join-1.14 {\n    execsql2 {\n      SELECT * FROM (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as 'tx'\n          NATURAL JOIN t1\n    }\n  } {c 3 d 4 e 5 a 1 b 2}\n}\n\ndo_test join-1.15 {\n  execsql {\n    CREATE TABLE t3(c,d,e);\n    INSERT INTO t3 VALUES(2,3,4);\n    INSERT INTO t3 VALUES(3,4,5);\n    INSERT INTO t3 VALUES(4,5,6);\n    SELECT * FROM t3;\n  }  \n} {2 3 4 3 4 5 4 5 6}\ndo_test join-1.16 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t3;\n  }\n} {1 2 3 4 5 2 3 4 5 6}\ndo_test join-1.17 {\n  execsql2 {\n    SELECT * FROM t1 natural join t2 natural join t3;\n  }\n} {a 1 b 2 c 3 d 4 e 5 a 2 b 3 c 4 d 5 e 6}\ndo_test join-1.18 {\n  execsql {\n    CREATE TABLE t4(d,e,f);\n    INSERT INTO t4 VALUES(2,3,4);\n    INSERT INTO t4 VALUES(3,4,5);\n    INSERT INTO t4 VALUES(4,5,6);\n    SELECT * FROM t4;\n  }  \n} {2 3 4 3 4 5 4 5 6}\ndo_test join-1.19.1 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t4;\n  }\n} {1 2 3 4 5 6}\ndo_test join-1.19.2 {\n  execsql2 {\n    SELECT * FROM t1 natural join t2 natural join t4;\n  }\n} {a 1 b 2 c 3 d 4 e 5 f 6}\ndo_test join-1.20 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t3 WHERE t1.a=1\n  }\n} {1 2 3 4 5}\n\ndo_test join-2.1 {\n  execsql {\n    SELECT * FROM t1 NATURAL LEFT JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5 3 4 5 {}}\n\n# ticket #3522\ndo_test join-2.1.1 {\n  execsql2 {\n    SELECT * FROM t1 NATURAL LEFT JOIN t2;\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5 a 3 b 4 c 5 d {}}\ndo_test join-2.1.2 {\n  execsql2 {\n    SELECT t1.* FROM t1 NATURAL LEFT JOIN t2;\n  }\n} {a 1 b 2 c 3 a 2 b 3 c 4 a 3 b 4 c 5}\ndo_test join-2.1.3 {\n  execsql2 {\n    SELECT t2.* FROM t1 NATURAL LEFT JOIN t2;\n  }\n} {b 2 c 3 d 4 b 3 c 4 d 5 b {} c {} d {}}\n\ndo_test join-2.2 {\n  execsql {\n    SELECT * FROM t2 NATURAL LEFT OUTER JOIN t1;\n  }\n} {1 2 3 {} 2 3 4 1 3 4 5 2}\ndo_test join-2.3 {\n  catchsql {\n    SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2;\n  }\n} {1 {RIGHT and FULL OUTER JOINs are not currently supported}}\ndo_test join-2.4 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d\n  }\n} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3}\ndo_test join-2.5 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t1.a>1\n  }\n} {2 3 4 {} {} {} 3 4 5 1 2 3}\ndo_test join-2.6 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t2.b IS NULL OR t2.b>1\n  }\n} {1 2 3 {} {} {} 2 3 4 {} {} {}}\n\ndo_test join-3.1 {\n  catchsql {\n    SELECT * FROM t1 NATURAL JOIN t2 ON t1.a=t2.b;\n  }\n} {1 {a NATURAL join may not have an ON or USING clause}}\ndo_test join-3.2 {\n  catchsql {\n    SELECT * FROM t1 NATURAL JOIN t2 USING(b);\n  }\n} {1 {a NATURAL join may not have an ON or USING clause}}\ndo_test join-3.3 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 ON t1.a=t2.b USING(b);\n  }\n} {1 {cannot have both ON and USING clauses in the same join}}\ndo_test join-3.4.1 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 USING(a);\n  }\n} {1 {cannot join using column a - column not present in both tables}}\ndo_test join-3.4.2 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 USING(d);\n  }\n} {1 {cannot join using column d - column not present in both tables}}\ndo_test join-3.5 {\n  catchsql { SELECT * FROM t1 USING(a) }\n} {1 {a JOIN clause is required before USING}}\ndo_test join-3.6 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 ON t3.a=t2.b;\n  }\n} {1 {no such column: t3.a}}\ndo_test join-3.7 {\n  catchsql {\n    SELECT * FROM t1 INNER OUTER JOIN t2;\n  }\n} {1 {unknown or unsupported join type: INNER OUTER}}\ndo_test join-3.8 {\n  catchsql {\n    SELECT * FROM t1 INNER OUTER CROSS JOIN t2;\n  }\n} {1 {unknown or unsupported join type: INNER OUTER CROSS}}\ndo_test join-3.9 {\n  catchsql {\n    SELECT * FROM t1 OUTER NATURAL INNER JOIN t2;\n  }\n} {1 {unknown or unsupported join type: OUTER NATURAL INNER}}\ndo_test join-3.10 {\n  catchsql {\n    SELECT * FROM t1 LEFT BOGUS JOIN t2;\n  }\n} {1 {unknown or unsupported join type: LEFT BOGUS}}\ndo_test join-3.11 {\n  catchsql {\n    SELECT * FROM t1 INNER BOGUS CROSS JOIN t2;\n  }\n} {1 {unknown or unsupported join type: INNER BOGUS CROSS}}\ndo_test join-3.12 {\n  catchsql {\n    SELECT * FROM t1 NATURAL AWK SED JOIN t2;\n  }\n} {1 {unknown or unsupported join type: NATURAL AWK SED}}\n\ndo_test join-4.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t5(a INTEGER PRIMARY KEY);\n    CREATE TABLE t6(a INTEGER);\n    INSERT INTO t6 VALUES(NULL);\n    INSERT INTO t6 VALUES(NULL);\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    COMMIT;\n  }\n  execsql {\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test join-4.2 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test join-4.3 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\ndo_test join-4.4 {\n  execsql {\n    UPDATE t6 SET a='xyz';\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test join-4.6 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test join-4.7 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\ndo_test join-4.8 {\n  execsql {\n    UPDATE t6 SET a=1;\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test join-4.9 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test join-4.10 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\n\ndo_test join-5.1 {\n  execsql {\n    BEGIN;\n    create table centros (id integer primary key, centro);\n    INSERT INTO centros VALUES(1,'xxx');\n    create table usuarios (id integer primary key, nombre, apellidos,\n    idcentro integer);\n    INSERT INTO usuarios VALUES(1,'a','aa',1);\n    INSERT INTO usuarios VALUES(2,'b','bb',1);\n    INSERT INTO usuarios VALUES(3,'c','cc',NULL);\n    create index idcentro on usuarios (idcentro);\n    END;\n    select usuarios.id, usuarios.nombre, centros.centro from\n    usuarios left outer join centros on usuarios.idcentro = centros.id;\n  }\n} {1 a xxx 2 b xxx 3 c {}}\n\n# A test for ticket #247.\n#\ndo_test join-7.1 {\n  execsql {\n    CREATE TABLE t7 (x, y);\n    INSERT INTO t7 VALUES (\"pa1\", 1);\n    INSERT INTO t7 VALUES (\"pa2\", NULL);\n    INSERT INTO t7 VALUES (\"pa3\", NULL);\n    INSERT INTO t7 VALUES (\"pa4\", 2);\n    INSERT INTO t7 VALUES (\"pa30\", 131);\n    INSERT INTO t7 VALUES (\"pa31\", 130);\n    INSERT INTO t7 VALUES (\"pa28\", NULL);\n\n    CREATE TABLE t8 (a integer primary key, b);\n    INSERT INTO t8 VALUES (1, \"pa1\");\n    INSERT INTO t8 VALUES (2, \"pa4\");\n    INSERT INTO t8 VALUES (3, NULL);\n    INSERT INTO t8 VALUES (4, NULL);\n    INSERT INTO t8 VALUES (130, \"pa31\");\n    INSERT INTO t8 VALUES (131, \"pa30\");\n\n    SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a;\n  }\n} {1 999 999 2 131 130 999}\n\n# Make sure a left join where the right table is really a view that\n# is itself a join works right.  Ticket #306.\n#\nifcapable view {\ndo_test join-8.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t9(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t9 VALUES(1,11);\n    INSERT INTO t9 VALUES(2,22);\n    CREATE TABLE t10(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t10 VALUES(1,2);\n    INSERT INTO t10 VALUES(3,3);    \n    CREATE TABLE t11(p INTEGER PRIMARY KEY, q);\n    INSERT INTO t11 VALUES(2,111);\n    INSERT INTO t11 VALUES(3,333);    \n    CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p;\n    COMMIT;\n    SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x );\n  }\n} {1 11 1 111 2 22 {} {}}\nifcapable subquery {\n  do_test join-8.2 {\n    execsql {\n      SELECT * FROM t9 LEFT JOIN (SELECT x, q FROM t10, t11 WHERE t10.y=t11.p)\n           ON( a=x);\n    }\n  } {1 11 1 111 2 22 {} {}}\n}\ndo_test join-8.3 {\n  execsql {\n    SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x );\n  }\n} {1 111 1 11 3 333 {} {}}\nifcapable subquery {\n  # Constant expressions in a subquery that is the right element of a\n  # LEFT JOIN evaluate to NULL for rows where the LEFT JOIN does not\n  # match.  Ticket #3300\n  do_test join-8.4 {\n    execsql {\n      SELECT * FROM t9 LEFT JOIN (SELECT 44, p, q FROM t11) AS sub1 ON p=a\n    }\n  } {1 11 {} {} {} 2 22 44 2 111}\n}\n} ;# ifcapable view\n\n# Ticket #350 describes a scenario where LEFT OUTER JOIN does not\n# function correctly if the right table in the join is really\n# subquery.\n#\n# To test the problem, we generate the same LEFT OUTER JOIN in two\n# separate selects but with on using a subquery and the other calling\n# the table directly.  Then connect the two SELECTs using an EXCEPT.\n# Both queries should generate the same results so the answer should\n# be an empty set.\n#\nifcapable compound {\ndo_test join-9.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t12(a,b);\n    INSERT INTO t12 VALUES(1,11);\n    INSERT INTO t12 VALUES(2,22);\n    CREATE TABLE t13(b,c);\n    INSERT INTO t13 VALUES(22,222);\n    COMMIT;\n  }\n} {}\n\nifcapable subquery {\n  do_test join-9.1.1 {\n    execsql {\n      SELECT * FROM t12 NATURAL LEFT JOIN t13\n      EXCEPT\n      SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0);\n    }\n  } {}\n}\nifcapable view {\n  do_test join-9.2 {\n    execsql {\n      CREATE VIEW v13 AS SELECT * FROM t13 WHERE b>0;\n      SELECT * FROM t12 NATURAL LEFT JOIN t13\n        EXCEPT\n        SELECT * FROM t12 NATURAL LEFT JOIN v13;\n    }\n  } {}\n} ;# ifcapable view\n} ;# ifcapable compound\n\nifcapable subquery {\n  # Ticket #1697:  Left Join WHERE clause terms that contain an\n  # aggregate subquery.\n  #\n  do_test join-10.1 {\n    execsql {\n      CREATE TABLE t21(a,b,c);\n      CREATE TABLE t22(p,q);\n      CREATE INDEX i22 ON t22(q);\n      SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=\n         (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);\n    }  \n  } {}\n\n  # Test a LEFT JOIN when the right-hand side of hte join is an empty\n  # sub-query. Seems fine.\n  #\n  do_test join-10.2 {\n    execsql {\n      CREATE TABLE t23(a, b, c);\n      CREATE TABLE t24(a, b, c);\n      INSERT INTO t23 VALUES(1, 2, 3);\n    }\n    execsql {\n      SELECT * FROM t23 LEFT JOIN t24;\n    }\n  } {1 2 3 {} {} {}}\n  do_test join-10.3 {\n    execsql {\n      SELECT * FROM t23 LEFT JOIN (SELECT * FROM t24);\n    }\n  } {1 2 3 {} {} {}}\n\n} ;# ifcapable subquery\n\n#-------------------------------------------------------------------------\n# The following tests are to ensure that bug b73fb0bd64 is fixed.\n#\ndo_test join-11.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t1 VALUES(1,'abc');\n    INSERT INTO t1 VALUES(2,'def');\n    INSERT INTO t2 VALUES(1,'abc');\n    INSERT INTO t2 VALUES(2,'def');\n    SELECT * FROM t1 NATURAL JOIN t2;\n  }\n} {1 abc 2 def}\n\ndo_test join-11.2 {\n  execsql { SELECT a FROM t1 JOIN t1 USING (a)}\n} {1 2}\ndo_test join-11.3 {\n  execsql { SELECT a FROM t1 JOIN t1 AS t2 USING (a)}\n} {1 2}\ndo_test join-11.3 {\n  execsql { SELECT * FROM t1 NATURAL JOIN t1 AS t2}\n} {1 abc 2 def}\ndo_test join-11.4 {\n  execsql { SELECT * FROM t1 NATURAL JOIN t1 }\n} {1 abc 2 def}\n\ndo_test join-11.5 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a COLLATE nocase, b);\n    CREATE TABLE t2(a, b);\n    INSERT INTO t1 VALUES('ONE', 1);\n    INSERT INTO t1 VALUES('two', 2);\n    INSERT INTO t2 VALUES('one', 1);\n    INSERT INTO t2 VALUES('two', 2);\n  }\n} {}\ndo_test join-11.6 {\n  execsql { SELECT * FROM t1 NATURAL JOIN t2 }\n} {ONE 1 two 2}\ndo_test join-11.7 {\n  execsql { SELECT * FROM t2 NATURAL JOIN t1 }\n} {two 2}\n\ndo_test join-11.8 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a, b TEXT);\n    CREATE TABLE t2(b INTEGER, a);\n    INSERT INTO t1 VALUES('one', '1.0');\n    INSERT INTO t1 VALUES('two', '2');\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(2, 'two');\n  }\n} {}\ndo_test join-11.9 {\n  execsql { SELECT * FROM t1 NATURAL JOIN t2 }\n} {one 1.0 two 2}\ndo_test join-11.10 {\n  execsql { SELECT * FROM t2 NATURAL JOIN t1 }\n} {1 one 2 two}\n\n#-------------------------------------------------------------------------\n# Test that at most 64 tables are allowed in a join.\n#\ndo_execsql_test join-12.1 {\n  CREATE TABLE t14(x);\n  INSERT INTO t14 VALUES('abcdefghij');\n}\n\nproc jointest {tn nTbl res} {\n  set sql \"SELECT 1 FROM [string repeat t14, [expr $nTbl-1]] t14;\"\n  uplevel [list do_catchsql_test $tn $sql $res]\n}\n\njointest join-12.2 30 {0 1}\njointest join-12.3 63 {0 1}\njointest join-12.4 64 {0 1}\njointest join-12.5 65 {1 {at most 64 tables in a join}}\njointest join-12.6 66 {1 {at most 64 tables in a join}}\njointest join-12.7 127 {1 {at most 64 tables in a join}}\njointest join-12.8 128 {1 {at most 64 tables in a join}}\njointest join-12.9 1000 {1 {at most 64 tables in a join}}\n\n# If SQLite is built with SQLITE_MEMDEBUG, then the huge number of realloc()\n# calls made by the following test cases are too time consuming to run.\n# Without SQLITE_MEMDEBUG, realloc() is fast enough that these are not\n# a problem.\nifcapable pragma&&compileoption_diags {\n  if {[lsearch [db eval {PRAGMA compile_options}] MEMDEBUG]<0} {\n    jointest join-12.10 65534 {1 {at most 64 tables in a join}}\n    jointest join-12.11 65535 {1 {too many references to \"t14\": max 65535}}\n    jointest join-12.12 65536 {1 {too many references to \"t14\": max 65535}}\n    jointest join-12.13 65537 {1 {too many references to \"t14\": max 65535}}\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# Test a problem with reordering tables following a LEFT JOIN.\n#\ndo_execsql_test join-13.0 {\n  CREATE TABLE aa(a);\n  CREATE TABLE bb(b);\n  CREATE TABLE cc(c);\n\n  INSERT INTO aa VALUES(45);\n  INSERT INTO cc VALUES(45);\n  INSERT INTO cc VALUES(45);\n}\n\ndo_execsql_test join-13.1 {\n  SELECT * FROM aa LEFT JOIN bb, cc WHERE cc.c=aa.a;\n} {45 {} 45 45 {} 45}\n\n# In the following, the order of [cc] and [bb] must not be exchanged, even\n# though this would be helpful if the query used an inner join.\ndo_execsql_test join-13.2 {\n  CREATE INDEX ccc ON cc(c);\n  SELECT * FROM aa LEFT JOIN bb, cc WHERE cc.c=aa.a;\n} {45 {} 45 45 {} 45}\n\n# Verify that that iTable attributes the TK_IF_NULL_ROW operators in the\n# expression tree are correctly updated by the query flattener.  This was\n# a bug discovered on 2017-05-22 by Mark Brand.\n#\ndo_execsql_test join-14.1 {\n  SELECT *\n    FROM (SELECT 1 a) AS x \n         LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT 1)));\n} {1 1 1}\ndo_execsql_test join-14.2 {\n  SELECT *\n  FROM (SELECT 1 a) AS x\n    LEFT JOIN (SELECT 1, * FROM (SELECT * FROM (SELECT * FROM (SELECT 1)))) AS y\n    JOIN (SELECT * FROM (SELECT 9)) AS z;\n} {1 1 1 9}\ndo_execsql_test join-14.3 {\n  SELECT *\n  FROM (SELECT 111)\n  LEFT JOIN (SELECT cc+222, * FROM (SELECT * FROM (SELECT 333 cc)));\n} {111 555 333}\n\ndo_execsql_test join-14.4 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(c PRIMARY KEY, a TEXT(10000), b TEXT(10000));\n  SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;\n} {111 {}}\ndo_execsql_test join-14.5 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(c PRIMARY KEY) WITHOUT ROWID;\n  SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1;\n} {111 {}}\n\n# Verify the fix to ticket \n# https://www.sqlite.org/src/tktview/7fde638e94287d2c948cd9389\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test join-14.10 {\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(1),(2),(3);\n  CREATE VIEW v2 AS SELECT a, 1 AS b FROM t1;\n  CREATE TABLE t3(x);\n  INSERT INTO t3 VALUES(2),(4);\n  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b=1;\n} {2 2 1 |}\ndo_execsql_test join-14.11 {\n  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x WHERE b+1=x;\n} {2 2 1 |}\ndo_execsql_test join-14.12 {\n  SELECT *, '|' FROM t3 LEFT JOIN v2 ON a=x ORDER BY b;\n} {4 {} {} | 2 2 1 |}\n\n# Verify the fix for ticket\n# https://www.sqlite.org/src/info/892fc34f173e99d8\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test join-14.20 {\n  CREATE TABLE t1(id INTEGER PRIMARY KEY);\n  CREATE TABLE t2(id INTEGER PRIMARY KEY, c2 INTEGER);\n  CREATE TABLE t3(id INTEGER PRIMARY KEY, c3 INTEGER);\n  INSERT INTO t1(id) VALUES(456);\n  INSERT INTO t3(id) VALUES(1),(2);\n  SELECT t1.id, x2.id, x3.id\n  FROM t1\n  LEFT JOIN (SELECT * FROM t2) AS x2 ON t1.id=x2.c2\n  LEFT JOIN t3 AS x3 ON x2.id=x3.c3;\n} {456 {} {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join2.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for joins, including outer joins.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix join2\n\ndo_test join2-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,11);\n    INSERT INTO t1 VALUES(2,22);\n    INSERT INTO t1 VALUES(3,33);\n    SELECT * FROM t1;\n  }  \n} {1 11 2 22 3 33}\ndo_test join2-1.2 {\n  execsql {\n    CREATE TABLE t2(b,c);\n    INSERT INTO t2 VALUES(11,111);\n    INSERT INTO t2 VALUES(33,333);\n    INSERT INTO t2 VALUES(44,444);\n    SELECT * FROM t2;\n  }  \n} {11 111 33 333 44 444};\ndo_test join2-1.3 {\n  execsql {\n    CREATE TABLE t3(c,d);\n    INSERT INTO t3 VALUES(111,1111);\n    INSERT INTO t3 VALUES(444,4444);\n    INSERT INTO t3 VALUES(555,5555);\n    SELECT * FROM t3;\n  }  \n} {111 1111 444 4444 555 5555}\n\ndo_test join2-1.4 {\n  execsql {\n    SELECT * FROM\n      t1 NATURAL JOIN t2 NATURAL JOIN t3\n  }\n} {1 11 111 1111}\ndo_test join2-1.5 {\n  execsql {\n    SELECT * FROM\n      t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3\n  }\n} {1 11 111 1111 3 33 333 {}}\ndo_test join2-1.6 {\n  execsql {\n    SELECT * FROM\n      t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3\n  }\n} {1 11 111 1111}\nifcapable subquery {\n  do_test join2-1.7 {\n    execsql {\n      SELECT * FROM\n        t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3)\n    }\n  } {1 11 111 1111 2 22 {} {} 3 33 {} {}}\n}\n\n#-------------------------------------------------------------------------\n# Check that ticket [25e335f802ddc] has been resolved. It should be an\n# error for the ON clause of a LEFT JOIN to refer to a table to its right.\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE aa(a);\n  CREATE TABLE bb(b);\n  CREATE TABLE cc(c);\n  INSERT INTO aa VALUES('one');\n  INSERT INTO bb VALUES('one');\n  INSERT INTO cc VALUES('one');\n}\n\ndo_catchsql_test 2.1 {\n  SELECT * FROM aa LEFT JOIN cc ON (a=b) JOIN bb ON (b=c);\n} {1 {ON clause references tables to its right}}\ndo_catchsql_test 2.2 {\n  SELECT * FROM aa JOIN cc ON (a=b) JOIN bb ON (b=c);\n} {0 {one one one}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join3.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for joins, including outer joins, where\n# there are a large number of tables involved in the join.\n#\n# $Id: join3.test,v 1.4 2005/01/19 23:24:51 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# An unrestricted join\n#\ncatch {unset ::result}\nset result {}\nfor {set N 1} {$N<=$bitmask_size} {incr N} {\n  lappend result $N\n  do_test join3-1.$N {\n    execsql \"CREATE TABLE t${N}(x);\"\n    execsql \"INSERT INTO t$N VALUES($N)\"\n    set sql \"SELECT * FROM t1\"\n    for {set i 2} {$i<=$N} {incr i} {append sql \", t$i\"}\n    execsql $sql\n  } $result\n}\n\n# Joins with a comparison\n#\nset result {}\nfor {set N 1} {$N<=$bitmask_size} {incr N} {\n  lappend result $N\n  do_test join3-2.$N {\n    set sql \"SELECT * FROM t1\"\n    for {set i 2} {$i<=$N} {incr i} {append sql \", t$i\"}\n    set sep WHERE\n    for {set i 1} {$i<$N} {incr i} {\n      append sql \" $sep t[expr {$i+1}].x==t$i.x+1\"\n      set sep AND\n    }\n    execsql $sql\n  } $result\n}\n\n# Error of too many tables in the join\n#\ndo_test join3-3.1 {\n  set sql \"SELECT * FROM t1 AS t0, t1\"\n  for {set i 2} {$i<=$bitmask_size} {incr i} {append sql \", t$i\"}\n  catchsql $sql\n} [list 1 \"at most $bitmask_size tables in a join\"]\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join4.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for left outer joins containing WHERE\n# clauses that restrict the scope of the left term of the join.\n#\n# $Id: join4.test,v 1.4 2005/03/29 03:11:00 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable tempdb {\n  do_test join4-1.1 {\n    execsql {\n      create temp table t1(a integer, b varchar(10));\n      insert into t1 values(1,'one');\n      insert into t1 values(2,'two');\n      insert into t1 values(3,'three');\n      insert into t1 values(4,'four');\n  \n      create temp table t2(x integer, y varchar(10), z varchar(10));\n      insert into t2 values(2,'niban','ok');\n      insert into t2 values(4,'yonban','err');\n    }\n    execsql {\n      select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'\n    }\n  } {2 two 2 niban ok}\n} else {\n  do_test join4-1.1 {\n    execsql {\n      create table t1(a integer, b varchar(10));\n      insert into t1 values(1,'one');\n      insert into t1 values(2,'two');\n      insert into t1 values(3,'three');\n      insert into t1 values(4,'four');\n  \n      create table t2(x integer, y varchar(10), z varchar(10));\n      insert into t2 values(2,'niban','ok');\n      insert into t2 values(4,'yonban','err');\n    }\n    execsql {\n      select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'\n    }\n  } {2 two 2 niban ok}\n}\ndo_test join4-1.2 {\n  execsql {\n    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'\n  }\n} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}\ndo_test join4-1.3 {\n  execsql {\n    create index i2 on t2(z);\n  }\n  execsql {\n    select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'\n  }\n} {2 two 2 niban ok}\ndo_test join4-1.4 {\n  execsql {\n    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'\n  }\n} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}\ndo_test join4-1.5 {\n  execsql {\n    select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'\n  }\n} {2 two 2 niban ok}\ndo_test join4-1.4 {\n  execsql {\n    select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'\n  }\n} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}\nifcapable subquery {\n  do_test join4-1.6 {\n    execsql {\n      select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')\n    }\n  } {2 two 2 niban ok}\n  do_test join4-1.7 {\n    execsql {\n      select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')\n    }\n  } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join5.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for left outer joins containing ON\n# clauses that restrict the scope of the left term of the join.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix join5\n\n\ndo_test join5-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a integer primary key, b integer, c integer);\n    CREATE TABLE t2(x integer primary key, y);\n    CREATE TABLE t3(p integer primary key, q);\n    INSERT INTO t3 VALUES(11,'t3-11');\n    INSERT INTO t3 VALUES(12,'t3-12');\n    INSERT INTO t2 VALUES(11,'t2-11');\n    INSERT INTO t2 VALUES(12,'t2-12');\n    INSERT INTO t1 VALUES(1, 5, 0);\n    INSERT INTO t1 VALUES(2, 11, 2);\n    INSERT INTO t1 VALUES(3, 12, 1);\n    COMMIT;\n  }\n} {}\ndo_test join5-1.2 {\n  execsql {\n    select * from t1 left join t2 on t1.b=t2.x and t1.c=1\n  }\n} {1 5 0 {} {} 2 11 2 {} {} 3 12 1 12 t2-12}\ndo_test join5-1.3 {\n  execsql {\n    select * from t1 left join t2 on t1.b=t2.x where t1.c=1\n  }\n} {3 12 1 12 t2-12}\ndo_test join5-1.4 {\n  execsql {\n    select * from t1 left join t2 on t1.b=t2.x and t1.c=1\n                     left join t3 on t1.b=t3.p and t1.c=2\n  }\n} {1 5 0 {} {} {} {} 2 11 2 {} {} 11 t3-11 3 12 1 12 t2-12 {} {}}\ndo_test join5-1.5 {\n  execsql {\n    select * from t1 left join t2 on t1.b=t2.x and t1.c=1\n                     left join t3 on t1.b=t3.p where t1.c=2\n  }\n} {2 11 2 {} {} 11 t3-11}\n\n# Ticket #2403\n#\ndo_test join5-2.1 {\n  execsql {\n    CREATE TABLE ab(a,b);\n    INSERT INTO \"ab\" VALUES(1,2);\n    INSERT INTO \"ab\" VALUES(3,NULL);\n\n    CREATE TABLE xy(x,y);\n    INSERT INTO \"xy\" VALUES(2,3);\n    INSERT INTO \"xy\" VALUES(NULL,1);\n  }\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 0}\n} {2 3 {} {} {} 1 {} {}}\ndo_test join5-2.2 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 1}\n} {2 3 1 2 2 3 3 {} {} 1 1 2 {} 1 3 {}}\ndo_test join5-2.3 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON NULL}\n} {2 3 {} {} {} 1 {} {}}\ndo_test join5-2.4 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE 0}\n} {}\ndo_test join5-2.5 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE 0}\n} {}\ndo_test join5-2.6 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE 0}\n} {}\ndo_test join5-2.7 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE 1}\n} {2 3 {} {} {} 1 {} {}}\ndo_test join5-2.8 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE 1}\n} {2 3 1 2 2 3 3 {} {} 1 1 2 {} 1 3 {}}\ndo_test join5-2.9 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE 1}\n} {2 3 {} {} {} 1 {} {}}\ndo_test join5-2.10 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 0 WHERE NULL}\n} {}\ndo_test join5-2.11 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON 1 WHERE NULL}\n} {}\ndo_test join5-2.12 {\n  execsql {SELECT * FROM xy LEFT JOIN ab ON NULL WHERE NULL}\n} {}\n\n# Ticket https://www.sqlite.org/src/tktview/6f2222d550f5b0ee7ed37601\n# Incorrect output on a LEFT JOIN.\n#\ndo_execsql_test join5-3.1 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE x1(a);\n  INSERT INTO x1 VALUES(1);\n  CREATE TABLE x2(b NOT NULL);\n  CREATE TABLE x3(c, d);\n  INSERT INTO x3 VALUES('a', NULL);\n  INSERT INTO x3 VALUES('b', NULL);\n  INSERT INTO x3 VALUES('c', NULL);\n  SELECT * FROM x1 LEFT JOIN x2 LEFT JOIN x3 ON x3.d = x2.b;\n} {1 {} {} {}}\ndo_execsql_test join5-3.2 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  DROP TABLE IF EXISTS t3;\n  DROP TABLE IF EXISTS t4;\n  DROP TABLE IF EXISTS t5;\n  CREATE TABLE t1(x text NOT NULL, y text);\n  CREATE TABLE t2(u text NOT NULL, x text NOT NULL);\n  CREATE TABLE t3(w text NOT NULL, v text);\n  CREATE TABLE t4(w text NOT NULL, z text NOT NULL);\n  CREATE TABLE t5(z text NOT NULL, m text);\n  INSERT INTO t1 VALUES('f6d7661f-4efe-4c90-87b5-858e61cd178b',NULL);\n  INSERT INTO t1 VALUES('f6ea82c3-2cad-45ce-ae8f-3ddca4fb2f48',NULL);\n  INSERT INTO t1 VALUES('f6f47499-ecb4-474b-9a02-35be73c235e5',NULL);\n  INSERT INTO t1 VALUES('56f47499-ecb4-474b-9a02-35be73c235e5',NULL);\n  INSERT INTO t3 VALUES('007f2033-cb20-494c-b135-a1e4eb66130c',\n                        'f6d7661f-4efe-4c90-87b5-858e61cd178b');\n  SELECT *\n    FROM t3\n         INNER JOIN t1 ON t1.x= t3.v AND t1.y IS NULL\n         LEFT JOIN t4  ON t4.w = t3.w\n         LEFT JOIN t5  ON t5.z = t4.z\n         LEFT JOIN t2  ON t2.u = t5.m\n         LEFT JOIN t1 xyz ON xyz.y = t2.x;\n} {007f2033-cb20-494c-b135-a1e4eb66130c f6d7661f-4efe-4c90-87b5-858e61cd178b f6d7661f-4efe-4c90-87b5-858e61cd178b {} {} {} {} {} {} {} {} {}}\ndo_execsql_test join5-3.3 {\n  DROP TABLE IF EXISTS x1;\n  DROP TABLE IF EXISTS x2;\n  DROP TABLE IF EXISTS x3;\n  CREATE TABLE x1(a);\n  INSERT INTO x1 VALUES(1);\n  CREATE TABLE x2(b NOT NULL);\n  CREATE TABLE x3(c, d);\n  INSERT INTO x3 VALUES('a', NULL);\n  INSERT INTO x3 VALUES('b', NULL);\n  INSERT INTO x3 VALUES('c', NULL);\n  SELECT * FROM x1 LEFT JOIN x2 JOIN x3 WHERE x3.d = x2.b;\n} {}\n\n# Ticket https://www.sqlite.org/src/tktview/c2a19d81652f40568c770c43 on\n# 2015-08-20.  LEFT JOIN and the push-down optimization.\n#\ndo_execsql_test join6-4.1 {\n  SELECT *\n  FROM (\n      SELECT 'apple' fruit\n      UNION ALL SELECT 'banana'\n  ) a\n  JOIN (\n      SELECT 'apple' fruit\n      UNION ALL SELECT 'banana'\n  ) b ON a.fruit=b.fruit\n  LEFT JOIN (\n      SELECT 1 isyellow\n  ) c ON b.fruit='banana';\n} {apple apple {} banana banana 1}\ndo_execsql_test join6-4.2 {\n  SELECT *\n    FROM (SELECT 'apple' fruit UNION ALL SELECT 'banana')\n         LEFT JOIN (SELECT 1) ON fruit='banana';\n} {apple {} banana 1}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 5.0 {\n  CREATE TABLE y1(x, y, z);\n  INSERT INTO y1 VALUES(0, 0, 1);\n  CREATE TABLE y2(a);\n}\n\ndo_execsql_test 5.1 {\n  SELECT count(z) FROM y1 LEFT JOIN y2 ON x GROUP BY y;\n} 1\n\ndo_execsql_test 5.2 {\n  SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x GROUP BY y;\n} 1\n\ndo_execsql_test 5.3 {\n  CREATE VIEW v1 AS SELECT x, y, z FROM y1;\n  SELECT count(z) FROM v1 LEFT JOIN y2 ON x GROUP BY y;\n} 1\n\ndo_execsql_test 5.4 {\n  SELECT count(z) FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x\n} 1\n\ndo_execsql_test 5.5 {\n  SELECT * FROM ( SELECT * FROM y1 ) LEFT JOIN y2 ON x\n} {0 0 1 {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/join6.test",
    "content": "# 2009 December 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for N-way joins (N>2) which make\n# use of USING or NATURAL JOIN.  For such joins, the USING and\n# NATURAL JOIN processing needs to search all tables to the left\n# of the join looking for a match.  See ticket [f74beaabde]\n# for additional information.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# The problem as initially reported on the mailing list:\n#\ndo_test join6-1.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    CREATE TABLE t2(a);\n    CREATE TABLE t3(a,b);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t3 VALUES(1,2);\n\n    SELECT * FROM t1 LEFT JOIN t2 USING(a) LEFT JOIN t3 USING(a);\n  }\n} {1 2}\ndo_test join6-1.2 {\n  execsql {\n    SELECT t1.a, t3.b \n      FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.a=t3.a;\n  }\n} {1 {}}\ndo_test join6-1.3 {\n  execsql {\n    SELECT t1.a, t3.b\n      FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t1.a=t3.a;\n  }\n} {1 2}\n\n\ndo_test join6-2.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n\n    CREATE TABLE t1(x,y);\n    CREATE TABLE t2(y,z);\n    CREATE TABLE t3(x,z);\n\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n\n    INSERT INTO t2 VALUES(2,3);\n    INSERT INTO t2 VALUES(4,5);\n\n    INSERT INTO t3 VALUES(1,3);\n    INSERT INTO t3 VALUES(3,5);\n\n    SELECT * FROM t1 JOIN t2 USING (y) JOIN t3 USING(x);\n  }\n} {1 2 3 3 3 4 5 5}\ndo_test join6-2.2 {\n  execsql {\n    SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;\n  }\n} {1 2 3 3 4 5}\n\n\ndo_test join6-3.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n\n    CREATE TABLE t1(a,x,y);\n    INSERT INTO t1 VALUES(1,91,92);\n    INSERT INTO t1 VALUES(2,93,94);\n    \n    CREATE TABLE t2(b,y,z);\n    INSERT INTO t2 VALUES(3,92,93);\n    INSERT INTO t2 VALUES(4,94,95);\n    \n    CREATE TABLE t3(c,x,z);\n    INSERT INTO t3 VALUES(5,91,93);\n    INSERT INTO t3 VALUES(6,99,95);\n    \n    SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN t3;\n  }\n} {1 91 92 3 93 5}\ndo_test join6-3.2 {\n  execsql {\n    SELECT * FROM t1 JOIN t2 NATURAL JOIN t3;\n  }\n} {1 91 92 3 92 93 5}\ndo_test join6-3.3 {\n  execsql {\n    SELECT * FROM t1 JOIN t2 USING(y) NATURAL JOIN t3;\n  }\n} {1 91 92 3 93 5}\ndo_test join6-3.4 {\n  execsql {\n    SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x,z);\n  }\n} {1 91 92 3 93 5}\ndo_test join6-3.5 {\n  execsql {\n    SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(x);\n  }\n} {1 91 92 3 93 5 93}\ndo_test join6-3.6 {\n  execsql {\n    SELECT * FROM t1 NATURAL JOIN t2 JOIN t3 USING(z);\n  }\n} {1 91 92 3 93 5 91 2 93 94 4 95 6 99}\n\nifcapable compound {\n  do_test join6-4.1 {\n    execsql {\n      SELECT * FROM\n         (SELECT 1 AS a, 91 AS x, 92 AS y UNION SELECT 2, 93, 94)\n         NATURAL JOIN t2 NATURAL JOIN t3\n    }\n  } {1 91 92 3 93 5}\n  do_test join6-4.2 {\n    execsql {\n      SELECT * FROM t1 NATURAL JOIN\n         (SELECT 3 AS b, 92 AS y, 93 AS z UNION SELECT 4, 94, 95)\n         NATURAL JOIN t3\n    }\n  } {1 91 92 3 93 5}\n  do_test join6-4.3 {\n    execsql {\n      SELECT * FROM t1 NATURAL JOIN t2 NATURAL JOIN\n         (SELECT 5 AS c, 91 AS x, 93 AS z UNION SELECT 6, 99, 95)\n    }\n  } {1 91 92 3 93 5}\n}\n\n\n\n\n\n\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/journal1.test",
    "content": "# 2005 March 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure that leftover journals from\n# prior databases do not try to rollback into new databases.\n#\n# $Id: journal1.test,v 1.2 2005/03/20 22:54:56 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# These tests will not work on windows because windows uses\n# manditory file locking which breaks the copy_file command.\n#\nif {$tcl_platform(platform)==\"windows\"} {\n  finish_test\n  return\n}\n\n# Create a smaple database\n#\ndo_test journal1-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,randstr(10,400));\n    INSERT INTO t1 VALUES(2,randstr(10,400));\n    INSERT INTO t1 SELECT a+2, a||b FROM t1;\n    INSERT INTO t1 SELECT a+4, a||b FROM t1;\n    SELECT count(*) FROM t1;\n  }\n} 8\n\n# Make changes to the database and save the journal file.\n# Then delete the database.  Replace the journal file\n# and try to create a new database with the same name.  The\n# old journal should not attempt to rollback into the new\n# database.\n#\ndo_test journal1-1.2 {\n  execsql {\n    BEGIN;\n    DELETE FROM t1;\n  }\n  forcecopy test.db-journal test.db-journal-bu\n  execsql {\n    ROLLBACK;\n  }\n  db close\n  delete_file test.db\n  copy_file test.db-journal-bu test.db-journal\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM sqlite_master\n  }\n} {0 {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/journal2.test",
    "content": "# 2010 June 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests SQLite when using a VFS that claims the SAFE_DELETE property.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\ndb close\n\nif {[permutation] == \"inmemory_journal\"} {\n  finish_test\n  return\n}\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\n\n# Create a [testvfs] and install it as the default VFS. Set the device\n# characteristics flags to \"SAFE_DELETE\".\n#\ntestvfs tvfs -default 1\ntvfs devchar {undeletable_when_open powersafe_overwrite}\n\n# Set up a hook so that each time a journal file is opened, closed or\n# deleted, the method name (\"xOpen\", \"xClose\" or \"xDelete\") and the final\n# segment of the journal file-name (i.e. \"test.db-journal\") are appended to\n# global list variable $::oplog.\n#\ntvfs filter {xOpen xClose xDelete}\ntvfs script journal_op_catcher\nproc journal_op_catcher {method filename args} {\n\n  # If global variable ::tvfs_error_on_write is defined, then return an\n  # IO error to every attempt to modify the file-system. Otherwise, return\n  # SQLITE_OK.\n  #\n  if {[info exists ::tvfs_error_on_write]} {\n    if {[lsearch {xDelete xWrite xTruncate} $method]>=0} {\n      return SQLITE_IOERR \n    }\n  }\n\n  # The rest of this command only deals with xOpen(), xClose() and xDelete()\n  # operations on journal files. If this invocation does not represent such\n  # an operation, return with no further ado.\n  #\n  set f [file tail $filename]\n  if {[string match *journal $f]==0} return\n  if {[lsearch {xOpen xDelete xClose} $method]<0} return\n\n  # Append a record of this operation to global list variable $::oplog.\n  #\n  lappend ::oplog $method $f\n\n  # If this is an attempt to delete a journal file for which there exists\n  # one ore more open handles, return an error. The code in test_vfs.c\n  # will not invoke the xDelete method of the \"real\" VFS in this case.\n  #\n  if {[info exists ::open_journals($f)]==0} { set ::open_journals($f) 0 }\n  switch -- $method {\n    xOpen   { incr ::open_journals($f) +1 }\n    xClose  { incr ::open_journals($f) -1 }\n    xDelete { if {$::open_journals($f)>0} { return SQLITE_IOERR } }\n  }\n\n  return \"\"\n}\n\n\ndo_test journal2-1.1 {\n  set ::oplog [list]\n  sqlite3 db test.db\n  execsql { CREATE TABLE t1(a, b) }\n  set ::oplog\n} {xOpen test.db-journal xClose test.db-journal xDelete test.db-journal}\ndo_test journal2-1.2 {\n  set ::oplog [list]\n  execsql { \n    PRAGMA journal_mode = truncate;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  set ::oplog\n} {xOpen test.db-journal}\ndo_test journal2-1.3 {\n  set ::oplog [list]\n  execsql { INSERT INTO t1 VALUES(3, 4) }\n  set ::oplog\n} {}\ndo_test journal2-1.4 { execsql { SELECT * FROM t1 } } {1 2 3 4}\n\n# Add a second connection. This connection attempts to commit data in\n# journal_mode=DELETE mode. When it tries to delete the journal file,\n# the VFS layer returns an IO error.\n#\ndo_test journal2-1.5 {\n  set ::oplog [list]\n  sqlite3 db2 test.db\n  execsql  { PRAGMA journal_mode = delete } db2\n  catchsql { INSERT INTO t1 VALUES(5, 6)  } db2\n} {1 {disk I/O error}}\ndo_test journal2-1.6 { file exists test.db-journal } 1\ndo_test journal2-1.7 { execsql { SELECT * FROM t1 } } {1 2 3 4}\ndo_test journal2-1.8 {\n  execsql { PRAGMA journal_mode = truncate } db2\n  execsql { INSERT INTO t1 VALUES(5, 6)  } db2\n} {}\ndo_test journal2-1.9 { execsql { SELECT * FROM t1 } } {1 2 3 4 5 6}\n\n# Grow the database until it is reasonably large.\n#\ndo_test journal2-1.10 {\n  db2 close\n  db func a_string a_string\n  execsql {\n    CREATE TABLE t2(a UNIQUE, b UNIQUE);\n    INSERT INTO t2 VALUES(a_string(200), a_string(300));\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  --  2\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  --  4\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  --  8\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  -- 16\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  -- 32\n    INSERT INTO t2 SELECT a_string(200), a_string(300) FROM t2;  -- 64\n  }\n  file size test.db-journal\n} {0}\ndo_test journal2-1.11 {\n  set sz [expr [file size test.db] / 1024]\n  expr {$sz>120 && $sz<200}\n} 1\n\n# Using new connection [db2] (with journal_mode=DELETE), write a lot of\n# data to the database. So that many pages within the database file are\n# modified before the transaction is committed.\n#\n# Then, enable simulated IO errors in all calls to xDelete, xWrite\n# and xTruncate before committing the transaction and closing the \n# database file. From the point of view of other file-system users, it\n# appears as if the process hosting [db2] unexpectedly exited.\n# \ndo_test journal2-1.12 {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      INSERT INTO t2 SELECT randomblob(200), randomblob(300) FROM t2;  -- 128\n  } db2\n} {}\ndo_test journal2-1.13 {\n  tvfs filter {xOpen xClose xDelete xWrite xTruncate}\n  set ::tvfs_error_on_write 1\n  catchsql { COMMIT } db2\n} {1 {disk I/O error}}\ndb2 close\nunset ::tvfs_error_on_write\nforcecopy test.db testX.db\n\ndo_test journal2-1.14 { file exists test.db-journal } 1\ndo_test journal2-1.15 {\n  execsql {\n    SELECT count(*) FROM t2;\n    PRAGMA integrity_check;\n  }\n} {64 ok}\n\n# This block checks that in the test case above, connection [db2] really\n# did begin writing to the database file before it hit IO errors. If\n# this is true, then the copy of the database file made before [db]\n# rolled back the hot journal should fail the integrity-check.\n#\ndo_test journal2-1.16 {\n  set sz [expr [file size testX.db] / 1024]\n  expr {$sz>240 && $sz<400}\n} 1\ndo_test journal2-1.17 {\n  expr {[catchsql { PRAGMA integrity_check } db] == \"0 ok\"}\n} {1}\ndo_test journal2-1.20 {\n  sqlite3 db2 testX.db\n  expr {[catchsql { PRAGMA integrity_check } db2] == \"0 ok\"}\n} {0}\ndo_test journal2-1.21 {\n  db2 close\n} {}\ndb close\n\n#-------------------------------------------------------------------------\n# Test that it is possible to switch from journal_mode=truncate to\n# journal_mode=WAL on a SAFE_DELETE file-system. SQLite should close and\n# delete the journal file when committing the transaction that switches\n# the system to WAL mode.\n#\nif {[wal_is_capable]} {\n  do_test journal2-2.1 {\n    faultsim_delete_and_reopen\n    set ::oplog [list]\n    execsql { PRAGMA journal_mode = persist }\n    set ::oplog\n  } {}\n  do_test journal2-2.2 {\n    execsql { \n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES(3.14159);\n    }\n    set ::oplog\n  } {xOpen test.db-journal}\n  do_test journal2-2.3 {\n    expr {[file size test.db-journal] > 512}\n  } {1}\n  do_test journal2-2.4 {\n    set ::oplog [list]\n    execsql { PRAGMA journal_mode = WAL }\n    set ::oplog\n  } {xClose test.db-journal xDelete test.db-journal}\n  db close\n}\n\ntvfs delete\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/journal3.test",
    "content": "# 2010 July 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\n#-------------------------------------------------------------------------\n# If a connection is required to create a journal file, it creates it with \n# the same file-system permissions as the database file itself. Test this.\n#\nif {$::tcl_platform(platform) == \"unix\"} {\n\n  # Changed on 2012-02-13:  umask is deliberately ignored for -wal, -journal,\n  # and -shm files.\n  #set umask [exec /bin/sh -c umask]\n  faultsim_delete_and_reopen\n  do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}\n\n  foreach {tn permissions} {\n   1 00644\n   2 00666\n   3 00600\n   4 00755\n  } {\n    db close\n    #set effective [format %.5o [expr $permissions & ~$umask]]\n    set effective $permissions\n    do_test journal3-1.2.$tn.1 {\n      catch { forcedelete test.db-journal }\n      file attributes test.db -permissions $permissions\n      file attributes test.db -permissions\n    } $permissions\n    do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}\n    do_test journal3-1.2.$tn.3 {\n      sqlite3 db test.db\n      execsql { \n        BEGIN;\n          INSERT INTO tx DEFAULT VALUES;\n      }\n      file exists test.db-journal\n    } {1}\n    do_test journal3-1.2.$tn.4 {\n      file attr test.db-journal -perm\n    } $effective\n    do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}\n  }\n\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/jrnlmode.test",
    "content": "# 2008 April 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of these tests is the journal mode pragma.\n#\n# $Id: jrnlmode.test,v 1.16 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!pager_pragmas} {\n  finish_test\n  return\n}\n\nif {[info exists TEMP_STORE] && $TEMP_STORE>=2} {\n  set temp_persist memory\n  set temp_delete memory\n  set temp_truncate memory\n  set temp_off off\n} else {\n  set temp_persist persist\n  set temp_delete delete\n  set temp_truncate truncate\n  set temp_off off\n}\n\nproc temp_journal_mode {newmode} {\n  if {[info exists ::TEMP_STORE] && $::TEMP_STORE>=2} {\n    if {$newmode ne \"off\" && $newmode ne \"memory\"} {\n      execsql {PRAGMA temp.journal_mode}\n      set newmode [db one {PRAGMA temp.journal_mode}]\n    }\n  }\n  set newmode\n}\n\n#----------------------------------------------------------------------\n# Test cases jrnlmode-1.X test the PRAGMA logic.\n#\ndo_test jrnlmode-1.0 {\n  execsql {\n    PRAGMA journal_mode;\n    PRAGMA main.journal_mode;\n    PRAGMA temp.journal_mode;\n  } \n} [list delete delete [temp_journal_mode delete]]\ndo_test jrnlmode-1.1 {\n  execsql {\n    PRAGMA journal_mode = persist;\n  } \n} {persist}\ndo_test jrnlmode-1.2 {\n  execsql {\n    PRAGMA journal_mode;\n    PRAGMA main.journal_mode;\n    PRAGMA temp.journal_mode;\n  } \n} [list persist persist [temp_journal_mode persist]]\ndo_test jrnlmode-1.4 {\n  execsql {\n    PRAGMA journal_mode = off;\n  } \n} {off}\ndo_test jrnlmode-1.5 {\n  execsql {\n    PRAGMA journal_mode;\n    PRAGMA main.journal_mode;\n    PRAGMA temp.journal_mode;\n  } \n} [list off off [temp_journal_mode off]]\ndo_test jrnlmode-1.6 {\n  execsql {\n    PRAGMA journal_mode = delete;\n  } \n} {delete}\ndo_test jrnlmode-1.7 {\n  execsql {\n    PRAGMA journal_mode;\n    PRAGMA main.journal_mode;\n    PRAGMA Temp.journal_mode;\n  } \n} [list delete delete [temp_journal_mode delete]]\ndo_test jrnlmode-1.7.1 {\n  execsql {\n    PRAGMA journal_mode = truncate;\n  } \n} {truncate}\ndo_test jrnlmode-1.7.2 {\n  execsql {\n    PRAGMA journal_mode;\n    PRAGMA main.journal_mode;\n    PRAGMA temp.journal_mode;\n  } \n} [list truncate truncate [temp_journal_mode truncate]]\ndo_test jrnlmode-1.8 {\n  execsql {\n    PRAGMA journal_mode = off;\n    PRAGMA journal_mode = invalid;\n  } \n} {off off}\nifcapable attach {\n  do_test jrnlmode-1.9 {\n    execsql {\n      PRAGMA journal_mode = PERSIST;\n      ATTACH ':memory:' as aux1;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA aux1.journal_mode;\n    }\n  } {persist memory}\n  do_test jrnlmode-1.10 {\n    execsql {\n      PRAGMA main.journal_mode = OFF;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA temp.journal_mode;\n      PRAGMA aux1.journal_mode;\n    }\n  } [list off [temp_journal_mode persist] memory]\n  do_test jrnlmode-1.11 {\n    execsql {\n      PRAGMA journal_mode;\n    }\n  } {off}\n  do_test jrnlmode-1.12 {\n    execsql {\n      ATTACH ':memory:' as aux2;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA aux1.journal_mode;\n      PRAGMA aux2.journal_mode;\n    }\n  } {off memory memory}\n  do_test jrnlmode-1.13 {\n    # The journal-mode used by in-memory databases cannot be changed.\n    execsql {\n      PRAGMA aux1.journal_mode = DELETE;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA aux1.journal_mode;\n      PRAGMA aux2.journal_mode;\n    }\n  } {off memory memory}\n  do_test jrnlmode-1.14 {\n    execsql {\n      PRAGMA journal_mode = delete;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA temp.journal_mode;\n      PRAGMA aux1.journal_mode;\n      PRAGMA aux2.journal_mode;\n    }\n  } [list delete [temp_journal_mode delete] memory memory]\n  do_test jrnlmode-1.15 {\n    execsql {\n      ATTACH ':memory:' as aux3;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA temp.journal_mode;\n      PRAGMA aux1.journal_mode;\n      PRAGMA aux2.journal_mode;\n      PRAGMA aux3.journal_mode;\n    }\n  } [list delete [temp_journal_mode delete] memory memory memory]\n  do_test jrnlmode-1.16 {\n    execsql {\n      PRAGMA journal_mode = TRUNCATE;\n    }\n    execsql {\n      PRAGMA main.journal_mode;\n      PRAGMA temp.journal_mode;\n      PRAGMA aux1.journal_mode;\n      PRAGMA aux2.journal_mode;\n      PRAGMA aux3.journal_mode;\n    }\n  } [list truncate [temp_journal_mode truncate] memory memory memory]\n\n  do_test jrnlmode-1.99 {\n    execsql {\n      DETACH aux1;\n      DETACH aux2;\n      DETACH aux3;\n    }\n  } {}\n}\n\nifcapable attach {\n  forcedelete test2.db\n  do_test jrnlmode-2.1 {\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA main.journal_mode = persist;\n      PRAGMA aux.journal_mode = persist;\n      CREATE TABLE abc(a, b, c);\n      CREATE TABLE aux.def(d, e, f);\n    }\n    execsql {\n      BEGIN;\n      INSERT INTO abc VALUES(1, 2, 3);\n      INSERT INTO def VALUES(4, 5, 6);\n      COMMIT;\n    }\n    list [file exists test.db-journal] [file exists test2.db-journal]\n  } {1 1}\n\n  do_test jrnlmode-2.2 {\n    file size test.db-journal\n  } {0}\n\n  do_test jrnlmode-2.3 {\n    execsql {\n      SELECT * FROM abc;\n    }\n  } {1 2 3}\n\n  do_test jrnlmode-2.4 {\n    file size test.db-journal\n  } {0}\n\n  do_test jrnlmode-2.5 {\n    execsql {\n      SELECT * FROM def;\n    }\n  } {4 5 6}\n\n#----------------------------------------------------------------------\n# Test caes jrnlmode-3.X verify that ticket #3127 has been fixed.\n#\n  db close\n  forcedelete test2.db\n  forcedelete test.db\n  sqlite3 db test.db\n\n  do_test jrnlmode-3.1 {\n    execsql { \n      CREATE TABLE x(n INTEGER); \n      ATTACH 'test2.db' AS a; \n      create table a.x ( n integer ); \n      insert into a.x values(1); \n      insert into a.x values (2); \n      insert into a.x values (3); \n      insert into a.x values (4); \n    }\n  } {}\n  \n  do_test jrnlmode-3.2 {\n    execsql { PRAGMA journal_mode=off; }\n    execsql { \n      BEGIN IMMEDIATE;\n      INSERT OR IGNORE INTO main.x SELECT * FROM a.x;\n      COMMIT;\n    }\n  } {}\n}\n\nifcapable autovacuum&&pragma {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  do_test jrnlmode-4.1 {\n    execsql {\n      PRAGMA cache_size = 1;\n      PRAGMA auto_vacuum = 1;\n      CREATE TABLE abc(a, b, c);\n    }\n    execsql { PRAGMA page_count }\n  } {3}\n\n  do_test jrnlmode-4.2 {\n    execsql { PRAGMA journal_mode = off }\n  } {off}\n\n  do_test jrnlmode-4.3 {\n    execsql { INSERT INTO abc VALUES(1, 2, randomblob(2000)) }\n  } {}\n\n  # This will attempt to truncate the database file. Check that this\n  # is not a problem when journal_mode=off.\n  do_test jrnlmode-4.4 {\n    execsql { DELETE FROM abc }\n  } {}\n\n  integrity_check jrnlmode-4.5\n}\n\n#------------------------------------------------------------------------\n# The following test caes, jrnlmode-5.*, test the journal_size_limit\n# pragma.\nifcapable pragma {\n  db close\n  forcedelete test.db test2.db test3.db\n  sqlite3 db test.db\n\n  do_test jrnlmode-5.1 {\n    execsql {pragma page_size=1024}\n    execsql {pragma journal_mode=persist}\n  } {persist}\n\n  do_test jrnlmode-5.2 {\n    execsql { PRAGMA journal_size_limit }\n  } {-1}\n  do_test jrnlmode-5.3 {\n    execsql { \n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.journal_mode=persist;\n      PRAGMA aux.journal_size_limit;\n    }\n  } {persist -1}\n  do_test jrnlmode-5.4.1 {\n    execsql { PRAGMA aux.journal_size_limit = 999999999999 }\n  } {999999999999}\n  do_test jrnlmode-5.4.2 {\n    execsql { PRAGMA aux.journal_size_limit = 10240 }\n  } {10240}\n  do_test jrnlmode-5.5 {\n    execsql { PRAGMA main.journal_size_limit = 20480 }\n  } {20480}\n  do_test jrnlmode-5.6 {\n    execsql { PRAGMA journal_size_limit }\n  } {20480}\n  do_test jrnlmode-5.7 {\n    execsql { PRAGMA aux.journal_size_limit }\n  } {10240}\n\n  do_test jrnlmode-5.8 {\n    execsql {\n      ATTACH 'test3.db' AS aux2;\n      PRAGMA aux2.journal_mode=persist;\n    }\n  } {persist}\n\n  do_test jrnlmode-5.9 {\n    execsql {\n      CREATE TABLE main.t1(a, b, c);\n      CREATE TABLE aux.t2(a, b, c);\n      CREATE TABLE aux2.t3(a, b, c);\n    }\n  } {}\n  do_test jrnlmode-5.10 {\n    list \\\n      [file exists test.db-journal]  \\\n      [file exists test2.db-journal] \\\n      [file exists test3.db-journal]\n  } {1 1 1}\n  do_test jrnlmode-5.11 {\n    execsql {\n      BEGIN;\n      INSERT INTO t3 VALUES(randomblob(1000),randomblob(1000),randomblob(1000));\n      INSERT INTO t3 \n          SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;\n      INSERT INTO t3 \n          SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;\n      INSERT INTO t3 \n          SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;\n      INSERT INTO t3 \n          SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;\n      INSERT INTO t3 \n          SELECT randomblob(1000),randomblob(1000),randomblob(1000) FROM t3;\n      INSERT INTO t2 SELECT * FROM t3;\n      INSERT INTO t1 SELECT * FROM t2;\n      COMMIT;\n    }\n    list \\\n      [file exists test.db-journal]  \\\n      [file exists test2.db-journal] \\\n      [file exists test3.db-journal] \\\n      [file size test.db-journal]    \\\n      [file size test2.db-journal]   \\\n      [file size test3.db-journal]\n  } {1 1 1 0 0 0}\n\n  do_test jrnlmode-5.12 {\n    execsql {\n      BEGIN;\n      UPDATE t1 SET a = randomblob(1000);\n    }\n    expr {[file size test.db-journal]>30000}\n  } {1}\n  do_test jrnlmode-5.13 {\n    execsql COMMIT\n    file size test.db-journal\n  } {20480}\n\n  do_test jrnlmode-5.14 {\n    execsql {\n      BEGIN;\n      UPDATE t2 SET a = randomblob(1000);\n    }\n    expr {[file size test2.db-journal]>30000}\n  } {1}\n  do_test jrnlmode-5.15 {\n    execsql COMMIT\n    file size test2.db-journal\n  } {10240}\n\n  do_test jrnlmode-5.16 {\n    execsql {\n      BEGIN;\n      UPDATE t3 SET a = randomblob(1000);\n    }\n    set journalsize [file size test3.db-journal]\n    expr {$journalsize>30000}\n  } {1}\n  do_test jrnlmode-5.17 {\n    execsql COMMIT\n    set sz [file size test3.db-journal]\n    expr {$sz>=$journalsize}\n  } {1}\n\n  do_test jrnlmode-5.18 {\n    execsql {\n      PRAGMA journal_size_limit = -4;\n      BEGIN;\n      UPDATE t1 SET a = randomblob(1000);\n    }\n    set journalsize [file size test.db-journal]\n    expr {$journalsize>30000}\n  } {1}\n  do_test jrnlmode-5.19 {\n    execsql COMMIT\n    set sz [file size test.db-journal]\n    expr {$sz>=$journalsize}\n  } {1}\n\n  # Test a size-limit of 0.\n  #\n  do_test jrnlmode-5.20 {\n    execsql {\n      PRAGMA journal_size_limit = 0;\n      BEGIN;\n      UPDATE t1 SET a = randomblob(1000);\n    }\n  } {0}\n  do_test jrnlmode-5.21 {\n    expr {[file size test.db-journal] > 1024}\n  } {1}\n  do_test jrnlmode-5.22 {\n    execsql COMMIT\n    list [file exists test.db-journal] [file size test.db-journal]\n  } {1 0}\n}\n\nifcapable pragma {\n  # These tests are not run as part of the \"journaltest\" permutation,\n  # as the test_journal.c layer is incompatible with in-memory journaling.\n  if {[permutation] ne \"journaltest\"} {\n\n    do_test jrnlmode-6.1 {\n      execsql {\n        PRAGMA journal_mode = truncate;\n        CREATE TABLE t4(a, b);\n        BEGIN;\n          INSERT INTO t4 VALUES(1, 2);\n          PRAGMA journal_mode = memory;\n      }\n    } {truncate truncate}\n    do_test jrnlmode-6.2 {\n      file exists test.db-journal\n    } {1}\n    do_test jrnlmode-6.3 {\n      execsql {\n        COMMIT;\n        SELECT * FROM t4;\n      }\n    } {1 2}\n    do_test jrnlmode-6.4 {\n      file exists test.db-journal\n    } {1}\n    do_test jrnlmode-6.5 {\n      execsql {\n        PRAGMA journal_mode = MEMORY;\n        BEGIN;\n          INSERT INTO t4 VALUES(3, 4);\n      }\n      file exists test.db-journal\n    } {0}\n    do_test jrnlmode-6.7 {\n      execsql {\n        COMMIT;\n        SELECT * FROM t4;\n      }\n    } {1 2 3 4}\n    do_test jrnlmode-6.8 {\n      file exists test.db-journal\n    } {0}\n    do_test jrnlmode-6.9 {\n      execsql {\n        PRAGMA journal_mode = DELETE;\n        BEGIN IMMEDIATE; INSERT INTO t4 VALUES(1,2); COMMIT;\n      }\n      file exists test.db-journal\n    } {0}\n  }\n}\n\nifcapable pragma {\n  catch { db close }\n  do_test jrnlmode-7.1 {\n    foreach f [glob -nocomplain test.db*] { forcedelete $f }\n    sqlite3 db test.db\n    execsql {\n      PRAGMA journal_mode = memory;\n      PRAGMA auto_vacuum = 0;\n      PRAGMA page_size = 1024;\n      PRAGMA user_version = 5;\n      PRAGMA user_version;\n    }\n  } {memory 5}\n  do_test jrnlmode-7.2 { file size test.db } {1024}\n}\n\ndo_execsql_test jrnlmode-8.1  { PRAGMA locking_mode=EXCLUSIVE } {exclusive}\ndo_execsql_test jrnlmode-8.2  { CREATE TABLE t1(x) }            {}\ndo_execsql_test jrnlmode-8.3  { INSERT INTO t1 VALUES(123) }    {}\ndo_execsql_test jrnlmode-8.4  { SELECT * FROM t1 }              {123}\ndo_execsql_test jrnlmode-8.5  { PRAGMA journal_mode=PERSIST }   {persist}\ndo_execsql_test jrnlmode-8.6  { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.7  { PRAGMA journal_mode=TRUNCATE }  {truncate}\ndo_execsql_test jrnlmode-8.8  { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.9  { CREATE TABLE t2(y) }            {}\ndo_execsql_test jrnlmode-8.10 { INSERT INTO t2 VALUES(456) }    {}\ndo_execsql_test jrnlmode-8.11 { SELECT * FROM t1, t2 }          {123 456}\ndo_execsql_test jrnlmode-8.12 { PRAGMA locking_mode=NORMAL }    {normal}\ndo_execsql_test jrnlmode-8.13 { PRAGMA journal_mode=PERSIST }   {persist}\ndo_execsql_test jrnlmode-8.14 { PRAGMA journal_mode=TRUNCATE }  {truncate}\ndo_execsql_test jrnlmode-8.15 { PRAGMA journal_mode=PERSIST }   {persist}\ndo_execsql_test jrnlmode-8.16 { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.17 { PRAGMA journal_mode=TRUNCATE }  {truncate}\ndo_execsql_test jrnlmode-8.18 { PRAGMA locking_mode=EXCLUSIVE } {exclusive}\ndo_execsql_test jrnlmode-8.19 { CREATE TABLE t3(z) }            {}\ndo_execsql_test jrnlmode-8.20 { BEGIN IMMEDIATE }               {}\ndo_execsql_test jrnlmode-8.21 { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.22 { COMMIT }                        {}\ndo_execsql_test jrnlmode-8.23 { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.24 { PRAGMA journal_mode=TRUNCATE }  {truncate}\ndo_execsql_test jrnlmode-8.25 { PRAGMA locking_mode=NORMAL }    {normal}\ndo_execsql_test jrnlmode-8.26 { CREATE TABLE t4(w) }            {}\ndo_execsql_test jrnlmode-8.27 { BEGIN IMMEDIATE }               {}\ndo_execsql_test jrnlmode-8.28 { PRAGMA journal_mode=DELETE }    {delete}\ndo_execsql_test jrnlmode-8.29 { COMMIT }                        {}\ndo_execsql_test jrnlmode-8.30 { PRAGMA journal_mode=DELETE }    {delete}\n\n# Assertion fault on 2015-05-01\ndo_test jrnlmode-9.1 {\n  forcedelete test2.db\n  sqlite3 db2 test2.db\n  db2 eval {CREATE TEMP TABLE t(l); PRAGMA journal_mode=off;}\n  db2 close\n} {}\ndo_execsql_test jrnlmode-9.2 {\n  PRAGMA locking_mode = exclusive;\n  CREATE TABLE tx(a);\n  PRAGMA journal_mode = off;\n} {exclusive off}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/jrnlmode2.test",
    "content": "# 2009 March 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!pager_pragmas} {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# The tests in this file check that the following two bugs (both now fixed)\n# do not reappear.\n#\n# jrnlmode2-1.*: Demonstrate bug #3745:\n#\n#     In persistent journal mode, if:\n#\n#       * There is a persistent journal in the file-system, AND\n#       * there exists a connection with a shared lock on the db file, \n#\n#     then a second connection cannot open a read-transaction on the database.\n#     The reason is because while determining that the persistent-journal is\n#     not a hot-journal, SQLite currently grabs an exclusive lock on the\n#     database file. If this fails because another connection has a shared\n#     lock, then SQLITE_BUSY is returned to the user.  \n#\n# jrnlmode2-2.*: Demonstrate bug #3751:\n#\n#     If a connection is opened in SQLITE_OPEN_READONLY mode, the underlying\n#     unix file descriptor on the database file is opened in O_RDONLY mode.\n#\n#     When SQLite queries the database file for the schema in order to compile\n#     the SELECT statement, it sees the empty journal in the file system, it\n#     attempts to obtain an exclusive lock on the database file (this is a\n#     bug). The attempt to obtain an exclusive (write) lock on a read-only file\n#     fails at the OS level. Under unix, fcntl() reports an EBADF - \"Bad file\n#     descriptor\" - error. \n#\n\ndo_test jrnlmode2-1.1 {\n  execsql {\n    PRAGMA journal_mode = persist;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} {persist}\n\ndo_test jrnlmode2-1.2 {\n  file exists test.db-journal\n} {1}\n\ndo_test jrnlmode2-1.3 {\n  sqlite3 db2 test.db\n  execsql { SELECT * FROM t1 } db2\n} {1 2}\n\ndo_test jrnlmode2-1.4 {\n  execsql {\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  }\n  execsql { PRAGMA lock_status }\n} {main shared temp closed}\n\ndo_test jrnlmode2-1.5 {\n  file exists test.db-journal\n} {1}\n\ndo_test jrnlmode2-1.6 {\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2 3 4}}\n\ndo_test jrnlmode2-1.7 {\n  execsql { COMMIT }\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2 3 4}}\n\n\n\ndo_test jrnlmode2-2.1 {\n  db2 close\n  execsql { PRAGMA journal_mode = truncate }\n  execsql { INSERT INTO t1 VALUES(5, 6) }\n} {}\n\ndo_test jrnlmode2-2.2 {\n  file exists test.db-journal\n} {1}\n\ndo_test jrnlmode2-2.3 {\n  file size test.db-journal\n} {0}\n\ndo_test jrnlmode2-2.4 {\n  sqlite3 db2 test.db -readonly 1\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2 3 4 5 6}}\n\ndo_test jrnlmode2-2.5 {\n  db close\n  delete_file test.db-journal\n} {}\ndo_test jrnlmode2-2.6 {\n  sqlite3 db2 test.db -readonly 1\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2 3 4 5 6}}\n\ncatch { db2 close }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/jrnlmode3.test",
    "content": "# 2009 April 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test cases inspired by ticket #3811.  Tests to make sure that\n# the journal_mode can only be changed at appropriate times and that\n# all reported changes are effective.\n#\n# $Id: jrnlmode3.test,v 1.5 2009/04/20 17:43:03 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!pager_pragmas} {\n  finish_test\n  return\n}\n\n#\n# Verify that journal_mode=OFF works as long as it occurs before the first\n# transaction, even if locking_mode=EXCLUSIVE is enabled.  The behavior if\n# journal_mode is changed after the first transaction is undefined and hence\n# untested.\n#\ndo_test jrnlmode3-1.1 {\n  db eval {\n    PRAGMA journal_mode=OFF;\n    PRAGMA locking_mode=EXCLUSIVE;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1;\n  }\n} {off exclusive 1}\ndo_test jrnlmode3-1.2 {\n  db eval {\n    BEGIN;\n    INSERT INTO t1 VALUES(2);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {1}\n\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndo_test jrnlmode3-2.1 {\n  db eval {\n    PRAGMA locking_mode=EXCLUSIVE;\n    PRAGMA journal_mode=OFF;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1;\n  }\n} {exclusive off 1}\ndo_test jrnlmode3-2.2 {\n  db eval {\n    BEGIN;\n    INSERT INTO t1 VALUES(2);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {1}\n\n# Test cases to verify that we can move from any journal_mode\n# to any other, as long as we are not in a transaction.  Verify\n# that we cannot change journal_mode while a transaction is active.\n#\nset all_journal_modes {delete persist truncate memory off}\nset cnt 0\nforeach fromjmode $all_journal_modes {\n  foreach tojmode $all_journal_modes {\n\n    # Skip the no-change cases\n    if {$fromjmode==$tojmode} continue\n    incr cnt\n\n    # Start with a fresh database connection an empty database file.\n    #\n    db close\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n\n    # Initialize the journal mode.\n    #\n    do_test jrnlmode3-3.$cnt.1-($fromjmode-to-$tojmode) {\n      db eval \"PRAGMA journal_mode = $fromjmode;\"\n    } $fromjmode\n\n    # Verify that the initial journal mode takes.\n    #\n    do_test jrnlmode3-3.$cnt.2 {\n      db eval {PRAGMA main.journal_mode}\n    } $fromjmode\n\n    # Start a transaction and try to change the journal mode within\n    # the transaction.  This should fail.\n    #\n    do_test jrnlmode3-3.$cnt.3 {\n      db eval {\n        CREATE TABLE t1(x);\n        BEGIN;\n        INSERT INTO t1 VALUES($cnt);\n      }\n      db eval \"PRAGMA journal_mode=$tojmode\"\n    } $fromjmode\n\n    # Rollback the transaction.  \n    #\n    do_test jrnlmode3-3.$cnt.4 {\n      db eval {\n        ROLLBACK;\n        SELECT * FROM t1;\n      }\n    } {}\n\n    # Now change the journal mode again.  This time the new mode\n    # should take.\n    #\n    do_test jrnlmode3-3.$cnt.5 {\n      db eval \"PRAGMA journal_mode=$tojmode\"\n    } $tojmode\n\n    # Do a the transaction.  Verify that the rollback occurred\n    # if journal_mode!=OFF.\n    #\n    do_test jrnlmode3-3.$cnt.6 {\n      db eval {\n        DROP TABLE IF EXISTS t1;\n        CREATE TABLE t1(x);\n        BEGIN;\n        INSERT INTO t1 VALUES(1);\n      }\n      db eval ROLLBACK\n      db eval {\n        SELECT * FROM t1;\n      }\n    } {}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/json101.test",
    "content": "# 2015-08-12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for JSON SQL functions extension to the\n# SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !json1 {\n  finish_test\n  return\n}\n\ndo_execsql_test json101-1.1.00 {\n  SELECT json_array(1,2.5,null,'hello');\n} {[1,2.5,null,\"hello\"]}\ndo_execsql_test json101-1.1.01 {\n  SELECT json_array(1,'{\"abc\":2.5,\"def\":null,\"ghi\":hello}',99);\n  -- the second term goes in as a string:\n} {[1,\"{\\\\\"abc\\\\\":2.5,\\\\\"def\\\\\":null,\\\\\"ghi\\\\\":hello}\",99]}\ndo_execsql_test json101-1.1.02 {\n  SELECT json_array(1,json('{\"abc\":2.5,\"def\":null,\"ghi\":\"hello\"}'),99);\n  -- the second term goes in as JSON\n} {[1,{\"abc\":2.5,\"def\":null,\"ghi\":\"hello\"},99]}\ndo_execsql_test json101-1.1.03 {\n  SELECT json_array(1,json_object('abc',2.5,'def',null,'ghi','hello'),99);\n  -- the second term goes in as JSON\n} {[1,{\"abc\":2.5,\"def\":null,\"ghi\":\"hello\"},99]}\ndo_execsql_test json101-1.2 {\n  SELECT hex(json_array('String \"\\ Test'));\n} {5B22537472696E67205C225C5C2054657374225D}\ndo_catchsql_test json101-1.3 {\n  SELECT json_array(1,printf('%.1000c','x'),x'abcd',3);\n} {1 {JSON cannot hold BLOB values}}\ndo_execsql_test json101-1.4 {\n  SELECT json_array(-9223372036854775808,9223372036854775807,0,1,-1,\n                    0.0, 1.0, -1.0, -1e99, +2e100,\n                    'one','two','three',\n                    4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,\n                    19, NULL, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,\n                    'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n                    'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n                    'abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ',\n                    99);\n} {[-9223372036854775808,9223372036854775807,0,1,-1,0.0,1.0,-1.0,-1.0e+99,2.0e+100,\"one\",\"two\",\"three\",4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,null,21,22,23,24,25,26,27,28,29,30,31,\"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ\",99]}\n\ndo_execsql_test json101-2.1 {\n  SELECT json_object('a',1,'b',2.5,'c',null,'d','String Test');\n} {{{\"a\":1,\"b\":2.5,\"c\":null,\"d\":\"String Test\"}}}\ndo_catchsql_test json101-2.2 {\n  SELECT json_object('a',printf('%.1000c','x'),2,2.5);\n} {1 {json_object() labels must be TEXT}}\ndo_catchsql_test json101-2.3 {\n  SELECT json_object('a',1,'b');\n} {1 {json_object() requires an even number of arguments}}\ndo_catchsql_test json101-2.4 {\n  SELECT json_object('a',printf('%.1000c','x'),'b',x'abcd');\n} {1 {JSON cannot hold BLOB values}}\n\ndo_execsql_test json101-3.1 {\n  SELECT json_replace('{\"a\":1,\"b\":2}','$.a','[3,4,5]');\n} {{{\"a\":\"[3,4,5]\",\"b\":2}}}\ndo_execsql_test json101-3.2 {\n  SELECT json_replace('{\"a\":1,\"b\":2}','$.a',json('[3,4,5]'));\n} {{{\"a\":[3,4,5],\"b\":2}}}\ndo_execsql_test json101-3.3 {\n  SELECT json_type(json_set('{\"a\":1,\"b\":2}','$.b','{\"x\":3,\"y\":4}'),'$.b');\n} {text}\ndo_execsql_test json101-3.4 {\n  SELECT json_type(json_set('{\"a\":1,\"b\":2}','$.b',json('{\"x\":3,\"y\":4}')),'$.b');\n} {object}\nifcapable vtab {\ndo_execsql_test json101-3.5 {\n  SELECT fullkey, atom, '|' FROM json_tree(json_set('{}','$.x',123,'$.x',456));\n} {{$} {} | {$.x} 456 |}\n}\n\n# Per rfc7159, any JSON value is allowed at the top level, and whitespace\n# is permitting before and/or after that value.\n#\ndo_execsql_test json101-4.1 {\n  CREATE TABLE j1(x);\n  INSERT INTO j1(x)\n   VALUES('true'),('false'),('null'),('123'),('-234'),('34.5e+6'),\n         ('\"\"'),('\"\\\"\"'),('\"\\\\\"'),('\"abcdefghijlmnopqrstuvwxyz\"'),\n         ('[]'),('{}'),('[true,false,null,123,-234,34.5e+6,{},[]]'),\n         ('{\"a\":true,\"b\":{\"c\":false}}');\n  SELECT * FROM j1 WHERE NOT json_valid(x);\n} {}\ndo_execsql_test json101-4.2 {\n  SELECT * FROM j1 WHERE NOT json_valid(char(0x20,0x09,0x0a,0x0d)||x);\n} {}\ndo_execsql_test json101-4.3 {\n  SELECT * FROM j1 WHERE NOT json_valid(x||char(0x20,0x09,0x0a,0x0d));\n} {}\n\n# But an empty string, or a string of pure whitespace is not valid JSON.\n#\ndo_execsql_test json101-4.4 {\n  SELECT json_valid(''), json_valid(char(0x20,0x09,0x0a,0x0d));\n} {0 0}\n\n# json_remove() and similar functions with no edit operations return their\n# input unchanged.\n#\ndo_execsql_test json101-4.5 {\n  SELECT x FROM j1 WHERE json_remove(x)<>x;\n} {}\ndo_execsql_test json101-4.6 {\n  SELECT x FROM j1 WHERE json_replace(x)<>x;\n} {}\ndo_execsql_test json101-4.7 {\n  SELECT x FROM j1 WHERE json_set(x)<>x;\n} {}\ndo_execsql_test json101-4.8 {\n  SELECT x FROM j1 WHERE json_insert(x)<>x;\n} {}\n\n# json_extract(JSON,'$') will return objects and arrays without change.\n#\ndo_execsql_test json-4.10 {\n  SELECT count(*) FROM j1 WHERE json_type(x) IN ('object','array');\n  SELECT x FROM j1\n   WHERE json_extract(x,'$')<>x\n     AND json_type(x) IN ('object','array');\n} {4}\n\ndo_execsql_test json-5.1 {\n  CREATE TABLE j2(id INTEGER PRIMARY KEY, json, src);\n  INSERT INTO j2(id,json,src)\n  VALUES(1,'{\n    \"firstName\": \"John\",\n    \"lastName\": \"Smith\",\n    \"isAlive\": true,\n    \"age\": 25,\n    \"address\": {\n      \"streetAddress\": \"21 2nd Street\",\n      \"city\": \"New York\",\n      \"state\": \"NY\",\n      \"postalCode\": \"10021-3100\"\n    },\n    \"phoneNumbers\": [\n      {\n        \"type\": \"home\",\n        \"number\": \"212 555-1234\"\n      },\n      {\n        \"type\": \"office\",\n        \"number\": \"646 555-4567\"\n      }\n    ],\n    \"children\": [],\n    \"spouse\": null\n  }','https://en.wikipedia.org/wiki/JSON');\n  INSERT INTO j2(id,json,src)\n  VALUES(2, '{\n\t\"id\": \"0001\",\n\t\"type\": \"donut\",\n\t\"name\": \"Cake\",\n\t\"ppu\": 0.55,\n\t\"batters\":\n\t\t{\n\t\t\t\"batter\":\n\t\t\t\t[\n\t\t\t\t\t{ \"id\": \"1001\", \"type\": \"Regular\" },\n\t\t\t\t\t{ \"id\": \"1002\", \"type\": \"Chocolate\" },\n\t\t\t\t\t{ \"id\": \"1003\", \"type\": \"Blueberry\" },\n\t\t\t\t\t{ \"id\": \"1004\", \"type\": \"Devil''s Food\" }\n\t\t\t\t]\n\t\t},\n\t\"topping\":\n\t\t[\n\t\t\t{ \"id\": \"5001\", \"type\": \"None\" },\n\t\t\t{ \"id\": \"5002\", \"type\": \"Glazed\" },\n\t\t\t{ \"id\": \"5005\", \"type\": \"Sugar\" },\n\t\t\t{ \"id\": \"5007\", \"type\": \"Powdered Sugar\" },\n\t\t\t{ \"id\": \"5006\", \"type\": \"Chocolate with Sprinkles\" },\n\t\t\t{ \"id\": \"5003\", \"type\": \"Chocolate\" },\n\t\t\t{ \"id\": \"5004\", \"type\": \"Maple\" }\n\t\t]\n   }','https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html');\n   INSERT INTO j2(id,json,src)\n   VALUES(3,'[\n\t{\n\t\t\"id\": \"0001\",\n\t\t\"type\": \"donut\",\n\t\t\"name\": \"Cake\",\n\t\t\"ppu\": 0.55,\n\t\t\"batters\":\n\t\t\t{\n\t\t\t\t\"batter\":\n\t\t\t\t\t[\n\t\t\t\t\t\t{ \"id\": \"1001\", \"type\": \"Regular\" },\n\t\t\t\t\t\t{ \"id\": \"1002\", \"type\": \"Chocolate\" },\n\t\t\t\t\t\t{ \"id\": \"1003\", \"type\": \"Blueberry\" },\n\t\t\t\t\t\t{ \"id\": \"1004\", \"type\": \"Devil''s Food\" }\n\t\t\t\t\t]\n\t\t\t},\n\t\t\"topping\":\n\t\t\t[\n\t\t\t\t{ \"id\": \"5001\", \"type\": \"None\" },\n\t\t\t\t{ \"id\": \"5002\", \"type\": \"Glazed\" },\n\t\t\t\t{ \"id\": \"5005\", \"type\": \"Sugar\" },\n\t\t\t\t{ \"id\": \"5007\", \"type\": \"Powdered Sugar\" },\n\t\t\t\t{ \"id\": \"5006\", \"type\": \"Chocolate with Sprinkles\" },\n\t\t\t\t{ \"id\": \"5003\", \"type\": \"Chocolate\" },\n\t\t\t\t{ \"id\": \"5004\", \"type\": \"Maple\" }\n\t\t\t]\n\t},\n\t{\n\t\t\"id\": \"0002\",\n\t\t\"type\": \"donut\",\n\t\t\"name\": \"Raised\",\n\t\t\"ppu\": 0.55,\n\t\t\"batters\":\n\t\t\t{\n\t\t\t\t\"batter\":\n\t\t\t\t\t[\n\t\t\t\t\t\t{ \"id\": \"1001\", \"type\": \"Regular\" }\n\t\t\t\t\t]\n\t\t\t},\n\t\t\"topping\":\n\t\t\t[\n\t\t\t\t{ \"id\": \"5001\", \"type\": \"None\" },\n\t\t\t\t{ \"id\": \"5002\", \"type\": \"Glazed\" },\n\t\t\t\t{ \"id\": \"5005\", \"type\": \"Sugar\" },\n\t\t\t\t{ \"id\": \"5003\", \"type\": \"Chocolate\" },\n\t\t\t\t{ \"id\": \"5004\", \"type\": \"Maple\" }\n\t\t\t]\n\t},\n\t{\n\t\t\"id\": \"0003\",\n\t\t\"type\": \"donut\",\n\t\t\"name\": \"Old Fashioned\",\n\t\t\"ppu\": 0.55,\n\t\t\"batters\":\n\t\t\t{\n\t\t\t\t\"batter\":\n\t\t\t\t\t[\n\t\t\t\t\t\t{ \"id\": \"1001\", \"type\": \"Regular\" },\n\t\t\t\t\t\t{ \"id\": \"1002\", \"type\": \"Chocolate\" }\n\t\t\t\t\t]\n\t\t\t},\n\t\t\"topping\":\n\t\t\t[\n\t\t\t\t{ \"id\": \"5001\", \"type\": \"None\" },\n\t\t\t\t{ \"id\": \"5002\", \"type\": \"Glazed\" },\n\t\t\t\t{ \"id\": \"5003\", \"type\": \"Chocolate\" },\n\t\t\t\t{ \"id\": \"5004\", \"type\": \"Maple\" }\n\t\t\t]\n\t}\n   ]','https://adobe.github.io/Spry/samples/data_region/JSONDataSetSample.html');\n   SELECT count(*) FROM j2;\n} {3}\n\ndo_execsql_test json-5.2 {\n  SELECT id, json_valid(json), json_type(json), '|' FROM j2 ORDER BY id;\n} {1 1 object | 2 1 object | 3 1 array |}\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# fullkey is always the same as path+key (with appropriate formatting)\n#\ndo_execsql_test json-5.3 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_tree(j2.json) AS jx\n   WHERE fullkey!=(path || CASE WHEN typeof(key)=='integer' THEN '['||key||']'\n                                ELSE '.'||key END);\n} {}\ndo_execsql_test json-5.4 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_each(j2.json) AS jx\n   WHERE fullkey!=(path || CASE WHEN typeof(key)=='integer' THEN '['||key||']'\n                                ELSE '.'||key END);\n} {}\n\n\n# Verify that the json_each.json and json_tree.json output is always the\n# same as input.\n#\ndo_execsql_test json-5.5 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_each(j2.json) AS jx\n   WHERE jx.json<>j2.json;\n} {}\ndo_execsql_test json-5.6 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_tree(j2.json) AS jx\n   WHERE jx.json<>j2.json;\n} {}\ndo_execsql_test json-5.7 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_each(j2.json) AS jx\n   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');\n} {}\ndo_execsql_test json-5.8 {\n  SELECT j2.rowid, jx.rowid, fullkey, path, key\n    FROM j2, json_tree(j2.json) AS jx\n   WHERE jx.value<>jx.atom AND type NOT IN ('array','object');\n} {}\n\ndo_execsql_test json-6.1 {\n  SELECT json_valid('{\"a\":55,\"b\":72,}');\n} {0}\ndo_execsql_test json-6.2 {\n  SELECT json_valid('{\"a\":55,\"b\":72}');\n} {1}\ndo_execsql_test json-6.3 {\n  SELECT json_valid('[\"a\",55,\"b\",72,]');\n} {0}\ndo_execsql_test json-6.4 {\n  SELECT json_valid('[\"a\",55,\"b\",72]');\n} {1}\n\n# White-space tests.  Note that form-feed is not white-space in JSON.\n# ticket [57eec374ae1d0a1d4a23077a95f4e173fe269113]\n# \nforeach {tn isvalid ws} {\n  7.1  1  char(0x20)\n  7.2  1  char(0x09)\n  7.3  1  char(0x0A)\n  7.4  1  char(0x0D)\n  7.5  0  char(0x0C)\n  7.6  1  char(0x20,0x09,0x0a,0x0d,0x20)\n  7.7  0  char(0x20,0x09,0x0a,0x0c,0x0d,0x20)\n} {\n  do_execsql_test json-$tn.1 \\\n    \"SELECT json_valid(printf('%s{%s\\\"x\\\"%s:%s9%s}%s',\n         $::ws,$::ws,$::ws,$::ws,$::ws,$::ws));\" \\\n  $isvalid\n}\n\n# Ticket https://www.sqlite.org/src/info/ad2559db380abf8e\n# Control characters must be escaped in JSON strings.\n#\ndo_execsql_test json-8.1 {\n  DROP TABLE IF EXISTS t8;\n  CREATE TABLE t8(a,b);\n  INSERT INTO t8(a) VALUES('abc' || char(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35) || 'xyz');\n  UPDATE t8 SET b=json_array(a);\n  SELECT b FROM t8;\n} {{[\"abc\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f !\\\"#xyz\"]}}\ndo_execsql_test json-8.2 {\n  SELECT a=json_extract(b,'$[0]') FROM t8;\n} {1}\n\n# 2017-04-12.  Regression reported on the mailing list by Rolf Ade\n#\ndo_execsql_test json-8.3 {\n  SELECT json_valid(char(0x22,0xe4,0x22));\n} {1}\ndo_execsql_test json-8.4 {\n  SELECT unicode(json_extract(char(0x22,228,0x22),'$'));\n} {228}\n\n# The json_quote() function transforms an SQL value into a JSON value.\n# String values are quoted and interior quotes are escaped.  NULL values\n# are rendered as the unquoted string \"null\".\n#\ndo_execsql_test json-9.1 {\n  SELECT json_quote('abc\"xyz');\n} {{\"abc\\\"xyz\"}}\ndo_execsql_test json-9.2 {\n  SELECT json_quote(3.14159);\n} {3.14159}\ndo_execsql_test json-9.3 {\n  SELECT json_quote(12345);\n} {12345}\ndo_execsql_test json-9.4 {\n  SELECT json_quote(null);\n} {\"null\"}\ndo_catchsql_test json-9.5 {\n  SELECT json_quote(x'30313233');\n} {1 {JSON cannot hold BLOB values}}\ndo_catchsql_test json-9.6 {\n  SELECT json_quote(123,456)\n} {1 {wrong number of arguments to function json_quote()}}\ndo_catchsql_test json-9.7 {\n  SELECT json_quote()\n} {1 {wrong number of arguments to function json_quote()}}\n\n# Make sure only valid backslash-escapes are accepted.\n#\ndo_execsql_test json-10.1 {\n  SELECT json_valid('\" \\  \"');\n} {0}\ndo_execsql_test json-10.2 {\n  SELECT json_valid('\" \\! \"');\n} {0}\ndo_execsql_test json-10.3 {\n  SELECT json_valid('\" \\\" \"');\n} {1}\ndo_execsql_test json-10.4 {\n  SELECT json_valid('\" \\# \"');\n} {0}\ndo_execsql_test json-10.5 {\n  SELECT json_valid('\" \\$ \"');\n} {0}\ndo_execsql_test json-10.6 {\n  SELECT json_valid('\" \\% \"');\n} {0}\ndo_execsql_test json-10.7 {\n  SELECT json_valid('\" \\& \"');\n} {0}\ndo_execsql_test json-10.8 {\n  SELECT json_valid('\" \\'' \"');\n} {0}\ndo_execsql_test json-10.9 {\n  SELECT json_valid('\" \\( \"');\n} {0}\ndo_execsql_test json-10.10 {\n  SELECT json_valid('\" \\) \"');\n} {0}\ndo_execsql_test json-10.11 {\n  SELECT json_valid('\" \\* \"');\n} {0}\ndo_execsql_test json-10.12 {\n  SELECT json_valid('\" \\+ \"');\n} {0}\ndo_execsql_test json-10.13 {\n  SELECT json_valid('\" \\, \"');\n} {0}\ndo_execsql_test json-10.14 {\n  SELECT json_valid('\" \\- \"');\n} {0}\ndo_execsql_test json-10.15 {\n  SELECT json_valid('\" \\. \"');\n} {0}\ndo_execsql_test json-10.16 {\n  SELECT json_valid('\" \\/ \"');\n} {1}\ndo_execsql_test json-10.17 {\n  SELECT json_valid('\" \\0 \"');\n} {0}\ndo_execsql_test json-10.18 {\n  SELECT json_valid('\" \\1 \"');\n} {0}\ndo_execsql_test json-10.19 {\n  SELECT json_valid('\" \\2 \"');\n} {0}\ndo_execsql_test json-10.20 {\n  SELECT json_valid('\" \\3 \"');\n} {0}\ndo_execsql_test json-10.21 {\n  SELECT json_valid('\" \\4 \"');\n} {0}\ndo_execsql_test json-10.22 {\n  SELECT json_valid('\" \\5 \"');\n} {0}\ndo_execsql_test json-10.23 {\n  SELECT json_valid('\" \\6 \"');\n} {0}\ndo_execsql_test json-10.24 {\n  SELECT json_valid('\" \\7 \"');\n} {0}\ndo_execsql_test json-10.25 {\n  SELECT json_valid('\" \\8 \"');\n} {0}\ndo_execsql_test json-10.26 {\n  SELECT json_valid('\" \\9 \"');\n} {0}\ndo_execsql_test json-10.27 {\n  SELECT json_valid('\" \\: \"');\n} {0}\ndo_execsql_test json-10.28 {\n  SELECT json_valid('\" \\; \"');\n} {0}\ndo_execsql_test json-10.29 {\n  SELECT json_valid('\" \\< \"');\n} {0}\ndo_execsql_test json-10.30 {\n  SELECT json_valid('\" \\= \"');\n} {0}\ndo_execsql_test json-10.31 {\n  SELECT json_valid('\" \\> \"');\n} {0}\ndo_execsql_test json-10.32 {\n  SELECT json_valid('\" \\? \"');\n} {0}\ndo_execsql_test json-10.33 {\n  SELECT json_valid('\" \\@ \"');\n} {0}\ndo_execsql_test json-10.34 {\n  SELECT json_valid('\" \\A \"');\n} {0}\ndo_execsql_test json-10.35 {\n  SELECT json_valid('\" \\B \"');\n} {0}\ndo_execsql_test json-10.36 {\n  SELECT json_valid('\" \\C \"');\n} {0}\ndo_execsql_test json-10.37 {\n  SELECT json_valid('\" \\D \"');\n} {0}\ndo_execsql_test json-10.38 {\n  SELECT json_valid('\" \\E \"');\n} {0}\ndo_execsql_test json-10.39 {\n  SELECT json_valid('\" \\F \"');\n} {0}\ndo_execsql_test json-10.40 {\n  SELECT json_valid('\" \\G \"');\n} {0}\ndo_execsql_test json-10.41 {\n  SELECT json_valid('\" \\H \"');\n} {0}\ndo_execsql_test json-10.42 {\n  SELECT json_valid('\" \\I \"');\n} {0}\ndo_execsql_test json-10.43 {\n  SELECT json_valid('\" \\J \"');\n} {0}\ndo_execsql_test json-10.44 {\n  SELECT json_valid('\" \\K \"');\n} {0}\ndo_execsql_test json-10.45 {\n  SELECT json_valid('\" \\L \"');\n} {0}\ndo_execsql_test json-10.46 {\n  SELECT json_valid('\" \\M \"');\n} {0}\ndo_execsql_test json-10.47 {\n  SELECT json_valid('\" \\N \"');\n} {0}\ndo_execsql_test json-10.48 {\n  SELECT json_valid('\" \\O \"');\n} {0}\ndo_execsql_test json-10.49 {\n  SELECT json_valid('\" \\P \"');\n} {0}\ndo_execsql_test json-10.50 {\n  SELECT json_valid('\" \\Q \"');\n} {0}\ndo_execsql_test json-10.51 {\n  SELECT json_valid('\" \\R \"');\n} {0}\ndo_execsql_test json-10.52 {\n  SELECT json_valid('\" \\S \"');\n} {0}\ndo_execsql_test json-10.53 {\n  SELECT json_valid('\" \\T \"');\n} {0}\ndo_execsql_test json-10.54 {\n  SELECT json_valid('\" \\U \"');\n} {0}\ndo_execsql_test json-10.55 {\n  SELECT json_valid('\" \\V \"');\n} {0}\ndo_execsql_test json-10.56 {\n  SELECT json_valid('\" \\W \"');\n} {0}\ndo_execsql_test json-10.57 {\n  SELECT json_valid('\" \\X \"');\n} {0}\ndo_execsql_test json-10.58 {\n  SELECT json_valid('\" \\Y \"');\n} {0}\ndo_execsql_test json-10.59 {\n  SELECT json_valid('\" \\Z \"');\n} {0}\ndo_execsql_test json-10.60 {\n  SELECT json_valid('\" \\[ \"');\n} {0}\ndo_execsql_test json-10.61 {\n  SELECT json_valid('\" \\\\ \"');\n} {1}\ndo_execsql_test json-10.62 {\n  SELECT json_valid('\" \\] \"');\n} {0}\ndo_execsql_test json-10.63 {\n  SELECT json_valid('\" \\^ \"');\n} {0}\ndo_execsql_test json-10.64 {\n  SELECT json_valid('\" \\_ \"');\n} {0}\ndo_execsql_test json-10.65 {\n  SELECT json_valid('\" \\` \"');\n} {0}\ndo_execsql_test json-10.66 {\n  SELECT json_valid('\" \\a \"');\n} {0}\ndo_execsql_test json-10.67 {\n  SELECT json_valid('\" \\b \"');\n} {1}\ndo_execsql_test json-10.68 {\n  SELECT json_valid('\" \\c \"');\n} {0}\ndo_execsql_test json-10.69 {\n  SELECT json_valid('\" \\d \"');\n} {0}\ndo_execsql_test json-10.70 {\n  SELECT json_valid('\" \\e \"');\n} {0}\ndo_execsql_test json-10.71 {\n  SELECT json_valid('\" \\f \"');\n} {1}\ndo_execsql_test json-10.72 {\n  SELECT json_valid('\" \\g \"');\n} {0}\ndo_execsql_test json-10.73 {\n  SELECT json_valid('\" \\h \"');\n} {0}\ndo_execsql_test json-10.74 {\n  SELECT json_valid('\" \\i \"');\n} {0}\ndo_execsql_test json-10.75 {\n  SELECT json_valid('\" \\j \"');\n} {0}\ndo_execsql_test json-10.76 {\n  SELECT json_valid('\" \\k \"');\n} {0}\ndo_execsql_test json-10.77 {\n  SELECT json_valid('\" \\l \"');\n} {0}\ndo_execsql_test json-10.78 {\n  SELECT json_valid('\" \\m \"');\n} {0}\ndo_execsql_test json-10.79 {\n  SELECT json_valid('\" \\n \"');\n} {1}\ndo_execsql_test json-10.80 {\n  SELECT json_valid('\" \\o \"');\n} {0}\ndo_execsql_test json-10.81 {\n  SELECT json_valid('\" \\p \"');\n} {0}\ndo_execsql_test json-10.82 {\n  SELECT json_valid('\" \\q \"');\n} {0}\ndo_execsql_test json-10.83 {\n  SELECT json_valid('\" \\r \"');\n} {1}\ndo_execsql_test json-10.84 {\n  SELECT json_valid('\" \\s \"');\n} {0}\ndo_execsql_test json-10.85 {\n  SELECT json_valid('\" \\t \"');\n} {1}\ndo_execsql_test json-10.86.0 {\n  SELECT json_valid('\" \\u \"');\n} {0}\ndo_execsql_test json-10.86.1 {\n  SELECT json_valid('\" \\ua \"');\n} {0}\ndo_execsql_test json-10.86.2 {\n  SELECT json_valid('\" \\uab \"');\n} {0}\ndo_execsql_test json-10.86.3 {\n  SELECT json_valid('\" \\uabc \"');\n} {0}\ndo_execsql_test json-10.86.4 {\n  SELECT json_valid('\" \\uabcd \"');\n} {1}\ndo_execsql_test json-10.86.5 {\n  SELECT json_valid('\" \\uFEDC \"');\n} {1}\ndo_execsql_test json-10.86.6 {\n  SELECT json_valid('\" \\u1234 \"');\n} {1}\ndo_execsql_test json-10.87 {\n  SELECT json_valid('\" \\v \"');\n} {0}\ndo_execsql_test json-10.88 {\n  SELECT json_valid('\" \\w \"');\n} {0}\ndo_execsql_test json-10.89 {\n  SELECT json_valid('\" \\x \"');\n} {0}\ndo_execsql_test json-10.90 {\n  SELECT json_valid('\" \\y \"');\n} {0}\ndo_execsql_test json-10.91 {\n  SELECT json_valid('\" \\z \"');\n} {0}\ndo_execsql_test json-10.92 {\n  SELECT json_valid('\" \\{ \"');\n} {0}\ndo_execsql_test json-10.93 {\n  SELECT json_valid('\" \\| \"');\n} {0}\ndo_execsql_test json-10.94 {\n  SELECT json_valid('\" \\} \"');\n} {0}\ndo_execsql_test json-10.95 {\n  SELECT json_valid('\" \\~ \"');\n} {0}\n\n#--------------------------------------------------------------------------\n# 2017-04-11.  https://www.sqlite.org/src/info/981329adeef51011\n# Stack overflow on deeply nested JSON.\n#\n# The following tests confirm that deeply nested JSON is considered invalid.\n#\ndo_execsql_test json-11.0 {\n  /* Shallow enough to be parsed */\n  SELECT json_valid(printf('%.2000c0%.2000c','[',']'));\n} {1}\ndo_execsql_test json-11.1 {\n  /* Too deep by one */\n  SELECT json_valid(printf('%.2001c0%.2001c','[',']'));\n} {0}\ndo_execsql_test json-11.2 {\n  /* Shallow enough to be parsed { */\n  SELECT json_valid(replace(printf('%.2000c0%.2000c','[','}'),'[','{\"a\":'));\n  /* } */\n} {1}\ndo_execsql_test json-11.3 {\n  /* Too deep by one { */\n  SELECT json_valid(replace(printf('%.2001c0%.2001c','[','}'),'[','{\"a\":'));\n  /* } */\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/json102.test",
    "content": "# 2015-08-12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for JSON SQL functions extension to the\n# SQLite library.\n#\n# This file contains tests automatically generated from the json1\n# documentation.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !json1 {\n  finish_test\n  return\n}\n\ndo_execsql_test json102-100 {\n  SELECT json_object('ex','[52,3.14159]');\n} {{{\"ex\":\"[52,3.14159]\"}}}\ndo_execsql_test json102-110 {\n  SELECT json_object('ex',json('[52,3.14159]'));\n} {{{\"ex\":[52,3.14159]}}}\ndo_execsql_test json102-120 {\n  SELECT json_object('ex',json_array(52,3.14159));\n} {{{\"ex\":[52,3.14159]}}}\ndo_execsql_test json102-130 {\n  SELECT json(' { \"this\" : \"is\", \"a\": [ \"test\" ] } ');\n} {{{\"this\":\"is\",\"a\":[\"test\"]}}}\ndo_execsql_test json102-140 {\n  SELECT json_array(1,2,'3',4);\n} {{[1,2,\"3\",4]}}\ndo_execsql_test json102-150 {\n  SELECT json_array('[1,2]');\n} {{[\"[1,2]\"]}}\ndo_execsql_test json102-160 {\n  SELECT json_array(json_array(1,2));\n} {{[[1,2]]}}\ndo_execsql_test json102-170 {\n  SELECT json_array(1,null,'3','[4,5]','{\"six\":7.7}');\n} {{[1,null,\"3\",\"[4,5]\",\"{\\\"six\\\":7.7}\"]}}\ndo_execsql_test json102-180 {\n  SELECT json_array(1,null,'3',json('[4,5]'),json('{\"six\":7.7}'));\n} {{[1,null,\"3\",[4,5],{\"six\":7.7}]}}\ndo_execsql_test json102-190 {\n  SELECT json_array_length('[1,2,3,4]');\n} {{4}}\ndo_execsql_test json102-200 {\n  SELECT json_array_length('[1,2,3,4]', '$');\n} {{4}}\ndo_execsql_test json102-210 {\n  SELECT json_array_length('[1,2,3,4]', '$[2]');\n} {{0}}\ndo_execsql_test json102-220 {\n  SELECT json_array_length('{\"one\":[1,2,3]}');\n} {{0}}\ndo_execsql_test json102-230 {\n  SELECT json_array_length('{\"one\":[1,2,3]}', '$.one');\n} {{3}}\ndo_execsql_test json102-240 {\n  SELECT json_array_length('{\"one\":[1,2,3]}', '$.two');\n} {{}}\ndo_execsql_test json102-250 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$');\n} {{{\"a\":2,\"c\":[4,5,{\"f\":7}]}}}\ndo_execsql_test json102-260 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$.c');\n} {{[4,5,{\"f\":7}]}}\ndo_execsql_test json102-270 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$.c[2]');\n} {{{\"f\":7}}}\ndo_execsql_test json102-280 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$.c[2].f');\n} {{7}}\ndo_execsql_test json102-290 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5],\"f\":7}','$.c','$.a');\n} {{[[4,5],2]}}\ndo_execsql_test json102-300 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$.x');\n} {{}}\ndo_execsql_test json102-310 {\n  SELECT json_extract('{\"a\":2,\"c\":[4,5,{\"f\":7}]}', '$.x', '$.a');\n} {{[null,2]}}\ndo_execsql_test json102-320 {\n  SELECT json_insert('{\"a\":2,\"c\":4}', '$.a', 99);\n} {{{\"a\":2,\"c\":4}}}\ndo_execsql_test json102-330 {\n  SELECT json_insert('{\"a\":2,\"c\":4}', '$.e', 99);\n} {{{\"a\":2,\"c\":4,\"e\":99}}}\ndo_execsql_test json102-340 {\n  SELECT json_replace('{\"a\":2,\"c\":4}', '$.a', 99);\n} {{{\"a\":99,\"c\":4}}}\ndo_execsql_test json102-350 {\n  SELECT json_replace('{\"a\":2,\"c\":4}', '$.e', 99);\n} {{{\"a\":2,\"c\":4}}}\ndo_execsql_test json102-360 {\n  SELECT json_set('{\"a\":2,\"c\":4}', '$.a', 99);\n} {{{\"a\":99,\"c\":4}}}\ndo_execsql_test json102-370 {\n  SELECT json_set('{\"a\":2,\"c\":4}', '$.e', 99);\n} {{{\"a\":2,\"c\":4,\"e\":99}}}\ndo_execsql_test json102-380 {\n  SELECT json_set('{\"a\":2,\"c\":4}', '$.c', '[97,96]');\n} {{{\"a\":2,\"c\":\"[97,96]\"}}}\ndo_execsql_test json102-390 {\n  SELECT json_set('{\"a\":2,\"c\":4}', '$.c', json('[97,96]'));\n} {{{\"a\":2,\"c\":[97,96]}}}\ndo_execsql_test json102-400 {\n  SELECT json_set('{\"a\":2,\"c\":4}', '$.c', json_array(97,96));\n} {{{\"a\":2,\"c\":[97,96]}}}\ndo_execsql_test json102-410 {\n  SELECT json_object('a',2,'c',4);\n} {{{\"a\":2,\"c\":4}}}\ndo_execsql_test json102-420 {\n  SELECT json_object('a',2,'c','{e:5}');\n} {{{\"a\":2,\"c\":\"{e:5}\"}}}\ndo_execsql_test json102-430 {\n  SELECT json_object('a',2,'c',json_object('e',5));\n} {{{\"a\":2,\"c\":{\"e\":5}}}}\ndo_execsql_test json102-440 {\n  SELECT json_remove('[0,1,2,3,4]','$[2]');\n} {{[0,1,3,4]}}\ndo_execsql_test json102-450 {\n  SELECT json_remove('[0,1,2,3,4]','$[2]','$[0]');\n} {{[1,3,4]}}\ndo_execsql_test json102-460 {\n  SELECT json_remove('[0,1,2,3,4]','$[0]','$[2]');\n} {{[1,2,4]}}\ndo_execsql_test json102-470 {\n  SELECT json_remove('{\"x\":25,\"y\":42}');\n} {{{\"x\":25,\"y\":42}}}\ndo_execsql_test json102-480 {\n  SELECT json_remove('{\"x\":25,\"y\":42}','$.z');\n} {{{\"x\":25,\"y\":42}}}\ndo_execsql_test json102-490 {\n  SELECT json_remove('{\"x\":25,\"y\":42}','$.y');\n} {{{\"x\":25}}}\ndo_execsql_test json102-500 {\n  SELECT json_remove('{\"x\":25,\"y\":42}','$');\n} {{}}\ndo_execsql_test json102-510 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}');\n} {{object}}\ndo_execsql_test json102-520 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$');\n} {{object}}\ndo_execsql_test json102-530 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a');\n} {{array}}\ndo_execsql_test json102-540 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[0]');\n} {{integer}}\ndo_execsql_test json102-550 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[1]');\n} {{real}}\ndo_execsql_test json102-560 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[2]');\n} {{true}}\ndo_execsql_test json102-570 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[3]');\n} {{false}}\ndo_execsql_test json102-580 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[4]');\n} {{null}}\ndo_execsql_test json102-590 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[5]');\n} {{text}}\ndo_execsql_test json102-600 {\n  SELECT json_type('{\"a\":[2,3.5,true,false,null,\"x\"]}','$.a[6]');\n} {{}}\ndo_execsql_test json102-610 {\n  SELECT json_valid(char(123)||'\"x\":35'||char(125));\n} {{1}}\ndo_execsql_test json102-620 {\n  SELECT json_valid(char(123)||'\"x\":35');\n} {{0}}\n\nifcapable vtab {\ndo_execsql_test json102-1000 {\n  CREATE TABLE user(name,phone);\n  INSERT INTO user(name,phone) VALUES\n     ('Alice','[\"919-555-2345\",\"804-555-3621\"]'),\n     ('Bob','[\"201-555-8872\"]'),\n     ('Cindy','[\"704-555-9983\"]'),\n     ('Dave','[\"336-555-8421\",\"704-555-4321\",\"803-911-4421\"]');\n  SELECT DISTINCT user.name\n    FROM user, json_each(user.phone)\n   WHERE json_each.value LIKE '704-%'\n   ORDER BY 1;\n} {Cindy Dave}\n\ndo_execsql_test json102-1010 {\n  UPDATE user\n     SET phone=json_extract(phone,'$[0]')\n   WHERE json_array_length(phone)<2;\n  SELECT name, substr(phone,1,5) FROM user ORDER BY name;\n} {Alice {[\"919} Bob 201-5 Cindy 704-5 Dave {[\"336}}\ndo_execsql_test json102-1011 {\n  SELECT name FROM user WHERE phone LIKE '704-%'\n  UNION\n  SELECT user.name\n    FROM user, json_each(user.phone)\n   WHERE json_valid(user.phone)\n     AND json_each.value LIKE '704-%';\n} {Cindy Dave}\n\ndo_execsql_test json102-1100 {\n  CREATE TABLE big(json JSON);\n  INSERT INTO big(json) VALUES('{\n    \"id\":123,\n    \"stuff\":[1,2,3,4],\n    \"partlist\":[\n       {\"uuid\":\"bb108722-572e-11e5-9320-7f3b63a4ca74\"},\n       {\"uuid\":\"c690dc14-572e-11e5-95f9-dfc8861fd535\"},\n       {\"subassembly\":[\n          {\"uuid\":\"6fa5181e-5721-11e5-a04e-57f3d7b32808\"}\n       ]}\n    ]\n  }');\n  INSERT INTO big(json) VALUES('{\n    \"id\":456,\n    \"stuff\":[\"hello\",\"world\",\"xyzzy\"],\n    \"partlist\":[\n       {\"uuid\":false},\n       {\"uuid\":\"c690dc14-572e-11e5-95f9-dfc8861fd535\"}\n    ]\n  }');\n} {}\nset correct_answer [list \\\n    1 {$.id} 123 \\\n    1 {$.stuff[0]} 1 \\\n    1 {$.stuff[1]} 2 \\\n    1 {$.stuff[2]} 3 \\\n    1 {$.stuff[3]} 4 \\\n    1 {$.partlist[0].uuid} bb108722-572e-11e5-9320-7f3b63a4ca74 \\\n    1 {$.partlist[1].uuid} c690dc14-572e-11e5-95f9-dfc8861fd535 \\\n    1 {$.partlist[2].subassembly[0].uuid} 6fa5181e-5721-11e5-a04e-57f3d7b32808 \\\n    2 {$.id} 456 \\\n    2 {$.stuff[0]} hello \\\n    2 {$.stuff[1]} world \\\n    2 {$.stuff[2]} xyzzy \\\n    2 {$.partlist[0].uuid} 0 \\\n    2 {$.partlist[1].uuid} c690dc14-572e-11e5-95f9-dfc8861fd535]\ndo_execsql_test json102-1110 {\n  SELECT big.rowid, fullkey, value\n    FROM big, json_tree(big.json)\n   WHERE json_tree.type NOT IN ('object','array')\n   ORDER BY +big.rowid, +json_tree.id\n} $correct_answer\ndo_execsql_test json102-1120 {\n  SELECT big.rowid, fullkey, atom\n    FROM big, json_tree(big.json)\n   WHERE atom IS NOT NULL\n   ORDER BY +big.rowid, +json_tree.id\n} $correct_answer\n\ndo_execsql_test json102-1130 {\n  SELECT DISTINCT json_extract(big.json,'$.id')\n    FROM big, json_tree(big.json,'$.partlist')\n   WHERE json_tree.key='uuid'\n     AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';\n} {123}\ndo_execsql_test json102-1131 {\n  SELECT DISTINCT json_extract(big.json,'$.id')\n    FROM big, json_tree(big.json,'$')\n   WHERE json_tree.key='uuid'\n     AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';\n} {123}\ndo_execsql_test json102-1132 {\n  SELECT DISTINCT json_extract(big.json,'$.id')\n    FROM big, json_tree(big.json)\n   WHERE json_tree.key='uuid'\n     AND json_tree.value='6fa5181e-5721-11e5-a04e-57f3d7b32808';\n} {123}\n} ;# end ifcapable vtab\n\n#-------------------------------------------------------------------------\n# Test that json_valid() correctly identifies non-ascii range \n# characters as non-whitespace.\n#\ndo_execsql_test json102-1201 { SELECT json_valid(char(32)  || '\"xyz\"') } 1\ndo_execsql_test json102-1202 { SELECT json_valid(char(200) || '\"xyz\"') } 0\n\n# Off-by-one error in jsonAppendString()\n#\nfor {set i 0} {$i<100} {incr i} {\n  set str abcdef[string repeat \\\" [expr {$i+50}]]uvwxyz\n  do_test json102-[format %d [expr {$i+1300}]] {\n    db eval {SELECT json_extract(json_array($::str),'$[0]')==$::str}\n  } {1}\n}\n\n#-------------------------------------------------------------------------\n# 2017-04-08 ticket b93be8729a895a528e2849fca99f7\n# JSON extension accepts invalid numeric values\n#\n# JSON does not allow leading zeros.  But the JSON extension was\n# allowing them.  The following tests verify that the problem is now\n# fixed.\n#\ndo_execsql_test json102-1401 { SELECT json_valid('{\"x\":01}') } 0\ndo_execsql_test json102-1402 { SELECT json_valid('{\"x\":-01}') } 0\ndo_execsql_test json102-1403 { SELECT json_valid('{\"x\":0}') } 1\ndo_execsql_test json102-1404 { SELECT json_valid('{\"x\":-0}') } 1\ndo_execsql_test json102-1405 { SELECT json_valid('{\"x\":0.1}') } 1\ndo_execsql_test json102-1406 { SELECT json_valid('{\"x\":-0.1}') } 1\ndo_execsql_test json102-1407 { SELECT json_valid('{\"x\":0.0000}') } 1\ndo_execsql_test json102-1408 { SELECT json_valid('{\"x\":-0.0000}') } 1\ndo_execsql_test json102-1409 { SELECT json_valid('{\"x\":01.5}') } 0\ndo_execsql_test json102-1410 { SELECT json_valid('{\"x\":-01.5}') } 0\ndo_execsql_test json102-1411 { SELECT json_valid('{\"x\":00}') } 0\ndo_execsql_test json102-1412 { SELECT json_valid('{\"x\":-00}') } 0\n\n#------------------------------------------------------------------------\n# 2017-04-10 ticket 6c9b5514077fed34551f98e64c09a10dc2fc8e16\n# JSON extension accepts strings containing control characters.\n#\n# The JSON spec requires that all control characters be escaped.\n#\ndo_execsql_test json102-1500 {\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<0x20)\n  SELECT x FROM c WHERE json_valid(printf('{\"a\":\"x%sz\"}', char(x))) ORDER BY x;\n} {32}\n\n# All control characters are escaped\n#\ndo_execsql_test json102-1501 {\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<0x1f)\n  SELECT sum(json_valid(json_quote('a'||char(x)||'z'))) FROM c ORDER BY x;\n} {31}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/json103.test",
    "content": "# 2015-12-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for JSON aggregate SQL functions\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !json1 {\n  finish_test\n  return\n}\n\ndo_execsql_test json103-100 {\n  CREATE TABLE t1(a,b,c);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<100)\n  INSERT INTO t1(a,b,c) SELECT x, x%3, printf('n%d',x)  FROM c;\n  UPDATE t1 SET a='orange' WHERE rowid=39;\n  UPDATE t1 SET a=32.5 WHERE rowid=31;\n  UPDATE t1 SET a=x'303132' WHERE rowid=29;\n  UPDATE t1 SET a=NULL WHERE rowid=37;\n  SELECT json_group_array(a) FROM t1 WHERE a<0 AND typeof(a)!='blob';\n} {{[]}}\ndo_catchsql_test json103-101 {\n  SELECT json_group_array(a) FROM t1;\n} {1 {JSON cannot hold BLOB values}}\ndo_execsql_test json103-110 {\n  SELECT json_group_array(a) FROM t1\n   WHERE rowid BETWEEN 31 AND 39;\n} {{[32.5,32,33,34,35,36,null,38,\"orange\"]}}\ndo_execsql_test json103-111 {\n  SELECT json_array_length(json_group_array(a)) FROM t1\n   WHERE rowid BETWEEN 31 AND 39;\n} {9}\ndo_execsql_test json103-120 {\n  SELECT b, json_group_array(a) FROM t1 WHERE rowid<10 GROUP BY b ORDER BY b;\n} {0 {[3,6,9]} 1 {[1,4,7]} 2 {[2,5,8]}}\n\ndo_execsql_test json103-200 {\n  SELECT json_group_object(c,a) FROM t1 WHERE a<0 AND typeof(a)!='blob';\n} {{{}}}\ndo_catchsql_test json103-201 {\n  SELECT json_group_object(c,a) FROM t1;\n} {1 {JSON cannot hold BLOB values}}\n\ndo_execsql_test json103-210 {\n  SELECT json_group_object(c,a) FROM t1\n   WHERE rowid BETWEEN 31 AND 39 AND rowid%2==1;\n} {{{\"n31\":32.5,\"n33\":33,\"n35\":35,\"n37\":null,\"n39\":\"orange\"}}}\ndo_execsql_test json103-220 {\n  SELECT b, json_group_object(c,a) FROM t1\n   WHERE rowid<7 GROUP BY b ORDER BY b;\n} {0 {{\"n3\":3,\"n6\":6}} 1 {{\"n1\":1,\"n4\":4}} 2 {{\"n2\":2,\"n5\":5}}}\n\n# ticket https://www.sqlite.org/src/info/f45ac567eaa9f93c 2016-01-30\n# Invalid JSON generated by json_group_array() \n#\n# The underlying problem is a failure to reset Mem.eSubtype\n#\ndo_execsql_test json103-300 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1),('abc');\n  SELECT\n     json_group_array(x),\n     json_group_array(json_object('x',x))\n    FROM t1;\n} {{[1,\"abc\"]} {[{\"x\":1},{\"x\":\"abc\"}]}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/json104.test",
    "content": "# 2017-03-22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for json_patch(A,B) SQL function.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !json1 {\n  finish_test\n  return\n}\n\n# This is the example from pages 2 and 3 of RFC-7396\ndo_execsql_test json104-100 {\n  SELECT json_patch('{\n       \"a\": \"b\",\n       \"c\": {\n         \"d\": \"e\",\n         \"f\": \"g\"\n       }\n     }','{\n       \"a\":\"z\",\n       \"c\": {\n         \"f\": null\n       }\n     }');\n} {{{\"a\":\"z\",\"c\":{\"d\":\"e\"}}}}\n\n\n# This is the example from pages 4 and 5 of RFC-7396 \ndo_execsql_test json104-110 {\n  SELECT json_patch('{\n       \"title\": \"Goodbye!\",\n       \"author\" : {\n         \"givenName\" : \"John\",\n         \"familyName\" : \"Doe\"\n       },\n       \"tags\":[ \"example\", \"sample\" ],\n       \"content\": \"This will be unchanged\"\n     }','{\n       \"title\": \"Hello!\",\n       \"phoneNumber\": \"+01-123-456-7890\",\n       \"author\": {\n         \"familyName\": null\n       },\n       \"tags\": [ \"example\" ]\n     }');\n} {{{\"title\":\"Hello!\",\"author\":{\"givenName\":\"John\"},\"tags\":[\"example\"],\"content\":\"This will be unchanged\",\"phoneNumber\":\"+01-123-456-7890\"}}}\n\ndo_execsql_test json104-200 {\n  SELECT json_patch('[1,2,3]','{\"x\":null}');\n} {{{}}}\ndo_execsql_test json104-210 {\n  SELECT json_patch('[1,2,3]','{\"x\":null,\"y\":1,\"z\":null}');\n} {{{\"y\":1}}}\ndo_execsql_test json104-220 {\n  SELECT json_patch('{}','{\"a\":{\"bb\":{\"ccc\":null}}}');\n} {{{\"a\":{\"bb\":{}}}}}\ndo_execsql_test json104-221 {\n  SELECT json_patch('{}','{\"a\":{\"bb\":{\"ccc\":[1,null,3]}}}');\n} {{{\"a\":{\"bb\":{\"ccc\":[1,null,3]}}}}}\ndo_execsql_test json104-222 {\n  SELECT json_patch('{}','{\"a\":{\"bb\":{\"ccc\":[1,{\"dddd\":null},3]}}}');\n} {{{\"a\":{\"bb\":{\"ccc\":[1,{\"dddd\":null},3]}}}}}\n\n# Example test cases at the end of the RFC-7396 document\ndo_execsql_test json104-300 {\n  SELECT json_patch('{\"a\":\"b\"}','{\"a\":\"c\"}');\n} {{{\"a\":\"c\"}}}\ndo_execsql_test json104-300a {\n  SELECT coalesce(json_patch(null,'{\"a\":\"c\"}'), 'real-null');\n} {{real-null}}\ndo_execsql_test json104-301 {\n  SELECT json_patch('{\"a\":\"b\"}','{\"b\":\"c\"}');\n} {{{\"a\":\"b\",\"b\":\"c\"}}}\ndo_execsql_test json104-302 {\n  SELECT json_patch('{\"a\":\"b\"}','{\"a\":null}');\n} {{{}}}\ndo_execsql_test json104-303 {\n  SELECT json_patch('{\"a\":\"b\",\"b\":\"c\"}','{\"a\":null}');\n} {{{\"b\":\"c\"}}}\ndo_execsql_test json104-304 {\n  SELECT json_patch('{\"a\":[\"b\"]}','{\"a\":\"c\"}');\n} {{{\"a\":\"c\"}}}\ndo_execsql_test json104-305 {\n  SELECT json_patch('{\"a\":\"c\"}','{\"a\":[\"b\"]}');\n} {{{\"a\":[\"b\"]}}}\ndo_execsql_test json104-306 {\n  SELECT json_patch('{\"a\":{\"b\":\"c\"}}','{\"a\":{\"b\":\"d\",\"c\":null}}');\n} {{{\"a\":{\"b\":\"d\"}}}}\ndo_execsql_test json104-307 {\n  SELECT json_patch('{\"a\":[{\"b\":\"c\"}]}','{\"a\":[1]}');\n} {{{\"a\":[1]}}}\ndo_execsql_test json104-308 {\n  SELECT json_patch('[\"a\",\"b\"]','[\"c\",\"d\"]');\n} {{[\"c\",\"d\"]}}\ndo_execsql_test json104-309 {\n  SELECT json_patch('{\"a\":\"b\"}','[\"c\"]');\n} {{[\"c\"]}}\ndo_execsql_test json104-310 {\n  SELECT json_patch('{\"a\":\"foo\"}','null');\n} {{null}}\ndo_execsql_test json104-310a {\n  SELECT coalesce(json_patch('{\"a\":\"foo\"}',null), 'real-null');\n} {{real-null}}\ndo_execsql_test json104-311 {\n  SELECT json_patch('{\"a\":\"foo\"}','\"bar\"');\n} {{\"bar\"}}\ndo_execsql_test json104-312 {\n  SELECT json_patch('{\"e\":null}','{\"a\":1}');\n} {{{\"e\":null,\"a\":1}}}\ndo_execsql_test json104-313 {\n  SELECT json_patch('[1,2]','{\"a\":\"b\",\"c\":null}');\n} {{{\"a\":\"b\"}}}\ndo_execsql_test json104-314 {\n  SELECT json_patch('{}','{\"a\":{\"bb\":{\"ccc\":null}}}');\n} {{{\"a\":{\"bb\":{}}}}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/keyword1.test",
    "content": "# 2009 January 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Verify that certain keywords can be used as identifiers.\n#\n# $Id: keyword1.test,v 1.1 2009/01/29 19:27:47 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndb eval {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n  INSERT INTO t1 VALUES(3, 'three');\n}\n\nset kwlist {\n  abort\n  after\n  analyze\n  asc\n  attach\n  before\n  begin\n  by\n  cascade\n  cast\n  column\n  conflict\n  current_date\n  current_time\n  current_timestamp\n  database\n  deferred\n  desc\n  detach\n  end\n  each\n  exclusive\n  explain\n  fail\n  for\n  glob\n  if\n  ignore\n  immediate\n  initially\n  instead\n  key\n  like\n  match\n  of\n  offset\n  plan\n  pragma\n  query\n  raise\n  recursive\n  regexp\n  reindex\n  release\n  rename\n  replace\n  restrict\n  rollback\n  row\n  savepoint\n  temp\n  temporary\n  trigger\n  vacuum\n  view\n  virtual\n  with\n  without\n};\nset exprkw {\n  cast\n  current_date\n  current_time\n  current_timestamp\n  raise\n}\nforeach kw $kwlist {  \n  do_test keyword1-$kw.1 {\n    if {$kw==\"if\"} {\n      db eval \"CREATE TABLE \\\"$kw\\\"($kw $kw)\"\n    } else {\n      db eval \"CREATE TABLE ${kw}($kw $kw)\"\n    }\n    db eval \"INSERT INTO $kw VALUES(99)\"\n    db eval \"INSERT INTO $kw SELECT a FROM t1\"\n    if {[lsearch $exprkw $kw]<0} {\n      db eval \"SELECT * FROM $kw ORDER BY $kw ASC\"\n    } else {\n      db eval \"SELECT * FROM $kw ORDER BY \\\"$kw\\\" ASC\"\n    }\n  } {1 2 3 99}\n  do_test keyword1-$kw.2 {\n    if {$kw==\"if\"} {\n      db eval \"DROP TABLE \\\"$kw\\\"\"\n      db eval \"CREATE INDEX \\\"$kw\\\" ON t1(a)\"\n    } else {\n      db eval \"DROP TABLE $kw\"\n      db eval \"CREATE INDEX $kw ON t1(a)\"\n    }\n    db eval \"SELECT b FROM t1 INDEXED BY $kw WHERE a=2\"\n  } {two}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/kvtest.c",
    "content": "/*\n** 2016-12-28\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file implements \"key-value\" performance test for SQLite.  The\n** purpose is to compare the speed of SQLite for accessing large BLOBs\n** versus reading those same BLOB values out of individual files in the\n** filesystem.\n**\n** Run \"kvtest\" with no arguments for on-line help, or see comments below.\n**\n** HOW TO COMPILE:\n**\n** (1) Gather this source file and a recent SQLite3 amalgamation with its\n**     header into the working directory.  You should have:\n**\n**          kvtest.c       >--- this file\n**          sqlite3.c      \\___ SQLite\n**          sqlite3.h      /    amlagamation & header\n**\n** (2) Run you compiler against the two C source code files.\n**\n**    (a) On linux or mac:\n**\n**        OPTS=\"-DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION\"\n**        gcc -Os -I. $OPTS kvtest.c sqlite3.c -o kvtest\n**\n**             The $OPTS options can be omitted.  The $OPTS merely omit\n**             the need to link against -ldl and -lpthread, or whatever\n**             the equivalent libraries are called on your system.\n**\n**    (b) Windows with MSVC:\n**\n**        cl -I. kvtest.c sqlite3.c\n**\n** USAGE:\n**\n** (1) Create a test database by running \"kvtest init\" with appropriate\n**     options.  See the help message for available options.\n**\n** (2) Construct the corresponding pile-of-files database on disk using\n**     the \"kvtest export\" command.\n**\n** (3) Run tests using \"kvtest run\" against either the SQLite database or\n**     the pile-of-files database and with appropriate options.\n**\n** For example:\n**\n**       ./kvtest init x1.db --count 100000 --size 10000\n**       mkdir x1\n**       ./kvtest export x1.db x1\n**       ./kvtest run x1.db --count 10000 --max-id 1000000\n**       ./kvtest run x1 --count 10000 --max-id 1000000\n*/\nstatic const char zHelp[] = \n\"Usage: kvtest COMMAND ARGS...\\n\"\n\"\\n\"\n\"   kvtest init DBFILE --count N --size M --pagesize X\\n\"\n\"\\n\"\n\"        Generate a new test database file named DBFILE containing N\\n\"\n\"        BLOBs each of size M bytes.  The page size of the new database\\n\"\n\"        file will be X.  Additional options:\\n\"\n\"\\n\"\n\"           --variance V           Randomly vary M by plus or minus V\\n\"\n\"\\n\"\n\"   kvtest export DBFILE DIRECTORY [--tree]\\n\"\n\"\\n\"\n\"        Export all the blobs in the kv table of DBFILE into separate\\n\"\n\"        files in DIRECTORY.  DIRECTORY is created if it does not previously\\n\"\n\"        exist.  If the --tree option is used, then the blobs are written\\n\"\n\"        into a hierarchy of directories, using names like 00/00/00,\\n\"\n\"        00/00/01, 00/00/02, and so forth.  Without the --tree option, all\\n\"\n\"        files are in the top-level directory with names like 000000, 000001,\\n\"\n\"        000002, and so forth.\\n\"\n\"\\n\"\n\"   kvtest stat DBFILE [options]\\n\"\n\"\\n\"\n\"        Display summary information about DBFILE.  Options:\\n\"\n\"\\n\"\n\"           --vacuum               Run VACUUM on the database file\\n\"\n\"\\n\"\n\"   kvtest run DBFILE [options]\\n\"\n\"\\n\"\n\"        Run a performance test.  DBFILE can be either the name of a\\n\"\n\"        database or a directory containing sample files.  Options:\\n\"\n\"\\n\"\n\"           --asc                  Read blobs in ascending order\\n\"\n\"           --blob-api             Use the BLOB API\\n\"\n\"           --cache-size N         Database cache size\\n\"\n\"           --count N              Read N blobs\\n\"\n\"           --desc                 Read blobs in descending order\\n\"\n\"           --fsync                Synchronous file writes\\n\"\n\"           --integrity-check      Run \\\"PRAGMA integrity_check\\\" after test\\n\"\n\"           --max-id N             Maximum blob key to use\\n\"\n\"           --mmap N               Mmap as much as N bytes of DBFILE\\n\"\n\"           --multitrans           Each read or write in its own transaction\\n\"\n\"           --nocheckpoint         Omit the checkpoint on WAL mode writes\\n\"\n\"           --nosync               Set \\\"PRAGMA synchronous=OFF\\\"\\n\"\n\"           --jmode MODE           Set MODE journal mode prior to starting\\n\"\n\"           --random               Read blobs in a random order\\n\"\n\"           --start N              Start reading with this blob key\\n\"\n\"           --stats                Output operating stats before exiting\\n\"\n\"           --update               Do an overwrite test\\n\"\n;\n\n/* Reference resources used */\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <assert.h>\n#include <string.h>\n#include \"sqlite3.h\"\n\n#ifndef _WIN32\n# include <unistd.h>\n#else\n  /* Provide Windows equivalent for the needed parts of unistd.h */\n# include <direct.h>\n# include <io.h>\n# define R_OK 2\n# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)\n# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)\n# define access _access\n#endif\n\n#include <stdint.h>\n\n/*\n** The following macros are used to cast pointers to integers and\n** integers to pointers.  The way you do this varies from one compiler\n** to the next, so we have developed the following set of #if statements\n** to generate appropriate macros for a wide range of compilers.\n**\n** The correct \"ANSI\" way to do this is to use the intptr_t type.\n** Unfortunately, that typedef is not available on all compilers, or\n** if it is available, it requires an #include of specific headers\n** that vary from one machine to the next.\n**\n** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on\n** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).\n** So we have to define the macros in different ways depending on the\n** compiler.\n*/\n#if defined(__PTRDIFF_TYPE__)  /* This case should work for GCC */\n# define SQLITE_INT_TO_PTR(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n# define SQLITE_PTR_TO_INT(X)  ((sqlite3_int64)(__PTRDIFF_TYPE__)(X))\n#else\n# define SQLITE_INT_TO_PTR(X)  ((void*)(intptr_t)(X))\n# define SQLITE_PTR_TO_INT(X)  ((sqlite3_int64)(intptr_t)(X))\n#endif\n\n/*\n** Show thqe help text and quit.\n*/\nstatic void showHelp(void){\n  fprintf(stdout, \"%s\", zHelp);\n  exit(1);\n}\n\n/*\n** Show an error message an quit.\n*/\nstatic void fatalError(const char *zFormat, ...){\n  va_list ap;\n  fprintf(stdout, \"ERROR: \");\n  va_start(ap, zFormat);\n  vfprintf(stdout, zFormat, ap);\n  va_end(ap);\n  fprintf(stdout, \"\\n\");\n  exit(1);\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic int integerValue(const char *zArg){\n  int v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( zArg[0]>='0' && zArg[0]<='9' ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  return isNeg? -v : v;\n}\n\n\n/*\n** Check the filesystem object zPath.  Determine what it is:\n**\n**    PATH_DIR     A single directory holding many files\n**    PATH_TREE    A directory hierarchy with files at the leaves\n**    PATH_DB      An SQLite database\n**    PATH_NEXIST  Does not exist\n**    PATH_OTHER   Something else\n**\n** PATH_DIR means all of the separate files are grouped together\n** into a single directory with names like 000000, 000001, 000002, and\n** so forth.  PATH_TREE means there is a hierarchy of directories so\n** that no single directory has too many entries.  The files have names\n** like 00/00/00, 00/00/01, 00/00/02 and so forth.  The decision between\n** PATH_DIR and PATH_TREE is determined by the presence of a subdirectory\n** named \"00\" at the top-level.\n*/\n#define PATH_DIR     1\n#define PATH_TREE    2\n#define PATH_DB      3\n#define PATH_NEXIST  0\n#define PATH_OTHER   99\nstatic int pathType(const char *zPath){\n  struct stat x;\n  int rc;\n  if( access(zPath,R_OK) ) return PATH_NEXIST;\n  memset(&x, 0, sizeof(x));\n  rc = stat(zPath, &x);\n  if( rc<0 ) return PATH_OTHER;\n  if( S_ISDIR(x.st_mode) ){\n    char *zLayer1 = sqlite3_mprintf(\"%s/00\", zPath);\n    memset(&x, 0, sizeof(x));\n    rc = stat(zLayer1, &x);\n    sqlite3_free(zLayer1);\n    if( rc<0 ) return PATH_DIR;\n    if( S_ISDIR(x.st_mode) ) return PATH_TREE;\n    return PATH_DIR;\n  }\n  if( (x.st_size%512)==0 ) return PATH_DB;\n  return PATH_OTHER;\n}\n\n/*\n** Return the size of a file in bytes.  Or return -1 if the\n** named object is not a regular file or does not exist.\n*/\nstatic sqlite3_int64 fileSize(const char *zPath){\n  struct stat x;\n  int rc;\n  memset(&x, 0, sizeof(x));\n  rc = stat(zPath, &x);\n  if( rc<0 ) return -1;\n  if( !S_ISREG(x.st_mode) ) return -1;\n  return x.st_size;\n}\n\n/*\n** A Pseudo-random number generator with a fixed seed.  Use this so\n** that the same sequence of \"random\" numbers are generated on each\n** run, for repeatability.\n*/\nstatic unsigned int randInt(void){\n  static unsigned int x = 0x333a13cd;\n  static unsigned int y = 0xecb2adea;\n  x = (x>>1) ^ ((1+~(x&1)) & 0xd0000001);\n  y = y*1103515245 + 12345;\n  return x^y;\n}\n\n/*\n** Do database initialization.\n*/\nstatic int initMain(int argc, char **argv){\n  char *zDb;\n  int i, rc;\n  int nCount = 1000;\n  int sz = 10000;\n  int iVariance = 0;\n  int pgsz = 4096;\n  sqlite3 *db;\n  char *zSql;\n  char *zErrMsg = 0;\n\n  assert( strcmp(argv[1],\"init\")==0 );\n  assert( argc>=3 );\n  zDb = argv[2];\n  for(i=3; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) fatalError(\"unknown argument: \\\"%s\\\"\", z);\n    if( z[1]=='-' ) z++;\n    if( strcmp(z, \"-count\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      nCount = integerValue(argv[++i]);\n      if( nCount<1 ) fatalError(\"the --count must be positive\");\n      continue;\n    }\n    if( strcmp(z, \"-size\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      sz = integerValue(argv[++i]);\n      if( sz<1 ) fatalError(\"the --size must be positive\");\n      continue;\n    }\n    if( strcmp(z, \"-variance\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      iVariance = integerValue(argv[++i]);\n      continue;\n    }\n    if( strcmp(z, \"-pagesize\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      pgsz = integerValue(argv[++i]);\n      if( pgsz<512 || pgsz>65536 || ((pgsz-1)&pgsz)!=0 ){\n        fatalError(\"the --pagesize must be power of 2 between 512 and 65536\");\n      }\n      continue;\n    }\n    fatalError(\"unknown option: \\\"%s\\\"\", argv[i]);\n  }\n  rc = sqlite3_open(zDb, &db);\n  if( rc ){\n    fatalError(\"cannot open database \\\"%s\\\": %s\", zDb, sqlite3_errmsg(db));\n  }\n  zSql = sqlite3_mprintf(\n    \"DROP TABLE IF EXISTS kv;\\n\"\n    \"PRAGMA page_size=%d;\\n\"\n    \"VACUUM;\\n\"\n    \"BEGIN;\\n\"\n    \"CREATE TABLE kv(k INTEGER PRIMARY KEY, v BLOB);\\n\"\n    \"WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<%d)\"\n    \" INSERT INTO kv(k,v) SELECT x, randomblob(%d+(random()%%(%d))) FROM c;\\n\"\n    \"COMMIT;\\n\",\n    pgsz, nCount, sz, iVariance+1\n  );\n  rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg);\n  if( rc ) fatalError(\"database create failed: %s\", zErrMsg);\n  sqlite3_free(zSql);\n  sqlite3_close(db);\n  return 0;\n}\n\n/*\n** Analyze an existing database file.  Report its content.\n*/\nstatic int statMain(int argc, char **argv){\n  char *zDb;\n  int i, rc;\n  sqlite3 *db;\n  char *zSql;\n  sqlite3_stmt *pStmt;\n  int doVacuum = 0;\n\n  assert( strcmp(argv[1],\"stat\")==0 );\n  assert( argc>=3 );\n  zDb = argv[2];\n  for(i=3; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) fatalError(\"unknown argument: \\\"%s\\\"\", z);\n    if( z[1]=='-' ) z++;\n    if( strcmp(z, \"-vacuum\")==0 ){\n      doVacuum = 1;\n      continue;\n    }\n    fatalError(\"unknown option: \\\"%s\\\"\", argv[i]);\n  }\n  rc = sqlite3_open(zDb, &db);\n  if( rc ){\n    fatalError(\"cannot open database \\\"%s\\\": %s\", zDb, sqlite3_errmsg(db));\n  }\n  if( doVacuum ){\n    printf(\"Vacuuming....\"); fflush(stdout);\n    sqlite3_exec(db, \"VACUUM\", 0, 0, 0);\n    printf(\"       done\\n\");\n  }\n  zSql = sqlite3_mprintf(\n    \"SELECT count(*), min(length(v)), max(length(v)), avg(length(v))\"\n    \"  FROM kv\"\n  );\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc ) fatalError(\"cannot prepare SQL [%s]: %s\", zSql, sqlite3_errmsg(db));\n  sqlite3_free(zSql);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"Number of entries:  %8d\\n\", sqlite3_column_int(pStmt, 0));\n    printf(\"Average value size: %8d\\n\", sqlite3_column_int(pStmt, 3));\n    printf(\"Minimum value size: %8d\\n\", sqlite3_column_int(pStmt, 1));\n    printf(\"Maximum value size: %8d\\n\", sqlite3_column_int(pStmt, 2));\n  }else{\n    printf(\"No rows\\n\");\n  }\n  sqlite3_finalize(pStmt);\n  zSql = sqlite3_mprintf(\"PRAGMA page_size\");\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc ) fatalError(\"cannot prepare SQL [%s]: %s\", zSql, sqlite3_errmsg(db));\n  sqlite3_free(zSql);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"Page-size:          %8d\\n\", sqlite3_column_int(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  zSql = sqlite3_mprintf(\"PRAGMA page_count\");\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc ) fatalError(\"cannot prepare SQL [%s]: %s\", zSql, sqlite3_errmsg(db));\n  sqlite3_free(zSql);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"Page-count:         %8d\\n\", sqlite3_column_int(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  zSql = sqlite3_mprintf(\"PRAGMA freelist_count\");\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc ) fatalError(\"cannot prepare SQL [%s]: %s\", zSql, sqlite3_errmsg(db));\n  sqlite3_free(zSql);\n  if( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"Freelist-count:     %8d\\n\", sqlite3_column_int(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  rc = sqlite3_prepare_v2(db, \"PRAGMA integrity_check(10)\", -1, &pStmt, 0);\n  if( rc ) fatalError(\"cannot prepare integrity check: %s\", sqlite3_errmsg(db));\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    printf(\"Integrity-check:    %s\\n\", sqlite3_column_text(pStmt, 0));\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_close(db);\n  return 0;\n}\n\n/*\n**      remember(V,PTR)\n**\n** Return the integer value V.  Also save the value of V in a\n** C-language variable whose address is PTR.\n*/\nstatic void rememberFunc(\n  sqlite3_context *pCtx,\n  int argc,\n  sqlite3_value **argv\n){\n  sqlite3_int64 v;\n  sqlite3_int64 ptr;\n  assert( argc==2 );\n  v = sqlite3_value_int64(argv[0]);\n  ptr = sqlite3_value_int64(argv[1]);\n  *(sqlite3_int64*)SQLITE_INT_TO_PTR(ptr) = v;\n  sqlite3_result_int64(pCtx, v);\n}\n\n/*\n** Make sure a directory named zDir exists.\n*/\nstatic void kvtest_mkdir(const char *zDir){\n#if defined(_WIN32)\n  (void)mkdir(zDir);\n#else\n  (void)mkdir(zDir, 0755);\n#endif\n}\n\n/*\n** Export the kv table to individual files in the filesystem\n*/\nstatic int exportMain(int argc, char **argv){\n  char *zDb;\n  char *zDir;\n  sqlite3 *db;\n  sqlite3_stmt *pStmt;\n  int rc;\n  int ePathType;\n  int nFN;\n  char *zFN;\n  char *zTail;\n  size_t nWrote;\n  int i;\n\n  assert( strcmp(argv[1],\"export\")==0 );\n  assert( argc>=3 );\n  if( argc<4 ) fatalError(\"Usage: kvtest export DATABASE DIRECTORY [OPTIONS]\");\n  zDb = argv[2];\n  zDir = argv[3];\n  kvtest_mkdir(zDir);\n  for(i=4; i<argc; i++){\n    const char *z = argv[i];\n    if( z[0]=='-' && z[1]=='-' ) z++;\n    if( strcmp(z,\"-tree\")==0 ){\n      zFN = sqlite3_mprintf(\"%s/00\", zDir);\n      kvtest_mkdir(zFN);\n      sqlite3_free(zFN);\n      continue;\n    }\n    fatalError(\"unknown argument: \\\"%s\\\"\\n\", argv[i]);\n  }\n  ePathType = pathType(zDir);\n  if( ePathType!=PATH_DIR && ePathType!=PATH_TREE ){\n    fatalError(\"object \\\"%s\\\" is not a directory\", zDir);\n  }\n  rc = sqlite3_open(zDb, &db);\n  if( rc ){\n    fatalError(\"cannot open database \\\"%s\\\": %s\", zDb, sqlite3_errmsg(db));\n  }\n  rc = sqlite3_prepare_v2(db, \"SELECT k, v FROM kv ORDER BY k\", -1, &pStmt, 0);\n  if( rc ){\n    fatalError(\"prepare_v2 failed: %s\\n\", sqlite3_errmsg(db));\n  }\n  nFN = (int)strlen(zDir);\n  zFN = sqlite3_mprintf(\"%s/00/00/00.extra---------------------\", zDir);\n  if( zFN==0 ){\n    fatalError(\"malloc failed\\n\");\n  }\n  zTail = zFN + nFN + 1;\n  while( sqlite3_step(pStmt)==SQLITE_ROW ){\n    int iKey = sqlite3_column_int(pStmt, 0);\n    sqlite3_int64 nData = sqlite3_column_bytes(pStmt, 1);\n    const void *pData = sqlite3_column_blob(pStmt, 1);\n    FILE *out;\n    if( ePathType==PATH_DIR ){\n      sqlite3_snprintf(20, zTail, \"%06d\", iKey);\n    }else{\n      sqlite3_snprintf(20, zTail, \"%02d\", iKey/10000);\n      kvtest_mkdir(zFN);\n      sqlite3_snprintf(20, zTail, \"%02d/%02d\", iKey/10000, (iKey/100)%100);\n      kvtest_mkdir(zFN);\n      sqlite3_snprintf(20, zTail, \"%02d/%02d/%02d\",\n                       iKey/10000, (iKey/100)%100, iKey%100);\n    }\n    out = fopen(zFN, \"wb\");      \n    nWrote = fwrite(pData, 1, nData, out);\n    fclose(out);\n    printf(\"\\r%s   \", zTail); fflush(stdout);\n    if( nWrote!=nData ){\n      fatalError(\"Wrote only %d of %d bytes to %s\\n\",\n                  (int)nWrote, nData, zFN);\n    }\n  }\n  sqlite3_finalize(pStmt);\n  sqlite3_close(db);\n  sqlite3_free(zFN);\n  printf(\"\\n\");\n  return 0;\n}\n\n/*\n** Read the content of file zName into memory obtained from sqlite3_malloc64()\n** and return a pointer to the buffer. The caller is responsible for freeing \n** the memory. \n**\n** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes\n** read.\n**\n** For convenience, a nul-terminator byte is always appended to the data read\n** from the file before the buffer is returned. This byte is not included in\n** the final value of (*pnByte), if applicable.\n**\n** NULL is returned if any error is encountered. The final value of *pnByte\n** is undefined in this case.\n*/\nstatic unsigned char *readFile(const char *zName, sqlite3_int64 *pnByte){\n  FILE *in;               /* FILE from which to read content of zName */\n  sqlite3_int64 nIn;      /* Size of zName in bytes */\n  size_t nRead;           /* Number of bytes actually read */\n  unsigned char *pBuf;    /* Content read from disk */\n\n  nIn = fileSize(zName);\n  if( nIn<0 ) return 0;\n  in = fopen(zName, \"rb\");\n  if( in==0 ) return 0;\n  pBuf = sqlite3_malloc64( nIn );\n  if( pBuf==0 ) return 0;\n  nRead = fread(pBuf, (size_t)nIn, 1, in);\n  fclose(in);\n  if( nRead!=1 ){\n    sqlite3_free(pBuf);\n    return 0;\n  }\n  if( pnByte ) *pnByte = nIn;\n  return pBuf;\n}\n\n/*\n** Overwrite a file with randomness.  Do not change the size of the\n** file.\n*/\nstatic void updateFile(const char *zName, sqlite3_int64 *pnByte, int doFsync){\n  FILE *out;              /* FILE from which to read content of zName */\n  sqlite3_int64 sz;       /* Size of zName in bytes */\n  size_t nWritten;        /* Number of bytes actually read */\n  unsigned char *pBuf;    /* Content to store on disk */\n  const char *zMode = \"wb\";   /* Mode for fopen() */\n\n  sz = fileSize(zName);\n  if( sz<0 ){\n    fatalError(\"No such file: \\\"%s\\\"\", zName);\n  }\n  *pnByte = sz;\n  if( sz==0 ) return;\n  pBuf = sqlite3_malloc64( sz );\n  if( pBuf==0 ){\n    fatalError(\"Cannot allocate %lld bytes\\n\", sz);\n  }\n  sqlite3_randomness((int)sz, pBuf); \n#if defined(_WIN32)\n  if( doFsync ) zMode = \"wbc\";\n#endif\n  out = fopen(zName, zMode);\n  if( out==0 ){\n    fatalError(\"Cannot open \\\"%s\\\" for writing\\n\", zName);\n  }\n  nWritten = fwrite(pBuf, 1, (size_t)sz, out);\n  if( doFsync ){\n#if defined(_WIN32)\n    fflush(out);\n#else\n    fsync(fileno(out));\n#endif\n  }\n  fclose(out);\n  if( nWritten!=(size_t)sz ){\n    fatalError(\"Wrote only %d of %d bytes to \\\"%s\\\"\\n\",\n               (int)nWritten, (int)sz, zName);\n  }\n  sqlite3_free(pBuf);\n}\n\n/*\n** Return the current time in milliseconds since the beginning of\n** the Julian epoch.\n*/\nstatic sqlite3_int64 timeOfDay(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n#ifdef __linux__\n/*\n** Attempt to display I/O stats on Linux using /proc/PID/io\n*/\nstatic void displayLinuxIoStats(FILE *out){\n  FILE *in;\n  char z[200];\n  sqlite3_snprintf(sizeof(z), z, \"/proc/%d/io\", getpid());\n  in = fopen(z, \"rb\");\n  if( in==0 ) return;\n  while( fgets(z, sizeof(z), in)!=0 ){\n    static const struct {\n      const char *zPattern;\n      const char *zDesc;\n    } aTrans[] = {\n      { \"rchar: \",                  \"Bytes received by read():\" },\n      { \"wchar: \",                  \"Bytes sent to write():\"    },\n      { \"syscr: \",                  \"Read() system calls:\"      },\n      { \"syscw: \",                  \"Write() system calls:\"     },\n      { \"read_bytes: \",             \"Bytes read from storage:\"  },\n      { \"write_bytes: \",            \"Bytes written to storage:\" },\n      { \"cancelled_write_bytes: \",  \"Cancelled write bytes:\"    },\n    };\n    int i;\n    for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){\n      int n = (int)strlen(aTrans[i].zPattern);\n      if( strncmp(aTrans[i].zPattern, z, n)==0 ){\n        fprintf(out, \"%-36s %s\", aTrans[i].zDesc, &z[n]);\n        break;\n      }\n    }\n  }\n  fclose(in);\n}\n#endif\n\n/*\n** Display memory stats.\n*/\nstatic int display_stats(\n  sqlite3 *db,                    /* Database to query */\n  int bReset                      /* True to reset SQLite stats */\n){\n  int iCur;\n  int iHiwtr;\n  FILE *out = stdout;\n\n  fprintf(out, \"\\n\");\n\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);\n  fprintf(out,\n          \"Memory Used:                         %d (max %d) bytes\\n\",\n          iCur, iHiwtr);\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);\n  fprintf(out, \"Number of Outstanding Allocations:   %d (max %d)\\n\",\n          iCur, iHiwtr);\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);\n  fprintf(out,\n      \"Number of Pcache Pages Used:         %d (max %d) pages\\n\",\n      iCur, iHiwtr);\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);\n  fprintf(out,\n          \"Number of Pcache Overflow Bytes:     %d (max %d) bytes\\n\",\n          iCur, iHiwtr);\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);\n  fprintf(out, \"Largest Allocation:                  %d bytes\\n\",\n          iHiwtr);\n  iHiwtr = iCur = -1;\n  sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);\n  fprintf(out, \"Largest Pcache Allocation:           %d bytes\\n\",\n          iHiwtr);\n\n  iHiwtr = iCur = -1;\n  sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);\n  fprintf(out, \"Pager Heap Usage:                    %d bytes\\n\",\n      iCur);\n  iHiwtr = iCur = -1;\n  sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);\n  fprintf(out, \"Page cache hits:                     %d\\n\", iCur);\n  iHiwtr = iCur = -1;\n  sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);\n  fprintf(out, \"Page cache misses:                   %d\\n\", iCur);\n  iHiwtr = iCur = -1;\n  sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);\n  fprintf(out, \"Page cache writes:                   %d\\n\", iCur);\n  iHiwtr = iCur = -1;\n\n#ifdef __linux__\n  displayLinuxIoStats(out);\n#endif\n\n  return 0;\n}\n\n/* Blob access order */\n#define ORDER_ASC     1\n#define ORDER_DESC    2\n#define ORDER_RANDOM  3\n\n\n/*\n** Run a performance test\n*/\nstatic int runMain(int argc, char **argv){\n  int eType;                  /* Is zDb a database or a directory? */\n  char *zDb;                  /* Database or directory name */\n  int i;                      /* Loop counter */\n  int rc;                     /* Return code from SQLite calls */\n  int nCount = 1000;          /* Number of blob fetch operations */\n  int nExtra = 0;             /* Extra cycles */\n  int iKey = 1;               /* Next blob key */\n  int iMax = 0;               /* Largest allowed key */\n  int iPagesize = 0;          /* Database page size */\n  int iCache = 1000;          /* Database cache size in kibibytes */\n  int bBlobApi = 0;           /* Use the incremental blob I/O API */\n  int bStats = 0;             /* Print stats before exiting */\n  int eOrder = ORDER_ASC;     /* Access order */\n  int isUpdateTest = 0;       /* Do in-place updates rather than reads */\n  int doIntegrityCk = 0;      /* Run PRAGMA integrity_check after the test */\n  int noSync = 0;             /* Disable synchronous mode */\n  int doFsync = 0;            /* Update disk files synchronously */\n  int doMultiTrans = 0;       /* Each operation in its own transaction */\n  int noCheckpoint = 0;       /* Omit the checkpoint in WAL mode */\n  sqlite3 *db = 0;            /* Database connection */\n  sqlite3_stmt *pStmt = 0;    /* Prepared statement for SQL access */\n  sqlite3_blob *pBlob = 0;    /* Handle for incremental Blob I/O */\n  sqlite3_int64 tmStart;      /* Start time */\n  sqlite3_int64 tmElapsed;    /* Elapsed time */\n  int mmapSize = 0;           /* --mmap N argument */\n  sqlite3_int64 nData = 0;    /* Bytes of data */\n  sqlite3_int64 nTotal = 0;   /* Total data read */\n  unsigned char *pData = 0;   /* Content of the blob */\n  sqlite3_int64 nAlloc = 0;   /* Space allocated for pData[] */\n  const char *zJMode = 0;     /* Journal mode */\n  \n\n  assert( strcmp(argv[1],\"run\")==0 );\n  assert( argc>=3 );\n  zDb = argv[2];\n  eType = pathType(zDb);\n  if( eType==PATH_OTHER ) fatalError(\"unknown object type: \\\"%s\\\"\", zDb);\n  if( eType==PATH_NEXIST ) fatalError(\"object does not exist: \\\"%s\\\"\", zDb);\n  for(i=3; i<argc; i++){\n    char *z = argv[i];\n    if( z[0]!='-' ) fatalError(\"unknown argument: \\\"%s\\\"\", z);\n    if( z[1]=='-' ) z++;\n    if( strcmp(z, \"-asc\")==0 ){\n      eOrder = ORDER_ASC;\n      continue;\n    }\n    if( strcmp(z, \"-blob-api\")==0 ){\n      bBlobApi = 1;\n      continue;\n    }\n    if( strcmp(z, \"-cache-size\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      iCache = integerValue(argv[++i]);\n      continue;\n    }\n    if( strcmp(z, \"-count\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      nCount = integerValue(argv[++i]);\n      if( nCount<1 ) fatalError(\"the --count must be positive\");\n      continue;\n    }\n    if( strcmp(z, \"-desc\")==0 ){\n      eOrder = ORDER_DESC;\n      continue;\n    }\n    if( strcmp(z, \"-fsync\")==0 ){\n      doFsync = 1;\n      continue;\n    }\n    if( strcmp(z, \"-integrity-check\")==0 ){\n      doIntegrityCk = 1;\n      continue;\n    }\n    if( strcmp(z, \"-jmode\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      zJMode = argv[++i];\n      continue;\n    }\n    if( strcmp(z, \"-mmap\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      mmapSize = integerValue(argv[++i]);\n      if( nCount<0 ) fatalError(\"the --mmap must be non-negative\");\n      continue;\n    }\n    if( strcmp(z, \"-max-id\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      iMax = integerValue(argv[++i]);\n      continue;\n    }\n    if( strcmp(z, \"-multitrans\")==0 ){\n      doMultiTrans = 1;\n      continue;\n    }\n    if( strcmp(z, \"-nocheckpoint\")==0 ){\n      noCheckpoint = 1;\n      continue;\n    }\n    if( strcmp(z, \"-nosync\")==0 ){\n      noSync = 1;\n      continue;\n    }\n    if( strcmp(z, \"-random\")==0 ){\n      eOrder = ORDER_RANDOM;\n      continue;\n    }\n    if( strcmp(z, \"-start\")==0 ){\n      if( i==argc-1 ) fatalError(\"missing argument on \\\"%s\\\"\", argv[i]);\n      iKey = integerValue(argv[++i]);\n      if( iKey<1 ) fatalError(\"the --start must be positive\");\n      continue;\n    }\n    if( strcmp(z, \"-stats\")==0 ){\n      bStats = 1;\n      continue;\n    }\n    if( strcmp(z, \"-update\")==0 ){\n      isUpdateTest = 1;\n      continue;\n    }\n    fatalError(\"unknown option: \\\"%s\\\"\", argv[i]);\n  }\n  if( eType==PATH_DB ){\n    /* Recover any prior crashes prior to starting the timer */\n    sqlite3_open(zDb, &db);\n    sqlite3_exec(db, \"SELECT rowid FROM sqlite_master LIMIT 1\", 0, 0, 0);\n    sqlite3_close(db);\n    db = 0;\n  }\n  tmStart = timeOfDay();\n  if( eType==PATH_DB ){\n    char *zSql;\n    rc = sqlite3_open(zDb, &db);\n    if( rc ){\n      fatalError(\"cannot open database \\\"%s\\\": %s\", zDb, sqlite3_errmsg(db));\n    }\n    zSql = sqlite3_mprintf(\"PRAGMA mmap_size=%d\", mmapSize);\n    sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    zSql = sqlite3_mprintf(\"PRAGMA cache_size=%d\", iCache);\n    sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n    if( noSync ){\n      sqlite3_exec(db, \"PRAGMA synchronous=OFF\", 0, 0, 0);\n    }\n    pStmt = 0;\n    sqlite3_prepare_v2(db, \"PRAGMA page_size\", -1, &pStmt, 0);\n    if( sqlite3_step(pStmt)==SQLITE_ROW ){\n      iPagesize = sqlite3_column_int(pStmt, 0);\n    }\n    sqlite3_finalize(pStmt);\n    sqlite3_prepare_v2(db, \"PRAGMA cache_size\", -1, &pStmt, 0);\n    if( sqlite3_step(pStmt)==SQLITE_ROW ){\n      iCache = sqlite3_column_int(pStmt, 0);\n    }else{\n      iCache = 0;\n    }\n    sqlite3_finalize(pStmt);\n    pStmt = 0;\n    if( zJMode ){\n      zSql = sqlite3_mprintf(\"PRAGMA journal_mode=%Q\", zJMode);\n      sqlite3_exec(db, zSql, 0, 0, 0);\n      sqlite3_free(zSql);\n      if( noCheckpoint ){\n        sqlite3_exec(db, \"PRAGMA wal_autocheckpoint=0\", 0, 0, 0);\n      }\n    }\n    sqlite3_prepare_v2(db, \"PRAGMA journal_mode\", -1, &pStmt, 0);\n    if( sqlite3_step(pStmt)==SQLITE_ROW ){\n      zJMode = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 0));\n    }else{\n      zJMode = \"???\";\n    }\n    sqlite3_finalize(pStmt);\n    if( iMax<=0 ){\n      sqlite3_prepare_v2(db, \"SELECT max(k) FROM kv\", -1, &pStmt, 0);\n      if( sqlite3_step(pStmt)==SQLITE_ROW ){\n        iMax = sqlite3_column_int(pStmt, 0);\n      }\n      sqlite3_finalize(pStmt);\n    }\n    pStmt = 0;\n    if( !doMultiTrans ) sqlite3_exec(db, \"BEGIN\", 0, 0, 0);\n  }\n  if( iMax<=0 ) iMax = 1000;\n  for(i=0; i<nCount; i++){\n    if( eType==PATH_DIR || eType==PATH_TREE ){\n      /* CASE 1: Reading or writing blobs out of separate files */\n      char *zKey;\n      if( eType==PATH_DIR ){\n        zKey = sqlite3_mprintf(\"%s/%06d\", zDb, iKey);\n      }else{\n        zKey = sqlite3_mprintf(\"%s/%02d/%02d/%02d\", zDb, iKey/10000,\n                               (iKey/100)%100, iKey%100);\n      }\n      nData = 0;\n      if( isUpdateTest ){\n        updateFile(zKey, &nData, doFsync);\n      }else{\n        pData = readFile(zKey, &nData);\n        sqlite3_free(pData);\n      }\n      sqlite3_free(zKey);\n    }else if( bBlobApi ){\n      /* CASE 2: Reading from database using the incremental BLOB I/O API */\n      if( pBlob==0 ){\n        rc = sqlite3_blob_open(db, \"main\", \"kv\", \"v\", iKey,\n                               isUpdateTest, &pBlob);\n        if( rc ){\n          fatalError(\"could not open sqlite3_blob handle: %s\",\n                     sqlite3_errmsg(db));\n        }\n      }else{\n        rc = sqlite3_blob_reopen(pBlob, iKey);\n      }\n      if( rc==SQLITE_OK ){\n        nData = sqlite3_blob_bytes(pBlob);\n        if( nAlloc<nData+1 ){\n          nAlloc = nData+100;\n          pData = sqlite3_realloc64(pData, nAlloc);\n        }\n        if( pData==0 ) fatalError(\"cannot allocate %d bytes\", nData+1);\n        if( isUpdateTest ){\n          sqlite3_randomness((int)nData, pData);\n          rc = sqlite3_blob_write(pBlob, pData, (int)nData, 0);\n          if( rc!=SQLITE_OK ){\n            fatalError(\"could not write the blob at %d: %s\", iKey,\n                      sqlite3_errmsg(db));\n          }\n        }else{\n          rc = sqlite3_blob_read(pBlob, pData, (int)nData, 0);\n          if( rc!=SQLITE_OK ){\n            fatalError(\"could not read the blob at %d: %s\", iKey,\n                      sqlite3_errmsg(db));\n          }\n        }\n      }\n    }else{\n      /* CASE 3: Reading from database using SQL */\n      if( pStmt==0 ){\n        if( isUpdateTest ){\n          sqlite3_create_function(db, \"remember\", 2, SQLITE_UTF8, 0,\n                                  rememberFunc, 0, 0);\n\n          rc = sqlite3_prepare_v2(db, \n            \"UPDATE kv SET v=randomblob(remember(length(v),?2))\"\n            \" WHERE k=?1\", -1, &pStmt, 0);\n          sqlite3_bind_int64(pStmt, 2, SQLITE_PTR_TO_INT(&nData));\n        }else{\n          rc = sqlite3_prepare_v2(db, \n                 \"SELECT v FROM kv WHERE k=?1\", -1, &pStmt, 0);\n        }\n        if( rc ){\n          fatalError(\"cannot prepare query: %s\", sqlite3_errmsg(db));\n        }\n      }else{\n        sqlite3_reset(pStmt);\n      }\n      sqlite3_bind_int(pStmt, 1, iKey);\n      nData = 0;\n      rc = sqlite3_step(pStmt);\n      if( rc==SQLITE_ROW ){\n        nData = sqlite3_column_bytes(pStmt, 0);\n        pData = (unsigned char*)sqlite3_column_blob(pStmt, 0);\n      }\n    }\n    if( eOrder==ORDER_ASC ){\n      iKey++;\n      if( iKey>iMax ) iKey = 1;\n    }else if( eOrder==ORDER_DESC ){\n      iKey--;\n      if( iKey<=0 ) iKey = iMax;\n    }else{\n      iKey = (randInt()%iMax)+1;\n    }\n    nTotal += nData;\n    if( nData==0 ){ nCount++; nExtra++; }\n  }\n  if( nAlloc ) sqlite3_free(pData);\n  if( pStmt ) sqlite3_finalize(pStmt);\n  if( pBlob ) sqlite3_blob_close(pBlob);\n  if( bStats ){\n    display_stats(db, 0);\n  }\n  if( db ){\n    if( !doMultiTrans ) sqlite3_exec(db, \"COMMIT\", 0, 0, 0);\n    if( !noCheckpoint ){\n      sqlite3_close(db);\n      db = 0;\n    }\n  }\n  tmElapsed = timeOfDay() - tmStart;\n  if( db && noCheckpoint ){\n    sqlite3_close(db);\n    db = 0;\n  }\n  if( nExtra ){\n    printf(\"%d cycles due to %d misses\\n\", nCount, nExtra);\n  }\n  if( eType==PATH_DB ){\n    printf(\"SQLite version: %s\\n\", sqlite3_libversion());\n    if( doIntegrityCk ){\n      sqlite3_open(zDb, &db);\n      sqlite3_prepare_v2(db, \"PRAGMA integrity_check\", -1, &pStmt, 0);\n      while( sqlite3_step(pStmt)==SQLITE_ROW ){\n        printf(\"integrity-check: %s\\n\", sqlite3_column_text(pStmt, 0));\n      }\n      sqlite3_finalize(pStmt);\n      sqlite3_close(db);\n      db = 0;\n    }\n  }\n  printf(\"--count %d --max-id %d\", nCount-nExtra, iMax);\n  switch( eOrder ){\n    case ORDER_RANDOM:  printf(\" --random\\n\");  break;\n    case ORDER_DESC:    printf(\" --desc\\n\");    break;\n    default:            printf(\" --asc\\n\");     break;\n  }\n  if( eType==PATH_DB ){\n    printf(\"--cache-size %d --jmode %s\\n\", iCache, zJMode);\n    printf(\"--mmap %d%s\\n\", mmapSize, bBlobApi ? \" --blob-api\" : \"\");\n    if( noSync ) printf(\"--nosync\\n\");\n  }\n  if( iPagesize ) printf(\"Database page size: %d\\n\", iPagesize);\n  printf(\"Total elapsed time: %.3f\\n\", tmElapsed/1000.0);\n  if( isUpdateTest ){\n    printf(\"Microseconds per BLOB write: %.3f\\n\", tmElapsed*1000.0/nCount);\n    printf(\"Content write rate: %.1f MB/s\\n\", nTotal/(1000.0*tmElapsed));\n  }else{\n    printf(\"Microseconds per BLOB read: %.3f\\n\", tmElapsed*1000.0/nCount);\n    printf(\"Content read rate: %.1f MB/s\\n\", nTotal/(1000.0*tmElapsed));\n  }\n  return 0;\n}\n\n\nint main(int argc, char **argv){\n  if( argc<3 ) showHelp();\n  if( strcmp(argv[1],\"init\")==0 ){\n    return initMain(argc, argv);\n  }\n  if( strcmp(argv[1],\"export\")==0 ){\n    return exportMain(argc, argv);\n  }\n  if( strcmp(argv[1],\"run\")==0 ){\n    return runMain(argc, argv);\n  }\n  if( strcmp(argv[1],\"stat\")==0 ){\n    return statMain(argc, argv);\n  }\n  showHelp();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lastinsert.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to make sure that value returned by last_insert_rowid() (LIRID)\n# is updated properly, especially inside triggers\n#\n# Note 1: insert into table is now the only statement which changes LIRID\n# Note 2: upon entry into before or instead of triggers,\n#           LIRID is unchanged (rather than -1)\n# Note 3: LIRID is changed within the context of a trigger,\n#           but is restored once the trigger exits\n# Note 4: LIRID is not changed by an insert into a view (since everything\n#           is done within instead of trigger context)\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# ----------------------------------------------------------------------------\n# 1.x - basic tests (no triggers)\n\n# LIRID changed properly after an insert into a table\ndo_test lastinsert-1.1 {\n    catchsql {\n        create table t1 (k integer primary key);\n        insert into t1 values (1);\n        insert into t1 values (NULL);\n        insert into t1 values (NULL);\n        select last_insert_rowid();\n    }\n} {0 3}\n\n# EVIDENCE-OF: R-47220-63683 The sqlite3_last_insert_rowid() function\n# does not work for WITHOUT ROWID tables.\n#\ndo_test lastinsert-1.1w {\n    catchsql {\n        create table t1w (k integer primary key) WITHOUT ROWID;\n        insert into t1w values (123456);\n        select last_insert_rowid(); -- returns 3 from above.\n    }\n} {0 3}\n\n# LIRID unchanged after an update on a table\ndo_test lastinsert-1.2 {\n    catchsql {\n        update t1 set k=4 where k=2;\n        select last_insert_rowid();\n    }\n} {0 3}\n\n# LIRID unchanged after a delete from a table\ndo_test lastinsert-1.3 {\n    catchsql {\n        delete from t1 where k=4;\n        select last_insert_rowid();\n    }\n} {0 3}\n\n# LIRID unchanged after create table/view statements\ndo_test lastinsert-1.4.1 {\n    catchsql {\n        create table t2 (k integer primary key, val1, val2, val3);\n        select last_insert_rowid();\n    }\n} {0 3}\nifcapable view {\ndo_test lastinsert-1.4.2 {\n    catchsql {\n        create view v as select * from t1;\n        select last_insert_rowid();\n    }\n} {0 3}\n} ;# ifcapable view\n\n# All remaining tests involve triggers.  Skip them if triggers are not\n# supported in this build.\n#\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# ----------------------------------------------------------------------------\n# 2.x - tests with after insert trigger\n\n# LIRID changed properly after an insert into table containing an after trigger\ndo_test lastinsert-2.1 {\n    catchsql {\n        delete from t2;\n        create trigger r1 after insert on t1 for each row begin\n            insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);\n            update t2 set k=k+10, val2=100+last_insert_rowid();\n            update t2 set val3=1000+last_insert_rowid();\n        end;\n        insert into t1 values (13);\n        select last_insert_rowid();\n    }\n} {0 13}\n\n# LIRID equals NEW.k upon entry into after insert trigger\ndo_test lastinsert-2.2 {\n    catchsql {\n        select val1 from t2;\n    }\n} {0 13}\n\n# LIRID changed properly by insert within context of after insert trigger\ndo_test lastinsert-2.3 {\n    catchsql {\n        select val2 from t2;\n    }\n} {0 126}\n\n# LIRID unchanged by update within context of after insert trigger\ndo_test lastinsert-2.4 {\n    catchsql {\n        select val3 from t2;\n    }\n} {0 1026}\n\n# ----------------------------------------------------------------------------\n# 3.x - tests with after update trigger\n\n# LIRID not changed after an update onto a table containing an after trigger\ndo_test lastinsert-3.1 {\n    catchsql {\n        delete from t2;\n        drop trigger r1;\n        create trigger r1 after update on t1 for each row begin\n            insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);\n            update t2 set k=k+10, val2=100+last_insert_rowid();\n            update t2 set val3=1000+last_insert_rowid();\n        end;\n        update t1 set k=14 where k=3;\n        select last_insert_rowid();\n    }\n} {0 13}\n\n# LIRID unchanged upon entry into after update trigger\ndo_test lastinsert-3.2 {\n    catchsql {\n        select val1 from t2;\n    }\n} {0 13}\n\n# LIRID changed properly by insert within context of after update trigger\ndo_test lastinsert-3.3 {\n    catchsql {\n        select val2 from t2;\n    }\n} {0 128}\n\n# LIRID unchanged by update within context of after update trigger\ndo_test lastinsert-3.4 {\n    catchsql {\n        select val3 from t2;\n    }\n} {0 1028}\n\n# ----------------------------------------------------------------------------\n# 4.x - tests with instead of insert trigger\n# These may not be run if either views or triggers were disabled at \n# compile-time\n\nifcapable {view && trigger} {\n# LIRID not changed after an insert into view containing an instead of trigger\ndo_test lastinsert-4.1 {\n    catchsql {\n        delete from t2;\n        drop trigger r1;\n        create trigger r1 instead of insert on v for each row begin\n            insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);\n            update t2 set k=k+10, val2=100+last_insert_rowid();\n            update t2 set val3=1000+last_insert_rowid();\n        end;\n        insert into v values (15);\n        select last_insert_rowid();\n    }\n} {0 13}\n\n# LIRID unchanged upon entry into instead of trigger\ndo_test lastinsert-4.2 {\n    catchsql {\n        select val1 from t2;\n    }\n} {0 13}\n\n# LIRID changed properly by insert within context of instead of trigger\ndo_test lastinsert-4.3 {\n    catchsql {\n        select val2 from t2;\n    }\n} {0 130}\n\n# LIRID unchanged by update within context of instead of trigger\ndo_test lastinsert-4.4 {\n    catchsql {\n        select val3 from t2;\n    }\n} {0 1030}\n} ;# ifcapable (view && trigger)\n\n# ----------------------------------------------------------------------------\n# 5.x - tests with before delete trigger\n\n# LIRID not changed after a delete on a table containing a before trigger\ndo_test lastinsert-5.1 {\n    catchsql {\n      drop trigger r1;  -- This was not created if views are disabled.\n    }\n    catchsql {\n        delete from t2;\n        create trigger r1 before delete on t1 for each row begin\n            insert into t2 values (77, last_insert_rowid(), NULL, NULL);\n            update t2 set k=k+10, val2=100+last_insert_rowid();\n            update t2 set val3=1000+last_insert_rowid();\n        end;\n        delete from t1 where k=1;\n        select last_insert_rowid();\n    }\n} {0 13}\n\n# LIRID unchanged upon entry into delete trigger\ndo_test lastinsert-5.2 {\n    catchsql {\n        select val1 from t2;\n    }\n} {0 13}\n\n# LIRID changed properly by insert within context of delete trigger\ndo_test lastinsert-5.3 {\n    catchsql {\n        select val2 from t2;\n    }\n} {0 177}\n\n# LIRID unchanged by update within context of delete trigger\ndo_test lastinsert-5.4 {\n    catchsql {\n        select val3 from t2;\n    }\n} {0 1077}\n\n# ----------------------------------------------------------------------------\n# 6.x - tests with instead of update trigger\n# These tests may not run if either views or triggers are disabled.\n\nifcapable {view && trigger} {\n# LIRID not changed after an update on a view containing an instead of trigger\ndo_test lastinsert-6.1 {\n    catchsql {\n        delete from t2;\n        drop trigger r1;\n        create trigger r1 instead of update on v for each row begin\n            insert into t2 values (NEW.k*2, last_insert_rowid(), NULL, NULL);\n            update t2 set k=k+10, val2=100+last_insert_rowid();\n            update t2 set val3=1000+last_insert_rowid();\n        end;\n        update v set k=16 where k=14;\n        select last_insert_rowid();\n    }\n} {0 13}\n\n# LIRID unchanged upon entry into instead of trigger\ndo_test lastinsert-6.2 {\n    catchsql {\n        select val1 from t2;\n    }\n} {0 13}\n\n# LIRID changed properly by insert within context of instead of trigger\ndo_test lastinsert-6.3 {\n    catchsql {\n        select val2 from t2;\n    }\n} {0 132}\n\n# LIRID unchanged by update within context of instead of trigger\ndo_test lastinsert-6.4 {\n    catchsql {\n        select val3 from t2;\n    }\n} {0 1032}\n} ;# ifcapable (view && trigger)\n\n# ----------------------------------------------------------------------------\n# 7.x - complex tests with temporary tables and nested instead of triggers\n# These do not run if views or triggers are disabled.\n\nifcapable {trigger && view && tempdb} {\ndo_test lastinsert-7.1 {\n    catchsql {\n        drop table t1; drop table t2; drop trigger r1;\n        create temp table t1 (k integer primary key);\n        create temp table t2 (k integer primary key);\n        create temp view v1 as select * from t1;\n        create temp view v2 as select * from t2;\n        create temp table rid (k integer primary key, rin, rout);\n        insert into rid values (1, NULL, NULL);\n        insert into rid values (2, NULL, NULL);\n        create temp trigger r1 instead of insert on v1 for each row begin\n            update rid set rin=last_insert_rowid() where k=1;\n            insert into t1 values (100+NEW.k);\n            insert into v2 values (100+last_insert_rowid());\n            update rid set rout=last_insert_rowid() where k=1;\n        end;\n        create temp trigger r2 instead of insert on v2 for each row begin\n            update rid set rin=last_insert_rowid() where k=2;\n            insert into t2 values (1000+NEW.k);\n            update rid set rout=last_insert_rowid() where k=2;\n        end;\n        insert into t1 values (77);\n        select last_insert_rowid();\n    }\n} {0 77}\n\ndo_test lastinsert-7.2 {\n    catchsql {\n        insert into v1 values (5);\n        select last_insert_rowid();\n    }\n} {0 77}\n\ndo_test lastinsert-7.3 {\n    catchsql {\n        select rin from rid where k=1;\n    }\n} {0 77}\n\ndo_test lastinsert-7.4 {\n    catchsql {\n        select rout from rid where k=1;\n    }\n} {0 105}\n\ndo_test lastinsert-7.5 {\n    catchsql {\n        select rin from rid where k=2;\n    }\n} {0 105}\n\ndo_test lastinsert-7.6 {\n    catchsql {\n        select rout from rid where k=2;\n    }\n} {0 1205}\n\ndo_test lastinsert-8.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t2(x INTEGER PRIMARY KEY, y);\n    CREATE TABLE t3(a, b);\n    CREATE TRIGGER after_t2 AFTER INSERT ON t2 BEGIN\n      INSERT INTO t3 VALUES(new.x, new.y);\n    END;\n    INSERT INTO t2 VALUES(5000000000, 1);\n    SELECT last_insert_rowid();\n  }\n} 5000000000\n\ndo_test lastinsert-9.1 {\n  db eval {INSERT INTO t2 VALUES(123456789012345,0)}\n  db last_insert_rowid\n} {123456789012345}\n\n\n} ;# ifcapable (view && trigger)\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/laststmtchanges.test",
    "content": "#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to make sure that values returned by changes() and total_changes()\n# are updated properly, especially inside triggers\n#\n# Note 1: changes() remains constant within a statement and only updates\n#         once the statement is finished (triggers count as part of\n#         statement).\n# Note 2: changes() is changed within the context of a trigger much like \n#         last_insert_rowid() (see lastinsert.test), but is restored once\n#         the trigger exits.\n# Note 3: changes() is not changed by a change to a view (since everything\n#         is done within instead of trigger context).\n#\n# $Id: laststmtchanges.test,v 1.7 2008/10/27 13:59:34 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# ----------------------------------------------------------------------------\n# 1.x - basic tests (no triggers)\n\n# changes() set properly after insert\ndo_test laststmtchanges-1.1 {\n    catchsql {\n        create table t0 (x);\n        insert into t0 values (1);\n        insert into t0 values (1);\n        insert into t0 values (2);\n        insert into t0 values (2);\n        insert into t0 values (1);\n        insert into t0 values (1);\n        insert into t0 values (1);\n        insert into t0 values (2);\n        select changes(), total_changes();\n    }\n} {0 {1 8}}\n\n# changes() set properly after update\ndo_test laststmtchanges-1.2 {\n    catchsql {\n        update t0 set x=3 where x=1;\n        select changes(), total_changes();\n    }\n} {0 {5 13}}\n\n# There was some goofy change-counting logic in sqlite3_exec() that\n# appears to have been left over from SQLite version 2.  This test\n# makes sure it has been removed.\n#\ndo_test laststmtchanges-1.2.1 {\n    db cache flush\n    sqlite3_exec_printf db {update t0 set x=4 where x=3; select 1;} {}\n    execsql {select changes()}\n} {5}\n\n# changes() unchanged within an update statement\ndo_test laststmtchanges-1.3 {\n    execsql {update t0 set x=3 where x=4}\n    catchsql {\n        update t0 set x=x+changes() where x=3;\n        select count() from t0 where x=8;\n    }\n} {0 5}\n\n# changes() set properly after update on table where no rows changed\ndo_test laststmtchanges-1.4 {\n    catchsql {\n        update t0 set x=77 where x=88;\n        select changes();\n    }\n} {0 0}\n\n# changes() set properly after delete from table\ndo_test laststmtchanges-1.5 {\n    catchsql {\n        delete from t0 where x=2;\n        select changes();\n    }\n} {0 3}\n\n# All remaining tests involve triggers.  Skip them if triggers are not\n# supported in this build.\n#\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n\n# ----------------------------------------------------------------------------\n# 2.x - tests with after insert trigger\n\n# changes() changed properly after insert into table containing after trigger\ndo_test laststmtchanges-2.1 {\n    set ::tc [db total_changes]\n    catchsql {\n        create table t1 (k integer primary key);\n        create table t2 (k integer primary key, v1, v2);\n        create trigger r1 after insert on t1 for each row begin\n            insert into t2 values (NULL, changes(), NULL);\n            update t0 set x=x;\n            update t2 set v2=changes();\n        end;\n        insert into t1 values (77);\n        select changes();\n    }\n} {0 1}\n\n# changes() unchanged upon entry into after insert trigger\ndo_test laststmtchanges-2.2 {\n    catchsql {\n        select v1 from t2;\n    }\n} {0 3}\n\n# changes() changed properly by update within context of after insert trigger\ndo_test laststmtchanges-2.3 {\n    catchsql {\n        select v2 from t2;\n    }\n} {0 5}\n\n# Total changes caused by firing the trigger above:\n#\n#   1 from \"insert into t1 values(77)\" + \n#   1 from \"insert into t2 values (NULL, changes(), NULL);\" +\n#   5 from \"update t0 set x=x;\" +\n#   1 from \"update t2 set v2=changes();\"\n#\ndo_test laststmtchanges-2.4 {\n  expr [db total_changes] - $::tc\n} {8}\n\n# ----------------------------------------------------------------------------\n# 3.x - tests with after update trigger\n\n# changes() changed properly after update into table containing after trigger\ndo_test laststmtchanges-3.1 {\n    catchsql {\n        drop trigger r1;\n        delete from t2; delete from t2;\n        create trigger r1 after update on t1 for each row begin\n            insert into t2 values (NULL, changes(), NULL);\n            delete from t0 where oid=1 or oid=2;\n            update t2 set v2=changes();\n        end;\n        update t1 set k=k;\n        select changes();\n    }\n} {0 1}\n\n# changes() unchanged upon entry into after update trigger\ndo_test laststmtchanges-3.2 {\n    catchsql {\n        select v1 from t2;\n    }\n} {0 0}\n\n# changes() changed properly by delete within context of after update trigger\ndo_test laststmtchanges-3.3 {\n    catchsql {\n        select v2 from t2;\n    }\n} {0 2}\n\n# ----------------------------------------------------------------------------\n# 4.x - tests with before delete trigger\n\n# changes() changed properly on delete from table containing before trigger\ndo_test laststmtchanges-4.1 {\n    catchsql {\n        drop trigger r1;\n        delete from t2; delete from t2;\n        create trigger r1 before delete on t1 for each row begin\n            insert into t2 values (NULL, changes(), NULL);\n            insert into t0 values (5);\n            update t2 set v2=changes();\n        end;\n        delete from t1;\n        select changes();\n    }\n} {0 1}\n\n# changes() unchanged upon entry into before delete trigger\ndo_test laststmtchanges-4.2 {\n    catchsql {\n        select v1 from t2;\n    }\n} {0 0}\n\n# changes() changed properly by insert within context of before delete trigger\ndo_test laststmtchanges-4.3 {\n    catchsql {\n        select v2 from t2;\n    }\n} {0 1}\n\n# ----------------------------------------------------------------------------\n# 5.x - complex tests with temporary tables and nested instead of triggers\n# These tests cannot run if the library does not have view support enabled.\n\nifcapable view&&tempdb {\n\ndo_test laststmtchanges-5.1 {\n    catchsql {\n        drop table t0; drop table t1; drop table t2;\n        create temp table t0(x);\n        create temp table t1 (k integer primary key);\n        create temp table t2 (k integer primary key);\n        create temp view v1 as select * from t1;\n        create temp view v2 as select * from t2;\n        create temp table n1 (k integer primary key, n);\n        create temp table n2 (k integer primary key, n);\n        insert into t0 values (1);\n        insert into t0 values (2);\n        insert into t0 values (1);\n        insert into t0 values (1);\n        insert into t0 values (1);\n        insert into t0 values (2);\n        insert into t0 values (2);\n        insert into t0 values (1);\n        create temp trigger r1 instead of insert on v1 for each row begin\n            insert into n1 values (NULL, changes());\n            update t0 set x=x*10 where x=1;\n            insert into n1 values (NULL, changes());\n            insert into t1 values (NEW.k);\n            insert into n1 values (NULL, changes());\n            update t0 set x=x*10 where x=0;\n            insert into v2 values (100+NEW.k);\n            insert into n1 values (NULL, changes());\n        end;\n        create temp trigger r2 instead of insert on v2 for each row begin\n            insert into n2 values (NULL, changes());\n            insert into t2 values (1000+NEW.k);\n            insert into n2 values (NULL, changes());\n            update t0 set x=x*100 where x=0;\n            insert into n2 values (NULL, changes());\n            delete from t0 where x=2;\n            insert into n2 values (NULL, changes());\n        end;\n        insert into t1 values (77);\n        select changes();\n    }\n} {0 1}\n\ndo_test laststmtchanges-5.2 {\n    catchsql {\n        delete from t1 where k=88;\n        select changes();\n    }\n} {0 0}\n\ndo_test laststmtchanges-5.3 {\n    catchsql {\n        insert into v1 values (5);\n        select changes();\n    }\n} {0 0}\n\ndo_test laststmtchanges-5.4 {\n    catchsql {\n        select n from n1;\n    }\n} {0 {0 5 1 0}}\n\ndo_test laststmtchanges-5.5 {\n    catchsql {\n        select n from n2;\n    }\n} {0 {0 1 0 3}}\n\n} ;# ifcapable view\n\n\n# ----------------------------------------------------------------------------\n# 6.x - Test \"DELETE FROM <table>\" in the absence of triggers\n#\ndo_test laststmtchanges-6.1 {\n  execsql {\n    CREATE TABLE t3(a, b, c);\n    INSERT INTO t3 VALUES(1, 2, 3);\n    INSERT INTO t3 VALUES(4, 5, 6);\n  }\n} {}\ndo_test laststmtchanges-6.2 {\n  execsql {\n    BEGIN;\n    DELETE FROM t3;\n    SELECT changes();\n  }\n} {2}\ndo_test laststmtchanges-6.3 {\n  execsql {\n    ROLLBACK;\n    BEGIN;\n    DELETE FROM t3 WHERE a IS NOT NULL;\n    SELECT changes();\n  }\n} {2}\ndo_test laststmtchanges-6.4 {\n  execsql {\n    ROLLBACK;\n    CREATE INDEX t3_i1 ON t3(a);\n    BEGIN;\n    DELETE FROM t3;\n    SELECT changes();\n  }\n} {2}\ndo_test laststmtchanges-6.5 {\n  execsql { ROLLBACK }\n  set nTotalChange [execsql {SELECT total_changes()}]\n  expr 0\n} {0}\ndo_test laststmtchanges-6.6 {\n  execsql {\n    SELECT total_changes();\n    DELETE FROM t3;\n    SELECT total_changes();\n  }\n} [list $nTotalChange [expr $nTotalChange+2]]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/like.test",
    "content": "# 2005 August 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIKE and GLOB operators and\n# in particular the optimizations that occur to help those operators\n# run faster.\n#\n# $Id: like.test,v 1.13 2009/06/07 23:45:11 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create some sample data to work with.\n#\ndo_test like-1.0 {\n  execsql {\n    CREATE TABLE t1(x TEXT);\n  }\n  foreach str {\n    a\n    ab\n    abc\n    abcd\n\n    acd\n    abd\n    bc\n    bcd\n\n    xyz\n    ABC\n    CDE\n    {ABC abc xyz}\n  } {\n    db eval {INSERT INTO t1 VALUES(:str)}\n  }\n  execsql {\n    SELECT count(*) FROM t1;\n  }\n} {12}\n\n# Test that both case sensitive and insensitive version of LIKE work.\n#\ndo_test like-1.1 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;\n  }\n} {ABC abc}\ndo_test like-1.2 {\n  execsql {\n    SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;\n  }\n} {abc}\ndo_test like-1.3 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;\n  }\n} {ABC abc}\ndo_test like-1.4 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;\n  }\n} {ABC abc}\ndo_test like-1.5.1 {\n  # Use sqlite3_exec() to verify fix for ticket [25ee81271091] 2011-06-26\n  sqlite3_exec db {PRAGMA case_sensitive_like=on}\n} {0 {}}\ndo_test like-1.5.2 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;\n  }\n} {abc}\ndo_test like-1.5.3 {\n  execsql {\n    PRAGMA case_sensitive_like; -- no argument; does not change setting\n    SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;\n  }\n} {abc}\ndo_test like-1.6 {\n  execsql {\n    SELECT x FROM t1 WHERE x GLOB 'abc' ORDER BY 1;\n  }\n} {abc}\ndo_test like-1.7 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'ABC' ORDER BY 1;\n  }\n} {ABC}\ndo_test like-1.8 {\n  execsql {\n    SELECT x FROM t1 WHERE x LIKE 'aBc' ORDER BY 1;\n  }\n} {}\ndo_test like-1.9 {\n  execsql {\n    PRAGMA case_sensitive_like=off;\n    SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;\n  }\n} {ABC abc}\ndo_test like-1.10 {\n  execsql {\n    PRAGMA case_sensitive_like;  -- No argument, does not change setting.\n    SELECT x FROM t1 WHERE x LIKE 'abc' ORDER BY 1;\n  }\n} {ABC abc}\n\n# Tests of the REGEXP operator\n#\ndo_test like-2.1 {\n  proc test_regexp {a b} {\n    return [regexp $a $b]\n  }\n  db function regexp -argcount 2 test_regexp\n  execsql {\n    SELECT x FROM t1 WHERE x REGEXP 'abc' ORDER BY 1;\n  }\n} {{ABC abc xyz} abc abcd}\ndo_test like-2.2 {\n  execsql {\n    SELECT x FROM t1 WHERE x REGEXP '^abc' ORDER BY 1;\n  }\n} {abc abcd}\n\n# Tests of the MATCH operator\n#\ndo_test like-2.3 {\n  proc test_match {a b} {\n    return [string match $a $b]\n  }\n  db function match -argcount 2 test_match\n  execsql {\n    SELECT x FROM t1 WHERE x MATCH '*abc*' ORDER BY 1;\n  }\n} {{ABC abc xyz} abc abcd}\ndo_test like-2.4 {\n  execsql {\n    SELECT x FROM t1 WHERE x MATCH 'abc*' ORDER BY 1;\n  }\n} {abc abcd}\n\n# For the remaining tests, we need to have the like optimizations\n# enabled.\n#\nifcapable !like_opt {\n  finish_test\n  return\n} \n\n# This procedure executes the SQL.  Then it appends to the result the\n# \"sort\" or \"nosort\" keyword (as in the cksort procedure above) then\n# it appends the names of the table and index used.\n#\nproc queryplan {sql} {\n  set ::sqlite_sort_count 0\n  db cache flush\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  set eqp [execsql \"EXPLAIN QUERY PLAN $sql\"]\n  # puts eqp=$eqp\n  foreach {a b c x} $eqp {\n    if {[regexp { TABLE (\\w+ AS )?(\\w+) USING COVERING INDEX (\\w+)\\y} \\\n        $x all as tab idx]} {\n      lappend data {} $idx\n    } elseif {[regexp { TABLE (\\w+ AS )?(\\w+) USING.* INDEX (\\w+)\\y} \\\n        $x all as tab idx]} {\n      lappend data $tab $idx\n    } elseif {[regexp { TABLE (\\w+ AS )?(\\w+)\\y} $x all as tab]} {\n      lappend data $tab *\n    }\n  }\n  return $data   \n}\n\n# Perform tests on the like optimization.\n#\n# With no index on t1.x and with case sensitivity turned off, no optimization\n# is performed.\n#\ndo_test like-3.1 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;\n  }\n} {ABC {ABC abc xyz} abc abcd sort t1 *}\ndo_test like-3.2 {\n  set sqlite_like_count\n} {12}\n\n# With an index on t1.x and case sensitivity on, optimize completely.\n#\ndo_test like-3.3.100 {\n  set sqlite_like_count 0\n  execsql {\n    PRAGMA case_sensitive_like=on;\n    CREATE INDEX i1 ON t1(x);\n  }\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.3.100.cnt {\n  set sqlite_like_count\n} 0\n\n# The like optimization works even when the pattern is a bound parameter\n#\n# Exception: It does not work if sqlite3_prepare() is used instead of\n# sqlite3_prepare_v2(), as in that case the statement cannot be reprepared\n# after the parameter is bound.\n#\nunset -nocomplain ::likepat\nset ::likepat abc%\nif {[permutation]!=\"prepare\"} {\n  do_test like-3.3.102 {\n    set sqlite_like_count 0\n    queryplan {\n      SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1;\n    }\n  } {abc abcd nosort {} i1}\n  do_test like-3.3.103 {\n    set sqlite_like_count\n  } 0\n}\n\n# Except, the like optimization does not work for bound parameters if\n# the query planner stability guarantee is active.\n#\ndo_test like-3.3.104 {\n  set sqlite_like_count 0\n  sqlite3_db_config db QPSG 1\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE $::likepat ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.3.105 {\n  set sqlite_like_count\n} 12\n\n# The query planner stability guarantee does not disrupt explicit patterns\n#\ndo_test like-3.3.105 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.3.106 {\n  set sqlite_like_count\n} 0\nsqlite3_db_config db QPSG 0\n\n# The LIKE optimization still works when the RHS is a string with no\n# wildcard.  Ticket [e090183531fc2747]\n#\ndo_test like-3.4.2 {\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'a' ORDER BY 1;\n  }\n} {a nosort {} i1}\ndo_test like-3.4.3 {\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'ab' ORDER BY 1;\n  }\n} {ab nosort {} i1}\ndo_test like-3.4.4 {\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abcd' ORDER BY 1;\n  }\n} {abcd nosort {} i1}\ndo_test like-3.4.5 {\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abcde' ORDER BY 1;\n  }\n} {nosort {} i1}\n\n\n# Partial optimization when the pattern does not end in '%'\n#\ndo_test like-3.5 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'a_c' ORDER BY 1;\n  }\n} {abc nosort {} i1}\ndo_test like-3.6 {\n  set sqlite_like_count\n} 6\ndo_test like-3.7 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'ab%d' ORDER BY 1;\n  }\n} {abcd abd nosort {} i1}\ndo_test like-3.8 {\n  set sqlite_like_count\n} 4\ndo_test like-3.9 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'a_c%' ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.10 {\n  set sqlite_like_count\n} 6\n\n# No optimization when the pattern begins with a wildcard.\n# Note that the index is still used but only for sorting.\n#\ndo_test like-3.11 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE '%bcd' ORDER BY 1;\n  }\n} {abcd bcd nosort {} i1}\ndo_test like-3.12 {\n  set sqlite_like_count\n} 12\n\n# No optimization for case insensitive LIKE\n#\ndo_test like-3.13 {\n  set sqlite_like_count 0\n  db eval {PRAGMA case_sensitive_like=off;}\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;\n  }\n} {ABC {ABC abc xyz} abc abcd nosort {} i1}\ndo_test like-3.14 {\n  set sqlite_like_count\n} 12\n\n# No optimization without an index.\n#\ndo_test like-3.15 {\n  set sqlite_like_count 0\n  db eval {\n    PRAGMA case_sensitive_like=on;\n    DROP INDEX i1;\n  }\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1;\n  }\n} {abc abcd sort t1 *}\ndo_test like-3.16 {\n  set sqlite_like_count\n} 12\n\n# No GLOB optimization without an index.\n#\ndo_test like-3.17 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;\n  }\n} {abc abcd sort t1 *}\ndo_test like-3.18 {\n  set sqlite_like_count\n} 12\n\n# GLOB is optimized regardless of the case_sensitive_like setting.\n#\ndo_test like-3.19 {\n  set sqlite_like_count 0\n  db eval {CREATE INDEX i1 ON t1(x);}\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.20 {\n  set sqlite_like_count\n} 0\ndo_test like-3.21 {\n  set sqlite_like_count 0\n  db eval {PRAGMA case_sensitive_like=on;}\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;\n  }\n} {abc abcd nosort {} i1}\ndo_test like-3.22 {\n  set sqlite_like_count\n} 0\ndo_test like-3.23 {\n  set sqlite_like_count 0\n  db eval {PRAGMA case_sensitive_like=off;}\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'a[bc]d' ORDER BY 1;\n  }\n} {abd acd nosort {} i1}\ndo_test like-3.24 {\n  set sqlite_like_count\n} 6\n\n# GLOB optimization when there is no wildcard.  Ticket [e090183531fc2747]\n#\ndo_test like-3.25 {\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'a' ORDER BY 1;\n  }\n} {a nosort {} i1}\ndo_test like-3.26 {\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'abcd' ORDER BY 1;\n  }\n} {abcd nosort {} i1}\ndo_test like-3.27 {\n  queryplan {\n    SELECT x FROM t1 WHERE x GLOB 'abcde' ORDER BY 1;\n  }\n} {nosort {} i1}\n\n\n\n# No optimization if the LHS of the LIKE is not a column name or\n# if the RHS is not a string.\n#\ndo_test like-4.1 {\n  execsql {PRAGMA case_sensitive_like=on}\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1\n  }\n} {abc abcd nosort {} i1}\ndo_test like-4.2 {\n  set sqlite_like_count\n} 0\ndo_test like-4.3 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE +x LIKE 'abc%' ORDER BY 1\n  }\n} {abc abcd nosort {} i1}\ndo_test like-4.4 {\n  set sqlite_like_count\n} 12\ndo_test like-4.5 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE ('ab' || 'c%') ORDER BY 1\n  }\n} {abc abcd nosort {} i1}\ndo_test like-4.6 {\n  set sqlite_like_count\n} 12\n\n# Collating sequences on the index disable the LIKE optimization.\n# Or if the NOCASE collating sequence is used, the LIKE optimization\n# is enabled when case_sensitive_like is OFF.\n#\ndo_test like-5.1 {\n  execsql {PRAGMA case_sensitive_like=off}\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'abc%' ORDER BY 1\n  }\n} {ABC {ABC abc xyz} abc abcd nosort {} i1}\ndo_test like-5.2 {\n  set sqlite_like_count\n} 12\ndo_test like-5.3 {\n  execsql {\n    CREATE TABLE t2(x TEXT COLLATE NOCASE);\n    INSERT INTO t2 SELECT * FROM t1 ORDER BY rowid;\n    CREATE INDEX i2 ON t2(x COLLATE NOCASE);\n  }\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1\n  }\n} {abc ABC {ABC abc xyz} abcd nosort {} i2}\ndo_test like-5.4 {\n  set sqlite_like_count\n} 0\ndo_test like-5.5 {\n  execsql {\n    PRAGMA case_sensitive_like=on;\n  }\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'abc%' ORDER BY 1\n  }\n} {abc abcd nosort {} i2}\ndo_test like-5.6 {\n  set sqlite_like_count\n} 12\ndo_test like-5.7 {\n  execsql {\n    PRAGMA case_sensitive_like=off;\n  }\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x GLOB 'abc*' ORDER BY 1\n  }\n} {abc abcd nosort {} i2}\ndo_test like-5.8 {\n  set sqlite_like_count\n} 12\ndo_test like-5.11 {\n  execsql {PRAGMA case_sensitive_like=off}\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t1 WHERE x LIKE 'ABC%' ORDER BY 1\n  }\n} {ABC {ABC abc xyz} abc abcd nosort {} i1}\ndo_test like-5.12 {\n  set sqlite_like_count\n} 12\ndo_test like-5.13 {\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1\n  }\n} {abc ABC {ABC abc xyz} abcd nosort {} i2}\ndo_test like-5.14 {\n  set sqlite_like_count\n} 0\ndo_test like-5.15 {\n  execsql {\n    PRAGMA case_sensitive_like=on;\n  }\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'ABC%' ORDER BY 1\n  }\n} {ABC {ABC abc xyz} nosort {} i2}\ndo_test like-5.16 {\n  set sqlite_like_count\n} 12\ndo_test like-5.17 {\n  execsql {\n    PRAGMA case_sensitive_like=off;\n  }\n  set sqlite_like_count 0\n  queryplan {\n    SELECT x FROM t2 WHERE x GLOB 'ABC*' ORDER BY 1\n  }\n} {ABC {ABC abc xyz} nosort {} i2}\ndo_test like-5.18 {\n  set sqlite_like_count\n} 12\n\n# Boundary case.  The prefix for a LIKE comparison is rounded up\n# when constructing the comparison.  Example:  \"ab\" becomes \"ac\".\n# In other words, the last character is increased by one.\n#\n# Make sure this happens correctly when the last character is a \n# \"z\" and we are doing case-insensitive comparisons.\n#\n# Ticket #2959\n#\ndo_test like-5.21 {\n  execsql {\n    PRAGMA case_sensitive_like=off;\n    INSERT INTO t2 VALUES('ZZ-upper-upper');\n    INSERT INTO t2 VALUES('zZ-lower-upper');\n    INSERT INTO t2 VALUES('Zz-upper-lower');\n    INSERT INTO t2 VALUES('zz-lower-lower');\n  }\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'zz%';\n  }\n} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}\ndo_test like-5.22 {\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'zZ%';\n  }\n} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}\ndo_test like-5.23 {\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'Zz%';\n  }\n} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}\ndo_test like-5.24 {\n  queryplan {\n    SELECT x FROM t2 WHERE x LIKE 'ZZ%';\n  }\n} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}\ndo_test like-5.25 {\n  db eval {\n    PRAGMA case_sensitive_like=on;\n    CREATE TABLE t3(x TEXT);\n    CREATE INDEX i3 ON t3(x);\n    INSERT INTO t3 VALUES('ZZ-upper-upper');\n    INSERT INTO t3 VALUES('zZ-lower-upper');\n    INSERT INTO t3 VALUES('Zz-upper-lower');\n    INSERT INTO t3 VALUES('zz-lower-lower');\n  }\n  queryplan {\n    SELECT x FROM t3 WHERE x LIKE 'zz%';\n  }\n} {zz-lower-lower nosort {} i3}\ndo_test like-5.26 {\n  queryplan {\n    SELECT x FROM t3 WHERE x LIKE 'zZ%';\n  }\n} {zZ-lower-upper nosort {} i3}\ndo_test like-5.27 {\n  queryplan {\n    SELECT x FROM t3 WHERE x LIKE 'Zz%';\n  }\n} {Zz-upper-lower nosort {} i3}\ndo_test like-5.28 {\n  queryplan {\n    SELECT x FROM t3 WHERE x LIKE 'ZZ%';\n  }\n} {ZZ-upper-upper nosort {} i3}\n\n\n# ticket #2407\n#\n# Make sure the LIKE prefix optimization does not strip off leading\n# characters of the like pattern that happen to be quote characters.\n#\ndo_test like-6.1 {\n  foreach x { 'abc 'bcd 'def 'ax } {\n    set x2 '[string map {' ''} $x]'\n    db eval \"INSERT INTO t2 VALUES($x2)\"\n  }\n  execsql {\n    SELECT * FROM t2 WHERE x LIKE '''a%'\n  }\n} {'abc 'ax}\n\ndo_test like-7.1 {\n  execsql {\n    SELECT rowid, * FROM t1 WHERE rowid GLOB '1*' ORDER BY rowid;\n  }\n} {1 a 10 ABC 11 CDE 12 {ABC abc xyz}}\n\n# ticket #3345.\n#\n# Overloading the LIKE function with -1 for the number of arguments\n# will overload both the 2-argument and the 3-argument LIKE.\n#\ndo_test like-8.1 {\n  db eval {\n    CREATE TABLE t8(x);\n    INSERT INTO t8 VALUES('abcdef');\n    INSERT INTO t8 VALUES('ghijkl');\n    INSERT INTO t8 VALUES('mnopqr');\n    SELECT 1, x FROM t8 WHERE x LIKE '%h%';\n    SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';\n  }\n} {1 ghijkl 2 ghijkl}\ndo_test like-8.2 {\n  proc newlike {args} {return 1} ;# Alternative LIKE is always return TRUE\n  db function like newlike       ;# Uses -1 for nArg in sqlite3_create_function\n  db cache flush\n  db eval {\n    SELECT 1, x FROM t8 WHERE x LIKE '%h%';\n    SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';\n  }\n} {1 ghijkl 2 ghijkl}\ndo_test like-8.3 {\n  db function like -argcount 2 newlike\n  db eval {\n    SELECT 1, x FROM t8 WHERE x LIKE '%h%';\n    SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';\n  }\n} {1 abcdef 1 ghijkl 1 mnopqr 2 ghijkl}\ndo_test like-8.4 {\n  db function like -argcount 3 newlike\n  db eval {\n    SELECT 1, x FROM t8 WHERE x LIKE '%h%';\n    SELECT 2, x FROM t8 WHERE x LIKE '%h%' ESCAPE 'x';\n  }\n} {1 abcdef 1 ghijkl 1 mnopqr 2 abcdef 2 ghijkl 2 mnopqr}\n\n\nifcapable like_opt&&!icu {\n  # Evaluate SQL.  Return the result set followed by the\n  # and the number of full-scan steps.\n  #\n  db close\n  sqlite3 db test.db\n  proc count_steps {sql} {\n    set r [db eval $sql]\n    lappend r scan [db status step] sort [db status sort]\n  }\n  do_test like-9.1 {\n    count_steps {\n       SELECT x FROM t2 WHERE x LIKE 'x%'\n    }\n  } {xyz scan 0 sort 0}\n  do_test like-9.2 {\n    count_steps {\n       SELECT x FROM t2 WHERE x LIKE '_y%'\n    }\n  } {xyz scan 19 sort 0}\n  do_test like-9.3.1 {\n    set res [sqlite3_exec_hex db {\n       SELECT x FROM t2 WHERE x LIKE '%78%25'\n    }]\n  } {0 {x xyz}}\n  ifcapable explain {\n    do_test like-9.3.2 {\n      set res [sqlite3_exec_hex db {\n         EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%78%25'\n      }]\n      regexp {INDEX i2} $res\n    } {1}\n  }\n  do_test like-9.4.1 {\n    sqlite3_exec_hex db {INSERT INTO t2 VALUES('%ffhello')}\n    set res [sqlite3_exec_hex db {\n       SELECT substr(x,2) AS x FROM t2 WHERE +x LIKE '%ff%25'\n    }]\n  } {0 {x hello}}\n  do_test like-9.4.2 {\n    set res [sqlite3_exec_hex db {\n       SELECT substr(x,2) AS x FROM t2 WHERE x LIKE '%ff%25'\n    }]\n  } {0 {x hello}}\n  ifcapable explain {\n    do_test like-9.4.3 {\n      set res [sqlite3_exec_hex db {\n         EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%ff%25'\n      }]\n      regexp {SCAN TABLE t2} $res\n    } {1}\n  }\n  do_test like-9.5.1 {\n    set res [sqlite3_exec_hex db {\n       SELECT x FROM t2 WHERE x LIKE '%fe%25'\n    }]\n  } {0 {}}\n  ifcapable explain {\n    do_test like-9.5.2 {\n      set res [sqlite3_exec_hex db {\n         EXPLAIN QUERY PLAN SELECT x FROM t2 WHERE x LIKE '%fe%25'\n      }]\n      regexp {INDEX i2} $res\n    } {1}\n  }\n\n  # Do an SQL statement.  Append the search count to the end of the result.\n  #\n  proc count sql {\n    set ::sqlite_search_count 0\n    set ::sqlite_like_count 0\n    return [concat [execsql $sql] scan $::sqlite_search_count \\\n             like $::sqlite_like_count]\n  }\n\n  # The LIKE and GLOB optimizations do not work on columns with\n  # affinity other than TEXT.\n  # Ticket #3901\n  #\n  do_test like-10.1 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t10(\n        a INTEGER PRIMARY KEY,\n        b INTEGER COLLATE nocase UNIQUE,\n        c NUMBER COLLATE nocase UNIQUE,\n        d BLOB COLLATE nocase UNIQUE,\n        e COLLATE nocase UNIQUE,\n        f TEXT COLLATE nocase UNIQUE\n      );\n      INSERT INTO t10 VALUES(1,1,1,1,1,1);\n      INSERT INTO t10 VALUES(12,12,12,12,12,12);\n      INSERT INTO t10 VALUES(123,123,123,123,123,123);\n      INSERT INTO t10 VALUES(234,234,234,234,234,234);\n      INSERT INTO t10 VALUES(345,345,345,345,345,345);\n      INSERT INTO t10 VALUES(45,45,45,45,45,45);\n    }\n    count {\n      SELECT a FROM t10 WHERE b LIKE '12%' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.2 {\n    count {\n      SELECT a FROM t10 WHERE c LIKE '12%' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.3 {\n    count {\n      SELECT a FROM t10 WHERE d LIKE '12%' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.4 {\n    count {\n      SELECT a FROM t10 WHERE e LIKE '12%' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  ifcapable like_match_blobs {\n    do_test like-10.5a {\n      count {\n        SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a;\n      }\n    } {12 123 scan 4 like 0}\n  } else {\n    do_test like-10.5b {\n      count {\n        SELECT a FROM t10 WHERE f LIKE '12%' ORDER BY +a;\n      }\n    } {12 123 scan 3 like 0}\n  }\n  do_test like-10.6 {\n    count {\n      SELECT a FROM t10 WHERE a LIKE '12%' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.10 {\n    execsql {\n      CREATE TABLE t10b(\n        a INTEGER PRIMARY KEY,\n        b INTEGER UNIQUE,\n        c NUMBER UNIQUE,\n        d BLOB UNIQUE,\n        e UNIQUE,\n        f TEXT UNIQUE\n      );\n      INSERT INTO t10b SELECT * FROM t10;\n    }\n    count {\n      SELECT a FROM t10b WHERE b GLOB '12*' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.11 {\n    count {\n      SELECT a FROM t10b WHERE c GLOB '12*' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.12 {\n    count {\n      SELECT a FROM t10b WHERE d GLOB '12*' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  do_test like-10.13 {\n    count {\n      SELECT a FROM t10b WHERE e GLOB '12*' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n  ifcapable like_match_blobs {\n    do_test like-10.14 {\n      count {\n        SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a;\n      }\n    } {12 123 scan 4 like 0}\n  } else {\n    do_test like-10.14 {\n      count {\n        SELECT a FROM t10b WHERE f GLOB '12*' ORDER BY +a;\n      }\n    } {12 123 scan 3 like 0}\n  }\n  do_test like-10.15 {\n    count {\n      SELECT a FROM t10b WHERE a GLOB '12*' ORDER BY +a;\n    }\n  } {12 123 scan 5 like 6}\n}\n\n# LIKE and GLOB where the default collating sequence is not appropriate\n# but an index with the appropriate collating sequence exists.\n#\ndo_test like-11.0 {\n  execsql {\n    CREATE TABLE t11(\n      a INTEGER PRIMARY KEY,\n      b TEXT COLLATE nocase,\n      c TEXT COLLATE binary\n    );\n    INSERT INTO t11 VALUES(1, 'a','a');\n    INSERT INTO t11 VALUES(2, 'ab','ab');\n    INSERT INTO t11 VALUES(3, 'abc','abc');\n    INSERT INTO t11 VALUES(4, 'abcd','abcd');\n    INSERT INTO t11 VALUES(5, 'A','A');\n    INSERT INTO t11 VALUES(6, 'AB','AB');\n    INSERT INTO t11 VALUES(7, 'ABC','ABC');\n    INSERT INTO t11 VALUES(8, 'ABCD','ABCD');\n    INSERT INTO t11 VALUES(9, 'x','x');\n    INSERT INTO t11 VALUES(10, 'yz','yz');\n    INSERT INTO t11 VALUES(11, 'X','X');\n    INSERT INTO t11 VALUES(12, 'YZ','YZ');\n    SELECT count(*) FROM t11;\n  }\n} {12}\ndo_test like-11.1 {\n  db eval {PRAGMA case_sensitive_like=OFF;}\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;\n  }\n} {abc abcd ABC ABCD nosort t11 *}\ndo_test like-11.2 {\n  db eval {PRAGMA case_sensitive_like=ON;}\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;\n  }\n} {abc abcd nosort t11 *}\ndo_test like-11.3 {\n  db eval {\n    PRAGMA case_sensitive_like=OFF;\n    CREATE INDEX t11b ON t11(b);\n  }\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;\n  }\n} {abc abcd ABC ABCD sort {} t11b}\ndo_test like-11.4 {\n  db eval {PRAGMA case_sensitive_like=ON;}\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY a;\n  }\n} {abc abcd nosort t11 *}\ndo_test like-11.5 {\n  db eval {\n    PRAGMA case_sensitive_like=OFF;\n    DROP INDEX t11b;\n    CREATE INDEX t11bnc ON t11(b COLLATE nocase);\n  }\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;\n  }\n} {abc abcd ABC ABCD sort {} t11bnc}\ndo_test like-11.6 {\n  db eval {CREATE INDEX t11bb ON t11(b COLLATE binary);}\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;\n  }\n} {abc abcd ABC ABCD sort {} t11bnc}\ndo_test like-11.7 {\n  db eval {PRAGMA case_sensitive_like=ON;}\n  queryplan {\n    SELECT b FROM t11 WHERE b LIKE 'abc%' ORDER BY +a;\n  }\n} {abc abcd sort {} t11bb}\ndo_test like-11.8 {\n  db eval {PRAGMA case_sensitive_like=OFF;}\n  queryplan {\n    SELECT b FROM t11 WHERE b GLOB 'abc*' ORDER BY +a;\n  }\n} {abc abcd sort {} t11bb}\ndo_test like-11.9 {\n  db eval {\n    CREATE INDEX t11cnc ON t11(c COLLATE nocase);\n    CREATE INDEX t11cb ON t11(c COLLATE binary);\n  }\n  queryplan {\n    SELECT c FROM t11 WHERE c LIKE 'abc%' ORDER BY +a;\n  }\n} {abc abcd ABC ABCD sort {} t11cnc}\ndo_test like-11.10 {\n  queryplan {\n    SELECT c FROM t11 WHERE c GLOB 'abc*' ORDER BY +a;\n  }\n} {abc abcd sort {} t11cb}\n\n# A COLLATE clause on the pattern does not change the result of a\n# LIKE operator.\n#\ndo_execsql_test like-12.1 {\n  CREATE TABLE t12nc(id INTEGER, x TEXT UNIQUE COLLATE nocase);\n  INSERT INTO t12nc VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');\n  CREATE TABLE t12b(id INTEGER, x TEXT UNIQUE COLLATE binary);\n  INSERT INTO t12b VALUES(1,'abcde'),(2,'uvwxy'),(3,'ABCDEF');\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;\n} {1 3}\ndo_execsql_test like-12.2 {\n  SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;\n} {1 3}\ndo_execsql_test like-12.3 {\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;\n} {1 3}\ndo_execsql_test like-12.4 {\n  SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;\n} {1 3}\ndo_execsql_test like-12.5 {\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;\n} {1 3}\ndo_execsql_test like-12.6 {\n  SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;\n} {1 3}\n\n# Adding a COLLATE clause to the pattern of a LIKE operator does nothing\n# to change the suitability of using an index to satisfy that LIKE\n# operator.\n#\ndo_execsql_test like-12.11 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' ORDER BY +id;\n} {/SEARCH/}\ndo_execsql_test like-12.12 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12b WHERE x LIKE 'abc%' ORDER BY +id;\n} {/SCAN/}\ndo_execsql_test like-12.13 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;\n} {/SEARCH/}\ndo_execsql_test like-12.14 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE nocase ORDER BY +id;\n} {/SCAN/}\ndo_execsql_test like-12.15 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12nc WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;\n} {/SEARCH/}\ndo_execsql_test like-12.16 {\n  EXPLAIN QUERY PLAN\n  SELECT id FROM t12b WHERE x LIKE 'abc%' COLLATE binary ORDER BY +id;\n} {/SCAN/}\n\n# Ticket [https://www.sqlite.org/src/tktview/80369eddd5c94d49f7fbbcf5]\n# 2016-01-20\n#\ndo_execsql_test like-13.1 {\n  SELECT char(0x304d) LIKE char(0x306d);\n} {0}\ndo_execsql_test like-13.2 {\n  SELECT char(0x4d) LIKE char(0x306d);\n} {0}\ndo_execsql_test like-13.3 {\n  SELECT char(0x304d) LIKE char(0x6d);\n} {0}\ndo_execsql_test like-13.4 {\n  SELECT char(0x4d) LIKE char(0x6d);\n} {1}\n\n# Performance testing for patterns with many wildcards.  These LIKE and GLOB\n# patterns were quite slow with SQLite 3.15.2 and earlier.\n#\ndo_test like-14.1 {\n  set x [lindex [time {\n    db one {SELECT 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz'GLOB'*a*a*a*a*a*a*a*a*y'}\n  }] 0]\n  puts -nonewline \" ($x ms - want less than 1000) \"\n  expr {$x<1000}\n} {1}\nifcapable !icu {\n  do_test like-14.2 {\n    set x [lindex [time {\n      db one {SELECT 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz'LIKE'%a%a%a%a%a%a%a%a%y'}\n    }] 0]\n    puts -nonewline \" ($x ms - want less than 1000) \"\n    expr {$x<1000}\n  } {1}\n}\n\nifcapable !icu {\n# As of 2017-07-27 (3.21.0) the LIKE optimization works with ESCAPE as\n# long as the ESCAPE is a single-byte literal.\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test like-15.100 {\n  CREATE TABLE t15(x TEXT COLLATE nocase, y, PRIMARY KEY(x));\n  INSERT INTO t15(x,y) VALUES\n    ('abcde',1), ('ab%de',2), ('a_cde',3),\n    ('uvwxy',11),('uvwx%',12),('uvwx_',13),\n    ('_bcde',21),('%bcde',22),\n    ('abcd_',31),('abcd%',32),\n    ('ab%xy',41);\n  SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '/';\n} {2}\ndo_execsql_test like-15.101 {\n  EXPLAIN QUERY PLAN\n  SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '/';\n} {/SEARCH/}\ndo_execsql_test like-15.102 {\n  EXPLAIN QUERY PLAN\n  SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '//';\n} {/SCAN/}\ndo_execsql_test like-15.103 {\n  EXPLAIN QUERY PLAN\n  SELECT y FROM t15 WHERE x LIKE 'ab/%d%' ESCAPE '';\n} {/SCAN/}\ndo_execsql_test like-15.110 {\n  SELECT y FROM t15 WHERE x LIKE 'abcdx%%' ESCAPE 'x';\n} {32}\ndo_execsql_test like-15.111 {\n  SELECT y FROM t15 WHERE x LIKE 'abx%%' ESCAPE 'x' ORDER BY +y\n} {2 41}\ndo_execsql_test like-15.112 {\n  EXPLAIN QUERY PLAN\n  SELECT y FROM t15 WHERE x LIKE 'abx%%' ESCAPE 'x' ORDER BY +y\n} {/SEARCH/}\ndo_execsql_test like-15.120 {\n  SELECT y FROM t15 WHERE x LIKE '/%bc%' ESCAPE '/';\n} {22}\ndo_execsql_test like-15.121 {\n  EXPLAIN QUERY PLAN\n  SELECT y FROM t15 WHERE x LIKE '/%bc%' ESCAPE '/';\n} {/SEARCH/}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/like2.test",
    "content": "# 2008 May 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIKE and GLOB operators and\n# in particular the optimizations that occur to help those operators\n# run faster.\n#\n# $Id: like2.test,v 1.1 2008/05/26 18:33:41 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test like2-1.1 {\n  db eval {\n    CREATE TABLE t1(x INT, y COLLATE NOCASE);\n    INSERT INTO t1(x,y) VALUES(1,CAST(x'01' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(2,CAST(x'02' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(3,CAST(x'03' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(4,CAST(x'04' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(5,CAST(x'05' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(6,CAST(x'06' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(7,CAST(x'07' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(8,CAST(x'08' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(9,CAST(x'09' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(10,CAST(x'0a' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(11,CAST(x'0b' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(12,CAST(x'0c' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(13,CAST(x'0d' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(14,CAST(x'0e' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(15,CAST(x'0f' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(16,CAST(x'10' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(17,CAST(x'11' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(18,CAST(x'12' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(19,CAST(x'13' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(20,CAST(x'14' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(21,CAST(x'15' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(22,CAST(x'16' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(23,CAST(x'17' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(24,CAST(x'18' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(25,CAST(x'19' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(26,CAST(x'1a' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(27,CAST(x'1b' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(28,CAST(x'1c' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(29,CAST(x'1d' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(30,CAST(x'1e' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(31,CAST(x'1f' AS TEXT));\n    INSERT INTO t1(x,y) VALUES(32,' ');\n    INSERT INTO t1(x,y) VALUES(33,'!');\n    INSERT INTO t1(x,y) VALUES(34,'\"');\n    INSERT INTO t1(x,y) VALUES(35,'#');\n    INSERT INTO t1(x,y) VALUES(36,'$');\n    INSERT INTO t1(x,y) VALUES(37,'%');\n    INSERT INTO t1(x,y) VALUES(38,'&');\n    INSERT INTO t1(x,y) VALUES(39,'''');\n    INSERT INTO t1(x,y) VALUES(40,'(');\n    INSERT INTO t1(x,y) VALUES(41,')');\n    INSERT INTO t1(x,y) VALUES(42,'*');\n    INSERT INTO t1(x,y) VALUES(43,'+');\n    INSERT INTO t1(x,y) VALUES(44,',');\n    INSERT INTO t1(x,y) VALUES(45,'-');\n    INSERT INTO t1(x,y) VALUES(46,'.');\n    INSERT INTO t1(x,y) VALUES(47,'/');\n    INSERT INTO t1(x,y) VALUES(48,'0');\n    INSERT INTO t1(x,y) VALUES(49,'1');\n    INSERT INTO t1(x,y) VALUES(50,'2');\n    INSERT INTO t1(x,y) VALUES(51,'3');\n    INSERT INTO t1(x,y) VALUES(52,'4');\n    INSERT INTO t1(x,y) VALUES(53,'5');\n    INSERT INTO t1(x,y) VALUES(54,'6');\n    INSERT INTO t1(x,y) VALUES(55,'7');\n    INSERT INTO t1(x,y) VALUES(56,'8');\n    INSERT INTO t1(x,y) VALUES(57,'9');\n    INSERT INTO t1(x,y) VALUES(58,':');\n    INSERT INTO t1(x,y) VALUES(59,';');\n    INSERT INTO t1(x,y) VALUES(60,'<');\n    INSERT INTO t1(x,y) VALUES(61,'=');\n    INSERT INTO t1(x,y) VALUES(62,'>');\n    INSERT INTO t1(x,y) VALUES(63,'?');\n    INSERT INTO t1(x,y) VALUES(64,'@');\n    INSERT INTO t1(x,y) VALUES(65,'A');\n    INSERT INTO t1(x,y) VALUES(66,'B');\n    INSERT INTO t1(x,y) VALUES(67,'C');\n    INSERT INTO t1(x,y) VALUES(68,'D');\n    INSERT INTO t1(x,y) VALUES(69,'E');\n    INSERT INTO t1(x,y) VALUES(70,'F');\n    INSERT INTO t1(x,y) VALUES(71,'G');\n    INSERT INTO t1(x,y) VALUES(72,'H');\n    INSERT INTO t1(x,y) VALUES(73,'I');\n    INSERT INTO t1(x,y) VALUES(74,'J');\n    INSERT INTO t1(x,y) VALUES(75,'K');\n    INSERT INTO t1(x,y) VALUES(76,'L');\n    INSERT INTO t1(x,y) VALUES(77,'M');\n    INSERT INTO t1(x,y) VALUES(78,'N');\n    INSERT INTO t1(x,y) VALUES(79,'O');\n    INSERT INTO t1(x,y) VALUES(80,'P');\n    INSERT INTO t1(x,y) VALUES(81,'Q');\n    INSERT INTO t1(x,y) VALUES(82,'R');\n    INSERT INTO t1(x,y) VALUES(83,'S');\n    INSERT INTO t1(x,y) VALUES(84,'T');\n    INSERT INTO t1(x,y) VALUES(85,'U');\n    INSERT INTO t1(x,y) VALUES(86,'V');\n    INSERT INTO t1(x,y) VALUES(87,'W');\n    INSERT INTO t1(x,y) VALUES(88,'X');\n    INSERT INTO t1(x,y) VALUES(89,'Y');\n    INSERT INTO t1(x,y) VALUES(90,'Z');\n    INSERT INTO t1(x,y) VALUES(91,'[');\n    INSERT INTO t1(x,y) VALUES(92,'\\');\n    INSERT INTO t1(x,y) VALUES(93,']');\n    INSERT INTO t1(x,y) VALUES(94,'^');\n    INSERT INTO t1(x,y) VALUES(95,'_');\n    INSERT INTO t1(x,y) VALUES(96,'`');\n    INSERT INTO t1(x,y) VALUES(97,'a');\n    INSERT INTO t1(x,y) VALUES(98,'b');\n    INSERT INTO t1(x,y) VALUES(99,'c');\n    INSERT INTO t1(x,y) VALUES(100,'d');\n    INSERT INTO t1(x,y) VALUES(101,'e');\n    INSERT INTO t1(x,y) VALUES(102,'f');\n    INSERT INTO t1(x,y) VALUES(103,'g');\n    INSERT INTO t1(x,y) VALUES(104,'h');\n    INSERT INTO t1(x,y) VALUES(105,'i');\n    INSERT INTO t1(x,y) VALUES(106,'j');\n    INSERT INTO t1(x,y) VALUES(107,'k');\n    INSERT INTO t1(x,y) VALUES(108,'l');\n    INSERT INTO t1(x,y) VALUES(109,'m');\n    INSERT INTO t1(x,y) VALUES(110,'n');\n    INSERT INTO t1(x,y) VALUES(111,'o');\n    INSERT INTO t1(x,y) VALUES(112,'p');\n    INSERT INTO t1(x,y) VALUES(113,'q');\n    INSERT INTO t1(x,y) VALUES(114,'r');\n    INSERT INTO t1(x,y) VALUES(115,'s');\n    INSERT INTO t1(x,y) VALUES(116,'t');\n    INSERT INTO t1(x,y) VALUES(117,'u');\n    INSERT INTO t1(x,y) VALUES(118,'v');\n    INSERT INTO t1(x,y) VALUES(119,'w');\n    INSERT INTO t1(x,y) VALUES(120,'x');\n    INSERT INTO t1(x,y) VALUES(121,'y');\n    INSERT INTO t1(x,y) VALUES(122,'z');\n    INSERT INTO t1(x,y) VALUES(123,'{');\n    INSERT INTO t1(x,y) VALUES(124,'|');\n    INSERT INTO t1(x,y) VALUES(125,'}');\n    INSERT INTO t1(x,y) VALUES(126,'~');\n    INSERT INTO t1(x,y) VALUES(127,CAST(x'7f' AS TEXT));\n    SELECT count(*) FROM t1;\n  }\n} {127}\ndo_test like2-1.2 {\n  db eval {\n    CREATE TABLE t2(x INT, y COLLATE NOCASE);\n    INSERT INTO t2 SELECT * FROM t1;\n    CREATE INDEX i2 ON t2(y);\n    SELECT count(*) FROM t2;\n  }\n} {127}\ndo_test like2-1.3 {\n  db eval {\n    CREATE TABLE t3(x INT, y COLLATE NOCASE);\n    INSERT INTO t3 SELECT x, 'abc' || y || 'xyz' FROM t1;\n    CREATE INDEX i3 ON t3(y);\n    SELECT count(*) FROM t2;\n  }\n} {127}\ndo_test like-2.32.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE ' %'\"\n} {32}\ndo_test like-2.32.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE ' %'\"\n} {32}\ndo_test like-2.32.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc %'\"\n} {32}\ndo_test like-2.33.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '!%'\"\n} {33}\ndo_test like-2.33.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '!%'\"\n} {33}\ndo_test like-2.33.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc!%'\"\n} {33}\ndo_test like-2.34.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\\"%'\"\n} {34}\ndo_test like-2.34.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\\"%'\"\n} {34}\ndo_test like-2.34.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\\"%'\"\n} {34}\ndo_test like-2.35.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '#%'\"\n} {35}\ndo_test like-2.35.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '#%'\"\n} {35}\ndo_test like-2.35.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc#%'\"\n} {35}\ndo_test like-2.36.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\$%'\"\n} {36}\ndo_test like-2.36.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\$%'\"\n} {36}\ndo_test like-2.36.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\$%'\"\n} {36}\ndo_test like-2.38.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '&%'\"\n} {38}\ndo_test like-2.38.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '&%'\"\n} {38}\ndo_test like-2.38.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc&%'\"\n} {38}\ndo_test like-2.39.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '''%'\"\n} {39}\ndo_test like-2.39.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '''%'\"\n} {39}\ndo_test like-2.39.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc''%'\"\n} {39}\ndo_test like-2.40.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '(%'\"\n} {40}\ndo_test like-2.40.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '(%'\"\n} {40}\ndo_test like-2.40.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc(%'\"\n} {40}\ndo_test like-2.41.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE ')%'\"\n} {41}\ndo_test like-2.41.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE ')%'\"\n} {41}\ndo_test like-2.41.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc)%'\"\n} {41}\ndo_test like-2.42.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '*%'\"\n} {42}\ndo_test like-2.42.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '*%'\"\n} {42}\ndo_test like-2.42.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc*%'\"\n} {42}\ndo_test like-2.43.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '+%'\"\n} {43}\ndo_test like-2.43.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '+%'\"\n} {43}\ndo_test like-2.43.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc+%'\"\n} {43}\ndo_test like-2.44.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE ',%'\"\n} {44}\ndo_test like-2.44.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE ',%'\"\n} {44}\ndo_test like-2.44.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc,%'\"\n} {44}\ndo_test like-2.45.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '-%'\"\n} {45}\ndo_test like-2.45.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '-%'\"\n} {45}\ndo_test like-2.45.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc-%'\"\n} {45}\ndo_test like-2.46.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '.%'\"\n} {46}\ndo_test like-2.46.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '.%'\"\n} {46}\ndo_test like-2.46.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc.%'\"\n} {46}\ndo_test like-2.47.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '/%'\"\n} {47}\ndo_test like-2.47.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '/%'\"\n} {47}\ndo_test like-2.47.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc/%'\"\n} {47}\ndo_test like-2.48.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '0%'\"\n} {48}\ndo_test like-2.48.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '0%'\"\n} {48}\ndo_test like-2.48.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc0%'\"\n} {48}\ndo_test like-2.49.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '1%'\"\n} {49}\ndo_test like-2.49.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '1%'\"\n} {49}\ndo_test like-2.49.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc1%'\"\n} {49}\ndo_test like-2.50.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '2%'\"\n} {50}\ndo_test like-2.50.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '2%'\"\n} {50}\ndo_test like-2.50.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc2%'\"\n} {50}\ndo_test like-2.51.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '3%'\"\n} {51}\ndo_test like-2.51.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '3%'\"\n} {51}\ndo_test like-2.51.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc3%'\"\n} {51}\ndo_test like-2.52.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '4%'\"\n} {52}\ndo_test like-2.52.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '4%'\"\n} {52}\ndo_test like-2.52.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc4%'\"\n} {52}\ndo_test like-2.53.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '5%'\"\n} {53}\ndo_test like-2.53.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '5%'\"\n} {53}\ndo_test like-2.53.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc5%'\"\n} {53}\ndo_test like-2.54.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '6%'\"\n} {54}\ndo_test like-2.54.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '6%'\"\n} {54}\ndo_test like-2.54.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc6%'\"\n} {54}\ndo_test like-2.55.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '7%'\"\n} {55}\ndo_test like-2.55.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '7%'\"\n} {55}\ndo_test like-2.55.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc7%'\"\n} {55}\ndo_test like-2.56.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '8%'\"\n} {56}\ndo_test like-2.56.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '8%'\"\n} {56}\ndo_test like-2.56.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc8%'\"\n} {56}\ndo_test like-2.57.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '9%'\"\n} {57}\ndo_test like-2.57.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '9%'\"\n} {57}\ndo_test like-2.57.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc9%'\"\n} {57}\ndo_test like-2.58.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE ':%'\"\n} {58}\ndo_test like-2.58.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE ':%'\"\n} {58}\ndo_test like-2.58.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc:%'\"\n} {58}\ndo_test like-2.59.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE ';%'\"\n} {59}\ndo_test like-2.59.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE ';%'\"\n} {59}\ndo_test like-2.59.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc;%'\"\n} {59}\ndo_test like-2.60.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '<%'\"\n} {60}\ndo_test like-2.60.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '<%'\"\n} {60}\ndo_test like-2.60.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc<%'\"\n} {60}\ndo_test like-2.61.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '=%'\"\n} {61}\ndo_test like-2.61.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '=%'\"\n} {61}\ndo_test like-2.61.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc=%'\"\n} {61}\ndo_test like-2.62.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '>%'\"\n} {62}\ndo_test like-2.62.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '>%'\"\n} {62}\ndo_test like-2.62.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc>%'\"\n} {62}\ndo_test like-2.63.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '?%'\"\n} {63}\ndo_test like-2.63.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '?%'\"\n} {63}\ndo_test like-2.63.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc?%'\"\n} {63}\ndo_test like-2.64.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '@%'\"\n} {64}\ndo_test like-2.64.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '@%'\"\n} {64}\ndo_test like-2.64.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc@%'\"\n} {64}\ndo_test like-2.65.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'A%'\"\n} {65 97}\ndo_test like-2.65.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'A%'\"\n} {65 97}\ndo_test like-2.65.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcA%'\"\n} {65 97}\ndo_test like-2.66.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'B%'\"\n} {66 98}\ndo_test like-2.66.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'B%'\"\n} {66 98}\ndo_test like-2.66.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcB%'\"\n} {66 98}\ndo_test like-2.67.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'C%'\"\n} {67 99}\ndo_test like-2.67.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'C%'\"\n} {67 99}\ndo_test like-2.67.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcC%'\"\n} {67 99}\ndo_test like-2.68.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'D%'\"\n} {68 100}\ndo_test like-2.68.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'D%'\"\n} {68 100}\ndo_test like-2.68.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcD%'\"\n} {68 100}\ndo_test like-2.69.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'E%'\"\n} {69 101}\ndo_test like-2.69.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'E%'\"\n} {69 101}\ndo_test like-2.69.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcE%'\"\n} {69 101}\ndo_test like-2.70.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'F%'\"\n} {70 102}\ndo_test like-2.70.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'F%'\"\n} {70 102}\ndo_test like-2.70.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcF%'\"\n} {70 102}\ndo_test like-2.71.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'G%'\"\n} {71 103}\ndo_test like-2.71.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'G%'\"\n} {71 103}\ndo_test like-2.71.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcG%'\"\n} {71 103}\ndo_test like-2.72.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'H%'\"\n} {72 104}\ndo_test like-2.72.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'H%'\"\n} {72 104}\ndo_test like-2.72.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcH%'\"\n} {72 104}\ndo_test like-2.73.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'I%'\"\n} {73 105}\ndo_test like-2.73.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'I%'\"\n} {73 105}\ndo_test like-2.73.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcI%'\"\n} {73 105}\ndo_test like-2.74.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'J%'\"\n} {74 106}\ndo_test like-2.74.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'J%'\"\n} {74 106}\ndo_test like-2.74.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcJ%'\"\n} {74 106}\ndo_test like-2.75.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'K%'\"\n} {75 107}\ndo_test like-2.75.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'K%'\"\n} {75 107}\ndo_test like-2.75.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcK%'\"\n} {75 107}\ndo_test like-2.76.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'L%'\"\n} {76 108}\ndo_test like-2.76.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'L%'\"\n} {76 108}\ndo_test like-2.76.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcL%'\"\n} {76 108}\ndo_test like-2.77.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'M%'\"\n} {77 109}\ndo_test like-2.77.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'M%'\"\n} {77 109}\ndo_test like-2.77.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcM%'\"\n} {77 109}\ndo_test like-2.78.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'N%'\"\n} {78 110}\ndo_test like-2.78.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'N%'\"\n} {78 110}\ndo_test like-2.78.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcN%'\"\n} {78 110}\ndo_test like-2.79.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'O%'\"\n} {79 111}\ndo_test like-2.79.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'O%'\"\n} {79 111}\ndo_test like-2.79.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcO%'\"\n} {79 111}\ndo_test like-2.80.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'P%'\"\n} {80 112}\ndo_test like-2.80.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'P%'\"\n} {80 112}\ndo_test like-2.80.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcP%'\"\n} {80 112}\ndo_test like-2.81.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'Q%'\"\n} {81 113}\ndo_test like-2.81.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'Q%'\"\n} {81 113}\ndo_test like-2.81.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcQ%'\"\n} {81 113}\ndo_test like-2.82.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'R%'\"\n} {82 114}\ndo_test like-2.82.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'R%'\"\n} {82 114}\ndo_test like-2.82.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcR%'\"\n} {82 114}\ndo_test like-2.83.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'S%'\"\n} {83 115}\ndo_test like-2.83.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'S%'\"\n} {83 115}\ndo_test like-2.83.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcS%'\"\n} {83 115}\ndo_test like-2.84.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'T%'\"\n} {84 116}\ndo_test like-2.84.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'T%'\"\n} {84 116}\ndo_test like-2.84.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcT%'\"\n} {84 116}\ndo_test like-2.85.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'U%'\"\n} {85 117}\ndo_test like-2.85.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'U%'\"\n} {85 117}\ndo_test like-2.85.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcU%'\"\n} {85 117}\ndo_test like-2.86.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'V%'\"\n} {86 118}\ndo_test like-2.86.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'V%'\"\n} {86 118}\ndo_test like-2.86.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcV%'\"\n} {86 118}\ndo_test like-2.87.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'W%'\"\n} {87 119}\ndo_test like-2.87.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'W%'\"\n} {87 119}\ndo_test like-2.87.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcW%'\"\n} {87 119}\ndo_test like-2.88.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'X%'\"\n} {88 120}\ndo_test like-2.88.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'X%'\"\n} {88 120}\ndo_test like-2.88.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcX%'\"\n} {88 120}\ndo_test like-2.89.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'Y%'\"\n} {89 121}\ndo_test like-2.89.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'Y%'\"\n} {89 121}\ndo_test like-2.89.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcY%'\"\n} {89 121}\ndo_test like-2.90.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'Z%'\"\n} {90 122}\ndo_test like-2.90.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'Z%'\"\n} {90 122}\ndo_test like-2.90.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcZ%'\"\n} {90 122}\ndo_test like-2.91.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\[%'\"\n} {91}\ndo_test like-2.91.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\[%'\"\n} {91}\ndo_test like-2.91.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\[%'\"\n} {91}\ndo_test like-2.92.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\\\%'\"\n} {92}\ndo_test like-2.92.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\\\%'\"\n} {92}\ndo_test like-2.92.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\\\%'\"\n} {92}\ndo_test like-2.93.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\]%'\"\n} {93}\ndo_test like-2.93.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\]%'\"\n} {93}\ndo_test like-2.93.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\]%'\"\n} {93}\ndo_test like-2.94.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '^%'\"\n} {94}\ndo_test like-2.94.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '^%'\"\n} {94}\ndo_test like-2.94.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc^%'\"\n} {94}\ndo_test like-2.96.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '`%'\"\n} {96}\ndo_test like-2.96.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '`%'\"\n} {96}\ndo_test like-2.96.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc`%'\"\n} {96}\ndo_test like-2.97.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'a%'\"\n} {65 97}\ndo_test like-2.97.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'a%'\"\n} {65 97}\ndo_test like-2.97.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abca%'\"\n} {65 97}\ndo_test like-2.98.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'b%'\"\n} {66 98}\ndo_test like-2.98.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'b%'\"\n} {66 98}\ndo_test like-2.98.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcb%'\"\n} {66 98}\ndo_test like-2.99.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'c%'\"\n} {67 99}\ndo_test like-2.99.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'c%'\"\n} {67 99}\ndo_test like-2.99.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcc%'\"\n} {67 99}\ndo_test like-2.100.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'd%'\"\n} {68 100}\ndo_test like-2.100.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'd%'\"\n} {68 100}\ndo_test like-2.100.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcd%'\"\n} {68 100}\ndo_test like-2.101.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'e%'\"\n} {69 101}\ndo_test like-2.101.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'e%'\"\n} {69 101}\ndo_test like-2.101.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abce%'\"\n} {69 101}\ndo_test like-2.102.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'f%'\"\n} {70 102}\ndo_test like-2.102.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'f%'\"\n} {70 102}\ndo_test like-2.102.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcf%'\"\n} {70 102}\ndo_test like-2.103.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'g%'\"\n} {71 103}\ndo_test like-2.103.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'g%'\"\n} {71 103}\ndo_test like-2.103.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcg%'\"\n} {71 103}\ndo_test like-2.104.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'h%'\"\n} {72 104}\ndo_test like-2.104.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'h%'\"\n} {72 104}\ndo_test like-2.104.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abch%'\"\n} {72 104}\ndo_test like-2.105.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'i%'\"\n} {73 105}\ndo_test like-2.105.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'i%'\"\n} {73 105}\ndo_test like-2.105.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abci%'\"\n} {73 105}\ndo_test like-2.106.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'j%'\"\n} {74 106}\ndo_test like-2.106.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'j%'\"\n} {74 106}\ndo_test like-2.106.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcj%'\"\n} {74 106}\ndo_test like-2.107.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'k%'\"\n} {75 107}\ndo_test like-2.107.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'k%'\"\n} {75 107}\ndo_test like-2.107.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abck%'\"\n} {75 107}\ndo_test like-2.108.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'l%'\"\n} {76 108}\ndo_test like-2.108.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'l%'\"\n} {76 108}\ndo_test like-2.108.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcl%'\"\n} {76 108}\ndo_test like-2.109.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'm%'\"\n} {77 109}\ndo_test like-2.109.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'm%'\"\n} {77 109}\ndo_test like-2.109.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcm%'\"\n} {77 109}\ndo_test like-2.110.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'n%'\"\n} {78 110}\ndo_test like-2.110.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'n%'\"\n} {78 110}\ndo_test like-2.110.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcn%'\"\n} {78 110}\ndo_test like-2.111.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'o%'\"\n} {79 111}\ndo_test like-2.111.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'o%'\"\n} {79 111}\ndo_test like-2.111.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abco%'\"\n} {79 111}\ndo_test like-2.112.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'p%'\"\n} {80 112}\ndo_test like-2.112.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'p%'\"\n} {80 112}\ndo_test like-2.112.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcp%'\"\n} {80 112}\ndo_test like-2.113.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'q%'\"\n} {81 113}\ndo_test like-2.113.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'q%'\"\n} {81 113}\ndo_test like-2.113.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcq%'\"\n} {81 113}\ndo_test like-2.114.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'r%'\"\n} {82 114}\ndo_test like-2.114.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'r%'\"\n} {82 114}\ndo_test like-2.114.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcr%'\"\n} {82 114}\ndo_test like-2.115.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 's%'\"\n} {83 115}\ndo_test like-2.115.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 's%'\"\n} {83 115}\ndo_test like-2.115.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcs%'\"\n} {83 115}\ndo_test like-2.116.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 't%'\"\n} {84 116}\ndo_test like-2.116.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 't%'\"\n} {84 116}\ndo_test like-2.116.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abct%'\"\n} {84 116}\ndo_test like-2.117.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'u%'\"\n} {85 117}\ndo_test like-2.117.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'u%'\"\n} {85 117}\ndo_test like-2.117.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcu%'\"\n} {85 117}\ndo_test like-2.118.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'v%'\"\n} {86 118}\ndo_test like-2.118.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'v%'\"\n} {86 118}\ndo_test like-2.118.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcv%'\"\n} {86 118}\ndo_test like-2.119.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'w%'\"\n} {87 119}\ndo_test like-2.119.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'w%'\"\n} {87 119}\ndo_test like-2.119.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcw%'\"\n} {87 119}\ndo_test like-2.120.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'x%'\"\n} {88 120}\ndo_test like-2.120.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'x%'\"\n} {88 120}\ndo_test like-2.120.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcx%'\"\n} {88 120}\ndo_test like-2.121.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'y%'\"\n} {89 121}\ndo_test like-2.121.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'y%'\"\n} {89 121}\ndo_test like-2.121.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcy%'\"\n} {89 121}\ndo_test like-2.122.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE 'z%'\"\n} {90 122}\ndo_test like-2.122.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE 'z%'\"\n} {90 122}\ndo_test like-2.122.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abcz%'\"\n} {90 122}\ndo_test like-2.123.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\173%'\"\n} {123}\ndo_test like-2.123.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\173%'\"\n} {123}\ndo_test like-2.123.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\173%'\"\n} {123}\ndo_test like-2.124.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '|%'\"\n} {124}\ndo_test like-2.124.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '|%'\"\n} {124}\ndo_test like-2.124.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc|%'\"\n} {124}\ndo_test like-2.125.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '\\175%'\"\n} {125}\ndo_test like-2.125.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '\\175%'\"\n} {125}\ndo_test like-2.125.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc\\175%'\"\n} {125}\ndo_test like-2.126.1 {\n  db eval \"SELECT x FROM t1 WHERE y LIKE '~%'\"\n} {126}\ndo_test like-2.126.2 {\n  db eval \"SELECT x FROM t2 WHERE y LIKE '~%'\"\n} {126}\ndo_test like-2.126.3 {\n  db eval \"SELECT x FROM t3 WHERE y LIKE 'abc~%'\"\n} {126}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/like3.test",
    "content": "# 2015-03-06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIKE and GLOB operators and\n# in particular the optimizations that occur to help those operators\n# run faster and that those optimizations work correctly when there\n# are both strings and blobs being tested.\n#\n# Ticket 05f43be8fdda9fbd948d374319b99b054140bc36 shows that the following\n# SQL was not working correctly:\n#\n#     CREATE TABLE t1(x TEXT UNIQUE COLLATE nocase);\n#     INSERT INTO t1(x) VALUES(x'616263');\n#     SELECT 'query-1', x FROM t1 WHERE x LIKE 'a%';\n#     SELECT 'query-2', x FROM t1 WHERE +x LIKE 'a%';\n#\n# This script verifies that it works right now.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !like_match_blobs {\n  finish_test\n  return\n}\n\ndo_execsql_test like3-1.1 {\n  PRAGMA encoding=UTF8;\n  CREATE TABLE t1(a,b TEXT COLLATE nocase);\n  INSERT INTO t1(a,b)\n     VALUES(1,'abc'),\n           (2,'ABX'),\n           (3,'BCD'),\n           (4,x'616263'),\n           (5,x'414258'),\n           (6,x'424344');\n  CREATE INDEX t1ba ON t1(b,a);\n\n  SELECT a, b FROM t1 WHERE b LIKE 'aB%' ORDER BY +a;\n} {1 abc 2 ABX 4 abc 5 ABX}\ndo_execsql_test like3-1.2 {\n  SELECT a, b FROM t1 WHERE +b LIKE 'aB%' ORDER BY +a;\n} {1 abc 2 ABX 4 abc 5 ABX}\n\ndo_execsql_test like3-2.0 {\n  CREATE TABLE t2(a, b TEXT);\n  INSERT INTO t2 SELECT a, b FROM t1;\n  CREATE INDEX t2ba ON t2(b,a);\n  SELECT a, b FROM t2 WHERE b GLOB 'ab*' ORDER BY +a;\n} {1 abc 4 abc}\ndo_execsql_test like3-2.1 {\n  SELECT a, b FROM t2 WHERE +b GLOB 'ab*' ORDER BY +a;\n} {1 abc 4 abc}\ndo_execsql_test like3-2.2 {\n  SELECT a, b FROM t2 WHERE b>=x'6162' AND b GLOB 'ab*'\n} {4 abc}\ndo_execsql_test like3-2.3 {\n  SELECT a, b FROM t2 WHERE +b>=x'6162' AND +b GLOB 'ab*'\n} {4 abc}\ndo_execsql_test like3-2.4 {\n  SELECT a, b FROM t2 WHERE b GLOB 'ab*' AND b>=x'6162'\n} {4 abc}\ndo_execsql_test like3-2.5 {\n  SELECT a, b FROM t2 WHERE +b GLOB 'ab*' AND +b>=x'6162'\n} {4 abc}\n\ndo_execsql_test like3-3.0 {\n  CREATE TABLE t3(x TEXT PRIMARY KEY COLLATE nocase);\n  INSERT INTO t3(x) VALUES('aaa'),('abc'),('abd'),('abe'),('acz');\n  INSERT INTO t3(x) SELECT CAST(x AS blob) FROM t3;\n  SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\ndo_execsql_test like3-3.1 {\n  SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x DESC;\n} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}\ndo_execsql_test like3-3.1ck {\n  SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY +x DESC;\n} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}\ndo_execsql_test like3-3.2 {\n  SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY x ASC;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\ndo_execsql_test like3-3.2ck {\n  SELECT quote(x) FROM t3 WHERE x LIKE 'ab%' ORDER BY +x ASC;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\n\ndo_execsql_test like3-4.0 {\n  CREATE TABLE t4(x TEXT COLLATE nocase);\n  CREATE INDEX t4x ON t4(x DESC);\n  INSERT INTO t4(x) SELECT x FROM t3;\n  SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\ndo_execsql_test like3-4.1 {\n  SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x DESC;\n} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}\ndo_execsql_test like3-4.1ck {\n  SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY +x DESC;\n} {X'616265' X'616264' X'616263' 'abe' 'abd' 'abc'}\ndo_execsql_test like3-4.2 {\n  SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY x ASC;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\ndo_execsql_test like3-4.2ck {\n  SELECT quote(x) FROM t4 WHERE x LIKE 'ab%' ORDER BY +x ASC;\n} {'abc' 'abd' 'abe' X'616263' X'616264' X'616265'}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/limit.test",
    "content": "# 2001 November 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIMIT ... OFFSET ... clause\n#  of SELECT statements.\n#\n# $Id: limit.test,v 1.32 2008/08/02 03:50:39 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\nexecsql {\n  CREATE TABLE t1(x int, y int);\n  BEGIN;\n}\nfor {set i 1} {$i<=32} {incr i} {\n  for {set j 0} {(1<<$j)<$i} {incr j} {}\n  execsql \"INSERT INTO t1 VALUES([expr {32-$i}],[expr {10-$j}])\"\n}\nexecsql {\n  COMMIT;\n}\n\ndo_test limit-1.0 {\n  execsql {SELECT count(*) FROM t1}\n} {32}\ndo_test limit-1.1 {\n  execsql {SELECT count(*) FROM t1 LIMIT  5}\n} {32}\ndo_test limit-1.2.1 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 5}\n} {0 1 2 3 4}\ndo_test limit-1.2.2 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 5 OFFSET 2}\n} {2 3 4 5 6}\ndo_test limit-1.2.3 {\n  execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT 5 OFFSET -2}\n} {0 1 2 3 4}\ndo_test limit-1.2.4 {\n  execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT 2, -5}\n} {2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\ndo_test limit-1.2.5 {\n  execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT -2, 5}\n} {0 1 2 3 4}\ndo_test limit-1.2.6 {\n  execsql {SELECT x FROM t1 ORDER BY x+1 LIMIT -2, -5}\n} {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}\ndo_test limit-1.2.7 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 2, 5}\n} {2 3 4 5 6}\ndo_test limit-1.3 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 5 OFFSET 5}\n} {5 6 7 8 9}\ndo_test limit-1.4.1 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 30}\n} {30 31}\ndo_test limit-1.4.2 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 30, 50}\n} {30 31}\ndo_test limit-1.5 {\n  execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 50}\n} {}\ndo_test limit-1.6 {\n  execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5}\n} {0 5 0 5 0 5 1 5 0 5 2 5 0 5 3 5 0 5 4 5}\ndo_test limit-1.7 {\n  execsql {SELECT * FROM t1 AS a, t1 AS b ORDER BY a.x, b.x LIMIT 5 OFFSET 32}\n} {1 5 0 5 1 5 1 5 1 5 2 5 1 5 3 5 1 5 4 5}\n\nifcapable {view && subquery} {\n  do_test limit-2.1 {\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 2;\n      SELECT count(*) FROM (SELECT * FROM v1);\n    }\n  } 2\n} ;# ifcapable view\ndo_test limit-2.2 {\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 2;\n    SELECT count(*) FROM t2;\n  }\n} 2\nifcapable subquery {\n  do_test limit-2.3 {\n    execsql {\n      SELECT count(*) FROM t1 WHERE rowid IN (SELECT rowid FROM t1 LIMIT 2);\n    }\n  } 2\n}\n\nifcapable subquery {\n  do_test limit-3.1 {\n    execsql {\n      SELECT z FROM (SELECT y*10+x AS z FROM t1 ORDER BY x LIMIT 10)\n      ORDER BY z LIMIT 5;\n    }\n  } {50 51 52 53 54}\n}\n\ndo_test limit-4.1 {\n  ifcapable subquery { \n    execsql {\n      BEGIN;\n      CREATE TABLE t3(x);\n      INSERT INTO t3 SELECT x FROM t1 ORDER BY x LIMIT 10 OFFSET 1;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;\n      END;\n      SELECT count(*) FROM t3;\n    }\n  } else {\n    execsql {\n      BEGIN;\n      CREATE TABLE t3(x);\n      INSERT INTO t3 SELECT x FROM t1 ORDER BY x LIMIT 10 OFFSET 1;\n    }\n    for {set i 0} {$i<10} {incr i} {\n      set max_x_t3 [execsql {SELECT max(x) FROM t3}]\n      execsql \"INSERT INTO t3 SELECT x+$max_x_t3 FROM t3;\"\n    }\n    execsql {\n      END;\n      SELECT count(*) FROM t3;\n    }\n  }\n} {10240}\ndo_test limit-4.2 {\n  execsql {\n    SELECT x FROM t3 LIMIT 2 OFFSET 10000\n  }\n} {10001 10002}\ndo_test limit-4.3 {\n  execsql {\n    CREATE TABLE t4 AS SELECT x,\n       'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||\n       'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||\n       'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||\n       'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x ||\n       'abcdefghijklmnopqrstuvwyxz ABCDEFGHIJKLMNOPQRSTUVWYXZ' || x AS y\n    FROM t3 LIMIT 1000;\n    SELECT x FROM t4 ORDER BY y DESC LIMIT 1 OFFSET 999;\n  }\n} {1000}\n\ndo_test limit-5.1 {\n  execsql {\n    CREATE TABLE t5(x,y);\n    INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x BETWEEN 10 AND 15\n        ORDER BY x LIMIT 2;\n    SELECT * FROM t5 ORDER BY x;\n  }\n} {5 15 6 16}\ndo_test limit-5.2 {\n  execsql {\n    DELETE FROM t5;\n    INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x BETWEEN 10 AND 15\n        ORDER BY x DESC LIMIT 2;\n    SELECT * FROM t5 ORDER BY x;\n  }\n} {9 19 10 20}\ndo_test limit-5.3 {\n  execsql {\n    DELETE FROM t5;\n    INSERT INTO t5 SELECT x-y, x+y FROM t1 WHERE x ORDER BY x DESC LIMIT 31;\n    SELECT * FROM t5 ORDER BY x LIMIT 2;\n  }\n} {-4 6 -3 7}\ndo_test limit-5.4 {\n  execsql {\n    SELECT * FROM t5 ORDER BY x DESC, y DESC LIMIT 2;\n  }\n} {21 41 21 39}\ndo_test limit-5.5 {\n  execsql {\n    DELETE FROM t5;\n    INSERT INTO t5 SELECT a.x*100+b.x, a.y*100+b.y FROM t1 AS a, t1 AS b\n                   ORDER BY 1, 2 LIMIT 1000;\n    SELECT count(*), sum(x), sum(y), min(x), max(x), min(y), max(y) FROM t5;\n  }\n} {1000 1528204 593161 0 3107 505 1005}\n\n# There is some contraversy about whether LIMIT 0 should be the same as\n# no limit at all or if LIMIT 0 should result in zero output rows.\n#\ndo_test limit-6.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t6(a);\n    INSERT INTO t6 VALUES(1);\n    INSERT INTO t6 VALUES(2);\n    INSERT INTO t6 SELECT a+2 FROM t6;\n    COMMIT;\n    SELECT * FROM t6;\n  }\n} {1 2 3 4}\ndo_test limit-6.2 {\n  execsql {\n    SELECT * FROM t6 LIMIT -1 OFFSET -1;\n  }\n} {1 2 3 4}\ndo_test limit-6.3 {\n  execsql {\n    SELECT * FROM t6 LIMIT 2 OFFSET -123;\n  }\n} {1 2}\ndo_test limit-6.4 {\n  execsql {\n    SELECT * FROM t6 LIMIT -432 OFFSET 2;\n  }\n} {3 4}\ndo_test limit-6.5 {\n  execsql {\n    SELECT * FROM t6 LIMIT -1\n  }\n} {1 2 3 4}\ndo_test limit-6.6 {\n  execsql {\n    SELECT * FROM t6 LIMIT -1 OFFSET 1\n  }\n} {2 3 4}\ndo_test limit-6.7 {\n  execsql {\n    SELECT * FROM t6 LIMIT 0\n  }\n} {}\ndo_test limit-6.8 {\n  execsql {\n    SELECT * FROM t6 LIMIT 0 OFFSET 1\n  }\n} {}\n\n# Make sure LIMIT works well with compound SELECT statements.\n# Ticket #393\n#\n# EVIDENCE-OF: R-13512-64012 In a compound SELECT, only the last or\n# right-most simple SELECT may contain a LIMIT clause.\n#\n# EVIDENCE-OF: R-03782-50113 In a compound SELECT, the LIMIT clause\n# applies to the entire compound, not just the final SELECT.\n#\nifcapable compound {\ndo_test limit-7.1.1 {\n  catchsql {\n    SELECT x FROM t2 LIMIT 5 UNION ALL SELECT a FROM t6;\n  }\n} {1 {LIMIT clause should come after UNION ALL not before}}\ndo_test limit-7.1.2 {\n  catchsql {\n    SELECT x FROM t2 LIMIT 5 UNION SELECT a FROM t6;\n  }\n} {1 {LIMIT clause should come after UNION not before}}\ndo_test limit-7.1.3 {\n  catchsql {\n    SELECT x FROM t2 LIMIT 5 EXCEPT SELECT a FROM t6 LIMIT 3;\n  }\n} {1 {LIMIT clause should come after EXCEPT not before}}\ndo_test limit-7.1.4 {\n  catchsql {\n    SELECT x FROM t2 LIMIT 0,5 INTERSECT SELECT a FROM t6;\n  }\n} {1 {LIMIT clause should come after INTERSECT not before}}\ndo_test limit-7.2 {\n  execsql {\n    SELECT x FROM t2 UNION ALL SELECT a FROM t6 LIMIT 5;\n  }\n} {31 30 1 2 3}\ndo_test limit-7.3 {\n  execsql {\n    SELECT x FROM t2 UNION ALL SELECT a FROM t6 LIMIT 3 OFFSET 1;\n  }\n} {30 1 2}\ndo_test limit-7.4 {\n  execsql {\n    SELECT x FROM t2 UNION ALL SELECT a FROM t6 ORDER BY 1 LIMIT 3 OFFSET 1;\n  }\n} {2 3 4}\ndo_test limit-7.5 {\n  execsql {\n    SELECT x FROM t2 UNION SELECT x+2 FROM t2 LIMIT 2 OFFSET 1;\n  }\n} {31 32}\ndo_test limit-7.6 {\n  execsql {\n    SELECT x FROM t2 UNION SELECT x+2 FROM t2 ORDER BY 1 DESC LIMIT 2 OFFSET 1;\n  }\n} {32 31}\ndo_test limit-7.7 {\n  execsql {\n    SELECT a+9 FROM t6 EXCEPT SELECT y FROM t2 LIMIT 2;\n  }\n} {11 12}\ndo_test limit-7.8 {\n  execsql {\n    SELECT a+9 FROM t6 EXCEPT SELECT y FROM t2 ORDER BY 1 DESC LIMIT 2;\n  }\n} {13 12}\ndo_test limit-7.9 {\n  execsql {\n    SELECT a+26 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1;\n  }\n} {30}\ndo_test limit-7.10 {\n  execsql {\n    SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1;\n  }\n} {30}\ndo_test limit-7.11 {\n  execsql {\n    SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2 LIMIT 1 OFFSET 1;\n  }\n} {31}\ndo_test limit-7.12 {\n  execsql {\n    SELECT a+27 FROM t6 INTERSECT SELECT x FROM t2 \n       ORDER BY 1 DESC LIMIT 1 OFFSET 1;\n  }\n} {30}\n} ;# ifcapable compound\n\n# Tests for limit in conjunction with distinct.  The distinct should\n# occur before both the limit and the offset.  Ticket #749.\n#\ndo_test limit-8.1 {\n  execsql {\n    SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5;\n  }\n} {0 1 2 3 4}\ndo_test limit-8.2 {\n  execsql {\n    SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5 OFFSET 5;\n  }\n} {5 6 7 8 9}\ndo_test limit-8.3 {\n  execsql {\n    SELECT DISTINCT cast(round(x/100) as integer) FROM t3 LIMIT 5 OFFSET 25;\n  }\n} {25 26 27 28 29}\n\n# Make sure limits on multiple subqueries work correctly.\n# Ticket #1035\n#\nifcapable subquery {\n  do_test limit-9.1 {\n    execsql {\n      SELECT * FROM (SELECT * FROM t6 LIMIT 3);\n    }\n  } {1 2 3}\n}\ndo_test limit-9.2.1 {\n  execsql {\n    CREATE TABLE t7 AS SELECT * FROM t6;\n  }\n} {}\nifcapable subquery {\n  do_test limit-9.2.2 {\n    execsql {\n      SELECT * FROM (SELECT * FROM t7 LIMIT 3);\n    }\n  } {1 2 3}\n}\nifcapable compound {\n  ifcapable subquery {\n    do_test limit-9.3 {\n      execsql {\n        SELECT * FROM (SELECT * FROM t6 LIMIT 3)\n        UNION\n        SELECT * FROM (SELECT * FROM t7 LIMIT 3)\n        ORDER BY 1\n      }\n    } {1 2 3}\n    do_test limit-9.4 {\n      execsql {\n        SELECT * FROM (SELECT * FROM t6 LIMIT 3)\n        UNION\n        SELECT * FROM (SELECT * FROM t7 LIMIT 3)\n        ORDER BY 1\n        LIMIT 2\n      }\n    } {1 2}\n  }\n  do_test limit-9.5 {\n    catchsql {\n      SELECT * FROM t6 LIMIT 3\n      UNION\n      SELECT * FROM t7 LIMIT 3\n    }\n  } {1 {LIMIT clause should come after UNION not before}}\n}\n\n# Test LIMIT and OFFSET using SQL variables.\ndo_test limit-10.1 {\n  set limit 10\n  db eval {\n    SELECT x FROM t1 LIMIT :limit;\n  }\n} {31 30 29 28 27 26 25 24 23 22}\ndo_test limit-10.2 {\n  set limit 5\n  set offset 5\n  db eval {\n    SELECT x FROM t1 LIMIT :limit OFFSET :offset;\n  }\n} {26 25 24 23 22}\ndo_test limit-10.3 {\n  set limit -1\n  db eval {\n    SELECT x FROM t1 WHERE x<10 LIMIT :limit;\n  }\n} {9 8 7 6 5 4 3 2 1 0}\ndo_test limit-10.4 {\n  set limit 1.5\n  set rc [catch {\n  db eval {\n    SELECT x FROM t1 WHERE x<10 LIMIT :limit;\n  } } msg]\n  list $rc $msg\n} {1 {datatype mismatch}}\ndo_test limit-10.5 {\n  set limit \"hello world\"\n  set rc [catch {\n  db eval {\n    SELECT x FROM t1 WHERE x<10 LIMIT :limit;\n  } } msg]\n  list $rc $msg\n} {1 {datatype mismatch}}\n\nifcapable subquery {\ndo_test limit-11.1 {\n  db eval {\n     SELECT x FROM (SELECT x FROM t1 ORDER BY x LIMIT 0) ORDER BY x\n  }\n} {}\n} ;# ifcapable subquery\n\n# Test error processing.\n#\ndo_test limit-12.1 {\n  catchsql {\n     SELECT * FROM t1 LIMIT replace(1)\n  }\n} {1 {wrong number of arguments to function replace()}}\ndo_test limit-12.2 {\n  catchsql {\n     SELECT * FROM t1 LIMIT 5 OFFSET replace(1)\n  }\n} {1 {wrong number of arguments to function replace()}}\ndo_test limit-12.3 {\n  catchsql {\n     SELECT * FROM t1 LIMIT x\n  }\n} {1 {no such column: x}}\ndo_test limit-12.4 {\n  catchsql {\n     SELECT * FROM t1 LIMIT 1 OFFSET x\n  }\n} {1 {no such column: x}}\n\n# Ticket [db4d96798da8b]\n# LIMIT does not work with nested views containing UNION ALL \n#\ndo_test limit-13.1 {\n  db eval {\n    CREATE TABLE t13(x);\n    INSERT INTO t13 VALUES(1),(2);\n    CREATE VIEW v13a AS SELECT x AS y FROM t13;\n    CREATE VIEW v13b AS SELECT y AS z FROM v13a UNION ALL SELECT y+10 FROM v13a;\n    CREATE VIEW v13c AS SELECT z FROM v13b UNION ALL SELECT z+20 FROM v13b;\n  }\n} {}\ndo_test limit-13.2 {\n  db eval {SELECT z FROM v13c LIMIT 1}\n} {1}\ndo_test limit-13.3 {\n  db eval {SELECT z FROM v13c LIMIT 2}\n} {1 2}\ndo_test limit-13.4 {\n  db eval {SELECT z FROM v13c LIMIT 3}\n} {1 2 11}\ndo_test limit-13.5 {\n  db eval {SELECT z FROM v13c LIMIT 4}\n} {1 2 11 12}\ndo_test limit-13.6 {\n  db eval {SELECT z FROM v13c LIMIT 5}\n} {1 2 11 12 21}\ndo_test limit-13.7 {\n  db eval {SELECT z FROM v13c LIMIT 6}\n} {1 2 11 12 21 22}\ndo_test limit-13.8 {\n  db eval {SELECT z FROM v13c LIMIT 7}\n} {1 2 11 12 21 22 31}\ndo_test limit-13.9 {\n  db eval {SELECT z FROM v13c LIMIT 8}\n} {1 2 11 12 21 22 31 32}\ndo_test limit-13.10 {\n  db eval {SELECT z FROM v13c LIMIT 9}\n} {1 2 11 12 21 22 31 32}\ndo_test limit-13.11 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 1}\n} {2}\ndo_test limit-13.12 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 1}\n} {2 11}\ndo_test limit-13.13 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 1}\n} {2 11 12}\ndo_test limit-13.14 {\n  db eval {SELECT z FROM v13c LIMIT 4 OFFSET 1}\n} {2 11 12 21}\ndo_test limit-13.15 {\n  db eval {SELECT z FROM v13c LIMIT 5 OFFSET 1}\n} {2 11 12 21 22}\ndo_test limit-13.16 {\n  db eval {SELECT z FROM v13c LIMIT 6 OFFSET 1}\n} {2 11 12 21 22 31}\ndo_test limit-13.17 {\n  db eval {SELECT z FROM v13c LIMIT 7 OFFSET 1}\n} {2 11 12 21 22 31 32}\ndo_test limit-13.18 {\n  db eval {SELECT z FROM v13c LIMIT 8 OFFSET 1}\n} {2 11 12 21 22 31 32}\ndo_test limit-13.21 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 2}\n} {11}\ndo_test limit-13.22 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 2}\n} {11 12}\ndo_test limit-13.23 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 2}\n} {11 12 21}\ndo_test limit-13.24 {\n  db eval {SELECT z FROM v13c LIMIT 4 OFFSET 2}\n} {11 12 21 22}\ndo_test limit-13.25 {\n  db eval {SELECT z FROM v13c LIMIT 5 OFFSET 2}\n} {11 12 21 22 31}\ndo_test limit-13.26 {\n  db eval {SELECT z FROM v13c LIMIT 6 OFFSET 2}\n} {11 12 21 22 31 32}\ndo_test limit-13.27 {\n  db eval {SELECT z FROM v13c LIMIT 7 OFFSET 2}\n} {11 12 21 22 31 32}\ndo_test limit-13.31 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 3}\n} {12}\ndo_test limit-13.32 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 3}\n} {12 21}\ndo_test limit-13.33 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 3}\n} {12 21 22}\ndo_test limit-13.34 {\n  db eval {SELECT z FROM v13c LIMIT 4 OFFSET 3}\n} {12 21 22 31}\ndo_test limit-13.35 {\n  db eval {SELECT z FROM v13c LIMIT 5 OFFSET 3}\n} {12 21 22 31 32}\ndo_test limit-13.36 {\n  db eval {SELECT z FROM v13c LIMIT 6 OFFSET 3}\n} {12 21 22 31 32}\ndo_test limit-13.41 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 4}\n} {21}\ndo_test limit-13.42 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 4}\n} {21 22}\ndo_test limit-13.43 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 4}\n} {21 22 31}\ndo_test limit-13.44 {\n  db eval {SELECT z FROM v13c LIMIT 4 OFFSET 4}\n} {21 22 31 32}\ndo_test limit-13.45 {\n  db eval {SELECT z FROM v13c LIMIT 5 OFFSET 4}\n} {21 22 31 32}\ndo_test limit-13.51 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 5}\n} {22}\ndo_test limit-13.52 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 5}\n} {22 31}\ndo_test limit-13.53 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 5}\n} {22 31 32}\ndo_test limit-13.54 {\n  db eval {SELECT z FROM v13c LIMIT 4 OFFSET 5}\n} {22 31 32}\ndo_test limit-13.61 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 6}\n} {31}\ndo_test limit-13.62 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 6}\n} {31 32}\ndo_test limit-13.63 {\n  db eval {SELECT z FROM v13c LIMIT 3 OFFSET 6}\n} {31 32}\ndo_test limit-13.71 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 7}\n} {32}\ndo_test limit-13.72 {\n  db eval {SELECT z FROM v13c LIMIT 2 OFFSET 7}\n} {32}\ndo_test limit-13.81 {\n  db eval {SELECT z FROM v13c LIMIT 1 OFFSET 8}\n} {}\n\ndo_execsql_test limit-14.1 {\n  SELECT 123 LIMIT 1 OFFSET 0\n} {123}\ndo_execsql_test limit-14.2 {\n  SELECT 123 LIMIT 1 OFFSET 1\n} {}\ndo_execsql_test limit-14.3 {\n  SELECT 123 LIMIT 0 OFFSET 0\n} {}\ndo_execsql_test limit-14.4 {\n  SELECT 123 LIMIT 0 OFFSET 1\n} {}\ndo_execsql_test limit-14.6 {\n  SELECT 123 LIMIT -1 OFFSET 0\n} {123}\ndo_execsql_test limit-14.7 {\n  SELECT 123 LIMIT -1 OFFSET 1\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/limit2.test",
    "content": "# 2016-05-20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIMIT in combination with ORDER BY\n# and in particular, the optimizations in the inner loop that cause an\n# early exit of the inner loop when the LIMIT is reached and the inner\n# loop is emitting rows in ORDER BY order.\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix limit2\n\ndo_execsql_test limit2-100 {\n  CREATE TABLE t1(a,b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n    INSERT INTO t1(a,b) SELECT 1, (x*17)%1000 + 1000 FROM c;\n  INSERT INTO t1(a,b) VALUES(2,2),(3,1006),(4,4),(5,9999);\n  CREATE INDEX t1ab ON t1(a,b);\n}\nset sqlite_search_count 0\ndo_execsql_test limit2-100.1 {\n  SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b LIMIT 5;\n} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}\nset fast_count $sqlite_search_count\nset sqlite_search_count 0\ndo_execsql_test limit2-100.2 {\n  SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b LIMIT 5;\n} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}\ndo_test limit2-100.3 {\n  set slow_count $sqlite_search_count\n  expr {$fast_count < 0.02*$slow_count}\n} {1}\n\ndo_execsql_test limit2-110 {\n  CREATE TABLE t2(x,y);\n  INSERT INTO t2(x,y) VALUES('a',1),('a',2),('a',3),('a',4);\n  INSERT INTO t2(x,y) VALUES('b',1),('c',2),('d',3),('e',4);\n  CREATE INDEX t2xy ON t2(x,y);\n}\nset sqlite_search_count 0\ndo_execsql_test limit2-110.1 {\n  SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY t1.b LIMIT 5;\n} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}\nset fast_count $sqlite_search_count\nset sqlite_search_count 0\ndo_execsql_test limit2-110.2 {\n  SELECT a, b, '|' FROM t2, t1 WHERE t2.x='a' AND t1.a=t2.y ORDER BY +t1.b LIMIT 5;\n} {2 2 | 4 4 | 1 1000 | 1 1001 | 1 1002 |}\nset slow_count $sqlite_search_count\ndo_test limit2-110.3 {\n  expr {$fast_count < 0.02*$slow_count}\n} {1}\n\ndo_execsql_test limit2-120 {\n  DROP INDEX t1ab;\n  CREATE INDEX t1ab ON t1(a,b DESC);\n}\nset sqlite_search_count 0\ndo_execsql_test limit2-120.1 {\n  SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY b DESC LIMIT 5;\n} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |}\nset fast_count $sqlite_search_count\nset sqlite_search_count 0\ndo_execsql_test limit2-120.2 {\n  SELECT a, b, '|' FROM t1 WHERE a IN (2,4,5,3,1) ORDER BY +b DESC LIMIT 5;\n} {5 9999 | 1 1999 | 1 1998 | 1 1997 | 1 1996 |}\ndo_test limit2-120.3 {\n  set slow_count $sqlite_search_count\n  expr {$fast_count < 0.02*$slow_count}\n} {1}\n\n# Bug report against the new ORDER BY LIMIT optimization just prior to\n# release.  (Unreleased so there is no ticket).\n#\n# Make sure the optimization is not applied if the inner loop can only\n# provide a single row of output.\n#\ndo_execsql_test limit2-200 {\n  CREATE TABLE t200(a, b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n    INSERT INTO t200(a,b) SELECT x, x FROM c;\n  CREATE TABLE t201(x INTEGER PRIMARY KEY, y);\n  INSERT INTO t201(x,y) VALUES(2,12345);\n\n  SELECT *, '|' FROM t200, t201 WHERE x=b ORDER BY y LIMIT 3;\n} {2 2 2 12345 |}\ndo_execsql_test limit2-210 {\n  SELECT *, '|' FROM t200 LEFT JOIN t201 ON x=b ORDER BY y LIMIT 3;\n} {1 1 {} {} | 3 3 {} {} | 4 4 {} {} |}\n\n# Bug in the ORDER BY LIMIT optimization reported on 2016-09-06.\n# Ticket https://www.sqlite.org/src/info/559733b09e96\n#\ndo_execsql_test limit2-300 {\n  CREATE TABLE t300(a,b,c);\n  CREATE INDEX t300x ON t300(a,b,c);\n  INSERT INTO t300 VALUES(0,1,99),(0,1,0),(0,0,0);\n  SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC;\n} {0 1 99 . 0 0 0 . 0 1 0 .}\ndo_execsql_test limit2-310 {\n  SELECT *,'.' FROM t300 WHERE a=0 AND (c=0 OR c=99) ORDER BY c DESC LIMIT 1;\n} {0 1 99 .}\n\n# Make sure the SELECT loop is ordered correctly for the direction of\n# the ORDER BY\n#\ndo_execsql_test limit2-400 {\n  CREATE TABLE t400(a,b);\n  CREATE INDEX t400_ab ON t400(a,b);\n  INSERT INTO t400(a,b) VALUES(1,90),(1,40),(2,80),(2,30),(3,70),(3,20);\n  SELECT *,'x' FROM t400 WHERE a IN (1,2,3) ORDER BY b DESC LIMIT 3;\n  SELECT *,'y' FROM t400 WHERE a IN (1,2,3) ORDER BY +b DESC LIMIT 3;\n} {1 90 x 2 80 x 3 70 x 1 90 y 2 80 y 3 70 y}\n\n\ndo_execsql_test 500 {\n  CREATE TABLE t500(i INTEGER PRIMARY KEY, j);\n  INSERT INTO t500 VALUES(1, 1);\n  INSERT INTO t500 VALUES(2, 2);\n  INSERT INTO t500 VALUES(3, 3);\n  INSERT INTO t500 VALUES(4, 0);\n  INSERT INTO t500 VALUES(5, 5);\n  SELECT j FROM t500 WHERE i IN (1,2,3,4,5) ORDER BY j DESC LIMIT 3;\n} {5 3 2}\ndo_execsql_test 501 {\n  CREATE TABLE t501(i INTEGER PRIMARY KEY, j);\n  INSERT INTO t501 VALUES(1, 5);\n  INSERT INTO t501 VALUES(2, 4);\n  INSERT INTO t501 VALUES(3, 3);\n  INSERT INTO t501 VALUES(4, 6);\n  INSERT INTO t501 VALUES(5, 1);\n  SELECT j FROM t501 WHERE i IN (1,2,3,4,5) ORDER BY j LIMIT 3;\n} {1 3 4}\ndo_execsql_test 502 {\n  CREATE TABLE t502(i INT PRIMARY KEY, j);\n  INSERT INTO t502 VALUES(1, 5);\n  INSERT INTO t502 VALUES(2, 4);\n  INSERT INTO t502 VALUES(3, 3);\n  INSERT INTO t502 VALUES(4, 6);\n  INSERT INTO t502 VALUES(5, 1);\n  SELECT j FROM t502 WHERE i IN (1,2,3,4,5) ORDER BY j LIMIT 3;\n} {1 3 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/loadext.test",
    "content": "# 2006 July 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is extension loading.\n#\n# $Id: loadext.test,v 1.17 2009/03/20 09:09:37 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !load_ext {\n  finish_test\n  return\n}\n\n# The name of the test extension varies by operating system.\n#\nif {$::tcl_platform(platform) eq \"windows\"} {\n  set testextension ./testloadext.dll\n} else {\n  set testextension ./libtestloadext.so\n}\nset gcc_shared \"-shared -fPIC\"\nif {$::tcl_platform(os) eq \"Darwin\"} {\n  set gcc_shared -dynamiclib\n}\n\n# The error messages tested by this file are operating system dependent\n# (because they are returned by sqlite3OsDlError()). For now, they only\n# work with UNIX (and probably only certain kinds of UNIX).\n#\n# When a shared-object cannot be opened because it does not exist, the\n# format of the message returned is:\n#\n#      [format $dlerror_nosuchfile <shared-object-name>]\n#\n# When a shared-object cannot be opened because it consists of the 4\n# characters \"blah\" only, we expect the error message to be:\n#\n#      [format $dlerror_notadll <shared-object-name>]\n#\n# When a symbol cannot be found within an open shared-object, the error\n# message should be:\n#\n#      [format $dlerror_nosymbol <shared-object-name> <symbol-name>]\n#\n# The exact error messages are not important. The important bit is\n# that SQLite is correctly copying the message from xDlError().\n#\nset dlerror_nosuchfile \\\n    {%s: cannot open shared object file: No such file or directory}\nset dlerror_notadll    {%s: file too short}\nset dlerror_nosymbol   {%s: undefined symbol: %s}\n\nif {$::tcl_platform(os) eq \"Darwin\"} {\n  set dlerror_nosuchfile {dlopen(%s, 10): image not found}\n  set dlerror_notadll    {dlopen(%1$s, 10): no suitable image found.*}\n  set dlerror_nosymbol   {dlsym(XXX, %2$s): symbol not found}\n}\n\nif {$::tcl_platform(platform) eq \"windows\"} {\n  set dlerror_nosuchfile {The specified module could not be found.*}\n  set dlerror_notadll    {%%1 is not a valid Win32 application.*}\n  set dlerror_nosymbol   {The specified procedure could not be found.*}\n}\n\n# Make sure the test extension actually exists.  If it does not\n# exist, try to create it.  If unable to create it, then skip this\n# test file.\n#\nif {![file exists $testextension]} {\n  set srcdir [file dir $testdir]/src\n  set testextsrc $srcdir/test_loadext.c\n\n  set cmdline [concat exec gcc $gcc_shared]\n  lappend cmdline -Wall -I$srcdir -I. -I.. -g $testextsrc -o $testextension\n  \n  if {[catch $cmdline msg]} {\n    puts \"Skipping loadext tests: Test extension not built...\"\n    puts $msg\n    finish_test\n    return\n  }\n}\n\n# Test that loading the extension produces the expected results - adding\n# the half() function to the specified database handle.\n#\ndo_test loadext-1.1 {\n  catchsql {\n    SELECT half(1.0);\n  }\n} {1 {no such function: half}}\ndo_test loadext-1.2 {\n  db enable_load_extension 1\n  sqlite3_load_extension db $testextension testloadext_init\n  catchsql {\n    SELECT half(1.0);\n  }\n} {0 0.5}\n\n# Test that a second database connection (db2) can load the extension also.\n#\ndo_test loadext-1.3 {\n  sqlite3 db2 test.db\n  sqlite3_db_config db2 SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1\n  catchsql {\n    SELECT half(1.0);\n  } db2\n} {1 {no such function: half}}\ndo_test loadext-1.4 {\n  sqlite3_load_extension db2 $testextension testloadext_init\n  catchsql {\n    SELECT half(1.0);\n  } db2\n} {0 0.5}\n\n# Close the first database connection. Then check that the second database\n# can still use the half() function without a problem.\n#\ndo_test loadext-1.5 {\n  db close\n  catchsql {\n    SELECT half(1.0);\n  } db2\n} {0 0.5}\n\ndb2 close\nsqlite3 db test.db\nsqlite3_enable_load_extension db 1\n\n# Try to load an extension for which the file does not exist.\n#\ndo_test loadext-2.1 {\n  forcedelete ${testextension}xx\n  set rc [catch {\n    sqlite3_load_extension db \"${testextension}xx\"\n  } msg]\n  list $rc $msg\n} /[list 1 [format $dlerror_nosuchfile ${testextension}xx.*]]/\n\n# Try to load an extension for which the file is not a shared object\n#\ndo_test loadext-2.2 {\n  set fd [open \"./notasharedlib.so\" w]\n  puts $fd blah\n  close $fd\n  set fd [open \"./notasharedlib.dll\" w]\n  puts $fd blah\n  close $fd\n  set rc [catch {\n    sqlite3_load_extension db \"./notasharedlib\"\n  } msg]\n  list $rc $msg\n} /[list 1 [format $dlerror_notadll ./notasharedlib.*]]/\n\n# Try to load an extension for which the file is present but the\n# entry point is not.\n#\ndo_test loadext-2.3 {\n  set rc [catch {\n    sqlite3_load_extension db $testextension icecream\n  } msg]\n  if {$::tcl_platform(os) eq \"Darwin\"} {\n    regsub {0x[1234567890abcdefABCDEF]*} $msg XXX msg\n  }\n  list $rc $msg\n} /[list 1 [format $dlerror_nosymbol $testextension icecream]]/\n\n# Try to load an extension for which the entry point fails (returns non-zero) \n#\ndo_test loadext-2.4 {\n  set rc [catch {\n    sqlite3_load_extension db $testextension testbrokenext_init\n  } msg]\n  list $rc $msg\n} {1 {error during initialization: broken!}}\n\n############################################################################\n# Tests for the load_extension() SQL function\n#\n\ndb close\nsqlite3 db test.db\nsqlite3_enable_load_extension db 1\ndo_test loadext-3.1 {\n  catchsql {\n    SELECT half(5);\n  }\n} {1 {no such function: half}}\ndo_test loadext-3.2 {\n  set res [catchsql {\n    SELECT load_extension($::testextension)\n  }]\n  if {$::tcl_platform(os) eq \"Darwin\"} {\n    regsub {0x[1234567890abcdefABCDEF]*} $res XXX res\n  }\n  set res\n} /[list 1 [format $dlerror_nosymbol $testextension sqlite3_.*_init]]/\ndo_test loadext-3.3 {\n  catchsql {\n    SELECT load_extension($::testextension,'testloadext_init')\n  }\n} {0 {{}}}\ndo_test loadext-3.4 {\n  catchsql {\n    SELECT half(5);\n  }\n} {0 2.5}\ndo_test loadext-3.5 {\n  db eval {\n    SELECT sqlite3_status('MEMORY_USED') AS mused\n  } break\n  puts -nonewline \" (memory_used=$mused) \"\n  expr {$mused>0}\n} {1}\ndo_test loadext-3.6 {\n  catchsql {\n    SELECT sqlite3_status('MEMORY_USED_X') AS mused\n  }\n} {1 {unknown status property: MEMORY_USED_X}}\ndo_test loadext-3.7 {\n  catchsql {\n    SELECT sqlite3_status(4.53) AS mused\n  }\n} {1 {unknown status type}}\ndo_test loadext-3.8 {\n  catchsql {\n    SELECT sqlite3_status(23) AS mused\n  }\n} {1 {sqlite3_status(23,...) returns 21}}\n\n# Ticket #1863\n# Make sure the extension loading mechanism will not work unless it\n# is explicitly enabled.\n#\ndb close\nsqlite3 db test.db\ndo_test loadext-4.1 {\n  catchsql {\n    SELECT load_extension($::testextension,'testloadext_init')\n  }\n} {1 {not authorized}}\ndo_test loadext-4.2 {\n  sqlite3_enable_load_extension db 1\n  catchsql {\n    SELECT load_extension($::testextension,'testloadext_init')\n  }\n} {0 {{}}}\n\n# disable all extension loading\ndo_test loadext-4.3 {\n  sqlite3_enable_load_extension db 0\n  catchsql {\n    SELECT load_extension($::testextension,'testloadext_init')\n  }\n} {1 {not authorized}}\n\n# enable C-api extension loading only.  Show that the SQL function\n# still does not work.\ndo_test loadext-4.4 {\n  sqlite3_db_config db SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1\n  catchsql {\n    SELECT load_extension($::testextension,'testloadext_init')\n  }\n} {1 {not authorized}}\n\nsource $testdir/malloc_common.tcl\n\n\n# Malloc failure in sqlite3_auto_extension and sqlite3_load_extension\n#\ndo_malloc_test loadext-5 -tclprep {\n  sqlite3_reset_auto_extension\n} -tclbody {\n  if {[autoinstall_test_functions]==7} {error \"out of memory\"}\n}\n\n# On Windows, this malloc test must be skipped because the winDlOpen\n# function itself can fail due to \"out of memory\" conditions.\n#\nif {$::tcl_platform(platform) ne \"windows\"} {\n  do_malloc_test loadext-6 -tclbody {\n    db enable_load_extension 1\n    sqlite3_load_extension db $::testextension testloadext_init\n  }\n}\n\nautoinstall_test_functions\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/loadext2.test",
    "content": "# 2006 August 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is automatic extension loading and the\n# sqlite3_auto_extension() API.\n#\n# $Id: loadext2.test,v 1.3 2008/03/19 16:08:54 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Only run these tests if the approriate APIs are defined\n# in the system under test.\n#\nifcapable !load_ext {\n  finish_test\n  return\n}\nif {[info command sqlite3_auto_extension_sqr]==\"\"} {\n  finish_test\n  return\n}\n\n\n# None of the extension are loaded by default.\n#\ndo_test loadext2-1.1 {\n  catchsql {\n    SELECT sqr(2)\n  }\n} {1 {no such function: sqr}}\ndo_test loadext2-1.2 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {1 {no such function: cube}}\n\n# Extensions loaders not currently registered\n#\ndo_test loadext2-1.2.1 {\n  sqlite3_cancel_auto_extension_sqr\n} {0}\ndo_test loadext2-1.2.2 {\n  sqlite3_cancel_auto_extension_sqr\n} {0}\ndo_test loadext2-1.2.3 {\n  sqlite3_cancel_auto_extension_sqr\n} {0}\n\n\n# Register auto-loaders.  Still functions do not exist.\n#\ndo_test loadext2-1.3 {\n  sqlite3_auto_extension_sqr\n  sqlite3_auto_extension_cube\n  catchsql {\n    SELECT sqr(2)\n  }\n} {1 {no such function: sqr}}\ndo_test loadext2-1.4 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {1 {no such function: cube}}\n\n\n# Functions do exist in a new database connection\n#\ndo_test loadext2-1.5 {\n  sqlite3 db test.db\n  catchsql {\n    SELECT sqr(2)\n  }\n} {0 4.0}\ndo_test loadext2-1.6 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {0 8.0}\n\n\n# Reset extension auto loading.  Existing extensions still exist.\n#\ndo_test loadext2-1.7.1 {\n  sqlite3_cancel_auto_extension_sqr\n} {1}\ndo_test loadext2-1.7.2 {\n  sqlite3_cancel_auto_extension_sqr\n} {0}\ndo_test loadext2-1.7.3 {\n  sqlite3_cancel_auto_extension_cube\n} {1}\ndo_test loadext2-1.7.4 {\n  sqlite3_cancel_auto_extension_cube\n} {0}\ndo_test loadext2-1.7.5 {\n  catchsql {\n    SELECT sqr(2)\n  }\n} {0 4.0}\ndo_test loadext2-1.8 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {0 8.0}\n\n\n# Register only the sqr() function.\n#\ndo_test loadext2-1.9 {\n  sqlite3_auto_extension_sqr\n  sqlite3 db test.db\n  catchsql {\n    SELECT sqr(2)\n  }\n} {0 4.0}\ndo_test loadext2-1.10 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {1 {no such function: cube}}\n\n# Register only the cube() function.\n#\ndo_test loadext2-1.11 {\n  sqlite3_reset_auto_extension\n  sqlite3_auto_extension_cube\n  sqlite3 db test.db\n  catchsql {\n    SELECT sqr(2)\n  }\n} {1 {no such function: sqr}}\ndo_test loadext2-1.12 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {0 8.0}\n\n# Register a broken entry point.\n#\ndo_test loadext2-1.13 {\n  sqlite3_auto_extension_broken\n  set rc [catch {sqlite3 db test.db} errmsg]\n  lappend rc $errmsg\n} {1 {automatic extension loading failed: broken autoext!}}\ndo_test loadext2-1.14 {\n  catchsql {\n    SELECT sqr(2)\n  }\n} {1 {no such function: sqr}}\ndo_test loadext2-1.15 {\n  catchsql {\n    SELECT cube(2)\n  }\n} {0 8.0}\n\n\nsqlite3_reset_auto_extension\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks.\n#\n# $Id: lock.test,v 1.40 2009/06/16 17:49:36 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create an alternative connection to the database\n#\ndo_test lock-1.0 {\n  # Give a complex pathname to stress the path simplification logic in\n  # the vxworks driver and in test_async.\n  file mkdir tempdir/t1/t2\n  sqlite3 db2 ./tempdir/../tempdir/t1/.//t2/../../..//test.db\n  set dummy {}\n} {}\ndo_test lock-1.1 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test lock-1.2 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name} db2\n} {}\ndo_test lock-1.3 {\n  execsql {CREATE TABLE t1(a int, b int)}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {t1}\ndo_test lock-1.5 {\n  catchsql {\n     SELECT name FROM sqlite_master WHERE type='table' ORDER BY name\n  } db2\n} {0 t1}\n\ndo_test lock-1.6 {\n  execsql {INSERT INTO t1 VALUES(1,2)}\n  execsql {SELECT * FROM t1}\n} {1 2}\n# Update: The schema is now brought up to date by test lock-1.5.\n# do_test lock-1.7.1 {\n#   catchsql {SELECT * FROM t1} db2\n# } {1 {no such table: t1}}\ndo_test lock-1.7.2 {\n  catchsql {SELECT * FROM t1} db2\n} {0 {1 2}}\ndo_test lock-1.8 {\n  execsql {UPDATE t1 SET a=b, b=a} db2\n  execsql {SELECT * FROM t1} db2\n} {2 1}\ndo_test lock-1.9 {\n  execsql {SELECT * FROM t1}\n} {2 1}\ndo_test lock-1.10 {\n  execsql {BEGIN TRANSACTION}\n  execsql {UPDATE t1 SET a = 0 WHERE 0}\n  execsql {SELECT * FROM t1}\n} {2 1}\ndo_test lock-1.11 {\n  catchsql {SELECT * FROM t1} db2\n} {0 {2 1}}\ndo_test lock-1.12 {\n  execsql {ROLLBACK}\n  catchsql {SELECT * FROM t1}\n} {0 {2 1}}\n\ndo_test lock-1.13 {\n  execsql {CREATE TABLE t2(x int, y int)}\n  execsql {INSERT INTO t2 VALUES(8,9)}\n  execsql {SELECT * FROM t2}\n} {8 9}\ndo_test lock-1.14.1 {\n  catchsql {SELECT * FROM t2} db2\n} {0 {8 9}}\ndo_test lock-1.14.2 {\n  catchsql {SELECT * FROM t1} db2\n} {0 {2 1}}\ndo_test lock-1.15 {\n  catchsql {SELECT * FROM t2} db2\n} {0 {8 9}}\n\ndo_test lock-1.16 {\n  db eval {SELECT * FROM t1} qv {\n    set x [db eval {SELECT * FROM t1}]\n  }\n  set x\n} {2 1}\ndo_test lock-1.17 {\n  db eval {SELECT * FROM t1} qv {\n    set x [db eval {SELECT * FROM t2}]\n  }\n  set x\n} {8 9}\n\n# You cannot UPDATE a table from within the callback of a SELECT\n# on that same table because the SELECT has the table locked.\n#\n# 2006-08-16:  Reads no longer block writes within the same\n# database connection.\n#\n#do_test lock-1.18 {\n#  db eval {SELECT * FROM t1} qv {\n#    set r [catch {db eval {UPDATE t1 SET a=b, b=a}} msg]\n#    lappend r $msg\n#  }\n#  set r\n#} {1 {database table is locked}}\n\n# But you can UPDATE a different table from the one that is used in\n# the SELECT.\n#\ndo_test lock-1.19 {\n  db eval {SELECT * FROM t1} qv {\n    set r [catch {db eval {UPDATE t2 SET x=y, y=x}} msg]\n    lappend r $msg\n  }\n  set r\n} {0 {}}\ndo_test lock-1.20 {\n  execsql {SELECT * FROM t2}\n} {9 8}\n\n# It is possible to do a SELECT of the same table within the\n# callback of another SELECT on that same table because two\n# or more read-only cursors can be open at once.\n#\ndo_test lock-1.21 {\n  db eval {SELECT * FROM t1} qv {\n    set r [catch {db eval {SELECT a FROM t1}} msg]\n    lappend r $msg\n  }\n  set r\n} {0 2}\n\n# Under UNIX you can do two SELECTs at once with different database\n# connections, because UNIX supports reader/writer locks.  Under windows,\n# this is not possible.\n#\nif {$::tcl_platform(platform)==\"unix\"} {\n  do_test lock-1.22 {\n    db eval {SELECT * FROM t1} qv {\n      set r [catch {db2 eval {SELECT a FROM t1}} msg]\n      lappend r $msg\n    }\n    set r\n  } {0 2}\n}\nintegrity_check lock-1.23\n\n# If one thread has a transaction another thread cannot start\n# a transaction.  -> Not true in version 3.0.  But if one thread\n# as a RESERVED lock another thread cannot acquire one.\n#\ndo_test lock-2.1 {\n  execsql {BEGIN TRANSACTION}\n  execsql {UPDATE t1 SET a = 0 WHERE 0}\n  execsql {BEGIN TRANSACTION} db2\n  set r [catch {execsql {UPDATE t1 SET a = 0 WHERE 0} db2} msg]\n  execsql {ROLLBACK} db2\n  lappend r $msg\n} {1 {database is locked}}\n\n# A thread can read when another has a RESERVED lock.\n#\ndo_test lock-2.2 {\n  catchsql {SELECT * FROM t2} db2\n} {0 {9 8}}\n\n# If the other thread (the one that does not hold the transaction with\n# a RESERVED lock) tries to get a RESERVED lock, we do get a busy callback\n# as long as we were not orginally holding a READ lock.\n#\ndo_test lock-2.3.1 {\n  proc callback {count} {\n    set ::callback_value $count\n    break\n  }\n  set ::callback_value {}\n  db2 busy callback\n  # db2 does not hold a lock so we should get a busy callback here\n  set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]\n  lappend r $msg\n  lappend r $::callback_value\n} {1 {database is locked} 0}\ndo_test lock-2.3.2 {\n  set ::callback_value {}\n  execsql {BEGIN; SELECT rowid FROM sqlite_master LIMIT 1} db2\n  # This time db2 does hold a read lock.  No busy callback this time.\n  set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]\n  lappend r $msg\n  lappend r $::callback_value\n} {1 {database is locked} {}}\ncatch {execsql {ROLLBACK} db2}\ndo_test lock-2.4.1 {\n  proc callback {count} {\n    lappend ::callback_value $count\n    if {$count>4} break\n  }\n  set ::callback_value {}\n  db2 busy callback\n  # We get a busy callback because db2 is not holding a lock\n  set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]\n  lappend r $msg\n  lappend r $::callback_value\n} {1 {database is locked} {0 1 2 3 4 5}}\ndo_test lock-2.4.2 {\n  proc callback {count} {\n    lappend ::callback_value $count\n    if {$count>4} break\n  }\n  set ::callback_value {}\n  db2 busy callback\n  execsql {BEGIN; SELECT rowid FROM sqlite_master LIMIT 1} db2\n  # No busy callback this time because we are holding a lock\n  set r [catch {execsql {UPDATE t1 SET a=b, b=a} db2} msg]\n  lappend r $msg\n  lappend r $::callback_value\n} {1 {database is locked} {}}\ncatch {execsql {ROLLBACK} db2}\ndo_test lock-2.5 {\n  proc callback {count} {\n    lappend ::callback_value $count\n    if {$count>4} break\n  }\n  set ::callback_value {}\n  db2 busy callback\n  set r [catch {execsql {SELECT * FROM t1} db2} msg]\n  lappend r $msg\n  lappend r $::callback_value\n} {0 {2 1} {}}\nexecsql {ROLLBACK}\n\n# Test the built-in busy timeout handler\n#\n# EVIDENCE-OF: R-23579-05241 PRAGMA busy_timeout; PRAGMA busy_timeout =\n# milliseconds; Query or change the setting of the busy timeout.\n#\ndo_test lock-2.8 {\n  db2 timeout 400\n  execsql BEGIN\n  execsql {UPDATE t1 SET a = 0 WHERE 0}\n  catchsql {BEGIN EXCLUSIVE;} db2\n} {1 {database is locked}}\ndo_test lock-2.8b {\n  db2 eval {PRAGMA busy_timeout}\n} {400}\ndo_test lock-2.9 {\n  db2 timeout 0\n  execsql COMMIT\n} {}\ndo_test lock-2.9b {\n  db2 eval {PRAGMA busy_timeout}\n} {0}\nintegrity_check lock-2.10\ndo_test lock-2.11 {\n  db2 eval {PRAGMA busy_timeout(400)}\n  execsql BEGIN\n  execsql {UPDATE t1 SET a = 0 WHERE 0}\n  catchsql {BEGIN EXCLUSIVE;} db2\n} {1 {database is locked}}\ndo_test lock-2.11b {\n  db2 eval {PRAGMA busy_timeout}\n} {400}\ndo_test lock-2.12 {\n  db2 eval {PRAGMA busy_timeout(0)}\n  execsql COMMIT\n} {}\ndo_test lock-2.12b {\n  db2 eval {PRAGMA busy_timeout}\n} {0}\nintegrity_check lock-2.13\n\n# Try to start two transactions in a row\n#\ndo_test lock-3.1 {\n  execsql {BEGIN TRANSACTION}\n  set r [catch {execsql {BEGIN TRANSACTION}} msg]\n  execsql {ROLLBACK}\n  lappend r $msg\n} {1 {cannot start a transaction within a transaction}}\nintegrity_check lock-3.2\n\n# Make sure the busy handler and error messages work when\n# opening a new pointer to the database while another pointer\n# has the database locked.\n#\ndo_test lock-4.1 {\n  db2 close\n  catch {db eval ROLLBACK}\n  db eval BEGIN\n  db eval {UPDATE t1 SET a=0 WHERE 0}\n  sqlite3 db2 ./test.db\n  catchsql {UPDATE t1 SET a=0} db2\n} {1 {database is locked}}\ndo_test lock-4.2 {\n  set ::callback_value {}\n  set rc [catch {db2 eval {UPDATE t1 SET a=0}} msg]\n  lappend rc $msg $::callback_value\n} {1 {database is locked} {}}\ndo_test lock-4.3 {\n  proc callback {count} {\n    lappend ::callback_value $count\n    if {$count>4} break\n  }\n  db2 busy callback\n  set rc [catch {db2 eval {UPDATE t1 SET a=0}} msg]\n  lappend rc $msg $::callback_value\n} {1 {database is locked} {0 1 2 3 4 5}}\nexecsql {ROLLBACK}\n\n# When one thread is writing, other threads cannot read.  Except if the\n# writing thread is writing to its temporary tables, the other threads\n# can still read.  -> Not so in 3.0.  One thread can read while another\n# holds a RESERVED lock.\n#\nproc tx_exec {sql} {\n  db2 eval $sql\n}\ndo_test lock-5.1 {\n  execsql {\n    SELECT * FROM t1\n  }\n} {2 1}\ndo_test lock-5.2 {\n  db function tx_exec tx_exec\n  catchsql {\n    INSERT INTO t1(a,b) SELECT 3, tx_exec('SELECT y FROM t2 LIMIT 1');\n  }\n} {0 {}}\n\nifcapable tempdb {\n  do_test lock-5.3 {\n    execsql {\n      CREATE TEMP TABLE t3(x);\n      SELECT * FROM t3;\n    }\n  } {}\n  do_test lock-5.4 {\n    catchsql {\n      INSERT INTO t3 SELECT tx_exec('SELECT y FROM t2 LIMIT 1');\n    }\n  } {0 {}}\n  do_test lock-5.5 {\n    execsql {\n      SELECT * FROM t3;\n    }\n  } {8}\n  do_test lock-5.6 {\n    catchsql {\n      UPDATE t1 SET a=tx_exec('SELECT x FROM t2');\n    }\n  } {0 {}}\n  do_test lock-5.7 {\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {9 1 9 8}\n  do_test lock-5.8 {\n    catchsql {\n      UPDATE t3 SET x=tx_exec('SELECT x FROM t2');\n    }\n  } {0 {}}\n  do_test lock-5.9 {\n    execsql {\n      SELECT * FROM t3;\n    }\n  } {9}\n}\n\ndo_test lock-6.1 {\n  execsql {\n    CREATE TABLE t4(a PRIMARY KEY, b);\n    INSERT INTO t4 VALUES(1, 'one');\n    INSERT INTO t4 VALUES(2, 'two');\n    INSERT INTO t4 VALUES(3, 'three');\n  }\n\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM sqlite_master\" -1 TAIL]\n  sqlite3_step $STMT\n\n  execsql { DELETE FROM t4 }\n  execsql { SELECT * FROM sqlite_master } db2\n  execsql { SELECT * FROM t4 } db2\n} {}\n\ndo_test lock-6.2 {\n  execsql { \n    BEGIN;\n    INSERT INTO t4 VALUES(1, 'one');\n    INSERT INTO t4 VALUES(2, 'two');\n    INSERT INTO t4 VALUES(3, 'three');\n    COMMIT;\n  }\n\n  execsql { SELECT * FROM t4 } db2\n} {1 one 2 two 3 three}\n\ndo_test lock-6.3 {\n  execsql { SELECT a FROM t4 ORDER BY a } db2\n} {1 2 3}\n\ndo_test lock-6.4 {\n  execsql { PRAGMA integrity_check } db2\n} {ok}\n\ndo_test lock-6.5 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\n# At one point the following set of conditions would cause SQLite to \n# retain a RESERVED or EXCLUSIVE lock after the transaction was committed:\n# \n#   * The journal-mode is set to something other than 'delete', and\n#   * there exists one or more active read-only statements, and\n#   * a transaction that modified zero database pages is committed.\n# \n#set temp_status unlocked\n#if {$TEMP_STORE>=2} {set temp_status unknown}\nset temp_status unknown\ndo_test lock-7.1 {\n  set STMT [sqlite3_prepare $DB \"SELECT * FROM sqlite_master\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test lock-7.2 {\n  execsql { PRAGMA lock_status }\n} [list main shared temp $temp_status]\ndo_test lock-7.3 {\n  execsql {\n    PRAGMA journal_mode = truncate;\n    BEGIN;\n    UPDATE t4 SET a = 10 WHERE 0;\n    COMMIT;\n  }\n  execsql { PRAGMA lock_status }\n} [list main shared temp $temp_status]\ndo_test lock-7.4 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\ndo_test lock-999.1 {\n  rename db2 {}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock2.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks between competing processes.\n#\n# $Id: lock2.test,v 1.11 2009/05/01 10:55:34 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\n\n\n# Simple locking test case:\n#\n# lock2-1.1: Connect a second process to the database.\n# lock2-1.2: Establish a RESERVED lock with this process.\n# lock2-1.3: Get a SHARED lock with the second process.\n# lock2-1.4: Try for a RESERVED lock with process 2. This fails.\n# lock2-1.5: Try to upgrade the first process to EXCLUSIVE, this fails so\n#            it gets PENDING.\n# lock2-1.6: Release the SHARED lock held by the second process. \n# lock2-1.7: Attempt to reaquire a SHARED lock with the second process.\n#            this fails due to the PENDING lock.\n# lock2-1.8: Ensure the first process can now upgrade to EXCLUSIVE.\n#\ndo_test lock2-1.1 {\n  set ::tf1 [launch_testfixture]\n  testfixture $::tf1 {\n    sqlite3 db test.db -key xyzzy\n    db eval {select * from sqlite_master}\n  }\n} {}\ndo_test lock2-1.1.1 {\n  execsql {pragma lock_status}\n} {main unlocked temp closed}\nsqlite3_soft_heap_limit 0\ndo_test lock2-1.2 {\n  execsql {\n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n  }\n} {}\ndo_test lock2-1.3 {\n  testfixture $::tf1 {\n    db eval {\n      BEGIN;\n      SELECT * FROM sqlite_master;\n    }\n  }\n} {}\ndo_test lock2-1.4 {\n  testfixture $::tf1 {\n    catch { db eval { CREATE TABLE def(d, e, f) } } msg\n    set msg\n  }\n} {database is locked}\ndo_test lock2-1.5 {\n  catchsql {\n    COMMIT;\n  }\n} {1 {database is locked}}\ndo_test lock2-1.6 {\n  testfixture $::tf1 {\n    db eval {\n      SELECT * FROM sqlite_master;\n      COMMIT;\n    }\n  }\n} {}\ndo_test lock2-1.7 {\n  testfixture $::tf1 {\n    catch { db eval {\n      BEGIN;\n      SELECT * FROM sqlite_master;\n    } } msg \n    set msg\n  }\n} {database is locked}\ndo_test lock2-1.8 {\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\ndo_test lock2-1.9 {\n  execsql {\n    SELECT * FROM sqlite_master;\n  }\n} \"table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}\"\ncatch flush_async_queue\ndo_test lock2-1.10 {\n  testfixture $::tf1 {\n    db eval {\n      SELECT * FROM sqlite_master;\n    }\n  }\n} \"table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}\"\n\ncatch {testfixture $::tf1 {db close}}\ncatch {close $::tf1}\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock3.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks and the operation of the\n# DEFERRED, IMMEDIATE, and EXCLUSIVE keywords as modifiers to the\n# BEGIN command.\n#\n# $Id: lock3.test,v 1.4 2009/03/28 15:04:24 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Establish two connections to the same database.  Put some\n# sample data into the database.\n#\ndo_test lock3-1.1 {\n  file mkdir tempdir/t1/t2/t3\n  sqlite3 db2 ./tempdir/t1//t2/./t3//./../..//./../../tempdir/..//test.db//\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n  }\n  execsql {\n    SELECT * FROM t1\n  } db2\n} 1\n\n# Get a deferred lock on the database using one connection.  The\n# other connection should still be able to write.\n#\ndo_test lock3-2.1 {\n  execsql {BEGIN DEFERRED TRANSACTION}\n  execsql {INSERT INTO t1 VALUES(2)} db2\n  execsql {END TRANSACTION}\n  execsql {SELECT * FROM t1}\n} {1 2}\n\n# Get an immediate lock on the database using one connection.  The\n# other connection should be able to read the database but not write\n# it.\n#\ndo_test lock3-3.1 {\n  execsql {BEGIN IMMEDIATE TRANSACTION}\n  catchsql {SELECT * FROM t1} db2\n} {0 {1 2}}\ndo_test lock3-3.2 {\n  catchsql {INSERT INTO t1 VALUES(3)} db2\n} {1 {database is locked}}\ndo_test lock3-3.3 {\n  execsql {END TRANSACTION}\n} {}\n\n\n# Get an exclusive lock on the database using one connection.  The\n# other connection should be unable to read or write the database.\n#\ndo_test lock3-4.1 {\n  execsql {BEGIN EXCLUSIVE TRANSACTION}\n  catchsql {SELECT * FROM t1} db2\n} {1 {database is locked}}\ndo_test lock3-4.2 {\n  catchsql {INSERT INTO t1 VALUES(3)} db2\n} {1 {database is locked}}\ndo_test lock3-4.3 {\n  execsql {END TRANSACTION}\n} {}\n\ncatch {db2 close}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock4.test",
    "content": "# 2007 April 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks.\n#\n# $Id: lock4.test,v 1.10 2009/05/06 00:52:41 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_not_use_codec\n\n# Initialize the test.db database so that it is non-empty\n#\ndo_test lock4-1.1 {\n  db eval {\n     PRAGMA auto_vacuum=OFF;\n     CREATE TABLE t1(x);\n  }\n  forcedelete test2.db test2.db-journal\n  sqlite3 db2 test2.db\n  db2 eval {\n     PRAGMA auto_vacuum=OFF;\n     CREATE TABLE t2(x)\n  }\n  db2 close\n  list [file size test.db] [file size test2.db]\n} {2048 2048}\n\n# Create a script to drive a separate process that will\n#\n#     1.  Create a second database test2.db\n#     2.  Get an exclusive lock on test2.db\n#     3.  Add an entry to test.db in table t1, waiting as necessary.\n#     4.  Commit the change to test2.db.\n#\n# Meanwhile, this process will:\n# \n#     A.  Get an exclusive lock on test.db\n#     B.  Attempt to read from test2.db but get an SQLITE_BUSY error.\n#     C.  Commit the changes to test.db thus alloing the other process\n#         to continue.\n#\ndo_test lock4-1.2 {\n \n  # Create a script for the second process to run.\n  #\n  set out [open test2-script.tcl w]\n  puts $out \"sqlite3_test_control_pending_byte [set sqlite_pending_byte]\"\n  puts $out {\n     sqlite3 db2 test2.db\n     db2 eval {\n        BEGIN;\n        INSERT INTO t2 VALUES(2);\n     }\n     sqlite3 db test.db\n     db timeout 1000000\n     db eval {\n        INSERT INTO t1 VALUES(2);\n     }\n     db close\n     db2 eval COMMIT\n     exit\n  }\n  close $out\n\n  # Begin a transaction on test.db.\n  db eval {\n     BEGIN EXCLUSIVE;\n     INSERT INTO t1 VALUES(1);\n  }\n\n  # Kick off the second process.\n  exec [info nameofexec] ./test2-script.tcl &\n\n  # Wait until the second process has started its transaction on test2.db.\n  while {![file exists test2.db-journal]} {\n    after 10\n  }\n\n  # Try to write to test2.db. We are locked out.\n  sqlite3 db2 test2.db\n  catchsql {\n    INSERT INTO t2 VALUES(1)\n  } db2\n} {1 {database is locked}}\ndo_test lock4-1.3 {\n  db eval {\n     COMMIT;\n  }\n  while {[file exists test2.db-journal]} {\n    after 10\n  }\n  # The other process has committed its transaction on test2.db by \n  # deleting the journal file. But it might retain the lock for a \n  # fraction longer \n  #\n  after 25\n  db2 eval {\n     SELECT * FROM t2\n  }\n} {2}\n\n    \ndo_test lock4-999.1 {\n  rename db2 {}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock5.test",
    "content": "# 2008 June 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks.\n#\n# $Id: lock5.test,v 1.6 2008/12/04 12:34:16 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This file is only run if using the unix backend compiled with the\n# SQLITE_ENABLE_LOCKING_STYLE macro.\ndb close\nif {[catch {sqlite3 db test.db -vfs unix-none} msg]} {\n  finish_test\n  return\n}\ndb close\nforcedelete test.db.lock\n\nifcapable lock_proxy_pragmas {\n  set ::using_proxy 0\n  foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n    set ::using_proxy $value\n  }\n  # Disable the proxy locking for these tests\n  set env(SQLITE_FORCE_PROXY_LOCKING) \"0\"\n}\n\n\ndo_test lock5-dotfile.1 {\n  sqlite3 db test.db -vfs unix-dotfile\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n  }\n} {}\n\ndo_test lock5-dotfile.2 {\n  file exists test.db.lock\n} {1}\n\ndo_test lock5-dotfile.3 {\n  execsql COMMIT\n  file exists test.db.lock\n} {0}\n\ndo_test lock5-dotfile.4 {\n  sqlite3 db2 test.db -vfs unix-dotfile\n  execsql {\n    INSERT INTO t1 VALUES('a', 'b');\n    SELECT * FROM t1;\n  } db2\n} {a b}\n\ndo_test lock5-dotfile.5 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {a b}\n\ndo_test lock5-dotfile.6 {\n  file exists test.db.lock\n} {1}\n\ndo_test lock5-dotfile.7 {\n  catchsql { SELECT * FROM t1; }\n} {1 {database is locked}}\n\ndo_test lock5-dotfile.8 {\n  execsql {\n    SELECT * FROM t1;\n    ROLLBACK;\n  } db2\n} {a b}\n\ndo_test lock5-dotfile.9 {\n  catchsql { SELECT * FROM t1; }\n} {0 {a b}}\n\ndo_test lock5-dotfile.10 {\n  file exists test.db.lock\n} {0}\n\ndo_test lock5-dotfile.X {\n  db2 close\n  execsql {BEGIN EXCLUSIVE}\n  db close\n  file exists test.db.lock\n} {0}\n\n#####################################################################\n\nforcedelete test.db\nif {[catch {sqlite3 db test.db -vfs unix-flock} msg]} {\n  finish_test\n  return\n}\n\ndo_test lock5-flock.1 {\n  sqlite3 db test.db -vfs unix-flock\n  execsql {\n    CREATE TABLE t1(a, b);\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} {}\n\n# Make sure we are not accidentally using the dotfile locking scheme.\ndo_test lock5-flock.2 {\n  file exists test.db.lock\n} {0}\n\ndo_test lock5-flock.3 {\n  catch { sqlite3 db2 test.db -vfs unix-flock }\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database is locked}}\n\ndo_test lock5-flock.4 {\n  execsql COMMIT\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2}}\n\ndo_test lock5-flock.5 {\n  execsql BEGIN\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2}}\n\ndo_test lock5-flock.6 {\n  execsql {SELECT * FROM t1}\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database is locked}}\n\ndo_test lock5-flock.7 {\n  db close\n  catchsql { SELECT * FROM t1 } db2\n} {0 {1 2}}\n\ndo_test lock5-flock.8 {\n  db2 close\n} {}\n\n#####################################################################\n\ndo_test lock5-none.1 {\n  sqlite3 db test.db -vfs unix-none\n  sqlite3 db2 test.db -vfs unix-none\n  execsql { PRAGMA mmap_size = 0 } db2\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n  }\n} {}\ndo_test lock5-none.2 {\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test lock5-none.3 {\n  execsql { SELECT * FROM t1; } db2\n} {1 2}\ndo_test lock5-none.4 {\n  execsql { \n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {1 2}\ndo_test lock5-none.5 {\n  execsql COMMIT\n  execsql {SELECT * FROM t1} db2\n} {1 2}\n\nifcapable memorymanage {\n  do_test lock5-none.6 {\n    sqlite3_release_memory 1000000\n    execsql {SELECT * FROM t1} db2\n  } {1 2 3 4}\n}\n\ndo_test lock5-none.X {\n  db close\n  db2 close\n} {}\n\nifcapable lock_proxy_pragmas {\n  set env(SQLITE_FORCE_PROXY_LOCKING) $::using_proxy\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock6.test",
    "content": "# 2008 October 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks.\n#\n# $Id: lock6.test,v 1.3 2009/02/05 16:31:46 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Launch another testfixture process to be controlled by this one. A\n# channel name is returned that may be passed as the first argument to proc\n# 'testfixture' to execute a command. The child testfixture process is shut\n# down by closing the channel.\nproc launch_testfixture {} {\n  set prg [info nameofexec]\n  if {$prg eq \"\"} {\n    set prg [file join . testfixture]\n  }\n  set chan [open \"|$prg tf_main2.tcl\" r+]\n  fconfigure $chan -buffering line\n  return $chan\n}\n\n# Execute a command in a child testfixture process, connected by two-way\n# channel $chan. Return the result of the command, or an error message.\nproc testfixture {chan cmd} {\n  puts $chan $cmd\n  puts $chan OVER\n  set r \"\"\n  while { 1 } {\n    set line [gets $chan]\n    if { $line == \"OVER\" } { \n      return $r\n    }\n    append r $line\n  }\n}\n\n# Write the main loop for the child testfixture processes into file\n# tf_main2.tcl. The parent (this script) interacts with the child processes\n# via a two way pipe. The parent writes a script to the stdin of the child\n# process, followed by the word \"OVER\" on a line of its own. The child\n# process evaluates the script and writes the results to stdout, followed\n# by an \"OVER\" of its own.\nset f [open tf_main2.tcl w]\nputs $f {\n  set l [open log w]\n  set script \"\"\n  while {![eof stdin]} {\n    flush stdout\n    set line [gets stdin]\n    puts $l \"READ $line\"\n    if { $line == \"OVER\" } {\n      catch {eval $script} result\n      puts $result\n      puts $l \"WRITE $result\"\n      puts OVER\n      puts $l \"WRITE OVER\"\n      flush stdout\n      set script \"\"\n    } else {\n      append script $line\n      append script \" ; \"\n    }\n  }\n  close $l\n}\nclose $f\n\n\nifcapable lock_proxy_pragmas&&prefer_proxy_locking {\n  set sqlite_hostid_num 1\n\n  set using_proxy 0\n  foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n    set using_proxy $value\n  }\n\n  # Test the lock_proxy_file pragmas.\n  #\n  set env(SQLITE_FORCE_PROXY_LOCKING) \"1\"\n\n  do_test lock6-1.1 {\n    set ::tf1 [launch_testfixture]\n    testfixture $::tf1 \"sqlite3_test_control_pending_byte $::sqlite_pending_byte\"\n    testfixture $::tf1 {\n      set sqlite_hostid_num 2    \n      sqlite3 db test.db -key xyzzy\n      set lockpath [db eval {\n        PRAGMA lock_proxy_file=\":auto:\";\n        select * from sqlite_master;\n        PRAGMA lock_proxy_file;\n      }]\n      string match \"*test.db:auto:\" $lockpath\n    }\n  } {1}\n  \n  set sqlite_hostid_num 3   \n  do_test lock6-1.2 {\n    execsql {pragma lock_status}\n  } {main unlocked temp closed}\n\n  sqlite3_soft_heap_limit 0\n  do_test lock6-1.3 {\n    list [catch {\n      sqlite3 db test.db\n      execsql { select * from sqlite_master } \n    } msg] $msg\n  } {1 {database is locked}}\n\n  do_test lock6-1.4 {\n    set lockpath [execsql {\n      PRAGMA lock_proxy_file=\":auto:\";\n      PRAGMA lock_proxy_file;\n    } db]\n    set lockpath\n  } {{:auto: (not held)}}\n\n  do_test lock6-1.4.1 {\n    catchsql {\n      PRAGMA lock_proxy_file=\"notmine\";\n      select * from sqlite_master;\n    } db\n  } {1 {database is locked}}\n\n  do_test lock6-1.4.2 {\n    execsql {\n      PRAGMA lock_proxy_file;\n    } db\n  } {notmine}\n    \n  do_test lock6-1.5 {\n    testfixture $::tf1 {\n      db eval {\n        BEGIN;\n        SELECT * FROM sqlite_master;\n      }\n    }\n  } {}\n\n  catch {testfixture $::tf1 {db close}}\n\n  do_test lock6-1.6 {\n    execsql {\n      PRAGMA lock_proxy_file=\"mine\";\n      select * from sqlite_master;\n    } db\n  } {}\n  \n  catch {close $::tf1}\n  set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy\n  set sqlite_hostid_num 0\n\n  sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n}\n      \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock7.test",
    "content": "# 2009 August 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Check that reading the database schema from within an active transaction\n# does not establish a SHARED lock on the database file if one is not\n# already held (or, more accurately, that the SHARED lock is released after\n# reading the database schema).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test lock7-1.1 {\n  execsql { CREATE TABLE t1(a, b) }\n  db close\n\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n\n  db1 eval {BEGIN}\n  db2 eval {BEGIN}\n} {}\n\ndo_test lock7-1.2 {\n  execsql { PRAGMA lock_status } db1\n} {main unlocked temp closed}\ndo_test lock7-1.3 {\n  execsql { PRAGMA lock_status } db2\n} {main unlocked temp closed}\n\ndo_test lock7-1.4 {\n  catchsql { INSERT INTO t1 VALUES(1, 1) } db1\n} {0 {}}\ndo_test lock7-1.5 {\n  catchsql { INSERT INTO t1 VALUES(2, 2) } db2\n} {1 {database is locked}}\n\ndo_test lock7-1.6 {\n  execsql { PRAGMA lock_status } db1\n} {main reserved temp closed}\ndo_test lock7-1.7 {\n  execsql { PRAGMA lock_status } db2\n} {main unlocked temp closed}\n\ndo_test lock7-1.8 {\n  execsql { COMMIT } db1\n} {}\n\ndb1 close\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lock_common.tcl",
    "content": "# 2010 April 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains code used by several different test scripts. The\n# code in this file allows testfixture to control another process (or\n# processes) to test locking.\n#\n\nproc do_multiclient_test {varname script} {\n\n  foreach code [list {\n    if {[info exists ::G(valgrind)]} { db close ; continue }\n    set ::code2_chan [launch_testfixture]\n    set ::code3_chan [launch_testfixture]\n    proc code2 {tcl} { testfixture $::code2_chan $tcl }\n    proc code3 {tcl} { testfixture $::code3_chan $tcl }\n    set tn 1\n  } {\n    proc code2 {tcl} { uplevel #0 $tcl }\n    proc code3 {tcl} { uplevel #0 $tcl }\n    set tn 2\n  }] {\n    faultsim_delete_and_reopen\n\n    proc code1 {tcl} { uplevel #0 $tcl }\n  \n    # Open connections [db2] and [db3]. Depending on which iteration this\n    # is, the connections may be created in this interpreter, or in \n    # interpreters running in other OS processes. As such, the [db2] and [db3]\n    # commands should only be accessed within [code2] and [code3] blocks,\n    # respectively.\n    #\n    eval $code\n    code2 { sqlite3 db2 test.db }\n    code3 { sqlite3 db3 test.db }\n    \n    # Shorthand commands. Execute SQL using database connection [db2] or \n    # [db3]. Return the results.\n    #\n    proc sql1 {sql} { db eval $sql }\n    proc sql2 {sql} { code2 [list db2 eval $sql] }\n    proc sql3 {sql} { code3 [list db3 eval $sql] }\n  \n    proc csql1 {sql} { list [catch { sql1 $sql } msg] $msg }\n    proc csql2 {sql} { list [catch { sql2 $sql } msg] $msg }\n    proc csql3 {sql} { list [catch { sql3 $sql } msg] $msg }\n\n    uplevel set $varname $tn\n    uplevel $script\n\n    catch { code2 { db2 close } }\n    catch { code3 { db3 close } }\n    catch { close $::code2_chan }\n    catch { close $::code3_chan }\n    catch { db close }\n  }\n}\n\n# Launch another testfixture process to be controlled by this one. A\n# channel name is returned that may be passed as the first argument to proc\n# 'testfixture' to execute a command. The child testfixture process is shut\n# down by closing the channel.\nproc launch_testfixture {{prg \"\"}} {\n  write_main_loop\n  if {$prg eq \"\"} { set prg [info nameofexec] }\n  if {$prg eq \"\"} { set prg testfixture }\n  if {[file tail $prg]==$prg} { set prg [file join . $prg] }\n  set chan [open \"|$prg tf_main.tcl\" r+]\n  fconfigure $chan -buffering line\n  set rc [catch { \n    testfixture $chan \"sqlite3_test_control_pending_byte $::sqlite_pending_byte\"\n  }]\n  if {$rc} {\n    testfixture $chan \"set ::sqlite_pending_byte $::sqlite_pending_byte\"\n  }\n  return $chan\n}\n\n# Execute a command in a child testfixture process, connected by two-way\n# channel $chan. Return the result of the command, or an error message.\n#\nproc testfixture {chan cmd args} {\n\n  if {[llength $args] == 0} {\n    fconfigure $chan -blocking 1\n    puts $chan $cmd\n    puts $chan OVER\n\n    set r \"\"\n    while { 1 } {\n      set line [gets $chan]\n      if { $line == \"OVER\" } { \n        set res [lindex $r 1]\n        if { [lindex $r 0] } { error $res }\n        return $res\n      }\n      if {[eof $chan]} {\n        return \"ERROR: Child process hung up\"\n      }\n      append r $line\n    }\n    return $r\n  } else {\n    set ::tfnb($chan) \"\"\n    fconfigure $chan -blocking 0 -buffering none\n    puts $chan $cmd\n    puts $chan OVER\n    fileevent $chan readable [list testfixture_script_cb $chan [lindex $args 0]]\n    return \"\"\n  }\n}\n\nproc testfixture_script_cb {chan script} {\n  if {[eof $chan]} {\n    append ::tfnb($chan) \"ERROR: Child process hung up\"\n    set line \"OVER\"\n  } else {\n    set line [gets $chan]\n  }\n\n  if { $line == \"OVER\" } {\n    uplevel #0 $script [list [lindex $::tfnb($chan) 1]]\n    unset ::tfnb($chan)\n    fileevent $chan readable \"\"\n  } else {\n    append ::tfnb($chan) $line\n  }\n}\n\nproc testfixture_nb_cb {varname chan} {\n  if {[eof $chan]} {\n    append ::tfnb($chan) \"ERROR: Child process hung up\"\n    set line \"OVER\"\n  } else {\n    set line [gets $chan]\n  }\n\n  if { $line == \"OVER\" } {\n    set $varname [lindex $::tfnb($chan) 1]\n    unset ::tfnb($chan)\n    close $chan\n  } else {\n    append ::tfnb($chan) $line\n  }\n}\n\nproc testfixture_nb {varname cmd} {\n  set chan [launch_testfixture]\n  set ::tfnb($chan) \"\"\n  fconfigure $chan -blocking 0 -buffering none\n  puts $chan $cmd\n  puts $chan OVER\n  fileevent $chan readable [list testfixture_nb_cb $varname $chan]\n  return \"\"\n}\n\n# Write the main loop for the child testfixture processes into file\n# tf_main.tcl. The parent (this script) interacts with the child processes\n# via a two way pipe. The parent writes a script to the stdin of the child\n# process, followed by the word \"OVER\" on a line of its own. The child\n# process evaluates the script and writes the results to stdout, followed\n# by an \"OVER\" of its own.\n#\nset main_loop_written 0\nproc write_main_loop {} {\n  if {$::main_loop_written} return\n  set wrapper \"\"\n  if {[sqlite3 -has-codec] && [info exists ::do_not_use_codec]==0} {\n    set wrapper \"\n      rename sqlite3 sqlite_orig\n      proc sqlite3 {args} {[info body sqlite3]}\n    \"\n  }\n\n  set fd [open tf_main.tcl w]\n  puts $fd [string map [list %WRAPPER% $wrapper] {\n    %WRAPPER%\n    set script \"\"\n    while {![eof stdin]} {\n      flush stdout\n      set line [gets stdin]\n      if { $line == \"OVER\" } {\n        set rc [catch {eval $script} result]\n        puts [list $rc $result]\n        puts OVER\n        flush stdout\n        set script \"\"\n      } else {\n        append script $line\n        append script \"\\n\"\n      }\n    }\n  }]\n  close $fd\n  set main_loop_written 1\n}\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/lookaside.test",
    "content": "# 2008 August 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the lookaside memory allocator.\n#\n# $Id: lookaside.test,v 1.10 2009/04/09 01:23:49 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !lookaside {\n  finish_test\n  return\n}\n\n# The tests in this file configure the lookaside allocator after a \n# connection is opened. This will not work if there is any \"presql\"\n# configured (SQL run within the [sqlite3] wrapper in tester.tcl).\nif {[info exists ::G(perm:presql)]} {\n  finish_test\n  return\n}\n\ntest_set_config_pagecache 0 0\n\ncatch {db close}\nsqlite3_shutdown\nsqlite3_initialize\nautoinstall_test_functions\nsqlite3 db test.db\n\n# Make sure sqlite3_db_config() and sqlite3_db_status are working.\n#\ndo_test lookaside-1.1 {\n  catch {sqlite3_config_error db}\n} {0}\n\ndo_test lookaside-1.2 {\n  sqlite3_db_config_lookaside db 1 18 18\n} {0}\ndo_test lookaside-1.3.1 {\n  sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0\n} {0 0 0}\ndo_test lookaside-1.3.2 {\n  sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0\n} {0 0 0}\ndo_test lookaside-1.3.3 {\n  sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0\n} {0 0 0}\ndo_test lookaside-1.3.4 {\n  sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0\n} {0 0 0}\n\ndo_test lookaside-1.4 {\n  db eval {CREATE TABLE t1(w,x,y,z);}\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break\n  set p [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_HIT 0] 2]\n  set q [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_SIZE 0] 2]\n  set r [lindex [sqlite3_db_status db DBSTATUS_LOOKASIDE_MISS_FULL 0] 2]\n  expr {$x==0 && $y<$z && $z==18 && $p>0 && $q>0 && $r>0}\n} {0}\ndo_test lookaside-1.5 {\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break\n  expr {$x==0 && $y<$z && $z==18}\n} {0}\ndo_test lookaside-1.6 {\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break\n  expr {$x==0 && $y==$z && $y<18}\n} {1}\ndo_test lookaside-1.7 {\n  db cache flush\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break\n  expr {$x==0 && $y==0 && $z<18}\n} {1}\ndo_test lookaside-1.8 {\n  db cache flush\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 1] break\n  expr {$x==0 && $y==0 && $z<18}\n} {1}\ndo_test lookaside-1.9 {\n  db cache flush\n  sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0\n} {0 0 0}\n\ndo_test lookaside-2.1 {\n  sqlite3_db_config_lookaside db 0 100 1000\n} {0}\ndo_test lookaside-2.2 {\n  db eval {CREATE TABLE t2(x);}\n  foreach {x y z} [sqlite3_db_status db DBSTATUS_LOOKASIDE_USED 0] break\n  expr {$x==0 && $y<$z && $z>10 && $z<100}\n} {1}\ndo_test lookaside-2.3 {\n  sqlite3_db_config_lookaside db 0 50 50\n} {5}  ;# SQLITE_BUSY\ndo_test lookaside-2.4 {\n  db cache flush\n  sqlite3_db_config_lookaside db 0 50 50\n} {0}  ;# SQLITE_OK\ndo_test lookaside-2.5 {\n  sqlite3_db_config_lookaside db 0 -1 50\n} {0}  ;# SQLITE_OK\ndo_test lookaside-2.6 {\n  sqlite3_db_config_lookaside db 0 50 -1\n} {0}  ;# SQLITE_OK\n\n# sqlite3_db_status() with an invalid verb returns an error.\n#\ndo_test lookaside-3.1 {\n  sqlite3_db_status db 99999 0\n} {1 0 0}\n\n# Test that an invalid verb on sqlite3_config() is detected and\n# reported as an error.\n#\ndo_test lookaside-4.1 {\n  db close\n  sqlite3_shutdown\n  catch sqlite3_config_error\n} {0}\nsqlite3_initialize\nautoinstall_test_functions\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/main.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is exercising the code in main.c.\n#\n# $Id: main.test,v 1.32 2009/04/28 04:51:29 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Only do the next group of tests if the sqlite3_complete API is available\n#\nifcapable {complete} {\n\n# Tests of the sqlite_complete() function.\n#\ndo_test main-1.1 {\n  db complete {This is a test}\n} {0}\ndo_test main-1.2.0 {\n  db complete {\n  }\n} {0}\ndo_test main-1.2.1 {\n  db complete {}\n} {0}\ndo_test main-1.3.0 {\n  db complete {\n     -- a comment ;\n  }\n} {0}\ndo_test main-1.3.1 {\n  db complete {\n     /* a comment ; */\n  }\n} {0}\ndo_test main-1.4.0 {\n  db complete {\n     -- a comment ;\n     ;\n  }\n} {1}\ndo_test main-1.4.1 {\n  db complete {\n     /* a comment ; */\n     ;\n  }\n} {1}\ndo_test main-1.4.2 {\n  db complete {\n     /* a comment ; */ ;\n  }\n} {1}\ndo_test main-1.5 {\n  db complete {DROP TABLE 'xyz;}\n} {0}\ndo_test main-1.6 {\n  db complete {DROP TABLE 'xyz';}\n} {1}\ndo_test main-1.7 {\n  db complete {DROP TABLE \"xyz;}\n} {0}\ndo_test main-1.8 {\n  db complete {DROP TABLE \"xyz';}\n} {0}\ndo_test main-1.9 {\n  db complete {DROP TABLE \"xyz\";}\n} {1}\ndo_test main-1.10 {\n  db complete {DROP TABLE xyz; hi}\n} {0}\ndo_test main-1.11 {\n  db complete {DROP TABLE xyz; }\n} {1}\ndo_test main-1.12 {\n  db complete {DROP TABLE xyz; -- hi }\n} {1}\ndo_test main-1.13 {\n  db complete {DROP TABLE xyz; -- hi\n  }\n} {1}\ndo_test main-1.14 {\n  db complete {SELECT a-b FROM t1; }\n} {1}\ndo_test main-1.15 {\n  db complete {SELECT a/e FROM t1 }\n} {0}\ndo_test main-1.16 {\n  db complete {\n    CREATE TABLE abc(x,y);\n  }\n} {1}\nifcapable {trigger} {\n  do_test main-1.17 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;\n    }\n  } {0}\n  do_test main-1.17.2 {\n    db complete {\n      EXPLAIN CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;\n    }\n  } {0}\n  do_test main-1.17.3 {\n    db complete {\n      EXPLAIN QUERY PLAN CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr;\n    }\n  } {0}\n  do_test main-1.18 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE abc BEGIN UPDATE pqr; END;\n    }\n  } {1}\n  do_test main-1.19 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE abc BEGIN\n         UPDATE pqr;\n         unknown command;\n    }\n  } {0}\n  do_test main-1.20 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE backend BEGIN\n         UPDATE pqr;\n    }\n  } {0}\n  do_test main-1.21 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE end BEGIN\n         SELECT a, b FROM end;\n    }\n  } {0}\n  do_test main-1.22 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE end BEGIN\n         SELECT a, b FROM end;\n      END;\n    }\n  } {1}\n  do_test main-1.23 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE end BEGIN\n         SELECT a, b FROM end;\n      END;\n      SELECT a, b FROM end;\n    }\n  } {1}\n  do_test main-1.24 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE [;end;] BEGIN\n         UPDATE pqr;\n    }\n  } {0}\n  do_test main-1.25 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE backend BEGIN\n         UPDATE cantor SET a=[;end;];;;\n    }\n  } {0}\n  do_test main-1.26 {\n    db complete {\n      CREATE -- a comment\n      TRIGGER exy AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n    }\n  } {0}\n  do_test main-1.27.1 {\n    db complete {\n      CREATE -- a comment\n      TRIGGERX tangentxx AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n    }\n  } {1}\n  do_test main-1.27.2 {\n    db complete {\n      CREATE/**/TRIGGER tiger00 AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n    }\n  } {0}\n  ifcapable {explain} {\n    do_test main-1.27.3 {\n      db complete {\n        /* */ EXPLAIN -- A comment\n        CREATE/**/TRIGGER ezxyz12 AFTER DELETE backend BEGIN\n           UPDATE pqr SET a=5;\n      }\n    } {0}\n  }\n  do_test main-1.27.4 {\n    db complete {\n      BOGUS token\n      CREATE  TRIGGER xyz AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n    }\n  } {1}\n  ifcapable {explain} {\n    do_test main-1.27.5 {\n      db complete {\n        EXPLAIN \n        CREATE TEMP TRIGGER xyz AFTER DELETE backend BEGIN\n           UPDATE pqr SET a=5;\n      }\n    } {0}\n  }\n  do_test main-1.28 {\n    db complete {\n      CREATE TEMPORARY TRIGGER xyz AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n    }\n  } {0}\n  do_test main-1.29 {\n    db complete {\n      CREATE TRIGGER xyz AFTER DELETE backend BEGIN\n         UPDATE pqr SET a=5;\n         EXPLAIN select * from xyz;\n    }\n  } {0}\n\n} ;# end ifcapable {complete}\n\n}\ndo_test main-1.30 {\n  db complete {\n     CREATE TABLE /* In comment ; */\n  }\n} {0}\ndo_test main-1.31 {\n  db complete {\n     CREATE TABLE /* In comment ; */ hi;\n  }\n} {1}\ndo_test main-1.31 {\n  db complete {\n     CREATE TABLE /* In comment ; */;\n  }\n} {1}\ndo_test main-1.32 {\n  db complete {\n     stuff;\n     /*\n       CREATE TABLE\n       multiple lines\n       of text\n     */\n  }\n} {1}\ndo_test main-1.33 {\n  db complete {\n     /*\n       CREATE TABLE\n       multiple lines\n       of text;\n  }\n} {0}\ndo_test main-1.34 {\n  db complete {\n     /*\n       CREATE TABLE\n       multiple lines \"*/\n       of text;\n  }\n} {1}\ndo_test main-1.35 {\n  db complete {hi /**/ there;}\n} {1}\ndo_test main-1.36 {\n  db complete {hi there/***/;}\n} {1}\ndo_test main-1.37 {\n  db complete {hi there/**}\n} {0}\ndo_test main-1.38 {\n  db complete {hi [there}\n} {0}\n\nifcapable {trigger} {\n  # Characters less than \\040 can never be part of an identifier.\n  # Characters greater than \\u177 are always identifier characters.\n  do_test main-1.100 {\n    db complete \"create \\037\\036\\035\\034trigger\\001\\002;\"\n  } {1}\n  do_test main-1.101 {\n    db complete \"create trigger\\200;\"\n  } {1}\n  do_test main-1.102 {\n    db complete \"create \\200trigger;\"\n  } {1}\n}\n\n\n# Try to open a database with a corrupt database file.\n#\nif {[permutation] == \"\"} {\n  do_test main-2.0 {\n    catch {db close}\n    forcedelete test.db\n    set fd [open test.db w]\n    puts $fd hi!\n    close $fd\n    set v [catch {sqlite3 db test.db} msg]\n    if {$v} {lappend v $msg} {lappend v {}}\n  } {0 {}}\n}\n\n# Here are some tests for tokenize.c.  \n#\ndo_test main-3.1 {\n  catch {db close}\n  foreach f [glob -nocomplain testdb/*] {forcedelete $f}\n  forcedelete testdb\n  sqlite3 db testdb\n  set v [catch {execsql {SELECT * from T1 where x!!5}} msg]\n  lappend v $msg\n} {1 {unrecognized token: \"!\"}}\ndo_test main-3.2 {\n  catch {db close}\n  foreach f [glob -nocomplain testdb/*] {forcedelete $f}\n  forcedelete testdb\n  sqlite3 db testdb\n  set v [catch {execsql {SELECT * from T1 where ^x}} msg]\n  lappend v $msg\n} {1 {unrecognized token: \"^\"}}\ndo_test main-3.2.2 {\n  catchsql {select 'abc}\n} {1 {unrecognized token: \"'abc\"}}\ndo_test main-3.2.3 {\n  catchsql {select \"abc}\n} {1 {unrecognized token: \"\"abc\"}}\ndo_test main-3.2.4 {\n  catchsql {select [abc}\n} {1 {unrecognized token: \"[abc\"}}\ndo_test main-3.2.5 {\n  catchsql {select x'4869}\n} {1 {unrecognized token: \"x'4869\"}}\ndo_test main-3.2.6 {\n  catchsql {select x'4869'}\n} {0 Hi}\ndo_test main-3.2.7 {\n  catchsql {select x'48695'}\n} {1 {unrecognized token: \"x'48695'\"}}\ndo_test main-3.2.8 {\n  catchsql {select x'486x'}\n} {1 {unrecognized token: \"x'486x'\"}}\ndo_test main-3.2.9 {\n  catchsql {select $abc(}\n} {1 {unrecognized token: \"$abc(\"}}\ndo_test main-3.2.10 {\n  catchsql {select $abc(x}\n} {1 {unrecognized token: \"$abc(x\"}}\nset xyz 123\ndo_test main-3.2.11 {\n  catchsql {select $::xyz}\n} {0 123}\nnamespace eval ::testnamespace {\n  variable xyz 321\n}\ndo_test main-3.2.12 {\n  catchsql {select $testnamespace::xyz}\n} {0 321}\ndo_test main-3.2.13 {\n  catchsql {select $(abc)}\n} {1 {unrecognized token: \"$\"}}\ndo_test main-3.2.14 {\n  set hi\\u1234x 987\n  db eval \"select \\$hi\\u1234x\"\n} {987}\ndo_test main-3.2.15 {\n  catchsql \"select 456\\u1234\"\n} [list 1 \"unrecognized token: \\\"456\\u1234\\\"\"]\ndo_test main-3.2.16 {\n  catchsql {select cast(3.14e+4 AS integer)}\n} {0 31400}\ndo_test main-3.2.17 {\n  catchsql {select cast(3.14e+04 AS integer)}\n} {0 31400}\ndo_test main-3.2.18 {\n  catchsql {select cast(3.14e+004 AS integer)}\n} {0 31400}\ndo_test main-3.2.19 {\n  catchsql {select cast(3.14e4 AS integer)}\n} {0 31400}\ndo_test main-3.2.20 {\n  catchsql {select cast(3.14e04 AS integer)}\n} {0 31400}\ndo_test main-3.2.21 {\n  catchsql {select cast(3.14e004 AS integer)}\n} {0 31400}\ndo_test main-3.2.16 {\n  catchsql {select cast(3.14E+4 AS integer)}\n} {0 31400}\ndo_test main-3.2.17 {\n  catchsql {select cast(3.14E+04 AS integer)}\n} {0 31400}\ndo_test main-3.2.18 {\n  catchsql {select cast(3.14E+004 AS integer)}\n} {0 31400}\ndo_test main-3.2.19 {\n  catchsql {select cast(3.14E4 AS integer)}\n} {0 31400}\ndo_test main-3.2.20 {\n  catchsql {select cast(3.14E04 AS integer)}\n} {0 31400}\ndo_test main-3.2.21 {\n  catchsql {select cast(3.14E004 AS integer)}\n} {0 31400}\ndo_test main-3.2.22 {\n  catchsql {select cast(3.14e-4 * 1e8 AS integer)}\n} {0 31400}\ndo_test main-3.2.23 {\n  catchsql {select cast(3.14E-04 * 1E08 AS integer)}\n} {0 31400}\ndo_test main-3.2.24 {\n  catchsql {select cast(3.14e-004 * 01.0E+8 AS integer)}\n} {0 31400}\ndo_test main-3.2.25 {\n  catchsql {select 123/*abc}\n} {0 123}\ndo_test main-3.2.26 {\n  catchsql {select 123/***abc}\n} {0 123}\ndo_test main-3.2.27 {\n  catchsql {select 123/*/*2}\n} {0 123}\ndo_test main-3.2.28 {\n  catchsql {select 123/**/*2}\n} {0 246}\ndo_test main-3.2.29 {\n  catchsql {select 123/}\n} {1 {near \"/\": syntax error}}\ndo_test main-3.2.30 {\n  catchsql {select 123--5}\n} {0 123}\n\n\ndo_test main-3.3 {\n  catch {db close}\n  foreach f [glob -nocomplain testdb/*] {forcedelete $f}\n  forcedelete testdb\n  sqlite3 db testdb\n  execsql {\n    create table T1(X REAL);  /* C-style comments allowed */\n    insert into T1 values(0.5);\n    insert into T1 values(0.5e2);\n    insert into T1 values(0.5e-002);\n    insert into T1 values(5e-002);\n    insert into T1 values(-5.0e-2);\n    insert into T1 values(-5.1e-2);\n    insert into T1 values(0.5e2);\n    insert into T1 values(0.5E+02);\n    insert into T1 values(5E+02);\n    insert into T1 values(5.0E+03);\n    select x*10 from T1 order by x*5;\n  }\n} {-0.51 -0.5 0.05 0.5 5.0 500.0 500.0 500.0 5000.0 50000.0}\ndo_test main-3.4 {\n  set v [catch {execsql {create bogus}} msg]\n  lappend v $msg\n} {1 {near \"bogus\": syntax error}}\ndo_test main-3.5 {\n  set v [catch {execsql {create}} msg]\n  lappend v $msg\n} {1 {near \"create\": syntax error}}\ndo_test main-3.6 {\n  catchsql {SELECT 'abc' + #9}\n} {1 {near \"#9\": syntax error}}\n\n# The following test-case tests the linked list code used to manage\n# sqlite3_vfs structures.\nif {$::tcl_platform(platform)==\"unix\" \n     && [info command sqlite3async_initialize]!=\"\"} {\n  ifcapable threadsafe {\n    do_test main-4.1 {\n      sqlite3_crash_enable 1\n      sqlite3_crash_enable 0\n    \n      sqlite3async_initialize \"\" 1\n      sqlite3async_shutdown\n    \n      sqlite3_crash_enable 1\n      sqlite3async_initialize \"\" 1\n      sqlite3_crash_enable 0\n      sqlite3async_shutdown\n    \n      sqlite3_crash_enable 1\n      sqlite3async_initialize \"\" 1\n      sqlite3async_shutdown\n      sqlite3_crash_enable 0\n    \n      sqlite3async_initialize \"\" 1\n      sqlite3_crash_enable 1\n      sqlite3_crash_enable 0\n      sqlite3async_shutdown\n    \n      sqlite3async_initialize \"\" 1\n      sqlite3_crash_enable 1\n      sqlite3async_shutdown\n      sqlite3_crash_enable 0\n    } {}\n    do_test main-4.2 {\n      set rc [catch {sqlite3 db test.db -vfs crash} msg]\n      list $rc $msg\n    } {1 {no such vfs: crash}}\n    do_test main-4.3 {\n      set rc [catch {sqlite3 db test.db -vfs async} msg]\n      list $rc $msg\n    } {1 {no such vfs: async}}\n  }\n}\n\n# Print the version number so that it can be picked up by releasetest.tcl.\n#\nputs [db one {SELECT 'VERSION: ' ||\n                  sqlite_version() || ' ' ||\n                  sqlite_source_id();}]\n\n# Do deliberate failures if the TEST_FAILURE environment variable is set.\n# This is done to verify that failure notifications are detected by the\n# releasetest.tcl script, or possibly by other scripts involved in automatic\n# testing.\n#\nif {[info exists ::env(TEST_FAILURE)]} {\n  set res 123\n  if {$::env(TEST_FAILURE)==0} {set res 234}\n  do_test main-99.1 {\n     bad_behavior $::env(TEST_FAILURE)\n     set x 123\n  } $res\n}\n    \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/make-where7.tcl",
    "content": "#!/usr/bin/tclsh\n#\n# Run this script to generate randomized test cases for the where7.test\n# script.  The output will need to be manually copied and pasted into\n# the where7.test script.\n#\nputs \"do_test where7-2.1 \\173\"\nputs \"  db eval \\173\"\nputs \"    CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\"\nset NA 100\nfor {set a 1} {$a<=$NA} {incr a} {\n  set b [expr {$a*11}]\n  set div3 [expr {int(($a+2)/3)}]\n  set c [expr {$div3*1001}]\n  set d [expr {$a*1.001}]\n  set e [expr {$div3*100.1}]\n  set x [expr {$a%26}]\n  set f [string range {abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz} \\\n           $x [expr {$x+8}]]\n  set div5 [expr {int(($a+7)/5)}]\n  set x [expr {$div5%26}]\n  set g [string range {zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba} \\\n           $x [expr {$x+6}]]\n  puts \"    INSERT INTO t2 VALUES($a,$b,$c,$d,$e,'$f','$g');\"\n  lappend fidx($f) $a\n  lappend gidx($g) $a\n  set gof($a) $g\n  set fof($a) $f\n\n  set expr \"a=$a\"\n  set term($expr) $a\n  set expr \"((a BETWEEN [expr {$a-1}] AND [expr {$a+1}]) AND a!=$a)\"\n  set x {}\n  if {$a>1} {set x [expr {$a-1}]}\n  if {$a<$NA} {lappend x [expr {$a+1}]}\n  set term($expr) $x\n  set expr \"b=$b\"\n  set term($expr) $a\n  set expr \"b=[expr {$a*11+3}]\"\n  set term($expr) {}\n  set expr \"c=$c\"\n  lappend term($expr) $a\n  set expr \"(d>=$a.0 AND d<[expr {$a+1.0}] AND d NOT NULL)\"\n  lappend term($expr) $a\n  set expr \"f='$f'\"\n  lappend term($expr) $a\n  set expr \\\n     \"(f GLOB '?[string range $f 1 4]*' AND f GLOB '[string range $f 0 3]*')\"\n  lappend term($expr) $a\n  set expr \"(g='$g' AND f GLOB '[string range $f 0 4]*')\"\n  lappend term($expr) $a\n}\nputs \"    CREATE INDEX t2b ON t2(b);\"\nputs \"    CREATE INDEX t2c ON t2(c);\"\nputs \"    CREATE INDEX t2d ON t2(d);\"\nputs \"    CREATE INDEX t2e ON t2(e);\"\nputs \"    CREATE INDEX t2f ON t2(f);\"\nputs \"    CREATE INDEX t2g ON t2(g);\"\nputs \"    CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\"\nputs \"    INSERT INTO t3 SELECT * FROM t2;\"\nputs \"    CREATE INDEX t3b ON t3(b,c);\"\nputs \"    CREATE INDEX t3c ON t3(c,e);\"\nputs \"    CREATE INDEX t3d ON t3(d,g);\"\nputs \"    CREATE INDEX t3e ON t3(e,f,g);\"\nputs \"    CREATE INDEX t3f ON t3(f,b,d,c);\"\nputs \"    CREATE INDEX t3g ON t3(g,f);\"\n\nputs \"  \\175\"\nputs \"\\175 {}\"\n\nset term(b<0) {}\nset term(1000000<b) {}\nset term(c<=10) {}\nset term(c>=[expr {int(($NA+2)/3)*1001+1}]) {}\nset term(d<0.0) {}\nset term(d>1e10) {}\nset expr {e IS NULL}\nset term($expr) {}\nset expr {f IS NULL}\nset term($expr) {}\nset expr {g IS NULL}\nset term($expr) {}\n\nset NT 1000\nset termlist [array names term]\nset nterm [llength $termlist]\nfor {set i 2} {$i<=$NT+1} {incr i} {\n  set n [expr {int(rand()*10)+2}]\n  set w {}\n  unset -nocomplain r\n  for {set j 0} {$j<$n} {incr j} {\n    set k [expr {int(rand()*$nterm)}]\n    set t [lindex $termlist $k]\n    lappend w $t\n    foreach a $term($t) {\n      set r($a) 1\n    }\n  }\n  if {[info exists seen($w)]} {\n    incr i -1\n    continue\n  }\n  set seen($w) 1\n  set result [lsort -int [array names r]]\n  puts \"do_test where7-2.$i.1 \\173\"\n  puts \"  count_steps_sort \\173\"\n  puts \"     SELECT a FROM t2\"\n  set wc [join $w \"\\n         OR \"]\n  puts \"      WHERE $wc\"\n  puts \"  \\175\"\n  puts \"\\175 {$result scan 0 sort 0}\"\n  puts \"do_test where7-2.$i.2 \\173\"\n  puts \"  count_steps_sort \\173\"\n  puts \"     SELECT a FROM t3\"\n  set wc [join $w \"\\n         OR \"]\n  puts \"      WHERE $wc\"\n  puts \"  \\175\"\n  puts \"\\175 {$result scan 0 sort 0}\"\n}\nputs \"finish_test\"\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file attempts to check the behavior of the SQLite library in \n# an out-of-memory situation. When compiled with -DSQLITE_DEBUG=1, \n# the SQLite library accepts a special command (sqlite3_memdebug_fail N C)\n# which causes the N-th malloc to fail.  This special feature is used\n# to see what happens in the library if a malloc were to really fail\n# due to an out-of-memory situation.\n#\n# $Id: malloc.test,v 1.81 2009/06/24 13:13:45 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix malloc\n\n\n# Only run these tests if memory debugging is turned on.\n#\nsource $testdir/malloc_common.tcl\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# Do a couple of memory dumps just to exercise the memory dump logic\n# that that we can say that we have.\n#\nputs stderr \"This is a test.  Ignore the error that follows:\"\nsqlite3_memdebug_dump $testdir\nputs \"Memory dump to file memdump.txt...\"\nsqlite3_memdebug_dump memdump.txt\n\nifcapable bloblit&&subquery {\n  do_malloc_test 1 -tclprep {\n    db close\n  } -tclbody {\n    if {[catch {sqlite3 db test.db}]} {\n      error \"out of memory\"\n    }\n    sqlite3_extended_result_codes db 1\n  } -sqlbody {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(\n       a int, b float, c double, d text, e varchar(20),\n       primary key(a,b,c)\n    );\n    CREATE INDEX i1 ON t1(a,b);\n    INSERT INTO t1 VALUES(1,2.3,4.5,'hi',x'746865726500');\n    INSERT INTO t1 VALUES(6,7.0,0.8,'hello','out yonder');\n    SELECT * FROM t1;\n    SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;\n    DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);\n    SELECT count(*), group_concat(e) FROM t1;\n    SELECT b FROM t1 ORDER BY 1 COLLATE nocase;\n  } \n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-1.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nifcapable subquery {\n  do_malloc_test 2 -sqlbody {\n    CREATE TABLE t1(a int, b int default 'abc', c int default 1);\n    CREATE INDEX i1 ON t1(a,b);\n    INSERT INTO t1 VALUES(1,1,'99 abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 VALUES(2,4,'98 abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 VALUES(3,9,'97 abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 VALUES(4,16,'96 abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 VALUES(5,25,'95 abcdefghijklmnopqrstuvwxyz');\n    INSERT INTO t1 VALUES(6,36,'94 abcdefghijklmnopqrstuvwxyz');\n    SELECT 'stuff', count(*) as 'other stuff', max(a+10) FROM t1;\n    UPDATE t1 SET b=b||b||b||b;\n    UPDATE t1 SET b=a WHERE a in (10,12,22);\n    INSERT INTO t1(c,b,a) VALUES(20,10,5);\n    INSERT INTO t1 SELECT * FROM t1\n        WHERE a IN (SELECT a FROM t1 WHERE a<10);\n    DELETE FROM t1 WHERE a>=10;\n    DROP INDEX i1;\n    DELETE FROM t1;\n  } \n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-2.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\ndo_malloc_test 3 -sqlbody {\n  BEGIN TRANSACTION;\n  CREATE TABLE t1(a int, b int, c int);\n  CREATE INDEX i1 ON t1(a,b);\n  INSERT INTO t1 VALUES(1,1,99);\n  INSERT INTO t1 VALUES(2,4,98);\n  INSERT INTO t1 VALUES(3,9,97);\n  INSERT INTO t1 VALUES(4,16,96);\n  INSERT INTO t1 VALUES(5,25,95);\n  INSERT INTO t1 VALUES(6,36,94);\n  INSERT INTO t1(c,b,a) VALUES(20,10,5);\n  DELETE FROM t1 WHERE a>=10;\n  DROP INDEX i1;\n  DELETE FROM t1;\n  ROLLBACK;\n} \n\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-3.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nifcapable subquery {\n  do_malloc_test 4 -sqlbody {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a int, b int, c int);\n    CREATE INDEX i1 ON t1(a,b);\n    INSERT INTO t1 VALUES(1,1,99);\n    INSERT INTO t1 VALUES(2,4,98);\n    INSERT INTO t1 VALUES(3,9,97);\n    INSERT INTO t1 VALUES(4,16,96);\n    INSERT INTO t1 VALUES(5,25,95);\n    INSERT INTO t1 VALUES(6,36,94);\n    UPDATE t1 SET b=a WHERE a in (10,12,22);\n    INSERT INTO t1 SELECT * FROM t1\n       WHERE a IN (SELECT a FROM t1 WHERE a<10);\n    DROP INDEX i1;\n    DELETE FROM t1;\n    COMMIT;\n  } \n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-4.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nifcapable trigger {\n  do_malloc_test 5 -sqlbody {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a,b);\n    CREATE TABLE t2(x,y);\n    CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a = 2 BEGIN\n      INSERT INTO t2(x,y) VALUES(new.rowid,1);\n      INSERT INTO t2(x,y) SELECT * FROM t2;\n      INSERT INTO t2 SELECT * FROM t2;\n      UPDATE t2 SET y=y+1 WHERE x=new.rowid;\n      SELECT 123;\n      DELETE FROM t2 WHERE x=new.rowid;\n    END;\n    INSERT INTO t1(a,b) VALUES(2,3);\n    COMMIT;\n  } \n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-5.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nifcapable vacuum {\n  do_malloc_test 6 -sqlprep {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    INSERT INTO t1 SELECT a*2 FROM t1;\n    DELETE FROM t1 where rowid%5 = 0;\n    COMMIT;\n  } -sqlbody {\n    VACUUM;\n  } \n}\n\nautoinstall_test_functions\ndo_malloc_test 7 -sqlprep {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n  INSERT INTO t1 VALUES(7, randstr(1200,1200));\n} -sqlbody {\n  SELECT min(a) FROM t1 WHERE a<6 GROUP BY b;\n  SELECT a FROM t1 WHERE a<6 ORDER BY a;\n  SELECT b FROM t1 WHERE a>6;\n}\n\n# This block is designed to test that some malloc failures that may\n# occur in vdbeapi.c. Specifically, if a malloc failure that occurs\n# when converting UTF-16 text to integers and real numbers is handled\n# correctly. \n#\n# This is done by retrieving a string from the database engine and\n# manipulating it using the sqlite3_column_*** APIs. This doesn't \n# actually return an error to the user when a malloc() fails.. That \n# could be viewed as a bug.\n#\n# These tests only run if UTF-16 support is compiled in.\n#\nifcapable utf16 {\n  set ::STMT {}\n  do_malloc_test 8 -tclprep {\n    set sql \"SELECT '[string repeat abc 20]', '[string repeat def 20]', ?\"\n    set ::STMT [sqlite3_prepare db $sql -1 X]\n    sqlite3_step $::STMT\n    if { $::tcl_platform(byteOrder)==\"littleEndian\" } {\n      set ::bomstr \"\\xFF\\xFE\"\n    } else {\n      set ::bomstr \"\\xFE\\xFF\"\n    }\n    append ::bomstr [encoding convertto unicode \"123456789_123456789_123456789\"]\n  } -tclbody {\n    sqlite3_column_text16 $::STMT 0\n    sqlite3_column_int $::STMT 0\n    sqlite3_column_text16 $::STMT 1\n    sqlite3_column_double $::STMT 1\n    set rc [sqlite3_reset $::STMT]\n    if {$rc eq \"SQLITE_NOMEM\"} {error \"out of memory\"}\n    sqlite3_bind_text16 $::STMT 1 $::bomstr 60\n    #catch {sqlite3_finalize $::STMT}\n    #if {[lindex [sqlite_malloc_stat] 2]<=0} {\n    #  error \"out of memory\"\n    #}\n  } -cleanup {\n    if {$::STMT!=\"\"} {\n      sqlite3_finalize $::STMT\n      set ::STMT {}\n    }\n  }\n}\n\n# This block tests that malloc() failures that occur whilst commiting\n# a multi-file transaction are handled correctly.\n#\ndo_malloc_test 9 -sqlprep {\n  ATTACH 'test2.db' as test2;\n  CREATE TABLE abc1(a, b, c);\n  CREATE TABLE test2.abc2(a, b, c);\n} -sqlbody {\n  BEGIN;\n  INSERT INTO abc1 VALUES(1, 2, 3);\n  INSERT INTO abc2 VALUES(1, 2, 3);\n  COMMIT;\n}\n\n# This block tests malloc() failures that occur while opening a \n# connection to a database.\ndo_malloc_test 10 -tclprep {\n  catch {db2 close}\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  sqlite3_extended_result_codes db 1\n  db eval {CREATE TABLE abc(a, b, c)}\n} -tclbody {\n  db close\n  sqlite3 db2 test.db\n  sqlite3_extended_result_codes db2 1\n  db2 eval {SELECT * FROM sqlite_master}\n  db2 close\n}\n\n# This block tests malloc() failures that occur within calls to\n# sqlite3_create_function().\ndo_malloc_test 11 -tclbody {\n  set rc [sqlite3_create_function db]\n  if {[string match $rc SQLITE_OK]} {\n    set rc [sqlite3_create_aggregate db]\n  }\n  if {[string match $rc SQLITE_NOMEM]} {\n    error \"out of memory\"\n  }\n}\n\ndo_malloc_test 12 -tclbody {\n  set sql16 [encoding convertto unicode \"SELECT * FROM sqlite_master\"]\n  append sql16 \"\\00\\00\"\n  set ::STMT [sqlite3_prepare16 db $sql16 -1 DUMMY]\n  sqlite3_finalize $::STMT\n}\n\n# Test malloc errors when replaying two hot journals from a 2-file \n# transaction.\nifcapable crashtest&&attach {\n  do_malloc_test 13 -tclprep {\n    set rc [crashsql -delay 1 -file test2.db {\n      ATTACH 'test2.db' as aux;\n      PRAGMA cache_size = 10;\n      BEGIN;\n      CREATE TABLE aux.t2(a, b, c);\n      CREATE TABLE t1(a, b, c);\n      COMMIT;\n    }]\n    if {$rc!=\"1 {child process exited abnormally}\"} {\n      error \"Wrong error message: $rc\"\n    }\n  } -tclbody {\n    db eval {ATTACH 'test2.db' as aux;}\n    set rc [catch {db eval {\n      SELECT * FROM t1; \n      SELECT * FROM t2;\n    }} err]\n    if {$rc && $err!=\"no such table: t1\"} {\n      error $err\n    }\n  }\n}\n\nif {$tcl_platform(platform)!=\"windows\"} {\n  do_malloc_test 14 -tclprep {\n    catch {db close}\n    sqlite3 db2 test2.db\n    sqlite3_extended_result_codes db2 1\n    db2 eval {\n      PRAGMA journal_mode = DELETE;    /* For inmemory_journal permutation */\n      PRAGMA synchronous = 0;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      BEGIN;\n      INSERT INTO t1 VALUES(3, 4);\n    }\n    forcecopy test2.db test.db\n    forcecopy test2.db-journal test.db-journal\n    db2 close\n  } -tclbody {\n    sqlite3 db test.db\n    sqlite3_extended_result_codes db 1\n\n    # If an out-of-memory occurs within a call to a VFS layer function during\n    # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit\n    # [5668] for details.\n    set rc [catch {db eval { SELECT * FROM t1 }} msg]\n    if {$msg eq \"database disk image is malformed\"} { set msg \"out of memory\" }\n    if {$rc} { error $msg }\n    set msg\n  }\n}\n\nproc string_compare {a b} {\n  return [string compare $a $b]\n}\n\n# Test for malloc() failures in sqlite3_create_collation() and \n# sqlite3_create_collation16().\n#\nifcapable utf16 {\n  do_malloc_test 15 -start 4 -tclbody {\n    db collate string_compare string_compare\n    if {[catch {add_test_collate db 1 1 1} msg]} {\n      if {$msg==\"SQLITE_NOMEM\"} {set msg \"out of memory\"}\n      error $msg\n    }\n  \n    db complete {SELECT \"hello \"\"\"||'world\"' [microsoft], * FROM anicetable;}\n    db complete {-- Useful comment}\n  \n    execsql {\n      CREATE TABLE t1(a, b COLLATE string_compare);\n      INSERT INTO t1 VALUES(10, 'string');\n      INSERT INTO t1 VALUES(10, 'string2');\n    }\n  }\n}\n\n# Also test sqlite3_complete(). There are (currently) no malloc()\n# calls in this function, but test anyway against future changes.\n#\ndo_malloc_test 16 -tclbody {\n  db complete {SELECT \"hello \"\"\"||'world\"' [microsoft], * FROM anicetable;}\n  db complete {-- Useful comment}\n  db eval {\n    SELECT * FROM sqlite_master;\n  }\n}\n\n# Test handling of malloc() failures in sqlite3_open16().\n#\nifcapable utf16 {\n  do_malloc_test 17 -tclbody {\n    set DB2 0\n    set STMT 0\n  \n    # open database using sqlite3_open16()\n    set filename [encoding convertto unicode test.db]\n    append filename \"\\x00\\x00\"\n    set DB2 [sqlite3_open16 $filename -unused]\n    if {0==$DB2} {\n      error \"out of memory\"\n    }\n    sqlite3_extended_result_codes $DB2 1\n  \n    # Prepare statement\n    set rc [catch {sqlite3_prepare $DB2 {SELECT * FROM sqlite_master} -1 X} msg]\n    if {[sqlite3_errcode $DB2] eq \"SQLITE_IOERR+12\"} {\n      error \"out of memory\"\n    }\n    if {[regexp \".*automatic extension loading.*\" [sqlite3_errmsg $DB2]]} {\n      error \"out of memory\"\n    }\n    if {$rc} {\n      error [string range $msg 4 end]\n    }\n    set STMT $msg\n  \n    # Finalize statement\n    set rc [sqlite3_finalize $STMT]\n    if {$rc!=\"SQLITE_OK\"} {\n      error [sqlite3_errmsg $DB2]\n    }\n    set STMT 0\n  \n    # Close database\n    set rc [sqlite3_close $DB2]\n    if {$rc!=\"SQLITE_OK\"} {\n      error [sqlite3_errmsg $DB2]\n    }\n    set DB2 0\n  } -cleanup {\n    if {$STMT!=\"0\"} {\n      sqlite3_finalize $STMT\n    }\n    if {$DB2!=\"0\"} {\n      set rc [sqlite3_close $DB2]\n    }\n  }\n}\n\n# Test handling of malloc() failures in sqlite3_errmsg16().\n#\nifcapable utf16 {\n  do_malloc_test 18 -tclprep {\n    catch {\n      db eval \"SELECT [string repeat longcolumnname 10] FROM sqlite_master\"\n    }\n  } -tclbody {\n    set utf16 [sqlite3_errmsg16 [sqlite3_connection_pointer db]]\n    binary scan $utf16 c* bytes\n    if {[llength $bytes]==0} {\n      error \"out of memory\"\n    }\n  }\n}\n\n# This test is aimed at coverage testing. Specificly, it is supposed to\n# cause a malloc() only used when converting between the two utf-16 \n# encodings to fail (i.e. little-endian->big-endian). It only actually \n# hits this malloc() on little-endian hosts.\n#\nset static_string \"\\x00h\\x00e\\x00l\\x00l\\x00o\"\nfor {set l 0} {$l<10} {incr l} {\n  append static_string $static_string\n}\nappend static_string \"\\x00\\x00\"\ndo_malloc_test 19 -tclprep {\n  execsql {\n    PRAGMA encoding = \"UTF16be\";\n    CREATE TABLE abc(a, b, c);\n  }\n} -tclbody {\n  unset -nocomplain ::STMT\n  set r [catch {\n    set ::STMT [sqlite3_prepare db {SELECT ?} -1 DUMMY]\n    sqlite3_bind_text16 -static $::STMT 1 $static_string 112\n  } msg]\n  if {$r} {error [string range $msg 4 end]}\n  set msg\n} -cleanup {\n  if {[info exists ::STMT]} {\n    sqlite3_finalize $::STMT\n  }\n}\nunset static_string\n\n# Make sure SQLITE_NOMEM is reported out on an ATTACH failure even\n# when the malloc failure occurs within the nested parse.\n#\nifcapable attach {\n  do_malloc_test 20 -tclprep {\n    db close\n    forcedelete test2.db test2.db-journal\n    sqlite3 db test2.db\n    sqlite3_extended_result_codes db 1\n    db eval {CREATE TABLE t1(x);}\n    db close\n  } -tclbody {\n    if {[catch {sqlite3 db test.db}]} {\n      error \"out of memory\"\n    }\n    sqlite3_extended_result_codes db 1\n  } -sqlbody {\n    ATTACH DATABASE 'test2.db' AS t2;\n    SELECT * FROM t1;\n    DETACH DATABASE t2;\n  } \n}\n\n# Test malloc failure whilst installing a foreign key.\n#\nifcapable foreignkey {\n  do_malloc_test 21 -sqlbody {\n    CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))\n  } \n}\n\n# Test malloc failure in an sqlite3_prepare_v2() call.\n#\ndo_malloc_test 22 -tclbody {\n  set ::STMT \"\"\n  set r [catch {\n    set ::STMT [\n      sqlite3_prepare_v2 db \"SELECT * FROM sqlite_master\" -1 DUMMY\n    ]\n  } msg]\n  if {$r} {error [string range $msg 4 end]}\n} -cleanup {\n  if {$::STMT ne \"\"} {\n    sqlite3_finalize $::STMT\n    set ::STMT \"\"\n  }\n}\n\nifcapable {pager_pragmas} {\n  # This tests a special case - that an error that occurs while the pager\n  # is trying to recover from error-state in exclusive-access mode works.\n  #\n  do_malloc_test 23 -tclprep {\n    db eval {\n      PRAGMA cache_size = 10;\n      PRAGMA locking_mode = exclusive;\n      BEGIN;\n      CREATE TABLE abc(a, b, c);\n      CREATE INDEX abc_i ON abc(a, b, c);\n      INSERT INTO abc \n        VALUES(randstr(100,100), randstr(100,100), randstr(100,100));\n      INSERT INTO abc \n        SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n      INSERT INTO abc \n        SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n      INSERT INTO abc \n        SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n      INSERT INTO abc \n        SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n      INSERT INTO abc \n        SELECT randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n      COMMIT;\n    }\n  \n    # This puts the pager into error state.\n    #\n    db eval BEGIN\n    db eval {UPDATE abc SET a = 0 WHERE oid%2}\n    set ::sqlite_io_error_pending 10\n    catch {db eval {ROLLBACK}} msg\n\n  } -tclbody {\n    # If an out-of-memory occurs within a call to a VFS layer function during\n    # hot-journal rollback, sqlite will report SQLITE_CORRUPT. See commit\n    # [5668] for details.\n    set rc [catch {db eval { SELECT * FROM abc LIMIT 10 }} msg]\n    if {$msg eq \"database disk image is malformed\"} { set msg \"out of memory\" }\n    if {$rc} { error $msg }\n    set msg\n  } -cleanup {\n    set e [db eval {PRAGMA integrity_check}]\n    if {$e ne \"ok\"} {error $e}\n  }\n}\n\nifcapable compound {\n  do_malloc_test 24 -sqlprep {\n    CREATE TABLE t1(a, b, c)\n  } -sqlbody {\n    SELECT 1 FROM t1 UNION SELECT 2 FROM t1 ORDER BY 1\n  }\n}\n\nifcapable view&&trigger {\n  do_malloc_test 25 -sqlprep {\n    CREATE TABLE t1(a, b, c);\n    CREATE VIEW v1 AS SELECT * FROM t1;\n    CREATE TRIGGER v1t1 INSTEAD OF DELETE ON v1 BEGIN SELECT 1; END;\n    CREATE TRIGGER v1t2 INSTEAD OF INSERT ON v1 BEGIN SELECT 1; END;\n    CREATE TRIGGER v1t3 INSTEAD OF UPDATE ON v1 BEGIN SELECT 1; END;\n  } -sqlbody {\n    DELETE FROM v1 WHERE a = 1;\n    INSERT INTO v1 VALUES(1, 2, 3);\n    UPDATE v1 SET a = 1 WHERE b = 2;\n  }\n}\n\ndo_malloc_test 25 -sqlprep {\n  CREATE TABLE abc(a, b, c);\n  CREATE INDEX i1 ON abc(a, b);\n  INSERT INTO abc VALUES(1, 2, 3);\n  INSERT INTO abc VALUES(4, 5, 6);\n} -tclbody {\n  # For each UPDATE executed, the cursor used for the SELECT statement\n  # must be \"saved\". Because the cursor is open on an index, this requires\n  # a malloc() to allocate space to save the index key. This test case is\n  # aimed at testing the response of the library to a failure in that\n  # particular malloc() call.\n  db eval {SELECT a FROM abc ORDER BY a} {\n    db eval {UPDATE abc SET b = b - 1 WHERE a = $a}\n  }\n}\n\n# This test is designed to test a specific juncture in the sqlite code.\n# The database set up by -sqlprep script contains a single table B-Tree\n# of height 2. In the -tclbody script, the existing database connection\n# is closed and a new one opened and used to insert a new row into the\n# table B-Tree. By using a new connection, the outcome of a malloc() \n# failure while seeking to the right-hand side of the B-Tree to insert \n# a new record can be tested.\n#\ndo_malloc_test 26 -sqlprep {\n  BEGIN;\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, randomblob(210));\n  INSERT INTO t1 VALUES(1, randomblob(210));\n  INSERT INTO t1 VALUES(1, randomblob(210));\n  INSERT INTO t1 VALUES(1, randomblob(210));\n  INSERT INTO t1 VALUES(1, randomblob(210));\n  COMMIT;\n} -tclbody {\n  db close\n  sqlite3 db test.db\n  db eval { INSERT INTO t1 VALUES(1, randomblob(210)) }\n}\n\n# Test that no memory is leaked following a malloc() failure in\n# sqlite3_initialize().\n#\ndo_malloc_test 27 -tclprep {\n  db close\n  sqlite3_shutdown\n} -tclbody {\n  set rc [sqlite3_initialize]\n  if {$rc == \"SQLITE_NOMEM\"} {\n    error \"out of memory\"\n  }\n}\nautoinstall_test_functions\n\n# Test that malloc failures that occur while processing INDEXED BY\n# clauses are handled correctly.\ndo_malloc_test 28 -sqlprep {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n  CREATE VIEW v1 AS SELECT * FROM t1 INDEXED BY i1 WHERE a = 10;\n} -sqlbody {\n  SELECT * FROM t1 INDEXED BY i1 ORDER BY a;\n  SELECT * FROM v1;\n}\n\ndo_malloc_test 29 -sqlprep {\n  CREATE TABLE t1(a TEXT, b TEXT);\n} -sqlbody {\n  INSERT INTO t1 VALUES(1, -234);\n  INSERT INTO t1 SELECT * FROM t1 UNION ALL SELECT * FROM t1;\n}\n\ndo_malloc_test 30 -tclprep {\n  db eval {\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES(randstr(500,500));\n    INSERT INTO t1 VALUES(randstr(500,500));\n    INSERT INTO t1 VALUES(randstr(500,500));\n  }\n  db close\n  sqlite3 db test.db\n\n  # The DELETE command in the following block moves the overflow pages that\n  # are part of the primary key index to the free-list. But it does not\n  # actually load the content of the pages. This leads to the peculiar\n  # situation where cache entries exist, but are not populated with data.\n  # They are populated next time they are requested by the b-tree layer.\n  #\n  db eval {\n    BEGIN;\n      DELETE FROM t1;\n    ROLLBACK;\n  }\n} -sqlbody {\n  -- This statement requires the 'no-content' pages loaded by the DELETE\n  -- statement above. When requesting the pages, the content is loaded\n  -- from the database file. The point of this test case is to test handling\n  -- of malloc errors (including SQLITE_IOERR_NOMEM errors) when loading\n  -- the content.\n  SELECT * FROM t1 ORDER BY x;\n}\n\n# After committing a transaction in persistent-journal mode, if a journal\n# size limit is configured SQLite may attempt to truncate the journal file.\n# This test verifies the libraries response to a malloc() failure during\n# this operation.\n#\ndo_malloc_test 31 -sqlprep {\n  PRAGMA journal_mode = persist;\n  PRAGMA journal_size_limit = 1024;\n  CREATE TABLE t1(a PRIMARY KEY, b);\n} -sqlbody {\n  INSERT INTO t1 VALUES(1, 2);\n}\n\n# When written, this test provoked an obscure change-counter bug.\n# \n# If, when running in exclusive mode, a malloc() failure occurs\n# after the database file change-counter has been written but\n# before the transaction has been committed, then the transaction\n# is automatically rolled back. However, internally the \n# Pager.changeCounterDone flag was being left set. This means\n# that if the same connection attempts another transaction following\n# the malloc failure and rollback, the change counter will not\n# be updated. This could corrupt another processes cache.\n#\ndo_malloc_test 32 -tclprep {\n  # Build a small database containing an indexed table.\n  #\n  db eval {\n    PRAGMA locking_mode = normal;\n    BEGIN;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n    COMMIT;\n    PRAGMA locking_mode = exclusive;\n  }\n\n  # Open a second database connection. Load the table (but not index)\n  # into the second connections pager cache.\n  #\n  sqlite3 db2 test.db\n  db2 eval { \n    PRAGMA locking_mode = normal;\n    SELECT b FROM t1;\n  }\n\n} -tclbody {\n  # Running in exclusive mode, perform a database transaction that \n  # modifies both the database table and index. For iterations where\n  # the malloc failure occurs after updating the change counter but\n  # before committing the transaction, this should result in the\n  # transaction being rolled back but the changeCounterDone flag\n  # left set.\n  #\n  db eval { UPDATE t1 SET a = a + 3 }\n} -cleanup {\n\n  # Perform another transaction using the first connection. Unlock\n  # the database after doing so. If this is one of the right iterations,\n  # then this should result in the database contents being updated but\n  # the change-counter left as it is.\n  #\n  db eval { \n    PRAGMA locking_mode = normal;\n    UPDATE t1 SET a = a + 3;\n  }\n\n  # Now do an integrity check with the second connection. The second\n  # connection still has the database table in its cache. If this is\n  # one of the magic iterations and the change counter was not modified,\n  # then it won't realize that the cached data is out of date. Since\n  # the cached data won't match the up to date index data read from\n  # the database file, the integrity check should fail.\n  #\n  set zRepeat \"transient\"\n  if {$::iRepeat} {set zRepeat \"persistent\"}\n  do_test malloc-32.$zRepeat.${::n}.integrity {\n    execsql {PRAGMA integrity_check} db2\n  } {ok}\n  db2 close\n}\n\n# The following two OOM tests verify that OOM handling works in the\n# code used to optimize \"SELECT count(*) FROM <tbl>\".\n#\ndo_malloc_test 33 -tclprep {\n  db eval { PRAGMA cache_size = 10 }\n  db transaction {\n    db eval { CREATE TABLE abc(a, b) }\n    for {set i 0} {$i<500} {incr i} {\n      db eval {INSERT INTO abc VALUES(randstr(100,100), randstr(1000,1000))}\n    }\n  }\n} -sqlbody {\n  SELECT count(*) FROM abc;\n}\ndo_malloc_test 34 -tclprep {\n  db eval { PRAGMA cache_size = 10 }\n  db transaction {\n    db eval { CREATE TABLE abc(a PRIMARY KEY, b) }\n    for {set i 0} {$i<500} {incr i} {\n      db eval {INSERT INTO abc VALUES(randstr(100,100), randstr(1000,1000))}\n    }\n  }\n} -sqlbody {\n  SELECT count(*) FROM abc;\n}\n\nproc f {args} { error \"Quite a long error!\" }\ndo_malloc_test 35 -tclprep {\n  db func f f\n  set ::STMT [sqlite3_prepare db \"SELECT f()\" -1 DUMMY]\n  sqlite3_step $::STMT\n} -tclbody {\n  sqlite3_finalize $::STMT\n} -cleanup {\n  # At one point an assert( !db->mallocFailed ) could fail in the following\n  # call to sqlite3_errmsg(). Because sqlite3_finalize() had failed to clear\n  # the flag before returning.\n  sqlite3_errmsg16 db\n}\n\ndo_malloc_test 36 -sqlprep {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n} -sqlbody {\n  SELECT test_agg_errmsg16(), group_concat(a) FROM t1\n}\n\n# At one point, if an OOM occurred immediately after obtaining a shared lock\n# on the database file, the file remained locked. This test case ensures\n# that bug has been fixed.i\nif {[db eval {PRAGMA locking_mode}]!=\"exclusive\"} {\n  do_malloc_test 37 -tclprep {\n    sqlite3 db2 test.db\n    execsql {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    } db2\n  } -sqlbody {\n    SELECT * FROM t1;\n  } -cleanup {\n    # Try to write to the database using connection [db2]. If connection [db]\n    # has correctly released the shared lock, this write attempt should \n    # succeed. If [db] has not released the lock, this should hit an \n    # SQLITE_BUSY error.\n    do_test malloc-36.$zRepeat.${::n}.unlocked {\n      execsql {INSERT INTO t1 VALUES(3, 4)} db2\n    } {}\n    db2 close\n  }\n  catch { db2 close }\n}\n\n\n# Test that if an OOM error occurs, aux-data is still correctly destroyed.\n# This test case was causing either a memory-leak or an assert() failure\n# at one point, depending on the configuration.\n#\ndo_malloc_test 39 -tclprep {\n  sqlite3 db test.db\n} -sqlbody {\n  SELECT test_auxdata('abc', 'def');\n} -cleanup {\n  db close\n}\n\nreset_db\nadd_test_utf16bin_collate db\ndo_execsql_test 40.1 {\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES('fghij');\n  INSERT INTO t1 VALUES('pqrst');\n  INSERT INTO t1 VALUES('abcde');\n  INSERT INTO t1 VALUES('uvwxy');\n  INSERT INTO t1 VALUES('klmno');\n}\ndo_execsql_test 40.2 {\n  SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin;\n} {abcde fghij klmno pqrst uvwxy}\ndo_faultsim_test 40.3 -faults oom-trans* -body {\n  execsql {\n    SELECT * FROM t1 ORDER BY 1 COLLATE utf16bin;\n  }\n} -test {\n  faultsim_test_result {0 {abcde fghij klmno pqrst uvwxy}} \n  faultsim_integrity_check\n}\n\nreset_db\nadd_test_utf16bin_collate db\nset big [string repeat x 200]\ndo_execsql_test 41.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a COLLATE utf16bin);\n  INSERT INTO t1 VALUES('fghij' || $::big);\n  INSERT INTO t1 VALUES('pqrst' || $::big);\n  INSERT INTO t1 VALUES('abcde' || $::big);\n  INSERT INTO t1 VALUES('uvwxy' || $::big);\n  INSERT INTO t1 VALUES('klmno' || $::big);\n  CREATE INDEX i1 ON t1(a);\n}\ndo_faultsim_test 41.2 -faults oom* -body {\n  execsql { SELECT * FROM t1 WHERE a = ('abcde' || $::big)}\n} -test {\n  faultsim_test_result [list 0 \"abcde$::big\"]\n  faultsim_integrity_check\n}\n\nreset_db\ndo_execsql_test 42.0 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY, y, z);\n  CREATE TABLE t2(a, b);\n  CREATE VIEW a002 AS SELECT *, sum(b) AS m FROM t2 GROUP BY a;\n}\nfaultsim_save_and_close\ndo_faultsim_test 42 -faults oom-tran* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM sqlite_master }\n} -body {\n  execsql {\n    SELECT t1.z, a002.m\n    FROM t1 JOIN a002 ON t1.y=a002.m\n    WHERE t1.x IN (1,2,3);\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-99.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nputs open-file-count=$sqlite_open_file_count\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc3.test",
    "content": "# 2005 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests to ensure that the library handles malloc() failures\n# correctly. The emphasis of these tests are the _prepare(), _step() and\n# _finalize() calls.\n#\n# $Id: malloc3.test,v 1.24 2008/10/14 15:54:08 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc3 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n\n# Do not run these tests with an in-memory journal.\n#\n# In the pager layer, if an IO or OOM error occurs during a ROLLBACK, or\n# when flushing a page to disk due to cache-stress, the pager enters an\n# \"error state\". The only way out of the error state is to unlock the\n# database file and end the transaction, leaving whatever journal and\n# database files happen to be on disk in place. The next time the current\n# (or any other) connection opens a read transaction, hot-journal rollback\n# is performed if necessary.\n#\n# Of course, this doesn't work with an in-memory journal.\n#\nif {[permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\n#--------------------------------------------------------------------------\n# NOTES ON RECOVERING FROM A MALLOC FAILURE\n# \n# The tests in this file test the behaviours described in the following\n# paragraphs. These tests test the behaviour of the system when malloc() fails\n# inside of a call to _prepare(), _step(), _finalize() or _reset(). The\n# handling of malloc() failures within ancillary procedures is tested\n# elsewhere.\n#\n# Overview:\n#\n# Executing a statement is done in three stages (prepare, step and finalize). A\n# malloc() failure may occur within any stage. If a memory allocation fails\n# during statement preparation, no statement handle is returned. From the users\n# point of view the system state is as if _prepare() had never been called.\n#\n# If the memory allocation fails during the _step() or _finalize() calls, then\n# the database may be left in one of two states (after finalize() has been\n# called):\n#\n#     * As if the neither _step() nor _finalize() had ever been called on\n#       the statement handle (i.e. any changes made by the statement are\n#       rolled back).\n#     * The current transaction may be rolled back. In this case a hot-journal\n#       may or may not actually be present in the filesystem.\n#\n# The caller can tell the difference between these two scenarios by invoking\n# _get_autocommit().\n#\n#\n# Handling of sqlite3_reset():\n#\n# If a malloc() fails while executing an sqlite3_reset() call, this is handled\n# in the same way as a failure within _finalize(). The statement handle\n# is not deleted and must be passed to _finalize() for resource deallocation.\n# Attempting to _step() or _reset() the statement after a failed _reset() will\n# always return SQLITE_NOMEM.\n#\n#\n# Other active SQL statements:\n#\n# The effect of a malloc failure on concurrently executing SQL statements,\n# particularly when the statement is executing with READ_UNCOMMITTED set and\n# the malloc() failure mandates statement rollback only. Currently, if\n# transaction rollback is required, all other vdbe's are aborted.\n#\n#     Non-transient mallocs in btree.c:\n#         * The Btree structure itself\n#         * Each BtCursor structure\n#\n#     Mallocs in pager.c:\n#         readMasterJournal()  - Space to read the master journal name\n#         pager_delmaster()    - Space for the entire master journal file\n#\n#         sqlite3pager_open()  - The pager structure itself\n#         sqlite3_pagerget()   - Space for a new page\n#         pager_open_journal() - Pager.aInJournal[] bitmap\n#         sqlite3pager_write() - For in-memory databases only: history page and\n#                                statement history page.\n#         pager_stmt_begin()   - Pager.aInStmt[] bitmap\n#\n# None of the above are a huge problem. The most troublesome failures are the\n# transient malloc() calls in btree.c, which can occur during the tree-balance\n# operation. This means the tree being balanced will be internally inconsistent\n# after the malloc() fails. To avoid the corrupt tree being read by a\n# READ_UNCOMMITTED query, we have to make sure the transaction or statement\n# rollback occurs before sqlite3_step() returns, not during a subsequent\n# sqlite3_finalize().\n#--------------------------------------------------------------------------\n\n#--------------------------------------------------------------------------\n# NOTES ON TEST IMPLEMENTATION\n#\n# The tests in this file are implemented differently from those in other\n# files. Instead, tests are specified using three primitives: SQL, PREP and\n# TEST. Each primitive has a single argument. Primitives are processed in\n# the order they are specified in the file.\n#\n# A TEST primitive specifies a TCL script as its argument. When a TEST\n# directive is encountered the Tcl script is evaluated. Usually, this Tcl\n# script contains one or more calls to [do_test].\n#\n# A PREP primitive specifies an SQL script as its argument. When a PREP\n# directive is encountered the SQL is evaluated using database connection\n# [db].\n#\n# The SQL primitives are where the action happens. An SQL primitive must\n# contain a single, valid SQL statement as its argument. When an SQL\n# primitive is encountered, it is evaluated one or more times to test the\n# behaviour of the system when malloc() fails during preparation or\n# execution of said statement. The Nth time the statement is executed,\n# the Nth malloc is said to fail. The statement is executed until it\n# succeeds, i.e. (M+1) times, where M is the number of mallocs() required\n# to prepare and execute the statement.\n#\n# Each time an SQL statement fails, the driver program (see proc [run_test]\n# below) figures out if a transaction has been automatically rolled back.\n# If not, it executes any TEST block immediately proceeding the SQL\n# statement, then reexecutes the SQL statement with the next value of N.\n#\n# If a transaction has been automatically rolled back, then the driver\n# program executes all the SQL specified as part of SQL or PREP primitives\n# between the current SQL statement and the most recent \"BEGIN\". Any \n# TEST block immediately proceeding the SQL statement is evaluated, and\n# then the SQL statement reexecuted with the incremented N value.\n#\n# That make any sense? If not, read the code in [run_test] and it might.\n#\n# Extra restriction imposed by the implementation:\n#\n# * If a PREP block starts a transaction, it must finish it.\n# * A PREP block may not close a transaction it did not start.\n#\n#--------------------------------------------------------------------------\n\n\n# These procs are used to build up a \"program\" in global variable\n# ::run_test_script. At the end of this file, the proc [run_test] is used\n# to execute the program (and all test cases contained therein).\n#\nset ::run_test_sql_id 0\nset ::run_test_script [list]\nproc TEST {id t} {lappend ::run_test_script -test [list $id $t]}\nproc PREP {p} {lappend ::run_test_script -prep [string trim $p]}\nproc DEBUG {s} {lappend ::run_test_script -debug $s}\n\n# SQL --\n#\n#     SQL ?-norollback? <sql-text>\n#\n# Add an 'SQL' primitive to the program (see notes above). If the -norollback\n# switch is present, then the statement is not allowed to automatically roll\n# back any active transaction if malloc() fails. It must rollback the statement\n# transaction only.\n#\nproc SQL  {a1 {a2 \"\"}} {\n  # An SQL primitive parameter is a list of three elements, an id, a boolean\n  # value indicating if the statement may cause transaction rollback when\n  # malloc() fails, and the sql statement itself.\n  set id [incr ::run_test_sql_id]\n  if {$a2 == \"\"} {\n    lappend ::run_test_script -sql [list $id true [string trim $a1]]\n  } else {\n    lappend ::run_test_script -sql [list $id false [string trim $a2]]\n  }\n}\n\n# TEST_AUTOCOMMIT --\n# \n#     A shorthand test to see if a transaction is active or not. The first\n#     argument - $id - is the integer number of the test case. The second\n#     argument is either 1 or 0, the expected value of the auto-commit flag.\n#\nproc TEST_AUTOCOMMIT {id a} {\n    TEST $id \"do_test \\$testid { sqlite3_get_autocommit \\$::DB } {$a}\"\n}\n\n#--------------------------------------------------------------------------\n# Start of test program declaration\n#\n\n\n# Warm body test. A malloc() fails in the middle of a CREATE TABLE statement\n# in a single-statement transaction on an empty database. Not too much can go\n# wrong here.\n#\nTEST 1 {\n  do_test $testid {\n    execsql {SELECT tbl_name FROM sqlite_master;}\n  } {}\n}\nSQL { \n  CREATE TABLE IF NOT EXISTS abc(a, b, c); \n}\nTEST 2 {\n  do_test $testid.1 {\n    execsql {SELECT tbl_name FROM sqlite_master;}\n  } {abc}\n}\n\n# Insert a couple of rows into the table. each insert is in its own\n# transaction. test that the table is unpopulated before running the inserts\n# (and hence after each failure of the first insert), and that it has been\n# populated correctly after the final insert succeeds.\n#\nTEST 3 {\n  do_test $testid.2 {\n    execsql {SELECT * FROM abc}\n  } {}\n}\nSQL {INSERT INTO abc VALUES(1, 2, 3);}\nSQL {INSERT INTO abc VALUES(4, 5, 6);}\nSQL {INSERT INTO abc VALUES(7, 8, 9);}\nTEST 4 {\n  do_test $testid {\n    execsql {SELECT * FROM abc}\n  } {1 2 3 4 5 6 7 8 9}\n}\n\n# Test a CREATE INDEX statement. Because the table 'abc' is so small, the index\n# will all fit on a single page, so this doesn't test too much that the CREATE\n# TABLE statement didn't test. A few of the transient malloc()s in btree.c\n# perhaps.\n#\nSQL {CREATE INDEX abc_i ON abc(a, b, c);}\nTEST 4 {\n  do_test $testid {\n    execsql {\n      SELECT * FROM abc ORDER BY a DESC;\n    }\n  } {7 8 9 4 5 6 1 2 3}\n}\n\n# Test a DELETE statement. Also create a trigger and a view, just to make sure\n# these statements don't have any obvious malloc() related bugs in them. Note\n# that the test above will be executed each time the DELETE fails, so we're\n# also testing rollback of a DELETE from a table with an index on it.\n#\nSQL {DELETE FROM abc WHERE a > 2;}\nSQL {CREATE TRIGGER abc_t AFTER INSERT ON abc BEGIN SELECT 'trigger!'; END;}\nSQL {CREATE VIEW abc_v AS SELECT * FROM abc;}\nTEST 5 {\n  do_test $testid {\n    execsql {\n      SELECT name, tbl_name FROM sqlite_master ORDER BY name;\n      SELECT * FROM abc;\n    }\n  } {abc abc abc_i abc abc_t abc abc_v abc_v 1 2 3}\n}\n\nset sql {\n  BEGIN;DELETE FROM abc;\n}\nfor {set i 1} {$i < 100} {incr i} {\n  set a $i\n  set b \"String value $i\"\n  set c [string repeat X $i]\n  append sql \"INSERT INTO abc VALUES ($a, '$b', '$c');\"\n}\nappend sql {COMMIT;}\nPREP $sql\n\nSQL {\n  DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);\n}\nTEST 6 {\n  do_test $testid.1 {\n    execsql {SELECT count(*) FROM abc}\n  } {94}\n  do_test $testid.2 {\n    execsql {\n      SELECT min(\n          (oid == a) AND 'String value ' || a == b AND a == length(c) \n      ) FROM abc;\n    }\n  } {1}\n}\nSQL {\n  DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);\n}\nTEST 7 {\n  do_test $testid {\n    execsql {SELECT count(*) FROM abc}\n  } {89}\n  do_test $testid {\n    execsql {\n      SELECT min(\n          (oid == a) AND 'String value ' || a == b AND a == length(c) \n      ) FROM abc;\n    }\n  } {1}\n}\nSQL {\n  DELETE FROM abc WHERE oid IN (SELECT oid FROM abc ORDER BY random() LIMIT 5);\n}\nTEST 9 {\n  do_test $testid {\n    execsql {SELECT count(*) FROM abc}\n  } {84}\n  do_test $testid {\n    execsql {\n      SELECT min(\n          (oid == a) AND 'String value ' || a == b AND a == length(c) \n      ) FROM abc;\n    }\n  } {1}\n}\n\nset padding [string repeat X 500]\nPREP [subst {\n  DROP TABLE abc;\n  CREATE TABLE abc(a PRIMARY KEY, padding, b, c);\n  INSERT INTO abc VALUES(0, '$padding', 2, 2);\n  INSERT INTO abc VALUES(3, '$padding', 5, 5);\n  INSERT INTO abc VALUES(6, '$padding', 8, 8);\n}]\n\nTEST 10 {\n  do_test $testid {\n    execsql {SELECT a, b, c FROM abc}\n  } {0 2 2 3 5 5 6 8 8}\n}\n\nSQL {BEGIN;}\nSQL {INSERT INTO abc VALUES(9, 'XXXXX', 11, 12);}\nTEST_AUTOCOMMIT 11 0\nSQL -norollback {UPDATE abc SET a = a + 1, c = c + 1;}\nTEST_AUTOCOMMIT 12 0\nSQL {DELETE FROM abc WHERE a = 10;}\nTEST_AUTOCOMMIT 13 0\nSQL {COMMIT;}\n\nTEST 14 {\n  do_test $testid.1 {\n    sqlite3_get_autocommit $::DB\n  } {1}\n  do_test $testid.2 {\n    execsql {SELECT a, b, c FROM abc}\n  } {1 2 3 4 5 6 7 8 9}\n}\n\nPREP [subst {\n  DROP TABLE abc;\n  CREATE TABLE abc(a, padding, b, c);\n  INSERT INTO abc VALUES(1, '$padding', 2, 3);\n  INSERT INTO abc VALUES(4, '$padding', 5, 6);\n  INSERT INTO abc VALUES(7, '$padding', 8, 9);\n  CREATE INDEX abc_i ON abc(a, padding, b, c);\n}]\n\nTEST 15 {\n  db eval {PRAGMA cache_size = 10}\n}\n\nSQL {BEGIN;}\nSQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}\nTEST 16 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 2 4 2 7 2}\n}\nSQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}\nTEST 17 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 4 4 4 7 4}\n}\nSQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}\nTEST 18 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 8 4 8 7 8}\n}\nSQL -norllbck {INSERT INTO abc (oid, a, padding, b, c) SELECT NULL, * FROM abc}\nTEST 19 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 16 4 16 7 16}\n}\nSQL {COMMIT;}\nTEST 21 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 16 4 16 7 16}\n}\n\nSQL {BEGIN;}\nSQL {DELETE FROM abc WHERE oid %2}\nTEST 22 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 8 4 8 7 8}\n}\nSQL {DELETE FROM abc}\nTEST 23 {\n  do_test $testid {\n    execsql {SELECT * FROM abc}\n  } {}\n}\nSQL {ROLLBACK;}\nTEST 24 {\n  do_test $testid {\n    execsql {SELECT a, count(*) FROM abc GROUP BY a;}\n  } {1 16 4 16 7 16}\n}\n\n# Test some schema modifications inside of a transaction. These should all\n# cause transaction rollback if they fail. Also query a view, to cover a bit\n# more code.\n#\nPREP {DROP VIEW abc_v;}\nTEST 25 {\n  do_test $testid {\n    execsql {\n      SELECT name, tbl_name FROM sqlite_master;\n    }\n  } {abc abc abc_i abc}\n}\nSQL {BEGIN;}\nSQL {CREATE TABLE def(d, e, f);}\nSQL {CREATE TABLE ghi(g, h, i);}\nTEST 26 {\n  do_test $testid {\n    execsql {\n      SELECT name, tbl_name FROM sqlite_master;\n    }\n  } {abc abc abc_i abc def def ghi ghi}\n}\nSQL {CREATE VIEW v1 AS SELECT * FROM def, ghi}\nSQL {CREATE UNIQUE INDEX ghi_i1 ON ghi(g);}\nTEST 27 {\n  do_test $testid {\n    execsql {\n      SELECT name, tbl_name FROM sqlite_master;\n    }\n  } {abc abc abc_i abc def def ghi ghi v1 v1 ghi_i1 ghi}\n}\nSQL {INSERT INTO def VALUES('a', 'b', 'c')}\nSQL {INSERT INTO def VALUES(1, 2, 3)}\nSQL -norollback {INSERT INTO ghi SELECT * FROM def}\nTEST 28 {\n  do_test $testid {\n    execsql {\n      SELECT * FROM def, ghi WHERE d = g;\n    }\n  } {a b c a b c 1 2 3 1 2 3}\n}\nSQL {COMMIT}\nTEST 29 {\n  do_test $testid {\n    execsql {\n      SELECT * FROM v1 WHERE d = g;\n    }\n  } {a b c a b c 1 2 3 1 2 3}\n}\n\n# Test a simple multi-file transaction \n#\nforcedelete test2.db\nifcapable attach {\n  SQL {ATTACH 'test2.db' AS aux;}\n  SQL {BEGIN}\n  SQL {CREATE TABLE aux.tbl2(x, y, z)}\n  SQL {INSERT INTO tbl2 VALUES(1, 2, 3)}\n  SQL {INSERT INTO def VALUES(4, 5, 6)}\n  TEST 30 {\n    do_test $testid {\n      execsql {\n        SELECT * FROM tbl2, def WHERE d = x;\n      }\n    } {1 2 3 1 2 3}\n  }\n  SQL {COMMIT}\n  TEST 31 {\n    do_test $testid {\n      execsql {\n        SELECT * FROM tbl2, def WHERE d = x;\n      }\n    } {1 2 3 1 2 3}\n  }\n}\n\n# Test what happens when a malloc() fails while there are other active\n# statements. This changes the way sqlite3VdbeHalt() works.\nTEST 32 {\n  if {![info exists ::STMT32]} {\n    set sql \"SELECT name FROM sqlite_master\"\n    set ::STMT32 [sqlite3_prepare $::DB $sql -1 DUMMY]\n    do_test $testid {\n      sqlite3_step $::STMT32\n    } {SQLITE_ROW}\n  }\n}\nSQL BEGIN\nTEST 33 { \n  do_test $testid {\n    execsql {SELECT * FROM ghi}\n  } {a b c 1 2 3}\n}\nSQL -norollback { \n  -- There is a unique index on ghi(g), so this statement may not cause\n  -- an automatic ROLLBACK. Hence the \"-norollback\" switch.\n  INSERT INTO ghi SELECT '2'||g, h, i FROM ghi;\n}\nTEST 34 {\n  if {[info exists ::STMT32]} {\n    do_test $testid {\n      sqlite3_finalize $::STMT32\n    } {SQLITE_OK}\n    unset ::STMT32\n  }\n}\nSQL COMMIT\n\n#\n# End of test program declaration\n#--------------------------------------------------------------------------\n\nproc run_test {arglist iRepeat {pcstart 0} {iFailStart 1}} {\n  if {[llength $arglist] %2} {\n    error \"Uneven number of arguments to TEST\"\n  }\n\n  for {set i 0} {$i < $pcstart} {incr i} {\n    set k2 [lindex $arglist [expr {2 * $i}]]\n    set v2 [lindex $arglist [expr {2 * $i + 1}]]\n    set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit\n    switch -- $k2 {\n      -sql  {db eval [lindex $v2 2]}\n      -prep {db eval $v2}\n      -debug {eval $v2}\n    }\n    set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit \n    if {$ac && !$nac} {set begin_pc $i}\n  }\n\n  db rollback_hook [list incr ::rollback_hook_count]\n\n  set iFail $iFailStart\n  set pc $pcstart\n  while {$pc*2 < [llength $arglist]} {\n    # Fetch the current instruction type and payload.\n    set k [lindex $arglist [expr {2 * $pc}]]\n    set v [lindex $arglist [expr {2 * $pc + 1}]]\n\n    # Id of this iteration:\n    set iterid \"pc=$pc.iFail=$iFail$k\"\n\n    switch -- $k {\n\n      -test { \n        foreach {id script} $v {}\n        set testid \"malloc3-(test $id).$iterid\"\n        eval $script\n        incr pc\n      }\n\n      -sql {\n        set ::rollback_hook_count 0\n\n        set id [lindex $v 0]\n        set testid \"malloc3-(integrity $id).$iterid\"\n\n        set ac [sqlite3_get_autocommit $::DB]        ;# Auto-Commit\n        sqlite3_memdebug_fail $iFail -repeat 0\n        set rc [catch {db eval [lindex $v 2]} msg]   ;# True error occurs\n        set nac [sqlite3_get_autocommit $::DB]       ;# New Auto-Commit \n\n        if {$rc != 0 && $nac && !$ac} {\n          # Before [db eval] the auto-commit flag was clear. Now it\n          # is set. Since an error occurred we assume this was not a\n          # commit - therefore a rollback occurred. Check that the\n          # rollback-hook was invoked.\n          do_test malloc3-rollback_hook_count.$iterid {\n            set ::rollback_hook_count\n          } {1}\n        }\n\n        set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]\n        if {$rc == 0} {\n            # Successful execution of sql. The number of failed malloc()\n            # calls should be equal to the number of benign failures.\n            # Otherwise a malloc() failed and the error was not reported.\n            # \n            set expr {$nFail!=$nBenign}\n            if {[expr $expr]} {\n              error \"Unreported malloc() failure, test \\\"$testid\\\", $expr\"\n            }\n\n            if {$ac && !$nac} {\n              # Before the [db eval] the auto-commit flag was set, now it\n              # is clear. We can deduce that a \"BEGIN\" statement has just\n              # been successfully executed.\n              set begin_pc $pc\n            } \n\n            incr pc\n            set iFail 1\n            integrity_check $testid\n        } elseif {[regexp {.*out of memory} $msg] || [db errorcode] == 3082} {\n            # Out of memory error, as expected.\n            #\n            integrity_check $testid\n            incr iFail\n            if {$nac && !$ac} {\n              if {![lindex $v 1] && [db errorcode] != 3082} {\n                # error \"Statement \\\"[lindex $v 2]\\\" caused a rollback\"\n              }\n\n              for {set i $begin_pc} {$i < $pc} {incr i} {\n                set k2 [lindex $arglist [expr {2 * $i}]]\n                set v2 [lindex $arglist [expr {2 * $i + 1}]]\n                set catchupsql \"\"\n                switch -- $k2 {\n                  -sql  {set catchupsql [lindex $v2 2]}\n                  -prep {set catchupsql $v2}\n                }\n                db eval $catchupsql\n              }\n            }\n        } else {\n            error $msg\n        }\n\n        # back up to the previous \"-test\" block.\n        while {[lindex $arglist [expr {2 * ($pc - 1)}]] == \"-test\"} {\n          incr pc -1\n        }\n      }\n\n      -prep {\n        db eval $v\n        incr pc\n      }\n\n      -debug {\n        eval $v\n        incr pc\n      }\n\n      default { error \"Unknown switch: $k\" }\n    }\n  }\n}\n\n# Turn off the Tcl interface's prepared statement caching facility. Then\n# run the tests with \"persistent\" malloc failures.\nsqlite3_extended_result_codes db 1\ndb cache size 0\nrun_test $::run_test_script 1\n\n# Close and reopen the db.\ndb close\nforcedelete test.db test.db-journal test2.db test2.db-journal\nsqlite3 db test.db\nsqlite3_extended_result_codes db 1\nset ::DB [sqlite3_connection_pointer db]\n\n# Turn off the Tcl interface's prepared statement caching facility in\n# the new connnection. Then run the tests with \"transient\" malloc failures.\ndb cache size 0\nrun_test $::run_test_script 0\n\nsqlite3_memdebug_fail -1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc4.test",
    "content": "# 2005 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests to ensure that the library handles malloc() failures\n# correctly. The emphasis in this file is on sqlite3_column_XXX() APIs.\n#\n# $Id: malloc4.test,v 1.10 2008/02/18 22:24:58 drh Exp $\n\n#---------------------------------------------------------------------------\n# NOTES ON EXPECTED BEHAVIOUR\n#\n# [193] When a memory allocation failure occurs during sqlite3_column_name(),\n#       sqlite3_column_name16(), sqlite3_column_decltype(), or\n#       sqlite3_column_decltype16() the function shall return NULL.\n#\n#---------------------------------------------------------------------------\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc4 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\nifcapable !utf16 {\n  finish_test\n  return\n}\n\nproc do_stmt_test {id sql} {\n  set ::sql $sql\n  set go 1\n  for {set n 0} {$go} {incr n} {\n    set testid \"malloc4-$id.$n\"\n\n    # Prepare the statement\n    do_test ${testid}.1 {\n      set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n      expr [string length $::STMT] > 0\n    } {1}\n\n    # Set the Nth malloc() to fail.\n    sqlite3_memdebug_fail $n -repeat 0\n\n    # Test malloc failure in the _name(), _name16(), decltype() and\n    # decltype16() APIs. Calls that occur after the malloc() failure should\n    # return NULL. No error is raised though.\n    #\n    # ${testid}.2.1 - Call _name()\n    # ${testid}.2.2 - Call _name16()\n    # ${testid}.2.3 - Call _name()\n    # ${testid}.2.4 - Check that the return values of the above three calls are\n    #                 consistent with each other and with the simulated\n    #                 malloc() failures.\n    #\n    # Because the code that implements the _decltype() and _decltype16() APIs\n    # is the same as the _name() and _name16() implementations, we don't worry\n    # about explicitly testing them.\n    #\n    do_test ${testid}.2.1 {\n      set mf1 [expr [sqlite3_memdebug_pending] < 0]\n      set ::name8  [sqlite3_column_name $::STMT 0]\n      set mf2 [expr [sqlite3_memdebug_pending] < 0]\n      expr {$mf1 == $mf2 || $::name8 == \"\"}\n    } {1}\n    do_test ${testid}.2.2 {\n      set mf1 [expr [sqlite3_memdebug_pending] < 0]\n      set ::name16 [sqlite3_column_name16 $::STMT 0]\n      set ::name16 [encoding convertfrom unicode $::name16]\n      set ::name16 [string range $::name16 0 end-1]\n      set mf2 [expr [sqlite3_memdebug_pending] < 0]\n      expr {$mf1 == $mf2 || $::name16 == \"\"}\n    } {1}\n    do_test ${testid}.2.3 {\n      set mf1 [expr [sqlite3_memdebug_pending] < 0]\n      set ::name8_2 [sqlite3_column_name $::STMT 0]\n      set mf2 [expr [sqlite3_memdebug_pending] < 0]\n      expr {$mf1 == $mf2 || $::name8_2 == \"\"}\n    } {1}\n    set ::mallocFailed [expr [sqlite3_memdebug_pending] < 0]\n    do_test ${testid}.2.4 {\n      expr {\n        $::name8 == $::name8_2 && $::name16 == $::name8 && !$::mallocFailed ||\n        $::name8 == $::name8_2 && $::name16 == \"\" &&        $::mallocFailed ||\n        $::name8 == $::name16 && $::name8_2 == \"\" &&        $::mallocFailed ||\n        $::name8_2 == $::name16 && $::name8 == \"\" &&        $::mallocFailed\n      }\n    } {1}\n\n    # Step the statement so that we can call _text() and _text16().  Before\n    # running sqlite3_step(), make sure that malloc() is not about to fail.\n    # Memory allocation failures that occur within sqlite3_step() are tested\n    # elsewhere.\n    set mf [sqlite3_memdebug_pending]\n    sqlite3_memdebug_fail -1\n    do_test ${testid}.3 {\n      sqlite3_step $::STMT\n    } {SQLITE_ROW}\n    sqlite3_memdebug_fail $mf\n\n    # Test for malloc() failures within _text() and _text16().\n    #\n    do_test ${testid}.4.1 {\n      set ::text8 [sqlite3_column_text $::STMT 0]\n      set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]\n      expr {$mf==0 || $::text8 == \"\"}\n    } {1}\n    do_test ${testid}.4.2 {\n      set ::text16 [sqlite3_column_text16 $::STMT 0]\n      set ::text16 [encoding convertfrom unicode $::text16]\n      set ::text16 [string range $::text16 0 end-1]\n      set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]\n      expr {$mf==0 || $::text16 == \"\"}\n    } {1}\n    do_test ${testid}.4.3 {\n      set ::text8_2 [sqlite3_column_text $::STMT 0]\n      set mf [expr [sqlite3_memdebug_pending] < 0 && !$::mallocFailed]\n      expr {$mf==0 || $::text8_2 == \"\" || ($::text16 == \"\" && $::text8 != \"\")}\n    } {1}\n\n    # Test for malloc() failures within _int(), _int64() and _real(). The only\n    # way this can occur is if the string has to be translated from UTF-16 to\n    # UTF-8 before being converted to a numeric value.\n    do_test ${testid}.4.4.1 {\n      set mf [sqlite3_memdebug_pending]\n      sqlite3_memdebug_fail -1\n      sqlite3_column_text16 $::STMT 0\n      sqlite3_memdebug_fail $mf\n      sqlite3_column_int $::STMT 0\n    } {0}\n    do_test ${testid}.4.5 {\n      set mf [sqlite3_memdebug_pending]\n      sqlite3_memdebug_fail -1\n      sqlite3_column_text16 $::STMT 0\n      sqlite3_memdebug_fail $mf\n      sqlite3_column_int64 $::STMT 0\n    } {0}\n\n    do_test ${testid}.4.6 {\n      set mf [sqlite3_memdebug_pending]\n      sqlite3_memdebug_fail -1\n      sqlite3_column_text16 $::STMT 0\n      sqlite3_memdebug_fail $mf\n      sqlite3_column_double $::STMT 0\n    } {0.0}\n\n    set mallocFailedAfterStep [expr \\\n      [sqlite3_memdebug_pending] < 0 && !$::mallocFailed\n    ]\n\n    sqlite3_memdebug_fail -1\n    # Test that if a malloc() failed the next call to sqlite3_step() returns\n    # SQLITE_ERROR. If malloc() did not fail, it should return SQLITE_DONE.\n    #\n    do_test ${testid}.5 {\n      sqlite3_step $::STMT\n    } [expr {$mallocFailedAfterStep ? \"SQLITE_ERROR\" : \"SQLITE_DONE\"}]\n\n    do_test ${testid}.6 {\n      sqlite3_finalize $::STMT\n    } [expr {$mallocFailedAfterStep ? \"SQLITE_NOMEM\" : \"SQLITE_OK\"}]\n\n    if {$::mallocFailed == 0 && $mallocFailedAfterStep == 0} {\n      sqlite3_memdebug_fail -1\n      set go 0\n    }\n  }\n}\n\nexecsql {\n  CREATE TABLE tbl(\n    the_first_reasonably_long_column_name that_also_has_quite_a_lengthy_type\n  );\n  INSERT INTO tbl VALUES(\n    'An extra long string. Far too long to be stored in NBFS bytes.'\n  );\n}\n\ndo_stmt_test 1 \"SELECT * FROM tbl\"\n\nsqlite3_memdebug_fail -1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc5.test",
    "content": "# 2005 November 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains test cases focused on the two memory-management APIs, \n# sqlite3_soft_heap_limit() and sqlite3_release_memory().\n#\n# Prior to version 3.6.2, calling sqlite3_release_memory() or exceeding\n# the configured soft heap limit could cause sqlite to upgrade database \n# locks and flush dirty pages to the file system. As of 3.6.2, this is\n# no longer the case. In version 3.6.2, sqlite3_release_memory() only\n# reclaims clean pages. This test file has been updated accordingly.\n#\n# $Id: malloc5.test,v 1.22 2009/04/11 19:09:54 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\ndb close\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc5 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# Skip these tests if OMIT_MEMORY_MANAGEMENT was defined at compile time.\nifcapable !memorymanage {\n   finish_test\n   return\n}\n\n# The sizes of memory allocations from system malloc() might vary,\n# depending on the memory allocator algorithms used.  The following\n# routine is designed to support answers that fall within a range\n# of values while also supplying easy-to-understand \"expected\" values\n# when errors occur.\n#\nproc value_in_range {target x args} {\n  set v [lindex $args 0]\n  if {$v!=\"\"} {\n    if {$v<$target*$x} {return $v}\n    if {$v>$target/$x} {return $v}\n  }\n  return \"number between [expr {int($target*$x)}] and [expr {int($target/$x)}]\"\n}\nset mrange 0.98   ;#  plus or minus 2%\n\ntest_set_config_pagecache 0 100\n\nsqlite3_soft_heap_limit 0\nsqlite3 db test.db\n# db eval {PRAGMA cache_size=1}\n\ndo_test malloc5-1.1 {\n  # Simplest possible test. Call sqlite3_release_memory when there is exactly\n  # one unused page in a single pager cache. The page cannot be freed, as\n  # it is dirty. So sqlite3_release_memory() returns 0.\n  #\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n  }\n  sqlite3_release_memory\n} {0}\n\ndo_test malloc5-1.2 {\n  # Test that the transaction started in the above test is still active.\n  # The lock on the database file should not have been upgraded (this was\n  # not the case before version 3.6.2).\n  #\n  sqlite3 db2 test.db\n  execsql {PRAGMA cache_size=2; SELECT * FROM sqlite_master } db2\n} {}\ndo_test malloc5-1.3 {\n  # Call [sqlite3_release_memory] when there is exactly one unused page \n  # in the cache belonging to db2.\n  #\n  set ::pgalloc [sqlite3_release_memory]\n  value_in_range 1288 0.75\n} [value_in_range 1288 0.75]\n\ndo_test malloc5-1.4 {\n  # Commit the transaction and open a new one. Read 1 page into the cache.\n  # Because the page is not dirty, it is eligible for collection even\n  # before the transaction is concluded.\n  #\n  execsql {\n    COMMIT;\n    BEGIN;\n    SELECT * FROM abc;\n  }\n  value_in_range $::pgalloc $::mrange [sqlite3_release_memory]\n} [value_in_range $::pgalloc $::mrange]\n\ndo_test malloc5-1.5 {\n  # Conclude the transaction opened in the previous [do_test] block. This\n  # causes another page (page 1) to become eligible for recycling.\n  #\n  execsql { COMMIT }\n  value_in_range $::pgalloc $::mrange [sqlite3_release_memory]\n} [value_in_range $::pgalloc $::mrange]\n\ndo_test malloc5-1.6 {\n  # Manipulate the cache so that it contains two unused pages. One requires \n  # a journal-sync to free, the other does not.\n  db2 close\n  execsql {\n    BEGIN;\n    CREATE TABLE def(d, e, f);\n    SELECT * FROM abc;\n  }\n  value_in_range $::pgalloc $::mrange [sqlite3_release_memory 500]\n} [value_in_range $::pgalloc $::mrange]\ndo_test malloc5-1.7 {\n  # Database should not be locked this time. \n  sqlite3 db2 test.db\n  catchsql { SELECT * FROM abc } db2\n} {0 {}}\ndo_test malloc5-1.8 {\n  # Try to release another block of memory. This will fail as the only\n  # pages currently in the cache are dirty (page 3) or pinned (page 1).\n  db2 close\n  sqlite3_release_memory 500\n} 0\ndo_test malloc5-1.8 {\n  # Database is still not locked.\n  #\n  sqlite3 db2 test.db\n  catchsql { SELECT * FROM abc } db2\n} {0 {}}\ndo_test malloc5-1.9 {\n  execsql {\n    COMMIT;\n  }\n} {}\n\ndo_test malloc5-2.1 {\n  # Put some data in tables abc and def. Both tables are still wholly \n  # contained within their root pages.\n  execsql {\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(4, 5, 6);\n    INSERT INTO def VALUES(7, 8, 9);\n    INSERT INTO def VALUES(10,11,12);\n  }\n} {}\ndo_test malloc5-2.2 {\n  # Load the root-page for table def into the cache. Then query table abc. \n  # Halfway through the query call sqlite3_release_memory(). The goal of this\n  # test is to make sure we don't free pages that are in use (specifically, \n  # the root of table abc).\n  sqlite3_release_memory\n  set nRelease 0\n  execsql { \n    BEGIN;\n    SELECT * FROM def;\n  }\n  set data [list]\n  db eval {SELECT * FROM abc} {\n    incr nRelease [sqlite3_release_memory]\n    lappend data $a $b $c\n  }\n  execsql {\n    COMMIT;\n  }\n  list $nRelease $data\n} [list $pgalloc [list 1 2 3 4 5 6]]\n\ndo_test malloc5-3.1 {\n  # Simple test to show that if two pagers are opened from within this\n  # thread, memory is freed from both when sqlite3_release_memory() is\n  # called.\n  execsql {\n    BEGIN;\n    SELECT * FROM abc;\n  }\n  execsql {\n    SELECT * FROM sqlite_master;\n    BEGIN;\n    SELECT * FROM def;\n  } db2\n  value_in_range [expr $::pgalloc*2] 0.99 [sqlite3_release_memory]\n} [value_in_range [expr $::pgalloc * 2] 0.99]\ndo_test malloc5-3.2 {\n  concat \\\n    [execsql {SELECT * FROM abc; COMMIT}] \\\n    [execsql {SELECT * FROM def; COMMIT} db2]\n} {1 2 3 4 5 6 7 8 9 10 11 12}\n\ndb2 close\nputs \"Highwater mark: [sqlite3_memory_highwater]\"\n\n# The following two test cases each execute a transaction in which \n# 10000 rows are inserted into table abc. The first test case is used\n# to ensure that more than 1MB of dynamic memory is used to perform\n# the transaction. \n#\n# The second test case sets the \"soft-heap-limit\" to 100,000 bytes (0.1 MB)\n# and tests to see that this limit is not exceeded at any point during \n# transaction execution.\n#\n# Before executing malloc5-4.* we save the value of the current soft heap \n# limit in variable ::soft_limit. The original value is restored after \n# running the tests.\n#\nset ::soft_limit [sqlite3_soft_heap_limit -1]\nexecsql {PRAGMA cache_size=2000}\ndo_test malloc5-4.1 {\n  execsql {BEGIN;}\n  execsql {DELETE FROM abc;}\n  for {set i 0} {$i < 10000} {incr i} {\n    execsql \"INSERT INTO abc VALUES($i, $i, '[string repeat X 100]');\"\n  }\n  execsql {COMMIT;}\n  db cache flush\n  sqlite3_release_memory\n  sqlite3_memory_highwater 1\n  execsql {SELECT * FROM abc}\n  set nMaxBytes [sqlite3_memory_highwater 1]\n  puts -nonewline \" (Highwater mark: $nMaxBytes) \"\n  expr $nMaxBytes > 1000000\n} {1}\ndo_test malloc5-4.2 {\n  db eval {PRAGMA cache_size=1}\n  db cache flush\n  sqlite3_release_memory\n  sqlite3_soft_heap_limit 200000\n  sqlite3_memory_highwater 1\n  execsql {SELECT * FROM abc}\n  set nMaxBytes [sqlite3_memory_highwater 1]\n  puts -nonewline \" (Highwater mark: $nMaxBytes) \"\n  expr $nMaxBytes <= 210000\n} {1}\ndo_test malloc5-4.3 {\n  # Check that the content of table abc is at least roughly as expected.\n  execsql {\n    SELECT count(*), sum(a), sum(b) FROM abc;\n  }\n} [list 10000 [expr int(10000.0 * 4999.5)] [expr int(10000.0 * 4999.5)]]\n\n# Restore the soft heap limit.\nsqlite3_soft_heap_limit $::soft_limit\n\n# Test that there are no problems calling sqlite3_release_memory when\n# there are open in-memory databases.\n#\n# At one point these tests would cause a seg-fault.\n#\ndo_test malloc5-5.1 {\n  db close\n  sqlite3 db :memory:\n  execsql {\n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES('abcdefghi', 1234567890, NULL);\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n    INSERT INTO abc SELECT * FROM abc;\n  }\n  sqlite3_release_memory\n} 0\ndo_test malloc5-5.2 {\n  sqlite3_soft_heap_limit 5000\n  execsql {\n    COMMIT;\n    PRAGMA temp_store = memory;\n    SELECT * FROM abc ORDER BY a;\n  }\n  expr 1\n} {1}\nsqlite3_soft_heap_limit $::soft_limit\n\n#-------------------------------------------------------------------------\n# The following test cases (malloc5-6.*) test the new global LRU list\n# used to determine the pages to recycle when sqlite3_release_memory is\n# called and there is more than one pager open.\n#\nproc nPage {db} {\n  set bt [btree_from_db $db]\n  array set stats [btree_pager_stats $bt]\n  set stats(page)\n}\ndb close\nforcedelete test.db test.db-journal test2.db test2.db-journal\n\n# This block of test-cases (malloc5-6.1.*) prepares two database files\n# for the subsequent tests.\ndo_test malloc5-6.1.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA default_cache_size=2;\n  }\n  execsql {\n    PRAGMA temp_store = memory;\n    BEGIN;\n    CREATE TABLE abc(a PRIMARY KEY, b, c);\n    INSERT INTO abc VALUES(randstr(50,50), randstr(75,75), randstr(100,100));\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    INSERT INTO abc \n        SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc;\n    COMMIT;\n  } \n  forcecopy test.db test2.db\n  sqlite3 db2 test2.db\n  db2 eval {PRAGMA cache_size=2}\n  list \\\n    [expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20]\n} {1 1}\ndo_test malloc5-6.1.2 {\n  list [execsql {PRAGMA cache_size}] [execsql {PRAGMA cache_size} db2]\n} {2 2}\n\ndo_test malloc5-6.2.1 {\n  execsql {SELECT * FROM abc} db2\n  execsql {SELECT * FROM abc} db\n  expr [nPage db] + [nPage db2]\n} {4}\n\ndo_test malloc5-6.2.2 {\n  # If we now try to reclaim some memory, it should come from the db2 cache.\n  sqlite3_release_memory 3000\n  expr [nPage db] + [nPage db2]\n} {1}\ndo_test malloc5-6.2.3 {\n  # Access the db2 cache again, so that all the db2 pages have been used\n  # more recently than all the db pages. Then try to reclaim 3000 bytes.\n  # This time, 3 pages should be pulled from the db cache.\n  execsql { SELECT * FROM abc } db2\n  sqlite3_release_memory 3000\n  expr [nPage db] + [nPage db2]\n} {0}\n\ndo_test malloc5-6.3.1 {\n  # Now open a transaction and update 2 pages in the db2 cache. Then\n  # do a SELECT on the db cache so that all the db pages are more recently\n  # used than the db2 pages. When we try to free memory, SQLite should\n  # free the non-dirty db2 pages, then the db pages, then finally use\n  # sync() to free up the dirty db2 pages. The only page that cannot be\n  # freed is page1 of db2. Because there is an open transaction, the\n  # btree layer holds a reference to page 1 in the db2 cache.\n  #\n  # UPDATE: No longer. As release_memory() does not cause a sync()\n  execsql {\n    BEGIN;\n    UPDATE abc SET c = randstr(100,100) \n    WHERE rowid = 1 OR rowid = (SELECT max(rowid) FROM abc);\n  } db2\n  execsql { SELECT * FROM abc } db\n  expr [nPage db] + [nPage db2]\n} {4}\ndo_test malloc5-6.3.2 {\n  # Try to release 7700 bytes. This should release all the \n  # non-dirty pages held by db2.\n  sqlite3_release_memory [expr 7*1132]\n  list [nPage db] [nPage db2]\n} {0 3}\ndo_test malloc5-6.3.3 {\n  # Try to release another 1000 bytes. This should come fromt the db\n  # cache, since all three pages held by db2 are either in-use or diry.\n  sqlite3_release_memory 1000\n  list [nPage db] [nPage db2]\n} {0 3}\ndo_test malloc5-6.3.4 {\n  # Now release 9900 more (about 9 pages worth). This should expunge\n  # the rest of the db cache. But the db2 cache remains intact, because\n  # SQLite tries to avoid calling sync().\n  if {$::tcl_platform(wordSize)==8} {\n    sqlite3_release_memory 10500\n  } else {\n    sqlite3_release_memory 9900\n  }\n  list [nPage db] [nPage db2]\n} {0 3}\ndo_test malloc5-6.3.5 {\n  # But if we are really insistent, SQLite will consent to call sync()\n  # if there is no other option. UPDATE: As of 3.6.2, SQLite will not\n  # call sync() in this scenario. So no further memory can be reclaimed.\n  sqlite3_release_memory 1000\n  list [nPage db] [nPage db2]\n} {0 3}\ndo_test malloc5-6.3.6 {\n  # The referenced page (page 1 of the db2 cache) will not be freed no\n  # matter how much memory we ask for:\n  sqlite3_release_memory 31459\n  list [nPage db] [nPage db2]\n} {0 3}\n\ndb2 close\n\nsqlite3_soft_heap_limit $::soft_limit\ntest_restore_config_pagecache\nfinish_test\ncatch {db close}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc6.test",
    "content": "# 2006 June 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file attempts to check the library in an out-of-memory situation.\n#\n# $Id: malloc6.test,v 1.5 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc6 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n\nset sqlite_os_trace 0\ndo_malloc_test malloc6-1 -tclprep {\n  db close\n} -tclbody {\n  if {[catch {sqlite3 db test.db}]} {\n    error \"out of memory\"\n  }\n  sqlite3_extended_result_codes db 1\n} -sqlbody {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE IF NOT EXISTS t1(\n     a int, b float, c double, d text, e varchar(20),\n     primary key(a,b,c)\n  );\n  CREATE TABLE IF NOT EXISTS t1(\n     a int, b float, c double, d text, e varchar(20),\n     primary key(a,b,c)\n  );\n  DROP TABLE IF EXISTS t1;\n} \n\n# Ensure that no file descriptors were leaked.\ndo_test malloc6-1.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc7.test",
    "content": "# 2006 July 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains additional out-of-memory checks (see malloc.tcl)\n# added to expose a bug in out-of-memory handling for sqlite3_prepare16().\n#\n# $Id: malloc7.test,v 1.5 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc7 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n\ndo_malloc_test malloc7-1 -sqlprep {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE INDEX i1 ON t1(b,c);\n} -tclbody {\n  set sql16 [encoding convertto unicode \"SELECT * FROM sqlite_master\"]\n  append sql16 \"\\00\\00\"\n  set nbyte [string length $sql16]\n  set ::STMT [sqlite3_prepare16 db $sql16 $nbyte DUMMY]\n  sqlite3_finalize $::STMT\n} \n\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-99.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nputs open-file-count=$sqlite_open_file_count\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc8.test",
    "content": "# 2007 April 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains additional out-of-memory checks (see malloc.tcl)\n# added to expose a bug in out-of-memory handling for sqlite3_value_text()\n#\n# $Id: malloc8.test,v 1.7 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc8 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n\n# The setup is a database with UTF-16 encoding that contains a single\n# large string.  We will be running lots of queries against this \n# database.  Because we will be extracting the string as UTF-8, there\n# is a type conversion that occurs and thus an opportunity for malloc()\n# to fail and for sqlite3_value_text() to return 0 even though\n# sqlite3_value_type() returns SQLITE_TEXT.\n#\n\ndo_malloc_test malloc8-1 -sqlprep {\n  PRAGMA encoding='UTF-16';\n  CREATE TABLE t1(a);\n  INSERT INTO t1 \n  VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n} -sqlbody {\n  SELECT lower(a), upper(a), quote(a), trim(a), trim('x',a) FROM t1;\n}\ndo_malloc_test malloc8-2 -sqlprep {\n  PRAGMA encoding='UTF-16';\n  CREATE TABLE t1(a);\n  INSERT INTO t1 \n  VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n} -sqlbody {\n  SELECT replace(a,'x','y'), replace('x',a,'y'), replace('x','y',a)\n    FROM t1;\n}\ndo_malloc_test malloc8-3 -sqlprep {\n  PRAGMA encoding='UTF-16';\n  CREATE TABLE t1(a);\n  INSERT INTO t1 \n  VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n} -sqlbody {\n  SELECT length(a), substr(a, 4, 4) FROM t1;\n}\nifcapable datetime {\n  do_malloc_test malloc8-4 -sqlprep {\n    PRAGMA encoding='UTF-16';\n    CREATE TABLE t1(a);\n    INSERT INTO t1 \n    VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n  } -sqlbody {\n    SELECT julianday(a,a) FROM t1;\n  }\n}\ndo_malloc_test malloc8-5 -sqlprep {\n  PRAGMA encoding='UTF-16';\n  CREATE TABLE t1(a);\n  INSERT INTO t1 \n  VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n} -sqlbody {\n  SELECT 1 FROM t1 WHERE a LIKE 'hello' ESCAPE NULL;\n}\ndo_malloc_test malloc8-6 -sqlprep {\n  PRAGMA encoding='UTF-16';\n  CREATE TABLE t1(a);\n  INSERT INTO t1 \n  VALUES('0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ');\n} -sqlbody {\n  SELECT hex(randomblob(100));\n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-99.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc9.test",
    "content": "# 2007 April 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains additional out-of-memory checks (see malloc.tcl)\n# added to expose a bug in out-of-memory handling for sqlite3_prepare().\n#\n# $Id: malloc9.test,v 1.5 2008/04/04 12:21:26 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping malloc9 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n\ndo_malloc_test malloc-9.1 -tclprep {\n  set sql {CREATE TABLE t1(x)}\n  set sqlbytes [string length $sql]\n  append sql {; INSERT INTO t1 VALUES(1)}\n} -tclbody {\n  if {[catch {sqlite3_prepare db $sql $sqlbytes TAIL} STMT]} {\n    set msg $STMT\n    set STMT {}\n    error $msg\n  }\n} -cleanup {\n  if {$STMT!=\"\"} {\n    sqlite3_finalize $STMT\n  }\n}\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc9-99.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocA.test",
    "content": "# 2007 April 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains additional out-of-memory checks (see malloc.tcl).\n#\n# $Id: mallocA.test,v 1.8 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix mallocA\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocA tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# Construct a test database\n#\nforcedelete test.db.bu\ndb eval {\n  CREATE TABLE t1(a COLLATE NOCASE,b,c);\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(1,2,4);\n  INSERT INTO t1 VALUES(2,3,4);\n  CREATE INDEX t1i1 ON t1(a);\n  CREATE INDEX t1i2 ON t1(b,c);\n  CREATE TABLE t2(x,y,z);\n}\ndb close\ncopy_file test.db test.db.bu\n\ndo_malloc_test mallocA-1 -testdb test.db.bu -sqlbody {\n  ANALYZE\n}\ndo_malloc_test mallocA-1.1 -testdb test.db.bu -sqlbody {\n  ANALYZE t1\n}\ndo_malloc_test mallocA-1.2 -testdb test.db.bu -sqlbody {\n  ANALYZE main\n}\ndo_malloc_test mallocA-1.3 -testdb test.db.bu -sqlbody {\n  ANALYZE main.t1\n}\n\nifcapable reindex {\n  do_malloc_test mallocA-2 -testdb test.db.bu -sqlbody {\n    REINDEX;\n  }\n  do_malloc_test mallocA-3 -testdb test.db.bu -sqlbody {\n    REINDEX t1;\n  }\n  do_malloc_test mallocA-4 -testdb test.db.bu -sqlbody {\n    REINDEX main.t1;\n  }\n  do_malloc_test mallocA-5 -testdb test.db.bu -sqlbody {\n    REINDEX nocase;\n  }\n}\n\nreset_db\nsqlite3_db_config_lookaside db 0 0 0\ndo_execsql_test 6-prep {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES('abc', 'w'); -- rowid=1\n  INSERT INTO t1 VALUES('abc', 'x'); -- rowid=2\n  INSERT INTO t1 VALUES('abc', 'y'); -- rowid=3\n  INSERT INTO t1 VALUES('abc', 'z'); -- rowid=4\n\n  INSERT INTO t1 VALUES('def', 'w'); -- rowid=5\n  INSERT INTO t1 VALUES('def', 'x'); -- rowid=6\n  INSERT INTO t1 VALUES('def', 'y'); -- rowid=7\n  INSERT INTO t1 VALUES('def', 'z'); -- rowid=8\n\n  ANALYZE;\n}\n\ndo_faultsim_test 6.1 -faults oom* -body {\n  execsql { SELECT rowid FROM t1 WHERE a='abc' AND b='x' }\n} -test {\n  faultsim_test_result [list 0 2]\n}\ndo_faultsim_test 6.2 -faults oom* -body {\n  execsql { SELECT rowid FROM t1 WHERE a='abc' AND b<'y' }\n} -test {\n  faultsim_test_result [list 0 {1 2}]\n}\nifcapable stat3 {\n  do_test 6.3-prep {\n    execsql {\n      PRAGMA writable_schema = 1;\n      CREATE TABLE sqlite_stat4 AS \n      SELECT tbl, idx, neq, nlt, ndlt, sqlite_record(sample) AS sample \n      FROM sqlite_stat3;\n    }\n  } {}\n  do_faultsim_test 6.3 -faults oom* -body {\n    execsql { \n      ANALYZE sqlite_master;\n      SELECT rowid FROM t1 WHERE a='abc' AND b<'y';\n    }\n  } -test {\n    faultsim_test_result [list 0 {1 2}]\n  }\n}\n\ndo_execsql_test 7.0 {\n  PRAGMA cache_size = 5;\n}\ndo_faultsim_test 7 -faults oom-trans* -prep {\n} -body {\n  execsql {\n    WITH r(x,y) AS (\n      SELECT 1, randomblob(100)\n      UNION ALL\n      SELECT x+1, randomblob(100) FROM r\n      LIMIT 1000\n    )\n    SELECT count(x), length(y) FROM r GROUP BY (x%5)\n  }\n} -test {\n  set res [list 200 100 200 100 200 100 200 100 200 100]\n  faultsim_test_result [list 0 $res]\n}\n\n\n# Ensure that no file descriptors were leaked.\ndo_test malloc-99.X {\n  catch {db close}\n  set sqlite_open_file_count\n} {0}\n\nforcedelete test.db.bu\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocAll.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all out-of-memory tests.\n#\n# $Id: mallocAll.test,v 1.1 2007/11/26 13:36:00 drh Exp $\n\nproc lshift {lvar} {\n  upvar $lvar l\n  set ret [lindex $l 0]\n  set l [lrange $l 1 end]\n  return $ret\n}\nwhile {[set arg [lshift argv]] != \"\"} {\n  switch -- $arg {\n    -sharedpagercache {\n      sqlite3_enable_shared_cache 1\n    }\n    default {\n      set argv [linsert $argv 0 $arg]\n      break\n    }\n  }\n}\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nrename finish_test really_finish_test\nproc finish_test {} {}\nset G(isquick) 1\n\nset EXCLUDE {\n  mallocAll.test\n}\n\nif {[sqlite3 -has-codec]} {\n  # lappend EXCLUDE \\\n  #  conflict.test\n}\n\n\n# Files to include in the test.  If this list is empty then everything\n# that is not in the EXCLUDE list is run.\n#\nset INCLUDE {\n}\n\nforeach testfile [lsort -dictionary [glob $testdir/*malloc*.test]] {\n  set tail [file tail $testfile]\n  if {[lsearch -exact $EXCLUDE $tail]>=0} continue\n  if {[llength $INCLUDE]>0 && [lsearch -exact $INCLUDE $tail]<0} continue\n  source $testfile\n  catch {db close}\n  if {$sqlite_open_file_count>0} {\n    puts \"$tail did not close all files: $sqlite_open_file_count\"\n    fail_test $tail\n    set sqlite_open_file_count 0\n  }\n}\nsource $testdir/misuse.test\n\nset sqlite_open_file_count 0\nreally_finish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocB.test",
    "content": "# 2007 May 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file contains additional out-of-memory checks (see malloc.tcl).\n# These were all discovered by fuzzy generation of SQL. Apart from\n# that they have little in common.\n#\n#\n# $Id: mallocB.test,v 1.9 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocB tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\nsource $testdir/malloc_common.tcl\n\ndo_malloc_test mallocB-1 -sqlbody {SELECT - 456}\ndo_malloc_test mallocB-2 -sqlbody {SELECT - 456.1}\ndo_malloc_test mallocB-3 -sqlbody {SELECT random()}\ndo_malloc_test mallocB-4 -sqlbody {SELECT length(zeroblob(1000))}\nifcapable subquery {\n  do_malloc_test mallocB-5 -sqlbody {SELECT * FROM (SELECT 1) GROUP BY 1;}\n}\n\n# The following test checks that there are no resource leaks following a\n# malloc() failure in sqlite3_set_auxdata().\n#\n# Note: This problem was not discovered by fuzzy generation of SQL. Not\n# that it really matters.\n#\ndo_malloc_test mallocB-6 -sqlbody { SELECT test_auxdata('hello world'); }\n\ndo_malloc_test mallocB-7 -sqlbody {\n  SELECT strftime(hex(randomblob(50)) || '%Y', 'now')\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocC.test",
    "content": "# 2007 Aug 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file tests aspects of the malloc failure while parsing\n# CREATE TABLE statements in auto_vacuum mode.\n#\n# $Id: mallocC.test,v 1.10 2009/04/11 16:27:50 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocC tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\nproc do_mallocC_test {tn args} {\n  array set ::mallocopts $args\n  #set sum [allcksum db]\n\n  for {set ::n 1} {true} {incr ::n} {\n\n    # Run the SQL. Malloc number $::n is set to fail. A malloc() failure\n    # may or may not be reported.\n    sqlite3_memdebug_fail $::n -repeat 1\n    do_test mallocC-$tn.$::n.1 {\n      set res [catchsql [string trim $::mallocopts(-sql)]]\n      set rc [expr { \n        0==[string compare $res {1 {out of memory}}] ||\n        [db errorcode] == 3082 ||\n        0==[lindex $res 0]\n      }]\n      if {$rc!=1} {\n        puts \"Error: $res\"\n      }\n      set rc\n    } {1}\n\n    # If $::n is greater than the number of malloc() calls required to\n    # execute the SQL, then this test is finished. Break out of the loop.\n    set nFail [sqlite3_memdebug_fail -1]\n    if {$nFail==0} {\n      break\n    }\n\n    # Recover from the malloc failure.\n    #\n    # Update: The new malloc() failure handling means that a transaction may\n    # still be active even if a malloc() has failed. But when these tests were\n    # written this was not the case. So do a manual ROLLBACK here so that the\n    # tests pass.\n    do_test mallocC-$tn.$::n.2 {\n      catch {\n        execsql {\n          ROLLBACK;\n        }\n      }\n      expr 0\n    } {0}\n\n    # Checksum the database.\n    #do_test mallocC-$tn.$::n.3 {\n    #  allcksum db\n    #} $sum\n\n    #integrity_check mallocC-$tn.$::n.4\n  }\n  unset ::mallocopts\n}\n\nsqlite3_extended_result_codes db 1\n\nexecsql {\n  PRAGMA auto_vacuum=1;\n  CREATE TABLE t0(a, b, c);\n}\n\n# The number of memory allocation failures is different on 64-bit\n# and 32-bit systems due to larger structures on 64-bit systems\n# overflowing the lookaside more often.  To debug problems, it is\n# sometimes helpful to reduce the size of the lookaside allocation\n# blocks.  But this is normally disabled.\n#\nif {0} {\n  db close\n  sqlite3_shutdown\n  sqlite3_config_lookaside 50 500\n  sqlite3_initialize\n  autoinstall_test_functions\n  sqlite3 db test.db\n}\n\ndo_mallocC_test 1 -sql {\n  BEGIN;\n  -- Allocate 32 new root pages. This will exercise the 'extract specific \n  -- page from the freelist' code when in auto-vacuum mode (see the\n  -- allocatePage() routine in btree.c).\n  CREATE TABLE t1(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t2(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t3(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t4(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t5(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t6(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t7(a UNIQUE, b UNIQUE, c UNIQUE);\n  CREATE TABLE t8(a UNIQUE, b UNIQUE, c UNIQUE);\n\n  ROLLBACK;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocD.test",
    "content": "# 2007 Aug 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: mallocD.test,v 1.6 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocD tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\ndb close\nsqlite3_simulate_device -char atomic\nsqlite3 db test.db -vfs devsym\n\nset PREP { \n  PRAGMA page_size = 1024;\n  CREATE TABLE abc(a, b, c);\n}\n\ndo_malloc_test mallocD-1 -sqlprep $PREP -sqlbody { \n  INSERT INTO abc VALUES(1, 2, 3);\n}\n\ndo_malloc_test mallocD-2 -sqlprep $PREP -sqlbody {\n  BEGIN;\n  INSERT INTO abc VALUES(1, 2, 3);\n  INSERT INTO abc VALUES(4, 5, 6);\n  ROLLBACK;\n}\n\ndo_malloc_test mallocD-3 -sqlprep $PREP -sqlbody {\n  BEGIN;\n  INSERT INTO abc VALUES(1, 2, 3);\n  INSERT INTO abc VALUES(4, 5, randstr(1500,1500));\n  COMMIT;\n}\n\nifcapable attach {\n  do_malloc_test mallocD-4 -sqlprep $PREP -sqlbody {\n    ATTACH 'test2.db' AS aux;\n    BEGIN;\n    CREATE TABLE aux.def(d, e, f);\n    INSERT INTO abc VALUES(4, 5, 6);\n    COMMIT;\n  }\n}\n\nsqlite3_simulate_device -char {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocE.test",
    "content": "# 2007 Aug 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks that tickets #2784 and #2789 have been fixed.\n# \n# $Id: mallocE.test,v 1.3 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocE tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# ticket #2784\n#\nset PREP { \n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(x, y, z);\n}\ndo_malloc_test mallocE-1 -sqlprep $PREP -sqlbody { \n  SELECT p, q FROM (SELECT a+b AS p, b+c AS q FROM t1, t2 WHERE c>5)\n              LEFT JOIN t2 ON p=x;\n}\n\n# Ticket #2789\n#\ndo_malloc_test mallocE-2 -sqlprep $PREP -sqlbody { \n  SELECT x, y2 FROM (SELECT a+b AS x, b+c AS y2 FROM t1, t2 WHERE c>5)\n              LEFT JOIN t2 USING(x) WHERE y2>11;\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocF.test",
    "content": "# 2007 Aug 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks that tickets #2794, #2795, #2796, and #2797\n# have been fixed.\n# \n# $Id: mallocF.test,v 1.4 2008/02/18 22:24:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocF tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# tickets #2794 and #2795 and #2797\n#\nset PREP {\n  CREATE TABLE t1(x,y);\n  INSERT INTO t1 VALUES('abc123', 5);\n  INSERT INTO t1 VALUES('xyz987', 42);\n}\ndo_malloc_test malloeF-1 -sqlprep $PREP -sqlbody {\n  SELECT * FROM t1 WHERE x GLOB 'abc*'\n}\n\n# ticket #2796\n#\nset PREP {\n  CREATE TABLE t1(x PRIMARY KEY,y UNIQUE);\n  INSERT INTO t1 VALUES('abc123', 5);\n  INSERT INTO t1 VALUES('xyz987', 42);\n}\ndo_malloc_test malloeF-2 -sqlprep $PREP -sqlbody {\n  SELECT x FROM t1\n   WHERE y=1 OR y=2 OR y=3 OR y=4 OR y=5\n      OR y=6 OR y=7 OR y=8 OR y=9 OR y=10\n      OR y=11 OR y=12 OR y=13 OR y=14 OR y=15\n      OR y=x\n}\n\nset PREP {\n  CREATE TABLE t1(x PRIMARY KEY,y UNIQUE);\n  INSERT INTO t1 VALUES('abc123', 5);\n  INSERT INTO t1 VALUES('xyz987', 42);\n}\ndo_malloc_test malloeF-3 -sqlprep $PREP -sqlbody {\n  SELECT x FROM t1 WHERE y BETWEEN 10 AND 29\n}\n\n# Ticket #2843\n#\nset PREP {\n  CREATE TABLE t1(x);\n  CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN\n    SELECT 'hello';\n  END;\n}\ndo_malloc_test mallocF-4 -sqlprep $PREP -sqlbody {\n  INSERT INTO t1 VALUES(random());\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocG.test",
    "content": "# 2007 Aug 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks malloc failures in various obscure operations.\n# \n# $Id: mallocG.test,v 1.5 2008/08/01 18:47:02 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Only run these tests if memory debugging is turned on.\n#\nif {!$MEMDEBUG} {\n   puts \"Skipping mallocG tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\n\n# Malloc failures while opening a database connection.\n#\ndo_malloc_test mallocG-1 -tclbody {\n  db close\n  sqlite3 db test.db\n}\n\ndo_malloc_test mallocG-2 -sqlprep {\n  CREATE TABLE t1(x, y);\n  CREATE TABLE t2(x INTEGER PRIMARY KEY);\n} -sqlbody {\n  SELECT y FROM t1 WHERE x IN t2;\n}\n\ndo_malloc_test mallocG-3 -sqlprep {\n  CREATE TABLE t1(x UNIQUE);\n  INSERT INTO t1 VALUES ('hello');\n  INSERT INTO t1 VALUES ('out there');\n} -sqlbody {\n  SELECT * FROM t1\n   WHERE x BETWEEN 'a' AND 'z'\n     AND x BETWEEN 'c' AND 'w'\n     AND x BETWEEN 'e' AND 'u'\n     AND x BETWEEN 'g' AND 'r'\n     AND x BETWEEN 'i' AND 'q'\n     AND x BETWEEN 'i' AND 'm'\n}\n\nifcapable !utf16 {\n  finish_test\n  return\n}\n\nproc utf16 {utf8} {\n  set utf16 [encoding convertto unicode $utf8]\n  append utf16 \"\\x00\\x00\"\n  return $utf16\n}\n\ndo_malloc_test mallocG-4 -tclbody {\n  set rc [sqlite3_complete16 [utf16 \"SELECT * FROM t1;\"]]\n  if {$rc==1} {set rc 0} {error \"out of memory\"}\n  set rc\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocH.test",
    "content": "# 2008 August 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks malloc failures in various obscure operations.\n# \n# $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Malloc failures in journaling of in-memory databases.\n#\ndo_malloc_test mallocH-1 -tclprep {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    CREATE TABLE t1(x UNIQUE, y);\n    INSERT INTO t1 VALUES(1,2);\n  }\n} -sqlbody {\n  INSERT INTO t1 SELECT x+1, y+100 FROM t1;\n}\n\n# Malloc failures while parsing a CASE expression.\n#\ndo_malloc_test mallocH-2 -sqlbody {\n   SELECT CASE WHEN 1 THEN 1 END;\n}\n\n# Malloc failures while parsing a EXISTS(SELECT ...)\n#\ndo_malloc_test mallocH-3 -sqlbody {\n   SELECT 3+EXISTS(SELECT * FROM sqlite_master);\n}\n\n# Malloc failures within the replace() function.\n#\ndo_malloc_test mallocH-3 -sqlbody {\n   SELECT replace('ababa','a','xyzzy');\n}\n\n# Malloc failures during EXPLAIN.\n#\nifcapable explain {\n  do_malloc_test mallocH-4 -sqlprep {\n     CREATE TABLE abc(a PRIMARY KEY, b, c);\n  } -sqlbody {\n     EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1;\n     EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1;\n  }\n}\n\n# Malloc failure during integrity_check pragma.\n#\ndo_malloc_test mallocH-5 -sqlprep {\n   CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n   CREATE TABLE t2(x,y);\n   INSERT INTO t1 VALUES(1,2);\n   INSERT INTO t2 SELECT * FROM t1;\n} -sqlbody {\n   PRAGMA integrity_check;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocI.test",
    "content": "# 2008 August 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks malloc failures in various obscure operations.\n# \n# $Id: mallocI.test,v 1.3 2009/08/10 04:26:39 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# Malloc failures in a view.\n#\ndo_malloc_test mallocI-1 -sqlprep {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE VIEW v1 AS SELECT a*b, c*d FROM t1 ORDER BY b-d;\n} -sqlbody {\n  SELECT * FROM v1\n}\n\n# Malloc failure while trying to service a pragma on a TEMP database.\n#\ndo_malloc_test mallocI-2 -sqlbody {\n  PRAGMA temp.page_size\n}\n\n# Malloc failure while creating a table from a SELECT statement.\n#\ndo_malloc_test mallocI-3 -sqlprep {\n  CREATE TABLE t1(a,b,c);\n} -sqlbody {\n  CREATE TABLE t2 AS SELECT b,c FROM t1;\n}\n\n# This tests that a malloc failure that occurs while passing the schema\n# does not result in a SHARED lock being left on the database file.\n#\ndo_malloc_test mallocI-4 -tclprep {\n  sqlite3 db2 test.db\n  db2 eval {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n  }\n} -sqlbody {\n  SELECT * FROM t1\n} -cleanup {\n  do_test mallocI-4.$::n.2 {\n    # If this INSERT is possible then [db] does not hold a shared lock\n    # on the database file.\n    catchsql { INSERT INTO t1 VALUES(1, 2, 3) } db2\n  } {0 {}}\n  catch {db2 close}\n}\ncatch { db2 close }\n\ndo_faultsim_test mallocI-5 -faults oom* -prep {\n  catch { db close }\n  sqlite3 db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n} -body {\n  db eval { Select CAST(1 AS blob) }\n} -test {\n  faultsim_test_result {0 1}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocJ.test",
    "content": "# 2008 August 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks malloc failures in LIMIT operations for \n# UPDATE/DELETE statements.\n# \n# $Id: mallocJ.test,v 1.6 2009/01/09 02:49:32 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nifcapable {update_delete_limit} {\n\n  do_malloc_test mallocJ-1 -sqlprep {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(x int, y int);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(2,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 VALUES(2,3);\n  } -sqlbody {\n    UPDATE t1 SET x=1 ORDER BY y LIMIT 2 OFFSET 2;\n    UPDATE t1 SET x=2 WHERE y=1 ORDER BY y LIMIT 2 OFFSET 2;\n    DELETE FROM t1 WHERE x=1 ORDER BY y LIMIT 2 OFFSET 2;\n    DELETE FROM t1 ORDER BY y LIMIT 2 OFFSET 2;\n  }\n\n}\n\n# ticket #3467\ndo_malloc_test mallocJ-2 -sqlprep {\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(1,2);\n  PRAGMA vdbe_trace=ON;\n} -sqlbody {\n  SELECT a, b, 'abc' FROM t1\n    UNION\n    SELECT b, a, 'xyz' FROM t1\n    ORDER BY 2, 3;\n}\n\n# ticket #3478\ndo_malloc_test mallocJ-3 -sqlbody {\n  EXPLAIN COMMIT\n}\n\n# ticket #3485\ndo_malloc_test mallocJ-4 -sqlprep {\n  CREATE TABLE t1(a,b,c);\n  CREATE TABLE t2(x,y,z);\n} -sqlbody {\n  SELECT * FROM (SELECT a,b FROM t1 UNION ALL SELECT x, y FROM t2) ORDER BY 1\n}\n\n# coverage testing\ndo_malloc_test mallocJ-5 -sqlprep {\n  CREATE TABLE t1([\"a\"]);\n} -sqlbody {\n  SELECT * FROM t1\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocK.test",
    "content": "# 2008 August 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script checks malloc failures in WHERE clause analysis.\n# \n# $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix mallocK\n\nset sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}\nfor {set x 1} {$x<5} {incr x} {\n  append sql \" AND b=y\"\n  do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {\n    CREATE TABLE t1(a,b);\n    CREATE TABLE t2(x,y);\n  }\n}\n\nset sql {SELECT * FROM t1 WHERE a GLOB 'xyz*' AND (a=1 OR a=2)}\nfor {set x 1} {$x<5} {incr x} {\n  append sql \" AND b!=$x\"\n  do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {\n    CREATE TABLE t1(a,b);\n  }\n}\n\nset sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}\nfor {set x 1} {$x<5} {incr x} {\n  append sql \" AND b=$x\"\n  do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {\n    CREATE TABLE t1(a,b);\n  }\n}\n\nset sql {SELECT * FROM t1 WHERE b=0}\nfor {set x 1} {$x<5} {incr x} {\n  set term \"(b=$x\"\n  for {set y 0} {$y<$x} {incr y} {\n    append term \" AND a!=$y\"\n  }\n  append sql \" OR $term)\"\n  do_malloc_test mallocK-4.$x -sqlbody $sql -sqlprep {\n    CREATE TABLE t1(a,b);\n  }\n}\n\nifcapable vtab {\n  set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}\n  for {set x 1} {$x<5} {incr x} {\n    append sql \" AND b!=$x\"\n    do_malloc_test mallocK-5.$x -sqlbody $sql -tclprep {\n      register_echo_module [sqlite3_connection_pointer db]\n      db eval {\n        CREATE TABLE t1(a,b);\n        CREATE VIRTUAL TABLE t2 USING echo(t1);\n      }\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that OOM errors are correctly handled by the code that uses stat4\n# data to estimate the number of rows visited by a skip-scan range query.\n#\nadd_alignment_test_collations db\ndo_execsql_test 6.0 {\n  CREATE TABLE t3(a TEXT, b TEXT COLLATE utf16_aligned, c);\n  INSERT INTO t3 VALUES('one', '.....', 0);\n  INSERT INTO t3 VALUES('one', '....x', 1);\n  INSERT INTO t3 VALUES('one', '...x.', 2);\n  INSERT INTO t3 VALUES('one', '...xx', 3);\n  INSERT INTO t3 VALUES('one', '..x..', 4);\n  INSERT INTO t3 VALUES('one', '..x.x', 5);\n  INSERT INTO t3 VALUES('one', '..xx.', 6);\n  INSERT INTO t3 VALUES('one', '..xxx', 7);\n  INSERT INTO t3 VALUES('one', '.x...', 8);\n  INSERT INTO t3 VALUES('one', '.x..x', 9);\n  INSERT INTO t3 VALUES('one', '.x.x.', 10);\n  INSERT INTO t3 VALUES('one', '.x.xx', 11);\n  INSERT INTO t3 VALUES('one', '.xx..', 12);\n  INSERT INTO t3 VALUES('one', '.xx.x', 13);\n  INSERT INTO t3 VALUES('one', '.xxx.', 14);\n  INSERT INTO t3 VALUES('one', '.xxxx', 15);\n\n  INSERT INTO t3 VALUES('two', 'x....', 16);\n  INSERT INTO t3 VALUES('two', 'x...x', 17);\n  INSERT INTO t3 VALUES('two', 'x..x.', 18);\n  INSERT INTO t3 VALUES('two', 'x..xx', 19);\n  INSERT INTO t3 VALUES('two', 'x.x..', 20);\n  INSERT INTO t3 VALUES('two', 'x.x.x', 21);\n  INSERT INTO t3 VALUES('two', 'x.xx.', 22);\n  INSERT INTO t3 VALUES('two', 'x.xxx', 23);\n  INSERT INTO t3 VALUES('two', 'xx...', 24);\n  INSERT INTO t3 VALUES('two', 'xx..x', 25);\n  INSERT INTO t3 VALUES('two', 'xx.x.', 26);\n  INSERT INTO t3 VALUES('two', 'xx.xx', 27);\n  INSERT INTO t3 VALUES('two', 'xxx..', 28);\n  INSERT INTO t3 VALUES('two', 'xxx.x', 29);\n  INSERT INTO t3 VALUES('two', 'xxxx.', 30);\n  INSERT INTO t3 VALUES('two', 'xxxxx', 31);\n\n  INSERT INTO t3 SELECT * FROM t3;\n\n  CREATE INDEX i3 ON t3(a, b);\n  ANALYZE;\n\n  SELECT 'x' > '.';\n} {1}\n\nifcapable stat4 {\n  do_eqp_test 6.1 {\n    SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx';\n  } {\n    0 0 0 {SEARCH TABLE t3 USING INDEX i3 (ANY(a) AND b>? AND b<?)} \n    0 0 0 {USE TEMP B-TREE FOR DISTINCT}\n  }\n}\n\ndo_faultsim_test 6 -faults oom* -body {\n  db cache flush\n  db eval { SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx' }\n} -test {\n  faultsim_test_result {0 {12 13 14 15}} \n}\n\ndo_execsql_test 7.1 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b);\n}\ndo_faultsim_test 7.2 -faults oom* -body {\n  execsql { SELECT * FROM x1 WHERE a = (SELECT 1) }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\nreset_db\n\nproc isqrt {i} { expr { int(sqrt($i)) } }\ndb func isqrt isqrt\n\ndo_execsql_test 8.0 {\n  PRAGMA encoding = 'utf-16';\n  CREATE TABLE x2(x TEXT, y TEXT);\n  WITH data(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM data\n  )\n  INSERT INTO x2 SELECT isqrt(i), isqrt(i) FROM data LIMIT 400;\n  CREATE INDEX x2x ON x2(x);\n  CREATE INDEX x2y ON x2(y);\n  ANALYZE;\n  DELETE FROM x2;\n}\n\nproc str {a} { return $a }\ndb func str -deterministic str\n\ndo_faultsim_test 8 -faults oom* -body {\n  execsql { SELECT * FROM x2 WHERE x = str('19') AND y = str('4') }\n} -test {\n  faultsim_test_result [list 0 {}]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocL.test",
    "content": "# 2014 August 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test script is designed to show that the assert() fix at \n# [f1cb48f412] really is required.\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix mallocL\n\ndo_test 1.0 {\n  for {set i 0} {$i < 40} {incr i} { \n    lappend cols \"c$i\" \n    lappend vals $i\n  }\n\n  execsql \"CREATE TABLE t1([join $cols ,])\"\n  execsql \"CREATE INDEX i1 ON t1([join $cols ,])\"\n  execsql \"INSERT INTO t1 VALUES([join $vals ,])\"\n} {}\n\nfor {set j 1} {$j < 40} {incr j} {\n  set ::sql \"SELECT DISTINCT [join [lrange $cols 0 $j] ,] FROM t1\"\n  do_faultsim_test 1.$j -faults oom* -body {\n    execsql $::sql\n  } -test {\n    faultsim_test_result [list 0 [lrange $::vals 0 $::j]]\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mallocM.test",
    "content": "# 2017 March 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Further OOM tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix mallocM\n\nsqlite3_db_config_lookaside db 0 0 0\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x);\n}\ndo_faultsim_test 1 -faults oom* -body {\n  execsql {\n    SELECT 'abc' FROM ( SELECT 'xyz' FROM t1 WHERE (SELECT 1) )\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_execsql_test 2.0.1 { SELECT instr(x'', x'') }         {1}\ndo_execsql_test 2.0.2 { SELECT instr(x'12345678', x'') } {1}\ndo_execsql_test 2.0.3 { SELECT instr(x'', x'1234') }     {0}\n\ndo_faultsim_test 2.1 -faults oom* -body {\n  execsql { SELECT instr (x'00', zeroblob(1)) }\n} -test {\n  faultsim_test_result {0 1}\n}\n\ndo_faultsim_test 2.2 -faults oom* -body {\n  execsql { SELECT instr (zeroblob(1), x'00') }\n} -test {\n  faultsim_test_result {0 1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/malloc_common.tcl",
    "content": "# 2007 May 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains common code used by many different malloc tests\n# within the test suite.\n#\n# $Id: malloc_common.tcl,v 1.22 2008/09/23 16:41:30 danielk1977 Exp $\n\n# If we did not compile with malloc testing enabled, then do nothing.\n#\nifcapable builtin_test {\n  set MEMDEBUG 1\n} else {\n  set MEMDEBUG 0\n  return 0\n}\n\n# Transient and persistent OOM errors:\n#\nset FAULTSIM(oom-transient) [list          \\\n  -injectstart   {oom_injectstart 0}       \\\n  -injectstop    oom_injectstop            \\\n  -injecterrlist {{1 {out of memory}}}     \\\n]\nset FAULTSIM(oom-persistent) [list         \\\n  -injectstart {oom_injectstart 1000000}   \\\n  -injectstop oom_injectstop               \\\n  -injecterrlist {{1 {out of memory}}}     \\\n]\n  \n# Transient and persistent IO errors:\n#\nset FAULTSIM(ioerr-transient) [list        \\\n  -injectstart   {ioerr_injectstart 0}     \\\n  -injectstop    ioerr_injectstop          \\\n  -injecterrlist {{1 {disk I/O error}}}    \\\n]\nset FAULTSIM(ioerr-persistent) [list       \\\n  -injectstart   {ioerr_injectstart 1}     \\\n  -injectstop    ioerr_injectstop          \\\n  -injecterrlist {{1 {disk I/O error}}}    \\\n]\n\n# SQLITE_FULL errors (always persistent):\n#\nset FAULTSIM(full) [list                   \\\n  -injectinstall   fullerr_injectinstall   \\\n  -injectstart     fullerr_injectstart     \\\n  -injectstop      fullerr_injectstop      \\\n  -injecterrlist   {{1 {database or disk is full}}} \\\n  -injectuninstall fullerr_injectuninstall \\\n]\n\n# Transient and persistent SHM errors:\n#\nset FAULTSIM(shmerr-transient) [list       \\\n  -injectinstall   shmerr_injectinstall    \\\n  -injectstart     {shmerr_injectstart 0}  \\\n  -injectstop      shmerr_injectstop       \\\n  -injecterrlist   {{1 {disk I/O error}}}  \\\n  -injectuninstall shmerr_injectuninstall  \\\n]\nset FAULTSIM(shmerr-persistent) [list      \\\n  -injectinstall   shmerr_injectinstall    \\\n  -injectstart     {shmerr_injectstart 1}  \\\n  -injectstop      shmerr_injectstop       \\\n  -injecterrlist   {{1 {disk I/O error}}}  \\\n  -injectuninstall shmerr_injectuninstall  \\\n]\n\n# Transient and persistent CANTOPEN errors:\n#\nset FAULTSIM(cantopen-transient) [list       \\\n  -injectinstall   cantopen_injectinstall    \\\n  -injectstart     {cantopen_injectstart 0}  \\\n  -injectstop      cantopen_injectstop       \\\n  -injecterrlist   {{1 {unable to open database file}}}  \\\n  -injectuninstall cantopen_injectuninstall  \\\n]\nset FAULTSIM(cantopen-persistent) [list      \\\n  -injectinstall   cantopen_injectinstall    \\\n  -injectstart     {cantopen_injectstart 1}  \\\n  -injectstop      cantopen_injectstop       \\\n  -injecterrlist   {{1 {unable to open database file}}}  \\\n  -injectuninstall cantopen_injectuninstall  \\\n]\n\nset FAULTSIM(interrupt) [list                 \\\n  -injectinstall   interrupt_injectinstall    \\\n  -injectstart     interrupt_injectstart      \\\n  -injectstop      interrupt_injectstop       \\\n  -injecterrlist   {{1 interrupted} {1 interrupt}}        \\\n  -injectuninstall interrupt_injectuninstall  \\\n]\n\n\n\n#--------------------------------------------------------------------------\n# Usage do_faultsim_test NAME ?OPTIONS...? \n#\n#     -faults           List of fault types to simulate.\n#\n#     -prep             Script to execute before -body.\n#\n#     -body             Script to execute (with fault injection).\n#\n#     -test             Script to execute after -body.\n#\n#     -install          Script to execute after faultsim -injectinstall\n#\n#     -uninstall        Script to execute after faultsim -uninjectinstall\n#\nproc do_faultsim_test {name args} {\n  global FAULTSIM\n  \n  foreach n [array names FAULTSIM] {\n    if {$n != \"interrupt\"} {lappend DEFAULT(-faults) $n}\n  }\n  set DEFAULT(-prep)          \"\"\n  set DEFAULT(-body)          \"\"\n  set DEFAULT(-test)          \"\"\n  set DEFAULT(-install)       \"\"\n  set DEFAULT(-uninstall)     \"\"\n  set DEFAULT(-start)          1\n  set DEFAULT(-end)            0\n\n  fix_testname name\n\n  array set O [array get DEFAULT]\n  array set O $args\n  foreach o [array names O] {\n    if {[info exists DEFAULT($o)]==0} { error \"unknown option: $o\" }\n  }\n\n  set faultlist [list]\n  foreach f $O(-faults) {\n    set flist [array names FAULTSIM $f]\n    if {[llength $flist]==0} { error \"unknown fault: $f\" }\n    set faultlist [concat $faultlist $flist]\n  }\n\n  set testspec [list -prep $O(-prep) -body $O(-body) \\\n      -test $O(-test) -install $O(-install) -uninstall $O(-uninstall) \\\n      -start $O(-start) -end $O(-end)\n  ]\n  foreach f [lsort -unique $faultlist] {\n    eval do_one_faultsim_test \"$name-$f\" $FAULTSIM($f) $testspec\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# Procedures to save and restore the current file-system state:\n#\n#   faultsim_save\n#   faultsim_restore\n#   faultsim_save_and_close\n#   faultsim_restore_and_reopen\n#   faultsim_delete_and_reopen\n#\nproc faultsim_save {args} { uplevel db_save $args }\nproc faultsim_save_and_close {args} { uplevel db_save_and_close $args }\nproc faultsim_restore {args} { uplevel db_restore $args }\nproc faultsim_restore_and_reopen {args} { \n  uplevel db_restore_and_reopen $args \n  sqlite3_extended_result_codes db 1\n  sqlite3_db_config_lookaside db 0 0 0\n}\nproc faultsim_delete_and_reopen {args} {\n  uplevel db_delete_and_reopen $args \n  sqlite3_extended_result_codes db 1\n  sqlite3_db_config_lookaside db 0 0 0\n}\n\nproc faultsim_integrity_check {{db db}} {\n  set ic [$db eval { PRAGMA integrity_check }]\n  if {$ic != \"ok\"} { error \"Integrity check: $ic\" }\n}\n\n\n# The following procs are used as [do_one_faultsim_test] callbacks when \n# injecting OOM faults into test cases.\n#\nproc oom_injectstart {nRepeat iFail} {\n  sqlite3_memdebug_fail [expr $iFail-1] -repeat $nRepeat\n}\nproc oom_injectstop {} {\n  sqlite3_memdebug_fail -1\n}\n\n# The following procs are used as [do_one_faultsim_test] callbacks when \n# injecting IO error faults into test cases.\n#\nproc ioerr_injectstart {persist iFail} {\n  set ::sqlite_io_error_persist $persist\n  set ::sqlite_io_error_pending $iFail\n}\nproc ioerr_injectstop {} {\n  set sv $::sqlite_io_error_hit\n  set ::sqlite_io_error_persist 0\n  set ::sqlite_io_error_pending 0\n  set ::sqlite_io_error_hardhit 0\n  set ::sqlite_io_error_hit     0\n  set ::sqlite_io_error_pending 0\n  return $sv\n}\n\n# The following procs are used as [do_one_faultsim_test] callbacks when \n# injecting shared-memory related error faults into test cases.\n#\nproc shmerr_injectinstall {} {\n  testvfs shmfault -default true\n  shmfault filter {xShmOpen xShmMap xShmLock}\n}\nproc shmerr_injectuninstall {} {\n  catch {db  close}\n  catch {db2 close}\n  shmfault delete\n}\nproc shmerr_injectstart {persist iFail} {\n  shmfault ioerr $iFail $persist\n}\nproc shmerr_injectstop {} {\n  shmfault ioerr\n}\n\n# The following procs are used as [do_one_faultsim_test] callbacks when \n# injecting SQLITE_FULL error faults into test cases.\n#\nproc fullerr_injectinstall {} {\n  testvfs shmfault -default true\n}\nproc fullerr_injectuninstall {} {\n  catch {db  close}\n  catch {db2 close}\n  shmfault delete\n}\nproc fullerr_injectstart {iFail} {\n  shmfault full $iFail 1\n}\nproc fullerr_injectstop {} {\n  shmfault full\n}\n\n# The following procs are used as [do_one_faultsim_test] callbacks when \n# injecting SQLITE_CANTOPEN error faults into test cases.\n#\nproc cantopen_injectinstall {} {\n  testvfs shmfault -default true\n}\nproc cantopen_injectuninstall {} {\n  catch {db  close}\n  catch {db2 close}\n  shmfault delete\n}\nproc cantopen_injectstart {persist iFail} {\n  shmfault cantopen $iFail $persist\n}\nproc cantopen_injectstop {} {\n  shmfault cantopen\n}\n\n# The following procs are used as [do_one_faultsim_test] callbacks \n# when injecting SQLITE_INTERRUPT error faults into test cases.\n#\nproc interrupt_injectinstall {} {\n}\nproc interrupt_injectuninstall {} {\n}\nproc interrupt_injectstart {iFail} {\n  set ::sqlite_interrupt_count $iFail\n}\nproc interrupt_injectstop {} {\n  set res [expr $::sqlite_interrupt_count<=0]\n  set ::sqlite_interrupt_count 0\n  set res\n}\n\n# This command is not called directly. It is used by the \n# [faultsim_test_result] command created by [do_faultsim_test] and used\n# by -test scripts.\n#\nproc faultsim_test_result_int {args} {\n  upvar testrc testrc testresult testresult testnfail testnfail\n  set t [list $testrc $testresult]\n  set r $args\n  if { ($testnfail==0 && $t != [lindex $r 0]) || [lsearch -exact $r $t]<0 } {\n    error \"nfail=$testnfail rc=$testrc result=$testresult list=$r\"\n  }\n}\n\n#--------------------------------------------------------------------------\n# Usage do_one_faultsim_test NAME ?OPTIONS...? \n#\n# The first argument, <test number>, is used as a prefix of the test names\n# taken by tests executed by this command. Options are as follows. All\n# options take a single argument.\n#\n#     -injectstart      Script to enable fault-injection.\n#\n#     -injectstop       Script to disable fault-injection.\n#\n#     -injecterrlist    List of generally acceptable test results (i.e. error\n#                       messages). Example: [list {1 {out of memory}}]\n#\n#     -injectinstall\n#\n#     -injectuninstall\n#\n#     -prep             Script to execute before -body.\n#\n#     -body             Script to execute (with fault injection).\n#\n#     -test             Script to execute after -body.\n#\n#     -start            Index of first fault to inject (default 1)\n#\nproc do_one_faultsim_test {testname args} {\n\n  set DEFAULT(-injectstart)     \"expr\"\n  set DEFAULT(-injectstop)      \"expr 0\"\n  set DEFAULT(-injecterrlist)   [list]\n  set DEFAULT(-injectinstall)   \"\"\n  set DEFAULT(-injectuninstall) \"\"\n  set DEFAULT(-prep)            \"\"\n  set DEFAULT(-body)            \"\"\n  set DEFAULT(-test)            \"\"\n  set DEFAULT(-install)         \"\"\n  set DEFAULT(-uninstall)       \"\"\n  set DEFAULT(-start)           1\n  set DEFAULT(-end)             0\n\n  array set O [array get DEFAULT]\n  array set O $args\n  foreach o [array names O] {\n    if {[info exists DEFAULT($o)]==0} { error \"unknown option: $o\" }\n  }\n\n  proc faultsim_test_proc {testrc testresult testnfail} $O(-test)\n  proc faultsim_test_result {args} \"\n    uplevel faultsim_test_result_int \\$args [list $O(-injecterrlist)]\n  \"\n\n  eval $O(-injectinstall)\n  eval $O(-install)\n\n  set stop 0\n  for {set iFail $O(-start)}                        \\\n      {!$stop && ($O(-end)==0 || $iFail<=$O(-end))} \\\n      {incr iFail}                                  \\\n  {\n\n    # Evaluate the -prep script.\n    #\n    eval $O(-prep)\n\n    # Start the fault-injection. Run the -body script. Stop the fault\n    # injection. Local var $nfail is set to the total number of faults \n    # injected into the system this trial.\n    #\n    eval $O(-injectstart) $iFail\n    set rc [catch $O(-body) res]\n    set nfail [eval $O(-injectstop)]\n\n    # Run the -test script. If it throws no error, consider this trial\n    # sucessful. If it does throw an error, cause a [do_test] test to\n    # fail (and print out the unexpected exception thrown by the -test\n    # script at the same time).\n    #\n    set rc [catch [list faultsim_test_proc $rc $res $nfail] res]\n    if {$rc == 0} {set res ok}\n    do_test $testname.$iFail [list list $rc $res] {0 ok}\n\n    # If no faults where injected this trial, don't bother running\n    # any more. This test is finished.\n    #\n    if {$nfail==0} { set stop 1 }\n  }\n\n  eval $O(-uninstall)\n  eval $O(-injectuninstall)\n}\n\n# Usage: do_malloc_test <test number> <options...>\n#\n# The first argument, <test number>, is an integer used to name the\n# tests executed by this proc. Options are as follows:\n#\n#     -tclprep          TCL script to run to prepare test.\n#     -sqlprep          SQL script to run to prepare test.\n#     -tclbody          TCL script to run with malloc failure simulation.\n#     -sqlbody          TCL script to run with malloc failure simulation.\n#     -cleanup          TCL script to run after the test.\n#\n# This command runs a series of tests to verify SQLite's ability\n# to handle an out-of-memory condition gracefully. It is assumed\n# that if this condition occurs a malloc() call will return a\n# NULL pointer. Linux, for example, doesn't do that by default. See\n# the \"BUGS\" section of malloc(3).\n#\n# Each iteration of a loop, the TCL commands in any argument passed\n# to the -tclbody switch, followed by the SQL commands in any argument\n# passed to the -sqlbody switch are executed. Each iteration the\n# Nth call to sqliteMalloc() is made to fail, where N is increased\n# each time the loop runs starting from 1. When all commands execute\n# successfully, the loop ends.\n#\nproc do_malloc_test {tn args} {\n  array unset ::mallocopts \n  array set ::mallocopts $args\n\n  if {[string is integer $tn]} {\n    set tn malloc-$tn\n    catch { set tn $::testprefix-$tn }\n  }\n  if {[info exists ::mallocopts(-start)]} {\n    set start $::mallocopts(-start)\n  } else {\n    set start 0\n  }\n  if {[info exists ::mallocopts(-end)]} {\n    set end $::mallocopts(-end)\n  } else {\n    set end 50000\n  }\n  save_prng_state\n\n  foreach ::iRepeat {0 10000000} {\n    set ::go 1\n    for {set ::n $start} {$::go && $::n <= $end} {incr ::n} {\n\n      # If $::iRepeat is 0, then the malloc() failure is transient - it\n      # fails and then subsequent calls succeed. If $::iRepeat is 1, \n      # then the failure is persistent - once malloc() fails it keeps\n      # failing.\n      #\n      set zRepeat \"transient\"\n      if {$::iRepeat} {set zRepeat \"persistent\"}\n      restore_prng_state\n      foreach file [glob -nocomplain test.db-mj*] {forcedelete $file}\n\n      do_test ${tn}.${zRepeat}.${::n} {\n  \n        # Remove all traces of database files test.db and test2.db \n        # from the file-system. Then open (empty database) \"test.db\" \n        # with the handle [db].\n        # \n        catch {db close} \n        catch {db2 close} \n        forcedelete test.db\n        forcedelete test.db-journal\n        forcedelete test.db-wal\n        forcedelete test2.db\n        forcedelete test2.db-journal\n        forcedelete test2.db-wal\n        if {[info exists ::mallocopts(-testdb)]} {\n          copy_file $::mallocopts(-testdb) test.db\n        }\n        catch { sqlite3 db test.db }\n        if {[info commands db] ne \"\"} {\n          sqlite3_extended_result_codes db 1\n        }\n        sqlite3_db_config_lookaside db 0 0 0\n  \n        # Execute any -tclprep and -sqlprep scripts.\n        #\n        if {[info exists ::mallocopts(-tclprep)]} {\n          eval $::mallocopts(-tclprep)\n        }\n        if {[info exists ::mallocopts(-sqlprep)]} {\n          execsql $::mallocopts(-sqlprep)\n        }\n  \n        # Now set the ${::n}th malloc() to fail and execute the -tclbody \n        # and -sqlbody scripts.\n        #\n        sqlite3_memdebug_fail $::n -repeat $::iRepeat\n        set ::mallocbody {}\n        if {[info exists ::mallocopts(-tclbody)]} {\n          append ::mallocbody \"$::mallocopts(-tclbody)\\n\"\n        }\n        if {[info exists ::mallocopts(-sqlbody)]} {\n          append ::mallocbody \"db eval {$::mallocopts(-sqlbody)}\"\n        }\n\n        # The following block sets local variables as follows:\n        #\n        #     isFail  - True if an error (any error) was reported by sqlite.\n        #     nFail   - The total number of simulated malloc() failures.\n        #     nBenign - The number of benign simulated malloc() failures.\n        #\n        set isFail [catch $::mallocbody msg]\n        set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]\n        # puts -nonewline \" (isFail=$isFail nFail=$nFail nBenign=$nBenign) \"\n\n        # If one or more mallocs failed, run this loop body again.\n        #\n        set go [expr {$nFail>0}]\n\n        if {($nFail-$nBenign)==0} {\n          if {$isFail} {\n            set v2 $msg\n          } else {\n            set isFail 1\n            set v2 1\n          }\n        } elseif {!$isFail} {\n          set v2 $msg\n        } elseif {\n          [info command db]==\"\" || \n          [db errorcode]==7 ||\n          $msg==\"out of memory\"\n        } {\n          set v2 1\n        } else {\n          set v2 $msg\n          puts [db errorcode]\n        }\n        lappend isFail $v2\n      } {1 1}\n  \n      if {[info exists ::mallocopts(-cleanup)]} {\n        catch [list uplevel #0 $::mallocopts(-cleanup)] msg\n      }\n    }\n  }\n  unset ::mallocopts\n  sqlite3_memdebug_fail -1\n}\n\n\n#-------------------------------------------------------------------------\n# This proc is used to test a single SELECT statement. Parameter $name is\n# passed a name for the test case (i.e. \"fts3_malloc-1.4.1\") and parameter\n# $sql is passed the text of the SELECT statement. Parameter $result is\n# set to the expected output if the SELECT statement is successfully\n# executed using [db eval].\n#\n# Example:\n#\n#   do_select_test testcase-1.1 \"SELECT 1+1, 1+2\" {1 2}\n#\n# If global variable DO_MALLOC_TEST is set to a non-zero value, or if\n# it is not defined at all, then OOM testing is performed on the SELECT\n# statement. Each OOM test case is said to pass if either (a) executing\n# the SELECT statement succeeds and the results match those specified\n# by parameter $result, or (b) TCL throws an \"out of memory\" error.\n#\n# If DO_MALLOC_TEST is defined and set to zero, then the SELECT statement\n# is executed just once. In this case the test case passes if the results\n# match the expected results passed via parameter $result.\n#\nproc do_select_test {name sql result} {\n  uplevel [list doPassiveTest 0 $name $sql [list 0 [list {*}$result]]]\n}\n\nproc do_restart_select_test {name sql result} {\n  uplevel [list doPassiveTest 1 $name $sql [list 0 $result]]\n}\n\nproc do_error_test {name sql error} {\n  uplevel [list doPassiveTest 0 $name $sql [list 1 $error]]\n}\n\nproc doPassiveTest {isRestart name sql catchres} {\n  if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 }\n\n  if {[info exists ::testprefix] \n   && [string is integer [string range $name 0 0]]\n  } {\n    set name $::testprefix.$name\n  }\n\n  switch $::DO_MALLOC_TEST {\n    0 { # No malloc failures.\n      do_test $name [list set {} [uplevel [list catchsql $sql]]] $catchres\n      return\n    }\n    1 { # Simulate transient failures.\n      set nRepeat 1\n      set zName \"transient\"\n      set nStartLimit 100000\n      set nBackup 1\n    }\n    2 { # Simulate persistent failures.\n      set nRepeat 1\n      set zName \"persistent\"\n      set nStartLimit 100000\n      set nBackup 1\n    }\n    3 { # Simulate transient failures with extra brute force.\n      set nRepeat 100000\n      set zName \"ridiculous\"\n      set nStartLimit 1\n      set nBackup 10\n    }\n  }\n\n  # The set of acceptable results from running [catchsql $sql].\n  #\n  set answers [list {1 {out of memory}} $catchres]\n  set str [join $answers \" OR \"]\n\n  set nFail 1\n  for {set iLimit $nStartLimit} {$nFail} {incr iLimit} {\n    for {set iFail 1} {$nFail && $iFail<=$iLimit} {incr iFail} {\n      for {set iTest 0} {$iTest<$nBackup && ($iFail-$iTest)>0} {incr iTest} {\n\n        if {$isRestart} { sqlite3 db test.db }\n\n        sqlite3_memdebug_fail [expr $iFail-$iTest] -repeat $nRepeat\n        set res [uplevel [list catchsql $sql]]\n        if {[lsearch -exact $answers $res]>=0} { set res $str }\n        set testname \"$name.$zName.$iFail\"\n        do_test \"$name.$zName.$iLimit.$iFail\" [list set {} $res] $str\n\n        set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]\n      }\n    }\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# Test a single write to the database. In this case a  \"write\" is a \n# DELETE, UPDATE or INSERT statement.\n#\n# If OOM testing is performed, there are several acceptable outcomes:\n#\n#   1) The write succeeds. No error is returned.\n#\n#   2) An \"out of memory\" exception is thrown and:\n#\n#     a) The statement has no effect, OR\n#     b) The current transaction is rolled back, OR\n#     c) The statement succeeds. This can only happen if the connection\n#        is in auto-commit mode (after the statement is executed, so this\n#        includes COMMIT statements).\n#\n# If the write operation eventually succeeds, zero is returned. If a\n# transaction is rolled back, non-zero is returned.\n#\n# Parameter $name is the name to use for the test case (or test cases).\n# The second parameter, $tbl, should be the name of the database table\n# being modified. Parameter $sql contains the SQL statement to test.\n#\nproc do_write_test {name tbl sql} {\n  if {![info exists ::DO_MALLOC_TEST]} { set ::DO_MALLOC_TEST 1 }\n\n  # Figure out an statement to get a checksum for table $tbl.\n  db eval \"SELECT * FROM $tbl\" V break\n  set cksumsql \"SELECT md5sum([join [concat rowid $V(*)] ,]) FROM $tbl\"\n\n  # Calculate the initial table checksum.\n  set cksum1 [db one $cksumsql]\n\n  if {$::DO_MALLOC_TEST } {\n    set answers [list {1 {out of memory}} {0 {}}]\n    if {$::DO_MALLOC_TEST==1} {\n      set modes {100000 persistent}\n    } else {\n      set modes {1 transient}\n    }\n  } else {\n    set answers [list {0 {}}]\n    set modes [list 0 nofail]\n  }\n  set str [join $answers \" OR \"]\n\n  foreach {nRepeat zName} $modes {\n    for {set iFail 1} 1 {incr iFail} {\n      if {$::DO_MALLOC_TEST} {sqlite3_memdebug_fail $iFail -repeat $nRepeat}\n\n      set res [uplevel [list catchsql $sql]]\n      set nFail [sqlite3_memdebug_fail -1 -benigncnt nBenign]\n      if {$nFail==0} {\n        do_test $name.$zName.$iFail [list set {} $res] {0 {}}\n        return\n      } else {\n        if {[lsearch $answers $res]>=0} {\n          set res $str\n        }\n        do_test $name.$zName.$iFail [list set {} $res] $str\n        set cksum2 [db one $cksumsql]\n        if {$cksum1 != $cksum2} return\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/manydb.test",
    "content": "# 2005 October 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests the ability of the library to open\n# many different databases at the same time without leaking memory.\n#\n# $Id: manydb.test,v 1.4 2008/11/21 00:10:35 aswift Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset N 300\n# if we're using proxy locks, we use 5 filedescriptors for a db\n# that is open and in the middle of writing changes, normally\n# sqlite uses 3 (proxy locking adds the conch and the local lock)\nset using_proxy 0\nforeach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n  set using_proxy value\n}\nset num_fd_per_openwrite_db 3\nif {$using_proxy>0} {\n  set num_fd_per_openwrite_db 5\n} \n\n# First test how many file descriptors are available for use. To open a\n# database for writing SQLite requires 3 file descriptors (the database, the\n# journal and the directory).\nset filehandles {}\ncatch {\n  for {set i 0} {$i<($N * 3)} {incr i} {\n    lappend filehandles [open testfile.1 w]\n  }\n}\nforeach fd $filehandles {\n  close $fd\n}\ncatch {\n  forcedelete testfile.1\n}\nset N [expr $i / $num_fd_per_openwrite_db]\n\n# Create a bunch of random database names\n#\nunset -nocomplain dbname\nunset -nocomplain used\nfor {set i 0} {$i<$N} {incr i} {\n  while 1 {\n    set name test-[format %08x [expr {int(rand()*0x7fffffff)}]].db\n    if {[info exists used($name)]} continue\n    set dbname($i) $name\n    set used($name) $i\n    break\n  }\n}\n\n# Create a bunch of databases\n#\nfor {set i 0} {$i<$N} {incr i} {\n  do_test manydb-1.$i {\n    sqlite3 db$i $dbname($i)\n    execsql {\n       CREATE TABLE t1(a,b);\n       BEGIN;\n       INSERT INTO t1 VALUES(1,2);\n    } db$i\n  } {}\n}\n\n# Finish the transactions\n#\nfor {set i 0} {$i<$N} {incr i} {\n  do_test manydb-2.$i {\n    execsql {\n       COMMIT;\n       SELECT * FROM t1;\n    } db$i\n  } {1 2}\n}\n\n\n# Close the databases and erase the files.\n#\nfor {set i 0} {$i<$N} {incr i} {\n  do_test manydb-3.$i {\n    db$i close\n    forcedelete $dbname($i)\n  } {}\n}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mem5.test",
    "content": "# 2011 March 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests of the mem5 allocation subsystem.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !mem5 {\n  finish_test\n  return\n}\n\n# The tests in this file configure the lookaside allocator after a \n# connection is opened. This will not work if there is any \"presql\"\n# configured (SQL run within the [sqlite3] wrapper in tester.tcl).\nif {[info exists ::G(perm:presql)]} {\n  finish_test\n  return\n}\n\ndo_test mem5-1.1 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap 25000000 0\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n} {SQLITE_OK}\n\n# try with min request size = 2^30\ndo_test mem5-1.2 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap 1 1073741824\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n} {SQLITE_NOMEM}\n\n# try with min request size = 2^30+1\n# previously this was causing the memsys5Log() func to infinitely loop.\ndo_test mem5-1.3 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap 1 1073741825\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n} {SQLITE_NOMEM}\n\ndo_test mem5-1.4 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap 0 0\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n} {SQLITE_OK}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/memdb.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is in-memory database backend.\n#\n# $Id: memdb.test,v 1.19 2009/05/18 16:04:38 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable memorydb {\n\n# In the following sequence of tests, compute the MD5 sum of the content\n# of a table, make lots of modifications to that table, then do a rollback.\n# Verify that after the rollback, the MD5 checksum is unchanged.\n#\n# These tests were browed from trans.tcl.\n#\ndo_test memdb-1.1 {\n  db close\n  sqlite3 db :memory:\n  # sqlite3 db test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(x TEXT);\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    COMMIT;\n    SELECT count(*) FROM t3;\n  }\n} {1024}\n\n# The following procedure computes a \"signature\" for table \"t3\".  If\n# T3 changes in any way, the signature should change.  \n#\n# This is used to test ROLLBACK.  We gather a signature for t3, then\n# make lots of changes to t3, then rollback and take another signature.\n# The two signatures should be the same.\n#\nproc signature {{fn {}}} {\n  set rx [db eval {SELECT x FROM t3}]\n  # set r1 [md5 $rx\\n]\n  if {$fn!=\"\"} {\n    # set fd [open $fn w]\n    # puts $fd $rx\n    # close $fd\n  }\n  # set r [db eval {SELECT count(*), md5sum(x) FROM t3}]\n  # puts \"SIG($fn)=$r1\"\n  return [list [string length $rx] $rx]\n}\n\n# Do rollbacks.  Make sure the signature does not change.\n#\nset limit 10\nfor {set i 2} {$i<=$limit} {incr i} {\n  set ::sig [signature one]\n  # puts \"sig=$sig\"\n  set cnt [lindex $::sig 0]\n  if {$i%2==0} {\n    execsql {PRAGMA synchronous=FULL}\n  } else {\n    execsql {PRAGMA synchronous=NORMAL}\n  }\n  do_test memdb-1.$i.1-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     set sig2 [signature two]\n  } $sig\n  # puts \"sig2=$sig2\"\n  # if {$sig2!=$sig} exit\n  do_test memdb-1.$i.2-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     signature\n  } $sig\n  if {$i<$limit} {\n    do_test memdb-1.$i.9-$cnt {\n       execsql {\n         INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;\n       }\n    } {}\n  }\n  set ::pager_old_format 0\n}\n\nintegrity_check memdb-2.1\n\ndo_test memdb-3.1 {\n  execsql {\n    CREATE TABLE t4(a,b,c,d);\n    BEGIN;\n    INSERT INTO t4 VALUES(1,2,3,4);\n    SELECT * FROM t4;\n  }\n} {1 2 3 4}\ndo_test memdb-3.2 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type='table';\n  }\n} {t3 t4}\ndo_test memdb-3.3 {\n  execsql {\n    DROP TABLE t4;\n    SELECT name FROM sqlite_master WHERE type='table';\n  }\n} {t3}\ndo_test memdb-3.4 {\n  execsql {\n    ROLLBACK;\n    SELECT name FROM sqlite_master WHERE type='table';\n  }\n} {t3 t4}\n\n# Create tables for the first group of tests.\n#\ndo_test memdb-4.0 {\n  execsql {\n    CREATE TABLE t1(a, b, c, UNIQUE(a,b));\n    CREATE TABLE t2(x);\n    SELECT c FROM t1 ORDER BY c;\n  }\n} {}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf   The conflict resolution algorithm on the BEGIN statement\n#   cmd    An INSERT or REPLACE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"c\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t2\n#\nforeach {i conf cmd t0 t1 t2} {\n  1 {}       INSERT                  1 {}  1\n  2 {}       {INSERT OR IGNORE}      0 3   1\n  3 {}       {INSERT OR REPLACE}     0 4   1\n  4 {}       REPLACE                 0 4   1\n  5 {}       {INSERT OR FAIL}        1 {}  1\n  6 {}       {INSERT OR ABORT}       1 {}  1\n  7 {}       {INSERT OR ROLLBACK}    1 {}  {}\n} {\n\n  # All tests after test 1 depend on conflict resolution. So end the\n  # loop if that is not available in this build.\n  ifcapable !conflict {if {$i>1} break}\n\n  do_test memdb-4.$i {\n    if {$conf!=\"\"} {set conf \"ON CONFLICT $conf\"}\n    set r0 [catch {execsql [subst {\n      DELETE FROM t1;\n      DELETE FROM t2;\n      INSERT INTO t1 VALUES(1,2,3);\n      BEGIN $conf;\n      INSERT INTO t2 VALUES(1); \n      $cmd INTO t1 VALUES(1,2,4);\n    }]} r1]\n    catch {execsql {COMMIT}}\n    if {$r0} {set r1 {}} {set r1 [execsql {SELECT c FROM t1}]}\n    set r2 [execsql {SELECT x FROM t2}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test memdb-5.0 {\n  execsql {\n    DROP TABLE t2;\n    DROP TABLE t3;\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES(1,2,1);\n    INSERT INTO t2 VALUES(2,3,2);\n    INSERT INTO t2 VALUES(3,4,1);\n    INSERT INTO t2 VALUES(4,5,4);\n    SELECT c FROM t2 ORDER BY b;\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n  }\n} {1 2 1 4}\n\n# Six columns of configuration data as follows:\n#\n#   i      The reference number of the test\n#   conf1  The conflict resolution algorithm on the UNIQUE constraint\n#   conf2  The conflict resolution algorithm on the BEGIN statement\n#   cmd    An UPDATE command to execute against table t1\n#   t0     True if there is an error from $cmd\n#   t1     Content of \"b\" column of t1 assuming no error in $cmd\n#   t2     Content of \"x\" column of t3\n#\nforeach {i conf1 conf2 cmd t0 t1 t2} {\n  1 {}       {}       UPDATE                  1 {6 7 8 9}  1\n  2 REPLACE  {}       UPDATE                  0 {7 6 9}    1\n  3 IGNORE   {}       UPDATE                  0 {6 7 3 9}  1\n  4 FAIL     {}       UPDATE                  1 {6 7 3 4}  1\n  5 ABORT    {}       UPDATE                  1 {1 2 3 4}  1\n  6 ROLLBACK {}       UPDATE                  1 {1 2 3 4}  0\n  7 REPLACE  {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1\n  8 IGNORE   {}       {UPDATE OR REPLACE}     0 {7 6 9}    1\n  9 FAIL     {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1\n 10 ABORT    {}       {UPDATE OR REPLACE}     0 {7 6 9}    1\n 11 ROLLBACK {}       {UPDATE OR IGNORE}      0 {6 7 3 9}   1\n 12 {}       {}       {UPDATE OR IGNORE}      0 {6 7 3 9}  1\n 13 {}       {}       {UPDATE OR REPLACE}     0 {7 6 9}    1\n 14 {}       {}       {UPDATE OR FAIL}        1 {6 7 3 4}  1\n 15 {}       {}       {UPDATE OR ABORT}       1 {1 2 3 4}  1\n 16 {}       {}       {UPDATE OR ROLLBACK}    1 {1 2 3 4}  0\n} {\n  # All tests after test 1 depend on conflict resolution. So end the\n  # loop if that is not available in this build.\n  ifcapable !conflict {\n    if {$i>1} break\n  }\n\n  if {$t0} {set t1 {UNIQUE constraint failed: t1.a}}\n  do_test memdb-5.$i {\n    if {$conf1!=\"\"} {set conf1 \"ON CONFLICT $conf1\"}\n    if {$conf2!=\"\"} {set conf2 \"ON CONFLICT $conf2\"}\n    set r0 [catch {execsql \"\n      DROP TABLE t1;\n      CREATE TABLE t1(a,b,c, UNIQUE(a) $conf1);\n      INSERT INTO t1 SELECT * FROM t2;\n      UPDATE t3 SET x=0;\n      BEGIN $conf2;\n      $cmd t3 SET x=1;\n      $cmd t1 SET b=b*2;\n      $cmd t1 SET a=c+5;\n    \"} r1]\n    catch {execsql {COMMIT}}\n    if {!$r0} {set r1 [execsql {SELECT a FROM t1 ORDER BY b}]}\n    set r2 [execsql {SELECT x FROM t3}]\n    list $r0 $r1 $r2\n  } [list $t0 $t1 $t2]\n}\n\ndo_test memdb-6.1 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 1 2 3 2 3 4 1 4 5 4}\ndo_test memdb-6.2 {\n  execsql {\n    BEGIN;\n    DROP TABLE t2;\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n  }\n} {t1 t3 t4}\ndo_test memdb-6.3 {\n  execsql {\n    ROLLBACK;\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n  }\n} {t1 t2 t3 t4}\ndo_test memdb-6.4 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 1 2 3 2 3 4 1 4 5 4}\nifcapable compound {\ndo_test memdb-6.5 {\n  execsql {\n    SELECT a FROM t2 UNION SELECT b FROM t2 ORDER BY 1;\n  }\n} {1 2 3 4 5}\n} ;# ifcapable compound \ndo_test memdb-6.6 {\n  execsql {\n    CREATE INDEX i2 ON t2(c);\n    SELECT a FROM t2 ORDER BY c;\n  }\n} {1 3 2 4}\ndo_test memdb-6.6 {\n  execsql {\n    SELECT a FROM t2 ORDER BY c DESC;\n  }\n} {4 2 3 1}\ndo_test memdb-6.7 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t5(x,y);\n    INSERT INTO t5 VALUES(1,2);\n    SELECT * FROM t5;\n  }\n} {1 2}\ndo_test memdb-6.8 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n  }\n} {t1 t2 t3 t4 t5}\ndo_test memdb-6.9 {\n  execsql {\n    ROLLBACK;\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n  }\n} {t1 t2 t3 t4}\ndo_test memdb-6.10 {\n  execsql {\n    CREATE TABLE t5(x PRIMARY KEY, y UNIQUE);\n    SELECT * FROM t5;\n  }\n} {}\ndo_test memdb-6.11 {\n  execsql {\n    SELECT * FROM t5 ORDER BY y DESC;\n  }\n} {}\n\nifcapable conflict {\n  do_test memdb-6.12 {\n    execsql {\n      INSERT INTO t5 VALUES(1,2);\n      INSERT INTO t5 VALUES(3,4);\n      REPLACE INTO t5 VALUES(1,4);\n      SELECT rowid,* FROM t5;\n    }\n  } {3 1 4}\n  do_test memdb-6.13 {\n    execsql {\n      DELETE FROM t5 WHERE x>5;\n      SELECT * FROM t5;\n    }\n  } {1 4}\n  do_test memdb-6.14 {\n    execsql {\n      DELETE FROM t5 WHERE y<3;\n      SELECT * FROM t5;\n    }\n  } {1 4}\n}\n\ndo_test memdb-6.15 {\n  execsql {\n    DELETE FROM t5 WHERE x>0;\n    SELECT * FROM t5;\n  }\n} {}\n\nifcapable subquery&&vtab {\n  do_test memdb-7.1 {\n    load_static_extension db wholenumber\n    execsql {\n      CREATE TABLE t6(x);\n      CREATE VIRTUAL TABLE nums USING wholenumber;\n      INSERT INTO t6 SELECT value FROM nums WHERE value BETWEEN 1 AND 256;\n      SELECT count(*) FROM (SELECT DISTINCT x FROM t6);\n    }\n  } {256}\n  for {set i 1} {$i<=256} {incr i} {\n    do_test memdb-7.2.$i {\n       execsql \"DELETE FROM t6 WHERE x=\\\n                (SELECT x FROM t6 ORDER BY random() LIMIT 1)\"\n       execsql {SELECT count(*) FROM t6}\n    } [expr {256-$i}]\n  }\n}\n\n# Ticket #1524\n#\ndo_test memdb-8.1 {\n  db close\n  sqlite3 db {:memory:}\n  execsql {\n    PRAGMA auto_vacuum=TRUE;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(randstr(5000,6000));\n    INSERT INTO t1 VALUES(randstr(5000,6000));\n    INSERT INTO t1 VALUES(randstr(5000,6000));\n    INSERT INTO t1 VALUES(randstr(5000,6000));\n    INSERT INTO t1 VALUES(randstr(5000,6000));\n    SELECT count(*) FROM t1;\n  }\n} 5\ndo_test memdb-8.2 {\n  execsql {\n    DELETE FROM t1;\n    SELECT count(*) FROM t1;\n  }\n} 0\n\n# Test that auto-vacuum works with in-memory databases.\n# \nifcapable autovacuum {\n  do_test memdb-9.1 {\n    db close\n    sqlite3 db test.db\n    db cache size 0\n    execsql {\n      PRAGMA auto_vacuum = full;\n      CREATE TABLE t1(a);\n      INSERT INTO t1 VALUES(randstr(1000,1000));\n      INSERT INTO t1 VALUES(randstr(1000,1000));\n      INSERT INTO t1 VALUES(randstr(1000,1000));\n    }\n    set before [db one {PRAGMA page_count}]\n    execsql { DELETE FROM t1 }\n    set after [db one {PRAGMA page_count}]\n    expr {$before>$after}\n  } {1}\n}\n\n} ;# ifcapable memorydb\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/memleak.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n# $Id: memleak.test,v 1.10 2007/03/30 17:17:52 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nrename finish_test memleak_finish_test\nproc finish_test {} {\n  catch {db close}\n  memleak_check\n}\n\nif {[file exists ./sqlite_test_count]} {\n  set COUNT [exec cat ./sqlite_test_count]\n} else {\n  set COUNT 3\n}\n\n# LeakList will hold a list of the number of unfreed mallocs after\n# each round of the test.  This number should be constant.  If it\n# grows, it may mean there is a memory leak in the library.\n#\nset LeakList {}\n\nset EXCLUDE {\n  all.test\n  quick.test\n  misuse.test\n  memleak.test\n  btree2.test\n  async.test\n  async2.test\n  trans.test\n  crash.test\n  autovacuum_crash.test\n}\n# Test files btree2.test and btree4.test don't work if the \n# SQLITE_DEFAULT_AUTOVACUUM macro is defined to true (because they depend\n# on tables being allocated starting at page 2).\n#\nifcapable default_autovacuum {\n  lappend EXCLUDE btree2.test\n  lappend EXCLUDE btree4.test\n}\n\nif {[sqlite3 -has-codec]} {\n  # lappend EXCLUDE \n}\nif {[llength $argv]>0} {\n  set FILELIST $argv\n  set argv {}\n} else {\n  set FILELIST [lsort -dictionary [glob $testdir/*.test]]\n}\n\nforeach testfile $FILELIST {\n  set tail [file tail $testfile]\n  if {[lsearch -exact $EXCLUDE $tail]>=0} continue\n  set LeakList {}\n  for {set COUNTER 0} {$COUNTER<$COUNT} {incr COUNTER} {\n    source $testfile\n    if {[info exists Leak]} {\n      lappend LeakList $Leak\n    }\n  }\n  if {$LeakList!=\"\"} {\n    puts -nonewline memory-leak-test-$tail...\n    incr_ntest\n    foreach x $LeakList {\n      if {$x!=[lindex $LeakList 0]} {\n         puts \" failed! ($LeakList)\"\n         fail_test memory-leak-test-$tail\n         break\n       }\n    }\n    puts \" Ok\"\n  }\n}\nmemleak_finish_test\n\n# Run the malloc tests and the misuse test after memory leak detection.\n# Both tests leak memory.\n#\n#catch {source $testdir/misuse.test}\n#catch {source $testdir/malloc.test}\n\nmemleak_finish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/memsubsys1.test",
    "content": "# 2008 June 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests of the memory allocation subsystem\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsqlite3_reset_auto_extension\n\n# This test assumes that no page-cache buffers are installed\n# by default when a new database connection is opened. As a result, it\n# will not work with the \"memsubsys1\" permutation.\n#\nif {[permutation] == \"memsubsys1\"} {\n  finish_test\n  return\n}\n\ntest_set_config_pagecache 0 0\n\n# This procedure constructs a new database in test.db.  It fills\n# this database with many small records (enough to force multiple\n# rebalance operations in the btree-layer and to require a large\n# page cache), verifies correct results, then returns.\n#\nproc build_test_db {testname pragmas} {\n  catch {db close}\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n  db eval $pragmas\n  db eval {\n    CREATE TABLE t1(x, y);\n    CREATE TABLE t2(a, b);\n    CREATE INDEX i1 ON t1(x,y);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 200);\n  }\n  for {set i 2} {$i<5000} {incr i $i} {\n    db eval {INSERT INTO t2 SELECT * FROM t1}\n    db eval {INSERT INTO t1 SELECT a+$i, a+b*100 FROM t2}\n    db eval {DELETE FROM t2}\n  }\n  do_test $testname.1 {\n    db eval {SELECT count(*) FROM t1}\n  } 8192\n  integrity_check $testname.2\n}\n\n# Reset all of the highwater marks.\n#\nproc reset_highwater_marks {} {\n  sqlite3_status SQLITE_STATUS_MEMORY_USED 1\n  sqlite3_status SQLITE_STATUS_MALLOC_SIZE 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_USED 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 1\n  sqlite3_status SQLITE_STATUS_PARSER_STACK 1\n}\n\nset xtra_size 290\n\n# Test 1:  Both PAGECACHE and SCRATCH are shut down.\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_lookaside 0 0\nsqlite3_config_pagecache 0 0\nsqlite3_initialize\nreset_highwater_marks\nbuild_test_db memsubsys1-1 {PRAGMA page_size=1024}\ndo_test memsubsys1-1.3 {\n  set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]\n} 0\ndo_test memsubsys1-1.4 {\n  set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]\n} 0\nset max_pagecache [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]\n#show_memstats\n\n# Test 2:  Activate PAGECACHE with 20 pages\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_pagecache [expr 1024+$xtra_size] 20\nsqlite3_initialize\nreset_highwater_marks\nbuild_test_db memsubsys1-2 {PRAGMA page_size=1024; PRAGMA mmap_size=0}\n#show_memstats\nset MEMORY_MANAGEMENT $sqlite_options(memorymanage)\nifcapable pagecache_overflow_stats {\n  ifcapable !malloc_usable_size {\n    do_test memsubsys1-2.3 {\n      set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]\n    } [expr ($TEMP_STORE>1 || $MEMORY_MANAGEMENT==0)*1024]\n  }\n}\ndo_test memsubsys1-2.4 {\n  set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]\n} 20\ndo_test memsubsys1-2.5 {\n  set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]\n} 0\n\n# Test 3:  Activate PAGECACHE with 20 pages but use the wrong page size\n# so that PAGECACHE is not used.\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_pagecache [expr 512+$xtra_size] 20\nsqlite3_config singlethread\nsqlite3_initialize\nreset_highwater_marks\nbuild_test_db memsubsys1-3.1 {PRAGMA page_size=1024}\ndo_test memsubsys1-3.1.3 {\n  set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]\n} 0\ndo_test memsubsys1-3.1.4 {\n  set overflow [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]\n  # Note:  The measured PAGECACHE_OVERFLOW is amount malloc() returns, not what\n  # was requested.  System malloc() implementations might (arbitrarily) return\n  # slightly different oversize buffers, which can result in slightly different\n  # PAGECACHE_OVERFLOW sizes between consecutive runs.  So we cannot do an\n  # exact comparison.  Simply verify that the amount is within 5%.\n  expr {$overflow>=$max_pagecache*0.95 && $overflow<=$max_pagecache*1.05}\n} 1\ndo_test memsubsys1-3.1.5 {\n  set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]\n} 0\ndb close\nsqlite3_shutdown\nsqlite3_config_pagecache [expr 2048+$xtra_size] 20\nsqlite3_initialize\nreset_highwater_marks\nbuild_test_db memsubsys1-3.2 {PRAGMA page_size=2048}\n#show_memstats\ndo_test memsubsys1-3.2.3 {\n  db eval {PRAGMA page_size}\n} 2048\ndo_test memsubsys1-3.2.4 {\n  set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]\n} 20\ndo_test memsubsys1-3.2.5 {\n  set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]\n} 0\n\n# Test 4:  Activate PAGECACHE\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_pagecache [expr 1024+$xtra_size] 50\nsqlite3_initialize\nreset_highwater_marks\nbuild_test_db memsubsys1-4 {PRAGMA page_size=1024}\n#show_memstats\ndo_test memsubsys1-4.3 {\n  set pg_used [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 2]\n  expr {$pg_used>=45 && $pg_used<=50}\n} 1\ndo_test memsubsys1-4.4 {\n  set pg_ovfl [lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0] 2]\n} 0\ndo_test memsubsys1-4.5 {\n  set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]\n  expr {$maxreq<7000}\n} 1\n\ndb close\nsqlite3_shutdown\nsqlite3_config_memstatus 1\nsqlite3_config_lookaside 100 500\nsqlite3_config serialized\nsqlite3_initialize\nautoinstall_test_functions\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/memsubsys2.test",
    "content": "# 2008 June 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests of the memory allocation subsystem.\n#\n# $Id: memsubsys2.test,v 1.2 2008/08/12 15:21:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsqlite3_reset_auto_extension\n\n# This procedure constructs a new database in test.db.  It fills\n# this database with many small records (enough to force multiple\n# rebalance operations in the btree-layer and to require a large\n# page cache), verifies correct results, then returns.\n#\nproc build_test_db {testname pragmas} {\n  catch {db close}\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db eval $pragmas\n  db eval {\n    CREATE TABLE t1(x, y);\n    CREATE TABLE t2(a, b);\n    CREATE INDEX i1 ON t1(x,y);\n    INSERT INTO t1 VALUES(1, 100);\n    INSERT INTO t1 VALUES(2, 200);\n  }\n  for {set i 2} {$i<5000} {incr i $i} {\n    db eval {INSERT INTO t2 SELECT * FROM t1}\n    db eval {INSERT INTO t1 SELECT a+$i, a+b*100 FROM t2}\n    db eval {DELETE FROM t2}\n  }\n  do_test $testname.1 {\n    db eval {SELECT count(*) FROM t1}\n  } 8192\n  integrity_check $testname.2\n}\n\n# Reset all of the highwater marks.\n#\nproc reset_highwater_marks {} {\n  sqlite3_status SQLITE_STATUS_MEMORY_USED 1\n  sqlite3_status SQLITE_STATUS_MALLOC_SIZE 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_USED 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_OVERFLOW 1\n  sqlite3_status SQLITE_STATUS_SCRATCH_SIZE 1\n  sqlite3_status SQLITE_STATUS_PARSER_STACK 1\n}\n\n# Test 1:  Verify that calling sqlite3_malloc(0) returns a NULL\n# pointer.\n#\nset highwater [sqlite3_memory_highwater 0]\ndo_test memsubsys2-1.1 {\n  sqlite3_malloc 0\n} {0}\ndo_test memsubsys2-1.2 {\n  sqlite3_memory_highwater 0\n} $highwater\n\n\n# Test 2:  Verify that the highwater mark increases after a large\n# allocation.\n#\nsqlite3_memory_highwater 1\nset highwater [sqlite3_memory_highwater 0]\ndo_test memsubsys2-2.1 {\n  sqlite3_free [set x [sqlite3_malloc 100000]]\n  expr {$x!=\"0\"}\n} {1}\ndo_test memsubsys2-2.2.1 {\n  expr {[sqlite3_memory_highwater 0]>=[sqlite3_memory_used]+100000}\n} {1}\ndo_test memsubsys2-2.2.2 {\n  expr {[sqlite3_memory_highwater 0]>=$highwater+50000}\n} {1}\n\n# Test 3: Verify that turning of memstatus disables the statistics\n# tracking.\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_memstatus 0\nsqlite3_initialize\nreset_highwater_marks\nset highwater [sqlite3_memory_highwater 0]\ndo_test memsubsys2-3.1 {\n  set highwater\n} {0}\ndo_test memsubsys2-3.2 {\n  sqlite3_malloc 0\n} {0}\ndo_test memsubsys2-3.3 {\n  sqlite3_memory_highwater 0\n} {0}\ndo_test memsubsys2-3.4 {\n  sqlite3_memory_used\n} {0}\ndo_test memsubsys2-3.5 {\n  set ::allocation [sqlite3_malloc 100000]\n  expr {$::allocation!=\"0\"}\n} {1}\ndo_test memsubsys2-3.6 {\n  sqlite3_memory_highwater 0\n} {0}\ndo_test memsubsys2-3.7 {\n  sqlite3_memory_used\n} {0}\ndo_test memsubsys2-3.8 {\n  sqlite3_free $::allocation\n} {}\ndo_test memsubsys2-3.9 {\n  sqlite3_free 0\n} {}\n  \n\n# Test 4: Verify that turning on memstatus reenables the statistics\n# tracking.\n#\nsqlite3_shutdown\nsqlite3_config_memstatus 1\nsqlite3_initialize\nreset_highwater_marks\nset highwater [sqlite3_memory_highwater 0]\ndo_test memsubsys2-4.1 {\n  set highwater\n} {0}\ndo_test memsubsys2-4.2 {\n  sqlite3_malloc 0\n} {0}\ndo_test memsubsys2-4.3 {\n  sqlite3_memory_highwater 0\n} {0}\ndo_test memsubsys2-4.4 {\n  sqlite3_memory_used\n} {0}\ndo_test memsubsys2-4.5 {\n  set ::allocation [sqlite3_malloc 100000]\n  expr {$::allocation!=\"0\"}\n} {1}\ndo_test memsubsys2-4.6 {\n  expr {[sqlite3_memory_highwater 0]>=100000}\n} {1}\ndo_test memsubsys2-4.7 {\n  expr {[sqlite3_memory_used]>=100000}\n} {1}\ndo_test memsubsys2-4.8 {\n  sqlite3_free $::allocation\n} {}\ndo_test memsubsys2-4.9 {\n  sqlite3_free 0\n} {}\ndo_test memsubsys2-4.10 {\n  expr {[sqlite3_memory_highwater 0]>=100000}\n} {1}\ndo_test memsubsys2-4.11 {\n  sqlite3_memory_used\n} {0}\n  \n\n\n\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/minmax.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing SELECT statements that contain\n# aggregate min() and max() functions and which are handled as\n# as a special case.\n#\n# $Id: minmax.test,v 1.21 2008/07/08 18:05:26 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix minmax\n\ndo_test minmax-1.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 VALUES(3,2);\n    INSERT INTO t1 VALUES(4,3);\n    INSERT INTO t1 VALUES(5,3);\n    INSERT INTO t1 VALUES(6,3);\n    INSERT INTO t1 VALUES(7,3);\n    INSERT INTO t1 VALUES(8,4);\n    INSERT INTO t1 VALUES(9,4);\n    INSERT INTO t1 VALUES(10,4);\n    INSERT INTO t1 VALUES(11,4);\n    INSERT INTO t1 VALUES(12,4);\n    INSERT INTO t1 VALUES(13,4);\n    INSERT INTO t1 VALUES(14,4);\n    INSERT INTO t1 VALUES(15,4);\n    INSERT INTO t1 VALUES(16,5);\n    INSERT INTO t1 VALUES(17,5);\n    INSERT INTO t1 VALUES(18,5);\n    INSERT INTO t1 VALUES(19,5);\n    INSERT INTO t1 VALUES(20,5);\n    COMMIT;\n    SELECT DISTINCT y FROM t1 ORDER BY y;\n  }\n} {1 2 3 4 5}\n\ndo_test minmax-1.1 {\n  set sqlite_search_count 0\n  execsql {SELECT min(x) FROM t1}\n} {1}\ndo_test minmax-1.2 {\n  set sqlite_search_count\n} {19}\ndo_test minmax-1.3 {\n  set sqlite_search_count 0\n  execsql {SELECT max(x) FROM t1}\n} {20}\ndo_test minmax-1.4 {\n  set sqlite_search_count\n} {19}\ndo_test minmax-1.5 {\n  execsql {CREATE INDEX t1i1 ON t1(x)}\n  set sqlite_search_count 0\n  execsql {SELECT min(x) FROM t1}\n} {1}\ndo_test minmax-1.6 {\n  set sqlite_search_count\n} {1}\ndo_test minmax-1.7 {\n  set sqlite_search_count 0\n  execsql {SELECT max(x) FROM t1}\n} {20}\ndo_test minmax-1.8 {\n  set sqlite_search_count\n} {0}\ndo_test minmax-1.9 {\n  set sqlite_search_count 0\n  execsql {SELECT max(y) FROM t1}\n} {5}\ndo_test minmax-1.10 {\n  set sqlite_search_count\n} {19}\n\ndo_test minmax-1.21 {\n  execsql {SELECT min(x) FROM t1 WHERE x=5}\n} {5}\ndo_test minmax-1.22 {\n  execsql {SELECT min(x) FROM t1 WHERE x>=5}\n} {5}\ndo_test minmax-1.23 {\n  execsql {SELECT min(x) FROM t1 WHERE x>=4.5}\n} {5}\ndo_test minmax-1.24 {\n  execsql {SELECT min(x) FROM t1 WHERE x<4.5}\n} {1}\n\ndo_test minmax-2.0 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n  set sqlite_search_count 0\n  execsql {SELECT min(a) FROM t2}\n} {1}\ndo_test minmax-2.1 {\n  set sqlite_search_count\n} {0}\ndo_test minmax-2.2 {\n  set sqlite_search_count 0\n  execsql {SELECT max(a) FROM t2}\n} {20}\ndo_test minmax-2.3 {\n  set sqlite_search_count\n} {0}\n\ndo_test minmax-3.0 {\n  ifcapable subquery {\n    execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}\n  } else {\n    db function max_a_t2 {execsql {SELECT max(a) FROM t2}}\n    execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}\n  }\n  set sqlite_search_count 0\n  execsql {SELECT max(a) FROM t2}\n} {21}\ndo_test minmax-3.1 {\n  set sqlite_search_count\n} {0}\ndo_test minmax-3.2 {\n  ifcapable subquery {\n    execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}\n  } else {\n    db function max_a_t2 {execsql {SELECT max(a) FROM t2}}\n    execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}\n  }\n  set sqlite_search_count 0\n  ifcapable subquery {\n    execsql { SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) }\n  } else {\n    execsql { SELECT b FROM t2 WHERE a=max_a_t2() }\n  }\n} {999}\ndo_test minmax-3.3 {\n  set sqlite_search_count\n} {0}\n\nifcapable {compound && subquery} {\n  do_test minmax-4.1 {\n    execsql {\n      SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM\n        (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')\n    }\n  } {1 20}\n  do_test minmax-4.2 {\n    execsql {\n      SELECT y, coalesce(sum(x),0) FROM\n        (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)\n      GROUP BY y ORDER BY y;\n    }\n  } {1 1 2 5 3 22 4 92 5 90 6 0}\n  do_test minmax-4.3 {\n    execsql {\n      SELECT y, count(x), count(*) FROM\n        (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)\n      GROUP BY y ORDER BY y;\n    }\n  } {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1}\n} ;# ifcapable compound\n\n# Make sure the min(x) and max(x) optimizations work on empty tables\n# including empty tables with indices. Ticket #296.\n#\ndo_test minmax-5.1 {\n  execsql {\n    CREATE TABLE t3(x INTEGER UNIQUE NOT NULL);\n    SELECT coalesce(min(x),999) FROM t3;\n  }\n} {999}\ndo_test minmax-5.2 {\n  execsql {\n    SELECT coalesce(min(rowid),999) FROM t3;\n  }\n} {999}\ndo_test minmax-5.3 {\n  execsql {\n    SELECT coalesce(max(x),999) FROM t3;\n  }\n} {999}\ndo_test minmax-5.4 {\n  execsql {\n    SELECT coalesce(max(rowid),999) FROM t3;\n  }\n} {999}\ndo_test minmax-5.5 {\n  execsql {\n    SELECT coalesce(max(rowid),999) FROM t3 WHERE rowid<25;\n  }\n} {999}\n\n# Make sure the min(x) and max(x) optimizations work when there\n# is a LIMIT clause.  Ticket #396.\n#\ndo_test minmax-6.1 {\n  execsql {\n    SELECT min(a) FROM t2 LIMIT 1\n  }\n} {1}\ndo_test minmax-6.2 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 3\n  }\n} {22}\ndo_test minmax-6.3 {\n  execsql {\n    SELECT min(a) FROM t2 LIMIT 0,100\n  }\n} {1}\ndo_test minmax-6.4 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 1,100\n  }\n} {}\ndo_test minmax-6.5 {\n  execsql {\n    SELECT min(x) FROM t3 LIMIT 1\n  }\n} {{}}\ndo_test minmax-6.6 {\n  execsql {\n    SELECT max(x) FROM t3 LIMIT 0\n  }\n} {}\ndo_test minmax-6.7 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 0\n  }\n} {}\n\n# Make sure the max(x) and min(x) optimizations work for nested\n# queries.  Ticket #587.\n#\ndo_test minmax-7.1 {\n  execsql {\n    SELECT max(x) FROM t1;\n  }\n} 20\nifcapable subquery {\n  do_test minmax-7.2 {\n    execsql {\n      SELECT * FROM (SELECT max(x) FROM t1);\n    }\n  } 20\n}\ndo_test minmax-7.3 {\n  execsql {\n    SELECT min(x) FROM t1;\n  }\n} 1\nifcapable subquery {\n  do_test minmax-7.4 {\n    execsql {\n      SELECT * FROM (SELECT min(x) FROM t1);\n    }\n  } 1\n}\n\n# Make sure min(x) and max(x) work correctly when the datatype is\n# TEXT instead of NUMERIC.  Ticket #623.\n#\ndo_test minmax-8.1 {\n  execsql {\n    CREATE TABLE t4(a TEXT);\n    INSERT INTO t4 VALUES('1234');\n    INSERT INTO t4 VALUES('234');\n    INSERT INTO t4 VALUES('34');\n    SELECT min(a), max(a) FROM t4;\n  }\n} {1234 34}\ndo_test minmax-8.2 {\n  execsql {\n    CREATE TABLE t5(a INTEGER);\n    INSERT INTO t5 VALUES('1234');\n    INSERT INTO t5 VALUES('234');\n    INSERT INTO t5 VALUES('34');\n    SELECT min(a), max(a) FROM t5;\n  }\n} {34 1234}\n\n# Ticket #658:  Test the min()/max() optimization when the FROM clause\n# is a subquery.\n#\nifcapable {compound && subquery} {\n  do_test minmax-9.1 {\n    execsql {\n      SELECT max(rowid) FROM (\n        SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5\n      )\n    }\n  } {{}}\n  do_test minmax-9.2 {\n    execsql {\n      SELECT max(rowid) FROM (\n        SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5\n      )\n    }\n  } {{}}\n} ;# ifcapable compound&&subquery\n\n# If there is a NULL in an aggregate max() or min(), ignore it.  An\n# aggregate min() or max() will only return NULL if all values are NULL.\n#\ndo_test minmax-10.1 {\n  execsql {\n    CREATE TABLE t6(x);\n    INSERT INTO t6 VALUES(1);\n    INSERT INTO t6 VALUES(2);\n    INSERT INTO t6 VALUES(NULL);\n    SELECT coalesce(min(x),-1) FROM t6;\n  }\n} {1}\ndo_test minmax-10.2 {\n  execsql {\n    SELECT max(x) FROM t6;\n  }\n} {2}\ndo_test minmax-10.3 {\n  execsql {\n    CREATE INDEX i6 ON t6(x);\n    SELECT coalesce(min(x),-1) FROM t6;\n  }\n} {1}\ndo_test minmax-10.4 {\n  execsql {\n    SELECT max(x) FROM t6;\n  }\n} {2}\ndo_test minmax-10.5 {\n  execsql {\n    DELETE FROM t6 WHERE x NOT NULL;\n    SELECT count(*) FROM t6;\n  }\n} 1\ndo_test minmax-10.6 {\n  execsql {\n    SELECT count(x) FROM t6;\n  }\n} 0\nifcapable subquery {\n  do_test minmax-10.7 {\n    execsql {\n      SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);\n    }\n  } {{} {}}\n}\ndo_test minmax-10.8 {\n  execsql {\n    SELECT min(x), max(x) FROM t6;\n  }\n} {{} {}}\ndo_test minmax-10.9 {\n  execsql {\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    SELECT count(*) FROM t6;\n  }\n} 1024\ndo_test minmax-10.10 {\n  execsql {\n    SELECT count(x) FROM t6;\n  }\n} 0\nifcapable subquery {\n  do_test minmax-10.11 {\n    execsql {\n      SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);\n    }\n  } {{} {}}\n}\ndo_test minmax-10.12 {\n  execsql {\n    SELECT min(x), max(x) FROM t6;\n  }\n} {{} {}}\n\n\ndo_test minmax-11.1 {\n  execsql {\n    CREATE INDEX t1i2 ON t1(y,x);\n    SELECT min(x) FROM t1 WHERE y=5;\n  }\n} {16}\ndo_test minmax-11.2 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE y=5;\n  }\n} {20}\ndo_test minmax-11.3 {\n  execsql {\n    SELECT min(x) FROM t1 WHERE y=6;\n  }\n} {{}}\ndo_test minmax-11.4 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE y=6;\n  }\n} {{}}\ndo_test minmax-11.5 {\n  execsql {\n    SELECT min(x) FROM t1 WHERE y=1;\n  }\n} {1}\ndo_test minmax-11.6 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE y=1;\n  }\n} {1}\ndo_test minmax-11.7 {\n  execsql {\n    SELECT min(x) FROM t1 WHERE y=0;\n  }\n} {{}}\ndo_test minmax-11.8 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE y=0;\n  }\n} {{}}\ndo_test minmax-11.9 {\n  execsql {\n    SELECT min(x) FROM t1 WHERE y=5 AND x>=17.5;\n  }\n} {18}\ndo_test minmax-11.10 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE y=5 AND x>=17.5;\n  }\n} {20}\n\ndo_test minmax-12.1 {\n  execsql {\n    CREATE TABLE t7(a,b,c);\n    INSERT INTO t7 SELECT y, x, x*y FROM t1;\n    INSERT INTO t7 SELECT y, x, x*y+1000 FROM t1;\n    CREATE INDEX t7i1 ON t7(a,b,c);\n    SELECT min(a) FROM t7;\n  }\n} {1}\ndo_test minmax-12.2 {\n  execsql {\n    SELECT max(a) FROM t7;\n  }\n} {5}\ndo_test minmax-12.3 {\n  execsql {\n    SELECT max(a) FROM t7 WHERE a=5;\n  }\n} {5}\ndo_test minmax-12.4 {\n  execsql {\n    SELECT min(b) FROM t7 WHERE a=5;\n  }\n} {16}\ndo_test minmax-12.5 {\n  execsql {\n    SELECT max(b) FROM t7 WHERE a=5;\n  }\n} {20}\ndo_test minmax-12.6 {\n  execsql {\n    SELECT min(b) FROM t7 WHERE a=4;\n  }\n} {8}\ndo_test minmax-12.7 {\n  execsql {\n    SELECT max(b) FROM t7 WHERE a=4;\n  }\n} {15}\ndo_test minmax-12.8 {\n  execsql {\n    SELECT min(c) FROM t7 WHERE a=4 AND b=10;\n  }\n} {40}\ndo_test minmax-12.9 {\n  execsql {\n    SELECT max(c) FROM t7 WHERE a=4 AND b=10;\n  }\n} {1040}\ndo_test minmax-12.10 {\n  execsql {\n    SELECT min(rowid) FROM t7;\n  }\n} {1}\ndo_test minmax-12.11 {\n  execsql {\n    SELECT max(rowid) FROM t7;\n  }\n} {40}\ndo_test minmax-12.12 {\n  execsql {\n    SELECT min(rowid) FROM t7 WHERE a=3;\n  }\n} {4}\ndo_test minmax-12.13 {\n  execsql {\n    SELECT max(rowid) FROM t7 WHERE a=3;\n  }\n} {27}\ndo_test minmax-12.14 {\n  execsql {\n    SELECT min(rowid) FROM t7 WHERE a=3 AND b=5;\n  }\n} {5}\ndo_test minmax-12.15 {\n  execsql {\n    SELECT max(rowid) FROM t7 WHERE a=3 AND b=5;\n  }\n} {25}\ndo_test minmax-12.16 {\n  execsql {\n    SELECT min(rowid) FROM t7 WHERE a=3 AND b=5 AND c=1015;\n  }\n} {25}\ndo_test minmax-12.17 {\n  execsql {\n    SELECT max(rowid) FROM t7 WHERE a=3 AND b=5 AND c=15;\n  }\n} {5}\n\n#-------------------------------------------------------------------------\nreset_db\n\nproc do_test_13 {op name sql1 sql2 res} {\n  set ::sqlite_search_count 0\n  uplevel [list do_execsql_test $name.1 $sql1 $res]\n  set a $::sqlite_search_count\n\n  set ::sqlite_search_count 0\n  uplevel [list do_execsql_test $name.2 $sql2 $res]\n  set b $::sqlite_search_count\n\n  uplevel [list do_test $name.3 [list expr \"$a $op $b\"] 1]\n}\n\n# Run a test named $name. Check that SQL statements $sql1 and $sql2 both\n# return the same result, but that $sql2 increments the $sqlite_search_count\n# variable more often (indicating that it is visiting more rows to determine\n# the result).\n#\nproc do_test_13_opt {name sql1 sql2 res} {\n  uplevel [list do_test_13 < $name $sql1 $sql2 $res]\n}\n\n# Like [do_test_13_noopt], except this time check that the $sqlite_search_count\n# variable is incremented the same number of times by both SQL statements.\n#\nproc do_test_13_noopt {name sql1 sql2 res} {\n  uplevel [list do_test_13 == $name $sql1 $sql2 $res]\n}\n\ndo_execsql_test 13.1 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES('a', 1, 1);\n  INSERT INTO t1 VALUES('b', 6, 6);\n  INSERT INTO t1 VALUES('c', 5, 5);\n  INSERT INTO t1 VALUES('a', 4, 4);\n  INSERT INTO t1 VALUES('a', 5, 5);\n  INSERT INTO t1 VALUES('c', 6, 6);\n  INSERT INTO t1 VALUES('b', 4, 4);\n  INSERT INTO t1 VALUES('c', 7, 7);\n  INSERT INTO t1 VALUES('b', 2, 2);\n  INSERT INTO t1 VALUES('b', 3, 3);\n  INSERT INTO t1 VALUES('a', 3, 3);\n  INSERT INTO t1 VALUES('b', 5, 5);\n  INSERT INTO t1 VALUES('c', 4, 4);\n  INSERT INTO t1 VALUES('c', 3, 3);\n  INSERT INTO t1 VALUES('a', 2, 2);\n  SELECT * FROM t1 ORDER BY a, b, c;\n} {a 1 1 a 2 2 a 3 3 a 4 4 a 5 5\n   b 2 2 b 3 3 b 4 4 b 5 5 b 6 6\n   c 3 3 c 4 4 c 5 5 c 6 6 c 7 7\n}\ndo_execsql_test 13.2 { CREATE INDEX i1 ON t1(a, b, c) }\n\ndo_test_13_opt 13.3 {\n  SELECT min(b) FROM t1 WHERE a='b'\n} {\n  SELECT min(c) FROM t1 WHERE a='b'\n} {2}\n\ndo_test_13_opt 13.4 {\n  SELECT a, min(b) FROM t1 WHERE a='b'\n} {\n  SELECT a, min(c) FROM t1 WHERE a='b'\n} {b 2}\n\ndo_test_13_opt 13.4 {\n  SELECT a||c, max(b)+4 FROM t1 WHERE a='c'\n} {\n  SELECT a||c, max(c)+4 FROM t1 WHERE a='c'\n} {c7 11}\n\ndo_test_13_noopt 13.5 {\n  SELECT a||c, max(b+1) FROM t1 WHERE a='c'\n} {\n  SELECT a||c, max(c+1) FROM t1 WHERE a='c'\n} {c7 8}\n\ndo_test_13_noopt 13.6 {\n  SELECT count(b) FROM t1 WHERE a='c'\n} {\n  SELECT count(c) FROM t1 WHERE a='c'\n} {5}\n\ndo_test_13_noopt 13.7 {\n  SELECT min(b), count(b) FROM t1 WHERE a='a';\n} {\n  SELECT min(c), count(c) FROM t1 WHERE a='a';\n} {1 5}\n\n# 2016-07-26.  https://www.sqlite.org/src/info/a0bac8b3c3d1bb75\n# Incorrect result on a min() query after a CREATE INDEX.\n#\ndo_execsql_test 14.1 {\n  CREATE TABLE t14(a INTEGER, b INTEGER);\n  INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2);\n  SELECT min(a) FROM t14 WHERE b='2' AND a>'50';\n} {100}\ndo_execsql_test 14.2 {\n  CREATE INDEX t14ba ON t14(b,a);\n  SELECT min(a) FROM t14 WHERE b='2' AND a>'50';\n} {100}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/minmax2.test",
    "content": "# 2007 July 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing SELECT statements that contain\n# aggregate min() and max() functions and which are handled as\n# as a special case.  This file makes sure that the min/max\n# optimization works right in the presence of descending\n# indices.  Ticket #2514.\n#\n# $Id: minmax2.test,v 1.2 2008/01/05 17:39:30 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test minmax2-1.0 {\n  execsql {\n    PRAGMA legacy_file_format=0;\n    BEGIN;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 VALUES(3,2);\n    INSERT INTO t1 VALUES(4,3);\n    INSERT INTO t1 VALUES(5,3);\n    INSERT INTO t1 VALUES(6,3);\n    INSERT INTO t1 VALUES(7,3);\n    INSERT INTO t1 VALUES(8,4);\n    INSERT INTO t1 VALUES(9,4);\n    INSERT INTO t1 VALUES(10,4);\n    INSERT INTO t1 VALUES(11,4);\n    INSERT INTO t1 VALUES(12,4);\n    INSERT INTO t1 VALUES(13,4);\n    INSERT INTO t1 VALUES(14,4);\n    INSERT INTO t1 VALUES(15,4);\n    INSERT INTO t1 VALUES(16,5);\n    INSERT INTO t1 VALUES(17,5);\n    INSERT INTO t1 VALUES(18,5);\n    INSERT INTO t1 VALUES(19,5);\n    INSERT INTO t1 VALUES(20,5);\n    COMMIT;\n    SELECT DISTINCT y FROM t1 ORDER BY y;\n  }\n} {1 2 3 4 5}\n\ndo_test minmax2-1.1 {\n  set sqlite_search_count 0\n  execsql {SELECT min(x) FROM t1}\n} {1}\ndo_test minmax2-1.2 {\n  set sqlite_search_count\n} {19}\ndo_test minmax2-1.3 {\n  set sqlite_search_count 0\n  execsql {SELECT max(x) FROM t1}\n} {20}\ndo_test minmax2-1.4 {\n  set sqlite_search_count\n} {19}\ndo_test minmax2-1.5 {\n  execsql {CREATE INDEX t1i1 ON t1(x DESC)}\n  set sqlite_search_count 0\n  execsql {SELECT min(x) FROM t1}\n} {1}\ndo_test minmax2-1.6 {\n  set sqlite_search_count\n} {1}\ndo_test minmax2-1.7 {\n  set sqlite_search_count 0\n  execsql {SELECT max(x) FROM t1}\n} {20}\ndo_test minmax2-1.8 {\n  set sqlite_search_count\n} {0}\ndo_test minmax2-1.9 {\n  set sqlite_search_count 0\n  execsql {SELECT max(y) FROM t1}\n} {5}\ndo_test minmax2-1.10 {\n  set sqlite_search_count\n} {19}\n\ndo_test minmax2-2.0 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n  set sqlite_search_count 0\n  execsql {SELECT min(a) FROM t2}\n} {1}\ndo_test minmax2-2.1 {\n  set sqlite_search_count\n} {0}\ndo_test minmax2-2.2 {\n  set sqlite_search_count 0\n  execsql {SELECT max(a) FROM t2}\n} {20}\ndo_test minmax2-2.3 {\n  set sqlite_search_count\n} {0}\n\ndo_test minmax2-3.0 {\n  ifcapable subquery {\n    execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}\n  } else {\n    db function max_a_t2 {execsql {SELECT max(a) FROM t2}}\n    execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}\n  }\n  set sqlite_search_count 0\n  execsql {SELECT max(a) FROM t2}\n} {21}\ndo_test minmax2-3.1 {\n  set sqlite_search_count\n} {0}\ndo_test minmax2-3.2 {\n  ifcapable subquery {\n    execsql {INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)}\n  } else {\n    db function max_a_t2 {execsql {SELECT max(a) FROM t2}}\n    execsql {INSERT INTO t2 VALUES(max_a_t2()+1,999)}\n  }\n  set sqlite_search_count 0\n  ifcapable subquery {\n    execsql { SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) }\n  } else {\n    execsql { SELECT b FROM t2 WHERE a=max_a_t2() }\n  }\n} {999}\ndo_test minmax2-3.3 {\n  set sqlite_search_count\n} {0}\n\nifcapable {compound && subquery} {\n  do_test minmax2-4.1 {\n    execsql {\n      SELECT coalesce(min(x+0),-1), coalesce(max(x+0),-1) FROM\n        (SELECT * FROM t1 UNION SELECT NULL as 'x', NULL as 'y')\n    }\n  } {1 20}\n  do_test minmax2-4.2 {\n    execsql {\n      SELECT y, coalesce(sum(x),0) FROM\n        (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)\n      GROUP BY y ORDER BY y;\n    }\n  } {1 1 2 5 3 22 4 92 5 90 6 0}\n  do_test minmax2-4.3 {\n    execsql {\n      SELECT y, count(x), count(*) FROM\n        (SELECT null AS x, y+1 AS y FROM t1 UNION SELECT * FROM t1)\n      GROUP BY y ORDER BY y;\n    }\n  } {1 1 1 2 2 3 3 4 5 4 8 9 5 5 6 6 0 1}\n} ;# ifcapable compound\n\n# Make sure the min(x) and max(x) optimizations work on empty tables\n# including empty tables with indices. Ticket #296.\n#\ndo_test minmax2-5.1 {\n  execsql {\n    CREATE TABLE t3(x INTEGER UNIQUE NOT NULL);\n    SELECT coalesce(min(x),999) FROM t3;\n  }\n} {999}\ndo_test minmax2-5.2 {\n  execsql {\n    SELECT coalesce(min(rowid),999) FROM t3;\n  }\n} {999}\ndo_test minmax2-5.3 {\n  execsql {\n    SELECT coalesce(max(x),999) FROM t3;\n  }\n} {999}\ndo_test minmax2-5.4 {\n  execsql {\n    SELECT coalesce(max(rowid),999) FROM t3;\n  }\n} {999}\ndo_test minmax2-5.5 {\n  execsql {\n    SELECT coalesce(max(rowid),999) FROM t3 WHERE rowid<25;\n  }\n} {999}\n\n# Make sure the min(x) and max(x) optimizations work when there\n# is a LIMIT clause.  Ticket #396.\n#\ndo_test minmax2-6.1 {\n  execsql {\n    SELECT min(a) FROM t2 LIMIT 1\n  }\n} {1}\ndo_test minmax2-6.2 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 3\n  }\n} {22}\ndo_test minmax2-6.3 {\n  execsql {\n    SELECT min(a) FROM t2 LIMIT 0,100\n  }\n} {1}\ndo_test minmax2-6.4 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 1,100\n  }\n} {}\ndo_test minmax2-6.5 {\n  execsql {\n    SELECT min(x) FROM t3 LIMIT 1\n  }\n} {{}}\ndo_test minmax2-6.6 {\n  execsql {\n    SELECT max(x) FROM t3 LIMIT 0\n  }\n} {}\ndo_test minmax2-6.7 {\n  execsql {\n    SELECT max(a) FROM t2 LIMIT 0\n  }\n} {}\n\n# Make sure the max(x) and min(x) optimizations work for nested\n# queries.  Ticket #587.\n#\ndo_test minmax2-7.1 {\n  execsql {\n    SELECT max(x) FROM t1;\n  }\n} 20\nifcapable subquery {\n  do_test minmax2-7.2 {\n    execsql {\n      SELECT * FROM (SELECT max(x) FROM t1);\n    }\n  } 20\n}\ndo_test minmax2-7.3 {\n  execsql {\n    SELECT min(x) FROM t1;\n  }\n} 1\nifcapable subquery {\n  do_test minmax2-7.4 {\n    execsql {\n      SELECT * FROM (SELECT min(x) FROM t1);\n    }\n  } 1\n}\n\n# Make sure min(x) and max(x) work correctly when the datatype is\n# TEXT instead of NUMERIC.  Ticket #623.\n#\ndo_test minmax2-8.1 {\n  execsql {\n    CREATE TABLE t4(a TEXT);\n    INSERT INTO t4 VALUES('1234');\n    INSERT INTO t4 VALUES('234');\n    INSERT INTO t4 VALUES('34');\n    SELECT min(a), max(a) FROM t4;\n  }\n} {1234 34}\ndo_test minmax2-8.2 {\n  execsql {\n    CREATE TABLE t5(a INTEGER);\n    INSERT INTO t5 VALUES('1234');\n    INSERT INTO t5 VALUES('234');\n    INSERT INTO t5 VALUES('34');\n    SELECT min(a), max(a) FROM t5;\n  }\n} {34 1234}\n\n# Ticket #658:  Test the min()/max() optimization when the FROM clause\n# is a subquery.\n#\nifcapable {compound && subquery} {\n  do_test minmax2-9.1 {\n    execsql {\n      SELECT max(rowid) FROM (\n        SELECT max(rowid) FROM t4 UNION SELECT max(rowid) FROM t5\n      )\n    }\n  } {{}}\n  do_test minmax2-9.2 {\n    execsql {\n      SELECT max(rowid) FROM (\n        SELECT max(rowid) FROM t4 EXCEPT SELECT max(rowid) FROM t5\n      )\n    }\n  } {{}}\n} ;# ifcapable compound&&subquery\n\n# If there is a NULL in an aggregate max() or min(), ignore it.  An\n# aggregate min() or max() will only return NULL if all values are NULL.\n#\ndo_test minmax2-10.1 {\n  execsql {\n    CREATE TABLE t6(x);\n    INSERT INTO t6 VALUES(1);\n    INSERT INTO t6 VALUES(2);\n    INSERT INTO t6 VALUES(NULL);\n    SELECT coalesce(min(x),-1) FROM t6;\n  }\n} {1}\ndo_test minmax2-10.2 {\n  execsql {\n    SELECT max(x) FROM t6;\n  }\n} {2}\ndo_test minmax2-10.3 {\n  execsql {\n    CREATE INDEX i6 ON t6(x DESC);\n    SELECT coalesce(min(x),-1) FROM t6;\n  }\n} {1}\ndo_test minmax2-10.4 {\n  execsql {\n    SELECT max(x) FROM t6;\n  }\n} {2}\ndo_test minmax2-10.5 {\n  execsql {\n    DELETE FROM t6 WHERE x NOT NULL;\n    SELECT count(*) FROM t6;\n  }\n} 1\ndo_test minmax2-10.6 {\n  execsql {\n    SELECT count(x) FROM t6;\n  }\n} 0\nifcapable subquery {\n  do_test minmax2-10.7 {\n    execsql {\n      SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);\n    }\n  } {{} {}}\n}\ndo_test minmax2-10.8 {\n  execsql {\n    SELECT min(x), max(x) FROM t6;\n  }\n} {{} {}}\ndo_test minmax2-10.9 {\n  execsql {\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    SELECT count(*) FROM t6;\n  }\n} 1024\ndo_test minmax2-10.10 {\n  execsql {\n    SELECT count(x) FROM t6;\n  }\n} 0\nifcapable subquery {\n  do_test minmax2-10.11 {\n    execsql {\n      SELECT (SELECT min(x) FROM t6), (SELECT max(x) FROM t6);\n    }\n  } {{} {}}\n}\ndo_test minmax2-10.12 {\n  execsql {\n    SELECT min(x), max(x) FROM t6;\n  }\n} {{} {}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/minmax3.test",
    "content": "# 2008 January 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# $Id: minmax3.test,v 1.5 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# This procedure sets the value of the file-format in file 'test.db'\n# to $newval. Also, the schema cookie is incremented.\n# \nproc set_file_format {newval} {\n  hexio_write test.db 44 [hexio_render_int32 $newval]\n  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]\n  incr schemacookie\n  hexio_write test.db 40 [hexio_render_int32 $schemacookie]\n  return {}\n}\n\ndo_test minmax3-1.0 {\n  execsql {\n    CREATE TABLE t1(x, y, z);\n  }\n  db close\n  set_file_format 4\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES('1', 'I',   'one');\n    INSERT INTO t1 VALUES('2', 'IV',  'four');\n    INSERT INTO t1 VALUES('2', NULL,  'three');\n    INSERT INTO t1 VALUES('2', 'II',  'two');\n    INSERT INTO t1 VALUES('2', 'V',   'five');\n    INSERT INTO t1 VALUES('3', 'VI',  'six');\n    COMMIT;\n    PRAGMA automatic_index=OFF;\n  }\n} {}\ndo_test minmax3-1.1.1 {\n  # Linear scan.\n  count { SELECT max(y) FROM t1 WHERE x = '2'; }\n} {V 5}\ndo_test minmax3-1.1.2 {\n  # Index optimizes the WHERE x='2' constraint.\n  execsql { CREATE INDEX i1 ON t1(x) }\n  count   { SELECT max(y) FROM t1 WHERE x = '2'; }\n} {V 9}\ndo_test minmax3-1.1.3 {\n  # Index optimizes the WHERE x='2' constraint and the MAX(y).\n  execsql { CREATE INDEX i2 ON t1(x,y) }\n  count   { SELECT max(y) FROM t1 WHERE x = '2'; }\n} {V 1}\ndo_test minmax3-1.1.4 {\n  # Index optimizes the WHERE x='2' constraint and the MAX(y).\n  execsql { DROP INDEX i2 ; CREATE INDEX i2 ON t1(x, y DESC) }\n  count   { SELECT max(y) FROM t1 WHERE x = '2'; }\n} {V 1}\ndo_test minmax3-1.1.5 {\n  count   { SELECT max(y) FROM t1 WHERE x = '2' AND y != 'V'; }\n} {IV 2}\ndo_test minmax3-1.1.6 {\n  count   { SELECT max(y) FROM t1 WHERE x = '2' AND y < 'V'; }\n} {IV 1}\ndo_test minmax3-1.1.6 {\n  count   { SELECT max(y) FROM t1 WHERE x = '2' AND z != 'five'; }\n} {IV 4}\n\ndo_test minmax3-1.2.1 {\n  # Linear scan of t1.\n  execsql { DROP INDEX i1 ; DROP INDEX i2 }\n  count { SELECT min(y) FROM t1 WHERE x = '2'; }\n} {II 5}\ndo_test minmax3-1.2.2 {\n  # Index i1 optimizes the WHERE x='2' constraint.\n  execsql { CREATE INDEX i1 ON t1(x) }\n  count   { SELECT min(y) FROM t1 WHERE x = '2'; }\n} {II 9}\ndo_test minmax3-1.2.3 {\n  # Index i2 optimizes the WHERE x='2' constraint and the min(y).\n  execsql { CREATE INDEX i2 ON t1(x,y) }\n  count   { SELECT min(y) FROM t1 WHERE x = '2'; }\n} {II 1}\ndo_test minmax3-1.2.4 {\n  # Index optimizes the WHERE x='2' constraint and the MAX(y).\n  execsql { DROP INDEX i2 ; CREATE INDEX i2 ON t1(x, y DESC) }\n  count   { SELECT min(y) FROM t1 WHERE x = '2'; }\n} {II 1}\n\ndo_test minmax3-1.3.1 {\n  # Linear scan\n  execsql { DROP INDEX i1 ; DROP INDEX i2 }\n  count   { SELECT min(y) FROM t1; }\n} {I 5}\ndo_test minmax3-1.3.2 {\n  # Index i1 optimizes the min(y)\n  execsql { CREATE INDEX i1 ON t1(y) }\n  count   { SELECT min(y) FROM t1; }\n} {I 1}\ndo_test minmax3-1.3.3 {\n  # Index i1 optimizes the min(y)\n  execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(y DESC) }\n  count   { SELECT min(y) FROM t1; }\n} {I 1}\n\ndo_test minmax3-1.4.1 {\n  # Linear scan\n  execsql { DROP INDEX i1 }\n  count   { SELECT max(y) FROM t1; }\n} {VI 5}\ndo_test minmax3-1.4.2 {\n  # Index i1 optimizes the max(y)\n  execsql { CREATE INDEX i1 ON t1(y) }\n  count   { SELECT max(y) FROM t1; }\n} {VI 0}\ndo_test minmax3-1.4.3 {\n  # Index i1 optimizes the max(y)\n  execsql { DROP INDEX i1 ; CREATE INDEX i1 ON t1(y DESC) }\n  execsql   { SELECT y from t1}\n  count   { SELECT max(y) FROM t1; }\n} {VI 0}\ndo_test minmax3-1.4.4 {\n  execsql { DROP INDEX i1 }\n} {}\n\ndo_test minmax3-2.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    CREATE INDEX i3 ON t2(a, b);\n    INSERT INTO t2 VALUES(1, NULL);\n    INSERT INTO t2 VALUES(1, 1);\n    INSERT INTO t2 VALUES(1, 2);\n    INSERT INTO t2 VALUES(1, 3);\n    INSERT INTO t2 VALUES(2, NULL);\n    INSERT INTO t2 VALUES(2, 1);\n    INSERT INTO t2 VALUES(2, 2);\n    INSERT INTO t2 VALUES(2, 3);\n    INSERT INTO t2 VALUES(3, 1);\n    INSERT INTO t2 VALUES(3, 2);\n    INSERT INTO t2 VALUES(3, 3);\n  }\n} {}\ndo_test minmax3-2.2 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1; }\n} {1}\ndo_test minmax3-2.3 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>1; }\n} {2}\ndo_test minmax3-2.4 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>-1; }\n} {1}\ndo_test minmax3-2.5 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1; }\n} {1}\ndo_test minmax3-2.6 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<2; }\n} {1}\ndo_test minmax3-2.7 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<1; }\n} {{}}\ndo_test minmax3-2.8 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }\n} {{}}\n\ndo_test minmax3-3.1 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(a, b);\n    CREATE INDEX i3 ON t2(a, b DESC);\n    INSERT INTO t2 VALUES(1, NULL);\n    INSERT INTO t2 VALUES(1, 1);\n    INSERT INTO t2 VALUES(1, 2);\n    INSERT INTO t2 VALUES(1, 3);\n    INSERT INTO t2 VALUES(2, NULL);\n    INSERT INTO t2 VALUES(2, 1);\n    INSERT INTO t2 VALUES(2, 2);\n    INSERT INTO t2 VALUES(2, 3);\n    INSERT INTO t2 VALUES(3, 1);\n    INSERT INTO t2 VALUES(3, 2);\n    INSERT INTO t2 VALUES(3, 3);\n  }\n} {}\ndo_test minmax3-3.2 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1; }\n} {1}\ndo_test minmax3-3.3 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>1; }\n} {2}\ndo_test minmax3-3.4 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b>-1; }\n} {1}\ndo_test minmax3-3.5 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1; }\n} {1}\ndo_test minmax3-3.6 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<2; }\n} {1}\ndo_test minmax3-3.7 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 1 AND b<1; }\n} {{}}\ndo_test minmax3-3.8 {\n  execsql { SELECT min(b) FROM t2 WHERE a = 3 AND b<1; }\n} {{}}\n\ndo_test minmax3-4.1 {\n  execsql {\n    CREATE TABLE t4(x);\n    INSERT INTO t4 VALUES('abc');\n    INSERT INTO t4 VALUES('BCD');\n    SELECT max(x) FROM t4;\n  }\n} {abc}\ndo_test minmax3-4.2 {\n  execsql {\n    SELECT max(x COLLATE nocase) FROM t4;\n  }\n} {BCD}\ndo_test minmax3-4.3 {\n  execsql {\n    SELECT max(x), max(x COLLATE nocase) FROM t4;\n  }\n} {abc BCD}\ndo_test minmax3-4.4 {\n  execsql {\n    SELECT max(x COLLATE binary), max(x COLLATE nocase) FROM t4;\n  }\n} {abc BCD}\ndo_test minmax3-4.5 {\n  execsql {\n    SELECT max(x COLLATE nocase), max(x COLLATE rtrim) FROM t4;\n  }\n} {BCD abc}\ndo_test minmax3-4.6 {\n  execsql {\n    SELECT max(x COLLATE nocase), max(x) FROM t4;\n  }\n} {BCD abc}\ndo_test minmax3-4.10 {\n  execsql {\n    SELECT min(x) FROM t4;\n  }\n} {BCD}\ndo_test minmax3-4.11 {\n  execsql {\n    SELECT min(x COLLATE nocase) FROM t4;\n  }\n} {abc}\ndo_test minmax3-4.12 {\n  execsql {\n    SELECT min(x), min(x COLLATE nocase) FROM t4;\n  }\n} {BCD abc}\ndo_test minmax3-4.13 {\n  execsql {\n    SELECT min(x COLLATE binary), min(x COLLATE nocase) FROM t4;\n  }\n} {BCD abc}\ndo_test minmax3-4.14 {\n  execsql {\n    SELECT min(x COLLATE nocase), min(x COLLATE rtrim) FROM t4;\n  }\n} {abc BCD}\ndo_test minmax3-4.15 {\n  execsql {\n    SELECT min(x COLLATE nocase), min(x) FROM t4;\n  }\n} {abc BCD}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/minmax4.test",
    "content": "# 2012 February 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test for queries of the form:  \n#\n#    SELECT p, max(q) FROM t1;\n#\n# Demonstration that the value returned for p is on the same row as \n# the maximum q.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test minmax4-1.1 {\n  db eval {\n    CREATE TABLE t1(p,q);\n    SELECT p, max(q) FROM t1;\n  }\n} {{} {}}\ndo_test minmax4-1.2 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {{} {}}\ndo_test minmax4-1.3 {\n  db eval {\n    INSERT INTO t1 VALUES(1,2);\n    SELECT p, max(q) FROM t1;\n  }\n} {1 2}\ndo_test minmax4-1.4 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {1 2}\ndo_test minmax4-1.5 {\n  db eval {\n    INSERT INTO t1 VALUES(3,4);\n    SELECT p, max(q) FROM t1;\n  }\n} {3 4}\ndo_test minmax4-1.6 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n    SELECT p FROM (SELECT p, min(q) FROM t1);\n  }\n} {1 2 1}\ndo_test minmax4-1.7 {\n  db eval {\n    INSERT INTO t1 VALUES(5,0);\n    SELECT p, max(q) FROM t1;\n    SELECT p FROM (SELECT max(q), p FROM t1);\n  }\n} {3 4 3}\ndo_test minmax4-1.8 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {5 0}\ndo_test minmax4-1.9 {\n  db eval {\n    INSERT INTO t1 VALUES(6,1);\n    SELECT p, max(q) FROM t1;\n    SELECT p FROM (SELECT max(q), p FROM t1);\n  }\n} {3 4 3}\ndo_test minmax4-1.10 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {5 0}\ndo_test minmax4-1.11 {\n  db eval {\n    INSERT INTO t1 VALUES(7,NULL);\n    SELECT p, max(q) FROM t1;\n  }\n} {3 4}\ndo_test minmax4-1.12 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {5 0}\ndo_test minmax4-1.13 {\n  db eval {\n    DELETE FROM t1 WHERE q IS NOT NULL;\n    SELECT p, max(q) FROM t1;\n  }\n} {7 {}}\ndo_test minmax4-1.14 {\n  db eval {\n    SELECT p, min(q) FROM t1;\n  }\n} {7 {}}\n\ndo_test minmax4-2.1 {\n  db eval {\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES\n         (1,null,2),\n         (1,2,3),\n         (1,1,4),\n         (2,3,5);\n    SELECT a, max(b), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 2 3 2 3 5}\ndo_test minmax4-2.2 {\n  db eval {\n    SELECT a, min(b), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 1 4 2 3 5}\ndo_test minmax4-2.3 {\n  db eval {\n    SELECT a, min(b), avg(b), count(b), c FROM t2 GROUP BY a ORDER BY a DESC;\n  }\n} {2 3 3.0 1 5 1 1 1.5 2 4}\ndo_test minmax4-2.4 {\n  db eval {\n    SELECT a, min(b), max(b), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 1 2 3 2 3 3 5}\ndo_test minmax4-2.5 {\n  db eval {\n    SELECT a, max(b), min(b), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 2 1 4 2 3 3 5}\ndo_test minmax4-2.6 {\n  db eval {\n    SELECT a, max(b), b, max(c), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 2 1 4 4 2 3 3 5 5}\ndo_test minmax4-2.7 {\n  db eval {\n    SELECT a, min(b), b, min(c), c FROM t2 GROUP BY a ORDER BY a;\n  }\n} {1 1 {} 2 2 2 3 3 5 5}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc1.test",
    "content": "# 2001 September 15.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for miscellanous features that were\n# left out of other test files.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Mimic the SQLite 2 collation type NUMERIC.\ndb collate numeric numeric_collate\nproc numeric_collate {lhs rhs} {\n  if {$lhs == $rhs} {return 0} \n  return [expr ($lhs>$rhs)?1:-1]\n}\n\n# Mimic the SQLite 2 collation type TEXT.\ndb collate text text_collate\nproc numeric_collate {lhs rhs} {\n  return [string compare $lhs $rhs]\n}\n\n# Test the creation and use of tables that have a large number\n# of columns.\n#\ndo_test misc1-1.1 {\n  set cmd \"CREATE TABLE manycol(x0 text\"\n  for {set i 1} {$i<=99} {incr i} {\n    append cmd \",x$i text\"\n  }\n  append cmd \")\";\n  execsql $cmd\n  set cmd \"INSERT INTO manycol VALUES(0\"\n  for {set i 1} {$i<=99} {incr i} {\n    append cmd \",$i\"\n  }\n  append cmd \")\";\n  execsql $cmd\n  execsql \"SELECT x99 FROM manycol\"\n} 99\ndo_test misc1-1.2 {\n  execsql {SELECT x0, x10, x25, x50, x75 FROM manycol}\n} {0 10 25 50 75}\ndo_test misc1-1.3.1 {\n  for {set j 100} {$j<=1000} {incr j 100} {\n    set cmd \"INSERT INTO manycol VALUES($j\"\n    for {set i 1} {$i<=99} {incr i} {\n      append cmd \",[expr {$i+$j}]\"\n    }\n    append cmd \")\"\n    execsql $cmd\n  }\n  execsql {SELECT x50 FROM manycol ORDER BY x80+0}\n} {50 150 250 350 450 550 650 750 850 950 1050}\ndo_test misc1-1.3.2 {\n  execsql {SELECT x50 FROM manycol ORDER BY x80}\n} {1050 150 250 350 450 550 650 750 50 850 950}\ndo_test misc1-1.4 {\n  execsql {SELECT x75 FROM manycol WHERE x50=350}\n} 375\ndo_test misc1-1.5 {\n  execsql {SELECT x50 FROM manycol WHERE x99=599}\n} 550\ndo_test misc1-1.6 {\n  execsql {CREATE INDEX manycol_idx1 ON manycol(x99)}\n  execsql {SELECT x50 FROM manycol WHERE x99=899}\n} 850\ndo_test misc1-1.7 {\n  execsql {SELECT count(*) FROM manycol}\n} 11\ndo_test misc1-1.8 {\n  execsql {DELETE FROM manycol WHERE x98=1234}\n  execsql {SELECT count(*) FROM manycol}\n} 11\ndo_test misc1-1.9 {\n  execsql {DELETE FROM manycol WHERE x98=998}\n  execsql {SELECT count(*) FROM manycol}\n} 10\ndo_test misc1-1.10 {\n  execsql {DELETE FROM manycol WHERE x99=500}\n  execsql {SELECT count(*) FROM manycol}\n} 10\ndo_test misc1-1.11 {\n  execsql {DELETE FROM manycol WHERE x99=599}\n  execsql {SELECT count(*) FROM manycol}\n} 9\n\n# Check GROUP BY expressions that name two or more columns.\n#\ndo_test misc1-2.1 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE agger(one text, two text, three text, four text);\n    INSERT INTO agger VALUES(1, 'one', 'hello', 'yes');\n    INSERT INTO agger VALUES(2, 'two', 'howdy', 'no');\n    INSERT INTO agger VALUES(3, 'thr', 'howareya', 'yes');\n    INSERT INTO agger VALUES(4, 'two', 'lothere', 'yes');\n    INSERT INTO agger VALUES(5, 'one', 'atcha', 'yes');\n    INSERT INTO agger VALUES(6, 'two', 'hello', 'no');\n    COMMIT\n  }\n  execsql {SELECT count(*) FROM agger}\n} 6\ndo_test misc1-2.2 {\n  execsql {SELECT sum(one), two, four FROM agger\n           GROUP BY two, four ORDER BY sum(one) desc}\n} {8 two no 6 one yes 4 two yes 3 thr yes}\ndo_test misc1-2.3 {\n  execsql {SELECT sum((one)), (two), (four) FROM agger\n           GROUP BY (two), (four) ORDER BY sum(one) desc}\n} {8 two no 6 one yes 4 two yes 3 thr yes}\n\n# Here's a test for a bug found by Joel Lucsy.  The code below\n# was causing an assertion failure.\n#\ndo_test misc1-3.1 {\n  set r [execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES('hi');\n    PRAGMA full_column_names=on;\n    SELECT rowid, * FROM t1;\n  }]\n  lindex $r 1\n} {hi}\n\n# Here's a test for yet another bug found by Joel Lucsy.  The code\n# below was causing an assertion failure.\n#\ndo_test misc1-4.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES('This is a long string to use up a lot of disk -');\n    UPDATE t2 SET a=a||a||a||a;\n    INSERT INTO t2 SELECT '1 - ' || a FROM t2;\n    INSERT INTO t2 SELECT '2 - ' || a FROM t2;\n    INSERT INTO t2 SELECT '3 - ' || a FROM t2;\n    INSERT INTO t2 SELECT '4 - ' || a FROM t2;\n    INSERT INTO t2 SELECT '5 - ' || a FROM t2;\n    INSERT INTO t2 SELECT '6 - ' || a FROM t2;\n    COMMIT;\n    SELECT count(*) FROM t2;\n  }\n} {64}\n\n# Make sure we actually see a semicolon or end-of-file in the SQL input\n# before executing a command.  Thus if \"WHERE\" is misspelled on an UPDATE,\n# the user won't accidently update every record.\n#\ndo_test misc1-5.1 {\n  catchsql {\n    CREATE TABLE t3(a,b);\n    INSERT INTO t3 VALUES(1,2);\n    INSERT INTO t3 VALUES(3,4);\n    UPDATE t3 SET a=0 WHEREwww b=2;\n  }\n} {1 {near \"WHEREwww\": syntax error}}\ndo_test misc1-5.2 {\n  execsql {\n    SELECT * FROM t3 ORDER BY a;\n  }\n} {1 2 3 4}\n\n# Certain keywords (especially non-standard keywords like \"REPLACE\") can\n# also be used as identifiers.  The way this works in the parser is that\n# the parser first detects a syntax error, the error handling routine\n# sees that the special keyword caused the error, then replaces the keyword\n# with \"ID\" and tries again.\n#\n# Check the operation of this logic.\n#\ndo_test misc1-6.1 {\n  catchsql {\n    CREATE TABLE t4(\n      abort, asc, begin, cluster, conflict, copy, delimiters, desc, end,\n      explain, fail, ignore, key, offset, pragma, replace, temp,\n      vacuum, view\n    );\n  }\n} {0 {}}\ndo_test misc1-6.2 {\n  catchsql {\n    INSERT INTO t4\n       VALUES(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);\n  }\n} {0 {}}\ndo_test misc1-6.3 {\n  execsql {\n    SELECT * FROM t4\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19}\ndo_test misc1-6.4 {\n  execsql {\n    SELECT abort+asc,max(key,pragma,temp) FROM t4\n  }\n} {3 17}\n\n# Test for multi-column primary keys, and for multiple primary keys.\n#\ndo_test misc1-7.1 {\n  catchsql {\n    CREATE TABLE error1(\n      a TYPE PRIMARY KEY,\n      b TYPE PRIMARY KEY\n    );\n  }\n} {1 {table \"error1\" has more than one primary key}}\ndo_test misc1-7.2 {\n  catchsql {\n    CREATE TABLE error1(\n      a INTEGER PRIMARY KEY,\n      b TYPE PRIMARY KEY\n    );\n  }\n} {1 {table \"error1\" has more than one primary key}}\ndo_test misc1-7.3 {\n  execsql {\n    CREATE TABLE t5(a,b,c,PRIMARY KEY(a,b));\n    INSERT INTO t5 VALUES(1,2,3);\n    SELECT * FROM t5 ORDER BY a;\n  }\n} {1 2 3}\ndo_test misc1-7.4 {\n  catchsql {\n    INSERT INTO t5 VALUES(1,2,4);\n  }\n} {1 {UNIQUE constraint failed: t5.a, t5.b}}\ndo_test misc1-7.5 {\n  catchsql {\n    INSERT INTO t5 VALUES(0,2,4);\n  }\n} {0 {}}\ndo_test misc1-7.6 {\n  execsql {\n    SELECT * FROM t5 ORDER BY a;\n  }\n} {0 2 4 1 2 3}\n\ndo_test misc1-8.1 {\n  catchsql {\n    SELECT *;\n  }\n} {1 {no tables specified}}\ndo_test misc1-8.2 {\n  catchsql {\n    SELECT t1.*;\n  }\n} {1 {no such table: t1}}\n\nexecsql {\n  DROP TABLE t1;\n  DROP TABLE t2;\n  DROP TABLE t3;\n  DROP TABLE t4;\n}\n\n# 64-bit integers are represented exactly.\n#\ndo_test misc1-9.1 {\n  catchsql {\n    CREATE TABLE t1(a unique not null, b unique not null);\n    INSERT INTO t1 VALUES('a',1234567890123456789);\n    INSERT INTO t1 VALUES('b',1234567891123456789);\n    INSERT INTO t1 VALUES('c',1234567892123456789);\n    SELECT * FROM t1;\n  }\n} {0 {a 1234567890123456789 b 1234567891123456789 c 1234567892123456789}}\n\n# A WHERE clause is not allowed to contain more than 99 terms.  Check to\n# make sure this limit is enforced.\n#\n# 2005-07-16: There is no longer a limit on the number of terms in a\n# WHERE clause.  But keep these tests just so that we have some tests\n# that use a large number of terms in the WHERE clause.\n#\ndo_test misc1-10.0 {\n  execsql {SELECT count(*) FROM manycol}\n} {9}\ndo_test misc1-10.1 {\n  set ::where {WHERE x0>=0}\n  for {set i 1} {$i<=99} {incr i} {\n    append ::where \" AND x$i<>0\"\n  }\n  catchsql \"SELECT count(*) FROM manycol $::where\"\n} {0 9}\ndo_test misc1-10.2 {\n  catchsql \"SELECT count(*) FROM manycol $::where AND rowid>0\"\n} {0 9}\ndo_test misc1-10.3 {\n  regsub \"x0>=0\" $::where \"x0=0\" ::where\n  catchsql \"DELETE FROM manycol $::where\"\n} {0 {}}\ndo_test misc1-10.4 {\n  execsql {SELECT count(*) FROM manycol}\n} {8}\ndo_test misc1-10.5 {\n  catchsql \"DELETE FROM manycol $::where AND rowid>0\"\n} {0 {}}\ndo_test misc1-10.6 {\n  execsql {SELECT x1 FROM manycol WHERE x0=100}\n} {101}\ndo_test misc1-10.7 {\n  regsub \"x0=0\" $::where \"x0=100\" ::where\n  catchsql \"UPDATE manycol SET x1=x1+1 $::where\"\n} {0 {}}\ndo_test misc1-10.8 {\n  execsql {SELECT x1 FROM manycol WHERE x0=100}\n} {102}\ndo_test misc1-10.9 {\n  catchsql \"UPDATE manycol SET x1=x1+1 $::where AND rowid>0\"\n} {0 {}}\ndo_test misc1-10.10 {\n  execsql {SELECT x1 FROM manycol WHERE x0=100}\n} {103}\n\n# Make sure the initialization works even if a database is opened while\n# another process has the database locked.\n#\n# Update for v3: The BEGIN doesn't lock the database so the schema is read\n# and the SELECT returns successfully.\ndo_test misc1-11.1 {\n  execsql {BEGIN}\n  execsql {UPDATE t1 SET a=0 WHERE 0}\n  sqlite3 db2 test.db\n  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]\n  lappend rc $msg\n# v2 result: {1 {database is locked}}\n} {0 3}\ndo_test misc1-11.2 {\n  execsql {COMMIT}\n  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]\n  db2 close\n  lappend rc $msg\n} {0 3}\n\n# Make sure string comparisons really do compare strings in format4+.\n# Similar tests in the format3.test file show that for format3 and earlier\n# all comparisions where numeric if either operand looked like a number.\n#\ndo_test misc1-12.1 {\n  execsql {SELECT '0'=='0.0'}\n} {0}\ndo_test misc1-12.2 {\n  execsql {SELECT '0'==0.0}\n} {0}\ndo_test misc1-12.3 {\n  execsql {SELECT '12345678901234567890'=='12345678901234567891'}\n} {0}\ndo_test misc1-12.4 {\n  execsql {\n    CREATE TABLE t6(a INT UNIQUE, b TEXT UNIQUE);\n    INSERT INTO t6 VALUES('0','0.0');\n    SELECT * FROM t6;\n  }\n} {0 0.0}\nifcapable conflict {\n  do_test misc1-12.5 {\n    execsql {\n      INSERT OR IGNORE INTO t6 VALUES(0.0,'x');\n      SELECT * FROM t6;\n    }\n  } {0 0.0}\n  do_test misc1-12.6 {\n    execsql {\n      INSERT OR IGNORE INTO t6 VALUES('y',0);\n      SELECT * FROM t6;\n    }\n  } {0 0.0 y 0}\n}\ndo_test misc1-12.7 {\n  execsql {\n    CREATE TABLE t7(x INTEGER, y TEXT, z);\n    INSERT INTO t7 VALUES(0,0,1);\n    INSERT INTO t7 VALUES(0.0,0,2);\n    INSERT INTO t7 VALUES(0,0.0,3);\n    INSERT INTO t7 VALUES(0.0,0.0,4);\n    SELECT DISTINCT x, y FROM t7 ORDER BY z;\n  }\n} {0 0 0 0.0}\ndo_test misc1-12.8 {\n  execsql {\n    SELECT min(z), max(z), count(z) FROM t7 GROUP BY x ORDER BY 1;\n  }\n} {1 4 4}\ndo_test misc1-12.9 {\n  execsql {\n    SELECT min(z), max(z), count(z) FROM t7 GROUP BY y ORDER BY 1;\n  }\n} {1 2 2 3 4 2}\n\n# This used to be an error.  But we changed the code so that arbitrary\n# identifiers can be used as a collating sequence.  Collation is by text\n# if the identifier contains \"text\", \"blob\", or \"clob\" and is numeric\n# otherwise.\n#\n# Update: In v3, it is an error again.\n#\n#do_test misc1-12.10 {\n#  catchsql {\n#    SELECT * FROM t6 ORDER BY a COLLATE unknown;\n#  }\n#} {0 {0 0 y 0}}\ndo_test misc1-12.11 {\n  execsql {\n    CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);\n    INSERT INTO t8 VALUES(0,0,1);\n    INSERT INTO t8 VALUES(0.0,0,2);\n    INSERT INTO t8 VALUES(0,0.0,3);\n    INSERT INTO t8 VALUES(0.0,0.0,4);\n    SELECT DISTINCT x, y FROM t8 ORDER BY z;\n  }\n} {0 0 0.0 0}\ndo_test misc1-12.12 {\n  execsql {\n    SELECT min(z), max(z), count(z) FROM t8 GROUP BY x ORDER BY 1;\n  }\n} {1 3 2 2 4 2}\ndo_test misc1-12.13 {\n  execsql {\n    SELECT min(z), max(z), count(z) FROM t8 GROUP BY y ORDER BY 1;\n  }\n} {1 4 4}\n\n# There was a problem with realloc() in the OP_MemStore operation of\n# the VDBE.  A buffer was being reallocated but some pointers into \n# the old copy of the buffer were not being moved over to the new copy.\n# The following code tests for the problem.\n#\nifcapable subquery {\n  do_test misc1-13.1 {\n     execsql {\n       CREATE TABLE t9(x,y);\n       INSERT INTO t9 VALUES('one',1);\n       INSERT INTO t9 VALUES('two',2);\n       INSERT INTO t9 VALUES('three',3);\n       INSERT INTO t9 VALUES('four',4);\n       INSERT INTO t9 VALUES('five',5);\n       INSERT INTO t9 VALUES('six',6);\n       INSERT INTO t9 VALUES('seven',7);\n       INSERT INTO t9 VALUES('eight',8);\n       INSERT INTO t9 VALUES('nine',9);\n       INSERT INTO t9 VALUES('ten',10);\n       INSERT INTO t9 VALUES('eleven',11);\n       SELECT y FROM t9\n       WHERE x=(SELECT x FROM t9 WHERE y=1)\n          OR x=(SELECT x FROM t9 WHERE y=2)\n          OR x=(SELECT x FROM t9 WHERE y=3)\n          OR x=(SELECT x FROM t9 WHERE y=4)\n          OR x=(SELECT x FROM t9 WHERE y=5)\n          OR x=(SELECT x FROM t9 WHERE y=6)\n          OR x=(SELECT x FROM t9 WHERE y=7)\n          OR x=(SELECT x FROM t9 WHERE y=8)\n          OR x=(SELECT x FROM t9 WHERE y=9)\n          OR x=(SELECT x FROM t9 WHERE y=10)\n          OR x=(SELECT x FROM t9 WHERE y=11)\n          OR x=(SELECT x FROM t9 WHERE y=12)\n          OR x=(SELECT x FROM t9 WHERE y=13)\n          OR x=(SELECT x FROM t9 WHERE y=14)\n       ;\n     }\n  } {1 2 3 4 5 6 7 8 9 10 11}\n}\n\n#\n# The following tests can only work if the current SQLite VFS has the concept\n# of a current directory.\n#\nifcapable curdir {\n# Make sure a database connection still works after changing the\n# working directory.\n#\nif {[atomic_batch_write test.db]==0} {\n  do_test misc1-14.1 {\n    file mkdir tempdir\n    cd tempdir\n    execsql {BEGIN}\n    file exists ./test.db-journal\n  } {0}\n  do_test misc1-14.2a {\n    execsql {UPDATE t1 SET a=a||'x' WHERE 0}\n    file exists ../test.db-journal\n  } {0}\n  do_test misc1-14.2b {\n    execsql {UPDATE t1 SET a=a||'y' WHERE 1}\n    file exists ../test.db-journal\n  } {1}\n  do_test misc1-14.3 {\n    cd ..\n    forcedelete tempdir\n    execsql {COMMIT}\n    file exists ./test.db-journal\n  } {0}\n}\n}\n\n# A failed create table should not leave the table in the internal\n# data structures.  Ticket #238.\n#\ndo_test misc1-15.1.1 {\n  catchsql {\n    CREATE TABLE t10 AS SELECT c1;\n  }\n} {1 {no such column: c1}}\ndo_test misc1-15.1.2 {\n  catchsql {\n    CREATE TABLE t10 AS SELECT t9.c1;\n  }\n} {1 {no such column: t9.c1}}\ndo_test misc1-15.1.3 {\n  catchsql {\n    CREATE TABLE t10 AS SELECT main.t9.c1;\n  }\n} {1 {no such column: main.t9.c1}}\ndo_test misc1-15.2 {\n  catchsql {\n    CREATE TABLE t10 AS SELECT 1;\n  }\n  # The bug in ticket #238 causes the statement above to fail with\n  # the error \"table t10 alread exists\"\n} {0 {}}\n\n# Test for memory leaks when a CREATE TABLE containing a primary key\n# fails.  Ticket #249.\n#\ndo_test misc1-16.1 {\n  catchsql {SELECT name FROM sqlite_master LIMIT 1}\n  catchsql {\n    CREATE TABLE test(a integer, primary key(a));\n  }\n} {0 {}}\ndo_test misc1-16.2 {\n  catchsql {\n    CREATE TABLE test(a integer, primary key(a));\n  }\n} {1 {table test already exists}}\ndo_test misc1-16.3 {\n  catchsql {\n    CREATE TABLE test2(a text primary key, b text, primary key(a,b));\n  }\n} {1 {table \"test2\" has more than one primary key}}\ndo_test misc1-16.4 {\n  execsql {\n    INSERT INTO test VALUES(1);\n    SELECT rowid, a FROM test;\n  }\n} {1 1}\ndo_test misc1-16.5 {\n  execsql {\n    INSERT INTO test VALUES(5);\n    SELECT rowid, a FROM test;\n  }\n} {1 1 5 5}\ndo_test misc1-16.6 {\n  execsql {\n    INSERT INTO test VALUES(NULL);\n    SELECT rowid, a FROM test;\n  }\n} {1 1 5 5 6 6}\n\nifcapable trigger&&tempdb {\n# Ticket #333: Temp triggers that modify persistent tables.\n#\ndo_test misc1-17.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE RealTable(TestID INTEGER PRIMARY KEY, TestString TEXT);\n    CREATE TEMP TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT);\n    CREATE TEMP TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN\n      INSERT INTO RealTable(TestString) \n         SELECT new.TestString FROM TempTable LIMIT 1;\n    END;\n    INSERT INTO TempTable(TestString) VALUES ('1');\n    INSERT INTO TempTable(TestString) VALUES ('2');\n    UPDATE TempTable SET TestString = TestString + 1 WHERE TestID=1 OR TestId=2;\n    COMMIT;\n    SELECT TestString FROM RealTable ORDER BY 1;\n  }\n} {2 3}\n}\n\ndo_test misc1-18.1 {\n  set n [sqlite3_sleep 100]\n  expr {$n>=100}\n} {1}\n\n# 2014-01-10:  In a CREATE TABLE AS, if one or more of the column names\n# are an empty string, that is still OK.\n#\ndo_execsql_test misc1-19.1 {\n  CREATE TABLE t19 AS SELECT 1, 2 AS '', 3;\n  SELECT * FROM t19;\n} {1 2 3}\ndo_execsql_test misc1-19.2 {\n  CREATE TABLE t19b AS SELECT 4 AS '', 5 AS '',  6 AS '';\n  SELECT * FROM t19b;\n} {4 5 6}\n\n# 2015-05-20:  CREATE TABLE AS should not store INT value is a TEXT\n# column.\n#\ndo_execsql_test misc1-19.3 {\n  CREATE TABLE t19c(x TEXT);\n  CREATE TABLE t19d AS SELECT * FROM t19c UNION ALL SELECT 1234;\n  SELECT x, typeof(x) FROM t19d;\n} {1234 text}\n\n# 2014-05-16:  Tests for the SQLITE_TESTCTRL_FAULT_INSTALL feature.\n#\nunset -nocomplain fault_callbacks\nset fault_callbacks {}\nproc fault_callback {n} {\n  lappend ::fault_callbacks $n\n  return 0\n}\ndo_test misc1-19.1 {\n  sqlite3_test_control_fault_install fault_callback\n  set fault_callbacks\n} {0}\ndo_test misc1-19.2 {\n  sqlite3_test_control_fault_install\n  set fault_callbacks\n} {0}\n\n# 2015-01-26:  Valgrind-detected over-read.\n# Reported on sqlite-users@sqlite.org by Michal Zalewski.  Found by afl-fuzz\n# presumably.\n#\ndo_execsql_test misc1-20.1 {\n  CREATE TABLE t0(x INTEGER DEFAULT(0==0) NOT NULL);\n  REPLACE INTO t0(x) VALUES('');\n  SELECT rowid, quote(x) FROM t0;\n} {1 ''}\n\n# 2015-03-22: NULL pointer dereference after a syntax error\n#\ndo_catchsql_test misc1-21.1 {\n  select''like''like''like#0;\n} {1 {near \"#0\": syntax error}}\ndo_catchsql_test misc1-21.2 {\n  VALUES(0,0x0MATCH#0;\n} {1 {near \";\": syntax error}}\n\n# 2015-04-15\ndo_execsql_test misc1-22.1 {\n  SELECT \"\"+3 FROM (SELECT \"\"+5);\n} {3}\n\n# 2015-04-19: NULL pointer dereference on a corrupt schema\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test misc1-23.1 {\n  CREATE TABLE t1(x);\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)';\n  BEGIN;\n  CREATE TABLE t2(y);\n  ROLLBACK;\n  DROP TABLE IF EXISTS t3;\n} {}\n\n# 2015-04-19:  Faulty assert() statement\n#\ndb close\ndatabase_may_be_corrupt\nsqlite3 db :memory:\ndo_catchsql_test misc1-23.2 {\n  CREATE TABLE t1(x UNIQUE);\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE TABLE IF not EXISTS t(c)';\n  BEGIN;\n  CREATE TABLE t2(x);\n  ROLLBACK;\n  DROP TABLE F;\n} {1 {no such table: F}}\ndb close\nsqlite3 db :memory:\ndo_catchsql_test misc1-23.3 {\n  CREATE TABLE t1(x UNIQUE);\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE table y(a TEXT, a TEXT)';\n  BEGIN;\n  CREATE TABLE t2(y);\n  ROLLBACK;\n  DROP TABLE IF EXISTS t;\n} {0 {}}\n\n\n# At one point, running this would read one byte passed the end of a \n# buffer, upsetting valgrind.\n#\ndo_test misc1-24.0 {\n  list [catch { sqlite3_prepare_v2 db ! -1 dummy } msg] $msg\n} {1 {(1) unrecognized token: \"!\"}}\n\n# The following query (provided by Kostya Serebryany) used to take 25\n# minutes to prepare.  This has been speeded up to about 250 milliseconds.\n#\ndo_catchsql_test misc1-25.0 {\nSELECT-1 UNION  SELECT 5 UNION SELECT 0 UNION SElECT*from(SELECT-5) UNION SELECT*from(SELECT-0) UNION  SELECT:SELECT-0 UNION SELECT-1 UNION SELECT 1 UNION SELECT 1 ORDER BY S  in(WITH K AS(WITH K AS(select'CREINDERcharREADEVIRTUL5TABLECONFLICT !1 USIN'' MFtOR(b38q,eWITH K AS(selectCREATe TABLE t0(a,b,c,d,e, PRIMARY KEY(a,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,b,c,d,c,a,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d'CEIl,k'',ab, g, a,b,o11b, i'nEX/charREDE IVT LR!VABLt5SG',N  ,N in rement,l_vacuum,M&U,'te3(''5l' a,bB,b,l*e)SELECT:SELECT, *,*,*from(( SELECT\n$group,:conc ap0,1)fro,(select\"\",:PBAG,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d, foreign_keysc,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,c,a,b,b,c,d,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,d,c,e,d,d,c,a,b,b,c,c,a,b,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,bb,b,E,d,c,d,c,b,c,d,c,d,c,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,a,b,c,e,d,d,c,a,b,b,c,d,d,c,a,b,c,e,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,c,d,c,a,b,d,d,c,a,a,b,d,d,c,a,b,b,c,d,c,a,b,e,e,d,b,c,d,c,a,b,b,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,c,a,b,c,e,d,d,c,a,b,b,c,d,c,d,c,a,b,c,e,c,d,c,a,b,b,c,d,MAato_aecSELEC,+?b,\" \"O,\"i\",\"a\",\"\"b  ,5 ))KEY)SELECT*FROM((k()reaC,k,K) eA,k '' )t ,K  M);\n} {1 {'k' is not a function}}\n\n# 2017-09-17\n#\n# Sometimes sqlite3ExprListAppend() can be invoked on an ExprList that\n# was obtained from sqlite3ExprListDup().\n#\ndo_execsql_test misc1-26.0 {\n  DROP TABLE IF EXISTS abc;\n  CREATE TABLE abc(a, b, c);\n  SELECT randomblob(min(max(coalesce(EXISTS (SELECT 1 FROM ( SELECT (SELECT 2147483647) NOT IN (SELECT 2147483649 UNION ALL SELECT DISTINCT -1) IN (SELECT 2147483649), 'fault', (SELECT ALL -1 INTERSECT SELECT 'experiments') IN (SELECT ALL 56.1 ORDER BY 'experiments' DESC) FROM (SELECT DISTINCT 2147483648, 'hardware' UNION ALL SELECT -2147483648, 'experiments' ORDER BY 2147483648 LIMIT 1 OFFSET 123456789.1234567899) GROUP BY (SELECT ALL 0 INTERSECT SELECT 'in') IN (SELECT DISTINCT 'experiments' ORDER BY zeroblob(1000) LIMIT 56.1 OFFSET -456) HAVING EXISTS (SELECT 'fault' EXCEPT    SELECT DISTINCT 56.1) UNION SELECT 'The', 'The', 2147483649 UNION ALL SELECT DISTINCT 'hardware', 'first', 'experiments' ORDER BY 'hardware' LIMIT 123456789.1234567899 OFFSET -2147483647)) NOT IN (SELECT (SELECT DISTINCT (SELECT 'The') FROM abc ORDER BY EXISTS (SELECT -1 INTERSECT SELECT ALL NULL) ASC) IN (SELECT DISTINCT EXISTS (SELECT ALL 123456789.1234567899 ORDER BY 1 ASC, NULL DESC) FROM sqlite_master INTERSECT SELECT 456)), (SELECT ALL 'injection' UNION ALL SELECT ALL (SELECT DISTINCT 'first' UNION     SELECT DISTINCT 'The') FROM (SELECT 456, 'in', 2147483649))),1), 500)), 'first', EXISTS (SELECT DISTINCT 456 FROM abc ORDER BY 'experiments' DESC) FROM abc;\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc2.test",
    "content": "# 2003 June 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for miscellanous features that were\n# left out of other test files.\n#\n# $Id: misc2.test,v 1.28 2007/09/12 17:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The tests in this file were written before SQLite supported recursive\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\nifcapable {trigger} {\n# Test for ticket #360\n#\ndo_test misc2-1.1 {\n  catchsql {\n    CREATE TABLE FOO(bar integer);\n    CREATE TRIGGER foo_insert BEFORE INSERT ON foo BEGIN\n      SELECT CASE WHEN (NOT new.bar BETWEEN 0 AND 20)\n             THEN raise(rollback, 'aiieee') END;\n    END;\n    INSERT INTO foo(bar) VALUES (1);\n  }\n} {0 {}}\ndo_test misc2-1.2 {\n  catchsql {\n    INSERT INTO foo(bar) VALUES (111);\n  }\n} {1 aiieee}\n} ;# endif trigger\n\n# Make sure ROWID works on a view and a subquery.  Ticket #364\n#\ndo_test misc2-2.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES(7,8,9);\n  }\n} {}\nifcapable subquery {\n  do_test misc2-2.2 {\n    execsql {\n      SELECT rowid, * FROM (SELECT * FROM t1, t2);\n    }\n  } {{} 1 2 3 7 8 9}\n}\nifcapable view {\n  do_test misc2-2.3 {\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM t1, t2;\n      SELECT rowid, * FROM v1;\n    }\n  } {{} 1 2 3 7 8 9}\n} ;# ifcapable view\n\n# Ticket #2002 and #1952.\nifcapable subquery {\n  do_test misc2-2.4 {\n    execsql2 {\n      SELECT * FROM (SELECT a, b AS 'a', c AS 'a', 4 AS 'a' FROM t1)\n    }\n  } {a 1 a:1 2 a:2 3 a:3 4}\n}\n\n# Check name binding precedence.  Ticket #387\n#\ndo_test misc2-3.1 {\n  catchsql {\n    SELECT t1.b+t2.b AS a, t1.a, t2.a FROM t1, t2 WHERE a==10\n  }\n} {1 {ambiguous column name: a}}\n\n# Make sure 32-bit integer overflow is handled properly in queries.\n# ticket #408\n#\ndo_test misc2-4.1 {\n  execsql {\n    INSERT INTO t1 VALUES(4000000000,'a','b');\n    SELECT a FROM t1 WHERE a>1;\n  }\n} {4000000000}\ndo_test misc2-4.2 {\n  execsql {\n    INSERT INTO t1 VALUES(2147483648,'b2','c2');\n    INSERT INTO t1 VALUES(2147483647,'b3','c3');\n    SELECT a FROM t1 WHERE a>2147483647;\n  }\n} {4000000000 2147483648}\ndo_test misc2-4.3 {\n  execsql {\n    SELECT a FROM t1 WHERE a<2147483648;\n  }\n} {1 2147483647}\ndo_test misc2-4.4 {\n  execsql {\n    SELECT a FROM t1 WHERE a<=2147483648;\n  }\n} {1 2147483648 2147483647}\ndo_test misc2-4.5 {\n  execsql {\n    SELECT a FROM t1 WHERE a<10000000000;\n  }\n} {1 4000000000 2147483648 2147483647}\ndo_test misc2-4.6 {\n  execsql {\n    SELECT a FROM t1 WHERE a<1000000000000 ORDER BY 1;\n  }\n} {1 2147483647 2147483648 4000000000}\n\n# There were some issues with expanding a SrcList object using a call\n# to sqliteSrcListAppend() if the SrcList had previously been duplicated\n# using a call to sqliteSrcListDup().  Ticket #416.  The following test\n# makes sure the problem has been fixed.\n#\nifcapable view {\ndo_test misc2-5.1 {\n  execsql {\n    CREATE TABLE x(a,b);\n    CREATE VIEW y AS \n      SELECT x1.b AS p, x2.b AS q FROM x AS x1, x AS x2 WHERE x1.a=x2.a;\n    CREATE VIEW z AS\n      SELECT y1.p, y2.p FROM y AS y1, y AS y2 WHERE y1.q=y2.q;\n    SELECT * from z;\n  }\n} {}\n}\n\n# Make sure we can open a database with an empty filename.  What this\n# does is store the database in a temporary file that is deleted when\n# the database is closed.  Ticket #432.\n#\ndo_test misc2-6.1 {\n  db close\n  sqlite3 db {}\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    SELECT * FROM t1;\n  }\n} {1 2}\n\n# Make sure we get an error message (not a segfault) on an attempt to\n# update a table from within the callback of a select on that same\n# table.\n#\n# 2006-08-16:  This has changed.  It is now permitted to update\n# the table being SELECTed from within the callback of the query.\n#\nifcapable tclvar {\n  do_test misc2-7.1 {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      SELECT * FROM t1;\n    }\n  } {1 2 3}\n  do_test misc2-7.2 {\n    set rc [catch {\n      db eval {SELECT rowid FROM t1} {} {\n        db eval \"DELETE FROM t1 WHERE rowid=$rowid\"\n      }\n    } msg]\n    lappend rc $msg\n  } {0 {}}\n  do_test misc2-7.3 {\n    execsql {SELECT * FROM t1}\n  } {}\n  do_test misc2-7.4 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1 WHERE rowid=$rowid}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {2 4}\n  do_test misc2-7.5 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1 WHERE rowid=$rowid+1}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {1 3}\n  do_test misc2-7.6 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {}\n  do_test misc2-7.7 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x & 1} {\n        db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {101 2 103 4}\n  do_test misc2-7.8 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x<10} {\n        db eval {INSERT INTO t1 VALUES($x+1)}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {1 2 3 4 5 6 7 8 9 10}\n  \n  # Repeat the tests 7.1 through 7.8 about but this time do the SELECTs\n  # in reverse order so that we exercise the sqlite3BtreePrev() routine\n  # instead of sqlite3BtreeNext()\n  #\n  do_test misc2-7.11 {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      SELECT * FROM t1;\n    }\n  } {1 2 3}\n  do_test misc2-7.12 {\n    set rc [catch {\n      db eval {SELECT rowid FROM t1 ORDER BY rowid DESC} {} {\n        db eval \"DELETE FROM t1 WHERE rowid=$rowid\"\n      }\n    } msg]\n    lappend rc $msg\n  } {0 {}}\n  do_test misc2-7.13 {\n    execsql {SELECT * FROM t1}\n  } {}\n  do_test misc2-7.14 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1 WHERE rowid=$rowid}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {2 4}\n  do_test misc2-7.15 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1 WHERE rowid=$rowid+1}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {1 3}\n  do_test misc2-7.16 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {\n      if {$x & 1} {\n        db eval {DELETE FROM t1}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {}\n  do_test misc2-7.17 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n      INSERT INTO t1 VALUES(4);\n    }\n    db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {\n      if {$x & 1} {\n        db eval {UPDATE t1 SET x=x+100 WHERE rowid=$rowid}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {101 2 103 4}\n  do_test misc2-7.18 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1(rowid,x) VALUES(10,10);\n    }\n    db eval {SELECT rowid, x FROM t1 ORDER BY rowid DESC} {\n      if {$x>1} {\n        db eval {INSERT INTO t1(rowid,x) VALUES($x-1,$x-1)}\n      }\n    }\n    execsql {SELECT * FROM t1}\n  } {1 2 3 4 5 6 7 8 9 10}\n}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ncatchsql { pragma recursive_triggers = off } \n\n# Ticket #453.  If the SQL ended with \"-\", the tokenizer was calling that\n# an incomplete token, which caused problem.  The solution was to just call\n# it a minus sign.\n#\ndo_test misc2-8.1 {\n  catchsql {-}\n} {1 {near \"-\": syntax error}}\n\n# Ticket #513.  Make sure the VDBE stack does not grow on a 3-way join.\n#\nifcapable tempdb {\n  do_test misc2-9.1 {\n    execsql {\n      BEGIN;\n      CREATE TABLE counts(n INTEGER PRIMARY KEY);\n      INSERT INTO counts VALUES(0);\n      INSERT INTO counts VALUES(1);\n      INSERT INTO counts SELECT n+2 FROM counts;\n      INSERT INTO counts SELECT n+4 FROM counts;\n      INSERT INTO counts SELECT n+8 FROM counts;\n      COMMIT;\n  \n      CREATE TEMP TABLE x AS\n      SELECT dim1.n, dim2.n, dim3.n\n      FROM counts AS dim1, counts AS dim2, counts AS dim3\n      WHERE dim1.n<10 AND dim2.n<10 AND dim3.n<10;\n  \n      SELECT count(*) FROM x;\n    }\n  } {1000}\n  do_test misc2-9.2 {\n    execsql {\n      DROP TABLE x;\n      CREATE TEMP TABLE x AS\n      SELECT dim1.n, dim2.n, dim3.n\n      FROM counts AS dim1, counts AS dim2, counts AS dim3\n      WHERE dim1.n>=6 AND dim2.n>=6 AND dim3.n>=6;\n  \n      SELECT count(*) FROM x;\n    }\n  } {1000}\n  do_test misc2-9.3 {\n    execsql {\n      DROP TABLE x;\n      CREATE TEMP TABLE x AS\n      SELECT dim1.n, dim2.n, dim3.n, dim4.n\n      FROM counts AS dim1, counts AS dim2, counts AS dim3, counts AS dim4\n      WHERE dim1.n<5 AND dim2.n<5 AND dim3.n<5 AND dim4.n<5;\n  \n      SELECT count(*) FROM x;\n    }\n  } [expr 5*5*5*5]\n}\n\n# Ticket #1229.  Sometimes when a \"NEW.X\" appears in a SELECT without\n# a FROM clause deep within a trigger, the code generator is unable to\n# trace the NEW.X back to an original table and thus figure out its\n# declared datatype.\n#\n# The SQL code below was causing a segfault.\n#\nifcapable subquery&&trigger {\n  do_test misc2-10.1 {\n    execsql {\n      CREATE TABLE t1229(x);\n      CREATE TRIGGER r1229 BEFORE INSERT ON t1229 BEGIN\n        INSERT INTO t1229 SELECT y FROM (SELECT new.x y);\n      END;\n      INSERT INTO t1229 VALUES(1);\n    }\n  } {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc3.test",
    "content": "# 2003 December 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for miscellanous features that were\n# left out of other test files.\n#\n# $Id: misc3.test,v 1.20 2009/05/06 00:49:01 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {integrityck} {\n  # Ticket #529.  Make sure an ABORT does not damage the in-memory cache\n  # that will be used by subsequent statements in the same transaction.\n  #\n  do_test misc3-1.1 {\n    execsql {\n      CREATE TABLE t1(a UNIQUE,b);\n      INSERT INTO t1\n        VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');\n      UPDATE t1 SET b=b||b;\n      UPDATE t1 SET b=b||b;\n      UPDATE t1 SET b=b||b;\n      UPDATE t1 SET b=b||b;\n      UPDATE t1 SET b=b||b;\n      INSERT INTO t1 VALUES(2,'x');\n      UPDATE t1 SET b=substr(b,1,500);\n      BEGIN;\n    }\n    catchsql {UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';}\n    execsql {\n      CREATE TABLE t2(x,y);\n      COMMIT;\n      PRAGMA integrity_check;\n    }\n  } ok\n}\nifcapable {integrityck} {\n  do_test misc3-1.2 {\n    execsql {\n      DROP TABLE t1;\n      DROP TABLE t2;\n    }\n    ifcapable {vacuum} {execsql VACUUM}\n    execsql {\n      CREATE TABLE t1(a UNIQUE,b);\n      INSERT INTO t1\n      VALUES(1,'a23456789_b23456789_c23456789_d23456789_e23456789_');\n      INSERT INTO t1 SELECT a+1, b||b FROM t1;\n      INSERT INTO t1 SELECT a+2, b||b FROM t1;\n      INSERT INTO t1 SELECT a+4, b FROM t1;\n      INSERT INTO t1 SELECT a+8, b FROM t1;\n      INSERT INTO t1 SELECT a+16, b FROM t1;\n      INSERT INTO t1 SELECT a+32, b FROM t1;\n      INSERT INTO t1 SELECT a+64, b FROM t1;\n      BEGIN;\n    }\n    catchsql {UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';}\n    execsql {\n      INSERT INTO t1 VALUES(200,'hello out there');\n      COMMIT;\n      PRAGMA integrity_check;\n    }\n  } ok\n}\n\n# Tests of the sqliteAtoF() function in util.c\n#\ndo_test misc3-2.1 {\n  execsql {SELECT 2e-25*0.5e25}\n} 1.0\ndo_test misc3-2.2 {\n  execsql {SELECT 2.0e-25*000000.500000000000000000000000000000e+00025}\n} 1.0\ndo_test misc3-2.3 {\n  execsql {SELECT 000000000002e-0000000025*0.5e25}\n} 1.0\ndo_test misc3-2.4 {\n  execsql {SELECT 2e-25*0.5e250}\n} 1e+225\ndo_test misc3-2.5 {\n  execsql {SELECT 2.0e-250*0.5e25}\n} 1e-225\ndo_test misc3-2.6 {\n  execsql {SELECT '-2.0e-127' * '-0.5e27'}\n} 1e-100\ndo_test misc3-2.7 {\n  execsql {SELECT '+2.0e-127' * '-0.5e27'}\n} -1e-100\ndo_test misc3-2.8 {\n  execsql {SELECT 2.0e-27 * '+0.5e+127'}\n} 1e+100\ndo_test misc3-2.9 {\n  execsql {SELECT 2.0e-27 * '+0.000005e+132'}\n} 1e+100\n\n# Ticket #522.  Make sure integer overflow is handled properly in\n# indices.\n#\nintegrity_check misc3-3.1\ndo_test misc3-3.2 {\n  execsql {\n    CREATE TABLE t2(a INT UNIQUE);\n  }\n} {}\nintegrity_check misc3-3.2.1\ndo_test misc3-3.3 {\n  execsql {\n    INSERT INTO t2 VALUES(2147483648);\n  }\n} {}\nintegrity_check misc3-3.3.1\ndo_test misc3-3.4 {\n  execsql {\n    INSERT INTO t2 VALUES(-2147483649);\n  }\n} {}\nintegrity_check misc3-3.4.1\ndo_test misc3-3.5 {\n  execsql {\n    INSERT INTO t2 VALUES(+2147483649);\n  }\n} {}\nintegrity_check misc3-3.5.1\ndo_test misc3-3.6 {\n  execsql {\n    INSERT INTO t2 VALUES(+2147483647);\n    INSERT INTO t2 VALUES(-2147483648);\n    INSERT INTO t2 VALUES(-2147483647);\n    INSERT INTO t2 VALUES(2147483646);\n    SELECT * FROM t2 ORDER BY a;\n  }\n} {-2147483649 -2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}\ndo_test misc3-3.7 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=-2147483648 ORDER BY a;\n  }\n} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}\ndo_test misc3-3.8 {\n  execsql {\n    SELECT * FROM t2 WHERE a>-2147483648 ORDER BY a;\n  }\n} {-2147483647 2147483646 2147483647 2147483648 2147483649}\ndo_test misc3-3.9 {\n  execsql {\n    SELECT * FROM t2 WHERE a>-2147483649 ORDER BY a;\n  }\n} {-2147483648 -2147483647 2147483646 2147483647 2147483648 2147483649}\ndo_test misc3-3.10 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=0 AND a<2147483649 ORDER BY a DESC;\n  }\n} {2147483648 2147483647 2147483646}\ndo_test misc3-3.11 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=0 AND a<=2147483648 ORDER BY a DESC;\n  }\n} {2147483648 2147483647 2147483646}\ndo_test misc3-3.12 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=0 AND a<2147483648 ORDER BY a DESC;\n  }\n} {2147483647 2147483646}\ndo_test misc3-3.13 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=0 AND a<=2147483647 ORDER BY a DESC;\n  }\n} {2147483647 2147483646}\ndo_test misc3-3.14 {\n  execsql {\n    SELECT * FROM t2 WHERE a>=0 AND a<2147483647 ORDER BY a DESC;\n  }\n} {2147483646}\n\n# Ticket #565.  A stack overflow is occurring when the subquery to the\n# right of an IN operator contains many NULLs\n#\ndo_test misc3-4.1 {\n  execsql {\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t3(b) VALUES('abc');\n    INSERT INTO t3(b) VALUES('xyz');\n    INSERT INTO t3(b) VALUES(NULL);\n    INSERT INTO t3(b) VALUES(NULL);\n    INSERT INTO t3(b) SELECT b||'d' FROM t3;\n    INSERT INTO t3(b) SELECT b||'e' FROM t3;\n    INSERT INTO t3(b) SELECT b||'f' FROM t3;\n    INSERT INTO t3(b) SELECT b||'g' FROM t3;\n    INSERT INTO t3(b) SELECT b||'h' FROM t3;\n    SELECT count(a), count(b) FROM t3;\n  }\n} {128 64}\nifcapable subquery {\ndo_test misc3-4.2 {\n    execsql {\n      SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3);\n    }\n  } {64}\n  do_test misc3-4.3 {\n    execsql {\n      SELECT count(a) FROM t3 WHERE b IN (SELECT b FROM t3 ORDER BY a+1);\n    }\n  } {64}\n}\n\n# Ticket #601:  Putting a left join inside \"SELECT * FROM (<join-here>)\"\n# gives different results that if the outer \"SELECT * FROM ...\" is omitted.\n#\nifcapable subquery {\n  do_test misc3-5.1 {\n    execsql {\n      CREATE TABLE x1 (b, c);\n      INSERT INTO x1 VALUES('dog',3);\n      INSERT INTO x1 VALUES('cat',1);\n      INSERT INTO x1 VALUES('dog',4);\n      CREATE TABLE x2 (c, e);\n      INSERT INTO x2 VALUES(1,'one');\n      INSERT INTO x2 VALUES(2,'two');\n      INSERT INTO x2 VALUES(3,'three');\n      INSERT INTO x2 VALUES(4,'four');\n      SELECT x2.c AS c, e, b FROM x2 LEFT JOIN\n         (SELECT b, max(c)+0 AS c FROM x1 GROUP BY b)\n         USING(c);\n    }\n  } {1 one cat 2 two {} 3 three {} 4 four dog}\n  do_test misc3-5.2 {\n    execsql {\n      SELECT * FROM (\n        SELECT x2.c AS c, e, b FROM x2 LEFT JOIN\n           (SELECT b, max(c)+0 AS c FROM x1 GROUP BY b)\n           USING(c)\n      );\n    }\n  } {1 one cat 2 two {} 3 three {} 4 four dog}\n}\n\nifcapable {explain} {\n  # Ticket #626:  make sure EXPLAIN prevents BEGIN and COMMIT from working.\n  #\n  do_test misc3-6.1 {\n    execsql {EXPLAIN BEGIN}\n    catchsql {BEGIN}\n  } {0 {}}\n  do_test misc3-6.2 {\n    execsql {EXPLAIN COMMIT}\n    catchsql {COMMIT}\n  } {0 {}}\n  do_test misc3-6.3 {\n    execsql {BEGIN; EXPLAIN ROLLBACK}\n    catchsql {ROLLBACK}\n  } {0 {}}\n\n  # Do some additional EXPLAIN operations to exercise the displayP4 logic.\n  do_test misc3-6.10 {\n    set x [execsql {\n      CREATE TABLE ex1(\n        a INTEGER DEFAULT 54321,\n        b TEXT DEFAULT \"hello\",\n        c REAL DEFAULT 3.1415926\n      );\n      CREATE UNIQUE INDEX ex1i1 ON ex1(a);\n      EXPLAIN REINDEX;\n    }]\n    ifcapable mergesort {\n      regexp { SorterCompare \\d+ \\d+ \\d+ } $x\n    } else {\n      regexp { IsUnique \\d+ \\d+ \\d+ \\d+ } $x\n    }\n  } {1}\n  if {[regexp {16} [db one {PRAGMA encoding}]]} {\n    do_test misc3-6.11-utf16 {\n      set x [execsql {\n        EXPLAIN SELECT a+123456789012, b*4.5678, c FROM ex1 ORDER BY +a, b DESC\n      }]\n      set y [regexp { 123456789012 } $x]\n      lappend y [regexp { 4.5678 } $x]\n      lappend y [regexp {,-B} $x]\n    } {1 1 1}\n  } else {\n    do_test misc3-6.11-utf8 {\n      set x [execsql {\n        EXPLAIN SELECT a+123456789012, b*4.5678, c FROM ex1 ORDER BY +a, b DESC\n      }]\n      set y [regexp { 123456789012 } $x]\n      lappend y [regexp { 4.5678 } $x]\n      lappend y [regexp { hello } $x]\n      lappend y [regexp {,-B} $x]\n    } {1 1 1 1}\n  }\n}\n\nifcapable {trigger} {\n# Ticket #640:  vdbe stack overflow with a LIMIT clause on a SELECT inside\n# of a trigger.\n#\ndo_test misc3-7.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE y1(a);\n    CREATE TABLE y2(b);\n    CREATE TABLE y3(c);\n    CREATE TRIGGER r1 AFTER DELETE ON y1 FOR EACH ROW BEGIN\n      INSERT INTO y3(c) SELECT b FROM y2 ORDER BY b LIMIT 1;\n    END;\n    INSERT INTO y1 VALUES(1);\n    INSERT INTO y1 VALUES(2);\n    INSERT INTO y1 SELECT a+2 FROM y1;\n    INSERT INTO y1 SELECT a+4 FROM y1;\n    INSERT INTO y1 SELECT a+8 FROM y1;\n    INSERT INTO y1 SELECT a+16 FROM y1;\n    INSERT INTO y2 SELECT a FROM y1;\n    COMMIT;\n    SELECT count(*) FROM y1;\n  }\n} 32\ndo_test misc3-7.2 {\n  execsql {\n    DELETE FROM y1;\n    SELECT count(*) FROM y1;\n  }\n} 0\ndo_test misc3-7.3 {\n  execsql {\n    SELECT count(*) FROM y3;\n  }\n} 32\n} ;# endif trigger\n\n# Ticket #668:  VDBE stack overflow occurs when the left-hand side\n# of an IN expression is NULL and the result is used as an integer, not\n# as a jump.\n#\nifcapable subquery {\n  do_test misc-8.1 {\n    execsql {\n      SELECT count(CASE WHEN b IN ('abc','xyz') THEN 'x' END) FROM t3\n    }\n  } {2}\n  do_test misc-8.2 {\n    execsql {\n      SELECT count(*) FROM t3 WHERE 1+(b IN ('abc','xyz'))==2\n    }\n  } {2}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc4.test",
    "content": "# 2004 Jun 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for miscellanous features that were\n# left out of other test files.\n#\n# $Id: misc4.test,v 1.23 2007/12/08 18:01:31 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Prepare a statement that will create a temporary table.  Then do\n# a rollback.  Then try to execute the prepared statement.\n#\ndo_test misc4-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n  }\n} {}\n\nifcapable tempdb {\n  do_test misc4-1.2 {\n    set sql {CREATE TEMP TABLE t2 AS SELECT * FROM t1}\n    set stmt [sqlite3_prepare $DB $sql -1 TAIL]\n    execsql {\n      BEGIN;\n      CREATE TABLE t3(a,b,c);\n      INSERT INTO t1 SELECT * FROM t1;\n      ROLLBACK;\n    }\n  } {}\n\n  # Because the previous transaction included a DDL statement and\n  # was rolled back, statement $stmt was marked as expired. Executing it\n  # now returns SQLITE_SCHEMA.\n  do_test misc4-1.2.1 {\n    list [sqlite3_step $stmt] [sqlite3_finalize $stmt]\n  } {SQLITE_ERROR SQLITE_SCHEMA}\n  do_test misc4-1.2.2 {\n    set stmt [sqlite3_prepare $DB $sql -1 TAIL]\n    set TAIL\n  } {}\n\n  do_test misc4-1.3 {\n    sqlite3_step $stmt\n  } SQLITE_DONE\n  do_test misc4-1.4 {\n    execsql {\n      SELECT * FROM temp.t2;\n    }\n  } {1}\n  \n  # Drop the temporary table, then rerun the prepared  statement to\n  # recreate it again.  This recreates ticket #807.\n  #\n  do_test misc4-1.5 {\n    execsql {DROP TABLE t2}\n    sqlite3_reset $stmt\n    sqlite3_step $stmt\n  } {SQLITE_ERROR}\n  do_test misc4-1.6 {\n    sqlite3_finalize $stmt\n  } {SQLITE_SCHEMA}\n}\n\n# Prepare but do not execute various CREATE statements.  Then before\n# those statements are executed, try to use the tables, indices, views,\n# are triggers that were created.\n#\ndo_test misc4-2.1 {\n  set stmt [sqlite3_prepare $DB {CREATE TABLE t3(x);} -1 TAIL]\n  catchsql {\n    INSERT INTO t3 VALUES(1);\n  }\n} {1 {no such table: t3}}\ndo_test misc4-2.2 {\n  sqlite3_step $stmt\n} SQLITE_DONE\ndo_test misc4-2.3 {\n  sqlite3_finalize $stmt\n} SQLITE_OK\ndo_test misc4-2.4 {\n  catchsql {\n    INSERT INTO t3 VALUES(1);\n  }\n} {0 {}}\n\n# Ticket #966\n#\ndo_test misc4-3.1 {\n  execsql { \n    CREATE TABLE Table1(ID integer primary key, Value TEXT);\n    INSERT INTO Table1 VALUES(1, 'x');\n    CREATE TABLE Table2(ID integer NOT NULL, Value TEXT);\n    INSERT INTO Table2 VALUES(1, 'z');\n    INSERT INTO Table2 VALUES (1, 'a');\n  }\n  catchsql { \n    SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2 ORDER BY 1, 2;\n  }\n} {1 {aggregate functions are not allowed in the GROUP BY clause}}\nifcapable compound {\n  do_test misc4-3.2 {\n    execsql {\n      SELECT ID, Value FROM Table1\n         UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1\n      ORDER BY 1, 2;\n    }\n  } {1 x 1 z}\n  do_test misc4-3.3 {\n    catchsql { \n      SELECT ID, Value FROM Table1\n         UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2\n      ORDER BY 1, 2;\n    }\n  } {1 {aggregate functions are not allowed in the GROUP BY clause}}\n  do_test misc4-3.4 {\n    catchsql { \n      SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2\n         UNION SELECT ID, Value FROM Table1\n      ORDER BY 1, 2;\n    }\n  } {1 {aggregate functions are not allowed in the GROUP BY clause}}\n} ;# ifcapable compound\n\n# Ticket #1047.  Make sure column types are preserved in subqueries.\n#\nifcapable subquery {\n  do_test misc4-4.1 {\n    execsql {\n      create table a(key varchar, data varchar);\n      create table b(key varchar, period integer);\n      insert into a values('01','data01');\n      insert into a values('+1','data+1');\n      \n      insert into b values ('01',1);\n      insert into b values ('01',2);\n      insert into b values ('+1',3);\n      insert into b values ('+1',4);\n      \n      select a.*, x.*\n        from a, (select key,sum(period) from b group by key) as x\n        where a.key=x.key order by 1 desc;\n    }\n  } {01 data01 01 3 +1 data+1 +1 7}\n\n  # This test case tests the same property as misc4-4.1, but it is\n  # a bit smaller which makes it easier to work with while debugging.\n  do_test misc4-4.2 {\n    execsql {\n      CREATE TABLE ab(a TEXT, b TEXT);\n      INSERT INTO ab VALUES('01', '1');\n    }\n    execsql {\n      select * from ab, (select b from ab) as x where x.b = ab.a;\n    }\n  } {}\n}\n\n\n# Ticket #1036.  When creating tables from a SELECT on a view, use the\n# short names of columns.\n#\nifcapable view {\n  do_test misc4-5.1 {\n    execsql {\n      create table t4(a,b);\n      create table t5(a,c);\n      insert into t4 values (1,2);\n      insert into t5 values (1,3);\n      create view myview as select t4.a a from t4 inner join t5 on t4.a=t5.a;\n      create table problem as select * from myview; \n    }\n    execsql2 {\n      select * FROM problem;\n    }\n  } {a 1}\n  do_test misc4-5.2 {\n    execsql2 {\n      create table t6 as select * from t4, t5;\n      select * from t6;\n    }\n  } {a 1 b 2 a:1 1 c 3}\n}\n\n# Ticket #1086\ndo_test misc4-6.1 {\n  execsql {\n    CREATE TABLE abc(a);\n    INSERT INTO abc VALUES(1);\n    CREATE TABLE def(d, e, f, PRIMARY KEY(d, e));\n  }\n} {}\ndo_test misc4-6.2 {\n  execsql {\n    SELECT a FROM abc LEFT JOIN def ON (abc.a=def.d);\n  }\n} {1}\n\n# 2015-05-15.  Error message formatting problem.\n#\ndb close\nsqlite3 db :memory:\ndo_catchsql_test misc4-7.1 {\n  CREATE TABLE t7(x);\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE TABLE [M%s%s%s%s%s%s%s%s%s%s%s%s%s';\n  VACUUM;\n} {1 {unrecognized token: \"[M%s%s%s%s%s%s%s%s%s%s%s%s%s\"}}\n\n# 2015-05-18.  Use of ephermeral Mem content after the cursor that holds\n# the canonical content has moved on.\n#\ndo_execsql_test misc4-7.2 {\n  CREATE TABLE t0(a,b);\n  INSERT INTO t0 VALUES(1,0),(2,0);\n  UPDATE t0 SET b=9 WHERE a AND (SELECT a FROM t0 WHERE a);\n  SELECT * FROM t0 ORDER BY +a;\n} {1 9 2 9}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc5.test",
    "content": "# 2005 Mar 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for miscellanous features that were\n# left out of other test files.\n#\n# $Id: misc5.test,v 1.22 2008/07/29 10:26:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build records using the MakeRecord opcode such that the size of the \n# header is at the transition point in the size of a varint.\n#\n# This test causes an assertion failure or a buffer overrun in version\n# 3.1.5 and earlier.\n#\nfor {set i 120} {$i<140} {incr i} {\n  do_test misc5-1.$i {\n    catchsql {DROP TABLE t1}\n    set sql1 {CREATE TABLE t1}\n    set sql2 {INSERT INTO t1 VALUES}\n    set sep (\n    for {set j 0} {$j<$i} {incr j} {\n      append sql1 ${sep}a$j\n      append sql2 ${sep}$j\n      set sep ,\n    }\n    append sql1 {);}\n    append sql2 {);}\n    execsql $sql1$sql2\n  } {}\n}\n\n# Make sure large integers are stored correctly.\n#\nifcapable conflict {\n  do_test misc5-2.1 {\n    execsql {\n      create table t2(x unique);\n      insert into t2 values(1);\n      insert or ignore into t2 select x*2 from t2;\n      insert or ignore into t2 select x*4 from t2;\n      insert or ignore into t2 select x*16 from t2;\n      insert or ignore into t2 select x*256 from t2;\n      insert or ignore into t2 select x*65536 from t2;\n      insert or ignore into t2 select x*2147483648 from t2;\n      insert or ignore into t2 select x-1 from t2;\n      insert or ignore into t2 select x+1 from t2;\n      insert or ignore into t2 select -x from t2;\n      select count(*) from t2;\n    }\n  } 371\n} else {\n  do_test misc5-2.1 {\n    execsql {\n      BEGIN;\n      create table t2(x unique);\n      create table t2_temp(x);\n      insert into t2_temp values(1);\n      insert into t2_temp select x*2 from t2_temp;\n      insert into t2_temp select x*4 from t2_temp;\n      insert into t2_temp select x*16 from t2_temp;\n      insert into t2_temp select x*256 from t2_temp;\n      insert into t2_temp select x*65536 from t2_temp;\n      insert into t2_temp select x*2147483648 from t2_temp;\n      insert into t2_temp select x-1 from t2_temp;\n      insert into t2_temp select x+1 from t2_temp;\n      insert into t2_temp select -x from t2_temp;\n      INSERT INTO t2 SELECT DISTINCT(x) FROM t2_temp;\n      DROP TABLE t2_temp;\n      COMMIT;\n      select count(*) from t2;\n    }\n  } 371\n}\ndo_test misc5-2.2 {\n  execsql {\n    select x from t2 order by x;\n  }\n} \\\n\"-4611686018427387905\\\n-4611686018427387904\\\n-4611686018427387903\\\n-2305843009213693953\\\n-2305843009213693952\\\n-2305843009213693951\\\n-1152921504606846977\\\n-1152921504606846976\\\n-1152921504606846975\\\n-576460752303423489\\\n-576460752303423488\\\n-576460752303423487\\\n-288230376151711745\\\n-288230376151711744\\\n-288230376151711743\\\n-144115188075855873\\\n-144115188075855872\\\n-144115188075855871\\\n-72057594037927937\\\n-72057594037927936\\\n-72057594037927935\\\n-36028797018963969\\\n-36028797018963968\\\n-36028797018963967\\\n-18014398509481985\\\n-18014398509481984\\\n-18014398509481983\\\n-9007199254740993\\\n-9007199254740992\\\n-9007199254740991\\\n-4503599627370497\\\n-4503599627370496\\\n-4503599627370495\\\n-2251799813685249\\\n-2251799813685248\\\n-2251799813685247\\\n-1125899906842625\\\n-1125899906842624\\\n-1125899906842623\\\n-562949953421313\\\n-562949953421312\\\n-562949953421311\\\n-281474976710657\\\n-281474976710656\\\n-281474976710655\\\n-140737488355329\\\n-140737488355328\\\n-140737488355327\\\n-70368744177665\\\n-70368744177664\\\n-70368744177663\\\n-35184372088833\\\n-35184372088832\\\n-35184372088831\\\n-17592186044417\\\n-17592186044416\\\n-17592186044415\\\n-8796093022209\\\n-8796093022208\\\n-8796093022207\\\n-4398046511105\\\n-4398046511104\\\n-4398046511103\\\n-2199023255553\\\n-2199023255552\\\n-2199023255551\\\n-1099511627777\\\n-1099511627776\\\n-1099511627775\\\n-549755813889\\\n-549755813888\\\n-549755813887\\\n-274877906945\\\n-274877906944\\\n-274877906943\\\n-137438953473\\\n-137438953472\\\n-137438953471\\\n-68719476737\\\n-68719476736\\\n-68719476735\\\n-34359738369\\\n-34359738368\\\n-34359738367\\\n-17179869185\\\n-17179869184\\\n-17179869183\\\n-8589934593\\\n-8589934592\\\n-8589934591\\\n-4294967297\\\n-4294967296\\\n-4294967295\\\n-2147483649\\\n-2147483648\\\n-2147483647\\\n-1073741825\\\n-1073741824\\\n-1073741823\\\n-536870913\\\n-536870912\\\n-536870911\\\n-268435457\\\n-268435456\\\n-268435455\\\n-134217729\\\n-134217728\\\n-134217727\\\n-67108865\\\n-67108864\\\n-67108863\\\n-33554433\\\n-33554432\\\n-33554431\\\n-16777217\\\n-16777216\\\n-16777215\\\n-8388609\\\n-8388608\\\n-8388607\\\n-4194305\\\n-4194304\\\n-4194303\\\n-2097153\\\n-2097152\\\n-2097151\\\n-1048577\\\n-1048576\\\n-1048575\\\n-524289\\\n-524288\\\n-524287\\\n-262145\\\n-262144\\\n-262143\\\n-131073\\\n-131072\\\n-131071\\\n-65537\\\n-65536\\\n-65535\\\n-32769\\\n-32768\\\n-32767\\\n-16385\\\n-16384\\\n-16383\\\n-8193\\\n-8192\\\n-8191\\\n-4097\\\n-4096\\\n-4095\\\n-2049\\\n-2048\\\n-2047\\\n-1025\\\n-1024\\\n-1023\\\n-513\\\n-512\\\n-511\\\n-257\\\n-256\\\n-255\\\n-129\\\n-128\\\n-127\\\n-65\\\n-64\\\n-63\\\n-33\\\n-32\\\n-31\\\n-17\\\n-16\\\n-15\\\n-9\\\n-8\\\n-7\\\n-5\\\n-4\\\n-3\\\n-2\\\n-1\\\n0\\\n1\\\n2\\\n3\\\n4\\\n5\\\n7\\\n8\\\n9\\\n15\\\n16\\\n17\\\n31\\\n32\\\n33\\\n63\\\n64\\\n65\\\n127\\\n128\\\n129\\\n255\\\n256\\\n257\\\n511\\\n512\\\n513\\\n1023\\\n1024\\\n1025\\\n2047\\\n2048\\\n2049\\\n4095\\\n4096\\\n4097\\\n8191\\\n8192\\\n8193\\\n16383\\\n16384\\\n16385\\\n32767\\\n32768\\\n32769\\\n65535\\\n65536\\\n65537\\\n131071\\\n131072\\\n131073\\\n262143\\\n262144\\\n262145\\\n524287\\\n524288\\\n524289\\\n1048575\\\n1048576\\\n1048577\\\n2097151\\\n2097152\\\n2097153\\\n4194303\\\n4194304\\\n4194305\\\n8388607\\\n8388608\\\n8388609\\\n16777215\\\n16777216\\\n16777217\\\n33554431\\\n33554432\\\n33554433\\\n67108863\\\n67108864\\\n67108865\\\n134217727\\\n134217728\\\n134217729\\\n268435455\\\n268435456\\\n268435457\\\n536870911\\\n536870912\\\n536870913\\\n1073741823\\\n1073741824\\\n1073741825\\\n2147483647\\\n2147483648\\\n2147483649\\\n4294967295\\\n4294967296\\\n4294967297\\\n8589934591\\\n8589934592\\\n8589934593\\\n17179869183\\\n17179869184\\\n17179869185\\\n34359738367\\\n34359738368\\\n34359738369\\\n68719476735\\\n68719476736\\\n68719476737\\\n137438953471\\\n137438953472\\\n137438953473\\\n274877906943\\\n274877906944\\\n274877906945\\\n549755813887\\\n549755813888\\\n549755813889\\\n1099511627775\\\n1099511627776\\\n1099511627777\\\n2199023255551\\\n2199023255552\\\n2199023255553\\\n4398046511103\\\n4398046511104\\\n4398046511105\\\n8796093022207\\\n8796093022208\\\n8796093022209\\\n17592186044415\\\n17592186044416\\\n17592186044417\\\n35184372088831\\\n35184372088832\\\n35184372088833\\\n70368744177663\\\n70368744177664\\\n70368744177665\\\n140737488355327\\\n140737488355328\\\n140737488355329\\\n281474976710655\\\n281474976710656\\\n281474976710657\\\n562949953421311\\\n562949953421312\\\n562949953421313\\\n1125899906842623\\\n1125899906842624\\\n1125899906842625\\\n2251799813685247\\\n2251799813685248\\\n2251799813685249\\\n4503599627370495\\\n4503599627370496\\\n4503599627370497\\\n9007199254740991\\\n9007199254740992\\\n9007199254740993\\\n18014398509481983\\\n18014398509481984\\\n18014398509481985\\\n36028797018963967\\\n36028797018963968\\\n36028797018963969\\\n72057594037927935\\\n72057594037927936\\\n72057594037927937\\\n144115188075855871\\\n144115188075855872\\\n144115188075855873\\\n288230376151711743\\\n288230376151711744\\\n288230376151711745\\\n576460752303423487\\\n576460752303423488\\\n576460752303423489\\\n1152921504606846975\\\n1152921504606846976\\\n1152921504606846977\\\n2305843009213693951\\\n2305843009213693952\\\n2305843009213693953\\\n4611686018427387903\\\n4611686018427387904\\\n4611686018427387905\"\n\n# Ticket #1210.  Do proper reference counting of Table structures\n# so that deeply nested SELECT statements can be flattened correctly.\n#\nifcapable subquery {\n  do_test misc5-3.1 {\n    execsql {\n      CREATE TABLE songs(songid, artist, timesplayed);\n      INSERT INTO songs VALUES(1,'one',1);\n      INSERT INTO songs VALUES(2,'one',2);\n      INSERT INTO songs VALUES(3,'two',3);\n      INSERT INTO songs VALUES(4,'three',5);\n      INSERT INTO songs VALUES(5,'one',7);\n      INSERT INTO songs VALUES(6,'two',11);\n      SELECT DISTINCT artist \n      FROM (    \n       SELECT DISTINCT artist    \n       FROM songs      \n       WHERE songid IN (    \n        SELECT songid    \n        FROM songs    \n        WHERE LOWER(artist) = (    \n          -- This sub-query is indeterminate. Because there is no ORDER BY,\n          -- it may return 'one', 'two' or 'three'. Because of this, the\n\t  -- outermost parent query may correctly return any of 'one', 'two' \n          -- or 'three' as well.\n          SELECT DISTINCT LOWER(artist)    \n          FROM (      \n            -- This sub-query returns the table:\n            --\n            --     two      14\n            --     one      10\n            --     three    5\n            --\n            SELECT DISTINCT artist,sum(timesplayed) AS total      \n            FROM songs      \n            GROUP BY LOWER(artist)      \n            ORDER BY total DESC      \n            LIMIT 10    \n          )    \n          WHERE artist <> '' \n        )  \n       )       \n      )  \n      ORDER BY LOWER(artist) ASC;\n    }\n  } {two}\n}\n\n# Ticket #1370.  Do not overwrite small files (less than 1024 bytes)\n# when trying to open them as a database.\n#\nif {[permutation] == \"\"} {\n  do_test misc5-4.1 {\n    db close\n    forcedelete test.db\n    set fd [open test.db w]\n    puts $fd \"This is not really a database\"\n    close $fd\n    sqlite3 db test.db\n    catchsql {\n      CREATE TABLE t1(a,b,c);\n    }\n  } {1 {file is not a database}}\n}\n\n# Ticket #1371.  Allow floating point numbers of the form .N  or N.\n#\ndo_test misc5-5.1 {\n  execsql {SELECT .1 }\n} 0.1\ndo_test misc5-5.2 {\n  execsql {SELECT 2. }\n} 2.0\ndo_test misc5-5.3 {\n  execsql {SELECT 3.e0 }\n} 3.0\ndo_test misc5-5.4 {\n  execsql {SELECT .4e+1}\n} 4.0\n\n# Ticket #1582.  Ensure that an unknown table in a LIMIT clause applied to\n# a UNION ALL query causes an error, not a crash.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\nifcapable subquery&&compound {\n  do_test misc5-6.1 {\n    catchsql {\n      SELECT * FROM sqlite_master \n      UNION ALL \n      SELECT * FROM sqlite_master\n      LIMIT (SELECT count(*) FROM blah);\n    }\n  } {1 {no such table: blah}}\n  do_test misc5-6.2 {\n    execsql {\n      CREATE TABLE logs(msg TEXT, timestamp INTEGER, dbtime TEXT);\n    }\n    catchsql {\n      SELECT * FROM logs WHERE logs.oid >= (SELECT head FROM logs_base) \n      UNION ALL \n      SELECT * FROM logs \n      LIMIT (SELECT lmt FROM logs_base) ;\n    }\n  } {1 {no such table: logs_base}}\n}\n\n# Overflow the lemon parser stack by providing an overly complex\n# expression.  Make sure that the overflow is detected and reported.\n#\n# This test fails when building with -DYYSTACKDEPTH=0\n#\ndo_test misc5-7.1 {\n  execsql {CREATE TABLE t1(x)}\n  set sql \"INSERT INTO t1 VALUES(\"\n  set tail \"\"\n  for {set i 0} {$i<200} {incr i} {\n    append sql \"(1+\"\n    append tail \")\"\n  }\n  append sql 2$tail\n  catchsql $sql\n} {1 {parser stack overflow}}\n\n# Parser stack overflow is silently ignored when it occurs while parsing the\n# schema and PRAGMA writable_schema is turned on.\n#\ndo_test misc5-7.2 {\n  sqlite3 db2 :memory:\n  catchsql {\n    CREATE TABLE t1(x UNIQUE);\n    PRAGMA writable_schema=ON;\n    UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)';\n    BEGIN;\n    CREATE TABLE t2(y);\n    ROLLBACK;\n    DROP TABLE IF EXISTS D;\n  } db2\n} {0 {}}\ndb2 close\n  \n\n# Ticket #1911\n#\nifcapable compound {\n  do_test misc5-9.1 {\n    execsql {\n      SELECT name, type FROM sqlite_master WHERE name IS NULL\n      UNION\n      SELECT type, name FROM sqlite_master WHERE type IS NULL\n      ORDER BY 1, 2, 1, 2, 1, 2\n    }\n  } {}\n  do_test misc5-9.2 {\n    execsql {\n      SELECT name, type FROM sqlite_master WHERE name IS NULL\n      UNION\n      SELECT type, name FROM sqlite_master WHERE type IS NULL\n      ORDER BY 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2\n    }\n  } {}\n}\n\n# Ticket #1912.  Make the tokenizer require a space after a numeric\n# literal.\n#\ndo_test misc5-10.1 {\n  catchsql {\n    SELECT 123abc\n  }\n} {1 {unrecognized token: \"123abc\"}}\ndo_test misc5-10.2 {\n  catchsql {\n    SELECT 1*123.4e5ghi;\n  }\n} {1 {unrecognized token: \"123.4e5ghi\"}}\n\n\n# Additional integer encoding tests.\n#\ndo_test misc5-11.1 {\n  db eval {\n    CREATE TABLE t3(x);\n    INSERT INTO t3 VALUES(-18);\n    INSERT INTO t3 VALUES(-17);\n    INSERT INTO t3 VALUES(-16);\n    INSERT INTO t3 VALUES(-15);\n    INSERT INTO t3 VALUES(-14);\n    INSERT INTO t3 VALUES(-13);\n    INSERT INTO t3 VALUES(-12);\n    INSERT INTO t3 VALUES(-11);\n    INSERT INTO t3 VALUES(-10);\n    INSERT INTO t3 VALUES(-9);\n    INSERT INTO t3 VALUES(-8);\n    INSERT INTO t3 VALUES(-7);\n    INSERT INTO t3 VALUES(-6);\n    INSERT INTO t3 VALUES(-5);\n    INSERT INTO t3 VALUES(-4);\n    INSERT INTO t3 VALUES(-3);\n    INSERT INTO t3 VALUES(-2);\n    INSERT INTO t3 VALUES(-1);\n    INSERT INTO t3 VALUES(0);\n    INSERT INTO t3 VALUES(1);\n    INSERT INTO t3 VALUES(2);\n    INSERT INTO t3 VALUES(3);\n    INSERT INTO t3 VALUES(4);\n    INSERT INTO t3 VALUES(5);\n    INSERT INTO t3 VALUES(6);\n    INSERT INTO t3 VALUES(7);\n    INSERT INTO t3 VALUES(8);\n    INSERT INTO t3 VALUES(9);\n    INSERT INTO t3 VALUES(10);\n    INSERT INTO t3 VALUES(11);\n    INSERT INTO t3 VALUES(12);\n    INSERT INTO t3 VALUES(13);\n    INSERT INTO t3 VALUES(14);\n    INSERT INTO t3 VALUES(15);\n    INSERT INTO t3 VALUES(16);\n    INSERT INTO t3 VALUES(17);\n    INSERT INTO t3 VALUES(18);\n    INSERT INTO t3 VALUES(30);\n    INSERT INTO t3 VALUES(31);\n    INSERT INTO t3 VALUES(32);\n    INSERT INTO t3 VALUES(33);\n    INSERT INTO t3 VALUES(34);\n    INSERT INTO t3 VALUES(-30);\n    INSERT INTO t3 VALUES(-31);\n    INSERT INTO t3 VALUES(-32);\n    INSERT INTO t3 VALUES(-33);\n    INSERT INTO t3 VALUES(-34);\n    INSERT INTO t3 VALUES(62);\n    INSERT INTO t3 VALUES(63);\n    INSERT INTO t3 VALUES(64);\n    INSERT INTO t3 VALUES(65);\n    INSERT INTO t3 VALUES(66);\n    INSERT INTO t3 VALUES(-62);\n    INSERT INTO t3 VALUES(-63);\n    INSERT INTO t3 VALUES(-64);\n    INSERT INTO t3 VALUES(-65);\n    INSERT INTO t3 VALUES(-66);\n    INSERT INTO t3 VALUES(126);\n    INSERT INTO t3 VALUES(127);\n    INSERT INTO t3 VALUES(128);\n    INSERT INTO t3 VALUES(129);\n    INSERT INTO t3 VALUES(130);\n    INSERT INTO t3 VALUES(-126);\n    INSERT INTO t3 VALUES(-127);\n    INSERT INTO t3 VALUES(-128);\n    INSERT INTO t3 VALUES(-129);\n    INSERT INTO t3 VALUES(-130);\n    INSERT INTO t3 VALUES(254);\n    INSERT INTO t3 VALUES(255);\n    INSERT INTO t3 VALUES(256);\n    INSERT INTO t3 VALUES(257);\n    INSERT INTO t3 VALUES(258);\n    INSERT INTO t3 VALUES(-254);\n    INSERT INTO t3 VALUES(-255);\n    INSERT INTO t3 VALUES(-256);\n    INSERT INTO t3 VALUES(-257);\n    INSERT INTO t3 VALUES(-258);\n    INSERT INTO t3 VALUES(510);\n    INSERT INTO t3 VALUES(511);\n    INSERT INTO t3 VALUES(512);\n    INSERT INTO t3 VALUES(513);\n    INSERT INTO t3 VALUES(514);\n    INSERT INTO t3 VALUES(-510);\n    INSERT INTO t3 VALUES(-511);\n    INSERT INTO t3 VALUES(-512);\n    INSERT INTO t3 VALUES(-513);\n    INSERT INTO t3 VALUES(-514);\n    INSERT INTO t3 VALUES(1022);\n    INSERT INTO t3 VALUES(1023);\n    INSERT INTO t3 VALUES(1024);\n    INSERT INTO t3 VALUES(1025);\n    INSERT INTO t3 VALUES(1026);\n    INSERT INTO t3 VALUES(-1022);\n    INSERT INTO t3 VALUES(-1023);\n    INSERT INTO t3 VALUES(-1024);\n    INSERT INTO t3 VALUES(-1025);\n    INSERT INTO t3 VALUES(-1026);\n    INSERT INTO t3 VALUES(2046);\n    INSERT INTO t3 VALUES(2047);\n    INSERT INTO t3 VALUES(2048);\n    INSERT INTO t3 VALUES(2049);\n    INSERT INTO t3 VALUES(2050);\n    INSERT INTO t3 VALUES(-2046);\n    INSERT INTO t3 VALUES(-2047);\n    INSERT INTO t3 VALUES(-2048);\n    INSERT INTO t3 VALUES(-2049);\n    INSERT INTO t3 VALUES(-2050);\n    INSERT INTO t3 VALUES(4094);\n    INSERT INTO t3 VALUES(4095);\n    INSERT INTO t3 VALUES(4096);\n    INSERT INTO t3 VALUES(4097);\n    INSERT INTO t3 VALUES(4098);\n    INSERT INTO t3 VALUES(-4094);\n    INSERT INTO t3 VALUES(-4095);\n    INSERT INTO t3 VALUES(-4096);\n    INSERT INTO t3 VALUES(-4097);\n    INSERT INTO t3 VALUES(-4098);\n    INSERT INTO t3 VALUES(8190);\n    INSERT INTO t3 VALUES(8191);\n    INSERT INTO t3 VALUES(8192);\n    INSERT INTO t3 VALUES(8193);\n    INSERT INTO t3 VALUES(8194);\n    INSERT INTO t3 VALUES(-8190);\n    INSERT INTO t3 VALUES(-8191);\n    INSERT INTO t3 VALUES(-8192);\n    INSERT INTO t3 VALUES(-8193);\n    INSERT INTO t3 VALUES(-8194);\n    INSERT INTO t3 VALUES(16382);\n    INSERT INTO t3 VALUES(16383);\n    INSERT INTO t3 VALUES(16384);\n    INSERT INTO t3 VALUES(16385);\n    INSERT INTO t3 VALUES(16386);\n    INSERT INTO t3 VALUES(-16382);\n    INSERT INTO t3 VALUES(-16383);\n    INSERT INTO t3 VALUES(-16384);\n    INSERT INTO t3 VALUES(-16385);\n    INSERT INTO t3 VALUES(-16386);\n    INSERT INTO t3 VALUES(32766);\n    INSERT INTO t3 VALUES(32767);\n    INSERT INTO t3 VALUES(32768);\n    INSERT INTO t3 VALUES(32769);\n    INSERT INTO t3 VALUES(32770);\n    INSERT INTO t3 VALUES(-32766);\n    INSERT INTO t3 VALUES(-32767);\n    INSERT INTO t3 VALUES(-32768);\n    INSERT INTO t3 VALUES(-32769);\n    INSERT INTO t3 VALUES(-32770);\n    INSERT INTO t3 VALUES(65534);\n    INSERT INTO t3 VALUES(65535);\n    INSERT INTO t3 VALUES(65536);\n    INSERT INTO t3 VALUES(65537);\n    INSERT INTO t3 VALUES(65538);\n    INSERT INTO t3 VALUES(-65534);\n    INSERT INTO t3 VALUES(-65535);\n    INSERT INTO t3 VALUES(-65536);\n    INSERT INTO t3 VALUES(-65537);\n    INSERT INTO t3 VALUES(-65538);\n    INSERT INTO t3 VALUES(131070);\n    INSERT INTO t3 VALUES(131071);\n    INSERT INTO t3 VALUES(131072);\n    INSERT INTO t3 VALUES(131073);\n    INSERT INTO t3 VALUES(131074);\n    INSERT INTO t3 VALUES(-131070);\n    INSERT INTO t3 VALUES(-131071);\n    INSERT INTO t3 VALUES(-131072);\n    INSERT INTO t3 VALUES(-131073);\n    INSERT INTO t3 VALUES(-131074);\n    INSERT INTO t3 VALUES(262142);\n    INSERT INTO t3 VALUES(262143);\n    INSERT INTO t3 VALUES(262144);\n    INSERT INTO t3 VALUES(262145);\n    INSERT INTO t3 VALUES(262146);\n    INSERT INTO t3 VALUES(-262142);\n    INSERT INTO t3 VALUES(-262143);\n    INSERT INTO t3 VALUES(-262144);\n    INSERT INTO t3 VALUES(-262145);\n    INSERT INTO t3 VALUES(-262146);\n    INSERT INTO t3 VALUES(524286);\n    INSERT INTO t3 VALUES(524287);\n    INSERT INTO t3 VALUES(524288);\n    INSERT INTO t3 VALUES(524289);\n    INSERT INTO t3 VALUES(524290);\n    INSERT INTO t3 VALUES(-524286);\n    INSERT INTO t3 VALUES(-524287);\n    INSERT INTO t3 VALUES(-524288);\n    INSERT INTO t3 VALUES(-524289);\n    INSERT INTO t3 VALUES(-524290);\n    INSERT INTO t3 VALUES(1048574);\n    INSERT INTO t3 VALUES(1048575);\n    INSERT INTO t3 VALUES(1048576);\n    INSERT INTO t3 VALUES(1048577);\n    INSERT INTO t3 VALUES(1048578);\n    INSERT INTO t3 VALUES(-1048574);\n    INSERT INTO t3 VALUES(-1048575);\n    INSERT INTO t3 VALUES(-1048576);\n    INSERT INTO t3 VALUES(-1048577);\n    INSERT INTO t3 VALUES(-1048578);\n    INSERT INTO t3 VALUES(2097150);\n    INSERT INTO t3 VALUES(2097151);\n    INSERT INTO t3 VALUES(2097152);\n    INSERT INTO t3 VALUES(2097153);\n    INSERT INTO t3 VALUES(2097154);\n    INSERT INTO t3 VALUES(-2097150);\n    INSERT INTO t3 VALUES(-2097151);\n    INSERT INTO t3 VALUES(-2097152);\n    INSERT INTO t3 VALUES(-2097153);\n    INSERT INTO t3 VALUES(-2097154);\n    INSERT INTO t3 VALUES(4194302);\n    INSERT INTO t3 VALUES(4194303);\n    INSERT INTO t3 VALUES(4194304);\n    INSERT INTO t3 VALUES(4194305);\n    INSERT INTO t3 VALUES(4194306);\n    INSERT INTO t3 VALUES(-4194302);\n    INSERT INTO t3 VALUES(-4194303);\n    INSERT INTO t3 VALUES(-4194304);\n    INSERT INTO t3 VALUES(-4194305);\n    INSERT INTO t3 VALUES(-4194306);\n    INSERT INTO t3 VALUES(8388606);\n    INSERT INTO t3 VALUES(8388607);\n    INSERT INTO t3 VALUES(8388608);\n    INSERT INTO t3 VALUES(8388609);\n    INSERT INTO t3 VALUES(8388610);\n    INSERT INTO t3 VALUES(-8388606);\n    INSERT INTO t3 VALUES(-8388607);\n    INSERT INTO t3 VALUES(-8388608);\n    INSERT INTO t3 VALUES(-8388609);\n    INSERT INTO t3 VALUES(-8388610);\n    INSERT INTO t3 VALUES(16777214);\n    INSERT INTO t3 VALUES(16777215);\n    INSERT INTO t3 VALUES(16777216);\n    INSERT INTO t3 VALUES(16777217);\n    INSERT INTO t3 VALUES(16777218);\n    INSERT INTO t3 VALUES(-16777214);\n    INSERT INTO t3 VALUES(-16777215);\n    INSERT INTO t3 VALUES(-16777216);\n    INSERT INTO t3 VALUES(-16777217);\n    INSERT INTO t3 VALUES(-16777218);\n    INSERT INTO t3 VALUES(33554430);\n    INSERT INTO t3 VALUES(33554431);\n    INSERT INTO t3 VALUES(33554432);\n    INSERT INTO t3 VALUES(33554433);\n    INSERT INTO t3 VALUES(33554434);\n    INSERT INTO t3 VALUES(-33554430);\n    INSERT INTO t3 VALUES(-33554431);\n    INSERT INTO t3 VALUES(-33554432);\n    INSERT INTO t3 VALUES(-33554433);\n    INSERT INTO t3 VALUES(-33554434);\n    INSERT INTO t3 VALUES(67108862);\n    INSERT INTO t3 VALUES(67108863);\n    INSERT INTO t3 VALUES(67108864);\n    INSERT INTO t3 VALUES(67108865);\n    INSERT INTO t3 VALUES(67108866);\n    INSERT INTO t3 VALUES(-67108862);\n    INSERT INTO t3 VALUES(-67108863);\n    INSERT INTO t3 VALUES(-67108864);\n    INSERT INTO t3 VALUES(-67108865);\n    INSERT INTO t3 VALUES(-67108866);\n    INSERT INTO t3 VALUES(134217726);\n    INSERT INTO t3 VALUES(134217727);\n    INSERT INTO t3 VALUES(134217728);\n    INSERT INTO t3 VALUES(134217729);\n    INSERT INTO t3 VALUES(134217730);\n    INSERT INTO t3 VALUES(-134217726);\n    INSERT INTO t3 VALUES(-134217727);\n    INSERT INTO t3 VALUES(-134217728);\n    INSERT INTO t3 VALUES(-134217729);\n    INSERT INTO t3 VALUES(-134217730);\n    INSERT INTO t3 VALUES(268435454);\n    INSERT INTO t3 VALUES(268435455);\n    INSERT INTO t3 VALUES(268435456);\n    INSERT INTO t3 VALUES(268435457);\n    INSERT INTO t3 VALUES(268435458);\n    INSERT INTO t3 VALUES(-268435454);\n    INSERT INTO t3 VALUES(-268435455);\n    INSERT INTO t3 VALUES(-268435456);\n    INSERT INTO t3 VALUES(-268435457);\n    INSERT INTO t3 VALUES(-268435458);\n    INSERT INTO t3 VALUES(536870910);\n    INSERT INTO t3 VALUES(536870911);\n    INSERT INTO t3 VALUES(536870912);\n    INSERT INTO t3 VALUES(536870913);\n    INSERT INTO t3 VALUES(536870914);\n    INSERT INTO t3 VALUES(-536870910);\n    INSERT INTO t3 VALUES(-536870911);\n    INSERT INTO t3 VALUES(-536870912);\n    INSERT INTO t3 VALUES(-536870913);\n    INSERT INTO t3 VALUES(-536870914);\n    INSERT INTO t3 VALUES(1073741822);\n    INSERT INTO t3 VALUES(1073741823);\n    INSERT INTO t3 VALUES(1073741824);\n    INSERT INTO t3 VALUES(1073741825);\n    INSERT INTO t3 VALUES(1073741826);\n    INSERT INTO t3 VALUES(-1073741822);\n    INSERT INTO t3 VALUES(-1073741823);\n    INSERT INTO t3 VALUES(-1073741824);\n    INSERT INTO t3 VALUES(-1073741825);\n    INSERT INTO t3 VALUES(-1073741826);\n    INSERT INTO t3 VALUES(2147483646);\n    INSERT INTO t3 VALUES(2147483647);\n    INSERT INTO t3 VALUES(2147483648);\n    INSERT INTO t3 VALUES(2147483649);\n    INSERT INTO t3 VALUES(2147483650);\n    INSERT INTO t3 VALUES(-2147483646);\n    INSERT INTO t3 VALUES(-2147483647);\n    INSERT INTO t3 VALUES(-2147483648);\n    INSERT INTO t3 VALUES(-2147483649);\n    INSERT INTO t3 VALUES(-2147483650);\n    INSERT INTO t3 VALUES(4294967294);\n    INSERT INTO t3 VALUES(4294967295);\n    INSERT INTO t3 VALUES(4294967296);\n    INSERT INTO t3 VALUES(4294967297);\n    INSERT INTO t3 VALUES(4294967298);\n    INSERT INTO t3 VALUES(-4294967294);\n    INSERT INTO t3 VALUES(-4294967295);\n    INSERT INTO t3 VALUES(-4294967296);\n    INSERT INTO t3 VALUES(-4294967297);\n    INSERT INTO t3 VALUES(-4294967298);\n    INSERT INTO t3 VALUES(8589934590);\n    INSERT INTO t3 VALUES(8589934591);\n    INSERT INTO t3 VALUES(8589934592);\n    INSERT INTO t3 VALUES(8589934593);\n    INSERT INTO t3 VALUES(8589934594);\n    INSERT INTO t3 VALUES(-8589934590);\n    INSERT INTO t3 VALUES(-8589934591);\n    INSERT INTO t3 VALUES(-8589934592);\n    INSERT INTO t3 VALUES(-8589934593);\n    INSERT INTO t3 VALUES(-8589934594);\n    INSERT INTO t3 VALUES(17179869182);\n    INSERT INTO t3 VALUES(17179869183);\n    INSERT INTO t3 VALUES(17179869184);\n    INSERT INTO t3 VALUES(17179869185);\n    INSERT INTO t3 VALUES(17179869186);\n    INSERT INTO t3 VALUES(-17179869182);\n    INSERT INTO t3 VALUES(-17179869183);\n    INSERT INTO t3 VALUES(-17179869184);\n    INSERT INTO t3 VALUES(-17179869185);\n    INSERT INTO t3 VALUES(-17179869186);\n    INSERT INTO t3 VALUES(34359738366);\n    INSERT INTO t3 VALUES(34359738367);\n    INSERT INTO t3 VALUES(34359738368);\n    INSERT INTO t3 VALUES(34359738369);\n    INSERT INTO t3 VALUES(34359738370);\n    INSERT INTO t3 VALUES(-34359738366);\n    INSERT INTO t3 VALUES(-34359738367);\n    INSERT INTO t3 VALUES(-34359738368);\n    INSERT INTO t3 VALUES(-34359738369);\n    INSERT INTO t3 VALUES(-34359738370);\n    INSERT INTO t3 VALUES(68719476734);\n    INSERT INTO t3 VALUES(68719476735);\n    INSERT INTO t3 VALUES(68719476736);\n    INSERT INTO t3 VALUES(68719476737);\n    INSERT INTO t3 VALUES(68719476738);\n    INSERT INTO t3 VALUES(-68719476734);\n    INSERT INTO t3 VALUES(-68719476735);\n    INSERT INTO t3 VALUES(-68719476736);\n    INSERT INTO t3 VALUES(-68719476737);\n    INSERT INTO t3 VALUES(-68719476738);\n    INSERT INTO t3 VALUES(137438953470);\n    INSERT INTO t3 VALUES(137438953471);\n    INSERT INTO t3 VALUES(137438953472);\n    INSERT INTO t3 VALUES(137438953473);\n    INSERT INTO t3 VALUES(137438953474);\n    INSERT INTO t3 VALUES(-137438953470);\n    INSERT INTO t3 VALUES(-137438953471);\n    INSERT INTO t3 VALUES(-137438953472);\n    INSERT INTO t3 VALUES(-137438953473);\n    INSERT INTO t3 VALUES(-137438953474);\n    INSERT INTO t3 VALUES(274877906942);\n    INSERT INTO t3 VALUES(274877906943);\n    INSERT INTO t3 VALUES(274877906944);\n    INSERT INTO t3 VALUES(274877906945);\n    INSERT INTO t3 VALUES(274877906946);\n    INSERT INTO t3 VALUES(-274877906942);\n    INSERT INTO t3 VALUES(-274877906943);\n    INSERT INTO t3 VALUES(-274877906944);\n    INSERT INTO t3 VALUES(-274877906945);\n    INSERT INTO t3 VALUES(-274877906946);\n    INSERT INTO t3 VALUES(549755813886);\n    INSERT INTO t3 VALUES(549755813887);\n    INSERT INTO t3 VALUES(549755813888);\n    INSERT INTO t3 VALUES(549755813889);\n    INSERT INTO t3 VALUES(549755813890);\n    INSERT INTO t3 VALUES(-549755813886);\n    INSERT INTO t3 VALUES(-549755813887);\n    INSERT INTO t3 VALUES(-549755813888);\n    INSERT INTO t3 VALUES(-549755813889);\n    INSERT INTO t3 VALUES(-549755813890);\n    INSERT INTO t3 VALUES(1099511627774);\n    INSERT INTO t3 VALUES(1099511627775);\n    INSERT INTO t3 VALUES(1099511627776);\n    INSERT INTO t3 VALUES(1099511627777);\n    INSERT INTO t3 VALUES(1099511627778);\n    INSERT INTO t3 VALUES(-1099511627774);\n    INSERT INTO t3 VALUES(-1099511627775);\n    INSERT INTO t3 VALUES(-1099511627776);\n    INSERT INTO t3 VALUES(-1099511627777);\n    INSERT INTO t3 VALUES(-1099511627778);\n    INSERT INTO t3 VALUES(2199023255550);\n    INSERT INTO t3 VALUES(2199023255551);\n    INSERT INTO t3 VALUES(2199023255552);\n    INSERT INTO t3 VALUES(2199023255553);\n    INSERT INTO t3 VALUES(2199023255554);\n    INSERT INTO t3 VALUES(-2199023255550);\n    INSERT INTO t3 VALUES(-2199023255551);\n    INSERT INTO t3 VALUES(-2199023255552);\n    INSERT INTO t3 VALUES(-2199023255553);\n    INSERT INTO t3 VALUES(-2199023255554);\n    INSERT INTO t3 VALUES(4398046511102);\n    INSERT INTO t3 VALUES(4398046511103);\n    INSERT INTO t3 VALUES(4398046511104);\n    INSERT INTO t3 VALUES(4398046511105);\n    INSERT INTO t3 VALUES(4398046511106);\n    INSERT INTO t3 VALUES(-4398046511102);\n    INSERT INTO t3 VALUES(-4398046511103);\n    INSERT INTO t3 VALUES(-4398046511104);\n    INSERT INTO t3 VALUES(-4398046511105);\n    INSERT INTO t3 VALUES(-4398046511106);\n    INSERT INTO t3 VALUES(8796093022206);\n    INSERT INTO t3 VALUES(8796093022207);\n    INSERT INTO t3 VALUES(8796093022208);\n    INSERT INTO t3 VALUES(8796093022209);\n    INSERT INTO t3 VALUES(8796093022210);\n    INSERT INTO t3 VALUES(-8796093022206);\n    INSERT INTO t3 VALUES(-8796093022207);\n    INSERT INTO t3 VALUES(-8796093022208);\n    INSERT INTO t3 VALUES(-8796093022209);\n    INSERT INTO t3 VALUES(-8796093022210);\n    INSERT INTO t3 VALUES(17592186044414);\n    INSERT INTO t3 VALUES(17592186044415);\n    INSERT INTO t3 VALUES(17592186044416);\n    INSERT INTO t3 VALUES(17592186044417);\n    INSERT INTO t3 VALUES(17592186044418);\n    INSERT INTO t3 VALUES(-17592186044414);\n    INSERT INTO t3 VALUES(-17592186044415);\n    INSERT INTO t3 VALUES(-17592186044416);\n    INSERT INTO t3 VALUES(-17592186044417);\n    INSERT INTO t3 VALUES(-17592186044418);\n    INSERT INTO t3 VALUES(35184372088830);\n    INSERT INTO t3 VALUES(35184372088831);\n    INSERT INTO t3 VALUES(35184372088832);\n    INSERT INTO t3 VALUES(35184372088833);\n    INSERT INTO t3 VALUES(35184372088834);\n    INSERT INTO t3 VALUES(-35184372088830);\n    INSERT INTO t3 VALUES(-35184372088831);\n    INSERT INTO t3 VALUES(-35184372088832);\n    INSERT INTO t3 VALUES(-35184372088833);\n    INSERT INTO t3 VALUES(-35184372088834);\n    INSERT INTO t3 VALUES(70368744177662);\n    INSERT INTO t3 VALUES(70368744177663);\n    INSERT INTO t3 VALUES(70368744177664);\n    INSERT INTO t3 VALUES(70368744177665);\n    INSERT INTO t3 VALUES(70368744177666);\n    INSERT INTO t3 VALUES(-70368744177662);\n    INSERT INTO t3 VALUES(-70368744177663);\n    INSERT INTO t3 VALUES(-70368744177664);\n    INSERT INTO t3 VALUES(-70368744177665);\n    INSERT INTO t3 VALUES(-70368744177666);\n    INSERT INTO t3 VALUES(140737488355326);\n    INSERT INTO t3 VALUES(140737488355327);\n    INSERT INTO t3 VALUES(140737488355328);\n    INSERT INTO t3 VALUES(140737488355329);\n    INSERT INTO t3 VALUES(140737488355330);\n    INSERT INTO t3 VALUES(-140737488355326);\n    INSERT INTO t3 VALUES(-140737488355327);\n    INSERT INTO t3 VALUES(-140737488355328);\n    INSERT INTO t3 VALUES(-140737488355329);\n    INSERT INTO t3 VALUES(-140737488355330);\n    INSERT INTO t3 VALUES(281474976710654);\n    INSERT INTO t3 VALUES(281474976710655);\n    INSERT INTO t3 VALUES(281474976710656);\n    INSERT INTO t3 VALUES(281474976710657);\n    INSERT INTO t3 VALUES(281474976710658);\n    INSERT INTO t3 VALUES(-281474976710654);\n    INSERT INTO t3 VALUES(-281474976710655);\n    INSERT INTO t3 VALUES(-281474976710656);\n    INSERT INTO t3 VALUES(-281474976710657);\n    INSERT INTO t3 VALUES(-281474976710658);\n    INSERT INTO t3 VALUES(562949953421310);\n    INSERT INTO t3 VALUES(562949953421311);\n    INSERT INTO t3 VALUES(562949953421312);\n    INSERT INTO t3 VALUES(562949953421313);\n    INSERT INTO t3 VALUES(562949953421314);\n    INSERT INTO t3 VALUES(-562949953421310);\n    INSERT INTO t3 VALUES(-562949953421311);\n    INSERT INTO t3 VALUES(-562949953421312);\n    INSERT INTO t3 VALUES(-562949953421313);\n    INSERT INTO t3 VALUES(-562949953421314);\n    INSERT INTO t3 VALUES(1125899906842622);\n    INSERT INTO t3 VALUES(1125899906842623);\n    INSERT INTO t3 VALUES(1125899906842624);\n    INSERT INTO t3 VALUES(1125899906842625);\n    INSERT INTO t3 VALUES(1125899906842626);\n    INSERT INTO t3 VALUES(-1125899906842622);\n    INSERT INTO t3 VALUES(-1125899906842623);\n    INSERT INTO t3 VALUES(-1125899906842624);\n    INSERT INTO t3 VALUES(-1125899906842625);\n    INSERT INTO t3 VALUES(-1125899906842626);\n    INSERT INTO t3 VALUES(2251799813685246);\n    INSERT INTO t3 VALUES(2251799813685247);\n    INSERT INTO t3 VALUES(2251799813685248);\n    INSERT INTO t3 VALUES(2251799813685249);\n    INSERT INTO t3 VALUES(2251799813685250);\n    INSERT INTO t3 VALUES(-2251799813685246);\n    INSERT INTO t3 VALUES(-2251799813685247);\n    INSERT INTO t3 VALUES(-2251799813685248);\n    INSERT INTO t3 VALUES(-2251799813685249);\n    INSERT INTO t3 VALUES(-2251799813685250);\n    INSERT INTO t3 VALUES(4503599627370494);\n    INSERT INTO t3 VALUES(4503599627370495);\n    INSERT INTO t3 VALUES(4503599627370496);\n    INSERT INTO t3 VALUES(4503599627370497);\n    INSERT INTO t3 VALUES(4503599627370498);\n    INSERT INTO t3 VALUES(-4503599627370494);\n    INSERT INTO t3 VALUES(-4503599627370495);\n    INSERT INTO t3 VALUES(-4503599627370496);\n    INSERT INTO t3 VALUES(-4503599627370497);\n    INSERT INTO t3 VALUES(-4503599627370498);\n    INSERT INTO t3 VALUES(9007199254740990);\n    INSERT INTO t3 VALUES(9007199254740991);\n    INSERT INTO t3 VALUES(9007199254740992);\n    INSERT INTO t3 VALUES(9007199254740993);\n    INSERT INTO t3 VALUES(9007199254740994);\n    INSERT INTO t3 VALUES(-9007199254740990);\n    INSERT INTO t3 VALUES(-9007199254740991);\n    INSERT INTO t3 VALUES(-9007199254740992);\n    INSERT INTO t3 VALUES(-9007199254740993);\n    INSERT INTO t3 VALUES(-9007199254740994);\n    INSERT INTO t3 VALUES(18014398509481982);\n    INSERT INTO t3 VALUES(18014398509481983);\n    INSERT INTO t3 VALUES(18014398509481984);\n    INSERT INTO t3 VALUES(18014398509481985);\n    INSERT INTO t3 VALUES(18014398509481986);\n    INSERT INTO t3 VALUES(-18014398509481982);\n    INSERT INTO t3 VALUES(-18014398509481983);\n    INSERT INTO t3 VALUES(-18014398509481984);\n    INSERT INTO t3 VALUES(-18014398509481985);\n    INSERT INTO t3 VALUES(-18014398509481986);\n    INSERT INTO t3 VALUES(36028797018963966);\n    INSERT INTO t3 VALUES(36028797018963967);\n    INSERT INTO t3 VALUES(36028797018963968);\n    INSERT INTO t3 VALUES(36028797018963969);\n    INSERT INTO t3 VALUES(36028797018963970);\n    INSERT INTO t3 VALUES(-36028797018963966);\n    INSERT INTO t3 VALUES(-36028797018963967);\n    INSERT INTO t3 VALUES(-36028797018963968);\n    INSERT INTO t3 VALUES(-36028797018963969);\n    INSERT INTO t3 VALUES(-36028797018963970);\n    INSERT INTO t3 VALUES(72057594037927934);\n    INSERT INTO t3 VALUES(72057594037927935);\n    INSERT INTO t3 VALUES(72057594037927936);\n    INSERT INTO t3 VALUES(72057594037927937);\n    INSERT INTO t3 VALUES(72057594037927938);\n    INSERT INTO t3 VALUES(-72057594037927934);\n    INSERT INTO t3 VALUES(-72057594037927935);\n    INSERT INTO t3 VALUES(-72057594037927936);\n    INSERT INTO t3 VALUES(-72057594037927937);\n    INSERT INTO t3 VALUES(-72057594037927938);\n    INSERT INTO t3 VALUES(144115188075855870);\n    INSERT INTO t3 VALUES(144115188075855871);\n    INSERT INTO t3 VALUES(144115188075855872);\n    INSERT INTO t3 VALUES(144115188075855873);\n    INSERT INTO t3 VALUES(144115188075855874);\n    INSERT INTO t3 VALUES(-144115188075855870);\n    INSERT INTO t3 VALUES(-144115188075855871);\n    INSERT INTO t3 VALUES(-144115188075855872);\n    INSERT INTO t3 VALUES(-144115188075855873);\n    INSERT INTO t3 VALUES(-144115188075855874);\n    INSERT INTO t3 VALUES(288230376151711742);\n    INSERT INTO t3 VALUES(288230376151711743);\n    INSERT INTO t3 VALUES(288230376151711744);\n    INSERT INTO t3 VALUES(288230376151711745);\n    INSERT INTO t3 VALUES(288230376151711746);\n    INSERT INTO t3 VALUES(-288230376151711742);\n    INSERT INTO t3 VALUES(-288230376151711743);\n    INSERT INTO t3 VALUES(-288230376151711744);\n    INSERT INTO t3 VALUES(-288230376151711745);\n    INSERT INTO t3 VALUES(-288230376151711746);\n    INSERT INTO t3 VALUES(576460752303423486);\n    INSERT INTO t3 VALUES(576460752303423487);\n    INSERT INTO t3 VALUES(576460752303423488);\n    INSERT INTO t3 VALUES(576460752303423489);\n    INSERT INTO t3 VALUES(576460752303423490);\n    INSERT INTO t3 VALUES(-576460752303423486);\n    INSERT INTO t3 VALUES(-576460752303423487);\n    INSERT INTO t3 VALUES(-576460752303423488);\n    INSERT INTO t3 VALUES(-576460752303423489);\n    INSERT INTO t3 VALUES(-576460752303423490);\n    INSERT INTO t3 VALUES(1152921504606846974);\n    INSERT INTO t3 VALUES(1152921504606846975);\n    INSERT INTO t3 VALUES(1152921504606846976);\n    INSERT INTO t3 VALUES(1152921504606846977);\n    INSERT INTO t3 VALUES(1152921504606846978);\n    INSERT INTO t3 VALUES(-1152921504606846974);\n    INSERT INTO t3 VALUES(-1152921504606846975);\n    INSERT INTO t3 VALUES(-1152921504606846976);\n    INSERT INTO t3 VALUES(-1152921504606846977);\n    INSERT INTO t3 VALUES(-1152921504606846978);\n    INSERT INTO t3 VALUES(2305843009213693950);\n    INSERT INTO t3 VALUES(2305843009213693951);\n    INSERT INTO t3 VALUES(2305843009213693952);\n    INSERT INTO t3 VALUES(2305843009213693953);\n    INSERT INTO t3 VALUES(2305843009213693954);\n    INSERT INTO t3 VALUES(-2305843009213693950);\n    INSERT INTO t3 VALUES(-2305843009213693951);\n    INSERT INTO t3 VALUES(-2305843009213693952);\n    INSERT INTO t3 VALUES(-2305843009213693953);\n    INSERT INTO t3 VALUES(-2305843009213693954);\n    INSERT INTO t3 VALUES(4611686018427387902);\n    INSERT INTO t3 VALUES(4611686018427387903);\n    INSERT INTO t3 VALUES(4611686018427387904);\n    INSERT INTO t3 VALUES(4611686018427387905);\n    INSERT INTO t3 VALUES(4611686018427387906);\n    INSERT INTO t3 VALUES(-4611686018427387902);\n    INSERT INTO t3 VALUES(-4611686018427387903);\n    INSERT INTO t3 VALUES(-4611686018427387904);\n    INSERT INTO t3 VALUES(-4611686018427387905);\n    INSERT INTO t3 VALUES(-4611686018427387906);\n    INSERT INTO t3 VALUES(9223372036854775806);\n    INSERT INTO t3 VALUES(9223372036854775807);\n    INSERT INTO t3 VALUES(-9223372036854775806);\n    INSERT INTO t3 VALUES(-9223372036854775807);\n    INSERT INTO t3 VALUES(-9223372036854775808);\n    SELECT x FROM t3 ORDER BY x;\n  }\n} {-9223372036854775808\\\n-9223372036854775807\\\n-9223372036854775806\\\n-4611686018427387906\\\n-4611686018427387905\\\n-4611686018427387904\\\n-4611686018427387903\\\n-4611686018427387902\\\n-2305843009213693954\\\n-2305843009213693953\\\n-2305843009213693952\\\n-2305843009213693951\\\n-2305843009213693950\\\n-1152921504606846978\\\n-1152921504606846977\\\n-1152921504606846976\\\n-1152921504606846975\\\n-1152921504606846974\\\n-576460752303423490\\\n-576460752303423489\\\n-576460752303423488\\\n-576460752303423487\\\n-576460752303423486\\\n-288230376151711746\\\n-288230376151711745\\\n-288230376151711744\\\n-288230376151711743\\\n-288230376151711742\\\n-144115188075855874\\\n-144115188075855873\\\n-144115188075855872\\\n-144115188075855871\\\n-144115188075855870\\\n-72057594037927938\\\n-72057594037927937\\\n-72057594037927936\\\n-72057594037927935\\\n-72057594037927934\\\n-36028797018963970\\\n-36028797018963969\\\n-36028797018963968\\\n-36028797018963967\\\n-36028797018963966\\\n-18014398509481986\\\n-18014398509481985\\\n-18014398509481984\\\n-18014398509481983\\\n-18014398509481982\\\n-9007199254740994\\\n-9007199254740993\\\n-9007199254740992\\\n-9007199254740991\\\n-9007199254740990\\\n-4503599627370498\\\n-4503599627370497\\\n-4503599627370496\\\n-4503599627370495\\\n-4503599627370494\\\n-2251799813685250\\\n-2251799813685249\\\n-2251799813685248\\\n-2251799813685247\\\n-2251799813685246\\\n-1125899906842626\\\n-1125899906842625\\\n-1125899906842624\\\n-1125899906842623\\\n-1125899906842622\\\n-562949953421314\\\n-562949953421313\\\n-562949953421312\\\n-562949953421311\\\n-562949953421310\\\n-281474976710658\\\n-281474976710657\\\n-281474976710656\\\n-281474976710655\\\n-281474976710654\\\n-140737488355330\\\n-140737488355329\\\n-140737488355328\\\n-140737488355327\\\n-140737488355326\\\n-70368744177666\\\n-70368744177665\\\n-70368744177664\\\n-70368744177663\\\n-70368744177662\\\n-35184372088834\\\n-35184372088833\\\n-35184372088832\\\n-35184372088831\\\n-35184372088830\\\n-17592186044418\\\n-17592186044417\\\n-17592186044416\\\n-17592186044415\\\n-17592186044414\\\n-8796093022210\\\n-8796093022209\\\n-8796093022208\\\n-8796093022207\\\n-8796093022206\\\n-4398046511106\\\n-4398046511105\\\n-4398046511104\\\n-4398046511103\\\n-4398046511102\\\n-2199023255554\\\n-2199023255553\\\n-2199023255552\\\n-2199023255551\\\n-2199023255550\\\n-1099511627778\\\n-1099511627777\\\n-1099511627776\\\n-1099511627775\\\n-1099511627774\\\n-549755813890\\\n-549755813889\\\n-549755813888\\\n-549755813887\\\n-549755813886\\\n-274877906946\\\n-274877906945\\\n-274877906944\\\n-274877906943\\\n-274877906942\\\n-137438953474\\\n-137438953473\\\n-137438953472\\\n-137438953471\\\n-137438953470\\\n-68719476738\\\n-68719476737\\\n-68719476736\\\n-68719476735\\\n-68719476734\\\n-34359738370\\\n-34359738369\\\n-34359738368\\\n-34359738367\\\n-34359738366\\\n-17179869186\\\n-17179869185\\\n-17179869184\\\n-17179869183\\\n-17179869182\\\n-8589934594\\\n-8589934593\\\n-8589934592\\\n-8589934591\\\n-8589934590\\\n-4294967298\\\n-4294967297\\\n-4294967296\\\n-4294967295\\\n-4294967294\\\n-2147483650\\\n-2147483649\\\n-2147483648\\\n-2147483647\\\n-2147483646\\\n-1073741826\\\n-1073741825\\\n-1073741824\\\n-1073741823\\\n-1073741822\\\n-536870914\\\n-536870913\\\n-536870912\\\n-536870911\\\n-536870910\\\n-268435458\\\n-268435457\\\n-268435456\\\n-268435455\\\n-268435454\\\n-134217730\\\n-134217729\\\n-134217728\\\n-134217727\\\n-134217726\\\n-67108866\\\n-67108865\\\n-67108864\\\n-67108863\\\n-67108862\\\n-33554434\\\n-33554433\\\n-33554432\\\n-33554431\\\n-33554430\\\n-16777218\\\n-16777217\\\n-16777216\\\n-16777215\\\n-16777214\\\n-8388610\\\n-8388609\\\n-8388608\\\n-8388607\\\n-8388606\\\n-4194306\\\n-4194305\\\n-4194304\\\n-4194303\\\n-4194302\\\n-2097154\\\n-2097153\\\n-2097152\\\n-2097151\\\n-2097150\\\n-1048578\\\n-1048577\\\n-1048576\\\n-1048575\\\n-1048574\\\n-524290\\\n-524289\\\n-524288\\\n-524287\\\n-524286\\\n-262146\\\n-262145\\\n-262144\\\n-262143\\\n-262142\\\n-131074\\\n-131073\\\n-131072\\\n-131071\\\n-131070\\\n-65538\\\n-65537\\\n-65536\\\n-65535\\\n-65534\\\n-32770\\\n-32769\\\n-32768\\\n-32767\\\n-32766\\\n-16386\\\n-16385\\\n-16384\\\n-16383\\\n-16382\\\n-8194\\\n-8193\\\n-8192\\\n-8191\\\n-8190\\\n-4098\\\n-4097\\\n-4096\\\n-4095\\\n-4094\\\n-2050\\\n-2049\\\n-2048\\\n-2047\\\n-2046\\\n-1026\\\n-1025\\\n-1024\\\n-1023\\\n-1022\\\n-514\\\n-513\\\n-512\\\n-511\\\n-510\\\n-258\\\n-257\\\n-256\\\n-255\\\n-254\\\n-130\\\n-129\\\n-128\\\n-127\\\n-126\\\n-66\\\n-65\\\n-64\\\n-63\\\n-62\\\n-34\\\n-33\\\n-32\\\n-31\\\n-30\\\n-18\\\n-17\\\n-16\\\n-15\\\n-14\\\n-13\\\n-12\\\n-11\\\n-10\\\n-9\\\n-8\\\n-7\\\n-6\\\n-5\\\n-4\\\n-3\\\n-2\\\n-1\\\n0\\\n1\\\n2\\\n3\\\n4\\\n5\\\n6\\\n7\\\n8\\\n9\\\n10\\\n11\\\n12\\\n13\\\n14\\\n15\\\n16\\\n17\\\n18\\\n30\\\n31\\\n32\\\n33\\\n34\\\n62\\\n63\\\n64\\\n65\\\n66\\\n126\\\n127\\\n128\\\n129\\\n130\\\n254\\\n255\\\n256\\\n257\\\n258\\\n510\\\n511\\\n512\\\n513\\\n514\\\n1022\\\n1023\\\n1024\\\n1025\\\n1026\\\n2046\\\n2047\\\n2048\\\n2049\\\n2050\\\n4094\\\n4095\\\n4096\\\n4097\\\n4098\\\n8190\\\n8191\\\n8192\\\n8193\\\n8194\\\n16382\\\n16383\\\n16384\\\n16385\\\n16386\\\n32766\\\n32767\\\n32768\\\n32769\\\n32770\\\n65534\\\n65535\\\n65536\\\n65537\\\n65538\\\n131070\\\n131071\\\n131072\\\n131073\\\n131074\\\n262142\\\n262143\\\n262144\\\n262145\\\n262146\\\n524286\\\n524287\\\n524288\\\n524289\\\n524290\\\n1048574\\\n1048575\\\n1048576\\\n1048577\\\n1048578\\\n2097150\\\n2097151\\\n2097152\\\n2097153\\\n2097154\\\n4194302\\\n4194303\\\n4194304\\\n4194305\\\n4194306\\\n8388606\\\n8388607\\\n8388608\\\n8388609\\\n8388610\\\n16777214\\\n16777215\\\n16777216\\\n16777217\\\n16777218\\\n33554430\\\n33554431\\\n33554432\\\n33554433\\\n33554434\\\n67108862\\\n67108863\\\n67108864\\\n67108865\\\n67108866\\\n134217726\\\n134217727\\\n134217728\\\n134217729\\\n134217730\\\n268435454\\\n268435455\\\n268435456\\\n268435457\\\n268435458\\\n536870910\\\n536870911\\\n536870912\\\n536870913\\\n536870914\\\n1073741822\\\n1073741823\\\n1073741824\\\n1073741825\\\n1073741826\\\n2147483646\\\n2147483647\\\n2147483648\\\n2147483649\\\n2147483650\\\n4294967294\\\n4294967295\\\n4294967296\\\n4294967297\\\n4294967298\\\n8589934590\\\n8589934591\\\n8589934592\\\n8589934593\\\n8589934594\\\n17179869182\\\n17179869183\\\n17179869184\\\n17179869185\\\n17179869186\\\n34359738366\\\n34359738367\\\n34359738368\\\n34359738369\\\n34359738370\\\n68719476734\\\n68719476735\\\n68719476736\\\n68719476737\\\n68719476738\\\n137438953470\\\n137438953471\\\n137438953472\\\n137438953473\\\n137438953474\\\n274877906942\\\n274877906943\\\n274877906944\\\n274877906945\\\n274877906946\\\n549755813886\\\n549755813887\\\n549755813888\\\n549755813889\\\n549755813890\\\n1099511627774\\\n1099511627775\\\n1099511627776\\\n1099511627777\\\n1099511627778\\\n2199023255550\\\n2199023255551\\\n2199023255552\\\n2199023255553\\\n2199023255554\\\n4398046511102\\\n4398046511103\\\n4398046511104\\\n4398046511105\\\n4398046511106\\\n8796093022206\\\n8796093022207\\\n8796093022208\\\n8796093022209\\\n8796093022210\\\n17592186044414\\\n17592186044415\\\n17592186044416\\\n17592186044417\\\n17592186044418\\\n35184372088830\\\n35184372088831\\\n35184372088832\\\n35184372088833\\\n35184372088834\\\n70368744177662\\\n70368744177663\\\n70368744177664\\\n70368744177665\\\n70368744177666\\\n140737488355326\\\n140737488355327\\\n140737488355328\\\n140737488355329\\\n140737488355330\\\n281474976710654\\\n281474976710655\\\n281474976710656\\\n281474976710657\\\n281474976710658\\\n562949953421310\\\n562949953421311\\\n562949953421312\\\n562949953421313\\\n562949953421314\\\n1125899906842622\\\n1125899906842623\\\n1125899906842624\\\n1125899906842625\\\n1125899906842626\\\n2251799813685246\\\n2251799813685247\\\n2251799813685248\\\n2251799813685249\\\n2251799813685250\\\n4503599627370494\\\n4503599627370495\\\n4503599627370496\\\n4503599627370497\\\n4503599627370498\\\n9007199254740990\\\n9007199254740991\\\n9007199254740992\\\n9007199254740993\\\n9007199254740994\\\n18014398509481982\\\n18014398509481983\\\n18014398509481984\\\n18014398509481985\\\n18014398509481986\\\n36028797018963966\\\n36028797018963967\\\n36028797018963968\\\n36028797018963969\\\n36028797018963970\\\n72057594037927934\\\n72057594037927935\\\n72057594037927936\\\n72057594037927937\\\n72057594037927938\\\n144115188075855870\\\n144115188075855871\\\n144115188075855872\\\n144115188075855873\\\n144115188075855874\\\n288230376151711742\\\n288230376151711743\\\n288230376151711744\\\n288230376151711745\\\n288230376151711746\\\n576460752303423486\\\n576460752303423487\\\n576460752303423488\\\n576460752303423489\\\n576460752303423490\\\n1152921504606846974\\\n1152921504606846975\\\n1152921504606846976\\\n1152921504606846977\\\n1152921504606846978\\\n2305843009213693950\\\n2305843009213693951\\\n2305843009213693952\\\n2305843009213693953\\\n2305843009213693954\\\n4611686018427387902\\\n4611686018427387903\\\n4611686018427387904\\\n4611686018427387905\\\n4611686018427387906\\\n9223372036854775806\\\n9223372036854775807}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc6.test",
    "content": "# 2006 September 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure sqlite3_value_text()\n# always returns a null-terminated string.\n#\n# $Id: misc6.test,v 1.3 2007/04/23 23:56:32 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test misc6-1.1 {\n  set DB [sqlite3_connection_pointer db]\n  sqlite3_create_function $DB\n  set STMT [sqlite3_prepare $DB {SELECT hex8(?)} -1 DUMMY]\n  set sqlite_static_bind_value {0123456789}\n  set sqlite_static_bind_nbyte 5\n  sqlite_bind $STMT 1 {} static-nbytes\n  sqlite3_step $STMT\n} SQLITE_ROW\ndo_test misc6-1.2 {\n  sqlite3_column_text $STMT 0\n} {3031323334}\nifcapable utf16 {\n  do_test misc6-1.3 {\n    sqlite3_finalize $STMT\n    set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY]\n    set sqlite_static_bind_value {0123456789}\n    set sqlite_static_bind_nbyte 5\n    sqlite_bind $STMT 1 {} static-nbytes\n    sqlite3_step $STMT\n  } SQLITE_ROW\n  do_test misc6-1.4 {\n    sqlite3_column_text $STMT 0\n  } {00300031003200330034}\n}\nsqlite3_finalize $STMT\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc7.test",
    "content": "# 2006 September 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# $Id: misc7.test,v 1.29 2009/07/16 18:21:18 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[clang_sanitize_address]==0} {\n  do_test misc7-1-misuse {\n    c_misuse_test\n  } {}\n}\n\ndo_test misc7-2 {\n  c_realloc_test\n} {}\n\ndo_test misc7-3 {\n  c_collation_test\n} {}\n\n# Try to open a directory:\n#\ndo_test misc7-4 {\n  delete_file mydir\n  file mkdir mydir\n  set rc [catch {\n    sqlite3 db2 ./mydir\n  } msg]\n  list $rc $msg\n} {1 {unable to open database file}}\n\n# Try to open a file with a directory where its journal file should be.\n#\ndo_test misc7-5 {\n  delete_file mydir\n  file mkdir mydir-journal\n  sqlite3 db2 ./mydir\n  catchsql {\n    CREATE TABLE abc(a, b, c);\n  } db2\n} {1 {unable to open database file}}\ndb2 close\n\n#--------------------------------------------------------------------\n# The following tests, misc7-6.* test the libraries behaviour when\n# it cannot open a file. To force this condition, we use up all the\n# file-descriptors before running sqlite. This probably only works\n# on unix.\n#\n\nproc use_up_files {} {\n  set ret [list]\n  catch {\n    while 1 { lappend ret [open test.db] }\n  }\n  return $ret\n}\n\nproc do_fileopen_test {prefix sql} {\n  set fd_list [use_up_files]\n  set ::go 1\n  set ::n 1\n  set ::sql $sql\n  while {$::go} {\n    catch {db close}\n    do_test ${prefix}.${::n} {\n      set rc [catch {\n        sqlite db test.db\n        db eval $::sql\n      } msg]\n      if {$rc == 0} {set ::go 0}\n  \n      expr {$rc == 0 || ($rc == 1 && [string first unable $msg]==0)}\n    } 1\n  \n    close [lindex $fd_list 0]\n    set fd_list [lrange $fd_list 1 end]\n    incr ::n\n  }\n  foreach fd $fd_list {\n    close $fd\n  }\n  db close\n}\n\nexecsql { CREATE TABLE abc(a PRIMARY KEY, b, c); }\ndb close\n\nif {$tcl_platform(platform)!=\"windows\"} {\n  do_fileopen_test misc7-6.1 {\n    BEGIN;\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(2, 3, 4);\n    INSERT INTO abc SELECT a+2, b, c FROM abc;\n    COMMIT;\n  }\n  \n  do_fileopen_test misc7-6.2 {\n    PRAGMA temp.cache_size = 1000;\n  }\n}\n\n#\n# End of tests for out-of-file-descriptors condition.\n#--------------------------------------------------------------------\n\nsqlite3 db test.db\nexecsql {\n  DELETE FROM abc;\n  INSERT INTO abc VALUES(1, 2, 3);\n  INSERT INTO abc VALUES(2, 3, 4);\n  INSERT INTO abc SELECT a+2, b, c FROM abc;\n}\n  \n\n#--------------------------------------------------------------------\n# Test that the sqlite3_busy_timeout call seems to delay approximately\n# the right amount of time.\n#\ndo_test misc7-7.0 {\n  sqlite3 db2 test.db\n  sqlite3_busy_timeout [sqlite3_connection_pointer db] 2000\n  execsql {\n    BEGIN EXCLUSIVE;\n  } db2\n\n  # Now db2 has an exclusive lock on the database file, and db has\n  # a busy-timeout of 2000 milliseconds. So check that trying to\n  # access the database using connection db delays for at least 1500 ms.\n  #\n  set tm [time {\n    set result [catchsql {\n        SELECT * FROM sqlite_master;\n      } db]\n  }]\n  set delay [lindex $tm 0]  ;# In microseconds\n  lappend result [expr {$delay>1500000 && $delay<4000000}]\n} {1 {database is locked} 1}\ndb2 close\n\n#--------------------------------------------------------------------\n# Test that nothing goes horribly wrong when attaching a database\n# after the omit_readlock pragma has been exercised.\n#\n# Note:  The PRAGMA omit_readlock was an early hack to disable the\n# fcntl() calls for read-only databases so that read-only databases could\n# be read on broken NFS systems.  That pragma has now been removed.\n# (Use the unix-none VFS as a replacement, if needed.)  But these tests\n# do not really depend on omit_readlock, so we left them in place.\n#\ndo_test misc7-7.1 {\n  forcedelete test2.db\n  forcedelete test2.db-journal\n  execsql {\n    PRAGMA omit_readlock = 1;\n    ATTACH 'test2.db' AS aux;\n    CREATE TABLE aux.hello(world);\n    SELECT name FROM aux.sqlite_master;\n  }\n} {hello}\ndo_test misc7-7.2 {\n  execsql {\n    DETACH aux;\n  }\n} {}\ndo_test misc7-7.3 {\n  db close\n  sqlite3 db test.db -readonly 1\n  execsql {\n    PRAGMA omit_readlock = 1;\n    ATTACH 'test2.db' AS aux;\n    SELECT name FROM aux.sqlite_master;\n    SELECT name FROM aux.sqlite_master;\n  }\n} {hello hello}\ndo_test misc7-7.3 {\n  db close\n  sqlite3 db test.db\n  set ::DB [sqlite3_connection_pointer db]\n  list\n} {}\n\n# Test the UTF-16 version of the \"out of memory\" message (used when\n# malloc fails during sqlite3_open() ).\n#\nifcapable utf16 {\n  do_test misc7-8 {\n    encoding convertfrom unicode [sqlite3_errmsg16 0x00000000]\n  } {out of memory}\n}\n\ndo_test misc7-9 {\n  execsql {\n    SELECT * \n    FROM (SELECT name+1 AS one FROM sqlite_master LIMIT 1 OFFSET 1) \n    WHERE one LIKE 'hello%';\n  }\n} {}\n\n#--------------------------------------------------------------------\n# Improve coverage for vtab code.\n#\nifcapable vtab {\n  # Run some debug code to improve reported coverage\n  #\n\n  # set sqlite_where_trace 1\n  do_test misc7-10 {\n    register_echo_module [sqlite3_connection_pointer db]\n    execsql {\n      CREATE VIRTUAL TABLE t1 USING echo(abc);\n      SELECT a FROM t1 WHERE a = 1 ORDER BY b;\n    }\n  } {1}\n  set sqlite_where_trace 0\n\n  # Specify an ORDER BY clause that cannot be indexed.\n  do_test misc7-11 {\n    execsql {\n      SELECT t1.a, t2.a FROM t1, t1 AS t2 ORDER BY 2 LIMIT 1;\n    }\n  } {1 1}\n\n  # The whole point of this is to test an error code other than\n  # SQLITE_NOMEM from the vtab xBestIndex callback.\n  #\n  do_ioerr_test misc7-12 -tclprep {\n    sqlite3 db2 test.db\n    register_echo_module [sqlite3_connection_pointer db2]\n    db2 eval {\n      CREATE TABLE abc(a PRIMARY KEY, b, c);\n      INSERT INTO abc VALUES(1, 2, 3);\n      CREATE VIRTUAL TABLE t1 USING echo(abc);\n    }\n    db2 close\n  } -tclbody {\n    register_echo_module [sqlite3_connection_pointer db]\n    execsql {SELECT * FROM t1 WHERE a = 1;}\n  } \n\n  # The case where the virtual table module returns a very large number\n  # as the cost of a scan (greater than SQLITE_BIG_DOUBLE in the code).\n  #\n  do_test misc7-13 {\n    sqlite3 db test.db\n    register_echo_module [sqlite3_connection_pointer db]\n    set ::echo_module_cost 2.0e+99\n    execsql {SELECT * FROM t1 WHERE a = 1;}\n  } {1 2 3}\n  unset ::echo_module_cost\n}\n\ndb close\nforcedelete test.db\nforcedelete test.db-journal\nsqlite3 db test.db\n\nifcapable explain {\n  do_execsql_test misc7-14.1 {\n    CREATE TABLE abc(a PRIMARY KEY, b, c);\n    EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid = 1;\n  } {\n    0 0 0 {SEARCH TABLE abc AS t2 USING INTEGER PRIMARY KEY (rowid=?)}\n  }\n  do_execsql_test misc7-14.2 {\n    EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE a = 1;\n  } {0 0 0 \n     {SEARCH TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (a=?)}\n  }\n  do_execsql_test misc7-14.3 {\n    EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 ORDER BY a;\n  } {0 0 0 \n     {SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1}\n  }\n}\n\ndb close\nforcedelete test.db\nforcedelete test.db-journal\nsqlite3 db test.db\n\n#--------------------------------------------------------------------\n# This is all to force the pager_remove_from_stmt_list() function\n# (inside pager.c) to remove a pager from the middle of the\n# statement-list.\n#\ndo_test misc7-15.1 {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE abc(a PRIMARY KEY, b, c);\n    INSERT INTO abc \n    VALUES(randstr(100,100), randstr(100,100), randstr(100,100));\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n    COMMIT;\n  }\n  expr {[file size test.db]>10240}\n} {1}\ndo_test misc7-15.2 {\n  execsql {\n    DELETE FROM abc WHERE rowid > 12;\n    INSERT INTO abc SELECT \n            randstr(100,100), randstr(100,100), randstr(100,100) FROM abc;\n  }\n} {}\n\ndb close\nforcedelete test.db\nforcedelete test.db-journal\nsqlite3 db test.db\n\ndo_ioerr_test misc7-16 -sqlprep {\n   PRAGMA cache_size = 10;\n   PRAGMA default_cache_size = 10;\n   CREATE TABLE t3(a, b, UNIQUE(a, b));\n   INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );\n   INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n   INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n   INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n   INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n   INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;\n   UPDATE t3 \n   SET b = 'hello world'\n   WHERE rowid >= (SELECT max(rowid)-1 FROM t3);\n} -tclbody {\n  set rc [catch {db eval {\n    BEGIN;\n      PRAGMA cache_size = 10;\n      INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );\n      UPDATE t3 SET a = b;\n    COMMIT;\n  }} msg]\n\n  if {!$rc || ($rc && [string first \"UNIQUE\" $msg]==0)} {\n    set msg\n  } else {\n    error $msg\n  }\n}\n\nsqlite3 db test.db\n\ndo_test misc7-16.X {\n  execsql {\n    SELECT count(*) FROM t3;\n  }\n} {32}\n\n#----------------------------------------------------------------------\n# Test the situation where a hot-journal is discovered but write-access\n# to it is denied. This should return SQLITE_BUSY.\n#\n# These tests do not work on windows due to restrictions in the\n# windows file system.\n#\nif {$tcl_platform(platform)!=\"windows\"} {\n\n  # Some network filesystems (ex: AFP) do not support setting read-only\n  # permissions.  Only run these tests if full unix permission setting\n  # capabilities are supported.\n  #\n  file attributes test.db -permissions rw-r--r--\n  if {[file attributes test.db -permissions]==0644} {\n\n    do_test misc7-17.1 {\n      execsql {\n        BEGIN;\n        DELETE FROM t3 WHERE (oid%3)==0;\n      }\n      forcecopy test.db bak.db\n      forcecopy test.db-journal bak.db-journal\n      execsql {\n        COMMIT;\n      }\n    \n      db close\n      forcecopy bak.db test.db\n      forcecopy bak.db-journal test.db-journal\n      sqlite3 db test.db\n    \n      catch {file attributes test.db-journal -permissions r--------}\n      catch {file attributes test.db-journal -readonly 1}\n      catchsql {\n        SELECT count(*) FROM t3;\n      }\n    } {1 {unable to open database file}}\n    do_test misc7-17.2 {\n      # Note that the -readonly flag must be cleared before the -permissions\n      # are set. Otherwise, when using tcl 8.5 on mac, the fact that the \n      # -readonly flag is set causes the attempt to set the permissions\n      # to fail.\n      catch {file attributes test.db-journal -readonly 0}\n      catch {file attributes test.db-journal -permissions rw-------}\n      catchsql {\n        SELECT count(*) FROM t3;\n      }\n    } {0 32}\n    \n    # sqlite3_test_control_pending_page [expr ($::sqlite_pending_byte / 1024) + 1]\n    set ::pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1]\n    sqlite3_test_control_pending_byte $::sqlite_pending_byte \n    do_test misc7-17.3 {\n      db eval {\n        pragma writable_schema = true;\n        UPDATE sqlite_master \n          SET rootpage = $pending_byte_page\n          WHERE type = 'table' AND name = 't3';\n      }\n      execsql {\n        SELECT rootpage FROM sqlite_master WHERE type = 'table' AND name = 't3';\n      }\n    } $::pending_byte_page\n    \n    do_test misc7-17.4 {\n      db close\n      sqlite3 db test.db\n      catchsql {\n        SELECT count(*) FROM t3;\n      } \n    } {1 {database disk image is malformed}}\n  }\n}\n\n# Ticket #2470\n#\ndo_test misc7-18.1 {\n  execsql {\n    CREATE TABLE table_1 (col_10);\n    CREATE TABLE table_2 (\n      col_1, col_2, col_3, col_4, col_5,\n      col_6, col_7, col_8, col_9, col_10\n    );\n    SELECT a.col_10\n    FROM\n      (SELECT table_1.col_10 AS col_10 FROM table_1) a,\n      (SELECT table_1.col_10, table_2.col_9 AS qcol_9\n         FROM table_1, table_2\n        GROUP BY table_1.col_10, qcol_9);\n  }\n} {}\n\n# Testing boundary conditions on sqlite3_status()\n#\ndo_test misc7-19.1 {\n  sqlite3_status -1 0\n} {21 0 0}\ndo_test misc7-19.2 {\n  sqlite3_status 1000 0\n} {21 0 0}\n\n\n# sqlite3_global_recover() is a no-op.  But we might as well test it\n# if only to get the test coverage.\n#\ndo_test misc7-20.1 {\n  sqlite3_global_recover\n} {SQLITE_OK}\n\n# Try to open a really long file name.\n#\ndo_test misc7-21.1 {\n  set zFile [file join [get_pwd] \"[string repeat abcde 104].db\"]\n  set rc [catch {sqlite3 db2 $zFile} msg]\n  list $rc $msg\n} {1 {unable to open database file}}\n\n# Try to do hot-journal rollback with a read-only connection. The \n# error code should be SQLITE_READONLY_ROLLBACK.\n#\ndo_test misc7-22.1 {\n  db close\n  forcedelete test.db copy.db-journal\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  db close\n  sqlite3 db test.db -readonly 1\n  catchsql {\n    INSERT INTO t1 VALUES(5, 6);\n  }\n} {1 {attempt to write a readonly database}}\ndo_test misc7-22.2 { execsql { SELECT * FROM t1 } } {1 2 3 4}\ndo_test misc7-22.3 { \n  set fd [open test.db-journal w]\n  puts $fd [string repeat abc 1000]\n  close $fd\n  catchsql { SELECT * FROM t1 }\n} {1 {attempt to write a readonly database}}\ndo_test misc7-22.4 { \n  sqlite3_extended_errcode db\n} SQLITE_READONLY_ROLLBACK\n\ndb close\nforcedelete test.db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misc8.test",
    "content": "# 2014-11-10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# The focus of this script is testing the \"eval.c\" loadable extension.\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nload_static_extension db eval\ndo_execsql_test misc8-1.0 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES(1,2,3),(4,5,6);\n  SELECT quote(eval('SELECT * FROM t1 ORDER BY a','-abc-'));\n} {'1-abc-2-abc-3-abc-4-abc-5-abc-6'}\ndo_execsql_test misc8-1.1 {\n  SELECT quote(eval('SELECT * FROM t1 ORDER BY a'));\n} {{'1 2 3 4 5 6'}}\ndo_catchsql_test misc8-1.2 {\n  SELECT quote(eval('SELECT d FROM t1 ORDER BY a'));\n} {1 {no such column: d}}\ndo_execsql_test misc8-1.3 {\n  INSERT INTO t1 VALUES(7,null,9);\n  SELECT eval('SELECT * FROM t1 ORDER BY a',',');\n} {1,2,3,4,5,6,7,,9}\ndo_catchsql_test misc8-1.4 {\n  BEGIN;\n  INSERT INTO t1 VALUES(10,11,12);\n  SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam'';')), c\n   FROM t1 ORDER BY a;\n} {0 {1 2 3 4 5 6 7 bam 9}}\ndo_catchsql_test misc8-1.5 {\n  INSERT INTO t1 VALUES(10,11,12);\n  SELECT a, coalesce(b, eval('SELECT ''bam''')), c\n    FROM t1\n   ORDER BY rowid;\n} {0 {1 2 3 4 5 6 7 bam 9 10 11 12}}\ndo_catchsql_test misc8-1.6 {\n  SELECT a, coalesce(b, eval('DELETE FROM t1; SELECT ''bam''')), c\n    FROM t1\n   ORDER BY rowid;\n} {0 {1 2 3 4 5 6 7 bam {}}}\ndo_catchsql_test misc8-1.7 {\n  INSERT INTO t1 VALUES(1,2,3),(4,5,6),(7,null,9);\n  BEGIN;\n  CREATE TABLE t2(x);\n  SELECT a, coalesce(b, eval('ROLLBACK; SELECT ''bam''')), c\n    FROM t1\n   ORDER BY rowid;\n} {1 {abort due to ROLLBACK}}\n\n\nreset_db\n\nproc dbeval {sql} { db eval $sql }\ndb func eval dbeval\n\ndo_execsql_test misc8-2.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b INTEGER) WITHOUT ROWID;\n  CREATE TABLE t2(c INTEGER PRIMARY KEY, d INTEGER, x BLOB);\n  INSERT INTO t1 VALUES(0,0);\n  INSERT INTO t1 VALUES(10,10);\n  INSERT INTO t2 VALUES(1,1,zeroblob(200));\n  INSERT INTO t2 VALUES(2,2,zeroblob(200));\n  INSERT INTO t2 VALUES(3,3,zeroblob(200));\n  INSERT INTO t2 VALUES(4,4,zeroblob(200));\n  INSERT INTO t2 VALUES(5,5,zeroblob(200));\n  INSERT INTO t2 VALUES(6,6,zeroblob(200));\n  INSERT INTO t2 VALUES(7,7,zeroblob(200));\n  INSERT INTO t2 VALUES(8,8,zeroblob(200));\n  INSERT INTO t2 VALUES(9,9,zeroblob(200));\n  INSERT INTO t2 VALUES(10,10,zeroblob(200));\n  SELECT a, c, eval(\n      printf('DELETE FROM t2 WHERE c=%d AND %d>5', a+c, a+c)\n  ) FROM t1, t2;\n} {\n  0 1 {} 10 1 {} \n  0 2 {} 10 2 {} \n  0 3 {} 10 3 {} \n  0 4 {} 10 4 {} \n  0 5 {} 10 5 {} \n  0 6 {} 10 {} {} \n  0 7 {} 10 {} {} \n  0 8 {} 10 {} {}\n  0 9 {} 10 {} {} \n  0 10 {} 10 {} {}\n}\n\n# 2016-02-26: An assertion fault found by the libFuzzer project\n#\ndo_execsql_test misc8-3.0 {\n  SELECT *\n    FROM\n         (\n           (SELECT 0 AS i) AS x1,\n           (SELECT 1) AS x2\n         ) AS x3,\n         (SELECT 6 AS j UNION ALL SELECT 7) AS x4\n   WHERE i<rowid\n   ORDER BY 1;\n} {0 1 6 0 1 7}\n\n# The SQLITE_DBCONFIG_MAINDBNAME interface\n#\ndb close\nforcedelete test.db test2.db\nsqlite3 db test.db\ndo_execsql_test misc8-4.0 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES(1,2,3);\n  ATTACH 'test2.db' AS aux2;\n  CREATE TABLE aux2.t2(c,d,e);\n  INSERT INTO t2 VALUES(4,5,6);\n  SELECT * FROM t1, t2;\n} {1 2 3 4 5 6}\ndo_execsql_test misc8-4.1 {\n  PRAGMA database_list;\n} {/0 main .* 2 aux2/}\ndbconfig_maindbname_icecube db\ndo_execsql_test misc8-4.2 {\n  SELECT name FROM icecube.sqlite_master;\n} {t1}\ndo_execsql_test misc8-4.3 {\n  PRAGMA database_list;\n} {/0 icecube .* 2 aux2/}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/misuse.test",
    "content": "# 2002 May 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the SQLITE_MISUSE detection logic.\n# This test file leaks memory and file descriptors.\n#\n# $Id: misuse.test,v 1.11 2006/01/03 00:33:50 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc catchsql2 {sql} {\n  set r [\n    catch {\n      set res [list]\n      db eval $sql data {\n        if { $res==[list] } {\n          foreach f $data(*) {lappend res $f}\n        }\n        foreach f $data(*) {lappend res $data($f)}\n      }\n      set res\n    } msg\n  ]\n  lappend r $msg\n}\n\n\n# Make sure the test logic works\n#\ndo_test misuse-1.1 {\n  db close\n  catch {forcedelete test2.db}\n  catch {forcedelete test2.db-journal}\n  sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n  }\n  catchsql2 {\n    SELECT * FROM t1\n  }\n} {0 {a b 1 2}}\ndo_test misuse-1.2 {\n  catchsql2 {\n    SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1\n  }\n} {1 {no such function: x_coalesce}}\ndo_test misuse-1.3 {\n  sqlite3_create_function $::DB\n  catchsql2 {\n    SELECT x_coalesce(NULL,a) AS 'xyz' FROM t1\n  }\n} {0 {xyz 1}}\n\n# Use the x_sqlite_exec() SQL function to simulate the effect of two\n# threads trying to use the same database at the same time.\n#\n# It used to be prohibited to invoke sqlite_exec() from within a function,\n# but that has changed.  The following tests used to cause errors but now\n# they do not.\n#\nifcapable {utf16} {\n  do_test misuse-1.4 {\n    catchsql2 {\n       SELECT x_sqlite_exec('SELECT * FROM t1') AS xyz;\n    } \n  } {0 {xyz {1 2}}}\n}\ndo_test misuse-1.5 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\ndo_test misuse-1.6 {\n  catchsql {\n    SELECT * FROM t1\n  }\n} {0 {1 2}}\n\n# Attempt to register a new SQL function while an sqlite_exec() is active.\n#\ndo_test misuse-2.1 {\n  db close\n  sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    SELECT * FROM t1\n  }\n} {1 2}\ndo_test misuse-2.2 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\n\n# We used to disallow creating new function from within an exec().\n# But now this is acceptable.\ndo_test misuse-2.3 {\n  set v [catch {\n    db eval {SELECT * FROM t1} {} {\n      sqlite3_create_function $::DB\n    }\n  } msg]\n  lappend v $msg\n} {0 {}}\ndo_test misuse-2.4 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\ndo_test misuse-2.5 {\n  catchsql {\n    SELECT * FROM t1\n  }\n} {0 {1 2}}\n\n# Attempt to register a new SQL aggregate while an sqlite_exec() is active.\n#\ndo_test misuse-3.1 {\n  db close\n  sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    SELECT * FROM t1\n  }\n} {1 2}\ndo_test misuse-3.2 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\n\n# We used to disallow creating new function from within an exec().\n# But now this is acceptable.\ndo_test misuse-3.3 {\n  set v [catch {\n    db eval {SELECT * FROM t1} {} {\n      sqlite3_create_aggregate $::DB\n    }\n  } msg]\n  lappend v $msg\n} {0 {}}\ndo_test misuse-3.4 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\ndo_test misuse-3.5 {\n  catchsql {\n    SELECT * FROM t1\n  }\n} {0 {1 2}}\n\n# Attempt to close the database from an sqlite_exec callback.\n#\n# Update for v3: The db cannot be closed because there are active\n# VMs. The sqlite3_close call would return SQLITE_BUSY.\ndo_test misuse-4.1 {\n  db close\n  sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    SELECT * FROM t1\n  }\n} {1 2}\ndo_test misuse-4.2 {\n  catchsql2 {SELECT * FROM t1}\n} {0 {a b 1 2}}\ndo_test misuse-4.3 {\n  set v [catch {\n    db eval {SELECT * FROM t1} {} {\n      set r [sqlite3_close $::DB]\n    }\n  } msg]\n  lappend v $msg $r\n} {0 {} SQLITE_BUSY}\n\nif {[clang_sanitize_address]==0} {\n  do_test misuse-4.4 {\n  # Flush the TCL statement cache here, otherwise the sqlite3_close() will\n  # fail because there are still un-finalized() VDBEs.\n    db cache flush\n      sqlite3_close $::DB\n      catchsql2 {SELECT * FROM t1}\n  } {1 {bad parameter or other API misuse}}\n  do_test misuse-4.5 {\n    catchsql {\n      SELECT * FROM t1\n    }\n  } {1 {bad parameter or other API misuse}}\n\n  # Attempt to use a database after it has been closed.\n  #\n  do_test misuse-5.1 {\n    db close\n      sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db]\n      execsql {\n        SELECT * FROM t1\n      }\n  } {1 2}\n  do_test misuse-5.2 {\n    catchsql2 {SELECT * FROM t1}\n  } {0 {a b 1 2}}\n  do_test misuse-5.3 {\n    db close\n      set r [catch {\n        sqlite3_prepare $::DB {SELECT * FROM t1} -1 TAIL\n      } msg]\n    lappend r $msg\n  } {1 {(21) bad parameter or other API misuse}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mjournal.test",
    "content": "# 2017 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix mjournal\n\n# Test that nothing bad happens if a journal file contains a pointer to\n# a master journal file that does not have a \"-\" in the name. At one point\n# this was causing a segfault on unix.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n}\n\ndo_test 1.1 {\n  forcedelete test.db2journal test.db-journal\n\n  close [open test.db-journal w]\n  \n  hexio_write test.db-journal 0 746573742e6462326a6f75726e616c00\n  hexio_write test.db-journal 16 00000010\n  hexio_write test.db-journal 20 000005e1\n  hexio_write test.db-journal 24 d9d505f920a163d7\n\n  close [open test.db2journal w]\n  hexio_write test.db2journal 0 abcd\n} {2}\n\ndo_execsql_test 1.2 {\n  SELECT * FROM t1;\n}\n\ndo_test 1.3 {\n  forcedelete test0db2journal test.db-journal\n  close [open test.db-journal w]\n  hexio_write test.db-journal 0 74657374306462326a6f75726e616c00\n  hexio_write test.db-journal 16 00000010\n  hexio_write test.db-journal 20 000005e3\n  hexio_write test.db-journal 24 d9d505f920a163d7\n\n  close [open test0db2journal w]\n  hexio_write test0db2journal 0 abcd\n} {2}\n\ndo_execsql_test 1.4 {\n  SELECT * FROM t1;\n}\n\n# And now test that nothing bad happens if a master journal contains a\n# pointer to a journal file that does not have a \"-\" in the name. \n#\ndo_test 1.5 {\n  forcedelete test.db2-master test.db-journal test1\n  close [open test.db-journal w]\n  hexio_write test.db-journal 0 746573742e6462322d6d617374657200\n  hexio_write test.db-journal 16 00000010\n  hexio_write test.db-journal 20 0000059f\n  hexio_write test.db-journal 24 d9d505f920a163d7\n\n  close [open test.db2-master w]\n  hexio_write test.db2-master 0 746573743100\n\n  close [open test1 w]\n  hexio_write test1 0 abcd\n} {2}\n\ndo_execsql_test 1.6 {\n  SELECT * FROM t1;\n}\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmap1.test",
    "content": "# 2013 March 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !mmap {\n  finish_test\n  return\n}\nsource $testdir/lock_common.tcl\nset testprefix mmap1\n\nproc nRead {db} {\n  set bt [btree_from_db $db]\n  db_enter $db\n  array set stats [btree_pager_stats $bt]\n  db_leave $db\n  # puts [array get stats]\n  return $stats(read)\n}\n\n# Return a Tcl script that registers a user-defined scalar function \n# named rblob() with database handle $dbname. The function returns a\n# sequence of pseudo-random blobs based on seed value $seed.\n#\nproc register_rblob_code {dbname seed} {\n  return [subst -nocommands {\n    set ::rcnt $seed\n    proc rblob {n} {\n      set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]\n      set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]\n      string range [string repeat [set str] [expr [set n]/4]] 1 [set n]\n    }\n    $dbname func rblob rblob\n  }]\n}\n\n\n# For cases 1.1 and 1.4, the number of pages read using xRead() is 4 on\n# unix and 9 on windows. The difference is that windows only ever maps\n# an integer number of OS pages (i.e. creates mappings that are a multiple\n# of 4KB in size). Whereas on unix any sized mapping may be created.\n#\nforeach {t mmap_size nRead c2init} {\n  1.1 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 0}\n  1.2 { PRAGMA mmap_size =    53248 } 150    {PRAGMA mmap_size = 0}\n  1.3 { PRAGMA mmap_size =        0 } 344    {PRAGMA mmap_size = 0}\n  1.4 { PRAGMA mmap_size = 67108864 } /[49]/ {PRAGMA mmap_size = 67108864 }\n  1.5 { PRAGMA mmap_size =    53248 } 150    {PRAGMA mmap_size = 67108864 }\n  1.6 { PRAGMA mmap_size =        0 } 344    {PRAGMA mmap_size = 67108864 }\n} {\n\n  do_multiclient_test tn {\n    sql1 {PRAGMA cache_size=2000}\n    sql2 {PRAGMA cache_size=2000}\n\n    sql1 {PRAGMA page_size=1024}\n    sql1 $mmap_size\n    sql2 $c2init\n\n    code2 [register_rblob_code db2 0]\n\n    sql2 {\n      PRAGMA page_size=1024;\n      PRAGMA auto_vacuum = 1;\n      CREATE TABLE t1(a, b, UNIQUE(a, b));\n      INSERT INTO t1 VALUES(rblob(500), rblob(500));\n      INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    2\n      INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    4\n      INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    8\n      INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --   16\n      INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --   32\n    }\n    do_test $t.$tn.1 {\n      sql1 \"SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count\"\n    } {32 ok 77}\n\n    # Have connection 2 shrink the file. Check connection 1 can still read it.\n    sql2 { DELETE FROM t1 WHERE rowid%2; }\n    do_test $t.$tn.2 {\n      sql1 \"SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count\"\n    } \"16 ok [expr {42+[nonzero_reserved_bytes]}]\"\n\n    # Have connection 2 grow the file. Check connection 1 can still read it.\n    sql2 { INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1 }\n    do_test $t.$tn.3 {\n      sql1 \"SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count\"\n    } {32 ok 79}\n\n    # Have connection 2 grow the file again. Check connection 1 is still ok.\n    sql2 { INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1 }\n    do_test $t.$tn.4 {\n      sql1 \"SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count\"\n    } {64 ok 149}\n\n    # Check that the number of pages read by connection 1 indicates that the\n    # \"PRAGMA mmap_size\" command worked.\n    if {[nonzero_reserved_bytes]==0} {\n      do_test $t.$tn.5 { nRead db } $nRead\n    }\n  }\n}\n\nset ::rcnt 0\nproc rblob {n} {\n  set ::rcnt [expr (($::rcnt << 3) + $::rcnt + 456) & 0xFFFFFFFF]\n  set str [format %.8x [expr $::rcnt ^ 0xbdf20da3]]\n  string range [string repeat $str [expr $n/4]] 1 $n\n}\n\nreset_db\ndb func rblob rblob\n\nifcapable wal {\n  do_execsql_test 2.1 {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA mmap_size = 67108864;\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n    INSERT INTO t1 VALUES(rblob(500), rblob(500));\n    INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    2\n    INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    4\n    INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    8\n    INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --   16\n    INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --   32\n    PRAGMA wal_checkpoint;\n  } {67108864 wal 0 103 103}\n\n  do_execsql_test 2.2 {\n    PRAGMA auto_vacuum;\n    SELECT count(*) FROM t1;\n  } {1 32}\n\n  if {[permutation] != \"inmemory_journal\"} {\n    do_test 2.3 {\n      sqlite3 db2 test.db\n      db2 func rblob rblob\n      db2 eval {\n        DELETE FROM t1 WHERE (rowid%4);\n          PRAGMA wal_checkpoint;\n      }\n      db2 eval {\n        INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    16\n        SELECT count(*) FROM t1;\n      }\n    } {16}\n\n    do_execsql_test 2.4 {\n      PRAGMA wal_checkpoint;\n    } {0 24 24}\n    db2 close\n  }\n}\n\nreset_db\nexecsql { PRAGMA mmap_size = 67108864; }\ndb func rblob rblob\ndo_execsql_test 3.1 {\n  PRAGMA auto_vacuum = 1;\n\n  CREATE TABLE t1(a, b, UNIQUE(a, b));\n  INSERT INTO t1 VALUES(rblob(500), rblob(500));\n  INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    2\n  INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    4\n  INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1; --    8\n\n  CREATE TABLE t2(a, b, UNIQUE(a, b));\n  INSERT INTO t2 SELECT * FROM t1;\n} {}\n\ndo_test 3.2 {\n  set nRow 0\n  db eval {SELECT * FROM t2 ORDER BY a, b} {\n    if {$nRow==4} { db eval { DELETE FROM t1 } }\n    incr nRow\n  }\n  set nRow\n} {8}\n\n#-------------------------------------------------------------------------\n# Ensure that existing cursors using xFetch() pages see changes made\n# to rows using the incrblob API.\n#\nreset_db\nexecsql { PRAGMA mmap_size = 67108864; }\nset aaa [string repeat a 400]\nset bbb [string repeat b 400]\nset ccc [string repeat c 400]\nset ddd [string repeat d 400]\nset eee [string repeat e 400]\n\ndo_execsql_test 4.1 {\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES($aaa);\n  INSERT INTO t1 VALUES($bbb);\n  INSERT INTO t1 VALUES($ccc);\n  INSERT INTO t1 VALUES($ddd);\n  SELECT * FROM t1;\n  BEGIN;\n} [list $aaa $bbb $ccc $ddd]\n\ndo_test 4.2 {\n  set ::STMT [sqlite3_prepare db \"SELECT * FROM t1 ORDER BY rowid\" -1 dummy]\n  sqlite3_step $::STMT\n  sqlite3_column_text $::STMT 0\n} $aaa\n\ndo_test 4.3 {\n  foreach r {2 3 4} {\n    set fd [db incrblob t1 x $r]\n    puts -nonewline $fd $eee\n    close $fd\n  }\n\n  set res [list]\n  while {\"SQLITE_ROW\" == [sqlite3_step $::STMT]} {\n    lappend res [sqlite3_column_text $::STMT 0]\n  }\n  set res\n} [list $eee $eee $eee]\n\ndo_test 4.4 {\n  sqlite3_finalize $::STMT\n} SQLITE_OK\n\ndo_execsql_test 4.5 { COMMIT }\n\n#-------------------------------------------------------------------------\n# Ensure that existing cursors holding xFetch() references are not\n# confused if those pages are moved to make way for the root page of a\n# new table or index.\n#\nreset_db\nexecsql { PRAGMA mmap_size = 67108864; }\ndo_execsql_test 5.1 {\n  PRAGMA auto_vacuum = 2;\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES($aaa);\n  INSERT INTO t1 VALUES($bbb);\n  INSERT INTO t1 VALUES($ccc);\n  INSERT INTO t1 VALUES($ddd);\n\n  PRAGMA auto_vacuum;\n  SELECT * FROM t1;\n} [list 2 $aaa $bbb $ccc $ddd]\n\ndo_test 5.2 {\n  set ::STMT [sqlite3_prepare db \"SELECT * FROM t1 ORDER BY rowid\" -1 dummy]\n  sqlite3_step $::STMT\n  sqlite3_column_text $::STMT 0\n} $aaa\n\ndo_execsql_test 5.3 {\n  CREATE TABLE t2(x);\n  INSERT INTO t2 VALUES('tricked you!');\n  INSERT INTO t2 VALUES('tricked you!');\n}\n\ndo_test 5.4 {\n  sqlite3_step $::STMT\n  sqlite3_column_text $::STMT 0\n} $bbb\n\ndo_test 5.5 {\n  sqlite3_finalize $::STMT\n} SQLITE_OK\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmap2.test",
    "content": "# 2013 March 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the effect of the mmap() or mremap() system calls \n# returning an error on the library. \n#\n# If either mmap() or mremap() fails, SQLite should log an error \n# message, then continue accessing the database using read() and \n# write() exclusively.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix mmap2\n\nif {$::tcl_platform(platform)!=\"unix\" || [test_syscall defaultvfs] != \"unix\"} {\n  finish_test\n  return\n}\nifcapable !mmap {\n  finish_test\n  return\n}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log xLog\nproc xLog {error_code msg} {\n  if {[string match os_unix.c* $msg]} {\n    lappend ::log $msg \n  }\n}\n\nforeach syscall {mmap mremap} {\n  test_syscall uninstall \n  if {[catch {test_syscall install $syscall}]} continue\n\n  for {set i 1} {$i < 20} {incr i} {\n    reset_db\n    execsql { PRAGMA mmap_size = 8000000 }\n\n    test_syscall fault $i 1\n    test_syscall errno $syscall ENOMEM\n    set ::log \"\"\n\n    do_execsql_test 1.$syscall.$i.1 {\n      CREATE TABLE t1(a, b, UNIQUE(a, b));\n      INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n      INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;\n    }\n\n    set nFail [test_syscall fault 0 0]\n\n    do_execsql_test 1.$syscall.$i.2 {\n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    } {64 ok}\n\n    do_test 1.$syscall.$i.3 {\n      expr {$nFail==0 || $nFail==1}\n    } {1}\n\n    do_test 1.$syscall.$i.4.nFail=$nFail {\n      regexp \".*${syscall}.*\" $::log\n    } [expr $nFail>0]\n  }\n}\n\ndb close\ntest_syscall uninstall \nsqlite3_shutdown\ntest_sqlite3_log \nsqlite3_initialize\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmap3.test",
    "content": "# 2013-05-23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !mmap||!vtab {\n  finish_test\n  return\n}\nsource $testdir/lock_common.tcl\nset testprefix mmap3\n\n# A codec shuts down memory-mapped I/O\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\ndo_test mmap3-1.0 {\n  load_static_extension db wholenumber\n  db eval {\n    PRAGMA mmap_size=100000;\n    CREATE TABLE t1(x, y);\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    INSERT INTO t1 SELECT value, randomblob(value) FROM nums\n                    WHERE value BETWEEN 1 and 1000;\n    SELECT sum(x), sum(length(y)) from t1;\n    PRAGMA mmap_size;\n  }\n} {100000 500500 500500 100000}\ndo_test mmap3-1.2 {\n  db eval {\n    PRAGMA mmap_size=50000;\n    CREATE TABLE t2(a,b);\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {50000 nums t1 t2 ok 50000}\ndo_test mmap3-1.3 {\n  db eval {\n    PRAGMA mmap_size=250000;\n    DROP TABLE t2;\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {250000 nums t1 ok 250000}\ndo_test mmap3-1.4 {\n  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {\n    db eval {PRAGMA mmap_size=150000}\n  }\n  db eval {\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {ok 250000}\ndo_test mmap3-1.5 {\n  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {\n    db eval {PRAGMA mmap_size=0}\n  }\n  db eval {\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {ok 250000}\ndo_test mmap3-1.6 {\n  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {\n    set x [db one {PRAGMA mmap_size}]\n  }\n  set x [concat $x [db eval {\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }]]\n} {250000 ok 250000}\ndo_test mmap3-1.7 {\n  db eval {\n    PRAGMA mmap_size(0);\n    CREATE TABLE t3(a,b,c);\n    SELECT name FROM sqlite_master WHERE type='table' ORDER BY 1;\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {0 nums t1 t3 ok 0}\ndo_test mmap3-1.8 {\n  db eval {SELECT x FROM t1 WHERE +x BETWEEN 10 AND 15} {\n    db eval {PRAGMA mmap_size=75000}\n  }\n  db eval {\n    PRAGMA quick_check;\n    PRAGMA mmap_size;\n  }\n} {ok 75000}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmap4.test",
    "content": "# 2016 February 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the effect of the mmap() or mremap() system calls \n# returning an error on the library. \n#\n# If either mmap() or mremap() fails, SQLite should log an error \n# message, then continue accessing the database using read() and \n# write() exclusively.\n# \nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !mmap {\n  finish_test\n  return\n}\nsource $testdir/lock_common.tcl\nset testprefix mmap4\n\n# Return a Tcl script that registers a user-defined scalar function \n# named rblob() with database handle $dbname. The function returns a\n# sequence of pseudo-random blobs based on seed value $seed.\n#\nproc register_rblob_code {dbname seed} {\n  return [subst -nocommands {\n    set ::rcnt $seed\n    proc rblob {n} {\n      set ::rcnt [expr (([set ::rcnt] << 3) + [set ::rcnt] + 456) & 0xFFFFFFFF]\n      set str [format %.8x [expr [set ::rcnt] ^ 0xbdf20da3]]\n      string range [string repeat [set str] [expr [set n]/4]] 1 [set n]\n    }\n    $dbname func rblob rblob\n  }]\n}\n\n#-------------------------------------------------------------------------\n# Test various mmap_size settings.\n#\nforeach {tn1 mmap1 mmap2} {\n     1 6144       167773\n     2 18432      140399\n     3 43008      401302\n     4 92160      253899\n     5 190464          2\n     6 387072     752431\n     7 780288     291143\n     8 1566720    594306\n     9 3139584    829137\n     10 6285312   793963\n     11 12576768 1015590\n} {\n  do_multiclient_test tn {\n    sql1 {\n      CREATE TABLE t1(a PRIMARY KEY);\n      CREATE TABLE t2(x);\n      INSERT INTO t2 VALUES('');\n    }\n\n    code1 [register_rblob_code db  0]\n    code2 [register_rblob_code db2 444]\n\n    sql1 \"PRAGMA mmap_size = $mmap1\"\n    sql2 \"PRAGMA mmap_size = $mmap2\"\n\n    do_test $tn1.$tn {\n      for {set i 1} {$i <= 100} {incr i} {\n        if {$i % 2} {\n          set c1 sql1\n            set c2 sql2\n        } else {\n          set c1 sql2\n            set c2 sql1\n        }\n\n        $c1 {\n          INSERT INTO t1 VALUES( rblob(5000) );\n          UPDATE t2 SET x = (SELECT md5sum(a) FROM t1);\n        }\n\n        set res [$c2 {\n            SELECT count(*) FROM t1;\n            SELECT x == (SELECT md5sum(a) FROM t1) FROM t2;\n            PRAGMA integrity_check;\n        }]\n        if {$res != [list $i 1 ok]} {\n          do_test $tn1.$tn.$i {\n            set ::res\n          } [list $i 1 ok]\n        }\n      }\n      set res 1\n    } {1}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmapfault.test",
    "content": "# 2013-05-23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !mmap {\n  finish_test\n  return\n}\nset testprefix mmapfault\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\ndo_test 1-pre {\n  execsql {\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\n\n\ndo_faultsim_test 1 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA mmap_size = 1000000;\n    PRAGMA cache_size = 5;\n    BEGIN;\n      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n  }\n} -body {\n  execsql { INSERT INTO t1 VALUES(a_string(200), a_string(300)) }\n} -test {\n  faultsim_test_result {0 {}} \n\n  if {[sqlite3_get_autocommit db]} {\n    sqlite3 db2 test.db\n    set nRow [db2 one {SELECT count(*) FROM t1}]\n    if {$nRow!=4} { error \"Database content appears incorrect (1)\" }\n    db2 close\n  }\n\n  execsql { INSERT INTO t1 VALUES(a_string(201), a_string(301)) }\n  set nRow [db one {SELECT count(*) FROM t1}]\n  if {$nRow!=5 && $nRow!=66 && $nRow!=65} { \n    error \"Database content appears incorrect (2) ($nRow)\" \n  }\n\n  catch { execsql COMMIT }\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mmapwarm.test",
    "content": "# 20 September 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\nif 0 {\n  db close\n  sqlite3_shutdown\n  proc msg {args} { puts $args }\n  test_sqlite3_log msg\n  sqlite3 db test.db\n}\n\nset testprefix mmapwarm\n\n\ndo_execsql_test 1.0 {\n  PRAGMA auto_vacuum = 0;\n  CREATE TABLE t1(x, y);\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<500\n  )\n  INSERT INTO t1 SELECT randomblob(400), randomblob(500) FROM s;\n  PRAGMA page_count;\n} {507}\ndb close\n\ndo_test 1.1 {\n  sqlite3 db test.db\n  db eval {PRAGMA mmap_size = 1000000}\n  sqlite3_mmap_warm db\n} {SQLITE_OK}\n\ndo_test 1.2 {\n  db close\n  sqlite3 db test.db\n  db eval {PRAGMA mmap_size = 1000000}\n  sqlite3_mmap_warm db \"main\"\n} {SQLITE_OK}\n\ndo_test 1.3 {\n  sqlite3 db test.db\n  sqlite3_mmap_warm db\n} {SQLITE_OK}\n\ndo_test 1.4 {\n  db close\n  sqlite3 db test.db\n  sqlite3_mmap_warm db \"main\"\n} {SQLITE_OK}\n\ndo_test 2.0 {\n  db close\n  sqlite3 db test.db\n  db eval BEGIN\n  sqlite3_mmap_warm db \"main\"\n} {SQLITE_MISUSE}\n\ndo_faultsim_test 3 -faults oom* -prep {\n  sqlite3 db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n  db eval { PRAGMA mmap_size = 1000000 }\n  db eval { SELECT * FROM sqlite_master }\n} -body {\n  sqlite3_mmap_warm db \"main\"\n} -test {\n  faultsim_test_result {0 SQLITE_OK} {0 SQLITE_NOMEM}\n}\n \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/multiplex.test",
    "content": "# 2010 October 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# The tests in this file assume that SQLite is compiled without\n# ENABLE_8_3_NAMES.\n#\nifcapable 8_3_names {\n  puts -nonewline \"SQLite compiled with SQLITE_ENABLE_8_3_NAMES. \"\n  puts            \"Skipping tests multiplex-*.\"\n  finish_test\n  return\n}\n\nset g_chunk_size [ expr ($::SQLITE_MAX_PAGE_SIZE*16384) ]\nset g_max_chunks 32\n\n# This handles appending the chunk number\n# to the end of the filename.  if \n# SQLITE_MULTIPLEX_EXT_OVWR is defined, then\n# it overwrites the last 2 bytes of the \n# file name with the chunk number.\nproc multiplex_name {name chunk} {\n  if {$chunk==0} { return $name }\n  set num [format \"%03d\" $chunk]\n  ifcapable {multiplex_ext_overwrite} {\n    set name [string range $name 0 [expr [string length $name]-2-1]]\n  }\n  return $name$num\n}\n\n# This saves off the parameters and calls the \n# underlying sqlite3_multiplex_control() API.\nproc multiplex_set {db name chunk_size max_chunks} {\n  global g_chunk_size\n  global g_max_chunks\n  set g_chunk_size [ expr (($chunk_size+($::SQLITE_MAX_PAGE_SIZE-1)) & ~($::SQLITE_MAX_PAGE_SIZE-1)) ]\n  set g_max_chunks $max_chunks\n  set rc [catch {sqlite3_multiplex_control $db $name chunk_size $chunk_size} msg]\n  if { $rc==0 } { \n    set rc [catch {sqlite3_multiplex_control $db $name max_chunks $max_chunks} msg]\n  }\n  list $msg\n}\n\n# This attempts to delete the base file and \n# and files with the chunk extension.\nproc multiplex_delete {name} {\n  global g_max_chunks\n  forcedelete $name\n  for {set i 0} {$i<$g_max_chunks} {incr i} {\n    forcedelete [multiplex_name $name $i]\n    forcedelete [multiplex_name $name-journal $i]\n    forcedelete [multiplex_name $name-wal $i]\n  }\n}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log xLog\nproc xLog {error_code msg} {\n  lappend ::log $error_code $msg \n}\nunset -nocomplain log\n\nmultiplex_delete test.db\nmultiplex_delete test2.db\n\n#-------------------------------------------------------------------------\n#   multiplex-1.1.*: Test initialize and shutdown.\n\ndo_test multiplex-1.1 { sqlite3_multiplex_initialize nosuchvfs 1 } {SQLITE_ERROR}\ndo_test multiplex-1.2 { sqlite3_multiplex_initialize \"\" 1 }        {SQLITE_OK}\ndo_test multiplex-1.3 { sqlite3_multiplex_initialize \"\" 1 }        {SQLITE_MISUSE}\ndo_test multiplex-1.4 { sqlite3_multiplex_shutdown }               {SQLITE_OK}\n\ndo_test multiplex-1.5 { sqlite3_multiplex_initialize \"\" 0 }        {SQLITE_OK}\ndo_test multiplex-1.6 { sqlite3_multiplex_shutdown }               {SQLITE_OK}\ndo_test multiplex-1.7 { sqlite3_multiplex_initialize \"\" 1 }        {SQLITE_OK}\ndo_test multiplex-1.8 { sqlite3_multiplex_shutdown }               {SQLITE_OK}\n\n\ndo_test multiplex-1.9.1  { sqlite3_multiplex_initialize \"\" 1 }     {SQLITE_OK}\ndo_test multiplex-1.9.2  { sqlite3 db test.db }                    {}\ndo_test multiplex-1.9.3  { multiplex_set db main 32768 16 }        {SQLITE_OK}\ndo_test multiplex-1.9.4  { multiplex_set db main 32768 -1 }        {SQLITE_OK}\ndo_test multiplex-1.9.6  { multiplex_set db main 31 16 }           {SQLITE_OK}\ndo_test multiplex-1.9.7  { multiplex_set db main 32768 100 }       {SQLITE_OK}\ndo_test multiplex-1.9.8  { multiplex_set db main 1073741824 1 }    {SQLITE_OK}\ndo_test multiplex-1.9.9  { db close }                              {}\ndo_test multiplex-1.9.10 { sqlite3_multiplex_shutdown }            {SQLITE_OK}\n\ndo_test multiplex-1.10.1  { sqlite3_multiplex_initialize \"\" 1 }                                  {SQLITE_OK}\ndo_test multiplex-1.10.2  { sqlite3 db test.db }                                                 {}\ndo_test multiplex-1.10.3  { lindex [ catchsql { SELECT multiplex_control(2, 32768); } ] 0 }      {0}\ndo_test multiplex-1.10.4  { lindex [ catchsql { SELECT multiplex_control(3, -1); } ] 0 }         {0}\ndo_test multiplex-1.10.6  { lindex [ catchsql { SELECT multiplex_control(2, 31); } ] 0 }         {0}\ndo_test multiplex-1.10.7  { lindex [ catchsql { SELECT multiplex_control(3, 100); } ] 0 }        {0}\ndo_test multiplex-1.10.8  { lindex [ catchsql { SELECT multiplex_control(2, 1073741824); } ] 0 } {0}\ndo_test multiplex-1.10.9  { db close }                                                           {}\ndo_test multiplex-1.10.10 { sqlite3_multiplex_shutdown }                                         {SQLITE_OK}\n\ndo_test multiplex-1.11.1  { sqlite3_multiplex_initialize \"\" 1 }               {SQLITE_OK}\ndo_test multiplex-1.11.2  { sqlite3 db test.db }                              {}\ndo_test multiplex-1.11.3  { sqlite3_multiplex_control db main enable 0  }     {SQLITE_OK}\ndo_test multiplex-1.11.4  { sqlite3_multiplex_control db main enable 1  }     {SQLITE_OK}\ndo_test multiplex-1.11.5  { sqlite3_multiplex_control db main enable -1 }     {SQLITE_OK}\ndo_test multiplex-1.11.6  { db close }                                        {}\ndo_test multiplex-1.11.7  { sqlite3_multiplex_shutdown }                      {SQLITE_OK}\n\ndo_test multiplex-1.12.1  { sqlite3_multiplex_initialize \"\" 1 }                           {SQLITE_OK}\ndo_test multiplex-1.12.2  { sqlite3 db test.db }                                          {}\ndo_test multiplex-1.12.3  { lindex [ catchsql { SELECT multiplex_control(1, 0); } ] 0 }   {0}\ndo_test multiplex-1.12.4  { lindex [ catchsql { SELECT multiplex_control(1, 1); } ] 0 }   {0}\ndo_test multiplex-1.12.5  { lindex [ catchsql { SELECT multiplex_control(1, -1); } ] 0 }  {0}\ndo_test multiplex-1.12.6  { db close }                                                    {}\ndo_test multiplex-1.12.7  { sqlite3_multiplex_shutdown }                                  {SQLITE_OK}\n\ndo_test multiplex-1.13.1  { sqlite3_multiplex_initialize \"\" 1 }                           {SQLITE_OK}\ndo_test multiplex-1.13.2  { sqlite3 db test.db }                                          {}\ndo_test multiplex-1.13.3  { lindex [ catchsql { SELECT multiplex_control(-1, 0); } ] 0 }  {1}\ndo_test multiplex-1.13.4  { lindex [ catchsql { SELECT multiplex_control(4, 1); } ] 0 }   {1}\ndo_test multiplex-1.13.6  { db close }                                                    {}\ndo_test multiplex-1.13.7  { sqlite3_multiplex_shutdown }                                  {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# Some simple warm-body tests with a single database file in rollback \n# mode:\n#\n#   multiplex-2.1.*: Test simple writing to a multiplex file.\n#\n#   multiplex-2.2.*: More writing.\n#\n#   multiplex-2.3.*: Open and close a second db.\n#\n#   multiplex-2.4.*: Try to shutdown the multiplex system before closing the db\n#                file. Check that this fails and the multiplex system still works\n#                afterwards. Then close the database and successfully shut\n#                down the multiplex system.\n#\n#   multiplex-2.5.*: More reading/writing.\n#\n#   multiplex-2.6.*: More reading/writing with varying small chunk sizes, as\n#                well as varying journal mode.\n#\n#   multiplex-2.7.*: Disable/enable tests.\n#\n\nsqlite3_multiplex_initialize \"\" 1\nmultiplex_set db main 32768 16\n\nforcedelete test.x\nforeach f [glob -nocomplain {test.x*[0-9][0-9][0-9]}] {\n  forcedelete $f\n}\ndo_test multiplex-2.1.2 {\n  sqlite3 db test.x\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA journal_mode=DELETE;\n  }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randomblob(1100));\n    INSERT INTO t1 VALUES(2, randomblob(1100));\n  }\n} {}\ndo_test multiplex-2.1.3 { file size [multiplex_name test.x 0] } {4096}\ndo_test multiplex-2.1.4 {\n  execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {}\n\ndo_test multiplex-2.2.1 {\n  execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {}\ndo_test multiplex-2.2.3 { file size [multiplex_name test.x 0] } {6144}\n\ndo_test multiplex-2.3.1 {\n  sqlite3 db2 test2.x\n  db2 close\n} {}\n\n\nunset -nocomplain ::log\n#do_test multiplex-2.4.1 {\n#  sqlite3_multiplex_shutdown\n#} {SQLITE_MISUSE}\ndo_test multiplex-2.4.2 {\n  execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {}\n#do_test multiplex-2.4.3 {\n#  set ::log\n#} {SQLITE_MISUSE {sqlite3_multiplex_shutdown() called while database connections are still open}}\n\ndo_test multiplex-2.4.4 { file size [multiplex_name test.x 0] } {7168}\ndo_test multiplex-2.4.5 {\n  db close\n  sqlite3 db test.x\n  db eval vacuum\n  db close\n  glob test.x*\n} {test.x}\ndo_test multiplex-2.4.99 {\n  sqlite3_multiplex_shutdown\n} {SQLITE_OK}\n\ndo_test multiplex-2.5.1 {\n  multiplex_delete test.x\n  sqlite3_multiplex_initialize \"\" 1\n  sqlite3 db test.x\n  multiplex_set db main 4096 16\n} {SQLITE_OK}\n\ndo_test multiplex-2.5.2 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = delete;\n    PRAGMA auto_vacuum = off;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n  }\n} {delete}\n\ndo_test multiplex-2.5.3 { \n  execsql { \n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, randomblob(4000));\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t1 VALUES(4, randomblob(4000));\n    INSERT INTO t1 VALUES(5, 'five');\n    INSERT INTO t1 VALUES(6, randomblob($g_chunk_size));\n    INSERT INTO t1 VALUES(7, randomblob($g_chunk_size));\n  }\n} {}\n\ndo_test multiplex-2.5.4 {\n  db eval {SELECT * FROM t1 WHERE a=1}\n} {1 one}\n\ndo_test multiplex-2.5.5 {\n  db eval {SELECT * FROM t1 WHERE a=3}\n} {3 three}\n\ndo_test multiplex-2.5.6 {\n  db eval {SELECT * FROM t1 WHERE a=5}\n} {5 five}\n\ndo_test multiplex-2.5.7 {\n  db eval {SELECT a,length(b) FROM t1 WHERE a=2}\n} {2 4000}\n\ndo_test multiplex-2.5.8 {\n  db eval {SELECT a,length(b) FROM t1 WHERE a=4}\n} {4 4000}\n\ndo_test multiplex-2.5.9 { file size [multiplex_name test.x 0] } [list $g_chunk_size]\ndo_test multiplex-2.5.10 { file size [multiplex_name test.x 1] } [list $g_chunk_size]\n\ndo_test multiplex-2.5.99 {\n  db close\n  sqlite3_multiplex_shutdown\n} {SQLITE_OK}\n\n\nset all_journal_modes {delete persist truncate memory off}\nforeach jmode $all_journal_modes {\n  for {set sz 151} {$sz<8000} {set sz [expr $sz+419]} {\n\n    do_test multiplex-2.6.1.$sz.$jmode {\n      multiplex_delete test.db\n      sqlite3_multiplex_initialize \"\" 1\n      sqlite3 db test.db\n      multiplex_set db main $sz 32\n    } {SQLITE_OK}\n\n    do_test multiplex-2.6.2.$sz.$jmode {\n      db eval {\n        PRAGMA page_size = 1024;\n        PRAGMA auto_vacuum = off;\n      }\n      db eval \"PRAGMA journal_mode = $jmode;\"\n    } $jmode\n\n    do_test multiplex-2.6.3.$sz.$jmode { \n      execsql { \n        CREATE TABLE t1(a PRIMARY KEY, b);\n        INSERT INTO t1 VALUES(1, 'one');\n        INSERT INTO t1 VALUES(2, randomblob($g_chunk_size));\n      }\n    } {}\n\n    do_test multiplex-2.6.4.$sz.$jmode {\n      db eval {SELECT b FROM t1 WHERE a=1}\n    } {one}\n\n    do_test multiplex-2.6.5.$sz.$jmode {\n      db eval {SELECT length(b) FROM t1 WHERE a=2}\n    } [list $g_chunk_size]\n\n    do_test multiplex-2.6.6.$sz.$jmode { file size [multiplex_name test.db 0] } [list $g_chunk_size]\n\n    do_test multiplex-2.6.99.$sz.$jmode {\n      db close\n      sqlite3_multiplex_shutdown\n    } {SQLITE_OK}\n\n  }\n}\n\ndo_test multiplex-2.7.1  { multiplex_delete test.db }                                       {}\ndo_test multiplex-2.7.2  { sqlite3_multiplex_initialize \"\" 1 }                              {SQLITE_OK}\ndo_test multiplex-2.7.3  { sqlite3 db test.db }                                             {}\ndo_test multiplex-2.7.4  { lindex [ catchsql { SELECT multiplex_control(2, 65536); } ] 0 }  {0}\ndo_test multiplex-2.7.5  { lindex [ catchsql { SELECT multiplex_control(1, 0); } ] 0 }      {0}\ndo_test multiplex-2.7.6 { \n  execsql { \n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, randomblob(1000));\n  }\n} {}\n# verify only one file, and file size is less than chunks size\ndo_test multiplex-2.7.7  { expr ([file size [multiplex_name test.db 0]] < 65536) } {1}\ndo_test multiplex-2.7.8  { file exists [multiplex_name test.db 1] }                {0}\ndo_test multiplex-2.7.9 { \n  execsql { \n    INSERT INTO t1 VALUES(2, randomblob(65536));\n  }\n} {}\n# verify only one file, and file size exceeds chunks size\ndo_test multiplex-2.7.10 { expr ([file size [multiplex_name test.db 0]] > 65536) } {1}\ndo_test multiplex-2.7.11 { file exists [multiplex_name test.db 1] }                {0}\ndo_test multiplex-2.7.12 { db close }                                              {}\ndo_test multiplex-2.7.13 { sqlite3_multiplex_shutdown }                            {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# Try some tests with more than one connection to a database file. Still\n# in rollback mode.\n#\n#   multiplex-3.1.*: Two connections to a single database file.\n#\n#   multiplex-3.2.*: Two connections to each of several database files (that\n#                are in the same multiplex group).\n#\ndo_test multiplex-3.1.1 {\n  multiplex_delete test.db\n  sqlite3_multiplex_initialize \"\" 1\n  sqlite3 db test.db\n  multiplex_set db main 32768 16\n} {SQLITE_OK}\ndo_test multiplex-3.1.2 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = delete;\n    PRAGMA auto_vacuum = off;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 'one');\n  }\n  file size [multiplex_name test.db 0]\n} {3072}\ndo_test multiplex-3.1.3 {\n  sqlite3 db2 test.db\n  execsql { CREATE TABLE t2(a, b) } db2\n} {}\ndo_test multiplex-3.1.4 {\n  execsql { CREATE TABLE t3(a, b) }\n} {}\ndo_test multiplex-3.1.5 {\n  catchsql { CREATE TABLE t3(a, b) }\n} {1 {table t3 already exists}}\ndo_test multiplex-3.1.6 {\n  db close\n  db2 close\n} {}\n\ndo_test multiplex-3.2.1a {\n\n  multiplex_delete test.db\n  multiplex_delete test2.db\n\n  sqlite3 db1a test.db\n  sqlite3 db2a test2.db\n\n  foreach db {db1a db2a} {\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA journal_mode = delete;\n      PRAGMA auto_vacuum = off;\n      CREATE TABLE t1(a, b);\n    } $db\n  }\n\n  list [file size [multiplex_name test.db 0]] [file size [multiplex_name test2.db 0]]\n} {2048 2048}\n\ndo_test multiplex-3.2.1b {\n  sqlite3 db1b test.db\n  sqlite3 db2b test2.db\n} {}\n\ndo_test multiplex-3.2.2 { execsql { INSERT INTO t1 VALUES('x', 'y') } db1a } {}\ndo_test multiplex-3.2.3 { execsql { INSERT INTO t1 VALUES('v', 'w') } db1b } {}\ndo_test multiplex-3.2.4 { execsql { INSERT INTO t1 VALUES('t', 'u') } db2a } {}\ndo_test multiplex-3.2.5 { execsql { INSERT INTO t1 VALUES('r', 's') } db2b } {}\n\ndo_test multiplex-3.2.6 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a\n} {}\ndo_test multiplex-3.2.7 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b\n} {}\ndo_test multiplex-3.2.8 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a\n} {}\ndo_test multiplex-3.2.9 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b\n} {}\n\ndo_test multiplex-3.3.1 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b\n} {}\n\ndo_test multiplex-3.2.X {\n  foreach db {db1a db2a db2b db1b} { catch { $db close } }\n} {}\n\n#-------------------------------------------------------------------------\n#\n\nsqlite3_multiplex_initialize \"\" 1\nmultiplex_set db main 32768 16\n\n# Return a list of all currently defined multiplexs.\nproc multiplex_list {} {\n  glob -nocomplain test2.db*\n}\n\ndo_test multiplex-4.1.6 {\n  multiplex_delete test2.db\n  sqlite3 db test2.db\n  db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}\n  set res [multiplex_list]\n  list [regexp {test2.db} $res]\n} {1}\ndo_test multiplex-4.1.6a {\n  sqlite3 db2 test2.db\n  db2 eval {SELECT * FROM t2}\n} {tab-t2}\ndo_test multiplex-4.1.7 {\n  execsql {INSERT INTO t2 VALUES(zeroblob(200000))}\n} {}\ndo_test multiplex-4.1.8 {\n  sqlite3 db2 test2.db\n  db2 eval {SELECT count(*) FROM t2}\n} {2}\ndo_test multiplex-4.1.8a {\n   db2 eval { DELETE FROM t2 WHERE x = 'tab-t2' }\n} {}\ndo_test multiplex-4.1.8b {\n  sqlite3 db2 test2.db\n  db2 eval {SELECT count(*) FROM t2}\n} {1}\n\n\ndo_test multiplex-4.1.9 {\n  execsql {INSERT INTO t2 VALUES(zeroblob(200000))}\n} {}\ndo_test multiplex-4.1.10 {\n  set res [multiplex_list]\n  list [regexp {test2.db} $res]\n} {1}\ndo_test multiplex-4.1.11 {\n  db2 close\n  set res [multiplex_list]\n  list [regexp {test2.db} $res]\n} {1}\ndo_test multiplex-4.1.12 {\n  db close\n  multiplex_list\n} {test2.db}\n\n\n#-------------------------------------------------------------------------\n# The following tests test that the multiplex VFS handles malloc and IO \n# errors.\n#\n\nsqlite3_multiplex_initialize \"\" 1\nmultiplex_set db main 32768 16\n\ndo_faultsim_test multiplex-5.1 -prep {\n  catch {db close}\n} -body {\n  sqlite3 db test2.db\n}\ndo_faultsim_test multiplex-5.2 -prep {\n  catch {db close}\n} -body {\n  sqlite3 db test.db\n}\n\ncatch { db close }\nmultiplex_delete test.db\nmultiplex_delete test2.db\n\ndo_test multiplex-5.3.prep {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(10, zeroblob(1200));\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test multiplex-5.3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { DELETE FROM t1 }\n}\n\ndo_test multiplex-5.4.1 {\n  catch { db close }\n  multiplex_delete test.db\n  file mkdir test.db\n  list [catch { sqlite3 db test.db } msg] $msg\n} {1 {unable to open database file}}\ncatch { delete_file test.db }\n\ndo_faultsim_test multiplex-5.5 -prep {\n  catch { sqlite3_multiplex_shutdown }\n} -body {\n  sqlite3_multiplex_initialize \"\" 1\n  multiplex_set db main 32768 16\n}\n\n#-------------------------------------------------------------------------\n# Test that you can vacuum a multiplex'ed DB.  \n\nifcapable vacuum {\n\nsqlite3_multiplex_shutdown\ndo_test multiplex-6.0.0 {\n  multiplex_delete test.db\n  multiplex_delete test.x\n  sqlite3_multiplex_initialize \"\" 1\n  sqlite3 db test.x\n  multiplex_set db main 4096 16\n} {SQLITE_OK}\n\ndo_test multiplex-6.1.0 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA journal_mode=DELETE;\n    PRAGMA auto_vacuum=OFF;\n  }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randomblob($g_chunk_size));\n    INSERT INTO t1 VALUES(2, randomblob($g_chunk_size));\n  }\n} {}\ndo_test multiplex-6.2.1 { file size [multiplex_name test.x 0] } [list $g_chunk_size]\ndo_test multiplex-6.2.2 { file size [multiplex_name test.x 1] } [list $g_chunk_size]\n\ndo_test multiplex-6.3.0 {\n  execsql { VACUUM }\n} {}\n\ndo_test multiplex-6.99 {\n  db close\n  multiplex_delete test.x\n  sqlite3_multiplex_shutdown\n} {SQLITE_OK}\n\n}\n\n\ncatch { db close }\ncatch { sqlite3_multiplex_shutdown }\nsqlite3_shutdown\ntest_sqlite3_log \nsqlite3_initialize\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/multiplex2.test",
    "content": "# 2010 October 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/lock_common.tcl\n\n\ndo_multiclient_test tn {\n  code1 { catch { sqlite3_multiplex_initialize \"\" 0 } }\n  code2 { catch { sqlite3_multiplex_initialize \"\" 0 } }\n\n  code1 { db close }\n  code2 { db2 close }\n\n  code1 { sqlite3 db test.db -vfs multiplex }\n  code2 { sqlite3 db2 test.db -vfs multiplex }\n\n  code1 { sqlite3_multiplex_control db main chunk_size [expr 1024*1024] }\n  code2 { sqlite3_multiplex_control db2 main chunk_size [expr 1024*1024] }\n\n  sql1 {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512\n    SELECT count(*) FROM t1;\n  } \n\n  do_test multiplex-1.$tn.1 { sql1 { SELECT count(*) FROM t1 } } 512\n  do_test multiplex-1.$tn.2 { sql2 { SELECT count(*) FROM t1 } } 512\n  sql2 { DELETE FROM t1 ; VACUUM }\n  do_test multiplex-1.$tn.3 { sql1 { SELECT count(*) FROM t1 } } 0\n\n  sql1 {\n    INSERT INTO t1 VALUES(randomblob(10), randomblob(4000));          --    1\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    2\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    4\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --    8\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   16\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   32\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --   64\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  128\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  256\n    INSERT INTO t1 SELECT randomblob(10), randomblob(4000) FROM t1;   --  512\n    SELECT count(*) FROM t1;\n  }\n\n  do_test multiplex-1.$tn.4 { sql2 { SELECT count(*) FROM t1 } } 512\n}\n\ncatch { sqlite3_multiplex_shutdown }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/multiplex3.test",
    "content": "\n# 2011 December 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for error (IO, OOM etc.) handling when using\n# the multiplexor extension with 8.3 filenames.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix multiplex3\n\nifcapable !8_3_names {\n  puts -nonewline \"SQLite compiled without SQLITE_ENABLE_8_3_NAMES. \"\n  puts            \"Skipping tests multiplex3-*.\"\n  finish_test\n  return\n}\n\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\nautoinstall_test_functions\n\nsqlite3_multiplex_initialize \"\" 1\n\nproc destroy_vfs_stack {} {\n  generic_unregister stack\n  sqlite3_multiplex_shutdown\n}\n\nproc multiplex_delete_db {} {\n  forcedelete test.db\n  for {set i 1} {$i <= 1000} {incr i} {\n    forcedelete test.[format %03d $i]\n  }\n}\n\n# Procs to save and restore the current muliplexed database.\n#\nproc multiplex_save_db {} {\n  foreach f [glob -nocomplain sv_test.*] { forcedelete $f }\n  foreach f [glob -nocomplain test.*]    { forcecopy $f \"sv_$f\" }\n}\nproc multiplex_restore_db {} {\n  foreach f [glob -nocomplain test.*]    {forcedelete $f}\n  foreach f [glob -nocomplain sv_test.*] {forcecopy $f [string range $f 3 end]} }\n\nproc setup_and_save_db {} {\n  multiplex_delete_db\n  sqlite3 db file:test.db?8_3_names=1\n  sqlite3_multiplex_control db main chunk_size [expr 256*1024]\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(randomblob(15), randomblob(2000));\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --   2\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --   4\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --   8\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --  16\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --  32\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    --  64\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 128\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 256\n    INSERT INTO t1 SELECT randomblob(15), randomblob(2000) FROM t1;    -- 512\n  }\n  set ::cksum1 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]\n  db close\n  multiplex_save_db\n}\n\ndo_test 1.0 { setup_and_save_db } {}\ndo_faultsim_test 1 -prep {\n  multiplex_restore_db\n  sqlite3 db file:test.db?8_3_names=1\n  sqlite3_multiplex_control db main chunk_size [expr 256*1024]\n} -body {\n  execsql {\n    UPDATE t1 SET a=randomblob(12), b=randomblob(1500) WHERE (rowid%32)=0\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  if {$testrc!=0} {\n    set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a}]\n    if {$cksum2 != $::cksum1} { error \"data mismatch\" }\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following tests verify that hot-journal rollback works. As follows:\n#\n#   1. Create a large database.\n#   2. Set the pager cache to be very small.\n#   3. Open a transaction. \n#   4. Run the following 100 times:\n#      a. Update a row.\n#      b. Copy all files on disk to a new db location, including the journal.\n#      c. Verify that the new db can be opened and that the content matches\n#         the database created in step 1 (proving the journal was rolled\n#         back).\n\ndo_test 2.0 { \n  setup_and_save_db\n  multiplex_restore_db\n  sqlite3 db file:test.db?8_3_names=1\n  execsql { PRAGMA cache_size = 10 }\n  execsql { BEGIN }\n} {}\n\nfor {set iTest 1} {$iTest<=100} {incr iTest} {\n  do_test 2.$iTest {\n    execsql { \n      UPDATE t1 SET a=randomblob(12), b=randomblob(1400) WHERE rowid=5*$iTest\n    }\n    foreach f [glob -nocomplain test.*] {forcecopy $f \"xx_$f\"}\n    sqlite3 db2 file:xx_test.db?8_3_names=1\n    execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2\n  } $::cksum1\n\n  db2 close\n}\ncatch { db close }\n\n\ndo_test 3.0 { setup_and_save_db } {}\ndo_faultsim_test 3 -faults ioerr-trans* -prep {\n\n  forcedelete test2.db\n  set fd [open test2.wal w]\n  seek $fd 4095\n  puts -nonewline $fd x\n  close $fd\n\n  multiplex_restore_db\n  sqlite3 db file:test.db?8_3_names=1\n  sqlite3 db2 file:test2.db?8_3_names=1\n  sqlite3_multiplex_control db main chunk_size [expr 256*1024]\n  sqlite3_multiplex_control db2 main chunk_size [expr 256*1024]\n} -body {\n  sqlite3_backup B db2 main db main\n  B step 100000\n  set rc [B finish]\n  if { [string match SQLITE_IOERR_* $rc] } {error \"disk I/O error\"}\n  set rc\n} -test {\n  faultsim_test_result {0 SQLITE_OK}\n  if {$testrc==0} {\n    set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2]\n    if {$cksum2 != $::cksum1} { error \"data mismatch\" }\n  }\n  catch { B finish }\n  catch { db close }\n  catch { db2 close }\n}\n\ncatch { db close }\nsqlite3_multiplex_shutdown\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/multiplex4.test",
    "content": "# 2014-09-25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the \"truncate\" option in the multiplexor.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix multiplex4\n\ndb close\nsqlite3_shutdown\nsqlite3_multiplex_initialize {} 0\n\n# delete all filesl with the base name of $basename\n#\nproc multiplex_delete_db {basename} {\n  foreach file [glob -nocomplain $basename.*] {\n    forcedelete $file\n  }\n}\n\n# Return a sorted list of all files with the base name of $basename.\n# Except, delete all text from the end of $basename through the NNN\n# suffix on the end of the filename.\n#\nproc multiplex_file_list {basename} {\n  set x {}\n  foreach file [glob -nocomplain $basename.*] {\n    regsub \"^$basename\\\\..*(\\\\d\\\\d\\\\d)\\$\" $file $basename.\\\\1 file\n    lappend x $file\n  }\n  return [lsort $x]\n}\n\ndo_test multiplex4-1.0 {\n  multiplex_delete_db mx4test\n  sqlite3 db {file:mx4test.db?chunksize=10&truncate=1} -uri 1 -vfs multiplex\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(randomblob(250000));\n  }\n  multiplex_file_list mx4test\n} {mx4test.001 mx4test.db}\n\ndo_test multiplex4-1.1 {\n  db eval {\n    DELETE FROM t1;\n    VACUUM;\n  }\n  multiplex_file_list mx4test\n} {mx4test.db}\n\n# NB:  The PRAGMA multiplex_truncate command is implemented using the\n# SQLITE_FCNTL_PRAGMA file-control...\n#\n# EVIDENCE-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, an\n# SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file\n# object corresponding to the database file to which the pragma\n# statement refers.\n#\ndo_test multiplex4-1.2 {\n  db eval {PRAGMA multiplex_truncate}\n} {on}\ndo_test multiplex4-1.3 {\n  db eval {PRAGMA multiplex_truncate=off}\n} {off}\ndo_test multiplex4-1.4 {\n  db eval {PRAGMA multiplex_truncate}\n} {off}\ndo_test multiplex4-1.5 {\n  db eval {PRAGMA multiplex_truncate=on}\n} {on}\ndo_test multiplex4-1.6 {\n  db eval {PRAGMA multiplex_truncate}\n} {on}\ndo_test multiplex4-1.7 {\n  db eval {PRAGMA multiplex_truncate=0}\n} {off}\ndo_test multiplex4-1.8 {\n  db eval {PRAGMA multiplex_truncate=1}\n} {on}\ndo_test multiplex4-1.9 {\n  db eval {PRAGMA multiplex_truncate=0}\n} {off}\n\n# EVIDENCE-OF: R-26188-08449 If the SQLITE_FCNTL_PRAGMA file control\n# returns SQLITE_OK, then the parser assumes that the VFS has handled\n# the PRAGMA itself and the parser generates a no-op prepared statement\n# if result string is NULL, or that returns a copy of the result string\n# if the string is non-NULL.\n#\ndo_test multiplex4-1.9-explain {\n  db eval {EXPLAIN PRAGMA multiplex_truncate=0;}\n} {/String8 \\d \\d \\d off/}\n\ndo_test multiplex4-1.10 {\n  db eval {\n    INSERT INTO t1(x) VALUES(randomblob(250000));\n  }\n  multiplex_file_list mx4test\n} {mx4test.001 mx4test.db}\n\ndo_test multiplex4-1.11 {\n  db eval {\n    DELETE FROM t1;\n    VACUUM;\n  }\n  multiplex_file_list mx4test\n} {mx4test.001 mx4test.db}\n\ndo_test multiplex4-1.12 {\n  db eval {\n    PRAGMA multiplex_truncate=ON;\n    DROP TABLE t1;\n    VACUUM;\n  }\n  multiplex_file_list mx4test\n} {mx4test.db}\n\ncatch { db close }\nforcedelete mx4test.db\nsqlite3_multiplex_shutdown\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mutex1.test",
    "content": "# 2008 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: mutex1.test,v 1.20 2009/04/23 14:58:40 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !mutex {\n  finish_test\n  return\n}\nif {[info exists tester_do_binarylog]} {\n  finish_test\n  return\n}\n\nsqlite3_reset_auto_extension\nclear_mutex_counters\n\nproc mutex_counters {varname} {\n  upvar $varname var\n  set var(total) 0\n  foreach {name value} [read_mutex_counters] {\n    set var($name) $value\n    incr var(total) $value\n  }\n}\n\n#-------------------------------------------------------------------------\n# Tests mutex1-1.* test that sqlite3_config() returns SQLITE_MISUSE if\n# is called at the wrong time. And that the first time sqlite3_initialize\n# is called it obtains the 'static_master' mutex 3 times and a recursive\n# mutex (sqlite3Config.pInitMutex) twice. Subsequent calls are no-ops\n# that do not require any mutexes.\n#\ndo_test mutex1-1.0 {\n  install_mutex_counters 1\n} {SQLITE_MISUSE}\n\ndo_test mutex1-1.1 {\n  db close\n  install_mutex_counters 1\n} {SQLITE_MISUSE}\n\ndo_test mutex1-1.2 {\n  sqlite3_shutdown\n  install_mutex_counters 1\n} {SQLITE_OK}\n\ndo_test mutex1-1.3 {\n  install_mutex_counters 0\n} {SQLITE_OK}\n\ndo_test mutex1-1.4 {\n  install_mutex_counters 1\n} {SQLITE_OK}\n\ndo_test mutex1-1.5 {\n  mutex_counters counters\n  set counters(total)\n} {0}\n\ndo_test mutex1-1.6 {\n  sqlite3_initialize\n} {SQLITE_OK}\n\ndo_test mutex1-1.7 {\n  mutex_counters counters\n  # list $counters(total) $counters(static_master)\n  expr {$counters(total)>0}\n} {1}\n\ndo_test mutex1-1.8 {\n  clear_mutex_counters\n  sqlite3_initialize\n} {SQLITE_OK}\n\ndo_test mutex1-1.9 {\n  mutex_counters counters\n  list $counters(total) $counters(static_master)\n} {0 0}\n\n#-------------------------------------------------------------------------\n# Tests mutex1-2.* test the three thread-safety related modes that\n# can be selected using sqlite3_config:\n#\n#   * Serialized mode,\n#   * Multi-threaded mode,\n#   * Single-threaded mode.\n#\nifcapable threadsafe1&&shared_cache {\n  set enable_shared_cache [sqlite3_enable_shared_cache 1]\n  foreach {mode mutexes} {\n    singlethread {}\n    multithread  {\n      fast static_app1 static_app2 static_app3\n      static_lru static_master static_mem static_open\n      static_prng static_pmem static_vfs1 static_vfs2\n      static_vfs3\n    }\n    serialized  {\n      fast recursive static_app1 static_app2\n      static_app3 static_lru static_master static_mem\n      static_open static_prng static_pmem static_vfs1\n      static_vfs2 static_vfs3\n    }\n  } {\n\n    do_test mutex1.2.$mode.1 {\n      catch {db close}\n      sqlite3_shutdown\n      sqlite3_config $mode\n    } SQLITE_OK\n\n    do_test mutex1.2.$mode.2 {\n      sqlite3_initialize\n      clear_mutex_counters\n      sqlite3 db test.db -nomutex 0 -fullmutex 0\n      catchsql { CREATE TABLE abc(a, b, c) }\n      db eval {\n        INSERT INTO abc VALUES(1, 2, 3);\n      }\n    } {}\n    ifcapable !memorymanage {\n      regsub { static_lru} $mutexes {} mutexes\n    }\n    if {$mode ne \"singlethread\"} {\n      do_test mutex1.2.$mode.3 {\n        #\n        # NOTE: Make sure all the app and vfs mutexes get used.\n        #\n        enter_static_mutex static_app1\n        leave_static_mutex static_app1\n        enter_static_mutex static_app2\n        leave_static_mutex static_app2\n        enter_static_mutex static_app3\n        leave_static_mutex static_app3\n        enter_static_mutex static_vfs1\n        leave_static_mutex static_vfs1\n        enter_static_mutex static_vfs2\n        leave_static_mutex static_vfs2\n        enter_static_mutex static_vfs3\n        leave_static_mutex static_vfs3\n      } {}\n    }\n    do_test mutex1.2.$mode.4 {\n      mutex_counters counters\n\n      set res [list]\n      foreach {key value} [array get counters] {\n        if {$key ne \"total\" && $value > 0} {\n          lappend res $key\n        }\n      }\n      lsort $res\n    } [lsort $mutexes]\n  }\n  sqlite3_enable_shared_cache $enable_shared_cache\n\n  # Open and use a connection in \"nomutex\" mode. Test that no recursive\n  # mutexes are obtained.\n  do_test mutex1.3.1 {\n    catch {db close}\n    clear_mutex_counters\n    sqlite3 db test.db -nomutex 1\n    execsql { SELECT * FROM abc }\n  } {1 2 3 1 2 3 1 2 3}\n  do_test mutex1.3.2 {\n    mutex_counters counters\n    set counters(recursive)\n  } {0}\n}\n\n# Test the sqlite3_db_mutex() function.\n#\ndo_test mutex1.4.1 {\n  catch {db close}\n  sqlite3 db test.db\n  enter_db_mutex db\n  db eval {SELECT 1, 2, 3}\n} {1 2 3}\ndo_test mutex1.4.2 {\n  leave_db_mutex db\n  db eval {SELECT 1, 2, 3}\n} {1 2 3}\ndo_test mutex1.4.3 {\n  catch {db close}\n  sqlite3 db test.db -nomutex 1\n  enter_db_mutex db\n  db eval {SELECT 1, 2, 3}\n} {1 2 3}\ndo_test mutex1.4.4 {\n  leave_db_mutex db\n  db eval {SELECT 1, 2, 3}\n} {1 2 3}\n\ndo_test mutex1-X {\n  catch {db close}\n  sqlite3_shutdown\n  clear_mutex_counters\n  install_mutex_counters 0\n  sqlite3_initialize\n} {SQLITE_OK}\n\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/mutex2.test",
    "content": "# 2008 July 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test scripts for deliberate failures of mutex routines.\n#\n# $Id: mutex2.test,v 1.9 2008/10/07 15:25:49 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !mutex {\n  finish_test\n  return\n}\n\n# deinitialize\n#\ncatch {db close}\nsqlite3_reset_auto_extension\nsqlite3_shutdown\ninstall_mutex_counters 1\n\n# Fix the mutex subsystem so that it will not initialize.  In other words,\n# make it so that sqlite3_initialize() always fails.  \n#\ndo_test mutex2-1.1 {\n  set ::disable_mutex_init 10\n  sqlite3_initialize\n} {SQLITE_IOERR}\ndo_test mutex2-1.1 {\n  set ::disable_mutex_init 7\n  sqlite3_initialize\n} {SQLITE_NOMEM}\n\nproc utf16 {str} {\n  set r [encoding convertto unicode $str]\n  append r \"\\x00\\x00\"\n  return $r\n}\n\n# Now that sqlite3_initialize() is failing, try to run various APIs that\n# require that SQLite be initialized.  Verify that they fail.\n#\ndo_test mutex2-2.1 {\n  set ::disable_mutex_init 7\n  set rc [catch {sqlite db test.db} msg]\n  lappend rc $msg\n} {1 {}}\nifcapable utf16 {\n  do_test mutex2-2.2 {\n    set db2 [sqlite3_open16 [utf16 test.db] {}]\n  } {0}\n  do_test mutex2-2.3 {\n    sqlite3_complete16 [utf16 {SELECT * FROM t1;}]\n  } {7}\n}\ndo_test mutex2-2.4 {\n  sqlite3_mprintf_int {This is a test %d,%d,%d} 1 2 3\n} {}\nifcapable load_ext {\n  do_test mutex2-2.5 {\n    sqlite3_auto_extension_sqr\n  } {7}\n}\ndo_test mutex2-2.6 {\n  sqlite3_reset_auto_extension\n} {}\ndo_test mutex2-2.7 {\n  sqlite3_malloc 10000\n} {0}\ndo_test mutex2-2.8 {\n  sqlite3_realloc 0 10000\n} {0}\nifcapable threadsafe {\n  do_test mutex2-2.9 {\n    alloc_dealloc_mutex\n  } {0}\n}\ndo_test mutex2-2.10 {\n  vfs_initfail_test\n} {}\n\n# Restore the system to a functional state\n#\ninstall_mutex_counters 0\nset disable_mutex_init 0\nautoinstall_test_functions\n\n# Mutex allocation works now.\n#\n\ndo_test mutex2-3.1 {\n  set ptr [alloc_dealloc_mutex]\n  expr {$ptr!=0}\n} {1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/nan.test",
    "content": "# 2008 April 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3060\n#\n# Make sure IEEE floating point NaN values are handled properly.\n# SQLite should always convert NaN into NULL.\n#\n# Also verify that the decimal to IEEE754 binary conversion routines\n# correctly generate 0.0, +Inf, and -Inf as appropriate for numbers\n# out of range.\n#\n# $Id: nan.test,v 1.5 2008/09/18 11:30:13 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\ndo_test nan-1.1.1 {\n  db eval {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size=1024;\n    CREATE TABLE t1(x FLOAT);\n  }\n  set ::STMT [sqlite3_prepare db \"INSERT INTO t1 VALUES(?)\" -1 TAIL]\n  sqlite3_bind_double $::STMT 1 NaN\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT x, typeof(x) FROM t1}\n} {{} null}\nif {$tcl_platform(platform) != \"symbian\"} {\n  do_realnum_test nan-1.1.2 {\n    sqlite3_bind_double $::STMT 1 +Inf\n    sqlite3_step $::STMT\n    sqlite3_reset $::STMT\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null inf real}\n  do_realnum_test nan-1.1.3 {\n    sqlite3_bind_double $::STMT 1 -Inf\n    sqlite3_step $::STMT\n    sqlite3_reset $::STMT\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null inf real -inf real}\n  do_realnum_test nan-1.1.4 {\n    sqlite3_bind_double $::STMT 1 -NaN\n    sqlite3_step $::STMT\n    sqlite3_reset $::STMT\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null inf real -inf real {} null}\n  do_realnum_test nan-1.1.5 {\n    sqlite3_bind_double $::STMT 1 NaN0\n    sqlite3_step $::STMT\n    sqlite3_reset $::STMT\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null inf real -inf real {} null {} null}\n  do_realnum_test nan-1.1.6 {\n    sqlite3_bind_double $::STMT 1 -NaN0\n    sqlite3_step $::STMT\n    sqlite3_reset $::STMT\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null inf real -inf real {} null {} null {} null}\n  do_test nan-1.1.7 {\n    db eval {\n      UPDATE t1 SET x=x-x;\n      SELECT x, typeof(x) FROM t1;\n    }\n  } {{} null {} null {} null {} null {} null {} null}\n}\n\n# The following block of tests, nan-1.2.*, are the same as the nan-1.1.*\n# tests above, except that the SELECT queries used to validate data \n# convert floating point values to text internally before returning them\n# to Tcl. This allows the tests to be run on platforms where Tcl has\n# problems converting \"inf\" and \"-inf\" from floating point to text format.\n# It also tests the internal float->text conversion routines a bit.\n#\ndo_test nan-1.2.1 {\n  db eval {\n    DELETE FROM T1;\n  }\n  sqlite3_bind_double $::STMT 1 NaN\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null}\ndo_test nan-1.2.2 {\n  sqlite3_bind_double $::STMT 1 +Inf\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null Inf real}\ndo_test nan-1.2.3 {\n  sqlite3_bind_double $::STMT 1 -Inf\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null Inf real -Inf real}\ndo_test nan-1.2.4 {\n  sqlite3_bind_double $::STMT 1 -NaN\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null Inf real -Inf real {} null}\ndo_test nan-1.2.5 {\n  sqlite3_bind_double $::STMT 1 NaN0\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null Inf real -Inf real {} null {} null}\ndo_test nan-1.2.6 {\n  sqlite3_bind_double $::STMT 1 -NaN0\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {{} null Inf real -Inf real {} null {} null {} null}\ndo_test nan-1.2.7 {\n  db eval {\n    UPDATE t1 SET x=x-x;\n    SELECT CAST(x AS text), typeof(x) FROM t1;\n  }\n} {{} null {} null {} null {} null {} null {} null}\n\ndo_test nan-2.1 {\n  db eval {\n    DELETE FROM T1;\n  }\n  sqlite3_bind_double $::STMT 1 NaN\n  sqlite3_step $::STMT\n  sqlite3_reset $::STMT\n  db eval {SELECT x, typeof(x) FROM t1}\n} {{} null}\nsqlite3_finalize $::STMT\n\n# SQLite always converts NaN into NULL so it is not possible to write\n# a NaN value into the database file using SQLite.  The following series\n# of tests writes a normal floating point value (0.5) into the database,\n# then writes directly into the database file to change the 0.5 into NaN.\n# Then it reads the value of the database to verify it is converted into\n# NULL.\n#\nif {![nonzero_reserved_bytes]} {\n  do_test nan-3.1 {\n    db eval {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(0.5);\n      PRAGMA auto_vacuum=OFF;\n      PRAGMA page_size=1024;\n      VACUUM;\n    }\n    hexio_read test.db 2040 8\n  } {3FE0000000000000}\n  do_test nan-3.2 {\n    db eval {\n      SELECT x, typeof(x) FROM t1\n    }\n  } {0.5 real}\n  do_test nan-3.3 {\n    db close\n    hexio_write test.db 2040 FFF8000000000000\n    sqlite3 db test.db\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null}\n  do_test nan-3.4 {\n    db close\n    hexio_write test.db 2040 7FF8000000000000\n    sqlite3 db test.db\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null}\n  do_test nan-3.5 {\n    db close\n    hexio_write test.db 2040 FFFFFFFFFFFFFFFF\n    sqlite3 db test.db\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null}\n  do_test nan-3.6 {\n    db close\n    hexio_write test.db 2040 7FFFFFFFFFFFFFFF\n    sqlite3 db test.db\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {{} null}\n}\n\n# Verify that the sqlite3AtoF routine is able to handle extreme\n# numbers.\n#\ndo_test nan-4.1 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES([string repeat 9 307].0)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {1e+307 real}\ndo_test nan-4.2 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES([string repeat 9 308].0)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {1e+308 real}\ndo_test nan-4.3 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES(-[string repeat 9 307].0)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {-1e+307 real}\ndo_test nan-4.4 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES(-[string repeat 9 308].0)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {-1e+308 real}\ndo_test nan-4.5 {\n  db eval {DELETE FROM t1}\n  set big -[string repeat 0 10000][string repeat 9 308].[string repeat 0 10000]\n  db eval \"INSERT INTO t1 VALUES($big)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {-1e+308 real}\ndo_test nan-4.6 {\n  db eval {DELETE FROM t1}\n  set big [string repeat 0 10000][string repeat 9 308].[string repeat 0 10000]\n  db eval \"INSERT INTO t1 VALUES($big)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {1e+308 real}\n\nif {$tcl_platform(platform) != \"symbian\"} {\n  # Do not run these tests on Symbian, as the Tcl port doesn't like to\n  # convert from floating point value \"-inf\" to a string.\n  #\n  do_realnum_test nan-4.7 {\n    db eval {DELETE FROM t1}\n    db eval \"INSERT INTO t1 VALUES([string repeat 9 309].0)\"\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {inf real}\n  do_realnum_test nan-4.8 {\n    db eval {DELETE FROM t1}\n    db eval \"INSERT INTO t1 VALUES(-[string repeat 9 309].0)\"\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {-inf real}\n}\ndo_test nan-4.9 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES([string repeat 9 309].0)\"\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {Inf real}\ndo_test nan-4.10 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES(-[string repeat 9 309].0)\"\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {-Inf real}\n\ndo_test nan-4.11 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES(1234.5[string repeat 0 10000]12345)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {1234.5 real}\ndo_test nan-4.12 {\n  db eval {DELETE FROM t1}\n  db eval \"INSERT INTO t1 VALUES(-1234.5[string repeat 0 10000]12345)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {-1234.5 real}\ndo_test nan-4.13 {\n  db eval {DELETE FROM t1}\n  set small [string repeat 0 10000].[string repeat 0 324][string repeat 9 10000]\n  db eval \"INSERT INTO t1 VALUES($small)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {0.0 real}\ndo_test nan-4.14 {\n  db eval {DELETE FROM t1}\n  set small \\\n      -[string repeat 0 10000].[string repeat 0 324][string repeat 9 10000]\n  db eval \"INSERT INTO t1 VALUES($small)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {0.0 real}\n\n# These tests test some really, really small floating point numbers.\n#\nif {$tcl_platform(platform) != \"symbian\"} {\n  # These two are not run on symbian because tcl has trouble converting\n  # the very small numbers back to text form (probably due to a difference\n  # in the sprintf() implementation).\n  #\n  do_test nan-4.15 {\n    db eval {DELETE FROM t1}\n    set small \\\n        [string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]\n    db eval \"INSERT INTO t1 VALUES($small)\"\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {9.88131291682493e-324 real}\n  do_test nan-4.16 {\n    db eval {DELETE FROM t1}\n    set small \\\n        -[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]\n    db eval \"INSERT INTO t1 VALUES($small)\"\n    db eval {SELECT x, typeof(x) FROM t1}\n  } {-9.88131291682493e-324 real}\n}\ndo_test nan-4.17 {\n  db eval {DELETE FROM t1}\n  set small [string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]\n  db eval \"INSERT INTO t1 VALUES($small)\"\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {9.88131291682493e-324 real}\ndo_test nan-4.18 {\n  db eval {DELETE FROM t1}\n  set small \\\n      -[string repeat 0 10000].[string repeat 0 323][string repeat 9 10000]\n  db eval \"INSERT INTO t1 VALUES($small)\"\n  db eval {SELECT CAST(x AS text), typeof(x) FROM t1}\n} {-9.88131291682493e-324 real}\n\ndo_realnum_test nan-4.20 {\n  db eval {DELETE FROM t1}\n  set big [string repeat 9 10000].0e-9000\n  db eval \"INSERT INTO t1 VALUES($big)\"\n  db eval {SELECT x, typeof(x) FROM t1}\n} {inf real}\n\ndo_realnum_test nan-4.30 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e+9999');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {inf real}\ndo_realnum_test nan-4.31 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e+10000');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {inf real}\n\ndo_realnum_test nan-4.32 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e-9999');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {0.0 real}\ndo_realnum_test nan-4.33 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e-10000');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {0.0 real}\ndo_realnum_test nan-4.34 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e2147483650');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {inf real}\ndo_realnum_test nan-4.35 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('2.5e-2147483650');\n    SELECT x, typeof(x) FROM t1;\n  }\n} {0.0 real}\n\ndo_realnum_test nan-4.40 {\n  db eval {\n    SELECT cast('-1e999' AS real);\n  }\n} {-inf}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/nockpt.test",
    "content": "# 2016 October 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE\n# option.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/wal_common.tcl\nifcapable !wal {finish_test ; return }\nif {[permutation]==\"journaltest\" || [permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\nset testprefix nockpt\n\ndo_execsql_test 1.0 {\n  PRAGMA auto_vacuum=OFF;\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = wal;\n  CREATE TABLE c1(x, y, z);\n  INSERT INTO c1 VALUES(1, 2, 3);\n} {wal}\n\ndo_test 1.1 { file exists test.db-wal } 1\ndo_test 1.2 { file size test.db-wal } [wal_file_size 3 1024]\ndo_test 1.3 { db close } {}\ndo_test 1.4 { file exists test.db-wal } 0\n\nsqlite3 db test.db\ndo_execsql_test 1.5 {\n  INSERT INTO c1 VALUES(4, 5, 6);\n  INSERT INTO c1 VALUES(7, 8, 9);\n}\ndo_test 1.6 { file exists test.db-wal } 1\ndo_test 1.7 { sqlite3_db_config db NO_CKPT_ON_CLOSE 1 } {1}\ndo_test 1.8 { file size test.db-wal } [wal_file_size 2 1024]\ndo_test 1.9 { db close } {}\ndo_test 1.10 { file exists test.db-wal } 1\ndo_test 1.11 { file size test.db-wal } [wal_file_size 2 1024]\n\nsqlite3 db test.db\ndo_execsql_test 1.12 {\n  SELECT * FROM c1\n} {1 2 3 4 5 6 7 8 9}\n\ndo_execsql_test 1.13 { PRAGMA main.journal_mode } {wal}\ndo_test 1.14 { sqlite3_db_config db NO_CKPT_ON_CLOSE 1 } {1}\ndo_execsql_test 1.14 { PRAGMA main.journal_mode = delete } {delete}\ndo_test 1.15 { file exists test.db-wal } {0}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/nolock.test",
    "content": "# 2014-05-07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the nolock=1 and immutable=1 query\n# parameters and the SQLITE_IOCAP_IMMUTABLE device characteristic.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nunset -nocomplain tvfs_calls\nproc tvfs_reset {} {\n  global tvfs_calls\n  array set tvfs_calls {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}\n}\nproc tvfs_callback {op args} {\n  global tvfs_calls\n  incr tvfs_calls($op)\n  return SQLITE_OK\n}\ntvfs_reset\n\ntestvfs tvfs\ntvfs script tvfs_callback\ntvfs filter {xLock xUnlock xCheckReservedLock xAccess}\n\n############################################################################\n# Verify that the nolock=1 query parameter for URI filenames disables all\n# calls to xLock and xUnlock for rollback databases.\n#\ndo_test nolock-1.0 {\n  db close\n  forcedelete test.db\n  tvfs_reset\n  sqlite db test.db -vfs tvfs\n  db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock)\n} {xLock 7 xUnlock 5 xCheckReservedLock 0}\n\ndo_test nolock-1.1 {\n  db close\n  forcedelete test.db\n  tvfs_reset\n  sqlite db file:test.db?nolock=0 -vfs tvfs -uri 1\n  db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock)\n} {xLock 7 xUnlock 5 xCheckReservedLock 0}\n\ndo_test nolock-1.2 {\n  db close\n  forcedelete test.db\n  tvfs_reset\n  sqlite db file:test.db?nolock=1 -vfs tvfs -uri 1\n  db eval {CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(1,2,3);}\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0}\n\ndo_test nolock-1.3 {\n  db close\n  tvfs_reset\n  sqlite db file:test.db?nolock=0 -vfs tvfs -uri 1 -readonly 1\n  db eval {SELECT * FROM t1}\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock)\n} {xLock 2 xUnlock 2 xCheckReservedLock 0}\n\ndo_test nolock-1.4 {\n  db close\n  tvfs_reset\n  sqlite db file:test.db?nolock=1 -vfs tvfs -uri 1 -readonly 1\n  db eval {SELECT * FROM t1}\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0}\n\n#############################################################################\n# Verify that immutable=1 disables both locking and xAccess calls to the\n# journal files.\n#\ndo_test nolock-2.0 {\n  db close\n  forcedelete test.db\n  # begin by creating a test database\n  sqlite3 db test.db\n  db eval {\n     CREATE TABLE t1(a,b);\n     INSERT INTO t1 VALUES('hello','world');\n     CREATE TABLE t2(x,y);\n     INSERT INTO t2 VALUES(12345,67890);\n     SELECT * FROM t1, t2;\n  }\n} {hello world 12345 67890}\ndo_test nolock-2.1 {\n  tvfs_reset\n  sqlite3 db2 test.db -vfs tvfs\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-2.2 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 2 xUnlock 2 xCheckReservedLock 0 xAccess 4}\n\n\ndo_test nolock-2.11 {\n  db2 close\n  tvfs_reset\n  sqlite3 db2 file:test.db?immutable=0 -vfs tvfs -uri 1\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-2.12 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 2 xUnlock 2 xCheckReservedLock 0 xAccess 4}\n\n\ndo_test nolock-2.21 {\n  db2 close\n  tvfs_reset\n  sqlite3 db2 file:test.db?immutable=1 -vfs tvfs -uri 1\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-2.22 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}\n\ndo_test nolock-2.31 {\n  db2 close\n  tvfs_reset\n  sqlite3 db2 file:test.db?immutable=1 -vfs tvfs -uri 1 -readonly 1\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-2.32 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}\n\n############################################################################\n# Verify that the SQLITE_IOCAP_IMMUTABLE flag works\n#\ndo_test nolock-3.1 {\n  db2 close\n  tvfs devchar immutable\n  tvfs_reset\n  sqlite3 db2 test.db -vfs tvfs\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-3.2 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}\n\ndo_test nolock-3.11 {\n  db2 close\n  tvfs_reset\n  sqlite3 db2 test.db -vfs tvfs -readonly 1\n  db2 eval {SELECT * FROM t1, t2}\n} {hello world 12345 67890}\ndo_test nolock-3.12 {\n  list xLock $::tvfs_calls(xLock) xUnlock $::tvfs_calls(xUnlock) \\\n       xCheckReservedLock $::tvfs_calls(xCheckReservedLock) \\\n       xAccess $::tvfs_calls(xAccess)\n} {xLock 0 xUnlock 0 xCheckReservedLock 0 xAccess 0}\n\ndb2 close\ndb close\ntvfs delete\n\nif {[permutation]!=\"inmemory_journal\"} {\n  # 2016-03-11:  Make sure all works when transitioning to WAL mode\n  # under nolock.\n  #\n  do_test nolock-4.1 {\n    forcedelete test.db\n    sqlite3 db file:test.db?nolock=1 -uri 1\n    db eval {\n       PRAGMA journal_mode=WAL;\n       CREATE TABLE t1(x);\n       INSERT INTO t1 VALUES('youngling');\n       SELECT * FROM t1;\n    }\n  } {delete youngling}\n  db close\n  \n  do_test nolock-4.2 {\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval {\n      PRAGMA journal_mode=WAL;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES('catbird');\n      SELECT * FROM t1;\n    }\n  } {wal catbird}\n  do_test nolock-4.3 {\n    db close\n    sqlite3 db file:test.db?nolock=1 -uri 1\n    set rc [catch {db eval {SELECT * FROM t1}} msg]\n    lappend rc $msg\n  } {1 {unable to open database file}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/notify1.test",
    "content": "# 2009 March 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite3_unlock_notify() API.\n#\n# $Id: notify1.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !unlock_notify||!shared_cache {\n  finish_test\n  return\n}\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n#-------------------------------------------------------------------------\n# Warm body test. Test that an unlock-notify callback can be registered \n# and that it is invoked.\n#\ndo_test notify1-1.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql { CREATE TABLE t1(a, b) }\n} {}\ndo_test notify1-1.2 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  catchsql { INSERT INTO t1 VALUES(3, 4) } db2\n} {1 {database table is locked}}\ndo_test notify1-1.3 {\n  set zScript \"\"\n  db2 unlock_notify {\n    set zScript \"db2 eval { INSERT INTO t1 VALUES(3, 4) }\"\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test notify1-1.4 {\n  set zScript\n} {}\ndo_test notify1-1.5 {\n  execsql { COMMIT }\n  eval $zScript\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\n\n#-------------------------------------------------------------------------\n# Verify that invoking the \"unlock_notify\" method with no arguments\n# (which is the equivalent of invoking sqlite3_unlock_notify() with\n# a NULL xNotify argument) cancels a pending notify callback.\n#\ndo_test notify1-1.11 {\n  execsql { DROP TABLE t1; CREATE TABLE t1(a, b) }\n} {}\ndo_test notify1-1.12 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  catchsql { INSERT INTO t1 VALUES(3, 4) } db2\n} {1 {database table is locked}}\ndo_test notify1-1.13 {\n  set zScript \"\"\n  db2 unlock_notify {\n    set zScript \"db2 eval { INSERT INTO t1 VALUES(3, 4) }\"\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test notify1-1.14 {\n  set zScript\n} {}\ndo_test notify1-1.15 {\n  db2 unlock_notify\n  execsql { COMMIT }\n  eval $zScript\n  execsql { SELECT * FROM t1 }\n} {1 2}\n\n#-------------------------------------------------------------------------\n# The following tests, notify1-2.*, test that deadlock is detected \n# correctly.\n# \ndo_test notify1-2.1 {\n  execsql { \n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES('I', 'II');\n  }\n} {}\n\n#\n# Test for simple deadlock involving two database connections.\n#\n# 1. Grab a write-lock on t1 with [db]. Then grab a read-lock on t2 with [db2].\n# 2. Try to grab a read-lock on t1 with [db2] (fails).\n# 3. Have [db2] wait on the read-lock it failed to obtain in step 2.\n# 4. Try to grab a write-lock on t2 with [db] (fails).\n# 5. Try to have [db] wait on the lock from step 4. Fails, as the system\n#    would be deadlocked (since [db2] is already waiting on [db], and this\n#    operation would have [db] wait on [db2]).\n#\ndo_test notify1-2.2.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(5, 6);\n  }\n  execsql {\n    BEGIN;\n    SELECT * FROM t2;\n  } db2\n} {I II}\ndo_test notify1-2.2.2 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked: t1}}\ndo_test notify1-2.2.3 {\n  db2 unlock_notify {lappend unlock_notify db2}\n} {}\ndo_test notify1-2.2.4 {\n  catchsql { INSERT INTO t2 VALUES('III', 'IV') }\n} {1 {database table is locked: t2}}\ndo_test notify1-2.2.5 {\n  set rc [catch { db unlock_notify {lappend unlock_notify db} } msg]\n  list $rc $msg\n} {1 {database is deadlocked}}\n\n#\n# Test for slightly more complex deadlock involving three database\n# connections: db, db2 and db3.\n#\ndo_test notify1-2.3.1 {\n  db close\n  db2 close\n  forcedelete test.db test2.db test3.db\n  foreach con {db db2 db3} {\n    sqlite3 $con test.db\n    $con eval { ATTACH 'test2.db' AS aux2 }\n    $con eval { ATTACH 'test3.db' AS aux3 }\n  }\n  execsql {\n    CREATE TABLE main.t1(a, b);\n    CREATE TABLE aux2.t2(a, b);\n    CREATE TABLE aux3.t3(a, b);\n  }\n} {}\ndo_test notify1-2.3.2 {\n  execsql { BEGIN ; INSERT INTO t1 VALUES(1, 2) } db\n  execsql { BEGIN ; INSERT INTO t2 VALUES(1, 2) } db2\n  execsql { BEGIN ; INSERT INTO t3 VALUES(1, 2) } db3\n} {}\ndo_test notify1-2.3.3 {\n  catchsql { SELECT * FROM t2 } db\n} {1 {database table is locked: t2}}\ndo_test notify1-2.3.4 {\n  catchsql { SELECT * FROM t3 } db2\n} {1 {database table is locked: t3}}\ndo_test notify1-2.3.5 {\n  catchsql { SELECT * FROM t1 } db3\n} {1 {database table is locked: t1}}\ndo_test notify1-2.3.6 {\n  set lUnlock [list]\n  db  unlock_notify {lappend lUnlock db}\n  db2 unlock_notify {lappend lUnlock db2}\n} {}\ndo_test notify1-2.3.7 {\n  set rc [catch { db3 unlock_notify {lappend lUnlock db3} } msg]\n  list $rc $msg\n} {1 {database is deadlocked}}\ndo_test notify1-2.3.8 {\n  execsql { COMMIT }\n  set lUnlock\n} {}\ndo_test notify1-2.3.9 {\n  db3 unlock_notify {lappend lUnlock db3} \n  set lUnlock\n} {db3}\ndo_test notify1-2.3.10 {\n  execsql { COMMIT } db2\n  set lUnlock\n} {db3 db}\ndo_test notify1-2.3.11 {\n  execsql { COMMIT } db3\n  set lUnlock\n} {db3 db db2}\ncatch { db3 close }\ncatch { db2 close }\ncatch { db close }\n\n#-------------------------------------------------------------------------\n# The following tests, notify1-3.* and notify1-4.*, test that callbacks \n# can be issued when there are many (>16) connections waiting on a single \n# unlock event.\n# \nforeach {tn nConn} {3 20 4 76} {\n  do_test notify1-$tn.1 {\n    sqlite3 db test.db\n    execsql {\n      BEGIN;\n      INSERT INTO t1 VALUES('a', 'b');\n    }\n  } {}\n  set lUnlock [list]\n  set lUnlockFinal [list]\n  for {set ii 1} {$ii <= $nConn} {incr ii} {\n    do_test notify1-$tn.2.$ii.1 {\n      set cmd \"db$ii\"\n      sqlite3 $cmd test.db\n      catchsql { SELECT * FROM t1 } $cmd\n    } {1 {database table is locked: t1}}\n    do_test notify1-$tn.2.$ii.2 {\n      $cmd unlock_notify \"lappend lUnlock $ii\"\n    } {}\n    lappend lUnlockFinal $ii\n  }\n  do_test notify1-$tn.3 {\n    set lUnlock\n  } {}\n  do_test notify1-$tn.4 {\n    execsql {COMMIT}\n    lsort -integer $lUnlock\n  } $lUnlockFinal\n  do_test notify1-$tn.5 {\n    for {set ii 1} {$ii <= $nConn} {incr ii} {\n      \"db$ii\" close\n    }\n  } {}\n}\ndb close\n\n#-------------------------------------------------------------------------\n# These tests, notify1-5.*, test that a malloc() failure that occurs while\n# allocating an array to use as an argument to an unlock-notify callback\n# is handled correctly.\n# \nsource $testdir/malloc_common.tcl\ndo_malloc_test notify1-5 -tclprep {\n  set ::lUnlock [list]\n  execsql {\n    CREATE TABLE t1(a, b);\n    BEGIN;\n    INSERT INTO t1 VALUES('a', 'b');\n  }\n  for {set ii 1} {$ii <= 60} {incr ii} {\n    set cmd \"db$ii\"\n    sqlite3 $cmd test.db\n    catchsql { SELECT * FROM t1 } $cmd\n    $cmd unlock_notify \"lappend ::lUnlock $ii\"\n  }\n} -sqlbody {\n  COMMIT;\n} -cleanup {\n  # One of two things should have happened:\n  #\n  #   1) The transaction opened by [db] was not committed. No unlock-notify\n  #      callbacks were invoked, OR\n  #   2) The transaction opened by [db] was committed and 60 unlock-notify\n  #      callbacks were invoked.\n  #\n  do_test notify1-5.systemstate {\n    expr { ([llength $::lUnlock]==0 && [sqlite3_get_autocommit db]==0)\n        || ([llength $::lUnlock]==60 && [sqlite3_get_autocommit db]==1)\n    }\n  } {1}\n  for {set ii 1} {$ii <= 60} {incr ii} { \"db$ii\" close }\n}\n\n#-------------------------------------------------------------------------\n# Test cases notify1-6.* test cases where the following occur:\n# \n#   notify1-6.1.*: Test encountering an SQLITE_LOCKED error when the\n#                  \"blocking connection\" has already been set by a previous\n#                  SQLITE_LOCKED.\n#\n#   notify1-6.2.*: Test encountering an SQLITE_LOCKED error when already\n#                  waiting on an unlock-notify callback.\n#\n#   notify1-6.3.*: Test that if an SQLITE_LOCKED error is encountered while\n#                  already waiting on an unlock-notify callback, and then\n#                  the blocker that caused the SQLITE_LOCKED commits its\n#                  transaction, the unlock-notify callback is not invoked.\n#\n#   notify1-6.4.*: Like 6.3.*, except that instead of the second blocker\n#                  committing its transaction, the first does. The \n#                  unlock-notify callback is therefore invoked.\n#\ndb close\ndo_test notify1-6.1.1 {\n  forcedelete test.db test2.db\n  foreach conn {db db2 db3} {\n    sqlite3 $conn test.db\n    execsql { ATTACH 'test2.db' AS two } $conn\n  }\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE two.t2(a, b);\n  }\n  execsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  } db2\n  execsql { \n    BEGIN;\n    INSERT INTO t2 VALUES(1, 2);\n  } db3\n} {}\ndo_test notify1-6.1.2 {\n  catchsql { SELECT * FROM t2 }\n} {1 {database table is locked: t2}}\ndo_test notify1-6.1.3 {\n  catchsql { SELECT * FROM t1 }\n} {1 {database table is locked: t1}}\n\ndo_test notify1-6.2.1 {\n  set unlocked 0\n  db unlock_notify {set unlocked 1}\n  set unlocked\n} {0}\ndo_test notify1-6.2.2 {\n  catchsql { SELECT * FROM t2 }\n} {1 {database table is locked: t2}}\ndo_test notify1-6.2.3 {\n  execsql { COMMIT } db2\n  set unlocked\n} {1}\n\ndo_test notify1-6.3.1 {\n  execsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n  } db2\n} {}\ndo_test notify1-6.3.2 {\n  catchsql { SELECT * FROM t1 }\n} {1 {database table is locked: t1}}\ndo_test notify1-6.3.3 {\n  set unlocked 0\n  db unlock_notify {set unlocked 1}\n  set unlocked\n} {0}\ndo_test notify1-6.3.4 {\n  catchsql { SELECT * FROM t2 }\n} {1 {database table is locked: t2}}\ndo_test notify1-6.3.5 {\n  execsql { COMMIT } db3\n  set unlocked\n} {0}\n\ndo_test notify1-6.4.1 {\n  execsql { \n    BEGIN;\n    INSERT INTO t2 VALUES(3, 4);\n  } db3\n  catchsql { SELECT * FROM t2 }\n} {1 {database table is locked: t2}}\ndo_test notify1-6.4.2 {\n  execsql { COMMIT } db2\n  set unlocked\n} {1}\ndo_test notify1-6.4.3 {\n  execsql { COMMIT } db3\n} {}\ndb close\ndb2 close\ndb3 close\n\n#-------------------------------------------------------------------------\n# Test cases notify1-7.* tests that when more than one distinct \n# unlock-notify function is registered, all are invoked correctly.\n#\nproc unlock_notify {} {\n  incr ::unlock_notify\n}\ndo_test notify1-7.1 {\n  foreach conn {db db2 db3} {\n    sqlite3 $conn test.db\n  }\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(5, 6);\n  }\n} {}\ndo_test notify1-7.2 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked: t1}}\ndo_test notify1-7.3 {\n  catchsql { SELECT * FROM t1 } db3\n} {1 {database table is locked: t1}}\ndo_test notify1-7.4 {\n  set unlock_notify 0\n  db2 unlock_notify unlock_notify\n  sqlite3_unlock_notify db3\n} {SQLITE_OK}\ndo_test notify1-7.5 {\n  set unlock_notify\n} {0}\ndo_test notify1-7.6 {\n  execsql { COMMIT }\n  set unlock_notify\n} {2}\n\n#-------------------------------------------------------------------------\n# Test cases notify1-8.* tests that the correct SQLITE_LOCKED extended \n# error code is returned in various scenarios.\n#\ndo_test notify1-8.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(7, 8);\n  }\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked: t1}}\ndo_test notify1-8.2 {\n  sqlite3_extended_errcode db2\n} {SQLITE_LOCKED_SHAREDCACHE}\n\ndo_test notify1-8.3 {\n  execsql {\n    COMMIT;\n    BEGIN EXCLUSIVE;\n  }\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database schema is locked: main}}\ndo_test notify1-8.4 {\n  sqlite3_extended_errcode db2\n} {SQLITE_LOCKED_SHAREDCACHE}\n\ndo_test notify1-8.X {\n  execsql { COMMIT } \n} {}\n\n#-------------------------------------------------------------------------\n# Test cases notify1-9.* test the shared-cache 'pending-lock' feature.\n#\ndo_test notify1-9.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {1 2 3 4 5 6 7 8}\ndo_test notify1-9.2 {\n  execsql { SELECT * FROM t1 } db3\n} {1 2 3 4 5 6 7 8}\ndo_test notify1-9.3 {\n  catchsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(9, 10);\n  }\n} {1 {database table is locked: t1}}\ndo_test notify1-9.4 {\n  catchsql { SELECT * FROM t2 } db3\n} {1 {database table is locked}}\ndo_test notify1-9.5 {\n  execsql  { COMMIT } db2\n  execsql { SELECT * FROM t2 } db3\n} {}\ndo_test notify1-9.6 {\n  execsql  { COMMIT }\n} {}\n\ndo_test notify1-9.7 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {1 2 3 4 5 6 7 8}\ndo_test notify1-9.8 {\n  execsql { SELECT * FROM t1 } db3\n} {1 2 3 4 5 6 7 8}\ndo_test notify1-9.9 {\n  catchsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(9, 10);\n  }\n} {1 {database table is locked: t1}}\ndo_test notify1-9.10 {\n  catchsql { SELECT * FROM t2 } db3\n} {1 {database table is locked}}\ndo_test notify1-9.11 {\n  execsql  { COMMIT }\n  execsql { SELECT * FROM t2 } db3\n} {}\ndo_test notify1-9.12 {\n  execsql  { COMMIT } db2\n} {}\n\ndb close\ndb2 close\ndb3 close\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/notify2.test",
    "content": "# 2009 March 04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: notify2.test,v 1.7 2009/03/30 11:59:31 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\nifcapable !unlock_notify||!shared_cache { finish_test ; return }\n\n# The tests in this file test the sqlite3_blocking_step() function in\n# test_thread.c. sqlite3_blocking_step() is not an SQLite API function,\n# it is just a demonstration of how the sqlite3_unlock_notify() function\n# can be used to synchronize multi-threaded access to SQLite databases\n# in shared-cache mode.\n#\n# Since the implementation of sqlite3_blocking_step() is included on the\n# website as example code, it is important to test that it works.\n#\n# notify2-1.*:\n#\n#   This test uses $nThread threads. Each thread opens the main database\n#   and attaches two other databases. Each database contains a single table.\n#\n#   Each thread repeats transactions over and over for 20 seconds. Each\n#   transaction consists of 3 operations. Each operation is either a read\n#   or a write of one of the tables. The read operations verify an invariant\n#   to make sure that things are working as expected. If an SQLITE_LOCKED\n#   error is returned the current transaction is rolled back immediately.\n#\n#   This exercise is repeated twice, once using sqlite3_step(), and the\n#   other using sqlite3_blocking_step(). The results are compared to ensure\n#   that sqlite3_blocking_step() resulted in higher transaction throughput.\n#\n\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Number of threads to run simultaneously.\n#\nset nThread 6\nset nSecond 5\n\n# The Tcl script executed by each of the $nThread threads used by this test.\n#\nset ThreadProgram {\n\n  # Proc used by threads to execute SQL.\n  #\n  proc execsql_blocking {db zSql} {\n    set lRes [list]\n    set rc SQLITE_OK\n\nset sql $zSql\n\n    while {$rc==\"SQLITE_OK\" && $zSql ne \"\"} {\n      set STMT [$::xPrepare $db $zSql -1 zSql]\n      while {[set rc [$::xStep $STMT]] eq \"SQLITE_ROW\"} {\n        for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n          lappend lRes [sqlite3_column_text $STMT 0]\n        }\n      }\n      set rc [sqlite3_finalize $STMT]\n    }\n\n    if {$rc != \"SQLITE_OK\"} { error \"$rc $sql [sqlite3_errmsg $db]\" }\n    return $lRes\n  }\n\n  proc execsql_retry {db sql} { \n    set msg \"SQLITE_LOCKED blah...\"\n    while { [string match SQLITE_LOCKED* $msg] } {\n      catch { execsql_blocking $db $sql } msg\n    }\n  }\n\n  proc select_one {args} {\n    set n [llength $args]\n    lindex $args [expr int($n*rand())]\n  }\n\n  proc opendb {} {\n    # Open a database connection. Attach the two auxillary databases.\n    set ::DB [sqlite3_open test.db]\n    execsql_retry $::DB { ATTACH 'test2.db' AS aux2; }\n    execsql_retry $::DB { ATTACH 'test3.db' AS aux3; }\n  }\n\n  opendb\n\n  #after 2000\n\n  # This loop runs for ~20 seconds.\n  #\n  set iStart [clock_seconds]\n  set nOp 0\n  set nAttempt 0\n  while { ([clock_seconds]-$iStart) < $nSecond } {\n\n    # Each transaction does 3 operations. Each operation is either a read\n    # or write of a randomly selected table (t1, t2 or t3). Set the variables\n    # $SQL(1), $SQL(2) and $SQL(3) to the SQL commands used to implement\n    # each operation.\n    #\n    for {set ii 1} {$ii <= 3} {incr ii} {\n      foreach {tbl database} [select_one {t1 main} {t2 aux2} {t3 aux3}] {}\n\n      set SQL($ii) [string map [list xxx $tbl yyy $database] [select_one {\n            SELECT \n              (SELECT b FROM xxx WHERE a=(SELECT max(a) FROM xxx))==total(a) \n              FROM xxx WHERE a!=(SELECT max(a) FROM xxx);\n      } {\n            DELETE FROM xxx WHERE a<(SELECT max(a)-100 FROM xxx);\n            INSERT INTO xxx SELECT NULL, total(a) FROM xxx;\n      } {\n            CREATE INDEX IF NOT EXISTS yyy.xxx_i ON xxx(b);\n      } {\n            DROP INDEX IF EXISTS yyy.xxx_i;\n      }\n      ]]\n    }\n\n    # Execute the SQL transaction.\n    #\n    incr nAttempt\n    set rc [catch { execsql_blocking $::DB \"\n        BEGIN;\n          $SQL(1);\n          $SQL(2);\n          $SQL(3);\n        COMMIT;\n      \"\n    } msg]\n\n    if {$rc && [string match \"SQLITE_LOCKED*\" $msg]\n            || [string match \"SQLITE_SCHEMA*\" $msg]\n    } {\n      # Hit an SQLITE_LOCKED error. Rollback the current transaction.\n      set rc [catch { execsql_blocking $::DB ROLLBACK } msg]\n      if {$rc && [string match \"SQLITE_LOCKED*\" $msg]} {\n        sqlite3_close $::DB\n        opendb\n      } \n    } elseif {$rc} {\n      # Hit some other kind of error. This is a malfunction.\n      error $msg\n    } else {\n      # No error occurred. Check that any SELECT statements in the transaction\n      # returned \"1\". Otherwise, the invariant was false, indicating that\n      # some malfunction has occurred.\n      foreach r $msg { if {$r != 1} { puts \"Invariant check failed: $msg\" } }\n      incr nOp\n    }\n  }\n\n  # Close the database connection and return 0.\n  #\n  sqlite3_close $::DB\n  list $nOp $nAttempt\n}\n\nforeach {iTest xStep xPrepare} {\n  1 sqlite3_blocking_step sqlite3_blocking_prepare_v2\n  2 sqlite3_step          sqlite3_nonblocking_prepare_v2\n} {\n  forcedelete test.db test2.db test3.db\n\n  set ThreadSetup \"set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond\"\n\n  # Set up the database schema used by this test. Each thread opens file\n  # test.db as the main database, then attaches files test2.db and test3.db\n  # as auxillary databases. Each file contains a single table (t1, t2 and t3, in\n  # files test.db, test2.db and test3.db, respectively). \n  #\n  do_test notify2-$iTest.1.1 {\n    sqlite3 db test.db\n    execsql {\n      ATTACH 'test2.db' AS aux2;\n      ATTACH 'test3.db' AS aux3;\n      CREATE TABLE main.t1(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE aux2.t2(a INTEGER PRIMARY KEY, b);\n      CREATE TABLE aux3.t3(a INTEGER PRIMARY KEY, b);\n      INSERT INTO t1 SELECT NULL, 0;\n      INSERT INTO t2 SELECT NULL, 0;\n      INSERT INTO t3 SELECT NULL, 0;\n    }\n  } {}\n  do_test notify2-$iTest.1.2 {\n    db close\n  } {}\n\n\n  # Launch $nThread threads. Then wait for them to finish.\n  #\n  puts \"Running $xStep test for $nSecond seconds\"\n  unset -nocomplain finished\n  for {set ii 0} {$ii < $nThread} {incr ii} {\n    thread_spawn finished($ii) $ThreadSetup $ThreadProgram\n  }\n  for {set ii 0} {$ii < $nThread} {incr ii} {\n    do_test notify2-$iTest.2.$ii {\n      if {![info exists finished($ii)]} { vwait finished($ii) }\n      incr anSuccess($xStep) [lindex $finished($ii) 0]\n      incr anAttempt($xStep) [lindex $finished($ii) 1]\n      expr 0\n    } {0}\n  }\n\n  # Count the total number of succesful writes.\n  do_test notify2-$iTest.3.1 {\n    sqlite3 db test.db\n    execsql {\n      ATTACH 'test2.db' AS aux2;\n      ATTACH 'test3.db' AS aux3;\n    }\n    set anWrite($xStep) [execsql {\n      SELECT (SELECT max(a) FROM t1)\n           + (SELECT max(a) FROM t2)\n           + (SELECT max(a) FROM t3)\n    }]\n    db close\n  } {}\n}\n\n# The following tests checks to make sure sqlite3_blocking_step() is\n# faster than sqlite3_step(). \"Faster\" in this case means uses fewer\n# CPU cycles. This is not always the same as faster in wall-clock time \n# for this type of test. The number of CPU cycles per transaction is \n# roughly proportional to the number of attempts made (i.e. one plus the \n# number of SQLITE_BUSY or SQLITE_LOCKED errors that require the transaction \n# to be retried). So this test just measures that a greater percentage of\n# transactions attempted using blocking_step() succeed.\n#\n# The blocking_step() function is almost always faster on multi-core and is\n# usually faster on single-core.  But sometimes, by chance, step() will be\n# faster on a single core, in which case the\n# following test will fail.\n#\nputs \"The following test seeks to demonstrate that the sqlite3_unlock_notify()\"\nputs \"interface helps multi-core systems to run more efficiently.  This test\"\nputs \"sometimes fails on single-core machines.\"\nputs [array get anWrite]\ndo_test notify2-3 {\n  set blocking [expr {\n    double($anSuccess(sqlite3_blocking_step)) /\n    double($anAttempt(sqlite3_blocking_step)) \n  }]\n  set non [expr {\n    double($anSuccess(sqlite3_step)) /\n    double($anAttempt(sqlite3_step)) \n  }]\n  puts -nonewline [format \" blocking: %.1f%% non-blocking %.1f%% ...\" \\\n    [expr $blocking*100.0] [expr $non*100.0]]\n\n  expr {$blocking > $non}\n} {1}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/notify3.test",
    "content": "# 2010 June 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite3_unlock_notify() API.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This script only runs if shared-cache and unlock-notify are available.\n#\nifcapable !unlock_notify||!shared_cache { \n  finish_test \n  return \n}\n\nset esc [sqlite3_enable_shared_cache 1]\n\nsqlite3 db  test.db\nforcedelete test.db2 test.db2-journal test.db2-wal\nsqlite3 db2 test.db2\n\ndo_test notify3-1.1 {\n  execsql { \n    CREATE TABLE t1(a, b); \n    INSERT INTO t1 VALUES('t1 A', 't1 B');\n  }\n} {}\ndo_test notify3-1.2 {\n  execsql { \n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES('t2 A', 't2 B');\n  } db2\n} {}\n\ndo_test notify3-1.3 {\n  execsql { \n    BEGIN EXCLUSIVE;\n    INSERT INTO t2 VALUES('t2 C', 't2 D');\n  } db2\n} {}\ndo_test notify3-1.4 {\n  catchsql { ATTACH 'test.db2' AS aux }\n} {0 {}}\n\ndo_test notify3-1.5 {\n  catchsql { SELECT * FROM t2 }\n} {1 {database schema is locked: aux}}\n\ndo_test notify3-1.6 {\n  list [sqlite3_errcode db] [sqlite3_extended_errcode db]\n} {SQLITE_LOCKED SQLITE_LOCKED_SHAREDCACHE}\n\ndo_test notify3-1.7 {\n  sqlite3_extended_result_codes db 1\n  catch { set ::stmt [sqlite3_prepare_v2 db \"SELECT * FROM t2\" -1 tail] } msg\n  set msg\n} {(262) database schema is locked: aux}\n\ndo_test notify3-1.8 {\n  set ::when 1\n  db unlock_notify { set ::res $::when }\n  set ::when 2\n  execsql { COMMIT } db2\n  set ::res\n} {2}\ndo_test notify3-1.9 {\n  catchsql { SELECT * FROM t2 }\n} {0 {{t2 A} {t2 B} {t2 C} {t2 D}}}\ndb close\n\n\nset err   {{1 {unable to open database: test.db2}}}\nset noerr {{0 {}}}\n\n# When a new database is attached, the connection doing the attaching \n# tries to load any unloaded schemas for both the new database and any\n# already attached databases (including the main database). If it is\n# unable to load any such schemas, then the ATTACH statement fails.\n#\n# This block tests that if the loading of schemas as a result of an\n# ATTACH fails due to locks on the schema table held by other shared-cache\n# connections the extended error code is SQLITE_LOCKED_SHAREDCACHE and\n# it is possible to use the unlock-notify mechanism to determine when\n# the ATTACH might succeed.\n#\n# This test does not work for test-permutations that specify SQL to\n# be executed as part of the [sqlite3] command that opens the database.\n# Executing such SQL causes SQLite to load the database schema into memory \n# earlier than expected, causing test cases to fail.\n#\nif {[presql] == \"\"} {\n  foreach {\n    tn\n    db1_loaded\n    db2_loaded\n    enable_extended_errors\n    result\n    error1 error2\n  } \"\n    0   0 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE\n    1   0 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE\n    2   0 1 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE\n    3   0 1 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE\n    4   1 0 0   $err     SQLITE_LOCKED               SQLITE_LOCKED_SHAREDCACHE\n    5   1 0 1   $err     SQLITE_LOCKED_SHAREDCACHE   SQLITE_LOCKED_SHAREDCACHE\n    6   1 1 0   $noerr   SQLITE_OK                   SQLITE_OK\n    7   1 1 1   $noerr   SQLITE_OK                   SQLITE_OK\n  \" {\n  \n    do_test notify3-2.$tn.1 {\n      catch { db1 close }\n      catch { db2 close }\n      sqlite3 db1 test.db\n      sqlite3 db2 test.db2\n  \n      sqlite3_extended_result_codes db1 $enable_extended_errors\n      sqlite3_extended_result_codes db2 $enable_extended_errors\n  \n      if { $db1_loaded } { db1 eval \"SELECT * FROM sqlite_master\" }\n      if { $db2_loaded } { db2 eval \"SELECT * FROM sqlite_master\" }\n  \n      db2 eval \"BEGIN EXCLUSIVE\"\n      catchsql \"ATTACH 'test.db2' AS two\" db1\n    } $result\n  \n    do_test notify3-2.$tn.2 {\n      list [sqlite3_errcode db1] [sqlite3_extended_errcode db1]\n    } [list $error1 $error2]\n  \n    do_test notify3-2.$tn.3 {\n      db1 unlock_notify {set invoked 1}\n      set invoked 0\n      db2 eval commit\n      set invoked\n    } [lindex $result 0]\n  }\n}\ncatch { db1 close }\ncatch { db2 close }\n\n\nsqlite3_enable_shared_cache $esc\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/notnull.test",
    "content": "# 2002 January 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the NOT NULL constraint.\n#\n# $Id: notnull.test,v 1.4 2006/01/17 09:35:02 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !conflict {\n  finish_test\n  return\n}\n\ndo_test notnull-1.0 {\n  execsql {\n    CREATE TABLE t1 (\n      a NOT NULL,\n      b NOT NULL DEFAULT 5,\n      c NOT NULL ON CONFLICT REPLACE DEFAULT 6,\n      d NOT NULL ON CONFLICT IGNORE DEFAULT 7,\n      e NOT NULL ON CONFLICT ABORT DEFAULT 8\n    );\n    SELECT * FROM t1;\n  }\n} {}\ndo_test notnull-1.1 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-1.2 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-1.2b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-1.4 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-1.4b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.5 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-1.5b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.6 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-1.7 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-1.8 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-1.9 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-1.10 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-1.10b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.11 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-1.12 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-1.13 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 6 4 5}}\ndo_test notnull-1.14 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-1.15 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 6 4 5}}\ndo_test notnull-1.16 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.c}}\nverify_ex_errcode notnull-1.16b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.17 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.d}}\nverify_ex_errcode notnull-1.17b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.18 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 7 5}}\ndo_test notnull-1.19 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 4 8}}\ndo_test notnull-1.20 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.e}}\nverify_ex_errcode notnull-1.20b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-1.21 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {5 5 3 2 1}}\n\ndo_test notnull-2.1 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-2.1b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-2.2 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR REPLACE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-2.2b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-2.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR IGNORE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-2.4 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR ABORT t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-2.4b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-2.5 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET b=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-2.6b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-2.6 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR REPLACE t1 SET b=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 5 3 5 4}}\ndo_test notnull-2.7 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR IGNORE t1 SET b=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-2.8 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET c=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 6 5 4}}\ndo_test notnull-2.9 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET d=null, a=b, b=a;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-2.10 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET e=null, a=b, b=a;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.e}}\nverify_ex_errcode notnull-2.10b SQLITE_CONSTRAINT_NOTNULL\n\ndo_test notnull-3.0 {\n  execsql {\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1b ON t1(b);\n    CREATE INDEX t1c ON t1(c);\n    CREATE INDEX t1d ON t1(d);\n    CREATE INDEX t1e ON t1(e);\n    CREATE INDEX t1abc ON t1(a,b,c);\n  }\n} {}\ndo_test notnull-3.1 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-3.2 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-3.2b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-3.4 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-3.4b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.5 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(b,c,d,e) VALUES(2,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-3.5b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.6 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-3.7 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-3.8 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-3.9 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,c,d,e) VALUES(1,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-3.10 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-3.10b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.11 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-3.12 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,null,3,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 5 3 4 5}}\ndo_test notnull-3.13 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 6 4 5}}\ndo_test notnull-3.14 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR IGNORE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {}}\ndo_test notnull-3.15 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 6 4 5}}\ndo_test notnull-3.16 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,null,4,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.c}}\nverify_ex_errcode notnull-3.16b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.17 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,d,e) VALUES(1,2,3,null,5);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.d}}\nverify_ex_errcode notnull-3.17b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.18 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR ABORT INTO t1(a,b,c,e) VALUES(1,2,3,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 7 5}}\ndo_test notnull-3.19 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {1 2 3 4 8}}\ndo_test notnull-3.20 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1(a,b,c,d,e) VALUES(1,2,3,4,null);\n    SELECT * FROM t1 order by a;\n  }\n} {1 {NOT NULL constraint failed: t1.e}}\nverify_ex_errcode notnull-3.20b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-3.21 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT OR REPLACE INTO t1(e,d,c,b,a) VALUES(1,2,3,null,5);\n    SELECT * FROM t1 order by a;\n  }\n} {0 {5 5 3 2 1}}\n\ndo_test notnull-4.1 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-4.1b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-4.2 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR REPLACE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-4.2b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-4.3 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR IGNORE t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-4.4 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR ABORT t1 SET a=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.a}}\nverify_ex_errcode notnull-4.4b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-4.5 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET b=null;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-4.5b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-4.6 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR REPLACE t1 SET b=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 5 3 5 4}}\ndo_test notnull-4.7 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE OR IGNORE t1 SET b=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-4.8 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET c=null, d=e, e=d;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 6 5 4}}\ndo_test notnull-4.9 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET d=null, a=b, b=a;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {0 {1 2 3 4 5}}\ndo_test notnull-4.10 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    UPDATE t1 SET e=null, a=b, b=a;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 {NOT NULL constraint failed: t1.e}}\nverify_ex_errcode notnull-4.10b SQLITE_CONSTRAINT_NOTNULL\n\n# Test that bug 29ab7be99f is fixed.\n#\ndo_test notnull-5.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(a, b NOT NULL);\n    CREATE TABLE t2(c, d);\n    INSERT INTO t2 VALUES(3, 4);\n    INSERT INTO t2 VALUES(5, NULL);\n  }\n}  {}\ndo_test notnull-5.2 {\n  catchsql {\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 SELECT * FROM t2;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-5.2b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-5.3 {\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test notnull-5.4 {\n  catchsql {\n    DELETE FROM t1;\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 SELECT * FROM t2;\n    COMMIT;\n  }\n} {1 {NOT NULL constraint failed: t1.b}}\nverify_ex_errcode notnull-5.4b SQLITE_CONSTRAINT_NOTNULL\ndo_test notnull-5.5 {\n  execsql { SELECT * FROM t1 }\n} {1 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/null.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for proper treatment of the special\n# value NULL.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table and some data to work with.\n#\ndo_test null-1.0 {\n  execsql {\n    begin;\n    create table t1(a,b,c);\n    insert into t1 values(1,0,0);\n    insert into t1 values(2,0,1);\n    insert into t1 values(3,1,0);\n    insert into t1 values(4,1,1);\n    insert into t1 values(5,null,0);\n    insert into t1 values(6,null,1);\n    insert into t1 values(7,null,null);\n    commit;\n    select * from t1;\n  }\n} {1 0 0 2 0 1 3 1 0 4 1 1 5 {} 0 6 {} 1 7 {} {}}\n\n# Check for how arithmetic expressions handle NULL\n#\ndo_test null-1.1 {\n  execsql {\n    select ifnull(a+b,99) from t1;\n  }\n} {1 2 4 5 99 99 99}\ndo_test null-1.2 {\n  execsql {\n    select ifnull(b*c,99) from t1;\n  }\n} {0 0 0 1 99 99 99}\n\n# Check to see how the CASE expression handles NULL values.  The\n# first WHEN for which the test expression is TRUE is selected.\n# FALSE and UNKNOWN test expressions are skipped.\n#\ndo_test null-2.1 {\n  execsql {\n    select ifnull(case when b<>0 then 1 else 0 end, 99) from t1;\n  }\n} {0 0 1 1 0 0 0}\ndo_test null-2.2 {\n  execsql {\n    select ifnull(case when not b<>0 then 1 else 0 end, 99) from t1;\n  }\n} {1 1 0 0 0 0 0}\ndo_test null-2.3 {\n  execsql {\n    select ifnull(case when b<>0 and c<>0 then 1 else 0 end, 99) from t1;\n  }\n} {0 0 0 1 0 0 0}\ndo_test null-2.4 {\n  execsql {\n    select ifnull(case when not (b<>0 and c<>0) then 1 else 0 end, 99) from t1;\n  }\n} {1 1 1 0 1 0 0}\ndo_test null-2.5 {\n  execsql {\n    select ifnull(case when b<>0 or c<>0 then 1 else 0 end, 99) from t1;\n  }\n} {0 1 1 1 0 1 0}\ndo_test null-2.6 {\n  execsql {\n    select ifnull(case when not (b<>0 or c<>0) then 1 else 0 end, 99) from t1;\n  }\n} {1 0 0 0 0 0 0}\ndo_test null-2.7 {\n  execsql {\n    select ifnull(case b when c then 1 else 0 end, 99) from t1;\n  }\n} {1 0 0 1 0 0 0}\ndo_test null-2.8 {\n  execsql {\n    select ifnull(case c when b then 1 else 0 end, 99) from t1;\n  }\n} {1 0 0 1 0 0 0}\n\n# Check to see that NULL values are ignored in aggregate functions.\n#\ndo_test null-3.1 {\n  execsql {\n    select count(*), count(b), count(c), sum(b), sum(c), \n           avg(b), avg(c), min(b), max(b) from t1;\n  }\n} {7 4 6 2 3 0.5 0.5 0 1}\n\n# The sum of zero entries is a NULL, but the total of zero entries is 0.\n#\ndo_test null-3.2 {\n  execsql {\n    SELECT sum(b), total(b) FROM t1 WHERE b<0\n  }\n} {{} 0.0}\n\n# Check to see how WHERE clauses handle NULL values.  A NULL value\n# is the same as UNKNOWN.  The WHERE clause should only select those\n# rows that are TRUE.  FALSE and UNKNOWN rows are rejected.\n#\ndo_test null-4.1 {\n  execsql {\n    select a from t1 where b<10\n  }\n} {1 2 3 4}\ndo_test null-4.2 {\n  execsql {\n    select a from t1 where not b>10\n  }\n} {1 2 3 4}\ndo_test null-4.3 {\n  execsql {\n    select a from t1 where b<10 or c=1;\n  }\n} {1 2 3 4 6}\ndo_test null-4.4 {\n  execsql {\n    select a from t1 where b<10 and c=1;\n  }\n} {2 4}\ndo_test null-4.5 {\n  execsql {\n    select a from t1 where not (b<10 and c=1);\n  }\n} {1 3 5}\n\n# The DISTINCT keyword on a SELECT statement should treat NULL values\n# as distinct\n#\ndo_test null-5.1 {\n  execsql {\n    select distinct b from t1 order by b;\n  }\n} {{} 0 1}\n\n# A UNION to two queries should treat NULL values\n# as distinct.\n#\n# (Later:)  We also take this opportunity to test the ability\n# of an ORDER BY clause to bind to either SELECT of a UNION.\n# The left-most SELECT is preferred.  In standard SQL, only\n# the left SELECT can be used.  The ability to match an ORDER\n# BY term to the right SELECT is an SQLite extension.\n#\nifcapable compound {\n  do_test null-6.1 {\n    execsql {\n      select b from t1 union select c from t1 order by b;\n    }\n  } {{} 0 1}\n  do_test null-6.2 {\n    execsql {\n      select b from t1 union select c from t1 order by 1;\n    }\n  } {{} 0 1}\n  do_test null-6.3 {\n    execsql {\n      select b from t1 union select c from t1 order by t1.b;\n    }\n  } {{} 0 1}\n  do_test null-6.4 {\n    execsql {\n      select b from t1 union select c from t1 order by main.t1.b;\n    }\n  } {{} 0 1}\n  do_test null-6.5 {\n    catchsql {\n      select b from t1 union select c from t1 order by t1.a;\n    }\n  } {1 {1st ORDER BY term does not match any column in the result set}}\n  do_test null-6.6 {\n    catchsql {\n      select b from t1 union select c from t1 order by main.t1.a;\n    }\n  } {1 {1st ORDER BY term does not match any column in the result set}}\n} ;# ifcapable compound\n\n# The UNIQUE constraint only applies to non-null values\n#\nifcapable conflict {\ndo_test null-7.1 {\n    execsql {\n      create table t2(a, b unique on conflict ignore);\n      insert into t2 values(1,1);\n      insert into t2 values(2,null);\n      insert into t2 values(3,null);\n      insert into t2 values(4,1);\n      select a from t2;\n    }\n  } {1 2 3}\n  do_test null-7.2 {\n    execsql {\n      create table t3(a, b, c, unique(b,c) on conflict ignore);\n      insert into t3 values(1,1,1);\n      insert into t3 values(2,null,1);\n      insert into t3 values(3,null,1);\n      insert into t3 values(4,1,1);\n      select a from t3;\n    }\n  } {1 2 3}\n}\n\n# Ticket #461 - Make sure nulls are handled correctly when doing a\n# lookup using an index.\n#\ndo_test null-8.1 {\n  execsql {\n    CREATE TABLE t4(x,y);\n    INSERT INTO t4 VALUES(1,11);\n    INSERT INTO t4 VALUES(2,NULL);\n    SELECT x FROM t4 WHERE y=NULL;\n  }\n} {}\nifcapable subquery {\n  do_test null-8.2 {\n    execsql {\n      SELECT x FROM t4 WHERE y IN (33,NULL);\n    }\n  } {}\n}\ndo_test null-8.3 {\n  execsql {\n    SELECT x FROM t4 WHERE y<33 ORDER BY x;\n  }\n} {1}\ndo_test null-8.4 {\n  execsql {\n    SELECT x FROM t4 WHERE y>6 ORDER BY x;\n  }\n} {1}\ndo_test null-8.5 {\n  execsql {\n    SELECT x FROM t4 WHERE y!=33 ORDER BY x;\n  }\n} {1}\ndo_test null-8.11 {\n  execsql {\n    CREATE INDEX t4i1 ON t4(y);\n    SELECT x FROM t4 WHERE y=NULL;\n  }\n} {}\nifcapable subquery {\n  do_test null-8.12 {\n    execsql {\n      SELECT x FROM t4 WHERE y IN (33,NULL);\n    }\n  } {}\n}\ndo_test null-8.13 {\n  execsql {\n    SELECT x FROM t4 WHERE y<33 ORDER BY x;\n  }\n} {1}\ndo_test null-8.14 {\n  execsql {\n    SELECT x FROM t4 WHERE y>6 ORDER BY x;\n  }\n} {1}\ndo_test null-8.15 {\n  execsql {\n    SELECT x FROM t4 WHERE y!=33 ORDER BY x;\n  }\n} {1}\n\ndo_execsql_test null-9.1 {\n  CREATE TABLE t5(a, b, c);\n  CREATE UNIQUE INDEX t5ab ON t5(a, b);\n\n  INSERT INTO t5 VALUES(1, NULL, 'one');\n  INSERT INTO t5 VALUES(1, NULL, 'i');\n  INSERT INTO t5 VALUES(NULL, 'x', 'two');\n  INSERT INTO t5 VALUES(NULL, 'x', 'ii');\n}\n\ndo_execsql_test null-9.2 {\n  SELECT * FROM t5 WHERE a = 1 AND b IS NULL;\n} {1 {} one 1 {} i}\n\ndo_execsql_test null-9.3 {\n  SELECT * FROM t5 WHERE a IS NULL AND b = 'x';\n} {{} x two {} x ii}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/numcast.test",
    "content": "# 2013 March 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n# This particular file does testing of casting strings into numeric\n# values.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nforeach enc {utf8 utf16le utf16be} {\n  do_test numcast-$enc.0 {\n    db close\n    sqlite3 db :memory:\n    db eval \"PRAGMA encoding='$enc'\"\n    set x [db eval {PRAGMA encoding}]\n    string map {- {}} [string tolower $x]\n  } $enc\n  foreach {idx str rval ival} {\n     1 12345.0       12345.0    12345\n     2 12345.0e0     12345.0    12345\n     3 -12345.0e0   -12345.0   -12345\n     4 -12345.25    -12345.25  -12345\n     5 { -12345.0}  -12345.0   -12345\n     6 { 876xyz}       876.0      876\n     7 { 456ķ89}       456.0      456\n     8 { Ġ 321.5}        0.0        0\n  } {\n    do_test numcast-$enc.$idx.1 {\n      db eval {SELECT CAST($str AS real)}\n    } $rval\n    do_test numcast-$enc.$idx.2 {\n      db eval {SELECT CAST($str AS integer)}\n    } $ival\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/numindex1.test",
    "content": "# 2015-11-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for indexes on large numeric values.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# Test cases from Zsbán Ambrus:\n#\ndo_execsql_test numindex1-1.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE INDEX t1b ON t1(b);\n  INSERT INTO t1(a,b) VALUES(100, 356282677878746339);\n  INSERT INTO t1(a,b) VALUES(50, 356282677878746339.0);\n  INSERT INTO t1(a,b) VALUES(0, 356282677878746340);\n  DELETE FROM t1 WHERE a=50;\n  PRAGMA integrity_check;\n} {ok}\n\ndo_execsql_test numindex1-1.2 {\n  CREATE TABLE t2(a,b);\n  INSERT INTO t2(a,b) VALUES('b', 1<<58),\n      ('c', (1<<58)+1e-7), ('d', (1<<58)+1);\n  SELECT a, b, typeof(b), '|' FROM t2 ORDER BY +a;\n} {b 288230376151711744 integer | c 2.88230376151712e+17 real | d 288230376151711745 integer |}\n\ndo_execsql_test numindex1-1.3 {\n  SELECT x.a || CASE WHEN x.b==y.b THEN '==' ELSE '<>' END || y.a\n    FROM t2 AS x, t2 AS y\n   ORDER BY +x.a, +x.b;\n} {b==b b==c b<>d c==b c==c c<>d d<>b d<>c d==d}\n\n# New test cases\n#\ndo_execsql_test numindex1-2.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY,b);\n  CREATE INDEX t1b ON t1(b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n  INSERT INTO t1(a,b) SELECT x, 10000000000000004.0 FROM c\n   WHERE x NOT IN (23,37);\n  INSERT INTO t1(a,b) VALUES(23,10000000000000005);\n  INSERT INTO t1(a,b) VALUES(37,10000000000000003);\n  DELETE FROM t1 WHERE a NOT IN (23,37);\n  PRAGMA integrity_check;\n} {ok}\n\ndo_execsql_test numindex1-3.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY,b);\n  CREATE INDEX t1b ON t1(b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)\n  INSERT INTO t1(a,b) SELECT x, 100000000000000005.0\n    FROM c WHERE x NOT IN (3,5,7,11,13,17,19);\n  INSERT INTO t1(a,b) VALUES(3,100000000000000005);\n  INSERT INTO t1(a,b) VALUES(5,100000000000000000);\n  INSERT INTO t1(a,b) VALUES(7,100000000000000008);\n  INSERT INTO t1(a,b) VALUES(11,100000000000000006);\n  INSERT INTO t1(a,b) VALUES(13,100000000000000001);\n  INSERT INTO t1(a,b) VALUES(17,100000000000000004);\n  INSERT INTO t1(a,b) VALUES(19,100000000000000003);\n  PRAGMA integrity_check;\n} {ok}\n\ndo_execsql_test numindex1-3.2 {\n  SELECT a FROM t1 ORDER BY b;\n} {1 2 4 5 6 8 9 10 12 14 15 16 18 20 13 19 17 3 11 7}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/offset1.test",
    "content": "# 2015-10-06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements test cases for the [b65cb2c8d91f6685841d7d1e13b6]\n# bug:  Correct handling of LIMIT and OFFSET on a UNION ALL query where\n# the right-hand SELECT contains an ORDER BY in a subquery.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_execsql_test offset1-1.1 {\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');\n  CREATE TABLE t2(x,y);\n  INSERT INTO t2 VALUES(8,'y'),(9,'z'),(6,'w'),(7,'x');\n  SELECT count(*) FROM t1, t2;\n} {20}\n\ndo_execsql_test offset1-1.2.0 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 0;\n} {1 a 2 b 3 c}\ndo_execsql_test offset1-1.2.1 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 1;\n} {2 b 3 c 4 d}\ndo_execsql_test offset1-1.2.2 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 2;\n} {3 c 4 d 5 e}\ndo_execsql_test offset1-1.2.3 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 3;\n} {4 d 5 e 6 w}\ndo_execsql_test offset1-1.2.4 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 4;\n} {5 e 6 w 7 x}\ndo_execsql_test offset1-1.2.5 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 5;\n} {6 w 7 x 8 y}\ndo_execsql_test offset1-1.2.6 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 6;\n} {7 x 8 y 9 z}\ndo_execsql_test offset1-1.2.7 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 7;\n} {8 y 9 z}\ndo_execsql_test offset1-1.2.8 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 8;\n} {9 z}\ndo_execsql_test offset1-1.2.9 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 9;\n} {}\n\ndo_execsql_test offset1-1.3.0 {\n  SELECT * FROM t1 LIMIT 0;\n} {}\n\ndo_execsql_test offset1-1.4.0 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 0 OFFSET 1;\n} {}\ndo_execsql_test offset1-1.4.1 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 1 OFFSET 1;\n} {2 b}\ndo_execsql_test offset1-1.4.2 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 2 OFFSET 1;\n} {2 b 3 c}\ndo_execsql_test offset1-1.4.3 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 3 OFFSET 1;\n} {2 b 3 c 4 d}\ndo_execsql_test offset1-1.4.4 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 4 OFFSET 1;\n} {2 b 3 c 4 d 5 e}\ndo_execsql_test offset1-1.4.5 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 5 OFFSET 1;\n} {2 b 3 c 4 d 5 e 6 w}\ndo_execsql_test offset1-1.4.6 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 6 OFFSET 1;\n} {2 b 3 c 4 d 5 e 6 w 7 x}\ndo_execsql_test offset1-1.4.7 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 7 OFFSET 1;\n} {2 b 3 c 4 d 5 e 6 w 7 x 8 y}\ndo_execsql_test offset1-1.4.8 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 8 OFFSET 1;\n} {2 b 3 c 4 d 5 e 6 w 7 x 8 y 9 z}\ndo_execsql_test offset1-1.4.9 {\n  SELECT a, b FROM t1\n  UNION ALL\n  SELECT * FROM (SELECT x, y FROM t2 ORDER BY y)\n  LIMIT 9 OFFSET 1;\n} {2 b 3 c 4 d 5 e 6 w 7 x 8 y 9 z}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/openv2.test",
    "content": "# 2007 Sep 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests on the sqlite3_open_v2() interface.\n#\n# $Id: openv2.test,v 1.2 2009/06/11 17:32:45 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndb close\nforcedelete test.db test.db-journal\ndo_test openv2-1.1 {\n  set rc [catch {sqlite3 db test.db -create 0} msg]\n  lappend rc $msg\n} {1 {unable to open database file}}\ndo_test openv2-1.2 {\n  info commands db\n} {}\ndo_test openv2-1.3 {\n  sqlite3 db test.db\n  db eval {CREATE TABLE t1(x)}\n  db close\n  sqlite3 db test.db -readonly 1\n  db eval {SELECT name FROM sqlite_master}\n} {t1}\ndo_test openv2-1.4 {\n  catchsql {\n    INSERT INTO t1 VALUES(123)\n  }\n} {1 {attempt to write a readonly database}}\n\n# Ticket #3908\n# Honor SQLITE_OPEN_READONLY even on an in-memory database, even though\n# this is pointless.\n#\ndo_test openv2-2.1 {\n  db close\n  sqlite3 db :memory: -readonly 1\n  db eval {SELECT * FROM sqlite_master}\n} {}\ndo_test openv2-2.2 {\n  catchsql {CREATE TABLE t1(x)}\n} {1 {attempt to write a readonly database}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby1.test",
    "content": "# 2012 Sept 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the optimizations that disable\n# ORDER BY clauses when the natural order of a query is correct.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby1\n\n# Generate test data for a join.  Verify that the join gets the\n# correct answer.\n#\ndo_test 1.0 {\n  db eval {\n    BEGIN;\n    CREATE TABLE album(\n      aid INTEGER PRIMARY KEY,\n      title TEXT UNIQUE NOT NULL\n    );\n    CREATE TABLE track(\n      tid INTEGER PRIMARY KEY,\n      aid INTEGER NOT NULL REFERENCES album,\n      tn INTEGER NOT NULL,\n      name TEXT,\n      UNIQUE(aid, tn)\n    );\n    INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');\n    INSERT INTO track VALUES\n        (NULL, 1, 1, 'one-a'),\n        (NULL, 2, 2, 'two-b'),\n        (NULL, 3, 3, 'three-c'),\n        (NULL, 1, 3, 'one-c'),\n        (NULL, 2, 1, 'two-a'),\n        (NULL, 3, 1, 'three-a');\n    COMMIT;\n  }\n} {}\ndo_test 1.1a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\n\n# Verify that the ORDER BY clause is optimized out\n#\ndo_test 1.1b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn\n  }\n} {~/ORDER BY/}  ;# ORDER BY optimized out\n\n# The same query with ORDER BY clause optimization disabled via + operators\n# should give exactly the same answer.\n#\ndo_test 1.2a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\n\n# The output is sorted manually in this case.\n#\ndo_test 1.2b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to \"+\" on ORDER BY terms\n\n# The same query with ORDER BY optimizations turned off via built-in test.\n#\ndo_test 1.3a {\n  optimization_control db order-by-idx-join 0\n  db cache flush\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\ndo_test 1.3b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to disabled optimization\noptimization_control db all 1\ndb cache flush\n\n# Reverse order sorts\n#\ndo_test 1.4a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {three-a three-c two-a two-b one-a one-c}\ndo_test 1.4b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn\n  }\n} {three-a three-c two-a two-b one-a one-c}  ;# verify same order after sorting\ndo_test 1.4c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {~/ORDER BY/}  ;# ORDER BY suppressed due to uniqueness constraints\n\ndo_test 1.5a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}\ndo_test 1.5b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}  ;# verify same order after sorting\ndo_test 1.5c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {~/ORDER BY/}  ;# ORDER BY suppressed due to uniqueness constraints\n\ndo_test 1.6a {\n  db eval {\n    SELECT name FROM album CROSS JOIN track USING (aid)\n     ORDER BY title DESC, tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}\ndo_test 1.6b {\n  db eval {\n    SELECT name FROM album CROSS JOIN track USING (aid)\n     ORDER BY +title DESC, +tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}  ;# verify same order after sorting\ndo_test 1.6c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album CROSS JOIN track USING (aid)\n     ORDER BY title DESC, tn DESC\n  }\n} {~/ORDER BY/}  ;# ORDER BY \n\n\n# Reconstruct the test data to use indices rather than integer primary keys.\n#\ndo_test 2.0 {\n  db eval {\n    BEGIN;\n    DROP TABLE album;\n    DROP TABLE track;\n    CREATE TABLE album(\n      aid INT PRIMARY KEY,\n      title TEXT NOT NULL\n    );\n    CREATE INDEX album_i1 ON album(title, aid);\n    CREATE TABLE track(\n      aid INTEGER NOT NULL REFERENCES album,\n      tn INTEGER NOT NULL,\n      name TEXT,\n      UNIQUE(aid, tn)\n    );\n    INSERT INTO album VALUES(1, '1-one'), (20, '2-two'), (3, '3-three');\n    INSERT INTO track VALUES\n        (1,  1, 'one-a'),\n        (20, 2, 'two-b'),\n        (3,  3, 'three-c'),\n        (1,  3, 'one-c'),\n        (20, 1, 'two-a'),\n        (3,  1, 'three-a');\n    COMMIT;\n  }\n} {}\ndo_test 2.1a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\n\n# Verify that the ORDER BY clause is optimized out\n#\ndo_test 2.1b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {/ORDER BY/}  ;# ORDER BY required because of missing aid term in ORDER BY\n\ndo_test 2.1c {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\ndo_test 2.1d {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, aid, tn\n  }\n} {/ORDER BY/}  ;# ORDER BY required in this case\n\n# The same query with ORDER BY clause optimization disabled via + operators\n# should give exactly the same answer.\n#\ndo_test 2.2a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\n\n# The output is sorted manually in this case.\n#\ndo_test 2.2b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to \"+\" on ORDER BY terms\n\n# The same query with ORDER BY optimizations turned off via built-in test.\n#\ndo_test 2.3a {\n  optimization_control db order-by-idx-join 0\n  db cache flush\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\ndo_test 2.3b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to disabled optimization\noptimization_control db all 1\ndb cache flush\n\n# Reverse order sorts\n#\ndo_test 2.4a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {three-a three-c two-a two-b one-a one-c}\ndo_test 2.4b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn\n  }\n} {three-a three-c two-a two-b one-a one-c}  ;# verify same order after sorting\ndo_test 2.4c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {/ORDER BY/}  ;# separate sorting pass due to mixed DESC/ASC\n\n\ndo_test 2.5a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}\ndo_test 2.5b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}  ;# verify same order after sorting\ndo_test 2.5c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {/ORDER BY/}  ;# separate sorting pass due to mixed ASC/DESC\n\ndo_test 2.6a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}\ndo_test 2.6b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}  ;# verify same order after sorting\ndo_test 2.6c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC\n  }\n} {/ORDER BY/}  ;# ORDER BY required\n\n\n# Generate another test dataset, but this time using mixed ASC/DESC indices.\n#\ndo_test 3.0 {\n  db eval {\n    BEGIN;\n    DROP TABLE album;\n    DROP TABLE track;\n    CREATE TABLE album(\n      aid INTEGER PRIMARY KEY,\n      title TEXT UNIQUE NOT NULL\n    );\n    CREATE TABLE track(\n      tid INTEGER PRIMARY KEY,\n      aid INTEGER NOT NULL REFERENCES album,\n      tn INTEGER NOT NULL,\n      name TEXT,\n      UNIQUE(aid ASC, tn DESC)\n    );\n    INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');\n    INSERT INTO track VALUES\n        (NULL, 1, 1, 'one-a'),\n        (NULL, 2, 2, 'two-b'),\n        (NULL, 3, 3, 'three-c'),\n        (NULL, 1, 3, 'one-c'),\n        (NULL, 2, 1, 'two-a'),\n        (NULL, 3, 1, 'three-a');\n    COMMIT;\n  }\n} {}\ndo_test 3.1a {\n  db eval {\n    SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}\n\n# Verify that the ORDER BY clause is optimized out\n#\ndo_test 3.1b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {~/ORDER BY/}  ;# ORDER BY optimized out\n\n# The same query with ORDER BY clause optimization disabled via + operators\n# should give exactly the same answer.\n#\ndo_test 3.2a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}\n\n# The output is sorted manually in this case.\n#\ndo_test 3.2b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn DESC\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to \"+\" on ORDER BY terms\n\n# The same query with ORDER BY optimizations turned off via built-in test.\n#\ndo_test 3.3a {\n  optimization_control db order-by-idx-join 0\n  db cache flush\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {one-c one-a two-b two-a three-c three-a}\ndo_test 3.3b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn DESC\n  }\n} {/ORDER BY/}   ;# separate sorting pass due to disabled optimization\noptimization_control db all 1\ndb cache flush\n\n# Without the mixed ASC/DESC on ORDER BY\n#\ndo_test 3.4a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {one-a one-c two-a two-b three-a three-c}\ndo_test 3.4b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title, +tn\n  }\n} {one-a one-c two-a two-b three-a three-c}  ;# verify same order after sorting\ndo_test 3.4c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title, tn\n  }\n} {~/ORDER BY/}  ;# ORDER BY suppressed by uniqueness constraints\n\ndo_test 3.5a {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}\ndo_test 3.5b {\n  db eval {\n    SELECT name FROM album JOIN track USING (aid) ORDER BY +title DESC, +tn DESC\n  }\n} {three-c three-a two-b two-a one-c one-a}  ;# verify same order after sorting\ndo_test 3.5c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album JOIN track USING (aid) ORDER BY title DESC, tn DESC\n  }\n} {~/ORDER BY/}  ;# ORDER BY suppressed by uniqueness constraints\n\n\ndo_test 3.6a {\n  db eval {\n    SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {three-a three-c two-a two-b one-a one-c}\ndo_test 3.6b {\n  db eval {\n    SELECT name FROM album CROSS JOIN track USING (aid)\n     ORDER BY +title DESC, +tn\n  }\n} {three-a three-c two-a two-b one-a one-c}  ;# verify same order after sorting\ndo_test 3.6c {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT name FROM album CROSS JOIN track USING (aid) ORDER BY title DESC, tn\n  }\n} {~/ORDER BY/}  ;# inverted ASC/DESC is optimized out\n\n# Ticket 5ed1772895bf3deeab78c5e3519b1da9165c541b (2013-06-04)\n# Incorrect ORDER BY on an indexed JOIN\n#\ndo_test 4.0 {\n  db eval {\n    CREATE TABLE t41(a INT UNIQUE NOT NULL, b INT NOT NULL);\n    CREATE INDEX t41ba ON t41(b,a);\n    CREATE TABLE t42(x INT NOT NULL REFERENCES t41(a), y INT NOT NULL);\n    CREATE UNIQUE INDEX t42xy ON t42(x,y);\n    INSERT INTO t41 VALUES(1,1),(3,1);\n    INSERT INTO t42 VALUES(1,13),(1,15),(3,14),(3,16);\n    \n    SELECT b, y FROM t41 CROSS JOIN t42 ON x=a ORDER BY b, y;\n  }\n} {1 13 1 14 1 15 1 16}\n\n# No sorting of queries that omit the FROM clause.\n#\ndo_execsql_test 5.0 {\n  EXPLAIN QUERY PLAN SELECT 5 ORDER BY 1\n} {}\ndo_execsql_test 5.1 {\n  EXPLAIN QUERY PLAN SELECT 5 UNION ALL SELECT 3 ORDER BY 1\n} {~/B-TREE/}\ndo_execsql_test 5.2 {\n  SELECT 5 UNION ALL SELECT 3 ORDER BY 1\n} {3 5}\ndo_execsql_test 5.3 {\n  SELECT 986 AS x GROUP BY X ORDER BY X\n} {986}\n\n# The following test (originally derived from a single test within fuzz.test)\n# verifies that a PseudoTable cursor is not closed prematurely in a deeply\n# nested query.  This test caused a segfault on 3.8.5 beta.\n#\ndo_execsql_test 6.0 {\n  CREATE TABLE abc(a, b, c);\n  INSERT INTO abc VALUES(1, 2, 3);\n  INSERT INTO abc VALUES(4, 5, 6);\n  INSERT INTO abc VALUES(7, 8, 9);\n  SELECT (\n    SELECT 'hardware' FROM ( \n      SELECT 'software' ORDER BY 'firmware' ASC, 'sportswear' DESC \n    ) GROUP BY 1 HAVING length(b)\n  )\n  FROM abc;\n} {hardware hardware hardware}\n\n# Here is a test for a query-planner problem reported on the SQLite\n# mailing list on 2014-09-18 by \"Merike\".  Beginning with version 3.8.0,\n# a separate sort was being used rather than using the single-column\n# index.  This was due to an oversight in the indexMightHelpWithOrderby()\n# routine in where.c.\n#\ndo_execsql_test 7.0 {\n  CREATE TABLE t7(a,b);\n  CREATE INDEX t7a ON t7(a);\n  CREATE INDEX t7ab ON t7(a,b);\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t7 WHERE a=?1 ORDER BY rowid;\n} {~/ORDER BY/}\n\n#-------------------------------------------------------------------------\n# Test a partial sort large enough to cause the sorter to spill data\n# to disk.\n#\nreset_db\ndo_execsql_test 8.0 {\n  PRAGMA cache_size = 5;\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n}\n\ndo_eqp_test 8.1 {\n  SELECT * FROM t1 ORDER BY a, b;\n} {\n  0 0 0 {SCAN TABLE t1 USING INDEX i1} \n  0 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n}\n\ndo_execsql_test 8.2 {\n  WITH cnt(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<10000\n  )\n  INSERT INTO t1 SELECT i%2, randomblob(500) FROM cnt;\n}\n\ndo_test 8.3 {\n  db eval { SELECT * FROM t1 ORDER BY a, b } { incr res $a }\n  set res\n} 5000\n\n#---------------------------------------------------------------------------\n# https://www.sqlite.org/src/tktview/cb3aa0641d9a413841c004293a4fc06cdc122029\n#\n# Adverse interaction between scalar subqueries and the partial-sorting\n# logic.\n#\ndo_execsql_test 9.0 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x INTEGER PRIMARY KEY);\n  INSERT INTO t1 VALUES(1),(2);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(y);\n  INSERT INTO t2 VALUES(9),(8),(3),(4);\n  SELECT (SELECT x||y FROM t2, t1 ORDER BY x, y);\n} {13}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby2.test",
    "content": "# 2012 Sept 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the optimizations that disable\n# ORDER BY clauses when the natural order of a query is correct.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby2\n\n# Generate test data for a join.  Verify that the join gets the\n# correct answer.\n#\ndo_test 1.0 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1,11), (2,22);\n    CREATE TABLE t2(d, e, UNIQUE(d,e));\n    INSERT INTO t2 VALUES(10, 'ten'), (11,'eleven'), (12,'twelve'),\n                         (11, 'oneteen');\n  }\n} {}\n\ndo_test 1.1a {\n  db eval {\n    SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY d, e;\n  }\n} {eleven oneteen}\ndo_test 1.1b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY d, e;\n  }\n} {~/ORDER BY/}\n\ndo_test 1.2a {\n  db eval {\n    SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY e;\n  }\n} {eleven oneteen}\ndo_test 1.2b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT e FROM t1, t2 WHERE a=1 AND d=b ORDER BY e;\n  }\n} {~/ORDER BY/}\n\ndo_test 1.3a {\n  db eval {\n    SELECT e, b FROM t1, t2 WHERE a=1 ORDER BY d, e;\n  }\n} {ten 11 eleven 11 oneteen 11 twelve 11}\ndo_test 1.3b {\n  db eval {\n    EXPLAIN QUERY PLAN\n    SELECT e, b FROM t1, t2 WHERE a=1 ORDER BY d, e;\n  }\n} {~/ORDER BY/}\n\n# The following tests derived from TH3 test module cov1/where34.test\n#\ndo_test 2.0 {\n  db eval {\n    CREATE TABLE t31(a,b); CREATE INDEX t31ab ON t31(a,b);\n    CREATE TABLE t32(c,d); CREATE INDEX t32cd ON t32(c,d);\n    CREATE TABLE t33(e,f); CREATE INDEX t33ef ON t33(e,f);\n    CREATE TABLE t34(g,h); CREATE INDEX t34gh ON t34(g,h);\n    \n    INSERT INTO t31 VALUES(1,4), (2,3), (1,3);\n    INSERT INTO t32 VALUES(4,5), (3,6), (3,7), (4,8);\n    INSERT INTO t33 VALUES(5,9), (7,10), (6,11), (8,12), (8,13), (7,14);\n    INSERT INTO t34 VALUES(11,20), (10,21), (12,22), (9,23), (13,24),\n                          (14,25), (12,26);\n    SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34\n     WHERE c=b AND e=d AND g=f\n     ORDER BY a ASC, c ASC, e DESC, g ASC;\n  }\n} {1,3,7,10 1,3,7,14 1,3,6,11 1,4,8,12 1,4,8,12 1,4,8,13 1,4,5,9 2,3,7,10 2,3,7,14 2,3,6,11}\ndo_test 2.1 {\n  db eval {\n    SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34\n     WHERE c=b AND e=d AND g=f\n     ORDER BY +a ASC, +c ASC, +e DESC, +g ASC;\n  }\n} {1,3,7,10 1,3,7,14 1,3,6,11 1,4,8,12 1,4,8,12 1,4,8,13 1,4,5,9 2,3,7,10 2,3,7,14 2,3,6,11}\ndo_test 2.2 {\n  db eval {\n    SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34\n     WHERE c=b AND e=d AND g=f\n     ORDER BY a ASC, c ASC, e ASC, g ASC;\n  }\n} {1,3,6,11 1,3,7,10 1,3,7,14 1,4,5,9 1,4,8,12 1,4,8,12 1,4,8,13 2,3,6,11 2,3,7,10 2,3,7,14}\ndo_test 2.3 {\n  optimization_control db cover-idx-scan off\n  db cache flush\n  db eval {\n    SELECT a||','||c||','||e||','||g FROM t31, t32, t33, t34\n     WHERE c=b AND e=d AND g=f\n     ORDER BY a ASC, c ASC, e ASC, g ASC;\n  }\n} {1,3,6,11 1,3,7,10 1,3,7,14 1,4,5,9 1,4,8,12 1,4,8,12 1,4,8,13 2,3,6,11 2,3,7,10 2,3,7,14}  \noptimization_control db all on\ndb cache flush\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby3.test",
    "content": "# 2013 January 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the optimizations that disable\n# ORDER BY clauses work correctly on a 3-way join.  See ticket\n# http://www.sqlite.org/src/956e4d7f89\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby3\n\n# Generate test data for a join.  Verify that the join gets the\n# correct answer.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY);\n  CREATE TABLE t2(b INTEGER PRIMARY KEY, c INTEGER);\n  CREATE TABLE t3(d INTEGER);\n    \n  INSERT INTO t1 VALUES(1),(2),(3);\n    \n  INSERT INTO t2 VALUES(3, 1);\n  INSERT INTO t2 VALUES(4, 2);\n  INSERT INTO t2 VALUES(5, 3);\n    \n  INSERT INTO t3 VALUES(4),(3),(5);\n} {}\ndo_execsql_test 1.1.asc {\n  SELECT t1.a\n    FROM t1, t2, t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.1.desc {\n  SELECT t1.a\n    FROM t1, t2, t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.123.asc {\n  SELECT t1.a\n    FROM t1 CROSS JOIN t2 CROSS JOIN t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.123.desc {\n  SELECT t1.a\n    FROM t1 CROSS JOIN t2 CROSS JOIN t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.132.asc {\n  SELECT t1.a\n    FROM t1 CROSS JOIN t3 CROSS JOIN t2\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.132.desc {\n  SELECT t1.a\n    FROM t1 CROSS JOIN t3 CROSS JOIN t2\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.213.asc {\n  SELECT t1.a\n    FROM t2 CROSS JOIN t1 CROSS JOIN t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.213.desc {\n  SELECT t1.a\n    FROM t2 CROSS JOIN t1 CROSS JOIN t3\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.231.asc {\n  SELECT t1.a\n    FROM t2 CROSS JOIN t3 CROSS JOIN t1\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.231.desc {\n  SELECT t1.a\n    FROM t2 CROSS JOIN t3 CROSS JOIN t1\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.312.asc {\n  SELECT t1.a\n    FROM t3 CROSS JOIN t1 CROSS JOIN t2\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.312.desc {\n  SELECT t1.a\n    FROM t3 CROSS JOIN t1 CROSS JOIN t2\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\ndo_execsql_test 1.321.asc {\n  SELECT t1.a\n    FROM t3 CROSS JOIN t2 CROSS JOIN t1\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a;\n} {1 2 3}\ndo_execsql_test 1.321.desc {\n  SELECT t1.a\n    FROM t3 CROSS JOIN t2 CROSS JOIN t1\n   WHERE t1.a=t2.c AND t2.b=t3.d\n   ORDER BY t1.a DESC;\n} {3 2 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby4.test",
    "content": "# 2013 March 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the optimizations that disable\n# ORDER BY clauses work correctly on multi-value primary keys and\n# unique indices when only some prefix of the terms in the key are\n# used.  See ticket http://www.sqlite.org/src/info/a179fe74659\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby4\n\n# Generate test data for a join.  Verify that the join gets the\n# correct answer.\n#\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(a,b));\n  INSERT INTO t1 VALUES(1,1),(1,2);\n  CREATE TABLE t2(x, y, PRIMARY KEY(x,y));\n  INSERT INTO t2 VALUES(3,3),(4,4);\n  SELECT a, x FROM t1, t2 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\ndo_execsql_test 1.2 {\n  SELECT a, x FROM t1 CROSS JOIN t2 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\ndo_execsql_test 1.3 {\n  SELECT a, x FROM t2 CROSS JOIN t1 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t3(a);\n  INSERT INTO t3 VALUES(1),(1);\n  CREATE INDEX t3a ON t3(a);\n  CREATE TABLE t4(x);\n  INSERT INTO t4 VALUES(3),(4);\n  CREATE INDEX t4x ON t4(x);\n  SELECT a, x FROM t3, t4 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\ndo_execsql_test 2.2 {\n  SELECT a, x FROM t3 CROSS JOIN t4 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\ndo_execsql_test 2.3 {\n  SELECT a, x FROM t4 CROSS JOIN t3 ORDER BY 1, 2;\n} {1 3 1 3 1 4 1 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby5.test",
    "content": "# 2013-06-14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the optimizations that disable\n# ORDER BY clauses work correctly\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby5\n\n# Generate test data for a join.  Verify that the join gets the\n# correct answer.\n#\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b,c);\n  CREATE INDEX t1bc ON t1(b,c);\n\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT a, b, c FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.2.1 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT a, c, b FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT a, c, b FROM t1 WHERE a='xyz' COLLATE nocase;\n} {/B-TREE/}\ndo_execsql_test 1.2.3 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz';\n} {/B-TREE/}\ndo_execsql_test 1.2.4 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz' COLLATE nocase;\n} {~/B-TREE/}\ndo_execsql_test 1.3 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT b, a, c FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.4 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT b, c, a FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.5 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT c, a, b FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.6 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT c, b, a FROM t1 WHERE a=0;\n} {~/B-TREE/}\ndo_execsql_test 1.7 {\n  EXPLAIN QUERY PLAN\n  SELECT DISTINCT c, b, a FROM t1 WHERE +a=0;\n} {/B-TREE/}\n\n# In some cases, it is faster to do repeated index lookups than it is to\n# sort.  But in other cases, it is faster to sort than to do repeated index\n# lookups.\n#\ndo_execsql_test 2.1a {\n  CREATE TABLE t2(a,b,c);\n  CREATE INDEX t2bc ON t2(b,c);\n  ANALYZE;\n  INSERT INTO sqlite_stat1 VALUES('t1','t1bc','1000000 10 9');\n  INSERT INTO sqlite_stat1 VALUES('t2','t2bc','100 10 5');\n  ANALYZE sqlite_master;\n\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t2 WHERE a=0 ORDER BY a, b, c;\n} {~/B-TREE/}\n\ndo_execsql_test 2.1b {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE likelihood(a=0, 0.05) ORDER BY a, b, c;\n} {/B-TREE/}\n\ndo_execsql_test 2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE +a=0 ORDER BY a, b, c;\n} {/B-TREE/}\ndo_execsql_test 2.3 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a=0 ORDER BY b, a, c;\n} {~/B-TREE/}\ndo_execsql_test 2.4 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a=0 ORDER BY b, c, a;\n} {~/B-TREE/}\ndo_execsql_test 2.5 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a=0 ORDER BY a, c, b;\n} {/B-TREE/}\ndo_execsql_test 2.6 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a=0 ORDER BY c, a, b;\n} {/B-TREE/}\ndo_execsql_test 2.7 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1 WHERE a=0 ORDER BY c, b, a;\n} {/B-TREE/}\n\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f);\n  CREATE INDEX t3bcde ON t3(b, c, d, e);\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;\n} {~/B-TREE/}\ndo_execsql_test 3.1 {\n  DROP TABLE t3;\n  CREATE TABLE t3(a INTEGER PRIMARY KEY, b, c, d, e, f) WITHOUT rowid;\n  CREATE INDEX t3bcde ON t3(b, c, d, e);\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t3 WHERE b=2 AND c=3 ORDER BY d DESC, e DESC, b, c, a DESC;\n} {~/B-TREE/}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby6.test",
    "content": "# 2014-03-21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the block-sort optimization.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby6\n\n# Run all tests twice.  Once with a normal table and a second time\n# with a WITHOUT ROWID table\n#\nforeach {tn rowidclause} {1 {} 2 {WITHOUT ROWID}} {\n\n  # Construct a table with 1000 rows and a split primary key\n  #\n  reset_db\n  do_test $tn.1 {\n    db eval \"CREATE TABLE t1(a,b,c,PRIMARY KEY(b,c)) $rowidclause;\"\n    db eval {\n      WITH RECURSIVE\n       cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<1000)\n     INSERT INTO t1 SELECT x, x%40, x/40 FROM cnt;\n    }\n  } {}\n\n  # Run various ORDER BY queries that can benefit from block-sort.\n  # Compare the output to the same output using a full-sort enforced\n  # by adding + to each term of the ORDER BY clause.\n  #\n  do_execsql_test $tn.2 {\n    SELECT b,a,c FROM t1 ORDER BY b,a,c;\n  } [db eval {SELECT b,a,c FROM t1 ORDER BY +b,+a,+c}]\n  do_execsql_test $tn.3 {\n    SELECT b,a,c FROM t1 ORDER BY b,c DESC,a;\n  } [db eval {SELECT b,a,c FROM t1 ORDER BY +b,+c DESC,+a}]\n  do_execsql_test $tn.4 {\n    SELECT b,a,c FROM t1 ORDER BY b DESC,c,a;\n  } [db eval {SELECT b,a,c FROM t1 ORDER BY +b DESC,+c,+a}]\n  do_execsql_test $tn.5 {\n    SELECT b,a,c FROM t1 ORDER BY b DESC,a,c;\n  } [db eval {SELECT b,a,c FROM t1 ORDER BY +b DESC,+a,+c}]\n\n  # LIMIT and OFFSET clauses on block-sort queries.\n  #\n  do_execsql_test $tn.11 {\n    SELECT a FROM t1 ORDER BY b, a LIMIT 10 OFFSET 20;\n  } {840 880 920 960 1000 1 41 81 121 161}\n  do_execsql_test $tn.11x {\n    SELECT a FROM t1 ORDER BY +b, a LIMIT 10 OFFSET 20;\n  } {840 880 920 960 1000 1 41 81 121 161}\n\n  do_execsql_test $tn.12 {\n    SELECT a FROM t1 ORDER BY b DESC, a LIMIT 10 OFFSET 20;\n  } {839 879 919 959 999 38 78 118 158 198}\n  do_execsql_test $tn.12 {\n    SELECT a FROM t1 ORDER BY +b DESC, a LIMIT 10 OFFSET 20;\n  } {839 879 919 959 999 38 78 118 158 198}\n\n  do_execsql_test $tn.13 {\n    SELECT a FROM t1 ORDER BY b, a DESC LIMIT 10 OFFSET 45;\n  } {161 121 81 41 1 962 922 882 842 802}\n  do_execsql_test $tn.13x {\n    SELECT a FROM t1 ORDER BY +b, a DESC LIMIT 10 OFFSET 45;\n  } {161 121 81 41 1 962 922 882 842 802}\n\n  do_execsql_test $tn.14 {\n    SELECT a FROM t1 ORDER BY b DESC, a LIMIT 10 OFFSET 45;\n  } {838 878 918 958 998 37 77 117 157 197}\n  do_execsql_test $tn.14x {\n    SELECT a FROM t1 ORDER BY +b DESC, a LIMIT 10 OFFSET 45;\n  } {838 878 918 958 998 37 77 117 157 197}\n\n  # Many test cases where the LIMIT+OFFSET window is in various\n  # alignments with block-sort boundaries.\n  #\n  foreach {tx limit offset orderby} {\n     1  10 24 {+b,+a}\n     2  10 25 {+b,+a}\n     3  10 26 {+b,+a}\n     4  10 39 {+b,+a}\n     5  10 40 {+b,+a}\n     6  10 41 {+b,+a}\n     7  27 24 {+b,+a}\n     8  27 49 {+b,+a}\n     11 10 24 {+b DESC,+a}\n     12 10 25 {+b DESC,+a}\n     13 10 26 {+b DESC,+a}\n     14 10 39 {+b DESC,+a}\n     15 10 40 {+b DESC,+a}\n     16 10 41 {+b DESC,+a}\n     17 27 24 {+b DESC,+a}\n     18 27 49 {+b DESC,+a}\n     21 10 24 {+b,+a DESC}\n     22 10 25 {+b,+a DESC}\n     23 10 26 {+b,+a DESC}\n     24 10 39 {+b,+a DESC}\n     25 10 40 {+b,+a DESC}\n     26 10 41 {+b,+a DESC}\n     27 27 24 {+b,+a DESC}\n     28 27 49 {+b,+a DESC}\n     31 10 24 {+b DESC,+a DESC}\n     32 10 25 {+b DESC,+a DESC}\n     33 10 26 {+b DESC,+a DESC}\n     34 10 39 {+b DESC,+a DESC}\n     35 10 40 {+b DESC,+a DESC}\n     36 10 41 {+b DESC,+a DESC}\n     37 27 24 {+b DESC,+a DESC}\n     38 27 49 {+b DESC,+a DESC}\n  } {\n    set sql1 \"SELECT a FROM t1 ORDER BY $orderby LIMIT $limit OFFSET $offset;\"\n    set sql2 [string map {+ {}} $sql1]\n    # puts $sql2\\n$sql1\\n[db eval $sql2]\n    do_test $tn.21.$tx {db eval $::sql2} [db eval $sql1]\n  }\n\n  ########################################################################\n  # A second test table, t2, has many columns open to sorting.\n  do_test $tn.31 {\n    db eval \"CREATE TABLE t2(a,b,c,d,e,f,PRIMARY KEY(b,c,d,e,f)) $rowidclause;\"\n    db eval {\n      WITH RECURSIVE\n       cnt(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM cnt WHERE x<242)\n     INSERT INTO t2 SELECT x,  x%3, (x/3)%3, (x/9)%3, (x/27)%3, (x/81)%3\n                      FROM cnt;\n    }\n  } {}\n\n  do_execsql_test $tn.32 {\n    SELECT a FROM t2 ORDER BY b,c,d,e,f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]\n  do_execsql_test $tn.33 {\n    SELECT a FROM t2 ORDER BY b,c,d,e,+f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]\n  do_execsql_test $tn.34 {\n    SELECT a FROM t2 ORDER BY b,c,d,+e,+f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]\n  do_execsql_test $tn.35 {\n    SELECT a FROM t2 ORDER BY b,c,+d,+e,+f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]\n  do_execsql_test $tn.36 {\n    SELECT a FROM t2 ORDER BY b,+c,+d,+e,+f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f;}]\n\n  do_execsql_test $tn.37 {\n    SELECT a FROM t2 ORDER BY b,c,d,e,f DESC;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f DESC;}]\n  do_execsql_test $tn.38 {\n    SELECT a FROM t2 ORDER BY b,c,d,e DESC,f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e DESC,+f;}]\n  do_execsql_test $tn.39 {\n    SELECT a FROM t2 ORDER BY b,c,d DESC,e,f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d DESC,+e,+f;}]\n  do_execsql_test $tn.40 {\n    SELECT a FROM t2 ORDER BY b,c DESC,d,e,f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c DESC,+d,+e,+f;}]\n  do_execsql_test $tn.41 {\n    SELECT a FROM t2 ORDER BY b DESC,c,d,e,f;\n  } [db eval {SELECT a FROM t2 ORDER BY +b DESC,+c,+d,+e,+f;}]\n\n  do_execsql_test $tn.42 {\n    SELECT a FROM t2 ORDER BY b DESC,c DESC,d,e,f LIMIT 31;\n  } [db eval {SELECT a FROM t2 ORDER BY +b DESC,+c DESC,+d,+e,+f LIMIT 31}]\n  do_execsql_test $tn.43 {\n    SELECT a FROM t2 ORDER BY b,c,d,e,f DESC LIMIT 8 OFFSET 7;\n  } [db eval {SELECT a FROM t2 ORDER BY +b,+c,+d,+e,+f DESC LIMIT 8 OFFSET 7}]\n\n\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby7.test",
    "content": "# 2014-04-25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing ORDER BY optimizations on joins\n# that involve virtual tables.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby7\n\nifcapable !fts3 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE fts USING fts3(content TEXT);\n  INSERT INTO fts(rowid,content)\n     VALUES(1,'this is a test of the fts3 virtual'),\n           (2,'table used as part of a join together'),\n           (3,'with the DISTINCT keyword.  There was'),\n           (4,'a bug at one time (2013-06 through 2014-04)'),\n           (5,'that prevented this from working correctly.'),\n           (11,'a row that occurs twice'),\n           (12,'a row that occurs twice');\n \n  CREATE TABLE t1(x TEXT PRIMARY KEY, y);\n  INSERT OR IGNORE INTO t1 SELECT content, rowid+100 FROM fts;\n} {}\ndo_execsql_test 1.1 {\n  SELECT DISTINCT fts.rowid, t1.y\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x\n   ORDER BY y;\n} {11 111 12 111}\ndo_execsql_test 1.2 {\n  SELECT DISTINCT fts.rowid, t1.x\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x\n   ORDER BY 1;\n} {11 {a row that occurs twice} 12 {a row that occurs twice}}\ndo_execsql_test 1.3 {\n  SELECT DISTINCT t1.x\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x\n   ORDER BY 1;\n} {{a row that occurs twice}}\ndo_execsql_test 1.4 {\n  SELECT t1.x\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x\n   ORDER BY 1;\n} {{a row that occurs twice} {a row that occurs twice}}\ndo_execsql_test 1.5 {\n  SELECT DISTINCT t1.x\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x;\n} {{a row that occurs twice}}\ndo_execsql_test 1.6 {\n  SELECT t1.x\n    FROM fts, t1\n   WHERE fts MATCH 'that twice'\n     AND content=x;\n} {{a row that occurs twice} {a row that occurs twice}}\n\ndo_execsql_test 2.1 {\n  SELECT DISTINCT t1.x\n    FROM fts, t1\n   WHERE fts.rowid=11\n     AND content=x\n   ORDER BY fts.rowid;\n} {{a row that occurs twice}}\ndo_execsql_test 2.2 {\n  SELECT DISTINCT t1.*\n    FROM fts, t1\n   WHERE fts.rowid=11\n     AND content=x\n   ORDER BY fts.rowid;\n} {{a row that occurs twice} 111}\ndo_execsql_test 2.3 {\n  SELECT DISTINCT t1.*\n    FROM fts, t1\n   WHERE fts.rowid=11\n     AND content=x\n   ORDER BY t1.y\n} {{a row that occurs twice} 111}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby8.test",
    "content": "# 2015-01-19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing ORDER BY and LIMIT on tables with\n# many columns.\n#\n# These tests verify that ticket [f97c4637102a3ae72b7911167e1d4da12ce60722]\n# from 2015-01-19 has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby8\n\ndo_test 1.0 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1(x) VALUES(1),(5),(9),(7),(3),(2),(4),(6),(8);\n  }\n  set ::result_set \"x\"\n} {x}\nfor {set i 1} {$i<200} {incr i} {\n  append ::result_set \", x+$i\"\n  do_test 1.$i {\n    set res {}\n    db eval \"SELECT $::result_set FROM t1 ORDER BY x LIMIT -1\" {\n      lappend res $x\n    }\n    set res\n  } {1 2 3 4 5 6 7 8 9}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/orderby9.test",
    "content": "# 2015-08-26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# \n# This file seeks to verify that expressions (and especially functions)\n# that are in both the ORDER BY clause and the result set are only\n# evaluated once.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix orderby9\n\n\ndo_execsql_test setup {\n  -- create a table with many entries\n  CREATE TABLE t1(x);\n  WITH RECURSIVE\n     c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n  INSERT INTO t1 SELECT x FROM c;\n}\n\n# Some versions of TCL are unable to [lsort -int] for\n# 64-bit integers.  So we write our own comparison\n# routine.\nproc bigintcompare {a b} {\n  set x [expr {$a-$b}]\n  if {$x<0} {return -1}\n  if {$x>0} {return +1}\n  return 0\n}\ndo_test 1.0 {\n  set l1 {}\n  # If random() is only evaluated once and then reused for each row, then\n  # the output should appear in sorted order.  If random() is evaluated \n  # separately for the result set and the ORDER BY clause, then the output\n  # order will be random.\n  db eval {SELECT random() AS y FROM t1 ORDER BY 1;} {lappend l1 $y}\n  expr {$l1==[lsort -command bigintcompare $l1]}\n} {1}\n\ndo_test 1.1 {\n  set l1 {}\n  db eval {SELECT random() AS y FROM t1 ORDER BY random();} {lappend l1 $y}\n  expr {$l1==[lsort -command bigintcompare $l1]}\n} {1}\n\ndo_test 1.2 {\n  set l1 {}\n  db eval {SELECT random() AS y FROM t1 ORDER BY +random();} {lappend l1 $y}\n  expr {$l1==[lsort -command bigintcompare $l1]}\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/oserror.test",
    "content": "# 2011 February 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that error messages are logged via the\n# sqlite3_log() mechanism when certain errors are encountered in the\n# default unix or windows VFS modules.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nif {$::tcl_platform(platform)!=\"unix\"} { finish_test ; return }\nset ::testprefix oserror\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log xLog\nproc xLog {error_code msg} {\n  if {[string match os_* $msg]} {\n    lappend ::log $msg \n  }\n}\n\nproc do_re_test {tn script expression} {\n  uplevel do_test $tn [list [subst -nocommands {\n    set res [eval { $script }]\n    if {[regexp {$expression} [set res]]} {\n      set {} {$expression}\n    } else {\n      set res\n    }\n  }]] [list $expression]\n  \n}\n\n#--------------------------------------------------------------------------\n# Tests oserror-1.* test failures in the open() system call.\n#\n\n# Test a failure in open() due to too many files. \n#\n# The xOpen() method of the unix VFS calls getcwd() as well as open().\n# Although this does not appear to be documented in the man page, on OSX\n# a call to getcwd() may fail if there are no free file descriptors. So\n# an error may be reported for either open() or getcwd() here.\n#\nif {![clang_sanitize_address]} {\n  do_test 1.1.1 {\n    set ::log [list]\n    list [catch {\n      for {set i 0} {$i < 2000} {incr i} { sqlite3 dbh_$i test.db -readonly 1 }\n    } msg] $msg\n  } {1 {unable to open database file}}\n  do_test 1.1.2 {\n    catch { for {set i 0} {$i < 2000} {incr i} { dbh_$i close } }\n  } {1}\n  do_re_test 1.1.3 { \n    lindex $::log 0 \n  } {^os_unix.c:\\d+: \\(\\d+\\) (open|getcwd)\\(.*test.db\\) - }\n}\n\n\n# Test a failure in open() due to the path being a directory.\n#\ndo_test 1.2.1 {\n  file mkdir dir.db\n  set ::log [list]\n  list [catch { sqlite3 dbh dir.db } msg] $msg\n} {1 {unable to open database file}}\n\ndo_re_test 1.2.2 { lindex $::log 0 } {^os_unix.c:\\d+: \\(\\d+\\) open\\(.*dir.db\\) - }\n\n# Test a failure in open() due to the path not existing.\n#\ndo_test 1.3.1 {\n  set ::log [list]\n  list [catch { sqlite3 dbh /x/y/z/test.db } msg] $msg\n} {1 {unable to open database file}}\n\ndo_re_test 1.3.2 { lindex $::log 0 } {^os_unix.c:\\d+: \\(\\d+\\) open\\(.*test.db\\) - }\n\n# Test a failure in open() due to the path not existing.\n#\ndo_test 1.4.1 {\n  set ::log [list]\n  list [catch { sqlite3 dbh /root/test.db } msg] $msg\n} {1 {unable to open database file}}\n\ndo_re_test 1.4.2 { \n  lindex $::log 0\n} {^os_unix.c:\\d*: \\(\\d+\\) (open|readlink|lstat)\\(.*test.db\\) - }\n\n#--------------------------------------------------------------------------\n# Tests oserror-1.* test failures in the unlink() system call.\n#\nifcapable wal {\n  do_test 2.1.1 {\n    set ::log [list]\n    file mkdir test.db-wal\n    forcedelete test.db\n    list [catch {\n      sqlite3 dbh test.db\n      execsql { SELECT * FROM sqlite_master } dbh\n    } msg] $msg\n  } {1 {disk I/O error}}\n  \n  do_re_test 2.1.2 { \n    lindex $::log 0 \n  } {^os_unix.c:\\d+: \\(\\d+\\) unlink\\(.*test.db-wal\\) - }\n  do_test 2.1.3 { \n    catch { dbh close }\n    forcedelete test.db-wal\n  } {}\n}\n  \n\ntest_syscall reset\nsqlite3_shutdown\ntest_sqlite3_log \nsqlite3_initialize\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ossfuzz.c",
    "content": "/*\n** This module interfaces SQLite to the Google OSS-Fuzz, fuzzer as a service.\n** (https://github.com/google/oss-fuzz)\n*/\n#include <stddef.h>\n#include <stdint.h>\n#include <stdio.h>\n#include <string.h>\n#include \"sqlite3.h\"\n\n/* Global debugging settings.  OSS-Fuzz will have all debugging turned\n** off.  But if LLVMFuzzerTestOneInput() is called interactively from\n** the ossshell utility program, then these flags might be set.\n*/\nstatic unsigned mDebug = 0;\n#define FUZZ_SQL_TRACE       0x0001   /* Set an sqlite3_trace() callback */\n#define FUZZ_SHOW_MAX_DELAY  0x0002   /* Show maximum progress callback delay */\n#define FUZZ_SHOW_ERRORS     0x0004   /* Print error messages from SQLite */\n\n/* The ossshell utility program invokes this interface to see the\n** debugging flags.  Unused by OSS-Fuzz.\n*/\nvoid ossfuzz_set_debug_flags(unsigned x){\n  mDebug = x;\n}\n\n/* Return the current real-world time in milliseconds since the\n** Julian epoch (-4714-11-24).\n*/\nstatic sqlite3_int64 timeOfDay(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n/* An instance of the following object is passed by pointer as the\n** client data to various callbacks.\n*/\ntypedef struct FuzzCtx {\n  sqlite3 *db;               /* The database connection */\n  sqlite3_int64 iCutoffTime; /* Stop processing at this time. */\n  sqlite3_int64 iLastCb;     /* Time recorded for previous progress callback */\n  sqlite3_int64 mxInterval;  /* Longest interval between two progress calls */\n  unsigned nCb;              /* Number of progress callbacks */\n} FuzzCtx;\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n/*\n** Progress handler callback.\n**\n** The argument is the cutoff-time after which all processing should\n** stop.  So return non-zero if the cut-off time is exceeded.\n*/\nstatic int progress_handler(void *pClientData) {\n  FuzzCtx *p = (FuzzCtx*)pClientData;\n  sqlite3_int64 iNow = timeOfDay();\n  int rc = iNow>=p->iCutoffTime;\n  sqlite3_int64 iDiff = iNow - p->iLastCb;\n  if( iDiff > p->mxInterval ) p->mxInterval = iDiff;\n  p->nCb++;\n  return rc;\n}\n#endif\n\n/*\n** Disallow debugging pragmas such as \"PRAGMA vdbe_debug\" and\n** \"PRAGMA parser_trace\" since they can dramatically increase the\n** amount of output without actually testing anything useful.\n*/\nstatic int block_debug_pragmas(\n  void *Notused,\n  int eCode,\n  const char *zArg1,\n  const char *zArg2,\n  const char *zArg3,\n  const char *zArg4\n){\n  if( eCode==SQLITE_PRAGMA\n   && (sqlite3_strnicmp(\"vdbe_\", zArg1, 5)==0\n        || sqlite3_stricmp(\"parser_trace\", zArg1)==0)\n  ){\n    return SQLITE_DENY;\n  }\n  return SQLITE_OK;\n}\n\n/*\n** Callback for sqlite3_exec().\n*/\nstatic int exec_handler(void *pCnt, int argc, char **argv, char **namev){\n  int i;\n  if( argv ){\n    for(i=0; i<argc; i++) sqlite3_free(sqlite3_mprintf(\"%s\", argv[i]));\n  }\n  return ((*(int*)pCnt)--)<=0;\n}\n\n/*\n** Main entry point.  The fuzzer invokes this function with each\n** fuzzed input.\n*/\nint LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {\n  int execCnt = 0;         /* Abort row callback when count reaches zero */\n  char *zErrMsg = 0;       /* Error message returned by sqlite_exec() */\n  uint8_t uSelector;       /* First byte of input data[] */\n  int rc;                  /* Return code from various interfaces */\n  char *zSql;              /* Zero-terminated copy of data[] */\n  FuzzCtx cx;              /* Fuzzing context */\n\n  memset(&cx, 0, sizeof(cx));\n  if( size<3 ) return 0;   /* Early out if unsufficient data */\n\n  /* Extract the selector byte from the beginning of the input.  But only\n  ** do this if the second byte is a \\n.  If the second byte is not \\n,\n  ** then use a default selector */\n  if( data[1]=='\\n' ){\n    uSelector = data[0];  data += 2; size -= 2;\n  }else{\n    uSelector = 0xfd;\n  }\n\n  /* Open the database connection.  Only use an in-memory database. */\n  rc = sqlite3_open_v2(\"fuzz.db\", &cx.db,\n           SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);\n  if( rc ) return 0;\n\n#ifndef SQLITE_OMIT_PROGRESS_CALLBACK\n  /* Invoke the progress handler frequently to check to see if we\n  ** are taking too long.  The progress handler will return true\n  ** (which will block further processing) if more than 10 seconds have\n  ** elapsed since the start of the test.\n  */\n  cx.iLastCb = timeOfDay();\n  cx.iCutoffTime = cx.iLastCb + 10000;  /* Now + 10 seconds */\n  sqlite3_progress_handler(cx.db, 10, progress_handler, (void*)&cx);\n#endif\n\n  /* Set a limit on the maximum size of a prepared statement */\n  sqlite3_limit(cx.db, SQLITE_LIMIT_VDBE_OP, 25000);\n\n  /* Bit 1 of the selector enables foreign key constraints */\n  sqlite3_db_config(cx.db, SQLITE_DBCONFIG_ENABLE_FKEY, uSelector&1, &rc);\n  uSelector >>= 1;\n\n  /* Do not allow debugging pragma statements that might cause excess output */\n  sqlite3_set_authorizer(cx.db, block_debug_pragmas, 0);\n\n  /* Remaining bits of the selector determine a limit on the number of\n  ** output rows */\n  execCnt = uSelector + 1;\n\n  /* Run the SQL.  The sqlite_exec() interface expects a zero-terminated\n  ** string, so make a copy. */\n  zSql = sqlite3_mprintf(\"%.*s\", (int)size, data);\n  sqlite3_exec(cx.db, zSql, exec_handler, (void*)&execCnt, &zErrMsg);\n\n  /* Show any errors */\n  if( (mDebug & FUZZ_SHOW_ERRORS)!=0 && zErrMsg ){\n    printf(\"Error: %s\\n\", zErrMsg);\n  }\n\n  /* Cleanup and return */\n  sqlite3_free(zErrMsg);\n  sqlite3_free(zSql);\n  sqlite3_exec(cx.db, \"PRAGMA temp_store_directory=''\", 0, 0, 0);\n  sqlite3_close(cx.db);\n\n  if( mDebug & FUZZ_SHOW_MAX_DELAY ){\n    printf(\"Progress callback count....... %d\\n\", cx.nCb);\n    printf(\"Max time between callbacks.... %d ms\\n\", (int)cx.mxInterval);\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ossshell.c",
    "content": "/*\n** This is a test interface for the ossfuzz.c module.  The ossfuzz.c module\n** is an adaptor for OSS-FUZZ.  (https://github.com/google/oss-fuzz)\n**\n** This program links against ossfuzz.c.  It reads files named on the\n** command line and passes them one by one into ossfuzz.c.\n*/\n#include <stddef.h>\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"sqlite3.h\"\n\n/*\n** The entry point in ossfuzz.c that this routine will be calling\n*/\nint LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);\n\n/* Must match equivalent #defines in ossfuzz.c */\n#define FUZZ_SQL_TRACE       0x0001   /* Set an sqlite3_trace() callback */\n#define FUZZ_SHOW_MAX_DELAY  0x0002   /* Show maximum progress callback delay */\n#define FUZZ_SHOW_ERRORS     0x0004   /* Show SQL errors */\nextern void ossfuzz_set_debug_flags(unsigned);\n\n\n\n/*\n** Read files named on the command-line and invoke the fuzzer for\n** each one.\n*/\nint main(int argc, char **argv){\n  FILE *in;\n  int i;\n  int nErr = 0;\n  uint8_t *zBuf = 0;\n  size_t sz;\n  unsigned mDebug = 0;\n\n  for(i=1; i<argc; i++){\n    const char *zFilename = argv[i];\n    if( zFilename[0]=='-' ){\n      if( zFilename[1]=='-' ) zFilename++;\n      if( strcmp(zFilename, \"-show-errors\")==0 ){\n        mDebug |= FUZZ_SHOW_ERRORS;\n        ossfuzz_set_debug_flags(mDebug);\n      }else\n      if( strcmp(zFilename, \"-show-max-delay\")==0 ){\n        mDebug |= FUZZ_SHOW_MAX_DELAY;\n        ossfuzz_set_debug_flags(mDebug);\n      }else\n      if( strcmp(zFilename, \"-sql-trace\")==0 ){\n        mDebug |= FUZZ_SQL_TRACE;\n        ossfuzz_set_debug_flags(mDebug);\n      }else\n      {\n        printf(\"unknown option \\\"%s\\\"\\n\", argv[i]);\n        printf(\"should be one of: --show-errors --show-max-delay\"\n               \" --sql-trace\\n\");\n        exit(1);\n      }\n      continue;\n    }\n    in = fopen(zFilename, \"rb\");\n    if( in==0 ){\n      fprintf(stderr, \"cannot open \\\"%s\\\"\\n\", zFilename);\n      nErr++;\n      continue;\n    }\n    fseek(in, 0, SEEK_END);\n    sz = ftell(in);\n    rewind(in);\n    zBuf = realloc(zBuf, sz);\n    if( zBuf==0 ){\n      fprintf(stderr, \"cannot malloc() for %d bytes\\n\", (int)sz);\n      exit(1);\n    }\n    if( fread(zBuf, sz, 1, in)!=1 ){\n      fprintf(stderr, \"cannot read %d bytes from \\\"%s\\\"\\n\",\n                       (int)sz, zFilename);\n      nErr++;\n    }else{\n      printf(\"%s... \", zFilename);\n      if( mDebug ) printf(\"\\n\");\n      fflush(stdout);\n      (void)LLVMFuzzerTestOneInput(zBuf, sz);\n      if( mDebug ) printf(\"%s: \", zFilename);\n      printf(\"ok\\n\");\n    }\n    fclose(in);\n  }\n  free(zBuf);\n  return nErr;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ovfl.test",
    "content": "# 2014 October 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SQLITE_DIRECT_OVERFLOW_READ logic.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix ovfl\n\n# Populate table t2:\n#\n#   CREATE TABLE t1(c1 TEXT, c2 TEXT);\n#\n# with 2000 rows. In each row, c2 spans multiple overflow pages. The text\n# value of c1 ranges in size from 1 to 2000 bytes. The idea is to create\n# at least one row where the first byte of c2 is also the first byte of\n# an overflow page. This was at one point exposing an obscure bug in the\n# SQLITE_DIRECT_OVERFLOW_READ logic.\n#\ndo_test 1.1 {\n  set c2 [string repeat abcdefghij 200]\n  execsql {\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(c1 TEXT, c2 TEXT);\n    BEGIN;\n  }\n  for {set i 1} {$i <= 2000} {incr i} {\n    set c1 [string repeat . $i]\n    execsql { INSERT INTO t1 VALUES($c1, $c2) }\n  }\n  execsql COMMIT\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT sum(length(c2)) FROM t1;\n} [expr 2000 * 2000]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pager1.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/wal_common.tcl\nset testprefix pager1\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n#\n# pager1-1.*: Test inter-process locking (clients in multiple processes).\n#\n# pager1-2.*: Test intra-process locking (multiple clients in this process).\n#\n# pager1-3.*: Savepoint related tests.\n#\n# pager1-4.*: Hot-journal related tests.\n#\n# pager1-5.*: Cases related to multi-file commits.\n#\n# pager1-6.*: Cases related to \"PRAGMA max_page_count\"\n#\n# pager1-7.*: Cases specific to \"PRAGMA journal_mode=TRUNCATE\"\n#\n# pager1-8.*: Cases using temporary and in-memory databases.\n#\n# pager1-9.*: Tests related to the backup API.\n#\n# pager1-10.*: Test that the assumed file-system sector-size is limited to\n#              64KB.\n#\n# pager1-12.*: Tests involving \"PRAGMA page_size\"\n#\n# pager1-13.*: Cases specific to \"PRAGMA journal_mode=PERSIST\"\n#\n# pager1-14.*: Cases specific to \"PRAGMA journal_mode=OFF\"\n#\n# pager1-15.*: Varying sqlite3_vfs.szOsFile\n#\n# pager1-16.*: Varying sqlite3_vfs.mxPathname\n#\n# pager1-17.*: Tests related to \"PRAGMA omit_readlock\"\n#              (The omit_readlock pragma has been removed and so have\n#              these tests.)\n#\n# pager1-18.*: Test that the pager layer responds correctly if the b-tree\n#              requests an invalid page number (due to db corruption).\n#\n\nproc recursive_select {id table {script {}}} {\n  set cnt 0\n  db eval \"SELECT rowid, * FROM $table WHERE rowid = ($id-1)\" {\n    recursive_select $rowid $table $script\n    incr cnt\n  }\n  if {$cnt==0} { eval $script }\n}\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\ndo_multiclient_test tn {\n\n  # Create and populate a database table using connection [db]. Check \n  # that connections [db2] and [db3] can see the schema and content.\n  #\n  do_test pager1-$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      CREATE INDEX i1 ON t1(b);\n      INSERT INTO t1 VALUES(1, 'one'); INSERT INTO t1 VALUES(2, 'two');\n    }\n  } {}\n  do_test pager1-$tn.2 { sql2 { SELECT * FROM t1 } } {1 one 2 two}\n  do_test pager1-$tn.3 { sql3 { SELECT * FROM t1 } } {1 one 2 two}\n\n  # Open a transaction and add a row using [db]. This puts [db] in\n  # RESERVED state. Check that connections [db2] and [db3] can still\n  # read the database content as it was before the transaction was\n  # opened. [db] should see the inserted row.\n  #\n  do_test pager1-$tn.4 {\n    sql1 {\n      BEGIN;\n        INSERT INTO t1 VALUES(3, 'three');\n    }\n  } {}\n  do_test pager1-$tn.5 { sql2 { SELECT * FROM t1 } } {1 one 2 two}\n  do_test pager1-$tn.7 { sql1 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n\n  # [db] still has an open write transaction. Check that this prevents\n  # other connections (specifically [db2]) from writing to the database.\n  #\n  # Even if [db2] opens a transaction first, it may not write to the\n  # database. After the attempt to write the db within a transaction, \n  # [db2] is left with an open transaction, but not a read-lock on\n  # the main database. So it does not prevent [db] from committing.\n  #\n  do_test pager1-$tn.8 { \n    csql2 { UPDATE t1 SET a = a + 10 }\n  } {1 {database is locked}}\n  do_test pager1-$tn.9 { \n    csql2 { \n      BEGIN;\n      UPDATE t1 SET a = a + 10;\n    }\n  } {1 {database is locked}}\n\n  # Have [db] commit its transactions. Check the other connections can\n  # now see the new database content.\n  #\n  do_test pager1-$tn.10 { sql1 { COMMIT } } {}\n  do_test pager1-$tn.11 { sql1 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n  do_test pager1-$tn.12 { sql2 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n  do_test pager1-$tn.13 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n\n  # Check that, as noted above, [db2] really did keep an open transaction\n  # after the attempt to write the database failed.\n  #\n  do_test pager1-$tn.14 { \n    csql2 { BEGIN } \n  } {1 {cannot start a transaction within a transaction}}\n  do_test pager1-$tn.15 { sql2 { ROLLBACK } } {}\n\n  # Have [db2] open a transaction and take a read-lock on the database.\n  # Check that this prevents [db] from writing to the database (outside\n  # of any transaction). After this fails, check that [db3] can read\n  # the db (showing that [db] did not take a PENDING lock etc.)\n  #\n  do_test pager1-$tn.15 { \n    sql2 { BEGIN; SELECT * FROM t1; }\n  } {1 one 2 two 3 three}\n  do_test pager1-$tn.16 { \n    csql1 { UPDATE t1 SET a = a + 10 }\n  } {1 {database is locked}}\n  do_test pager1-$tn.17 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n\n  # This time, have [db] open a transaction before writing the database.\n  # This works - [db] gets a RESERVED lock which does not conflict with\n  # the SHARED lock [db2] is holding.\n  #\n  do_test pager1-$tn.18 { \n    sql1 { \n      BEGIN;  \n      UPDATE t1 SET a = a + 10; \n    }\n  } {}\n  do_test pager1-$tn-19 { \n    sql1 { PRAGMA lock_status } \n  } {main reserved temp closed}\n  do_test pager1-$tn-20 { \n    sql2 { PRAGMA lock_status } \n  } {main shared temp closed}\n\n  # Check that all connections can still read the database. Only [db] sees\n  # the updated content (as the transaction has not been committed yet).\n  #\n  do_test pager1-$tn.21 { sql1 { SELECT * FROM t1 } } {11 one 12 two 13 three}\n  do_test pager1-$tn.22 { sql2 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n  do_test pager1-$tn.23 { sql3 { SELECT * FROM t1 } } {1 one 2 two 3 three}\n\n  # Because [db2] still has the SHARED lock, [db] is unable to commit the\n  # transaction. If it tries, an error is returned and the connection \n  # upgrades to a PENDING lock.\n  #\n  # Once this happens, [db] can read the database and see the new content,\n  # [db2] (still holding SHARED) can still read the old content, but [db3]\n  # (not holding any lock) is prevented by [db]'s PENDING from reading\n  # the database.\n  #\n  do_test pager1-$tn.24 { csql1 { COMMIT } } {1 {database is locked}}\n  do_test pager1-$tn-25 { \n    sql1 { PRAGMA lock_status } \n  } {main pending temp closed}\n  do_test pager1-$tn.26 { sql1 { SELECT * FROM t1  } } {11 one 12 two 13 three}\n  do_test pager1-$tn.27 { sql2 { SELECT * FROM t1  } } {1 one 2 two 3 three}\n  do_test pager1-$tn.28 { csql3 { SELECT * FROM t1 } } {1 {database is locked}}\n\n  # Have [db2] commit its read transaction, releasing the SHARED lock it\n  # is holding. Now, neither [db2] nor [db3] may read the database (as [db]\n  # is still holding a PENDING).\n  #\n  do_test pager1-$tn.29 { sql2 { COMMIT } } {}\n  do_test pager1-$tn.30 { csql2 { SELECT * FROM t1 } } {1 {database is locked}}\n  do_test pager1-$tn.31 { csql3 { SELECT * FROM t1 } } {1 {database is locked}}\n\n  # [db] is now able to commit the transaction. Once the transaction is \n  # committed, all three connections can read the new content.\n  #\n  do_test pager1-$tn.25 { sql1 { UPDATE t1 SET a = a+10 } } {}\n  do_test pager1-$tn.26 { sql1 { COMMIT } } {}\n  do_test pager1-$tn.27 { sql1 { SELECT * FROM t1 } } {21 one 22 two 23 three}\n  do_test pager1-$tn.27 { sql2 { SELECT * FROM t1 } } {21 one 22 two 23 three}\n  do_test pager1-$tn.28 { sql3 { SELECT * FROM t1 } } {21 one 22 two 23 three}\n\n  # Install a busy-handler for connection [db].\n  #\n  set ::nbusy [list]\n  proc busy {n} {\n    lappend ::nbusy $n\n    if {$n>5} { sql2 COMMIT }\n    return 0\n  }\n  db busy busy\n\n  do_test pager1-$tn.29 { \n    sql1 { BEGIN ; INSERT INTO t1 VALUES('x', 'y') } \n  } {}\n  do_test pager1-$tn.30 { \n    sql2 { BEGIN ; SELECT * FROM t1 } \n  } {21 one 22 two 23 three}\n  do_test pager1-$tn.31 { sql1 COMMIT } {}\n  do_test pager1-$tn.32 { set ::nbusy } {0 1 2 3 4 5 6}\n}\n\n#-------------------------------------------------------------------------\n# Savepoint related test cases.\n#\n# pager1-3.1.2.*: Force a savepoint rollback to cause the database file\n#                 to grow.\n#\n# pager1-3.1.3.*: Use a journal created in synchronous=off mode as part\n#                 of a savepoint rollback.\n# \ndo_test pager1-3.1.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE counter(\n      i CHECK (i<5), \n      u CHECK (u<10)\n    );\n    INSERT INTO counter VALUES(0, 0);\n    CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n      UPDATE counter SET i = i+1;\n    END;\n    CREATE TRIGGER tr2 AFTER UPDATE ON t1 BEGIN\n      UPDATE counter SET u = u+1;\n    END;\n  }\n  execsql { SELECT * FROM counter }\n} {0 0}\n\ndo_execsql_test pager1-3.1.2 {\n  PRAGMA cache_size = 10;\n  BEGIN;\n    INSERT INTO t1 VALUES(1, randomblob(1500));\n    INSERT INTO t1 VALUES(2, randomblob(1500));\n    INSERT INTO t1 VALUES(3, randomblob(1500));\n    SELECT * FROM counter;\n} {3 0}\ndo_catchsql_test pager1-3.1.3 {\n    INSERT INTO t1 SELECT a+3, randomblob(1500) FROM t1\n} {1 {CHECK constraint failed: counter}}\ndo_execsql_test pager1-3.4 { SELECT * FROM counter } {3 0}\ndo_execsql_test pager1-3.5 { SELECT a FROM t1 } {1 2 3}\ndo_execsql_test pager1-3.6 { COMMIT } {}\n\nforeach {tn sql tcl} {\n  7  { PRAGMA synchronous = NORMAL ; PRAGMA temp_store = 0 } {\n    testvfs tv -default 1\n    tv devchar safe_append\n  }\n  8  { PRAGMA synchronous = NORMAL ; PRAGMA temp_store = 2 } {\n    testvfs tv -default 1\n    tv devchar sequential\n  }\n  9  { PRAGMA synchronous = FULL } { }\n  10 { PRAGMA synchronous = NORMAL } { }\n  11 { PRAGMA synchronous = OFF } { }\n  12 { PRAGMA synchronous = FULL ; PRAGMA fullfsync = 1 } { }\n  13 { PRAGMA synchronous = FULL } {\n    testvfs tv -default 1\n    tv devchar sequential\n  }\n  14 { PRAGMA locking_mode = EXCLUSIVE } {\n  }\n} {\n  do_test pager1-3.$tn.1 {\n    eval $tcl\n    faultsim_delete_and_reopen\n    db func a_string a_string\n    execsql $sql\n    execsql {\n      PRAGMA auto_vacuum = 2;\n      PRAGMA cache_size = 10;\n      CREATE TABLE z(x INTEGER PRIMARY KEY, y);\n      BEGIN;\n        INSERT INTO z VALUES(NULL, a_string(800));\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --   2\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --   4\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --   8\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --  16\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --  32\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     --  64\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     -- 128\n        INSERT INTO z SELECT NULL, a_string(800) FROM z;     -- 256\n      COMMIT;\n    }\n    execsql { PRAGMA auto_vacuum }\n  } {2}\n  do_execsql_test pager1-3.$tn.2 {\n    BEGIN;\n      INSERT INTO z VALUES(NULL, a_string(800));\n      INSERT INTO z VALUES(NULL, a_string(800));\n      SAVEPOINT one;\n        UPDATE z SET y = NULL WHERE x>256;\n        PRAGMA incremental_vacuum;\n        SELECT count(*) FROM z WHERE x < 100;\n      ROLLBACK TO one;\n    COMMIT;\n  } {99}\n\n  do_execsql_test pager1-3.$tn.3 {\n    BEGIN;\n      SAVEPOINT one;\n        UPDATE z SET y = y||x;\n      ROLLBACK TO one;\n    COMMIT;\n    SELECT count(*) FROM z;\n  } {258}\n\n  do_execsql_test pager1-3.$tn.4 {\n    SAVEPOINT one;\n      UPDATE z SET y = y||x;\n    ROLLBACK TO one;\n  } {}\n  do_execsql_test pager1-3.$tn.5 {\n    SELECT count(*) FROM z;\n    RELEASE one;\n    PRAGMA integrity_check;\n  } {258 ok}\n\n  do_execsql_test pager1-3.$tn.6 {\n    SAVEPOINT one;\n    RELEASE one;\n  } {}\n\n  db close\n  catch { tv delete }\n}\n\n#-------------------------------------------------------------------------\n# Hot journal rollback related test cases.\n#\n# pager1.4.1.*: Test that the pager module deletes very small invalid\n#               journal files.\n#\n# pager1.4.2.*: Test that if the master journal pointer at the end of a\n#               hot-journal file appears to be corrupt (checksum does not\n#               compute) the associated journal is rolled back (and no\n#               xAccess() call to check for the presence of any master \n#               journal file is made).\n#\n# pager1.4.3.*: Test that the contents of a hot-journal are ignored if the\n#               page-size or sector-size in the journal header appear to\n#               be invalid (too large, too small or not a power of 2).\n#\n# pager1.4.4.*: Test hot-journal rollback of journal file with a master\n#               journal pointer generated in various \"PRAGMA synchronous\"\n#               modes.\n#\n# pager1.4.5.*: Test that hot-journal rollback stops if it encounters a\n#               journal-record for which the checksum fails.\n#\n# pager1.4.6.*: Test that when rolling back a hot-journal that contains a\n#               master journal pointer, the master journal file is deleted\n#               after all the hot-journals that refer to it are deleted.\n#\n# pager1.4.7.*: Test that if a hot-journal file exists but a client can\n#               open it for reading only, the database cannot be accessed and\n#               SQLITE_CANTOPEN is returned.\n# \ndo_test pager1.4.1.1 {\n  faultsim_delete_and_reopen\n  execsql { \n    CREATE TABLE x(y, z);\n    INSERT INTO x VALUES(1, 2);\n  }\n  set fd [open test.db-journal w]\n  puts -nonewline $fd \"helloworld\"\n  close $fd\n  file exists test.db-journal\n} {1}\ndo_test pager1.4.1.2 { execsql { SELECT * FROM x } } {1 2}\ndo_test pager1.4.1.3 { file exists test.db-journal } {0}\n\n# Set up a [testvfs] to snapshot the file-system just before SQLite\n# deletes the master-journal to commit a multi-file transaction.\n#\n# In subsequent test cases, invoking [faultsim_restore_and_reopen] sets\n# up the file system to contain two databases, two hot-journal files and\n# a master-journal.\n#\ndo_test pager1.4.2.1 {\n  testvfs tstvfs -default 1\n  tstvfs filter xDelete\n  tstvfs script xDeleteCallback\n  proc xDeleteCallback {method file args} {\n    set file [file tail $file]\n    if { [string match *mj* $file] } { faultsim_save }\n  }\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    PRAGMA journal_mode = DELETE;\n    PRAGMA main.cache_size = 10;\n    PRAGMA aux.cache_size = 10;\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    CREATE TABLE aux.t2(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t2 SELECT * FROM t1;\n    BEGIN;\n      INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;\n      INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;\n      INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;\n      INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;\n      REPLACE INTO t2 SELECT * FROM t1;\n    COMMIT;\n  }\n  db close\n  tstvfs delete\n} {}\n\nif {$::tcl_platform(platform)!=\"windows\"} {\ndo_test pager1.4.2.2 {\n  faultsim_restore_and_reopen\n  execsql {\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {4 ok}\ndo_test pager1.4.2.3 {\n  faultsim_restore_and_reopen\n  foreach f [glob test.db-mj*] { forcedelete $f }\n  execsql {\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {64 ok}\ndo_test pager1.4.2.4 {\n  faultsim_restore_and_reopen\n  hexio_write test.db-journal [expr [file size test.db-journal]-30] 123456\n  execsql {\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {4 ok}\ndo_test pager1.4.2.5 {\n  faultsim_restore_and_reopen\n  hexio_write test.db-journal [expr [file size test.db-journal]-30] 123456\n  foreach f [glob test.db-mj*] { forcedelete $f }\n  execsql {\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {4 ok}\n}\n\ndo_test pager1.4.3.1 {\n  testvfs tstvfs -default 1\n  tstvfs filter xSync\n  tstvfs script xSyncCallback\n  proc xSyncCallback {method file args} {\n    set file [file tail $file]\n    if { 0==[string match *journal $file] } { faultsim_save }\n  }\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = DELETE;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  db close\n  tstvfs delete\n} {}\n\nforeach {tn ofst value result} {\n          2   20    31       {1 2 3 4}\n          3   20    32       {1 2 3 4}\n          4   20    33       {1 2 3 4}\n          5   20    65536    {1 2 3 4}\n          6   20    131072   {1 2 3 4}\n\n          7   24    511      {1 2 3 4}\n          8   24    513      {1 2 3 4}\n          9   24    131072   {1 2 3 4}\n\n         10   32    65536    {1 2}\n} {\n  do_test pager1.4.3.$tn {\n    faultsim_restore_and_reopen\n    hexio_write test.db-journal $ofst [format %.8x $value]\n    execsql { SELECT * FROM t1 }\n  } $result\n}\ndb close\n\n# Set up a VFS that snapshots the file-system just before a master journal\n# file is deleted to commit a multi-file transaction. Specifically, the\n# file-system is saved just before the xDelete() call to remove the \n# master journal file from the file-system.\n#\nset pwd [get_pwd]\ntestvfs tv -default 1\ntv script copy_on_mj_delete\nset ::mj_filename_length 0\nset ::mj_delete_cnt 0\nproc copy_on_mj_delete {method filename args} {\n  if {[string match *mj* [file tail $filename]]} { \n    #\n    # NOTE: Is the file name relative?  If so, add the length of the current\n    #       directory.\n    #\n    if {[is_relative_file $filename]} {\n      set ::mj_filename_length \\\n        [expr {[string length $filename] + [string length $::pwd]}]\n    } else {\n      set ::mj_filename_length [string length $filename]\n    }\n    faultsim_save \n    incr ::mj_delete_cnt\n  }\n  return SQLITE_OK\n}\n\nforeach {tn1 tcl} {\n  1 { set prefix \"test.db\" }\n  2 { \n    # This test depends on the underlying VFS being able to open paths\n    # 512 bytes in length. The idea is to create a hot-journal file that\n    # contains a master-journal pointer so large that it could contain\n    # a valid page record (if the file page-size is 512 bytes). So as to\n    # make sure SQLite doesn't get confused by this.\n    #\n    set nPadding [expr 511 - $::mj_filename_length]\n    if {$tcl_platform(platform)==\"windows\"} {\n      # TBD need to figure out how to do this correctly for Windows!!!\n      set nPadding [expr 255 - $::mj_filename_length]\n    }\n\n    # We cannot just create a really long database file name to open, as\n    # Linux limits a single component of a path to 255 bytes by default\n    # (and presumably other systems have limits too). So create a directory\n    # hierarchy to work in.\n    #\n    set dirname \"d123456789012345678901234567890/\"\n    set nDir [expr $nPadding / 32]\n    if { $nDir } {\n      set p [string repeat $dirname $nDir]\n      file mkdir $p\n      cd $p\n    }\n\n    set padding [string repeat x [expr $nPadding %32]]\n    set prefix \"test.db${padding}\"\n  }\n} {\n  eval $tcl\n  foreach {tn2 sql usesMJ} {\n    o { \n      PRAGMA main.synchronous=OFF;\n      PRAGMA aux.synchronous=OFF;\n      PRAGMA journal_mode = DELETE;\n    } 0\n    o512 { \n      PRAGMA main.synchronous=OFF;\n      PRAGMA aux.synchronous=OFF;\n      PRAGMA main.page_size = 512;\n      PRAGMA aux.page_size = 512;\n      PRAGMA journal_mode = DELETE;\n    } 0\n    n { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA journal_mode = DELETE;\n    } 1\n    f { \n      PRAGMA main.synchronous=FULL;\n      PRAGMA aux.synchronous=FULL;\n      PRAGMA journal_mode = DELETE;\n    } 1\n    w1 { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA journal_mode = WAL;\n    } 0\n    w2 { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA main.journal_mode=DELETE;\n      PRAGMA aux.journal_mode=WAL;\n    } 0\n    o1a { \n      PRAGMA main.synchronous=FULL;\n      PRAGMA aux.synchronous=OFF;\n      PRAGMA journal_mode=DELETE;\n    } 0\n    o1b { \n      PRAGMA main.synchronous=OFF;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA journal_mode=DELETE;\n    } 0\n    m1 { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA main.journal_mode=DELETE;\n      PRAGMA aux.journal_mode = MEMORY;\n    } 0\n    t1 { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA main.journal_mode=DELETE;\n      PRAGMA aux.journal_mode = TRUNCATE;\n    } 1\n    p1 { \n      PRAGMA main.synchronous=NORMAL;\n      PRAGMA aux.synchronous=NORMAL;\n      PRAGMA main.journal_mode=DELETE;\n      PRAGMA aux.journal_mode = PERSIST;\n    } 1\n  } {\n\n    set tn \"${tn1}.${tn2}\"\n  \n    # Set up a connection to have two databases, test.db (main) and \n    # test.db2 (aux). Then run a multi-file transaction on them. The\n    # VFS will snapshot the file-system just before the master-journal\n    # file is deleted to commit the transaction.\n    #\n    tv filter xDelete\n    do_test pager1-4.4.$tn.1 {\n      set ::mj_delete_cnt 0\n      faultsim_delete_and_reopen $prefix\n      execsql \"\n        ATTACH '${prefix}2' AS aux;\n        $sql\n        CREATE TABLE a(x);\n        CREATE TABLE aux.b(x);\n        INSERT INTO a VALUES('double-you');\n        INSERT INTO a VALUES('why');\n        INSERT INTO a VALUES('zed');\n        INSERT INTO b VALUES('won');\n        INSERT INTO b VALUES('too');\n        INSERT INTO b VALUES('free');\n      \"\n      execsql {\n        BEGIN;\n          INSERT INTO a SELECT * FROM b WHERE rowid<=3;\n          INSERT INTO b SELECT * FROM a WHERE rowid<=3;\n        COMMIT;\n      }\n    } {}\n    tv filter {}\n\n    # Verify that a master journal was deleted only for those cases where\n    # master journals really ought to be used\n    #\n    do_test pager1-4.4.$tn.1b {\n      set ::mj_delete_cnt\n    } $usesMJ\n    \n    # Check that the transaction was committed successfully.\n    #\n    do_execsql_test pager1-4.4.$tn.2 {\n      SELECT * FROM a\n    } {double-you why zed won too free}\n    do_execsql_test pager1-4.4.$tn.3 {\n      SELECT * FROM b\n    } {won too free double-you why zed}\n    \n    if {$usesMJ} {\n      # Restore the file-system and reopen the databases. Check that it now\n      # appears that the transaction was not committed (because the file-system\n      # was restored to the state where it had not been).\n      #\n      do_test pager1-4.4.$tn.4 {\n        faultsim_restore_and_reopen $prefix\n        execsql \"ATTACH '${prefix}2' AS aux\"\n      } {}\n      do_execsql_test pager1-4.4.$tn.5 {SELECT * FROM a} {double-you why zed}\n      do_execsql_test pager1-4.4.$tn.6 {SELECT * FROM b} {won too free}\n    }\n    \n    # Restore the file-system again. This time, before reopening the databases,\n    # delete the master-journal file from the file-system. It now appears that\n    # the transaction was committed (no master-journal file == no rollback).\n    #\n    do_test pager1-4.4.$tn.7 {\n      if {$::mj_delete_cnt>0} {\n        faultsim_restore_and_reopen $prefix\n        foreach f [glob ${prefix}-mj*] { forcedelete $f }\n      } else {\n        db close\n        sqlite3 db $prefix\n      }\n      execsql \"ATTACH '${prefix}2' AS aux\"\n      glob -nocomplain ${prefix}-mj*\n    } {}\n    do_execsql_test pager1-4.4.$tn.8 {\n      SELECT * FROM a\n    } {double-you why zed won too free}\n    do_execsql_test pager1-4.4.$tn.9 {\n      SELECT * FROM b\n    } {won too free double-you why zed}\n  }\n\n  cd $pwd\n}\ndb close\ntv delete\nforcedelete $dirname\n\n# Set up a VFS to make a copy of the file-system just before deleting a\n# journal file to commit a transaction. The transaction modifies exactly\n# two database pages (and page 1 - the change counter).\n#\ntestvfs tv -default 1\ntv sectorsize 512\ntv script copy_on_journal_delete\ntv filter xDelete\nproc copy_on_journal_delete {method filename args} {\n  if {[string match *journal $filename]} faultsim_save \n  return SQLITE_OK\n}\nfaultsim_delete_and_reopen\ndo_execsql_test pager1.4.5.1 {\n  PRAGMA journal_mode = DELETE;\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  INSERT INTO t1 VALUES('I', 'II');\n  INSERT INTO t2 VALUES('III', 'IV');\n  BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES(3, 4);\n  COMMIT;\n} {delete}\ntv filter {}\n\n# Check the transaction was committed:\n#\ndo_execsql_test pager1.4.5.2 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {I II 1 2 III IV 3 4}\n\n# Now try four tests:\n#\n#  pager1-4.5.3: Restore the file-system. Check that the whole transaction \n#                is rolled back.\n#\n#  pager1-4.5.4: Restore the file-system. Corrupt the first record in the\n#                journal. Check the transaction is not rolled back.\n#\n#  pager1-4.5.5: Restore the file-system. Corrupt the second record in the\n#                journal. Check that the first record in the transaction is \n#                played back, but not the second.\n#\n#  pager1-4.5.6: Restore the file-system. Try to open the database with a\n#                readonly connection. This should fail, as a read-only\n#                connection cannot roll back the database file.\n#\nfaultsim_restore_and_reopen\ndo_execsql_test pager1.4.5.3 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {I II III IV}\nfaultsim_restore_and_reopen\nhexio_write test.db-journal [expr 512+4+1024 - 202] 0123456789ABCDEF\ndo_execsql_test pager1.4.5.4 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {I II 1 2 III IV 3 4}\nfaultsim_restore_and_reopen\nhexio_write test.db-journal [expr 512+4+1024+4+4+1024 - 202] 0123456789ABCDEF\ndo_execsql_test pager1.4.5.5 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {I II III IV 3 4}\n\nfaultsim_restore_and_reopen\ndb close\nsqlite3 db test.db -readonly 1\ndo_catchsql_test pager1.4.5.6 {\n  SELECT * FROM t1;\n  SELECT * FROM t2;\n} {1 {attempt to write a readonly database}}\ndb close\n\n# Snapshot the file-system just before multi-file commit. Save the name\n# of the master journal file in $::mj_filename.\n#\ntv script copy_on_mj_delete\ntv filter xDelete\nproc copy_on_mj_delete {method filename args} {\n  if {[string match *mj* [file tail $filename]]} { \n    set ::mj_filename $filename\n    faultsim_save \n  }\n  return SQLITE_OK\n}\ndo_test pager1.4.6.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = DELETE;\n    ATTACH 'test.db2' AS two;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE two.t2(a, b);\n    INSERT INTO t1 VALUES(1, 't1.1');\n    INSERT INTO t2 VALUES(1, 't2.1');\n    BEGIN;\n      UPDATE t1 SET b = 't1.2';\n      UPDATE t2 SET b = 't2.2';\n    COMMIT;\n  }\n  tv filter {}\n  db close\n} {}\n\nfaultsim_restore_and_reopen\ndo_execsql_test pager1.4.6.2 { SELECT * FROM t1 }           {1 t1.1}\ndo_test         pager1.4.6.3 { file exists $::mj_filename } {1}\ndo_execsql_test pager1.4.6.4 {\n  ATTACH 'test.db2' AS two;\n  SELECT * FROM t2;\n} {1 t2.1}\ndo_test pager1.4.6.5 { file exists $::mj_filename } {0}\n\nfaultsim_restore_and_reopen\ndb close\ndo_test pager1.4.6.8 {\n  set ::mj_filename1 $::mj_filename\n  tv filter xDelete\n  sqlite3 db test.db2\n  execsql {\n    PRAGMA journal_mode = DELETE;\n    ATTACH 'test.db3' AS three;\n    CREATE TABLE three.t3(a, b);\n    INSERT INTO t3 VALUES(1, 't3.1');\n    BEGIN;\n      UPDATE t2 SET b = 't2.3';\n      UPDATE t3 SET b = 't3.3';\n    COMMIT;\n  }\n  expr {$::mj_filename1 != $::mj_filename}\n} {1}\nfaultsim_restore_and_reopen\ntv filter {}\n\n# The file-system now contains:\n#\n#   * three databases\n#   * three hot-journal files\n#   * two master-journal files.\n#\n# The hot-journals associated with test.db2 and test.db3 point to\n# master journal $::mj_filename. The hot-journal file associated with\n# test.db points to master journal $::mj_filename1. So reading from\n# test.db should delete $::mj_filename1.\n#\ndo_test pager1.4.6.9 {\n  lsort [glob test.db*]\n} [lsort [list                                           \\\n  test.db test.db2 test.db3                              \\\n  test.db-journal test.db2-journal test.db3-journal      \\\n  [file tail $::mj_filename] [file tail $::mj_filename1]\n]]\n\n# The master-journal $::mj_filename1 contains pointers to test.db and \n# test.db2. However the hot-journal associated with test.db2 points to\n# a different master-journal. Therefore, reading from test.db only should\n# be enough to cause SQLite to delete $::mj_filename1.\n#\ndo_test         pager1.4.6.10 { file exists $::mj_filename  } {1}\ndo_test         pager1.4.6.11 { file exists $::mj_filename1 } {1}\ndo_execsql_test pager1.4.6.12 { SELECT * FROM t1 } {1 t1.1}\ndo_test         pager1.4.6.13 { file exists $::mj_filename  } {1}\ndo_test         pager1.4.6.14 { file exists $::mj_filename1 } {0}\n\ndo_execsql_test pager1.4.6.12 {\n  ATTACH 'test.db2' AS two;\n  SELECT * FROM t2;\n} {1 t2.1}\ndo_test         pager1.4.6.13 { file exists $::mj_filename }  {1}\ndo_execsql_test pager1.4.6.14 {\n  ATTACH 'test.db3' AS three;\n  SELECT * FROM t3;\n} {1 t3.1}\ndo_test         pager1.4.6.15 { file exists $::mj_filename }  {0}\n\ndb close\ntv delete\n\ntestvfs tv -default 1\ntv sectorsize 512\ntv script copy_on_journal_delete\ntv filter xDelete\nproc copy_on_journal_delete {method filename args} {\n  if {[string match *journal $filename]} faultsim_save \n  return SQLITE_OK\n}\nfaultsim_delete_and_reopen\ndo_execsql_test pager1.4.7.1 {\n  PRAGMA journal_mode = DELETE;\n  CREATE TABLE t1(x PRIMARY KEY, y);\n  CREATE INDEX i1 ON t1(y);\n  INSERT INTO t1 VALUES('I',   'one');\n  INSERT INTO t1 VALUES('II',  'four');\n  INSERT INTO t1 VALUES('III', 'nine');\n  BEGIN;\n    INSERT INTO t1 VALUES('IV', 'sixteen');\n    INSERT INTO t1 VALUES('V' , 'twentyfive');\n  COMMIT;\n} {delete}\ntv filter {}\ndb close\ntv delete \ncatch {\n  test_syscall install fchmod\n  test_syscall fault 1 1\n}\ndo_test pager1.4.7.2 {\n  faultsim_restore_and_reopen\n  catch {file attributes test.db-journal -permissions r--------}\n  catch {file attributes test.db-journal -readonly 1}\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ncatch {\n  test_syscall reset\n  test_syscall fault 0 0\n}\ndo_test pager1.4.7.3 {\n  db close\n  catch {file attributes test.db-journal -permissions rw-rw-rw-}\n  catch {file attributes test.db-journal -readonly 0}\n  delete_file test.db-journal\n  file exists test.db-journal\n} {0}\ndo_test pager1.4.8.1 {\n  catch {file attributes test.db -permissions r--------}\n  catch {file attributes test.db -readonly 1}\n  sqlite3 db test.db\n  db eval { SELECT * FROM t1 }\n  sqlite3_db_readonly db main\n} {1}\ndo_test pager1.4.8.2 {\n  sqlite3_db_readonly db xyz\n} {-1}\ndo_test pager1.4.8.3 {\n  db close\n  catch {file attributes test.db -readonly 0}\n  catch {file attributes test.db -permissions rw-rw-rw-} msg\n  sqlite3 db test.db\n  db eval { SELECT * FROM t1 }\n  sqlite3_db_readonly db main\n} {0}\n\n#-------------------------------------------------------------------------\n# The following tests deal with multi-file commits.\n#\n# pager1-5.1.*: The case where a multi-file cannot be committed because\n#               another connection is holding a SHARED lock on one of the\n#               files. After the SHARED lock is removed, the COMMIT succeeds.\n#\n# pager1-5.2.*: Multi-file commits with journal_mode=memory.\n#\n# pager1-5.3.*: Multi-file commits with journal_mode=memory.\n#\n# pager1-5.4.*: Check that with synchronous=normal, the master-journal file\n#               name is added to a journal file immediately after the last\n#               journal record. But with synchronous=full, extra unused space\n#               is allocated between the last journal record and the \n#               master-journal file name so that the master-journal file\n#               name does not lie on the same sector as the last journal file\n#               record.\n#\n# pager1-5.5.*: Check that in journal_mode=PERSIST mode, a journal file is\n#               truncated to zero bytes when a multi-file transaction is \n#               committed (instead of the first couple of bytes being zeroed).\n#\n#\ndo_test pager1-5.1.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE aux.t2(a, b);\n    INSERT INTO t1 VALUES(17, 'Lenin');\n    INSERT INTO t1 VALUES(22, 'Stalin');\n    INSERT INTO t1 VALUES(53, 'Khrushchev');\n  }\n} {}\ndo_test pager1-5.1.2 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES(64, 'Brezhnev');\n      INSERT INTO t2 SELECT * FROM t1;\n  }\n  sqlite3 db2 test.db2\n  execsql {\n    BEGIN;\n      SELECT * FROM t2;\n  } db2\n} {}\ndo_test pager1-5.1.3 {\n  catchsql COMMIT\n} {1 {database is locked}}\ndo_test pager1-5.1.4 {\n  execsql COMMIT db2\n  execsql COMMIT\n  execsql { SELECT * FROM t2 } db2\n} {17 Lenin 22 Stalin 53 Khrushchev 64 Brezhnev}\ndo_test pager1-5.1.5 {\n  db2 close\n} {}\n\ndo_test pager1-5.2.1 {\n  execsql {\n    PRAGMA journal_mode = memory;\n    BEGIN;\n      INSERT INTO t1 VALUES(84, 'Andropov');\n      INSERT INTO t2 VALUES(84, 'Andropov');\n    COMMIT;\n  }\n} {memory}\ndo_test pager1-5.3.1 {\n  execsql {\n    PRAGMA journal_mode = off;\n    BEGIN;\n      INSERT INTO t1 VALUES(85, 'Gorbachev');\n      INSERT INTO t2 VALUES(85, 'Gorbachev');\n    COMMIT;\n  }\n} {off}\n\ndo_test pager1-5.4.1 {\n  db close\n  testvfs tv\n  sqlite3 db test.db -vfs tv\n  execsql { ATTACH 'test.db2' AS aux }\n\n  tv filter xDelete\n  tv script max_journal_size\n  tv sectorsize 512\n  set ::max_journal 0\n  proc max_journal_size {method args} {\n    set sz 0\n    catch { set sz [file size test.db-journal] }\n    if {$sz > $::max_journal} {\n      set ::max_journal $sz\n    }\n    return SQLITE_OK\n  }\n  execsql {\n    PRAGMA journal_mode = DELETE;\n    PRAGMA synchronous = NORMAL;\n    BEGIN;\n      INSERT INTO t1 VALUES(85, 'Gorbachev');\n      INSERT INTO t2 VALUES(85, 'Gorbachev');\n    COMMIT;\n  }\n\n  # The size of the journal file is now:\n  # \n  #   1) 512 byte header +\n  #   2) 2 * (1024+8) byte records +\n  #   3) 20+N bytes of master-journal pointer, where N is the size of \n  #      the master-journal name encoded as utf-8 with no nul term.\n  #\n  set mj_pointer [expr {\n    20 + [string length \"test.db-mjXXXXXX9XX\"]\n  }]\n  #\n  #   NOTE: For item 3 above, if the current SQLite VFS lacks the concept of a\n  #         current directory, the length of the current directory name plus 1\n  #         character for the directory separator character are NOT counted as\n  #         part of the total size; otherwise, they are.\n  #\n  ifcapable curdir {\n    set mj_pointer [expr {$mj_pointer + [string length [get_pwd]] + 1}]\n  }\n  expr {$::max_journal==(512+2*(1024+8)+$mj_pointer)}\n} 1\ndo_test pager1-5.4.2 {\n  set ::max_journal 0\n  execsql {\n    PRAGMA synchronous = full;\n    BEGIN;\n      DELETE FROM t1 WHERE b = 'Lenin';\n      DELETE FROM t2 WHERE b = 'Lenin';\n    COMMIT;\n  }\n\n  # In synchronous=full mode, the master-journal pointer is not written\n  # directly after the last record in the journal file. Instead, it is\n  # written starting at the next (in this case 512 byte) sector boundary.\n  #\n  set mj_pointer [expr {\n    20 + [string length \"test.db-mjXXXXXX9XX\"]\n  }]\n  #\n  #   NOTE: If the current SQLite VFS lacks the concept of a current directory,\n  #         the length of the current directory name plus 1 character for the\n  #         directory separator character are NOT counted as part of the total\n  #         size; otherwise, they are.\n  #\n  ifcapable curdir {\n    set mj_pointer [expr {$mj_pointer + [string length [get_pwd]] + 1}]\n  }\n  expr {$::max_journal==(((512+2*(1024+8)+511)/512)*512 + $mj_pointer)}\n} 1\ndb close\ntv delete\n\ndo_test pager1-5.5.1 {\n  sqlite3 db test.db\n  execsql { \n    ATTACH 'test.db2' AS aux;\n    PRAGMA journal_mode = PERSIST;\n    CREATE TABLE t3(a, b);\n    INSERT INTO t3 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    UPDATE t3 SET b = randomblob(1500);\n  }\n  expr [file size test.db-journal] > 15000\n} {1}\ndo_test pager1-5.5.2 {\n  execsql {\n    PRAGMA synchronous = full;\n    BEGIN;\n      DELETE FROM t1 WHERE b = 'Stalin';\n      DELETE FROM t2 WHERE b = 'Stalin';\n    COMMIT;\n  }\n  file size test.db-journal\n} {0}\n\n\n#-------------------------------------------------------------------------\n# The following tests work with \"PRAGMA max_page_count\"\n#\ndo_test pager1-6.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = none;\n    PRAGMA max_page_count = 10;\n    CREATE TABLE t2(a, b);\n    CREATE TABLE t3(a, b);\n    CREATE TABLE t4(a, b);\n    CREATE TABLE t5(a, b);\n    CREATE TABLE t6(a, b);\n    CREATE TABLE t7(a, b);\n    CREATE TABLE t8(a, b);\n    CREATE TABLE t9(a, b);\n    CREATE TABLE t10(a, b);\n  }\n} {10}\ndo_catchsql_test pager1-6.2 {\n  CREATE TABLE t11(a, b)\n} {1 {database or disk is full}}\ndo_execsql_test pager1-6.4 { PRAGMA max_page_count      } {10}\ndo_execsql_test pager1-6.5 { PRAGMA max_page_count = 15 } {15}\ndo_execsql_test pager1-6.6 { CREATE TABLE t11(a, b)     } {}\ndo_execsql_test pager1-6.7 {\n  BEGIN;\n    INSERT INTO t11 VALUES(1, 2);\n    PRAGMA max_page_count = 13;\n} {13}\ndo_execsql_test pager1-6.8 {\n    INSERT INTO t11 VALUES(3, 4);\n    PRAGMA max_page_count = 10;\n} {11}\ndo_execsql_test pager1-6.9 { COMMIT } {}\n\ndo_execsql_test pager1-6.10 { PRAGMA max_page_count = 10 } {11}\ndo_execsql_test pager1-6.11 { SELECT * FROM t11 }          {1 2 3 4}\ndo_execsql_test pager1-6.12 { PRAGMA max_page_count }      {11}\n\n\n#-------------------------------------------------------------------------\n# The following tests work with \"PRAGMA journal_mode=TRUNCATE\" and\n# \"PRAGMA locking_mode=EXCLUSIVE\".\n#\n# Each test is specified with 5 variables. As follows:\n#\n#   $tn:  Test Number. Used as part of the [do_test] test names.\n#   $sql: SQL to execute.\n#   $res: Expected result of executing $sql.\n#   $js:  The expected size of the journal file, in bytes, after executing\n#         the SQL script. Or -1 if the journal is not expected to exist.\n#   $ws:  The expected size of the WAL file, in bytes, after executing\n#         the SQL script. Or -1 if the WAL is not expected to exist.\n#\nifcapable wal {\n  faultsim_delete_and_reopen\n  foreach {tn sql res js ws} [subst {\n  \n    1  {\n      CREATE TABLE t1(a, b);\n      PRAGMA auto_vacuum=OFF;\n      PRAGMA synchronous=NORMAL;\n      PRAGMA page_size=1024;\n      PRAGMA locking_mode=EXCLUSIVE;\n      PRAGMA journal_mode=TRUNCATE;\n      INSERT INTO t1 VALUES(1, 2);\n    } {exclusive truncate} 0 -1\n  \n    2  {\n      BEGIN IMMEDIATE;\n        SELECT * FROM t1;\n      COMMIT;\n    } {1 2} 0 -1\n  \n    3  {\n      BEGIN;\n        SELECT * FROM t1;\n      COMMIT;\n    } {1 2} 0 -1\n  \n    4  { PRAGMA journal_mode = WAL }    wal       -1 -1\n    5  { INSERT INTO t1 VALUES(3, 4) }  {}        -1 [wal_file_size 1 1024]\n    6  { PRAGMA locking_mode = NORMAL } exclusive -1 [wal_file_size 1 1024]\n    7  { INSERT INTO t1 VALUES(5, 6); } {}        -1 [wal_file_size 2 1024]\n  \n    8  { PRAGMA journal_mode = TRUNCATE } truncate          0 -1\n    9  { INSERT INTO t1 VALUES(7, 8) }    {}                0 -1\n    10 { SELECT * FROM t1 }               {1 2 3 4 5 6 7 8} 0 -1\n  \n  }] {\n    do_execsql_test pager1-7.1.$tn.1 $sql $res\n    catch { set J -1 ; set J [file size test.db-journal] }\n    catch { set W -1 ; set W [file size test.db-wal] }\n    do_test pager1-7.1.$tn.2 { list $J $W } [list $js $ws]\n  }\n}\n\ndo_test pager1-7.2.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA locking_mode = EXCLUSIVE;\n    CREATE TABLE t1(a, b);\n    BEGIN;\n      PRAGMA journal_mode = delete;\n      PRAGMA journal_mode = truncate;\n  }\n} {exclusive delete truncate}\ndo_test pager1-7.2.2 {\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  execsql { PRAGMA journal_mode = persist }\n} {truncate}\ndo_test pager1-7.2.3 {\n  execsql { COMMIT }\n  execsql {\n    PRAGMA journal_mode = persist;\n    PRAGMA journal_size_limit;\n  }\n} {persist -1}\n\n#-------------------------------------------------------------------------\n# The following tests, pager1-8.*, test that the special filenames \n# \":memory:\" and \"\" open temporary databases.\n#\nforeach {tn filename} {\n  1 :memory:\n  2 \"\"\n} {\n  do_test pager1-8.$tn.1 {\n    faultsim_delete_and_reopen\n    db close\n    sqlite3 db $filename\n    execsql {\n      PRAGMA auto_vacuum = 1;\n      CREATE TABLE x1(x);\n      INSERT INTO x1 VALUES('Charles');\n      INSERT INTO x1 VALUES('James');\n      INSERT INTO x1 VALUES('Mary');\n      SELECT * FROM x1;\n    }\n  } {Charles James Mary}\n\n  do_test pager1-8.$tn.2 {\n    sqlite3 db2 $filename\n    catchsql { SELECT * FROM x1 } db2\n  } {1 {no such table: x1}}\n\n  do_execsql_test pager1-8.$tn.3 {\n    BEGIN;\n      INSERT INTO x1 VALUES('William');\n      INSERT INTO x1 VALUES('Anne');\n    ROLLBACK;\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# The next block of tests - pager1-9.* - deal with interactions between\n# the pager and the backup API. Test cases:\n#\n#   pager1-9.1.*: Test that a backup completes successfully even if the\n#                 source db is written to during the backup op.\n#\n#   pager1-9.2.*: Test that a backup completes successfully even if the\n#                 source db is written to and then rolled back during a \n#                 backup operation.\n#\ndo_test pager1-9.0.1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      CREATE TABLE ab(a, b, UNIQUE(a, b));\n      INSERT INTO ab VALUES( a_string(200), a_string(300) );\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n      INSERT INTO ab SELECT a_string(200), a_string(300) FROM ab;\n    COMMIT;\n  }\n} {}\ndo_test pager1-9.0.2 {\n  sqlite3 db2 test.db2\n  db2 eval { PRAGMA cache_size = 10 }\n  sqlite3_backup B db2 main db main\n  list [B step 10000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test pager1-9.0.3 {\n db one {SELECT md5sum(a, b) FROM ab}\n} [db2 one {SELECT md5sum(a, b) FROM ab}]\n\ndo_test pager1-9.1.1 {\n  execsql { UPDATE ab SET a = a_string(201) }\n  sqlite3_backup B db2 main db main\n  B step 30\n} {SQLITE_OK}\ndo_test pager1-9.1.2 {\n  execsql { UPDATE ab SET b = a_string(301) }\n  list [B step 10000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test pager1-9.1.3 {\n db one {SELECT md5sum(a, b) FROM ab}\n} [db2 one {SELECT md5sum(a, b) FROM ab}]\ndo_test pager1-9.1.4 { execsql { SELECT count(*) FROM ab } } {128}\n\ndo_test pager1-9.2.1 {\n  execsql { UPDATE ab SET a = a_string(202) }\n  sqlite3_backup B db2 main db main\n  B step 30\n} {SQLITE_OK}\ndo_test pager1-9.2.2 {\n  execsql { \n    BEGIN;\n      UPDATE ab SET b = a_string(301);\n    ROLLBACK;\n  }\n  list [B step 10000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test pager1-9.2.3 {\n db one {SELECT md5sum(a, b) FROM ab}\n} [db2 one {SELECT md5sum(a, b) FROM ab}]\ndo_test pager1-9.2.4 { execsql { SELECT count(*) FROM ab } } {128}\ndb close\ndb2 close\n\ndo_test pager1-9.3.1 {\n  testvfs tv -default 1\n  tv sectorsize 4096\n  faultsim_delete_and_reopen\n\n  execsql { PRAGMA page_size = 1024 }\n  for {set ii 0} {$ii < 4} {incr ii} { execsql \"CREATE TABLE t${ii}(a, b)\" }\n} {}\nif {[nonzero_reserved_bytes]} {\n  # backup with a page size changes is not possible with the codec\n  #\n  do_test pager1-9.3.2codec {\n    sqlite3 db2 test.db2\n    execsql {\n      PRAGMA page_size = 4096;\n      PRAGMA synchronous = OFF;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n    } db2\n    sqlite3_backup B db2 main db main\n    B step 30\n    list [B step 10000] [B finish]\n  } {SQLITE_READONLY SQLITE_READONLY}\n  do_test pager1-9.3.3codec {\n    db2 close\n    db close\n    tv delete\n    file size test.db2\n  } [file size test.db2]\n} else {\n  do_test pager1-9.3.2 {\n    sqlite3 db2 test.db2\n    execsql {\n      PRAGMA page_size = 4096;\n      PRAGMA synchronous = OFF;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n    } db2\n    sqlite3_backup B db2 main db main\n    B step 30\n    list [B step 10000] [B finish]\n  } {SQLITE_DONE SQLITE_OK}\n  do_test pager1-9.3.3 {\n    db2 close\n    db close\n    tv delete\n    file size test.db2\n  } [file size test.db]\n}\n\ndo_test pager1-9.4.1 {\n  faultsim_delete_and_reopen\n  sqlite3 db2 test.db2\n  execsql {\n    PRAGMA page_size = 4096;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a, b);\n  } db2\n  sqlite3_backup B db2 main db main\n  list [B step 10000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test pager1-9.4.2 {\n  list [file size test.db2] [file size test.db]\n} {1024 0}\ndb2 close\n\n#-------------------------------------------------------------------------\n# Test that regardless of the value returned by xSectorSize(), the\n# minimum effective sector-size is 512 and the maximum 65536 bytes.\n#\ntestvfs tv -default 1\nforeach sectorsize {\n    16\n    32   64   128   256   512   1024   2048 \n    4096 8192 16384 32768 65536 131072 262144\n} {\n  tv sectorsize $sectorsize\n  tv devchar {}\n  set eff $sectorsize\n  if {$sectorsize < 512}   { set eff 512 }\n  if {$sectorsize > 65536} { set eff 65536 }\n\n  do_test pager1-10.$sectorsize.1 {\n    faultsim_delete_and_reopen\n    db func a_string a_string\n    execsql {\n      PRAGMA journal_mode = PERSIST;\n      PRAGMA page_size = 1024;\n      BEGIN;\n        CREATE TABLE t1(a, b);\n        CREATE TABLE t2(a, b);\n        CREATE TABLE t3(a, b);\n      COMMIT;\n    }\n    file size test.db-journal\n  } [expr $sectorsize > 65536 ? 65536 : ($sectorsize<32 ? 512 : $sectorsize)]\n\n  do_test pager1-10.$sectorsize.2 {\n    execsql { \n      INSERT INTO t3 VALUES(a_string(300), a_string(300));\n      INSERT INTO t3 SELECT * FROM t3;        /*  2 */\n      INSERT INTO t3 SELECT * FROM t3;        /*  4 */\n      INSERT INTO t3 SELECT * FROM t3;        /*  8 */\n      INSERT INTO t3 SELECT * FROM t3;        /* 16 */\n      INSERT INTO t3 SELECT * FROM t3;        /* 32 */\n    }\n  } {}\n\n  do_test pager1-10.$sectorsize.3 {\n    db close\n    sqlite3 db test.db\n    execsql { \n      PRAGMA cache_size = 10;\n      BEGIN;\n    }\n    recursive_select 32 t3 {db eval \"INSERT INTO t2 VALUES(1, 2)\"}\n    execsql {\n      COMMIT;\n      SELECT * FROM t2;\n    }\n  } {1 2}\n\n  do_test pager1-10.$sectorsize.4 {\n    execsql {\n      CREATE TABLE t6(a, b);\n      CREATE TABLE t7(a, b);\n      CREATE TABLE t5(a, b);\n      DROP TABLE t6;\n      DROP TABLE t7;\n    }\n    execsql {\n      BEGIN;\n        CREATE TABLE t6(a, b);\n    }\n    recursive_select 32 t3 {db eval \"INSERT INTO t5 VALUES(1, 2)\"}\n    execsql {\n      COMMIT;\n      SELECT * FROM t5;\n    }\n  } {1 2}\n  \n}\ndb close\n\ntv sectorsize 4096\ndo_test pager1.10.x.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = none;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);\n  }\n  for {set i 0} {$i<30} {incr i} {\n    execsql { INSERT INTO t1 VALUES(zeroblob(900)) }\n  }\n  file size test.db\n} {32768}\ndo_test pager1.10.x.2 {\n  execsql {\n    CREATE TABLE t2(x);\n    DROP TABLE t2;\n  }\n  file size test.db\n} {33792}\ndo_test pager1.10.x.3 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t2(x);\n  }\n  recursive_select 30 t1\n  execsql {\n    CREATE TABLE t3(x);\n    COMMIT;\n  }\n} {}\n\ndb close\ntv delete\n\ntestvfs tv -default 1\nfaultsim_delete_and_reopen\ndb func a_string a_string\ndo_execsql_test pager1-11.1 {\n  PRAGMA journal_mode = DELETE;\n  PRAGMA cache_size = 10;\n  BEGIN;\n    CREATE TABLE zz(top PRIMARY KEY);\n    INSERT INTO zz VALUES(a_string(222));\n    INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;\n    INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;\n    INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;\n    INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;\n    INSERT INTO zz SELECT a_string((SELECT 222+max(rowid) FROM zz)) FROM zz;\n  COMMIT;\n  BEGIN;\n    UPDATE zz SET top = a_string(345);\n} {delete}\n\nproc lockout {method args} { return SQLITE_IOERR }\ntv script lockout\ntv filter {xWrite xTruncate xSync}\ndo_catchsql_test pager1-11.2 { COMMIT } {1 {disk I/O error}}\n\ntv script {}\ndo_test pager1-11.3 {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA journal_mode = TRUNCATE;\n    PRAGMA integrity_check;\n  } db2\n} {truncate ok}\ndo_test pager1-11.4 {\n  db2 close\n  file exists test.db-journal\n} {0}\ndo_execsql_test pager1-11.5 { SELECT count(*) FROM zz } {32}\ndb close\ntv delete\n  \n#-------------------------------------------------------------------------\n# Test \"PRAGMA page_size\"\n#\ntestvfs tv -default 1\ntv sectorsize 1024\nforeach pagesize {\n    512   1024   2048 4096 8192 16384 32768 \n} {\n  faultsim_delete_and_reopen\n\n  # The sector-size (according to the VFS) is 1024 bytes. So if the\n  # page-size requested using \"PRAGMA page_size\" is greater than the\n  # compile time value of SQLITE_MAX_PAGE_SIZE, then the effective \n  # page-size remains 1024 bytes.\n  #\n  set eff $pagesize\n  if {$eff > $::SQLITE_MAX_PAGE_SIZE} { set eff 1024 }\n\n  do_test pager1-12.$pagesize.1 {\n    sqlite3 db2 test.db\n    execsql \"\n      PRAGMA page_size = $pagesize;\n      CREATE VIEW v AS SELECT * FROM sqlite_master;\n    \" db2\n    file size test.db\n  } $eff\n  do_test pager1-12.$pagesize.2 {\n    sqlite3 db2 test.db\n    execsql { \n      SELECT count(*) FROM v;\n      PRAGMA main.page_size;\n    } db2\n  } [list 1 $eff]\n  do_test pager1-12.$pagesize.3 {\n    execsql { \n      SELECT count(*) FROM v;\n      PRAGMA main.page_size;\n    }\n  } [list 1 $eff]\n  db2 close\n}\ndb close\ntv delete\n\n#-------------------------------------------------------------------------\n# Test specal \"PRAGMA journal_mode=PERSIST\" test cases.\n#\n# pager1-13.1.*: This tests a special case encountered in persistent \n#                journal mode: If the journal associated with a transaction\n#                is smaller than the journal file (because a previous \n#                transaction left a very large non-hot journal file in the\n#                file-system), then SQLite has to be careful that there is\n#                not a journal-header left over from a previous transaction\n#                immediately following the journal content just written.\n#                If there is, and the process crashes so that the journal\n#                becomes a hot-journal and must be rolled back by another\n#                process, there is a danger that the other process may roll\n#                back the aborted transaction, then continue copying data\n#                from an older transaction from the remainder of the journal.\n#                See the syncJournal() function for details.\n#\n# pager1-13.2.*: Same test as the previous. This time, throw an index into\n#                the mix to make the integrity-check more likely to catch\n#                errors.\n#\ntestvfs tv -default 1\ntv script xSyncCb\ntv filter xSync\nproc xSyncCb {method filename args} {\n  set t [file tail $filename]\n  if {$t == \"test.db\"} faultsim_save\n  return SQLITE_OK\n}\nfaultsim_delete_and_reopen\ndb func a_string a_string\n\n# The UPDATE statement at the end of this test case creates a really big\n# journal. Since the cache-size is only 10 pages, the journal contains \n# frequent journal headers.\n#\ndo_execsql_test pager1-13.1.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = PERSIST;\n  PRAGMA cache_size = 10;\n  BEGIN;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);\n    INSERT INTO t1 VALUES(NULL, a_string(400));\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*   2 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*   4 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*   8 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*  16 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*  32 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /*  64 */\n    INSERT INTO t1 SELECT NULL, a_string(400) FROM t1;          /* 128 */\n  COMMIT;\n  UPDATE t1 SET b = a_string(400);\n} {persist}\n\nif {$::tcl_platform(platform)!=\"windows\"} {\n# Run transactions of increasing sizes. Eventually, one (or more than one)\n# of these will write just enough content that one of the old headers created \n# by the transaction in the block above lies immediately after the content\n# journalled by the current transaction.\n#\nfor {set nUp 1} {$nUp<64} {incr nUp} {\n  do_execsql_test pager1-13.1.2.$nUp.1 { \n    UPDATE t1 SET b = a_string(399) WHERE a <= $nUp\n  } {}\n  do_execsql_test pager1-13.1.2.$nUp.2 { PRAGMA integrity_check } {ok} \n\n  # Try to access the snapshot of the file-system.\n  #\n  sqlite3 db2 sv_test.db\n  do_test pager1-13.1.2.$nUp.3 {\n    execsql { SELECT sum(length(b)) FROM t1 } db2\n  } [expr {128*400 - ($nUp-1)}]\n  do_test pager1-13.1.2.$nUp.4 {\n    execsql { PRAGMA integrity_check } db2\n  } {ok}\n  db2 close\n}\n}\n\nif {$::tcl_platform(platform)!=\"windows\"} {\n# Same test as above. But this time with an index on the table.\n#\ndo_execsql_test pager1-13.2.1 {\n  CREATE INDEX i1 ON t1(b);\n  UPDATE t1 SET b = a_string(400);\n} {}\nfor {set nUp 1} {$nUp<64} {incr nUp} {\n  do_execsql_test pager1-13.2.2.$nUp.1 { \n    UPDATE t1 SET b = a_string(399) WHERE a <= $nUp\n  } {}\n  do_execsql_test pager1-13.2.2.$nUp.2 { PRAGMA integrity_check } {ok} \n  sqlite3 db2 sv_test.db\n  do_test pager1-13.2.2.$nUp.3 {\n    execsql { SELECT sum(length(b)) FROM t1 } db2\n  } [expr {128*400 - ($nUp-1)}]\n  do_test pager1-13.2.2.$nUp.4 {\n    execsql { PRAGMA integrity_check } db2\n  } {ok}\n  db2 close\n}\n}\n\ndb close\ntv delete\n\n#-------------------------------------------------------------------------\n# Test specal \"PRAGMA journal_mode=OFF\" test cases.\n#\nfaultsim_delete_and_reopen\ndo_execsql_test pager1-14.1.1 {\n  PRAGMA journal_mode = OFF;\n  CREATE TABLE t1(a, b);\n  BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  COMMIT;\n  SELECT * FROM t1;\n} {off 1 2}\ndo_catchsql_test pager1-14.1.2 {\n  BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n  ROLLBACK;\n} {0 {}}\ndo_execsql_test pager1-14.1.3 {\n  SELECT * FROM t1;\n} {1 2}\ndo_catchsql_test pager1-14.1.4 {\n  BEGIN;\n    INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;\n    INSERT INTO t1(rowid, a, b) SELECT a+3, b, b FROM t1;\n} {1 {UNIQUE constraint failed: t1.rowid}}\ndo_execsql_test pager1-14.1.5 {\n  COMMIT;\n  SELECT * FROM t1;\n} {1 2 2 2}\n\n#-------------------------------------------------------------------------\n# Test opening and closing the pager sub-system with different values\n# for the sqlite3_vfs.szOsFile variable.\n#\nfaultsim_delete_and_reopen\ndo_execsql_test pager1-15.0 {\n  CREATE TABLE tx(y, z);\n  INSERT INTO tx VALUES('Ayutthaya', 'Beijing');\n  INSERT INTO tx VALUES('London', 'Tokyo');\n} {}\ndb close\nfor {set i 0} {$i<513} {incr i 3} {\n  testvfs tv -default 1 -szosfile $i\n  sqlite3 db test.db\n  do_execsql_test pager1-15.$i.1 {\n    SELECT * FROM tx;\n  } {Ayutthaya Beijing London Tokyo}\n  db close\n  tv delete\n}\n\n#-------------------------------------------------------------------------\n# Check that it is not possible to open a database file if the full path\n# to the associated journal file will be longer than sqlite3_vfs.mxPathname.\n#\ntestvfs tv -default 1\ntv script xOpenCb\ntv filter xOpen\nproc xOpenCb {method filename args} {\n  set ::file_len [string length $filename]\n}\nsqlite3 db test.db\ndb close\ntv delete\n\nfor {set ii [expr $::file_len-5]} {$ii < [expr $::file_len+20]} {incr ii} {\n  testvfs tv -default 1 -mxpathname $ii\n\n  # The length of the full path to file \"test.db-journal\" is ($::file_len+8).\n  # If the configured sqlite3_vfs.mxPathname value greater than or equal to\n  # this, then the file can be opened. Otherwise, it cannot.\n  #\n  if {$ii >= [expr $::file_len+8]} {\n    set res {0 {}}\n  } else {\n    set res {1 {unable to open database file}}\n  }\n\n  do_test pager1-16.1.$ii {\n    list [catch { sqlite3 db test.db } msg] $msg\n  } $res\n\n  catch {db close}\n  tv delete\n}\n\n\n#-------------------------------------------------------------------------\n# Test the pagers response to the b-tree layer requesting illegal page \n# numbers:\n#\n#   + The locking page,\n#   + Page 0,\n#   + A page with a page number greater than (2^31-1).\n#\n# These tests will not work if SQLITE_DIRECT_OVERFLOW_READ is defined. In\n# that case IO errors are sometimes reported instead of SQLITE_CORRUPT.\n#\nifcapable !direct_read {\ndo_test pager1-18.1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql { \n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(a_string(500), a_string(200));\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n    INSERT INTO t1 SELECT a_string(500), a_string(200) FROM t1;\n  }\n} {}\ndo_test pager1-18.2 {\n  set root [db one \"SELECT rootpage FROM sqlite_master\"]\n  set lockingpage [expr (0x10000/1024) + 1]\n  execsql {\n    PRAGMA writable_schema = 1;\n    UPDATE sqlite_master SET rootpage = $lockingpage;\n  }\n  sqlite3 db2 test.db\n  catchsql { SELECT count(*) FROM t1 } db2\n} {1 {database disk image is malformed}}\ndb2 close\ndo_test pager1-18.3.1 {\n  execsql {\n    CREATE TABLE t2(x);\n    INSERT INTO t2 VALUES(a_string(5000));\n  }\n  set pgno [expr ([file size test.db] / 1024)-2]\n  hexio_write test.db [expr ($pgno-1)*1024] 00000000\n  sqlite3 db2 test.db\n  # even though x is malformed, because typeof() does\n  # not load the content of x, the error is not noticed.\n  catchsql { SELECT typeof(x) FROM t2 } db2\n} {0 text}\ndo_test pager1-18.3.2 {\n  # in this case, the value of x is loaded and so the error is\n  # detected\n  catchsql { SELECT length(x||'') FROM t2 } db2\n} {1 {database disk image is malformed}}\ndb2 close\ndo_test pager1-18.3.3 {\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(randomblob(5000));\n  }\n  set pgno [expr ([file size test.db] / 1024)-2]\n  hexio_write test.db [expr ($pgno-1)*1024] 00000000\n  sqlite3 db2 test.db\n  # even though x is malformed, because length() and typeof() do\n  # not load the content of x, the error is not noticed.\n  catchsql { SELECT length(x), typeof(x) FROM t2 } db2\n} {0 {5000 blob}}\ndo_test pager1-18.3.4 {\n  # in this case, the value of x is loaded and so the error is\n  # detected\n  catchsql { SELECT length(x||'') FROM t2 } db2\n} {1 {database disk image is malformed}}\ndb2 close\ndo_test pager1-18.4 {\n  hexio_write test.db [expr ($pgno-1)*1024] 90000000\n  sqlite3 db2 test.db\n  catchsql { SELECT length(x||'') FROM t2 } db2\n} {1 {database disk image is malformed}}\ndb2 close\ndo_test pager1-18.5 {\n  sqlite3 db \"\"\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a, b);\n    PRAGMA writable_schema = 1;\n    UPDATE sqlite_master SET rootpage=5 WHERE tbl_name = 't1';\n    PRAGMA writable_schema = 0;\n    ALTER TABLE t1 RENAME TO x1;\n  }\n  catchsql { SELECT * FROM x1 }\n} {1 {database disk image is malformed}}\ndb close\n\ndo_test pager1-18.6 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(a_string(800));\n    INSERT INTO t1 VALUES(a_string(800));\n  }\n\n  set root [db one \"SELECT rootpage FROM sqlite_master\"]\n  db close\n\n  hexio_write test.db [expr ($root-1)*1024 + 8] 00000000\n  sqlite3 db test.db\n  catchsql { SELECT length(x) FROM t1 }\n} {1 {database disk image is malformed}}\n}\n\ndo_test pager1-19.1 {\n  sqlite3 db \"\"\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,\n                    ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,\n                    ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,\n                    da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,\n                    ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,\n                    fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,\n                    ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,\n                    ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,\n                    ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,\n                    ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,\n                    ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,\n                    la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,\n                    ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn\n    );\n    CREATE TABLE t2(aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an,\n                    ba, bb, bc, bd, be, bf, bg, bh, bi, bj, bk, bl, bm, bn,\n                    ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, cn,\n                    da, db, dc, dd, de, df, dg, dh, di, dj, dk, dl, dm, dn,\n                    ea, eb, ec, ed, ee, ef, eg, eh, ei, ej, ek, el, em, en,\n                    fa, fb, fc, fd, fe, ff, fg, fh, fi, fj, fk, fl, fm, fn,\n                    ga, gb, gc, gd, ge, gf, gg, gh, gi, gj, gk, gl, gm, gn,\n                    ha, hb, hc, hd, he, hf, hg, hh, hi, hj, hk, hl, hm, hn,\n                    ia, ib, ic, id, ie, if, ig, ih, ii, ij, ik, il, im, ix,\n                    ja, jb, jc, jd, je, jf, jg, jh, ji, jj, jk, jl, jm, jn,\n                    ka, kb, kc, kd, ke, kf, kg, kh, ki, kj, kk, kl, km, kn,\n                    la, lb, lc, ld, le, lf, lg, lh, li, lj, lk, ll, lm, ln,\n                    ma, mb, mc, md, me, mf, mg, mh, mi, mj, mk, ml, mm, mn\n    );\n    INSERT INTO t1(aa) VALUES( a_string(100000) );\n    INSERT INTO t2(aa) VALUES( a_string(100000) );\n    VACUUM;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test a couple of special cases that come up while committing \n# transactions:\n#\n#   pager1-20.1.*: Committing an in-memory database transaction when the \n#                  database has not been modified at all.\n#\n#   pager1-20.2.*: As above, but with a normal db in exclusive-locking mode.\n#\n#   pager1-20.3.*: Committing a transaction in WAL mode where the database has\n#                  been modified, but all dirty pages have been flushed to \n#                  disk before the commit.\n#\ndo_test pager1-20.1.1 {\n  catch {db close}\n  sqlite3 db :memory:\n  execsql {\n    CREATE TABLE one(two, three);\n    INSERT INTO one VALUES('a', 'b');\n  }\n} {}\ndo_test pager1-20.1.2 {\n  execsql {\n    BEGIN EXCLUSIVE;\n    COMMIT;\n  }\n} {}\n\ndo_test pager1-20.2.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA locking_mode = exclusive;\n    PRAGMA journal_mode = persist;\n    CREATE TABLE one(two, three);\n    INSERT INTO one VALUES('a', 'b');\n  }\n} {exclusive persist}\ndo_test pager1-20.2.2 {\n  execsql {\n    BEGIN EXCLUSIVE;\n    COMMIT;\n  }\n} {}\n\nifcapable wal {\n  do_test pager1-20.3.1 {\n    faultsim_delete_and_reopen\n    db func a_string a_string\n    execsql {\n      PRAGMA cache_size = 10;\n      PRAGMA journal_mode = wal;\n      BEGIN;\n        CREATE TABLE t1(x);\n        CREATE TABLE t2(y);\n        INSERT INTO t1 VALUES(a_string(800));\n        INSERT INTO t1 SELECT a_string(800) FROM t1;         /*   2 */\n        INSERT INTO t1 SELECT a_string(800) FROM t1;         /*   4 */\n        INSERT INTO t1 SELECT a_string(800) FROM t1;         /*   8 */\n        INSERT INTO t1 SELECT a_string(800) FROM t1;         /*  16 */\n        INSERT INTO t1 SELECT a_string(800) FROM t1;         /*  32 */\n      COMMIT;\n    }\n  } {wal}\n  do_test pager1-20.3.2 {\n    execsql {\n      BEGIN;\n      INSERT INTO t2 VALUES('xxxx');\n    }\n    recursive_select 32 t1\n    execsql COMMIT\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Test that a WAL database may not be opened if:\n#\n#   pager1-21.1.*: The VFS has an iVersion less than 2, or\n#   pager1-21.2.*: The VFS does not provide xShmXXX() methods.\n#\nifcapable wal {\n  do_test pager1-21.0 {\n    faultsim_delete_and_reopen\n    execsql {\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');\n      INSERT INTO ko DEFAULT VALUES;\n    }\n  } {wal}\n  do_test pager1-21.1 {\n    testvfs tv -noshm 1\n    sqlite3 db2 test.db -vfs tv\n    catchsql { SELECT * FROM ko } db2\n  } {1 {unable to open database file}}\n  db2 close\n  tv delete\n  do_test pager1-21.2 {\n    testvfs tv -iversion 1\n    sqlite3 db2 test.db -vfs tv\n    catchsql { SELECT * FROM ko } db2\n  } {1 {unable to open database file}}\n  db2 close\n  tv delete\n}\n\n#-------------------------------------------------------------------------\n# Test that a \"PRAGMA wal_checkpoint\":\n#\n#   pager1-22.1.*: is a no-op on a non-WAL db, and\n#   pager1-22.2.*: does not cause xSync calls with a synchronous=off db.\n#\nifcapable wal {\n  do_test pager1-22.1.1 {\n    faultsim_delete_and_reopen\n    execsql {\n      CREATE TABLE ko(c DEFAULT 'abc', b DEFAULT 'def');\n      INSERT INTO ko DEFAULT VALUES;\n    }\n    execsql { PRAGMA wal_checkpoint }\n  } {0 -1 -1}\n  do_test pager1-22.2.1 {\n    testvfs tv -default 1\n    tv filter xSync\n    tv script xSyncCb\n    proc xSyncCb {args} {incr ::synccount}\n    set ::synccount 0\n    sqlite3 db test.db\n    execsql {\n      PRAGMA synchronous = off;\n      PRAGMA journal_mode = WAL;\n      INSERT INTO ko DEFAULT VALUES;\n    }\n    execsql { PRAGMA wal_checkpoint }\n    set synccount\n  } {0}\n  db close\n  tv delete\n}\n\n#-------------------------------------------------------------------------\n# Tests for changing journal mode.\n#\n#   pager1-23.1.*: Test that when changing from PERSIST to DELETE mode,\n#                  the journal file is deleted.\n#\n#   pager1-23.2.*: Same test as above, but while a shared lock is held\n#                  on the database file.\n#\n#   pager1-23.3.*: Same test as above, but while a reserved lock is held\n#                  on the database file.\n#\n#   pager1-23.4.*: And, for fun, while holding an exclusive lock.\n#\n#   pager1-23.5.*: Try to set various different journal modes with an\n#                  in-memory database (only MEMORY and OFF should work).\n#\n#   pager1-23.6.*: Try to set locking_mode=normal on an in-memory database\n#                  (doesn't work - in-memory databases always use\n#                  locking_mode=exclusive).\n#\ndo_test pager1-23.1.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    CREATE TABLE t1(a, b);\n  }\n  file exists test.db-journal\n} {1}\ndo_test pager1-23.1.2 {\n  execsql { PRAGMA journal_mode = DELETE }\n  file exists test.db-journal\n} {0}\n\ndo_test pager1-23.2.1 {\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    INSERT INTO t1 VALUES('Canberra', 'ACT');\n  }\n  db eval { SELECT * FROM t1 } {\n    db eval { PRAGMA journal_mode = DELETE }\n  }\n  execsql { PRAGMA journal_mode }\n} {delete}\ndo_test pager1-23.2.2 {\n  file exists test.db-journal\n} {0}\n\ndo_test pager1-23.3.1 {\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    INSERT INTO t1 VALUES('Darwin', 'NT');\n    BEGIN IMMEDIATE;\n  }\n  db eval { PRAGMA journal_mode = DELETE }\n  execsql { PRAGMA journal_mode }\n} {delete}\ndo_test pager1-23.3.2 {\n  file exists test.db-journal\n} {0}\ndo_test pager1-23.3.3 {\n  execsql COMMIT\n} {}\n\ndo_test pager1-23.4.1 {\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    INSERT INTO t1 VALUES('Adelaide', 'SA');\n    BEGIN EXCLUSIVE;\n  }\n  db eval { PRAGMA journal_mode = DELETE }\n  execsql { PRAGMA journal_mode }\n} {delete}\ndo_test pager1-23.4.2 {\n  file exists test.db-journal\n} {0}\ndo_test pager1-23.4.3 {\n  execsql COMMIT\n} {}\n\ndo_test pager1-23.5.1 {\n  faultsim_delete_and_reopen\n  sqlite3 db :memory:\n} {}\nforeach {tn mode possible} {\n  2  off      1\n  3  memory   1\n  4  persist  0\n  5  delete   0\n  6  wal      0\n  7  truncate 0\n} {\n  do_test pager1-23.5.$tn.1 {\n    execsql \"PRAGMA journal_mode = off\"\n    execsql \"PRAGMA journal_mode = $mode\"\n  } [if $possible {list $mode} {list off}]\n  do_test pager1-23.5.$tn.2 {\n    execsql \"PRAGMA journal_mode = memory\"\n    execsql \"PRAGMA journal_mode = $mode\"\n  } [if $possible {list $mode} {list memory}]\n}\ndo_test pager1-23.6.1 {\n  execsql {PRAGMA locking_mode = normal}\n} {exclusive}\ndo_test pager1-23.6.2 {\n  execsql {PRAGMA locking_mode = exclusive}\n} {exclusive}\ndo_test pager1-23.6.3 {\n  execsql {PRAGMA locking_mode}\n} {exclusive}\ndo_test pager1-23.6.4 {\n  execsql {PRAGMA main.locking_mode}\n} {exclusive}\n\n#-------------------------------------------------------------------------\n#\ndo_test pager1-24.1.1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA auto_vacuum = FULL;\n    CREATE TABLE x1(x, y, z, PRIMARY KEY(y, z));\n    CREATE TABLE x2(x, y, z, PRIMARY KEY(y, z));\n    INSERT INTO x2 VALUES(a_string(400), a_string(500), a_string(600));\n    INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;\n    INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;\n    INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;\n    INSERT INTO x2 SELECT a_string(600), a_string(400), a_string(500) FROM x2;\n    INSERT INTO x2 SELECT a_string(500), a_string(600), a_string(400) FROM x2;\n    INSERT INTO x2 SELECT a_string(400), a_string(500), a_string(600) FROM x2;\n    INSERT INTO x1 SELECT * FROM x2;\n  }\n} {}\ndo_test pager1-24.1.2 {\n  execsql {\n    BEGIN;\n      DELETE FROM x1 WHERE rowid<32;\n  }\n  recursive_select 64 x2\n} {}\ndo_test pager1-24.1.3 {\n  execsql { \n      UPDATE x1 SET z = a_string(300) WHERE rowid>40;\n    COMMIT;\n    PRAGMA integrity_check;\n    SELECT count(*) FROM x1;\n  }\n} {ok 33}\n\ndo_test pager1-24.1.4 {\n  execsql {\n    DELETE FROM x1;\n    INSERT INTO x1 SELECT * FROM x2;\n    BEGIN;\n      DELETE FROM x1 WHERE rowid<32;\n      UPDATE x1 SET z = a_string(299) WHERE rowid>40;\n  }\n  recursive_select 64 x2 {db eval COMMIT}\n  execsql {\n    PRAGMA integrity_check;\n    SELECT count(*) FROM x1;\n  }\n} {ok 33}\n\ndo_test pager1-24.1.5 {\n  execsql {\n    DELETE FROM x1;\n    INSERT INTO x1 SELECT * FROM x2;\n  }\n  recursive_select 64 x2 { db eval {CREATE TABLE x3(x, y, z)} }\n  execsql { SELECT * FROM x3 }\n} {}\n\n#-------------------------------------------------------------------------\n#\ndo_test pager1-25-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    BEGIN;\n      SAVEPOINT abc;\n        CREATE TABLE t1(a, b);\n      ROLLBACK TO abc;\n    COMMIT;\n  }\n  db close\n} {}\ndo_test pager1-25-2 {\n  faultsim_delete_and_reopen\n  execsql {\n    SAVEPOINT abc;\n      CREATE TABLE t1(a, b);\n    ROLLBACK TO abc;\n    COMMIT;\n  }\n  db close\n} {}\n\n#-------------------------------------------------------------------------\n# Sector-size tests.\n#\ndo_test pager1-26.1 {\n  testvfs tv -default 1\n  tv sectorsize 4096\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 512;\n    CREATE TABLE tbl(a PRIMARY KEY, b UNIQUE);\n    BEGIN;\n      INSERT INTO tbl VALUES(a_string(25), a_string(600));\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n      INSERT INTO tbl SELECT a_string(25), a_string(600) FROM tbl;\n    COMMIT;\n  }\n} {}\ndo_execsql_test pager1-26.1 {\n  UPDATE tbl SET b = a_string(550);\n} {}\ndb close\ntv delete\n\n#-------------------------------------------------------------------------\n#\ndo_test pager1.27.1 {\n  faultsim_delete_and_reopen\n  sqlite3_pager_refcounts db\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n  }\n  sqlite3_pager_refcounts db\n  execsql COMMIT\n} {}\n\n#-------------------------------------------------------------------------\n# Test that attempting to open a write-transaction with \n# locking_mode=exclusive in WAL mode fails if there are other clients on \n# the same database.\n#\ncatch { db close }\nifcapable wal {\n  do_multiclient_test tn {\n    do_test pager1-28.$tn.1 {\n      sql1 { \n        PRAGMA journal_mode = WAL;\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES('a', 'b');\n      }\n    } {wal}\n    do_test pager1-28.$tn.2 { sql2 { SELECT * FROM t1 } } {a b}\n\n    do_test pager1-28.$tn.3 { sql1 { PRAGMA locking_mode=exclusive } } {exclusive}\n    do_test pager1-28.$tn.4 { \n      csql1 { BEGIN; INSERT INTO t1 VALUES('c', 'd'); }\n    } {1 {database is locked}}\n    code2 { db2 close ; sqlite3 db2 test.db }\n    do_test pager1-28.$tn.4 { \n      sql1 { INSERT INTO t1 VALUES('c', 'd'); COMMIT }\n    } {}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Normally, when changing from journal_mode=PERSIST to DELETE the pager\n# attempts to delete the journal file. However, if it cannot obtain a\n# RESERVED lock on the database file, this step is skipped.\n#\ndo_multiclient_test tn {\n  do_test pager1-28.$tn.1 {\n    sql1 { \n      PRAGMA journal_mode = PERSIST;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES('a', 'b');\n    }\n  } {persist}\n  do_test pager1-28.$tn.2 { file exists test.db-journal } 1\n  do_test pager1-28.$tn.3 { sql1 { PRAGMA journal_mode = DELETE } } delete\n  do_test pager1-28.$tn.4 { file exists test.db-journal } 0\n\n  do_test pager1-28.$tn.5 {\n    sql1 { \n      PRAGMA journal_mode = PERSIST;\n      INSERT INTO t1 VALUES('c', 'd');\n    }\n  } {persist}\n  do_test pager1-28.$tn.6 { file exists test.db-journal } 1\n  do_test pager1-28.$tn.7 {\n    sql2 { BEGIN; INSERT INTO t1 VALUES('e', 'f'); }\n  } {}\n  do_test pager1-28.$tn.8  { file exists test.db-journal } 1\n  do_test pager1-28.$tn.9  { sql1 { PRAGMA journal_mode = DELETE } } delete\n  do_test pager1-28.$tn.10 { file exists test.db-journal } 1\n\n  do_test pager1-28.$tn.11 { sql2 COMMIT } {}\n  do_test pager1-28.$tn.12 { file exists test.db-journal } 0\n\n  do_test pager1-28-$tn.13 {\n    code1 { set channel [db incrblob -readonly t1 a 2] }\n    sql1 {\n      PRAGMA journal_mode = PERSIST;\n      INSERT INTO t1 VALUES('g', 'h');\n    }\n  } {persist}\n  do_test pager1-28.$tn.14 { file exists test.db-journal } 1\n  do_test pager1-28.$tn.15 {\n    sql2 { BEGIN; INSERT INTO t1 VALUES('e', 'f'); }\n  } {}\n  do_test pager1-28.$tn.16 { sql1 { PRAGMA journal_mode = DELETE } } delete\n  do_test pager1-28.$tn.17 { file exists test.db-journal } 1\n\n  do_test pager1-28.$tn.17 { csql2 { COMMIT } } {1 {database is locked}}\n  do_test pager1-28-$tn.18 { code1 { read $channel } } c\n  do_test pager1-28-$tn.19 { code1 { close $channel } } {}\n  do_test pager1-28.$tn.20 { sql2 { COMMIT } } {}\n}\n\ndo_test pager1-29.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = full;\n    PRAGMA locking_mode=exclusive;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  file size test.db\n} [expr 1024*3]\nif {[nonzero_reserved_bytes]} {\n  # VACUUM with size changes is not possible with the codec.\n  do_test pager1-29.2 {\n    catchsql {\n      PRAGMA page_size = 4096;\n      VACUUM;\n    }\n  } {1 {attempt to write a readonly database}}\n} else {\n  do_test pager1-29.2 {\n    execsql {\n      PRAGMA page_size = 4096;\n      VACUUM;\n    }\n    file size test.db\n  } [expr 4096*3]\n}\n\n#-------------------------------------------------------------------------\n# Test that if an empty database file (size 0 bytes) is opened in \n# exclusive-locking mode, any journal file is deleted from the file-system\n# without being rolled back. And that the RESERVED lock obtained while\n# doing this is not released.\n#\ndo_test pager1-30.1 {\n  db close\n  delete_file test.db\n  delete_file test.db-journal\n  set fd [open test.db-journal w]\n  seek $fd [expr 512+1032*2]\n  puts -nonewline $fd x\n  close $fd\n\n  sqlite3 db test.db\n  execsql {\n    PRAGMA locking_mode=EXCLUSIVE;\n    SELECT count(*) FROM sqlite_master;\n    PRAGMA lock_status;\n  }\n} {exclusive 0 main reserved temp closed}\n\n#-------------------------------------------------------------------------\n# Test that if the \"page-size\" field in a journal-header is 0, the journal\n# file can still be rolled back. This is required for backward compatibility -\n# versions of SQLite prior to 3.5.8 always set this field to zero.\n#\nif {$tcl_platform(platform)==\"unix\"} {\ndo_test pager1-31.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x, y, UNIQUE(x, y));\n    INSERT INTO t1 VALUES(randomblob(1500), randomblob(1500));\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1;\n    BEGIN;\n      UPDATE t1 SET y = randomblob(1499);\n  }\n  copy_file test.db test.db2\n  copy_file test.db-journal test.db2-journal\n  \n  hexio_write test.db2-journal 24 00000000\n  sqlite3 db2 test.db2\n  execsql { PRAGMA integrity_check } db2\n} {ok}\n}\n\n#-------------------------------------------------------------------------\n# Test that a database file can be \"pre-hinted\" to a certain size and that\n# subsequent spilling of the pager cache does not result in the database\n# file being shrunk.\n#\ncatch {db close}\nforcedelete test.db\n\ndo_test pager1-32.1 {\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(x, y);\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(1, randomblob(10000));\n  }\n  file_control_chunksize_test db main 1024\n  file_control_sizehint_test db main 20971520; # 20MB\n  execsql {\n    PRAGMA cache_size = 10;\n    INSERT INTO t1 VALUES(1, randomblob(10000));\n    INSERT INTO t1 VALUES(2, randomblob(10000));\n    INSERT INTO t1 SELECT x+2, randomblob(10000) from t1;\n    INSERT INTO t1 SELECT x+4, randomblob(10000) from t1;\n    INSERT INTO t1 SELECT x+8, randomblob(10000) from t1;\n    INSERT INTO t1 SELECT x+16, randomblob(10000) from t1;\n    SELECT count(*) FROM t1;\n    COMMIT;\n  }\n  db close\n  file size test.db\n} {20971520}\n\n# Cleanup 20MB file left by the previous test.\nforcedelete test.db\n\n#-------------------------------------------------------------------------\n# Test that if a transaction is committed in journal_mode=DELETE mode,\n# and the call to unlink() returns an ENOENT error, the COMMIT does not\n# succeed.\n#\nif {$::tcl_platform(platform)==\"unix\"} {\n  do_test pager1-33.1 {\n    sqlite3 db test.db\n    execsql {\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES('one');\n      INSERT INTO t1 VALUES('two');\n      BEGIN;\n        INSERT INTO t1 VALUES('three');\n        INSERT INTO t1 VALUES('four');\n    }\n    forcedelete bak-journal\n    file rename test.db-journal bak-journal\n\n    catchsql COMMIT\n  } {1 {disk I/O error}}\n\n  do_test pager1-33.2 {\n    file rename bak-journal test.db-journal\n    execsql { SELECT * FROM t1 }\n  } {one two}\n}\n\n#-------------------------------------------------------------------------\n# Test that appending pages to the database file then moving those pages\n# to the free-list before the transaction is committed does not cause\n# an error.\n#\nforeach {tn pragma strsize} {\n  1 { PRAGMA mmap_size = 0 } 2400\n  2 { }                       2400\n  3 { PRAGMA mmap_size = 0 } 4400\n  4 { }                       4400\n} {\n  reset_db\n  db func a_string a_string\n  db eval $pragma\n  do_execsql_test 34.$tn.1 {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  do_execsql_test 34.$tn.2 {\n    BEGIN;\n    INSERT INTO t1 VALUES(2, a_string($strsize));\n    DELETE FROM t1 WHERE oid=2;\n    COMMIT;\n    PRAGMA integrity_check;\n  } {ok}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_test 35 {\n  sqlite3 db test.db\n\n  execsql {\n    CREATE TABLE t1(x, y);\n    PRAGMA journal_mode = WAL;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n\n  execsql {\n    BEGIN;\n      CREATE TABLE t2(a, b);\n  }\n\n  hexio_write test.db-shm [expr 16*1024] [string repeat 0055 8192]\n  catchsql ROLLBACK\n} {0 {}}\n\ndo_multiclient_test tn {\n  sql1 {\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n\n  do_test 36.$tn.1 { \n    sql2 { PRAGMA max_page_count = 2 }\n    list [catch { sql2 { CREATE TABLE t2(x) } } msg] $msg\n  } {1 {database or disk is full}}\n\n  sql1 { PRAGMA checkpoint_fullfsync = 1 }\n  sql1 { CREATE TABLE t2(x) }\n\n  do_test 36.$tn.2 { \n    sql2 { INSERT INTO t2 VALUES('xyz') }\n    list [catch { sql2 { CREATE TABLE t3(x) } } msg] $msg\n  } {1 {database or disk is full}}\n}\n\nforcedelete test1 test2\nforeach {tn uri} {\n  1   {file:?mode=memory&cache=shared}\n  2   {file:one?mode=memory&cache=shared}\n  3   {file:test1?cache=shared}\n  4   {file:test2?another=parameter&yet=anotherone}\n} {\n  do_test 37.$tn {\n    catch { db close }\n    sqlite3_shutdown\n    sqlite3_config_uri 1\n    sqlite3 db $uri\n\n    db eval {\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES(1);\n      SELECT * FROM t1;\n    }\n  } {1}\n\n  do_execsql_test 37.$tn.2 {\n    VACUUM;\n    SELECT * FROM t1;\n  } {1}\n\n  db close\n  sqlite3_shutdown\n  sqlite3_config_uri 0\n}\n\ndo_test 38.1 {\n  catch { db close }\n  forcedelete test.db\n  set fd [open test.db w]\n  puts $fd \"hello world\"\n  close $fd\n  sqlite3 db test.db\n  catchsql { CREATE TABLE t1(x) }\n} {1 {file is not a database}}\ndo_test 38.2 {\n  catch { db close }\n  forcedelete test.db\n} {}\n\ndo_test 39.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('xxx');\n    INSERT INTO t1 VALUES('two');\n    INSERT INTO t1 VALUES(randomblob(400));\n    INSERT INTO t1 VALUES(randomblob(400));\n    INSERT INTO t1 VALUES(randomblob(400));\n    INSERT INTO t1 VALUES(randomblob(400));\n    BEGIN;\n    UPDATE t1 SET x = 'one' WHERE rowid=1;\n  }\n  set ::stmt [sqlite3_prepare db \"SELECT * FROM t1 ORDER BY rowid\" -1 dummy]\n  sqlite3_step $::stmt\n  sqlite3_column_text $::stmt 0\n} {one}\ndo_test 39.2 {\n  execsql { CREATE TABLE t2(x) }\n  sqlite3_step $::stmt\n  sqlite3_column_text $::stmt 0\n} {two}\ndo_test 39.3 {\n  sqlite3_finalize $::stmt\n  execsql COMMIT\n} {}\n\ndo_execsql_test 39.4 {\n  PRAGMA auto_vacuum = 2;\n  CREATE TABLE t3(x);\n  CREATE TABLE t4(x);\n\n  DROP TABLE t2;\n  DROP TABLE t3;\n  DROP TABLE t4;\n}\ndo_test 39.5 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size = 1;\n    PRAGMA incremental_vacuum;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\ndo_test 40.1 {\n  reset_db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES(randomblob(1200));\n    PRAGMA page_count;\n  }\n} {6}\ndo_test 40.2 {\n  execsql {\n    INSERT INTO t1 VALUES(randomblob(1200));\n    INSERT INTO t1 VALUES(randomblob(1200));\n    INSERT INTO t1 VALUES(randomblob(1200));\n  }\n} {}\ndo_test 40.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size = 1;\n    CREATE TABLE t2(x);\n    PRAGMA integrity_check;\n  }\n} {ok}\n\ndo_test 41.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES(randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200) FROM t1;\n  }\n} {}\ndo_test 41.2 {\n  testvfs tv -default 1\n  tv sectorsize 16384;\n  tv devchar [list]\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size = 1;\n    DELETE FROM t1 WHERE rowid%4;\n    PRAGMA integrity_check;\n  }\n} {ok}\ndb close\ntv delete\n\nset pending_prev [sqlite3_test_control_pending_byte 0x1000000]\ndo_test 42.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n  }\n  db close\n  sqlite3_test_control_pending_byte 0x0010000\n  sqlite3 db test.db\n  db eval { PRAGMA mmap_size = 0 }\n  catchsql { SELECT sum(length(y)) FROM t1 }\n} {1 {database disk image is malformed}}\ndo_test 42.2 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n  }\n  db close\n\n  testvfs tv -default 1\n  tv sectorsize 16384;\n  tv devchar [list]\n  sqlite3 db test.db -vfs tv\n  execsql { UPDATE t1 SET x = randomblob(200) }\n} {}\ndb close\ntv delete\nsqlite3_test_control_pending_byte $pending_prev\n\ndo_test 43.1 {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(1, 2);\n    CREATE TABLE t2(x, y);\n    INSERT INTO t2 VALUES(1, 2);\n    CREATE TABLE t3(x, y);\n    INSERT INTO t3 VALUES(1, 2);\n  }\n  db close\n  sqlite3 db test.db\n\n  db eval { PRAGMA mmap_size = 0 }\n  db eval { SELECT * FROM t1 }\n  sqlite3_db_status db CACHE_MISS 0\n} {0 2 0}\n\ndo_test 43.2 {\n  db eval { SELECT * FROM t2 }\n  sqlite3_db_status db CACHE_MISS 1\n} {0 3 0}\n\ndo_test 43.3 {\n  db eval { SELECT * FROM t3 }\n  sqlite3_db_status db CACHE_MISS 0\n} {0 1 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pager2.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nset otn 0\ntestvfs tv -default 1\nforeach code [list {\n  set s 512\n} {\n  set s 1024\n  set sql { PRAGMA journal_mode = memory }\n} {\n  set s 1024\n  set sql { \n    PRAGMA journal_mode = memory;\n    PRAGMA locking_mode = exclusive;\n  }\n} {\n  set s 2048\n  tv devchar safe_append\n} {\n  set s 4096\n} {\n  set s 4096\n  set sql { PRAGMA journal_mode = WAL }\n} {\n  set s 4096\n  set sql { PRAGMA auto_vacuum = 1 }\n} {\n  set s 8192\n  set sql { PRAGMA synchronous = off }\n}] {\n\n  incr otn\n  set sql \"\"\n  tv devchar {}\n  eval $code\n  tv sectorsize $s\n  \n  do_test pager2-1.$otn.0 {\n    faultsim_delete_and_reopen\n    execsql $sql\n    execsql {\n      PRAGMA cache_size = 10;\n      CREATE TABLE t1(i INTEGER PRIMARY KEY, j blob);\n    }\n  } {}\n\n  set tn 0\n  set lowpoint 0\n  foreach x {\n    100 x 0 100\n  x\n    70 22 96 59 96 50 22 56 21 16 37 64 43 40  0 38 22 38 55  0  6   \n    43 62 32 93 54 18 13 29 45 66 29 25 61 31 53 82 75 25 96 86 10 69   \n     2 29  6 60 80 95 42 82 85 50 68 96 90 39 78 69 87 97 48 74 65 43   \n  x\n    86 34 26 50 41 85 58 44 89 22  6 51 45 46 58 32 97  6  1 12 32  2   \n    69 39 48 71 33 31  5 58 90 43 24 54 12  9 18 57  4 38 91 42 27 45   \n    50 38 56 29 10  0 26 37 83  1 78 15 47 30 75 62 46 29 68  5 30  4   \n    27 96 33 95 79 75 56 10 29 70 32 75 52 88  5 36 50 57 46 63 88 65   \n  x\n    44 95 64 20 24 35 69 61 61  2 35 92 42 46 23 98 78  1 38 72 79 35   \n    94 37 13 59  5 93 27 58 80 75 58  7 67 13 10 76 84  4  8 70 81 45   \n     8 41 98  5 60 26 92 29 91 90  2 62 40  4  5 22 80 15 83 76 52 88   \n    29  5 68 73 72  7 54 17 89 32 81 94 51 28 53 71  8 42 54 59 70 79   \n  x\n  } {\n    incr tn\n    set now [db one {SELECT count(i) FROM t1}]\n    if {$x == \"x\"} {\n      execsql { COMMIT ; BEGIN }\n      set lowpoint $now\n      do_test pager2.1.$otn.$tn { \n        sqlite3 db2 test.db\n        execsql {\n          SELECT COALESCE(max(i), 0) FROM t1;\n          PRAGMA integrity_check;\n        } \n      } [list $lowpoint ok]\n      db2 close\n    } else {\n      if {$now > $x } {\n        if { $x>=$lowpoint } {\n          execsql \"ROLLBACK TO sp_$x\"\n        } else {\n          execsql \"DELETE FROM t1 WHERE i>$x\"\n          set lowpoint $x\n        }\n      } elseif {$now < $x} {\n        for {set k $now} {$k < $x} {incr k} {\n          execsql \"SAVEPOINT sp_$k\"\n          execsql { INSERT INTO t1(j) VALUES(randomblob(1500)) }\n        }\n      }\n      do_execsql_test pager2.1.$otn.$tn { \n        SELECT COALESCE(max(i), 0) FROM t1;\n        PRAGMA integrity_check;\n      } [list $x ok]\n    }\n  }\n}\ndb close\ntv delete\n\n\n#-------------------------------------------------------------------------\n# pager2-2.1: Test a ROLLBACK with journal_mode=off.\n# pager2-2.2: Test shrinking the database (auto-vacuum) with \n#             journal_mode=off\n#\ndo_test pager2-2.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(a, b);\n    PRAGMA journal_mode = off;\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {off}\ndo_test pager2-2.2 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = incremental;\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = off;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));\n    DELETE FROM t1;\n    PRAGMA incremental_vacuum;\n  }\n  file size test.db\n} {3072}\n\n#-------------------------------------------------------------------------\n# Test that shared in-memory databases seem to work.\n#\ndb close\ndo_test pager2-3.1 {\n  forcedelete test.db\n  sqlite3_shutdown\n  sqlite3_config_uri 1\n\n  sqlite3 db1 {file:test.db?mode=memory&cache=shared}\n  sqlite3 db2 {file:test.db?mode=memory&cache=shared}\n  sqlite3 db3 test.db\n\n  db1 eval { CREATE TABLE t1(a, b) }\n  db2 eval { INSERT INTO t1 VALUES(1, 2) }\n  list [catch { db3 eval { INSERT INTO t1 VALUES(3, 4) } } msg] $msg\n} {1 {no such table: t1}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pager3.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/wal_common.tcl\n\n\nforeach {tn sql res j} {\n  1 \"PRAGMA journal_mode = DELETE\"  delete        0\n  2 \"CREATE TABLE t1(a, b)\"         {}            0\n  3 \"PRAGMA locking_mode=EXCLUSIVE\" {exclusive}   0\n  4 \"INSERT INTO t1 VALUES(1, 2)\"   {}            1\n  5 \"PRAGMA locking_mode=NORMAL\"    {normal}      1\n  6 \"SELECT * FROM t1\"              {1 2}         0\n} {\n  do_execsql_test pager3-1.$tn.1 $sql $res\n  do_test         pager3-1.$tn.2 { file exists test.db-journal } $j\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pager4.test",
    "content": "# 2013-12-06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the SQLITE_READONLY_DBMOVED error condition: the database file\n# is unlinked or renamed out from under SQLite.\n#\n\nif {$tcl_platform(platform)!=\"unix\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\n# Create a database file for testing\n#\ndo_execsql_test pager4-1.1 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES(673,'stone','philips');\n  SELECT * FROM t1;\n} {673 stone philips}\n\n# After renaming the database file while it is open, one can still\n# read from the database, but writing returns a READONLY error.\n#\nfile delete -force test-xyz.db\nfile rename test.db test-xyz.db\ndo_catchsql_test pager4-1.2 {\n  SELECT * FROM t1;\n} {0 {673 stone philips}}\ndo_catchsql_test pager4-1.3 {\n  UPDATE t1 SET a=537;\n} {1 {attempt to write a readonly database}}\n\n# Creating a different database file with the same name of the original\n# is detected and still leaves the database read-only.\n#\nsqlite3 db2 test.db\ndb2 eval {CREATE TABLE t2(x,y,z)}\ndo_catchsql_test pager4-1.4 {\n  UPDATE t1 SET a=948;\n} {1 {attempt to write a readonly database}}\n\n# Changing the name back clears the READONLY error\n#\ndb2 close\nfile delete -force test.db\nfile rename test-xyz.db test.db\ndo_catchsql_test pager4-1.5 {\n  SELECT * FROM t1;\n} {0 {673 stone philips}}\ndo_catchsql_test pager4-1.6 {\n  UPDATE t1 SET a=537;\n  SELECT * FROM t1;\n} {0 {537 stone philips}}\n\n# We can write to a renamed database if journal_mode=OFF or\n# journal_mode=MEMORY.\n#\nfile rename test.db test-xyz.db\ndo_catchsql_test pager4-1.7 {\n  PRAGMA journal_mode=OFF;\n  UPDATE t1 SET a=107;\n  SELECT * FROM t1;\n} {0 {off 107 stone philips}}\ndo_catchsql_test pager4-1.8 {\n  PRAGMA journal_mode=MEMORY;\n  UPDATE t1 SET b='magpie';\n  SELECT * FROM t1;\n} {0 {memory 107 magpie philips}}\n\n# Any other journal mode gives a READONLY error\n#\ndo_catchsql_test pager4-1.9 {\n  PRAGMA journal_mode=DELETE;\n  UPDATE t1 SET c='jaguar';\n} {1 {attempt to write a readonly database}}\ndo_catchsql_test pager4-1.10 {\n  PRAGMA journal_mode=TRUNCATE;\n  UPDATE t1 SET c='jaguar';\n} {1 {attempt to write a readonly database}}\ndo_catchsql_test pager4-1.11 {\n  PRAGMA journal_mode=PERSIST;\n  UPDATE t1 SET c='jaguar';\n} {1 {attempt to write a readonly database}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pagerfault.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {[permutation] == \"inmemory_journal\"} {\n  finish_test\n  return\n}\n\nif {$::tcl_platform(platform)==\"windows\"} {\n  finish_test\n  return\n}\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\n#-------------------------------------------------------------------------\n# Test fault-injection while rolling back a hot-journal file.\n#\ndo_test pagerfault-1-pre1 {\n  execsql {\n    PRAGMA journal_mode = DELETE;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    BEGIN;\n      INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;\n      INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;\n      INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;\n      INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT count(*) FROM t1 }\n} -test {\n  faultsim_test_result {0 4} \n  faultsim_integrity_check\n  if {[db one { SELECT count(*) FROM t1 }] != 4} {\n    error \"Database content appears incorrect\"\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection while rolling back a hot-journal file with a \n# page-size different from the current value stored on page 1 of the\n# database file.\n#\ndo_test pagerfault-2-pre1 {\n  testvfs tv -default 1\n  tv filter xSync\n  tv script xSyncCb\n  proc xSyncCb {filename args} {\n    if {[string match *journal filename]==0} faultsim_save\n  }\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 4096;\n    BEGIN;\n      CREATE TABLE abc(a, b, c);\n      INSERT INTO abc VALUES('o', 't', 't'); \n      INSERT INTO abc VALUES('f', 'f', 's'); \n      INSERT INTO abc SELECT * FROM abc; -- 4\n      INSERT INTO abc SELECT * FROM abc; -- 8\n      INSERT INTO abc SELECT * FROM abc; -- 16\n      INSERT INTO abc SELECT * FROM abc; -- 32\n      INSERT INTO abc SELECT * FROM abc; -- 64\n      INSERT INTO abc SELECT * FROM abc; -- 128\n      INSERT INTO abc SELECT * FROM abc; -- 256\n    COMMIT;\n    PRAGMA page_size = 1024;\n    VACUUM;\n  }\n  db close\n  tv delete\n} {}\ndo_faultsim_test pagerfault-2 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT * FROM abc }\n} -test {\n  set answer [split [string repeat \"ottffs\" 128] \"\"]\n  faultsim_test_result [list 0 $answer]\n  faultsim_integrity_check\n  set res [db eval { SELECT * FROM abc }]\n  if {$res != $answer} { error \"Database content appears incorrect ($res)\" }\n} \n\n#-------------------------------------------------------------------------\n# Test fault-injection while rolling back hot-journals that were created\n# as part of a multi-file transaction.\n#\ndo_test pagerfault-3-pre1 {\n  testvfs tstvfs -default 1\n  tstvfs filter xDelete\n  tstvfs script xDeleteCallback\n\n  proc xDeleteCallback {method file args} {\n    set file [file tail $file]\n    if { [string match *mj* $file] } { faultsim_save }\n  }\n\n  faultsim_delete_and_reopen\n  db func a_string a_string\n\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    PRAGMA journal_mode = DELETE;\n    PRAGMA main.cache_size = 10;\n    PRAGMA aux.cache_size = 10;\n\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    CREATE TABLE aux.t2(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t2 SELECT * FROM t1;\n\n    BEGIN;\n      INSERT INTO t1 SELECT a_string(201), a_string(301) FROM t1;\n      INSERT INTO t1 SELECT a_string(202), a_string(302) FROM t1;\n      INSERT INTO t1 SELECT a_string(203), a_string(303) FROM t1;\n      INSERT INTO t1 SELECT a_string(204), a_string(304) FROM t1;\n      REPLACE INTO t2 SELECT * FROM t1;\n    COMMIT;\n  }\n\n  db close\n  tstvfs delete\n} {}\ndo_faultsim_test pagerfault-3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    ATTACH 'test.db2' AS aux;\n    SELECT count(*) FROM t2;\n    SELECT count(*) FROM t1;\n  }\n} -test {\n  faultsim_test_result {0 {4 4}} {1 {unable to open database: test.db2}}\n  faultsim_integrity_check\n  catchsql { ATTACH 'test.db2' AS aux }\n  if {[db one { SELECT count(*) FROM t1 }] != 4\n   || [db one { SELECT count(*) FROM t2 }] != 4\n  } {\n    error \"Database content appears incorrect\"\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection as part of a vanilla, no-transaction, INSERT\n# statement.\n#\ndo_faultsim_test pagerfault-4 -prep {\n  faultsim_delete_and_reopen\n} -body {\n  execsql { \n    CREATE TABLE x(y);\n    INSERT INTO x VALUES('z');\n    SELECT * FROM x;\n  }\n} -test {\n  faultsim_test_result {0 z}\n  faultsim_integrity_check\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection as part of a commit when using journal_mode=PERSIST.\n# Three different cases:\n#\n#    pagerfault-5.1: With no journal_size_limit configured.\n#    pagerfault-5.2: With a journal_size_limit configured.\n#    pagerfault-5.4: Multi-file transaction. One connection has a \n#                    journal_size_limit of 0, the other has no limit.\n#\ndo_test pagerfault-5-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n    INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-5.1 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql { PRAGMA journal_mode = PERSIST }\n} -body {\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-5.2 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql { \n    PRAGMA journal_mode = PERSIST;\n    PRAGMA journal_size_limit = 2048;\n  }\n} -body {\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-5.3 -faults oom-transient -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  forcedelete test2.db test2.db-journal test2.db-wal\n  execsql { \n    PRAGMA journal_mode = PERSIST;\n    ATTACH 'test2.db' AS aux;\n    PRAGMA aux.journal_mode = PERSIST;\n    PRAGMA aux.journal_size_limit = 0;\n  }\n} -body {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1;\n      CREATE TABLE aux.t2 AS SELECT * FROM t1;\n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n\n  catchsql { COMMIT }\n  catchsql { ROLLBACK }\n\n  faultsim_integrity_check\n  set res \"\"\n  set rc [catch { set res [db one { PRAGMA aux.integrity_check }] }]\n  if {$rc!=0 || $res != \"ok\"} {error \"integrity-check problem:$rc $res\"}\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection as part of a commit when using \n# journal_mode=TRUNCATE.\n#\ndo_test pagerfault-6-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(200), a_string(300));\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test pagerfault-6.1 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql { PRAGMA journal_mode = TRUNCATE }\n} -body {\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\n# The unix vfs xAccess() method considers a file zero bytes in size to\n# \"not exist\". This proc overrides that behaviour so that a zero length\n# file is considered to exist.\n#\nproc xAccess {method filename op args} {\n  if {$op != \"SQLITE_ACCESS_EXISTS\"} { return \"\" }\n  return [file exists $filename]\n}\ndo_faultsim_test pagerfault-6.2 -faults cantopen-* -prep {\n  shmfault filter xAccess\n  shmfault script xAccess\n\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql { PRAGMA journal_mode = TRUNCATE }\n} -body {\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n  execsql { INSERT INTO t1 SELECT a_string(200), a_string(300) FROM t1 }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\n# The following was an attempt to get a bitvec malloc to fail. Didn't work.\n#\n# do_test pagerfault-6-pre1 {\n#   faultsim_delete_and_reopen\n#   execsql {\n#     CREATE TABLE t1(x, y, UNIQUE(x, y));\n#     INSERT INTO t1 VALUES(1, randomblob(1501));\n#     INSERT INTO t1 VALUES(2, randomblob(1502));\n#     INSERT INTO t1 VALUES(3, randomblob(1503));\n#     INSERT INTO t1 VALUES(4, randomblob(1504));\n#     INSERT INTO t1 \n#       SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;\n#     INSERT INTO t1 \n#       SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;\n#     INSERT INTO t1 \n#       SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;\n#     INSERT INTO t1 \n#       SELECT x, randomblob(1500+oid+(SELECT max(oid) FROM t1)) FROM t1;\n#   }\n#   faultsim_save_and_close\n# } {}\n# do_faultsim_test pagerfault-6 -prep {\n#   faultsim_restore_and_reopen\n# } -body {\n#   execsql { \n#     BEGIN;\n#       UPDATE t1 SET x=x+4 WHERE x=1;\n#       SAVEPOINT one;\n#         UPDATE t1 SET x=x+4 WHERE x=2;\n#         SAVEPOINT three;\n#           UPDATE t1 SET x=x+4 WHERE x=3;\n#           SAVEPOINT four;\n#             UPDATE t1 SET x=x+4 WHERE x=4;\n#         RELEASE three;\n#     COMMIT;\n#     SELECT DISTINCT x FROM t1;\n#   }\n# } -test {\n#   faultsim_test_result {0 {5 6 7 8}}\n#   faultsim_integrity_check\n# }\n#\n\n# This is designed to provoke a special case in the pager code:\n#\n# If an error (specifically, a FULL or IOERR error) occurs while writing a\n# dirty page to the file-system in order to free up memory, the pager enters\n# the \"error state\". An IO error causes SQLite to roll back the current\n# transaction (exiting the error state). A FULL error, however, may only\n# rollback the current statement.\n#\n# This block tests that nothing goes wrong if a FULL error occurs while\n# writing a dirty page out to free memory from within a statement that has\n# opened a statement transaction.\n#\ndo_test pagerfault-7-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    BEGIN;\n      INSERT INTO t2 VALUES(NULL, randomblob(1500));\n      INSERT INTO t2 VALUES(NULL, randomblob(1500));\n      INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2;    --  4\n      INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2;    --  8\n      INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2;    -- 16\n      INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2;    -- 32\n      INSERT INTO t2 SELECT NULL, randomblob(1500) FROM t2;    -- 64\n    COMMIT;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 SELECT * FROM t2;\n    DROP TABLE t2;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-7 -prep {\n  faultsim_restore_and_reopen\n  execsql { \n    PRAGMA cache_size = 10;\n    BEGIN;\n      UPDATE t1 SET b = randomblob(1500);\n  }\n} -body {\n  execsql { UPDATE t1 SET a = 65, b = randomblob(1500) WHERE (a+1)>200 }\n  execsql COMMIT\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\ndo_test pagerfault-8-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    BEGIN;\n      INSERT INTO t1 VALUES(NULL, randomblob(1500));\n      INSERT INTO t1 VALUES(NULL, randomblob(1500));\n      INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1;    --  4\n      INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1;    --  8\n      INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1;    -- 16\n      INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1;    -- 32\n      INSERT INTO t1 SELECT NULL, randomblob(1500) FROM t1;    -- 64\n    COMMIT;\n  }\n  faultsim_save_and_close\n  set filesize [file size test.db]\n  set {} {}\n} {}\ndo_test pagerfault-8-pre2 {\n  faultsim_restore_and_reopen\n  execsql { DELETE FROM t1 WHERE a>32 }\n  expr {[file size test.db] < $filesize}\n} {1}\ndo_faultsim_test pagerfault-8 -prep {\n  faultsim_restore_and_reopen\n  execsql { \n    BEGIN;\n    DELETE FROM t1 WHERE a>32;\n  }\n} -body {\n  execsql COMMIT\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\n#-------------------------------------------------------------------------\n# This test case is specially designed so that during a savepoint \n# rollback, a new cache entry must be allocated (see comments surrounding\n# the call to sqlite3PagerAcquire() from within pager_playback_one_page()\n# for details). Test the effects of injecting an OOM at this point.\n#\ndo_test pagerfault-9-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = incremental;\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(y);\n    CREATE TABLE t3(z);\n\n    INSERT INTO t1 VALUES(randomblob(900));\n    INSERT INTO t1 VALUES(randomblob(900));\n    DELETE FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-9.1 -prep {\n  faultsim_restore_and_reopen\n  execsql { \n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(900));\n      INSERT INTO t1 VALUES(randomblob(900));\n      DROP TABLE t3;\n      DROP TABLE t2;\n      SAVEPOINT abc;\n        PRAGMA incremental_vacuum;\n  }\n} -body {\n  execsql {\n    ROLLBACK TO abc;\n    COMMIT;\n    PRAGMA freelist_count\n  }\n} -test {\n  faultsim_test_result {0 2}\n  faultsim_integrity_check\n\n  set sl [db one { SELECT COALESCE(sum(length(x)), 'null') FROM t1 }]\n  if {$sl!=\"null\" && $sl!=1800} { \n    error \"Content looks no good... ($sl)\" \n  }\n}\n\n#-------------------------------------------------------------------------\n# Test fault injection with a temporary database file.\n#\nforeach v {a b} {\n  do_faultsim_test pagerfault-10$v -prep {\n    sqlite3 db \"\"\n    db func a_string a_string;\n    execsql {\n      PRAGMA cache_size = 10;\n      BEGIN;\n        CREATE TABLE xx(a, b, UNIQUE(a, b));\n        INSERT INTO xx VALUES(a_string(200), a_string(200));\n        INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;\n        INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;\n        INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;\n        INSERT INTO xx SELECT a_string(200), a_string(200) FROM xx;\n      COMMIT;\n    }\n  } -body {\n    execsql { UPDATE xx SET a = a_string(300) }\n  } -test {\n    faultsim_test_result {0 {}}\n    if {$::v == \"b\"} { execsql { PRAGMA journal_mode = TRUNCATE } }\n    faultsim_integrity_check\n    faultsim_integrity_check\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test fault injection with transaction savepoints (savepoints created\n# when a SAVEPOINT command is executed outside of any other savepoint\n# or transaction context).\n#\ndo_test pagerfault-9-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string;\n  execsql {\n    PRAGMA auto_vacuum = on;\n    CREATE TABLE t1(x UNIQUE);\n    CREATE TABLE t2(y UNIQUE);\n    CREATE TABLE t3(z UNIQUE);\n    BEGIN;\n      INSERT INTO t1 VALUES(a_string(202));\n      INSERT INTO t2 VALUES(a_string(203));\n      INSERT INTO t3 VALUES(a_string(204));\n      INSERT INTO t1 SELECT a_string(202) FROM t1;\n      INSERT INTO t1 SELECT a_string(203) FROM t1;\n      INSERT INTO t1 SELECT a_string(204) FROM t1;\n      INSERT INTO t1 SELECT a_string(205) FROM t1;\n      INSERT INTO t2 SELECT a_string(length(x)) FROM t1;\n      INSERT INTO t3 SELECT a_string(length(x)) FROM t1;\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-11 -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA cache_size = 10 }\n} -body {\n  execsql {\n    SAVEPOINT trans;\n      UPDATE t2 SET y = y||'2';\n      INSERT INTO t3 SELECT * FROM t2;\n      DELETE FROM t1;\n    ROLLBACK TO trans;\n    UPDATE t1 SET x = x||'3';\n    INSERT INTO t2 SELECT * FROM t1;\n    DELETE FROM t3;\n    RELEASE trans;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\n\n#-------------------------------------------------------------------------\n# Test fault injection when writing to a database file that resides on\n# a file-system with a sector-size larger than the database page-size.\n#\ndo_test pagerfault-12-pre1 {\n  testvfs ss_layer -default 1\n  ss_layer sectorsize 4096\n  faultsim_delete_and_reopen\n  db func a_string a_string;\n\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = PERSIST;\n    PRAGMA cache_size = 10;\n    BEGIN;\n      CREATE TABLE t1(x, y UNIQUE);\n      INSERT INTO t1 VALUES(a_string(333), a_string(444));\n      INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;\n      INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;\n      INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;\n      INSERT INTO t1 SELECT a_string(333+rowid), a_string(444+rowid) FROM t1;\n      INSERT INTO t1 SELECT a_string(44), a_string(55) FROM t1 LIMIT 13;\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test pagerfault-12a -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA cache_size = 10 }\n  db func a_string a_string;\n} -body {\n  execsql {\n    UPDATE t1 SET x = a_string(length(x)), y = a_string(length(y));\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\ndo_test pagerfault-12-pre2 {\n  faultsim_restore_and_reopen\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1 LIMIT 10;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-12b -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string;\n  execsql { SELECT * FROM t1 }\n} -body {\n  set sql(1) { UPDATE t2 SET x = a_string(280) }\n  set sql(2) { UPDATE t1 SET x = a_string(280) WHERE rowid = 5 }\n\n  db eval { SELECT rowid FROM t1 LIMIT 2 } { db eval $sql($rowid) }\n\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\ncatch { db close }\nss_layer delete\n\n\n#-------------------------------------------------------------------------\n# Test fault injection when SQLite opens a database where the size of the\n# database file is zero bytes but the accompanying journal file is larger\n# than that. In this scenario SQLite should delete the journal file \n# without rolling it back, even if it is in all other respects a valid\n# hot-journal file.\n#\ndo_test pagerfault-13-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string;\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    BEGIN;\n      CREATE TABLE t1(x, y UNIQUE);\n      INSERT INTO t1 VALUES(a_string(333), a_string(444));\n    COMMIT;\n  }\n  db close\n  forcedelete test.db\n  faultsim_save\n} {}\ndo_faultsim_test pagerfault-13 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE TABLE xx(a, b) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#---------------------------------------------------------------------------\n# Test fault injection into a small backup operation.\n#\ndo_test pagerfault-14-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string;\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    ATTACH 'test.db2' AS two;\n    BEGIN;\n      CREATE TABLE t1(x, y UNIQUE);\n      CREATE TABLE two.t2(x, y UNIQUE);\n      INSERT INTO t1 VALUES(a_string(333), a_string(444));\n      INSERT INTO t2 VALUES(a_string(333), a_string(444));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test pagerfault-14a -prep {\n  faultsim_restore_and_reopen\n} -body {\n  if {[catch {db backup test.db2} msg]} { error [regsub {.*: } $msg {}] }\n} -test {\n  faultsim_test_result {0 {}} {1 {}} {1 {SQL logic error}}\n}\n\n# If TEMP_STORE is 2 or greater, then the database [db2] will be created\n# as an in-memory database. This test will not work in that case, as it\n# is not possible to change the page-size of an in-memory database. Even\n# using the backup API.\n#\n# Update: It is no longer possible to change the page size of any temp\n# database after it has been created.\n#\ndo_faultsim_test pagerfault-14b -prep {\n  catch { db2 close }\n  faultsim_restore_and_reopen\n    sqlite3 db2 \"\"\n    db2 eval { PRAGMA page_size = 4096; CREATE TABLE xx(a) }\n} -body {\n  sqlite3_backup B db2 main db main\n  B step 200\n  set rc [B finish]\n  if {[string match SQLITE_IOERR_* $rc]} {set rc SQLITE_IOERR}\n  if {$rc != \"SQLITE_OK\"} { error [sqlite3_test_errstr $rc] }\n  set {} {}\n} -test {\n  faultsim_test_result {1 {attempt to write a readonly database}} \\\n                       {1 {sqlite3_backup_init() failed}}\n}\n\ndo_faultsim_test pagerfault-14c -prep {\n  catch { db2 close }\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db2\n  db2 eval { \n    PRAGMA synchronous = off; \n    PRAGMA page_size = 4096; \n    CREATE TABLE xx(a);\n  }\n} -body {\n  sqlite3_backup B db2 main db main\n  B step 200\n  set rc [B finish]\n  if {[string match SQLITE_IOERR_* $rc]} {set rc SQLITE_IOERR}\n  if {$rc != \"SQLITE_OK\"} { error [sqlite3_test_errstr $rc] }\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}} {1 {sqlite3_backup_init() failed}}\n}\n\ndo_test pagerfault-15-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string;\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(x, y UNIQUE);\n      INSERT INTO t1 VALUES(a_string(11), a_string(22));\n      INSERT INTO t1 VALUES(a_string(11), a_string(22));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-15 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string;\n} -body {\n  db eval { SELECT * FROM t1 LIMIT 1 } {\n    execsql {\n      BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;\n      BEGIN; INSERT INTO t1 VALUES(a_string(333), a_string(555)); COMMIT;\n    }\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\n\ndo_test pagerfault-16-pre1 {\n  faultsim_delete_and_reopen\n  execsql { CREATE TABLE t1(x, y UNIQUE) }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-16 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql {\n    PRAGMA locking_mode = exclusive;\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    PRAGMA journal_mode = delete;\n    INSERT INTO t1 VALUES(4, 5);\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(6, 7);\n    PRAGMA journal_mode = persist;\n    INSERT INTO t1 VALUES(8, 9);\n  }\n} -test {\n  faultsim_test_result {0 {exclusive wal delete wal persist}}\n  faultsim_integrity_check\n}\n\n\n#-------------------------------------------------------------------------\n# Test fault injection while changing into and out of WAL mode.\n#\ndo_test pagerfault-17-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1862, 'Botha');\n    INSERT INTO t1 VALUES(1870, 'Smuts');\n    INSERT INTO t1 VALUES(1866, 'Hertzog');\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-17a -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql {\n    PRAGMA journal_mode = wal;\n    PRAGMA journal_mode = delete;\n  }\n} -test {\n  faultsim_test_result {0 {wal delete}}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-17b -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA synchronous = OFF }\n} -body {\n  execsql {\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(22, 'Clarke');\n    PRAGMA journal_mode = delete;\n  }\n} -test {\n  faultsim_test_result {0 {wal delete}}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-17c -prep {\n  faultsim_restore_and_reopen\n  execsql { \n    PRAGMA locking_mode = exclusive;\n    PRAGMA journal_mode = wal;\n  }\n} -body {\n  execsql { PRAGMA journal_mode = delete }\n} -test {\n  faultsim_test_result {0 delete}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-17d -prep {\n  catch { db2 close }\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db\n  execsql { PRAGMA journal_mode = delete }\n  execsql { PRAGMA journal_mode = wal }\n  execsql { INSERT INTO t1 VALUES(99, 'Bradman') } db2\n} -body {\n  execsql { PRAGMA journal_mode = delete }\n} -test {\n  faultsim_test_result {1 {database is locked}}\n  faultsim_integrity_check\n}\ndo_faultsim_test pagerfault-17e -prep {\n  catch { db2 close }\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db\n  execsql { PRAGMA journal_mode = delete }\n  execsql { PRAGMA journal_mode = wal }\n  set ::chan [launch_testfixture]\n  testfixture $::chan {\n    sqlite3 db test.db\n    db eval { INSERT INTO t1 VALUES(101, 'Latham') }\n  }\n  catch { testfixture $::chan sqlite_abort }\n  catch { close $::chan }\n} -body {\n  execsql { PRAGMA journal_mode = delete }\n} -test {\n  faultsim_test_result {0 delete}\n  faultsim_integrity_check\n}\n\n#-------------------------------------------------------------------------\n# Test fault-injection when changing from journal_mode=persist to \n# journal_mode=delete (this involves deleting the journal file).\n#\ndo_test pagerfault-18-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE qq(x);\n    INSERT INTO qq VALUES('Herbert');\n    INSERT INTO qq VALUES('Macalister');\n    INSERT INTO qq VALUES('Mackenzie');\n    INSERT INTO qq VALUES('Lilley');\n    INSERT INTO qq VALUES('Palmer');\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-18 -prep {\n  faultsim_restore_and_reopen\n  execsql {\n    PRAGMA journal_mode = PERSIST;\n    INSERT INTO qq VALUES('Beatty');\n  }\n} -body {\n  execsql { PRAGMA journal_mode = delete }\n} -test {\n  faultsim_test_result {0 delete}\n  faultsim_integrity_check\n}\n\ndo_faultsim_test pagerfault-19a -prep {\n  sqlite3 db :memory:\n  db func a_string a_string\n  execsql {\n    PRAGMA auto_vacuum = FULL;\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(a_string(5000), a_string(6000));\n    COMMIT;\n  }\n} -body {\n  execsql { \n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 SELECT * FROM t1; \n    DELETE FROM t1;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test pagerfault-19-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = FULL;\n    CREATE TABLE t1(x); INSERT INTO t1 VALUES(1);\n    CREATE TABLE t2(x); INSERT INTO t2 VALUES(2);\n    CREATE TABLE t3(x); INSERT INTO t3 VALUES(3);\n    CREATE TABLE t4(x); INSERT INTO t4 VALUES(4);\n    CREATE TABLE t5(x); INSERT INTO t5 VALUES(5);\n    CREATE TABLE t6(x); INSERT INTO t6 VALUES(6);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-19b -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    BEGIN;\n      UPDATE t4 SET x = x+1;\n      UPDATE t6 SET x = x+1;\n      SAVEPOINT one;\n        UPDATE t3 SET x = x+1;\n        SAVEPOINT two;\n          DROP TABLE t2;\n      ROLLBACK TO one;\n    COMMIT;\n    SELECT * FROM t3;\n    SELECT * FROM t4;\n    SELECT * FROM t6;\n  }\n} -test {\n  faultsim_test_result {0 {3 5 7}}\n}\n\n#-------------------------------------------------------------------------\n# This tests fault-injection in a special case in the auto-vacuum code.\n#\ndo_test pagerfault-20-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA auto_vacuum = FULL;\n    CREATE TABLE t0(a, b);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-20 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    BEGIN;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n      DROP TABLE t1;\n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test pagerfault-21-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA cache_size = 10;\n    CREATE TABLE t0(a PRIMARY KEY, b);\n    INSERT INTO t0 VALUES(1, 2);\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-21 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { SELECT * FROM t0 LIMIT 1 } {\n    db eval { INSERT INTO t0 SELECT a+1, b FROM t0 }\n    db eval { INSERT INTO t0 SELECT a+2, b FROM t0 }\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n\n#-------------------------------------------------------------------------\n# Test fault-injection and rollback when the nReserve header value \n# is non-zero.\n#\ndo_test pagerfault-21-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    PRAGMA journal_mode = DELETE;\n  }\n  db close\n  hexio_write test.db 20    10\n  hexio_write test.db 105 03F0\n  sqlite3 db test.db\n  db func a_string a_string\n  execsql {\n    CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t0 VALUES(a_string(222), a_string(333));\n    INSERT INTO t0 VALUES(a_string(223), a_string(334));\n    INSERT INTO t0 VALUES(a_string(224), a_string(335));\n    INSERT INTO t0 VALUES(a_string(225), a_string(336));\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test pagerfault-21 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO t0 SELECT a||'x', b||'x' FROM t0 }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\nifcapable crashtest {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    PRAGMA journal_mode = DELETE;\n  }\n  db close\n  hexio_write test.db 20    10\n  hexio_write test.db 105 03F0\n\n  sqlite3 db test.db\n  db func a_string a_string\n  execsql {\n    CREATE TABLE t0(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t0 VALUES(a_string(222), a_string(333));\n    INSERT INTO t0 VALUES(a_string(223), a_string(334));\n  }\n  faultsim_save_and_close\n\n  for {set iTest 1} {$iTest<50} {incr iTest} {\n    do_test pagerfault-21.crash.$iTest.1 {\n      crashsql -delay 1 -file test.db -seed $iTest {\n        BEGIN;\n          CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n          INSERT INTO t1 SELECT a, b FROM t0;\n        COMMIT;\n      }\n    } {1 {child process exited abnormally}}\n    do_test pagerfault-22.$iTest.2 {\n      sqlite3 db test.db\n      execsql { PRAGMA integrity_check }\n    } {ok}\n    db close\n  }\n}\n\n\n#-------------------------------------------------------------------------\n# When a 3.7.0 client opens a write-transaction on a database file that\n# has been appended to or truncated by a pre-370 client, it updates\n# the db-size in the file header immediately. This test case provokes\n# errors during that operation.\n#\ndo_test pagerfault-22-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(a);\n    CREATE INDEX i1 ON t1(a);\n    INSERT INTO t1 VALUES(a_string(3000));\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n  }\n  db close\n  sql36231 { INSERT INTO t1 VALUES(a_string(3000)) }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-22 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { INSERT INTO t2 VALUES(2) }\n  execsql { SELECT * FROM t2 }\n} -test {\n  faultsim_test_result {0 {1 2}}\n  faultsim_integrity_check\n}\n\n#-------------------------------------------------------------------------\n# Provoke an OOM error during a commit of multi-file transaction. One of\n# the databases written during the transaction is an in-memory database.\n# This test causes rollback of the in-memory database after CommitPhaseOne()\n# has successfully returned. i.e. the series of calls for the aborted commit \n# is:\n#\n#   PagerCommitPhaseOne(<in-memory-db>)   ->   SQLITE_OK\n#   PagerCommitPhaseOne(<file-db>)        ->   SQLITE_IOERR\n#   PagerRollback(<in-memory-db>)\n#   PagerRollback(<file-db>)\n#\ndo_faultsim_test pagerfault-23 -prep {\n  sqlite3 db :memory:\n  foreach f [glob -nocomplain test.db*] { forcedelete $f }\n  db eval { \n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE aux.t2(a, b);\n  }\n} -body {\n  execsql { \n    BEGIN;\n      INSERT INTO t1 VALUES(1,2);\n      INSERT INTO t2 VALUES(3,4); \n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check\n}\n\ndo_faultsim_test pagerfault-24 -prep {\n  faultsim_delete_and_reopen\n  db eval { PRAGMA temp_store = file }\n  execsql { CREATE TABLE x(a, b) }\n} -body {\n  execsql { CREATE TEMP TABLE t1(a, b) }\n} -test {\n  faultsim_test_result {0 {}} \\\n    {1 {unable to open a temporary database file for storing temporary tables}}\n  set ic [db eval { PRAGMA temp.integrity_check }]\n  if {$ic != \"ok\"} { error \"Integrity check: $ic\" }\n}\n\nproc lockrows {n} {\n  if {$n==0} { return \"\" }\n  db eval { SELECT * FROM t1 WHERE oid = $n } { \n    return [lockrows [expr {$n-1}]]\n  }\n}\n\n\ndo_test pagerfault-25-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(a_string(500));\n    INSERT INTO t1 SELECT a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(500) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-25 -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  set ::channel [db incrblob -readonly t1 a 1]\n  execsql { \n    PRAGMA cache_size = 10;\n    BEGIN;\n      INSERT INTO t1 VALUES(a_string(3000));\n      INSERT INTO t1 VALUES(a_string(3000));\n  }\n} -body {\n  lockrows 30\n} -test {\n  catch { lockrows 30 }\n  catch { db eval COMMIT }\n  close $::channel\n  faultsim_test_result {0 {}} \n}\n\ndo_faultsim_test pagerfault-26 -prep {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = truncate;\n    PRAGMA auto_vacuum = full;\n    PRAGMA locking_mode=exclusive;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    PRAGMA page_size = 4096;\n  }\n} -body {\n  execsql {\n    VACUUM;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n\n  set contents [db eval {SELECT * FROM t1}]\n  if {$contents != \"1 2\"} { error \"Bad database contents ($contents)\" }\n\n  set sz [file size test.db]\n  if {$testrc!=0 && $sz!=1024*3 && $sz!=4096*3} { \n    error \"Expected file size to be 3072 or 12288 bytes - actual size $sz bytes\"\n  }\n  if {$testrc==0 && $sz!=4096*3} { \n    error \"Expected file size to be 12288 bytes - actual size $sz bytes\"\n  }\n} \n\ndo_test pagerfault-27-pre {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a UNIQUE, b UNIQUE);\n    INSERT INTO t2 VALUES( a_string(800), a_string(800) );\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    INSERT INTO t1 VALUES (a_string(20000), a_string(20000));\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-27 -faults ioerr-persistent -prep {\n  faultsim_restore_and_reopen\n  db func a_string a_string\n  execsql { \n    PRAGMA cache_size = 10;\n    BEGIN EXCLUSIVE;\n  }\n  set ::channel [db incrblob t1 a 1]\n} -body {\n  puts $::channel [string repeat abc 6000]\n  flush $::channel\n} -test {\n  catchsql { UPDATE t2 SET a = a_string(800), b = a_string(800) }\n  catch { close $::channel }\n  catchsql { ROLLBACK }\n  faultsim_integrity_check\n}\n\n\n#-------------------------------------------------------------------------\n#\ndo_test pagerfault-28-pre {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 512;\n\n    PRAGMA journal_mode = wal;\n    PRAGMA wal_autocheckpoint = 0;\n    PRAGMA cache_size = 100000;\n\n    BEGIN;\n      CREATE TABLE t2(a UNIQUE, b UNIQUE);\n      INSERT INTO t2 VALUES( a_string(800), a_string(800) );\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    COMMIT;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n  }\n  expr {[file size test.db-shm] >= 96*1024}\n} {1}\nfaultsim_save_and_close\n\ndo_faultsim_test pagerfault-28a -faults oom* -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA mmap_size=0 }\n\n  sqlite3 db2 test.db\n  db2 eval { SELECT count(*) FROM t2 }\n\n  db func a_string a_string\n  execsql { \n    BEGIN;\n      INSERT INTO t1 VALUES(a_string(2000), a_string(2000));\n      INSERT INTO t1 VALUES(a_string(2000), a_string(2000));\n  }\n  set ::STMT [sqlite3_prepare db \"SELECT * FROM t1 ORDER BY a\" -1 DUMMY]\n  sqlite3_step $::STMT\n} -body {\n  execsql { ROLLBACK }\n} -test {\n  db2 close\n  sqlite3_finalize $::STMT\n  catchsql { ROLLBACK }\n  faultsim_integrity_check\n}\n\nfaultsim_restore_and_reopen\nsqlite3 db2 test.db\ndb2 eval {SELECT count(*) FROM t2}\ndb close\n\ndo_faultsim_test pagerfault-28b -faults oom* -prep {\n  sqlite3 db test.db\n} -body {\n  execsql { SELECT count(*) FROM t2 }\n} -test {\n  faultsim_test_result {0 2048}\n  db close\n}\n\ndb2 close\n\n#-------------------------------------------------------------------------\n# Try this:\n#\n#    1) Put the pager in ERROR state (error during rollback)\n#\n#    2) Next time the connection is used inject errors into all xWrite() and\n#       xUnlock() calls. This causes the hot-journal rollback to fail and\n#       the pager to declare its locking state UNKNOWN.\n#\n#    3) Same again.\n#\n#    4a) Stop injecting errors. Allow the rollback to succeed. Check that\n#        the database is Ok. Or, \n#\n#    4b) Close and reopen the db. Check that the db is Ok.\n#\nproc custom_injectinstall {} {\n  testvfs custom -default true\n  custom filter {xWrite xUnlock}\n}\nproc custom_injectuninstall {} {\n  catch {db  close}\n  catch {db2 close}\n  custom delete\n}\nproc custom_injectstart {iFail} {\n  custom ioerr $iFail 1\n}\nproc custom_injectstop {} {\n  custom ioerr\n}\nset ::FAULTSIM(custom)          [list      \\\n  -injectinstall   custom_injectinstall    \\\n  -injectstart     custom_injectstart      \\\n  -injectstop      custom_injectstop       \\\n  -injecterrlist   {{1 {disk I/O error}}}  \\\n  -injectuninstall custom_injectuninstall  \\\n]\n\ndo_test pagerfault-29-pre {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 5;\n\n    BEGIN;\n      CREATE TABLE t2(a UNIQUE, b UNIQUE);\n      INSERT INTO t2 VALUES( a_string(800), a_string(800) );\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n      INSERT INTO t2 SELECT a_string(800), a_string(800) FROM t2;\n    COMMIT;\n  }\n  expr {[file size test.db] >= 50*1024}\n} {1}\nfaultsim_save_and_close\nforeach {tn tt} {\n  29 { catchsql ROLLBACK }\n  30 { db close ; sqlite3 db test.db }\n} {\n  do_faultsim_test pagerfault-$tn -faults custom -prep {\n    faultsim_restore_and_reopen\n      db func a_string a_string\n      execsql {\n        PRAGMA cache_size = 5;\n        BEGIN;\n        UPDATE t2 SET a = a_string(799);\n      }\n  } -body {\n    catchsql ROLLBACK\n    catchsql ROLLBACK\n    catchsql ROLLBACK\n  } -test {\n    eval $::tt\n    if {\"ok\" != [db one {PRAGMA integrity_check}]} {\n      error \"integrity check failed\"\n    }\n  }\n}\n\ndo_test pagerfault-31-pre {\n  sqlite3_shutdown\n  sqlite3_config_uri 1\n} {SQLITE_OK}\ndo_faultsim_test pagerfault-31 -faults oom* -body {\n  sqlite3 db {file:one?mode=memory&cache=shared}\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1;\n  }\n} -test {\n  faultsim_test_result {0 1} {1 {}}\n  catch { db close }\n}\nsqlite3_shutdown\nsqlite3_config_uri 0\n\ndo_test pagerfault-32-pre {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES('one');\n  }\n} {}\nfaultsim_save_and_close\n\ndo_faultsim_test pagerfault-32 -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM t1; }\n} -body {\n  execsql { SELECT * FROM t1; }\n} -test {\n  faultsim_test_result {0 one}\n}\nsqlite3_shutdown\nsqlite3_config_uri 0\n\ndo_faultsim_test pagerfault-33a -prep {\n  sqlite3 db :memory:\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} -body {\n  execsql { VACUUM }\n} -test {\n  faultsim_test_result {0 {}}\n} \ndo_faultsim_test pagerfault-33b -prep {\n  sqlite3 db \"\"\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} -body {\n  execsql { VACUUM }\n} -test {\n  faultsim_test_result {0 {}}\n} \n\ndo_test pagerfault-34-pre {\n  reset_db\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY);\n  }\n} {}\nfaultsim_save_and_close\ndo_faultsim_test pagerfault-34 -prep {\n  faultsim_restore_and_reopen\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES( randomblob(4000) );\n      DELETE FROM t1;\n  }\n} -body {\n  execsql COMMIT\n} -test {\n  faultsim_test_result {0 {}}\n} \n\ndo_test pagerfault-35-pre {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ntestvfs tv -default 1\ntv sectorsize 8192;\ntv devchar [list]\ndo_faultsim_test pagerfault-35 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { UPDATE t1 SET x=randomblob(200) }\n} -test {\n  faultsim_test_result {0 {}}\n}\ncatch {db close}\ntv delete\n\nsqlite3_shutdown\nsqlite3_config_uri 1\ndo_test pagerfault-36-pre {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test pagerfault-36 -prep {\n  faultsim_restore\n  sqlite3 db file:test.db?cache=shared\n  sqlite3 db2 file:test.db?cache=shared\n  db2 eval {\n    BEGIN;\n    SELECT count(*) FROM sqlite_master;\n  }\n  db eval {\n    PRAGMA cache_size = 1;\n    BEGIN;\n      UPDATE t1 SET x = randomblob(200);\n  }\n} -body {\n  execsql ROLLBACK db\n} -test {\n  catch { db eval {UPDATE t1 SET x = randomblob(200)} }\n  faultsim_test_result {0 {}}\n  catch { db close }\n  catch { db2 close }\n}\n\nsqlite3_shutdown\nsqlite3_config_uri 0\nsqlite3_initialize\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pagerfault2.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file test the pager modules response to various\n# fault conditions (OOM, IO error, disk full etc.). They are similar\n# to those in file pagerfault1.test. \n#\n# More specifically, the tests in this file are those deemed too slow to \n# run as part of pagerfault1.test.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {[permutation] == \"inmemory_journal\"} {\n  finish_test\n  return\n}\n\nsqlite3_memdebug_vfs_oom_test 0\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\ndo_test pagerfault2-1-pre1 {\n  faultsim_delete_and_reopen\n  db func a_string a_string\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = DELETE;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(a_string(401), a_string(402));\n  }\n  for {set ii 0} {$ii < 13} {incr ii} {\n    execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }\n  }\n  faultsim_save_and_close\n  file size test.db\n} [expr 1024 * 8268]\n\ndo_faultsim_test pagerfault2-1 -faults oom-transient -prep {\n  faultsim_restore_and_reopen\n  sqlite3_db_config_lookaside db 0 256 4096\n  execsql { \n    BEGIN;\n      SELECT * FROM t1;\n      INSERT INTO t1 VALUES(5, 6);\n      SAVEPOINT abc;\n        UPDATE t1 SET a = a||'x' WHERE rowid<3700;\n  }\n} -body {\n  execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }\n  execsql { ROLLBACK TO abc }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\ndo_test pagerfault2-2-pre1 {\n  faultsim_restore_and_reopen\n  execsql { DELETE FROM t1 }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test pagerfault2-2 -faults oom-transient -prep {\n  faultsim_restore_and_reopen\n  sqlite3_db_config_lookaside db 0 256 4096\n  db func a_string a_string\n\n  execsql { \n    PRAGMA cache_size = 20;\n    BEGIN;\n      INSERT INTO t1 VALUES(a_string(401), a_string(402));\n      SAVEPOINT abc;\n  }\n} -body {\n  execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nsqlite3_memdebug_vfs_oom_test 1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pagerfault3.test",
    "content": "# 2011 January 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {[permutation] == \"inmemory_journal\"} {\n  finish_test\n  return\n}\n\n# Create a database with page-size 2048 bytes that uses 2 pages. Populate\n# it so that if the page-size is changed to 1024 bytes and the db vacuumed, \n# the new db size is 3 pages.\n#\ndo_test pagerfault3-pre1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 2048;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(1200));\n    PRAGMA page_count;\n  }\n} {2}\ndo_test pagerfault3-pre2 {\n  faultsim_save_and_close\n  faultsim_restore_and_reopen\n  execsql { \n    PRAGMA page_size = 1024;\n    VACUUM;\n    PRAGMA page_count;\n  }\n} {3}\n\n# Now do the page-size change and VACUUM with IO error injection. When\n# an IO error is injected into the final xSync() of the commit, the pager\n# will have to extend the db file from 3072 to 4096 byts when rolling\n# back the hot-journal file. This is a special case in pager_truncate().\n#\ndo_faultsim_test pagerfault3-1 -faults ioerr-transient -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { \n    PRAGMA page_size = 1024;\n    VACUUM;\n  }\n} -test {\n  faultsim_test_result {0 {}} \n  faultsim_integrity_check\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pageropt.test",
    "content": "# 2007 April 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# The focus of the tests in this file are to verify that the\n# pager optimizations implemented in version 3.3.14 work.\n#\n# $Id: pageropt.test,v 1.5 2008/08/20 14:49:25 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndo_not_use_codec\n\nifcapable {!pager_pragmas||secure_delete||direct_read} {\n  finish_test\n  return\n}\n\n# A non-zero reserved_bytes value changes the number of pages in the \n# database file, which messes up the results in this test.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\n# Run the SQL statement supplied by the argument and return\n# the results.  Prepend four integers to the beginning of the\n# result which are\n#\n#     (1)  The number of page reads from the database\n#     (2)  The number of page writes to the database\n#     (3)  The number of page writes to the journal\n#     (4)  The number of cache pages freed\n#\nproc pagercount_sql {sql {db db}} {\n  global sqlite3_pager_readdb_count\n  global sqlite3_pager_writedb_count\n  global sqlite3_pager_writej_count\n  global sqlite3_pager_pgfree_count\n  set sqlite3_pager_readdb_count 0\n  set sqlite3_pager_writedb_count 0\n  set sqlite3_pager_writej_count 0\n  set r [$db eval $sql]\n  set cnt [list $sqlite3_pager_readdb_count \\\n                $sqlite3_pager_writedb_count \\\n                $sqlite3_pager_writej_count ]\n  return [concat $cnt $r]\n}\n\n# Setup the test database\n#\ndo_test pageropt-1.1 {\n  sqlite3_soft_heap_limit 0\n  execsql {\n    PRAGMA auto_vacuum = OFF;\n    PRAGMA page_size = 1024;\n  }\n  pagercount_sql {\n    CREATE TABLE t1(x);\n  }\n} {0 2 0}\ndo_test pageropt-1.2 {\n  pagercount_sql {\n    INSERT INTO t1 VALUES(randomblob(5000));\n  }\n} {0 6 2}\n\n# Verify that values remain in cache on for subsequent reads.\n# We should not have to go back to disk.\n#\ndo_test pageropt-1.3 {\n  pagercount_sql {\n    SELECT length(x) FROM t1\n  }\n} {0 0 0 5000}\n\n# If another thread reads the database, the original cache\n# remains valid.\n#\nsqlite3 db2 test.db\nset blobcontent [db2 one {SELECT hex(x) FROM t1}]\ndo_test pageropt-1.4 {\n  pagercount_sql {\n    SELECT hex(x) FROM t1\n  }\n} [list 0 0 0 $blobcontent]\n\n# But if the other thread modifies the database, then the cache\n# must refill.\n#\nifcapable mmap {\n  set x [expr {[permutation]==\"mmap\" ? 1 : 6}]\n} else {\n  set x 6\n}\ndo_test pageropt-1.5 {\n  db2 eval {CREATE TABLE t2(y)}\n  pagercount_sql {\n    SELECT hex(x) FROM t1\n  }\n} [list $x 0 0 $blobcontent]\ndo_test pageropt-1.6 {\n  pagercount_sql {\n    SELECT hex(x) FROM t1\n  }\n} [list 0 0 0 $blobcontent]\n\n# Verify that the last page of an overflow chain is not read from\n# disk when deleting a row.  The one row of t1(x) has four pages\n# of overflow.  So deleting that row from t1 should involve reading\n# the sqlite_master table (1 page) the main page of t1 (1 page) and\n# the three overflow pages of t1 for a total of 5 pages.\n#\n# Pages written are page 1 (for the freelist pointer), the root page\n# of the table, and one of the overflow chain pointers because it\n# becomes the trunk of the freelist.  Total 3.\n#\ndo_test pageropt-2.1 {\n  db close\n  sqlite3 db test.db\n  pagercount_sql {\n    DELETE FROM t1 WHERE rowid=1\n  }\n} {5 3 3}\n\n# When pulling pages off of the freelist, there is no reason\n# to actually bring in the old content.\n#\ndo_test pageropt-2.2 {\n  db close\n  sqlite3 db test.db\n  pagercount_sql {\n    INSERT INTO t1 VALUES(randomblob(1500));\n  }\n} {3 4 3}\ndo_test pageropt-2.3 {\n  pagercount_sql {\n    INSERT INTO t1 VALUES(randomblob(1500));\n  }\n} {0 4 3}\n\n# Note the new optimization that when pulling the very last page off of the\n# freelist we do not read the content of that page.\n#\ndo_test pageropt-2.4 {\n  pagercount_sql {\n    INSERT INTO t1 VALUES(randomblob(1500));\n  }\n} {0 5 3}\n\n# Appending a large quantity of data does not involve writing much\n# to the journal file.\n#\ndo_test pageropt-3.1 {\n  pagercount_sql {\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n} {1 7 2}\n\n# Once again, we do not need to read the last page of an overflow chain\n# while deleting.\n#\ndo_test pageropt-3.2 {\n  pagercount_sql {\n    DROP TABLE t2;\n  }\n} {0 2 3}\ndo_test pageropt-3.3 {\n  pagercount_sql {\n    DELETE FROM t1;\n  }\n} {0 3 3}\n\n# There are now 11 pages on the freelist.  Move them all into an\n# overflow chain by inserting a single large record.  Starting from\n# a cold cache, only page 1, the root page of table t1, and the trunk\n# of the freelist need to be read (3 pages).  And only those three\n# pages need to be journalled.  But 13 pages need to be written:\n# page1, the root page of table t1, and an 11 page overflow chain.\n#\ndo_test pageropt-4.1 {\n  db close\n  sqlite3 db test.db\n  pagercount_sql {\n    INSERT INTO t1 VALUES(randomblob(11300))\n  }\n} {3 13 3}\n\n# Now we delete that big entries starting from a cold cache and an\n# empty freelist.  The first 10 of the 11 pages overflow chain have\n# to be read, together with page1 and the root of the t1 table.  12\n# reads total.  But only page1, the t1 root, and the trunk of the\n# freelist need to be journalled and written back.\n#\ndo_test pageropt-4.2 {\n  db close\n  sqlite3 db test.db\n  pagercount_sql {\n    DELETE FROM t1\n  }\n} {12 3 3}\n\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\ncatch {db2 close}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pagesize.test",
    "content": "# 2004 September 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# This file implements tests for the page_size PRAGMA.\n#\n# $Id: pagesize.test,v 1.13 2008/08/26 21:07:27 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# This test script depends entirely on \"PRAGMA page_size\". So if this\n# pragma is not available, omit the whole file.\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\ndo_test pagesize-1.1 {\n  execsql {PRAGMA page_size}\n} 1024\nifcapable {explain} {\n  do_test pagesize-1.2 {\n    catch {execsql {EXPLAIN PRAGMA page_size}}\n  } 0\n}\ndo_test pagesize-1.3 {\n  execsql {\n    CREATE TABLE t1(a);\n    PRAGMA page_size=2048;\n    PRAGMA page_size;\n  }\n} 1024\n\ndo_test pagesize-1.4 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size=511;\n    PRAGMA page_size;\n  }\n} 1024\ndo_test pagesize-1.5 {\n  execsql {\n    PRAGMA page_size=512;\n    PRAGMA page_size;\n  }\n} 512\nif {![info exists SQLITE_MAX_PAGE_SIZE] || $SQLITE_MAX_PAGE_SIZE>=8192} {\n  do_test pagesize-1.6 {\n    execsql {\n      PRAGMA page_size=8192;\n      PRAGMA page_size;\n    }\n  } 8192\n  do_test pagesize-1.7 {\n    execsql {\n      PRAGMA page_size=65537;\n      PRAGMA page_size;\n    }\n  } 8192\n  do_test pagesize-1.8 {\n    execsql {\n      PRAGMA page_size=1234;\n      PRAGMA page_size\n    }\n  } 8192\n}  \nforeach PGSZ {512 2048 4096 8192} {\n  if {[info exists SQLITE_MAX_PAGE_SIZE]\n           && $SQLITE_MAX_PAGE_SIZE<$PGSZ} continue\n  ifcapable memorydb {\n    do_test pagesize-2.$PGSZ.0.1 {\n      db close\n      sqlite3 db :memory:\n      execsql \"PRAGMA page_size=$PGSZ;\"\n      execsql {PRAGMA page_size}\n    } $PGSZ\n    do_test pagesize-2.$PGSZ.0.2 {\n      execsql {CREATE TABLE t1(x UNIQUE, y UNIQUE, z UNIQUE)}\n      execsql {PRAGMA page_size}\n    } $PGSZ\n    do_test pagesize-2.$PGSZ.0.3 {\n      execsql {\n        INSERT INTO t1 VALUES(1,2,3);\n        INSERT INTO t1 VALUES(2,3,4);\n        SELECT * FROM t1;\n      }\n    } {1 2 3 2 3 4}\n  }\n  do_test pagesize-2.$PGSZ.1 {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    execsql \"PRAGMA page_size=$PGSZ\"\n    execsql {\n      CREATE TABLE t1(x);\n      PRAGMA page_size;\n    }\n  } $PGSZ\n  do_test pagesize-2.$PGSZ.2 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      PRAGMA page_size\n    }\n  } $PGSZ\n  do_test pagesize-2.$PGSZ.3 {\n    file size test.db\n  } [expr {$PGSZ*($AUTOVACUUM?3:2)}]\n  ifcapable {vacuum} {\n    do_test pagesize-2.$PGSZ.4 {\n      execsql {VACUUM}\n    } {}\n  }\n  integrity_check pagesize-2.$PGSZ.5\n  do_test pagesize-2.$PGSZ.6 {\n    db close\n    sqlite3 db test.db\n    execsql {PRAGMA page_size}\n  } $PGSZ\n  do_test pagesize-2.$PGSZ.7 {\n    execsql {\n      INSERT INTO t1 VALUES(randstr(10,9000));\n      INSERT INTO t1 VALUES(randstr(10,9000));\n      INSERT INTO t1 VALUES(randstr(10,9000));\n      BEGIN;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      SELECT count(*) FROM t1;\n    }\n  } 48\n  do_test pagesize-2.$PGSZ.8 {\n    execsql {\n      ROLLBACK;\n      SELECT count(*) FROM t1;\n    }\n  } 3\n  integrity_check pagesize-2.$PGSZ.9\n  do_test pagesize-2.$PGSZ.10 {\n    db close\n    sqlite3 db test.db\n    execsql {PRAGMA page_size}\n  } $PGSZ\n  do_test pagesize-2.$PGSZ.11 {\n    execsql {\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      INSERT INTO t1 SELECT x||x FROM t1;\n      SELECT count(*) FROM t1;\n    }\n  } 192\n  do_test pagesize-2.$PGSZ.12 {\n    execsql {\n      BEGIN;\n      DELETE FROM t1 WHERE rowid%5!=0;\n      SELECT count(*) FROM t1;\n    }\n  } 38\n  do_test pagesize-2.$PGSZ.13 {\n    execsql {\n      ROLLBACK;\n      SELECT count(*) FROM t1;\n    }\n  } 192\n  integrity_check pagesize-2.$PGSZ.14\n  do_test pagesize-2.$PGSZ.15 {\n    execsql {DELETE FROM t1 WHERE rowid%5!=0}\n    ifcapable {vacuum} {execsql VACUUM}\n    execsql {SELECT count(*) FROM t1}\n  } 38\n  do_test pagesize-2.$PGSZ.16 {\n    execsql {DROP TABLE t1}\n    ifcapable {vacuum} {execsql VACUUM}\n  } {}\n  integrity_check pagesize-2.$PGSZ.17\n\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  do_test pagesize-2.$PGSZ.30 {\n    execsql \"\n      CREATE TABLE t1(x);\n      PRAGMA temp.page_size=$PGSZ;\n      CREATE TEMP TABLE t2(y);\n      PRAGMA main.page_size;\n      PRAGMA temp.page_size;\n    \"\n  } [list 1024 $PGSZ]\n\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  do_test pagesize-2.$PGSZ.40 {\n    execsql \"\n      PRAGMA page_size=$PGSZ;\n      CREATE TABLE t1(x);\n      CREATE TEMP TABLE t2(y);\n      PRAGMA main.page_size;\n      PRAGMA temp.page_size;\n    \"\n  } [list $PGSZ $PGSZ]\n}\n\nreset_db\ndo_execsql_test pagesize-3.1 {\n  BEGIN;\n  SELECT * FROM sqlite_master;\n  PRAGMA page_size=2048;\n  PRAGMA main.page_size;\n} {1024}\ndo_execsql_test pagesize-3.2 {\n  CREATE TABLE t1(x);\n  COMMIT;\n}\ndo_execsql_test pagesize-3.3 {\n  BEGIN;\n    PRAGMA page_size = 2048;\n  COMMIT;\n  PRAGMA main.page_size;\n} {1024}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/parser1.test",
    "content": "# 2014-08-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# The focus of this script is testing details of the SQL language parser.\n# \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_catchsql_test parser1-1.1 {\n  CREATE TABLE t1(\n    a TEXT PRIMARY KEY,\n    b TEXT,\n    FOREIGN KEY(b COLLATE nocase DESC) REFERENCES t1(a COLLATE binary ASC)\n  );\n} {1 {syntax error after column name \"b\"}}\n\n\n# Verify that a legacy schema in the sqlite_master file is allowed to have\n# COLLATE, ASC, and DESC keywords on the id list of a FK constraint, and that\n# those keywords are silently ignored.\n#\ndo_execsql_test parser1-1.2 {\n  CREATE TABLE t1(\n    a TEXT PRIMARY KEY,\n    b TEXT,\n    FOREIGN KEY(b) REFERENCES t1(a)\n  );\n  INSERT INTO t1 VALUES('abc',NULL),('xyz','abc');\n  PRAGMA writable_schema=on;\n  UPDATE sqlite_master SET sql='CREATE TABLE t1(\n    a TEXT PRIMARY KEY,\n    b TEXT,\n    FOREIGN KEY(b COLLATE nocase) REFERENCES t1(a)\n  )' WHERE name='t1';\n  SELECT name FROM sqlite_master WHERE sql LIKE '%collate%';\n} {t1}\nsqlite3 db2 test.db\ndo_test parser1-1.3 {\n  sqlite3 db2 test.db\n  db2 eval {SELECT * FROM t1 ORDER BY 1}\n} {abc {} xyz abc}\ndb2 close\n\ndo_execsql_test parser1-1.4 {\n  UPDATE sqlite_master SET sql='CREATE TABLE t1(\n    a TEXT PRIMARY KEY,\n    b TEXT,\n    FOREIGN KEY(b ASC) REFERENCES t1(a)\n  )' WHERE name='t1';\n  SELECT name FROM sqlite_master WHERE sql LIKE '%ASC%';\n} {t1}\nsqlite3 db2 test.db\ndo_test parser1-1.5 {\n  sqlite3 db2 test.db\n  db2 eval {SELECT * FROM t1 ORDER BY 1}\n} {abc {} xyz abc}\ndb2 close\n\ndo_catchsql_test parser1-2.1 {\n  WITH RECURSIVE\n    c(x COLLATE binary) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)\n  SELECT x FROM c;\n} {1 {syntax error after column name \"x\"}}\ndo_catchsql_test parser1-2.2 {\n  WITH RECURSIVE\n    c(x ASC) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)\n  SELECT x FROM c;\n} {1 {syntax error after column name \"x\"}}\n\n# Verify that the comma between multiple table constraints is\n# optional.\n#\n# The missing comma is technically a syntax error.  But we have to support\n# it because there might be legacy databases that omit the commas in their\n# sqlite_master tables.\n#\ndo_execsql_test parser1-3.1 {\n  CREATE TABLE t300(id INTEGER PRIMARY KEY);\n  CREATE TABLE t301(\n    id INTEGER PRIMARY KEY,\n    c1 INTEGER NOT NULL,\n    c2 INTEGER NOT NULL,\n    c3 BOOLEAN NOT NULL DEFAULT 0,\n    FOREIGN KEY(c1) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT\n        /* no comma */\n    FOREIGN KEY(c2) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT\n        /* no comma */\n    UNIQUE(c1, c2)\n  );\n  PRAGMA foreign_key_list(t301);\n} {0 0 t300 c2 id RESTRICT CASCADE NONE 1 0 t300 c1 id RESTRICT CASCADE NONE}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pcache.test",
    "content": "# 2008 August 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is focused on testing the pcache module.\n#\n# $Id: pcache.test,v 1.5 2009/05/08 06:52:48 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Only works with a mode-2 pcache where all pcaches share a single set\n# of pages.\n#\nifcapable {!memorymanage && threadsafe} {\n  finish_test\n  return\n}\n\n# The pcache module limits the number of pages available to purgeable\n# caches to the sum of the 'cache_size' values for the set of open\n# caches. This block of tests, pcache-1.*, test that the library behaves\n# corrctly when it is forced to exceed this limit.\n#\ndo_test pcache-1.1 {\n  db close\n  pcache_stats\n} {current 0 max 0 min 0 recyclable 0}\n\ndo_test pcache-1.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size=12;\n    PRAGMA auto_vacuum=0;\n    PRAGMA mmap_size=0;\n  }\n  pcache_stats\n} {current 1 max 12 min 10 recyclable 1}\n\ndo_test pcache-1.3 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n    CREATE TABLE t3(a, b, c);\n    CREATE TABLE t4(a, b, c);\n    CREATE TABLE t5(a, b, c);\n  }\n  pcache_stats\n} {current 6 max 12 min 10 recyclable 0}\n\ndo_test pcache-1.4 {\n  execsql {\n    CREATE TABLE t6(a, b, c);\n    CREATE TABLE t7(a, b, c);\n    CREATE TABLE t8(a, b, c);\n    CREATE TABLE t9(a, b, c);\n  }\n  pcache_stats\n} {current 10 max 12 min 10 recyclable 0}\n\ndo_test pcache-1.5 {\n  sqlite3 db2 test.db\n  execsql \"PRAGMA cache_size; PRAGMA cache_size=10\" db2\n  pcache_stats\n} {current 11 max 22 min 20 recyclable 1}\n\ndo_test pcache-1.6.1 {\n  execsql {\n    BEGIN;\n    SELECT * FROM sqlite_master;\n  } db2\n  pcache_stats\n} {current 11 max 22 min 20 recyclable 0}\n\n# At this point connection db2 has a read lock on the database file and a \n# single pinned page in its cache. Connection [db] is holding 10 dirty \n# pages. It cannot recycle them because of the read lock held by db2.\n#\ndo_test pcache-1.6.2 {\n  execsql {\n    CREATE INDEX i1 ON t1(a, b);\n    CREATE INDEX i2 ON t2(a, b);\n    CREATE INDEX i3 ON t3(a, b);\n    CREATE INDEX i4 ON t4(a, b);\n    CREATE INDEX i5 ON t5(a, b);\n    CREATE INDEX i6 ON t6(a, b);\n    CREATE INDEX i7 ON t7(a, b);\n    CREATE INDEX i8 ON t8(a, b);\n    CREATE INDEX i9 ON t9(a, b);\n    CREATE INDEX i10 ON t9(a, b);\n    CREATE INDEX i11 ON t9(a, b);\n  } \n  pcache_stats\n} {current 23 max 22 min 20 recyclable 0}\n\ndo_test pcache-1.7 {\n  execsql {\n    CREATE TABLE t10(a, b, c);\n  } \n  pcache_stats\n} {current 24 max 22 min 20 recyclable 0}\n\n# Rolling back the transaction held by db2 at this point releases a pinned\n# page. Because the number of allocated pages is greater than the \n# configured maximum, this page should be freed immediately instead of\n# recycled.\n#\ndo_test pcache-1.8 {\n  execsql {ROLLBACK} db2\n  pcache_stats\n} {current 23 max 22 min 20 recyclable 0}\n\ndo_test pcache-1.9 {\n  execsql COMMIT\n  pcache_stats\n} {current 22 max 22 min 20 recyclable 22}\n\ndo_test pcache-1.10 {\n  db2 close\n  pcache_stats\n} {current 12 max 12 min 10 recyclable 12}\n\ndo_test pcache-1.11 {\n  execsql { PRAGMA cache_size = 20 }\n  pcache_stats\n} {current 12 max 20 min 10 recyclable 12}\n\ndo_test pcache-1.12 {\n  execsql { \n    SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;\n    SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;\n    SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;\n    SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;\n    SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;\n    SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;\n    SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;\n    SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;\n    SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;\n  }\n  pcache_stats\n} {current 19 max 20 min 10 recyclable 19}\n\ndo_test pcache-1.13 {\n  execsql { PRAGMA cache_size = 15 }\n  pcache_stats\n} {current 15 max 15 min 10 recyclable 15}\n\ndo_test pcache-1.14 {\n  hexio_write test.db 24 [hexio_render_int32 1000]\n  execsql { SELECT * FROM sqlite_master }\n  pcache_stats\n} {current 2 max 15 min 10 recyclable 2}\n\ndo_test pcache-1.15 {\n  execsql { \n    SELECT * FROM t1 ORDER BY a; SELECT * FROM t1;\n    SELECT * FROM t2 ORDER BY a; SELECT * FROM t2;\n    SELECT * FROM t3 ORDER BY a; SELECT * FROM t3;\n    SELECT * FROM t4 ORDER BY a; SELECT * FROM t4;\n    SELECT * FROM t5 ORDER BY a; SELECT * FROM t5;\n    SELECT * FROM t6 ORDER BY a; SELECT * FROM t6;\n    SELECT * FROM t7 ORDER BY a; SELECT * FROM t7;\n    SELECT * FROM t8 ORDER BY a; SELECT * FROM t8;\n    SELECT * FROM t9 ORDER BY a; SELECT * FROM t9;\n  }\n  pcache_stats\n} {current 14 max 15 min 10 recyclable 14}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pcache2.test",
    "content": "# 2008 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is focused on testing the pcache module.\n#\n# $Id: pcache2.test,v 1.5 2009/07/18 14:36:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ntest_set_config_pagecache 0 0\n\n# Set up a pcache memory pool so that we can easily track how many\n# pages are being used for cache.\n#\ndo_test pcache2-1.1 {\n  db close\n  sqlite3_reset_auto_extension\n  sqlite3_shutdown\n  sqlite3_config_pagecache 6000 100\n  sqlite3_config singlethread\n  sqlite3_initialize\n  autoinstall_test_functions\n  sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1\n  sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0\n} {0 0 0}\n\n# Open up two database connections to separate files.\n#\ndo_test pcache2-1.2 {\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db eval {PRAGMA cache_size=10; SELECT 1 FROM sqlite_master;}\n  lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1\n} {2}\ndo_test pcache2-1.3 {\n  forcedelete test2.db test2.db-journal\n  sqlite3 db2 test2.db\n  db2 eval {PRAGMA cache_size=50; SELECT 1 FROM sqlite_master;}\n  lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1\n} {4}\n\n\n# Make lots of changes on the first connection.  Verify that the\n# page cache usage does not grow to consume the page space set aside\n# for the second connection.\n#\ndo_test pcache2-1.4 {\n  db eval {\n     CREATE TABLE t1(a,b);\n     CREATE TABLE t2(x,y);\n     INSERT INTO t1 VALUES(1, zeroblob(800));\n     INSERT INTO t1 VALUES(2, zeroblob(800));\n     INSERT INTO t2 SELECT * FROM t1;\n     INSERT INTO t1 SELECT x+2, y FROM t2;\n     INSERT INTO t2 SELECT a+10, b FROM t1;\n     INSERT INTO t1 SELECT x+10, y FROM t2;\n     INSERT INTO t2 SELECT a+100, b FROM t1;\n     INSERT INTO t1 SELECT x+100, y FROM t2;\n     INSERT INTO t2 SELECT a+1000, b FROM t1;\n     INSERT INTO t1 SELECT x+1000, y FROM t2;\n  }\n  sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0\n} {0 13 13}\n\ndb close\ncatch {db2 close}\nsqlite3_reset_auto_extension\nsqlite3_shutdown\nsqlite3_config_pagecache 0 0\nsqlite3_config serialized\nsqlite3_initialize\nautoinstall_test_functions\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/percentile.test",
    "content": "# 2013-05-28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is percentile.c extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Basic test of the percentile() function.\n#\ndo_test percentile-1.0 {\n  load_static_extension db percentile\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1),(4),(6),(7),(8),(9),(11),(11),(11);\n  }\n  execsql {SELECT percentile(x,0) FROM t1}\n} {1.0}\nforeach {in out} {\n  100    11.0\n   50     8.0\n   12.5   4.0\n   15     4.4\n   20     5.2\n   80    11.0\n   89    11.0\n} {\n  do_test percentile-1.1.$in {\n    execsql {SELECT percentile(x,$in) FROM t1}\n  } $out\n}\n\n# Add some NULL values.\n#\ndo_test percentile-1.2 {\n  execsql {INSERT INTO t1 VALUES(NULL),(NULL);}\n} {}\nforeach {in out} {\n  100    11.0\n   50     8.0\n   12.5   4.0\n   15     4.4\n   20     5.2\n   80    11.0\n   89    11.0\n} {\n  do_test percentile-1.3.$in {\n    execsql {SELECT percentile(x,$in) FROM t1}\n  } $out\n}\n\n# The second argument to percentile can change some, but not much.\n#\ndo_test percentile-1.4 {\n  catchsql {SELECT round(percentile(x, 15+0.000001*rowid),1) FROM t1}\n} {0 4.4}\ndo_test percentile-1.5 {\n  catchsql {SELECT round(percentile(x, 15+0.1*rowid),1) FROM t1}\n} {1 {2nd argument to percentile() is not the same for all input rows}}\n\n# Input values in a random order\n#\ndo_test percentile-1.6 {\n  execsql {\n    CREATE TABLE t2(x);\n    INSERT INTO t2 SELECT x+0.0 FROM t1 ORDER BY random();\n  }\n} {}\nforeach {in out} {\n  100    11.0\n   50     8.0\n   12.5   4.0\n   15     4.4\n   20     5.2\n   80    11.0\n   89    11.0\n} {\n  do_test percentile-1.7.$in {\n    execsql {SELECT percentile(x,$in) FROM t2}\n  } $out\n}\n\n# Wrong number of arguments\n#\ndo_test percentile-1.8 {\n  catchsql {SELECT percentile(x,0,1) FROM t1}\n} {1 {wrong number of arguments to function percentile()}}\ndo_test percentile-1.9 {\n  catchsql {SELECT percentile(x) FROM t1}\n} {1 {wrong number of arguments to function percentile()}}\n\n# Second argument must be numeric\n#\ndo_test percentile-1.10 {\n  catchsql {SELECT percentile(x,null) FROM t1}\n} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}\ndo_test percentile-1.11 {\n  catchsql {SELECT percentile(x,'fifty') FROM t1}\n} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}\ndo_test percentile-1.12 {\n  catchsql {SELECT percentile(x,x'3530') FROM t1}\n} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}\n\n# Second argument is out of range\n#\ndo_test percentile-1.13 {\n  catchsql {SELECT percentile(x,-0.0000001) FROM t1}\n} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}\ndo_test percentile-1.14 {\n  catchsql {SELECT percentile(x,100.0000001) FROM t1}\n} {1 {2nd argument to percentile() is not a number between 0.0 and 100.0}}\n\n# First argument is not NULL and is not NUMERIC\n#\ndo_test percentile-1.15 {\n  catchsql {\n    BEGIN;\n    UPDATE t1 SET x='50' WHERE x IS NULL;\n    SELECT percentile(x, 50) FROM t1;\n  }\n} {1 {1st argument to percentile() is not numeric}}\ndo_test percentile-1.16 {\n  catchsql {\n    ROLLBACK;\n    BEGIN;\n    UPDATE t1 SET x=x'3530' WHERE x IS NULL;\n    SELECT percentile(x, 50) FROM t1;\n  }\n} {1 {1st argument to percentile() is not numeric}}\ndo_test percentile-1.17 {\n  catchsql {\n    ROLLBACK;\n    SELECT percentile(x, 50) FROM t1;\n  }\n} {0 8.0}\n\n# No non-NULL entries.\n#\ndo_test percentile-1.18 {\n  execsql {\n    UPDATE t1 SET x=NULL;\n    SELECT ifnull(percentile(x, 50),'NULL') FROM t1\n  } \n} {NULL}\n\n# Exactly one non-NULL entry\n#\ndo_test percentile-1.19 {\n  execsql {\n    UPDATE t1 SET x=12345 WHERE rowid=5;\n    SELECT percentile(x, 0), percentile(x, 50), percentile(x,100) FROM t1\n  } \n} {12345.0 12345.0 12345.0}\n\n# Infinity as an input\n#\ndo_test percentile-1.20 {\n  catchsql {\n    DELETE FROM t1;\n    INSERT INTO t1 SELECT x+0.0 FROM t2;\n    UPDATE t1 SET x=1.0e300*1.0e300 WHERE rowid=5;\n    SELECT percentile(x,50) from t1;\n  }\n} {1 {Inf input to percentile()}}\ndo_test percentile-1.21 {\n  catchsql {\n    UPDATE t1 SET x=-1.0e300*1.0e300 WHERE rowid=5;\n    SELECT percentile(x,50) from t1;\n  }\n} {1 {Inf input to percentile()}}\n\n# Million-row Inputs\n#\nifcapable vtab {\n  do_test percentile-2.0 {\n    load_static_extension db wholenumber\n    execsql {\n      CREATE VIRTUAL TABLE nums USING wholenumber;\n      CREATE TABLE t3(x);\n      INSERT INTO t3 SELECT value-1 FROM nums WHERE value BETWEEN 1 AND 500000;\n      INSERT INTO t3 SELECT value*10 FROM nums\n                      WHERE value BETWEEN 500000 AND 999999;\n      SELECT count(*) FROM t3;\n    }\n  } {1000000}\n  foreach {in out} {\n      0          0.0\n    100    9999990.0\n     50    2749999.5\n     10      99999.9\n  } {\n    do_test percentile-2.1.$in {\n      execsql {\n        SELECT round(percentile(x, $in),1) from t3;\n      }\n    } $out\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/permutations.test",
    "content": "# 2008 June 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndb close\n\n#-------------------------------------------------------------------------\n# test_suite NAME OPTIONS\n#\n# where available options are:  \n#\n#       -description TITLE                  (default \"\")\n#       -initialize  SCRIPT                 (default \"\")\n#       -shutdown    SCRIPT                 (default \"\")\n#       -presql      SQL                    (default \"\")\n#       -files       LIST-OF-FILES          (default $::ALLTESTS)\n#       -prefix      NAME                   (default \"$::NAME.\")\n#       -dbconfig    SCRIPT                 (default \"\")\n#\nproc test_suite {name args} {\n\n  set default(-shutdown)    \"\"\n  set default(-initialize)  \"\"\n  set default(-presql)      \"\"\n  set default(-description) \"no description supplied (fixme)\"\n  set default(-files)       \"\"\n  set default(-prefix)      \"${name}.\"\n  set default(-dbconfig)    \"\"\n\n  array set options [array get default]\n  if {[llength $args]%2} {\n    error \"uneven number of options/switches passed to test_suite\"\n  }\n  foreach {k v} $args {\n    set o [array names options ${k}*]\n    if {[llength $o]>1}  { error \"ambiguous option: $k\" }\n    if {[llength $o]==0} { error \"unknown option: $k\" }\n    set options([lindex $o 0]) $v\n  }\n\n  set     ::testspec($name) [array get options]\n  lappend ::testsuitelist $name\n}\n\n#-------------------------------------------------------------------------\n# test_set ARGS...\n#\nproc test_set {args} {\n  set isExclude 0\n  foreach a $args {\n    if {[string match -* $a]} {\n      switch -- $a {\n        -include { set isExclude 0 }\n        -exclude { set isExclude 1 }\n        default {\n          error \"Unknown switch: $a\"\n        }\n      }\n    } elseif {$isExclude == 0} {\n      foreach f $a { set t($f) 1 }\n    } else {\n      foreach f $a { array unset t $f }\n      foreach f $a { array unset t */$f }\n    }\n  }\n\n  return [array names t]\n}\n\n#-------------------------------------------------------------------------\n# Set up the following global list variables containing the names of \n# various test scripts:\n#\n#   $alltests\n#   $allquicktests\n#\nset alltests [list]\nforeach f [glob $testdir/*.test] { lappend alltests [file tail $f] }\nforeach f [glob -nocomplain       \\\n    $testdir/../ext/rtree/*.test  \\\n    $testdir/../ext/fts5/test/*.test   \\\n    $testdir/../ext/lsm1/test/*.test   \\\n] {\n  lappend alltests $f \n}\nforeach f [glob -nocomplain $testdir/../ext/session/*.test] { \n  lappend alltests $f \n}\n\nif {$::tcl_platform(platform)!=\"unix\"} {\n  set alltests [test_set $alltests -exclude crash.test crash2.test]\n}\nset alltests [test_set $alltests -exclude {\n  all.test        async.test         quick.test  veryquick.test\n  memleak.test    permutations.test  soak.test   fts3.test\n  mallocAll.test  rtree.test         full.test   extraquick.test\n  session.test\n}]\n\nset allquicktests [test_set $alltests -exclude {\n  async2.test async3.test backup_ioerr.test corrupt.test\n  corruptC.test crash.test crash2.test crash3.test crash4.test crash5.test\n  crash6.test crash7.test delete3.test e_fts3.test fts3rnd.test\n  fkey_malloc.test fuzz.test fuzz3.test fuzz_malloc.test in2.test loadext.test\n  misc7.test mutex2.test notify2.test onefile.test pagerfault2.test \n  savepoint4.test savepoint6.test select9.test \n  speed1.test speed1p.test speed2.test speed3.test speed4.test \n  speed4p.test sqllimits1.test tkt2686.test thread001.test thread002.test\n  thread003.test thread004.test thread005.test trans2.test vacuum3.test \n  incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test\n  vtab_err.test walslow.test walcrash.test walcrash3.test\n  walthread.test rtree3.test indexfault.test securedel2.test\n  sort3.test sort4.test fts4growth.test fts4growth2.test\n  bigsort.test rbu.test walprotocol.test mmap4.test fuzzer2.test\n  walcrash2.test e_fkey.test backup.test\n\n  fts4merge.test fts4merge2.test fts4merge4.test fts4check.test\n  fts3cov.test fts3snippet.test fts3corrupt2.test fts3an.test\n  fts3defer.test fts4langid.test fts3sort.test fts5unicode.test\n\n  rtree4.test\n}]\nif {[info exists ::env(QUICKTEST_INCLUDE)]} {\n  set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]\n}\nif {[info exists ::env(QUICKTEST_OMIT)]} {\n  foreach x [split $::env(QUICKTEST_OMIT) ,] {\n    regsub -all \\\\y$x\\\\y $allquicktests {} allquicktests\n  }\n}\n\n# If the TEST_FAILURE environment variable is set, it means that we what to\n# deliberately provoke test failures in order to test the test infrastructure.\n# Only the main.test module is needed for this.\n#\nif {[info exists ::env(TEST_FAILURE)]} {\n  set allquicktests main.test\n}\n\n#############################################################################\n# Start of tests\n#\n\n#-------------------------------------------------------------------------\n# Define the generic test suites:\n#\n#   veryquick\n#   quick\n#   full\n#\nlappend ::testsuitelist xxx\n\ntest_suite \"veryquick\" -prefix \"\" -description {\n  \"Very\" quick test suite. Runs in minutes on a workstation.\n  This test suite is the same as the \"quick\" tests, except that some files\n  that test malloc and IO errors are omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \\\n      *fts5corrupt* *fts5big* *fts5aj*\n]\n\ntest_suite \"extraquick\" -prefix \"\" -description {\n  \"Extra\" quick test suite. Runs in a few minutes on a workstation.\n  This test suite is the same as the \"veryquick\" tests, except that\n  slower tests are omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \\\n     wal3.test fts4merge* sort2.test mmap1.test walcrash* \\\n     percentile.test where8m.test walcksum.test savepoint3.test \\\n     fuzzer1.test fuzzer3.test fts3expr3.test\n]\n\ntest_suite \"mmap\" -prefix \"mm-\" -description {\n  Similar to veryquick. Except with memory mapping enabled.\n} -presql {\n  pragma mmap_size = 268435456;\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* -include malloc.test\n]\n\ntest_suite \"valgrind\" -prefix \"\" -description {\n  Run the \"veryquick\" test suite with a couple of multi-process tests (that\n  fail under valgrind) omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* wal.test \\\n              shell*.test crash8.test atof1.test selectG.test \\\n              tkt-fc62af4523.test numindex1.test corruptK.test\n] -initialize {\n  set ::G(valgrind) 1\n} -shutdown {\n  unset -nocomplain ::G(valgrind)\n}\n\ntest_suite \"valgrind-nolookaside\" -prefix \"\" -description {\n  Run the \"veryquick\" test suite with a couple of multi-process tests (that\n  fail under valgrind) omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err* \\\n      wal.test atof1.test\n] -initialize {\n  set ::G(valgrind) 1\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n  autoinstall_test_functions\n} -shutdown {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_lookaside 100 500\n  sqlite3_initialize\n  autoinstall_test_functions\n  unset -nocomplain ::G(valgrind)\n}\n\n\ntest_suite \"quick\" -prefix \"\" -description {\n  Quick test suite. Runs in around 10 minutes on a workstation.\n} -files [\n  test_set $allquicktests\n]\n\ntest_suite \"full\" -prefix \"\" -description {\n  Full test suite. Takes a long time.\n} -files [ \n  test_set $alltests \n] -initialize {\n  unset -nocomplain ::G(isquick)\n}\n\ntest_suite \"threads\" -prefix \"\" -description {\n  All multi-threaded tests.\n} -files {\n  notify2.test   thread001.test thread002.test thread003.test \n  thread004.test thread005.test walthread.test\n}\n\ntest_suite \"fts3\" -prefix \"\" -description {\n  All FTS3 tests except fts3rnd.test.\n} -files {\n  fts3aa.test fts3ab.test fts3ac.test fts3ad.test\n  fts3ae.test fts3af.test fts3ag.test fts3ah.test\n  fts3ai.test fts3aj.test fts3ak.test fts3al.test\n  fts3am.test fts3an.test fts3ao.test fts3atoken.test\n  fts3auto.test fts3aux1.test fts3aux2.test fts3b.test\n  fts3comp1.test fts3conf.test fts3corrupt2.test fts3corrupt.test\n  fts3cov.test fts3c.test fts3defer2.test fts3defer3.test\n  fts3defer.test fts3drop.test fts3d.test fts3e.test\n  fts3expr2.test fts3expr3.test fts3expr4.test fts3expr5.test\n  fts3expr.test fts3fault2.test fts3fault.test fts3first.test\n  fts3join.test fts3malloc.test fts3matchinfo.test fts3near.test\n  fts3offsets.test fts3prefix2.test fts3prefix.test fts3query.test\n  fts3shared.test fts3snippet.test fts3sort.test fts3tok1.test\n  fts3tok_err.test fts3varint.test fts4aa.test fts4check.test\n  fts4content.test fts4docid.test fts4growth2.test fts4growth.test\n  fts4incr.test fts4langid.test fts4lastrowid.test fts4merge2.test\n  fts4merge4.test fts4merge.test fts4noti.test fts4onepass.test \n  fts4opt.test fts4unicode.test\n  fts3corrupt3.test\n  fts3misc.test\n}\n\ntest_suite \"fts5\" -prefix \"\" -description {\n  All FTS5 tests.\n} -files [glob -nocomplain $::testdir/../ext/fts5/test/*.test]\n\ntest_suite \"fts5-light\" -prefix \"\" -description {\n  All FTS5 tests.\n} -files [\n  test_set \\\n      [glob -nocomplain $::testdir/../ext/fts5/test/*.test] \\\n      -exclude *corrupt* *fault* *big* *fts5aj*\n]\n\ntest_suite \"lsm1\" -prefix \"\" -description {\n  All LSM1 tests.\n} -files [glob -nocomplain $::testdir/../ext/lsm1/test/*.test]\n\ntest_suite \"nofaultsim\" -prefix \"\" -description {\n  \"Very\" quick test suite. Runs in less than 5 minutes on a workstation. \n  This test suite is the same as the \"quick\" tests, except that some files\n  that test malloc and IO errors are omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *_err*\n] -initialize {\n  catch {db close}\n  sqlite3_shutdown\n  install_malloc_faultsim 0\n  sqlite3_initialize\n  autoinstall_test_functions\n} -shutdown {\n  unset -nocomplain ::G(valgrind)\n}\n\ntest_suite \"queryplanner\" -prefix \"\" -description {\n  Tests of the query planner and query optimizer\n} -files {\n  alter2.test alter3.test alter4.test alter.test analyze3.test\n  analyze4.test analyze5.test analyze6.test analyze7.test analyze8.test\n  analyze.test attach2.test attach3.test attach4.test\n  attach.test autoinc.test autoindex1.test between.test cast.test\n  check.test closure01.test coalesce.test collate1.test collate2.test\n  collate3.test collate4.test collate5.test collate6.test collate7.test\n  collate8.test collate9.test collateA.test colmeta.test colname.test\n  conflict.test count.test coveridxscan.test createtab.test cse.test\n  date.test dbstatus2.test dbstatus.test default.test delete2.test\n  delete3.test delete.test descidx1.test descidx2.test descidx3.test\n  distinctagg.test distinct.test e_createtable.test e_delete.test\n  e_droptrigger.test e_dropview.test e_expr.test e_insert.test\n  eqp.test e_reindex.test e_resolve.test e_select2.test e_select.test\n  e_update.test exists.test expr.test fkey1.test fkey2.test fkey3.test\n  fkey4.test fkey5.test func2.test func3.test func.test \n  in3.test in4.test in5.test index2.test index3.test\n  index4.test index5.test indexedby.test index.test\n  insert2.test insert3.test insert4.test insert5.test insert.test\n  instr.test in.test intpkey.test join2.test join3.test join4.test\n  join5.test join6.test join.test like2.test like.test limit.test\n  minmax2.test minmax3.test minmax4.test minmax.test misc1.test misc2.test\n  misc3.test misc4.test misc5.test misc6.test misc7.test orderby1.test\n  orderby2.test orderby3.test orderby4.test randexpr1.test regexp1.test\n  reindex.test rowhash.test rowid.test schema2.test schema3.test\n  schema4.test schema5.test schema.test\n  select1.test select2.test select3.test select4.test select5.test\n  select6.test select7.test select8.test select9.test selectA.test\n  selectB.test selectC.test selectD.test selectE.test sidedelete.test\n  sort.test spellfix.test subquery2.test subquery.test subselect.test\n  substr.test tkt-02a8e81d44.test tkt1435.test tkt1443.test tkt1444.test\n  tkt1449.test tkt1473.test tkt1501.test tkt1512.test tkt1514.test\n  tkt1536.test tkt1537.test tkt1567.test tkt1644.test tkt1667.test\n  tkt1873.test tkt2141.test tkt2192.test tkt2213.test tkt2251.test\n  tkt2285.test tkt2332.test tkt2339.test tkt2391.test tkt2409.test\n  tkt2450.test tkt2565.test tkt2640.test tkt2643.test tkt2686.test\n  tkt-26ff0c2d1e.test tkt2767.test tkt2817.test tkt2820.test tkt2822.test\n  tkt2832.test tkt2854.test tkt2920.test tkt2927.test tkt2942.test\n  tkt-2a5629202f.test tkt-2d1a5c67d.test tkt-2ea2425d34.test tkt3080.test\n  tkt3093.test tkt3121.test tkt-31338dca7e.test tkt-313723c356.test\n  tkt3201.test tkt3292.test tkt3298.test tkt3334.test tkt3346.test\n  tkt3357.test tkt3419.test tkt3424.test tkt3442.test tkt3457.test\n  tkt3461.test tkt3493.test tkt3508.test tkt3522.test tkt3527.test\n  tkt3541.test tkt3554.test tkt3581.test tkt35xx.test tkt3630.test\n  tkt3718.test tkt3731.test tkt3757.test tkt3761.test tkt3762.test\n  tkt3773.test tkt3791.test tkt3793.test tkt3810.test tkt3824.test\n  tkt3832.test tkt3838.test tkt3841.test tkt-385a5b56b9.test tkt3871.test\n  tkt3879.test tkt-38cb5df375.test tkt3911.test tkt3918.test tkt3922.test\n  tkt3929.test tkt3935.test tkt3992.test tkt3997.test tkt-3998683a16.test\n  tkt-3a77c9714e.test tkt-3fe897352e.test tkt4018.test tkt-4a03edc4c8.test\n  tkt-4dd95f6943.test tkt-54844eea3f.test tkt-5d863f876e.test\n  tkt-5e10420e8d.test tkt-5ee23731f.test tkt-6bfb98dfc0.test\n  tkt-752e1646fc.test tkt-78e04e52ea.test tkt-7a31705a7e6.test\n  tkt-7bbfb7d442.test tkt-80ba201079.test tkt-80e031a00f.test\n  tkt-8454a207b9.test tkt-91e2e8ba6f.test tkt-94c04eaadb.test\n  tkt-9d68c883.test tkt-a7b7803e.test tkt-b1d3a2e531.test\n  tkt-b351d95f9.test tkt-b72787b1.test tkt-bd484a090c.test\n  tkt-bdc6bbbb38.test tkt-c48d99d690.test tkt-cbd054fa6b.test\n  tkt-d11f09d36e.test tkt-d635236375.test tkt-d82e3f3721.test\n  tkt-f3e5abed55.test tkt-f777251dc7a.test tkt-f7b4edec.test\n  tkt-f973c7ac31.test tkt-fa7bf5ec.test tkt-fc62af4523.test\n  tkt-fc7bd6358f.test trigger1.test trigger2.test trigger3.test\n  trigger4.test trigger5.test trigger6.test trigger7.test trigger8.test\n  trigger9.test triggerA.test triggerB.test triggerC.test triggerD.test\n  types2.test types3.test types.test unique.test unordered.test\n  update.test view.test vtab1.test vtab2.test vtab3.test vtab4.test\n  vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test\n  vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test\n  vtabF.test where2.test where3.test where4.test where5.test where6.test\n  where7.test where8m.test where8.test where9.test whereA.test whereB.test\n  whereC.test whereD.test whereE.test whereF.test wherelimit.test\n  where.test\n}\n\ntest_suite \"vfslog\" -prefix \"\" -description {\n  \"Vfslog\" quick test suite. Like \"veryquick\" except does not omits\n  a few tests that do not work with a version 1 VFS. And the quota* tests,\n  which do not work with a VFS that uses the pVfs argument passed to\n  sqlite3_vfs methods.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* oserror.test \\\n  pager1.test syscall.test sysfault.test tkt3457.test quota* superlock* \\\n  wal* mmap*\n]\n\ntest_suite \"atomic-batch-write\" -prefix \"\" -description {\n  Like veryquick.test, but must be run on a file-system that supports\n  atomic-batch-writes. Tests that depend on the journal file being present\n  are omitted.\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \\\n      *fts5corrupt* *fts5big* *fts5aj*  \\\n      crash8.test delete_db.test        \\\n      exclusive.test journal3.test      \\\n      journal1.test                     \\\n      jrnlmode.test jrnlmode2.test      \\\n      lock4.test pager1.test            \\\n      pager3.test sharedA.test          \\\n      symlink.test stmt.test            \\\n      sync.test sync2.test              \\\n      tempdb.test tkt3457.test          \\\n      vacuum5.test wal2.test            \\\n      walmode.test zerodamage.test\n] -initialize {\n  if {[atomic_batch_write test.db]==0} {\n    error \"File system does NOT support atomic-batch-write\"\n  }\n}\n\nlappend ::testsuitelist xxx\n#-------------------------------------------------------------------------\n# Define the coverage related test suites:\n#\n#   coverage-wal\n#\ntest_suite \"coverage-wal\" -description {\n  Coverage tests for file wal.c.\n} -files {\n  wal.test       wal2.test     wal3.test       walmode.test    \n  walbak.test    walhook.test  walcrash2.test  walcksum.test\n  walfault.test  walbig.test   walnoshm.test\n  wal5.test\n} \n\ntest_suite \"coverage-pager\" -description {\n  Coverage tests for file pager.c.\n} -files {\n  pager1.test    pager2.test  pagerfault.test  pagerfault2.test\n  walfault.test  walbak.test  journal2.test    tkt-9d68c883.test\n} \n\ntest_suite \"coverage-analyze\" -description {\n  Coverage tests for file analyze.c.\n} -files {\n  analyze3.test analyze4.test analyze5.test analyze6.test\n  analyze7.test analyze8.test analyze9.test analyzeA.test\n  analyze.test analyzeB.test mallocA.test\n} \n\ntest_suite \"coverage-sorter\" -description {\n  Coverage tests for file vdbesort.c.\n} -files {\n  sort.test sortfault.test\n} \n\n\nlappend ::testsuitelist xxx\n#-------------------------------------------------------------------------\n# Define the permutation test suites:\n#\n\n# Run some tests using pre-allocated page blocks.\n#\n# mmap1.test is excluded because a good number of its tests depend on \n# the page-cache being larger than the database. But this permutation\n# causes the effective limit on the page-cache to be just 24 pages.\n#\ntest_suite \"memsubsys1\" -description {\n  Tests using pre-allocated page blocks\n} -files [\n  test_set $::allquicktests -exclude ioerr5.test malloc5.test mmap1.test\n] -initialize {\n  test_set_config_pagecache 4096 24\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_initialize\n  autoinstall_test_functions\n} -shutdown {\n  test_restore_config_pagecache\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_initialize\n  autoinstall_test_functions\n}\n\n# Run some tests using pre-allocated page blocks. This time\n# the allocations are too small to use in most cases.\n#\n# Both ioerr5.test and malloc5.test are excluded because they test the\n# sqlite3_soft_heap_limit() and sqlite3_release_memory() functionality.\n# This functionality is disabled if a pre-allocated page block is provided.\n#\ntest_suite \"memsubsys2\" -description {\n  Tests using small pre-allocated page blocks\n} -files [\n  test_set $::allquicktests -exclude ioerr5.test malloc5.test\n] -initialize {\n  test_set_config_pagecache 512 5\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_initialize\n  autoinstall_test_functions\n} -shutdown {\n  test_restore_config_pagecache\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_initialize\n  autoinstall_test_functions\n}\n\n# Run all tests with the lookaside allocator disabled.\n#\ntest_suite \"nolookaside\" -description {\n  OOM tests with lookaside disabled\n} -initialize {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_lookaside 0 0\n  sqlite3_initialize\n  autoinstall_test_functions\n} -shutdown {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_lookaside 100 500\n  sqlite3_initialize\n  autoinstall_test_functions\n} -files $::allquicktests\n\n# Run some tests in SQLITE_CONFIG_SINGLETHREAD mode.\n#\ntest_suite \"singlethread\" -description {\n  Tests run in SQLITE_CONFIG_SINGLETHREAD mode\n} -initialize {\n  catch {db close}\n  sqlite3_shutdown\n  catch {sqlite3_config singlethread}\n  sqlite3_initialize\n  autoinstall_test_functions\n} -files {\n  delete.test   delete2.test  insert.test  rollback.test  select1.test\n  select2.test  trans.test    update.test  vacuum.test    types.test\n  types2.test   types3.test\n} -shutdown {\n  catch {db close}\n  sqlite3_shutdown\n  catch {sqlite3_config serialized}\n  sqlite3_initialize\n  autoinstall_test_functions\n}\n\ntest_suite \"nomutex\" -description {\n  Tests run with the SQLITE_OPEN_MULTITHREADED flag passed to sqlite3_open().\n} -initialize {\n  rename sqlite3 sqlite3_nomutex\n  proc sqlite3 {args} {\n    if {[string range [lindex $args 0] 0 0] ne \"-\"} {\n      lappend args -fullmutex 0 -nomutex 1\n    }\n    uplevel [concat sqlite3_nomutex $args]\n  }\n} -files {\n  delete.test   delete2.test  insert.test  rollback.test  select1.test\n  select2.test  trans.test    update.test  vacuum.test    types.test\n  types2.test   types3.test\n} -shutdown {\n  rename sqlite3 {}\n  rename sqlite3_nomutex sqlite3\n}\n\n# Run some tests in SQLITE_CONFIG_MULTITHREAD mode.\n#\ntest_suite \"multithread\" -description {\n  Tests run in SQLITE_CONFIG_MULTITHREAD mode\n} -initialize {\n  catch {db close}\n  sqlite3_shutdown\n  catch {sqlite3_config multithread}\n  sqlite3_initialize\n  autoinstall_test_functions\n} -files {\n  delete.test   delete2.test  insert.test  rollback.test  select1.test\n  select2.test  trans.test    update.test  vacuum.test    types.test\n  types2.test   types3.test   sort4.test\n} -shutdown {\n  catch {db close}\n  sqlite3_shutdown\n  catch {sqlite3_config serialized}\n  sqlite3_initialize\n  autoinstall_test_functions\n}\n\n# Run some tests in SQLITE_OPEN_FULLMUTEX mode.\n#\ntest_suite \"fullmutex\" -description {\n  Tests run in SQLITE_OPEN_FULLMUTEX mode\n} -initialize {\n  rename sqlite3 sqlite3_fullmutex\n  proc sqlite3 {args} {\n    if {[string range [lindex $args 0] 0 0] ne \"-\"} {\n      lappend args -nomutex 0 -fullmutex 1\n    }\n    uplevel [concat sqlite3_fullmutex $args]\n  }\n} -files {\n  delete.test   delete2.test  insert.test  rollback.test  select1.test\n  select2.test  trans.test    update.test  vacuum.test    types.test\n  types2.test   types3.test\n} -shutdown {\n  rename sqlite3 {}\n  rename sqlite3_fullmutex sqlite3\n}\n\n# Run some tests using the \"onefile\" demo.\n#\ntest_suite \"onefile\" -description {\n  Run some tests using the \"test_onefile.c\" demo\n} -initialize {\n  rename sqlite3 sqlite3_onefile\n  proc sqlite3 {args} {\n    if {[string range [lindex $args 0] 0 0] ne \"-\"} {\n      lappend args -vfs fs\n    }\n    uplevel [concat sqlite3_onefile $args]\n  }\n} -files {\n  conflict.test  insert.test   insert2.test  insert3.test\n  rollback.test  select1.test  select2.test  select3.test\n} -shutdown {\n  rename sqlite3 {}\n  rename sqlite3_onefile sqlite3\n}\n\n# Run some tests using UTF-16 databases.\n#\ntest_suite \"utf16\" -description {\n  Run tests using UTF-16 databases\n} -presql {\n  pragma encoding = 'UTF-16'\n} -files {\n    alter.test alter3.test\n    analyze.test analyze3.test analyze4.test analyze5.test analyze6.test\n    analyze7.test analyze8.test analyze9.test analyzeA.test analyzeB.test\n    auth.test bind.test blob.test capi2.test capi3.test collate1.test\n    collate2.test collate3.test collate4.test collate5.test collate6.test\n    conflict.test date.test delete.test expr.test fkey1.test func.test\n    hook.test index.test insert2.test insert.test interrupt.test in.test\n    intpkey.test ioerr.test join2.test join.test lastinsert.test\n    laststmtchanges.test limit.test lock2.test lock.test main.test \n    memdb.test minmax.test misc1.test misc2.test misc3.test notnull.test\n    null.test progress.test quote.test rowid.test select1.test select2.test\n    select3.test select4.test select5.test select6.test sort.test \n    subselect.test tableapi.test table.test temptable.test\n    trace.test trigger1.test trigger2.test trigger3.test\n    trigger4.test types2.test types.test unique.test update.test\n    vacuum.test view.test where.test\n    bestindex1.test\n}\n\n# Run some tests in exclusive locking mode.\n#\ntest_suite \"exclusive\" -description {\n  Run tests in exclusive locking mode.\n} -presql {\n  pragma locking_mode = 'exclusive'\n} -files {\n  rollback.test select1.test select2.test \n  malloc.test ioerr.test\n} \n\n# Run some tests in exclusive locking mode with truncated journals.\n#\ntest_suite \"exclusive-truncate\" -description {\n  Run tests in exclusive locking mode and truncate journal mode.\n} -presql {\n  pragma locking_mode = 'exclusive';\n  pragma journal_mode = TRUNCATE;\n} -files {\n  delete.test delete2.test insert.test rollback.test select1.test\n  select2.test update.test malloc.test ioerr.test\n} \n\n# Run some tests in persistent journal mode.\n#\ntest_suite \"persistent_journal\" -description {\n  Run tests in persistent-journal mode.\n} -presql {\n  pragma journal_mode = persist\n} -files {\n  delete.test delete2.test insert.test rollback.test select1.test\n  select2.test trans.test update.test vacuum.test \n}\n\n# Run some tests in truncating journal mode.\n#\ntest_suite \"truncate_journal\" -description {\n  Run tests in persistent-journal mode.\n} -presql {\n  pragma journal_mode = truncate\n} -files {\n  delete.test delete2.test insert.test rollback.test select1.test\n  select2.test trans.test update.test vacuum.test \n  malloc.test ioerr.test\n}\n\n# Run some error tests in persistent journal mode.\n#\ntest_suite \"persistent_journal_error\" -description {\n  Run malloc.test and ioerr.test in persistent-journal mode.\n} -presql {\n  pragma journal_mode = persist\n} -files {\n  malloc.test ioerr.test\n}\n\n# Run some tests in no journal mode.\n#\ntest_suite \"no_journal\" -description {\n  Run tests in no-journal mode.\n} -presql {\n  pragma journal_mode = persist\n} -files {\n  delete.test delete2.test insert.test rollback.test select1.test\n  select2.test trans.test update.test vacuum.test \n}\n\n# Run some error tests in no journal mode.\n#\ntest_suite \"no_journal_error\" -description {\n  Run malloc.test and ioerr.test in no-journal mode.\n} -presql {\n  pragma journal_mode = persist\n} -files {\n  malloc.test ioerr.test\n}\n\n# Run some crash-tests in autovacuum mode.\n#\ntest_suite \"autovacuum_crash\" -description {\n  Run crash.test in autovacuum mode.\n} -presql {\n  pragma auto_vacuum = 1\n} -files crash.test\n\n# Run some ioerr-tests in autovacuum mode.\n#\ntest_suite \"autovacuum_ioerr\" -description {\n  Run ioerr.test in autovacuum mode.\n} -presql {\n  pragma auto_vacuum = 1\n} -files ioerr.test\n\n# Run tests with an in-memory journal.\n#\ntest_suite \"inmemory_journal\" -description {\n  Run tests with an in-memory journal file.\n} -presql {\n  pragma journal_mode = 'memory'\n} -files [test_set $::allquicktests -exclude {\n  # Exclude all tests that simulate IO errors.\n  autovacuum_ioerr2.test cffault.test incrvacuum_ioerr.test ioerr.test\n  ioerr.test ioerr2.test ioerr3.test ioerr4.test ioerr5.test\n  vacuum3.test incrblob_err.test diskfull.test backup_ioerr.test\n  e_fts3.test fts3cov.test fts3malloc.test fts3rnd.test\n  fts3snippet.test mmapfault.test sessionfault.test sessionfault2.test\n\n  # Exclude test scripts that use tcl IO to access journal files or count\n  # the number of fsync() calls.\n  pager.test exclusive.test jrnlmode.test sync.test misc1.test \n  journal1.test conflict.test crash8.test tkt3457.test io.test\n  journal3.test 8_3_names.test\n\n  pager1.test async4.test corrupt.test filefmt.test pager2.test\n  corrupt5.test corruptA.test pageropt.test\n\n  # Exclude stmt.test, which expects sub-journals to use temporary files.\n  stmt.test symlink.test\n\n  zerodamage.test\n\n  # WAL mode is different.\n  wal* tkt-2d1a5c67d.test backcompat.test e_wal* rowallock.test\n\n  # This test does not work as the \"PRAGMA journal_mode = memory\"\n  # statement switches the database out of wal mode at inopportune\n  # times.\n  snapshot_fault.test\n  \n  # This test assumes a journal file is created on disk.\n  delete_db.test\n  \n  # This test depends on a successful recovery from the pager error \n  # state. Which is not possible with an in-memory journal\n  fts5fault1.test\n}]\n\nifcapable mem3 {\n  test_suite \"memsys3\" -description {\n    Run tests using the allocator in mem3.c.\n  } -files [test_set $::allquicktests -exclude {\n    autovacuum.test           delete3.test              manydb.test\n    bigrow.test               incrblob2.test            memdb.test\n    bitvec.test               index2.test               memsubsys1.test\n    capi3c.test               ioerr.test                memsubsys2.test\n    capi3.test                join3.test                pagesize.test\n    collate5.test             limit.test                backup_ioerr.test\n    backup_malloc.test\n  }] -initialize {\n    catch {db close}\n    sqlite3_reset_auto_extension\n    sqlite3_shutdown\n    sqlite3_config_heap 25000000 0\n    sqlite3_config_lookaside 0 0\n    ifcapable mem5 {\n      # If both memsys3 and memsys5 are enabled in the build, the call to\n      # [sqlite3_config_heap] will initialize the system to use memsys5.\n      # The following overrides this preference and installs the memsys3\n      # allocator.\n      sqlite3_install_memsys3\n    }\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  } -shutdown {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_heap 0 0\n    sqlite3_config_lookaside 100 500\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  }\n}\n\nifcapable mem5 {\n  test_suite \"memsys5\" -description {\n    Run tests using the allocator in mem5.c.\n  } -files [test_set $::allquicktests -exclude {\n    autovacuum.test           delete3.test              manydb.test\n    bigrow.test               incrblob2.test            memdb.test\n    bitvec.test               index2.test               memsubsys1.test\n    capi3c.test               ioerr.test                memsubsys2.test\n    capi3.test                join3.test                pagesize.test\n    collate5.test             limit.test                zeroblob.test\n  }] -initialize {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_heap 25000000 64\n    sqlite3_config_lookaside 0 0\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  } -shutdown {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_heap 0 0\n    sqlite3_config_lookaside 100 500\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  }\n\n  test_suite \"memsys5-2\" -description {\n    Run tests using the allocator in mem5.c in a different configuration.\n  } -files {\n    select1.test \n  } -initialize {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_memstatus 0\n    sqlite3_config_heap 40000000 16\n    sqlite3_config_lookaside 0 0\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  } -shutdown {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_heap 0 0\n    sqlite3_config_lookaside 100 500\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  }\n}\n\nifcapable threadsafe {\n  test_suite \"no_mutex_try\" -description {\n     The sqlite3_mutex_try() interface always fails\n  } -files [\n    test_set $::allquicktests -exclude mutex1.test mutex2.test\n  ] -initialize {\n    catch {db close}\n    sqlite3_shutdown\n    install_mutex_counters 1\n    set ::disable_mutex_try 1\n    sqlite3_initialize\n    autoinstall_test_functions\n  } -shutdown {\n    catch {db close}\n    sqlite3_shutdown\n    install_mutex_counters 0\n    sqlite3_initialize\n    autoinstall_test_functions\n  }\n}\n\n# run_tests \"crash_safe_append\" -description {\n#   Run crash.test with persistent journals on a SAFE_APPEND file-system.\n# } -initialize {\n#   rename crashsql sa_crashsql\n#   proc crashsql {args} {\n#     set options [lrange $args 0 [expr {[llength $args]-2}]]\n#     lappend options -char safe_append\n#     set sql [lindex $args end]\n#     lappend options \"\n#       PRAGMA journal_mode=persistent;\n#       $sql\n#     \"\n#     set fd [open test.db-journal w]\n#     puts $fd [string repeat 1234567890 100000]\n#     close $fd\n#     eval sa_crashsql $options\n#   }\n# } -shutdown {\n#   rename crashsql {}\n#   rename sa_crashsql crashsql\n# } -files crash.test\n\ntest_suite \"safe_append\" -description {\n  Run some tests on a SAFE_APPEND file-system.\n} -initialize {\n  rename sqlite3 sqlite3_safeappend\n  proc sqlite3 {args} {\n    if {[string range [lindex $args 0] 0 0] ne \"-\"} {\n      lappend args -vfs devsym\n    }\n    uplevel [concat sqlite3_safeappend $args]\n  }\n  sqlite3_simulate_device -char safe_append\n} -shutdown {\n  rename sqlite3 {}\n  rename sqlite3_shutdown sqlite3\n} -files [\n  test_set $::allquicktests shared_err.test -exclude async3.test\n]\n\n# The set of tests to run on the alternative-pcache\nset perm-alt-pcache-testset {\n  async.test\n  attach.test\n  delete.test delete2.test\n  index.test\n  insert.test insert2.test\n  join.test join2.test\n  rollback.test\n  select1.test select2.test\n  trans.test\n  update.test\n}\n\nforeach discard_rate {0 10 50 90 100} {\n  test_suite \"pcache${discard_rate}\" -description \"\n    Alternative pcache implementation with ${discard_rate}% random discard\n  \" -initialize \"\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_alt_pcache 1 $discard_rate 1\n    sqlite3_initialize\n    autoinstall_test_functions\n  \" -shutdown {\n    catch {db close}\n    sqlite3_shutdown\n    sqlite3_config_alt_pcache 0 0 0\n    sqlite3_config_lookaside 100 500\n    install_malloc_faultsim 1 \n    sqlite3_initialize\n    autoinstall_test_functions\n  } -files ${perm-alt-pcache-testset}\n}\n\ntest_suite \"journaltest\" -description {\n  Check that pages are synced before being written (test_journal.c).\n} -initialize {\n  catch {db close}\n  register_jt_vfs -default \"\"\n} -shutdown {\n  unregister_jt_vfs\n} -files [test_set $::allquicktests -exclude {\n  wal* incrvacuum.test ioerr.test corrupt4.test io.test crash8.test \n  async4.test bigfile.test backcompat.test e_wal* fstat.test mmap2.test\n  pager1.test syscall.test tkt3457.test *malloc* mmap* multiplex* nolock*\n  pager2.test *fault* rowal* snapshot* superlock* symlink.test\n  delete_db.test\n}]\n\nif {[info commands register_demovfs] != \"\"} {\n  test_suite \"demovfs\" -description {\n    Check that the demovfs (code in test_demovfs.c) more or less works.\n  } -initialize {\n    register_demovfs\n  } -shutdown {\n    unregister_demovfs\n  } -files {\n    insert.test   insert2.test  insert3.test rollback.test \n    select1.test  select2.test  select3.test\n  }\n}\n\ntest_suite \"wal\" -description {\n  Run tests with journal_mode=WAL\n} -initialize {\n  set ::G(savepoint6_iterations) 100\n} -shutdown {\n  unset -nocomplain ::G(savepoint6_iterations)\n} -files {\n  savepoint.test     savepoint2.test     savepoint6.test\n  trans.test         avtrans.test\n\n  fts3aa.test  fts3ab.test  fts3ac.test  fts3ad.test\n  fts3ae.test  fts3af.test  fts3ag.test  fts3ah.test\n  fts3ai.test  fts3aj.test  fts3ak.test  fts3al.test\n  fts3am.test  fts3an.test  fts3ao.test  fts3b.test\n  fts3c.test   fts3d.test   fts3e.test   fts3query.test \n}\n\ntest_suite \"rtree\" -description {\n  All R-tree related tests. Provides coverage of source file rtree.c.\n} -files [glob -nocomplain $::testdir/../ext/rtree/*.test]\n\ntest_suite \"session\" -description {\n  All session module related tests. \n} -files [glob -nocomplain $::testdir/../ext/session/*.test]\n\ntest_suite \"session_eec\" -description {\n  All session module related tests with sqlite3_extended_result_codes() set. \n} -files [\n  glob -nocomplain $::testdir/../ext/session/*.test\n] -dbconfig {\n  sqlite3_extended_result_codes $::dbhandle 1\n}\n\ntest_suite \"session_strm\" -description {\n  All session module related tests using the streaming APIs.\n} -files [\n  glob -nocomplain $::testdir/../ext/session/*.test\n] -dbconfig {\n  set ::sqlite3session_streams 1\n}\n\ntest_suite \"rbu\" -description {\n  RBU tests.\n} -files [\n  test_set [glob -nocomplain $::testdir/../ext/rbu/*.test] -exclude rbu.test\n]\n\ntest_suite \"no_optimization\" -description {\n  Run test scripts with optimizations disabled using the\n  sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS) interface.\n} -files {\n  where.test where2.test where3.test where4.test where5.test\n  where6.test where7.test where8.test where9.test\n  whereA.test whereB.test wherelimit.test\n  select1.test select2.test select3.test select4.test select5.test\n  select7.test select8.test selectA.test selectC.test\n} -dbconfig {\n  optimization_control $::dbhandle all 0\n}\n\ntest_suite \"prepare\" -description {\n  Run tests with the db connection using sqlite3_prepare() instead of _v2().\n} -dbconfig {\n  $::dbhandle version -use-legacy-prepare 1\n  #$::dbhandle cache size 0\n} -files [\n  test_set $allquicktests -exclude *malloc* *ioerr* *fault* \\\n      stmtvtab1.test index9.test\n]\n\n# End of tests\n#############################################################################\n\n# run_tests NAME OPTIONS\n#\n# where available options are:  \n#\n#       -description TITLE\n#       -initialize  SCRIPT\n#       -shutdown    SCRIPT\n#       -presql      SQL\n#       -files       LIST-OF-FILES\n#       -prefix      NAME\n#\nproc run_tests {name args} {\n  array set options $args\n\n  set ::G(perm:name)         $name\n  set ::G(perm:prefix)       $options(-prefix)\n  set ::G(perm:presql)       $options(-presql)\n  set ::G(isquick)           1\n  set ::G(perm:dbconfig)     $options(-dbconfig)\n\n  foreach file [lsort $options(-files)] {\n    uplevel $options(-initialize)\n    if {[file tail $file] == $file} { set file [file join $::testdir $file] }\n    slave_test_file $file\n    uplevel $options(-shutdown)\n  }\n\n  unset ::G(perm:name)\n  unset ::G(perm:prefix)\n  unset ::G(perm:presql)\n  unset ::G(perm:dbconfig)\n}\n\nproc run_test_suite {name} {\n  if {[info exists ::testspec($name)]==0} {\n    error \"No such test suite: $name\"\n  }\n  uplevel run_tests $name $::testspec($name)\n}\n\nproc help {} {\n  puts \"Usage: $::argv0 TESTSUITE ?TESTFILE?\"\n  puts \"\"\n  puts \"Available test-suites are:\"\n  foreach k $::testsuitelist {\n    if {[info exists ::testspec($k)]==0} {\n      puts \"         ----------------------------------------\"\n      puts \"\"\n    } else {\n      array set o $::testspec($k)\n      puts \"Test suite: \\\"$k\\\"\"\n      set d [string trim $o(-description)]\n      set d [regsub {\\n *} $d \"\\n  \"]\n      puts \"  $d\"\n      puts \"\"\n    }\n  }\n  exit -1\n}\n\nif {[file tail $argv0] == \"permutations.test\"} {\n  proc main {argv} {\n    if {[llength $argv]==0} {\n      help\n    } else {\n      set suite [file tail [lindex $argv 0]]\n      if {[info exists ::testspec($suite)]==0} help\n      set extra \"\"\n      if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }\n      eval run_tests $suite $::testspec($suite) $extra\n    }\n  }\n  main $argv\n  finish_test\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragma.test",
    "content": "# 2002 March 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the PRAGMA command.\n#\n# $Id: pragma.test,v 1.73 2009/01/12 14:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix pragma\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Test organization:\n#\n# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.\n# pragma-2.*: Test synchronous on attached db.\n# pragma-3.*: Test detection of table/index inconsistency by integrity_check.\n# pragma-4.*: Test cache_size and default_cache_size on attached db.\n# pragma-5.*: Test that pragma synchronous may not be used inside of a\n#             transaction.\n# pragma-6.*: Test schema-query pragmas.\n# pragma-7.*: Miscellaneous tests.\n# pragma-8.*: Test user_version and schema_version pragmas.\n# pragma-9.*: Test temp_store and temp_store_directory.\n# pragma-10.*: Test the count_changes pragma in the presence of triggers.\n# pragma-11.*: Test the collation_list pragma.\n# pragma-14.*: Test the page_count pragma.\n# pragma-15.*: Test that the value set using the cache_size pragma is not\n#              reset when the schema is reloaded.\n# pragma-16.*: Test proxy locking\n# pragma-20.*: Test data_store_directory.\n# pragma-22.*: Test that \"PRAGMA [db].integrity_check\" respects the \"db\"\n#              directive - if it is present.\n#\n\nifcapable !pragma {\n  finish_test\n  return\n}\n\n# Capture the output of a pragma in a TEMP table.\n#\nproc capture_pragma {db tabname sql} {\n  $db eval \"DROP TABLE IF EXISTS temp.$tabname\"\n  set once 1\n  $db eval $sql x {\n    if {$once} {\n      set once 0\n      set ins \"INSERT INTO $tabname VALUES\"\n      set crtab \"CREATE TEMP TABLE $tabname \"\n      set sep \"(\"\n      foreach col $x(*) {\n        append ins ${sep}\\$x($col)\n        append crtab ${sep}\\\"$col\\\"\n        set sep ,\n      }\n      append ins )\n      append crtab )\n      $db eval $crtab\n    }\n    $db eval $ins\n  }\n}\n\n# Delete the preexisting database to avoid the special setup\n# that the \"all.test\" script does.\n#\ndb close\ndelete_file test.db test.db-journal\ndelete_file test3.db test3.db-journal\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\n\n# EVIDENCE-OF: R-13861-56665 PRAGMA schema.cache_size; PRAGMA\n# schema.cache_size = pages; PRAGMA schema.cache_size = -kibibytes;\n# Query or change the suggested maximum number of database disk pages\n# that SQLite will hold in memory at once per open database file.\n#\nifcapable pager_pragmas {\nset DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}]\nset TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}]\ndo_test pragma-1.1 {\n  execsql {\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]\ndo_test pragma-1.2 {\n  # EVIDENCE-OF: R-42059-47211 If the argument N is positive then the\n  # suggested cache size is set to N.\n  execsql {\n    PRAGMA synchronous=OFF;\n    PRAGMA cache_size=1234;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list 1234 $DFLT_CACHE_SZ 0]\ndo_test pragma-1.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]\ndo_test pragma-1.4 {\n  execsql {\n    PRAGMA synchronous=OFF;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0]\ndo_test pragma-1.5 {\n  execsql {\n    PRAGMA cache_size=-4321;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list -4321 $DFLT_CACHE_SZ 0]\ndo_test pragma-1.6 {\n  execsql {\n    PRAGMA synchronous=ON;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list -4321 $DFLT_CACHE_SZ 1]\ndo_test pragma-1.7 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2]\ndo_test pragma-1.8 {\n  execsql {\n    PRAGMA default_cache_size=-123;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 2}\ndo_test pragma-1.9.1 {\n  db close\n  sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 2}\nifcapable vacuum {\n  do_test pragma-1.9.2 {\n    execsql {\n      VACUUM;\n      PRAGMA cache_size;\n      PRAGMA default_cache_size;\n      PRAGMA synchronous;\n    }\n  } {123 123 2}\n}\ndo_test pragma-1.10 {\n  execsql {\n    PRAGMA synchronous=NORMAL;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 1}\ndo_test pragma-1.11.1 {\n  execsql {\n    PRAGMA synchronous=EXTRA;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 3}\ndo_test pragma-1.11.2 {\n  execsql {\n    PRAGMA synchronous=FULL;\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 2}\ndo_test pragma-1.12 {\n  db close\n  sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db]\n  execsql {\n    PRAGMA cache_size;\n    PRAGMA default_cache_size;\n    PRAGMA synchronous;\n  }\n} {123 123 2}\n\n# Make sure the pragma handler understands numeric values in addition\n# to keywords like \"off\" and \"full\".\n#\ndo_test pragma-1.13 {\n  execsql {\n    PRAGMA synchronous=0;\n    PRAGMA synchronous;\n  }\n} {0}\ndo_test pragma-1.14 {\n  execsql {\n    PRAGMA synchronous=2;\n    PRAGMA synchronous;\n  }\n} {2}\ndo_test pragma-1.14.1 {\n  execsql {\n    PRAGMA synchronous=4;\n    PRAGMA synchronous;\n  }\n} {4}\ndo_test pragma-1.14.2 {\n  execsql {\n    PRAGMA synchronous=3;\n    PRAGMA synchronous;\n  }\n} {3}\ndo_test pragma-1.14.3 {\n  execsql {\n    PRAGMA synchronous=8;\n    PRAGMA synchronous;\n  }\n} {0}\ndo_test pragma-1.14.4 {\n  execsql {\n    PRAGMA synchronous=10;\n    PRAGMA synchronous;\n  }\n} {2}\n} ;# ifcapable pager_pragmas\n\n# Test turning \"flag\" pragmas on and off.\n#\nifcapable debug {\n  # Pragma \"vdbe_listing\" is only available if compiled with SQLITE_DEBUG\n  #\n  do_test pragma-1.15 {\n    execsql {\n      PRAGMA vdbe_listing=YES;\n      PRAGMA vdbe_listing;\n    }\n  } {1}\n  do_test pragma-1.16 {\n    execsql {\n      PRAGMA vdbe_listing=NO;\n      PRAGMA vdbe_listing;\n    }\n  } {0}\n}\n\ndo_test pragma-1.17 {\n  execsql {\n    PRAGMA parser_trace=ON;\n    PRAGMA parser_trace=OFF;\n  }\n} {}\ndo_test pragma-1.18 {\n  execsql {\n    PRAGMA bogus = -1234;  -- Parsing of negative values\n  }\n} {}\n\n# Test modifying the safety_level of an attached database.\nifcapable pager_pragmas&&attach {\n  do_test pragma-2.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' AS aux;\n    } \n  } {}\n  do_test pragma-2.2 {\n    execsql {\n      pragma aux.synchronous;\n    } \n  } {2}\n  do_test pragma-2.3 {\n    execsql {\n      pragma aux.synchronous = OFF;\n      pragma aux.synchronous;\n      pragma synchronous;\n    } \n  } {0 2}\n  do_test pragma-2.4 {\n    execsql {\n      pragma aux.synchronous = ON;\n      pragma synchronous;\n      pragma aux.synchronous;\n    } \n  } {2 1}\n} ;# ifcapable pager_pragmas\n\n# Construct a corrupted index and make sure the integrity_check\n# pragma finds it.\n#\n# These tests won't work if the database is encrypted\n#\ndo_test pragma-3.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    BEGIN;\n    CREATE TABLE t2(a,b,c);\n    CREATE INDEX i2 ON t2(a);\n    INSERT INTO t2 VALUES(11,2,3);\n    INSERT INTO t2 VALUES(22,3,4);\n    COMMIT;\n    SELECT rowid, * from t2;\n  }\n} {1 11 2 3 2 22 3 4}\nifcapable attach {\n  if {![sqlite3 -has-codec] && $sqlite_options(integrityck)} {\n    do_test pragma-3.2 {\n      db eval {SELECT rootpage FROM sqlite_master WHERE name='i2'} break\n      set pgsz [db eval {PRAGMA page_size}]\n      # overwrite the header on the rootpage of the index in order to\n      # make the index appear to be empty.\n      #\n      set offset [expr {$pgsz*($rootpage-1)}]\n      hexio_write test.db $offset 0a00000000040000000000\n      db close\n      sqlite3 db test.db\n      execsql {PRAGMA integrity_check}\n    } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n    do_test pragma-3.3 {\n      execsql {PRAGMA integrity_check=1}\n    } {{row 1 missing from index i2}}\n    do_test pragma-3.4 {\n      execsql {\n        ATTACH DATABASE 'test.db' AS t2;\n        PRAGMA integrity_check\n      }\n    } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n    do_test pragma-3.5 {\n      execsql {\n        PRAGMA integrity_check=4\n      }\n    } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2}}\n    do_test pragma-3.6 {\n      execsql {\n        PRAGMA integrity_check=xyz\n      }\n    } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n    do_test pragma-3.7 {\n      execsql {\n        PRAGMA integrity_check=0\n      }\n    } {{row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n  \n    # Add additional corruption by appending unused pages to the end of\n    # the database file testerr.db\n    #\n    do_test pragma-3.8 {\n      execsql {DETACH t2}\n      forcedelete testerr.db testerr.db-journal\n      set out [open testerr.db w]\n      fconfigure $out -translation binary\n      set in [open test.db r]\n      fconfigure $in -translation binary\n      puts -nonewline $out [read $in]\n      seek $in 0\n      puts -nonewline $out [read $in]\n      close $in\n      close $out\n      hexio_write testerr.db 28 00000000\n      execsql {REINDEX t2}\n      execsql {PRAGMA integrity_check}\n    } {ok}\n    do_test pragma-3.8.1 {\n      execsql {PRAGMA quick_check}\n    } {ok}\n    do_test pragma-3.8.2 {\n      execsql {PRAGMA QUICK_CHECK}\n    } {ok}\n    do_test pragma-3.9 {\n      execsql {\n        ATTACH 'testerr.db' AS t2;\n        PRAGMA integrity_check\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n    do_test pragma-3.10 {\n      execsql {\n        PRAGMA integrity_check=1\n      }\n    } {{*** in database t2 ***\nPage 4 is never used}}\n    do_test pragma-3.11 {\n      execsql {\n        PRAGMA integrity_check=5\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2}}\n    do_test pragma-3.12 {\n      execsql {\n        PRAGMA integrity_check=4\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2}}\n    do_test pragma-3.13 {\n      execsql {\n        PRAGMA integrity_check=3\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used}}\n    do_test pragma-3.14 {\n      execsql {\n        PRAGMA integrity_check(2)\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used}}\n    do_test pragma-3.15 {\n      execsql {\n        ATTACH 'testerr.db' AS t3;\n        PRAGMA integrity_check\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2}}\n    do_test pragma-3.16 {\n      execsql {\n        PRAGMA integrity_check(10)\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2}}\n    do_test pragma-3.17 {\n      execsql {\n        PRAGMA integrity_check=8\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2} {row 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 ***\nPage 4 is never used\nPage 5 is never used}}\n    do_test pragma-3.18 {\n      execsql {\n        PRAGMA integrity_check=4\n      }\n    } {{*** in database t2 ***\nPage 4 is never used\nPage 5 is never used\nPage 6 is never used} {row 1 missing from index i2}}\n  }\n  do_test pragma-3.19 {\n    catch {db close}\n    forcedelete test.db test.db-journal\n    sqlite3 db test.db\n    db eval {PRAGMA integrity_check}\n  } {ok}\n}\n\n# Verify that PRAGMA integrity_check catches UNIQUE and NOT NULL\n# constraint violations.\n#\ndo_execsql_test pragma-3.20 {\n  CREATE TABLE t1(a,b);\n  CREATE INDEX t1a ON t1(a);\n  INSERT INTO t1 VALUES(1,1),(2,2),(3,3),(2,4),(NULL,5),(NULL,6);\n  PRAGMA writable_schema=ON;\n  UPDATE sqlite_master SET sql='CREATE UNIQUE INDEX t1a ON t1(a)'\n   WHERE name='t1a';\n  UPDATE sqlite_master SET sql='CREATE TABLE t1(a NOT NULL,b)'\n   WHERE name='t1';\n  PRAGMA writable_schema=OFF;\n  ALTER TABLE t1 RENAME TO t1x;\n  PRAGMA integrity_check;\n} {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a} {NULL value in t1x.a}}\ndo_execsql_test pragma-3.21 {\n  PRAGMA integrity_check(3);\n} {{non-unique entry in index t1a} {NULL value in t1x.a} {non-unique entry in index t1a}}\ndo_execsql_test pragma-3.22 {\n  PRAGMA integrity_check(2);\n} {{non-unique entry in index t1a} {NULL value in t1x.a}}\ndo_execsql_test pragma-3.23 {\n  PRAGMA integrity_check(1);\n} {{non-unique entry in index t1a}}\n\n# PRAGMA integrity check (or more specifically the sqlite3BtreeCount()\n# interface) used to leave index cursors in an inconsistent state\n# which could result in an assertion fault in sqlite3BtreeKey()\n# called from saveCursorPosition() if content is removed from the\n# index while the integrity_check is still running.  This test verifies\n# that problem has been fixed.\n#\ndo_test pragma-3.30 {\n  db close\n  delete_file test.db\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(a,b,c);\n    WITH RECURSIVE\n      c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)\n    INSERT INTO t1(a,b,c) SELECT i, printf('xyz%08x',i), 2000-i FROM c;\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1bc ON t1(b,c);\n  }\n  db eval {PRAGMA integrity_check} {\n     db eval {DELETE FROM t1}\n  }\n} {}\n\n# Test modifying the cache_size of an attached database.\nifcapable pager_pragmas&&attach {\ndo_test pragma-4.1 {\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    pragma aux.cache_size;\n    pragma aux.default_cache_size;\n  } \n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]\ndo_test pragma-4.2 {\n  execsql {\n    pragma aux.cache_size = 50;\n    pragma aux.cache_size;\n    pragma aux.default_cache_size;\n  } \n} [list 50 $DFLT_CACHE_SZ]\ndo_test pragma-4.3 {\n  execsql {\n    pragma aux.default_cache_size = 456;\n    pragma aux.cache_size;\n    pragma aux.default_cache_size;\n  } \n} {456 456}\ndo_test pragma-4.4 {\n  execsql {\n    pragma cache_size;\n    pragma default_cache_size;\n  } \n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]\ndo_test pragma-4.5 {\n  execsql {\n    DETACH aux;\n    ATTACH 'test3.db' AS aux;\n    pragma aux.cache_size;\n    pragma aux.default_cache_size;\n  } \n} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ]\ndo_test pragma-4.6 {\n  execsql {\n    DETACH aux;\n    ATTACH 'test2.db' AS aux;\n    pragma aux.cache_size;\n    pragma aux.default_cache_size;\n  } \n} {456 456}\n} ;# ifcapable pager_pragmas\n\n# Test that modifying the sync-level in the middle of a transaction is\n# disallowed.\nifcapable pager_pragmas {\ndo_test pragma-5.0 {\n  execsql {\n    pragma synchronous;\n  } \n} {2}\ndo_test pragma-5.1 {\n  catchsql {\n    BEGIN;\n    pragma synchronous = OFF;\n  } \n} {1 {Safety level may not be changed inside a transaction}}\ndo_test pragma-5.2 {\n  execsql {\n    pragma synchronous;\n  } \n} {2}\ncatchsql {COMMIT;}\n} ;# ifcapable pager_pragmas\n\n# Test schema-query pragmas\n#\nifcapable schema_pragmas {\nifcapable tempdb&&attach {\n  do_test pragma-6.1 {\n    set res {}\n    execsql {SELECT * FROM sqlite_temp_master}\n    foreach {idx name file} [execsql {pragma database_list}] {\n      lappend res $idx $name\n    }\n    set res\n  } {0 main 1 temp 2 aux}\n}\ndo_test pragma-6.2 {\n  execsql {\n    CREATE TABLE t2(a TYPE_X, b [TYPE_Y], c \"TYPE_Z\");\n    pragma table_info(t2)\n  }\n} {0 a TYPE_X 0 {} 0 1 b TYPE_Y 0 {} 0 2 c TYPE_Z 0 {} 0}\ndo_test pragma-6.2.1 {\n  execsql {\n    pragma table_info;\n  }\n} {}\ndb nullvalue <<NULL>>\ndo_test pragma-6.2.2 {\n  execsql {\n    CREATE TABLE t5(\n      a TEXT DEFAULT CURRENT_TIMESTAMP, \n      b DEFAULT (5+3),\n      c TEXT,\n      d INTEGER DEFAULT NULL,\n      e TEXT DEFAULT '',\n      UNIQUE(b,c,d),\n      PRIMARY KEY(e,b,c)\n    );\n    PRAGMA table_info(t5);\n  }\n} {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 2 2 c TEXT 0 <<NULL>> 3 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 1}\ndb nullvalue {}\ndo_test pragma-6.2.3 {\n  execsql {\n    CREATE TABLE t2_3(a,b INTEGER PRIMARY KEY,c);\n    pragma table_info(t2_3)\n  }\n} {0 a {} 0 {} 0 1 b INTEGER 0 {} 1 2 c {} 0 {} 0}\nifcapable {foreignkey} {\n  do_test pragma-6.3.1 {\n    execsql {\n      CREATE TABLE t3(a int references t2(b), b UNIQUE);\n      pragma foreign_key_list(t3);\n    }\n  } {0 0 t2 a b {NO ACTION} {NO ACTION} NONE}\n  do_test pragma-6.3.2 {\n    execsql {\n      pragma foreign_key_list;\n    }\n  } {}\n  do_test pragma-6.3.3 {\n    execsql {\n      pragma foreign_key_list(t3_bogus);\n    }\n  } {}\n  do_test pragma-6.3.4 {\n    execsql {\n      pragma foreign_key_list(t5);\n    }\n  } {}\n  do_test pragma-6.4 {\n    capture_pragma db out {\n      pragma index_list(t3);\n    }\n    db eval {SELECT seq, \"name\", \"unique\" FROM out ORDER BY seq}\n  } {0 sqlite_autoindex_t3_1 1}\n}\nifcapable {!foreignkey} {\n  execsql {CREATE TABLE t3(a,b UNIQUE)}\n}\ndo_test pragma-6.5.1 {\n  execsql {\n    CREATE INDEX t3i1 ON t3(a,b);\n  }\n  capture_pragma db out {\n    pragma index_info(t3i1);\n  }\n  db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}\n} {0 0 a 1 1 b}\n\n# EVIDENCE-OF: R-23114-21695 The auxiliary index-columns are not shown\n# by the index_info pragma, but they are listed by the index_xinfo\n# pragma.\n#\ndo_test pragma-6.5.1b {\n  capture_pragma db out {PRAGMA index_xinfo(t3i1)}\n  db eval {SELECT seqno, cid, name FROM out ORDER BY seqno}\n} {0 0 a 1 1 b 2 -1 {}}\n\n\n# EVIDENCE-OF: R-29448-60346 PRAGMA schema.index_info(index-name); This\n# pragma returns one row for each key column in the named index.\n#\n# (The first column of output from PRAGMA index_info is...)\n# EVIDENCE-OF: R-34186-52914 The rank of the column within the index. (0\n# means left-most.)\n#\n# (The second column of output from PRAGMA index_info is...)\n# EVIDENCE-OF: R-65019-08383 The rank of the column within the table\n# being indexed.\n#\n# (The third column of output from PRAGMA index_info is...)\n# EVIDENCE-OF: R-09773-34266 The name of the column being indexed.\n#\ndo_execsql_test pragma-6.5.1c {\n  CREATE INDEX t3i2 ON t3(b,a);\n  PRAGMA index_info='t3i2';\n  DROP INDEX t3i2;\n} {0 1 b 1 0 a}\n\ndo_test pragma-6.5.2 {\n  execsql {\n    pragma index_info(t3i1_bogus);\n  }\n} {}\n\nifcapable tempdb {\n  # Test for ticket #3320. When a temp table of the same name exists, make\n  # sure the schema of the main table can still be queried using \n  # \"pragma table_info\":\n  do_test pragma-6.6.1 {\n    execsql {\n      CREATE TABLE trial(col_main);\n      CREATE TEMP TABLE trial(col_temp);\n    }\n  } {}\n  do_test pragma-6.6.2 {\n    execsql {\n      PRAGMA table_info(trial);\n    }\n  } {0 col_temp {} 0 {} 0}\n  do_test pragma-6.6.3 {\n    execsql {\n      PRAGMA temp.table_info(trial);\n    }\n  } {0 col_temp {} 0 {} 0}\n  do_test pragma-6.6.4 {\n    execsql {\n      PRAGMA main.table_info(trial);\n    }\n  } {0 col_main {} 0 {} 0}\n}\n\ndo_test pragma-6.7 {\n  execsql {\n    CREATE TABLE test_table(\n      one INT NOT NULL DEFAULT -1, \n      two text,\n      three VARCHAR(45, 65) DEFAULT 'abcde',\n      four REAL DEFAULT X'abcdef',\n      five DEFAULT CURRENT_TIME\n    );\n  }\n  capture_pragma db out {PRAGMA table_info(test_table)}\n  db eval {SELECT cid, \"name\", type, \"notnull\", dflt_value, pk FROM out\n            ORDER BY cid}\n} [concat \\\n  {0 one INT 1 -1 0} \\\n  {1 two text 0 {} 0} \\\n  {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \\\n  {3 four REAL 0 X'abcdef' 0} \\\n  {4 five {} 0 CURRENT_TIME 0} \\\n]\ndo_test pragma-6.8 {\n  execsql {\n    CREATE TABLE t68(a,b,c,PRIMARY KEY(a,b,a,c));\n    PRAGMA table_info(t68);\n  }\n} [concat \\\n  {0 a {} 0 {} 1} \\\n  {1 b {} 0 {} 2} \\\n  {2 c {} 0 {} 4} \\\n]\n} ;# ifcapable schema_pragmas\n# Miscellaneous tests\n#\nifcapable schema_pragmas {\n# EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This\n# pragma returns one row for each index associated with the given table.\n#\ndo_test pragma-7.1.1 {\n  # Make sure a pragma knows to read the schema if it needs to\n  db close\n  sqlite3 db test.db\n  capture_pragma db out \"PRAGMA index_list(t3)\"\n  db eval {SELECT name, \"origin\" FROM out ORDER BY name DESC}\n} {t3i1 c sqlite_autoindex_t3_1 u}\ndo_test pragma-7.1.2 {\n  execsql {\n    pragma index_list(t3_bogus);\n  }\n} {}\n} ;# ifcapable schema_pragmas\nifcapable {utf16} {\n  if {[permutation] == \"\"} {\n    do_test pragma-7.2 {\n      db close\n      sqlite3 db test.db\n      catchsql {\n        pragma encoding=bogus;\n      }\n    } {1 {unsupported encoding: bogus}}\n  }\n}\nifcapable tempdb {\n  do_test pragma-7.3 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      pragma lock_status;\n    }\n  } {main unlocked temp closed}\n} else {\n  do_test pragma-7.3 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      pragma lock_status;\n    }\n  } {main unlocked}\n}\n\n\n#----------------------------------------------------------------------\n# Test cases pragma-8.* test the \"PRAGMA schema_version\" and \"PRAGMA\n# user_version\" statements.\n#\n# pragma-8.1: PRAGMA schema_version\n# pragma-8.2: PRAGMA user_version\n#\n\nifcapable schema_version {\n\n# First check that we can set the schema version and then retrieve the\n# same value.\ndo_test pragma-8.1.1 {\n  execsql {\n    PRAGMA schema_version = 105;\n  }\n} {}\ndo_test pragma-8.1.2 {\n  execsql2 {\n    PRAGMA schema_version;\n  }\n} {schema_version 105}\ndo_test pragma-8.1.3 {\n  execsql {\n    PRAGMA schema_version = 106;\n  }\n} {}\ndo_test pragma-8.1.4 {\n  execsql {\n    PRAGMA schema_version;\n  }\n} 106\n\n# Check that creating a table modifies the schema-version (this is really\n# to verify that the value being read is in fact the schema version).\ndo_test pragma-8.1.5 {\n  execsql {\n    CREATE TABLE t4(a, b, c);\n    INSERT INTO t4 VALUES(1, 2, 3);\n    SELECT * FROM t4;\n  }\n} {1 2 3}\ndo_test pragma-8.1.6 {\n  execsql {\n    PRAGMA schema_version;\n  }\n} 107\n\n# Now open a second connection to the database. Ensure that changing the\n# schema-version using the first connection forces the second connection\n# to reload the schema. This has to be done using the C-API test functions,\n# because the TCL API accounts for SCHEMA_ERROR and retries the query.\ndo_test pragma-8.1.7 {\n  sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]\n  execsql {\n    SELECT * FROM t4;\n  } db2\n} {1 2 3}\ndo_test pragma-8.1.8 {\n  execsql {\n    PRAGMA schema_version = 108;\n  }\n} {}\ndo_test pragma-8.1.9 {\n  set ::STMT [sqlite3_prepare $::DB2 \"SELECT * FROM t4\" -1 DUMMY]\n  sqlite3_step $::STMT\n} SQLITE_ERROR\ndo_test pragma-8.1.10 {\n  sqlite3_finalize $::STMT\n} SQLITE_SCHEMA\n\n# Make sure the schema-version can be manipulated in an attached database.\nforcedelete test2.db\nforcedelete test2.db-journal\nifcapable attach {\n  do_test pragma-8.1.11 {\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      CREATE TABLE aux.t1(a, b, c);\n      PRAGMA aux.schema_version = 205;\n    }\n  } {}\n  do_test pragma-8.1.12 {\n    execsql {\n      PRAGMA aux.schema_version;\n    }\n  } 205\n}\ndo_test pragma-8.1.13 {\n  execsql {\n    PRAGMA schema_version;\n  }\n} 108\n\n# And check that modifying the schema-version in an attached database\n# forces the second connection to reload the schema.\nifcapable attach {\n  do_test pragma-8.1.14 {\n    sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2]\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      SELECT * FROM aux.t1;\n    } db2\n  } {}\n  do_test pragma-8.1.15 {\n    execsql {\n      PRAGMA aux.schema_version = 206;\n    }\n  } {}\n  do_test pragma-8.1.16 {\n    set ::STMT [sqlite3_prepare $::DB2 \"SELECT * FROM aux.t1\" -1 DUMMY]\n    sqlite3_step $::STMT\n  } SQLITE_ERROR\n  do_test pragma-8.1.17 {\n    sqlite3_finalize $::STMT\n  } SQLITE_SCHEMA\n  do_test pragma-8.1.18 {\n    db2 close\n  } {}\n}\n\n# Now test that the user-version can be read and written (and that we aren't\n# accidentally manipulating the schema-version instead).\ndo_test pragma-8.2.1 {\n  execsql2 {\n    PRAGMA user_version;\n  }\n} {user_version 0}\ndo_test pragma-8.2.2 {\n  execsql {\n    PRAGMA user_version = 2;\n  }\n} {}\ndo_test pragma-8.2.3.1 {\n  execsql2 {\n    PRAGMA user_version;\n  }\n} {user_version 2}\ndo_test pragma-8.2.3.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA user_version;\n  }\n} {2}\ndo_test pragma-8.2.4.1 {\n  execsql {\n    PRAGMA schema_version;\n  }\n} {108}\nifcapable vacuum {\n  do_test pragma-8.2.4.2 {\n    execsql {\n      VACUUM;\n      PRAGMA user_version;\n    }\n  } {2}\n  do_test pragma-8.2.4.3 {\n    execsql {\n      PRAGMA schema_version;\n    }\n  } {109}\n}\n\nifcapable attach {\n  db eval {ATTACH 'test2.db' AS aux}\n  \n  # Check that the user-version in the auxilary database can be manipulated (\n  # and that we aren't accidentally manipulating the same in the main db).\n  do_test pragma-8.2.5 {\n    execsql {\n      PRAGMA aux.user_version;\n    }\n  } {0}\n  do_test pragma-8.2.6 {\n    execsql {\n      PRAGMA aux.user_version = 3;\n    }\n  } {}\n  do_test pragma-8.2.7 {\n    execsql {\n      PRAGMA aux.user_version;\n    }\n  } {3}\n  do_test pragma-8.2.8 {\n    execsql {\n      PRAGMA main.user_version;\n    }\n  } {2}\n  \n  # Now check that a ROLLBACK resets the user-version if it has been modified\n  # within a transaction.\n  do_test pragma-8.2.9 {\n    execsql {\n      BEGIN;\n      PRAGMA aux.user_version = 10;\n      PRAGMA user_version = 11;\n    }\n  } {}\n  do_test pragma-8.2.10 {\n    execsql {\n      PRAGMA aux.user_version;\n    }\n  } {10}\n  do_test pragma-8.2.11 {\n    execsql {\n      PRAGMA main.user_version;\n    }\n  } {11}\n  do_test pragma-8.2.12 {\n    execsql {\n      ROLLBACK;\n      PRAGMA aux.user_version;\n    }\n  } {3}\n  do_test pragma-8.2.13 {\n    execsql {\n      PRAGMA main.user_version;\n    }\n  } {2}\n}\n\n# Try a negative value for the user-version\ndo_test pragma-8.2.14 {\n  execsql {\n    PRAGMA user_version = -450;\n  }\n} {}\ndo_test pragma-8.2.15 {\n  execsql {\n    PRAGMA user_version;\n  }\n} {-450}\n} ; # ifcapable schema_version\n\n# Check to see if TEMP_STORE is memory or disk.  Return strings\n# \"memory\" or \"disk\" as appropriate.\n#\nproc check_temp_store {} {\n  db eval {\n    PRAGMA temp.cache_size = 1;\n    CREATE TEMP TABLE IF NOT EXISTS a(b);\n    DELETE FROM a;\n    INSERT INTO a VALUES(randomblob(1000));\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n    INSERT INTO a SELECT * FROM a;\n  }\n  db eval {PRAGMA database_list} {\n    if {$name==\"temp\"} {\n      set bt [btree_from_db db 1]\n      if {[btree_ismemdb $bt]} {\n        return \"memory\"\n      }\n      return \"disk\"\n    }\n  }\n  return \"unknown\"\n}\n\n# Application_ID\n#\ndo_test pragma-8.3.1 {\n  execsql {\n    PRAGMA application_id;\n  }\n} {0}\ndo_test pragma-8.3.2 {\n  execsql {PRAGMA Application_ID(12345); PRAGMA application_id;}\n} {12345}\n\n# Test temp_store and temp_store_directory pragmas\n#\nifcapable pager_pragmas {\ndo_test pragma-9.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA temp_store;\n  }\n} {0}\nif {$TEMP_STORE<=1} {\n  do_test pragma-9.1.1 {\n    check_temp_store\n  } {disk}\n} else {\n  do_test pragma-9.1.1 {\n    check_temp_store\n  } {memory}\n}\n\ndo_test pragma-9.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA temp_store=file;\n    PRAGMA temp_store;\n  }\n} {1}\nif {$TEMP_STORE==3} {\n  # When TEMP_STORE is 3, always use memory regardless of pragma settings.\n  do_test pragma-9.2.1 {\n    check_temp_store\n  } {memory}\n} else {\n  do_test pragma-9.2.1 {\n    check_temp_store\n  } {disk}\n}\n\ndo_test pragma-9.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA temp_store=memory;\n    PRAGMA temp_store;\n  }\n} {2}\nif {$TEMP_STORE==0} {\n  # When TEMP_STORE is 0, always use the disk regardless of pragma settings.\n  do_test pragma-9.3.1 {\n    check_temp_store\n  } {disk}\n} else {\n  do_test pragma-9.3.1 {\n    check_temp_store\n  } {memory}\n}\n\ndo_test pragma-9.4 {\n  execsql {\n    PRAGMA temp_store_directory;\n  }\n} {}\nifcapable wsd {\n  do_test pragma-9.5 {\n    set pwd [string map {' ''} [file nativename [get_pwd]]]\n    execsql \"\n      PRAGMA temp_store_directory='$pwd';\n    \"\n  } {}\n  do_test pragma-9.6 {\n    execsql { \n      PRAGMA temp_store_directory;\n    }\n  } [list [file nativename [get_pwd]]]\n  do_test pragma-9.7 {\n    catchsql { \n      PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR';\n    }\n  } {1 {not a writable directory}}\n  do_test pragma-9.8 {\n    execsql { \n      PRAGMA temp_store_directory='';\n    }\n  } {}\n  if {![info exists TEMP_STORE] || $TEMP_STORE<=1} {\n    ifcapable tempdb {\n      do_test pragma-9.9 {\n        execsql { \n          PRAGMA temp_store_directory;\n          PRAGMA temp_store=FILE;\n          CREATE TEMP TABLE temp_store_directory_test(a integer);\n          INSERT INTO temp_store_directory_test values (2);\n          SELECT * FROM temp_store_directory_test;\n        }\n      } {2}\n      do_test pragma-9.10 {\n        catchsql \"\n          PRAGMA temp_store_directory='$pwd';\n          SELECT * FROM temp_store_directory_test;\n        \"\n      } {1 {no such table: temp_store_directory_test}}\n    }\n  }\n}\ndo_test pragma-9.11 {\n  execsql {\n    PRAGMA temp_store = 0;\n    PRAGMA temp_store;\n  }\n} {0}\ndo_test pragma-9.12 {\n  execsql {\n    PRAGMA temp_store = 1;\n    PRAGMA temp_store;\n  }\n} {1}\ndo_test pragma-9.13 {\n  execsql {\n    PRAGMA temp_store = 2;\n    PRAGMA temp_store;\n  }\n} {2}\ndo_test pragma-9.14 {\n  execsql {\n    PRAGMA temp_store = 3;\n    PRAGMA temp_store;\n  }\n} {0}\ndo_test pragma-9.15 {\n  catchsql {\n    BEGIN EXCLUSIVE;\n    CREATE TEMP TABLE temp_table(t);\n    INSERT INTO temp_table VALUES('valuable data');\n    PRAGMA temp_store = 1;\n  }\n} {1 {temporary storage cannot be changed from within a transaction}}\ndo_test pragma-9.16 {\n  execsql {\n    SELECT * FROM temp_table;\n    COMMIT;\n  }\n} {{valuable data}}\n\ndo_test pragma-9.17 {\n  execsql {\n    INSERT INTO temp_table VALUES('valuable data II');\n    SELECT * FROM temp_table;\n  }\n} {{valuable data} {valuable data II}}\n\ndo_test pragma-9.18 {\n  set rc [catch {\n    db eval {SELECT t FROM temp_table} {\n      execsql {pragma temp_store = 1}\n    }\n  } msg]\n  list $rc $msg\n} {1 {temporary storage cannot be changed from within a transaction}}\n\n} ;# ifcapable pager_pragmas\n\nifcapable trigger {\n\ndo_test pragma-10.0 {\n  catchsql {\n    DROP TABLE main.t1;\n  }\n  execsql {\n    PRAGMA count_changes = 1;\n\n    CREATE TABLE t1(a PRIMARY KEY);\n    CREATE TABLE t1_mirror(a);\n    CREATE TABLE t1_mirror2(a);\n    CREATE TRIGGER t1_bi BEFORE INSERT ON t1 BEGIN \n      INSERT INTO t1_mirror VALUES(new.a);\n    END;\n    CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN \n      INSERT INTO t1_mirror2 VALUES(new.a);\n    END;\n    CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN \n      UPDATE t1_mirror SET a = new.a WHERE a = old.a;\n    END;\n    CREATE TRIGGER t1_au AFTER UPDATE ON t1 BEGIN \n      UPDATE t1_mirror2 SET a = new.a WHERE a = old.a;\n    END;\n    CREATE TRIGGER t1_bd BEFORE DELETE ON t1 BEGIN \n      DELETE FROM t1_mirror WHERE a = old.a;\n    END;\n    CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN \n      DELETE FROM t1_mirror2 WHERE a = old.a;\n    END;\n  }\n} {}\n\ndo_test pragma-10.1 {\n  execsql {\n    INSERT INTO t1 VALUES(randstr(10,10));\n  }\n} {1}\ndo_test pragma-10.2 {\n  execsql {\n    UPDATE t1 SET a = randstr(10,10);\n  }\n} {1}\ndo_test pragma-10.3 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {1}\n\n} ;# ifcapable trigger\n\nifcapable schema_pragmas {\n  do_test pragma-11.1 {\n    execsql2 {\n      pragma collation_list;\n    }\n  } {seq 0 name RTRIM seq 1 name NOCASE seq 2 name BINARY}\n  do_test pragma-11.2 {\n    db collate New_Collation blah...\n    execsql {\n      pragma collation_list;\n    }\n  } {0 New_Collation 1 RTRIM 2 NOCASE 3 BINARY}\n}\n\nifcapable schema_pragmas&&tempdb {\n  do_test pragma-12.1 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA temp.table_info('abc');\n    } db2\n  } {}\n  db2 close\n\n  do_test pragma-12.2 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA temp.default_cache_size = 200;\n      PRAGMA temp.default_cache_size;\n    } db2\n  } {200}\n  db2 close\n\n  do_test pragma-12.3 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA temp.cache_size = 400;\n      PRAGMA temp.cache_size;\n    } db2\n  } {400}\n  db2 close\n}\n\nifcapable bloblit {\n\ndo_test pragma-13.1 {\n  execsql {\n    DROP TABLE IF EXISTS t4;\n    PRAGMA vdbe_trace=on;\n    PRAGMA vdbe_listing=on;\n    PRAGMA sql_trace=on;\n    CREATE TABLE t4(a INTEGER PRIMARY KEY,b);\n    INSERT INTO t4(b) VALUES(x'0123456789abcdef0123456789abcdef0123456789');\n    INSERT INTO t4(b) VALUES(randstr(30,30));\n    INSERT INTO t4(b) VALUES(1.23456);\n    INSERT INTO t4(b) VALUES(NULL);\n    INSERT INTO t4(b) VALUES(0);\n    INSERT INTO t4(b) SELECT b||b||b||b FROM t4;\n    SELECT * FROM t4;\n  }\n  execsql {\n    PRAGMA vdbe_trace=off;\n    PRAGMA vdbe_listing=off;\n    PRAGMA sql_trace=off;\n  }\n} {}\n\n} ;# ifcapable bloblit \n\nifcapable pager_pragmas {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n \n  # EVIDENCE-OF: R-15672-33611 PRAGMA schema.page_count; Return the total\n  # number of pages in the database file.\n  #\n  do_test pragma-14.1 {\n    execsql { pragma auto_vacuum = 0 }\n    execsql { pragma page_count; pragma main.page_count }\n  } {0 0}\n\n  do_test pragma-14.2 {\n    execsql { \n      CREATE TABLE abc(a, b, c);\n      PRAGMA page_count;\n      PRAGMA main.page_count;\n      PRAGMA temp.page_count;\n    }\n  } {2 2 0}\n  do_test pragma-14.2uc {\n    execsql {pragma PAGE_COUNT}\n  } {2}\n\n  do_test pragma-14.3 {\n    execsql { \n      BEGIN;\n      CREATE TABLE def(a, b, c);\n      PRAGMA page_count;\n    }\n  } {3}\n  do_test pragma-14.3uc {\n    execsql {pragma PAGE_COUNT}\n  } {3}\n\n  do_test pragma-14.4 {\n    set page_size [db one {pragma page_size}]\n    expr [file size test.db] / $page_size\n  } {2}\n\n  do_test pragma-14.5 {\n    execsql {\n      ROLLBACK;\n      PRAGMA page_count;\n    }\n  } {2}\n\n  do_test pragma-14.6 {\n    forcedelete test2.db\n    sqlite3 db2 test2.db\n    execsql {\n      PRAGMA auto_vacuum = 0;\n      CREATE TABLE t1(a, b, c);\n      CREATE TABLE t2(a, b, c);\n      CREATE TABLE t3(a, b, c);\n      CREATE TABLE t4(a, b, c);\n    } db2\n    db2 close\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.page_count;\n    } \n  } {5}\n  do_test pragma-14.6uc {\n    execsql {pragma AUX.PAGE_COUNT}\n  } {5}\n}\n\n# Test that the value set using the cache_size pragma is not reset when the\n# schema is reloaded.\n#\nifcapable pager_pragmas {\n  db close\n  sqlite3 db test.db\n  do_test pragma-15.1 {\n    execsql {\n      PRAGMA cache_size=59;\n      PRAGMA cache_size;\n    }\n  } {59}\n  do_test pragma-15.2 {\n    sqlite3 db2 test.db\n    execsql {\n      CREATE TABLE newtable(a, b, c);\n    } db2\n    db2 close\n  } {}\n  do_test pragma-15.3 {\n    # Evaluating this statement will cause the schema to be reloaded (because\n    # the schema was changed by another connection in pragma-15.2). At one\n    # point there was a bug that reset the cache_size to its default value\n    # when this happened. \n    execsql { SELECT * FROM sqlite_master }\n    execsql { PRAGMA cache_size }\n  } {59}\n}\n\n# Reset the sqlite3_temp_directory variable for the next run of tests:\nsqlite3 dbX :memory:\ndbX eval {PRAGMA temp_store_directory = \"\"}\ndbX close\n\nifcapable lock_proxy_pragmas&&prefer_proxy_locking {\n  set sqlite_hostid_num 1\n\n  set using_proxy 0\n  foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n    set using_proxy $value\n  }\n\n  # Test the lock_proxy_file pragmas.\n  #\n  db close\n  set env(SQLITE_FORCE_PROXY_LOCKING) \"0\"\n\n  sqlite3 db test.db\n  do_test pragma-16.1 {\n    execsql {\n      PRAGMA lock_proxy_file=\"mylittleproxy\";\n      select * from sqlite_master;\n    }\n    execsql {\n      PRAGMA lock_proxy_file;\n    } \n  } {mylittleproxy}\n\n  do_test pragma-16.2 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA lock_proxy_file=\"mylittleproxy\";\n    } db2\n  } {}\n\n  db2 close\n  do_test pragma-16.2.1 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA lock_proxy_file=\":auto:\";\n      select * from sqlite_master;\n    } db2\n    execsql {\n      PRAGMA lock_proxy_file;\n    } db2\n  } {mylittleproxy}\n\n  db2 close\n  do_test pragma-16.3 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA lock_proxy_file=\"myotherproxy\";\n    } db2\n    catchsql {\n      select * from sqlite_master;\n    } db2\n  } {1 {database is locked}}\n\n  do_test pragma-16.4 {\n    db2 close\n    db close\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA lock_proxy_file=\"myoriginalproxy\";\n      PRAGMA lock_proxy_file=\"myotherproxy\";\n      PRAGMA lock_proxy_file;\n    } db2\n  } {myotherproxy}\n\n  db2 close\n  set env(SQLITE_FORCE_PROXY_LOCKING) \"1\"\n  do_test pragma-16.5 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA lock_proxy_file=\":auto:\";\n      PRAGMA lock_proxy_file;\n    } db2\n  } {myotherproxy}\n  \n  do_test pragma-16.6 {\n    db2 close\n    sqlite3 db2 test2.db\n    set lockpath [execsql {\n      PRAGMA lock_proxy_file=\":auto:\";\n      PRAGMA lock_proxy_file;\n    } db2]\n    string match \"*test2.db:auto:\" $lockpath\n  } {1}\n  \n  set sqlite_hostid_num 2\n  do_test pragma-16.7 {\n    list [catch {\n      sqlite3 db test2.db\n      execsql { \n        PRAGMA lock_proxy_file=\":auto:\";\n        select * from sqlite_master;\n      }\n    } msg] $msg\n  } {1 {database is locked}}\n  db close\n  \n  do_test pragma-16.8 {\n    list [catch {\n      sqlite3 db test2.db\n      execsql { select * from sqlite_master } \n    } msg] $msg\n  } {1 {database is locked}}\n\n  db2 close\n  do_test pragma-16.8.1 {\n    execsql {\n      PRAGMA lock_proxy_file=\"yetanotherproxy\";\n      PRAGMA lock_proxy_file;\n    } \n  } {yetanotherproxy}\n  do_test pragma-16.8.2 {\n    execsql {\n      create table mine(x);\n    } \n  } {}\n\n  db close\n  do_test pragma-16.9 {\n    sqlite3 db proxytest.db\n    set lockpath2 [execsql {\n      PRAGMA lock_proxy_file=\":auto:\";\n      PRAGMA lock_proxy_file;\n    } db]\n    string match \"*proxytest.db:auto:\" $lockpath2\n  } {1}\n\n  set env(SQLITE_FORCE_PROXY_LOCKING) $using_proxy\n  set sqlite_hostid_num 0\n}\n\n# Parsing of auto_vacuum settings.\n#\nforeach {autovac_setting val} {\n  0 0\n  1 1\n  2 2\n  3 0\n  -1 0\n  none 0\n  NONE 0\n  NoNe 0\n  full 1\n  FULL 1\n  incremental 2\n  INCREMENTAL 2\n  -1234 0\n  1234 0\n} {\n  do_test pragma-17.1.$autovac_setting {\n    catch {db close}\n    sqlite3 db :memory:\n    execsql \"\n      PRAGMA auto_vacuum=$::autovac_setting;\n      PRAGMA auto_vacuum;\n    \"\n  } $val\n}\n\n# Parsing of temp_store settings.\n#\nforeach {temp_setting val} {\n  0 0\n  1 1\n  2 2\n  3 0\n  -1 0\n  file 1\n  FILE 1\n  fIlE 1\n  memory 2\n  MEMORY 2\n  MeMoRy 2\n} {\n  do_test pragma-18.1.$temp_setting {\n    catch {db close}\n    sqlite3 db :memory:\n    execsql \"\n      PRAGMA temp_store=$::temp_setting;\n      PRAGMA temp_store=$::temp_setting;\n      PRAGMA temp_store;\n    \"\n  } $val\n}\n\n# The SQLITE_FCNTL_PRAGMA logic, with error handling.\n#\ndb close\ntestvfs tvfs\nsqlite3 db test.db -vfs tvfs\ndo_test pragma-19.1 {\n  catchsql {PRAGMA error}\n} {1 {SQL logic error}}\ndo_test pragma-19.2 {\n  catchsql {PRAGMA error='This is the error message'}\n} {1 {This is the error message}}\ndo_test pragma-19.3 {\n  catchsql {PRAGMA error='7 This is the error message'}\n} {1 {This is the error message}}\ndo_test pragma-19.4 {\n  catchsql {PRAGMA error=7}\n} {1 {out of memory}}\ndo_test pragma-19.5 {\n  file tail [lindex [execsql {PRAGMA filename}] 0]\n} {test.db}\n\nif {$tcl_platform(platform)==\"windows\"} {\n# Test data_store_directory pragma\n#\ndb close\nsqlite3 db test.db\nfile mkdir data_dir\ndo_test pragma-20.1 {\n  catchsql {PRAGMA data_store_directory}\n} {0 {}}\ndo_test pragma-20.2 {\n  set pwd [string map {' ''} [file nativename [get_pwd]]]\n  catchsql \"PRAGMA data_store_directory='$pwd';\"\n} {0 {}}\ndo_test pragma-20.3 {\n  catchsql {PRAGMA data_store_directory}\n} [list 0 [list [file nativename [get_pwd]]]]\ndo_test pragma-20.4 {\n  set pwd [string map {' ''} [file nativename \\\n    [file join [get_pwd] data_dir]]]\n  catchsql \"PRAGMA data_store_directory='$pwd';\"\n} {0 {}}\ndo_test pragma-20.5 {\n  sqlite3 db2 test2.db\n  catchsql \"PRAGMA database_list;\" db2\n} [list 0 [list 0 main [file nativename \\\n    [file join [get_pwd] data_dir test2.db]]]]\ncatch {db2 close}\ndo_test pragma-20.6 {\n  sqlite3 db2 [file join [get_pwd] test2.db]\n  catchsql \"PRAGMA database_list;\" db2\n} [list 0 [list 0 main [file nativename \\\n    [file join [get_pwd] test2.db]]]]\ncatch {db2 close}\ndo_test pragma-20.7 {\n  catchsql \"PRAGMA data_store_directory='';\"\n} {0 {}}\ndo_test pragma-20.8 {\n  catchsql {PRAGMA data_store_directory}\n} {0 {}}\n\nforcedelete data_dir\n} ;# endif windows\n\ndatabase_may_be_corrupt\nif {![nonzero_reserved_bytes]} {\n\n  do_test 21.1 {\n    # Create a corrupt database in testerr.db. And a non-corrupt at test.db.\n    #\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    execsql { \n      PRAGMA page_size = 1024;\n      PRAGMA auto_vacuum = 0;\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1, 1);\n    }\n    for {set i 0} {$i < 10} {incr i} {\n      execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 }\n    }\n    db close\n    forcecopy test.db testerr.db\n    hexio_write testerr.db 15000 [string repeat 55 100]\n  } {100}\n  \n  set mainerr {*** in database main ***\nMultiple uses for byte 672 of page 15}\n  set auxerr {*** in database aux ***\nMultiple uses for byte 672 of page 15}\n  \n  set mainerr {/{\\*\\*\\* in database main \\*\\*\\*\nMultiple uses for byte 672 of page 15}.*/}\n  set auxerr {/{\\*\\*\\* in database aux \\*\\*\\*\nMultiple uses for byte 672 of page 15}.*/}\n  \n  do_test 22.2 {\n    catch { db close }\n    sqlite3 db testerr.db\n    execsql { PRAGMA integrity_check }\n  } $mainerr\n  \n  do_test 22.3.1 {\n    catch { db close }\n    sqlite3 db test.db\n    execsql { \n      ATTACH 'testerr.db' AS 'aux';\n      PRAGMA integrity_check;\n    }\n  } $auxerr\n  do_test 22.3.2 {\n    execsql { PRAGMA main.integrity_check; }\n  } {ok}\n  do_test 22.3.3 {\n    execsql { PRAGMA aux.integrity_check; }\n  } $auxerr\n  \n  do_test 22.4.1 {\n    catch { db close }\n    sqlite3 db testerr.db\n    execsql { \n      ATTACH 'test.db' AS 'aux';\n      PRAGMA integrity_check;\n    }\n  } $mainerr\n  do_test 22.4.2 {\n    execsql { PRAGMA main.integrity_check; }\n  } $mainerr\n  do_test 22.4.3 {\n    execsql { PRAGMA aux.integrity_check; }\n  } {ok}\n}\n  \ndb close\nforcedelete test.db test.db-wal test.db-journal\nsqlite3 db test.db\nsqlite3 db2 test.db\ndo_test 23.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);\n    CREATE INDEX i1 ON t1(b,c);\n    CREATE INDEX i2 ON t1(c,d);\n    CREATE INDEX i2x ON t1(d COLLATE nocase, c DESC);\n    CREATE TABLE t2(x INTEGER REFERENCES t1);\n  }\n  db2 eval {SELECT name FROM sqlite_master}\n} {t1 i1 i2 i2x t2}\ndo_test 23.2a {\n  db eval {\n    DROP INDEX i2;\n    CREATE INDEX i2 ON t1(c,d,b);\n  }\n  capture_pragma db2 out {PRAGMA index_info(i2)}\n  db2 eval {SELECT cid, name, '|' FROM out ORDER BY seqno}\n} {2 c | 3 d | 1 b |}\n\n# EVIDENCE-OF: R-56143-29319 PRAGMA schema.index_xinfo(index-name); This\n# pragma returns information about every column in an index.\n#\n# EVIDENCE-OF: R-45970-35618 Unlike this index_info pragma, this pragma\n# returns information about every column in the index, not just the key\n# columns.\n#\ndo_test 23.2b {\n  capture_pragma db2 out {PRAGMA index_xinfo(i2)}\n  db2 eval {SELECT cid, name, \"desc\", coll, \"key\", '|' FROM out ORDER BY seqno}\n} {2 c 0 BINARY 1 | 3 d 0 BINARY 1 | 1 b 0 BINARY 1 | -1 {} 0 BINARY 0 |}\n\n# (The first column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-00197-14279 The rank of the column within the index. (0\n# means left-most. Key columns come before auxiliary columns.)\n#\n# (The second column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-40889-06838 The rank of the column within the table\n# being indexed, or -1 if the index-column is the rowid of the table\n# being indexed.\n#\n# (The third column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-22751-28901 The name of the column being indexed, or\n# NULL if the index-column is the rowid of the table being indexed.\n#\n# (The fourth column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-11847-09179 1 if the index-column is sorted in reverse\n# (DESC) order by the index and 0 otherwise.\n#\n# (The fifth column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-15313-19540 The name for the collating sequence used to\n# compare values in the index-column.\n#\n# (The sixth column of output from PRAGMA index_xinfo is...)\n# EVIDENCE-OF: R-14310-64553 1 if the index-column is a key column and 0\n# if the index-column is an auxiliary column.\n#\ndo_test 23.2c {\n  db2 eval {PRAGMA index_xinfo(i2)}\n} {0 2 c 0 BINARY 1 1 3 d 0 BINARY 1 2 1 b 0 BINARY 1 3 -1 {} 0 BINARY 0}\ndo_test 23.2d {\n  db2 eval {PRAGMA index_xinfo(i2x)}\n} {0 3 d 0 nocase 1 1 2 c 1 BINARY 1 2 -1 {} 0 BINARY 0}\n\n# EVIDENCE-OF: R-64103-17776 PRAGMA schema.index_list(table-name); This\n# pragma returns one row for each index associated with the given table.\n#\n# (The first column of output from PRAGMA index_list is...)\n# EVIDENCE-OF: R-02753-24748 A sequence number assigned to each index\n# for internal tracking purposes.\n#\n# (The second column of output from PRAGMA index_list is...)\n# EVIDENCE-OF: R-35496-03635 The name of the index.\n#\n# (The third column of output from PRAGMA index_list is...)\n# EVIDENCE-OF: R-57301-64506 \"1\" if the index is UNIQUE and \"0\" if not.\n#\n# (The fourth column of output from PRAGMA index_list is...)\n# EVIDENCE-OF: R-36609-39554 \"c\" if the index was created by a CREATE\n# INDEX statement, \"u\" if the index was created by a UNIQUE constraint,\n# or \"pk\" if the index was created by a PRIMARY KEY constraint.\n#\ndo_test 23.3 {\n  db eval {\n    CREATE INDEX i3 ON t1(d,b,c);\n  }\n  capture_pragma db2 out {PRAGMA index_list(t1)}\n  db2 eval {SELECT seq, name, \"unique\", origin, '|' FROM out ORDER BY seq}\n} {0 i3 0 c | 1 i2 0 c | 2 i2x 0 c | 3 i1 0 c |}\ndo_test 23.4 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN e;\n  }\n  db2 eval {\n    PRAGMA table_info(t1);\n  }\n} {/4 e {} 0 {} 0/}\ndo_test 23.5 {\n  db eval {\n    DROP TABLE t2;\n    CREATE TABLE t2(x, y INTEGER REFERENCES t1);\n  }\n  db2 eval {\n    PRAGMA foreign_key_list(t2);\n  }\n} {0 0 t1 y {} {NO ACTION} {NO ACTION} NONE}\ndb2 close\n\nifcapable !has_codec {\n  reset_db\n  do_execsql_test 24.0 {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(b);\n    INSERT INTO t1 VALUES('a', 'b', 'c');\n    PRAGMA integrity_check;\n  } {ok}\n  \n  set r [db one {SELECT rootpage FROM sqlite_master WHERE name = 't1'}]\n  db close\n  hexio_write test.db [expr $r*1024 - 16] 000000000000000701040f0f1f616263\n  \n  sqlite3 db test.db\n  do_catchsql_test 24.1 {\n    SELECT * FROM t1;\n  } {1 {database disk image is malformed}}\n  do_catchsql_test 24.2 {\n    PRAGMA integrity_check;\n  } {0 {{database disk image is malformed}}}\n}  \ndatabase_never_corrupt\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragma2.test",
    "content": "# 2002 March 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the PRAGMA command.\n#\n# $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test organization:\n#\n# pragma2-1.*: Test freelist_count pragma on the main database.\n# pragma2-2.*: Test freelist_count pragma on an attached database.\n# pragma2-3.*: Test trying to write to the freelist_count is a no-op.\n# pragma2-4.*: Tests for PRAGMA cache_spill\n#\n\nifcapable !pragma||!schema_pragmas {\n  finish_test\n  return\n}\n\ntest_set_config_pagecache 0 0\n\n# Delete the preexisting database to avoid the special setup\n# that the \"all.test\" script does.\n#\ndb close\ndelete_file test.db test.db-journal\ndelete_file test3.db test3.db-journal\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndb eval {PRAGMA auto_vacuum=0}\n\n\n# EVIDENCE-OF: R-11211-21323 PRAGMA schema.freelist_count; Return the\n# number of unused pages in the database file.\n#\ndo_test pragma2-1.1 {\n  execsql {\n    PRAGMA freelist_count;\n  }\n} {0}\ndo_test pragma2-1.2 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    PRAGMA freelist_count;\n  }\n} {0}\ndo_test pragma2-1.3 {\n  execsql {\n    DROP TABLE abc;\n    PRAGMA freelist_count;\n  }\n} {1}\ndo_test pragma2-1.4 {\n  execsql {\n    PRAGMA main.freelist_count;\n  }\n} {1}\n\nforcedelete test2.db\nforcedelete test2.db-journal\n\nifcapable attach {\n  do_test pragma2-2.1 {\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA aux.auto_vacuum=OFF;\n      PRAGMA aux.freelist_count;\n    }\n  } {0}\n  do_test pragma2-2.2 {\n    execsql {\n      CREATE TABLE aux.abc(a, b, c);\n      PRAGMA aux.freelist_count;\n    }\n  } {0}\n  do_test pragma2-2.3 {\n    set ::val [string repeat 0123456789 1000]\n    execsql {\n      INSERT INTO aux.abc VALUES(1, 2, $::val);\n      PRAGMA aux.freelist_count;\n    }\n  } {0}\n  do_test pragma2-2.4 {\n    expr {[file size test2.db] / 1024}\n  } {11}\n  do_test pragma2-2.5 {\n    execsql {\n      DELETE FROM aux.abc;\n      PRAGMA aux.freelist_count;\n    }\n  } {9}\n  \n  do_test pragma2-3.1 {\n    execsql {\n      PRAGMA aux.freelist_count;\n      PRAGMA main.freelist_count;\n      PRAGMA freelist_count;\n    }\n  } {9 1 1}\n  do_test pragma2-3.2 {\n    execsql {\n      PRAGMA freelist_count = 500;\n      PRAGMA freelist_count;\n    }\n  } {1 1}\n  do_test pragma2-3.3 {\n    execsql {\n      PRAGMA aux.freelist_count = 500;\n      PRAGMA aux.freelist_count;\n    }\n  } {9 9}\n}\n\n# Default setting of PRAGMA cache_spill is always ON\n#\n# EVIDENCE-OF: R-63549-59887 PRAGMA cache_spill; PRAGMA\n# cache_spill=boolean; PRAGMA schema.cache_spill=N;\n#\n# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default\n#\ndb close\ndelete_file test.db test.db-journal\ndelete_file test2.db test2.db-journal\nsqlite3 db test.db\ndo_execsql_test pragma2-4.1 {\n  PRAGMA main.cache_size=2000;\n  PRAGMA temp.cache_size=2000;\n  PRAGMA cache_spill;\n  PRAGMA main.cache_spill;\n  PRAGMA temp.cache_spill;\n} {2000 2000 2000}\ndo_execsql_test pragma2-4.2 {\n  PRAGMA cache_spill=OFF;\n  PRAGMA cache_spill;\n  PRAGMA main.cache_spill;\n  PRAGMA temp.cache_spill;\n} {0 0 0}\ndo_execsql_test pragma2-4.3 {\n  PRAGMA page_size=1024;\n  PRAGMA cache_size=50;\n  BEGIN;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d);\n  INSERT INTO t1 VALUES(1, randomblob(400), 1, randomblob(400));\n  INSERT INTO t1 SELECT a+1, randomblob(400), a+1, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+2, randomblob(400), a+2, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+4, randomblob(400), a+4, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+8, randomblob(400), a+8, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+16, randomblob(400), a+16, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+32, randomblob(400), a+32, randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT a+64, randomblob(400), a+64, randomblob(400) FROM t1;\n  COMMIT;\n  ATTACH 'test2.db' AS aux1;\n  CREATE TABLE aux1.t2(a INTEGER PRIMARY KEY, b, c, d);\n  INSERT INTO t2 SELECT * FROM t1;\n  DETACH aux1;\n  PRAGMA cache_spill=ON;\n} {}\nsqlite3_release_memory\n#\n# EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables\n# the ability of the pager to spill dirty cache pages to the database\n# file in the middle of a transaction.\n#\ndo_test pragma2-4.4 {\n  db eval {\n    BEGIN;\n    UPDATE t1 SET c=c+1;\n    PRAGMA lock_status;\n  }\n} {main exclusive temp unknown}  ;# EXCLUSIVE lock due to cache spill\ndo_test pragma2-4.5.1 {\n  db eval {\n    ROLLBACK;\n    PRAGMA cache_spill=OFF;\n    PRAGMA Cache_Spill;\n    BEGIN;\n    UPDATE t1 SET c=c+1;\n    PRAGMA lock_status;\n  }\n} {0 main reserved temp unknown}   ;# No cache spill, so no exclusive lock\n\n\n# EVIDENCE-OF: R-34657-61226 The \"PRAGMA cache_spill=N\" form of this\n# pragma sets a minimum cache size threshold required for spilling to\n# occur.\ndo_test pragma2-4.5.2 {\n  db eval {\n    ROLLBACK;\n    PRAGMA cache_spill=100000;\n    PRAGMA cache_spill;\n    BEGIN;\n    UPDATE t1 SET c=c+1;\n    PRAGMA lock_status;\n  }\n} {100000 main reserved temp unknown}   ;# Big spill threshold -> no excl lock\nifcapable !memorymanage {\n  do_test pragma2-4.5.3 {\n    db eval {\n      ROLLBACK;\n      PRAGMA cache_spill=25;\n      PRAGMA main.cache_spill;\n      BEGIN;\n      UPDATE t1 SET c=c+1;\n      PRAGMA lock_status;\n    }\n  } {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock\n  do_test pragma2-4.5.4 {\n    db eval {\n      ROLLBACK;\n      PRAGMA cache_spill(-25);\n      PRAGMA main.cache_spill;\n      BEGIN;\n      UPDATE t1 SET c=c+1;\n      PRAGMA lock_status;\n    }\n  } {50 main exclusive temp unknown}   ;# Small cache spill -> exclusive lock\n}\n\n\n# Verify that newly attached databases inherit the cache_spill=OFF\n# setting.\n#\ndo_execsql_test pragma2-4.6 {\n  ROLLBACK;\n  PRAGMA cache_spill=OFF;\n  ATTACH 'test2.db' AS aux1;\n  PRAGMA aux1.cache_size=50;\n  BEGIN;\n  UPDATE t2 SET c=c+1;\n  PRAGMA lock_status;\n} {main unlocked temp unknown aux1 reserved}\ndo_execsql_test pragma2-4.7 {\n  COMMIT;\n}\nsqlite3_release_memory\ndo_execsql_test pragma2-4.8 {\n  PRAGMA cache_spill=ON; -- Applies to all databases\n  BEGIN;\n  UPDATE t2 SET c=c-1;\n  PRAGMA lock_status;\n} {main unlocked temp unknown aux1 exclusive}\ndb close\nforcedelete test.db\nsqlite3 db test.db\n\ndo_execsql_test pragma2-5.1 {\n  PRAGMA page_size=16384;\n  CREATE TABLE t1(x);\n  PRAGMA cache_size=2;\n  PRAGMA cache_spill=YES;\n  PRAGMA cache_spill;\n} {2}\ndo_execsql_test pragma2-5.2 {\n  PRAGMA cache_spill=NO;\n  PRAGMA cache_spill;\n} {0}\ndo_execsql_test pragma2-5.3 {\n  PRAGMA cache_spill(-51);\n  PRAGMA cache_spill;\n} {3}\n   \ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragma3.test",
    "content": "# 2014-12-19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for PRAGMA data_version command.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndo_not_use_codec\n\ndo_execsql_test pragma3-100 {\n  PRAGMA data_version;\n} {1}\ndo_execsql_test pragma3-101 {\n  PRAGMA temp.data_version;\n} {1}\n\n# Writing to the pragma is a no-op \ndo_execsql_test pragma3-102 {\n  PRAGMA main.data_version=1234;\n  PRAGMA main.data_version;\n} {1 1}\n\n# EVIDENCE-OF: R-27726-60934 The \"PRAGMA data_version\" command provides\n# an indication that the database file has been modified.\n#\n# EVIDENCE-OF: R-47505-58569 The \"PRAGMA data_version\" value is\n# unchanged for commits made on the same database connection.\n#\ndo_execsql_test pragma3-110 {\n  PRAGMA data_version;\n  BEGIN IMMEDIATE;\n  PRAGMA data_version;\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(100),(200),(300);\n  PRAGMA data_version;\n  COMMIT;\n  SELECT * FROM t1;\n  PRAGMA data_version;\n} {1 1 1 100 200 300 1}\n\nsqlite3 db2 test.db\ndo_test pragma3-120 {\n  db2 eval {\n    SELECT * FROM t1;\n    PRAGMA data_version;\n  }\n} {100 200 300 1}\n\ndo_execsql_test pragma3-130 {\n  PRAGMA data_version;\n  BEGIN IMMEDIATE;\n  PRAGMA data_version;\n  INSERT INTO t1 VALUES(400),(500);\n  PRAGMA data_version;\n  COMMIT;\n  SELECT * FROM t1;\n  PRAGMA data_version;\n  PRAGMA shrink_memory;\n} {1 1 1 100 200 300 400 500 1}\n\n# EVIDENCE-OF: R-63005-41812 The integer values returned by two\n# invocations of \"PRAGMA data_version\" from the same connection will be\n# different if changes were committed to the database by any other\n# connection in the interim.\n#\n# Value went from 1 in pragma3-120 to 2 here.\n#\ndo_test pragma3-140 {\n  db2 eval {\n    SELECT * FROM t1;\n    PRAGMA data_version;\n    BEGIN IMMEDIATE;\n    PRAGMA data_version;\n    UPDATE t1 SET a=a+1;\n    COMMIT;\n    SELECT * FROM t1;\n    PRAGMA data_version;\n  }\n} {100 200 300 400 500 2 2 101 201 301 401 501 2}\ndo_execsql_test pragma3-150 {\n  SELECT * FROM t1;\n  PRAGMA data_version;\n} {101 201 301 401 501 2}\n\n#\ndo_test pragma3-160 {\n  db eval {\n    BEGIN;\n    PRAGMA data_version;\n    UPDATE t1 SET a=555 WHERE a=501;\n    PRAGMA data_version;\n    SELECT * FROM t1 ORDER BY a;\n    PRAGMA data_version;\n  }\n} {2 2 101 201 301 401 555 2}\ndo_test pragma3-170 {\n  db2 eval {\n    PRAGMA data_version;\n  }\n} {2}\ndo_test pragma3-180 {\n  db eval {\n    COMMIT;\n    PRAGMA data_version;\n  }\n} {2}\ndo_test pragma3-190 {\n  db2 eval {\n    PRAGMA data_version;\n  }\n} {3}\n\n# EVIDENCE-OF: R-19326-44825 The \"PRAGMA data_version\" value is a local\n# property of each database connection and so values returned by two\n# concurrent invocations of \"PRAGMA data_version\" on separate database\n# connections are often different even though the underlying database is\n# identical.\n#\ndo_test pragma3-195 {\n  expr {[db eval {PRAGMA data_version}]!=[db2 eval {PRAGMA data_version}]}\n} {1}\n\n# EVIDENCE-OF: R-54562-06892 The behavior of \"PRAGMA data_version\" is\n# the same for all database connections, including database connections\n# in separate processes and shared cache database connections.\n#\n# The next block checks the behavior for separate processes.\n#\ndo_test pragma3-200 {\n  db eval {PRAGMA data_version; SELECT * FROM t1;}\n} {2 101 201 301 401 555}\ndo_test pragma3-201 {\n  set fd [open pragma3.txt wb]\n  puts $fd {\n     sqlite3 db test.db;\n     db eval {DELETE FROM t1 WHERE a>300};\n     db close;\n     exit;\n  }\n  close $fd\n  exec [info nameofexec] pragma3.txt\n  forcedelete pragma3.txt\n  db eval {\n    PRAGMA data_version;\n    SELECT * FROM t1;\n  }\n} {3 101 201}\ndb2 close\ndb close\n\n# EVIDENCE-OF: R-54562-06892 The behavior of \"PRAGMA data_version\" is\n# the same for all database connections, including database connections\n# in separate processes and shared cache database connections.\n#\n# The next block checks that behavior is the same for shared-cache.\n#\nifcapable shared_cache {\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  do_test pragma3-300 {\n    db eval {\n      PRAGMA data_version;\n      BEGIN;\n      CREATE TABLE t3(a,b,c);\n      CREATE TABLE t4(x,y,z);\n      INSERT INTO t4 VALUES(123,456,789);\n      PRAGMA data_version;\n      COMMIT;\n      PRAGMA data_version;\n    }\n  } {1 1 1}\n  do_test pragma3-310 {\n    db2 eval {\n      PRAGMA data_version;\n      BEGIN;\n      INSERT INTO t3(a,b,c) VALUES('abc','def','ghi');\n      SELECT * FROM t3;\n      PRAGMA data_version;\n    }\n  } {2 abc def ghi 2}\n  # The transaction in db2 has not yet committed, so the data_version in\n  # db is unchanged.\n  do_test pragma3-320 {\n    db eval {\n      PRAGMA data_version;\n      SELECT * FROM t4;\n    }\n  } {1 123 456 789}\n  do_test pragma3-330 {\n    db2 eval {\n      COMMIT;\n      PRAGMA data_version;\n      SELECT * FROM t4;\n    }\n  } {2 123 456 789}\n  do_test pragma3-340 {\n    db eval {\n      PRAGMA data_version;\n      SELECT * FROM t3;\n      SELECT * FROM t4;\n    }\n  } {2 abc def ghi 123 456 789}\n  db2 close\n  db close\n  sqlite3_enable_shared_cache $::enable_shared_cache\n}\n\n# Make sure this also works in WAL mode\n#\n# This will not work with the in-memory journal permutation, as opening\n# [db2] switches the journal mode back to \"memory\"\n#\nif {[wal_is_capable]} {\nif {[permutation]!=\"inmemory_journal\"} {\n\n  sqlite3 db test.db\n  db eval {PRAGMA journal_mode=WAL}\n  sqlite3 db2 test.db\n  do_test pragma3-400 {\n    db eval {\n      PRAGMA data_version;\n      PRAGMA journal_mode;\n      SELECT * FROM t1;\n    }\n  } {2 wal 101 201}\n  do_test pragma3-410 {\n    db2 eval {\n      PRAGMA data_version;\n      PRAGMA journal_mode;\n      SELECT * FROM t1;\n    }\n  } {2 wal 101 201}\n  do_test pragma3-420 {\n    db eval {UPDATE t1 SET a=111*(a/100); PRAGMA data_version; SELECT * FROM t1}\n  } {2 111 222}\n  do_test pragma3-430 {\n    db2 eval {PRAGMA data_version; SELECT * FROM t1;}\n  } {3 111 222}\n  db2 close\n}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragma4.test",
    "content": "# 2017 Jan 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix pragma4\n\nproc do_pragma_ncol_test {tn sql nCol} {\n  set ::stmt 0\n  set ::stmt [sqlite3_prepare_v2 db $sql -1 dummy]\n  uplevel [list do_test $tn { sqlite3_column_count $::stmt } $nCol]\n  sqlite3_finalize $::stmt\n}\n\n# If there is no RHS argument, the following PRAGMA statements operate as\n# queries, returning a single row containing a single column.\n#\n# Or, if there is RHS argument, they return zero rows of zero columns.\n#\nforeach {tn sql} {\n  1 \"PRAGMA application_id = 10\"\n  2 \"PRAGMA automatic_index = 1\"\n  3 \"PRAGMA auto_vacuum = 1\"\n  4 \"PRAGMA cache_size = -100\"\n  5 \"PRAGMA cache_spill = 1\"\n  6 \"PRAGMA cell_size_check = 1\"\n  7 \"PRAGMA checkpoint_fullfsync = 1\"\n  8 \"PRAGMA count_changes = 1\"\n  9 \"PRAGMA default_cache_size = 100\"\n 10 \"PRAGMA defer_foreign_keys = 1\"\n 11 \"PRAGMA empty_result_callbacks = 1\"\n 12 \"PRAGMA encoding = 'utf-8'\"\n 13 \"PRAGMA foreign_keys = 1\"\n 14 \"PRAGMA full_column_names = 1\"\n 15 \"PRAGMA fullfsync = 1\"\n 16 \"PRAGMA ignore_check_constraints = 1\"\n 17 \"PRAGMA legacy_file_format = 1\"\n 18 \"PRAGMA page_size = 511\"\n 19 \"PRAGMA page_size = 512\"\n 20 \"PRAGMA query_only = false\"\n 21 \"PRAGMA read_uncommitted = true\"\n 22 \"PRAGMA recursive_triggers = false\"\n 23 \"PRAGMA reverse_unordered_selects = false\"\n 24 \"PRAGMA schema_version = 211\"\n 25 \"PRAGMA short_column_names = 1\"\n 26 \"PRAGMA synchronous = full\"\n 29 \"PRAGMA temp_store = memory\"\n 30 \"PRAGMA user_version = 405\"\n 31 \"PRAGMA writable_schema = 1\"\n} {\n  reset_db\n\n  # Without RHS:\n  do_pragma_ncol_test 1.$tn.1 [lindex [split $sql =] 0] 1\n\n  # With RHS:\n  do_pragma_ncol_test 1.$tn.2 $sql  0\n}\n\n# These pragmas should never return any values.\n#\nforeach {tn sql} {\n  1 \"PRAGMA shrink_memory\"\n  2 \"PRAGMA shrink_memory = 10\"\n  3 \"PRAGMA case_sensitive_like = 0\"\n  4 \"PRAGMA case_sensitive_like = 1\"\n  5 \"PRAGMA case_sensitive_like\"\n} {\n\n  do_pragma_ncol_test 1.$tn.1 $sql 0\n}\n\n# EXPLAIN on a PRAGMA integrity_check.\n# Verify that that P4_INTARRAY argument to OP_IntegrityCk is rendered\n# correctly.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_test pragma4-2.100 {\n  db eval {\n    PRAGMA page_size=512;\n    CREATE TABLE t1(x);\n    WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10000)\n    INSERT INTO t1(x) SELECT zeroblob(300) FROM c;\n    CREATE TABLE t2(y);\n    DROP TABLE t1;\n  }\n  string map {\\[ x \\] x \\173 {} \\175 {}} \\\n    [db eval {EXPLAIN PRAGMA integrity_check}]\n} {/ IntegrityCk 2 2 1 x[0-9]+,1x /}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragma5.test",
    "content": "# 2017 August 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the PRAGMA command. Specifically,\n# those pragmas enabled at build time by setting:\n#\n#   -DSQLITE_INTROSPECTION_PRAGMAS\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix pragma5\n\nif { [catch {db one \"SELECT count(*) FROM pragma_function_list\"}] } {\n  finish_test\n  return\n}\n\ndb function external external\n\ndo_execsql_test 1.0 {\n  PRAGMA table_info(pragma_function_list)\n} {\n  0 name {} 0 {} 0 \n  1 builtin {} 0 {} 0\n}\ndo_execsql_test 1.1 {\n  SELECT * FROM pragma_function_list WHERE name='upper'\n} {upper 1}\ndo_execsql_test 1.2 {\n  SELECT * FROM pragma_function_list WHERE name LIKE 'exter%';\n} {external 0}\n\nifcapable fts5 {\n  do_execsql_test 2.0 {\n    PRAGMA table_info(pragma_module_list)\n  } {\n    0 name {} 0 {} 0 \n  }\n  do_execsql_test 2.1 {\n    SELECT * FROM pragma_module_list WHERE name='fts5'\n  } {fts5}\n}\n\ndo_execsql_test 3.0 {\n  PRAGMA table_info(pragma_pragma_list)\n} {\n  0 name {} 0 {} 0 \n}\ndo_execsql_test 3.1 {\n  SELECT * FROM pragma_pragma_list WHERE name='pragma_list'\n} {pragma_list}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pragmafault.test",
    "content": "# 2010 June 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nset testprefix pragmafault\n\ndb close\nsqlite3 db test.db\nsqlite3_db_config_lookaside db 0 0 0\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, CHECK(a!=b));\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  catchsql { PRAGMA integrity_check }\n  set {} 0\n} -test {\n  faultsim_test_result {0 0} \n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/printf.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite_*_printf() interface.\n#\n# $Id: printf.test,v 1.31 2009/02/01 00:21:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\ndo_test printf-1.1.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       1 1 1\n} {abc: 1 1 1 :xyz}\ndo_test printf-1.1.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       1 1 1\n} {abc: (     1) (     1) (     1) :xyz}\ndo_test printf-1.1.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       1 1 1\n} {abc: (1     ) (1     ) (1     ) :xyz}\ndo_test printf-1.1.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       1 1 1\n} {abc: (    +1) (     1) (     1) :xyz}\ndo_test printf-1.1.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       1 1 1\n} {abc: (000001) (000001) (000001) :xyz}\ndo_test printf-1.1.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       1 1 1\n} {abc: (     1) (     1) (     1) :xyz}\ndo_test printf-1.1.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       1 1 1\n} {abc: (     1) (   0x1) (    01) :xyz}\ndo_test printf-1.2.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       2 2 2\n} {abc: 2 2 2 :xyz}\ndo_test printf-1.2.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       2 2 2\n} {abc: (     2) (     2) (     2) :xyz}\ndo_test printf-1.2.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       2 2 2\n} {abc: (2     ) (2     ) (2     ) :xyz}\ndo_test printf-1.2.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       2 2 2\n} {abc: (    +2) (     2) (     2) :xyz}\ndo_test printf-1.2.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       2 2 2\n} {abc: (000002) (000002) (000002) :xyz}\ndo_test printf-1.2.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       2 2 2\n} {abc: (     2) (     2) (     2) :xyz}\ndo_test printf-1.2.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       2 2 2\n} {abc: (     2) (   0x2) (    02) :xyz}\ndo_test printf-1.3.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       5 5 5\n} {abc: 5 5 5 :xyz}\ndo_test printf-1.3.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       5 5 5\n} {abc: (     5) (     5) (     5) :xyz}\ndo_test printf-1.3.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       5 5 5\n} {abc: (5     ) (5     ) (5     ) :xyz}\ndo_test printf-1.3.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       5 5 5\n} {abc: (    +5) (     5) (     5) :xyz}\ndo_test printf-1.3.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       5 5 5\n} {abc: (000005) (000005) (000005) :xyz}\ndo_test printf-1.3.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       5 5 5\n} {abc: (     5) (     5) (     5) :xyz}\ndo_test printf-1.3.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       5 5 5\n} {abc: (     5) (   0x5) (    05) :xyz}\ndo_test printf-1.4.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       10 10 10\n} {abc: 10 a 12 :xyz}\ndo_test printf-1.4.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       10 10 10\n} {abc: (    10) (     a) (    12) :xyz}\ndo_test printf-1.4.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       10 10 10\n} {abc: (10    ) (a     ) (12    ) :xyz}\ndo_test printf-1.4.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       10 10 10\n} {abc: (   +10) (     a) (    12) :xyz}\ndo_test printf-1.4.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       10 10 10\n} {abc: (000010) (00000a) (000012) :xyz}\ndo_test printf-1.4.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       10 10 10\n} {abc: (    10) (     a) (    12) :xyz}\ndo_test printf-1.4.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       10 10 10\n} {abc: (    10) (   0xa) (   012) :xyz}\ndo_test printf-1.5.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       99 99 99\n} {abc: 99 63 143 :xyz}\ndo_test printf-1.5.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       99 99 99\n} {abc: (    99) (    63) (   143) :xyz}\ndo_test printf-1.5.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       99 99 99\n} {abc: (99    ) (63    ) (143   ) :xyz}\ndo_test printf-1.5.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       99 99 99\n} {abc: (   +99) (    63) (   143) :xyz}\ndo_test printf-1.5.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       99 99 99\n} {abc: (000099) (000063) (000143) :xyz}\ndo_test printf-1.5.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       99 99 99\n} {abc: (    99) (    63) (   143) :xyz}\ndo_test printf-1.5.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       99 99 99\n} {abc: (    99) (  0x63) (  0143) :xyz}\ndo_test printf-1.6.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       100 100 100\n} {abc: 100 64 144 :xyz}\ndo_test printf-1.6.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       100 100 100\n} {abc: (   100) (    64) (   144) :xyz}\ndo_test printf-1.6.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       100 100 100\n} {abc: (100   ) (64    ) (144   ) :xyz}\ndo_test printf-1.6.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       100 100 100\n} {abc: (  +100) (    64) (   144) :xyz}\ndo_test printf-1.6.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       100 100 100\n} {abc: (000100) (000064) (000144) :xyz}\ndo_test printf-1.6.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       100 100 100\n} {abc: (   100) (    64) (   144) :xyz}\ndo_test printf-1.6.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       100 100 100\n} {abc: (   100) (  0x64) (  0144) :xyz}\ndo_test printf-1.7.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       1000000 1000000 1000000\n} {abc: 1000000 f4240 3641100 :xyz}\ndo_test printf-1.7.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: (1000000) ( f4240) (3641100) :xyz}\ndo_test printf-1.7.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: (1000000) (f4240 ) (3641100) :xyz}\ndo_test printf-1.7.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: (+1000000) ( f4240) (3641100) :xyz}\ndo_test printf-1.7.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: (1000000) (0f4240) (3641100) :xyz}\ndo_test printf-1.7.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: ( 1000000) ( f4240) (3641100) :xyz}\ndo_test printf-1.7.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       1000000 1000000 1000000\n} {abc: (1000000) (0xf4240) (03641100) :xyz}\ndo_test printf-1.8.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       999999999 999999999 999999999\n} {abc: 999999999 3b9ac9ff 7346544777 :xyz}\ndo_test printf-1.8.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}\ndo_test printf-1.8.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}\ndo_test printf-1.8.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: (+999999999) (3b9ac9ff) (7346544777) :xyz}\ndo_test printf-1.8.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: (999999999) (3b9ac9ff) (7346544777) :xyz}\ndo_test printf-1.8.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: ( 999999999) (3b9ac9ff) (7346544777) :xyz}\ndo_test printf-1.8.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       999999999 999999999 999999999\n} {abc: (999999999) (0x3b9ac9ff) (07346544777) :xyz}\ndo_test printf-1.9.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0 0 0\n} {abc: 0 0 0 :xyz}\ndo_test printf-1.9.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0 0 0\n} {abc: (     0) (     0) (     0) :xyz}\ndo_test printf-1.9.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0 0 0\n} {abc: (0     ) (0     ) (0     ) :xyz}\ndo_test printf-1.9.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0 0 0\n} {abc: (    +0) (     0) (     0) :xyz}\ndo_test printf-1.9.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0 0 0\n} {abc: (000000) (000000) (000000) :xyz}\ndo_test printf-1.9.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0 0 0\n} {abc: (     0) (     0) (     0) :xyz}\ndo_test printf-1.9.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0 0 0\n} {abc: (     0) (     0) (     0) :xyz}\n# 0xffffffff == -1\ndo_test printf-1.10.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: -1 ffffffff 37777777777 :xyz}\ndo_test printf-1.10.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (    -1) (ffffffff) (37777777777) :xyz}\ndo_test printf-1.10.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (-1    ) (ffffffff) (37777777777) :xyz}\ndo_test printf-1.10.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (    -1) (ffffffff) (37777777777) :xyz}\ndo_test printf-1.10.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (-00001) (ffffffff) (37777777777) :xyz}\ndo_test printf-1.10.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (    -1) (ffffffff) (37777777777) :xyz}\ndo_test printf-1.10.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xffffffff 0xffffffff 0xffffffff\n} {abc: (    -1) (0xffffffff) (037777777777) :xyz}\n# 0xfffffffe == -2\ndo_test printf-1.11.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: -2 fffffffe 37777777776 :xyz}\ndo_test printf-1.11.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (    -2) (fffffffe) (37777777776) :xyz}\ndo_test printf-1.11.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (-2    ) (fffffffe) (37777777776) :xyz}\ndo_test printf-1.11.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (    -2) (fffffffe) (37777777776) :xyz}\ndo_test printf-1.11.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (-00002) (fffffffe) (37777777776) :xyz}\ndo_test printf-1.11.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (    -2) (fffffffe) (37777777776) :xyz}\ndo_test printf-1.11.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xfffffffe 0xfffffffe 0xfffffffe\n} {abc: (    -2) (0xfffffffe) (037777777776) :xyz}\n# 0xfffffffb == -5\ndo_test printf-1.12.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: -5 fffffffb 37777777773 :xyz}\ndo_test printf-1.12.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (    -5) (fffffffb) (37777777773) :xyz}\ndo_test printf-1.12.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (-5    ) (fffffffb) (37777777773) :xyz}\ndo_test printf-1.12.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (    -5) (fffffffb) (37777777773) :xyz}\ndo_test printf-1.12.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (-00005) (fffffffb) (37777777773) :xyz}\ndo_test printf-1.12.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (    -5) (fffffffb) (37777777773) :xyz}\ndo_test printf-1.12.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xfffffffb 0xfffffffb 0xfffffffb\n} {abc: (    -5) (0xfffffffb) (037777777773) :xyz}\n# 0xfffffff6 == -10\ndo_test printf-1.13.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: -10 fffffff6 37777777766 :xyz}\ndo_test printf-1.13.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (   -10) (fffffff6) (37777777766) :xyz}\ndo_test printf-1.13.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (-10   ) (fffffff6) (37777777766) :xyz}\ndo_test printf-1.13.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (   -10) (fffffff6) (37777777766) :xyz}\ndo_test printf-1.13.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (-00010) (fffffff6) (37777777766) :xyz}\ndo_test printf-1.13.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (   -10) (fffffff6) (37777777766) :xyz}\ndo_test printf-1.13.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xfffffff6 0xfffffff6 0xfffffff6\n} {abc: (   -10) (0xfffffff6) (037777777766) :xyz}\n# 0xffffff9d == -99\ndo_test printf-1.14.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: -99 ffffff9d 37777777635 :xyz}\ndo_test printf-1.14.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (   -99) (ffffff9d) (37777777635) :xyz}\ndo_test printf-1.14.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (-99   ) (ffffff9d) (37777777635) :xyz}\ndo_test printf-1.14.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (   -99) (ffffff9d) (37777777635) :xyz}\ndo_test printf-1.14.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (-00099) (ffffff9d) (37777777635) :xyz}\ndo_test printf-1.14.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (   -99) (ffffff9d) (37777777635) :xyz}\ndo_test printf-1.14.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xffffff9d 0xffffff9d 0xffffff9d\n} {abc: (   -99) (0xffffff9d) (037777777635) :xyz}\n# 0xffffff9c == -100\ndo_test printf-1.15.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: -100 ffffff9c 37777777634 :xyz}\ndo_test printf-1.15.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (  -100) (ffffff9c) (37777777634) :xyz}\ndo_test printf-1.15.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (-100  ) (ffffff9c) (37777777634) :xyz}\ndo_test printf-1.15.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (  -100) (ffffff9c) (37777777634) :xyz}\ndo_test printf-1.15.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (-00100) (ffffff9c) (37777777634) :xyz}\ndo_test printf-1.15.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (  -100) (ffffff9c) (37777777634) :xyz}\ndo_test printf-1.15.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xffffff9c 0xffffff9c 0xffffff9c\n} {abc: (  -100) (0xffffff9c) (037777777634) :xyz}\n# 0xff676981 == -9999999\ndo_test printf-1.16.1 {\n  sqlite3_mprintf_int {abc: %d %x %o :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: -9999999 ff676981 37731664601 :xyz}\ndo_test printf-1.16.2 {\n  sqlite3_mprintf_int {abc: (%6d) (%6x) (%6o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (ff676981) (37731664601) :xyz}\ndo_test printf-1.16.3 {\n  sqlite3_mprintf_int {abc: (%-6d) (%-6x) (%-6o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (ff676981) (37731664601) :xyz}\ndo_test printf-1.16.4 {\n  sqlite3_mprintf_int {abc: (%+6d) (%+6x) (%+6o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (ff676981) (37731664601) :xyz}\ndo_test printf-1.16.5 {\n  sqlite3_mprintf_int {abc: (%06d) (%06x) (%06o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (ff676981) (37731664601) :xyz}\ndo_test printf-1.16.6 {\n  sqlite3_mprintf_int {abc: (% 6d) (% 6x) (% 6o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (ff676981) (37731664601) :xyz}\ndo_test printf-1.16.7 {\n  sqlite3_mprintf_int {abc: (%#6d) (%#6x) (%#6o) :xyz}\\\n       0xff676981 0xff676981 0xff676981\n} {abc: (-9999999) (0xff676981) (037731664601) :xyz}\ndo_test printf-1.17.1 {\n  sqlite3_mprintf_int {abd: %2147483647d %2147483647x %2147483647o} 1 1 1\n} {}\ndo_test printf-1.17.2 {\n  sqlite3_mprintf_int {abd: %*d %x} 2147483647 1 1\n} {}\ndo_test printf-1.17.3 {\n  sqlite3_mprintf_int {abd: %*d %x} -2147483648 1 1\n} {abd: 1 1}\ndo_test printf-1.17.4 {\n  sqlite3_mprintf_int {abd: %.2147483648d %x %x} 1 1 1\n} {/.*/}\ndo_test printf-2.1.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 0.001\n} {abc: (0.0) :xyz}\ndo_test printf-2.1.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 0.001\n} {abc: (1.0e-03) :xyz}\ndo_test printf-2.1.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.1.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 0.001\n} {abc: 1 1 (0.001) :xyz}\ndo_test printf-2.1.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 0.001\n} {abc: 1 1 (0.00100000) :xyz}\ndo_test printf-2.1.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 0.001\n} {abc: 1 1 (000000.001) :xyz}\ndo_test printf-2.1.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 0.001\n} {abc: 1 1 (0.0) :xyz}\ndo_test printf-2.1.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 0.001\n} {abc: 1 1 (1.0e-03) :xyz}\ndo_test printf-2.1.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 0.001\n} {abc: 1 1 (0.001) :xyz}\ndo_test printf-2.1.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 1.0e-20\n} {abc: (0.0) :xyz}\ndo_test printf-2.1.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 1.0e-20\n} {abc: (1.0e-20) :xyz}\ndo_test printf-2.1.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.1.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (1e-20) :xyz}\ndo_test printf-2.1.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (1.00000e-20) :xyz}\ndo_test printf-2.1.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (000001e-20) :xyz}\ndo_test printf-2.1.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (0.0) :xyz}\ndo_test printf-2.1.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (1.0e-20) :xyz}\ndo_test printf-2.1.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 1.0e-20\n} {abc: 1 1 (1e-20) :xyz}\ndo_test printf-2.1.2.10 {\n  sqlite3_mprintf_double {abc: %*.*f}  2000000000 1000000000 1.0e-20\n} {abc: }\ndo_test printf-2.1.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 1.0\n} {abc: (1.0) :xyz}\ndo_test printf-2.1.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 1.0\n} {abc: (1.0e+00) :xyz}\ndo_test printf-2.1.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 1.0\n} {abc: (1) :xyz}\ndo_test printf-2.1.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 1.0\n} {abc: 1 1 (1) :xyz}\ndo_test printf-2.1.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 1.0\n} {abc: 1 1 (1.00000) :xyz}\ndo_test printf-2.1.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 1.0\n} {abc: 1 1 (0000000001) :xyz}\ndo_test printf-2.1.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 1.0\n} {abc: 1 1 (1.0) :xyz}\ndo_test printf-2.1.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 1.0\n} {abc: 1 1 (1.0e+00) :xyz}\ndo_test printf-2.1.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 1.0\n} {abc: 1 1 (1) :xyz}\ndo_test printf-2.1.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 0.0\n} {abc: (0.0) :xyz}\ndo_test printf-2.1.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 0.0\n} {abc: (0.0e+00) :xyz}\ndo_test printf-2.1.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 0.0\n} {abc: (0) :xyz}\ndo_test printf-2.1.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 0.0\n} {abc: 1 1 (0) :xyz}\ndo_test printf-2.1.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 0.0\n} {abc: 1 1 (0.00000) :xyz}\ndo_test printf-2.1.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 0.0\n} {abc: 1 1 (0000000000) :xyz}\ndo_test printf-2.1.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 0.0\n} {abc: 1 1 (0.0) :xyz}\ndo_test printf-2.1.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 0.0\n} {abc: 1 1 (0.0e+00) :xyz}\ndo_test printf-2.1.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 0.0\n} {abc: 1 1 (0) :xyz}\ndo_test printf-2.1.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 100.0\n} {abc: (100.0) :xyz}\ndo_test printf-2.1.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 100.0\n} {abc: (1.0e+02) :xyz}\ndo_test printf-2.1.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 100.0\n} {abc: (1e+02) :xyz}\ndo_test printf-2.1.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 100.0\n} {abc: 1 1 (100) :xyz}\ndo_test printf-2.1.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 100.0\n} {abc: 1 1 (100.000) :xyz}\ndo_test printf-2.1.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 100.0\n} {abc: 1 1 (0000000100) :xyz}\ndo_test printf-2.1.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 100.0\n} {abc: 1 1 (100.0) :xyz}\ndo_test printf-2.1.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 100.0\n} {abc: 1 1 (1.0e+02) :xyz}\ndo_test printf-2.1.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 100.0\n} {abc: 1 1 (1e+02) :xyz}\ndo_test printf-2.1.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 9.99999\n} {abc: (10.0) :xyz}\ndo_test printf-2.1.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 9.99999\n} {abc: (1.0e+01) :xyz}\ndo_test printf-2.1.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 9.99999\n} {abc: (1e+01) :xyz}\ndo_test printf-2.1.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 9.99999\n} {abc: 1 1 (9.99999) :xyz}\ndo_test printf-2.1.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 9.99999\n} {abc: 1 1 (9.99999) :xyz}\ndo_test printf-2.1.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 9.99999\n} {abc: 1 1 (0009.99999) :xyz}\ndo_test printf-2.1.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 9.99999\n} {abc: 1 1 (10.0) :xyz}\ndo_test printf-2.1.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 9.99999\n} {abc: 1 1 (1.0e+01) :xyz}\ndo_test printf-2.1.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 9.99999\n} {abc: 1 1 (1e+01) :xyz}\ndo_test printf-2.1.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -0.00543\n} {abc: (-0.0) :xyz}\ndo_test printf-2.1.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -0.00543\n} {abc: (-5.4e-03) :xyz}\ndo_test printf-2.1.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -0.00543\n} {abc: (-0.005) :xyz}\ndo_test printf-2.1.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-0.00543) :xyz}\ndo_test printf-2.1.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-0.00543000) :xyz}\ndo_test printf-2.1.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-000.00543) :xyz}\ndo_test printf-2.1.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-0.0) :xyz}\ndo_test printf-2.1.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-5.4e-03) :xyz}\ndo_test printf-2.1.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -0.00543\n} {abc: 1 1 (-0.005) :xyz}\ndo_test printf-2.1.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -1.0\n} {abc: (-1.0) :xyz}\ndo_test printf-2.1.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -1.0\n} {abc: (-1.0e+00) :xyz}\ndo_test printf-2.1.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -1.0\n} {abc: (-1) :xyz}\ndo_test printf-2.1.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -1.0\n} {abc: 1 1 (-1) :xyz}\ndo_test printf-2.1.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -1.0\n} {abc: 1 1 (-1.00000) :xyz}\ndo_test printf-2.1.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -1.0\n} {abc: 1 1 (-000000001) :xyz}\ndo_test printf-2.1.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -1.0\n} {abc: 1 1 (-1.0) :xyz}\ndo_test printf-2.1.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -1.0\n} {abc: 1 1 (-1.0e+00) :xyz}\ndo_test printf-2.1.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -1.0\n} {abc: 1 1 (-1) :xyz}\ndo_test printf-2.1.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -99.99999\n} {abc: (-100.0) :xyz}\ndo_test printf-2.1.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -99.99999\n} {abc: (-1.0e+02) :xyz}\ndo_test printf-2.1.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -99.99999\n} {abc: (-1e+02) :xyz}\ndo_test printf-2.1.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-100) :xyz}\ndo_test printf-2.1.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-100.000) :xyz}\ndo_test printf-2.1.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-000000100) :xyz}\ndo_test printf-2.1.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-100.0) :xyz}\ndo_test printf-2.1.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-1.0e+02) :xyz}\ndo_test printf-2.1.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -99.99999\n} {abc: 1 1 (-1e+02) :xyz}\ndo_test printf-2.1.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 3.14e+9\n} {abc: (3140000000.0) :xyz}\ndo_test printf-2.1.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 3.14e+9\n} {abc: (3.1e+09) :xyz}\ndo_test printf-2.1.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 3.14e+9\n} {abc: (3e+09) :xyz}\ndo_test printf-2.1.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (3.14e+09) :xyz}\ndo_test printf-2.1.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (3.14000e+09) :xyz}\ndo_test printf-2.1.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (003.14e+09) :xyz}\ndo_test printf-2.1.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (3140000000.0) :xyz}\ndo_test printf-2.1.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (3.1e+09) :xyz}\ndo_test printf-2.1.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 3.14e+9\n} {abc: 1 1 (3e+09) :xyz}\ndo_test printf-2.1.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -4.72732e+88\n} {abc: (-4.7e+88) :xyz}\ndo_test printf-2.1.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -4.72732e+88\n} {abc: (-5e+88) :xyz}\ndo_test printf-2.1.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -4.72732e+88\n} {abc: 1 1 (-4.72732e+88) :xyz}\ndo_test printf-2.1.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -4.72732e+88\n} {abc: 1 1 (-4.72732e+88) :xyz}\ndo_test printf-2.1.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -4.72732e+88\n} {abc: 1 1 (-4.72732e+88) :xyz}\ndo_test printf-2.1.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -4.72732e+88\n} {abc: 1 1 (-4.7e+88) :xyz}\ndo_test printf-2.1.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -4.72732e+88\n} {abc: 1 1 (-5e+88) :xyz}\ndo_test printf-2.1.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 9.87991e+143\n} {abc: (9.9e+143) :xyz}\ndo_test printf-2.1.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 9.87991e+143\n} {abc: (1e+144) :xyz}\ndo_test printf-2.1.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 9.87991e+143\n} {abc: 1 1 (9.87991e+143) :xyz}\ndo_test printf-2.1.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 9.87991e+143\n} {abc: 1 1 (9.87991e+143) :xyz}\ndo_test printf-2.1.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 9.87991e+143\n} {abc: 1 1 (9.87991e+143) :xyz}\ndo_test printf-2.1.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 9.87991e+143\n} {abc: 1 1 (9.9e+143) :xyz}\ndo_test printf-2.1.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 9.87991e+143\n} {abc: 1 1 (1e+144) :xyz}\ndo_test printf-2.1.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 -6.287291e-9\n} {abc: (-0.0) :xyz}\ndo_test printf-2.1.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 -6.287291e-9\n} {abc: (-6.3e-09) :xyz}\ndo_test printf-2.1.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 -6.287291e-9\n} {abc: (-6e-09) :xyz}\ndo_test printf-2.1.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-6.28729e-09) :xyz}\ndo_test printf-2.1.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-6.28729e-09) :xyz}\ndo_test printf-2.1.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-6.28729e-09) :xyz}\ndo_test printf-2.1.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-0.0) :xyz}\ndo_test printf-2.1.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-6.3e-09) :xyz}\ndo_test printf-2.1.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 -6.287291e-9\n} {abc: 1 1 (-6e-09) :xyz}\ndo_test printf-2.1.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 1 1 3.38826392e-110\n} {abc: (0.0) :xyz}\ndo_test printf-2.1.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 1 1 3.38826392e-110\n} {abc: (3.4e-110) :xyz}\ndo_test printf-2.1.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 1 1 3.38826392e-110\n} {abc: (3e-110) :xyz}\ndo_test printf-2.1.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (3.38826e-110) :xyz}\ndo_test printf-2.1.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (3.38826e-110) :xyz}\ndo_test printf-2.1.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (3.38826e-110) :xyz}\ndo_test printf-2.1.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1f) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (0.0) :xyz}\ndo_test printf-2.1.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1e) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (3.4e-110) :xyz}\ndo_test printf-2.1.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%1.1g) :xyz} 1 1 3.38826392e-110\n} {abc: 1 1 (3e-110) :xyz}\ndo_test printf-2.2.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 0.001\n} {abc: (0.00100) :xyz}\ndo_test printf-2.2.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 0.001\n} {abc: (1.00000e-03) :xyz}\ndo_test printf-2.2.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.2.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 0.001\n} {abc: 5 5 (0.001) :xyz}\ndo_test printf-2.2.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 0.001\n} {abc: 5 5 (0.00100000) :xyz}\ndo_test printf-2.2.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 0.001\n} {abc: 5 5 (000000.001) :xyz}\ndo_test printf-2.2.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 0.001\n} {abc: 5 5 (0.00100) :xyz}\ndo_test printf-2.2.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 0.001\n} {abc: 5 5 (1.00000e-03) :xyz}\ndo_test printf-2.2.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 0.001\n} {abc: 5 5 (0.001) :xyz}\ndo_test printf-2.2.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 1.0e-20\n} {abc: (0.00000) :xyz}\ndo_test printf-2.2.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 1.0e-20\n} {abc: (1.00000e-20) :xyz}\ndo_test printf-2.2.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.2.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (1e-20) :xyz}\ndo_test printf-2.2.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (1.00000e-20) :xyz}\ndo_test printf-2.2.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (000001e-20) :xyz}\ndo_test printf-2.2.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (0.00000) :xyz}\ndo_test printf-2.2.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (1.00000e-20) :xyz}\ndo_test printf-2.2.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 1.0e-20\n} {abc: 5 5 (1e-20) :xyz}\ndo_test printf-2.2.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 1.0\n} {abc: (1.00000) :xyz}\ndo_test printf-2.2.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 1.0\n} {abc: (1.00000e+00) :xyz}\ndo_test printf-2.2.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 1.0\n} {abc: (    1) :xyz}\ndo_test printf-2.2.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 1.0\n} {abc: 5 5 (1) :xyz}\ndo_test printf-2.2.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 1.0\n} {abc: 5 5 (1.00000) :xyz}\ndo_test printf-2.2.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 1.0\n} {abc: 5 5 (0000000001) :xyz}\ndo_test printf-2.2.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 1.0\n} {abc: 5 5 (1.00000) :xyz}\ndo_test printf-2.2.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 1.0\n} {abc: 5 5 (1.00000e+00) :xyz}\ndo_test printf-2.2.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 1.0\n} {abc: 5 5 (    1) :xyz}\ndo_test printf-2.2.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 0.0\n} {abc: (0.00000) :xyz}\ndo_test printf-2.2.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 0.0\n} {abc: (0.00000e+00) :xyz}\ndo_test printf-2.2.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 0.0\n} {abc: (    0) :xyz}\ndo_test printf-2.2.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 0.0\n} {abc: 5 5 (0) :xyz}\ndo_test printf-2.2.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 0.0\n} {abc: 5 5 (0.00000) :xyz}\ndo_test printf-2.2.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 0.0\n} {abc: 5 5 (0000000000) :xyz}\ndo_test printf-2.2.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 0.0\n} {abc: 5 5 (0.00000) :xyz}\ndo_test printf-2.2.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 0.0\n} {abc: 5 5 (0.00000e+00) :xyz}\ndo_test printf-2.2.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 0.0\n} {abc: 5 5 (    0) :xyz}\ndo_test printf-2.2.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 100.0\n} {abc: (100.00000) :xyz}\ndo_test printf-2.2.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 100.0\n} {abc: (1.00000e+02) :xyz}\ndo_test printf-2.2.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 100.0\n} {abc: (  100) :xyz}\ndo_test printf-2.2.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 100.0\n} {abc: 5 5 (100) :xyz}\ndo_test printf-2.2.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 100.0\n} {abc: 5 5 (100.000) :xyz}\ndo_test printf-2.2.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 100.0\n} {abc: 5 5 (0000000100) :xyz}\ndo_test printf-2.2.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 100.0\n} {abc: 5 5 (100.00000) :xyz}\ndo_test printf-2.2.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 100.0\n} {abc: 5 5 (1.00000e+02) :xyz}\ndo_test printf-2.2.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 100.0\n} {abc: 5 5 (  100) :xyz}\ndo_test printf-2.2.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 9.99999\n} {abc: (9.99999) :xyz}\ndo_test printf-2.2.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 9.99999\n} {abc: (9.99999e+00) :xyz}\ndo_test printf-2.2.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 9.99999\n} {abc: (   10) :xyz}\ndo_test printf-2.2.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 9.99999\n} {abc: 5 5 (9.99999) :xyz}\ndo_test printf-2.2.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 9.99999\n} {abc: 5 5 (9.99999) :xyz}\ndo_test printf-2.2.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 9.99999\n} {abc: 5 5 (0009.99999) :xyz}\ndo_test printf-2.2.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 9.99999\n} {abc: 5 5 (9.99999) :xyz}\ndo_test printf-2.2.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 9.99999\n} {abc: 5 5 (9.99999e+00) :xyz}\ndo_test printf-2.2.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 9.99999\n} {abc: 5 5 (   10) :xyz}\ndo_test printf-2.2.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -0.00543\n} {abc: (-0.00543) :xyz}\ndo_test printf-2.2.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -0.00543\n} {abc: (-5.43000e-03) :xyz}\ndo_test printf-2.2.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -0.00543\n} {abc: (-0.00543) :xyz}\ndo_test printf-2.2.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-0.00543) :xyz}\ndo_test printf-2.2.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-0.00543000) :xyz}\ndo_test printf-2.2.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-000.00543) :xyz}\ndo_test printf-2.2.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-0.00543) :xyz}\ndo_test printf-2.2.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-5.43000e-03) :xyz}\ndo_test printf-2.2.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -0.00543\n} {abc: 5 5 (-0.00543) :xyz}\ndo_test printf-2.2.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -1.0\n} {abc: (-1.00000) :xyz}\ndo_test printf-2.2.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -1.0\n} {abc: (-1.00000e+00) :xyz}\ndo_test printf-2.2.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -1.0\n} {abc: (   -1) :xyz}\ndo_test printf-2.2.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -1.0\n} {abc: 5 5 (-1) :xyz}\ndo_test printf-2.2.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -1.0\n} {abc: 5 5 (-1.00000) :xyz}\ndo_test printf-2.2.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -1.0\n} {abc: 5 5 (-000000001) :xyz}\ndo_test printf-2.2.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -1.0\n} {abc: 5 5 (-1.00000) :xyz}\ndo_test printf-2.2.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -1.0\n} {abc: 5 5 (-1.00000e+00) :xyz}\ndo_test printf-2.2.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -1.0\n} {abc: 5 5 (   -1) :xyz}\ndo_test printf-2.2.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -99.99999\n} {abc: (-99.99999) :xyz}\ndo_test printf-2.2.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -99.99999\n} {abc: (-1.00000e+02) :xyz}\ndo_test printf-2.2.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -99.99999\n} {abc: ( -100) :xyz}\ndo_test printf-2.2.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -99.99999\n} {abc: 5 5 (-100) :xyz}\ndo_test printf-2.2.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -99.99999\n} {abc: 5 5 (-100.000) :xyz}\ndo_test printf-2.2.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -99.99999\n} {abc: 5 5 (-000000100) :xyz}\ndo_test printf-2.2.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -99.99999\n} {abc: 5 5 (-99.99999) :xyz}\ndo_test printf-2.2.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -99.99999\n} {abc: 5 5 (-1.00000e+02) :xyz}\ndo_test printf-2.2.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -99.99999\n} {abc: 5 5 ( -100) :xyz}\ndo_test printf-2.2.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 3.14e+9\n} {abc: (3140000000.00000) :xyz}\ndo_test printf-2.2.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 3.14e+9\n} {abc: (3.14000e+09) :xyz}\ndo_test printf-2.2.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 3.14e+9\n} {abc: (3.14e+09) :xyz}\ndo_test printf-2.2.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (3.14e+09) :xyz}\ndo_test printf-2.2.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (3.14000e+09) :xyz}\ndo_test printf-2.2.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (003.14e+09) :xyz}\ndo_test printf-2.2.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (3140000000.00000) :xyz}\ndo_test printf-2.2.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (3.14000e+09) :xyz}\ndo_test printf-2.2.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 3.14e+9\n} {abc: 5 5 (3.14e+09) :xyz}\ndo_test printf-2.2.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -4.72732e+88\n} {abc: (-4.72732e+88) :xyz}\ndo_test printf-2.2.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -4.72732e+88\n} {abc: (-4.7273e+88) :xyz}\ndo_test printf-2.2.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -4.72732e+88\n} {abc: 5 5 (-4.72732e+88) :xyz}\ndo_test printf-2.2.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -4.72732e+88\n} {abc: 5 5 (-4.72732e+88) :xyz}\ndo_test printf-2.2.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -4.72732e+88\n} {abc: 5 5 (-4.72732e+88) :xyz}\ndo_test printf-2.2.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -4.72732e+88\n} {abc: 5 5 (-4.72732e+88) :xyz}\ndo_test printf-2.2.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -4.72732e+88\n} {abc: 5 5 (-4.7273e+88) :xyz}\ndo_test printf-2.2.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 9.87991e+143\n} {abc: (9.87991e+143) :xyz}\ndo_test printf-2.2.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 9.87991e+143\n} {abc: (9.8799e+143) :xyz}\ndo_test printf-2.2.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 9.87991e+143\n} {abc: 5 5 (9.87991e+143) :xyz}\ndo_test printf-2.2.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 9.87991e+143\n} {abc: 5 5 (9.87991e+143) :xyz}\ndo_test printf-2.2.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 9.87991e+143\n} {abc: 5 5 (9.87991e+143) :xyz}\ndo_test printf-2.2.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 9.87991e+143\n} {abc: 5 5 (9.87991e+143) :xyz}\ndo_test printf-2.2.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 9.87991e+143\n} {abc: 5 5 (9.8799e+143) :xyz}\ndo_test printf-2.2.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 -6.287291e-9\n} {abc: (-0.00000) :xyz}\ndo_test printf-2.2.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 -6.287291e-9\n} {abc: (-6.28729e-09) :xyz}\ndo_test printf-2.2.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 -6.287291e-9\n} {abc: (-6.2873e-09) :xyz}\ndo_test printf-2.2.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-6.28729e-09) :xyz}\ndo_test printf-2.2.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-6.28729e-09) :xyz}\ndo_test printf-2.2.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-6.28729e-09) :xyz}\ndo_test printf-2.2.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-0.00000) :xyz}\ndo_test printf-2.2.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-6.28729e-09) :xyz}\ndo_test printf-2.2.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 -6.287291e-9\n} {abc: 5 5 (-6.2873e-09) :xyz}\ndo_test printf-2.2.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 5 5 3.38826392e-110\n} {abc: (0.00000) :xyz}\ndo_test printf-2.2.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 5 5 3.38826392e-110\n} {abc: (3.38826e-110) :xyz}\ndo_test printf-2.2.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 5 5 3.38826392e-110\n} {abc: (3.3883e-110) :xyz}\ndo_test printf-2.2.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (3.38826e-110) :xyz}\ndo_test printf-2.2.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (3.38826e-110) :xyz}\ndo_test printf-2.2.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (3.38826e-110) :xyz}\ndo_test printf-2.2.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5f) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (0.00000) :xyz}\ndo_test printf-2.2.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5e) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (3.38826e-110) :xyz}\ndo_test printf-2.2.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%5.5g) :xyz} 5 5 3.38826392e-110\n} {abc: 5 5 (3.3883e-110) :xyz}\ndo_test printf-2.3.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 0.001\n} {abc: (0.0010000000) :xyz}\ndo_test printf-2.3.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 0.001\n} {abc: (1.0000000000e-03) :xyz}\ndo_test printf-2.3.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 0.001\n} {abc: (     0.001) :xyz}\ndo_test printf-2.3.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 0.001\n} {abc: 10 10 (0.001) :xyz}\ndo_test printf-2.3.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 0.001\n} {abc: 10 10 (0.00100000) :xyz}\ndo_test printf-2.3.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 0.001\n} {abc: 10 10 (000000.001) :xyz}\ndo_test printf-2.3.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 0.001\n} {abc: 10 10 (0.0010000000) :xyz}\ndo_test printf-2.3.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 0.001\n} {abc: 10 10 (1.0000000000e-03) :xyz}\ndo_test printf-2.3.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 0.001\n} {abc: 10 10 (     0.001) :xyz}\ndo_test printf-2.3.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 1.0e-20\n} {abc: (0.0000000000) :xyz}\ndo_test printf-2.3.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 1.0e-20\n} {abc: (1.0000000000e-20) :xyz}\ndo_test printf-2.3.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 1.0e-20\n} {abc: (     1e-20) :xyz}\ndo_test printf-2.3.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (1e-20) :xyz}\ndo_test printf-2.3.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (1.00000e-20) :xyz}\ndo_test printf-2.3.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (000001e-20) :xyz}\ndo_test printf-2.3.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (0.0000000000) :xyz}\ndo_test printf-2.3.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (1.0000000000e-20) :xyz}\ndo_test printf-2.3.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 1.0e-20\n} {abc: 10 10 (     1e-20) :xyz}\ndo_test printf-2.3.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 1.0\n} {abc: (1.0000000000) :xyz}\ndo_test printf-2.3.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 1.0\n} {abc: (1.0000000000e+00) :xyz}\ndo_test printf-2.3.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 1.0\n} {abc: (         1) :xyz}\ndo_test printf-2.3.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 1.0\n} {abc: 10 10 (1) :xyz}\ndo_test printf-2.3.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 1.0\n} {abc: 10 10 (1.00000) :xyz}\ndo_test printf-2.3.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 1.0\n} {abc: 10 10 (0000000001) :xyz}\ndo_test printf-2.3.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 1.0\n} {abc: 10 10 (1.0000000000) :xyz}\ndo_test printf-2.3.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 1.0\n} {abc: 10 10 (1.0000000000e+00) :xyz}\ndo_test printf-2.3.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 1.0\n} {abc: 10 10 (         1) :xyz}\ndo_test printf-2.3.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 0.0\n} {abc: (0.0000000000) :xyz}\ndo_test printf-2.3.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 0.0\n} {abc: (0.0000000000e+00) :xyz}\ndo_test printf-2.3.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 0.0\n} {abc: (         0) :xyz}\ndo_test printf-2.3.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 0.0\n} {abc: 10 10 (0) :xyz}\ndo_test printf-2.3.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 0.0\n} {abc: 10 10 (0.00000) :xyz}\ndo_test printf-2.3.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 0.0\n} {abc: 10 10 (0000000000) :xyz}\ndo_test printf-2.3.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 0.0\n} {abc: 10 10 (0.0000000000) :xyz}\ndo_test printf-2.3.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 0.0\n} {abc: 10 10 (0.0000000000e+00) :xyz}\ndo_test printf-2.3.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 0.0\n} {abc: 10 10 (         0) :xyz}\ndo_test printf-2.3.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 100.0\n} {abc: (100.0000000000) :xyz}\ndo_test printf-2.3.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 100.0\n} {abc: (1.0000000000e+02) :xyz}\ndo_test printf-2.3.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 100.0\n} {abc: (       100) :xyz}\ndo_test printf-2.3.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 100.0\n} {abc: 10 10 (100) :xyz}\ndo_test printf-2.3.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 100.0\n} {abc: 10 10 (100.000) :xyz}\ndo_test printf-2.3.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 100.0\n} {abc: 10 10 (0000000100) :xyz}\ndo_test printf-2.3.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 100.0\n} {abc: 10 10 (100.0000000000) :xyz}\ndo_test printf-2.3.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 100.0\n} {abc: 10 10 (1.0000000000e+02) :xyz}\ndo_test printf-2.3.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 100.0\n} {abc: 10 10 (       100) :xyz}\ndo_test printf-2.3.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 9.99999\n} {abc: (9.9999900000) :xyz}\ndo_test printf-2.3.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 9.99999\n} {abc: (9.9999900000e+00) :xyz}\ndo_test printf-2.3.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 9.99999\n} {abc: (   9.99999) :xyz}\ndo_test printf-2.3.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 9.99999\n} {abc: 10 10 (9.99999) :xyz}\ndo_test printf-2.3.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 9.99999\n} {abc: 10 10 (9.99999) :xyz}\ndo_test printf-2.3.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 9.99999\n} {abc: 10 10 (0009.99999) :xyz}\ndo_test printf-2.3.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 9.99999\n} {abc: 10 10 (9.9999900000) :xyz}\ndo_test printf-2.3.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 9.99999\n} {abc: 10 10 (9.9999900000e+00) :xyz}\ndo_test printf-2.3.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 9.99999\n} {abc: 10 10 (   9.99999) :xyz}\ndo_test printf-2.3.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -0.00543\n} {abc: (-0.0054300000) :xyz}\ndo_test printf-2.3.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -0.00543\n} {abc: (-5.4300000000e-03) :xyz}\ndo_test printf-2.3.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -0.00543\n} {abc: (  -0.00543) :xyz}\ndo_test printf-2.3.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -0.00543\n} {abc: 10 10 (-0.00543) :xyz}\ndo_test printf-2.3.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -0.00543\n} {abc: 10 10 (-0.00543000) :xyz}\ndo_test printf-2.3.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -0.00543\n} {abc: 10 10 (-000.00543) :xyz}\ndo_test printf-2.3.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -0.00543\n} {abc: 10 10 (-0.0054300000) :xyz}\ndo_test printf-2.3.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -0.00543\n} {abc: 10 10 (-5.4300000000e-03) :xyz}\ndo_test printf-2.3.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -0.00543\n} {abc: 10 10 (  -0.00543) :xyz}\ndo_test printf-2.3.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -1.0\n} {abc: (-1.0000000000) :xyz}\ndo_test printf-2.3.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -1.0\n} {abc: (-1.0000000000e+00) :xyz}\ndo_test printf-2.3.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -1.0\n} {abc: (        -1) :xyz}\ndo_test printf-2.3.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -1.0\n} {abc: 10 10 (-1) :xyz}\ndo_test printf-2.3.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -1.0\n} {abc: 10 10 (-1.00000) :xyz}\ndo_test printf-2.3.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -1.0\n} {abc: 10 10 (-000000001) :xyz}\ndo_test printf-2.3.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -1.0\n} {abc: 10 10 (-1.0000000000) :xyz}\ndo_test printf-2.3.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -1.0\n} {abc: 10 10 (-1.0000000000e+00) :xyz}\ndo_test printf-2.3.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -1.0\n} {abc: 10 10 (        -1) :xyz}\ndo_test printf-2.3.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -99.99999\n} {abc: (-99.9999900000) :xyz}\ndo_test printf-2.3.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -99.99999\n} {abc: (-9.9999990000e+01) :xyz}\ndo_test printf-2.3.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -99.99999\n} {abc: ( -99.99999) :xyz}\ndo_test printf-2.3.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -99.99999\n} {abc: 10 10 (-100) :xyz}\ndo_test printf-2.3.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -99.99999\n} {abc: 10 10 (-100.000) :xyz}\ndo_test printf-2.3.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -99.99999\n} {abc: 10 10 (-000000100) :xyz}\ndo_test printf-2.3.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -99.99999\n} {abc: 10 10 (-99.9999900000) :xyz}\ndo_test printf-2.3.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -99.99999\n} {abc: 10 10 (-9.9999990000e+01) :xyz}\ndo_test printf-2.3.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -99.99999\n} {abc: 10 10 ( -99.99999) :xyz}\ndo_test printf-2.3.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 3.14e+9\n} {abc: (3140000000.0000000000) :xyz}\ndo_test printf-2.3.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 3.14e+9\n} {abc: (3.1400000000e+09) :xyz}\ndo_test printf-2.3.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 3.14e+9\n} {abc: (3140000000) :xyz}\ndo_test printf-2.3.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (3.14e+09) :xyz}\ndo_test printf-2.3.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (3.14000e+09) :xyz}\ndo_test printf-2.3.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (003.14e+09) :xyz}\ndo_test printf-2.3.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (3140000000.0000000000) :xyz}\ndo_test printf-2.3.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (3.1400000000e+09) :xyz}\ndo_test printf-2.3.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 3.14e+9\n} {abc: 10 10 (3140000000) :xyz}\ndo_test printf-2.3.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -4.72732e+88\n} {abc: (-4.7273200000e+88) :xyz}\ndo_test printf-2.3.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -4.72732e+88\n} {abc: (-4.72732e+88) :xyz}\ndo_test printf-2.3.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -4.72732e+88\n} {abc: 10 10 (-4.72732e+88) :xyz}\ndo_test printf-2.3.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -4.72732e+88\n} {abc: 10 10 (-4.72732e+88) :xyz}\ndo_test printf-2.3.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -4.72732e+88\n} {abc: 10 10 (-4.72732e+88) :xyz}\ndo_test printf-2.3.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -4.72732e+88\n} {abc: 10 10 (-4.7273200000e+88) :xyz}\ndo_test printf-2.3.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -4.72732e+88\n} {abc: 10 10 (-4.72732e+88) :xyz}\ndo_test printf-2.3.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 9.87991e+143\n} {abc: (9.8799100000e+143) :xyz}\ndo_test printf-2.3.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 9.87991e+143\n} {abc: (9.87991e+143) :xyz}\ndo_test printf-2.3.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 9.87991e+143\n} {abc: 10 10 (9.87991e+143) :xyz}\ndo_test printf-2.3.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 9.87991e+143\n} {abc: 10 10 (9.87991e+143) :xyz}\ndo_test printf-2.3.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 9.87991e+143\n} {abc: 10 10 (9.87991e+143) :xyz}\ndo_test printf-2.3.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 9.87991e+143\n} {abc: 10 10 (9.8799100000e+143) :xyz}\ndo_test printf-2.3.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 9.87991e+143\n} {abc: 10 10 (9.87991e+143) :xyz}\ndo_test printf-2.3.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 -6.287291e-9\n} {abc: (-0.0000000063) :xyz}\ndo_test printf-2.3.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 -6.287291e-9\n} {abc: (-6.2872910000e-09) :xyz}\ndo_test printf-2.3.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 -6.287291e-9\n} {abc: (-6.287291e-09) :xyz}\ndo_test printf-2.3.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-6.28729e-09) :xyz}\ndo_test printf-2.3.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-6.28729e-09) :xyz}\ndo_test printf-2.3.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-6.28729e-09) :xyz}\ndo_test printf-2.3.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-0.0000000063) :xyz}\ndo_test printf-2.3.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-6.2872910000e-09) :xyz}\ndo_test printf-2.3.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 -6.287291e-9\n} {abc: 10 10 (-6.287291e-09) :xyz}\ndo_test printf-2.3.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 10 3.38826392e-110\n} {abc: (0.0000000000) :xyz}\ndo_test printf-2.3.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 10 3.38826392e-110\n} {abc: (3.3882639200e-110) :xyz}\ndo_test printf-2.3.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 10 3.38826392e-110\n} {abc: (3.38826392e-110) :xyz}\ndo_test printf-2.3.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (3.38826e-110) :xyz}\ndo_test printf-2.3.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (3.38826e-110) :xyz}\ndo_test printf-2.3.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (3.38826e-110) :xyz}\ndo_test printf-2.3.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10f) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (0.0000000000) :xyz}\ndo_test printf-2.3.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10e) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (3.3882639200e-110) :xyz}\ndo_test printf-2.3.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.10g) :xyz} 10 10 3.38826392e-110\n} {abc: 10 10 (3.38826392e-110) :xyz}\ndo_test printf-2.4.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 0.001\n} {abc: (   0.00100) :xyz}\ndo_test printf-2.4.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 0.001\n} {abc: (1.00000e-03) :xyz}\ndo_test printf-2.4.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 0.001\n} {abc: (     0.001) :xyz}\ndo_test printf-2.4.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 0.001\n} {abc: 10 5 (0.001) :xyz}\ndo_test printf-2.4.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 0.001\n} {abc: 10 5 (0.00100000) :xyz}\ndo_test printf-2.4.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 0.001\n} {abc: 10 5 (000000.001) :xyz}\ndo_test printf-2.4.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 0.001\n} {abc: 10 5 (   0.00100) :xyz}\ndo_test printf-2.4.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 0.001\n} {abc: 10 5 (1.00000e-03) :xyz}\ndo_test printf-2.4.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 0.001\n} {abc: 10 5 (     0.001) :xyz}\ndo_test printf-2.4.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 1.0e-20\n} {abc: (   0.00000) :xyz}\ndo_test printf-2.4.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 1.0e-20\n} {abc: (1.00000e-20) :xyz}\ndo_test printf-2.4.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 1.0e-20\n} {abc: (     1e-20) :xyz}\ndo_test printf-2.4.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (1e-20) :xyz}\ndo_test printf-2.4.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (1.00000e-20) :xyz}\ndo_test printf-2.4.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (000001e-20) :xyz}\ndo_test printf-2.4.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (   0.00000) :xyz}\ndo_test printf-2.4.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (1.00000e-20) :xyz}\ndo_test printf-2.4.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 1.0e-20\n} {abc: 10 5 (     1e-20) :xyz}\ndo_test printf-2.4.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 1.0\n} {abc: (   1.00000) :xyz}\ndo_test printf-2.4.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 1.0\n} {abc: (1.00000e+00) :xyz}\ndo_test printf-2.4.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 1.0\n} {abc: (         1) :xyz}\ndo_test printf-2.4.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 1.0\n} {abc: 10 5 (1) :xyz}\ndo_test printf-2.4.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 1.0\n} {abc: 10 5 (1.00000) :xyz}\ndo_test printf-2.4.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 1.0\n} {abc: 10 5 (0000000001) :xyz}\ndo_test printf-2.4.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 1.0\n} {abc: 10 5 (   1.00000) :xyz}\ndo_test printf-2.4.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 1.0\n} {abc: 10 5 (1.00000e+00) :xyz}\ndo_test printf-2.4.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 1.0\n} {abc: 10 5 (         1) :xyz}\ndo_test printf-2.4.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 0.0\n} {abc: (   0.00000) :xyz}\ndo_test printf-2.4.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 0.0\n} {abc: (0.00000e+00) :xyz}\ndo_test printf-2.4.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 0.0\n} {abc: (         0) :xyz}\ndo_test printf-2.4.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 0.0\n} {abc: 10 5 (0) :xyz}\ndo_test printf-2.4.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 0.0\n} {abc: 10 5 (0.00000) :xyz}\ndo_test printf-2.4.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 0.0\n} {abc: 10 5 (0000000000) :xyz}\ndo_test printf-2.4.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 0.0\n} {abc: 10 5 (   0.00000) :xyz}\ndo_test printf-2.4.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 0.0\n} {abc: 10 5 (0.00000e+00) :xyz}\ndo_test printf-2.4.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 0.0\n} {abc: 10 5 (         0) :xyz}\ndo_test printf-2.4.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 100.0\n} {abc: ( 100.00000) :xyz}\ndo_test printf-2.4.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 100.0\n} {abc: (1.00000e+02) :xyz}\ndo_test printf-2.4.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 100.0\n} {abc: (       100) :xyz}\ndo_test printf-2.4.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 100.0\n} {abc: 10 5 (100) :xyz}\ndo_test printf-2.4.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 100.0\n} {abc: 10 5 (100.000) :xyz}\ndo_test printf-2.4.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 100.0\n} {abc: 10 5 (0000000100) :xyz}\ndo_test printf-2.4.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 100.0\n} {abc: 10 5 ( 100.00000) :xyz}\ndo_test printf-2.4.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 100.0\n} {abc: 10 5 (1.00000e+02) :xyz}\ndo_test printf-2.4.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 100.0\n} {abc: 10 5 (       100) :xyz}\ndo_test printf-2.4.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 9.99999\n} {abc: (   9.99999) :xyz}\ndo_test printf-2.4.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 9.99999\n} {abc: (9.99999e+00) :xyz}\ndo_test printf-2.4.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 9.99999\n} {abc: (        10) :xyz}\ndo_test printf-2.4.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 9.99999\n} {abc: 10 5 (9.99999) :xyz}\ndo_test printf-2.4.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 9.99999\n} {abc: 10 5 (9.99999) :xyz}\ndo_test printf-2.4.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 9.99999\n} {abc: 10 5 (0009.99999) :xyz}\ndo_test printf-2.4.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 9.99999\n} {abc: 10 5 (   9.99999) :xyz}\ndo_test printf-2.4.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 9.99999\n} {abc: 10 5 (9.99999e+00) :xyz}\ndo_test printf-2.4.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 9.99999\n} {abc: 10 5 (        10) :xyz}\ndo_test printf-2.4.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -0.00543\n} {abc: (  -0.00543) :xyz}\ndo_test printf-2.4.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -0.00543\n} {abc: (-5.43000e-03) :xyz}\ndo_test printf-2.4.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -0.00543\n} {abc: (  -0.00543) :xyz}\ndo_test printf-2.4.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -0.00543\n} {abc: 10 5 (-0.00543) :xyz}\ndo_test printf-2.4.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -0.00543\n} {abc: 10 5 (-0.00543000) :xyz}\ndo_test printf-2.4.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -0.00543\n} {abc: 10 5 (-000.00543) :xyz}\ndo_test printf-2.4.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -0.00543\n} {abc: 10 5 (  -0.00543) :xyz}\ndo_test printf-2.4.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -0.00543\n} {abc: 10 5 (-5.43000e-03) :xyz}\ndo_test printf-2.4.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -0.00543\n} {abc: 10 5 (  -0.00543) :xyz}\ndo_test printf-2.4.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -1.0\n} {abc: (  -1.00000) :xyz}\ndo_test printf-2.4.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -1.0\n} {abc: (-1.00000e+00) :xyz}\ndo_test printf-2.4.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -1.0\n} {abc: (        -1) :xyz}\ndo_test printf-2.4.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -1.0\n} {abc: 10 5 (-1) :xyz}\ndo_test printf-2.4.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -1.0\n} {abc: 10 5 (-1.00000) :xyz}\ndo_test printf-2.4.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -1.0\n} {abc: 10 5 (-000000001) :xyz}\ndo_test printf-2.4.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -1.0\n} {abc: 10 5 (  -1.00000) :xyz}\ndo_test printf-2.4.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -1.0\n} {abc: 10 5 (-1.00000e+00) :xyz}\ndo_test printf-2.4.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -1.0\n} {abc: 10 5 (        -1) :xyz}\ndo_test printf-2.4.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -99.99999\n} {abc: ( -99.99999) :xyz}\ndo_test printf-2.4.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -99.99999\n} {abc: (-1.00000e+02) :xyz}\ndo_test printf-2.4.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -99.99999\n} {abc: (      -100) :xyz}\ndo_test printf-2.4.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -99.99999\n} {abc: 10 5 (-100) :xyz}\ndo_test printf-2.4.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -99.99999\n} {abc: 10 5 (-100.000) :xyz}\ndo_test printf-2.4.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -99.99999\n} {abc: 10 5 (-000000100) :xyz}\ndo_test printf-2.4.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -99.99999\n} {abc: 10 5 ( -99.99999) :xyz}\ndo_test printf-2.4.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -99.99999\n} {abc: 10 5 (-1.00000e+02) :xyz}\ndo_test printf-2.4.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -99.99999\n} {abc: 10 5 (      -100) :xyz}\ndo_test printf-2.4.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 3.14e+9\n} {abc: (3140000000.00000) :xyz}\ndo_test printf-2.4.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 3.14e+9\n} {abc: (3.14000e+09) :xyz}\ndo_test printf-2.4.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 3.14e+9\n} {abc: (  3.14e+09) :xyz}\ndo_test printf-2.4.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (3.14e+09) :xyz}\ndo_test printf-2.4.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (3.14000e+09) :xyz}\ndo_test printf-2.4.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (003.14e+09) :xyz}\ndo_test printf-2.4.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (3140000000.00000) :xyz}\ndo_test printf-2.4.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (3.14000e+09) :xyz}\ndo_test printf-2.4.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 3.14e+9\n} {abc: 10 5 (  3.14e+09) :xyz}\ndo_test printf-2.4.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -4.72732e+88\n} {abc: (-4.72732e+88) :xyz}\ndo_test printf-2.4.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -4.72732e+88\n} {abc: (-4.7273e+88) :xyz}\ndo_test printf-2.4.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -4.72732e+88\n} {abc: 10 5 (-4.72732e+88) :xyz}\ndo_test printf-2.4.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -4.72732e+88\n} {abc: 10 5 (-4.72732e+88) :xyz}\ndo_test printf-2.4.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -4.72732e+88\n} {abc: 10 5 (-4.72732e+88) :xyz}\ndo_test printf-2.4.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -4.72732e+88\n} {abc: 10 5 (-4.72732e+88) :xyz}\ndo_test printf-2.4.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -4.72732e+88\n} {abc: 10 5 (-4.7273e+88) :xyz}\ndo_test printf-2.4.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 9.87991e+143\n} {abc: (9.87991e+143) :xyz}\ndo_test printf-2.4.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 9.87991e+143\n} {abc: (9.8799e+143) :xyz}\ndo_test printf-2.4.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 9.87991e+143\n} {abc: 10 5 (9.87991e+143) :xyz}\ndo_test printf-2.4.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 9.87991e+143\n} {abc: 10 5 (9.87991e+143) :xyz}\ndo_test printf-2.4.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 9.87991e+143\n} {abc: 10 5 (9.87991e+143) :xyz}\ndo_test printf-2.4.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 9.87991e+143\n} {abc: 10 5 (9.87991e+143) :xyz}\ndo_test printf-2.4.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 9.87991e+143\n} {abc: 10 5 (9.8799e+143) :xyz}\ndo_test printf-2.4.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 -6.287291e-9\n} {abc: (  -0.00000) :xyz}\ndo_test printf-2.4.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 -6.287291e-9\n} {abc: (-6.28729e-09) :xyz}\ndo_test printf-2.4.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 -6.287291e-9\n} {abc: (-6.2873e-09) :xyz}\ndo_test printf-2.4.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (-6.28729e-09) :xyz}\ndo_test printf-2.4.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (-6.28729e-09) :xyz}\ndo_test printf-2.4.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (-6.28729e-09) :xyz}\ndo_test printf-2.4.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (  -0.00000) :xyz}\ndo_test printf-2.4.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (-6.28729e-09) :xyz}\ndo_test printf-2.4.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 -6.287291e-9\n} {abc: 10 5 (-6.2873e-09) :xyz}\ndo_test printf-2.4.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 10 5 3.38826392e-110\n} {abc: (   0.00000) :xyz}\ndo_test printf-2.4.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 10 5 3.38826392e-110\n} {abc: (3.38826e-110) :xyz}\ndo_test printf-2.4.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 10 5 3.38826392e-110\n} {abc: (3.3883e-110) :xyz}\ndo_test printf-2.4.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (3.38826e-110) :xyz}\ndo_test printf-2.4.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (3.38826e-110) :xyz}\ndo_test printf-2.4.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (3.38826e-110) :xyz}\ndo_test printf-2.4.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5f) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (   0.00000) :xyz}\ndo_test printf-2.4.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5e) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (3.38826e-110) :xyz}\ndo_test printf-2.4.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%10.5g) :xyz} 10 5 3.38826392e-110\n} {abc: 10 5 (3.3883e-110) :xyz}\ndo_test printf-2.5.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 0.001\n} {abc: (0.00) :xyz}\ndo_test printf-2.5.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 0.001\n} {abc: (1.00e-03) :xyz}\ndo_test printf-2.5.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.5.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 0.001\n} {abc: 2 2 (0.001) :xyz}\ndo_test printf-2.5.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 0.001\n} {abc: 2 2 (0.00100000) :xyz}\ndo_test printf-2.5.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 0.001\n} {abc: 2 2 (000000.001) :xyz}\ndo_test printf-2.5.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 0.001\n} {abc: 2 2 (0.00) :xyz}\ndo_test printf-2.5.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 0.001\n} {abc: 2 2 (1.00e-03) :xyz}\ndo_test printf-2.5.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 0.001\n} {abc: 2 2 (0.001) :xyz}\ndo_test printf-2.5.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 1.0e-20\n} {abc: (0.00) :xyz}\ndo_test printf-2.5.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 1.0e-20\n} {abc: (1.00e-20) :xyz}\ndo_test printf-2.5.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.5.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (1e-20) :xyz}\ndo_test printf-2.5.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (1.00000e-20) :xyz}\ndo_test printf-2.5.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (000001e-20) :xyz}\ndo_test printf-2.5.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (0.00) :xyz}\ndo_test printf-2.5.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (1.00e-20) :xyz}\ndo_test printf-2.5.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 1.0e-20\n} {abc: 2 2 (1e-20) :xyz}\ndo_test printf-2.5.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 1.0\n} {abc: (1.00) :xyz}\ndo_test printf-2.5.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 1.0\n} {abc: (1.00e+00) :xyz}\ndo_test printf-2.5.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 1.0\n} {abc: ( 1) :xyz}\ndo_test printf-2.5.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 1.0\n} {abc: 2 2 (1) :xyz}\ndo_test printf-2.5.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 1.0\n} {abc: 2 2 (1.00000) :xyz}\ndo_test printf-2.5.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 1.0\n} {abc: 2 2 (0000000001) :xyz}\ndo_test printf-2.5.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 1.0\n} {abc: 2 2 (1.00) :xyz}\ndo_test printf-2.5.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 1.0\n} {abc: 2 2 (1.00e+00) :xyz}\ndo_test printf-2.5.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 1.0\n} {abc: 2 2 ( 1) :xyz}\ndo_test printf-2.5.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 0.0\n} {abc: (0.00) :xyz}\ndo_test printf-2.5.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 0.0\n} {abc: (0.00e+00) :xyz}\ndo_test printf-2.5.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 0.0\n} {abc: ( 0) :xyz}\ndo_test printf-2.5.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 0.0\n} {abc: 2 2 (0) :xyz}\ndo_test printf-2.5.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 0.0\n} {abc: 2 2 (0.00000) :xyz}\ndo_test printf-2.5.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 0.0\n} {abc: 2 2 (0000000000) :xyz}\ndo_test printf-2.5.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 0.0\n} {abc: 2 2 (0.00) :xyz}\ndo_test printf-2.5.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 0.0\n} {abc: 2 2 (0.00e+00) :xyz}\ndo_test printf-2.5.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 0.0\n} {abc: 2 2 ( 0) :xyz}\ndo_test printf-2.5.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 100.0\n} {abc: (100.00) :xyz}\ndo_test printf-2.5.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 100.0\n} {abc: (1.00e+02) :xyz}\ndo_test printf-2.5.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 100.0\n} {abc: (1e+02) :xyz}\ndo_test printf-2.5.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 100.0\n} {abc: 2 2 (100) :xyz}\ndo_test printf-2.5.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 100.0\n} {abc: 2 2 (100.000) :xyz}\ndo_test printf-2.5.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 100.0\n} {abc: 2 2 (0000000100) :xyz}\ndo_test printf-2.5.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 100.0\n} {abc: 2 2 (100.00) :xyz}\ndo_test printf-2.5.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 100.0\n} {abc: 2 2 (1.00e+02) :xyz}\ndo_test printf-2.5.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 100.0\n} {abc: 2 2 (1e+02) :xyz}\ndo_test printf-2.5.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 9.99999\n} {abc: (10.00) :xyz}\ndo_test printf-2.5.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 9.99999\n} {abc: (1.00e+01) :xyz}\ndo_test printf-2.5.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 9.99999\n} {abc: (10) :xyz}\ndo_test printf-2.5.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 9.99999\n} {abc: 2 2 (9.99999) :xyz}\ndo_test printf-2.5.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 9.99999\n} {abc: 2 2 (9.99999) :xyz}\ndo_test printf-2.5.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 9.99999\n} {abc: 2 2 (0009.99999) :xyz}\ndo_test printf-2.5.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 9.99999\n} {abc: 2 2 (10.00) :xyz}\ndo_test printf-2.5.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 9.99999\n} {abc: 2 2 (1.00e+01) :xyz}\ndo_test printf-2.5.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 9.99999\n} {abc: 2 2 (10) :xyz}\ndo_test printf-2.5.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -0.00543\n} {abc: (-0.01) :xyz}\ndo_test printf-2.5.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -0.00543\n} {abc: (-5.43e-03) :xyz}\ndo_test printf-2.5.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -0.00543\n} {abc: (-0.0054) :xyz}\ndo_test printf-2.5.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-0.00543) :xyz}\ndo_test printf-2.5.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-0.00543000) :xyz}\ndo_test printf-2.5.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-000.00543) :xyz}\ndo_test printf-2.5.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-0.01) :xyz}\ndo_test printf-2.5.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-5.43e-03) :xyz}\ndo_test printf-2.5.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -0.00543\n} {abc: 2 2 (-0.0054) :xyz}\ndo_test printf-2.5.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -1.0\n} {abc: (-1.00) :xyz}\ndo_test printf-2.5.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -1.0\n} {abc: (-1.00e+00) :xyz}\ndo_test printf-2.5.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -1.0\n} {abc: (-1) :xyz}\ndo_test printf-2.5.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -1.0\n} {abc: 2 2 (-1) :xyz}\ndo_test printf-2.5.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -1.0\n} {abc: 2 2 (-1.00000) :xyz}\ndo_test printf-2.5.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -1.0\n} {abc: 2 2 (-000000001) :xyz}\ndo_test printf-2.5.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -1.0\n} {abc: 2 2 (-1.00) :xyz}\ndo_test printf-2.5.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -1.0\n} {abc: 2 2 (-1.00e+00) :xyz}\ndo_test printf-2.5.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -1.0\n} {abc: 2 2 (-1) :xyz}\ndo_test printf-2.5.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -99.99999\n} {abc: (-100.00) :xyz}\ndo_test printf-2.5.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -99.99999\n} {abc: (-1.00e+02) :xyz}\ndo_test printf-2.5.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -99.99999\n} {abc: (-1e+02) :xyz}\ndo_test printf-2.5.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-100) :xyz}\ndo_test printf-2.5.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-100.000) :xyz}\ndo_test printf-2.5.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-000000100) :xyz}\ndo_test printf-2.5.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-100.00) :xyz}\ndo_test printf-2.5.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-1.00e+02) :xyz}\ndo_test printf-2.5.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -99.99999\n} {abc: 2 2 (-1e+02) :xyz}\ndo_test printf-2.5.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 3.14e+9\n} {abc: (3140000000.00) :xyz}\ndo_test printf-2.5.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 3.14e+9\n} {abc: (3.14e+09) :xyz}\ndo_test printf-2.5.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 3.14e+9\n} {abc: (3.1e+09) :xyz}\ndo_test printf-2.5.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (3.14e+09) :xyz}\ndo_test printf-2.5.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (3.14000e+09) :xyz}\ndo_test printf-2.5.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (003.14e+09) :xyz}\ndo_test printf-2.5.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (3140000000.00) :xyz}\ndo_test printf-2.5.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (3.14e+09) :xyz}\ndo_test printf-2.5.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 3.14e+9\n} {abc: 2 2 (3.1e+09) :xyz}\ndo_test printf-2.5.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -4.72732e+88\n} {abc: (-4.73e+88) :xyz}\ndo_test printf-2.5.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -4.72732e+88\n} {abc: (-4.7e+88) :xyz}\ndo_test printf-2.5.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -4.72732e+88\n} {abc: 2 2 (-4.72732e+88) :xyz}\ndo_test printf-2.5.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -4.72732e+88\n} {abc: 2 2 (-4.72732e+88) :xyz}\ndo_test printf-2.5.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -4.72732e+88\n} {abc: 2 2 (-4.72732e+88) :xyz}\ndo_test printf-2.5.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -4.72732e+88\n} {abc: 2 2 (-4.73e+88) :xyz}\ndo_test printf-2.5.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -4.72732e+88\n} {abc: 2 2 (-4.7e+88) :xyz}\ndo_test printf-2.5.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 9.87991e+143\n} {abc: (9.88e+143) :xyz}\ndo_test printf-2.5.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 9.87991e+143\n} {abc: (9.9e+143) :xyz}\ndo_test printf-2.5.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 9.87991e+143\n} {abc: 2 2 (9.87991e+143) :xyz}\ndo_test printf-2.5.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 9.87991e+143\n} {abc: 2 2 (9.87991e+143) :xyz}\ndo_test printf-2.5.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 9.87991e+143\n} {abc: 2 2 (9.87991e+143) :xyz}\ndo_test printf-2.5.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 9.87991e+143\n} {abc: 2 2 (9.88e+143) :xyz}\ndo_test printf-2.5.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 9.87991e+143\n} {abc: 2 2 (9.9e+143) :xyz}\ndo_test printf-2.5.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 -6.287291e-9\n} {abc: (-0.00) :xyz}\ndo_test printf-2.5.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 -6.287291e-9\n} {abc: (-6.29e-09) :xyz}\ndo_test printf-2.5.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 -6.287291e-9\n} {abc: (-6.3e-09) :xyz}\ndo_test printf-2.5.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-6.28729e-09) :xyz}\ndo_test printf-2.5.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-6.28729e-09) :xyz}\ndo_test printf-2.5.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-6.28729e-09) :xyz}\ndo_test printf-2.5.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-0.00) :xyz}\ndo_test printf-2.5.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-6.29e-09) :xyz}\ndo_test printf-2.5.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 -6.287291e-9\n} {abc: 2 2 (-6.3e-09) :xyz}\ndo_test printf-2.5.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 2 3.38826392e-110\n} {abc: (0.00) :xyz}\ndo_test printf-2.5.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 2 3.38826392e-110\n} {abc: (3.39e-110) :xyz}\ndo_test printf-2.5.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 2 3.38826392e-110\n} {abc: (3.4e-110) :xyz}\ndo_test printf-2.5.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (3.38826e-110) :xyz}\ndo_test printf-2.5.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (3.38826e-110) :xyz}\ndo_test printf-2.5.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (3.38826e-110) :xyz}\ndo_test printf-2.5.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2f) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (0.00) :xyz}\ndo_test printf-2.5.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2e) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (3.39e-110) :xyz}\ndo_test printf-2.5.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.2g) :xyz} 2 2 3.38826392e-110\n} {abc: 2 2 (3.4e-110) :xyz}\ndo_test printf-2.6.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.6.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 0.001\n} {abc: (1.000e-03) :xyz}\ndo_test printf-2.6.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.6.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 0.001\n} {abc: 2 3 (0.001) :xyz}\ndo_test printf-2.6.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 0.001\n} {abc: 2 3 (0.00100000) :xyz}\ndo_test printf-2.6.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 0.001\n} {abc: 2 3 (000000.001) :xyz}\ndo_test printf-2.6.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 0.001\n} {abc: 2 3 (0.001) :xyz}\ndo_test printf-2.6.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 0.001\n} {abc: 2 3 (1.000e-03) :xyz}\ndo_test printf-2.6.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 0.001\n} {abc: 2 3 (0.001) :xyz}\ndo_test printf-2.6.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 1.0e-20\n} {abc: (0.000) :xyz}\ndo_test printf-2.6.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 1.0e-20\n} {abc: (1.000e-20) :xyz}\ndo_test printf-2.6.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.6.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (1e-20) :xyz}\ndo_test printf-2.6.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (1.00000e-20) :xyz}\ndo_test printf-2.6.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (000001e-20) :xyz}\ndo_test printf-2.6.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (0.000) :xyz}\ndo_test printf-2.6.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (1.000e-20) :xyz}\ndo_test printf-2.6.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 1.0e-20\n} {abc: 2 3 (1e-20) :xyz}\ndo_test printf-2.6.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 1.0\n} {abc: (1.000) :xyz}\ndo_test printf-2.6.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 1.0\n} {abc: (1.000e+00) :xyz}\ndo_test printf-2.6.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 1.0\n} {abc: ( 1) :xyz}\ndo_test printf-2.6.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 1.0\n} {abc: 2 3 (1) :xyz}\ndo_test printf-2.6.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 1.0\n} {abc: 2 3 (1.00000) :xyz}\ndo_test printf-2.6.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 1.0\n} {abc: 2 3 (0000000001) :xyz}\ndo_test printf-2.6.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 1.0\n} {abc: 2 3 (1.000) :xyz}\ndo_test printf-2.6.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 1.0\n} {abc: 2 3 (1.000e+00) :xyz}\ndo_test printf-2.6.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 1.0\n} {abc: 2 3 ( 1) :xyz}\ndo_test printf-2.6.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 0.0\n} {abc: (0.000) :xyz}\ndo_test printf-2.6.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 0.0\n} {abc: (0.000e+00) :xyz}\ndo_test printf-2.6.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 0.0\n} {abc: ( 0) :xyz}\ndo_test printf-2.6.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 0.0\n} {abc: 2 3 (0) :xyz}\ndo_test printf-2.6.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 0.0\n} {abc: 2 3 (0.00000) :xyz}\ndo_test printf-2.6.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 0.0\n} {abc: 2 3 (0000000000) :xyz}\ndo_test printf-2.6.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 0.0\n} {abc: 2 3 (0.000) :xyz}\ndo_test printf-2.6.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 0.0\n} {abc: 2 3 (0.000e+00) :xyz}\ndo_test printf-2.6.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 0.0\n} {abc: 2 3 ( 0) :xyz}\ndo_test printf-2.6.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 100.0\n} {abc: (100.000) :xyz}\ndo_test printf-2.6.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 100.0\n} {abc: (1.000e+02) :xyz}\ndo_test printf-2.6.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 100.0\n} {abc: (100) :xyz}\ndo_test printf-2.6.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 100.0\n} {abc: 2 3 (100) :xyz}\ndo_test printf-2.6.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 100.0\n} {abc: 2 3 (100.000) :xyz}\ndo_test printf-2.6.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 100.0\n} {abc: 2 3 (0000000100) :xyz}\ndo_test printf-2.6.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 100.0\n} {abc: 2 3 (100.000) :xyz}\ndo_test printf-2.6.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 100.0\n} {abc: 2 3 (1.000e+02) :xyz}\ndo_test printf-2.6.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 100.0\n} {abc: 2 3 (100) :xyz}\ndo_test printf-2.6.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 9.99999\n} {abc: (10.000) :xyz}\ndo_test printf-2.6.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 9.99999\n} {abc: (1.000e+01) :xyz}\ndo_test printf-2.6.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 9.99999\n} {abc: (10) :xyz}\ndo_test printf-2.6.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 9.99999\n} {abc: 2 3 (9.99999) :xyz}\ndo_test printf-2.6.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 9.99999\n} {abc: 2 3 (9.99999) :xyz}\ndo_test printf-2.6.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 9.99999\n} {abc: 2 3 (0009.99999) :xyz}\ndo_test printf-2.6.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 9.99999\n} {abc: 2 3 (10.000) :xyz}\ndo_test printf-2.6.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 9.99999\n} {abc: 2 3 (1.000e+01) :xyz}\ndo_test printf-2.6.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 9.99999\n} {abc: 2 3 (10) :xyz}\ndo_test printf-2.6.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -0.00543\n} {abc: (-0.005) :xyz}\ndo_test printf-2.6.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -0.00543\n} {abc: (-5.430e-03) :xyz}\ndo_test printf-2.6.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -0.00543\n} {abc: (-0.00543) :xyz}\ndo_test printf-2.6.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-0.00543) :xyz}\ndo_test printf-2.6.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-0.00543000) :xyz}\ndo_test printf-2.6.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-000.00543) :xyz}\ndo_test printf-2.6.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-0.005) :xyz}\ndo_test printf-2.6.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-5.430e-03) :xyz}\ndo_test printf-2.6.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -0.00543\n} {abc: 2 3 (-0.00543) :xyz}\ndo_test printf-2.6.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -1.0\n} {abc: (-1.000) :xyz}\ndo_test printf-2.6.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -1.0\n} {abc: (-1.000e+00) :xyz}\ndo_test printf-2.6.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -1.0\n} {abc: (-1) :xyz}\ndo_test printf-2.6.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -1.0\n} {abc: 2 3 (-1) :xyz}\ndo_test printf-2.6.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -1.0\n} {abc: 2 3 (-1.00000) :xyz}\ndo_test printf-2.6.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -1.0\n} {abc: 2 3 (-000000001) :xyz}\ndo_test printf-2.6.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -1.0\n} {abc: 2 3 (-1.000) :xyz}\ndo_test printf-2.6.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -1.0\n} {abc: 2 3 (-1.000e+00) :xyz}\ndo_test printf-2.6.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -1.0\n} {abc: 2 3 (-1) :xyz}\ndo_test printf-2.6.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -99.99999\n} {abc: (-100.000) :xyz}\ndo_test printf-2.6.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -99.99999\n} {abc: (-1.000e+02) :xyz}\ndo_test printf-2.6.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -99.99999\n} {abc: (-100) :xyz}\ndo_test printf-2.6.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-100) :xyz}\ndo_test printf-2.6.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-100.000) :xyz}\ndo_test printf-2.6.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-000000100) :xyz}\ndo_test printf-2.6.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-100.000) :xyz}\ndo_test printf-2.6.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-1.000e+02) :xyz}\ndo_test printf-2.6.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -99.99999\n} {abc: 2 3 (-100) :xyz}\ndo_test printf-2.6.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 3.14e+9\n} {abc: (3140000000.000) :xyz}\ndo_test printf-2.6.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 3.14e+9\n} {abc: (3.140e+09) :xyz}\ndo_test printf-2.6.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 3.14e+9\n} {abc: (3.14e+09) :xyz}\ndo_test printf-2.6.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (3.14e+09) :xyz}\ndo_test printf-2.6.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (3.14000e+09) :xyz}\ndo_test printf-2.6.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (003.14e+09) :xyz}\ndo_test printf-2.6.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (3140000000.000) :xyz}\ndo_test printf-2.6.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (3.140e+09) :xyz}\ndo_test printf-2.6.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 3.14e+9\n} {abc: 2 3 (3.14e+09) :xyz}\ndo_test printf-2.6.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -4.72732e+88\n} {abc: (-4.727e+88) :xyz}\ndo_test printf-2.6.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -4.72732e+88\n} {abc: (-4.73e+88) :xyz}\ndo_test printf-2.6.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -4.72732e+88\n} {abc: 2 3 (-4.72732e+88) :xyz}\ndo_test printf-2.6.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -4.72732e+88\n} {abc: 2 3 (-4.72732e+88) :xyz}\ndo_test printf-2.6.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -4.72732e+88\n} {abc: 2 3 (-4.72732e+88) :xyz}\ndo_test printf-2.6.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -4.72732e+88\n} {abc: 2 3 (-4.727e+88) :xyz}\ndo_test printf-2.6.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -4.72732e+88\n} {abc: 2 3 (-4.73e+88) :xyz}\ndo_test printf-2.6.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 9.87991e+143\n} {abc: (9.880e+143) :xyz}\ndo_test printf-2.6.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 9.87991e+143\n} {abc: (9.88e+143) :xyz}\ndo_test printf-2.6.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 9.87991e+143\n} {abc: 2 3 (9.87991e+143) :xyz}\ndo_test printf-2.6.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 9.87991e+143\n} {abc: 2 3 (9.87991e+143) :xyz}\ndo_test printf-2.6.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 9.87991e+143\n} {abc: 2 3 (9.87991e+143) :xyz}\ndo_test printf-2.6.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 9.87991e+143\n} {abc: 2 3 (9.880e+143) :xyz}\ndo_test printf-2.6.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 9.87991e+143\n} {abc: 2 3 (9.88e+143) :xyz}\ndo_test printf-2.6.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 -6.287291e-9\n} {abc: (-0.000) :xyz}\ndo_test printf-2.6.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 -6.287291e-9\n} {abc: (-6.287e-09) :xyz}\ndo_test printf-2.6.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 -6.287291e-9\n} {abc: (-6.29e-09) :xyz}\ndo_test printf-2.6.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-6.28729e-09) :xyz}\ndo_test printf-2.6.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-6.28729e-09) :xyz}\ndo_test printf-2.6.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-6.28729e-09) :xyz}\ndo_test printf-2.6.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-0.000) :xyz}\ndo_test printf-2.6.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-6.287e-09) :xyz}\ndo_test printf-2.6.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 -6.287291e-9\n} {abc: 2 3 (-6.29e-09) :xyz}\ndo_test printf-2.6.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 2 3 3.38826392e-110\n} {abc: (0.000) :xyz}\ndo_test printf-2.6.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 2 3 3.38826392e-110\n} {abc: (3.388e-110) :xyz}\ndo_test printf-2.6.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 2 3 3.38826392e-110\n} {abc: (3.39e-110) :xyz}\ndo_test printf-2.6.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (3.38826e-110) :xyz}\ndo_test printf-2.6.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (3.38826e-110) :xyz}\ndo_test printf-2.6.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (3.38826e-110) :xyz}\ndo_test printf-2.6.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3f) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (0.000) :xyz}\ndo_test printf-2.6.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3e) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (3.388e-110) :xyz}\ndo_test printf-2.6.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%2.3g) :xyz} 2 3 3.38826392e-110\n} {abc: 2 3 (3.39e-110) :xyz}\ndo_test printf-2.7.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.7.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 0.001\n} {abc: (1.000e-03) :xyz}\ndo_test printf-2.7.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.7.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 0.001\n} {abc: 3 3 (0.001) :xyz}\ndo_test printf-2.7.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 0.001\n} {abc: 3 3 (0.00100000) :xyz}\ndo_test printf-2.7.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 0.001\n} {abc: 3 3 (000000.001) :xyz}\ndo_test printf-2.7.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 0.001\n} {abc: 3 3 (0.001) :xyz}\ndo_test printf-2.7.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 0.001\n} {abc: 3 3 (1.000e-03) :xyz}\ndo_test printf-2.7.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 0.001\n} {abc: 3 3 (0.001) :xyz}\ndo_test printf-2.7.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 1.0e-20\n} {abc: (0.000) :xyz}\ndo_test printf-2.7.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 1.0e-20\n} {abc: (1.000e-20) :xyz}\ndo_test printf-2.7.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.7.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (1e-20) :xyz}\ndo_test printf-2.7.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (1.00000e-20) :xyz}\ndo_test printf-2.7.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (000001e-20) :xyz}\ndo_test printf-2.7.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (0.000) :xyz}\ndo_test printf-2.7.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (1.000e-20) :xyz}\ndo_test printf-2.7.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 1.0e-20\n} {abc: 3 3 (1e-20) :xyz}\ndo_test printf-2.7.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 1.0\n} {abc: (1.000) :xyz}\ndo_test printf-2.7.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 1.0\n} {abc: (1.000e+00) :xyz}\ndo_test printf-2.7.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 1.0\n} {abc: (  1) :xyz}\ndo_test printf-2.7.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 1.0\n} {abc: 3 3 (1) :xyz}\ndo_test printf-2.7.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 1.0\n} {abc: 3 3 (1.00000) :xyz}\ndo_test printf-2.7.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 1.0\n} {abc: 3 3 (0000000001) :xyz}\ndo_test printf-2.7.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 1.0\n} {abc: 3 3 (1.000) :xyz}\ndo_test printf-2.7.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 1.0\n} {abc: 3 3 (1.000e+00) :xyz}\ndo_test printf-2.7.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 1.0\n} {abc: 3 3 (  1) :xyz}\ndo_test printf-2.7.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 0.0\n} {abc: (0.000) :xyz}\ndo_test printf-2.7.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 0.0\n} {abc: (0.000e+00) :xyz}\ndo_test printf-2.7.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 0.0\n} {abc: (  0) :xyz}\ndo_test printf-2.7.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 0.0\n} {abc: 3 3 (0) :xyz}\ndo_test printf-2.7.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 0.0\n} {abc: 3 3 (0.00000) :xyz}\ndo_test printf-2.7.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 0.0\n} {abc: 3 3 (0000000000) :xyz}\ndo_test printf-2.7.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 0.0\n} {abc: 3 3 (0.000) :xyz}\ndo_test printf-2.7.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 0.0\n} {abc: 3 3 (0.000e+00) :xyz}\ndo_test printf-2.7.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 0.0\n} {abc: 3 3 (  0) :xyz}\ndo_test printf-2.7.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 100.0\n} {abc: (100.000) :xyz}\ndo_test printf-2.7.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 100.0\n} {abc: (1.000e+02) :xyz}\ndo_test printf-2.7.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 100.0\n} {abc: (100) :xyz}\ndo_test printf-2.7.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 100.0\n} {abc: 3 3 (100) :xyz}\ndo_test printf-2.7.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 100.0\n} {abc: 3 3 (100.000) :xyz}\ndo_test printf-2.7.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 100.0\n} {abc: 3 3 (0000000100) :xyz}\ndo_test printf-2.7.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 100.0\n} {abc: 3 3 (100.000) :xyz}\ndo_test printf-2.7.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 100.0\n} {abc: 3 3 (1.000e+02) :xyz}\ndo_test printf-2.7.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 100.0\n} {abc: 3 3 (100) :xyz}\ndo_test printf-2.7.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 9.99999\n} {abc: (10.000) :xyz}\ndo_test printf-2.7.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 9.99999\n} {abc: (1.000e+01) :xyz}\ndo_test printf-2.7.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 9.99999\n} {abc: ( 10) :xyz}\ndo_test printf-2.7.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 9.99999\n} {abc: 3 3 (9.99999) :xyz}\ndo_test printf-2.7.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 9.99999\n} {abc: 3 3 (9.99999) :xyz}\ndo_test printf-2.7.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 9.99999\n} {abc: 3 3 (0009.99999) :xyz}\ndo_test printf-2.7.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 9.99999\n} {abc: 3 3 (10.000) :xyz}\ndo_test printf-2.7.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 9.99999\n} {abc: 3 3 (1.000e+01) :xyz}\ndo_test printf-2.7.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 9.99999\n} {abc: 3 3 ( 10) :xyz}\ndo_test printf-2.7.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -0.00543\n} {abc: (-0.005) :xyz}\ndo_test printf-2.7.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -0.00543\n} {abc: (-5.430e-03) :xyz}\ndo_test printf-2.7.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -0.00543\n} {abc: (-0.00543) :xyz}\ndo_test printf-2.7.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-0.00543) :xyz}\ndo_test printf-2.7.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-0.00543000) :xyz}\ndo_test printf-2.7.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-000.00543) :xyz}\ndo_test printf-2.7.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-0.005) :xyz}\ndo_test printf-2.7.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-5.430e-03) :xyz}\ndo_test printf-2.7.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -0.00543\n} {abc: 3 3 (-0.00543) :xyz}\ndo_test printf-2.7.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -1.0\n} {abc: (-1.000) :xyz}\ndo_test printf-2.7.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -1.0\n} {abc: (-1.000e+00) :xyz}\ndo_test printf-2.7.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -1.0\n} {abc: ( -1) :xyz}\ndo_test printf-2.7.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -1.0\n} {abc: 3 3 (-1) :xyz}\ndo_test printf-2.7.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -1.0\n} {abc: 3 3 (-1.00000) :xyz}\ndo_test printf-2.7.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -1.0\n} {abc: 3 3 (-000000001) :xyz}\ndo_test printf-2.7.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -1.0\n} {abc: 3 3 (-1.000) :xyz}\ndo_test printf-2.7.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -1.0\n} {abc: 3 3 (-1.000e+00) :xyz}\ndo_test printf-2.7.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -1.0\n} {abc: 3 3 ( -1) :xyz}\ndo_test printf-2.7.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -99.99999\n} {abc: (-100.000) :xyz}\ndo_test printf-2.7.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -99.99999\n} {abc: (-1.000e+02) :xyz}\ndo_test printf-2.7.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -99.99999\n} {abc: (-100) :xyz}\ndo_test printf-2.7.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-100) :xyz}\ndo_test printf-2.7.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-100.000) :xyz}\ndo_test printf-2.7.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-000000100) :xyz}\ndo_test printf-2.7.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-100.000) :xyz}\ndo_test printf-2.7.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-1.000e+02) :xyz}\ndo_test printf-2.7.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -99.99999\n} {abc: 3 3 (-100) :xyz}\ndo_test printf-2.7.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 3.14e+9\n} {abc: (3140000000.000) :xyz}\ndo_test printf-2.7.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 3.14e+9\n} {abc: (3.140e+09) :xyz}\ndo_test printf-2.7.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 3.14e+9\n} {abc: (3.14e+09) :xyz}\ndo_test printf-2.7.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (3.14e+09) :xyz}\ndo_test printf-2.7.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (3.14000e+09) :xyz}\ndo_test printf-2.7.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (003.14e+09) :xyz}\ndo_test printf-2.7.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (3140000000.000) :xyz}\ndo_test printf-2.7.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (3.140e+09) :xyz}\ndo_test printf-2.7.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 3.14e+9\n} {abc: 3 3 (3.14e+09) :xyz}\ndo_test printf-2.7.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -4.72732e+88\n} {abc: (-4.727e+88) :xyz}\ndo_test printf-2.7.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -4.72732e+88\n} {abc: (-4.73e+88) :xyz}\ndo_test printf-2.7.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -4.72732e+88\n} {abc: 3 3 (-4.72732e+88) :xyz}\ndo_test printf-2.7.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -4.72732e+88\n} {abc: 3 3 (-4.72732e+88) :xyz}\ndo_test printf-2.7.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -4.72732e+88\n} {abc: 3 3 (-4.72732e+88) :xyz}\ndo_test printf-2.7.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -4.72732e+88\n} {abc: 3 3 (-4.727e+88) :xyz}\ndo_test printf-2.7.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -4.72732e+88\n} {abc: 3 3 (-4.73e+88) :xyz}\ndo_test printf-2.7.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 9.87991e+143\n} {abc: (9.880e+143) :xyz}\ndo_test printf-2.7.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 9.87991e+143\n} {abc: (9.88e+143) :xyz}\ndo_test printf-2.7.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 9.87991e+143\n} {abc: 3 3 (9.87991e+143) :xyz}\ndo_test printf-2.7.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 9.87991e+143\n} {abc: 3 3 (9.87991e+143) :xyz}\ndo_test printf-2.7.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 9.87991e+143\n} {abc: 3 3 (9.87991e+143) :xyz}\ndo_test printf-2.7.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 9.87991e+143\n} {abc: 3 3 (9.880e+143) :xyz}\ndo_test printf-2.7.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 9.87991e+143\n} {abc: 3 3 (9.88e+143) :xyz}\ndo_test printf-2.7.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 -6.287291e-9\n} {abc: (-0.000) :xyz}\ndo_test printf-2.7.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 -6.287291e-9\n} {abc: (-6.287e-09) :xyz}\ndo_test printf-2.7.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 -6.287291e-9\n} {abc: (-6.29e-09) :xyz}\ndo_test printf-2.7.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-6.28729e-09) :xyz}\ndo_test printf-2.7.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-6.28729e-09) :xyz}\ndo_test printf-2.7.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-6.28729e-09) :xyz}\ndo_test printf-2.7.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-0.000) :xyz}\ndo_test printf-2.7.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-6.287e-09) :xyz}\ndo_test printf-2.7.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 -6.287291e-9\n} {abc: 3 3 (-6.29e-09) :xyz}\ndo_test printf-2.7.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 3 3.38826392e-110\n} {abc: (0.000) :xyz}\ndo_test printf-2.7.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 3 3.38826392e-110\n} {abc: (3.388e-110) :xyz}\ndo_test printf-2.7.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 3 3.38826392e-110\n} {abc: (3.39e-110) :xyz}\ndo_test printf-2.7.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (3.38826e-110) :xyz}\ndo_test printf-2.7.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (3.38826e-110) :xyz}\ndo_test printf-2.7.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (3.38826e-110) :xyz}\ndo_test printf-2.7.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3f) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (0.000) :xyz}\ndo_test printf-2.7.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3e) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (3.388e-110) :xyz}\ndo_test printf-2.7.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.3g) :xyz} 3 3 3.38826392e-110\n} {abc: 3 3 (3.39e-110) :xyz}\ndo_test printf-2.8.1.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 0.001\n} {abc: (0.00) :xyz}\ndo_test printf-2.8.1.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 0.001\n} {abc: (1.00e-03) :xyz}\ndo_test printf-2.8.1.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 0.001\n} {abc: (0.001) :xyz}\ndo_test printf-2.8.1.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 0.001\n} {abc: 3 2 (0.001) :xyz}\ndo_test printf-2.8.1.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 0.001\n} {abc: 3 2 (0.00100000) :xyz}\ndo_test printf-2.8.1.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 0.001\n} {abc: 3 2 (000000.001) :xyz}\ndo_test printf-2.8.1.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 0.001\n} {abc: 3 2 (0.00) :xyz}\ndo_test printf-2.8.1.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 0.001\n} {abc: 3 2 (1.00e-03) :xyz}\ndo_test printf-2.8.1.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 0.001\n} {abc: 3 2 (0.001) :xyz}\ndo_test printf-2.8.2.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 1.0e-20\n} {abc: (0.00) :xyz}\ndo_test printf-2.8.2.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 1.0e-20\n} {abc: (1.00e-20) :xyz}\ndo_test printf-2.8.2.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 1.0e-20\n} {abc: (1e-20) :xyz}\ndo_test printf-2.8.2.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (1e-20) :xyz}\ndo_test printf-2.8.2.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (1.00000e-20) :xyz}\ndo_test printf-2.8.2.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (000001e-20) :xyz}\ndo_test printf-2.8.2.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (0.00) :xyz}\ndo_test printf-2.8.2.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (1.00e-20) :xyz}\ndo_test printf-2.8.2.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 1.0e-20\n} {abc: 3 2 (1e-20) :xyz}\ndo_test printf-2.8.3.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 1.0\n} {abc: (1.00) :xyz}\ndo_test printf-2.8.3.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 1.0\n} {abc: (1.00e+00) :xyz}\ndo_test printf-2.8.3.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 1.0\n} {abc: (  1) :xyz}\ndo_test printf-2.8.3.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 1.0\n} {abc: 3 2 (1) :xyz}\ndo_test printf-2.8.3.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 1.0\n} {abc: 3 2 (1.00000) :xyz}\ndo_test printf-2.8.3.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 1.0\n} {abc: 3 2 (0000000001) :xyz}\ndo_test printf-2.8.3.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 1.0\n} {abc: 3 2 (1.00) :xyz}\ndo_test printf-2.8.3.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 1.0\n} {abc: 3 2 (1.00e+00) :xyz}\ndo_test printf-2.8.3.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 1.0\n} {abc: 3 2 (  1) :xyz}\ndo_test printf-2.8.4.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 0.0\n} {abc: (0.00) :xyz}\ndo_test printf-2.8.4.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 0.0\n} {abc: (0.00e+00) :xyz}\ndo_test printf-2.8.4.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 0.0\n} {abc: (  0) :xyz}\ndo_test printf-2.8.4.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 0.0\n} {abc: 3 2 (0) :xyz}\ndo_test printf-2.8.4.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 0.0\n} {abc: 3 2 (0.00000) :xyz}\ndo_test printf-2.8.4.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 0.0\n} {abc: 3 2 (0000000000) :xyz}\ndo_test printf-2.8.4.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 0.0\n} {abc: 3 2 (0.00) :xyz}\ndo_test printf-2.8.4.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 0.0\n} {abc: 3 2 (0.00e+00) :xyz}\ndo_test printf-2.8.4.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 0.0\n} {abc: 3 2 (  0) :xyz}\ndo_test printf-2.8.5.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 100.0\n} {abc: (100.00) :xyz}\ndo_test printf-2.8.5.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 100.0\n} {abc: (1.00e+02) :xyz}\ndo_test printf-2.8.5.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 100.0\n} {abc: (1e+02) :xyz}\ndo_test printf-2.8.5.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 100.0\n} {abc: 3 2 (100) :xyz}\ndo_test printf-2.8.5.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 100.0\n} {abc: 3 2 (100.000) :xyz}\ndo_test printf-2.8.5.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 100.0\n} {abc: 3 2 (0000000100) :xyz}\ndo_test printf-2.8.5.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 100.0\n} {abc: 3 2 (100.00) :xyz}\ndo_test printf-2.8.5.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 100.0\n} {abc: 3 2 (1.00e+02) :xyz}\ndo_test printf-2.8.5.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 100.0\n} {abc: 3 2 (1e+02) :xyz}\ndo_test printf-2.8.6.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 9.99999\n} {abc: (10.00) :xyz}\ndo_test printf-2.8.6.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 9.99999\n} {abc: (1.00e+01) :xyz}\ndo_test printf-2.8.6.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 9.99999\n} {abc: ( 10) :xyz}\ndo_test printf-2.8.6.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 9.99999\n} {abc: 3 2 (9.99999) :xyz}\ndo_test printf-2.8.6.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 9.99999\n} {abc: 3 2 (9.99999) :xyz}\ndo_test printf-2.8.6.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 9.99999\n} {abc: 3 2 (0009.99999) :xyz}\ndo_test printf-2.8.6.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 9.99999\n} {abc: 3 2 (10.00) :xyz}\ndo_test printf-2.8.6.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 9.99999\n} {abc: 3 2 (1.00e+01) :xyz}\ndo_test printf-2.8.6.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 9.99999\n} {abc: 3 2 ( 10) :xyz}\ndo_test printf-2.8.7.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -0.00543\n} {abc: (-0.01) :xyz}\ndo_test printf-2.8.7.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -0.00543\n} {abc: (-5.43e-03) :xyz}\ndo_test printf-2.8.7.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -0.00543\n} {abc: (-0.0054) :xyz}\ndo_test printf-2.8.7.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-0.00543) :xyz}\ndo_test printf-2.8.7.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-0.00543000) :xyz}\ndo_test printf-2.8.7.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-000.00543) :xyz}\ndo_test printf-2.8.7.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-0.01) :xyz}\ndo_test printf-2.8.7.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-5.43e-03) :xyz}\ndo_test printf-2.8.7.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -0.00543\n} {abc: 3 2 (-0.0054) :xyz}\ndo_test printf-2.8.8.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -1.0\n} {abc: (-1.00) :xyz}\ndo_test printf-2.8.8.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -1.0\n} {abc: (-1.00e+00) :xyz}\ndo_test printf-2.8.8.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -1.0\n} {abc: ( -1) :xyz}\ndo_test printf-2.8.8.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -1.0\n} {abc: 3 2 (-1) :xyz}\ndo_test printf-2.8.8.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -1.0\n} {abc: 3 2 (-1.00000) :xyz}\ndo_test printf-2.8.8.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -1.0\n} {abc: 3 2 (-000000001) :xyz}\ndo_test printf-2.8.8.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -1.0\n} {abc: 3 2 (-1.00) :xyz}\ndo_test printf-2.8.8.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -1.0\n} {abc: 3 2 (-1.00e+00) :xyz}\ndo_test printf-2.8.8.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -1.0\n} {abc: 3 2 ( -1) :xyz}\ndo_test printf-2.8.9.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -99.99999\n} {abc: (-100.00) :xyz}\ndo_test printf-2.8.9.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -99.99999\n} {abc: (-1.00e+02) :xyz}\ndo_test printf-2.8.9.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -99.99999\n} {abc: (-1e+02) :xyz}\ndo_test printf-2.8.9.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-100) :xyz}\ndo_test printf-2.8.9.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-100.000) :xyz}\ndo_test printf-2.8.9.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-000000100) :xyz}\ndo_test printf-2.8.9.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-100.00) :xyz}\ndo_test printf-2.8.9.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-1.00e+02) :xyz}\ndo_test printf-2.8.9.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -99.99999\n} {abc: 3 2 (-1e+02) :xyz}\ndo_test printf-2.8.10.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 3.14e+9\n} {abc: (3140000000.00) :xyz}\ndo_test printf-2.8.10.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 3.14e+9\n} {abc: (3.14e+09) :xyz}\ndo_test printf-2.8.10.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 3.14e+9\n} {abc: (3.1e+09) :xyz}\ndo_test printf-2.8.10.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (3.14e+09) :xyz}\ndo_test printf-2.8.10.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (3.14000e+09) :xyz}\ndo_test printf-2.8.10.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (003.14e+09) :xyz}\ndo_test printf-2.8.10.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (3140000000.00) :xyz}\ndo_test printf-2.8.10.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (3.14e+09) :xyz}\ndo_test printf-2.8.10.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 3.14e+9\n} {abc: 3 2 (3.1e+09) :xyz}\ndo_test printf-2.8.11.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -4.72732e+88\n} {abc: (-4.73e+88) :xyz}\ndo_test printf-2.8.11.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -4.72732e+88\n} {abc: (-4.7e+88) :xyz}\ndo_test printf-2.8.11.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -4.72732e+88\n} {abc: 3 2 (-4.72732e+88) :xyz}\ndo_test printf-2.8.11.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -4.72732e+88\n} {abc: 3 2 (-4.72732e+88) :xyz}\ndo_test printf-2.8.11.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -4.72732e+88\n} {abc: 3 2 (-4.72732e+88) :xyz}\ndo_test printf-2.8.11.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -4.72732e+88\n} {abc: 3 2 (-4.73e+88) :xyz}\ndo_test printf-2.8.11.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -4.72732e+88\n} {abc: 3 2 (-4.7e+88) :xyz}\ndo_test printf-2.8.12.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 9.87991e+143\n} {abc: (9.88e+143) :xyz}\ndo_test printf-2.8.12.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 9.87991e+143\n} {abc: (9.9e+143) :xyz}\ndo_test printf-2.8.12.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 9.87991e+143\n} {abc: 3 2 (9.87991e+143) :xyz}\ndo_test printf-2.8.12.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 9.87991e+143\n} {abc: 3 2 (9.87991e+143) :xyz}\ndo_test printf-2.8.12.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 9.87991e+143\n} {abc: 3 2 (9.87991e+143) :xyz}\ndo_test printf-2.8.12.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 9.87991e+143\n} {abc: 3 2 (9.88e+143) :xyz}\ndo_test printf-2.8.12.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 9.87991e+143\n} {abc: 3 2 (9.9e+143) :xyz}\ndo_test printf-2.8.13.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 -6.287291e-9\n} {abc: (-0.00) :xyz}\ndo_test printf-2.8.13.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 -6.287291e-9\n} {abc: (-6.29e-09) :xyz}\ndo_test printf-2.8.13.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 -6.287291e-9\n} {abc: (-6.3e-09) :xyz}\ndo_test printf-2.8.13.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-6.28729e-09) :xyz}\ndo_test printf-2.8.13.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-6.28729e-09) :xyz}\ndo_test printf-2.8.13.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-6.28729e-09) :xyz}\ndo_test printf-2.8.13.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-0.00) :xyz}\ndo_test printf-2.8.13.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-6.29e-09) :xyz}\ndo_test printf-2.8.13.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 -6.287291e-9\n} {abc: 3 2 (-6.3e-09) :xyz}\ndo_test printf-2.8.14.1 {\n  sqlite3_mprintf_double {abc: (%*.*f) :xyz} 3 2 3.38826392e-110\n} {abc: (0.00) :xyz}\ndo_test printf-2.8.14.2 {\n  sqlite3_mprintf_double {abc: (%*.*e) :xyz} 3 2 3.38826392e-110\n} {abc: (3.39e-110) :xyz}\ndo_test printf-2.8.14.3 {\n  sqlite3_mprintf_double {abc: (%*.*g) :xyz} 3 2 3.38826392e-110\n} {abc: (3.4e-110) :xyz}\ndo_test printf-2.8.14.4 {\n  sqlite3_mprintf_double {abc: %d %d (%g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (3.38826e-110) :xyz}\ndo_test printf-2.8.14.5 {\n  sqlite3_mprintf_double {abc: %d %d (%#g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (3.38826e-110) :xyz}\ndo_test printf-2.8.14.6 {\n  sqlite3_mprintf_double {abc: %d %d (%010g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (3.38826e-110) :xyz}\ndo_test printf-2.8.14.7 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2f) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (0.00) :xyz}\ndo_test printf-2.8.14.8 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2e) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (3.39e-110) :xyz}\ndo_test printf-2.8.14.9 {\n  sqlite3_mprintf_double {abc: %d %d (%3.2g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 (3.4e-110) :xyz}\ndo_test printf-2.8.15.1 {\n  sqlite3_mprintf_double {abc: (% *.*f) :xyz} 3 2 3.38826392e-110\n} {abc: ( 0.00) :xyz}\ndo_test printf-2.8.15.2 {\n  sqlite3_mprintf_double {abc: (% *.*e) :xyz} 3 2 3.38826392e-110\n} {abc: ( 3.39e-110) :xyz}\ndo_test printf-2.8.15.3 {\n  sqlite3_mprintf_double {abc: (% *.*g) :xyz} 3 2 3.38826392e-110\n} {abc: ( 3.4e-110) :xyz}\ndo_test printf-2.8.15.4 {\n  sqlite3_mprintf_double {abc: %d %d (% g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 3.38826e-110) :xyz}\ndo_test printf-2.8.15.5 {\n  sqlite3_mprintf_double {abc: %d %d (% #g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 3.38826e-110) :xyz}\ndo_test printf-2.8.15.6 {\n  sqlite3_mprintf_double {abc: %d %d (%0 10g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 3.38826e-110) :xyz}\ndo_test printf-2.8.15.7 {\n  sqlite3_mprintf_double {abc: %d %d (% 3.2f) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 0.00) :xyz}\ndo_test printf-2.8.15.8 {\n  sqlite3_mprintf_double {abc: %d %d (% 3.2e) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 3.39e-110) :xyz}\ndo_test printf-2.8.15.9 {\n  sqlite3_mprintf_double {abc: %d %d (% 3.2g) :xyz} 3 2 3.38826392e-110\n} {abc: 3 2 ( 3.4e-110) :xyz}\n\ndo_test printf-2.9.1 {\n  sqlite3_mprintf_double {abc: %d %d (%5.0g) :xyz} 0 0 1.234\n} {abc: 0 0 (    1) :xyz}\ndo_test printf-2.9.2 {\n  sqlite3_mprintf_double {abc: %d %d (%+5.0g) :xyz} 0 0 1.234\n} {abc: 0 0 (   +1) :xyz}\ndo_test printf-2.9.3 {\n  sqlite3_mprintf_double {abc: %d %d (%+-5.0g) :xyz} 0 0 1.234\n} {abc: 0 0 (+1   ) :xyz}\n\ndo_test printf-2.10.1 {\n  sqlite3_mprintf_double {abc: %d %d (%-010.5f) :xyz} 0 0 1.234\n} {abc: 0 0 (1.23400   ) :xyz}\ndo_test printf-2.10.2 {\n  sqlite3_mprintf_double {abc: %d %d (%010.5f) :xyz} 0 0 1.234\n} {abc: 0 0 (0001.23400) :xyz}\ndo_test printf-2.10.3 {\n  sqlite3_mprintf_double {abc: %d %d (%+010.5f) :xyz} 0 0 1.234\n} {abc: 0 0 (+001.23400) :xyz}\n\ndo_test printf-3.1 {\n  sqlite3_mprintf_str {A String: (%*.*s)} 10 10 {This is the string}\n} [format {A String: (%*.*s)} 10 10 {This is the string}]\ndo_test printf-3.2 {\n  sqlite3_mprintf_str {A String: (%*.*s)} 10 5 {This is the string}\n} [format {A String: (%*.*s)} 10 5 {This is the string}]\ndo_test printf-3.3 {\n  sqlite3_mprintf_str {A String: (%*.*s)} -10 5 {This is the string}\n} [format {A String: (%*.*s)} -10 5 {This is the string}]\ndo_test printf-3.4 {\n  sqlite3_mprintf_str {%d %d A String: (%s)} 1 2 {This is the string}\n} [format {%d %d A String: (%s)} 1 2 {This is the string}]\ndo_test printf-3.5 {\n  sqlite3_mprintf_str {%d %d A String: (%30s)} 1 2 {This is the string}\n} [format {%d %d A String: (%30s)} 1 2 {This is the string}]\ndo_test printf-3.6 {\n  sqlite3_mprintf_str {%d %d A String: (%-30s)} 1 2 {This is the string}\n} [format {%d %d A String: (%-30s)} 1 2 {This is the string}]\ndo_test printf-3.7 {\n  sqlite3_mprintf_str {%d A String: (%*s)} 1 2147483647 {This is the string}\n} []\ndo_test printf-3.8 {\n  sqlite3_mprintf_str {%d A String: (%*s)} 1 -2147483648 {This is the string}\n} {1 A String: (This is the string)}\ndo_test printf-3.9 {\n  sqlite3_mprintf_str {%d A String: (%.*s)} 1 -2147483648 {This is the string}\n} {1 A String: (This is the string)}\ndo_test snprintf-3.11 {\n  sqlite3_snprintf_str 2 {x%d %d %s} 10 10 {This is the string}\n} {x}\ndo_test snprintf-3.12 {\n  sqlite3_snprintf_str 3 {x%d %d %s} 10 10 {This is the string}\n} {x1}\ndo_test snprintf-3.13 {\n  sqlite3_snprintf_str 4 {x%d %d %s} 10 10 {This is the string}\n} {x10}\ndo_test snprintf-3.14 {\n  sqlite3_snprintf_str 5 {x%d %d %s} 10 10 {This is the string}\n} {x10 }\ndo_test snprintf-3.15 {\n  sqlite3_snprintf_str 6 {x%d %d %s} 10 10 {This is the string}\n} {x10 1}\ndo_test snprintf-3.16 {\n  sqlite3_snprintf_str 7 {x%d %d %s} 10 10 {This is the string}\n} {x10 10}\ndo_test snprintf-3.17 {\n  sqlite3_snprintf_str 8 {x%d %d %s} 10 10 {This is the string}\n} {x10 10 }\ndo_test snprintf-3.18 {\n  sqlite3_snprintf_str 9 {x%d %d %s} 10 10 {This is the string}\n} {x10 10 T}\ndo_test snprintf-3.19 {\n  sqlite3_snprintf_str 100 {x%d %d %s} 10 10 {This is the string}\n} {x10 10 This is the string}\n\ndo_test printf-4.1 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''all'}\ndo_test printf-4.2 {\n  sqlite3_mprintf_str {%d %d A NULL pointer in %%q: '%q'} 1 2\n} {1 2 A NULL pointer in %q: '(NULL)'}\ndo_test printf-4.3 {\n  sqlite3_mprintf_str {%d %d A quoted string: %Q} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''all'}\ndo_test printf-4.4 {\n  sqlite3_mprintf_str {%d %d A NULL pointer in %%Q: %Q} 1 2\n} {1 2 A NULL pointer in %Q: NULL}\ndo_test printf-4.5 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.10q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''all'}\ndo_test printf-4.6 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.9q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''all'}\ndo_test printf-4.7 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.8q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''all'}\ndo_test printf-4.8 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.7q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''al'}\ndo_test printf-4.9 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.6q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y''a'}\ndo_test printf-4.10 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.5q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y'''}\ndo_test printf-4.11 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.4q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi Y'}\ndo_test printf-4.12 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.3q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi '}\ndo_test printf-4.13 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.2q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'Hi'}\ndo_test printf-4.14 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.1q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: 'H'}\ndo_test printf-4.15 {\n  sqlite3_mprintf_str {%d %d A quoted string: '%.0q'} 1 2 {Hi Y'all}\n} {1 2 A quoted string: ''}\ndo_test printf-4.16 {\n  sqlite3_mprintf_str {%d A quoted string: '%.*q'} 1 6 {Hi Y'all}\n} {1 A quoted string: 'Hi Y''a'}\n\n\ndo_test printf-5.1 {\n  set x [sqlite3_mprintf_str {%d %d %100000s} 0 0 {Hello}]\n  string length $x\n} {100004}\ndo_test printf-5.2 {\n  sqlite3_mprintf_str {%d %d (%-10.10s) %} -9 -10 {HelloHelloHello}\n} {-9 -10 (HelloHello) %}\n\ndo_test printf-6.1 {\n  sqlite3_mprintf_z_test , one two three four five six\n} {,one,two,three,four,five,six}\n\n\ndo_test printf-7.1 {\n  sqlite3_mprintf_scaled {A double: %g} 1.0e307 1.0\n} {A double: 1e+307}\ndo_test printf-7.2 {\n  sqlite3_mprintf_scaled {A double: %g} 1.0e307 10.0\n} {A double: 1e+308}\ndo_test printf-7.3 {\n  sqlite3_mprintf_scaled {A double: %g} 1.0e307 100.0\n} {A double: Inf}\ndo_test printf-7.4 {\n  sqlite3_mprintf_scaled {A double: %g} -1.0e307 100.0\n} {A double: -Inf}\ndo_test printf-7.5 {\n  sqlite3_mprintf_scaled {A double: %+g} 1.0e307 100.0\n} {A double: +Inf}\n\ndo_test printf-8.1 {\n  sqlite3_mprintf_int {%u %u %u} 0x7fffffff 0x80000000 0xffffffff\n} {2147483647 2147483648 4294967295}\ndo_test printf-8.2 {\n  sqlite3_mprintf_long {%lu %lu %lu} 0x7fffffff 0x80000000 0xffffffff\n} {2147483647 2147483648 4294967295}\ndo_test printf-8.3 {\n  sqlite3_mprintf_int64 {%llu %llu %llu} 2147483647 2147483648 4294967296\n} {2147483647 2147483648 4294967296}\ndo_test printf-8.4 {\n  sqlite3_mprintf_int64 {%lld %lld %lld} 2147483647 2147483648 4294967296\n} {2147483647 2147483648 4294967296}\ndo_test printf-8.5 {\n  sqlite3_mprintf_int64 {%llx %llx %llx} 2147483647 2147483648 4294967296\n} {7fffffff 80000000 100000000}\ndo_test printf-8.6 {\n  sqlite3_mprintf_int64 {%llx %llo %lld} -1 -1 -1\n} {ffffffffffffffff 1777777777777777777777 -1}\ndo_test printf-8.7 {\n  sqlite3_mprintf_int64 {%llx %llx %llx} +2147483647 +2147483648 +4294967296\n} {7fffffff 80000000 100000000}\n\ndo_test printf-9.1 {\n  sqlite3_mprintf_int {%*.*c} 4 4 65\n} {AAAA}\ndo_test printf-9.2 {\n  sqlite3_mprintf_int {%*.*c} -4 1 66\n} {B   }\ndo_test printf-9.3 {\n  sqlite3_mprintf_int {%*.*c} 4 1 67\n} {   C}\ndo_test printf-9.4 {\n  sqlite3_mprintf_int {%d %d %c} 4 1 67\n} {4 1 C}\nset ten {          }\nset fifty $ten$ten$ten$ten$ten\ndo_test printf-9.5 {\n  sqlite3_mprintf_int {%d %*c} 1 -201 67\n} \"1 C$fifty$fifty$fifty$fifty\"\ndo_test printf-9.6 {\n  sqlite3_mprintf_int {hi%12345.12346yhello} 0 0 0\n} {hi}\n\n# Ticket #812\n#\ndo_test printf-10.1 {\n  sqlite3_mprintf_stronly %s {}\n} {}\n\n# Ticket #831\n#\ndo_test printf-10.2 {\n  sqlite3_mprintf_stronly %q {}\n} {}\n\n# Ticket #1340:  Test for loss of precision on large positive exponents\n#\ndo_test printf-10.3 {\n  sqlite3_mprintf_double {%d %d %f} 1 1 1e300\n} {1 1 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000}\n\n# The non-standard '!' flag on a 'g' conversion forces a decimal point\n# and at least one digit on either side of the decimal point.\n#\ndo_test printf-11.1 {\n  sqlite3_mprintf_double {%d %d %!g} 1 1 1\n} {1 1 1.0}\ndo_test printf-11.2 {\n  sqlite3_mprintf_double {%d %d %!g} 1 1 123\n} {1 1 123.0}\ndo_test printf-11.3 {\n  sqlite3_mprintf_double {%d %d %!g} 1 1 12.3\n} {1 1 12.3}\ndo_test printf-11.4 {\n  sqlite3_mprintf_double {%d %d %!g} 1 1 0.123\n} {1 1 0.123}\ndo_test printf-11.5 {\n  sqlite3_mprintf_double {%d %d %!.15g} 1 1 1\n} {1 1 1.0}\ndo_test printf-11.6 {\n  sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e10\n} {1 1 10000000000.0}\ndo_test printf-11.7 {\n  sqlite3_mprintf_double {%d %d %!.15g} 1 1 1e300\n} {1 1 1.0e+300}\n\n# Additional tests for coverage\n#\ndo_test printf-12.1 {\n  sqlite3_mprintf_double {%d %d %.2000g} 1 1 1.0\n} {1 1 1}\n\n# Floating point boundary cases\n#\ndo_test printf-13.1 {\n  sqlite3_mprintf_hexdouble %.20f 4024000000000000\n} {10.00000000000000000000}\ndo_test printf-13.2 {\n  sqlite3_mprintf_hexdouble %.20f 4197d78400000000\n} {100000000.00000000000000000000}\ndo_test printf-13.3 {\n  sqlite3_mprintf_hexdouble %.20f 4693b8b5b5056e17\n} {100000000000000000000000000000000.00000000000000000000}\ndo_test printf-13.4 {\n  sqlite3_mprintf_hexdouble %.20f 7ff0000000000000\n} {Inf}\ndo_test printf-13.5 {\n  sqlite3_mprintf_hexdouble %.20f fff0000000000000\n} {-Inf}\ndo_test printf-13.6 {\n  sqlite3_mprintf_hexdouble %.20f fff8000000000000\n} {NaN}\ndo_test printf-13.7 {\n  sqlite3_mprintf_hexdouble %2147483648.10000f 4693b8b5b5056e17\n} {/100000000000000000000000000000000.00/}\n\ndo_test printf-14.1 {\n  sqlite3_mprintf_str {abc-%y-123} 0 0 {not used}\n} {abc-}\ndo_test printf-14.2 {\n  sqlite3_mprintf_n_test {xyzzy}\n} 5\ndo_test printf-14.3 {\n  sqlite3_mprintf_str {abc-%T-123} 0 0 {not used}\n} {abc-}\ndo_test printf-14.4 {\n  sqlite3_mprintf_str {abc-%#} 0 0 {not used}\n} {abc-}\ndo_test printf-14.5 {\n  sqlite3_mprintf_str {abc-%*.*s-xyz} 10 -10 {a_very_long_string}\n} {abc-a_very_lon-xyz}\ndo_test printf-14.6 {\n  sqlite3_mprintf_str {abc-%5.10/} 0 0 {not used}\n} {abc-}\ndo_test printf-14.7 {\n  sqlite3_mprintf_str {abc-%05.5d} 123 0 {not used}\n} {abc-00123}\ndo_test printf-14.8 {\n  sqlite3_mprintf_str {abc-%05.5d} 1234567 0 {not used}\n} {abc-1234567}\n\nfor {set i 2} {$i<200} {incr i} {\n  set res [string repeat { } [expr {$i-1}]]x\n  do_test printf-14.90.$i \"\n    sqlite3_mprintf_str {%*.*s} $i 500 x\n  \" $res\n}\n\ndo_test printf-15.1 {\n  sqlite3_snprintf_int 5 {12345} 0\n} {1234}\ndo_test printf-15.2 {\n  sqlite3_snprintf_int 5 {} 0\n} {}\ndo_test printf-15.3 {\n  sqlite3_snprintf_int 0 {} 0\n} {abcdefghijklmnopqrstuvwxyz}\n\n# Now test malloc() failure within a sqlite3_mprintf():\n#\nifcapable memdebug {\n  foreach var {a b c d} {\n    set $var [string repeat $var 400]\n  }\n  set str1 \"[string repeat A 360]%d%d%s\"\n  set str2 [string repeat B 5000]\n  set zSuccess \"[string repeat A 360]11[string repeat B 5000]\"\n  foreach ::iRepeat {0 1} {\n    set nTestNum 1\n    while {1} {\n      sqlite3_memdebug_fail $nTestNum -repeat $::iRepeat\n      set z [sqlite3_mprintf_str $str1 1 1 $str2]\n      set nFail [sqlite3_memdebug_fail -1 -benign nBenign]\n      do_test printf-malloc-$::iRepeat.$nTestNum {\n        expr {($nFail>0 && $z eq \"\") || ($nFail==$nBenign && $z eq $zSuccess)}\n      } {1}\n      if {$nFail == 0} break\n      incr nTestNum\n    }\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/printf2.test",
    "content": "# 2013-12-17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the printf() SQL function.\n#\n#\n# EVIDENCE-OF: R-63057-40065 The printf(FORMAT,...) SQL function works\n# like the sqlite3_mprintf() C-language function and the printf()\n# function from the standard C library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# EVIDENCE-OF: R-40086-60101 If the FORMAT argument is missing or NULL\n# then the result is NULL.\n#\ndo_execsql_test printf2-1.1 {\n  SELECT quote(printf()), quote(printf(NULL,1,2,3));\n} {NULL NULL}\n\n\ndo_execsql_test printf2-1.2 {\n  SELECT printf('hello');\n} {hello}\ndo_execsql_test printf2-1.3 {\n  SELECT printf('%d,%d,%d',55,-11,3421);\n} {55,-11,3421}\ndo_execsql_test printf2-1.4 {\n  SELECT printf('%d,%d,%d',55,'-11',3421);\n} {55,-11,3421}\ndo_execsql_test printf2-1.5 {\n  SELECT printf('%d,%d,%d,%d',55,'-11',3421);\n} {55,-11,3421,0}\ndo_execsql_test printf2-1.6 {\n  SELECT printf('%.2f',3.141592653);\n} {3.14}\ndo_execsql_test printf2-1.7 {\n  SELECT printf('%.*f',2,3.141592653);\n} {3.14}\ndo_execsql_test printf2-1.8 {\n  SELECT printf('%*.*f',5,2,3.141592653);\n} {{ 3.14}}\ndo_execsql_test printf2-1.9 {\n  SELECT printf('%d',314159.2653);\n} {314159}\ndo_execsql_test printf2-1.10 {\n  SELECT printf('%lld',314159.2653);\n} {314159}\ndo_execsql_test printf2-1.11 {\n  SELECT printf('%lld%n',314159.2653,'hi');\n} {314159}\ndo_execsql_test printf2-1.12 {\n  SELECT printf('%n',0);\n} {{}}\n\n# EVIDENCE-OF: R-17002-27534 The %z format is interchangeable with %s.\n#\ndo_execsql_test printf2-1.12 {\n  SELECT printf('%.*z',5,'abcdefghijklmnop');\n} {abcde}\ndo_execsql_test printf2-1.13 {\n  SELECT printf('%c','abcdefghijklmnop');\n} {a}\n\n# EVIDENCE-OF: R-02347-27622 The %n format is silently ignored and does\n# not consume an argument.\n#\ndo_execsql_test printf2-2.1 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(-1,-2,-3);\n  INSERT INTO t1 VALUES('abc','def','ghi');\n  INSERT INTO t1 VALUES(1.5,2.25,3.125);\n  SELECT printf('(%s)-%n-(%s)',a,b,c) FROM t1 ORDER BY rowid;\n} {(1)--(2) (-1)--(-2) (abc)--(def) (1.5)--(2.25)}\n\n# EVIDENCE-OF: R-56064-04001 The %p format is an alias for %X.\n#\ndo_execsql_test printf2-2.2 {\n  SELECT printf('%s=(%p)',a,a) FROM t1 ORDER BY a;\n} {-1=(FFFFFFFFFFFFFFFF) 1=(1) 1.5=(1) abc=(0)}\n\n# EVIDENCE-OF: R-29410-53018 If there are too few arguments in the\n# argument list, missing arguments are assumed to have a NULL value,\n# which is translated into 0 or 0.0 for numeric formats or an empty\n# string for %s.\n#\ndo_execsql_test printf2-2.3 {\n  SELECT printf('%s=(%d/%g/%s)',a) FROM t1 ORDER BY a;\n} {-1=(0/0/) 1=(0/0/) 1.5=(0/0/) abc=(0/0/)}\n\n# The precision of the %c conversion causes the character to repeat.\n#\ndo_execsql_test printf2-3.1 {\n  SELECT printf('|%110.100c|','*');\n} {{|          ****************************************************************************************************|}}\ndo_execsql_test printf2-3.2 {\n  SELECT printf('|%-110.100c|','*');\n} {{|****************************************************************************************************          |}}\ndo_execsql_test printf2-3.3 {\n  SELECT printf('|%9.8c|%-9.8c|','*','*');\n} {{| ********|******** |}}\ndo_execsql_test printf2-3.4 {\n  SELECT printf('|%8.8c|%-8.8c|','*','*');\n} {|********|********|}\ndo_execsql_test printf2-3.5 {\n  SELECT printf('|%7.8c|%-7.8c|','*','*');\n} {|********|********|}\n\n# The \",\" separator\ndo_execsql_test printf2-4.1 {\n  SELECT printf('|%,d|%,d|',0,-1);\n} {|0|-1|}\ndo_execsql_test printf2-4.2 {\n  SELECT printf('|%,d|%,d|',12,-12);\n} {|12|-12|}\ndo_execsql_test printf2-4.3 {\n  SELECT printf('|%,d|%,d|',123,-123);\n} {|123|-123|}\ndo_execsql_test printf2-4.4 {\n  SELECT printf('|%,d|%,d|',1234,-1234);\n} {|1,234|-1,234|}\ndo_execsql_test printf2-4.5 {\n  SELECT printf('|%,d|%,d|',12345,-12345);\n} {|12,345|-12,345|}\ndo_execsql_test printf2-4.6 {\n  SELECT printf('|%,d|%,d|',123456,-123456);\n} {|123,456|-123,456|}\ndo_execsql_test printf2-4.7 {\n  SELECT printf('|%,d|%,d|',1234567,-1234567);\n} {|1,234,567|-1,234,567|}\ndo_execsql_test printf2-4.8 {\n  SELECT printf('|%,d|%,d|',12345678,-12345678);\n} {|12,345,678|-12,345,678|}\ndo_execsql_test printf2-4.9 {\n  SELECT printf('|%,d|%,d|',123456789,-123456789);\n} {|123,456,789|-123,456,789|}\ndo_execsql_test printf2-4.10 {\n  SELECT printf('|%,d|%,d|',1234567890,-1234567890);\n} {|1,234,567,890|-1,234,567,890|}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/progress.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the 'progress callback'.\n#\n# $Id: progress.test,v 1.8 2007/06/15 14:53:53 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the progress callback is not available in this build, skip this\n# whole file.\nifcapable !progress {\n  finish_test\n  return\n}\n\n# Build some test data\n#\nexecsql {\n  BEGIN;\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n  INSERT INTO t1 VALUES(3);\n  INSERT INTO t1 VALUES(4);\n  INSERT INTO t1 VALUES(5);\n  INSERT INTO t1 VALUES(6);\n  INSERT INTO t1 VALUES(7);\n  INSERT INTO t1 VALUES(8);\n  INSERT INTO t1 VALUES(9);\n  INSERT INTO t1 VALUES(10);\n  COMMIT;\n}\n\n\n# Test that the progress callback is invoked.\ndo_test progress-1.0 {\n  set counter 0\n  db progress 1 \"[namespace code {incr counter}] ; expr 0\"\n  execsql {\n    SELECT * FROM t1\n  }\n  expr $counter > 1\n} 1\ndo_test progress-1.0.1 {\n  db progress\n} {::namespace inscope :: {incr counter} ; expr 0}\ndo_test progress-1.0.2 {\n  set v [catch {db progress xyz bogus} msg]\n  lappend v $msg\n} {1 {expected integer but got \"xyz\"}}\n\n# Test that the query is abandoned when the progress callback returns non-zero\ndo_test progress-1.1 {\n  set counter 0\n  db progress 1 \"[namespace code {incr counter}] ; expr 1\"\n  set rc [catch {execsql {\n    SELECT * FROM t1\n  }}]\n  list $counter $rc\n} {1 1}\n\n# Test that the query is rolled back when the progress callback returns\n# non-zero.\ndo_test progress-1.2 {\n\n  # This figures out how many opcodes it takes to copy 5 extra rows into t1.\n  db progress 1 \"[namespace code {incr five_rows}] ; expr 0\"\n  set five_rows 0\n  execsql {\n    INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 6\n  }\n  db progress 0 \"\"\n  execsql {\n    DELETE FROM t1 WHERE a > 10\n  }\n\n  # Now set up the progress callback to abandon the query after the number of\n  # opcodes to copy 5 rows. That way, when we try to copy 6 rows, we know\n  # some data will have been inserted into the table by the time the progress\n  # callback abandons the query.\n  db progress $five_rows \"expr 1\"\n  catchsql {\n    INSERT INTO t1 SELECT a+10 FROM t1 WHERE a < 9\n  }\n  execsql {\n    SELECT count(*) FROM t1\n  }\n} 10\n\n# Test that an active transaction remains active and not rolled back \n# after the progress query abandons a query. \n#\n# UPDATE: It is now recognised that this is a sure route to database\n# corruption. So the transaction is rolled back.\ndo_test progress-1.3 {\n\n  db progress 0 \"\"\n  execsql BEGIN\n  execsql {\n    INSERT INTO t1 VALUES(11)\n  }\n  db progress 1 \"expr 1\"\n  catchsql {\n    INSERT INTO t1 VALUES(12)\n  }\n  db progress 0 \"\"\n  catchsql COMMIT\n} {1 {cannot commit - no transaction is active}}\ndo_test progress-1.3.1 {\n  execsql {\n    SELECT count(*) FROM t1\n  }\n} 10\n\n# Check that a value of 0 for N means no progress callback\ndo_test progress-1.4 {\n  set counter 0\n  db progress 0 \"[namespace code {incr counter}] ; expr 0\"\n  execsql {\n    SELECT * FROM t1;\n  }\n  set counter\n} 0\n\ndb progress 0 \"\"\n\n# Make sure other queries can be run from within the progress\n# handler.  Ticket #1827\n#\ndo_test progress-1.5 {\n  set rx 0\n  proc set_rx {args} {\n    db progress 0 {}\n    set ::rx [db eval {SELECT count(*) FROM t1}]\n    return [expr 0]\n  }\n  db progress 10 set_rx\n  db eval {\n    SELECT sum(a) FROM t1\n  }\n} {55}\ndo_test progress-1.6 {\n  set ::rx\n} {10}\n\n# Check that abandoning a query using the progress handler does\n# not cause other queries to abort. Ticket #2415.\ndo_test progress-1.7 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(4, 5, 6);\n    INSERT INTO abc VALUES(7, 8, 9);\n  }\n\n  set ::res [list]\n  db eval {SELECT a, b, c FROM abc} {\n    lappend ::res $a $b $c\n    db progress 5 \"expr 1\"\n    catch {db eval {SELECT a, b, c FROM abc} { }} msg\n    db progress 5 \"expr 0\"\n    lappend ::res $msg\n  }\n\n  set ::res\n} {1 2 3 interrupted 4 5 6 interrupted 7 8 9 interrupted}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/ptrchng.test",
    "content": "# 2007 April 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# The focus of the tests in this file are to verify that the\n# underlying TEXT or BLOB representation of an sqlite3_value\n# changes appropriately when APIs from the following set are\n# called:\n#\n#     sqlite3_value_text()\n#     sqlite3_value_text16()\n#     sqlite3_value_blob()\n#     sqlite3_value_bytes()\n#     sqlite3_value_bytes16()\n#\n# $Id: ptrchng.test,v 1.5 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !bloblit {\n  finish_test\n  return\n}\n\n# Register the \"pointer_change\" SQL function.\n#\nsqlite3_create_function db\n\ndo_test ptrchng-1.1 {\n  execsql {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y BLOB);\n    INSERT INTO t1 VALUES(1, 'abc');\n    INSERT INTO t1 VALUES(2, \n       'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234356789');\n    INSERT INTO t1 VALUES(3, x'626c6f62');\n    INSERT INTO t1 VALUES(4,\n x'000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324'\n    );\n    SELECT count(*) FROM t1;\n  }\n} {4}\n\n# For the short entries that fit in the Mem.zBuf[], the pointer should\n# never change regardless of what type conversions occur.\n#\n# UPDATE: No longer true, as Mem.zBuf[] has been removed.\n#\ndo_test ptrchng-2.1 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=1\n  }\n} {0}\ndo_test ptrchng-2.2 {\n  execsql {\n    SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=1\n  }\n} {0}\nifcapable utf16 {\n  do_test ptrchng-2.3 {\n    execsql {\n      SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=1\n    }\n  } {1}\n  do_test ptrchng-2.4 {\n    execsql {\n      SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=1\n    }\n  } {1}\n  do_test ptrchng-2.5 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=1\n    }\n  } {0}\n  do_test ptrchng-2.6 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=1\n    }\n  } {1}\n}\ndo_test ptrchng-2.11 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=3\n  }\n} {0}\ndo_test ptrchng-2.12 {\n  execsql {\n    SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=3\n  }\n} {0}\nifcapable utf16 {\n  do_test ptrchng-2.13 {\n    execsql {\n      SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=3\n    }\n  } {1}\n  do_test ptrchng-2.14 {\n    execsql {\n      SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=3\n    }\n  } {1}\n  do_test ptrchng-2.15 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=3\n    }\n  } {0}\n  do_test ptrchng-2.16 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=3\n    }\n  } {1}\n}\n\n# For the long entries that do not fit in the Mem.zBuf[], the pointer\n# should change sometimes.\n#\ndo_test ptrchng-3.1 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=2\n  }\n} {0}\ndo_test ptrchng-3.2 {\n  execsql {\n    SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=2\n  }\n} {0}\nifcapable utf16 {\n  do_test ptrchng-3.3 {\n    execsql {\n      SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=2\n    }\n  } {1}\n  do_test ptrchng-3.4 {\n    execsql {\n      SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=2\n    }\n  } {1}\n  do_test ptrchng-3.5 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=2\n    }\n  } {0}\n  do_test ptrchng-3.6 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=2\n    }\n  } {1}\n}\ndo_test ptrchng-3.11 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=4\n  }\n} {0}\ndo_test ptrchng-3.12 {\n  execsql {\n    SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=4\n  }\n} {0}\nifcapable utf16 {\n  do_test ptrchng-3.13 {\n    execsql {\n      SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=4\n    }\n  } {1}\n  do_test ptrchng-3.14 {\n    execsql {\n      SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=4\n    }\n  } {1}\n  do_test ptrchng-3.15 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=4\n    }\n  } {0}\n  do_test ptrchng-3.16 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=4\n    }\n  } {1}\n}\n\n# A call to _bytes() should never reformat a _text() or _blob().\n#\ndo_test ptrchng-4.1 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'bytes', 'text') FROM t1\n  }\n} {0 0 0 0}\ndo_test ptrchng-4.2 {\n  execsql {\n    SELECT pointer_change(y, 'blob', 'bytes', 'blob') FROM t1\n  }\n} {0 0 0 0}\n\n# A call to _blob() should never trigger a reformat\n#\ndo_test ptrchng-5.1 {\n  execsql {\n    SELECT pointer_change(y, 'text', 'bytes', 'blob') FROM t1\n  }\n} {0 0 0 0}\nifcapable utf16 {\n  do_test ptrchng-5.2 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1\n    }\n  } {0 0 0 0}\n  do_test ptrchng-5.3 {\n    execsql {\n      SELECT pointer_change(y, 'text16', 'bytes16', 'blob') FROM t1\n    }\n  } {0 0 0 0}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/pushdown.test",
    "content": "# 2017 April 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix pushdown\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, 'b1', 'c1');\n  INSERT INTO t1 VALUES(2, 'b2', 'c2');\n  INSERT INTO t1 VALUES(3, 'b3', 'c3');\n  INSERT INTO t1 VALUES(4, 'b4', 'c4');\n  CREATE INDEX i1 ON t1(a, c);\n}\n\nproc f {val} {\n  lappend ::L $val\n  return 0\n}\ndb func f f \n\ndo_test 1.1 {\n  set L [list]\n  execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }\n  set L\n} {c2}\n\ndo_test 1.2 {\n  set L [list]\n  execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }\n  set L\n} {c3}\n\ndo_execsql_test 1.3 {\n  DROP INDEX i1;\n  CREATE INDEX i1 ON t1(a, b);\n}\ndo_test 1.4 {\n  set L [list]\n  execsql { SELECT * FROM t1 WHERE a=2 AND f(b) AND f(c) }\n  set L\n} {b2}\n\ndo_test 1.5 {\n  set L [list]\n  execsql { SELECT * FROM t1 WHERE a=3 AND f(c) AND f(b) }\n  set L\n} {b3}\n\n#-----------------------------------------------\n\ndo_execsql_test 2.0 {\n  CREATE TABLE u1(a, b, c);\n  CREATE TABLE u2(x, y, z);\n\n  INSERT INTO u1 VALUES('a1', 'b1', 'c1');\n  INSERT INTO u2 VALUES('a1', 'b1', 'c1');\n}\n\ndo_test 2.1 {\n  set L [list]\n  execsql {\n    SELECT * FROM u1 WHERE f('one')=123 AND 123=(\n      SELECT x FROM u2 WHERE x=a AND f('two')\n    )\n  }\n  set L\n} {one}\n\ndo_test 2.2 {\n  set L [list]\n  execsql {\n    SELECT * FROM u1 WHERE 123=(\n      SELECT x FROM u2 WHERE x=a AND f('two')\n    ) AND f('three')=123\n  }\n  set L\n} {three}\n\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/queryonly.test",
    "content": "# 2013-07-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests the \"query_only\" pragma.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test queryonly-1.1 {\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(123),(456);\n  SELECT a FROM t1 ORDER BY a;\n} {123 456}\ndo_execsql_test queryonly-1.2 {\n  PRAGMA query_only;\n} {0}\ndo_execsql_test queryonly-1.3 {\n  PRAGMA query_only=ON;\n  PRAGMA query_only;\n} {1}\ndo_test queryonly-1.4 {\n  catchsql {INSERT INTO t1 VALUES(789);}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.5 {\n  catchsql {DELETE FROM t1;}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.6 {\n  catchsql {UPDATE t1 SET a=a+1;}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.7 {\n  catchsql {CREATE TABLE t2(b);}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.8 {\n  catchsql {CREATE INDEX t1a ON t1(a);}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.9 {\n  catchsql {DROP TABLE t1;}\n} {1 {attempt to write a readonly database}}\ndo_test queryonly-1.10 {\n  catchsql {ANALYZE;}\n} {1 {attempt to write a readonly database}}\ndo_execsql_test queryonly-1.11 {\n  SELECT a FROM t1 ORDER BY a;\n} {123 456}\n\ndo_execsql_test queryonly-2.2 {\n  PRAGMA query_only;\n} {1}\ndo_execsql_test queryonly-2.3 {\n  PRAGMA query_only=OFF;\n  PRAGMA query_only;\n} {0}\ndo_execsql_test queryonly-2.4 {\n  INSERT INTO t1 VALUES(789);\n  SELECT a FROM t1 ORDER BY a;\n} {123 456 789}\ndo_execsql_test queryonly-2.5 {\n  UPDATE t1 SET a=a+1;\n  SELECT a FROM t1 ORDER BY a;\n} {124 457 790}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/quick.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nrun_test_suite quick\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/quota-glob.test",
    "content": "# 2011 December 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for the glob-style string compare operator embedded in the\n# quota shim.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ncatch { unset testnum }\ncatch { unset pattern }\ncatch { unset text }\ncatch { unset ans }\n\nforeach {testnum pattern text ans} {\n   1  abcdefg   abcdefg   1\n   2  abcdefG   abcdefg   0\n   3  abcdef    abcdefg   0\n   4  abcdefgh  abcdefg   0\n   5  abcdef?   abcdefg   1\n   6  abcdef?   abcdef    0\n   7  abcdef?   abcdefgh  0\n   8  abcdefg   abcdef?   0\n   9  abcdef?   abcdef?   1\n  10  abc/def   abc/def   1\n  11  abc//def  abc/def   0\n  12  */abc/*   x/abc/y   1\n  13  */abc/*   /abc/     1\n  16  */abc/*   x///a/ab/abc   0\n  17  */abc/*   x//a/ab/abc/   1\n  16  */abc/*   x///a/ab/abc   0\n  17  */abc/*   x//a/ab/abc/   1\n  18  **/abc/** x//a/ab/abc/   1\n  19  *?/abc/*? x//a/ab/abc/y  1\n  20  ?*/abc/?* x//a/ab/abc/y  1\n  21  {abc[cde]efg}   abcbefg  0\n  22  {abc[cde]efg}   abccefg  1\n  23  {abc[cde]efg}   abcdefg  1\n  24  {abc[cde]efg}   abceefg  1\n  25  {abc[cde]efg}   abcfefg  0\n  26  {abc[^cde]efg}  abcbefg  1\n  27  {abc[^cde]efg}  abccefg  0\n  28  {abc[^cde]efg}  abcdefg  0\n  29  {abc[^cde]efg}  abceefg  0\n  30  {abc[^cde]efg}  abcfefg  1\n  31  {abc[c-e]efg}   abcbefg  0\n  32  {abc[c-e]efg}   abccefg  1\n  33  {abc[c-e]efg}   abcdefg  1\n  34  {abc[c-e]efg}   abceefg  1\n  35  {abc[c-e]efg}   abcfefg  0\n  36  {abc[^c-e]efg}  abcbefg  1\n  37  {abc[^c-e]efg}  abccefg  0\n  38  {abc[^c-e]efg}  abcdefg  0\n  39  {abc[^c-e]efg}  abceefg  0\n  40  {abc[^c-e]efg}  abcfefg  1\n  41  {abc[c-e]efg}   abc-efg  0\n  42  {abc[-ce]efg}   abc-efg  1\n  43  {abc[ce-]efg}   abc-efg  1\n  44  {abc[][*?]efg}  {abc]efg} 1\n  45  {abc[][*?]efg}  {abc*efg} 1\n  46  {abc[][*?]efg}  {abc?efg} 1\n  47  {abc[][*?]efg}  {abc[efg} 1\n  48  {abc[^][*?]efg} {abc]efg} 0\n  49  {abc[^][*?]efg} {abc*efg} 0\n  50  {abc[^][*?]efg} {abc?efg} 0\n  51  {abc[^][*?]efg} {abc[efg} 0\n  52  {abc[^][*?]efg} {abcdefg} 1\n  53  {*[xyz]efg}     {abcxefg} 1\n  54  {*[xyz]efg}     {abcwefg} 0\n} {\n  do_test quota-glob-$testnum.1 {\n    sqlite3_quota_glob $::pattern $::text\n  } $::ans\n  do_test quota-glob-$testnum.2 {\n    sqlite3_quota_glob $::pattern [string map {/ \\\\} $::text]\n  } $::ans\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/quota.test",
    "content": "# 2010 September 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_CURDIR is not defined, omit this file.\nifcapable !curdir {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\n\nforcedelete bak.db\nunset -nocomplain defaultVfs\nset defaultVfs [file_control_vfsname db]\ndb close\n\ndo_test quota-1.1 { sqlite3_quota_initialize nosuchvfs 1 } {SQLITE_ERROR}\ndo_test quota-1.2 { sqlite3_quota_initialize \"\" 1 }        {SQLITE_OK}\ndo_test quota-1.3 { sqlite3_quota_initialize \"\" 1 }        {SQLITE_MISUSE}\ndo_test quota-1.4 { sqlite3_quota_shutdown }               {SQLITE_OK}\n\ndo_test quota-1.5 { sqlite3_quota_initialize \"\" 0 }        {SQLITE_OK}\ndo_test quota-1.6 { sqlite3_quota_shutdown }               {SQLITE_OK}\ndo_test quota-1.7 { sqlite3_quota_initialize \"\" 1 }        {SQLITE_OK}\ndo_test quota-1.8 { sqlite3_quota_shutdown }               {SQLITE_OK}\n\n\n#-------------------------------------------------------------------------\n# Some simple warm-body tests with a single database file in rollback \n# mode:\n#\n#   quota-2.1.*: Test that SQLITE_FULL is returned if the database would\n#                exceed the configured quota.\n#\n#   quota-2.2.*: Test that SQLITE_FULL is not returned and the database\n#                grows if the callback extends the quota when the database\n#                attempts to grow beyond the configured quota.\n#\n#   quota-2.3.*: Open and close a db that is not part of any quota group. At\n#                one point this was causing mutex refs to be leaked.\n#\n#   quota-2.4.*: Try to shutdown the quota system before closing the db\n#                file. Check that this fails and the quota system still works\n#                afterwards. Then close the database and successfully shut\n#                down the quota system.\n#   \nsqlite3_quota_initialize \"\" 1\n\nunset -nocomplain quota_request_ok\nproc quota_check {filename limitvar size} {\n  upvar $limitvar limit\n\n  lappend ::quota [set limit] $size\n  if {[info exists ::quota_request_ok]} { set limit $size }\n}\n\ndo_test quota-2.1.1 {\n  sqlite3_quota_set *test.db 4096 quota_check\n} {SQLITE_OK}\ndo_test quota-2.1.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA journal_mode=DELETE;\n  }\n  set ::quota [list]\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randomblob(1100));\n    INSERT INTO t1 VALUES(2, randomblob(1100));\n  }\n  set ::quota\n} {}\ndo_test quota-2.1.2.1 {\n  file_control_vfsname db\n} quota/$defaultVfs\ndo_test quota-2.1.3 { file size test.db } {4096}\ndo_test quota-2.1.4 {\n  catchsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {1 {database or disk is full}}\ndo_test quota-2.1.5 { set ::quota } {4096 5120}\n\nset ::quota_request_ok 1\nset ::quota [list]\ndo_test quota-2.2.1 {\n  execsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {}\ndo_test quota-2.2.2 { set ::quota } {4096 5120}\ndo_test quota-2.2.3 { file size test.db } {5120}\nunset ::quota_request_ok\n\ndo_test quota-2.3.1 {\n  sqlite3 db2 bak.db\n  db2 close\n} {}\n\ndo_test quota-2.4.1 {\n  sqlite3_quota_shutdown\n} {SQLITE_MISUSE}\nset ::quota [list]\ndo_test quota-2.4.2 {\n  catchsql { INSERT INTO t1 VALUES(3, randomblob(1100)) }\n} {1 {database or disk is full}}\ndo_test quota-2.4.3 { set ::quota } {5120 6144}\ndo_test quota-2.4.4 { file size test.db } {5120}\ndo_test quota-2.4.99 {\n  db close\n  sqlite3_quota_shutdown\n} {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# Try some tests with more than one connection to a database file. Still\n# in rollback mode.\n#\n#   quota-3.1.*: Two connections to a single database file.\n#\n#   quota-3.2.*: Two connections to each of several database files (that\n#                are in the same quota group).\n#\nproc quota_check {filename limitvar size} {\n  upvar $limitvar limit\n  lappend ::quota [set limit] $size\n  if {[info exists ::quota_request_ok]} { set limit $size }\n}\n\ndo_test quota-3.1.1 {\n  forcedelete test.db\n  sqlite3_quota_initialize \"\" 1\n  sqlite3_quota_set *test.db 4096 quota_check\n} {SQLITE_OK}\ndo_test quota-3.1.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = delete;\n    PRAGMA auto_vacuum = off;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 'one');\n  }\n  file size test.db\n} {3072}\ndo_test quota-3.1.3 {\n  sqlite3 db2 test.db\n  set ::quota [list]\n  execsql { CREATE TABLE t2(a, b) } db2\n  set ::quota\n} {}\ndo_test quota-3.1.4 {\n  catchsql { CREATE TABLE t3(a, b) }\n} {1 {database or disk is full}}\ndo_test quota-3.1.5 {\n  set ::quota_request_ok 1\n  execsql { CREATE TABLE t3(a, b) }\n} {}\ndo_test quota-3.1.6 {\n  db close\n  db2 close\n  sqlite3_quota_set *test.db 0 {}\n} {SQLITE_OK}\n\ndo_test quota-3.2.1 {\n  delete_file force test.db test2.db \n\n  sqlite3_quota_set * 4096 {}\n  sqlite3 db1a test.db\n  sqlite3 db2a test2.db\n\n  foreach db {db1a db2a} {\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA journal_mode = delete;\n      PRAGMA auto_vacuum = off;\n      CREATE TABLE t1(a, b);\n    } $db\n  }\n\n  sqlite3 db1b test.db\n  sqlite3 db2b test2.db\n\n  list [file size test.db] [file size test2.db]\n} {2048 2048}\n\ncatch { unset ::quota_request_ok }\n\ndo_test quota-3.2.2 { execsql { INSERT INTO t1 VALUES('x', 'y') } db1a } {}\ndo_test quota-3.2.3 { execsql { INSERT INTO t1 VALUES('v', 'w') } db1b } {}\ndo_test quota-3.2.4 { execsql { INSERT INTO t1 VALUES('t', 'u') } db2a } {}\ndo_test quota-3.2.5 { execsql { INSERT INTO t1 VALUES('r', 's') } db2b } {}\n\ndo_test quota-3.2.6 { \n  catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a\n} {1 {database or disk is full}}\ndo_test quota-3.2.7 { \n  catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b\n} {1 {database or disk is full}}\ndo_test quota-3.2.8 { \n  catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a\n} {1 {database or disk is full}}\ndo_test quota-3.2.9 { \n  catchsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b\n} {1 {database or disk is full}}\n\nset ::quota [list]\nproc quota_callback {file limitvar size} {\n  upvar $limitvar limit\n  if {$::tcl_platform(platform)==\"windows\"} {\n    set file [ lindex [string map {\\\\ \\/} $file] 0 ]\n  }\n  lappend ::quota $file $size\n  set limit 0\n}\nsqlite3_quota_set * 4096 quota_callback\ndo_test quota-3.3.1 { \n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1a\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db1b\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2a\n  execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) } db2b\n  set ::quota\n} [list [file join [get_pwd] test.db] 5120]\n\ndo_test quota-3.2.X {\n  foreach db {db1a db2a db2b db1b} { catch { $db close } }\n  sqlite3_quota_set * 0 {}\n} {SQLITE_OK}\n\n#-------------------------------------------------------------------------\n# Quotas are deleted when unused and when their limit is set to zero\n#\n\n# Return a list of all currently defined quotas.  Each quota is identified\n# by its pattern.\nproc quota_list {} {\n  set allq {}\n  foreach q [sqlite3_quota_dump] {\n    lappend allq [lindex $q 0]\n  }\n  return [lsort $allq]\n}\nproc quota_size {name} {\n  set allq {}\n  foreach q [sqlite3_quota_dump] {\n    if {[lindex $q 0]==$name} {return [lindex $q 2]}\n  }\n  return 0\n}\n\ndo_test quota-4.1.1 {\n  sqlite3_quota_set *test.db 0 {}\n  quota_list\n} {}\ndo_test quota-4.1.2 {\n  sqlite3_quota_set *test.db 4096 {}\n  quota_list\n} {*test.db}\ndo_test quota-4.1.3 {\n  sqlite3_quota_set *test2.db 0 {}\n  quota_list\n} {*test.db}\ndo_test quota-4.1.4 {\n  sqlite3_quota_set *test2.db 100000 {}\n  quota_list\n} {*test.db *test2.db}\ndo_test quota-4.1.5 {\n  sqlite3_quota_set *test.db 0 {}\n  quota_list\n} {*test2.db}\ndo_test quota-4.1.6 {\n  forcedelete test2.db test2.db-journal test2.db-wal\n  sqlite3 db test2.db\n  db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');}\n  quota_list\n} {*test2.db}\ndo_test quota-4.1.7 {\n  catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}\n} {1 {database or disk is full}}\ndo_test quota-4.1.8 {\n  sqlite3 db2 test2.db\n  db2 eval {SELECT * FROM t2}\n} {tab-t2}\ndo_test quota-4.1.9 {\n  sqlite3_quota_set *test2.db 0 {}\n  catchsql {INSERT INTO t2 VALUES(zeroblob(200000))}\n} {0 {}}\ndo_test quota-4.1.10 {\n  quota_list\n} {*test2.db}\ndo_test quota-4.1.11 {\n  db2 close\n  quota_list\n} {*test2.db}\ndo_test quota-4.1.12 {\n  db close\n  quota_list\n} {}\n\ndo_test quota-4.2.1 {\n  sqlite3_quota_set A 1000 {}\n  sqlite3_quota_set B 1000 {}\n  sqlite3_quota_set C 1000 {}\n  sqlite3_quota_set D 1000 {}\n  quota_list\n} {A B C D}\ndo_test quota-4.2.2 {\n  sqlite3_quota_set C 0 {}\n  sqlite3_quota_set B 0 {}\n  quota_list\n} {A D}\ndo_test quota-4.2.3 {\n  sqlite3_quota_set A 0 {}\n  sqlite3_quota_set D 0 {}\n  quota_list\n} {}\ndo_test quota-4.2.4 {\n  sqlite3_quota_set A 1000 {}\n  sqlite3_quota_set B 1000 {}\n  sqlite3_quota_set C 1000 {}\n  sqlite3_quota_set A 0 {}\n  sqlite3_quota_set B 0 {}\n  sqlite3_quota_set C 0 {}\n  quota_list\n} {}\ndo_test quota-4.2.5 {\n  sqlite3_quota_set A 1000 {}\n  sqlite3_quota_set B 1000 {}\n  sqlite3_quota_set C 1000 {}\n  sqlite3_quota_set C 0 {}\n  sqlite3_quota_set B 0 {}\n  sqlite3_quota_set A 0 {}\n  quota_list\n} {}\n\ndo_test quota-4.3.1 {\n  sqlite3_quota_set A 1000 quota_callback\n  sqlite3 db A\n  sqlite3_quota_set A 0 quota_callback\n  db close\n  quota_list\n} {}\n\nunset -nocomplain quotagroup\nif {$tcl_platform(platform)==\"windows\"} {\n  set quotagroup *\\\\quota-test-A?.db\n} else {\n  set quotagroup */quota-test-A?.db\n} \nforeach file [glob -nocomplain quota-test-A*] {\n  forcedelete $file\n}\ndo_test quota-4.4.1 {\n  set ::quota {}\n  sqlite3_quota_set $::quotagroup 10000 quota_callback\n  forcedelete ./quota-test-A1.db ./quota-test-A2.db\n  sqlite3 db ./quota-test-A1.db\n  db eval {\n     CREATE TABLE t1(x);\n     INSERT INTO t1 VALUES(randomblob(5000));\n  }\n  quota_list\n} [list $quotagroup]\ndo_test quota-4.4.2 {\n  expr {$::quota==\"\"}\n} {1}\ndo_test quota-4.4.3 {\n  db close\n  sqlite3 db ./quota-test-A2.db\n  db eval {\n     CREATE TABLE t1(x);\n     INSERT INTO t1 VALUES(randomblob(5000));\n  }\n  quota_list\n} [list $quotagroup]\ndo_test quota-4.4.4 {\n  expr {$::quota!=\"\"}\n} {1}\ndo_test quota-4.4.5 {\n  db close\n  sqlite3_quota_set $::quotagroup 0 {}\n  sqlite3_quota_dump\n} {}\ndo_test quota-4.4.6 {\n  sqlite3_quota_set $quotagroup 10000 quota_callback\n  sqlite3 db quota-test-A1.db\n  db eval {SELECT count(*) FROM sqlite_master}\n  quota_size $quotagroup\n} [file size quota-test-A1.db]\ndo_test quota-4.4.7 {\n  sqlite3_quota_file quota-test-A2.db\n  quota_size $::quotagroup\n} [expr {[file size quota-test-A1.db]+[file size quota-test-A2.db]}]\n\nunset -nocomplain quotagroup\nif {$tcl_platform(platform)==\"windows\"} {\n  set quotagroup *\\\\quota-test-B*\n} else {\n  set quotagroup */quota-test-B*\n} \nforeach file [glob -nocomplain quota-test-B*] {\n  forcedelete $file\n}\ndo_test quota-4.5.1 {\n  sqlite3_quota_set $::quotagroup 100000 quota_callback\n  quota_size $::quotagroup\n} {0}\ndo_test quota-4.5.2 {\n  sqlite3_quota_file quota-test-B1.txt\n  quota_size $::quotagroup\n} {0}\nproc add_to_file {name n} {\n  set out [open $name a]\n  fconfigure $out -translation binary\n  puts -nonewline $out [string repeat x $n]\n  close $out\n}\ndo_test quota-4.5.3 {\n  add_to_file quota-test-B1.txt 123\n  sqlite3_quota_file quota-test-B1.txt\n  quota_size $::quotagroup\n} {123}\ndo_test quota-4.5.4 {\n  add_to_file quota-test-B2.txt 234\n  sqlite3_quota_file quota-test-B2.txt\n  quota_size $::quotagroup\n} {357}\ndo_test quota-4.5.5 {\n  add_to_file quota-test-B1.txt 2000\n  sqlite3_quota_file quota-test-B1.txt\n  quota_size $::quotagroup\n} {2357}\ndo_test quota-4.5.6 {\n  forcedelete quota-test-B1.txt\n  sqlite3_quota_file quota-test-B1.txt\n  quota_size $::quotagroup\n} {234}\ndo_test quota-4.5.7 {\n  forcedelete quota-test-B2.txt\n  sqlite3_quota_file quota-test-B2.txt\n  quota_size $::quotagroup\n} {0}\ndo_test quota-4.5.8 {\n  add_to_file quota-test-B3.txt 1234\n  sqlite3_quota_file quota-test-B3.txt\n  quota_size $::quotagroup\n} {1234}\ndo_test quota-4.5.9 {\n  sqlite3_quota_set $quotagroup 0 {}\n  quota_size $::quotagroup\n} {0}\n\ndo_test quota-4.9.1 {\n  db close\n  sqlite3_quota_set A 1000 quota_callback\n  sqlite3_quota_shutdown\n} {SQLITE_OK}\ndo_test quota-4.9.2 {\n  quota_list\n} {}\n\n#-------------------------------------------------------------------------\n# The following tests test that the quota VFS handles malloc and IO \n# errors.\n#\n\nsqlite3_quota_initialize \"\" 1\nsqlite3_quota_set *test.db 4096 {}\n\ndo_faultsim_test quota-5.1 -prep {\n  catch {db close}\n} -body {\n  sqlite3 db test2.db\n}\ndo_faultsim_test quota-5.2 -prep {\n  catch {db close}\n} -body {\n  sqlite3 db test.db\n}\n\ncatch { db close }\nforcedelete test.db\n\ndo_test quota-5.3.prep {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(10, zeroblob(1200));\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test quota-5.3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { DELETE FROM t1 }\n}\n\ndo_test quota-5.4.1 {\n  catch { db close }\n  forcedelete test.db\n  file mkdir test.db\n  list [catch { sqlite3 db test.db } msg] $msg\n} {1 {unable to open database file}}\n\ndo_faultsim_test quota-5.5 -prep {\n  catch { sqlite3_quota_shutdown }\n} -body {\n  sqlite3_quota_initialize \"\" 1\n}\n\ndo_faultsim_test quota-5.6 -prep {\n  catch { sqlite3_quota_shutdown }\n  sqlite3_quota_initialize \"\" 1\n} -body {\n  sqlite3_quota_set * 4096 {}\n}\n\ncatch { sqlite3_quota_shutdown }\ncatch { db close }\nforcedelete test.db\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/quota2.test",
    "content": "# 2011 December 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If SQLITE_CURDIR is not defined, omit this file.\nifcapable !curdir {\n  finish_test\n  return\n}\n\nsource $testdir/malloc_common.tcl\n\ndb close\nsqlite3_quota_initialize \"\" 1\n\nforeach dir {quota2a/x1 quota2a/x2 quota2a quota2b quota2c} {\n  forcedelete $dir\n}\nforeach dir {quota2a quota2a/x1 quota2a/x2 quota2b quota2c} {\n  file mkdir $dir\n}\n\n# The standard_path procedure converts a pathname into a standard format\n# that is the same across platforms.\n#\nunset -nocomplain ::quota_pwd ::quota_mapping\nset ::quota_pwd [string map {\\\\ /} [get_pwd]]\nset ::quota_mapping [list $::quota_pwd PWD]\nproc standard_path {x} {\n  set x [string map {\\\\ /} $x]\n  return [string map $::quota_mapping $x]\n}\n\n# The quota_check procedure is a callback from the quota handler.\n# It has three arguments which are (1) the full pathname of the file\n# that has gone over quota, (2) the quota limit, (3) the requested\n# new quota size to cover the last write.  These three values are\n# appended to the global variable $::quota.  The filename is processed\n# to convert every \\ character into / and to change the name of the\n# working directory to PWD.  \n#\n# The quota is increased to the request if the ::quota_request_ok \n# global variable is true.\n#\nset ::quota {}\nset ::quota_request_ok 0\n\nproc quota_check {filename limitvar size} {\n  upvar $limitvar limit\n  lappend ::quota [standard_path $filename] [set limit] $size\n  if {$::quota_request_ok} {set limit $size}\n}\n\nsqlite3_quota_set */quota2a/* 4000 quota_check\nsqlite3_quota_set */quota2b/* 5000 quota_check\n\nunset -nocomplain bigtext\nfor {set i 1} {$i<=1000} {incr i} {\n  if {$i%10==0} {\n    append bigtext [format \"%06d\\n\" $i]\n  } else {\n    append bigtext [format \"%06d \" $i]\n  }\n}\n\ncatch { unset h1 }\ncatch { unset x }\ndo_test quota2-1.1 {\n  set ::h1 [sqlite3_quota_fopen quota2a/xyz.txt w+b]\n  sqlite3_quota_fwrite $::h1 1 7000 $bigtext\n} {4000}\ndo_test quota2-1.2 {\n  set ::quota\n} {PWD/quota2a/xyz.txt 4000 7000}\ndo_test quota2-1.2.1 {\n  sqlite3_quota_file_size $::h1\n} {4000}\ndo_test quota2-1.2.2 {\n  sqlite3_quota_fflush $::h1 1\n  sqlite3_quota_file_truesize $::h1\n} {4000}\ndo_test quota2-1.3 {\n  sqlite3_quota_rewind $::h1\n  set ::x [sqlite3_quota_fread $::h1 1001 7]\n  string length $::x\n} {3003}\ndo_test quota2-1.4 {\n  string match $::x [string range $::bigtext 0 3002]\n} {1}\ndo_test quota2-1.5 {\n  sqlite3_quota_fseek $::h1 0 SEEK_END\n  sqlite3_quota_ftell $::h1\n} {4000}\ndo_test quota2-1.6 {\n  sqlite3_quota_fseek $::h1 -100 SEEK_END\n  sqlite3_quota_ftell $::h1\n} {3900}\ndo_test quota2-1.7 {\n  sqlite3_quota_fseek $::h1 -100 SEEK_CUR\n  sqlite3_quota_ftell $::h1\n} {3800}\ndo_test quota2-1.8 {\n  sqlite3_quota_fseek $::h1 50 SEEK_CUR\n  sqlite3_quota_ftell $::h1\n} {3850}\ndo_test quota2-1.9 {\n  sqlite3_quota_fseek $::h1 50 SEEK_SET\n  sqlite3_quota_ftell $::h1\n} {50}\ndo_test quota2-1.10 {\n  sqlite3_quota_rewind $::h1\n  sqlite3_quota_ftell $::h1\n} {0}\ndo_test quota2-1.11 {\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 1 0}}}\ndo_test quota2-1.12 {\n  sqlite3_quota_ftruncate $::h1 3500\n  sqlite3_quota_file_size $::h1\n} {3500}\ndo_test quota2-1.13 {\n  sqlite3_quota_file_truesize $::h1\n} {3500}\ndo_test quota2-1.14 {\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 3500 {PWD/quota2a/xyz.txt 3500 1 0}}}\ndo_test quota2-1.15 {\n  sqlite3_quota_fseek $::h1 0 SEEK_END\n  sqlite3_quota_ftell $::h1\n} {3500}\ndo_test quota2-1.16 {\n  sqlite3_quota_fwrite $::h1 1 7000 $bigtext\n} {500}\ndo_test quota2-1.17 {\n  sqlite3_quota_ftell $::h1\n} {4000}\ndo_test quota2-1.18 {\n  sqlite3_quota_file_size $::h1\n} {4000}\ndo_test quota2-1.19 {\n  sqlite3_quota_fflush $::h1 1\n  sqlite3_quota_file_truesize $::h1\n} {4000}\ndo_test quota2-1.20 {\n  sqlite3_quota_fclose $::h1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 0 0}}}\ndo_test quota2-1.21 {\n  sqlite3_quota_remove quota2a/xyz.txt\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}\n\n\n\nset quota {}\ndo_test quota2-2.1 {\n  set ::h1 [sqlite3_quota_fopen quota2c/xyz.txt w+b]\n  sqlite3_quota_fwrite $::h1 1 7000 $bigtext\n} {7000}\ndo_test quota2-2.2 {\n  set ::quota\n} {}\ndo_test quota2-2.3.1 {\n  sqlite3_quota_rewind $::h1\n  sqlite3_quota_file_available $::h1\n} {7000}\ndo_test quota2-2.3.2 {\n  set ::x [sqlite3_quota_fread $::h1 1001 7]\n  string length $::x\n} {6006}\ndo_test quota2-2.3.3 {\n  sqlite3_quota_file_available $::h1\n} {0}\ndo_test quota2-2.4 {\n  string match $::x [string range $::bigtext 0 6005]\n} {1}\ndo_test quota2-2.5 {\n  sqlite3_quota_fseek $::h1 0 SEEK_END\n  sqlite3_quota_ftell $::h1\n} {7000}\ndo_test quota2-2.6 {\n  sqlite3_quota_fseek $::h1 -100 SEEK_END\n  sqlite3_quota_ftell $::h1\n} {6900}\ndo_test quota2-2.6.1 {\n  sqlite3_quota_file_available $::h1\n} {100}\ndo_test quota2-2.7 {\n  sqlite3_quota_fseek $::h1 -100 SEEK_CUR\n  sqlite3_quota_ftell $::h1\n} {6800}\ndo_test quota2-2.7.1 {\n  sqlite3_quota_file_available $::h1\n} {200}\ndo_test quota2-2.8 {\n  sqlite3_quota_fseek $::h1 50 SEEK_CUR\n  sqlite3_quota_ftell $::h1\n} {6850}\ndo_test quota2-2.8.1 {\n  sqlite3_quota_file_available $::h1\n} {150}\ndo_test quota2-2.9 {\n  sqlite3_quota_fseek $::h1 50 SEEK_SET\n  sqlite3_quota_ftell $::h1\n} {50}\ndo_test quota2-2.9.1 {\n  sqlite3_quota_file_available $::h1\n} {6950}\ndo_test quota2-2.10 {\n  sqlite3_quota_rewind $::h1\n  sqlite3_quota_ftell $::h1\n} {0}\ndo_test quota2-2.10.1 {\n  sqlite3_quota_file_available $::h1\n} {7000}\ndo_test quota2-2.10.2 {\n  sqlite3_quota_ferror $::h1\n} {0}\ndo_test quota2-2.11 {\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}\ndo_test quota2-2.12 {\n  sqlite3_quota_fclose $::h1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}\n\ndo_test quota2-3.1 {\n  sqlite3_quota_set */quota2b/* 0 quota_check\n  set ::h1 [sqlite3_quota_fopen quota2a/x1/a.txt a]\n  sqlite3_quota_fwrite $::h1 10 10 $bigtext\n} {10}\ndo_test quota2-3.2 {\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}\ndo_test quota2-3.3a {\n  sqlite3_quota_fflush $::h1 0\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}\ndo_test quota2-3.3b {\n  sqlite3_quota_fflush $::h1 1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}\ndo_test quota2-3.3c {\n  sqlite3_quota_fflush $::h1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 1 0}}}\ndo_test quota2-3.4 {\n  sqlite3_quota_fclose $::h1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 100 {PWD/quota2a/x1/a.txt 100 0 0}}}\ndo_test quota2-3.5 {\n  set ::h2 [sqlite3_quota_fopen quota2a/x2/b.txt a]\n  sqlite3_quota_fwrite $::h2 10 20 $bigtext\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 300 {PWD/quota2a/x2/b.txt 200 1 0} {PWD/quota2a/x1/a.txt 100 0 0}}}\ndo_test quota2-3.6 {\n  set ::h3 [sqlite3_quota_fopen quota2a/x1/c.txt a]\n  sqlite3_quota_fwrite $::h3 10 50 $bigtext\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 800 {PWD/quota2a/x1/c.txt 500 1 0} {PWD/quota2a/x2/b.txt 200 1 0} {PWD/quota2a/x1/a.txt 100 0 0}}}\ndo_test quota2-3.7 {\n  file exists quota2a/x1/a.txt\n} {1}\ndo_test quota2-3.8 {\n  file exists quota2a/x2/b.txt\n} {1}\ndo_test quota2-3.9 {\n  file exists quota2a/x1/c.txt\n} {1}\ndo_test quota2-3.10 {\n  sqlite3_quota_remove quota2a/x1\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 700 {PWD/quota2a/x1/c.txt 500 1 1} {PWD/quota2a/x2/b.txt 200 1 0}}}\ndo_test quota2-3.11 {\n  sqlite3_quota_fclose $::h2\n  sqlite3_quota_fclose $::h3\n  standard_path [sqlite3_quota_dump]\n} {{*/quota2a/* 4000 200 {PWD/quota2a/x2/b.txt 200 0 0}}}\ndo_test quota2-3.12 {\n  file exists quota2a/x1/a.txt\n} {0}\ndo_test quota2-3.13 {\n  file exists quota2a/x2/b.txt\n} {1}\ndo_test quota2-3.14 {\n  file exists quota2a/x1/c.txt\n} {0}\n\ncatch { sqlite3_quota_shutdown }\ncatch { unset quota_request_ok }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/quote.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the ability to specify table and column names\n# as quoted strings.\n#\n# $Id: quote.test,v 1.7 2007/04/25 11:32:30 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table with a strange name and with strange column names.\n#\ndo_test quote-1.0 {\n  catchsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}\n} {0 {}}\n\n# Insert, update and query the table.\n#\ndo_test quote-1.1 {\n  catchsql {INSERT INTO '@abc' VALUES(5,'hello')}\n} {0 {}}\ndo_test quote-1.2.1 {\n  catchsql {SELECT * FROM '@abc'}\n} {0 {5 hello}}\ndo_test quote-1.2.2 {\n  catchsql {SELECT * FROM [@abc]}  ;# SqlServer compatibility\n} {0 {5 hello}}\ndo_test quote-1.2.3 {\n  catchsql {SELECT * FROM `@abc`}  ;# MySQL compatibility\n} {0 {5 hello}}\ndo_test quote-1.3 {\n  catchsql {\n    SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'\n  }\n} {0 {hello 10}}\ndo_test quote-1.3.1 {\n  catchsql {\n    SELECT '!pqr', '#xyz'+5 FROM '@abc'\n  }\n} {0 {!pqr 5}}\ndo_test quote-1.3.2 {\n  catchsql {\n    SELECT \"!pqr\", \"#xyz\"+5 FROM '@abc'\n  }\n} {0 {hello 10}}\ndo_test quote-1.3.3 {\n  catchsql {\n    SELECT [!pqr], `#xyz`+5 FROM '@abc'\n  }\n} {0 {hello 10}}\ndo_test quote-1.3.4 {\n  set r [catch {\n    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}\n  } msg ]\n  lappend r $msg\n} {0 {hello 10}}\ndo_test quote-1.4 {\n  set r [catch {\n    execsql {UPDATE '@abc' SET '#xyz'=11}\n  } msg ]\n  lappend r $msg\n} {0 {}}\ndo_test quote-1.5 {\n  set r [catch {\n    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}\n  } msg ]\n  lappend r $msg\n} {0 {hello 16}}\n\n# Drop the table with the strange name.\n#\ndo_test quote-1.6 {\n  set r [catch {\n    execsql {DROP TABLE '@abc'}\n  } msg ]\n  lappend r $msg\n} {0 {}}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/randexpr1.tcl",
    "content": "# Run this TCL script to generate thousands of test cases containing\n# complicated expressions.\n#\n# The generated tests are intended to verify expression evaluation\n# in SQLite against expression evaluation TCL.  \n#\n\n# Terms of the $intexpr list each contain two sub-terms.\n#\n#     *  An SQL expression template\n#     *  The equivalent TCL expression\n#\n# EXPR is replaced by an integer subexpression.  BOOL is replaced\n# by a boolean subexpression.\n#\nset intexpr {\n  {11 wide(11)}\n  {13 wide(13)}\n  {17 wide(17)}\n  {19 wide(19)}\n  {a $a}\n  {b $b}\n  {c $c}\n  {d $d}\n  {e $e}\n  {f $f}\n  {t1.a $a}\n  {t1.b $b}\n  {t1.c $c}\n  {t1.d $d}\n  {t1.e $e}\n  {t1.f $f}\n  {(EXPR) (EXPR)}\n  {{ -EXPR} {-EXPR}}\n  {+EXPR +EXPR}\n  {~EXPR ~EXPR}\n  {EXPR+EXPR EXPR+EXPR}\n  {EXPR-EXPR EXPR-EXPR}\n  {EXPR*EXPR EXPR*EXPR}\n  {EXPR+EXPR EXPR+EXPR}\n  {EXPR-EXPR EXPR-EXPR}\n  {EXPR*EXPR EXPR*EXPR}\n  {EXPR+EXPR EXPR+EXPR}\n  {EXPR-EXPR EXPR-EXPR}\n  {EXPR*EXPR EXPR*EXPR}\n  {{EXPR | EXPR} {EXPR | EXPR}}\n  {(abs(EXPR)/abs(EXPR)) (abs(EXPR)/abs(EXPR))}\n  {\n    {case when BOOL then EXPR else EXPR end}\n    {((BOOL)?EXPR:EXPR)}\n  }\n  {\n    {case when BOOL then EXPR when BOOL then EXPR else EXPR end}\n    {((BOOL)?EXPR:((BOOL)?EXPR:EXPR))}\n  }\n  {\n    {case EXPR when EXPR then EXPR else EXPR end}\n    {(((EXPR)==(EXPR))?EXPR:EXPR)}\n  }\n  {\n    {(select AGG from t1)}\n    {(AGG)}\n  }\n  {\n    {coalesce((select max(EXPR) from t1 where BOOL),EXPR)}\n    {[coalesce_subquery [expr {EXPR}] [expr {BOOL}] [expr {EXPR}]]}\n  }\n  {\n    {coalesce((select EXPR from t1 where BOOL),EXPR)}\n    {[coalesce_subquery [expr {EXPR}] [expr {BOOL}] [expr {EXPR}]]}\n  }\n}\n\n# The $boolexpr list contains terms that show both an SQL boolean\n# expression and its equivalent TCL.\n#\nset boolexpr {\n  {EXPR=EXPR   ((EXPR)==(EXPR))}\n  {EXPR<EXPR   ((EXPR)<(EXPR))}\n  {EXPR>EXPR   ((EXPR)>(EXPR))}\n  {EXPR<=EXPR  ((EXPR)<=(EXPR))}\n  {EXPR>=EXPR  ((EXPR)>=(EXPR))}\n  {EXPR<>EXPR  ((EXPR)!=(EXPR))}\n  {\n    {EXPR between EXPR and EXPR}\n    {[betweenop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]]}\n  }\n  {\n    {EXPR not between EXPR and EXPR}\n    {(![betweenop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}\n  }\n  {\n    {EXPR in (EXPR,EXPR,EXPR)}\n    {([inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}\n  }\n  {\n    {EXPR not in (EXPR,EXPR,EXPR)}\n    {(![inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]])}\n  }\n  {\n    {EXPR in (select EXPR from t1 union select EXPR from t1)}\n    {[inop [expr {EXPR}] [expr {EXPR}] [expr {EXPR}]]}\n  }\n  {\n    {EXPR in (select AGG from t1 union select AGG from t1)}\n    {[inop [expr {EXPR}] [expr {AGG}] [expr {AGG}]]}\n  }\n  {\n    {exists(select 1 from t1 where BOOL)}\n    {(BOOL)}\n  }\n  {\n    {not exists(select 1 from t1 where BOOL)}\n    {!(BOOL)}\n  }\n  {{not BOOL}  !BOOL}\n  {{BOOL and BOOL} {BOOL tcland BOOL}}\n  {{BOOL or BOOL}  {BOOL || BOOL}}\n  {{BOOL and BOOL} {BOOL tcland BOOL}}\n  {{BOOL or BOOL}  {BOOL || BOOL}}\n  {(BOOL) (BOOL)}\n  {(BOOL) (BOOL)}\n}\n\n# Aggregate expressions\n#\nset aggexpr {\n  {count(*) wide(1)}\n  {{count(distinct EXPR)} {[one {EXPR}]}}\n  {{cast(avg(EXPR) AS integer)} (EXPR)}\n  {min(EXPR) (EXPR)}\n  {max(EXPR) (EXPR)}\n  {(AGG) (AGG)}\n  {{ -AGG} {-AGG}}\n  {+AGG +AGG}\n  {~AGG ~AGG}\n  {abs(AGG)  abs(AGG)}\n  {AGG+AGG   AGG+AGG}\n  {AGG-AGG   AGG-AGG}\n  {AGG*AGG   AGG*AGG}\n  {{AGG | AGG}  {AGG | AGG}}\n  {\n    {case AGG when AGG then AGG else AGG end}\n    {(((AGG)==(AGG))?AGG:AGG)}\n  }\n}\n\n# Convert a string containing EXPR, AGG, and BOOL into a string\n# that contains nothing but X, Y, and Z.\n#\nproc extract_vars {a} {\n  regsub -all {EXPR} $a X a\n  regsub -all {AGG} $a Y a\n  regsub -all {BOOL} $a Z a\n  regsub -all {[^XYZ]} $a {} a\n  return $a\n}\n\n\n# Test all templates to make sure the number of EXPR, AGG, and BOOL\n# expressions match.\n#\nforeach term [concat $aggexpr $intexpr $boolexpr] {\n  foreach {a b} $term break\n  if {[extract_vars $a]!=[extract_vars $b]} {\n    error \"mismatch: $term\"\n  }\n}\n\n# Generate a random expression according to the templates given above.\n# If the argument is EXPR or omitted, then an integer expression is\n# generated.  If the argument is BOOL then a boolean expression is\n# produced.\n#\nproc generate_expr {{e EXPR}} {\n  set tcle $e\n  set ne [llength $::intexpr]\n  set nb [llength $::boolexpr]\n  set na [llength $::aggexpr]\n  set div 2\n  set mx 50\n  set i 0\n  while {1} {\n    set cnt 0\n    set re [lindex $::intexpr [expr {int(rand()*$ne)}]]\n    incr cnt [regsub {EXPR} $e [lindex $re 0] e]\n    regsub {EXPR} $tcle [lindex $re 1] tcle\n    set rb [lindex $::boolexpr [expr {int(rand()*$nb)}]]\n    incr cnt [regsub {BOOL} $e [lindex $rb 0] e]\n    regsub {BOOL} $tcle [lindex $rb 1] tcle\n    set ra [lindex $::aggexpr [expr {int(rand()*$na)}]]\n    incr cnt [regsub {AGG} $e [lindex $ra 0] e]\n    regsub {AGG} $tcle [lindex $ra 1] tcle\n\n    if {$cnt==0} break\n    incr i $cnt\n\n    set v1 [extract_vars $e]\n    if {$v1!=[extract_vars $tcle]} {\n      exit\n    }\n\n    if {$i+[string length $v1]>=$mx} {\n      set ne [expr {$ne/$div}]\n      set nb [expr {$nb/$div}]\n      set na [expr {$na/$div}]\n      set div 1\n      set mx [expr {$mx*1000}]\n    }\n  }\n  regsub -all { tcland } $tcle { \\&\\& } tcle\n  return [list $e $tcle]\n}\n\n# Implementation of routines used to implement the IN and BETWEEN\n# operators.\nproc inop {lhs args} {\n  foreach a $args {\n    if {$a==$lhs} {return 1}\n  }\n  return 0\n}\nproc betweenop {lhs first second} {\n  return [expr {$lhs>=$first && $lhs<=$second}]\n}\nproc coalesce_subquery {a b e} {\n  if {$b} {\n    return $a\n  } else {\n    return $e\n  }\n}\nproc one {args} {\n  return 1\n}\n\n# Begin generating the test script:\n#\nputs {# 2008 December 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests randomly generated SQL expressions.  The expressions\n# are generated by a TCL script.  The same TCL script also computes the\n# correct value of the expression.  So, from one point of view, this\n# file verifies the expression evaluation logic of SQLite against the\n# expression evaluation logic of TCL.\n#\n# An early version of this script is how bug #3541 was detected.\n#\n# $Id: randexpr1.tcl,v 1.1 2008/12/15 16:33:30 drh Exp $\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create test data\n#\ndo_test randexpr1-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b,c,d,e,f);\n    INSERT INTO t1 VALUES(100,200,300,400,500,600);\n    SELECT * FROM t1\n  }\n} {100 200 300 400 500 600}\n}\n\n# Test data for TCL evaluation.\n#\nset a [expr {wide(100)}]\nset b [expr {wide(200)}]\nset c [expr {wide(300)}]\nset d [expr {wide(400)}]\nset e [expr {wide(500)}]\nset f [expr {wide(600)}]\n\n# A procedure to generate a test case.\n#\nset tn 0\nproc make_test_case {sql result} {\n  global tn\n  incr tn\n  puts \"do_test randexpr-2.$tn {\\n  db eval {$sql}\\n} {$result}\"\n}\n\n# Generate many random test cases.\n#\nexpr srand(0)\nfor {set i 0} {$i<1000} {incr i} {\n  while {1} {\n    foreach {sqle tcle} [generate_expr EXPR] break;\n    if {[catch {expr $tcle} ans]} {\n      #puts stderr [list $tcle]\n      #puts stderr ans=$ans\n      if {![regexp {divide by zero} $ans]} exit\n      continue\n    }\n    set len [string length $sqle]\n    if {$len<100 || $len>2000} continue\n    if {[info exists seen($sqle)]} continue\n    set seen($sqle) 1\n    break\n  }\n  while {1} {\n    foreach {sqlb tclb} [generate_expr BOOL] break;\n    if {[catch {expr $tclb} bans]} {\n      #puts stderr [list $tclb]\n      #puts stderr bans=$bans\n      if {![regexp {divide by zero} $bans]} exit\n      continue\n    }\n    break\n  }\n  if {$bans} {\n    make_test_case \"SELECT $sqle FROM t1 WHERE $sqlb\" $ans\n    make_test_case \"SELECT $sqle FROM t1 WHERE NOT ($sqlb)\" {}\n  } else {\n    make_test_case \"SELECT $sqle FROM t1 WHERE $sqlb\" {}\n    make_test_case \"SELECT $sqle FROM t1 WHERE NOT ($sqlb)\" $ans\n  }\n  if {[regexp { \\| } $sqle]} {\n    regsub -all { \\| } $sqle { \\& } sqle\n    regsub -all { \\| } $tcle { \\& } tcle\n    if {[catch {expr $tcle} ans]==0} {\n      if {$bans} {\n        make_test_case \"SELECT $sqle FROM t1 WHERE $sqlb\" $ans\n      } else {\n        make_test_case \"SELECT $sqle FROM t1 WHERE NOT ($sqlb)\" $ans\n      }\n    }\n  }\n}\n\n# Terminate the test script\n#\nputs {finish_test}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/randexpr1.test",
    "content": "# 2008 December 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests randomly generated SQL expressions.  The expressions\n# are generated by a TCL script.  The same TCL script also computes the\n# correct value of the expression.  So, from one point of view, this\n# file verifies the expression evaluation logic of SQLite against the\n# expression evaluation logic of TCL.\n#\n# An early version of this script is how bug #3541 was detected.\n#\n# $Id: randexpr1.test,v 1.1 2008/12/15 16:33:30 drh Exp $\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\n# Create test data\n#\ndo_test randexpr1-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b,c,d,e,f);\n    INSERT INTO t1 VALUES(100,200,300,400,500,600);\n    SELECT * FROM t1\n  }\n} {100 200 300 400 500 600}\n\ndo_test randexpr-2.1 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a | d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when  -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) | 17)),13) FROM t1 WHERE not not c=a-+(select case ~case  -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else  -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d}\n} {}\ndo_test randexpr-2.2 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a | d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when  -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) | 17)),13) FROM t1 WHERE NOT (not not c=a-+(select case ~case  -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else  -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d)}\n} {13}\ndo_test randexpr-2.3 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (t1.b,+11,coalesce((select max((abs(17)/abs(t1.f))) from t1 where ((abs(t1.f)/abs(t1.b)) in (select case (min(t1.a & d*d)+(abs(count(*)-count(*)+ -count(*)*max( -t1.c))-max(f))) when  -count(distinct 19) then ((count(*))) else max(13) end from t1 union select count(distinct b) from t1)) or 19 in (t1.a,t1.c,17)),17) & 17)),13) FROM t1 WHERE NOT (not not c=a-+(select case ~case  -~+count(distinct (select count(distinct t1.a)*max(13) from t1))+max( -19*f)*max(f)*max(f)* -count(distinct d)-(count(distinct 11)) | max(t1.f)*count(*) when count(distinct b) then count(distinct t1.b) else  -min(t1.f) end*cast(avg(11) AS integer) when max(t1.f) then max(c) else count(*) end from t1)+d)}\n} {13}\ndo_test randexpr-2.4 {\n  db eval {SELECT t1.c*19-t1.f*19+coalesce((select 17 from t1 where e in (f,case (select cast(avg(t1.a) AS integer) from t1)-t1.d when coalesce((select +case when not exists(select 1 from t1 where 17<>t1.f and ((a))<t1.b) then t1.c when c not between b and 11 then case when t1.c<f then t1.b when e in (t1.d,t1.d, -e) then d else t1.b end else f end+11 from t1 where exists(select 1 from t1 where t1.f in (select (count(distinct f)) from t1 union select max(11) from t1))),e) then 11 else t1.a end,t1.d)),13)*b+b FROM t1 WHERE ~t1.b<case when t1.b+t1.c in (select  -count(distinct 17+coalesce((select max( -f+t1.c-d) from t1 where (19>=a) and t1.b between f and 13),t1.a))+case abs(+(max(19))) | count(distinct t1.e) | count(distinct 19) when count(*) then (max(a)) else count(distinct d) end from t1 union select (count(*)) from t1) and t1.b>=19 then d when t1.b in (select d from t1 union select c from t1) then t1.e else a end}\n} {-2900}\ndo_test randexpr-2.5 {\n  db eval {SELECT t1.c*19-t1.f*19+coalesce((select 17 from t1 where e in (f,case (select cast(avg(t1.a) AS integer) from t1)-t1.d when coalesce((select +case when not exists(select 1 from t1 where 17<>t1.f and ((a))<t1.b) then t1.c when c not between b and 11 then case when t1.c<f then t1.b when e in (t1.d,t1.d, -e) then d else t1.b end else f end+11 from t1 where exists(select 1 from t1 where t1.f in (select (count(distinct f)) from t1 union select max(11) from t1))),e) then 11 else t1.a end,t1.d)),13)*b+b FROM t1 WHERE NOT (~t1.b<case when t1.b+t1.c in (select  -count(distinct 17+coalesce((select max( -f+t1.c-d) from t1 where (19>=a) and t1.b between f and 13),t1.a))+case abs(+(max(19))) | count(distinct t1.e) | count(distinct 19) when count(*) then (max(a)) else count(distinct d) end from t1 union select (count(*)) from t1) and t1.b>=19 then d when t1.b in (select d from t1 union select c from t1) then t1.e else a end)}\n} {}\ndo_test randexpr-2.6 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 | t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE t1.b<case when exists(select 1 from t1 where not  -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d}\n} {11}\ndo_test randexpr-2.7 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 | t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE NOT (t1.b<case when exists(select 1 from t1 where not  -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d)}\n} {}\ndo_test randexpr-2.8 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where e not in (~t1.d,+case when t1.c<b then t1.e else t1.a end-11 & t1.f,c) or b in (select cast(avg(b) AS integer)*(~abs((count(*))))* -( -cast(avg(e) AS integer)) from t1 union select min(t1.c) from t1)) then t1.f when not exists(select 1 from t1 where not c<>d) then 17 else t1.e end in (a,t1.e,17) or (not exists(select 1 from t1 where a in (f,t1.c,t1.a))) then 11 else 13 end FROM t1 WHERE t1.b<case when exists(select 1 from t1 where not  -(select min(t1.b*b*t1.a+t1.d)+abs(case count(*) | (cast(avg(c) AS integer)) when max(17) then min(c) else (min(13)) end)+min(e) from t1) not in (t1.c,f-d,11) and c not between (19) and e) then ~13*t1.a when 13 not in (t1.e,c,11) then b else t1.c end*c-t1.d}\n} {11}\ndo_test randexpr-2.9 {\n  db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) | f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13)}\n} {}\ndo_test randexpr-2.10 {\n  db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) | f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE NOT (case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13))}\n} {-670}\ndo_test randexpr-2.11 {\n  db eval {SELECT coalesce((select max(11- -19-f-t1.b+a) from t1 where exists(select 1 from t1 where 11-~(d)-c*a*~t1.a-t1.e-t1.e+coalesce((select coalesce((select t1.c from t1 where case (c) when d then e else 11 end=t1.f),t1.d) from t1 where (t1.d)>b), -11) & f+t1.f not in (((c)),b,13))),f) FROM t1 WHERE NOT (case when 19+c>=t1.a then t1.c when not case when not exists(select 1 from t1 where +f | b*b*19+19*13-a | case when t1.e not in (t1.f,t1.c,b) then 11 when 17>t1.c then a else e end<>e) then b when 17=t1.e then b else e end<>t1.b then a else d end-t1.b=(13))}\n} {-670}\ndo_test randexpr-2.12 {\n  db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b | coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end | b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d}\n} {}\ndo_test randexpr-2.13 {\n  db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b | coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end | b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d)}\n} {0}\ndo_test randexpr-2.14 {\n  db eval {SELECT (abs(17)/abs(~case when (abs(t1.c* -(abs(case b & coalesce((select max(17*e*case when 11 in (select t1.b from t1 union select t1.c from t1) then 19 when d between f and t1.e then t1.e else t1.e end & b) from t1 where (13 not in (11,t1.d,e))),e)*a*d when 11 then e else d end*17)/abs(19)))/abs(t1.e))<>e then t1.b else t1.d end*(19))) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d+11 in (case t1.b++c when +a*(+case (select count(*) from t1) when 19 then t1.c else a end) then t1.a else case when (t1.b> -d) and not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs( -f*a+c*11))<>a)) then 13 else 19 end end,17,a)) or c=t1.d)}\n} {0}\ndo_test randexpr-2.15 {\n  db eval {SELECT coalesce((select t1.c from t1 where e not between 19 and b*d or not exists(select 1 from t1 where t1.a not in (case when d not between b+~(t1.d)-case when ((t1.f<=t1.e) and  -11<f) then e*(abs(t1.a)/abs((t1.c))) else c end+b and t1.e then e when not exists(select 1 from t1 where 11<17) then a else t1.f end,(c),c))),t1.d) FROM t1 WHERE t1.c*((select  -count(distinct t1.a) | + -count(distinct t1.b)*cast(avg(a) AS integer)-cast(avg(13) AS integer) | ~abs(min(17)) |  -min(c)*(count(distinct t1.e)) from t1)- -(abs(+t1.b-13)/abs(11)))+t1.f-coalesce((select max(f) from t1 where t1.d between c and t1.a),17)*a in (select 17 from t1 union select  -17 from t1)}\n} {}\ndo_test randexpr-2.16 {\n  db eval {SELECT coalesce((select t1.c from t1 where e not between 19 and b*d or not exists(select 1 from t1 where t1.a not in (case when d not between b+~(t1.d)-case when ((t1.f<=t1.e) and  -11<f) then e*(abs(t1.a)/abs((t1.c))) else c end+b and t1.e then e when not exists(select 1 from t1 where 11<17) then a else t1.f end,(c),c))),t1.d) FROM t1 WHERE NOT (t1.c*((select  -count(distinct t1.a) | + -count(distinct t1.b)*cast(avg(a) AS integer)-cast(avg(13) AS integer) | ~abs(min(17)) |  -min(c)*(count(distinct t1.e)) from t1)- -(abs(+t1.b-13)/abs(11)))+t1.f-coalesce((select max(f) from t1 where t1.d between c and t1.a),17)*a in (select 17 from t1 union select  -17 from t1))}\n} {400}\ndo_test randexpr-2.17 {\n  db eval {SELECT +t1.f*~t1.c-coalesce((select max(~b) from t1 where t1.e+11-(abs(e+case d when b then case when f=(13) then (abs(13+b*t1.f)/abs(t1.c)) when d<=t1.e then 13 else a end else 19 end*13+f)/abs((a)))*17<=c),b)-13*c FROM t1 WHERE not exists(select 1 from t1 where coalesce((select max(case when case when exists(select 1 from t1 where ~t1.d+d in (select ~count(distinct 13) from t1 union select count(*)+~abs(+(~min(t1.a))) from t1)) then t1.e+t1.c else  -(abs(t1.d)/abs(coalesce((select max(t1.d) from t1 where d not in (17,f,f)),11)*t1.c)) end<=(11) then 19 else (t1.e) end) from t1 where (13=11)),c) not between 13 and 19)}\n} {}\ndo_test randexpr-2.18 {\n  db eval {SELECT +t1.f*~t1.c-coalesce((select max(~b) from t1 where t1.e+11-(abs(e+case d when b then case when f=(13) then (abs(13+b*t1.f)/abs(t1.c)) when d<=t1.e then 13 else a end else 19 end*13+f)/abs((a)))*17<=c),b)-13*c FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select max(case when case when exists(select 1 from t1 where ~t1.d+d in (select ~count(distinct 13) from t1 union select count(*)+~abs(+(~min(t1.a))) from t1)) then t1.e+t1.c else  -(abs(t1.d)/abs(coalesce((select max(t1.d) from t1 where d not in (17,f,f)),11)*t1.c)) end<=(11) then 19 else (t1.e) end) from t1 where (13=11)),c) not between 13 and 19))}\n} {-184299}\ndo_test randexpr-2.19 {\n  db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) | t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) |  -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE t1.c not between ~case when case when (select  - -abs( -case  -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c}\n} {}\ndo_test randexpr-2.20 {\n  db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) | t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) |  -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE NOT (t1.c not between ~case when case when (select  - -abs( -case  -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c)}\n} {-589}\ndo_test randexpr-2.21 {\n  db eval {SELECT case when (a not in (t1.e,(+case when t1.b<=(abs(coalesce((select max(a+(select count(distinct (select max(((abs( -t1.d)/abs(a))) & t1.c)*min(t1.e) from t1)) from t1)) from t1 where +t1.f>e),17))/abs( - -17)) then 17 else t1.d end-t1.b-d) &  -f,c)) then 11-t1.f when ( -13<e) then t1.d else a end FROM t1 WHERE NOT (t1.c not between ~case when case when (select  - -abs( -case  -count(distinct c) when count(*) then max(c) else count(distinct 13) end) | min(c) from t1) in (t1.f,b+11,19*t1.d) then 19 else a end*t1.b>13 or t1.e in (select (count(*)) from t1 union select cast(avg(t1.e) AS integer) from t1) or 19>17 and 13 not between 19 and 17 then (t1.f) when not t1.b<>t1.f or d<>b then t1.e else a end and c)}\n} {-589}\ndo_test randexpr-2.22 {\n  db eval {SELECT t1.a | case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end | 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between  -11 and t1.f),f) then e else t1.c end | a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end | f FROM t1 WHERE coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11}\n} {636}\ndo_test randexpr-2.23 {\n  db eval {SELECT t1.a | case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end | 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between  -11 and t1.f),f) then e else t1.c end | a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end | f FROM t1 WHERE NOT (coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11)}\n} {}\ndo_test randexpr-2.24 {\n  db eval {SELECT t1.a & case when e in (select (13) from t1 union select d from t1) then (17) when c*~case (17) when coalesce((select max(case when case when 19 in (13,t1.f,11) then t1.b else t1.b end & 11>t1.a then 11 else t1.b end-b) from t1 where (13 not in (a,19,b)) and t1.a not between  -11 and t1.f),f) then e else t1.c end & a in (select 11 from t1 union select t1.d from t1) then 17 else t1.a end & f FROM t1 WHERE coalesce((select t1.a*t1.a from t1 where ~ -(abs((select abs(count(*))-count(distinct t1.d*11) from t1)*+b)/abs(~t1.c))+c not in (coalesce((select ~13*t1.a from t1 where f+(abs(d* -t1.f)/abs(t1.c))<=t1.b or not t1.a<=t1.c),t1.c),e,(t1.e))),(a))+11<>11}\n} {64}\ndo_test randexpr-2.25 {\n  db eval {SELECT c*coalesce((select ~19-e from t1 where not exists(select 1 from t1 where case when t1.b<>(d) then case when exists(select 1 from t1 where not exists(select 1 from t1 where case t1.e when e*(11) then 13 else 11 end in (select t1.a from t1 union select 13 from t1))) then coalesce((select case when f in (select t1.c from t1 union select (t1.b) from t1) then f else a end from t1 where t1.f not between 17 and f), -f) else 11 end else (a) end*d not in (e,t1.c,t1.e))),t1.e)-a FROM t1 WHERE 19+(select cast(avg((abs(t1.d)/abs(coalesce((select max(+b-(t1.e+b+ -c)*19) from t1 where 11 not between t1.b and f), -17)))*(11)) AS integer) from t1)*f in (select count(*) from t1 union select case max(t1.d)-( -min(t1.d)*(+max(e))) when max(t1.a) then cast(avg(t1.d) AS integer)-(count(distinct t1.f))-( -cast(avg(f) AS integer)) else max(t1.e) end from t1)}\n} {}\ndo_test randexpr-2.26 {\n  db eval {SELECT c*coalesce((select ~19-e from t1 where not exists(select 1 from t1 where case when t1.b<>(d) then case when exists(select 1 from t1 where not exists(select 1 from t1 where case t1.e when e*(11) then 13 else 11 end in (select t1.a from t1 union select 13 from t1))) then coalesce((select case when f in (select t1.c from t1 union select (t1.b) from t1) then f else a end from t1 where t1.f not between 17 and f), -f) else 11 end else (a) end*d not in (e,t1.c,t1.e))),t1.e)-a FROM t1 WHERE NOT (19+(select cast(avg((abs(t1.d)/abs(coalesce((select max(+b-(t1.e+b+ -c)*19) from t1 where 11 not between t1.b and f), -17)))*(11)) AS integer) from t1)*f in (select count(*) from t1 union select case max(t1.d)-( -min(t1.d)*(+max(e))) when max(t1.a) then cast(avg(t1.d) AS integer)-(count(distinct t1.f))-( -cast(avg(f) AS integer)) else max(t1.e) end from t1))}\n} {149900}\ndo_test randexpr-2.27 {\n  db eval {SELECT (abs((select (case abs(min(t1.f)) | count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) | max(t1.d) end) from t1))/abs(~c+(select  -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE 11>=t1.f}\n} {}\ndo_test randexpr-2.28 {\n  db eval {SELECT (abs((select (case abs(min(t1.f)) | count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) | max(t1.d) end) from t1))/abs(~c+(select  -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE NOT (11>=t1.f)}\n} {0}\ndo_test randexpr-2.29 {\n  db eval {SELECT (abs((select (case abs(min(t1.f)) & count(distinct e) when (~+count(*)+max(e)++abs(cast(avg(~19) AS integer))) then +cast(avg(c) AS integer) else ~ -max(+t1.b)+~max(19)*count(distinct a)*min(17) & max(t1.d) end) from t1))/abs(~c+(select  -(count(distinct t1.e)) from t1)-11+t1.e)) FROM t1 WHERE NOT (11>=t1.f)}\n} {1}\ndo_test randexpr-2.30 {\n  db eval {SELECT (select +count(distinct case when 11=a or e<+t1.f+t1.c and not exists(select 1 from t1 where not t1.a-t1.b=~a and f<=coalesce((select max((e)) from t1 where +t1.f>=b),t1.d)*13) and t1.c>t1.e and t1.a<17 then f when a<c then t1.d else c end) from t1) FROM t1 WHERE t1.b=case t1.e | f+t1.d when case when t1.f | t1.e in (select  -+min(case when t1.c in (select t1.b from t1 union select b-19*(abs(b)/abs(t1.b*case when not exists(select 1 from t1 where t1.a in (select ~cast(avg(d) AS integer) from t1 union select max(t1.f) from t1)) then ~(13) when  -c=t1.b then t1.c else f end)) from t1) then e else 17 end) from t1 union select max((a)) from t1) then  -b else t1.d end+13 then a else 13 end}\n} {}\ndo_test randexpr-2.31 {\n  db eval {SELECT (select +count(distinct case when 11=a or e<+t1.f+t1.c and not exists(select 1 from t1 where not t1.a-t1.b=~a and f<=coalesce((select max((e)) from t1 where +t1.f>=b),t1.d)*13) and t1.c>t1.e and t1.a<17 then f when a<c then t1.d else c end) from t1) FROM t1 WHERE NOT (t1.b=case t1.e | f+t1.d when case when t1.f | t1.e in (select  -+min(case when t1.c in (select t1.b from t1 union select b-19*(abs(b)/abs(t1.b*case when not exists(select 1 from t1 where t1.a in (select ~cast(avg(d) AS integer) from t1 union select max(t1.f) from t1)) then ~(13) when  -c=t1.b then t1.c else f end)) from t1) then e else 17 end) from t1 union select max((a)) from t1) then  -b else t1.d end+13 then a else 13 end)}\n} {1}\ndo_test randexpr-2.32 {\n  db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end | f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE 13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a}\n} {}\ndo_test randexpr-2.33 {\n  db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end | f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE NOT (13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a)}\n} {581}\ndo_test randexpr-2.34 {\n  db eval {SELECT coalesce((select (select max(t1.a)*(max(a))*max(t1.f*~11*case when b not in ((select min(19) from t1),b,coalesce((select max((t1.f)) from t1 where t1.c in (c,t1.b,(t1.f)) or t1.a<>(c)),b)*t1.b-t1.b) then d else t1.e end & f* -13-c) from t1) from t1 where not ~a<f), -19)+t1.d+b FROM t1 WHERE NOT (13*t1.d between coalesce((select t1.d from t1 where b in (select t1.d from t1 union select case b*t1.f+t1.a*+coalesce((select t1.a from t1 where (not exists(select 1 from t1 where b*t1.c=13))),11)+t1.e when ~f then d+case b when e then f else t1.e end*13 else f end from t1)),19) and t1.d and 19 between 17 and e and a>a)}\n} {581}\ndo_test randexpr-2.35 {\n  db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e | a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not  -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE a<>f+f}\n} {17}\ndo_test randexpr-2.36 {\n  db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e | a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not  -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE NOT (a<>f+f)}\n} {}\ndo_test randexpr-2.37 {\n  db eval {SELECT case when t1.d not in (t1.d,coalesce((select max(11) from t1 where f not between 13 and c-coalesce((select max(d) from t1 where 19 not in ((t1.f),f,11)),t1.d)*t1.e & a),13), -(t1.e)) then t1.b when t1.f=t1.a and exists(select 1 from t1 where b in (select c from t1 union select 11 from t1) and t1.c=b and not  -d in (t1.d,t1.d,t1.b) and d between 11 and c) or d<=17 or a not in (e,19,(t1.b)) then 17 else 11 end FROM t1 WHERE a<>f+f}\n} {17}\ndo_test randexpr-2.38 {\n  db eval {SELECT case 13 when coalesce((select t1.a*d+++b | b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) | +t1.f else t1.c end FROM t1 WHERE coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where  -t1.d not between coalesce((select a from t1 where  -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b)}\n} {}\ndo_test randexpr-2.39 {\n  db eval {SELECT case 13 when coalesce((select t1.a*d+++b | b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) | +t1.f else t1.c end FROM t1 WHERE NOT (coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where  -t1.d not between coalesce((select a from t1 where  -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b))}\n} {300}\ndo_test randexpr-2.40 {\n  db eval {SELECT case 13 when coalesce((select t1.a*d+++b & b+(abs(t1.e)/abs(c))+(select count(*) from t1) from t1 where not exists(select 1 from t1 where 17 in (select d from t1 union select t1.f from t1))),t1.b) then ~t1.c-(select case min(case when 17 not in (19,19,t1.c) then c when 13 between (19) and t1.e then e else 19 end-19) when cast(avg( -11) AS integer) then max(t1.c)* -min(t1.d) else (count(distinct t1.f)) end from t1) & +t1.f else t1.c end FROM t1 WHERE NOT (coalesce((select max(t1.c) from t1 where (abs(t1.b)/abs(a))>=(e)),+ -case when (11<17) then t1.a when t1.a*e=19* -11 and not exists(select 1 from t1 where  -t1.d not between coalesce((select a from t1 where  -t1.c>t1.e), -19) and t1.d and not exists(select 1 from t1 where (t1.e) in (select d from t1 union select t1.c from t1))) then c else a end*a)-t1.b* -(b) in (e,d,b))}\n} {300}\ndo_test randexpr-2.41 {\n  db eval {SELECT case when not exists(select 1 from t1 where ( -case when b in ((11),coalesce((select f from t1 where (not exists(select 1 from t1 where coalesce((select (t1.a) from t1 where e<=a),11) in (select t1.f from t1 union select 13 from t1)) or t1.a>d)),t1.a),t1.e) or not not exists(select 1 from t1 where (t1.f<=(t1.a))) then e*t1.a else t1.c end)<=d and not (t1.e)>=t1.e) then coalesce((select max( -t1.e) from t1 where t1.d between t1.b and t1.c),t1.d) else t1.c end+13*13 FROM t1 WHERE t1.b=t1.f | 19+coalesce((select max(a) from t1 where case t1.e when case when (11<=11 | t1.f and b>=b or t1.f<=a) then case when c between t1.e and b then e else +t1.f end else  -t1.c end then t1.b else 13 end*13 between t1.f and c and exists(select 1 from t1 where (b not between 11 and a)) and f>=t1.b), -t1.b)-c}\n} {}\ndo_test randexpr-2.42 {\n  db eval {SELECT case when not exists(select 1 from t1 where ( -case when b in ((11),coalesce((select f from t1 where (not exists(select 1 from t1 where coalesce((select (t1.a) from t1 where e<=a),11) in (select t1.f from t1 union select 13 from t1)) or t1.a>d)),t1.a),t1.e) or not not exists(select 1 from t1 where (t1.f<=(t1.a))) then e*t1.a else t1.c end)<=d and not (t1.e)>=t1.e) then coalesce((select max( -t1.e) from t1 where t1.d between t1.b and t1.c),t1.d) else t1.c end+13*13 FROM t1 WHERE NOT (t1.b=t1.f | 19+coalesce((select max(a) from t1 where case t1.e when case when (11<=11 | t1.f and b>=b or t1.f<=a) then case when c between t1.e and b then e else +t1.f end else  -t1.c end then t1.b else 13 end*13 between t1.f and c and exists(select 1 from t1 where (b not between 11 and a)) and f>=t1.b), -t1.b)-c)}\n} {569}\ndo_test randexpr-2.43 {\n  db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d | t1.a else case when t1.a-b not between e and  -t1.c* -13 then 19 else d end end),d) | t1.d FROM t1 WHERE +13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then  -+t1.e |  -(coalesce((select max(~coalesce((select ( -13) from t1 where  -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19)}\n} {}\ndo_test randexpr-2.44 {\n  db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d | t1.a else case when t1.a-b not between e and  -t1.c* -13 then 19 else d end end),d) | t1.d FROM t1 WHERE NOT (+13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then  -+t1.e |  -(coalesce((select max(~coalesce((select ( -13) from t1 where  -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19))}\n} {400}\ndo_test randexpr-2.45 {\n  db eval {SELECT coalesce((select c from t1 where t1.a=case when a=t1.b+~(select case cast(avg( -b*13) AS integer) when max(f*13* -c) then (cast(avg(t1.d) AS integer)) else count(distinct t1.e*c) end from t1) then t1.d & t1.a else case when t1.a-b not between e and  -t1.c* -13 then 19 else d end end),d) & t1.d FROM t1 WHERE NOT (+13 in (f,t1.f+t1.f, -coalesce((select max(t1.f) from t1 where (t1.a-13)<=(case (select count(*) from t1) when 13 then  -+t1.e |  -(coalesce((select max(~coalesce((select ( -13) from t1 where  -c<(11) or 11 between a and t1.d),13)*t1.d) from t1 where d not between b and 13),19))*t1.a else 13 end-b-c)),t1.e)-19))}\n} {400}\ndo_test randexpr-2.46 {\n  db eval {SELECT case ~11-13 when 11-d-case when t1.f*+a-t1.a-t1.f=t1.a then a when t1.f between 19-t1.a+coalesce((select a from t1 where e in (select case  -max(t1.c) when count(*) then max(t1.d) else  -(cast(avg((t1.e)) AS integer)) end from t1 union select (max(t1.b)) from t1)), -b) and e or ((11<c)) or e>=t1.d then t1.b else a end+13+(t1.c) then a else  -d end FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (not +t1.b-~a*(d*t1.e | + -coalesce((select t1.c from t1 where t1.b*case t1.b when f then  -a*b else e end<>a+t1.a),17))+e*t1.e*11 | t1.a not between 13 and  -t1.a and b between d and  -f)))}\n} {-400}\ndo_test randexpr-2.47 {\n  db eval {SELECT case ~11-13 when 11-d-case when t1.f*+a-t1.a-t1.f=t1.a then a when t1.f between 19-t1.a+coalesce((select a from t1 where e in (select case  -max(t1.c) when count(*) then max(t1.d) else  -(cast(avg((t1.e)) AS integer)) end from t1 union select (max(t1.b)) from t1)), -b) and e or ((11<c)) or e>=t1.d then t1.b else a end+13+(t1.c) then a else  -d end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where (not +t1.b-~a*(d*t1.e | + -coalesce((select t1.c from t1 where t1.b*case t1.b when f then  -a*b else e end<>a+t1.a),17))+e*t1.e*11 | t1.a not between 13 and  -t1.a and b between d and  -f))))}\n} {}\ndo_test randexpr-2.48 {\n  db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 | 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else  -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b}\n} {-49978}\ndo_test randexpr-2.49 {\n  db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 | 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE NOT (f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else  -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b)}\n} {}\ndo_test randexpr-2.50 {\n  db eval {SELECT 11++(case 19 when t1.c-19-coalesce((select t1.b from t1 where e*19-t1.e<=+case when c in (select 19 & 17 from t1 union select 11 from t1) then (abs(a)/abs(19)) when a*t1.d>19 or (11) not in (b,t1.a,t1.a) then b else b end-11),f) then 13 else 11 end-t1.e*a) FROM t1 WHERE f in (17,t1.f | coalesce((select max(t1.e) from t1 where not 17 in (select f from t1 union select +17 from t1)),b+coalesce((select max(b) from t1 where 19 in (select case min(t1.d) when (count(*)) then min(d) else  -min(d) end from t1 union select max(d) from t1)),f)*f-17+19),b) or d<=f or t1.f>=11 or t1.b<=11 or t1.c<=11 or t1.b<=b}\n} {-49978}\ndo_test randexpr-2.51 {\n  db eval {SELECT  -c-coalesce((select max(t1.a) from t1 where (a>17-t1.a) and (select abs(min(t1.a))*case abs(case (((min((t1.c))))+min(a)) when count(distinct f) then min(11) else count(distinct b) end) when min(t1.f) then (count(distinct t1.b)) else  -count(*) end from t1)<>case d when +(select ((min(t1.a))) from t1)-(abs(c)/abs(f)) then b else 17 end+t1.c),coalesce((select t1.d from t1 where d>19),t1.a)) FROM t1 WHERE b+(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.b<=c-(select ~~max((abs(e)/abs(13 | (t1.e)-c-19))) from t1) or d in (select t1.b from t1 union select d from t1)) or 13 in (select cast(avg(19) AS integer) from t1 union select ( -cast(avg(19) AS integer) | count(*)*min(19)) from t1) or 19<=11),t1.c))-t1.d-c>f}\n} {}\ndo_test randexpr-2.52 {\n  db eval {SELECT  -c-coalesce((select max(t1.a) from t1 where (a>17-t1.a) and (select abs(min(t1.a))*case abs(case (((min((t1.c))))+min(a)) when count(distinct f) then min(11) else count(distinct b) end) when min(t1.f) then (count(distinct t1.b)) else  -count(*) end from t1)<>case d when +(select ((min(t1.a))) from t1)-(abs(c)/abs(f)) then b else 17 end+t1.c),coalesce((select t1.d from t1 where d>19),t1.a)) FROM t1 WHERE NOT (b+(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.b<=c-(select ~~max((abs(e)/abs(13 | (t1.e)-c-19))) from t1) or d in (select t1.b from t1 union select d from t1)) or 13 in (select cast(avg(19) AS integer) from t1 union select ( -cast(avg(19) AS integer) | count(*)*min(19)) from t1) or 19<=11),t1.c))-t1.d-c>f)}\n} {-400}\ndo_test randexpr-2.53 {\n  db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) | case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and  -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then  -f else d end FROM t1 WHERE (case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select  -t1.a from t1 union select a from t1))}\n} {}\ndo_test randexpr-2.54 {\n  db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) | case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and  -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then  -f else d end FROM t1 WHERE NOT ((case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select  -t1.a from t1 union select a from t1)))}\n} {400}\ndo_test randexpr-2.55 {\n  db eval {SELECT case when t1.b+coalesce((select max(a) from t1 where exists(select 1 from t1 where not not t1.d>19)),13) & case when f in (select a from t1 union select case when (a)<>t1.c then c when not exists(select 1 from t1 where t1.c not between 17 and  -(t1.d)) then f else (11) end from t1) then t1.c when (not exists(select 1 from t1 where 17 not between t1.f and a)) and d=b then t1.c else d end<=19 and (t1.c<>c and (13) not between t1.d and t1.c) and a>= -b or 11>13 and c<>13 then  -f else d end FROM t1 WHERE NOT ((case when (17 not in (f*11,+coalesce((select max(b-b) from t1 where t1.c+f not between 11 and t1.d),13),c)) or (t1.e in (select ~min(t1.f) from t1 union select ~count(*) from t1) and exists(select 1 from t1 where (not f>=19 and 17 not between a and t1.e)) or (e) not in (e,d,13) or t1.d>=f) then e when 17 between t1.c and 13 then case when 11<>19 then t1.d else t1.a end else b end in (select  -t1.a from t1 union select a from t1)))}\n} {400}\ndo_test randexpr-2.56 {\n  db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d | t1.d | t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then  -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then  -b else t1.b end FROM t1 WHERE (coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d)}\n} {300}\ndo_test randexpr-2.57 {\n  db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d | t1.d | t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then  -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then  -b else t1.b end FROM t1 WHERE NOT ((coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d))}\n} {}\ndo_test randexpr-2.58 {\n  db eval {SELECT t1.e+case when d not between f and case when a in (select t1.c from t1 union select t1.e from t1) or coalesce((select 19 from t1 where 17<=t1.d or 19*t1.f*t1.b<>t1.d & t1.d & t1.a),t1.b)*case when (t1.a) in (t1.d,t1.a,a) then  -c when 17<13 then t1.f else 17 end-t1.f*e not in (19,t1.d,17) then 19 else t1.e end then  -b else t1.b end FROM t1 WHERE (coalesce((select t1.d-coalesce((select max(coalesce((select max(c+13) from t1 where ~13*t1.b in (select abs(abs(abs((cast(avg( -e) AS integer)))))- -count(distinct (13))*max(13) from t1 union select count(distinct 19) from t1)), -t1.f)) from t1 where exists(select 1 from t1 where 17 in (t1.b,13,b))),b)+d+t1.a from t1 where d not in (13,t1.b,b)),17) not between 11 and e or not 17 between d and d)}\n} {300}\ndo_test randexpr-2.59 {\n  db eval {SELECT coalesce((select max(t1.f*case when not exists(select 1 from t1 where exists(select 1 from t1 where (select count(distinct 11) from t1) between coalesce((select max(c) from t1 where t1.e=t1.a+17),a) and t1.b) or c not in (t1.e,19,t1.e)) then 13 when exists(select 1 from t1 where t1.a between 19 and  -c) then coalesce((select coalesce((select max((( -d))) from t1 where 17 not in (t1.d,e,t1.e)),e) from t1 where c= -f),( -c)) else t1.f end) from t1 where not (11 between a and t1.e)),19) FROM t1 WHERE case c when case when (exists(select 1 from t1 where t1.d<>coalesce((select 13 from t1 where (t1.b>+e)),(17))+coalesce((select 13 from t1 where exists(select 1 from t1 where 13 in (t1.b+c,case when f between t1.f and b then t1.b else f end,(11)))),f)-17-17)) then  -c-(c) when 11 in (b,f,(t1.d)) then t1.c else t1.b end then t1.d else 11 end in (select  -count(*) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.60 {\n  db eval {SELECT coalesce((select max(t1.f*case when not exists(select 1 from t1 where exists(select 1 from t1 where (select count(distinct 11) from t1) between coalesce((select max(c) from t1 where t1.e=t1.a+17),a) and t1.b) or c not in (t1.e,19,t1.e)) then 13 when exists(select 1 from t1 where t1.a between 19 and  -c) then coalesce((select coalesce((select max((( -d))) from t1 where 17 not in (t1.d,e,t1.e)),e) from t1 where c= -f),( -c)) else t1.f end) from t1 where not (11 between a and t1.e)),19) FROM t1 WHERE NOT (case c when case when (exists(select 1 from t1 where t1.d<>coalesce((select 13 from t1 where (t1.b>+e)),(17))+coalesce((select 13 from t1 where exists(select 1 from t1 where 13 in (t1.b+c,case when f between t1.f and b then t1.b else f end,(11)))),f)-17-17)) then  -c-(c) when 11 in (b,f,(t1.d)) then t1.c else t1.b end then t1.d else 11 end in (select  -count(*) from t1 union select count(*) from t1))}\n} {360000}\ndo_test randexpr-2.61 {\n  db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d | 19+13)-t1.a | ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select  -cast(avg(c) AS integer) from t1)) then (select  -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d)}\n} {}\ndo_test randexpr-2.62 {\n  db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d | 19+13)-t1.a | ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select  -cast(avg(c) AS integer) from t1)) then (select  -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d))}\n} {400}\ndo_test randexpr-2.63 {\n  db eval {SELECT case when t1.a-coalesce((select t1.b from t1 where (d<=~a)),t1.b+t1.d & 19+13)-t1.a & ~coalesce((select ~17 from t1 where not exists(select 1 from t1 where ~case when 13 in (select +(cast(avg(b) AS integer)) from t1 union select count(*) from t1) then 17 when 11 not in (c,t1.a,t1.a) then e else e end*a not between 11 and c)),t1.c) in (11,t1.a,e) then t1.f when 19 in (select ~count(distinct d) from t1 union select cast(avg(19) AS integer) from t1) then t1.d else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(*) from t1)+coalesce((select max(a) from t1 where t1.a between (abs(case when exists(select 1 from t1 where case when t1.e=case when 19 between 11 and e then t1.f else a end then t1.e else t1.b end in (select count(distinct d) | max(11)*abs(case count(*) when max(f) then cast(avg(e) AS integer) else count(distinct t1.e) end) from t1 union select  -cast(avg(c) AS integer) from t1)) then (select  -min(e) from t1) when (c>e) then t1.d else f end)/abs(b)) and (17)),e) not between t1.a and d))}\n} {400}\ndo_test randexpr-2.64 {\n  db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) | min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a | 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and  -a not between b and d) then d when  -t1.f=b or t1.b between  -f and  -d then 19 else d end+d FROM t1 WHERE case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select  -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1)}\n} {}\ndo_test randexpr-2.65 {\n  db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) | min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a | 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and  -a not between b and d) then d when  -t1.f=b or t1.b between  -f and  -d then 19 else d end+d FROM t1 WHERE NOT (case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select  -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1))}\n} {800}\ndo_test randexpr-2.66 {\n  db eval {SELECT case when 11 in (select max(f) from t1 union select min(19++13) & min(t1.c) from t1) and (e in (select t1.d from t1 union select t1.a & 17*case e when coalesce((select max(a) from t1 where b not in (b,f,d) or t1.a<=f),11) then t1.a else t1.b end from t1) and  -a not between b and d) then d when  -t1.f=b or t1.b between  -f and  -d then 19 else d end+d FROM t1 WHERE NOT (case when (coalesce((select case (select max(t1.b) from t1) when (b* -t1.e+e*e-t1.a) then c else a end from t1 where 17 in (select min(t1.d)-abs(count(*)) from t1 union select count(distinct c) from t1)),t1.d)=(t1.d)) and e in (select  -min(t1.b) from t1 union select count(distinct 11) from t1) and a< - -17 then t1.d | 11 else 19 end in (select 17 from t1 union select d from t1))}\n} {800}\ndo_test randexpr-2.67 {\n  db eval {SELECT (abs((select min(13) from t1))/abs(coalesce((select t1.e from t1 where coalesce((select t1.f from t1 where  -11<=b-t1.c*case when (d)-t1.f+t1.e-13<>t1.b then 11 when exists(select 1 from t1 where t1.d<>((t1.b)) or t1.a not between d and 13) or t1.b<>t1.c then t1.e else  -t1.d end+t1.a or t1.c not between f and d),e)<>e), -f))) FROM t1 WHERE t1.c<>(select min((abs(( -19-t1.b*13- -++~t1.f*d-17*19*11))/abs(17))) from t1)}\n} {0}\ndo_test randexpr-2.68 {\n  db eval {SELECT (abs((select min(13) from t1))/abs(coalesce((select t1.e from t1 where coalesce((select t1.f from t1 where  -11<=b-t1.c*case when (d)-t1.f+t1.e-13<>t1.b then 11 when exists(select 1 from t1 where t1.d<>((t1.b)) or t1.a not between d and 13) or t1.b<>t1.c then t1.e else  -t1.d end+t1.a or t1.c not between f and d),e)<>e), -f))) FROM t1 WHERE NOT (t1.c<>(select min((abs(( -19-t1.b*13- -++~t1.f*d-17*19*11))/abs(17))) from t1))}\n} {}\ndo_test randexpr-2.69 {\n  db eval {SELECT case d-case when c< -case when b<=f or coalesce((select t1.e from t1 where 11<coalesce((select b+(t1.f)+t1.e-d from t1 where (t1.c<f)),t1.d)),t1.e)>e then 19 when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d>=d)) then t1.f else 17 end then e when not exists(select 1 from t1 where d=b) then t1.c else f end when 17 then 19 else t1.f end FROM t1 WHERE coalesce((select max(+t1.d) from t1 where e<>e or not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs(f))++t1.b in (select case abs(cast(avg(e) AS integer)) when cast(avg(17) AS integer) | max(d) | cast(avg(t1.e) AS integer) | min(t1.e) then (cast(avg(19) AS integer)) else cast(avg(c) AS integer) end from t1 union select cast(avg(t1.f) AS integer) from t1))) and t1.a between t1.f and b or not 17<13 or  -11= -t1.f or t1.f between c and 19),d)+(t1.d) not between b and e}\n} {600}\ndo_test randexpr-2.70 {\n  db eval {SELECT case d-case when c< -case when b<=f or coalesce((select t1.e from t1 where 11<coalesce((select b+(t1.f)+t1.e-d from t1 where (t1.c<f)),t1.d)),t1.e)>e then 19 when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d>=d)) then t1.f else 17 end then e when not exists(select 1 from t1 where d=b) then t1.c else f end when 17 then 19 else t1.f end FROM t1 WHERE NOT (coalesce((select max(+t1.d) from t1 where e<>e or not exists(select 1 from t1 where not exists(select 1 from t1 where (abs(f)/abs(f))++t1.b in (select case abs(cast(avg(e) AS integer)) when cast(avg(17) AS integer) | max(d) | cast(avg(t1.e) AS integer) | min(t1.e) then (cast(avg(19) AS integer)) else cast(avg(c) AS integer) end from t1 union select cast(avg(t1.f) AS integer) from t1))) and t1.a between t1.f and b or not 17<13 or  -11= -t1.f or t1.f between c and 19),d)+(t1.d) not between b and e)}\n} {}\ndo_test randexpr-2.71 {\n  db eval {SELECT case when t1.e in (select abs(max(case a+case when t1.a>=e+ -c then a else t1.b end+t1.a when t1.f then 19 else  -19 end)+abs( -count(distinct t1.c))+~(count(distinct t1.b)))-min(b) from t1 union select max(f) from t1) and case t1.e when  -t1.c then 19 else b end<t1.d then e+(d) when exists(select 1 from t1 where 19 not between t1.e and (19)) then  -19 else t1.c end FROM t1 WHERE (exists(select 1 from t1 where t1.e between t1.c-t1.d and (t1.a)) and ((not case 19 when 11 then e else ~d | t1.a*19 end*((b))>=t1.e))) or c in (select f from t1 union select 13 from t1) and (b)< -t1.c and f in (select max(13) from t1 union select ~+abs(count(distinct e)*abs(((count(*)))*((max(f))))) from t1)}\n} {}\ndo_test randexpr-2.72 {\n  db eval {SELECT case when t1.e in (select abs(max(case a+case when t1.a>=e+ -c then a else t1.b end+t1.a when t1.f then 19 else  -19 end)+abs( -count(distinct t1.c))+~(count(distinct t1.b)))-min(b) from t1 union select max(f) from t1) and case t1.e when  -t1.c then 19 else b end<t1.d then e+(d) when exists(select 1 from t1 where 19 not between t1.e and (19)) then  -19 else t1.c end FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.e between t1.c-t1.d and (t1.a)) and ((not case 19 when 11 then e else ~d | t1.a*19 end*((b))>=t1.e))) or c in (select f from t1 union select 13 from t1) and (b)< -t1.c and f in (select max(13) from t1 union select ~+abs(count(distinct e)*abs(((count(*)))*((max(f))))) from t1))}\n} {-19}\ndo_test randexpr-2.73 {\n  db eval {SELECT c*case when t1.a in (select ~count(*) from t1 union select  -count(distinct ~case (abs(11)/abs(b-(coalesce((select 17-t1.a from t1 where not t1.d=t1.d),(abs(11)/abs(a)))))) when case when t1.d between 19 and c and t1.b between 11 and t1.a then 13 else (13) end then (13) else 19 end-19*13+11) from t1) then t1.a when t1.f<=t1.e then f else b end-19-c+f FROM t1 WHERE t1.b>=c+case when exists(select 1 from t1 where a>=+f- -c*e+coalesce((select max(b) from t1 where (b not between (t1.b) and 19) or t1.f<11),d)*f | t1.e+t1.b) then ( -t1.e)-19 when ((t1.a in (select 19 from t1 union select t1.f from t1) or b<c and b> -17)) then f else f end | d}\n} {}\ndo_test randexpr-2.74 {\n  db eval {SELECT c*case when t1.a in (select ~count(*) from t1 union select  -count(distinct ~case (abs(11)/abs(b-(coalesce((select 17-t1.a from t1 where not t1.d=t1.d),(abs(11)/abs(a)))))) when case when t1.d between 19 and c and t1.b between 11 and t1.a then 13 else (13) end then (13) else 19 end-19*13+11) from t1) then t1.a when t1.f<=t1.e then f else b end-19-c+f FROM t1 WHERE NOT (t1.b>=c+case when exists(select 1 from t1 where a>=+f- -c*e+coalesce((select max(b) from t1 where (b not between (t1.b) and 19) or t1.f<11),d)*f | t1.e+t1.b) then ( -t1.e)-19 when ((t1.a in (select 19 from t1 union select t1.f from t1) or b<c and b> -17)) then f else f end | d)}\n} {60281}\ndo_test randexpr-2.75 {\n  db eval {SELECT (abs(case when a>=b then t1.c-case when not exists(select 1 from t1 where case d when +17 then 19+c else 11 end-(abs((select  - -cast(avg(case when (11- -(abs(e)/abs(13))-t1.f<t1.e) then t1.c+d else a end-t1.c) AS integer) from t1))/abs(t1.a))<=b) then  -e+d else (t1.c) end else 19 end)/abs(c)) FROM t1 WHERE f<>11}\n} {0}\ndo_test randexpr-2.76 {\n  db eval {SELECT (abs(case when a>=b then t1.c-case when not exists(select 1 from t1 where case d when +17 then 19+c else 11 end-(abs((select  - -cast(avg(case when (11- -(abs(e)/abs(13))-t1.f<t1.e) then t1.c+d else a end-t1.c) AS integer) from t1))/abs(t1.a))<=b) then  -e+d else (t1.c) end else 19 end)/abs(c)) FROM t1 WHERE NOT (f<>11)}\n} {}\ndo_test randexpr-2.77 {\n  db eval {SELECT  -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b | e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c | 13*(d) | b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then  -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) | c FROM t1 WHERE not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case  -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then  -max(d) else ((count(*))) end) from t1))}\n} {-212}\ndo_test randexpr-2.78 {\n  db eval {SELECT  -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b | e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c | 13*(d) | b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then  -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) | c FROM t1 WHERE NOT (not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case  -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then  -max(d) else ((count(*))) end) from t1)))}\n} {}\ndo_test randexpr-2.79 {\n  db eval {SELECT  -coalesce((select max(e-t1.b) from t1 where t1.e<11 and t1.b & e in ((abs(13)/abs(t1.b)),(abs((+17-case when t1.c & 13*(d) & b<>a or ((t1.e)>=a) then t1.b-t1.e when not exists(select 1 from t1 where 17<13) then  -(13) else 17 end*13))/abs(13)),t1.c)),t1.e) & c FROM t1 WHERE not exists(select 1 from t1 where 17<=(select (case (~+abs(cast(avg((t1.e)-17 | b) AS integer))-((case  -cast(avg(case when ~t1.b in (select d from t1 union select 19 from t1) then b when 13 in (t1.f,c,t1.b) then c else f end) AS integer)+count(distinct t1.f)+count(distinct t1.d) when count(*) then ((max(c))) else count(*) end)*cast(avg(t1.e) AS integer))) when ((cast(avg(a) AS integer))) then  -max(d) else ((count(*))) end) from t1))}\n} {12}\ndo_test randexpr-2.80 {\n  db eval {SELECT 17-coalesce((select c+t1.f from t1 where (select count(distinct d)-abs(min((select case  - -count(*) when  -max(19) then  -count(*) else count(*) end from t1))-count(*)) from t1)-t1.a+case when (abs(t1.e)/abs(t1.e)) not in (a,t1.a,19) and (b between 19 and  -t1.c) then 17 else c end-19+t1.e*13<= -(t1.a)),11)-t1.d-c FROM t1 WHERE ((t1.d in ((select +cast(avg(coalesce((select max(coalesce((select max(a) from t1 where not a in (b,~(select ~count(*) from t1),case (select +max(11) |  -count(*) from t1) when 17*t1.f*17 then b else (t1.b) end+f | 17)),e)) from t1 where not exists(select 1 from t1 where 17 between a and a)),(19))) AS integer) from t1),coalesce((select max(e) from t1 where t1.e<>11),b),t1.d)))}\n} {-694}\ndo_test randexpr-2.81 {\n  db eval {SELECT 17-coalesce((select c+t1.f from t1 where (select count(distinct d)-abs(min((select case  - -count(*) when  -max(19) then  -count(*) else count(*) end from t1))-count(*)) from t1)-t1.a+case when (abs(t1.e)/abs(t1.e)) not in (a,t1.a,19) and (b between 19 and  -t1.c) then 17 else c end-19+t1.e*13<= -(t1.a)),11)-t1.d-c FROM t1 WHERE NOT (((t1.d in ((select +cast(avg(coalesce((select max(coalesce((select max(a) from t1 where not a in (b,~(select ~count(*) from t1),case (select +max(11) |  -count(*) from t1) when 17*t1.f*17 then b else (t1.b) end+f | 17)),e)) from t1 where not exists(select 1 from t1 where 17 between a and a)),(19))) AS integer) from t1),coalesce((select max(e) from t1 where t1.e<>11),b),t1.d))))}\n} {}\ndo_test randexpr-2.82 {\n  db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c | (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) | case when not (e)*f in (select count(distinct a)-count(distinct c) | min(a) from t1 union select  -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then  -t1.c else t1.a end-t1.a-11-f in (select (case  -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct  -d)) from t1 union select min(t1.e) from t1)),t1.c)}\n} {60408}\ndo_test randexpr-2.83 {\n  db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c | (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) | case when not (e)*f in (select count(distinct a)-count(distinct c) | min(a) from t1 union select  -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE NOT (t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then  -t1.c else t1.a end-t1.a-11-f in (select (case  -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct  -d)) from t1 union select min(t1.e) from t1)),t1.c))}\n} {}\ndo_test randexpr-2.84 {\n  db eval {SELECT case (t1.a) when e then t1.a else t1.d end+(b)*t1.c & (select ~count(distinct (select count(distinct t1.f) from t1)) from t1)* -case c*t1.b when 19 then t1.d else (t1.b) & case when not (e)*f in (select count(distinct a)-count(distinct c) & min(a) from t1 union select  -count(*) from t1) and (t1.f in (d, -t1.c,f)) then e when t1.c not in (t1.b,t1.e,b) then t1.e else f end end FROM t1 WHERE t1.d<>coalesce((select max(case when exists(select 1 from t1 where f<=e | b) then (select min(+t1.f) from t1) else 11 end) from t1 where +case when t1.e=c then  -t1.c else t1.a end-t1.a-11-f in (select (case  -min(a) when count(*)*(( -+abs(cast(avg(a) AS integer))*max((17))) | max(19)) then min(11) else min(a) end | count(distinct  -d)) from t1 union select min(t1.e) from t1)),t1.c)}\n} {384}\ndo_test randexpr-2.85 {\n  db eval {SELECT (select abs(max((select (case cast(avg(t1.a) AS integer) when +~abs(cast(avg( -17+case when t1.a in (c,(e),t1.f) and f in (c,t1.d,t1.a) then d when d between c and t1.d then f else e end) AS integer))-(abs(~max((b)))-min(t1.f)) then cast(avg(t1.f) AS integer) else count(*) end) from t1)+case when (exists(select 1 from t1 where t1.a in (select  -max(e) from t1 union select  -count(*) from t1)) or e in (t1.b*d,a, - -d)) then 17*t1.c else c end)) from t1) FROM t1 WHERE ~t1.e>case 13 when e then a else coalesce((select ~t1.d from t1 where exists(select 1 from t1 where t1.f between coalesce((select t1.a from t1 where ((select min(d-d- -t1.d+a) from t1)) not between f and t1.c or exists(select 1 from t1 where b<>17)),(a)) and  -d) or not exists(select 1 from t1 where e in (select min(19)*(count(*))*cast(avg(11) AS integer) | min(b) from t1 union select (cast(avg(t1.e) AS integer)) from t1))),c) end-t1.c}\n} {}\ndo_test randexpr-2.86 {\n  db eval {SELECT (select abs(max((select (case cast(avg(t1.a) AS integer) when +~abs(cast(avg( -17+case when t1.a in (c,(e),t1.f) and f in (c,t1.d,t1.a) then d when d between c and t1.d then f else e end) AS integer))-(abs(~max((b)))-min(t1.f)) then cast(avg(t1.f) AS integer) else count(*) end) from t1)+case when (exists(select 1 from t1 where t1.a in (select  -max(e) from t1 union select  -count(*) from t1)) or e in (t1.b*d,a, - -d)) then 17*t1.c else c end)) from t1) FROM t1 WHERE NOT (~t1.e>case 13 when e then a else coalesce((select ~t1.d from t1 where exists(select 1 from t1 where t1.f between coalesce((select t1.a from t1 where ((select min(d-d- -t1.d+a) from t1)) not between f and t1.c or exists(select 1 from t1 where b<>17)),(a)) and  -d) or not exists(select 1 from t1 where e in (select min(19)*(count(*))*cast(avg(11) AS integer) | min(b) from t1 union select (cast(avg(t1.e) AS integer)) from t1))),c) end-t1.c)}\n} {301}\ndo_test randexpr-2.87 {\n  db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) | 19-b-t1.e | t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct  -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c)}\n} {}\ndo_test randexpr-2.88 {\n  db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) | 19-b-t1.e | t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE NOT (not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct  -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c))}\n} {-33}\ndo_test randexpr-2.89 {\n  db eval {SELECT t1.c+(abs(t1.b*t1.b)/abs(++t1.a-t1.e-(abs(t1.b)/abs(d))*11*t1.f)) & 19-b-t1.e & t1.e-+~t1.d*13+a+case case when (d)+17-c=d then a else t1.b end when e then t1.a else 19 end FROM t1 WHERE NOT (not coalesce((select (abs(case t1.b when coalesce((select case when exists(select 1 from t1 where f between 17 and f) then 11 else f end from t1 where not exists(select 1 from t1 where c>=t1.d)),17)*t1.a then t1.e else 13 end)/abs(17)) from t1 where ((13 in (select abs(~min(d)*count(distinct  -(f)) | count(*)*cast(avg(11) AS integer)) from t1 union select count(*) from t1) and a<=13) and c<> -(t1.c))), -t1.a)*t1.e*f+d not in (11,d,t1.c))}\n} {0}\ndo_test randexpr-2.90 {\n  db eval {SELECT case when t1.f>t1.d then (select abs(+count(distinct c)+(abs(min((abs(+11)/abs(b)))* -count(*)))) from t1)-t1.a when d+case when (select cast(avg(t1.f) AS integer)-count(distinct 19) from t1)<>17 then c when t1.e in (select cast(avg(t1.a) AS integer) from t1 union select count(distinct f) from t1) and d>t1.c and t1.f not in (11,19,t1.b) then a else (c) end+(17)=c then t1.d else t1.c end-c FROM t1 WHERE 13 not in (e,t1.b,+coalesce((select max(b) from t1 where 13*b-t1.d-case when 11>=a then t1.a-t1.d else (t1.d)*e+19 end*t1.a+19+(11) | t1.c*t1.a-17<t1.e),b)-a+17*17*c)}\n} {-399}\ndo_test randexpr-2.91 {\n  db eval {SELECT case when t1.f>t1.d then (select abs(+count(distinct c)+(abs(min((abs(+11)/abs(b)))* -count(*)))) from t1)-t1.a when d+case when (select cast(avg(t1.f) AS integer)-count(distinct 19) from t1)<>17 then c when t1.e in (select cast(avg(t1.a) AS integer) from t1 union select count(distinct f) from t1) and d>t1.c and t1.f not in (11,19,t1.b) then a else (c) end+(17)=c then t1.d else t1.c end-c FROM t1 WHERE NOT (13 not in (e,t1.b,+coalesce((select max(b) from t1 where 13*b-t1.d-case when 11>=a then t1.a-t1.d else (t1.d)*e+19 end*t1.a+19+(11) | t1.c*t1.a-17<t1.e),b)-a+17*17*c))}\n} {}\ndo_test randexpr-2.92 {\n  db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b | a-e | 13-(abs(19)/abs((select max(t1.d | coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE (select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between  -17 and t1.c}\n} {}\ndo_test randexpr-2.93 {\n  db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b | a-e | 13-(abs(19)/abs((select max(t1.d | coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE NOT ((select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between  -17 and t1.c)}\n} {19}\ndo_test randexpr-2.94 {\n  db eval {SELECT coalesce((select +19 from t1 where 19-c+t1.c-f not in (coalesce((select 19 from t1 where (t1.b between t1.c*t1.a*t1.b & a-e & 13-(abs(19)/abs((select max(t1.d & coalesce((select max( -t1.c) from t1 where b in (select e from t1 union select (f) from t1)),t1.d)+(e)) from t1)+c)) and f)),11),f,17)),f) FROM t1 WHERE NOT ((select count(distinct 11)+min((coalesce((select max(case when t1.d<>(abs(t1.a)/abs(e)) then d else ~(t1.e)-e+d+13-t1.b+b*19 end) from t1 where (select max(19)-cast(avg(a) AS integer) from t1)> -t1.e),17)+e+t1.e-t1.c+(c))*17) from t1) between  -17 and t1.c)}\n} {19}\ndo_test randexpr-2.95 {\n  db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f | f+~e-a*t1.b+13 end | 13) FROM t1 WHERE (coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f)}\n} {-19491}\ndo_test randexpr-2.96 {\n  db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f | f+~e-a*t1.b+13 end | 13) FROM t1 WHERE NOT ((coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f))}\n} {}\ndo_test randexpr-2.97 {\n  db eval {SELECT (case t1.a when (select (count(distinct t1.f)) from t1)-e then 11 else t1.c+17-f*~f & f+~e-a*t1.b+13 end & 13) FROM t1 WHERE (coalesce((select max(f) from t1 where (c+t1.f | (select count(distinct t1.d) from t1)>=coalesce((select b+(abs(case when t1.f>=(select case max(f) when max(19) then cast(avg(t1.a) AS integer) else count(distinct 13) end from t1) | t1.b and (a in (select (b) from t1 union select t1.b from t1)) then (a)-b when not exists(select 1 from t1 where c between t1.c and t1.a) then a else t1.a end)/abs(t1.b))- -f from t1 where b not in (t1.b,t1.f,c)),t1.d)-t1.d)), -17) between 13 and t1.f)}\n} {0}\ndo_test randexpr-2.98 {\n  db eval {SELECT case when ((select  -abs(min(coalesce((select max(11 | t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between  -t1.e and 13}\n} {}\ndo_test randexpr-2.99 {\n  db eval {SELECT case when ((select  -abs(min(coalesce((select max(11 | t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE NOT (e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between  -t1.e and 13)}\n} {489}\ndo_test randexpr-2.100 {\n  db eval {SELECT case when ((select  -abs(min(coalesce((select max(11 & t1.f) from t1 where coalesce((select f from t1 where e+c in (select 19 from t1 union select f from t1)),b) not in (t1.a,+case when 13>=t1.e then t1.a when 17 not in (t1.d,b,t1.e) then 13 else t1.b end-t1.e,t1.f)),t1.f))*count(*)*min(t1.c)) from t1)<17) and 13* -f+a not between (a) and f then c-11+b else 19 end FROM t1 WHERE NOT (e+case case when a<>c then (abs(case when coalesce((select (abs( -19+11)/abs(t1.c)) from t1 where (17) in (a,13,11) and 17 in (select 11 from t1 union select t1.f from t1)),t1.a) between t1.f and c then t1.d when not exists(select 1 from t1 where not exists(select 1 from t1 where 19=f)) then f else (b) end-19)/abs(e)) else 11 end when 17 then a else t1.f end-13 | e between  -t1.e and 13)}\n} {489}\ndo_test randexpr-2.101 {\n  db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select  -17 from t1 where (t1.f+((select case count(*) when  -cast(avg(19) AS integer)+count(distinct (t1.c)) | (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) | case when t1.b | a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE case  -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select  -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b}\n} {}\ndo_test randexpr-2.102 {\n  db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select  -17 from t1 where (t1.f+((select case count(*) when  -cast(avg(19) AS integer)+count(distinct (t1.c)) | (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) | case when t1.b | a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE NOT (case  -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select  -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b)}\n} {17}\ndo_test randexpr-2.103 {\n  db eval {SELECT case when t1.b-t1.e*c<>c then coalesce((select  -17 from t1 where (t1.f+((select case count(*) when  -cast(avg(19) AS integer)+count(distinct (t1.c)) & (cast(avg(19) AS integer))*max(t1.c)*count(*)-((count(*))) then cast(avg(b) AS integer) else (count(*)) end-min(a) from t1)) & case when t1.b & a in (select t1.a from t1 union select (select count(distinct e) from t1) from t1) then t1.e else b end+t1.a)<e),17) else 19 end FROM t1 WHERE NOT (case  -coalesce((select d-+t1.d-13-b from t1 where case when not exists(select 1 from t1 where (t1.a-t1.f in (select t1.e from t1 union select 17 from t1)) or 19<=t1.a) then t1.c-b else b end in (select  -max(13)++abs(max(t1.c))*+max(t1.d) from t1 union select cast(avg(t1.e) AS integer) from t1)),13) | t1.d when (t1.f) then f else a end not between 11 and b)}\n} {-17}\ndo_test randexpr-2.104 {\n  db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) | max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else  -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE ~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where  -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else  -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d)}\n} {}\ndo_test randexpr-2.105 {\n  db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) | max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else  -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE NOT (~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where  -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else  -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d))}\n} {-12}\ndo_test randexpr-2.106 {\n  db eval {SELECT coalesce((select max(case when (select ~cast(avg(a) AS integer) from t1)>~t1.a then f else +~11 end) from t1 where ((select case ~abs(count(distinct t1.e)+(count(*)+count(*)+(abs( -~count(*) & max((t1.b))))))*(cast(avg(t1.a) AS integer)) when (count(*)) then min(19) else  -(min(b)) end from t1))+11<>t1.f), -c-f) FROM t1 WHERE NOT (~e>coalesce((select max(case case case coalesce((select max(coalesce((select c from t1 where t1.a-t1.c>13),13)) from t1 where  -b not in (case d when ~t1.f | t1.c then 13 else 11 end,19,19)),t1.d) when c then t1.a else t1.b end+f-e*b when f then 19 else  -t1.b end when t1.b then 11 else 13 end) from t1 where c in (select 19 from t1 union select e from t1)),t1.d))}\n} {-12}\ndo_test randexpr-2.107 {\n  db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) | count(*) | case count(*) when cast(avg(17) AS integer) then  -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE ~((case when not 13-+t1.c>=17 then  -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when  -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c}\n} {-500}\ndo_test randexpr-2.108 {\n  db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) | count(*) | case count(*) when cast(avg(17) AS integer) then  -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE NOT (~((case when not 13-+t1.c>=17 then  -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when  -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c)}\n} {}\ndo_test randexpr-2.109 {\n  db eval {SELECT coalesce((select a from t1 where b>=~11-coalesce((select max((abs(19)/abs(t1.e))+19+t1.d) from t1 where (select abs(count(*) & count(*) & case count(*) when cast(avg(17) AS integer) then  -cast(avg(b) AS integer) else count(*) end*min(b))*(min(t1.e)) from t1) in (11*(select count(*) from t1)*17*t1.e-e*t1.b,t1.e,t1.f)),a)*t1.d),13)-f FROM t1 WHERE ~((case when not 13-+t1.c>=17 then  -~ -b+t1.f+case when t1.c<t1.b then t1.b when e*t1.b in (c,f,19) then (abs(a)/abs(case when 13=e then t1.e when  -a<>t1.d then 11 else t1.e end)) else t1.b end when d>a then (a) else t1.b end))+t1.c in (13,t1.a,13) or t1.e>c}\n} {-500}\ndo_test randexpr-2.110 {\n  db eval {SELECT case when 13>=~t1.a or (exists(select 1 from t1 where 11 not in (17,t1.f,17))) then f when not exists(select 1 from t1 where exists(select 1 from t1 where 13 not between e and ~+case b when t1.f then case  -case f when 11 then  -17 else 19 end+17 when b then b else 13 end else 13 end- -t1.a and t1.c not in (t1.f,a,c) or t1.f<11)) then t1.c else 11 end FROM t1 WHERE +t1.e in (select cast(avg(t1.c*t1.a*(abs(13)/abs(t1.e))) AS integer) from t1 union select min(c+13) from t1)}\n} {}\ndo_test randexpr-2.111 {\n  db eval {SELECT case when 13>=~t1.a or (exists(select 1 from t1 where 11 not in (17,t1.f,17))) then f when not exists(select 1 from t1 where exists(select 1 from t1 where 13 not between e and ~+case b when t1.f then case  -case f when 11 then  -17 else 19 end+17 when b then b else 13 end else 13 end- -t1.a and t1.c not in (t1.f,a,c) or t1.f<11)) then t1.c else 11 end FROM t1 WHERE NOT (+t1.e in (select cast(avg(t1.c*t1.a*(abs(13)/abs(t1.e))) AS integer) from t1 union select min(c+13) from t1))}\n} {600}\ndo_test randexpr-2.112 {\n  db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d | case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then  -t1.e when 19 between  -t1.f and t1.a then  -t1.b else t1.f end FROM t1 WHERE exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f)}\n} {}\ndo_test randexpr-2.113 {\n  db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d | case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then  -t1.e when 19 between  -t1.f and t1.a then  -t1.b else t1.f end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f))}\n} {-500}\ndo_test randexpr-2.114 {\n  db eval {SELECT case when coalesce((select max(13) from t1 where coalesce((select max(c) from t1 where coalesce((select max(17) from t1 where 11 in (select ~d & case when t1.a>+19 then 11 when t1.d not in ( -e,e,c) or 13<t1.c then t1.b else d end-t1.d from t1 union select e from t1)),t1.b) in (select e from t1 union select c from t1)),d)<>d or t1.e<>b),t1.b)*13<=f then  -t1.e when 19 between  -t1.f and t1.a then  -t1.b else t1.f end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.f between a and coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where coalesce((select 19 from t1 where t1.c=b),a)= -t1.b and not exists(select 1 from t1 where b between e and b) and a<= -17 or exists(select 1 from t1 where 17<=f)) or t1.a>=t1.c),13)*~13*t1.c*13 or t1.d>13 and 11>=t1.d and 11 not between c and c and t1.f>=17 and (d)=f))}\n} {-500}\ndo_test randexpr-2.115 {\n  db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) | t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or  -t1.b>=t1.b) then (f) else d end FROM t1 WHERE t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else  -d end)/abs(11))}\n} {}\ndo_test randexpr-2.116 {\n  db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) | t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or  -t1.b>=t1.b) then (f) else d end FROM t1 WHERE NOT (t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else  -d end)/abs(11)))}\n} {19}\ndo_test randexpr-2.117 {\n  db eval {SELECT case when coalesce((select +case when not exists(select 1 from t1 where 19*t1.e< -~11*a or t1.b>=t1.c and t1.a<>e) then coalesce((select max(13) from t1 where 11>11), -(e)) & t1.a when (t1.d) in (select f from t1 union select b from t1) then a else e end from t1 where t1.f<> -t1.d),t1.b) not in (d,t1.d,t1.c) then 19 when (t1.b<>t1.e or  -t1.b>=t1.b) then (f) else d end FROM t1 WHERE NOT (t1.e=a and b>=(abs(case when 19 not between ~+17 and +case when ((b+e-f=t1.d or b not in (t1.a,t1.f,t1.b) or t1.a not between 19 and e or b>=(t1.d) or t1.b not in (d,t1.a,t1.b))) then e-f else t1.e*t1.f end | f then d else  -d end)/abs(11)))}\n} {19}\ndo_test randexpr-2.118 {\n  db eval {SELECT (select (cast(avg(b) AS integer) | count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else  - -19 end-17+19) | abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else  -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE 11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d}\n} {}\ndo_test randexpr-2.119 {\n  db eval {SELECT (select (cast(avg(b) AS integer) | count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else  - -19 end-17+19) | abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else  -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE NOT (11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d)}\n} {207}\ndo_test randexpr-2.120 {\n  db eval {SELECT (select (cast(avg(b) AS integer) & count(distinct case when coalesce((select 13 from t1 where (+(abs(e)/abs(t1.b))) in ( -b, -(a),13)),t1.e)>=b then 11 else  - -19 end-17+19) & abs(~case count(distinct t1.b) when +min(e) then +abs(~ - -count(distinct 11)-count(distinct t1.b))-count(distinct a) else  -min(b) end)*count(distinct 19)-count(distinct t1.b)) from t1) FROM t1 WHERE NOT (11<=t1.a-t1.f-19*t1.b+19+coalesce((select e from t1 where d not between (select count(distinct coalesce((select t1.a from t1 where (select cast(avg(t1.e) AS integer)-+count(distinct c)+max((abs(t1.c)/abs(t1.f))-a)-(count(*)-cast(avg((17)) AS integer)) from t1) in (t1.e, -e | d,b)),c)) from t1) and t1.a),t1.d)-t1.d)}\n} {0}\ndo_test randexpr-2.121 {\n  db eval {SELECT 11+a*case t1.a*t1.e when 17 then coalesce((select +t1.b from t1 where t1.c<>t1.c and e between +(abs(case b+f*coalesce((select c from t1 where t1.d>17), -t1.c)+(19) when b then t1.f else t1.d end)/abs(t1.d)) and t1.c and t1.a>b or t1.f<t1.a),t1.c)*17 else  -t1.d end*t1.b FROM t1 WHERE  -19-~t1.b<(select ~count(*) from t1)+(abs(++coalesce((select max(t1.a-c) from t1 where t1.a=11),11))/abs(case when not not exists(select 1 from t1 where exists(select 1 from t1 where t1.a>c or t1.d | 11 in (select t1.e from t1 union select d from t1))) then 17 else (abs(coalesce((select max(f) from t1 where not (c)<t1.a),t1.b))/abs(d))+f end-t1.c))-t1.e-t1.e}\n} {}\ndo_test randexpr-2.122 {\n  db eval {SELECT 11+a*case t1.a*t1.e when 17 then coalesce((select +t1.b from t1 where t1.c<>t1.c and e between +(abs(case b+f*coalesce((select c from t1 where t1.d>17), -t1.c)+(19) when b then t1.f else t1.d end)/abs(t1.d)) and t1.c and t1.a>b or t1.f<t1.a),t1.c)*17 else  -t1.d end*t1.b FROM t1 WHERE NOT ( -19-~t1.b<(select ~count(*) from t1)+(abs(++coalesce((select max(t1.a-c) from t1 where t1.a=11),11))/abs(case when not not exists(select 1 from t1 where exists(select 1 from t1 where t1.a>c or t1.d | 11 in (select t1.e from t1 union select d from t1))) then 17 else (abs(coalesce((select max(f) from t1 where not (c)<t1.a),t1.b))/abs(d))+f end-t1.c))-t1.e-t1.e)}\n} {-7999989}\ndo_test randexpr-2.123 {\n  db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select  -min(t1.f)-+cast(avg(e) AS integer) from t1 union select  -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end | t1.e FROM t1 WHERE (abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select  -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17)}\n} {}\ndo_test randexpr-2.124 {\n  db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select  -min(t1.f)-+cast(avg(e) AS integer) from t1 union select  -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end | t1.e FROM t1 WHERE NOT ((abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select  -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17))}\n} {1524}\ndo_test randexpr-2.125 {\n  db eval {SELECT (e)+case when t1.a>e then t1.f else t1.b+case when b between coalesce((select max(t1.d-~(abs(a)/abs(c))+t1.c) from t1 where f in (select  -min(t1.f)-+cast(avg(e) AS integer) from t1 union select  -(cast(avg(13) AS integer)) from t1) and f<=a and not exists(select 1 from t1 where f not between t1.d and t1.d or (f)<=a) and (t1.f) between 11 and d),t1.a) and t1.f then e when (11<d) then 11 else d end end & t1.e FROM t1 WHERE NOT ((abs(13)/abs(a)) in (+coalesce((select 13 from t1 where (t1.e in (select cast(avg(t1.c) AS integer) from t1 union select case +count(distinct t1.c) when +count(*) then ( -min( -b)) else count(*) end*max(e) from t1)) and +case when c in (select (11) from t1 union select  -t1.c from t1) then 17 when 17 in (select 17 from t1 union select d from t1) then c else t1.a end>13),case when c<=11 then t1.e when t1.e<=b then t1.d else t1.e end)-11,11,17))}\n} {176}\ndo_test randexpr-2.126 {\n  db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e | a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE (select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c}\n} {}\ndo_test randexpr-2.127 {\n  db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e | a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE NOT ((select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c)}\n} {100}\ndo_test randexpr-2.128 {\n  db eval {SELECT coalesce((select max(~d-t1.f+b-13) from t1 where t1.c not between case when +f=t1.b then 13 when ~f not in (~t1.a,coalesce((select max(t1.b) from t1 where b between c-t1.c+e and (t1.b)),coalesce((select max(t1.d) from t1 where not e in (select 17 from t1 union select t1.c+e & a from t1)),b)),t1.e) then t1.b else a end and c),t1.a) FROM t1 WHERE NOT ((select (++ -count(*) | cast(avg(t1.b) AS integer) | ++(max(t1.d))+count(*)+max(t1.b)-count(distinct t1.e)-+abs( -+~max((abs(t1.c)/abs((select min(a) from t1)))))+count(distinct t1.a-t1.b)) from t1) between e and c)}\n} {100}\ndo_test randexpr-2.129 {\n  db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 | t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE (t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select  -t1.a from t1 union select 13 from t1))}\n} {}\ndo_test randexpr-2.130 {\n  db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 | t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE NOT ((t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select  -t1.a from t1 union select 13 from t1)))}\n} {589}\ndo_test randexpr-2.131 {\n  db eval {SELECT a+case when exists(select 1 from t1 where 19>=e) then b*b+coalesce((select max( -coalesce((select max(19 & t1.e) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where +case t1.a when a then a else (17) end*19 in (select max(d) from t1 union select max(t1.a) from t1) and not exists(select 1 from t1 where t1.a<=11)) or 11>(19))),11* -a)) from t1 where t1.e<>17),f) else t1.e end-11 FROM t1 WHERE NOT ((t1.a>=(abs(coalesce((select +13*t1.a | c from t1 where 11+case when exists(select 1 from t1 where case when +t1.d in (select case +count(*) when count(distinct 11) then count(*) else (min(11)) end from t1 union select max( -11) from t1) or 11<> -t1.f then t1.d when t1.b in (13,a,d) then c else c end+t1.b=b) then e-c else (t1.d) end>t1.d),d))/abs(t1.f)) and 11 in (select  -t1.a from t1 union select 13 from t1)))}\n} {589}\ndo_test randexpr-2.132 {\n  db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) | count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) |  -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct  -d) else count(*) end from t1) end-t1.d*case (abs(e | t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d)}\n} {-245199}\ndo_test randexpr-2.133 {\n  db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) | count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) |  -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct  -d) else count(*) end from t1) end-t1.d*case (abs(e | t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d))}\n} {}\ndo_test randexpr-2.134 {\n  db eval {SELECT case ~13 when t1.e then e else (select case case (abs(count(*))-~count(*)+count(*) & count(*)-count(*)+max(t1.b)* -(cast(avg(13) AS integer)) &  -(count(distinct t1.c))) when min(e) then (min(13)) else count(*) end*count(*) when max(e) then count(distinct  -d) else count(*) end from t1) end-t1.d*case (abs(e & t1.b)/abs((select cast(avg(t1.c) AS integer) from t1))) when (select cast(avg(a) AS integer) from t1) then t1.c else f+13 end FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case when t1.a>t1.f-~case when ~t1.d+c+t1.f>11 then t1.a when (f between t1.f and t1.c) then t1.f else 13 end*t1.a then t1.d when c<t1.e or e>19 then c else t1.e end from t1 where e<>a and 19<>t1.f),t1.b)+t1.f-t1.e<d)}\n} {-245199}\ndo_test randexpr-2.135 {\n  db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case  -min(e) when count(distinct t1.a) then  -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else  -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 | 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE ((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e)}\n} {}\ndo_test randexpr-2.136 {\n  db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case  -min(e) when count(distinct t1.a) then  -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else  -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 | 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE NOT (((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e))}\n} {-160289}\ndo_test randexpr-2.137 {\n  db eval {SELECT 11-case when 17<=c and (select ( -abs(case count(*)+~case  -min(e) when count(distinct t1.a) then  -count(*) else min(a) end+max(t1.c) when count(*) then max(b) else  -count(distinct 19) end)*cast(avg(17) AS integer)) from t1) not in (case f when e then 19 & 11 else (t1.d) end,d, -t1.b) then +t1.c when t1.d not in (11,c,t1.a) then 13 else a end-t1.d*t1.d FROM t1 WHERE NOT (((abs((abs(coalesce((select a from t1 where (select max(case when t1.f=b then e when 11>t1.c and 11<>e then 13 else a end-(a))-max(t1.e)*count(distinct t1.f) | case max((f)) when (count(distinct f)) then count(*) else min(t1.c) end+min(19) from t1) not in (11,19,t1.e)),t1.f*17))/abs(a)))/abs(c)) in (select t1.c from t1 union select t1.a from t1)) or ( -t1.f=e))}\n} {-160289}\ndo_test randexpr-2.138 {\n  db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end |  -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) |  -count(*)*max( -13) from t1) then 11 | case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE +b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when  -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1)}\n} {}\ndo_test randexpr-2.139 {\n  db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end |  -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) |  -count(*)*max( -13) from t1) then 11 | case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE NOT (+b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when  -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1))}\n} {-15}\ndo_test randexpr-2.140 {\n  db eval {SELECT (f+case +t1.e when t1.d then 17 else f*19 end &  -(abs( -coalesce((select 17* -c+19 from t1 where (abs(case 19*e*d when (select +(cast(avg( -11) AS integer)) &  -count(*)*max( -13) from t1) then 11 & case t1.b when a then a else t1.f end else t1.a end)/abs(a)) in (select t1.b from t1 union select (a) from t1)),t1.b))/abs( -13))) FROM t1 WHERE NOT (+b in (select case case case when not ((~coalesce((select t1.e+d from t1 where (19 between f and t1.b)),(select cast(avg(c+t1.b) AS integer)++cast(avg(b) AS integer) from t1))) not in (t1.c+c,b,e)) or (13 not between d and t1.d) then 13 else b end when  -11 then 13 else 19 end*t1.e when (f) then 19 else 19 end from t1 union select f from t1))}\n} {12000}\ndo_test randexpr-2.141 {\n  db eval {SELECT 11*coalesce((select max(t1.f) from t1 where a-case t1.c when +coalesce((select t1.a-t1.b from t1 where (abs(19)/abs(b)) in (17-case when a<t1.b then t1.a when c not between 19 and t1.d then e else (t1.b) end, -t1.b,f) or 19 in (select t1.b from t1 union select t1.a from t1)),e)+t1.f*t1.b then t1.c else 13 end in (select t1.b from t1 union select f from t1) or e<>17),d)*(t1.e) FROM t1 WHERE (coalesce((select max(~t1.b) from t1 where t1.c in (select ~+case count(distinct a) when (max(t1.a)) then (count(*)) else ~+abs(cast(avg(d | t1.a) AS integer)+case (cast(avg(13) AS integer)) when cast(avg(b) AS integer) then cast(avg(t1.f) AS integer) else min(t1.a) end) | count(distinct c)*( -( -max(t1.f)))*count(*) end from t1 union select count(distinct  -e) from t1)),~a-11)<19 or t1.a*13<>t1.d and not exists(select 1 from t1 where t1.e=e))}\n} {3300000}\ndo_test randexpr-2.142 {\n  db eval {SELECT 11*coalesce((select max(t1.f) from t1 where a-case t1.c when +coalesce((select t1.a-t1.b from t1 where (abs(19)/abs(b)) in (17-case when a<t1.b then t1.a when c not between 19 and t1.d then e else (t1.b) end, -t1.b,f) or 19 in (select t1.b from t1 union select t1.a from t1)),e)+t1.f*t1.b then t1.c else 13 end in (select t1.b from t1 union select f from t1) or e<>17),d)*(t1.e) FROM t1 WHERE NOT ((coalesce((select max(~t1.b) from t1 where t1.c in (select ~+case count(distinct a) when (max(t1.a)) then (count(*)) else ~+abs(cast(avg(d | t1.a) AS integer)+case (cast(avg(13) AS integer)) when cast(avg(b) AS integer) then cast(avg(t1.f) AS integer) else min(t1.a) end) | count(distinct c)*( -( -max(t1.f)))*count(*) end from t1 union select count(distinct  -e) from t1)),~a-11)<19 or t1.a*13<>t1.d and not exists(select 1 from t1 where t1.e=e)))}\n} {}\ndo_test randexpr-2.143 {\n  db eval {SELECT 11+t1.b+17+case when 13 not between t1.d*(17)+d-t1.f and 13 then t1.d when case when case when t1.f not in (t1.b,c,t1.f) and  -d between d and 11 then d else 19 end not between a and e then t1.b when t1.d in (17,13,11) then 19 else t1.e end*a>e then t1.a else t1.d end*f*e FROM t1 WHERE not exists(select 1 from t1 where (t1.f) in (b-b,(select +(max( -13*t1.c*c+t1.e+case t1.a when +t1.d-(c) then  -t1.a else t1.c end | 19* -17)*count(distinct a) | (count(distinct t1.f)))++cast(avg(f) AS integer)-max(13) | cast(avg(b) AS integer) from t1),t1.f))}\n} {}\ndo_test randexpr-2.144 {\n  db eval {SELECT 11+t1.b+17+case when 13 not between t1.d*(17)+d-t1.f and 13 then t1.d when case when case when t1.f not in (t1.b,c,t1.f) and  -d between d and 11 then d else 19 end not between a and e then t1.b when t1.d in (17,13,11) then 19 else t1.e end*a>e then t1.a else t1.d end*f*e FROM t1 WHERE NOT (not exists(select 1 from t1 where (t1.f) in (b-b,(select +(max( -13*t1.c*c+t1.e+case t1.a when +t1.d-(c) then  -t1.a else t1.c end | 19* -17)*count(distinct a) | (count(distinct t1.f)))++cast(avg(f) AS integer)-max(13) | cast(avg(b) AS integer) from t1),t1.f)))}\n} {120000228}\ndo_test randexpr-2.145 {\n  db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) | e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19)}\n} {23}\ndo_test randexpr-2.146 {\n  db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) | e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE NOT (exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19))}\n} {}\ndo_test randexpr-2.147 {\n  db eval {SELECT ((abs(+((select count(*)*abs(min((abs(case (abs(c)/abs(f)) & e when case when 19>=d then 13 when a=f then 13 else f end then b else a end+t1.a)/abs(11))*t1.c*17))-cast(avg(e) AS integer)*count(*) from t1)))/abs(coalesce((select max(case when t1.a in (select t1.c from t1 union select 19 from t1) then e else t1.e end) from t1 where (t1.a<= -t1.e)),17)+c*13))) FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select max(c) from t1 where exists(select 1 from t1 where case when not case coalesce((select max(coalesce((select d from t1 where exists(select 1 from t1 where a<(t1.c))),19)) from t1 where e=t1.e),13) when t1.e then t1.b else f end in (select abs((min(e))*(max(t1.d))+min(t1.e)*(( -((max(t1.a)))))) from t1 union select count(distinct t1.a) from t1) then coalesce((select t1.c from t1 where t1.a< -t1.c and a in (t1.b,t1.f,t1.c)),17) else 17 end>=t1.f)),t1.f)+t1.a*b in (select c from t1 union select 19 from t1)) or exists(select 1 from t1 where not t1.f not in (t1.f,11,t1.d) and 19<=19)}\n} {23}\ndo_test randexpr-2.148 {\n  db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select  -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select  -(+max(11)-max((t1.a))+ -count(distinct d) | cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE (select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else  -count(*) end | max(a)+max(t1.e)) from t1)+e<a}\n} {600}\ndo_test randexpr-2.149 {\n  db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select  -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select  -(+max(11)-max((t1.a))+ -count(distinct d) | cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE NOT ((select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else  -count(*) end | max(a)+max(t1.e)) from t1)+e<a)}\n} {}\ndo_test randexpr-2.150 {\n  db eval {SELECT coalesce((select max(case when t1.f between 17 and 11+case when not coalesce((select max(11) from t1 where t1.f in (select max(t1.d) from t1 union select  -count(*) from t1) or 17=(13) or f in (( -t1.b),13,a)),case when d>13 then 13 else 11 end) between 19 and 19 then 19 when t1.c=d then e else 17 end then t1.e else t1.d end) from t1 where e in (select  -(+max(11)-max((t1.a))+ -count(distinct d) & cast(avg(t1.a) AS integer)*count(distinct b))-count(*)* -count(distinct t1.e) from t1 union select cast(avg(d) AS integer) from t1)),d)+b FROM t1 WHERE (select +~abs( -min(t1.a)-abs(count(*)))+ -abs(+ -+case (cast(avg(a) AS integer)) when min(e+t1.d) then +case cast(avg(coalesce((select max(t1.f+ -t1.e) from t1 where t1.c between 13 and t1.b),19)) AS integer) when ~~min(t1.f) then count(distinct 13) else cast(avg(t1.b) AS integer) end+count(distinct t1.e) else  -count(*) end | max(a)+max(t1.e)) from t1)+e<a}\n} {600}\ndo_test randexpr-2.151 {\n  db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select  -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and  -t1.b), -e)) from t1 union select +( -case  -abs(( -count(*))) | count(distinct d) when max(17) then max(13) else  -(min(13)) end) | (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or  -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a}\n} {11}\ndo_test randexpr-2.152 {\n  db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select  -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and  -t1.b), -e)) from t1 union select +( -case  -abs(( -count(*))) | count(distinct d) when max(17) then max(13) else  -(min(13)) end) | (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE NOT (t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or  -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a)}\n} {}\ndo_test randexpr-2.153 {\n  db eval {SELECT case when ((+b in (select min(coalesce((select c from t1 where t1.b-t1.c+coalesce((select max(case when 13 in (select  -count(distinct b)*max(c) from t1 union select (( - -cast(avg(d) AS integer))) from t1) then b else t1.f end) from t1 where t1.f<t1.e),13) between (b) and  -t1.b), -e)) from t1 union select +( -case  -abs(( -count(*))) & count(distinct d) when max(17) then max(13) else  -(min(13)) end) & (count(distinct t1.a)) from t1))) then t1.f else case c when t1.d then e else 11 end end FROM t1 WHERE t1.a+case t1.c when case c when 13 then t1.f*(select count(*) | cast(avg(a) AS integer) from t1)+13*t1.a else (select abs( -count(*)) from t1) end then b else t1.c end in (t1.a,d,17) or  -(select ~ -max(c) from t1)+17<>d or t1.a not between b and 13 or f<> -19 and t1.b>a}\n} {11}\ndo_test randexpr-2.154 {\n  db eval {SELECT case when t1.a | (abs(case when  -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select  -a from t1)) or t1.b<=a then d when t1.e in (select  -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE (coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c)}\n} {300}\ndo_test randexpr-2.155 {\n  db eval {SELECT case when t1.a | (abs(case when  -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select  -a from t1)) or t1.b<=a then d when t1.e in (select  -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE NOT ((coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c))}\n} {}\ndo_test randexpr-2.156 {\n  db eval {SELECT case when t1.a & (abs(case when  -t1.e in (17,11,(abs(t1.b)/abs(b+case when (17 in (select f-c from t1 union select  -a from t1)) or t1.b<=a then d when t1.e in (select  -(count(*)) from t1 union select max(t1.b) from t1) then c else c end*a-t1.f))) then t1.b else t1.e end)/abs(t1.f))>=11 and not exists(select 1 from t1 where exists(select 1 from t1 where t1.d in (select t1.d from t1 union select 17 from t1))) then c else t1.c end FROM t1 WHERE (coalesce((select f from t1 where case a-e+a when (abs(t1.d)/abs((coalesce((select ~t1.e*+t1.a+b*a*(abs(19)/abs(a))*a+e from t1 where 13<t1.e),a))))+11 then 11 else d end>=13 or t1.b<= -19),t1.f)+17* -t1.c<t1.c)}\n} {300}\ndo_test randexpr-2.157 {\n  db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when  -t1.a then d*t1.e+t1.c-11+b | e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE (e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end)}\n} {100}\ndo_test randexpr-2.158 {\n  db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when  -t1.a then d*t1.e+t1.c-11+b | e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE NOT ((e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end))}\n} {}\ndo_test randexpr-2.159 {\n  db eval {SELECT coalesce((select max(~t1.b) from t1 where b in (select count(distinct b) from t1 union select max(case coalesce((select max(b) from t1 where d in (select t1.f from t1 union select d from t1) and t1.a=d),t1.a) when  -t1.a then d*t1.e+t1.c-11+b & e-t1.a+e+t1.f else c end) from t1)),t1.a) FROM t1 WHERE (e<t1.f*case 17 when t1.a then t1.d else +coalesce((select max(17) from t1 where not 13<>~a-11),t1.f) end)}\n} {100}\ndo_test randexpr-2.160 {\n  db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then  -b else a end*b | d) and  -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE e>e}\n} {}\ndo_test randexpr-2.161 {\n  db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then  -b else a end*b | d) and  -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE NOT (e>e)}\n} {900}\ndo_test randexpr-2.162 {\n  db eval {SELECT case when not t1.c not in (13,d,~case when coalesce((select max((abs(t1.c)/abs(t1.e))) from t1 where b-t1.d+b+t1.f>a),t1.a) in (select 19 from t1 union select t1.a from t1) then  -b else a end*b & d) and  -(t1.b)>=e and 11<d or ((19))<> -t1.c then t1.f else t1.f end+(t1.b)+a FROM t1 WHERE NOT (e>e)}\n} {900}\ndo_test randexpr-2.163 {\n  db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e | a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE b<=t1.d}\n} {-600}\ndo_test randexpr-2.164 {\n  db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e | a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE NOT (b<=t1.d)}\n} {}\ndo_test randexpr-2.165 {\n  db eval {SELECT coalesce((select t1.c*c from t1 where (select (abs(cast(avg(b*13) AS integer))) from t1) in (select 11 from t1 union select e & a-17 from t1)), -case t1.c when t1.b++(select cast(avg(e) AS integer) from t1) then 17 else t1.b end)-d FROM t1 WHERE b<=t1.d}\n} {-600}\ndo_test randexpr-2.166 {\n  db eval {SELECT coalesce((select max((case (abs(t1.b)/abs(e)) when 13 then ((select +case count(*)*count(distinct coalesce((select max((11)+b) from t1 where exists(select 1 from t1 where t1.e=(t1.b))), -13)) when count(distinct  -c) then count(*)*max( -d) else max((a)) end+min(c) from t1)) else t1.a end-(abs(case when a=17 and e<=b then a when a>=e then t1.c else t1.c end+13)/abs(e))*(e))) from t1 where t1.a in (select d from t1 union select  -t1.e from t1)),13) FROM t1 WHERE not coalesce((select max(case when f<=d | b | case when case when (t1.c in (f,19,c)) then t1.f when d>t1.b then t1.f else t1.f end<=c then 11 else c end- -t1.c-13 and t1.c in (select b from t1 union select  -17 from t1) then t1.b else a end) from t1 where 11 between d and a), -17) not between t1.f and t1.f and t1.f>11 or (not exists(select 1 from t1 where t1.b in (select min(t1.d) from t1 union select min(c) from t1)))}\n} {13}\ndo_test randexpr-2.167 {\n  db eval {SELECT coalesce((select max((case (abs(t1.b)/abs(e)) when 13 then ((select +case count(*)*count(distinct coalesce((select max((11)+b) from t1 where exists(select 1 from t1 where t1.e=(t1.b))), -13)) when count(distinct  -c) then count(*)*max( -d) else max((a)) end+min(c) from t1)) else t1.a end-(abs(case when a=17 and e<=b then a when a>=e then t1.c else t1.c end+13)/abs(e))*(e))) from t1 where t1.a in (select d from t1 union select  -t1.e from t1)),13) FROM t1 WHERE NOT (not coalesce((select max(case when f<=d | b | case when case when (t1.c in (f,19,c)) then t1.f when d>t1.b then t1.f else t1.f end<=c then 11 else c end- -t1.c-13 and t1.c in (select b from t1 union select  -17 from t1) then t1.b else a end) from t1 where 11 between d and a), -17) not between t1.f and t1.f and t1.f>11 or (not exists(select 1 from t1 where t1.b in (select min(t1.d) from t1 union select min(c) from t1))))}\n} {}\ndo_test randexpr-2.168 {\n  db eval {SELECT case when ((t1.e | (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or  -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d | f end FROM t1 WHERE not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1)}\n} {}\ndo_test randexpr-2.169 {\n  db eval {SELECT case when ((t1.e | (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or  -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d | f end FROM t1 WHERE NOT (not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1))}\n} {984}\ndo_test randexpr-2.170 {\n  db eval {SELECT case when ((t1.e & (select min( -t1.f) from t1)*((abs(b)/abs(19)))-b<=t1.b and not e>13 or  -f in (select count(distinct e)-min(t1.a) from t1 union select count(distinct f) from t1))) then 13 when 17 between f and 19 or 11 between b and 19 or not t1.f>e then t1.d else d & f end FROM t1 WHERE NOT (not case when t1.a=t1.a then c when ~case when case when t1.e in (select + -count(distinct t1.d) from t1 union select cast(avg(t1.a) AS integer) from t1) then (t1.e) when 17 in (13, -f,a) then t1.d else d end<17 then e else f end+17+a* -e+b+b>t1.e then t1.e else t1.a end<c and a in (select max( -t1.f) | count(distinct t1.b)+~~count(distinct t1.b)-max(e)- -max(a) from t1 union select min(11) from t1))}\n} {16}\ndo_test randexpr-2.171 {\n  db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) | min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) | (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE 13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f}\n} {}\ndo_test randexpr-2.172 {\n  db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) | min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) | (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE NOT (13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f)}\n} {-15}\ndo_test randexpr-2.173 {\n  db eval {SELECT coalesce((select (select cast(avg(~13) AS integer)-count(distinct ~19-coalesce((select d-17 from t1 where case when (case 17 when b then d else (select min(11) & min(17) from t1)++t1.a end in (d, -c,t1.d)) then b else t1.c end between t1.a and (t1.e)),19)-t1.f) from t1) & (abs(t1.e)/abs(t1.e)) from t1 where (t1.c not in (( -t1.d),(t1.b),(d)))),t1.e) FROM t1 WHERE NOT (13 between 19 and ~ -(abs( -t1.d | coalesce((select t1.f from t1 where 19 not between + -case when ~~b+coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where (select cast(avg(19) AS integer)-cast(avg(b) AS integer) from t1)<>a and 19 between 11 and b and 11 between a and b)),t1.f) | c in ( -t1.c,13,b) then 11 when f in (select min(t1.d) from t1 union select cast(avg(f) AS integer) from t1) then t1.b else a end and t1.a),t1.c))/abs(11))+ -f)}\n} {1}\ndo_test randexpr-2.174 {\n  db eval {SELECT coalesce((select max(+(d+a)*b) from t1 where (case e-t1.b when 17+11*13 then t1.a else 17 end-(17)<>(select cast(avg(t1.f) AS integer) from t1))),case when case when 11+13<>19 then 13 else t1.f end*e in (a,t1.f,t1.c) and not exists(select 1 from t1 where t1.b in (select  - -count(distinct t1.b)*( -count(*)) from t1 union select count(distinct t1.e) from t1)) then t1.c else a end) FROM t1 WHERE case when t1.d in (select count(*)-count(*)+ -min(case d when t1.c then 19 else 11 end)*count(*) | min(19)-(max((e))) from t1 union select count(*) from t1) then c when exists(select 1 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (abs(b)/abs(t1.c))>coalesce((select max(f) from t1 where f<=t1.a),t1.d)))) then f*t1.c+11 else t1.f end+e-e*t1.f<=17}\n} {100000}\ndo_test randexpr-2.175 {\n  db eval {SELECT coalesce((select max(+(d+a)*b) from t1 where (case e-t1.b when 17+11*13 then t1.a else 17 end-(17)<>(select cast(avg(t1.f) AS integer) from t1))),case when case when 11+13<>19 then 13 else t1.f end*e in (a,t1.f,t1.c) and not exists(select 1 from t1 where t1.b in (select  - -count(distinct t1.b)*( -count(*)) from t1 union select count(distinct t1.e) from t1)) then t1.c else a end) FROM t1 WHERE NOT (case when t1.d in (select count(*)-count(*)+ -min(case d when t1.c then 19 else 11 end)*count(*) | min(19)-(max((e))) from t1 union select count(*) from t1) then c when exists(select 1 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (abs(b)/abs(t1.c))>coalesce((select max(f) from t1 where f<=t1.a),t1.d)))) then f*t1.c+11 else t1.f end+e-e*t1.f<=17)}\n} {}\ndo_test randexpr-2.176 {\n  db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d |  - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE ((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select  -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f)))))}\n} {}\ndo_test randexpr-2.177 {\n  db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d |  - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE NOT (((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select  -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f))))))}\n} {90000}\ndo_test randexpr-2.178 {\n  db eval {SELECT t1.c*case when t1.e>(select +cast(avg(13) AS integer)*min((11)* - -d &  - -coalesce((select max(b) from t1 where (select cast(avg((abs(a)/abs(b-(e)))) AS integer) from t1)+11*c<t1.d),e)-t1.f-t1.b+(t1.a)) from t1) then t1.c when +b in (17,a,b) then d else f end FROM t1 WHERE NOT (((not exists(select 1 from t1 where not (exists(select 1 from t1 where (t1.c in (select t1.d from t1 union select  -c from t1)) or (select cast(avg(~(e)) AS integer) | min(case when f=t1.e and t1.e in (t1.b,t1.f,t1.a) then t1.f when t1.d>=a then t1.b else t1.b end | 19+a-c)*count(distinct t1.d)-+count(distinct t1.d) from t1) not in (19,d,b) and t1.f not between b and t1.f))))))}\n} {120000}\ndo_test randexpr-2.179 {\n  db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) | count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else  -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) | min(t1.a)-cast(avg(t1.f) AS integer)) | max(e) from t1) else 11 end*a | t1.a*f FROM t1 WHERE t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or  -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d}\n} {61036}\ndo_test randexpr-2.180 {\n  db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) | count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else  -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) | min(t1.a)-cast(avg(t1.f) AS integer)) | max(e) from t1) else 11 end*a | t1.a*f FROM t1 WHERE NOT (t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or  -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d)}\n} {}\ndo_test randexpr-2.181 {\n  db eval {SELECT case when not exists(select 1 from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where not d*19=b))) or t1.a-a-t1.d*t1.f in (select ~case cast(avg(t1.d) AS integer) & count(*)+max(t1.c) when max(17) then cast(avg( -f) AS integer) else  -min(e) end from t1 union select max( -13) from t1)) then (select abs((+ -min(a)) & min(t1.a)-cast(avg(t1.f) AS integer)) & max(e) from t1) else 11 end*a & t1.a*f FROM t1 WHERE t1.c in (c,t1.b,~e) and 13+19-t1.b | coalesce((select max(case d when +t1.e+13*13 then coalesce((select case when f<t1.f then ~d else 19 end from t1 where not d>=e or  -f<=e and t1.d<>19),d) else d end) from t1 where t1.d<b),t1.a)*d*(a)<=t1.d}\n} {64}\ndo_test randexpr-2.182 {\n  db eval {SELECT (abs(t1.f-(abs(case c when t1.a+(select max(17-coalesce((select +e-t1.a+11-13+d+11-t1.a from t1 where t1.e in (select ~coalesce((select a from t1 where t1.c-a=b),t1.c)+17 from t1 union select t1.e from t1)),c)-d) from t1) then 17 else  -t1.e end)/abs(d))-17)/abs(t1.b)) FROM t1 WHERE b in (select +count(distinct (19)-11) from t1 union select case count(*) when  -case min((abs(t1.c*(t1.c)+11)/abs(19))*~d*f) when abs(count(*)+count(*)) then (+(min(e)* -cast(avg(17) AS integer)* -cast(avg(d) AS integer)+max(t1.f))) else (count(*)) end | (min( -((t1.b)))) then (max(t1.c)) else  -count(distinct t1.d) end from t1) and not exists(select 1 from t1 where d<f)}\n} {}\ndo_test randexpr-2.183 {\n  db eval {SELECT (abs(t1.f-(abs(case c when t1.a+(select max(17-coalesce((select +e-t1.a+11-13+d+11-t1.a from t1 where t1.e in (select ~coalesce((select a from t1 where t1.c-a=b),t1.c)+17 from t1 union select t1.e from t1)),c)-d) from t1) then 17 else  -t1.e end)/abs(d))-17)/abs(t1.b)) FROM t1 WHERE NOT (b in (select +count(distinct (19)-11) from t1 union select case count(*) when  -case min((abs(t1.c*(t1.c)+11)/abs(19))*~d*f) when abs(count(*)+count(*)) then (+(min(e)* -cast(avg(17) AS integer)* -cast(avg(d) AS integer)+max(t1.f))) else (count(*)) end | (min( -((t1.b)))) then (max(t1.c)) else  -count(distinct t1.d) end from t1) and not exists(select 1 from t1 where d<f))}\n} {2}\ndo_test randexpr-2.184 {\n  db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) | count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) |  -max(t1.e)) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.185 {\n  db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) | count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE NOT (b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) |  -max(t1.e)) from t1 union select count(*) from t1))}\n} {99}\ndo_test randexpr-2.186 {\n  db eval {SELECT ~case +~c+(case when not exists(select 1 from t1 where t1.d in (select abs( -abs(max(t1.f)-count(distinct e)* -cast(avg(11) AS integer) & count(*))+min(f)*min( -17)*cast(avg(19) AS integer)) from t1 union select count(*) from t1)) or (t1.f)<>t1.b then d*t1.f*17 else (b) end)+t1.f*13 when c then t1.a else t1.e end- -t1.f FROM t1 WHERE NOT (b-case when t1.b=t1.b and (coalesce((select max(t1.e) from t1 where t1.b in (select ~cast(avg(19) AS integer)+max(t1.b)+min(t1.e) from t1 union select max(t1.a) from t1) or exists(select 1 from t1 where 11 in (select max(t1.e) from t1 union select max(t1.f) from t1))),(abs(17)/abs(17)))) not between c and t1.a then 13 else 13 end | t1.c in (select ++cast(avg(f) AS integer)-(+(count(distinct 13) | max(19))-count(*) |  -max(t1.e)) from t1 union select count(*) from t1))}\n} {99}\ndo_test randexpr-2.187 {\n  db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) | t1.a+e not between (case  -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE t1.b*coalesce((select max(t1.d) from t1 where  -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else  -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f)}\n} {}\ndo_test randexpr-2.188 {\n  db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) | t1.a+e not between (case  -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE NOT (t1.b*coalesce((select max(t1.d) from t1 where  -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else  -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f))}\n} {11}\ndo_test randexpr-2.189 {\n  db eval {SELECT case when t1.c in (select c from t1 union select a from t1) then 11 when ((select max(19) from t1) & t1.a+e not between (case  -19 when b*e-b-case when b<>~d*t1.d+t1.c*d then t1.d when t1.c=19 then f else d end-f*t1.d then t1.d else 13 end) and 13) then 11 else t1.b end FROM t1 WHERE NOT (t1.b*coalesce((select max(t1.d) from t1 where  -f<=(select max(t1.e) from t1)*e),case when case when t1.e- -13>t1.b+t1.f+c then 13 else  -d end in (select 19 from t1 union select t1.f from t1) then e when t1.b in (select ~count(distinct t1.a)+count(*) from t1 union select abs( - -((cast(avg(c) AS integer)))*(cast(avg(t1.b) AS integer))) from t1) then 17 else d end)+ -17 | t1.a-t1.d in (t1.e,f,f))}\n} {11}\ndo_test randexpr-2.190 {\n  db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) | case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end |  -cast(avg(t1.f) AS integer) |  - -count(distinct c)*max(b) when count(distinct t1.d) then  - -min(a) else count(*) end from t1) FROM t1 WHERE t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then  -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between  -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d}\n} {-402}\ndo_test randexpr-2.191 {\n  db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) | case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end |  -cast(avg(t1.f) AS integer) |  - -count(distinct c)*max(b) when count(distinct t1.d) then  - -min(a) else count(*) end from t1) FROM t1 WHERE NOT (t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then  -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between  -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d)}\n} {}\ndo_test randexpr-2.192 {\n  db eval {SELECT ~(d)-(select case case cast(avg(t1.b- -~b) AS integer) when max(coalesce((select e from t1 where 11<>e),coalesce((select c from t1 where c not in (t1.e,a,(17)) or t1.b in ((b),t1.c,t1.f)),13))) then +cast(avg(d) AS integer) & case max(t1.c) when min((e)) then max(e)+cast(avg(t1.d) AS integer) else min(t1.f) end+max(d) else count(*) end &  -cast(avg(t1.f) AS integer) &  - -count(distinct c)*max(b) when count(distinct t1.d) then  - -min(a) else count(*) end from t1) FROM t1 WHERE t1.c+a=t1.e+t1.c*t1.e | case t1.d when case when 13 in (select min(c) from t1 union select max(d) from t1) or t1.f>=13 then 19 when t1.c<=11 then  -t1.b else 13 end then 13 else t1.e end or f in (select t1.a from t1 union select t1.f from t1) or (t1.a<t1.b) and e>t1.b and (((t1.d not between  -a and t1.f))) or t1.a not in ( -t1.d,13,a) and d<c or d=t1.d or e<d}\n} {-402}\ndo_test randexpr-2.193 {\n  db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d | (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE 11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when  -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1)}\n} {}\ndo_test randexpr-2.194 {\n  db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d | (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE NOT (11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when  -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1))}\n} {52}\ndo_test randexpr-2.195 {\n  db eval {SELECT (abs(coalesce((select max(a) from t1 where exists(select 1 from t1 where t1.f<19 and coalesce((select max(case when t1.a+e in (select t1.c from t1 union select f from t1) then f else (17) end) from t1 where t1.e in (f,coalesce((select max(t1.f) from t1 where 17<=((abs(t1.d & (t1.a))/abs(13))*(a))-d),17),e)),t1.c) not between t1.b and 11 and 13<t1.f)),f+t1.d))/abs(19)) FROM t1 WHERE NOT (11*c+17-f in (select min(t1.e*11*case when exists(select 1 from t1 where not exists(select 1 from t1 where + -17<a)) then (abs((d))/abs(13)) when 11 in (select case count(*) when count(distinct t1.f) then count(distinct 17) else cast(avg((11)) AS integer) end from t1 union select cast(avg(t1.c) AS integer) from t1) then b else e end) from t1 union select case count(*) when  -count(distinct t1.d) then max(a) else (count(distinct t1.c))-max((b)) | (count(distinct t1.e))*count(distinct (13))-count(distinct e) end-count(*)-count(*) from t1))}\n} {52}\ndo_test randexpr-2.196 {\n  db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) | case e when c then a else t1.b end+a FROM t1 WHERE case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1)}\n} {}\ndo_test randexpr-2.197 {\n  db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) | case e when c then a else t1.b end+a FROM t1 WHERE NOT (case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1))}\n} {303}\ndo_test randexpr-2.198 {\n  db eval {SELECT coalesce((select max(~t1.d) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where c>t1.c or ((t1.f>e)) and t1.e-19+c+ -d*t1.d+11<>17+coalesce((select max(t1.d) from t1 where 17+t1.c<t1.d),t1.b) or f<>11))),11) & case e when c then a else t1.b end+a FROM t1 WHERE NOT (case when d not in (a,11,(13)) then a when exists(select 1 from t1 where case when case when case when (t1.c) in (c,e,b) then f else (19) end-t1.f<t1.d then 11 else a end>=t1.a then 11 else t1.c end in (select abs(~~max(t1.c)) from t1 union select cast(avg(c) AS integer) from t1)) then 11 else t1.f end in (select (~~count(*)*cast(avg(19) AS integer)) from t1 union select min(t1.d)+ -count(distinct f) from t1))}\n} {8}\ndo_test randexpr-2.199 {\n  db eval {SELECT case when t1.e*t1.b<>e then 19 else  -11-b+coalesce((select max(t1.e+t1.f) from t1 where 11+f*t1.c<>t1.a*(~f+case when t1.f in (t1.f, -((13)),19) then t1.a when t1.e>17 then a else a end+b-t1.e-(f))),13)+d end+t1.b* -c FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(t1.a*t1.e+13) from t1 where 13 in ((abs(e)/abs(t1.a)),a+t1.c,17*t1.c)),(select  -case max(c) | cast(avg(e) AS integer) when ~+ -count(distinct coalesce((select d from t1 where exists(select 1 from t1 where  -17<e)),( -t1.e))) | case max(11) when cast(avg(a) AS integer) then max( -t1.f) else count(distinct  -11) end then cast(avg(t1.d) AS integer) else max((d)) end*count(distinct t1.b) from t1) | t1.b-t1.d*t1.c+11)<=b)}\n} {-59981}\ndo_test randexpr-2.200 {\n  db eval {SELECT case when t1.e*t1.b<>e then 19 else  -11-b+coalesce((select max(t1.e+t1.f) from t1 where 11+f*t1.c<>t1.a*(~f+case when t1.f in (t1.f, -((13)),19) then t1.a when t1.e>17 then a else a end+b-t1.e-(f))),13)+d end+t1.b* -c FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(t1.a*t1.e+13) from t1 where 13 in ((abs(e)/abs(t1.a)),a+t1.c,17*t1.c)),(select  -case max(c) | cast(avg(e) AS integer) when ~+ -count(distinct coalesce((select d from t1 where exists(select 1 from t1 where  -17<e)),( -t1.e))) | case max(11) when cast(avg(a) AS integer) then max( -t1.f) else count(distinct  -11) end then cast(avg(t1.d) AS integer) else max((d)) end*count(distinct t1.b) from t1) | t1.b-t1.d*t1.c+11)<=b))}\n} {}\ndo_test randexpr-2.201 {\n  db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) | max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE ( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19)}\n} {}\ndo_test randexpr-2.202 {\n  db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) | max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE NOT (( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19))}\n} {11}\ndo_test randexpr-2.203 {\n  db eval {SELECT coalesce((select max(coalesce((select 19 from t1 where (case when ((abs(coalesce((select max(case when t1.a between (t1.c)+ -b and d then e else d end) from t1 where t1.e in (select (count(*)) from t1 union select max( -a)-count(distinct t1.c)-((min(13))) & max((t1.f)) from t1)),11))/abs(19)))+d>c then t1.b when 17 not between t1.e and c then 11 else f end in (select a from t1 union select 13 from t1))),11)) from t1 where not exists(select 1 from t1 where f=17)),e) FROM t1 WHERE NOT (( -13 in (13,b,case when 19=11 then t1.d else case when (d | b-case when t1.f-(select +abs(cast(avg( -17* -17) AS integer)*count(*)+max(t1.e)) from t1)*t1.f not in (f,a,c) then t1.a else t1.b end between 19 and e) then a else 13 end end-t1.a) or t1.c<19))}\n} {11}\ndo_test randexpr-2.204 {\n  db eval {SELECT  -~d*19-a-c | t1.c+(abs(case  -19 | ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or  -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE t1.f+13<>19}\n} {7671}\ndo_test randexpr-2.205 {\n  db eval {SELECT  -~d*19-a-c | t1.c+(abs(case  -19 | ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or  -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE NOT (t1.f+13<>19)}\n} {}\ndo_test randexpr-2.206 {\n  db eval {SELECT  -~d*19-a-c & t1.c+(abs(case  -19 & ~case t1.d when c then t1.f else c end when +t1.d then 17 else case case when b>case case when t1.c=d or  -t1.a=17 then ((a)) when t1.a<>d then (t1.c) else a end+19+11 when 19 then t1.a else b end-(t1.e) then f else t1.c end when 17 then t1.b else a end end)/abs(d))+t1.b FROM t1 WHERE t1.f+13<>19}\n} {48}\ndo_test randexpr-2.207 {\n  db eval {SELECT (abs(coalesce((select b from t1 where t1.a>(abs(t1.f)/abs(coalesce((select 13 from t1 where not coalesce((select (select cast(avg(case when case when t1.e not between t1.c and 19 then t1.d when d in (11,t1.b,13) then e else 17 end*b between 13 and (t1.b) then t1.f when a<>19 and t1.c not in (a,t1.f,b) then t1.e else t1.f end) AS integer) from t1)+t1.c-b* -a*f from t1 where (t1.d in (select c from t1 union select t1.b from t1))),t1.e)-c<>c),t1.c)))),e))/abs(t1.e)) FROM t1 WHERE (t1.a-t1.c-case when e<c*17 then t1.e when case case t1.b when t1.c then coalesce((select max(t1.c) from t1 where t1.c in (select ~cast(avg(case when 17 in (t1.f,t1.f,t1.a) then c when 13<>b then f else d end | t1.d) AS integer) from t1 union select count(distinct 11) from t1)),c) else t1.f end when f then 19 else t1.b end<t1.f then t1.b else t1.e end-11 not between 11 and t1.d)}\n} {0}\ndo_test randexpr-2.208 {\n  db eval {SELECT (abs(coalesce((select b from t1 where t1.a>(abs(t1.f)/abs(coalesce((select 13 from t1 where not coalesce((select (select cast(avg(case when case when t1.e not between t1.c and 19 then t1.d when d in (11,t1.b,13) then e else 17 end*b between 13 and (t1.b) then t1.f when a<>19 and t1.c not in (a,t1.f,b) then t1.e else t1.f end) AS integer) from t1)+t1.c-b* -a*f from t1 where (t1.d in (select c from t1 union select t1.b from t1))),t1.e)-c<>c),t1.c)))),e))/abs(t1.e)) FROM t1 WHERE NOT ((t1.a-t1.c-case when e<c*17 then t1.e when case case t1.b when t1.c then coalesce((select max(t1.c) from t1 where t1.c in (select ~cast(avg(case when 17 in (t1.f,t1.f,t1.a) then c when 13<>b then f else d end | t1.d) AS integer) from t1 union select count(distinct 11) from t1)),c) else t1.f end when f then 19 else t1.b end<t1.f then t1.b else t1.e end-11 not between 11 and t1.d))}\n} {}\ndo_test randexpr-2.209 {\n  db eval {SELECT case when t1.d<>d then case 11 when ~+case t1.a when (abs(t1.a)/abs( -c))*t1.c+ -a+coalesce((select t1.c from t1 where ((abs(e)/abs((case when (11>=e) then  -17 when (11)<=a then e else b end)+t1.f))>19)),b)-d then c else 17 end+ -b then ( -t1.a) else c end when 11<=t1.f then 11 else 17 end FROM t1 WHERE (coalesce((select max(17) from t1 where ~case ((select min( -e-a)*+cast(avg(11) AS integer)*count(*)-(count(*))*max(b)*min( -13)+count(*)-min( -13) from t1)+19)+a when e then (select min(f) from t1) else coalesce((select t1.f from t1 where 17>t1.c),19) end=11 and f=t1.b),19) not between  -a and t1.a)}\n} {}\ndo_test randexpr-2.210 {\n  db eval {SELECT case when t1.d<>d then case 11 when ~+case t1.a when (abs(t1.a)/abs( -c))*t1.c+ -a+coalesce((select t1.c from t1 where ((abs(e)/abs((case when (11>=e) then  -17 when (11)<=a then e else b end)+t1.f))>19)),b)-d then c else 17 end+ -b then ( -t1.a) else c end when 11<=t1.f then 11 else 17 end FROM t1 WHERE NOT ((coalesce((select max(17) from t1 where ~case ((select min( -e-a)*+cast(avg(11) AS integer)*count(*)-(count(*))*max(b)*min( -13)+count(*)-min( -13) from t1)+19)+a when e then (select min(f) from t1) else coalesce((select t1.f from t1 where 17>t1.c),19) end=11 and f=t1.b),19) not between  -a and t1.a))}\n} {11}\ndo_test randexpr-2.211 {\n  db eval {SELECT coalesce((select max(t1.e) from t1 where not d in (select (abs(t1.f)/abs(~case when (abs(t1.e)/abs( -t1.a))+t1.b-t1.e*t1.a-t1.c between b and t1.e then f else a end+19)) from t1 union select 13 from t1) or (t1.e=(a)) and  -11 in (select t1.f from t1 union select c from t1)),a)*coalesce((select max(f) from t1 where d=f),f)*c+(t1.c) FROM t1 WHERE case when +(abs(19)/abs(13*t1.e))<>11 then 19 when coalesce((select max(c) from t1 where t1.e+t1.a between t1.f and f),t1.a)=(a) then d else  -19 end<=f or (((e in (b,t1.b,13)))) or b<(f) and t1.a<>11 or exists(select 1 from t1 where t1.d=d) or (t1.a)<>a or t1.a<>e}\n} {90000300}\ndo_test randexpr-2.212 {\n  db eval {SELECT coalesce((select max(t1.e) from t1 where not d in (select (abs(t1.f)/abs(~case when (abs(t1.e)/abs( -t1.a))+t1.b-t1.e*t1.a-t1.c between b and t1.e then f else a end+19)) from t1 union select 13 from t1) or (t1.e=(a)) and  -11 in (select t1.f from t1 union select c from t1)),a)*coalesce((select max(f) from t1 where d=f),f)*c+(t1.c) FROM t1 WHERE NOT (case when +(abs(19)/abs(13*t1.e))<>11 then 19 when coalesce((select max(c) from t1 where t1.e+t1.a between t1.f and f),t1.a)=(a) then d else  -19 end<=f or (((e in (b,t1.b,13)))) or b<(f) and t1.a<>11 or exists(select 1 from t1 where t1.d=d) or (t1.a)<>a or t1.a<>e)}\n} {}\ndo_test randexpr-2.213 {\n  db eval {SELECT case (select abs(count(distinct  -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end | b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) | count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then  -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11)}\n} {}\ndo_test randexpr-2.214 {\n  db eval {SELECT case (select abs(count(distinct  -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end | b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) | count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE NOT (case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then  -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11))}\n} {200}\ndo_test randexpr-2.215 {\n  db eval {SELECT case (select abs(count(distinct  -17+(abs(c)/abs(case when exists(select 1 from t1 where (17<>(f))) then e when t1.c not between 11 and t1.d then +11 else t1.e end & b))+d)*+ -(min(f)*max(t1.e))*+cast(avg(t1.f) AS integer) & count(distinct (f))- - -count(*)-cast(avg((e)) AS integer)) from t1) when (abs(11)/abs(t1.e)) then 13 else b end FROM t1 WHERE NOT (case when t1.e not between coalesce((select (select count(*)+case max(17) when count(distinct 19-t1.c*t1.c-e) then  -min(b)-cast(avg((13)) AS integer)*count(*) else min(19) end from t1)*a*t1.d-17*a+17 from t1 where t1.d not in (13,t1.f, -c)),t1.c) and e then ( -b) when (13)>=(e) then t1.c else e end in (t1.d,t1.c, -11))}\n} {200}\ndo_test randexpr-2.216 {\n  db eval {SELECT  -case when d<d or not exists(select 1 from t1 where not exists(select 1 from t1 where not not not exists(select 1 from t1 where not e+~t1.c between t1.e and t1.c and t1.c>t1.d))) then case +coalesce((select case when 13>t1.b then 17+t1.d+d when 17 in (t1.b,b,b) and 17<=t1.e then (c) else t1.d end from t1 where 17<a),11) when f then t1.c else b end when 19 between 11 and t1.e then f else a end-19*13 FROM t1 WHERE exists(select 1 from t1 where +13 in (select count(distinct 13) from t1 union select case count(*)+ -(max(t1.c)) when count(*) | ~( -count(*)-count(distinct  -f))+min(a)-max(t1.b) then  - -max(13) else max(e) end+count(distinct 17) from t1) and d*t1.b>b+t1.a*t1.a-coalesce((select max(d) from t1 where (17 between (t1.d) and (f))),t1.e)-t1.c and t1.d>11)}\n} {}\ndo_test randexpr-2.217 {\n  db eval {SELECT  -case when d<d or not exists(select 1 from t1 where not exists(select 1 from t1 where not not not exists(select 1 from t1 where not e+~t1.c between t1.e and t1.c and t1.c>t1.d))) then case +coalesce((select case when 13>t1.b then 17+t1.d+d when 17 in (t1.b,b,b) and 17<=t1.e then (c) else t1.d end from t1 where 17<a),11) when f then t1.c else b end when 19 between 11 and t1.e then f else a end-19*13 FROM t1 WHERE NOT (exists(select 1 from t1 where +13 in (select count(distinct 13) from t1 union select case count(*)+ -(max(t1.c)) when count(*) | ~( -count(*)-count(distinct  -f))+min(a)-max(t1.b) then  - -max(13) else max(e) end+count(distinct 17) from t1) and d*t1.b>b+t1.a*t1.a-coalesce((select max(d) from t1 where (17 between (t1.d) and (f))),t1.e)-t1.c and t1.d>11))}\n} {-447}\ndo_test randexpr-2.218 {\n  db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) | case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case  -count(*) when  -count(*) then  -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) |  -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where  -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select  -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else  -cast(avg(17) AS integer) end from t1)),case t1.f when  -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b)}\n} {-452}\ndo_test randexpr-2.219 {\n  db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) | case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case  -count(*) when  -count(*) then  -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) |  -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where  -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select  -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else  -cast(avg(17) AS integer) end from t1)),case t1.f when  -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b))}\n} {}\ndo_test randexpr-2.220 {\n  db eval {SELECT (select + -max(t1.c)*abs(min(t1.b) & case (abs(min(13)))+count(*)-max(t1.a) when max(~13) then abs( -~min(t1.b)+abs(count(distinct (select +++cast(avg(t1.b) AS integer)-case  -count(*) when  -count(*) then  -count(distinct b) else count(distinct c) end from t1)))) else count(*) end-max((e))) &  -cast(avg(t1.e) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where  -f-d*t1.f-c-coalesce((select max(t1.a) from t1 where 11 not in ((select count(*) from t1),coalesce((select max(t1.f+e) from t1 where t1.b in (select count(distinct t1.c) from t1 union select  -case abs(abs(count(distinct 13))) when max(t1.b) then abs(cast(avg(11) AS integer)) else  -cast(avg(17) AS integer) end from t1)),case t1.f when  -b then 17 else 17 end)- -t1.f,b)),a)+f+c-t1.c<t1.b)}\n} {-2560}\ndo_test randexpr-2.221 {\n  db eval {SELECT  -+(select count(distinct case when (case ~c | coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then  -c else  -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE f<= -b}\n} {}\ndo_test randexpr-2.222 {\n  db eval {SELECT  -+(select count(distinct case when (case ~c | coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then  -c else  -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE NOT (f<= -b)}\n} {-1}\ndo_test randexpr-2.223 {\n  db eval {SELECT  -+(select count(distinct case when (case ~c & coalesce((select max(t1.e-f+t1.d) from t1 where b-coalesce((select max(b) from t1 where t1.c in (select max(t1.d) from t1 union select min(a) from t1)),t1.f) in (select t1.a from t1 union select e from t1)),c) when e then  -c else  -t1.b end in ( -19, -d,b)) then d when t1.e in (19,d,19) and (t1.b between c and t1.a) then t1.d else 17 end-d) from t1) FROM t1 WHERE NOT (f<= -b)}\n} {-1}\ndo_test randexpr-2.224 {\n  db eval {SELECT (abs(~(+t1.b))/abs(~coalesce((select max(t1.a) from t1 where t1.f<+case when not exists(select 1 from t1 where not c+11=case c when t1.e then 13 else t1.f end+t1.e) and t1.f in (select 11 from t1 union select t1.d from t1) and c not in (t1.f,17,a) then case when a=17 or t1.c between t1.e and 19 or t1.a<>e then 19 else t1.c-t1.d end else b end),(e))-t1.a+(13)-19)) FROM t1 WHERE (not t1.e not in (case when exists(select 1 from t1 where 17<=t1.f*17*t1.b) then f+coalesce((select max(t1.b-c-11+t1.c-a) from t1 where 13 in (select t1.e from t1 union select case when a not between t1.f and d or f<t1.f then d when t1.f<=e then d else e end+17- -17 from t1)),t1.c) else t1.f end,e,t1.a) or exists(select 1 from t1 where t1.a not in (t1.c,(t1.d),(t1.c))))}\n} {0}\ndo_test randexpr-2.225 {\n  db eval {SELECT (abs(~(+t1.b))/abs(~coalesce((select max(t1.a) from t1 where t1.f<+case when not exists(select 1 from t1 where not c+11=case c when t1.e then 13 else t1.f end+t1.e) and t1.f in (select 11 from t1 union select t1.d from t1) and c not in (t1.f,17,a) then case when a=17 or t1.c between t1.e and 19 or t1.a<>e then 19 else t1.c-t1.d end else b end),(e))-t1.a+(13)-19)) FROM t1 WHERE NOT ((not t1.e not in (case when exists(select 1 from t1 where 17<=t1.f*17*t1.b) then f+coalesce((select max(t1.b-c-11+t1.c-a) from t1 where 13 in (select t1.e from t1 union select case when a not between t1.f and d or f<t1.f then d when t1.f<=e then d else e end+17- -17 from t1)),t1.c) else t1.f end,e,t1.a) or exists(select 1 from t1 where t1.a not in (t1.c,(t1.d),(t1.c)))))}\n} {}\ndo_test randexpr-2.226 {\n  db eval {SELECT (select min(b) | case case cast(avg(c) AS integer) when ~+~count(distinct  -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) |  - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE case when (((exists(select 1 from t1 where ~t1.d-t1.f between  -+t1.f*c and f and not t1.e in (19,a,13))) or  -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where  -t1.b>=d),13) else b end}\n} {203}\ndo_test randexpr-2.227 {\n  db eval {SELECT (select min(b) | case case cast(avg(c) AS integer) when ~+~count(distinct  -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) |  - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE NOT (case when (((exists(select 1 from t1 where ~t1.d-t1.f between  -+t1.f*c and f and not t1.e in (19,a,13))) or  -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where  -t1.b>=d),13) else b end)}\n} {}\ndo_test randexpr-2.228 {\n  db eval {SELECT (select min(b) & case case cast(avg(c) AS integer) when ~+~count(distinct  -19*f*f) then count(distinct (select cast(avg(d-case when t1.a<=19 then 19 else 11 end+f+a) AS integer) from t1))+count(distinct t1.c)+ -+ -count(*) &  - -max((17))*min(t1.b)*min((e)) else max(t1.c) end when ( - - -min(a)) then ( -min(c)) else max((11)) end from t1) FROM t1 WHERE case when (((exists(select 1 from t1 where ~t1.d-t1.f between  -+t1.f*c and f and not t1.e in (19,a,13))) or  -e>=t1.b) and (t1.e<>( -t1.d)) and (t1.c<=13)) then c else d+11 end<=case when (t1.c)>=19 then (t1.e) when (f) not between 11 and f then coalesce((select 13 from t1 where  -t1.b>=d),13) else b end}\n} {8}\ndo_test randexpr-2.229 {\n  db eval {SELECT case when 19-b in (select (min(case coalesce((select e from t1 where (c not between c and e)),(select abs(count(distinct coalesce((select max( -coalesce((select max(17) from t1 where (d)>17 and c not between d and b),11)-d) from t1 where ((11)) not in (d,d,e)), - -e))) from t1)+t1.e+t1.a) when f then t1.e else t1.a end)) from t1 union select max(11) from t1) then c else f end+t1.e FROM t1 WHERE coalesce((select max(d) from t1 where coalesce((select max(case when (a++19=case t1.d when t1.e then t1.b else t1.a end*f) and  -13=a then case t1.d+13 when t1.f then 17 else t1.f end when (11 not in (d,17,t1.f)) then e else 11 end+b*t1.b) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where t1.f in (select t1.e from t1 union select b from t1)))),(d))<=c),a) between t1.f and d}\n} {}\ndo_test randexpr-2.230 {\n  db eval {SELECT case when 19-b in (select (min(case coalesce((select e from t1 where (c not between c and e)),(select abs(count(distinct coalesce((select max( -coalesce((select max(17) from t1 where (d)>17 and c not between d and b),11)-d) from t1 where ((11)) not in (d,d,e)), - -e))) from t1)+t1.e+t1.a) when f then t1.e else t1.a end)) from t1 union select max(11) from t1) then c else f end+t1.e FROM t1 WHERE NOT (coalesce((select max(d) from t1 where coalesce((select max(case when (a++19=case t1.d when t1.e then t1.b else t1.a end*f) and  -13=a then case t1.d+13 when t1.f then 17 else t1.f end when (11 not in (d,17,t1.f)) then e else 11 end+b*t1.b) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where t1.f in (select t1.e from t1 union select b from t1)))),(d))<=c),a) between t1.f and d)}\n} {1100}\ndo_test randexpr-2.231 {\n  db eval {SELECT  -t1.e*coalesce((select max(17) from t1 where (11*(select case  -abs( -+count(*)) when  -case +(cast(avg( -f) AS integer)) | (abs(cast(avg(c) AS integer))) when min(d) then  -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE (select min(19) from t1) in (select 17 from t1 union select  -11+t1.d+t1.c from t1)}\n} {}\ndo_test randexpr-2.232 {\n  db eval {SELECT  -t1.e*coalesce((select max(17) from t1 where (11*(select case  -abs( -+count(*)) when  -case +(cast(avg( -f) AS integer)) | (abs(cast(avg(c) AS integer))) when min(d) then  -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE NOT ((select min(19) from t1) in (select 17 from t1 union select  -11+t1.d+t1.c from t1))}\n} {50000}\ndo_test randexpr-2.233 {\n  db eval {SELECT  -t1.e*coalesce((select max(17) from t1 where (11*(select case  -abs( -+count(*)) when  -case +(cast(avg( -f) AS integer)) & (abs(cast(avg(c) AS integer))) when min(d) then  -max(t1.f) else count(*) end then cast(avg( -t1.f) AS integer) else max(b) end from t1)*~t1.e*case (select min(e) from t1) when 17-t1.b then (e) else t1.f+t1.f end) in (select t1.d from t1 union select 19 from t1)), -t1.a) FROM t1 WHERE NOT ((select min(19) from t1) in (select 17 from t1 union select  -11+t1.d+t1.c from t1))}\n} {50000}\ndo_test randexpr-2.234 {\n  db eval {SELECT (coalesce((select max(case when t1.e>= -e | 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) | count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else  -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE (((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when  -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then  -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select  - -count(*) from t1))))}\n} {}\ndo_test randexpr-2.235 {\n  db eval {SELECT (coalesce((select max(case when t1.e>= -e | 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) | count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else  -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE NOT ((((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when  -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then  -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select  - -count(*) from t1)))))}\n} {-7600}\ndo_test randexpr-2.236 {\n  db eval {SELECT (coalesce((select max(case when t1.e>= -e & 13-19*d then case when c not in (+(select count(*) from t1),coalesce((select max(t1.a) from t1 where 13 in (select case count(distinct t1.a) & count(*) when cast(avg(t1.b) AS integer) then count(distinct a) else min(11) end from t1 union select count(*) from t1)),19),t1.a) then t1.c else c end when t1.f in (select t1.f from t1 union select t1.e from t1) then t1.e else  -t1.e end) from t1 where (17 in (e,d,a))),t1.d)* -19) FROM t1 WHERE NOT ((((abs(t1.f)/abs(d)) in (select case (case max(coalesce((select max(e*(t1.d*13+t1.b)-t1.b) from t1 where t1.a=13),(t1.c))) when (case max(t1.a) when  -abs(max(17))-count(distinct 19) then cast(avg(t1.d) AS integer) else max(13) end)*count(distinct t1.c) then (max((t1.b))) else min(19) end) when max(f) then  -(count(distinct t1.f)) else min(t1.b) end from t1 union select cast(avg(13) AS integer) from t1) and (13 in (select ((min(b))) from t1 union select  - -count(*) from t1)))))}\n} {-7600}\ndo_test randexpr-2.237 {\n  db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end | c)-( -case min(c) when  -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else  -19 end FROM t1 WHERE d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end}\n} {-19}\ndo_test randexpr-2.238 {\n  db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end | c)-( -case min(c) when  -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else  -19 end FROM t1 WHERE NOT (d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end)}\n} {}\ndo_test randexpr-2.239 {\n  db eval {SELECT case when case when b in (select abs(abs( -max(case c+d when f then f else 19 end & c)-( -case min(c) when  -(cast(avg((t1.f)) AS integer)) then count(*) else ((cast(avg(t1.b) AS integer))) end))+count(*)+(max(17))) from t1 union select count(*) from t1) then t1.a when ~13*t1.a- -c not in (b,e,19) then t1.c else (t1.d) end<=(b) and 13 between t1.f and 11 then t1.f else  -19 end FROM t1 WHERE d>=case when t1.d+case when ( -17)-c>11 or b in ((select min(13)+ -cast(avg(11) AS integer) from t1)+~t1.f, -c,(13)) and e in (select (d) from t1 union select f from t1) then t1.a when d= -t1.d then a- -17 else 17 end-t1.c>d then 11 when exists(select 1 from t1 where 17 not between t1.b and t1.b) then t1.b else (t1.a) end}\n} {-19}\ndo_test randexpr-2.240 {\n  db eval {SELECT e-coalesce((select coalesce((select max(19) from t1 where (coalesce((select max(case 11 when b then 13 else t1.a end) from t1 where 19 not in (c,t1.f,b)),t1.a)+t1.d in (select 17 from t1 union select 19 from t1) and 11 in (13,t1.c,17) or 19 not in (t1.f,a,17) or t1.e not between 13 and f and a>=d)),(a)-17+t1.f)+t1.a+17 from t1 where not exists(select 1 from t1 where a>t1.f)),t1.b) FROM t1 WHERE t1.a-17 in (select (abs(count(*)))-case case case abs(abs(count(*))) when min(t1.f) then count(*) else cast(avg(+t1.a+(e) | 19*e+t1.f) AS integer) end when abs(+cast(avg(b) AS integer) | count(distinct (13))*+~ -(min(e)) | cast(avg(19) AS integer)) then cast(avg(19) AS integer) else count(distinct t1.c) end | min(t1.d) when count(*) then (count(distinct d)) else (min(11)) end from t1 union select (cast(avg(t1.a) AS integer)) from t1)}\n} {}\ndo_test randexpr-2.241 {\n  db eval {SELECT e-coalesce((select coalesce((select max(19) from t1 where (coalesce((select max(case 11 when b then 13 else t1.a end) from t1 where 19 not in (c,t1.f,b)),t1.a)+t1.d in (select 17 from t1 union select 19 from t1) and 11 in (13,t1.c,17) or 19 not in (t1.f,a,17) or t1.e not between 13 and f and a>=d)),(a)-17+t1.f)+t1.a+17 from t1 where not exists(select 1 from t1 where a>t1.f)),t1.b) FROM t1 WHERE NOT (t1.a-17 in (select (abs(count(*)))-case case case abs(abs(count(*))) when min(t1.f) then count(*) else cast(avg(+t1.a+(e) | 19*e+t1.f) AS integer) end when abs(+cast(avg(b) AS integer) | count(distinct (13))*+~ -(min(e)) | cast(avg(19) AS integer)) then cast(avg(19) AS integer) else count(distinct t1.c) end | min(t1.d) when count(*) then (count(distinct d)) else (min(11)) end from t1 union select (cast(avg(t1.a) AS integer)) from t1))}\n} {364}\ndo_test randexpr-2.242 {\n  db eval {SELECT  -coalesce((select case when b>19 | f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE +c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select  -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select  -count(distinct 19) from t1))) then  -e*19 else 13 end,t1.a,d)}\n} {}\ndo_test randexpr-2.243 {\n  db eval {SELECT  -coalesce((select case when b>19 | f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE NOT (+c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select  -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select  -count(distinct 19) from t1))) then  -e*19 else 13 end,t1.a,d))}\n} {-383}\ndo_test randexpr-2.244 {\n  db eval {SELECT  -coalesce((select case when b>19 & f-(select abs(max(t1.b+case when e>17 then 11 else f end)+count(*)) from t1) and case when (19<11*t1.d*t1.b) then 13 else t1.e end not between c and b then d+17 else c end-f from t1 where t1.b>=f),t1.c)+17-a FROM t1 WHERE NOT (+c in (+~a+case when ((case t1.d when coalesce((select f from t1 where e in (select count(distinct t1.e) from t1 union select min((abs(t1.c)/abs(e | b)) | d* -t1.d) from t1)),t1.e)+a then c else b end in (select  -cast(avg(t1.c) AS integer)-~cast(avg(11) AS integer) from t1 union select  -count(distinct 19) from t1))) then  -e*19 else 13 end,t1.a,d))}\n} {-383}\ndo_test randexpr-2.245 {\n  db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e | +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b | (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when  -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when  -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1))}\n} {}\ndo_test randexpr-2.246 {\n  db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e | +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b | (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE NOT (exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when  -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when  -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1)))}\n} {500}\ndo_test randexpr-2.247 {\n  db eval {SELECT case when t1.b>=+(abs(t1.e)/abs(coalesce((select c from t1 where 17<=+(e)),(e)-+~11*17+t1.d-e & +coalesce((select max(t1.d) from t1 where f>e),t1.a)*b & (e))))-t1.a and c>=t1.d or (17 not between e and b) then t1.e else d end FROM t1 WHERE NOT (exists(select 1 from t1 where (19-((17))+(b) in (select d*e*a from t1 union select ~19 from t1)) and case b-(abs(case a when coalesce((select max(19) from t1 where exists(select 1 from t1 where exists(select 1 from t1 where b not between e and (t1.f) or a not in (t1.c,17,t1.d)))),case t1.b when  -d then 13 else 13 end)*a+t1.c then e else a end)/abs(t1.d))*t1.e when  -13 then t1.c else 19 end in (select +count(distinct e) from t1 union select count(*) from t1)))}\n} {500}\ndo_test randexpr-2.248 {\n  db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) | ( -min(t1.b)) | count(distinct 19) | (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where  -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then  -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c}\n} {19}\ndo_test randexpr-2.249 {\n  db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) | ( -min(t1.b)) | count(distinct 19) | (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where  -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE NOT (case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then  -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c)}\n} {}\ndo_test randexpr-2.250 {\n  db eval {SELECT case when 11 in (select min(+t1.e)* -max(a)+count(distinct d*11*c)*(count(distinct (e))) & ( -min(t1.b)) & count(distinct 19) & (max(t1.f))-max(t1.b) from t1 union select (min(19)) from t1) then coalesce((select max(17) from t1 where  -17=13 or c in (select t1.d from t1 union select d from t1)),b)*t1.b-a+19 when t1.d<(d) then (d) else 19 end FROM t1 WHERE case when case when t1.c not in (f,19,b) then t1.d-t1.c-case when 17<>t1.a then  -(abs((select cast(avg(b) AS integer)- -max(t1.c) from t1))/abs(t1.c)) else t1.f end-17 | 19 when exists(select 1 from t1 where exists(select 1 from t1 where (e between 13 and (t1.a))) and e<=t1.c) then f else t1.a end>=11 then c when f<a then t1.b else t1.e end=t1.c}\n} {19}\ndo_test randexpr-2.251 {\n  db eval {SELECT c*~17+~case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(e)/abs(c))=case when t1.c not in (a,13,11) and t1.b>=c then t1.b else t1.f end)) and 17<>f) then case when (e) not in (t1.a,t1.f,e) then case case t1.c when 13 then 19 else t1.d end-19 when t1.d then  -t1.b else t1.f end when t1.d not in (17,t1.a,t1.d) or c in (d,(19),t1.b) then  -t1.b else c end else 19 end+t1.b-f+t1.e FROM t1 WHERE t1.f-case when (coalesce((select 13*(abs(~11)/abs(t1.b)) from t1 where ~a between +f+~+17 and t1.e),e) not between coalesce((select 19-(abs(11)/abs(t1.b)) from t1 where f<>c),t1.b) and t1.f or t1.d between (select case min(a) when cast(avg(e) AS integer) then  -((count(*))) else cast(avg(t1.a) AS integer) end | count(*) from t1) and (t1.a)) then 19 else f end=f}\n} {}\ndo_test randexpr-2.252 {\n  db eval {SELECT c*~17+~case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(e)/abs(c))=case when t1.c not in (a,13,11) and t1.b>=c then t1.b else t1.f end)) and 17<>f) then case when (e) not in (t1.a,t1.f,e) then case case t1.c when 13 then 19 else t1.d end-19 when t1.d then  -t1.b else t1.f end when t1.d not in (17,t1.a,t1.d) or c in (d,(19),t1.b) then  -t1.b else c end else 19 end+t1.b-f+t1.e FROM t1 WHERE NOT (t1.f-case when (coalesce((select 13*(abs(~11)/abs(t1.b)) from t1 where ~a between +f+~+17 and t1.e),e) not between coalesce((select 19-(abs(11)/abs(t1.b)) from t1 where f<>c),t1.b) and t1.f or t1.d between (select case min(a) when cast(avg(e) AS integer) then  -((count(*))) else cast(avg(t1.a) AS integer) end | count(*) from t1) and (t1.a)) then 19 else f end=f)}\n} {-5601}\ndo_test randexpr-2.253 {\n  db eval {SELECT coalesce((select c-t1.a | 17 | b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE (((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) |  -(c))<>e))}\n} {763}\ndo_test randexpr-2.254 {\n  db eval {SELECT coalesce((select c-t1.a | 17 | b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE NOT ((((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) |  -(c))<>e)))}\n} {}\ndo_test randexpr-2.255 {\n  db eval {SELECT coalesce((select c-t1.a & 17 & b-~t1.e-11 from t1 where not exists(select 1 from t1 where t1.c<=t1.b)),17) FROM t1 WHERE (((coalesce((select max((abs(b-t1.d-19*t1.a*e+~case when t1.e=t1.f-e then (select abs(abs(cast(avg((f)) AS integer))) from t1) else ((abs(t1.b)/abs(t1.a))) end-t1.b-t1.c)/abs(t1.b))) from t1 where not t1.c in (select count(distinct c) from t1 union select count(*) from t1) and 17< -t1.e),(c)) |  -(c))<>e))}\n} {0}\ndo_test randexpr-2.256 {\n  db eval {SELECT case case +(select case count(distinct case when case when (abs(f | t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) | ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then  -f else t1.a end+d FROM t1 WHERE case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between  - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or  -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1)}\n} {}\ndo_test randexpr-2.257 {\n  db eval {SELECT case case +(select case count(distinct case when case when (abs(f | t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) | ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then  -f else t1.a end+d FROM t1 WHERE NOT (case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between  - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or  -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1))}\n} {-200}\ndo_test randexpr-2.258 {\n  db eval {SELECT case case +(select case count(distinct case when case when (abs(f & t1.d)/abs(13))<= -c then t1.a else t1.b end+t1.b<=19 then c when 19=a then 17 else 11 end+13) when ~+case (cast(avg(t1.b) AS integer) & ((count(*)))-max(t1.d)) when count(distinct d) then count(*) else cast(avg(t1.c) AS integer) end then count(*) else count(*) end from t1) when c*t1.a then 13 else t1.a end when a then  -f else t1.a end+d FROM t1 WHERE NOT (case when coalesce((select t1.c | c*t1.e-11 from t1 where exists(select 1 from t1 where t1.d-t1.d*d between  - -t1.e and a)), -13)<=e and 11 not in (d,t1.a,f) and t1.a not between 11 and 19 or t1.e<>t1.e and t1.e<c or a between t1.c and c and d>=t1.a or  -t1.e>=b then b when 17 not between t1.f and t1.b then a else b end in (select 11 from t1 union select f from t1))}\n} {-200}\ndo_test randexpr-2.259 {\n  db eval {SELECT f*coalesce((select max((select count(*) from t1)) from t1 where ~case when t1.e<=case when 17>=+case when c*a in (c,t1.b,13) then t1.e when a>t1.b and a<=19 then c else t1.e end then t1.c else 17 end-f*17 or a between b and 19 then t1.c when  -f<=11 then c else  -11 end*t1.c+d>=e),17) FROM t1 WHERE (19 not between t1.b and ~e)}\n} {10200}\ndo_test randexpr-2.260 {\n  db eval {SELECT f*coalesce((select max((select count(*) from t1)) from t1 where ~case when t1.e<=case when 17>=+case when c*a in (c,t1.b,13) then t1.e when a>t1.b and a<=19 then c else t1.e end then t1.c else 17 end-f*17 or a between b and 19 then t1.c when  -f<=11 then c else  -11 end*t1.c+d>=e),17) FROM t1 WHERE NOT ((19 not between t1.b and ~e))}\n} {}\ndo_test randexpr-2.261 {\n  db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) |  -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where  -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE c<>e+t1.c}\n} {100}\ndo_test randexpr-2.262 {\n  db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) |  -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where  -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE NOT (c<>e+t1.c)}\n} {}\ndo_test randexpr-2.263 {\n  db eval {SELECT coalesce((select max(t1.c- -case when (~(select max(b*t1.a)*~((min(t1.e))-min((a))) &  -cast(avg(t1.e+t1.a) AS integer) from t1))<d then c else (abs( -~19)/abs(c)) end-coalesce((select max(t1.e+a) from t1 where 11<>c or (t1.b)> -(11)),11)) from t1 where  -11 in ((d),f,t1.d)),t1.a) FROM t1 WHERE c<>e+t1.c}\n} {100}\ndo_test randexpr-2.264 {\n  db eval {SELECT  -case when (not exists(select 1 from t1 where e*d*case 17 when case t1.c-t1.f when t1.a then t1.a else 11 end then t1.c else t1.b end-e+(t1.a)-e not in (e,e,t1.a) and (t1.f not between 19 and t1.e))) and t1.b<t1.a then f-d-c+b when 17=17 then 19 else d end FROM t1 WHERE f*t1.a not between coalesce((select t1.b from t1 where 17=13),17*e) and e}\n} {-19}\ndo_test randexpr-2.265 {\n  db eval {SELECT  -case when (not exists(select 1 from t1 where e*d*case 17 when case t1.c-t1.f when t1.a then t1.a else 11 end then t1.c else t1.b end-e+(t1.a)-e not in (e,e,t1.a) and (t1.f not between 19 and t1.e))) and t1.b<t1.a then f-d-c+b when 17=17 then 19 else d end FROM t1 WHERE NOT (f*t1.a not between coalesce((select t1.b from t1 where 17=13),17*e) and e)}\n} {}\ndo_test randexpr-2.266 {\n  db eval {SELECT coalesce((select 17+coalesce((select max(case when  -coalesce((select max((abs( -(abs(t1.a)/abs(t1.d))+11)/abs(e))-b) from t1 where t1.b not between f and t1.c and t1.f<>e),c) between t1.e and f then t1.e when  -f> - -b then c else t1.c end) from t1 where not 11 in (select f from t1 union select a from t1)),t1.d)-t1.a-13 from t1 where t1.d between  -t1.e and t1.a),f) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where c in (select (abs(f)/abs(13)) from t1 union select t1.a+b from t1)))}\n} {}\ndo_test randexpr-2.267 {\n  db eval {SELECT coalesce((select 17+coalesce((select max(case when  -coalesce((select max((abs( -(abs(t1.a)/abs(t1.d))+11)/abs(e))-b) from t1 where t1.b not between f and t1.c and t1.f<>e),c) between t1.e and f then t1.e when  -f> - -b then c else t1.c end) from t1 where not 11 in (select f from t1 union select a from t1)),t1.d)-t1.a-13 from t1 where t1.d between  -t1.e and t1.a),f) FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where c in (select (abs(f)/abs(13)) from t1 union select t1.a+b from t1))))}\n} {600}\ndo_test randexpr-2.268 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where t1.d in (select case (abs(((count(distinct t1.d-c))* -cast(avg(11) AS integer)+max(t1.c)))) when (cast(avg(t1.c+a) AS integer)*+min(a)*max(c)-max(t1.a)+cast(avg(f) AS integer))+cast(avg(t1.e) AS integer) then min(11) else (((min(11)))) end from t1 union select count(*) from t1))),coalesce((select max(b+13) from t1 where exists(select 1 from t1 where f in (select 11 from t1 union select t1.b from t1))),t1.e)) FROM t1 WHERE b>11}\n} {500}\ndo_test randexpr-2.269 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where exists(select 1 from t1 where t1.d in (select case (abs(((count(distinct t1.d-c))* -cast(avg(11) AS integer)+max(t1.c)))) when (cast(avg(t1.c+a) AS integer)*+min(a)*max(c)-max(t1.a)+cast(avg(f) AS integer))+cast(avg(t1.e) AS integer) then min(11) else (((min(11)))) end from t1 union select count(*) from t1))),coalesce((select max(b+13) from t1 where exists(select 1 from t1 where f in (select 11 from t1 union select t1.b from t1))),t1.e)) FROM t1 WHERE NOT (b>11)}\n} {}\ndo_test randexpr-2.270 {\n  db eval {SELECT coalesce((select max( -(select count(*)-case min(19)-abs(count(*))+(max( -b)-+count(distinct (t1.e))) when max(a) then (count(distinct 19)) else count(*) end from t1)) from t1 where exists(select 1 from t1 where a<(abs(case when a-t1.c+ -19+t1.d between 11 and f then t1.f else d end+t1.a+d)/abs(c))) or t1.c>t1.c),17)*f FROM t1 WHERE not f<>t1.b}\n} {}\ndo_test randexpr-2.271 {\n  db eval {SELECT coalesce((select max( -(select count(*)-case min(19)-abs(count(*))+(max( -b)-+count(distinct (t1.e))) when max(a) then (count(distinct 19)) else count(*) end from t1)) from t1 where exists(select 1 from t1 where a<(abs(case when a-t1.c+ -19+t1.d between 11 and f then t1.f else d end+t1.a+d)/abs(c))) or t1.c>t1.c),17)*f FROM t1 WHERE NOT (not f<>t1.b)}\n} {10200}\ndo_test randexpr-2.272 {\n  db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b | t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end |  -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19}\n} {500}\ndo_test randexpr-2.273 {\n  db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b | t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end |  -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE NOT (case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19)}\n} {}\ndo_test randexpr-2.274 {\n  db eval {SELECT case when coalesce((select f-coalesce((select +coalesce((select t1.c from t1 where (t1.c=(abs(t1.e)/abs(+t1.c+f+(f))))),13+17)+t1.b & t1.c from t1 where case when t1.a not in (d,17,t1.c) then f else f end &  -13 in (select cast(avg(t1.e) AS integer) from t1 union select min(t1.a) from t1)),c) from t1 where 17>c), -t1.b)>t1.c then 17 when t1.b<>11 then e else t1.f end FROM t1 WHERE case when t1.f in (t1.a+(abs(17)/abs((t1.d))),coalesce((select max(c) from t1 where (not (d- -case f when 17 then d else (17) end+e*t1.d) not in ((t1.d),t1.f,f))),coalesce((select c from t1 where 13 not in (19,d,b)),f)),17) then t1.b when e<=f then 17 else c end<d or t1.d> -19}\n} {500}\ndo_test randexpr-2.275 {\n  db eval {SELECT case when d*t1.c*a<>t1.b*~t1.b*t1.f-b then e else 17 end*t1.e+case when a not between t1.a and t1.d or (select  - -cast(avg(c) AS integer) from t1)<>17+c then case 11 when t1.f then  -t1.b else t1.b end when 13 not in (c,t1.f,19) or not exists(select 1 from t1 where 13=t1.d or t1.e<>a) then (17) else  -t1.f end FROM t1 WHERE (not (case e when e then +case when e>=a and 13<>e*t1.e or t1.d<>11 then t1.c else t1.b end else 17 end) in (select cast(avg( -t1.c) AS integer) from t1 union select case min(13) when  -+count(distinct 13) then case (+(cast(avg(e) AS integer))+((cast(avg(13) AS integer)))* - -count(distinct c)*count(*)) | count(*) when min(t1.c) then (min(11)) else max(f) end else cast(avg(17) AS integer) end from t1))}\n} {250200}\ndo_test randexpr-2.276 {\n  db eval {SELECT case when d*t1.c*a<>t1.b*~t1.b*t1.f-b then e else 17 end*t1.e+case when a not between t1.a and t1.d or (select  - -cast(avg(c) AS integer) from t1)<>17+c then case 11 when t1.f then  -t1.b else t1.b end when 13 not in (c,t1.f,19) or not exists(select 1 from t1 where 13=t1.d or t1.e<>a) then (17) else  -t1.f end FROM t1 WHERE NOT ((not (case e when e then +case when e>=a and 13<>e*t1.e or t1.d<>11 then t1.c else t1.b end else 17 end) in (select cast(avg( -t1.c) AS integer) from t1 union select case min(13) when  -+count(distinct 13) then case (+(cast(avg(e) AS integer))+((cast(avg(13) AS integer)))* - -count(distinct c)*count(*)) | count(*) when min(t1.c) then (min(11)) else max(f) end else cast(avg(17) AS integer) end from t1)))}\n} {}\ndo_test randexpr-2.277 {\n  db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) | case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE e not between (select min(t1.a) from t1) and d+t1.d}\n} {}\ndo_test randexpr-2.278 {\n  db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) | case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE NOT (e not between (select min(t1.a) from t1) and d+t1.d)}\n} {495}\ndo_test randexpr-2.279 {\n  db eval {SELECT (select max(t1.a)*abs(count(distinct f-t1.a-(abs(t1.a)/abs(case e when case t1.f when e*(b)-19 then 11 else t1.d end then t1.f else 11 end)))) & case +~cast(avg(t1.a) AS integer)-+abs(count(distinct 17)) when case count(distinct t1.b)*cast(avg(t1.a) AS integer)+count(distinct t1.c) when count(*) then min(t1.f) else count(distinct e) end then max((t1.e)) else max(d) end-count(*) from t1) FROM t1 WHERE NOT (e not between (select min(t1.a) from t1) and d+t1.d)}\n} {4}\ndo_test randexpr-2.280 {\n  db eval {SELECT e*c-t1.e*t1.c++(select abs(case abs(max(coalesce((select f from t1 where (b*coalesce((select max(b) from t1 where 17>f),t1.e) not between c and f or t1.a>d and t1.a<11 or a<> -f)),(t1.a)))) when  -+count(distinct e) then  -+(count(distinct 19))+min(t1.c) else  -min(t1.f) end) from t1)+t1.b-19 FROM t1 WHERE d-coalesce((select max(t1.d*c+c) from t1 where t1.f between (select count(distinct t1.b-e)+abs(~case case ~cast(avg(t1.f) AS integer)-count(distinct t1.a) when count(*) then count(distinct e) else count(*) end when min(e) then min( -t1.c) else max(a) end) from t1)+17 and  -case when d>=d-11 then t1.c else t1.a end),t1.a)*t1.a not in (t1.f,t1.f,d)}\n} {781}\ndo_test randexpr-2.281 {\n  db eval {SELECT e*c-t1.e*t1.c++(select abs(case abs(max(coalesce((select f from t1 where (b*coalesce((select max(b) from t1 where 17>f),t1.e) not between c and f or t1.a>d and t1.a<11 or a<> -f)),(t1.a)))) when  -+count(distinct e) then  -+(count(distinct 19))+min(t1.c) else  -min(t1.f) end) from t1)+t1.b-19 FROM t1 WHERE NOT (d-coalesce((select max(t1.d*c+c) from t1 where t1.f between (select count(distinct t1.b-e)+abs(~case case ~cast(avg(t1.f) AS integer)-count(distinct t1.a) when count(*) then count(distinct e) else count(*) end when min(e) then min( -t1.c) else max(a) end) from t1)+17 and  -case when d>=d-11 then t1.c else t1.a end),t1.a)*t1.a not in (t1.f,t1.f,d))}\n} {}\ndo_test randexpr-2.282 {\n  db eval {SELECT coalesce((select a from t1 where (exists(select 1 from t1 where 11-case when ((select count(distinct t1.e+d) from t1))<>t1.d*f then  -13 when t1.b in (select abs(cast(avg(c) AS integer)) from t1 union select count(distinct e)*count(distinct c)-cast(avg(e) AS integer) from t1) or c in (select t1.d from t1 union select 17 from t1) then a else t1.b end>=t1.c) and f>=d and d>=t1.f)),case when 11=19 and t1.a between t1.d and e then t1.d-b else t1.b end) FROM t1 WHERE 19 not in ( -t1.f,+19,t1.b)}\n} {}\ndo_test randexpr-2.283 {\n  db eval {SELECT coalesce((select a from t1 where (exists(select 1 from t1 where 11-case when ((select count(distinct t1.e+d) from t1))<>t1.d*f then  -13 when t1.b in (select abs(cast(avg(c) AS integer)) from t1 union select count(distinct e)*count(distinct c)-cast(avg(e) AS integer) from t1) or c in (select t1.d from t1 union select 17 from t1) then a else t1.b end>=t1.c) and f>=d and d>=t1.f)),case when 11=19 and t1.a between t1.d and e then t1.d-b else t1.b end) FROM t1 WHERE NOT (19 not in ( -t1.f,+19,t1.b))}\n} {200}\ndo_test randexpr-2.284 {\n  db eval {SELECT (~case when t1.f>(abs(t1.c)/abs(13-coalesce((select max(t1.a) from t1 where case when e not in (c,t1.a,~11) then 19+( -c) else a end in (select (19) from t1 union select t1.c from t1)),t1.b)+a)) and e>d and (t1.a)=e then t1.e when (not exists(select 1 from t1 where  -t1.d=e) and  -d in (select d from t1 union select e from t1)) then t1.b else a end) FROM t1 WHERE (t1.f in (select coalesce((select max(coalesce((select c from t1 where coalesce((select max(coalesce((select max(++13*t1.d) from t1 where case when case when e<>13 or b<= -t1.a then t1.c when t1.a not in ( - -13,t1.a,13) then a else c end not in ( -e,d,(11)) or t1.d<t1.a then t1.b when t1.a<> -b then t1.e else t1.d end<a),t1.d)) from t1 where e<>t1.b),c) not in (t1.e,c,b)),13)) from t1 where ((t1.f) in (select max(a) from t1 union select abs(abs(min(13))) from t1))),11) from t1 union select b from t1))}\n} {}\ndo_test randexpr-2.285 {\n  db eval {SELECT (~case when t1.f>(abs(t1.c)/abs(13-coalesce((select max(t1.a) from t1 where case when e not in (c,t1.a,~11) then 19+( -c) else a end in (select (19) from t1 union select t1.c from t1)),t1.b)+a)) and e>d and (t1.a)=e then t1.e when (not exists(select 1 from t1 where  -t1.d=e) and  -d in (select d from t1 union select e from t1)) then t1.b else a end) FROM t1 WHERE NOT ((t1.f in (select coalesce((select max(coalesce((select c from t1 where coalesce((select max(coalesce((select max(++13*t1.d) from t1 where case when case when e<>13 or b<= -t1.a then t1.c when t1.a not in ( - -13,t1.a,13) then a else c end not in ( -e,d,(11)) or t1.d<t1.a then t1.b when t1.a<> -b then t1.e else t1.d end<a),t1.d)) from t1 where e<>t1.b),c) not in (t1.e,c,b)),13)) from t1 where ((t1.f) in (select max(a) from t1 union select abs(abs(min(13))) from t1))),11) from t1 union select b from t1)))}\n} {-101}\ndo_test randexpr-2.286 {\n  db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end | a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else  -t1.a end* -t1.d) from t1)* -17>13}\n} {1}\ndo_test randexpr-2.287 {\n  db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end | a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE NOT (not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else  -t1.a end* -t1.d) from t1)* -17>13)}\n} {}\ndo_test randexpr-2.288 {\n  db eval {SELECT (select count(distinct case b when 13 then (select (+(cast(avg(+(d)*case t1.f-c*(abs(case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (d<=t1.e) or d between c and t1.b)) then 11 else 19 end in ((t1.d),t1.a,t1.f) then t1.f when c<=t1.e then t1.c else b end & a)/abs(c))+t1.b when t1.c then a else d end) AS integer))) from t1) else t1.b*(e) end) from t1) FROM t1 WHERE not t1.a+t1.b | t1.f-11*(select max(+case when case ~e-(abs(d*t1.d+t1.d)/abs( -f)) when t1.a then t1.e else t1.c end in (select cast(avg((f)) AS integer) from t1 union select +~(min(t1.d)) from t1) then (t1.d) when not exists(select 1 from t1 where a not in (17,a,d)) then 19 else  -t1.a end* -t1.d) from t1)* -17>13}\n} {1}\ndo_test randexpr-2.289 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then  -min(a) | min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b |  -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else  -t1.a end- - -t1.e*17-t1.d-t1.d}\n} {}\ndo_test randexpr-2.290 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then  -min(a) | min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE NOT (t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b |  -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else  -t1.a end- - -t1.e*17-t1.d-t1.d)}\n} {13}\ndo_test randexpr-2.291 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where ((~t1.f) between b and (abs(e)/abs(f)))),13+(select case abs((+count(*)*max(19))) when (~min(b)) then  -min(a) & min( -a) else (max(t1.c)) end from t1)+17*f+11)) from t1 where not 19<=coalesce((select e from t1 where t1.d-d not between 19 and 19),11)),13) FROM t1 WHERE NOT (t1.f+t1.d=t1.f+17-case when (abs(t1.a*(case when not exists(select 1 from t1 where not exists(select 1 from t1 where (b) between d and t1.f)) then (t1.b |  -(t1.c)) | 19 when d=t1.a then 13 else d end)+ -t1.d)/abs(d)) not in (d,e,t1.d) then t1.f when 19 in (select t1.f from t1 union select t1.e from t1) then e else  -t1.a end- - -t1.e*17-t1.d-t1.d)}\n} {13}\ndo_test randexpr-2.292 {\n  db eval {SELECT case when  -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) | abs(count(distinct t1.d))+count(*) | count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1)}\n} {189}\ndo_test randexpr-2.293 {\n  db eval {SELECT case when  -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) | abs(count(distinct t1.d))+count(*) | count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE NOT (case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1))}\n} {}\ndo_test randexpr-2.294 {\n  db eval {SELECT case when  -t1.b=c and ((t1.c>t1.b)) and not exists(select 1 from t1 where (abs((select max(t1.d) from t1))/abs((abs(c+t1.b)/abs(t1.d))-t1.e))+c in (select cast(avg((t1.a)) AS integer) & abs(count(distinct t1.d))+count(*) & count(*)+count(*) from t1 union select (min(t1.d)) from t1)) then (abs(t1.b)/abs(t1.f)) when t1.b not in (a,t1.f,(a)) then t1.b else t1.d end-11 FROM t1 WHERE case when ~e in (coalesce((select 13 from t1 where 17 between t1.a and b or not exists(select 1 from t1 where (c in (11,e,a)))),t1.e),c,e) then e else t1.f end in (select ++abs(case case count(*) when (max(t1.d)) then cast(avg(t1.c) AS integer) else count(distinct b) end | count(*) when max(e) then min(c) else max(13) end | count(*)*count(*)) | max(t1.a) from t1 union select count(distinct t1.c) from t1) or b in (select cast(avg(t1.b) AS integer) from t1 union select cast(avg( -t1.a) AS integer) from t1)}\n} {189}\ndo_test randexpr-2.295 {\n  db eval {SELECT case when (((abs(11 | e)/abs(17-d))+t1.b | a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between  - -d and e),t1.b) end FROM t1 WHERE t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f)}\n} {}\ndo_test randexpr-2.296 {\n  db eval {SELECT case when (((abs(11 | e)/abs(17-d))+t1.b | a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between  - -d and e),t1.b) end FROM t1 WHERE NOT (t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f))}\n} {17}\ndo_test randexpr-2.297 {\n  db eval {SELECT case when (((abs(11 & e)/abs(17-d))+t1.b & a<>11)) and t1.d in (13,t1.c,11) or 17 between t1.f and b or not f in (select 19 from t1 union select t1.e from t1) and b<>19 or e between 19 and t1.d or b<=d or d<17 or t1.a<>t1.f then 17 when t1.e=t1.b then 11 else coalesce((select t1.e from t1 where (b) between  - -d and e),t1.b) end FROM t1 WHERE NOT (t1.a between d and +17-17*coalesce((select ~ -19-13-19 from t1 where 19>(select abs(count(distinct t1.d-17))+count(distinct case when 19>17 then t1.f else t1.e end+b) | max(t1.b)+count(distinct 13) from t1)-coalesce((select 13 from t1 where t1.e not in (19,17,e) and 11<=t1.d),c)),t1.f))}\n} {17}\ndo_test randexpr-2.298 {\n  db eval {SELECT case when 19=13 or 13+a | 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE (13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when  -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select  -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d)}\n} {400}\ndo_test randexpr-2.299 {\n  db eval {SELECT case when 19=13 or 13+a | 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE NOT ((13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when  -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select  -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d))}\n} {}\ndo_test randexpr-2.300 {\n  db eval {SELECT case when 19=13 or 13+a & 19*11+b<>b and ((19<=b+(select count(*) from t1))) then t1.d when t1.e<= -19 then d-t1.e+(select ~max(19)*+(count(distinct b)) from t1)+t1.d*t1.d+f else t1.c end FROM t1 WHERE (13*case when 19*case when 19 not between 17 and t1.e then t1.e when ((case when case case when e<>11 or t1.b not in (t1.a, -c,17) then b else a end when  -e then b else a end*a in (select 19 from t1 union select 13 from t1) then e else t1.c end in (select  -abs(+count(*)) from t1 union select count(distinct f) from t1))) then 19 else d end>=f then t1.a when t1.e>=b then a else c end>=t1.d)}\n} {400}\ndo_test randexpr-2.301 {\n  db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) | t1.e FROM t1 WHERE not (11>(+b))}\n} {500}\ndo_test randexpr-2.302 {\n  db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) | t1.e FROM t1 WHERE NOT (not (11>(+b)))}\n} {}\ndo_test randexpr-2.303 {\n  db eval {SELECT +coalesce((select t1.d from t1 where coalesce((select t1.c+t1.b-case (19) when t1.c then 13+13+17 else t1.e end from t1 where (not exists(select 1 from t1 where t1.f<13)) and d not in (t1.e,11,19) and not 19>=t1.f or e in (select min(t1.c) from t1 union select cast(avg(t1.c) AS integer) from t1)), -a)-b*(13)<t1.b),(t1.c)) & t1.e FROM t1 WHERE not (11>(+b))}\n} {400}\ndo_test randexpr-2.304 {\n  db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end | ((abs(b*(abs(t1.e | +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f}\n} {}\ndo_test randexpr-2.305 {\n  db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end | ((abs(b*(abs(t1.e | +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE NOT (case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f)}\n} {124}\ndo_test randexpr-2.306 {\n  db eval {SELECT case when (((t1.c)<=a-11*t1.e)) then t1.b else a end & ((abs(b*(abs(t1.e & +c)/abs(11)))/abs(t1.a))) FROM t1 WHERE NOT (case when t1.e in (select t1.a-e from t1 union select t1.e from t1) then 19*coalesce((select a*t1.c-19+f+t1.d-case case when 11>=d then f when not f<>17 then t1.d else t1.f end+t1.e-t1.c when d then b else t1.f end from t1 where t1.f>a), -t1.a)- -(t1.c)-t1.e+b else 11 end<t1.f)}\n} {36}\ndo_test randexpr-2.307 {\n  db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) | count(*) then  -count(distinct b) else  - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE not exists(select 1 from t1 where (case  -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else  -t1.c end<=(11)))}\n} {}\ndo_test randexpr-2.308 {\n  db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) | count(*) then  -count(distinct b) else  - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE NOT (not exists(select 1 from t1 where (case  -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else  -t1.c end<=(11))))}\n} {6800}\ndo_test randexpr-2.309 {\n  db eval {SELECT 17*case when case t1.e when 13-c+f then d else (select + -case cast(avg(b) AS integer)*count(*) when (count(distinct 17)+case abs((count(distinct t1.e))) when count(*) then count(*) else count(distinct c) end) & count(*) then  -count(distinct b) else  - -min(e) end*min(f)-min(t1.e) from t1) end-(select (count(*)) from t1) in (select 19 from t1 union select t1.a-(select count(distinct t1.c) from t1) from t1) then a-13 else t1.d end FROM t1 WHERE NOT (not exists(select 1 from t1 where (case  -17 when c then (abs(t1.d)/abs(c-(abs(case when t1.e in (17,t1.a,(abs(e)/abs(t1.d))) then +d-17*t1.b when (select +cast(avg(t1.a*t1.e+e-19) AS integer) from t1) in (select (abs(b)/abs(f)) from t1 union select (19) from t1) then b else t1.f end)/abs(e))*e))+(c) else  -t1.c end<=(11))))}\n} {6800}\ndo_test randexpr-2.310 {\n  db eval {SELECT t1.f+coalesce((select t1.b-13-(coalesce((select 17 from t1 where b>a),13)*11)-t1.c from t1 where 11 between t1.a and  -13+t1.f*~coalesce((select max(b-f) from t1 where t1.a<=13 or a not in (13,f,17)),b) or (t1.d<19 or b> -t1.c)),b) FROM t1 WHERE 11 not between d and coalesce((select  -(select (cast(avg(d) AS integer)) from t1) from t1 where case when 17<t1.a then t1.b else coalesce((select max(f) from t1 where t1.d-+case when (d<=t1.f) and t1.e not in (17,t1.d,t1.a) and 11 in (13,t1.e, -t1.a) and t1.c<13 then  -b else case when a>13 then e when 19 between t1.a and t1.b then b else b end end*13<=c),t1.c) end in (select t1.e from t1 union select d from t1)),t1.b)}\n} {300}\ndo_test randexpr-2.311 {\n  db eval {SELECT t1.f+coalesce((select t1.b-13-(coalesce((select 17 from t1 where b>a),13)*11)-t1.c from t1 where 11 between t1.a and  -13+t1.f*~coalesce((select max(b-f) from t1 where t1.a<=13 or a not in (13,f,17)),b) or (t1.d<19 or b> -t1.c)),b) FROM t1 WHERE NOT (11 not between d and coalesce((select  -(select (cast(avg(d) AS integer)) from t1) from t1 where case when 17<t1.a then t1.b else coalesce((select max(f) from t1 where t1.d-+case when (d<=t1.f) and t1.e not in (17,t1.d,t1.a) and 11 in (13,t1.e, -t1.a) and t1.c<13 then  -b else case when a>13 then e when 19 between t1.a and t1.b then b else b end end*13<=c),t1.c) end in (select t1.e from t1 union select d from t1)),t1.b))}\n} {}\ndo_test randexpr-2.312 {\n  db eval {SELECT (abs(13)/abs((select min(case when case when exists(select 1 from t1 where not exists(select 1 from t1 where (select count(distinct (t1.e)) from t1)+t1.f>t1.e) and t1.a>=13 or f in (select t1.e from t1 union select t1.e from t1)) then b when f not in (13,13,13) then coalesce((select max(d*f) from t1 where t1.e in (t1.d,t1.e,(e))),t1.e) else a end>=t1.f then b when t1.c in (e,f,t1.e) then b else t1.c end)*abs(count(*))-abs(~count(*)-min(e))-cast(avg(17) AS integer) from t1))) FROM t1 WHERE t1.b not in (a*17-17-case when  -17-t1.f in (select coalesce((select t1.a from t1 where (d)=t1.a),d) from t1 union select 19 from t1) or 13 not between 17 and 13 and (19 between (t1.e) and t1.f) or ( -t1.e)>=17 then b when t1.d not in (19,f,t1.f) then a else case when t1.a=t1.d then e when 17 in (t1.e,t1.b,t1.d) then t1.a else a end end,e,11)}\n} {0}\ndo_test randexpr-2.313 {\n  db eval {SELECT (abs(13)/abs((select min(case when case when exists(select 1 from t1 where not exists(select 1 from t1 where (select count(distinct (t1.e)) from t1)+t1.f>t1.e) and t1.a>=13 or f in (select t1.e from t1 union select t1.e from t1)) then b when f not in (13,13,13) then coalesce((select max(d*f) from t1 where t1.e in (t1.d,t1.e,(e))),t1.e) else a end>=t1.f then b when t1.c in (e,f,t1.e) then b else t1.c end)*abs(count(*))-abs(~count(*)-min(e))-cast(avg(17) AS integer) from t1))) FROM t1 WHERE NOT (t1.b not in (a*17-17-case when  -17-t1.f in (select coalesce((select t1.a from t1 where (d)=t1.a),d) from t1 union select 19 from t1) or 13 not between 17 and 13 and (19 between (t1.e) and t1.f) or ( -t1.e)>=17 then b when t1.d not in (19,f,t1.f) then a else case when t1.a=t1.d then e when 17 in (t1.e,t1.b,t1.d) then t1.a else a end end,e,11))}\n} {}\ndo_test randexpr-2.314 {\n  db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 | b)/abs(f))-t1.e FROM t1 WHERE not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else  -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11)}\n} {}\ndo_test randexpr-2.315 {\n  db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 | b)/abs(f))-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else  -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11))}\n} {-500}\ndo_test randexpr-2.316 {\n  db eval {SELECT (abs(case coalesce((select t1.d* -case when d in (select cast(avg(13) AS integer)*abs(((cast(avg(d) AS integer)))+ -count(distinct c))-max(t1.c) from t1 union select min(e) from t1) then (abs(19)/abs(case when b not in (19,d,13) or t1.b not in (b,17,17) then e else b end)) else 19 end from t1 where a>=t1.c and 17 not in (t1.c,17,t1.f)),13)*t1.f when e then (11) else 17 end+19 & b)/abs(f))-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where case a when coalesce((select max(case 19 when 17 then b-d else t1.e end) from t1 where ( -coalesce((select max(t1.a) from t1 where e between t1.b and (abs(e)/abs(17))),(abs(case when case when 13 between e and (t1.b) and 11 not in (t1.f,t1.e,c) then (t1.d) else  -c end< -e then 11 when 13>t1.b then 11 else t1.a end*13)/abs((f)))-t1.a) not in (e,(b),t1.c))),19) then t1.b else 13 end not between t1.b and 11))}\n} {-500}\ndo_test randexpr-2.317 {\n  db eval {SELECT  -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case  -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then  -t1.b else 19 end | d*e) FROM t1 WHERE ~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select  -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else  -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1)}\n} {}\ndo_test randexpr-2.318 {\n  db eval {SELECT  -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case  -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then  -t1.b else 19 end | d*e) FROM t1 WHERE NOT (~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select  -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else  -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1))}\n} {136}\ndo_test randexpr-2.319 {\n  db eval {SELECT  -(+case when ~t1.d-f-case coalesce((select max((select (min((abs(t1.f)/abs(t1.b))-17)) from t1)) from t1 where e<=17),f) when t1.f then (select case  -( -count(distinct b)) when cast(avg( -13) AS integer) then cast(avg(13) AS integer) else max(19) end from t1)-t1.e else 13 end*b between t1.c and t1.d then t1.d when e<t1.f then  -t1.b else 19 end & d*e) FROM t1 WHERE NOT (~t1.d*~( -coalesce((select max(t1.d | t1.a) from t1 where d-(select  -( - -count(distinct 13)) | min((t1.f))+min(t1.c) from t1) not between case t1.a when t1.b then e else  -c end and c or t1.a not in (a,19,c)),d)) in (select +(max(t1.b))*max((13))++(count(distinct t1.a))+count(*)-count(distinct f) | cast(avg(t1.d) AS integer) from t1 union select cast(avg(13) AS integer) from t1))}\n} {-199936}\ndo_test randexpr-2.320 {\n  db eval {SELECT ~d-coalesce((select +e from t1 where b not between b and ~d++ -t1.b),f)-f-+19-t1.a+case when d<=(abs(19)/abs(+coalesce((select 11 from t1 where not exists(select 1 from t1 where not coalesce((select t1.d from t1 where not t1.a<=t1.c),11) in (select 19 from t1 union select t1.a from t1) or t1.c<=t1.c and a<t1.b)),17-t1.e))) then f else t1.a end*c FROM t1 WHERE (select count(*) from t1)*e-17 | f not between 11 and t1.d or t1.c* -b in (select (abs(case when not 19<( -(t1.e-c*t1.b)+(d)-c) then t1.f-t1.b when t1.f<=11 or exists(select 1 from t1 where t1.e in (13,t1.f,t1.d)) then t1.f else 19 end)/abs(e)) from t1 union select 17 from t1)}\n} {28380}\ndo_test randexpr-2.321 {\n  db eval {SELECT ~d-coalesce((select +e from t1 where b not between b and ~d++ -t1.b),f)-f-+19-t1.a+case when d<=(abs(19)/abs(+coalesce((select 11 from t1 where not exists(select 1 from t1 where not coalesce((select t1.d from t1 where not t1.a<=t1.c),11) in (select 19 from t1 union select t1.a from t1) or t1.c<=t1.c and a<t1.b)),17-t1.e))) then f else t1.a end*c FROM t1 WHERE NOT ((select count(*) from t1)*e-17 | f not between 11 and t1.d or t1.c* -b in (select (abs(case when not 19<( -(t1.e-c*t1.b)+(d)-c) then t1.f-t1.b when t1.f<=11 or exists(select 1 from t1 where t1.e in (13,t1.f,t1.d)) then t1.f else 19 end)/abs(e)) from t1 union select 17 from t1))}\n} {}\ndo_test randexpr-2.322 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) | (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select  -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct  -t1.a) from t1) or +17 in (select  -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then  -t1.f else t1.f end)))/abs(c+a)) and d)}\n} {17}\ndo_test randexpr-2.323 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) | (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select  -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct  -t1.a) from t1) or +17 in (select  -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then  -t1.f else t1.f end)))/abs(c+a)) and d))}\n} {}\ndo_test randexpr-2.324 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where 11 in (select count(distinct d-coalesce((select t1.c-t1.f from t1 where 13 in (19,e,t1.b) and e in (select ( -count(*)) from t1 union select max(e) from t1) or t1.a>t1.f),d)*t1.e)+max(t1.f)+cast(avg(e) AS integer) & (abs((count(distinct 17)))) from t1 union select max(t1.b) from t1) or 17 in (select  -t1.b from t1 union select t1.a from t1) and exists(select 1 from t1 where t1.e=t1.c))),f+(t1.e)) FROM t1 WHERE exists(select 1 from t1 where +t1.d between (abs((abs(t1.c)/abs(case when not exists(select 1 from t1 where d*~(select abs(min(13))-( -(max(t1.f))*( -(count(distinct a)))-max(17)*min(t1.a) | (cast(avg(t1.b) AS integer))) from t1)>case when a in (select max(c) from t1 union select count(distinct  -t1.a) from t1) or +17 in (select  -count(distinct t1.f) from t1 union select cast(avg(t1.f) AS integer) from t1) then c else t1.a end) then  -t1.f else t1.f end)))/abs(c+a)) and d)}\n} {17}\ndo_test randexpr-2.325 {\n  db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) | +cast(avg(++t1.e+t1.d) AS integer) | ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when  -17=c then t1.e else t1.c end FROM t1 WHERE t1.b in (f,b,a)}\n} {7100}\ndo_test randexpr-2.326 {\n  db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) | +cast(avg(++t1.e+t1.d) AS integer) | ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when  -17=c then t1.e else t1.c end FROM t1 WHERE NOT (t1.b in (f,b,a))}\n} {}\ndo_test randexpr-2.327 {\n  db eval {SELECT t1.d*17- -case when case (b) when t1.c then (abs(t1.f)/abs((select + -~abs(min(f) & +cast(avg(++t1.e+t1.d) AS integer) & ((count(distinct t1.a)-count(*)))) from t1))) else c*case t1.b when t1.d then (t1.c) else t1.c end*(b)-c end=t1.d then t1.c when  -17=c then t1.e else t1.c end FROM t1 WHERE t1.b in (f,b,a)}\n} {7100}\ndo_test randexpr-2.328 {\n  db eval {SELECT coalesce((select e-t1.d-+b*coalesce((select 11 from t1 where (t1.a<=coalesce((select  - -coalesce((select max(case case 19 when t1.d then t1.e else t1.a end when b then 13 else t1.e end) from t1 where (c)>=(b)),t1.c)+t1.b from t1 where t1.e>e and exists(select 1 from t1 where b in (t1.b,e,t1.c) or e not between a and d) and 13<b),a))),t1.e) from t1 where t1.a<t1.a),t1.e) FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(coalesce((select case case coalesce((select d from t1 where b in (17,t1.a,13)),11) when (coalesce((select 11 from t1 where a++t1.d>(coalesce((select (f)+t1.c from t1 where a>t1.c),b))),t1.e)) then 19 else e end when t1.d then t1.e else b end from t1 where t1.b>=f),13)-b*17) from t1 where 11<>e),t1.b)<(c))}\n} {500}\ndo_test randexpr-2.329 {\n  db eval {SELECT coalesce((select e-t1.d-+b*coalesce((select 11 from t1 where (t1.a<=coalesce((select  - -coalesce((select max(case case 19 when t1.d then t1.e else t1.a end when b then 13 else t1.e end) from t1 where (c)>=(b)),t1.c)+t1.b from t1 where t1.e>e and exists(select 1 from t1 where b in (t1.b,e,t1.c) or e not between a and d) and 13<b),a))),t1.e) from t1 where t1.a<t1.a),t1.e) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(coalesce((select case case coalesce((select d from t1 where b in (17,t1.a,13)),11) when (coalesce((select 11 from t1 where a++t1.d>(coalesce((select (f)+t1.c from t1 where a>t1.c),b))),t1.e)) then 19 else e end when t1.d then t1.e else b end from t1 where t1.b>=f),13)-b*17) from t1 where 11<>e),t1.b)<(c)))}\n} {}\ndo_test randexpr-2.330 {\n  db eval {SELECT (abs(case when ++e not in (~c-(19)*+case t1.c when t1.d-coalesce((select max(t1.f) from t1 where (select count(*) from t1)>case when exists(select 1 from t1 where not exists(select 1 from t1 where (not not exists(select 1 from t1 where 19<t1.c)))) then ~t1.d else case coalesce((select 17 from t1 where  -t1.b<>e),t1.e) when 13 then b else t1.c end end+f),c)*t1.c then t1.e else t1.b end,11,b) then  -(t1.b) else a end)/abs(13)) FROM t1 WHERE a*t1.a<=17 and exists(select 1 from t1 where (+case coalesce((select max(f) from t1 where d in (select ((+count(*)-( -max(b))))*min(t1.c)* -max(11) from t1 union select count(distinct (19)) from t1)),t1.c) when 13 then 19 else coalesce((select t1.a from t1 where t1.c not in (t1.c,f,13)),b) end)>t1.c) and ( -( -19) between 13 and b or b in (select 11 from t1 union select a from t1) and 19 in (t1.d,t1.d,19))}\n} {}\ndo_test randexpr-2.331 {\n  db eval {SELECT (abs(case when ++e not in (~c-(19)*+case t1.c when t1.d-coalesce((select max(t1.f) from t1 where (select count(*) from t1)>case when exists(select 1 from t1 where not exists(select 1 from t1 where (not not exists(select 1 from t1 where 19<t1.c)))) then ~t1.d else case coalesce((select 17 from t1 where  -t1.b<>e),t1.e) when 13 then b else t1.c end end+f),c)*t1.c then t1.e else t1.b end,11,b) then  -(t1.b) else a end)/abs(13)) FROM t1 WHERE NOT (a*t1.a<=17 and exists(select 1 from t1 where (+case coalesce((select max(f) from t1 where d in (select ((+count(*)-( -max(b))))*min(t1.c)* -max(11) from t1 union select count(distinct (19)) from t1)),t1.c) when 13 then 19 else coalesce((select t1.a from t1 where t1.c not in (t1.c,f,13)),b) end)>t1.c) and ( -( -19) between 13 and b or b in (select 11 from t1 union select a from t1) and 19 in (t1.d,t1.d,19)))}\n} {15}\ndo_test randexpr-2.332 {\n  db eval {SELECT case when a>=f then  -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when  -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end | 17 FROM t1 WHERE 11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d)}\n} {}\ndo_test randexpr-2.333 {\n  db eval {SELECT case when a>=f then  -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when  -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end | 17 FROM t1 WHERE NOT (11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d))}\n} {217}\ndo_test randexpr-2.334 {\n  db eval {SELECT case when a>=f then  -t1.a-11*t1.c when ((t1.e-t1.e+17 between (select max(c) from t1)-13 and coalesce((select t1.d from t1 where ((coalesce((select max(case when (not b>17) then t1.b-b when  -e in (c,a,13) then 11 else t1.a end) from t1 where 19<=11),t1.e)>=e))),t1.a))) then c else t1.b end & 17 FROM t1 WHERE NOT (11-t1.d+d-13+(t1.f*case when exists(select 1 from t1 where ( -coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where 19 in (select d from t1 union select t1.f from t1)))),t1.d)<=case when 13*11+11 in (select abs(+~abs( -min(c))) from t1 union select (min(t1.e)) from t1) then t1.f else 19 end)) then t1.c else (abs(e)/abs(19)) end*t1.f*f)<(t1.d))}\n} {0}\ndo_test randexpr-2.335 {\n  db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) | min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select  - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else  -b end FROM t1 WHERE case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1))}\n} {}\ndo_test randexpr-2.336 {\n  db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) | min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select  - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else  -b end FROM t1 WHERE NOT (case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1)))}\n} {-200}\ndo_test randexpr-2.337 {\n  db eval {SELECT case ~13*c-t1.f- -t1.f when coalesce((select max(coalesce((select max(t1.c) from t1 where coalesce((select t1.d from t1 where 11*f-a=a),t1.e) in (select case ~count(distinct 11) & min(c) when (count(*))-count(*) then max( -17) else (min(13)) end from t1 union select  - -cast(avg(b) AS integer) from t1)),19)-t1.c) from t1 where exists(select 1 from t1 where t1.b not between t1.e and 11 and ((a<>t1.f)) and (t1.a)=t1.d)),17) then t1.d else  -b end FROM t1 WHERE NOT (case when ~13+t1.e-19>=13 then 17 else t1.c end>=a*19 and (f in (select case min(t1.e*+(abs(11)/abs(13))) when count(distinct t1.c) | abs((min(t1.b)-(max(t1.d)))+abs(max(a))+count(*)) | cast(avg(e) AS integer) then max(c) else max(c) end from t1 union select min(t1.c) from t1)))}\n} {-200}\ndo_test randexpr-2.338 {\n  db eval {SELECT f*13-t1.f*(abs(19*t1.a*c-(select ~max(t1.c)- -( -cast(avg(f) AS integer))+(max(d))*cast(avg(t1.d) AS integer)*(count(*)) from t1))/abs(case when coalesce((select (coalesce((select max(t1.c) from t1 where  -(b)<> -t1.a),b)+11) from t1 where not (11)<=t1.e and c not between 17 and t1.e and b not in (f,(t1.a),t1.e)),t1.f) in (select t1.d from t1 union select 19 from t1) then t1.a when f>13 then t1.e else a end)) FROM t1 WHERE  -b<>b*t1.e}\n} {-484800}\ndo_test randexpr-2.339 {\n  db eval {SELECT f*13-t1.f*(abs(19*t1.a*c-(select ~max(t1.c)- -( -cast(avg(f) AS integer))+(max(d))*cast(avg(t1.d) AS integer)*(count(*)) from t1))/abs(case when coalesce((select (coalesce((select max(t1.c) from t1 where  -(b)<> -t1.a),b)+11) from t1 where not (11)<=t1.e and c not between 17 and t1.e and b not in (f,(t1.a),t1.e)),t1.f) in (select t1.d from t1 union select 19 from t1) then t1.a when f>13 then t1.e else a end)) FROM t1 WHERE NOT ( -b<>b*t1.e)}\n} {}\ndo_test randexpr-2.340 {\n  db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e | t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct  -a) | max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when  -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d))}\n} {}\ndo_test randexpr-2.341 {\n  db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e | t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct  -a) | max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when  -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d)))}\n} {19}\ndo_test randexpr-2.342 {\n  db eval {SELECT case when coalesce((select c from t1 where (13-(11-t1.e & t1.b) in (select +min(c)*+case +min(t1.e) when min(coalesce((select t1.e*t1.a from t1 where t1.f in (t1.d,11,t1.d) or t1.e>11 or t1.d>=c),17))+max(11)-count(distinct  -a) & max(11)+min(t1.c)-max(13) then count(distinct c) else (max(13)) end from t1 union select (( -cast(avg(11) AS integer))) from t1))),d) in (select f from t1 union select t1.a from t1) then 17 else 19 end FROM t1 WHERE NOT (not exists(select 1 from t1 where (select +min(case when not (f*e between (select min(~~t1.d) from t1)*(abs(c)/abs(d)) and case when f<t1.b then 19 else e end+t1.b) and not exists(select 1 from t1 where exists(select 1 from t1 where 11 in (select t1.e from t1 union select (a) from t1))) then case when  -c>=b then t1.f when not c>=17 then ~t1.b else 11 end else 19 end) from t1)-19 not in (d,t1.a,d)))}\n} {19}\ndo_test randexpr-2.343 {\n  db eval {SELECT t1.c*a+(case when t1.b+11 | case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17)))}\n} {30400}\ndo_test randexpr-2.344 {\n  db eval {SELECT t1.c*a+(case when t1.b+11 | case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17))))}\n} {}\ndo_test randexpr-2.345 {\n  db eval {SELECT t1.c*a+(case when t1.b+11 & case when exists(select 1 from t1 where b<>17 or not exists(select 1 from t1 where t1.f in (19,t1.f,c)) or (t1.d)<>b) then e else d end+t1.b+t1.a*b=t1.d or d=b then t1.e when not exists(select 1 from t1 where b>t1.c or 17 between t1.f and e and d>=t1.c) then t1.d else c end) FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where (abs(c)/abs(b)) in (t1.a, -e*~e*17,17)))}\n} {30400}\ndo_test randexpr-2.346 {\n  db eval {SELECT coalesce((select  -b from t1 where t1.f=d),case when case  -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and  -f and e not between d and a then 13 when c<=a then 13 else 19 | e end)*a-d*t1.e FROM t1 WHERE (abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select  -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a}\n} {}\ndo_test randexpr-2.347 {\n  db eval {SELECT coalesce((select  -b from t1 where t1.f=d),case when case  -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and  -f and e not between d and a then 13 when c<=a then 13 else 19 | e end)*a-d*t1.e FROM t1 WHERE NOT ((abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select  -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a)}\n} {-149700}\ndo_test randexpr-2.348 {\n  db eval {SELECT coalesce((select  -b from t1 where t1.f=d),case when case  -17-t1.b*t1.d+d when b then t1.a else t1.e end not in (t1.c,13,19) and e>f and 13 not between 17 and  -f and e not between d and a then 13 when c<=a then 13 else 19 & e end)*a-d*t1.e FROM t1 WHERE NOT ((abs(+t1.f)/abs(coalesce((select max(coalesce((select max(e) from t1 where t1.a in (select (abs( -t1.b)/abs(a)) from t1 union select e from t1)),(abs(case t1.f when c then (select (~cast(avg(b*d) AS integer))*abs(min(11)) from t1) else coalesce((select f from t1 where d in (select ( -min(e)) from t1 union select  -count(*) from t1)),t1.c) end*t1.b)/abs(c))+17)) from t1 where exists(select 1 from t1 where d not between t1.f and t1.b)),(t1.c))))*t1.d between t1.f and t1.a)}\n} {-198400}\ndo_test randexpr-2.349 {\n  db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) | t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 | a*f | t1.c-d from t1)),19) FROM t1 WHERE t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13}\n} {19}\ndo_test randexpr-2.350 {\n  db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) | t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 | a*f | t1.c-d from t1)),19) FROM t1 WHERE NOT (t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13)}\n} {}\ndo_test randexpr-2.351 {\n  db eval {SELECT coalesce((select t1.b*19 from t1 where ~f in (select 19 from t1 union select ~b-+case 13 when coalesce((select max(a) from t1 where (abs(d)/abs(t1.d)) & t1.e-c-t1.d-t1.c+11*f-c+t1.a>17), -a) then f else t1.d end+17 & a*f & t1.c-d from t1)),19) FROM t1 WHERE t1.e*t1.c>coalesce((select 13 from t1 where ~t1.a<>case when exists(select 1 from t1 where e<>~d and not +17 not between a+case 13 when d then case t1.d when t1.a then b else 13 end else 13 end and 13) or 13 not in (t1.e,t1.f,t1.c) then 19-e+19 when f<=t1.f then b else 11 end),e)-13}\n} {19}\ndo_test randexpr-2.352 {\n  db eval {SELECT (abs( -coalesce((select max((t1.f)) from t1 where not exists(select 1 from t1 where  -b-~b not between t1.c and f and t1.d*( -(select abs(+count(*)) from t1))-d>=a) and case when +case when ((f)) in (select  -count(distinct t1.a) from t1 union select count(*) from t1) then t1.b else d end in (select min(17) from t1 union select min(t1.e) from t1) then d else 17 end+c not between 11 and a),f)*11)/abs(a)) FROM t1 WHERE t1.f*t1.a*(+c)+case case when t1.d=f and (t1.a<>~+a*a*e*t1.e+case when t1.c between 11 and b and t1.a<>e then 13 when ( -t1.e)<>(t1.a) then (t1.b) else 13 end-t1.b-e+f) then t1.f+a else 17 end when d then 17 else d end-t1.e not in (13,t1.a,11)}\n} {66}\ndo_test randexpr-2.353 {\n  db eval {SELECT (abs( -coalesce((select max((t1.f)) from t1 where not exists(select 1 from t1 where  -b-~b not between t1.c and f and t1.d*( -(select abs(+count(*)) from t1))-d>=a) and case when +case when ((f)) in (select  -count(distinct t1.a) from t1 union select count(*) from t1) then t1.b else d end in (select min(17) from t1 union select min(t1.e) from t1) then d else 17 end+c not between 11 and a),f)*11)/abs(a)) FROM t1 WHERE NOT (t1.f*t1.a*(+c)+case case when t1.d=f and (t1.a<>~+a*a*e*t1.e+case when t1.c between 11 and b and t1.a<>e then 13 when ( -t1.e)<>(t1.a) then (t1.b) else 13 end-t1.b-e+f) then t1.f+a else 17 end when d then 17 else d end-t1.e not in (13,t1.a,11))}\n} {}\ndo_test randexpr-2.354 {\n  db eval {SELECT case t1.b- -t1.d+t1.d+t1.f when t1.f then 19+~13 else d end-case when not exists(select 1 from t1 where (f not between coalesce((select b from t1 where d in (17,13,t1.a) and 13 between c and 13 and 19>=f),13) and e or d not between 13 and f) or f>=d) then t1.f else coalesce((select max(~e-11) from t1 where t1.b in (f,13,13)),t1.a) end FROM t1 WHERE a<e}\n} {300}\ndo_test randexpr-2.355 {\n  db eval {SELECT case t1.b- -t1.d+t1.d+t1.f when t1.f then 19+~13 else d end-case when not exists(select 1 from t1 where (f not between coalesce((select b from t1 where d in (17,13,t1.a) and 13 between c and 13 and 19>=f),13) and e or d not between 13 and f) or f>=d) then t1.f else coalesce((select max(~e-11) from t1 where t1.b in (f,13,13)),t1.a) end FROM t1 WHERE NOT (a<e)}\n} {}\ndo_test randexpr-2.356 {\n  db eval {SELECT  -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select  -max(e) from t1)*t1.e<e and exists(select 1 from t1 where  -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end | e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select  - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else  -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11)}\n} {-13}\ndo_test randexpr-2.357 {\n  db eval {SELECT  -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select  -max(e) from t1)*t1.e<e and exists(select 1 from t1 where  -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end | e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE NOT (t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select  - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else  -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11))}\n} {}\ndo_test randexpr-2.358 {\n  db eval {SELECT  -coalesce((select max(13) from t1 where case case when f in (select e from t1 union select coalesce((select max(e) from t1 where (select  -max(e) from t1)*t1.e<e and exists(select 1 from t1 where  -c in (a,a,a))),t1.d) from t1) and e>=t1.c and exists(select 1 from t1 where t1.f>=13) then t1.d when d between t1.d and t1.a then 19 else a end & e when (a) then e else a end between b and t1.c and not exists(select 1 from t1 where 13 in (t1.d,t1.a,13)) or t1.a>= -13),c) FROM t1 WHERE t1.e not in ( -coalesce((select max(13) from t1 where exists(select 1 from t1 where not t1.d>a) and t1.a not in (d*+case when t1.b in (select max(e*11+t1.a)+ -count(*)-( -max(t1.e))-min(11)-count(distinct t1.a) from t1 union select  - -min(t1.b) from t1) then t1.e when e in (select count(distinct t1.a) from t1 union select (max(d)) from t1) then e else  -(19) end+ -t1.d, -17,f)),case c when a then f else 17 end),d,11)}\n} {-13}\ndo_test randexpr-2.359 {\n  db eval {SELECT case d when  -e+coalesce((select max(case (select +abs((~case case count(distinct b) when  -count(*) then count(*) else max(t1.e) end when max(e) then min(t1.c) else count(*) end-min(c))) from t1) when t1.c then t1.a else  -11 end) from t1 where case ~t1.b when e then d else 11 end in (b,t1.e,t1.b) or not t1.f>=b or (t1.f in (a,e,t1.e)) or f<b),t1.e) then t1.b else f end FROM t1 WHERE b<=(d) and (abs(coalesce((select max(coalesce((select case when (abs(~11)/abs(((abs(17+f+t1.f)/abs(t1.c))-11*c)-d*17)) not in (b,13,((e))) then 19 else 19 end from t1 where a in (select t1.b from t1 union select t1.b from t1)),13)) from t1 where t1.d in (select a from t1 union select 13 from t1)), -e)+17*c)/abs(t1.c))=13}\n} {}\ndo_test randexpr-2.360 {\n  db eval {SELECT case d when  -e+coalesce((select max(case (select +abs((~case case count(distinct b) when  -count(*) then count(*) else max(t1.e) end when max(e) then min(t1.c) else count(*) end-min(c))) from t1) when t1.c then t1.a else  -11 end) from t1 where case ~t1.b when e then d else 11 end in (b,t1.e,t1.b) or not t1.f>=b or (t1.f in (a,e,t1.e)) or f<b),t1.e) then t1.b else f end FROM t1 WHERE NOT (b<=(d) and (abs(coalesce((select max(coalesce((select case when (abs(~11)/abs(((abs(17+f+t1.f)/abs(t1.c))-11*c)-d*17)) not in (b,13,((e))) then 19 else 19 end from t1 where a in (select t1.b from t1 union select t1.b from t1)),13)) from t1 where t1.d in (select a from t1 union select 13 from t1)), -e)+17*c)/abs(t1.c))=13)}\n} {600}\ndo_test randexpr-2.361 {\n  db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and  -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end |  -t1.c*d end-13 FROM t1 WHERE e not in (e,t1.b,t1.d)}\n} {}\ndo_test randexpr-2.362 {\n  db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and  -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end |  -t1.c*d end-13 FROM t1 WHERE NOT (e not in (e,t1.b,t1.d))}\n} {-119864}\ndo_test randexpr-2.363 {\n  db eval {SELECT case a when ~c then e+17-d else case t1.a when c then t1.b else case when ((case t1.e when c then d-11 else t1.f end not in (e,(17),t1.d))) or not exists(select 1 from t1 where e not in (d,t1.f,11) and  -t1.a>t1.b) or t1.a not in (f,t1.b,t1.e) or t1.d<=t1.b and 19 not in (t1.d,11,t1.f) then t1.d else 19 end+e+17 end &  -t1.c*d end-13 FROM t1 WHERE NOT (e not in (e,t1.b,t1.d))}\n} {755}\ndo_test randexpr-2.364 {\n  db eval {SELECT coalesce((select max(case t1.a when d then ~11 else t1.e end) from t1 where (t1.f*17<t1.d-(t1.a*t1.a+t1.b+case case d when coalesce((select max(19) from t1 where  -(t1.e) in (select count(distinct c) from t1 union select (count(distinct t1.f)) from t1)),13) then c else 19 end*d when c then 13 else 17 end+t1.c)) and (f>=a or t1.e=t1.a and  -c>=t1.b)),t1.b) FROM t1 WHERE a+( -t1.c) between case when case a when t1.f then ~t1.b*t1.c+17 else  -case when f not in (e,f,17) then a when 11=13 then t1.c else t1.d end end>=t1.b then b when t1.d in (select +max(19) from t1 union select abs(cast(avg(t1.f) AS integer))+case ~count(*)-max(t1.a)+max(11) when (max(a)) then (max(t1.d)) else count(distinct 11) end from t1) and e in (t1.d,17,11) then (11) else b end and a}\n} {}\ndo_test randexpr-2.365 {\n  db eval {SELECT coalesce((select max(case t1.a when d then ~11 else t1.e end) from t1 where (t1.f*17<t1.d-(t1.a*t1.a+t1.b+case case d when coalesce((select max(19) from t1 where  -(t1.e) in (select count(distinct c) from t1 union select (count(distinct t1.f)) from t1)),13) then c else 19 end*d when c then 13 else 17 end+t1.c)) and (f>=a or t1.e=t1.a and  -c>=t1.b)),t1.b) FROM t1 WHERE NOT (a+( -t1.c) between case when case a when t1.f then ~t1.b*t1.c+17 else  -case when f not in (e,f,17) then a when 11=13 then t1.c else t1.d end end>=t1.b then b when t1.d in (select +max(19) from t1 union select abs(cast(avg(t1.f) AS integer))+case ~count(*)-max(t1.a)+max(11) when (max(a)) then (max(t1.d)) else count(distinct 11) end from t1) and e in (t1.d,17,11) then (11) else b end and a)}\n} {200}\ndo_test randexpr-2.366 {\n  db eval {SELECT t1.f+case when c*f | (t1.a) in (select b*f from t1 union select  -case when d not between ~13 | 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then  -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE ~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between  -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c}\n} {700}\ndo_test randexpr-2.367 {\n  db eval {SELECT t1.f+case when c*f | (t1.a) in (select b*f from t1 union select  -case when d not between ~13 | 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then  -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE NOT (~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between  -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c)}\n} {}\ndo_test randexpr-2.368 {\n  db eval {SELECT t1.f+case when c*f & (t1.a) in (select b*f from t1 union select  -case when d not between ~13 & 13+case a when a then e else a end and f then 11 else e-t1.d end from t1) then  -(abs(case when ((case t1.f when t1.b then t1.f else a end*f+t1.c)) in (select d from t1 union select (t1.e) from t1) then d else (t1.f) end)/abs(b)) else t1.a end FROM t1 WHERE ~(f+17-(select +max(t1.f)-case count(distinct d-19) when ~count(distinct (abs(b)/abs(a))) then cast(avg(17) AS integer) else ~count(distinct e)*count(*) end from t1)-f-coalesce((select t1.f from t1 where t1.a>=t1.c or t1.b between  -t1.a and 19 or exists(select 1 from t1 where t1.e not in (13,t1.c,e)) and d>a),t1.d)) not between d and c}\n} {700}\ndo_test randexpr-2.369 {\n  db eval {SELECT case when coalesce((select d from t1 where not coalesce((select f*t1.b from t1 where exists(select 1 from t1 where (t1.f*t1.a)-19-13 in (select ~(cast(avg(t1.b) AS integer)) from t1 union select min(t1.a)+case min( -t1.a) when cast(avg(19) AS integer) then cast(avg(19) AS integer) else min(13) end+( -min(a)) from t1))),(t1.f)) between 17 and d),11)=19 then t1.b when 17<11 or exists(select 1 from t1 where d in (select 13 from t1 union select f from t1)) then 11 else t1.c end FROM t1 WHERE case c when 13 then +t1.d else t1.a end in (select abs(case + -count(*)+count(distinct coalesce((select (abs(~case when t1.c=19 | 13 then t1.c when not e>(13) then f else d end)/abs(a)) from t1 where 17>=t1.b),t1.b))+min(t1.a)*count(*) | (((max(a)))-cast(avg((17)) AS integer)) when max(d) then count(*) else cast(avg(t1.e) AS integer) end) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.370 {\n  db eval {SELECT case when coalesce((select d from t1 where not coalesce((select f*t1.b from t1 where exists(select 1 from t1 where (t1.f*t1.a)-19-13 in (select ~(cast(avg(t1.b) AS integer)) from t1 union select min(t1.a)+case min( -t1.a) when cast(avg(19) AS integer) then cast(avg(19) AS integer) else min(13) end+( -min(a)) from t1))),(t1.f)) between 17 and d),11)=19 then t1.b when 17<11 or exists(select 1 from t1 where d in (select 13 from t1 union select f from t1)) then 11 else t1.c end FROM t1 WHERE NOT (case c when 13 then +t1.d else t1.a end in (select abs(case + -count(*)+count(distinct coalesce((select (abs(~case when t1.c=19 | 13 then t1.c when not e>(13) then f else d end)/abs(a)) from t1 where 17>=t1.b),t1.b))+min(t1.a)*count(*) | (((max(a)))-cast(avg((17)) AS integer)) when max(d) then count(*) else cast(avg(t1.e) AS integer) end) from t1 union select count(*) from t1))}\n} {300}\ndo_test randexpr-2.371 {\n  db eval {SELECT  -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then  -a else t1.e end)-abs(min(e)+ -max(c) | ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE f between 19*t1.d and 19}\n} {}\ndo_test randexpr-2.372 {\n  db eval {SELECT  -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then  -a else t1.e end)-abs(min(e)+ -max(c) | ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE NOT (f between 19*t1.d and 19)}\n} {-118}\ndo_test randexpr-2.373 {\n  db eval {SELECT  -(select count(*) from t1)*(select (+(cast(avg(+f) AS integer))+++case +max(t1.b-case when t1.e+t1.e>=11 then  -a else t1.e end)-abs(min(e)+ -max(c) & ((max(11)))) when max(11) then (min(b)) else cast(avg( -b) AS integer) end-cast(avg(b) AS integer)-count(*)+count(*)) from t1)+~17- -t1.a FROM t1 WHERE NOT (f between 19*t1.d and 19)}\n} {-118}\ndo_test randexpr-2.374 {\n  db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) | max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else  -t1.d end then f else e end FROM t1 WHERE d>11}\n} {200}\ndo_test randexpr-2.375 {\n  db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) | max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else  -t1.d end then f else e end FROM t1 WHERE NOT (d>11)}\n} {}\ndo_test randexpr-2.376 {\n  db eval {SELECT case when not t1.a< -~~e then b when c*(select +case max((abs( -a)/abs(a))) when min(t1.b) then case ~min(t1.d)-cast(avg(e) AS integer) & max(e) when count(distinct 11) then count(*) else max(b) end else count(*) end from t1) not between 13 and case when exists(select 1 from t1 where exists(select 1 from t1 where f not in (19,t1.f,19)) and 11 between t1.b and t1.b) then (13) else  -t1.d end then f else e end FROM t1 WHERE d>11}\n} {200}\ndo_test randexpr-2.377 {\n  db eval {SELECT coalesce((select max(t1.c | ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1)}\n} {}\ndo_test randexpr-2.378 {\n  db eval {SELECT coalesce((select max(t1.c | ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE NOT (case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1))}\n} {-18}\ndo_test randexpr-2.379 {\n  db eval {SELECT coalesce((select max(t1.c & ~17) from t1 where exists(select 1 from t1 where t1.f<>b-(abs(13)/abs(e)))),13) FROM t1 WHERE NOT (case when case (abs(c+a+19+coalesce((select max(t1.a) from t1 where coalesce((select coalesce((select (f) from t1 where t1.d between 19 and b),t1.a) from t1 where 13=(c)),f) in (select ~case count(*) when max(t1.b) then ((count(distinct 11))) else count(*) end- -count(distinct a) from t1 union select count(distinct 13) from t1)),t1.c) | t1.b+t1.d)/abs(e)) when t1.d then a else 17 end not between 19 and t1.f then t1.b else d end in (select t1.c from t1 union select (t1.a) from t1))}\n} {300}\ndo_test randexpr-2.380 {\n  db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d | (select count(distinct coalesce((select max(t1.e) from t1 where case when  -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then  -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end}\n} {}\ndo_test randexpr-2.381 {\n  db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d | (select count(distinct coalesce((select max(t1.e) from t1 where case when  -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE NOT (d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then  -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end)}\n} {-120289}\ndo_test randexpr-2.382 {\n  db eval {SELECT (coalesce((select (coalesce((select d from t1 where not exists(select 1 from t1 where 17>t1.c)),d))*c from t1 where t1.b between t1.d & (select count(distinct coalesce((select max(t1.e) from t1 where case when  -e>t1.b then f when t1.a<t1.f then t1.e else t1.d end<=c),(19))) from t1) and b or 13 in (t1.d,t1.d,t1.d)),t1.b)-b*f)+11-t1.e FROM t1 WHERE NOT (d<case when d>(abs(19*case when coalesce((select b*case when 11 not between 19 and (abs(13)/abs(t1.b-t1.d-e+b-f+19*t1.a)) then  -t1.a else f end from t1 where (b=17)),f)= -t1.d then 17 when 11<>19 then f else t1.d end)/abs(t1.b)) then d else 19 end)}\n} {-489}\ndo_test randexpr-2.383 {\n  db eval {SELECT 19*case when coalesce((select max(t1.e-c) from t1 where f=(abs(coalesce((select t1.c from t1 where not (not exists(select 1 from t1 where a in (select b from t1 union select c from t1)))),13))/abs(coalesce((select 13 from t1 where t1.b in (d,t1.d,a)), -t1.b)))),c) in (select ~min(t1.c) from t1 union select count(*) from t1) and  -f<>t1.c then t1.a-t1.e when not t1.a in (select cast(avg(a) AS integer) from t1 union select min(13) from t1) then  -19 else f end FROM t1 WHERE 11<>13}\n} {11400}\ndo_test randexpr-2.384 {\n  db eval {SELECT 19*case when coalesce((select max(t1.e-c) from t1 where f=(abs(coalesce((select t1.c from t1 where not (not exists(select 1 from t1 where a in (select b from t1 union select c from t1)))),13))/abs(coalesce((select 13 from t1 where t1.b in (d,t1.d,a)), -t1.b)))),c) in (select ~min(t1.c) from t1 union select count(*) from t1) and  -f<>t1.c then t1.a-t1.e when not t1.a in (select cast(avg(a) AS integer) from t1 union select min(13) from t1) then  -19 else f end FROM t1 WHERE NOT (11<>13)}\n} {}\ndo_test randexpr-2.385 {\n  db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) | cast(avg(t1.d) AS integer) | ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end | max((19)) | min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else  -13 end<=(t1.b)}\n} {}\ndo_test randexpr-2.386 {\n  db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) | cast(avg(t1.d) AS integer) | ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end | max((19)) | min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE NOT (t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else  -13 end<=(t1.b))}\n} {-7400}\ndo_test randexpr-2.387 {\n  db eval {SELECT t1.b*(select max(t1.b*coalesce((select max(t1.f*(t1.b)) from t1 where 17 not in (d,(a),(t1.b)+13)),t1.c)-t1.a) & cast(avg(t1.d) AS integer) & ~+case abs(abs(count(distinct t1.b))) when ~count(distinct e)-(count(*)) then max(t1.e) else max(d) end & max((19)) & min(19) from t1)-t1.d-t1.d*17 FROM t1 WHERE NOT (t1.f-case t1.d+19+13*case when (abs(e)/abs((select count(*)+cast(avg(a) AS integer)*count(*) from t1)-c*(abs(d)/abs(c*t1.e-19)))) not in (17,17,t1.a) then t1.f when t1.d<>t1.f then b else d end+ - -f*t1.b*d when b then 11 else  -13 end<=(t1.b))}\n} {-7200}\ndo_test randexpr-2.388 {\n  db eval {SELECT (select abs(count(distinct t1.e) | min(b))-cast(avg(c) AS integer) | case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) | count(*) | ~max(b) | ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) | count(distinct a) when ((count(distinct t1.d))) then  -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE ((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct  -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e)))}\n} {-99}\ndo_test randexpr-2.389 {\n  db eval {SELECT (select abs(count(distinct t1.e) | min(b))-cast(avg(c) AS integer) | case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) | count(*) | ~max(b) | ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) | count(distinct a) when ((count(distinct t1.d))) then  -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE NOT (((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct  -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e))))}\n} {}\ndo_test randexpr-2.390 {\n  db eval {SELECT (select abs(count(distinct t1.e) & min(b))-cast(avg(c) AS integer) & case +~+max(t1.a)*abs(+~ - -+cast(avg(19*f) AS integer) & count(*) & ~max(b) & ((max(t1.e)))-count(distinct t1.d)+ -(count(distinct t1.c)))* -count(distinct 17) & count(distinct a) when ((count(distinct t1.d))) then  -min(t1.c) else count(distinct t1.c) end- -min(d) from t1) FROM t1 WHERE ((not exists(select 1 from t1 where c=f)) and case when not 19+t1.c- -11+11+e>=a or t1.d>b then f else t1.e end<> -t1.c) or (t1.a in (select +count(*) from t1 union select abs((case max(d) when count(distinct d) then min( -t1.e) else count(distinct a) end-count(distinct  -t1.f)))*count(*) from t1) or not exists(select 1 from t1 where t1.d not in (c,17,e)))}\n} {144}\ndo_test randexpr-2.391 {\n  db eval {SELECT case when exists(select 1 from t1 where coalesce((select b from t1 where case when (b<t1.b) then (select (min(a+17+a-t1.f)) from t1) else t1.a end in (select (17-a)*t1.e+c*c from t1 union select 17 from t1)),t1.f)<e) then case when t1.e in (t1.d, -t1.a,c) then 17 else  -e end when not t1.c in (select t1.e from t1 union select e from t1) then t1.c else t1.b end FROM t1 WHERE coalesce((select max(13) from t1 where e=t1.a),case when f+(d)<=~case when (case when 17*t1.a in (select 13 from t1 union select 19 from t1) then f else 17 end in (select max(t1.a) from t1 union select cast(avg(t1.e) AS integer)+max(a) | count(*) from t1)) or 13 in (b,t1.e,19) then t1.b*b when t1.a> -11 then  -t1.c else  -b end then d else t1.a end) not in (t1.b,d,t1.b)}\n} {300}\ndo_test randexpr-2.392 {\n  db eval {SELECT case when exists(select 1 from t1 where coalesce((select b from t1 where case when (b<t1.b) then (select (min(a+17+a-t1.f)) from t1) else t1.a end in (select (17-a)*t1.e+c*c from t1 union select 17 from t1)),t1.f)<e) then case when t1.e in (t1.d, -t1.a,c) then 17 else  -e end when not t1.c in (select t1.e from t1 union select e from t1) then t1.c else t1.b end FROM t1 WHERE NOT (coalesce((select max(13) from t1 where e=t1.a),case when f+(d)<=~case when (case when 17*t1.a in (select 13 from t1 union select 19 from t1) then f else 17 end in (select max(t1.a) from t1 union select cast(avg(t1.e) AS integer)+max(a) | count(*) from t1)) or 13 in (b,t1.e,19) then t1.b*b when t1.a> -11 then  -t1.c else  -b end then d else t1.a end) not in (t1.b,d,t1.b))}\n} {}\ndo_test randexpr-2.393 {\n  db eval {SELECT t1.f+coalesce((select t1.a-t1.d*f-coalesce((select max(coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where a=~t1.d+case when (c in (select abs(~( -cast(avg(e) AS integer))) from t1 union select  -min(19) from t1)) and 19<>t1.e or t1.e<11 and c in (t1.b,t1.b,t1.d) or 17 between  -t1.d and t1.d then 11 else d end)),c-f)) from t1 where t1.a<=t1.c),11)-t1.c from t1 where f between t1.a and d),19) FROM t1 WHERE exists(select 1 from t1 where case +t1.d when d then f else t1.e end in (t1.e,17,11) or 13*e-t1.b in (select t1.e from t1 union select 17 from t1)) and 11<=case  -case when not exists(select 1 from t1 where (17 | t1.e in (11,11,11) and b<(19))) then case t1.c+t1.f+c when t1.b then c else 19 end else 17 end when d then t1.b else t1.a end}\n} {}\ndo_test randexpr-2.394 {\n  db eval {SELECT t1.f+coalesce((select t1.a-t1.d*f-coalesce((select max(coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where a=~t1.d+case when (c in (select abs(~( -cast(avg(e) AS integer))) from t1 union select  -min(19) from t1)) and 19<>t1.e or t1.e<11 and c in (t1.b,t1.b,t1.d) or 17 between  -t1.d and t1.d then 11 else d end)),c-f)) from t1 where t1.a<=t1.c),11)-t1.c from t1 where f between t1.a and d),19) FROM t1 WHERE NOT (exists(select 1 from t1 where case +t1.d when d then f else t1.e end in (t1.e,17,11) or 13*e-t1.b in (select t1.e from t1 union select 17 from t1)) and 11<=case  -case when not exists(select 1 from t1 where (17 | t1.e in (11,11,11) and b<(19))) then case t1.c+t1.f+c when t1.b then c else 19 end else 17 end when d then t1.b else t1.a end)}\n} {619}\ndo_test randexpr-2.395 {\n  db eval {SELECT case when (coalesce((select coalesce((select max( -11) from t1 where not case t1.c*case when exists(select 1 from t1 where (t1.d) in (select case count(*) when count(distinct t1.c) then count(*) else count(*) end from t1 union select cast(avg(t1.c) AS integer) from t1)) then +e when f=19 then 17 else t1.e end when t1.a then 19 else c end=e),t1.a)- -d*f-a from t1 where (t1.e)<>13),19)*(a)=19) then (c) when (exists(select 1 from t1 where 17=t1.d)) then 19 else c end FROM t1 WHERE t1.d*c*(select cast(avg(((abs(t1.d*13)/abs(f)))) AS integer) from t1)+t1.d=case when +(coalesce((select t1.a from t1 where case when not exists(select 1 from t1 where not exists(select 1 from t1 where c=t1.e)) then 19 |  -17 else 13 end not in (t1.f,b,t1.b)),t1.f))*t1.a-t1.c-13 in (e,11,t1.c) then t1.a when (d between  -t1.f and f) then t1.d else t1.a end}\n} {}\ndo_test randexpr-2.396 {\n  db eval {SELECT case when (coalesce((select coalesce((select max( -11) from t1 where not case t1.c*case when exists(select 1 from t1 where (t1.d) in (select case count(*) when count(distinct t1.c) then count(*) else count(*) end from t1 union select cast(avg(t1.c) AS integer) from t1)) then +e when f=19 then 17 else t1.e end when t1.a then 19 else c end=e),t1.a)- -d*f-a from t1 where (t1.e)<>13),19)*(a)=19) then (c) when (exists(select 1 from t1 where 17=t1.d)) then 19 else c end FROM t1 WHERE NOT (t1.d*c*(select cast(avg(((abs(t1.d*13)/abs(f)))) AS integer) from t1)+t1.d=case when +(coalesce((select t1.a from t1 where case when not exists(select 1 from t1 where not exists(select 1 from t1 where c=t1.e)) then 19 |  -17 else 13 end not in (t1.f,b,t1.b)),t1.f))*t1.a-t1.c-13 in (e,11,t1.c) then t1.a when (d between  -t1.f and f) then t1.d else t1.a end)}\n} {300}\ndo_test randexpr-2.397 {\n  db eval {SELECT coalesce((select d from t1 where f in (select max(19) from t1 union select ~+max(t1.e) from t1)),b-case  -11 when 13 then t1.a-e else case when not exists(select 1 from t1 where c not in ( -t1.c,(t1.e),19)) and d+t1.b-t1.b in (select t1.a from t1 union select t1.d from t1) then 19+19*(t1.f) when t1.b<=a then 17 else t1.a end end+t1.b)*t1.a FROM t1 WHERE (select +cast(avg(~13+(select count(*) from t1)) AS integer)++min(case when (not d<>a) then coalesce((select t1.b from t1 where t1.f not between e and t1.d),13)+13 when t1.d not between 11 and t1.d then 17 else f end) | count(*) | ~count(distinct t1.e) | cast(avg(e) AS integer)-max(t1.d) from t1) not between coalesce((select case t1.a when a then e else 17 end from t1 where t1.a in (t1.e,11,( -t1.d))), -(b)) and t1.a}\n} {}\ndo_test randexpr-2.398 {\n  db eval {SELECT coalesce((select d from t1 where f in (select max(19) from t1 union select ~+max(t1.e) from t1)),b-case  -11 when 13 then t1.a-e else case when not exists(select 1 from t1 where c not in ( -t1.c,(t1.e),19)) and d+t1.b-t1.b in (select t1.a from t1 union select t1.d from t1) then 19+19*(t1.f) when t1.b<=a then 17 else t1.a end end+t1.b)*t1.a FROM t1 WHERE NOT ((select +cast(avg(~13+(select count(*) from t1)) AS integer)++min(case when (not d<>a) then coalesce((select t1.b from t1 where t1.f not between e and t1.d),13)+13 when t1.d not between 11 and t1.d then 17 else f end) | count(*) | ~count(distinct t1.e) | cast(avg(e) AS integer)-max(t1.d) from t1) not between coalesce((select case t1.a when a then e else 17 end from t1 where t1.a in (t1.e,11,( -t1.d))), -(b)) and t1.a)}\n} {30000}\ndo_test randexpr-2.399 {\n  db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct  - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a | t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select  -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE case when a between  -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and  -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a)}\n} {}\ndo_test randexpr-2.400 {\n  db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct  - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a | t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select  -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE NOT (case when a between  -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and  -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a))}\n} {1500}\ndo_test randexpr-2.401 {\n  db eval {SELECT (abs(c)/abs((coalesce((select t1.d from t1 where ((19) in (select count(distinct  - -(abs(coalesce((select max(t1.e) from t1 where t1.c*t1.a & t1.d=t1.d or t1.f in (select min(t1.f)-cast(avg(e) AS integer) from t1 union select  -count(*) from t1)),c))/abs(a))) from t1 union select case cast(avg(c) AS integer)-abs( -((count(*))))*(count(*))*min(d) when cast(avg(a) AS integer) then count(distinct 11) else count(*) end-(count(distinct 17)) from t1))),a))))*t1.e FROM t1 WHERE NOT (case when a between  -t1.a+(t1.c) and c-case when (~+t1.b-~case when t1.a not between 19*11 and 11 then t1.a when 11=f and  -t1.d not between t1.a and d then e else b end in (select min(19) from t1 union select case count(distinct 17) when count(*) then count(distinct t1.f) else min(c) end from t1)) then t1.f else 17 end then 17 else 13 end in (t1.a,t1.d,a))}\n} {1500}\ndo_test randexpr-2.402 {\n  db eval {SELECT case when d=c-(select (~max(t1.f*t1.c-11)) from t1) then coalesce((select max(19) from t1 where 13<coalesce((select case when (select count(distinct t1.f+13) from t1)>d then t1.e when not not exists(select 1 from t1 where t1.c not in (a,a,t1.d) and d not between b and 19) then t1.a else 11 end*f-f from t1 where t1.f between e and e and d between 19 and t1.e or 11<>t1.a),t1.c)),d) else 17 end FROM t1 WHERE (t1.e=11)}\n} {}\ndo_test randexpr-2.403 {\n  db eval {SELECT case when d=c-(select (~max(t1.f*t1.c-11)) from t1) then coalesce((select max(19) from t1 where 13<coalesce((select case when (select count(distinct t1.f+13) from t1)>d then t1.e when not not exists(select 1 from t1 where t1.c not in (a,a,t1.d) and d not between b and 19) then t1.a else 11 end*f-f from t1 where t1.f between e and e and d between 19 and t1.e or 11<>t1.a),t1.c)),d) else 17 end FROM t1 WHERE NOT ((t1.e=11))}\n} {17}\ndo_test randexpr-2.404 {\n  db eval {SELECT case when t1.a-t1.a | case when (abs(t1.d)/abs(t1.c | t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b | t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE (abs(case when not t1.d<=t1.f and not t1.d not between  -f and  -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select  -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19}\n} {11}\ndo_test randexpr-2.405 {\n  db eval {SELECT case when t1.a-t1.a | case when (abs(t1.d)/abs(t1.c | t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b | t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE NOT ((abs(case when not t1.d<=t1.f and not t1.d not between  -f and  -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select  -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19)}\n} {}\ndo_test randexpr-2.406 {\n  db eval {SELECT case when t1.a-t1.a & case when (abs(t1.d)/abs(t1.c & t1.a))<>t1.e then e*+t1.c-t1.d*coalesce((select t1.b from t1 where b>=+d+ -e*11),11)+t1.b & t1.f when not exists(select 1 from t1 where d not in (17,e,d)) then 11 else t1.d end>=13 then 11 when d=c then a else f end FROM t1 WHERE (abs(case when not t1.d<=t1.f and not t1.d not between  -f and  -17-11*t1.d and (13<t1.b) and 17 in (select min(c)-+min(13)-min(t1.b) from t1 union select  -max((( -11))) from t1) then 13 when c<>d then t1.d*coalesce((select max(t1.a) from t1 where (17) not between (t1.b) and 11),d) else t1.d end)/abs(f)) not between 13 and 19}\n} {600}\ndo_test randexpr-2.407 {\n  db eval {SELECT coalesce((select t1.f*13 from t1 where exists(select 1 from t1 where 13<=t1.e)),(abs(+ -17)/abs(c))) FROM t1 WHERE coalesce((select 17 from t1 where 11>++a-~t1.a+d | (19)),(abs(t1.c)/abs(case when case t1.c*17-case when b not between t1.b and f then t1.a when f>=a then 19 else 13 end when 19 then 13 else t1.f end not between c and a then c else 13 end)))> -e or 13 between f and c and t1.e>=b}\n} {7800}\ndo_test randexpr-2.408 {\n  db eval {SELECT coalesce((select t1.f*13 from t1 where exists(select 1 from t1 where 13<=t1.e)),(abs(+ -17)/abs(c))) FROM t1 WHERE NOT (coalesce((select 17 from t1 where 11>++a-~t1.a+d | (19)),(abs(t1.c)/abs(case when case t1.c*17-case when b not between t1.b and f then t1.a when f>=a then 19 else 13 end when 19 then 13 else t1.f end not between c and a then c else 13 end)))> -e or 13 between f and c and t1.e>=b)}\n} {}\ndo_test randexpr-2.409 {\n  db eval {SELECT ~+coalesce((select (select count(distinct +coalesce((select c from t1 where e>=13),+c)-t1.c) from t1) from t1 where case a when t1.d*(select cast(avg(case when t1.b*coalesce((select 17 from t1 where case  -a when t1.b then d else (t1.f) end not in ((t1.e),a,t1.f)),t1.c)-c in (d,a,t1.c) then c else b end) AS integer) from t1)+t1.d then 13 else t1.e end not in (19,a,17)),13) FROM t1 WHERE +c in (a,17,t1.d)}\n} {}\ndo_test randexpr-2.410 {\n  db eval {SELECT ~+coalesce((select (select count(distinct +coalesce((select c from t1 where e>=13),+c)-t1.c) from t1) from t1 where case a when t1.d*(select cast(avg(case when t1.b*coalesce((select 17 from t1 where case  -a when t1.b then d else (t1.f) end not in ((t1.e),a,t1.f)),t1.c)-c in (d,a,t1.c) then c else b end) AS integer) from t1)+t1.d then 13 else t1.e end not in (19,a,17)),13) FROM t1 WHERE NOT (+c in (a,17,t1.d))}\n} {-2}\ndo_test randexpr-2.411 {\n  db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) | cast(avg(t1.d) AS integer)*count(*))+max( -11) | max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when  -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f}\n} {500}\ndo_test randexpr-2.412 {\n  db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) | cast(avg(t1.d) AS integer)*count(*))+max( -11) | max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE NOT (not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when  -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f)}\n} {}\ndo_test randexpr-2.413 {\n  db eval {SELECT f-coalesce((select t1.d from t1 where t1.a>11+t1.d),coalesce((select coalesce((select t1.d from t1 where 17>=d or (case c when t1.c then (t1.c) else t1.e end in (b,17,17) or t1.b>=t1.a) or t1.b<=e),case d when (19) then t1.d else t1.a end)-t1.d from t1 where 13 in (select ( -count(distinct (e)) & cast(avg(t1.d) AS integer)*count(*))+max( -11) & max( -c) from t1 union select count(distinct 11) from t1)),a)) FROM t1 WHERE not b<=13 or (coalesce((select max(t1.b) from t1 where b in (case when not a<>13 then 17 when  -(select ~abs( -(max(f))+count(distinct t1.a)) from t1)+13>=t1.b then case c when t1.a then d else f end-c else t1.d end-19, -t1.d,f)),19)) not in (t1.a,c,t1.d) or t1.e>t1.f}\n} {500}\ndo_test randexpr-2.414 {\n  db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between  -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) | f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE a>coalesce((select coalesce((select e from t1 where case when  -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d)}\n} {}\ndo_test randexpr-2.415 {\n  db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between  -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) | f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE NOT (a>coalesce((select coalesce((select e from t1 where case when  -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d))}\n} {13}\ndo_test randexpr-2.416 {\n  db eval {SELECT coalesce((select e from t1 where (coalesce((select max(+e+e*11*t1.c-e) from t1 where exists(select 1 from t1 where (19<=~t1.f))),case (abs(t1.c)/abs(case t1.c when 19 then f*~case when t1.e+t1.d between  -t1.f and (d) then b when (d=a) then t1.e else e end else c end*t1.a)) & f when (d) then 17 else t1.f end)<t1.c)),13) FROM t1 WHERE NOT (a>coalesce((select coalesce((select e from t1 where case when  -d+t1.e>e then coalesce((select d+b from t1 where exists(select 1 from t1 where not 13-b not in (f,a,d)) and (t1.b between (a) and t1.c)),c) when a=13 then t1.e else a end in (select t1.d from t1 union select t1.d from t1) and e not in (d, -19,11)),d) from t1 where not f in (t1.a,19,t1.d)),t1.d))}\n} {13}\ndo_test randexpr-2.417 {\n  db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end | 13+b | b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE t1.f>=19}\n} {1}\ndo_test randexpr-2.418 {\n  db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end | 13+b | b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE NOT (t1.f>=19)}\n} {}\ndo_test randexpr-2.419 {\n  db eval {SELECT (select count(distinct 11-17-11) from t1)-coalesce((select (abs(13)/abs(t1.b-c*11+coalesce((select max(f) from t1 where t1.a>t1.a),(e))*case when (abs(e)/abs(t1.b)) not between ~f and t1.e then c else (abs(t1.b)/abs(t1.d)) end & 13+b & b+t1.e)) from t1 where t1.c in (select t1.c from t1 union select (a) from t1)),19) FROM t1 WHERE t1.f>=19}\n} {1}\ndo_test randexpr-2.420 {\n  db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) | ~ -count(distinct 17) from t1 union select min(c) from t1) then b else  -t1.e end) from t1 where d not between c and  -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) |  -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a)}\n} {17}\ndo_test randexpr-2.421 {\n  db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) | ~ -count(distinct 17) from t1 union select min(c) from t1) then b else  -t1.e end) from t1 where d not between c and  -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE NOT (t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) |  -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a))}\n} {}\ndo_test randexpr-2.422 {\n  db eval {SELECT coalesce((select max(case when 11+(select +abs(count(*)) from t1) not in (case when (case when not exists(select 1 from t1 where t1.d=f) then a else a end+11 in (select ((13)) from t1 union select t1.d from t1)) then (abs(t1.c)/abs(t1.b)) when a>=t1.c then b else f end,t1.a,c) then t1.a when b in (select cast(avg(t1.a) AS integer) & ~ -count(distinct 17) from t1 union select min(c) from t1) then b else  -t1.e end) from t1 where d not between c and  -t1.b and b=d and b between 13 and t1.c),(17)) FROM t1 WHERE t1.a in (coalesce((select max(e) from t1 where case case (select count(*) from t1)-~19 when t1.f*t1.d+coalesce((select max((select + -(((min(t1.b)))) |  -(count(distinct t1.c)) | count(*) from t1)*11) from t1 where f>=case when d in ((d),t1.d,13) then 19 when 17=17 then 11 else a end),t1.e) then c else t1.f end when t1.e then f else t1.d end in (13,(13),c)),t1.d),t1.e,a)}\n} {17}\ndo_test randexpr-2.423 {\n  db eval {SELECT coalesce((select t1.a-case t1.a when c then coalesce((select case (abs(11-(abs(t1.b)/abs(t1.a)))/abs((abs(t1.c)/abs(t1.a))))-t1.f when t1.d then f else 19 end from t1 where +t1.b*a in (select t1.e from t1 union select c from t1) and e between d and 11),t1.b) else a end from t1 where exists(select 1 from t1 where ((a in (13,c,d)))) and  -t1.e in ((t1.d),t1.a,t1.b)),t1.c) FROM t1 WHERE ++e*19 in (case when case when not (d<>case when  -case when (t1.a not between b and  -e) then 17 when f<>a then  -t1.d else t1.a end not in (a,a,c) then b when b<=c then e else b end) then 19 when (t1.b not in ( -13,t1.a,a)) then t1.b | 13 else e end* -19*t1.a<t1.f then t1.c when t1.f=t1.f then t1.a else t1.b end+d,a,11)}\n} {}\ndo_test randexpr-2.424 {\n  db eval {SELECT coalesce((select t1.a-case t1.a when c then coalesce((select case (abs(11-(abs(t1.b)/abs(t1.a)))/abs((abs(t1.c)/abs(t1.a))))-t1.f when t1.d then f else 19 end from t1 where +t1.b*a in (select t1.e from t1 union select c from t1) and e between d and 11),t1.b) else a end from t1 where exists(select 1 from t1 where ((a in (13,c,d)))) and  -t1.e in ((t1.d),t1.a,t1.b)),t1.c) FROM t1 WHERE NOT (++e*19 in (case when case when not (d<>case when  -case when (t1.a not between b and  -e) then 17 when f<>a then  -t1.d else t1.a end not in (a,a,c) then b when b<=c then e else b end) then 19 when (t1.b not in ( -13,t1.a,a)) then t1.b | 13 else e end* -19*t1.a<t1.f then t1.c when t1.f=t1.f then t1.a else t1.b end+d,a,11))}\n} {300}\ndo_test randexpr-2.425 {\n  db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a | t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) | t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a)}\n} {375}\ndo_test randexpr-2.426 {\n  db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a | t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) | t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE NOT (a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a))}\n} {}\ndo_test randexpr-2.427 {\n  db eval {SELECT (abs(e-((coalesce((select max(t1.c) from t1 where t1.f-a-case coalesce((select max(d) from t1 where (13<>~19)),f) when a- -t1.a & t1.f then t1.a*11-t1.e else coalesce((select max(t1.b) from t1 where not exists(select 1 from t1 where 17=t1.a or b>=f)),c) & t1.b end>19),t1.a))+c)-t1.c*e)/abs(t1.d)) FROM t1 WHERE a-t1.b not in (a,a-19-c | t1.d-d | e*t1.c*b,t1.e+t1.a)}\n} {375}\ndo_test randexpr-2.428 {\n  db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) |  -d*a*(b++ -13)*b>=b),17) | a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE  -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else  -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c}\n} {100}\ndo_test randexpr-2.429 {\n  db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) |  -d*a*(b++ -13)*b>=b),17) | a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE NOT ( -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else  -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c)}\n} {}\ndo_test randexpr-2.430 {\n  db eval {SELECT t1.b-coalesce((select t1.a from t1 where (d<=f)),~~case b when coalesce((select coalesce((select t1.c from t1 where a+~+~(abs(t1.d)/abs(17)) &  -d*a*(b++ -13)*b>=b),17) & a from t1 where a<a),17)-13 then 11 else t1.a end) FROM t1 WHERE  -coalesce((select (abs(t1.d)/abs(~t1.e))-a from t1 where (c>=coalesce((select t1.d+(select case min(a) | max(t1.b) when max(e) then count(*) else  -count(distinct f) end from t1)-t1.f+( - - -19) from t1 where t1.c in (select 19 from t1 union select 17 from t1)),11))),19)+11 not in ((b),e,e) or t1.e in (select min(t1.f) from t1 union select count(*)- -(cast(avg(17) AS integer)) from t1) or e>=t1.c}\n} {100}\ndo_test randexpr-2.431 {\n  db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end | t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE 17>=t1.b}\n} {}\ndo_test randexpr-2.432 {\n  db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end | t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE NOT (17>=t1.b)}\n} {187}\ndo_test randexpr-2.433 {\n  db eval {SELECT coalesce((select max(case when e<=t1.d then f*+case 17 when 17 then (abs((select abs(cast(avg(13) AS integer)+min(t1.b)) from t1))/abs(t1.c)) else d end*t1.c else a end) from t1 where coalesce((select t1.c from t1 where a<>t1.e+f-t1.c-a),+t1.a)+t1.d*case when d in (select t1.c from t1 union select 11 from t1) then a when 19 not in (d,e,b) then 11 else 19 end & t1.b in (select 19 from t1 union select t1.a from t1)),17)*11 FROM t1 WHERE NOT (17>=t1.b)}\n} {187}\ndo_test randexpr-2.434 {\n  db eval {SELECT case when coalesce((select max(case f when (abs(t1.d)/abs(case when +~e not in (t1.d,c,t1.a) or 17 in (select count(distinct  -b) from t1 union select count(distinct d) from t1) and d<=t1.b or b>(f) then coalesce((select c from t1 where t1.f<t1.e),e)+(d) when 17<19 then t1.c else t1.b end)) then t1.b else f end) from t1 where (17 not between 11 and t1.b) or t1.f>f or t1.b<> -t1.c), -t1.d)<11 then c else f end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where case  -case when case t1.c-t1.b-e when t1.b then t1.e else  -t1.c+~17 | coalesce((select max(t1.c) from t1 where 19 not between  -(a)-t1.c and 17),t1.c) end in (select (t1.f) from t1 union select b from t1) then e when c<>19 then t1.b else f end when  -11 then 11 else 19 end in ( -19,t1.a,d)) and not 17<t1.d)}\n} {600}\ndo_test randexpr-2.435 {\n  db eval {SELECT case when coalesce((select max(case f when (abs(t1.d)/abs(case when +~e not in (t1.d,c,t1.a) or 17 in (select count(distinct  -b) from t1 union select count(distinct d) from t1) and d<=t1.b or b>(f) then coalesce((select c from t1 where t1.f<t1.e),e)+(d) when 17<19 then t1.c else t1.b end)) then t1.b else f end) from t1 where (17 not between 11 and t1.b) or t1.f>f or t1.b<> -t1.c), -t1.d)<11 then c else f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where case  -case when case t1.c-t1.b-e when t1.b then t1.e else  -t1.c+~17 | coalesce((select max(t1.c) from t1 where 19 not between  -(a)-t1.c and 17),t1.c) end in (select (t1.f) from t1 union select b from t1) then e when c<>19 then t1.b else f end when  -11 then 11 else 19 end in ( -19,t1.a,d)) and not 17<t1.d))}\n} {}\ndo_test randexpr-2.436 {\n  db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) | (select max(t1.e-e) | max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) | max(t1.c)) | min(b) | (count(*))*min(19)- -count(*) | (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE +b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else  -e end or f in (t1.f,d,t1.c)}\n} {7995}\ndo_test randexpr-2.437 {\n  db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) | (select max(t1.e-e) | max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) | max(t1.c)) | min(b) | (count(*))*min(19)- -count(*) | (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE NOT (+b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else  -e end or f in (t1.f,d,t1.c))}\n} {}\ndo_test randexpr-2.438 {\n  db eval {SELECT ((select abs(min(t1.b-t1.b)-cast(avg((t1.d-t1.a*a) & (select max(t1.e-e) & max(17)*~abs(count(*)-cast(avg(coalesce((select t1.c from t1 where t1.c<=11),19)+ -e) AS integer) & max(t1.c)) & min(b) & (count(*))*min(19)- -count(*) & (cast(avg(b) AS integer)) from t1)) AS integer)-cast(avg(t1.b) AS integer)) from t1)) FROM t1 WHERE +b+(19*19)+c+t1.d<=e-19+case 13 when t1.f+~11+(select cast(avg(t1.e) AS integer) from t1) then (case when not exists(select 1 from t1 where t1.a between d and t1.b) then case c when d then d else t1.f end when not t1.b in (11,t1.c,t1.d) or t1.c<=(d) then (t1.a) else t1.b end) else  -e end or f in (t1.f,d,t1.c)}\n} {200}\ndo_test randexpr-2.439 {\n  db eval {SELECT case when (b<coalesce((select coalesce((select max(19 | t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between  -17 and b),11)) | count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 | f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE case when (((case coalesce((select  -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c}\n} {600}\ndo_test randexpr-2.440 {\n  db eval {SELECT case when (b<coalesce((select coalesce((select max(19 | t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between  -17 and b),11)) | count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 | f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE NOT (case when (((case coalesce((select  -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c)}\n} {}\ndo_test randexpr-2.441 {\n  db eval {SELECT case when (b<coalesce((select coalesce((select max(19 & t1.c) from t1 where 13 not in (t1.f,e,t1.e) or (select (count(distinct coalesce((select d from t1 where t1.c between  -17 and b),11)) & count(*)-max(t1.d)* -(max(d))) from t1)-c*t1.e in (select 19 & f from t1 union select a from t1)),c)*a from t1 where (13 not between a and 19)),19) and b>a) then t1.f else t1.c end FROM t1 WHERE case when (((case coalesce((select  -t1.b-t1.b*19*c | 19 from t1 where (exists(select 1 from t1 where e>=t1.a))),t1.a)+11 when d then t1.e else t1.c end=t1.d))) then t1.b when not not exists(select 1 from t1 where t1.f<(t1.a)) and t1.d>=f or t1.c>t1.a or t1.b between t1.f and 19 then t1.c else ~t1.c end=11 or (t1.e) not between 13 and t1.c}\n} {300}\ndo_test randexpr-2.442 {\n  db eval {SELECT case when not t1.d not in (coalesce((select 17 |  -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) | 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select  - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17))}\n} {}\ndo_test randexpr-2.443 {\n  db eval {SELECT case when not t1.d not in (coalesce((select 17 |  -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) | 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select  - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17)))}\n} {100}\ndo_test randexpr-2.444 {\n  db eval {SELECT case when not t1.d not in (coalesce((select 17 &  -coalesce((select (select min(a-t1.a+t1.a-t1.c*t1.e) from t1) from t1 where t1.d<=a),11) & 19 from t1 where not ( -13 in ( -t1.d,t1.d,19))),e)+11,11,13) then e when ((t1.b<t1.c) or d=19) then (t1.a) else a end FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where ~f-e+t1.b*d+case when coalesce((select max(d) from t1 where (t1.c*t1.b in (b,t1.e,17)) or t1.b not in (t1.c,t1.a,t1.c)), -17) in (select count(distinct 13) from t1 union select  - -~min( -11) | cast(avg(c) AS integer) from t1) then f else a end+e*t1.c+t1.c>t1.f and a>=17)))}\n} {100}\ndo_test randexpr-2.445 {\n  db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case  -count(*) when cast(avg(a) AS integer) then count(distinct b) else  -max(f) end | (cast(avg(t1.e) AS integer)) |  -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then  -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE case when  -case when t1.f<t1.c then  -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19}\n} {1500}\ndo_test randexpr-2.446 {\n  db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case  -count(*) when cast(avg(a) AS integer) then count(distinct b) else  -max(f) end | (cast(avg(t1.e) AS integer)) |  -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then  -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE NOT (case when  -case when t1.f<t1.c then  -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19)}\n} {}\ndo_test randexpr-2.447 {\n  db eval {SELECT e+c-(c)+t1.e*(abs(case when 13 in (select abs(max(17)*case  -count(*) when cast(avg(a) AS integer) then count(distinct b) else  -max(f) end & (cast(avg(t1.e) AS integer)) &  -min(f)) from t1 union select count(distinct d) from t1) and case when (t1.e+a> -(a)) then e when not c<t1.f or t1.d=f then e else t1.e end<=t1.f then  -a when t1.d<=13 then a else t1.b end)/abs( -t1.a))-t1.b+t1.b FROM t1 WHERE case when  -case when t1.f<t1.c then  -(t1.e) when 11 between e and coalesce((select c from t1 where not exists(select 1 from t1 where b>=e)),coalesce((select max(case t1.e when t1.c then t1.a else a end) from t1 where b>=t1.c and b<>t1.c),13)) then t1.b else a end<11 then b when (11 in (select a from t1 union select t1.b from t1)) or t1.b=e or a between a and 13 then t1.b else b end>19}\n} {1500}\ndo_test randexpr-2.448 {\n  db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select  -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then  -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) | f else t1.e end and  -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE ((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where  - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else  -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13))}\n} {-1887}\ndo_test randexpr-2.449 {\n  db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select  -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then  -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) | f else t1.e end and  -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE NOT (((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where  - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else  -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13)))}\n} {}\ndo_test randexpr-2.450 {\n  db eval {SELECT 13-coalesce((select t1.a*a from t1 where not exists(select 1 from t1 where 17 not between case +coalesce((select  -case 19 when a*b then 19 else f end from t1 where (t1.d-t1.e between case f when (select abs(case abs( -min(13)) when min(t1.b) then  -(count(distinct f)) else min(t1.b) end) from t1) then 17*( -13) & f else t1.e end and  -t1.a)),d)*c when 13 then 11 else t1.a end and c)),t1.a)*19 FROM t1 WHERE ((not f-c<=(abs(a)/abs(+t1.a)) or t1.e not between coalesce((select 11 from t1 where  - -a*t1.d*case coalesce((select max(d) from t1 where ((t1.b<=t1.c))),case when f>t1.d or t1.d=t1.a or t1.c<=c then a else  -c end*t1.b) when (f) then 11 else 19 end-t1.a<=b),c) and 13))}\n} {-1887}\ndo_test randexpr-2.451 {\n  db eval {SELECT ~case when (t1.d | 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1)}\n} {}\ndo_test randexpr-2.452 {\n  db eval {SELECT ~case when (t1.d | 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE NOT (not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1))}\n} {-102}\ndo_test randexpr-2.453 {\n  db eval {SELECT ~case when (t1.d & 17 in (b*t1.e,19*case when t1.d<= -a then t1.d*~t1.c*e*t1.c-19 else ~t1.b+17 end-d,(t1.c))) then +t1.d else (abs( -case t1.e when t1.c then (t1.b) else t1.f end-11+ -a)/abs(f))+a end FROM t1 WHERE NOT (not exists(select 1 from t1 where not c in (select case count(distinct (f)-19) when ~( -+~cast(avg(c) AS integer) | count(distinct 11)-max(d)+min(t1.a)+ -( -count(distinct b))+(count(*)))-count(*)+cast(avg(c) AS integer) then count(distinct d) else ((max(t1.b))) end-min(b) from t1 union select min(t1.c) from t1)) and t1.c in (select +d from t1 union select case when c+b=17 then a else 13 end+11 from t1))}\n} {-102}\ndo_test randexpr-2.454 {\n  db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then  -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) | max(t1.c) from t1 union select count(distinct  -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) | ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1)}\n} {}\ndo_test randexpr-2.455 {\n  db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then  -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) | max(t1.c) from t1 union select count(distinct  -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) | ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE NOT (coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1))}\n} {17}\ndo_test randexpr-2.456 {\n  db eval {SELECT (select case case min(d) when abs(cast(avg((abs(a)/abs(coalesce((select (select abs(cast(avg(t1.f) AS integer)) from t1) from t1 where (case when t1.e in (select 11 from t1 union select 17 from t1) then  -t1.e- -t1.e else a end<>a) and not not exists(select 1 from t1 where t1.b in (select ~+max( -t1.b) & max(t1.c) from t1 union select count(distinct  -t1.a) from t1))),t1.a)))) AS integer)) then (count(*) & ((count(distinct b)))-count(*)) else min(11) end when max(a) then count(distinct f) else (min(17)) end from t1) FROM t1 WHERE NOT (coalesce((select max(13) from t1 where t1.b not in ( -case when 13 not between 17 and b then f when t1.e+~+e between coalesce((select max(case 19 when e then 17 else coalesce((select coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.b not between t1.a and a)),e)*b*t1.f from t1 where t1.f>=t1.c),c) end) from t1 where e>b),t1.f) | f and f then c else 11 end,(c),t1.e)),19)-t1.c in (select t1.a from t1 union select e from t1))}\n} {17}\ndo_test randexpr-2.457 {\n  db eval {SELECT (a*f+c | ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when  -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or  -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and  -t1.b)}\n} {}\ndo_test randexpr-2.458 {\n  db eval {SELECT (a*f+c | ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when  -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or  -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and  -t1.b))}\n} {327281}\ndo_test randexpr-2.459 {\n  db eval {SELECT (a*f+c & ~b*(select cast(avg(19) AS integer) from t1)+17*(select max(a*b-d) from t1)+(abs((select count(distinct b) from t1))/abs(case when  -13*c between t1.f and t1.c then c when not 17 between 17 and 11 and 17<=((t1.c)) then c else a end*t1.c))-a*a)-c FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-11+t1.d*e+(abs(coalesce((select max(t1.b) from t1 where 19-13- -coalesce((select c*t1.e+t1.f*f from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (17<=d or  -11 in (select cast(avg(c) AS integer) from t1 union select +count(*) from t1))))),t1.b)<a),(t1.c)))/abs(t1.c))<=a or 13 between t1.e and  -t1.b))}\n} {51800}\ndo_test randexpr-2.460 {\n  db eval {SELECT coalesce((select max(case when not ((select ((count(distinct t1.f)*(cast(avg(e) AS integer)))-min(t1.d)*min(t1.c)) from t1)*(select min(t1.d) from t1) not in ((select count(distinct b) from t1),f*d,19) and  -a in (t1.d,b,a)) and d>=t1.c or t1.b>t1.c or 19 not between c and t1.e then 17 else t1.b end) from t1 where (e<=t1.b)),11) FROM t1 WHERE t1.a in (f,t1.d*+a,t1.c* -(select (abs(case +(max(coalesce((select max((select count(*)-cast(avg(b) AS integer) from t1)) from t1 where (c<c)),b)-t1.d))+max(c)*+count(distinct coalesce((select max((17)) from t1 where d in (select 11 from t1 union select 17 from t1)),t1.e))*count(*) when ~count(*) then cast(avg(d) AS integer) else max(t1.a) end*count(distinct c))) from t1))}\n} {}\ndo_test randexpr-2.461 {\n  db eval {SELECT coalesce((select max(case when not ((select ((count(distinct t1.f)*(cast(avg(e) AS integer)))-min(t1.d)*min(t1.c)) from t1)*(select min(t1.d) from t1) not in ((select count(distinct b) from t1),f*d,19) and  -a in (t1.d,b,a)) and d>=t1.c or t1.b>t1.c or 19 not between c and t1.e then 17 else t1.b end) from t1 where (e<=t1.b)),11) FROM t1 WHERE NOT (t1.a in (f,t1.d*+a,t1.c* -(select (abs(case +(max(coalesce((select max((select count(*)-cast(avg(b) AS integer) from t1)) from t1 where (c<c)),b)-t1.d))+max(c)*+count(distinct coalesce((select max((17)) from t1 where d in (select 11 from t1 union select 17 from t1)),t1.e))*count(*) when ~count(*) then cast(avg(d) AS integer) else max(t1.a) end*count(distinct c))) from t1)))}\n} {11}\ndo_test randexpr-2.462 {\n  db eval {SELECT (case case when +c>e then case t1.d when 13 then t1.c else 19 end-13 else t1.e+coalesce((select max(19) from t1 where case when e in (+b,coalesce((select a+(11) from t1 where b not between c and d or t1.b not in (a,11,17)),b),11) then 19 when (c) not in (t1.c,t1.b,d) then t1.c else t1.d end*f not between t1.a and d),13) end when c then 11 else c end) FROM t1 WHERE 19 not between coalesce((select max(d*t1.c) from t1 where (select cast(avg((b)) AS integer) from t1) in (select ( - -(abs(case max(b) when cast(avg( -13-11) AS integer) then count(distinct a-e) else ~ -cast(avg((c)) AS integer)-min(17)+count(*) end) | (min(e)))-min((19))) from t1 union select count(distinct 13) from t1)),case when  -e | 19 between  -11 and f then 19 else 19 end) and (f)}\n} {}\ndo_test randexpr-2.463 {\n  db eval {SELECT (case case when +c>e then case t1.d when 13 then t1.c else 19 end-13 else t1.e+coalesce((select max(19) from t1 where case when e in (+b,coalesce((select a+(11) from t1 where b not between c and d or t1.b not in (a,11,17)),b),11) then 19 when (c) not in (t1.c,t1.b,d) then t1.c else t1.d end*f not between t1.a and d),13) end when c then 11 else c end) FROM t1 WHERE NOT (19 not between coalesce((select max(d*t1.c) from t1 where (select cast(avg((b)) AS integer) from t1) in (select ( - -(abs(case max(b) when cast(avg( -13-11) AS integer) then count(distinct a-e) else ~ -cast(avg((c)) AS integer)-min(17)+count(*) end) | (min(e)))-min((19))) from t1 union select count(distinct 13) from t1)),case when  -e | 19 between  -11 and f then 19 else 19 end) and (f))}\n} {300}\ndo_test randexpr-2.464 {\n  db eval {SELECT (abs((select abs(case  -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then  -min(e) else  -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b | d in (select max(d) from t1 union select  -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) | e+t1.a)/abs(t1.d)) FROM t1 WHERE t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17)}\n} {}\ndo_test randexpr-2.465 {\n  db eval {SELECT (abs((select abs(case  -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then  -min(e) else  -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b | d in (select max(d) from t1 union select  -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) | e+t1.a)/abs(t1.d)) FROM t1 WHERE NOT (t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17))}\n} {201}\ndo_test randexpr-2.466 {\n  db eval {SELECT (abs((select abs(case  -max(e)+max(t1.f)+(count(*)* -count(distinct case e when 19 then c else 13 end))*~min(t1.a) when cast(avg(t1.a) AS integer) then  -min(e) else  -count(*) end) from t1)*coalesce((select (t1.a) from t1 where case when c+t1.b-b & d in (select max(d) from t1 union select  -max(19) from t1) then t1.b else f end=t1.d),t1.b)*(t1.d) & e+t1.a)/abs(t1.d)) FROM t1 WHERE NOT (t1.f in (19,d*t1.d,(select min((select count(*)*min((17)+(abs(11)/abs(+~coalesce((select max(f) from t1 where 13 not between t1.c and t1.a),t1.e)-11))) from t1)) from t1)+17))}\n} {0}\ndo_test randexpr-2.467 {\n  db eval {SELECT d+case when (coalesce((select max(t1.a) from t1 where t1.a not in (t1.d,f*(select count(distinct t1.d) from t1)+t1.f,c)),b)-c-17-t1.c)-case when 13*t1.a-19*e<>11 then f when t1.f not between 11 and t1.d then b else f end=t1.d then t1.f when not e>t1.f then 17 else b end FROM t1 WHERE exists(select 1 from t1 where 11* -d>=e) or t1.c<+ -e*11 or (17 not between t1.d and case t1.a when t1.a then t1.d+f-b else 11 end | t1.e)}\n} {417}\ndo_test randexpr-2.468 {\n  db eval {SELECT d+case when (coalesce((select max(t1.a) from t1 where t1.a not in (t1.d,f*(select count(distinct t1.d) from t1)+t1.f,c)),b)-c-17-t1.c)-case when 13*t1.a-19*e<>11 then f when t1.f not between 11 and t1.d then b else f end=t1.d then t1.f when not e>t1.f then 17 else b end FROM t1 WHERE NOT (exists(select 1 from t1 where 11* -d>=e) or t1.c<+ -e*11 or (17 not between t1.d and case t1.a when t1.a then t1.d+f-b else 11 end | t1.e))}\n} {}\ndo_test randexpr-2.469 {\n  db eval {SELECT t1.f-coalesce((select max(+e | b) from t1 where case when  -(abs(11)/abs(~(19 | t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 | 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e}\n} {}\ndo_test randexpr-2.470 {\n  db eval {SELECT t1.f-coalesce((select max(+e | b) from t1 where case when  -(abs(11)/abs(~(19 | t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 | 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE NOT (case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e)}\n} {0}\ndo_test randexpr-2.471 {\n  db eval {SELECT t1.f-coalesce((select max(+e & b) from t1 where case when  -(abs(11)/abs(~(19 & t1.d)))-~c*e not in (19,b*t1.b,b) then 11 when f<=13 then d else t1.d end in (select (count(*))-cast(avg(11 & 17*t1.b) AS integer) from t1 union select count(distinct a-17) from t1)),t1.c)-c FROM t1 WHERE NOT (case when (t1.f*a<=11+d+coalesce((select max(19+19) from t1 where 13 in (select min(f)+cast(avg((abs(t1.e)/abs((select count(distinct c) from t1)))) AS integer)+(~cast(avg(e) AS integer))-min(c) from t1 union select count(*) from t1)),b)) then (a) else t1.b end-t1.b<=t1.b and 13 in (select t1.e from t1 union select t1.e from t1) and a<e)}\n} {0}\ndo_test randexpr-2.472 {\n  db eval {SELECT coalesce((select max(t1.c) from t1 where case when (t1.e*19*f-t1.b in (select cast(avg(d-~d) AS integer) from t1 union select +( -case +~count(*)*count(distinct (c)) when cast(avg(19) AS integer) then min(c) else count(distinct 17) end*cast(avg((13)) AS integer)-max(11)+(count(distinct b))) from t1)) then +11 else t1.b end>=t1.d or (exists(select 1 from t1 where (t1.e=t1.c)))),t1.c)-11 FROM t1 WHERE (not exists(select 1 from t1 where 11+t1.c-13>=t1.c or not exists(select 1 from t1 where a in (select b from t1 union select 19-d from t1) and ((abs(a+(abs(coalesce((select t1.d from t1 where exists(select 1 from t1 where case when t1.e>= -13 or  -e<>f then d when t1.c=13 then (b) else t1.c end not between 13 and b)),d))/abs(t1.d))-b)/abs(t1.a))<> -13 and exists(select 1 from t1 where 19<>e) or 13>=19))))}\n} {}\ndo_test randexpr-2.473 {\n  db eval {SELECT coalesce((select max(t1.c) from t1 where case when (t1.e*19*f-t1.b in (select cast(avg(d-~d) AS integer) from t1 union select +( -case +~count(*)*count(distinct (c)) when cast(avg(19) AS integer) then min(c) else count(distinct 17) end*cast(avg((13)) AS integer)-max(11)+(count(distinct b))) from t1)) then +11 else t1.b end>=t1.d or (exists(select 1 from t1 where (t1.e=t1.c)))),t1.c)-11 FROM t1 WHERE NOT ((not exists(select 1 from t1 where 11+t1.c-13>=t1.c or not exists(select 1 from t1 where a in (select b from t1 union select 19-d from t1) and ((abs(a+(abs(coalesce((select t1.d from t1 where exists(select 1 from t1 where case when t1.e>= -13 or  -e<>f then d when t1.c=13 then (b) else t1.c end not between 13 and b)),d))/abs(t1.d))-b)/abs(t1.a))<> -13 and exists(select 1 from t1 where 19<>e) or 13>=19)))))}\n} {289}\ndo_test randexpr-2.474 {\n  db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d | e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) | c FROM t1 WHERE exists(select 1 from t1 where c in (t1.a,(select count(distinct  -t1.d) from t1),t1.b)) or (~d=t1.e)}\n} {}\ndo_test randexpr-2.475 {\n  db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d | e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) | c FROM t1 WHERE NOT (exists(select 1 from t1 where c in (t1.a,(select count(distinct  -t1.d) from t1),t1.b)) or (~d=t1.e))}\n} {300}\ndo_test randexpr-2.476 {\n  db eval {SELECT +coalesce((select max(11) from t1 where not case d+t1.c*coalesce((select max(coalesce((select d & e from t1 where 17 not between coalesce((select (t1.d) from t1 where t1.a between (select max(t1.b+d+t1.a) from t1)-t1.e and 17),t1.a) and 11),19)) from t1 where t1.d<t1.b),d)+t1.e when t1.f then t1.d else t1.f end not in (e,t1.c,t1.c)),c) & c FROM t1 WHERE NOT (exists(select 1 from t1 where c in (t1.a,(select count(distinct  -t1.d) from t1),t1.b)) or (~d=t1.e))}\n} {300}\ndo_test randexpr-2.477 {\n  db eval {SELECT case when ((select  -min(e)+cast(avg(t1.a) AS integer) from t1)>t1.d*a) then (abs(~a)/abs(+11))*f when (c-(coalesce((select 11 from t1 where t1.d in (case when (19)+11>=c then 19 when e<>b then 13 else c end,a,13)),17))+13) not between 11 and t1.c then (t1.b) else 17 end+b FROM t1 WHERE a*b*11 in (select case when not coalesce((select max(~13 | (select abs((count(distinct t1.f))*cast(avg(t1.f) AS integer)+(max(t1.e))) from t1)) from t1 where coalesce((select max(11) from t1 where t1.b=19),b) in (f,11,19) and t1.f between a and t1.c or 19=t1.a and d=17 or c>=t1.f or t1.d<>t1.c),11)*c in (select f from t1 union select  -t1.b from t1) then t1.c when c not between f and 13 then e else  -e end from t1 union select e from t1)}\n} {}\ndo_test randexpr-2.478 {\n  db eval {SELECT case when ((select  -min(e)+cast(avg(t1.a) AS integer) from t1)>t1.d*a) then (abs(~a)/abs(+11))*f when (c-(coalesce((select 11 from t1 where t1.d in (case when (19)+11>=c then 19 when e<>b then 13 else c end,a,13)),17))+13) not between 11 and t1.c then (t1.b) else 17 end+b FROM t1 WHERE NOT (a*b*11 in (select case when not coalesce((select max(~13 | (select abs((count(distinct t1.f))*cast(avg(t1.f) AS integer)+(max(t1.e))) from t1)) from t1 where coalesce((select max(11) from t1 where t1.b=19),b) in (f,11,19) and t1.f between a and t1.c or 19=t1.a and d=17 or c>=t1.f or t1.d<>t1.c),11)*c in (select f from t1 union select  -t1.b from t1) then t1.c when c not between f and 13 then e else  -e end from t1 union select e from t1))}\n} {217}\ndo_test randexpr-2.479 {\n  db eval {SELECT t1.d-coalesce((select  -t1.c from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d<=case t1.d+e when case when d>19 then 11+t1.c else t1.b end-t1.f-t1.e then (abs(t1.d-19*t1.b)/abs(13+case when t1.f in (select count(*)-count(distinct t1.b) from t1 union select (max((t1.f))) from t1) then (((t1.d))) when t1.b not in (t1.d,13,a) then t1.d else 19 end*t1.c))-t1.d else e end))),13)+c*t1.a FROM t1 WHERE exists(select 1 from t1 where ~coalesce((select a+t1.a from t1 where ~(abs(c)/abs(17 | +13))-t1.f in (select f from t1 union select case when t1.b between 11*e and f then e when a in (e* -t1.f-f,coalesce((select 17 from t1 where t1.e in (select (cast(avg(e) AS integer)) from t1 union select max(b) from t1)),a),d) then t1.c else (f) end from t1)),f) between  -19 and (13) or t1.f<>t1.a)}\n} {30700}\ndo_test randexpr-2.480 {\n  db eval {SELECT t1.d-coalesce((select  -t1.c from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.d<=case t1.d+e when case when d>19 then 11+t1.c else t1.b end-t1.f-t1.e then (abs(t1.d-19*t1.b)/abs(13+case when t1.f in (select count(*)-count(distinct t1.b) from t1 union select (max((t1.f))) from t1) then (((t1.d))) when t1.b not in (t1.d,13,a) then t1.d else 19 end*t1.c))-t1.d else e end))),13)+c*t1.a FROM t1 WHERE NOT (exists(select 1 from t1 where ~coalesce((select a+t1.a from t1 where ~(abs(c)/abs(17 | +13))-t1.f in (select f from t1 union select case when t1.b between 11*e and f then e when a in (e* -t1.f-f,coalesce((select 17 from t1 where t1.e in (select (cast(avg(e) AS integer)) from t1 union select max(b) from t1)),a),d) then t1.c else (f) end from t1)),f) between  -19 and (13) or t1.f<>t1.a))}\n} {}\ndo_test randexpr-2.481 {\n  db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case  -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select  -min(13)-(max(t1.a)) from t1) then 19 else  -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c | d when  -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE 13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17))}\n} {}\ndo_test randexpr-2.482 {\n  db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case  -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select  -min(13)-(max(t1.a)) from t1) then 19 else  -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c | d when  -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE NOT (13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17)))}\n} {227691}\ndo_test randexpr-2.483 {\n  db eval {SELECT (abs((abs(t1.b*t1.b*t1.f+a)/abs(t1.f))*t1.a-case  -(abs(coalesce((select (case when 11*19 in (select count(*) from t1 union select  -min(13)-(max(t1.a)) from t1) then 19 else  -17 end) from t1 where t1.e between 13 and (a)),t1.b)+d)/abs(t1.f))-t1.b-t1.c & d when  -t1.f then c else 17 end)/abs(13))-b*t1.d FROM t1 WHERE NOT (13 in (t1.b,17*e+c*a,coalesce((select max(d) from t1 where +f+b not in (a,t1.a*~t1.c | t1.b-case when t1.a<=case when t1.f in (b,11,e) then d else t1.e end+f then 19 else (f) end-b*13- -t1.f-17,t1.c)),17)))}\n} {227691}\ndo_test randexpr-2.484 {\n  db eval {SELECT coalesce((select t1.c*f from t1 where t1.f-+coalesce((select max(t1.d) from t1 where  - -t1.e in (select f from t1 union select t1.e from t1)),a)+case when 19 not in (t1.e,case when ~t1.a<>e+a then  -t1.d else t1.e end,f) then t1.b when  -(t1.e) in (e,(19),t1.c) then t1.f else e end+17*t1.c+d>b),t1.c)+a FROM t1 WHERE t1.b>=~b}\n} {180100}\ndo_test randexpr-2.485 {\n  db eval {SELECT coalesce((select t1.c*f from t1 where t1.f-+coalesce((select max(t1.d) from t1 where  - -t1.e in (select f from t1 union select t1.e from t1)),a)+case when 19 not in (t1.e,case when ~t1.a<>e+a then  -t1.d else t1.e end,f) then t1.b when  -(t1.e) in (e,(19),t1.c) then t1.f else e end+17*t1.c+d>b),t1.c)+a FROM t1 WHERE NOT (t1.b>=~b)}\n} {}\ndo_test randexpr-2.486 {\n  db eval {SELECT case case when case when 13 between coalesce((select max(t1.f) from t1 where b+f in (b+(coalesce((select t1.f from t1 where (t1.c)>=17 or 19 not in (11,t1.e,c)),13)),b,t1.e) and c<=e and not t1.b<>13 and 19 not between t1.c and a or c between f and f),t1.c) and b then t1.b when 13<>t1.a then 11 else d end in (select 13 from t1 union select 19 from t1) then t1.c when t1.f not in (17,b,b) then t1.f else e end when t1.e then t1.e else  -d end FROM t1 WHERE case when not exists(select 1 from t1 where t1.f not between coalesce((select coalesce((select max(+case t1.a when f then t1.a else t1.e end+case when t1.f>t1.d or 11 in (t1.e,11,b) then b else a end) from t1 where t1.f in (select a from t1 union select d from t1)),t1.d) from t1 where t1.a=b),(t1.c)) and d) then (select case max(t1.a) when ~min((11)) | min(e) then max(t1.e) else abs(max(t1.c)*count(distinct 19)) end from t1) else t1.b end<>b}\n} {}\ndo_test randexpr-2.487 {\n  db eval {SELECT case case when case when 13 between coalesce((select max(t1.f) from t1 where b+f in (b+(coalesce((select t1.f from t1 where (t1.c)>=17 or 19 not in (11,t1.e,c)),13)),b,t1.e) and c<=e and not t1.b<>13 and 19 not between t1.c and a or c between f and f),t1.c) and b then t1.b when 13<>t1.a then 11 else d end in (select 13 from t1 union select 19 from t1) then t1.c when t1.f not in (17,b,b) then t1.f else e end when t1.e then t1.e else  -d end FROM t1 WHERE NOT (case when not exists(select 1 from t1 where t1.f not between coalesce((select coalesce((select max(+case t1.a when f then t1.a else t1.e end+case when t1.f>t1.d or 11 in (t1.e,11,b) then b else a end) from t1 where t1.f in (select a from t1 union select d from t1)),t1.d) from t1 where t1.a=b),(t1.c)) and d) then (select case max(t1.a) when ~min((11)) | min(e) then max(t1.e) else abs(max(t1.c)*count(distinct 19)) end from t1) else t1.b end<>b)}\n} {-400}\ndo_test randexpr-2.488 {\n  db eval {SELECT case  -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) |  - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when  -t1.b then  -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then  -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) |  -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.489 {\n  db eval {SELECT case  -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) |  - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE NOT (coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when  -t1.b then  -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then  -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) |  -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1))}\n} {600}\ndo_test randexpr-2.490 {\n  db eval {SELECT case  -coalesce((select max(case when case when t1.e in (11*t1.e*17,(select (min(b) &  - -+cast(avg(17) AS integer)*max((t1.c))+cast(avg(t1.a) AS integer))+(( -(min(t1.c))))*count(*) from t1), -~b*t1.d+t1.d) then d else t1.a end<(t1.c) then t1.f else e end) from t1 where 13<>c),e)-(t1.b) when t1.a then 17 else t1.f end FROM t1 WHERE NOT (coalesce((select max(t1.e) from t1 where (not exists(select 1 from t1 where b<+c))),case when b | ~case t1.a when  -t1.b then  -t1.f else t1.f end*f+f in (select t1.b from t1 union select t1.c from t1) then  -(t1.f) when a<>11 then (d) else 11 end) in (select abs(~(abs(case (min(t1.b)*abs(count(distinct a)+count(*) |  -count(distinct a)))- -max(19) when max(t1.e) then min(d) else (max(a)) end))) from t1 union select count(*) from t1))}\n} {600}\ndo_test randexpr-2.491 {\n  db eval {SELECT +case when case when ~t1.b<=case when ~17*19 | 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then  -t1.f else t1.d end FROM t1 WHERE 19*++t1.e=coalesce((select case  -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then  - - -f else b end then  -11 else  -d end from t1 where ( -t1.c<f)),t1.e)+19}\n} {}\ndo_test randexpr-2.492 {\n  db eval {SELECT +case when case when ~t1.b<=case when ~17*19 | 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then  -t1.f else t1.d end FROM t1 WHERE NOT (19*++t1.e=coalesce((select case  -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then  - - -f else b end then  -11 else  -d end from t1 where ( -t1.c<f)),t1.e)+19)}\n} {-600}\ndo_test randexpr-2.493 {\n  db eval {SELECT +case when case when ~t1.b<=case when ~17*19 & 11*11*f between t1.c and b then t1.a when e in (t1.a,t1.e,e) then t1.c else 19 end-t1.c-17+a then (t1.d) when 13 not between 13 and 19 then c else c end=(f) or d<t1.f then  -t1.f else t1.d end FROM t1 WHERE NOT (19*++t1.e=coalesce((select case  -t1.f when case when d-t1.a*d*coalesce((select max(t1.d) from t1 where b-b> -coalesce((select t1.b from t1 where c*13+c<>t1.f),a)),t1.e)+t1.f=t1.f then  - - -f else b end then  -11 else  -d end from t1 where ( -t1.c<f)),t1.e)+19)}\n} {-600}\ndo_test randexpr-2.494 {\n  db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) | cast(avg(t1.d) AS integer))+count(distinct  -t1.a)+count(*)) from t1 union select  -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select  -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE (a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end)}\n} {39800}\ndo_test randexpr-2.495 {\n  db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) | cast(avg(t1.d) AS integer))+count(distinct  -t1.a)+count(*)) from t1 union select  -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select  -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE NOT ((a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end))}\n} {}\ndo_test randexpr-2.496 {\n  db eval {SELECT case when case when 19 in (select abs(abs(count(distinct f))*~~~count(*)-abs(+abs(count(*))* -cast(avg(17) AS integer) & cast(avg(t1.d) AS integer))+count(distinct  -t1.a)+count(*)) from t1 union select  -cast(avg(19) AS integer) from t1) then b* -b-c else t1.e*c end=17 then d else coalesce((select  -11 from t1 where e<e),a)-c end+d*t1.a FROM t1 WHERE (a-t1.b+19<>case when b between ~11 and (abs(case when (coalesce((select max(+13) from t1 where not not exists(select 1 from t1 where t1.b+e in (b,t1.b,t1.d)) and 13 not in (d,f,17)),t1.a) not in (t1.f,17,17)) then coalesce((select max(19) from t1 where (17) in (t1.a,17,a)),t1.b) when b in (13,t1.a,b) then t1.c else d end)/abs(11)) then t1.f when t1.d>19 then d else d end)}\n} {39800}\ndo_test randexpr-2.497 {\n  db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) | cast(avg((select  -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end | max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select  -count(*) from t1))),~17) FROM t1 WHERE case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f}\n} {-400}\ndo_test randexpr-2.498 {\n  db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) | cast(avg((select  -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end | max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select  -count(*) from t1))),~17) FROM t1 WHERE NOT (case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f)}\n} {}\ndo_test randexpr-2.499 {\n  db eval {SELECT t1.a-coalesce((select t1.e from t1 where not exists(select 1 from t1 where a in (select min(d-11) & cast(avg((select  -case count(*) when count(*) then +abs(+case ~min((abs(13- -a)/abs(t1.c))) when ~~count(*)+min((13)) then max(t1.e) else cast(avg(t1.a) AS integer) end & max(c))+count(*) else count(*) end*max(t1.d) from t1)) AS integer)+max(t1.c)*count(distinct f) from t1 union select  -count(*) from t1))),~17) FROM t1 WHERE case 11 when coalesce((select coalesce((select 19 from t1 where t1.b not between t1.e and e and not not exists(select 1 from t1 where (e in ((abs(c)/abs(17)),(d) | e,(select count(distinct t1.b) from t1)-b)))),case d when a then f else t1.c end) | (t1.d) | b from t1 where t1.c not in (t1.a,19,11)),t1.b)-d then t1.e else t1.d end*t1.d<>f}\n} {-400}\ndo_test randexpr-2.500 {\n  db eval {SELECT case b*coalesce((select coalesce((select max(coalesce((select t1.b from t1 where t1.a<>11),17+~19)) from t1 where (t1.e<>e)),case 13 when 17 then 13 else c-coalesce((select max(case when (select min(d) from t1) in (select max(13) from t1 union select min(t1.f) from t1) then 13 else t1.a end*c) from t1 where t1.b<(t1.b)),f) end) from t1 where 19<=t1.e),(t1.b)) when t1.b then e else t1.d end+t1.c FROM t1 WHERE b+coalesce((select max((d)) from t1 where e=b),t1.c)*((select  -(min(coalesce((select 19+(abs((abs((t1.a)*case f when c then t1.b else t1.d end-e)/abs((t1.f))))/abs( -t1.e))+b from t1 where 13 not between d and t1.c),t1.f))) from t1))*case e when 19 then t1.d else t1.b end+t1.e not in (t1.d,t1.a,17)}\n} {700}\ndo_test randexpr-2.501 {\n  db eval {SELECT case b*coalesce((select coalesce((select max(coalesce((select t1.b from t1 where t1.a<>11),17+~19)) from t1 where (t1.e<>e)),case 13 when 17 then 13 else c-coalesce((select max(case when (select min(d) from t1) in (select max(13) from t1 union select min(t1.f) from t1) then 13 else t1.a end*c) from t1 where t1.b<(t1.b)),f) end) from t1 where 19<=t1.e),(t1.b)) when t1.b then e else t1.d end+t1.c FROM t1 WHERE NOT (b+coalesce((select max((d)) from t1 where e=b),t1.c)*((select  -(min(coalesce((select 19+(abs((abs((t1.a)*case f when c then t1.b else t1.d end-e)/abs((t1.f))))/abs( -t1.e))+b from t1 where 13 not between d and t1.c),t1.f))) from t1))*case e when 19 then t1.d else t1.b end+t1.e not in (t1.d,t1.a,17))}\n} {}\ndo_test randexpr-2.502 {\n  db eval {SELECT case when case when exists(select 1 from t1 where 17 in (select b from t1 union select 13 from t1)) and 19+a in (select count(distinct  -(select min(t1.a-f) from t1)) from t1 union select min(case when 11 between coalesce((select max(t1.b) from t1 where case when t1.d<>c or t1.b>=t1.a then ( -11) else t1.d end>=t1.a),t1.c) and  -17 then  -t1.f else e end) from t1) then a else 19 end+t1.e in (select e from t1 union select  -t1.b from t1) then t1.b when not (f) between f and t1.c then t1.e else e end FROM t1 WHERE 17>coalesce((select t1.b from t1 where t1.a+case when b in (19,t1.c,case t1.e when d-(b) then t1.f else 13 end) then 13 when d in (select count(distinct t1.a) from t1 union select case ~max(f) when cast(avg(b) AS integer) then max(d) else min(t1.f) end*min(e) from t1) or (t1.c<a) then t1.f else  -t1.c end<f or 13<=f),c) or 19>=t1.e}\n} {}\ndo_test randexpr-2.503 {\n  db eval {SELECT case when case when exists(select 1 from t1 where 17 in (select b from t1 union select 13 from t1)) and 19+a in (select count(distinct  -(select min(t1.a-f) from t1)) from t1 union select min(case when 11 between coalesce((select max(t1.b) from t1 where case when t1.d<>c or t1.b>=t1.a then ( -11) else t1.d end>=t1.a),t1.c) and  -17 then  -t1.f else e end) from t1) then a else 19 end+t1.e in (select e from t1 union select  -t1.b from t1) then t1.b when not (f) between f and t1.c then t1.e else e end FROM t1 WHERE NOT (17>coalesce((select t1.b from t1 where t1.a+case when b in (19,t1.c,case t1.e when d-(b) then t1.f else 13 end) then 13 when d in (select count(distinct t1.a) from t1 union select case ~max(f) when cast(avg(b) AS integer) then max(d) else min(t1.f) end*min(e) from t1) or (t1.c<a) then t1.f else  -t1.c end<f or 13<=f),c) or 19>=t1.e)}\n} {500}\ndo_test randexpr-2.504 {\n  db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a | t1.e+t1.e in (select  -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then  -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then  -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE ((select  -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f}\n} {300}\ndo_test randexpr-2.505 {\n  db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a | t1.e+t1.e in (select  -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then  -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then  -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE NOT (((select  -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f)}\n} {}\ndo_test randexpr-2.506 {\n  db eval {SELECT c*(select (count(distinct (abs(case when t1.c<>e then e else 19 end)/abs(case when case when +case when a & t1.e+t1.e in (select  -count(*) from t1 union select (max(case when 11 not in (t1.f,11,f) then c when c not in (d,t1.f,t1.f) then  -t1.a else 13 end)) from t1) then 17 else 13 end>=t1.e then  -11 when (t1.f)>c then 11 else 11 end<=11 and not exists(select 1 from t1 where t1.a between t1.e and e) then 19 else (17) end)))) from t1) FROM t1 WHERE ((select  -case min(a-13*17+c*coalesce((select 19 from t1 where 19>=t1.d),(t1.b))+t1.e) when +(min(17)) then min(17) else +min(b) end* -cast(avg(19) AS integer)*count(*) from t1) not between a and d) and +c in (c,t1.d,d) or d<>t1.f}\n} {300}\ndo_test randexpr-2.507 {\n  db eval {SELECT a*coalesce((select t1.d+17 from t1 where 13*case a when t1.a then 11 else  -t1.a-d-11-coalesce((select max(e-coalesce((select d from t1 where a<=t1.d*(coalesce((select max( -t1.d) from t1 where t1.f not in (11, -t1.d,17) and t1.a between (13) and c and e not in (t1.b,t1.b,b)),b))), -17)) from t1 where t1.b<>a),19)+t1.d+t1.c end<13),t1.e) FROM t1 WHERE t1.e not between f and 19}\n} {50000}\ndo_test randexpr-2.508 {\n  db eval {SELECT a*coalesce((select t1.d+17 from t1 where 13*case a when t1.a then 11 else  -t1.a-d-11-coalesce((select max(e-coalesce((select d from t1 where a<=t1.d*(coalesce((select max( -t1.d) from t1 where t1.f not in (11, -t1.d,17) and t1.a between (13) and c and e not in (t1.b,t1.b,b)),b))), -17)) from t1 where t1.b<>a),19)+t1.d+t1.c end<13),t1.e) FROM t1 WHERE NOT (t1.e not between f and 19)}\n} {}\ndo_test randexpr-2.509 {\n  db eval {SELECT 17 | case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE ~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then  -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1)}\n} {}\ndo_test randexpr-2.510 {\n  db eval {SELECT 17 | case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE NOT (~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then  -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1))}\n} {219}\ndo_test randexpr-2.511 {\n  db eval {SELECT 17 & case case when exists(select 1 from t1 where (not t1.d between a and f)) then t1.e when not (b=coalesce((select ~t1.c-case when (select (count(*))*(count(distinct t1.f)) from t1)>=11 then b else 19 end from t1 where not not (13<=e) and t1.b=t1.b),13)) then coalesce((select max((abs(11)/abs(t1.b))) from t1 where t1.a not between t1.e and t1.b),(t1.a)) else t1.a end when c then 13 else 19 end+b FROM t1 WHERE NOT (~t1.a+t1.d+c*17 | (select max(t1.d)*abs(case (max(t1.f)+count(distinct t1.b))*(count(distinct f)) when count(distinct e) then  -min(t1.e) else min(t1.f) end)+max(b)+count(distinct t1.d) from t1) in (select max(t1.d*(19)) from t1 union select count(distinct case when t1.c+b in (select max(e) from t1 union select cast(avg(f) AS integer) from t1) then (17) when e not in (c,d,19) or 11=19 then (19) else t1.e end+t1.a) from t1))}\n} {17}\ndo_test randexpr-2.512 {\n  db eval {SELECT case when coalesce((select max((+t1.a+17+11+case when (abs(19)/abs(t1.a)) in (select ~(case count(*) when min( -c) then count(distinct b) else count(*) end) from t1 union select  -min(t1.e) from t1) or 13>=t1.a then case c when 13 then t1.d else e end when  -t1.e<=t1.a then t1.c else t1.c end)) from t1 where not t1.c= -t1.f),b)=f and t1.e<=(t1.f) then ~(t1.a) when 17=e then 19 else t1.b end FROM t1 WHERE case when  -t1.f in (select (13) from t1 union select coalesce((select max(coalesce((select (~13) from t1 where t1.b>(11)),e*t1.c)) from t1 where (not (abs(t1.c)/abs(a))>=c)),t1.d) from t1) then  -t1.e+ -a-coalesce((select t1.d from t1 where not exists(select 1 from t1 where  -b=t1.f-f)),t1.c)*17 when 19<=11 then 19 else t1.d end>=b}\n} {200}\ndo_test randexpr-2.513 {\n  db eval {SELECT case when coalesce((select max((+t1.a+17+11+case when (abs(19)/abs(t1.a)) in (select ~(case count(*) when min( -c) then count(distinct b) else count(*) end) from t1 union select  -min(t1.e) from t1) or 13>=t1.a then case c when 13 then t1.d else e end when  -t1.e<=t1.a then t1.c else t1.c end)) from t1 where not t1.c= -t1.f),b)=f and t1.e<=(t1.f) then ~(t1.a) when 17=e then 19 else t1.b end FROM t1 WHERE NOT (case when  -t1.f in (select (13) from t1 union select coalesce((select max(coalesce((select (~13) from t1 where t1.b>(11)),e*t1.c)) from t1 where (not (abs(t1.c)/abs(a))>=c)),t1.d) from t1) then  -t1.e+ -a-coalesce((select t1.d from t1 where not exists(select 1 from t1 where  -b=t1.f-f)),t1.c)*17 when 19<=11 then 19 else t1.d end>=b)}\n} {}\ndo_test randexpr-2.514 {\n  db eval {SELECT +(case when t1.a<=a then t1.d when ((abs(t1.a)/abs((coalesce((select t1.e from t1 where t1.f>=t1.c),e))))) between coalesce((select case when not 19> -11 then (case when t1.d in (select e from t1 union select f from t1) then  -d when t1.b not between 11 and t1.d then (19) else c end) else t1.e end from t1 where not exists(select 1 from t1 where e not in (t1.d,a, -a)) and t1.d>t1.b),a) and t1.a then d else b end)-17 FROM t1 WHERE (+e*t1.d in (select (+abs(abs(min(~+b)-min(a)-case  -case abs(max(t1.c)) when max(e) then count(*) else count(distinct 19) end- -max(t1.a) when count(distinct t1.a) then (count(*)) else min(t1.f) end)))-(count(*)) from t1 union select max(t1.f) from t1) or ~c*case when not exists(select 1 from t1 where t1.f in (t1.f,t1.a,d)) then t1.c when t1.c<t1.d then (17) else e end+t1.b |  -((c)) not between a and 17)}\n} {383}\ndo_test randexpr-2.515 {\n  db eval {SELECT +(case when t1.a<=a then t1.d when ((abs(t1.a)/abs((coalesce((select t1.e from t1 where t1.f>=t1.c),e))))) between coalesce((select case when not 19> -11 then (case when t1.d in (select e from t1 union select f from t1) then  -d when t1.b not between 11 and t1.d then (19) else c end) else t1.e end from t1 where not exists(select 1 from t1 where e not in (t1.d,a, -a)) and t1.d>t1.b),a) and t1.a then d else b end)-17 FROM t1 WHERE NOT ((+e*t1.d in (select (+abs(abs(min(~+b)-min(a)-case  -case abs(max(t1.c)) when max(e) then count(*) else count(distinct 19) end- -max(t1.a) when count(distinct t1.a) then (count(*)) else min(t1.f) end)))-(count(*)) from t1 union select max(t1.f) from t1) or ~c*case when not exists(select 1 from t1 where t1.f in (t1.f,t1.a,d)) then t1.c when t1.c<t1.d then (17) else e end+t1.b |  -((c)) not between a and 17))}\n} {}\ndo_test randexpr-2.516 {\n  db eval {SELECT  -case when coalesce((select max(case when ~(+case when t1.b*t1.b>t1.e then t1.a when  -d=t1.e or t1.c not between t1.c and e then c else t1.d end)- -17 in (select a from t1 union select  -t1.e from t1) then 19 else a end) from t1 where t1.a in (select  -a from t1 union select 19 from t1)),t1.a)<>t1.d then 13 when a in (19,d,c) and a<11 then t1.a else b end+t1.a-t1.b FROM t1 WHERE c>=t1.e}\n} {}\ndo_test randexpr-2.517 {\n  db eval {SELECT  -case when coalesce((select max(case when ~(+case when t1.b*t1.b>t1.e then t1.a when  -d=t1.e or t1.c not between t1.c and e then c else t1.d end)- -17 in (select a from t1 union select  -t1.e from t1) then 19 else a end) from t1 where t1.a in (select  -a from t1 union select 19 from t1)),t1.a)<>t1.d then 13 when a in (19,d,c) and a<11 then t1.a else b end+t1.a-t1.b FROM t1 WHERE NOT (c>=t1.e)}\n} {-113}\ndo_test randexpr-2.518 {\n  db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) | count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE ~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then  -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else  -t1.f-t1.b end*t1.a not between  -e and t1.e}\n} {500}\ndo_test randexpr-2.519 {\n  db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) | count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE NOT (~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then  -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else  -t1.f-t1.b end*t1.a not between  -e and t1.e)}\n} {}\ndo_test randexpr-2.520 {\n  db eval {SELECT coalesce((select case coalesce((select max(19) from t1 where +case when exists(select 1 from t1 where not exists(select 1 from t1 where not c in (case when e>=c then b else t1.b end,t1.b,t1.e))) then a-f+13-t1.f+19 when f>=t1.e then t1.e else t1.c end+17 in (select count(distinct 19) from t1 union select cast(avg(b) AS integer) & count(distinct 11)-count(*) from t1)),a) when b then 17 else c end from t1 where t1.f<=t1.e),t1.e) FROM t1 WHERE ~~+d-d*19*case ~(select count(*) from t1)-11 when 19 then  -+(abs(t1.a)/abs(a)) | (f)-(abs(+t1.c)/abs((select ~+max(13*e)+min(f)*count(distinct 13) from t1)))*t1.a else  -t1.f-t1.b end*t1.a not between  -e and t1.e}\n} {500}\ndo_test randexpr-2.521 {\n  db eval {SELECT a*17+ -case when not exists(select 1 from t1 where 11=t1.d) then 11-b when case when t1.c<>t1.c++t1.a or t1.c*t1.a+d-f between 19 and case when not t1.e>=11 and t1.b<=t1.c then coalesce((select max(a) from t1 where 19=11),f) when f not in (t1.b,13,b) then f else  -d end then d else t1.c end in (select 17 from t1 union select d from t1) then 17 else b end FROM t1 WHERE  -(+~ -d++c+b)>=t1.a-case when coalesce((select t1.a-(select max(t1.e) from t1)-(abs(11)/abs(17))+t1.d from t1 where not (not exists(select 1 from t1 where c=t1.c)) or t1.b in (select abs(max(11)+count(*)) from t1 union select ((max(a))) from t1)),f)>=a then t1.f when d not in (11,c,17) then a else 19 end}\n} {}\ndo_test randexpr-2.522 {\n  db eval {SELECT a*17+ -case when not exists(select 1 from t1 where 11=t1.d) then 11-b when case when t1.c<>t1.c++t1.a or t1.c*t1.a+d-f between 19 and case when not t1.e>=11 and t1.b<=t1.c then coalesce((select max(a) from t1 where 19=11),f) when f not in (t1.b,13,b) then f else  -d end then d else t1.c end in (select 17 from t1 union select d from t1) then 17 else b end FROM t1 WHERE NOT ( -(+~ -d++c+b)>=t1.a-case when coalesce((select t1.a-(select max(t1.e) from t1)-(abs(11)/abs(17))+t1.d from t1 where not (not exists(select 1 from t1 where c=t1.c)) or t1.b in (select abs(max(11)+count(*)) from t1 union select ((max(a))) from t1)),f)>=a then t1.f when d not in (11,c,17) then a else 19 end)}\n} {1889}\ndo_test randexpr-2.523 {\n  db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a | b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where  -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c}\n} {13}\ndo_test randexpr-2.524 {\n  db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a | b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where  -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c)}\n} {}\ndo_test randexpr-2.525 {\n  db eval {SELECT coalesce((select max(t1.b+a) from t1 where case (select count(distinct b*case when t1.f*+~a & b+17*13+a+11 in (select c from t1 union select d from t1) then t1.f else t1.b end) from t1) when t1.a then f else t1.c end+ -f between 17 and d and b in (13,t1.e,t1.e) and d not between t1.f and d),13) FROM t1 WHERE coalesce((select max(t1.d) from t1 where (coalesce((select ~t1.c from t1 where  -t1.a<=c*+d or not (case when (t1.b)>=t1.d then t1.e when 17<d then (a) else 11 end>a and a<>e and t1.e<t1.e) or 19<=t1.c),(c))+b*t1.c+17*t1.a | 11+(t1.f)>=19)),19)<>t1.c}\n} {13}\ndo_test randexpr-2.526 {\n  db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 | 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select  -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or  -((17))<>c)),e) FROM t1 WHERE ((abs(a)/abs(f-a)) between  -(abs(++t1.b)/abs(13)) and t1.c)}\n} {619}\ndo_test randexpr-2.527 {\n  db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 | 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select  -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or  -((17))<>c)),e) FROM t1 WHERE NOT (((abs(a)/abs(f-a)) between  -(abs(++t1.b)/abs(13)) and t1.c))}\n} {}\ndo_test randexpr-2.528 {\n  db eval {SELECT coalesce((select (t1.b-(abs(t1.b-~17 & 13+13)/abs(t1.e))* -t1.a- -19+t1.d) from t1 where exists(select 1 from t1 where 19 in (select t1.a from t1 union select  -19 from t1) and a in (c,e,13) and 19 in (select t1.a from t1 union select b from t1) or 13 in (select 19 from t1 union select d from t1) and not t1.c=t1.f or ( -t1.d between e and 19) or  -((17))<>c)),e) FROM t1 WHERE ((abs(a)/abs(f-a)) between  -(abs(++t1.b)/abs(13)) and t1.c)}\n} {619}\ndo_test randexpr-2.529 {\n  db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b | ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE +11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d}\n} {}\ndo_test randexpr-2.530 {\n  db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b | ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE NOT (+11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d)}\n} {13}\ndo_test randexpr-2.531 {\n  db eval {SELECT case when coalesce((select max(c- -b-t1.c) from t1 where t1.d between 11 and case when b & ~t1.e*(t1.f)>t1.f then a when (19<13) and not exists(select 1 from t1 where f not in (t1.a,((b)),17)) or d in ((a),t1.c,19) or (f)>13 then t1.e else f end*t1.a),t1.a)>=e then t1.d when t1.e>=c then 13 else f end FROM t1 WHERE NOT (+11 between case when t1.f>t1.c then t1.b else t1.b end and ((select count(distinct case when t1.a between (abs(coalesce((select t1.b from t1 where case when t1.d<=(abs((c))/abs(coalesce((select max(17) from t1 where 11=b),13))) then 17 when b=t1.e then d else e end-13>=(e)), -d))/abs(b)) and b then t1.d when (b) in (13,t1.b,t1.a) then f else 19 end) from t1))-d)}\n} {13}\ndo_test randexpr-2.532 {\n  db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) | max(case when t1.d<>c then  -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end | b)) from t1)+c FROM t1 WHERE f | t1.a+b>=t1.d}\n} {80}\ndo_test randexpr-2.533 {\n  db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) | max(case when t1.d<>c then  -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end | b)) from t1)+c FROM t1 WHERE NOT (f | t1.a+b>=t1.d)}\n} {}\ndo_test randexpr-2.534 {\n  db eval {SELECT (select ~abs(max(case when (case when ( -t1.a>e) then t1.a else (select (~count(*) & max(case when t1.d<>c then  -+13 else case when b between 19 and 17 or (t1.a)>=13 then 19 else t1.c end end)) from t1) end<>t1.e) then 19 when c*e+t1.b<=19 then f else (t1.d) end & b)) from t1)+c FROM t1 WHERE f | t1.a+b>=t1.d}\n} {299}\ndo_test randexpr-2.535 {\n  db eval {SELECT  -case when ~case t1.f+13+t1.a when coalesce((select max(17) from t1 where coalesce((select max(( -11)) from t1 where not exists(select 1 from t1 where case case when not exists(select 1 from t1 where (a in (select f from t1 union select b from t1))) then d when (a) in (f,t1.a, -f) then t1.a else b end when t1.d then c else t1.b end<>a and 11= -t1.a and 19=a)),11) in (select c from t1 union select 17 from t1)),t1.c) then e else 11 end=t1.d then 17 else 17 end FROM t1 WHERE not exists(select 1 from t1 where f<d or exists(select 1 from t1 where ~t1.a not between coalesce((select max(case b+(select  -case max(t1.b)- -count(distinct c)*max(t1.b) when min(17) then (count(*)) else cast(avg(t1.d) AS integer) end*max(f) from t1)+case when (abs((abs(19)/abs(e)))/abs(t1.d))*t1.a not between b and 13 then e else (e) end when d then b else 17 end) from t1 where t1.c between b and t1.f),t1.b) and a))}\n} {}\ndo_test randexpr-2.536 {\n  db eval {SELECT  -case when ~case t1.f+13+t1.a when coalesce((select max(17) from t1 where coalesce((select max(( -11)) from t1 where not exists(select 1 from t1 where case case when not exists(select 1 from t1 where (a in (select f from t1 union select b from t1))) then d when (a) in (f,t1.a, -f) then t1.a else b end when t1.d then c else t1.b end<>a and 11= -t1.a and 19=a)),11) in (select c from t1 union select 17 from t1)),t1.c) then e else 11 end=t1.d then 17 else 17 end FROM t1 WHERE NOT (not exists(select 1 from t1 where f<d or exists(select 1 from t1 where ~t1.a not between coalesce((select max(case b+(select  -case max(t1.b)- -count(distinct c)*max(t1.b) when min(17) then (count(*)) else cast(avg(t1.d) AS integer) end*max(f) from t1)+case when (abs((abs(19)/abs(e)))/abs(t1.d))*t1.a not between b and 13 then e else (e) end when d then b else 17 end) from t1 where t1.c between b and t1.f),t1.b) and a)))}\n} {-17}\ndo_test randexpr-2.537 {\n  db eval {SELECT t1.f-t1.b | coalesce((select max((select max(case  -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else  -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE t1.f<=a}\n} {}\ndo_test randexpr-2.538 {\n  db eval {SELECT t1.f-t1.b | coalesce((select max((select max(case  -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else  -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE NOT (t1.f<=a)}\n} {-49744}\ndo_test randexpr-2.539 {\n  db eval {SELECT t1.f-t1.b & coalesce((select max((select max(case  -case when t1.f>coalesce((select max(case when (17> -t1.e) then f when 19=t1.a then t1.a else a end) from t1 where t1.c<=t1.e or (t1.d)>=t1.d),t1.a)+a then f when b not in (e,t1.e,t1.b) or t1.f not in (f,t1.c, -d) or e<=13 then f else (17) end-t1.d+t1.f*13 when (t1.c) then b else  -t1.e end) from t1)) from t1 where t1.b in (t1.b,t1.f,(t1.e))),t1.e)*(a) FROM t1 WHERE NOT (t1.f<=a)}\n} {144}\ndo_test randexpr-2.540 {\n  db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select  -count(*)* -max(t1.a) | ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else  -19 end)/abs(b)) | (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a)}\n} {}\ndo_test randexpr-2.541 {\n  db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select  -count(*)* -max(t1.a) | ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else  -19 end)/abs(b)) | (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE NOT (b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a))}\n} {50800}\ndo_test randexpr-2.542 {\n  db eval {SELECT t1.e+t1.a*case when not t1.f<=d-(c)*13 then t1.e+13*(abs(case when exists(select 1 from t1 where (select  -count(*)* -max(t1.a) & ((((cast(avg((e)) AS integer))))) from t1)>=+c+b) then +11 when t1.a not between t1.c and c then t1.b else  -19 end)/abs(b)) & (19) when not exists(select 1 from t1 where t1.c between t1.e and t1.c) then d else t1.f end FROM t1 WHERE NOT (b in (+c,case b when f*~19-t1.b*t1.f then t1.f else a end,a | t1.a))}\n} {600}\ndo_test randexpr-2.543 {\n  db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b | e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE +t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where  -b between 11 and t1.b or b in (select  -max(19) from t1 union select  -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11}\n} {600}\ndo_test randexpr-2.544 {\n  db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b | e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE NOT (+t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where  -b between 11 and t1.b or b in (select  -max(19) from t1 union select  -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11)}\n} {}\ndo_test randexpr-2.545 {\n  db eval {SELECT t1.e++a-c-a+coalesce((select t1.e from t1 where 11=case when t1.f not between 13 and t1.b+a*t1.c then 17 when (select min((select cast(avg(17) AS integer)*max(d)-(cast(avg(c) AS integer))*count(distinct t1.b) from t1)) from t1)>=case coalesce((select t1.b & e from t1 where t1.d in (t1.c,17,t1.c)),a) when 13 then t1.a else 19 end then t1.a else e end),t1.d) FROM t1 WHERE +t1.a*t1.c between case when case coalesce((select max(+t1.f-t1.b*(select min((b))+count(distinct c) from t1)) from t1 where  -b between 11 and t1.b or b in (select  -max(19) from t1 union select  -count(*)+ -count(*) from t1) and 17=d),13)-t1.b*a when t1.b then (17) else c end>b then e else 11 end and ( -b) or t1.e not between a and 11}\n} {600}\ndo_test randexpr-2.546 {\n  db eval {SELECT (select case ~case count(*) when (count(distinct d)*min(17)+min(13)+min(11))-max(t1.a) then count(distinct  -13) else min(t1.c) end-max( - -t1.d)*count(*) when  -count(*) then count(*) else (cast(avg(e) AS integer)) end from t1)-case when a>b then t1.d+case when (e= -t1.a) and c<c then coalesce((select t1.f+f from t1 where t1.b not in (f,13,t1.b)),t1.d) else d end+ -t1.a-c+e else 19 end FROM t1 WHERE t1.b not between a and 11 and t1.c in (select +case count(*) when count(*)*cast(avg(13) AS integer) then min(~b-c-t1.e*(abs(a)/abs(case when t1.d>=(13) and t1.e<=c then 11 else t1.f end | t1.a)))-abs(abs(count(*)))-+~min(t1.e)+~count(distinct 11)* -count(*) | max(t1.d)-( -cast(avg(13) AS integer))*(min(e)) else  -min(t1.a) end from t1 union select max(t1.f) from t1)}\n} {}\ndo_test randexpr-2.547 {\n  db eval {SELECT (select case ~case count(*) when (count(distinct d)*min(17)+min(13)+min(11))-max(t1.a) then count(distinct  -13) else min(t1.c) end-max( - -t1.d)*count(*) when  -count(*) then count(*) else (cast(avg(e) AS integer)) end from t1)-case when a>b then t1.d+case when (e= -t1.a) and c<c then coalesce((select t1.f+f from t1 where t1.b not in (f,13,t1.b)),t1.d) else d end+ -t1.a-c+e else 19 end FROM t1 WHERE NOT (t1.b not between a and 11 and t1.c in (select +case count(*) when count(*)*cast(avg(13) AS integer) then min(~b-c-t1.e*(abs(a)/abs(case when t1.d>=(13) and t1.e<=c then 11 else t1.f end | t1.a)))-abs(abs(count(*)))-+~min(t1.e)+~count(distinct 11)* -count(*) | max(t1.d)-( -cast(avg(13) AS integer))*(min(e)) else  -min(t1.a) end from t1 union select max(t1.f) from t1))}\n} {481}\ndo_test randexpr-2.548 {\n  db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case  -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then  -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end | e+t1.b when a then f else 19 end FROM t1 WHERE 17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between  -t1.c and t1.a then coalesce((select max((19)) from t1 where  -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1)}\n} {}\ndo_test randexpr-2.549 {\n  db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case  -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then  -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end | e+t1.b when a then f else 19 end FROM t1 WHERE NOT (17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between  -t1.c and t1.a then coalesce((select max((19)) from t1 where  -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1))}\n} {19}\ndo_test randexpr-2.550 {\n  db eval {SELECT case ~case 19 when t1.e then f else 19*f end*case when exists(select 1 from t1 where t1.e not between t1.f-~case case  -e when f then t1.d else case when t1.b in (t1.e,f,11) then e when 11<=d then  -t1.d else 17 end end when 13 then 19 else c end and 19) then coalesce((select t1.b from t1 where not exists(select 1 from t1 where (a<>b))),b) else t1.c end & e+t1.b when a then f else 19 end FROM t1 WHERE NOT (17 in (select count(distinct t1.f)+~min(coalesce((select max(e*f-case when case when 11<>e and t1.e<=t1.d or (t1.d)<=t1.e then d when ( -17) not between  -t1.c and t1.a then coalesce((select max((19)) from t1 where  -b between e and 11), -a) else d end in (b,t1.d,a) and 19 in (13,13,t1.c) or b not in (f,(t1.e),19) then t1.c when 17 not in ((19),(t1.b),f) then +t1.d else f end) from t1 where (not a between 19 and d and (d>a))),d)) from t1 union select cast(avg(f) AS integer) from t1))}\n} {19}\ndo_test randexpr-2.551 {\n  db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where  -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where  -t1.d in (select cast(avg(c) AS integer) | count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE t1.c+t1.c=t1.f}\n} {6}\ndo_test randexpr-2.552 {\n  db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where  -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where  -t1.d in (select cast(avg(c) AS integer) | count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE NOT (t1.c+t1.c=t1.f)}\n} {}\ndo_test randexpr-2.553 {\n  db eval {SELECT (abs(11*coalesce((select max(t1.a) from t1 where d>=case when coalesce((select case when not exists(select 1 from t1 where  -d in (select b-(abs(13)/abs(t1.e)) from t1 union select e from t1)) then ~c when not exists(select 1 from t1 where not exists(select 1 from t1 where  -t1.d in (select cast(avg(c) AS integer) & count(distinct e)+max( -t1.d)-(max(f)) from t1 union select count(*) from t1))) then t1.a else e end from t1 where exists(select 1 from t1 where t1.f between d and t1.b) or 17 in (11,17,d)),11) not between t1.c and t1.d then 17 when 13=t1.a then 19 else (13) end), -t1.b)-e)/abs(a)) FROM t1 WHERE t1.c+t1.c=t1.f}\n} {6}\ndo_test randexpr-2.554 {\n  db eval {SELECT  -t1.a*coalesce((select max(c) from t1 where  -(17 | case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f |  -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE (c<=t1.e)}\n} {-30348}\ndo_test randexpr-2.555 {\n  db eval {SELECT  -t1.a*coalesce((select max(c) from t1 where  -(17 | case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f |  -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE NOT ((c<=t1.e))}\n} {}\ndo_test randexpr-2.556 {\n  db eval {SELECT  -t1.a*coalesce((select max(c) from t1 where  -(17 & case when (select cast(avg(17+coalesce((select max(c) from t1 where exists(select 1 from t1 where (coalesce((select max( -f) from t1 where (t1.b<=t1.b)),t1.e)<>e))),f &  -t1.a)) AS integer) from t1) in (13,e,t1.c) then f when (f>e) then b else t1.a end)*c*e not between 19 and t1.b),11)+13-19*(19) FROM t1 WHERE (c<=t1.e)}\n} {-30348}\ndo_test randexpr-2.557 {\n  db eval {SELECT 19-coalesce((select max(case when 17 | t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when  -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE t1.a in (select  -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1)}\n} {}\ndo_test randexpr-2.558 {\n  db eval {SELECT 19-coalesce((select max(case when 17 | t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when  -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE NOT (t1.a in (select  -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1))}\n} {-481}\ndo_test randexpr-2.559 {\n  db eval {SELECT 19-coalesce((select max(case when 17 & t1.a in (select case case coalesce((select max(t1.b) from t1 where t1.f not between case when  -b in (13,f,a) then a else a end and t1.f or (a not in (d,d,t1.c))),c) when a then t1.e else f end when 13 then 13 else b end from t1 union select 17 from t1) then c when not b not in (d, -t1.e,c) then 17 else b end) from t1 where e not in (17,t1.e,b)),t1.e) FROM t1 WHERE NOT (t1.a in (select  -count(*) from t1 union select min((select (cast(avg((select +max(t1.b) from t1)) AS integer)) from t1)+17*c) from t1))}\n} {-481}\ndo_test randexpr-2.560 {\n  db eval {SELECT  -f-coalesce((select max(case a-t1.a when t1.f then 13 else +t1.a-t1.f end) from t1 where (select count(distinct a) from t1)>d),( -~t1.a+17+case when (not exists(select 1 from t1 where c=t1.b and c>t1.d)) then ~coalesce((select t1.f from t1 where t1.e not between t1.b and t1.e),11)+a when b<=t1.d then t1.c else 11 end+t1.b)*d)*17+d FROM t1 WHERE +t1.c in (select max(~case when 17>t1.f then 19 else  -case when d=11 or t1.b> -t1.e or d not in (b,t1.a,t1.e) then e-( -13)+d else 11 end end-t1.d) from t1 union select max(17)+case min(t1.a) | case + -case abs(cast(avg(t1.d) AS integer)) when  -count(*) then count(*) else max(19) end when min(e) then count(*) else cast(avg(t1.c) AS integer) end when min(t1.f) then count(*) else min(b) end from t1)}\n} {}\ndo_test randexpr-2.561 {\n  db eval {SELECT  -f-coalesce((select max(case a-t1.a when t1.f then 13 else +t1.a-t1.f end) from t1 where (select count(distinct a) from t1)>d),( -~t1.a+17+case when (not exists(select 1 from t1 where c=t1.b and c>t1.d)) then ~coalesce((select t1.f from t1 where t1.e not between t1.b and t1.e),11)+a when b<=t1.d then t1.c else 11 end+t1.b)*d)*17+d FROM t1 WHERE NOT (+t1.c in (select max(~case when 17>t1.f then 19 else  -case when d=11 or t1.b> -t1.e or d not in (b,t1.a,t1.e) then e-( -13)+d else 11 end end-t1.d) from t1 union select max(17)+case min(t1.a) | case + -case abs(cast(avg(t1.d) AS integer)) when  -count(*) then count(*) else max(19) end when min(e) then count(*) else cast(avg(t1.c) AS integer) end when min(t1.f) then count(*) else min(b) end from t1))}\n} {-2761000}\ndo_test randexpr-2.562 {\n  db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 | e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE case when  -13 not in (b,(abs(coalesce((select max(case when  -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and  -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13}\n} {11}\ndo_test randexpr-2.563 {\n  db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 | e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE NOT (case when  -13 not in (b,(abs(coalesce((select max(case when  -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and  -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13)}\n} {}\ndo_test randexpr-2.564 {\n  db eval {SELECT coalesce((select 11 from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not (select +count(*)* -count(distinct case when exists(select 1 from t1 where 13+a=t1.b) then d else 13 end-t1.b) from t1)<=17 & e-13)) or not exists(select 1 from t1 where not t1.e in ((13),17,19) and not t1.d>a and t1.e not between t1.e and b)),coalesce((select max(coalesce((select max(b) from t1 where (b)>11),d)) from t1 where 11> -19),f)-c) FROM t1 WHERE case when  -13 not in (b,(abs(coalesce((select max(case when  -17<>t1.f then b when coalesce((select t1.b from t1 where t1.c in (select (a) from t1 union select c from t1)),17)<=t1.e then b else f end) from t1 where b<=11),t1.c))/abs((d))),19) then t1.b when (exists(select 1 from t1 where not exists(select 1 from t1 where ((13)=e and t1.f between 17 and t1.a) or t1.f between (a) and  -(t1.f)))) and t1.e between b and 13 or b<>(f) then t1.f else d end>=a or d>=13}\n} {11}\ndo_test randexpr-2.565 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13+f | c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a | 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b)}\n} {300}\ndo_test randexpr-2.566 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13+f | c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a | 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b))}\n} {}\ndo_test randexpr-2.567 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13+f & c+a) from t1 where 17<t1.a),~case when 17 in (select count(distinct 11) from t1 union select ++cast(avg(a & 11) AS integer)-count(*) from t1) then t1.a else 17 end)) from t1 where case t1.d when 17 then t1.a else 17 end not between 13 and case t1.c when t1.b*case when t1.d<>d then 13 else c end-c then e else t1.e end),c) FROM t1 WHERE exists(select 1 from t1 where t1.a+( -case when exists(select 1 from t1 where exists(select 1 from t1 where b | c-c+t1.d not between 19 and 11)) then coalesce((select t1.c from t1 where c+17 in (f,13,c) or t1.e*coalesce((select case when (not exists(select 1 from t1 where 17>e)) then t1.d else ~t1.e end from t1 where (t1.f not in (19,a,t1.b) or c=f)),c)=c), -11) else e end)<=t1.b)}\n} {300}\ndo_test randexpr-2.568 {\n  db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where  - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) | case count(*) when  -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then  -e+t1.a else t1.f end FROM t1 WHERE (case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then  -t1.a else t1.d end) in (e,t1.c,f) and  -((t1.c)) in (11,t1.e,t1.c)}\n} {}\ndo_test randexpr-2.569 {\n  db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where  - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) | case count(*) when  -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then  -e+t1.a else t1.f end FROM t1 WHERE NOT ((case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then  -t1.a else t1.d end) in (e,t1.c,f) and  -((t1.c)) in (11,t1.e,t1.c))}\n} {-400}\ndo_test randexpr-2.570 {\n  db eval {SELECT case when ((coalesce((select max((select ~cast(avg((~d*f)) AS integer) from t1)) from t1 where  - -t1.f<>d),e) in (select cast(avg(+13) AS integer)*~count(*) & case count(*) when  -abs(abs(max(f))) then cast(avg(e) AS integer) else (count(distinct b)) end from t1 union select count(*) from t1) and b>= -t1.d)) then (17) when b between 13 and t1.d then  -e+t1.a else t1.f end FROM t1 WHERE NOT ((case when +t1.f-(select abs(count(distinct d)) from t1)*case when c in (select min(b) from t1 union select max(c+f*case 11*t1.b when b then t1.c else c end | t1.a) from t1) then d else f end | t1.a*b in (t1.d,17,a) then  -t1.a else t1.d end) in (e,t1.c,f) and  -((t1.c)) in (11,t1.e,t1.c))}\n} {-400}\ndo_test randexpr-2.571 {\n  db eval {SELECT t1.d-case when e in (17,coalesce((select max((select count(*) from t1)) from t1 where (~t1.f++19*t1.f+b in (a,t1.b, -t1.e)) and b in (select count(distinct t1.a) from t1 union select (abs(abs(abs(max(t1.e)*max(t1.d))-min(11)* -count(*)))) from t1)),17),13) and t1.f in (select t1.b from t1 union select f from t1) then t1.c else c end+f FROM t1 WHERE not (select (abs(abs((+count(*)*~ -cast(avg(+t1.f-c) AS integer)*count(distinct +coalesce((select max((abs(c)/abs(t1.e))) from t1 where coalesce((select coalesce((select max(f) from t1 where t1.d<=t1.d),e)*c from t1 where t1.f<>f),c) not between t1.a and c),t1.e)+13)-count(distinct f) | abs(cast(avg(t1.b) AS integer)))))) from t1)-13<t1.c}\n} {700}\ndo_test randexpr-2.572 {\n  db eval {SELECT t1.d-case when e in (17,coalesce((select max((select count(*) from t1)) from t1 where (~t1.f++19*t1.f+b in (a,t1.b, -t1.e)) and b in (select count(distinct t1.a) from t1 union select (abs(abs(abs(max(t1.e)*max(t1.d))-min(11)* -count(*)))) from t1)),17),13) and t1.f in (select t1.b from t1 union select f from t1) then t1.c else c end+f FROM t1 WHERE NOT (not (select (abs(abs((+count(*)*~ -cast(avg(+t1.f-c) AS integer)*count(distinct +coalesce((select max((abs(c)/abs(t1.e))) from t1 where coalesce((select coalesce((select max(f) from t1 where t1.d<=t1.d),e)*c from t1 where t1.f<>f),c) not between t1.a and c),t1.e)+13)-count(distinct f) | abs(cast(avg(t1.b) AS integer)))))) from t1)-13<t1.c)}\n} {}\ndo_test randexpr-2.573 {\n  db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) | t1.c*b+t1.d)- -f)/abs(13))<>t1.e then  -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE (abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e}\n} {}\ndo_test randexpr-2.574 {\n  db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) | t1.c*b+t1.d)- -f)/abs(13))<>t1.e then  -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE NOT ((abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e)}\n} {600}\ndo_test randexpr-2.575 {\n  db eval {SELECT (abs(t1.f*case when (abs(t1.f+17-(t1.a*11*(abs(d)/abs(coalesce((select max(11) from t1 where e=a-t1.a or e not between 17 and 11 or (t1.f)>=c or f<>e),+d))) & t1.c*b+t1.d)- -f)/abs(13))<>t1.e then  -t1.e when t1.e not between f and t1.a then t1.c else t1.c end)/abs(t1.e)) FROM t1 WHERE NOT ((abs(b*t1.e+t1.a)/abs(t1.c))<case when 13 in (coalesce((select max(~(abs( -11*t1.a)/abs(c))+t1.e) from t1 where t1.d in (f,c,(f))),f)-f,b,t1.b) then e when not exists(select 1 from t1 where f in (select max(19) from t1 union select cast(avg(t1.e) AS integer)- -min(11) | abs((cast(avg(t1.d) AS integer))) from t1)) then d else d end and e<e)}\n} {600}\ndo_test randexpr-2.576 {\n  db eval {SELECT (abs(t1.c-case when +coalesce((select max(coalesce((select max(a-a*t1.f) from t1 where ~t1.a*t1.a-t1.b+f* -19 not in (t1.d,e,b)),11)*t1.a) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (c) in (b,c,t1.c))) or t1.e between  -b and b),a)+a<=e then t1.d else 17 end)/abs(f)) FROM t1 WHERE t1.d-t1.c+~t1.c<>case when (17) in (select + -abs(count(distinct t1.e*17*c+f)-max(19)) from t1 union select count(*)-max(case t1.f when a then (11+19*t1.b+t1.f) else (19) end*t1.c) from t1) then (abs(b- -f)/abs(f)) else t1.f end}\n} {0}\ndo_test randexpr-2.577 {\n  db eval {SELECT (abs(t1.c-case when +coalesce((select max(coalesce((select max(a-a*t1.f) from t1 where ~t1.a*t1.a-t1.b+f* -19 not in (t1.d,e,b)),11)*t1.a) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (c) in (b,c,t1.c))) or t1.e between  -b and b),a)+a<=e then t1.d else 17 end)/abs(f)) FROM t1 WHERE NOT (t1.d-t1.c+~t1.c<>case when (17) in (select + -abs(count(distinct t1.e*17*c+f)-max(19)) from t1 union select count(*)-max(case t1.f when a then (11+19*t1.b+t1.f) else (19) end*t1.c) from t1) then (abs(b- -f)/abs(f)) else t1.f end)}\n} {}\ndo_test randexpr-2.578 {\n  db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) | cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) | 13) | 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE 11<>t1.b}\n} {-400}\ndo_test randexpr-2.579 {\n  db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) | cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) | 13) | 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE NOT (11<>t1.b)}\n} {}\ndo_test randexpr-2.580 {\n  db eval {SELECT (abs( -coalesce((select 11 from t1 where (case f when (19+ -(select count(*) from t1)) then (select ++~count(distinct 17+t1.f*(17)) & cast(avg(c) AS integer) from t1) else 13-t1.b*t1.b end*t1.c*(select max(e)*cast(avg(t1.b) AS integer) from t1) & 13) & 17 between 11 and 17),(e))+d)/abs(t1.b))-t1.d FROM t1 WHERE 11<>t1.b}\n} {-400}\ndo_test randexpr-2.581 {\n  db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) | max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE 11<=t1.e+19*+t1.d}\n} {-613}\ndo_test randexpr-2.582 {\n  db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) | max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE NOT (11<=t1.e+19*+t1.d)}\n} {}\ndo_test randexpr-2.583 {\n  db eval {SELECT ( -13)-case when (13)+19 between (select cast(avg(11+coalesce((select d from t1 where t1.a in (select b from t1 union select c from t1)),11)+t1.e*d) AS integer)*+(max(t1.c))+cast(avg((c)) AS integer)*count(*) & max( -t1.b) from t1)-t1.d and t1.a then t1.b when b<>t1.f then t1.c else a end-b-t1.b FROM t1 WHERE 11<=t1.e+19*+t1.d}\n} {-713}\ndo_test randexpr-2.584 {\n  db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 | t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else  -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end | b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then  -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17))}\n} {}\ndo_test randexpr-2.585 {\n  db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 | t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else  -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end | b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE NOT (not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then  -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17)))}\n} {500}\ndo_test randexpr-2.586 {\n  db eval {SELECT coalesce((select max(t1.e++case ~t1.c when t1.f-c then t1.b*+coalesce((select max(+t1.c) from t1 where 19-19-13 & t1.d+(select ~min(17) from t1) not in (case when t1.a<>b then e else  -e end,(t1.d),t1.a)),b)+((e))* -t1.e else t1.d end & b) from t1 where a not between 13 and c),t1.e) FROM t1 WHERE NOT (not case when (exists(select 1 from t1 where (((abs(19)/abs((case when exists(select 1 from t1 where +t1.f>c) then 19 when f in (t1.d,t1.a,13) and b=t1.e then t1.f else t1.a end))) in (e, -t1.c,t1.b))))) then  -t1.f when b in (d,11, -d) then t1.e*t1.a else a end+d<>t1.f and (t1.f=( -17)))}\n} {500}\ndo_test randexpr-2.587 {\n  db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) | max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then  -13 when b in (select cast(avg((a)) AS integer) from t1 union select  -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19)}\n} {}\ndo_test randexpr-2.588 {\n  db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) | max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE NOT (case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then  -13 when b in (select cast(avg((a)) AS integer) from t1 union select  -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19))}\n} {-5489}\ndo_test randexpr-2.589 {\n  db eval {SELECT case when t1.d-~case t1.b when coalesce((select max(b) from t1 where exists(select 1 from t1 where t1.c<>b)),case when 17 in (select min(c+17) from t1 union select ~ -count(distinct 11) & max(d) from t1) then d when ((t1.a not between t1.f and t1.f)) then t1.a else t1.b end) then (c) else (t1.c) end<t1.a then t1.d when f not between 19 and c and 17 in (t1.f,t1.d,c) then t1.f else 11 end+t1.e*( -11) FROM t1 WHERE NOT (case c when f then case (abs(t1.d | case when ((13))*a+c+19>=d then  -13 when b in (select cast(avg((a)) AS integer) from t1 union select  -~abs(count(*))*min(t1.f) from t1) then d else 19 end)/abs(19)) when 11 then 11 else t1.f end+13-t1.d else t1.b end+b>=d and not exists(select 1 from t1 where e>=19))}\n} {-5489}\ndo_test randexpr-2.590 {\n  db eval {SELECT b+coalesce((select (t1.e) from t1 where coalesce((select max((select abs(cast(avg( -t1.f*17) AS integer))+count(*) from t1)-19*coalesce((select b*+~(t1.c)*(abs(c)/abs(a))+t1.e from t1 where 11 in (t1.a,17,b* -t1.f)),t1.e)*t1.b) from t1 where t1.f<>17),17) in (11,11, -t1.f)),t1.e) FROM t1 WHERE coalesce((select max(coalesce((select 19-e from t1 where t1.b not in (coalesce((select max(t1.e+coalesce((select 11+ -coalesce((select max(t1.a) from t1 where t1.a in (select cast(avg( -11) AS integer) from t1 union select  -max(c) from t1)),11)*t1.a from t1 where exists(select 1 from t1 where a= -e)),e)-t1.c | t1.d) from t1 where t1.e=t1.a),17),(t1.e),c)),t1.b)) from t1 where not exists(select 1 from t1 where (13>=a) or exists(select 1 from t1 where d<>11))), -19)<=t1.b}\n} {700}\ndo_test randexpr-2.591 {\n  db eval {SELECT b+coalesce((select (t1.e) from t1 where coalesce((select max((select abs(cast(avg( -t1.f*17) AS integer))+count(*) from t1)-19*coalesce((select b*+~(t1.c)*(abs(c)/abs(a))+t1.e from t1 where 11 in (t1.a,17,b* -t1.f)),t1.e)*t1.b) from t1 where t1.f<>17),17) in (11,11, -t1.f)),t1.e) FROM t1 WHERE NOT (coalesce((select max(coalesce((select 19-e from t1 where t1.b not in (coalesce((select max(t1.e+coalesce((select 11+ -coalesce((select max(t1.a) from t1 where t1.a in (select cast(avg( -11) AS integer) from t1 union select  -max(c) from t1)),11)*t1.a from t1 where exists(select 1 from t1 where a= -e)),e)-t1.c | t1.d) from t1 where t1.e=t1.a),17),(t1.e),c)),t1.b)) from t1 where not exists(select 1 from t1 where (13>=a) or exists(select 1 from t1 where d<>11))), -19)<=t1.b)}\n} {}\ndo_test randexpr-2.592 {\n  db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e |  -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then  -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE ~e<=(a-(select count(*) from t1)+c+(select  -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1))}\n} {-198}\ndo_test randexpr-2.593 {\n  db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e |  -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then  -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE NOT (~e<=(a-(select count(*) from t1)+c+(select  -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1)))}\n} {}\ndo_test randexpr-2.594 {\n  db eval {SELECT (select count(distinct t1.a)-cast(avg(~c+coalesce((select e from t1 where e in (select t1.f from t1 union select d from t1) or t1.d not in (case when a not in (t1.d,t1.c,t1.b) then a-case when ~t1.b+t1.e &  -t1.e not in (a,(b),19) then t1.d else 11 end*b when 13 in (c,13,t1.a) then  -t1.a else 17 end,c,d)),t1.e)) AS integer) from t1) FROM t1 WHERE ~e<=(a-(select count(*) from t1)+c+(select  -abs(abs( -(max((abs(coalesce((select a*(abs(b-b)/abs((c*a*b)-11+coalesce((select max(b) from t1 where a<c),e))) from t1 where 17<>e),e))/abs(11))*t1.e)))) | abs((count(*))) from t1))}\n} {-198}\ndo_test randexpr-2.595 {\n  db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) | 11+t1.b | coalesce((select max(case when b in (select case  -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else  - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE (~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select  -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct  -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e)}\n} {}\ndo_test randexpr-2.596 {\n  db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) | 11+t1.b | coalesce((select max(case when b in (select case  -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else  - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE NOT ((~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select  -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct  -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e))}\n} {-1}\ndo_test randexpr-2.597 {\n  db eval {SELECT 13-(select cast(avg(t1.c-13) AS integer) from t1) & 11+t1.b & coalesce((select max(case when b in (select case  -case max(17) when ~cast(avg(13-t1.a) AS integer) then count(distinct 13) else  - -((cast(avg(e) AS integer))) end when cast(avg(t1.c) AS integer) then count(distinct d) else count(*) end from t1 union select count(*) from t1) then case when t1.d<>~13 then b when t1.c<>13 then t1.a else a end else t1.a end) from t1 where t1.f<>( -(17))),t1.e)+c FROM t1 WHERE NOT ((~coalesce((select (11+t1.d) from t1 where 17 in (select f+a from t1 union select case when 11>coalesce((select  -case when (11 not in (t1.f,(abs(t1.a)/abs((select count(distinct  -case when 13<=e then c when d between (t1.d) and t1.d then a else 11 end) from t1)-f)),c)) then f when (t1.f>t1.d) then 17 else 13 end from t1 where t1.e>a),17) then f else t1.b end from t1)),b)*13>e))}\n} {128}\ndo_test randexpr-2.598 {\n  db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e | case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE not exists(select 1 from t1 where 11 between c and b and  -case when 13 between  -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then  -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a))}\n} {}\ndo_test randexpr-2.599 {\n  db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e | case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 between c and b and  -case when 13 between  -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then  -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a)))}\n} {787}\ndo_test randexpr-2.600 {\n  db eval {SELECT f+coalesce((select case when ~case when coalesce((select max(b) from t1 where not exists(select 1 from t1 where 11*t1.b>case t1.b when 13 then 11 else b end)),t1.b) not in (a,b,+t1.e & case when t1.a<>17 then 17 else t1.e end) then c when (t1.e)<>d then 11 else f end*(e) not between d and e then 17 else 17 end from t1 where 13 not between 19 and f),t1.b)*11 FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 between c and b and  -case when 13 between  -f | case when t1.b<+c then b when t1.f>13 then a else (d) end and d then t1.d when t1.a in (select 19 from t1 union select 11 from t1) or not exists(select 1 from t1 where exists(select 1 from t1 where not b=t1.b)) then  -19 else t1.b end in (select max(17) from t1 union select count(distinct a)+count(distinct 11) from t1) and t1.f<t1.d or b not in (d,t1.d,a)))}\n} {787}\ndo_test randexpr-2.601 {\n  db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where  -b>c) or t1.a>=11 then t1.e else e end*13*t1.f | d>=19),t1.b)+t1.a FROM t1 WHERE t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and  -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13)}\n} {600}\ndo_test randexpr-2.602 {\n  db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where  -b>c) or t1.a>=11 then t1.e else e end*13*t1.f | d>=19),t1.b)+t1.a FROM t1 WHERE NOT (t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and  -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13))}\n} {}\ndo_test randexpr-2.603 {\n  db eval {SELECT coalesce((select max(e) from t1 where e*~t1.b*e+c*case when +(abs(coalesce((select max(t1.b) from t1 where t1.b>=t1.a-11),11))/abs(17))=t1.f and ((t1.f)=t1.e) then t1.a+t1.d when not exists(select 1 from t1 where  -b>c) or t1.a>=11 then t1.e else e end*13*t1.f & d>=19),t1.b)+t1.a FROM t1 WHERE t1.e not in (t1.f+case when f-d not between coalesce((select max(d) from t1 where (coalesce((select max(17) from t1 where not 19 in (select cast(avg(c) AS integer)-~count(distinct f- -e)+cast(avg(19) AS integer) from t1 union select cast(avg(d) AS integer) from t1)),b) not in (13,t1.c,13))),17)+ -e+t1.f and  -(t1.b) then (t1.d) when t1.b in (select min(a) from t1 union select min(17) from t1) then c else 11 end,c, -13)}\n} {600}\ndo_test randexpr-2.604 {\n  db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) | abs(+ -count(distinct t1.e)*min(t1.b) | count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE 13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19}\n} {}\ndo_test randexpr-2.605 {\n  db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) | abs(+ -count(distinct t1.e)*min(t1.b) | count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE NOT (13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19)}\n} {-300}\ndo_test randexpr-2.606 {\n  db eval {SELECT case when exists(select 1 from t1 where f in (select cast(avg(t1.c) AS integer) from t1 union select min(t1.b) from t1)) then c+d-d when (coalesce((select a from t1 where a<(select abs(count(*)) from t1)),(select count(distinct t1.e) & abs(+ -count(distinct t1.e)*min(t1.b) & count(distinct 11)) from t1))) not in (17,(abs(t1.d)/abs(coalesce((select max(t1.f) from t1 where t1.a*t1.f>=t1.c),t1.f))),t1.e) then t1.c else t1.e end-f FROM t1 WHERE NOT (13*~~(abs(b)/abs(coalesce((select max(t1.a) from t1 where t1.e in ( -(13-17)-b+(e | (abs(t1.e)/abs(case when ~t1.d between t1.e and c and t1.b in (select t1.c from t1 union select b from t1) then 11+t1.b when a=t1.d then b else c end)))*17,t1.c, -17)),13)))-e+b-19>19)}\n} {-100}\ndo_test randexpr-2.607 {\n  db eval {SELECT case when t1.f<d or t1.d>=17 then t1.d-19-11*f*t1.a*t1.b-case (select +cast(avg(a) AS integer) from t1) when 19 then 17 else a end when t1.a between case t1.c when t1.c*t1.c then (d) else t1.c end and c then e else t1.a end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (abs(+f-( -~(select count(distinct ~a*e | (select max(f)*count(distinct t1.f) from t1)) |  -max(17)+(count(*))+max(11)+count(distinct t1.e)- - -count(distinct f) from t1)+b*b-t1.c) | t1.e)/abs(17))*c*b in (17,19,t1.e)))}\n} {-131999719}\ndo_test randexpr-2.608 {\n  db eval {SELECT case when t1.f<d or t1.d>=17 then t1.d-19-11*f*t1.a*t1.b-case (select +cast(avg(a) AS integer) from t1) when 19 then 17 else a end when t1.a between case t1.c when t1.c*t1.c then (d) else t1.c end and c then e else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(+f-( -~(select count(distinct ~a*e | (select max(f)*count(distinct t1.f) from t1)) |  -max(17)+(count(*))+max(11)+count(distinct t1.e)- - -count(distinct f) from t1)+b*b-t1.c) | t1.e)/abs(17))*c*b in (17,19,t1.e))))}\n} {}\ndo_test randexpr-2.609 {\n  db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) | max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f | t1.a-f FROM t1 WHERE ((t1.d>=t1.c))}\n} {-500}\ndo_test randexpr-2.610 {\n  db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) | max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f | t1.a-f FROM t1 WHERE NOT (((t1.d>=t1.c)))}\n} {}\ndo_test randexpr-2.611 {\n  db eval {SELECT f-~+17*(abs(t1.f)/abs(a*case when case when (case when d>=t1.b or t1.b>=11 then t1.c when t1.b>t1.d then t1.d else t1.a end+17) not in (11,t1.e,17) then c when (t1.b>=a and b>b) then t1.d else d end in (select +abs( -max(t1.e)) from t1 union select count(*) & max(17) from t1) then (t1.a) else a end+(t1.e)))*(11)-f & t1.a-f FROM t1 WHERE ((t1.d>=t1.c))}\n} {0}\ndo_test randexpr-2.612 {\n  db eval {SELECT e+ -((abs(f)/abs(17))) | t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where  -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) | (13) FROM t1 WHERE d<>13 or t1.c in (select count(distinct  -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else  -count(*) end-count(*)) from t1 union select count(distinct 11) from t1)}\n} {5597}\ndo_test randexpr-2.613 {\n  db eval {SELECT e+ -((abs(f)/abs(17))) | t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where  -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) | (13) FROM t1 WHERE NOT (d<>13 or t1.c in (select count(distinct  -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else  -count(*) end-count(*)) from t1 union select count(distinct 11) from t1))}\n} {}\ndo_test randexpr-2.614 {\n  db eval {SELECT e+ -((abs(f)/abs(17))) & t1.e*11-coalesce((select max(f) from t1 where ((abs(~+t1.b-coalesce((select coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where ((f) not in (11,19,t1.b)))),11* -t1.b) from t1 where  -a<=c),t1.f))/abs( -b)) between t1.c and e and not exists(select 1 from t1 where f not in ( -t1.f,19,t1.e)))),case t1.c when 19 then (11) else (t1.a) end) & (13) FROM t1 WHERE d<>13 or t1.c in (select count(distinct  -c*11-( -e)-t1.e)-( -case +max(t1.c)-min((select +cast(avg(19*17) AS integer) from t1)* -t1.f)+~(~count(distinct f))+count(*)-cast(avg(t1.c) AS integer) when count(distinct t1.f) then count(distinct e) else  -count(*) end-count(*)) from t1 union select count(distinct 11) from t1)}\n} {0}\ndo_test randexpr-2.615 {\n  db eval {SELECT coalesce((select case t1.e when t1.d then  -t1.b else b | t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case  -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE (select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b}\n} {728}\ndo_test randexpr-2.616 {\n  db eval {SELECT coalesce((select case t1.e when t1.d then  -t1.b else b | t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case  -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE NOT ((select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b)}\n} {}\ndo_test randexpr-2.617 {\n  db eval {SELECT coalesce((select case t1.e when t1.d then  -t1.b else b & t1.f end from t1 where case e when case 11 when t1.f then 13 else c end-19 then case  -(select count(distinct 19+ - -d*t1.f+d) from t1)*(abs(c)/abs(coalesce((select max(e) from t1 where not t1.c>t1.d),(17-t1.a)))) when 11 then t1.f else t1.a end else a end<>t1.c),t1.e) FROM t1 WHERE (select case count(*)* -+abs(+count(*)+min(t1.d)) | max(+(17)) when ~count(*)*(count(*))-(count(distinct t1.b)) then count(distinct 11) else max(t1.e) end from t1)>=(abs(coalesce((select t1.b from t1 where (a<f)),b-t1.a))/abs((11*c)-t1.f-b)) and 13 not between (t1.b) and t1.b}\n} {72}\ndo_test randexpr-2.618 {\n  db eval {SELECT case when 13<11 then 19 when  -(abs(f)/abs(13))*17-13 | case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else  -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a | e>(t1.c) then t1.d else t1.d end FROM t1 WHERE case when 17-t1.f in (select case  -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select  -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1)}\n} {}\ndo_test randexpr-2.619 {\n  db eval {SELECT case when 13<11 then 19 when  -(abs(f)/abs(13))*17-13 | case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else  -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a | e>(t1.c) then t1.d else t1.d end FROM t1 WHERE NOT (case when 17-t1.f in (select case  -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select  -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1))}\n} {400}\ndo_test randexpr-2.620 {\n  db eval {SELECT case when 13<11 then 19 when  -(abs(f)/abs(13))*17-13 & case t1.b when ~((select (count(*)-abs(case cast(avg(19) AS integer) when count(distinct 19)*(count(*))-count(*) then count(distinct t1.d) else  -count(distinct 17) end)+max(17)) from t1)) then t1.c else d end+11*t1.e*t1.a & e>(t1.c) then t1.d else t1.d end FROM t1 WHERE NOT (case when 17-t1.f in (select case  -~max(c-~e+19)*max(c)*count(*)+~count(distinct f)+case count(distinct d) when max(t1.b) then cast(avg(t1.d) AS integer) else count(distinct d) end-count(distinct d)*max(f)+ -count(distinct 13) when count(*) then ( -min(t1.c)) else min(( -d)) end from t1 union select  -min(c) from t1) then 13 else case t1.c when t1.c then f else d end end-e-(17) in (select c from t1 union select c from t1))}\n} {400}\ndo_test randexpr-2.621 {\n  db eval {SELECT coalesce((select case ~(case when  -f between t1.e and f then coalesce((select max(t1.a-t1.d) from t1 where d=b),case when (f*11-a-t1.d-c>t1.e and b>=19) then  -+d when t1.b>= -13 then 17 else t1.f end) else (19) end) when 11 then b else f end from t1 where  -t1.e<=t1.d),a) FROM t1 WHERE (+coalesce((select max((abs(19*a-t1.b+t1.a*a)/abs(19))) from t1 where not t1.f in (select case  -count(*)-cast(avg(c) AS integer)+cast(avg(e) AS integer)*count(*) when min(t1.d) then  -(cast(avg(t1.f) AS integer)) else max(13) end+min(t1.d)+count(*) | count(*) | min(11) | count(distinct f) from t1 union select  -count(*) from t1)),e))-t1.e*d | f in (t1.d,e,e)}\n} {}\ndo_test randexpr-2.622 {\n  db eval {SELECT coalesce((select case ~(case when  -f between t1.e and f then coalesce((select max(t1.a-t1.d) from t1 where d=b),case when (f*11-a-t1.d-c>t1.e and b>=19) then  -+d when t1.b>= -13 then 17 else t1.f end) else (19) end) when 11 then b else f end from t1 where  -t1.e<=t1.d),a) FROM t1 WHERE NOT ((+coalesce((select max((abs(19*a-t1.b+t1.a*a)/abs(19))) from t1 where not t1.f in (select case  -count(*)-cast(avg(c) AS integer)+cast(avg(e) AS integer)*count(*) when min(t1.d) then  -(cast(avg(t1.f) AS integer)) else max(13) end+min(t1.d)+count(*) | count(*) | min(11) | count(distinct f) from t1 union select  -count(*) from t1)),e))-t1.e*d | f in (t1.d,e,e))}\n} {600}\ndo_test randexpr-2.623 {\n  db eval {SELECT case d*t1.f when  -t1.a then t1.c+(coalesce((select max(13+case when  -t1.d*13*c*d | case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when  -max(13) then cast(avg( -(11)) AS integer) else  -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a)}\n} {}\ndo_test randexpr-2.624 {\n  db eval {SELECT case d*t1.f when  -t1.a then t1.c+(coalesce((select max(13+case when  -t1.d*13*c*d | case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE NOT (t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when  -max(13) then cast(avg( -(11)) AS integer) else  -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a))}\n} {700}\ndo_test randexpr-2.625 {\n  db eval {SELECT case d*t1.f when  -t1.a then t1.c+(coalesce((select max(13+case when  -t1.d*13*c*d & case t1.e when t1.e then t1.b+t1.d else (abs(t1.b)/abs(case when c>b or d in (t1.e,a,d) then d else e end))+f end=t1.f then a when t1.a<=19 then 17 else d end) from t1 where (t1.f>t1.b)),(f))) else f end+t1.a FROM t1 WHERE NOT (t1.f+case d when 19 then +t1.c else 19-(abs((t1.b)*~coalesce((select f from t1 where (case when +case when t1.d>13 then t1.e else (t1.a) end<13 then f when t1.c<=e then d else t1.a end*t1.d in (select +case ~min(b) when  -max(13) then cast(avg( -(11)) AS integer) else  -cast(avg(17) AS integer) end+count(distinct t1.a) from t1 union select min(t1.f) from t1))),t1.a))/abs(f)) end+(a) in (b,t1.c,t1.a))}\n} {700}\ndo_test randexpr-2.626 {\n  db eval {SELECT case case when (not exists(select 1 from t1 where  -e in (select t1.c from t1 union select b from t1))) then coalesce((select max(t1.d) from t1 where (17+~t1.c in (select min(t1.b) from t1 union select min(13) from t1))),t1.d)*t1.a+d when not a=a and t1.b not in (b,13,d) or d<13 or t1.f not between t1.c and f or t1.c<>c then t1.e else t1.d end when t1.c then (t1.d) else  -f end FROM t1 WHERE (abs(case when (t1.e in (17,19+t1.b,t1.a)) or (t1.d-19)+(t1.d)+t1.d in (select t1.f from t1 union select t1.e from t1) and 13 in (select t1.c from t1 union select c from t1) or 11 not between e and 17 then  -17-a else d end*13)/abs((b)))*d-f-13 between t1.d and (b)}\n} {}\ndo_test randexpr-2.627 {\n  db eval {SELECT case case when (not exists(select 1 from t1 where  -e in (select t1.c from t1 union select b from t1))) then coalesce((select max(t1.d) from t1 where (17+~t1.c in (select min(t1.b) from t1 union select min(13) from t1))),t1.d)*t1.a+d when not a=a and t1.b not in (b,13,d) or d<13 or t1.f not between t1.c and f or t1.c<>c then t1.e else t1.d end when t1.c then (t1.d) else  -f end FROM t1 WHERE NOT ((abs(case when (t1.e in (17,19+t1.b,t1.a)) or (t1.d-19)+(t1.d)+t1.d in (select t1.f from t1 union select t1.e from t1) and 13 in (select t1.c from t1 union select c from t1) or 11 not between e and 17 then  -17-a else d end*13)/abs((b)))*d-f-13 between t1.d and (b))}\n} {-600}\ndo_test randexpr-2.628 {\n  db eval {SELECT a+a+(f)-(t1.f+d+t1.e | case when case (13) when t1.c then case coalesce((select  -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE (t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when  -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b}\n} {}\ndo_test randexpr-2.629 {\n  db eval {SELECT a+a+(f)-(t1.f+d+t1.e | case when case (13) when t1.c then case coalesce((select  -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE NOT ((t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when  -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b)}\n} {-54045400}\ndo_test randexpr-2.630 {\n  db eval {SELECT a+a+(f)-(t1.f+d+t1.e & case when case (13) when t1.c then case coalesce((select  -t1.b-t1.f-13 from t1 where t1.f between t1.d and (a)),t1.b) when b then 13 else t1.f end-f else t1.d end>=e then 19 else t1.c end*t1.c)*f-(t1.d)-b FROM t1 WHERE NOT ((t1.b)=t1.a+t1.d-13 | +~f+13 | e+t1.c+coalesce((select t1.a+e from t1 where b in (select (~max(b-t1.b-coalesce((select ((a)) from t1 where e=d or b not between b and t1.e),t1.b)))++~case case count(*) when  -max(t1.c) then min(b) else min(17) end when max( -t1.a) then (min(t1.f)) else max((a)) end*cast(avg(f) AS integer)+max(19) from t1 union select count(distinct f) from t1)),(t1.e)) | t1.b)}\n} {-854200}\ndo_test randexpr-2.631 {\n  db eval {SELECT 19-e+t1.d | 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) | min(t1.a) | (max(t1.a)))+max((t1.d)) when min(t1.a) then  -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE case when case when not b-(t1.c)-11 in (case  -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else  -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e}\n} {-1}\ndo_test randexpr-2.632 {\n  db eval {SELECT 19-e+t1.d | 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) | min(t1.a) | (max(t1.a)))+max((t1.d)) when min(t1.a) then  -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE NOT (case when case when not b-(t1.c)-11 in (case  -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else  -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e)}\n} {}\ndo_test randexpr-2.633 {\n  db eval {SELECT 19-e+t1.d & 19-(abs(11)/abs(t1.b-(select case cast(avg(t1.f) AS integer)-count(*)-count(distinct t1.c)-abs(count(*))-(cast(avg(case when 11<b then d when (c) in (t1.a,t1.b,t1.a) then t1.a else t1.f end) AS integer) & min(t1.a) & (max(t1.a)))+max((t1.d)) when min(t1.a) then  -count(*) else min((e)) end from t1)*19))-c+13 FROM t1 WHERE case when case when not b-(t1.c)-11 in (case  -(b*11) when t1.d then coalesce((select 13 from t1 where e<>b),t1.d) else ~11 end+t1.b,11,19) then t1.a else  -t1.d-case d*a when t1.d then t1.e else 13 end end+e+b>19 then t1.a else t1.f end not between t1.d and e}\n} {-348}\ndo_test randexpr-2.634 {\n  db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) | min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct  -t1.c | t1.a) | abs(abs(min(d+c))) from t1)}\n} {}\ndo_test randexpr-2.635 {\n  db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) | min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE NOT (not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct  -t1.c | t1.a) | abs(abs(min(d+c))) from t1))}\n} {995}\ndo_test randexpr-2.636 {\n  db eval {SELECT (select abs(abs(~ -min(case t1.a-d when (abs(f)/abs(f+t1.b)) then ~e-11-+ -13*t1.a else 13 end)-count(*)*case + -count(*) when (count(distinct t1.e)) then max(t1.f) else (count(*)* - -+count(*) & min(17)) end+(cast(avg(t1.f) AS integer))+min(d))) from t1) FROM t1 WHERE NOT (not t1.f>=t1.a or not exists(select 1 from t1 where 19=17) and 13 in (select abs(count(*) | ((count(*)))) from t1 union select count(distinct  -t1.c | t1.a) | abs(abs(min(d+c))) from t1))}\n} {1011}\ndo_test randexpr-2.637 {\n  db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select  - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else  -cast(avg(c) AS integer) end | min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE exists(select 1 from t1 where (13>=t1.a))}\n} {}\ndo_test randexpr-2.638 {\n  db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select  - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else  -cast(avg(c) AS integer) end | min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE NOT (exists(select 1 from t1 where (13>=t1.a)))}\n} {-12}\ndo_test randexpr-2.639 {\n  db eval {SELECT (case when not exists(select 1 from t1 where ((not t1.f in (b,17-d,t1.a) and f<t1.f)) or b=t1.e or a in (select  - -count(distinct t1.c) from t1 union select min(11) from t1)) then (select case max( -t1.c) when (~ -count(distinct (b))-count(*))* -count(*) then count(distinct 11) else  -cast(avg(c) AS integer) end & min(t1.e)*cast(avg(13) AS integer) from t1)+b else (abs(t1.c)/abs( -b)) end-t1.b) FROM t1 WHERE NOT (exists(select 1 from t1 where (13>=t1.a)))}\n} {6212}\ndo_test randexpr-2.640 {\n  db eval {SELECT coalesce((select t1.a from t1 where case when +(abs(e)/abs(19))+(abs(coalesce((select max(b) from t1 where 19 not in (f,(c),11) or  -c not in (t1.f,e,d)),13)*e+t1.f)/abs((d)))<>t1.b then t1.e when t1.d not in (t1.f,17,t1.b) or t1.f not between t1.d and 13 then t1.a else t1.e end>e or not exists(select 1 from t1 where a>=e or not exists(select 1 from t1 where d<>t1.b))),f)+19 FROM t1 WHERE 13 in (case when (select +max( -t1.b+a*case when not 13*13<t1.c then 19 else d end*11*c)+max(b) from t1)<>t1.f and ~e>= -t1.b then t1.c when 11 not between t1.d and e and (d<c) then t1.f else d end | e,a,t1.c)}\n} {}\ndo_test randexpr-2.641 {\n  db eval {SELECT coalesce((select t1.a from t1 where case when +(abs(e)/abs(19))+(abs(coalesce((select max(b) from t1 where 19 not in (f,(c),11) or  -c not in (t1.f,e,d)),13)*e+t1.f)/abs((d)))<>t1.b then t1.e when t1.d not in (t1.f,17,t1.b) or t1.f not between t1.d and 13 then t1.a else t1.e end>e or not exists(select 1 from t1 where a>=e or not exists(select 1 from t1 where d<>t1.b))),f)+19 FROM t1 WHERE NOT (13 in (case when (select +max( -t1.b+a*case when not 13*13<t1.c then 19 else d end*11*c)+max(b) from t1)<>t1.f and ~e>= -t1.b then t1.c when 11 not between t1.d and e and (d<c) then t1.f else d end | e,a,t1.c))}\n} {119}\ndo_test randexpr-2.642 {\n  db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) | 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a}\n} {}\ndo_test randexpr-2.643 {\n  db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) | 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a)}\n} {19}\ndo_test randexpr-2.644 {\n  db eval {SELECT +coalesce((select case when coalesce((select f+t1.e from t1 where b not in (case when not exists(select 1 from t1 where (f not in (t1.f-t1.b,t1.d,t1.d))) then t1.a when t1.f*t1.c*17>+(t1.e*(d))-t1.d then t1.f else 11 end,17,f)),e) & 19-13<d then t1.a else t1.d end from t1 where d not between c and e),19) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((t1.c not between case d-c+(t1.b) when d then 17 else 13 end+f and coalesce((select t1.f from t1 where ((t1.f*case when not exists(select 1 from t1 where t1.f>=t1.b) then (select max(11)-(count(distinct f)) from t1) else t1.a end+c in (t1.d,e,f) or e in (11,11,11)))),b)*t1.b*11))) and t1.b>=a)}\n} {19}\ndo_test randexpr-2.645 {\n  db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 | (t1.c)+case when  -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then  -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13)}\n} {80000400}\ndo_test randexpr-2.646 {\n  db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 | (t1.c)+case when  -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE NOT (case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then  -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13))}\n} {}\ndo_test randexpr-2.647 {\n  db eval {SELECT (case when case 19 when b then 13 else t1.e end in (select (c) from t1 union select a from t1) then 11 else (d*coalesce((select t1.b from t1 where 19 & (t1.c)+case when  -17>t1.a then t1.a when (19>=13) then t1.a else t1.e end=f and (e)>a or 11 in (select e from t1 union select t1.b from t1)),t1.d*t1.e))+c+a end) FROM t1 WHERE case case when case when not (abs(t1.d | f)/abs(a)) in (d,a,t1.c) then  -d when (not exists(select 1 from t1 where f>=c)) then t1.a else e end+t1.d not in (t1.b,(t1.f),11) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b in (19,t1.c,13))) then b+t1.c when t1.d>=t1.a then t1.c else (c) end when (13) then t1.e else b end in (t1.a,t1.b,13)}\n} {80000400}\ndo_test randexpr-2.648 {\n  db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select  -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end | b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e | (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13)}\n} {}\ndo_test randexpr-2.649 {\n  db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select  -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end | b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e | (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE NOT (coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13))}\n} {400}\ndo_test randexpr-2.650 {\n  db eval {SELECT case when 19<=19 then d when not exists(select 1 from t1 where case case when case when (select  -min(((t1.f)))*((cast(avg(t1.d) AS integer))) from t1) in (select t1.a-b from t1 union select 17 from t1) then f when (19 not between t1.c and 13 and f>13) then d else a end & b-t1.b in (t1.e,t1.f, -d) then t1.e when c<t1.e then ( -b) else (c) end-t1.e & (17)+17 when 13 then t1.a else d end+19>=17) then t1.e else t1.e end FROM t1 WHERE NOT (coalesce((select +a- -t1.d*b*coalesce((select t1.c from t1 where t1.a in (select (abs(11)/abs(case when not exists(select 1 from t1 where +e=t1.e) then case t1.b when a-c then b else b end when (not exists(select 1 from t1 where 19 in (select 13 from t1 union select t1.b from t1))) and e in (t1.e, -f,e) then 19 else t1.a end)) from t1 union select b from t1)),17)*d from t1 where t1.f not in (t1.a,(t1.b),t1.d)),13)<=(13))}\n} {400}\ndo_test randexpr-2.651 {\n  db eval {SELECT case when c<=t1.b*e+case when not exists(select 1 from t1 where a+ -t1.f= -t1.e*(17)+f and 19 in (select  -13 from t1 union select t1.f from t1) and 19>=t1.a or  -11 in (select a from t1 union select 17 from t1)) then t1.f else 19 end+t1.d or ((c))<>a then t1.f-t1.c when c not between ((t1.b)) and f then a else d end FROM t1 WHERE coalesce((select t1.e from t1 where t1.c in (t1.a,f,coalesce((select max( -f) from t1 where t1.f<coalesce((select (select cast(avg(b) AS integer) from t1) from t1 where a>=(abs(13)/abs(~19+(abs((select count(distinct t1.f) from t1))/abs(coalesce((select 13 from t1 where d | 17*c*a*b+d<>t1.a),b)-(b)))))),b)),19))),t1.e)*c<>t1.e}\n} {300}\ndo_test randexpr-2.652 {\n  db eval {SELECT case when c<=t1.b*e+case when not exists(select 1 from t1 where a+ -t1.f= -t1.e*(17)+f and 19 in (select  -13 from t1 union select t1.f from t1) and 19>=t1.a or  -11 in (select a from t1 union select 17 from t1)) then t1.f else 19 end+t1.d or ((c))<>a then t1.f-t1.c when c not between ((t1.b)) and f then a else d end FROM t1 WHERE NOT (coalesce((select t1.e from t1 where t1.c in (t1.a,f,coalesce((select max( -f) from t1 where t1.f<coalesce((select (select cast(avg(b) AS integer) from t1) from t1 where a>=(abs(13)/abs(~19+(abs((select count(distinct t1.f) from t1))/abs(coalesce((select 13 from t1 where d | 17*c*a*b+d<>t1.a),b)-(b)))))),b)),19))),t1.e)*c<>t1.e)}\n} {}\ndo_test randexpr-2.653 {\n  db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end | count(*))) when count(distinct 13) then  -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else  -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE (c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19)}\n} {600}\ndo_test randexpr-2.654 {\n  db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end | count(*))) when count(distinct 13) then  -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else  -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE NOT ((c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19))}\n} {}\ndo_test randexpr-2.655 {\n  db eval {SELECT case when t1.c>=13 or d in (select case ((case min(t1.f)+min(f) when max( -11) then min(19) else cast(avg( -t1.d) AS integer) end & count(*))) when count(distinct 13) then  -cast(avg( -t1.e) AS integer) else min(e) end from t1 union select max( -a) from t1) then case when +c-11+(t1.d)<e or f in (select 17 from t1 union select 13 from t1) then f when t1.c in (select t1.c from t1 union select 19 from t1) then t1.f else  -f end when e in (a,19,t1.e) then t1.d else f end FROM t1 WHERE (c<=t1.f or 11<case when t1.b+ -~a*case when exists(select 1 from t1 where case when b | 17 not between 17 and c then 11 else t1.e end in (d,a,b)) then t1.b when t1.b not in (t1.f,b,c) then 11 else b end>13 then d when not exists(select 1 from t1 where t1.c in (f,t1.b,t1.b)) then a else 19 end*t1.c and t1.d>=19)}\n} {600}\ndo_test randexpr-2.656 {\n  db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f | 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE d*19 between 11 and f}\n} {}\ndo_test randexpr-2.657 {\n  db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f | 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE NOT (d*19 between 11 and f)}\n} {20000100}\ndo_test randexpr-2.658 {\n  db eval {SELECT t1.a+(e*a)*t1.d+(abs(d)/abs(case when case f when t1.a then t1.f else d end*t1.f*t1.e*c*17+coalesce((select t1.d from t1 where c<=~t1.f & 13),e)*t1.a<case when 13 between a and 19 and c<a then t1.b else f end then t1.e when exists(select 1 from t1 where ((t1.b)=t1.f)) then t1.c else f end)) FROM t1 WHERE NOT (d*19 between 11 and f)}\n} {20000100}\ndo_test randexpr-2.659 {\n  db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else  -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) | t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c}\n} {600}\ndo_test randexpr-2.660 {\n  db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else  -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) | t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE NOT (coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c)}\n} {}\ndo_test randexpr-2.661 {\n  db eval {SELECT case f when (abs(t1.f)/abs(case when d+case when exists(select 1 from t1 where exists(select 1 from t1 where exists(select 1 from t1 where case when not case when +11>=t1.d then t1.d when (t1.b)<>17 or t1.b<=t1.c then a else (e) end in (select min(t1.e) from t1 union select abs( -max((17))) from t1) then c when 19<>17 then 13 else  -d end>t1.d))) then 17 when t1.a<=13 then coalesce((select (17) & t1.c from t1 where t1.e>d),b) else 13 end in (select min(f) from t1 union select count(*) from t1) then 19 else t1.f end)) then t1.f else f end FROM t1 WHERE coalesce((select max(11 | e+case c*t1.b+13 when 19 | ~t1.f+case when d>11 then t1.f-(case t1.d when a then 19+t1.f else t1.b end) else d-case e when c+t1.a then 13 else case when not exists(select 1 from t1 where (t1.d)<>17) then d when b in ( -f,11,17) then 11 else t1.f end end end+d then e else t1.a end) from t1 where t1.a>= -11),b)>t1.c}\n} {600}\ndo_test randexpr-2.662 {\n  db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) | ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) | count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE t1.a+t1.a>13}\n} {909}\ndo_test randexpr-2.663 {\n  db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) | ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) | count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE NOT (t1.a+t1.a>13)}\n} {}\ndo_test randexpr-2.664 {\n  db eval {SELECT (select abs(case max(t1.b)-(min(17))* -count(distinct case when case t1.f when t1.b then case e when c then t1.c else c end else t1.b end>=t1.e then d else e end) & ~+count(distinct t1.c)-(abs( -count(*))- -max(c)) & count(distinct t1.c) when count(distinct ( -t1.c)) then count(*) else max(t1.b) end* -count(*))-cast(avg( -11) AS integer)*min(19)+max(e) from t1) FROM t1 WHERE t1.a+t1.a>13}\n} {710}\ndo_test randexpr-2.665 {\n  db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 | 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE t1.f<> -13}\n} {700}\ndo_test randexpr-2.666 {\n  db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 | 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE NOT (t1.f<> -13)}\n} {}\ndo_test randexpr-2.667 {\n  db eval {SELECT (t1.d- -c+e-f++case when a between case f when case when ~~~11-coalesce((select b from t1 where coalesce((select max(e) from t1 where not t1.d>= -11),a)+a between 11 and t1.a), -d)*17-a-13 & 13>=17 then a else 11 end then t1.a else t1.d end and t1.f then 19 else t1.a end) FROM t1 WHERE t1.f<> -13}\n} {700}\ndo_test randexpr-2.668 {\n  db eval {SELECT (abs(case when (c<=b+t1.b) then  -11+t1.a-d when b*(select count(distinct e)*+max(~t1.a*case when (select count(*)*+min(t1.b)+max(t1.a) from t1) in (c,t1.d,t1.d) then (select  -(count(*)) from t1) else e end) from t1)<=a-11 then 11 else t1.e end)/abs(t1.e))+c FROM t1 WHERE a<+coalesce((select t1.f from t1 where exists(select 1 from t1 where ~case when (e not between t1.a-~case d when b then  -c else 13 end and d) then 11 else a end+17-f-a*19*t1.f not in (f, -t1.d,11))),c)-t1.f and (t1.d<17) and t1.f=c or f<= -e}\n} {}\ndo_test randexpr-2.669 {\n  db eval {SELECT (abs(case when (c<=b+t1.b) then  -11+t1.a-d when b*(select count(distinct e)*+max(~t1.a*case when (select count(*)*+min(t1.b)+max(t1.a) from t1) in (c,t1.d,t1.d) then (select  -(count(*)) from t1) else e end) from t1)<=a-11 then 11 else t1.e end)/abs(t1.e))+c FROM t1 WHERE NOT (a<+coalesce((select t1.f from t1 where exists(select 1 from t1 where ~case when (e not between t1.a-~case d when b then  -c else 13 end and d) then 11 else a end+17-f-a*19*t1.f not in (f, -t1.d,11))),c)-t1.f and (t1.d<17) and t1.f=c or f<= -e)}\n} {300}\ndo_test randexpr-2.670 {\n  db eval {SELECT case when case when c in (select abs((max(d*case t1.b when t1.b+t1.f then d else b end+d))- - -~count(*)*cast(avg(t1.b) AS integer)-min(d)*cast(avg(b) AS integer)*count(*)) from t1 union select  -count(distinct t1.f) from t1) then case when 17 between t1.f and 11 then c else d end when t1.c>=13 then a else a end<=c then t1.d else 13 end+e FROM t1 WHERE t1.f between  -11 and b}\n} {}\ndo_test randexpr-2.671 {\n  db eval {SELECT case when case when c in (select abs((max(d*case t1.b when t1.b+t1.f then d else b end+d))- - -~count(*)*cast(avg(t1.b) AS integer)-min(d)*cast(avg(b) AS integer)*count(*)) from t1 union select  -count(distinct t1.f) from t1) then case when 17 between t1.f and 11 then c else d end when t1.c>=13 then a else a end<=c then t1.d else 13 end+e FROM t1 WHERE NOT (t1.f between  -11 and b)}\n} {900}\ndo_test randexpr-2.672 {\n  db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else  -f end else 13 end*t1.e-t1.f | 13 FROM t1 WHERE b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13))}\n} {}\ndo_test randexpr-2.673 {\n  db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else  -f end else 13 end*t1.e-t1.f | 13 FROM t1 WHERE NOT (b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13)))}\n} {6413}\ndo_test randexpr-2.674 {\n  db eval {SELECT b*~~t1.b*(a-t1.c+t1.b)+13-+~case t1.b when d then case 17*13 when t1.e then case when case when t1.c<>~(11) then t1.e else coalesce((select max( -c) from t1 where (f<>e)),t1.f) end<=a then (t1.c) else t1.c end else  -f end else 13 end*t1.e-t1.f & 13 FROM t1 WHERE NOT (b between (d) and t1.c*(abs(t1.c-13 | t1.d+t1.a)/abs(13)))}\n} {13}\ndo_test randexpr-2.675 {\n  db eval {SELECT case when t1.b in (select case 13 when 13 | t1.e then case +(select (min((e)))-case count(*) | max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) | max( -t1.a)) then (count(distinct 13)) else  -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE b in (select a from t1 union select 11+t1.e from t1)}\n} {}\ndo_test randexpr-2.676 {\n  db eval {SELECT case when t1.b in (select case 13 when 13 | t1.e then case +(select (min((e)))-case count(*) | max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) | max( -t1.a)) then (count(distinct 13)) else  -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE NOT (b in (select a from t1 union select 11+t1.e from t1))}\n} {200}\ndo_test randexpr-2.677 {\n  db eval {SELECT case when t1.b in (select case 13 when 13 & t1.e then case +(select (min((e)))-case count(*) & max(t1.b*d+17+e) when abs(count(distinct (11))*count(*)-cast(avg(a) AS integer) & max( -t1.a)) then (count(distinct 13)) else  -(cast(avg(t1.b) AS integer)) end from t1) when (select count(distinct e) from t1) then t1.e else a+(t1.b) end-d-t1.d else t1.e end from t1 union select (f) from t1) then t1.b else (b) end FROM t1 WHERE NOT (b in (select a from t1 union select 11+t1.e from t1))}\n} {200}\ndo_test randexpr-2.678 {\n  db eval {SELECT coalesce((select 17 from t1 where d between 17 and 13),case when t1.f in (select c+a from t1 union select a from t1) and (abs(f)/abs(t1.b))-t1.e>=case when not exists(select 1 from t1 where t1.e>(select count(distinct t1.f) from t1)) then t1.f when (11)-~t1.f<case 13 when f then 19 else coalesce((select  -t1.c from t1 where 11<=t1.e),e) end then t1.e else 13 end*t1.e then t1.f else b end) FROM t1 WHERE  -coalesce((select max(11) from t1 where (abs( -case 19 when (abs(coalesce((select max(coalesce((select 13 from t1 where a>e),b)) from t1 where (t1.f) in (13,e,t1.c) or t1.c>13),t1.b))/abs(13)) then t1.b else d end)/abs(13)) in (t1.f,t1.e,t1.a) or 17 between 13 and f or (f>11 and t1.f<t1.b)),case when 19 not between  -17 and d then 11 when t1.c=d then t1.a else t1.f end)>=t1.e}\n} {}\ndo_test randexpr-2.679 {\n  db eval {SELECT coalesce((select 17 from t1 where d between 17 and 13),case when t1.f in (select c+a from t1 union select a from t1) and (abs(f)/abs(t1.b))-t1.e>=case when not exists(select 1 from t1 where t1.e>(select count(distinct t1.f) from t1)) then t1.f when (11)-~t1.f<case 13 when f then 19 else coalesce((select  -t1.c from t1 where 11<=t1.e),e) end then t1.e else 13 end*t1.e then t1.f else b end) FROM t1 WHERE NOT ( -coalesce((select max(11) from t1 where (abs( -case 19 when (abs(coalesce((select max(coalesce((select 13 from t1 where a>e),b)) from t1 where (t1.f) in (13,e,t1.c) or t1.c>13),t1.b))/abs(13)) then t1.b else d end)/abs(13)) in (t1.f,t1.e,t1.a) or 17 between 13 and f or (f>11 and t1.f<t1.b)),case when 19 not between  -17 and d then 11 when t1.c=d then t1.a else t1.f end)>=t1.e)}\n} {200}\ndo_test randexpr-2.680 {\n  db eval {SELECT (select min(19-case 19 when  -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and  -b),t1.b) else t1.b end) from t1) | f FROM t1 WHERE case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select  -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c)}\n} {}\ndo_test randexpr-2.681 {\n  db eval {SELECT (select min(19-case 19 when  -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and  -b),t1.b) else t1.b end) from t1) | f FROM t1 WHERE NOT (case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select  -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c))}\n} {-165}\ndo_test randexpr-2.682 {\n  db eval {SELECT (select min(19-case 19 when  -t1.a+13 then coalesce((select c from t1 where (abs(13)/abs(11))>=coalesce((select f+b*+t1.c from t1 where t1.c=+11+t1.e),11) or (e in (a,a,13) and t1.a<f) and t1.c not between t1.f and  -b),t1.b) else t1.b end) from t1) & f FROM t1 WHERE NOT (case 13-t1.e when 13 then f*c else ~f+(abs(t1.f | t1.e-c)/abs((coalesce((select max((select  -cast(avg(b) AS integer) from t1)-b) from t1 where 17 in (c,( -(f)),11) and 17>=f or t1.a=t1.e),t1.f)*t1.a+t1.f)*19)) end*f-t1.f in (select d from t1 union select t1.c from t1) and b in (t1.f,t1.d,c))}\n} {584}\ndo_test randexpr-2.683 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and  -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end | 19 FROM t1 WHERE t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e}\n} {}\ndo_test randexpr-2.684 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and  -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end | 19 FROM t1 WHERE NOT (t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e)}\n} {-485}\ndo_test randexpr-2.685 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c not between case case ~t1.b*19 when b then t1.c*t1.e else t1.d end when c then case ++13 when case when a+d+~~11 not between e and  -19 then 19 else b end then t1.d else 19 end else t1.a end and d) then 19 when c in (select abs(count(distinct 17)) from t1 union select max(t1.b) from t1) then (d) else t1.e end & 19 FROM t1 WHERE NOT (t1.d between 11 and ~19-coalesce((select d from t1 where (d>=c)),t1.d)*+t1.e+t1.e)}\n} {3}\ndo_test randexpr-2.686 {\n  db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between  -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) |  -t1.e-b-t1.b-t1.e FROM t1 WHERE t1.b=11}\n} {}\ndo_test randexpr-2.687 {\n  db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between  -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) |  -t1.e-b-t1.b-t1.e FROM t1 WHERE NOT (t1.b=11)}\n} {-359}\ndo_test randexpr-2.688 {\n  db eval {SELECT +t1.b-17*11-coalesce((select coalesce((select max(t1.f+a-t1.c+b) from t1 where 17* -b+t1.e=13),coalesce((select +t1.f*coalesce((select b from t1 where 19 between  -a and c),t1.d) from t1 where 17<>b),17)*11) from t1 where f<c),e) &  -t1.e-b-t1.b-t1.e FROM t1 WHERE NOT (t1.b=11)}\n} {-1528}\ndo_test randexpr-2.689 {\n  db eval {SELECT  -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between  -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) | f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then  -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a)}\n} {}\ndo_test randexpr-2.690 {\n  db eval {SELECT  -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between  -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) | f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE NOT (t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then  -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a))}\n} {-49410}\ndo_test randexpr-2.691 {\n  db eval {SELECT  -d+t1.d-t1.a-+t1.c-(select +min((abs(+(case when b>=case when b not between  -t1.f and c then e else f end or a<=11 or t1.e between a and 11 or t1.d not in (b,d,d) then case when f>=c then t1.c else 19 end when t1.e=a then e else t1.e end) & f)/abs(t1.a))) from t1)+e* -t1.a+f+d FROM t1 WHERE NOT (t1.b<=t1.c+ -(abs(t1.b)/abs(case t1.b+t1.e when 11 then t1.c else 17 end))*coalesce((select coalesce((select coalesce((select 13 from t1 where b=t1.b),f) | t1.f-11 from t1 where (t1.c) in (select +min(19)*(~max(b)-max(11))*max(11) from t1 union select min(f) from t1)),t1.f) from t1 where f in (select case count(distinct 19) when max(t1.b) then  -cast(avg(t1.e) AS integer) else cast(avg(b) AS integer) end from t1 union select count(*) from t1)),t1.a))}\n} {-49400}\ndo_test randexpr-2.692 {\n  db eval {SELECT ~case +t1.a when t1.a then 19 else coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where t1.b*f<>e and e not in (17,t1.c-case when t1.e<19 then t1.c else (abs(t1.c)/abs(d*coalesce((select t1.e from t1 where exists(select 1 from t1 where t1.c in (select t1.f from t1 union select 11 from t1)) or t1.a<=t1.d),a))) end*t1.e,t1.e))),coalesce((select max(a) from t1 where (b) in ((11),e,b)),17)) end FROM t1 WHERE not (c)+c*d>t1.e and exists(select 1 from t1 where d*coalesce((select +case when ((select cast(avg((c)) AS integer)- -cast(avg(a) AS integer) from t1) in (select min(b)-count(*) from t1 union select count(distinct 19) from t1)) or not t1.b between 19 and 19 then t1.c else coalesce((select e from t1 where t1.e>=e),c) end from t1 where ( -f)<a),17)>19) and 17<> -t1.e and b>=a}\n} {}\ndo_test randexpr-2.693 {\n  db eval {SELECT ~case +t1.a when t1.a then 19 else coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where t1.b*f<>e and e not in (17,t1.c-case when t1.e<19 then t1.c else (abs(t1.c)/abs(d*coalesce((select t1.e from t1 where exists(select 1 from t1 where t1.c in (select t1.f from t1 union select 11 from t1)) or t1.a<=t1.d),a))) end*t1.e,t1.e))),coalesce((select max(a) from t1 where (b) in ((11),e,b)),17)) end FROM t1 WHERE NOT (not (c)+c*d>t1.e and exists(select 1 from t1 where d*coalesce((select +case when ((select cast(avg((c)) AS integer)- -cast(avg(a) AS integer) from t1) in (select min(b)-count(*) from t1 union select count(distinct 19) from t1)) or not t1.b between 19 and 19 then t1.c else coalesce((select e from t1 where t1.e>=e),c) end from t1 where ( -f)<a),17)>19) and 17<> -t1.e and b>=a)}\n} {-20}\ndo_test randexpr-2.694 {\n  db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then  -(17) | b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE t1.d<>d}\n} {}\ndo_test randexpr-2.695 {\n  db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then  -(17) | b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE NOT (t1.d<>d)}\n} {-100}\ndo_test randexpr-2.696 {\n  db eval {SELECT coalesce((select max(t1.d-t1.e) from t1 where not exists(select 1 from t1 where c*+19<=(d)) or c+e not between a and ~f*t1.f*case when t1.e<> -coalesce((select case when ((e between t1.d and f)) then  -(17) & b else t1.d end from t1 where b in (select t1.c from t1 union select 11 from t1)),d) then t1.d when e not in ( -t1.b,t1.c,(t1.e)) then t1.c else d end), -b) FROM t1 WHERE NOT (t1.d<>d)}\n} {-100}\ndo_test randexpr-2.697 {\n  db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d | e- -t1.f*19+(select  -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then  -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a)}\n} {200}\ndo_test randexpr-2.698 {\n  db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d | e- -t1.f*19+(select  -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE NOT (t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then  -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a))}\n} {}\ndo_test randexpr-2.699 {\n  db eval {SELECT case when a in (select max(17) from t1 union select abs(count(*)) from t1) then t1.a- -e-t1.d & e- -t1.f*19+(select  -abs(max(a))*count(distinct e)*max(19) from t1)-11-13-d*11+t1.a else d end-b FROM t1 WHERE t1.e in (select (abs(case when (abs(f)/abs((select ~min(a) from t1)+coalesce((select t1.f from t1 where 11<>t1.b),19)))*t1.e+ -t1.d | e<=t1.f then  -e when (b)>t1.a then t1.d else t1.a end)/abs(11)) from t1 union select 13 from t1) and f not between t1.b and e or not exists(select 1 from t1 where not exists(select 1 from t1 where 19<c)) and t1.c not in (t1.d,e,t1.a)}\n} {200}\ndo_test randexpr-2.700 {\n  db eval {SELECT coalesce((select f from t1 where (case t1.a*t1.b*c when t1.d*coalesce((select max(coalesce((select 19 from t1 where t1.b in (select max(~case  -e when c+coalesce((select max(e) from t1 where (t1.d) not between c and t1.f),17) then c else 13 end) from t1 union select count(distinct a) from t1)),t1.f)) from t1 where f>t1.d),c) then 19 else 17 end between t1.b and t1.f and t1.d not in (c,e,(17)))),11) FROM t1 WHERE (((select min(t1.f) from t1)<=e))}\n} {}\ndo_test randexpr-2.701 {\n  db eval {SELECT coalesce((select f from t1 where (case t1.a*t1.b*c when t1.d*coalesce((select max(coalesce((select 19 from t1 where t1.b in (select max(~case  -e when c+coalesce((select max(e) from t1 where (t1.d) not between c and t1.f),17) then c else 13 end) from t1 union select count(distinct a) from t1)),t1.f)) from t1 where f>t1.d),c) then 19 else 17 end between t1.b and t1.f and t1.d not in (c,e,(17)))),11) FROM t1 WHERE NOT ((((select min(t1.f) from t1)<=e)))}\n} {11}\ndo_test randexpr-2.702 {\n  db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end | t1.c+t1.f FROM t1 WHERE coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e}\n} {988}\ndo_test randexpr-2.703 {\n  db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end | t1.c+t1.f FROM t1 WHERE NOT (coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e)}\n} {}\ndo_test randexpr-2.704 {\n  db eval {SELECT case t1.a when e*t1.e then case when exists(select 1 from t1 where (coalesce((select max(17) from t1 where (not (case when not a>=13*c then t1.f else (11)*t1.b end between 11 and t1.f or t1.c>(t1.c)))),t1.b*~t1.c)*b*d>=13)) then (abs(17)/abs(e)) else b end else t1.f end & t1.c+t1.f FROM t1 WHERE coalesce((select max(11) from t1 where c-d not between ~case when (select +~count(distinct t1.f)*cast(avg(t1.e) AS integer) from t1)+19 not in (t1.e,t1.f,t1.a) then t1.a when a in (e,t1.d,d) then t1.b else t1.e end and t1.b and c>=e or (t1.d<>b) and not exists(select 1 from t1 where (t1.f between 13 and a))),t1.a)-e<=t1.e}\n} {512}\ndo_test randexpr-2.705 {\n  db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) | case  -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct  -a)*count(*) from t1) | c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when  -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then  -t1.e else b end)) and t1.f}\n} {}\ndo_test randexpr-2.706 {\n  db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) | case  -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct  -a)*count(*) from t1) | c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE NOT (c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when  -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then  -t1.e else b end)) and t1.f)}\n} {700}\ndo_test randexpr-2.707 {\n  db eval {SELECT coalesce((select max(t1.e+(t1.b)) from t1 where 17<=t1.d-(select ~+cast(avg(b) AS integer) & case  -case cast(avg(t1.e) AS integer) when min((abs((a))/abs(t1.e))) then cast(avg(t1.c) AS integer)+count(*) else min(d) end when max(t1.e) then count(*) else ( -count(*)) end-min(t1.b)-count(distinct  -a)*count(*) from t1) & c+coalesce((select f from t1 where (19=t1.c-t1.b)),t1.f+17)),f) FROM t1 WHERE NOT (c not between (abs(t1.f)/abs(case when t1.f+e<=t1.c+t1.d then case when d in (select +count(distinct case when  -t1.a*19-t1.c not between 11 and c then t1.e when (19<>19) then t1.d else d end) from t1 union select cast(avg(e) AS integer) from t1) then t1.e when c in (select count(*) from t1 union select cast(avg(f) AS integer)* - - -cast(avg(t1.e) AS integer) from t1) then b else (t1.b) end when not (11>=11) then  -t1.e else b end)) and t1.f)}\n} {700}\ndo_test randexpr-2.708 {\n  db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct  -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end | t1.d)/abs((13)))*f FROM t1 WHERE coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select  - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then  -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11}\n} {}\ndo_test randexpr-2.709 {\n  db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct  -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end | t1.d)/abs((13)))*f FROM t1 WHERE NOT (coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select  - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then  -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11)}\n} {-22783}\ndo_test randexpr-2.710 {\n  db eval {SELECT 17-(abs(case when t1.e<+(select count(distinct  -f) from t1)+t1.b then +case when t1.b not in (coalesce((select max(coalesce((select case when 17<e then 13 else t1.e end+t1.b from t1 where not (t1.f) between d and ((t1.d))),t1.f)) from t1 where t1.f>=a and 13 not in (b,t1.f,d)),b),t1.d, -13) then (e) else (13) end-19 when not exists(select 1 from t1 where 19<>f) then c else t1.e end & t1.d)/abs((13)))*f FROM t1 WHERE NOT (coalesce((select f from t1 where coalesce((select ~d*19-d*~case c when case a when t1.e*19 then (select  - -( -max(t1.f))*cast(avg(t1.c) AS integer) from t1) else 13 end*13-11 then  -11 else t1.f end | t1.e | t1.f*19 from t1 where t1.f>t1.a),b)*b not in (17,17,t1.e)),t1.a)-b*d>=11)}\n} {-17983}\ndo_test randexpr-2.711 {\n  db eval {SELECT (select cast(avg(case when (e=case when e>d and case coalesce((select ((t1.b)) from t1 where 17<=t1.c),a) when t1.b then f else d end*b>t1.d then (t1.a) else 11 end or 17 not in (19,f,d) or not not exists(select 1 from t1 where  - -e>=13)) and 17 in ( -t1.b,c,t1.f) then t1.c when t1.c not between t1.f and 17 then t1.c else d end) AS integer) from t1)+b+a FROM t1 WHERE (((coalesce((select coalesce((select max(19) from t1 where d between ~t1.a and 11),c+d-coalesce((select e from t1 where (abs(b)/abs(coalesce((select 13 from t1 where case when (17) not in (19,t1.c,t1.b) or 17 not in (t1.b,t1.f,t1.e) then 11 else 19 end<>t1.c),11)*17))=t1.b),d)) from t1 where d not in (b,b,d)),t1.a) not between b and b) and d>=t1.d) and t1.d in (13,c,t1.b))}\n} {}\ndo_test randexpr-2.712 {\n  db eval {SELECT (select cast(avg(case when (e=case when e>d and case coalesce((select ((t1.b)) from t1 where 17<=t1.c),a) when t1.b then f else d end*b>t1.d then (t1.a) else 11 end or 17 not in (19,f,d) or not not exists(select 1 from t1 where  - -e>=13)) and 17 in ( -t1.b,c,t1.f) then t1.c when t1.c not between t1.f and 17 then t1.c else d end) AS integer) from t1)+b+a FROM t1 WHERE NOT ((((coalesce((select coalesce((select max(19) from t1 where d between ~t1.a and 11),c+d-coalesce((select e from t1 where (abs(b)/abs(coalesce((select 13 from t1 where case when (17) not in (19,t1.c,t1.b) or 17 not in (t1.b,t1.f,t1.e) then 11 else 19 end<>t1.c),11)*17))=t1.b),d)) from t1 where d not in (b,b,d)),t1.a) not between b and b) and d>=t1.d) and t1.d in (13,c,t1.b)))}\n} {600}\ndo_test randexpr-2.713 {\n  db eval {SELECT (abs((select +abs(+max(b) | abs(~~count(distinct  -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 | 11 end FROM t1 WHERE t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else  -a end)}\n} {}\ndo_test randexpr-2.714 {\n  db eval {SELECT (abs((select +abs(+max(b) | abs(~~count(distinct  -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 | 11 end FROM t1 WHERE NOT (t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else  -a end))}\n} {400}\ndo_test randexpr-2.715 {\n  db eval {SELECT (abs((select +abs(+max(b) & abs(~~count(distinct  -19))) from t1))/abs(coalesce((select max(19*11*d) from t1 where (t1.e<=t1.e)),t1.f)))+case e when (t1.e) then d else c*13 & 11 end FROM t1 WHERE NOT (t1.d>=(case when (select count(*) from t1)*t1.c*t1.e+e<>t1.e*13 | f+(select (min(13+t1.b) | ~+~count(*)) from t1)*e*coalesce((select max(19+t1.a) from t1 where t1.e in (select +(count(distinct b))+count(*) from t1 union select ( -min(17)) from t1)),t1.a)-t1.d* -t1.e then e else  -a end))}\n} {400}\ndo_test randexpr-2.716 {\n  db eval {SELECT  -17+c-(abs(t1.a)/abs(t1.c))-case when t1.a<>c then case when exists(select 1 from t1 where 11 not between + -d and d and 13 not between 13 and 17 or not  -f<=19 or (t1.a)<a or t1.a>(11)) and 11<t1.b then t1.e else coalesce((select case when t1.f not in (c,t1.c,t1.e) then (select +count(*) from t1) when  -t1.f>=t1.f then b else a end from t1 where t1.e in (e,t1.c,b)),11) end else  -17 end FROM t1 WHERE not exists(select 1 from t1 where t1.a>=coalesce((select t1.f from t1 where + -19*t1.c<~+t1.a*13),a))}\n} {-217}\ndo_test randexpr-2.717 {\n  db eval {SELECT  -17+c-(abs(t1.a)/abs(t1.c))-case when t1.a<>c then case when exists(select 1 from t1 where 11 not between + -d and d and 13 not between 13 and 17 or not  -f<=19 or (t1.a)<a or t1.a>(11)) and 11<t1.b then t1.e else coalesce((select case when t1.f not in (c,t1.c,t1.e) then (select +count(*) from t1) when  -t1.f>=t1.f then b else a end from t1 where t1.e in (e,t1.c,b)),11) end else  -17 end FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a>=coalesce((select t1.f from t1 where + -19*t1.c<~+t1.a*13),a)))}\n} {}\ndo_test randexpr-2.718 {\n  db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b | t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE t1.e>11}\n} {-138117}\ndo_test randexpr-2.719 {\n  db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b | t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE NOT (t1.e>11)}\n} {}\ndo_test randexpr-2.720 {\n  db eval {SELECT f*19+17*(select max(b)+count(*)- -~count(*)-min(case when (e<=b-t1.b) then case when t1.b>t1.a or f not in (c, -c,f) or f in (e,13,13) then t1.b else t1.b end else a end*a) from t1)+t1.f*(abs(case b & t1.c+t1.a when ((f)) then f else c end+b)/abs(17))-(c) FROM t1 WHERE t1.e>11}\n} {-138117}\ndo_test randexpr-2.721 {\n  db eval {SELECT  -case when case when (case (abs(13)/abs(t1.e-13*t1.f)) when b- -13+t1.d then 11 else a end) not between t1.b and b then t1.c when d not between t1.e and t1.c or t1.f in (select 11 from t1 union select f from t1) and 17=d then 13 else t1.a end+11>=f then a when f>b then t1.d else 17 end-t1.e FROM t1 WHERE (case when not exists(select 1 from t1 where exists(select 1 from t1 where (abs(b*d-t1.e)/abs(t1.b))>c)) and t1.d in (13,t1.f,17) then e else ( - -t1.a)+11+c end*t1.b in (select (case  -+min(17) when +count(*) | min(t1.a) | cast(avg(11) AS integer) then cast(avg(11) AS integer) else cast(avg(a) AS integer) end)-cast(avg(t1.a) AS integer) from t1 union select (min(t1.e)) from t1) or not t1.c in ((f),t1.c,(t1.e)))}\n} {}\ndo_test randexpr-2.722 {\n  db eval {SELECT  -case when case when (case (abs(13)/abs(t1.e-13*t1.f)) when b- -13+t1.d then 11 else a end) not between t1.b and b then t1.c when d not between t1.e and t1.c or t1.f in (select 11 from t1 union select f from t1) and 17=d then 13 else t1.a end+11>=f then a when f>b then t1.d else 17 end-t1.e FROM t1 WHERE NOT ((case when not exists(select 1 from t1 where exists(select 1 from t1 where (abs(b*d-t1.e)/abs(t1.b))>c)) and t1.d in (13,t1.f,17) then e else ( - -t1.a)+11+c end*t1.b in (select (case  -+min(17) when +count(*) | min(t1.a) | cast(avg(11) AS integer) then cast(avg(11) AS integer) else cast(avg(a) AS integer) end)-cast(avg(t1.a) AS integer) from t1 union select (min(t1.e)) from t1) or not t1.c in ((f),t1.c,(t1.e))))}\n} {-900}\ndo_test randexpr-2.723 {\n  db eval {SELECT case t1.a when a then t1.c else  -case coalesce((select t1.e from t1 where (abs(case when not (a*case when f>=f*13-19 then t1.e else +t1.a end=t1.a) then (select min(a)+min(+19) from t1) else case when t1.a=(f) then c else c end+17 end)/abs(t1.e)) between 17 and 13),e) when 17 then 13 else t1.d end end FROM t1 WHERE 17 in (select case cast(avg(b+b) AS integer) when abs(abs(count(*))) then min(case t1.c+t1.b+t1.e+17+case case when t1.b<>17 and t1.e>=t1.b then b else  -t1.f end when 11 then 13 else f end*t1.f*b when 19 then  -11 else t1.d end- -t1.f) else min(t1.c) end from t1 union select abs(abs(count(distinct b)*max(t1.d))+count(distinct 13)-count(*)) from t1)}\n} {}\ndo_test randexpr-2.724 {\n  db eval {SELECT case t1.a when a then t1.c else  -case coalesce((select t1.e from t1 where (abs(case when not (a*case when f>=f*13-19 then t1.e else +t1.a end=t1.a) then (select min(a)+min(+19) from t1) else case when t1.a=(f) then c else c end+17 end)/abs(t1.e)) between 17 and 13),e) when 17 then 13 else t1.d end end FROM t1 WHERE NOT (17 in (select case cast(avg(b+b) AS integer) when abs(abs(count(*))) then min(case t1.c+t1.b+t1.e+17+case case when t1.b<>17 and t1.e>=t1.b then b else  -t1.f end when 11 then 13 else f end*t1.f*b when 19 then  -11 else t1.d end- -t1.f) else min(t1.c) end from t1 union select abs(abs(count(distinct b)*max(t1.d))+count(distinct 13)-count(*)) from t1))}\n} {300}\ndo_test randexpr-2.725 {\n  db eval {SELECT case when coalesce((select e from t1 where coalesce((select coalesce((select max( -coalesce((select max(case when exists(select 1 from t1 where not exists(select 1 from t1 where b in (select e+d from t1 union select t1.e from t1))) then t1.d else t1.f end) from t1 where exists(select 1 from t1 where f not in ((c),a,11))),e)) from t1 where t1.b=t1.f and e<d or d>t1.b),t1.b) from t1 where t1.a in (select a from t1 union select  -f from t1)),17)>=17),((b))) not in (t1.e,b,e) then 19 when not  -a<=f then t1.f else t1.b end FROM t1 WHERE 13=t1.d}\n} {}\ndo_test randexpr-2.726 {\n  db eval {SELECT case when coalesce((select e from t1 where coalesce((select coalesce((select max( -coalesce((select max(case when exists(select 1 from t1 where not exists(select 1 from t1 where b in (select e+d from t1 union select t1.e from t1))) then t1.d else t1.f end) from t1 where exists(select 1 from t1 where f not in ((c),a,11))),e)) from t1 where t1.b=t1.f and e<d or d>t1.b),t1.b) from t1 where t1.a in (select a from t1 union select  -f from t1)),17)>=17),((b))) not in (t1.e,b,e) then 19 when not  -a<=f then t1.f else t1.b end FROM t1 WHERE NOT (13=t1.d)}\n} {200}\ndo_test randexpr-2.727 {\n  db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) | t1.d | 11 | b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) | t1.a-a-17 FROM t1 WHERE ( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1))}\n} {}\ndo_test randexpr-2.728 {\n  db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) | t1.d | 11 | b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) | t1.a-a-17 FROM t1 WHERE NOT (( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1)))}\n} {-1}\ndo_test randexpr-2.729 {\n  db eval {SELECT 19*13+((abs(case when 17*d in ((abs((case (abs((abs((select abs(min(d))+cast(avg(19) AS integer) from t1) & t1.d & 11 & b)/abs(19)))/abs(b)) when 11 then a else e end))/abs(13)),t1.f,b) then t1.b when t1.c>=t1.d then (t1.c) else c end*d)/abs(f))) & t1.a-a-17 FROM t1 WHERE NOT (( -t1.d+coalesce((select max(11) from t1 where t1.c between 13 and t1.d and case d when b then 13+ -~t1.a else +case when coalesce((select max((select +case (cast(avg(e) AS integer)) when count(distinct t1.a) then count(*) else min(( -d)) end from t1)-+a+d) from t1 where (e in (17,t1.e, -a))),b)<>f then a else 11 end end<(t1.e)),t1.d) in (select t1.a from t1 union select b from t1)))}\n} {431}\ndo_test randexpr-2.730 {\n  db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 | c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) |  -c not between  -e and  -a then (t1.c) else t1.d end FROM t1 WHERE c in (select case abs((count(*))) when  -max(t1.c) | abs(abs(+count(*)))-~case (case  -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select  -((count(distinct t1.d))) from t1)-t1.b from t1))}\n} {}\ndo_test randexpr-2.731 {\n  db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 | c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) |  -c not between  -e and  -a then (t1.c) else t1.d end FROM t1 WHERE NOT (c in (select case abs((count(*))) when  -max(t1.c) | abs(abs(+count(*)))-~case (case  -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select  -((count(distinct t1.d))) from t1)-t1.b from t1)))}\n} {400}\ndo_test randexpr-2.732 {\n  db eval {SELECT case when (19*b)+11*~f-coalesce((select max(11) from t1 where f<>case when case 17 when 11 then 17 else c end-11 in (t1.c,c,t1.e) and 19=t1.a or 17<=e or e<=19 then 19 & c when t1.b=t1.f then d else 19 end or t1.e not in (13,19,c)),b) &  -c not between  -e and  -a then (t1.c) else t1.d end FROM t1 WHERE NOT (c in (select case abs((count(*))) when  -max(t1.c) | abs(abs(+count(*)))-~case (case  -max(e) when max(11)- -count(*) then ((max(t1.e))) else count(*) end) when count(distinct t1.e) then cast(avg(f) AS integer) else cast(avg(t1.c) AS integer) end* -cast(avg(f) AS integer) then max(f) else (max(b)) end from t1 union select (max(13)) from t1) and not exists(select 1 from t1 where case when t1.e<=19-b then c else c end in (select c from t1 union select (select  -((count(distinct t1.d))) from t1)-t1.b from t1)))}\n} {300}\ndo_test randexpr-2.733 {\n  db eval {SELECT case when t1.e not between e and 13 then (select count(*) from t1) when f>=case when c in (select a from t1 union select t1.e+coalesce((select 11 from t1 where (select count(distinct t1.b) from t1)+17 not in (b,t1.c,t1.f-(select ~count(distinct 17) from t1)+ -e)),13) from t1) or 19 between d and t1.f then (select min(19) from t1) when not (e not between c and a) then d else a end then d else (t1.c) end FROM t1 WHERE f not in (17,f+d | f+case when  -f=19 then (select max((select +abs(abs(max(((select ((max(t1.d))+count(distinct t1.e))-min(t1.a) from t1))+t1.e)-abs(count(distinct  -t1.b)-count(distinct 11)))*min(a)-count(*))-min(t1.a) from t1)) from t1) else t1.f end,c-a) and c<>11}\n} {1}\ndo_test randexpr-2.734 {\n  db eval {SELECT case when t1.e not between e and 13 then (select count(*) from t1) when f>=case when c in (select a from t1 union select t1.e+coalesce((select 11 from t1 where (select count(distinct t1.b) from t1)+17 not in (b,t1.c,t1.f-(select ~count(distinct 17) from t1)+ -e)),13) from t1) or 19 between d and t1.f then (select min(19) from t1) when not (e not between c and a) then d else a end then d else (t1.c) end FROM t1 WHERE NOT (f not in (17,f+d | f+case when  -f=19 then (select max((select +abs(abs(max(((select ((max(t1.d))+count(distinct t1.e))-min(t1.a) from t1))+t1.e)-abs(count(distinct  -t1.b)-count(distinct 11)))*min(a)-count(*))-min(t1.a) from t1)) from t1) else t1.f end,c-a) and c<>11)}\n} {}\ndo_test randexpr-2.735 {\n  db eval {SELECT case c-+case when t1.f in (t1.a,t1.e,19) then t1.b else case when a<>t1.a then case ~(t1.d) when t1.e then (select max(t1.f) from t1)-(select +(cast(avg(b) AS integer))*cast(avg(t1.a) AS integer)+max(d)*count(*)+count(*) from t1)* -t1.f else 13 end else t1.a+a end*t1.f-t1.b*(e) end when d then d else 17 end FROM t1 WHERE case when not exists(select 1 from t1 where not exists(select 1 from t1 where c in (select t1.a*t1.b from t1 union select t1.d | e from t1))) and (coalesce((select (abs(11)/abs(13-17*c)) from t1 where b in (select 13 from t1 union select (t1.c) from t1)),11) not in (17,b,b)) then (abs(+t1.f)/abs(c)) when exists(select 1 from t1 where not exists(select 1 from t1 where not (not exists(select 1 from t1 where e<=19 and e>19)))) then c else t1.e end not between t1.f and c}\n} {17}\ndo_test randexpr-2.736 {\n  db eval {SELECT case c-+case when t1.f in (t1.a,t1.e,19) then t1.b else case when a<>t1.a then case ~(t1.d) when t1.e then (select max(t1.f) from t1)-(select +(cast(avg(b) AS integer))*cast(avg(t1.a) AS integer)+max(d)*count(*)+count(*) from t1)* -t1.f else 13 end else t1.a+a end*t1.f-t1.b*(e) end when d then d else 17 end FROM t1 WHERE NOT (case when not exists(select 1 from t1 where not exists(select 1 from t1 where c in (select t1.a*t1.b from t1 union select t1.d | e from t1))) and (coalesce((select (abs(11)/abs(13-17*c)) from t1 where b in (select 13 from t1 union select (t1.c) from t1)),11) not in (17,b,b)) then (abs(+t1.f)/abs(c)) when exists(select 1 from t1 where not exists(select 1 from t1 where not (not exists(select 1 from t1 where e<=19 and e>19)))) then c else t1.e end not between t1.f and c)}\n} {}\ndo_test randexpr-2.737 {\n  db eval {SELECT 11+a+(select count(distinct coalesce((select  -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then  -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) | +max(t1.c) from t1) FROM t1 WHERE 11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else  - -t1.b end*b-11, -f)}\n} {}\ndo_test randexpr-2.738 {\n  db eval {SELECT 11+a+(select count(distinct coalesce((select  -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then  -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) | +max(t1.c) from t1) FROM t1 WHERE NOT (11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else  - -t1.b end*b-11, -f))}\n} {412}\ndo_test randexpr-2.739 {\n  db eval {SELECT 11+a+(select count(distinct coalesce((select  -coalesce((select case when (t1.a<=a) then (case when 17=t1.c then (select count(distinct e)-min(11) from t1) else f end) when f>=t1.f and t1.c not in (t1.e,a,17) and 17=t1.f then  -t1.d else 11 end*t1.d from t1 where t1.a<=t1.b),t1.b) from t1 where t1.e not between d and 13),t1.a)) & +max(t1.c) from t1) FROM t1 WHERE NOT (11 in (t1.a,+t1.c* -t1.f | t1.d*+t1.c-b-(abs((select min(case when 19 in (select abs(count(distinct c)) from t1 union select ~ -min(t1.c) from t1) then case (11) when a then t1.c else t1.d end when (f)<=t1.b then t1.b else t1.a end)+min((t1.d)) | min(b) from t1))/abs(t1.e))+case 13 when t1.b then b else  - -t1.b end*b-11, -f))}\n} {111}\ndo_test randexpr-2.740 {\n  db eval {SELECT  -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 | a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case  -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select  -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE (select cast(avg(case when +d>=e+17 and (not case when 13>=(select case  -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select  -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19}\n} {}\ndo_test randexpr-2.741 {\n  db eval {SELECT  -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 | a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case  -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select  -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE NOT ((select cast(avg(case when +d>=e+17 and (not case when 13>=(select case  -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select  -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19)}\n} {-300300}\ndo_test randexpr-2.742 {\n  db eval {SELECT  -c-case 11 when ++e*(select cast(avg( -t1.f+case when case when 19=t1.e+((select min(17 & a) from t1)) then t1.f else t1.b end>=t1.e then t1.e when (((exists(select 1 from t1 where b in (select case  -count(*) when (count(distinct d)) then count(*) else (cast(avg(t1.b) AS integer)) end from t1 union select  -count(*) from t1))))) then t1.a else a end+t1.a*d) AS integer) from t1) then 13 else f end*e FROM t1 WHERE NOT ((select cast(avg(case when +d>=e+17 and (not case when 13>=(select case  -count(distinct t1.e) when cast(avg(c) AS integer) then cast(avg(19) AS integer) else count(distinct t1.a) end from t1) then t1.e else t1.f end in (select t1.b from t1 union select 13 from t1)) or t1.a<=e and e in (select count(*) from t1 union select  -count(*) from t1) and b>=t1.b or t1.e between c and 19 then c when f between 19 and b then coalesce((select max(t1.d) from t1 where a<>t1.b),13)* -(d) else t1.e end) AS integer) from t1)<=19)}\n} {-300300}\ndo_test randexpr-2.743 {\n  db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f | c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then  -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE (b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e}\n} {11}\ndo_test randexpr-2.744 {\n  db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f | c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then  -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE NOT ((b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e)}\n} {}\ndo_test randexpr-2.745 {\n  db eval {SELECT case d when 11 then t1.d-(abs(t1.d)/abs(19))+coalesce((select d*d from t1 where (select cast(avg(case when f & c+case when e in (select min(coalesce((select t1.f from t1 where 11 not between t1.b and 19),t1.f)) from t1 union select (max(t1.b)) from t1) then 19 when t1.b=b or t1.c>=c then 13 else e end*19 in (select 17 from t1 union select 11 from t1) then  -c else t1.d end) AS integer) from t1)<13),d) else 11 end FROM t1 WHERE (b>~t1.c-+(abs(case when 11>(c) and t1.a>13 then t1.d else (b) end)/abs(t1.d))-13 or t1.f between t1.a and 19 and 11 in (select (min(t1.e))-~( -+count(*)) from t1 union select count(distinct t1.c) from t1)) and 17 not in (f,(t1.b),t1.c) and (t1.f<>t1.e) or d in (f,t1.a,t1.d) or (d)<=t1.e}\n} {11}\ndo_test randexpr-2.746 {\n  db eval {SELECT (select  -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where  -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) | count(*)-max(t1.e) from t1) FROM t1 WHERE 19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17}\n} {}\ndo_test randexpr-2.747 {\n  db eval {SELECT (select  -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where  -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) | count(*)-max(t1.e) from t1) FROM t1 WHERE NOT (19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17)}\n} {-497}\ndo_test randexpr-2.748 {\n  db eval {SELECT (select  -~count(distinct ~+case when c<>coalesce((select max(case when ~13 in (t1.a,t1.f,13+t1.d+(19)*t1.d*f-e) then 13 else a end) from t1 where  -t1.d<>19),(a))*d+a then t1.d when exists(select 1 from t1 where b=d) then t1.f else 17 end*11) & count(*)-max(t1.e) from t1) FROM t1 WHERE NOT (19 in (select max(b) from t1 union select count(*) from t1) and +t1.b+c*d+coalesce((select max(17) from t1 where case when t1.a=coalesce((select max((select (min(t1.f)) from t1)) from t1 where not case when not exists(select 1 from t1 where ( -t1.b)=13 and d in (f,c,e)) or 17 between 17 and e then t1.e-t1.c else 11 end>=d),19)-11 then 11 else 17 end<=t1.a),t1.f)+t1.f-f<>17)}\n} {0}\ndo_test randexpr-2.749 {\n  db eval {SELECT coalesce((select max(a) from t1 where exists(select 1 from t1 where (abs(t1.f)/abs(case when (t1.a+case when exists(select 1 from t1 where t1.e>=(abs(coalesce((select f from t1 where (((b>=t1.d) or t1.e= -a) or 17=a)),case when t1.d between t1.a and b then t1.b when e in (e,t1.a,t1.e) then 13 else (f) end))/abs(13))) then 11 else t1.d end* - -t1.f)<=c then d else t1.d end))-t1.c-19>=t1.a)),((t1.b))) FROM t1 WHERE case when t1.f in (e,19,(abs(t1.e)/abs(t1.e))) and (17 between 11+(select +max(case case when f=(t1.b) then e when t1.e in (13,19,c) then c else  -t1.b end- -c when (13) then d else t1.f end) from t1) and 17 and (19 in (b,t1.d,11))) and f not between 19 and b then e when 13 not between (t1.e) and t1.a then 11 else 11 end not between d and t1.a}\n} {200}\ndo_test randexpr-2.750 {\n  db eval {SELECT coalesce((select max(a) from t1 where exists(select 1 from t1 where (abs(t1.f)/abs(case when (t1.a+case when exists(select 1 from t1 where t1.e>=(abs(coalesce((select f from t1 where (((b>=t1.d) or t1.e= -a) or 17=a)),case when t1.d between t1.a and b then t1.b when e in (e,t1.a,t1.e) then 13 else (f) end))/abs(13))) then 11 else t1.d end* - -t1.f)<=c then d else t1.d end))-t1.c-19>=t1.a)),((t1.b))) FROM t1 WHERE NOT (case when t1.f in (e,19,(abs(t1.e)/abs(t1.e))) and (17 between 11+(select +max(case case when f=(t1.b) then e when t1.e in (13,19,c) then c else  -t1.b end- -c when (13) then d else t1.f end) from t1) and 17 and (19 in (b,t1.d,11))) and f not between 19 and b then e when 13 not between (t1.e) and t1.a then 11 else 11 end not between d and t1.a)}\n} {}\ndo_test randexpr-2.751 {\n  db eval {SELECT 11-17 | case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else  -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b)}\n} {-1}\ndo_test randexpr-2.752 {\n  db eval {SELECT 11-17 | case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else  -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE NOT (t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b))}\n} {}\ndo_test randexpr-2.753 {\n  db eval {SELECT 11-17 & case when 11<t1.c then case when ~f<=(abs(t1.e)/abs(19))-t1.f then 17 when 11>=c or 11 in (select cast(avg(t1.c) AS integer)-case cast(avg(t1.b) AS integer) when count(distinct e) then min(t1.a) else  -count(distinct 19) end from t1 union select count(*) from t1) or e in (t1.e,t1.b,b) or 13=t1.f and e>=t1.a then e else e end when ( -19<=e) then 13 else e end+a FROM t1 WHERE t1.c*d not in ( -t1.a,coalesce((select d from t1 where coalesce((select c from t1 where ((d<=11))),(17)+(abs(coalesce((select (select ( -+count(*))+count(distinct d) from t1) from t1 where (coalesce((select b from t1 where ~a<>13),(t1.c))) not between d and t1.d),17))/abs(d)))*f<a and t1.b<>17),e),t1.b)}\n} {112}\ndo_test randexpr-2.754 {\n  db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and  -f<t1.a) then (select max((select min(t1.b) | count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE (case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else  -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f)}\n} {99}\ndo_test randexpr-2.755 {\n  db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and  -f<t1.a) then (select max((select min(t1.b) | count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE NOT ((case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else  -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f))}\n} {}\ndo_test randexpr-2.756 {\n  db eval {SELECT (abs(f-case when +(t1.f)-c<case when 17=case when not exists(select 1 from t1 where (19)=17 or c<>13 and  -f<t1.a) then (select max((select min(t1.b) & count(distinct 19) from t1)) from t1) when e not between t1.b and e then t1.e else 17 end+t1.e or t1.c in (t1.f,f,t1.d) then (11)+f when t1.c=11 and t1.e not in (a,(t1.e),a) then a else t1.f end-d then 11 else (t1.e) end-t1.b)/abs(11))*11 FROM t1 WHERE (case when (f not in (~(t1.f*case when case when case 11 when t1.e then t1.c else a end | 19 in (select t1.a from t1 union select t1.e from t1) then f when d>t1.c then 11 else  -11 end<>t1.c and t1.f not between (11) and (t1.f) then b else 11 end)*b+t1.f,a,t1.d)) then 11 else t1.d end=e) or e<(t1.f)}\n} {99}\ndo_test randexpr-2.757 {\n  db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where  -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end | f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c)}\n} {}\ndo_test randexpr-2.758 {\n  db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where  -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end | f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE NOT (b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c))}\n} {278400}\ndo_test randexpr-2.759 {\n  db eval {SELECT +(select (max(case when not (((exists(select 1 from t1 where b not between t1.a and t1.d) or t1.a>=coalesce((select max(17) from t1 where  -t1.e between t1.e and a),f)-11) or 11<=t1.c)) then b when 19 between 19 and b then t1.f else +d+ -t1.a-t1.f-e end & f-t1.b+ -t1.b)+min(t1.b)) from t1)*t1.c FROM t1 WHERE NOT (b in (t1.b-b,coalesce((select max(e) from t1 where t1.d not between 11 and case when d>=+13 then case when t1.a between e and a then t1.c else (t1.f)+(t1.b) end else case (d)*e when b then f else a end end or t1.d in (select cast(avg(d) AS integer) from t1 union select +abs( -max(e))*max(19) | max(d) from t1)),11),t1.c))}\n} {81600}\ndo_test randexpr-2.760 {\n  db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select  -count(*)-(min(t1.a)) | +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) | count(distinct d) else count(*) end)) from t1) then a else  -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE 19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) |  -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1)}\n} {}\ndo_test randexpr-2.761 {\n  db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select  -count(*)-(min(t1.a)) | +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) | count(distinct d) else count(*) end)) from t1) then a else  -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE NOT (19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) |  -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1))}\n} {60150000}\ndo_test randexpr-2.762 {\n  db eval {SELECT t1.e*t1.c*(select count(*)+abs(cast(avg(case t1.a when (select  -count(*)-(min(t1.a)) & +(abs(case max(a) when abs(min(17)) then +cast(avg(a) AS integer) & count(distinct d) else count(*) end)) from t1) then a else  -+b-coalesce((select max(f*19) from t1 where ~~c in (a,13,t1.a)),t1.b) end) AS integer)) from t1) FROM t1 WHERE NOT (19-(abs(b)/abs(t1.b)) | case when t1.e in (select case (+cast(avg(t1.c+a) AS integer) | (cast(avg(t1.d) AS integer) |  -cast(avg( -d) AS integer)* -( -count(*))+min(17))) when min(13) then max( -11) else count(*) end from t1 union select min(17) from t1) or 13 in (case when t1.e between e and coalesce((select c from t1 where not exists(select 1 from t1 where (b)>=t1.e)),t1.b) then 19 else 11 end,17,f) then 11 else b end in (select c from t1 union select 19 from t1))}\n} {60150000}\ndo_test randexpr-2.763 {\n  db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 | b | case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select  -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else  - -t1.d end) from t1)}\n} {}\ndo_test randexpr-2.764 {\n  db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 | b | case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE NOT (e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select  -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else  - -t1.d end) from t1))}\n} {400}\ndo_test randexpr-2.765 {\n  db eval {SELECT t1.b+case when e+(select abs(abs(min(d+case 11 when t1.d+19 & b & case when e<=b+coalesce((select 11 from t1 where 11<>13),17)-17 then t1.d else d end+19 then 11 else d end))) from t1)- -d-(t1.e) in (select 17 from t1 union select 11 from t1) then t1.e when exists(select 1 from t1 where e>t1.c) then t1.b else 13 end FROM t1 WHERE NOT (e in (select count(*) from t1 union select min(case when (select abs(cast(avg(+17) AS integer)) from t1) not between t1.e and 17+t1.f then f when ((case when ((select cast(avg(t1.d) AS integer) from t1)=17) then 19 else t1.f end)<>t1.c or t1.a in (select  -+abs(cast(avg(t1.b) AS integer)) from t1 union select +((cast(avg(11) AS integer)))+ -min(b) from t1)) or not exists(select 1 from t1 where ((t1.d in (b,a,17)) and f<=t1.a)) and t1.f<> - -t1.a then d else  - -t1.d end) from t1))}\n} {400}\ndo_test randexpr-2.766 {\n  db eval {SELECT (select cast(avg( -coalesce((select max(+(abs(t1.d)/abs(~d))*+c*t1.c) from t1 where e in (select coalesce((select f from t1 where t1.f<> -11),17)+c*19 from t1 union select f from t1)),t1.c)) AS integer)-~case ~count(distinct 17)*count(distinct 19) when count(distinct t1.c)*count(*)-count(distinct 19) then +(max(a)+case  - - - -min(t1.f) when max(c) then count(distinct (f)) else min(13) end) else ( -cast(avg( -t1.b) AS integer)) end from t1) FROM t1 WHERE exists(select 1 from t1 where (abs(e*coalesce((select (abs(b*(t1.b)+f)/abs(d)) from t1 where t1.c in (select min(a | t1.b) from t1 union select abs(case  -case ~ -~cast(avg(e) AS integer) when ++min(17)+( -cast(avg(a) AS integer))-max(t1.c) then cast(avg(t1.b) AS integer) else cast(avg(f) AS integer) end when  - -max((t1.d)) then  -min(t1.b) else cast(avg(t1.c) AS integer) end) from t1)),b))/abs(t1.d)) in (select min(t1.c)-cast(avg( -e) AS integer)- -cast(avg(t1.f) AS integer) from t1 union select (max((19))) from t1))}\n} {}\ndo_test randexpr-2.767 {\n  db eval {SELECT (select cast(avg( -coalesce((select max(+(abs(t1.d)/abs(~d))*+c*t1.c) from t1 where e in (select coalesce((select f from t1 where t1.f<> -11),17)+c*19 from t1 union select f from t1)),t1.c)) AS integer)-~case ~count(distinct 17)*count(distinct 19) when count(distinct t1.c)*count(*)-count(distinct 19) then +(max(a)+case  - - - -min(t1.f) when max(c) then count(distinct (f)) else min(13) end) else ( -cast(avg( -t1.b) AS integer)) end from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where (abs(e*coalesce((select (abs(b*(t1.b)+f)/abs(d)) from t1 where t1.c in (select min(a | t1.b) from t1 union select abs(case  -case ~ -~cast(avg(e) AS integer) when ++min(17)+( -cast(avg(a) AS integer))-max(t1.c) then cast(avg(t1.b) AS integer) else cast(avg(f) AS integer) end when  - -max((t1.d)) then  -min(t1.b) else cast(avg(t1.c) AS integer) end) from t1)),b))/abs(t1.d)) in (select min(t1.c)-cast(avg( -e) AS integer)- -cast(avg(t1.f) AS integer) from t1 union select (max((19))) from t1)))}\n} {-99}\ndo_test randexpr-2.768 {\n  db eval {SELECT t1.a+11*coalesce((select max( -t1.e-coalesce((select max((abs(t1.c)/abs((13*e+t1.c)-t1.f))) from t1 where exists(select 1 from t1 where d<>a) or ~(select case abs(count(distinct f)) when (count(*)) then count(*) else min(t1.f) end from t1)+coalesce((select f from t1 where d in (select min(t1.d) from t1 union select count(*) from t1)),c) in (11,t1.a,t1.b)),11)- -11) from t1 where 13<11),t1.b) FROM t1 WHERE not ++coalesce((select t1.f from t1 where not exists(select 1 from t1 where ((select min(b) from t1)<>case t1.d when coalesce((select max(case e-t1.c when 19-t1.c+f+(t1.c*coalesce((select max(17) from t1 where 17 between 11 and t1.a),t1.d)+b) then  -17 else d end-a) from t1 where t1.d>11),b) then 11 else c end))),b | t1.d)*17 not between t1.e and 17}\n} {}\ndo_test randexpr-2.769 {\n  db eval {SELECT t1.a+11*coalesce((select max( -t1.e-coalesce((select max((abs(t1.c)/abs((13*e+t1.c)-t1.f))) from t1 where exists(select 1 from t1 where d<>a) or ~(select case abs(count(distinct f)) when (count(*)) then count(*) else min(t1.f) end from t1)+coalesce((select f from t1 where d in (select min(t1.d) from t1 union select count(*) from t1)),c) in (11,t1.a,t1.b)),11)- -11) from t1 where 13<11),t1.b) FROM t1 WHERE NOT (not ++coalesce((select t1.f from t1 where not exists(select 1 from t1 where ((select min(b) from t1)<>case t1.d when coalesce((select max(case e-t1.c when 19-t1.c+f+(t1.c*coalesce((select max(17) from t1 where 17 between 11 and t1.a),t1.d)+b) then  -17 else d end-a) from t1 where t1.d>11),b) then 11 else c end))),b | t1.d)*17 not between t1.e and 17)}\n} {2300}\ndo_test randexpr-2.770 {\n  db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) | count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e | b))/abs(t1.f))) from t1 where e in (select  -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE  -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else  -t1.d end*c,d)}\n} {}\ndo_test randexpr-2.771 {\n  db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) | count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e | b))/abs(t1.f))) from t1 where e in (select  -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE NOT ( -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else  -t1.d end*c,d))}\n} {100}\ndo_test randexpr-2.772 {\n  db eval {SELECT coalesce((select max(coalesce((select ((abs(coalesce((select max((select ~(count(distinct e-11)-cast(avg(t1.a) AS integer) & count(*)) from t1)) from t1 where t1.f<case when not exists(select 1 from t1 where exists(select 1 from t1 where t1.a not in (11,e,13))) then t1.b when t1.d<t1.b then t1.e else t1.b end+ -c or t1.e>b or t1.c in (select c from t1 union select 19 from t1)),e & b))/abs(t1.f))) from t1 where e in (select  -(b) from t1 union select 13 from t1)),t1.a)) from t1 where f<>11),t1.e) FROM t1 WHERE NOT ( -11 in (a,case when exists(select 1 from t1 where 11 in (select 13 from t1 union select t1.d from t1)) and exists(select 1 from t1 where exists(select 1 from t1 where (t1.a) not between t1.c and t1.c)) then ~case when ~t1.f not between +t1.b-11 and e or not b in (c,17,e) and (not exists(select 1 from t1 where b in (( -t1.e), -t1.c,t1.c))) or 17 not in (t1.e,t1.c,t1.f) then c when 19= - -11 then t1.b else t1.c end when (13) between t1.f and ( -t1.e) then t1.d else  -t1.d end*c,d))}\n} {100}\ndo_test randexpr-2.773 {\n  db eval {SELECT 17-13-case 19 when 17+case case t1.b when t1.b then coalesce((select coalesce((select 11 from t1 where (coalesce((select t1.a from t1 where (abs(f)/abs(case t1.e when 11 then a else t1.c end))<c),b)*a- -t1.e) not between t1.e and  -13),19) from t1 where d>19 or d not between f and t1.e),(t1.c)) else 11 end when  -a then 13 else e end then t1.b else b end+t1.c FROM t1 WHERE not exists(select 1 from t1 where coalesce((select e from t1 where case when not exists(select 1 from t1 where not not exists(select 1 from t1 where f<> -t1.e-t1.c)) or coalesce((select max(17+t1.c) from t1 where t1.f in (select cast(avg(17) AS integer) from t1 union select cast(avg(t1.c) AS integer) from t1)),t1.d)<>19 then 19 else t1.a+ -(b)+t1.c end<=t1.c),t1.b)>t1.d) or (e) in (t1.c,f,13) or d in (select +count(*) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.774 {\n  db eval {SELECT 17-13-case 19 when 17+case case t1.b when t1.b then coalesce((select coalesce((select 11 from t1 where (coalesce((select t1.a from t1 where (abs(f)/abs(case t1.e when 11 then a else t1.c end))<c),b)*a- -t1.e) not between t1.e and  -13),19) from t1 where d>19 or d not between f and t1.e),(t1.c)) else 11 end when  -a then 13 else e end then t1.b else b end+t1.c FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select e from t1 where case when not exists(select 1 from t1 where not not exists(select 1 from t1 where f<> -t1.e-t1.c)) or coalesce((select max(17+t1.c) from t1 where t1.f in (select cast(avg(17) AS integer) from t1 union select cast(avg(t1.c) AS integer) from t1)),t1.d)<>19 then 19 else t1.a+ -(b)+t1.c end<=t1.c),t1.b)>t1.d) or (e) in (t1.c,f,13) or d in (select +count(*) from t1 union select count(*) from t1))}\n} {104}\ndo_test randexpr-2.775 {\n  db eval {SELECT t1.e*(abs(coalesce((select max(case when t1.c in (select (case when d>13 then t1.c else 11 end+e) from t1 union select t1.a from t1) or t1.a between 17 and c then c when t1.d>=a then t1.c else t1.e end-t1.e*t1.b-d) from t1 where b<>(t1.c) or not exists(select 1 from t1 where b in (t1.d,13,a))),11)*t1.a)/abs(t1.a))+t1.c FROM t1 WHERE a>c}\n} {}\ndo_test randexpr-2.776 {\n  db eval {SELECT t1.e*(abs(coalesce((select max(case when t1.c in (select (case when d>13 then t1.c else 11 end+e) from t1 union select t1.a from t1) or t1.a between 17 and c then c when t1.d>=a then t1.c else t1.e end-t1.e*t1.b-d) from t1 where b<>(t1.c) or not exists(select 1 from t1 where b in (t1.d,13,a))),11)*t1.a)/abs(t1.a))+t1.c FROM t1 WHERE NOT (a>c)}\n} {50050300}\ndo_test randexpr-2.777 {\n  db eval {SELECT t1.d*(+coalesce((select max(case when coalesce((select (abs(f)/abs((abs(d)/abs((select cast(avg(19+11) AS integer) from t1)))+t1.b)) from t1 where exists(select 1 from t1 where t1.d not between t1.f and t1.e)),17) not in (17,t1.f, -t1.b) then 19 else  -19 end) from t1 where exists(select 1 from t1 where 11 in (select abs(count(distinct t1.f)) from t1 union select cast(avg(t1.e) AS integer) from t1) and exists(select 1 from t1 where t1.f<t1.c) or 17<f)),13)+13) FROM t1 WHERE not exists(select 1 from t1 where t1.c*coalesce((select max(19) from t1 where a between (select abs(+min(b)*case cast(avg(b) AS integer) when case  -(count(distinct 11)) when max(coalesce((select 11 from t1 where c in (13,17,t1.b)),b)) then  -count(*) else (cast(avg(19) AS integer)) end+max(11) then max(t1.e) else count(*) end | count(*))+count(*) from t1) and ~a),(select  -count(*) from t1)) between t1.c and 13-d)}\n} {12800}\ndo_test randexpr-2.778 {\n  db eval {SELECT t1.d*(+coalesce((select max(case when coalesce((select (abs(f)/abs((abs(d)/abs((select cast(avg(19+11) AS integer) from t1)))+t1.b)) from t1 where exists(select 1 from t1 where t1.d not between t1.f and t1.e)),17) not in (17,t1.f, -t1.b) then 19 else  -19 end) from t1 where exists(select 1 from t1 where 11 in (select abs(count(distinct t1.f)) from t1 union select cast(avg(t1.e) AS integer) from t1) and exists(select 1 from t1 where t1.f<t1.c) or 17<f)),13)+13) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.c*coalesce((select max(19) from t1 where a between (select abs(+min(b)*case cast(avg(b) AS integer) when case  -(count(distinct 11)) when max(coalesce((select 11 from t1 where c in (13,17,t1.b)),b)) then  -count(*) else (cast(avg(19) AS integer)) end+max(11) then max(t1.e) else count(*) end | count(*))+count(*) from t1) and ~a),(select  -count(*) from t1)) between t1.c and 13-d))}\n} {}\ndo_test randexpr-2.779 {\n  db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) | case max(~f) | count(distinct t1.d) when count(*) then count(*) else  -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b | 13-d) from t1 where t1.b> -11),(17)) | b-19*d FROM t1 WHERE b>coalesce((select max(13+d) from t1 where 17>=11),t1.b)}\n} {}\ndo_test randexpr-2.780 {\n  db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) | case max(~f) | count(distinct t1.d) when count(*) then count(*) else  -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b | 13-d) from t1 where t1.b> -11),(17)) | b-19*d FROM t1 WHERE NOT (b>coalesce((select max(13+d) from t1 where 17>=11),t1.b))}\n} {-1}\ndo_test randexpr-2.781 {\n  db eval {SELECT coalesce((select max(coalesce((select (select cast(avg(d) AS integer) & case max(~f) & count(distinct t1.d) when count(*) then count(*) else  -min(17) end from t1) from t1 where b=t1.e+ -e or t1.a not in (t1.f,t1.d,t1.d) or f not in (t1.a, -t1.b,f)),t1.c)+b & 13-d) from t1 where t1.b> -11),(17)) & b-19*d FROM t1 WHERE NOT (b>coalesce((select max(13+d) from t1 where 17>=11),t1.b))}\n} {8}\ndo_test randexpr-2.782 {\n  db eval {SELECT (d+f*t1.c-t1.e+coalesce((select c from t1 where c>=a),case when (c in (select e from t1 union select 13 from t1)) then 11+a else f end))-13 FROM t1 WHERE c not between c and b+coalesce((select c from t1 where t1.d<case when 13 not in (case a when b then coalesce((select max(case when f in (select case when ((t1.c | t1.f not between c and 13)) then t1.e-(t1.a) else 17 end from t1 union select 13 from t1) then t1.e else e end*a) from t1 where 11=17),t1.f) else f end,17,t1.f) then t1.d else t1.d end+t1.a | b),f)}\n} {}\ndo_test randexpr-2.783 {\n  db eval {SELECT (d+f*t1.c-t1.e+coalesce((select c from t1 where c>=a),case when (c in (select e from t1 union select 13 from t1)) then 11+a else f end))-13 FROM t1 WHERE NOT (c not between c and b+coalesce((select c from t1 where t1.d<case when 13 not in (case a when b then coalesce((select max(case when f in (select case when ((t1.c | t1.f not between c and 13)) then t1.e-(t1.a) else 17 end from t1 union select 13 from t1) then t1.e else e end*a) from t1 where 11=17),t1.f) else f end,17,t1.f) then t1.d else t1.d end+t1.a | b),f))}\n} {180187}\ndo_test randexpr-2.784 {\n  db eval {SELECT case when t1.e not in (t1.a,~case when case when 17>=d then (abs(13)/abs(t1.f)) when (d in ((select abs(min(19)) from t1), -(select count(*)-abs( -count(*)) from t1),t1.e)) then coalesce((select max(19) from t1 where (c)>t1.f),17) else 13 end<>a then 11 when b<(d) then b else c end,d) then 17 when (17 in (13,t1.a,t1.c)) then e else c end+t1.c FROM t1 WHERE t1.a+t1.e in (select 19 from t1 union select t1.c from t1)}\n} {}\ndo_test randexpr-2.785 {\n  db eval {SELECT case when t1.e not in (t1.a,~case when case when 17>=d then (abs(13)/abs(t1.f)) when (d in ((select abs(min(19)) from t1), -(select count(*)-abs( -count(*)) from t1),t1.e)) then coalesce((select max(19) from t1 where (c)>t1.f),17) else 13 end<>a then 11 when b<(d) then b else c end,d) then 17 when (17 in (13,t1.a,t1.c)) then e else c end+t1.c FROM t1 WHERE NOT (t1.a+t1.e in (select 19 from t1 union select t1.c from t1))}\n} {317}\ndo_test randexpr-2.786 {\n  db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) | +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE t1.a not between 17 and d}\n} {}\ndo_test randexpr-2.787 {\n  db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) | +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE NOT (t1.a not between 17 and d)}\n} {-180600}\ndo_test randexpr-2.788 {\n  db eval {SELECT (select ~cast(avg(t1.c) AS integer)*case count(*) & +min(case +case when a<13 or case t1.f when c then 17 else t1.d end in (11,a,(t1.a)) and a<>a then t1.b+f when f not in (d,t1.a,c) then t1.f else t1.e end when t1.f then 17 else f end)+abs(++count(distinct 19))*(count(distinct 13))-count(distinct t1.e)-(count(*))*max(19) when max(11) then cast(avg(a) AS integer) else min(t1.f) end from t1) FROM t1 WHERE NOT (t1.a not between 17 and d)}\n} {-180600}\ndo_test randexpr-2.789 {\n  db eval {SELECT case t1.a when c then  -~t1.d*t1.e-coalesce((select max((abs(d+e+d)/abs(case when 11-t1.d in (select t1.d from t1 union select coalesce((select t1.c from t1 where 17<=t1.d and e between 11 and a),c) from t1) or 11 in (select ( -+(count(*))) from t1 union select count(distinct  -t1.a) from t1) then (f) when b=a then c else t1.b end))) from t1 where t1.c not between 17 and t1.b),13)+t1.f else d end FROM t1 WHERE not exists(select 1 from t1 where f<=a)}\n} {400}\ndo_test randexpr-2.790 {\n  db eval {SELECT case t1.a when c then  -~t1.d*t1.e-coalesce((select max((abs(d+e+d)/abs(case when 11-t1.d in (select t1.d from t1 union select coalesce((select t1.c from t1 where 17<=t1.d and e between 11 and a),c) from t1) or 11 in (select ( -+(count(*))) from t1 union select count(distinct  -t1.a) from t1) then (f) when b=a then c else t1.b end))) from t1 where t1.c not between 17 and t1.b),13)+t1.f else d end FROM t1 WHERE NOT (not exists(select 1 from t1 where f<=a))}\n} {}\ndo_test randexpr-2.791 {\n  db eval {SELECT (select  -max(d) from t1)+coalesce((select max(t1.e*t1.d*f) from t1 where t1.b-coalesce((select  -a*d from t1 where t1.c not in (t1.f,coalesce((select b+t1.b from t1 where t1.a not between f and t1.b),coalesce((select  -b from t1 where (t1.d>=t1.c) and 19<>t1.f),t1.a))-e*a,e)),(t1.a))+t1.f between 19 and e),t1.a)*a FROM t1 WHERE exists(select 1 from t1 where not exists(select 1 from t1 where case when t1.d-t1.b-t1.d*(case when t1.b>= -t1.d then c when t1.d not between c and t1.d then (19) else d end*e)+t1.d | 19>t1.c then e when exists(select 1 from t1 where t1.e not between d and t1.b or (17 in (t1.e, - -a,t1.d))) then t1.f else (e) end between 13 and e or 11>t1.b))}\n} {9600}\ndo_test randexpr-2.792 {\n  db eval {SELECT (select  -max(d) from t1)+coalesce((select max(t1.e*t1.d*f) from t1 where t1.b-coalesce((select  -a*d from t1 where t1.c not in (t1.f,coalesce((select b+t1.b from t1 where t1.a not between f and t1.b),coalesce((select  -b from t1 where (t1.d>=t1.c) and 19<>t1.f),t1.a))-e*a,e)),(t1.a))+t1.f between 19 and e),t1.a)*a FROM t1 WHERE NOT (exists(select 1 from t1 where not exists(select 1 from t1 where case when t1.d-t1.b-t1.d*(case when t1.b>= -t1.d then c when t1.d not between c and t1.d then (19) else d end*e)+t1.d | 19>t1.c then e when exists(select 1 from t1 where t1.e not between d and t1.b or (17 in (t1.e, - -a,t1.d))) then t1.f else (e) end between 13 and e or 11>t1.b)))}\n} {}\ndo_test randexpr-2.793 {\n  db eval {SELECT 11-t1.d-t1.e-case when (select count(distinct t1.b+coalesce((select max((abs(19)/abs(case when coalesce((select t1.f from t1 where e not between t1.f and t1.f),f)*( -11)=((e)) then 11 else d end))) from t1 where e in (17,t1.b,t1.b)), -t1.a)-(t1.c)) from t1)>t1.f then t1.b when 11>13 and a>=f then 11 else d end-t1.f FROM t1 WHERE (select min(d)-case cast(avg(case (d-~t1.c+~(select max(+d-coalesce((select max(t1.f) from t1 where c<>e),t1.a))-(( - -(cast(avg(13) AS integer)))-count(distinct e))*max(17) from t1) | 19-13*b) when  -t1.d then 13 else  -13 end) AS integer) when min(t1.c) then cast(avg(e) AS integer) else ~count(*) end from t1)<b}\n} {}\ndo_test randexpr-2.794 {\n  db eval {SELECT 11-t1.d-t1.e-case when (select count(distinct t1.b+coalesce((select max((abs(19)/abs(case when coalesce((select t1.f from t1 where e not between t1.f and t1.f),f)*( -11)=((e)) then 11 else d end))) from t1 where e in (17,t1.b,t1.b)), -t1.a)-(t1.c)) from t1)>t1.f then t1.b when 11>13 and a>=f then 11 else d end-t1.f FROM t1 WHERE NOT ((select min(d)-case cast(avg(case (d-~t1.c+~(select max(+d-coalesce((select max(t1.f) from t1 where c<>e),t1.a))-(( - -(cast(avg(13) AS integer)))-count(distinct e))*max(17) from t1) | 19-13*b) when  -t1.d then 13 else  -13 end) AS integer) when min(t1.c) then cast(avg(e) AS integer) else ~count(*) end from t1)<b)}\n} {-1889}\ndo_test randexpr-2.795 {\n  db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select  -+cast(avg(t1.a) AS integer) | ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else  -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1))}\n} {}\ndo_test randexpr-2.796 {\n  db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select  -+cast(avg(t1.a) AS integer) | ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else  -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE NOT (not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1)))}\n} {400}\ndo_test randexpr-2.797 {\n  db eval {SELECT case f when 13 then 19 else case when (case when c not between b and d then t1.c when +~t1.d+(select  -+cast(avg(t1.a) AS integer) & ((max(t1.d)))*(max(e)) from t1)-19+t1.a*t1.d in (select ~max(c) from t1 union select count(distinct d)-count(distinct b) from t1) then f else  -11 end not between 11 and 11) or 17>(c) then t1.d else 13 end end FROM t1 WHERE NOT (not ((abs(f)/abs(t1.b))<=(select min(+t1.d)+~+case count(distinct (abs(case d when 11 then coalesce((select coalesce((select max(t1.a) from t1 where t1.b=t1.e),t1.f) | a from t1 where 13<>(a)),d) else 17 end*f)/abs(t1.f))) when cast(avg(t1.c) AS integer) then case count(*) when min(t1.b) | cast(avg(t1.c) AS integer) then count(distinct f) else max(17) end else cast(avg((c)) AS integer) end from t1)))}\n} {400}\ndo_test randexpr-2.798 {\n  db eval {SELECT f+case when (not exists(select 1 from t1 where ((17<>+t1.b+t1.f or b between t1.e and t1.e)))) then (abs( -(abs(case when exists(select 1 from t1 where not exists(select 1 from t1 where d in (select (select cast(avg((t1.b)) AS integer)-count(*) from t1) from t1 union select t1.e+(11) from t1))) then c when not t1.d between f and 11 or d>a then (a) else 13 end+t1.e+e)/abs(d)))/abs(t1.b)) else f end-13 FROM t1 WHERE case when 17< - -t1.b-case when not exists(select 1 from t1 where 19<>t1.d) then 13+coalesce((select max((abs((case case when  - -t1.c*11 in (select +max(t1.d)*count(distinct  -t1.c) from t1 union select max(t1.b) from t1) then 13 else 19 end when f then 19 else (t1.d) end)+e)/abs(f))) from t1 where (13 between t1.d and 19)),t1.b) else 13 end then a else t1.a end-13 not in (t1.d,d,(t1.f))}\n} {1187}\ndo_test randexpr-2.799 {\n  db eval {SELECT f+case when (not exists(select 1 from t1 where ((17<>+t1.b+t1.f or b between t1.e and t1.e)))) then (abs( -(abs(case when exists(select 1 from t1 where not exists(select 1 from t1 where d in (select (select cast(avg((t1.b)) AS integer)-count(*) from t1) from t1 union select t1.e+(11) from t1))) then c when not t1.d between f and 11 or d>a then (a) else 13 end+t1.e+e)/abs(d)))/abs(t1.b)) else f end-13 FROM t1 WHERE NOT (case when 17< - -t1.b-case when not exists(select 1 from t1 where 19<>t1.d) then 13+coalesce((select max((abs((case case when  - -t1.c*11 in (select +max(t1.d)*count(distinct  -t1.c) from t1 union select max(t1.b) from t1) then 13 else 19 end when f then 19 else (t1.d) end)+e)/abs(f))) from t1 where (13 between t1.d and 19)),t1.b) else 13 end then a else t1.a end-13 not in (t1.d,d,(t1.f)))}\n} {}\ndo_test randexpr-2.800 {\n  db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select  -(count(*)) from t1)))) then  -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) | max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE +b between case when c<=t1.a then t1.b when case when  -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct  -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else  -t1.b end and b}\n} {}\ndo_test randexpr-2.801 {\n  db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select  -(count(*)) from t1)))) then  -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) | max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE NOT (+b between case when c<=t1.a then t1.b when case when  -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct  -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else  -t1.b end and b)}\n} {-274}\ndo_test randexpr-2.802 {\n  db eval {SELECT +~t1.a-(abs(+case when (((t1.d*t1.c+11 in (select cast(avg(17) AS integer) from t1 union select  -(count(*)) from t1)))) then  -coalesce((select t1.e-b from t1 where not exists(select 1 from t1 where t1.c in (select max(f) from t1 union select max(e) & max( -t1.e)-count(*) from t1))),f) else f end)/abs(t1.f))-e+11+t1.b+t1.a- -17 FROM t1 WHERE NOT (+b between case when c<=t1.a then t1.b when case when  -t1.a*d-17+17*~e- -13 in (select + -max(19) | +cast(avg(19) AS integer) from t1 union select (count(distinct  -19)*case max((13)) when max(e)*count(*) then min(t1.d) else count(*) end) from t1) then t1.f else (d) end in (select e from t1 union select d from t1) then f else  -t1.b end and b)}\n} {-274}\ndo_test randexpr-2.803 {\n  db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) | cast(avg(t1.e) AS integer) |  -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where  - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or  -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE 17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d)}\n} {20000}\ndo_test randexpr-2.804 {\n  db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) | cast(avg(t1.e) AS integer) |  -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where  - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or  -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE NOT (17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d))}\n} {}\ndo_test randexpr-2.805 {\n  db eval {SELECT case when 19=(select ( -count(*)* -(cast(avg(t1.e) AS integer))+count(distinct 13)*min(t1.f)) & cast(avg(t1.e) AS integer) &  -cast(avg(13) AS integer)-(min(d)) from t1) then 13*a when t1.a+((select min((t1.d)) from t1)) in (select t1.b from t1 union select 11 from t1) or not exists(select 1 from t1 where not exists(select 1 from t1 where  - -e in (select t1.e from t1 union select t1.d from t1) or t1.d in (select count(distinct t1.a) from t1 union select count(*) from t1)) or  -b=(19) and 11<c) then b else t1.c end*a FROM t1 WHERE 17-case 19 when t1.f-+(t1.d)-t1.a*t1.a then ~t1.d | e*coalesce((select b from t1 where 17< -17), -f)-17 else 19 end-case when (~t1.d)*17<f then f when t1.c in (f,a,t1.e) then t1.f else 17 end not in (t1.c,e,t1.d)}\n} {20000}\ndo_test randexpr-2.806 {\n  db eval {SELECT +t1.a*11+case when 19<13-11 or exists(select 1 from t1 where not (abs(f)/abs(+t1.a+t1.c*t1.d-t1.c))*t1.a between t1.e and 17) then coalesce((select max(t1.a) from t1 where t1.b not between t1.a and t1.a),17) when 13 not between  -f and  -t1.d then t1.c else d end-13-13*c*t1.e FROM t1 WHERE 19<=case t1.b when  -t1.d+c-t1.a-19-t1.f*t1.b-coalesce((select max(coalesce((select max( -b) from t1 where not t1.f+19 in (select case cast(avg(17) AS integer) when min(t1.a) then max((d)) else max(b) end | count(*) from t1 union select max(13) from t1) and not exists(select 1 from t1 where t1.c not between 19 and 11)),t1.e)*19) from t1 where 13 in (select  -d from t1 union select t1.f from t1)),b)-e-(t1.e) then t1.f else t1.e end}\n} {-1948813}\ndo_test randexpr-2.807 {\n  db eval {SELECT +t1.a*11+case when 19<13-11 or exists(select 1 from t1 where not (abs(f)/abs(+t1.a+t1.c*t1.d-t1.c))*t1.a between t1.e and 17) then coalesce((select max(t1.a) from t1 where t1.b not between t1.a and t1.a),17) when 13 not between  -f and  -t1.d then t1.c else d end-13-13*c*t1.e FROM t1 WHERE NOT (19<=case t1.b when  -t1.d+c-t1.a-19-t1.f*t1.b-coalesce((select max(coalesce((select max( -b) from t1 where not t1.f+19 in (select case cast(avg(17) AS integer) when min(t1.a) then max((d)) else max(b) end | count(*) from t1 union select max(13) from t1) and not exists(select 1 from t1 where t1.c not between 19 and 11)),t1.e)*19) from t1 where 13 in (select  -d from t1 union select t1.f from t1)),b)-e-(t1.e) then t1.f else t1.e end)}\n} {}\ndo_test randexpr-2.808 {\n  db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) | count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when  -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then  -c else t1.c end then e else (13) end+d,t1.a,11)}\n} {}\ndo_test randexpr-2.809 {\n  db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) | count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE NOT (t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when  -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then  -c else t1.c end then e else (13) end+d,t1.a,11))}\n} {-201}\ndo_test randexpr-2.810 {\n  db eval {SELECT case (abs(f)/abs(f)) when t1.e*t1.f then (abs(t1.d)/abs(t1.b*11)) else ~case when case ~~19 when t1.f then e else case coalesce((select (abs(f)/abs(a)) from t1 where t1.a<>17 and t1.a>= -t1.b),t1.f) when t1.d then c else t1.d end end in (select count(*) from t1 union select ~abs(min(t1.a)) & count(*) from t1) then 17 when t1.f not between (e) and t1.c then f else b end+c+a end FROM t1 WHERE NOT (t1.f in (case when ~(select max(d) from t1)*t1.f>=case when 17*d<t1.f then d when (t1.d) not between t1.e-t1.d-e and +(t1.e*13*(select case count(*) when  -count(distinct e) then max(13) else count(distinct t1.b) end from t1)-case when c<e then c else 11 end)-17 then  -c else t1.c end then e else (13) end+d,t1.a,11))}\n} {-201}\ndo_test randexpr-2.811 {\n  db eval {SELECT (abs(case when a*case when e<+(t1.e) then e else d end+t1.f<c then t1.e when d not between +13 and case when (e>=(select cast(avg(13) AS integer) from t1)) and (exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select t1.c from t1 where (b between d and 13)),t1.e)>13))) then case when b not between 19 and t1.c then a else 13 end+t1.b when t1.c>11 then c else b end then 13 else t1.d end*t1.f)/abs(17)) FROM t1 WHERE c not in (coalesce((select max(d) from t1 where (select min(t1.e) from t1)-17<=coalesce((select t1.c from t1 where exists(select 1 from t1 where 17<19 or coalesce((select 13 from t1 where t1.e not in (a+t1.c,t1.e*t1.a+t1.d* -a*(a)*f,((b)))),19) not in (c,t1.f,t1.b))),(select abs( -max(19)) from t1))),t1.f)-t1.b, -f,17)}\n} {458}\ndo_test randexpr-2.812 {\n  db eval {SELECT (abs(case when a*case when e<+(t1.e) then e else d end+t1.f<c then t1.e when d not between +13 and case when (e>=(select cast(avg(13) AS integer) from t1)) and (exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select t1.c from t1 where (b between d and 13)),t1.e)>13))) then case when b not between 19 and t1.c then a else 13 end+t1.b when t1.c>11 then c else b end then 13 else t1.d end*t1.f)/abs(17)) FROM t1 WHERE NOT (c not in (coalesce((select max(d) from t1 where (select min(t1.e) from t1)-17<=coalesce((select t1.c from t1 where exists(select 1 from t1 where 17<19 or coalesce((select 13 from t1 where t1.e not in (a+t1.c,t1.e*t1.a+t1.d* -a*(a)*f,((b)))),19) not in (c,t1.f,t1.b))),(select abs( -max(19)) from t1))),t1.f)-t1.b, -f,17))}\n} {}\ndo_test randexpr-2.813 {\n  db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) |  -min(t1.b))) from t1 union select  -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end}\n} {}\ndo_test randexpr-2.814 {\n  db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) |  -min(t1.b))) from t1 union select  -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE NOT (t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end)}\n} {-54800}\ndo_test randexpr-2.815 {\n  db eval {SELECT t1.c*case when (t1.f in (select case (coalesce((select t1.d from t1 where not (coalesce((select d from t1 where f<=(11)),19)*e in (select ((min((17)) &  -min(t1.b))) from t1 union select  -cast(avg(t1.f) AS integer) from t1))),19)+11)*t1.a when t1.d then t1.a else f end-e-t1.a*( -17) from t1 union select c from t1) or 13 not between t1.e and b) then d+19-t1.f else t1.c end-e FROM t1 WHERE NOT (t1.f in (~t1.b,13,+e) and 11<>d-case when t1.e<>t1.b or f>t1.f and 19 not between 17 and case when (b not in (b,t1.d,a)) then e else (abs(11)/abs(d)) end and not exists(select 1 from t1 where t1.a<>c) then t1.f when not (t1.b) in (select t1.d from t1 union select t1.c from t1) then 13 else t1.b+a end)}\n} {-54800}\ndo_test randexpr-2.816 {\n  db eval {SELECT e-t1.e+a*f*11*c*case when ~f*t1.d-t1.c*b-13*19+(abs(t1.d)/abs(case when t1.c=13 then 17 else 19 end))*a between b*(select abs(cast(avg(( -13)) AS integer)) from t1)-19+19 and t1.b then t1.d else t1.d end+13 FROM t1 WHERE t1.b not between a and e}\n} {}\ndo_test randexpr-2.817 {\n  db eval {SELECT e-t1.e+a*f*11*c*case when ~f*t1.d-t1.c*b-13*19+(abs(t1.d)/abs(case when t1.c=13 then 17 else 19 end))*a between b*(select abs(cast(avg(( -13)) AS integer)) from t1)-19+19 and t1.b then t1.d else t1.d end+13 FROM t1 WHERE NOT (t1.b not between a and e)}\n} {79200000013}\ndo_test randexpr-2.818 {\n  db eval {SELECT case case when coalesce((select b from t1 where not exists(select 1 from t1 where d-e+coalesce((select max(b) from t1 where case case when t1.d-t1.e not between t1.f and e then 11 else t1.d end when t1.e then f else b end+t1.e=13),t1.c) not in (( -c),c,t1.d))),t1.f)<>a and c not in (t1.b,c,t1.a) then (select count(*) from t1) else c end-11 when t1.d then t1.e else c end FROM t1 WHERE ~b | coalesce((select case (select +count(distinct b) from t1) when coalesce((select case when coalesce((select e from t1 where c>b),t1.c) between 11 and (b) then t1.d else t1.b end-e from t1 where t1.d in (13,t1.a,f)),17) then e else 17 end from t1 where not b=t1.c or t1.d in (select abs(abs( -min(13)*(cast(avg(t1.c) AS integer)))) from t1 union select (max(c)) from t1) and b>t1.a),t1.f) in (select 11 from t1 union select c from t1)}\n} {}\ndo_test randexpr-2.819 {\n  db eval {SELECT case case when coalesce((select b from t1 where not exists(select 1 from t1 where d-e+coalesce((select max(b) from t1 where case case when t1.d-t1.e not between t1.f and e then 11 else t1.d end when t1.e then f else b end+t1.e=13),t1.c) not in (( -c),c,t1.d))),t1.f)<>a and c not in (t1.b,c,t1.a) then (select count(*) from t1) else c end-11 when t1.d then t1.e else c end FROM t1 WHERE NOT (~b | coalesce((select case (select +count(distinct b) from t1) when coalesce((select case when coalesce((select e from t1 where c>b),t1.c) between 11 and (b) then t1.d else t1.b end-e from t1 where t1.d in (13,t1.a,f)),17) then e else 17 end from t1 where not b=t1.c or t1.d in (select abs(abs( -min(13)*(cast(avg(t1.c) AS integer)))) from t1 union select (max(c)) from t1) and b>t1.a),t1.f) in (select 11 from t1 union select c from t1))}\n} {300}\ndo_test randexpr-2.820 {\n  db eval {SELECT case t1.c when t1.e then 19 else  -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where  -19 in (f,a,13)),f)))+min(e) | ( -(min(13))) from t1) from t1 where f between  -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE t1.e<>f}\n} {-13}\ndo_test randexpr-2.821 {\n  db eval {SELECT case t1.c when t1.e then 19 else  -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where  -19 in (f,a,13)),f)))+min(e) | ( -(min(13))) from t1) from t1 where f between  -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE NOT (t1.e<>f)}\n} {}\ndo_test randexpr-2.822 {\n  db eval {SELECT case t1.c when t1.e then 19 else  -case when not exists(select 1 from t1 where t1.b in (select (t1.b) from t1 union select +13 from t1)) then coalesce((select max(c*t1.b) from t1 where 17>=19*e),coalesce((select (select abs(~min(coalesce((select max(t1.a) from t1 where  -19 in (f,a,13)),f)))+min(e) & ( -(min(13))) from t1) from t1 where f between  -a and t1.c),t1.e)) when 19<>a then 13 else c end end FROM t1 WHERE t1.e<>f}\n} {-13}\ndo_test randexpr-2.823 {\n  db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case  -min(~t1.f)+min(coalesce((select  -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select  -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) | t1.a)/abs(c)) | t1.f FROM t1 WHERE (abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f |  -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1)}\n} {}\ndo_test randexpr-2.824 {\n  db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case  -min(~t1.f)+min(coalesce((select  -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select  -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) | t1.a)/abs(c)) | t1.f FROM t1 WHERE NOT ((abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f |  -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1))}\n} {605}\ndo_test randexpr-2.825 {\n  db eval {SELECT 13- -(abs(coalesce((select max(17) from t1 where f*b in (select count(*)*case  -min(~t1.f)+min(coalesce((select  -(select min(17) from t1) from t1 where (t1.b in (select abs(min(t1.f)) from t1 union select  -max(t1.e) from t1))),17)+d) when count(distinct a) then abs(count(*)) else count(*) end from t1 union select min(t1.c) from t1)),coalesce((select max(f) from t1 where d in (select t1.b from t1 union select t1.e from t1)),17)) & t1.a)/abs(c)) & t1.f FROM t1 WHERE NOT ((abs(t1.f*11++ -f)/abs(19 | (abs(((abs(f)/abs(17))))/abs(case when a not in (t1.d,(c)-~c*f |  -13-t1.b+ -d,13) then t1.f when 11=11 then c else d end))*d+t1.c))+e+ -(t1.d) in (select t1.a from t1 union select 19 from t1))}\n} {8}\ndo_test randexpr-2.826 {\n  db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or  -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a | 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE case when case case when case when  -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else  -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1)}\n} {689}\ndo_test randexpr-2.827 {\n  db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or  -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a | 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE NOT (case when case case when case when  -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else  -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1))}\n} {}\ndo_test randexpr-2.828 {\n  db eval {SELECT (a+case when (exists(select 1 from t1 where not exists(select 1 from t1 where not t1.e*13=13-f or (e)=t1.c or  -d not between t1.b and t1.a or e not between 17 and (a) and 11 not in (a,(t1.f),a) or t1.e<>13 or t1.d between t1.e and t1.c or t1.d=17 or a>=b))) and a between t1.e and t1.b then case when e not between (17) and t1.d then ~c*coalesce((select t1.a & 13+d from t1 where t1.e not between b and 11),t1.a) else t1.f end else t1.f end-11) FROM t1 WHERE case when case case when case when  -(select +min(11) from t1)*(13)>11 then t1.e when 13<e then 19 else c end in (t1.a,a,t1.e) then 17 when c<>t1.a then t1.d else  -t1.e end when (a) then a else t1.e end>t1.a then 13 when t1.a not in (t1.f,t1.b,t1.a) then a else t1.c end in (select cast(avg(13) AS integer) from t1 union select (max(t1.e)+min(17)) from t1)}\n} {689}\ndo_test randexpr-2.829 {\n  db eval {SELECT ~b-t1.a-f*+case when exists(select 1 from t1 where 17<>t1.d-f or not exists(select 1 from t1 where (select (min(a)+count(distinct d)) from t1)+( -f)- -c<t1.e or d not between t1.a and b and exists(select 1 from t1 where 11<(a)) and 13=d or 13 between (t1.f) and f)) then t1.b when a not in (e,d,d) then (select ((count(*))) from t1) else case d when d then  -e else 11 end end FROM t1 WHERE ~(abs(17)/abs((a)))*~t1.e-coalesce((select (abs((select abs(cast(avg(d) AS integer)) from t1) | 13*e+17)/abs(t1.f)) from t1 where t1.c<>f and not exists(select 1 from t1 where t1.c<b or 19 in (17,19,b) or 17 not between a and f) or a not in (c,b,17)),t1.c)+t1.a-e-t1.f*e+ -a-t1.a*d not in (d,( -f),t1.a)}\n} {-120301}\ndo_test randexpr-2.830 {\n  db eval {SELECT ~b-t1.a-f*+case when exists(select 1 from t1 where 17<>t1.d-f or not exists(select 1 from t1 where (select (min(a)+count(distinct d)) from t1)+( -f)- -c<t1.e or d not between t1.a and b and exists(select 1 from t1 where 11<(a)) and 13=d or 13 between (t1.f) and f)) then t1.b when a not in (e,d,d) then (select ((count(*))) from t1) else case d when d then  -e else 11 end end FROM t1 WHERE NOT (~(abs(17)/abs((a)))*~t1.e-coalesce((select (abs((select abs(cast(avg(d) AS integer)) from t1) | 13*e+17)/abs(t1.f)) from t1 where t1.c<>f and not exists(select 1 from t1 where t1.c<b or 19 in (17,19,b) or 17 not between a and f) or a not in (c,b,17)),t1.c)+t1.a-e-t1.f*e+ -a-t1.a*d not in (d,( -f),t1.a))}\n} {}\ndo_test randexpr-2.831 {\n  db eval {SELECT (t1.a)*t1.d*t1.c+t1.b*case when (select case count(*) when (count(*))+ - -count(*)+cast(avg(t1.d) AS integer)- - -min(f) then min(11) else cast(avg(c) AS integer) end from t1) in (select (cast(avg((19)) AS integer)) from t1 union select max(t1.e) from t1) then b when d=a then t1.f else coalesce((select t1.c from t1 where not exists(select 1 from t1 where (~+a not in ((a),b,t1.f)))),case e when 13 then t1.f else 13 end) end FROM t1 WHERE c | a | ~(t1.d)+t1.b not in (t1.a* -+13+~(abs( -case when (11) in (select e from t1 union select t1.f*coalesce((select case when e<e then t1.f when (13) in (13,t1.d,t1.c) then c else t1.d end from t1 where t1.b between  -11 and e),e) from t1) then t1.a else d end*t1.a)/abs(t1.e)),19,d) or t1.e<b}\n} {12002600}\ndo_test randexpr-2.832 {\n  db eval {SELECT (t1.a)*t1.d*t1.c+t1.b*case when (select case count(*) when (count(*))+ - -count(*)+cast(avg(t1.d) AS integer)- - -min(f) then min(11) else cast(avg(c) AS integer) end from t1) in (select (cast(avg((19)) AS integer)) from t1 union select max(t1.e) from t1) then b when d=a then t1.f else coalesce((select t1.c from t1 where not exists(select 1 from t1 where (~+a not in ((a),b,t1.f)))),case e when 13 then t1.f else 13 end) end FROM t1 WHERE NOT (c | a | ~(t1.d)+t1.b not in (t1.a* -+13+~(abs( -case when (11) in (select e from t1 union select t1.f*coalesce((select case when e<e then t1.f when (13) in (13,t1.d,t1.c) then c else t1.d end from t1 where t1.b between  -11 and e),e) from t1) then t1.a else d end*t1.a)/abs(t1.e)),19,d) or t1.e<b)}\n} {}\ndo_test randexpr-2.833 {\n  db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 | t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE (select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f)}\n} {400}\ndo_test randexpr-2.834 {\n  db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 | t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE NOT ((select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f))}\n} {}\ndo_test randexpr-2.835 {\n  db eval {SELECT case when case ~( -t1.e)-a when coalesce((select max(case +t1.e when t1.b*~19 & t1.a*case when c-c<>19 then 13 else c end*d+t1.c then f else 17 end) from t1 where d<=e), -d) then 19 else 17 end in (t1.b,19,c) then 19 when t1.a in (select a from t1 union select 13 from t1) then t1.d else t1.d end FROM t1 WHERE (select abs(cast(avg(t1.d*t1.f) AS integer))-cast(avg(b) AS integer) from t1)-~coalesce((select max(t1.a+t1.d-coalesce((select max(a*case when t1.e<=e then f when t1.d<>a then 11 else 11 end*t1.a*11) from t1 where t1.d>=d),t1.f)) from t1 where 11 not between (13) and 17),f)*t1.b+17-e not in (t1.d,t1.f,t1.f)}\n} {400}\ndo_test randexpr-2.836 {\n  db eval {SELECT t1.d+case when case when case when (19 not between ~(t1.a)*b and t1.c) then (select (abs(case count(distinct t1.e) when min( -f) then  -max(t1.d) else cast(avg(19) AS integer) end-(count(distinct t1.e)))) from t1) when a<>t1.f then  -19 else 11 end>f or b in ((13),f,11) then t1.a when t1.e in (e,f,t1.f) then (t1.d) else t1.d end in (17,t1.c,17) then 13 when b not between t1.a and (19) then t1.e else  -11 end+a+((f)) FROM t1 WHERE t1.f in (select case +cast(avg(t1.f+c) AS integer)++count(*) when count(*) then ~~(count(distinct 11+t1.a)) else +(case max(e-f) | ~ -max(t1.f) |  -abs(abs(min(e-19+e))-abs(count(*)))-abs(cast(avg(f) AS integer)) when (min(f)) then cast(avg(a) AS integer) else min(13) end) end from t1 union select  -count(distinct 13) from t1)}\n} {}\ndo_test randexpr-2.837 {\n  db eval {SELECT t1.d+case when case when case when (19 not between ~(t1.a)*b and t1.c) then (select (abs(case count(distinct t1.e) when min( -f) then  -max(t1.d) else cast(avg(19) AS integer) end-(count(distinct t1.e)))) from t1) when a<>t1.f then  -19 else 11 end>f or b in ((13),f,11) then t1.a when t1.e in (e,f,t1.f) then (t1.d) else t1.d end in (17,t1.c,17) then 13 when b not between t1.a and (19) then t1.e else  -11 end+a+((f)) FROM t1 WHERE NOT (t1.f in (select case +cast(avg(t1.f+c) AS integer)++count(*) when count(*) then ~~(count(distinct 11+t1.a)) else +(case max(e-f) | ~ -max(t1.f) |  -abs(abs(min(e-19+e))-abs(count(*)))-abs(cast(avg(f) AS integer)) when (min(f)) then cast(avg(a) AS integer) else min(13) end) end from t1 union select  -count(distinct 13) from t1))}\n} {1600}\ndo_test randexpr-2.838 {\n  db eval {SELECT (select (min(case when b+b*(select cast(avg(e+19-t1.f*case when case when not (c) in (select (e) from t1 union select f from t1) or t1.b not in (t1.e,t1.b,11) or 19= -t1.a then 17 else  -d end<e then e when t1.b>13 then 13 else t1.f end+11*19) AS integer) from t1)+d not between 11 and c then t1.c else t1.c end)) from t1) FROM t1 WHERE 13 not between +b* -f and coalesce((select f*19-case when not a=~f+t1.d then case when d*b not in (case when d not between  -c and t1.d then e else 13 end+17,c,t1.a) then b when t1.e>t1.f then b else  -d end else f end-e+(d) from t1 where 17 between t1.a and t1.e),t1.d) | t1.b}\n} {}\ndo_test randexpr-2.839 {\n  db eval {SELECT (select (min(case when b+b*(select cast(avg(e+19-t1.f*case when case when not (c) in (select (e) from t1 union select f from t1) or t1.b not in (t1.e,t1.b,11) or 19= -t1.a then 17 else  -d end<e then e when t1.b>13 then 13 else t1.f end+11*19) AS integer) from t1)+d not between 11 and c then t1.c else t1.c end)) from t1) FROM t1 WHERE NOT (13 not between +b* -f and coalesce((select f*19-case when not a=~f+t1.d then case when d*b not in (case when d not between  -c and t1.d then e else 13 end+17,c,t1.a) then b when t1.e>t1.f then b else  -d end else f end-e+(d) from t1 where 17 between t1.a and t1.e),t1.d) | t1.b)}\n} {300}\ndo_test randexpr-2.840 {\n  db eval {SELECT t1.c-(abs((select (case abs(count(distinct 11-c*11)) when count(*) then count(*) else  -min(+e+~e+coalesce((select d-a*t1.d+t1.e from t1 where (t1.f>=17) and t1.e in (11,a,e)),13)*t1.d) end) from t1)-(a-t1.f)-t1.d)/abs(d)) FROM t1 WHERE t1.c in (select d from t1 union select ( -t1.e) from t1)}\n} {}\ndo_test randexpr-2.841 {\n  db eval {SELECT t1.c-(abs((select (case abs(count(distinct 11-c*11)) when count(*) then count(*) else  -min(+e+~e+coalesce((select d-a*t1.d+t1.e from t1 where (t1.f>=17) and t1.e in (11,a,e)),13)*t1.d) end) from t1)-(a-t1.f)-t1.d)/abs(d)) FROM t1 WHERE NOT (t1.c in (select d from t1 union select ( -t1.e) from t1))}\n} {300}\ndo_test randexpr-2.842 {\n  db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b | d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then  -t1.f when  -a<=19 or  -11<>t1.f then  -19 else d end FROM t1 WHERE ((13 in (t1.b,f,b)))}\n} {}\ndo_test randexpr-2.843 {\n  db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b | d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then  -t1.f when  -a<=19 or  -11<>t1.f then  -19 else d end FROM t1 WHERE NOT (((13 in (t1.b,f,b))))}\n} {-19}\ndo_test randexpr-2.844 {\n  db eval {SELECT case when coalesce((select max(t1.a-case when not (coalesce((select d+c from t1 where c between ( -(a)) and b or 17 between 11 and (c)),(t1.f)))=f then b & d when f not in (t1.b,f,a) then t1.a else f end-t1.f) from t1 where 19<=11 and t1.c between 19 and t1.a or t1.f>11), -t1.e)*e between b and 17 then  -t1.f when  -a<=19 or  -11<>t1.f then  -19 else d end FROM t1 WHERE NOT (((13 in (t1.b,f,b))))}\n} {-19}\ndo_test randexpr-2.845 {\n  db eval {SELECT case  -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a | t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE  -b*t1.c>13}\n} {}\ndo_test randexpr-2.846 {\n  db eval {SELECT case  -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a | t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE NOT ( -b*t1.c>13)}\n} {0}\ndo_test randexpr-2.847 {\n  db eval {SELECT case  -(abs(t1.b-13*d*b*t1.e- -11)/abs(+d-t1.f*(11+ -13)-t1.c))+c+(e*t1.c)+f*17*a & t1.e-13+f when t1.d then t1.e else f end-t1.f FROM t1 WHERE NOT ( -b*t1.c>13)}\n} {0}\ndo_test randexpr-2.848 {\n  db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 | e end when (select abs(abs(min(11) | max((a)))) from t1) then d else ~t1.f end)) | t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE +13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17}\n} {-87}\ndo_test randexpr-2.849 {\n  db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 | e end when (select abs(abs(min(11) | max((a)))) from t1) then d else ~t1.f end)) | t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE NOT (+13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17)}\n} {}\ndo_test randexpr-2.850 {\n  db eval {SELECT case when t1.c between t1.e and ~t1.d+(abs(~d*case t1.b-19 when t1.e then e else e end)/abs(case case t1.b when c then t1.d else 13+17 & e end when (select abs(abs(min(11) & max((a)))) from t1) then d else ~t1.f end)) & t1.b then t1.c when (not (11>=b)) then 13 else e end-a FROM t1 WHERE +13*case when +11*t1.f=f+t1.b then t1.f else t1.b end not between coalesce((select max(f) from t1 where (not exists(select 1 from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where t1.c in (select abs(min(e)) from t1 union select ~ -case cast(avg(~17) AS integer) when min(e | 17) then min(e) else cast(avg(c) AS integer) end from t1)))) or f>e*t1.a+e)),t1.c) and 17}\n} {-87}\ndo_test randexpr-2.851 {\n  db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) | count(distinct t1.e)+( -cast(avg(13) AS integer)) | max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c | t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE (abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a)}\n} {}\ndo_test randexpr-2.852 {\n  db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) | count(distinct t1.e)+( -cast(avg(13) AS integer)) | max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c | t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE NOT ((abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a))}\n} {19}\ndo_test randexpr-2.853 {\n  db eval {SELECT coalesce((select +case when case d when b then e else (select min(case b when 17 then b else t1.c end)+ -+ -(abs(max(t1.e))-min(t1.d)+max( -d)) & count(distinct t1.e)+( -cast(avg(13) AS integer)) & max(t1.f)+min(e)+count(*) from t1) end<>b then t1.a else 19*~t1.e-c & t1.c end from t1 where b in ( -c,t1.f,t1.c)),19) FROM t1 WHERE NOT ((abs(d)/abs(coalesce((select max(coalesce((select d*c from t1 where ((abs(t1.b)/abs(t1.d))-(abs(t1.f)/abs(t1.c))+(t1.a)*13-t1.e not between t1.e and ~f*11+t1.f-11 | t1.a+13+d)),19)) from t1 where c not in (+ -11,a,c)),t1.c))) in (b,b,a))}\n} {19}\ndo_test randexpr-2.854 {\n  db eval {SELECT a-a-(abs(f)/abs(coalesce((select 17+19 from t1 where (select min(t1.e*e) from t1)>t1.b+case when not exists(select 1 from t1 where e not between 11 and t1.f-e) then coalesce((select max(f*case when t1.f not in (19,t1.c,(t1.a)) and c<=17 then 11 when 17 not between 11 and 17 then c else 17 end) from t1 where d not between t1.a and 13),t1.c) else t1.b end-13 and a=t1.e),17)+t1.c))-f FROM t1 WHERE +(select cast(avg(13-t1.a-t1.b++t1.a-(select count(*) from t1)+case b-(select +~ -min(case when exists(select 1 from t1 where ((select count(*)+ -(min(13)) from t1)) not between 13 and 13) then d else e end) from t1) when f*t1.b*t1.b then t1.a else b end*t1.a) AS integer) from t1)*t1.b in (t1.f,17,f)}\n} {}\ndo_test randexpr-2.855 {\n  db eval {SELECT a-a-(abs(f)/abs(coalesce((select 17+19 from t1 where (select min(t1.e*e) from t1)>t1.b+case when not exists(select 1 from t1 where e not between 11 and t1.f-e) then coalesce((select max(f*case when t1.f not in (19,t1.c,(t1.a)) and c<=17 then 11 when 17 not between 11 and 17 then c else 17 end) from t1 where d not between t1.a and 13),t1.c) else t1.b end-13 and a=t1.e),17)+t1.c))-f FROM t1 WHERE NOT (+(select cast(avg(13-t1.a-t1.b++t1.a-(select count(*) from t1)+case b-(select +~ -min(case when exists(select 1 from t1 where ((select count(*)+ -(min(13)) from t1)) not between 13 and 13) then d else e end) from t1) when f*t1.b*t1.b then t1.a else b end*t1.a) AS integer) from t1)*t1.b in (t1.f,17,f))}\n} {-601}\ndo_test randexpr-2.856 {\n  db eval {SELECT case when (11+19 | t1.e-e*17=t1.e*~d+t1.a+ -d | a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e}\n} {100}\ndo_test randexpr-2.857 {\n  db eval {SELECT case when (11+19 | t1.e-e*17=t1.e*~d+t1.a+ -d | a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE NOT (case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e)}\n} {}\ndo_test randexpr-2.858 {\n  db eval {SELECT case when (11+19 & t1.e-e*17=t1.e*~d+t1.a+ -d & a-~(abs((abs((case when 13 not in (b,((t1.a)),f) then t1.d else t1.a end+e))/abs(t1.f))*b+t1.b)/abs(17))+t1.e+t1.a) then 11 else t1.a end FROM t1 WHERE case (case when (select +~ -~ -cast(avg(b*e*case when t1.a between t1.c and a and d<13 then b else 19 end* -f*d) AS integer) | count(*)++~+min((11))*max(19)-min((b)) from t1) in (select 13 from t1 union select (select min(19) from t1) from t1) then t1.f+t1.d else 13 end-t1.e) when t1.e then t1.f else a end<e}\n} {100}\ndo_test randexpr-2.859 {\n  db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select  -max(d | coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) | min(t1.c) | (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select  - - - -count(*) from t1 union select  -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE ~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1)}\n} {}\ndo_test randexpr-2.860 {\n  db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select  -max(d | coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) | min(t1.c) | (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select  - - - -count(*) from t1 union select  -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE NOT (~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1))}\n} {17}\ndo_test randexpr-2.861 {\n  db eval {SELECT coalesce((select max(+t1.a) from t1 where c in (select  -max(d & coalesce((select max(t1.b) from t1 where (abs(case d when t1.f then t1.e else t1.c end-t1.f)/abs(13))<=11), -a)) & min(t1.c) & (max(f))++abs(case max(b) when (count(distinct e)) then count(*) else min(17) end) from t1 union select (min(19)) from t1) or not exists(select 1 from t1 where coalesce((select c from t1 where b in (select  - - - -count(*) from t1 union select  -min((a)) from t1)),13)<t1.d)),17) FROM t1 WHERE NOT (~a in (select count(*) from t1 union select case +abs((abs(abs(count(*))))+min(a))*max(case when exists(select 1 from t1 where d between 17+(b)-a and 17) then (select count(*) from t1) when 13<> -t1.b then t1.f else t1.e end)*min(t1.a)+ -count(*) | +max(e)*(min(t1.e)) | count(distinct t1.d) | (count(*)) when count(distinct ((19))) then count(*) else max(t1.f) end from t1))}\n} {17}\ndo_test randexpr-2.862 {\n  db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c | 17-(e))/abs(t1.f)) | 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE t1.a>t1.c-19}\n} {}\ndo_test randexpr-2.863 {\n  db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c | 17-(e))/abs(t1.f)) | 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE NOT (t1.a>t1.c-19)}\n} {600}\ndo_test randexpr-2.864 {\n  db eval {SELECT case 17 when (select ~count(distinct t1.d) from t1) then e else case when not not exists(select 1 from t1 where (abs(~coalesce((select (coalesce((select max(13) from t1 where e>a),19)) from t1 where (not exists(select 1 from t1 where t1.c in (f,b,c)))),c)*t1.c & 17-(e))/abs(t1.f)) & 17*17*a in (select e from t1 union select f from t1)) then 13 when t1.a not between (b) and t1.c then (abs(17)/abs(17)) else t1.d end*f end FROM t1 WHERE NOT (t1.a>t1.c-19)}\n} {600}\ndo_test randexpr-2.865 {\n  db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b | 11,t1.b) then  -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then  -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c}\n} {}\ndo_test randexpr-2.866 {\n  db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b | 11,t1.b) then  -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE NOT (a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then  -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c)}\n} {389}\ndo_test randexpr-2.867 {\n  db eval {SELECT case when f>=t1.c then t1.d when coalesce((select max(+11-b) from t1 where a-t1.d in (select +case when f in (13,b & 11,t1.b) then  -t1.d when f in (select ~count(distinct 17) from t1 union select count(distinct t1.a) from t1) then 19 else c end-d+b from t1 union select a from t1) and (17) in (t1.f,11,t1.c)),f)< -a then d else t1.c end-11 FROM t1 WHERE NOT (a<(select count(distinct +11*coalesce((select max(coalesce((select max(t1.d) from t1 where t1.e>t1.b),b)*t1.f) from t1 where case 11 when t1.a then  -t1.e else a end<=17),e)-11+c-19) | count(distinct 19)*count(*)* -(count(distinct t1.f))+cast(avg(17) AS integer)-(~~(count(*)))-cast(avg(11) AS integer) | cast(avg((19)) AS integer) from t1)-t1.c)}\n} {389}\ndo_test randexpr-2.868 {\n  db eval {SELECT coalesce((select max(17) from t1 where  -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) | min(t1.a) from t1) when  -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where  -11=17*t1.d*f))}\n} {}\ndo_test randexpr-2.869 {\n  db eval {SELECT coalesce((select max(17) from t1 where  -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) | min(t1.a) from t1) when  -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where  -11=17*t1.d*f)))}\n} {17}\ndo_test randexpr-2.870 {\n  db eval {SELECT coalesce((select max(17) from t1 where  -coalesce((select t1.b+coalesce((select case when case t1.f when c then (e) else a end+t1.c+(f)>17 and e>=f and (13>t1.f) then (select ~(cast(avg(t1.e) AS integer)) & min(t1.a) from t1) when  -c>c then 19 else t1.f end from t1 where (17<t1.f)),t1.f) from t1 where not exists(select 1 from t1 where 13 not between t1.a and c)),d)*17< -t1.c),b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where  -11=17*t1.d*f)))}\n} {17}\ndo_test randexpr-2.871 {\n  db eval {SELECT case when a*t1.a*a in (select case (e- -11+case when ~c>=a then 13 when ((case when t1.d<t1.d then f when t1.c not between a and t1.e then  -f else t1.f end>=a)) then 19 else t1.b end-t1.f) when 19 then  - -13 else 17 end from t1 union select  -17 from t1) and 19 in (select d from t1 union select e from t1) then (select abs(min(t1.f)) from t1) else c end FROM t1 WHERE case coalesce((select 19 from t1 where 13<coalesce((select 19 | case when t1.e>=e then d when (case when not exists(select 1 from t1 where (a>d and d not between e and ((19)) and c in (e,t1.b,(b)) and e not in (t1.f,t1.a,t1.b))) then t1.b when f not between 11 and d then t1.d else d end<=11) then (abs(13)/abs(11)) else  -11 end from t1 where (t1.b)<d),b)),11) | d when c then 17 else (e) end not in (t1.e,t1.c,a)}\n} {}\ndo_test randexpr-2.872 {\n  db eval {SELECT case when a*t1.a*a in (select case (e- -11+case when ~c>=a then 13 when ((case when t1.d<t1.d then f when t1.c not between a and t1.e then  -f else t1.f end>=a)) then 19 else t1.b end-t1.f) when 19 then  - -13 else 17 end from t1 union select  -17 from t1) and 19 in (select d from t1 union select e from t1) then (select abs(min(t1.f)) from t1) else c end FROM t1 WHERE NOT (case coalesce((select 19 from t1 where 13<coalesce((select 19 | case when t1.e>=e then d when (case when not exists(select 1 from t1 where (a>d and d not between e and ((19)) and c in (e,t1.b,(b)) and e not in (t1.f,t1.a,t1.b))) then t1.b when f not between 11 and d then t1.d else d end<=11) then (abs(13)/abs(11)) else  -11 end from t1 where (t1.b)<d),b)),11) | d when c then 17 else (e) end not in (t1.e,t1.c,a))}\n} {300}\ndo_test randexpr-2.873 {\n  db eval {SELECT case when t1.e not between (select +max(17) from t1)*t1.f and d then t1.c+case when e+f<=coalesce((select max((19)) from t1 where t1.e not in ((abs( -17-17)/abs(t1.e)),(c),(t1.b))),d) and 13 in (select d from t1 union select c from t1) then 19 else c end-19 when exists(select 1 from t1 where t1.a in (select t1.a from t1 union select 13 from t1)) and not exists(select 1 from t1 where a<19) then b else t1.b end FROM t1 WHERE not t1.d=b}\n} {581}\ndo_test randexpr-2.874 {\n  db eval {SELECT case when t1.e not between (select +max(17) from t1)*t1.f and d then t1.c+case when e+f<=coalesce((select max((19)) from t1 where t1.e not in ((abs( -17-17)/abs(t1.e)),(c),(t1.b))),d) and 13 in (select d from t1 union select c from t1) then 19 else c end-19 when exists(select 1 from t1 where t1.a in (select t1.a from t1 union select 13 from t1)) and not exists(select 1 from t1 where a<19) then b else t1.b end FROM t1 WHERE NOT (not t1.d=b)}\n} {}\ndo_test randexpr-2.875 {\n  db eval {SELECT +17+(11)-coalesce((select max(case (11) when f then +e+case when +11< -13-f or b between (b) and t1.b and e<>t1.c and e not between 13 and t1.d and t1.e in (t1.d,17,t1.c) then c+t1.e*t1.d when t1.f>=t1.d then t1.a else t1.c end else t1.e end-e) from t1 where t1.b not in (t1.b,t1.d,d)), -c)*13 FROM t1 WHERE (abs(e+17)/abs((select count(distinct 11-t1.b)*cast(avg(case c when coalesce((select max(19-coalesce((select max(f) from t1 where 19 in (17,t1.f,11)),t1.d)) from t1 where c in (t1.a,11,13) and t1.a<=t1.c),t1.c) then t1.c else e end) AS integer) | max(e) | (+~case case cast(avg(t1.d) AS integer) when  -min(13) then count(*) else count(*) end when max(t1.c) then count(distinct f) else count(*) end-count(distinct 19)) from t1)))>=t1.e | f}\n} {}\ndo_test randexpr-2.876 {\n  db eval {SELECT +17+(11)-coalesce((select max(case (11) when f then +e+case when +11< -13-f or b between (b) and t1.b and e<>t1.c and e not between 13 and t1.d and t1.e in (t1.d,17,t1.c) then c+t1.e*t1.d when t1.f>=t1.d then t1.a else t1.c end else t1.e end-e) from t1 where t1.b not in (t1.b,t1.d,d)), -c)*13 FROM t1 WHERE NOT ((abs(e+17)/abs((select count(distinct 11-t1.b)*cast(avg(case c when coalesce((select max(19-coalesce((select max(f) from t1 where 19 in (17,t1.f,11)),t1.d)) from t1 where c in (t1.a,11,13) and t1.a<=t1.c),t1.c) then t1.c else e end) AS integer) | max(e) | (+~case case cast(avg(t1.d) AS integer) when  -min(13) then count(*) else count(*) end when max(t1.c) then count(distinct f) else count(*) end-count(distinct 19)) from t1)))>=t1.e | f)}\n} {3928}\ndo_test randexpr-2.877 {\n  db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d | d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and  -b then c else t1.a end FROM t1 WHERE t1.d<>t1.a}\n} {500}\ndo_test randexpr-2.878 {\n  db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d | d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and  -b then c else t1.a end FROM t1 WHERE NOT (t1.d<>t1.a)}\n} {}\ndo_test randexpr-2.879 {\n  db eval {SELECT case when case when d*c not in (13,a,d) then (t1.b-f)+coalesce((select max((select count(distinct 13)-case max(11) when count(*) then count(*) else min(t1.b) end*min(17)+(min(t1.c)) from t1)) from t1 where not exists(select 1 from t1 where t1.c between 17-d & d and t1.e)),b) else t1.e end<=d then e when f in (a,13,d) or t1.b between f and  -b then c else t1.a end FROM t1 WHERE t1.d<>t1.a}\n} {500}\ndo_test randexpr-2.880 {\n  db eval {SELECT case case c when  -b then (abs(b)/abs(c)) else (select count(distinct f) | (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select  -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end | e))) from t1) end when  -13 then t1.f else +17 end FROM t1 WHERE 17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when  -+~count(distinct  -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then  -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then  -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1)}\n} {}\ndo_test randexpr-2.881 {\n  db eval {SELECT case case c when  -b then (abs(b)/abs(c)) else (select count(distinct f) | (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select  -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end | e))) from t1) end when  -13 then t1.f else +17 end FROM t1 WHERE NOT (17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when  -+~count(distinct  -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then  -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then  -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1))}\n} {17}\ndo_test randexpr-2.882 {\n  db eval {SELECT case case c when  -b then (abs(b)/abs(c)) else (select count(distinct f) & (~abs(min(c-+case 11 when case when t1.a between b and t1.e-case when (13<=b) then (select  -count(*) from t1) else a end then t1.e when e>=11 then (19) else b end then d else 17 end & e))) from t1) end when  -13 then t1.f else +17 end FROM t1 WHERE NOT (17 in (select +(count(*) | case abs( -abs(abs( -min(d)))) | max(+11) when  -+~count(distinct  -(abs(coalesce((select max(f) from t1 where t1.e in (select e from t1 union select t1.a from t1)),f) | t1.c-t1.b)/abs(13))) | +abs(case max(b) when count(*) then  -min(t1.e) else (cast(avg(t1.f) AS integer)) end)- -count(*) then  -count(*) else max(19) end* -cast(avg(t1.b) AS integer))+(max(t1.f)) from t1 union select count(distinct b) from t1))}\n} {17}\ndo_test randexpr-2.883 {\n  db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select  -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) | case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e}\n} {500}\ndo_test randexpr-2.884 {\n  db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select  -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) | case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE NOT (e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e)}\n} {}\ndo_test randexpr-2.885 {\n  db eval {SELECT case 11 when (case when t1.e in (select +cast(avg(coalesce((select max(13) from t1 where case when exists(select 1 from t1 where t1.b in ((a),d,(t1.e))) then case when 19 in (select  -max(17) from t1 union select min(t1.f) from t1) then t1.b else 17 end when a not in ((t1.f),11,t1.e) then 17 else t1.c end<t1.b),11)*a) AS integer) from t1 union select max(b) & case (+min(t1.f)) when cast(avg(a) AS integer) then count(distinct 13) else max(t1.c) end from t1) then t1.e when c<=t1.d then t1.b else t1.f end-17) then b else t1.e end FROM t1 WHERE e-case when a*b between t1.d-(abs(11)/abs(coalesce((select t1.b from t1 where not exists(select 1 from t1 where c=17) or a not between (coalesce((select t1.c from t1 where 19>(19)),c)) and c and (11 in (select t1.b from t1 union select 13 from t1) and ( -t1.d)=d)),e | 19*t1.a))) and t1.a then t1.a when 19>=t1.a then e else c end> -e}\n} {500}\ndo_test randexpr-2.886 {\n  db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) | t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE (abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where  -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f}\n} {}\ndo_test randexpr-2.887 {\n  db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) | t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE NOT ((abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where  -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f)}\n} {60000}\ndo_test randexpr-2.888 {\n  db eval {SELECT case a*t1.a when ~++a*(abs(e)/abs(19)) & t1.d+(select count(*) from t1) then b else t1.a end*coalesce((select max(f) from t1 where f<>t1.d),b) FROM t1 WHERE NOT ((abs(c-~t1.b)/abs(d))-((+coalesce((select max(c) from t1 where  -+(select ~ -(cast(avg((13+case 11*t1.c when t1.b then f else ~e-coalesce((select max((f)) from t1 where t1.f<a), -t1.c-(t1.c)) end)) AS integer)) from t1)=d*a),t1.d)+a))* -t1.e=t1.f)}\n} {60000}\ndo_test randexpr-2.889 {\n  db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) | t1.b FROM t1 WHERE (abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then  -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then  -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1)}\n} {}\ndo_test randexpr-2.890 {\n  db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) | t1.b FROM t1 WHERE NOT ((abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then  -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then  -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1))}\n} {-792}\ndo_test randexpr-2.891 {\n  db eval {SELECT t1.c-t1.f-coalesce((select max(a) from t1 where e in ((abs(a)/abs(t1.d))*coalesce((select max((abs(case when e>=+t1.b then f when t1.c+f<a or e<>13 then t1.d else t1.a end)/abs(t1.d))) from t1 where t1.c not between t1.c and 11 and e>d),f)*t1.e+d,a,13)),e) & t1.b FROM t1 WHERE NOT ((abs(+(+t1.a)+case a-case when c>=d then 13 when t1.c not in (17,17,e) then a else t1.d end when c then  -f else b end*d)/abs(17))<=11 and 11 in (select cast(avg(17) AS integer) from t1 union select min( -19)+(case max(a) when abs(count(*)) then  -abs(count(*)*min(t1.e)+max(11)) else min(c) end) from t1))}\n} {192}\ndo_test randexpr-2.892 {\n  db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select  -count(*) | count(*) | count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where  -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) | b+d | 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when  -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end}\n} {100}\ndo_test randexpr-2.893 {\n  db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select  -count(*) | count(*) | count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where  -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) | b+d | 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE NOT (f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when  -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end)}\n} {}\ndo_test randexpr-2.894 {\n  db eval {SELECT coalesce((select (select count(*) from t1)*a*b from t1 where ((~b*a-t1.d+11*e-(select  -count(*) & count(*) & count(*) from t1)*(select min((abs(coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where  -17 in (t1.b,t1.f,t1.d))),11))/abs(t1.d))) from t1)-17+(abs(11)/abs(11)) & b+d & 11 in (select t1.a from t1 union select 13 from t1)))),t1.a) FROM t1 WHERE f>case when f-case when not exists(select 1 from t1 where case when b in (select abs(max(coalesce((select max(~t1.c) from t1 where t1.f<=13),17))) from t1 union select cast(avg(t1.c) AS integer) from t1) then t1.e else (13) end> -t1.e) or d<>19 then coalesce((select max((select abs(max(d)+cast(avg(d) AS integer)) from t1)) from t1 where t1.e<t1.c),19) when  -t1.c in (t1.e,t1.f,e) then 11 else t1.a end<>19 then b when t1.a<=11 then 11 else t1.d end}\n} {100}\ndo_test randexpr-2.895 {\n  db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) | ~max(19-t1.d) | cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE (13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17))}\n} {}\ndo_test randexpr-2.896 {\n  db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) | ~max(19-t1.d) | cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE NOT ((13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17)))}\n} {517}\ndo_test randexpr-2.897 {\n  db eval {SELECT coalesce((select e from t1 where ((abs((select case (~max(f) & ~max(19-t1.d) & cast(avg(11) AS integer)) when min(+t1.d*c) then max(case when 19+13 not between 13 and t1.c or t1.c not in ((b),11,(e)) then d else t1.d end+ -t1.d) else min(a) end from t1))/abs(11)))<17),t1.b)+17 FROM t1 WHERE NOT ((13 in (a,t1.a,~+(e)+t1.c*t1.c | t1.c- -t1.b-t1.b+e*b | t1.e-t1.e-e*coalesce((select max(t1.b) from t1 where t1.a*d<>coalesce((select max(t1.e-t1.b) from t1 where exists(select 1 from t1 where coalesce((select e from t1 where (17 not between 13 and t1.c)),t1.c)>=t1.c)),b)),t1.f)+17)))}\n} {517}\ndo_test randexpr-2.898 {\n  db eval {SELECT c | coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then  -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) | t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f}\n} {-19587}\ndo_test randexpr-2.899 {\n  db eval {SELECT c | coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then  -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) | t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE NOT (t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f)}\n} {}\ndo_test randexpr-2.900 {\n  db eval {SELECT c & coalesce((select max(~b*case +coalesce((select max( -(abs(c)/abs(11))+case when t1.c*17 not in (a,a,c) then t1.e when t1.b in (select 13 from t1 union select (c) from t1) then  -(t1.c) else d end* -t1.c+a) from t1 where t1.f>=11),17) & t1.b when t1.b then c else t1.a end) from t1 where t1.f>t1.a),t1.c)+13*17 FROM t1 WHERE t1.e<t1.c*(select min((select count(*) from t1)) from t1)*f}\n} {8}\ndo_test randexpr-2.901 {\n  db eval {SELECT coalesce((select max(a) from t1 where t1.b<t1.b),13 |  -(coalesce((select max((abs(~t1.a | (abs(11)/abs((abs(t1.e)/abs(coalesce((select max(t1.e) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)<>e) and not exists(select 1 from t1 where (19)=t1.e))),19*t1.e)-t1.c)) | 17))*t1.b)/abs(17))) from t1 where (t1.b) between d and t1.b),t1.c)) | t1.f-c-d) FROM t1 WHERE 13 not in (f,t1.c+11*c,coalesce((select e from t1 where case t1.b when c- -case (select cast(avg(+t1.c*t1.f) AS integer) from t1) when 13*case when not case when  -17 in (select (t1.c) from t1 union select t1.c from t1) or t1.f in (t1.b,t1.d,t1.b) then t1.a when 11<>t1.c then e else a end>=(11) and a=d or  -t1.f between c and b then e else t1.f end then 19 else t1.d end then t1.c else t1.b end<>13),d))}\n} {-35}\ndo_test randexpr-2.902 {\n  db eval {SELECT coalesce((select max(a) from t1 where t1.b<t1.b),13 |  -(coalesce((select max((abs(~t1.a | (abs(11)/abs((abs(t1.e)/abs(coalesce((select max(t1.e) from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)<>e) and not exists(select 1 from t1 where (19)=t1.e))),19*t1.e)-t1.c)) | 17))*t1.b)/abs(17))) from t1 where (t1.b) between d and t1.b),t1.c)) | t1.f-c-d) FROM t1 WHERE NOT (13 not in (f,t1.c+11*c,coalesce((select e from t1 where case t1.b when c- -case (select cast(avg(+t1.c*t1.f) AS integer) from t1) when 13*case when not case when  -17 in (select (t1.c) from t1 union select t1.c from t1) or t1.f in (t1.b,t1.d,t1.b) then t1.a when 11<>t1.c then e else a end>=(11) and a=d or  -t1.f between c and b then e else t1.f end then 19 else t1.d end then t1.c else t1.b end<>13),d)))}\n} {}\ndo_test randexpr-2.903 {\n  db eval {SELECT f+b+(t1.a+c)+(case when (select (cast(avg(coalesce((select max(t1.b) from t1 where case  -(select +cast(avg(b-t1.e) AS integer)-abs(cast(avg(~(abs(f)/abs(f))) AS integer)) from t1)+d when 11 then d else 13 end+t1.e<>t1.e),(t1.e))-13+13) AS integer)) from t1)-t1.b<>a then t1.e else e end) FROM t1 WHERE c in (select abs((max(t1.d))) from t1 union select count(*) from t1) and (coalesce((select max(+ -(t1.f-d)* -b) from t1 where not exists(select 1 from t1 where (b not in (coalesce((select t1.e-a from t1 where not t1.a between 13 and f or t1.b in (t1.e,e,17)),11),17,t1.a) and (b<>d)))),b) in (select  -min(17) from t1 union select abs(max(e)) from t1))}\n} {}\ndo_test randexpr-2.904 {\n  db eval {SELECT f+b+(t1.a+c)+(case when (select (cast(avg(coalesce((select max(t1.b) from t1 where case  -(select +cast(avg(b-t1.e) AS integer)-abs(cast(avg(~(abs(f)/abs(f))) AS integer)) from t1)+d when 11 then d else 13 end+t1.e<>t1.e),(t1.e))-13+13) AS integer)) from t1)-t1.b<>a then t1.e else e end) FROM t1 WHERE NOT (c in (select abs((max(t1.d))) from t1 union select count(*) from t1) and (coalesce((select max(+ -(t1.f-d)* -b) from t1 where not exists(select 1 from t1 where (b not in (coalesce((select t1.e-a from t1 where not t1.a between 13 and f or t1.b in (t1.e,e,17)),11),17,t1.a) and (b<>d)))),b) in (select  -min(17) from t1 union select abs(max(e)) from t1)))}\n} {1700}\ndo_test randexpr-2.905 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select  -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end | t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE exists(select 1 from t1 where f<=19)}\n} {}\ndo_test randexpr-2.906 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select  -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end | t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<=19))}\n} {17}\ndo_test randexpr-2.907 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (select  -min(t1.e) from t1) in (select f from t1 union select d from t1) then +e else d end & t1.e not between t1.a and t1.b))) and not exists(select 1 from t1 where a>=t1.e) and b=e then 13 else coalesce((select 19 from t1 where t1.d>=t1.e),13) end<11*t1.b then 17 when 17 in (19,t1.e, -t1.c) or 17<f then t1.d else t1.b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<=19))}\n} {17}\ndo_test randexpr-2.908 {\n  db eval {SELECT 11*t1.c* -case when t1.d<=t1.c then case when case case +t1.b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.e not in (t1.a,a,11)))) then (abs((select case count(distinct d) when cast(avg(19) AS integer) then  -min(t1.a) else (cast(avg(f) AS integer)) end from t1))/abs(b)) when t1.c<>t1.a then c else 19 end when t1.c then e else t1.d end when 17 then t1.d else  -d end between e and t1.e then 13 when (13<>13) then t1.c else 17 end when exists(select 1 from t1 where (t1.c between b and 11)) then e else f end FROM t1 WHERE ~a* -b+11-case when coalesce((select max(case when (t1.c in (case t1.b when t1.c then 13 else 17 end,17,19)) then case e when a then c else 13 end else c end) from t1 where a between b and t1.c),t1.a)=c or (17>d) then case when f= -t1.a then t1.b when (t1.d)<t1.e then (f) else t1.e end else c end+d<a}\n} {}\ndo_test randexpr-2.909 {\n  db eval {SELECT 11*t1.c* -case when t1.d<=t1.c then case when case case +t1.b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.e not in (t1.a,a,11)))) then (abs((select case count(distinct d) when cast(avg(19) AS integer) then  -min(t1.a) else (cast(avg(f) AS integer)) end from t1))/abs(b)) when t1.c<>t1.a then c else 19 end when t1.c then e else t1.d end when 17 then t1.d else  -d end between e and t1.e then 13 when (13<>13) then t1.c else 17 end when exists(select 1 from t1 where (t1.c between b and 11)) then e else f end FROM t1 WHERE NOT (~a* -b+11-case when coalesce((select max(case when (t1.c in (case t1.b when t1.c then 13 else 17 end,17,19)) then case e when a then c else 13 end else c end) from t1 where a between b and t1.c),t1.a)=c or (17>d) then case when f= -t1.a then t1.b when (t1.d)<t1.e then (f) else t1.e end else c end+d<a)}\n} {-1980000}\ndo_test randexpr-2.910 {\n  db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 | d | d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or  -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and  -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then  -t1.a else 13 end)-t1.c)}\n} {947}\ndo_test randexpr-2.911 {\n  db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 | d | d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE NOT (exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or  -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and  -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then  -t1.a else 13 end)-t1.c))}\n} {}\ndo_test randexpr-2.912 {\n  db eval {SELECT +case when e in (13, -b,11) then d else coalesce((select max(13 & d & d+19+(abs(case when (19) between (abs(case f when t1.f then (13) else 17 end)/abs(a)) and d then 19 when (not exists(select 1 from t1 where t1.a>=t1.f)) and t1.f>t1.a or e<>c then 17 else d end)/abs(a))) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (t1.f) in (t1.c,(t1.e),17)))),t1.a) end+e FROM t1 WHERE exists(select 1 from t1 where 17>(case coalesce((select max((abs(+t1.f-case when 11=(abs((select count(*) from t1)-13*13)/abs(t1.d)) then coalesce((select max(t1.c) from t1 where 19 in (select ((max(19))) from t1 union select min(t1.d) from t1) or  -t1.a=t1.a and f<17),t1.e-d) when not exists(select 1 from t1 where t1.b not between (d) and  -t1.f) then 11 else t1.a end)/abs(t1.a))) from t1 where t1.e not in ((f),11,t1.f)),t1.c) when b then  -t1.a else 13 end)-t1.c)}\n} {500}\ndo_test randexpr-2.913 {\n  db eval {SELECT (13*case when exists(select 1 from t1 where exists(select 1 from t1 where coalesce((select max(b) from t1 where t1.b=e),a)<(b-a)+13)) then 11 else t1.e end*coalesce((select 17 from t1 where not ((select cast(avg(13) AS integer) from t1)< -t1.c) and 17 between 13 and 13),case when f<c then b when t1.c<t1.a then  -d else e end)*d+b)+ - -t1.b+11 FROM t1 WHERE not exists(select 1 from t1 where b>=case when exists(select 1 from t1 where (13 in ( -(b)*(select count(*)* -cast(avg(case t1.e when t1.b then (f)-f-f else e end) AS integer)*cast(avg(17) AS integer) | cast(avg((17)) AS integer) | min(d) | count(distinct e) from t1),19+(abs(19)/abs(17))*f,t1.b))) then 11 when 17>t1.f then +a else t1.d end)}\n} {28600411}\ndo_test randexpr-2.914 {\n  db eval {SELECT (13*case when exists(select 1 from t1 where exists(select 1 from t1 where coalesce((select max(b) from t1 where t1.b=e),a)<(b-a)+13)) then 11 else t1.e end*coalesce((select 17 from t1 where not ((select cast(avg(13) AS integer) from t1)< -t1.c) and 17 between 13 and 13),case when f<c then b when t1.c<t1.a then  -d else e end)*d+b)+ - -t1.b+11 FROM t1 WHERE NOT (not exists(select 1 from t1 where b>=case when exists(select 1 from t1 where (13 in ( -(b)*(select count(*)* -cast(avg(case t1.e when t1.b then (f)-f-f else e end) AS integer)*cast(avg(17) AS integer) | cast(avg((17)) AS integer) | min(d) | count(distinct e) from t1),19+(abs(19)/abs(17))*f,t1.b))) then 11 when 17>t1.f then +a else t1.d end))}\n} {}\ndo_test randexpr-2.915 {\n  db eval {SELECT case when +11 | (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between  -t1.a and (t1.c))),e)) then t1.e when  -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE e<=19}\n} {}\ndo_test randexpr-2.916 {\n  db eval {SELECT case when +11 | (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between  -t1.a and (t1.c))),e)) then t1.e when  -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE NOT (e<=19)}\n} {20000}\ndo_test randexpr-2.917 {\n  db eval {SELECT case when +11 & (select min(case 13+a when e then d else 17-t1.b-~b*a end) from t1)-f*t1.f=(coalesce((select e from t1 where a<=f and not exists(select 1 from t1 where d-case 19 when 11 then (b) else t1.e end not between  -t1.a and (t1.c))),e)) then t1.e when  -17>=d then t1.f else t1.b end*t1.a FROM t1 WHERE NOT (e<=19)}\n} {20000}\ndo_test randexpr-2.918 {\n  db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 | case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select  -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not  -t1.a<t1.f or t1.f>=11}\n} {-289}\ndo_test randexpr-2.919 {\n  db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 | case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select  -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE NOT (t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not  -t1.a<t1.f or t1.f>=11)}\n} {}\ndo_test randexpr-2.920 {\n  db eval {SELECT 11-coalesce((select max(coalesce((select max((select abs(case +max((e)) when abs(abs( -count(distinct e))) then +cast(avg(f) AS integer) else count(*) end+count(*)+min( -e)) from t1)) from t1 where t1.b in (select count(distinct (17 & case case when e in (13,t1.a,e) or t1.d>=t1.e then 17 else a end when t1.e then 17 else t1.d end*t1.c)) from t1 union select cast(avg(t1.a) AS integer) from t1)),17)) from t1 where t1.c in (select ~cast(avg(t1.b) AS integer) from t1 union select  -(cast(avg(t1.c) AS integer)) from t1)),(t1.c)) FROM t1 WHERE t1.b not in (case when 11 in (select case +min(t1.f) when (+cast(avg((case t1.c when a then f else a end-f)) AS integer)) then +count(distinct (t1.f))-count(distinct t1.f) else count(*) end-count(*) | count(*) from t1 union select min(e) from t1) then (abs(b | 13-f | c)/abs(t1.f)) else t1.c end,f,t1.b) or not  -t1.a<t1.f or t1.f>=11}\n} {-289}\ndo_test randexpr-2.921 {\n  db eval {SELECT (select  -abs(max(+(select +count(*) from t1)))-max(case when b in (select (abs(13)/abs(b)) from t1 union select case when exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(coalesce((select max(+19*t1.e+case t1.f when (abs(f)/abs(t1.f)) then t1.f else e end) from t1 where 19<17),t1.a)))+11 in (select b from t1 union select t1.e from t1))) then d else t1.c end from t1) then f when 13=d then  -a else t1.a end) from t1) FROM t1 WHERE ~(select ~ -(min(f)- -cast(avg(f) AS integer)-abs(count(distinct case when t1.d=b then d when e in (select +cast(avg(e) AS integer) from t1 union select count(*) from t1) then t1.f else c end*17*f))) | (count(*)) from t1)-f<>case when (select + -max(t1.e) from t1)+(select  -min(17) from t1)*13 between 17 and 19 then t1.b else t1.d end}\n} {-101}\ndo_test randexpr-2.922 {\n  db eval {SELECT (select  -abs(max(+(select +count(*) from t1)))-max(case when b in (select (abs(13)/abs(b)) from t1 union select case when exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(coalesce((select max(+19*t1.e+case t1.f when (abs(f)/abs(t1.f)) then t1.f else e end) from t1 where 19<17),t1.a)))+11 in (select b from t1 union select t1.e from t1))) then d else t1.c end from t1) then f when 13=d then  -a else t1.a end) from t1) FROM t1 WHERE NOT (~(select ~ -(min(f)- -cast(avg(f) AS integer)-abs(count(distinct case when t1.d=b then d when e in (select +cast(avg(e) AS integer) from t1 union select count(*) from t1) then t1.f else c end*17*f))) | (count(*)) from t1)-f<>case when (select + -max(t1.e) from t1)+(select  -min(17) from t1)*13 between 17 and 19 then t1.b else t1.d end)}\n} {}\ndo_test randexpr-2.923 {\n  db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when  -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c | 17 when t1.f between t1.a and  -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19)}\n} {0}\ndo_test randexpr-2.924 {\n  db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when  -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c | 17 when t1.f between t1.a and  -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE NOT (not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19))}\n} {}\ndo_test randexpr-2.925 {\n  db eval {SELECT case (select ( - - -(+max(c))+min(e)-(count(*))+cast(avg(t1.e) AS integer)-min(t1.a)*(cast(avg(11) AS integer))) from t1) when t1.d then t1.c else case (select max(a) from t1) when  -t1.b then case when not 17<>case when t1.e<=t1.d or ((t1.e))=t1.e then t1.f when e>=t1.b then 11 else t1.d end or d in (t1.f,t1.a,t1.a) then c & 17 when t1.f between t1.a and  -t1.e then d else t1.c end else t1.c end end-t1.c FROM t1 WHERE not (exists(select 1 from t1 where a<>11+t1.d-t1.a+(select count(distinct t1.d)++max(case e when coalesce((select 11 from t1 where a>=case when coalesce((select f from t1 where exists(select 1 from t1 where 13 in (t1.c,13,t1.a))),(d))+f not between d and t1.e then d else (t1.c) end-13),(d))-t1.d then t1.a else 17 end) from t1)) and not a<(d)*19)}\n} {0}\ndo_test randexpr-2.926 {\n  db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end | (count(distinct t1.c)) | ((max(t1.a))) | count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE exists(select 1 from t1 where t1.d>=f)}\n} {}\ndo_test randexpr-2.927 {\n  db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end | (count(distinct t1.c)) | ((max(t1.a))) | count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d>=f))}\n} {500}\ndo_test randexpr-2.928 {\n  db eval {SELECT case t1.b when c*(case when ((select ++case abs(cast(avg(a) AS integer))*min(c) when min(t1.c) then cast(avg(t1.b) AS integer) else count(*) end & (count(distinct t1.c)) & ((max(t1.a))) & count(distinct b) from t1) not between t1.e and 11 and coalesce((select max(e) from t1 where a between t1.c and c+b),e) in (select t1.d from t1 union select t1.b from t1) or (not exists(select 1 from t1 where 13<>t1.a))) then 11*b else t1.b end) then t1.c else e end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d>=f))}\n} {500}\ndo_test randexpr-2.929 {\n  db eval {SELECT d-coalesce((select d from t1 where case when ~11*a*c>=17 then coalesce((select (abs(t1.e+c+(abs(f*(select abs((min(e))) from t1)-t1.f)/abs( - -a))-a)/abs(t1.d)) from t1 where f not in (e,b,t1.f) and c<>f),f)*19 else f end in (b,e,17)),13)-19 FROM t1 WHERE not f>=11}\n} {}\ndo_test randexpr-2.930 {\n  db eval {SELECT d-coalesce((select d from t1 where case when ~11*a*c>=17 then coalesce((select (abs(t1.e+c+(abs(f*(select abs((min(e))) from t1)-t1.f)/abs( - -a))-a)/abs(t1.d)) from t1 where f not in (e,b,t1.f) and c<>f),f)*19 else f end in (b,e,17)),13)-19 FROM t1 WHERE NOT (not f>=11)}\n} {368}\ndo_test randexpr-2.931 {\n  db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f | b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or  - -a>=t1.b),a) FROM t1 WHERE f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e)}\n} {240100}\ndo_test randexpr-2.932 {\n  db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f | b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or  - -a>=t1.b),a) FROM t1 WHERE NOT (f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e))}\n} {}\ndo_test randexpr-2.933 {\n  db eval {SELECT f*t1.d+coalesce((select a+17-t1.e from t1 where 13=t1.f and not (t1.f & b*t1.d-t1.c*coalesce((select max(coalesce((select t1.f from t1 where f not in (13,a,d)),d)) from t1 where t1.a in (select cast(avg(c) AS integer) from t1 union select count(distinct b)*count(distinct t1.c) from t1)),((17)))+ -b+19+13)=t1.f and 19>=t1.a or  - -a>=t1.b),a) FROM t1 WHERE f not in (coalesce((select max(19) from t1 where (t1.e<=+t1.f*case when ~(abs(b)/abs(b)) in (f,t1.d,17) then (abs(t1.e-11 | d)/abs(coalesce((select d from t1 where not coalesce((select t1.a from t1 where not exists(select 1 from t1 where c>=t1.c)),d) in (select count(distinct f)*cast(avg(19) AS integer) from t1 union select count(distinct d) from t1)),13))) when not 11<=t1.a then t1.f else 19 end-19)),f)-17, -a,e)}\n} {240100}\ndo_test randexpr-2.934 {\n  db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) | c FROM t1 WHERE case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c)}\n} {-19}\ndo_test randexpr-2.935 {\n  db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) | c FROM t1 WHERE NOT (case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c))}\n} {}\ndo_test randexpr-2.936 {\n  db eval {SELECT coalesce((select case e*+(abs(t1.f-t1.b)/abs(e))-d when coalesce((select t1.e from t1 where exists(select 1 from t1 where +d+ -t1.e not between case when (abs(b)/abs(t1.b)) between a and 17 then t1.b when not 11 not between b and d then 19 else 19 end and t1.f and t1.a between 17 and b)), -13) then (t1.a) else 13 end from t1 where 17 between b and 13), -19) & c FROM t1 WHERE case when t1.e*t1.b | f+d | f+11+(a)-+a+ -t1.c-t1.f | coalesce((select case t1.e when 17 then e else t1.a end from t1 where t1.a<t1.b),t1.b)*f<= -t1.a and c<t1.f then (select (max((b))) from t1) else t1.b end not in (a,a,t1.c)}\n} {300}\ndo_test randexpr-2.937 {\n  db eval {SELECT coalesce((select max(t1.d*case when case when ~ -t1.d+17-b-13*t1.f*(abs(t1.b+13)/abs(t1.a))+a*t1.e*t1.a+c*t1.d-t1.a in (select t1.b from t1 union select t1.d from t1) then t1.e else t1.e end not in (t1.f,t1.e,19) then t1.d else 11 end) from t1 where d not between t1.a and a),c) FROM t1 WHERE t1.e in (select a from t1 union select +b-t1.b from t1)}\n} {}\ndo_test randexpr-2.938 {\n  db eval {SELECT coalesce((select max(t1.d*case when case when ~ -t1.d+17-b-13*t1.f*(abs(t1.b+13)/abs(t1.a))+a*t1.e*t1.a+c*t1.d-t1.a in (select t1.b from t1 union select t1.d from t1) then t1.e else t1.e end not in (t1.f,t1.e,19) then t1.d else 11 end) from t1 where d not between t1.a and a),c) FROM t1 WHERE NOT (t1.e in (select a from t1 union select +b-t1.b from t1))}\n} {4400}\ndo_test randexpr-2.939 {\n  db eval {SELECT d*(select  - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 | coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when  -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) | 13 FROM t1 WHERE not exists(select 1 from t1 where t1.c< -d or t1.e between c and  -t1.d or d<=17)}\n} {10143}\ndo_test randexpr-2.940 {\n  db eval {SELECT d*(select  - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 | coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when  -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) | 13 FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.c< -d or t1.e between c and  -t1.d or d<=17))}\n} {}\ndo_test randexpr-2.941 {\n  db eval {SELECT d*(select  - - -max( -(abs(e)/abs(~t1.c))) from t1)-13 & coalesce((select max(+t1.a*a) from t1 where t1.e+case e when a then t1.f+(select case ~ -max(d)* - -cast(avg(c) AS integer) when  -min( -t1.b) then min(t1.b) else count(distinct 13) end from t1)-a else ~case when t1.f not in (b,b,a) or c between d and t1.a then c when t1.b>b then e else t1.d end end-11>=13),e) & 13 FROM t1 WHERE not exists(select 1 from t1 where t1.c< -d or t1.e between c and  -t1.d or d<=17)}\n} {0}\ndo_test randexpr-2.942 {\n  db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select  -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) | f | e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE (f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17)}\n} {120000}\ndo_test randexpr-2.943 {\n  db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select  -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) | f | e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE NOT ((f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17))}\n} {}\ndo_test randexpr-2.944 {\n  db eval {SELECT t1.c*+case when a<>+case when b>t1.e or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e in (select coalesce((select b from t1 where (d<f) or t1.e in ((t1.f),(t1.a),13) and (t1.e)<>( -t1.d)),(( -b))) from t1 union select t1.d from t1))) then (select  -max(t1.e)-count(*) from t1) else (t1.c) end+b+(t1.f) & f & e then t1.d when t1.f not in (19,13,e) then 13 else 11 end FROM t1 WHERE (f<>coalesce((select max(a) from t1 where (exists(select 1 from t1 where c between t1.b and case when (abs(19)/abs(t1.f)) in (t1.f,17,t1.a) then t1.b when t1.d<=t1.a then t1.a else c end or c<c) or 13>=b and c>=t1.d and t1.d between c and t1.c)),e+case (select count(distinct case 19 when 13 then t1.b else 11 end) from t1) when 13 then b else t1.b end)-17-17)}\n} {120000}\ndo_test randexpr-2.945 {\n  db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else  -11 end+a) when count(distinct  -f) then count(*) else  -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when  -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b | t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE (select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1)}\n} {}\ndo_test randexpr-2.946 {\n  db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else  -11 end+a) when count(distinct  -f) then count(*) else  -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when  -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b | t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE NOT ((select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1))}\n} {400}\ndo_test randexpr-2.947 {\n  db eval {SELECT case when (e)- -((select case min(case when e in (select coalesce((select max(d) from t1 where 13<>(t1.d-e)),e) from t1 union select c from t1) then d else  -11 end+a) when count(distinct  -f) then count(*) else  -(case cast(avg(17) AS integer)- -count(distinct t1.c)+cast(avg(b) AS integer) when  -max(11) then count(*) else cast(avg(t1.e) AS integer) end+max(t1.f)) end from t1))<=t1.b & t1.e then t1.d when not exists(select 1 from t1 where c<>13) then 11 else d end FROM t1 WHERE NOT ((select max(t1.a*case f when b then ~case when not exists(select 1 from t1 where f-d>(select abs(cast(avg(~17+b+d) AS integer)) from t1) or f-e in (select b from t1 union select t1.d from t1) or exists(select 1 from t1 where 13<>b)) then (abs(a)/abs( -d)) when (d<t1.a) then e else t1.e end else t1.a end) from t1)*t1.e in (select t1.f from t1 union select t1.b from t1))}\n} {400}\ndo_test randexpr-2.948 {\n  db eval {SELECT (t1.b+coalesce((select case when e-13+11 | f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then  -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else  -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct  -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e)}\n} {}\ndo_test randexpr-2.949 {\n  db eval {SELECT (t1.b+coalesce((select case when e-13+11 | f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then  -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE NOT (t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else  -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct  -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e))}\n} {3413413}\ndo_test randexpr-2.950 {\n  db eval {SELECT (t1.b+coalesce((select case when e-13+11 & f+case when not t1.b not between t1.f and t1.f then e else (t1.e) end-c-b+c>=e and d between d and a then t1.c when (t1.c>19) then  -11 else a end from t1 where a<d),e)+f+t1.e*d)*17 FROM t1 WHERE NOT (t1.b in (select cast(avg(17) AS integer) from t1 union select ~case (+abs(cast(avg((d)) AS integer))) when count(distinct case when (case when c>c then t1.e else  -d end-t1.e) between b and 11 then b when exists(select 1 from t1 where a<=d) then 11 else 13 end) then cast(avg(t1.b) AS integer)-(cast(avg(11) AS integer)-min(a))-count(distinct  -e) else cast(avg(13) AS integer) end*max(b) from t1) or (t1.f not between t1.d and 17 | 19*e))}\n} {3413413}\ndo_test randexpr-2.951 {\n  db eval {SELECT coalesce((select max(+19) from t1 where t1.f>=(abs(19)/abs(t1.c*(select count(distinct (abs(t1.f)/abs(t1.c))*coalesce((select max(case when (select count(*) from t1)*t1.f in (t1.b,17,t1.f) then d when t1.e not in (t1.b,t1.a,t1.b) then  -17 else t1.d end) from t1 where (11 not in (t1.b,(f),t1.c)) and t1.c>=t1.f),e)) from t1))) or ((t1.d<=t1.b))),13) FROM t1 WHERE t1.a<>(coalesce((select coalesce((select max(t1.a) from t1 where case  -t1.c when t1.b then coalesce((select t1.b from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where ((select count(*)++count(distinct a) from t1) not between b and +(17))))),19)*t1.e else f end<=(t1.b)),t1.c) from t1 where d<>b),13)-17+a)+d+(19)+a or d between 11 and  -11}\n} {19}\ndo_test randexpr-2.952 {\n  db eval {SELECT coalesce((select max(+19) from t1 where t1.f>=(abs(19)/abs(t1.c*(select count(distinct (abs(t1.f)/abs(t1.c))*coalesce((select max(case when (select count(*) from t1)*t1.f in (t1.b,17,t1.f) then d when t1.e not in (t1.b,t1.a,t1.b) then  -17 else t1.d end) from t1 where (11 not in (t1.b,(f),t1.c)) and t1.c>=t1.f),e)) from t1))) or ((t1.d<=t1.b))),13) FROM t1 WHERE NOT (t1.a<>(coalesce((select coalesce((select max(t1.a) from t1 where case  -t1.c when t1.b then coalesce((select t1.b from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where ((select count(*)++count(distinct a) from t1) not between b and +(17))))),19)*t1.e else f end<=(t1.b)),t1.c) from t1 where d<>b),13)-17+a)+d+(19)+a or d between 11 and  -11)}\n} {}\ndo_test randexpr-2.953 {\n  db eval {SELECT t1.b-coalesce((select max(~t1.a) from t1 where coalesce((select max(t1.d) from t1 where coalesce((select max(coalesce((select t1.c*t1.d from t1 where not f>=a-t1.c+ -coalesce((select t1.f*e from t1 where (not exists(select 1 from t1 where d<=19))),b)-d),13)* -e) from t1 where (d<19 or 13 not between t1.f and t1.d)),11) between 17 and 19),t1.c)< -b),d) FROM t1 WHERE +case when b in (b+~b+t1.f,coalesce((select max(13) from t1 where exists(select 1 from t1 where 17<>+a or not exists(select 1 from t1 where e+19=f))),(e)),case when c>case when coalesce((select 13 from t1 where f>=t1.b and c not between t1.e and t1.d),11) in (select (case max(11) when (min(b)) then min( -d) else cast(avg(t1.e) AS integer) end) from t1 union select max(19) from t1) then t1.d else 13 end then t1.f else t1.e end) or b>=(t1.f) then t1.e else t1.e end*b>f}\n} {-200}\ndo_test randexpr-2.954 {\n  db eval {SELECT t1.b-coalesce((select max(~t1.a) from t1 where coalesce((select max(t1.d) from t1 where coalesce((select max(coalesce((select t1.c*t1.d from t1 where not f>=a-t1.c+ -coalesce((select t1.f*e from t1 where (not exists(select 1 from t1 where d<=19))),b)-d),13)* -e) from t1 where (d<19 or 13 not between t1.f and t1.d)),11) between 17 and 19),t1.c)< -b),d) FROM t1 WHERE NOT (+case when b in (b+~b+t1.f,coalesce((select max(13) from t1 where exists(select 1 from t1 where 17<>+a or not exists(select 1 from t1 where e+19=f))),(e)),case when c>case when coalesce((select 13 from t1 where f>=t1.b and c not between t1.e and t1.d),11) in (select (case max(11) when (min(b)) then min( -d) else cast(avg(t1.e) AS integer) end) from t1 union select max(19) from t1) then t1.d else 13 end then t1.f else t1.e end) or b>=(t1.f) then t1.e else t1.e end*b>f)}\n} {}\ndo_test randexpr-2.955 {\n  db eval {SELECT (select count(distinct + - -f-c-17*a+(t1.d)-+((select abs( - - -count(distinct 13)-count(*)*count(distinct t1.d)*count(*))-cast(avg(f) AS integer) from t1))-~19+13- -d*t1.e*(19)+ -f- -b) from t1)-e FROM t1 WHERE not t1.c between t1.f and coalesce((select coalesce((select case when exists(select 1 from t1 where +~f=case when d<>t1.d then t1.f else  -d end and d between 17 and t1.c) then ~case when a in (d,c,t1.d) then 17 else t1.f end when f=f then d else  -b end from t1 where c>f),e) from t1 where not exists(select 1 from t1 where t1.d<=c) and 19=(11) and t1.e<>19),a)}\n} {-499}\ndo_test randexpr-2.956 {\n  db eval {SELECT (select count(distinct + - -f-c-17*a+(t1.d)-+((select abs( - - -count(distinct 13)-count(*)*count(distinct t1.d)*count(*))-cast(avg(f) AS integer) from t1))-~19+13- -d*t1.e*(19)+ -f- -b) from t1)-e FROM t1 WHERE NOT (not t1.c between t1.f and coalesce((select coalesce((select case when exists(select 1 from t1 where +~f=case when d<>t1.d then t1.f else  -d end and d between 17 and t1.c) then ~case when a in (d,c,t1.d) then 17 else t1.f end when f=f then d else  -b end from t1 where c>f),e) from t1 where not exists(select 1 from t1 where t1.d<=c) and 19=(11) and t1.e<>19),a))}\n} {}\ndo_test randexpr-2.957 {\n  db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c | f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and  -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where  -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e}\n} {}\ndo_test randexpr-2.958 {\n  db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c | f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and  -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE NOT (e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where  -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e)}\n} {300}\ndo_test randexpr-2.959 {\n  db eval {SELECT case when f-t1.b*coalesce((select max(11) from t1 where exists(select 1 from t1 where (abs(t1.b)/abs(13-11))=(19+c))),coalesce((select t1.c & f from t1 where (abs(c*19)/abs(17))=t1.e),19))-e between t1.f and  -((19)) and 13 not between t1.c and 11 and not exists(select 1 from t1 where t1.b>b) then t1.d when t1.c>=13 then c else f end FROM t1 WHERE NOT (e-t1.c=+e*~coalesce((select max(t1.f) from t1 where (t1.f in (coalesce((select max(11) from t1 where  -13<>(13)-(select (count(*)) from t1)*t1.f and ( -11+t1.b+b*b-(select max(13) from t1)) in (t1.f,a,f)),d),17,13))),t1.f)-e)}\n} {300}\ndo_test randexpr-2.960 {\n  db eval {SELECT t1.e+case when coalesce((select  -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d | d between  -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE 19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when  -b<11 then t1.c else  -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b}\n} {}\ndo_test randexpr-2.961 {\n  db eval {SELECT t1.e+case when coalesce((select  -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d | d between  -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE NOT (19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when  -b<11 then t1.c else  -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b)}\n} {1100}\ndo_test randexpr-2.962 {\n  db eval {SELECT t1.e+case when coalesce((select  -(abs(t1.e)/abs(t1.c-t1.e)) from t1 where d & d between  -t1.d and ~case t1.d when t1.f then ((abs((select ((min(b)+abs(cast(avg(t1.a) AS integer)*(max(19))))-(cast(avg(t1.d) AS integer))) from t1)*~f)/abs(t1.a*t1.c)))*17 else 19 end),f)- -c<>t1.c then f else t1.f end FROM t1 WHERE NOT (19*coalesce((select max(a) from t1 where not (select count(distinct ~t1.b | t1.d) from t1)<case when b+(case when t1.c not in (f,(b),t1.c) then t1.d else 19 end)>t1.e then c when  -b<11 then t1.c else  -t1.e end and not d in ( -t1.d,t1.a,f) and c=t1.f and f<>t1.a),t1.b) between t1.a and b)}\n} {1100}\ndo_test randexpr-2.963 {\n  db eval {SELECT t1.b*coalesce((select max(e) from t1 where ((t1.d))<=case case when +coalesce((select (abs(t1.a)/abs(c))-(abs( -e)/abs(11* -t1.b+t1.d* -c))-t1.c from t1 where not exists(select 1 from t1 where t1.c=(11))), -11) between 17 and t1.a then t1.a when t1.b>t1.e then (b) else b end-c when d then d else t1.f end),((t1.e))) FROM t1 WHERE ~ -case when not exists(select 1 from t1 where t1.b between b and 11 | d) then  -(abs(17+d)/abs(e)) else case when not (t1.d>=case when case a when case t1.f when (e) then 17 else 19 end then 13 else 19 end in (t1.e,b,((t1.b))) then d when t1.d not in (19,t1.a, -c) then 11 else  -a end) then 11 else c end end*17*t1.b not in (a,b,13)}\n} {100000}\ndo_test randexpr-2.964 {\n  db eval {SELECT t1.b*coalesce((select max(e) from t1 where ((t1.d))<=case case when +coalesce((select (abs(t1.a)/abs(c))-(abs( -e)/abs(11* -t1.b+t1.d* -c))-t1.c from t1 where not exists(select 1 from t1 where t1.c=(11))), -11) between 17 and t1.a then t1.a when t1.b>t1.e then (b) else b end-c when d then d else t1.f end),((t1.e))) FROM t1 WHERE NOT (~ -case when not exists(select 1 from t1 where t1.b between b and 11 | d) then  -(abs(17+d)/abs(e)) else case when not (t1.d>=case when case a when case t1.f when (e) then 17 else 19 end then 13 else 19 end in (t1.e,b,((t1.b))) then d when t1.d not in (19,t1.a, -c) then 11 else  -a end) then 11 else c end end*17*t1.b not in (a,b,13))}\n} {}\ndo_test randexpr-2.965 {\n  db eval {SELECT e*case +case when not (select max(17) from t1)>=case when not d=c+t1.c then 11 else 11 end or (c in (select t1.c from t1 union select c from t1) or 11<=t1.a) or d<=11 or 19 in ( -13,d,19) or a not between 13 and (t1.c) then case when t1.f<=(t1.a) then t1.e+13*e when (t1.b) not between f and a then c else 11 end*11 else a end when 19 then t1.a else 17 end FROM t1 WHERE b<>17}\n} {8500}\ndo_test randexpr-2.966 {\n  db eval {SELECT e*case +case when not (select max(17) from t1)>=case when not d=c+t1.c then 11 else 11 end or (c in (select t1.c from t1 union select c from t1) or 11<=t1.a) or d<=11 or 19 in ( -13,d,19) or a not between 13 and (t1.c) then case when t1.f<=(t1.a) then t1.e+13*e when (t1.b) not between f and a then c else 11 end*11 else a end when 19 then t1.a else 17 end FROM t1 WHERE NOT (b<>17)}\n} {}\ndo_test randexpr-2.967 {\n  db eval {SELECT (abs(case when (13+e in (select min(a) | case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE t1.e<f+11-b}\n} {}\ndo_test randexpr-2.968 {\n  db eval {SELECT (abs(case when (13+e in (select min(a) | case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE NOT (t1.e<f+11-b)}\n} {11}\ndo_test randexpr-2.969 {\n  db eval {SELECT (abs(case when (13+e in (select min(a) & case abs(min(case when t1.e in (select b from t1 union select a from t1) then t1.e when t1.b=t1.c then t1.b else c end-f)) when ~(cast(avg(c) AS integer)) then min(t1.e) else count(*) end from t1 union select min(f) from t1)) and t1.d not between c and 13 then coalesce((select t1.d from t1 where t1.e<>a),19)-t1.d else 19 end)/abs(c))-c+11+c FROM t1 WHERE NOT (t1.e<f+11-b)}\n} {11}\ndo_test randexpr-2.970 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where (11 not between ~~t1.d-case c when coalesce((select case f when coalesce((select max(t1.f) from t1 where 11 not in (((13)),d,t1.d)),11) then f else a end from t1 where 11 not between (t1.a) and 17),t1.c)-c*17 then (17) else t1.b end+t1.d+t1.a and d)) then t1.e-11+19 else (d) end*d<=11 then t1.b else f end FROM t1 WHERE not exists(select 1 from t1 where d>=t1.f)}\n} {600}\ndo_test randexpr-2.971 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where (11 not between ~~t1.d-case c when coalesce((select case f when coalesce((select max(t1.f) from t1 where 11 not in (((13)),d,t1.d)),11) then f else a end from t1 where 11 not between (t1.a) and 17),t1.c)-c*17 then (17) else t1.b end+t1.d+t1.a and d)) then t1.e-11+19 else (d) end*d<=11 then t1.b else f end FROM t1 WHERE NOT (not exists(select 1 from t1 where d>=t1.f))}\n} {}\ndo_test randexpr-2.972 {\n  db eval {SELECT 13 | t1.c+case when (not t1.d-c between +t1.b and  -coalesce((select (select count(distinct 17) from t1)*a from t1 where  -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then  -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) | t1.f) then c else 11 end FROM t1 WHERE case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17}\n} {}\ndo_test randexpr-2.973 {\n  db eval {SELECT 13 | t1.c+case when (not t1.d-c between +t1.b and  -coalesce((select (select count(distinct 17) from t1)*a from t1 where  -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then  -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) | t1.f) then c else 11 end FROM t1 WHERE NOT (case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17)}\n} {605}\ndo_test randexpr-2.974 {\n  db eval {SELECT 13 & t1.c+case when (not t1.d-c between +t1.b and  -coalesce((select (select count(distinct 17) from t1)*a from t1 where  -case when not t1.f in (select count(distinct 13) from t1 union select min( -t1.a) from t1) then case when (t1.e)< -11 then  -c else t1.a end else d end-c*t1.a-d+ -e-t1.a not in (17,e,t1.a)),b) & t1.f) then c else 11 end FROM t1 WHERE NOT (case when (+e | (t1.e) | 11)<>b then t1.b when t1.e<>~(case when (t1.a*b) in (select d from t1 union select b from t1) or t1.c not in (t1.a,t1.d,13) and t1.f in (select case min(19) when min(17) then min(19) else count(distinct t1.e) end from t1 union select (count(*)) from t1) then t1.f else b end)+11 then b else 13 end+t1.d between b and 17)}\n} {8}\ndo_test randexpr-2.975 {\n  db eval {SELECT case when case when t1.a<>t1.d then d*t1.a*11-e-(+11+d)-e else (select case  -count(distinct t1.e) when cast(avg(b) AS integer) then count(distinct t1.d) else cast(avg(13) AS integer) end*cast(avg(19) AS integer) from t1) end<>case e when e then t1.e else (t1.f) end or not exists(select 1 from t1 where 19=f) and  -t1.d>t1.e then t1.e+e*e when 11=t1.c then e else c end FROM t1 WHERE ~c>(case when t1.e<=e then case when case when 17+f in (d,t1.d | t1.c,t1.b) and 13<>19 or not t1.c<f then coalesce((select max(b) from t1 where c not between b and t1.c),c)+(17) when d<=t1.c then t1.b else t1.c end-b not in (a,f,11) then c else 17 end else f end)}\n} {}\ndo_test randexpr-2.976 {\n  db eval {SELECT case when case when t1.a<>t1.d then d*t1.a*11-e-(+11+d)-e else (select case  -count(distinct t1.e) when cast(avg(b) AS integer) then count(distinct t1.d) else cast(avg(13) AS integer) end*cast(avg(19) AS integer) from t1) end<>case e when e then t1.e else (t1.f) end or not exists(select 1 from t1 where 19=f) and  -t1.d>t1.e then t1.e+e*e when 11=t1.c then e else c end FROM t1 WHERE NOT (~c>(case when t1.e<=e then case when case when 17+f in (d,t1.d | t1.c,t1.b) and 13<>19 or not t1.c<f then coalesce((select max(b) from t1 where c not between b and t1.c),c)+(17) when d<=t1.c then t1.b else t1.c end-b not in (a,f,11) then c else 17 end else f end))}\n} {250500}\ndo_test randexpr-2.977 {\n  db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e | t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then  -max(d) else min(t1.d) end | ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE coalesce((select  -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b)}\n} {}\ndo_test randexpr-2.978 {\n  db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e | t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then  -max(d) else min(t1.d) end | ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE NOT (coalesce((select  -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b))}\n} {300}\ndo_test randexpr-2.979 {\n  db eval {SELECT case when (13 in (select ~t1.c from t1 union select case when t1.a in (select t1.f-t1.e & t1.c+19 from t1 union select coalesce((select max(13) from t1 where e in (select ~19-(select case count(*)-cast(avg(c) AS integer) when cast(avg(t1.f) AS integer) then  -max(d) else min(t1.d) end & ( -cast(avg(t1.a) AS integer)) from t1)-b*d-coalesce((select max(f) from t1 where not t1.c=c),b) from t1 union select 13 from t1)),a) from t1) then t1.c else t1.b end from t1)) then (abs(c)/abs(19)) else c end FROM t1 WHERE NOT (coalesce((select  -case (select count(*) from t1) when d*+b then a else d end from t1 where b not in (11*case t1.e when case +coalesce((select b+19*+case t1.c when t1.a then t1.b else t1.f end*f*11 from t1 where t1.a=t1.f),c) when t1.e then 17 else d end then t1.f else t1.b end,f,d)),t1.d) in (13,e, -b))}\n} {300}\ndo_test randexpr-2.980 {\n  db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f | +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else  -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) | c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE (select (count(*)) from t1) between 11 and t1.d}\n} {}\ndo_test randexpr-2.981 {\n  db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f | +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else  -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) | c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE NOT ((select (count(*)) from t1) between 11 and t1.d)}\n} {-101}\ndo_test randexpr-2.982 {\n  db eval {SELECT ~case when exists(select 1 from t1 where ((coalesce((select d from t1 where t1.e-f & +t1.d between t1.c and t1.a or exists(select 1 from t1 where 19 in (11,11,13)) and 17 in (select case min(d) when count(*) then (min(13)) else  -(cast(avg( -c) AS integer)) end*count(distinct 19) from t1 union select count(distinct e) from t1)),f) & c*b<= -b or not not t1.c<13 or (t1.f)>=t1.f))) and t1.c not in (17,b,e) then a else (select count(distinct t1.d) from t1) end FROM t1 WHERE NOT ((select (count(*)) from t1) between 11 and t1.d)}\n} {-101}\ndo_test randexpr-2.983 {\n  db eval {SELECT coalesce((select max(b) from t1 where not not c*t1.e>=19 or case when 17<=t1.b and case when 13 not between d and  -f then case e when 11 then case when e in (select ( -d) from t1 union select e from t1) and 19<=(a) then t1.a else (19) end else f end else t1.a end+t1.a<19 then ~d when e in (a,11, -b) then b else e end not between f and 13),a) FROM t1 WHERE t1.a>=+a}\n} {200}\ndo_test randexpr-2.984 {\n  db eval {SELECT coalesce((select max(b) from t1 where not not c*t1.e>=19 or case when 17<=t1.b and case when 13 not between d and  -f then case e when 11 then case when e in (select ( -d) from t1 union select e from t1) and 19<=(a) then t1.a else (19) end else f end else t1.a end+t1.a<19 then ~d when e in (a,11, -b) then b else e end not between f and 13),a) FROM t1 WHERE NOT (t1.a>=+a)}\n} {}\ndo_test randexpr-2.985 {\n  db eval {SELECT case when case when 11 between a+a+t1.b and b then c*e-t1.c*t1.a when +b<= -t1.c-t1.e-19*t1.b+c*t1.b then e else d end-(11)-e<d then 11 when 13=t1.e then a else 13 end+c-d FROM t1 WHERE ~coalesce((select max((select count(*) from t1)+t1.f) from t1 where 17 in (~t1.a,d,13)), -(select max(13) from t1) | coalesce((select c from t1 where t1.e* -coalesce((select 17 from t1 where (abs(t1.a+t1.d)/abs(t1.f))*t1.e | 17 | 11 not in ((t1.d),c,t1.c)),13)*13 in (11,t1.e,a)),19)) in (13,13,c)}\n} {}\ndo_test randexpr-2.986 {\n  db eval {SELECT case when case when 11 between a+a+t1.b and b then c*e-t1.c*t1.a when +b<= -t1.c-t1.e-19*t1.b+c*t1.b then e else d end-(11)-e<d then 11 when 13=t1.e then a else 13 end+c-d FROM t1 WHERE NOT (~coalesce((select max((select count(*) from t1)+t1.f) from t1 where 17 in (~t1.a,d,13)), -(select max(13) from t1) | coalesce((select c from t1 where t1.e* -coalesce((select 17 from t1 where (abs(t1.a+t1.d)/abs(t1.f))*t1.e | 17 | 11 not in ((t1.d),c,t1.c)),13)*13 in (11,t1.e,a)),19)) in (13,13,c))}\n} {-89}\ndo_test randexpr-2.987 {\n  db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) | a then t1.d else e end+ -t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select  -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select  -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and  - -11 then t1.a when 11 not between  -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where  -11<=t1.c),t1.c)+f not in (t1.f, -d,19))}\n} {}\ndo_test randexpr-2.988 {\n  db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) | a then t1.d else e end+ -t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select  -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select  -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and  - -11 then t1.a when 11 not between  -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where  -11<=t1.c),t1.c)+f not in (t1.f, -d,19)))}\n} {-700}\ndo_test randexpr-2.989 {\n  db eval {SELECT c-case 17 when c+b-t1.a-a*coalesce((select max(t1.c) from t1 where t1.b- -(abs(13)/abs(t1.e)) in (case t1.f when f then coalesce((select max(coalesce((select 13 from t1 where exists(select 1 from t1 where f not between e and c)),e)) from t1 where d not between t1.a and 13),d)-b else a end, -13,(t1.f)) and 13 between e and 17),a) & a then t1.d else e end+ -t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select  -+t1.c | case when a in (select case max(+b) when ~count(*) then count(*) else (abs((max(f)))) end from t1 union select  -max(e) from t1) then case when (t1.d>=11) or t1.c not between t1.d and  - -11 then t1.a when 11 not between  -t1.e and t1.a then 11 else t1.b end when (d not in (a,c,19)) then f else c end*17 from t1 where  -11<=t1.c),t1.c)+f not in (t1.f, -d,19)))}\n} {-700}\ndo_test randexpr-2.990 {\n  db eval {SELECT (select ( -count(distinct case case a when e then c*case when e<=t1.d+b then a when (abs(t1.f)/abs(case when b-coalesce((select max(t1.f-t1.b) from t1 where not exists(select 1 from t1 where 17 in (b,13,(b)) or b in (d,c,t1.e))),t1.b) not in (d,((c)),t1.b) then  -19 when c between a and 13 then 19 else t1.f end))=13 then f else 13 end else 17 end when 13 then t1.f else t1.b end-t1.c)) from t1) FROM t1 WHERE coalesce((select max(t1.d) from t1 where t1.c<>t1.c-13),t1.a)>=d or b*coalesce((select max((d)) from t1 where c not between +coalesce((select max(13) from t1 where e between  -(abs(( -coalesce((select max(case f when t1.f then e else  -t1.c end) from t1 where 11>e and t1.b<t1.e),t1.c)))/abs(b)) and d),a) and t1.e),t1.b)* -19 not between (17) and t1.f and (t1.e<=a)}\n} {-1}\ndo_test randexpr-2.991 {\n  db eval {SELECT (select ( -count(distinct case case a when e then c*case when e<=t1.d+b then a when (abs(t1.f)/abs(case when b-coalesce((select max(t1.f-t1.b) from t1 where not exists(select 1 from t1 where 17 in (b,13,(b)) or b in (d,c,t1.e))),t1.b) not in (d,((c)),t1.b) then  -19 when c between a and 13 then 19 else t1.f end))=13 then f else 13 end else 17 end when 13 then t1.f else t1.b end-t1.c)) from t1) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where t1.c<>t1.c-13),t1.a)>=d or b*coalesce((select max((d)) from t1 where c not between +coalesce((select max(13) from t1 where e between  -(abs(( -coalesce((select max(case f when t1.f then e else  -t1.c end) from t1 where 11>e and t1.b<t1.e),t1.c)))/abs(b)) and d),a) and t1.e),t1.b)* -19 not between (17) and t1.f and (t1.e<=a))}\n} {}\ndo_test randexpr-2.992 {\n  db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end | f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE (select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) |  -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when  -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when  -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c}\n} {100500}\ndo_test randexpr-2.993 {\n  db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end | f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE NOT ((select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) |  -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when  -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when  -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c)}\n} {}\ndo_test randexpr-2.994 {\n  db eval {SELECT case when (11=(t1.b)) then t1.c-coalesce((select case when t1.f*c-b<>b then t1.a else e end & f from t1 where 13 in (select abs(~max((17))) from t1 union select cast(avg(t1.b) AS integer)-min(19) from t1)), -t1.a) when c<d or (e=17 or t1.f in (select min(t1.a) from t1 union select max(a) from t1)) then e else d end*b+t1.e FROM t1 WHERE (select case case case cast(avg(+(select abs(+count(distinct t1.d)-count(distinct t1.b) | max(17)) |  -cast(avg(f) AS integer)*count(*) from t1)) AS integer) when  -count(*)* - -max(b) then (count(distinct 19)) else max(t1.e) end when count(*) then count(*) else cast(avg(t1.c) AS integer) end when max(c) then (cast(avg(t1.c) AS integer)) else min(t1.f) end-max(17) | min((11)) from t1)<>+case ~e+~t1.d | 13 when case when t1.c<=t1.c or (11)=t1.a then 11 when  -11 in (17,11, -d) then t1.a else t1.b end then 19 else 13 end* -t1.c}\n} {100500}\ndo_test randexpr-2.995 {\n  db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case  -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end | count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct  -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end | a FROM t1 WHERE coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1)}\n} {}\ndo_test randexpr-2.996 {\n  db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case  -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end | count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct  -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end | a FROM t1 WHERE NOT (coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1))}\n} {636}\ndo_test randexpr-2.997 {\n  db eval {SELECT case when (f in (select count(distinct 17) from t1 union select count(distinct t1.b) from t1)) then d when e in (coalesce((select max(e+e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where 11-t1.a in (select case  -max(11)-max(b) when min(t1.f) then count(distinct f) else count(distinct t1.c) end & count(*) from t1 union select min( -a) from t1)) and t1.e in (select count(distinct  -t1.e) from t1 union select count(distinct a) from t1) and d not in (b,f,t1.d)) and a between t1.c and t1.e),f),c,11) then c else t1.f end & a FROM t1 WHERE NOT (coalesce((select a from t1 where t1.a | (17-coalesce((select t1.b from t1 where ~t1.f | t1.e=d and a<=19+(select (cast(avg(c) AS integer)) from t1)),t1.c))+t1.e*t1.d+t1.c not between t1.d and 19), -t1.d) in (select (count(*)) from t1 union select (++~min(c)*+max(t1.a)+cast(avg( -(t1.e)) AS integer)) from t1))}\n} {64}\ndo_test randexpr-2.998 {\n  db eval {SELECT case when coalesce((select t1.b from t1 where a not in (19,coalesce((select max(t1.f) from t1 where (select count(distinct t1.b) from t1) in (t1.e,t1.f*13-11,d)),(t1.f))-17*c,c) or t1.c<=11),19)>13 and f not in (t1.a,11,t1.d) then (((e))) when f=11 or f not in (a,19,17) then 13 else e end FROM t1 WHERE c in (select min(t1.a*a+(select count(distinct t1.b+(t1.a)- - -c) from t1)-t1.e) from t1 union select count(*) from t1) and c in (select min(t1.d) from t1 union select cast(avg(d) AS integer)+abs(case count(*) when count(distinct 11) then  -count(distinct 19) else count(distinct (t1.b)) end) | cast(avg((t1.c)) AS integer)+count(*) from t1) and e=13 and t1.d>c or 13 not in (17,(t1.f),t1.a) or (11)=t1.b and t1.e>=a or 11<=t1.b or d<=17}\n} {500}\ndo_test randexpr-2.999 {\n  db eval {SELECT case when coalesce((select t1.b from t1 where a not in (19,coalesce((select max(t1.f) from t1 where (select count(distinct t1.b) from t1) in (t1.e,t1.f*13-11,d)),(t1.f))-17*c,c) or t1.c<=11),19)>13 and f not in (t1.a,11,t1.d) then (((e))) when f=11 or f not in (a,19,17) then 13 else e end FROM t1 WHERE NOT (c in (select min(t1.a*a+(select count(distinct t1.b+(t1.a)- - -c) from t1)-t1.e) from t1 union select count(*) from t1) and c in (select min(t1.d) from t1 union select cast(avg(d) AS integer)+abs(case count(*) when count(distinct 11) then  -count(distinct 19) else count(distinct (t1.b)) end) | cast(avg((t1.c)) AS integer)+count(*) from t1) and e=13 and t1.d>c or 13 not in (17,(t1.f),t1.a) or (11)=t1.b and t1.e>=a or 11<=t1.b or d<=17)}\n} {}\ndo_test randexpr-2.1000 {\n  db eval {SELECT case when t1.d not between (abs(d)/abs(t1.e))+t1.f*t1.a*a and 17*e then case when 11 between a and coalesce((select max(t1.b) from t1 where (case when t1.e+(t1.b) not in (t1.e,d,f) or 13<>17 then 17 when a>e then 11 else a end in (select count(*) from t1 union select min(a) from t1))),17) then 19 when  -11 in (select t1.c from t1 union select  -19 from t1) or  - - -t1.e=t1.a then 17 else t1.a end else t1.e end FROM t1 WHERE (select +count(distinct f) from t1)-t1.f between t1.f and c}\n} {}\ndo_test randexpr-2.1001 {\n  db eval {SELECT case when t1.d not between (abs(d)/abs(t1.e))+t1.f*t1.a*a and 17*e then case when 11 between a and coalesce((select max(t1.b) from t1 where (case when t1.e+(t1.b) not in (t1.e,d,f) or 13<>17 then 17 when a>e then 11 else a end in (select count(*) from t1 union select min(a) from t1))),17) then 19 when  -11 in (select t1.c from t1 union select  -19 from t1) or  - - -t1.e=t1.a then 17 else t1.a end else t1.e end FROM t1 WHERE NOT ((select +count(distinct f) from t1)-t1.f between t1.f and c)}\n} {100}\ndo_test randexpr-2.1002 {\n  db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) | +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end |  -e*a FROM t1 WHERE f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then  -b else  -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c)}\n} {-49732}\ndo_test randexpr-2.1003 {\n  db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) | +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end |  -e*a FROM t1 WHERE NOT (f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then  -b else  -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c))}\n} {}\ndo_test randexpr-2.1004 {\n  db eval {SELECT case when (case when e between t1.b and c+(select cast(avg( -case c when a then t1.f+c else 17 end) AS integer) from t1) then t1.e when not 19>=t1.a then 17 else d end in (select cast(avg(13) AS integer)-max(11) & +count(*) from t1 union select case (cast(avg(d) AS integer)) when min(a) then abs( -max(19)) else count(*) end from t1)) then (t1.a) else c end &  -e*a FROM t1 WHERE f*t1.d*(abs(case d when coalesce((select max((abs(t1.e)/abs(t1.f))) from t1 where ((e between (b) and 13) or t1.d=(c)) and t1.f between 17 and t1.e),a) then  -b else  -e end+ -t1.e)/abs(t1.c))+f<=17 or t1.f not between f and t1.e or (t1.c in (select 17 from t1 union select f from t1)) or exists(select 1 from t1 where (a not in (d,t1.a,t1.e) and t1.a in (t1.a,c,19))) and f not in (t1.d,t1.c,c)}\n} {32}\ndo_test randexpr-2.1005 {\n  db eval {SELECT  -case coalesce((select case when f<>t1.d | c-(e)*t1.b and 17 in (select t1.b from t1 union select  -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where  -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select  -min(d) from t1)}\n} {}\ndo_test randexpr-2.1006 {\n  db eval {SELECT  -case coalesce((select case when f<>t1.d | c-(e)*t1.b and 17 in (select t1.b from t1 union select  -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where  -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE NOT (coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select  -min(d) from t1))}\n} {-100}\ndo_test randexpr-2.1007 {\n  db eval {SELECT  -case coalesce((select case when f<>t1.d & c-(e)*t1.b and 17 in (select t1.b from t1 union select  -(t1.c) from t1) or t1.e>=11 and t1.f not between b and f or e not in (11,19,t1.e) and t1.c<=a then coalesce((select max(t1.f+t1.f) from t1 where  -t1.a<t1.f),t1.c) when e not in (t1.c,t1.d,t1.e) then t1.f else t1.e end-d from t1 where e>=13),e) when t1.e then c else t1.a end FROM t1 WHERE NOT (coalesce((select t1.f from t1 where (t1.e>=case (abs(11)/abs(t1.a)) when 11 then case t1.c when t1.a then t1.e else a end else t1.f end+t1.d) and (exists(select 1 from t1 where t1.b not in (t1.b,a,19))) or t1.a>=11),(select abs((~cast(avg(t1.b) AS integer)-~cast(avg((t1.b)) AS integer)* -count(*))+ -count(distinct t1.b)) from t1)*19)<=f and b in (select count(*) from t1 union select  -min(d) from t1))}\n} {-100}\ndo_test randexpr-2.1008 {\n  db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where  -case when t1.d<=coalesce((select t1.d | (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and  -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) | count(*) when min(t1.c) then ( - -count(distinct  -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select  -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f}\n} {400}\ndo_test randexpr-2.1009 {\n  db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where  -case when t1.d<=coalesce((select t1.d | (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and  -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) | count(*) when min(t1.c) then ( - -count(distinct  -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE NOT (case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select  -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f)}\n} {}\ndo_test randexpr-2.1010 {\n  db eval {SELECT case when exists(select 1 from t1 where exists(select 1 from t1 where  -case when t1.d<=coalesce((select t1.d & (f)*t1.a from t1 where not exists(select 1 from t1 where t1.f not in ((e),t1.e,13) or t1.a not between a and  -t1.d or (f) not between f and 13)),19) then e when (t1.f)<19 or e<=d then b else d end in (select case ~ -(cast(avg(b) AS integer)*cast(avg(t1.b) AS integer)*min(t1.f)) & count(*) when min(t1.c) then ( - -count(distinct  -d)) else count(*) end from t1 union select cast(avg(f) AS integer) from t1) and b<a)) then t1.b else t1.d end FROM t1 WHERE case case when case when not d<t1.a+t1.d+t1.c then ~f when ((not exists(select 1 from t1 where 19 in ( -(t1.f),17, -e)))) or f not between a and a then t1.f else 19 end in (select min(e)-~ -count(*)*(count(*))+count(*)*min(e) from t1 union select  -( -( -count(*))) from t1) then 11 when e<=f then 17 else 13 end+(19)+f when c then b else c end<>t1.b or 19<>t1.f}\n} {400}\ndo_test randexpr-2.1011 {\n  db eval {SELECT case when ~+11<>f then case e when 11 then coalesce((select case d when t1.e-coalesce((select a+t1.c from t1 where (d) in (select +min(t1.f)+count(*) from t1 union select count(distinct t1.e) from t1)),t1.f) then t1.c else d end from t1 where t1.f in (select t1.f from t1 union select b from t1) or (t1.a not in ( -a,t1.a,t1.b))),t1.c) else t1.f end-t1.f when not exists(select 1 from t1 where b between f and t1.a) then t1.c else t1.f end FROM t1 WHERE t1.a<=coalesce((select max(b) from t1 where coalesce((select t1.c*case when coalesce((select max((select count(*) from t1)) from t1 where not not exists(select 1 from t1 where case t1.b | a when t1.f then c else 11 end<>f and 13>=13 and f between t1.b and c)),13)=case e when a then 19 else d end then t1.b when t1.a not in (a,t1.b,a) then e else b end-d from t1 where t1.f between t1.d and t1.e),e)>t1.f),17)+t1.f}\n} {0}\ndo_test randexpr-2.1012 {\n  db eval {SELECT case when ~+11<>f then case e when 11 then coalesce((select case d when t1.e-coalesce((select a+t1.c from t1 where (d) in (select +min(t1.f)+count(*) from t1 union select count(distinct t1.e) from t1)),t1.f) then t1.c else d end from t1 where t1.f in (select t1.f from t1 union select b from t1) or (t1.a not in ( -a,t1.a,t1.b))),t1.c) else t1.f end-t1.f when not exists(select 1 from t1 where b between f and t1.a) then t1.c else t1.f end FROM t1 WHERE NOT (t1.a<=coalesce((select max(b) from t1 where coalesce((select t1.c*case when coalesce((select max((select count(*) from t1)) from t1 where not not exists(select 1 from t1 where case t1.b | a when t1.f then c else 11 end<>f and 13>=13 and f between t1.b and c)),13)=case e when a then 19 else d end then t1.b when t1.a not in (a,t1.b,a) then e else b end-d from t1 where t1.f between t1.d and t1.e),e)>t1.f),17)+t1.f)}\n} {}\ndo_test randexpr-2.1013 {\n  db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then  -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) | min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1)}\n} {}\ndo_test randexpr-2.1014 {\n  db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then  -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) | min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE NOT (coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1))}\n} {0}\ndo_test randexpr-2.1015 {\n  db eval {SELECT (abs(d)/abs(t1.f++(select cast(avg(coalesce((select max(b) from t1 where case when t1.a*+(abs( -t1.b)/abs((select cast(avg(13) AS integer) from t1)))<=(t1.c-t1.d- -t1.c) then case d when 17 then  -t1.d else f end when t1.b between t1.b and t1.b then a else t1.d end in (select count(*) from t1 union select abs(cast(avg(13) AS integer)) & min(t1.c) from t1) or ((13))>=b),17)) AS integer) from t1)+13)) FROM t1 WHERE NOT (coalesce((select +t1.a from t1 where not exists(select 1 from t1 where (select cast(avg(13) AS integer) from t1)<=(abs( -11)/abs(t1.f))*coalesce((select t1.e from t1 where not t1.f in (select max(+b-t1.d) from t1 union select + -(abs(cast(avg((t1.b)) AS integer)))-+count(*)-(min(13)) from t1)),d+t1.d*t1.d) | (17)-t1.b)),f) in (select max(t1.c) from t1 union select count(distinct f) from t1))}\n} {0}\ndo_test randexpr-2.1016 {\n  db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end | (17) | t1.d FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e)}\n} {}\ndo_test randexpr-2.1017 {\n  db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end | (17) | t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e))}\n} {401}\ndo_test randexpr-2.1018 {\n  db eval {SELECT case t1.a when (select ~max(coalesce((select (t1.b-a*+t1.c-t1.e) from t1 where not 11*t1.f++t1.f-t1.a*f*+t1.e*t1.b>17 and 19+e not in (t1.c,t1.b,a)),19)) from t1) then 19*11 else d end & (17) & t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(13) from t1 where t1.e not in (d,13-19,17) or e*19=d or ((t1.a< -t1.a or 11- -t1.d-case when 13<( -t1.e) then a else e end*t1.b+t1.e in (select t1.d from t1 union select t1.e from t1) and 19<>d))),b)+11*11=t1.e))}\n} {16}\ndo_test randexpr-2.1019 {\n  db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a | (t1.a+++(select cast(avg((abs(t1.d | e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE ~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11}\n} {-400}\ndo_test randexpr-2.1020 {\n  db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a | (t1.a+++(select cast(avg((abs(t1.d | e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE NOT (~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11)}\n} {}\ndo_test randexpr-2.1021 {\n  db eval {SELECT t1.a-coalesce((select 11-case when 11<19-f+t1.a then a & (t1.a+++(select cast(avg((abs(t1.d & e)/abs((abs(t1.a)/abs(13))))) AS integer)-max(a) from t1)+e+13*19+t1.a-c) else 13 end+t1.e-19 from t1 where 13>t1.f),e) FROM t1 WHERE ~(abs((select max( -case when d+(11)*d between coalesce((select 11 from t1 where (t1.f)=e),d*f) and t1.e then d-case when a<> -17+(abs(t1.d)/abs(t1.f)) then t1.f else t1.e end*11+c-(c) else d end) from t1)*t1.e)/abs((t1.f)))-f<>11}\n} {-400}\ndo_test randexpr-2.1022 {\n  db eval {SELECT d | (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) | max(e)) from t1) FROM t1 WHERE  -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when  -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b)}\n} {511}\ndo_test randexpr-2.1023 {\n  db eval {SELECT d | (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) | max(e)) from t1) FROM t1 WHERE NOT ( -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when  -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b))}\n} {}\ndo_test randexpr-2.1024 {\n  db eval {SELECT d & (select (cast(avg((abs(case when b*(abs((abs(case f when 17 then t1.e else t1.c end)/abs( -d)))/abs(t1.c)) in (d,a,a) then 19 when (exists(select 1 from t1 where t1.c=t1.a) or a<>d) then a else c end)/abs(t1.e))-17) AS integer)* -min(19)-count(distinct a)-+count(distinct 17)*min(t1.a)+ -cast(avg(t1.a) AS integer)- -max(17) & max(e)) from t1) FROM t1 WHERE  -f-t1.f++e+case when not (((select abs(count(*)) from t1)) not in ((case when (t1.b>t1.c) then t1.b else f end),e,13)) and not exists(select 1 from t1 where 11 in (select t1.f from t1 union select ((t1.f)) from t1)) then (t1.e)+c-c+c when  -b in (13,19,t1.c) then 17 else 13 end-d | t1.a not in (a,b,b)}\n} {128}\ndo_test randexpr-2.1025 {\n  db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f | 11 between (select case  -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select  -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE e in (e, -17*t1.c*17,e)}\n} {11}\ndo_test randexpr-2.1026 {\n  db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f | 11 between (select case  -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select  -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE NOT (e in (e, -17*t1.c*17,e))}\n} {}\ndo_test randexpr-2.1027 {\n  db eval {SELECT 11-(select min((abs(e)/abs(f*t1.e*c+17+~case when f & 11 between (select case  -max(19) when (cast(avg(t1.a) AS integer)) then count(distinct t1.f) else count(*) end from t1) and coalesce((select 13 from t1 where a<=(t1.d)),f)-a then t1.a when f in (select 17 from t1 union select  -b from t1) and t1.d<a or d<>(17) or 19>=d then (f) else 11 end))) from t1) FROM t1 WHERE e in (e, -17*t1.c*17,e)}\n} {11}\ndo_test randexpr-2.1028 {\n  db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) | count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE ((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when  -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a)}\n} {-81200}\ndo_test randexpr-2.1029 {\n  db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) | count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE NOT (((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when  -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a))}\n} {}\ndo_test randexpr-2.1030 {\n  db eval {SELECT coalesce((select max( -t1.d-f+~t1.d*t1.b) from t1 where (select ~+min(t1.f)+abs(min(+(select cast(avg((b)) AS integer) from t1)-d*d))-max(f)-count(distinct 19) & count(*)*count(*) from t1)>c),case 13 when +t1.c-t1.c-t1.a then c else c end*d) FROM t1 WHERE ((t1.b>=case when not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where e>=t1.a or (coalesce((select max(coalesce((select case when a in (select t1.d from t1 union select t1.c from t1) then a when  -b in (17,c,t1.f) then f else b end from t1 where not exists(select 1 from t1 where f<=13)),17)) from t1 where t1.f>=t1.b),d) between t1.f and 11) or t1.b between 13 and t1.b))) then a when e<=17 then t1.b+ -~11 else a end and not e>= - -b or 13 not in (c,f,11)) and d not between 11 and t1.a)}\n} {120000}\ndo_test randexpr-2.1031 {\n  db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end | t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1)))}\n} {4400}\ndo_test randexpr-2.1032 {\n  db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end | t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE NOT (t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1))))}\n} {}\ndo_test randexpr-2.1033 {\n  db eval {SELECT case when t1.d<>coalesce((select 13 from t1 where (d in (select case when (13<>t1.a*d-19-+11*13-t1.c) then case when t1.c=d then e else t1.b end when not exists(select 1 from t1 where 17<>t1.b) then t1.e else t1.e end & t1.a+t1.e from t1 union select t1.d from t1))),t1.f) or a> -t1.e then 11 else 17 end*d FROM t1 WHERE t1.a-d<=d-(abs(coalesce((select b from t1 where ~e<case when (case when case when d>=13 then t1.d else (t1.c) end not between t1.a and 13 then a when (17) not between 11 and t1.c then a else a end) not between 13 and t1.d then 13 else a end),19))/abs(t1.e))+t1.c+t1.e*b+c or ((17 in (select f from t1 union select t1.e from t1)))}\n} {4400}\ndo_test randexpr-2.1034 {\n  db eval {SELECT coalesce((select (abs(c)/abs(case when 13<=11 then t1.a when case t1.d when (11) then coalesce((select coalesce((select d-17 from t1 where t1.e=a),11) from t1 where 13 in (select t1.e from t1 union select c from t1)),19) else d end>=t1.f or 11 in (select cast(avg(t1.f) AS integer) from t1 union select ( - -count(*)) from t1) and t1.c between 13 and  -b then f else e end)) from t1 where d<=(19)),d)-t1.b FROM t1 WHERE 17>=case when t1.c not in (f,t1.a,c*17*a | t1.c-~t1.d+(+coalesce((select max(case when exists(select 1 from t1 where (t1.e in (select  -t1.e from t1 union select t1.c from t1))) then t1.b else t1.b*t1.b end) from t1 where not exists(select 1 from t1 where 17=t1.a)),d))+t1.e | (13)*t1.e+c) and e in (select  -c from t1 union select 17 from t1) then t1.d*13 else c end- -e}\n} {}\ndo_test randexpr-2.1035 {\n  db eval {SELECT coalesce((select (abs(c)/abs(case when 13<=11 then t1.a when case t1.d when (11) then coalesce((select coalesce((select d-17 from t1 where t1.e=a),11) from t1 where 13 in (select t1.e from t1 union select c from t1)),19) else d end>=t1.f or 11 in (select cast(avg(t1.f) AS integer) from t1 union select ( - -count(*)) from t1) and t1.c between 13 and  -b then f else e end)) from t1 where d<=(19)),d)-t1.b FROM t1 WHERE NOT (17>=case when t1.c not in (f,t1.a,c*17*a | t1.c-~t1.d+(+coalesce((select max(case when exists(select 1 from t1 where (t1.e in (select  -t1.e from t1 union select t1.c from t1))) then t1.b else t1.b*t1.b end) from t1 where not exists(select 1 from t1 where 17=t1.a)),d))+t1.e | (13)*t1.e+c) and e in (select  -c from t1 union select 17 from t1) then t1.d*13 else c end- -e)}\n} {200}\ndo_test randexpr-2.1036 {\n  db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) | ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b | 11) from t1 union select count(*) | count(distinct c) | count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE ((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17}\n} {}\ndo_test randexpr-2.1037 {\n  db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) | ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b | 11) from t1 union select count(*) | count(distinct c) | count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE NOT (((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17)}\n} {-400}\ndo_test randexpr-2.1038 {\n  db eval {SELECT (abs(case when t1.a in (select case when d=(select ~cast(avg(t1.a) AS integer) & ~+min(17*(abs(19)/abs(t1.a))) from t1) or 13 in (select count(distinct t1.b & 11) from t1 union select count(*) & count(distinct c) & count(distinct 17) from t1) and not b<=17 then t1.a when 11=t1.f then (abs(t1.c)/abs(11)) else f end from t1 union select c from t1) then t1.c else a end)/abs(t1.d))-t1.d FROM t1 WHERE NOT (((abs(e)/abs(t1.a* -(coalesce((select max(t1.b-t1.d) from t1 where f>=13),~a+ -a)) | case when not exists(select 1 from t1 where coalesce((select max(c) from t1 where 19-t1.a | e<=17),~( -t1.a)) in (select f from t1 union select t1.d from t1)) then t1.d else (t1.c) end)) in (17,f,t1.a)) or 19=13 or 19=17)}\n} {-400}\ndo_test randexpr-2.1039 {\n  db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select  - -abs(max(19))+(min(a)) from t1 union select count(distinct  -t1.d) from t1)),e)>=e),t1.f) | t1.a | 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and  -11) then coalesce((select  -b from t1 where  -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1)}\n} {}\ndo_test randexpr-2.1040 {\n  db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select  - -abs(max(19))+(min(a)) from t1 union select count(distinct  -t1.d) from t1)),e)>=e),t1.f) | t1.a | 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and  -11) then coalesce((select  -b from t1 where  -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE NOT (t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1))}\n} {400}\ndo_test randexpr-2.1041 {\n  db eval {SELECT case when f>coalesce((select c from t1 where coalesce((select max(c+c) from t1 where t1.f in (select  - -abs(max(19))+(min(a)) from t1 union select count(distinct  -t1.d) from t1)),e)>=e),t1.f) & t1.a & 19 or (t1.c) not in (19, - -t1.f,t1.c) or exists(select 1 from t1 where t1.b not between t1.a and  -11) then coalesce((select  -b from t1 where  -t1.a in (select c from t1 union select 17 from t1)),t1.d) when t1.a=c then c else t1.e end FROM t1 WHERE NOT (t1.e in (select +cast(avg(f) AS integer) from t1 union select case +max(19) | count(*) when count(*)*+count(*) then ~+count(*) else count(*) end from t1))}\n} {400}\ndo_test randexpr-2.1042 {\n  db eval {SELECT +case t1.d when d then t1.f else +t1.b+(select  -count(distinct coalesce((select max(c) from t1 where exists(select 1 from t1 where 17 not between d and e)),case when t1.f+f-~17<>d then case when exists(select 1 from t1 where t1.d=(13)) then t1.e when c=t1.e then  -a else f end when not 17>11 then t1.b else e end))-max(t1.d) from t1)+ -e-(t1.d) end-11-b FROM t1 WHERE e-case +t1.e when e*e then t1.d else case (abs(case when (abs(case when t1.a+11+t1.a>11-t1.e then +t1.f when e<=a then (c) else b end)/abs(13))*b between b and t1.f then  -a else t1.c end+d)/abs(a)) when d then 13 else t1.e end end+e+t1.d<=c}\n} {}\ndo_test randexpr-2.1043 {\n  db eval {SELECT +case t1.d when d then t1.f else +t1.b+(select  -count(distinct coalesce((select max(c) from t1 where exists(select 1 from t1 where 17 not between d and e)),case when t1.f+f-~17<>d then case when exists(select 1 from t1 where t1.d=(13)) then t1.e when c=t1.e then  -a else f end when not 17>11 then t1.b else e end))-max(t1.d) from t1)+ -e-(t1.d) end-11-b FROM t1 WHERE NOT (e-case +t1.e when e*e then t1.d else case (abs(case when (abs(case when t1.a+11+t1.a>11-t1.e then +t1.f when e<=a then (c) else b end)/abs(13))*b between b and t1.f then  -a else t1.c end+d)/abs(a)) when d then 13 else t1.e end end+e+t1.d<=c)}\n} {389}\ndo_test randexpr-2.1044 {\n  db eval {SELECT + -(select count(*) from t1)*(t1.b)-a-t1.e+17*coalesce((select max(13) from t1 where not exists(select 1 from t1 where case when t1.f<coalesce((select a from t1 where t1.a not in (t1.b,t1.a,19)),t1.a)*f and not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)=19)) then +t1.d when c<>t1.d then 17 else  -17 end* -(t1.f)=(t1.a))), -d)*t1.f*t1.a* -e FROM t1 WHERE not exists(select 1 from t1 where ~case when d+ -t1.c+11*t1.e-t1.c*a*(t1.b)<=~~t1.b then f else case b when t1.b*t1.c-t1.d then c-b else  -t1.c end end-13+f>=case when d not between t1.c and (t1.b) then t1.e else t1.c end) or t1.d in (d,t1.c,t1.c)}\n} {-6630000800}\ndo_test randexpr-2.1045 {\n  db eval {SELECT + -(select count(*) from t1)*(t1.b)-a-t1.e+17*coalesce((select max(13) from t1 where not exists(select 1 from t1 where case when t1.f<coalesce((select a from t1 where t1.a not in (t1.b,t1.a,19)),t1.a)*f and not exists(select 1 from t1 where exists(select 1 from t1 where (t1.d)=19)) then +t1.d when c<>t1.d then 17 else  -17 end* -(t1.f)=(t1.a))), -d)*t1.f*t1.a* -e FROM t1 WHERE NOT (not exists(select 1 from t1 where ~case when d+ -t1.c+11*t1.e-t1.c*a*(t1.b)<=~~t1.b then f else case b when t1.b*t1.c-t1.d then c-b else  -t1.c end end-13+f>=case when d not between t1.c and (t1.b) then t1.e else t1.c end) or t1.d in (d,t1.c,t1.c))}\n} {}\ndo_test randexpr-2.1046 {\n  db eval {SELECT (abs((select  -~~ -count(*)+++count(distinct c) from t1))/abs(coalesce((select e from t1 where (case when case when b not between case t1.d when f then  -t1.c else t1.e end and c then d when b=19 then t1.c else d end in (select max(13) from t1 union select count(distinct b) from t1) and t1.d not in (a,t1.b,a) or  -t1.d between 13 and e then 17+t1.e when 19 not between t1.f and 17 then t1.b else t1.a end in (17,(t1.e),t1.a))),b) | 17)) FROM t1 WHERE 11>t1.b}\n} {}\ndo_test randexpr-2.1047 {\n  db eval {SELECT (abs((select  -~~ -count(*)+++count(distinct c) from t1))/abs(coalesce((select e from t1 where (case when case when b not between case t1.d when f then  -t1.c else t1.e end and c then d when b=19 then t1.c else d end in (select max(13) from t1 union select count(distinct b) from t1) and t1.d not in (a,t1.b,a) or  -t1.d between 13 and e then 17+t1.e when 19 not between t1.f and 17 then t1.b else t1.a end in (17,(t1.e),t1.a))),b) | 17)) FROM t1 WHERE NOT (11>t1.b)}\n} {0}\ndo_test randexpr-2.1048 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) | max((17)) | cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE not a<=17-t1.f}\n} {400}\ndo_test randexpr-2.1049 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) | max((17)) | cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE NOT (not a<=17-t1.f)}\n} {}\ndo_test randexpr-2.1050 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where coalesce((select e from t1 where case when (c)<>11+case f when t1.a then (select abs( -cast(avg(t1.c) AS integer)) & max((17)) & cast(avg(t1.d) AS integer)-count(distinct e) from t1) else 17*(abs(case t1.d when t1.b then a else b end)/abs(b)) end- -c-17+c*t1.c- -t1.d then t1.c else e end>=f),d)<>t1.a), -t1.f) FROM t1 WHERE not a<=17-t1.f}\n} {400}\ndo_test randexpr-2.1051 {\n  db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c | (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then  -t1.e else  -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f}\n} {}\ndo_test randexpr-2.1052 {\n  db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c | (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then  -t1.e else  -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE NOT (case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f)}\n} {-401}\ndo_test randexpr-2.1053 {\n  db eval {SELECT coalesce((select coalesce((select ~d from t1 where t1.b-t1.c+13 not between t1.b and (abs(t1.a-case t1.c when t1.c & (select max((abs(case when (select count(*) from t1)<>(~t1.e-13*+d+d) then  -t1.e else  -t1.f end*13)/abs(f))-t1.f) from t1) then t1.f else t1.c end)/abs(c))),t1.e) from t1 where t1.f=f), - -11) FROM t1 WHERE NOT (case ((abs(t1.e)/abs(case b when ~17 then 19+(t1.d)+13 else case t1.a*17 when c then 19*case when c<>coalesce((select max(~a) from t1 where 19<>case case when t1.d in (select +count(distinct 11) from t1 union select ( -max(a)) from t1) then t1.f else b end when t1.f then d else t1.a end-t1.b),11) then t1.b else t1.d end else 11 end end))) when t1.b then 11 else t1.d end*t1.c= -t1.f)}\n} {-401}\ndo_test randexpr-2.1054 {\n  db eval {SELECT  -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f | coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else  -t1.c end FROM t1 WHERE case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c}\n} {-713}\ndo_test randexpr-2.1055 {\n  db eval {SELECT  -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f | coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else  -t1.c end FROM t1 WHERE NOT (case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c)}\n} {}\ndo_test randexpr-2.1056 {\n  db eval {SELECT  -13-case when (not d<=11-t1.c*t1.e+t1.b) then case when t1.f & coalesce((select +d from t1 where t1.d= -c),(t1.a)) not between b and t1.a then t1.f+a when t1.a<11 and exists(select 1 from t1 where t1.f in (t1.b,17,11)) then b else 19 end when (t1.b between t1.d and e) then b else  -t1.c end FROM t1 WHERE case when b between case when coalesce((select t1.c-t1.c from t1 where 13*(select case min(11) when cast(avg(t1.c) AS integer) then (count(*)) else count(distinct 11) end+cast(avg( -f) AS integer) from t1)>=t1.a),t1.c) in ( -t1.c,d,b) then t1.e when f in (select e from t1 union select t1.d from t1) then f else c end and a and 13<>c and exists(select 1 from t1 where f<>c) then case when c in (11,b, -11) then t1.e else e end else 13 end<=t1.c}\n} {-713}\ndo_test randexpr-2.1057 {\n  db eval {SELECT t1.b | (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 | +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE (a between t1.e and  -13)}\n} {}\ndo_test randexpr-2.1058 {\n  db eval {SELECT t1.b | (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 | +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE NOT ((a between t1.e and  -13))}\n} {200}\ndo_test randexpr-2.1059 {\n  db eval {SELECT t1.b & (abs( -(select ~ -~abs(case ~min((c* -b+c))+min(f) when ~abs(count(distinct 13))+(min(13)) then max(11) else count(*) end) from t1)-11 & +(abs(t1.d-t1.e)/abs(t1.b))-t1.f*19+t1.c*17)/abs(f))+t1.b FROM t1 WHERE NOT ((a between t1.e and  -13))}\n} {192}\ndo_test randexpr-2.1060 {\n  db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) | ~cast(avg(b | case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) | min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE (t1.d)+t1.b<( -t1.b)}\n} {}\ndo_test randexpr-2.1061 {\n  db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) | ~cast(avg(b | case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) | min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE NOT ((t1.d)+t1.b<( -t1.b))}\n} {100}\ndo_test randexpr-2.1062 {\n  db eval {SELECT t1.c-case t1.b when t1.f-t1.b-f then +coalesce((select b from t1 where (t1.d in (select (select count(*)+abs(count(*)) & ~cast(avg(b & case when 11 between b and (f) then b when (19)>19 then 17 else t1.e end) AS integer) & min(d) from t1) from t1 union select 19 from t1))),(abs(c*c)/abs(11))-a-t1.c+t1.f-t1.c)+b else b end FROM t1 WHERE NOT ((t1.d)+t1.b<( -t1.b))}\n} {100}\ndo_test randexpr-2.1063 {\n  db eval {SELECT 17*(select (case case min(t1.d+( -d | case 11* -11*11 when 13 then t1.c else  -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) | +abs(cast(avg((a)) AS integer))+(count(*)) when  -max(17) then  -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end |  -max(t1.d) from t1 union select  -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d}\n} {}\ndo_test randexpr-2.1064 {\n  db eval {SELECT 17*(select (case case min(t1.d+( -d | case 11* -11*11 when 13 then t1.c else  -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) | +abs(cast(avg((a)) AS integer))+(count(*)) when  -max(17) then  -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE NOT (d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end |  -max(t1.d) from t1 union select  -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d)}\n} {17}\ndo_test randexpr-2.1065 {\n  db eval {SELECT 17*(select (case case min(t1.d+( -d & case 11* -11*11 when 13 then t1.c else  -17 end)-d*t1.d)-count(*)-abs( -max(17)+~max(t1.b)) & +abs(cast(avg((a)) AS integer))+(count(*)) when  -max(17) then  -max(19) else (cast(avg(d) AS integer)) end when count(distinct t1.c) then min(b) else count(*) end) from t1) FROM t1 WHERE NOT (d>=(abs(coalesce((select max(d) from t1 where not not case when a in (select count(*)* -case +min(case when t1.e<t1.e then 11 else a end-19)*case count(*) when max(13) then count(*) else min(b) end | ( -cast(avg(b) AS integer)) when max(t1.d) then (cast(avg((t1.a)) AS integer)) else min(f) end |  -max(t1.d) from t1 union select  -min(c) from t1) then e else e end<(select max(t1.c) from t1)),c++t1.f*c))/abs(e))+t1.d)}\n} {17}\ndo_test randexpr-2.1066 {\n  db eval {SELECT 11 | ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then  -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c)}\n} {59707}\ndo_test randexpr-2.1067 {\n  db eval {SELECT 11 | ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then  -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE NOT (not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c))}\n} {}\ndo_test randexpr-2.1068 {\n  db eval {SELECT 11 & ~case case when e between 17 and coalesce((select max(((f-t1.f))) from t1 where d<>f),t1.f) and 11 not between 13 and 13 and ( -11<>c and t1.b>c) or 19<>t1.e and t1.b<=t1.f then +f*b when t1.d>=e then  -13 else t1.c end when b then (17) else t1.d end+a+f*a FROM t1 WHERE not exists(select 1 from t1 where a between t1.f and 17 or e>=(d)*19+t1.e*c)}\n} {3}\ndo_test randexpr-2.1069 {\n  db eval {SELECT  -case when t1.d | ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then  -f* -d else (e) end*f FROM t1 WHERE case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then  -17 else t1.c end and c then  -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else  -13 end=c}\n} {}\ndo_test randexpr-2.1070 {\n  db eval {SELECT  -case when t1.d | ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then  -f* -d else (e) end*f FROM t1 WHERE NOT (case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then  -17 else t1.c end and c then  -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else  -13 end=c)}\n} {-144000000}\ndo_test randexpr-2.1071 {\n  db eval {SELECT  -case when t1.d & ~b<>coalesce((select max(t1.c) from t1 where t1.c not between coalesce((select max(coalesce((select max(e) from t1 where 11 not in (case when 13 not between d and c then 17 when (t1.a) not in (e,b,b) then 19 else c end,a,t1.d)),b)+f) from t1 where t1.d not in (11,f,t1.e)),t1.b) and f),11) or 11<>(d) then  -f* -d else (e) end*f FROM t1 WHERE NOT (case f when 11 then coalesce((select b from t1 where 19+case when 17*t1.d-t1.f+t1.f between t1.d-case when +d=coalesce((select max(f) from t1 where e>t1.f),17) and c=t1.e and b not in (17,11,(t1.f)) then  -17 else t1.c end and c then  -t1.a else t1.d end+11*e not between t1.f and d),13)+t1.d else  -13 end=c)}\n} {-144000000}\ndo_test randexpr-2.1072 {\n  db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) |  - -a FROM t1 WHERE 13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1)}\n} {}\ndo_test randexpr-2.1073 {\n  db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) |  - -a FROM t1 WHERE NOT (13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1))}\n} {236}\ndo_test randexpr-2.1074 {\n  db eval {SELECT coalesce((select t1.b from t1 where not (t1.c>19) and 11<=+(abs(t1.b-19)/abs(a))+case when ((coalesce((select 13 from t1 where c in (b,t1.b,t1.d)),e))<>13) or f in ((t1.b),t1.e, -b) then 11+(c) else b end or b<>d),t1.f+t1.f+13) &  - -a FROM t1 WHERE NOT (13 between t1.c and 13+~19+c+(select min(f-(abs(17)/abs((t1.e)))) from t1))}\n} {64}\ndo_test randexpr-2.1075 {\n  db eval {SELECT  -(coalesce((select max(coalesce((select t1.f from t1 where not exists(select 1 from t1 where (abs(+b+19+19)/abs(t1.b))<t1.b) or 19+f>=(select  -max(19) from t1)+t1.f),t1.e+t1.f)* -t1.e+19-f) from t1 where (( -t1.c<19) or d>=c)),t1.c))*c*((t1.b))-17 FROM t1 WHERE t1.e not between t1.f*c and t1.f+ -d}\n} {18034859983}\ndo_test randexpr-2.1076 {\n  db eval {SELECT  -(coalesce((select max(coalesce((select t1.f from t1 where not exists(select 1 from t1 where (abs(+b+19+19)/abs(t1.b))<t1.b) or 19+f>=(select  -max(19) from t1)+t1.f),t1.e+t1.f)* -t1.e+19-f) from t1 where (( -t1.c<19) or d>=c)),t1.c))*c*((t1.b))-17 FROM t1 WHERE NOT (t1.e not between t1.f*c and t1.f+ -d)}\n} {}\ndo_test randexpr-2.1077 {\n  db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and  -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when  -min(e) |  -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select  -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f))}\n} {}\ndo_test randexpr-2.1078 {\n  db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and  -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when  -min(e) |  -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select  -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f)))}\n} {600}\ndo_test randexpr-2.1079 {\n  db eval {SELECT case 17 when (t1.d)*coalesce((select (select case (cast(avg(c) AS integer)+max(case when (not d+ -t1.e not between 11 and  -f) then f when b<(11) then t1.b else 11 end))+count(distinct t1.c)*max(b) when  -min(e) &  -count(distinct t1.c) then cast(avg(e) AS integer) else count(*) end from t1) from t1 where case c when a then a else t1.d end-11<>19),t1.a)+t1.b then f else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (abs(d)/abs((f*+coalesce((select  -~case when exists(select 1 from t1 where b<c) then t1.b else 17 end+case (select (min(coalesce((select b from t1 where 11<>t1.c or ((t1.c))<>e),(t1.e)))) from t1)*17 when e then a else t1.e end-t1.b-19 from t1 where t1.e in (select abs(+min(f)+cast(avg( -a) AS integer)) from t1 union select count(distinct c) from t1)),d))))<>f)))}\n} {600}\ndo_test randexpr-2.1080 {\n  db eval {SELECT ((select  -case min(17 | (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) | f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) | min(t1.f)+max(11)) then  -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE (13)-(t1.a*17-t1.b)-coalesce((select (select  -cast(avg(t1.c) AS integer)+case  - -count(*) | (count(distinct t1.a)) when  -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1)}\n} {}\ndo_test randexpr-2.1081 {\n  db eval {SELECT ((select  -case min(17 | (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) | f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) | min(t1.f)+max(11)) then  -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE NOT ((13)-(t1.a*17-t1.b)-coalesce((select (select  -cast(avg(t1.c) AS integer)+case  - -count(*) | (count(distinct t1.a)) when  -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1))}\n} {-20000}\ndo_test randexpr-2.1082 {\n  db eval {SELECT ((select  -case min(17 & (abs(a)/abs(case (select max(a) from t1)+13+t1.c when c then (abs(case when 17<>a and t1.c=d then ((17)) else e end)/abs(t1.b)) else 17 end)) & f*a) when abs(~(count(distinct t1.e))-abs((~max(c)))-count(*) & min(t1.f)+max(11)) then  -cast(avg((b)) AS integer) else min(b) end from t1))*a FROM t1 WHERE NOT ((13)-(t1.a*17-t1.b)-coalesce((select (select  -cast(avg(t1.c) AS integer)+case  - -count(*) | (count(distinct t1.a)) when  -min(t1.e) then (max(t1.d)) else count(distinct t1.b) end from t1)-e+(abs(17)/abs(e)) from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where (d)>=13 and (t1.b not in (c,a, -t1.d) or t1.e in (select c from t1 union select t1.c from t1)) or 11<=t1.d))),17) in (select e from t1 union select e from t1))}\n} {-20000}\ndo_test randexpr-2.1083 {\n  db eval {SELECT case when (select  -min(11) from t1)<>(abs(17)/abs(t1.d | e)) then case 11+case 11 when b | e-e then 19+e else b end*(abs(t1.a)/abs(b | a)) | coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select  - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE ~17 in (11,t1.c,19)}\n} {}\ndo_test randexpr-2.1084 {\n  db eval {SELECT case when (select  -min(11) from t1)<>(abs(17)/abs(t1.d | e)) then case 11+case 11 when b | e-e then 19+e else b end*(abs(t1.a)/abs(b | a)) | coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select  - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE NOT (~17 in (11,t1.c,19))}\n} {300}\ndo_test randexpr-2.1085 {\n  db eval {SELECT case when (select  -min(11) from t1)<>(abs(17)/abs(t1.d & e)) then case 11+case 11 when b & e-e then 19+e else b end*(abs(t1.a)/abs(b & a)) & coalesce((select case when a in (select cast(avg(d) AS integer) from t1 union select  - - -max(c) from t1) or e not in (c,d,a) then +13 when t1.a>a then 19 else f end from t1 where t1.c=13 or f<>t1.e),a) when f then f else c end else t1.e end FROM t1 WHERE NOT (~17 in (11,t1.c,19))}\n} {300}\ndo_test randexpr-2.1086 {\n  db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) | +max(f-t1.e*t1.e | (f)* -19+ -b*d) | count(*)*count(*)* -count(*) | ~count(distinct  -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE ((select  -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select  -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f))}\n} {}\ndo_test randexpr-2.1087 {\n  db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) | +max(f-t1.e*t1.e | (f)* -19+ -b*d) | count(*)*count(*)* -count(*) | ~count(distinct  -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE NOT (((select  -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select  -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f)))}\n} {-101}\ndo_test randexpr-2.1088 {\n  db eval {SELECT (select case +cast(avg(+19) AS integer) when (abs(count(*))) then (cast(avg(e*t1.b) AS integer)) else cast(avg(t1.a) AS integer) end+count(*) & +max(f-t1.e*t1.e & (f)* -19+ -b*d) & count(*)*count(*)* -count(*) & ~count(distinct  -b)*cast(avg(t1.f) AS integer)+count(*) from t1)-t1.c+t1.b FROM t1 WHERE NOT (((select  -count(*)+min(case ~coalesce((select max(d) from t1 where (not not exists(select 1 from t1 where t1.b not in ((select  -max(a)+(count(*)) from t1) | c+case when t1.e not in (13,e,c) then (t1.f) else t1.c end+17*c+19,c,e)))),t1.f) when (f) then t1.a else t1.f end | b | t1.a) from t1) in (c,t1.c+ -a,f)))}\n} {-36}\ndo_test randexpr-2.1089 {\n  db eval {SELECT (coalesce((select (select  -~+ -abs(case cast(avg(a*t1.d) AS integer) when case ~case count(distinct ((abs(t1.a)/abs(d)))) when case cast(avg(17) AS integer)-count(*) when  -count(*) then count(distinct d) else (max(t1.d)) end*count(*) then count(distinct t1.c) else min(19) end-count(*) when cast(avg(t1.a) AS integer) then ((count(*))) else min(a) end then (count(*)) else max(e) end)*(count(*))*max(a) from t1) from t1 where (19>=(17))),d)) FROM t1 WHERE exists(select 1 from t1 where 19 in (t1.a*coalesce((select a from t1 where (11<case a when (t1.e+c-t1.a) then t1.b else t1.c end) or d between +t1.e-+coalesce((select max(coalesce((select (select cast(avg((19)) AS integer) from t1) from t1 where t1.e>t1.b),t1.e)) from t1 where e not between 13 and t1.c),(a))-t1.d and 13),13*b)-17, -b,17))}\n} {}\ndo_test randexpr-2.1090 {\n  db eval {SELECT (coalesce((select (select  -~+ -abs(case cast(avg(a*t1.d) AS integer) when case ~case count(distinct ((abs(t1.a)/abs(d)))) when case cast(avg(17) AS integer)-count(*) when  -count(*) then count(distinct d) else (max(t1.d)) end*count(*) then count(distinct t1.c) else min(19) end-count(*) when cast(avg(t1.a) AS integer) then ((count(*))) else min(a) end then (count(*)) else max(e) end)*(count(*))*max(a) from t1) from t1 where (19>=(17))),d)) FROM t1 WHERE NOT (exists(select 1 from t1 where 19 in (t1.a*coalesce((select a from t1 where (11<case a when (t1.e+c-t1.a) then t1.b else t1.c end) or d between +t1.e-+coalesce((select max(coalesce((select (select cast(avg((19)) AS integer) from t1) from t1 where t1.e>t1.b),t1.e)) from t1 where e not between 13 and t1.c),(a))-t1.d and 13),13*b)-17, -b,17)))}\n} {-49900}\ndo_test randexpr-2.1091 {\n  db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end |  -13*t1.d*t1.c FROM t1 WHERE c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else  -count(*) end end+max(t1.c) from t1 union select  -count(*) from t1)}\n} {}\ndo_test randexpr-2.1092 {\n  db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end |  -13*t1.d*t1.c FROM t1 WHERE NOT (c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else  -count(*) end end+max(t1.c) from t1 union select  -count(*) from t1))}\n} {-1559700}\ndo_test randexpr-2.1093 {\n  db eval {SELECT case when (coalesce((select max((select +max(c) from t1)) from t1 where t1.c<>t1.a),d) not in (t1.d,+case when 17>19 then e when t1.b<>+(select count(*) from t1) then t1.e else t1.d end,t1.c)) then (select count(*)-count(distinct t1.d)+ -max( -t1.c-a)*case cast(avg((f)) AS integer) when count(distinct d) then max((13)) else max(t1.d) end from t1)*t1.b else t1.c end &  -13*t1.d*t1.c FROM t1 WHERE NOT (c in (select case count(distinct ~(abs( -a)/abs(d))) when ~count(*) then ~min(coalesce((select max((abs(e)/abs(d))) from t1 where not exists(select 1 from t1 where t1.e>( -+t1.a-t1.e*17))),19))+count(*) else case ~ -cast(avg((11)) AS integer) | +cast(avg(d) AS integer) | (cast(avg(c) AS integer))+min(t1.e) when min(t1.c) then max(11) else  -count(*) end end+max(t1.c) from t1 union select  -count(*) from t1))}\n} {0}\ndo_test randexpr-2.1094 {\n  db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) | 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then  -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) | f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select  -11 from t1))),t1.f) FROM t1 WHERE (((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then  -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select  -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select  -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else  -cast(avg(t1.d) AS integer) end from t1))))}\n} {}\ndo_test randexpr-2.1095 {\n  db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) | 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then  -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) | f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select  -11 from t1))),t1.f) FROM t1 WHERE NOT ((((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then  -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select  -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select  -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else  -cast(avg(t1.d) AS integer) end from t1)))))}\n} {511}\ndo_test randexpr-2.1096 {\n  db eval {SELECT coalesce((select max(t1.c+t1.b-t1.b+(abs(d++t1.f)/abs(t1.a)) & 13*17) from t1 where coalesce((select 11 from t1 where case case case c when d then t1.d else 13 end when b then  -11 else t1.b end when 13 then (t1.a) else d end not in (c,13,a)),t1.c) & f not in (t1.a,t1.c,13) and not exists(select 1 from t1 where t1.c in (select e from t1 union select  -11 from t1))),t1.f) FROM t1 WHERE NOT ((((13+coalesce((select max(13) from t1 where not exists(select 1 from t1 where ((abs(c-case when not exists(select 1 from t1 where ((f) between c and 13)) then (select case min(f) when max(17) then min(13) else min(b) end from t1) when 17 in (t1.e,13,f) then  -13 else 11 end)/abs(t1.f)) in (select min(c) from t1 union select  -count(*) | + -min(19) from t1))) and f<13),t1.e+t1.c) in (select count(distinct c)-count(*) from t1 union select  -case min((e))+cast(avg(t1.a) AS integer) when ((min(t1.c))) then count(distinct e) else  -cast(avg(t1.d) AS integer) end from t1)))))}\n} {20}\ndo_test randexpr-2.1097 {\n  db eval {SELECT case when t1.a in (select t1.e*case when t1.b between t1.d and 11 or c-case when (t1.e=13) then ~e when e<>a then t1.d else t1.f end in (11,t1.e,t1.c) and 11 not between t1.a and 13 and 19<11 then 11 else t1.e end*t1.d from t1 union select t1.c from t1) then a when e between e and b then ((19)) else 11 end FROM t1 WHERE coalesce((select (select count(distinct t1.f) from t1) from t1 where case coalesce((select max(t1.d) from t1 where 17<>19),t1.d) when a then coalesce((select ~t1.f- - -c-c*17-f-c-t1.a from t1 where (t1.f) in (select max(11) from t1 union select ~cast(avg(17) AS integer) | ~count(*)+max(f)- -cast(avg(11) AS integer) from t1)),13) else e end in (a,t1.c,11)),c)>=t1.e}\n} {}\ndo_test randexpr-2.1098 {\n  db eval {SELECT case when t1.a in (select t1.e*case when t1.b between t1.d and 11 or c-case when (t1.e=13) then ~e when e<>a then t1.d else t1.f end in (11,t1.e,t1.c) and 11 not between t1.a and 13 and 19<11 then 11 else t1.e end*t1.d from t1 union select t1.c from t1) then a when e between e and b then ((19)) else 11 end FROM t1 WHERE NOT (coalesce((select (select count(distinct t1.f) from t1) from t1 where case coalesce((select max(t1.d) from t1 where 17<>19),t1.d) when a then coalesce((select ~t1.f- - -c-c*17-f-c-t1.a from t1 where (t1.f) in (select max(11) from t1 union select ~cast(avg(17) AS integer) | ~count(*)+max(f)- -cast(avg(11) AS integer) from t1)),13) else e end in (a,t1.c,11)),c)>=t1.e)}\n} {11}\ndo_test randexpr-2.1099 {\n  db eval {SELECT coalesce((select max(case t1.b+(select ~((cast(avg(17) AS integer)))*min(a)+ -count(distinct b)*cast(avg(t1.b) AS integer)-count(*)+max(19) from t1)-(e) when d then 13 else 13*c end+t1.c) from t1 where t1.b in (select +cast(avg(e) AS integer)*case count(*) when cast(avg(13) AS integer) then count(distinct t1.b) else count(*) end-(count(distinct 19))*min(t1.d) from t1 union select max(a) from t1)),(f))*e+t1.f*19 FROM t1 WHERE 17 not between  -t1.e and d}\n} {}\ndo_test randexpr-2.1100 {\n  db eval {SELECT coalesce((select max(case t1.b+(select ~((cast(avg(17) AS integer)))*min(a)+ -count(distinct b)*cast(avg(t1.b) AS integer)-count(*)+max(19) from t1)-(e) when d then 13 else 13*c end+t1.c) from t1 where t1.b in (select +cast(avg(e) AS integer)*case count(*) when cast(avg(13) AS integer) then count(distinct t1.b) else count(*) end-(count(distinct 19))*min(t1.d) from t1 union select max(a) from t1)),(f))*e+t1.f*19 FROM t1 WHERE NOT (17 not between  -t1.e and d)}\n} {311400}\ndo_test randexpr-2.1101 {\n  db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) | (f)<>13), - -17)+c from t1 union select  -19 from t1)),17) FROM t1 WHERE ~t1.d not between 11*13-+t1.d-11-f and t1.d}\n} {}\ndo_test randexpr-2.1102 {\n  db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) | (f)<>13), - -17)+c from t1 union select  -19 from t1)),17) FROM t1 WHERE NOT (~t1.d not between 11*13-+t1.d-11-f and t1.d)}\n} {17}\ndo_test randexpr-2.1103 {\n  db eval {SELECT coalesce((select max(~19) from t1 where 11 in (select t1.b-11*coalesce((select max(b) from t1 where coalesce((select max(e) from t1 where c*case 19*19+coalesce((select 19 from t1 where (11 not in (13+t1.d,b,(11)))),13)*d when t1.e then t1.b else t1.b end+t1.e between d and t1.b),t1.b) & (f)<>13), - -17)+c from t1 union select  -19 from t1)),17) FROM t1 WHERE NOT (~t1.d not between 11*13-+t1.d-11-f and t1.d)}\n} {17}\ndo_test randexpr-2.1104 {\n  db eval {SELECT case t1.b when coalesce((select max(17+coalesce((select max(coalesce((select (select count(distinct case f when 19 then coalesce((select coalesce((select max(11-(abs(d)/abs(11))) from t1 where not  -a in (19,t1.b,17)),17) from t1 where (f in (b,f,t1.a))),b) else b end) from t1) from t1 where 17 between e and t1.f),t1.a)) from t1 where 13>=e),b)) from t1 where t1.f>t1.f),t1.b) then 17 else t1.f end FROM t1 WHERE not exists(select 1 from t1 where 13 between a+17 and (t1.c))}\n} {17}\ndo_test randexpr-2.1105 {\n  db eval {SELECT case t1.b when coalesce((select max(17+coalesce((select max(coalesce((select (select count(distinct case f when 19 then coalesce((select coalesce((select max(11-(abs(d)/abs(11))) from t1 where not  -a in (19,t1.b,17)),17) from t1 where (f in (b,f,t1.a))),b) else b end) from t1) from t1 where 17 between e and t1.f),t1.a)) from t1 where 13>=e),b)) from t1 where t1.f>t1.f),t1.b) then 17 else t1.f end FROM t1 WHERE NOT (not exists(select 1 from t1 where 13 between a+17 and (t1.c)))}\n} {}\ndo_test randexpr-2.1106 {\n  db eval {SELECT case when coalesce((select max(d) from t1 where t1.a in (select a-a from t1 union select a from t1)),t1.b)*(select max(t1.b) from t1)>=case when t1.b<case 17 when 19 then t1.a else t1.a end then b when 17<19 then t1.e else t1.b end and (t1.e=t1.c or (not exists(select 1 from t1 where not exists(select 1 from t1 where a=(13)))) or t1.b between 17 and t1.d and b in (t1.f,f,13) or t1.d<e) then t1.c when t1.c between 19 and 11 then d else a end FROM t1 WHERE t1.c>=t1.a}\n} {300}\ndo_test randexpr-2.1107 {\n  db eval {SELECT case when coalesce((select max(d) from t1 where t1.a in (select a-a from t1 union select a from t1)),t1.b)*(select max(t1.b) from t1)>=case when t1.b<case 17 when 19 then t1.a else t1.a end then b when 17<19 then t1.e else t1.b end and (t1.e=t1.c or (not exists(select 1 from t1 where not exists(select 1 from t1 where a=(13)))) or t1.b between 17 and t1.d and b in (t1.f,f,13) or t1.d<e) then t1.c when t1.c between 19 and 11 then d else a end FROM t1 WHERE NOT (t1.c>=t1.a)}\n} {}\ndo_test randexpr-2.1108 {\n  db eval {SELECT case when case when f*~case when t1.c*t1.f in (c,t1.b,(17)) then 17 when 11>t1.c then 13 else t1.e end+t1.f in (select +max(e)+case (count(distinct a)*count(*))+max(19) when  -max(11) then count(distinct a) else ((count(distinct t1.d))) end from t1 union select count(distinct c) from t1) then 17 else d end+(t1.c)<17 then b when not exists(select 1 from t1 where 11>t1.b) then t1.d else t1.a end FROM t1 WHERE t1.b< -f}\n} {}\ndo_test randexpr-2.1109 {\n  db eval {SELECT case when case when f*~case when t1.c*t1.f in (c,t1.b,(17)) then 17 when 11>t1.c then 13 else t1.e end+t1.f in (select +max(e)+case (count(distinct a)*count(*))+max(19) when  -max(11) then count(distinct a) else ((count(distinct t1.d))) end from t1 union select count(distinct c) from t1) then 17 else d end+(t1.c)<17 then b when not exists(select 1 from t1 where 11>t1.b) then t1.d else t1.a end FROM t1 WHERE NOT (t1.b< -f)}\n} {400}\ndo_test randexpr-2.1110 {\n  db eval {SELECT (select cast(avg(f) AS integer) | ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) |  -~(count(*))+max(17))+cast(avg(t1.a) AS integer) | min(a)*(count(*))*min(17) from t1) FROM t1 WHERE b-(t1.e*t1.e)-t1.d=t1.c}\n} {}\ndo_test randexpr-2.1111 {\n  db eval {SELECT (select cast(avg(f) AS integer) | ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) |  -~(count(*))+max(17))+cast(avg(t1.a) AS integer) | min(a)*(count(*))*min(17) from t1) FROM t1 WHERE NOT (b-(t1.e*t1.e)-t1.d=t1.c)}\n} {-260}\ndo_test randexpr-2.1112 {\n  db eval {SELECT (select cast(avg(f) AS integer) & ~++cast(avg((abs(17)/abs( -f+(c-coalesce((select case when c=d and t1.e=t1.b then e when e in (t1.b,19,t1.c) then 17 else d end from t1 where e between t1.a and t1.c),a))+a))) AS integer)-abs( -min(t1.c))-abs(max((t1.b)) &  -~(count(*))+max(17))+cast(avg(t1.a) AS integer) & min(a)*(count(*))*min(17) from t1) FROM t1 WHERE NOT (b-(t1.e*t1.e)-t1.d=t1.c)}\n} {512}\ndo_test randexpr-2.1113 {\n  db eval {SELECT ~+coalesce((select case when t1.f>d then b when (abs(t1.a)/abs((abs(f)/abs(t1.c))))*case ~b when e then (select cast(avg( -+t1.f) AS integer) from t1) else c end+coalesce((select max(17*case t1.a+b when t1.b then t1.d else t1.f end) from t1 where d=e),t1.f)+13>=17 then 19 else f end from t1 where t1.a in (select d from t1 union select e from t1)),b) FROM t1 WHERE 17<>f-~t1.a-case when  -b in (t1.b,(select min( -coalesce((select max(coalesce((select a- -t1.b from t1 where 11 in (t1.b,13, -t1.e) and f not between  -13 and t1.b),c)) from t1 where b not in (a,11,17)),t1.e)) from t1),e) or not exists(select 1 from t1 where t1.c in (select t1.b from t1 union select t1.b from t1)) then coalesce((select  -t1.e from t1 where e<>t1.e),f) when not t1.e<>t1.c then 19 else e end}\n} {-201}\ndo_test randexpr-2.1114 {\n  db eval {SELECT ~+coalesce((select case when t1.f>d then b when (abs(t1.a)/abs((abs(f)/abs(t1.c))))*case ~b when e then (select cast(avg( -+t1.f) AS integer) from t1) else c end+coalesce((select max(17*case t1.a+b when t1.b then t1.d else t1.f end) from t1 where d=e),t1.f)+13>=17 then 19 else f end from t1 where t1.a in (select d from t1 union select e from t1)),b) FROM t1 WHERE NOT (17<>f-~t1.a-case when  -b in (t1.b,(select min( -coalesce((select max(coalesce((select a- -t1.b from t1 where 11 in (t1.b,13, -t1.e) and f not between  -13 and t1.b),c)) from t1 where b not in (a,11,17)),t1.e)) from t1),e) or not exists(select 1 from t1 where t1.c in (select t1.b from t1 union select t1.b from t1)) then coalesce((select  -t1.e from t1 where e<>t1.e),f) when not t1.e<>t1.c then 19 else e end)}\n} {}\ndo_test randexpr-2.1115 {\n  db eval {SELECT d- -e*(abs(t1.c)/abs(d)) | t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and  -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not  -case when case 13 when +~(select case count(*) when  -max(t1.b) then max(a) else min(c) end from t1) then c else  -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19}\n} {-584}\ndo_test randexpr-2.1116 {\n  db eval {SELECT d- -e*(abs(t1.c)/abs(d)) | t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and  -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE NOT (b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not  -case when case 13 when +~(select case count(*) when  -max(t1.b) then max(a) else min(c) end from t1) then c else  -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19)}\n} {}\ndo_test randexpr-2.1117 {\n  db eval {SELECT d- -e*(abs(t1.c)/abs(d)) & t1.a+ -coalesce((select max(t1.e) from t1 where case when case when (a in (13,b,t1.b)) and d in (t1.c,17,a) then 17+t1.e when 19>=t1.b then a else 11 end=t1.f and d between c and (d) then (abs(17)/abs(d)) else t1.d end*f>e and not f<=13 and  -t1.f>=t1.e and t1.b<t1.b),t1.e)-case when t1.c<>e then t1.b else c end FROM t1 WHERE b-coalesce((select (coalesce((select max((coalesce((select d from t1 where not  -case when case 13 when +~(select case count(*) when  -max(t1.b) then max(a) else min(c) end from t1) then c else  -a end in (17,t1.b,(b)) then f else b end-f+17<=t1.a),t1.f)-d)) from t1 where t1.e=b),t1.b)) from t1 where (t1.a=t1.c)), -t1.a) not between 19 and 19}\n} {384}\ndo_test randexpr-2.1118 {\n  db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d | b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE 11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else  -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13)}\n} {-9281}\ndo_test randexpr-2.1119 {\n  db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d | b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE NOT (11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else  -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13))}\n} {}\ndo_test randexpr-2.1120 {\n  db eval {SELECT 19-case 13-f when b then t1.a*11-t1.d-+17*t1.b-coalesce((select 17 from t1 where 13<=f),+coalesce((select (abs(17+~coalesce((select a from t1 where 11<>t1.b and 11 not between t1.e and 19),17)+t1.e+t1.d & b)/abs(c))+f from t1 where 19 not between 19 and c),d)) else 19 end*t1.e+b FROM t1 WHERE 11+11 not in (t1.c,t1.e,19) and f+19*19*case when ~t1.a+19*b between t1.a-case case when f=(t1.d) then ((t1.d)) else  -d end*e when c then e else t1.a end*t1.e and c then t1.e else b end in (select d from t1 union select t1.a from t1) or t1.d>=t1.f or not exists(select 1 from t1 where a<=13)}\n} {-9281}\ndo_test randexpr-2.1121 {\n  db eval {SELECT case 19 when e then t1.b-t1.d else 11+coalesce((select 19 from t1 where not (t1.a)+(abs(case coalesce((select coalesce((select t1.e from t1 where 11=d),a) from t1 where t1.d<=13),a) when 17 then 13 else t1.a end)/abs(t1.b))-t1.d*e+t1.d not between b and b or e in (select  -min(c) from t1 union select min(t1.b) from t1)),(abs(e)/abs(t1.b)))+t1.c end FROM t1 WHERE exists(select 1 from t1 where c in (select t1.a from t1 union select f from t1))}\n} {}\ndo_test randexpr-2.1122 {\n  db eval {SELECT case 19 when e then t1.b-t1.d else 11+coalesce((select 19 from t1 where not (t1.a)+(abs(case coalesce((select coalesce((select t1.e from t1 where 11=d),a) from t1 where t1.d<=13),a) when 17 then 13 else t1.a end)/abs(t1.b))-t1.d*e+t1.d not between b and b or e in (select  -min(c) from t1 union select min(t1.b) from t1)),(abs(e)/abs(t1.b)))+t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where c in (select t1.a from t1 union select f from t1)))}\n} {313}\ndo_test randexpr-2.1123 {\n  db eval {SELECT 17 | t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then  -19 else  -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 | b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE (11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select  -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else  -a end not in (t1.c,b,t1.f))}\n} {-41}\ndo_test randexpr-2.1124 {\n  db eval {SELECT 17 | t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then  -19 else  -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 | b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE NOT ((11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select  -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else  -a end not in (t1.c,b,t1.f)))}\n} {}\ndo_test randexpr-2.1125 {\n  db eval {SELECT 17 & t1.d-(select +max(case when not exists(select 1 from t1 where (a<=t1.f)) then  -19 else  -t1.d end)- -min(t1.f+t1.f-(select (count(*)) from t1)) from t1)- -19 & b-d+coalesce((select max(d) from t1 where e-t1.a in (19,b,11) or e in (19,t1.b,c)),11) FROM t1 WHERE (11<=11 and case coalesce((select max((f)) from t1 where t1.b | case 11 when t1.e*t1.e then e else case when ~b-case when 19 not in (t1.d,13,e) then 13 when c between t1.e and b then 19 else t1.c end-(c) in (select  -t1.f from t1 union select d from t1) then c else t1.b end end*t1.a in (19,e,c)),t1.a) when t1.d then t1.a else  -a end not in (t1.c,b,t1.f))}\n} {0}\ndo_test randexpr-2.1126 {\n  db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a | a |  -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE c<17}\n} {}\ndo_test randexpr-2.1127 {\n  db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a | a |  -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE NOT (c<17)}\n} {100}\ndo_test randexpr-2.1128 {\n  db eval {SELECT case t1.e-d+b when coalesce((select (select max(t1.a & a &  -(select (count(*))+( - - -count(*)) from t1)*19+ -f+t1.e) from t1) from t1 where not exists(select 1 from t1 where (d not between a and 11) or not d>=11 and exists(select 1 from t1 where not t1.a<>13)) or 19 not in (17,t1.c,t1.c)),19)*t1.c+d then b else c end-b FROM t1 WHERE NOT (c<17)}\n} {100}\ndo_test randexpr-2.1129 {\n  db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and  -t1.c)),19)-19 in (select max(t1.e) | min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE (t1.a in ((t1.f-t1.c)+b,11,t1.a+f))}\n} {}\ndo_test randexpr-2.1130 {\n  db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and  -t1.c)),19)-19 in (select max(t1.e) | min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE NOT ((t1.a in ((t1.f-t1.c)+b,11,t1.a+f)))}\n} {0}\ndo_test randexpr-2.1131 {\n  db eval {SELECT f*f*(abs(case when (17-coalesce((select max(11) from t1 where coalesce((select max(t1.c-11*t1.a) from t1 where +e=(abs(d)/abs(11))+ -13),t1.b)<b and exists(select 1 from t1 where t1.f between d and  -t1.c)),19)-19 in (select max(t1.e) & min(t1.e) from t1 union select count(*) from t1) and 17>t1.e) then e else 17 end)/abs(c)) FROM t1 WHERE NOT ((t1.a in ((t1.f-t1.c)+b,11,t1.a+f)))}\n} {0}\ndo_test randexpr-2.1132 {\n  db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 |  -19-f then  -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then  -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) | b FROM t1 WHERE (~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case  -t1.b when 17 then 17 else  -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b}\n} {-771}\ndo_test randexpr-2.1133 {\n  db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 |  -19-f then  -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then  -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) | b FROM t1 WHERE NOT ((~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case  -t1.b when 17 then 17 else  -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b)}\n} {}\ndo_test randexpr-2.1134 {\n  db eval {SELECT ( -19-f+coalesce((select max( -~case when case 11 when ~coalesce((select max(13) from t1 where not (e)<>(t1.c)),19)+11 &  -19-f then  -13 else t1.c end-e<=t1.a then 11 when not exists(select 1 from t1 where (not t1.c<19) and not (13<>17)) then  -e else f end) from t1 where (b)<=t1.e),t1.d)+ -t1.c) & b FROM t1 WHERE (~(select (max(f)-count(distinct c)) from t1) | case when e>=t1.c then t1.b+(select abs(count(*)+max(c)*abs(count(distinct e)+max(t1.f))+cast(avg(c) AS integer)) | cast(avg(t1.d) AS integer)*min(11) from t1)-t1.c else c end in (select case  -t1.b when 17 then 17 else  -case when not t1.c not in (17,t1.d,17) then 19 else a end end from t1 union select a from t1)) or (11)<=t1.b}\n} {64}\ndo_test randexpr-2.1135 {\n  db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end |  -(t1.e) | 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) | 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17}\n} {}\ndo_test randexpr-2.1136 {\n  db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end |  -(t1.e) | 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) | 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE NOT (not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17)}\n} {500}\ndo_test randexpr-2.1137 {\n  db eval {SELECT +case when (not exists(select 1 from t1 where (abs(t1.a+coalesce((select max(b+ -case when e=t1.f then (abs(d)/abs(t1.e)) when not exists(select 1 from t1 where 17<t1.c) then d else f end &  -(t1.e) & 13*e) from t1 where f in (select t1.e from t1 union select t1.f from t1)),d) & 11)/abs(t1.b))-b not between b and t1.d) and t1.d>t1.c) then e else e end FROM t1 WHERE NOT (not t1.d-d+case b when t1.a+t1.a then t1.f+ -t1.e else 11+b*coalesce((select max(t1.f) from t1 where 11>= -f+t1.d),t1.c)*19 end not between d and t1.c-(11)+17)}\n} {500}\ndo_test randexpr-2.1138 {\n  db eval {SELECT t1.d+case when (t1.a)<=11 then ~t1.a else ~19 end-+~ -coalesce((select t1.d from t1 where ~t1.f in (select (cast(avg(t1.e+c) AS integer)) from t1 union select count(distinct (abs(coalesce((select max(19) from t1 where not ~11-t1.a=t1.c+case when t1.d between c and t1.d then 11 when t1.f>=17 then f else 19 end*t1.c),17)+f)/abs(f))) from t1)),11) FROM t1 WHERE e>c}\n} {370}\ndo_test randexpr-2.1139 {\n  db eval {SELECT t1.d+case when (t1.a)<=11 then ~t1.a else ~19 end-+~ -coalesce((select t1.d from t1 where ~t1.f in (select (cast(avg(t1.e+c) AS integer)) from t1 union select count(distinct (abs(coalesce((select max(19) from t1 where not ~11-t1.a=t1.c+case when t1.d between c and t1.d then 11 when t1.f>=17 then f else 19 end*t1.c),17)+f)/abs(f))) from t1)),11) FROM t1 WHERE NOT (e>c)}\n} {}\ndo_test randexpr-2.1140 {\n  db eval {SELECT case when coalesce((select max(case b | d*(abs(t1.e)/abs(a))-f | t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end | 11+e-17*19 FROM t1 WHERE d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b)}\n} {}\ndo_test randexpr-2.1141 {\n  db eval {SELECT case when coalesce((select max(case b | d*(abs(t1.e)/abs(a))-f | t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end | 11+e-17*19 FROM t1 WHERE NOT (d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b))}\n} {191}\ndo_test randexpr-2.1142 {\n  db eval {SELECT case when coalesce((select max(case b & d*(abs(t1.e)/abs(a))-f & t1.b when t1.e then coalesce((select max(t1.e) from t1 where t1.e between (select ~count(*)*cast(avg(19) AS integer) from t1) and case c when a then 13 else a end),t1.f)+e*c else t1.d end) from t1 where t1.a in (select t1.d from t1 union select 17 from t1)),e)+17<19 then t1.a else 19 end & 11+e-17*19 FROM t1 WHERE NOT (d*t1.c-case when case when ((13 in (17+e,b,11)) or 19>(13)) then (abs(coalesce((select t1.a from t1 where t1.a not in (13,c,t1.f)),11))/abs(t1.e))-f when t1.b not between t1.b and f then t1.d else t1.a end in (a,e,t1.d) then t1.f else t1.f end+f+t1.e in (t1.d,e,b))}\n} {16}\ndo_test randexpr-2.1143 {\n  db eval {SELECT ((select (count(*) | +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) | ~max(t1.f) then count(distinct t1.f) | ~count(distinct t1.d) else count(*) end then min(t1.c) else  -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE (a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c))}\n} {511}\ndo_test randexpr-2.1144 {\n  db eval {SELECT ((select (count(*) | +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) | ~max(t1.f) then count(distinct t1.f) | ~count(distinct t1.d) else count(*) end then min(t1.c) else  -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE NOT ((a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c)))}\n} {}\ndo_test randexpr-2.1145 {\n  db eval {SELECT ((select (count(*) & +~(case ++(min(t1.f+17+(11-case when b between d and d and t1.a not in (13,c,t1.c) and e< -t1.b then 17+(11) else t1.e end+ -b))) when case min(e) when min( -13) & ~max(t1.f) then count(distinct t1.f) & ~count(distinct t1.d) else count(*) end then min(t1.c) else  -cast(avg(11) AS integer) end)+count(distinct (f))) from t1)+e) FROM t1 WHERE (a in (11*a-t1.a | t1.b+e*13,(f | a | (select min((select min(13)-min(17)*((count(distinct t1.d))) from t1)) from t1)+t1.a- -11)+(11),t1.c) and (a) between t1.d and t1.f or t1.d not between t1.c and f or d not in (t1.c,t1.f,c))}\n} {501}\ndo_test randexpr-2.1146 {\n  db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and  -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when  -a | t1.e*19 then t1.a else  -t1.c end then  -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE c in (select (t1.a) from t1 union select e from t1)}\n} {}\ndo_test randexpr-2.1147 {\n  db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and  -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when  -a | t1.e*19 then t1.a else  -t1.c end then  -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE NOT (c in (select (t1.a) from t1 union select e from t1))}\n} {600}\ndo_test randexpr-2.1148 {\n  db eval {SELECT coalesce((select max(13) from t1 where d in (select (max(19)*count(distinct case when t1.f between ~e and  -b-t1.f then b else d end)-count(distinct f)) from t1 union select cast(avg(case e when case t1.b when  -a & t1.e*19 then t1.a else  -t1.c end then  -d else t1.e end) AS integer) from t1)),case when t1.d in (select t1.e from t1 union select b from t1) then t1.f when t1.f between 13 and f then f else f end) FROM t1 WHERE NOT (c in (select (t1.a) from t1 union select e from t1))}\n} {600}\ndo_test randexpr-2.1149 {\n  db eval {SELECT (abs(t1.d+b)/abs(~t1.f+case when t1.f=t1.c or exists(select 1 from t1 where c>=+~t1.c*17) or exists(select 1 from t1 where (select  -cast(avg(case when 19<>t1.f then  -c when c<>b then t1.e else t1.d end) AS integer) from t1) in (d-t1.f,b,19)) then d+b when 11<b then t1.c else d end* -t1.a-19)) FROM t1 WHERE t1.a-(select cast(avg(a) AS integer) from t1) in (select t1.c from t1 union select 19 from t1) and not exists(select 1 from t1 where coalesce((select max(11) from t1 where case when not d>(19) then c else  -case when 11>b or t1.c<=c then f when t1.f>t1.a then t1.a else t1.e end*d-11 end+d*t1.b>t1.e),d)>t1.b and c<>d and not exists(select 1 from t1 where 17>=(t1.f)) and t1.e not in (f,t1.b,t1.b))}\n} {}\ndo_test randexpr-2.1150 {\n  db eval {SELECT (abs(t1.d+b)/abs(~t1.f+case when t1.f=t1.c or exists(select 1 from t1 where c>=+~t1.c*17) or exists(select 1 from t1 where (select  -cast(avg(case when 19<>t1.f then  -c when c<>b then t1.e else t1.d end) AS integer) from t1) in (d-t1.f,b,19)) then d+b when 11<b then t1.c else d end* -t1.a-19)) FROM t1 WHERE NOT (t1.a-(select cast(avg(a) AS integer) from t1) in (select t1.c from t1 union select 19 from t1) and not exists(select 1 from t1 where coalesce((select max(11) from t1 where case when not d>(19) then c else  -case when 11>b or t1.c<=c then f when t1.f>t1.a then t1.a else t1.e end*d-11 end+d*t1.b>t1.e),d)>t1.b and c<>d and not exists(select 1 from t1 where 17>=(t1.f)) and t1.e not in (f,t1.b,t1.b)))}\n} {0}\ndo_test randexpr-2.1151 {\n  db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select  -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select  -min(19)+cast(avg(t1.d) AS integer) from t1) else d end | 17 | t1.e FROM t1 WHERE c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17}\n} {}\ndo_test randexpr-2.1152 {\n  db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select  -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select  -min(19)+cast(avg(t1.d) AS integer) from t1) else d end | 17 | t1.e FROM t1 WHERE NOT (c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17)}\n} {1021}\ndo_test randexpr-2.1153 {\n  db eval {SELECT t1.b-~case when +a in (select ~min(11) from t1 union select  -count(*)+count(distinct ~coalesce((select coalesce((select t1.b-19+c from t1 where a<>13 or 13 in (t1.b,d,t1.e)),11) from t1 where 19 in (19,e,17)),e)) from t1) then (select  -min(19)+cast(avg(t1.d) AS integer) from t1) else d end & 17 & t1.e FROM t1 WHERE NOT (c-b+e*11+(c+13+11)+(13)+(select cast(avg((abs(e-d+a)/abs(t1.f))) AS integer) from t1)-t1.d+~13<=t1.e-c-17)}\n} {16}\ndo_test randexpr-2.1154 {\n  db eval {SELECT coalesce((select max(b) from t1 where t1.e<t1.b-11*case when ( -c*case d when case +t1.c+t1.b when ~11*(select count(distinct d) from t1) then a else t1.d end then t1.b else (abs((select max(+coalesce((select (t1.d) from t1 where 19 not between t1.b and t1.a and t1.d between 19 and  -13),t1.a)) from t1))/abs(f)) end)<>t1.e then 17 when 19 not between 11 and b then t1.e else 19 end*t1.c),t1.c) FROM t1 WHERE not t1.f*(abs(case when ~19-17*e>=t1.d then t1.b when (select cast(avg(t1.e) AS integer) from t1) in ((abs(t1.e)/abs(t1.e))-case when f not in (t1.d,13,c) then c else t1.e end-t1.b-t1.a | b-(t1.c), -a,e) then t1.e else e end+a)/abs(t1.d)) | b not between b and t1.d}\n} {}\ndo_test randexpr-2.1155 {\n  db eval {SELECT coalesce((select max(b) from t1 where t1.e<t1.b-11*case when ( -c*case d when case +t1.c+t1.b when ~11*(select count(distinct d) from t1) then a else t1.d end then t1.b else (abs((select max(+coalesce((select (t1.d) from t1 where 19 not between t1.b and t1.a and t1.d between 19 and  -13),t1.a)) from t1))/abs(f)) end)<>t1.e then 17 when 19 not between 11 and b then t1.e else 19 end*t1.c),t1.c) FROM t1 WHERE NOT (not t1.f*(abs(case when ~19-17*e>=t1.d then t1.b when (select cast(avg(t1.e) AS integer) from t1) in ((abs(t1.e)/abs(t1.e))-case when f not in (t1.d,13,c) then c else t1.e end-t1.b-t1.a | b-(t1.c), -a,e) then t1.e else e end+a)/abs(t1.d)) | b not between b and t1.d)}\n} {300}\ndo_test randexpr-2.1156 {\n  db eval {SELECT  -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end | t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then  -c else 19 end+17) FROM t1 WHERE not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else  -c end-c<>t1.b)}\n} {-883}\ndo_test randexpr-2.1157 {\n  db eval {SELECT  -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end | t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then  -c else 19 end+17) FROM t1 WHERE NOT (not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else  -c end-c<>t1.b))}\n} {}\ndo_test randexpr-2.1158 {\n  db eval {SELECT  -f+( - -case when 13-b not between case when (a<>t1.f or case when not exists(select 1 from t1 where 11<>t1.a) then b when c<=t1.b then t1.f else 11 end in (select 17 from t1 union select t1.b from t1)) then b-c-b when t1.f=13 then a else 19 end & t1.d and t1.e and not exists(select 1 from t1 where 19=t1.f) then  -c else 19 end+17) FROM t1 WHERE not not exists(select 1 from t1 where ~(select cast(avg(t1.d) AS integer) from t1) | +~~case case when f-case when exists(select 1 from t1 where 13 not in (d,11,case when not exists(select 1 from t1 where f between t1.d and e) then 13 when t1.e<>19 then f else 11 end) or b in ( -d,t1.c,17)) then b else f end-(t1.d) in (t1.c,t1.c,b) then t1.b else e end when 11 then t1.e else  -c end-c<>t1.b)}\n} {-883}\ndo_test randexpr-2.1159 {\n  db eval {SELECT +(abs(d+d+a+b+t1.d)/abs(coalesce((select (select abs(cast(avg(17-11+e*t1.d) AS integer)++cast(avg(coalesce((select max(11-+t1.f- -e-a* -19+t1.a) from t1 where  -a in (select 11 from t1 union select  -11 from t1)),e)) AS integer)) from t1) from t1 where f=17),t1.b)*a)) FROM t1 WHERE t1.b in (select t1.e from t1 union select coalesce((select max(11) from t1 where d<t1.f),f) from t1)}\n} {}\ndo_test randexpr-2.1160 {\n  db eval {SELECT +(abs(d+d+a+b+t1.d)/abs(coalesce((select (select abs(cast(avg(17-11+e*t1.d) AS integer)++cast(avg(coalesce((select max(11-+t1.f- -e-a* -19+t1.a) from t1 where  -a in (select 11 from t1 union select  -11 from t1)),e)) AS integer)) from t1) from t1 where f=17),t1.b)*a)) FROM t1 WHERE NOT (t1.b in (select t1.e from t1 union select coalesce((select max(11) from t1 where d<t1.f),f) from t1))}\n} {0}\ndo_test randexpr-2.1161 {\n  db eval {SELECT case when t1.b*t1.c=coalesce((select t1.f from t1 where case when exists(select 1 from t1 where t1.d in (select e from t1 union select 19 from t1)) or t1.e>t1.e then t1.a+e-a when 19>t1.c then c else t1.c end+c not between b and t1.d),t1.f) and  -(t1.b) between t1.e and  -t1.d or b<>19 then (select ~(min(13))+max(f) from t1) else (t1.b) end*t1.b FROM t1 WHERE b in (b,e,case coalesce((select max(t1.b) from t1 where e>13 or ( -(select case  -~count(distinct 17)-cast(avg((t1.f)) AS integer)*cast(avg(d) AS integer) when  -cast(avg(f) AS integer) then max(17) else  -(count(*)) end from t1)-(coalesce((select (b) from t1 where t1.b>=t1.e),t1.c)) in (17,t1.e,b)) or (exists(select 1 from t1 where (t1.d=(d))))),t1.c) when b then c else (e) end)}\n} {117200}\ndo_test randexpr-2.1162 {\n  db eval {SELECT case when t1.b*t1.c=coalesce((select t1.f from t1 where case when exists(select 1 from t1 where t1.d in (select e from t1 union select 19 from t1)) or t1.e>t1.e then t1.a+e-a when 19>t1.c then c else t1.c end+c not between b and t1.d),t1.f) and  -(t1.b) between t1.e and  -t1.d or b<>19 then (select ~(min(13))+max(f) from t1) else (t1.b) end*t1.b FROM t1 WHERE NOT (b in (b,e,case coalesce((select max(t1.b) from t1 where e>13 or ( -(select case  -~count(distinct 17)-cast(avg((t1.f)) AS integer)*cast(avg(d) AS integer) when  -cast(avg(f) AS integer) then max(17) else  -(count(*)) end from t1)-(coalesce((select (b) from t1 where t1.b>=t1.e),t1.c)) in (17,t1.e,b)) or (exists(select 1 from t1 where (t1.d=(d))))),t1.c) when b then c else (e) end))}\n} {}\ndo_test randexpr-2.1163 {\n  db eval {SELECT +t1.c+case when t1.e not in ((e)-(case when 17<11 then 19 when (t1.d in (d,coalesce((select max(t1.a) from t1 where not b<>t1.b),case t1.b when coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where e not in (t1.f,11,17))),(19))*t1.f then c else t1.c end+ -t1.d)-t1.b+t1.e,d)) then 19 else b end)-e,t1.c, -13) then e else 17 end FROM t1 WHERE t1.e*t1.b | t1.b<>17*+coalesce((select max(t1.b) from t1 where case when coalesce((select max(b) from t1 where case when (b between 17 and d) then t1.f when t1.c between b and t1.a then t1.e else t1.a end not in (11,19,13)),11) in (t1.d,17,17) then t1.f when d<>13 then 11 else t1.a end+a<17),t1.a)-17+t1.f*d-a}\n} {800}\ndo_test randexpr-2.1164 {\n  db eval {SELECT +t1.c+case when t1.e not in ((e)-(case when 17<11 then 19 when (t1.d in (d,coalesce((select max(t1.a) from t1 where not b<>t1.b),case t1.b when coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where e not in (t1.f,11,17))),(19))*t1.f then c else t1.c end+ -t1.d)-t1.b+t1.e,d)) then 19 else b end)-e,t1.c, -13) then e else 17 end FROM t1 WHERE NOT (t1.e*t1.b | t1.b<>17*+coalesce((select max(t1.b) from t1 where case when coalesce((select max(b) from t1 where case when (b between 17 and d) then t1.f when t1.c between b and t1.a then t1.e else t1.a end not in (11,19,13)),11) in (t1.d,17,17) then t1.f when d<>13 then 11 else t1.a end+a<17),t1.a)-17+t1.f*d-a)}\n} {}\ndo_test randexpr-2.1165 {\n  db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end | 11 when (select ~~+min(t1.e) from t1) then t1.c else  -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE (f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f)}\n} {}\ndo_test randexpr-2.1166 {\n  db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end | 11 when (select ~~+min(t1.e) from t1) then t1.c else  -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE NOT ((f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f))}\n} {11}\ndo_test randexpr-2.1167 {\n  db eval {SELECT 11+case when case case f when (abs(t1.a)/abs(19))+t1.e then (abs(19)/abs(b+e)) else 13 end & 11 when (select ~~+min(t1.e) from t1) then t1.c else  -e end<>case t1.a when 17 then case when (c not between 19 and t1.b) and t1.b<>t1.d then coalesce((select a from t1 where t1.d in (t1.e,t1.f,f)),t1.e) else 13 end else d end or t1.c<t1.d then t1.f else 17 end-f FROM t1 WHERE NOT ((f*c*coalesce((select e from t1 where (exists(select 1 from t1 where +t1.e<= -e | t1.f))),a)+b in (select t1.c from t1 union select c from t1) or (t1.e between b and (19)) and 13 between t1.e and 13 and 11 in (13,t1.c,17) and exists(select 1 from t1 where t1.d in (select count(*)-max(e)-((max((11)))) from t1 union select max(17) from t1)) and c>f))}\n} {11}\ndo_test randexpr-2.1168 {\n  db eval {SELECT d-case when ~c<>case when not exists(select 1 from t1 where  -t1.b<>19) then coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where (t1.c in (select ~~+~max(~case when 13 not between t1.d and t1.d or c between c and f then t1.f else t1.a end)*abs(count(*)+(min( -t1.e))) from t1 union select cast(avg(e) AS integer) from t1) and (abs(t1.f*f-t1.a)/abs(d))>t1.b)) and (17) not in ( -t1.f,13,17)),19) else a end then b else f end FROM t1 WHERE f=(select case ~ -~count(distinct t1.b)+count(distinct d) |  -count(distinct t1.e)*count(*)* -cast(avg(b) AS integer)*(cast(avg(13) AS integer)) when  -min(19) then min(t1.e) else ((cast(avg(17) AS integer))) end from t1) or 19>=(19) and not exists(select 1 from t1 where (select count(*) from t1)*t1.d not between 19+11 and d) and  -t1.e not in (e,t1.a, -a) and t1.e between t1.f and (t1.b) or c in ( -11,17,t1.c) or t1.a in (a,11,t1.d)}\n} {200}\ndo_test randexpr-2.1169 {\n  db eval {SELECT d-case when ~c<>case when not exists(select 1 from t1 where  -t1.b<>19) then coalesce((select max(t1.f) from t1 where exists(select 1 from t1 where (t1.c in (select ~~+~max(~case when 13 not between t1.d and t1.d or c between c and f then t1.f else t1.a end)*abs(count(*)+(min( -t1.e))) from t1 union select cast(avg(e) AS integer) from t1) and (abs(t1.f*f-t1.a)/abs(d))>t1.b)) and (17) not in ( -t1.f,13,17)),19) else a end then b else f end FROM t1 WHERE NOT (f=(select case ~ -~count(distinct t1.b)+count(distinct d) |  -count(distinct t1.e)*count(*)* -cast(avg(b) AS integer)*(cast(avg(13) AS integer)) when  -min(19) then min(t1.e) else ((cast(avg(17) AS integer))) end from t1) or 19>=(19) and not exists(select 1 from t1 where (select count(*) from t1)*t1.d not between 19+11 and d) and  -t1.e not in (e,t1.a, -a) and t1.e between t1.f and (t1.b) or c in ( -11,17,t1.c) or t1.a in (a,11,t1.d))}\n} {}\ndo_test randexpr-2.1170 {\n  db eval {SELECT case when a in (select t1.b from t1 union select coalesce((select ~19 from t1 where e>13*t1.d or c in (select b from t1 union select case a*t1.f when e then (t1.c) else (t1.b) end from t1)),t1.a) from t1) and t1.d>b or not exists(select 1 from t1 where t1.e in (select count(*)*min(t1.b)*~count(*) from t1 union select case  -min((19)) when  -max(b) then (min(t1.a)) else (count(distinct t1.d)) end from t1)) then (t1.c) when exists(select 1 from t1 where f not between 19 and f) then 19 else t1.c end-a FROM t1 WHERE a=coalesce((select f from t1 where t1.c in (11,(abs(coalesce((select max(t1.d) from t1 where (abs(t1.c | 13)/abs(11)) not in (b+case when coalesce((select max(b) from t1 where 11 between d and t1.a),b)<a then 19 when (e) not in (t1.e,13,t1.d) then t1.c else  - -t1.e end-19,a,17)),19))/abs(t1.a)),t1.b) or (((13)>=t1.b))),c) and f between 19 and t1.d or c>(f)}\n} {}\ndo_test randexpr-2.1171 {\n  db eval {SELECT case when a in (select t1.b from t1 union select coalesce((select ~19 from t1 where e>13*t1.d or c in (select b from t1 union select case a*t1.f when e then (t1.c) else (t1.b) end from t1)),t1.a) from t1) and t1.d>b or not exists(select 1 from t1 where t1.e in (select count(*)*min(t1.b)*~count(*) from t1 union select case  -min((19)) when  -max(b) then (min(t1.a)) else (count(distinct t1.d)) end from t1)) then (t1.c) when exists(select 1 from t1 where f not between 19 and f) then 19 else t1.c end-a FROM t1 WHERE NOT (a=coalesce((select f from t1 where t1.c in (11,(abs(coalesce((select max(t1.d) from t1 where (abs(t1.c | 13)/abs(11)) not in (b+case when coalesce((select max(b) from t1 where 11 between d and t1.a),b)<a then 19 when (e) not in (t1.e,13,t1.d) then t1.c else  - -t1.e end-19,a,17)),19))/abs(t1.a)),t1.b) or (((13)>=t1.b))),c) and f between 19 and t1.d or c>(f))}\n} {200}\ndo_test randexpr-2.1172 {\n  db eval {SELECT case when  -(t1.f)- -case when t1.e not in ((t1.d)+a-t1.a,t1.c, - -a) then t1.b when (not exists(select 1 from t1 where t1.d>= -t1.f)) then  -19 else f end-t1.f in (select cast(avg(19) AS integer)*case count(*) when abs((++min( -11))*max(13)-count(distinct 13)) then min(t1.a) else count(distinct 17) end from t1 union select count(distinct t1.a) from t1) then t1.c when b not between t1.f and 13 then e else t1.a end FROM t1 WHERE 11 not between ~17+d and ~case when t1.b in (c*((abs(case 13 when  -(select abs(count(distinct coalesce((select max(coalesce((select t1.b from t1 where not exists(select 1 from t1 where (t1.c) in (t1.a,e,13))),t1.d)) from t1 where not t1.d>c),b))) from t1) then t1.f else t1.b end- -t1.c)/abs(c))+a),t1.d,t1.a) then (t1.c) else (d) end-13 or  -t1.a in (17,a,f)}\n} {500}\ndo_test randexpr-2.1173 {\n  db eval {SELECT case when  -(t1.f)- -case when t1.e not in ((t1.d)+a-t1.a,t1.c, - -a) then t1.b when (not exists(select 1 from t1 where t1.d>= -t1.f)) then  -19 else f end-t1.f in (select cast(avg(19) AS integer)*case count(*) when abs((++min( -11))*max(13)-count(distinct 13)) then min(t1.a) else count(distinct 17) end from t1 union select count(distinct t1.a) from t1) then t1.c when b not between t1.f and 13 then e else t1.a end FROM t1 WHERE NOT (11 not between ~17+d and ~case when t1.b in (c*((abs(case 13 when  -(select abs(count(distinct coalesce((select max(coalesce((select t1.b from t1 where not exists(select 1 from t1 where (t1.c) in (t1.a,e,13))),t1.d)) from t1 where not t1.d>c),b))) from t1) then t1.f else t1.b end- -t1.c)/abs(c))+a),t1.d,t1.a) then (t1.c) else (d) end-13 or  -t1.a in (17,a,f))}\n} {}\ndo_test randexpr-2.1174 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end | count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1)}\n} {}\ndo_test randexpr-2.1175 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end | count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE NOT (t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1))}\n} {500}\ndo_test randexpr-2.1176 {\n  db eval {SELECT coalesce((select 17 from t1 where not exists(select 1 from t1 where (t1.b- -b+(select +case max(b)-~count(distinct e*(select case max(c) when abs((count(*))) then max(t1.f) else max(t1.c) end+cast(avg(t1.b) AS integer) from t1)) when abs(count(distinct e*19)) then max(b) else max(t1.c) end & count(distinct t1.e) from t1)-b*+t1.b not in ((11),17,13)))),t1.e) FROM t1 WHERE NOT (t1.c in (select min(coalesce((select 17 from t1 where t1.c | 17>=(abs(t1.a)/abs(case when t1.e not in (19,t1.d,19) then a when 13<=case when not exists(select 1 from t1 where (abs(e)/abs(t1.c)) in (select 19 from t1 union select d from t1) and t1.c>=17 or 19=t1.a) then f else a end then t1.d else e end))-f),e))*min(f) | ++min(a) from t1 union select cast(avg(f) AS integer) from t1))}\n} {500}\ndo_test randexpr-2.1177 {\n  db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 | b | t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and  -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then  -c else t1.b end FROM t1 WHERE (exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else  -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or  -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d}\n} {}\ndo_test randexpr-2.1178 {\n  db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 | b | t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and  -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then  -c else t1.b end FROM t1 WHERE NOT ((exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else  -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or  -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d)}\n} {200}\ndo_test randexpr-2.1179 {\n  db eval {SELECT case coalesce((select t1.e from t1 where +coalesce((select a from t1 where 13 & b & t1.b<=11*a*case when exists(select 1 from t1 where (a-t1.d+t1.e-f<17 and  -17 between 19 and a)) then c when 17 between f and t1.c then a*11 else t1.d end),t1.e) not in (b,t1.f,t1.d)),a) when c then  -c else t1.b end FROM t1 WHERE NOT ((exists(select 1 from t1 where case when not exists(select 1 from t1 where (select cast(avg(d) AS integer) from t1) in (select a from t1 union select case case when t1.e>t1.d or t1.b in (select c from t1 union select e from t1) or t1.a>=f and b>=11 then t1.c-(t1.c)*19 when b not in (e,c,t1.d) then t1.b else t1.c end when 13 then f else  -t1.f end from t1)) then 17 when not exists(select 1 from t1 where not exists(select 1 from t1 where f not in (t1.d,f, -t1.b)) or  -19<=t1.c) or t1.e between 13 and t1.a then f else d end<>t1.f) and f between 11 and t1.c and t1.e not in (t1.d,c,t1.e)) or d not between t1.b and t1.d)}\n} {200}\ndo_test randexpr-2.1180 {\n  db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case  - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) | d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and  -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1))}\n} {120000}\ndo_test randexpr-2.1181 {\n  db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case  - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) | d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and  -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE NOT (not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1)))}\n} {}\ndo_test randexpr-2.1182 {\n  db eval {SELECT case when exists(select 1 from t1 where b<>coalesce((select (select + - -count(*)-~count(*)+~+case  - -count(distinct (t1.d)) when max(t1.d) then count(*) else max(a) end+(cast(avg(17) AS integer)) from t1) & d from t1 where not exists(select 1 from t1 where (abs(f)/abs(t1.c)) between 13+a and  -t1.d)),19) or (coalesce((select t1.d from t1 where (( - -19)>a)),t1.f) in (e,e,t1.e))) then t1.b*t1.f when t1.d not between (a) and a then e else b end FROM t1 WHERE not exists(select 1 from t1 where a in (select 13 from t1 union select 17 from t1))}\n} {120000}\ndo_test randexpr-2.1183 {\n  db eval {SELECT coalesce((select case when f>17-t1.f then (select +max(coalesce((select +11 from t1 where coalesce((select max(d) from t1 where +t1.c between (f) and c),t1.f) not in (c, -f,t1.e)),d)) from t1) else 17+19 end from t1 where not not exists(select 1 from t1 where t1.a in (select a from t1 union select t1.a from t1) and 17=d or (17)<=(( -19)) and t1.f in (select d from t1 union select 13 from t1) or 19>13 or t1.b not in (t1.b,17,d))), -(t1.c)) FROM t1 WHERE +t1.a-13+(select count(distinct a) from t1)-e*e*case when coalesce((select max(coalesce((select a from t1 where ((case b+t1.c-t1.c*d*17 when t1.a then t1.a else f end<>c))),t1.b+13)) from t1 where t1.f between 17 and t1.d),t1.c)<=(b) then f else t1.e end-13<>t1.f}\n} {11}\ndo_test randexpr-2.1184 {\n  db eval {SELECT coalesce((select case when f>17-t1.f then (select +max(coalesce((select +11 from t1 where coalesce((select max(d) from t1 where +t1.c between (f) and c),t1.f) not in (c, -f,t1.e)),d)) from t1) else 17+19 end from t1 where not not exists(select 1 from t1 where t1.a in (select a from t1 union select t1.a from t1) and 17=d or (17)<=(( -19)) and t1.f in (select d from t1 union select 13 from t1) or 19>13 or t1.b not in (t1.b,17,d))), -(t1.c)) FROM t1 WHERE NOT (+t1.a-13+(select count(distinct a) from t1)-e*e*case when coalesce((select max(coalesce((select a from t1 where ((case b+t1.c-t1.c*d*17 when t1.a then t1.a else f end<>c))),t1.b+13)) from t1 where t1.f between 17 and t1.d),t1.c)<=(b) then f else t1.e end-13<>t1.f)}\n} {}\ndo_test randexpr-2.1185 {\n  db eval {SELECT coalesce((select 13 from t1 where ~(select max(b) from t1)<= -+d*f+t1.b*f or coalesce((select max(case when d=(abs(19)/abs(t1.f)) then case b+d when (abs(coalesce((select 11 from t1 where t1.f between  -d and c),t1.f))/abs(t1.a)) then b else t1.d end when a<t1.d then 13 else 11 end) from t1 where a not between t1.e and b),t1.d)>=t1.e),17)+ -c FROM t1 WHERE t1.b-+(t1.b) in (select a from t1 union select 19 from t1)}\n} {}\ndo_test randexpr-2.1186 {\n  db eval {SELECT coalesce((select 13 from t1 where ~(select max(b) from t1)<= -+d*f+t1.b*f or coalesce((select max(case when d=(abs(19)/abs(t1.f)) then case b+d when (abs(coalesce((select 11 from t1 where t1.f between  -d and c),t1.f))/abs(t1.a)) then b else t1.d end when a<t1.d then 13 else 11 end) from t1 where a not between t1.e and b),t1.d)>=t1.e),17)+ -c FROM t1 WHERE NOT (t1.b-+(t1.b) in (select a from t1 union select 19 from t1))}\n} {-283}\ndo_test randexpr-2.1187 {\n  db eval {SELECT case when (abs((abs(d)/abs(t1.f-c)))/abs( -t1.f))*case when (t1.c not in (case when t1.b>case t1.d when t1.b then e else 11 end then t1.a when ( -t1.d in (select  -count(*)-cast(avg(f) AS integer) from t1 union select count(*) from t1)) or 11 in (e,t1.e,c) then a else b end,t1.a,11) or t1.a in (17,t1.a,t1.d) and b>(t1.a)) then 11 when c<b then t1.f+t1.e else b end+t1.a>t1.b then t1.c else 17 end FROM t1 WHERE t1.b>f}\n} {}\ndo_test randexpr-2.1188 {\n  db eval {SELECT case when (abs((abs(d)/abs(t1.f-c)))/abs( -t1.f))*case when (t1.c not in (case when t1.b>case t1.d when t1.b then e else 11 end then t1.a when ( -t1.d in (select  -count(*)-cast(avg(f) AS integer) from t1 union select count(*) from t1)) or 11 in (e,t1.e,c) then a else b end,t1.a,11) or t1.a in (17,t1.a,t1.d) and b>(t1.a)) then 11 when c<b then t1.f+t1.e else b end+t1.a>t1.b then t1.c else 17 end FROM t1 WHERE NOT (t1.b>f)}\n} {17}\ndo_test randexpr-2.1189 {\n  db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) | max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e | t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else  -b end FROM t1 WHERE ( -(select  -min(13-t1.b) from t1)-coalesce((select case when  -d>=t1.e or 11 between 17 and  -t1.e then 19+f when t1.f=11 then  -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select  -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1)}\n} {}\ndo_test randexpr-2.1190 {\n  db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) | max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e | t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else  -b end FROM t1 WHERE NOT (( -(select  -min(13-t1.b) from t1)-coalesce((select case when  -d>=t1.e or 11 between 17 and  -t1.e then 19+f when t1.f=11 then  -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select  -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1))}\n} {300}\ndo_test randexpr-2.1191 {\n  db eval {SELECT t1.e-case when case when ((exists(select 1 from t1 where not exists(select 1 from t1 where case when not 13<=13 or (t1.c<>t1.e) then t1.d else +13 end+13 in (select max(13) & max((t1.b)) from t1 union select max(f) from t1))))) then t1.f else ~t1.e & t1.d*t1.b end+11 not between t1.c and 13 then b when (t1.f not in (19,t1.f,t1.d)) then c else  -b end FROM t1 WHERE NOT (( -(select  -min(13-t1.b) from t1)-coalesce((select case when  -d>=t1.e or 11 between 17 and  -t1.e then 19+f when t1.f=11 then  -t1.c else t1.b end from t1 where t1.a not in (11,t1.e,t1.a)),t1.c)*11 in (select  -case abs((abs(min(t1.d)))) when max(19) then cast(avg(f) AS integer) else case count(*) when count(*) then (count(distinct t1.f)) else cast(avg(11) AS integer) end end from t1 union select min(d) from t1)) or b in (select (count(*)) from t1 union select max(t1.a) from t1))}\n} {300}\ndo_test randexpr-2.1192 {\n  db eval {SELECT (coalesce((select c*(select +~count(distinct 19)-cast(avg(~ -c) AS integer)-max( -f)-cast(avg(t1.d) AS integer) from t1)+t1.a*t1.f+t1.e-a*b from t1 where not t1.e<t1.b or 11=d and 19<>d and 11<=t1.e and (not exists(select 1 from t1 where exists(select 1 from t1 where (13=a)) or t1.e>t1.b))),19)) FROM t1 WHERE coalesce((select max(t1.f*11) from t1 where not exists(select 1 from t1 where t1.a<>17) and t1.b>case (abs(b* -t1.a)/abs(11)) when b*case case when f>=t1.e then 11 when t1.b<=d then 17 else a end* -a when e then 11 else c end then (t1.b) else 19 end or t1.f<13), -b)>=e and ((d in (select f from t1 union select f from t1)))}\n} {}\ndo_test randexpr-2.1193 {\n  db eval {SELECT (coalesce((select c*(select +~count(distinct 19)-cast(avg(~ -c) AS integer)-max( -f)-cast(avg(t1.d) AS integer) from t1)+t1.a*t1.f+t1.e-a*b from t1 where not t1.e<t1.b or 11=d and 19<>d and 11<=t1.e and (not exists(select 1 from t1 where exists(select 1 from t1 where (13=a)) or t1.e>t1.b))),19)) FROM t1 WHERE NOT (coalesce((select max(t1.f*11) from t1 where not exists(select 1 from t1 where t1.a<>17) and t1.b>case (abs(b* -t1.a)/abs(11)) when b*case case when f>=t1.e then 11 when t1.b<=d then 17 else a end* -a when e then 11 else c end then (t1.b) else 19 end or t1.f<13), -b)>=e and ((d in (select f from t1 union select f from t1))))}\n} {10200}\ndo_test randexpr-2.1194 {\n  db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c | 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE (t1.b*19<=17)}\n} {}\ndo_test randexpr-2.1195 {\n  db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c | 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE NOT ((t1.b*19<=17))}\n} {6700}\ndo_test randexpr-2.1196 {\n  db eval {SELECT b-b+case when d+e between 17 and case when exists(select 1 from t1 where coalesce((select max(coalesce((select 11 from t1 where t1.e not between 13 and case when t1.e<>c then c & 19+t1.a else 17 end),t1.a)) from t1 where t1.d<=17 or a not in (b,11,a)),(t1.b))+b>=t1.a) then 11 else a end then d else a end+11*f FROM t1 WHERE NOT ((t1.b*19<=17))}\n} {6700}\ndo_test randexpr-2.1197 {\n  db eval {SELECT +(abs(13)/abs(+~~case t1.e | +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else  -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE t1.a between 19 and (t1.b)}\n} {0}\ndo_test randexpr-2.1198 {\n  db eval {SELECT +(abs(13)/abs(+~~case t1.e | +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else  -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE NOT (t1.a between 19 and (t1.b))}\n} {}\ndo_test randexpr-2.1199 {\n  db eval {SELECT +(abs(13)/abs(+~~case t1.e & +11-b-coalesce((select max(c) from t1 where 19 in (select cast(avg(coalesce((select max(case when t1.a<t1.d and t1.f<(11) then t1.f else  -a end*t1.c) from t1 where e<=d and c<f),17)) AS integer)- -max(t1.e)-count(distinct a) from t1 union select max(f) from t1)),t1.c) when t1.a then t1.e else t1.c end*17)) FROM t1 WHERE t1.a between 19 and (t1.b)}\n} {0}\ndo_test randexpr-2.1200 {\n  db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where  -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else  -(max(c)) end from t1)-f | b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f))}\n} {400}\ndo_test randexpr-2.1201 {\n  db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where  -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else  -(max(c)) end from t1)-f | b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE NOT (t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f)))}\n} {}\ndo_test randexpr-2.1202 {\n  db eval {SELECT coalesce((select t1.f from t1 where case d-(select case cast(avg(coalesce((select case when not 11<>e*c then 11 else 13 end from t1 where  -t1.c not between t1.f and 11),t1.e)) AS integer) when case max( -d) when ((min(17))) then cast(avg(t1.a) AS integer) else min(e) end+cast(avg((t1.b)) AS integer) then cast(avg(t1.d) AS integer) else  -(max(c)) end from t1)-f & b*13+e when t1.b then (f) else t1.a end in (select d from t1 union select 17 from t1)),d) FROM t1 WHERE t1.e*c>13-+t1.f | (abs((select abs(min(b)-abs( - -count(distinct 17-d-13+ -e-(t1.d)*e)+max(t1.e)) | (~abs((max(c)))+cast(avg(17) AS integer)-count(*)*cast(avg(11) AS integer))) from t1))/abs(t1.f))}\n} {400}\ndo_test randexpr-2.1203 {\n  db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) | count(*) from t1 union select case count(*) | count(distinct e) when count(*) then  -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where  -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE (t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b)}\n} {801}\ndo_test randexpr-2.1204 {\n  db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) | count(*) from t1 union select case count(*) | count(distinct e) when count(*) then  -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where  -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE NOT ((t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b))}\n} {}\ndo_test randexpr-2.1205 {\n  db eval {SELECT t1.b-~case when ~(abs(17)/abs(t1.a))+17+t1.b in (select count(distinct d) & count(*) from t1 union select case count(*) & count(distinct e) when count(*) then  -count(*) else cast(avg(11) AS integer) end from t1) and t1.e>b or e not between (e) and c and 17 in (t1.c,b,b) and t1.a not between a and (t1.f) then coalesce((select t1.a*t1.c from t1 where  -11 in (t1.a,(t1.f), -f)),13)*t1.c else t1.f end FROM t1 WHERE (t1.e<>t1.a+~~c-t1.a+13*e-17+t1.b)}\n} {801}\ndo_test randexpr-2.1206 {\n  db eval {SELECT ((abs(b)/abs(t1.e+coalesce((select max((abs(coalesce((select max(11) from t1 where t1.a<=coalesce((select case when t1.a in (case t1.b when t1.d then t1.d else a end,17,11) then 13 when t1.a>b then 19 else d end from t1 where c in (select (~case count(*) when min(f) then  -min(d) else count(distinct (t1.f)) end)*(count(*)) from t1 union select  -min((t1.c)) from t1)),11) and (b<=t1.c)),t1.f))/abs(e))-13) from t1 where b not in (d,( -e),e)),c)-t1.c))) FROM t1 WHERE (exists(select 1 from t1 where b in (select +( -abs(max(19+((select case  -+cast(avg(e) AS integer) when  -max(19)-min(t1.c) | count(*) then count(distinct t1.e) else min(f) end-cast(avg( -19) AS integer)*count(*) | count(*) from t1))-17)) | +cast(avg((select cast(avg(a) AS integer) from t1)*f) AS integer)-cast(avg(13-t1.a+b) AS integer))+ -max(t1.a) from t1 union select cast(avg( -f) AS integer) from t1)))}\n} {}\ndo_test randexpr-2.1207 {\n  db eval {SELECT ((abs(b)/abs(t1.e+coalesce((select max((abs(coalesce((select max(11) from t1 where t1.a<=coalesce((select case when t1.a in (case t1.b when t1.d then t1.d else a end,17,11) then 13 when t1.a>b then 19 else d end from t1 where c in (select (~case count(*) when min(f) then  -min(d) else count(distinct (t1.f)) end)*(count(*)) from t1 union select  -min((t1.c)) from t1)),11) and (b<=t1.c)),t1.f))/abs(e))-13) from t1 where b not in (d,( -e),e)),c)-t1.c))) FROM t1 WHERE NOT ((exists(select 1 from t1 where b in (select +( -abs(max(19+((select case  -+cast(avg(e) AS integer) when  -max(19)-min(t1.c) | count(*) then count(distinct t1.e) else min(f) end-cast(avg( -19) AS integer)*count(*) | count(*) from t1))-17)) | +cast(avg((select cast(avg(a) AS integer) from t1)*f) AS integer)-cast(avg(13-t1.a+b) AS integer))+ -max(t1.a) from t1 union select cast(avg( -f) AS integer) from t1))))}\n} {1}\ndo_test randexpr-2.1208 {\n  db eval {SELECT t1.f-17+(abs(case when ~e*coalesce((select max(coalesce((select d from t1 where not  -(19*t1.d*17) not in (t1.a*t1.c,b,b)),f)) from t1 where 13 between t1.d and 19),11* -t1.e)-(t1.a)>d then 17 when (e in (select  -(t1.d) from t1 union select  -(t1.b) from t1)) then e else  -t1.d end)/abs(17))*a FROM t1 WHERE 17 in (select 19 from t1 union select  -17 | d from t1)}\n} {}\ndo_test randexpr-2.1209 {\n  db eval {SELECT t1.f-17+(abs(case when ~e*coalesce((select max(coalesce((select d from t1 where not  -(19*t1.d*17) not in (t1.a*t1.c,b,b)),f)) from t1 where 13 between t1.d and 19),11* -t1.e)-(t1.a)>d then 17 when (e in (select  -(t1.d) from t1 union select  -(t1.b) from t1)) then e else  -t1.d end)/abs(17))*a FROM t1 WHERE NOT (17 in (select 19 from t1 union select  -17 | d from t1))}\n} {683}\ndo_test randexpr-2.1210 {\n  db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c | c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then  -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE (case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c}\n} {}\ndo_test randexpr-2.1211 {\n  db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c | c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then  -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE NOT ((case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c)}\n} {600}\ndo_test randexpr-2.1212 {\n  db eval {SELECT case t1.a when case when 13+( -f-b)*c-t1.d-t1.c & c+d>=d*case when not ++c+t1.d<>+b- -a*t1.e then  -f else 17 end+t1.f then t1.e when 11<>19 then c else 11 end then e else f end FROM t1 WHERE NOT ((case when (abs(t1.f+case f-case when exists(select 1 from t1 where t1.c>13) then t1.e when t1.f>= -f then b else e end when 13 then t1.e else t1.c end)/abs(c)) in (select max(f)*max(f)*( -max( -17)) | min(t1.a) | cast(avg(13) AS integer)+count(*) from t1 union select ( -max(e)) from t1) then ( -d) when c not between f and ( -c) then 13 else b end between t1.a and e) and 19 not between 19 and c)}\n} {600}\ndo_test randexpr-2.1213 {\n  db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select  -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end | 19 FROM t1 WHERE (case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e)}\n} {403}\ndo_test randexpr-2.1214 {\n  db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select  -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end | 19 FROM t1 WHERE NOT ((case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e))}\n} {}\ndo_test randexpr-2.1215 {\n  db eval {SELECT case when 19=t1.e or (abs(t1.f)/abs(((select  -count(distinct f+~t1.e-t1.b-coalesce((select max(b*c) from t1 where 17<>b),b))+~cast(avg(d) AS integer) from t1)))) not between f and d then coalesce((select max( -a) from t1 where 13<=11 or t1.d>=f),t1.d) when 17 in (select 11 from t1 union select t1.a from t1) then t1.d else t1.c end & 19 FROM t1 WHERE (case t1.d when ~a then coalesce((select max((abs( -~+b)/abs(t1.c))) from t1 where case t1.e when (abs((abs(case t1.a++t1.d | 19-coalesce((select e from t1 where b not between t1.f+b+c and t1.b), -t1.f) when t1.e then t1.a else f end)/abs(t1.b)))/abs(t1.e)) then t1.d else t1.d end>t1.f),t1.d)*t1.b else t1.f end not between a and e)}\n} {16}\ndo_test randexpr-2.1216 {\n  db eval {SELECT coalesce((select t1.c from t1 where  -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 | t1.d | t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) | t1.d) FROM t1 WHERE e<d or case case when  -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e)}\n} {401}\ndo_test randexpr-2.1217 {\n  db eval {SELECT coalesce((select t1.c from t1 where  -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 | t1.d | t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) | t1.d) FROM t1 WHERE NOT (e<d or case case when  -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e))}\n} {}\ndo_test randexpr-2.1218 {\n  db eval {SELECT coalesce((select t1.c from t1 where  -a in (select e from t1 union select 13 from t1)),(select count(distinct coalesce((select max((17)) from t1 where c not between case 19-t1.b when a then ~+(abs((select count(distinct (t1.a)) from t1)+(t1.b))/abs((t1.a)*a+13 & t1.d & t1.a)) else a end and 13 or d in (a,a,t1.f)),d)) from t1) & t1.d) FROM t1 WHERE e<d or case case when  -t1.a between coalesce((select coalesce((select d from t1 where (t1.f=~coalesce((select max(t1.d) from t1 where t1.d<=t1.e),f)*19)),17) from t1 where (t1.f in ( -11,t1.f,a)) or 19<=13),t1.b) and c then t1.f when t1.d=f then t1.f else f end when t1.d then 11 else 17 end*t1.e not in (t1.a,t1.f,e)}\n} {0}\ndo_test randexpr-2.1219 {\n  db eval {SELECT case when case when t1.b<=f+coalesce((select max(11) from t1 where not e in (select count(distinct f) from t1 union select count(*) from t1)),t1.d) or 19 between (e) and 19 and f not in (t1.d,(19),t1.e) and exists(select 1 from t1 where t1.e<=19) or t1.e>t1.a then (select +abs(count(distinct t1.f)*max(13)) from t1) else +d end>=b+t1.c and b not in (f,13,b) then t1.d when b>b then d else t1.d end*11 FROM t1 WHERE d<>b}\n} {4400}\ndo_test randexpr-2.1220 {\n  db eval {SELECT case when case when t1.b<=f+coalesce((select max(11) from t1 where not e in (select count(distinct f) from t1 union select count(*) from t1)),t1.d) or 19 between (e) and 19 and f not in (t1.d,(19),t1.e) and exists(select 1 from t1 where t1.e<=19) or t1.e>t1.a then (select +abs(count(distinct t1.f)*max(13)) from t1) else +d end>=b+t1.c and b not in (f,13,b) then t1.d when b>b then d else t1.d end*11 FROM t1 WHERE NOT (d<>b)}\n} {}\ndo_test randexpr-2.1221 {\n  db eval {SELECT ~(abs(case when t1.a not between  -t1.d*(b) and 17 then f when e<=t1.f then b*t1.d else 13*(a) end)/abs((coalesce((select d from t1 where +(abs((select (min(a)) from t1))/abs((select count(distinct a) from t1)))- -t1.a in (select  -case max(e)+count(distinct d) when cast(avg(( -t1.e)) AS integer) then ( -(count(*))) else  -min(d) end+max(t1.f) from t1 union select max(t1.a) from t1)),t1.d)))) FROM t1 WHERE (t1.a<t1.a)}\n} {}\ndo_test randexpr-2.1222 {\n  db eval {SELECT ~(abs(case when t1.a not between  -t1.d*(b) and 17 then f when e<=t1.f then b*t1.d else 13*(a) end)/abs((coalesce((select d from t1 where +(abs((select (min(a)) from t1))/abs((select count(distinct a) from t1)))- -t1.a in (select  -case max(e)+count(distinct d) when cast(avg(( -t1.e)) AS integer) then ( -(count(*))) else  -min(d) end+max(t1.f) from t1 union select max(t1.a) from t1)),t1.d)))) FROM t1 WHERE NOT ((t1.a<t1.a))}\n} {-2}\ndo_test randexpr-2.1223 {\n  db eval {SELECT f+case when (~t1.c between case when +d between (select  -abs(count(distinct t1.a+17+t1.f))+case min(19)*count(distinct  -t1.a) when (count(*)) then ((count(*))) else ((max(t1.e))) end from t1) and case when  -t1.b>=13 then 11 else a end then  -17 else a end and (t1.c) and (b=17)) then (+(t1.c)) when t1.a<=t1.f then t1.d else 11 end FROM t1 WHERE c<>~13}\n} {1000}\ndo_test randexpr-2.1224 {\n  db eval {SELECT f+case when (~t1.c between case when +d between (select  -abs(count(distinct t1.a+17+t1.f))+case min(19)*count(distinct  -t1.a) when (count(*)) then ((count(*))) else ((max(t1.e))) end from t1) and case when  -t1.b>=13 then 11 else a end then  -17 else a end and (t1.c) and (b=17)) then (+(t1.c)) when t1.a<=t1.f then t1.d else 11 end FROM t1 WHERE NOT (c<>~13)}\n} {}\ndo_test randexpr-2.1225 {\n  db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select  -min(t1.d) from t1) then 11 when 11<=(a) then f else  -e end |  -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where  -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c}\n} {}\ndo_test randexpr-2.1226 {\n  db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select  -min(t1.d) from t1) then 11 when 11<=(a) then f else  -e end |  -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE NOT (t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where  -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c)}\n} {100}\ndo_test randexpr-2.1227 {\n  db eval {SELECT case when ~(abs((select count(*) from t1))/abs(c))<>case when 17*case when coalesce((select max(f) from t1 where exists(select 1 from t1 where t1.f=t1.e)),t1.a) in (select min(t1.f) from t1 union select  -min(t1.d) from t1) then 11 when 11<=(a) then f else  -e end &  -t1.b< -c then d else f end then ((t1.a)) when t1.f in (select ~(++(count(*))+cast(avg(t1.f) AS integer))+max(( -t1.d)) from t1 union select cast(avg(e) AS integer) from t1) then 11 else d end FROM t1 WHERE NOT (t1.a between case when t1.d=t1.a*11 | (select (cast(avg(t1.a) AS integer)+abs( -count(distinct e)) | ~count(distinct coalesce((select max(b) from t1 where not exists(select 1 from t1 where  -e>=13)),(t1.e)))- -( -max(d))* -count(*)) from t1)+(abs(t1.f)/abs((select cast(avg(11) AS integer) from t1))) then t1.a else coalesce((select max(c) from t1 where 11>=t1.e or 11 in (t1.b,t1.b,t1.d) or t1.a>=t1.a),13)*a end and t1.c)}\n} {100}\ndo_test randexpr-2.1228 {\n  db eval {SELECT (coalesce((select 19 from t1 where  - -t1.d | t1.c+~(select max(11) |  -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end}\n} {}\ndo_test randexpr-2.1229 {\n  db eval {SELECT (coalesce((select 19 from t1 where  - -t1.d | t1.c+~(select max(11) |  -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE NOT (t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end)}\n} {400}\ndo_test randexpr-2.1230 {\n  db eval {SELECT (coalesce((select 19 from t1 where  - -t1.d & t1.c+~(select max(11) &  -~count(*)+count(*)-cast(avg(case when t1.e in (select a from t1 union select f from t1) then c else 11 end) AS integer) from t1)*coalesce((select t1.b from t1 where ((abs(t1.b)/abs(coalesce((select (b)-f from t1 where t1.f not in ( -e, -t1.b, -t1.d) and t1.d>=a or 19 not in (a,13,t1.f)),b))))<t1.e),f)+b<t1.c),d)) FROM t1 WHERE NOT (t1.f | +19+f*t1.d+t1.b*d<case when (select min(t1.e) from t1) not in (t1.b,11, -b*case c when coalesce((select max(t1.b+b) from t1 where 19+13=t1.f),coalesce((select max(19*f) from t1 where t1.a=a),a)) then d else t1.f end) then t1.f when f=t1.c then a else 19 end)}\n} {19}\ndo_test randexpr-2.1231 {\n  db eval {SELECT +case when t1.f<c then 19 when f<=case t1.c when c*d then case when (t1.d=17) and not (d-case when 11<19 then t1.b when t1.d in (t1.e, - -e,c) then a else t1.d end+b in (t1.a,19,11)) then case 19 when c then t1.d else t1.d end when d in (select a from t1 union select 11 from t1) then (t1.e) else 11 end else 19 end then c else 19 end FROM t1 WHERE exists(select 1 from t1 where 19 in (select ++min(t1.f)+case abs((count(distinct 11-t1.a-t1.f)-case ((min(13))) when count(distinct t1.f) then  - -cast(avg(t1.d) AS integer) else cast(avg(t1.d) AS integer) end | count(*)*max(b)- -min(b)))- -min((b)) | min(b) | count(*)*count(*) when count(*) then max(19) else max(19) end | cast(avg(t1.b) AS integer)+min(t1.d)* -max(t1.c) | ( -( -min(t1.e)))*min(d)- -min(d) from t1 union select ((min(b))) from t1))}\n} {}\ndo_test randexpr-2.1232 {\n  db eval {SELECT +case when t1.f<c then 19 when f<=case t1.c when c*d then case when (t1.d=17) and not (d-case when 11<19 then t1.b when t1.d in (t1.e, - -e,c) then a else t1.d end+b in (t1.a,19,11)) then case 19 when c then t1.d else t1.d end when d in (select a from t1 union select 11 from t1) then (t1.e) else 11 end else 19 end then c else 19 end FROM t1 WHERE NOT (exists(select 1 from t1 where 19 in (select ++min(t1.f)+case abs((count(distinct 11-t1.a-t1.f)-case ((min(13))) when count(distinct t1.f) then  - -cast(avg(t1.d) AS integer) else cast(avg(t1.d) AS integer) end | count(*)*max(b)- -min(b)))- -min((b)) | min(b) | count(*)*count(*) when count(*) then max(19) else max(19) end | cast(avg(t1.b) AS integer)+min(t1.d)* -max(t1.c) | ( -( -min(t1.e)))*min(d)- -min(d) from t1 union select ((min(b))) from t1)))}\n} {19}\ndo_test randexpr-2.1233 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 | coalesce((select max(t1.f | t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE not  -t1.e+t1.c not between case when  -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select  -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select  -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e}\n} {}\ndo_test randexpr-2.1234 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 | coalesce((select max(t1.f | t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE NOT (not  -t1.e+t1.c not between case when  -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select  -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select  -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e)}\n} {-120}\ndo_test randexpr-2.1235 {\n  db eval {SELECT ~case when exists(select 1 from t1 where t1.c in (t1.a,e+t1.b+e-19 & coalesce((select max(t1.f & t1.a+11*a) from t1 where (abs((abs(f)/abs(d)))/abs(coalesce((select max(t1.a) from t1 where (13 between (f) and f and t1.e between e and t1.b)),t1.c)))<=(f)),e)+f+13, -t1.c)) then t1.b when t1.d<>t1.d then (17) else e end+t1.d-19 FROM t1 WHERE NOT (not  -t1.e+t1.c not between case when  -case case when exists(select 1 from t1 where 17 in (select min(19) from t1 union select  -min(19) from t1) and 13 not in (17,a,t1.e)) then case when f>=19 then (c) when t1.f>13 then 19 else 19 end | t1.a else e end when b then t1.c else b end in (select  -max(13) from t1 union select count(distinct 17) from t1) and 11 not in (11,t1.a,f) and t1.c=f then ~(abs(t1.e)/abs(t1.d)) when f<13 then 17 else 19 end*b and t1.e)}\n} {-120}\ndo_test randexpr-2.1236 {\n  db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d | b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then  -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) | max(c) from t1)*t1.e*19*11) FROM t1 WHERE b<>(select count(distinct f) from t1)}\n} {104918000}\ndo_test randexpr-2.1237 {\n  db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d | b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then  -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) | max(c) from t1)*t1.e*19*11) FROM t1 WHERE NOT (b<>(select count(distinct f) from t1))}\n} {}\ndo_test randexpr-2.1238 {\n  db eval {SELECT ((select min(e+case when b not between coalesce((select t1.d & b from t1 where not exists(select 1 from t1 where 17>11)), -c) and (t1.a) or e<t1.b and (11)<>d then a when 19>11 then  -13 else t1.b end+13)+count(distinct d)+count(*)* -count(distinct t1.f)-((count(distinct t1.c)))+min(a) & max(c) from t1)*t1.e*19*11) FROM t1 WHERE b<>(select count(distinct f) from t1)}\n} {836000}\ndo_test randexpr-2.1239 {\n  db eval {SELECT coalesce((select max(t1.a) from t1 where +b-b+t1.e<>(case when (case when ((select case  -cast(avg(17) AS integer) when max(17) then count(*) else count(distinct t1.d) end from t1))-case 19 when 11 then e else t1.f end<=e then 19 when b not between t1.c and 13 then e else 17 end+t1.c in (select 19 from t1 union select a from t1)) then e-t1.c else t1.f end*t1.b)-e),a) FROM t1 WHERE coalesce((select 13 from t1 where t1.c<>t1.b | t1.e*19-e),f+t1.d) not in (13,(c)*a,e)}\n} {}\ndo_test randexpr-2.1240 {\n  db eval {SELECT coalesce((select max(t1.a) from t1 where +b-b+t1.e<>(case when (case when ((select case  -cast(avg(17) AS integer) when max(17) then count(*) else count(distinct t1.d) end from t1))-case 19 when 11 then e else t1.f end<=e then 19 when b not between t1.c and 13 then e else 17 end+t1.c in (select 19 from t1 union select a from t1)) then e-t1.c else t1.f end*t1.b)-e),a) FROM t1 WHERE NOT (coalesce((select 13 from t1 where t1.c<>t1.b | t1.e*19-e),f+t1.d) not in (13,(c)*a,e))}\n} {100}\ndo_test randexpr-2.1241 {\n  db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when  -count(*) then min(b) else  - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then  -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) |  -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and  -c then (d) when t1.f<=((t1.c)) then  - -13 else c end FROM t1 WHERE 13-e>(abs(t1.f)/abs((t1.d)*d))}\n} {}\ndo_test randexpr-2.1242 {\n  db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when  -count(*) then min(b) else  - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then  -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) |  -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and  -c then (d) when t1.f<=((t1.c)) then  - -13 else c end FROM t1 WHERE NOT (13-e>(abs(t1.f)/abs((t1.d)*d)))}\n} {0}\ndo_test randexpr-2.1243 {\n  db eval {SELECT t1.d-case when (11) not between coalesce((select max(a) from t1 where f in (select cast(avg(t1.c+(select case case case max(a) when  -count(*) then min(b) else  - -(min((t1.a))) end when (max((19))) then max(t1.f) else count(*) end when max(t1.a) then  -min(t1.c) else count(*) end from t1)+c+t1.d) AS integer)-min(a) &  -cast(avg(f) AS integer)*(cast(avg(f) AS integer))-( -count(*)) from t1 union select min( -c) from t1)),t1.a) and  -c then (d) when t1.f<=((t1.c)) then  - -13 else c end FROM t1 WHERE NOT (13-e>(abs(t1.f)/abs((t1.d)*d)))}\n} {0}\ndo_test randexpr-2.1244 {\n  db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where  -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) | cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select  -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1)}\n} {}\ndo_test randexpr-2.1245 {\n  db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where  -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) | cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE NOT (not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select  -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1))}\n} {4}\ndo_test randexpr-2.1246 {\n  db eval {SELECT (abs(coalesce((select max(b) from t1 where not exists(select 1 from t1 where 19>(t1.c))),(11+(abs(c)/abs(19)))+b)+coalesce((select max(t1.c) from t1 where t1.a<=13),t1.d+t1.b+case when exists(select 1 from t1 where  -t1.b in (select min(t1.a-+13) from t1 union select max(t1.c) from t1)) then (select ++(cast(avg(11) AS integer)) & cast(avg(b) AS integer)*cast(avg(d) AS integer) from t1) when f>=b then 19 else 19 end))/abs(b)) FROM t1 WHERE NOT (not b in (select case when t1.e in (select +cast(avg(d) AS integer)-count(*)*count(*)-(case ~count(distinct d)*cast(avg(t1.b) AS integer) when count(distinct t1.e) then max(19) else cast(avg(t1.b) AS integer) end+(count(distinct t1.c))) from t1 union select  -min(t1.f) from t1) or 19<=+11 then ((select (min(t1.b)) from t1)*a-19+17*13) | a when (11 in (select d from t1 union select t1.e from t1)) then 19 else t1.b end from t1 union select t1.c from t1))}\n} {4}\ndo_test randexpr-2.1247 {\n  db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f | e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else  - -count(distinct e) end | count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE b>=+t1.e or f<=t1.b and  -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b)}\n} {}\ndo_test randexpr-2.1248 {\n  db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f | e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else  - -count(distinct e) end | count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE NOT (b>=+t1.e or f<=t1.b and  -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b))}\n} {519}\ndo_test randexpr-2.1249 {\n  db eval {SELECT +case ~t1.d when case when b*f in (select b from t1 union select 17 from t1) and ((case when t1.f & e in (select ~abs(~(case cast(avg(t1.f) AS integer) when min(b) then min(t1.d) else  - -count(distinct e) end & count(*)*( -cast(avg(t1.b) AS integer)))) from t1 union select (count(distinct t1.b)) from t1) then t1.f else t1.f*17+a end-13+e<>t1.c)) then d else t1.c end then t1.f else t1.e end+19 FROM t1 WHERE NOT (b>=+t1.e or f<=t1.b and  -c*17-t1.d*19 not in (c+coalesce((select (abs(~+d*t1.f)/abs(11)) from t1 where +case when t1.d+ -t1.e in (select max(t1.d)*count(distinct b) from t1 union select count(distinct 11) from t1) then (17) when (t1.e>t1.a) then e else e end not in (e,f,t1.a)),t1.f),t1.a,b))}\n} {519}\ndo_test randexpr-2.1250 {\n  db eval {SELECT (abs((abs(t1.a)/abs(~17 | coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c | e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) | 13)))/abs(e)) FROM t1 WHERE exists(select 1 from t1 where t1.a+t1.d-11<=t1.e)}\n} {0}\ndo_test randexpr-2.1251 {\n  db eval {SELECT (abs((abs(t1.a)/abs(~17 | coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c | e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) | 13)))/abs(e)) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a+t1.d-11<=t1.e))}\n} {}\ndo_test randexpr-2.1252 {\n  db eval {SELECT (abs((abs(t1.a)/abs(~17 & coalesce((select ~coalesce((select (d) from t1 where t1.b>=t1.a),case when t1.e-(select ~max( -19*c & e+t1.c) from t1) not between (abs(c)/abs(e)) and t1.e then a else 17 end*17)+13 from t1 where a in (select max(t1.f) from t1 union select ~count(distinct b) from t1)),b) & 13)))/abs(e)) FROM t1 WHERE exists(select 1 from t1 where t1.a+t1.d-11<=t1.e)}\n} {0}\ndo_test randexpr-2.1253 {\n  db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case  -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) | t1.f FROM t1 WHERE t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then  -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then  -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e))}\n} {}\ndo_test randexpr-2.1254 {\n  db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case  -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) | t1.f FROM t1 WHERE NOT (t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then  -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then  -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e)))}\n} {984}\ndo_test randexpr-2.1255 {\n  db eval {SELECT coalesce((select max(d) from t1 where not exists(select 1 from t1 where t1.e not in (13,e,coalesce((select f from t1 where (abs(case  -t1.e when ~f then (t1.c)*13-t1.b+a-d+ -t1.a else a end)/abs(11))*19*t1.d>=a),(t1.b)))) or d not in (f,e,19)),coalesce((select max(17) from t1 where e in (select t1.e from t1 union select 17 from t1)),t1.c)) & t1.f FROM t1 WHERE NOT (t1.e not in (13,(select +count(*)+abs(cast(avg(case t1.d when 17 then  -t1.e+13 else (abs( -c)/abs(case when t1.e*+coalesce((select max(13) from t1 where a>t1.b),t1.f)>=(13) then  -f else t1.a end)) end) AS integer)) from t1)*(13),(select ((max(t1.d))) from t1)) and not exists(select 1 from t1 where e+b not in (b,t1.c,t1.e)))}\n} {16}\ndo_test randexpr-2.1256 {\n  db eval {SELECT (abs(case when (t1.d*coalesce((select max(case coalesce((select max(e) from t1 where t1.a not in (coalesce((select (select count(distinct t1.e) from t1) from t1 where c>=t1.c),f),19,a)),t1.a) when t1.c then t1.a else b end-a) from t1 where c>t1.d),b)<= -11) then t1.a when not exists(select 1 from t1 where not (t1.d=e) or t1.f between t1.a and  -e and (t1.c)=f and a not in (t1.c,a,c)) then t1.a else t1.a end)/abs( -13))+e-d FROM t1 WHERE 17 not in (13,19,t1.c)}\n} {107}\ndo_test randexpr-2.1257 {\n  db eval {SELECT (abs(case when (t1.d*coalesce((select max(case coalesce((select max(e) from t1 where t1.a not in (coalesce((select (select count(distinct t1.e) from t1) from t1 where c>=t1.c),f),19,a)),t1.a) when t1.c then t1.a else b end-a) from t1 where c>t1.d),b)<= -11) then t1.a when not exists(select 1 from t1 where not (t1.d=e) or t1.f between t1.a and  -e and (t1.c)=f and a not in (t1.c,a,c)) then t1.a else t1.a end)/abs( -13))+e-d FROM t1 WHERE NOT (17 not in (13,19,t1.c))}\n} {}\ndo_test randexpr-2.1258 {\n  db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f | c else f end from t1 where e>=(select ~case count(*) when  -abs(max(11)-count(distinct  -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end |  -a*d)-13-17 FROM t1 WHERE (abs(coalesce((select  -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1)}\n} {-39995}\ndo_test randexpr-2.1259 {\n  db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f | c else f end from t1 where e>=(select ~case count(*) when  -abs(max(11)-count(distinct  -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end |  -a*d)-13-17 FROM t1 WHERE NOT ((abs(coalesce((select  -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1))}\n} {}\ndo_test randexpr-2.1260 {\n  db eval {SELECT ~ -coalesce((select c from t1 where (case when b<= -e*t1.f then +coalesce((select case when (select count(*) from t1)=e then t1.f & c else f end from t1 where e>=(select ~case count(*) when  -abs(max(11)-count(distinct  -t1.d)) then count(distinct e) else max(f) end*count(*) from t1)),13) else 19 end>=t1.e)),case when t1.c<t1.a then t1.f else a end &  -a*d)-13-17 FROM t1 WHERE (abs(coalesce((select  -coalesce((select max((select +count(distinct a | t1.d)- -(((count(distinct d))))-max(t1.c) from t1)) from t1 where (( -case t1.b when 17 then 17 else 13 end<c))),t1.b) from t1 where d not in (t1.c,19,17) or t1.a in (select (max(b)) from t1 union select (cast(avg(b) AS integer)) from t1)),(t1.b))*19)/abs(e))<a or (not exists(select 1 from t1 where t1.f not in (a, -17,e))) and (t1.a) in (select cast(avg(e) AS integer) from t1 union select max(19) from t1)}\n} {33}\ndo_test randexpr-2.1261 {\n  db eval {SELECT case t1.b when coalesce((select t1.b from t1 where not exists(select 1 from t1 where +case ( -case f when 13 then (abs(t1.b+f)/abs(c)) else t1.d end) when f*t1.f+t1.d then e else coalesce((select coalesce((select max(b) from t1 where t1.a<=t1.a or t1.d+f<=19 or t1.b in (select (11) from t1 union select (19) from t1)),t1.d) from t1 where not exists(select 1 from t1 where 17=b)),c)+e end between t1.c and b)),d) then c else t1.d end FROM t1 WHERE b>t1.e | case when exists(select 1 from t1 where not ~+11<=coalesce((select max(a) from t1 where ~17*case when a=+(select cast(avg(t1.a*e) AS integer) from t1) then t1.e when c<11 then b else f end+c not between t1.e and  -17), -t1.c)) then e+c when not exists(select 1 from t1 where t1.c not between 13 and  -f) then 17 else  -t1.d end or (f)<=c}\n} {300}\ndo_test randexpr-2.1262 {\n  db eval {SELECT case t1.b when coalesce((select t1.b from t1 where not exists(select 1 from t1 where +case ( -case f when 13 then (abs(t1.b+f)/abs(c)) else t1.d end) when f*t1.f+t1.d then e else coalesce((select coalesce((select max(b) from t1 where t1.a<=t1.a or t1.d+f<=19 or t1.b in (select (11) from t1 union select (19) from t1)),t1.d) from t1 where not exists(select 1 from t1 where 17=b)),c)+e end between t1.c and b)),d) then c else t1.d end FROM t1 WHERE NOT (b>t1.e | case when exists(select 1 from t1 where not ~+11<=coalesce((select max(a) from t1 where ~17*case when a=+(select cast(avg(t1.a*e) AS integer) from t1) then t1.e when c<11 then b else f end+c not between t1.e and  -17), -t1.c)) then e+c when not exists(select 1 from t1 where t1.c not between 13 and  -f) then 17 else  -t1.d end or (f)<=c)}\n} {}\ndo_test randexpr-2.1263 {\n  db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a | case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select  -(abs(count(*)) | cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end | a FROM t1 WHERE t1.b not in ((a),t1.d,b)}\n} {}\ndo_test randexpr-2.1264 {\n  db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a | case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select  -(abs(count(*)) | cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end | a FROM t1 WHERE NOT (t1.b not in ((a),t1.d,b))}\n} {500}\ndo_test randexpr-2.1265 {\n  db eval {SELECT case when case when case when exists(select 1 from t1 where exists(select 1 from t1 where t1.a+t1.a & case when t1.b between f and 19 and t1.c<a then t1.e else t1.d end<e)) then a else coalesce((select 11 from t1 where c in (select  -(abs(count(*)) & cast(avg(t1.b) AS integer))+( -min(17))+ -(count(distinct t1.e)) from t1 union select max((t1.a)) from t1)),a) end-t1.d=13 then t1.a else e end*t1.e*t1.c>=t1.e then t1.e else 19 end & a FROM t1 WHERE NOT (t1.b not in ((a),t1.d,b))}\n} {100}\ndo_test randexpr-2.1266 {\n  db eval {SELECT case when exists(select 1 from t1 where a between 13+t1.e and t1.e and (abs((abs(case when not 19 between t1.e and b and not exists(select 1 from t1 where (abs(17)/abs(f-c)) not between (d) and t1.e) then t1.e else 19 end)/abs(11)))/abs(19))=f) or t1.e<= -a then t1.b when exists(select 1 from t1 where t1.d>t1.c) and t1.b<19 then a else 11 end*d FROM t1 WHERE exists(select 1 from t1 where t1.e<>(select count(distinct ((coalesce((select coalesce((select max( -coalesce((select max( -e) from t1 where ((abs(t1.a)/abs(d)) in (select ~~count(*) from t1 union select count(*) from t1) or a in (d,t1.f,d) and  -c in (b,e,t1.d))),t1.c)-19 | 11-t1.e) from t1 where exists(select 1 from t1 where a<=e) and f not in (17,t1.b,t1.c) or (t1.a)>=t1.d),e)-t1.c from t1 where b<t1.d or d<= -t1.c),t1.e)))) from t1))}\n} {4400}\ndo_test randexpr-2.1267 {\n  db eval {SELECT case when exists(select 1 from t1 where a between 13+t1.e and t1.e and (abs((abs(case when not 19 between t1.e and b and not exists(select 1 from t1 where (abs(17)/abs(f-c)) not between (d) and t1.e) then t1.e else 19 end)/abs(11)))/abs(19))=f) or t1.e<= -a then t1.b when exists(select 1 from t1 where t1.d>t1.c) and t1.b<19 then a else 11 end*d FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e<>(select count(distinct ((coalesce((select coalesce((select max( -coalesce((select max( -e) from t1 where ((abs(t1.a)/abs(d)) in (select ~~count(*) from t1 union select count(*) from t1) or a in (d,t1.f,d) and  -c in (b,e,t1.d))),t1.c)-19 | 11-t1.e) from t1 where exists(select 1 from t1 where a<=e) and f not in (17,t1.b,t1.c) or (t1.a)>=t1.d),e)-t1.c from t1 where b<t1.d or d<= -t1.c),t1.e)))) from t1)))}\n} {}\ndo_test randexpr-2.1268 {\n  db eval {SELECT t1.c | 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between  -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE t1.a<b}\n} {-18}\ndo_test randexpr-2.1269 {\n  db eval {SELECT t1.c | 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between  -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE NOT (t1.a<b)}\n} {}\ndo_test randexpr-2.1270 {\n  db eval {SELECT t1.c & 13-19-d+case when t1.d-t1.b+t1.f*t1.a-coalesce((select max(c-17-case when t1.e<c then t1.f when exists(select 1 from t1 where d between  -c and f) then t1.a else 17 end) from t1 where 11 in (select a from t1 union select 17 from t1)),c)*11-d in (select c from t1 union select t1.c from t1) then 17 when 11 between a and (a) then a else t1.a end FROM t1 WHERE t1.a<b}\n} {12}\ndo_test randexpr-2.1271 {\n  db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select  -cast(avg( -t1.b | 19) AS integer)+case min(t1.d) when  -max(t1.e) then  -count(distinct 11) else  - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else  -11 end FROM t1 WHERE t1.d*b<=+~t1.c-t1.d+d*~b | e}\n} {}\ndo_test randexpr-2.1272 {\n  db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select  -cast(avg( -t1.b | 19) AS integer)+case min(t1.d) when  -max(t1.e) then  -count(distinct 11) else  - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else  -11 end FROM t1 WHERE NOT (t1.d*b<=+~t1.c-t1.d+d*~b | e)}\n} {-11}\ndo_test randexpr-2.1273 {\n  db eval {SELECT case when coalesce((select b from t1 where t1.d not in (t1.c,case when t1.d not in (d,coalesce((select (select count(distinct d) from t1)*e from t1 where not exists(select 1 from t1 where t1.d>=t1.f) or 11+t1.a between (select  -cast(avg( -t1.b & 19) AS integer)+case min(t1.d) when  -max(t1.e) then  -count(distinct 11) else  - -max((t1.c)) end from t1) and f),(e)),13) then t1.a else d end* -t1.f,13)),d)>=e then 17 else  -11 end FROM t1 WHERE NOT (t1.d*b<=+~t1.c-t1.d+d*~b | e)}\n} {-11}\ndo_test randexpr-2.1274 {\n  db eval {SELECT t1.a*a+11-case when exists(select 1 from t1 where (t1.d)<d and (b=case when t1.d+(t1.c*c)*t1.b=t1.f then t1.e else  -11 end)) or not exists(select 1 from t1 where t1.d between 13 and  -19 and d<>b) and (19 not in ((t1.a),11,a)) then ~t1.b when t1.c<c then ~c else a end FROM t1 WHERE a+d> -coalesce((select (select max(e) | min(coalesce((select coalesce((select t1.d from t1 where a<a),11)+c from t1 where (b<e)),19)+t1.c)*abs(count(*))*case count(*) when  -min(a) then min(t1.c) else max( -19) end* -count(*) from t1) from t1 where (abs((abs(e)/abs(t1.e)))/abs(t1.e)) between a and b),((t1.a)))-17 and t1.e not between 13 and 17}\n} {10212}\ndo_test randexpr-2.1275 {\n  db eval {SELECT t1.a*a+11-case when exists(select 1 from t1 where (t1.d)<d and (b=case when t1.d+(t1.c*c)*t1.b=t1.f then t1.e else  -11 end)) or not exists(select 1 from t1 where t1.d between 13 and  -19 and d<>b) and (19 not in ((t1.a),11,a)) then ~t1.b when t1.c<c then ~c else a end FROM t1 WHERE NOT (a+d> -coalesce((select (select max(e) | min(coalesce((select coalesce((select t1.d from t1 where a<a),11)+c from t1 where (b<e)),19)+t1.c)*abs(count(*))*case count(*) when  -min(a) then min(t1.c) else max( -19) end* -count(*) from t1) from t1 where (abs((abs(e)/abs(t1.e)))/abs(t1.e)) between a and b),((t1.a)))-17 and t1.e not between 13 and 17)}\n} {}\ndo_test randexpr-2.1276 {\n  db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) | (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE t1.b=t1.b}\n} {200}\ndo_test randexpr-2.1277 {\n  db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) | (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE NOT (t1.b=t1.b)}\n} {}\ndo_test randexpr-2.1278 {\n  db eval {SELECT case when case when case (abs(t1.b)/abs(t1.a)) when e then f else t1.a end>c then 19 else b end- -11 in (select case case count(distinct t1.f) & (max(17)) when (count(*)) then count(distinct b) else count(distinct 19) end when min(t1.f) then (count(distinct t1.f)) else count(*) end-min(13) from t1 union select cast(avg( -t1.c) AS integer) from t1) or f<>t1.a then coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where t1.e>=t1.e)), -t1.a) when exists(select 1 from t1 where 17 between t1.f and t1.d) then t1.c else c end FROM t1 WHERE t1.b=t1.b}\n} {200}\ndo_test randexpr-2.1279 {\n  db eval {SELECT (abs(b)/abs(case 19 when case e+13*~t1.c*11 when case when (select ~min(t1.a) from t1)>t1.c then (case when 11 between (a) and (19) then d else d+t1.c end) else f end then (abs((e+t1.d)*e*19-t1.d)/abs(c)) else t1.b end then 11 else ( -t1.b) end*13)) FROM t1 WHERE case when ((select min( -case when b in (d-t1.e,case when e in (select d from t1 union select 17 from t1) then 11 else c end,( -t1.d)) then t1.b when b>e then c else  -t1.f end)+ -((min(t1.f)))-+min(f) | ( -(cast(avg(a) AS integer))) from t1)) in (select 11 from t1 union select 19 from t1) then 19 when not exists(select 1 from t1 where  -17>t1.f and t1.e in (select t1.e from t1 union select d from t1)) then 11 else d end=t1.d}\n} {}\ndo_test randexpr-2.1280 {\n  db eval {SELECT (abs(b)/abs(case 19 when case e+13*~t1.c*11 when case when (select ~min(t1.a) from t1)>t1.c then (case when 11 between (a) and (19) then d else d+t1.c end) else f end then (abs((e+t1.d)*e*19-t1.d)/abs(c)) else t1.b end then 11 else ( -t1.b) end*13)) FROM t1 WHERE NOT (case when ((select min( -case when b in (d-t1.e,case when e in (select d from t1 union select 17 from t1) then 11 else c end,( -t1.d)) then t1.b when b>e then c else  -t1.f end)+ -((min(t1.f)))-+min(f) | ( -(cast(avg(a) AS integer))) from t1)) in (select 11 from t1 union select 19 from t1) then 19 when not exists(select 1 from t1 where  -17>t1.f and t1.e in (select t1.e from t1 union select d from t1)) then 11 else d end=t1.d)}\n} {0}\ndo_test randexpr-2.1281 {\n  db eval {SELECT coalesce((select max(11) from t1 where not not exists(select 1 from t1 where ((abs(b)/abs(t1.f))-19+f-case ~11 when 19 then c else t1.a end)> -c+t1.a)),(11))- -b FROM t1 WHERE b*case when 19 not in (t1.e,a*+t1.d,(abs(+c)/abs(case 11 when b then +case when (not exists(select 1 from t1 where d<=c or c<t1.d or f<=b)) then e*19 | d+f else (t1.d) end | t1.d else b end))) then t1.b when not exists(select 1 from t1 where  -t1.e between 11 and e) then a else 17 end*t1.f between  -c and  -t1.d}\n} {}\ndo_test randexpr-2.1282 {\n  db eval {SELECT coalesce((select max(11) from t1 where not not exists(select 1 from t1 where ((abs(b)/abs(t1.f))-19+f-case ~11 when 19 then c else t1.a end)> -c+t1.a)),(11))- -b FROM t1 WHERE NOT (b*case when 19 not in (t1.e,a*+t1.d,(abs(+c)/abs(case 11 when b then +case when (not exists(select 1 from t1 where d<=c or c<t1.d or f<=b)) then e*19 | d+f else (t1.d) end | t1.d else b end))) then t1.b when not exists(select 1 from t1 where  -t1.e between 11 and e) then a else 17 end*t1.f between  -c and  -t1.d)}\n} {211}\ndo_test randexpr-2.1283 {\n  db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and  -(coalesce((select max(coalesce((select max((select count(*) from t1) |  -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where  - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a)}\n} {}\ndo_test randexpr-2.1284 {\n  db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and  -(coalesce((select max(coalesce((select max((select count(*) from t1) |  -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where  - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE NOT (e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a))}\n} {813}\ndo_test randexpr-2.1285 {\n  db eval {SELECT case when ((select count(*) from t1) not between b+t1.f and  -(coalesce((select max(coalesce((select max((select count(*) from t1) &  -case when ~19-b between a and 17 and (t1.c) between (13) and d and t1.a<=a then f-19 when 19<t1.d then f else t1.d end) from t1 where  - -t1.d between t1.b and a),t1.c)) from t1 where 11<(11)),e)-t1.c)) then b+t1.f else (b) end+13 FROM t1 WHERE NOT (e in (case when 17+b-17*+11 | +case when ~b-17*t1.d in (13,19, -t1.b) or 13 between t1.a and d and 11 not in (t1.e,f, -b) then t1.d*17 else b end not in (17,17,t1.c) then t1.c when t1.d not in (f,e,b) then t1.d else 11 end,11,t1.a))}\n} {813}\ndo_test randexpr-2.1286 {\n  db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 | coalesce((select  -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select  -(count(distinct  -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE t1.d>=11*t1.d}\n} {}\ndo_test randexpr-2.1287 {\n  db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 | coalesce((select  -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select  -(count(distinct  -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE NOT (t1.d>=11*t1.d)}\n} {-100}\ndo_test randexpr-2.1288 {\n  db eval {SELECT case coalesce((select t1.e from t1 where 19 in (select 13 from t1 union select 11 & coalesce((select  -(t1.c) from t1 where t1.a<=t1.c),case when ~case when t1.e not between 11 and t1.e then d else 19 end+t1.a+f in (select  -(count(distinct  -c))-max(d)+count(distinct t1.d) from t1 union select cast(avg((b)) AS integer) from t1) then (t1.d) when not (t1.a not in ( -t1.e,t1.b,17) and 11<d) then e else b end) from t1)),11) when t1.c then a else a end-t1.b FROM t1 WHERE NOT (t1.d>=11*t1.d)}\n} {-100}\ndo_test randexpr-2.1289 {\n  db eval {SELECT (select min(coalesce((select max(case (b | case  -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and  -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE (19)<>t1.b}\n} {149900}\ndo_test randexpr-2.1290 {\n  db eval {SELECT (select min(coalesce((select max(case (b | case  -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and  -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE NOT ((19)<>t1.b)}\n} {}\ndo_test randexpr-2.1291 {\n  db eval {SELECT (select min(coalesce((select max(case (b & case  -e when 11 then +(abs(17)/abs((19))) else 13 end) when t1.f then 17 else a end) from t1 where 17 not between e and  -a and 19=13 or t1.f=19 and t1.c<e and t1.c in (select cast(avg(19) AS integer)*min(c) from t1 union select +count(*) from t1)),t1.c)) from t1)*t1.e-t1.a FROM t1 WHERE (19)<>t1.b}\n} {149900}\ndo_test randexpr-2.1292 {\n  db eval {SELECT t1.f*b | coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then  -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case  -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end |  -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end}\n} {-17}\ndo_test randexpr-2.1293 {\n  db eval {SELECT t1.f*b | coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then  -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE NOT (c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case  -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end |  -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end)}\n} {}\ndo_test randexpr-2.1294 {\n  db eval {SELECT t1.f*b & coalesce((select max(t1.f) from t1 where (case when (select cast(avg((select (count(distinct e+t1.c)) from t1)) AS integer) from t1)=t1.d then case when not exists(select 1 from t1 where (b)+t1.e+t1.f in (select min(e) from t1 union select case count(distinct t1.c) when count(distinct f) then cast(avg((t1.f)) AS integer) else (cast(avg(13) AS integer)) end from t1)) and not exists(select 1 from t1 where (d=b)) then t1.d when 13 in (f,c,c) then case t1.c when 11 then  -a else t1.b end else 13 end else 19 end)<17),19)-t1.a FROM t1 WHERE c>=case when d<t1.e then t1.b when t1.f not between 11 and 17 then coalesce((select max( -~e | (17-c)) from t1 where not exists(select 1 from t1 where (( -13-b) in (select ++cast(avg(b) AS integer) from t1 union select case  -case ~max(e)-count(*) when (min(19)) then count(*) else max(t1.c) end |  -cast(avg(11) AS integer) when max(b) then (max(e)) else count(*) end | min(t1.d) from t1)))),t1.d) else t1.c end}\n} {119936}\ndo_test randexpr-2.1295 {\n  db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where  -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else  -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end | t1.a+d- -f+f FROM t1 WHERE a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where  -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b)}\n} {}\ndo_test randexpr-2.1296 {\n  db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where  -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else  -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end | t1.a+d- -f+f FROM t1 WHERE NOT (a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where  -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b))}\n} {1964}\ndo_test randexpr-2.1297 {\n  db eval {SELECT +case when b in (13,(t1.f),19+a) and not exists(select 1 from t1 where  -case when case when case (abs(coalesce((select b from t1 where t1.b>=t1.a),t1.e))/abs(13)) when t1.b then b else  -a end=11 then 13 else a end<>t1.f or 19 not in (b,(t1.b), -19) then b else e end<>e) then t1.f else c end & t1.a+d- -f+f FROM t1 WHERE NOT (a in (13+17,case when (t1.a>t1.e) then ~t1.c+d*case coalesce((select coalesce((select d from t1 where 11 not between t1.e and coalesce((select t1.b from t1 where  -coalesce((select max(t1.b) from t1 where t1.d in (a,11,d) and b=c),c) between b and d),(t1.e))),t1.f) from t1 where t1.e=a),t1.a) when 17 then (t1.f) else t1.d end+b+c when a>=t1.d then t1.a else f end,b))}\n} {36}\ndo_test randexpr-2.1298 {\n  db eval {SELECT coalesce((select t1.b from t1 where 17+13+t1.b in (e,19,case when 17 in (select case max(b*17-d*t1.b*t1.d)+case max((19)) when ~ -max(t1.f) then +count(*) else cast(avg(13) AS integer) end when count(distinct 11) then min(e) else max(t1.c) end from t1 union select min(d) from t1) then t1.a* -(t1.a) when t1.c=19 then (t1.c) else t1.f end) and t1.f<=13),17) FROM t1 WHERE t1.e<>~t1.b}\n} {17}\ndo_test randexpr-2.1299 {\n  db eval {SELECT coalesce((select t1.b from t1 where 17+13+t1.b in (e,19,case when 17 in (select case max(b*17-d*t1.b*t1.d)+case max((19)) when ~ -max(t1.f) then +count(*) else cast(avg(13) AS integer) end when count(distinct 11) then min(e) else max(t1.c) end from t1 union select min(d) from t1) then t1.a* -(t1.a) when t1.c=19 then (t1.c) else t1.f end) and t1.f<=13),17) FROM t1 WHERE NOT (t1.e<>~t1.b)}\n} {}\ndo_test randexpr-2.1300 {\n  db eval {SELECT (abs(coalesce((select  -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) | cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) | f-13+d*17 when a in (t1.f,t1.c,11) then f else  -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when  -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end)}\n} {0}\ndo_test randexpr-2.1301 {\n  db eval {SELECT (abs(coalesce((select  -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) | cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) | f-13+d*17 when a in (t1.f,t1.c,11) then f else  -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when  -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end))}\n} {}\ndo_test randexpr-2.1302 {\n  db eval {SELECT (abs(coalesce((select  -~(abs(t1.d)/abs(a)) from t1 where case when f in (select ~~(+abs( - -count(*)) & cast(avg(d) AS integer)) from t1 union select (min(f)) from t1) then (abs(t1.c)/abs( -13)) & f-13+d*17 when a in (t1.f,t1.c,11) then f else  -(f) end*c not in (13,d,d) and 19 in (t1.d,t1.d,b)),13))/abs(17)) FROM t1 WHERE exists(select 1 from t1 where t1.d<>case case when not exists(select 1 from t1 where t1.b<e and t1.c>(abs(c)/abs(t1.a))) then t1.b else 17 end when +~(e- -coalesce((select e from t1 where not (b) in (select max(t1.b) from t1 union select case max(t1.e)-max(17)-count(distinct (13)) when  -cast(avg( -t1.b) AS integer) then count(distinct d) else min(t1.f) end from t1)),c*d))*a*13 | f then (13) else c end)}\n} {0}\ndo_test randexpr-2.1303 {\n  db eval {SELECT t1.f*+case when ( -17-a*t1.f | case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE (select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else  -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d}\n} {210000}\ndo_test randexpr-2.1304 {\n  db eval {SELECT t1.f*+case when ( -17-a*t1.f | case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE NOT ((select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else  -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d)}\n} {}\ndo_test randexpr-2.1305 {\n  db eval {SELECT t1.f*+case when ( -17-a*t1.f & case when (coalesce((select max((case a when +13*19* -b then a else 17 end)) from t1 where (t1.b) not between 13 and t1.a),e))-t1.b=t1.f then f else 17 end-b*a*d)<>11 then f else t1.c end-t1.c*e FROM t1 WHERE (select +cast(avg(case when 13*a in (select 11 from t1 union select b from t1) then e when t1.f in (select ~count(distinct f) | count(*) from t1 union select count(distinct 13*t1.a+coalesce((select max(e) from t1 where ~(abs(t1.e)/abs(a)) not in (t1.a+e-c,t1.e,case when t1.f>t1.c or f>t1.c then 13 when t1.c>c then t1.a else  -t1.d end)),f)*19) from t1) then d else d end) AS integer) from t1)=d}\n} {210000}\ndo_test randexpr-2.1306 {\n  db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) | cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) | min(t1.b) | (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where  -17>11)) then (13) else 13 end FROM t1 WHERE 19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and  -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13}\n} {}\ndo_test randexpr-2.1307 {\n  db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) | cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) | min(t1.b) | (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where  -17>11)) then (13) else 13 end FROM t1 WHERE NOT (19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and  -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13)}\n} {313}\ndo_test randexpr-2.1308 {\n  db eval {SELECT t1.c+case when t1.a in (select max(coalesce((select coalesce((select coalesce((select max(19+case t1.f when a then e else t1.d end) from t1 where t1.d> -c),b) from t1 where (t1.c=e) and t1.f=17), -a) from t1 where (e not between e and 11)),t1.f)) & cast(avg(t1.a) AS integer)*max(t1.c) from t1 union select count(distinct c)-max(a) & min(t1.b) & (count(*))* -min(f) from t1) then t1.a when exists(select 1 from t1 where not exists(select 1 from t1 where  -17>11)) then (13) else 13 end FROM t1 WHERE NOT (19=case when exists(select 1 from t1 where t1.f not between 11 and ~c+b-t1.c*case when t1.f<13+(t1.d) and  -t1.f<17 or (b<>b) then ~d else t1.b end) or exists(select 1 from t1 where not exists(select 1 from t1 where t1.e=19)) then c+f*17 else t1.a end and t1.e<13)}\n} {313}\ndo_test randexpr-2.1309 {\n  db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 |  -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where  -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a | t1.c+t1.f else c end FROM t1 WHERE (case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and  -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else  -t1.b end) not between 17 and e}\n} {}\ndo_test randexpr-2.1310 {\n  db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 |  -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where  -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a | t1.c+t1.f else c end FROM t1 WHERE NOT ((case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and  -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else  -t1.b end) not between 17 and e)}\n} {-287}\ndo_test randexpr-2.1311 {\n  db eval {SELECT 13-case when exists(select 1 from t1 where f+b>t1.f+t1.c) or +17 &  -coalesce((select case coalesce((select 13-(select (cast(avg(13) AS integer))-max(t1.b) from t1) from t1 where  -c in (select max(17) from t1 union select max(t1.b) from t1)),t1.a) when t1.d then 19 else d end from t1 where d>=11),b) between 13 and 11 and 17<=13 then a & t1.c+t1.f else c end FROM t1 WHERE NOT ((case when a not in (t1.d+t1.f,b,t1.b) then case when case f | t1.c when t1.e then e else (t1.a)-d | 13 end<>f then t1.e when (((13) in (select min(t1.a) from t1 union select max( -e) from t1) or t1.f between 13 and  -t1.b or (f>=f) or 19<c or t1.d<=13)) then 13 else 19 end else  -t1.b end) not between 17 and e)}\n} {-287}\ndo_test randexpr-2.1312 {\n  db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when  -t1.e<>t1.e or f between b and 13 then t1.c else c end |  -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a | (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when  -19<>11 then d else 13 end from t1)}\n} {}\ndo_test randexpr-2.1313 {\n  db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when  -t1.e<>t1.e or f between b and 13 then t1.c else c end |  -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a | (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE NOT (t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when  -19<>11 then d else 13 end from t1))}\n} {467}\ndo_test randexpr-2.1314 {\n  db eval {SELECT a+case when ((~t1.d*13<=e or (coalesce((select coalesce((select case when  -t1.e<>t1.e or f between b and 13 then t1.c else c end &  -b from t1 where 17<=17),t1.e) from t1 where 11<c and t1.b not between f and t1.d or 13<=17),t1.f)) not in (13,t1.e,13) and ((13>=d) and t1.e>17))) then t1.a & (select ~ - -cast(avg( -c) AS integer) from t1) else c end FROM t1 WHERE NOT (t1.f>=e and t1.f in (select 17 from t1 union select case when (not exists(select 1 from t1 where case when coalesce((select max(19+t1.c) from t1 where 17>=t1.f),c)+19+t1.c< -d then t1.d when t1.c not in (c,t1.f,e) then 17 else t1.d end<t1.e) or (f<=t1.b)) and t1.a not in (a,11, -t1.f) then coalesce((select f from t1 where 17 not in (e,b,t1.f)),t1.f-t1.d) | t1.b when  -19<>11 then d else 13 end from t1))}\n} {132}\ndo_test randexpr-2.1315 {\n  db eval {SELECT case when t1.b not in (17 | t1.e*t1.a,11,(select +case max((select  -+case (max(t1.f)) when count(*) then count(distinct d) else  -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) | count(distinct (t1.e)) when  -min(c) then count(*) else  -count(distinct e) end | cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else  - -d end-t1.e else (t1.f) end FROM t1 WHERE not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where  -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c)}\n} {-481}\ndo_test randexpr-2.1316 {\n  db eval {SELECT case when t1.b not in (17 | t1.e*t1.a,11,(select +case max((select  -+case (max(t1.f)) when count(*) then count(distinct d) else  -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) | count(distinct (t1.e)) when  -min(c) then count(*) else  -count(distinct e) end | cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else  - -d end-t1.e else (t1.f) end FROM t1 WHERE NOT (not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where  -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c))}\n} {}\ndo_test randexpr-2.1317 {\n  db eval {SELECT case when t1.b not in (17 & t1.e*t1.a,11,(select +case max((select  -+case (max(t1.f)) when count(*) then count(distinct d) else  -( -(cast(avg(f) AS integer))) end-count(distinct t1.a) from t1)) & count(distinct (t1.e)) when  -min(c) then count(*) else  -count(distinct e) end & cast(avg(17) AS integer) from t1)) then case when d<=t1.c and (exists(select 1 from t1 where (select count(distinct (e)) from t1)=(abs(17)/abs(d)))) then (abs(t1.f)/abs(t1.c)) when t1.f<>e or t1.c<=d and t1.e<=t1.d then 19 else  - -d end-t1.e else (t1.f) end FROM t1 WHERE not t1.b=coalesce((select (abs(c)/abs(11)) from t1 where exists(select 1 from t1 where  -coalesce((select max(((abs(coalesce((select max(case (select min((abs(19)/abs(19))+19)*count(*)- -cast(avg(t1.d) AS integer)-max(17)+min( -11) from t1) when e then t1.e else f end) from t1 where t1.d<=t1.f), -f)- -t1.e)/abs(d))-t1.b)) from t1 where c<11),t1.b)*a not in (d,d,f))),c)}\n} {-481}\ndo_test randexpr-2.1318 {\n  db eval {SELECT  -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e | 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then  -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE exists(select 1 from t1 where (f=(d)*e))}\n} {}\ndo_test randexpr-2.1319 {\n  db eval {SELECT  -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e | 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then  -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE NOT (exists(select 1 from t1 where (f=(d)*e)))}\n} {-257}\ndo_test randexpr-2.1320 {\n  db eval {SELECT  -t1.a*(select (cast(avg((select count(*)-abs(count(*)*count(*)) from t1)) AS integer)++max(t1.d))*cast(avg(t1.a) AS integer) from t1)+t1.c+t1.c+d-e & 11+t1.b-coalesce((select max(case when exists(select 1 from t1 where t1.a+11=t1.b) then c when t1.a not between t1.f and t1.d or 13<11 then  -b else 19 end) from t1 where c>=t1.f),t1.f) FROM t1 WHERE NOT (exists(select 1 from t1 where (f=(d)*e)))}\n} {-3999632}\ndo_test randexpr-2.1321 {\n  db eval {SELECT  -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) | t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE case a when e then f else case when  -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and  -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select  -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19)}\n} {-400}\ndo_test randexpr-2.1322 {\n  db eval {SELECT  -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) | t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE NOT (case a when e then f else case when  -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and  -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select  -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19))}\n} {}\ndo_test randexpr-2.1323 {\n  db eval {SELECT  -case when t1.a+ -c+coalesce((select d from t1 where (t1.d between a and case when t1.c*t1.b*a between a and 13 then t1.d else 11 end) or not t1.e in (select max(d) from t1 union select max(t1.e)-( -count(distinct t1.e)) from t1) or t1.c>=t1.b or a not in (c,t1.f,t1.d) and b<=t1.c),13)+d-(17) & t1.c*17<=t1.a then t1.c else d end FROM t1 WHERE case a when e then f else case when  -t1.c not between e*f | b and t1.d then case (select max((b)) from t1)+coalesce((select max(case when 19 in (b,e,17) then 13 when 11 in (t1.a,t1.a,t1.a) then t1.e else 19 end) from t1 where a<=e and 13 between t1.e and  -t1.f),13) when 17 then a else t1.d end when e in (select f from t1 union select  -t1.d from t1) then t1.a else c end*d end-13*a not in (19,t1.d,19)}\n} {-400}\ndo_test randexpr-2.1324 {\n  db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) |  - - -+max(19) from t1)-f),b) FROM t1 WHERE t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1)}\n} {}\ndo_test randexpr-2.1325 {\n  db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) |  - - -+max(19) from t1)-f),b) FROM t1 WHERE NOT (t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1))}\n} {7}\ndo_test randexpr-2.1326 {\n  db eval {SELECT coalesce((select (abs(t1.a)/abs(13)) from t1 where a<>(select max(b)-abs(+min(f+13*17+~coalesce((select case when 11-t1.c<>19 then t1.c when (c) not between t1.e and d and 11 in (t1.f,13,((c))) then 19 else 11 end from t1 where ( -d)<e and 17>f),11)+c-t1.c)) &  - - -+max(19) from t1)-f),b) FROM t1 WHERE NOT (t1.b-t1.a+case ((t1.a)) when t1.f then (abs(e*e-(e)*c)/abs(t1.f)) else (abs(t1.a)/abs(t1.b)) end between f and (select case cast(avg(13) AS integer) when (count(*)) then (~abs( -case count(*) when abs((count(*))) then count(distinct 13) else count(*) end)-(count(distinct 11)))-count(distinct 19)*((max(t1.c)))-cast(avg(11) AS integer) else (max(19)) end from t1))}\n} {7}\ndo_test randexpr-2.1327 {\n  db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) | (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and  -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE (not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select  -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end))}\n} {}\ndo_test randexpr-2.1328 {\n  db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) | (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and  -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE NOT ((not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select  -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end)))}\n} {119883}\ndo_test randexpr-2.1329 {\n  db eval {SELECT t1.d*coalesce((select d from t1 where coalesce((select max(t1.c) from t1 where 11<>13),e)<=(select ~min(13) from t1)*t1.a),c)-coalesce((select (t1.b+17) & (abs( -~17)/abs(t1.d)) from t1 where not exists(select 1 from t1 where case t1.d when case when t1.f not in (t1.e,e,17) then f when t1.c not between 11 and  -t1.a then b else 17 end+13 then t1.f else t1.b end+13+t1.b between 17 and 13)),t1.b)+t1.a FROM t1 WHERE NOT ((not d in (t1.d,(select max(e) from t1),case d*case when not exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where t1.b<=11-d+(select  -max(13-t1.f) from t1)*t1.a),19)>t1.c) and c not between d and 19) then 11+~ -t1.a when t1.e<t1.d then f else t1.a end when 17 then t1.b else t1.c end)))}\n} {120100}\ndo_test randexpr-2.1330 {\n  db eval {SELECT d+~e-case when exists(select 1 from t1 where  -a in (select max( -(select  -count(*)-min(e)++cast(avg(case when d in (select +max(c) from t1 union select ((count(distinct (e)))) from t1) then (c) when t1.c<e then 13 else t1.f end) AS integer) from t1)++case 19 when a*t1.e then (t1.c) else 13 end+t1.b) from t1 union select max(11) from t1)) then (abs(19)/abs(t1.b)) when f>=f then t1.b else t1.a end*a+19-13 FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where (select min(case when 13 not in (19,e-t1.a*17,17- -case 19 when 17+17 then a else t1.d end+f-t1.a*11) then 17 else t1.b end*17+11-b) from t1) between 11 and f or t1.e<>t1.d)) or c not in (t1.c,17,d)}\n} {}\ndo_test randexpr-2.1331 {\n  db eval {SELECT d+~e-case when exists(select 1 from t1 where  -a in (select max( -(select  -count(*)-min(e)++cast(avg(case when d in (select +max(c) from t1 union select ((count(distinct (e)))) from t1) then (c) when t1.c<e then 13 else t1.f end) AS integer) from t1)++case 19 when a*t1.e then (t1.c) else 13 end+t1.b) from t1 union select max(11) from t1)) then (abs(19)/abs(t1.b)) when f>=f then t1.b else t1.a end*a+19-13 FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where (select min(case when 13 not in (19,e-t1.a*17,17- -case 19 when 17+17 then a else t1.d end+f-t1.a*11) then 17 else t1.b end*17+11-b) from t1) between 11 and f or t1.e<>t1.d)) or c not in (t1.c,17,d))}\n} {-20095}\ndo_test randexpr-2.1332 {\n  db eval {SELECT case coalesce((select 11*19*t1.a+(abs(t1.e*(select count(distinct  -d) from t1)*case t1.f when +c then d else c end+b)/abs(d)) from t1 where t1.b*13=(e)),13) when (t1.d)*b-19*(e)*e-19+(t1.d) then 13 else b end*a FROM t1 WHERE not d=19 and (abs(t1.c)/abs(17))-a<coalesce((select max(d-+d+case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.b<>b))) then case when 13 not between t1.e and t1.a then c when t1.c>t1.c then 13 else a end | 19 else (19) end*f*13) from t1 where 17=t1.d and (b<>11)),t1.b)+t1.a | d}\n} {20000}\ndo_test randexpr-2.1333 {\n  db eval {SELECT case coalesce((select 11*19*t1.a+(abs(t1.e*(select count(distinct  -d) from t1)*case t1.f when +c then d else c end+b)/abs(d)) from t1 where t1.b*13=(e)),13) when (t1.d)*b-19*(e)*e-19+(t1.d) then 13 else b end*a FROM t1 WHERE NOT (not d=19 and (abs(t1.c)/abs(17))-a<coalesce((select max(d-+d+case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.b<>b))) then case when 13 not between t1.e and t1.a then c when t1.c>t1.c then 13 else a end | 19 else (19) end*f*13) from t1 where 17=t1.d and (b<>11)),t1.b)+t1.a | d)}\n} {}\ndo_test randexpr-2.1334 {\n  db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where  -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 | 19) FROM t1 WHERE not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f |  -b not between 17 and e then  -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select  -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b)}\n} {307}\ndo_test randexpr-2.1335 {\n  db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where  -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 | 19) FROM t1 WHERE NOT (not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f |  -b not between 17 and e then  -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select  -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b))}\n} {}\ndo_test randexpr-2.1336 {\n  db eval {SELECT (c*(abs(coalesce((select t1.b from t1 where (select ~~count(*)+ -count(distinct coalesce((select max(case coalesce((select max(a+(t1.e)) from t1 where  -(a)>=t1.e or t1.e<17),c) when t1.d then t1.a else 17 end) from t1 where t1.b not in (e,(c),t1.a)),f)) from t1) between t1.a and b),case when exists(select 1 from t1 where t1.c>=t1.a) then 19 else t1.e end+t1.c))/abs(b))-11 & 19) FROM t1 WHERE not t1.e<=d or not exists(select 1 from t1 where exists(select 1 from t1 where ( -t1.c+d)>t1.a+case when f |  -b not between 17 and e then  -t1.d else (19) end) or 11 not between 17 and t1.f) or a in (select  -cast(avg(13) AS integer)*count(distinct 17)-min(b)- -max(11) | (count(*)) from t1 union select ((((max(b))))) from t1) and t1.e in (13,(13),b)}\n} {1}\ndo_test randexpr-2.1337 {\n  db eval {SELECT (select cast(avg(13*13* -coalesce((select b from t1 where case +(abs(17)/abs(d))*e+c-case  -case when not a in (d,13,t1.b) then t1.b when t1.f<=b then e else  -f end-17 when t1.e then t1.d else a end when c then b else f end<>e or e<b),f)+t1.a-d*a+t1.c) AS integer) from t1) FROM t1 WHERE 19 in (select  -~count(distinct case when not not not exists(select 1 from t1 where (d in ((abs(19*t1.f-t1.e*e)/abs(11))*13,t1.f,t1.f))) then 13 else t1.a+17-13 end)-min(t1.f) from t1 union select ( -abs(count(distinct d)))-min(t1.b)*+(+count(*) | (min(19)))+min(c) from t1)}\n} {}\ndo_test randexpr-2.1338 {\n  db eval {SELECT (select cast(avg(13*13* -coalesce((select b from t1 where case +(abs(17)/abs(d))*e+c-case  -case when not a in (d,13,t1.b) then t1.b when t1.f<=b then e else  -f end-17 when t1.e then t1.d else a end when c then b else f end<>e or e<b),f)+t1.a-d*a+t1.c) AS integer) from t1) FROM t1 WHERE NOT (19 in (select  -~count(distinct case when not not not exists(select 1 from t1 where (d in ((abs(19*t1.f-t1.e*e)/abs(11))*13,t1.f,t1.f))) then 13 else t1.a+17-13 end)-min(t1.f) from t1 union select ( -abs(count(distinct d)))-min(t1.b)*+(+count(*) | (min(19)))+min(c) from t1))}\n} {-73400}\ndo_test randexpr-2.1339 {\n  db eval {SELECT b | t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where  -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19)))}\n} {}\ndo_test randexpr-2.1340 {\n  db eval {SELECT b | t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where  -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE NOT (t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19))))}\n} {1000}\ndo_test randexpr-2.1341 {\n  db eval {SELECT b & t1.d- -coalesce((select case coalesce((select max((select (abs(cast(avg(coalesce((select max(coalesce((select 17 from t1 where  -11=t1.e),a)) from t1 where not exists(select 1 from t1 where 13 between t1.f and 13)),11)-c) AS integer)))+min( -b) from t1)+b) from t1 where t1.d not in (b*19,t1.a,a)),t1.e) when t1.e then t1.b else t1.d end from t1 where (e not in (b,t1.a,(a)))),13) FROM t1 WHERE NOT (t1.c=coalesce((select t1.d*(select count(*) from t1) from t1 where ((abs(e)/abs(case 13 when t1.d then t1.e else 11 end+13))>t1.d) or (t1.f in (select 11 from t1 union select t1.c from t1) or c>t1.e and b not in (t1.b, -t1.e,t1.a)) or c<>b),(a))-19*t1.c-c*t1.d and exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (t1.b,e,19) or not exists(select 1 from t1 where t1.c=19))))}\n} {0}\ndo_test randexpr-2.1342 {\n  db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then  -f else 19 end | c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE (coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a)}\n} {19}\ndo_test randexpr-2.1343 {\n  db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then  -f else 19 end | c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE NOT ((coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a))}\n} {}\ndo_test randexpr-2.1344 {\n  db eval {SELECT coalesce((select 19 from t1 where not exists(select 1 from t1 where 11+d between b and 19-case when t1.e>e*f+case when 13 in (select count(*) from t1 union select ~min(a*t1.d)+count(*) from t1) then c when (select min(d) from t1) in (select cast(avg(17) AS integer) from t1 union select min(t1.a) from t1) and 11<>(f) then  -f else 19 end & c then 13 else 19 end*b*t1.b)),a) FROM t1 WHERE (coalesce((select d from t1 where coalesce((select ~(coalesce((select max(t1.a) from t1 where 13+t1.c-c*coalesce((select t1.a from t1 where ( -t1.d not between a and d)),t1.e)+t1.e- - -11-t1.d*11<17),d)) from t1 where f between t1.a and t1.a),t1.c)<>e),t1.d)*(19)-t1.e- -17-a>=d or t1.c between f and a)}\n} {19}\ndo_test randexpr-2.1345 {\n  db eval {SELECT coalesce((select +case case when f>t1.d then a+t1.b-f when coalesce((select max(t1.b-case f when 13*t1.a then 11 else 11 end*c) from t1 where f in (select min(t1.d) from t1 union select +count(distinct f) from t1)),17) not in (e,b,t1.a) then f else t1.b end-e*t1.a when  -11 then 19 else (t1.d) end from t1 where 17 not between  -13 and t1.e),19) FROM t1 WHERE not t1.b*coalesce((select max(17 | coalesce((select coalesce((select +coalesce((select max(case when (b not in (a,t1.b, -t1.a)) and t1.f=t1.b then t1.c-t1.f when 11>d then 17 else 11 end+f) from t1 where t1.e<>b), -t1.e) from t1 where t1.f in (select min(b) from t1 union select max(19)+count(distinct e)+(count(distinct e)) |  - -count(distinct 17)*count(*) from t1)),13) from t1 where t1.f>=t1.f),t1.f)) from t1 where t1.f>=b),c)<t1.d}\n} {19}\ndo_test randexpr-2.1346 {\n  db eval {SELECT coalesce((select +case case when f>t1.d then a+t1.b-f when coalesce((select max(t1.b-case f when 13*t1.a then 11 else 11 end*c) from t1 where f in (select min(t1.d) from t1 union select +count(distinct f) from t1)),17) not in (e,b,t1.a) then f else t1.b end-e*t1.a when  -11 then 19 else (t1.d) end from t1 where 17 not between  -13 and t1.e),19) FROM t1 WHERE NOT (not t1.b*coalesce((select max(17 | coalesce((select coalesce((select +coalesce((select max(case when (b not in (a,t1.b, -t1.a)) and t1.f=t1.b then t1.c-t1.f when 11>d then 17 else 11 end+f) from t1 where t1.e<>b), -t1.e) from t1 where t1.f in (select min(b) from t1 union select max(19)+count(distinct e)+(count(distinct e)) |  - -count(distinct 17)*count(*) from t1)),13) from t1 where t1.f>=t1.f),t1.f)) from t1 where t1.f>=b),c)<t1.d)}\n} {}\ndo_test randexpr-2.1347 {\n  db eval {SELECT  -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a | a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then  -t1.e else b end*t1.a FROM t1 WHERE a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when  -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1)}\n} {}\ndo_test randexpr-2.1348 {\n  db eval {SELECT  -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a | a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then  -t1.e else b end*t1.a FROM t1 WHERE NOT (a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when  -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1))}\n} {52000}\ndo_test randexpr-2.1349 {\n  db eval {SELECT  -11* -t1.b-t1.b+ -case when t1.e-(select max((select abs((cast(avg(t1.f) AS integer)+++ -cast(avg(a & a) AS integer))) from t1))+(( -max( -b))) from t1)<=(abs(11)/abs((select count(distinct t1.e) from t1)-b*case when t1.a<>11 then t1.a when 17 not between d and 13 or t1.f in (b,b,t1.a) then t1.d else c end)) then  -t1.e else b end*t1.a FROM t1 WHERE NOT (a in ((abs(t1.c*+(abs(17-(abs(19)/abs(b-coalesce((select max(t1.c) from t1 where c>t1.f),t1.e))))/abs(t1.e))+t1.b | t1.d*t1.a)/abs(coalesce((select case when t1.f in (case when  -e<=t1.a then f else 17 end,f,b) then b else t1.c end from t1 where not a in (t1.d,t1.a,c)),t1.f))),b,t1.b) and e in (select f from t1 union select e from t1))}\n} {52000}\ndo_test randexpr-2.1350 {\n  db eval {SELECT case when ((select count(*) | min(case when (a*e in (select  -+ -min(a) | cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c | a*t1.c else  -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE (c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c))}\n} {}\ndo_test randexpr-2.1351 {\n  db eval {SELECT case when ((select count(*) | min(case when (a*e in (select  -+ -min(a) | cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c | a*t1.c else  -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE NOT ((c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c)))}\n} {600}\ndo_test randexpr-2.1352 {\n  db eval {SELECT case when ((select count(*) & min(case when (a*e in (select  -+ -min(a) & cast(avg(11) AS integer) from t1 union select count(distinct t1.e) from t1) and exists(select 1 from t1 where not 13 in (select count(distinct 11) from t1 union select (max(19)) from t1) or (t1.f) between t1.e and (t1.e)) or t1.a<=f) or t1.e<t1.a then t1.a when t1.e not between t1.c and t1.b then t1.c & a*t1.c else  -b end) from t1))+19-17<=c then f when 19>t1.c then t1.e else t1.b end FROM t1 WHERE NOT ((c not between +(select + -~~max(coalesce((select case when t1.b<=t1.d*a then t1.c else t1.e end*t1.e from t1 where t1.d>=t1.b and c=(f) or t1.e>t1.d and b<e),t1.b))-count(*) | max(d)+cast(avg(19) AS integer) | count(distinct 17) from t1)*t1.a and ((coalesce((select max(t1.b) from t1 where t1.f in (select 17 from t1 union select a from t1)),e))*c)))}\n} {600}\ndo_test randexpr-2.1353 {\n  db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct  -17+t1.a) from t1)) or (d*coalesce((select b | coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE d*a | 19<> -t1.d}\n} {-500}\ndo_test randexpr-2.1354 {\n  db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct  -17+t1.a) from t1)) or (d*coalesce((select b | coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE NOT (d*a | 19<> -t1.d)}\n} {}\ndo_test randexpr-2.1355 {\n  db eval {SELECT coalesce((select max(coalesce((select max((abs((11))/abs(13))-e) from t1 where 11 not in (c,f,(select count(distinct  -17+t1.a) from t1)) or (d*coalesce((select b & coalesce((select max(17) from t1 where e in (d,t1.c,t1.c)),+b) from t1 where d in (d-13,t1.c,f)),13))<>t1.c),t1.d)) from t1 where b not in (t1.e, -13,f)),f) FROM t1 WHERE d*a | 19<> -t1.d}\n} {-500}\ndo_test randexpr-2.1356 {\n  db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 |  -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then  -t1.f else 13 end-f) then ( -17) else  -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) | count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end | (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1)}\n} {500}\ndo_test randexpr-2.1357 {\n  db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 |  -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then  -t1.f else 13 end-f) then ( -17) else  -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) | count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end | (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE NOT (not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1))}\n} {}\ndo_test randexpr-2.1358 {\n  db eval {SELECT coalesce((select t1.f from t1 where case when 19<>(c*case when 19 &  -t1.e in (select ~+(max(c)) from t1 union select min(19) from t1) then  -t1.f else 13 end-f) then ( -17) else  -19 end-b in (t1.b,t1.f,b) or c in (select ~case max( -t1.d) & count(*)*cast(avg(b) AS integer) when count(distinct t1.f) then cast(avg(t1.f) AS integer) else cast(avg(f) AS integer) end & (cast(avg( -t1.e) AS integer)) from t1 union select max(c) from t1) and t1.f in (select max(17) from t1 union select max(11) from t1)),e) FROM t1 WHERE not 13 in (select (t1.b)*(coalesce((select (abs(t1.f)/abs( -t1.f-d))-coalesce((select 19 from t1 where not exists(select 1 from t1 where (select count(distinct t1.f+19-(abs(e)/abs(e))) from t1)- -e<>d)),t1.e)* -t1.a-t1.a-(t1.f)*t1.e*t1.d-t1.b from t1 where t1.e between t1.a and b),11)) from t1 union select d from t1)}\n} {500}\ndo_test randexpr-2.1359 {\n  db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when  -c+f-11 | coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE t1.e>= -f}\n} {-1}\ndo_test randexpr-2.1360 {\n  db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when  -c+f-11 | coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE NOT (t1.e>= -f)}\n} {}\ndo_test randexpr-2.1361 {\n  db eval {SELECT ~ -case when t1.d in (17,t1.e,case t1.b*c when  -c+f-11 & coalesce((select 11 from t1 where (select (min(13)-max(t1.c))+count(*) from t1)+13<=(( -(t1.f)))),b)+17 then t1.d else b end) then c when c between 13 and f and b>17 then f else t1.a end-t1.f FROM t1 WHERE t1.e>= -f}\n} {-1}\ndo_test randexpr-2.1362 {\n  db eval {SELECT ((abs(13)/abs( -b | coalesce((select 17 | t1.e from t1 where (d in (select coalesce((select 17 | (a) | c*case when case when t1.c in (select max(13) | cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE 11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c)}\n} {3}\ndo_test randexpr-2.1363 {\n  db eval {SELECT ((abs(13)/abs( -b | coalesce((select 17 | t1.e from t1 where (d in (select coalesce((select 17 | (a) | c*case when case when t1.c in (select max(13) | cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE NOT (11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c))}\n} {}\ndo_test randexpr-2.1364 {\n  db eval {SELECT ((abs(13)/abs( -b & coalesce((select 17 & t1.e from t1 where (d in (select coalesce((select 17 & (a) & c*case when case when t1.c in (select max(13) & cast(avg(t1.b) AS integer) from t1 union select count(*) from t1) then t1.c when 13>=17 then (11) else t1.e end>t1.d and t1.b>=t1.f then 13 when 11 not in (t1.d, -f,13) then f else 11 end from t1 where b<>11),d) from t1 union select t1.e from t1) or b not in (t1.e,b,e))),t1.e)))) FROM t1 WHERE 11<=coalesce((select max(t1.d) from t1 where coalesce((select ~d+t1.d-case when c not in (t1.b-f,19+~coalesce((select t1.a from t1 where t1.f<=b),case when not (e not between f and t1.e) then (t1.e)-d else b end), -t1.d) then 17 when t1.d not between 13 and t1.d then d else (c) end from t1 where c>t1.a),t1.b)<d),t1.c)}\n} {0}\ndo_test randexpr-2.1365 {\n  db eval {SELECT case when (c between 11 and t1.e*t1.a | c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and  - -11<>13 and t1.b not between  -b and d then 19 else a end FROM t1 WHERE 19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else  -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when  -count(*) then cast(avg(f) AS integer) else  -(max(c)) end from t1) and t1.c}\n} {400}\ndo_test randexpr-2.1366 {\n  db eval {SELECT case when (c between 11 and t1.e*t1.a | c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and  - -11<>13 and t1.b not between  -b and d then 19 else a end FROM t1 WHERE NOT (19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else  -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when  -count(*) then cast(avg(f) AS integer) else  -(max(c)) end from t1) and t1.c)}\n} {}\ndo_test randexpr-2.1367 {\n  db eval {SELECT case when (c between 11 and t1.e*t1.a & c) then case when (case when (b=(select max((t1.c))-min(t1.d) from t1)*b) then t1.c else 17 end-e>t1.d and a between d and d) then c else d end when exists(select 1 from t1 where (11)>19) or a in (t1.b,(t1.c),(a)) and  - -11<>13 and t1.b not between  -b and d then 19 else a end FROM t1 WHERE 19 | t1.d not between (select ~case case count(distinct t1.c) when (count(*)) then ~~~count(*) else  -count(*)- -max(coalesce((select max(19) from t1 where (abs(t1.b-b)/abs(d))+11<a and 17>=t1.a),11))*max(t1.e) | count(*)-abs(max((c)))*max(t1.d) end when  -count(*) then cast(avg(f) AS integer) else  -(max(c)) end from t1) and t1.c}\n} {100}\ndo_test randexpr-2.1368 {\n  db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c | coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case  -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19))))}\n} {}\ndo_test randexpr-2.1369 {\n  db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c | coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE NOT (t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case  -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19)))))}\n} {600}\ndo_test randexpr-2.1370 {\n  db eval {SELECT case when not exists(select 1 from t1 where t1.c not in (t1.d,17,t1.c & coalesce((select t1.f from t1 where t1.c*t1.c-t1.e not in (t1.e*(case when (f) not between c and +f then (a) else t1.e end)+17,13, -((t1.a))) and f not between f and t1.d), -t1.e))) then (abs(e)/abs(a)) when 17<17 or 13<>a then f else (f) end FROM t1 WHERE NOT (t1.f in (e,(19),case when not exists(select 1 from t1 where coalesce((select max( -(abs(case  -t1.d when t1.d*13+coalesce((select a from t1 where d>19),t1.c) then f else b end)/abs(t1.b))) from t1 where f in (t1.a,t1.d,(c))),t1.d)+c+17<t1.b) then t1.c*t1.b else d end) and (((17 not in (17,t1.c,19)))))}\n} {600}\ndo_test randexpr-2.1371 {\n  db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case  -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then  -e else  - -13 end+d | t1.d FROM t1 WHERE ((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when  - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else  -t1.a end when t1.f then e else t1.d end<a then t1.a when b between  -a and t1.d then  -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and  -17<=a),t1.d))}\n} {413}\ndo_test randexpr-2.1372 {\n  db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case  -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then  -e else  - -13 end+d | t1.d FROM t1 WHERE NOT (((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when  - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else  -t1.a end when t1.f then e else t1.d end<a then t1.a when b between  -a and t1.d then  -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and  -17<=a),t1.d)))}\n} {}\ndo_test randexpr-2.1373 {\n  db eval {SELECT case +b when coalesce((select max(b) from t1 where exists(select 1 from t1 where (((+~13) in (select case cast(avg(t1.e+(11)+t1.b*e) AS integer) when max(((t1.e))) then min(b)-case  -cast(avg(17) AS integer) when min(e) then cast(avg(t1.c) AS integer) else (max(d)) end-count(distinct t1.f) else count(distinct d) end+count(*) from t1 union select max(d) from t1))))),(abs(~d)/abs(11))) then  -e else  - -13 end+d & t1.d FROM t1 WHERE ((a)>coalesce((select max(coalesce((select max(case when case case when 19 in (select case min(11) when  - -cast(avg(c) AS integer) then count(*) else count(*) end-cast(avg(19) AS integer) | cast(avg(17) AS integer) from t1 union select min(t1.d) from t1) then t1.b*t1.a else  -t1.a end when t1.f then e else t1.d end<a then t1.a when b between  -a and t1.d then  -a else t1.f end) from t1 where b<>d),t1.d)) from t1 where t1.c<>e and  -17<=a),t1.d))}\n} {400}\ndo_test randexpr-2.1374 {\n  db eval {SELECT +c+case when (~t1.e in (+(select case cast(avg(17) AS integer)+min(19)+count(*) when  -max(c) then count(distinct t1.c) else  - - -(max(13)) end*count(distinct ( -17)) from t1)-case when d+case when f<>d or t1.d<=t1.e then t1.a else  -11 end in (select cast(avg(t1.e) AS integer) from t1 union select cast(avg(b) AS integer) from t1) then 19 when ((t1.c) between e and a and  -13 not in (d,f,e)) then t1.e else d end,a,t1.b)) then case when t1.b<19 then 13 else 19 end else t1.c end FROM t1 WHERE not exists(select 1 from t1 where 19>t1.f+coalesce((select 13 from t1 where t1.d in (coalesce((select max(e) from t1 where c<t1.c),case when exists(select 1 from t1 where not exists(select 1 from t1 where not (coalesce((select 19 from t1 where case when not exists(select 1 from t1 where 17<17) then t1.f else a end>=t1.c),t1.d) between t1.b and c))) then  -f+(t1.b)-t1.e-t1.c+t1.c when c in (select  -( -f) from t1 union select 13 from t1) then t1.e else t1.a end),t1.b,a)),11))}\n} {600}\ndo_test randexpr-2.1375 {\n  db eval {SELECT +c+case when (~t1.e in (+(select case cast(avg(17) AS integer)+min(19)+count(*) when  -max(c) then count(distinct t1.c) else  - - -(max(13)) end*count(distinct ( -17)) from t1)-case when d+case when f<>d or t1.d<=t1.e then t1.a else  -11 end in (select cast(avg(t1.e) AS integer) from t1 union select cast(avg(b) AS integer) from t1) then 19 when ((t1.c) between e and a and  -13 not in (d,f,e)) then t1.e else d end,a,t1.b)) then case when t1.b<19 then 13 else 19 end else t1.c end FROM t1 WHERE NOT (not exists(select 1 from t1 where 19>t1.f+coalesce((select 13 from t1 where t1.d in (coalesce((select max(e) from t1 where c<t1.c),case when exists(select 1 from t1 where not exists(select 1 from t1 where not (coalesce((select 19 from t1 where case when not exists(select 1 from t1 where 17<17) then t1.f else a end>=t1.c),t1.d) between t1.b and c))) then  -f+(t1.b)-t1.e-t1.c+t1.c when c in (select  -( -f) from t1 union select 13 from t1) then t1.e else t1.a end),t1.b,a)),11)))}\n} {}\ndo_test randexpr-2.1376 {\n  db eval {SELECT (17-t1.e-17*t1.d+coalesce((select  -(abs(t1.a)/abs(t1.e))-t1.e*13*c*c-c from t1 where coalesce((select max(t1.a) from t1 where +case when t1.a not in (e,(t1.b),t1.f) then 11 when t1.b not between t1.c and t1.c then d else b end not in (13,t1.c,b)),f) between f and 11),d)-t1.d)-f+13 FROM t1 WHERE t1.f<>case when 11 in (coalesce((select e from t1 where not exists(select 1 from t1 where not case when t1.c between 11 and f then +t1.d else (((abs(coalesce((select  -t1.c from t1 where (c in (b,b,t1.e))),13) | t1.e*t1.d)/abs(c))-t1.f)) end-t1.d<a and a>=c)),t1.e),d,t1.e) or t1.b<t1.a then 13 when 11=a then t1.a else t1.a end}\n} {-7870}\ndo_test randexpr-2.1377 {\n  db eval {SELECT (17-t1.e-17*t1.d+coalesce((select  -(abs(t1.a)/abs(t1.e))-t1.e*13*c*c-c from t1 where coalesce((select max(t1.a) from t1 where +case when t1.a not in (e,(t1.b),t1.f) then 11 when t1.b not between t1.c and t1.c then d else b end not in (13,t1.c,b)),f) between f and 11),d)-t1.d)-f+13 FROM t1 WHERE NOT (t1.f<>case when 11 in (coalesce((select e from t1 where not exists(select 1 from t1 where not case when t1.c between 11 and f then +t1.d else (((abs(coalesce((select  -t1.c from t1 where (c in (b,b,t1.e))),13) | t1.e*t1.d)/abs(c))-t1.f)) end-t1.d<a and a>=c)),t1.e),d,t1.e) or t1.b<t1.a then 13 when 11=a then t1.a else t1.a end)}\n} {}\ndo_test randexpr-2.1378 {\n  db eval {SELECT case +c when 19*t1.b*coalesce((select t1.b-(19* -case when (coalesce((select t1.a from t1 where c>=e or t1.a not in (t1.c,e,t1.f)),t1.b)+19<=t1.a) then ((b)) when d>=b or d not between 19 and t1.e then t1.c else t1.b end-t1.a*f) from t1 where 13 between t1.f and t1.b or e not in (t1.e,b,19)),t1.a) then d else t1.a end FROM t1 WHERE  -b>=(select max(19) from t1)}\n} {}\ndo_test randexpr-2.1379 {\n  db eval {SELECT case +c when 19*t1.b*coalesce((select t1.b-(19* -case when (coalesce((select t1.a from t1 where c>=e or t1.a not in (t1.c,e,t1.f)),t1.b)+19<=t1.a) then ((b)) when d>=b or d not between 19 and t1.e then t1.c else t1.b end-t1.a*f) from t1 where 13 between t1.f and t1.b or e not in (t1.e,b,19)),t1.a) then d else t1.a end FROM t1 WHERE NOT ( -b>=(select max(19) from t1))}\n} {100}\ndo_test randexpr-2.1380 {\n  db eval {SELECT d+(abs(case t1.e when e*(abs(17)/abs(b)) then f else case when not not 13=c then coalesce((select t1.b from t1 where ((e-11 in (select 19 from t1 union select 17 from t1))) or f>=f),d) else case when c in (t1.a,t1.c,d) then t1.e when  -11 in (t1.a,e,t1.d) then t1.a else 19 end end-t1.e end*19)/abs(t1.c))-t1.e+d*t1.f FROM t1 WHERE t1.d+t1.c*coalesce((select e from t1 where coalesce((select max(t1.f) from t1 where not f in (select abs(case min(case when a not between a and f then 17 when e>17 then t1.d else 13 end) when abs(case cast(avg(t1.a) AS integer) when  -min(t1.b) then count(distinct 17) else (count(distinct t1.a)) end)-count(distinct  -b) then count(distinct d) else max(t1.f) end)+count(*)*max(e) from t1 union select (cast(avg(t1.c) AS integer)) from t1)),b*case 19 when t1.a then 11 else e end)<=f),17)=c}\n} {}\ndo_test randexpr-2.1381 {\n  db eval {SELECT d+(abs(case t1.e when e*(abs(17)/abs(b)) then f else case when not not 13=c then coalesce((select t1.b from t1 where ((e-11 in (select 19 from t1 union select 17 from t1))) or f>=f),d) else case when c in (t1.a,t1.c,d) then t1.e when  -11 in (t1.a,e,t1.d) then t1.a else 19 end end-t1.e end*19)/abs(t1.c))-t1.e+d*t1.f FROM t1 WHERE NOT (t1.d+t1.c*coalesce((select e from t1 where coalesce((select max(t1.f) from t1 where not f in (select abs(case min(case when a not between a and f then 17 when e>17 then t1.d else 13 end) when abs(case cast(avg(t1.a) AS integer) when  -min(t1.b) then count(distinct 17) else (count(distinct t1.a)) end)-count(distinct  -b) then count(distinct d) else max(t1.f) end)+count(*)*max(e) from t1 union select (cast(avg(t1.c) AS integer)) from t1)),b*case 19 when t1.a then 11 else e end)<=f),17)=c)}\n} {239900}\ndo_test randexpr-2.1382 {\n  db eval {SELECT case when ~t1.b=t1.b-coalesce((select 17 from t1 where t1.d-a>=(abs(case when c*11 between 19+(select cast(avg(13*b) AS integer) from t1) and case t1.e-t1.f when t1.a then 11 else a end then 19 else 17 end-c+a)/abs(t1.a))),e) then (f) when exists(select 1 from t1 where (11) in (c,t1.c,t1.b)) then f else 19 end*t1.f FROM t1 WHERE case 19 when t1.b then b*case t1.a when +t1.f then e else 17+t1.a end-11++(select ~~abs(~count(*))+count(distinct 13) from t1)*t1.b-t1.c- -a else 17 end>=t1.e}\n} {}\ndo_test randexpr-2.1383 {\n  db eval {SELECT case when ~t1.b=t1.b-coalesce((select 17 from t1 where t1.d-a>=(abs(case when c*11 between 19+(select cast(avg(13*b) AS integer) from t1) and case t1.e-t1.f when t1.a then 11 else a end then 19 else 17 end-c+a)/abs(t1.a))),e) then (f) when exists(select 1 from t1 where (11) in (c,t1.c,t1.b)) then f else 19 end*t1.f FROM t1 WHERE NOT (case 19 when t1.b then b*case t1.a when +t1.f then e else 17+t1.a end-11++(select ~~abs(~count(*))+count(distinct 13) from t1)*t1.b-t1.c- -a else 17 end>=t1.e)}\n} {11400}\ndo_test randexpr-2.1384 {\n  db eval {SELECT case when t1.a<=e and d*(t1.d)+t1.d++a-t1.f-a<=e or c not between b and d and 19 not between t1.e and 11 or  -t1.b in (select b from t1 union select 17 from t1) and t1.d<>t1.e or t1.d in (select t1.c from t1 union select t1.d from t1) then t1.e else 17 end+f+t1.b FROM t1 WHERE t1.c*~case 19+coalesce((select 19 from t1 where e>11-d),t1.e) when coalesce((select max(11) from t1 where not t1.f in (select ~abs(cast(avg(coalesce((select max(b+f) from t1 where  -f=(t1.b) and a between t1.c and t1.b),a)) AS integer))+ -count(distinct t1.b)- -max(f)*max((f)) from t1 union select min(t1.e) from t1) or a in (select +d*d from t1 union select t1.c from t1)),t1.e) then t1.d else t1.c end*t1.b<t1.b}\n} {1300}\ndo_test randexpr-2.1385 {\n  db eval {SELECT case when t1.a<=e and d*(t1.d)+t1.d++a-t1.f-a<=e or c not between b and d and 19 not between t1.e and 11 or  -t1.b in (select b from t1 union select 17 from t1) and t1.d<>t1.e or t1.d in (select t1.c from t1 union select t1.d from t1) then t1.e else 17 end+f+t1.b FROM t1 WHERE NOT (t1.c*~case 19+coalesce((select 19 from t1 where e>11-d),t1.e) when coalesce((select max(11) from t1 where not t1.f in (select ~abs(cast(avg(coalesce((select max(b+f) from t1 where  -f=(t1.b) and a between t1.c and t1.b),a)) AS integer))+ -count(distinct t1.b)- -max(f)*max((f)) from t1 union select min(t1.e) from t1) or a in (select +d*d from t1 union select t1.c from t1)),t1.e) then t1.d else t1.c end*t1.b<t1.b)}\n} {}\ndo_test randexpr-2.1386 {\n  db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c | 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end)}\n} {40200}\ndo_test randexpr-2.1387 {\n  db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c | 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end))}\n} {}\ndo_test randexpr-2.1388 {\n  db eval {SELECT coalesce((select 17 from t1 where (~f=(abs(coalesce((select t1.d from t1 where case (select count(distinct c & 13)- -(cast(avg(11) AS integer)) from t1)+coalesce((select 19 from t1 where d in (select t1.c from t1 union select 17 from t1)),t1.f) when e then t1.c else t1.d end*d<=19 and not exists(select 1 from t1 where (e)<>b)),e)-13)/abs(t1.e))+17)),t1.a)*t1.d+b FROM t1 WHERE not exists(select 1 from t1 where t1.b=case 19 when f then d+case when t1.c not between 13 and d | (select abs((min(17) | (min(t1.f)))) from t1) and coalesce((select max(11*19) from t1 where not exists(select 1 from t1 where (e>=t1.b))),11) not in (t1.c,19,t1.c) or t1.a in (select count(*) from t1 union select max(c)+cast(avg(11) AS integer) from t1) and (c) not between t1.a and t1.d and t1.b between 11 and a then t1.d else c end else (t1.f) end)}\n} {40200}\ndo_test randexpr-2.1389 {\n  db eval {SELECT coalesce((select max(t1.f+19+case  -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) | t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE (exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b)))}\n} {-98470}\ndo_test randexpr-2.1390 {\n  db eval {SELECT coalesce((select max(t1.f+19+case  -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) | t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE NOT ((exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b))))}\n} {}\ndo_test randexpr-2.1391 {\n  db eval {SELECT coalesce((select max(t1.f+19+case  -d when t1.f then t1.e else e end+case when +d in (select case when exists(select 1 from t1 where coalesce((select max( -17-d+t1.b-t1.d) from t1 where e not in (f,t1.e,11)),c) & t1.e>=c) then b else d end from t1 union select c from t1) then t1.b else d end-e*b+11) from t1 where f<>t1.b),d) FROM t1 WHERE (exists(select 1 from t1 where f> -t1.a*11 or e in (a-~ -t1.e,+a | e*case when coalesce((select t1.c from t1 where t1.f in (select (count(*)) from t1 union select ((count(*))) from t1)),a)-t1.e not in (e,t1.a,d) or 19 in (t1.b,t1.c,13) and c>19 then b*d else ( -t1.d) end-t1.a*t1.b*19,b)))}\n} {-98670}\ndo_test randexpr-2.1392 {\n  db eval {SELECT case t1.b* -(abs(e)/abs(d+b)) when ~a-11 then coalesce((select max(case when (~~19- -t1.d<t1.f or t1.e>=f) then +(abs(t1.c)/abs(t1.e)) when (t1.d>e or t1.a>=t1.a) then 19 else t1.a end*b-(19)-a-t1.c) from t1 where t1.f>=11),13) else b end FROM t1 WHERE (not exists(select 1 from t1 where t1.e<=t1.f) or c- -e*17 in (t1.c+c, -b-17, -coalesce((select case when +coalesce((select max(coalesce((select t1.f from t1 where t1.d in (select max(t1.d)-count(*) from t1 union select max( -t1.a) from t1)),e)+11) from t1 where ( -19)>=t1.a),t1.e)-13 not between t1.a and d then t1.d else 19 end+t1.b from t1 where t1.d<>19),11)))}\n} {}\ndo_test randexpr-2.1393 {\n  db eval {SELECT case t1.b* -(abs(e)/abs(d+b)) when ~a-11 then coalesce((select max(case when (~~19- -t1.d<t1.f or t1.e>=f) then +(abs(t1.c)/abs(t1.e)) when (t1.d>e or t1.a>=t1.a) then 19 else t1.a end*b-(19)-a-t1.c) from t1 where t1.f>=11),13) else b end FROM t1 WHERE NOT ((not exists(select 1 from t1 where t1.e<=t1.f) or c- -e*17 in (t1.c+c, -b-17, -coalesce((select case when +coalesce((select max(coalesce((select t1.f from t1 where t1.d in (select max(t1.d)-count(*) from t1 union select max( -t1.a) from t1)),e)+11) from t1 where ( -19)>=t1.a),t1.e)-13 not between t1.a and d then t1.d else 19 end+t1.b from t1 where t1.d<>19),11))))}\n} {200}\ndo_test randexpr-2.1394 {\n  db eval {SELECT (select case case min(d-t1.c)-max(t1.a) when ~count(distinct d+case  -f*t1.d+11 when b then b else b end)-min(c) then case +max(t1.a)*~abs(count(*)) when  -min(13) then max(17) else count(*) end else  -max(e) end when max(t1.a) then max(d) else max(17) end-count(distinct t1.b) from t1)-(d) FROM t1 WHERE +19 between b*11 and (select max(d-13) | ~+~+~((count(*)))*cast(avg(b) AS integer) from t1)+b}\n} {}\ndo_test randexpr-2.1395 {\n  db eval {SELECT (select case case min(d-t1.c)-max(t1.a) when ~count(distinct d+case  -f*t1.d+11 when b then b else b end)-min(c) then case +max(t1.a)*~abs(count(*)) when  -min(13) then max(17) else count(*) end else  -max(e) end when max(t1.a) then max(d) else max(17) end-count(distinct t1.b) from t1)-(d) FROM t1 WHERE NOT (+19 between b*11 and (select max(d-13) | ~+~+~((count(*)))*cast(avg(b) AS integer) from t1)+b)}\n} {-384}\ndo_test randexpr-2.1396 {\n  db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e | 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE (coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and  -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a)}\n} {45}\ndo_test randexpr-2.1397 {\n  db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e | 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE NOT ((coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and  -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a))}\n} {}\ndo_test randexpr-2.1398 {\n  db eval {SELECT (abs(case when +a*t1.e+(abs(t1.e & 11+coalesce((select max(d) from t1 where (not not b<coalesce((select e from t1 where e<>19),17)) and t1.b>13 and d=t1.a and 13 in (d,t1.a,11)),t1.e)*d)/abs(11+t1.a-19))=c or b<>c then t1.e when b<>19 then 17 else b end)/abs(11)) FROM t1 WHERE (coalesce((select max(case when exists(select 1 from t1 where coalesce((select a from t1 where not 19-~(coalesce((select t1.d from t1 where d between e and 17),t1.a)-t1.a-17) in (t1.d,t1.e,19)),19)*11*d in (select d from t1 union select t1.b from t1)) then c when d between t1.a and  -19 then t1.e else 19 end-d*c) from t1 where (t1.f>=t1.c)),11)) not in (17,17,a)}\n} {45}\ndo_test randexpr-2.1399 {\n  db eval {SELECT 19+(t1.f)*case coalesce((select max(b) from t1 where not f not between coalesce((select (select (count(distinct t1.c))+ -max( -(f)) from t1)+t1.c from t1 where t1.c<=d),17)-c-19 and 17 or f<>13),case when not exists(select 1 from t1 where ((a)) between b and t1.f) then c when not ( -f not in (t1.b,t1.a,t1.c)) then  -t1.b else 19 end)-t1.d-t1.e when t1.e then 11 else 19 end FROM t1 WHERE not not exists(select 1 from t1 where not 11=c and a*e between coalesce((select max(t1.e) from t1 where f=t1.b*19+case when (e not in (t1.d,t1.d, -c) or t1.a<e or 13 in (select  - -count(*) from t1 union select min(17) from t1)) then t1.c when  -19 in (13,f,e) then  -t1.d else 17 end+t1.b*d),f)*d and t1.a)}\n} {}\ndo_test randexpr-2.1400 {\n  db eval {SELECT 19+(t1.f)*case coalesce((select max(b) from t1 where not f not between coalesce((select (select (count(distinct t1.c))+ -max( -(f)) from t1)+t1.c from t1 where t1.c<=d),17)-c-19 and 17 or f<>13),case when not exists(select 1 from t1 where ((a)) between b and t1.f) then c when not ( -f not in (t1.b,t1.a,t1.c)) then  -t1.b else 19 end)-t1.d-t1.e when t1.e then 11 else 19 end FROM t1 WHERE NOT (not not exists(select 1 from t1 where not 11=c and a*e between coalesce((select max(t1.e) from t1 where f=t1.b*19+case when (e not in (t1.d,t1.d, -c) or t1.a<e or 13 in (select  - -count(*) from t1 union select min(17) from t1)) then t1.c when  -19 in (13,f,e) then  -t1.d else 17 end+t1.b*d),f)*d and t1.a))}\n} {11419}\ndo_test randexpr-2.1401 {\n  db eval {SELECT coalesce((select max(19) from t1 where e-coalesce((select 13 from t1 where exists(select 1 from t1 where ((+(case when d*t1.b not in (t1.d,t1.f,e) then 11 else t1.c end))+19*11+e<=11))),19+t1.d) between t1.c and  -e and exists(select 1 from t1 where t1.d=c and exists(select 1 from t1 where exists(select 1 from t1 where t1.f=b and a in (19,t1.b,d) or t1.b=11) or t1.c>19) or t1.d=a)),19) FROM t1 WHERE t1.c not between f and d}\n} {19}\ndo_test randexpr-2.1402 {\n  db eval {SELECT coalesce((select max(19) from t1 where e-coalesce((select 13 from t1 where exists(select 1 from t1 where ((+(case when d*t1.b not in (t1.d,t1.f,e) then 11 else t1.c end))+19*11+e<=11))),19+t1.d) between t1.c and  -e and exists(select 1 from t1 where t1.d=c and exists(select 1 from t1 where exists(select 1 from t1 where t1.f=b and a in (19,t1.b,d) or t1.b=11) or t1.c>19) or t1.d=a)),19) FROM t1 WHERE NOT (t1.c not between f and d)}\n} {}\ndo_test randexpr-2.1403 {\n  db eval {SELECT case e when (t1.e+case when t1.e not between t1.c and case when d+coalesce((select t1.d+13+case case a when t1.a then t1.b else t1.c end when 17 then t1.b else f end+19 from t1 where exists(select 1 from t1 where t1.f< -17)),11)>=d then 13 else 13 end*(t1.c) then  -c when t1.e not between t1.f and t1.d then t1.a else ( - -t1.a) end-d) then t1.a else t1.d end FROM t1 WHERE t1.d between case when  -(t1.e-c)+a between  -+coalesce((select max(+t1.c) from t1 where (coalesce((select max(case when d>~t1.e then t1.c when t1.f in (select t1.d from t1 union select t1.e from t1) then (19) else t1.e end) from t1 where not exists(select 1 from t1 where t1.e< -(11))),t1.f) in (select min(t1.f) from t1 union select count(distinct 13) from t1))),t1.e) and t1.d then a when 13<=c then b else t1.c end-c and f}\n} {400}\ndo_test randexpr-2.1404 {\n  db eval {SELECT case e when (t1.e+case when t1.e not between t1.c and case when d+coalesce((select t1.d+13+case case a when t1.a then t1.b else t1.c end when 17 then t1.b else f end+19 from t1 where exists(select 1 from t1 where t1.f< -17)),11)>=d then 13 else 13 end*(t1.c) then  -c when t1.e not between t1.f and t1.d then t1.a else ( - -t1.a) end-d) then t1.a else t1.d end FROM t1 WHERE NOT (t1.d between case when  -(t1.e-c)+a between  -+coalesce((select max(+t1.c) from t1 where (coalesce((select max(case when d>~t1.e then t1.c when t1.f in (select t1.d from t1 union select t1.e from t1) then (19) else t1.e end) from t1 where not exists(select 1 from t1 where t1.e< -(11))),t1.f) in (select min(t1.f) from t1 union select count(distinct 13) from t1))),t1.e) and t1.d then a when 13<=c then b else t1.c end-c and f)}\n} {}\ndo_test randexpr-2.1405 {\n  db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between  -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) |  -count(distinct t1.f) from t1) FROM t1 WHERE (e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a}\n} {}\ndo_test randexpr-2.1406 {\n  db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between  -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) |  -count(distinct t1.f) from t1) FROM t1 WHERE NOT ((e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a)}\n} {-1}\ndo_test randexpr-2.1407 {\n  db eval {SELECT (select abs(min(case when d not between coalesce((select max(case case t1.e when e-t1.f-a then case when (not exists(select 1 from t1 where coalesce((select max(t1.f) from t1 where 19<>17 and e not between  -13 and t1.a),t1.c)>=t1.e)) then (select abs(cast(avg(17) AS integer)) from t1) when c between e and 17 then (select (count(*)) from t1) else 11 end else 11 end when e then 11 else a end) from t1 where t1.b>t1.b),t1.e) and 13 then t1.d else 17 end))*min(b) &  -count(distinct t1.f) from t1) FROM t1 WHERE NOT ((e) in (select +t1.f from t1 union select t1.f+coalesce((select t1.d+e from t1 where t1.f not in (t1.b,t1.f,e)),(19))*case when t1.a<=a and t1.e<=e then t1.d else t1.c end from t1) and (t1.c not between 11 and e) or d in (select count(*)-cast(avg(t1.a) AS integer) from t1 union select max(19) from t1) and not t1.a not in (11,t1.d,b) or 17>=t1.a)}\n} {80000}\ndo_test randexpr-2.1408 {\n  db eval {SELECT case when ++coalesce((select (abs(a)/abs((select max((abs(13*f)/abs(t1.d))-t1.d*t1.e) from t1)))+b-t1.c+(select +(cast(avg(c) AS integer))*count(*) from t1)-t1.d-b*t1.e+19 from t1 where t1.c not between 11 and t1.d),19)<=t1.d then t1.d when not exists(select 1 from t1 where  -11=t1.a) then e else 11 end FROM t1 WHERE (coalesce((select max(coalesce((select a-19 | ~~t1.b from t1 where (abs(t1.f)/abs(b)) not between case when t1.d<=case when not exists(select 1 from t1 where 19<=t1.d) then case when t1.a<=c then f else t1.d end when d>=17 then t1.c else (b) end*t1.c then  - -t1.c when c<>t1.a then t1.f else 11 end and e),t1.e)-(t1.a)) from t1 where e<=a),17)<=t1.e) and t1.d=(f)}\n} {}\ndo_test randexpr-2.1409 {\n  db eval {SELECT case when ++coalesce((select (abs(a)/abs((select max((abs(13*f)/abs(t1.d))-t1.d*t1.e) from t1)))+b-t1.c+(select +(cast(avg(c) AS integer))*count(*) from t1)-t1.d-b*t1.e+19 from t1 where t1.c not between 11 and t1.d),19)<=t1.d then t1.d when not exists(select 1 from t1 where  -11=t1.a) then e else 11 end FROM t1 WHERE NOT ((coalesce((select max(coalesce((select a-19 | ~~t1.b from t1 where (abs(t1.f)/abs(b)) not between case when t1.d<=case when not exists(select 1 from t1 where 19<=t1.d) then case when t1.a<=c then f else t1.d end when d>=17 then t1.c else (b) end*t1.c then  - -t1.c when c<>t1.a then t1.f else 11 end and e),t1.e)-(t1.a)) from t1 where e<=a),17)<=t1.e) and t1.d=(f))}\n} {400}\ndo_test randexpr-2.1410 {\n  db eval {SELECT c*t1.c*(abs(case 11 when case when 11*11 not between b and t1.a then t1.d else  -coalesce((select t1.c from t1 where (not exists(select 1 from t1 where e*~13 not in (a*t1.c, -t1.a,case when 13=t1.c or 13 between 11 and a then  - -a when e<=t1.e then 13 else 11 end)))),t1.b+t1.b) end then t1.c else ((e)) end)/abs(t1.a))+t1.a-e-13 FROM t1 WHERE t1.a*13+case when (select count(distinct b++(select case count(distinct 19*(select  -+min((13*f))-count(distinct t1.c)-max(t1.e) | (count(distinct 11)) from t1)*(f)) when count(*) then min(a)+(cast(avg(t1.d) AS integer)) else  -min(17) end from t1) | t1.c-f) from t1)>t1.b then 19 else c end+17<c}\n} {}\ndo_test randexpr-2.1411 {\n  db eval {SELECT c*t1.c*(abs(case 11 when case when 11*11 not between b and t1.a then t1.d else  -coalesce((select t1.c from t1 where (not exists(select 1 from t1 where e*~13 not in (a*t1.c, -t1.a,case when 13=t1.c or 13 between 11 and a then  - -a when e<=t1.e then 13 else 11 end)))),t1.b+t1.b) end then t1.c else ((e)) end)/abs(t1.a))+t1.a-e-13 FROM t1 WHERE NOT (t1.a*13+case when (select count(distinct b++(select case count(distinct 19*(select  -+min((13*f))-count(distinct t1.c)-max(t1.e) | (count(distinct 11)) from t1)*(f)) when count(*) then min(a)+(cast(avg(t1.d) AS integer)) else  -min(17) end from t1) | t1.c-f) from t1)>t1.b then 19 else c end+17<c)}\n} {449587}\ndo_test randexpr-2.1412 {\n  db eval {SELECT ~coalesce((select b from t1 where b between e and case when t1.c+coalesce((select 11 from t1 where (a in (+d-11,t1.f-a,b)) and t1.c in (select t1.f from t1 union select c from t1) or b between 13 and t1.b and t1.e<(c) and a>=t1.c and e between d and t1.f),case when (13)<>(t1.e) then d when t1.a<=t1.e then 13 else d end) not in (17,b,17) then t1.d else t1.a end+a),t1.d) FROM t1 WHERE case t1.f when 11 then t1.e | f*case when ((select max(17) from t1) | 11>17+~coalesce((select max(t1.b) from t1 where (coalesce((select max(t1.e) from t1 where t1.e in (select (cast(avg( -t1.a) AS integer)) from t1 union select count(*) from t1)),a)) in (t1.f,a,t1.e)),f)+17) then t1.a when 19 in (t1.c, -e,11) or not exists(select 1 from t1 where t1.e between d and a) then 13 else 19 end+t1.f else 11 end<17}\n} {-401}\ndo_test randexpr-2.1413 {\n  db eval {SELECT ~coalesce((select b from t1 where b between e and case when t1.c+coalesce((select 11 from t1 where (a in (+d-11,t1.f-a,b)) and t1.c in (select t1.f from t1 union select c from t1) or b between 13 and t1.b and t1.e<(c) and a>=t1.c and e between d and t1.f),case when (13)<>(t1.e) then d when t1.a<=t1.e then 13 else d end) not in (17,b,17) then t1.d else t1.a end+a),t1.d) FROM t1 WHERE NOT (case t1.f when 11 then t1.e | f*case when ((select max(17) from t1) | 11>17+~coalesce((select max(t1.b) from t1 where (coalesce((select max(t1.e) from t1 where t1.e in (select (cast(avg( -t1.a) AS integer)) from t1 union select count(*) from t1)),a)) in (t1.f,a,t1.e)),f)+17) then t1.a when 19 in (t1.c, -e,11) or not exists(select 1 from t1 where t1.e between d and a) then 13 else 19 end+t1.f else 11 end<17)}\n} {}\ndo_test randexpr-2.1414 {\n  db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end | case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 | d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE (case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select  -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11)}\n} {}\ndo_test randexpr-2.1415 {\n  db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end | case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 | d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE NOT ((case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select  -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11))}\n} {-645}\ndo_test randexpr-2.1416 {\n  db eval {SELECT ~case when (a<> -++ -11) then e+case when c*t1.a<t1.d then 19 when not not 11>d then t1.a else b end else a end & case when not exists(select 1 from t1 where not exists(select 1 from t1 where 13 & d in (select a from t1 union select d from t1))) or t1.f not between c and 19 then +t1.a else c-a end-17*c FROM t1 WHERE NOT ((case when (case when b in (select 11*coalesce((select 11 from t1 where (d not between 13 and 13+17)),coalesce((select max(13) from t1 where t1.c in (select max(e) from t1 union select count(*) from t1)),t1.b)) from t1 union select  -t1.e from t1) then 13 when t1.f in ( -f, -(f),c) then 19 else f end in (select t1.a from t1 union select (t1.c) from t1)) then (abs(19)/abs(t1.b)) when (e in (b,11,19)) and t1.a<c then 19 else a end between d and 11))}\n} {-5056}\ndo_test randexpr-2.1417 {\n  db eval {SELECT case when t1.d in (select case when exists(select 1 from t1 where 13>19) then  -d when ~c in (select min(e) from t1 union select cast(avg(case when c not between b and t1.a then b else 13-e+t1.e end) AS integer) from t1) then 13-coalesce((select max(coalesce((select max(19) from t1 where (17=a)),13)) from t1 where t1.a>=c),a) else t1.d end*(t1.c) from t1 union select (11) from t1) then a when b not in (e,t1.f,13) then t1.f else 13 end FROM t1 WHERE 13<>e or t1.a in (select f from t1 union select f from t1)}\n} {600}\ndo_test randexpr-2.1418 {\n  db eval {SELECT case when t1.d in (select case when exists(select 1 from t1 where 13>19) then  -d when ~c in (select min(e) from t1 union select cast(avg(case when c not between b and t1.a then b else 13-e+t1.e end) AS integer) from t1) then 13-coalesce((select max(coalesce((select max(19) from t1 where (17=a)),13)) from t1 where t1.a>=c),a) else t1.d end*(t1.c) from t1 union select (11) from t1) then a when b not in (e,t1.f,13) then t1.f else 13 end FROM t1 WHERE NOT (13<>e or t1.a in (select f from t1 union select f from t1))}\n} {}\ndo_test randexpr-2.1419 {\n  db eval {SELECT 17-(select case max(t1.f*~case when 17>=b then t1.d else t1.a end) when (count(distinct t1.c)) then count(distinct t1.d+~13*19) else  -min((select +case abs(count(*)) when abs(+count(*)) then ~case count(distinct a) when max(t1.c) then max(t1.c) else min(t1.f) end+max(17) else count(*) end from t1))- -cast(avg(f) AS integer)-min(a) end from t1) FROM t1 WHERE (select count(*) from t1) in (select abs(min(coalesce((select t1.d from t1 where coalesce((select max((t1.d)) from t1 where not b+t1.e*(select min(t1.a+t1.e) from t1)<=(abs(t1.d)/abs(t1.c))+t1.d),f*17+d+case when f between e and d and t1.c= -c then ~13 when b not between 11 and e then (11) else e end+t1.d)=13),t1.e))) from t1 union select (cast(avg(b) AS integer)) from t1)}\n} {}\ndo_test randexpr-2.1420 {\n  db eval {SELECT 17-(select case max(t1.f*~case when 17>=b then t1.d else t1.a end) when (count(distinct t1.c)) then count(distinct t1.d+~13*19) else  -min((select +case abs(count(*)) when abs(+count(*)) then ~case count(distinct a) when max(t1.c) then max(t1.c) else min(t1.f) end+max(17) else count(*) end from t1))- -cast(avg(f) AS integer)-min(a) end from t1) FROM t1 WHERE NOT ((select count(*) from t1) in (select abs(min(coalesce((select t1.d from t1 where coalesce((select max((t1.d)) from t1 where not b+t1.e*(select min(t1.a+t1.e) from t1)<=(abs(t1.d)/abs(t1.c))+t1.d),f*17+d+case when f between e and d and t1.c= -c then ~13 when b not between 11 and e then (11) else e end+t1.d)=13),t1.e))) from t1 union select (cast(avg(b) AS integer)) from t1))}\n} {-1067}\ndo_test randexpr-2.1421 {\n  db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 | case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE (select  -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e}\n} {-20013}\ndo_test randexpr-2.1422 {\n  db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 | case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE NOT ((select  -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e)}\n} {}\ndo_test randexpr-2.1423 {\n  db eval {SELECT case when +coalesce((select 19 from t1 where c between f and 13),t1.f)<>t1.c*t1.d then coalesce((select max(d) from t1 where t1.d between t1.a and t1.a),t1.f-f)-(13 & case when 11 in (select abs(max(t1.b)*cast(avg(t1.c) AS integer))+count(*) from t1 union select count(distinct b) from t1) and t1.a not in (b,t1.a,e) or a not in (e,19,(t1.e)) then t1.b else 17+t1.a end*t1.a) when 13 in (select e from t1 union select c from t1) then a else e end FROM t1 WHERE (select  -count(*) from t1)*case when not coalesce((select max(11) from t1 where t1.f<>a),t1.a)<>b then c else ~case when not 19+13-t1.d=t1.d or c>c or (t1.a=t1.d) or 13>=a then a when t1.c not between 13 and 17 then (abs(13+t1.d-t1.a)/abs(b)) else d end end+a | 11<=e}\n} {0}\ndo_test randexpr-2.1424 {\n  db eval {SELECT case t1.d | t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end | b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE case when c<=13*t1.a then 11 else  -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b}\n} {200}\ndo_test randexpr-2.1425 {\n  db eval {SELECT case t1.d | t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end | b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE NOT (case when c<=13*t1.a then 11 else  -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b)}\n} {}\ndo_test randexpr-2.1426 {\n  db eval {SELECT case t1.d & t1.f+(e)+case when +t1.e-d*t1.a+17-b*(abs(t1.f)/abs( -a))-case when 19>=e then ~t1.a*case when t1.e>19 and t1.f<>d then t1.a else t1.d end & b*e else 17 end+t1.a=17 then t1.c else t1.b end when 17 then t1.b else t1.b end FROM t1 WHERE case when c<=13*t1.a then 11 else  -case when t1.f*e>= -((19)) then case when a>=t1.c then t1.d*e else b end else coalesce((select t1.b from t1 where 11+d-17-t1.d-t1.b not in (case d-17 when f then t1.d else t1.b end,e,t1.c)),t1.c) end*19 end<>b}\n} {200}\ndo_test randexpr-2.1427 {\n  db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) | 13)-d*e FROM t1 WHERE 11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1)}\n} {}\ndo_test randexpr-2.1428 {\n  db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) | 13)-d*e FROM t1 WHERE NOT (11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1))}\n} {-4771395}\ndo_test randexpr-2.1429 {\n  db eval {SELECT (coalesce((select max(~t1.d*19*t1.f) from t1 where (abs(17)/abs(t1.f-case when not exists(select 1 from t1 where case when a in (f,t1.a,c) then c when t1.a not in (13,t1.c,a) then e else t1.a end in (select abs(abs(min(t1.e))) from t1 union select cast(avg(11) AS integer) from t1)) or c<a then t1.f else a+d end-11))<>13 or t1.e in (e,t1.c,d)),t1.e) & 13)-d*e FROM t1 WHERE NOT (11 in (select max(+(select max(d | b) from t1)*17-e) from t1 union select (cast(avg(+a-+((coalesce((select t1.e from t1 where exists(select 1 from t1 where (abs( -case when coalesce((select max(b-17) from t1 where not exists(select 1 from t1 where t1.f not between a and 11)),t1.c) in (select t1.d from t1 union select (17) from t1) then t1.c else ( - -t1.d) end)/abs(t1.f))+11>f)),b)))*19) AS integer))-count(distinct t1.f) from t1))}\n} {-199992}\ndo_test randexpr-2.1430 {\n  db eval {SELECT coalesce((select t1.e from t1 where +~case when d-(abs(+t1.b)/abs( -19*t1.c-(select (abs( -cast(avg((abs(d)/abs(t1.d))) AS integer))) from t1)))+11<19 then t1.a-19-a-f when not (c in (case f when t1.a then 17 else 11 end-a,t1.d, -e)) then 17 else (t1.b) end<d),t1.d) FROM t1 WHERE exists(select 1 from t1 where f not between ~17+t1.e and coalesce((select max(t1.f) from t1 where 17+19=t1.c),case when case  -case when e not in (+c, - -19,t1.c) then 19 else (b)*t1.a end+t1.c when c then 19 else t1.d end<>(t1.b) then t1.d when (not exists(select 1 from t1 where t1.f<>t1.c)) then t1.b else 17 end-e)-19)}\n} {500}\ndo_test randexpr-2.1431 {\n  db eval {SELECT coalesce((select t1.e from t1 where +~case when d-(abs(+t1.b)/abs( -19*t1.c-(select (abs( -cast(avg((abs(d)/abs(t1.d))) AS integer))) from t1)))+11<19 then t1.a-19-a-f when not (c in (case f when t1.a then 17 else 11 end-a,t1.d, -e)) then 17 else (t1.b) end<d),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where f not between ~17+t1.e and coalesce((select max(t1.f) from t1 where 17+19=t1.c),case when case  -case when e not in (+c, - -19,t1.c) then 19 else (b)*t1.a end+t1.c when c then 19 else t1.d end<>(t1.b) then t1.d when (not exists(select 1 from t1 where t1.f<>t1.c)) then t1.b else 17 end-e)-19))}\n} {}\ndo_test randexpr-2.1432 {\n  db eval {SELECT case when (abs(17)/abs(t1.e))<t1.b then t1.d when (select count(distinct coalesce((select d from t1 where exists(select 1 from t1 where 19<(select abs(max(t1.b)) from t1)*case when t1.e>=case when (exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<>19))) then coalesce((select 11 from t1 where not exists(select 1 from t1 where t1.e not in ( -t1.d,(b),t1.d))),t1.a)+t1.f*11 else t1.a end then b else e end)),17)) from t1) not in (13,e,17) then t1.e else 11 end FROM t1 WHERE not (t1.e<>coalesce((select (case t1.c when (coalesce((select 19 from t1 where (case when not exists(select 1 from t1 where e not in (c,e,t1.f)) then t1.f | t1.a else t1.a end in (d,19,t1.a)) or t1.f<=t1.c),+13))*t1.b-t1.d then  -t1.c else b end) from t1 where 17<f), -e) or ((a)<=a)) or e<t1.e and  -(13) between 19 and 19}\n} {}\ndo_test randexpr-2.1433 {\n  db eval {SELECT case when (abs(17)/abs(t1.e))<t1.b then t1.d when (select count(distinct coalesce((select d from t1 where exists(select 1 from t1 where 19<(select abs(max(t1.b)) from t1)*case when t1.e>=case when (exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<>19))) then coalesce((select 11 from t1 where not exists(select 1 from t1 where t1.e not in ( -t1.d,(b),t1.d))),t1.a)+t1.f*11 else t1.a end then b else e end)),17)) from t1) not in (13,e,17) then t1.e else 11 end FROM t1 WHERE NOT (not (t1.e<>coalesce((select (case t1.c when (coalesce((select 19 from t1 where (case when not exists(select 1 from t1 where e not in (c,e,t1.f)) then t1.f | t1.a else t1.a end in (d,19,t1.a)) or t1.f<=t1.c),+13))*t1.b-t1.d then  -t1.c else b end) from t1 where 17<f), -e) or ((a)<=a)) or e<t1.e and  -(13) between 19 and 19)}\n} {400}\ndo_test randexpr-2.1434 {\n  db eval {SELECT (select max(t1.c) from t1) | case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then  -t1.f else f end)+count(*)-max(t1.f) | count(distinct t1.a) | cast(avg(t1.c) AS integer)) |  -max(a) from t1) end end FROM t1 WHERE a | t1.c in (select f from t1 union select case  -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when  -t1.b then t1.d else 19 end),a) end+d+e from t1)}\n} {}\ndo_test randexpr-2.1435 {\n  db eval {SELECT (select max(t1.c) from t1) | case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then  -t1.f else f end)+count(*)-max(t1.f) | count(distinct t1.a) | cast(avg(t1.c) AS integer)) |  -max(a) from t1) end end FROM t1 WHERE NOT (a | t1.c in (select f from t1 union select case  -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when  -t1.b then t1.d else 19 end),a) end+d+e from t1))}\n} {1391}\ndo_test randexpr-2.1436 {\n  db eval {SELECT (select max(t1.c) from t1) & case when d=(abs(t1.d)/abs(t1.b)) then 19 else case b when a then b+17+c-t1.d+d-a*t1.c else e+t1.f+ -(select abs(~+count(distinct case when b<d and t1.f<> -19 then e when a in (17,d,t1.f) then  -t1.f else f end)+count(*)-max(t1.f) & count(distinct t1.a) & cast(avg(t1.c) AS integer)) &  -max(a) from t1) end end FROM t1 WHERE NOT (a | t1.c in (select f from t1 union select case  -t1.c when (abs(c | t1.c)/abs(17)) then (abs(t1.e)/abs(t1.c))+~19 else coalesce((select b from t1 where 11<=case d+coalesce((select max((select ( -(cast(avg(17) AS integer)))*max(t1.e)-max(t1.d)*cast(avg(t1.e) AS integer) from t1)) from t1 where (abs(case t1.f when 19 then b else t1.c end)/abs(t1.e))=b),d)*t1.f when  -t1.b then t1.d else 19 end),a) end+d+e from t1))}\n} {12}\ndo_test randexpr-2.1437 {\n  db eval {SELECT case e*case when case coalesce((select max(13) from t1 where exists(select 1 from t1 where t1.a in (17,b,17))),t1.e)-t1.c when c then 19 else  -t1.d end+17 in (t1.d,c,11) or b<= -( - -a) then ~(a) when f in (select case case (max(e)) when count(*) then max(17) else (max(17)) end+count(distinct e)- -count(distinct d) when  -count(*) then  -count(distinct d) else ((min(t1.f))) end from t1 union select min( -19) from t1) then c else (13) end when b then t1.b else f end FROM t1 WHERE t1.b<t1.e}\n} {600}\ndo_test randexpr-2.1438 {\n  db eval {SELECT case e*case when case coalesce((select max(13) from t1 where exists(select 1 from t1 where t1.a in (17,b,17))),t1.e)-t1.c when c then 19 else  -t1.d end+17 in (t1.d,c,11) or b<= -( - -a) then ~(a) when f in (select case case (max(e)) when count(*) then max(17) else (max(17)) end+count(distinct e)- -count(distinct d) when  -count(*) then  -count(distinct d) else ((min(t1.f))) end from t1 union select min( -19) from t1) then c else (13) end when b then t1.b else f end FROM t1 WHERE NOT (t1.b<t1.e)}\n} {}\ndo_test randexpr-2.1439 {\n  db eval {SELECT case when d in (c,t1.a*19,+++case when exists(select 1 from t1 where case 17 when ~t1.b then f-e*~b-17+ -t1.c else c end<>17 or (t1.c in (19,c,a))) then 13 else c end-11+11*11) then t1.e when (11)<13 then  - -t1.c else t1.d end FROM t1 WHERE ((t1.c+17 not between case b*(11-coalesce((select max(t1.a) from t1 where ~case when (not t1.d*17=f) then t1.c-13+c else t1.d end+t1.c>=(b)),b)*e) when t1.f then b else f end-f- -17 and d or t1.d not in (t1.c,11,b)))}\n} {300}\ndo_test randexpr-2.1440 {\n  db eval {SELECT case when d in (c,t1.a*19,+++case when exists(select 1 from t1 where case 17 when ~t1.b then f-e*~b-17+ -t1.c else c end<>17 or (t1.c in (19,c,a))) then 13 else c end-11+11*11) then t1.e when (11)<13 then  - -t1.c else t1.d end FROM t1 WHERE NOT (((t1.c+17 not between case b*(11-coalesce((select max(t1.a) from t1 where ~case when (not t1.d*17=f) then t1.c-13+c else t1.d end+t1.c>=(b)),b)*e) when t1.f then b else f end-f- -17 and d or t1.d not in (t1.c,11,b))))}\n} {}\ndo_test randexpr-2.1441 {\n  db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and  -t1.d),t1.f) when d then t1.e else t1.d end-e | f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE t1.a>t1.a | t1.c}\n} {}\ndo_test randexpr-2.1442 {\n  db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and  -t1.d),t1.f) when d then t1.e else t1.d end-e | f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE NOT (t1.a>t1.a | t1.c)}\n} {150000}\ndo_test randexpr-2.1443 {\n  db eval {SELECT t1.e*coalesce((select 17 from t1 where (19>(abs(case coalesce((select coalesce((select ~11 from t1 where b not between (13) and b),17) from t1 where 19 not between e+b+13 and  -t1.d),t1.f) when d then t1.e else t1.d end-e & f)/abs((e)))) and (t1.b<=a and 11<> - -t1.e) and t1.d<d),c) FROM t1 WHERE NOT (t1.a>t1.a | t1.c)}\n} {150000}\ndo_test randexpr-2.1444 {\n  db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b | d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 | b-~t1.e*a-t1.b | +c)),b)*a FROM t1 WHERE not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where  -t1.d in (select  -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then  -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where  -11=b and (d)<>t1.e))))}\n} {}\ndo_test randexpr-2.1445 {\n  db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b | d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 | b-~t1.e*a-t1.b | +c)),b)*a FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where  -t1.d in (select  -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then  -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where  -11=b and (d)<>t1.e)))))}\n} {-20100}\ndo_test randexpr-2.1446 {\n  db eval {SELECT ~coalesce((select max(t1.a) from t1 where ((t1.c)<=case 11-~t1.b++(t1.a+ -c)*t1.d-b & d when ~e then 17 else (abs(f)/abs(t1.f-t1.c)) end-19 & b-~t1.e*a-t1.b & +c)),b)*a FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a=((abs(coalesce((select coalesce((select max(+d) from t1 where not exists(select 1 from t1 where  -t1.d in (select  -max(13)-(min((t1.a))) from t1 union select count(distinct f) from t1)) and 11 in (select f from t1 union select 17 from t1) and a<>13),case when e>(11) then  -c else d end) from t1 where e<>11 and e<d),t1.d)+t1.b)/abs(17))* -19)-b or t1.e not in (a,11,t1.f) or not exists(select 1 from t1 where (exists(select 1 from t1 where  -11=b and (d)<>t1.e)))))}\n} {-20100}\ndo_test randexpr-2.1447 {\n  db eval {SELECT (select count(distinct ~(((abs(b-a)/abs(case (select min((select case cast(avg(11+t1.e) AS integer) when case min( -~coalesce((select 13 from t1 where case t1.e when f then d else 17 end>=b),e)) when case max(t1.b) when (~ -count(*)+(( -max( -t1.a)))-(count(*))) then  -count(distinct (t1.c)) else min( -t1.e) end then count(*) else cast(avg( -(e)) AS integer) end then cast(avg(13) AS integer) else max(17) end from t1)) from t1) when 13 then c else (d) end))))) from t1)*t1.b FROM t1 WHERE not t1.c>=t1.b}\n} {}\ndo_test randexpr-2.1448 {\n  db eval {SELECT (select count(distinct ~(((abs(b-a)/abs(case (select min((select case cast(avg(11+t1.e) AS integer) when case min( -~coalesce((select 13 from t1 where case t1.e when f then d else 17 end>=b),e)) when case max(t1.b) when (~ -count(*)+(( -max( -t1.a)))-(count(*))) then  -count(distinct (t1.c)) else min( -t1.e) end then count(*) else cast(avg( -(e)) AS integer) end then cast(avg(13) AS integer) else max(17) end from t1)) from t1) when 13 then c else (d) end))))) from t1)*t1.b FROM t1 WHERE NOT (not t1.c>=t1.b)}\n} {200}\ndo_test randexpr-2.1449 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 | t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c))}\n} {180000}\ndo_test randexpr-2.1450 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 | t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE NOT (t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c)))}\n} {}\ndo_test randexpr-2.1451 {\n  db eval {SELECT coalesce((select max(coalesce((select max(13) from t1 where t1.b in (select e from t1 union select t1.e from t1)),t1.a)) from t1 where case when t1.d=case when d not between t1.a and case when not t1.c in ((t1.e),a,t1.c) then 19 & t1.c when a not between 19 and b then (19) else 13 end then t1.d else b end-11 and not t1.f=t1.c or 19 not in (t1.d,c, -t1.f) and 17< -t1.d then e when t1.b not between 17 and t1.b then f else d end<11),t1.c)*f FROM t1 WHERE t1.b<=(coalesce((select c from t1 where e in (t1.a,t1.c,case when 17 not between 19 and (19)-t1.a-(abs(coalesce((select d from t1 where case (t1.b+e*b*t1.c) when 13 then t1.b else 19 end<>19),17))/abs(a))*t1.a then 17 when exists(select 1 from t1 where ( -e)=a) or 13>=d then 17 else t1.f end)),c))}\n} {180000}\ndo_test randexpr-2.1452 {\n  db eval {SELECT (d)+(select  -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 | (abs(19)/abs(~13))) from t1) | t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE c-t1.c not between t1.c and +case when +case  -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select  -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end}\n} {-500}\ndo_test randexpr-2.1453 {\n  db eval {SELECT (d)+(select  -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 | (abs(19)/abs(~13))) from t1) | t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE NOT (c-t1.c not between t1.c and +case when +case  -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select  -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end)}\n} {}\ndo_test randexpr-2.1454 {\n  db eval {SELECT (d)+(select  -abs(+cast(avg((select max((coalesce((select d from t1 where case when 13>=e then t1.c else 19 end>=d),coalesce((select 19-(select count(distinct 19 & (abs(19)/abs(~13))) from t1) & t1.d from t1 where coalesce((select max(11) from t1 where t1.a in (select t1.d from t1 union select c from t1)),19)>t1.d),e)+t1.b))) from t1)) AS integer)+abs( -max(b))) from t1) FROM t1 WHERE c-t1.c not between t1.c and +case when +case  -case when 17 not in (17,(e),t1.c) then a else 19 end-13 when t1.e then b else 13 end>19 or 17 in (select b from t1 union select t1.c from t1) then case c when t1.c then d else c end when not t1.f in (select  -cast(avg(a) AS integer)*count(distinct (17))+min(f)* - - -cast(avg(b) AS integer) from t1 union select (count(*)) from t1) then d else a end}\n} {-500}\ndo_test randexpr-2.1455 {\n  db eval {SELECT case when 19 in (case when coalesce((select max(case when e*t1.b in (coalesce((select t1.a from t1 where (abs(f)/abs(coalesce((select f from t1 where t1.f in (a,b,t1.d)),13))) in (b,b,11)),c),t1.a,17) then b else d end) from t1 where f>=13 and a>=17 and not exists(select 1 from t1 where (b<>f))), -t1.c) between d and 11 then d else t1.f end,t1.c,11) then 13 else 17 end FROM t1 WHERE t1.d in (select (abs(t1.a)/abs(t1.f)) from t1 union select e from t1) and ((b*coalesce((select  -11 from t1 where (coalesce((select max( -t1.e+ -coalesce((select d from t1 where t1.c<= - -t1.d),t1.c)) from t1 where b in (select  -count(distinct d)+count(distinct d)- -((min(e))) from t1 union select count(*) from t1)),(t1.e))-19*d<>t1.e)),a)*t1.f)=b)}\n} {}\ndo_test randexpr-2.1456 {\n  db eval {SELECT case when 19 in (case when coalesce((select max(case when e*t1.b in (coalesce((select t1.a from t1 where (abs(f)/abs(coalesce((select f from t1 where t1.f in (a,b,t1.d)),13))) in (b,b,11)),c),t1.a,17) then b else d end) from t1 where f>=13 and a>=17 and not exists(select 1 from t1 where (b<>f))), -t1.c) between d and 11 then d else t1.f end,t1.c,11) then 13 else 17 end FROM t1 WHERE NOT (t1.d in (select (abs(t1.a)/abs(t1.f)) from t1 union select e from t1) and ((b*coalesce((select  -11 from t1 where (coalesce((select max( -t1.e+ -coalesce((select d from t1 where t1.c<= - -t1.d),t1.c)) from t1 where b in (select  -count(distinct d)+count(distinct d)- -((min(e))) from t1 union select count(*) from t1)),(t1.e))-19*d<>t1.e)),a)*t1.f)=b))}\n} {17}\ndo_test randexpr-2.1457 {\n  db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d | b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between  -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b}\n} {}\ndo_test randexpr-2.1458 {\n  db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d | b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between  -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b)}\n} {-100}\ndo_test randexpr-2.1459 {\n  db eval {SELECT coalesce((select max((select count(*) from t1)) from t1 where coalesce((select max(t1.a-coalesce((select t1.d+case when exists(select 1 from t1 where exists(select 1 from t1 where t1.f between t1.a and f)) or d & b between 19 and 19 then f+17 else (t1.b) end from t1 where t1.e not between  -t1.d and (19)),(17))) from t1 where not exists(select 1 from t1 where 19 between t1.b and 13 or t1.b>t1.c) or 19>=19),b) between 13 and f), -t1.a) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.f+t1.e<(abs(t1.b)/abs( -f*e))) or case t1.c when case when 19 not between 17 and case when t1.e<>e then t1.b when not exists(select 1 from t1 where coalesce((select max(b) from t1 where (e<t1.a)),e)>t1.d or (t1.d<>t1.e)) then t1.c else 17 end then t1.c when e<>b then 17 else e end then t1.d else t1.e end between d and b)}\n} {-100}\ndo_test randexpr-2.1460 {\n  db eval {SELECT case when not case 11 when t1.e*coalesce((select max(t1.b) from t1 where (abs(t1.c)/abs(~11)) not between coalesce((select max((abs(a)/abs(c))) from t1 where t1.b>=t1.a or b= -e),t1.f) and e and c not in (t1.a,t1.f,t1.c) and not (a)<t1.b or t1.b not between b and t1.a),17)*11+b+f then f else 17 end not between t1.f and a then b else t1.a end FROM t1 WHERE not exists(select 1 from t1 where a in (select coalesce((select max(13) from t1 where t1.e not in (t1.d,case when t1.b not in ((select (count(distinct case when  -t1.a not between a and t1.f then t1.c when 13 not in (t1.a,t1.b,d) then f else 19 end)) from t1),b,t1.f) then c when 11 in (select min(a)+max(19) from t1 union select cast(avg(11) AS integer) from t1) and t1.c in (f,13,t1.e) or a>17 then c else a end | t1.b,a) or not (t1.d<11)),d) from t1 union select t1.a from t1) and f in (select b from t1 union select b from t1))}\n} {100}\ndo_test randexpr-2.1461 {\n  db eval {SELECT case when not case 11 when t1.e*coalesce((select max(t1.b) from t1 where (abs(t1.c)/abs(~11)) not between coalesce((select max((abs(a)/abs(c))) from t1 where t1.b>=t1.a or b= -e),t1.f) and e and c not in (t1.a,t1.f,t1.c) and not (a)<t1.b or t1.b not between b and t1.a),17)*11+b+f then f else 17 end not between t1.f and a then b else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where a in (select coalesce((select max(13) from t1 where t1.e not in (t1.d,case when t1.b not in ((select (count(distinct case when  -t1.a not between a and t1.f then t1.c when 13 not in (t1.a,t1.b,d) then f else 19 end)) from t1),b,t1.f) then c when 11 in (select min(a)+max(19) from t1 union select cast(avg(11) AS integer) from t1) and t1.c in (f,13,t1.e) or a>17 then c else a end | t1.b,a) or not (t1.d<11)),d) from t1 union select t1.a from t1) and f in (select b from t1 union select b from t1)))}\n} {}\ndo_test randexpr-2.1462 {\n  db eval {SELECT case when case when coalesce((select max(case when ((a<=case t1.a+t1.a when t1.d then  -c else b end or t1.b<>e)) then 17 else 19*19*a end*13) from t1 where d<>t1.d),d)<=a or 11<=t1.e then t1.c when 17<11 then 17 else e end<=t1.a then t1.d when e= -e then t1.d else 19 end FROM t1 WHERE t1.e<=t1.a or (abs(+a+coalesce((select max(t1.b) from t1 where (select ~count(distinct 17) from t1)-b in (select t1.b+t1.b from t1 union select 19 from t1)), -11))/abs(case when not exists(select 1 from t1 where t1.d not between 17 and c- -c+e) or t1.e>t1.f then t1.d when t1.d not in (17,e,d) then a else 17 end)) in (c,d,11)}\n} {}\ndo_test randexpr-2.1463 {\n  db eval {SELECT case when case when coalesce((select max(case when ((a<=case t1.a+t1.a when t1.d then  -c else b end or t1.b<>e)) then 17 else 19*19*a end*13) from t1 where d<>t1.d),d)<=a or 11<=t1.e then t1.c when 17<11 then 17 else e end<=t1.a then t1.d when e= -e then t1.d else 19 end FROM t1 WHERE NOT (t1.e<=t1.a or (abs(+a+coalesce((select max(t1.b) from t1 where (select ~count(distinct 17) from t1)-b in (select t1.b+t1.b from t1 union select 19 from t1)), -11))/abs(case when not exists(select 1 from t1 where t1.d not between 17 and c- -c+e) or t1.e>t1.f then t1.d when t1.d not in (17,e,d) then a else 17 end)) in (c,d,11))}\n} {19}\ndo_test randexpr-2.1464 {\n  db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select  -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) | case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when  -count(distinct e) then count(*) else max( - -17) end from t1) not between c and  -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select  -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then  -13+19 else t1.e end end) from t1 where ((t1.a not between d and  -t1.c))),t1.a)<11}\n} {}\ndo_test randexpr-2.1465 {\n  db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select  -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) | case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when  -count(distinct e) then count(*) else max( - -17) end from t1) not between c and  -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE NOT (coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select  -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then  -13+19 else t1.e end end) from t1 where ((t1.a not between d and  -t1.c))),t1.a)<11)}\n} {-194512}\ndo_test randexpr-2.1466 {\n  db eval {SELECT ~case when t1.e<=t1.a then b else (11) end+(select  -((cast(avg(coalesce((select a from t1 where (select cast(avg(t1.d) AS integer) & case case min((t1.e)) when cast(avg(t1.b) AS integer) then max(t1.c) else max(19) end*count(*) when  -count(distinct e) then count(*) else max( - -17) end from t1) not between c and  -t1.e-f+f),11)-11) AS integer)))*max(e) from t1)+e* - -a-t1.d*e FROM t1 WHERE NOT (coalesce((select max(case when 11 between d and d then e | b else case (select (case count(distinct coalesce((select  -coalesce((select max(t1.f) from t1 where t1.b in (select 11 from t1 union select 19 from t1)),t1.e) from t1 where 13<>17),17)) when (max( -t1.e)) then max(17)+max(11) else ((count(*))) end)*(count(*)) from t1) when 11 then  -13+19 else t1.e end end) from t1 where ((t1.a not between d and  -t1.c))),t1.a)<11)}\n} {-194512}\ndo_test randexpr-2.1467 {\n  db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else  -t1.e end)+13*t1.f)) | 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else  -19 end FROM t1 WHERE exists(select 1 from t1 where t1.c*coalesce((select f from t1 where  - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else  -13 end)*(a)<17)}\n} {}\ndo_test randexpr-2.1468 {\n  db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else  -t1.e end)+13*t1.f)) | 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else  -19 end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c*coalesce((select f from t1 where  - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else  -13 end)*(a)<17))}\n} {-6499}\ndo_test randexpr-2.1469 {\n  db eval {SELECT t1.e*~13-t1.a-~case when (abs(t1.a)/abs(coalesce((select max(t1.a) from t1 where e not between f and e-t1.b+13),case when (a in (select ( -c) from t1 union select 11 from t1) or exists(select 1 from t1 where 11 between f and t1.f)) then t1.b-a else  -t1.e end)+13*t1.f)) & 13<t1.a then t1.f when (t1.a in (select 19 from t1 union select c from t1)) then a else  -19 end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c*coalesce((select f from t1 where  - -f+b-(select min(t1.b) from t1) not in (c,17-t1.b*t1.a,t1.c)),case when (select abs(count(*)) from t1)<> -19-a then (a)-coalesce((select max(case when a in (13,t1.b,11) then t1.b else (13) end) from t1 where not exists(select 1 from t1 where t1.b>=b)),t1.c) else  -13 end)*(a)<17))}\n} {-6499}\ndo_test randexpr-2.1470 {\n  db eval {SELECT coalesce((select max(f*b | case when f in (t1.b,t1.b*(select count(*) from t1)+(select  -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select  -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c | t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select  -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17}\n} {}\ndo_test randexpr-2.1471 {\n  db eval {SELECT coalesce((select max(f*b | case when f in (t1.b,t1.b*(select count(*) from t1)+(select  -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select  -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c | t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE NOT (b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select  -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17)}\n} {0}\ndo_test randexpr-2.1472 {\n  db eval {SELECT coalesce((select max(f*b & case when f in (t1.b,t1.b*(select count(*) from t1)+(select  -count(*) from t1), -b) and +13<(abs( -~d-case when t1.a in (select  -f from t1 union select t1.c from t1) then (t1.a) when t1.a<e then t1.d else a end)/abs(t1.c)) then t1.b*19 else e end+t1.c & t1.d) from t1 where 13 not in (t1.e,13,c)),11)-11 FROM t1 WHERE NOT (b not between e-case when case 11 when t1.a then t1.e*17 else t1.c end in (select ~t1.a | b+(abs(f)/abs(case coalesce((select (select abs( -cast(avg(17) AS integer)) from t1) from t1 where not f=t1.b or 11>=a),coalesce((select 11 from t1 where 11 not between 19 and t1.c),t1.a))-19 when t1.e then t1.f else e end)) from t1 union select  -d from t1) then d when t1.f between 17 and d then t1.d else t1.d end and (f) or d<17)}\n} {0}\ndo_test randexpr-2.1473 {\n  db eval {SELECT case when (t1.b+case when a in (select coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 11=case e when (e) then t1.b else t1.c end or c in (t1.f,f,11))),t1.f) from t1 union select t1.d from t1) and t1.e<>e then t1.f when t1.a in (t1.d,a,13) then 17 else t1.d end not in (t1.f,t1.d,17)) or c<> -19 then b when f<t1.c and t1.b in (e,11,t1.f) then t1.b-t1.c else  - -d end FROM t1 WHERE t1.f- -t1.d in (select case a when 13+coalesce((select coalesce((select coalesce((select case when b>a-e then b else 19 end from t1 where 11<>t1.b),a) from t1 where not 19 in (select max(19)*count(distinct a) from t1 union select cast(avg(11) AS integer) from t1)),11) from t1 where t1.e<>a),17) then d else 19 end from t1 union select f from t1) and c in (select count(distinct c) from t1 union select  -+max(d) | abs(count(*)) from t1)}\n} {}\ndo_test randexpr-2.1474 {\n  db eval {SELECT case when (t1.b+case when a in (select coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 11=case e when (e) then t1.b else t1.c end or c in (t1.f,f,11))),t1.f) from t1 union select t1.d from t1) and t1.e<>e then t1.f when t1.a in (t1.d,a,13) then 17 else t1.d end not in (t1.f,t1.d,17)) or c<> -19 then b when f<t1.c and t1.b in (e,11,t1.f) then t1.b-t1.c else  - -d end FROM t1 WHERE NOT (t1.f- -t1.d in (select case a when 13+coalesce((select coalesce((select coalesce((select case when b>a-e then b else 19 end from t1 where 11<>t1.b),a) from t1 where not 19 in (select max(19)*count(distinct a) from t1 union select cast(avg(11) AS integer) from t1)),11) from t1 where t1.e<>a),17) then d else 19 end from t1 union select f from t1) and c in (select count(distinct c) from t1 union select  -+max(d) | abs(count(*)) from t1))}\n} {200}\ndo_test randexpr-2.1475 {\n  db eval {SELECT 17+coalesce((select max(19) from t1 where  -(select max(t1.d) from t1)>coalesce((select max((13)) from t1 where (coalesce((select 11 from t1 where  -e-t1.d-b-(abs(t1.b)/abs(11))*t1.f*b-e not between (f) and t1.e or 11 in (t1.b,t1.e, -e)),t1.a) in (select t1.b from t1 union select 19 from t1)) and exists(select 1 from t1 where 13<19)),t1.e)),e) FROM t1 WHERE t1.a<>t1.d or not exists(select 1 from t1 where t1.a>=coalesce((select case t1.e*d when  -case d*11 when t1.f then t1.e else t1.c end then 13*coalesce((select max(f*b*t1.e*t1.c) from t1 where t1.d in (select t1.c from t1 union select f from t1) or ((t1.e<f or t1.e=t1.b))),t1.d) | t1.b else d end from t1 where t1.f between t1.c and a),(13)))}\n} {517}\ndo_test randexpr-2.1476 {\n  db eval {SELECT 17+coalesce((select max(19) from t1 where  -(select max(t1.d) from t1)>coalesce((select max((13)) from t1 where (coalesce((select 11 from t1 where  -e-t1.d-b-(abs(t1.b)/abs(11))*t1.f*b-e not between (f) and t1.e or 11 in (t1.b,t1.e, -e)),t1.a) in (select t1.b from t1 union select 19 from t1)) and exists(select 1 from t1 where 13<19)),t1.e)),e) FROM t1 WHERE NOT (t1.a<>t1.d or not exists(select 1 from t1 where t1.a>=coalesce((select case t1.e*d when  -case d*11 when t1.f then t1.e else t1.c end then 13*coalesce((select max(f*b*t1.e*t1.c) from t1 where t1.d in (select t1.c from t1 union select f from t1) or ((t1.e<f or t1.e=t1.b))),t1.d) | t1.b else d end from t1 where t1.f between t1.c and a),(13))))}\n} {}\ndo_test randexpr-2.1477 {\n  db eval {SELECT case +a when (coalesce((select d*f*t1.d from t1 where t1.f between (case when e* -13<~ - -t1.e then e when 13>=t1.a then f-coalesce((select  -(select max((select min(a)-count(distinct c) from t1)) from t1) from t1 where a between f and d),c) else d end) and c or not exists(select 1 from t1 where 11<=13)),f)) then (e) else t1.b end FROM t1 WHERE not  -c between  -d+f | 17+t1.a and 11 or 11*e=(+case when c>=d then coalesce((select max(d-t1.f*f) from t1 where 11 in (select count(distinct t1.e) from t1 union select (~case count(*) when  -max(t1.f) then count(distinct t1.d) else (cast(avg(t1.f) AS integer)) end) from t1)),t1.c) else d end+t1.b-t1.c+b)+t1.c- -(13)}\n} {200}\ndo_test randexpr-2.1478 {\n  db eval {SELECT case +a when (coalesce((select d*f*t1.d from t1 where t1.f between (case when e* -13<~ - -t1.e then e when 13>=t1.a then f-coalesce((select  -(select max((select min(a)-count(distinct c) from t1)) from t1) from t1 where a between f and d),c) else d end) and c or not exists(select 1 from t1 where 11<=13)),f)) then (e) else t1.b end FROM t1 WHERE NOT (not  -c between  -d+f | 17+t1.a and 11 or 11*e=(+case when c>=d then coalesce((select max(d-t1.f*f) from t1 where 11 in (select count(distinct t1.e) from t1 union select (~case count(*) when  -max(t1.f) then count(distinct t1.d) else (cast(avg(t1.f) AS integer)) end) from t1)),t1.c) else d end+t1.b-t1.c+b)+t1.c- -(13))}\n} {}\ndo_test randexpr-2.1479 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where a between +d-case when t1.c+e not between case 11 when +t1.b+11 then 19 else  -t1.f end+(11) and d and exists(select 1 from t1 where (a)>b) and not exists(select 1 from t1 where 11 in (a,11,t1.c)) then 19 else t1.a end and t1.a) then 17 when t1.d<>e then (t1.a) else e end-a<=e then c else 11 end FROM t1 WHERE coalesce((select a from t1 where not exists(select 1 from t1 where  -t1.c not between b and t1.a)),case when t1.d<=19-13 then coalesce((select max((select count(*)*cast(avg(~t1.a-e*~17+t1.e) AS integer) from t1)) from t1 where (exists(select 1 from t1 where + - -e-11*a-t1.d in (11,(t1.b),c)))),19+e)* -b else c end)>=17}\n} {300}\ndo_test randexpr-2.1480 {\n  db eval {SELECT case when case when not exists(select 1 from t1 where a between +d-case when t1.c+e not between case 11 when +t1.b+11 then 19 else  -t1.f end+(11) and d and exists(select 1 from t1 where (a)>b) and not exists(select 1 from t1 where 11 in (a,11,t1.c)) then 19 else t1.a end and t1.a) then 17 when t1.d<>e then (t1.a) else e end-a<=e then c else 11 end FROM t1 WHERE NOT (coalesce((select a from t1 where not exists(select 1 from t1 where  -t1.c not between b and t1.a)),case when t1.d<=19-13 then coalesce((select max((select count(*)*cast(avg(~t1.a-e*~17+t1.e) AS integer) from t1)) from t1 where (exists(select 1 from t1 where + - -e-11*a-t1.d in (11,(t1.b),c)))),19+e)* -b else c end)>=17)}\n} {}\ndo_test randexpr-2.1481 {\n  db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select  -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) | 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE not (t1.e not between ~17 and +t1.e*(~b)*e)}\n} {}\ndo_test randexpr-2.1482 {\n  db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select  -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) | 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE NOT (not (t1.e not between ~17 and +t1.e*(~b)*e))}\n} {10519}\ndo_test randexpr-2.1483 {\n  db eval {SELECT coalesce((select t1.c-~t1.e*19++case t1.b when coalesce((select 17 from t1 where t1.f not between t1.c-+coalesce((select max(a+ -t1.c) from t1 where (select count(distinct 11) from t1) in (select  -+case when a not between f and b or b>=t1.d then (t1.d) when a in (t1.e,b,13) then t1.d else t1.c end*a from t1 union select t1.f from t1)),f) and 17),a) & 17*c then 19 else d end+t1.c from t1 where e<>t1.b),19) FROM t1 WHERE NOT (not (t1.e not between ~17 and +t1.e*(~b)*e))}\n} {10519}\ndo_test randexpr-2.1484 {\n  db eval {SELECT ~case when b<=(t1.c | (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) | cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where  -f in (select e from t1 union select  -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17)}\n} {}\ndo_test randexpr-2.1485 {\n  db eval {SELECT ~case when b<=(t1.c | (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) | cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where  -f in (select e from t1 union select  -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17))}\n} {-401}\ndo_test randexpr-2.1486 {\n  db eval {SELECT ~case when b<=(t1.c & (abs(d)/abs(a*f)))+case when (13*(t1.b) not in (19,b,t1.d)) and exists(select 1 from t1 where 19 between t1.d and 11) then (select case count(distinct t1.f) when +( -count(distinct c) & cast(avg(t1.d) AS integer)) then cast(avg(t1.c) AS integer) else min(f) end from t1) else 13 end*t1.c or exists(select 1 from t1 where  -f in (select e from t1 union select  -t1.a from t1)) then t1.d else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where t1.c+b-t1.d between 11 and 17))}\n} {-401}\ndo_test randexpr-2.1487 {\n  db eval {SELECT coalesce((select max(~coalesce((select 19+~coalesce((select (abs((19)*c+~t1.a-t1.a*19)/abs(case when t1.d<>t1.b then t1.f when 13<>19 then (11) else t1.c end)) from t1 where f= -t1.a or t1.d not between t1.d and  -f),t1.f) from t1 where not exists(select 1 from t1 where  -19 not between d and f)),d)*t1.a-f) from t1 where c not in (c,c,c)),t1.b) FROM t1 WHERE (coalesce((select max( -t1.d+19+11+coalesce((select a from t1 where 11 not between e and t1.d),t1.d)) from t1 where not ( -t1.f not between b and f) and t1.e in (b,11,f)),f)+t1.e<=19) or c>t1.d or e in (a,19,11) or t1.f>b or  -t1.f<=13 and a between 11 and t1.a}\n} {200}\ndo_test randexpr-2.1488 {\n  db eval {SELECT coalesce((select max(~coalesce((select 19+~coalesce((select (abs((19)*c+~t1.a-t1.a*19)/abs(case when t1.d<>t1.b then t1.f when 13<>19 then (11) else t1.c end)) from t1 where f= -t1.a or t1.d not between t1.d and  -f),t1.f) from t1 where not exists(select 1 from t1 where  -19 not between d and f)),d)*t1.a-f) from t1 where c not in (c,c,c)),t1.b) FROM t1 WHERE NOT ((coalesce((select max( -t1.d+19+11+coalesce((select a from t1 where 11 not between e and t1.d),t1.d)) from t1 where not ( -t1.f not between b and f) and t1.e in (b,11,f)),f)+t1.e<=19) or c>t1.d or e in (a,19,11) or t1.f>b or  -t1.f<=13 and a between 11 and t1.a)}\n} {}\ndo_test randexpr-2.1489 {\n  db eval {SELECT case t1.d when 17 then 11 | t1.a-17+13+t1.f*t1.e+t1.e-case when d | t1.e in (t1.b,t1.a,c) then  -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1)}\n} {}\ndo_test randexpr-2.1490 {\n  db eval {SELECT case t1.d when 17 then 11 | t1.a-17+13+t1.f*t1.e+t1.e-case when d | t1.e in (t1.b,t1.a,c) then  -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE NOT (d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1))}\n} {600}\ndo_test randexpr-2.1491 {\n  db eval {SELECT case t1.d when 17 then 11 & t1.a-17+13+t1.f*t1.e+t1.e-case when d & t1.e in (t1.b,t1.a,c) then  -13 else (b*19) end-(select cast(avg(coalesce((select a from t1 where e in (t1.f,t1.b,f)), -e)) AS integer) from t1)*d-11-t1.e-t1.a else t1.f end FROM t1 WHERE NOT (d*13 in (select abs(min(d)) from t1 union select cast(avg(d) AS integer) from t1))}\n} {600}\ndo_test randexpr-2.1492 {\n  db eval {SELECT coalesce((select max(19-(abs(t1.c)/abs( -13))-(select count(*)*abs(max(t1.a-b)) from t1)-t1.d) from t1 where (case coalesce((select max(~(select ~count(*) from t1)) from t1 where b=(abs(17)/abs(d))),11*case when not t1.c>=e or 17=c then d else 17*b end*t1.d) when 13 then 11 else t1.c end) in (select c from t1 union select t1.c from t1)),13) FROM t1 WHERE case t1.a*(select  -case count(distinct ~(case 13-+t1.d-f when d then c else (19) end)*19)* -max(19) |  -count(*)+abs(min(19)) | cast(avg(d) AS integer) when min(a) then count(distinct 11) else count(*) end from t1)*(abs(t1.a)/abs(11))-f-t1.b+(t1.f) when 11 then 17 else 19 end<>d}\n} {-504}\ndo_test randexpr-2.1493 {\n  db eval {SELECT coalesce((select max(19-(abs(t1.c)/abs( -13))-(select count(*)*abs(max(t1.a-b)) from t1)-t1.d) from t1 where (case coalesce((select max(~(select ~count(*) from t1)) from t1 where b=(abs(17)/abs(d))),11*case when not t1.c>=e or 17=c then d else 17*b end*t1.d) when 13 then 11 else t1.c end) in (select c from t1 union select t1.c from t1)),13) FROM t1 WHERE NOT (case t1.a*(select  -case count(distinct ~(case 13-+t1.d-f when d then c else (19) end)*19)* -max(19) |  -count(*)+abs(min(19)) | cast(avg(d) AS integer) when min(a) then count(distinct 11) else count(*) end from t1)*(abs(t1.a)/abs(11))-f-t1.b+(t1.f) when 11 then 17 else 19 end<>d)}\n} {}\ndo_test randexpr-2.1494 {\n  db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then  -(f) else e end-17)) | case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b | t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE f<a+t1.f}\n} {212}\ndo_test randexpr-2.1495 {\n  db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then  -(f) else e end-17)) | case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b | t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE NOT (f<a+t1.f)}\n} {}\ndo_test randexpr-2.1496 {\n  db eval {SELECT +(select abs( -abs(count(distinct case when (abs(t1.f)/abs(t1.a-t1.d)) in (select count(distinct 19) from t1 union select +abs(+ -cast(avg(c) AS integer)) from t1) then  -(f) else e end-17)) & case count(distinct b) when count(*) then cast(avg(13) AS integer) else ( -count(distinct d)) end-count(*)* - -cast(avg(a) AS integer)) from t1)+case when t1.f in (select d*b & t1.d from t1 union select d from t1) then t1.f when 19<>t1.e then t1.b else 11 end+11 FROM t1 WHERE f<a+t1.f}\n} {298}\ndo_test randexpr-2.1497 {\n  db eval {SELECT case when e in (+(select ~(max(t1.f)-+count(distinct 11)) from t1)*t1.b+t1.c*a*t1.b+e,a,t1.c) and (19)<>17 or 17 between 13 and a and exists(select 1 from t1 where c not between t1.f and t1.d) then coalesce((select max(d) from t1 where t1.e<>19),17) else a end*(( -f))+t1.d FROM t1 WHERE exists(select 1 from t1 where exists(select 1 from t1 where t1.c between case when (a<a and not exists(select 1 from t1 where exists(select 1 from t1 where d<~t1.f-+t1.a or (abs(17)/abs(t1.c)) in (select 19 from t1 union select 11 from t1)))) then +e when d<>13 or b>=e or 19 between t1.d and  -t1.e then t1.f else f end and f) and c>((t1.c))) and not exists(select 1 from t1 where 17<t1.c)}\n} {}\ndo_test randexpr-2.1498 {\n  db eval {SELECT case when e in (+(select ~(max(t1.f)-+count(distinct 11)) from t1)*t1.b+t1.c*a*t1.b+e,a,t1.c) and (19)<>17 or 17 between 13 and a and exists(select 1 from t1 where c not between t1.f and t1.d) then coalesce((select max(d) from t1 where t1.e<>19),17) else a end*(( -f))+t1.d FROM t1 WHERE NOT (exists(select 1 from t1 where exists(select 1 from t1 where t1.c between case when (a<a and not exists(select 1 from t1 where exists(select 1 from t1 where d<~t1.f-+t1.a or (abs(17)/abs(t1.c)) in (select 19 from t1 union select 11 from t1)))) then +e when d<>13 or b>=e or 19 between t1.d and  -t1.e then t1.f else f end and f) and c>((t1.c))) and not exists(select 1 from t1 where 17<t1.c))}\n} {-239600}\ndo_test randexpr-2.1499 {\n  db eval {SELECT 17+11+d+t1.d | t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) | min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) | (t1.d) FROM t1 WHERE d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end)}\n} {}\ndo_test randexpr-2.1500 {\n  db eval {SELECT 17+11+d+t1.d | t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) | min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) | (t1.d) FROM t1 WHERE NOT (d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end))}\n} {959}\ndo_test randexpr-2.1501 {\n  db eval {SELECT 17+11+d+t1.d & t1.c+(abs(case when 11 in (select count(distinct 11*+t1.d) from t1 union select ~cast(avg(t1.c) AS integer)*case (count(distinct 19)) when (cast(avg(t1.c) AS integer) & min(t1.a-f)) then cast(avg(a) AS integer) else cast(avg(t1.b) AS integer) end+max( - -d) from t1) then t1.a-13 when (11)>=13 then t1.e else t1.c end)/abs(19)) & (t1.d) FROM t1 WHERE NOT (d>=(case when ((t1.a)) between t1.f and a then case when 11 between 19-case when (~coalesce((select t1.e from t1 where d>t1.c and e<>t1.f),e))>=13 then t1.b when t1.d in (select (count(*)-min(19)) from t1 union select cast(avg(t1.e) AS integer) from t1) then 17 else (t1.d) end*t1.a and (13) then 11 when not exists(select 1 from t1 where not 19<>(t1.e) and t1.a between d and d and t1.c=a) then 17 else t1.a end-17 else e end))}\n} {272}\ndo_test randexpr-2.1502 {\n  db eval {SELECT coalesce((select 17 from t1 where ((abs(19)/abs(case when ((f+17<(d))) and (abs(t1.c)/abs((t1.b)))>11 then ~a+11 when (t1.f)>t1.d then 19 else c end))<>t1.b) or (b in (( -t1.d),b,e) and (t1.a)<>c) and (17) not in (t1.f,11,17) or (f) not between t1.c and  -t1.c),t1.a) FROM t1 WHERE 17 between  -t1.b+f-19 | 17 and t1.e+t1.c}\n} {}\ndo_test randexpr-2.1503 {\n  db eval {SELECT coalesce((select 17 from t1 where ((abs(19)/abs(case when ((f+17<(d))) and (abs(t1.c)/abs((t1.b)))>11 then ~a+11 when (t1.f)>t1.d then 19 else c end))<>t1.b) or (b in (( -t1.d),b,e) and (t1.a)<>c) and (17) not in (t1.f,11,17) or (f) not between t1.c and  -t1.c),t1.a) FROM t1 WHERE NOT (17 between  -t1.b+f-19 | 17 and t1.e+t1.c)}\n} {17}\ndo_test randexpr-2.1504 {\n  db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) | min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b | f) | e-f,d,d) then t1.a else d end FROM t1 WHERE t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1)}\n} {-108}\ndo_test randexpr-2.1505 {\n  db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) | min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b | f) | e-f,d,d) then t1.a else d end FROM t1 WHERE NOT (t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1))}\n} {}\ndo_test randexpr-2.1506 {\n  db eval {SELECT +(11)-19-case when 19+13-19+f*19*c not in (coalesce((select max((select ~min(t1.b)+(count(distinct t1.d)) & min(13)*count(distinct t1.a)*max(a) from t1)) from t1 where not 19 in (select t1.d from t1 union select 19 from t1) or 19<=t1.c),t1.b & f) & e-f,d,d) then t1.a else d end FROM t1 WHERE t1.d in (select case when t1.e>(case coalesce((select (11)-t1.e from t1 where case t1.e when t1.c then (coalesce((select max(+t1.b) from t1 where (a in (case when 19 in (select cast(avg((t1.b)) AS integer) from t1 union select cast(avg( - -17) AS integer) from t1) then a when 17>=13 then c else t1.e end,11,11) or not 19 between t1.b and t1.a)),t1.e)) else d end<=t1.c),13) when e then a else d end) then a when 19 in (select (11) from t1 union select t1.e from t1) then (e) else t1.d end from t1 union select t1.d from t1)}\n} {-108}\ndo_test randexpr-2.1507 {\n  db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f | case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d | t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE 17 in (select f*f from t1 union select a+d from t1)}\n} {}\ndo_test randexpr-2.1508 {\n  db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f | case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d | t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE NOT (17 in (select f*f from t1 union select a+d from t1))}\n} {110}\ndo_test randexpr-2.1509 {\n  db eval {SELECT (abs(case t1.f when (abs((abs( -t1.b+t1.f & case when t1.e-b*19<=17 then 13 when t1.d<>c-coalesce((select max(coalesce((select t1.d from t1 where (not exists(select 1 from t1 where (19)<=a) or 11 between t1.e and f)),d & t1.f)) from t1 where (t1.a between 19 and t1.a)),13) then 19 else f end)/abs(t1.f))-t1.a)/abs(e))+t1.e then t1.b else b end)/abs(19))+t1.a FROM t1 WHERE NOT (17 in (select f*f from t1 union select a+d from t1))}\n} {110}\ndo_test randexpr-2.1510 {\n  db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case  -f when f then a else t1.b end-t1.e-t1.f when t1.b then  -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) | d FROM t1 WHERE case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1)))}\n} {}\ndo_test randexpr-2.1511 {\n  db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case  -f when f then a else t1.b end-t1.e-t1.f when t1.b then  -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) | d FROM t1 WHERE NOT (case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1))))}\n} {500}\ndo_test randexpr-2.1512 {\n  db eval {SELECT (coalesce((select t1.e from t1 where +case when t1.c+f<>d-17 then t1.a when not (abs(t1.c)/abs(case case  -f when f then a else t1.b end-t1.e-t1.f when t1.b then  -e else t1.c end))>e or t1.b=a or exists(select 1 from t1 where 19>=t1.b) and t1.c< -e then t1.e else 13 end<=t1.b),b)) & d FROM t1 WHERE NOT (case 13 when 13 then 17-f else a end=e and (exists(select 1 from t1 where b in (select t1.f from t1 union select coalesce((select case when (abs(t1.c)/abs(17)) in (a,f*c,11) then c when ( -t1.d) in (select ~count(distinct t1.b) from t1 union select min((t1.c)) from t1) then t1.a else t1.e end from t1 where exists(select 1 from t1 where (t1.f) in (t1.d,17, -11))),b)-d*11*c+a from t1))))}\n} {400}\ndo_test randexpr-2.1513 {\n  db eval {SELECT (abs( -case when exists(select 1 from t1 where (abs(e++11-(abs(c)/abs(t1.f)))/abs(19+t1.b))+t1.b-c=(b)) or d in (~d, -f,c) then (select min(13) from t1)+11+~t1.a*t1.a else d end-t1.d)/abs((select (max(d))+count(*)-min(t1.c) from t1))) FROM t1 WHERE (select +min(c+d) | (max(13)+min(case when t1.e not in (t1.d,t1.d,19*t1.d) then t1.a when 17=d then t1.b else a end)+ - -max(t1.a)*count(distinct f) | count(*)+max(t1.d) | count(distinct d))-count(distinct 17)-count(*) from t1) not in (e,d+11,(t1.a+t1.f))}\n} {7}\ndo_test randexpr-2.1514 {\n  db eval {SELECT (abs( -case when exists(select 1 from t1 where (abs(e++11-(abs(c)/abs(t1.f)))/abs(19+t1.b))+t1.b-c=(b)) or d in (~d, -f,c) then (select min(13) from t1)+11+~t1.a*t1.a else d end-t1.d)/abs((select (max(d))+count(*)-min(t1.c) from t1))) FROM t1 WHERE NOT ((select +min(c+d) | (max(13)+min(case when t1.e not in (t1.d,t1.d,19*t1.d) then t1.a when 17=d then t1.b else a end)+ - -max(t1.a)*count(distinct f) | count(*)+max(t1.d) | count(distinct d))-count(distinct 17)-count(*) from t1) not in (e,d+11,(t1.a+t1.f)))}\n} {}\ndo_test randexpr-2.1515 {\n  db eval {SELECT case when not exists(select 1 from t1 where (not case t1.b when d then c else coalesce((select max(b+case c+c when t1.c then coalesce((select ((e)) from t1 where c in (e,t1.f,t1.d)),t1.a) else t1.f end+t1.e) from t1 where not t1.e not between t1.f and t1.a),19) end+f<>b)) then e when f in (19,t1.d, -c) then 19 else case when e>=t1.f then 19 else 19 end end FROM t1 WHERE 19 between e+case when d>(select ~max(t1.d)+max(t1.d*t1.c)-~count(distinct c)-count(*)-count(distinct t1.b)* -(count(*)) from t1) then ~a when not exists(select 1 from t1 where t1.c>=13) or (t1.f=t1.a or c in ((f), -c,t1.e)) and b=b and e not between t1.b and  -11 or t1.c in (t1.c,17,t1.c) and t1.f=t1.d then t1.a*t1.d*t1.c else d end and e}\n} {}\ndo_test randexpr-2.1516 {\n  db eval {SELECT case when not exists(select 1 from t1 where (not case t1.b when d then c else coalesce((select max(b+case c+c when t1.c then coalesce((select ((e)) from t1 where c in (e,t1.f,t1.d)),t1.a) else t1.f end+t1.e) from t1 where not t1.e not between t1.f and t1.a),19) end+f<>b)) then e when f in (19,t1.d, -c) then 19 else case when e>=t1.f then 19 else 19 end end FROM t1 WHERE NOT (19 between e+case when d>(select ~max(t1.d)+max(t1.d*t1.c)-~count(distinct c)-count(*)-count(distinct t1.b)* -(count(*)) from t1) then ~a when not exists(select 1 from t1 where t1.c>=13) or (t1.f=t1.a or c in ((f), -c,t1.e)) and b=b and e not between t1.b and  -11 or t1.c in (t1.c,17,t1.c) and t1.f=t1.d then t1.a*t1.d*t1.c else d end and e)}\n} {500}\ndo_test randexpr-2.1517 {\n  db eval {SELECT (select  -+case  -(case  -max(d) when ~+ -+(count(*)) then abs(max(case 17+t1.a-11-t1.c when 19 then f else e end*((t1.c))+b)) else (min(d)*count(distinct t1.e)) end)++abs(count(*))- -cast(avg(c) AS integer)+max(d) when count(distinct c) then min(f) else (count(distinct a)) end from t1) FROM t1 WHERE ((case  -a when case when f between 11 and t1.d then d else c+17 end then b else a end+11-c between  -a and t1.a) or b>t1.f and t1.a<t1.e and (t1.d)<=b or 19 in (select f from t1 union select e from t1) and t1.f not between 19 and 11 or t1.b not in (t1.e,t1.e,11))}\n} {-1}\ndo_test randexpr-2.1518 {\n  db eval {SELECT (select  -+case  -(case  -max(d) when ~+ -+(count(*)) then abs(max(case 17+t1.a-11-t1.c when 19 then f else e end*((t1.c))+b)) else (min(d)*count(distinct t1.e)) end)++abs(count(*))- -cast(avg(c) AS integer)+max(d) when count(distinct c) then min(f) else (count(distinct a)) end from t1) FROM t1 WHERE NOT (((case  -a when case when f between 11 and t1.d then d else c+17 end then b else a end+11-c between  -a and t1.a) or b>t1.f and t1.a<t1.e and (t1.d)<=b or 19 in (select f from t1 union select e from t1) and t1.f not between 19 and 11 or t1.b not in (t1.e,t1.e,11)))}\n} {}\ndo_test randexpr-2.1519 {\n  db eval {SELECT  -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) | (min(b)) then  -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then  -~c-d else t1.e end)/abs(13))) FROM t1 WHERE (select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b}\n} {}\ndo_test randexpr-2.1520 {\n  db eval {SELECT  -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) | (min(b)) then  -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then  -~c-d else t1.e end)/abs(13))) FROM t1 WHERE NOT ((select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b)}\n} {-38}\ndo_test randexpr-2.1521 {\n  db eval {SELECT  -coalesce((select max((select case +count(*)+(case min((abs(d)/abs(b))) when +count(*) & (min(b)) then  -min((t1.a)) else max( -t1.a) end*max( -t1.e))+max(f) when (count(*)) then count(distinct 17) else cast(avg((t1.c)) AS integer) end from t1)) from t1 where t1.d in (select 13 from t1 union select t1.c from t1)),(abs(case when ((c>=f) or f in (t1.a,(t1.a),a)) then  -~c-d else t1.e end)/abs(13))) FROM t1 WHERE NOT ((select (+~max(case when t1.e>=coalesce((select max(t1.d) from t1 where +f not in (coalesce((select 11 from t1 where 13 | c in (select c from t1 union select b from t1)),f),t1.c, -a)),13) then e else 19 end)-min(t1.a)) from t1)+((coalesce((select t1.e from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where t1.c=t1.a))),a)))+13 in (select d from t1 union select t1.a from t1) and e>=b)}\n} {-38}\ndo_test randexpr-2.1522 {\n  db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case  -max( -(t1.a*t1.f)+t1.e* -t1.f*13 | 17 | f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) | count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e)}\n} {}\ndo_test randexpr-2.1523 {\n  db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case  -max( -(t1.a*t1.f)+t1.e* -t1.f*13 | 17 | f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) | count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE NOT (case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e))}\n} {37500}\ndo_test randexpr-2.1524 {\n  db eval {SELECT +(select +abs(+cast(avg(t1.b) AS integer)*abs(case  -max( -(t1.a*t1.f)+t1.e* -t1.f*13 & 17 & f+t1.c) when abs(cast(avg(d) AS integer))-(++~min(t1.f) & count(*)-cast(avg(f) AS integer)) then count(*) else cast(avg(13) AS integer) end+ -min(b)))+min(a) from t1) FROM t1 WHERE NOT (case t1.a-t1.e*+t1.f-(select abs(count(*)) from t1)+coalesce((select max(t1.c) from t1 where not exists(select 1 from t1 where ~t1.b in (select +count(*) | count(distinct case b when t1.a then f else case when (t1.d-t1.b)<11 then t1.d else f end end) from t1 union select +cast(avg(( -d)) AS integer) from t1))),t1.d*t1.a) | e when t1.f then (t1.d) else t1.f end not in (d,f,e))}\n} {37500}\ndo_test randexpr-2.1525 {\n  db eval {SELECT t1.d+case when coalesce((select b from t1 where case when (select max(t1.a*(select case count(distinct c) when max(17+c) then  - -max(d)-count(*) else cast(avg((e)) AS integer) end from t1)) from t1) not between t1.d and t1.d then t1.d when t1.c not between c and t1.f then ( -t1.d) else t1.d end not between e and t1.e),d)<>17 then (t1.f) when 11=t1.c then 11 else t1.f end*c*t1.a-c FROM t1 WHERE (case when coalesce((select ~coalesce((select max(a) from t1 where 11 in (select ~case  -count(*) when cast(avg(d) AS integer) then  -max(t1.f) else (count(distinct 11)) end+cast(avg( - -13) AS integer) | count(*)-min(f) from t1 union select count(*) from t1)),t1.b*t1.f*17) from t1 where not exists(select 1 from t1 where t1.a not between d and 11)),b)-17*t1.d+t1.a in ( -t1.c,t1.e,11) then b else t1.d end in (select 17 from t1 union select 13 from t1)) and  -t1.a in (select (d) from t1 union select t1.b from t1)}\n} {}\ndo_test randexpr-2.1526 {\n  db eval {SELECT t1.d+case when coalesce((select b from t1 where case when (select max(t1.a*(select case count(distinct c) when max(17+c) then  - -max(d)-count(*) else cast(avg((e)) AS integer) end from t1)) from t1) not between t1.d and t1.d then t1.d when t1.c not between c and t1.f then ( -t1.d) else t1.d end not between e and t1.e),d)<>17 then (t1.f) when 11=t1.c then 11 else t1.f end*c*t1.a-c FROM t1 WHERE NOT ((case when coalesce((select ~coalesce((select max(a) from t1 where 11 in (select ~case  -count(*) when cast(avg(d) AS integer) then  -max(t1.f) else (count(distinct 11)) end+cast(avg( - -13) AS integer) | count(*)-min(f) from t1 union select count(*) from t1)),t1.b*t1.f*17) from t1 where not exists(select 1 from t1 where t1.a not between d and 11)),b)-17*t1.d+t1.a in ( -t1.c,t1.e,11) then b else t1.d end in (select 17 from t1 union select 13 from t1)) and  -t1.a in (select (d) from t1 union select t1.b from t1))}\n} {18000100}\ndo_test randexpr-2.1527 {\n  db eval {SELECT coalesce((select (abs(b+t1.c)/abs(coalesce((select max( -~t1.d) from t1 where coalesce((select max(11) from t1 where not t1.d>=(select count(*) from t1)),case b-coalesce((select t1.e-f from t1 where coalesce((select max(case a when t1.e then t1.f else 11 end) from t1 where t1.b>=t1.f),t1.d) not in (f,e,13)),t1.f) when  -11 then t1.c else 19 end)-d not in (f,f,b)),f))) from t1 where d<=t1.d),f) FROM t1 WHERE c+case when coalesce((select d from t1 where coalesce((select max(17) from t1 where c>17-11),17)<c),case when not (t1.d) in (select 19 from t1 union select t1.a from t1) then case when  -d<=17 then f else t1.a end else 19 end)+e in (select 17 from t1 union select  -t1.b from t1) then b when 17<t1.b or 17<f then  -11 else t1.d end*b-t1.d in (select count(distinct d) from t1 union select count(distinct c) from t1)}\n} {}\ndo_test randexpr-2.1528 {\n  db eval {SELECT coalesce((select (abs(b+t1.c)/abs(coalesce((select max( -~t1.d) from t1 where coalesce((select max(11) from t1 where not t1.d>=(select count(*) from t1)),case b-coalesce((select t1.e-f from t1 where coalesce((select max(case a when t1.e then t1.f else 11 end) from t1 where t1.b>=t1.f),t1.d) not in (f,e,13)),t1.f) when  -11 then t1.c else 19 end)-d not in (f,f,b)),f))) from t1 where d<=t1.d),f) FROM t1 WHERE NOT (c+case when coalesce((select d from t1 where coalesce((select max(17) from t1 where c>17-11),17)<c),case when not (t1.d) in (select 19 from t1 union select t1.a from t1) then case when  -d<=17 then f else t1.a end else 19 end)+e in (select 17 from t1 union select  -t1.b from t1) then b when 17<t1.b or 17<f then  -11 else t1.d end*b-t1.d in (select count(distinct d) from t1 union select count(distinct c) from t1))}\n} {1}\ndo_test randexpr-2.1529 {\n  db eval {SELECT (abs(19)/abs(coalesce((select max((abs((abs(t1.a)/abs(e)))/abs(b))) from t1 where not t1.f<13 and 17-(abs(b-13*f*(abs(+17-f+t1.a)/abs(t1.d)))/abs(t1.e))+e-17>f and (exists(select 1 from t1 where (17 in (e, -t1.f,c)) and t1.f<=19))),d))) FROM t1 WHERE f*t1.c<>t1.b}\n} {0}\ndo_test randexpr-2.1530 {\n  db eval {SELECT (abs(19)/abs(coalesce((select max((abs((abs(t1.a)/abs(e)))/abs(b))) from t1 where not t1.f<13 and 17-(abs(b-13*f*(abs(+17-f+t1.a)/abs(t1.d)))/abs(t1.e))+e-17>f and (exists(select 1 from t1 where (17 in (e, -t1.f,c)) and t1.f<=19))),d))) FROM t1 WHERE NOT (f*t1.c<>t1.b)}\n} {}\ndo_test randexpr-2.1531 {\n  db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) |  -(count(*))) when count(*) then count(distinct t1.b) else count(distinct  -t1.a) end | max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b | c when f=t1.e then e else 19 end FROM t1 WHERE t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e}\n} {}\ndo_test randexpr-2.1532 {\n  db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) |  -(count(*))) when count(*) then count(distinct t1.b) else count(distinct  -t1.a) end | max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b | c when f=t1.e then e else 19 end FROM t1 WHERE NOT (t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e)}\n} {19}\ndo_test randexpr-2.1533 {\n  db eval {SELECT case when t1.d in (select count(distinct 11) from t1 union select case abs(++cast(avg(t1.b) AS integer)+count(*) &  -(count(*))) when count(*) then count(distinct t1.b) else count(distinct  -t1.a) end & max(t1.c) from t1) and t1.f<=case when exists(select 1 from t1 where t1.f+t1.f<>17 and t1.b>d) then 19 when t1.e=a then coalesce((select b from t1 where 13 not in (t1.b,t1.a,t1.a)),t1.c) else t1.d end and t1.d>(t1.b) and c in (e,t1.d,t1.b) then b & c when f=t1.e then e else 19 end FROM t1 WHERE NOT (t1.f between (c-t1.d+t1.f*t1.f) and 11+t1.e*coalesce((select max(coalesce((select max(t1.e) from t1 where exists(select 1 from t1 where (c-13 between t1.e*a and 11 or (t1.f>f) or t1.c>=t1.f))),t1.b-b-11)) from t1 where (f>t1.f)),11)-t1.b*e)}\n} {19}\ndo_test randexpr-2.1534 {\n  db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when  -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end | b<>a)),t1.e) FROM t1 WHERE not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when  -c then d else 19 end) and  -17 in (select min(t1.b) from t1 union select count(distinct f) from t1))}\n} {500}\ndo_test randexpr-2.1535 {\n  db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when  -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end | b<>a)),t1.e) FROM t1 WHERE NOT (not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when  -c then d else 19 end) and  -17 in (select min(t1.b) from t1 union select count(distinct f) from t1)))}\n} {}\ndo_test randexpr-2.1536 {\n  db eval {SELECT coalesce((select t1.e from t1 where (case when 19>=t1.c then t1.d else coalesce((select max(11*t1.b) from t1 where case ~t1.c-(select max(11) from t1)*~t1.b+f*~coalesce((select max(d) from t1 where d>=b),d)-t1.a*t1.c*t1.d when  -t1.c then 13 else f end in (select b from t1 union select 13 from t1)),t1.f) end & b<>a)),t1.e) FROM t1 WHERE not exists(select 1 from t1 where not (t1.e<t1.b and t1.e<>t1.b+case (select count(distinct e)*cast(avg(case c when e then case a when f then b else d end-a-13 else 13 end*t1.a+ -t1.d) AS integer) from t1)+c | (t1.f)*f when  -c then d else 19 end) and  -17 in (select min(t1.b) from t1 union select count(distinct f) from t1))}\n} {500}\ndo_test randexpr-2.1537 {\n  db eval {SELECT coalesce((select t1.c from t1 where f between case when (abs(coalesce((select 11* -~coalesce((select a*case coalesce((select max(a) from t1 where exists(select 1 from t1 where e in (17,t1.b,13))), -t1.e) when  -a then d else c end from t1 where t1.a>=t1.e),17)+t1.a-t1.d from t1 where exists(select 1 from t1 where  -b>t1.b)),e))/abs(d))<>17 then t1.d when 11< -f then d else d end*d and 17),b)-f-t1.d FROM t1 WHERE case when e<t1.d then t1.a when t1.f>=(abs(t1.b)/abs((abs(t1.f)/abs( -case b when 19 then ((abs((case when (+case when f between e and c then t1.f when t1.b>19 then t1.e else t1.f end+11+t1.a in (select t1.c from t1 union select f from t1)) then e-(13) when not exists(select 1 from t1 where not exists(select 1 from t1 where (13)>t1.f)) then t1.c else t1.f end))/abs(t1.d))) else c end)))) then b else (t1.d) end not between t1.a and t1.a}\n} {-800}\ndo_test randexpr-2.1538 {\n  db eval {SELECT coalesce((select t1.c from t1 where f between case when (abs(coalesce((select 11* -~coalesce((select a*case coalesce((select max(a) from t1 where exists(select 1 from t1 where e in (17,t1.b,13))), -t1.e) when  -a then d else c end from t1 where t1.a>=t1.e),17)+t1.a-t1.d from t1 where exists(select 1 from t1 where  -b>t1.b)),e))/abs(d))<>17 then t1.d when 11< -f then d else d end*d and 17),b)-f-t1.d FROM t1 WHERE NOT (case when e<t1.d then t1.a when t1.f>=(abs(t1.b)/abs((abs(t1.f)/abs( -case b when 19 then ((abs((case when (+case when f between e and c then t1.f when t1.b>19 then t1.e else t1.f end+11+t1.a in (select t1.c from t1 union select f from t1)) then e-(13) when not exists(select 1 from t1 where not exists(select 1 from t1 where (13)>t1.f)) then t1.c else t1.f end))/abs(t1.d))) else c end)))) then b else (t1.d) end not between t1.a and t1.a)}\n} {}\ndo_test randexpr-2.1539 {\n  db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b | t1.a then 17 else 13 end-f | t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE not exists(select 1 from t1 where case when  -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then  -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else  -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b)}\n} {13}\ndo_test randexpr-2.1540 {\n  db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b | t1.a then 17 else 13 end-f | t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE NOT (not exists(select 1 from t1 where case when  -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then  -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else  -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b))}\n} {}\ndo_test randexpr-2.1541 {\n  db eval {SELECT case when not exists(select 1 from t1 where (coalesce((select max(coalesce((select 11 from t1 where t1.b*t1.d<=+case t1.c when (select max(case when not exists(select 1 from t1 where e=t1.b) then t1.a else f end) from t1)*t1.b & t1.a then 17 else 13 end-f & t1.e),13)) from t1 where a in (t1.b,t1.b,(t1.e))),11)*11 not in (d,t1.a,17))) then 13 when c in (select e from t1 union select t1.d from t1) then 19 else 13 end FROM t1 WHERE not exists(select 1 from t1 where case when  -b*13>+d then t1.e else coalesce((select case when not exists(select 1 from t1 where 11 in (c,+case when (case when e between t1.b and f then t1.a when t1.c not in (a,(c),t1.a) then  -t1.b else t1.a end<>d or f>e) then t1.e else t1.c end,t1.b)) then 19 else  -17 end*t1.d from t1 where (17 in (19,17,t1.f))),(t1.e)) end between 11 and t1.b and t1.a<>b)}\n} {13}\ndo_test randexpr-2.1542 {\n  db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) | 19-t1.d*f+b FROM t1 WHERE t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when  -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where  -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1)}\n} {}\ndo_test randexpr-2.1543 {\n  db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) | 19-t1.d*f+b FROM t1 WHERE NOT (t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when  -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where  -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1))}\n} {-239781}\ndo_test randexpr-2.1544 {\n  db eval {SELECT a-coalesce((select max(++19) from t1 where (select count(distinct coalesce((select max(t1.c) from t1 where not (t1.c+t1.c)-case when (not coalesce((select max(t1.a-t1.a) from t1 where t1.d>t1.b),e) in (t1.d,19,(t1.e))) then b when exists(select 1 from t1 where t1.e> -13) then c else e end<>c),17)) from t1) not between 19 and t1.f),t1.b) & 19-t1.d*f+b FROM t1 WHERE NOT (t1.f | coalesce((select case when c>=t1.f then t1.e+t1.e when  -19 | (a)+t1.f in (b,coalesce((select t1.c | (f+e)-e*17 from t1 where  -c not in (t1.d,c,(13))),19),t1.e) then t1.c else 17 end+b from t1 where t1.a not in (17,d,c)),17) in (select f from t1 union select f from t1))}\n} {81}\ndo_test randexpr-2.1545 {\n  db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 | t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end | t1.a-f from t1 union select  -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not  - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and  -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a}\n} {}\ndo_test randexpr-2.1546 {\n  db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 | t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end | t1.a-f from t1 union select  -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE NOT (coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not  - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and  -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a)}\n} {600}\ndo_test randexpr-2.1547 {\n  db eval {SELECT coalesce((select (t1.d) from t1 where not not case when c<coalesce((select f from t1 where 13 & t1.d in (select 11*t1.f*case when exists(select 1 from t1 where d>=case when f<>( -t1.c) then c when 19<>t1.d then t1.f else d end) then e-f when c in (select d from t1 union select f from t1) then a else t1.b end & t1.a-f from t1 union select  -19 from t1)),19) then 19 when 11 between f and t1.f then t1.c else 19 end=a),t1.f) FROM t1 WHERE NOT (coalesce((select t1.d from t1 where (case when exists(select 1 from t1 where not  - -19 in (17,f,t1.b)) and 19>c or t1.c in (select t1.e from t1 union select 17 from t1) then a when exists(select 1 from t1 where (t1.c<>d)) and  -t1.c not between b and e then 11 else (select cast(avg((abs(b)/abs(d))) AS integer) from t1) end+t1.d not in (t1.f,11,b) and f not between 17 and t1.d)),t1.e)=t1.a)}\n} {600}\ndo_test randexpr-2.1548 {\n  db eval {SELECT coalesce((select max(case when  -++t1.c++(abs(case when t1.b<case when exists(select 1 from t1 where  -t1.b-13=t1.e) then t1.b else c end then t1.f else case when t1.a<t1.b+t1.d then 19 when t1.f not in (t1.c,c,c) then t1.d else t1.f end end)/abs(19))*b-d>b then 11 else b end) from t1 where ((t1.b)) between e and e),t1.e) FROM t1 WHERE not ~t1.c-(coalesce((select max(~case t1.e | b*11+d+19 when t1.a then t1.b else t1.d end) from t1 where (13 not in (t1.a,t1.a,13))),e)) not between t1.a and 11 or exists(select 1 from t1 where (t1.d) not in (11,13,t1.a) and (c<>b or  -13<>t1.b and c in (t1.f, -c,t1.d)))}\n} {500}\ndo_test randexpr-2.1549 {\n  db eval {SELECT coalesce((select max(case when  -++t1.c++(abs(case when t1.b<case when exists(select 1 from t1 where  -t1.b-13=t1.e) then t1.b else c end then t1.f else case when t1.a<t1.b+t1.d then 19 when t1.f not in (t1.c,c,c) then t1.d else t1.f end end)/abs(19))*b-d>b then 11 else b end) from t1 where ((t1.b)) between e and e),t1.e) FROM t1 WHERE NOT (not ~t1.c-(coalesce((select max(~case t1.e | b*11+d+19 when t1.a then t1.b else t1.d end) from t1 where (13 not in (t1.a,t1.a,13))),e)) not between t1.a and 11 or exists(select 1 from t1 where (t1.d) not in (11,13,t1.a) and (c<>b or  -13<>t1.b and c in (t1.f, -c,t1.d))))}\n} {}\ndo_test randexpr-2.1550 {\n  db eval {SELECT case 19*d-+t1.a | coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e | 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then  -f else t1.f end | t1.b FROM t1 WHERE t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f}\n} {728}\ndo_test randexpr-2.1551 {\n  db eval {SELECT case 19*d-+t1.a | coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e | 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then  -f else t1.f end | t1.b FROM t1 WHERE NOT (t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f)}\n} {}\ndo_test randexpr-2.1552 {\n  db eval {SELECT case 19*d-+t1.a & coalesce((select f from t1 where +b between coalesce((select +t1.f from t1 where not exists(select 1 from t1 where case 17 when b then f else f end>=~13)),t1.f) and t1.d),c+11)- -t1.e & 17+case t1.b when t1.a then 17 else t1.f end*t1.c+a when f then  -f else t1.f end & t1.b FROM t1 WHERE t1.f=f and not exists(select 1 from t1 where case when t1.b>e then (abs(13)/abs(t1.f | 17))+(t1.f) else ~t1.a-(~e) end in (select count(distinct coalesce((select max(coalesce((select 11 from t1 where t1.a<d),(b))*17) from t1 where (e in (select count(*) from t1 union select max(t1.a)-cast(avg(17) AS integer)-(cast(avg(11) AS integer)) from t1))),t1.d)) from t1 union select cast(avg(c) AS integer) from t1)) and e between c and f}\n} {72}\ndo_test randexpr-2.1553 {\n  db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where  -case when b>=t1.e and e>f then 11 | 19 else t1.c end | b in (select a from t1 union select 13 from t1)),b)+t1.b | (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select  -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select  -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13)}\n} {600}\ndo_test randexpr-2.1554 {\n  db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where  -case when b>=t1.e and e>f then 11 | 19 else t1.c end | b in (select a from t1 union select 13 from t1)),b)+t1.b | (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE NOT (coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select  -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select  -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13))}\n} {}\ndo_test randexpr-2.1555 {\n  db eval {SELECT (coalesce((select max(coalesce((select (abs(t1.e* -b*coalesce((select max( -t1.e*t1.e+t1.f) from t1 where  -case when b>=t1.e and e>f then 11 & 19 else t1.c end & b in (select a from t1 union select 13 from t1)),b)+t1.b & (d)*11)/abs(e)) from t1 where a=19),t1.e)*13) from t1 where 13>f),t1.f)) FROM t1 WHERE coalesce((select max(~t1.a*t1.f*t1.b+f+a) from t1 where case when d in (select  -+count(distinct (t1.c))*max(t1.e+b)-(( -count(distinct 17))) from t1 union select  -count(distinct t1.d) from t1) then t1.d else (abs(case when t1.e in (select t1.c from t1 union select c from t1) then c else d end)/abs(f)) end in (select max( -c) from t1 union select abs(count(distinct 19)) from t1)), -a) not in (d,t1.f,13)}\n} {600}\ndo_test randexpr-2.1556 {\n  db eval {SELECT +(abs(17*(abs(a | t1.a)/abs(11)) | f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and  -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE not a not between t1.a and 11+ -coalesce((select  -c*coalesce((select max(~f*a+11-t1.a |  -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between  -b and f or 17<>13}\n} {300}\ndo_test randexpr-2.1557 {\n  db eval {SELECT +(abs(17*(abs(a | t1.a)/abs(11)) | f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and  -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE NOT (not a not between t1.a and 11+ -coalesce((select  -c*coalesce((select max(~f*a+11-t1.a |  -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between  -b and f or 17<>13)}\n} {}\ndo_test randexpr-2.1558 {\n  db eval {SELECT +(abs(17*(abs(a & t1.a)/abs(11)) & f)/abs(coalesce((select +t1.b+~a from t1 where case when a=t1.b then c when t1.d=t1.e then t1.b else 17 end<=t1.f and (b<>13) or t1.a<>a or t1.d>d and 11 between 17 and t1.a and t1.b<> -e and  -13<(17)),a)+ -t1.e))*(t1.c) FROM t1 WHERE not a not between t1.a and 11+ -coalesce((select  -c*coalesce((select max(~f*a+11-t1.a |  -a+t1.a*t1.b*f) from t1 where 11=11),t1.a)+d from t1 where 13>=e),d) | t1.b or t1.a not between  -b and f or 17<>13}\n} {0}\ndo_test randexpr-2.1559 {\n  db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) |  -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when  -a then 11 else t1.e end FROM t1 WHERE coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and  -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case  -count(distinct t1.e) when  -(max(19)) then (count(distinct 19)) else  -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1)}\n} {}\ndo_test randexpr-2.1560 {\n  db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) |  -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when  -a then 11 else t1.e end FROM t1 WHERE NOT (coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and  -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case  -count(distinct t1.e) when  -(max(19)) then (count(distinct 19)) else  -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1))}\n} {-300}\ndo_test randexpr-2.1561 {\n  db eval {SELECT b-case e*13+case when not not t1.d in (select t1.b from t1 union select f from t1) then t1.c when coalesce((select max(coalesce((select (select ~min(coalesce((select max(a*f) from t1 where t1.f<=t1.b or a<=f),t1.a)) &  -(count(distinct 19)) from t1) from t1 where f between (t1.f) and 11),a)) from t1 where 11 not in (f, -11,19)),e)>=d then t1.f else t1.c end when  -a then 11 else t1.e end FROM t1 WHERE NOT (coalesce((select case case when case when (coalesce((select max(t1.e) from t1 where c>c and  -19>= -a),d) not in (11,t1.b,t1.a)) then d else a end between 11 and t1.c then b else a end+13-t1.a when t1.d then (b) else t1.d end from t1 where b between e and t1.f),11) in (select (+abs(count(*)+case  -count(distinct t1.e) when  -(max(19)) then (count(distinct 19)) else  -count(distinct e) end-max(t1.b)) | count(distinct t1.e) | (cast(avg(11) AS integer))) from t1 union select cast(avg(c) AS integer) from t1))}\n} {-300}\ndo_test randexpr-2.1562 {\n  db eval {SELECT coalesce((select case when a not in (~17,a,c) then b when t1.c<>t1.f-13 then +f else 11 end+t1.e*t1.a+case when ((a-c)>case when (exists(select 1 from t1 where (c) between d and  -t1.b)) then a+t1.f else f end) or e between t1.c and 13 then  -t1.c else t1.e end-t1.d from t1 where ( -17=a)),e) FROM t1 WHERE +case when not exists(select 1 from t1 where f+(select ~ -min(b) | abs(+max(+c)) from t1)+b not between 13-a*17 and t1.e-t1.b) then t1.a when b not between ((11)) and 11 then 13 else 17 end+ - -t1.f in (f,t1.d,f) or t1.b>t1.a and not exists(select 1 from t1 where t1.d in (t1.c,d,t1.c))}\n} {}\ndo_test randexpr-2.1563 {\n  db eval {SELECT coalesce((select case when a not in (~17,a,c) then b when t1.c<>t1.f-13 then +f else 11 end+t1.e*t1.a+case when ((a-c)>case when (exists(select 1 from t1 where (c) between d and  -t1.b)) then a+t1.f else f end) or e between t1.c and 13 then  -t1.c else t1.e end-t1.d from t1 where ( -17=a)),e) FROM t1 WHERE NOT (+case when not exists(select 1 from t1 where f+(select ~ -min(b) | abs(+max(+c)) from t1)+b not between 13-a*17 and t1.e-t1.b) then t1.a when b not between ((11)) and 11 then 13 else 17 end+ - -t1.f in (f,t1.d,f) or t1.b>t1.a and not exists(select 1 from t1 where t1.d in (t1.c,d,t1.c)))}\n} {500}\ndo_test randexpr-2.1564 {\n  db eval {SELECT case coalesce((select 19-case when case when f in (select t1.c from t1 union select (select count(*) from t1) from t1) then a+e else 19 end*19-19-13 not in (11,19,a) then f when (13<>(t1.c) or d>e and b=b) then t1.a else 13 end from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where t1.a=17)))),a) when t1.d then 19 else e end FROM t1 WHERE 13-coalesce((select (abs(19)/abs(11)) from t1 where case when a in (select d from t1 union select case when  -11-11<>d or t1.e between (t1.d) and b then t1.f else f end from t1) then t1.e else  -a end not between 13 and 19 or exists(select 1 from t1 where f< -( -t1.d)) and t1.a not between  -e and t1.e or t1.f<f and 13=13 and t1.f>(t1.f)),t1.d)=11}\n} {}\ndo_test randexpr-2.1565 {\n  db eval {SELECT case coalesce((select 19-case when case when f in (select t1.c from t1 union select (select count(*) from t1) from t1) then a+e else 19 end*19-19-13 not in (11,19,a) then f when (13<>(t1.c) or d>e and b=b) then t1.a else 13 end from t1 where (not exists(select 1 from t1 where not exists(select 1 from t1 where t1.a=17)))),a) when t1.d then 19 else e end FROM t1 WHERE NOT (13-coalesce((select (abs(19)/abs(11)) from t1 where case when a in (select d from t1 union select case when  -11-11<>d or t1.e between (t1.d) and b then t1.f else f end from t1) then t1.e else  -a end not between 13 and 19 or exists(select 1 from t1 where f< -( -t1.d)) and t1.a not between  -e and t1.e or t1.f<f and 13=13 and t1.f>(t1.f)),t1.d)=11)}\n} {500}\ndo_test randexpr-2.1566 {\n  db eval {SELECT (select  -count(distinct  -case (select (max( -c-t1.b+~f)*count(distinct 11) | +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a | t1.d+t1.d) from t1) FROM t1 WHERE not 11-t1.a=a+11}\n} {-1}\ndo_test randexpr-2.1567 {\n  db eval {SELECT (select  -count(distinct  -case (select (max( -c-t1.b+~f)*count(distinct 11) | +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a | t1.d+t1.d) from t1) FROM t1 WHERE NOT (not 11-t1.a=a+11)}\n} {}\ndo_test randexpr-2.1568 {\n  db eval {SELECT (select  -count(distinct  -case (select (max( -c-t1.b+~f)*count(distinct 11) & +cast(avg(11) AS integer)-min(t1.f)+ -(cast(avg(( -11)) AS integer))-count(distinct t1.d)*(max(13))*(max(d))-(count(*))-min(e)) from t1) when + -c then t1.d else t1.b*19 end-a & t1.d+t1.d) from t1) FROM t1 WHERE not 11-t1.a=a+11}\n} {-1}\ndo_test randexpr-2.1569 {\n  db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) | min(case when d | f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) | cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19}\n} {}\ndo_test randexpr-2.1570 {\n  db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) | min(case when d | f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) | cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE NOT (coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19)}\n} {-119980000}\ndo_test randexpr-2.1571 {\n  db eval {SELECT (select ~count(distinct t1.d*e+19)+abs(+cast(avg((select (count(*)) from t1)) AS integer)-cast(avg(t1.c) AS integer) & min(case when d & f* -19 in (select min(c) from t1 union select ~count(*)-max(17) from t1) then t1.e when (t1.b between 17 and (b)) then t1.d else t1.d end)*cast(avg(e) AS integer))-count(distinct t1.f) & cast(avg( -d) AS integer)*cast(avg(f) AS integer) from t1)*t1.e FROM t1 WHERE NOT (coalesce((select 17 from t1 where coalesce((select max(case when 13-b+coalesce((select case when (f>a) then t1.f when t1.c<=19 then a else a end from t1 where c in (select (e) from t1 union select 13 from t1)),13)<13 then 13 else t1.b end) from t1 where (13)<>13),17) in (select +min(b) from t1 union select ~max(t1.d)*max( -t1.b)*min(t1.e) from t1) and e>c),f) between ((t1.f)) and b and t1.a=19)}\n} {512000}\ndo_test randexpr-2.1572 {\n  db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) | ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d}\n} {500}\ndo_test randexpr-2.1573 {\n  db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) | ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE NOT (case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d)}\n} {}\ndo_test randexpr-2.1574 {\n  db eval {SELECT coalesce((select d from t1 where case when (17 between c+t1.d-t1.a and b and t1.b in (13,t1.d,19)) then case when t1.c<(a) then t1.c when t1.e not in (a,11,(t1.d)) then t1.d else d end else t1.a end in (select abs(min(a) & ~~count(distinct t1.e)+min(b)-count(*)) from t1 union select count(*) from t1) and not exists(select 1 from t1 where (t1.a) between t1.a and t1.d)),t1.f)-t1.a FROM t1 WHERE case when t1.e not in (coalesce((select max(coalesce((select max(b+t1.c-19*(e)-~11) from t1 where t1.a in (select ~cast(avg(~t1.a) AS integer) from t1 union select abs(~cast(avg(f) AS integer)) from t1)),e)* -c-c-b-t1.d-f) from t1 where t1.f>=t1.c),((t1.d)))- - -19,17,t1.b) then b else t1.f end<d}\n} {500}\ndo_test randexpr-2.1575 {\n  db eval {SELECT (abs((select min(t1.a)*~+ -count(*)-max(t1.f) from t1))/abs((abs(13*~t1.c- -e-( -19) | case 17*~13 when t1.c+case when not 19 between 13 and a then t1.c when  -11 not between e and 17 then 19 else a end then 19 else 17 end*19)/abs(t1.d)))) FROM t1 WHERE t1.e in (select d from t1 union select case when not exists(select 1 from t1 where c+a*17 not between case when t1.f>=(t1.f)+a then t1.d else 19 end and t1.c or exists(select 1 from t1 where (b in (13,13,b)) and (t1.f<>t1.e)) or (13)<>17 and e<=f and e<= -c) and t1.f>f then t1.e*19-t1.e-b else 17 end from t1)}\n} {}\ndo_test randexpr-2.1576 {\n  db eval {SELECT (abs((select min(t1.a)*~+ -count(*)-max(t1.f) from t1))/abs((abs(13*~t1.c- -e-( -19) | case 17*~13 when t1.c+case when not 19 between 13 and a then t1.c when  -11 not between e and 17 then 19 else a end then 19 else 17 end*19)/abs(t1.d)))) FROM t1 WHERE NOT (t1.e in (select d from t1 union select case when not exists(select 1 from t1 where c+a*17 not between case when t1.f>=(t1.f)+a then t1.d else 19 end and t1.c or exists(select 1 from t1 where (b in (13,13,b)) and (t1.f<>t1.e)) or (13)<>17 and e<=f and e<= -c) and t1.f>f then t1.e*19-t1.e-b else 17 end from t1))}\n} {85}\ndo_test randexpr-2.1577 {\n  db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) | count(distinct t1.e)) | cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then  -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else  -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE t1.a<> -a}\n} {0}\ndo_test randexpr-2.1578 {\n  db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) | count(distinct t1.e)) | cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then  -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else  -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE NOT (t1.a<> -a)}\n} {}\ndo_test randexpr-2.1579 {\n  db eval {SELECT b-t1.b-coalesce((select (abs(case t1.c+coalesce((select +17*case when b in (select abs(max(19) & count(distinct t1.e)) & cast(avg(t1.d) AS integer) from t1 union select (count(*)) from t1) then +11+t1.a when 11<d then  -b else t1.c end from t1 where t1.f not between d and t1.c),t1.d)-13*t1.b when e then t1.e else  -17 end)/abs( - -d)) from t1 where (t1.a<>e)),d) FROM t1 WHERE t1.a<> -a}\n} {0}\ndo_test randexpr-2.1580 {\n  db eval {SELECT ~(abs(b*t1.b)/abs(case when coalesce((select max((abs(a)/abs(case t1.e when t1.e then c*(t1.d) else t1.a end))) from t1 where b in (select min((t1.a)) from t1 union select + -max(b) from t1)),19)+a not between t1.e and  -19 and 13<=a then (select case cast(avg((a)) AS integer) when min(e)*max(f) then  -(count(distinct 13)) else cast(avg(13) AS integer) end-count(*) | count(distinct d) |  -count(*) from t1) else b end)) FROM t1 WHERE f not between t1.d and b}\n} {-40001}\ndo_test randexpr-2.1581 {\n  db eval {SELECT ~(abs(b*t1.b)/abs(case when coalesce((select max((abs(a)/abs(case t1.e when t1.e then c*(t1.d) else t1.a end))) from t1 where b in (select min((t1.a)) from t1 union select + -max(b) from t1)),19)+a not between t1.e and  -19 and 13<=a then (select case cast(avg((a)) AS integer) when min(e)*max(f) then  -(count(distinct 13)) else cast(avg(13) AS integer) end-count(*) | count(distinct d) |  -count(*) from t1) else b end)) FROM t1 WHERE NOT (f not between t1.d and b)}\n} {}\ndo_test randexpr-2.1582 {\n  db eval {SELECT +(abs(19)/abs(d | 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) | coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE t1.b>=e}\n} {}\ndo_test randexpr-2.1583 {\n  db eval {SELECT +(abs(19)/abs(d | 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) | coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE NOT (t1.b>=e)}\n} {-100}\ndo_test randexpr-2.1584 {\n  db eval {SELECT +(abs(19)/abs(d & 11*t1.f))*t1.e-coalesce((select t1.b from t1 where not ((f*case when a>=17 then t1.c else (a) end-b not in (t1.b,t1.f,t1.f) or not exists(select 1 from t1 where t1.c>t1.a) and c not in (t1.d,t1.b,c)))),e) & coalesce((select ( - -f) from t1 where 19 not between 17 and 17),(a))-17*d*c FROM t1 WHERE NOT (t1.b>=e)}\n} {-2039800}\ndo_test randexpr-2.1585 {\n  db eval {SELECT (abs((abs(a)/abs(~17+t1.b-e+(abs(a)/abs(coalesce((select max(13) from t1 where c not in (c-(abs(+coalesce((select max(t1.b-f) from t1 where (abs(13+case ~t1.f when t1.c then t1.b else b end-e)/abs(c))-t1.e>t1.c),t1.c))/abs(11))+t1.b,t1.a,11)),t1.a)))))+19)/abs( - -t1.c)) FROM t1 WHERE ~t1.e+t1.a+(abs(case when d+e+17*~t1.a-t1.a-a*~(abs(~f)/abs( -13))*+(t1.c | a)*t1.b=e then t1.d when ( -e) not between c and  -d then  -(t1.f) else t1.b end)/abs(19))>t1.f and 11<(11)}\n} {}\ndo_test randexpr-2.1586 {\n  db eval {SELECT (abs((abs(a)/abs(~17+t1.b-e+(abs(a)/abs(coalesce((select max(13) from t1 where c not in (c-(abs(+coalesce((select max(t1.b-f) from t1 where (abs(13+case ~t1.f when t1.c then t1.b else b end-e)/abs(c))-t1.e>t1.c),t1.c))/abs(11))+t1.b,t1.a,11)),t1.a)))))+19)/abs( - -t1.c)) FROM t1 WHERE NOT (~t1.e+t1.a+(abs(case when d+e+17*~t1.a-t1.a-a*~(abs(~f)/abs( -13))*+(t1.c | a)*t1.b=e then t1.d when ( -e) not between c and  -d then  -(t1.f) else t1.b end)/abs(19))>t1.f and 11<(11))}\n} {0}\ndo_test randexpr-2.1587 {\n  db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) | max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then  -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b)}\n} {}\ndo_test randexpr-2.1588 {\n  db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) | max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE NOT (d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then  -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b))}\n} {0}\ndo_test randexpr-2.1589 {\n  db eval {SELECT (abs((abs( -t1.e)/abs(~17+b)))/abs((case 19 when case when t1.b in (select ~cast(avg(19) AS integer) from t1 union select max(t1.b) from t1) then case when case when exists(select 1 from t1 where t1.c not between d and e) then (11) when t1.d<11 then ( -t1.f) else c end in (select count(distinct 17) from t1 union select ~min(a) & max( -t1.a)- -min(b) from t1) then d else 17 end when 13> -t1.b then f else d end then (t1.b) else c end))) FROM t1 WHERE NOT (d in (b,+(abs(t1.b | t1.e)/abs(coalesce((select max(t1.b) from t1 where t1.f=(e*+t1.b-t1.d+b-t1.f-t1.a-case case a*t1.b when coalesce((select max(f) from t1 where c<11),(a)) then  -t1.b else t1.f end when e then d else 19 end*t1.e+19)*d),t1.b))),t1.b))}\n} {0}\ndo_test randexpr-2.1590 {\n  db eval {SELECT c | case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else  -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then  -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d | t1.a then  -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a)}\n} {317}\ndo_test randexpr-2.1591 {\n  db eval {SELECT c | case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else  -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then  -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d | t1.a then  -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE NOT (coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a))}\n} {}\ndo_test randexpr-2.1592 {\n  db eval {SELECT c & case when e<=(abs(case when case when not exists(select 1 from t1 where case when t1.f>case when 19>=17 or f in (19,c,t1.d) then t1.b else b end then t1.e else  -t1.b end*t1.d in (select t1.e from t1 union select c from t1)) then e else f end<>t1.d then  -a when (11 in (select b from t1 union select a from t1)) then 19 else t1.a end-(c))/abs(c))+t1.d & t1.a then  -19 else 17 end+t1.d-(t1.a) FROM t1 WHERE coalesce((select 13 from t1 where not exists(select 1 from t1 where t1.e*t1.d*t1.f>=(11) and d in (13,coalesce((select t1.f+t1.b from t1 where coalesce((select max(t1.a) from t1 where not (t1.d)<=t1.c),c) not in (t1.e,t1.d,b)),b)+f,d)) or (t1.f>f) or 11<=t1.d and 17<>13),a)<(t1.a)}\n} {300}\ndo_test randexpr-2.1593 {\n  db eval {SELECT  -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when  -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select  -count(*)-~+cast(avg(11) AS integer) | cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c))}\n} {}\ndo_test randexpr-2.1594 {\n  db eval {SELECT  -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when  -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select  -count(*)-~+cast(avg(11) AS integer) | cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c)))}\n} {-360489}\ndo_test randexpr-2.1595 {\n  db eval {SELECT  -+t1.f*coalesce((select 17 from t1 where b in (coalesce((select f- -11 from t1 where not exists(select 1 from t1 where t1.d*a<=(case when  -17<t1.c or d in (c,t1.f,c) then 13 else 13 end-e+t1.d) or 17 in (select count(distinct t1.c) from t1 union select  -count(*)-~+cast(avg(11) AS integer) & cast(avg((t1.b)) AS integer)* -cast(avg(d) AS integer)+count(distinct t1.c) from t1))),19),t1.f,e)),(f))+11-e FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where ((exists(select 1 from t1 where not b | t1.d<t1.f)))) or t1.b | f | b>=d-coalesce((select a from t1 where coalesce((select max(19) from t1 where case when 13 between coalesce((select max(b) from t1 where t1.e in (c,t1.a,17)),(a)) and ((17)) then t1.b when f=t1.b then t1.f else 17 end>t1.b),e)+b*a>=t1.a),c)))}\n} {-360489}\ndo_test randexpr-2.1596 {\n  db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) | t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE 17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or  -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case  -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else  -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else  -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) |  -cast(avg(11) AS integer) from t1)}\n} {}\ndo_test randexpr-2.1597 {\n  db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) | t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE NOT (17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or  -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case  -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else  -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else  -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) |  -cast(avg(11) AS integer) from t1))}\n} {-293}\ndo_test randexpr-2.1598 {\n  db eval {SELECT ~f+coalesce((select max(17+~a+t1.b) from t1 where 17>t1.c),c+case when t1.f*d not between t1.f-13 and ~t1.b then 19 when t1.a between case coalesce((select 17 from t1 where (e in (f,e,t1.b))),13) & t1.a* - -c*t1.f-a+a when e then t1.a else 13 end and b then b else e end)-11 FROM t1 WHERE NOT (17=19*~d-case when (exists(select 1 from t1 where 17-e not between t1.b and f) or  -f not in ( -13,b,c) and t1.f not between t1.f and 13) then 13 else coalesce((select t1.f from t1 where 11 not in (a,(e),t1.f)),(t1.c)) end+t1.c or 17 in (select +(count(*)) from t1 union select ~+case  -min(t1.b) when case case max(19) when cast(avg((b)) AS integer) then (count(distinct t1.b)) else  -cast(avg(t1.b) AS integer) end when ( -max(t1.e)) then max(17) else  -count(distinct t1.f) end then cast(avg(19) AS integer) else count(*) end-count(*) |  -cast(avg(11) AS integer) from t1))}\n} {-293}\ndo_test randexpr-2.1599 {\n  db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e | t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then  -t1.e else t1.a end) FROM t1 WHERE 11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11}\n} {}\ndo_test randexpr-2.1600 {\n  db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e | t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then  -t1.e else t1.a end) FROM t1 WHERE NOT (11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11)}\n} {100}\ndo_test randexpr-2.1601 {\n  db eval {SELECT (case when (select count(*) from t1)++t1.d+b*t1.e & t1.a+coalesce((select max(t1.d) from t1 where d-19<>c),t1.a)+t1.f in (select coalesce((select max(b) from t1 where t1.c-case when t1.c in (select c from t1 union select t1.f from t1) then f when t1.c not in ( -e,t1.e,11) then (t1.e) else 13 end in (f,t1.e,t1.f) or t1.a not between 19 and 17),t1.c) from t1 union select e from t1) then  -t1.e else t1.a end) FROM t1 WHERE NOT (11*b+~ -coalesce((select t1.e from t1 where not exists(select 1 from t1 where 19=t1.f)),t1.d+(abs( -a)/abs(t1.d)))-t1.d-19<=11)}\n} {100}\ndo_test randexpr-2.1602 {\n  db eval {SELECT 19+~case when not not (select + - -min(f | f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b | a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE +t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end}\n} {-482}\ndo_test randexpr-2.1603 {\n  db eval {SELECT 19+~case when not not (select + - -min(f | f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b | a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE NOT (+t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end)}\n} {}\ndo_test randexpr-2.1604 {\n  db eval {SELECT 19+~case when not not (select + - -min(f & f)-count(*)+count(*)-min(b)+count(distinct a) from t1)<=13-case when +13 between t1.a and a then 11 else 11 end and (11 not in (17, -t1.d,(f))) then t1.b & a-t1.f when t1.d<>17 then e else 17 end FROM t1 WHERE +t1.e-c<>case when c in (select d from t1 union select f from t1) then case (case when 13 in (select +c*a*13-11 from t1 union select b from t1) then t1.a when t1.f in ( -t1.f,11,a) or t1.a<=f or (exists(select 1 from t1 where 13>=d)) then t1.c else b end) when t1.d then 11 else e end when t1.b in (19,t1.d,(19)) then c else a end}\n} {-482}\ndo_test randexpr-2.1605 {\n  db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) |  - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and  - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE b<=13}\n} {}\ndo_test randexpr-2.1606 {\n  db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) |  - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and  - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE NOT (b<=13)}\n} {619}\ndo_test randexpr-2.1607 {\n  db eval {SELECT (case when e not between 19 and t1.a then case coalesce((select t1.e from t1 where (exists(select 1 from t1 where c in (select case count(distinct t1.b) when max(b) then min((t1.d)) else count(distinct 11) end+ -count(*) &  - -count(distinct t1.e) from t1 union select min(f) from t1))) or (select min(17) from t1) not between 13 and b and  - -c<e),t1.a)+f when (select cast(avg(a) AS integer) from t1) then 19 else 19 end when not 13>=17 and 17 between t1.e and 13 or 13>d or 11>= -t1.d then a else 13 end)+t1.f FROM t1 WHERE NOT (b<=13)}\n} {619}\ndo_test randexpr-2.1608 {\n  db eval {SELECT case c when d then +e else 17-e+case when exists(select 1 from t1 where not  -f<19) then (a) when t1.a between case when t1.d- -~t1.a+(select case min(t1.a) when count(distinct t1.e) then max(f) else max(t1.f) end-min(t1.b) from t1)*(select max(17) from t1)+e*13-f in (t1.d,f,d) then f else t1.b end and b then t1.d else d end end FROM t1 WHERE b<>c*f}\n} {-83}\ndo_test randexpr-2.1609 {\n  db eval {SELECT case c when d then +e else 17-e+case when exists(select 1 from t1 where not  -f<19) then (a) when t1.a between case when t1.d- -~t1.a+(select case min(t1.a) when count(distinct t1.e) then max(f) else max(t1.f) end-min(t1.b) from t1)*(select max(17) from t1)+e*13-f in (t1.d,f,d) then f else t1.b end and b then t1.d else d end end FROM t1 WHERE NOT (b<>c*f)}\n} {}\ndo_test randexpr-2.1610 {\n  db eval {SELECT  -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select  -max(c++t1.d | +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE  -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then  -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1)}\n} {}\ndo_test randexpr-2.1611 {\n  db eval {SELECT  -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select  -max(c++t1.d | +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE NOT ( -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then  -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1))}\n} {-500}\ndo_test randexpr-2.1612 {\n  db eval {SELECT  -(select min(coalesce((select max(case when d>=t1.c then f-t1.c else t1.b end) from t1 where case when (17)-13<=(abs(a-e)/abs(19-t1.a)) then (select  -max(c++t1.d & +case when 19 in (select b from t1 union select t1.c from t1) then t1.d else f end) from t1) else 11-19 end not in (e,t1.e,17)),c)+t1.b) from t1) FROM t1 WHERE NOT ( -case when case when e=case when not 17>+t1.d and b*b in (e, -d,13) then  -b*c else t1.e end then t1.f when e>=a then c else 19 end+t1.e<> -t1.d then 11 when not 11<>13 then 13 else e end*17*t1.d+t1.f in (select e from t1 union select t1.b from t1))}\n} {-500}\ndo_test randexpr-2.1613 {\n  db eval {SELECT case when b<=(abs(19)/abs(t1.a)) | 13-b then +f | ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then  -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE (t1.e in (select +17 from t1 union select 11 from t1))}\n} {}\ndo_test randexpr-2.1614 {\n  db eval {SELECT case when b<=(abs(19)/abs(t1.a)) | 13-b then +f | ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then  -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE NOT ((t1.e in (select +17 from t1 union select 11 from t1)))}\n} {-201}\ndo_test randexpr-2.1615 {\n  db eval {SELECT case when b<=(abs(19)/abs(t1.a)) & 13-b then +f & ~d else ~case when case case when t1.c in (select 13+19 from t1 union select t1.a from t1) then  -c when 13 between t1.a and b then 17 else c end when t1.c then e else 11 end between t1.e and 11 or f in (select 17 from t1 union select (a) from t1) then t1.f-d when t1.b in (select t1.f from t1 union select t1.f from t1) then t1.c else t1.b end end FROM t1 WHERE NOT ((t1.e in (select +17 from t1 union select 11 from t1)))}\n} {-201}\ndo_test randexpr-2.1616 {\n  db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select  -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) | t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE t1.f<>(abs(t1.c)/abs(t1.a))}\n} {400}\ndo_test randexpr-2.1617 {\n  db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select  -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) | t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE NOT (t1.f<>(abs(t1.c)/abs(t1.a)))}\n} {}\ndo_test randexpr-2.1618 {\n  db eval {SELECT coalesce((select coalesce((select coalesce((select ~e+coalesce((select  -e-+17 from t1 where (select cast(avg(11) AS integer) from t1) between case when +13+13 between 19 and t1.c then t1.d else 13 end and 13),t1.c)* -(19)+17-t1.a+e from t1 where t1.b>=t1.f),t1.b) & t1.f from t1 where f in (select d from t1 union select 11 from t1)),t1.b) from t1 where t1.b=13),t1.d) FROM t1 WHERE t1.f<>(abs(t1.c)/abs(t1.a))}\n} {400}\ndo_test randexpr-2.1619 {\n  db eval {SELECT (abs(a)/abs(coalesce((select case when coalesce((select d from t1 where d+case (coalesce((select max(e) from t1 where 17+f*13-(case 19 when t1.f then 17 else t1.e end)<>b),17)) when t1.e then t1.e else t1.a end- -13+ -t1.f between b and f),11)+t1.d between 13 and t1.d then b else (19) end-t1.c from t1 where c in (select t1.e from t1 union select f from t1)),b))) FROM t1 WHERE d>t1.a}\n} {0}\ndo_test randexpr-2.1620 {\n  db eval {SELECT (abs(a)/abs(coalesce((select case when coalesce((select d from t1 where d+case (coalesce((select max(e) from t1 where 17+f*13-(case 19 when t1.f then 17 else t1.e end)<>b),17)) when t1.e then t1.e else t1.a end- -13+ -t1.f between b and f),11)+t1.d between 13 and t1.d then b else (19) end-t1.c from t1 where c in (select t1.e from t1 union select f from t1)),b))) FROM t1 WHERE NOT (d>t1.a)}\n} {}\ndo_test randexpr-2.1621 {\n  db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) | t1.c FROM t1 WHERE c<=e}\n} {892}\ndo_test randexpr-2.1622 {\n  db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) | t1.c FROM t1 WHERE NOT (c<=e)}\n} {}\ndo_test randexpr-2.1623 {\n  db eval {SELECT coalesce((select case when coalesce((select max(coalesce((select max(e-c-coalesce((select max(c) from t1 where 19 between 13 and 13),(abs(case when c<=17 or f in (t1.a, -17,t1.f) then b else t1.c end)/abs(e))+t1.b)) from t1 where not exists(select 1 from t1 where t1.e>=b)),e)) from t1 where not exists(select 1 from t1 where 13<=t1.b or t1.f in (select d from t1 union select t1.d from t1))),17) in (select 11 from t1 union select t1.d from t1) then c else t1.e end from t1 where t1.c in (select b from t1 union select b from t1)),f) & t1.c FROM t1 WHERE c<=e}\n} {8}\ndo_test randexpr-2.1624 {\n  db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then  -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c | t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when  -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then  -t1.b else  -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e}\n} {3400}\ndo_test randexpr-2.1625 {\n  db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then  -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c | t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE NOT (c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when  -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then  -t1.b else  -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e)}\n} {}\ndo_test randexpr-2.1626 {\n  db eval {SELECT (select +max(case when t1.a in (f,case when f in (t1.b,+ -(select count(*)-min(17) from t1)+19,11) then  -19 else 19 end*(abs(b)/abs(a)),a) then t1.b when (case a when 17 then c & t1.d else t1.c end+11)-13 in (b,11,f) then b else 17 end*17) from t1) FROM t1 WHERE c between (abs(case when (abs(d+19)/abs(19))-c*t1.d+t1.e+case when  -(abs(case when exists(select 1 from t1 where exists(select 1 from t1 where 13 in (select cast(avg(t1.b) AS integer) from t1 union select max(d) from t1))) then ~c when t1.d not between 13 and d then  -t1.b else  -f end)/abs(t1.b))+d in (t1.e,(13),e) then e when (b)<>d then t1.b else 19 end in (select 17 from t1 union select e from t1) then t1.e else t1.e end)/abs(t1.f)) and t1.e}\n} {3400}\ndo_test randexpr-2.1627 {\n  db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d | coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE (t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a)}\n} {}\ndo_test randexpr-2.1628 {\n  db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d | coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE NOT ((t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a))}\n} {-200}\ndo_test randexpr-2.1629 {\n  db eval {SELECT case when c between f and t1.f*t1.f then (coalesce((select max(d & coalesce((select 19+t1.c from t1 where t1.a between d and (b)),(t1.f))*t1.f*t1.b) from t1 where 11>13 or 19 not between 13 and 11 or t1.a>=b or b>t1.e or 11=a and t1.b<=d),f)) when a in (select min(t1.b)-abs(count(distinct 11)) from t1 union select cast(avg(t1.d) AS integer) from t1) then f else c end-t1.e FROM t1 WHERE NOT ((t1.f+a)*t1.b+(abs(b)/abs(b)) in (t1.e,case when 11-t1.a+e+case 19 when +11+ -t1.b then case ~t1.f*(f)-b when d then a else ( -c) end*(c) else t1.a end+t1.a not in (17,11,t1.e) then t1.b else (d) end*19,t1.a))}\n} {-200}\ndo_test randexpr-2.1630 {\n  db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a | a | 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) | count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11}\n} {}\ndo_test randexpr-2.1631 {\n  db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a | a | 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) | count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE NOT (case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11)}\n} {600}\ndo_test randexpr-2.1632 {\n  db eval {SELECT coalesce((select max(f) from t1 where (a+13>19*t1.e+a & a & 17*e or ~c not between 17 and 19*(select +(~count(distinct e)*(cast(avg(t1.b) AS integer))) & count(distinct t1.c) from t1)-f and t1.a*t1.f+c not between t1.f and f)),t1.c*(t1.e)*e) FROM t1 WHERE NOT (case case t1.f when ~17 then 11 else t1.d end when a then t1.a else e end>d*11)}\n} {600}\ndo_test randexpr-2.1633 {\n  db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) | 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end | t1.d FROM t1 WHERE 17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where  -t1.a in (select min(coalesce((select 11 from t1 where  -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct  -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1)}\n} {}\ndo_test randexpr-2.1634 {\n  db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) | 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end | t1.d FROM t1 WHERE NOT (17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where  -t1.a in (select min(coalesce((select 11 from t1 where  -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct  -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1))}\n} {500}\ndo_test randexpr-2.1635 {\n  db eval {SELECT case when e<11 then (case case t1.a when coalesce((select max(11) from t1 where t1.c<=case when exists(select 1 from t1 where 13=e) then case when c not in (t1.f,t1.e,c) then c else ~(c)+d*f end when a>b then 11 else 11 end),(t1.c)) & 11 then b else t1.a end when 11 then t1.f else t1.d end) when d<c then t1.f else (e) end & t1.d FROM t1 WHERE NOT (17 in (select case t1.e+ -coalesce((select max(coalesce((select max(e+t1.a) from t1 where  -t1.a in (select min(coalesce((select 11 from t1 where  -t1.a in (select a from t1 union select t1.e from t1)),t1.c))+(~cast(avg(f) AS integer)) from t1 union select case abs(( -count(distinct t1.e))) when count(distinct  -11) then count(distinct t1.b) else (max(t1.c)) end from t1)),t1.f)) from t1 where t1.c in (t1.c,t1.f,f)),c)-t1.b-t1.c-(t1.d) when 17 then 17 else t1.c end from t1 union select c from t1))}\n} {400}\ndo_test randexpr-2.1636 {\n  db eval {SELECT case coalesce((select a from t1 where exists(select 1 from t1 where t1.e>f)),17) when coalesce((select max((b)) from t1 where not case (abs(t1.b)/abs(t1.d+t1.b)) when t1.d then f-coalesce((select max(a) from t1 where case t1.e when c then c else 11 end not between b and  -t1.b),t1.e) else t1.a end-17 between t1.e and f and (t1.e<e) and t1.d>17), -e)*19 then t1.b else t1.c end FROM t1 WHERE not  -coalesce((select d from t1 where exists(select 1 from t1 where coalesce((select max(case when 11 not in (case when d*11<>17-(t1.e) then 13 else c end,t1.d,t1.c) then e else t1.c end) from t1 where t1.d<= - -d),11) in (select + -case (+ -cast(avg(19) AS integer)+ - -(count(*))* -count(distinct ((t1.e)))*max(d)) when count(*) then max(b) else count(*) end from t1 union select count(*) from t1))),t1.d)+13>a}\n} {300}\ndo_test randexpr-2.1637 {\n  db eval {SELECT case coalesce((select a from t1 where exists(select 1 from t1 where t1.e>f)),17) when coalesce((select max((b)) from t1 where not case (abs(t1.b)/abs(t1.d+t1.b)) when t1.d then f-coalesce((select max(a) from t1 where case t1.e when c then c else 11 end not between b and  -t1.b),t1.e) else t1.a end-17 between t1.e and f and (t1.e<e) and t1.d>17), -e)*19 then t1.b else t1.c end FROM t1 WHERE NOT (not  -coalesce((select d from t1 where exists(select 1 from t1 where coalesce((select max(case when 11 not in (case when d*11<>17-(t1.e) then 13 else c end,t1.d,t1.c) then e else t1.c end) from t1 where t1.d<= - -d),11) in (select + -case (+ -cast(avg(19) AS integer)+ - -(count(*))* -count(distinct ((t1.e)))*max(d)) when count(*) then max(b) else count(*) end from t1 union select count(*) from t1))),t1.d)+13>a)}\n} {}\ndo_test randexpr-2.1638 {\n  db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d | t1.e when 19>b then 13 else t1.a end*e*13 | 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11}\n} {}\ndo_test randexpr-2.1639 {\n  db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d | t1.e when 19>b then 13 else t1.a end*e*13 | 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE NOT (d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11)}\n} {-3600000}\ndo_test randexpr-2.1640 {\n  db eval {SELECT ~coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.e-t1.e in (select t1.c+case d when case when not case when t1.f between ( -t1.a) and (b) or 11<>19 then (abs(t1.e)/abs(t1.f)) else e end between t1.b and e then t1.d & t1.e when 19>b then 13 else t1.a end*e*13 & 11+t1.f then t1.b else 17 end from t1 union select e from t1))),t1.a-t1.b)*t1.d*e FROM t1 WHERE NOT (d in (select 11 from t1 union select +11 from t1) or coalesce((select max(coalesce((select b-e*case when (c) | e | b in (select 19*t1.d from t1 union select t1.e from t1) then t1.d else e end from t1 where t1.a<11),d)) from t1 where (not ((17 not in ( -t1.a,e,d) and 13<11) and f>=11))),t1.b)<11)}\n} {-3600000}\ndo_test randexpr-2.1641 {\n  db eval {SELECT case b-f when t1.a then  -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) |  -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then  -11 else t1.a end else 17 end FROM t1 WHERE  -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a}\n} {}\ndo_test randexpr-2.1642 {\n  db eval {SELECT case b-f when t1.a then  -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) |  -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then  -11 else t1.a end else 17 end FROM t1 WHERE NOT ( -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a)}\n} {17}\ndo_test randexpr-2.1643 {\n  db eval {SELECT case b-f when t1.a then  -case when not (case t1.a when (select case cast(avg(c) AS integer) when count(distinct t1.f) then +max(t1.e) &  -((( -(count(*))))) else cast(avg(f) AS integer) end from t1)-b then a else coalesce((select t1.a from t1 where (e<d)),t1.d) end not between t1.a and t1.f) then coalesce((select max(13) from t1 where (13)=e),t1.d) when d not in (a,t1.f,c) then  -11 else t1.a end else 17 end FROM t1 WHERE NOT ( -13*t1.b-c-e+case when t1.b | b in (select cast(avg(t1.a | +(select abs(+count(*))-count(distinct (t1.f))*abs(min(t1.d))+count(distinct case when exists(select 1 from t1 where (19)>=a and e>c) or c not between a and 19 then 11 when t1.b not between e and t1.a then 17 else 11 end) from t1)) AS integer) from t1 union select cast(avg((abs(b)/abs(t1.f))) AS integer) from t1) then 17 else t1.e end>=a)}\n} {17}\ndo_test randexpr-2.1644 {\n  db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) | e FROM t1 WHERE +t1.c>t1.d}\n} {}\ndo_test randexpr-2.1645 {\n  db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) | e FROM t1 WHERE NOT (+t1.c>t1.d)}\n} {1823220}\ndo_test randexpr-2.1646 {\n  db eval {SELECT coalesce((select max((abs(t1.b*t1.d*case when f*t1.d<a*17* -t1.c+coalesce((select max(a) from t1 where 11>b),t1.d*19)*e+c+t1.d then t1.c when exists(select 1 from t1 where 13>=e) then t1.e else f end-f*e)/abs(13))) from t1 where (a)<=t1.d),13) & e FROM t1 WHERE NOT (+t1.c>t1.d)}\n} {356}\ndo_test randexpr-2.1647 {\n  db eval {SELECT case when not exists(select 1 from t1 where 17>=19) or t1.c in (select min(19)-(cast(avg(f) AS integer)) from t1 union select cast(avg(19) AS integer) from t1) and e in (select ~+count(distinct 19)*max(13) from t1 union select min(17+d) from t1) or t1.f in (select count(*) from t1 union select (max(a)) from t1) then coalesce((select  -d- -t1.d from t1 where b in (select cast(avg(c) AS integer) from t1 union select (count(*)) from t1) or b<=11),e) else t1.e end FROM t1 WHERE a< -13}\n} {}\ndo_test randexpr-2.1648 {\n  db eval {SELECT case when not exists(select 1 from t1 where 17>=19) or t1.c in (select min(19)-(cast(avg(f) AS integer)) from t1 union select cast(avg(19) AS integer) from t1) and e in (select ~+count(distinct 19)*max(13) from t1 union select min(17+d) from t1) or t1.f in (select count(*) from t1 union select (max(a)) from t1) then coalesce((select  -d- -t1.d from t1 where b in (select cast(avg(c) AS integer) from t1 union select (count(*)) from t1) or b<=11),e) else t1.e end FROM t1 WHERE NOT (a< -13)}\n} {500}\ndo_test randexpr-2.1649 {\n  db eval {SELECT f+case when 17-t1.f in (select ~count(distinct (abs((abs(c)/abs(c)))/abs((abs(11)/abs(+case  -t1.a when t1.d then  -13 else 17 end))))-t1.c) from t1 union select ~case cast(avg(t1.c) AS integer) when  -~ -count(*)*max((t1.f))+count(*) then (min(d)) else max(a) end-count(distinct t1.a)+ -count(*)-count(*) from t1) then d when b not between t1.f and t1.e then a else 11 end+t1.a FROM t1 WHERE (exists(select 1 from t1 where case when exists(select 1 from t1 where case when (t1.e+case (t1.b) when f then case t1.c when 11 |  -13-coalesce((select max(d) from t1 where c not in ( -t1.e,t1.c,17) and t1.c<17),e)*17+t1.a then t1.b else 11 end else d end)+t1.f not in (d,13,d) then f else t1.d end not between (c) and f) then t1.e else f end-t1.c in (t1.b,t1.a,f)))}\n} {}\ndo_test randexpr-2.1650 {\n  db eval {SELECT f+case when 17-t1.f in (select ~count(distinct (abs((abs(c)/abs(c)))/abs((abs(11)/abs(+case  -t1.a when t1.d then  -13 else 17 end))))-t1.c) from t1 union select ~case cast(avg(t1.c) AS integer) when  -~ -count(*)*max((t1.f))+count(*) then (min(d)) else max(a) end-count(distinct t1.a)+ -count(*)-count(*) from t1) then d when b not between t1.f and t1.e then a else 11 end+t1.a FROM t1 WHERE NOT ((exists(select 1 from t1 where case when exists(select 1 from t1 where case when (t1.e+case (t1.b) when f then case t1.c when 11 |  -13-coalesce((select max(d) from t1 where c not in ( -t1.e,t1.c,17) and t1.c<17),e)*17+t1.a then t1.b else 11 end else d end)+t1.f not in (d,13,d) then f else t1.d end not between (c) and f) then t1.e else f end-t1.c in (t1.b,t1.a,f))))}\n} {800}\ndo_test randexpr-2.1651 {\n  db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) | cast(avg(17) AS integer) from t1) then 17*e*t1.f | t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end | 13+13 then 17 else t1.f end FROM t1 WHERE (not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when  -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end |  -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1)))}\n} {600}\ndo_test randexpr-2.1652 {\n  db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) | cast(avg(17) AS integer) from t1) then 17*e*t1.f | t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end | 13+13 then 17 else t1.f end FROM t1 WHERE NOT ((not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when  -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end |  -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1))))}\n} {}\ndo_test randexpr-2.1653 {\n  db eval {SELECT case ~t1.d when case when c in (select count(*) from t1 union select +(( -min(17)-~cast(avg(t1.c) AS integer)))* -min(t1.f)-max(t1.d)*count(*) & cast(avg(17) AS integer) from t1) then 17*e*t1.f & t1.e else 19-coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where t1.c>=e)),t1.f) end & 13+13 then 17 else t1.f end FROM t1 WHERE (not exists(select 1 from t1 where +c-19 in (select (~((min(b)))-+count(*) | cast(avg(case when 11 in (select (abs((t1.b))/abs(e)) from t1 union select (17) from t1) then t1.c when  -a<=b then t1.a else t1.e end) AS integer)++case max(t1.b) when cast(avg(c) AS integer) then count(*) else cast(avg(f) AS integer) end |  -count(*)-(count(*))*max(t1.e)*count(*)*cast(avg(a) AS integer))+min(11) from t1 union select max((d)) from t1)))}\n} {600}\ndo_test randexpr-2.1654 {\n  db eval {SELECT 19 | case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a | t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and  -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE (t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17}\n} {}\ndo_test randexpr-2.1655 {\n  db eval {SELECT 19 | case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a | t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and  -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE NOT ((t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17)}\n} {19}\ndo_test randexpr-2.1656 {\n  db eval {SELECT 19 & case when not (select min(17) from t1)>t1.e then coalesce((select max(coalesce((select b from t1 where (t1.a not in (a & t1.c,t1.d,19) or not exists(select 1 from t1 where t1.b in (select t1.d from t1 union select a from t1)) and (a in (select count(*) from t1 union select max(t1.b) from t1) and t1.c in (t1.b,f,t1.d)))),t1.c)) from t1 where f=d and  -b>c),t1.f)-t1.c when c in ((a),11,t1.c) then 13 else 13 end-c FROM t1 WHERE NOT ((t1.e)*case when +a*t1.f*t1.e>=+d*a+b-t1.f*~13 | t1.d*11-f-~f+17-coalesce((select max( -f) from t1 where b<t1.a),t1.b) | a-(17)-13-f then e else c end<17)}\n} {0}\ndo_test randexpr-2.1657 {\n  db eval {SELECT case when not exists(select 1 from t1 where not not not d=17) then t1.b when (not coalesce((select coalesce((select max(d) from t1 where c+c>t1.c),11)*e*t1.e from t1 where e<=t1.d),t1.a)*f<t1.b) then coalesce((select case when 19>=11 then e when t1.a in (select e from t1 union select b from t1) then t1.b-t1.a else e end from t1 where a=t1.a), -17) else e end FROM t1 WHERE not exists(select 1 from t1 where t1.e in (select max((abs(~+t1.a-t1.c*a)/abs(17))) from t1 union select min(11*t1.c+t1.f) from t1))}\n} {500}\ndo_test randexpr-2.1658 {\n  db eval {SELECT case when not exists(select 1 from t1 where not not not d=17) then t1.b when (not coalesce((select coalesce((select max(d) from t1 where c+c>t1.c),11)*e*t1.e from t1 where e<=t1.d),t1.a)*f<t1.b) then coalesce((select case when 19>=11 then e when t1.a in (select e from t1 union select b from t1) then t1.b-t1.a else e end from t1 where a=t1.a), -17) else e end FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.e in (select max((abs(~+t1.a-t1.c*a)/abs(17))) from t1 union select min(11*t1.c+t1.f) from t1)))}\n} {}\ndo_test randexpr-2.1659 {\n  db eval {SELECT coalesce((select coalesce((select max(case when not a not in ((abs(11)/abs(coalesce((select t1.d from t1 where 17 in (select count(*) from t1 union select count(distinct t1.a) from t1)),b)*t1.e*c)),t1.a,t1.b) or t1.c<=t1.f or (t1.d>= -a) then (select cast(avg(~t1.f-t1.f) AS integer) from t1) else 17 end) from t1 where t1.b<=c and t1.b<=a),11) from t1 where exists(select 1 from t1 where e<c) and 11 not between t1.d and c),a) FROM t1 WHERE e>=(select min(coalesce((select max(19) from t1 where not exists(select 1 from t1 where (select count(distinct +case when coalesce((select max(case when e<a then b else (c) end) from t1 where f<>t1.d),t1.d) in (select abs(cast(avg(t1.d) AS integer)-min(t1.c)) from t1 union select  -cast(avg(19) AS integer) from t1) then b when t1.e< -t1.c then t1.b else t1.c end-19*e) from t1)<=a)),17))+ -(max(a))- -cast(avg(11) AS integer)+ -count(distinct c) from t1)-11}\n} {100}\ndo_test randexpr-2.1660 {\n  db eval {SELECT coalesce((select coalesce((select max(case when not a not in ((abs(11)/abs(coalesce((select t1.d from t1 where 17 in (select count(*) from t1 union select count(distinct t1.a) from t1)),b)*t1.e*c)),t1.a,t1.b) or t1.c<=t1.f or (t1.d>= -a) then (select cast(avg(~t1.f-t1.f) AS integer) from t1) else 17 end) from t1 where t1.b<=c and t1.b<=a),11) from t1 where exists(select 1 from t1 where e<c) and 11 not between t1.d and c),a) FROM t1 WHERE NOT (e>=(select min(coalesce((select max(19) from t1 where not exists(select 1 from t1 where (select count(distinct +case when coalesce((select max(case when e<a then b else (c) end) from t1 where f<>t1.d),t1.d) in (select abs(cast(avg(t1.d) AS integer)-min(t1.c)) from t1 union select  -cast(avg(19) AS integer) from t1) then b when t1.e< -t1.c then t1.b else t1.c end-19*e) from t1)<=a)),17))+ -(max(a))- -cast(avg(11) AS integer)+ -count(distinct c) from t1)-11)}\n} {}\ndo_test randexpr-2.1661 {\n  db eval {SELECT e*(case when +t1.c+t1.e+f<=13 then (select case cast(avg(coalesce((select (t1.f*a)*11 from t1 where c<>t1.a),b)) AS integer)+cast(avg(b) AS integer)+max( -b)-min(e) when max(11) then cast(avg(t1.e) AS integer) else cast(avg(t1.b) AS integer) end from t1) when ~11*t1.d<=t1.b or (t1.e=t1.a) then t1.b else  -19 end)+e FROM t1 WHERE a>13*d+t1.e+c}\n} {}\ndo_test randexpr-2.1662 {\n  db eval {SELECT e*(case when +t1.c+t1.e+f<=13 then (select case cast(avg(coalesce((select (t1.f*a)*11 from t1 where c<>t1.a),b)) AS integer)+cast(avg(b) AS integer)+max( -b)-min(e) when max(11) then cast(avg(t1.e) AS integer) else cast(avg(t1.b) AS integer) end from t1) when ~11*t1.d<=t1.b or (t1.e=t1.a) then t1.b else  -19 end)+e FROM t1 WHERE NOT (a>13*d+t1.e+c)}\n} {100500}\ndo_test randexpr-2.1663 {\n  db eval {SELECT (abs(t1.d-t1.b)/abs(t1.c))+t1.a*coalesce((select max(coalesce((select max(~11+11) from t1 where e-a>=case when 11*t1.d+13+(select cast(avg(t1.d+f) AS integer) from t1)-d+t1.d-b not between a and a then e else coalesce((select e from t1 where d>b and b between 11 and t1.d),t1.b) end), -t1.b)) from t1 where t1.e<=c),17)+ -t1.d FROM t1 WHERE case when (19>b) then case (abs(t1.d+case when not exists(select 1 from t1 where f in (19,d,11) and f not between t1.e and a) then (19) when a<=t1.d then 17 else t1.c end* -c*13)/abs(d))*f when 19 then t1.c else  - - -t1.d end when c in (select max(t1.e) from t1 union select ( - -abs(cast(avg(t1.f) AS integer))-case cast(avg(a) AS integer) when (min(t1.f)) then max(13) else max(11) end |  -((min(11)))+max((a))) from t1) then c else  -b end*t1.d>d}\n} {}\ndo_test randexpr-2.1664 {\n  db eval {SELECT (abs(t1.d-t1.b)/abs(t1.c))+t1.a*coalesce((select max(coalesce((select max(~11+11) from t1 where e-a>=case when 11*t1.d+13+(select cast(avg(t1.d+f) AS integer) from t1)-d+t1.d-b not between a and a then e else coalesce((select e from t1 where d>b and b between 11 and t1.d),t1.b) end), -t1.b)) from t1 where t1.e<=c),17)+ -t1.d FROM t1 WHERE NOT (case when (19>b) then case (abs(t1.d+case when not exists(select 1 from t1 where f in (19,d,11) and f not between t1.e and a) then (19) when a<=t1.d then 17 else t1.c end* -c*13)/abs(d))*f when 19 then t1.c else  - - -t1.d end when c in (select max(t1.e) from t1 union select ( - -abs(cast(avg(t1.f) AS integer))-case cast(avg(a) AS integer) when (min(t1.f)) then max(13) else max(11) end |  -((min(11)))+max((a))) from t1) then c else  -b end*t1.d>d)}\n} {1300}\ndo_test randexpr-2.1665 {\n  db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b | case 13 | case when  -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and  -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE (13-coalesce((select  -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b}\n} {}\ndo_test randexpr-2.1666 {\n  db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b | case 13 | case when  -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and  -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE NOT ((13-coalesce((select  -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b)}\n} {-59083}\ndo_test randexpr-2.1667 {\n  db eval {SELECT ~t1.a*(case when not not exists(select 1 from t1 where coalesce((select max(t1.c) from t1 where (select count(distinct b & case 13 & case when  -11<>a then t1.a else b end when t1.e then t1.b else d end*t1.f) from t1)<>17 or t1.a not between c and t1.a),11) in (t1.e,c,c)) and  -11>f then t1.d else f end-17)+ -(t1.b) FROM t1 WHERE NOT ((13-coalesce((select  -case when 19+c=a then f else 11 end*(e) from t1 where (t1.b in (select t1.a from t1 union select 11 from t1))),(t1.f))*e+f*(t1.f)=a and not 17 in (select max(f) from t1 union select max(19) from t1) or 19<>t1.f) and 13 between f and f and d<>b)}\n} {-59083}\ndo_test randexpr-2.1668 {\n  db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select  -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end | f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between  -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f)}\n} {}\ndo_test randexpr-2.1669 {\n  db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select  -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end | f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between  -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f))}\n} {386}\ndo_test randexpr-2.1670 {\n  db eval {SELECT ~13+case when (t1.e-~b+13*case when b>(select max(case when (19*f in (select ~count(distinct a)+count(distinct (e)) from t1 union select (cast(avg(t1.c) AS integer)) from t1)) then coalesce((select  -19 from t1 where t1.f<=c or 19 not in (t1.c, -b,19)),t1.e) when t1.e>c then e else 13 end & f) from t1) then 13 else d end in (select t1.f from t1 union select c from t1)) then t1.f when not exists(select 1 from t1 where a between f and f) then (d) else t1.c end FROM t1 WHERE NOT (exists(select 1 from t1 where case when 19 in (19,+(abs(case t1.f when e then case (select +cast(avg(a) AS integer)*min(e) from t1) when case when 19 not between  -t1.c and d then 11 else t1.f end then f else t1.c end else e end+17+b)/abs(t1.d))*13,t1.f) then a when t1.d not in (f,d, -c) then t1.c else t1.b end not between d and c and t1.b not between t1.b and f))}\n} {386}\ndo_test randexpr-2.1671 {\n  db eval {SELECT  -case coalesce((select max((case when a>t1.c | t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when  -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f)}\n} {}\ndo_test randexpr-2.1672 {\n  db eval {SELECT  -case coalesce((select max((case when a>t1.c | t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE NOT (e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when  -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f))}\n} {-19}\ndo_test randexpr-2.1673 {\n  db eval {SELECT  -case coalesce((select max((case when a>t1.c & t1.a then (select abs(count(distinct a)) from t1) when (e not in (coalesce((select c from t1 where exists(select 1 from t1 where c<=11) and t1.a>e),e),d,a)) or t1.d<>e then t1.c else c end)- -11*b) from t1 where not exists(select 1 from t1 where not (c in ((t1.e),d,19)))),(t1.c))*b when 17 then t1.b else 19 end FROM t1 WHERE NOT (e<=coalesce((select t1.b from t1 where coalesce((select c*19 | (a) from t1 where not exists(select 1 from t1 where 19>=13 or case when coalesce((select max(19) from t1 where t1.e=t1.d or t1.f<>e),t1.f)>19 and t1.f=t1.d then 11+ -t1.d when  -t1.f not between f and f then t1.a else d end not in ((t1.a),13,t1.a) and c in (select (13) from t1 union select f from t1) and 17<(f)) and t1.a<>t1.e),t1.d)>=t1.c),t1.f))}\n} {-19}\ndo_test randexpr-2.1674 {\n  db eval {SELECT coalesce((select (11) from t1 where not e in (select  -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d | t1.f) FROM t1 WHERE  -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then  -t1.e else (13) end}\n} {}\ndo_test randexpr-2.1675 {\n  db eval {SELECT coalesce((select (11) from t1 where not e in (select  -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d | t1.f) FROM t1 WHERE NOT ( -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then  -t1.e else (13) end)}\n} {11}\ndo_test randexpr-2.1676 {\n  db eval {SELECT coalesce((select (11) from t1 where not e in (select  -min(d*13) from t1 union select count(distinct f) from t1)),t1.f*t1.d & t1.f) FROM t1 WHERE NOT ( -t1.c*d>case d when ~coalesce((select max(e) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where not e=c))),+coalesce((select +t1.e from t1 where not exists(select 1 from t1 where c>=t1.b)),(abs( -t1.c+case t1.c when ~~t1.c+a-t1.c then coalesce((select max(case when t1.b<=c then 19 else f end) from t1 where 13<b),d) else t1.d end)/abs(a))*(d))) then  -t1.e else (13) end)}\n} {11}\ndo_test randexpr-2.1677 {\n  db eval {SELECT +case when t1.e>=(select max(17) from t1) then case 11 when e then coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.d in (select t1.a from t1 union select e from t1) and e=case when 11<19 and t1.e<19 then t1.e when t1.c in (t1.b,t1.e,t1.d) then 13 else 13 end and e<=d or b between 19 and t1.a or t1.a<=(13))),t1.a) else t1.e-t1.d end*t1.a when  -11 not in (17,t1.d,a) then t1.c else b end*19 FROM t1 WHERE not t1.b>t1.e or t1.d not in (~t1.f,d+case when (b+(abs(19*~t1.c | t1.b*d*(b)-t1.e-t1.e+a)/abs(t1.c)) not in (17,b,t1.e)) then 13+f else b end-t1.f,t1.e) or t1.e not in (f,a,t1.d)}\n} {190000}\ndo_test randexpr-2.1678 {\n  db eval {SELECT +case when t1.e>=(select max(17) from t1) then case 11 when e then coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.d in (select t1.a from t1 union select e from t1) and e=case when 11<19 and t1.e<19 then t1.e when t1.c in (t1.b,t1.e,t1.d) then 13 else 13 end and e<=d or b between 19 and t1.a or t1.a<=(13))),t1.a) else t1.e-t1.d end*t1.a when  -11 not in (17,t1.d,a) then t1.c else b end*19 FROM t1 WHERE NOT (not t1.b>t1.e or t1.d not in (~t1.f,d+case when (b+(abs(19*~t1.c | t1.b*d*(b)-t1.e-t1.e+a)/abs(t1.c)) not in (17,b,t1.e)) then 13+f else b end-t1.f,t1.e) or t1.e not in (f,a,t1.d))}\n} {}\ndo_test randexpr-2.1679 {\n  db eval {SELECT t1.e | t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select  -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE d between t1.f and t1.c}\n} {}\ndo_test randexpr-2.1680 {\n  db eval {SELECT t1.e | t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select  -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE NOT (d between t1.f and t1.c)}\n} {10740}\ndo_test randexpr-2.1681 {\n  db eval {SELECT t1.e & t1.b+a*coalesce((select t1.a from t1 where ~(d)-f<>e-c or 17+f in (select  -(~case max(t1.c) when abs(count(*)) then abs( - -cast(avg(b) AS integer)*count(*)) else cast(avg(t1.c) AS integer) end) from t1 union select count(distinct (11)) from t1) and exists(select 1 from t1 where not 13>t1.e) or t1.c<d),~b)- -b FROM t1 WHERE NOT (d between t1.f and t1.c)}\n} {160}\ndo_test randexpr-2.1682 {\n  db eval {SELECT ~(select +~count(distinct 17)*count(distinct t1.e) from t1)-t1.e+a*11-case when 13<>t1.b then 19 when case when case (select ( -max(c)) from t1) when 11 then d else e end*t1.d<>d then a else 11 end=t1.b or 17=d then b else t1.e end+11+t1.a*a-e FROM t1 WHERE coalesce((select coalesce((select max(c) from t1 where  -+ -e-t1.d*case when coalesce((select d from t1 where (c=a)),f) between t1.b and t1.b or (13)<>c and e in (t1.e,e,(t1.a)) then b*t1.c else b end+t1.c in (select t1.f from t1 union select t1.b from t1)),19) from t1 where t1.f in (select count(*) from t1 union select cast(avg(t1.e) AS integer)*min((a))*+(max(t1.b))+max(17) from t1)),t1.d)< -e}\n} {}\ndo_test randexpr-2.1683 {\n  db eval {SELECT ~(select +~count(distinct 17)*count(distinct t1.e) from t1)-t1.e+a*11-case when 13<>t1.b then 19 when case when case (select ( -max(c)) from t1) when 11 then d else e end*t1.d<>d then a else 11 end=t1.b or 17=d then b else t1.e end+11+t1.a*a-e FROM t1 WHERE NOT (coalesce((select coalesce((select max(c) from t1 where  -+ -e-t1.d*case when coalesce((select d from t1 where (c=a)),f) between t1.b and t1.b or (13)<>c and e in (t1.e,e,(t1.a)) then b*t1.c else b end+t1.c in (select t1.f from t1 union select t1.b from t1)),19) from t1 where t1.f in (select count(*) from t1 union select cast(avg(t1.e) AS integer)*min((a))*+(max(t1.b))+max(17) from t1)),t1.d)< -e)}\n} {10093}\ndo_test randexpr-2.1684 {\n  db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then  -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then  -17 else t1.d end then a when 19<11 then t1.a else t1.b end | t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d}\n} {19}\ndo_test randexpr-2.1685 {\n  db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then  -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then  -17 else t1.d end then a when 19<11 then t1.a else t1.b end | t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE NOT (case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d)}\n} {}\ndo_test randexpr-2.1686 {\n  db eval {SELECT coalesce((select max(case when f<=(17-coalesce((select ~t1.e+11 from t1 where t1.f in (select c from t1 union select b from t1)),f)) then  -case when e>case when 17+ -t1.b in (select cast(avg(f) AS integer) from t1 union select min(c-17+a) from t1) then  -17 else t1.d end then a when 19<11 then t1.a else t1.b end & t1.f else a end) from t1 where e between a and d),19) FROM t1 WHERE case 19 when ((select max(f) from t1)) then 13 else t1.d end-t1.c>a-b-t1.d}\n} {19}\ndo_test randexpr-2.1687 {\n  db eval {SELECT case when (select case min(t1.b) when max(13) | +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE exists(select 1 from t1 where f<13)}\n} {}\ndo_test randexpr-2.1688 {\n  db eval {SELECT case when (select case min(t1.b) when max(13) | +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<13))}\n} {0}\ndo_test randexpr-2.1689 {\n  db eval {SELECT case when (select case min(t1.b) when max(13) & +max(t1.e)*max(f) then abs( -+count(*)) else max(t1.f) end from t1)*t1.a+(abs(case 19 when 19 then d else ((13)) end)/abs(13))+(19) between f and 13 or (not not 17<e) then (abs(17)/abs((f))) when f in (select min(f) from t1 union select cast(avg(11) AS integer) from t1) then c else b end FROM t1 WHERE NOT (exists(select 1 from t1 where f<13))}\n} {0}\ndo_test randexpr-2.1690 {\n  db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) | 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then  -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d))}\n} {-50000}\ndo_test randexpr-2.1691 {\n  db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) | 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE NOT (not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then  -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d)))}\n} {}\ndo_test randexpr-2.1692 {\n  db eval {SELECT coalesce((select +(select max(coalesce((select (abs(((t1.e)+b))/abs(f))+e from t1 where (select (case min(t1.b) when count(*) then count(*) else abs(++count(distinct t1.a)+cast(avg(d) AS integer)) end)+min(f)-max(11) from t1)<>~17),t1.e+(select count(*) from t1) & 11-coalesce((select 13 from t1 where 11 not in ( -t1.f,t1.e,t1.f)),t1.b))+ -(t1.c)) from t1) from t1 where t1.a=(13)), -a)*e FROM t1 WHERE not exists(select 1 from t1 where (select count(distinct t1.e) from t1)<=coalesce((select case when not exists(select 1 from t1 where e=t1.b*coalesce((select max(+b) from t1 where exists(select 1 from t1 where not (not not exists(select 1 from t1 where t1.c in (select 11 from t1 union select 19+13 from t1)))) and not t1.b<a),case when b in (t1.c,t1.e,f) and b=t1.a then ~b when 13 not between d and 11 then  -t1.d-c else t1.d end)) then (abs((11))/abs(17)) else b end from t1 where t1.b not in (t1.f,t1.e,17)), -t1.d))}\n} {-50000}\ndo_test randexpr-2.1693 {\n  db eval {SELECT ~~t1.b | 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE (17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select  -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when  -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1))}\n} {}\ndo_test randexpr-2.1694 {\n  db eval {SELECT ~~t1.b | 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE NOT ((17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select  -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when  -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1)))}\n} {246747}\ndo_test randexpr-2.1695 {\n  db eval {SELECT ~~t1.b & 11+d*coalesce((select max(t1.f-a) from t1 where not exists(select 1 from t1 where (a-coalesce((select b from t1 where t1.f<case when not exists(select 1 from t1 where 11=b or d<>e) then t1.e*c else c end-13+t1.a),f)+t1.d- -t1.a)*t1.c<>f) and t1.b not between (e) and t1.c),f)+11*t1.f FROM t1 WHERE NOT ((17 in (select 13 from t1 union select case coalesce((select max( -case when not b in ((select  -+case max((b)) when cast(avg(13) AS integer) then count(*) else max(a) end+min(b)-max(d) from t1),coalesce((select t1.d from t1 where case when  -13 in ( -t1.e,f,t1.e) then t1.c else e end | 11<=(t1.b)),t1.c)-11,t1.e) then t1.f else 13 end) from t1 where b>=t1.e),f) when e then t1.c else c end from t1)))}\n} {64}\ndo_test randexpr-2.1696 {\n  db eval {SELECT case case when not ++b+~e-11-d-f*e*case when (t1.f) not between t1.c and t1.e or (13>e) then (abs(17)/abs(d)) when 11 not between 17 and (t1.b) then c else 13 end-(f)-f between t1.c and t1.f then t1.c when a between t1.d and 13 then t1.e else t1.a end when a then f else 13 end FROM t1 WHERE t1.a in (select case when (+e*t1.f not in ( -(select (case max(+t1.e-case when not exists(select 1 from t1 where 19 in (select 13 from t1 union select ((t1.d)) from t1)) then 13-t1.b else 19 end) when count(*)-(cast(avg(t1.b) AS integer)-cast(avg(b) AS integer)) then count(distinct t1.b) else count(distinct t1.c) end | cast(avg((19)) AS integer)) from t1),~17-f,c)) then (select count(*) from t1) when t1.a>t1.a then b else t1.d end+(f) from t1 union select b from t1)}\n} {}\ndo_test randexpr-2.1697 {\n  db eval {SELECT case case when not ++b+~e-11-d-f*e*case when (t1.f) not between t1.c and t1.e or (13>e) then (abs(17)/abs(d)) when 11 not between 17 and (t1.b) then c else 13 end-(f)-f between t1.c and t1.f then t1.c when a between t1.d and 13 then t1.e else t1.a end when a then f else 13 end FROM t1 WHERE NOT (t1.a in (select case when (+e*t1.f not in ( -(select (case max(+t1.e-case when not exists(select 1 from t1 where 19 in (select 13 from t1 union select ((t1.d)) from t1)) then 13-t1.b else 19 end) when count(*)-(cast(avg(t1.b) AS integer)-cast(avg(b) AS integer)) then count(distinct t1.b) else count(distinct t1.c) end | cast(avg((19)) AS integer)) from t1),~17-f,c)) then (select count(*) from t1) when t1.a>t1.a then b else t1.d end+(f) from t1 union select b from t1))}\n} {13}\ndo_test randexpr-2.1698 {\n  db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e | 19-(select  -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE (t1.f<>t1.c)}\n} {596}\ndo_test randexpr-2.1699 {\n  db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e | 19-(select  -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE NOT ((t1.f<>t1.c))}\n} {}\ndo_test randexpr-2.1700 {\n  db eval {SELECT 13-case when a<=case when e not between t1.b*(abs(t1.c)/abs(e & 19-(select  -~count(distinct t1.b)+min(t1.a-t1.c-f+t1.d+t1.d+t1.d) from t1)))-t1.e and coalesce((select 11 from t1 where c<e),d)* -d then 17 else t1.e end then t1.c else 17 end+f FROM t1 WHERE (t1.f<>t1.c)}\n} {596}\ndo_test randexpr-2.1701 {\n  db eval {SELECT (case when coalesce((select max(~case coalesce((select max(b) from t1 where case (select count(distinct 17) from t1)-e when b then d else t1.b end<13),f) when c then (( -c)) else 13 end) from t1 where t1.e between a and b),t1.b) in (select  -min(t1.f) from t1 union select case cast(avg(t1.d) AS integer) when count(distinct b) then case +~ -cast(avg(b) AS integer) when max(t1.f) then count(*) else (max(e)) end else count(*) end from t1) then c when 13<=t1.f then ( -17) else t1.b end) FROM t1 WHERE (select min(19*coalesce((select max(t1.e) from t1 where ~coalesce((select t1.a-coalesce((select max((abs(a)/abs(d))) from t1 where  -13 not in ((d)*t1.a+t1.e,13,t1.c) or 17 not in (a,b,t1.d)), -t1.a) from t1 where c<>t1.e),a) | 11+17 between b and 17),c))*~ -max(e) from t1)<>11}\n} {-17}\ndo_test randexpr-2.1702 {\n  db eval {SELECT (case when coalesce((select max(~case coalesce((select max(b) from t1 where case (select count(distinct 17) from t1)-e when b then d else t1.b end<13),f) when c then (( -c)) else 13 end) from t1 where t1.e between a and b),t1.b) in (select  -min(t1.f) from t1 union select case cast(avg(t1.d) AS integer) when count(distinct b) then case +~ -cast(avg(b) AS integer) when max(t1.f) then count(*) else (max(e)) end else count(*) end from t1) then c when 13<=t1.f then ( -17) else t1.b end) FROM t1 WHERE NOT ((select min(19*coalesce((select max(t1.e) from t1 where ~coalesce((select t1.a-coalesce((select max((abs(a)/abs(d))) from t1 where  -13 not in ((d)*t1.a+t1.e,13,t1.c) or 17 not in (a,b,t1.d)), -t1.a) from t1 where c<>t1.e),a) | 11+17 between b and 17),c))*~ -max(e) from t1)<>11)}\n} {}\ndo_test randexpr-2.1703 {\n  db eval {SELECT t1.f* -t1.e-c | b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then  -count(distinct e) else (((count(distinct t1.d)))) end | max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not  -c+b-t1.f<>d),a) else b end FROM t1 WHERE d in (select 11 from t1 union select  -d*~t1.b from t1)}\n} {}\ndo_test randexpr-2.1704 {\n  db eval {SELECT t1.f* -t1.e-c | b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then  -count(distinct e) else (((count(distinct t1.d)))) end | max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not  -c+b-t1.f<>d),a) else b end FROM t1 WHERE NOT (d in (select 11 from t1 union select  -d*~t1.b from t1))}\n} {-295178}\ndo_test randexpr-2.1705 {\n  db eval {SELECT t1.f* -t1.e-c & b++19*(select (case max(t1.c) when +abs(count(distinct case when e<t1.a then 19 else d end)) then  -count(distinct e) else (((count(distinct t1.d)))) end & max(e)+(cast(avg(t1.c) AS integer)))+count(*) from t1)+case when t1.d>=13 then coalesce((select max(t1.c) from t1 where not  -c+b-t1.f<>d),a) else b end FROM t1 WHERE NOT (d in (select 11 from t1 union select  -d*~t1.b from t1))}\n} {52}\ndo_test randexpr-2.1706 {\n  db eval {SELECT 11-t1.e+d+case case when (b between  -+case when f not between case coalesce((select t1.a from t1 where e not between (t1.d) and t1.a or 17<11),t1.d) when 17 then t1.f else t1.e end and d then 17 when e>=t1.f then t1.b else t1.b end and t1.e) then case f when t1.d then t1.c else  -e end when (not exists(select 1 from t1 where  -(11)>a) or t1.c<b) then 17 else 11 end when (t1.e) then d else t1.e end FROM t1 WHERE not (f)>t1.e}\n} {}\ndo_test randexpr-2.1707 {\n  db eval {SELECT 11-t1.e+d+case case when (b between  -+case when f not between case coalesce((select t1.a from t1 where e not between (t1.d) and t1.a or 17<11),t1.d) when 17 then t1.f else t1.e end and d then 17 when e>=t1.f then t1.b else t1.b end and t1.e) then case f when t1.d then t1.c else  -e end when (not exists(select 1 from t1 where  -(11)>a) or t1.c<b) then 17 else 11 end when (t1.e) then d else t1.e end FROM t1 WHERE NOT (not (f)>t1.e)}\n} {411}\ndo_test randexpr-2.1708 {\n  db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select  -count(distinct t1.c)-max(c) | count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where  -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select  -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else  -11 end-d when t1.e then 11 else f end+f=19}\n} {}\ndo_test randexpr-2.1709 {\n  db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select  -count(distinct t1.c)-max(c) | count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where  -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE NOT (case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select  -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else  -11 end-d when t1.e then 11 else f end+f=19)}\n} {17}\ndo_test randexpr-2.1710 {\n  db eval {SELECT coalesce((select max(case when f>11 then 13 when 19*e+(select  -count(distinct t1.c)-max(c) & count(distinct 13) from t1) between coalesce((select max(case when t1.a<t1.c and (t1.a)<=d then c when 17 between t1.b and b then (t1.c) else a end) from t1 where  -19 in (select min(11) from t1 union select count(*) from t1)),11) and 11 or (exists(select 1 from t1 where not exists(select 1 from t1 where c not between ( -b) and e))) and b not between 17 and t1.a and 19<b then 17 else f end) from t1 where t1.b between t1.c and 13 and t1.b<>e),17) FROM t1 WHERE NOT (case case 13+coalesce((select max( -t1.b*t1.c) from t1 where t1.c*c<>(select  -(count(distinct e)) from t1)-t1.c | t1.d*t1.e+11*t1.a+11-t1.a*b),d)+t1.d+e when t1.f then e else  -11 end-d when t1.e then 11 else f end+f=19)}\n} {17}\ndo_test randexpr-2.1711 {\n  db eval {SELECT 13+coalesce((select  -(abs(b)/abs(coalesce((select (abs(e+t1.a)/abs(13)) from t1 where a<c), -19)+t1.a+t1.c)) from t1 where (not t1.a not between e and e)),t1.d) FROM t1 WHERE ~(abs(t1.f)/abs(f)) not in (f,case c when coalesce((select max(17) from t1 where case when 17 not between 13 and 11+case when exists(select 1 from t1 where t1.e<c) then case when d between f and t1.c then 19 when 11 in (t1.a,11,e) then a else t1.e end else 13 end | 11+17 then t1.e else e end<>17 and t1.d<>t1.f),17)+a- -t1.d then t1.d else  -t1.b end,b)}\n} {413}\ndo_test randexpr-2.1712 {\n  db eval {SELECT 13+coalesce((select  -(abs(b)/abs(coalesce((select (abs(e+t1.a)/abs(13)) from t1 where a<c), -19)+t1.a+t1.c)) from t1 where (not t1.a not between e and e)),t1.d) FROM t1 WHERE NOT (~(abs(t1.f)/abs(f)) not in (f,case c when coalesce((select max(17) from t1 where case when 17 not between 13 and 11+case when exists(select 1 from t1 where t1.e<c) then case when d between f and t1.c then 19 when 11 in (t1.a,11,e) then a else t1.e end else 13 end | 11+17 then t1.e else e end<>17 and t1.d<>t1.f),17)+a- -t1.d then t1.d else  -t1.b end,b))}\n} {}\ndo_test randexpr-2.1713 {\n  db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) | min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE (abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not  -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a}\n} {}\ndo_test randexpr-2.1714 {\n  db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) | min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE NOT ((abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not  -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a)}\n} {-120000}\ndo_test randexpr-2.1715 {\n  db eval {SELECT (~(abs(case when t1.f*17 not in (coalesce((select 13 from t1 where d in (select count(distinct t1.e- -t1.e+t1.e*11) from t1 union select (abs(~~(cast(avg(d) AS integer))* -(min(13))+max(d) & min(13))) from t1)),d),a,t1.e) then c else t1.c end-c)/abs((t1.d)))*t1.c)*t1.d+t1.b-b FROM t1 WHERE NOT ((abs(case when (t1.e+case when t1.f+t1.d*t1.c<=t1.f or t1.c>=a and a not between 19 and t1.e then e else b end-t1.c) | t1.b<>19 then t1.f when 19<=t1.d and not  -t1.c>=11 and t1.a between t1.f and (19) then b else t1.c end)/abs(b))+11>=t1.f and t1.f not between f and t1.a)}\n} {-120000}\ndo_test randexpr-2.1716 {\n  db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select  - -min(c) | min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then  -t1.f else t1.a end else t1.b end)) FROM t1 WHERE t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b}\n} {}\ndo_test randexpr-2.1717 {\n  db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select  - -min(c) | min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then  -t1.f else t1.a end else t1.b end)) FROM t1 WHERE NOT (t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b)}\n} {0}\ndo_test randexpr-2.1718 {\n  db eval {SELECT (abs(a)/abs(case when (not t1.f in (select count(*) from t1 union select  - -min(c) & min(13*t1.d) from t1)) and ( -t1.a*t1.d)>=d or (t1.a in (a,11,f)) or (c>=t1.a) then 17+case when not exists(select 1 from t1 where e<t1.f) then + -(e)-d when t1.e in (19,19, -e) then  -t1.f else t1.a end else t1.b end)) FROM t1 WHERE NOT (t1.d in (select min(t1.d) from t1 union select +~case abs(max(case when t1.e not between 19-f | f | t1.c and b then t1.b else e end+b) | count(distinct f)) when count(distinct e) then count(*) else (+count(*)-(count(*))+min(t1.d)) end from t1) and (f)*coalesce((select 17 from t1 where f between t1.e and a),(13))<=b)}\n} {0}\ndo_test randexpr-2.1719 {\n  db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and  -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) | c | coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE  -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then  -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when  -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end)}\n} {}\ndo_test randexpr-2.1720 {\n  db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and  -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) | c | coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE NOT ( -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then  -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when  -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end))}\n} {17}\ndo_test randexpr-2.1721 {\n  db eval {SELECT +case when case when coalesce((select c from t1 where (exists(select 1 from t1 where not (abs(b)/abs(t1.b)) not between f and 19 and  -b>c)) and 13 between t1.c and 17 or a=13),coalesce((select a from t1 where (t1.d) in (c,11,t1.c)),t1.d)) & c & coalesce((select max(d) from t1 where t1.b>b),t1.a)=19 then e else 13 end between t1.a and t1.f and 17>=c then a when d in (e,13,c) or t1.b<> -19 then (17) else 17 end FROM t1 WHERE NOT ( -b in (t1.b,t1.f,case when a in (select case +(min(t1.c)*+~cast(avg(+t1.f) AS integer)*cast(avg(d) AS integer) | abs(count(*))+count(*)*count(distinct 17)) when count(distinct e) then  -cast(avg(t1.a) AS integer) else min(11) end from t1 union select ((min(13))) from t1) then (abs(t1.d)/abs(case when  -19<b then t1.e- -f+f else b end)) when t1.a between t1.f and 13 then f else t1.e end))}\n} {17}\ndo_test randexpr-2.1722 {\n  db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) | ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where t1.a<>e)}\n} {}\ndo_test randexpr-2.1723 {\n  db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) | ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a<>e))}\n} {200}\ndo_test randexpr-2.1724 {\n  db eval {SELECT coalesce((select t1.b from t1 where not exists(select 1 from t1 where 13 in (select count(*) & ~min((select max((abs(d)/abs(t1.e+t1.e))) from t1)* -case when f*case e*~a when case e when (d) then 19 else (b) end then d else 17 end*t1.b between 11 and 13 then e when d in (a,(19),e) then c else 13 end-e*17) from t1 union select (count(*)) from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.a<>e))}\n} {200}\ndo_test randexpr-2.1725 {\n  db eval {SELECT  - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and  -t1.d),d)+19) from t1 where (f in (select ( -count(*) | count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or  -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and  -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and  -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end}\n} {}\ndo_test randexpr-2.1726 {\n  db eval {SELECT  - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and  -t1.d),d)+19) from t1 where (f in (select ( -count(*) | count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or  -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE NOT (d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and  -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and  -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end)}\n} {8}\ndo_test randexpr-2.1727 {\n  db eval {SELECT  - -case b when +~coalesce((select max(coalesce((select c from t1 where coalesce((select max(t1.a+f) from t1 where (t1.a not between t1.a and t1.e)),t1.a)-b not between e and  -t1.d),d)+19) from t1 where (f in (select ( -count(*) & count(*)+cast(avg(11) AS integer)) from t1 union select count(distinct 13) from t1) or  -b<>19 or 17>=t1.a)),t1.e)-c-t1.d then t1.a else 19 end- - -11 FROM t1 WHERE NOT (d+a*~coalesce((select max((select count(distinct t1.e)-max(t1.d) from t1)) from t1 where not exists(select 1 from t1 where t1.e in (11-f*19,a,c-b)) and 11=t1.b),t1.a)=(t1.b) and  -t1.b<case when (+11 | coalesce((select t1.f from t1 where b<=(t1.b) and  -t1.e<=(t1.f)),13) | t1.e between 13 and 19) then 17 else 11 end)}\n} {8}\ndo_test randexpr-2.1728 {\n  db eval {SELECT  -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e | t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE (select abs( -abs(abs(case count(*) when ~ -min(f)+case  - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1)}\n} {}\ndo_test randexpr-2.1729 {\n  db eval {SELECT  -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e | t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE NOT ((select abs( -abs(abs(case count(*) when ~ -min(f)+case  - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1))}\n} {0}\ndo_test randexpr-2.1730 {\n  db eval {SELECT  -(abs(t1.a)/abs(case when coalesce((select max( -c) from t1 where t1.a*e>coalesce((select max(coalesce((select max(t1.d) from t1 where not exists(select 1 from t1 where e & t1.f-19 between t1.e-a and b and e>=t1.d)),+d)) from t1 where (exists(select 1 from t1 where t1.b in (select 19 from t1 union select 17 from t1) or 11 between t1.b and d))),c)),t1.e)*t1.a<=c then b else t1.d end)) FROM t1 WHERE NOT ((select abs( -abs(abs(case count(*) when ~ -min(f)+case  - -abs(+cast(avg(c*17) AS integer)) when count(*) then max(t1.a) else max(11) end+(cast(avg(e) AS integer)) then min(17) else count(*) end-cast(avg(a) AS integer)-count(*))))+ -cast(avg(t1.a) AS integer) | ((count(*))) from t1)+f in (select max((abs(+11*t1.a)/abs(t1.f))) from t1 union select max(d)-(( -count(distinct 11))) from t1))}\n} {0}\ndo_test randexpr-2.1731 {\n  db eval {SELECT case when ((select (+~~max(13)*count(distinct t1.c)) from t1)<>(select (+ -count(*)) from t1)) then +(17) else 19 end+~(abs(13)/abs(d))-t1.d FROM t1 WHERE coalesce((select (select  -+ -count(distinct a)*count(*)+max(t1.b) from t1) from t1 where exists(select 1 from t1 where t1.b=c)),t1.c)+f<>t1.f}\n} {-384}\ndo_test randexpr-2.1732 {\n  db eval {SELECT case when ((select (+~~max(13)*count(distinct t1.c)) from t1)<>(select (+ -count(*)) from t1)) then +(17) else 19 end+~(abs(13)/abs(d))-t1.d FROM t1 WHERE NOT (coalesce((select (select  -+ -count(distinct a)*count(*)+max(t1.b) from t1) from t1 where exists(select 1 from t1 where t1.b=c)),t1.c)+f<>t1.f)}\n} {}\ndo_test randexpr-2.1733 {\n  db eval {SELECT case t1.f when case when 17<=c and coalesce((select case when e in (case when (t1.a=c) then b else  -13 end,t1.d,t1.a) then 13 else t1.b end from t1 where (b)=13),t1.d) in ((t1.e),b,t1.b) and d not between 19 and 11 then +(select ~ -~max(e)+count(*)+cast(avg((t1.c)) AS integer) from t1) when t1.f<>e and t1.e<d then t1.c else 19 end then t1.a else t1.f end FROM t1 WHERE t1.b between t1.b and case when ((select abs(cast(avg( -17+f) AS integer)) from t1) between  -a and c) then case when coalesce((select max(d) from t1 where 11 in (select max(c) | (count(distinct 13)) from t1 union select count(*) from t1)),13) | t1.a between 13 and t1.f then f else (c) end-c when f in (19,(f), -13) then f else (t1.f) end-d or (f) not in (b,c,d)}\n} {600}\ndo_test randexpr-2.1734 {\n  db eval {SELECT case t1.f when case when 17<=c and coalesce((select case when e in (case when (t1.a=c) then b else  -13 end,t1.d,t1.a) then 13 else t1.b end from t1 where (b)=13),t1.d) in ((t1.e),b,t1.b) and d not between 19 and 11 then +(select ~ -~max(e)+count(*)+cast(avg((t1.c)) AS integer) from t1) when t1.f<>e and t1.e<d then t1.c else 19 end then t1.a else t1.f end FROM t1 WHERE NOT (t1.b between t1.b and case when ((select abs(cast(avg( -17+f) AS integer)) from t1) between  -a and c) then case when coalesce((select max(d) from t1 where 11 in (select max(c) | (count(distinct 13)) from t1 union select count(*) from t1)),13) | t1.a between 13 and t1.f then f else (c) end-c when f in (19,(f), -13) then f else (t1.f) end-d or (f) not in (b,c,d))}\n} {}\ndo_test randexpr-2.1735 {\n  db eval {SELECT t1.c+b+t1.c*case when f in (select max(case when not t1.e<case when (select ~+(min(13)) from t1)+t1.e in (select  -+count(*) from t1 union select ((cast(avg(e) AS integer))) from t1) then c when t1.f not between f and t1.f or (c) in (t1.e,c,d) then c else 11 end then +f else b end)-count(*) from t1 union select +min(11)-count(distinct t1.e) from t1) then d else 17 end-19 FROM t1 WHERE (select abs(case (count(distinct case when not exists(select 1 from t1 where  -t1.c=t1.c) and t1.d not in (13,t1.c,t1.c) then case (19)-c when t1.b then 11 else t1.f end else t1.d end+t1.c)+max(11)) when (count(distinct t1.f)*count(distinct 19)) then  -max(f) else count(*) end) from t1)*coalesce((select max(e) from t1 where (abs(case  -d when t1.b then 19 else t1.e end)/abs(c))< -e), -b)-e<=f}\n} {5581}\ndo_test randexpr-2.1736 {\n  db eval {SELECT t1.c+b+t1.c*case when f in (select max(case when not t1.e<case when (select ~+(min(13)) from t1)+t1.e in (select  -+count(*) from t1 union select ((cast(avg(e) AS integer))) from t1) then c when t1.f not between f and t1.f or (c) in (t1.e,c,d) then c else 11 end then +f else b end)-count(*) from t1 union select +min(11)-count(distinct t1.e) from t1) then d else 17 end-19 FROM t1 WHERE NOT ((select abs(case (count(distinct case when not exists(select 1 from t1 where  -t1.c=t1.c) and t1.d not in (13,t1.c,t1.c) then case (19)-c when t1.b then 11 else t1.f end else t1.d end+t1.c)+max(11)) when (count(distinct t1.f)*count(distinct 19)) then  -max(f) else count(*) end) from t1)*coalesce((select max(e) from t1 where (abs(case  -d when t1.b then 19 else t1.e end)/abs(c))< -e), -b)-e<=f)}\n} {}\ndo_test randexpr-2.1737 {\n  db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) | ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) | count(distinct f) | min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE (~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where  -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select  -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c)}\n} {60000}\ndo_test randexpr-2.1738 {\n  db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) | ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) | count(distinct f) | min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE NOT ((~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where  -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select  -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c))}\n} {}\ndo_test randexpr-2.1739 {\n  db eval {SELECT +case + -(+t1.a)-~13+t1.b*t1.b+ -c+(select abs(case ~max(t1.c)++min( -13)+ -count(*)+(count(*)) & ((cast(avg(t1.e) AS integer))) when min(t1.c) then min(t1.d) else min(b) end)+min(13) & count(distinct f) & min(t1.a) from t1) when t1.e then 11-17 else t1.b*c end FROM t1 WHERE (~coalesce((select max(coalesce((select max(19) from t1 where case when case f-(coalesce((select ~11 from t1 where  -19= -t1.f or b=t1.b),13)) when 19 then t1.d else t1.b end<=17 then 17 when t1.b>t1.e then t1.d else (d) end in (select count(*) from t1 union select  -abs(~abs(count(distinct d)) | min(t1.e))*count(*) from t1)),t1.f)) from t1 where a>13),d) not between t1.d and c)}\n} {60000}\ndo_test randexpr-2.1740 {\n  db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a | 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select  - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11}\n} {0}\ndo_test randexpr-2.1741 {\n  db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a | 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select  - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE NOT (coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11)}\n} {}\ndo_test randexpr-2.1742 {\n  db eval {SELECT (abs(e)/abs((+b)*coalesce((select c+c+t1.a+t1.e+t1.a+t1.a & 17+e*(t1.c) from t1 where a in (select count(distinct t1.c)-+count(*) from t1 union select  - -( -max(t1.f))-count(distinct t1.b)+min(t1.b)*count(*)+count(distinct a) from t1)),t1.a)+e))*19 FROM t1 WHERE coalesce((select 11 from t1 where case t1.e-(t1.a) when (f) then ((19)) else t1.f end+ -t1.b+a+coalesce((select coalesce((select d from t1 where exists(select 1 from t1 where 13+(t1.a)<>19 or 17 not in (c,e,t1.c) or f not in (t1.e,t1.a, -f))),~ -13+e) from t1 where b between (11) and t1.f),t1.a)<=t1.d), -c)<=11}\n} {0}\ndo_test randexpr-2.1743 {\n  db eval {SELECT case coalesce((select t1.f from t1 where not exists(select 1 from t1 where coalesce((select max(d) from t1 where 13 not in (11,coalesce((select max((+f)) from t1 where not d>=f or e in (select 11-t1.b from t1 union select t1.d from t1) or not exists(select 1 from t1 where  -b in (select t1.d from t1 union select b from t1) or t1.a<>b or t1.d>e) or t1.a not between (t1.f) and t1.e),+f),t1.e)),t1.f)*t1.b not in (13,t1.b,t1.f))),t1.a)*b when c then b else t1.f end FROM t1 WHERE case when c*coalesce((select max(19+t1.e*~case case t1.e when t1.f then  -t1.a else 11 end when 11 then t1.a else (select cast(avg(a) AS integer) from t1) end- -t1.b*coalesce((select 19 from t1 where t1.f in ((a),t1.d,t1.c)),a)) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where t1.a not in (t1.b,t1.a,17)))),13)>=a then b when t1.c>t1.a then d else 17 end not in (a,17,t1.b)}\n} {600}\ndo_test randexpr-2.1744 {\n  db eval {SELECT case coalesce((select t1.f from t1 where not exists(select 1 from t1 where coalesce((select max(d) from t1 where 13 not in (11,coalesce((select max((+f)) from t1 where not d>=f or e in (select 11-t1.b from t1 union select t1.d from t1) or not exists(select 1 from t1 where  -b in (select t1.d from t1 union select b from t1) or t1.a<>b or t1.d>e) or t1.a not between (t1.f) and t1.e),+f),t1.e)),t1.f)*t1.b not in (13,t1.b,t1.f))),t1.a)*b when c then b else t1.f end FROM t1 WHERE NOT (case when c*coalesce((select max(19+t1.e*~case case t1.e when t1.f then  -t1.a else 11 end when 11 then t1.a else (select cast(avg(a) AS integer) from t1) end- -t1.b*coalesce((select 19 from t1 where t1.f in ((a),t1.d,t1.c)),a)) from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where t1.a not in (t1.b,t1.a,17)))),13)>=a then b when t1.c>t1.a then d else 17 end not in (a,17,t1.b))}\n} {}\ndo_test randexpr-2.1745 {\n  db eval {SELECT (abs(case when (c*+~t1.d++t1.b+a-case when (select +case count(*)+min(d) when  -count(distinct 17) then max(t1.b) else  -cast(avg(d) AS integer) end from t1) in (select cast(avg(c) AS integer) from t1 union select ((count(*))) from t1) then t1.a* -f else f end*c*19-(f)-t1.c-t1.f+t1.d>=f) then (t1.d) else d end)/abs(t1.b)) FROM t1 WHERE coalesce((select a from t1 where t1.d not in ( -13*d,19,t1.a)),(abs(coalesce((select case when c>=t1.e then b else case ~t1.d+a-+t1.b+17 when case when t1.e+t1.e not between e and (c) then t1.d when d>a then t1.d else t1.c end | t1.a-(d) then t1.f else c end end from t1 where d>=t1.c),13))/abs(t1.c)))=t1.e}\n} {}\ndo_test randexpr-2.1746 {\n  db eval {SELECT (abs(case when (c*+~t1.d++t1.b+a-case when (select +case count(*)+min(d) when  -count(distinct 17) then max(t1.b) else  -cast(avg(d) AS integer) end from t1) in (select cast(avg(c) AS integer) from t1 union select ((count(*))) from t1) then t1.a* -f else f end*c*19-(f)-t1.c-t1.f+t1.d>=f) then (t1.d) else d end)/abs(t1.b)) FROM t1 WHERE NOT (coalesce((select a from t1 where t1.d not in ( -13*d,19,t1.a)),(abs(coalesce((select case when c>=t1.e then b else case ~t1.d+a-+t1.b+17 when case when t1.e+t1.e not between e and (c) then t1.d when d>a then t1.d else t1.c end | t1.a-(d) then t1.f else c end end from t1 where d>=t1.c),13))/abs(t1.c)))=t1.e)}\n} {2}\ndo_test randexpr-2.1747 {\n  db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 | t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c | b+17*t1.e-c)), -c) in (select  -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between  -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a}\n} {}\ndo_test randexpr-2.1748 {\n  db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 | t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c | b+17*t1.e-c)), -c) in (select  -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE NOT (case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between  -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a)}\n} {1117}\ndo_test randexpr-2.1749 {\n  db eval {SELECT d+coalesce((select max(coalesce((select f from t1 where coalesce((select 17 & t1.b from t1 where 11 not in ((t1.e),+a-f,t1.c & b+17*t1.e-c)), -c) in (select  -count(distinct e)-+max(t1.b) from t1 union select count(distinct c)+cast(avg(t1.b) AS integer) from t1)),17)) from t1 where not t1.c<t1.e),17)+b+e FROM t1 WHERE NOT (case t1.f when t1.a then t1.e else d-case when e<>(select ~~+(min(11-11)) | ~ -(count(*)) from t1)*(case when t1.d=19 then a when not t1.a in (11,t1.e,c) or t1.a not between t1.f and e then t1.a else t1.e end+19) then 13 when 19 between  -17 and t1.a then t1.a else 19 end end>=t1.f and t1.e>t1.a)}\n} {1117}\ndo_test randexpr-2.1750 {\n  db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) | max((13))-min(t1.c) |  -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then  -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE (f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when  -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17)}\n} {300}\ndo_test randexpr-2.1751 {\n  db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) | max((13))-min(t1.c) |  -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then  -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE NOT ((f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when  -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17))}\n} {}\ndo_test randexpr-2.1752 {\n  db eval {SELECT (select case ~ -(~case case cast(avg(t1.e) AS integer) when min(case when t1.c between coalesce((select t1.b from t1 where d in (select f from t1 union select t1.e from t1)),(e)) and t1.d and (19=(11)) then 17 else b end) & max((13))-min(t1.c) &  -count(distinct t1.d)*max(11) then count(*) else max(f) end*count(*)-(( -count(distinct f))) when min(t1.c) then (count(distinct (13))) else max((b)) end)+max(t1.a) when (max(t1.c)) then  -cast(avg(a) AS integer) else cast(avg(t1.c) AS integer) end from t1) FROM t1 WHERE (f) not between c and 17 | t1.b | coalesce((select t1.d from t1 where t1.d*~case when a<=f or (case t1.f when d+17+17 then e else +case when (11<>17) then 11 when  -t1.b not in (e,19,(f)) then t1.c else a end+13 end>= -t1.f) then ~ -t1.c else c end*t1.f*a*17<=t1.f),17)}\n} {300}\ndo_test randexpr-2.1753 {\n  db eval {SELECT (select abs(min(t1.b)) from t1)-f | case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) | cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c)))}\n} {-268}\ndo_test randexpr-2.1754 {\n  db eval {SELECT (select abs(min(t1.b)) from t1)-f | case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) | cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE NOT (t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c))))}\n} {}\ndo_test randexpr-2.1755 {\n  db eval {SELECT (select abs(min(t1.b)) from t1)-f & case when +t1.d*d not in (t1.f,t1.a,case when ~t1.f-17*c<>t1.a then 11 when 19 in (select (+count(distinct b)) & cast(avg(19) AS integer)*count(*) from t1 union select count(distinct t1.d) from t1) then d else d end+19+b) then (a) else 17 end*13+d FROM t1 WHERE t1.f<>(abs(t1.a)/abs(coalesce((select max(case when coalesce((select max((select count(*) from t1)) from t1 where f<>t1.a),coalesce((select max(11) from t1 where 17+coalesce((select t1.a from t1 where a in (select +~cast(avg(d+11) AS integer) from t1 union select count(distinct coalesce((select max((13)) from t1 where not (t1.f)<>19),f)*d) from t1)),19)+t1.e between 13 and (t1.b)),e))>=e then d else t1.f end) from t1 where ((not f>= -t1.b))),t1.c)))}\n} {1568}\ndo_test randexpr-2.1756 {\n  db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) | a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select  -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b}\n} {1300}\ndo_test randexpr-2.1757 {\n  db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) | a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select  -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE NOT (t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b)}\n} {}\ndo_test randexpr-2.1758 {\n  db eval {SELECT coalesce((select max(a) from t1 where a>a*(((t1.d)) & a)-+case t1.a-t1.d-19+coalesce((select max(t1.c) from t1 where ~(select  -cast(avg(a+d) AS integer) from t1) not in (~((17)),t1.a,(t1.e))),b)+a*(c) when t1.f then a else t1.f end-17+c),13)*t1.a FROM t1 WHERE t1.b*t1.d*11*case 13 | t1.a when (case when not exists(select 1 from t1 where t1.a not between coalesce((select f-a from t1 where a not in (11,d,(a)) or e<=d and 11=t1.e),d)+e and t1.c) and (t1.a>=t1.f or (t1.a)>=t1.a) then (c)+t1.d else a end)* -t1.a then e else t1.f end | 13>=b}\n} {10000}\ndo_test randexpr-2.1759 {\n  db eval {SELECT (abs(t1.f)/abs(11*19 | case when (e+t1.b*t1.d+(abs(case  -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select  -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and  -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1)}\n} {}\ndo_test randexpr-2.1760 {\n  db eval {SELECT (abs(t1.f)/abs(11*19 | case when (e+t1.b*t1.d+(abs(case  -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE NOT (a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select  -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and  -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1))}\n} {0}\ndo_test randexpr-2.1761 {\n  db eval {SELECT (abs(t1.f)/abs(11*19 & case when (e+t1.b*t1.d+(abs(case  -13+t1.d*t1.a-+coalesce((select t1.d from t1 where t1.b not between b and d and d in (select c from t1 union select d from t1)),(19)) when d then 13 else d end*t1.e)/abs(d))+f not between e and t1.a) then ( -f) else d end*a)) FROM t1 WHERE NOT (a in (select abs(max(b))-count(distinct case when d not between coalesce((select max(13) from t1 where a+a<+(19)), -f*case (select  -cast(avg(t1.c) AS integer)*cast(avg(c) AS integer)-cast(avg(13) AS integer) from t1)*coalesce((select d from t1 where (e=(f))),t1.d) when t1.a then 17 else 19 end) and d then t1.f when (19 between t1.e and  -a) then t1.a else (t1.c) end) from t1 union select max(t1.e)+~min(t1.c) from t1))}\n} {4}\ndo_test randexpr-2.1762 {\n  db eval {SELECT +t1.d | (d)*t1.e | (select case abs((max(t1.e)-abs(+case min(a) | (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end | max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else  -count(distinct 13) end from t1)+t1.b FROM t1 WHERE not exists(select 1 from t1 where e<t1.a)}\n} {200151}\ndo_test randexpr-2.1763 {\n  db eval {SELECT +t1.d | (d)*t1.e | (select case abs((max(t1.e)-abs(+case min(a) | (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end | max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else  -count(distinct 13) end from t1)+t1.b FROM t1 WHERE NOT (not exists(select 1 from t1 where e<t1.a))}\n} {}\ndo_test randexpr-2.1764 {\n  db eval {SELECT +t1.d & (d)*t1.e & (select case abs((max(t1.e)-abs(+case min(a) & (~(min(~t1.c)))*(abs(abs(count(*))+count(distinct b)*count(distinct 17)))*max(c) when max(t1.c) then max(t1.d) else cast(avg(d) AS integer) end & max(t1.a))))*cast(avg(11) AS integer) when (cast(avg( -a) AS integer)) then min(19) else  -count(distinct 13) end from t1)+t1.b FROM t1 WHERE not exists(select 1 from t1 where e<t1.a)}\n} {0}\ndo_test randexpr-2.1765 {\n  db eval {SELECT coalesce((select max(e) from t1 where  -(abs(~(t1.f+b))/abs(t1.f)) not in (~case 11+c*case when  -t1.d not between coalesce((select max(d) from t1 where f- -t1.f+t1.f-13-e<c),(f)) and a then t1.d else t1.a end when d then 17 else 13 end,d,c) or exists(select 1 from t1 where b<d)),13) FROM t1 WHERE (case when (t1.f<>13) or t1.a*t1.f- -a>=t1.d or d in (select  -case cast(avg(b) AS integer) when max(19) then count(distinct  -t1.f) else count(distinct f) end* -max(t1.d) from t1 union select  -cast(avg(13) AS integer) from t1) and 11 between t1.f and d then case when t1.f not between b and 13 then f else t1.e end-t1.c when t1.d in (t1.e,b,d) then t1.f else  -t1.d end-t1.d)*d*f>=a}\n} {}\ndo_test randexpr-2.1766 {\n  db eval {SELECT coalesce((select max(e) from t1 where  -(abs(~(t1.f+b))/abs(t1.f)) not in (~case 11+c*case when  -t1.d not between coalesce((select max(d) from t1 where f- -t1.f+t1.f-13-e<c),(f)) and a then t1.d else t1.a end when d then 17 else 13 end,d,c) or exists(select 1 from t1 where b<d)),13) FROM t1 WHERE NOT ((case when (t1.f<>13) or t1.a*t1.f- -a>=t1.d or d in (select  -case cast(avg(b) AS integer) when max(19) then count(distinct  -t1.f) else count(distinct f) end* -max(t1.d) from t1 union select  -cast(avg(13) AS integer) from t1) and 11 between t1.f and d then case when t1.f not between b and 13 then f else t1.e end-t1.c when t1.d in (t1.e,b,d) then t1.f else  -t1.d end-t1.d)*d*f>=a)}\n} {500}\ndo_test randexpr-2.1767 {\n  db eval {SELECT case when ~case when t1.a | case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select  -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c | 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end | count(*)) from t1) then t1.a else t1.c end | b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE exists(select 1 from t1 where d<>13)}\n} {300}\ndo_test randexpr-2.1768 {\n  db eval {SELECT case when ~case when t1.a | case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select  -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c | 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end | count(*)) from t1) then t1.a else t1.c end | b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE NOT (exists(select 1 from t1 where d<>13))}\n} {}\ndo_test randexpr-2.1769 {\n  db eval {SELECT case when ~case when t1.a & case when exists(select 1 from t1 where 19 in (select (count(*))-count(*) from t1 union select  -min(b) from t1) or t1.f not in (17,11,t1.c) and t1.d in (a,19,t1.a)) then ~c & 11 else 17 end* -19 in (select count(*) from t1 union select abs( - -case ~cast(avg(t1.b) AS integer) when min(b) then max(a) else (max( -d)) end & count(*)) from t1) then t1.a else t1.c end & b in (select f from t1 union select 13 from t1) then t1.b when t1.a<>(17) then c else t1.a end FROM t1 WHERE exists(select 1 from t1 where d<>13)}\n} {300}\ndo_test randexpr-2.1770 {\n  db eval {SELECT coalesce((select a+t1.d from t1 where t1.d+coalesce((select max(case when e not between 11 and case when (abs(f)/abs(t1.f+19*t1.b))>e then ~d when not not 17 in (13,17,t1.a) then f else t1.f end then 11 when b<17 then t1.b else f end) from t1 where exists(select 1 from t1 where (c<>c))), -f)+t1.c in (select (t1.e) from t1 union select c from t1)),c) FROM t1 WHERE not (t1.a)<=case a when t1.f then +coalesce((select max(c) from t1 where (abs(d-11)/abs(t1.a))+t1.f<=d*d*t1.a+coalesce((select 19 from t1 where (select cast(avg(f) AS integer) from t1)*t1.f+19+ -13 in ((t1.d),c,t1.a)),t1.c) or ((not exists(select 1 from t1 where 19 in (select e from t1 union select  -11 from t1))))),c) else e end}\n} {}\ndo_test randexpr-2.1771 {\n  db eval {SELECT coalesce((select a+t1.d from t1 where t1.d+coalesce((select max(case when e not between 11 and case when (abs(f)/abs(t1.f+19*t1.b))>e then ~d when not not 17 in (13,17,t1.a) then f else t1.f end then 11 when b<17 then t1.b else f end) from t1 where exists(select 1 from t1 where (c<>c))), -f)+t1.c in (select (t1.e) from t1 union select c from t1)),c) FROM t1 WHERE NOT (not (t1.a)<=case a when t1.f then +coalesce((select max(c) from t1 where (abs(d-11)/abs(t1.a))+t1.f<=d*d*t1.a+coalesce((select 19 from t1 where (select cast(avg(f) AS integer) from t1)*t1.f+19+ -13 in ((t1.d),c,t1.a)),t1.c) or ((not exists(select 1 from t1 where 19 in (select e from t1 union select  -11 from t1))))),c) else e end)}\n} {300}\ndo_test randexpr-2.1772 {\n  db eval {SELECT (abs( -c+b)/abs(case when ~11 in (select t1.c from t1 union select coalesce((select t1.f from t1 where coalesce((select max(17) from t1 where coalesce((select case  -t1.d when t1.e then a else b end-(t1.d) from t1 where t1.a not between  -a and t1.b or t1.f<t1.e and e<=a),t1.e)*t1.d not in (b,11,t1.f)),19)<19 and not exists(select 1 from t1 where t1.f>=t1.b) and (f)>= -13),t1.b) from t1) then t1.c when t1.b<=t1.f then 13 else t1.e end)) FROM t1 WHERE (d-coalesce((select max(case 11 when +13-17 | 13 | coalesce((select t1.b from t1 where ((abs(t1.b)/abs((abs(b)/abs(+(19)))*t1.c)) | a in ( -t1.c,t1.a,t1.b))),d)* -d then 13 else 11 end) from t1 where e not in (d,11,11) or t1.e>t1.e),17)+t1.a>b)}\n} {7}\ndo_test randexpr-2.1773 {\n  db eval {SELECT (abs( -c+b)/abs(case when ~11 in (select t1.c from t1 union select coalesce((select t1.f from t1 where coalesce((select max(17) from t1 where coalesce((select case  -t1.d when t1.e then a else b end-(t1.d) from t1 where t1.a not between  -a and t1.b or t1.f<t1.e and e<=a),t1.e)*t1.d not in (b,11,t1.f)),19)<19 and not exists(select 1 from t1 where t1.f>=t1.b) and (f)>= -13),t1.b) from t1) then t1.c when t1.b<=t1.f then 13 else t1.e end)) FROM t1 WHERE NOT ((d-coalesce((select max(case 11 when +13-17 | 13 | coalesce((select t1.b from t1 where ((abs(t1.b)/abs((abs(b)/abs(+(19)))*t1.c)) | a in ( -t1.c,t1.a,t1.b))),d)* -d then 13 else 11 end) from t1 where e not in (d,11,11) or t1.e>t1.e),17)+t1.a>b))}\n} {}\ndo_test randexpr-2.1774 {\n  db eval {SELECT coalesce((select max(17) from t1 where (e* -t1.f*e*c-coalesce((select max(t1.f) from t1 where t1.c between case when e+~ -t1.e+11 in (select c from t1 union select t1.a from t1) and t1.d>=c then 19 else ( - -(t1.a)) end*c+f and t1.b),13) not in (t1.b,e,t1.c) and (11) not in (b,( -t1.b),13))),19) FROM t1 WHERE d>e+f}\n} {}\ndo_test randexpr-2.1775 {\n  db eval {SELECT coalesce((select max(17) from t1 where (e* -t1.f*e*c-coalesce((select max(t1.f) from t1 where t1.c between case when e+~ -t1.e+11 in (select c from t1 union select t1.a from t1) and t1.d>=c then 19 else ( - -(t1.a)) end*c+f and t1.b),13) not in (t1.b,e,t1.c) and (11) not in (b,( -t1.b),13))),19) FROM t1 WHERE NOT (d>e+f)}\n} {17}\ndo_test randexpr-2.1776 {\n  db eval {SELECT case when t1.b in (select case 13-(select case count(*) when count(distinct (abs(19)/abs(t1.d)))*~count(distinct 13)*(max((abs(t1.e*d*f)/abs(17)))) then  -case  - -count(distinct e) when min(19) then (cast(avg(17) AS integer)) else count(distinct t1.a) end*max(t1.b)-cast(avg(a) AS integer) else count(distinct t1.d) end from t1)+t1.b*d when t1.c+t1.a then f else t1.f end from t1 union select t1.c from t1) then t1.a when a in (select 11 from t1 union select a from t1) then a else e end FROM t1 WHERE (case when case 11+case f when e then d else (abs(e)/abs(19))*a end when 19 then b else d end<t1.d then t1.c when b>= -19 then 13 else t1.e end between 17 and t1.a or b>=17 and ((( -t1.f))>=t1.c and 17 between t1.c and 19 and t1.c between t1.d and a or t1.d=17) or c in (b,13,17))}\n} {}\ndo_test randexpr-2.1777 {\n  db eval {SELECT case when t1.b in (select case 13-(select case count(*) when count(distinct (abs(19)/abs(t1.d)))*~count(distinct 13)*(max((abs(t1.e*d*f)/abs(17)))) then  -case  - -count(distinct e) when min(19) then (cast(avg(17) AS integer)) else count(distinct t1.a) end*max(t1.b)-cast(avg(a) AS integer) else count(distinct t1.d) end from t1)+t1.b*d when t1.c+t1.a then f else t1.f end from t1 union select t1.c from t1) then t1.a when a in (select 11 from t1 union select a from t1) then a else e end FROM t1 WHERE NOT ((case when case 11+case f when e then d else (abs(e)/abs(19))*a end when 19 then b else d end<t1.d then t1.c when b>= -19 then 13 else t1.e end between 17 and t1.a or b>=17 and ((( -t1.f))>=t1.c and 17 between t1.c and 19 and t1.c between t1.d and a or t1.d=17) or c in (b,13,17)))}\n} {100}\ndo_test randexpr-2.1778 {\n  db eval {SELECT case when coalesce((select case when (not exists(select 1 from t1 where t1.f<>t1.f)) then case when d-t1.e*t1.d=((select (count(distinct t1.a)) from t1)) then t1.a when 13 not in ( -b,13,19) then t1.b else e end when t1.e=13 then e else 17 end-17*b from t1 where (t1.d in (d,t1.e,t1.f))),( -f)) not in (d,t1.e,c) then t1.d else  -t1.f end* -t1.b FROM t1 WHERE not exists(select 1 from t1 where 11 in (select max(coalesce((select max(case when e+coalesce((select max(d) from t1 where not a<t1.c),(a)) in (((f)),c,13) then t1.e else e end-d) from t1 where 17 between (c) and t1.c),17)) from t1 union select ( -case cast(avg(c) AS integer) when case min(11) when ( -min(e)) then min(t1.b) else min(f) end then  -min(b) else count(distinct 13) end+min(13)- - -count(*)) from t1) or 17 in (19,t1.d,(a)) and exists(select 1 from t1 where t1.e in (t1.d,e,11)))}\n} {}\ndo_test randexpr-2.1779 {\n  db eval {SELECT case when coalesce((select case when (not exists(select 1 from t1 where t1.f<>t1.f)) then case when d-t1.e*t1.d=((select (count(distinct t1.a)) from t1)) then t1.a when 13 not in ( -b,13,19) then t1.b else e end when t1.e=13 then e else 17 end-17*b from t1 where (t1.d in (d,t1.e,t1.f))),( -f)) not in (d,t1.e,c) then t1.d else  -t1.f end* -t1.b FROM t1 WHERE NOT (not exists(select 1 from t1 where 11 in (select max(coalesce((select max(case when e+coalesce((select max(d) from t1 where not a<t1.c),(a)) in (((f)),c,13) then t1.e else e end-d) from t1 where 17 between (c) and t1.c),17)) from t1 union select ( -case cast(avg(c) AS integer) when case min(11) when ( -min(e)) then min(t1.b) else min(f) end then  -min(b) else count(distinct 13) end+min(13)- - -count(*)) from t1) or 17 in (19,t1.d,(a)) and exists(select 1 from t1 where t1.e in (t1.d,e,11))))}\n} {-80000}\ndo_test randexpr-2.1780 {\n  db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) | e then c else e end from t1 where  -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select  -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between  -c and  -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end)}\n} {-3051}\ndo_test randexpr-2.1781 {\n  db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) | e then c else e end from t1 where  -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE NOT (t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select  -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between  -c and  -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end))}\n} {}\ndo_test randexpr-2.1782 {\n  db eval {SELECT coalesce((select (abs(~c*t1.a+t1.b*coalesce((select case c when b+coalesce((select t1.b-case e when 19 then b else b end*11 from t1 where t1.b<>b or not t1.f in (11,t1.a,t1.e)),t1.a) & e then c else e end from t1 where  -t1.a<11),13))/abs(t1.b))-t1.b*17 from t1 where c=t1.c),17) FROM t1 WHERE t1.e+e>=coalesce((select max(t1.d) from t1 where +(t1.f) not between c and f),case when exists(select 1 from t1 where t1.e+t1.c<>(abs(e*(select  -count(*) from t1))/abs(t1.e*coalesce((select max((select cast(avg(13) AS integer) from t1)) from t1 where not (a) not between  -c and  -17), -d)+ -a+t1.f))) then case when e between 17 and d then a else 19 end when not c between e and 11 then 13 else t1.a end)}\n} {-3051}\ndo_test randexpr-2.1783 {\n  db eval {SELECT t1.a-~17-t1.c+t1.c | (c) | (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 | t1.e FROM t1 WHERE e in (select 11 from t1 union select a from t1)}\n} {}\ndo_test randexpr-2.1784 {\n  db eval {SELECT t1.a-~17-t1.c+t1.c | (c) | (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 | t1.e FROM t1 WHERE NOT (e in (select 11 from t1 union select a from t1))}\n} {57342}\ndo_test randexpr-2.1785 {\n  db eval {SELECT t1.a-~17-t1.c+t1.c & (c) & (13)*coalesce((select max((case when 11 in (case when (19 in (select abs(max(c)) from t1 union select ( -cast(avg(19) AS integer)) from t1)) then 13 when t1.a= -t1.a then t1.b else c end,a,13) then t1.e when t1.b in (t1.a,13, -19) then d else t1.a end)) from t1 where t1.d between t1.d and t1.b and t1.d<=17),t1.d)*11 & t1.e FROM t1 WHERE NOT (e in (select 11 from t1 union select a from t1))}\n} {32}\ndo_test randexpr-2.1786 {\n  db eval {SELECT (abs(case when 11 not between t1.d and case coalesce((select case c+case when b in (case when a<=t1.b then (t1.a) when f not in (d,t1.f, -(a)) then (t1.a) else c end,t1.a,b) then 11 when (t1.c not between 17 and  -d) then t1.d else e end+e*t1.a when 19 then b else t1.e end from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where  -(19)=d))),t1.d) when c then a else  -17 end or a>=19 then 17 else b end+ -13)/abs(b)) FROM t1 WHERE not exists(select 1 from t1 where not e+case 13 when 11 then +t1.d else t1.f+11 end*a-19+t1.c+a in (~e | coalesce((select ~a*+(abs( -case case b*e when f then e else  -13 end when t1.d then t1.b else t1.b end)/abs(17))+t1.b from t1 where t1.a=e),d),e,e))}\n} {}\ndo_test randexpr-2.1787 {\n  db eval {SELECT (abs(case when 11 not between t1.d and case coalesce((select case c+case when b in (case when a<=t1.b then (t1.a) when f not in (d,t1.f, -(a)) then (t1.a) else c end,t1.a,b) then 11 when (t1.c not between 17 and  -d) then t1.d else e end+e*t1.a when 19 then b else t1.e end from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where  -(19)=d))),t1.d) when c then a else  -17 end or a>=19 then 17 else b end+ -13)/abs(b)) FROM t1 WHERE NOT (not exists(select 1 from t1 where not e+case 13 when 11 then +t1.d else t1.f+11 end*a-19+t1.c+a in (~e | coalesce((select ~a*+(abs( -case case b*e when f then e else  -13 end when t1.d then t1.b else t1.b end)/abs(17))+t1.b from t1 where t1.a=e),d),e,e)))}\n} {0}\ndo_test randexpr-2.1788 {\n  db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 | (select abs(min((t1.c) | +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select  -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select  -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else  -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c}\n} {}\ndo_test randexpr-2.1789 {\n  db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 | (select abs(min((t1.c) | +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE NOT (t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select  -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select  -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else  -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c)}\n} {-200}\ndo_test randexpr-2.1790 {\n  db eval {SELECT t1.c-coalesce((select t1.e from t1 where not 17 & (select abs(min((t1.c) & +case 19 when d then f else t1.c end*(13)+a)- -count(*)) from t1)>t1.c and (exists(select 1 from t1 where c in (select f from t1 union select a from t1))) or t1.e>t1.c),coalesce((select e*(e) from t1 where not exists(select 1 from t1 where b not in (f,a,19))),c)) FROM t1 WHERE NOT (t1.f*t1.e*b+coalesce((select case when 17 not in (case e++t1.d+19*11 when case when 11 in (select  -min(t1.a)*min(t1.e)+cast(avg(t1.a) AS integer) from t1 union select  -count(*) from t1) then 13 else 11 end*17 then a else t1.a end,(t1.b),t1.d) then t1.f else  -b end from t1 where t1.b not between 17 and (a)),d)-t1.d-c*b<c)}\n} {-200}\ndo_test randexpr-2.1791 {\n  db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c | case when +c>= -b+t1.f | 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1)}\n} {}\ndo_test randexpr-2.1792 {\n  db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c | case when +c>= -b+t1.f | 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE NOT (t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1))}\n} {-39999700}\ndo_test randexpr-2.1793 {\n  db eval {SELECT c-coalesce((select max(case when (case t1.a when a then case f when e*e then ~c & case when +c>= -b+t1.f & 19 then t1.d else 11 end else t1.a end-t1.e else d end not between f and t1.f) then c else e end) from t1 where f>=t1.b and t1.c between t1.f and t1.a),e)*d*b FROM t1 WHERE NOT (t1.b in (select 11-case when (t1.a+19<=case when c>=(19) then 11 else t1.e+t1.a*c end*e and t1.f in (select case abs(+abs( -count(*) | count(*)*count(distinct c)+max(13))) when min(d) then min(b) else min(t1.b) end | cast(avg(t1.e) AS integer) from t1 union select count(distinct t1.e) from t1)) then t1.a else t1.f end*17 from t1 union select t1.a from t1))}\n} {-39999700}\ndo_test randexpr-2.1794 {\n  db eval {SELECT coalesce((select f from t1 where ~coalesce((select max(b-e) from t1 where 13 in (select d from t1 union select d from t1)),(abs(t1.f)/abs(t1.f)))-t1.d+case a when t1.b then 13 else case when 19>case a when t1.a then 13 else  -d end or e<>c then coalesce((select max(a) from t1 where t1.e not between (13) and t1.d),11) when b in (select t1.a from t1 union select t1.f from t1) then 19 else a end end-b>11),17) FROM t1 WHERE b in (select e-17 from t1 union select d from t1)}\n} {}\ndo_test randexpr-2.1795 {\n  db eval {SELECT coalesce((select f from t1 where ~coalesce((select max(b-e) from t1 where 13 in (select d from t1 union select d from t1)),(abs(t1.f)/abs(t1.f)))-t1.d+case a when t1.b then 13 else case when 19>case a when t1.a then 13 else  -d end or e<>c then coalesce((select max(a) from t1 where t1.e not between (13) and t1.d),11) when b in (select t1.a from t1 union select t1.f from t1) then 19 else a end end-b>11),17) FROM t1 WHERE NOT (b in (select e-17 from t1 union select d from t1))}\n} {17}\ndo_test randexpr-2.1796 {\n  db eval {SELECT coalesce((select case case when 13<>((abs(t1.b)/abs(f+t1.c))) then 11 else coalesce((select max(b) from t1 where (b=(abs((select min((select case  -min(11) when count(distinct d) then count(*) else min(t1.c) end from t1)) from t1))/abs(t1.f))-c)), -19)*e end*d* -e+t1.d when 13 then c else c end+b from t1 where d>13 or (b between t1.e and 19)),a) FROM t1 WHERE not exists(select 1 from t1 where ((not not exists(select 1 from t1 where ((case when coalesce((select max(19) from t1 where case when b>=e and f between t1.d and t1.c or ( -t1.b)=t1.f then b+a else 11 end in (d,t1.d,(17))),t1.d)>t1.b then (t1.f) else d end*e*t1.e<=t1.b)) or 13<>13)) or 17<d) and t1.f in (t1.e,d,t1.b)) and e<=a}\n} {}\ndo_test randexpr-2.1797 {\n  db eval {SELECT coalesce((select case case when 13<>((abs(t1.b)/abs(f+t1.c))) then 11 else coalesce((select max(b) from t1 where (b=(abs((select min((select case  -min(11) when count(distinct d) then count(*) else min(t1.c) end from t1)) from t1))/abs(t1.f))-c)), -19)*e end*d* -e+t1.d when 13 then c else c end+b from t1 where d>13 or (b between t1.e and 19)),a) FROM t1 WHERE NOT (not exists(select 1 from t1 where ((not not exists(select 1 from t1 where ((case when coalesce((select max(19) from t1 where case when b>=e and f between t1.d and t1.c or ( -t1.b)=t1.f then b+a else 11 end in (d,t1.d,(17))),t1.d)>t1.b then (t1.f) else d end*e*t1.e<=t1.b)) or 13<>13)) or 17<d) and t1.f in (t1.e,d,t1.b)) and e<=a)}\n} {500}\ndo_test randexpr-2.1798 {\n  db eval {SELECT ~case when 19 not between ~case when coalesce((select max(t1.c*(select cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where case when (t1.b in (d,b,t1.c)) and 13>t1.d then e+t1.c when 19 between t1.f and t1.f then 11 else e end between t1.e and 17) and c=t1.f),t1.c) not between t1.a and (19) then c else t1.b end*a-19 and b then b when a not in (a,t1.f,11) then a else a end FROM t1 WHERE (select abs((+min(t1.c)*min(t1.d)*count(*)))*count(*)++count(distinct ~13*11+t1.f) | case abs(+count(*)) when min(t1.e) then count(*) else max(13) end from t1)*t1.b between d and a++19 and t1.c in (select ~((abs(17)/abs(c)))-d from t1 union select t1.f from t1)}\n} {}\ndo_test randexpr-2.1799 {\n  db eval {SELECT ~case when 19 not between ~case when coalesce((select max(t1.c*(select cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where case when (t1.b in (d,b,t1.c)) and 13>t1.d then e+t1.c when 19 between t1.f and t1.f then 11 else e end between t1.e and 17) and c=t1.f),t1.c) not between t1.a and (19) then c else t1.b end*a-19 and b then b when a not in (a,t1.f,11) then a else a end FROM t1 WHERE NOT ((select abs((+min(t1.c)*min(t1.d)*count(*)))*count(*)++count(distinct ~13*11+t1.f) | case abs(+count(*)) when min(t1.e) then count(*) else max(13) end from t1)*t1.b between d and a++19 and t1.c in (select ~((abs(17)/abs(c)))-d from t1 union select t1.f from t1))}\n} {-101}\ndo_test randexpr-2.1800 {\n  db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then  -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 | (17) | b FROM t1 WHERE (select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1)}\n} {}\ndo_test randexpr-2.1801 {\n  db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then  -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 | (17) | b FROM t1 WHERE NOT ((select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1))}\n} {477}\ndo_test randexpr-2.1802 {\n  db eval {SELECT (t1.d)+(abs(coalesce((select ((abs(case t1.e when a+(abs(11)/abs(b)) then t1.f else case coalesce((select max(d+c) from t1 where +19+11<b),t1.d)-t1.d-t1.d*d when t1.c then  -e else t1.d end end-c)/abs(17))) from t1 where 17<>t1.c),d))/abs(t1.d))-11 & (17) & b FROM t1 WHERE NOT ((select ~min(b)+count(distinct 17) from t1)>(select max((abs((13))/abs(coalesce((select case when b*13 in (case when e=t1.b then c when 11<>e then f else t1.b end,t1.f,t1.a) then d when not exists(select 1 from t1 where t1.f<>e) then t1.a else c end from t1 where t1.e=13),t1.f) | b)))+(~~cast(avg(f) AS integer)-min((13))) from t1))}\n} {0}\ndo_test randexpr-2.1803 {\n  db eval {SELECT d+case coalesce((select t1.f from t1 where coalesce((select max((11)) from t1 where (coalesce((select d from t1 where ((case b when ( -a) then 19 else e end)) not in ( -d,t1.c,13)),b))>t1.b and ((c in (select ~~cast(avg(t1.b) AS integer)+ -(max(t1.e)) from t1 union select max(c) from t1) and (e) in (select  -count(distinct 17) from t1 union select count(*) from t1) or 11<>t1.c))),t1.b) not between (f) and 11),t1.d) when (19) then e else 13 end-t1.f FROM t1 WHERE exists(select 1 from t1 where (t1.a between case when e | b*c-19 | a<t1.a or (19 in (select coalesce((select max(f) from t1 where e<19),t1.e-17 | t1.e) from t1 union select 13 from t1)) then coalesce((select t1.e from t1 where not exists(select 1 from t1 where 11<=19) or exists(select 1 from t1 where  -(e) between a and 19) or b between b and c),c) else f end and 19))}\n} {}\ndo_test randexpr-2.1804 {\n  db eval {SELECT d+case coalesce((select t1.f from t1 where coalesce((select max((11)) from t1 where (coalesce((select d from t1 where ((case b when ( -a) then 19 else e end)) not in ( -d,t1.c,13)),b))>t1.b and ((c in (select ~~cast(avg(t1.b) AS integer)+ -(max(t1.e)) from t1 union select max(c) from t1) and (e) in (select  -count(distinct 17) from t1 union select count(*) from t1) or 11<>t1.c))),t1.b) not between (f) and 11),t1.d) when (19) then e else 13 end-t1.f FROM t1 WHERE NOT (exists(select 1 from t1 where (t1.a between case when e | b*c-19 | a<t1.a or (19 in (select coalesce((select max(f) from t1 where e<19),t1.e-17 | t1.e) from t1 union select 13 from t1)) then coalesce((select t1.e from t1 where not exists(select 1 from t1 where 11<=19) or exists(select 1 from t1 where  -(e) between a and 19) or b between b and c),c) else f end and 19)))}\n} {-187}\ndo_test randexpr-2.1805 {\n  db eval {SELECT coalesce((select c from t1 where  - -19-coalesce((select t1.e from t1 where not f<=b-17 or not  -13>=f or (select  -count(*) from t1) in (select t1.c from t1 union select 17 from t1)),b)*e not between case coalesce((select max(~case when 17>t1.e then d else 13 end) from t1 where not t1.c<=17),t1.c) when 13 then c else t1.e end+t1.c-t1.e and t1.e),t1.e) FROM t1 WHERE case ~case when not exists(select 1 from t1 where f<=~t1.d) then (abs(coalesce((select ~19 from t1 where d+t1.f=b),d))/abs(e)) when d in (select +min(11) from t1 union select ( -abs(count(distinct e)))+count(distinct t1.a) from t1) then e else t1.d end when  -d then t1.e else t1.b end=t1.f or t1.d not in (t1.c,t1.e,t1.e) and t1.c not in (17,t1.a,e)}\n} {300}\ndo_test randexpr-2.1806 {\n  db eval {SELECT coalesce((select c from t1 where  - -19-coalesce((select t1.e from t1 where not f<=b-17 or not  -13>=f or (select  -count(*) from t1) in (select t1.c from t1 union select 17 from t1)),b)*e not between case coalesce((select max(~case when 17>t1.e then d else 13 end) from t1 where not t1.c<=17),t1.c) when 13 then c else t1.e end+t1.c-t1.e and t1.e),t1.e) FROM t1 WHERE NOT (case ~case when not exists(select 1 from t1 where f<=~t1.d) then (abs(coalesce((select ~19 from t1 where d+t1.f=b),d))/abs(e)) when d in (select +min(11) from t1 union select ( -abs(count(distinct e)))+count(distinct t1.a) from t1) then e else t1.d end when  -d then t1.e else t1.b end=t1.f or t1.d not in (t1.c,t1.e,t1.e) and t1.c not in (17,t1.a,e))}\n} {}\ndo_test randexpr-2.1807 {\n  db eval {SELECT case when t1.e<=~d then case when t1.d-e in (~t1.c-case e*case when t1.e not in (t1.d,19,f) then e else b end*e when (19) then t1.a else  -e end,19,17) then t1.f when t1.d not in (t1.b,b,17) then t1.b else 19 end when 13= -t1.f and not (19=t1.d) then t1.f else (d) end FROM t1 WHERE 19<>d}\n} {400}\ndo_test randexpr-2.1808 {\n  db eval {SELECT case when t1.e<=~d then case when t1.d-e in (~t1.c-case e*case when t1.e not in (t1.d,19,f) then e else b end*e when (19) then t1.a else  -e end,19,17) then t1.f when t1.d not in (t1.b,b,17) then t1.b else 19 end when 13= -t1.f and not (19=t1.d) then t1.f else (d) end FROM t1 WHERE NOT (19<>d)}\n} {}\ndo_test randexpr-2.1809 {\n  db eval {SELECT (select max(case when (t1.d<=t1.a*t1.b) then t1.e else case when t1.a> -t1.c*t1.f then b else b*(a) end end)*min(+ -19-(select min(a) from t1)-+17*case when not exists(select 1 from t1 where (select abs(cast(avg(a) AS integer)) from t1)=t1.a) then e when 19>=a then 13 else t1.a end*19-e) from t1) FROM t1 WHERE t1.e in (select max(t1.e)-cast(avg(e) AS integer) from t1 union select (~+count(*) | count(*) | cast(avg((abs(coalesce((select max(case f+c-17 when t1.b then t1.e else t1.d end) from t1 where 17 in (select a from t1 union select t1.b from t1)),a))/abs( -t1.e))) AS integer)+~case count(*) when cast(avg(t1.d) AS integer) then  -cast(avg(t1.e) AS integer) else count(distinct d) end-max(13)+ -min(t1.a) | min((17)) | count(distinct d))-min(e) from t1)}\n} {}\ndo_test randexpr-2.1810 {\n  db eval {SELECT (select max(case when (t1.d<=t1.a*t1.b) then t1.e else case when t1.a> -t1.c*t1.f then b else b*(a) end end)*min(+ -19-(select min(a) from t1)-+17*case when not exists(select 1 from t1 where (select abs(cast(avg(a) AS integer)) from t1)=t1.a) then e when 19>=a then 13 else t1.a end*19-e) from t1) FROM t1 WHERE NOT (t1.e in (select max(t1.e)-cast(avg(e) AS integer) from t1 union select (~+count(*) | count(*) | cast(avg((abs(coalesce((select max(case f+c-17 when t1.b then t1.e else t1.d end) from t1 where 17 in (select a from t1 union select t1.b from t1)),a))/abs( -t1.e))) AS integer)+~case count(*) when cast(avg(t1.d) AS integer) then  -cast(avg(t1.e) AS integer) else count(distinct d) end-max(13)+ -min(t1.a) | min((17)) | count(distinct d))-min(e) from t1))}\n} {-16459500}\ndo_test randexpr-2.1811 {\n  db eval {SELECT case when case (select max(t1.b)*min(case when (abs(t1.e)/abs(d)) in (select 19 from t1 union select +t1.d from t1) then t1.d when t1.d=d or 11 in (t1.c,b,t1.b) and 13 in (select max(b)-count(distinct b) from t1 union select count(distinct  -t1.c) from t1) then f else 17 end) from t1) when t1.a then 11 else t1.d end+t1.a>c or t1.c between 13 and a then f when (t1.b)>=t1.a then d else b end FROM t1 WHERE (not exists(select 1 from t1 where coalesce((select max(e) from t1 where  -b+a-(abs(c)/abs(b))-( -t1.a)-t1.c>=d),d) in (select count(distinct a) from t1 union select cast(avg(t1.b) AS integer) from t1) and exists(select 1 from t1 where not t1.d<>f) and t1.a in (select min(t1.a)+max(a)*max(19)*count(distinct c) from t1 union select ((count(distinct 11))) from t1) or t1.c>(13) and a between (t1.f) and 13))}\n} {600}\ndo_test randexpr-2.1812 {\n  db eval {SELECT case when case (select max(t1.b)*min(case when (abs(t1.e)/abs(d)) in (select 19 from t1 union select +t1.d from t1) then t1.d when t1.d=d or 11 in (t1.c,b,t1.b) and 13 in (select max(b)-count(distinct b) from t1 union select count(distinct  -t1.c) from t1) then f else 17 end) from t1) when t1.a then 11 else t1.d end+t1.a>c or t1.c between 13 and a then f when (t1.b)>=t1.a then d else b end FROM t1 WHERE NOT ((not exists(select 1 from t1 where coalesce((select max(e) from t1 where  -b+a-(abs(c)/abs(b))-( -t1.a)-t1.c>=d),d) in (select count(distinct a) from t1 union select cast(avg(t1.b) AS integer) from t1) and exists(select 1 from t1 where not t1.d<>f) and t1.a in (select min(t1.a)+max(a)*max(19)*count(distinct c) from t1 union select ((count(distinct 11))) from t1) or t1.c>(13) and a between (t1.f) and 13)))}\n} {}\ndo_test randexpr-2.1813 {\n  db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) |  -19 not in (f,b,f) then  -b when not 13 in (select max((19)) from t1 union select count(*) | count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b | t1.b)/abs(f))*f*f FROM t1 WHERE ~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1)}\n} {}\ndo_test randexpr-2.1814 {\n  db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) |  -19 not in (f,b,f) then  -b when not 13 in (select max((19)) from t1 union select count(*) | count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b | t1.b)/abs(f))*f*f FROM t1 WHERE NOT (~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1))}\n} {-24192000000}\ndo_test randexpr-2.1815 {\n  db eval {SELECT f*~13*(abs(13*d- -(abs(case when ~coalesce((select max(c) from t1 where b>case when not exists(select 1 from t1 where f not in ( - -(t1.b),t1.b,t1.f)) then e when t1.c<>f then c else 13 end),17) &  -19 not in (f,b,f) then  -b when not 13 in (select max((19)) from t1 union select count(*) & count(*) from t1) and 11 not between t1.b and e or 13 in (t1.a, -e,(t1.c)) then a else 11 end)/abs(t1.c))*b & t1.b)/abs(f))*f*f FROM t1 WHERE NOT (~case f when coalesce((select max(17) from t1 where b+t1.f*case 11 when coalesce((select max(t1.f) from t1 where 17>t1.f),19)-t1.b-t1.b | d then b else c end+t1.d*11-t1.c<=case when b>=a then 19 else f end | t1.a),13) then f else t1.e end*t1.e*17-d in (select 13 from t1 union select t1.e from t1))}\n} {0}\ndo_test randexpr-2.1816 {\n  db eval {SELECT t1.b | (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or  -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE (abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19}\n} {217}\ndo_test randexpr-2.1817 {\n  db eval {SELECT t1.b | (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or  -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE NOT ((abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19)}\n} {}\ndo_test randexpr-2.1818 {\n  db eval {SELECT t1.b & (select case max( -17)-min(17) when cast(avg(a) AS integer)*(+cast(avg(f) AS integer)-cast(avg(case when not exists(select 1 from t1 where not case when t1.c<>t1.b or  -d not between b and a then 11 when (11)=11 then b else t1.b end in (t1.d,t1.c,13)) then 13 when t1.e not between 17 and t1.b then t1.c else t1.d end*t1.b) AS integer))-cast(avg(19) AS integer)*~max(t1.c)-((max(13)))*(count(*))+(max(11)) then count(distinct 13) else cast(avg(17) AS integer) end from t1) FROM t1 WHERE (abs(t1.c)/abs(case t1.d when t1.f then 13 else t1.f+13 end)) not between c and 19}\n} {0}\ndo_test randexpr-2.1819 {\n  db eval {SELECT case +c-case (select case count(distinct 13) when min(19*e) then ~count(*) else ~min(case when not +13*(case when e*c>=e then e else f end)-a+c not in (b,t1.b,t1.e) then 19 else 17 end*a) end from t1) when 11 then 11 else c end+t1.c when t1.b then d else 19 end FROM t1 WHERE t1.a<>~coalesce((select max(e) from t1 where 13-17*13<>19*17-f or coalesce((select max(~case +t1.d-f*e | c+(17)+a | c*((b)) when a then t1.a else d end-d) from t1 where t1.c>= -t1.a),t1.b) | 19>t1.a),c)}\n} {19}\ndo_test randexpr-2.1820 {\n  db eval {SELECT case +c-case (select case count(distinct 13) when min(19*e) then ~count(*) else ~min(case when not +13*(case when e*c>=e then e else f end)-a+c not in (b,t1.b,t1.e) then 19 else 17 end*a) end from t1) when 11 then 11 else c end+t1.c when t1.b then d else 19 end FROM t1 WHERE NOT (t1.a<>~coalesce((select max(e) from t1 where 13-17*13<>19*17-f or coalesce((select max(~case +t1.d-f*e | c+(17)+a | c*((b)) when a then t1.a else d end-d) from t1 where t1.c>= -t1.a),t1.b) | 19>t1.a),c))}\n} {}\ndo_test randexpr-2.1821 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b |  -(select +cast(avg(17-case when  -c<=17 then a when  -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and  -11), -b) FROM t1 WHERE (f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a)}\n} {}\ndo_test randexpr-2.1822 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b |  -(select +cast(avg(17-case when  -c<=17 then a when  -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and  -11), -b) FROM t1 WHERE NOT ((f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a))}\n} {-200}\ndo_test randexpr-2.1823 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where f between case when (19 not in (t1.b,(a),t1.a)) or t1.a=t1.b &  -(select +cast(avg(17-case when  -c<=17 then a when  -11 not in (11,19,a) then e else 11 end-t1.a*d) AS integer) from t1) then t1.b when (11)*f in (13,t1.a,a) or t1.a<t1.d then b*t1.f else a end and  -11), -b) FROM t1 WHERE NOT ((f-b<case case (a) when a then 19+coalesce((select t1.a from t1 where 11 between +coalesce((select max(case when t1.b not in (t1.f,f,t1.b) and a in (select 11 from t1 union select c from t1) then ~(t1.e) else 13 end) from t1 where t1.c>=e),f)*b-f and t1.f),t1.b) else d end+19 when t1.a then 11 else e end-t1.a))}\n} {-200}\ndo_test randexpr-2.1824 {\n  db eval {SELECT case when not  -t1.c in (coalesce((select d from t1 where t1.a not in (t1.c+f, -f,19) and t1.b in (select max(t1.d)+min(19)*min(t1.e) from t1 union select count(distinct d) from t1) and (t1.d) in (select  -count(*) from t1 union select  -count(*) from t1)),d* -t1.e),b,f) or  -c not in (a, -t1.a,t1.e) then case when b between 17 and t1.b and a not in (t1.a,e,t1.e) then t1.d else 19 end*t1.b else t1.d end+t1.d FROM t1 WHERE (abs((17))/abs(11 | e*e+d++t1.d)) in (19+t1.f,e,(abs(13)/abs( -t1.c)))}\n} {4200}\ndo_test randexpr-2.1825 {\n  db eval {SELECT case when not  -t1.c in (coalesce((select d from t1 where t1.a not in (t1.c+f, -f,19) and t1.b in (select max(t1.d)+min(19)*min(t1.e) from t1 union select count(distinct d) from t1) and (t1.d) in (select  -count(*) from t1 union select  -count(*) from t1)),d* -t1.e),b,f) or  -c not in (a, -t1.a,t1.e) then case when b between 17 and t1.b and a not in (t1.a,e,t1.e) then t1.d else 19 end*t1.b else t1.d end+t1.d FROM t1 WHERE NOT ((abs((17))/abs(11 | e*e+d++t1.d)) in (19+t1.f,e,(abs(13)/abs( -t1.c))))}\n} {}\ndo_test randexpr-2.1826 {\n  db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) | count(distinct (11)) | min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and  -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f}\n} {1}\ndo_test randexpr-2.1827 {\n  db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) | count(distinct (11)) | min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and  -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f)}\n} {}\ndo_test randexpr-2.1828 {\n  db eval {SELECT case when ( -(select ~ -~ -(max(c))-min(t1.e) & count(distinct (11)) & min(t1.a) from t1)-case when case d when a then case when t1.e=t1.a then t1.c else c end else c end<=t1.f then t1.b when t1.c not in (a,19,c) then b else 17 end>=19) or d in (19,f, -11) then 19 else (select case min(t1.a)-(cast(avg(t1.f) AS integer))-(min(11)) when count(*) then count(*) else count(distinct a) end from t1) end FROM t1 WHERE not exists(select 1 from t1 where (abs(11-13)/abs(f))>19*~19+t1.d-t1.f+coalesce((select max(f) from t1 where t1.a-t1.e+case when case when a not between t1.c and 19 and  -t1.e>t1.c then case when t1.f in (t1.d,e,t1.f) then d when c not in (11,t1.c,d) then t1.a else a end when t1.b=11 then t1.c else t1.e end>e then e else e end-11<t1.f),c)- -c-17) or 19<>t1.f}\n} {1}\ndo_test randexpr-2.1829 {\n  db eval {SELECT t1.e | t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select  -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE not +19+coalesce((select  -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else  -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else  -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13}\n} {}\ndo_test randexpr-2.1830 {\n  db eval {SELECT t1.e | t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select  -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE NOT (not +19+coalesce((select  -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else  -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else  -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13)}\n} {-108002820}\ndo_test randexpr-2.1831 {\n  db eval {SELECT t1.e & t1.a*~(17)-t1.c*f*f-coalesce((select max( -t1.a+coalesce((select t1.a from t1 where 19 not between 17 and f),(t1.b))*c+11) from t1 where 19 in (select  -cast(avg(f) AS integer)-cast(avg(a) AS integer)*count(distinct d) from t1 union select count(*) from t1) and t1.d in (17,t1.d, -t1.c) or 19<>19),a)*11 FROM t1 WHERE NOT (not +19+coalesce((select  -19 from t1 where t1.c | e in (select ~ -abs(case ~abs(+(count(distinct 17) | case ~(max(t1.a))+(+~ -min(17)) when abs(min(t1.c)) then count(distinct 17) else  -cast(avg(t1.e) AS integer) end)*cast(avg(c) AS integer)*cast(avg(t1.b) AS integer)) when count(distinct t1.d) then min(b) else  -cast(avg(d) AS integer) end) from t1 union select count(*) from t1)),13)>13)}\n} {420}\ndo_test randexpr-2.1832 {\n  db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end |  -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else  -t1.c end FROM t1 WHERE 19>=11}\n} {500}\ndo_test randexpr-2.1833 {\n  db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end |  -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else  -t1.c end FROM t1 WHERE NOT (19>=11)}\n} {}\ndo_test randexpr-2.1834 {\n  db eval {SELECT case when t1.a<(abs((abs(13)/abs(case t1.e+11*17*case +case case when ~19>=t1.c then f when f not in (a,e,d) then 19 else b end when 19 then 19 else b end &  -c when c then t1.c else c end*d-t1.e when e then 13 else c end)))/abs(t1.b)) then 17 when t1.b not in (t1.a,13,e) then e else  -t1.c end FROM t1 WHERE 19>=11}\n} {500}\ndo_test randexpr-2.1835 {\n  db eval {SELECT coalesce((select (select count(*)-+count(*) from t1) from t1 where +t1.f+t1.f<~case when exists(select 1 from t1 where coalesce((select t1.a from t1 where b-19<t1.f),11) in (case when  -(select count(distinct t1.a) from t1)-c-t1.d between b and (d) then d else t1.e end,f,c)) then t1.b when t1.e<>(11) then d else (c) end+e+t1.d),c) FROM t1 WHERE case when t1.f+(select min(t1.c+(abs(13+(abs(t1.e+d-11-e+d+c)/abs(t1.e))-c*t1.f)/abs(t1.b))) from t1)+f=d or t1.b not between t1.e and t1.a then 11-a when (13 in (13,19,19)) then t1.d else t1.b end<t1.f}\n} {300}\ndo_test randexpr-2.1836 {\n  db eval {SELECT coalesce((select (select count(*)-+count(*) from t1) from t1 where +t1.f+t1.f<~case when exists(select 1 from t1 where coalesce((select t1.a from t1 where b-19<t1.f),11) in (case when  -(select count(distinct t1.a) from t1)-c-t1.d between b and (d) then d else t1.e end,f,c)) then t1.b when t1.e<>(11) then d else (c) end+e+t1.d),c) FROM t1 WHERE NOT (case when t1.f+(select min(t1.c+(abs(13+(abs(t1.e+d-11-e+d+c)/abs(t1.e))-c*t1.f)/abs(t1.b))) from t1)+f=d or t1.b not between t1.e and t1.a then 11-a when (13 in (13,19,19)) then t1.d else t1.b end<t1.f)}\n} {}\ndo_test randexpr-2.1837 {\n  db eval {SELECT case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (abs(a)/abs(t1.f))<a then t1.a when t1.b not in (11,t1.f,(c+d*t1.d)+t1.b+d-t1.a+e) then e else e end<=d))) then (select ~max(13) from t1) when 13 not between coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 13>=t1.b)),((d))) and t1.c then 19 else 13 end FROM t1 WHERE d*a in (case when 19>t1.e then c | (select +~count(distinct t1.b)-++abs(min(11)+ -~min(t1.b)+ -(max(t1.d))-min(t1.b)-count(distinct t1.f)) | max(f) from t1) else a+t1.c end,t1.a+case 19 when (11*a)*t1.c then d else a end*t1.a-d,f)}\n} {}\ndo_test randexpr-2.1838 {\n  db eval {SELECT case when not exists(select 1 from t1 where not exists(select 1 from t1 where (case when (abs(a)/abs(t1.f))<a then t1.a when t1.b not in (11,t1.f,(c+d*t1.d)+t1.b+d-t1.a+e) then e else e end<=d))) then (select ~max(13) from t1) when 13 not between coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where 13>=t1.b)),((d))) and t1.c then 19 else 13 end FROM t1 WHERE NOT (d*a in (case when 19>t1.e then c | (select +~count(distinct t1.b)-++abs(min(11)+ -~min(t1.b)+ -(max(t1.d))-min(t1.b)-count(distinct t1.f)) | max(f) from t1) else a+t1.c end,t1.a+case 19 when (11*a)*t1.c then d else a end*t1.a-d,f))}\n} {-14}\ndo_test randexpr-2.1839 {\n  db eval {SELECT case when b<= -coalesce((select max(t1.b+t1.c+a*a-t1.c-e) from t1 where not 11>e or c<=17 and b<=b), -t1.d)+13 and 17 not between a and c and not exists(select 1 from t1 where f not between t1.d and t1.e and t1.d between 13 and  -t1.a) then t1.b when e not in (a,t1.f, -t1.d) then t1.c else e end FROM t1 WHERE not coalesce((select max((c)) from t1 where d* -coalesce((select max(coalesce((select t1.d from t1 where (d<=d)),d)) from t1 where (abs(case 11 when (select  -+count(distinct 13)*min(c) | count(*) from t1) then 11 else case when (19 between (19) and 17 or t1.c in (c,19,d)) then c when  -t1.e>=c then c else c end end*11)/abs((13))) not in (17, -t1.e, -t1.e)),t1.e)=17),t1.c) between 13 and t1.f}\n} {}\ndo_test randexpr-2.1840 {\n  db eval {SELECT case when b<= -coalesce((select max(t1.b+t1.c+a*a-t1.c-e) from t1 where not 11>e or c<=17 and b<=b), -t1.d)+13 and 17 not between a and c and not exists(select 1 from t1 where f not between t1.d and t1.e and t1.d between 13 and  -t1.a) then t1.b when e not in (a,t1.f, -t1.d) then t1.c else e end FROM t1 WHERE NOT (not coalesce((select max((c)) from t1 where d* -coalesce((select max(coalesce((select t1.d from t1 where (d<=d)),d)) from t1 where (abs(case 11 when (select  -+count(distinct 13)*min(c) | count(*) from t1) then 11 else case when (19 between (19) and 17 or t1.c in (c,19,d)) then c when  -t1.e>=c then c else c end end*11)/abs((13))) not in (17, -t1.e, -t1.e)),t1.e)=17),t1.c) between 13 and t1.f)}\n} {300}\ndo_test randexpr-2.1841 {\n  db eval {SELECT 17 |  -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e | t1.e)) when (t1.d) then  -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) | t1.e FROM t1 WHERE 17>=e}\n} {}\ndo_test randexpr-2.1842 {\n  db eval {SELECT 17 |  -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e | t1.e)) when (t1.d) then  -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) | t1.e FROM t1 WHERE NOT (17>=e)}\n} {-3}\ndo_test randexpr-2.1843 {\n  db eval {SELECT 17 &  -(case when (a) not between 11 and case (abs(~(abs(13-case (abs(17)/abs(19+e & t1.e)) when (t1.d) then  -(t1.c) else t1.f end+t1.f*t1.c)/abs(a)))/abs(17)) when 19 then d else t1.d end then 17 when not exists(select 1 from t1 where t1.e not in (t1.b,t1.b,b) or a between a and 17) then 11 else b end) & t1.e FROM t1 WHERE NOT (17>=e)}\n} {16}\ndo_test randexpr-2.1844 {\n  db eval {SELECT (abs(11 | t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE t1.f<>17}\n} {5}\ndo_test randexpr-2.1845 {\n  db eval {SELECT (abs(11 | t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE NOT (t1.f<>17)}\n} {}\ndo_test randexpr-2.1846 {\n  db eval {SELECT (abs(11 & t1.e)/abs(case 13 when 17*+t1.a+d*+d then ~ -17*+ - -case f when b then a-b else t1.d end-f+t1.f+17 else t1.a end)) FROM t1 WHERE t1.f<>17}\n} {0}\ndo_test randexpr-2.1847 {\n  db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) | case 11 when t1.d then 11 else (t1.a) end | t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE t1.d-t1.c>=13}\n} {300}\ndo_test randexpr-2.1848 {\n  db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) | case 11 when t1.d then 11 else (t1.a) end | t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE NOT (t1.d-t1.c>=13)}\n} {}\ndo_test randexpr-2.1849 {\n  db eval {SELECT case when not coalesce((select max(case 11 when case d when coalesce((select f from t1 where case when (t1.d) & case 11 when t1.d then 11 else (t1.a) end & t1.b in (e,c,(11)) then 17 when c between e and f then t1.e else t1.a end>t1.e),t1.d) then 13 else c end then c else c end) from t1 where t1.e not between (a) and (t1.d)),c) not in ((11),((19)),a) then (t1.c) else (c) end FROM t1 WHERE t1.d-t1.c>=13}\n} {300}\ndo_test randexpr-2.1850 {\n  db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a | e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case  -(case  -cast(avg(t1.b) AS integer) when  -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when  -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE t1.e=t1.d}\n} {}\ndo_test randexpr-2.1851 {\n  db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a | e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case  -(case  -cast(avg(t1.b) AS integer) when  -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when  -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE NOT (t1.e=t1.d)}\n} {-701}\ndo_test randexpr-2.1852 {\n  db eval {SELECT (select case count(distinct ~case when (abs(coalesce((select t1.e from t1 where (not exists(select 1 from t1 where a & e between c and coalesce((select (t1.d) from t1 where (t1.a=t1.a)), -(c))))),b+19))/abs(d))>11 then b else t1.d end) when count(distinct 17) then ~min((t1.d))-case  -(case  -cast(avg(t1.b) AS integer) when  -max(13) then (min(t1.d)) else count(distinct t1.b) end+(min(t1.e)))*(cast(avg( -17) AS integer)) when  -count(distinct 19) then count(*) else max(t1.c) end else count(distinct f) end from t1) FROM t1 WHERE NOT (t1.e=t1.d)}\n} {-701}\ndo_test randexpr-2.1853 {\n  db eval {SELECT case when t1.d<>t1.a and a-t1.b-c in (13,t1.e-(abs(d)/abs(coalesce((select max(e) from t1 where 19 not between  -b and 17),b))),t1.b) or (not exists(select 1 from t1 where t1.f not between  -17 and a)) then case when e>t1.e then t1.d when t1.c<d or (19<=13) then (13) else b end+t1.e when c<=a then t1.d else f end+17 FROM t1 WHERE (t1.d)-case when not exists(select 1 from t1 where c<>f-11 and not not b<coalesce((select max(a) from t1 where (select cast(avg(case t1.a*19 when (select abs(cast(avg(c) AS integer)+(count(*))) from t1) | t1.f+11* -b then ((e)) else t1.a end) AS integer) from t1)-t1.f in (a,a,e)),19)) then 13*e else t1.b end not between 13 and t1.c}\n} {617}\ndo_test randexpr-2.1854 {\n  db eval {SELECT case when t1.d<>t1.a and a-t1.b-c in (13,t1.e-(abs(d)/abs(coalesce((select max(e) from t1 where 19 not between  -b and 17),b))),t1.b) or (not exists(select 1 from t1 where t1.f not between  -17 and a)) then case when e>t1.e then t1.d when t1.c<d or (19<=13) then (13) else b end+t1.e when c<=a then t1.d else f end+17 FROM t1 WHERE NOT ((t1.d)-case when not exists(select 1 from t1 where c<>f-11 and not not b<coalesce((select max(a) from t1 where (select cast(avg(case t1.a*19 when (select abs(cast(avg(c) AS integer)+(count(*))) from t1) | t1.f+11* -b then ((e)) else t1.a end) AS integer) from t1)-t1.f in (a,a,e)),19)) then 13*e else t1.b end not between 13 and t1.c)}\n} {}\ndo_test randexpr-2.1855 {\n  db eval {SELECT ~case 17 when t1.c then coalesce((select max((case when not exists(select 1 from t1 where 11<>coalesce((select d from t1 where not exists(select 1 from t1 where c*b in (t1.b*t1.d,t1.c,b) or c between d and a)),19)-t1.c*e) then coalesce((select f from t1 where 11 in (select c from t1 union select b from t1)),(c)) when 17<>t1.b then d else 19 end)) from t1 where f in (a,t1.f,t1.d)),(19)) else t1.e end FROM t1 WHERE not not exists(select 1 from t1 where (select abs(min(19-19))*count(*) | min(13)*min((a))+cast(avg(t1.e) AS integer)+(cast(avg(19) AS integer)) from t1) in (17,+(select min(b) from t1),(select cast(avg(f) AS integer) from t1)) and 11 in (select ( -(min(c))) from t1 union select (min(13)) from t1)) or t1.d between c and  -(f) or not t1.c in (select min(e) from t1 union select  -(max(e)) from t1) and t1.e in (t1.f,a,11) and f not between a and 17 and 19<=17 and 13 not in (b,t1.b,13)}\n} {}\ndo_test randexpr-2.1856 {\n  db eval {SELECT ~case 17 when t1.c then coalesce((select max((case when not exists(select 1 from t1 where 11<>coalesce((select d from t1 where not exists(select 1 from t1 where c*b in (t1.b*t1.d,t1.c,b) or c between d and a)),19)-t1.c*e) then coalesce((select f from t1 where 11 in (select c from t1 union select b from t1)),(c)) when 17<>t1.b then d else 19 end)) from t1 where f in (a,t1.f,t1.d)),(19)) else t1.e end FROM t1 WHERE NOT (not not exists(select 1 from t1 where (select abs(min(19-19))*count(*) | min(13)*min((a))+cast(avg(t1.e) AS integer)+(cast(avg(19) AS integer)) from t1) in (17,+(select min(b) from t1),(select cast(avg(f) AS integer) from t1)) and 11 in (select ( -(min(c))) from t1 union select (min(13)) from t1)) or t1.d between c and  -(f) or not t1.c in (select min(e) from t1 union select  -(max(e)) from t1) and t1.e in (t1.f,a,11) and f not between a and 17 and 19<=17 and 13 not in (b,t1.b,13))}\n} {-501}\ndo_test randexpr-2.1857 {\n  db eval {SELECT coalesce((select +f+coalesce((select case when b- -f*t1.d-t1.a>d and t1.e in (select b from t1 union select t1.d from t1) then 11 else  -a end from t1 where (not (t1.f) not between 13 and t1.f)),11) from t1 where t1.c<=c and (d) between 11 and t1.b or b in (select d from t1 union select t1.e from t1) and 19<>t1.e or 19 not between a and a),19) FROM t1 WHERE t1.e<>(select cast(avg((b)*(select abs( -max(t1.f)) from t1)) AS integer) from t1)}\n} {500}\ndo_test randexpr-2.1858 {\n  db eval {SELECT coalesce((select +f+coalesce((select case when b- -f*t1.d-t1.a>d and t1.e in (select b from t1 union select t1.d from t1) then 11 else  -a end from t1 where (not (t1.f) not between 13 and t1.f)),11) from t1 where t1.c<=c and (d) between 11 and t1.b or b in (select d from t1 union select t1.e from t1) and 19<>t1.e or 19 not between a and a),19) FROM t1 WHERE NOT (t1.e<>(select cast(avg((b)*(select abs( -max(t1.f)) from t1)) AS integer) from t1))}\n} {}\ndo_test randexpr-2.1859 {\n  db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else  -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) | ~(~ -count(distinct  -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) | t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a}\n} {}\ndo_test randexpr-2.1860 {\n  db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else  -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) | ~(~ -count(distinct  -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) | t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE NOT (b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a)}\n} {300}\ndo_test randexpr-2.1861 {\n  db eval {SELECT coalesce((select max(coalesce((select (t1.f) from t1 where f in (select t1.f+(select case count(distinct 19) when count(*) then max(t1.d) else  -count(*) end from t1) from t1 union select 13 from t1)),c)) from t1 where not exists(select 1 from t1 where coalesce((select (select +count(*) & ~(~ -count(distinct  -13)) from t1) from t1 where case when d*~f-13<>((d)) then 19 else t1.a end not between d and t1.e),t1.f) & t1.d in (select t1.d from t1 union select t1.d from t1))),13) FROM t1 WHERE NOT (b= -~case f-t1.a | ~case coalesce((select max(t1.b) from t1 where b>t1.e or t1.d=17-(abs(coalesce((select 17 from t1 where 17 between c and c),a)-c+a)/abs(t1.f))-c and d not in (17,19,c)),c) when 11 then e else t1.d end | t1.c-d when t1.c then c else e end | a)}\n} {300}\ndo_test randexpr-2.1862 {\n  db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 | (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE t1.f in (select 19 from t1 union select  -17*11+t1.d from t1)}\n} {}\ndo_test randexpr-2.1863 {\n  db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 | (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE NOT (t1.f in (select 19 from t1 union select  -17*11+t1.d from t1))}\n} {400}\ndo_test randexpr-2.1864 {\n  db eval {SELECT coalesce((select max(( -17-case when t1.c-13<+11 & (t1.a)-e then 13*t1.a when coalesce((select 11 from t1 where t1.a>t1.c),17)+f+t1.a not between 13 and e then t1.f else c end)) from t1 where exists(select 1 from t1 where (19>=t1.f)) and f in (select max(13) from t1 union select count(*) from t1) and (19)>=t1.f),d) FROM t1 WHERE NOT (t1.f in (select 19 from t1 union select  -17*11+t1.d from t1))}\n} {400}\ndo_test randexpr-2.1865 {\n  db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) | t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or  -t1.e>b}\n} {}\ndo_test randexpr-2.1866 {\n  db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) | t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE NOT (b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or  -t1.e>b)}\n} {4000}\ndo_test randexpr-2.1867 {\n  db eval {SELECT (t1.a)+c*case when not b in (select 11 from t1 union select 13 from t1) and a=case when not exists(select 1 from t1 where exists(select 1 from t1 where ~+( -(17)) & t1.d>=b)) then case t1.d when c then 19 else t1.c end*a else d end-a then e when b not between f and d and t1.b>=11 or not (t1.e>=b) and 11<=17 then 13 else t1.d end FROM t1 WHERE NOT (b in (e | 19,t1.c,case 17 when 19 then +(case when 19> -coalesce((select max(a) from t1 where t1.a not in (case e when t1.d then (c)-c else 11 end | (11)-c*t1.f,e,t1.f)),13) then t1.e else t1.e end)*e else 13 end-19+ - -t1.d* -b) or  -t1.e>b)}\n} {4000}\ndo_test randexpr-2.1868 {\n  db eval {SELECT case when b | case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then  -b else a end-a in (select max(t1.c) from t1 union select min(e) | count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE +~+13>=t1.c}\n} {}\ndo_test randexpr-2.1869 {\n  db eval {SELECT case when b | case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then  -b else a end-a in (select max(t1.c) from t1 union select min(e) | count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE NOT (+~+13>=t1.c)}\n} {-187}\ndo_test randexpr-2.1870 {\n  db eval {SELECT case when b & case when 13 between ~coalesce((select 19 from t1 where b in (select max(a*17) from t1 union select cast(avg( -19) AS integer)+abs(cast(avg(a) AS integer)) from t1)),17) and 11 then a when not exists(select 1 from t1 where not exists(select 1 from t1 where 19<=e)) and d in (select 17 from t1 union select 17 from t1) then  -b else a end-a in (select max(t1.c) from t1 union select min(e) & count(*)+count(*) from t1) then t1.b when not (not 19<=t1.b) then 13 else a end-b FROM t1 WHERE NOT (+~+13>=t1.c)}\n} {0}\ndo_test randexpr-2.1871 {\n  db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c | +t1.e) FROM t1 WHERE a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select  -( -count(distinct (a))) |  -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c)}\n} {}\ndo_test randexpr-2.1872 {\n  db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c | +t1.e) FROM t1 WHERE NOT (a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select  -( -count(distinct (a))) |  -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c))}\n} {13}\ndo_test randexpr-2.1873 {\n  db eval {SELECT coalesce((select case when t1.d in (select min(f) from t1 union select ~ -count(*) from t1) then d else 13 end from t1 where 19<=case when 13>=+17-c+(select count(*)-min(11) from t1)+t1.f*t1.e*c*t1.d then c else t1.b end),t1.c & +t1.e) FROM t1 WHERE NOT (a between (abs(coalesce((select max(case when (t1.d+a*coalesce((select d-13 from t1 where a<=19),t1.f))>= -c then c else 13 end) from t1 where f>=d or t1.a>t1.d),t1.a))/abs(t1.f)) and 19 and 13=t1.e and not exists(select 1 from t1 where 13 in (select  -( -count(distinct (a))) |  -cast(avg(t1.c) AS integer) from t1 union select (min(t1.c)) from t1) or t1.f not between t1.c and t1.c))}\n} {13}\ndo_test randexpr-2.1874 {\n  db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and  - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) | c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE (~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d}\n} {600}\ndo_test randexpr-2.1875 {\n  db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and  - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) | c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE NOT ((~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d)}\n} {}\ndo_test randexpr-2.1876 {\n  db eval {SELECT coalesce((select max(f) from t1 where coalesce((select max(+(select cast(avg(t1.d) AS integer) from t1)*19) from t1 where (abs(t1.d*t1.c)/abs(f))+t1.e> -t1.d*t1.e-a),13-case +coalesce((select max(t1.c) from t1 where d<=d and  - -t1.a<=(t1.f) or f<>19 and 17<19),(t1.c)) & c*t1.f*b when t1.a then 19 else (b) end)>=a),t1.f) FROM t1 WHERE (~c-13*case when case when a+19-c in (select case count(distinct c)-case cast(avg(t1.a) AS integer) when max( -b) then cast(avg(t1.f) AS integer) else cast(avg((t1.d)) AS integer) end when min(b) then cast(avg(b) AS integer) else count(*) end from t1 union select max(t1.f) from t1) and 17 between (t1.b) and c and 19>t1.d or 19 in (t1.f,t1.a,(b)) then a else t1.e end in (13,t1.a,b) then 17 else t1.e end*t1.d+a+t1.b+t1.f)<t1.d}\n} {600}\ndo_test randexpr-2.1877 {\n  db eval {SELECT a | t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e | 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d}\n} {-268}\ndo_test randexpr-2.1878 {\n  db eval {SELECT a | t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e | 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE NOT (t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d)}\n} {}\ndo_test randexpr-2.1879 {\n  db eval {SELECT a & t1.c-case t1.b when case when f< -(c*case when f<13 then t1.e & 13-coalesce((select max( -13+13+t1.a) from t1 where not exists(select 1 from t1 where 17=11)),19) else a end+t1.e*t1.d)+11+(13) then t1.f when not t1.f> -b then a else f end then t1.e else f end FROM t1 WHERE t1.f-~coalesce((select 17 from t1 where (e+ -case when (d<coalesce((select max(a) from t1 where a | a<t1.a and t1.c<=17 or t1.d not between a and b),13)) then 17*t1.d else t1.f end in (select ~~~cast(avg(f) AS integer)*max(t1.c)-count(distinct t1.e)-( -min(t1.f))+( -count(*)) from t1 union select max(a) from t1))),13)*t1.c-t1.d not between 17 and d}\n} {68}\ndo_test randexpr-2.1880 {\n  db eval {SELECT  -(17-case (select max(a)+min( -(abs(t1.c-t1.a | t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct  -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select  -count(distinct b)*count(*) from t1 union select count(distinct  -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else  -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a}\n} {}\ndo_test randexpr-2.1881 {\n  db eval {SELECT  -(17-case (select max(a)+min( -(abs(t1.c-t1.a | t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct  -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE NOT (f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select  -count(distinct b)*count(*) from t1 union select count(distinct  -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else  -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a)}\n} {7683}\ndo_test randexpr-2.1882 {\n  db eval {SELECT  -(17-case (select max(a)+min( -(abs(t1.c-t1.a & t1.e- -t1.b+19*t1.c)/abs(c)))+ -case min(a) when count(distinct  -a) then count(distinct 19) else count(*) end-count(distinct t1.e)*(max(t1.a))-(count(distinct 19)) from t1) when (select count(*) from t1) then b else t1.d end*11)-11* -c FROM t1 WHERE NOT (f between (case case when +(f) in (select t1.f from t1 union select case when t1.b in ((abs(19)/abs(11)),f,c) and (d) in (select  -count(distinct b)*count(*) from t1 union select count(distinct  -13) from t1) or (t1.e>19) then case when f in (11,11,d) then t1.e when t1.a<=19 then a else e end else  -t1.e end from t1) then e when t1.c=t1.b then 19 else e end when f then 19 else c end) | d-c and a)}\n} {7683}\ndo_test randexpr-2.1883 {\n  db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f | e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then  -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f}\n} {500}\ndo_test randexpr-2.1884 {\n  db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f | e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then  -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE NOT (a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f)}\n} {}\ndo_test randexpr-2.1885 {\n  db eval {SELECT (case coalesce((select +a from t1 where exists(select 1 from t1 where t1.e not between t1.f-b and (select count(*) from t1)-t1.f & e)),t1.d+case when t1.b not between t1.d and 17+case when a in (t1.d,a,(abs(~case when (t1.f)<=t1.c then  -17 else t1.f end)/abs(19))*d*t1.d) then (b) else a end then 11 else f end+(t1.a)) when f then 17 else t1.e end) FROM t1 WHERE a-e*case t1.d+case c when (abs(~t1.d*(select min(case when not exists(select 1 from t1 where ((d)+(19) between 11 and 19)) then 11+13 when e not in (t1.f,17,e) and t1.c<>a then t1.e else 19 end*t1.a-f) from t1))/abs(b)) then 13 else 17 end when t1.f then (f) else t1.c end<b and 19 between t1.a and t1.a or d<f}\n} {500}\ndo_test randexpr-2.1886 {\n  db eval {SELECT  -19 | t1.c*coalesce((select max(+(select cast(avg(case when  -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select  -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c}\n} {-19}\ndo_test randexpr-2.1887 {\n  db eval {SELECT  -19 | t1.c*coalesce((select max(+(select cast(avg(case when  -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE NOT (case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select  -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c)}\n} {}\ndo_test randexpr-2.1888 {\n  db eval {SELECT  -19 & t1.c*coalesce((select max(+(select cast(avg(case when  -e+t1.d in (select t1.e*a from t1 union select a from t1) then t1.b when 17 in (select t1.a from t1 union select 11 from t1) then 19 else 11 end-19+a+t1.f) AS integer)+count(distinct t1.a) from t1)+(t1.b)) from t1 where (19) not in (17,d,a)),t1.a)*t1.b*19* -11 FROM t1 WHERE case t1.e when f then (select ~count(distinct a) | abs((count(distinct d*f+d+t1.b+17+~t1.f))) from t1) else coalesce((select e from t1 where t1.f not between 17+t1.f+19 and (abs(f)/abs(t1.f))*~t1.b*(b)),coalesce((select t1.b from t1 where 19 in (select count(distinct (t1.d)) from t1 union select  -count(distinct a) from t1)),19)) | 17 end not between t1.c and t1.c}\n} {-11198220000}\ndo_test randexpr-2.1889 {\n  db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 | ~coalesce((select e from t1 where t1.b>(13) |  -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c)}\n} {}\ndo_test randexpr-2.1890 {\n  db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 | ~coalesce((select e from t1 where t1.b>(13) |  -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE NOT (not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c))}\n} {500}\ndo_test randexpr-2.1891 {\n  db eval {SELECT (abs(b)/abs((select max(c) from t1)))+case when (select +cast(avg(17 & ~coalesce((select e from t1 where t1.b>(13) &  -11 and c>f),19)+t1.c) AS integer)-(~case cast(avg(t1.f) AS integer)*abs(max(b)+(count(*))+count(distinct b)) when min(c) then cast(avg(t1.b) AS integer) else count(*) end) from t1) in (select t1.e from t1 union select t1.c from t1) then f when d<t1.e then t1.e else 19 end FROM t1 WHERE NOT (not ( -a*(select case min(coalesce((select max(a) from t1 where case when 11 between t1.c and d then c when t1.c not in (t1.a,e,t1.c) then d else 13 end*d>=(c)),b)) when max(d) then ( -max(c))+((min(11)))+max(t1.c) else max(t1.a) end from t1)-e+t1.b-(b)-11-t1.d*t1.c<>t1.c))}\n} {500}\ndo_test randexpr-2.1892 {\n  db eval {SELECT coalesce((select max(case 13 when +coalesce((select max(c) from t1 where t1.a+f in (t1.b,t1.b,(abs(19)/abs(+17+~(abs(t1.a+f)/abs(~t1.c))+case when not exists(select 1 from t1 where coalesce((select max(e) from t1 where (b)> -t1.a),c)=t1.b) then 19 else b end))-f)),t1.a)+a then f else 17 end*t1.e) from t1 where 13<>t1.f),t1.f) FROM t1 WHERE not exists(select 1 from t1 where coalesce((select max(case when 13 not in (t1.b,b,t1.c) then t1.c | t1.a else 13-19+a+t1.e-t1.e end+t1.a*17+( -d)-17 | t1.c-t1.a | 19+b) from t1 where not a=e),11) in (select 17 from t1 union select c from t1) or t1.c>=t1.e)}\n} {8500}\ndo_test randexpr-2.1893 {\n  db eval {SELECT coalesce((select max(case 13 when +coalesce((select max(c) from t1 where t1.a+f in (t1.b,t1.b,(abs(19)/abs(+17+~(abs(t1.a+f)/abs(~t1.c))+case when not exists(select 1 from t1 where coalesce((select max(e) from t1 where (b)> -t1.a),c)=t1.b) then 19 else b end))-f)),t1.a)+a then f else 17 end*t1.e) from t1 where 13<>t1.f),t1.f) FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select max(case when 13 not in (t1.b,b,t1.c) then t1.c | t1.a else 13-19+a+t1.e-t1.e end+t1.a*17+( -d)-17 | t1.c-t1.a | 19+b) from t1 where not a=e),11) in (select 17 from t1 union select c from t1) or t1.c>=t1.e))}\n} {}\ndo_test randexpr-2.1894 {\n  db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 | coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then  -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select  -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c))))}\n} {-1709400}\ndo_test randexpr-2.1895 {\n  db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 | coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE NOT (not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then  -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select  -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c)))))}\n} {}\ndo_test randexpr-2.1896 {\n  db eval {SELECT t1.f++c*coalesce((select +t1.f from t1 where a<~13),case when exists(select 1 from t1 where not exists(select 1 from t1 where 17 in (select 11 from t1 union select (17) from t1))) then b else + -19 & coalesce((select case when (select cast(avg(a) AS integer) from t1)>e then case when (11=(e) and 17<f) then (e)+ -c else e end else c end from t1 where 13 not in (f,t1.b,e)),t1.d) end*t1.c) FROM t1 WHERE not exists(select 1 from t1 where exists(select 1 from t1 where t1.e=+(abs((coalesce((select max( -a | case when coalesce((select c from t1 where not 17 not between t1.e and t1.b),e)-(a) not between t1.e and t1.b then f when c>=t1.a then  -c else 19 end-f) from t1 where not exists(select 1 from t1 where d in (select  -~count(distinct 11)+max(t1.a) from t1 union select count(distinct e)* -count(distinct t1.b) from t1)) or (c<t1.c)),t1.f)))/abs(t1.c))))}\n} {27000600}\ndo_test randexpr-2.1897 {\n  db eval {SELECT (select + -min(case when case when exists(select 1 from t1 where a<=c or coalesce((select max(11) from t1 where d=17),19)*11<=f and t1.e in (select t1.c from t1 union select a from t1)) then (f)-d when a<t1.a then t1.b else a end in (select ~( -min(f)) from t1 union select case  -max(t1.d)-count(distinct t1.c) when min(f) then cast(avg( -e) AS integer) else ( -count(distinct 17)) end from t1) then d when t1.f>=t1.c then f else t1.f end-f) from t1) FROM t1 WHERE (~ -t1.c in (select d from t1 union select t1.c*case when (17 in (+case c when t1.f then t1.c else c+e+t1.c*e+coalesce((select max((c)) from t1 where (t1.e)>a),19)-t1.e end | e-t1.b,t1.d,c)) then d when t1.e in (select (max( -e)-~~count(*)) from t1 union select count(*) from t1) then d else t1.f end from t1))}\n} {}\ndo_test randexpr-2.1898 {\n  db eval {SELECT (select + -min(case when case when exists(select 1 from t1 where a<=c or coalesce((select max(11) from t1 where d=17),19)*11<=f and t1.e in (select t1.c from t1 union select a from t1)) then (f)-d when a<t1.a then t1.b else a end in (select ~( -min(f)) from t1 union select case  -max(t1.d)-count(distinct t1.c) when min(f) then cast(avg( -e) AS integer) else ( -count(distinct 17)) end from t1) then d when t1.f>=t1.c then f else t1.f end-f) from t1) FROM t1 WHERE NOT ((~ -t1.c in (select d from t1 union select t1.c*case when (17 in (+case c when t1.f then t1.c else c+e+t1.c*e+coalesce((select max((c)) from t1 where (t1.e)>a),19)-t1.e end | e-t1.b,t1.d,c)) then d when t1.e in (select (max( -e)-~~count(*)) from t1 union select count(*) from t1) then d else t1.f end from t1)))}\n} {0}\ndo_test randexpr-2.1899 {\n  db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b | +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE (exists(select 1 from t1 where  -t1.f not between ~17 and t1.a+(b+d+13)))}\n} {-1101}\ndo_test randexpr-2.1900 {\n  db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b | +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE NOT ((exists(select 1 from t1 where  -t1.f not between ~17 and t1.a+(b+d+13))))}\n} {}\ndo_test randexpr-2.1901 {\n  db eval {SELECT ~+t1.f-coalesce((select t1.f from t1 where case when t1.d>=t1.f then b else case c when 11 then t1.f*case when (select (count(*)) from t1)<>a+t1.b & +11-coalesce((select max(t1.f-a) from t1 where (f<=t1.c and t1.d=c)),d)-11 then b when (t1.c)<=t1.b then 19 else 11 end else c end end*19-13< - -b),e) FROM t1 WHERE (exists(select 1 from t1 where  -t1.f not between ~17 and t1.a+(b+d+13)))}\n} {-1101}\ndo_test randexpr-2.1902 {\n  db eval {SELECT  -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select  -17 from t1) then 19 when 17<c then t1.b else c end | t1.e) from t1 where exists(select 1 from t1 where  -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE ((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where  -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then  -13 else 17 end) | d in (a,d,13))}\n} {}\ndo_test randexpr-2.1903 {\n  db eval {SELECT  -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select  -17 from t1) then 19 when 17<c then t1.b else c end | t1.e) from t1 where exists(select 1 from t1 where  -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE NOT (((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where  -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then  -13 else 17 end) | d in (a,d,13)))}\n} {-100}\ndo_test randexpr-2.1904 {\n  db eval {SELECT  -t1.e+coalesce((select (d) from t1 where t1.f=t1.f*(select +count(distinct case when (coalesce((select max(case when a in (select b+17 from t1 union select  -17 from t1) then 19 when 17<c then t1.b else c end & t1.e) from t1 where exists(select 1 from t1 where  -e in (t1.b,t1.d,c) and f not between t1.f and b) and 17<>a),e)<>f or d not between (e) and b) then 11 else (abs(13)/abs( -(d))) end*t1.c) from t1)),e-f) FROM t1 WHERE NOT (((case when t1.e+d*~coalesce((select coalesce((select max(b) from t1 where ~case when t1.f not between t1.c and coalesce((select t1.b from t1 where  -t1.e in (select (( - -min(19))) from t1 union select count(distinct t1.d) from t1)),t1.d) then c when t1.f=e then t1.f else b end=13),13) from t1 where t1.e not between 13 and 11 or not exists(select 1 from t1 where t1.a not between (11) and d and 11>=a)),t1.f) in (select count(*) from t1 union select ~max( -13) from t1) then  -13 else 17 end) | d in (a,d,13)))}\n} {-100}\ndo_test randexpr-2.1905 {\n  db eval {SELECT coalesce((select max((19)) from t1 where d* -a<=(select count(*) from t1)+19*19*a-e-d or b in (t1.c+ -t1.b,t1.a,b+t1.b)),d) FROM t1 WHERE exists(select 1 from t1 where exists(select 1 from t1 where not t1.e>e))}\n} {19}\ndo_test randexpr-2.1906 {\n  db eval {SELECT coalesce((select max((19)) from t1 where d* -a<=(select count(*) from t1)+19*19*a-e-d or b in (t1.c+ -t1.b,t1.a,b+t1.b)),d) FROM t1 WHERE NOT (exists(select 1 from t1 where exists(select 1 from t1 where not t1.e>e)))}\n} {}\ndo_test randexpr-2.1907 {\n  db eval {SELECT (select  -~count(distinct (abs(11)/abs(f-17-+(select cast(avg(+(select count(*) from t1)) AS integer) from t1)))) from t1) FROM t1 WHERE (abs((a))/abs(t1.b))>(select count(distinct case case when 17 in (select  -b-case when 17 in (select +(( - -max(t1.b))) from t1 union select max((t1.b)) from t1) then f when t1.e=(t1.d) then 17 else e end | e-t1.d | t1.c* -13*d*t1.b from t1 union select 11 from t1) then c when c>=a then 13 else 13 end+t1.b when  -f then 19 else 13 end)*min(t1.f) from t1)-19-f}\n} {2}\ndo_test randexpr-2.1908 {\n  db eval {SELECT (select  -~count(distinct (abs(11)/abs(f-17-+(select cast(avg(+(select count(*) from t1)) AS integer) from t1)))) from t1) FROM t1 WHERE NOT ((abs((a))/abs(t1.b))>(select count(distinct case case when 17 in (select  -b-case when 17 in (select +(( - -max(t1.b))) from t1 union select max((t1.b)) from t1) then f when t1.e=(t1.d) then 17 else e end | e-t1.d | t1.c* -13*d*t1.b from t1 union select 11 from t1) then c when c>=a then 13 else 13 end+t1.b when  -f then 19 else 13 end)*min(t1.f) from t1)-19-f)}\n} {}\ndo_test randexpr-2.1909 {\n  db eval {SELECT  -(select cast(avg(coalesce((select max(f) from t1 where  -case coalesce((select max(~c-case when exists(select 1 from t1 where  -b in (~e,t1.e,t1.e)) then t1.e when (17 in (select ++ -(count(distinct t1.a)) from t1 union select (max( -f)) from t1)) then b else t1.f end) from t1 where (13 in (19,b,11))),t1.e) when c then (b) else 11 end-a*b*13=t1.e),13)) AS integer) from t1) FROM t1 WHERE exists(select 1 from t1 where case when not (case when ~17*d>=b then a when c*(abs((abs(f)/abs(t1.c)))/abs(t1.b))+d*t1.b<19 and not case 13 when a then 11 else  -t1.e end<>f then 11 else c end+t1.d) not in (t1.c,t1.f,d) then (abs(c)/abs(t1.f)) else t1.a end*t1.f not between t1.d and c)}\n} {-13}\ndo_test randexpr-2.1910 {\n  db eval {SELECT  -(select cast(avg(coalesce((select max(f) from t1 where  -case coalesce((select max(~c-case when exists(select 1 from t1 where  -b in (~e,t1.e,t1.e)) then t1.e when (17 in (select ++ -(count(distinct t1.a)) from t1 union select (max( -f)) from t1)) then b else t1.f end) from t1 where (13 in (19,b,11))),t1.e) when c then (b) else 11 end-a*b*13=t1.e),13)) AS integer) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when not (case when ~17*d>=b then a when c*(abs((abs(f)/abs(t1.c)))/abs(t1.b))+d*t1.b<19 and not case 13 when a then 11 else  -t1.e end<>f then 11 else c end+t1.d) not in (t1.c,t1.f,d) then (abs(c)/abs(t1.f)) else t1.a end*t1.f not between t1.d and c))}\n} {}\ndo_test randexpr-2.1911 {\n  db eval {SELECT case t1.c when (select abs( -max(t1.a*t1.f*t1.a*e)) from t1)*case when not exists(select 1 from t1 where (select cast(avg(c) AS integer) from t1) in (select case case when ( -case t1.f when 17 then t1.c else e end=17) then 19 else e end when e then c else  -a end*t1.d from t1 union select d from t1)) then e*t1.a else b end+e*t1.d+t1.b then t1.d else c end+t1.e FROM t1 WHERE 13 in (select +abs(case count(distinct t1.e+(abs((abs(coalesce((select t1.b from t1 where coalesce((select max(case when (19<=t1.d) then (13) when a>=13 then 13 else t1.f end) from t1 where a in (t1.c,19,t1.b)),19)>13),d))/abs(f))+t1.a*t1.b)/abs(e))) when +cast(avg(c) AS integer) then ~~+max(f) | cast(avg(t1.c) AS integer) else count(distinct 13)+min(t1.b) | count(*) end)*max(t1.d)-count(*) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.1912 {\n  db eval {SELECT case t1.c when (select abs( -max(t1.a*t1.f*t1.a*e)) from t1)*case when not exists(select 1 from t1 where (select cast(avg(c) AS integer) from t1) in (select case case when ( -case t1.f when 17 then t1.c else e end=17) then 19 else e end when e then c else  -a end*t1.d from t1 union select d from t1)) then e*t1.a else b end+e*t1.d+t1.b then t1.d else c end+t1.e FROM t1 WHERE NOT (13 in (select +abs(case count(distinct t1.e+(abs((abs(coalesce((select t1.b from t1 where coalesce((select max(case when (19<=t1.d) then (13) when a>=13 then 13 else t1.f end) from t1 where a in (t1.c,19,t1.b)),19)>13),d))/abs(f))+t1.a*t1.b)/abs(e))) when +cast(avg(c) AS integer) then ~~+max(f) | cast(avg(t1.c) AS integer) else count(distinct 13)+min(t1.b) | count(*) end)*max(t1.d)-count(*) from t1 union select count(*) from t1))}\n} {800}\ndo_test randexpr-2.1913 {\n  db eval {SELECT case when f in (d, -case when (case 11 when (select max(t1.d) from t1) then (abs(a)/abs(+t1.b)) else ~b end<19) then (abs( -(abs(17)/abs(t1.f)))/abs((select count(*) from t1))) when (f) not between coalesce((select 13 from t1 where t1.a<=case t1.a when 13 then  -t1.c else 13 end and 13 not between t1.f and 11),11) and 19 then e else b end,t1.d) then b else t1.b end FROM t1 WHERE t1.f between f and a-c-t1.d-t1.d+t1.d*case when exists(select 1 from t1 where d between (select ~cast(avg(17) AS integer) from t1) and a) then case when case b when f then 13 else b end<c then t1.d when (t1.a) in (select  -( -b) from t1 union select  -t1.f from t1) and f not in (t1.b,t1.d,t1.a) then  -d else (13) end when d in (c,((t1.d)),c) then b else 19 end and exists(select 1 from t1 where not t1.a=17)}\n} {200}\ndo_test randexpr-2.1914 {\n  db eval {SELECT case when f in (d, -case when (case 11 when (select max(t1.d) from t1) then (abs(a)/abs(+t1.b)) else ~b end<19) then (abs( -(abs(17)/abs(t1.f)))/abs((select count(*) from t1))) when (f) not between coalesce((select 13 from t1 where t1.a<=case t1.a when 13 then  -t1.c else 13 end and 13 not between t1.f and 11),11) and 19 then e else b end,t1.d) then b else t1.b end FROM t1 WHERE NOT (t1.f between f and a-c-t1.d-t1.d+t1.d*case when exists(select 1 from t1 where d between (select ~cast(avg(17) AS integer) from t1) and a) then case when case b when f then 13 else b end<c then t1.d when (t1.a) in (select  -( -b) from t1 union select  -t1.f from t1) and f not in (t1.b,t1.d,t1.a) then  -d else (13) end when d in (c,((t1.d)),c) then b else 19 end and exists(select 1 from t1 where not t1.a=17))}\n} {}\ndo_test randexpr-2.1915 {\n  db eval {SELECT (abs(case when 11<=case 17 when t1.d then t1.b+~19-~case when not t1.b not in (t1.a,b,coalesce((select a+(a) from t1 where t1.b>19),t1.b)) or ((t1.a>19)) or e<>19 then  -t1.e else  -13 end-b+t1.d else a end then 19 when d between b and t1.c then t1.e else e end)/abs(t1.a)) FROM t1 WHERE b | t1.b>b-case when a-f in (select 17 from t1 union select coalesce((select coalesce((select t1.e+t1.a+d+d from t1 where 13 not between t1.e+19 and 13),(select count(distinct t1.e) from t1)*11) from t1 where b not in (b,(t1.f),t1.a)),13) from t1) then b else c end+a-13-13*(13) | 11}\n} {0}\ndo_test randexpr-2.1916 {\n  db eval {SELECT (abs(case when 11<=case 17 when t1.d then t1.b+~19-~case when not t1.b not in (t1.a,b,coalesce((select a+(a) from t1 where t1.b>19),t1.b)) or ((t1.a>19)) or e<>19 then  -t1.e else  -13 end-b+t1.d else a end then 19 when d between b and t1.c then t1.e else e end)/abs(t1.a)) FROM t1 WHERE NOT (b | t1.b>b-case when a-f in (select 17 from t1 union select coalesce((select coalesce((select t1.e+t1.a+d+d from t1 where 13 not between t1.e+19 and 13),(select count(distinct t1.e) from t1)*11) from t1 where b not in (b,(t1.f),t1.a)),13) from t1) then b else c end+a-13-13*(13) | 11)}\n} {}\ndo_test randexpr-2.1917 {\n  db eval {SELECT  -t1.a | coalesce((select t1.f*(select min(f)+min(( -(select  -case (min(13)) when  -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select  - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else  -c end*a*t1.c from t1 union select t1.b from t1)),b) | a FROM t1 WHERE +19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17}\n} {-4}\ndo_test randexpr-2.1918 {\n  db eval {SELECT  -t1.a | coalesce((select t1.f*(select min(f)+min(( -(select  -case (min(13)) when  -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select  - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else  -c end*a*t1.c from t1 union select t1.b from t1)),b) | a FROM t1 WHERE NOT (+19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17)}\n} {}\ndo_test randexpr-2.1919 {\n  db eval {SELECT  -t1.a & coalesce((select t1.f*(select min(f)+min(( -(select  -case (min(13)) when  -abs(min(t1.b)) then count(distinct a) else count(*) end from t1)*(select  - -count(*) from t1)))* -count(*) from t1) from t1 where t1.d in (select case case when t1.a<(f) then c else 19 end when f then b else  -c end*a*t1.c from t1 union select t1.b from t1)),b) & a FROM t1 WHERE +19*case when exists(select 1 from t1 where e<+13 | f or t1.d=19) then t1.a when case when exists(select 1 from t1 where t1.c in (select 11 from t1 union select c from t1)) then 13*t1.e else 19 end<=c and (t1.e between (b) and 13) or 11 not between t1.f and 13 or 17 between b and 13 then t1.e+a else 17 end not between b and d or t1.e not between 13 and 17}\n} {0}\ndo_test randexpr-2.1920 {\n  db eval {SELECT (select  -case +count(distinct case when  -+ -~case when ((t1.e)) not between e and f then e when t1.b between  -11 and t1.b then d else t1.a end*19 in (select t1.f from t1 union select t1.d from t1) then t1.b when a in (select  -19 from t1 union select c from t1) then a else f end) when +~ -(count(*)) then  -( -count(distinct t1.e))-count(distinct c) else max(t1.c) end-count(distinct t1.c)-count(distinct 19)-(max(11)) from t1) FROM t1 WHERE  -~coalesce((select max(19*t1.b) from t1 where t1.d in (select max( -coalesce((select max(t1.c) from t1 where case 13 when f+ -13+t1.b-case 13 when t1.a | (abs(t1.a)/abs(t1.f)) then 11 else f end then f else 17 end in (b,t1.d,(e))),13)) from t1 union select ~~min(b)*abs(cast(avg(b) AS integer)) from t1)),e)*((t1.d))<>t1.d}\n} {-313}\ndo_test randexpr-2.1921 {\n  db eval {SELECT (select  -case +count(distinct case when  -+ -~case when ((t1.e)) not between e and f then e when t1.b between  -11 and t1.b then d else t1.a end*19 in (select t1.f from t1 union select t1.d from t1) then t1.b when a in (select  -19 from t1 union select c from t1) then a else f end) when +~ -(count(*)) then  -( -count(distinct t1.e))-count(distinct c) else max(t1.c) end-count(distinct t1.c)-count(distinct 19)-(max(11)) from t1) FROM t1 WHERE NOT ( -~coalesce((select max(19*t1.b) from t1 where t1.d in (select max( -coalesce((select max(t1.c) from t1 where case 13 when f+ -13+t1.b-case 13 when t1.a | (abs(t1.a)/abs(t1.f)) then 11 else f end then f else 17 end in (b,t1.d,(e))),13)) from t1 union select ~~min(b)*abs(cast(avg(b) AS integer)) from t1)),e)*((t1.d))<>t1.d)}\n} {}\ndo_test randexpr-2.1922 {\n  db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d | (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else  -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) | t1.d)/abs( -(d))) else a end FROM t1 WHERE coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where  -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when  -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c)}\n} {100}\ndo_test randexpr-2.1923 {\n  db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d | (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else  -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) | t1.d)/abs( -(d))) else a end FROM t1 WHERE NOT (coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where  -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when  -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c))}\n} {}\ndo_test randexpr-2.1924 {\n  db eval {SELECT case a when c then (abs((select abs(~(+~~case max(t1.d) when +count(distinct ~d & (select case max(17) when count(*) then count(distinct (t1.c)) else count(distinct 11) end from t1)) then (+cast(avg((17)) AS integer))+count(*) else  -(( - -(cast(avg(c) AS integer)))) end)+count(distinct t1.e)+min(13)) from t1)*+11-((abs(t1.a)/abs(coalesce((select c from t1 where ((t1.f<>d))),(t1.c))))) & t1.d)/abs( -(d))) else a end FROM t1 WHERE coalesce((select max(case t1.a when +t1.e then case when t1.c+(select (max(t1.d))-max(13)+cast(avg(c) AS integer)+min((e)) | max(a) from t1)<= -t1.a | case when not exists(select 1 from t1 where  -t1.d<=t1.a) then t1.f when 11<a then f else t1.f end then b when  -t1.c>=c then a else 13 end | t1.c else t1.a end) from t1 where 19<=e and t1.e between t1.d and 11),13) not in (e,a,c)}\n} {100}\ndo_test randexpr-2.1925 {\n  db eval {SELECT t1.d-+case ~(select ~+~count(distinct case when case when case when 11 not between t1.c and t1.a-e then t1.d else e end*d-(d) between  -13 and e then a else c end in (select b from t1 union select 17 from t1) then a else 13 end)*cast(avg(d) AS integer) from t1) when t1.e then (abs(11)/abs(coalesce((select max(19) from t1 where (a)<>t1.e),19))) else t1.c end+t1.c FROM t1 WHERE 19 not in (t1.a*+case when  -c+~t1.a-t1.c in (t1.a,b*case t1.a | coalesce((select max(coalesce((select 17 from t1 where t1.e>t1.a),t1.d)) from t1 where not 11=19),17) when 11 then t1.d else (f) end*b-t1.a+c, -b) then d when a<>f then a else b end-c,d,t1.b)}\n} {400}\ndo_test randexpr-2.1926 {\n  db eval {SELECT t1.d-+case ~(select ~+~count(distinct case when case when case when 11 not between t1.c and t1.a-e then t1.d else e end*d-(d) between  -13 and e then a else c end in (select b from t1 union select 17 from t1) then a else 13 end)*cast(avg(d) AS integer) from t1) when t1.e then (abs(11)/abs(coalesce((select max(19) from t1 where (a)<>t1.e),19))) else t1.c end+t1.c FROM t1 WHERE NOT (19 not in (t1.a*+case when  -c+~t1.a-t1.c in (t1.a,b*case t1.a | coalesce((select max(coalesce((select 17 from t1 where t1.e>t1.a),t1.d)) from t1 where not 11=19),17) when 11 then t1.d else (f) end*b-t1.a+c, -b) then d when a<>f then a else b end-c,d,t1.b))}\n} {}\ndo_test randexpr-2.1927 {\n  db eval {SELECT case when case (select +min(~ -11+f*~b) | case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then  -d else  -t1.b end FROM t1 WHERE t1.a+b-t1.c*17>=c}\n} {}\ndo_test randexpr-2.1928 {\n  db eval {SELECT case when case (select +min(~ -11+f*~b) | case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then  -d else  -t1.b end FROM t1 WHERE NOT (t1.a+b-t1.c*17>=c)}\n} {-400}\ndo_test randexpr-2.1929 {\n  db eval {SELECT case when case (select +min(~ -11+f*~b) & case abs(cast(avg(t1.f) AS integer))*~min(c) when count(*)+max( -11) then abs(count(*)) else max(13) end from t1) when coalesce((select max(coalesce((select max(19) from t1 where (17>=17)),t1.f)) from t1 where c<b),13) then t1.f else (f) end*t1.f>t1.a then  -d else  -t1.b end FROM t1 WHERE NOT (t1.a+b-t1.c*17>=c)}\n} {-400}\ndo_test randexpr-2.1930 {\n  db eval {SELECT case when ~case when t1.f>11*t1.a then f when case when (t1.c*19<(t1.f)) then (e) when a<t1.f then c else  -e end not in (11,b,19) then t1.a else f end=17 or not t1.a>t1.e and a in (d,t1.c,13) then t1.b when  -17 not between f and d then f else t1.c end FROM t1 WHERE c in (select + -min(case (select count(*) from t1) when t1.a then t1.c else coalesce((select max(b) from t1 where d in (select  -abs(cast(avg(t1.b) AS integer)) | (min(t1.f)) | count(distinct a)+abs(cast(avg(b) AS integer))*( -min(b)) | cast(avg(t1.c) AS integer)*((min(t1.e))) from t1 union select cast(avg(f) AS integer) from t1)),t1.e) | +case b when  -t1.c then (select (count(*)) from t1) else b end | 13 end) from t1 union select min(t1.d) from t1)}\n} {}\ndo_test randexpr-2.1931 {\n  db eval {SELECT case when ~case when t1.f>11*t1.a then f when case when (t1.c*19<(t1.f)) then (e) when a<t1.f then c else  -e end not in (11,b,19) then t1.a else f end=17 or not t1.a>t1.e and a in (d,t1.c,13) then t1.b when  -17 not between f and d then f else t1.c end FROM t1 WHERE NOT (c in (select + -min(case (select count(*) from t1) when t1.a then t1.c else coalesce((select max(b) from t1 where d in (select  -abs(cast(avg(t1.b) AS integer)) | (min(t1.f)) | count(distinct a)+abs(cast(avg(b) AS integer))*( -min(b)) | cast(avg(t1.c) AS integer)*((min(t1.e))) from t1 union select cast(avg(f) AS integer) from t1)),t1.e) | +case b when  -t1.c then (select (count(*)) from t1) else b end | 13 end) from t1 union select min(t1.d) from t1))}\n} {600}\ndo_test randexpr-2.1932 {\n  db eval {SELECT case when (b) between 19 and case when t1.a* -t1.d+t1.a-t1.d-b-a<=d then t1.c when not exists(select 1 from t1 where (13>t1.e) and ((a>a))) and  -(13)>t1.b then t1.d else 11 end or d=e then 13+t1.f when ( -a) not between t1.e and t1.b then (c) else t1.e end+t1.a+17 FROM t1 WHERE (case when a<=f+t1.a | f then t1.c*a-coalesce((select max( -e) from t1 where t1.a=t1.d),b)*d- -f else t1.b end) in (select min(t1.f)+~max(b) | count(distinct t1.d)*+ - -case (count(*)) when +count(distinct e) then count(*) else  -cast(avg(d) AS integer) end from t1 union select count(*) from t1) and d between 11 and t1.a}\n} {}\ndo_test randexpr-2.1933 {\n  db eval {SELECT case when (b) between 19 and case when t1.a* -t1.d+t1.a-t1.d-b-a<=d then t1.c when not exists(select 1 from t1 where (13>t1.e) and ((a>a))) and  -(13)>t1.b then t1.d else 11 end or d=e then 13+t1.f when ( -a) not between t1.e and t1.b then (c) else t1.e end+t1.a+17 FROM t1 WHERE NOT ((case when a<=f+t1.a | f then t1.c*a-coalesce((select max( -e) from t1 where t1.a=t1.d),b)*d- -f else t1.b end) in (select min(t1.f)+~max(b) | count(distinct t1.d)*+ - -case (count(*)) when +count(distinct e) then count(*) else  -cast(avg(d) AS integer) end from t1 union select count(*) from t1) and d between 11 and t1.a)}\n} {730}\ndo_test randexpr-2.1934 {\n  db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 | (17) from t1 union select t1.b from t1) or  -e<t1.d then 11 else a end-t1.b FROM t1 WHERE (e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b}\n} {}\ndo_test randexpr-2.1935 {\n  db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 | (17) from t1 union select t1.b from t1) or  -e<t1.d then 11 else a end-t1.b FROM t1 WHERE NOT ((e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b)}\n} {-3420224}\ndo_test randexpr-2.1936 {\n  db eval {SELECT +f*19*~~ -t1.c-13-case when t1.b in (select +case when not exists(select 1 from t1 where (((abs((abs((select count(*)*(count(distinct t1.d)) from t1))/abs(b)))/abs(e))*(e))>=d)) then f when t1.a=f then b else t1.e end+19 & (17) from t1 union select t1.b from t1) or  -e<t1.d then 11 else a end-t1.b FROM t1 WHERE NOT ((e in (17,t1.b*19+(abs(19)/abs(coalesce((select t1.b+d from t1 where not exists(select 1 from t1 where 19* -t1.c+ -t1.b-~e not between 11-c+b and 11) or e=a),d))),a)) and d<=b or b>e and t1.e<=t1.b)}\n} {-3420224}\ndo_test randexpr-2.1937 {\n  db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 |  -t1.e or c=11 then (t1.e) when  -t1.d<=t1.b and (t1.f<>t1.c) then a else  -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE  -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) |  -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d}\n} {24239687}\ndo_test randexpr-2.1938 {\n  db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 |  -t1.e or c=11 then (t1.e) when  -t1.d<=t1.b and (t1.f<>t1.c) then a else  -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE NOT ( -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) |  -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d)}\n} {}\ndo_test randexpr-2.1939 {\n  db eval {SELECT f-coalesce((select max(d+~+ - -(a)*(select min(t1.d) from t1)*t1.f+case when ( -13)*t1.e<>11 &  -t1.e or c=11 then (t1.e) when  -t1.d<=t1.b and (t1.f<>t1.c) then a else  -t1.f end) from t1 where 11 not between t1.e and b),t1.f)-13 FROM t1 WHERE  -a not in (17+~coalesce((select t1.a from t1 where (exists(select 1 from t1 where 11>c))),11)+17-11,11,t1.c) or f in (select case (min((t1.a))) when max(b) then min(13) else cast(avg(c) AS integer) end*max(d)*(case cast(avg(19) AS integer) when ( -min(19)) then count(*) else count(*) end) |  -cast(avg(19) AS integer) from t1 union select cast(avg(b) AS integer) from t1) or t1.f>= -t1.d}\n} {24239687}\ndo_test randexpr-2.1940 {\n  db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b | (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select  -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case t1.b when  -t1.c then c-17 else case f when (abs(case when ((13*case  -e when case when b>c and 11>11 then  -a when  -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then  -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a)}\n} {-514}\ndo_test randexpr-2.1941 {\n  db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b | (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select  -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where coalesce((select case t1.b when  -t1.c then c-17 else case f when (abs(case when ((13*case  -e when case when b>c and 11>11 then  -a when  -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then  -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a))}\n} {}\ndo_test randexpr-2.1942 {\n  db eval {SELECT ~case when ~coalesce((select max(f) from t1 where b & (select +max(13) from t1)+t1.b<~13*t1.d*coalesce((select  -t1.b from t1 where coalesce((select t1.e+a from t1 where 11=17),a) between 19 and e),17)*d),t1.b) in (select cast(avg(t1.d) AS integer) from t1 union select ~count(distinct 11) from t1) then 11 when t1.d>=t1.b then 13 else f end-t1.e FROM t1 WHERE not exists(select 1 from t1 where coalesce((select case t1.b when  -t1.c then c-17 else case f when (abs(case when ((13*case  -e when case when b>c and 11>11 then  -a when  -(t1.c)>t1.e then d else t1.d end then t1.d else t1.e end<=11)) then ~t1.b+f when (d)<=c then t1.a else (t1.a) end+b)/abs(b)) then  -b else 11 end end-19 from t1 where t1.e<=t1.b),a)>t1.a)}\n} {-514}\ndo_test randexpr-2.1943 {\n  db eval {SELECT +(case when (not exists(select 1 from t1 where t1.c in (select +(abs(a)/abs( -coalesce((select max(17) from t1 where (not (c>=t1.d and t1.c>=f) and t1.e>e)),19-17))) from t1 union select case when (b)>d then d when c not in (f,t1.b,t1.d) then t1.f else t1.d end from t1) or a not in (t1.d,a, -b))) and exists(select 1 from t1 where b<11) then c when t1.c not between e and  -19 then t1.b else ~c end) FROM t1 WHERE t1.e*f-a- -13-b= -d}\n} {}\ndo_test randexpr-2.1944 {\n  db eval {SELECT +(case when (not exists(select 1 from t1 where t1.c in (select +(abs(a)/abs( -coalesce((select max(17) from t1 where (not (c>=t1.d and t1.c>=f) and t1.e>e)),19-17))) from t1 union select case when (b)>d then d when c not in (f,t1.b,t1.d) then t1.f else t1.d end from t1) or a not in (t1.d,a, -b))) and exists(select 1 from t1 where b<11) then c when t1.c not between e and  -19 then t1.b else ~c end) FROM t1 WHERE NOT (t1.e*f-a- -13-b= -d)}\n} {200}\ndo_test randexpr-2.1945 {\n  db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a | c,t1.a,f) then 13 when  -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else  -11 end then 11 else t1.a end FROM t1 WHERE not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end))}\n} {189}\ndo_test randexpr-2.1946 {\n  db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a | c,t1.a,f) then 13 when  -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else  -11 end then 11 else t1.a end FROM t1 WHERE NOT (not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end)))}\n} {}\ndo_test randexpr-2.1947 {\n  db eval {SELECT b-case when a not between t1.f and case when t1.d in (select count(*) from t1 union select cast(avg(coalesce((select +11*t1.e from t1 where e+b<case when 19 not in (t1.a & c,t1.a,f) then 13 when  -b<=17 then t1.e else a end),17)) AS integer) from t1) then 13 when not exists(select 1 from t1 where 13 between e and 17) or (a= -13) then t1.e else  -11 end then 11 else t1.a end FROM t1 WHERE not exists(select 1 from t1 where (e+17+t1.f)<=(case b when ~t1.f+(select +max(t1.f*case t1.b when +t1.f then t1.b else case when (not case when c=d then t1.c when t1.c<>b and t1.d between c and b then t1.d else t1.d end<t1.b) then t1.d when f<= -a then case when 17<c then a else a end else t1.e end end) from t1)*+t1.f then e else 17 end))}\n} {189}\ndo_test randexpr-2.1948 {\n  db eval {SELECT (select (min(coalesce((select max((case when t1.f<coalesce((select max(e+case when (t1.d in (select cast(avg(b) AS integer)+count(*) from t1 union select max(13) from t1)) then e*a else c end-t1.e) from t1 where (t1.c between b and t1.f and  -t1.b between  -t1.d and  -t1.a or c in (t1.b,t1.f,(f)))),13)+t1.c*19 then f else c end)) from t1 where  -t1.b not between t1.b and t1.c),11)-19))+count(distinct t1.e) from t1) FROM t1 WHERE  - -+t1.b*(19-t1.a | e*(select abs((count(distinct  -f+t1.d-11*t1.a))) from t1))*+(abs(c)/abs(t1.c))+t1.c*(t1.a)+case when b>=t1.d and 17<=13 or f between  -t1.c and 11 then case d when t1.c then 13 else t1.e end when (11)>b then a else c end in (t1.e,a,b)}\n} {}\ndo_test randexpr-2.1949 {\n  db eval {SELECT (select (min(coalesce((select max((case when t1.f<coalesce((select max(e+case when (t1.d in (select cast(avg(b) AS integer)+count(*) from t1 union select max(13) from t1)) then e*a else c end-t1.e) from t1 where (t1.c between b and t1.f and  -t1.b between  -t1.d and  -t1.a or c in (t1.b,t1.f,(f)))),13)+t1.c*19 then f else c end)) from t1 where  -t1.b not between t1.b and t1.c),11)-19))+count(distinct t1.e) from t1) FROM t1 WHERE NOT ( - -+t1.b*(19-t1.a | e*(select abs((count(distinct  -f+t1.d-11*t1.a))) from t1))*+(abs(c)/abs(t1.c))+t1.c*(t1.a)+case when b>=t1.d and 17<=13 or f between  -t1.c and 11 then case d when t1.c then 13 else t1.e end when (11)>b then a else c end in (t1.e,a,b))}\n} {582}\ndo_test randexpr-2.1950 {\n  db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d | 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 | 11+17)+e-(c)-d-b FROM t1 WHERE (d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b)}\n} {}\ndo_test randexpr-2.1951 {\n  db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d | 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 | 11+17)+e-(c)-d-b FROM t1 WHERE NOT ((d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b))}\n} {-371}\ndo_test randexpr-2.1952 {\n  db eval {SELECT coalesce((select max((abs(e)/abs(t1.a))) from t1 where (select (count(distinct ~ - -11- -t1.a-a*t1.d & 11-19+t1.f+17*c)-cast(avg(17) AS integer)+(cast(avg((19)) AS integer))) from t1)>a),17 & 11+17)+e-(c)-d-b FROM t1 WHERE NOT ((d>t1.d-case when case +(abs(t1.d | t1.f)/abs(t1.b)) when +b then coalesce((select max(t1.d | t1.c+(11+t1.d-t1.c)) from t1 where ((t1.e=17))),17) else t1.c end>=b then a else t1.f end) and (not (e<=c)) and not (t1.c<>b))}\n} {-384}\ndo_test randexpr-2.1953 {\n  db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) | case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b | +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE (b+t1.c*c in (11, -t1.f,t1.b))}\n} {}\ndo_test randexpr-2.1954 {\n  db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) | case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b | +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE NOT ((b+t1.c*c in (11, -t1.f,t1.b)))}\n} {17}\ndo_test randexpr-2.1955 {\n  db eval {SELECT coalesce((select c from t1 where case b when t1.a*(17) & case b++b when e then d else t1.b+f end+a+t1.d then d else t1.b & +e end<+~(select (count(*)) from t1)),17) FROM t1 WHERE NOT ((b+t1.c*c in (11, -t1.f,t1.b)))}\n} {17}\ndo_test randexpr-2.1956 {\n  db eval {SELECT case when coalesce((select max((abs(c)/abs(t1.d))) from t1 where t1.f*case when t1.a in (select (abs(17)/abs(c))*(t1.a) from t1 union select t1.e from t1) then t1.b else b end<19),e)+a-d in (select case max(t1.b)-count(distinct t1.c) when +case abs(cast(avg(t1.f) AS integer)) when +cast(avg(f) AS integer)-min(f) then count(distinct c) else cast(avg(d) AS integer) end then count(distinct t1.a) else cast(avg(b) AS integer) end from t1 union select count(distinct t1.e) from t1) then t1.c else f end FROM t1 WHERE ((19 in (t1.b,case t1.f when 11 then 11 else  -+t1.b | 19 end+coalesce((select 11 from t1 where c<=t1.c* -e),f),t1.f)) or (b between t1.b and 17) or not exists(select 1 from t1 where  -17 between  -f and t1.e or (not b<>11) and 19 in (select 11 from t1 union select t1.b from t1))) or 13>(t1.e)}\n} {}\ndo_test randexpr-2.1957 {\n  db eval {SELECT case when coalesce((select max((abs(c)/abs(t1.d))) from t1 where t1.f*case when t1.a in (select (abs(17)/abs(c))*(t1.a) from t1 union select t1.e from t1) then t1.b else b end<19),e)+a-d in (select case max(t1.b)-count(distinct t1.c) when +case abs(cast(avg(t1.f) AS integer)) when +cast(avg(f) AS integer)-min(f) then count(distinct c) else cast(avg(d) AS integer) end then count(distinct t1.a) else cast(avg(b) AS integer) end from t1 union select count(distinct t1.e) from t1) then t1.c else f end FROM t1 WHERE NOT (((19 in (t1.b,case t1.f when 11 then 11 else  -+t1.b | 19 end+coalesce((select 11 from t1 where c<=t1.c* -e),f),t1.f)) or (b between t1.b and 17) or not exists(select 1 from t1 where  -17 between  -f and t1.e or (not b<>11) and 19 in (select 11 from t1 union select t1.b from t1))) or 13>(t1.e))}\n} {300}\ndo_test randexpr-2.1958 {\n  db eval {SELECT f+case when e>+11+t1.e or ~t1.a=f+t1.e+t1.c then t1.a+case when b*coalesce((select max(a) from t1 where not exists(select 1 from t1 where (t1.f=case when exists(select 1 from t1 where t1.f<b) then f when 19<13 then t1.e else f end))),coalesce((select max(11) from t1 where (t1.d) between t1.c and  - -f and d<>f),11))<(e) then t1.e else 19 end+(c) else t1.a end*c-t1.c FROM t1 WHERE not ~coalesce((select max(t1.f*coalesce((select max(f) from t1 where case 17 when e*19 then case t1.a when 17 then f else t1.c+t1.d end | (e) else ~a end>=e or not t1.b in (select a from t1 union select d from t1)),19)) from t1 where e>coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.c=t1.a)),case t1.b when t1.b then a else 19 end)),13)*t1.b not between t1.e and t1.e}\n} {}\ndo_test randexpr-2.1959 {\n  db eval {SELECT f+case when e>+11+t1.e or ~t1.a=f+t1.e+t1.c then t1.a+case when b*coalesce((select max(a) from t1 where not exists(select 1 from t1 where (t1.f=case when exists(select 1 from t1 where t1.f<b) then f when 19<13 then t1.e else f end))),coalesce((select max(11) from t1 where (t1.d) between t1.c and  - -f and d<>f),11))<(e) then t1.e else 19 end+(c) else t1.a end*c-t1.c FROM t1 WHERE NOT (not ~coalesce((select max(t1.f*coalesce((select max(f) from t1 where case 17 when e*19 then case t1.a when 17 then f else t1.c+t1.d end | (e) else ~a end>=e or not t1.b in (select a from t1 union select d from t1)),19)) from t1 where e>coalesce((select 17 from t1 where not exists(select 1 from t1 where t1.c=t1.a)),case t1.b when t1.b then a else 19 end)),13)*t1.b not between t1.e and t1.e)}\n} {30300}\ndo_test randexpr-2.1960 {\n  db eval {SELECT e*(select  -max((case when  -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end |  -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE exists(select 1 from t1 where c<>a)}\n} {-50000000}\ndo_test randexpr-2.1961 {\n  db eval {SELECT e*(select  -max((case when  -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end |  -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where c<>a))}\n} {}\ndo_test randexpr-2.1962 {\n  db eval {SELECT e*(select  -max((case when  -case when (+(abs(f)/abs(17))*13)> -a then 17 else f end &  -t1.f-e*11<>11 then c when exists(select 1 from t1 where not exists(select 1 from t1 where t1.b not in (t1.d,19,d) and t1.d<>11)) or 13<= -t1.f then 11 else d end-t1.a)*e) from t1) FROM t1 WHERE exists(select 1 from t1 where c<>a)}\n} {-50000000}\ndo_test randexpr-2.1963 {\n  db eval {SELECT a-t1.b | (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE (case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13)}\n} {}\ndo_test randexpr-2.1964 {\n  db eval {SELECT a-t1.b | (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE NOT ((case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13))}\n} {-68}\ndo_test randexpr-2.1965 {\n  db eval {SELECT a-t1.b & (case case when 13 in (t1.c,(t1.c),t1.e) then e+b when b in (select e from t1 union select d from t1) then (select count(distinct (abs(case when t1.e not between c and c then f else case t1.a when t1.c then e+t1.d else c end end)/abs(b))) from t1) else t1.b- -t1.d end when t1.c then 11 else e end- -a)+d-t1.b FROM t1 WHERE NOT ((case when f between f+(abs(coalesce((select t1.c*t1.c from t1 where f between 19 and (select count(distinct coalesce((select max(case case when t1.b<>t1.c then t1.d when 19<d then t1.c else d end | 19-17 when b then 11 else f end) from t1 where c in (select 11 from t1 union select t1.e from t1)),e)) from t1)),13))/abs(19)) and (e) then c when 17 in ((c),t1.e,f) and a in (select 19 from t1 union select t1.e from t1) then t1.f else 13 end<13))}\n} {768}\ndo_test randexpr-2.1966 {\n  db eval {SELECT (abs(case t1.f | d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d | d* -11+t1.d*t1.f | a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE t1.f in (select count(*) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.1967 {\n  db eval {SELECT (abs(case t1.f | d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d | d* -11+t1.d*t1.f | a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE NOT (t1.f in (select count(*) from t1 union select count(*) from t1))}\n} {76}\ndo_test randexpr-2.1968 {\n  db eval {SELECT (abs(case t1.f & d when coalesce((select max(~b) from t1 where +t1.a<> -case t1.f when +b-case when (17 in (select count(distinct b)+count(distinct t1.a) from t1 union select count(distinct 13) from t1)) then d else 13 end+t1.d & d* -11+t1.d*t1.f & a-17 then 13 else c end*t1.e),d) then t1.b else d end)/abs(t1.a))*19 FROM t1 WHERE NOT (t1.f in (select count(*) from t1 union select count(*) from t1))}\n} {76}\ndo_test randexpr-2.1969 {\n  db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b | ~case a | c | t1.d when t1.c then t1.a else t1.e end | e-13*b) from t1 where  -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end | (min(t1.e)) |  -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select  -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1)))}\n} {}\ndo_test randexpr-2.1970 {\n  db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b | ~case a | c | t1.d when t1.c then t1.a else t1.e end | e-13*b) from t1 where  -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end | (min(t1.e)) |  -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE NOT (not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select  -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1))))}\n} {300}\ndo_test randexpr-2.1971 {\n  db eval {SELECT t1.d+coalesce((select max(t1.b*t1.b & ~case a & c & t1.d when t1.c then t1.a else t1.e end & e-13*b) from t1 where  -t1.a in (select e from t1 union select t1.b from t1) and not exists(select 1 from t1 where (a) in (select min(13)* -cast(avg(t1.e) AS integer)*~case count(*) when count(*) then ((cast(avg(e) AS integer))) else count(*) end & (min(t1.e)) &  -count(*) from t1 union select max(t1.a) from t1))), -t1.b)+a FROM t1 WHERE NOT (not exists(select 1 from t1 where 11*d+a>=(t1.a-e+17*(select +cast(avg((select cast(avg((abs(case when (abs(t1.a)/abs(coalesce((select max(c+t1.e) from t1 where not exists(select 1 from t1 where 13 in (select  -t1.c from t1 union select t1.f from t1))),17) | e*e)) not between e and t1.f then 19 else t1.b end)/abs(19))) AS integer)* -count(*) from t1)) AS integer)*count(distinct 11)-abs(cast(avg(b) AS integer)) from t1))))}\n} {300}\ndo_test randexpr-2.1972 {\n  db eval {SELECT ~case when case when +d+case b when 11 then coalesce((select max(b) from t1 where (((abs(f)/abs((abs(11)/abs(e))+t1.b))>t1.f))),(select max(t1.e) from t1)) else t1.f end*t1.f*17>=(t1.e) or 17>t1.f then t1.a else t1.a end in (c,13,c) then t1.f when t1.a not in (t1.d, -t1.b,a) then  -t1.b else 11 end FROM t1 WHERE t1.a in (+e,17,11*13) and b not between t1.f*(abs(t1.c-((abs(t1.a | coalesce((select max(case when  -f-t1.c<=t1.f then 19 when (t1.a)<>t1.f and 13 between a and t1.e then  -11 else 17 end) from t1 where c>19),f)-t1.e)/abs(e))))/abs(b))-t1.e | (19) and  -t1.a and t1.f in (select 13 from t1 union select a from t1)}\n} {}\ndo_test randexpr-2.1973 {\n  db eval {SELECT ~case when case when +d+case b when 11 then coalesce((select max(b) from t1 where (((abs(f)/abs((abs(11)/abs(e))+t1.b))>t1.f))),(select max(t1.e) from t1)) else t1.f end*t1.f*17>=(t1.e) or 17>t1.f then t1.a else t1.a end in (c,13,c) then t1.f when t1.a not in (t1.d, -t1.b,a) then  -t1.b else 11 end FROM t1 WHERE NOT (t1.a in (+e,17,11*13) and b not between t1.f*(abs(t1.c-((abs(t1.a | coalesce((select max(case when  -f-t1.c<=t1.f then 19 when (t1.a)<>t1.f and 13 between a and t1.e then  -11 else 17 end) from t1 where c>19),f)-t1.e)/abs(e))))/abs(b))-t1.e | (19) and  -t1.a and t1.f in (select 13 from t1 union select a from t1))}\n} {-12}\ndo_test randexpr-2.1974 {\n  db eval {SELECT case when case 17 when case when (abs(t1.c)/abs(t1.c | coalesce((select max(t1.d) from t1 where not t1.e<17 or 11 not in (t1.a,t1.c,a) or c=d and (t1.b)<f and t1.c>=t1.e and 17 in ( -t1.c,a,d) and t1.f not in (19,a,b)),11) | (select  -max(+t1.b) from t1)+19-19 | f))<>t1.a or e>17 then f else a end then 11 else f end=t1.a then f else  -t1.f end FROM t1 WHERE  -t1.b+a>= -t1.a}\n} {-600}\ndo_test randexpr-2.1975 {\n  db eval {SELECT case when case 17 when case when (abs(t1.c)/abs(t1.c | coalesce((select max(t1.d) from t1 where not t1.e<17 or 11 not in (t1.a,t1.c,a) or c=d and (t1.b)<f and t1.c>=t1.e and 17 in ( -t1.c,a,d) and t1.f not in (19,a,b)),11) | (select  -max(+t1.b) from t1)+19-19 | f))<>t1.a or e>17 then f else a end then 11 else f end=t1.a then f else  -t1.f end FROM t1 WHERE NOT ( -t1.b+a>= -t1.a)}\n} {}\ndo_test randexpr-2.1976 {\n  db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a | a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when  - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE ((d not between  -a and b))}\n} {17}\ndo_test randexpr-2.1977 {\n  db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a | a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when  - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE NOT (((d not between  -a and b)))}\n} {}\ndo_test randexpr-2.1978 {\n  db eval {SELECT (abs(coalesce((select ((t1.c)) from t1 where not exists(select 1 from t1 where t1.e*17<13*coalesce((select max(a) from t1 where 19 in (select max(e*11) from t1 union select cast(avg(t1.b) AS integer) from t1)),a & a))),case when f-13<d+17 and not exists(select 1 from t1 where e<= -13) or a between e and d then case t1.a when t1.b then f else t1.f end when  - -t1.f<>t1.e then t1.b else f end))/abs(17)) FROM t1 WHERE ((d not between  -a and b))}\n} {17}\ndo_test randexpr-2.1979 {\n  db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 | d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE (not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when  - -cast(avg(t1.f) AS integer) then (count(*)) else  -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1)))}\n} {600}\ndo_test randexpr-2.1980 {\n  db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 | d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE NOT ((not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when  - -cast(avg(t1.f) AS integer) then (count(*)) else  -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1))))}\n} {}\ndo_test randexpr-2.1981 {\n  db eval {SELECT case f when (d)-case when coalesce((select max(coalesce((select 11 from t1 where case when (t1.f<=17 or exists(select 1 from t1 where 11 & d in (select (abs(max(t1.f))) from t1 union select ( -min(c)) from t1))) then a when t1.f not in (e,13,13) then t1.c else e end between 19 and c),t1.a)) from t1 where f>=t1.d),17) not between e and t1.c and 11<=17 then t1.e-19 when t1.a not in (c,t1.e,t1.c) then 11 else t1.b end then t1.e else t1.f end FROM t1 WHERE (not (case 17 when d then t1.c else c end=f | (select case count(*) when count(*)++max(11)+ -(abs(+cast(avg(c) AS integer)-(~count(*))+count(*)*(~case max( -c) when  - -cast(avg(t1.f) AS integer) then (count(*)) else  -max(t1.b) end*cast(avg(a) AS integer))-count(*) | ( -( -max(11)))) | ( -min(17))+count(*)) then (max(19)) else max(t1.c) end from t1)))}\n} {600}\ndo_test randexpr-2.1982 {\n  db eval {SELECT case when d+t1.d not between t1.f and + -t1.c then ~+a+(select +count(*) from t1) else (select +abs(count(*)) from t1)-t1.a end FROM t1 WHERE t1.b+f | d+a in (select +cast(avg(b) AS integer)++case min(coalesce((select t1.c from t1 where (e) in ((a)+17,t1.b,d)),t1.f)) when ~~cast(avg(17) AS integer)-max((t1.a)) then case min(13) when count(*) then count(distinct t1.a) else cast(avg(b) AS integer) end*max(d)+max(t1.b) else  -count(*) end-count(*) from t1 union select cast(avg(t1.f) AS integer) from t1)}\n} {}\ndo_test randexpr-2.1983 {\n  db eval {SELECT case when d+t1.d not between t1.f and + -t1.c then ~+a+(select +count(*) from t1) else (select +abs(count(*)) from t1)-t1.a end FROM t1 WHERE NOT (t1.b+f | d+a in (select +cast(avg(b) AS integer)++case min(coalesce((select t1.c from t1 where (e) in ((a)+17,t1.b,d)),t1.f)) when ~~cast(avg(17) AS integer)-max((t1.a)) then case min(13) when count(*) then count(distinct t1.a) else cast(avg(b) AS integer) end*max(d)+max(t1.b) else  -count(*) end-count(*) from t1 union select cast(avg(t1.f) AS integer) from t1))}\n} {-100}\ndo_test randexpr-2.1984 {\n  db eval {SELECT case when case when case case when (case when (( -f<t1.a)) and a between t1.b and 17 then c else +t1.c end-f+11+e between (17) and a) then t1.d else f end+t1.e*11-11 when  -11 then 17 else f end in (select t1.d from t1 union select b from t1) then c when t1.d<=(a) then t1.e else  -f end<t1.d then a else 11 end-19*f FROM t1 WHERE t1.b in (case +t1.f | d*~(case when b not between c and e+t1.d-coalesce((select  -t1.f* -t1.c from t1 where (f in (select t1.d from t1 union select  -t1.d from t1))),t1.b) then t1.c when not exists(select 1 from t1 where a<>t1.c or exists(select 1 from t1 where not exists(select 1 from t1 where (a not between b and  -t1.e)) and t1.f>=(t1.a)) and t1.f<(t1.b)) then 19 else e end) when a then t1.e else 11 end,(a),19)}\n} {}\ndo_test randexpr-2.1985 {\n  db eval {SELECT case when case when case case when (case when (( -f<t1.a)) and a between t1.b and 17 then c else +t1.c end-f+11+e between (17) and a) then t1.d else f end+t1.e*11-11 when  -11 then 17 else f end in (select t1.d from t1 union select b from t1) then c when t1.d<=(a) then t1.e else  -f end<t1.d then a else 11 end-19*f FROM t1 WHERE NOT (t1.b in (case +t1.f | d*~(case when b not between c and e+t1.d-coalesce((select  -t1.f* -t1.c from t1 where (f in (select t1.d from t1 union select  -t1.d from t1))),t1.b) then t1.c when not exists(select 1 from t1 where a<>t1.c or exists(select 1 from t1 where not exists(select 1 from t1 where (a not between b and  -t1.e)) and t1.f>=(t1.a)) and t1.f<(t1.b)) then 19 else e end) when a then t1.e else 11 end,(a),19))}\n} {-11300}\ndo_test randexpr-2.1986 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b | 13+19 FROM t1 WHERE t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1)}\n} {}\ndo_test randexpr-2.1987 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b | 13+19 FROM t1 WHERE NOT (t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1))}\n} {4900}\ndo_test randexpr-2.1988 {\n  db eval {SELECT coalesce((select 11 from t1 where 19 in (select ((count(*)*min(11)*(abs(max(a)))-max(b)*+count(*))) from t1 union select case abs(abs(min(t1.b))*case count(distinct b) when count(distinct t1.a) then count(distinct t1.f-t1.f) else max(11) end) when cast(avg(e) AS integer) then count(*) else count(*) end from t1)),d)*11+t1.c+b & 13+19 FROM t1 WHERE NOT (t1.c in (select 19 from t1 union select ~t1.f-t1.f+17- -17 from t1))}\n} {32}\ndo_test randexpr-2.1989 {\n  db eval {SELECT case f when (select ++abs(max(d))+case case count(*) when min(t1.c) then (count(*)) else min(t1.e) end when  -count(distinct t1.e) then count(distinct a) else min(t1.b) end from t1) then coalesce((select case when e in (select d from t1 union select f from t1) and t1.a not between b and 13 and d in (select 17 from t1 union select b from t1) then 17 when 11=f then 19 else d end from t1 where 11 not in (t1.c,t1.c,t1.d)),a) else e end-t1.e-t1.d-17*t1.f FROM t1 WHERE case when coalesce((select max(c) from t1 where 19 not between 11 and t1.e and t1.b in (select count(*) from t1 union select ~min(case c when (abs(case when d=( -t1.e) or t1.b<>t1.f then b else t1.b end)/abs(t1.c))+19 then t1.f else d end) from t1) and  -b in (select min(17) from t1 union select min( -c) | count(distinct 17)- -(count(*))+max(t1.c) |  -cast(avg(t1.c) AS integer) from t1)),t1.c)*t1.f not between  -t1.e and t1.f then 11 else f end>f}\n} {}\ndo_test randexpr-2.1990 {\n  db eval {SELECT case f when (select ++abs(max(d))+case case count(*) when min(t1.c) then (count(*)) else min(t1.e) end when  -count(distinct t1.e) then count(distinct a) else min(t1.b) end from t1) then coalesce((select case when e in (select d from t1 union select f from t1) and t1.a not between b and 13 and d in (select 17 from t1 union select b from t1) then 17 when 11=f then 19 else d end from t1 where 11 not in (t1.c,t1.c,t1.d)),a) else e end-t1.e-t1.d-17*t1.f FROM t1 WHERE NOT (case when coalesce((select max(c) from t1 where 19 not between 11 and t1.e and t1.b in (select count(*) from t1 union select ~min(case c when (abs(case when d=( -t1.e) or t1.b<>t1.f then b else t1.b end)/abs(t1.c))+19 then t1.f else d end) from t1) and  -b in (select min(17) from t1 union select min( -c) | count(distinct 17)- -(count(*))+max(t1.c) |  -cast(avg(t1.c) AS integer) from t1)),t1.c)*t1.f not between  -t1.e and t1.f then 11 else f end>f)}\n} {-10700}\ndo_test randexpr-2.1991 {\n  db eval {SELECT case when ((coalesce((select t1.a from t1 where exists(select 1 from t1 where t1.a<=t1.b-e*coalesce((select max(a) from t1 where t1.e in (select min(13+13) from t1 union select  -(count(distinct t1.f)-count(*)) from t1)),17)-f-t1.f) or t1.d in (select t1.a from t1 union select b from t1)),t1.d*t1.f)<>a)) then t1.d when not exists(select 1 from t1 where ((t1.f in (c,19,f)))) then t1.f else 17 end FROM t1 WHERE t1.c<=a}\n} {}\ndo_test randexpr-2.1992 {\n  db eval {SELECT case when ((coalesce((select t1.a from t1 where exists(select 1 from t1 where t1.a<=t1.b-e*coalesce((select max(a) from t1 where t1.e in (select min(13+13) from t1 union select  -(count(distinct t1.f)-count(*)) from t1)),17)-f-t1.f) or t1.d in (select t1.a from t1 union select b from t1)),t1.d*t1.f)<>a)) then t1.d when not exists(select 1 from t1 where ((t1.f in (c,19,f)))) then t1.f else 17 end FROM t1 WHERE NOT (t1.c<=a)}\n} {400}\ndo_test randexpr-2.1993 {\n  db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end | 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then  -t1.c else 17 end else t1.b end) end FROM t1 WHERE d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a}\n} {200}\ndo_test randexpr-2.1994 {\n  db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end | 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then  -t1.c else 17 end else t1.b end) end FROM t1 WHERE NOT (d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a)}\n} {}\ndo_test randexpr-2.1995 {\n  db eval {SELECT case 17 when t1.f then 11 else (case when (c between case when ~t1.e+13-t1.c+case coalesce((select t1.c from t1 where t1.a not between a and 17),coalesce((select max(case when exists(select 1 from t1 where a>=t1.a) then ((t1.e)) when t1.e>=11 then 17 else t1.b end) from t1 where ( -11<e)),a)*t1.c) when t1.f then t1.d else b end & 13<t1.d then f else t1.f end and e) then case t1.b when t1.b then  -t1.c else 17 end else t1.b end) end FROM t1 WHERE d- -coalesce((select max( -(17)+(t1.d)* -coalesce((select max(+d) from t1 where case when t1.e between 19 and t1.d then a when t1.d between t1.e and 17 then e else t1.c end+13 between a and t1.b or (c) in (select t1.b from t1 union select a from t1) or 11<>d),t1.c) | b- -17-(17)*c) from t1 where (19<13)),t1.c) not between a and t1.a}\n} {200}\ndo_test randexpr-2.1996 {\n  db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) | ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) | t1.d FROM t1 WHERE (case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when  -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when  -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d)}\n} {1017}\ndo_test randexpr-2.1997 {\n  db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) | ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) | t1.d FROM t1 WHERE NOT ((case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when  -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when  -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d))}\n} {}\ndo_test randexpr-2.1998 {\n  db eval {SELECT 17+(select case ~max((abs(t1.c+coalesce((select max(t1.f) from t1 where t1.f in (select 13-c-case when not a>=t1.c then f else t1.c end+t1.c from t1 union select 19 from t1) or exists(select 1 from t1 where 13<t1.e)),17)*(19))/abs(b))) when ~abs( -+max(t1.a)) then +abs(cast(avg(t1.e) AS integer)) & ~abs(~cast(avg(b) AS integer)) else cast(avg(t1.f) AS integer) end from t1) & t1.d FROM t1 WHERE (case when case when 13<>17 | e*d-17*t1.e*case a when case when (not f>=19 and t1.f<=t1.b) then coalesce((select case 11 when  -c then t1.f else (t1.f) end from t1 where 13 between t1.e and t1.f),(e)) when  -t1.f not between b and d then t1.d else t1.a end then 11 else 19 end then d when a<t1.d then 19 else 11 end=t1.e then t1.a else t1.d end+f>d)}\n} {0}\ndo_test randexpr-2.1999 {\n  db eval {SELECT ~c-t1.a*case  -case 19 when d then t1.f else t1.a end-d when 11 then coalesce((select max(case when (case when exists(select 1 from t1 where 11*11>13) then t1.c else 11 end)<=(select min(~d+case 19 when e then 13 else e end) from t1) then c when ((f))<=17 then d else t1.c end+t1.f) from t1 where (t1.b between  -c and t1.e)),t1.e) else 17 end FROM t1 WHERE +(abs(d-(select cast(avg((select (abs(max(t1.d*+d*( -e*(13)) | 17)+ -min(t1.d)+~ - -max(17) | max(t1.a) |  -count(distinct t1.a)-count(distinct 13)*(count(distinct t1.a)) | (count(distinct 17)))) from t1)) AS integer) from t1)-11)/abs(c+d-t1.e))>=t1.d}\n} {}\ndo_test randexpr-2.2000 {\n  db eval {SELECT ~c-t1.a*case  -case 19 when d then t1.f else t1.a end-d when 11 then coalesce((select max(case when (case when exists(select 1 from t1 where 11*11>13) then t1.c else 11 end)<=(select min(~d+case 19 when e then 13 else e end) from t1) then c when ((f))<=17 then d else t1.c end+t1.f) from t1 where (t1.b between  -c and t1.e)),t1.e) else 17 end FROM t1 WHERE NOT (+(abs(d-(select cast(avg((select (abs(max(t1.d*+d*( -e*(13)) | 17)+ -min(t1.d)+~ - -max(17) | max(t1.a) |  -count(distinct t1.a)-count(distinct 13)*(count(distinct t1.a)) | (count(distinct 17)))) from t1)) AS integer) from t1)-11)/abs(c+d-t1.e))>=t1.d)}\n} {-2001}\ndo_test randexpr-2.2001 {\n  db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select  -abs(case ( -count(distinct t1.e)) when count(distinct 13) | max((abs(case 11 when  -(abs(19)/abs(17 | t1.c*t1.e))*t1.c | t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE 19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c}\n} {}\ndo_test randexpr-2.2002 {\n  db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select  -abs(case ( -count(distinct t1.e)) when count(distinct 13) | max((abs(case 11 when  -(abs(19)/abs(17 | t1.c*t1.e))*t1.c | t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE NOT (19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c)}\n} {11}\ndo_test randexpr-2.2003 {\n  db eval {SELECT coalesce((select 11 from t1 where a not in (17,e,(select  -abs(case ( -count(distinct t1.e)) when count(distinct 13) & max((abs(case 11 when  -(abs(19)/abs(17 & t1.c*t1.e))*t1.c & t1.b then a else +d end)/abs(b*t1.a))) then max(c*13) else cast(avg(t1.f) AS integer) end)-max(11) from t1)*d)),t1.d) FROM t1 WHERE NOT (19-c*coalesce((select max(case (select count(distinct t1.f) from t1) | t1.a when case a when (abs(case when not c+t1.d>=e then 17*t1.e+a when not exists(select 1 from t1 where 11>b) then c else a end)/abs(t1.e))+t1.f*13 then 11 else t1.f end then 19 else d end-b) from t1 where (d) not between f and e),t1.d)= -c)}\n} {11}\ndo_test randexpr-2.2004 {\n  db eval {SELECT 11+t1.b*~c*17-13-a+t1.d | t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE e=11}\n} {}\ndo_test randexpr-2.2005 {\n  db eval {SELECT 11+t1.b*~c*17-13-a+t1.d | t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE NOT (e=11)}\n} {-1019998}\ndo_test randexpr-2.2006 {\n  db eval {SELECT 11+t1.b*~c*17-13-a+t1.d & t1.f+t1.b*coalesce((select 17 from t1 where t1.e in (select (select cast(avg(case case e when (t1.d) then 17 else (abs((abs(case when d<t1.d then b when t1.c<>19 then 19 else a end)/abs(f)))/abs((t1.e))) end when b then (11) else f end+17) AS integer) from t1) from t1 union select t1.c from t1)),(17)) FROM t1 WHERE NOT (e=11)}\n} {896}\ndo_test randexpr-2.2007 {\n  db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select  -count(distinct 11) | min(11) from t1)>case b when b then c else d end)),13)) from t1 where  -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE exists(select 1 from t1 where case when case when e<c then  -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b)}\n} {200000}\ndo_test randexpr-2.2008 {\n  db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select  -count(distinct 11) | min(11) from t1)>case b when b then c else d end)),13)) from t1 where  -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE NOT (exists(select 1 from t1 where case when case when e<c then  -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b))}\n} {}\ndo_test randexpr-2.2009 {\n  db eval {SELECT e*~~(coalesce((select +case when not exists(select 1 from t1 where 13*coalesce((select max(coalesce((select max(11) from t1 where not exists(select 1 from t1 where (select  -count(distinct 11) & min(11) from t1)>case b when b then c else d end)),13)) from t1 where  -c<>d),13)<>t1.f and 13 between 13 and 19) then b-t1.e+e else (t1.f) end from t1 where ((not not e>t1.c and c not between a and e))),t1.d)) FROM t1 WHERE exists(select 1 from t1 where case when case when e<c then  -coalesce((select max((abs(17)/abs(coalesce((select max(d) from t1 where (abs(13)/abs(t1.b)) between 11 and e),19)*f+d))*t1.f) from t1 where not exists(select 1 from t1 where 11 not in (t1.d, -t1.a,11))),t1.b)-e when (t1.c=17) then b else e end=f then d else t1.b end<=t1.d or t1.a<> -b)}\n} {200000}\ndo_test randexpr-2.2010 {\n  db eval {SELECT (case t1.b-coalesce((select max(t1.f) from t1 where +t1.c=e or coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where ((13-(select +cast(avg( -t1.b) AS integer) from t1) in (case f when (19) then t1.f else t1.f end,11,t1.e))))),(t1.a)+t1.e) not in (t1.f,t1.a,b) and t1.e not in (11,t1.b,t1.b)),d) when 19 then t1.e else c end-t1.e*t1.f) FROM t1 WHERE t1.e<t1.e}\n} {}\ndo_test randexpr-2.2011 {\n  db eval {SELECT (case t1.b-coalesce((select max(t1.f) from t1 where +t1.c=e or coalesce((select max(t1.a) from t1 where exists(select 1 from t1 where ((13-(select +cast(avg( -t1.b) AS integer) from t1) in (case f when (19) then t1.f else t1.f end,11,t1.e))))),(t1.a)+t1.e) not in (t1.f,t1.a,b) and t1.e not in (11,t1.b,t1.b)),d) when 19 then t1.e else c end-t1.e*t1.f) FROM t1 WHERE NOT (t1.e<t1.e)}\n} {-299700}\ndo_test randexpr-2.2012 {\n  db eval {SELECT t1.a+e-case when 19<+17 then case when 19 not between t1.e and t1.e then (abs(case when e+17*(select count(distinct (abs(+17)/abs(t1.c))) from t1)<>coalesce((select max(f) from t1 where 19>=b),19) then f else t1.e end-f)/abs(t1.a))-11 else t1.e end when exists(select 1 from t1 where not exists(select 1 from t1 where ((c)) not in (b,a,e))) then t1.c else ((11)) end FROM t1 WHERE (not 13 not in (17,a,e))}\n} {}\ndo_test randexpr-2.2013 {\n  db eval {SELECT t1.a+e-case when 19<+17 then case when 19 not between t1.e and t1.e then (abs(case when e+17*(select count(distinct (abs(+17)/abs(t1.c))) from t1)<>coalesce((select max(f) from t1 where 19>=b),19) then f else t1.e end-f)/abs(t1.a))-11 else t1.e end when exists(select 1 from t1 where not exists(select 1 from t1 where ((c)) not in (b,a,e))) then t1.c else ((11)) end FROM t1 WHERE NOT ((not 13 not in (17,a,e)))}\n} {589}\ndo_test randexpr-2.2014 {\n  db eval {SELECT case when not exists(select 1 from t1 where case when  -~(19)=t1.c then t1.f*~case when t1.f<=(select max(t1.c) from t1) then e when (c<>13) then t1.a else (b) end when t1.b between 19 and 17 then 17 else e end-e+t1.a>e or  -19 in (select max(13) from t1 union select min( -19) from t1)) then t1.b when  -11>=a then ~b else 19 end FROM t1 WHERE (c not between coalesce((select max(c) from t1 where (not t1.c<>t1.a)), -(abs(case when t1.e<=t1.c then t1.d when exists(select 1 from t1 where 17 in (select case when coalesce((select c from t1 where 17-t1.a-coalesce((select 17 from t1 where t1.f in (t1.b,19,t1.c)),17) not between e and 13),t1.b) not in (e,13,t1.a) then t1.c else b end | f from t1 union select t1.f from t1)) then t1.f else 11 end)/abs(t1.a))) and t1.e)}\n} {}\ndo_test randexpr-2.2015 {\n  db eval {SELECT case when not exists(select 1 from t1 where case when  -~(19)=t1.c then t1.f*~case when t1.f<=(select max(t1.c) from t1) then e when (c<>13) then t1.a else (b) end when t1.b between 19 and 17 then 17 else e end-e+t1.a>e or  -19 in (select max(13) from t1 union select min( -19) from t1)) then t1.b when  -11>=a then ~b else 19 end FROM t1 WHERE NOT ((c not between coalesce((select max(c) from t1 where (not t1.c<>t1.a)), -(abs(case when t1.e<=t1.c then t1.d when exists(select 1 from t1 where 17 in (select case when coalesce((select c from t1 where 17-t1.a-coalesce((select 17 from t1 where t1.f in (t1.b,19,t1.c)),17) not between e and 13),t1.b) not in (e,13,t1.a) then t1.c else b end | f from t1 union select t1.f from t1)) then t1.f else 11 end)/abs(t1.a))) and t1.e))}\n} {19}\ndo_test randexpr-2.2016 {\n  db eval {SELECT case t1.c | t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct  -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e}\n} {100}\ndo_test randexpr-2.2017 {\n  db eval {SELECT case t1.c | t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct  -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE NOT (t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e)}\n} {}\ndo_test randexpr-2.2018 {\n  db eval {SELECT case t1.c & t1.b when t1.f-c then case when c<t1.c then t1.e when not t1.f in (select case when exists(select 1 from t1 where t1.e<=coalesce((select (select case count(distinct  -e*a) when ~( -min(11)) then count(*) else count(*) end from t1) from t1 where (b-d<= -t1.f)),t1.e) or exists(select 1 from t1 where t1.d>=11) or t1.c<=t1.e) then + - -b+11 else 13 end from t1 union select (t1.c) from t1) then 17 else 11 end else t1.a end FROM t1 WHERE t1.f | 13+coalesce((select max(11) from t1 where e>=(select ~case cast(avg(19*f+(c)) AS integer) when (min(c))-min(t1.a) then cast(avg(13) AS integer) else count(distinct e) end from t1)),t1.f)>=coalesce((select c from t1 where (exists(select 1 from t1 where t1.f>=f and (t1.d)<>t1.a))),c) or not exists(select 1 from t1 where not 11>=t1.d) or (b between c and 11 and 11< -t1.b and t1.e>=t1.b) or t1.c>e}\n} {100}\ndo_test randexpr-2.2019 {\n  db eval {SELECT coalesce((select 19 from t1 where a<=case (abs(e)/abs(case b+f when b then t1.e else e end)) when + -t1.b+coalesce((select max(t1.f) from t1 where (19<=+e) and (c*b)>= -t1.e and (c>=c)),11+(e)+a)-t1.b then 17 else 17 end-t1.e),a) FROM t1 WHERE +d*t1.f+c+t1.c*13<>t1.e}\n} {100}\ndo_test randexpr-2.2020 {\n  db eval {SELECT coalesce((select 19 from t1 where a<=case (abs(e)/abs(case b+f when b then t1.e else e end)) when + -t1.b+coalesce((select max(t1.f) from t1 where (19<=+e) and (c*b)>= -t1.e and (c>=c)),11+(e)+a)-t1.b then 17 else 17 end-t1.e),a) FROM t1 WHERE NOT (+d*t1.f+c+t1.c*13<>t1.e)}\n} {}\ndo_test randexpr-2.2021 {\n  db eval {SELECT (abs(t1.e)/abs(coalesce((select +t1.a*c from t1 where (abs(e)/abs(d)) in (select +~count(*)-min(t1.d) from t1 union select abs(abs(cast(avg(t1.b) AS integer))+cast(avg(b) AS integer)) from t1)),d))) FROM t1 WHERE not b not between (select max(13) from t1) and 13}\n} {}\ndo_test randexpr-2.2022 {\n  db eval {SELECT (abs(t1.e)/abs(coalesce((select +t1.a*c from t1 where (abs(e)/abs(d)) in (select +~count(*)-min(t1.d) from t1 union select abs(abs(cast(avg(t1.b) AS integer))+cast(avg(b) AS integer)) from t1)),d))) FROM t1 WHERE NOT (not b not between (select max(13) from t1) and 13)}\n} {1}\ndo_test randexpr-2.2023 {\n  db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where  -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) | count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case  -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) |  - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19}\n} {5216}\ndo_test randexpr-2.2024 {\n  db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where  -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) | count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case  -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) |  - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19)}\n} {}\ndo_test randexpr-2.2025 {\n  db eval {SELECT +(select +~(count(distinct (abs((abs(coalesce((select max(t1.c) from t1 where  -e in (select t1.e from t1 union select (e) from t1)),c)-11)/abs(19))*t1.c)/abs(19))))*count(distinct t1.a)*+count(distinct a)*count(distinct t1.d) & count(*)-max(11)+cast(avg(t1.b) AS integer)*min(t1.a) from t1)+19+t1.c*19+~coalesce((select e from t1 where 13 in (select count(distinct 17) from t1 union select count(distinct 11) from t1) or t1.f<>c),17) FROM t1 WHERE exists(select 1 from t1 where coalesce((select t1.f from t1 where t1.a in (case when exists(select 1 from t1 where b*t1.e in (select (t1.a) from t1 union select (case  -13 when f then t1.b else t1.a end) from t1)) then t1.d else 17 end,d,11)),c) not in (17,19,t1.b)) or (b) in (select abs(~~abs(count(*)) |  - -min(c)-min(11)+count(*) | max(a) | count(*)-count(distinct 11)) from t1 union select max(t1.f) from t1) or t1.b>=19}\n} {25208}\ndo_test randexpr-2.2026 {\n  db eval {SELECT (abs(case t1.c when ~coalesce((select max(case coalesce((select max(b) from t1 where not a<b or e*coalesce((select case t1.d when c then e else 13 end from t1 where not t1.c in (select t1.e from t1 union select 11 from t1)),(d))+c in (select +min(t1.d) from t1 union select cast(avg(13) AS integer) from t1)),e-f)*e when t1.e then t1.f else 19 end) from t1 where e>a),e) then 17 else a end)/abs(19)) FROM t1 WHERE d not in (d,d+case coalesce((select t1.e from t1 where (case when 17*case case f-+t1.c+coalesce((select t1.c from t1 where t1.d<e),t1.e) when  -t1.d then e else t1.f end when d then t1.c else  -17 end*17*b<=t1.f then b when t1.a<e then 11 else 13 end>f)),d) when t1.e then (t1.c) else  -e end,t1.f)}\n} {}\ndo_test randexpr-2.2027 {\n  db eval {SELECT (abs(case t1.c when ~coalesce((select max(case coalesce((select max(b) from t1 where not a<b or e*coalesce((select case t1.d when c then e else 13 end from t1 where not t1.c in (select t1.e from t1 union select 11 from t1)),(d))+c in (select +min(t1.d) from t1 union select cast(avg(13) AS integer) from t1)),e-f)*e when t1.e then t1.f else 19 end) from t1 where e>a),e) then 17 else a end)/abs(19)) FROM t1 WHERE NOT (d not in (d,d+case coalesce((select t1.e from t1 where (case when 17*case case f-+t1.c+coalesce((select t1.c from t1 where t1.d<e),t1.e) when  -t1.d then e else t1.f end when d then t1.c else  -17 end*17*b<=t1.f then b when t1.a<e then 11 else 13 end>f)),d) when t1.e then (t1.c) else  -e end,t1.f))}\n} {5}\ndo_test randexpr-2.2028 {\n  db eval {SELECT case 13 when 13 then case when 11 between case case when not 17 not between f-t1.e and (abs(19)/abs(((t1.b))))*19 then t1.a when exists(select 1 from t1 where t1.e not between d and 13) then t1.c else  -e end when t1.e then t1.c else e end and 17 then 19 when not exists(select 1 from t1 where 11=f) and exists(select 1 from t1 where d<>t1.a) or t1.f>=17 then a else t1.e end else 19 end*11 FROM t1 WHERE case 17 when t1.f then 11 else c end+d=t1.f}\n} {}\ndo_test randexpr-2.2029 {\n  db eval {SELECT case 13 when 13 then case when 11 between case case when not 17 not between f-t1.e and (abs(19)/abs(((t1.b))))*19 then t1.a when exists(select 1 from t1 where t1.e not between d and 13) then t1.c else  -e end when t1.e then t1.c else e end and 17 then 19 when not exists(select 1 from t1 where 11=f) and exists(select 1 from t1 where d<>t1.a) or t1.f>=17 then a else t1.e end else 19 end*11 FROM t1 WHERE NOT (case 17 when t1.f then 11 else c end+d=t1.f)}\n} {1100}\ndo_test randexpr-2.2030 {\n  db eval {SELECT coalesce((select max(b-case when exists(select 1 from t1 where case when t1.c>t1.b then t1.c*19 else coalesce((select max((abs(t1.a)/abs(~(select +max(t1.c)*max(a)*cast(avg(t1.d) AS integer) from t1)+case when e=t1.c or t1.c between e and b then +a else 13 end))) from t1 where 17=b),t1.a) end not between f and t1.c) then c else e end+ - -d-17) from t1 where t1.e<d),17) FROM t1 WHERE  -a>=(select cast(avg(d) AS integer) from t1)}\n} {}\ndo_test randexpr-2.2031 {\n  db eval {SELECT coalesce((select max(b-case when exists(select 1 from t1 where case when t1.c>t1.b then t1.c*19 else coalesce((select max((abs(t1.a)/abs(~(select +max(t1.c)*max(a)*cast(avg(t1.d) AS integer) from t1)+case when e=t1.c or t1.c between e and b then +a else 13 end))) from t1 where 17=b),t1.a) end not between f and t1.c) then c else e end+ - -d-17) from t1 where t1.e<d),17) FROM t1 WHERE NOT ( -a>=(select cast(avg(d) AS integer) from t1))}\n} {17}\ndo_test randexpr-2.2032 {\n  db eval {SELECT case when  -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and  -t1.e)),t1.c)+c | b not between f and t1.b) then  -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE (select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13)}\n} {}\ndo_test randexpr-2.2033 {\n  db eval {SELECT case when  -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and  -t1.e)),t1.c)+c | b not between f and t1.b) then  -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE NOT ((select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13))}\n} {411}\ndo_test randexpr-2.2034 {\n  db eval {SELECT case when  -13 in (select +case when case when exists(select 1 from t1 where ~coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.a not between t1.b and  -t1.e)),t1.c)+c & b not between f and t1.b) then  -11-19 else t1.d end in (select ~abs(max(19))+cast(avg(e) AS integer)-max(13)-count(*) from t1 union select min(f) from t1) then t1.f else b end+t1.e from t1 union select t1.f from t1) then b when e<t1.f then d else t1.f end+11 FROM t1 WHERE NOT ((select count(distinct +t1.e) from t1) in (select max(coalesce((select case when exists(select 1 from t1 where +19*a<>(select count(distinct d) from t1)) then t1.a when +(select cast(avg(e-19*~case 19 when t1.f then (t1.d) else t1.e end*t1.d*c) AS integer) from t1) in (e,t1.c,t1.e) then 13 else a end from t1 where d not between t1.b and f),a)) from t1 union select min((t1.b)) from t1) or (t1.e<=13))}\n} {411}\ndo_test randexpr-2.2035 {\n  db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a |  -a*(abs(11 | e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then  -11-a else t1.a end*19+b | t1.a<=t1.e),t1.b)) FROM t1 WHERE t1.e between  -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when  -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c}\n} {}\ndo_test randexpr-2.2036 {\n  db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a |  -a*(abs(11 | e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then  -11-a else t1.a end*19+b | t1.a<=t1.e),t1.b)) FROM t1 WHERE NOT (t1.e between  -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when  -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c)}\n} {300}\ndo_test randexpr-2.2037 {\n  db eval {SELECT (+coalesce((select max(c) from t1 where case when ( -t1.f between t1.a &  -a*(abs(11 & e+case when not exists(select 1 from t1 where t1.b<>f or a=t1.a) then 17*(a) else 17 end*c)/abs(c))-d+f* -e-t1.a and b) then  -11-a else t1.a end*19+b & t1.a<=t1.e),t1.b)) FROM t1 WHERE NOT (t1.e between  -case when e not in (t1.e,case when d+t1.c-b-t1.b+case when  -e<f then + -t1.c*t1.d+a*13*e when ( -t1.f<=a) then f else 13 end*t1.e-a-t1.b<(t1.e) then t1.d else t1.d end,t1.f) then f else t1.d end and t1.c)}\n} {300}\ndo_test randexpr-2.2038 {\n  db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) | ( -cast(avg(b) AS integer) |  - -(count(distinct t1.f)))) when  -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE (abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when  - -((count(distinct f))) then max(a) else count(*) end |  -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1)}\n} {}\ndo_test randexpr-2.2039 {\n  db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) | ( -cast(avg(b) AS integer) |  - -(count(distinct t1.f)))) when  -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE NOT ((abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when  - -((count(distinct f))) then max(a) else count(*) end |  -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1))}\n} {377}\ndo_test randexpr-2.2040 {\n  db eval {SELECT (select +~~ -(count(*))+max((select ~count(*)+count(distinct d)*~cast(avg(19) AS integer)+case count(*)- -abs(abs(~abs(++abs(cast(avg(t1.c) AS integer)))+count(distinct e)+count(*)))+(min(19) & ( -cast(avg(b) AS integer) &  - -(count(distinct t1.f)))) when  -count(*) then max( -b) else max((t1.d)) end from t1)) from t1) FROM t1 WHERE NOT ((abs(c)/abs((select (abs(count(*))) from t1))) not between t1.b and (select abs(count(*)* -~min(~e+case when t1.a+(a)>e then t1.d else a end+f)-case (+min(t1.f)*min(e)+cast(avg(c) AS integer))*count(*) when  - -((count(distinct f))) then max(a) else count(*) end |  -cast(avg(11) AS integer)*count(*))-count(*)*( -max(f)) from t1))}\n} {377}\ndo_test randexpr-2.2041 {\n  db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 | 11+c | f else 19 end) | +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select  -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11))}\n} {400}\ndo_test randexpr-2.2042 {\n  db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 | 11+c | f else 19 end) | +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select  -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE NOT (not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11)))}\n} {}\ndo_test randexpr-2.2043 {\n  db eval {SELECT case when ((select abs((count(*)))+min(case 17 when b then 13 & 11+c & f else 19 end) & +count(*)- - -max(t1.d) from t1) not between 19-case when t1.c not between ~e and (e) then t1.d else t1.c end and t1.e) then t1.d when t1.d in (select  -~count(distinct t1.f)*(min(t1.b)) from t1 union select (cast(avg(17) AS integer)) from t1) then d else t1.b end FROM t1 WHERE not exists(select 1 from t1 where d in (coalesce((select max((select abs(~min(f))++~count(distinct t1.a)+cast(avg(t1.b) AS integer)*cast(avg(13) AS integer) from t1)) from t1 where exists(select 1 from t1 where not not exists(select 1 from t1 where (exists(select 1 from t1 where 11<e or t1.a not between t1.a and c)) or e<t1.f)) or t1.a not in (13,f,13)),case when t1.b>=13 then ~19*13 | t1.c+t1.e when c between t1.d and a then t1.b else t1.d end)-13,17,11))}\n} {400}\ndo_test randexpr-2.2044 {\n  db eval {SELECT case when not exists(select 1 from t1 where e in (select +(count(distinct (abs(case when ((abs(coalesce((select coalesce((select case when c>f and a in (19, -e,t1.c) then +t1.a else t1.e end from t1 where c<b and f=13),13) from t1 where 11 not between t1.f and f and t1.c<=(11)),t1.e))/abs(t1.e))+17)<=c then t1.b when not exists(select 1 from t1 where t1.f in (select c from t1 union select 11 from t1)) then t1.f else 17 end)/abs(t1.e)))) from t1 union select max(t1.e) from t1)) then f else c end*t1.d FROM t1 WHERE (select max(t1.c) from t1) in (t1.f+coalesce((select max(d) from t1 where (c in (select 11*case when e=c then a else t1.f end from t1 union select b from t1)) and t1.c in (select b from t1 union select d from t1) and not exists(select 1 from t1 where t1.c in (t1.a,17,t1.b)) and t1.e=17 or c<>t1.f),(select case abs(count(distinct t1.e)-cast(avg(t1.d) AS integer)*cast(avg(t1.b) AS integer)) when min(19) then count(*) else min(c) end+count(distinct t1.c) from t1))+t1.b,t1.d, -d)}\n} {}\ndo_test randexpr-2.2045 {\n  db eval {SELECT case when not exists(select 1 from t1 where e in (select +(count(distinct (abs(case when ((abs(coalesce((select coalesce((select case when c>f and a in (19, -e,t1.c) then +t1.a else t1.e end from t1 where c<b and f=13),13) from t1 where 11 not between t1.f and f and t1.c<=(11)),t1.e))/abs(t1.e))+17)<=c then t1.b when not exists(select 1 from t1 where t1.f in (select c from t1 union select 11 from t1)) then t1.f else 17 end)/abs(t1.e)))) from t1 union select max(t1.e) from t1)) then f else c end*t1.d FROM t1 WHERE NOT ((select max(t1.c) from t1) in (t1.f+coalesce((select max(d) from t1 where (c in (select 11*case when e=c then a else t1.f end from t1 union select b from t1)) and t1.c in (select b from t1 union select d from t1) and not exists(select 1 from t1 where t1.c in (t1.a,17,t1.b)) and t1.e=17 or c<>t1.f),(select case abs(count(distinct t1.e)-cast(avg(t1.d) AS integer)*cast(avg(t1.b) AS integer)) when min(19) then count(*) else min(c) end+count(distinct t1.c) from t1))+t1.b,t1.d, -d))}\n} {120000}\ndo_test randexpr-2.2046 {\n  db eval {SELECT  -case when  -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c |  -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b | a)-t1.c-(c)<=19))),t1.c) then e else  -t1.d end-(17) FROM t1 WHERE (t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else  -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f)}\n} {}\ndo_test randexpr-2.2047 {\n  db eval {SELECT  -case when  -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c |  -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b | a)-t1.c-(c)<=19))),t1.c) then e else  -t1.d end-(17) FROM t1 WHERE NOT ((t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else  -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f))}\n} {-517}\ndo_test randexpr-2.2048 {\n  db eval {SELECT  -case when  -b=t1.c then t1.a when (select min(t1.b) from t1)<=d+coalesce((select max(11+a) from t1 where (not exists(select 1 from t1 where c &  -((case case when (t1.f between a and t1.b) then b else c end-t1.c when 19 then t1.c else f end+t1.c)+t1.b & a)-t1.c-(c)<=19))),t1.c) then e else  -t1.d end-(17) FROM t1 WHERE NOT ((t1.b | case t1.b when ((t1.e)) then (abs(19)/abs(t1.a))-coalesce((select max(t1.e*case b when a then 11 else t1.a end) from t1 where +~case when 13=17 and t1.e+11 in (select t1.f from t1 union select t1.d from t1) then t1.b when (b<17 and a>= -17) then f else  -t1.e end+(17)<=13),d) else b end | b between t1.d and t1.f))}\n} {-517}\ndo_test randexpr-2.2049 {\n  db eval {SELECT case when not c<b and case when not (11 not in (c+b+t1.d- -13+e,(select  -min((case (abs(t1.a)/abs(a)) when 13 then b else  -19 end+11)) from t1),d)) and 13 in (19,t1.c,t1.e) then t1.b else 17 end<=~t1.e then +b*t1.c else t1.b end FROM t1 WHERE (abs(a)/abs(coalesce((select (e) from t1 where case when not d<=c then b else (19) end in (select ~( -(~(((count(*)))) | (count(distinct t1.e)))+min(t1.b)-(cast(avg(d) AS integer))-count(distinct b))-min(e)*max(t1.a) from t1 union select count(distinct f) from t1)),19 | t1.b)*t1.c+13)) in (select ~ -count(distinct e)*max((b)) | min(a) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.2050 {\n  db eval {SELECT case when not c<b and case when not (11 not in (c+b+t1.d- -13+e,(select  -min((case (abs(t1.a)/abs(a)) when 13 then b else  -19 end+11)) from t1),d)) and 13 in (19,t1.c,t1.e) then t1.b else 17 end<=~t1.e then +b*t1.c else t1.b end FROM t1 WHERE NOT ((abs(a)/abs(coalesce((select (e) from t1 where case when not d<=c then b else (19) end in (select ~( -(~(((count(*)))) | (count(distinct t1.e)))+min(t1.b)-(cast(avg(d) AS integer))-count(distinct b))-min(e)*max(t1.a) from t1 union select count(distinct f) from t1)),19 | t1.b)*t1.c+13)) in (select ~ -count(distinct e)*max((b)) | min(a) from t1 union select count(*) from t1))}\n} {200}\ndo_test randexpr-2.2051 {\n  db eval {SELECT +11+~coalesce((select  -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f | t1.d),19),t1.a) then (t1.d) when  -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE (select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else  -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then  - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else  -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13)}\n} {}\ndo_test randexpr-2.2052 {\n  db eval {SELECT +11+~coalesce((select  -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f | t1.d),19),t1.a) then (t1.d) when  -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE NOT ((select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else  -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then  - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else  -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13))}\n} {317}\ndo_test randexpr-2.2053 {\n  db eval {SELECT +11+~coalesce((select  -19 from t1 where exists(select 1 from t1 where f*t1.e not in ( -f*~t1.a-f*case when t1.f in ((e),coalesce((select b from t1 where b>=t1.f & t1.d),19),t1.a) then (t1.d) when  -a<=( -t1.a) then a else f end*a,13,19)) or e=17),a)*17 FROM t1 WHERE NOT ((select case min(+19) when abs((max(17)* -min(a*(abs(case e when t1.b then t1.f else  -t1.c end*f)/abs(t1.d))*e)-count(*) | max(19))) then  - -case count(distinct 11) when min(11) then max(19) else min(13) end-( -count(distinct 13)) else  -(count(distinct b)) end*cast(avg(17) AS integer)-max(e) from t1) between t1.d and coalesce((select max(13) from t1 where not 17>a-f-e),13))}\n} {317}\ndo_test randexpr-2.2054 {\n  db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f | 11 | 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or  - -t1.f<t1.f)),13) FROM t1 WHERE a not in (f,t1.e,11)}\n} {13}\ndo_test randexpr-2.2055 {\n  db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f | 11 | 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or  - -t1.f<t1.f)),13) FROM t1 WHERE NOT (a not in (f,t1.e,11))}\n} {}\ndo_test randexpr-2.2056 {\n  db eval {SELECT coalesce((select 11 from t1 where (b-case (select count(distinct t1.f*e) from t1) when t1.f & 11 & 11*coalesce((select 19 from t1 where (~coalesce((select f from t1 where (t1.c>17)),a)+t1.c not between f and t1.e or 19>=c)),(t1.d)) then a else t1.f end>=f and exists(select 1 from t1 where 13<>c) or  - -t1.f<t1.f)),13) FROM t1 WHERE a not in (f,t1.e,11)}\n} {13}\ndo_test randexpr-2.2057 {\n  db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c | case when t1.b in (select  -max(t1.b)*cast(avg(19) AS integer) from t1 union select  -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where  -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c)}\n} {0}\ndo_test randexpr-2.2058 {\n  db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c | case when t1.b in (select  -max(t1.b)*cast(avg(19) AS integer) from t1 union select  -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where  -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE NOT (t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c))}\n} {}\ndo_test randexpr-2.2059 {\n  db eval {SELECT (abs(coalesce((select max(t1.e) from t1 where c>coalesce((select max(coalesce((select t1.e from t1 where not (abs(a+t1.e*c & case when t1.b in (select  -max(t1.b)*cast(avg(19) AS integer) from t1 union select  -max(13) from t1) then t1.f else 19 end-f+(19)+19)/abs(t1.e)) in (d,13,e) or t1.e<=t1.e),t1.b-17)) from t1 where  -11<>17 or e in (select max(19) from t1 union select (cast(avg(f) AS integer)) from t1)),a)),17))/abs(t1.e)) FROM t1 WHERE t1.e<>13 | (t1.f)+c-((13))-~13 | (abs(e)/abs(coalesce((select max(t1.c) from t1 where (d)<=t1.d),case when (exists(select 1 from t1 where not exists(select 1 from t1 where (abs(17)/abs(t1.d))>coalesce((select max(a) from t1 where t1.c not between t1.f and t1.f and f not in (t1.f, -t1.c,13)),t1.c)))) then c else 19 end))) | t1.a*11* -e*t1.c or not exists(select 1 from t1 where f>c)}\n} {0}\ndo_test randexpr-2.2060 {\n  db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when  -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and  -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then  -e*t1.d else 17 end | t1.e else t1.b end FROM t1 WHERE f+17<=17}\n} {}\ndo_test randexpr-2.2061 {\n  db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when  -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and  -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then  -e*t1.d else 17 end | t1.e else t1.b end FROM t1 WHERE NOT (f+17<=17)}\n} {200}\ndo_test randexpr-2.2062 {\n  db eval {SELECT case t1.e when a then case when not exists(select 1 from t1 where (abs(~coalesce((select c from t1 where (case when not case when a between t1.b and t1.a then t1.c when  -17 not in (11,t1.d,11) then a else t1.a end in (select count(distinct t1.a)+count(distinct t1.a) from t1 union select count(*) from t1) then t1.c when t1.b<(11) then f else a end>=11 and (t1.f)=11)),+11))/abs(e)) not between 17 and  -t1.a) or c not between 19 and t1.b then t1.c when t1.e<t1.a then  -e*t1.d else 17 end & t1.e else t1.b end FROM t1 WHERE NOT (f+17<=17)}\n} {200}\ndo_test randexpr-2.2063 {\n  db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e | coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when  -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE b=b}\n} {400}\ndo_test randexpr-2.2064 {\n  db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e | coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when  -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE NOT (b=b)}\n} {}\ndo_test randexpr-2.2065 {\n  db eval {SELECT ~~coalesce((select t1.a from t1 where case f*+e when ~11-coalesce((select max(t1.f) from t1 where t1.f>b),~case when b between 17 and e & coalesce((select max(a) from t1 where (f in (t1.b,f,a))),13) then f when  -d<=d then t1.e else e end+13)+13 then d else d end+t1.f=d),b)+b FROM t1 WHERE b=b}\n} {400}\ndo_test randexpr-2.2066 {\n  db eval {SELECT e | t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE 13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else  -c end from t1 union select t1.a from t1) or f<c}\n} {}\ndo_test randexpr-2.2067 {\n  db eval {SELECT e | t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE NOT (13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else  -c end from t1 union select t1.a from t1) or f<c)}\n} {18000200180}\ndo_test randexpr-2.2068 {\n  db eval {SELECT e & t1.e*case d when t1.e then a else case when t1.a<= -~+e then b else 17-t1.e end*c*f+case when case when +c in (select +min(11) from t1 union select cast(avg(f) AS integer) from t1) and b between c and t1.f then 11+t1.a when f>=c then d else t1.c end<t1.c and t1.d between t1.a and t1.e then 19 when t1.a<=t1.c then t1.d else f end end FROM t1 WHERE NOT (13 in (select case when ++(select abs(max((select count(*) from t1)+~13)) from t1)*11 not in ((d*~19),(abs(f)/abs(t1.b)),case when not exists(select 1 from t1 where b<=e+t1.d) then b*f when d in (select min(t1.d) from t1 union select min(e) from t1) then 19 else f end*a) then t1.c else  -c end from t1 union select t1.a from t1) or f<c)}\n} {320}\ndo_test randexpr-2.2069 {\n  db eval {SELECT coalesce((select  -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) | abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d}\n} {}\ndo_test randexpr-2.2070 {\n  db eval {SELECT coalesce((select  -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) | abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE NOT (t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d)}\n} {-1800}\ndo_test randexpr-2.2071 {\n  db eval {SELECT coalesce((select  -(select min(f)-+min(f)*~case +cast(avg(t1.e) AS integer) when max(13)-abs( -max(a)) then +count(distinct a) & abs(max( -c+13)) else (count(*)) end from t1) from t1 where t1.a<>t1.e), -t1.d) FROM t1 WHERE NOT (t1.b between coalesce((select (coalesce((select max(case when case when not exists(select 1 from t1 where (17) not in (13,case when 19 not in (19,t1.f,t1.e) and b>=t1.a then e when b<=t1.c then 11 else b end,11)) then c | t1.a else 17 end | 19 in (c,t1.b,d) then t1.a else t1.a end | t1.c) from t1 where not exists(select 1 from t1 where t1.a<=t1.e)),t1.c)) from t1 where t1.d<=t1.a),17)*c-11 and d)}\n} {-1800}\ndo_test randexpr-2.2072 {\n  db eval {SELECT coalesce((select c from t1 where case when +case when not 11 | c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else  - -f end>=19 and b<=e),d) FROM t1 WHERE (+a*t1.a+(19-(abs(case  -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when  -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b))}\n} {300}\ndo_test randexpr-2.2073 {\n  db eval {SELECT coalesce((select c from t1 where case when +case when not 11 | c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else  - -f end>=19 and b<=e),d) FROM t1 WHERE NOT ((+a*t1.a+(19-(abs(case  -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when  -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b)))}\n} {}\ndo_test randexpr-2.2074 {\n  db eval {SELECT coalesce((select c from t1 where case when +case when not 11 & c not in (11,case when 13> -d then e when a>t1.c then 17 else t1.e end,t1.b) then t1.d when c<>t1.a then t1.b else 19 end-b>=17 or 11<t1.c then case when not exists(select 1 from t1 where not exists(select 1 from t1 where t1.f<t1.c)) then t1.f when not exists(select 1 from t1 where 19 not in (t1.d,t1.b,t1.a)) then t1.c else t1.a end else  - -f end>=19 and b<=e),d) FROM t1 WHERE (+a*t1.a+(19-(abs(case  -c when d then (abs(f)/abs(case t1.a when 19 then b else +~( -case t1.f*t1.a | 17 when  -t1.a then d else (t1.e) end*d)+t1.a-a end)) else 13 end)/abs(11))*t1.c)+17-d not in (11,a,b))}\n} {300}\ndo_test randexpr-2.2075 {\n  db eval {SELECT case 17 when t1.c then t1.c*f | t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then  -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE ~17 between (select  -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e}\n} {400}\ndo_test randexpr-2.2076 {\n  db eval {SELECT case 17 when t1.c then t1.c*f | t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then  -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE NOT (~17 between (select  -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e)}\n} {}\ndo_test randexpr-2.2077 {\n  db eval {SELECT case 17 when t1.c then t1.c*f & t1.b+t1.d+b+c-t1.e+t1.c+t1.c-t1.c*t1.f else case when t1.f+case when (abs(t1.a-coalesce((select a from t1 where (t1.c) in (t1.c,d,19)), -t1.a))/abs(f)) between t1.c and a then  -(t1.b) else b end not in (11, -t1.d,t1.d) then t1.d else d end end FROM t1 WHERE ~17 between (select  -count(distinct b+b)++max(t1.b)*(~(max(t1.d)))-abs(cast(avg(17) AS integer)*count(*))-max(f) | count(distinct t1.a)-count(distinct 13)-cast(avg(c) AS integer) from t1) and c-case when f<>t1.e then (abs(~(a)+e+t1.a | t1.a)/abs(t1.c)) else 13 end- -t1.e}\n} {400}\ndo_test randexpr-2.2078 {\n  db eval {SELECT (select cast(avg(coalesce((select max(coalesce((select e from t1 where not ((coalesce((select b from t1 where coalesce((select max(11) from t1 where exists(select 1 from t1 where (a in (select count(*)+max(((t1.a))) from t1 union select cast(avg(a) AS integer) from t1)))),b)<=19), -b))*f<t1.b and not exists(select 1 from t1 where d>=t1.e) and 17<>11 and e in (t1.f,f,17)) or a not between  -a and (17)),+~b)-17*b) from t1 where t1.b>=b),t1.a)) AS integer) from t1) FROM t1 WHERE f in (select cast(avg(t1.e-f-t1.e) AS integer)+min(t1.d) from t1 union select max(case b when 11 then case case when f in (a,a,f) then t1.b when (t1.f)>d then  -19 else t1.a end when 11 then a else t1.e end else (t1.b) end*a)*cast(avg(a) AS integer)+ -+cast(avg(t1.e) AS integer)*case cast(avg(t1.e) AS integer) when (cast(avg( -t1.a) AS integer)) then count(*) else count(*) end*min(t1.d)*min(e) from t1) and (a between d and t1.f)}\n} {}\ndo_test randexpr-2.2079 {\n  db eval {SELECT (select cast(avg(coalesce((select max(coalesce((select e from t1 where not ((coalesce((select b from t1 where coalesce((select max(11) from t1 where exists(select 1 from t1 where (a in (select count(*)+max(((t1.a))) from t1 union select cast(avg(a) AS integer) from t1)))),b)<=19), -b))*f<t1.b and not exists(select 1 from t1 where d>=t1.e) and 17<>11 and e in (t1.f,f,17)) or a not between  -a and (17)),+~b)-17*b) from t1 where t1.b>=b),t1.a)) AS integer) from t1) FROM t1 WHERE NOT (f in (select cast(avg(t1.e-f-t1.e) AS integer)+min(t1.d) from t1 union select max(case b when 11 then case case when f in (a,a,f) then t1.b when (t1.f)>d then  -19 else t1.a end when 11 then a else t1.e end else (t1.b) end*a)*cast(avg(a) AS integer)+ -+cast(avg(t1.e) AS integer)*case cast(avg(t1.e) AS integer) when (cast(avg( -t1.a) AS integer)) then count(*) else count(*) end*min(t1.d)*min(e) from t1) and (a between d and t1.f))}\n} {-2900}\ndo_test randexpr-2.2080 {\n  db eval {SELECT case when coalesce((select max(coalesce((select max((select min(13) from t1)*d*case when not 19<>(t1.c)-d then 11 else 17 end) from t1 where 13<t1.f and t1.e not between (t1.a) and d),c)) from t1 where t1.d between (d) and 19 or t1.c in (t1.f,(11),17)), -11)>=t1.e then t1.d when not exists(select 1 from t1 where t1.c in (select (count(*)) from t1 union select +count(*) from t1)) then t1.c else 19 end FROM t1 WHERE ((11>=11))}\n} {300}\ndo_test randexpr-2.2081 {\n  db eval {SELECT case when coalesce((select max(coalesce((select max((select min(13) from t1)*d*case when not 19<>(t1.c)-d then 11 else 17 end) from t1 where 13<t1.f and t1.e not between (t1.a) and d),c)) from t1 where t1.d between (d) and 19 or t1.c in (t1.f,(11),17)), -11)>=t1.e then t1.d when not exists(select 1 from t1 where t1.c in (select (count(*)) from t1 union select +count(*) from t1)) then t1.c else 19 end FROM t1 WHERE NOT (((11>=11)))}\n} {}\ndo_test randexpr-2.2082 {\n  db eval {SELECT  -case when 19 in (select abs((count(*))) from t1 union select abs(min(t1.f)*min(e*e)) from t1) and case when not not (17>a) or d>=c and (19)<=t1.b and  - -t1.f<>t1.f then f when t1.b between d and t1.f then case when t1.e=e then coalesce((select max(d) from t1 where t1.b>=b),a) when t1.a not between c and e then e else 13 end else (17) end>t1.d then b else b end+t1.b-a FROM t1 WHERE exists(select 1 from t1 where +coalesce((select 19 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where case when (select max(11-(select +count(distinct +case + -coalesce((select t1.d from t1 where exists(select 1 from t1 where (b)>t1.c)),t1.f)*11 when  -a then 19 else 19 end) from t1)) from t1)<=t1.d-c then f when exists(select 1 from t1 where t1.f not between b and a) then  -d else t1.d end not in (t1.b,t1.e, -t1.f)))),f) not in (f,e,13))}\n} {}\ndo_test randexpr-2.2083 {\n  db eval {SELECT  -case when 19 in (select abs((count(*))) from t1 union select abs(min(t1.f)*min(e*e)) from t1) and case when not not (17>a) or d>=c and (19)<=t1.b and  - -t1.f<>t1.f then f when t1.b between d and t1.f then case when t1.e=e then coalesce((select max(d) from t1 where t1.b>=b),a) when t1.a not between c and e then e else 13 end else (17) end>t1.d then b else b end+t1.b-a FROM t1 WHERE NOT (exists(select 1 from t1 where +coalesce((select 19 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where case when (select max(11-(select +count(distinct +case + -coalesce((select t1.d from t1 where exists(select 1 from t1 where (b)>t1.c)),t1.f)*11 when  -a then 19 else 19 end) from t1)) from t1)<=t1.d-c then f when exists(select 1 from t1 where t1.f not between b and a) then  -d else t1.d end not in (t1.b,t1.e, -t1.f)))),f) not in (f,e,13)))}\n} {-100}\ndo_test randexpr-2.2084 {\n  db eval {SELECT coalesce((select max(b) from t1 where d not between a-t1.e and a),coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where t1.e<t1.a)),e)+19) FROM t1 WHERE +case f when case  -~c-case when d=17 then t1.c*(select abs(case (cast(avg(19) AS integer)) when ( -count(*)) then min(19) else count(*) end*min(a)) from t1) when b* -(e)-t1.b in (select max(19) | max(t1.c) from t1 union select max(17) from t1) then c else a end when  -f then 13 else 19 end then t1.d else t1.c end<>e or 11 between b and 13}\n} {200}\ndo_test randexpr-2.2085 {\n  db eval {SELECT coalesce((select max(b) from t1 where d not between a-t1.e and a),coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where t1.e<t1.a)),e)+19) FROM t1 WHERE NOT (+case f when case  -~c-case when d=17 then t1.c*(select abs(case (cast(avg(19) AS integer)) when ( -count(*)) then min(19) else count(*) end*min(a)) from t1) when b* -(e)-t1.b in (select max(19) | max(t1.c) from t1 union select max(17) from t1) then c else a end when  -f then 13 else 19 end then t1.d else t1.c end<>e or 11 between b and 13)}\n} {}\ndo_test randexpr-2.2086 {\n  db eval {SELECT (select case count(*) when ~(case case  -abs(count(*) | (case case ~case  -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else  -count(*) end when  -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then  -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end | max(11) from t1)+19 FROM t1 WHERE case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11}\n} {30}\ndo_test randexpr-2.2087 {\n  db eval {SELECT (select case count(*) when ~(case case  -abs(count(*) | (case case ~case  -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else  -count(*) end when  -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then  -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end | max(11) from t1)+19 FROM t1 WHERE NOT (case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11)}\n} {}\ndo_test randexpr-2.2088 {\n  db eval {SELECT (select case count(*) when ~(case case  -abs(count(*) & (case case ~case  -count(distinct case when t1.a< -t1.d then b when 19 in (t1.e, - -19,t1.b) then t1.c else t1.f end)-count(distinct (t1.f)) when count(*) then max(c) else count(distinct 17) end when count(*) then ((cast(avg(b) AS integer))) else  -count(*) end when  -count(distinct t1.f) then count(distinct t1.a) else count(distinct t1.e) end))+count(*) when cast(avg(19) AS integer) then  -min( -t1.c) else count(*) end when (min(t1.e)) then cast(avg(c) AS integer) else min(t1.f) end) then min(e) else count(*) end & max(11) from t1)+19 FROM t1 WHERE case when (((d not between (+t1.a-coalesce((select max(b*t1.b* -t1.f) from t1 where a>a),13)) and a)) and c>=d or f<c) then coalesce((select (abs(17)/abs(13))*e from t1 where f in (t1.a,13,t1.b) and (t1.c)<>e and t1.c< -11 and f<>b or t1.b<17),c) else t1.a end>=11}\n} {20}\ndo_test randexpr-2.2089 {\n  db eval {SELECT case when case when t1.a*~t1.a-19-c | 17+t1.d*f*c=d then f else  -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select  - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17}\n} {400}\ndo_test randexpr-2.2090 {\n  db eval {SELECT case when case when t1.a*~t1.a-19-c | 17+t1.d*f*c=d then f else  -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE NOT (not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select  - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17)}\n} {}\ndo_test randexpr-2.2091 {\n  db eval {SELECT case when case when t1.a*~t1.a-19-c & 17+t1.d*f*c=d then f else  -13 end+t1.b+a in (t1.f,t1.d,t1.f) and (not c=11) and t1.e<>f then coalesce((select f from t1 where t1.d not in (t1.e,f,11)), -17) else f end-b FROM t1 WHERE not exists(select 1 from t1 where +d between d*13 and ((abs(13+e+e)/abs(+case when not t1.c in (~(select cast(avg(case e when b then 11 else 13 end) AS integer) from t1)*b*17,t1.e,t1.e) then 11* -c when t1.f in (select min(e)*count(distinct c) from t1 union select  - - - -max(e) | cast(avg((d)) AS integer) from t1) then (c) else e end)))) or d<17}\n} {400}\ndo_test randexpr-2.2092 {\n  db eval {SELECT coalesce((select c from t1 where t1.b between t1.b and  -17),coalesce((select  -t1.e from t1 where (select count(distinct coalesce((select case t1.b-t1.a*(b)*13 when 11 then (a) else 11 end from t1 where a not in ((t1.e),c,11) and e>b),13)) from t1) in (t1.d,b,13) and not t1.b<13 or 11<> -17 or (11)>17 or t1.f not between b and (t1.a)),(b))) FROM t1 WHERE ((+case +d when f then (d) else case t1.f-(b)-11 when d then  -t1.c else a end end not in ( -17,(t1.d),13) and (11 not in ((c),t1.f,t1.d)) and (e in (select 13 from t1 union select t1.a from t1) and d in (select t1.e from t1 union select 19 from t1))) or exists(select 1 from t1 where  -t1.a= -t1.d)) and exists(select 1 from t1 where t1.b not between f and e or 19>=t1.d)}\n} {}\ndo_test randexpr-2.2093 {\n  db eval {SELECT coalesce((select c from t1 where t1.b between t1.b and  -17),coalesce((select  -t1.e from t1 where (select count(distinct coalesce((select case t1.b-t1.a*(b)*13 when 11 then (a) else 11 end from t1 where a not in ((t1.e),c,11) and e>b),13)) from t1) in (t1.d,b,13) and not t1.b<13 or 11<> -17 or (11)>17 or t1.f not between b and (t1.a)),(b))) FROM t1 WHERE NOT (((+case +d when f then (d) else case t1.f-(b)-11 when d then  -t1.c else a end end not in ( -17,(t1.d),13) and (11 not in ((c),t1.f,t1.d)) and (e in (select 13 from t1 union select t1.a from t1) and d in (select t1.e from t1 union select 19 from t1))) or exists(select 1 from t1 where  -t1.a= -t1.d)) and exists(select 1 from t1 where t1.b not between f and e or 19>=t1.d))}\n} {-500}\ndo_test randexpr-2.2094 {\n  db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select  -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then  -d else b end-b | t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c}\n} {}\ndo_test randexpr-2.2095 {\n  db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select  -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then  -d else b end-b | t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE NOT (t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c)}\n} {200}\ndo_test randexpr-2.2096 {\n  db eval {SELECT case d when f then case when (abs(coalesce((select ~f*case when t1.f<(select  -count(distinct (select count(*)-min(13) from t1)) from t1) then d when t1.d between t1.b and f and not (t1.b between ( -t1.f) and f) then  -d else b end-b & t1.f*17 from t1 where ((d>t1.d))),17))/abs(11))-13=t1.c then a else 11 end else b end FROM t1 WHERE NOT (t1.b between coalesce((select case when coalesce((select t1.c from t1 where not ((t1.a>=11+17 and (13+(11)<>13))) and b<=c and c in (c, -c,(e)) and d not in (f,b,c) or t1.d>=13 and 13 between 19 and a),d) not between 13-case when t1.f<>t1.b then t1.f else t1.c end | d and d then b when c<c then 13 else 11 end*t1.e from t1 where b>= -d),19) and c)}\n} {200}\ndo_test randexpr-2.2097 {\n  db eval {SELECT (coalesce((select case when exists(select 1 from t1 where case when (t1.b)>=f+e*coalesce((select max( -+t1.c) from t1 where case a when e then e else 11 end in (select 17 from t1 union select d from t1) or e not between d and a),t1.f) then ( -t1.d) else e end in (11,c,b)) then 17 else t1.f end+t1.f from t1 where not d in ((b),(f),11) and t1.f<f),19)) FROM t1 WHERE exists(select 1 from t1 where coalesce((select max(case when t1.d in (select  -a from t1 union select 11 from t1) then t1.b when case when t1.f not in (t1.d, -19,t1.e) and t1.a>=t1.b and 19<13 then 19 else 13 end<a then e else b end) from t1 where t1.f in (select +count(distinct  - -13)* - -case max(t1.f) when max(13) then (min(t1.c)) else (max(t1.b)) end from t1 union select cast(avg(t1.a) AS integer) from t1) or t1.e not in (b,17,e)), -17)>=19) and b not in (c,t1.a,d) or b between e and  -t1.f or t1.b between t1.e and c and t1.a<=t1.d}\n} {}\ndo_test randexpr-2.2098 {\n  db eval {SELECT (coalesce((select case when exists(select 1 from t1 where case when (t1.b)>=f+e*coalesce((select max( -+t1.c) from t1 where case a when e then e else 11 end in (select 17 from t1 union select d from t1) or e not between d and a),t1.f) then ( -t1.d) else e end in (11,c,b)) then 17 else t1.f end+t1.f from t1 where not d in ((b),(f),11) and t1.f<f),19)) FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select max(case when t1.d in (select  -a from t1 union select 11 from t1) then t1.b when case when t1.f not in (t1.d, -19,t1.e) and t1.a>=t1.b and 19<13 then 19 else 13 end<a then e else b end) from t1 where t1.f in (select +count(distinct  - -13)* - -case max(t1.f) when max(13) then (min(t1.c)) else (max(t1.b)) end from t1 union select cast(avg(t1.a) AS integer) from t1) or t1.e not in (b,17,e)), -17)>=19) and b not in (c,t1.a,d) or b between e and  -t1.f or t1.b between t1.e and c and t1.a<=t1.d)}\n} {19}\ndo_test randexpr-2.2099 {\n  db eval {SELECT 11+17+case when case 17 when coalesce((select max(d) from t1 where 13+(t1.c-e)+19+e-t1.e>=b and not 11 not in (19,t1.e,13) and (t1.f)>b),19)*19 then c else  -d end not in (c,19,t1.c) then d when d<=t1.d then 13 else 11 end+ -a FROM t1 WHERE coalesce((select max(~t1.f) from t1 where (13*t1.e)<=case when 17 | a<=t1.e then coalesce((select max(19) from t1 where case when not not exists(select 1 from t1 where 19 in (t1.d+19,11,t1.f) or not exists(select 1 from t1 where a<e)) then case when t1.d<(t1.b) then t1.d when 13>=t1.c then  - -11 else t1.b end else f end-f<=b),t1.b) else t1.e end),f)-19>=13}\n} {328}\ndo_test randexpr-2.2100 {\n  db eval {SELECT 11+17+case when case 17 when coalesce((select max(d) from t1 where 13+(t1.c-e)+19+e-t1.e>=b and not 11 not in (19,t1.e,13) and (t1.f)>b),19)*19 then c else  -d end not in (c,19,t1.c) then d when d<=t1.d then 13 else 11 end+ -a FROM t1 WHERE NOT (coalesce((select max(~t1.f) from t1 where (13*t1.e)<=case when 17 | a<=t1.e then coalesce((select max(19) from t1 where case when not not exists(select 1 from t1 where 19 in (t1.d+19,11,t1.f) or not exists(select 1 from t1 where a<e)) then case when t1.d<(t1.b) then t1.d when 13>=t1.c then  - -11 else t1.b end else f end-f<=b),t1.b) else t1.e end),f)-19>=13)}\n} {}\ndo_test randexpr-2.2101 {\n  db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when  -coalesce((select (t1.e) from t1 where  -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and  -t1.e) then e else t1.a end)) | count(*) from t1 union select  -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between  -d and  -t1.e or t1.f not between d and a and  -b=19),t1.b) else +t1.f end not between a and e}\n} {-99}\ndo_test randexpr-2.2102 {\n  db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when  -coalesce((select (t1.e) from t1 where  -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and  -t1.e) then e else t1.a end)) | count(*) from t1 union select  -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE NOT (case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between  -d and  -t1.e or t1.f not between d and a and  -b=19),t1.b) else +t1.f end not between a and e)}\n} {}\ndo_test randexpr-2.2103 {\n  db eval {SELECT coalesce((select max(t1.a+(select count(distinct 11-case when coalesce((select max(11) from t1 where t1.f<(t1.a)-t1.b),b) in (select ~abs(min(c-case when (case 13 when  -coalesce((select (t1.e) from t1 where  -a not in (f,t1.d,d)),(11)) then b else t1.e end not between b and  -t1.e) then e else t1.a end)) & count(*) from t1 union select  -min(17) from t1) then t1.a else t1.d end) from t1)-t1.b) from t1 where 17<t1.e),t1.e) FROM t1 WHERE case when not (not exists(select 1 from t1 where c*case when (a>11) then e else a end-t1.c+(d)*(13) in (select ~count(distinct (t1.f))+ -~ -count(distinct t1.e)+(min(13)) from t1 union select cast(avg(11) AS integer) from t1) or t1.e<>t1.f)) then f when not a<19 then coalesce((select max(11) from t1 where (t1.d) between  -d and  -t1.e or t1.f not between d and a and  -b=19),t1.b) else +t1.f end not between a and e}\n} {-99}\ndo_test randexpr-2.2104 {\n  db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) | count(*) | cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select  -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select  -a from t1) then t1.c when b<=c then t1.a else  -13 end)))))),19)}\n} {-500}\ndo_test randexpr-2.2105 {\n  db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) | count(*) | cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE NOT (t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select  -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select  -a from t1) then t1.c when b<=c then t1.a else  -13 end)))))),19))}\n} {}\ndo_test randexpr-2.2106 {\n  db eval {SELECT t1.b-case when 13 not between 13 and (select +count(*) from t1) then t1.e when +11 in (coalesce((select t1.f from t1 where d-((f))*coalesce((select d from t1 where 17 between ~(select max(d) & count(*) & cast(avg(e) AS integer)+count(*) from t1) and case when c<13 or 17>13 then a else e end-t1.b),e)-t1.a<=(t1.e)),19),b,13) then e else b end-t1.b FROM t1 WHERE t1.b>=coalesce((select max(d-c) from t1 where exists(select 1 from t1 where (~a*(select  -count(distinct 11-d*13+d+19) from t1)* -b in (f,t1.d-c,a-(abs(c)/abs(case when (abs(13- -(19))/abs(t1.f)) in (select c from t1 union select  -a from t1) then t1.c when b<=c then t1.a else  -13 end)))))),19)}\n} {-500}\ndo_test randexpr-2.2107 {\n  db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) | abs(count(distinct t1.a) | min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where  -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19}\n} {}\ndo_test randexpr-2.2108 {\n  db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) | abs(count(distinct t1.a) | min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE NOT (case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where  -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19)}\n} {240000}\ndo_test randexpr-2.2109 {\n  db eval {SELECT t1.f*case when c*case when t1.d*t1.b-(~19) in (select (cast(avg(d-t1.d) AS integer)) from t1 union select min(11)+cast(avg(e) AS integer) & abs(count(distinct t1.a) & min(19)) from t1) then t1.d when not 11 not in (d,t1.e,13) then t1.a else 11 end in (select (t1.c) from t1 union select 11 from t1) or t1.e not in (f, -t1.f,t1.e) then c else d end FROM t1 WHERE NOT (case when t1.e=t1.c and (abs(case when (11* -17 not in (c,t1.f-t1.c-coalesce((select max(c) from t1 where c in (select min(19) from t1 union select ~count(*)*max(t1.f) from t1)),a),t1.a)) then coalesce((select max(17) from t1 where  -b>=(t1.c)),19) else f end+19)/abs(t1.f))*t1.d between d and b then t1.b-t1.e else c end=19)}\n} {240000}\ndo_test randexpr-2.2110 {\n  db eval {SELECT coalesce((select max((abs(t1.d)/abs((coalesce((select c from t1 where (abs(+f)/abs(t1.b))-t1.a between 13 and case (13+c+((abs(coalesce((select 11 from t1 where 11+19<b),case t1.f when t1.f then b else 11 end)*a)/abs(c)))+t1.f) when f then  -c else t1.f end),e)-t1.e*19)))) from t1 where e<e),t1.c) FROM t1 WHERE c in (select c+19 from t1 union select +t1.f from t1) and t1.e<case when case (abs(t1.a)/abs(t1.b))-coalesce((select (abs(e+t1.e | b)/abs(e))*13 from t1 where (c=11) and b< -f or 13=b or  -d< -(e)),b) when e then 11 else t1.e end between b and (19) then t1.b else c end}\n} {}\ndo_test randexpr-2.2111 {\n  db eval {SELECT coalesce((select max((abs(t1.d)/abs((coalesce((select c from t1 where (abs(+f)/abs(t1.b))-t1.a between 13 and case (13+c+((abs(coalesce((select 11 from t1 where 11+19<b),case t1.f when t1.f then b else 11 end)*a)/abs(c)))+t1.f) when f then  -c else t1.f end),e)-t1.e*19)))) from t1 where e<e),t1.c) FROM t1 WHERE NOT (c in (select c+19 from t1 union select +t1.f from t1) and t1.e<case when case (abs(t1.a)/abs(t1.b))-coalesce((select (abs(e+t1.e | b)/abs(e))*13 from t1 where (c=11) and b< -f or 13=b or  -d< -(e)),b) when e then 11 else t1.e end between b and (19) then t1.b else c end)}\n} {300}\ndo_test randexpr-2.2112 {\n  db eval {SELECT f+coalesce((select max(t1.f) from t1 where (case when 13<>a then (coalesce((select  -e from t1 where case coalesce((select case when 19 in (select t1.e from t1 union select f from t1) then b when t1.c=11 then a else (13) end from t1 where t1.a in (select ( -cast(avg(13) AS integer)+max(t1.e)) from t1 union select cast(avg(19) AS integer) from t1)),19) when f then f else ( -t1.c) end+17<=e and a>=t1.b or t1.c>=b),t1.e)) else e end)>=e),b)+f FROM t1 WHERE exists(select 1 from t1 where 17 in (select  -abs(case (min(t1.b)) when count(*)*max(a) then  -abs((max(e))) | ~max( -coalesce((select max(coalesce((select e from t1 where f>=11 or exists(select 1 from t1 where 11 not in (11,t1.c,f))),d)) from t1 where 13=t1.d and 17<>f),t1.d))+count(distinct t1.e) else count(*)+~cast(avg(t1.f) AS integer) end | count(distinct t1.a))+count(distinct t1.a) from t1 union select count(*) from t1))}\n} {}\ndo_test randexpr-2.2113 {\n  db eval {SELECT f+coalesce((select max(t1.f) from t1 where (case when 13<>a then (coalesce((select  -e from t1 where case coalesce((select case when 19 in (select t1.e from t1 union select f from t1) then b when t1.c=11 then a else (13) end from t1 where t1.a in (select ( -cast(avg(13) AS integer)+max(t1.e)) from t1 union select cast(avg(19) AS integer) from t1)),19) when f then f else ( -t1.c) end+17<=e and a>=t1.b or t1.c>=b),t1.e)) else e end)>=e),b)+f FROM t1 WHERE NOT (exists(select 1 from t1 where 17 in (select  -abs(case (min(t1.b)) when count(*)*max(a) then  -abs((max(e))) | ~max( -coalesce((select max(coalesce((select e from t1 where f>=11 or exists(select 1 from t1 where 11 not in (11,t1.c,f))),d)) from t1 where 13=t1.d and 17<>f),t1.d))+count(distinct t1.e) else count(*)+~cast(avg(t1.f) AS integer) end | count(distinct t1.a))+count(distinct t1.a) from t1 union select count(*) from t1)))}\n} {1400}\ndo_test randexpr-2.2114 {\n  db eval {SELECT case when case when (abs( -t1.b)/abs(case case case (select ~ -(+abs(case min(19) when (( -min(t1.e))) then count(distinct (t1.e)) else cast(avg(11) AS integer) end)) from t1) when t1.e then (select min(19) from t1) else 17 end when (13)-a*17 then t1.d else t1.a end when a then 19 else  -( -f) end))>=d then t1.e else 13 end between f and 19 then f when t1.c<=t1.a or (t1.b>(11)) then 11 else t1.b end FROM t1 WHERE t1.c in (select case when 11<17 then case when (t1.b*coalesce((select (abs((coalesce((select a-19 from t1 where t1.c between e and f and d<>17 and t1.d not between 19 and 19),a)))/abs(t1.c))+t1.b-17 from t1 where c=a), -t1.d)+c>t1.f) then  -13+(t1.e) when 11<>t1.c then 13 else t1.c end when 11=c then t1.c else (c) end from t1 union select t1.e from t1)}\n} {}\ndo_test randexpr-2.2115 {\n  db eval {SELECT case when case when (abs( -t1.b)/abs(case case case (select ~ -(+abs(case min(19) when (( -min(t1.e))) then count(distinct (t1.e)) else cast(avg(11) AS integer) end)) from t1) when t1.e then (select min(19) from t1) else 17 end when (13)-a*17 then t1.d else t1.a end when a then 19 else  -( -f) end))>=d then t1.e else 13 end between f and 19 then f when t1.c<=t1.a or (t1.b>(11)) then 11 else t1.b end FROM t1 WHERE NOT (t1.c in (select case when 11<17 then case when (t1.b*coalesce((select (abs((coalesce((select a-19 from t1 where t1.c between e and f and d<>17 and t1.d not between 19 and 19),a)))/abs(t1.c))+t1.b-17 from t1 where c=a), -t1.d)+c>t1.f) then  -13+(t1.e) when 11<>t1.c then 13 else t1.c end when 11=c then t1.c else (c) end from t1 union select t1.e from t1))}\n} {11}\ndo_test randexpr-2.2116 {\n  db eval {SELECT t1.e+coalesce((select case t1.a-case when t1.a in (case (abs(coalesce((select t1.e from t1 where t1.a>t1.b),~c))/abs(t1.b))* -(select count(distinct t1.c)-cast(avg(coalesce((select 19 from t1 where c not between (abs(b-11)/abs( -t1.e)) and (17)),17)) AS integer) from t1) when t1.e then f else 17 end,t1.c,t1.c) then d else t1.e end when d then 17 else 13 end from t1 where 11<11),t1.f) FROM t1 WHERE 11* -19 in (select case when ~coalesce((select t1.b from t1 where coalesce((select d from t1 where t1.a=17*~e+t1.d*case when 11< -~t1.b*t1.b*c+a then (c) else 19 end*a),e)>e),11)<=19 then t1.c when (not exists(select 1 from t1 where t1.d<17)) then b else c end from t1 union select t1.a from t1)}\n} {}\ndo_test randexpr-2.2117 {\n  db eval {SELECT t1.e+coalesce((select case t1.a-case when t1.a in (case (abs(coalesce((select t1.e from t1 where t1.a>t1.b),~c))/abs(t1.b))* -(select count(distinct t1.c)-cast(avg(coalesce((select 19 from t1 where c not between (abs(b-11)/abs( -t1.e)) and (17)),17)) AS integer) from t1) when t1.e then f else 17 end,t1.c,t1.c) then d else t1.e end when d then 17 else 13 end from t1 where 11<11),t1.f) FROM t1 WHERE NOT (11* -19 in (select case when ~coalesce((select t1.b from t1 where coalesce((select d from t1 where t1.a=17*~e+t1.d*case when 11< -~t1.b*t1.b*c+a then (c) else 19 end*a),e)>e),11)<=19 then t1.c when (not exists(select 1 from t1 where t1.d<17)) then b else c end from t1 union select t1.a from t1))}\n} {1100}\ndo_test randexpr-2.2118 {\n  db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a | 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case  -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end | max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE ~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a)}\n} {}\ndo_test randexpr-2.2119 {\n  db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a | 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case  -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end | max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE NOT (~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a))}\n} {-129400}\ndo_test randexpr-2.2120 {\n  db eval {SELECT 19* -coalesce((select coalesce((select t1.d*17 from t1 where t1.b<=t1.b+17), -(a & 17)) from t1 where t1.d in (select case abs(count(*))*count(distinct (17)) when max(11) then abs(+max(13)-case  -cast(avg(t1.d) AS integer)- -(max(19))-count(distinct d) when min(t1.c) then cast(avg(c) AS integer) else count(distinct t1.f) end & max(c)) else max(t1.d) end from t1 union select count(*) from t1)),t1.f)-t1.e+c FROM t1 WHERE NOT (~(abs(case 17 when d then coalesce((select t1.d from t1 where 13 in (select t1.d-f | case when (17 in (t1.a,19,t1.f)) then case when a*f in (select e from t1 union select t1.a from t1) or 11=t1.c or t1.a>=(19) and ( -b)<f or e<>13 then b when t1.e in (t1.c, -t1.b,a) then 19 else 19 end else a end from t1 union select t1.b from t1)),d) else 13 end)/abs(11))+19*t1.e in (e, -t1.e,a))}\n} {-129400}\ndo_test randexpr-2.2121 {\n  db eval {SELECT case t1.f when f then t1.a-case d+t1.d+coalesce((select (select cast(avg( -case when t1.d in (select  -min(17)-count(*)+max(f) from t1 union select  -count(distinct 13) from t1) then t1.e else a end*a) AS integer) from t1)-t1.d from t1 where  -t1.b not in (11, -(t1.b),t1.d) and c in (select b from t1 union select 19 from t1) and t1.a in (select  -e from t1 union select t1.e from t1)),a)*t1.f when 19 then t1.f else 11 end else c end FROM t1 WHERE t1.c>11}\n} {89}\ndo_test randexpr-2.2122 {\n  db eval {SELECT case t1.f when f then t1.a-case d+t1.d+coalesce((select (select cast(avg( -case when t1.d in (select  -min(17)-count(*)+max(f) from t1 union select  -count(distinct 13) from t1) then t1.e else a end*a) AS integer) from t1)-t1.d from t1 where  -t1.b not in (11, -(t1.b),t1.d) and c in (select b from t1 union select 19 from t1) and t1.a in (select  -e from t1 union select t1.e from t1)),a)*t1.f when 19 then t1.f else 11 end else c end FROM t1 WHERE NOT (t1.c>11)}\n} {}\ndo_test randexpr-2.2123 {\n  db eval {SELECT case when (case when (e not in (e | e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) | t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE (select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19}\n} {200}\ndo_test randexpr-2.2124 {\n  db eval {SELECT case when (case when (e not in (e | e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) | t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE NOT ((select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19)}\n} {}\ndo_test randexpr-2.2125 {\n  db eval {SELECT case when (case when (e not in (e & e,17,e)) then 13 else t1.b end>+t1.b*f-b+t1.d-e) or 19 between b and t1.a then 11 when exists(select 1 from t1 where (t1.d) & t1.d in (case when (e>=(11)) or (t1.a)>=t1.f then c-b when t1.c<>t1.e then t1.a else (17) end,c,13)) then 17 else t1.b end FROM t1 WHERE (select min(case when a not in (coalesce((select 19 from t1 where t1.f<((abs(e)/abs(t1.a+e)) | d)-e),e),t1.f,t1.a) then c else 13 end)-(count(distinct d)-abs(count(distinct t1.c)-cast(avg(d) AS integer) | min(b)+(cast(avg(19) AS integer) | case count(distinct t1.c) when cast(avg( -t1.b) AS integer) then cast(avg(t1.a) AS integer) else max(13) end))) from t1) not between b | a and 19}\n} {200}\ndo_test randexpr-2.2126 {\n  db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else  -t1.c end- -a | 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then  -((count(distinct 17))) else max(t1.b) end | ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when  -c not between f and t1.f then b else t1.a end FROM t1 WHERE a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where  -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where  -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and  -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19}\n} {200}\ndo_test randexpr-2.2127 {\n  db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else  -t1.c end- -a | 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then  -((count(distinct 17))) else max(t1.b) end | ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when  -c not between f and t1.f then b else t1.a end FROM t1 WHERE NOT (a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where  -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where  -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and  -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19)}\n} {}\ndo_test randexpr-2.2128 {\n  db eval {SELECT case when case when t1.c+13<13 then 11 when (t1.b) not in (t1.b,e,t1.c) then t1.f else  -t1.c end- -a & 13 in (select max(a) from t1 union select count(distinct 17)* -case count(*) when count(*) then  -((count(distinct 17))) else max(t1.b) end & ( -count(*)) from t1) and e<=17 and t1.c<=d then coalesce((select max(coalesce((select max(e) from t1 where t1.f not in (e,17,t1.b) and d= -t1.b),t1.d)) from t1 where t1.d<f),b) when  -c not between f and t1.f then b else t1.a end FROM t1 WHERE a<=case b when coalesce((select max(19) from t1 where (coalesce((select max(11) from t1 where ((not coalesce((select max(t1.e) from t1 where  -19 in (select count(*) from t1 union select (max(t1.c)) from t1)),t1.a)-11 between f and t1.c))),case when exists(select 1 from t1 where  -(17)< -a) then 17*17 else a end) not in (17,b,t1.e)) or 17 between a and t1.f and  -a<11 and 19<=(t1.b)),t1.c) then ~case when 11>(f) then t1.e else 17 end else t1.c end-19}\n} {200}\ndo_test randexpr-2.2129 {\n  db eval {SELECT coalesce((select case t1.e when coalesce((select max(e- -coalesce((select 17-d-e from t1 where ( -e*(d)>t1.c and 17=(t1.b) or not 11>(a) and b not between ((f)) and t1.d)),t1.c)-f-(f)*b+t1.a) from t1 where f<>13),t1.b) then t1.c else t1.b end from t1 where c in (select t1.a from t1 union select (t1.e) from t1)),e) FROM t1 WHERE (c in (select ~abs(cast(avg(19) AS integer))- -(case (++abs(max( -(select case case ( -abs(+cast(avg(b) AS integer) | count(distinct t1.b*17)*min( -11)*count(distinct t1.e))) when (max( -t1.b)) then count(distinct e) else max(11) end when  -min(d) then count(*) else cast(avg(t1.a) AS integer) end from t1))*max(11))) when min(b) then max(19) else (count(*)) end)* -(max(t1.a))-count(*) from t1 union select count(distinct t1.a) from t1))}\n} {}\ndo_test randexpr-2.2130 {\n  db eval {SELECT coalesce((select case t1.e when coalesce((select max(e- -coalesce((select 17-d-e from t1 where ( -e*(d)>t1.c and 17=(t1.b) or not 11>(a) and b not between ((f)) and t1.d)),t1.c)-f-(f)*b+t1.a) from t1 where f<>13),t1.b) then t1.c else t1.b end from t1 where c in (select t1.a from t1 union select (t1.e) from t1)),e) FROM t1 WHERE NOT ((c in (select ~abs(cast(avg(19) AS integer))- -(case (++abs(max( -(select case case ( -abs(+cast(avg(b) AS integer) | count(distinct t1.b*17)*min( -11)*count(distinct t1.e))) when (max( -t1.b)) then count(distinct e) else max(11) end when  -min(d) then count(*) else cast(avg(t1.a) AS integer) end from t1))*max(11))) when min(b) then max(19) else (count(*)) end)* -(max(t1.a))-count(*) from t1 union select count(distinct t1.a) from t1)))}\n} {500}\ndo_test randexpr-2.2131 {\n  db eval {SELECT t1.e+13-(abs(f)/abs(e | coalesce((select case when (f>=~t1.c*case t1.a when  -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when  -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d}\n} {}\ndo_test randexpr-2.2132 {\n  db eval {SELECT t1.e+13-(abs(f)/abs(e | coalesce((select case when (f>=~t1.c*case t1.a when  -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE NOT (coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when  -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d)}\n} {513}\ndo_test randexpr-2.2133 {\n  db eval {SELECT t1.e+13-(abs(f)/abs(e & coalesce((select case when (f>=~t1.c*case t1.a when  -d then (11) else 17 end*19) then case a when t1.e then b else e end else t1.c end from t1 where e in (select t1.a from t1 union select a from t1) or t1.d not in (f,f,17) and t1.b not between f and 17 and e=c),t1.c)*17+d+t1.d)) FROM t1 WHERE NOT (coalesce((select ~f+t1.c*t1.d | t1.d*t1.d-t1.b from t1 where t1.b | t1.a between case when (abs(coalesce((select f from t1 where t1.e between 11-17 and t1.c),e)-t1.d*b)/abs(((d))))-d between t1.b and d then a when  -(f) between e and t1.e then t1.a else a end and t1.b),t1.a)-11=d)}\n} {511}\ndo_test randexpr-2.2134 {\n  db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c | coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f | coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11}\n} {0}\ndo_test randexpr-2.2135 {\n  db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c | coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f | coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE NOT (t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11)}\n} {}\ndo_test randexpr-2.2136 {\n  db eval {SELECT +(abs(~+13+(abs(t1.c)/abs(t1.c & coalesce((select t1.a from t1 where (select min(t1.c) from t1)<>(abs(t1.f & coalesce((select c from t1 where b=17),f)-b)/abs(coalesce((select max(d-t1.e) from t1 where not exists(select 1 from t1 where t1.e in (select f from t1 union select t1.d from t1))),19)*e+19)) or t1.a in (select 13 from t1 union select t1.d from t1) and (b)<= -t1.f),11))))/abs(e)) FROM t1 WHERE t1.e<>coalesce((select case 17 when f then coalesce((select max(t1.c) from t1 where coalesce((select coalesce((select ~e from t1 where not 17<=e | 17),11)+t1.d+t1.e from t1 where (e>=f or (not t1.e>=t1.a or e between f and t1.f))),t1.b) not in (13,17,c) or t1.a> -t1.d),19) else t1.c end from t1 where (not 17 not in (t1.b,11,b) and f>=t1.f) or 19<=t1.f),d)-11}\n} {0}\ndo_test randexpr-2.2137 {\n  db eval {SELECT (case when not case when ((e not between d and case when not exists(select 1 from t1 where 11>=(a)*t1.d*11 or  -(d) not in (a,11,t1.f)) then f else ~f end or not d<>t1.e or t1.c in (a,t1.d,t1.c))) then case when  -b between 11 and b then (select count(distinct 17) from t1) when t1.e<>11 then f else d end else t1.d end<=a then (abs(t1.d)/abs(e)) when t1.d<t1.f then d else t1.e end) FROM t1 WHERE case when ~ -13*case when (not exists(select 1 from t1 where t1.c in (a,case case when 11<=17 then e else 13 end when 11 then 11 else b end,f))) then t1.a when not exists(select 1 from t1 where (t1.a>=t1.b and 17=t1.e)) then f else 19 end-t1.a*t1.a-e<=t1.b and 17 in (t1.d,13,t1.b) then c else t1.b end<>t1.b or not exists(select 1 from t1 where 17 between (d) and ( -(t1.d)))}\n} {0}\ndo_test randexpr-2.2138 {\n  db eval {SELECT (case when not case when ((e not between d and case when not exists(select 1 from t1 where 11>=(a)*t1.d*11 or  -(d) not in (a,11,t1.f)) then f else ~f end or not d<>t1.e or t1.c in (a,t1.d,t1.c))) then case when  -b between 11 and b then (select count(distinct 17) from t1) when t1.e<>11 then f else d end else t1.d end<=a then (abs(t1.d)/abs(e)) when t1.d<t1.f then d else t1.e end) FROM t1 WHERE NOT (case when ~ -13*case when (not exists(select 1 from t1 where t1.c in (a,case case when 11<=17 then e else 13 end when 11 then 11 else b end,f))) then t1.a when not exists(select 1 from t1 where (t1.a>=t1.b and 17=t1.e)) then f else 19 end-t1.a*t1.a-e<=t1.b and 17 in (t1.d,13,t1.b) then c else t1.b end<>t1.b or not exists(select 1 from t1 where 17 between (d) and ( -(t1.d))))}\n} {}\ndo_test randexpr-2.2139 {\n  db eval {SELECT t1.b+case when f+f not in (c+case when t1.f<>d then 11 when f between 11 and t1.d then 11 else 13 end,e,(t1.f)) and not exists(select 1 from t1 where (exists(select 1 from t1 where 19<11)) or 11 in ((t1.d),t1.c,b) and t1.b>13) and t1.b=t1.b then (abs(t1.d)/abs(13)) when a not between t1.c and 19 then t1.f else 19 end+13*17-t1.e FROM t1 WHERE not exists(select 1 from t1 where (exists(select 1 from t1 where t1.c>=19)))}\n} {}\ndo_test randexpr-2.2140 {\n  db eval {SELECT t1.b+case when f+f not in (c+case when t1.f<>d then 11 when f between 11 and t1.d then 11 else 13 end,e,(t1.f)) and not exists(select 1 from t1 where (exists(select 1 from t1 where 19<11)) or 11 in ((t1.d),t1.c,b) and t1.b>13) and t1.b=t1.b then (abs(t1.d)/abs(13)) when a not between t1.c and 19 then t1.f else 19 end+13*17-t1.e FROM t1 WHERE NOT (not exists(select 1 from t1 where (exists(select 1 from t1 where t1.c>=19))))}\n} {-49}\ndo_test randexpr-2.2141 {\n  db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) | count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then  -f when f<> -b then t1.e else  -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE t1.d>11}\n} {600}\ndo_test randexpr-2.2142 {\n  db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) | count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then  -f when f<> -b then t1.e else  -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE NOT (t1.d>11)}\n} {}\ndo_test randexpr-2.2143 {\n  db eval {SELECT (case when f>(select abs((((count(*)-+cast(avg(d) AS integer)))) & count(distinct a)) from t1) then case when (abs(coalesce((select max(t1.d) from t1 where coalesce((select max(case when t1.b between t1.f and a then  -f when f<> -b then t1.e else  -19 end) from t1 where not exists(select 1 from t1 where t1.c not in (t1.f,t1.c,t1.a))),t1.c)<=b), -t1.c))/abs(t1.a))<t1.b and exists(select 1 from t1 where t1.c between d and t1.f) then t1.a else t1.d end when a not in (e, -t1.f,t1.a) or f in (d,t1.c,(f)) and d in (t1.e,17,c) then 19 else (b) end)+t1.b FROM t1 WHERE t1.d>11}\n} {600}\ndo_test randexpr-2.2144 {\n  db eval {SELECT (abs(+coalesce((select t1.f from t1 where not exists(select 1 from t1 where (((c)<=t1.a)))),f+(select count(distinct t1.b) from t1)*t1.b+case when case (select count(*) from t1) when coalesce((select max(t1.f-e+13) from t1 where (t1.e>a and 19 not in (13,b,19))),t1.c)+e then t1.b else t1.b end in (select  -c from t1 union select c from t1) then f when t1.a>t1.e then t1.c else d end+ -13))/abs((t1.f))) FROM t1 WHERE coalesce((select t1.f from t1 where a>=e),13) between  -c and t1.a}\n} {1}\ndo_test randexpr-2.2145 {\n  db eval {SELECT (abs(+coalesce((select t1.f from t1 where not exists(select 1 from t1 where (((c)<=t1.a)))),f+(select count(distinct t1.b) from t1)*t1.b+case when case (select count(*) from t1) when coalesce((select max(t1.f-e+13) from t1 where (t1.e>a and 19 not in (13,b,19))),t1.c)+e then t1.b else t1.b end in (select  -c from t1 union select c from t1) then f when t1.a>t1.e then t1.c else d end+ -13))/abs((t1.f))) FROM t1 WHERE NOT (coalesce((select t1.f from t1 where a>=e),13) between  -c and t1.a)}\n} {}\ndo_test randexpr-2.2146 {\n  db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b | 11 FROM t1 WHERE (+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then  -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13)}\n} {-209}\ndo_test randexpr-2.2147 {\n  db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b | 11 FROM t1 WHERE NOT ((+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then  -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13))}\n} {}\ndo_test randexpr-2.2148 {\n  db eval {SELECT coalesce((select max(~19) from t1 where t1.a between case t1.c when t1.b then t1.e else +~f end and case when 19 not in (e+b,t1.e-d,(select max(e) from t1)) then t1.a else case 13 when case e when e then t1.f else f end-a+t1.f then 19 else t1.b end+11 end-t1.d-17 or t1.b<>t1.a),13)-t1.b & 11 FROM t1 WHERE (+(17)-(select cast(avg( -((17)*case t1.b when 13+f then t1.f else t1.b end)) AS integer) | case case cast(avg(e) AS integer) when abs((case (~min(t1.c)) when max(t1.e) then cast(avg(t1.b) AS integer) else (( -count(*))) end-max(b)))+(min(t1.c)) then  -cast(avg(c) AS integer) else min(f) end when cast(avg(17) AS integer) then max(f) else (min(d)) end from t1)+e+c*19>=13)}\n} {0}\ndo_test randexpr-2.2149 {\n  db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 | d)-coalesce((select t1.e | coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE ~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e)}\n} {19}\ndo_test randexpr-2.2150 {\n  db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 | d)-coalesce((select t1.e | coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE NOT (~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e))}\n} {}\ndo_test randexpr-2.2151 {\n  db eval {SELECT coalesce((select max(e) from t1 where 11>=coalesce((select max(b) from t1 where (abs(13)/abs(coalesce((select max(11) from t1 where f not between t1.a and t1.d),t1.d)))=case when 11 in (select (11 & d)-coalesce((select t1.e & coalesce((select t1.e from t1 where t1.f in (select 13 from t1 union select t1.c from t1) and d in (select t1.b from t1 union select 17 from t1)),(c))-17-19 from t1 where (t1.b)<=t1.b),(d)) from t1 union select t1.d from t1) then t1.a else (b) end),c)),19) FROM t1 WHERE ~t1.b not in (~++(select (case ~ -min( -11) when abs(count(*)*count(*)) then +~max(t1.a-11 | (19)) else case abs((cast(avg(f) AS integer)))-count(distinct t1.a) when (( -(max(a)))) then (min(t1.d)) else (min(a)) end end) from t1)+(abs(+t1.b)/abs(a))-t1.f+~t1.d+b+t1.c,13,e)}\n} {19}\ndo_test randexpr-2.2152 {\n  db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e | t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else  -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e))))}\n} {-360000}\ndo_test randexpr-2.2153 {\n  db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e | t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else  -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e)))))}\n} {}\ndo_test randexpr-2.2154 {\n  db eval {SELECT (abs(+b)/abs(coalesce((select max(t1.b) from t1 where (not t1.a not between t1.c-(abs(b)/abs(d)) and c)),19)+19*t1.e & t1.e))-t1.f*coalesce((select case d when e*t1.d*f then 17 else t1.c+t1.c end from t1 where t1.b>=(select count(*) from t1)),+f+t1.b-t1.b+19- -b) FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where not exists(select 1 from t1 where not (b>=(abs(case when case (select count(*) from t1) when t1.a then a+case t1.f when a+ -t1.a*t1.d then 19 else e end+t1.a+f else  -d end>=e then f when t1.b>=t1.d or not d<f or t1.f>t1.b then t1.e else d end)/abs(f)) or a>e))))}\n} {-360000}\ndo_test randexpr-2.2155 {\n  db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) | min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) | cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) | count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then  -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1))}\n} {6}\ndo_test randexpr-2.2156 {\n  db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) | min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) | cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) | count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE NOT (b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then  -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1)))}\n} {}\ndo_test randexpr-2.2157 {\n  db eval {SELECT (abs((select +abs(case count(*) when +max(19) then count(distinct b)*count(distinct (13+(select max(t1.d) from t1)* -a+t1.e*t1.b*a))+cast(avg(13) AS integer) & min(13)*cast(avg(c) AS integer)-count(distinct t1.e)-((min(f))) & cast(avg(17) AS integer)-( -cast(avg(( -t1.d)) AS integer))- -cast(avg(t1.d) AS integer) & count(*) else max(t1.f) end) from t1))/abs(t1.a)) FROM t1 WHERE b<=e or exists(select 1 from t1 where 17 in (select ~e+coalesce((select d from t1 where 11* -~+case when not (b) not between t1.f and b then  -~t1.c-11*+19+((b)) when f not between f and 11 then b else a end+11-(b)-t1.f<>17),d) from t1 union select t1.a from t1))}\n} {6}\ndo_test randexpr-2.2158 {\n  db eval {SELECT coalesce((select max(11) from t1 where c=(abs(coalesce((select case when t1.c-t1.f+coalesce((select max(b) from t1 where case when (11<>17) then t1.c else c end in (select b from t1 union select t1.b from t1) and 13=11),f)+t1.b>=t1.f then 11 when c>t1.f then 19 else 19 end from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (e>19)))),t1.d))/abs(b)) and  -t1.d between t1.b and 13 or 17<>t1.e), -((11))) FROM t1 WHERE case when case when (not exists(select 1 from t1 where 19 not between case when coalesce((select b from t1 where (abs(t1.c)/abs(17))+t1.e between case when not exists(select 1 from t1 where not a<=t1.e) then t1.e when d<t1.c then 17 else  -d end and f),e)<13 then t1.a else t1.c end and e)) then +t1.a else d end not in (e,t1.d,t1.a) then t1.a when a in (select 19 from t1 union select t1.a from t1) then 19 else  -e end<t1.c}\n} {11}\ndo_test randexpr-2.2159 {\n  db eval {SELECT coalesce((select max(11) from t1 where c=(abs(coalesce((select case when t1.c-t1.f+coalesce((select max(b) from t1 where case when (11<>17) then t1.c else c end in (select b from t1 union select t1.b from t1) and 13=11),f)+t1.b>=t1.f then 11 when c>t1.f then 19 else 19 end from t1 where exists(select 1 from t1 where not exists(select 1 from t1 where (e>19)))),t1.d))/abs(b)) and  -t1.d between t1.b and 13 or 17<>t1.e), -((11))) FROM t1 WHERE NOT (case when case when (not exists(select 1 from t1 where 19 not between case when coalesce((select b from t1 where (abs(t1.c)/abs(17))+t1.e between case when not exists(select 1 from t1 where not a<=t1.e) then t1.e when d<t1.c then 17 else  -d end and f),e)<13 then t1.a else t1.c end and e)) then +t1.a else d end not in (e,t1.d,t1.a) then t1.a when a in (select 19 from t1 union select t1.a from t1) then 19 else  -e end<t1.c)}\n} {}\ndo_test randexpr-2.2160 {\n  db eval {SELECT coalesce((select ( -t1.e*(abs((case when not 13 not in (case coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where d between  -b and f)),11) when 11 then 19 else a end,t1.a,t1.a) then f-t1.f when t1.c in (select  -abs(count(*)+(max((t1.a)))) from t1 union select  -max((19)) from t1) then d else 13 end-19))/abs(t1.b))-t1.d*e-19) from t1 where t1.e not between 13 and c),19)*13 FROM t1 WHERE 19<>(t1.c)}\n} {-2600247}\ndo_test randexpr-2.2161 {\n  db eval {SELECT coalesce((select ( -t1.e*(abs((case when not 13 not in (case coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where d between  -b and f)),11) when 11 then 19 else a end,t1.a,t1.a) then f-t1.f when t1.c in (select  -abs(count(*)+(max((t1.a)))) from t1 union select  -max((19)) from t1) then d else 13 end-19))/abs(t1.b))-t1.d*e-19) from t1 where t1.e not between 13 and c),19)*13 FROM t1 WHERE NOT (19<>(t1.c))}\n} {}\ndo_test randexpr-2.2162 {\n  db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select  -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a | ~11),19) FROM t1 WHERE (exists(select 1 from t1 where t1.c>19)) and a>d-a}\n} {}\ndo_test randexpr-2.2163 {\n  db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select  -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a | ~11),19) FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.c>19)) and a>d-a)}\n} {19}\ndo_test randexpr-2.2164 {\n  db eval {SELECT coalesce((select max(13) from t1 where f= -case when exists(select 1 from t1 where not t1.b>=e and b in (select b from t1 union select (+(t1.f-d)) from t1) or 19 in (select min(e) from t1 union select  -~+++ -abs(min(17*t1.d)) from t1) or not t1.a>a) then 13 else t1.c end+a & ~11),19) FROM t1 WHERE NOT ((exists(select 1 from t1 where t1.c>19)) and a>d-a)}\n} {19}\ndo_test randexpr-2.2165 {\n  db eval {SELECT coalesce((select case when a between (select count(distinct 19) from t1) and case when d<t1.d and (select min(d)*min(a) from t1)<=t1.c+d then case 11 when 13 then t1.b else t1.a end else t1.d end+19 and exists(select 1 from t1 where t1.b between  -t1.e and t1.d) then f-d when 13 not between  -(c) and 13 then t1.c else 17 end from t1 where t1.e not in (c,f,t1.b)), -b) FROM t1 WHERE case 13*(abs(c)/abs(c*d-~t1.f-case coalesce((select +t1.f-a from t1 where b in (13,t1.f,f+19*+c)),b-a+coalesce((select max(c) from t1 where t1.f=d),d)-t1.a) when 13 then t1.d else t1.d end)) when 19 then 13 else  -11 end | 19=t1.c}\n} {}\ndo_test randexpr-2.2166 {\n  db eval {SELECT coalesce((select case when a between (select count(distinct 19) from t1) and case when d<t1.d and (select min(d)*min(a) from t1)<=t1.c+d then case 11 when 13 then t1.b else t1.a end else t1.d end+19 and exists(select 1 from t1 where t1.b between  -t1.e and t1.d) then f-d when 13 not between  -(c) and 13 then t1.c else 17 end from t1 where t1.e not in (c,f,t1.b)), -b) FROM t1 WHERE NOT (case 13*(abs(c)/abs(c*d-~t1.f-case coalesce((select +t1.f-a from t1 where b in (13,t1.f,f+19*+c)),b-a+coalesce((select max(c) from t1 where t1.f=d),d)-t1.a) when 13 then t1.d else t1.d end)) when 19 then 13 else  -11 end | 19=t1.c)}\n} {200}\ndo_test randexpr-2.2167 {\n  db eval {SELECT case 17 when  -b then e*c else (abs(coalesce((select max(coalesce((select coalesce((select max(case when t1.d<=19 and t1.d>e then b*t1.e else a end) from t1 where t1.e=t1.e),t1.f) from t1 where (d not between 13 and (f))),17)-d) from t1 where (11<>19)),t1.e)+t1.c)/abs(t1.e))*11*c-t1.d*t1.d+a end FROM t1 WHERE 13-e*t1.e<case when (coalesce((select max(c*13) from t1 where not exists(select 1 from t1 where (19+(coalesce((select coalesce((select max(a) from t1 where 17>=19),(abs(e)/abs((abs( -d+e)/abs(a))))+t1.a) from t1 where t1.b in (t1.e,(t1.e),t1.f)),f))=t1.e)) or b<=19),t1.b)<=13) then 13 else t1.f end-f}\n} {-159900}\ndo_test randexpr-2.2168 {\n  db eval {SELECT case 17 when  -b then e*c else (abs(coalesce((select max(coalesce((select coalesce((select max(case when t1.d<=19 and t1.d>e then b*t1.e else a end) from t1 where t1.e=t1.e),t1.f) from t1 where (d not between 13 and (f))),17)-d) from t1 where (11<>19)),t1.e)+t1.c)/abs(t1.e))*11*c-t1.d*t1.d+a end FROM t1 WHERE NOT (13-e*t1.e<case when (coalesce((select max(c*13) from t1 where not exists(select 1 from t1 where (19+(coalesce((select coalesce((select max(a) from t1 where 17>=19),(abs(e)/abs((abs( -d+e)/abs(a))))+t1.a) from t1 where t1.b in (t1.e,(t1.e),t1.f)),f))=t1.e)) or b<=19),t1.b)<=13) then 13 else t1.f end-f)}\n} {}\ndo_test randexpr-2.2169 {\n  db eval {SELECT case when case when e*(d-case a when 13 then (19) else d end) between 13 and f then f when exists(select 1 from t1 where 19<>t1.a) then e else b end in (select  -max(e)+min(11)-case ~~cast(avg(t1.c) AS integer) when max(19) then max(f) else  -cast(avg(f) AS integer) end from t1 union select  -max(13) from t1) and f>d and (t1.f=c) then t1.b else t1.c+ -t1.f end FROM t1 WHERE t1.e+11>=~t1.a-11}\n} {-300}\ndo_test randexpr-2.2170 {\n  db eval {SELECT case when case when e*(d-case a when 13 then (19) else d end) between 13 and f then f when exists(select 1 from t1 where 19<>t1.a) then e else b end in (select  -max(e)+min(11)-case ~~cast(avg(t1.c) AS integer) when max(19) then max(f) else  -cast(avg(f) AS integer) end from t1 union select  -max(13) from t1) and f>d and (t1.f=c) then t1.b else t1.c+ -t1.f end FROM t1 WHERE NOT (t1.e+11>=~t1.a-11)}\n} {}\ndo_test randexpr-2.2171 {\n  db eval {SELECT coalesce((select t1.f from t1 where not (abs(coalesce((select 17*13+(select cast(avg(t1.a) AS integer)-(count(distinct t1.c)*+cast(avg((select count(*) from t1)) AS integer))+count(*) from t1) from t1 where (select count(distinct t1.d*(((t1.d)))+f) from t1) in ( -b*t1.e-11,t1.d,d) and exists(select 1 from t1 where t1.d>c)),t1.e))/abs(b)) not in (t1.f,11,d)),t1.d) FROM t1 WHERE exists(select 1 from t1 where +t1.c-case when exists(select 1 from t1 where (select +case count(distinct case when 19*d in (select (cast(avg(11) AS integer)*cast(avg( -13) AS integer)) from t1 union select count(*) from t1) then t1.c else 13 end) when count(*) then count(*) else (min(t1.b)) end from t1)<>case when (not t1.f<b) or b>t1.d then case when f>=17 then t1.a else t1.e end else b end) then 11+t1.f when d<>17 then t1.e else a end- -13<>e) and t1.a<=17}\n} {}\ndo_test randexpr-2.2172 {\n  db eval {SELECT coalesce((select t1.f from t1 where not (abs(coalesce((select 17*13+(select cast(avg(t1.a) AS integer)-(count(distinct t1.c)*+cast(avg((select count(*) from t1)) AS integer))+count(*) from t1) from t1 where (select count(distinct t1.d*(((t1.d)))+f) from t1) in ( -b*t1.e-11,t1.d,d) and exists(select 1 from t1 where t1.d>c)),t1.e))/abs(b)) not in (t1.f,11,d)),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where +t1.c-case when exists(select 1 from t1 where (select +case count(distinct case when 19*d in (select (cast(avg(11) AS integer)*cast(avg( -13) AS integer)) from t1 union select count(*) from t1) then t1.c else 13 end) when count(*) then count(*) else (min(t1.b)) end from t1)<>case when (not t1.f<b) or b>t1.d then case when f>=17 then t1.a else t1.e end else b end) then 11+t1.f when d<>17 then t1.e else a end- -13<>e) and t1.a<=17)}\n} {400}\ndo_test randexpr-2.2173 {\n  db eval {SELECT case when not (select  - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) | (max(t1.e)) from t1)<>~t1.d then b when  -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then  -f else 11 end FROM t1 WHERE t1.a<>(select max(19) from t1)}\n} {-600}\ndo_test randexpr-2.2174 {\n  db eval {SELECT case when not (select  - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) | (max(t1.e)) from t1)<>~t1.d then b when  -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then  -f else 11 end FROM t1 WHERE NOT (t1.a<>(select max(19) from t1))}\n} {}\ndo_test randexpr-2.2175 {\n  db eval {SELECT case when not (select  - -count(distinct t1.f)-(max(case when e not between f and t1.b+(13)+ -d-t1.a then t1.d else 11 end))+ -max(t1.b)*cast(avg(13) AS integer)-count(*) & (max(t1.e)) from t1)<>~t1.d then b when  -coalesce((select (abs(t1.e)/abs(t1.b)) from t1 where a<>b), - -17)<=t1.a then  -f else 11 end FROM t1 WHERE t1.a<>(select max(19) from t1)}\n} {-600}\ndo_test randexpr-2.2176 {\n  db eval {SELECT case when case coalesce((select t1.d+a*11 from t1 where e<=t1.d),19) when 19 then  -t1.d-t1.a else t1.e end not between 17 and d then t1.f when not (t1.c<=e and ((13<>e or t1.c not between t1.c and 13)) or t1.c=17 and t1.a not in (t1.e, -t1.d,t1.b) and b<t1.e) and c>=b then t1.d else 13 end FROM t1 WHERE (case t1.f when t1.b then case when case when not exists(select 1 from t1 where (t1.d+t1.a in (c,coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where (t1.a>=c))),+b), -t1.b))) then (select abs( -case ((abs( - - -count(*)+count(*)))) when min(d) then  -(cast(avg(t1.d) AS integer)) else cast(avg(e) AS integer) end | ((max((t1.f)))))+(min(t1.c)) from t1) else 11 end>f then 19 else t1.b end else b end)<=13 or (t1.f>b)}\n} {600}\ndo_test randexpr-2.2177 {\n  db eval {SELECT case when case coalesce((select t1.d+a*11 from t1 where e<=t1.d),19) when 19 then  -t1.d-t1.a else t1.e end not between 17 and d then t1.f when not (t1.c<=e and ((13<>e or t1.c not between t1.c and 13)) or t1.c=17 and t1.a not in (t1.e, -t1.d,t1.b) and b<t1.e) and c>=b then t1.d else 13 end FROM t1 WHERE NOT ((case t1.f when t1.b then case when case when not exists(select 1 from t1 where (t1.d+t1.a in (c,coalesce((select max(t1.c) from t1 where exists(select 1 from t1 where (t1.a>=c))),+b), -t1.b))) then (select abs( -case ((abs( - - -count(*)+count(*)))) when min(d) then  -(cast(avg(t1.d) AS integer)) else cast(avg(e) AS integer) end | ((max((t1.f)))))+(min(t1.c)) from t1) else 11 end>f then 19 else t1.b end else b end)<=13 or (t1.f>b))}\n} {}\ndo_test randexpr-2.2178 {\n  db eval {SELECT (((d)+t1.f))-case +t1.d when coalesce((select max(13) from t1 where (select  -max(17*case when d>=coalesce((select 19 from t1 where a<>t1.e),t1.b) then e when  -c<>d then e else t1.a end*t1.f)+ -case count(*) when (+cast(avg(c) AS integer)) then count(*) else  -count(distinct t1.f) end+count(*) from t1)<=(abs(t1.c)/abs(t1.f))),17) then 17 else t1.d end-t1.b FROM t1 WHERE ~d-c in (select cast(avg(19) AS integer) from t1 union select  - -abs((abs((cast(avg(f) AS integer)) | abs(count(distinct 19))))) from t1)}\n} {}\ndo_test randexpr-2.2179 {\n  db eval {SELECT (((d)+t1.f))-case +t1.d when coalesce((select max(13) from t1 where (select  -max(17*case when d>=coalesce((select 19 from t1 where a<>t1.e),t1.b) then e when  -c<>d then e else t1.a end*t1.f)+ -case count(*) when (+cast(avg(c) AS integer)) then count(*) else  -count(distinct t1.f) end+count(*) from t1)<=(abs(t1.c)/abs(t1.f))),17) then 17 else t1.d end-t1.b FROM t1 WHERE NOT (~d-c in (select cast(avg(19) AS integer) from t1 union select  - -abs((abs((cast(avg(f) AS integer)) | abs(count(distinct 19))))) from t1))}\n} {400}\ndo_test randexpr-2.2180 {\n  db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) | ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE 19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select  -11 from t1))))),t1.f) from t1 where t1.d<=d),13))}\n} {400}\ndo_test randexpr-2.2181 {\n  db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) | ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE NOT (19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select  -11 from t1))))),t1.f) from t1 where t1.d<=d),13)))}\n} {}\ndo_test randexpr-2.2182 {\n  db eval {SELECT coalesce((select max(f+t1.c*b) from t1 where (select abs(cast(avg(f) AS integer)) from t1)-c*~ -b+ -coalesce((select max(t1.a) from t1 where (select cast(avg((c) & ~t1.d) AS integer) from t1) not between t1.d-+(abs(t1.d)/abs(t1.c))+d and 11 and 17>=t1.e),t1.e)-b in (t1.c,d,e)),a)+c FROM t1 WHERE 19*e not in (a,t1.d,coalesce((select coalesce((select max(t1.d) from t1 where (exists(select 1 from t1 where not exists(select 1 from t1 where e*case when ~c | f+11* -a in ( -t1.c,17,(t1.b)) then (f) when e=e or t1.d=f and (e)>(e) then (11) else a end+a*c in (select d from t1 union select  -11 from t1))))),t1.f) from t1 where t1.d<=d),13))}\n} {400}\ndo_test randexpr-2.2183 {\n  db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) | min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) | t1.f FROM t1 WHERE case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1)}\n} {}\ndo_test randexpr-2.2184 {\n  db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) | min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) | t1.f FROM t1 WHERE NOT (case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1))}\n} {-90116}\ndo_test randexpr-2.2185 {\n  db eval {SELECT c*~case ((abs(t1.b)/abs(t1.b))) when c then e else t1.c end-(case when (c)>=case coalesce((select max((abs(d)/abs(c))) from t1 where 13 not in (a-t1.e-(select count(*) & min(e)+min(c) from t1)*19*t1.b,11,a)),e) when e then b else t1.d end then d when 17<11 then c else t1.d end) & t1.f FROM t1 WHERE NOT (case when not (abs(t1.d | (abs( - -coalesce((select max(coalesce((select c+e from t1 where not t1.b in ((c),b,(f))),t1.b)) from t1 where 11=b),t1.f)+13*t1.f*e)/abs(t1.e)))/abs(t1.b))>=c then coalesce((select (t1.c) from t1 where t1.e in (11,e,t1.a)),a) when 13<=t1.b then t1.f else t1.d end in (select e from t1 union select (t1.d) from t1))}\n} {16}\ndo_test randexpr-2.2186 {\n  db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 | (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or  -t1.f not between  -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19}\n} {200}\ndo_test randexpr-2.2187 {\n  db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 | (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE NOT (e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or  -t1.f not between  -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19)}\n} {}\ndo_test randexpr-2.2188 {\n  db eval {SELECT case when a+13*+ -~case when 17=t1.c*17 then 19 & (t1.b) when f+t1.e+(d)+b+c not between (d) and e or (a between t1.b and t1.a) then 17 else a end-17-(e)<=17 then b when c in (select 17 from t1 union select t1.a from t1) then c else t1.e end FROM t1 WHERE e-coalesce((select f-case 17+t1.a*(abs(t1.e)/abs((abs(coalesce((select max(+ -case when t1.a>=d then c else t1.e end-d) from t1 where (not exists(select 1 from t1 where (t1.d in ( -f,d,t1.b))) or  -t1.f not between  -b and t1.b)),11))/abs(13)))) when 13 then d else t1.f end from t1 where t1.e in ((19),t1.e,17) or e>=t1.d),e)<>17 or 19<=19}\n} {200}\ndo_test randexpr-2.2189 {\n  db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) | (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE 13>case (e) when t1.a then t1.a else 11 end-t1.b}\n} {-183}\ndo_test randexpr-2.2190 {\n  db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) | (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE NOT (13>case (e) when t1.a then t1.a else 11 end-t1.b)}\n} {}\ndo_test randexpr-2.2191 {\n  db eval {SELECT 17-t1.a*(select abs(~count(*)*abs(count(distinct a)) & (~count(distinct case (a* -coalesce((select a from t1 where (13 in (select max((abs(t1.e)/abs(case when not exists(select 1 from t1 where (b<>c)) then (11)-t1.f-e else e end))) from t1 union select (count(distinct 11)) from t1))),t1.b)+11) when (17) then e else f end))) from t1) FROM t1 WHERE 13>case (e) when t1.a then t1.a else 11 end-t1.b}\n} {-183}\ndo_test randexpr-2.2192 {\n  db eval {SELECT case when t1.b= -b then e else (select  -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) | max(d) |  -(cast(avg(d) AS integer)) then  -cast(avg(11) AS integer) else  -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE t1.f>=f}\n} {-119801}\ndo_test randexpr-2.2193 {\n  db eval {SELECT case when t1.b= -b then e else (select  -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) | max(d) |  -(cast(avg(d) AS integer)) then  -cast(avg(11) AS integer) else  -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE NOT (t1.f>=f)}\n} {}\ndo_test randexpr-2.2194 {\n  db eval {SELECT case when t1.b= -b then e else (select  -(count(distinct t1.a))*max(c)-count(*)+count(distinct t1.b+d)*min(t1.f-case when 19 in (select t1.d from t1 union select e from t1) then 17 when f<=t1.c then t1.b else e end-(d)*c)-count(distinct t1.d)*case +max(f) when max(17) & max(d) &  -(cast(avg(d) AS integer)) then  -cast(avg(11) AS integer) else  -count(distinct 11) end*min(t1.d) from t1) end FROM t1 WHERE t1.f>=f}\n} {-119801}\ndo_test randexpr-2.2195 {\n  db eval {SELECT  -~f | (abs(13+t1.b)/abs((select max(t1.b | t1.f+ -17-11) | +case min(e) when count(*) | case (~ -min(c)*cast(avg(19) AS integer)) when  -count(*) then min(a) else min(13) end then  -((max(t1.c))) else max(e) end-(count(distinct  -t1.a)) from t1)))+~(abs((abs(case when a<>19 then t1.a when f>17 then a else b end)/abs(t1.b)))/abs(t1.f)) FROM t1 WHERE (17 between t1.f*(abs(b)/abs((abs((select max(17) from t1) | 17)/abs(13))+c-coalesce((select max(d) from t1 where d between f-a-11-d and a+t1.a+d-t1.b+17+13),case when a not between a and t1.b then t1.d when t1.d not in ((e),a,d) then c else b end*d))) and b and t1.e> -17)}\n} {}\ndo_test randexpr-2.2196 {\n  db eval {SELECT  -~f | (abs(13+t1.b)/abs((select max(t1.b | t1.f+ -17-11) | +case min(e) when count(*) | case (~ -min(c)*cast(avg(19) AS integer)) when  -count(*) then min(a) else min(13) end then  -((max(t1.c))) else max(e) end-(count(distinct  -t1.a)) from t1)))+~(abs((abs(case when a<>19 then t1.a when f>17 then a else b end)/abs(t1.b)))/abs(t1.f)) FROM t1 WHERE NOT ((17 between t1.f*(abs(b)/abs((abs((select max(17) from t1) | 17)/abs(13))+c-coalesce((select max(d) from t1 where d between f-a-11-d and a+t1.a+d-t1.b+17+13),case when a not between a and t1.b then t1.d when t1.d not in ((e),a,d) then c else b end*d))) and b and t1.e> -17))}\n} {-1}\ndo_test randexpr-2.2197 {\n  db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then  -count(distinct a) else count(*) end | count(distinct 13))) from t1) FROM t1 WHERE exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e)}\n} {}\ndo_test randexpr-2.2198 {\n  db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then  -count(distinct a) else count(*) end | count(distinct 13))) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e))}\n} {1}\ndo_test randexpr-2.2199 {\n  db eval {SELECT (select abs(abs( -case case ~count(distinct t1.f+(t1.f)+coalesce((select (abs(t1.e+(b)+a)/abs(11))+b from t1 where exists(select 1 from t1 where t1.f not in (t1.b,(b),e) and not (t1.b)>c)),f)) when ~count(*)-min(t1.f) then +(count(*))*( -count(*)-max(t1.a)) else min(11) end when count(distinct (f)) then  -count(distinct a) else count(*) end & count(distinct 13))) from t1) FROM t1 WHERE NOT (exists(select 1 from t1 where case when t1.f>(abs(b)/abs(a)) then ~case when t1.e+13-b<=(coalesce((select max(11) from t1 where (select abs(min(11)) from t1) in (select case d when f then 17 else t1.f end from t1 union select t1.f from t1)),b)*13)-19 then 11 when not 19 between t1.c and t1.b then a else e end-t1.a when (t1.a) not between b and t1.f then t1.a else c end=t1.e))}\n} {1}\ndo_test randexpr-2.2200 {\n  db eval {SELECT 19 | t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select  -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) | e*t1.b-t1.d FROM t1 WHERE (((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select  -min(d) from t1)) then case when  -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11)))}\n} {}\ndo_test randexpr-2.2201 {\n  db eval {SELECT 19 | t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select  -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) | e*t1.b-t1.d FROM t1 WHERE NOT ((((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select  -min(d) from t1)) then case when  -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11))))}\n} {99703}\ndo_test randexpr-2.2202 {\n  db eval {SELECT 19 & t1.a*(select case max(case when t1.b*17>=t1.b then coalesce((select max(e) from t1 where e in (select count(*) from t1 union select count(distinct t1.f) from t1)),d) when t1.a in (select min(11) from t1 union select (( -( -max(t1.f)))) from t1) and 17 in (select count(distinct 17) from t1 union select  -count(distinct d) from t1) and (d)<>t1.c and t1.c not between b and b then a else 11 end)+cast(avg(t1.a) AS integer) when ~count(distinct t1.e) then count(distinct d) else count(distinct e) end from t1) & e*t1.b-t1.d FROM t1 WHERE NOT ((((abs(19)/abs(case ~c*d+(abs(e)/abs((coalesce((select case when (f in (select count(*) from t1 union select  -min(d) from t1)) then case when  -t1.f between t1.c and t1.f then b when 11<>a then t1.a else t1.c end when 13=13 then 13 else t1.a end from t1 where 19 not between 11 and t1.b or t1.b not in ((e),(b),c)),a)- -((t1.c))-c)))+t1.b+17 when 13 then ((13)) else t1.f end*t1.b)) in ( -17,t1.a,11))))}\n} {0}\ndo_test randexpr-2.2203 {\n  db eval {SELECT c-coalesce((select  -coalesce((select max(case when (abs(~~case when case when t1.e<=e and t1.f>t1.d then b when t1.a<>t1.a then 17 else 17 end+t1.c>=t1.a then (c) when c not in (f,e,t1.c) then t1.d else 13 end)/abs(t1.a))<t1.b then t1.e when c<=t1.a then b else d end) from t1 where (19) not in (13,t1.e,f)),17) from t1 where 19>c),t1.a)*19 FROM t1 WHERE (17) | case when 19 not in ((case when (e*19=f) then case t1.f when a then 13 else t1.d end when b<t1.f then f else a end)*t1.d,c, -t1.f) then t1.f when (e=(d) and 19<>t1.b) then f else a end in (select c from t1 union select  -13 from t1) or 17 in (select 19 from t1 union select d from t1) and t1.b in (c,b,19) and t1.b>=( -b)}\n} {}\ndo_test randexpr-2.2204 {\n  db eval {SELECT c-coalesce((select  -coalesce((select max(case when (abs(~~case when case when t1.e<=e and t1.f>t1.d then b when t1.a<>t1.a then 17 else 17 end+t1.c>=t1.a then (c) when c not in (f,e,t1.c) then t1.d else 13 end)/abs(t1.a))<t1.b then t1.e when c<=t1.a then b else d end) from t1 where (19) not in (13,t1.e,f)),17) from t1 where 19>c),t1.a)*19 FROM t1 WHERE NOT ((17) | case when 19 not in ((case when (e*19=f) then case t1.f when a then 13 else t1.d end when b<t1.f then f else a end)*t1.d,c, -t1.f) then t1.f when (e=(d) and 19<>t1.b) then f else a end in (select c from t1 union select  -13 from t1) or 17 in (select 19 from t1 union select d from t1) and t1.b in (c,b,19) and t1.b>=( -b))}\n} {-1600}\ndo_test randexpr-2.2205 {\n  db eval {SELECT 13+case when not (t1.d in (11,f,t1.a)) then coalesce((select +t1.e from t1 where case t1.e when t1.b then 19+t1.a+~e+a*t1.a else 11 end not between 19 and 19),(abs(t1.f-case when (19)<t1.a and d=t1.d then a else a end-f)/abs(13))*c+t1.c)+c else 19 end*t1.e FROM t1 WHERE t1.e in (select +count(distinct a-(select count(*)+count(distinct (abs((select max(coalesce((select case d++11+(t1.c-t1.d-t1.e*t1.e) when t1.a then t1.b else t1.b end from t1 where f in (select (abs(case when e not between  -t1.a and f then 11 when t1.b>=17 then t1.c else t1.f end)/abs(19)) from t1 union select c from t1)), -d)) from t1))/abs(t1.d))) from t1)*(c) | 11+t1.c*t1.b) from t1 union select cast(avg(t1.c) AS integer) from t1)}\n} {}\ndo_test randexpr-2.2206 {\n  db eval {SELECT 13+case when not (t1.d in (11,f,t1.a)) then coalesce((select +t1.e from t1 where case t1.e when t1.b then 19+t1.a+~e+a*t1.a else 11 end not between 19 and 19),(abs(t1.f-case when (19)<t1.a and d=t1.d then a else a end-f)/abs(13))*c+t1.c)+c else 19 end*t1.e FROM t1 WHERE NOT (t1.e in (select +count(distinct a-(select count(*)+count(distinct (abs((select max(coalesce((select case d++11+(t1.c-t1.d-t1.e*t1.e) when t1.a then t1.b else t1.b end from t1 where f in (select (abs(case when e not between  -t1.a and f then 11 when t1.b>=17 then t1.c else t1.f end)/abs(19)) from t1 union select c from t1)), -d)) from t1))/abs(t1.d))) from t1)*(c) | 11+t1.c*t1.b) from t1 union select cast(avg(t1.c) AS integer) from t1))}\n} {400013}\ndo_test randexpr-2.2207 {\n  db eval {SELECT case when  -11-t1.b-f-t1.b>~c then t1.e else case when t1.d<>b*~17+t1.d*(select max(+(select count(distinct t1.a)+ -cast(avg(d) AS integer)*max(13) from t1)) from t1) or (abs(c)/abs(c)) not in (11,d,t1.c) then 13 when d in (select f from t1 union select b from t1) then t1.f else  -t1.a end+ -f end FROM t1 WHERE ~t1.b*19-d not between ~b and t1.f}\n} {-587}\ndo_test randexpr-2.2208 {\n  db eval {SELECT case when  -11-t1.b-f-t1.b>~c then t1.e else case when t1.d<>b*~17+t1.d*(select max(+(select count(distinct t1.a)+ -cast(avg(d) AS integer)*max(13) from t1)) from t1) or (abs(c)/abs(c)) not in (11,d,t1.c) then 13 when d in (select f from t1 union select b from t1) then t1.f else  -t1.a end+ -f end FROM t1 WHERE NOT (~t1.b*19-d not between ~b and t1.f)}\n} {}\ndo_test randexpr-2.2209 {\n  db eval {SELECT coalesce((select t1.b from t1 where coalesce((select max(coalesce((select max(t1.a) from t1 where t1.c=t1.e),case b-f when f then e else 13 end-t1.d)) from t1 where not exists(select 1 from t1 where  -t1.f>=17)),a)*(19) in (select max(d) from t1 union select case  -count(*) when +count(distinct (t1.f)) then min(t1.d) else count(*) end from t1) and a<=f and d not between b and 19 and not exists(select 1 from t1 where b between t1.c and e or c<>t1.f)),17) FROM t1 WHERE t1.a-19<>c*d}\n} {17}\ndo_test randexpr-2.2210 {\n  db eval {SELECT coalesce((select t1.b from t1 where coalesce((select max(coalesce((select max(t1.a) from t1 where t1.c=t1.e),case b-f when f then e else 13 end-t1.d)) from t1 where not exists(select 1 from t1 where  -t1.f>=17)),a)*(19) in (select max(d) from t1 union select case  -count(*) when +count(distinct (t1.f)) then min(t1.d) else count(*) end from t1) and a<=f and d not between b and 19 and not exists(select 1 from t1 where b between t1.c and e or c<>t1.f)),17) FROM t1 WHERE NOT (t1.a-19<>c*d)}\n} {}\ndo_test randexpr-2.2211 {\n  db eval {SELECT (coalesce((select case (select ~count(*) | max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when  -~~ -(cast(avg(13) AS integer)) | count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f}\n} {713}\ndo_test randexpr-2.2212 {\n  db eval {SELECT (coalesce((select case (select ~count(*) | max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when  -~~ -(cast(avg(13) AS integer)) | count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE NOT (not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f)}\n} {}\ndo_test randexpr-2.2213 {\n  db eval {SELECT (coalesce((select case (select ~count(*) & max(b+t1.b)+case max((abs(+coalesce((select max(f) from t1 where not (17=e)),t1.f))/abs(b))*a) when  -~~ -(cast(avg(13) AS integer)) & count(*) then min(13) else count(*) end-count(distinct d) from t1) when 17+t1.d then t1.a else 13 end from t1 where e not between 13 and 11),11)+t1.e+b) FROM t1 WHERE not f in (select t1.e from t1 union select t1.f from t1) or 13 not in (t1.b | t1.e,t1.f,d) or (abs(f)/abs(+(abs(f+(select max(case when ((13<>t1.c)) then 13 else t1.c end) | ~min(t1.a)+cast(avg(a) AS integer) from t1)*(d)-b)/abs(d))*e))-t1.b not in (t1.c,f,t1.d) and t1.b<>t1.f}\n} {713}\ndo_test randexpr-2.2214 {\n  db eval {SELECT t1.b-c*a*t1.b+ -f | (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a | e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE exists(select 1 from t1 where t1.a>17)}\n} {-6000392}\ndo_test randexpr-2.2215 {\n  db eval {SELECT t1.b-c*a*t1.b+ -f | (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a | e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.a>17))}\n} {}\ndo_test randexpr-2.2216 {\n  db eval {SELECT t1.b-c*a*t1.b+ -f & (case when 13<f then d else t1.a+case (select +min(a) from t1) when case when a<=d*a & e then b when not f not between e and 17 or not 19=coalesce((select 13 from t1 where t1.f in (t1.b,t1.d,t1.a)),d) then 11 else (13) end then 11 else (a) end end-b) FROM t1 WHERE exists(select 1 from t1 where t1.a>17)}\n} {192}\ndo_test randexpr-2.2217 {\n  db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) |  -f-f FROM t1 WHERE a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select  -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13}\n} {-1040}\ndo_test randexpr-2.2218 {\n  db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) |  -f-f FROM t1 WHERE NOT (a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select  -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13)}\n} {}\ndo_test randexpr-2.2219 {\n  db eval {SELECT ~(select (abs(cast(avg(((b)-d*t1.a-c+17+f+e+ -17)) AS integer))) from t1)*t1.c++ -(11-t1.b*~f-e*t1.b)-coalesce((select max(case when not c=13 then 17 else b end) from t1 where (t1.a>17)),c) &  -f-f FROM t1 WHERE a+coalesce((select max(coalesce((select max(f) from t1 where ((not b in (select t1.b from t1 union select (select  -cast(avg(t1.b) AS integer) from t1) from t1)) or not t1.d= -t1.c and 19<=t1.c)),t1.f)-coalesce((select c from t1 where d<=t1.a), -e)) from t1 where d in (select t1.d from t1 union select t1.d from t1)),t1.d)-a | t1.b>(f) or t1.d between 19 and t1.c and exists(select 1 from t1 where b=13) and not 13 not in (t1.d,(c),d) and e not between 17 and 13}\n} {-11720688}\ndo_test randexpr-2.2220 {\n  db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) |  -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) | b when t1.d>a then f else b end FROM t1 WHERE 19<=case when (t1.a*11*19-e<>(select abs(min(e))+case  -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then  -(min(f)) else  - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and  -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f}\n} {600}\ndo_test randexpr-2.2221 {\n  db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) |  -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) | b when t1.d>a then f else b end FROM t1 WHERE NOT (19<=case when (t1.a*11*19-e<>(select abs(min(e))+case  -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then  -(min(f)) else  - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and  -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f)}\n} {}\ndo_test randexpr-2.2222 {\n  db eval {SELECT case when t1.a in (select count(*) from t1 union select cast(avg(t1.a) AS integer)*count(distinct 17) &  -count(*) from t1) then ~coalesce((select max(19+t1.a) from t1 where +d=t1.a),case t1.c-(select count(*) from t1) when coalesce((select (abs((select (cast(avg(13) AS integer)) from t1))/abs(13)) from t1 where f<~13-(t1.a)*19),d) then a else 19 end) & b when t1.d>a then f else b end FROM t1 WHERE 19<=case when (t1.a*11*19-e<>(select abs(min(e))+case  -abs(abs( - -( -(( -max(c)))))-(min(c))) when min(e) then  -(min(f)) else  - -min(t1.a) end from t1)*t1.d) then e+f+coalesce((select max(e-a) from t1 where (t1.b) between 11 and  -t1.c),c) when t1.c<=17 then 17 else t1.b end and 19<>t1.f}\n} {200}\ndo_test randexpr-2.2223 {\n  db eval {SELECT c-case when t1.e>coalesce((select case  -t1.d-case when d in (select  -t1.f from t1 union select t1.c+t1.c from t1) and (t1.a<=t1.a) then 11*(17) when d between 11 and e or  -c<>t1.f then 19 else 19 end+11 when 19 then b else t1.b end-t1.a from t1 where not e<=f),( -t1.f)) then b when ((d<c)) then 19 else f end FROM t1 WHERE t1.c in (t1.c,~19,13)}\n} {100}\ndo_test randexpr-2.2224 {\n  db eval {SELECT c-case when t1.e>coalesce((select case  -t1.d-case when d in (select  -t1.f from t1 union select t1.c+t1.c from t1) and (t1.a<=t1.a) then 11*(17) when d between 11 and e or  -c<>t1.f then 19 else 19 end+11 when 19 then b else t1.b end-t1.a from t1 where not e<=f),( -t1.f)) then b when ((d<c)) then 19 else f end FROM t1 WHERE NOT (t1.c in (t1.c,~19,13))}\n} {}\ndo_test randexpr-2.2225 {\n  db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then  -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end | min(b) from t1))/abs(t1.b)) FROM t1 WHERE e<a}\n} {}\ndo_test randexpr-2.2226 {\n  db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then  -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end | min(b) from t1))/abs(t1.b)) FROM t1 WHERE NOT (e<a)}\n} {3}\ndo_test randexpr-2.2227 {\n  db eval {SELECT (abs(~(select case max(t1.a) when min(coalesce((select ~coalesce((select max((abs(e)/abs(t1.d))*t1.b*13+t1.b) from t1 where t1.d=t1.f),t1.e)-d from t1 where e between t1.f and 19),(b))) then ~case ~cast(avg(t1.b) AS integer)+~case cast(avg(f) AS integer) when min(19) then  -min(t1.f) else (cast(avg(e) AS integer)) end when cast(avg(f) AS integer) then count(*) else count(distinct c) end-cast(avg(11) AS integer) else cast(avg(t1.f) AS integer) end & min(b) from t1))/abs(t1.b)) FROM t1 WHERE NOT (e<a)}\n} {0}\ndo_test randexpr-2.2228 {\n  db eval {SELECT case when not (select  -case (( -(count(*)) | cast(avg(d) AS integer))) | min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) | max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select  -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE (abs( -t1.f)/abs(t1.a))<=t1.d}\n} {200}\ndo_test randexpr-2.2229 {\n  db eval {SELECT case when not (select  -case (( -(count(*)) | cast(avg(d) AS integer))) | min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) | max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select  -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE NOT ((abs( -t1.f)/abs(t1.a))<=t1.d)}\n} {}\ndo_test randexpr-2.2230 {\n  db eval {SELECT case when not (select  -case (( -(count(*)) & cast(avg(d) AS integer))) & min((e)) when cast(avg(d) AS integer) then count(*) else count(distinct t1.e) end+max((17)) & max(t1.a)+ -count(*) from t1)-e in (t1.a,11-t1.d,t1.b) and coalesce((select max(t1.c) from t1 where case t1.d when t1.f then d else b end<>t1.d),d)>=13 then coalesce((select  -17+e from t1 where t1.a<=19),b) else (19) end FROM t1 WHERE (abs( -t1.f)/abs(t1.a))<=t1.d}\n} {200}\ndo_test randexpr-2.2231 {\n  db eval {SELECT case when 13 in (select cast(avg(11) AS integer) from t1 union select count(*) from t1) then t1.f-case c-(abs(d+~+t1.d-(abs(13)/abs(t1.e-t1.b-t1.c))*e)/abs(17*19+t1.e)) when 19 then 17 else a end when (t1.a in (select count(distinct 13) from t1 union select max(t1.f) from t1)) and c between ((c)) and (t1.a) then c else 19 end+t1.e FROM t1 WHERE 19<>t1.c}\n} {519}\ndo_test randexpr-2.2232 {\n  db eval {SELECT case when 13 in (select cast(avg(11) AS integer) from t1 union select count(*) from t1) then t1.f-case c-(abs(d+~+t1.d-(abs(13)/abs(t1.e-t1.b-t1.c))*e)/abs(17*19+t1.e)) when 19 then 17 else a end when (t1.a in (select count(distinct 13) from t1 union select max(t1.f) from t1)) and c between ((c)) and (t1.a) then c else 19 end+t1.e FROM t1 WHERE NOT (19<>t1.c)}\n} {}\ndo_test randexpr-2.2233 {\n  db eval {SELECT coalesce((select max(case when not exists(select 1 from t1 where coalesce((select a from t1 where (t1.c+t1.d<=t1.b and exists(select 1 from t1 where t1.f not in (~case when t1.d>d then t1.a else a end,( -e),t1.b))) and (c<>17)),e) in (select e from t1 union select d from t1)) then case when b not in (a,17,e) or f=t1.e then t1.d else d end else a end*19) from t1 where ((t1.c not between e and t1.e))),13) FROM t1 WHERE c not in (~t1.e,t1.e,a)}\n} {1900}\ndo_test randexpr-2.2234 {\n  db eval {SELECT coalesce((select max(case when not exists(select 1 from t1 where coalesce((select a from t1 where (t1.c+t1.d<=t1.b and exists(select 1 from t1 where t1.f not in (~case when t1.d>d then t1.a else a end,( -e),t1.b))) and (c<>17)),e) in (select e from t1 union select d from t1)) then case when b not in (a,17,e) or f=t1.e then t1.d else d end else a end*19) from t1 where ((t1.c not between e and t1.e))),13) FROM t1 WHERE NOT (c not in (~t1.e,t1.e,a))}\n} {}\ndo_test randexpr-2.2235 {\n  db eval {SELECT coalesce((select t1.f from t1 where d+(select count(distinct e) from t1)+~+ -~e-a+t1.a-b- -a*coalesce((select c-t1.d*case when ( -11<=e or b>= - -c and t1.c<t1.f) then (t1.d)-11 when a not between t1.b and t1.e then 11 else b end from t1 where t1.e<=11),t1.f)*t1.e<>19),t1.f) FROM t1 WHERE t1.f<>c}\n} {600}\ndo_test randexpr-2.2236 {\n  db eval {SELECT coalesce((select t1.f from t1 where d+(select count(distinct e) from t1)+~+ -~e-a+t1.a-b- -a*coalesce((select c-t1.d*case when ( -11<=e or b>= - -c and t1.c<t1.f) then (t1.d)-11 when a not between t1.b and t1.e then 11 else b end from t1 where t1.e<=11),t1.f)*t1.e<>19),t1.f) FROM t1 WHERE NOT (t1.f<>c)}\n} {}\ndo_test randexpr-2.2237 {\n  db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e | a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE f>=t1.d+(t1.a)}\n} {-281}\ndo_test randexpr-2.2238 {\n  db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e | a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE NOT (f>=t1.d+(t1.a))}\n} {}\ndo_test randexpr-2.2239 {\n  db eval {SELECT 19+case when d between t1.b and 19+t1.d*(select ~min(t1.e & a) from t1)-case when exists(select 1 from t1 where 19<>t1.a and 19 between case +19 when 19 then t1.e else e end and t1.a) then a when t1.a between 13 and f or (t1.f<19) and d>=t1.c and f not between a and t1.b then a else t1.d end then b else t1.a end+ -d FROM t1 WHERE f>=t1.d+(t1.a)}\n} {-281}\ndo_test randexpr-2.2240 {\n  db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a | d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else  -~count(*) end from t1)+e FROM t1 WHERE (e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e}\n} {902}\ndo_test randexpr-2.2241 {\n  db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a | d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else  -~count(*) end from t1)+e FROM t1 WHERE NOT ((e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e)}\n} {}\ndo_test randexpr-2.2242 {\n  db eval {SELECT t1.d+(select case max(t1.f) when count(distinct ~coalesce((select case when 17 in (select t1.b from t1 union select t1.e from t1) then c when (d<= -(abs(t1.a)/abs(t1.d))) then t1.b+ -case when t1.b<b then f when d not in ( - -f,11,t1.c) then d else t1.d end*a & d else e end-t1.e from t1 where a<f or a=f),c)) then cast(avg(17) AS integer) else  -~count(*) end from t1)+e FROM t1 WHERE (e-coalesce((select b+11+( -t1.e) | coalesce((select (abs(c)/abs(coalesce((select max(t1.b) from t1 where t1.d<=f),c)*t1.b)) from t1 where 13 not in (f,19,b)),e)+t1.b+t1.e+13+19-t1.b-t1.c from t1 where d>t1.a or t1.d>=t1.f),t1.a)-e)<=t1.e}\n} {902}\ndo_test randexpr-2.2243 {\n  db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where  -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) | case min(13) when max(11) then count(distinct  -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then  -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE (d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then  -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1))}\n} {}\ndo_test randexpr-2.2244 {\n  db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where  -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) | case min(13) when max(11) then count(distinct  -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then  -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE NOT ((d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then  -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1)))}\n} {1}\ndo_test randexpr-2.2245 {\n  db eval {SELECT (select count(distinct (select case ~abs(~+abs(case (max(17)) when max(coalesce((select ~b from t1 where (not exists(select 1 from t1 where  -17<>f or t1.d>=b and 19 between 19 and t1.b))),(abs(case when 19<>a then t1.c else t1.b end)/abs(19)))) then ~+cast(avg(19) AS integer) else min(t1.a) end) & case min(13) when max(11) then count(distinct  -d) else count(distinct t1.d) end)*max(t1.d) when count(*) then  -min(e) else (count(*)) end+count(*) from t1)) from t1) FROM t1 WHERE NOT ((d in (select abs(count(*) | case max((case when b<=13 then t1.b*e when case when t1.c between t1.d and a then t1.a when (f< -19) then t1.c else d end between t1.d and b then t1.e else t1.b end))-max((t1.c)) when max(t1.f) then  -abs(+cast(avg(19) AS integer)) else abs(max(t1.c)) end++max(17))- -cast(avg(f) AS integer) from t1 union select min(11) from t1)))}\n} {1}\ndo_test randexpr-2.2246 {\n  db eval {SELECT case d*coalesce((select e from t1 where t1.f in (case when not exists(select 1 from t1 where 19>=(+f-13)) then case when not not exists(select 1 from t1 where 17>=t1.d-13) then f else d end else t1.c end,c,+(abs(e)/abs(19*d | case 19 when b then 17 else b end-b))) or e between 13 and a),19) when b then c else t1.b end FROM t1 WHERE t1.b<=coalesce((select coalesce((select t1.a from t1 where not t1.b*(select max(t1.d) from t1)<a),e)-b-~11+t1.d from t1 where c not in (((abs((select  -case  -case abs(+count(*)-(count(distinct a))) when min(a) then min(d) else cast(avg(t1.a) AS integer) end when min(19) then cast(avg(a) AS integer) else min(d) end from t1) | d)/abs(d)))+19,17,11-c)),t1.c)}\n} {200}\ndo_test randexpr-2.2247 {\n  db eval {SELECT case d*coalesce((select e from t1 where t1.f in (case when not exists(select 1 from t1 where 19>=(+f-13)) then case when not not exists(select 1 from t1 where 17>=t1.d-13) then f else d end else t1.c end,c,+(abs(e)/abs(19*d | case 19 when b then 17 else b end-b))) or e between 13 and a),19) when b then c else t1.b end FROM t1 WHERE NOT (t1.b<=coalesce((select coalesce((select t1.a from t1 where not t1.b*(select max(t1.d) from t1)<a),e)-b-~11+t1.d from t1 where c not in (((abs((select  -case  -case abs(+count(*)-(count(distinct a))) when min(a) then min(d) else cast(avg(t1.a) AS integer) end when min(19) then cast(avg(a) AS integer) else min(d) end from t1) | d)/abs(d)))+19,17,11-c)),t1.c))}\n} {}\ndo_test randexpr-2.2248 {\n  db eval {SELECT 13-case when f in (select t1.f from t1 union select ~17 from t1) then ~t1.c*t1.f-(abs(17-e*c)/abs(b))*t1.b-11-a+19-coalesce((select (abs(case  -(abs(coalesce((select t1.f from t1 where t1.e in (t1.a,b,f)),t1.a))/abs(c)) when c then t1.c else c end)/abs(17)) from t1 where e<t1.c),f) else t1.c end- -d FROM t1 WHERE 17 in (select t1.f from t1 union select t1.d from t1) and (select max((case when t1.d*19 not between  -t1.e-case when e=t1.f then (select abs(max( -17)-count(*)-min(13)) from t1) else b- -(c) end*d* -t1.c and 11 then 19 else e end-t1.a-t1.f)+(a)) from t1) in (t1.b,b,t1.f) and 11<=e}\n} {}\ndo_test randexpr-2.2249 {\n  db eval {SELECT 13-case when f in (select t1.f from t1 union select ~17 from t1) then ~t1.c*t1.f-(abs(17-e*c)/abs(b))*t1.b-11-a+19-coalesce((select (abs(case  -(abs(coalesce((select t1.f from t1 where t1.e in (t1.a,b,f)),t1.a))/abs(c)) when c then t1.c else c end)/abs(17)) from t1 where e<t1.c),f) else t1.c end- -d FROM t1 WHERE NOT (17 in (select t1.f from t1 union select t1.d from t1) and (select max((case when t1.d*19 not between  -t1.e-case when e=t1.f then (select abs(max( -17)-count(*)-min(13)) from t1) else b- -(c) end*d* -t1.c and 11 then 19 else e end-t1.a-t1.f)+(a)) from t1) in (t1.b,b,t1.f) and 11<=e)}\n} {331505}\ndo_test randexpr-2.2250 {\n  db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end | f-t1.d<=t1.f then f else 19 end FROM t1 WHERE ((f not between t1.f and d))}\n} {600}\ndo_test randexpr-2.2251 {\n  db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end | f-t1.d<=t1.f then f else 19 end FROM t1 WHERE NOT (((f not between t1.f and d)))}\n} {}\ndo_test randexpr-2.2252 {\n  db eval {SELECT case when case when case when case when t1.b<> -c then (b)* -19 else t1.d end<=11 or 17 not between t1.f and 13 or a not in (t1.c,t1.b,11) then c else c end<>t1.a and (f) in (select cast(avg(11) AS integer) from t1 union select case max(b) when (min(t1.c)) then count(distinct f) else max(19) end from t1) then 13 else d end & f-t1.d<=t1.f then f else 19 end FROM t1 WHERE ((f not between t1.f and d))}\n} {600}\ndo_test randexpr-2.2253 {\n  db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then  - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) | b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end}\n} {199}\ndo_test randexpr-2.2254 {\n  db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then  - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) | b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE NOT (d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end)}\n} {}\ndo_test randexpr-2.2255 {\n  db eval {SELECT d-b-(abs(a)/abs(coalesce((select b from t1 where coalesce((select t1.f from t1 where 13>=f-b),t1.c)*case when coalesce((select case (d*t1.e+b) when t1.a-13 then  - -t1.d else t1.a end+13 from t1 where e>=t1.f),11) & b<t1.e then d else c end between c and d),11)-19))+11 FROM t1 WHERE d>=case when coalesce((select max(case when f<>~b | coalesce((select max(11*c) from t1 where 17=t1.f),t1.d)*d then b when a in (c,(t1.d),(f)) then a else 19 end-t1.f) from t1 where not 13 in (select cast(avg(t1.b) AS integer)-cast(avg( -t1.a) AS integer) from t1 union select count(*) from t1)),17) not in ((t1.f),c, -19) and e between 11 and (19) then 19 else t1.d end}\n} {199}\ndo_test randexpr-2.2256 {\n  db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e |  -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then  -e else t1.b end when t1.e then 11 else t1.e end then  -f else c end) | t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE not  -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct  -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1)}\n} {90100}\ndo_test randexpr-2.2257 {\n  db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e |  -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then  -e else t1.b end when t1.e then 11 else t1.e end then  -f else c end) | t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE NOT (not  -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct  -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1))}\n} {}\ndo_test randexpr-2.2258 {\n  db eval {SELECT coalesce((select max(coalesce((select 13 from t1 where not t1.b<>e*b),t1.c*case when d>=case case 13 when coalesce((select ~~t1.f*(abs(t1.f)/abs(t1.e))-e &  -t1.b from t1 where a in (11,13,t1.e)),d)*t1.e then  -e else t1.b end when t1.e then 11 else t1.e end then  -f else c end) & t1.a) from t1 where e>t1.d), -(t1.f)) FROM t1 WHERE not  -13 in (select (+(case case min(a+t1.a) when abs(count(*)-count(distinct t1.d-+(f)-case 19 when b then t1.b else a end)) then case count(*)*max(c) when ~ -count(*)*cast(avg(t1.e) AS integer)*count(distinct  -a) then count(*) else cast(avg(19) AS integer) end else cast(avg(b) AS integer) end when min(f) then max( -a) else (count(*)) end)*count(distinct t1.f)-count(*)) from t1 union select count(distinct f) from t1)}\n} {0}\ndo_test randexpr-2.2259 {\n  db eval {SELECT coalesce((select max(t1.e*~t1.b- -t1.b-t1.b-coalesce((select t1.a from t1 where exists(select 1 from t1 where ~d+case case when a between b and f then 13 else  -17 end-13 when  -19 then t1.f else d end+t1.b<>e or not t1.e between 19 and t1.a or 11 in (19,c, -19))),a)*e) from t1 where t1.f<19),t1.e)-13 FROM t1 WHERE t1.b not between e and 13}\n} {487}\ndo_test randexpr-2.2260 {\n  db eval {SELECT coalesce((select max(t1.e*~t1.b- -t1.b-t1.b-coalesce((select t1.a from t1 where exists(select 1 from t1 where ~d+case case when a between b and f then 13 else  -17 end-13 when  -19 then t1.f else d end+t1.b<>e or not t1.e between 19 and t1.a or 11 in (19,c, -19))),a)*e) from t1 where t1.f<19),t1.e)-13 FROM t1 WHERE NOT (t1.b not between e and 13)}\n} {}\ndo_test randexpr-2.2261 {\n  db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) | (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) | min(t1.c) from t1) when 11 not between  -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE not b*c+d<>b}\n} {}\ndo_test randexpr-2.2262 {\n  db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) | (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) | min(t1.c) from t1) when 11 not between  -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE NOT (not b*c+d<>b)}\n} {1}\ndo_test randexpr-2.2263 {\n  db eval {SELECT (select (count(distinct case t1.d+case when (coalesce((select max((select + -cast(avg(b) AS integer)-min(19) & (cast(avg(19) AS integer)) from t1)) from t1 where ~c+t1.c<t1.d),(c)) in (select t1.c from t1 union select t1.f from t1)) then (select abs( -min(t1.e)) & min(t1.c) from t1) when 11 not between  -d and a or a<>t1.a and f between t1.e and d and f<=19 then t1.f else t1.b end-c*a when t1.f then e else t1.b end)) from t1) FROM t1 WHERE NOT (not b*c+d<>b)}\n} {1}\ndo_test randexpr-2.2264 {\n  db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d | t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE (b)-t1.c*19-t1.b>17*b-13}\n} {}\ndo_test randexpr-2.2265 {\n  db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d | t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE NOT ((b)-t1.c*19-t1.b>17*b-13)}\n} {800}\ndo_test randexpr-2.2266 {\n  db eval {SELECT t1.b+case case c when f-((abs(t1.f)/abs(coalesce((select max(f+t1.d & t1.c*e+f+~case when c not between b and t1.a or 11<19 then c-d else t1.f end+e-t1.b*11+t1.e) from t1 where 17 not between e and 19),19)))) then d else a end when (t1.c) then t1.f else f end FROM t1 WHERE NOT ((b)-t1.c*19-t1.b>17*b-13)}\n} {800}\ndo_test randexpr-2.2267 {\n  db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 | d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE (t1.e in (select  -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when  -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1))}\n} {}\ndo_test randexpr-2.2268 {\n  db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 | d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE NOT ((t1.e in (select  -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when  -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1)))}\n} {-289}\ndo_test randexpr-2.2269 {\n  db eval {SELECT coalesce((select coalesce((select ((abs(19)/abs(17))) from t1 where +13 & d>d),13-(select abs(abs(~count(*)))+~count(*) from t1)+(t1.c*t1.e*(abs(19+(13))/abs(a)))-coalesce((select 17 from t1 where c<>e and b not in ((d),t1.b,b)),t1.c)+t1.d)-13 from t1 where t1.f<b),11)+ -t1.c FROM t1 WHERE NOT ((t1.e in (select  -(+min(f*t1.c)- -max(t1.a))-+min(b) | count(distinct 17) from t1 union select abs(case count(*) when abs(min(d*t1.c-t1.b*~b+c) | (max(case when not 19<(e) then 19 when  -17>19 then 17 else t1.c end)-count(*))) then max(11) else +max(b) end) from t1)))}\n} {-289}\ndo_test randexpr-2.2270 {\n  db eval {SELECT coalesce((select case d when e then t1.f else d++(abs((select count(*) from t1)-case when t1.f*case when t1.b-c in (select  -cast(avg(e) AS integer) from t1 union select max(t1.a) from t1) or b between t1.a and  -17 and  -t1.f not between 17 and a then t1.e when 17<>11 then (abs(19)/abs(f)) else 17 end-17 not in (13,11,c) then t1.f else t1.c end)/abs(c))*t1.e end from t1 where f between t1.c and 17),t1.f) FROM t1 WHERE t1.b<>19}\n} {600}\ndo_test randexpr-2.2271 {\n  db eval {SELECT coalesce((select case d when e then t1.f else d++(abs((select count(*) from t1)-case when t1.f*case when t1.b-c in (select  -cast(avg(e) AS integer) from t1 union select max(t1.a) from t1) or b between t1.a and  -17 and  -t1.f not between 17 and a then t1.e when 17<>11 then (abs(19)/abs(f)) else 17 end-17 not in (13,11,c) then t1.f else t1.c end)/abs(c))*t1.e end from t1 where f between t1.c and 17),t1.f) FROM t1 WHERE NOT (t1.b<>19)}\n} {}\ndo_test randexpr-2.2272 {\n  db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then  - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when  -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then  -cast(avg(a) AS integer) else cast(avg(19) AS integer) end | count(distinct 13)+ -count(*) from t1 union select  -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b}\n} {}\ndo_test randexpr-2.2273 {\n  db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then  - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when  -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then  -cast(avg(a) AS integer) else cast(avg(19) AS integer) end | count(distinct 13)+ -count(*) from t1 union select  -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE NOT (t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b)}\n} {1000}\ndo_test randexpr-2.2274 {\n  db eval {SELECT t1.f-case when ((t1.a in (select case case +min(case when coalesce((select max(a) from t1 where t1.e not between f and t1.b),f)<>(t1.d) then  - -t1.f else 19 end)-case count(*)+(count(distinct t1.d)) when  -min(e) then max(t1.f) else min(19) end when cast(avg(13) AS integer) then cast(avg( -t1.a) AS integer) else (min(t1.f)) end when (count(distinct t1.e)) then  -cast(avg(a) AS integer) else cast(avg(19) AS integer) end & count(distinct 13)+ -count(*) from t1 union select  -max(t1.b) from t1))) then a when d between a and 11 or t1.e<>c then +t1.a-(t1.e) else t1.e end FROM t1 WHERE NOT (t1.e between d | t1.a*13 and 11+13*17+b*c++13-~b)}\n} {1000}\ndo_test randexpr-2.2275 {\n  db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) | 19 from t1 where t1.d in (select  -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f)}\n} {}\ndo_test randexpr-2.2276 {\n  db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) | 19 from t1 where t1.d in (select  -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE NOT (not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f))}\n} {400}\ndo_test randexpr-2.2277 {\n  db eval {SELECT coalesce((select ~(abs(e)/abs(case when exists(select 1 from t1 where 19=+c or exists(select 1 from t1 where not exists(select 1 from t1 where 11>=d or b not between b and 19)) or t1.a not in (t1.a,(11),13)) then e-13+a-c else a end))*t1.f-(19) & 19 from t1 where t1.d in (select  -(cast(avg(19) AS integer)) from t1 union select count(distinct (t1.e)) from t1) and (f in (a,c,(t1.a))) and a between 11 and 11 and t1.d>=t1.f and 11 not in ((t1.f),e,(f)) and 13 not in (t1.c,t1.d,t1.c)),t1.d) FROM t1 WHERE NOT (not exists(select 1 from t1 where not coalesce((select max(b) from t1 where coalesce((select t1.f from t1 where t1.f not between t1.e and coalesce((select 13*+ -t1.a | e+case when t1.a not in (case t1.f when d then 19 else 11 end,f*e+19,t1.e+(d)) then 13 else t1.d end+t1.c-17 from t1 where t1.c>=t1.d),t1.c)),t1.d)>t1.c),11) not between b and t1.f))}\n} {400}\ndo_test randexpr-2.2278 {\n  db eval {SELECT case when (select +case  -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) | count(distinct 11) when  -cast(avg(13) AS integer) then  -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select  -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) | t1.f,f,f) then t1.e else a end FROM t1 WHERE (select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then  -count(distinct f) else count(distinct 11) end then max( -t1.d) else  -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a)}\n} {100}\ndo_test randexpr-2.2279 {\n  db eval {SELECT case when (select +case  -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) | count(distinct 11) when  -cast(avg(13) AS integer) then  -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select  -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) | t1.f,f,f) then t1.e else a end FROM t1 WHERE NOT ((select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then  -count(distinct f) else count(distinct 11) end then max( -t1.d) else  -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a))}\n} {}\ndo_test randexpr-2.2280 {\n  db eval {SELECT case when (select +case  -+ -case min(t1.f) when cast(avg(t1.a) AS integer) then abs(~case (min(t1.a)) when (count(*)) then (min(e)) else count(*) end) else ( -cast(avg(b) AS integer)) end*count(*) & count(distinct 11) when  -cast(avg(13) AS integer) then  -min(13) else max(b) end+max(a) from t1) in ((abs(coalesce((select max(11*a) from t1 where t1.b>11-(select  -cast(avg(t1.d) AS integer) from t1)),case when exists(select 1 from t1 where t1.f<13) then a else e end))/abs(c)) & t1.f,f,f) then t1.e else a end FROM t1 WHERE (select case min(case when not 17<11 then (abs(+(d)*t1.c+e-f)/abs(13)) when b between a and 11 then e else b end) when abs(min(t1.b) | (+count(*))) | ~case ( -count(*))-cast(avg(a) AS integer) when count(distinct t1.a) then  -count(distinct f) else count(distinct 11) end then max( -t1.d) else  -max(f) end from t1)-~c*t1.a not in (t1.e,t1.c,t1.a)}\n} {100}\ndo_test randexpr-2.2281 {\n  db eval {SELECT case when ~t1.b | 13>=~coalesce((select t1.e from t1 where 11 in (select  -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else  -( - -max(t1.f)) end from t1 union select count(*) from t1)),b | ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between  -t1.e and t1.e or f not between  -a and 19 then d else 11 end FROM t1 WHERE not (d in (select t1.c from t1 union select 11 from t1))}\n} {400}\ndo_test randexpr-2.2282 {\n  db eval {SELECT case when ~t1.b | 13>=~coalesce((select t1.e from t1 where 11 in (select  -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else  -( - -max(t1.f)) end from t1 union select count(*) from t1)),b | ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between  -t1.e and t1.e or f not between  -a and 19 then d else 11 end FROM t1 WHERE NOT (not (d in (select t1.c from t1 union select 11 from t1)))}\n} {}\ndo_test randexpr-2.2283 {\n  db eval {SELECT case when ~t1.b & 13>=~coalesce((select t1.e from t1 where 11 in (select  -case +max(case when (t1.f) in (t1.b,t1.a,t1.f) then f else e end) when max(f)*cast(avg(t1.d) AS integer) then cast(avg(c) AS integer) else  -( - -max(t1.f)) end from t1 union select count(*) from t1)),b & ( -t1.e))*t1.c*t1.a*t1.d-f then a when 19 not between  -t1.e and t1.e or f not between  -a and 19 then d else 11 end FROM t1 WHERE not (d in (select t1.c from t1 union select 11 from t1))}\n} {100}\ndo_test randexpr-2.2284 {\n  db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) | cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a)}\n} {30000}\ndo_test randexpr-2.2285 {\n  db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) | cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE NOT (not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a))}\n} {}\ndo_test randexpr-2.2286 {\n  db eval {SELECT coalesce((select c from t1 where 19 in (select case count(*) when count(distinct c)*+cast(avg(13) AS integer) then max(t1.d) else max(case case when exists(select 1 from t1 where 13 not in (d,e,(19)) and 13 between t1.d and t1.f) then t1.a when b in (t1.a,a,17) then case when t1.a not between 13 and c then (t1.b) else t1.b end else 19 end when 13 then a else 19 end) end from t1 union select (abs(abs(~cast(avg(t1.d) AS integer))) & cast(avg(t1.a) AS integer)) from t1)),t1.e-11)*(t1.a) FROM t1 WHERE not exists(select 1 from t1 where t1.e in (coalesce((select max(13) from t1 where 19 in (select f from t1 union select a from t1) or (not exists(select 1 from t1 where t1.a<=(19)*c*c | 13))),+e-(f)*case when t1.c not in (coalesce((select max(t1.a) from t1 where not c<(19)),19),e,(19)) then d else f end)+a,19,17)) or (d<t1.a)}\n} {30000}\ndo_test randexpr-2.2287 {\n  db eval {SELECT  -~a+d-case d when  -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) | case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then  - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE +c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c)}\n} {}\ndo_test randexpr-2.2288 {\n  db eval {SELECT  -~a+d-case d when  -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) | case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then  - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE NOT (+c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c))}\n} {395}\ndo_test randexpr-2.2289 {\n  db eval {SELECT  -~a+d-case d when  -(select max(d)*~min(coalesce((select max(t1.e) from t1 where (exists(select 1 from t1 where 17<>13))),t1.a)-f-a+t1.f) & case (cast(avg(t1.c) AS integer)) when cast(avg(t1.a) AS integer)-(count(*))+max(19) then  - -max(19) else cast(avg(e) AS integer) end from t1)+(select cast(avg(b) AS integer) from t1) then t1.a else e-t1.d end-17+11 FROM t1 WHERE NOT (+c-(c)*d in (coalesce((select max( -t1.d-d-13) from t1 where (t1.c) not between (abs(13)/abs(t1.c)) and t1.b),d),11,c))}\n} {395}\ndo_test randexpr-2.2290 {\n  db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a | b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else  -d end FROM t1 WHERE t1.e<t1.e}\n} {}\ndo_test randexpr-2.2291 {\n  db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a | b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else  -d end FROM t1 WHERE NOT (t1.e<t1.e)}\n} {100}\ndo_test randexpr-2.2292 {\n  db eval {SELECT case when 17 in (case (abs(coalesce((select max((select cast(avg(case when 17-(t1.b)+t1.a & b+b in (select b from t1 union select 17 from t1) then c when t1.f in (select t1.a from t1 union select 19 from t1) then 11 else t1.c end) AS integer) from t1)) from t1 where t1.e>=t1.e or (b)<b or t1.a>=b and c not in (f,t1.a,t1.a)),d))/abs(t1.b)) when 17 then t1.b else 13 end-a,13,17) then t1.a else  -d end FROM t1 WHERE NOT (t1.e<t1.e)}\n} {100}\ndo_test randexpr-2.2293 {\n  db eval {SELECT case t1.a when coalesce((select a from t1 where t1.b>19),b-case when +13>case when (coalesce((select b from t1 where coalesce((select max(t1.f) from t1 where 17<=case c when t1.e+f then d else case when 11<17 and t1.d<=t1.e then 13 when t1.d<>f then (t1.f) else c end end*t1.c),a) in (select 17 from t1 union select b from t1)),t1.c)>= -11) then (a)*t1.a else 19 end then 13 else 17 end*19) then d else (t1.a) end FROM t1 WHERE t1.d+t1.b not in (b,f,coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where c-t1.b not between case when coalesce((select max(~t1.e) from t1 where f not in (t1.b,17,t1.a)),t1.e) not in (e,13,(t1.d)) then 11 when t1.d>=17 then t1.c else 11 end and (11) and (exists(select 1 from t1 where t1.b<>11))) or 13 in (select max(t1.d) from t1 union select max(b) from t1)),t1.b+19+a))}\n} {}\ndo_test randexpr-2.2294 {\n  db eval {SELECT case t1.a when coalesce((select a from t1 where t1.b>19),b-case when +13>case when (coalesce((select b from t1 where coalesce((select max(t1.f) from t1 where 17<=case c when t1.e+f then d else case when 11<17 and t1.d<=t1.e then 13 when t1.d<>f then (t1.f) else c end end*t1.c),a) in (select 17 from t1 union select b from t1)),t1.c)>= -11) then (a)*t1.a else 19 end then 13 else 17 end*19) then d else (t1.a) end FROM t1 WHERE NOT (t1.d+t1.b not in (b,f,coalesce((select max(t1.b) from t1 where exists(select 1 from t1 where c-t1.b not between case when coalesce((select max(~t1.e) from t1 where f not in (t1.b,17,t1.a)),t1.e) not in (e,13,(t1.d)) then 11 when t1.d>=17 then t1.c else 11 end and (11) and (exists(select 1 from t1 where t1.b<>11))) or 13 in (select max(t1.d) from t1 union select max(b) from t1)),t1.b+19+a)))}\n} {400}\ndo_test randexpr-2.2295 {\n  db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e | e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE not exists(select 1 from t1 where  -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b}\n} {}\ndo_test randexpr-2.2296 {\n  db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e | e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE NOT (not exists(select 1 from t1 where  -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b)}\n} {-300}\ndo_test randexpr-2.2297 {\n  db eval {SELECT coalesce((select max((coalesce((select coalesce((select max(case when case when e<case 17 when case when t1.e=f then a else t1.b end then 13 else d end then t1.b when 13<>t1.f then t1.b else c end<b or 13<17 then e* -17 else 11 end*e & e) from t1 where 19<>19),t1.f) from t1 where t1.e<>t1.d),t1.b))) from t1 where 11=t1.c), -c) FROM t1 WHERE NOT (not exists(select 1 from t1 where  -~e not in (c++case when 17+t1.c<coalesce((select max(t1.c) from t1 where (not exists(select 1 from t1 where 19+coalesce((select a from t1 where d in (( -t1.a), - -b, -t1.f)),e)-a-c>=d))),f-13) then a else (t1.a) end+f*19-a,b,f)) and t1.a=b)}\n} {-300}\ndo_test randexpr-2.2298 {\n  db eval {SELECT t1.b-11-case when t1.d+13+t1.c | 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else  -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13}\n} {}\ndo_test randexpr-2.2299 {\n  db eval {SELECT t1.b-11-case when t1.d+13+t1.c | 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else  -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE NOT (case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13)}\n} {-111}\ndo_test randexpr-2.2300 {\n  db eval {SELECT t1.b-11-case when t1.d+13+t1.c & 17+case when (+a*t1.b*t1.c not in (e,t1.f,t1.e)) then coalesce((select max(e) from t1 where t1.f>=f), -d) when f>b and t1.e<t1.a or t1.f>t1.c then 17 else  -13 end not in (f,t1.f,a) and exists(select 1 from t1 where a<=11) then t1.e else c end FROM t1 WHERE NOT (case f+~d*case when t1.f<=t1.b*t1.a then e*t1.e else f end*a+f when ~case when 11 not between +(abs(b)/abs(case b+d when t1.a then f else t1.e end*13))+a and (b) then t1.e when t1.e<>11 then t1.d else 17 end+11 then t1.d else t1.b end<=13)}\n} {-111}\ndo_test randexpr-2.2301 {\n  db eval {SELECT coalesce((select t1.a from t1 where d not between 11 and 13 or case 13*17 when  -c then case when (coalesce((select 17 from t1 where (~case when t1.e=d then 19 when 11 in (t1.d,b,17) then t1.c else c end-11 in (select max(e) from t1 union select (case cast(avg((t1.b)) AS integer) when max(11) then min(17) else ( -count(*)) end) from t1))),(19))>d) then t1.d else 11 end else t1.c end<=a),c) FROM t1 WHERE 19 | (abs(t1.d)/abs(11))=b}\n} {}\ndo_test randexpr-2.2302 {\n  db eval {SELECT coalesce((select t1.a from t1 where d not between 11 and 13 or case 13*17 when  -c then case when (coalesce((select 17 from t1 where (~case when t1.e=d then 19 when 11 in (t1.d,b,17) then t1.c else c end-11 in (select max(e) from t1 union select (case cast(avg((t1.b)) AS integer) when max(11) then min(17) else ( -count(*)) end) from t1))),(19))>d) then t1.d else 11 end else t1.c end<=a),c) FROM t1 WHERE NOT (19 | (abs(t1.d)/abs(11))=b)}\n} {100}\ndo_test randexpr-2.2303 {\n  db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) | cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select  -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else  -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then  -t1.d else 13 end) FROM t1 WHERE exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else  -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f)}\n} {}\ndo_test randexpr-2.2304 {\n  db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) | cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select  -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else  -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then  -t1.d else 13 end) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else  -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f))}\n} {-400}\ndo_test randexpr-2.2305 {\n  db eval {SELECT coalesce((select max(17-t1.e-17) from t1 where (t1.c>d)),case when coalesce((select +f+~coalesce((select coalesce((select case when (select cast(avg(17) AS integer) & cast(avg(t1.e) AS integer) from t1)<>coalesce((select t1.e from t1 where 19 in (select count(*) from t1 union select  -( -count(*)) from t1)), -d) then b when exists(select 1 from t1 where t1.b between (t1.b) and 13) then a else  -b end from t1 where 19=e),t1.c) from t1 where t1.c<=b),t1.d) from t1 where 17 between t1.a and b),t1.e) between c and t1.e then  -t1.d else 13 end) FROM t1 WHERE NOT (exists(select 1 from t1 where t1.e-13-17-f*f*t1.d*coalesce((select 19-case when not not t1.d>e then case when t1.f<t1.a then case when e<=t1.c then t1.e when (c)>=t1.c then 19 else f end else  -t1.b end when e in (f,t1.e,17) then t1.a else t1.b end*t1.d from t1 where ((f)) in (select (~case count(distinct 11) when count(distinct t1.d) | count(distinct t1.b)-max( -f) then max(e) else (count(distinct (((a))))) end) from t1 union select max(e) from t1)),f)+c>=t1.f))}\n} {-400}\ndo_test randexpr-2.2306 {\n  db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) | min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE ++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11}\n} {}\ndo_test randexpr-2.2307 {\n  db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) | min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE NOT (++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11)}\n} {13}\ndo_test randexpr-2.2308 {\n  db eval {SELECT coalesce((select t1.b from t1 where exists(select 1 from t1 where (abs(~case (~13*case when c in (select (max(case when b<>11 then d when 13 not in (19,c,e) then t1.f else 19 end*t1.d)) from t1 union select abs(count(*)) & min(19) from t1) then t1.a else t1.c end-a-13-f*e*17) when f then t1.a else 13 end*t1.c)/abs(a))>t1.b)),13) FROM t1 WHERE NOT (++case when a<=t1.a then 17 else 13 end>+f+(coalesce((select max(19) from t1 where 11 not in (case when t1.e<(abs(11)/abs(19*d*t1.c)) and (c in (select t1.c from t1 union select f from t1) or a>a) then t1.a when 11 not between t1.c and t1.a or t1.e not in ( -t1.a,17,f) then t1.d else e end+t1.f,19,(17))),17))* -11)}\n} {13}\ndo_test randexpr-2.2309 {\n  db eval {SELECT case when c*(abs(t1.f)/abs(c))*b-11-t1.a<coalesce((select max(case when coalesce((select max(c*+(t1.e)) from t1 where t1.c+ - -t1.f*t1.b in (select a from t1 union select d from t1)),t1.e)<>t1.d then  -d else t1.f end*e) from t1 where (b)<>t1.a or 11 between ( -a) and a),t1.b) then t1.d when e=t1.e then t1.c else t1.e end FROM t1 WHERE (coalesce((select (t1.b)+f*case case +coalesce((select 13 from t1 where t1.e<=d),f)-a when d then t1.b else t1.c end+t1.e when a then 17 else t1.e end from t1 where not t1.d in (select b from t1 union select 19 from t1) or not (17<t1.a) or t1.c in (select count(*) from t1 union select max(t1.c) from t1)),t1.e) in (b,t1.b,t1.f) or not exists(select 1 from t1 where not t1.d between 11 and  -t1.f))}\n} {}\ndo_test randexpr-2.2310 {\n  db eval {SELECT case when c*(abs(t1.f)/abs(c))*b-11-t1.a<coalesce((select max(case when coalesce((select max(c*+(t1.e)) from t1 where t1.c+ - -t1.f*t1.b in (select a from t1 union select d from t1)),t1.e)<>t1.d then  -d else t1.f end*e) from t1 where (b)<>t1.a or 11 between ( -a) and a),t1.b) then t1.d when e=t1.e then t1.c else t1.e end FROM t1 WHERE NOT ((coalesce((select (t1.b)+f*case case +coalesce((select 13 from t1 where t1.e<=d),f)-a when d then t1.b else t1.c end+t1.e when a then 17 else t1.e end from t1 where not t1.d in (select b from t1 union select 19 from t1) or not (17<t1.a) or t1.c in (select count(*) from t1 union select max(t1.c) from t1)),t1.e) in (b,t1.b,t1.f) or not exists(select 1 from t1 where not t1.d between 11 and  -t1.f)))}\n} {300}\ndo_test randexpr-2.2311 {\n  db eval {SELECT (17)+coalesce((select (case when (case (case t1.d when t1.d then 11 else 13 end) when e then e else 13 end*11)*t1.c not between a and 11 then (17) else c end)+t1.a from t1 where 17 in (select max(t1.d)*count(distinct 17) from t1 union select  -cast(avg(t1.d) AS integer)*case case +min(t1.c) when min(e) then cast(avg(b) AS integer) else max(t1.d) end when (max(c)) then cast(avg(t1.b) AS integer) else count(distinct 17) end from t1)),b)-a FROM t1 WHERE ((abs(t1.c)/abs(a)) between 11 | 11 and  -b)}\n} {}\ndo_test randexpr-2.2312 {\n  db eval {SELECT (17)+coalesce((select (case when (case (case t1.d when t1.d then 11 else 13 end) when e then e else 13 end*11)*t1.c not between a and 11 then (17) else c end)+t1.a from t1 where 17 in (select max(t1.d)*count(distinct 17) from t1 union select  -cast(avg(t1.d) AS integer)*case case +min(t1.c) when min(e) then cast(avg(b) AS integer) else max(t1.d) end when (max(c)) then cast(avg(t1.b) AS integer) else count(distinct 17) end from t1)),b)-a FROM t1 WHERE NOT (((abs(t1.c)/abs(a)) between 11 | 11 and  -b))}\n} {117}\ndo_test randexpr-2.2313 {\n  db eval {SELECT case when case when  -f-case when t1.a between 13 and (e) then t1.d | a else 13 end<t1.d and  -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else  -e end FROM t1 WHERE not exists(select 1 from t1 where ((11<=+11)))}\n} {}\ndo_test randexpr-2.2314 {\n  db eval {SELECT case when case when  -f-case when t1.a between 13 and (e) then t1.d | a else 13 end<t1.d and  -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else  -e end FROM t1 WHERE NOT (not exists(select 1 from t1 where ((11<=+11))))}\n} {500}\ndo_test randexpr-2.2315 {\n  db eval {SELECT case when case when  -f-case when t1.a between 13 and (e) then t1.d & a else 13 end<t1.d and  -(13) in (select cast(avg(13) AS integer) from t1 union select +count(distinct c)-cast(avg(t1.c) AS integer) from t1) or not exists(select 1 from t1 where (not exists(select 1 from t1 where t1.e<>a) or ( -d) between c and c or (19) between t1.f and t1.b) or (b) not in (t1.d,t1.c,e)) then t1.b*t1.b when a>19 then t1.d else 11 end>=11 then t1.e else  -e end FROM t1 WHERE NOT (not exists(select 1 from t1 where ((11<=+11))))}\n} {500}\ndo_test randexpr-2.2316 {\n  db eval {SELECT (abs(+case when 11*t1.d not between 13 and t1.d then coalesce((select 17 from t1 where case ~e when (abs(+(b+(select ~ -cast(avg(t1.c) AS integer) from t1)))/abs(case 17 when 17 then c else a end)) then t1.d else t1.d end<>t1.a),f) when not exists(select 1 from t1 where (19<=(f))) and 17=t1.b or 19 not between a and a then t1.d else d end)/abs(b)) FROM t1 WHERE t1.d-13 in (t1.a,d,(t1.b))}\n} {}\ndo_test randexpr-2.2317 {\n  db eval {SELECT (abs(+case when 11*t1.d not between 13 and t1.d then coalesce((select 17 from t1 where case ~e when (abs(+(b+(select ~ -cast(avg(t1.c) AS integer) from t1)))/abs(case 17 when 17 then c else a end)) then t1.d else t1.d end<>t1.a),f) when not exists(select 1 from t1 where (19<=(f))) and 17=t1.b or 19 not between a and a then t1.d else d end)/abs(b)) FROM t1 WHERE NOT (t1.d-13 in (t1.a,d,(t1.b)))}\n} {0}\ndo_test randexpr-2.2318 {\n  db eval {SELECT b+(select case ~min(t1.a+13) when (cast(avg(t1.a) AS integer)) then max(d) else max(case when case t1.b when t1.e then t1.c else t1.f end+19<>+(select count(*) from t1) then case when b in (t1.e,t1.d,t1.e) and t1.c not between t1.f and 13 then (t1.c) when 17>t1.b then 19 else t1.b end-t1.d when d in (e,f,t1.f) and (a)<t1.c then 13 else  -t1.e end) end from t1)* -11-t1.f FROM t1 WHERE t1.a between (abs(e)/abs(a)) and t1.f-case when not (19)<>+t1.e then e+case when (exists(select 1 from t1 where d<17) and d<(abs(t1.e)/abs(+ - -t1.f+d))) then coalesce((select max((t1.f)) from t1 where not 19=t1.e),t1.e)+t1.e else t1.d end when not exists(select 1 from t1 where t1.d not in (19,11,t1.c)) then (t1.f) else d end}\n} {1800}\ndo_test randexpr-2.2319 {\n  db eval {SELECT b+(select case ~min(t1.a+13) when (cast(avg(t1.a) AS integer)) then max(d) else max(case when case t1.b when t1.e then t1.c else t1.f end+19<>+(select count(*) from t1) then case when b in (t1.e,t1.d,t1.e) and t1.c not between t1.f and 13 then (t1.c) when 17>t1.b then 19 else t1.b end-t1.d when d in (e,f,t1.f) and (a)<t1.c then 13 else  -t1.e end) end from t1)* -11-t1.f FROM t1 WHERE NOT (t1.a between (abs(e)/abs(a)) and t1.f-case when not (19)<>+t1.e then e+case when (exists(select 1 from t1 where d<17) and d<(abs(t1.e)/abs(+ - -t1.f+d))) then coalesce((select max((t1.f)) from t1 where not 19=t1.e),t1.e)+t1.e else t1.d end when not exists(select 1 from t1 where t1.d not in (19,11,t1.c)) then (t1.f) else d end)}\n} {}\ndo_test randexpr-2.2320 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) | case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE (select abs(+min(b)) from t1)<=d+t1.a}\n} {400}\ndo_test randexpr-2.2321 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) | case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE NOT ((select abs(+min(b)) from t1)<=d+t1.a)}\n} {}\ndo_test randexpr-2.2322 {\n  db eval {SELECT coalesce((select max(t1.d) from t1 where t1.b+b in (select (t1.c)*11*e+f+ -c-t1.b*coalesce((select max(a) from t1 where t1.a*17 between 19 and (((abs(f)/abs(t1.c+d))))),t1.c-(abs(t1.c)/abs(19)) & case when t1.d= -t1.f then b when (t1.c) not in (e, -11,19) then 19 else t1.a end-c)*t1.a-c from t1 union select t1.d from t1)),a) FROM t1 WHERE (select abs(+min(b)) from t1)<=d+t1.a}\n} {400}\ndo_test randexpr-2.2323 {\n  db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where  -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) | d<>11 then a else 19 end FROM t1 WHERE 13=b}\n} {}\ndo_test randexpr-2.2324 {\n  db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where  -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) | d<>11 then a else 19 end FROM t1 WHERE NOT (13=b)}\n} {100}\ndo_test randexpr-2.2325 {\n  db eval {SELECT case when coalesce((select c from t1 where (~13<>d)),t1.d-+d+13*coalesce((select max(17) from t1 where  -f<case when (abs(a+coalesce((select max(19) from t1 where not t1.d<>d),e))/abs(13))*f not in (t1.e,t1.c,e) then 19 when 17 not between t1.f and 17 then t1.f else t1.e end),f)+t1.c) & d<>11 then a else 19 end FROM t1 WHERE NOT (13=b)}\n} {100}\ndo_test randexpr-2.2326 {\n  db eval {SELECT case case t1.e+13 when case when not  -f>coalesce((select max(t1.b) from t1 where (select min(a) from t1)<a),a) then case when not exists(select 1 from t1 where d>t1.d and t1.c<19 and d between b and ( -c)) then (select case ~max( -( - -t1.f)) when min(e) then  -count(*) else count(*) end-cast(avg(b) AS integer) from t1) when 17<>11 then f else case  -17 when t1.d then b else  -t1.f end end+t1.e when t1.d>=11 then 17 else 11 end then t1.d else t1.d end when t1.c then t1.a else 11 end FROM t1 WHERE (coalesce((select coalesce((select max(coalesce((select max( -(select + -case ++case (count(*)) when cast(avg(11) AS integer) then count(*) else  -min(13) end when max(19) then  -cast(avg(11) AS integer) else count(distinct (b)) end | max(t1.a)+max(b) from t1)) from t1 where 11 in (select b from t1 union select 13 from t1)),case (select count(*) from t1) when 19 then case when d not between  -d and b then t1.f else t1.b end else t1.c end)+d-t1.e) from t1 where t1.f not between t1.c and 19),t1.b) from t1 where t1.c between d and  -t1.b),t1.b))>=c}\n} {}\ndo_test randexpr-2.2327 {\n  db eval {SELECT case case t1.e+13 when case when not  -f>coalesce((select max(t1.b) from t1 where (select min(a) from t1)<a),a) then case when not exists(select 1 from t1 where d>t1.d and t1.c<19 and d between b and ( -c)) then (select case ~max( -( - -t1.f)) when min(e) then  -count(*) else count(*) end-cast(avg(b) AS integer) from t1) when 17<>11 then f else case  -17 when t1.d then b else  -t1.f end end+t1.e when t1.d>=11 then 17 else 11 end then t1.d else t1.d end when t1.c then t1.a else 11 end FROM t1 WHERE NOT ((coalesce((select coalesce((select max(coalesce((select max( -(select + -case ++case (count(*)) when cast(avg(11) AS integer) then count(*) else  -min(13) end when max(19) then  -cast(avg(11) AS integer) else count(distinct (b)) end | max(t1.a)+max(b) from t1)) from t1 where 11 in (select b from t1 union select 13 from t1)),case (select count(*) from t1) when 19 then case when d not between  -d and b then t1.f else t1.b end else t1.c end)+d-t1.e) from t1 where t1.f not between t1.c and 19),t1.b) from t1 where t1.c between d and  -t1.b),t1.b))>=c)}\n} {11}\ndo_test randexpr-2.2328 {\n  db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case  -(13) when 13 then t1.f else a end | 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else  -(c) end>=t1.c then t1.d else c end FROM t1 WHERE t1.d<17-t1.a | a-+11}\n} {}\ndo_test randexpr-2.2329 {\n  db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case  -(13) when 13 then t1.f else a end | 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else  -(c) end>=t1.c then t1.d else c end FROM t1 WHERE NOT (t1.d<17-t1.a | a-+11)}\n} {300}\ndo_test randexpr-2.2330 {\n  db eval {SELECT case when +case when coalesce((select t1.b from t1 where not exists(select 1 from t1 where f<=coalesce((select c from t1 where t1.a in (select ~f from t1 union select coalesce((select max(case  -(13) when 13 then t1.f else a end & 13) from t1 where c<= -c or b not between f and t1.d and t1.b not in (e,t1.a,17)),a)+d from t1)),13) or t1.a>c)),11*19) between e and 17 then c else  -(c) end>=t1.c then t1.d else c end FROM t1 WHERE NOT (t1.d<17-t1.a | a-+11)}\n} {300}\ndo_test randexpr-2.2331 {\n  db eval {SELECT t1.c+c- -d*t1.d+t1.e | case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE (exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when  -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19)}\n} {161788}\ndo_test randexpr-2.2332 {\n  db eval {SELECT t1.c+c- -d*t1.d+t1.e | case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE NOT ((exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when  -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19))}\n} {}\ndo_test randexpr-2.2333 {\n  db eval {SELECT t1.c+c- -d*t1.d+t1.e & case when t1.e<=e and (a*t1.c) in (select ((abs(f)/abs(( -+(select abs(~(min( -c))-max( - -b)-count(*)) from t1))))) from t1 union select b from t1) then +a*t1.c-t1.d*t1.c else e end-t1.d+t1.f FROM t1 WHERE (exists(select 1 from t1 where coalesce((select max(++11+coalesce((select max(17) from t1 where case case when exists(select 1 from t1 where c not between t1.e and 17) then 19 else f end when  -t1.f then t1.f else t1.a end<=t1.e or 11 in (b,a,e) and e between 11 and 11), -(a)-19)*t1.f) from t1 where t1.b between d and 17 and 17=e),19) not in (a,b,b))) and (e>=d) or b not in (c,13,19)}\n} {12}\ndo_test randexpr-2.2334 {\n  db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) |  -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f)))}\n} {}\ndo_test randexpr-2.2335 {\n  db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) |  -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f))))}\n} {200}\ndo_test randexpr-2.2336 {\n  db eval {SELECT b-case when exists(select 1 from t1 where (exists(select 1 from t1 where t1.a not between 17 and a+t1.f) or not exists(select 1 from t1 where not exists(select 1 from t1 where t1.b+f+a in (select max(19) &  -max(t1.e)-cast(avg(t1.c) AS integer)- -count(distinct t1.b) from t1 union select max(t1.b) from t1)) or not exists(select 1 from t1 where not exists(select 1 from t1 where 11>c or (13) in ( -11,c,19)) or 11>f))) and t1.c not in ( -(d),t1.a,t1.a) and 17 in (t1.b,13,19)) then coalesce((select max(+19) from t1 where 17<b),13) else (abs(11)/abs(t1.e)) end FROM t1 WHERE NOT (not exists(select 1 from t1 where (13 between f and (e) or (f-d in (select t1.c*t1.d | f-19 from t1 union select 19*t1.d*coalesce((select coalesce((select max(t1.d-c*11) from t1 where 17= -t1.a),t1.a)-c from t1 where exists(select 1 from t1 where 17>e)),b) from t1))) or ((t1.d<f))))}\n} {200}\ndo_test randexpr-2.2337 {\n  db eval {SELECT coalesce((select t1.f*t1.b+case t1.a when 17 then  -t1.c else coalesce((select b from t1 where 19 in (f,d+b,coalesce((select t1.e-b from t1 where t1.b*d+case t1.c when case coalesce((select t1.b from t1 where c not in (b,a,13)),(13)) when t1.b then 19 else 19 end then t1.d else 19 end+ -b>= -t1.f),t1.c))),b) end from t1 where not a=11),t1.c) FROM t1 WHERE not 13<>11+17-case when 17 between (abs(case f when 19 | t1.a then +(select cast(avg(case when not exists(select 1 from t1 where ~ -13*(select  -cast(avg(t1.b*d) AS integer) from t1)+17<>(t1.b)) then ~t1.c when b>t1.d then c else (f) end) AS integer) from t1) else a end)/abs(19)) and t1.f then t1.b when a<>t1.c then t1.e else b end}\n} {}\ndo_test randexpr-2.2338 {\n  db eval {SELECT coalesce((select t1.f*t1.b+case t1.a when 17 then  -t1.c else coalesce((select b from t1 where 19 in (f,d+b,coalesce((select t1.e-b from t1 where t1.b*d+case t1.c when case coalesce((select t1.b from t1 where c not in (b,a,13)),(13)) when t1.b then 19 else 19 end then t1.d else 19 end+ -b>= -t1.f),t1.c))),b) end from t1 where not a=11),t1.c) FROM t1 WHERE NOT (not 13<>11+17-case when 17 between (abs(case f when 19 | t1.a then +(select cast(avg(case when not exists(select 1 from t1 where ~ -13*(select  -cast(avg(t1.b*d) AS integer) from t1)+17<>(t1.b)) then ~t1.c when b>t1.d then c else (f) end) AS integer) from t1) else a end)/abs(19)) and t1.f then t1.b when a<>t1.c then t1.e else b end)}\n} {120200}\ndo_test randexpr-2.2339 {\n  db eval {SELECT coalesce((select max(19) from t1 where t1.f*17+case t1.f when 11 then coalesce((select max(t1.a) from t1 where 13<>t1.d),(abs(13+b-case when not c+(abs(case when t1.c not between a and t1.f then  -(e) else t1.d end)/abs( -17))<a then 11 else t1.c end)/abs(17)))*d*t1.a else c end-((f))-e*t1.a<17),t1.f)+t1.a FROM t1 WHERE e>=13}\n} {119}\ndo_test randexpr-2.2340 {\n  db eval {SELECT coalesce((select max(19) from t1 where t1.f*17+case t1.f when 11 then coalesce((select max(t1.a) from t1 where 13<>t1.d),(abs(13+b-case when not c+(abs(case when t1.c not between a and t1.f then  -(e) else t1.d end)/abs( -17))<a then 11 else t1.c end)/abs(17)))*d*t1.a else c end-((f))-e*t1.a<17),t1.f)+t1.a FROM t1 WHERE NOT (e>=13)}\n} {}\ndo_test randexpr-2.2341 {\n  db eval {SELECT +coalesce((select max(e) from t1 where  -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) | case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else  -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE (select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select  -a from t1 where case a*f when t1.a then  -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1)}\n} {100}\ndo_test randexpr-2.2342 {\n  db eval {SELECT +coalesce((select max(e) from t1 where  -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) | case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else  -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE NOT ((select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select  -a from t1 where case a*f when t1.a then  -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1))}\n} {}\ndo_test randexpr-2.2343 {\n  db eval {SELECT +coalesce((select max(e) from t1 where  -(case 13*(t1.b* -case when e<=19 then b when t1.e=c then (b) else f end*t1.e) when e then 13 else t1.f end)=t1.b and t1.a in (select count(*) & case case min(b)*(count(*)) when abs(cast(avg(13) AS integer))-max(t1.d) then min(19) else  -cast(avg(b) AS integer) end when count(*) then (max(c)) else count(distinct 19) end+cast(avg((b)) AS integer) from t1 union select count(*) from t1)),t1.a) FROM t1 WHERE (select (min(13-(abs(c)/abs(case when coalesce((select case when coalesce((select  -a from t1 where case a*f when t1.a then  -c else (f) end between t1.a and t1.c),b) not between t1.e and b then 19 when 17 not in (19,d,11) then b else a end from t1 where b in (select t1.e from t1 union select t1.b from t1)),t1.a) not in (t1.e,t1.a,t1.f) then (d) else 19 end)))) from t1) in (select +13 from t1 union select 17 from t1)}\n} {100}\ndo_test randexpr-2.2344 {\n  db eval {SELECT case when b in (select 19 from t1 union select c from t1) then  -d else 19-13+coalesce((select t1.c from t1 where t1.d>=case when e in (select f*t1.b from t1 union select t1.d from t1) then t1.c when not exists(select 1 from t1 where t1.f not in (17,t1.c,11) and b between b and 17 or c in (t1.b,17,a) or t1.d>t1.d and t1.c<>11 and 13=e and t1.f not in ( -t1.c,19,f)) then coalesce((select max(case when t1.c in (t1.e,d,b) then t1.f else t1.a end) from t1 where e<=t1.f),11) else t1.b end*11),t1.e) end FROM t1 WHERE 13 not between +19 and a}\n} {506}\ndo_test randexpr-2.2345 {\n  db eval {SELECT case when b in (select 19 from t1 union select c from t1) then  -d else 19-13+coalesce((select t1.c from t1 where t1.d>=case when e in (select f*t1.b from t1 union select t1.d from t1) then t1.c when not exists(select 1 from t1 where t1.f not in (17,t1.c,11) and b between b and 17 or c in (t1.b,17,a) or t1.d>t1.d and t1.c<>11 and 13=e and t1.f not in ( -t1.c,19,f)) then coalesce((select max(case when t1.c in (t1.e,d,b) then t1.f else t1.a end) from t1 where e<=t1.f),11) else t1.b end*11),t1.e) end FROM t1 WHERE NOT (13 not between +19 and a)}\n} {}\ndo_test randexpr-2.2346 {\n  db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d | c+(select case count(*) | (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) | t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then  -d else t1.f end-t1.f)) FROM t1 WHERE (select  -count(*) from t1)=d+11}\n} {}\ndo_test randexpr-2.2347 {\n  db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d | c+(select case count(*) | (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) | t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then  -d else t1.f end-t1.f)) FROM t1 WHERE NOT ((select  -count(*) from t1)=d+11)}\n} {0}\ndo_test randexpr-2.2348 {\n  db eval {SELECT (abs(13)/abs(case when t1.f not between a and f then 19-t1.d-t1.d*d & c+(select case count(*) & (~ -count(*)) when cast(avg( -19) AS integer) then min(d) else (cast(avg(e) AS integer)) end from t1) & t1.f-t1.b when f<>case when f<>b and 19 in (d,( -t1.a),t1.c) then 11 when e not between b and (t1.d) then t1.e else t1.d end-t1.e or t1.b not in (f,c,(a)) then  -d else t1.f end-t1.f)) FROM t1 WHERE NOT ((select  -count(*) from t1)=d+11)}\n} {0}\ndo_test randexpr-2.2349 {\n  db eval {SELECT ((select count(distinct 11+19 | case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) | count(*) from t1)) FROM t1 WHERE case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1)}\n} {}\ndo_test randexpr-2.2350 {\n  db eval {SELECT ((select count(distinct 11+19 | case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) | count(*) from t1)) FROM t1 WHERE NOT (case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1))}\n} {1}\ndo_test randexpr-2.2351 {\n  db eval {SELECT ((select count(distinct 11+19 & case (d) when t1.b then coalesce((select case coalesce((select max(+c*t1.f) from t1 where (t1.e=f and 13<=t1.d)), -17)+11-t1.a when (t1.c) then 19 else 13 end from t1 where t1.c in (select ~+ -count(distinct t1.f) from t1 union select count(*)+count(distinct b)*min(11) from t1)),e) else 19 end+d) & count(*) from t1)) FROM t1 WHERE NOT (case b when 19 then ~b-~e-d+d+t1.c else a end in (select max(t1.b)-~count(*)+abs(abs((case min((abs(~t1.c*t1.f)/abs(t1.e))) when case max(b) when abs(count(distinct t1.b)) then +cast(avg((13)) AS integer) else +case min(b) when count(*) then count(*) else count(distinct t1.f) end end then max(19) else ( -count(*)) end)))*count(distinct f)*cast(avg(t1.c) AS integer) from t1 union select count(distinct a) from t1))}\n} {1}\ndo_test randexpr-2.2352 {\n  db eval {SELECT 17+ -(abs(case case when a>t1.c then t1.e else a end*11-case when not exists(select 1 from t1 where coalesce((select  -t1.e-11+coalesce((select t1.e from t1 where 13=t1.e),d) from t1 where t1.e between t1.d and a),13)-t1.e in (select t1.d from t1 union select d from t1)) then t1.b else t1.d end-t1.e-13+b when 19 then t1.b else c end)/abs(t1.d)) FROM t1 WHERE coalesce((select max(t1.d) from t1 where t1.a+t1.d<19),t1.a) in (select t1.b from t1 union select c from t1) or t1.c in (select  -abs(max(case when  -f<>t1.b and b<>11 then t1.f when t1.a=e then t1.d else  -(f) end) | case cast(avg(f) AS integer) when count(distinct t1.f) then min(e) else  -count(*) end+cast(avg((t1.f)) AS integer)) from t1 union select max(17) from t1) or t1.c between ((c)) and  -t1.b and  -c not between d and 11 or b>=19}\n} {17}\ndo_test randexpr-2.2353 {\n  db eval {SELECT 17+ -(abs(case case when a>t1.c then t1.e else a end*11-case when not exists(select 1 from t1 where coalesce((select  -t1.e-11+coalesce((select t1.e from t1 where 13=t1.e),d) from t1 where t1.e between t1.d and a),13)-t1.e in (select t1.d from t1 union select d from t1)) then t1.b else t1.d end-t1.e-13+b when 19 then t1.b else c end)/abs(t1.d)) FROM t1 WHERE NOT (coalesce((select max(t1.d) from t1 where t1.a+t1.d<19),t1.a) in (select t1.b from t1 union select c from t1) or t1.c in (select  -abs(max(case when  -f<>t1.b and b<>11 then t1.f when t1.a=e then t1.d else  -(f) end) | case cast(avg(f) AS integer) when count(distinct t1.f) then min(e) else  -count(*) end+cast(avg((t1.f)) AS integer)) from t1 union select max(17) from t1) or t1.c between ((c)) and  -t1.b and  -c not between d and 11 or b>=19)}\n} {}\ndo_test randexpr-2.2354 {\n  db eval {SELECT e*~+(e)-(abs(~case when (t1.f)>13+~t1.d then case when d=t1.b+13 then 17 when 11 in (t1.d,e,e) then ~19*t1.a else coalesce((select t1.c from t1 where 19*(abs(t1.e)/abs(b)) between t1.c and t1.c),t1.d) end when a not between 13 and  -17 then 19 else b end)/abs(t1.b)) FROM t1 WHERE (not d>case t1.b+t1.f when +(~(select (case abs(cast(avg(13) AS integer)) when cast(avg(+a) AS integer) then abs(abs(count(distinct case when t1.f*e<=11 then 13 when exists(select 1 from t1 where t1.e<17 or t1.a>=t1.a) then (11) else f end))) else min(t1.b)-min(11) end) from t1))+17*t1.b*f*17 then e else 11 end)}\n} {}\ndo_test randexpr-2.2355 {\n  db eval {SELECT e*~+(e)-(abs(~case when (t1.f)>13+~t1.d then case when d=t1.b+13 then 17 when 11 in (t1.d,e,e) then ~19*t1.a else coalesce((select t1.c from t1 where 19*(abs(t1.e)/abs(b)) between t1.c and t1.c),t1.d) end when a not between 13 and  -17 then 19 else b end)/abs(t1.b)) FROM t1 WHERE NOT ((not d>case t1.b+t1.f when +(~(select (case abs(cast(avg(13) AS integer)) when cast(avg(+a) AS integer) then abs(abs(count(distinct case when t1.f*e<=11 then 13 when exists(select 1 from t1 where t1.e<17 or t1.a>=t1.a) then (11) else f end))) else min(t1.b)-min(11) end) from t1))+17*t1.b*f*17 then e else 11 end))}\n} {-250502}\ndo_test randexpr-2.2356 {\n  db eval {SELECT  -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) | ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 | e then b else  -13 end*e-c FROM t1 WHERE b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b}\n} {6200}\ndo_test randexpr-2.2357 {\n  db eval {SELECT  -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) | ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 | e then b else  -13 end*e-c FROM t1 WHERE NOT (b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b)}\n} {}\ndo_test randexpr-2.2358 {\n  db eval {SELECT  -case when t1.c<= -case coalesce((select max((coalesce((select case 11 when t1.b then t1.f else 11 end-d from t1 where c in (select count(*) & ~count(distinct f) from t1 union select count(*) from t1)),a)*t1.a)-t1.f) from t1 where not exists(select 1 from t1 where ((t1.f not in ( -c,t1.d,b)) or t1.a not in (b,11,t1.c)) or t1.d not in (17,a,t1.a))),19)-t1.b when d then t1.e else t1.e end-19 & e then b else  -13 end*e-c FROM t1 WHERE b<>coalesce((select max((abs((abs(11)/abs(13)))/abs(case when t1.e between 11 and 19 then t1.d when 11>=b-19 then (select count(distinct ~a | 19*f+case when f not in (t1.e,t1.f, -t1.f) then 17 when c not in ( -t1.a,t1.c,b) then f else 11 end) from t1) else t1.e end))-t1.e*a) from t1 where e in (t1.c,17,17)),t1.a) or a=t1.e or d>t1.b}\n} {-100300}\ndo_test randexpr-2.2359 {\n  db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end | count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11}\n} {}\ndo_test randexpr-2.2360 {\n  db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end | count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE NOT (a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11)}\n} {2}\ndo_test randexpr-2.2361 {\n  db eval {SELECT (abs(case when t1.d not in (t1.f,t1.d,(select abs(min(((select +count(*)*case max(t1.e-coalesce((select max(case t1.b when 13 then a else e end) from t1 where t1.b>b),19)+d)- -+count(*) when +cast(avg(d) AS integer) then max(c) else (cast(avg(c) AS integer)) end & count(*) from t1)+t1.f)))-max(t1.c) from t1)) then t1.b*t1.f else f end)/abs(b+19)) FROM t1 WHERE NOT (a not in ((11),(t1.d),a) or case when f<t1.e | 11+t1.b+17-coalesce((select t1.f+case when ((not (t1.d)>(abs(d)/abs(t1.d)))) then a when f not between t1.f | t1.b and t1.d then a else 13 end from t1 where 19<=c),f) then t1.a else f end between 13 and 11)}\n} {2}\ndo_test randexpr-2.2362 {\n  db eval {SELECT t1.a+d | +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) | min(t1.b)) then  -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b | 13 else t1.c end FROM t1 WHERE coalesce((select max(coalesce((select  -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select  -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when  -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13}\n} {}\ndo_test randexpr-2.2363 {\n  db eval {SELECT t1.a+d | +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) | min(t1.b)) then  -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b | 13 else t1.c end FROM t1 WHERE NOT (coalesce((select max(coalesce((select  -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select  -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when  -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13)}\n} {508}\ndo_test randexpr-2.2364 {\n  db eval {SELECT t1.a+d & +case when +t1.a-t1.f++t1.c+(select case ~count(*) when (+cast(avg(f*t1.f) AS integer) & min(t1.b)) then  -(cast(avg(t1.f) AS integer)) else min(e) end from t1)-b* - -13-f+c in (select b from t1 union select t1.d from t1) or e<e then b & 13 else t1.c end FROM t1 WHERE NOT (coalesce((select max(coalesce((select  -e*a from t1 where (select max(case t1.a when b then d else 17 end) from t1) in (select 17 from t1 union select  -case when exists(select 1 from t1 where coalesce((select t1.d from t1 where t1.a not between t1.d and 17 and 19=17),t1.c)-t1.e+b<=a) then 17 | c when  -e<=d then 13 else (b) end from t1)),e)) from t1 where t1.e not in (11, -t1.b,(f))),t1.c) not in ( -c,t1.d,t1.d) and b<=13)}\n} {292}\ndo_test randexpr-2.2365 {\n  db eval {SELECT coalesce((select max((select (max((abs(coalesce((select max(+case when ~t1.d=t1.a then a when coalesce((select case when t1.c in (select 19 from t1 union select (d) from t1) then e else f end from t1 where t1.a<>t1.a),t1.f) between t1.a and 19 then ( -b) else t1.a end) from t1 where t1.c in (a,(f),e)),t1.c))/abs(a)))) from t1)) from t1 where case when exists(select 1 from t1 where e<11) and 17 in (select 11 from t1 union select a from t1) then d else (d) end in (select cast(avg(f) AS integer) from t1 union select count(*) from t1)),t1.d) FROM t1 WHERE exists(select 1 from t1 where b not between case 11 when d then (select + -(abs(abs(case  -min(d)+ - -count(*)-max(c) when count(*) then max(t1.b) else count(*) end))) from t1)+t1.f-f*t1.b*((select min(a) from t1))-b+f else t1.e end | t1.c+13 and 19) and b<t1.c or (17>t1.e)}\n} {400}\ndo_test randexpr-2.2366 {\n  db eval {SELECT coalesce((select max((select (max((abs(coalesce((select max(+case when ~t1.d=t1.a then a when coalesce((select case when t1.c in (select 19 from t1 union select (d) from t1) then e else f end from t1 where t1.a<>t1.a),t1.f) between t1.a and 19 then ( -b) else t1.a end) from t1 where t1.c in (a,(f),e)),t1.c))/abs(a)))) from t1)) from t1 where case when exists(select 1 from t1 where e<11) and 17 in (select 11 from t1 union select a from t1) then d else (d) end in (select cast(avg(f) AS integer) from t1 union select count(*) from t1)),t1.d) FROM t1 WHERE NOT (exists(select 1 from t1 where b not between case 11 when d then (select + -(abs(abs(case  -min(d)+ - -count(*)-max(c) when count(*) then max(t1.b) else count(*) end))) from t1)+t1.f-f*t1.b*((select min(a) from t1))-b+f else t1.e end | t1.c+13 and 19) and b<t1.c or (17>t1.e))}\n} {}\ndo_test randexpr-2.2367 {\n  db eval {SELECT case when t1.d+b+c | case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) |  - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d)}\n} {619}\ndo_test randexpr-2.2368 {\n  db eval {SELECT case when t1.d+b+c | case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) |  - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE NOT (coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d))}\n} {}\ndo_test randexpr-2.2369 {\n  db eval {SELECT case when t1.d+b+c & case +a-t1.d-f*(select cast(avg(17) AS integer)+count(distinct e)-count(distinct t1.a) &  - -cast(avg(t1.b) AS integer) from t1)+~t1.e-a when d then t1.f else d end+t1.e*b<>11 then f when t1.a=b or t1.b>(t1.d) then 19 else t1.f end+19 FROM t1 WHERE coalesce((select case t1.e-case coalesce((select (select min(t1.d) from t1) from t1 where coalesce((select max(coalesce((select max(a) from t1 where t1.d in (select cast(avg(t1.b) AS integer) from t1 union select count(distinct a) from t1)), -19)*t1.e) from t1 where d>11),t1.f)>17),t1.f) when (17) then e else d end when b then (19) else 19 end from t1 where not t1.f in (select ( -max(13)) from t1 union select max(c) from t1)),11)-d not in ( -19,13,d)}\n} {619}\ndo_test randexpr-2.2370 {\n  db eval {SELECT case when (t1.a not in (coalesce((select 17 from t1 where case when t1.b*(abs( -t1.b*f*coalesce((select 17 from t1 where not t1.d<t1.d),t1.b)*t1.a+19* -17)/abs(b))<=b then t1.b else 13 end+t1.d not between t1.b and  - -11),d),11,t1.e) or a<=19) or t1.e not between t1.c and 13 then 13 else e end FROM t1 WHERE t1.f+(abs(f)/abs((abs(t1.e+19)/abs(t1.c))*t1.d)) in (e*11,(select count(*) from t1),t1.e)}\n} {}\ndo_test randexpr-2.2371 {\n  db eval {SELECT case when (t1.a not in (coalesce((select 17 from t1 where case when t1.b*(abs( -t1.b*f*coalesce((select 17 from t1 where not t1.d<t1.d),t1.b)*t1.a+19* -17)/abs(b))<=b then t1.b else 13 end+t1.d not between t1.b and  - -11),d),11,t1.e) or a<=19) or t1.e not between t1.c and 13 then 13 else e end FROM t1 WHERE NOT (t1.f+(abs(f)/abs((abs(t1.e+19)/abs(t1.c))*t1.d)) in (e*11,(select count(*) from t1),t1.e))}\n} {13}\ndo_test randexpr-2.2372 {\n  db eval {SELECT case when case when (case (t1.a)*case when c<f and t1.e<>t1.d then 13 when c>b then c else 11 end when e then a else t1.e end>c) or 19 in (select ++min(f) from t1 union select  -count(distinct t1.a) from t1) then (case when t1.f in (select t1.f from t1 union select  -t1.a from t1) then c when b not between t1.a and b then  -t1.c else t1.a end) else t1.c end not in (f,a,17) then 11 else 11 end FROM t1 WHERE not c not between (select abs(max(~(19*e-t1.a*c*t1.d))*~abs((abs(min(a)-min(c) | cast(avg(19) AS integer))) | count(distinct 19)) | (cast(avg(d) AS integer))) from t1) and (abs(case coalesce((select max(19) from t1 where b not between a and f or 19 in (t1.c,t1.c,b)),t1.e) when c then f else 11 end)/abs(c))}\n} {}\ndo_test randexpr-2.2373 {\n  db eval {SELECT case when case when (case (t1.a)*case when c<f and t1.e<>t1.d then 13 when c>b then c else 11 end when e then a else t1.e end>c) or 19 in (select ++min(f) from t1 union select  -count(distinct t1.a) from t1) then (case when t1.f in (select t1.f from t1 union select  -t1.a from t1) then c when b not between t1.a and b then  -t1.c else t1.a end) else t1.c end not in (f,a,17) then 11 else 11 end FROM t1 WHERE NOT (not c not between (select abs(max(~(19*e-t1.a*c*t1.d))*~abs((abs(min(a)-min(c) | cast(avg(19) AS integer))) | count(distinct 19)) | (cast(avg(d) AS integer))) from t1) and (abs(case coalesce((select max(19) from t1 where b not between a and f or 19 in (t1.c,t1.c,b)),t1.e) when c then f else 11 end)/abs(c)))}\n} {11}\ndo_test randexpr-2.2374 {\n  db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c | 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) | count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else  -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c}\n} {}\ndo_test randexpr-2.2375 {\n  db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c | 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) | count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE NOT (coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else  -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c)}\n} {-270}\ndo_test randexpr-2.2376 {\n  db eval {SELECT (select count(*)-+ -(max(~coalesce((select ~b from t1 where not t1.c & 19 not between c+t1.c and d),a)*(abs(t1.a)/abs(d*(case t1.a*case when 17>e then 11 else 13 end when 19 then e else t1.d end)))+17))-cast(avg(c) AS integer) & count(distinct f) from t1)+(select abs(min(11)) from t1) FROM t1 WHERE NOT (coalesce((select max(11) from t1 where case when b<=13-~case when ~~(select count(*)+count(*)* -count(*) from t1)>17*17 then t1.f+case when not case when 19 in (t1.e,a,19) then 17 when f<=19 then 17 else  -d end=19 then f when a>=19 then d else f end else t1.c end | f then 19 else b end*t1.d between e and b),f)<c)}\n} {11}\ndo_test randexpr-2.2377 {\n  db eval {SELECT case when ((select max((t1.e+19 | (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct  -t1.a) |  - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d | t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE (select min(a) from t1)<t1.e}\n} {-389}\ndo_test randexpr-2.2378 {\n  db eval {SELECT case when ((select max((t1.e+19 | (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct  -t1.a) |  - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d | t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE NOT ((select min(a) from t1)<t1.e)}\n} {}\ndo_test randexpr-2.2379 {\n  db eval {SELECT case when ((select max((t1.e+19 & (abs((select case ++cast(avg(b-coalesce((select t1.c from t1 where t1.e not in (t1.a, -e,e)),c)) AS integer) when count(distinct t1.b) then count(distinct  -t1.a) &  - -count(distinct t1.b) else count(*) end*( -(min(11)))+(min(t1.f))-(count(*)) from t1))/abs(b+t1.b+t1.d & t1.e-19+t1.a))*t1.c)) from t1))>19 then 11 else 17 end-t1.d FROM t1 WHERE (select min(a) from t1)<t1.e}\n} {-383}\ndo_test randexpr-2.2380 {\n  db eval {SELECT t1.d*11-case 11 when a then 11 else  - -t1.b-(t1.b)+c+t1.a* -case when not exists(select 1 from t1 where coalesce((select t1.c from t1 where t1.c=case when 13 in (coalesce((select max(coalesce((select max(t1.c) from t1 where c between t1.d and t1.f and t1.a<=b),e)) from t1 where (11 not in (b,19,c))),b),e, -b) then 17 when t1.a in (b,t1.d,b) and t1.f>c then t1.a else (d) end),d)<= -t1.c) then t1.e*t1.c else 13 end end FROM t1 WHERE exists(select 1 from t1 where ((b not between f and t1.a)))}\n} {15004100}\ndo_test randexpr-2.2381 {\n  db eval {SELECT t1.d*11-case 11 when a then 11 else  - -t1.b-(t1.b)+c+t1.a* -case when not exists(select 1 from t1 where coalesce((select t1.c from t1 where t1.c=case when 13 in (coalesce((select max(coalesce((select max(t1.c) from t1 where c between t1.d and t1.f and t1.a<=b),e)) from t1 where (11 not in (b,19,c))),b),e, -b) then 17 when t1.a in (b,t1.d,b) and t1.f>c then t1.a else (d) end),d)<= -t1.c) then t1.e*t1.c else 13 end end FROM t1 WHERE NOT (exists(select 1 from t1 where ((b not between f and t1.a))))}\n} {}\ndo_test randexpr-2.2382 {\n  db eval {SELECT t1.c*case when not b>(+coalesce((select t1.e from t1 where t1.b>(abs(case when t1.d<=c+ -17*t1.f*19*17 then 11+a-13-t1.d else case (select abs(count(distinct 19))+ -count(distinct 17) from t1) when 17*t1.d then a else t1.a end end)/abs(17))),(11)))+17 then (t1.c)*f else 17 end FROM t1 WHERE (t1.b)-b<=t1.a*13}\n} {54000000}\ndo_test randexpr-2.2383 {\n  db eval {SELECT t1.c*case when not b>(+coalesce((select t1.e from t1 where t1.b>(abs(case when t1.d<=c+ -17*t1.f*19*17 then 11+a-13-t1.d else case (select abs(count(distinct 19))+ -count(distinct 17) from t1) when 17*t1.d then a else t1.a end end)/abs(17))),(11)))+17 then (t1.c)*f else 17 end FROM t1 WHERE NOT ((t1.b)-b<=t1.a*13)}\n} {}\ndo_test randexpr-2.2384 {\n  db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f |  -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a)}\n} {}\ndo_test randexpr-2.2385 {\n  db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f |  -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE NOT (d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a))}\n} {219}\ndo_test randexpr-2.2386 {\n  db eval {SELECT t1.b+coalesce((select max(~e- -t1.d+case +b+f when a-case when t1.a-d+t1.c between t1.e and a*e then (abs(e)/abs(t1.a)) else f &  -f*t1.b-t1.c end*t1.e+f then 19 else t1.b end*19) from t1 where 19 in (select e from t1 union select 17 from t1)),19) FROM t1 WHERE NOT (d in (11,t1.c+c*t1.d+case when t1.c-case when ~(19+13)*c=11 and d<>17 or t1.e>=c then case t1.a when c then f else 11 end+t1.c when t1.f in (select max(13) from t1 union select cast(avg(c) AS integer) from t1) or t1.c<t1.b then 13 else b end=13 then 11 when d<>t1.b then t1.e else 19 end,a))}\n} {219}\ndo_test randexpr-2.2387 {\n  db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end | max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) | coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) |  -t1.e FROM t1 WHERE exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select  -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b)}\n} {}\ndo_test randexpr-2.2388 {\n  db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end | max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) | coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) |  -t1.e FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select  -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b))}\n} {-499}\ndo_test randexpr-2.2389 {\n  db eval {SELECT (abs((select (case (abs(max( -t1.a))* -case count(*) when case min(c) when max(d) then count(*) else max(17) end-cast(avg(17) AS integer) then max(11) else cast(avg(t1.d) AS integer) end & max(13)+max(f)) when cast(avg(f) AS integer) then cast(avg(19) AS integer) else (max(11)) end) from t1) & coalesce((select (select max( -t1.d) from t1) from t1 where t1.b-~e in (select d from t1 union select e from t1) and t1.e=t1.d), -t1.e)-17)/abs(t1.e)) &  -t1.e FROM t1 WHERE NOT (exists(select 1 from t1 where coalesce((select +19 from t1 where (coalesce((select max(e) from t1 where ((coalesce((select max(19) from t1 where coalesce((select t1.d*19+(t1.c) from t1 where e in (select  -11 from t1 union select t1.f from t1) and (t1.d) in (select ~max(t1.e) from t1 union select (( -count(*))) from t1) or 19>=(a)),f) in ((e),e,t1.a)),t1.a)<=t1.c))),t1.f+t1.c)>13)),11) in (11,17,t1.d) and e>=t1.b))}\n} {0}\ndo_test randexpr-2.2390 {\n  db eval {SELECT f-coalesce((select 19+t1.e+t1.f from t1 where +11>coalesce((select +t1.f from t1 where t1.a between ~ -(select case cast(avg((abs(t1.d)/abs(t1.b))) AS integer) when  -~max(19) then  - -case count(distinct c) when count(*) then min((a)) else  -min(t1.d) end else max( -t1.b) end from t1) and (select count(distinct f) from t1)),(coalesce((select max(t1.e) from t1 where not 11>=d),t1.c)))),19)-t1.f+19+f*t1.d FROM t1 WHERE f in (select (min((abs(d-t1.c+coalesce((select t1.f from t1 where f<t1.a),t1.c)+a-t1.d*(f)-19)/abs(11))) | abs((count(*))))+(abs(~case count(*) | max(t1.a) when max(t1.d) then count(distinct 19) else count(distinct e) end)+cast(avg((t1.e)) AS integer))+max(t1.c) from t1 union select count(*) from t1) and c*t1.a in (select e from t1 union select f from t1)}\n} {}\ndo_test randexpr-2.2391 {\n  db eval {SELECT f-coalesce((select 19+t1.e+t1.f from t1 where +11>coalesce((select +t1.f from t1 where t1.a between ~ -(select case cast(avg((abs(t1.d)/abs(t1.b))) AS integer) when  -~max(19) then  - -case count(distinct c) when count(*) then min((a)) else  -min(t1.d) end else max( -t1.b) end from t1) and (select count(distinct f) from t1)),(coalesce((select max(t1.e) from t1 where not 11>=d),t1.c)))),19)-t1.f+19+f*t1.d FROM t1 WHERE NOT (f in (select (min((abs(d-t1.c+coalesce((select t1.f from t1 where f<t1.a),t1.c)+a-t1.d*(f)-19)/abs(11))) | abs((count(*))))+(abs(~case count(*) | max(t1.a) when max(t1.d) then count(distinct 19) else count(distinct e) end)+cast(avg((t1.e)) AS integer))+max(t1.c) from t1 union select count(*) from t1) and c*t1.a in (select e from t1 union select f from t1))}\n} {240000}\ndo_test randexpr-2.2392 {\n  db eval {SELECT t1.b-case when b not between 17 and t1.d*11*f*t1.a or t1.c+case when  -t1.e between t1.d and coalesce((select coalesce((select max((select ~count(*) from t1)) from t1 where  -17*13-19-((d))<>(c)), -a) from t1 where (e)<=t1.a),d) then d when e<t1.f then 19 else e end>=a then t1.f else f end FROM t1 WHERE f in (13*13-(abs(d)/abs(e)),19,case t1.b+coalesce((select max((abs((abs(17)/abs(a)))/abs(11+t1.c))) from t1 where  -t1.c>=t1.f and e in (select count(*) | min(t1.c) from t1 union select cast(avg(e) AS integer) from t1) or 11 not in (e,b,a) or t1.c< -a and t1.e not in (t1.e,b,t1.d)),t1.b) when f then 19 else b end-11) or d>t1.b}\n} {-400}\ndo_test randexpr-2.2393 {\n  db eval {SELECT t1.b-case when b not between 17 and t1.d*11*f*t1.a or t1.c+case when  -t1.e between t1.d and coalesce((select coalesce((select max((select ~count(*) from t1)) from t1 where  -17*13-19-((d))<>(c)), -a) from t1 where (e)<=t1.a),d) then d when e<t1.f then 19 else e end>=a then t1.f else f end FROM t1 WHERE NOT (f in (13*13-(abs(d)/abs(e)),19,case t1.b+coalesce((select max((abs((abs(17)/abs(a)))/abs(11+t1.c))) from t1 where  -t1.c>=t1.f and e in (select count(*) | min(t1.c) from t1 union select cast(avg(e) AS integer) from t1) or 11 not in (e,b,a) or t1.c< -a and t1.e not in (t1.e,b,t1.d)),t1.b) when f then 19 else b end-11) or d>t1.b)}\n} {}\ndo_test randexpr-2.2394 {\n  db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and  -t1.c | t1.a*(abs(b)/abs(c)) then  -d when a in (select +11 from t1 union select c from t1) then  -t1.c else 13 end | t1.c,t1.b)),d)-f)) | t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE 17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end}\n} {200}\ndo_test randexpr-2.2395 {\n  db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and  -t1.c | t1.a*(abs(b)/abs(c)) then  -d when a in (select +11 from t1 union select c from t1) then  -t1.c else 13 end | t1.c,t1.b)),d)-f)) | t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE NOT (17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end)}\n} {}\ndo_test randexpr-2.2396 {\n  db eval {SELECT case t1.d when (abs(17)/abs(coalesce((select max(e) from t1 where a not in (t1.e,case when 11+t1.d not between t1.e and  -t1.c & t1.a*(abs(b)/abs(c)) then  -d when a in (select +11 from t1 union select c from t1) then  -t1.c else 13 end & t1.c,t1.b)),d)-f)) & t1.c then case when 13<c then t1.b when d<>t1.d then 13 else f end else b end FROM t1 WHERE 17>d*~t1.e+case when not t1.f<>(select count(distinct 19)+min(e) from t1) then case when (13-a<= -t1.b) and t1.f<=t1.f then 19*d else f end-t1.f*d+t1.d when b not in (t1.b,19,19) or t1.d not between t1.b and a then t1.f else b end}\n} {200}\ndo_test randexpr-2.2397 {\n  db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d | e<e),t1.e) FROM t1 WHERE (t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c))}\n} {}\ndo_test randexpr-2.2398 {\n  db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d | e<e),t1.e) FROM t1 WHERE NOT ((t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c)))}\n} {500}\ndo_test randexpr-2.2399 {\n  db eval {SELECT coalesce((select max(d) from t1 where coalesce((select t1.c from t1 where 17>b),d*coalesce((select max(11*19) from t1 where coalesce((select c from t1 where 19<(abs((case a when b then ~case t1.a+(select min(t1.f)+min(b) from t1) when (d) then e else t1.b end else t1.c end+f+t1.f))/abs(t1.b))),c)<=19),13))*d & e<e),t1.e) FROM t1 WHERE NOT ((t1.d*t1.c not in (t1.b,t1.b*t1.f,t1.c)))}\n} {400}\ndo_test randexpr-2.2400 {\n  db eval {SELECT t1.b+ -t1.d*(select max(t1.a) | count(*) | abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not  -c>=b then t1.c when  -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c)}\n} {-558600}\ndo_test randexpr-2.2401 {\n  db eval {SELECT t1.b+ -t1.d*(select max(t1.a) | count(*) | abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE NOT (t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not  -c>=b then t1.c when  -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c))}\n} {}\ndo_test randexpr-2.2402 {\n  db eval {SELECT t1.b+ -t1.d*(select max(t1.a) & count(*) & abs(cast(avg(f+a-(select ~(min((abs(a)/abs(13+case when f=coalesce((select t1.b from t1 where d<>t1.e and 11 in (t1.e,t1.e,d)),f)+13 then t1.b else c end))- -f)) from t1)) AS integer))-count(distinct 11+11+13)+count(distinct t1.a) from t1) FROM t1 WHERE t1.d<c+t1.c | (select max((t1.e)) from t1)+case when t1.f-t1.d<a then t1.c-(abs(c)/abs(b*t1.c)) when case when not  -c>=b then t1.c when  -f*e<=t1.b then e else 17 end not between 17 and t1.f then t1.c else t1.b end-19+f+19*(t1.c)}\n} {200}\ndo_test randexpr-2.2403 {\n  db eval {SELECT case when case when t1.e<~17 or (case case case t1.d*17*13 when t1.a then e+c else c end when d*f+coalesce((select 17 from t1 where 13 not between 13 and  -13),(17)) then t1.b else b end when t1.a then a else t1.c end*d<>d) then ~t1.c else a end<>t1.f then  -t1.d else t1.a end+11-t1.c-e FROM t1 WHERE (case when (~f- -e in (17,case when d in (select t1.f from t1 union select a+(abs(coalesce((select (t1.c) from t1 where a in (select min(13) | (max(t1.e)) from t1 union select count(distinct t1.d) from t1)),b)+13)/abs(e))*19*f from t1) then b when not a between 13 and 13 then t1.f else 17 end,t1.c)) then (select max(t1.e)-count(*) | count(*) from t1) else c end)>(t1.e)}\n} {}\ndo_test randexpr-2.2404 {\n  db eval {SELECT case when case when t1.e<~17 or (case case case t1.d*17*13 when t1.a then e+c else c end when d*f+coalesce((select 17 from t1 where 13 not between 13 and  -13),(17)) then t1.b else b end when t1.a then a else t1.c end*d<>d) then ~t1.c else a end<>t1.f then  -t1.d else t1.a end+11-t1.c-e FROM t1 WHERE NOT ((case when (~f- -e in (17,case when d in (select t1.f from t1 union select a+(abs(coalesce((select (t1.c) from t1 where a in (select min(13) | (max(t1.e)) from t1 union select count(distinct t1.d) from t1)),b)+13)/abs(e))*19*f from t1) then b when not a between 13 and 13 then t1.f else 17 end,t1.c)) then (select max(t1.e)-count(*) | count(*) from t1) else c end)>(t1.e))}\n} {-1189}\ndo_test randexpr-2.2405 {\n  db eval {SELECT coalesce((select max(t1.a-(abs(e*coalesce((select max(d) from t1 where (case when case e when case when (t1.e)=d then t1.a+11 else 17 end then (c) else b end<=a then b when 19 in (t1.b,b,t1.e) then f else  -19 end+17 between 19 and c or b in (select t1.c from t1 union select t1.a from t1))),t1.a))/abs( -t1.d))) from t1 where 13=17),t1.b)+(t1.b) FROM t1 WHERE coalesce((select  -case when (d)>=(select ~case +(+~~cast(avg(a) AS integer)*abs(( -count(*))) | count(distinct 11)) when (count(*)) then count(distinct 19) else min(t1.a) end+min(t1.a) from t1)*13-t1.f then 13 else (e) | t1.c*(select (min(17)) from t1) end*case when (c) in (select 11 from t1 union select t1.f from t1) then 17 else 19 end from t1 where t1.c<t1.f),19)*19<>c}\n} {400}\ndo_test randexpr-2.2406 {\n  db eval {SELECT coalesce((select max(t1.a-(abs(e*coalesce((select max(d) from t1 where (case when case e when case when (t1.e)=d then t1.a+11 else 17 end then (c) else b end<=a then b when 19 in (t1.b,b,t1.e) then f else  -19 end+17 between 19 and c or b in (select t1.c from t1 union select t1.a from t1))),t1.a))/abs( -t1.d))) from t1 where 13=17),t1.b)+(t1.b) FROM t1 WHERE NOT (coalesce((select  -case when (d)>=(select ~case +(+~~cast(avg(a) AS integer)*abs(( -count(*))) | count(distinct 11)) when (count(*)) then count(distinct 19) else min(t1.a) end+min(t1.a) from t1)*13-t1.f then 13 else (e) | t1.c*(select (min(17)) from t1) end*case when (c) in (select 11 from t1 union select t1.f from t1) then 17 else 19 end from t1 where t1.c<t1.f),19)*19<>c)}\n} {}\ndo_test randexpr-2.2407 {\n  db eval {SELECT t1.b-t1.d-case when exists(select 1 from t1 where  -coalesce((select t1.a from t1 where a in (c,coalesce((select max((abs(t1.d)/abs(e))) from t1 where case t1.b when t1.e then t1.d else t1.d end-17 between b and t1.f),17)-t1.f-t1.e,t1.a) or t1.b in (t1.a,19,t1.f)),19)>=d) then 19-b when t1.c between (f) and t1.f then t1.d else t1.f end-11 FROM t1 WHERE coalesce((select 13 from t1 where ( -t1.a<d)),(abs(t1.d)/abs(case when ( -11)+f+d+ -17+f*e not between t1.b and  -11 and not t1.a<>13 or a in (select cast(avg(d) AS integer) | count(*)* -max(t1.f) from t1 union select count(*) from t1) then 17 when not exists(select 1 from t1 where b>=c) then e else 17 end |  -t1.a))*b)*t1.d>=b}\n} {-811}\ndo_test randexpr-2.2408 {\n  db eval {SELECT t1.b-t1.d-case when exists(select 1 from t1 where  -coalesce((select t1.a from t1 where a in (c,coalesce((select max((abs(t1.d)/abs(e))) from t1 where case t1.b when t1.e then t1.d else t1.d end-17 between b and t1.f),17)-t1.f-t1.e,t1.a) or t1.b in (t1.a,19,t1.f)),19)>=d) then 19-b when t1.c between (f) and t1.f then t1.d else t1.f end-11 FROM t1 WHERE NOT (coalesce((select 13 from t1 where ( -t1.a<d)),(abs(t1.d)/abs(case when ( -11)+f+d+ -17+f*e not between t1.b and  -11 and not t1.a<>13 or a in (select cast(avg(d) AS integer) | count(*)* -max(t1.f) from t1 union select count(*) from t1) then 17 when not exists(select 1 from t1 where b>=c) then e else 17 end |  -t1.a))*b)*t1.d>=b)}\n} {}\ndo_test randexpr-2.2409 {\n  db eval {SELECT 17 | t1.c*t1.a | case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE (17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e)}\n} {}\ndo_test randexpr-2.2410 {\n  db eval {SELECT 17 | t1.c*t1.a | case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE NOT ((17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e))}\n} {-715}\ndo_test randexpr-2.2411 {\n  db eval {SELECT 17 & t1.c*t1.a & case when ~ -~(abs(t1.b)/abs(coalesce((select max(coalesce((select max(+t1.d) from t1 where (t1.b not between 17 and t1.b) and d not between c and 19),d)*(t1.d)-d) from t1 where t1.a in (t1.c,(t1.c),t1.f)),19)))-b+19+ -17>=t1.a then 19 when 19 in (select t1.f from t1 union select t1.b from t1) then t1.c else f end-19*t1.c FROM t1 WHERE NOT ((17-t1.f in (d | b-17,t1.f,coalesce((select e+(abs(11)/abs(case t1.c when case (abs(a)/abs(11)) when e then t1.c else 17+c end then b else 11+t1.e end)) from t1 where (13 not between + -b and 13)),t1.c)) and 17 between t1.d | t1.f and t1.e))}\n} {16}\ndo_test randexpr-2.2412 {\n  db eval {SELECT coalesce((select t1.a*a+t1.f | t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) | t1.a) FROM t1 WHERE not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d)}\n} {10744}\ndo_test randexpr-2.2413 {\n  db eval {SELECT coalesce((select t1.a*a+t1.f | t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) | t1.a) FROM t1 WHERE NOT (not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d))}\n} {}\ndo_test randexpr-2.2414 {\n  db eval {SELECT coalesce((select t1.a*a+t1.f & t1.d from t1 where t1.d<+t1.c*d-c*19+t1.e-(abs( -t1.e)/abs(19))), -t1.c+coalesce((select t1.b from t1 where not not (select max(t1.c) from t1)-17+e in (e,t1.c,b) and not (d in (select ( -((max(b)))) from t1 union select min(d) from t1))),t1.b) & t1.a) FROM t1 WHERE not t1.f in (select ((select abs(count(*)) from t1)-11) from t1 union select t1.a-17 from t1) or not exists(select 1 from t1 where case (abs(e)/abs(+c)) when coalesce((select max((select +(count(distinct t1.a)) from t1)) from t1 where not (e<=c*t1.a)),~(case when t1.c<=17 then e when t1.c<=t1.c then e else 17 end)) then 13 else d end*b-a= -d)}\n} {256}\ndo_test randexpr-2.2415 {\n  db eval {SELECT case a+(abs(+13)/abs(a)) when ~(e)*(abs(b* -t1.d*19-t1.c+a-~t1.b*b-coalesce((select max(case when not exists(select 1 from t1 where d in (f,t1.c,f) or t1.c not in (13,f,t1.a)) then case when t1.a>= -t1.e then (( - -b)) else t1.b end else c end+e) from t1 where (a>11)),13)*17)/abs(e)) then 11 else c end FROM t1 WHERE 17 between a and t1.a}\n} {}\ndo_test randexpr-2.2416 {\n  db eval {SELECT case a+(abs(+13)/abs(a)) when ~(e)*(abs(b* -t1.d*19-t1.c+a-~t1.b*b-coalesce((select max(case when not exists(select 1 from t1 where d in (f,t1.c,f) or t1.c not in (13,f,t1.a)) then case when t1.a>= -t1.e then (( - -b)) else t1.b end else c end+e) from t1 where (a>11)),13)*17)/abs(e)) then 11 else c end FROM t1 WHERE NOT (17 between a and t1.a)}\n} {300}\ndo_test randexpr-2.2417 {\n  db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b | c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE t1.c not between (abs(+case when not  -19 in (case when t1.b+~d+11+f>e then (select  -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19}\n} {-4501}\ndo_test randexpr-2.2418 {\n  db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b | c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE NOT (t1.c not between (abs(+case when not  -19 in (case when t1.b+~d+11+f>e then (select  -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19)}\n} {}\ndo_test randexpr-2.2419 {\n  db eval {SELECT +~t1.f-c*case when t1.f between coalesce((select max(a) from t1 where (t1.c-17*t1.b & c=e)),t1.b) and (abs(coalesce((select max(19) from t1 where t1.b not between c+(select min(t1.d) from t1)-t1.d+d+t1.d+t1.c*t1.e and 11),t1.a))/abs(a))-c*b then 17 else 13 end FROM t1 WHERE t1.c not between (abs(+case when not  -19 in (case when t1.b+~d+11+f>e then (select  -cast(avg(coalesce((select 17 from t1 where (t1.b>=f)),19)) AS integer)*min(d)*(min(e))* -min(b) from t1) when 17+b not between 17 and t1.a then 11 else a end,19,(t1.e)) then f else 19 end*t1.a)/abs(b)) and 19}\n} {-4501}\ndo_test randexpr-2.2420 {\n  db eval {SELECT +(abs(case t1.a when coalesce((select max(13) from t1 where d<=case when t1.b=(select abs(count(distinct t1.e)) from t1) and (select  -count(distinct e) from t1) not in ( -11,e,13) then 13 else t1.e end and (not exists(select 1 from t1 where t1.d in (select count(*) from t1 union select max(f) from t1))) and 19<f and t1.f>=13 or  -e=17),coalesce((select (abs(17)/abs(b))-t1.b from t1 where (19)<=t1.f),t1.d))*t1.b then 17 else 13 end)/abs(19)) FROM t1 WHERE a in (select case max(13)-~cast(avg(case when t1.d>13 or exists(select 1 from t1 where not (( -c<=e)) and (b)*t1.a in (select count(*) from t1 union select cast(avg(t1.c) AS integer)+max(f) from t1)) then t1.a else t1.c end) AS integer) when abs(count(distinct t1.d)) then count(distinct (~t1.a)) else count(distinct c)-cast(avg(e) AS integer) end from t1 union select abs(count(distinct a)*max(t1.d)) from t1)}\n} {}\ndo_test randexpr-2.2421 {\n  db eval {SELECT +(abs(case t1.a when coalesce((select max(13) from t1 where d<=case when t1.b=(select abs(count(distinct t1.e)) from t1) and (select  -count(distinct e) from t1) not in ( -11,e,13) then 13 else t1.e end and (not exists(select 1 from t1 where t1.d in (select count(*) from t1 union select max(f) from t1))) and 19<f and t1.f>=13 or  -e=17),coalesce((select (abs(17)/abs(b))-t1.b from t1 where (19)<=t1.f),t1.d))*t1.b then 17 else 13 end)/abs(19)) FROM t1 WHERE NOT (a in (select case max(13)-~cast(avg(case when t1.d>13 or exists(select 1 from t1 where not (( -c<=e)) and (b)*t1.a in (select count(*) from t1 union select cast(avg(t1.c) AS integer)+max(f) from t1)) then t1.a else t1.c end) AS integer) when abs(count(distinct t1.d)) then count(distinct (~t1.a)) else count(distinct c)-cast(avg(e) AS integer) end from t1 union select abs(count(distinct a)*max(t1.d)) from t1))}\n} {0}\ndo_test randexpr-2.2422 {\n  db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b | f-11-t1.b | coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE (select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c)}\n} {200}\ndo_test randexpr-2.2423 {\n  db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b | f-11-t1.b | coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE NOT ((select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c))}\n} {}\ndo_test randexpr-2.2424 {\n  db eval {SELECT +coalesce((select max(f+c) from t1 where t1.b in (select +max(b+t1.b) from t1 union select cast(avg(d-b & f-11-t1.b & coalesce((select ~t1.a from t1 where (t1.a=case when not exists(select 1 from t1 where 13 not in (t1.b,t1.e,t1.f)) then (abs(t1.d)/abs(c)) when c<>17 then c else 19 end)),t1.c)) AS integer) from t1) and t1.e not in (b,d,(13))),t1.b) FROM t1 WHERE (select cast(avg(~t1.f) AS integer) from t1) not in ( -c,17,11*c)}\n} {200}\ndo_test randexpr-2.2425 {\n  db eval {SELECT t1.e*case when ((13)-13-13-t1.d+t1.c*b>11) then b when case when (t1.a*b not in (t1.a,t1.b,t1.f)) then 11+e else t1.f end<= -f or f in (t1.a,11,13) or exists(select 1 from t1 where not exists(select 1 from t1 where f in (f,d,t1.e))) then t1.d else b end FROM t1 WHERE coalesce((select 19 from t1 where 13-t1.b*c-t1.a+case when case when coalesce((select +t1.b from t1 where a<>b),13) in ((b),t1.f,b) and not t1.b in (select  -cast(avg(13) AS integer) from t1 union select cast(avg(11) AS integer) from t1) or a>=13 then (abs(t1.b+a)/abs(11)) else t1.e end-17+t1.d<>b then (19) else f end=e),13)>=t1.c}\n} {}\ndo_test randexpr-2.2426 {\n  db eval {SELECT t1.e*case when ((13)-13-13-t1.d+t1.c*b>11) then b when case when (t1.a*b not in (t1.a,t1.b,t1.f)) then 11+e else t1.f end<= -f or f in (t1.a,11,13) or exists(select 1 from t1 where not exists(select 1 from t1 where f in (f,d,t1.e))) then t1.d else b end FROM t1 WHERE NOT (coalesce((select 19 from t1 where 13-t1.b*c-t1.a+case when case when coalesce((select +t1.b from t1 where a<>b),13) in ((b),t1.f,b) and not t1.b in (select  -cast(avg(13) AS integer) from t1 union select cast(avg(11) AS integer) from t1) or a>=13 then (abs(t1.b+a)/abs(11)) else t1.e end-17+t1.d<>b then (19) else f end=e),13)>=t1.c)}\n} {100000}\ndo_test randexpr-2.2427 {\n  db eval {SELECT coalesce((select max(d) from t1 where 19+case t1.b when t1.a-a then (abs(case when (e>=case t1.a when coalesce((select max(t1.d) from t1 where (select case  -max(c)+cast(avg(t1.a) AS integer) when cast(avg(t1.a) AS integer) then cast(avg(19) AS integer) else cast(avg(t1.b) AS integer) end from t1)>t1.c),coalesce((select max(d) from t1 where 19<>17 and d<=b), -(t1.c)))+e then c else t1.d end+b) then b when 19 between c and 17 then 11 else e end)/abs( -t1.b)) else t1.a end+13>=d),d) FROM t1 WHERE a=case when t1.f in (select (max(f)-++(min(t1.a))-max(19)-count(*)) from t1 union select +max(t1.b) from t1) then t1.b*19*19 when t1.f>d then 17-d else t1.f end and exists(select 1 from t1 where not exists(select 1 from t1 where d in (select count(distinct 11)+max(a) from t1 union select cast(avg(13) AS integer) from t1) or 19 not in (t1.b,c,13)))}\n} {}\ndo_test randexpr-2.2428 {\n  db eval {SELECT coalesce((select max(d) from t1 where 19+case t1.b when t1.a-a then (abs(case when (e>=case t1.a when coalesce((select max(t1.d) from t1 where (select case  -max(c)+cast(avg(t1.a) AS integer) when cast(avg(t1.a) AS integer) then cast(avg(19) AS integer) else cast(avg(t1.b) AS integer) end from t1)>t1.c),coalesce((select max(d) from t1 where 19<>17 and d<=b), -(t1.c)))+e then c else t1.d end+b) then b when 19 between c and 17 then 11 else e end)/abs( -t1.b)) else t1.a end+13>=d),d) FROM t1 WHERE NOT (a=case when t1.f in (select (max(f)-++(min(t1.a))-max(19)-count(*)) from t1 union select +max(t1.b) from t1) then t1.b*19*19 when t1.f>d then 17-d else t1.f end and exists(select 1 from t1 where not exists(select 1 from t1 where d in (select count(distinct 11)+max(a) from t1 union select cast(avg(13) AS integer) from t1) or 19 not in (t1.b,c,13))))}\n} {400}\ndo_test randexpr-2.2429 {\n  db eval {SELECT coalesce((select max(case t1.c | b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case  -(count(distinct  -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and  -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select  -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1)}\n} {}\ndo_test randexpr-2.2430 {\n  db eval {SELECT coalesce((select max(case t1.c | b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case  -(count(distinct  -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE NOT (case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and  -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select  -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1))}\n} {40013}\ndo_test randexpr-2.2431 {\n  db eval {SELECT coalesce((select max(case t1.c & b-t1.d+13 when 17 then c else 13 end) from t1 where case when exists(select 1 from t1 where b<>t1.c) then t1.d when a not between (abs(t1.d)/abs((t1.b))) and (t1.c) or (a in (select ~max(((17))) from t1 union select case  -(count(distinct  -t1.c)) when count(distinct t1.c) then (count(*)) else max(f) end from t1)) and t1.f>19 or a<>11 then t1.b else t1.b end>(11)),13)+b*(b) FROM t1 WHERE NOT (case when not exists(select 1 from t1 where (19<>11+t1.b*c+d)) and 13<>b or t1.d between t1.c and b and f between t1.b and  -a or 19 between 19 and 17 or t1.e not between e and t1.d then ~13 else coalesce((select max(t1.b) from t1 where f=a),(a)) end in (select  -( -+count(distinct 11)-count(*))*count(distinct ( -t1.c))+(count(distinct t1.c))+max(17)-count(*) from t1 union select count(*) from t1))}\n} {40013}\ndo_test randexpr-2.2432 {\n  db eval {SELECT coalesce((select max(coalesce((select max(11) from t1 where t1.b< -t1.b),e)+coalesce((select t1.b from t1 where not case when ~case when  -17+t1.d> - -t1.d then t1.b when t1.b between 13 and c or t1.a>= -f then t1.b else t1.e end+t1.c<= -c then 19 else t1.f end not in (c,d,e) or t1.f not between t1.b and 19 and 13>= -t1.f or 13 in (e,(t1.b),11)),t1.b)) from t1 where  -(f) not in (f,(t1.e),b)),t1.f) FROM t1 WHERE f in (select f from t1 union select t1.f*t1.b from t1)}\n} {700}\ndo_test randexpr-2.2433 {\n  db eval {SELECT coalesce((select max(coalesce((select max(11) from t1 where t1.b< -t1.b),e)+coalesce((select t1.b from t1 where not case when ~case when  -17+t1.d> - -t1.d then t1.b when t1.b between 13 and c or t1.a>= -f then t1.b else t1.e end+t1.c<= -c then 19 else t1.f end not in (c,d,e) or t1.f not between t1.b and 19 and 13>= -t1.f or 13 in (e,(t1.b),11)),t1.b)) from t1 where  -(f) not in (f,(t1.e),b)),t1.f) FROM t1 WHERE NOT (f in (select f from t1 union select t1.f*t1.b from t1))}\n} {}\ndo_test randexpr-2.2434 {\n  db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) | t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) |  -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d}\n} {}\ndo_test randexpr-2.2435 {\n  db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) | t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE NOT (f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) |  -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d)}\n} {-7800}\ndo_test randexpr-2.2436 {\n  db eval {SELECT ( -+(a)*(abs(case coalesce((select max(d) from t1 where t1.d<>c*(select count(distinct e*coalesce((select 13-17 from t1 where not exists(select 1 from t1 where t1.a in (select f from t1 union select (a) from t1))),t1.f)+(t1.c)) from t1) & t1.e*19 and not t1.a<13),t1.b)+t1.b when t1.d then (t1.f) else t1.c end)/abs(t1.f))-13*t1.f) FROM t1 WHERE NOT (f>=t1.a+ -(select (count(*))-(~case cast(avg(t1.b-13-e) AS integer) when count(*) then (max(t1.f*case 13 when 11 then 13 else c end))- -cast(avg(t1.f) AS integer)*count(*)-min(19) else count(distinct d) end)+min(t1.d) |  -max(t1.b) from t1) | t1.b*17+t1.d+t1.b-d)}\n} {-7800}\ndo_test randexpr-2.2437 {\n  db eval {SELECT coalesce((select t1.a from t1 where c in (select a from t1 union select t1.a*f from t1) and t1.b in (select (select count(*) from t1)*11 from t1 union select  -13 from t1)),13) FROM t1 WHERE (d<t1.b)}\n} {}\ndo_test randexpr-2.2438 {\n  db eval {SELECT coalesce((select t1.a from t1 where c in (select a from t1 union select t1.a*f from t1) and t1.b in (select (select count(*) from t1)*11 from t1 union select  -13 from t1)),13) FROM t1 WHERE NOT ((d<t1.b))}\n} {13}\ndo_test randexpr-2.2439 {\n  db eval {SELECT case when (not exists(select 1 from t1 where a<=case a | e-case t1.f when c then e else 19 end | t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e | t1.c when 19 then 13 else  -(19) end | 11 else a end-t1.f-f*t1.c FROM t1 WHERE case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c}\n} {-180500}\ndo_test randexpr-2.2440 {\n  db eval {SELECT case when (not exists(select 1 from t1 where a<=case a | e-case t1.f when c then e else 19 end | t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e | t1.c when 19 then 13 else  -(19) end | 11 else a end-t1.f-f*t1.c FROM t1 WHERE NOT (case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c)}\n} {}\ndo_test randexpr-2.2441 {\n  db eval {SELECT case when (not exists(select 1 from t1 where a<=case a & e-case t1.f when c then e else 19 end & t1.b when t1.c then t1.e else 19 end+d)) or f between a and b and (t1.f) not in (d,t1.e,11) then case 17+e & t1.c when 19 then 13 else  -(19) end & 11 else a end-t1.f-f*t1.c FROM t1 WHERE case when t1.b in ( - -case when case when t1.f-case when 19<=c then a else 19 end between 13 and t1.d and not a not in ((f),d,f) then t1.c-a when t1.d not in ( -b,c,11) then 13 else f end>=17 then d when f<=t1.c then t1.a else d end,t1.e,e) or not 19>c then t1.c-19 else 13 end<>t1.c}\n} {-180500}\ndo_test randexpr-2.2442 {\n  db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d | f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) | t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select  -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end |  -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1))}\n} {600}\ndo_test randexpr-2.2443 {\n  db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d | f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) | t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE NOT (not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select  -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end |  -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1)))}\n} {}\ndo_test randexpr-2.2444 {\n  db eval {SELECT coalesce((select d-(abs(case when +coalesce((select 19 from t1 where not exists(select 1 from t1 where d & f in (select ~case count(distinct f) when ( -(cast(avg((( -19))) AS integer))) then (count(*)) else count(distinct 17) end*(max(t1.d)) from t1 union select min(b) from t1))),13) & t1.b+t1.e in (13,(t1.b),t1.a) then t1.a when a in (select t1.f from t1 union select t1.b from t1) then t1.e else a end)/abs(f))-t1.e from t1 where not exists(select 1 from t1 where not 19 in (select t1.b from t1 union select t1.f from t1) or 13 in (select e from t1 union select e from t1))),f) FROM t1 WHERE not exists(select 1 from t1 where case when not exists(select 1 from t1 where a<+case c when (abs(t1.b)/abs(e))+t1.b-b-t1.b then (t1.d)*t1.c else t1.d end) then b else 19 end in (select  -count(distinct c)*(max(f)) | ~+case min(t1.a) when cast(avg(c) AS integer) then cast(avg(t1.a) AS integer) | count(distinct t1.d)* -count(distinct t1.e) else ( -count(*)) end |  -cast(avg(t1.d) AS integer)+min(a)*count(distinct b) from t1 union select max(13) from t1))}\n} {600}\ndo_test randexpr-2.2445 {\n  db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) | t1.d FROM t1 WHERE ~a<>a or d<>t1.e}\n} {927}\ndo_test randexpr-2.2446 {\n  db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) | t1.d FROM t1 WHERE NOT (~a<>a or d<>t1.e)}\n} {}\ndo_test randexpr-2.2447 {\n  db eval {SELECT (t1.e)+t1.c-coalesce((select max((abs(coalesce((select case when f>=(abs(coalesce((select max(a) from t1 where 11*(t1.f)*a*t1.d=11),t1.b))/abs(t1.d))+t1.b then c when not exists(select 1 from t1 where t1.c<>b) then 13 else 11 end from t1 where (13 not in (f,t1.c,13))),b)+t1.d)/abs(t1.f))) from t1 where b<>t1.a),t1.a) & t1.d FROM t1 WHERE ~a<>a or d<>t1.e}\n} {272}\ndo_test randexpr-2.2448 {\n  db eval {SELECT case when coalesce((select 11 from t1 where exists(select 1 from t1 where t1.a<= -19)),t1.c-t1.e*e-19-t1.d-t1.e-~a*coalesce((select max(b) from t1 where b>(abs(+c+case c when 11 then t1.f else 11 end)/abs(b))),t1.e)-f+t1.c+19+e-t1.e)<=t1.f then e else c end FROM t1 WHERE (abs(t1.d)/abs(~b)) in (select count(distinct case when t1.c+t1.f<coalesce((select b from t1 where ((select case min( -d+d+f+d) when ~max(t1.c) then case max(d) when  -( - -min(d)) then cast(avg(t1.d) AS integer) else (max( -c)) end else cast(avg(t1.e) AS integer) end from t1)<t1.b)),17) or t1.b=f then case when t1.f<>e and ((d) between t1.a and d) then t1.b else 13 end else 11 end) from t1 union select count(*) from t1)}\n} {500}\ndo_test randexpr-2.2449 {\n  db eval {SELECT case when coalesce((select 11 from t1 where exists(select 1 from t1 where t1.a<= -19)),t1.c-t1.e*e-19-t1.d-t1.e-~a*coalesce((select max(b) from t1 where b>(abs(+c+case c when 11 then t1.f else 11 end)/abs(b))),t1.e)-f+t1.c+19+e-t1.e)<=t1.f then e else c end FROM t1 WHERE NOT ((abs(t1.d)/abs(~b)) in (select count(distinct case when t1.c+t1.f<coalesce((select b from t1 where ((select case min( -d+d+f+d) when ~max(t1.c) then case max(d) when  -( - -min(d)) then cast(avg(t1.d) AS integer) else (max( -c)) end else cast(avg(t1.e) AS integer) end from t1)<t1.b)),17) or t1.b=f then case when t1.f<>e and ((d) between t1.a and d) then t1.b else 13 end else 11 end) from t1 union select count(*) from t1))}\n} {}\ndo_test randexpr-2.2450 {\n  db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then  -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end | t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct  -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then  -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE ~+e+11>b}\n} {}\ndo_test randexpr-2.2451 {\n  db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then  -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end | t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct  -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then  -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE NOT (~+e+11>b)}\n} {240311}\ndo_test randexpr-2.2452 {\n  db eval {SELECT case when 19*case when case when t1.e>((t1.d)) and 11>t1.d then  -17 else e end in (select count(distinct a) from t1 union select min(d) from t1) then (d) else e end & t1.c+a in (select count(*) from t1 union select case +(max(19))+count(distinct  -t1.d) when min(19) then cast(avg(e) AS integer) else cast(avg(t1.a) AS integer) end from t1) and 17 between 17 and t1.b then  -(t1.e) when b between t1.c and 13 then b else 11 end+t1.f*(t1.d)+t1.c FROM t1 WHERE NOT (~+e+11>b)}\n} {240311}\ndo_test randexpr-2.2453 {\n  db eval {SELECT coalesce((select max((e)) from t1 where not (((abs(c)/abs((abs(t1.e)/abs(t1.d)))) between d and a+t1.f+19-a or (not exists(select 1 from t1 where f*11 in (19,t1.d,case when (11 in (19,17,19) and t1.a>t1.d) then t1.e-19 else t1.e end+f))) and a<11) and 19<>a)),c+d) FROM t1 WHERE 17+case b*f when b then a+e else d end*t1.b<=case when not f=11 then c when t1.e<f-coalesce((select max(d) from t1 where e in (select (select count(*) from t1) | coalesce((select e from t1 where t1.d>d and exists(select 1 from t1 where 19 in (t1.e,t1.a,(e)))),a)*c from t1 union select f from t1)),t1.a)+f+17 then t1.c else b end}\n} {}\ndo_test randexpr-2.2454 {\n  db eval {SELECT coalesce((select max((e)) from t1 where not (((abs(c)/abs((abs(t1.e)/abs(t1.d)))) between d and a+t1.f+19-a or (not exists(select 1 from t1 where f*11 in (19,t1.d,case when (11 in (19,17,19) and t1.a>t1.d) then t1.e-19 else t1.e end+f))) and a<11) and 19<>a)),c+d) FROM t1 WHERE NOT (17+case b*f when b then a+e else d end*t1.b<=case when not f=11 then c when t1.e<f-coalesce((select max(d) from t1 where e in (select (select count(*) from t1) | coalesce((select e from t1 where t1.d>d and exists(select 1 from t1 where 19 in (t1.e,t1.a,(e)))),a)*c from t1 union select f from t1)),t1.a)+f+17 then t1.c else b end)}\n} {500}\ndo_test randexpr-2.2455 {\n  db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) |  -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE d= -19}\n} {}\ndo_test randexpr-2.2456 {\n  db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) |  -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE NOT (d= -19)}\n} {-5483}\ndo_test randexpr-2.2457 {\n  db eval {SELECT ((select cast(avg(case a when t1.d then (abs(coalesce((select coalesce((select coalesce((select e-a from t1 where not exists(select 1 from t1 where t1.f>11 or t1.a= -f)), -t1.a) from t1 where 11<= -t1.f),t1.f)-13 from t1 where not exists(select 1 from t1 where t1.e in (f,t1.b,d))),t1.d))/abs(11)) else (17) end) AS integer)+abs( -count(distinct e)+count(*)) &  -count(*)*+min(e)*count(distinct b)*cast(avg(11) AS integer) from t1)) FROM t1 WHERE NOT (d= -19)}\n} {0}\ndo_test randexpr-2.2458 {\n  db eval {SELECT 11+t1.e*c | t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE ((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b)))))}\n} {}\ndo_test randexpr-2.2459 {\n  db eval {SELECT 11+t1.e*c | t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE NOT (((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b))))))}\n} {191487}\ndo_test randexpr-2.2460 {\n  db eval {SELECT 11+t1.e*c & t1.a+t1.a*coalesce((select max(b*t1.d*case when c in (select t1.b from t1 union select case when (t1.b>=d) then 19 else case when ((((t1.a<>t1.b)))) then b when f<=11 then case when e not in (19,t1.d,a) then coalesce((select 11 from t1 where e between a and e),e) when 11<=e then t1.a else 13 end else t1.c end end from t1) then 19 else (t1.d) end-a) from t1 where (t1.d)<= -e),t1.f) FROM t1 WHERE NOT (((f not between t1.a and (abs(19)/abs(17 | (a))) and ((exists(select 1 from t1 where coalesce((select case e*(17) when b-(abs((abs(11)/abs(t1.c+e+t1.c)))/abs(17-((t1.f-t1.e | 11)))) then e else a end from t1 where t1.c not in (19,t1.b,t1.d)),c)=b))))))}\n} {18624}\ndo_test randexpr-2.2461 {\n  db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) | max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE 13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select  -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b)}\n} {}\ndo_test randexpr-2.2462 {\n  db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) | max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE NOT (13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select  -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b))}\n} {300}\ndo_test randexpr-2.2463 {\n  db eval {SELECT (select (case +~ -abs(count(distinct + -(select (case ~((min(t1.b)+max(a))+count(*))*cast(avg(e) AS integer) when count(distinct (17)) then count(distinct t1.d) else max(a) end) from t1)*(17)-t1.f+case (abs( -t1.e)/abs(17)) when t1.f then b else 11 end)) & max(c)-case max(f) when (max(t1.f)) then min(c) else cast(avg((t1.d)) AS integer) end when count(*) then min(t1.a) else cast(avg(t1.c) AS integer) end) from t1) FROM t1 WHERE NOT (13 in ((select ~ -abs((abs( -max(c)+count(distinct c)-~case +max(f) when min(13) then count(distinct t1.e) else count(*) end-((cast(avg(t1.c) AS integer)))))) from t1),~t1.c-t1.e,case when exists(select 1 from t1 where not exists(select 1 from t1 where t1.a in (select case when t1.c<d or e>a then b else (c) end+t1.d from t1 union select  -t1.e from t1)) or 11 not between b and d or e>e) then t1.f else t1.f end*t1.b- -t1.b))}\n} {300}\ndo_test randexpr-2.2464 {\n  db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b |  -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when  -max(13) then max(t1.c) else  -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE  -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then  -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1)}\n} {}\ndo_test randexpr-2.2465 {\n  db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b |  -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when  -max(13) then max(t1.c) else  -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE NOT ( -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then  -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1))}\n} {0}\ndo_test randexpr-2.2466 {\n  db eval {SELECT case when (abs(~(t1.e))/abs(case when (( -13<d or b not in (t1.d,a,19)) and t1.b<d) or a<13 then +~c else 17 end)) in (select cast(avg(t1.b &  -t1.f) AS integer)- - -case (~min(t1.e)+count(*)) when  -max(13) then max(t1.c) else  -cast(avg(11) AS integer) end from t1 union select cast(avg(11) AS integer) from t1) then t1.e when not exists(select 1 from t1 where (19 not between d and 13)) then 19 else c end-t1.c FROM t1 WHERE NOT ( -t1.a-+case when c between b and t1.a then 19 else t1.b end | (coalesce((select t1.f from t1 where case ~((abs(case case t1.e when t1.b then  -13 else f end when t1.a then t1.f else t1.b end+(e)-t1.b)/abs(c))+t1.d) when 19 then 11 else a end not in ( - -13,a,11)),b))+t1.b+e in (select t1.d from t1 union select d from t1))}\n} {0}\ndo_test randexpr-2.2467 {\n  db eval {SELECT case when (select  -case abs(min(c)) when count(distinct a)-min(t1.c) then  -~abs(max(c)) | min( -13) |  -count(*)+min(d)*count(*) else  -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then  -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1)}\n} {}\ndo_test randexpr-2.2468 {\n  db eval {SELECT case when (select  -case abs(min(c)) when count(distinct a)-min(t1.c) then  -~abs(max(c)) | min( -13) |  -count(*)+min(d)*count(*) else  -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE NOT (t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then  -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1))}\n} {17}\ndo_test randexpr-2.2469 {\n  db eval {SELECT case when (select  -case abs(min(c)) when count(distinct a)-min(t1.c) then  -~abs(max(c)) & min( -13) &  -count(*)+min(d)*count(*) else  -(count(distinct t1.f)) end from t1) in (select count(distinct b)+max(f) from t1 union select cast(avg(19) AS integer) from t1) then (t1.d) when b<=case d when t1.d then t1.a else t1.d end then coalesce((select t1.d from t1 where not exists(select 1 from t1 where t1.a not in (11,e,13))),13) else 17 end FROM t1 WHERE NOT (t1.f in (select count(*)-max(case f+(abs(e-17*(abs(11+17+e)/abs(f)) | t1.e*b+t1.d)/abs(e))+t1.a when t1.a then  -t1.d else 13 end) | abs( -cast(avg(b) AS integer)-count(distinct 13) | (count(*))+count(*))-cast(avg(((a))) AS integer) from t1 union select count(distinct 11) from t1))}\n} {17}\ndo_test randexpr-2.2470 {\n  db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e | (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where  -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE 19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b}\n} {}\ndo_test randexpr-2.2471 {\n  db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e | (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where  -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE NOT (19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b)}\n} {19}\ndo_test randexpr-2.2472 {\n  db eval {SELECT (select min(coalesce((select max(t1.c-case t1.e & (abs(coalesce((select max(t1.b) from t1 where 19<f-13 or exists(select 1 from t1 where  -case coalesce((select max( -17-19) from t1 where (e>c)),f)+t1.b when 13 then t1.c else t1.b end<>a) or t1.a=a),e+t1.e))/abs((f))) when a then e else f end) from t1 where t1.a>t1.d),19)) from t1) FROM t1 WHERE NOT (19*~case when (case when t1.f<>t1.a*17*(abs(t1.e)/abs(a))*a*(select case +min(11)*cast(avg(b) AS integer)*cast(avg(19) AS integer) when count(distinct t1.f) then max( -t1.e) else cast(avg( -f) AS integer) end from t1)*(select min(t1.b) from t1)*t1.d then coalesce((select max(11) from t1 where t1.a between t1.d and 17 and 19 not between 17 and a),17) else 17 end in (select t1.f from t1 union select 17 from t1)) then ~t1.b else t1.d end<=b)}\n} {19}\ndo_test randexpr-2.2473 {\n  db eval {SELECT  -case (select ~count(*)-~abs(~ -(count(*)+count(*)))*count(*) from t1)*13++coalesce((select max( -+17+case when f not between e and t1.c and t1.f between t1.e and t1.a then e when (b)>19 then f else t1.b end) from t1 where 17 not in (a,t1.f,17) or (d>=t1.e) or a<=17),d) when t1.c then 19 else t1.f end FROM t1 WHERE (19<+case when not 17>e then +t1.f when e | 13 in (select ~(abs(a)/abs(t1.b)) from t1 union select t1.f from t1) then case when f between case case b*f+19-case t1.c when f then 13 else c end when t1.d then b else b end*11 when 19 then 13 else t1.c end and t1.f then c when t1.b<=c then t1.d else 13 end else t1.d end)}\n} {-600}\ndo_test randexpr-2.2474 {\n  db eval {SELECT  -case (select ~count(*)-~abs(~ -(count(*)+count(*)))*count(*) from t1)*13++coalesce((select max( -+17+case when f not between e and t1.c and t1.f between t1.e and t1.a then e when (b)>19 then f else t1.b end) from t1 where 17 not in (a,t1.f,17) or (d>=t1.e) or a<=17),d) when t1.c then 19 else t1.f end FROM t1 WHERE NOT ((19<+case when not 17>e then +t1.f when e | 13 in (select ~(abs(a)/abs(t1.b)) from t1 union select t1.f from t1) then case when f between case case b*f+19-case t1.c when f then 13 else c end when t1.d then b else b end*11 when 19 then 13 else t1.c end and t1.f then c when t1.b<=c then t1.d else 13 end else t1.d end))}\n} {}\ndo_test randexpr-2.2475 {\n  db eval {SELECT case when e not in (t1.a,t1.b,t1.e-t1.a) then f-coalesce((select max(~19-t1.b-f) from t1 where case when (select count(*)*count(*) from t1)-coalesce((select max(13) from t1 where (abs(13)/abs(19-f)) in (select count(distinct f) from t1 union select ~ - -count(distinct  -f) from t1)),t1.b) between t1.f and t1.d then d else f end between t1.f and a),t1.f)+ -t1.f else t1.e end FROM t1 WHERE d not in (c,t1.d, -coalesce((select max( -coalesce((select f from t1 where t1.b>t1.c* - -t1.f),case when (t1.e-t1.e | 19*t1.c+e<19 and 19<=e or not exists(select 1 from t1 where t1.a<=t1.d or e in (a,t1.e,b))) then  -e when f in ((t1.a),d,11) then 13 else d end)) from t1 where c between 19 and f),b))}\n} {}\ndo_test randexpr-2.2476 {\n  db eval {SELECT case when e not in (t1.a,t1.b,t1.e-t1.a) then f-coalesce((select max(~19-t1.b-f) from t1 where case when (select count(*)*count(*) from t1)-coalesce((select max(13) from t1 where (abs(13)/abs(19-f)) in (select count(distinct f) from t1 union select ~ - -count(distinct  -f) from t1)),t1.b) between t1.f and t1.d then d else f end between t1.f and a),t1.f)+ -t1.f else t1.e end FROM t1 WHERE NOT (d not in (c,t1.d, -coalesce((select max( -coalesce((select f from t1 where t1.b>t1.c* - -t1.f),case when (t1.e-t1.e | 19*t1.c+e<19 and 19<=e or not exists(select 1 from t1 where t1.a<=t1.d or e in (a,t1.e,b))) then  -e when f in ((t1.a),d,11) then 13 else d end)) from t1 where c between 19 and f),b)))}\n} {-600}\ndo_test randexpr-2.2477 {\n  db eval {SELECT  -case when (17<>t1.b-d+t1.a | t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) | cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then  -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where  -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f)}\n} {}\ndo_test randexpr-2.2478 {\n  db eval {SELECT  -case when (17<>t1.b-d+t1.a | t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) | cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then  -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE NOT (a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where  -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f))}\n} {301}\ndo_test randexpr-2.2479 {\n  db eval {SELECT  -case when (17<>t1.b-d+t1.a & t1.f) then ~c when ((19)-coalesce((select case t1.d-t1.f when (abs(((select abs(cast(avg(13) AS integer) & cast(avg( -(t1.b)) AS integer)) from t1)))/abs(case d when t1.b then  -11 else 19 end))*17 then t1.e else t1.a end from t1 where (19 not in (f,t1.d,t1.e))),t1.d)<>a) then t1.d else t1.c end FROM t1 WHERE NOT (a in (~b-t1.f*c,13 | coalesce((select max(t1.a) from t1 where  -t1.a-~case when b in (case when t1.e in (select 11 from t1 union select d from t1) and 13>19 then 13*c when f not in (t1.d,c,13) then t1.a else a end,t1.f,d) then a else 11 end+b in (select +(min(11)) from t1 union select max(11)+cast(avg(19) AS integer) from t1)),13),t1.f))}\n} {301}\ndo_test randexpr-2.2480 {\n  db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) | cast(avg(t1.e) AS integer)+count(distinct e) |  -count(*) from t1)) end-t1.b*f and t1.b | t1.b-b<=c then  -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f)}\n} {300}\ndo_test randexpr-2.2481 {\n  db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) | cast(avg(t1.e) AS integer)+count(distinct e) |  -count(*) from t1)) end-t1.b*f and t1.b | t1.b-b<=c then  -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE NOT (case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f))}\n} {}\ndo_test randexpr-2.2482 {\n  db eval {SELECT case f when case when +t1.a between a and case e when 17 then t1.e else f-t1.e+a-((select ++count(distinct d) & cast(avg(t1.e) AS integer)+count(distinct e) &  -count(*) from t1)) end-t1.b*f and t1.b & t1.b-b<=c then  -t1.b+d when 11 in (select t1.e from t1 union select 11 from t1) then 13 else a end then b else c end FROM t1 WHERE case when ++c-13*d>t1.a and f=t1.d-t1.b then (select count(distinct 11)*(+cast(avg(t1.b) AS integer)+case cast(avg(e) AS integer) when max(d) | min(11) then min(f) else ( -min(t1.b)) end*(count(*)))* -min(19) from t1) else t1.e end*11 in (select a from t1 union select t1.e from t1) and e=17 or 11 not in ( -t1.d,f,t1.f)}\n} {300}\ndo_test randexpr-2.2483 {\n  db eval {SELECT  -(19)-coalesce((select max(t1.e) from t1 where c not in (t1.b,17,t1.c)),case coalesce((select b+f+coalesce((select t1.a from t1 where t1.e>=t1.e+t1.a+t1.c or t1.f between c and t1.f),t1.e) from t1 where 11<>13 or t1.a=b),t1.c)*f+a when a then 17 else 17 end+t1.e)+a FROM t1 WHERE e | a not between  -case when not c between case when exists(select 1 from t1 where (f not in (coalesce((select max(t1.d) from t1 where t1.e=t1.d),t1.e)+a,19,t1.c)) or not exists(select 1 from t1 where a in (19,a,e) and 11>=t1.f)) or 11<17 then t1.e+19*t1.f-b when t1.c in (e,t1.b,e) then f else t1.f end and t1.b or (11>=(t1.a)) then e when t1.a=t1.a then (select count(*) from t1) else e end and t1.b}\n} {-436}\ndo_test randexpr-2.2484 {\n  db eval {SELECT  -(19)-coalesce((select max(t1.e) from t1 where c not in (t1.b,17,t1.c)),case coalesce((select b+f+coalesce((select t1.a from t1 where t1.e>=t1.e+t1.a+t1.c or t1.f between c and t1.f),t1.e) from t1 where 11<>13 or t1.a=b),t1.c)*f+a when a then 17 else 17 end+t1.e)+a FROM t1 WHERE NOT (e | a not between  -case when not c between case when exists(select 1 from t1 where (f not in (coalesce((select max(t1.d) from t1 where t1.e=t1.d),t1.e)+a,19,t1.c)) or not exists(select 1 from t1 where a in (19,a,e) and 11>=t1.f)) or 11<17 then t1.e+19*t1.f-b when t1.c in (e,t1.b,e) then f else t1.f end and t1.b or (11>=(t1.a)) then e when t1.a=t1.a then (select count(*) from t1) else e end and t1.b)}\n} {}\ndo_test randexpr-2.2485 {\n  db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) | b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE d>=e}\n} {}\ndo_test randexpr-2.2486 {\n  db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) | b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE NOT (d>=e)}\n} {400}\ndo_test randexpr-2.2487 {\n  db eval {SELECT case (abs(case when 13 not in (t1.f,a,t1.b) then d*(abs((coalesce((select coalesce((select coalesce((select max(t1.d-t1.a) from t1 where (t1.c between 19 and (c) and c<t1.c)),17) from t1 where (11>=17)),t1.f) from t1 where t1.e between e and 17),17))-b)/abs(d)) & b+t1.b when e between t1.f and d then 19 else 17 end*f)/abs(a)) when t1.c then 11 else t1.d end FROM t1 WHERE NOT (d>=e)}\n} {400}\ndo_test randexpr-2.2488 {\n  db eval {SELECT case ((abs(case when case  -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) | cast(avg(d) AS integer) | min(b) from t1) | +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then  -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f)}\n} {600}\ndo_test randexpr-2.2489 {\n  db eval {SELECT case ((abs(case when case  -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) | cast(avg(d) AS integer) | min(b) from t1) | +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then  -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE NOT (t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f))}\n} {}\ndo_test randexpr-2.2490 {\n  db eval {SELECT case ((abs(case when case  -(select count(distinct case when t1.d in (select t1.b from t1 union select t1.b from t1) then b when f not in (t1.a,b,a) then c else 17 end) & cast(avg(d) AS integer) & min(b) from t1) & +b-e when t1.e then f else a end not between 11 and 13 then f when 17>e and 17<c or exists(select 1 from t1 where b>=t1.f) or d in ( -t1.c,f,t1.a) then  -a else t1.f end)/abs(t1.b))) when 17 then t1.f else t1.f end FROM t1 WHERE t1.d=t1.b+case c-11+coalesce((select case when +(select +(case max(t1.e) when count(*) then (count(*)) else cast(avg(d) AS integer) end) from t1)-d between b and t1.d then 11 else f end from t1 where t1.f<=t1.c and exists(select 1 from t1 where exists(select 1 from t1 where e between t1.e and t1.e))),t1.b)-19 when t1.d then t1.f else (t1.f) end | e-c or t1.f not in (b, -f, -f)}\n} {600}\ndo_test randexpr-2.2491 {\n  db eval {SELECT coalesce((select max(11) from t1 where 17 not in (11,case when (case when t1.f>b then t1.d*t1.d else (abs((abs(19)/abs(coalesce((select 17*t1.e-t1.c from t1 where 17<13 and (t1.a in (select (min(17)) from t1 union select max(c) from t1) and  -t1.d not in ((t1.b),d,a))), -17))))/abs(c))*13 end)<>(t1.f) then a when a=t1.a then 17 else  -19 end-d,a)),e) FROM t1 WHERE 19<=case when not exists(select 1 from t1 where case when case when case when ((t1.a in (select +min(t1.c) from t1 union select max(t1.a) from t1))) or 19 between t1.d and b then +c | 11*f else d end<b and 17 not in (t1.b,t1.e,t1.c) then case when f=t1.b then t1.c when d between t1.c and t1.c then 17 else 19 end else t1.d end<>b then c else t1.d end in (17,( -b),t1.c)) then t1.e when t1.f in (t1.a,13,d) then 17 else t1.f end*11*t1.d and a<=t1.d}\n} {11}\ndo_test randexpr-2.2492 {\n  db eval {SELECT coalesce((select max(11) from t1 where 17 not in (11,case when (case when t1.f>b then t1.d*t1.d else (abs((abs(19)/abs(coalesce((select 17*t1.e-t1.c from t1 where 17<13 and (t1.a in (select (min(17)) from t1 union select max(c) from t1) and  -t1.d not in ((t1.b),d,a))), -17))))/abs(c))*13 end)<>(t1.f) then a when a=t1.a then 17 else  -19 end-d,a)),e) FROM t1 WHERE NOT (19<=case when not exists(select 1 from t1 where case when case when case when ((t1.a in (select +min(t1.c) from t1 union select max(t1.a) from t1))) or 19 between t1.d and b then +c | 11*f else d end<b and 17 not in (t1.b,t1.e,t1.c) then case when f=t1.b then t1.c when d between t1.c and t1.c then 17 else 19 end else t1.d end<>b then c else t1.d end in (17,( -b),t1.c)) then t1.e when t1.f in (t1.a,13,d) then 17 else t1.f end*11*t1.d and a<=t1.d)}\n} {}\ndo_test randexpr-2.2493 {\n  db eval {SELECT b*case when t1.f not in (a,f,t1.e-e) and t1.b in (select coalesce((select max(t1.e) from t1 where coalesce((select max(~d) from t1 where case when t1.b not in (t1.c,17, -c) then t1.f when t1.c>17 then 17 else e end>t1.f and t1.f not in (b,f,d)),17)>=t1.c or 19<=t1.e),t1.a) from t1 union select (e) from t1) then d when t1.c<e then  -t1.b else b end*c FROM t1 WHERE b not between 13 and d}\n} {}\ndo_test randexpr-2.2494 {\n  db eval {SELECT b*case when t1.f not in (a,f,t1.e-e) and t1.b in (select coalesce((select max(t1.e) from t1 where coalesce((select max(~d) from t1 where case when t1.b not in (t1.c,17, -c) then t1.f when t1.c>17 then 17 else e end>t1.f and t1.f not in (b,f,d)),17)>=t1.c or 19<=t1.e),t1.a) from t1 union select (e) from t1) then d when t1.c<e then  -t1.b else b end*c FROM t1 WHERE NOT (b not between 13 and d)}\n} {-12000000}\ndo_test randexpr-2.2495 {\n  db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) | cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) | (max(t1.e))) | min(f) when  -max(19) then (count(distinct  -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else  -c end-t1.c-c-19+c+a not in (t1.a,13,e)}\n} {-90801}\ndo_test randexpr-2.2496 {\n  db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) | cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) | (max(t1.e))) | min(f) when  -max(19) then (count(distinct  -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE NOT (t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else  -c end-t1.c-c-19+c+a not in (t1.a,13,e))}\n} {}\ndo_test randexpr-2.2497 {\n  db eval {SELECT +(select ~(~cast(avg(t1.c) AS integer)* -cast(avg(c) AS integer))-case min(t1.e) when case count(*)*~(count(*)-+count(*)*cast(avg(case t1.d when 19 then d else (t1.a) end*e) AS integer) & cast(avg(13) AS integer)-cast(avg( -11) AS integer)+max(b)+cast(avg(19) AS integer) & (max(t1.e))) & min(f) when  -max(19) then (count(distinct  -t1.a)) else (count(distinct 17)) end then max(t1.d) else cast(avg(t1.e) AS integer) end from t1) FROM t1 WHERE t1.c-case f when 17 | b then case +case f | case when +t1.a>c and e in (select +max(17) from t1 union select count(*) from t1) then (abs( -c)/abs(a)) when b>=t1.f then t1.b else 11 end when t1.f then 17 else t1.d end*(c)+17 when e then c else t1.f end else  -c end-t1.c-c-19+c+a not in (t1.a,13,e)}\n} {-90801}\ndo_test randexpr-2.2498 {\n  db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a | 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e | e*t1.b)*f)) end FROM t1 WHERE (abs(t1.d)/abs(t1.c)) not between +13 and t1.c}\n} {0}\ndo_test randexpr-2.2499 {\n  db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a | 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e | e*t1.b)*f)) end FROM t1 WHERE NOT ((abs(t1.d)/abs(t1.c)) not between +13 and t1.c)}\n} {}\ndo_test randexpr-2.2500 {\n  db eval {SELECT case t1.d when e then t1.d else (abs(e-b)/abs(t1.c+a*a & 17+19*coalesce((select 17 from t1 where 11 between +(select abs(+cast(avg(13) AS integer)) from t1)*19 and t1.e),t1.e-11-t1.e+( -t1.e*13)*t1.e & e*t1.b)*f)) end FROM t1 WHERE (abs(t1.d)/abs(t1.c)) not between +13 and t1.c}\n} {18}\ndo_test randexpr-2.2501 {\n  db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else  -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) | min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE +t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select  -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13}\n} {}\ndo_test randexpr-2.2502 {\n  db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else  -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) | min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE NOT (+t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select  -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13)}\n} {813}\ndo_test randexpr-2.2503 {\n  db eval {SELECT coalesce((select coalesce((select t1.e from t1 where case when c+a in (select t1.f from t1 union select 13 from t1) then c when not not exists(select 1 from t1 where d>= -11) then t1.d else  -t1.f end between b and 11 or d not between e and 11), -f)+e+ -11*17 from t1 where not exists(select 1 from t1 where exists(select 1 from t1 where t1.e in (select ~min(e) from t1 union select case case count(distinct f) & min(19)+min(a) when count(*) then max( -t1.c) else max(17) end when (max(t1.c)) then min(11) else min(t1.c) end from t1)) or d=a)),t1.e) FROM t1 WHERE NOT (+t1.e<~case when t1.e in (select (abs(c)/abs(~t1.d)) from t1 union select a from t1) then coalesce((select e from t1 where t1.d+ -coalesce((select max(11-t1.e*b) from t1 where 19 in (11,t1.b,e)),11)*t1.e+19 in (select t1.d from t1 union select  -t1.d from t1)),17) | t1.e+e when t1.f in (17,f,f) then t1.b else 17 end*13)}\n} {813}\ndo_test randexpr-2.2504 {\n  db eval {SELECT case when ((t1.f)+coalesce((select coalesce((select ++d from t1 where not t1.d not between e and e),19) from t1 where t1.d<>19),a)-c*a not between c and t1.a and not exists(select 1 from t1 where 17<=a) and exists(select 1 from t1 where not e in (select t1.b from t1 union select t1.e from t1)) and t1.f between 11 and t1.d) or e between c and 13 then t1.a+e when t1.a not between a and d then 17 else t1.a end FROM t1 WHERE (a)+t1.f>t1.e+a}\n} {100}\ndo_test randexpr-2.2505 {\n  db eval {SELECT case when ((t1.f)+coalesce((select coalesce((select ++d from t1 where not t1.d not between e and e),19) from t1 where t1.d<>19),a)-c*a not between c and t1.a and not exists(select 1 from t1 where 17<=a) and exists(select 1 from t1 where not e in (select t1.b from t1 union select t1.e from t1)) and t1.f between 11 and t1.d) or e between c and 13 then t1.a+e when t1.a not between a and d then 17 else t1.a end FROM t1 WHERE NOT ((a)+t1.f>t1.e+a)}\n} {}\ndo_test randexpr-2.2506 {\n  db eval {SELECT b*b+case d*d when t1.f then c else coalesce((select coalesce((select max(f) from t1 where (d=t1.b or case when e=11 then t1.a else f end<>t1.d and exists(select 1 from t1 where f not between t1.c and a))),(select count(distinct f) from t1)+case when t1.b between a and (19) and t1.e=a then 13 else 17 end) from t1 where d>=11),f)*t1.e end-11-a- -(11) FROM t1 WHERE (c<19)}\n} {}\ndo_test randexpr-2.2507 {\n  db eval {SELECT b*b+case d*d when t1.f then c else coalesce((select coalesce((select max(f) from t1 where (d=t1.b or case when e=11 then t1.a else f end<>t1.d and exists(select 1 from t1 where f not between t1.c and a))),(select count(distinct f) from t1)+case when t1.b between a and (19) and t1.e=a then 13 else 17 end) from t1 where d>=11),f)*t1.e end-11-a- -(11) FROM t1 WHERE NOT ((c<19))}\n} {339900}\ndo_test randexpr-2.2508 {\n  db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d | +f*d*coalesce((select case when not  -t1.c<t1.b then t1.b when  -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or  -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a)}\n} {13}\ndo_test randexpr-2.2509 {\n  db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d | +f*d*coalesce((select case when not  -t1.c<t1.b then t1.b when  -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or  -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE NOT (t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a))}\n} {}\ndo_test randexpr-2.2510 {\n  db eval {SELECT coalesce((select max(c) from t1 where ((d between t1.c and c)) and b not between t1.a and a or f+c in (d & +f*d*coalesce((select case when not  -t1.c<t1.b then t1.b when  -t1.a between t1.a and e then 11 else c end from t1 where (t1.d>=a)),e)*f,b,11) or  -19>=t1.c and t1.a in (b,t1.f,c)),13) FROM t1 WHERE t1.c in (select count(distinct t1.a)*max(d) | +case (~ -~+count(distinct 13)*min(19) | (max(e))+ -(count(*))) when count(distinct t1.a) then max(d) else count(*) end+min(t1.c) from t1 union select min(e) from t1) and 17=t1.c-t1.d or t1.c-d not in ( -c,(abs(case a when t1.a then 13 else e end+f)/abs(e)),t1.a)}\n} {13}\ndo_test randexpr-2.2511 {\n  db eval {SELECT case case when not (abs(t1.d)/abs(17))>=t1.a+((19))+ -e-b or 11 between t1.a and 11 then 13 when t1.f in (select case count(distinct t1.d) when abs( -+(cast(avg(t1.c) AS integer)))*count(distinct (t1.e)) then max(19) else case count(distinct t1.a) when cast(avg(19) AS integer) then count(*) else cast(avg((t1.a)) AS integer) end end from t1 union select max(13) from t1) then  -t1.b else t1.f end when c then  -c else b end FROM t1 WHERE not exists(select 1 from t1 where not exists(select 1 from t1 where 13>=f))}\n} {}\ndo_test randexpr-2.2512 {\n  db eval {SELECT case case when not (abs(t1.d)/abs(17))>=t1.a+((19))+ -e-b or 11 between t1.a and 11 then 13 when t1.f in (select case count(distinct t1.d) when abs( -+(cast(avg(t1.c) AS integer)))*count(distinct (t1.e)) then max(19) else case count(distinct t1.a) when cast(avg(19) AS integer) then count(*) else cast(avg((t1.a)) AS integer) end end from t1 union select max(13) from t1) then  -t1.b else t1.f end when c then  -c else b end FROM t1 WHERE NOT (not exists(select 1 from t1 where not exists(select 1 from t1 where 13>=f)))}\n} {200}\ndo_test randexpr-2.2513 {\n  db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) | abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE  - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else  -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f)}\n} {}\ndo_test randexpr-2.2514 {\n  db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) | abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE NOT ( - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else  -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f))}\n} {11}\ndo_test randexpr-2.2515 {\n  db eval {SELECT 11-(abs( -(select ((count(*)-(abs( -min(~19)))+case min(case when not exists(select 1 from t1 where (exists(select 1 from t1 where 17>f) or t1.c>=a)) then d else 11 end) & abs(cast(avg(19) AS integer)) when (count(distinct t1.f*19))-+ -( -count(*)) then ((cast(avg(t1.d) AS integer))) else cast(avg(t1.a) AS integer) end*count(distinct t1.d))+cast(avg(c) AS integer))-max(17) from t1)-17)/abs(t1.f)) FROM t1 WHERE NOT ( - - -f+d in (select 19 from t1 union select t1.b from t1) or ((abs(a)/abs( -11+case when t1.e>=( -f) | d then ~t1.a when coalesce((select t1.d from t1 where e not in (e-(d)+a,e,t1.b)),a)<>t1.b then a else  -t1.c end)))<=t1.e and t1.e in (13,t1.a,t1.f))}\n} {11}\ndo_test randexpr-2.2516 {\n  db eval {SELECT coalesce((select ~11*b from t1 where (not exists(select 1 from t1 where case d when t1.b then t1.b else d end not between b and t1.b and f in (select ~count(*) from t1 union select count(distinct coalesce((select max( -c+(abs(coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where d>a)),t1.b)-17)/abs((b)))*(a)) from t1 where t1.f>b),f)) from t1) or t1.e not in ((d),c,c)))),c)*17+t1.c FROM t1 WHERE coalesce((select 17*case when exists(select 1 from t1 where coalesce((select t1.e from t1 where f<>e and e not between c and 11),d) in (select 11 from t1 union select c from t1)) then t1.b when t1.a between t1.f and 19 then t1.d else t1.c end*f | 19 from t1 where a between t1.c and b or t1.e in ((b),b,t1.f)),17) in (select ( -~case case (((count(*)))) when max(e) then max(e) else cast(avg(c) AS integer) end when min(17) then cast(avg(13) AS integer) else cast(avg(t1.b) AS integer) end+ -count(*)* -count(*))+min(d) from t1 union select count(distinct t1.e) from t1)}\n} {}\ndo_test randexpr-2.2517 {\n  db eval {SELECT coalesce((select ~11*b from t1 where (not exists(select 1 from t1 where case d when t1.b then t1.b else d end not between b and t1.b and f in (select ~count(*) from t1 union select count(distinct coalesce((select max( -c+(abs(coalesce((select max(t1.a) from t1 where not exists(select 1 from t1 where d>a)),t1.b)-17)/abs((b)))*(a)) from t1 where t1.f>b),f)) from t1) or t1.e not in ((d),c,c)))),c)*17+t1.c FROM t1 WHERE NOT (coalesce((select 17*case when exists(select 1 from t1 where coalesce((select t1.e from t1 where f<>e and e not between c and 11),d) in (select 11 from t1 union select c from t1)) then t1.b when t1.a between t1.f and 19 then t1.d else t1.c end*f | 19 from t1 where a between t1.c and b or t1.e in ((b),b,t1.f)),17) in (select ( -~case case (((count(*)))) when max(e) then max(e) else cast(avg(c) AS integer) end when min(17) then cast(avg(13) AS integer) else cast(avg(t1.b) AS integer) end+ -count(*)* -count(*))+min(d) from t1 union select count(distinct t1.e) from t1))}\n} {5400}\ndo_test randexpr-2.2518 {\n  db eval {SELECT (abs(case when not +c<>coalesce((select max(19) from t1 where not (abs(c)/abs(a))*a-t1.a>=case when (exists(select 1 from t1 where d=11)) then t1.a*~b else case when b in (select (f) from t1 union select 17 from t1) or not 17 not between f and  -b then t1.a when f<t1.e then a else t1.c end end),t1.c) then case when 19 between 13 and a then 13 else t1.f end else 11 end)/abs(a)) FROM t1 WHERE (t1.f in (select case case ~abs(case case  -cast(avg((select +max((select min(c) from t1)) from t1)) AS integer) when  -abs( -max(f)*count(*)) then ~case max(c)-count(distinct (t1.f))-(cast(avg(t1.d) AS integer)) when ( -cast(avg( -11) AS integer)) then min( -13) else count(*) end else  -cast(avg(f) AS integer) end when ((min(e))) then min(t1.f) else (count(distinct 17)) end | cast(avg(11) AS integer)-cast(avg(13) AS integer)) when count(*) then count(*) else max(b) end when count(distinct 17) then  -count(distinct t1.d) else count(distinct  -e) end*min(t1.c) from t1 union select count(distinct 17) from t1))}\n} {}\ndo_test randexpr-2.2519 {\n  db eval {SELECT (abs(case when not +c<>coalesce((select max(19) from t1 where not (abs(c)/abs(a))*a-t1.a>=case when (exists(select 1 from t1 where d=11)) then t1.a*~b else case when b in (select (f) from t1 union select 17 from t1) or not 17 not between f and  -b then t1.a when f<t1.e then a else t1.c end end),t1.c) then case when 19 between 13 and a then 13 else t1.f end else 11 end)/abs(a)) FROM t1 WHERE NOT ((t1.f in (select case case ~abs(case case  -cast(avg((select +max((select min(c) from t1)) from t1)) AS integer) when  -abs( -max(f)*count(*)) then ~case max(c)-count(distinct (t1.f))-(cast(avg(t1.d) AS integer)) when ( -cast(avg( -11) AS integer)) then min( -13) else count(*) end else  -cast(avg(f) AS integer) end when ((min(e))) then min(t1.f) else (count(distinct 17)) end | cast(avg(11) AS integer)-cast(avg(13) AS integer)) when count(*) then count(*) else max(b) end when count(distinct 17) then  -count(distinct t1.d) else count(distinct  -e) end*min(t1.c) from t1 union select count(distinct 17) from t1)))}\n} {0}\ndo_test randexpr-2.2520 {\n  db eval {SELECT ~case when case 11*17 when f then t1.a else t1.e end in ( -coalesce((select max(case coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.c in (case t1.e when  -d then c else (d) end,t1.e,t1.a))), -t1.c) when 19 then 11 else t1.e end) from t1 where t1.e in (19, -t1.b,a)),17)+f-11,17,19) then a when ((d<d)) then 11 else  -t1.e end FROM t1 WHERE not e>=t1.b and (b not in (c,t1.e,t1.a))}\n} {}\ndo_test randexpr-2.2521 {\n  db eval {SELECT ~case when case 11*17 when f then t1.a else t1.e end in ( -coalesce((select max(case coalesce((select t1.f from t1 where exists(select 1 from t1 where t1.c in (case t1.e when  -d then c else (d) end,t1.e,t1.a))), -t1.c) when 19 then 11 else t1.e end) from t1 where t1.e in (19, -t1.b,a)),17)+f-11,17,19) then a when ((d<d)) then 11 else  -t1.e end FROM t1 WHERE NOT (not e>=t1.b and (b not in (c,t1.e,t1.a)))}\n} {499}\ndo_test randexpr-2.2522 {\n  db eval {SELECT (abs(case f when case when d+f between e and t1.f then f when coalesce((select max(t1.f) from t1 where c in (select t1.a from t1 union select case when a not between t1.c and 13 then a else t1.c end from t1) or f*f not in (case when (11<=d) then case when 13<t1.a then (t1.d) else t1.a end else t1.a end-t1.d,17,f) or a>= -d),b)<=t1.b then t1.e else 13 end then f else t1.b end)/abs(f)) FROM t1 WHERE c between c and coalesce((select max(f) from t1 where b in (select count(*) from t1 union select max(13) from t1)),19)}\n} {}\ndo_test randexpr-2.2523 {\n  db eval {SELECT (abs(case f when case when d+f between e and t1.f then f when coalesce((select max(t1.f) from t1 where c in (select t1.a from t1 union select case when a not between t1.c and 13 then a else t1.c end from t1) or f*f not in (case when (11<=d) then case when 13<t1.a then (t1.d) else t1.a end else t1.a end-t1.d,17,f) or a>= -d),b)<=t1.b then t1.e else 13 end then f else t1.b end)/abs(f)) FROM t1 WHERE NOT (c between c and coalesce((select max(f) from t1 where b in (select count(*) from t1 union select max(13) from t1)),19))}\n} {0}\ndo_test randexpr-2.2524 {\n  db eval {SELECT d++11*a+coalesce((select max(t1.a) from t1 where 17+case when (19>=a) then t1.b when f>=f then  -(select cast(avg(t1.e-t1.f*t1.a) AS integer) from t1)-f else t1.f end*a+f*t1.a not in (t1.e,e,13)),17)- -t1.b-a-c*19 FROM t1 WHERE f*t1.a*t1.b>17 and case when 13 not in (19, -(select count(*) from t1),coalesce((select max(coalesce((select max(t1.a) from t1 where  -coalesce((select max(case when not t1.f<=(t1.d) then t1.a else (a) end) from t1 where t1.f>c or 13<(t1.a)),17)>=t1.a or not exists(select 1 from t1 where  - -c not in (a,t1.b,t1.e))),t1.e)) from t1 where (f not in (b,f,f))),c)) then (t1.e) when t1.a<>e then e else b end- -t1.f not in (a, -c,(c))}\n} {-4000}\ndo_test randexpr-2.2525 {\n  db eval {SELECT d++11*a+coalesce((select max(t1.a) from t1 where 17+case when (19>=a) then t1.b when f>=f then  -(select cast(avg(t1.e-t1.f*t1.a) AS integer) from t1)-f else t1.f end*a+f*t1.a not in (t1.e,e,13)),17)- -t1.b-a-c*19 FROM t1 WHERE NOT (f*t1.a*t1.b>17 and case when 13 not in (19, -(select count(*) from t1),coalesce((select max(coalesce((select max(t1.a) from t1 where  -coalesce((select max(case when not t1.f<=(t1.d) then t1.a else (a) end) from t1 where t1.f>c or 13<(t1.a)),17)>=t1.a or not exists(select 1 from t1 where  - -c not in (a,t1.b,t1.e))),t1.e)) from t1 where (f not in (b,f,f))),c)) then (t1.e) when t1.a<>e then e else b end- -t1.f not in (a, -c,(c)))}\n} {}\ndo_test randexpr-2.2526 {\n  db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end |  -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE  -f | t1.f*c-t1.a | t1.c+11*case ~17 when  -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c}\n} {200}\ndo_test randexpr-2.2527 {\n  db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end |  -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE NOT ( -f | t1.f*c-t1.a | t1.c+11*case ~17 when  -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c)}\n} {}\ndo_test randexpr-2.2528 {\n  db eval {SELECT coalesce((select (a) from t1 where 11-11+t1.b<=17-b),case when case when not t1.e*f>= -t1.f and a in (11,t1.c,t1.b) or 19>e then (select case min((f)-f) when cast(avg(t1.a) AS integer) then (cast(avg(17) AS integer)) else ((cast(avg((13)) AS integer))) end from t1) when 13 not between f and t1.c then (abs(e)/abs(17)) else t1.e end &  -17<=f then b when f<19 or t1.b<=t1.d then f else f end) FROM t1 WHERE  -f | t1.f*c-t1.a | t1.c+11*case ~17 when  -coalesce((select max(t1.e) from t1 where 13*(17)>=11),t1.a) then case case when (t1.b>= -t1.b) then t1.f when t1.f<a or 11>a and t1.e in (e,(t1.d),19) then t1.f else t1.c end when a then t1.a else t1.e end else a end*t1.a-13<c}\n} {200}\ndo_test randexpr-2.2529 {\n  db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) | t1.a) in (select abs(~((min(t1.f) | cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) |  -((count(*))))-cast(avg(d) AS integer) from t1 union select  -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when  -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE c<=19}\n} {}\ndo_test randexpr-2.2530 {\n  db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) | t1.a) in (select abs(~((min(t1.f) | cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) |  -((count(*))))-cast(avg(d) AS integer) from t1 union select  -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when  -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE NOT (c<=19)}\n} {0}\ndo_test randexpr-2.2531 {\n  db eval {SELECT (abs(case when exists(select 1 from t1 where b not between ~case when (t1.e-(c-t1.c) & t1.a) in (select abs(~((min(t1.f) & cast(avg(c) AS integer))*(min(b))-count(distinct 19)*min(e)) &  -((count(*))))-cast(avg(d) AS integer) from t1 union select  -count(distinct t1.a) from t1) or f>a then 11 else e end*11 and t1.e) then t1.e when  -17<11 then 17 else t1.a end)/abs(a)) FROM t1 WHERE NOT (c<=19)}\n} {0}\ndo_test randexpr-2.2532 {\n  db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when  - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a | t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE (case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17)}\n} {2200}\ndo_test randexpr-2.2533 {\n  db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when  - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a | t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE NOT ((case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17))}\n} {}\ndo_test randexpr-2.2534 {\n  db eval {SELECT case when t1.e-19 in (case (abs(t1.a*+~c*coalesce((select c from t1 where ~ -(select abs(case cast(avg(13) AS integer) when  - -cast(avg(f) AS integer) then count(distinct t1.d) else (count(*)) end+count(*)) from t1) not between (abs(a & t1.a)/abs(t1.c)) and 19),t1.b)-c*17*(t1.f))/abs(d)) when 13 then 19 else t1.b end,(b),17) then 19 when (11)>=t1.b then b else b end*11 FROM t1 WHERE (case 11 when case t1.e when coalesce((select a from t1 where t1.a<t1.e),t1.e | case when 13 in (coalesce((select max( -b) from t1 where d not between (t1.a) and t1.e and t1.e>=t1.a),t1.f),d,13) then c when 11 between t1.b and 17 then d else 19 end) then f else 19 end then t1.d else c end< -c) and a not in (11,c,11) or 11<>e or exists(select 1 from t1 where b<17)}\n} {2200}\ndo_test randexpr-2.2535 {\n  db eval {SELECT t1.b*case when (abs(t1.c+case when d not in (a,case when b=(t1.a) then (e) when b not between f and t1.c then t1.b else t1.e end, -11) then t1.d when not exists(select 1 from t1 where 19 not between (a) and a or t1.c>d) then d else b end+t1.a+13-19+d)/abs(t1.d))> -t1.f then t1.a when t1.d in (select d from t1 union select c from t1) or 13 not between d and t1.f then t1.b else e end+ - -a FROM t1 WHERE t1.f<=11}\n} {}\ndo_test randexpr-2.2536 {\n  db eval {SELECT t1.b*case when (abs(t1.c+case when d not in (a,case when b=(t1.a) then (e) when b not between f and t1.c then t1.b else t1.e end, -11) then t1.d when not exists(select 1 from t1 where 19 not between (a) and a or t1.c>d) then d else b end+t1.a+13-19+d)/abs(t1.d))> -t1.f then t1.a when t1.d in (select d from t1 union select c from t1) or 13 not between d and t1.f then t1.b else e end+ - -a FROM t1 WHERE NOT (t1.f<=11)}\n} {20100}\ndo_test randexpr-2.2537 {\n  db eval {SELECT coalesce((select max(coalesce((select e+t1.c from t1 where f*11+coalesce((select max(17) from t1 where not ~case a when t1.f+13*e-(11)*t1.f then d else a end>d and (a not between t1.c and t1.c)),t1.d)- -f-b+11=b),19)-t1.f) from t1 where exists(select 1 from t1 where 19<>11)),c) FROM t1 WHERE case when 11 in (select  -abs(abs( - -(cast(avg(+11-c) AS integer)+cast(avg(~a) AS integer))*max(11))+cast(avg(d) AS integer)-cast(avg(e) AS integer)-((max(t1.e))))+count(*) from t1 union select ( -count(*)) from t1) then t1.a when e>d then c- - -t1.a else 19 end in (select count(distinct  -f) from t1 union select count(distinct d) from t1) and not e<17}\n} {}\ndo_test randexpr-2.2538 {\n  db eval {SELECT coalesce((select max(coalesce((select e+t1.c from t1 where f*11+coalesce((select max(17) from t1 where not ~case a when t1.f+13*e-(11)*t1.f then d else a end>d and (a not between t1.c and t1.c)),t1.d)- -f-b+11=b),19)-t1.f) from t1 where exists(select 1 from t1 where 19<>11)),c) FROM t1 WHERE NOT (case when 11 in (select  -abs(abs( - -(cast(avg(+11-c) AS integer)+cast(avg(~a) AS integer))*max(11))+cast(avg(d) AS integer)-cast(avg(e) AS integer)-((max(t1.e))))+count(*) from t1 union select ( -count(*)) from t1) then t1.a when e>d then c- - -t1.a else 19 end in (select count(distinct  -f) from t1 union select count(distinct d) from t1) and not e<17)}\n} {-581}\ndo_test randexpr-2.2539 {\n  db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between  - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) | count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE ((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d |  -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d)}\n} {}\ndo_test randexpr-2.2540 {\n  db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between  - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) | count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE NOT (((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d |  -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d))}\n} {400}\ndo_test randexpr-2.2541 {\n  db eval {SELECT case when (coalesce((select max(a*case when 17+f>f-t1.d*t1.f then t1.d when t1.c not between t1.e and d then 19 else (c) end) from t1 where not t1.d not between  - -17 and 19),t1.a) in (select min((13)) from t1 union select ~(abs(count(distinct t1.a))*((( -max( -t1.f)))+max( -t1.c) & count(*)))-cast(avg(11) AS integer) from t1)) then c- - -d when t1.d>=d then d else 13 end FROM t1 WHERE NOT (((abs(t1.a-t1.a*t1.d*coalesce((select coalesce((select max(11) from t1 where exists(select 1 from t1 where 11+t1.d |  -t1.c-case when b+d in (select count(*) from t1 union select max(17)+ -count(distinct t1.d) from t1) then t1.c else d end-a | 13<>c)),t1.c) from t1 where 13 not in (d,t1.a,f) and 19=t1.f),(13))+(t1.d))/abs(t1.c)) between t1.f and t1.d))}\n} {400}\ndo_test randexpr-2.2542 {\n  db eval {SELECT case when f | c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between  -(t1.e) and f) then 17 when f in (select  -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then  -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end}\n} {}\ndo_test randexpr-2.2543 {\n  db eval {SELECT case when f | c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE NOT (e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between  -(t1.e) and f) then 17 when f in (select  -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then  -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end)}\n} {11}\ndo_test randexpr-2.2544 {\n  db eval {SELECT case when f & c>t1.d-case when (abs(t1.b-t1.d*f)/abs(c))=t1.e then 17 when not exists(select 1 from t1 where t1.b=(11) or c not in (13,17,b)) or a<e then t1.f else 19 end+b-t1.f and t1.b between t1.b and t1.f and e in (t1.f,b,b) then (select cast(avg(e) AS integer)-~ -~count(*) from t1) else 11 end FROM t1 WHERE NOT (e<=case when (case when 17<>a then t1.c when not 11<(f) then case when t1.c= -b then c else 11 end else e end | f>=t1.b and b not between  -(t1.e) and f) then 17 when f in (select  -count(distinct t1.e) from t1 union select case min(f) when case cast(avg( -t1.b) AS integer) when cast(avg(e) AS integer) then  -max(e) else min(t1.b) end then count(*) else (cast(avg(t1.e) AS integer)) end from t1) then case c when e then t1.f else 13 end else t1.d end)}\n} {11}\ndo_test randexpr-2.2545 {\n  db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end | e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select  - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select  -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a}\n} {}\ndo_test randexpr-2.2546 {\n  db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end | e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE NOT (e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select  - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select  -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a)}\n} {34}\ndo_test randexpr-2.2547 {\n  db eval {SELECT 17+coalesce((select max(19) from t1 where 11 in (select (abs((abs(~(case +b+17 when t1.e*t1.b then 17 else case when t1.b+17+d*a in (select (~count(distinct a)) from t1 union select case cast(avg(t1.e) AS integer) when count(*) then count(distinct t1.d) else count(distinct b) end from t1) then t1.f when (t1.e in ( -t1.a,t1.e,d)) then 17 else t1.e end & e end)- -b)/abs(t1.f)))/abs(13)) from t1 union select t1.d from t1)),17) FROM t1 WHERE NOT (e+t1.b not in (d,a,t1.c) and case case e when (case when +case 13 when t1.a then 19 else 19 end+d in (select count(*)-min(b) from t1 union select  - -min(t1.d) from t1) or f in (select ( -min(t1.e)) from t1 union select cast(avg( -19) AS integer) from t1) or (t1.f in (select  -max( -t1.c) from t1 union select (min(t1.c)) from t1)) then b else +t1.b end)-t1.b then b else 19 end when a then b else e end between ( -(t1.c)) and a)}\n} {34}\ndo_test randexpr-2.2548 {\n  db eval {SELECT (abs(~(abs((select ~count(*) | +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b | t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE c not in (coalesce((select t1.a from t1 where  -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f)}\n} {80}\ndo_test randexpr-2.2549 {\n  db eval {SELECT (abs(~(abs((select ~count(*) | +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b | t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE NOT (c not in (coalesce((select t1.a from t1 where  -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f))}\n} {}\ndo_test randexpr-2.2550 {\n  db eval {SELECT (abs(~(abs((select ~count(*) & +(max( -coalesce((select max(13) from t1 where coalesce((select max(t1.d) from t1 where 11<+coalesce((select max((case when 19=t1.a then (d) else 19 end)) from t1 where (11) in (17,c,b)),c)*t1.e),t1.c)<13),11)*b & t1.c+17)) from t1))/abs(~b-f))-t1.d*a)/abs(e)) FROM t1 WHERE c not in (coalesce((select t1.a from t1 where  -(t1.a+17*~case when coalesce((select max(t1.c) from t1 where (coalesce((select max(t1.f) from t1 where not exists(select 1 from t1 where a<=t1.a)),11) in (select (count(distinct t1.d)+count(distinct c)) from t1 union select count(distinct e) from t1))),13)*f=d then d when t1.d in (select t1.d from t1 union select t1.f from t1) then d else t1.f end+c*c | f)+t1.c*t1.a in (select 17 from t1 union select 13 from t1)),t1.f),17,t1.f)}\n} {80}\ndo_test randexpr-2.2551 {\n  db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d | case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where  -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) | (t1.a)+e else a end FROM t1 WHERE (case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case  -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d |  -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select  -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17))}\n} {100}\ndo_test randexpr-2.2552 {\n  db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d | case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where  -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) | (t1.a)+e else a end FROM t1 WHERE NOT ((case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case  -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d |  -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select  -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17)))}\n} {}\ndo_test randexpr-2.2553 {\n  db eval {SELECT case (19) when t1.a then t1.f+coalesce((select max(t1.f) from t1 where case when t1.c=t1.a or (t1.d & case when t1.f=t1.d then a else coalesce((select max(case when 11>=a then t1.b else d end+t1.a) from t1 where  -t1.a not between t1.e and 19),11) end<>t1.d) then t1.e else c end-t1.f*b+f=19),t1.b) & (t1.a)+e else a end FROM t1 WHERE (case e when d then +(select (min(t1.a)) from t1) else case when a in ((select min(case  -t1.c when d then d else f end+ -e)-+cast(avg(19) AS integer)+max(d) from t1)*t1.d |  -t1.c,b,e) then t1.d when t1.b in (select +min(e) | min(t1.b) from t1 union select  -count(distinct e) from t1) then d else 11 end*13-(e) end not in (t1.c,c,17))}\n} {100}\ndo_test randexpr-2.2554 {\n  db eval {SELECT (abs(( -case when 11*coalesce((select coalesce((select d from t1 where ((+t1.f*(select max(t1.f)*min(t1.a) from t1)*d*t1.f between 11 and 13))), -t1.c) from t1 where ((e)>=t1.b) or not t1.a in (select f from t1 union select c from t1) and 11<=a or c between (t1.c) and t1.d),t1.f)<t1.b then 13 else c end-d-t1.e))/abs(17)) FROM t1 WHERE +(select ~case  -++(( -~count(distinct t1.b)))*min(c)*max(t1.f) when ~+count(distinct  -(abs(d)/abs(t1.a))+t1.d+c-13) then count(*) else case (~max(d))+((count(distinct f))) when max(t1.e) then min(t1.c) else (cast(avg(t1.e) AS integer)) end end from t1)-+(select min(17) from t1)+19>t1.f}\n} {}\ndo_test randexpr-2.2555 {\n  db eval {SELECT (abs(( -case when 11*coalesce((select coalesce((select d from t1 where ((+t1.f*(select max(t1.f)*min(t1.a) from t1)*d*t1.f between 11 and 13))), -t1.c) from t1 where ((e)>=t1.b) or not t1.a in (select f from t1 union select c from t1) and 11<=a or c between (t1.c) and t1.d),t1.f)<t1.b then 13 else c end-d-t1.e))/abs(17)) FROM t1 WHERE NOT (+(select ~case  -++(( -~count(distinct t1.b)))*min(c)*max(t1.f) when ~+count(distinct  -(abs(d)/abs(t1.a))+t1.d+c-13) then count(*) else case (~max(d))+((count(distinct f))) when max(t1.e) then min(t1.c) else (cast(avg(t1.e) AS integer)) end end from t1)-+(select min(17) from t1)+19>t1.f)}\n} {53}\ndo_test randexpr-2.2556 {\n  db eval {SELECT case (t1.b) | t1.d-+t1.e*(select (~count(*) | min(c)-case max(case when e | b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) | b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE (17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11}\n} {}\ndo_test randexpr-2.2557 {\n  db eval {SELECT case (t1.b) | t1.d-+t1.e*(select (~count(*) | min(c)-case max(case when e | b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) | b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE NOT ((17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11)}\n} {400}\ndo_test randexpr-2.2558 {\n  db eval {SELECT case (t1.b) & t1.d-+t1.e*(select (~count(*) & min(c)-case max(case when e & b in (select t1.b from t1 union select t1.b from t1) then d when 17 between 13 and t1.d then d else t1.c end) when abs(count(distinct (t1.e)))- -min(t1.e) then cast(avg(17) AS integer) else count(distinct c) end) from t1) & b-a-+f-t1.f when +a then t1.d else d end FROM t1 WHERE NOT ((17>t1.d) and coalesce((select max((t1.a)+coalesce((select max(17*b) from t1 where t1.d-coalesce((select t1.e from t1 where t1.b<>13 or 19=t1.a),t1.d)*f<=(19) or (t1.c<11 and not not d<t1.a)), -11)-17) from t1 where t1.d not in (19,a,t1.c)),e)*13>t1.d or d=11)}\n} {400}\ndo_test randexpr-2.2559 {\n  db eval {SELECT case when case when coalesce((select max(c*case (select min(case when f in (select t1.e from t1 union select f+case when d<=d then t1.f when b<=11 then t1.c else t1.b end*11 from t1) then f else c end) from t1) when f then 11 else b end) from t1 where d in (t1.b,t1.a,c)),d) between (d) and 19 then  -a else a end in ( -c,t1.d,t1.d) then c when e<> -d then a else t1.c end FROM t1 WHERE a=c or case when e<coalesce((select t1.c from t1 where exists(select 1 from t1 where (f not in (case (select case +(min(11)) when cast(avg(t1.c) AS integer) then count(*) else  - -cast(avg(t1.a) AS integer) end from t1) when t1.b then d else t1.b end,13,a) and t1.c<= -t1.d and (t1.a)<=b or e not between t1.a and b) or a not between t1.b and t1.f) or 19>=(e)),t1.a) then c | t1.f when exists(select 1 from t1 where a not between 19 and e) then t1.a else 17 end>t1.d}\n} {}\ndo_test randexpr-2.2560 {\n  db eval {SELECT case when case when coalesce((select max(c*case (select min(case when f in (select t1.e from t1 union select f+case when d<=d then t1.f when b<=11 then t1.c else t1.b end*11 from t1) then f else c end) from t1) when f then 11 else b end) from t1 where d in (t1.b,t1.a,c)),d) between (d) and 19 then  -a else a end in ( -c,t1.d,t1.d) then c when e<> -d then a else t1.c end FROM t1 WHERE NOT (a=c or case when e<coalesce((select t1.c from t1 where exists(select 1 from t1 where (f not in (case (select case +(min(11)) when cast(avg(t1.c) AS integer) then count(*) else  - -cast(avg(t1.a) AS integer) end from t1) when t1.b then d else t1.b end,13,a) and t1.c<= -t1.d and (t1.a)<=b or e not between t1.a and b) or a not between t1.b and t1.f) or 19>=(e)),t1.a) then c | t1.f when exists(select 1 from t1 where a not between 19 and e) then t1.a else 17 end>t1.d)}\n} {100}\ndo_test randexpr-2.2561 {\n  db eval {SELECT 13+(select  -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) | min(t1.e | t1.e-t1.b)*max(e)-max(t1.f) | min(c)*min(t1.b)+min(t1.e)-count(distinct 11) | min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE d in (select count(*) from t1 union select case count(*) when max(17) |  -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select  -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when  -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a)}\n} {}\ndo_test randexpr-2.2562 {\n  db eval {SELECT 13+(select  -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) | min(t1.e | t1.e-t1.b)*max(e)-max(t1.f) | min(c)*min(t1.b)+min(t1.e)-count(distinct 11) | min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE NOT (d in (select count(*) from t1 union select case count(*) when max(17) |  -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select  -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when  -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a))}\n} {-261615}\ndo_test randexpr-2.2563 {\n  db eval {SELECT 13+(select  -abs(+cast(avg((select cast(avg(t1.e*(t1.c)- -(abs(b+e)/abs(f))) AS integer) from t1)) AS integer)-~ -+abs(abs(count(*))) & min(t1.e & t1.e-t1.b)*max(e)-max(t1.f) & min(c)*min(t1.b)+min(t1.e)-count(distinct 11) & min(b)*( - -count(distinct 19)))-count(*) from t1) FROM t1 WHERE NOT (d in (select count(*) from t1 union select case count(*) when max(17) |  -max(coalesce((select case t1.d*t1.e when t1.a then 11 else 13 end*f- -f from t1 where b in (select case ~abs(max(13)) when case ((max(c))) when cast(avg(t1.c) AS integer) then max(13) else count(distinct t1.d) end then cast(avg(t1.a) AS integer) else cast(avg(11) AS integer) end from t1 union select  -max(13) from t1)),13))*cast(avg(f) AS integer) then count(*) else count(distinct e) end from t1) and exists(select 1 from t1 where case d when  -(abs(17)/abs(t1.f)) then t1.a else t1.d end<t1.a))}\n} {-52}\ndo_test randexpr-2.2564 {\n  db eval {SELECT c+c*(abs(t1.c+coalesce((select case when 17 not in (t1.f,t1.e,t1.d) or (17<t1.d) then case d when t1.a then t1.f else 11 end else t1.e end*d from t1 where 19 in (select abs(~count(distinct a)) from t1 union select case cast(avg(t1.c) AS integer) when  -max(t1.b) then min(c) else min(f) end+ -max(t1.d) from t1)),t1.b)+t1.e)/abs(17))+t1.b+ -t1.f+17-t1.c FROM t1 WHERE (13)+19>=19}\n} {17017}\ndo_test randexpr-2.2565 {\n  db eval {SELECT c+c*(abs(t1.c+coalesce((select case when 17 not in (t1.f,t1.e,t1.d) or (17<t1.d) then case d when t1.a then t1.f else 11 end else t1.e end*d from t1 where 19 in (select abs(~count(distinct a)) from t1 union select case cast(avg(t1.c) AS integer) when  -max(t1.b) then min(c) else min(f) end+ -max(t1.d) from t1)),t1.b)+t1.e)/abs(17))+t1.b+ -t1.f+17-t1.c FROM t1 WHERE NOT ((13)+19>=19)}\n} {}\ndo_test randexpr-2.2566 {\n  db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select  -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) | cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a | 17 | t1.a-f FROM t1 WHERE (c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct  -b) then cast(avg(11) AS integer) else  - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or  -17=b or f in (select a from t1 union select  -b from t1))}\n} {-227}\ndo_test randexpr-2.2567 {\n  db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select  -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) | cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a | 17 | t1.a-f FROM t1 WHERE NOT ((c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct  -b) then cast(avg(11) AS integer) else  - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or  -17=b or f in (select a from t1 union select  -b from t1)))}\n} {}\ndo_test randexpr-2.2568 {\n  db eval {SELECT +case when not c in (select count(distinct t1.b) from t1 union select  -+(cast(avg(b*t1.b) AS integer))*max(case 17 when b then 13 else t1.a end)-count(distinct a) & cast(avg(t1.f) AS integer)+max(t1.d) from t1) then t1.e when a<=case t1.a when (e) then t1.d else d end then d else t1.b end*11-a & 17 & t1.a-f FROM t1 WHERE (c not in (t1.b,(select case case ++(min(19))*(count(distinct t1.a))+count(distinct e) | cast(avg(t1.e) AS integer) when min( -t1.d) then cast(avg(13) AS integer) else min(17) end*cast(avg(a) AS integer) when count(distinct  -b) then cast(avg(11) AS integer) else  - -(cast(avg(c) AS integer)) end from t1)-11+t1.e,t1.a) or d*case d when a then t1.c else 17 end*19 not between b and t1.c or  -17=b or f in (select a from t1 union select  -b from t1))}\n} {0}\ndo_test randexpr-2.2569 {\n  db eval {SELECT coalesce((select (abs(f)/abs(coalesce((select max(19*b+d*coalesce((select max(t1.c) from t1 where case when d>=(abs((11))/abs(t1.a*13+(13)-d*e+11)) then t1.c when t1.c>=a then 19 else  -17 end*t1.e> -e),t1.f)) from t1 where 13<=t1.e),t1.d))) from t1 where t1.d in (select d from t1 union select a from t1)),t1.e) FROM t1 WHERE t1.c between (11) and coalesce((select max(b*case t1.c when t1.f then t1.f else 11 end) from t1 where +(select count(distinct case when f not between  -13 and 19 then t1.f++(f) | t1.e*(+13)* -(t1.c)-t1.b when 13=t1.d then 19 else t1.b end*t1.a) from t1) in (t1.e,11, -19)),d)+f}\n} {0}\ndo_test randexpr-2.2570 {\n  db eval {SELECT coalesce((select (abs(f)/abs(coalesce((select max(19*b+d*coalesce((select max(t1.c) from t1 where case when d>=(abs((11))/abs(t1.a*13+(13)-d*e+11)) then t1.c when t1.c>=a then 19 else  -17 end*t1.e> -e),t1.f)) from t1 where 13<=t1.e),t1.d))) from t1 where t1.d in (select d from t1 union select a from t1)),t1.e) FROM t1 WHERE NOT (t1.c between (11) and coalesce((select max(b*case t1.c when t1.f then t1.f else 11 end) from t1 where +(select count(distinct case when f not between  -13 and 19 then t1.f++(f) | t1.e*(+13)* -(t1.c)-t1.b when 13=t1.d then 19 else t1.b end*t1.a) from t1) in (t1.e,11, -19)),d)+f)}\n} {}\ndo_test randexpr-2.2571 {\n  db eval {SELECT case when (not 19>=(abs(t1.b)/abs(+f))) then case 13 when case t1.c when t1.b then f else 13 end then t1.e else t1.a end+coalesce((select max(c) from t1 where a not between t1.d*17*coalesce((select max(e*b) from t1 where t1.a=11),t1.c) and t1.d),t1.d) when (case when t1.d not in (e,t1.a,t1.b) then 19 else t1.f end between t1.c and 19) then t1.e else 11 end FROM t1 WHERE t1.b*+c>=17}\n} {11}\ndo_test randexpr-2.2572 {\n  db eval {SELECT case when (not 19>=(abs(t1.b)/abs(+f))) then case 13 when case t1.c when t1.b then f else 13 end then t1.e else t1.a end+coalesce((select max(c) from t1 where a not between t1.d*17*coalesce((select max(e*b) from t1 where t1.a=11),t1.c) and t1.d),t1.d) when (case when t1.d not in (e,t1.a,t1.b) then 19 else t1.f end between t1.c and 19) then t1.e else 11 end FROM t1 WHERE NOT (t1.b*+c>=17)}\n} {}\ndo_test randexpr-2.2573 {\n  db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else  -case when c*t1.d>=b*b then  -t1.f else b-t1.c | d*(case t1.d when  -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE ~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or  -a not between c and t1.b then c when  -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13)}\n} {500}\ndo_test randexpr-2.2574 {\n  db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else  -case when c*t1.d>=b*b then  -t1.f else b-t1.c | d*(case t1.d when  -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE NOT (~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or  -a not between c and t1.b then c when  -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13))}\n} {}\ndo_test randexpr-2.2575 {\n  db eval {SELECT case when d-t1.c<>e then c when (11 not between 13 and 13) then 13 else  -case when c*t1.d>=b*b then  -t1.f else b-t1.c & d*(case t1.d when  -case t1.b when t1.b then t1.b else 19 end*19*(t1.d) then 13 else 19 end) end+19*11 end+b FROM t1 WHERE ~~case when t1.d+(abs(t1.b+coalesce((select coalesce((select max(b-a-a) from t1 where 17 not in (e,case when (t1.d)<=t1.f or  -a not between c and t1.b then c when  -19 in ( -d,(t1.a),19) then b else f end,t1.e)), -13) from t1 where not b in (t1.b, -t1.b,c)),e))/abs(11)) between 13 and d then (t1.b) when t1.e<13 then 19 else a end-(19)-d*t1.d not in (d,t1.c,13)}\n} {500}\ndo_test randexpr-2.2576 {\n  db eval {SELECT 19+t1.d+d-t1.c*case when 11 not between e and ~c+(select min((abs(t1.b*t1.b)/abs(+t1.c-e))) from t1) then 17 when case when 17*13 not in (t1.b,(abs(~c)/abs( -17-e)),(t1.e)) then 17 else (t1.c) end+c+t1.f not in (t1.f,19,t1.f) then  -t1.e else t1.f end FROM t1 WHERE (+13) between +b and t1.e+11}\n} {}\ndo_test randexpr-2.2577 {\n  db eval {SELECT 19+t1.d+d-t1.c*case when 11 not between e and ~c+(select min((abs(t1.b*t1.b)/abs(+t1.c-e))) from t1) then 17 when case when 17*13 not in (t1.b,(abs(~c)/abs( -17-e)),(t1.e)) then 17 else (t1.c) end+c+t1.f not in (t1.f,19,t1.f) then  -t1.e else t1.f end FROM t1 WHERE NOT ((+13) between +b and t1.e+11)}\n} {-4281}\ndo_test randexpr-2.2578 {\n  db eval {SELECT 17+d*~(abs(coalesce((select 19 | f | e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between  -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE t1.e not in (d,e,case 19 when  - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c))}\n} {}\ndo_test randexpr-2.2579 {\n  db eval {SELECT 17+d*~(abs(coalesce((select 19 | f | e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between  -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE NOT (t1.e not in (d,e,case 19 when  - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c)))}\n} {-2353302}\ndo_test randexpr-2.2580 {\n  db eval {SELECT 17+d*~(abs(coalesce((select 19 & f & e*~+((abs(e)/abs(+19))-t1.c-case 17 when t1.f then f else 19 end-17) from t1 where (e in (select ~(11) from t1 union select case when (f)>a then b when e between  -e and t1.b then 17 else t1.f end*t1.a from t1))),t1.b)*e)/abs(17))-t1.a-19 FROM t1 WHERE NOT (t1.e not in (d,e,case 19 when  - -~case when exists(select 1 from t1 where 17 not in (t1.d,t1.a,coalesce((select max(11-a) from t1 where coalesce((select +c from t1 where exists(select 1 from t1 where case when t1.f not in (19+(f),d,t1.c) then t1.c when (exists(select 1 from t1 where t1.c>19)) then 19 else f end not between a and t1.f)),t1.c)<=b),17))) then t1.d-11 else t1.b end then (d) else t1.f end-(c)))}\n} {-2353302}\ndo_test randexpr-2.2581 {\n  db eval {SELECT case a when b-coalesce((select coalesce((select max(c-(abs((19))/abs(coalesce((select t1.c+d from t1 where 17 not in (d,t1.c, -t1.e)),t1.b)-(e)))) from t1 where t1.d in (t1.e,e,t1.f)),(e)) from t1 where t1.b=t1.e or t1.b not between b and e or t1.f not between t1.b and e or c not between  -b and a),d) then 13 else 17 end FROM t1 WHERE a+17+(17) in ( -t1.a,13,coalesce((select max(e) from t1 where b+a-13<=b),e)) or e in (select abs( -+~abs(+(min(c))))+count(distinct b) from t1 union select abs(+((max(t1.c)) | min(t1.b))) from t1) and 13 not between f and 19 or not e not in ( -17,13,t1.a)}\n} {}\ndo_test randexpr-2.2582 {\n  db eval {SELECT case a when b-coalesce((select coalesce((select max(c-(abs((19))/abs(coalesce((select t1.c+d from t1 where 17 not in (d,t1.c, -t1.e)),t1.b)-(e)))) from t1 where t1.d in (t1.e,e,t1.f)),(e)) from t1 where t1.b=t1.e or t1.b not between b and e or t1.f not between t1.b and e or c not between  -b and a),d) then 13 else 17 end FROM t1 WHERE NOT (a+17+(17) in ( -t1.a,13,coalesce((select max(e) from t1 where b+a-13<=b),e)) or e in (select abs( -+~abs(+(min(c))))+count(distinct b) from t1 union select abs(+((max(t1.c)) | min(t1.b))) from t1) and 13 not between f and 19 or not e not in ( -17,13,t1.a))}\n} {17}\ndo_test randexpr-2.2583 {\n  db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c | c*13)- -+ -cast(avg(c) AS integer)-min(19)+case  -max(c) when  -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end | cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e |  -t1.a-a end FROM t1 WHERE (t1.f<=~c+f)}\n} {}\ndo_test randexpr-2.2584 {\n  db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c | c*13)- -+ -cast(avg(c) AS integer)-min(19)+case  -max(c) when  -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end | cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e |  -t1.a-a end FROM t1 WHERE NOT ((t1.f<=~c+f))}\n} {340}\ndo_test randexpr-2.2585 {\n  db eval {SELECT case when not t1.e between 17 and a then 11+ -(select ~case count(distinct +13+t1.c & c*13)- -+ -cast(avg(c) AS integer)-min(19)+case  -max(c) when  -cast(avg(b) AS integer) then max(11) else max(13) end+count(distinct t1.f) when max(( -d)) then cast(avg(t1.c) AS integer) else (min((t1.b))) end & cast(avg(t1.f) AS integer)*count(distinct 17) from t1)+b else +t1.e &  -t1.a-a end FROM t1 WHERE NOT ((t1.f<=~c+f))}\n} {-317}\ndo_test randexpr-2.2586 {\n  db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select  -~min(c) | max(t1.d) from t1 union select  -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where  -11 in (c,t1.d, -a)) or a not between  - - -(b) and b) or 13 between t1.b and f}\n} {-200}\ndo_test randexpr-2.2587 {\n  db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select  -~min(c) | max(t1.d) from t1 union select  -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE NOT (not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where  -11 in (c,t1.d, -a)) or a not between  - - -(b) and b) or 13 between t1.b and f)}\n} {}\ndo_test randexpr-2.2588 {\n  db eval {SELECT t1.f-coalesce((select max(case when b<>~t1.f then b+f else coalesce((select t1.c from t1 where case a when 19*t1.e+a then 19 else 13 end between 13 and a),t1.d)+b end) from t1 where (t1.c) in (select  -~min(c) & max(t1.d) from t1 union select  -cast(avg(t1.a) AS integer) from t1) and t1.c in (t1.a,d,11) or 11<t1.c),t1.a) FROM t1 WHERE not exists(select 1 from t1 where +case when 19+~coalesce((select max(+c*t1.c-d) from t1 where t1.f>13 and not exists(select 1 from t1 where (((t1.d<=t1.b))))),e)*b*t1.f>t1.a or not exists(select 1 from t1 where (13) not in (11,t1.b,t1.c)) then c+d else t1.e end>=t1.f) or (not exists(select 1 from t1 where  -11 in (c,t1.d, -a)) or a not between  - - -(b) and b) or 13 between t1.b and f}\n} {-200}\ndo_test randexpr-2.2589 {\n  db eval {SELECT case when ( -c=~t1.b and coalesce((select max(coalesce((select b from t1 where t1.f between case when t1.e between t1.f and 19 then (t1.b) else t1.a end and t1.f),a)) from t1 where 11=t1.f),t1.f)+t1.c=d) and a>t1.c and 19> -19 and exists(select 1 from t1 where (b=17)) and 17 between 19 and 13 then 19*case (d) when c then b else a end when t1.d not in ( -t1.a,f,13) then  -t1.f else (d) end FROM t1 WHERE 11*case when d | (abs(+t1.e-t1.e*b+(select case abs(count(*)) when count(*) then count(*) else cast(avg(t1.c) AS integer) end from t1)*17+(d)-13-11)/abs(c))-f- -t1.c-d | t1.a not between 19 and f then t1.a when t1.d in (select 11 from t1 union select d from t1) then e else e end-t1.c between 19 and c}\n} {}\ndo_test randexpr-2.2590 {\n  db eval {SELECT case when ( -c=~t1.b and coalesce((select max(coalesce((select b from t1 where t1.f between case when t1.e between t1.f and 19 then (t1.b) else t1.a end and t1.f),a)) from t1 where 11=t1.f),t1.f)+t1.c=d) and a>t1.c and 19> -19 and exists(select 1 from t1 where (b=17)) and 17 between 19 and 13 then 19*case (d) when c then b else a end when t1.d not in ( -t1.a,f,13) then  -t1.f else (d) end FROM t1 WHERE NOT (11*case when d | (abs(+t1.e-t1.e*b+(select case abs(count(*)) when count(*) then count(*) else cast(avg(t1.c) AS integer) end from t1)*17+(d)-13-11)/abs(c))-f- -t1.c-d | t1.a not between 19 and f then t1.a when t1.d in (select 11 from t1 union select d from t1) then e else e end-t1.c between 19 and c)}\n} {-600}\ndo_test randexpr-2.2591 {\n  db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case  - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then  -count(*) else  -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct  -t1.d) end | min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE  -+b>=19}\n} {}\ndo_test randexpr-2.2592 {\n  db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case  - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then  -count(*) else  -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct  -t1.d) end | min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE NOT ( -+b>=19)}\n} {100}\ndo_test randexpr-2.2593 {\n  db eval {SELECT +case when t1.a-17 in (select cast(avg(t1.a*t1.d+(abs( -t1.e)/abs(case when t1.e>t1.a or a>t1.d then t1.f when 13<11 then t1.b else c end))*t1.d) AS integer) from t1 union select count(distinct t1.a) from t1) then t1.c when d in (select +count(distinct b)-case case  - -cast(avg(d) AS integer) when case max(11) when min(17) then count(*) else (cast(avg(a) AS integer)) end then  -count(*) else  -cast(avg(17) AS integer) end when max(19) then count(distinct t1.f) else count(distinct  -t1.d) end & min(e) from t1 union select count(*) from t1) then t1.d else t1.a end FROM t1 WHERE NOT ( -+b>=19)}\n} {100}\ndo_test randexpr-2.2594 {\n  db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 | d=case when 19 between b+e+a | t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1)}\n} {200}\ndo_test randexpr-2.2595 {\n  db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 | d=case when 19 between b+e+a | t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE NOT (not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1))}\n} {}\ndo_test randexpr-2.2596 {\n  db eval {SELECT case ~(t1.f)-t1.b-t1.e*c when coalesce((select case when d*13 & d=case when 19 between b+e+a & t1.f and a+11+t1.b*(t1.f) then d else b end then t1.c when e not between 13 and 13 then 19 else a end from t1 where 13=t1.b),c) then t1.c else b end FROM t1 WHERE not t1.d in (select cast(avg(t1.e) AS integer)-~~min(coalesce((select (abs(11)/abs(11+(select count(*)+min(17)+ -cast(avg(t1.d) AS integer) from t1)*13+coalesce((select max(b) from t1 where (t1.c)<>t1.e or e<(a)),13)-d*t1.c))*t1.b from t1 where 19<=e),c))++abs(count(distinct t1.b))+~max(11)*max(11) from t1 union select +max(11) from t1)}\n} {200}\ndo_test randexpr-2.2597 {\n  db eval {SELECT t1.d+(abs(11)/abs(e*~(select  -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else  -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when  -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct  -19) end-count(distinct b) | cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13}\n} {701}\ndo_test randexpr-2.2598 {\n  db eval {SELECT t1.d+(abs(11)/abs(e*~(select  -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else  -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when  -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct  -19) end-count(distinct b) | cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE NOT (c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13)}\n} {}\ndo_test randexpr-2.2599 {\n  db eval {SELECT t1.d+(abs(11)/abs(e*~(select  -+ -case min(t1.e) when count(distinct case when (exists(select 1 from t1 where (t1.d not in (19+11,t1.e,t1.c)))) then c*b-t1.a else  -c end) then count(*)+case (cast(avg(a) AS integer))-count(distinct f) when  -(count(*)) then count(distinct e) else max(t1.b) end- -count(distinct 17)* -min(t1.c) else count(distinct  -19) end-count(distinct b) & cast(avg(19) AS integer) from t1)))-~t1.c FROM t1 WHERE c*coalesce((select e from t1 where case when exists(select 1 from t1 where not exists(select 1 from t1 where coalesce((select +b | 13 from t1 where ((17<(select (+~min(coalesce((select t1.c from t1 where case e when 13 then a else 11 end not in ( -b,t1.b,e)),(a)))) from t1)+d-19))),17) not between t1.b and t1.a)) then 11*d else t1.a end in (select c from t1 union select t1.e from t1)),t1.f) not between ( -d) and 13}\n} {701}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rbu.test",
    "content": "# 2014 September 20\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all RBU related tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nifcapable !rbu { finish_test ; return }\n\nrun_test_suite rbu\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rdonly.test",
    "content": "# 2007 April 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure SQLite treats a database\n# as readonly if its write version is set to  high.\n#\n# $Id: rdonly.test,v 1.2 2008/07/08 10:19:58 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# Create a database.\n#\ndo_test rdonly-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1;\n  }\n} {1}\n\n# EVIDENCE-OF: R-29639-16887 The sqlite3_db_readonly(D,N) interface\n# returns 1 if the database N of connection D is read-only, 0 if it is\n# read/write, or -1 if N is not the name of a database on connection D.\n#\ndo_test rdonly-1.1.1 {\n  sqlite3_db_readonly db main\n} {0}\n\n# Changes the write version from 1 to 3.  Verify that the database\n# can be read but not written.\n#\ndo_test rdonly-1.2 {\n  db close\n  hexio_get_int [hexio_read test.db 18 1]\n} 1\ndo_test rdonly-1.3 {\n  hexio_write test.db 18 03\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM t1;\n  }\n} {1}\ndo_test rdonly-1.3.1 {\n  sqlite3_db_readonly db main\n} {1}\ndo_test rdonly-1.4 {\n  catchsql {\n    INSERT INTO t1 VALUES(2)\n  }\n} {1 {attempt to write a readonly database}}\n\n# Change the write version back to 1.  Verify that the database\n# is read-write again.\n#\ndo_test rdonly-1.5 {\n  db close\n  hexio_write test.db 18 01\n  sqlite3 db test.db\n  catchsql {\n    INSERT INTO t1 VALUES(2);\n    SELECT * FROM t1;\n  }\n} {0 {1 2}}\n\n# Now, after connection [db] has loaded the database schema, modify the\n# write-version of the file (and the change-counter, so that the \n# write-version is reloaded). This way, SQLite does not discover that\n# the database is read-only until after it is locked.\n#\nset ro_version 02\nifcapable wal { set ro_version 03 }\ndo_test rdonly-1.6 {\n  hexio_write test.db 18 $ro_version     ; # write-version\n  hexio_write test.db 24 11223344        ; # change-counter\n  catchsql {\n    INSERT INTO t1 VALUES(2);\n  }\n} {1 {attempt to write a readonly database}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/regexp1.test",
    "content": "# 2012 December 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements test for the REGEXP operator in test_regexp.c.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test regexp1-1.1 {\n  load_static_extension db regexp\n  db eval {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);\n    INSERT INTO t1 VALUES(1, 'For since by man came death,');\n    INSERT INTO t1 VALUES(2, 'by man came also the resurrection of the dead.');\n    INSERT INTO t1 VALUES(3, 'For as in Adam all die,');\n    INSERT INTO t1 VALUES(4, 'even so in Christ shall all be made alive.');\n\n    SELECT x FROM t1 WHERE y REGEXP '^For ' ORDER BY x;\n  }\n} {1 3}\n\ndo_execsql_test regexp1-1.2 {\n  SELECT x FROM t1 WHERE y REGEXP 'by|in' ORDER BY x;\n} {1 2 3 4}\ndo_execsql_test regexp1-1.3 {\n  SELECT x FROM t1 WHERE y REGEXP 'by|Christ' ORDER BY x;\n} {1 2 4}\ndo_execsql_test regexp1-1.4 {\n  SELECT x FROM t1 WHERE y REGEXP 'shal+ al+' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.5 {\n  SELECT x FROM t1 WHERE y REGEXP 'shall x*y*z*all' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.6 {\n  SELECT x FROM t1 WHERE y REGEXP 'shallx?y? ?z?all' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.7 {\n  SELECT x FROM t1 WHERE y REGEXP 'r{2}' ORDER BY x;\n} {2}\ndo_execsql_test regexp1-1.8 {\n  SELECT x FROM t1 WHERE y REGEXP 'r{3}' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.9 {\n  SELECT x FROM t1 WHERE y REGEXP 'r{1}' ORDER BY x;\n} {1 2 3 4}\ndo_execsql_test regexp1-1.10 {\n  SELECT x FROM t1 WHERE y REGEXP 'ur{2,10}e' ORDER BY x;\n} {2}\ndo_execsql_test regexp1-1.11 {\n  SELECT x FROM t1 WHERE y REGEXP '[Aa]dam' ORDER BY x;\n} {3}\ndo_execsql_test regexp1-1.12 {\n  SELECT x FROM t1 WHERE y REGEXP '[^Aa]dam' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.13 {\n  SELECT x FROM t1 WHERE y REGEXP '[^b-zB-Z]dam' ORDER BY x;\n} {3}\ndo_execsql_test regexp1-1.14 {\n  SELECT x FROM t1 WHERE y REGEXP 'alive' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.15 {\n  SELECT x FROM t1 WHERE y REGEXP '^alive' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.16 {\n  SELECT x FROM t1 WHERE y REGEXP 'alive$' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.17 {\n  SELECT x FROM t1 WHERE y REGEXP 'alive.$' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.18 {\n  SELECT x FROM t1 WHERE y REGEXP 'alive\\.$' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.19 {\n  SELECT x FROM t1 WHERE y REGEXP 'ma[nd]' ORDER BY x;\n} {1 2 4}\ndo_execsql_test regexp1-1.20 {\n  SELECT x FROM t1 WHERE y REGEXP '\\bma[nd]' ORDER BY x;\n} {1 2 4}\ndo_execsql_test regexp1-1.21 {\n  SELECT x FROM t1 WHERE y REGEXP 'ma[nd]\\b' ORDER BY x;\n} {1 2}\ndo_execsql_test regexp1-1.22 {\n  SELECT x FROM t1 WHERE y REGEXP 'ma\\w' ORDER BY x;\n} {1 2 4}\ndo_execsql_test regexp1-1.23 {\n  SELECT x FROM t1 WHERE y REGEXP 'ma\\W' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.24 {\n  SELECT x FROM t1 WHERE y REGEXP '\\sma\\w' ORDER BY x;\n} {1 2 4}\ndo_execsql_test regexp1-1.25 {\n  SELECT x FROM t1 WHERE y REGEXP '\\Sma\\w' ORDER BY x;\n} {}\ndo_execsql_test regexp1-1.26 {\n  SELECT x FROM t1 WHERE y REGEXP 'alive\\S$' ORDER BY x;\n} {4}\ndo_execsql_test regexp1-1.27 {\n  SELECT x FROM t1 WHERE y REGEXP\n          '\\b(unto|us|son|given|his|name|called|' ||\n          'wonderful|councelor|mighty|god|everlasting|father|' ||\n          'prince|peace|alive)\\b';\n} {4}\n\ndo_execsql_test regexp1-2.1 {\n  SELECT 'aaaabbbbcccc' REGEXP 'ab*c', \n         'aaaacccc' REGEXP 'ab*c';\n} {1 1}\ndo_execsql_test regexp1-2.2 {\n  SELECT 'aaaabbbbcccc' REGEXP 'ab+c',\n         'aaaacccc' REGEXP 'ab+c';\n} {1 0}\ndo_execsql_test regexp1-2.3 {\n  SELECT 'aaaabbbbcccc' REGEXP 'ab?c',\n         'aaaacccc' REGEXP 'ab?c';\n} {0 1}\ndo_execsql_test regexp1-2.4 {\n  SELECT 'aaaabbbbbbcccc' REGEXP 'ab{3,5}c',\n         'aaaabbbbbcccc' REGEXP 'ab{3,5}c',\n         'aaaabbbbcccc' REGEXP 'ab{3,5}c',\n         'aaaabbbcccc' REGEXP 'ab{3,5}c',\n         'aaaabbcccc' REGEXP 'ab{3,5}c',\n         'aaaabcccc' REGEXP 'ab{3,5}c'\n} {0 1 1 1 0 0}\ndo_execsql_test regexp1-2.5 {\n  SELECT 'aaaabbbbcccc' REGEXP 'a(a|b|c)+c',\n         'aaaabbbbcccc' REGEXP '^a(a|b|c){11}c$',\n         'aaaabbbbcccc' REGEXP '^a(a|b|c){10}c$',\n         'aaaabbbbcccc' REGEXP '^a(a|b|c){9}c$'\n} {1 0 1 0}\ndo_execsql_test regexp1-2.6 {\n  SELECT 'aaaabbbbcccc' REGEXP '^a(a|bb|c)+c$',\n         'aaaabbbbcccc' REGEXP '^a(a|bbb|c)+c$',\n         'aaaabbbbcccc' REGEXP '^a(a|bbbb|c)+c$'\n} {1 0 1}\ndo_execsql_test regexp1-2.7 {\n  SELECT 'aaaabbbbcccc' REGEXP '^a([ac]+|bb){3}c$',\n         'aaaabbbbcccc' REGEXP '^a([ac]+|bb){4}c$',\n         'aaaabbbbcccc' REGEXP '^a([ac]+|bb){5}c$'\n} {0 1 1}\n\ndo_execsql_test regexp1-2.8 {\n  SELECT 'abc*def+ghi.jkl[mno]pqr' REGEXP 'c.d',\n         'abc*def+ghi.jkl[mno]pqr' REGEXP 'c\\*d',\n         'abc*def+ghi.jkl[mno]pqr' REGEXP 'f\\+g',\n         'abc*def+ghi.jkl[mno]pqr' REGEXP 'i\\.j',\n         'abc*def+ghi.jkl[mno]pqr' REGEXP 'l\\[mno\\]p'\n} {1 1 1 1 1}\n\ndo_test regexp1-2.9 {\n  set v1 \"abc\\ndef\"\n  db eval {SELECT $v1 REGEXP '^abc\\ndef$'}\n} {1}\ndo_test regexp1-2.10 {\n  set v1 \"abc\\adef\"\n  db eval {SELECT $v1 REGEXP '^abc\\adef$'}\n} {1}\ndo_test regexp1-2.11 {\n  set v1 \"abc\\tdef\"\n  db eval {SELECT $v1 REGEXP '^abc\\tdef$'}\n} {1}\ndo_test regexp1-2.12 {\n  set v1 \"abc\\rdef\"\n  db eval {SELECT $v1 REGEXP '^abc\\rdef$'}\n} {1}\ndo_test regexp1-2.13 {\n  set v1 \"abc\\fdef\"\n  db eval {SELECT $v1 REGEXP '^abc\\fdef$'}\n} {1}\ndo_test regexp1-2.14 {\n  set v1 \"abc\\vdef\"\n  db eval {SELECT $v1 REGEXP '^abc\\vdef$'}\n} {1}\ndo_execsql_test regexp1-2.15 {\n  SELECT 'abc\\def' REGEXP '^abc\\\\def',\n         'abc(def' REGEXP '^abc\\(def',\n         'abc)def' REGEXP '^abc\\)def',\n         'abc*def' REGEXP '^abc\\*def',\n         'abc.def' REGEXP '^abc\\.def',\n         'abc+def' REGEXP '^abc\\+def',\n         'abc?def' REGEXP '^abc\\?def',\n         'abc[def' REGEXP '^abc\\[def',\n         'abc$def' REGEXP '^abc\\$',\n         '^def'    REGEXP '\\^def',\n         'abc{4}x' REGEXP '^abc\\{4\\}x$',\n         'abc|def' REGEXP '^abc\\|def$'\n} {1 1 1 1 1 1 1 1 1 1 1 1}\n\ndo_execsql_test regexp1-2.20 {\n  SELECT 'abc$¢€xyz' REGEXP '^abc\\u0024\\u00a2\\u20acxyz$',\n         'abc$¢€xyz' REGEXP '^abc\\u0024\\u00A2\\u20ACxyz$',\n         'abc$¢€xyz' REGEXP '^abc\\x24\\xa2\\u20acxyz$'\n} {1 1 1}\ndo_execsql_test regexp1-2.21 {\n  SELECT 'abc$¢€xyz' REGEXP '^abc[\\u0024][\\u00a2][\\u20ac]xyz$',\n         'abc$¢€xyz' REGEXP '^abc[\\u0024\\u00A2\\u20AC]{3}xyz$',\n         'abc$¢€xyz' REGEXP '^abc[\\x24][\\xa2\\u20ac]+xyz$'\n} {1 1 1}\ndo_execsql_test regexp1-2.22 {\n  SELECT 'abc$¢€xyz' REGEXP '^abc[^\\u0025-X][^ -\\u007f][^\\u20ab]xyz$'\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/regexp2.test",
    "content": "# 2016 February 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests for the REGEXP operator in ext/misc/regexp.c.\n# It focuses on the use of the sqlite3_set_auxdata()/get_auxdata() APIs.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix regexp2\n\nload_static_extension db regexp\n\n#-------------------------------------------------------------------------\n# Test that triggers do not become confused and use aux-data created by\n# a different trigger for a different REGEXP invocation.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE x1(x, y, z);\n  CREATE TABLE x2(x, y, z);\n\n  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n    INSERT INTO x1 VALUES(\n        new.a REGEXP 'abc',\n        new.b REGEXP 'abc',\n        new.c REGEXP 'abc'\n    );\n  END;\n\n  CREATE TRIGGER tr2 AFTER INSERT ON t1 BEGIN\n    INSERT INTO x2 VALUES(\n        new.a REGEXP 'def',\n        new.b REGEXP 'def',\n        new.c REGEXP 'def'\n    );\n  END;\n\n  INSERT INTO t1 VALUES('abc', 'def', 'abc');\n  SELECT * FROM t1;\n} {abc def abc}\n\ndo_execsql_test 1.1 { SELECT * FROM x1 } {1 0 1}\ndo_execsql_test 1.2 { SELECT * FROM x2 } {0 1 0}\n\n#-------------------------------------------------------------------------\n# Test that if an exception is thrown several triggers deep, all aux-data\n# objects are cleaned up correctly.\n#\nproc sql_error {} {\n  error \"SQL error!\"\n}\ndb func error sql_error\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a, b);\n  CREATE TABLE t3(c, d);\n  CREATE TABLE t4(e, f);\n\n  CREATE TRIGGER t2_tr1 AFTER UPDATE ON t2 BEGIN\n    UPDATE t3 SET d = new.b WHERE c = old.a;\n  END;\n\n  CREATE TRIGGER t3_tr1 AFTER UPDATE ON t3 BEGIN\n    UPDATE t4 SET f = new.d WHERE e = old.c AND new.d REGEXP 'a.*';\n  END;\n\n  CREATE TRIGGER t4_tr1 AFTER UPDATE ON t4 BEGIN\n    SELECT CASE WHEN new.f REGEXP '.*y.*' THEN error() ELSE 1 END;\n  END;\n\n  INSERT INTO t2 VALUES(1, 'a_x_1');\n  INSERT INTO t2 VALUES(2, 'a_y_1');\n\n  INSERT INTO t3 VALUES(1, 'b1');\n  INSERT INTO t3 VALUES(2, 'b2');\n\n  INSERT INTO t4 VALUES(1, 'b1');\n  INSERT INTO t4 VALUES(2, 'b2');\n} {}\n\ndo_catchsql_test 2.1 {\n  UPDATE t2 SET a=a+1 WHERE b REGEXP 'a.*' AND b REGEXP '.*1';\n} {1 {SQL error!}}\n\n# Test that the triggers used in the test above work as expected.\n#\ndo_execsql_test 2.2 {\n  UPDATE t2 SET b = 'a_abc_1';\n} {}\ndo_execsql_test 2.3 {\n  SELECT * FROM t2;\n  SELECT * FROM t3;\n  SELECT * FROM t4;\n} {1 a_abc_1 2 a_abc_1 1 a_abc_1 2 a_abc_1 1 a_abc_1 2 a_abc_1}\n\n#-------------------------------------------------------------------------\n# Test that trigger parameters (i.e. new.* and old.*) refs are not \n# considered to be constant across separate invocations of the trigger.\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE t5(a);\n  CREATE TABLE t6(x);\n\n  CREATE TRIGGER t5tr AFTER DELETE ON t5 BEGIN\n    DELETE FROM t6 WHERE t6.x REGEXP old.a;\n  END;\n\n  INSERT INTO t5 VALUES ('^a.*'), ('^b.*'), ('^c.*');\n  INSERT INTO t6 VALUES ('eab'), ('abc'), ('bcd'), ('cde'), ('dea');\n\n  DELETE FROM t5;\n  SELECT * FROM t6;\n} {eab dea}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/reindex.test",
    "content": "# 2004 November 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# This file implements tests for the REINDEX command.\n#\n# $Id: reindex.test,v 1.4 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# There is nothing to test if REINDEX is disable for this build.\n#\nifcapable {!reindex} {\n  finish_test\n  return\n}\n\n# Basic sanity checks.\n#\ndo_test reindex-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    CREATE INDEX i1 ON t1(a);\n    REINDEX;\n  }\n} {}\nintegrity_check reindex-1.2\ndo_test reindex-1.3 {\n  execsql {\n    REINDEX t1;\n  }\n} {}\nintegrity_check reindex-1.4\ndo_test reindex-1.5 {\n  execsql {\n    REINDEX i1;\n  }\n} {}\nintegrity_check reindex-1.6\ndo_test reindex-1.7 {\n  execsql {\n    REINDEX main.t1;\n  }\n} {}\ndo_test reindex-1.8 {\n  execsql {\n    REINDEX main.i1;\n  }\n} {}\ndo_test reindex-1.9 {\n  catchsql {\n    REINDEX bogus\n  }\n} {1 {unable to identify the object to be reindexed}}\n\n# Set up a table for testing that includes several different collating\n# sequences including some that we can modify.\n#\ndo_test reindex-2.1 {\n  proc c1 {a b} {\n    return [expr {-[string compare $a $b]}]\n  }\n  proc c2 {a b} {\n    return [expr {-[string compare [string tolower $a] [string tolower $b]]}]\n  }\n  db collate c1 c1\n  db collate c2 c2\n  execsql {\n    CREATE TABLE t2(\n      a TEXT PRIMARY KEY COLLATE c1,\n      b TEXT UNIQUE COLLATE c2,\n      c TEXT COLLATE nocase,\n      d TEST COLLATE binary\n    );\n    INSERT INTO t2 VALUES('abc','abc','abc','abc');\n    INSERT INTO t2 VALUES('ABCD','ABCD','ABCD','ABCD');\n    INSERT INTO t2 VALUES('bcd','bcd','bcd','bcd');\n    INSERT INTO t2 VALUES('BCDE','BCDE','BCDE','BCDE');\n    SELECT a FROM t2 ORDER BY a;\n  }\n} {bcd abc BCDE ABCD}\ndo_test reindex-2.2 {\n  execsql {\n    SELECT b FROM t2 ORDER BY b;\n  }\n} {BCDE bcd ABCD abc}\ndo_test reindex-2.3 {\n  execsql {\n    SELECT c FROM t2 ORDER BY c;\n  }\n} {abc ABCD bcd BCDE}\ndo_test reindex-2.4 {\n  execsql {\n    SELECT d FROM t2 ORDER BY d;\n  }\n} {ABCD BCDE abc bcd}\n\n# Change a collating sequence function.  Verify that REINDEX rebuilds\n# the index.\n#\ndo_test reindex-2.5 {\n  proc c1 {a b} {\n    return [string compare $a $b]\n  }\n  execsql {\n    SELECT a FROM t2 ORDER BY a;\n  }\n} {bcd abc BCDE ABCD}\nifcapable {integrityck} {\n  do_test reindex-2.5.1 {\n    string equal ok [execsql {PRAGMA integrity_check}]\n  } {0}\n}\ndo_test reindex-2.6 {\n  execsql {\n    REINDEX c2;\n    SELECT a FROM t2 ORDER BY a;\n  }\n} {bcd abc BCDE ABCD}\ndo_test reindex-2.7 {\n  execsql {\n    REINDEX t1;\n    SELECT a FROM t2 ORDER BY a;\n  }\n} {bcd abc BCDE ABCD}\ndo_test reindex-2.8 {\n  execsql {\n    REINDEX c1;\n    SELECT a FROM t2 ORDER BY a;\n  }\n} {ABCD BCDE abc bcd}\nintegrity_check reindex-2.8.1\n\n# Try to REINDEX an index for which the collation sequence is not available.\n#\ndo_test reindex-3.1 {\n  sqlite3 db2 test.db\n  catchsql {\n    REINDEX c1;\n  } db2\n} {1 {no such collation sequence: c1}}\ndo_test reindex-3.2 {\n  proc need_collate {collation} {\n    db2 collate c1 c1\n  }\n  db2 collation_needed need_collate\n  catchsql {\n    REINDEX c1;\n  } db2\n} {0 {}}\ndo_test reindex-3.3 {\n  catchsql {\n    REINDEX;\n  } db2\n} {1 {no such collation sequence: c2}}\n\ndo_test reindex-3.99 {\n  db2 close\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/releasetest.tcl",
    "content": "#!/usr/bin/tclsh\n#\n# Documentation for this script. This may be output to stderr\n# if the script is invoked incorrectly. See the [process_options]\n# proc below.\n#\nset ::USAGE_MESSAGE {\nThis Tcl script is used to test the various configurations required\nbefore releasing a new version. Supported command line options (all\noptional) are:\n\n    --buildonly                        (Just build testfixture - do not run)\n    --config   CONFIGNAME              (Run only CONFIGNAME)\n    --dryrun                           (Print what would have happened)\n    -f|--force                         (Run even if uncommitted changes)\n    --info                             (Show diagnostic info)\n    --jobs     N                       (Use N processes - default 1)\n    --keep                             (Delete no files after each test run)\n    --msvc                             (Use MSVC as the compiler)\n    --platform PLATFORM                (see below)\n    --progress                         (Show progress messages)\n    --quick                            (Run \"veryquick.test\" only)\n    --veryquick                        (Run \"make smoketest\" only)\n    --with-tcl=DIR                     (Use TCL build at DIR)\n\nThe script determines the default value for --platform using the\n$tcl_platform(os) and $tcl_platform(machine) variables.  Supported\nplatforms are \"Linux-x86\", \"Linux-x86_64\", \"Darwin-i386\",\n\"Darwin-x86_64\", \"Windows NT-intel\", and \"Windows NT-amd64\".\n\nEvery test begins with a fresh run of the configure script at the top\nof the SQLite source tree.\n}\n\n# Return a timestamp of the form HH:MM:SS\n#\nproc now {} {\n  return [clock format [clock seconds] -format %H:%M:%S]\n}\n\n# Omit comments (text between # and \\n) in a long multi-line string.\n#\nproc strip_comments {in} {\n  regsub -all {#[^\\n]*\\n} $in {} out\n  return $out\n}\n\narray set ::Configs [strip_comments {\n  \"Default\" {\n    -O2\n    --disable-amalgamation --disable-shared\n    --enable-session\n  }\n  \"Sanitize\" {\n    CC=clang -fsanitize=undefined\n    -DSQLITE_ENABLE_STAT4\n    --enable-session\n  }\n  \"Stdcall\" {\n    -DUSE_STDCALL=1\n    -O2\n  }\n  \"Have-Not\" {\n    # The \"Have-Not\" configuration sets all possible -UHAVE_feature options\n    # in order to verify that the code works even on platforms that lack\n    # these support services.\n    -DHAVE_FDATASYNC=0\n    -DHAVE_GMTIME_R=0\n    -DHAVE_ISNAN=0\n    -DHAVE_LOCALTIME_R=0\n    -DHAVE_LOCALTIME_S=0\n    -DHAVE_MALLOC_USABLE_SIZE=0\n    -DHAVE_STRCHRNUL=0\n    -DHAVE_USLEEP=0\n    -DHAVE_UTIME=0\n  }\n  \"Unlock-Notify\" {\n    -O2\n    -DSQLITE_ENABLE_UNLOCK_NOTIFY\n    -DSQLITE_THREADSAFE\n    -DSQLITE_TCL_DEFAULT_FULLMUTEX=1\n  }\n  \"Secure-Delete\" {\n    -O2\n    -DSQLITE_SECURE_DELETE=1\n    -DSQLITE_SOUNDEX=1\n  }\n  \"Update-Delete-Limit\" {\n    -O2\n    -DSQLITE_DEFAULT_FILE_FORMAT=4\n    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1\n    -DSQLITE_ENABLE_STMT_SCANSTATUS\n    -DSQLITE_LIKE_DOESNT_MATCH_BLOBS\n    -DSQLITE_ENABLE_CURSOR_HINTS\n    --enable-json1\n  }\n  \"Check-Symbols\" {\n    -DSQLITE_MEMDEBUG=1\n    -DSQLITE_ENABLE_FTS3_PARENTHESIS=1\n    -DSQLITE_ENABLE_FTS3=1\n    -DSQLITE_ENABLE_RTREE=1\n    -DSQLITE_ENABLE_MEMSYS5=1\n    -DSQLITE_ENABLE_MEMSYS3=1\n    -DSQLITE_ENABLE_COLUMN_METADATA=1\n    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1\n    -DSQLITE_SECURE_DELETE=1\n    -DSQLITE_SOUNDEX=1\n    -DSQLITE_ENABLE_ATOMIC_WRITE=1\n    -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1\n    -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1\n    -DSQLITE_ENABLE_STAT4\n    -DSQLITE_ENABLE_STMT_SCANSTATUS\n    --enable-json1 --enable-fts5 --enable-session\n  }\n  \"Debug-One\" {\n    --disable-shared\n    -O2 -funsigned-char\n    -DSQLITE_DEBUG=1\n    -DSQLITE_MEMDEBUG=1\n    -DSQLITE_MUTEX_NOOP=1\n    -DSQLITE_TCL_DEFAULT_FULLMUTEX=1\n    -DSQLITE_ENABLE_FTS3=1\n    -DSQLITE_ENABLE_RTREE=1\n    -DSQLITE_ENABLE_MEMSYS5=1\n    -DSQLITE_ENABLE_COLUMN_METADATA=1\n    -DSQLITE_ENABLE_STAT4\n    -DSQLITE_ENABLE_HIDDEN_COLUMNS\n    -DSQLITE_MAX_ATTACHED=125\n    -DSQLITE_MUTATION_TEST\n  }\n  \"Fast-One\" {\n    -O6\n    -DSQLITE_ENABLE_FTS4=1\n    -DSQLITE_ENABLE_RTREE=1\n    -DSQLITE_ENABLE_STAT4\n    -DSQLITE_ENABLE_RBU\n    -DSQLITE_MAX_ATTACHED=125\n    -DLONGDOUBLE_TYPE=double\n    --enable-session\n  }\n  \"Device-One\" {\n    -O2\n    -DSQLITE_DEBUG=1\n    -DSQLITE_DEFAULT_AUTOVACUUM=1\n    -DSQLITE_DEFAULT_CACHE_SIZE=64\n    -DSQLITE_DEFAULT_PAGE_SIZE=1024\n    -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=32\n    -DSQLITE_DISABLE_LFS=1\n    -DSQLITE_ENABLE_ATOMIC_WRITE=1\n    -DSQLITE_ENABLE_IOTRACE=1\n    -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1\n    -DSQLITE_MAX_PAGE_SIZE=4096\n    -DSQLITE_OMIT_LOAD_EXTENSION=1\n    -DSQLITE_OMIT_PROGRESS_CALLBACK=1\n    -DSQLITE_OMIT_VIRTUALTABLE=1\n    -DSQLITE_ENABLE_HIDDEN_COLUMNS\n    -DSQLITE_TEMP_STORE=3\n    --enable-json1\n  }\n  \"Device-Two\" {\n    -DSQLITE_4_BYTE_ALIGNED_MALLOC=1\n    -DSQLITE_DEFAULT_AUTOVACUUM=1\n    -DSQLITE_DEFAULT_CACHE_SIZE=1000\n    -DSQLITE_DEFAULT_LOCKING_MODE=0\n    -DSQLITE_DEFAULT_PAGE_SIZE=1024\n    -DSQLITE_DEFAULT_TEMP_CACHE_SIZE=1000\n    -DSQLITE_DISABLE_LFS=1\n    -DSQLITE_ENABLE_FTS3=1\n    -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1\n    -DSQLITE_ENABLE_RTREE=1\n    -DSQLITE_MAX_COMPOUND_SELECT=50\n    -DSQLITE_MAX_PAGE_SIZE=32768\n    -DSQLITE_OMIT_TRACE=1\n    -DSQLITE_TEMP_STORE=3\n    -DSQLITE_THREADSAFE=2\n    --enable-json1 --enable-fts5 --enable-session\n  }\n  \"Locking-Style\" {\n    -O2\n    -DSQLITE_ENABLE_LOCKING_STYLE=1\n  }\n  \"Apple\" {\n    -Os\n    -DHAVE_GMTIME_R=1\n    -DHAVE_ISNAN=1\n    -DHAVE_LOCALTIME_R=1\n    -DHAVE_PREAD=1\n    -DHAVE_PWRITE=1\n    -DHAVE_USLEEP=1\n    -DHAVE_USLEEP=1\n    -DHAVE_UTIME=1\n    -DSQLITE_DEFAULT_CACHE_SIZE=1000\n    -DSQLITE_DEFAULT_CKPTFULLFSYNC=1\n    -DSQLITE_DEFAULT_MEMSTATUS=1\n    -DSQLITE_DEFAULT_PAGE_SIZE=1024\n    -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS=1\n    -DSQLITE_ENABLE_API_ARMOR=1\n    -DSQLITE_ENABLE_AUTO_PROFILE=1\n    -DSQLITE_ENABLE_FLOCKTIMEOUT=1\n    -DSQLITE_ENABLE_FTS3=1\n    -DSQLITE_ENABLE_FTS3_PARENTHESIS=1\n    -DSQLITE_ENABLE_FTS3_TOKENIZER=1\n    if:os==\"Darwin\" -DSQLITE_ENABLE_LOCKING_STYLE=1\n    -DSQLITE_ENABLE_PERSIST_WAL=1\n    -DSQLITE_ENABLE_PURGEABLE_PCACHE=1\n    -DSQLITE_ENABLE_RTREE=1\n    -DSQLITE_ENABLE_SNAPSHOT=1\n    # -DSQLITE_ENABLE_SQLLOG=1\n    -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1\n    -DSQLITE_MAX_LENGTH=2147483645\n    -DSQLITE_MAX_VARIABLE_NUMBER=500000\n    # -DSQLITE_MEMDEBUG=1\n    -DSQLITE_NO_SYNC=1\n    -DSQLITE_OMIT_AUTORESET=1\n    -DSQLITE_OMIT_LOAD_EXTENSION=1\n    -DSQLITE_PREFER_PROXY_LOCKING=1\n    -DSQLITE_SERIES_CONSTRAINT_VERIFY=1\n    -DSQLITE_THREADSAFE=2\n    -DSQLITE_USE_URI=1\n    -DSQLITE_WRITE_WALFRAME_PREBUFFERED=1\n    -DUSE_GUARDED_FD=1\n    -DUSE_PREAD=1\n    --enable-json1 --enable-fts5\n  }\n  \"Extra-Robustness\" {\n    -DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1\n    -DSQLITE_MAX_ATTACHED=62\n  }\n  \"Devkit\" {\n    -DSQLITE_DEFAULT_FILE_FORMAT=4\n    -DSQLITE_MAX_ATTACHED=30\n    -DSQLITE_ENABLE_COLUMN_METADATA\n    -DSQLITE_ENABLE_FTS4\n    -DSQLITE_ENABLE_FTS5\n    -DSQLITE_ENABLE_FTS4_PARENTHESIS\n    -DSQLITE_DISABLE_FTS4_DEFERRED\n    -DSQLITE_ENABLE_RTREE\n    --enable-json1 --enable-fts5\n  }\n  \"No-lookaside\" {\n    -DSQLITE_TEST_REALLOC_STRESS=1\n    -DSQLITE_OMIT_LOOKASIDE=1\n    -DHAVE_USLEEP=1\n  }\n  \"Valgrind\" {\n    -DSQLITE_ENABLE_STAT4\n    -DSQLITE_ENABLE_FTS4\n    -DSQLITE_ENABLE_RTREE\n    -DSQLITE_ENABLE_HIDDEN_COLUMNS\n    --enable-json1\n  }\n\n  # The next group of configurations are used only by the\n  # Failure-Detection platform.  They are all the same, but we need\n  # different names for them all so that they results appear in separate\n  # subdirectories.\n  #\n  Fail0 {-O0}\n  Fail2 {-O0}\n  Fail3 {-O0}\n  Fail4 {-O0}\n  FuzzFail1 {-O0}\n  FuzzFail2 {-O0}\n}]\n\narray set ::Platforms [strip_comments {\n  Linux-x86_64 {\n    \"Check-Symbols\"           checksymbols\n    \"Fast-One\"                fuzztest\n    \"Debug-One\"               \"mptest test\"\n    \"Have-Not\"                test\n    \"Secure-Delete\"           test\n    \"Unlock-Notify\"           \"QUICKTEST_INCLUDE=notify2.test test\"\n    \"Update-Delete-Limit\"     test\n    \"Extra-Robustness\"        test\n    \"Device-Two\"              test\n    \"No-lookaside\"            test\n    \"Devkit\"                  test\n    \"Apple\"                   test\n    \"Sanitize\"                {QUICKTEST_OMIT=func4.test,nan.test test}\n    \"Device-One\"              fulltest\n    \"Default\"                 \"threadtest fulltest\"\n    \"Valgrind\"                valgrindtest\n  }\n  Linux-i686 {\n    \"Devkit\"                  test\n    \"Have-Not\"                test\n    \"Unlock-Notify\"           \"QUICKTEST_INCLUDE=notify2.test test\"\n    \"Device-One\"              test\n    \"Device-Two\"              test\n    \"Default\"                 \"threadtest fulltest\"\n  }\n  Darwin-i386 {\n    \"Locking-Style\"           \"mptest test\"\n    \"Have-Not\"                test\n    \"Apple\"                   \"threadtest fulltest\"\n  }\n  Darwin-x86_64 {\n    \"Locking-Style\"           \"mptest test\"\n    \"Have-Not\"                test\n    \"Apple\"                   \"threadtest fulltest\"\n  }\n  \"Windows NT-intel\" {\n    \"Stdcall\"                 test\n    \"Have-Not\"                test\n    \"Default\"                 \"mptest fulltestonly\"\n  }\n  \"Windows NT-amd64\" {\n    \"Stdcall\"                 test\n    \"Have-Not\"                test\n    \"Default\"                 \"mptest fulltestonly\"\n  }\n\n  # The Failure-Detection platform runs various tests that deliberately\n  # fail.  This is used as a test of this script to verify that this script\n  # correctly identifies failures.\n  #\n  Failure-Detection {\n    Fail0     \"TEST_FAILURE=0 test\"\n    Sanitize  \"TEST_FAILURE=1 test\"\n    Fail2     \"TEST_FAILURE=2 valgrindtest\"\n    Fail3     \"TEST_FAILURE=3 valgrindtest\"\n    Fail4     \"TEST_FAILURE=4 test\"\n    FuzzFail1 \"TEST_FAILURE=5 test\"\n    FuzzFail2 \"TEST_FAILURE=5 valgrindtest\"\n  }\n}]\n\n\n# End of configuration section.\n#########################################################################\n#########################################################################\n\n# Configuration verification: Check that each entry in the list of configs\n# specified for each platforms exists.\n#\nforeach {key value} [array get ::Platforms] {\n  foreach {v t} $value {\n    if {0==[info exists ::Configs($v)]} {\n      puts stderr \"No such configuration: \\\"$v\\\"\"\n      exit -1\n    }\n  }\n}\n\n# Output log.   Disabled for slave interpreters.\n#\nif {[lindex $argv end]!=\"--slave\"} {\n  set LOG [open releasetest-out.txt w]\n  proc PUTS {txt} {\n    puts $txt\n    puts $::LOG $txt\n    flush $::LOG\n  }\n  proc PUTSNNL {txt} {\n    puts -nonewline $txt\n    puts -nonewline $::LOG $txt\n    flush $::LOG\n  }\n  proc PUTSERR {txt} {\n    puts stderr $txt\n    puts $::LOG $txt\n    flush $::LOG\n  }\n  puts $LOG \"$argv0 $argv\"\n  set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]\n  puts $LOG \"start-time: $tm0 UTC\"\n} else {\n  proc PUTS {txt} {\n    puts $txt\n  }\n  proc PUTSNNL {txt} {\n    puts -nonewline $txt\n  }\n  proc PUTSERR {txt} {\n    puts stderr $txt\n  }\n}\n\n# Open the file $logfile and look for a report on the number of errors\n# and the number of test cases run.  Add these values to the global\n# $::NERRCASE and $::NTESTCASE variables.\n#\n# If any errors occur, then write into $errmsgVar the text of an appropriate\n# one-line error message to show on the output.\n#\nproc count_tests_and_errors {logfile rcVar errmsgVar} {\n  if {$::DRYRUN} return\n  upvar 1 $rcVar rc $errmsgVar errmsg\n  set fd [open $logfile rb]\n  set seen 0\n  while {![eof $fd]} {\n    set line [gets $fd]\n    if {[regexp {(\\d+) errors out of (\\d+) tests} $line all nerr ntest]} {\n      incr ::NERRCASE $nerr\n      incr ::NTESTCASE $ntest\n      set seen 1\n      if {$nerr>0} {\n        set rc 1\n        set errmsg $line\n      }\n    }\n    if {[regexp {runtime error: +(.*)} $line all msg]} {\n      # skip over \"value is outside range\" errors\n      if {[regexp {value .* is outside the range of representable} $line]} {\n         # noop\n      } else {\n        incr ::NERRCASE\n        if {$rc==0} {\n          set rc 1\n          set errmsg $msg\n        }\n      }\n    }\n    if {[regexp {fatal error +(.*)} $line all msg]} {\n      incr ::NERRCASE\n      if {$rc==0} {\n        set rc 1\n        set errmsg $msg\n      }\n    }\n    if {[regexp {ERROR SUMMARY: (\\d+) errors.*} $line all cnt] && $cnt>0} {\n      incr ::NERRCASE\n      if {$rc==0} {\n        set rc 1\n        set errmsg $all\n      }\n    }\n    if {[regexp {^VERSION: 3\\.\\d+.\\d+} $line]} {\n      set v [string range $line 9 end]\n      if {$::SQLITE_VERSION eq \"\"} {\n        set ::SQLITE_VERSION $v\n      } elseif {$::SQLITE_VERSION ne $v} {\n        set rc 1\n        set errmsg \"version conflict: {$::SQLITE_VERSION} vs. {$v}\"\n      }\n    }\n  }\n  close $fd\n  if {$::BUILDONLY} {\n    incr ::NTESTCASE\n    if {$rc!=0} {\n      set errmsg \"Build failed\"\n    }\n  } elseif {!$seen} {\n    set rc 1\n    set errmsg \"Test did not complete\"\n    if {[file readable core]} {\n      append errmsg \" - core file exists\"\n    }\n  }\n}\n\n#--------------------------------------------------------------------------\n# This command is invoked as the [main] routine for scripts run with the\n# \"--slave\" option.\n#\n# For each test (i.e. \"configure && make test\" execution), the master\n# process spawns a process with the --slave option. It writes two lines\n# to the slaves stdin. The first contains a single boolean value - the\n# value of ::TRACE to use in the slave script. The second line contains a\n# list in the same format as each element of the list passed to the\n# [run_all_test_suites] command in the master process.\n#\n# The slave then runs the \"configure && make test\" commands specified. It\n# exits successfully if the tests passes, or with a non-zero error code\n# otherwise.\n#\nproc run_slave_test {} {\n  # Read global vars configuration from stdin.\n  set V [gets stdin]\n  foreach {::TRACE ::MSVC ::DRYRUN ::KEEPFILES} $V {}\n\n  # Read the test-suite configuration from stdin.\n  set T [gets stdin]\n  foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}\n\n  # Create and switch to the test directory.\n  set normaldir [file normalize $dir]\n  set ::env(SQLITE_TMPDIR) $normaldir\n  trace_cmd file mkdir $dir\n  trace_cmd cd $dir\n  catch {file delete core}\n  catch {file delete test.log}\n\n  # Run the \"./configure && make\" commands.\n  set rc 0\n  set rc [catch [configureCommand $configOpts]]\n  if {!$rc} {\n    if {[info exists ::env(TCLSH_CMD)]} {\n      set savedEnv(TCLSH_CMD) $::env(TCLSH_CMD)\n    } else {\n      unset -nocomplain savedEnv(TCLSH_CMD)\n    }\n    set ::env(TCLSH_CMD) [file nativename [info nameofexecutable]]\n    set rc [catch [makeCommand $testtarget $makeOpts $cflags $opts]]\n    if {[info exists savedEnv(TCLSH_CMD)]} {\n      set ::env(TCLSH_CMD) $savedEnv(TCLSH_CMD)\n    } else {\n      unset -nocomplain ::env(TCLSH_CMD)\n    }\n  }\n\n  # Clean up lots of extra files if --keep was not specified.\n  if {$::KEEPFILES==0} { cleanup $normaldir }\n\n  # Exis successfully if the test passed, or with a non-zero error code\n  # otherwise.\n  exit $rc\n}\n\n# This command is invoked in the master process each time a slave\n# file-descriptor is readable.\n#\nproc slave_fileevent {fd T tm1} {\n  global G\n  foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}\n\n  if {[eof $fd]} {\n    fconfigure $fd -blocking 1\n    set rc [catch { close $fd }]\n\n    set errmsg {}\n    set logfile [file join $dir test.log]\n    if {[file exists $logfile]} {\n      count_tests_and_errors [file join $dir test.log] rc errmsg\n    } elseif {$rc==0 && !$::DRYRUN} {\n      set rc 1\n      set errmsg \"no test.log file...\"\n    }\n\n    if {!$::TRACE} {\n      set tm2 [clock seconds]\n      set hours [expr {($tm2-$tm1)/3600}]\n      set minutes [expr {(($tm2-$tm1)/60)%60}]\n      set seconds [expr {($tm2-$tm1)%60}]\n      set tm [format (%02d:%02d:%02d) $hours $minutes $seconds]\n\n      if {$rc} {\n        set status FAIL\n        incr ::NERR\n      } else {\n        set status Ok\n      }\n\n      set n [string length $title]\n      if {$::PROGRESS_MSGS} {\n        PUTS \"finished: ${title}[string repeat . [expr {53-$n}]] $status $tm\"\n      } else {\n        PUTS \"${title}[string repeat . [expr {63-$n}]] $status $tm\"\n      }\n      if {$errmsg!=\"\"} {PUTS \"     $errmsg\"}\n      flush stdout\n    }\n\n    incr G(nJob) -1\n  } else {\n    set line [gets $fd]\n    if {[string trim $line] != \"\"} {\n      puts \"Trace   : $title - \\\"$line\\\"\"\n    }\n  }\n}\n\n#--------------------------------------------------------------------------\n# The only argument passed to this function is a list of test-suites to\n# run. Each \"test-suite\" is itself a list consisting of the following\n# elements:\n#\n#   * Test title (for display).\n#   * The name of the directory to run the test in.\n#   * The argument for [configureCommand]\n#   * The first argument for [makeCommand]\n#   * The second argument for [makeCommand]\n#   * The third argument for [makeCommand]\n#\nproc run_all_test_suites {alltests} {\n  global G\n  set tests $alltests\n\n  set G(nJob) 0\n\n  while {[llength $tests]>0 || $G(nJob)>0} {\n    if {$G(nJob)>=$::JOBS || [llength $tests]==0} {\n      vwait G(nJob)\n    }\n\n    if {[llength $tests]>0} {\n      set T [lindex $tests 0]\n      set tests [lrange $tests 1 end]\n      foreach {title dir configOpts testtarget makeOpts cflags opts} $T {}\n      if {$::PROGRESS_MSGS && !$::TRACE} {\n        set n [string length $title]\n        PUTS \"starting: ${title} at [now]\"\n        flush stdout\n      }\n\n      # Run the job.\n      #\n      set tm1 [clock seconds]\n      incr G(nJob)\n      set script [file normalize [info script]]\n      set fd [open \"|[info nameofexecutable] $script --slave\" r+]\n      fconfigure $fd -blocking 0\n      fileevent $fd readable [list slave_fileevent $fd $T $tm1]\n      puts $fd [list $::TRACE $::MSVC $::DRYRUN $::KEEPFILES]\n      puts $fd [list {*}$T]\n      flush $fd\n    }\n  }\n}\n\nproc add_test_suite {listvar name testtarget config} {\n  upvar $listvar alltests\n\n  # Tcl variable $opts is used to build up the value used to set the\n  # OPTS Makefile variable. Variable $cflags holds the value for\n  # CFLAGS. The makefile will pass OPTS to both gcc and lemon, but\n  # CFLAGS is only passed to gcc.\n  #\n  set makeOpts \"\"\n  set cflags [expr {$::MSVC ? \"-Zi\" : \"-g\"}]\n  set opts \"\"\n  set title ${name}($testtarget)\n  set configOpts $::WITHTCL\n  set skip 0\n\n  regsub -all {#[^\\n]*\\n} $config \\n config\n  foreach arg $config {\n    if {$skip} {\n      set skip 0\n      continue\n    }\n    if {[regexp {^-[UD]} $arg]} {\n      lappend opts $arg\n    } elseif {[regexp {^[A-Z]+=} $arg]} {\n      lappend testtarget $arg\n    } elseif {[regexp {^if:([a-z]+)(.*)} $arg all key tail]} {\n      # Arguments of the form 'if:os==\"Linux\"' will cause the subsequent\n      # argument to be skipped if the $tcl_platform(os) is not \"Linux\", for\n      # example...\n      set skip [expr !(\\$::tcl_platform($key)$tail)]\n    } elseif {[regexp {^--(enable|disable)-} $arg]} {\n      if {$::MSVC} {\n        if {$arg eq \"--disable-amalgamation\"} {\n          lappend makeOpts USE_AMALGAMATION=0\n          continue\n        }\n        if {$arg eq \"--disable-shared\"} {\n          lappend makeOpts USE_CRT_DLL=0 DYNAMIC_SHELL=0\n          continue\n        }\n        if {$arg eq \"--enable-fts5\"} {\n          lappend opts -DSQLITE_ENABLE_FTS5\n          continue\n        }\n        if {$arg eq \"--enable-json1\"} {\n          lappend opts -DSQLITE_ENABLE_JSON1\n          continue\n        }\n        if {$arg eq \"--enable-shared\"} {\n          lappend makeOpts USE_CRT_DLL=1 DYNAMIC_SHELL=1\n          continue\n        }\n      }\n      lappend configOpts $arg\n    } else {\n      if {$::MSVC} {\n        if {$arg eq \"-g\"} {\n          lappend cflags -Zi\n          continue\n        }\n        if {[regexp -- {^-O(\\d+)$} $arg all level]} then {\n          lappend makeOpts OPTIMIZATIONS=$level\n          continue\n        }\n      }\n      lappend cflags $arg\n    }\n  }\n\n  # Disable sync to make testing faster.\n  #\n  lappend opts -DSQLITE_NO_SYNC=1\n\n  # Some configurations already set HAVE_USLEEP; in that case, skip it.\n  #\n  if {[lsearch -regexp $opts {^-DHAVE_USLEEP(?:=|$)}]==-1} {\n    lappend opts -DHAVE_USLEEP=1\n  }\n\n  # Add the define for this platform.\n  #\n  if {$::tcl_platform(platform)==\"windows\"} {\n    lappend opts -DSQLITE_OS_WIN=1\n  } else {\n    lappend opts -DSQLITE_OS_UNIX=1\n  }\n\n  # Set the sub-directory to use.\n  #\n  set dir [string tolower [string map {- _ \" \" _} $name]]\n\n  # Join option lists into strings, using space as delimiter.\n  #\n  set makeOpts [join $makeOpts \" \"]\n  set cflags   [join $cflags \" \"]\n  set opts     [join $opts \" \"]\n\n  lappend alltests [list \\\n      $title $dir $configOpts $testtarget $makeOpts $cflags $opts]\n}\n\n# The following procedure returns the \"configure\" command to be exectued for\n# the current platform, which may be Windows (via MinGW, etc).\n#\nproc configureCommand {opts} {\n  if {$::MSVC} return [list]; # This is not needed for MSVC.\n  set result [list trace_cmd exec]\n  if {$::tcl_platform(platform)==\"windows\"} {\n    lappend result sh\n  }\n  lappend result $::SRCDIR/configure --enable-load-extension\n  foreach x $opts {lappend result $x}\n  lappend result >& test.log\n}\n\n# The following procedure returns the \"make\" command to be executed for the\n# specified targets, compiler flags, and options.\n#\nproc makeCommand { targets makeOpts cflags opts } {\n  set result [list trace_cmd exec]\n  if {$::MSVC} {\n    set nmakeDir [file nativename $::SRCDIR]\n    set nmakeFile [file nativename [file join $nmakeDir Makefile.msc]]\n    lappend result nmake /f $nmakeFile TOP=$nmakeDir\n    if {[regexp {USE_STDCALL=1} $cflags]} {\n      lappend result USE_STDCALL=1\n    }\n  } else {\n    lappend result make\n  }\n  foreach makeOpt $makeOpts {\n    lappend result $makeOpt\n  }\n  lappend result clean\n  foreach target $targets {\n    lappend result $target\n  }\n  lappend result CFLAGS=$cflags OPTS=$opts >>& test.log\n}\n\n# The following procedure prints its arguments if ::TRACE is true.\n# And it executes the command of its arguments in the calling context\n# if ::DRYRUN is false.\n#\nproc trace_cmd {args} {\n  if {$::TRACE} {\n    PUTS $args\n  }\n  set res \"\"\n  if {!$::DRYRUN} {\n    set res [uplevel 1 $args]\n  }\n  return $res\n}\n\n\n# This proc processes the command line options passed to this script.\n# Currently the only option supported is \"-makefile\", default\n# \"releasetest.mk\". Set the ::MAKEFILE variable to the value of this\n# option.\n#\nproc process_options {argv} {\n  set ::SRCDIR    [file normalize [file dirname [file dirname $::argv0]]]\n  set ::QUICK          0\n  set ::MSVC           0\n  set ::BUILDONLY      0\n  set ::DRYRUN         0\n  set ::TRACE          0\n  set ::JOBS           1\n  set ::PROGRESS_MSGS  0\n  set ::WITHTCL        {}\n  set ::FORCE          0\n  set ::KEEPFILES      0          ;# Keep extra files after test run\n  set config {}\n  set platform $::tcl_platform(os)-$::tcl_platform(machine)\n\n  for {set i 0} {$i < [llength $argv]} {incr i} {\n    set x [lindex $argv $i]\n    if {[regexp {^--[a-z]} $x]} {set x [string range $x 1 end]}\n    switch -glob -- $x {\n      -slave {\n        run_slave_test\n        exit\n      }\n\n      # Undocumented legacy option: --srcdir DIRECTORY\n      #\n      # DIRECTORY is the root of the SQLite checkout.  This sets the\n      # SRCDIR global variable.  But that variable is already set\n      # automatically so there really is no reason to have this option.\n      #\n      -srcdir {\n        incr i\n        set ::SRCDIR [file normalize [lindex $argv $i]]\n      }\n\n      -platform {\n        incr i\n        set platform [lindex $argv $i]\n      }\n\n      -jobs {\n        incr i\n        set ::JOBS [lindex $argv $i]\n      }\n\n      -progress {\n        set ::PROGRESS_MSGS 1\n      }\n\n      -quick {\n        set ::QUICK 1\n      }\n      -veryquick {\n        set ::QUICK 2\n      }\n\n      -config {\n        incr i\n        set config [lindex $argv $i]\n      }\n\n      -msvc {\n        set ::MSVC 1\n      }\n\n      -buildonly {\n        set ::BUILDONLY 1\n      }\n\n      -dryrun {\n        set ::DRYRUN 1\n      }\n\n      -force -\n      -f {\n        set ::FORCE 1\n      }\n\n      -trace {\n        set ::TRACE 1\n      }\n\n      -info {\n        PUTS \"Command-line Options:\"\n        PUTS \"   --srcdir $::SRCDIR\"\n        PUTS \"   --platform [list $platform]\"\n        PUTS \"   --config [list $config]\"\n        if {$::QUICK} {\n          if {$::QUICK==1} {PUTS \"   --quick\"}\n          if {$::QUICK==2} {PUTS \"   --veryquick\"}\n        }\n        if {$::MSVC}      {PUTS \"   --msvc\"}\n        if {$::BUILDONLY} {PUTS \"   --buildonly\"}\n        if {$::DRYRUN}    {PUTS \"   --dryrun\"}\n        if {$::TRACE}     {PUTS \"   --trace\"}\n        PUTS \"\\nAvailable --platform options:\"\n        foreach y [lsort [array names ::Platforms]] {\n          PUTS \"   [list $y]\"\n        }\n        PUTS \"\\nAvailable --config options:\"\n        foreach y [lsort [array names ::Configs]] {\n          PUTS \"   [list $y]\"\n        }\n        exit\n      }\n\n      -g {\n        lappend ::EXTRACONFIG [lindex $argv $i]\n      }\n\n      -keep {\n        set ::KEEPFILES 1\n      }\n\n      -with-tcl=* {\n        set ::WITHTCL -$x\n      }\n\n      -D* -\n      -O* -\n      -enable-* -\n      -disable-* -\n      *=* {\n        lappend ::EXTRACONFIG [lindex $argv $i]\n      }\n\n      default {\n        PUTSERR \"\"\n        PUTSERR [string trim $::USAGE_MESSAGE]\n        exit -1\n      }\n    }\n  }\n\n  if {0==[info exists ::Platforms($platform)]} {\n    PUTS \"Unknown platform: $platform\"\n    PUTSNNL \"Set the -platform option to \"\n    set print [list]\n    foreach p [array names ::Platforms] {\n      lappend print \"\\\"$p\\\"\"\n    }\n    lset print end \"or [lindex $print end]\"\n    PUTS \"[join $print {, }].\"\n    exit\n  }\n\n  if {$config!=\"\"} {\n    if {[llength $config]==1} {lappend config fulltest}\n    set ::CONFIGLIST $config\n  } else {\n    if {$::JOBS>1} {\n      set ::CONFIGLIST {}\n      foreach {target zConfig} [lreverse $::Platforms($platform)] {\n        append ::CONFIGLIST [format \"    %-25s %s\\n\" \\\n                               [list $zConfig] [list $target]]\n      }\n    } else {\n      set ::CONFIGLIST $::Platforms($platform)\n    }\n  }\n  PUTS \"Running the following test configurations for $platform:\"\n  PUTS \"    [string trim $::CONFIGLIST]\"\n  PUTSNNL \"Flags:\"\n  if {$::PROGRESS_MSGS} {PUTSNNL \" --progress\"}\n  if {$::DRYRUN} {PUTSNNL \" --dryrun\"}\n  if {$::BUILDONLY} {PUTSNNL \" --buildonly\"}\n  if {$::MSVC} {PUTSNNL \" --msvc\"}\n  switch -- $::QUICK {\n     1 {PUTSNNL \" --quick\"}\n     2 {PUTSNNL \" --veryquick\"}\n  }\n  if {$::JOBS>1} {PUTSNNL \" --jobs $::JOBS\"}\n  PUTS \"\"\n}\n\n# Check to see if there are uncommitted changes in the SQLite source\n# checkout.  Exit if there are.  Except:  Do nothing if the --force\n# flag is used.  Also, ignore this test if the fossil binary is\n# unavailable, or if the source tree is not a valid fossil checkout.\n#\nproc check_uncommitted {} {\n  if {$::FORCE} return\n  set pwd [pwd]\n  cd $::SRCDIR\n  if {[catch {exec fossil changes} res]==0 && [string trim $res]!=\"\"} {\n    puts \"ERROR: The check-out contains uncommitted changes:\"\n    puts $res\n    puts \"Use the -f or --force options to override\"\n    exit 1\n  }\n  cd $pwd\n}\n\n# A test run has just finished in directory $dir. This command deletes all\n# non-essential files from the directory. Specifically, everything except\n#\n#   * The \"testfixture\" and \"sqlite3\" binaries,\n#   * The \"test-out.log\" and \"test.log\" log files.\n#\nproc cleanup {dir} {\n  set K(testfixture) 1\n  set K(testfixture.exe) 1\n  set K(sqlite3) 1\n  set K(sqlite3.exe) 1\n  set K(test-out.txt) 1\n  set K(test.log) 1\n\n  foreach f [glob -nocomplain [file join $dir *]] {\n    set tail [file tail $f]\n    if {[info exists K($tail)]==0} { \n      file delete -force $f\n    }\n  }\n}\n\n\n# Main routine.\n#\nproc main {argv} {\n\n  # Process any command line options.\n  set ::EXTRACONFIG {}\n  process_options $argv\n  if {!$::DRYRUN} check_uncommitted\n  PUTS [string repeat * 79]\n\n  set ::NERR 0\n  set ::NTEST 0\n  set ::NTESTCASE 0\n  set ::NERRCASE 0\n  set ::SQLITE_VERSION {}\n  set STARTTIME [clock seconds]\n  foreach {zConfig target} $::CONFIGLIST {\n    if {$::MSVC && ($zConfig eq \"Sanitize\" || \"checksymbols\" in $target\n           || \"valgrindtest\" in $target)} {\n      PUTS \"Skipping $zConfig / $target for MSVC...\"\n      continue\n    }\n    if {$target ne \"checksymbols\"} {\n      switch -- $::QUICK {\n         1 {set target quicktest}\n         2 {set target smoketest}\n      }\n      if {$::BUILDONLY} {\n        set target testfixture\n        if {$::tcl_platform(platform)==\"windows\"} {\n          append target .exe\n        }\n      }\n    }\n    set config_options [concat $::Configs($zConfig) $::EXTRACONFIG]\n\n    incr NTEST\n    add_test_suite all $zConfig $target $config_options\n\n    # If the configuration included the SQLITE_DEBUG option, then remove\n    # it and run veryquick.test. If it did not include the SQLITE_DEBUG option\n    # add it and run veryquick.test.\n    if {$target!=\"checksymbols\" && $target!=\"valgrindtest\"\n           && $target!=\"fuzzoomtest\" && !$::BUILDONLY && $::QUICK<2} {\n      set debug_idx [lsearch -glob $config_options -DSQLITE_DEBUG*]\n      set xtarget $target\n      regsub -all {fulltest[a-z]*} $xtarget test xtarget\n      regsub -all {fuzzoomtest} $xtarget fuzztest xtarget\n      if {$debug_idx < 0} {\n        incr NTEST\n        append config_options \" -DSQLITE_DEBUG=1 -DSQLITE_EXTRA_IFNULLROW=1\"\n        add_test_suite all \"${zConfig}_debug\" $xtarget $config_options\n      } else {\n        incr NTEST\n        regsub { *-DSQLITE_MEMDEBUG[^ ]* *} $config_options { } config_options\n        regsub { *-DSQLITE_DEBUG[^ ]* *} $config_options { } config_options\n        add_test_suite all \"${zConfig}_ndebug\" $xtarget $config_options\n      }\n    }\n  }\n\n  run_all_test_suites $all\n\n  set elapsetime [expr {[clock seconds]-$STARTTIME}]\n  set hr [expr {$elapsetime/3600}]\n  set min [expr {($elapsetime/60)%60}]\n  set sec [expr {$elapsetime%60}]\n  set etime [format (%02d:%02d:%02d) $hr $min $sec]\n  if {$::JOBS>1} {append etime \" $::JOBS cores\"}\n  if {[catch {exec hostname} HNAME]==0} {append etime \" on $HNAME\"}\n  PUTS [string repeat * 79]\n  incr ::NERRCASE $::NERR\n  PUTS \"$::NERRCASE failures out of $::NTESTCASE tests in $etime\"\n  if {$::SQLITE_VERSION ne \"\"} {\n    PUTS \"SQLite $::SQLITE_VERSION\"\n  }\n}\n\nmain $argv\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/resolver01.test",
    "content": "# 2013-04-13\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests features of the name resolver (the component that\n# figures out what identifiers in the SQL statement refer to) that\n# were fixed by ticket [2500cdb9be].\n#\n# See also tickets [1c69be2daf] and [f617ea3125] from 2013-08-14.\n#\n# Also a fuzzer-discovered problem on 2015-04-23.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# \"ORDER BY y\" binds to the output result-set column named \"y\"\n# if available.  If no output column is named \"y\", then try to\n# bind against an input column named \"y\".\n#\n# This is classical SQL92 behavior.\n#\ndo_test resolver01-1.1 {\n  catchsql {\n    CREATE TABLE t1(x, y); INSERT INTO t1 VALUES(11,22);\n    CREATE TABLE t2(y, z); INSERT INTO t2 VALUES(33,44);\n    SELECT 1 AS y FROM t1, t2 ORDER BY y;\n  }\n} {0 1}\ndo_test resolver01-1.2 {\n  catchsql {\n    SELECT 1 AS yy FROM t1, t2 ORDER BY y;\n  }\n} {1 {ambiguous column name: y}}\ndo_test resolver01-1.3 {\n  catchsql {\n    CREATE TABLE t3(x,y); INSERT INTO t3 VALUES(11,44),(33,22);\n    SELECT x AS y FROM t3 ORDER BY y;\n  }\n} {0 {11 33}}\ndo_test resolver01-1.4 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY y;\n  }\n} {0 {33 11}}\n\n# SQLite allows the WHERE clause to reference output columns if there is\n# no other way to resolve the name.\n#\ndo_test resolver01-1.5 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY yy;\n  }\n} {0 {11 33}}\ndo_test resolver01-1.6 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY 1;\n  }\n} {0 {11 33}}\n\n# The \"ORDER BY y COLLATE nocase\" form works the same as \"ORDER BY y\".\n# The \"y\" binds more tightly to output columns than to input columns.\n#\n# This is for compatibility with SQL92 and with historical SQLite behavior.\n# Note that PostgreSQL considers \"y COLLATE nocase\" to be an expression\n# and thus PostgreSQL treats this case as if it where the 3.x case below.\n#\ndo_test resolver01-2.1 {\n  catchsql {\n    SELECT 2 AS y FROM t1, t2 ORDER BY y COLLATE nocase;\n  }\n} {0 2}\ndo_test resolver01-2.2 {\n  catchsql {\n    SELECT 2 AS yy FROM t1, t2 ORDER BY y COLLATE nocase;\n  }\n} {1 {ambiguous column name: y}}\ndo_test resolver01-2.3 {\n  catchsql {\n    SELECT x AS y FROM t3 ORDER BY y COLLATE nocase;\n  }\n} {0 {11 33}}\ndo_test resolver01-2.4 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY y COLLATE nocase;\n  }\n} {0 {33 11}}\ndo_test resolver01-2.5 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY yy COLLATE nocase;\n  }\n} {0 {11 33}}\ndo_test resolver01-2.6 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY 1 COLLATE nocase;\n  }\n} {0 {11 33}}\n\n# But if the form is \"ORDER BY expr\" then bind more tightly to the\n# the input column names and only use the output column names if no\n# input column name matches.\n#\n# This is SQL99 behavior, as implemented by PostgreSQL and MS-SQL.\n# Note that Oracle works differently.\n#\ndo_test resolver01-3.1 {\n  catchsql {\n    SELECT 3 AS y FROM t1, t2 ORDER BY +y;\n  }\n} {1 {ambiguous column name: y}}\ndo_test resolver01-3.2 {\n  catchsql {\n    SELECT 2 AS yy FROM t1, t2 ORDER BY +y;\n  }\n} {1 {ambiguous column name: y}}\ndo_test resolver01-3.3 {\n  catchsql {\n    SELECT x AS y FROM t3 ORDER BY +y;\n  }\n} {0 {33 11}}\ndo_test resolver01-3.4 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY +y;\n  }\n} {0 {33 11}}\ndo_test resolver01-3.5 {\n  catchsql {\n    SELECT x AS yy FROM t3 ORDER BY +yy\n  }\n} {0 {11 33}}\n\n# This is the test case given in ticket [f617ea3125e9] (with table name\n# changed from \"t1\" to \"t4\".  The behavior of (1) and (3) match with\n# PostgreSQL, but we intentionally break with PostgreSQL to provide\n# SQL92 behavior for case (2).\n#\ndo_execsql_test resolver01-4.1 {\n  CREATE TABLE t4(m CHAR(2));\n  INSERT INTO t4 VALUES('az');\n  INSERT INTO t4 VALUES('by');\n  INSERT INTO t4 VALUES('cx');\n  SELECT '1', substr(m,2) AS m FROM t4 ORDER BY m;\n  SELECT '2', substr(m,2) AS m FROM t4 ORDER BY m COLLATE binary;\n  SELECT '3', substr(m,2) AS m FROM t4 ORDER BY lower(m);\n} {1 x 1 y 1 z 2 x 2 y 2 z 3 z 3 y 3 x}\n\n##########################################################################\n# Test cases for ticket [1c69be2dafc28]:  Make sure the GROUP BY binds\n# more tightly to the input tables in all cases.\n#\n# This first case case has been wrong in SQLite for time out of mind.\n# For SQLite version 3.7.17 the answer was two rows, which is wrong.\n#\ndo_execsql_test resolver01-5.1 {\n  CREATE TABLE t5(m CHAR(2));\n  INSERT INTO t5 VALUES('ax');\n  INSERT INTO t5 VALUES('bx');\n  INSERT INTO t5 VALUES('cy');\n  SELECT count(*), substr(m,2,1) AS m FROM t5 GROUP BY m ORDER BY 1, 2;\n} {1 x 1 x 1 y}\n\n# This case is unambiguous and has always been correct.\n#\ndo_execsql_test resolver01-5.2 {\n  SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY m ORDER BY 1, 2;\n} {1 x 1 x 1 y}\n\n# This case is not allowed in standard SQL, but SQLite allows and does\n# the sensible thing.\n#\ndo_execsql_test resolver01-5.3 {\n  SELECT count(*), substr(m,2,1) AS mx FROM t5 GROUP BY mx ORDER BY 1, 2;\n} {1 y 2 x}\ndo_execsql_test resolver01-5.4 {\n  SELECT count(*), substr(m,2,1) AS mx FROM t5\n   GROUP BY substr(m,2,1) ORDER BY 1, 2;\n} {1 y 2 x}\n\n# These test case weere provided in the 2013-08-14 email from Rob Golsteijn\n# that originally reported the problem of ticket [1c69be2dafc28].\n#\ndo_execsql_test resolver01-6.1 {\n  CREATE TABLE t61(name);\n  SELECT min(name) FROM t61 GROUP BY lower(name);\n} {}\ndo_execsql_test resolver01-6.2 {\n  SELECT min(name) AS name FROM t61 GROUP BY lower(name); \n} {}\ndo_execsql_test resolver01-6.3 {\n  CREATE TABLE t63(name);\n  INSERT INTO t63 VALUES (NULL);\n  INSERT INTO t63 VALUES ('abc');\n  SELECT count(),\n       NULLIF(name,'abc') AS name\n    FROM t63\n   GROUP BY lower(name);\n} {1 {} 1 {}}\n\ndo_execsql_test resolver01-7.1 {\n  SELECT 2 AS x WHERE (SELECT x AS y WHERE 3>y);\n} {2}\ndo_execsql_test resolver01-7.2 {\n  SELECT 2 AS x WHERE (SELECT x AS y WHERE 1>y);\n} {}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rollback.test",
    "content": "# 2004 June 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is verifying that a rollback in one statement\n# caused by an ON CONFLICT ROLLBACK clause aborts any other pending\n# statements.\n#\n# $Id: rollback.test,v 1.11 2009/06/26 07:12:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset DB [sqlite3_connection_pointer db]\n\ndo_test rollback-1.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4}\n\nifcapable conflict {\n  do_test rollback-1.2 {\n    execsql {\n      CREATE TABLE t3(a unique on conflict rollback);\n      INSERT INTO t3 SELECT a FROM t1;\n      BEGIN;\n      INSERT INTO t1 SELECT * FROM t1;\n    }\n  } {}\n}\ndo_test rollback-1.3 {\n  set STMT [sqlite3_prepare $DB \"SELECT a FROM t1\" -1 TAIL]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\n\nifcapable conflict {\n  # This causes a ROLLBACK, which deletes the table out from underneath the\n  # SELECT statement.\n  #\n  do_test rollback-1.4 {\n    catchsql {\n      INSERT INTO t3 SELECT a FROM t1;\n    }\n  } {1 {UNIQUE constraint failed: t3.a}}\n  \n  # Try to continue with the SELECT statement\n  #\n  do_test rollback-1.5 {\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n\n  # Restart the SELECT statement\n  #\n  do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK}\n} else {\n  do_test rollback-1.6 { sqlite3_reset $STMT } {SQLITE_OK}\n}\n\ndo_test rollback-1.7 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test rollback-1.8 {\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test rollback-1.9 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\nif {$tcl_platform(platform) == \"unix\" \n && [permutation] ne \"onefile\"\n && [permutation] ne \"inmemory_journal\"\n && [permutation] ne \"atomic-batch-write\"\n} {\n  do_test rollback-2.1 {\n    execsql {\n      BEGIN;\n      INSERT INTO t3 VALUES('hello world');\n    }\n    forcecopy test.db testA.db\n    forcecopy test.db-journal testA.db-journal\n    execsql {\n      COMMIT;\n    }\n  } {}\n\n  # At this point files testA.db and testA.db-journal are present in the\n  # file system. This block adds a master-journal file pointer to the\n  # end of testA.db-journal. The master-journal file does not exist.\n  # \n  set mj [file normalize testA.db-mj-123]\n  binary scan $mj c* a\n  set cksum 0\n  foreach i $a { incr cksum $i }\n  set mj_pgno [expr $sqlite_pending_byte / 1024]\n  set zAppend [binary format Ia*IIa8 $mj_pgno $mj [string length $mj] $cksum \\\n    \"\\xd9\\xd5\\x05\\xf9\\x20\\xa1\\x63\\xd7\"\n  ]\n  set iOffset [expr (([file size testA.db-journal] + 511)/512)*512]\n  set fd [open testA.db-journal a+]\n  fconfigure $fd -encoding binary -translation binary\n  seek $fd $iOffset\n  puts -nonewline $fd $zAppend\n\n  # Also, fix the first journal-header in the journal-file. Because the\n  # journal file has not yet been synced, the 8-byte magic string at the\n  # start of the first journal-header has not been written by SQLite.\n  # So write it now.\n  seek $fd 0\n  puts -nonewline $fd \"\\xd9\\xd5\\x05\\xf9\\x20\\xa1\\x63\\xd7\"\n  close $fd\n\n  # Open a handle on testA.db and use it to query the database. At one\n  # point the first query would attempt a hot rollback, attempt to open\n  # the master-journal file and return SQLITE_CANTOPEN when it could not\n  # be opened. This is incorrect, it should simply delete the journal\n  # file and proceed with the query.\n  # \n  do_test rollback-2.2 {\n    sqlite3 db2 testA.db\n    execsql {\n      SELECT distinct tbl_name FROM sqlite_master;\n    } db2\n  } {t1 t3}\n  if {[lsearch {exclusive persistent_journal no_journal} [permutation]]<0} {\n    do_test rollback-2.3 {\n      file exists testA.db-journal\n    } 0\n  }\n  do_test rollback-2.4 {\n    execsql {\n      SELECT distinct tbl_name FROM sqlite_master;\n    } db2\n  } {t1 t3}\n\n  db2 close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rollback2.test",
    "content": "# 2014 November 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file containst tests to verify that ROLLBACK or ROLLBACK TO \n# operations interact correctly with ongoing SELECT statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rollback2\n\nproc int2hex {i} { format %.2X $i }\ndb func int2hex int2hex\ndo_execsql_test 1.0 {\n  SELECT int2hex(0), int2hex(100), int2hex(255)\n} {00 64 FF}\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(i, h);\n  CREATE INDEX i1 ON t1(h);\n  WITH data(a, b) AS (\n    SELECT 1, int2hex(1)\n      UNION ALL\n    SELECT a+1, int2hex(a+1) FROM data WHERE a<40\n  )\n  INSERT INTO t1 SELECT * FROM data;\n} {}\n\n\n# do_rollback_test ID SWITCHES\n#\n# where SWITCHES are:\n#\n#   -setup      SQL script to open transaction and begin writing.\n#   -select     SELECT to execute after -setup script\n#   -result     Expected result of -select statement\n#   -rollback   Use this SQL command (\"ROLLBACK\" or \"ROLLBACK TO ...\") to\n#               rollback the transaction in the middle of the -select statment\n#               execution.\n#\nproc do_rollback_test {tn args} {\n  set A(-setup)    \"\"\n  set A(-select)   \"\"\n  set A(-result)   \"\"\n  set A(-rollback) ROLLBACK\n\n  array set O $args\n  foreach k [array names O] {\n    if {[info exists A($k)]==0} { error \"unknown option: $k\" }\n    set A($k) $O($k)\n  }\n\n  for {set iRollback 0} 1 {incr iRollback} {\n    catch { db eval ROLLBACK }\n    set res [list]\n    db eval $A(-setup)\n\n    set i 0\n    db eval $A(-select) x {\n      if {$i==$iRollback} { db eval $A(-rollback) }\n      foreach k $x(*) { lappend res $x($k) }\n      incr i\n    }\n\n    do_test $tn.$iRollback [list set {} $res] [list {*}$A(-result)]\n    if {$i < $iRollback} break\n  }\n}\n\ndo_rollback_test 2.1 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%2)==1;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0\n} -result {\n  2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40\n}\n\ndo_rollback_test 2.2 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%4)==1;\n    SAVEPOINT one;\n      DELETE FROM t1 WHERE (i%2)==1;\n} -rollback {\n  ROLLBACK TO one;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0\n} -result {\n  2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40\n}\n\n#--------------------------------------------------------------------\n# Try with some index scans\n#\ndo_eqp_test 3.1 {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;\n} {0 0 0 {SCAN TABLE t1 USING INDEX i1}}\ndo_rollback_test 3.2 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%2)==1;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;\n} -result {\n  40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10  8  6  4  2\n}\ndo_rollback_test 3.3 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%4)==1;\n    SAVEPOINT one;\n      DELETE FROM t1 WHERE (i%2)==1;\n} -rollback {\n  ROLLBACK TO one;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h DESC;\n} -result {\n  40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10  8  6  4  2\n}\n\n#--------------------------------------------------------------------\n# Now with some index scans that feature overflow keys.\n#\nset leader [string repeat \"abcdefghij\" 70]\ndo_execsql_test 4.1 { UPDATE t1 SET h = $leader || h; }\n\ndo_eqp_test 4.2 {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;\n} {0 0 0 {SCAN TABLE t1 USING INDEX i1}}\ndo_rollback_test 4.3 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%2)==1;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;\n} -result {\n  2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40\n}\ndo_rollback_test 4.4 -setup {\n  BEGIN;\n    DELETE FROM t1 WHERE (i%4)==1;\n    SAVEPOINT one;\n      DELETE FROM t1 WHERE (i%2)==1;\n} -rollback {\n  ROLLBACK TO one;\n} -select {\n  SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h ASC;\n} -result {\n  2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rollbackfault.test",
    "content": "# 2014-11-12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that errors encountered during a ROLLBACK operation correctly \n# affect ongoing SQL statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix rollbackfault\n\n\nproc int2hex {i} { format %.2X $i }\ndb func int2hex int2hex\ndo_execsql_test 1.0 {\n  SELECT int2hex(0), int2hex(100), int2hex(255)\n} {00 64 FF}\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(i, h);\n  CREATE INDEX i1 ON t1(h);\n  WITH data(a, b) AS (\n    SELECT 1, int2hex(1)\n      UNION ALL\n    SELECT a+1, int2hex(a+1) FROM data WHERE a<40\n  )\n  INSERT INTO t1 SELECT * FROM data;\n} {}\n\nforeach f {oom ioerr} {\n  do_faultsim_test 1.2 -faults $f* -prep {\n    set sql1 { SELECT i FROM t1 WHERE (i%2)==0 }\n    set sql2 { SELECT i FROM t1 WHERE (i%2)==0 ORDER BY h }\n    set ::s1 [sqlite3_prepare db $sql1 -1 dummy]\n    set ::s2 [sqlite3_prepare db $sql2 -1 dummy]\n  \n    for {set i 0} {$i < 10} {incr i} { sqlite3_step $::s1 }\n    for {set i 0} {$i < 3}  {incr i} { sqlite3_step $::s2 }\n  \n    execsql {\n      BEGIN; DELETE FROM t1 WHERE (i%2)\n    }\n  } -body {\n    execsql { ROLLBACK }\n  } -test {\n  \n    set res1 [list]\n    set res2 [list]\n    while {\"SQLITE_ROW\" == [sqlite3_step $::s1]} {\n      lappend res1 [sqlite3_column_text $::s1 0]\n    }\n    while {\"SQLITE_ROW\" == [sqlite3_step $::s2]} {\n      lappend res2 [sqlite3_column_text $::s2 0]\n    }\n    set rc1 [sqlite3_finalize $::s1]\n    set rc2 [sqlite3_finalize $::s2]\n  \n    catchsql { ROLLBACK }\n  \n    if {$rc1==\"SQLITE_OK\" && $rc2==\"SQLITE_OK\" \n     && $res1==\"22 24 26 28 30 32 34 36 38 40\"\n     && $res2==\"8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40\"\n    } {\n      # This is Ok.\n    } elseif {$rc1!=\"SQLITE_OK\" && $rc2!=\"SQLITE_OK\" && $res1==\"\" &&$res2==\"\"} {\n      # Also Ok.\n    } else {\n      error \"statements don't look right\"\n    }\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowallock.test",
    "content": "\n# 2015-05-28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing locks on read-only WAL-mode databases.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset testprefix rowallock\n\nset mmap_res 1000000\nifcapable !mmap {\n  set mmap_res 0\n}\n\ndo_multiclient_test tn {\n  code2 { db2 close }\n  code3 { db3 close }\n  \n  do_execsql_test 1.$tn.1 {\n    PRAGMA page_size = 4096;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a, b);\n    INSERT INTO t1 VALUES(1, 2), (3, 4);\n    PRAGMA journal_mode = wal;\n  } {wal}\n\n  code1 { \n    db close \n    sqlite3 db test.db -readonly 1\n  }\n\n  do_execsql_test 1.$tn.2 {\n    PRAGMA mmap_size = 1000000;\n  } $mmap_res\n  do_execsql_test 1.$tn.2.1 {\n    SELECT * FROM t1;\n  } {1 2 3 4}\n\n  do_catchsql_test 1.$tn.3 {\n    INSERT INTO t1 VALUES(5, 6);\n  } {1 {attempt to write a readonly database}}\n\n  do_test 1.$tn.4 {\n    code2 { sqlite3 db2 test.db }\n    sql2 { INSERT INTO t1 VALUES(5, 6); }\n    code2 { db2 close }\n    file exists test.db-wal\n  } {1}\n\n  do_test 1.$tn.5 {\n    sql1 { SELECT * FROM t2 }\n    code1 { db close }\n    file exists test.db-wal\n  } {1}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowhash.test",
    "content": "# 2009 April 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the code in rowhash.c.\n#\n# NB:  The rowhash.c module is no longer part of the source tree.  But\n# we might as well keep this test.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test rowhash-1.1 {\n  execsql {\n    CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n    CREATE INDEX i3 ON t1(c);\n  }\n} {}\n\nproc do_keyset_test {name lKey} {\n  db transaction {\n    execsql { DELETE FROM t1 }\n    foreach key $lKey {\n      execsql { INSERT OR IGNORE INTO t1 VALUES($key, 'a', 'b', 'c') }\n    }\n  }\n  do_test $name {\n    lsort -integer [execsql {\n      SELECT id FROM t1 WHERE a = 'a' OR b = 'b' OR c = 'c';\n    }]\n  } [lsort -integer -unique $lKey]\n}\n\ndo_keyset_test rowhash-2.1 {1 2 3}\ndo_keyset_test rowhash-2.2 {0 1 2 3}\ndo_keyset_test rowhash-2.3 {62 125 188}\nif {[working_64bit_int]} {\n  expr srand(1)\n  unset -nocomplain i L\n  for {set i 4} {$i < 10} {incr i} {\n    for {set j 0} {$j < 5000} {incr j} {\n        lappend L [expr int(rand()*1000000000)]\n    }\n    do_keyset_test rowhash-2.$i $L\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowid.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the magic ROWID column that is\n# found on all tables.\n#\n# EVIDENCE-OF: R-36924-43758 By default, every row in SQLite has a\n# special column, usually called the \"rowid\", that uniquely identifies\n# that row within the table.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Basic ROWID functionality tests.\n#\ndo_test rowid-1.1 {\n  execsql {\n    CREATE TABLE t1(x int, y int);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    SELECT x FROM t1 ORDER BY y;\n  }\n} {1 3}\ndo_test rowid-1.2 {\n  set r [execsql {SELECT rowid FROM t1 ORDER BY x}]\n  global x2rowid rowid2x\n  set x2rowid(1) [lindex $r 0]\n  set x2rowid(3) [lindex $r 1]\n  set rowid2x($x2rowid(1)) 1\n  set rowid2x($x2rowid(3)) 3\n  llength $r\n} {2}\ndo_test rowid-1.3 {\n  global x2rowid\n  set sql \"SELECT x FROM t1 WHERE rowid==$x2rowid(1)\"\n  execsql $sql\n} {1}\ndo_test rowid-1.4 {\n  global x2rowid\n  set sql \"SELECT x FROM t1 WHERE rowid==$x2rowid(3)\"\n  execsql $sql\n} {3}\ndo_test rowid-1.5 {\n  global x2rowid\n  set sql \"SELECT x FROM t1 WHERE oid==$x2rowid(1)\"\n  execsql $sql\n} {1}\ndo_test rowid-1.6 {\n  global x2rowid\n  set sql \"SELECT x FROM t1 WHERE OID==$x2rowid(3)\"\n  execsql $sql\n} {3}\ndo_test rowid-1.7 {\n  global x2rowid\n  set sql \"SELECT x FROM t1 WHERE _rowid_==$x2rowid(1)\"\n  execsql $sql\n} {1}\ndo_test rowid-1.7.1 {\n  while 1 {\n    set norow [expr {int(rand()*1000000)}]\n    if {$norow!=$x2rowid(1) && $norow!=$x2rowid(3)} break\n  }\n  execsql \"SELECT x FROM t1 WHERE rowid=$norow\"\n} {}\ndo_test rowid-1.8 {\n  global x2rowid\n  set v [execsql {SELECT x, oid FROM t1 order by x}]\n  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]\n  expr {$v==$v2}\n} {1}\ndo_test rowid-1.9 {\n  global x2rowid\n  set v [execsql {SELECT x, RowID FROM t1 order by x}]\n  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]\n  expr {$v==$v2}\n} {1}\ndo_test rowid-1.10 {\n  global x2rowid\n  set v [execsql {SELECT x, _rowid_ FROM t1 order by x}]\n  set v2 [list 1 $x2rowid(1) 3 $x2rowid(3)]\n  expr {$v==$v2}\n} {1}\n\n# We can insert or update the ROWID column.\n#\ndo_test rowid-2.1 {\n  catchsql {\n    INSERT INTO t1(rowid,x,y) VALUES(1234,5,6);\n    SELECT rowid, * FROM t1;\n  }\n} {0 {1 1 2 2 3 4 1234 5 6}}\ndo_test rowid-2.2 {\n  catchsql {\n    UPDATE t1 SET rowid=12345 WHERE x==1;\n    SELECT rowid, * FROM t1\n  }\n} {0 {2 3 4 1234 5 6 12345 1 2}}\ndo_test rowid-2.3 {\n  catchsql {\n    INSERT INTO t1(y,x,oid) VALUES(8,7,1235);\n    SELECT rowid, * FROM t1 WHERE rowid>1000;\n  }\n} {0 {1234 5 6 1235 7 8 12345 1 2}}\ndo_test rowid-2.4 {\n  catchsql {\n    UPDATE t1 SET oid=12346 WHERE x==1;\n    SELECT rowid, * FROM t1;\n  }\n} {0 {2 3 4 1234 5 6 1235 7 8 12346 1 2}}\ndo_test rowid-2.5 {\n  catchsql {\n    INSERT INTO t1(x,_rowid_,y) VALUES(9,1236,10);\n    SELECT rowid, * FROM t1 WHERE rowid>1000;\n  }\n} {0 {1234 5 6 1235 7 8 1236 9 10 12346 1 2}}\ndo_test rowid-2.6 {\n  catchsql {\n    UPDATE t1 SET _rowid_=12347 WHERE x==1;\n    SELECT rowid, * FROM t1 WHERE rowid>1000;\n  }\n} {0 {1234 5 6 1235 7 8 1236 9 10 12347 1 2}}\n\n# But we can use ROWID in the WHERE clause of an UPDATE that does not\n# change the ROWID.\n#\ndo_test rowid-2.7 {\n  global x2rowid\n  set sql \"UPDATE t1 SET x=2 WHERE OID==$x2rowid(3)\"\n  execsql $sql\n  execsql {SELECT x FROM t1 ORDER BY x}\n} {1 2 5 7 9}\ndo_test rowid-2.8 {\n  global x2rowid\n  set sql \"UPDATE t1 SET x=3 WHERE _rowid_==$x2rowid(3)\"\n  execsql $sql\n  execsql {SELECT x FROM t1 ORDER BY x}\n} {1 3 5 7 9}\n\nif 0 {  # With the index-on-expressions enhancement, creating\n        # an index on ROWID has become possible.\n# We cannot index by ROWID\n#\ndo_test rowid-2.9 {\n  set v [catch {execsql {CREATE INDEX idxt1 ON t1(rowid)}} msg]\n  lappend v $msg\n} {1 {table t1 has no column named rowid}}\ndo_test rowid-2.10 {\n  set v [catch {execsql {CREATE INDEX idxt1 ON t1(_rowid_)}} msg]\n  lappend v $msg\n} {1 {table t1 has no column named _rowid_}}\ndo_test rowid-2.11 {\n  set v [catch {execsql {CREATE INDEX idxt1 ON t1(oid)}} msg]\n  lappend v $msg\n} {1 {table t1 has no column named oid}}\ndo_test rowid-2.12 {\n  set v [catch {execsql {CREATE INDEX idxt1 ON t1(x, rowid)}} msg]\n  lappend v $msg\n} {1 {table t1 has no column named rowid}}\n}\n\n# Columns defined in the CREATE statement override the buildin ROWID\n# column names.\n#\ndo_test rowid-3.1 {\n  execsql {\n    CREATE TABLE t2(rowid int, x int, y int);\n    INSERT INTO t2 VALUES(0,2,3);\n    INSERT INTO t2 VALUES(4,5,6);\n    INSERT INTO t2 VALUES(7,8,9);\n    SELECT * FROM t2 ORDER BY x;\n  }\n} {0 2 3 4 5 6 7 8 9}\ndo_test rowid-3.2 {\n  execsql {SELECT * FROM t2 ORDER BY rowid}\n} {0 2 3 4 5 6 7 8 9}\ndo_test rowid-3.3 {\n  execsql {SELECT rowid, x, y FROM t2 ORDER BY rowid}\n} {0 2 3 4 5 6 7 8 9}\ndo_test rowid-3.4 {\n  set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]\n  foreach {a b c d e f} $r1 {}\n  set r2 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY x DESC}]\n  foreach {u v w x y z} $r2 {}\n  expr {$u==$e && $w==$c && $y==$a}\n} {1}\n# sqlite3 v3 - do_probtest doesn't exist anymore?\nif 0 {\ndo_probtest rowid-3.5 {\n  set r1 [execsql {SELECT _rowid_, rowid FROM t2 ORDER BY rowid}]\n  foreach {a b c d e f} $r1 {}\n  expr {$a!=$b && $c!=$d && $e!=$f}\n} {1}\n}\n\n# Let's try some more complex examples, including some joins.\n#\ndo_test rowid-4.1 {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM t2;\n  }\n  for {set i 1} {$i<=50} {incr i} {\n    execsql \"INSERT INTO t1(x,y) VALUES($i,[expr {$i*$i}])\"\n  }\n  execsql {INSERT INTO t2 SELECT _rowid_, x*y, y*y FROM t1}\n  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}\n} {256}\ndo_test rowid-4.2 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}\n} {256}\ndo_test rowid-4.2.1 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.oid==t2.rowid}\n} {256}\ndo_test rowid-4.2.2 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}\n} {256}\ndo_test rowid-4.2.3 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t2.rowid==t1.rowid}\n} {256}\ndo_test rowid-4.2.4 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND t1.x==4}\n} {256}\ndo_test rowid-4.2.5 {\n  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}\n} {256}\ndo_test rowid-4.2.6 {\n  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t2.rowid==t1.rowid}\n} {256}\ndo_test rowid-4.2.7 {\n  execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND t1.x==4}\n} {256}\ndo_test rowid-4.3 {\n  execsql {CREATE INDEX idxt1 ON t1(x)}\n  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1.rowid==t2.rowid}\n} {256}\ndo_test rowid-4.3.1 {\n  execsql {SELECT t2.y FROM t1, t2 WHERE t1.x==4 AND t1._rowid_==t2.rowid}\n} {256}\ndo_test rowid-4.3.2 {\n  execsql {SELECT t2.y FROM t1, t2 WHERE t2.rowid==t1.oid AND 4==t1.x}\n} {256}\ndo_test rowid-4.4 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1.rowid==t2.rowid}\n} {256}\ndo_test rowid-4.4.1 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t1.x==4 AND t1._rowid_==t2.rowid}\n} {256}\ndo_test rowid-4.4.2 {\n  execsql {SELECT t2.y FROM t2, t1 WHERE t2.rowid==t1.oid AND 4==t1.x}\n} {256}\ndo_test rowid-4.5 {\n  execsql {CREATE INDEX idxt2 ON t2(y)}\n  set sqlite_search_count 0\n  concat [execsql {\n    SELECT t1.x FROM t2, t1 \n    WHERE t2.y==256 AND t1.rowid==t2.rowid\n  }] $sqlite_search_count\n} {4 3}\ndo_test rowid-4.5.1 {\n  set sqlite_search_count 0\n  concat [execsql {\n    SELECT t1.x FROM t2, t1 \n    WHERE t1.OID==t2.rowid AND t2.y==81\n  }] $sqlite_search_count\n} {3 3}\ndo_test rowid-4.6 {\n  execsql {\n    SELECT t1.x FROM t1, t2\n    WHERE t2.y==256 AND t1.rowid==t2.rowid\n  }\n} {4}\n\ndo_test rowid-5.1.1 {\n  ifcapable subquery {\n    execsql {DELETE FROM t1 WHERE _rowid_ IN (SELECT oid FROM t1 WHERE x>8)}\n  } else {\n    set oids [execsql {SELECT oid FROM t1 WHERE x>8}]\n    set where \"_rowid_ = [join $oids { OR _rowid_ = }]\"\n    execsql \"DELETE FROM t1 WHERE $where\"\n  }\n} {}\ndo_test rowid-5.1.2 {\n  execsql {SELECT max(x) FROM t1}\n} {8}\n\n# Make sure a \"WHERE rowid=X\" clause works when there is no ROWID of X.\n#\ndo_test rowid-6.1 {\n  execsql {\n    SELECT x FROM t1\n  }\n} {1 2 3 4 5 6 7 8}\ndo_test rowid-6.2 {\n  for {set ::norow 1} {1} {incr ::norow} {\n    if {[execsql \"SELECT x FROM t1 WHERE rowid=$::norow\"]==\"\"}  break\n  }\n  execsql [subst {\n    DELETE FROM t1 WHERE rowid=$::norow\n  }]\n} {}\ndo_test rowid-6.3 {\n  execsql {\n    SELECT x FROM t1\n  }\n} {1 2 3 4 5 6 7 8}\n\n# Beginning with version 2.3.4, SQLite computes rowids of new rows by\n# finding the maximum current rowid and adding one.  It falls back to\n# the old random algorithm if the maximum rowid is the largest integer.\n# The following tests are for this new behavior.\n#\ndo_test rowid-7.0 {\n  execsql {\n    DELETE FROM t1;\n    DROP TABLE t2;\n    DROP INDEX idxt1;\n    INSERT INTO t1 VALUES(1,2);\n    SELECT rowid, * FROM t1;\n  }\n} {1 1 2}\ndo_test rowid-7.1 {\n  execsql {\n    INSERT INTO t1 VALUES(99,100);\n    SELECT rowid,* FROM t1\n  }\n} {1 1 2 2 99 100}\ndo_test rowid-7.2 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t2(b) VALUES(55);\n    SELECT * FROM t2;\n  }\n} {1 55}\ndo_test rowid-7.3 {\n  execsql {\n    INSERT INTO t2(b) VALUES(66);\n    SELECT * FROM t2;\n  }\n} {1 55 2 66}\ndo_test rowid-7.4 {\n  execsql {\n    INSERT INTO t2(a,b) VALUES(1000000,77);\n    INSERT INTO t2(b) VALUES(88);\n    SELECT * FROM t2;\n  }\n} {1 55 2 66 1000000 77 1000001 88}\ndo_test rowid-7.5 {\n  execsql {\n    INSERT INTO t2(a,b) VALUES(2147483647,99);\n    INSERT INTO t2(b) VALUES(11);\n    SELECT b FROM t2 ORDER BY b;\n  }\n} {11 55 66 77 88 99}\nifcapable subquery {\n  do_test rowid-7.6 {\n    execsql {\n      SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647);\n    }\n  } {11}\n  do_test rowid-7.7 {\n    execsql {\n      INSERT INTO t2(b) VALUES(22);\n      INSERT INTO t2(b) VALUES(33);\n      INSERT INTO t2(b) VALUES(44);\n      INSERT INTO t2(b) VALUES(55);\n      SELECT b FROM t2 WHERE a NOT IN(1,2,1000000,1000001,2147483647) \n          ORDER BY b;\n    }\n  } {11 22 33 44 55}\n}\ndo_test rowid-7.8 {\n  execsql {\n    DELETE FROM t2 WHERE a!=2;\n    INSERT INTO t2(b) VALUES(111);\n    SELECT * FROM t2;\n  }\n} {2 66 3 111}\n\nifcapable {trigger} {\n# Make sure AFTER triggers that do INSERTs do not change the last_insert_rowid.\n# Ticket #290\n#\ndo_test rowid-8.1 {\n  execsql {\n    CREATE TABLE t3(a integer primary key);\n    CREATE TABLE t4(x);\n    INSERT INTO t4 VALUES(1);\n    CREATE TRIGGER r3 AFTER INSERT on t3 FOR EACH ROW BEGIN\n      INSERT INTO t4 VALUES(NEW.a+10);\n    END;\n    SELECT * FROM t3;\n  }\n} {}\ndo_test rowid-8.2 {\n  execsql {\n    SELECT rowid, * FROM t4;\n  }\n} {1 1}\ndo_test rowid-8.3 {\n  execsql {\n    INSERT INTO t3 VALUES(123);\n    SELECT last_insert_rowid();\n  }\n} {123}\ndo_test rowid-8.4 {\n  execsql {\n    SELECT * FROM t3;\n  }\n} {123}\ndo_test rowid-8.5 {\n  execsql {\n    SELECT rowid, * FROM t4;\n  }\n} {1 1 2 133}\ndo_test rowid-8.6 {\n  execsql {\n    INSERT INTO t3 VALUES(NULL);\n    SELECT last_insert_rowid();\n  }\n} {124}\ndo_test rowid-8.7 {\n  execsql {\n    SELECT * FROM t3;\n  }\n} {123 124}\ndo_test rowid-8.8 {\n  execsql {\n    SELECT rowid, * FROM t4;\n  }\n} {1 1 2 133 3 134}\n} ;# endif trigger\n\n# If triggers are not enable, simulate their effect for the tests that\n# follow.\nifcapable {!trigger} {\n  execsql {\n    CREATE TABLE t3(a integer primary key);\n    INSERT INTO t3 VALUES(123);\n    INSERT INTO t3 VALUES(124);\n  }\n}\n\n# ticket #377: Comparison between integer primiary key and floating point\n# values.\n#\ndo_test rowid-9.1 {\n  execsql {\n    SELECT * FROM t3 WHERE a<123.5\n  }\n} {123}\ndo_test rowid-9.2 {\n  execsql {\n    SELECT * FROM t3 WHERE a<124.5\n  }\n} {123 124}\ndo_test rowid-9.3 {\n  execsql {\n    SELECT * FROM t3 WHERE a>123.5\n  }\n} {124}\ndo_test rowid-9.4 {\n  execsql {\n    SELECT * FROM t3 WHERE a>122.5\n  }\n} {123 124}\ndo_test rowid-9.5 {\n  execsql {\n    SELECT * FROM t3 WHERE a==123.5\n  }\n} {}\ndo_test rowid-9.6 {\n  execsql {\n    SELECT * FROM t3 WHERE a==123.000\n  }\n} {123}\ndo_test rowid-9.7 {\n  execsql {\n    SELECT * FROM t3 WHERE a>100.5 AND a<200.5\n  }\n} {123 124}\ndo_test rowid-9.8 {\n  execsql {\n    SELECT * FROM t3 WHERE a>'xyz';\n  }\n} {}\ndo_test rowid-9.9 {\n  execsql {\n    SELECT * FROM t3 WHERE a<'xyz';\n  }\n} {123 124}\ndo_test rowid-9.10 {\n  execsql {\n    SELECT * FROM t3 WHERE a>=122.9 AND a<=123.1\n  }\n} {123}\n\n# Ticket #567.  Comparisons of ROWID or integery primary key against\n# floating point numbers still do not always work.\n#\ndo_test rowid-10.1 {\n  execsql {\n    CREATE TABLE t5(a);\n    INSERT INTO t5 VALUES(1);\n    INSERT INTO t5 VALUES(2);\n    INSERT INTO t5 SELECT a+2 FROM t5;\n    INSERT INTO t5 SELECT a+4 FROM t5;\n    SELECT rowid, * FROM t5;\n  }\n} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}\ndo_test rowid-10.2 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5}\n} {6 6 7 7 8 8}\ndo_test rowid-10.3 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0}\n} {5 5 6 6 7 7 8 8}\ndo_test rowid-10.4 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5}\n} {6 6 7 7 8 8}\ndo_test rowid-10.3.2 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0}\n} {6 6 7 7 8 8}\ndo_test rowid-10.5 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid}\n} {6 6 7 7 8 8}\ndo_test rowid-10.6 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid}\n} {6 6 7 7 8 8}\ndo_test rowid-10.7 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5}\n} {1 1 2 2 3 3 4 4 5 5}\ndo_test rowid-10.8 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5}\n} {1 1 2 2 3 3 4 4 5 5}\ndo_test rowid-10.9 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid}\n} {1 1 2 2 3 3 4 4 5 5}\ndo_test rowid-10.10 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid}\n} {1 1 2 2 3 3 4 4 5 5}\ndo_test rowid-10.11 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.5 ORDER BY rowid DESC}\n} {8 8 7 7 6 6}\ndo_test rowid-10.11.2 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>=5.0 ORDER BY rowid DESC}\n} {8 8 7 7 6 6 5 5}\ndo_test rowid-10.12 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.5 ORDER BY rowid DESC}\n} {8 8 7 7 6 6}\ndo_test rowid-10.12.2 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>5.0 ORDER BY rowid DESC}\n} {8 8 7 7 6 6}\ndo_test rowid-10.13 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5<=rowid ORDER BY rowid DESC}\n} {8 8 7 7 6 6}\ndo_test rowid-10.14 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5<rowid ORDER BY rowid DESC}\n} {8 8 7 7 6 6}\ndo_test rowid-10.15 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<=5.5 ORDER BY rowid DESC}\n} {5 5 4 4 3 3 2 2 1 1}\ndo_test rowid-10.16 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<5.5 ORDER BY rowid DESC}\n} {5 5 4 4 3 3 2 2 1 1}\ndo_test rowid-10.17 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5>=rowid ORDER BY rowid DESC}\n} {5 5 4 4 3 3 2 2 1 1}\ndo_test rowid-10.18 {\n  execsql {SELECT rowid, a FROM t5 WHERE 5.5>rowid ORDER BY rowid DESC}\n} {5 5 4 4 3 3 2 2 1 1}\n\ndo_test rowid-10.30 {\n  execsql {\n    CREATE TABLE t6(a);\n    INSERT INTO t6(rowid,a) SELECT -a,a FROM t5;\n    SELECT rowid, * FROM t6;\n  }\n} {-8 8 -7 7 -6 6 -5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.31.1 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5}\n} {-5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.31.2 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0}\n} {-5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.32.1 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.5 ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4 -5 5}\ndo_test rowid-10.32.1 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>=-5.0 ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4 -5 5}\ndo_test rowid-10.33 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid}\n} {-5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.34 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5<=rowid ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4 -5 5}\ndo_test rowid-10.35.1 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5}\n} {-5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.35.2 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0}\n} {-4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.36.1 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.5 ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4 -5 5}\ndo_test rowid-10.36.2 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid>-5.0 ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4}\ndo_test rowid-10.37 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid}\n} {-5 5 -4 4 -3 3 -2 2 -1 1}\ndo_test rowid-10.38 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5<rowid ORDER BY rowid DESC}\n} {-1 1 -2 2 -3 3 -4 4 -5 5}\ndo_test rowid-10.39 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5}\n} {-8 8 -7 7 -6 6}\ndo_test rowid-10.40 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid<=-5.5 ORDER BY rowid DESC}\n} {-6 6 -7 7 -8 8}\ndo_test rowid-10.41 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid}\n} {-8 8 -7 7 -6 6}\ndo_test rowid-10.42 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5>=rowid ORDER BY rowid DESC}\n} {-6 6 -7 7 -8 8}\ndo_test rowid-10.43 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5}\n} {-8 8 -7 7 -6 6}\ndo_test rowid-10.44 {\n  execsql {SELECT rowid, a FROM t6 WHERE rowid<-5.5 ORDER BY rowid DESC}\n} {-6 6 -7 7 -8 8}\ndo_test rowid-10.44 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid}\n} {-8 8 -7 7 -6 6}\ndo_test rowid-10.46 {\n  execsql {SELECT rowid, a FROM t6 WHERE -5.5>rowid ORDER BY rowid DESC}\n} {-6 6 -7 7 -8 8}\n\n# Comparison of rowid against string values.\n#\ndo_test rowid-11.1 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>'abc'}\n} {}\ndo_test rowid-11.2 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid>='abc'}\n} {}\ndo_test rowid-11.3 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<'abc'}\n} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}\ndo_test rowid-11.4 {\n  execsql {SELECT rowid, a FROM t5 WHERE rowid<='abc'}\n} {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}\n\n# Test the automatic generation of rowids when the table already contains\n# a rowid with the maximum value.\n#\n# Once the maximum rowid is taken, rowids are normally chosen at\n# random.  By by reseting the random number generator, we can cause\n# the rowid guessing loop to collide with prior rowids, and test the\n# loop out to its limit of 100 iterations.  After 100 collisions, the\n# rowid guesser gives up and reports SQLITE_FULL.\n#\ndo_test rowid-12.1 {\n  execsql {\n    CREATE TABLE t7(x INTEGER PRIMARY KEY, y);\n    CREATE TABLE t7temp(a INTEGER PRIMARY KEY);\n    INSERT INTO t7 VALUES(9223372036854775807,'a');\n    SELECT y FROM t7;\n  }\n} {a}\ndo_test rowid-12.2 {\n  db close\n  sqlite3 db test.db\n  save_prng_state\n  execsql {\n    INSERT INTO t7 VALUES(NULL,'b');\n    SELECT x, y FROM t7 ORDER BY x;\n  }\n} {/\\d+ b 9223372036854775807 a/}\nexecsql {INSERT INTO t7 VALUES(2,'y');}\nfor {set i 1} {$i<100} {incr i} {\n  do_test rowid-12.3.$i {\n    db eval {DELETE FROM t7temp; INSERT INTO t7temp VALUES(1);}\n    restore_prng_state\n    execsql {\n      INSERT INTO t7 VALUES(NULL,'x');\n      SELECT count(*) FROM t7 WHERE y=='x';\n    }\n  } $i\n}\ndo_test rowid-12.4 {\n  db eval {DELETE FROM t7temp; INSERT INTO t7temp VALUES(1);}\n  restore_prng_state\n  catchsql {\n    INSERT INTO t7 VALUES(NULL,'x');\n  }\n} {1 {database or disk is full}}\n\n# INSERTs that happen inside of nested function calls are recorded\n# by last_insert_rowid.\n#\nproc rowid_addrow_func {n} {\n  db eval {INSERT INTO t13(rowid,x) VALUES($n,$n*$n)}\n  return [db last_insert_rowid]\n}\ndb function addrow rowid_addrow_func\ndo_execsql_test rowid-13.1 {\n  CREATE TABLE t13(x);\n  INSERT INTO t13(rowid,x) VALUES(1234,5);\n  SELECT rowid, x, addrow(rowid+1000), '|' FROM t13 LIMIT 3;\n  SELECT last_insert_rowid();\n} {1234 5 2234 | 2234 4990756 3234 | 3234 10458756 4234 | 4234}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue.test",
    "content": "# 2016 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue\n\ndo_execsql_test 0.0 {\n  CREATE TABLE one(o);\n  INSERT INTO one VALUES(1);\n}\n\nforeach {tn v1 v2 eq ne is isnot} {\n  1 \"1, 2, 3\"    \"1, 2, 3\"                   1  0     1 0\n  2 \"1, 0, 3\"    \"1, 2, 3\"                   0  1     0 1\n  3 \"1, 2, NULL\" \"1, 2, 3\"                   {} {}    0 1\n  4 \"1, 2, NULL\" \"1, 2, NULL\"                {} {}    1 0\n  5 \"NULL, NULL, NULL\" \"NULL, NULL, NULL\"    {} {}    1 0\n\n  6 \"1, NULL, 1\" \"1, 1, 1\"                   {} {}    0 1\n  7 \"1, NULL, 1\" \"1, 1, 2\"                   0  1     0 1\n} {\n  do_execsql_test 1.$tn.eq \"SELECT ($v1) == ($v2)\" [list $eq]\n  do_execsql_test 1.$tn.ne \"SELECT ($v1) != ($v2)\" [list $ne]\n\n  do_execsql_test 1.$tn.is    \"SELECT ($v1) IS ($v2)\"     [list $is]\n  do_execsql_test 1.$tn.isnot \"SELECT ($v1) IS NOT ($v2)\" [list $isnot]\n\n  do_execsql_test 1.$tn.2.eq \"SELECT (SELECT $v1) == (SELECT $v2)\" [list $eq]\n  do_execsql_test 1.$tn.2.ne \"SELECT (SELECT $v1) != (SELECT $v2)\" [list $ne]\n}\n\nforeach {tn v1 v2 lt gt le ge} {\n  1 \"(1, 1, 3)\"    \"(1, 2, 3)\"                   1 0      1 0\n  2 \"(1, 2, 3)\"    \"(1, 2, 3)\"                   0 0      1 1\n  3 \"(1, 3, 3)\"    \"(1, 2, 3)\"                   0 1      0 1\n\n  4 \"(1, NULL, 3)\"    \"(1, 2, 3)\"                {} {}      {} {}\n  5 \"(1, 3, 3)\"    \"(1, NULL, 3)\"                {} {}      {} {}\n  6 \"(1, NULL, 3)\"    \"(1, NULL, 3)\"             {} {}      {} {}\n} {\n  foreach {tn2 expr res} [list \\\n    2.$tn.lt \"$v1 < $v2\" $lt   \\\n    2.$tn.gt \"$v1 > $v2\" $gt   \\\n    2.$tn.le \"$v1 <= $v2\" $le   \\\n    2.$tn.ge \"$v1 >= $v2\" $ge   \\\n  ] {\n    do_execsql_test $tn2 \"SELECT $expr\" [list $res]\n\n    set map(0) [list]\n    set map() [list]\n    set map(1) [list 1]\n    do_execsql_test $tn2.where1 \"SELECT * FROM one WHERE $expr\" $map($res)\n\n    set map(0) [list 1]\n    set map() [list]\n    set map(1) [list]\n    do_execsql_test $tn2.where2 \"SELECT * FROM one WHERE NOT $expr\" $map($res)\n  }\n}\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 1);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(2, 3);\n  INSERT INTO t1 VALUES(2, 4);\n  INSERT INTO t1 VALUES(3, 5);\n  INSERT INTO t1 VALUES(3, 6);\n}\n\nforeach {tn r order} {\n  1 \"(1, 1)\"           \"ORDER BY y\"\n  2 \"(1, 1)\"           \"ORDER BY x, y\"\n  3 \"(1, 2)\"           \"ORDER BY x, y DESC\"\n  4 \"(3, 6)\"           \"ORDER BY x DESC, y DESC\"\n  5 \"((3, 5))\"         \"ORDER BY x DESC, y\"\n  6 \"(SELECT 3, 5)\"    \"ORDER BY x DESC, y\"\n} {\n  do_execsql_test 3.$tn.1 \"SELECT $r == (SELECT x,y FROM t1 $order)\" 1\n  do_execsql_test 3.$tn.2 \"SELECT $r == (SELECT * FROM t1 $order)\" 1\n\n  do_execsql_test 3.$tn.3 \"\n    SELECT (SELECT * FROM t1 $order) == (SELECT * FROM t1 $order)\n  \" 1\n  do_execsql_test 3.$tn.4 \"\n    SELECT (SELECT 0, 0) == (SELECT * FROM t1 $order)\n  \" 0\n}\n\nforeach {tn expr res} {\n  1 {(2, 2) BETWEEN (2, 2) AND (3, 3)} 1\n  2 {(2, 2) BETWEEN (2, NULL) AND (3, 3)} {}\n  3 {(2, 2) BETWEEN (3, NULL) AND (3, 3)} 0\n} {\n  do_execsql_test 4.$tn \"SELECT $expr\" [list $res]\n}\n\nforeach {tn expr res} {\n  1 {(2, 4) IN (SELECT * FROM t1)} 1\n  2 {(3, 4) IN (SELECT * FROM t1)} 0\n\n  3 {(NULL, 4) IN (SELECT * FROM t1)} {}\n  4 {(NULL, 0) IN (SELECT * FROM t1)} 0\n\n  5 {(NULL, 4) NOT IN (SELECT * FROM t1)} {}\n  6 {(NULL, 0) NOT IN (SELECT * FROM t1)} 1\n} {\n  do_execsql_test 5.$tn \"SELECT $expr\" [list $res]\n}\n\ndo_execsql_test 6.0 {\n  CREATE TABLE hh(a, b, c);\n  INSERT INTO hh VALUES('abc', 1, 'i');\n  INSERT INTO hh VALUES('ABC', 1, 'ii');\n  INSERT INTO hh VALUES('def', 2, 'iii');\n  INSERT INTO hh VALUES('DEF', 2, 'iv');\n  INSERT INTO hh VALUES('GHI', 3, 'v');\n  INSERT INTO hh VALUES('ghi', 3, 'vi');\n\n  CREATE INDEX hh_ab ON hh(a, b); \n}\n\ndo_execsql_test 6.1 {\n  SELECT c FROM hh WHERE (a, b) = (SELECT 'abc', 1);\n} {i}\ndo_execsql_test 6.2 {\n  SELECT c FROM hh WHERE (a, b) = (SELECT 'abc' COLLATE nocase, 1);\n} {i}\ndo_execsql_test 6.3 {\n  SELECT c FROM hh WHERE a = (SELECT 'abc' COLLATE nocase) AND b = (SELECT 1);\n} {i}\ndo_execsql_test 6.4 {\n  SELECT c FROM hh WHERE +a = (SELECT 'abc' COLLATE nocase) AND b = (SELECT 1);\n} {i}\ndo_execsql_test 6.5 {\n  SELECT c FROM hh WHERE a = (SELECT 'abc') COLLATE nocase AND b = (SELECT 1);\n} {i ii}\ndo_catchsql_test 6.6 {\n  SELECT c FROM hh WHERE (a, b) = (SELECT 'abc', 1) COLLATE nocase;\n} {1 {row value misused}}\ndo_catchsql_test 6.7 {\n  SELECT c FROM hh WHERE (a, b) = 1;\n} {1 {row value misused}}\ndo_execsql_test 6.8 {\n  SELECT c FROM hh WHERE (a COLLATE nocase, b) = (SELECT 'def', 2);\n} {iii iv}\ndo_execsql_test 6.9 {\n  SELECT c FROM hh WHERE (a COLLATE nocase, b) IS NOT (SELECT 'def', 2);\n} {i ii v vi}\ndo_execsql_test 6.10 {\n  SELECT c FROM hh WHERE (b, a) = (SELECT 2, 'def');\n} {iii}\n\ndo_execsql_test 7.0 {\n  CREATE TABLE xy(i INTEGER PRIMARY KEY, j, k);\n  INSERT INTO xy VALUES(1, 1, 1);\n  INSERT INTO xy VALUES(2, 2, 2);\n  INSERT INTO xy VALUES(3, 3, 3);\n  INSERT INTO xy VALUES(4, 4, 4);\n}\n\n\nforeach {tn sql res eqp} {\n  1 \"SELECT * FROM xy WHERE (i, j) IS (2, 2)\" {2 2 2} \n    \"0 0 0 {SEARCH TABLE xy USING INTEGER PRIMARY KEY (rowid=?)}\"\n\n  2 \"SELECT * FROM xy WHERE (k, j) < (2, 3)\" {1 1 1 2 2 2}\n    \"0 0 0 {SCAN TABLE xy}\"\n\n  3 \"SELECT * FROM xy WHERE (i, j) < (2, 3)\" {1 1 1 2 2 2}\n    \"0 0 0 {SEARCH TABLE xy USING INTEGER PRIMARY KEY (rowid<?)}\"\n\n  4 \"SELECT * FROM xy WHERE (i, j) > (2, 1)\" {2 2 2 3 3 3 4 4 4}\n    \"0 0 0 {SEARCH TABLE xy USING INTEGER PRIMARY KEY (rowid>?)}\"\n\n  5 \"SELECT * FROM xy WHERE (i, j) > ('2', 1)\" {2 2 2 3 3 3 4 4 4}\n    \"0 0 0 {SEARCH TABLE xy USING INTEGER PRIMARY KEY (rowid>?)}\"\n\n} {\n  do_eqp_test 7.$tn.1 $sql $eqp\n  do_execsql_test 7.$tn.2 $sql $res\n}\n\ndo_execsql_test 8.0 {\n  CREATE TABLE j1(a);\n}\ndo_execsql_test 8.1 {\n  SELECT * FROM j1 WHERE (select min(a) FROM j1) IN (?, ?, ?)\n}\n\ndo_execsql_test 9.0 {\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);\n  INSERT INTO t2 VALUES(1, 1, 1);\n  INSERT INTO t2 VALUES(2, 2, 2);\n  INSERT INTO t2 VALUES(3, 3, 3);\n  INSERT INTO t2 VALUES(4, 4, 4);\n  INSERT INTO t2 VALUES(5, 5, 5);\n}\n\nforeach {tn q res} {\n  1 \"(a, b) > (2, 1)\" {2 3 4 5}\n  2 \"(a, b) > (2, 2)\" {3 4 5}\n  3 \"(a, b) < (4, 5)\" {1 2 3 4}\n  4 \"(a, b) < (4, 3)\" {1 2 3}\n} {\n  do_execsql_test 9.$tn \"SELECT c FROM t2 WHERE $q\" $res\n} \n\ndo_execsql_test 10.0 {\n  CREATE TABLE dual(dummy); INSERT INTO dual(dummy) VALUES('X');\n  CREATE TABLE t3(a TEXT,b TEXT,c TEXT,d TEXT,e TEXT,f TEXT);\n  CREATE INDEX t3x ON t3(b,c,d,e,f);\n\n  SELECT a FROM t3\n    WHERE (c,d) IN (SELECT 'c','d' FROM dual)\n    AND (a,b,e) IN (SELECT 'a','b','d' FROM dual);\n}\n\ndo_catchsql_test 11.1 {\n  CREATE TABLE t11(a);\n  SELECT * FROM t11 WHERE (a,a)<=1;\n} {1 {row value misused}}\ndo_catchsql_test 11.2 {\n  SELECT * FROM t11 WHERE (a,a)<1;\n} {1 {row value misused}}\ndo_catchsql_test 11.3 {\n  SELECT * FROM t11 WHERE (a,a)>=1;\n} {1 {row value misused}}\ndo_catchsql_test 11.4 {\n  SELECT * FROM t11 WHERE (a,a)>1;\n} {1 {row value misused}}\ndo_catchsql_test 11.5 {\n  SELECT * FROM t11 WHERE (a,a)==1;\n} {1 {row value misused}}\ndo_catchsql_test 11.6 {\n  SELECT * FROM t11 WHERE (a,a)<>1;\n} {1 {row value misused}}\ndo_catchsql_test 11.7 {\n  SELECT * FROM t11 WHERE (a,a) IS 1;\n} {1 {row value misused}}\ndo_catchsql_test 11.8 {\n  SELECT * FROM t11 WHERE (a,a) IS NOT 1;\n} {1 {row value misused}}\n\n# 2016-10-27: https://www.sqlite.org/src/tktview/fef4bb4bd9185ec8f\n# Incorrect result from a LEFT JOIN with a row-value constraint\n#\ndo_execsql_test 12.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(x,y); INSERT INTO t2 VALUES(3,4);\n  SELECT *,'x' FROM t1 LEFT JOIN t2 ON (a,b)=(x,y);\n} {1 2 {} {} x}\n\n\nforeach {tn sql} {\n  0 \"SELECT (1,2) AS x WHERE x=3\"\n  1 \"SELECT (1,2) BETWEEN 1 AND 2\"\n  2 \"SELECT 1 BETWEEN (1,2) AND 2\"\n  3 \"SELECT 2 BETWEEN 1 AND (1,2)\"\n  4 \"SELECT (1,2) FROM (SELECT 1) ORDER BY 1\"\n  5 \"SELECT (1,2) FROM (SELECT 1) GROUP BY 1\"\n} {\n  do_catchsql_test 13.$tn $sql {1 {row value misused}}\n}\n\ndo_execsql_test 14.0 {\n  CREATE TABLE t12(x);\n  INSERT INTO t12 VALUES(2), (4);\n}\ndo_execsql_test 14.1 \"SELECT 1 WHERE (2,2) BETWEEN (1,1) AND (3,3)\" 1\ndo_execsql_test 14.2 \"SELECT CASE (2,2) WHEN (1, 1) THEN 2 ELSE 1 END\" 1\ndo_execsql_test 14.3 \"SELECT CASE (SELECT 2,2) WHEN (1, 1) THEN 2 ELSE 1 END\" 1\ndo_execsql_test 14.4 \"SELECT 1 WHERE (SELECT 2,2) BETWEEN (1,1) AND (3,3)\" 1\ndo_execsql_test 14.5 \"SELECT 1 FROM t12 WHERE (x,1) BETWEEN (1,1) AND (3,3)\" 1\ndo_execsql_test 14.6 {\n  SELECT 1 FROM t12 WHERE (1,x) BETWEEN (1,1) AND (3,3)\n} {1 1}\n\n#-------------------------------------------------------------------------\n# Test that errors are not concealed by the SELECT flattening or\n# WHERE-clause push-down optimizations.\ndo_execsql_test 14.1 {\n  CREATE TABLE x1(a PRIMARY KEY, b);\n  CREATE TABLE x2(a INTEGER PRIMARY KEY, b);\n}\n\nforeach {tn n sql} {\n  1 0 \"SELECT * FROM (SELECT (1, 1) AS c FROM x1) WHERE c=1\"\n  2 2 \"SELECT * FROM (SELECT 1 AS x, (SELECT 8,9) AS y) WHERE y<1\"\n  3 3 \"SELECT * FROM (SELECT 1 AS x, (SELECT 8,9,10) AS y) WHERE y<1\"\n  4 0 \"SELECT * FROM (SELECT (a, b) AS c FROM x1), x2 WHERE c=a\"\n  5 0 \"SELECT * FROM (SELECT a AS c, (1, 2, 3) FROM x1), x2 WHERE c=a\"\n  6 0 \"SELECT * FROM (SELECT 1 AS c, (1, 2, 3) FROM x1) WHERE c=1\"\n} {\n  if {$n==0} {\n    set err \"row value misused\"\n  } else {\n    set err \"sub-select returns $n columns - expected 1\"\n  }\n  do_catchsql_test 14.2.$tn $sql [list 1 $err]\n}\n\n#--------------------------------------------------------------------------\n# Test for vector size mismatches concealed by unexpanded subqueries.\n#\ndo_catchsql_test 15.1 {\n  DETACH (SELECT * FROM (SELECT 1,2))<3;\n} {1 {row value misused}}\ndo_catchsql_test 15.2 {\n  UPDATE x1 SET a=(SELECT * FROM (SELECT b,2))<3;\n} {1 {row value misused}}\ndo_catchsql_test 15.3 {\n  UPDATE x1 SET a=NULL WHERE  a<(SELECT * FROM (SELECT b,2));\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_catchsql_test 15.4 {\n  DELETE FROM x1 WHERE  a<(SELECT * FROM (SELECT b,2));\n} {1 {sub-select returns 2 columns - expected 1}}\ndo_catchsql_test 15.5 {\n  INSERT INTO x1(a,b) VALUES(1,(SELECT * FROM (SELECT 1,2))<3);\n} {1 {row value misused}}\n\n#-------------------------------------------------------------------------\n# Row-values used in UPDATE statements within TRIGGERs\n#\n# Ticket https://www.sqlite.org/src/info/8c9458e703666e1a\n#\ndo_execsql_test 16.1 {\n  CREATE TABLE t16a(a,b,c);\n  INSERT INTO t16a VALUES(1,2,3);\n  CREATE TABLE t16b(x);\n  INSERT INTO t16b(x) VALUES(1);\n  CREATE TRIGGER t16r AFTER UPDATE ON t16b BEGIN\n     UPDATE t16a SET (a,b,c)=(SELECT new.x,new.x+1,new.x+2);\n  END;\n  UPDATE t16b SET x=7;\n  SELECT * FROM t16a;\n} {7 8 9}\ndo_execsql_test 16.2 {\n  UPDATE t16b SET x=97;\n  SELECT * FROM t16a;\n} {97 98 99}\n\ndo_execsql_test 16.3 {\n  CREATE TABLE t16c(a, b, c, d, e);\n  INSERT INTO t16c VALUES(1, 'a', 'b', 'c', 'd');\n  CREATE TRIGGER t16c1 AFTER INSERT ON t16c BEGIN\n    UPDATE t16c SET (c, d) = (SELECT 'A', 'B'), (e, b) = (SELECT 'C', 'D')\n      WHERE a = new.a-1;\n  END;\n\n  SELECT * FROM t16c;\n} {1 a b c d}\n\ndo_execsql_test 16.4 {\n  INSERT INTO t16c VALUES(2, 'w', 'x', 'y', 'z');\n  SELECT * FROM t16c;\n} {\n  1 D A B C \n  2 w x y z\n}\n\ndo_execsql_test 16.5 {\n  DROP TRIGGER t16c1;\n  PRAGMA recursive_triggers = 1;\n  INSERT INTO t16c VALUES(3, 'i', 'ii', 'iii', 'iv');\n  CREATE TRIGGER t16c1 AFTER UPDATE ON t16c WHEN new.a>1 BEGIN\n    UPDATE t16c SET (e, d) = (\n      SELECT b, c FROM t16c WHERE a = new.a-1\n    ), (c, b) = (\n      SELECT d, e FROM t16c WHERE a = new.a-1\n    ) WHERE a = new.a-1;\n  END;\n\n  UPDATE t16c SET a=a WHERE a=3;\n  SELECT * FROM t16c;\n} {\n  1 C B A D\n  2 z y x w\n  3 i ii iii iv\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue2.test",
    "content": "# 2016 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue2\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(0, 0, 0);\n  INSERT INTO t1 VALUES(0, 1, 1);\n  INSERT INTO t1 VALUES(1, 0, 2);\n  INSERT INTO t1 VALUES(1, 1, 3);\n\n  CREATE INDEX i1 ON t1(a, b);\n}\n\ndo_execsql_test 1.1.1 { SELECT c FROM t1 WHERE (a, b) >= (1, 0) } {2 3} \ndo_execsql_test 1.1.2 { SELECT c FROM t1 WHERE (a, b) > (1, 0)  } {3}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 2.0.1 {\n  CREATE TABLE t2(a INTEGER, b INTEGER, c INTEGER, d INTEGER);\n  CREATE INDEX i2 ON t2(a, b, c);\n}\ndo_test 2.0.2 {\n  foreach a {0 1 2 3} {\n  foreach b {0 1 2 3} {\n  foreach c {0 1 2 3} {\n    execsql { INSERT INTO t2 VALUES($a, $b, $c, $c + $b*4 + $a*16); }\n  }}}\n} {}\n\ndo_execsql_test 2.1 {\n  SELECT d FROM t2 WHERE (a, b) > (2, 2);\n} [db eval { SELECT d FROM t2 WHERE a>2 OR (a=2 AND b>2) }]\n\ndo_execsql_test 2.2 {\n  SELECT d FROM t2 WHERE (a, b) >= (2, 2);\n} [db eval { SELECT d FROM t2 WHERE a>2 OR (a=2 AND b>=2) }]\n\ndo_execsql_test 2.3 {\n  SELECT d FROM t2 WHERE a=1 AND (b, c) >= (1, 2);\n} [db eval { SELECT d FROM t2 WHERE +a=1 AND (b>1 OR (b==1 AND c>=2)) }]\n\ndo_execsql_test 2.4 {\n  SELECT d FROM t2 WHERE a=1 AND (b, c) > (1, 2);\n} [db eval { SELECT d FROM t2 WHERE +a=1 AND (b>1 OR (b==1 AND c>2)) }]\n\n#-------------------------------------------------------------------------\n\nset words {\nairfare airfield airfields airflow airfoil\nairfoils airframe airframes airily airing\nairings airless airlift airlifts airline\nairliner airlines airlock airlocks airmail\nairmails airman airmen airplane airplanes\n\narraignment arraignments arraigns arrange arranged\narrangement arrangements arranger arrangers arranges\narranging arrant array arrayed arrays\narrears arrest arrested arrester arresters\narresting arrestingly arrestor arrestors arrests\n\nedifices edit edited editing edition\neditions editor editorial editorially editorials\neditors edits educable educate educated\neducates educating education educational educationally\neducations educator educators eel eelgrass\n}\n\ndo_test 3.0 {\n  execsql { CREATE TABLE t3(a, b, c, w); }\n  foreach w $words {\n    set a [string range $w 0 2]\n    set b [string range $w 3 5]\n    set c [string range $w 6 end]\n    execsql { INSERT INTO t3 VALUES($a, $b, $c, $w) }\n  }\n} {}\n\n\nforeach {tn idx} {\n  IDX1 {}\n  IDX2 { CREATE INDEX i3 ON t3(a, b, c); }\n  IDX3 { CREATE INDEX i3 ON t3(a, b); }\n  IDX4 { CREATE INDEX i3 ON t3(a); }\n} {\n  execsql { DROP INDEX IF EXISTS i3 }\n  execsql $idx\n\n  foreach w $words {\n    set a [string range $w 0 2]\n    set b [string range $w 3 5]\n    set c [string range $w 6 end]\n\n    foreach op [list > >= < <= == IS] {\n      do_execsql_test 3.1.$tn.$w.$op [subst -novar {\n        SELECT rowid FROM t3 WHERE (a, b, c) [set op] ($a, $b, $c) \n        ORDER BY +rowid\n      }] [db eval [subst -novar {\n        SELECT rowid FROM t3 WHERE w [set op] $w ORDER BY +rowid\n      }]]\n\n      do_execsql_test 3.1.$tn.$w.$op.subselect [subst -novar {\n        SELECT rowid FROM t3 WHERE (a, b, c) [set op] (\n          SELECT a, b, c FROM t3 WHERE w = $w\n        )\n        ORDER BY +rowid\n      }] [db eval [subst -novar {\n        SELECT rowid FROM t3 WHERE w [set op] $w ORDER BY +rowid\n      }]]\n    }\n\n  }\n}\n\n#-------------------------------------------------------------------------\n#\n\ndo_execsql_test 4.0 {\n  CREATE TABLE t4(a, b, c);\n  INSERT INTO t4 VALUES(NULL, NULL, NULL);\n  INSERT INTO t4 VALUES(NULL, NULL, 0);\n  INSERT INTO t4 VALUES(NULL, NULL, 1);\n  INSERT INTO t4 VALUES(NULL,    0, NULL);\n  INSERT INTO t4 VALUES(NULL,    0, 0);\n  INSERT INTO t4 VALUES(NULL,    0, 1);\n  INSERT INTO t4 VALUES(NULL,    1, NULL);\n  INSERT INTO t4 VALUES(NULL,    1, 0);\n  INSERT INTO t4 VALUES(NULL,    1, 1);\n\n  INSERT INTO t4 VALUES(   0, NULL, NULL);\n  INSERT INTO t4 VALUES(   0, NULL, 0);\n  INSERT INTO t4 VALUES(   0, NULL, 1);\n  INSERT INTO t4 VALUES(   0,    0, NULL);\n  INSERT INTO t4 VALUES(   0,    0, 0);\n  INSERT INTO t4 VALUES(   0,    0, 1);\n  INSERT INTO t4 VALUES(   0,    1, NULL);\n  INSERT INTO t4 VALUES(   0,    1, 0);\n  INSERT INTO t4 VALUES(   0,    1, 1);\n\n  INSERT INTO t4 VALUES(   1, NULL, NULL);\n  INSERT INTO t4 VALUES(   1, NULL, 0);\n  INSERT INTO t4 VALUES(   1, NULL, 1);\n  INSERT INTO t4 VALUES(   1,    0, NULL);\n  INSERT INTO t4 VALUES(   1,    0, 0);\n  INSERT INTO t4 VALUES(   1,    0, 1);\n  INSERT INTO t4 VALUES(   1,    1, NULL);\n  INSERT INTO t4 VALUES(   1,    1, 0);\n  INSERT INTO t4 VALUES(   1,    1, 1);\n}\n\nproc make_expr1 {cList vList op} {\n  return \"([join $cList ,]) $op ([join $vList ,])\"\n}\n\nproc make_expr3 {cList vList op} {\n  set n [llength $cList]\n\n  set aList [list]\n  foreach c [lrange $cList 0 end-1] v [lrange $vList 0 end-1] {\n    lappend aList \"$c == $v\"\n  }\n  lappend aList \"[lindex $cList end] $op [lindex $vList end]\"\n\n  return \"([join $aList { AND }])\"\n}\n\nproc make_expr2 {cList vList op} {\n  set ret \"\"\n\n  switch -- $op {\n    == - IS {\n      set aList [list]\n      foreach c $cList v $vList { lappend aList \"($c $op $v)\" }\n      set ret [join $aList \" AND \"]\n    }\n\n    < - > {\n      set oList [list]\n      for {set i 0} {$i < [llength $cList]} {incr i} {\n        lappend oList [make_expr3 [lrange $cList 0 $i] [lrange $vList 0 $i] $op]\n      }\n      set ret [join $oList \" OR \"]\n    }\n\n    <= - >= {\n      set o2 [string range $op 0 0]\n      set oList [list]\n      for {set i 0} {$i < [llength $cList]-1} {incr i} {\n        lappend oList [make_expr3 [lrange $cList 0 $i] [lrange $vList 0 $i] $o2]\n      }\n      lappend oList [make_expr3 $cList $vList $op]\n      set ret [join $oList \" OR \"]\n    }\n\n\n    default {\n      error \"Unknown op: $op\"\n    }\n  }\n\n  set ret\n}\n\nforeach {tn idx} {\n  IDX1 {}\n  IDX2 { CREATE INDEX i4 ON t4(a, b, c); }\n  IDX3 { CREATE INDEX i4 ON t4(a, b); }\n  IDX4 { CREATE INDEX i4 ON t4(a); }\n} {\n  execsql { DROP INDEX IF EXISTS i4 }\n  execsql $idx\n\n  foreach {tn2 vector} {\n    1 {0 0 0}\n    2 {1 1 1}\n    3 {0 0 NULL}\n    4 {0 NULL 0}\n    5 {NULL 0 0}\n    6 {1 1 NULL}\n    7 {1 NULL 1}\n    8 {NULL 1 1}\n  } {\n    foreach op { IS == < <= > >= } {\n      set e1 [make_expr1 {a b c} $vector $op]\n      set e2 [make_expr2 {a b c} $vector $op]\n\n      do_execsql_test 4.$tn.$tn2.$op \\\n          \"SELECT rowid FROM t4 WHERE $e2 ORDER BY +rowid\" [\n          db eval \"SELECT rowid FROM t4 WHERE $e1 ORDER BY +rowid\"\n      ]\n    }\n  }\n}\n\ndo_execsql_test 5.0 {\n  CREATE TABLE r1(a TEXT, iB TEXT);\n  CREATE TABLE r2(x TEXT, zY INTEGER);\n  CREATE INDEX r1ab ON r1(a, iB);\n\n  INSERT INTO r1 VALUES(35, 35);\n  INSERT INTO r2 VALUES(35, 36);\n  INSERT INTO r2 VALUES(35, 4);\n  INSERT INTO r2 VALUES(35, 35);\n} {}\n\nforeach {tn lhs rhs} {\n  1 {x +zY} {a iB}\n  2 {x  zY} {a iB}\n  3 {x  zY} {a +iB}\n  4 {+x  zY} {a iB}\n  5 {x  zY} {+a iB}\n} {\n  foreach op { IS == < <= > >= } {\n    set e1 [make_expr1 $lhs $rhs $op]\n    set e2 [make_expr2 $lhs $rhs $op]\n    do_execsql_test 5.$tn.$op \\\n      \"SELECT * FROM r1, r2 WHERE $e2 ORDER BY iB\" [db eval \\\n      \"SELECT * FROM r1, r2 WHERE $e1 ORDER BY iB\"\n    ]\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue3.test",
    "content": "# 2016 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing \"(...) IN (SELECT ...)\" expressions\n# where the SELECT statement returns more than one column.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue3\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  INSERT INTO t1 VALUES(7, 8, 9);\n}\n\nforeach {tn sql res} {\n  1  \"SELECT 1 WHERE (4, 5) IN (SELECT a, b FROM t1)\"  1\n  2  \"SELECT 1 WHERE (5, 5) IN (SELECT a, b FROM t1)\"  {}\n  3  \"SELECT 1 WHERE (5, 4) IN (SELECT a, b FROM t1)\"  {}\n  4  \"SELECT 1 WHERE (5, 4) IN (SELECT b, a FROM t1)\"  1\n  5  \"SELECT 1 WHERE (SELECT a, b FROM t1 WHERE c=6) IN (SELECT a, b FROM t1)\" 1\n  6  \"SELECT (5, 4) IN (SELECT a, b FROM t1)\" 0\n  7  \"SELECT 1 WHERE (5, 4) IN (SELECT +b, +a FROM t1)\"  1\n  8  \"SELECT (5, 4) IN (SELECT +b, +a FROM t1)\"  1\n  9  \"SELECT (1, 2) IN (SELECT rowid, b FROM t1)\"  1\n  10 \"SELECT 1 WHERE (1, 2) IN (SELECT rowid, b FROM t1)\"  1\n  11 \"SELECT 1 WHERE (1, NULL) IN (SELECT rowid, b FROM t1)\"  {}\n  12 \"SELECT 1 FROM t1 WHERE (a, b) = (SELECT +a, +b FROM t1)\" {1}\n} {\n  do_execsql_test 1.$tn $sql $res\n}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 2.0 {\n  CREATE TABLE z1(x, y, z);\n  CREATE TABLE kk(a, b);\n\n  INSERT INTO z1 VALUES('a', 'b', 'c');\n  INSERT INTO z1 VALUES('d', 'e', 'f');\n  INSERT INTO z1 VALUES('g', 'h', 'i');\n\n  -- INSERT INTO kk VALUES('y', 'y');\n  INSERT INTO kk VALUES('d', 'e');\n  -- INSERT INTO kk VALUES('x', 'x');\n\n}\n\nforeach {tn idx} {\n  1 { }\n  2 { CREATE INDEX z1idx ON z1(x, y) }\n  3 { CREATE UNIQUE INDEX z1idx ON z1(x, y) }\n  4 { CREATE INDEX z1idx ON kk(a, b) }\n} {\n  execsql \"DROP INDEX IF EXISTS z1idx\"\n  execsql $idx\n\n  do_execsql_test 2.$tn.1 {\n    SELECT * FROM z1 WHERE x IN (SELECT a FROM kk)\n  } {d e f}\n\n  do_execsql_test 2.$tn.2 {\n    SELECT * FROM z1 WHERE (x,y) IN (SELECT a, b FROM kk)\n  } {d e f}\n\n  do_execsql_test 2.$tn.3 {\n    SELECT * FROM z1 WHERE (x, +y) IN (SELECT a, b FROM kk)\n  } {d e f}\n  \n  do_execsql_test 2.$tn.4 {\n    SELECT * FROM z1 WHERE (x, +y) IN (SELECT a, b||'x' FROM kk)\n  } {}\n\n  do_execsql_test 2.$tn.5 {\n    SELECT * FROM z1 WHERE (+x, y) IN (SELECT a, b FROM kk)\n  } {d e f}\n}\n\n#-------------------------------------------------------------------------\n#\n\ndo_execsql_test 3.0 {\n  CREATE TABLE c1(a, b, c, d);\n  INSERT INTO c1(rowid, a, b) VALUES(1,   NULL, 1);\n  INSERT INTO c1(rowid, a, b) VALUES(2,   2, NULL);\n  INSERT INTO c1(rowid, a, b) VALUES(3,   2, 2);\n  INSERT INTO c1(rowid, a, b) VALUES(4,   3, 3);\n\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(101, 'a', 'b', 1, 1);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(102, 'a', 'b', 1, 2);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(103, 'a', 'b', 1, 3);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(104, 'a', 'b', 2, 1);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(105, 'a', 'b', 2, 2);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(106, 'a', 'b', 2, 3);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(107, 'a', 'b', 3, 1);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(108, 'a', 'b', 3, 2);\n  INSERT INTO c1(rowid, a, b, c, d) VALUES(109, 'a', 'b', 3, 3);\n}\n\n\nforeach {tn idx} {\n  1 { }\n  2 { CREATE INDEX c1ab ON c1(a, b); }\n  3 { CREATE INDEX c1ba ON c1(b, a); }\n\n  4 { CREATE INDEX c1cd ON c1(c, d); }\n  5 { CREATE INDEX c1dc ON c1(d, c); }\n} {\n  drop_all_indexes\n\n  foreach {tn2 sql res} {\n    1 \"SELECT (1, 2) IN (SELECT a, b FROM c1)\" {0}\n    2 \"SELECT (1, 1) IN (SELECT a, b FROM c1)\" {{}}\n    3 \"SELECT (2, 1) IN (SELECT a, b FROM c1)\" {{}}\n    4 \"SELECT (2, 2) IN (SELECT a, b FROM c1)\" {1}\n    5 \"SELECT c, d FROM c1 WHERE (c, d) IN (SELECT d, c FROM c1)\"\n      { 1 1 1 2 1 3   2 1 2 2 2 3   3 1 3 2 3 3 }\n\n    6 \"SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) ORDER BY c DESC\"\n      { 3 1 3 2 3 3   2 1 2 2 2 3   1 1 1 2 1 3 }\n\n    7 {\n        SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) \n        ORDER BY c DESC, d ASC\n      } { 3 1 3 2 3 3   2 1 2 2 2 3   1 1 1 2 1 3 }\n\n    8 {\n        SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) \n        ORDER BY c ASC, d DESC\n      } { 1 3 1 2 1 1   2 3 2 2 2 1   3 3 3 2 3 1 }\n\n    9 {\n        SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) \n        ORDER BY c ASC, d ASC\n      } { 1 1 1 2 1 3   2 1 2 2 2 3   3 1 3 2 3 3 }\n    10 {\n        SELECT c, d FROM c1 WHERE (c,d) IN (SELECT d, c FROM c1) \n        ORDER BY c DESC, d DESC\n      } { 3 3 3 2 3 1   2 3 2 2 2 1   1 3 1 2 1 1 }\n\n  } {\n    do_execsql_test 3.$tn.$tn2 $sql $res\n  }\n}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 4.0 {\n  CREATE TABLE hh(a, b, c);\n\n  INSERT INTO hh VALUES('a', 'a', 1);\n  INSERT INTO hh VALUES('a', 'b', 2);\n  INSERT INTO hh VALUES('b', 'a', 3);\n  INSERT INTO hh VALUES('b', 'b', 4);\n\n  CREATE TABLE k1(x, y);\n  INSERT INTO k1 VALUES('a', 'a');\n  INSERT INTO k1 VALUES('b', 'b');\n  INSERT INTO k1 VALUES('a', 'b');\n  INSERT INTO k1 VALUES('b', 'a');\n}\n\nforeach {tn idx} {\n  1 { }\n  2 { CREATE INDEX h1 ON hh(a, b); }\n  3 { CREATE UNIQUE INDEX k1idx ON k1(x, y) }\n  4 { CREATE UNIQUE INDEX k1idx ON k1(x, y DESC) }\n  5 { \n    CREATE INDEX h1 ON hh(a, b);\n    CREATE UNIQUE INDEX k1idx ON k1(x, y); \n  }\n  6 { \n    CREATE INDEX h1 ON hh(a, b);\n    CREATE UNIQUE INDEX k1idx ON k1(x, y DESC); \n  }\n} {\n  drop_all_indexes\n  execsql $idx\n  foreach {tn2 orderby res} {\n    1 \"a ASC, b ASC\"  {1 2 3 4}\n    2 \"a ASC, b DESC\" {2 1 4 3}\n    3 \"a DESC, b ASC\" {3 4 1 2}\n    4 \"a DESC, b DESC\" {4 3 2 1}\n  } {\n    do_execsql_test 4.$tn.$tn2 \"\n      SELECT c FROM hh WHERE (a, b) in (SELECT x, y FROM k1) ORDER BY $orderby\n    \" $res\n  }\n}\n\n#-------------------------------------------------------------------------\n\n# 2016-11-17.  Query flattening in a vector SELECT on the RHS of an IN\n# operator.  Ticket https://www.sqlite.org/src/info/da7841375186386c\n#\ndo_execsql_test 5.0 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE T1(a TEXT);\n  INSERT INTO T1(a) VALUES ('aaa');\n  CREATE TABLE T2(a TEXT PRIMARY KEY,n INT);\n  INSERT INTO T2(a, n) VALUES('aaa',0);\n  SELECT * FROM T2\n  WHERE (a,n) IN (SELECT T1.a, V.n FROM T1, (SELECT * FROM (SELECT 0 n)) V);\n} {aaa 0}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue4.test",
    "content": "# 2016 July 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is syntax errors involving row-value constructors\n# and sub-selects that return multiple arguments.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue4\n\n#-------------------------------------------------------------------------\n# Test some error conditions:\n# \n#   * row values used where they are not supported,\n#   * row values or sub-selects that contain/return the wrong number\n#     of elements.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX t1bac ON t1(b, a, c);\n}\n\nforeach {tn e} {\n  1 \"(1, 2, 3)\"\n  2 \"1 + (1, 2)\"\n  3 \"(1,2,3) == (1, 2)\"\n} {\n  do_catchsql_test 1.$tn \"SELECT $e\" {1 {row value misused}}\n}\n\nforeach {tn s error} {\n  1 \"SELECT * FROM t1 WHERE a = (1, 2)\"       {row value misused}\n  2 \"SELECT * FROM t1 WHERE b = (1, 2)\"       {row value misused}\n  3 \"SELECT * FROM t1 WHERE NOT (b = (1, 2))\" {row value misused}\n  4 \"SELECT * FROM t1 LIMIT (1, 2)\"           {row value misused}\n  5 \"SELECT (a, b) IN (SELECT * FROM t1) FROM t1\" \n                             {sub-select returns 3 columns - expected 2}\n\n  6 \"SELECT * FROM t1 WHERE (a, b) IN (SELECT * FROM t1)\" \n                             {sub-select returns 3 columns - expected 2}\n  7 \"SELECT * FROM t1 WHERE (c, c) <= 1\" {row value misused}\n  8 \"SELECT * FROM t1 WHERE (b, b) <= 1\" {row value misused}\n} {\n  do_catchsql_test 2.$tn \"$s\" [list 1 $error]\n}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a, b, c, d);\n  INSERT INTO t2 VALUES(1, 1, 1,   1);\n  INSERT INTO t2 VALUES(1, 1, 2,   2);\n  INSERT INTO t2 VALUES(1, 1, 3,   3);\n  INSERT INTO t2 VALUES(1, 2, 1,   4);\n  INSERT INTO t2 VALUES(1, 2, 2,   5);\n  INSERT INTO t2 VALUES(1, 2, 3,   6);\n  INSERT INTO t2 VALUES(1, 3, 1,   7);\n  INSERT INTO t2 VALUES(1, 3, 2,   8);\n  INSERT INTO t2 VALUES(1, 3, 3,   9);\n\n  INSERT INTO t2 VALUES(2, 1, 1,   10);\n  INSERT INTO t2 VALUES(2, 1, 2,   11);\n  INSERT INTO t2 VALUES(2, 1, 3,   12);\n  INSERT INTO t2 VALUES(2, 2, 1,   13);\n  INSERT INTO t2 VALUES(2, 2, 2,   14);\n  INSERT INTO t2 VALUES(2, 2, 3,   15);\n  INSERT INTO t2 VALUES(2, 3, 1,   16);\n  INSERT INTO t2 VALUES(2, 3, 2,   17);\n  INSERT INTO t2 VALUES(2, 3, 3,   18);\n\n  INSERT INTO t2 VALUES(3, 1, 1,   19);\n  INSERT INTO t2 VALUES(3, 1, 2,   20);\n  INSERT INTO t2 VALUES(3, 1, 3,   21);\n  INSERT INTO t2 VALUES(3, 2, 1,   22);\n  INSERT INTO t2 VALUES(3, 2, 2,   23);\n  INSERT INTO t2 VALUES(3, 2, 3,   24);\n  INSERT INTO t2 VALUES(3, 3, 1,   25);\n  INSERT INTO t2 VALUES(3, 3, 2,   26);\n  INSERT INTO t2 VALUES(3, 3, 3,   27);\n}\n\nforeach {nm idx} {\n  idx1 {}\n  idx2 { CREATE INDEX t2abc ON t2(a, b, c); }\n  idx3 { CREATE INDEX t2abc ON t2(a, b DESC, c); }\n  idx4 { CREATE INDEX t2abc ON t2(a DESC, b DESC, c DESC); }\n  idx5 { CREATE INDEX t2abc ON t2(a ASC, b ASC, c ASC); }\n  idx6 { CREATE INDEX t2abc ON t2(a DESC, b, c); }\n  idx7 { CREATE INDEX t2abc ON t2(a DESC, b DESC) }\n  idx8 { CREATE INDEX t2abc ON t2(c, b, a); }\n  idx9 { CREATE INDEX t2d ON t2(d); }\n  idx10 { CREATE INDEX t2abc ON t2(a DESC, b, c DESC); }\n} {\n  drop_all_indexes\n  execsql $idx\n\n  foreach {tn where res} {\n    1 \"(a, b, c) < (2, 2, 2)\"  {1 2 3 4 5 6 7 8 9 10 11 12 13}\n    2 \"(a, b, c) <= (2, 2, 2)\" {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n    3 \"(a, b, c) > (2, 2, 2)\"  {15 16 17 18 19 20 21 22 23 24 25 26 27}\n    4 \"(a, b, c) >= (2, 2, 2)\" {14 15 16 17 18 19 20 21 22 23 24 25 26 27}\n    5 \"(a, b, c) >= (2, 2, NULL)\" {16 17 18 19 20 21 22 23 24 25 26 27}\n    6 \"(a, b, c) <= (2, 2, NULL)\" {1 2 3 4 5 6 7 8 9 10 11 12}\n    7 \"(a, b, c) >= (2, NULL, NULL)\" {19 20 21 22 23 24 25 26 27}\n    8 \"(a, b, c) <= (2, NULL, NULL)\" {1 2 3 4 5 6 7 8 9}\n\n    9 \"(a, b, c) < (SELECT a, b, c FROM t2 WHERE d=14)\"  \n      {1 2 3 4 5 6 7 8 9 10 11 12 13}\n\n    10 \"(a, b, c) = (SELECT a, b, c FROM t2 WHERE d=14)\" 14\n\n    11 \"a = 2 AND (b, c) > (2, 2)\" {15 16 17 18}\n    12 \"a = 2 AND (b, c) < (3, 3) AND (b, c) > (1, 1)\" {11 12 13 14 15 16 17}\n  } {\n    set result [db eval \"SELECT d FROM t2 WHERE $where\"]\n    do_test 2.1.$nm.$tn { lsort -integer $result } $res\n  }\n\n  foreach {tn e res} {\n    1 \"(2, 1) IN (SELECT a, b FROM t2)\" 1\n    2 \"(2, 1) IN (SELECT a, b FROM t2 ORDER BY d)\" 1\n    3 \"(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 9)\" 0\n    4 \"(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 10)\" 1\n\n    5 \"(3, 3) = (SELECT a, b FROM t2 ORDER BY d DESC LIMIT 1)\" 1\n    6 \"(3, 3) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)\" 0\n    7 \"(1, NULL) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)\" {{}}\n\n    8 \"(3, 1) = (SELECT b, c FROM t2 ORDER BY d DESC LIMIT 1 OFFSET 2)\" 1\n    9 \"(3, 1) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)\" 0\n    10 \"(1, NULL) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)\" {{}}\n\n    11 \"(3, 3) = (SELECT max(a), max(b) FROM t2)\" 1\n    12 \"(3, 1) = (SELECT max(a), min(b) FROM t2)\" 1\n    13 \"(NULL, NULL) = (SELECT max(a), min(b) FROM t2)\" {{}}\n\n    14 \"(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 11)\" 1\n    15 \"(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 12)\" 0\n  } {\n    do_execsql_test 2.2.$nm.$tn \"SELECT $e\" $res\n  }\n}\n\nifcapable stat4 {\n  do_execsql_test 3.0 {\n    CREATE TABLE c1(a, b, c, d);\n    INSERT INTO c1(a, b) VALUES(1, 'a');\n    INSERT INTO c1(a, b) VALUES(1, 'b');\n    INSERT INTO c1(a, b) VALUES(1, 'c');\n    INSERT INTO c1(a, b) VALUES(1, 'd');\n    INSERT INTO c1(a, b) VALUES(1, 'e');\n    INSERT INTO c1(a, b) VALUES(1, 'f');\n    INSERT INTO c1(a, b) VALUES(1, 'g');\n    INSERT INTO c1(a, b) VALUES(1, 'h');\n    INSERT INTO c1(a, b) VALUES(1, 'i');\n    INSERT INTO c1(a, b) VALUES(1, 'j');\n    INSERT INTO c1(a, b) VALUES(1, 'k');\n    INSERT INTO c1(a, b) VALUES(1, 'l');\n    INSERT INTO c1(a, b) VALUES(1, 'm');\n    INSERT INTO c1(a, b) VALUES(1, 'n');\n    INSERT INTO c1(a, b) VALUES(1, 'o');\n    INSERT INTO c1(a, b) VALUES(1, 'p');\n    INSERT INTO c1(a, b) VALUES(2, 'a');\n    INSERT INTO c1(a, b) VALUES(2, 'b');\n    INSERT INTO c1(a, b) VALUES(2, 'c');\n    INSERT INTO c1(a, b) VALUES(2, 'd');\n    INSERT INTO c1(a, b) VALUES(2, 'e');\n    INSERT INTO c1(a, b) VALUES(2, 'f');\n    INSERT INTO c1(a, b) VALUES(2, 'g');\n    INSERT INTO c1(a, b) VALUES(2, 'h');\n\n    INSERT INTO c1(c, d) SELECT a, b FROM c1;\n\n    CREATE INDEX c1ab ON c1(a, b);\n    CREATE INDEX c1cd ON c1(c, d);\n    ANALYZE;\n  }\n\n  do_eqp_test 3.1.1 { SELECT * FROM c1 WHERE a=1 AND c=2 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1cd (c=?)}\n  }\n  do_eqp_test 3.1.2 { SELECT * FROM c1 WHERE a=1 AND b>'d' AND c=2 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1cd (c=?)}\n  }\n  do_eqp_test 3.1.3 { SELECT * FROM c1 WHERE a=1 AND b>'l' AND c=2 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1ab (a=? AND b>?)}\n  }\n\n  do_eqp_test 3.2.1 { SELECT * FROM c1 WHERE a=1 AND c>1 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1cd (c>?)}\n  }\n  do_eqp_test 3.2.2 { SELECT * FROM c1 WHERE a=1 AND c>0 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1ab (a=?)}\n  }\n  do_eqp_test 3.2.3 { SELECT * FROM c1 WHERE a=1 AND c>=1 } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1ab (a=?)}\n  }\n  do_eqp_test 3.2.4 { SELECT * FROM c1 WHERE a=1 AND (c, d)>(1, 'c') } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1ab (a=?)}\n  }\n  do_eqp_test 3.2.5 { SELECT * FROM c1 WHERE a=1 AND (c, d)>(1, 'o') } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1cd ((c,d)>(?,?))}\n  }\n  do_eqp_test 3.2.6 { SELECT * FROM c1 WHERE a=1 AND (c, +b)>(1, 'c') } {\n    0 0 0 {SEARCH TABLE c1 USING INDEX c1ab (a=?)}\n  }\n}\n\n#------------------------------------------------------------------------\n\ndo_execsql_test 5.0 {\n  CREATE TABLE d1(x, y);\n  CREATE TABLE d2(a, b, c);\n  CREATE INDEX d2ab ON d2(a, b);\n  CREATE INDEX d2c ON d2(c);\n\n  WITH i(i) AS (\n    VALUES(1) UNION ALL SELECT i+1 FROM i WHERE i<1000\n  )\n  INSERT INTO d2 SELECT i/3, i%3, i/3 FROM i;\n  ANALYZE;\n}\n\ndo_eqp_test 5.1 {\n  SELECT * FROM d2 WHERE \n    (a, b) IN (SELECT x, y FROM d1) AND\n    (c) IN (SELECT y FROM d1)\n} {\n  0 0 0 {SEARCH TABLE d2 USING INDEX d2ab (a=? AND b=?)}\n  0 0 0 {EXECUTE LIST SUBQUERY 1} \n  1 0 0 {SCAN TABLE d1}\n  0 0 0 {EXECUTE LIST SUBQUERY 2} \n  2 0 0 {SCAN TABLE d1}\n}\n\ndo_execsql_test 6.0 {\n  CREATE TABLE e1(a, b, c, d, e);\n  CREATE INDEX e1ab ON e1(a, b);\n  CREATE INDEX e1cde ON e1(c, d, e);\n}\n\ndo_eqp_test 6.1 {\n  SELECT * FROM e1 WHERE (a, b) > (?, ?)\n} {\n  0 0 0 {SEARCH TABLE e1 USING INDEX e1ab ((a,b)>(?,?))}\n}\ndo_eqp_test 6.2 {\n  SELECT * FROM e1 WHERE (a, b) < (?, ?)\n} {\n  0 0 0 {SEARCH TABLE e1 USING INDEX e1ab ((a,b)<(?,?))}\n}\ndo_eqp_test 6.3 {\n  SELECT * FROM e1 WHERE c = ? AND (d, e) > (?, ?)\n} {\n  0 0 0 {SEARCH TABLE e1 USING INDEX e1cde (c=? AND (d,e)>(?,?))}\n}\ndo_eqp_test 6.4 {\n  SELECT * FROM e1 WHERE c = ? AND (d, e) < (?, ?)\n} {\n  0 0 0 {SEARCH TABLE e1 USING INDEX e1cde (c=? AND (d,e)<(?,?))}\n}\n\ndo_eqp_test 6.5 {\n  SELECT * FROM e1 WHERE (d, e) BETWEEN (?, ?) AND (?, ?) AND c = ?\n} {\n  0 0 0 \n  {SEARCH TABLE e1 USING INDEX e1cde (c=? AND (d,e)>(?,?) AND (d,e)<(?,?))}\n}\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 7.1 {\n  CREATE TABLE f1(a, b, c);\n  CREATE INDEX f1ab ON f1(a, b);\n}\n\ndo_catchsql_test 7.2 {\n  SELECT (a COLLATE nocase, b) IN (SELECT a, b FROM f1) FROM f1;\n} {0 {}}\n\ndo_catchsql_test 7.3 {\n  SELECT (a COLLATE nose, b) IN (SELECT a, b FROM f1) FROM f1;\n} {1 {no such collation sequence: nose}}\n\ndo_catchsql_test 7.4 {\n  SELECT * FROM f1 WHERE (?, ? COLLATE nose) > (a, b);\n} {1 {no such collation sequence: nose}}\n\n#-------------------------------------------------------------------------\ndrop_all_tables\ndo_execsql_test 8.1 {\n  CREATE TABLE c1(x, y);\n  CREATE TABLE c2(a, b, c);\n  CREATE INDEX c2ab ON c2(a, b);\n  CREATE INDEX c2c ON c2(c);\n\n  CREATE TABLE c3(d);\n}\ndo_catchsql_test 8.2 {\n  SELECT * FROM c2 CROSS JOIN c3 WHERE \n    ( (a, b) == (SELECT x, y FROM c1) AND c3.d = c ) OR\n    ( c == (SELECT x, y FROM c1) AND c3.d = c )\n} {1 {row value misused}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue5.test",
    "content": "# 2016 July 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is syntax errors involving row-values and\n# virtual tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue5\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nproc vtab_command {method args} {\n  switch -- $method {\n    xConnect {\n      return \"CREATE TABLE t1(a, b, c, d, expr)\"\n    }\n\n    xBestIndex {\n      set COL(0) a\n      set COL(1) b\n      set COL(2) c\n      set COL(3) d\n      set COL(4) expr\n\n      set OP(eq) =\n      set OP(ne) !=\n      set OP(gt) >\n      set OP(le) <=\n      set OP(lt) <\n      set OP(ge) >=\n      set OP(match) MATCH\n      set OP(like) LIKE\n      set OP(glob) GLOB\n      set OP(regexp) REGEXP\n\n      set clist [lindex $args 0]\n      set ret [list]\n      set elist [list]\n      set i 0\n      foreach c $clist {\n        array set C $c\n        if {$C(usable)} {\n          lappend ret omit $i\n          lappend elist \"$COL($C(column)) $OP($C(op)) %$i%\"\n        }\n        incr i\n      }\n\n      lappend ret idxstr [join $elist \" AND \"]\n      #puts \"xBestIndex: $ret\"\n      return $ret\n    }\n\n    xFilter {\n      foreach {idxnum idxstr arglist} $args {}\n      set i 0\n      set ee $idxstr\n      foreach a $arglist {\n        if {[string is double $a]==0} {\n          set a \"'[string map {' ''} $a]'\"\n        }\n        set ee [string map [list \"%$i%\" $a] $ee]\n        incr i\n      }\n      set ee [string map [list \"'\" \"''\"] $ee]\n\n      set ret [list sql \"SELECT 1, 'a', 'b', 'c', 'd', '$ee'\"]\n      #puts \"xFilter: $ret\"\n      return $ret\n    }\n  }\n\n  return {}\n}\n\nregister_tcl_module db\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE x1 USING tcl(vtab_command);\n} {}\n\n\nforeach {tn where res} {\n  1 \"1\"                              {{}}\n  2 \"a=1\"                            {{a = 1}}\n  3 \"a=1 AND 4 = b\"                  {{a = 1 AND b = 4}}\n  4 \"c>'hello'\"                      {{c > 'hello'}}\n  5 \"c<='hel''lo'\"                   {{c <= 'hel''lo'}}\n  6 \"(a, b) = (SELECT 9, 10)\"        {{a = 9 AND b = 10}}\n  7 \"(+a, b) = (SELECT 'a', 'b')\"    {{b = 'b'}}\n  8 \"(a, +b) = (SELECT 'a', 'b')\"    {{a = 'a'}}\n  11 \"(+a, b) IN (SELECT 'a', 'b')\"  {{b = 'b'}}\n  12 \"(a, +b) IN (SELECT 'a', 'b')\"  {{a = 'a'}}\n\n  13 \"(a, b) < ('d', 'e')\"           {{a <= 'd'}}\n  14 \"(a, b) < ('a', 'c')\"           {{a <= 'a'}}\n  15 \"(a, b) <= ('a', 'b')\"          {{a <= 'a'}}\n  16 \"(a, b) < ('a', 'b')\"           {}\n} {\n  do_execsql_test 1.$tn \"SELECT expr FROM x1 WHERE $where\" $res\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue6.test",
    "content": "# 2016-08-18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The focus of this file is handling of NULL values in row-value IN\n# expressions.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue6\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b,c);\n  CREATE INDEX t1x1 ON t1(a,b);\n  INSERT INTO t1 VALUES(1,NULL,200);\n\n  CREATE TABLE t2(x,y,z);\n  INSERT INTO t2 VALUES(1,NULL,55);\n\n  SELECT c FROM t1 WHERE (a,b) IN (SELECT x,y FROM t2 WHERE z==55);\n} {}\ndo_execsql_test 1.2 {\n  INSERT INTO t1 VALUES(2,3,400);\n  INSERT INTO t2 VALUES(2,3,55);  \n\n  SELECT c FROM t1 WHERE (a,b) IN (SELECT x,y FROM t2 WHERE z==55);\n} {400}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue7.test",
    "content": "# 2016-08-18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The focus of this file is vector assignments in the SET clause of\n# an UPDATE statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue7\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE INDEX t1x ON t1(a,b);\n  INSERT INTO t1(a,b,c,d) VALUES(1,2,0,0),(3,4,0,0),(5,6,0,0);\n  CREATE TABLE t2(w,x,y,z);\n  CREATE INDEX t2x ON t2(w,x);\n  INSERT INTO t2(w,x,y,z) VALUES(1,2,11,22),(8,9,88,99),(3,5,33,55),(5,6,55,66);\n\n  SELECT *,'|' FROM t1 ORDER BY a;\n} {1 2 0 0 | 3 4 0 0 | 5 6 0 0 |}\n\ndo_execsql_test 1.2 {\n  UPDATE t1 SET (c,d) = (SELECT y,z FROM t2 WHERE (w,x)=(a,b));\n  SELECT *,'|' FROM t1 ORDER BY a;\n} {1 2 11 22 | 3 4 {} {} | 5 6 55 66 |}\n\ndo_execsql_test 1.3 {\n  UPDATE t1 SET (c,d) = (SELECT y,z FROM t2 WHERE w=a);\n  SELECT *,'|' FROM t1 ORDER BY a;\n} {1 2 11 22 | 3 4 33 55 | 5 6 55 66 |}\n\ndo_execsql_test 1.4 {\n  UPDATE t1 SET (c) = 99 WHERE a=3;\n  SELECT *,'|' FROM t1 ORDER BY a;\n} {1 2 11 22 | 3 4 99 55 | 5 6 55 66 |}\n\ndo_execsql_test 1.5 {\n  UPDATE t1 SET b = 8, (c,d) = (SELECT 123,456) WHERE a=3;\n  SELECT *,'|' FROM t1 ORDER BY a;\n} {1 2 11 22 | 3 8 123 456 | 5 6 55 66 |}\n\ndo_catchsql_test 2.1 {\n  UPDATE t1 SET (c,d) = (SELECT x,y,z FROM t2 WHERE w=a);\n} {1 {2 columns assigned 3 values}}\n\ndo_catchsql_test 2.2 {\n  UPDATE t1 SET (b,c,d) = (SELECT x,y FROM t2 WHERE w=a);\n} {1 {3 columns assigned 2 values}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue8.test",
    "content": "# 2016-08-22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Use of row values in CASE statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue8\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);\n  INSERT INTO t1(a,b,c,d) VALUES\n     (1,1,2,3),\n     (2,2,3,4),\n     (3,1,2,4),\n     (4,2,3,5),\n     (5,3,4,6),\n     (6,4,5,9);\n  SELECT a, CASE (b,c) WHEN (1,2) THEN 'aleph'\n                       WHEN (2,3) THEN 'bet'\n                       WHEN (3,4) THEN 'gimel'\n                       ELSE '-' END,\n         '|'\n    FROM t1\n   ORDER BY a;\n} {1 aleph | 2 bet | 3 aleph | 4 bet | 5 gimel | 6 - |}\ndo_execsql_test 1.2 {\n  SELECT a, CASE (b,c,d) WHEN (1,2,3) THEN 'aleph'\n                         WHEN (2,3,4) THEN 'bet'\n                         WHEN (3,4,6) THEN 'gimel'\n                         ELSE '-' END,\n         '|'\n    FROM t1\n   ORDER BY a;\n} {1 aleph | 2 bet | 3 - | 4 - | 5 gimel | 6 - |}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t2(x INTEGER PRIMARY KEY, y);\n  INSERT INTO t2(x,y) VALUES(1,6),(2,5),(3,4),(4,3),(5,2),(6,1);\n  SELECT x, CASE (SELECT b,c FROM t1 WHERE a=y)\n            WHEN (1,2) THEN 'aleph'\n            WHEN (2,3) THEN 'bet'\n            WHEN (3,4) THEN 'gimel'\n            ELSE '-' END,\n         '|'\n    FROM t2\n   ORDER BY +x;\n} {1 - | 2 gimel | 3 bet | 4 aleph | 5 bet | 6 aleph |}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvalue9.test",
    "content": "# 2016 September 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing SQL statements that use row value\n# constructors.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix rowvalue9\n\n# Tests:\n#\n#  1.*: Test that affinities are handled correctly by various row-value\n#       operations without indexes.\n#\n#  2.*: Test an affinity bug that came up during testing.\n#\n#  3.*: Test a row-value version of the bug tested by 2.*.\n#\n#  4.*: Test that affinities are handled correctly by various row-value\n#       operations with assorted indexes.\n#\n\ndo_execsql_test 1.0.1 {\n  CREATE TABLE a1(c, b INTEGER, a TEXT, PRIMARY KEY(a, b));\n \n  INSERT INTO a1 (rowid, c, b, a) VALUES(3,  '0x03', 1, 1);\n  INSERT INTO a1 (rowid, c, b, a) VALUES(14, '0x0E', 2, 2);\n  INSERT INTO a1 (rowid, c, b, a) VALUES(15, '0x0F', 3, 3);\n  INSERT INTO a1 (rowid, c, b, a) VALUES(92, '0x5C', 4, 4);\n\n  CREATE TABLE a2(x BLOB, y BLOB);\n  INSERT INTO a2(x, y) VALUES(1, 1);\n  INSERT INTO a2(x, y) VALUES(2, '2');\n  INSERT INTO a2(x, y) VALUES('3', 3);\n  INSERT INTO a2(x, y) VALUES('4', '4');\n}\n\ndo_execsql_test 1.0.2 { \n  SELECT x, typeof(x), y, typeof(y) FROM a2 ORDER BY rowid\n} {\n  1 integer 1 integer \n  2 integer 2 text \n  3 text    3 integer \n  4 text    4 text\n}\n\ndo_execsql_test 1.1.1 {\n  SELECT (SELECT rowid FROM a1 WHERE a=x AND b=y) FROM a2\n} {{} {} 15 92}\ndo_execsql_test 1.1.2 {\n  SELECT (SELECT rowid FROM a1 WHERE (a, b) = (x, y)) FROM a2\n} {{} {} 15 92}\n\ndo_execsql_test 1.2.3 {\n  SELECT a1.rowid FROM a1, a2 WHERE a=x AND b=y;\n} {15 92}\ndo_execsql_test 1.2.4 {\n  SELECT a1.rowid FROM a1, a2 WHERE (a, b) = (x, y)\n} {15 92}\n\n\ndo_execsql_test 1.3.1 {\n  SELECT a1.rowid FROM a1, a2 WHERE coalesce(NULL,x)=a AND coalesce(NULL,y)=b\n} {3 14 15 92}\ndo_execsql_test 1.3.2 {\n  SELECT a1.rowid FROM a1, a2 \n  WHERE (coalesce(NULL,x), coalesce(NULL,y)) = (a, b)\n} {3 14 15 92}\n\ndo_execsql_test 1.4.1 {\n  SELECT a1.rowid FROM a1, a2 WHERE +x=a AND +y=b\n} {3 14 15 92}\ndo_execsql_test 1.4.2 {\n  SELECT a1.rowid FROM a1, a2 WHERE (+x, +y) = (a, b)\n} {3 14 15 92}\n\ndo_execsql_test 1.5.1 {\n  SELECT (SELECT rowid FROM a1 WHERE a=+x AND b=+y) FROM a2\n} {3 14 15 92}\ndo_execsql_test 1.5.2 {\n  SELECT (SELECT rowid FROM a1 WHERE (a, b) = (+x, +y)) FROM a2\n} {3 14 15 92}\ndo_execsql_test 1.5.3 {\n  SELECT (SELECT rowid FROM a1 WHERE (+x, +y) = (a, b)) FROM a2\n} {3 14 15 92}\n\ndo_execsql_test 1.6.1 {\n  SELECT a1.rowid FROM a1 WHERE (a, b) IN (SELECT x, y FROM a2)\n} {15 92}\ndo_execsql_test 1.6.2 {\n  SELECT a1.rowid FROM a1, a2 WHERE EXISTS (\n    SELECT 1 FROM a1 WHERE a=x AND b=y\n  )\n} {3 14 15 92 3 14 15 92}\n\n# Test that [199df416] is fixed.\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE b1(a TEXT);\n  CREATE TABLE b2(x BLOB);\n  INSERT INTO b1 VALUES(1);\n  INSERT INTO b2 VALUES(1);\n}\ndo_execsql_test 2.2 { SELECT * FROM b1, b2 WHERE a=x; } {}\ndo_execsql_test 2.3 { SELECT * FROM b1 WHERE a IN (SELECT x FROM b2) } {}\ndo_execsql_test 2.4 { CREATE UNIQUE INDEX b1a ON b1(a); }\ndo_execsql_test 2.5 { SELECT * FROM b1 WHERE a IN (SELECT x FROM b2) } {}\n\n# Test that a multi-column version of the query that revealed problem \n# [199df416] also works.\n#\ndo_execsql_test 3.1 {\n  CREATE TABLE c1(a INTEGER, b TEXT);\n  INSERT INTO c1 VALUES(1, 1);\n  CREATE TABLE c2(x BLOB, y BLOB);\n  INSERT INTO c2 VALUES(1, 1);\n}\ndo_execsql_test 3.2 {\n  SELECT * FROM c1 WHERE (a, b) IN (SELECT x, y FROM c2)\n} {}\ndo_execsql_test 3.3 {\n  CREATE UNIQUE INDEX c1ab ON c1(a, b);\n  SELECT * FROM c1 WHERE (a, b) IN (SELECT x, y FROM c2)\n} {}\ndo_execsql_test 3.4 {\n  SELECT * FROM c1 WHERE (a, +b) IN (SELECT x, y FROM c2)\n} {}\n\ndo_execsql_test 3.5 {\n  SELECT c1.rowid FROM c1 WHERE b = (SELECT y FROM c2);\n} {}\ndo_execsql_test 3.6 {\n  SELECT c1.rowid FROM c1 WHERE (a, b) = (SELECT x, y FROM c2);\n} {}\n\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 4.0 {\n  CREATE TABLE d1(a TEXT, b INTEGER, c NUMERIC);\n  CREATE TABLE d2(x BLOB, y BLOB);\n\n  INSERT INTO d1 VALUES(1, 1, 1);\n  INSERT INTO d1 VALUES(2, 2, 2);\n  INSERT INTO d1 VALUES(3, 3, 3);\n  INSERT INTO d1 VALUES(4, 4, 4);\n\n  INSERT INTO d2 VALUES (1, 1);\n  INSERT INTO d2 VALUES (2, '2');\n  INSERT INTO d2 VALUES ('3', 3);\n  INSERT INTO d2 VALUES ('4', '4');\n}\n\nforeach {tn idx} {\n  1 {}\n  2 { CREATE INDEX idx ON d1(a) }\n  3 { CREATE INDEX idx ON d1(a, c) }\n  4 { CREATE INDEX idx ON d1(c) }\n  5 { CREATE INDEX idx ON d1(c, a) }\n\n  6 { \n    CREATE INDEX idx ON d1(c, a) ;\n    CREATE INDEX idx1 ON d2(x, y);\n  }\n\n  7 { \n    CREATE INDEX idx ON d1(c, a) ;\n    CREATE UNIQUE INDEX idx2 ON d2(x, y) ;\n  }\n\n  8 { \n    CREATE INDEX idx ON d1(c) ;\n    CREATE UNIQUE INDEX idx2 ON d2(x);\n  }\n\n} {\n  execsql { DROP INDEX IF EXISTS idx } \n  execsql { DROP INDEX IF EXISTS idx2 } \n  execsql { DROP INDEX IF EXISTS idx3 } \n  execsql $idx\n\n  do_execsql_test 4.$tn.1 {\n    SELECT rowid FROM d1 WHERE (a, c) IN (SELECT x, y FROM d2);\n  } {3 4}\n\n  do_execsql_test 4.$tn.2 {\n    SELECT rowid FROM d1 WHERE (c, a) IN (SELECT x, y FROM d2);\n  } {2 4}\n\n  do_execsql_test 4.$tn.3 {\n    SELECT rowid FROM d1 WHERE (+c, a) IN (SELECT x, y FROM d2);\n  } {2}\n\n  do_execsql_test 4.$tn.4 {\n    SELECT rowid FROM d1 WHERE (c, a) = (\n      SELECT x, y FROM d2 WHERE d2.rowid=d1.rowid\n    );\n  } {2 4}\n\n  do_execsql_test 4.$tn.5 {\n    SELECT d1.rowid FROM d1, d2 WHERE a = y;\n  } {2 4}\n\n  do_execsql_test 4.$tn.6 {\n    SELECT d1.rowid FROM d1 WHERE a = (\n      SELECT y FROM d2 where d2.rowid=d1.rowid\n    );\n  } {2 4}\n}\n\ndo_execsql_test 5.0 {\n  CREATE TABLE e1(a TEXT, c NUMERIC);\n  CREATE TABLE e2(x BLOB, y BLOB);\n\n  INSERT INTO e1 VALUES(2, 2);\n\n  INSERT INTO e2 VALUES ('2', 2);\n  INSERT INTO e2 VALUES ('2', '2');\n  INSERT INTO e2 VALUES ('2', '2.0');\n\n  CREATE INDEX e1c ON e1(c);\n}\n\ndo_execsql_test 5.1 {\n  SELECT rowid FROM e1 WHERE (a, c) IN (SELECT x, y FROM e2);\n} {1}\ndo_execsql_test 5.2 {\n  SELECT rowid FROM e2 WHERE rowid IN (SELECT +c FROM e1);\n} {2}\ndo_execsql_test 5.3 {\n  SELECT rowid FROM e2 WHERE rowid IN (SELECT 0+c FROM e1);\n} {2}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 6.0 {\n  CREATE TABLE f1(a, b);\n  CREATE TABLE f2(c, d);\n  CREATE TABLE f3(e, f);\n}\n\ndo_execsql_test 6.1 {\n  SELECT * FROM f3 WHERE (e, f) IN (\n    SELECT a, b FROM f1 UNION ALL SELECT c, d FROM f2\n  );\n}\ndo_execsql_test 6.2 {\n  CREATE INDEX f3e ON f3(e);\n  SELECT * FROM f3 WHERE (e, f) IN (\n    SELECT a, b FROM f1 UNION ALL SELECT c, d FROM f2\n  );\n}\n\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 7.0 {\n  CREATE TABLE g1(a, b); \n  INSERT INTO g1 VALUES\n      (1, 1), (1, 2), (1, 3), (1, 'i'), (1, 'j'),\n      (1, 6), (1, 7), (1, 8), (1, 9), (1, 10),\n      (1, 4), (1, 5);\n\n  CREATE TABLE g2(x, y);\n  CREATE INDEX g2x ON g2(x);\n\n  INSERT INTO g2 VALUES(1, 4);\n  INSERT INTO g2 VALUES(1, 5);\n}\n\ndo_execsql_test 7.1 {\n  SELECT * FROM g2 WHERE (x, y) IN (\n    SELECT a, b FROM g1 ORDER BY +a, +b LIMIT 10\n  );\n} { 1 4 1 5 }\n\ndo_execsql_test 7.2 {\n  SELECT * FROM g2 WHERE (x, y) IN (\n    SELECT a, b FROM g1 ORDER BY a, b LIMIT 10\n  );\n} { 1 4 1 5 }\n\ndo_execsql_test 7.3 {\n  SELECT * FROM g2 WHERE (x, y) IN (\n    SELECT a, b FROM g1 ORDER BY 1, 2 LIMIT 10\n  );\n} { 1 4 1 5 }\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rowvaluefault.test",
    "content": "# 2016 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  \n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix rowvaluefault\n\ndo_execsql_test 1.0 {\n  CREATE TABLE xyz(one, two, thr, fou);\n  INSERT INTO xyz VALUES('A', 'A', 'A',  1);\n  INSERT INTO xyz VALUES('B', 'B', 'B',  2);\n  INSERT INTO xyz VALUES('C', 'C', 'C',  3);\n  INSERT INTO xyz VALUES('D', 'D', 'D',  4);\n\n  CREATE UNIQUE INDEX xyz_one_two ON xyz(one, two);\n}\n\ndo_faultsim_test 1 -faults oom* -body {\n  execsql { SELECT fou FROM xyz WHERE (one, two, thr) = ('B', 'B', 'B') }\n} -test {\n  faultsim_test_result {0 2} \n}\n\ndo_faultsim_test 2 -faults oom* -body {\n  execsql { SELECT fou FROM xyz WHERE (two, thr) IS ('C', 'C') }\n} -test {\n  faultsim_test_result {0 3} \n}\n\ndo_faultsim_test 3 -faults oom* -body {\n  execsql { SELECT fou FROM xyz WHERE (one, two, thr) > ('B', 'B', 'B') }\n} -test {\n  faultsim_test_result {0 {3 4}} \n}\n\ndo_faultsim_test 4 -faults oom* -body {\n  execsql { SELECT fou FROM xyz WHERE (one, two) IN (SELECT one, two FROM xyz) }\n} -test {\n  faultsim_test_result {0 {1 2 3 4}} \n}\n\ndo_faultsim_test 5 -faults oom* -body {\n  execsql { \n    SELECT fou FROM xyz \n    WHERE (one, two, thr) IN (SELECT one, two, thr FROM xyz) \n  }\n} -test {\n  faultsim_test_result {0 {1 2 3 4}} \n}\n\ndo_faultsim_test 6 -faults oom* -body {\n  execsql { \n    SELECT fou FROM xyz \n    WHERE (one, two, thr) BETWEEN ('B', 'B', 'B') AND ('C', 'C', 'C') }\n} -test {\n  faultsim_test_result {0 {2 3}} \n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/rtree.test",
    "content": "# 2008 June 23\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all rtree related tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nifcapable rtree {\n  run_test_suite rtree\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/run-wordcount.sh",
    "content": "#!/bin/sh\n#\n# This script runs the wordcount program in different ways, comparing\n# the output from each.\n#\n\n# Select the source text to be analyzed.\n#\nif test \"x$1\" = \"x\";\nthen echo \"Usage: $0 FILENAME [ARGS...]\"; exit 1;\nfi\n\n# Do test runs\n#\nrm -f wcdb1.db\n./wordcount --timer --summary wcdb1.db $* --insert >wc-out.txt\nmv wc-out.txt wc-baseline.txt\nrm -f wcdb2.db\n./wordcount --timer --summary wcdb2.db $* --insert --without-rowid >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\nrm -f wcdb1.db\n./wordcount --timer --summary wcdb1.db $* --replace >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\nrm -f wcdb2.db\n./wordcount --timer --summary wcdb2.db $* --replace --without-rowid >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\nrm -f wcdb1.db\n./wordcount --timer --summary wcdb1.db $* --select >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\nrm -f wcdb2.db\n./wordcount --timer --summary wcdb2.db $* --select --without-rowid >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\n./wordcount --timer --summary wcdb1.db $* --query >wc-out.txt\nmv wc-out.txt wc-baseline.txt\n./wordcount --timer --summary wcdb2.db $* --query --without-rowid >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\n./wordcount --timer --summary wcdb1.db $* --delete >wc-out.txt\nmv wc-out.txt wc-baseline.txt\n./wordcount --timer --summary wcdb2.db $* --delete --without-rowid >wc-out.txt\n  if cmp -s wc-out.txt wc-baseline.txt;\n  then echo hi >/dev/null;\n  else echo ERROR:;\n       diff -u wc-baseline.txt wc-out.txt;\n  fi\n\n\n# Clean up temporary files created.\n#\nrm -rf wcdb1.db wcdb2.db wc-out.txt wc-baseline.txt\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint.test",
    "content": "# 2008 December 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: savepoint.test,v 1.13 2009/07/18 08:30:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\n#----------------------------------------------------------------------\n# The following tests - savepoint-1.* - test that the SAVEPOINT, RELEASE\n# and ROLLBACK TO comands are correctly parsed, and that the auto-commit\n# flag is correctly set and unset as a result.\n#\ndo_test savepoint-1.1 {\n  wal_set_journal_mode\n  execsql {\n    SAVEPOINT sp1;\n    RELEASE sp1;\n  }\n} {}\ndo_test savepoint-1.2 {\n  execsql {\n    SAVEPOINT sp1;\n    ROLLBACK TO sp1;\n  }\n} {}\ndo_test savepoint-1.3 {\n  execsql { SAVEPOINT sp1 }\n  db close\n} {}\nsqlite3 db test.db\ndo_test savepoint-1.4.1 {\n  execsql {\n    SAVEPOINT sp1;\n    SAVEPOINT sp2;\n    RELEASE sp1;\n  }\n  sqlite3_get_autocommit db\n} {1}\ndo_test savepoint-1.4.2 {\n  execsql {\n    SAVEPOINT sp1;\n    SAVEPOINT sp2;\n    RELEASE sp2;\n  }\n  sqlite3_get_autocommit db\n} {0}\ndo_test savepoint-1.4.3 {\n  execsql { RELEASE sp1 }\n  sqlite3_get_autocommit db\n} {1}\ndo_test savepoint-1.4.4 {\n  execsql {\n    SAVEPOINT sp1;\n    SAVEPOINT sp2;\n    ROLLBACK TO sp1;\n  }\n  sqlite3_get_autocommit db\n} {0}\ndo_test savepoint-1.4.5 {\n  execsql { RELEASE SAVEPOINT sp1 }\n  sqlite3_get_autocommit db\n} {1}\ndo_test savepoint-1.4.6 {\n  execsql {\n    SAVEPOINT sp1;\n    SAVEPOINT sp2;\n    SAVEPOINT sp3;\n    ROLLBACK TO SAVEPOINT sp3;\n    ROLLBACK TRANSACTION TO sp2;\n    ROLLBACK TRANSACTION TO SAVEPOINT sp1;\n  }\n  sqlite3_get_autocommit db\n} {0}\ndo_test savepoint-1.4.7 {\n  execsql { RELEASE SAVEPOINT SP1 }\n  sqlite3_get_autocommit db\n} {1}\ndo_test savepoint-1.5 {\n  execsql {\n    SAVEPOINT sp1;\n    ROLLBACK TO sp1;\n  }\n} {}\ndo_test savepoint-1.6 {\n  execsql COMMIT\n} {}\nwal_check_journal_mode savepoint-1.7\n\n#------------------------------------------------------------------------\n# These tests - savepoint-2.* - test rollbacks and releases of savepoints\n# with a very simple data set.\n# \n\ndo_test savepoint-2.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2, 3);\n    SAVEPOINT one;\n    UPDATE t1 SET a = 2, b = 3, c = 4;\n  }\n  execsql { SELECT * FROM t1 }\n} {2 3 4}\ndo_test savepoint-2.2 {\n  execsql {\n    ROLLBACK TO one;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3}\ndo_test savepoint-2.3 {\n  execsql {\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6}\ndo_test savepoint-2.4 {\n  execsql {\n    ROLLBACK TO one;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3}\n\n\ndo_test savepoint-2.5 {\n  execsql {\n    INSERT INTO t1 VALUES(7, 8, 9);\n    SAVEPOINT two;\n    INSERT INTO t1 VALUES(10, 11, 12);\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 7 8 9 10 11 12}\ndo_test savepoint-2.6 {\n  execsql {\n    ROLLBACK TO two;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 7 8 9}\ndo_test savepoint-2.7 {\n  execsql {\n    INSERT INTO t1 VALUES(10, 11, 12);\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 7 8 9 10 11 12}\ndo_test savepoint-2.8 {\n  execsql {\n    ROLLBACK TO one;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3}\ndo_test savepoint-2.9 {\n  execsql {\n    INSERT INTO t1 VALUES('a', 'b', 'c');\n    SAVEPOINT two;\n    INSERT INTO t1 VALUES('d', 'e', 'f');\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 a b c d e f}\ndo_test savepoint-2.10 {\n  execsql {\n    RELEASE two;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 a b c d e f}\ndo_test savepoint-2.11 {\n  execsql {\n    ROLLBACK;\n  }\n  execsql { SELECT * FROM t1 }\n} {}\nwal_check_journal_mode savepoint-2.12\n\n#------------------------------------------------------------------------\n# This block of tests - savepoint-3.* - test that when a transaction\n# savepoint is rolled back, locks are not released from database files.\n# And that when a transaction savepoint is released, they are released.\n#\n# These tests do not work in WAL mode. WAL mode does not take RESERVED\n# locks on the database file.\n# \nif {[wal_is_wal_mode]==0} {\n  do_test savepoint-3.1 {\n    execsql { SAVEPOINT \"transaction\" }\n    execsql { PRAGMA lock_status }\n  } {main unlocked temp closed}\n  \n  do_test savepoint-3.2 {\n    execsql { INSERT INTO t1 VALUES(1, 2, 3) }\n    execsql { PRAGMA lock_status }\n  } {main reserved temp closed}\n  \n  do_test savepoint-3.3 {\n    execsql { ROLLBACK TO \"transaction\" }\n    execsql { PRAGMA lock_status }\n  } {main reserved temp closed}\n  \n  do_test savepoint-3.4 {\n    execsql { INSERT INTO t1 VALUES(1, 2, 3) }\n    execsql { PRAGMA lock_status }\n  } {main reserved temp closed}\n  \n  do_test savepoint-3.5 {\n    execsql { RELEASE \"transaction\" }\n    execsql { PRAGMA lock_status }\n  } {main unlocked temp closed}\n}\n\n#------------------------------------------------------------------------\n# Test that savepoints that include schema modifications are handled\n# correctly. Test cases savepoint-4.*.\n# \ndo_test savepoint-4.1 {\n  execsql {\n    CREATE TABLE t2(d, e, f);\n    SELECT sql FROM sqlite_master;\n  }\n} {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}\ndo_test savepoint-4.2 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(g,h);\n    INSERT INTO t3 VALUES('I', 'II');\n    SAVEPOINT one;\n    DROP TABLE t3;\n  }\n} {}\ndo_test savepoint-4.3 {\n  execsql {\n    CREATE TABLE t3(g, h, i);\n    INSERT INTO t3 VALUES('III', 'IV', 'V');\n  }\n  execsql {SELECT * FROM t3}\n} {III IV V}\ndo_test savepoint-4.4 {\n  execsql { ROLLBACK TO one; }\n  execsql {SELECT * FROM t3}\n} {I II}\ndo_test savepoint-4.5 {\n  execsql {\n    ROLLBACK;\n    SELECT sql FROM sqlite_master;\n  }\n} {{CREATE TABLE t1(a, b, c)} {CREATE TABLE t2(d, e, f)}}\n\ndo_test savepoint-4.6 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES('o', 't', 't');\n    SAVEPOINT sp1;\n    CREATE TABLE t3(a, b, c);\n    INSERT INTO t3 VALUES('z', 'y', 'x');\n  }\n  execsql {SELECT * FROM t3}\n} {z y x}\ndo_test savepoint-4.7 {\n  execsql {\n    ROLLBACK TO sp1;\n    CREATE TABLE t3(a);\n    INSERT INTO t3 VALUES('value');\n  }\n  execsql {SELECT * FROM t3}\n} {value}\ndo_test savepoint-4.8 {\n  execsql COMMIT\n} {}\nwal_check_journal_mode savepoint-4.9\n\n#------------------------------------------------------------------------\n# Test some logic errors to do with the savepoint feature.\n# \n\nifcapable incrblob {\n  do_test savepoint-5.1.1 {\n    execsql {\n      CREATE TABLE blobs(x);\n      INSERT INTO blobs VALUES('a twentyeight character blob');\n    }\n    set fd [db incrblob blobs x 1]\n    puts -nonewline $fd \"hello\"\n    catchsql {SAVEPOINT abc}\n  } {1 {cannot open savepoint - SQL statements in progress}}\n  do_test savepoint-5.1.2 {\n    close $fd\n    catchsql {SAVEPOINT abc}\n  } {0 {}}\n  \n  do_test savepoint-5.2 {\n    execsql  {RELEASE abc}\n    catchsql {RELEASE abc}\n  } {1 {no such savepoint: abc}}\n  \n  do_test savepoint-5.3.1 {\n    execsql  {SAVEPOINT abc}\n    catchsql {ROLLBACK TO def}\n  } {1 {no such savepoint: def}}\n  do_test savepoint-5.3.2.1 {\n    execsql  {SAVEPOINT def}\n    set fd [db incrblob -readonly blobs x 1]\n    set rc [catch {seek $fd 0;read $fd} res]\n    lappend rc $res\n  } {0 {hellontyeight character blob}}\n  do_test savepoint-5.3.2.2 {\n    catchsql {ROLLBACK TO def}\n  } {0 {}}\n  do_test savepoint-5.3.2.3 {\n    set rc [catch {seek $fd 0; read $fd} res]\n    set rc\n  } {0}\n  do_test savepoint-5.3.3 {\n    catchsql  {RELEASE def}\n  } {0 {}}\n  do_test savepoint-5.3.4 {\n    close $fd\n    execsql  {savepoint def}\n    set fd [db incrblob blobs x 1]\n    catchsql {release def}\n  } {1 {cannot release savepoint - SQL statements in progress}}\n  do_test savepoint-5.3.5 {\n    close $fd\n    execsql {release abc}\n  } {}\n  \n  # Rollback mode:\n  #\n  #   Open a savepoint transaction and insert a row into the database. Then,\n  #   using a second database handle, open a read-only transaction on the\n  #   database file. Check that the savepoint transaction cannot be committed\n  #   until after the read-only transaction has been closed.\n  #\n  # WAL mode:\n  # \n  #   As above, except that the savepoint transaction can be successfully\n  #   committed before the read-only transaction has been closed.\n  #\n  do_test savepoint-5.4.1 {\n    execsql {\n      SAVEPOINT main;\n      INSERT INTO blobs VALUES('another blob');\n    }\n  } {}\n  do_test savepoint-5.4.2 {\n    sqlite3 db2 test.db\n    execsql { BEGIN ; SELECT count(*) FROM blobs } db2\n  } {1}\n  if {[wal_is_wal_mode]} {\n    do_test savepoint-5.4.3 { catchsql \"RELEASE main\" } {0 {}}\n    do_test savepoint-5.4.4 { db2 close               } {}\n  } else {\n    do_test savepoint-5.4.3 {\n      catchsql { RELEASE main }\n    } {1 {database is locked}}\n    do_test savepoint-5.4.4 {\n      db2 close\n      catchsql { RELEASE main }\n    } {0 {}}\n  }\n  do_test savepoint-5.4.5 {\n    execsql { SELECT x FROM blobs WHERE rowid = 2 }\n  } {{another blob}}\n  do_test savepoint-5.4.6 {\n    execsql { SELECT count(*) FROM blobs }\n  } {2}\n}\nwal_check_journal_mode savepoint-5.5\n\n#-------------------------------------------------------------------------\n# The following tests, savepoint-6.*, test an incr-vacuum inside of a\n# couple of nested savepoints.\n#\nifcapable {autovacuum && pragma} {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  do_test savepoint-6.1 {\n    execsql { PRAGMA auto_vacuum = incremental }\n    wal_set_journal_mode\n    execsql {\n      CREATE TABLE t1(a, b, c);\n      CREATE INDEX i1 ON t1(a, b);\n      BEGIN;\n      INSERT INTO t1 VALUES(randstr(10,400),randstr(10,400),randstr(10,400));\n    }\n    set r \"randstr(10,400)\"\n    for {set ii 0} {$ii < 10} {incr ii} {\n      execsql \"INSERT INTO t1 SELECT $r, $r, $r FROM t1\"\n    }\n    execsql { COMMIT }\n  } {}\n\n  integrity_check savepoint-6.2\n\n  do_test savepoint-6.3 {\n    execsql {\n      PRAGMA cache_size = 10;\n      BEGIN;\n        UPDATE t1 SET a = randstr(10,10) WHERE (rowid%4)==0;\n        SAVEPOINT one;\n          DELETE FROM t1 WHERE rowid%2;\n          PRAGMA incr_vacuum;\n          SAVEPOINT two;\n            INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;\n            DELETE FROM t1 WHERE rowid%2;\n            PRAGMA incr_vacuum;\n        ROLLBACK TO one;\n      COMMIT;\n    }\n  } {}\n\n  integrity_check savepoint-6.4\n\n  wal_check_journal_mode savepoint-6.5\n}\n\n#-------------------------------------------------------------------------\n# The following tests, savepoint-7.*, attempt to break the logic \n# surrounding savepoints by growing and shrinking the database file.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\n\ndo_test savepoint-7.1 {\n  execsql { PRAGMA auto_vacuum = incremental }\n  wal_set_journal_mode\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1(a) VALUES('alligator');\n      INSERT INTO t1(a) VALUES('angelfish');\n      INSERT INTO t1(a) VALUES('ant');\n      INSERT INTO t1(a) VALUES('antelope');\n      INSERT INTO t1(a) VALUES('ape');\n      INSERT INTO t1(a) VALUES('baboon');\n      INSERT INTO t1(a) VALUES('badger');\n      INSERT INTO t1(a) VALUES('bear');\n      INSERT INTO t1(a) VALUES('beetle');\n      INSERT INTO t1(a) VALUES('bird');\n      INSERT INTO t1(a) VALUES('bison');\n      UPDATE t1 SET b =    randstr(1000,1000);\n      UPDATE t1 SET b = b||randstr(1000,1000);\n      UPDATE t1 SET b = b||randstr(1000,1000);\n      UPDATE t1 SET b = b||randstr(10,1000);\n    COMMIT;\n  }\n  expr ([execsql { PRAGMA page_count }] > 20)\n} {1}\ndo_test savepoint-7.2.1 {\n  execsql {\n    BEGIN;\n      SAVEPOINT one;\n      CREATE TABLE t2(a, b);\n      INSERT INTO t2 SELECT a, b FROM t1;\n      ROLLBACK TO one;\n  }\n  execsql {\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_test savepoint-7.2.2 {\n  execsql {\n    COMMIT;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\ndo_test savepoint-7.3.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 SELECT a, b FROM t1;\n  }\n} {}\ndo_test savepoint-7.3.2 {\n  execsql {\n    BEGIN;\n      SAVEPOINT one;\n        DELETE FROM t2;\n        PRAGMA incremental_vacuum;\n        SAVEPOINT two;\n          INSERT INTO t2 SELECT a, b FROM t1;\n        ROLLBACK TO two;\n    COMMIT;\n  }\n  execsql { PRAGMA integrity_check }\n} {ok}\nwal_check_journal_mode savepoint-7.3.3\n\ndo_test savepoint-7.4.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql { PRAGMA auto_vacuum = incremental }\n  wal_set_journal_mode\n  execsql {\n    CREATE TABLE t1(a, b, PRIMARY KEY(a, b));\n    INSERT INTO t1 VALUES(randstr(1000,1000), randstr(1000,1000));\n    BEGIN;\n      DELETE FROM t1;\n      SAVEPOINT one;\n      PRAGMA incremental_vacuum;\n      ROLLBACK TO one;\n    COMMIT;\n  }\n\n  execsql { PRAGMA integrity_check }\n} {ok}\n\ndo_test savepoint-7.5.1 {\n  execsql {\n    PRAGMA incremental_vacuum;\n    CREATE TABLE t5(x, y);\n    INSERT INTO t5 VALUES(1, randstr(1000,1000));\n    INSERT INTO t5 VALUES(2, randstr(1000,1000));\n    INSERT INTO t5 VALUES(3, randstr(1000,1000));\n\n    BEGIN;\n      INSERT INTO t5 VALUES(4, randstr(1000,1000));\n      INSERT INTO t5 VALUES(5, randstr(1000,1000));\n      DELETE FROM t5 WHERE x=1 OR x=2;\n      SAVEPOINT one;\n        PRAGMA incremental_vacuum;\n        SAVEPOINT two;\n          INSERT INTO t5 VALUES(1, randstr(1000,1000));\n          INSERT INTO t5 VALUES(2, randstr(1000,1000));\n        ROLLBACK TO two;\n      ROLLBACK TO one;\n    COMMIT;\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_test savepoint-7.5.2 {\n  execsql {\n    DROP TABLE t5;\n  }\n} {}\nwal_check_journal_mode savepoint-7.5.3\n\n# Test oddly named and quoted savepoints.\n#\ndo_test savepoint-8-1 {\n  execsql { SAVEPOINT \"save1\" }\n  execsql { RELEASE save1 }\n} {}\ndo_test savepoint-8-2 {\n  execsql { SAVEPOINT \"Including whitespace \" }\n  execsql { RELEASE \"including Whitespace \" }\n} {}\n\n# Test that the authorization callback works.\n#\nifcapable auth {\n  proc auth {args} {\n    eval lappend ::authdata [lrange $args 0 4]\n    return SQLITE_OK\n  }\n  db auth auth\n\n  do_test savepoint-9.1 {\n    set ::authdata [list]\n    execsql { SAVEPOINT sp1 }\n    set ::authdata\n  } {SQLITE_SAVEPOINT BEGIN sp1 {} {}}\n  do_test savepoint-9.2 {\n    set ::authdata [list]\n    execsql { ROLLBACK TO sp1 }\n    set ::authdata\n  } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {}}\n  do_test savepoint-9.3 {\n    set ::authdata [list]\n    execsql { RELEASE sp1 }\n    set ::authdata\n  } {SQLITE_SAVEPOINT RELEASE sp1 {} {}}\n\n  proc auth {args} {\n    eval lappend ::authdata [lrange $args 0 4]\n    return SQLITE_DENY\n  }\n  db auth auth\n\n  do_test savepoint-9.4 {\n    set ::authdata [list]\n    set res [catchsql { SAVEPOINT sp1 }]\n    concat $::authdata $res\n  } {SQLITE_SAVEPOINT BEGIN sp1 {} {} 1 {not authorized}}\n  do_test savepoint-9.5 {\n    set ::authdata [list]\n    set res [catchsql { ROLLBACK TO sp1 }]\n    concat $::authdata $res\n  } {SQLITE_SAVEPOINT ROLLBACK sp1 {} {} 1 {not authorized}}\n  do_test savepoint-9.6 {\n    set ::authdata [list]\n    set res [catchsql { RELEASE sp1 }]\n    concat $::authdata $res\n  } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}\n\n  catch { db eval ROLLBACK }\n  db auth \"\"\n}\n\n#-------------------------------------------------------------------------\n# The following tests - savepoint-10.* - test the interaction of \n# savepoints and ATTACH statements.\n# \n\n# First make sure it is not possible to attach or detach a database while\n# a savepoint is open (it is not possible if any transaction is open).\n#\n# UPDATE 2017-07-26:  It is not possible to ATTACH and DETACH within a\n# a transaction.\n#\ndo_test savepoint-10.1.1 {\n  catchsql {\n    SAVEPOINT one;\n    ATTACH 'test2.db' AS aux;\n    DETACH aux;\n  }\n} {0 {}}\ndo_test savepoint-10.1.2 {\n  execsql {\n    RELEASE one;\n    ATTACH 'test2.db' AS aux;\n  }\n  catchsql {\n    SAVEPOINT one;\n    DETACH aux;\n    ATTACH 'test2.db' AS aux;\n  }\n} {0 {}}\ndo_test savepoint-10.1.3 {\n  execsql {\n    RELEASE one;\n    DETACH aux;\n  }\n} {}\n\n# The lock state of the TEMP database can vary if SQLITE_TEMP_STORE=3\n# And the following set of tests is only really interested in the status\n# of the aux1 and aux2 locks.  So record the current lock status of\n# TEMP for use in the answers.\nset templockstate [lindex [db eval {PRAGMA lock_status}] 3]\n\n\nif {[wal_is_wal_mode]==0} {\n  do_test savepoint-10.2.1 {\n    forcedelete test3.db\n    forcedelete test2.db\n    execsql {\n      ATTACH 'test2.db' AS aux1;\n      ATTACH 'test3.db' AS aux2;\n      DROP TABLE t1;\n      CREATE TABLE main.t1(x, y);\n      CREATE TABLE aux1.t2(x, y);\n      CREATE TABLE aux2.t3(x, y);\n      SELECT name FROM sqlite_master;\n      SELECT name FROM aux1.sqlite_master;\n      SELECT name FROM aux2.sqlite_master;\n    }\n  } {t1 t2 t3}\n  do_test savepoint-10.2.2 {\n    execsql { PRAGMA lock_status }\n  } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]\n  \n  do_test savepoint-10.2.3 {\n    execsql {\n      SAVEPOINT one;\n      INSERT INTO t1 VALUES(1, 2);\n      PRAGMA lock_status;\n    }\n  } [list main reserved temp $templockstate aux1 unlocked aux2 unlocked]\n  do_test savepoint-10.2.4 {\n    execsql {\n      INSERT INTO t3 VALUES(3, 4);\n      PRAGMA lock_status;\n    }\n  } [list main reserved temp $templockstate aux1 unlocked aux2 reserved]\n  do_test savepoint-10.2.5 {\n    execsql {\n      SAVEPOINT two;\n      INSERT INTO t2 VALUES(5, 6);\n      PRAGMA lock_status;\n    }\n  } [list main reserved temp $templockstate aux1 reserved aux2 reserved]\n  do_test savepoint-10.2.6 {\n    execsql { SELECT * FROM t2 }\n  } {5 6}\n  do_test savepoint-10.2.7 {\n    execsql { ROLLBACK TO two }\n    execsql { SELECT * FROM t2 }\n  } {}\n  do_test savepoint-10.2.8 {\n    execsql { PRAGMA lock_status }\n  } [list main reserved temp $templockstate aux1 reserved aux2 reserved]\n  do_test savepoint-10.2.9 {\n    execsql { SELECT 'a', * FROM t1 ; SELECT 'b', * FROM t3 }\n  } {a 1 2 b 3 4}\n  do_test savepoint-10.2.9 {\n    execsql {\n      INSERT INTO t2 VALUES(5, 6);\n      RELEASE one;\n    }\n    execsql { \n      SELECT * FROM t1;\n      SELECT * FROM t2;\n      SELECT * FROM t3;\n    }\n  } {1 2 5 6 3 4}\n  do_test savepoint-10.2.9 {\n    execsql { PRAGMA lock_status }\n  } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]\n  \n  do_test savepoint-10.2.10 {\n    execsql { \n      SAVEPOINT one;\n        INSERT INTO t1 VALUES('a', 'b');\n        SAVEPOINT two;\n          INSERT INTO t2 VALUES('c', 'd');\n          SAVEPOINT three;\n            INSERT INTO t3 VALUES('e', 'f');\n    }\n    execsql { \n      SELECT * FROM t1;\n      SELECT * FROM t2;\n      SELECT * FROM t3;\n    }\n  } {1 2 a b 5 6 c d 3 4 e f}\n  do_test savepoint-10.2.11 {\n    execsql { ROLLBACK TO two }\n    execsql { \n      SELECT * FROM t1;\n      SELECT * FROM t2;\n      SELECT * FROM t3;\n    }\n  } {1 2 a b 5 6 3 4}\n  do_test savepoint-10.2.12 {\n    execsql { \n      INSERT INTO t3 VALUES('g', 'h');\n      ROLLBACK TO two;\n    }\n    execsql { \n      SELECT * FROM t1;\n      SELECT * FROM t2;\n      SELECT * FROM t3;\n    }\n  } {1 2 a b 5 6 3 4}\n  do_test savepoint-10.2.13 {\n    execsql { ROLLBACK }\n    execsql { \n      SELECT * FROM t1;\n      SELECT * FROM t2;\n      SELECT * FROM t3;\n    }\n  } {1 2 5 6 3 4}\n  do_test savepoint-10.2.14 {\n    execsql { PRAGMA lock_status }\n  } [list main unlocked temp $templockstate aux1 unlocked aux2 unlocked]\n}\n\n#-------------------------------------------------------------------------\n# The following tests - savepoint-11.* - test the interaction of \n# savepoints and creating or dropping tables and indexes in \n# auto-vacuum mode.\n# \ndo_test savepoint-11.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql { PRAGMA auto_vacuum = full; }\n  wal_set_journal_mode\n  execsql {\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 VALUES(2, randstr(1000,1000));\n  }\n} {}\ndo_test savepoint-11.2 {\n  execsql {\n    SAVEPOINT one;\n      CREATE TABLE t2(a, b, UNIQUE(a, b));\n      SAVEPOINT two;\n        CREATE TABLE t3(a, b, UNIQUE(a, b));\n  }\n} {}\nintegrity_check savepoint-11.3\ndo_test savepoint-11.4 {\n  execsql { ROLLBACK TO two }\n} {}\nintegrity_check savepoint-11.5\ndo_test savepoint-11.6 {\n  execsql { \n    CREATE TABLE t3(a, b, UNIQUE(a, b));\n    ROLLBACK TO one;\n  }\n} {}\nintegrity_check savepoint-11.7\ndo_test savepoint-11.8 {\n  execsql { ROLLBACK }\n  execsql { PRAGMA wal_checkpoint }\n  file size test.db\n} {8192}\n\ndo_test savepoint-11.9 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    DROP TABLE IF EXISTS t3;\n  }\n} {}\ndo_test savepoint-11.10 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(x, y);\n      INSERT INTO t2 VALUES(1, 2);\n      SAVEPOINT one;\n        INSERT INTO t2 VALUES(3, 4);\n        SAVEPOINT two;\n          DROP TABLE t1;\n        ROLLBACK TO two;\n  }\n  execsql {SELECT * FROM t2}\n} {1 2 3 4}\ndo_test savepoint-11.11 {\n  execsql COMMIT\n} {}\ndo_test savepoint-11.12 {\n  execsql {SELECT * FROM t2}\n} {1 2 3 4}\nwal_check_journal_mode savepoint-11.13\n\n#-------------------------------------------------------------------------\n# The following tests - savepoint-12.* - test the interaction of \n# savepoints and \"ON CONFLICT ROLLBACK\" clauses.\n# \ndo_test savepoint-12.1 {\n  execsql {\n    CREATE TABLE t4(a PRIMARY KEY, b);\n    INSERT INTO t4 VALUES(1, 'one');\n  }\n} {}\ndo_test savepoint-12.2 {\n  # The final statement of the following SQL hits a constraint when the\n  # conflict handling mode is \"OR ROLLBACK\" and there are a couple of\n  # open savepoints. At one point this would fail to clear the internal\n  # record of the open savepoints, resulting in an assert() failure \n  # later on.\n  # \n  catchsql {\n    BEGIN;\n      INSERT INTO t4 VALUES(2, 'two');\n      SAVEPOINT sp1;\n        INSERT INTO t4 VALUES(3, 'three');\n        SAVEPOINT sp2;\n          INSERT OR ROLLBACK INTO t4 VALUES(1, 'one');\n  }\n} {1 {UNIQUE constraint failed: t4.a}}\ndo_test savepoint-12.3 {\n  sqlite3_get_autocommit db\n} {1}\ndo_test savepoint-12.4 {\n  execsql { SAVEPOINT one }\n} {}\nwal_check_journal_mode savepoint-12.5\n\n#-------------------------------------------------------------------------\n# The following tests - savepoint-13.* - test the interaction of \n# savepoints and \"journal_mode = off\".\n# \nif {[wal_is_wal_mode]==0} {\n  do_test savepoint-13.1 {\n    db close\n    catch {forcedelete test.db}\n    sqlite3 db test.db\n    execsql {\n      BEGIN;\n        CREATE TABLE t1(a PRIMARY KEY, b);\n        INSERT INTO t1 VALUES(1, 2);\n      COMMIT;\n      PRAGMA journal_mode = off;\n    }\n  } {off}\n  do_test savepoint-13.2 {\n    execsql {\n      BEGIN;\n      INSERT INTO t1 VALUES(3, 4);\n      INSERT INTO t1 SELECT a+4,b+4  FROM t1;\n      COMMIT;\n    }\n  } {}\n  do_test savepoint-13.3 {\n    execsql {\n      BEGIN;\n        INSERT INTO t1 VALUES(9, 10);\n        SAVEPOINT s1;\n          INSERT INTO t1 VALUES(11, 12);\n      COMMIT;\n    }\n  } {}\n  do_test savepoint-13.4 {\n    execsql {\n      BEGIN;\n        INSERT INTO t1 VALUES(13, 14);\n        SAVEPOINT s1;\n          INSERT INTO t1 VALUES(15, 16);\n        ROLLBACK TO s1;\n      ROLLBACK;\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 7 8 9 10 11 12}\n}\n\ndb close\ndelete_file test.db\ndo_multiclient_test tn {\n  do_test savepoint-14.$tn.1 {\n    sql1 {\n      CREATE TABLE foo(x);\n      INSERT INTO foo VALUES(1);\n      INSERT INTO foo VALUES(2);\n    }\n    sql2 {\n      BEGIN;\n        SELECT * FROM foo;\n    }\n  } {1 2}\n  do_test savepoint-14.$tn.2 {\n    sql1 {\n      SAVEPOINT one;\n      INSERT INTO foo VALUES(1);\n    }\n    csql1 { RELEASE one }\n  } {1 {database is locked}}\n  do_test savepoint-14.$tn.3 {\n    sql1 { ROLLBACK TO one }\n    sql2 { COMMIT }\n    sql1 { RELEASE one }\n  } {}\n\n  do_test savepoint-14.$tn.4 {\n    sql2 {\n      BEGIN;\n        SELECT * FROM foo;\n    }\n  } {1 2}\n  do_test savepoint-14.$tn.5 {\n    sql1 {\n      SAVEPOINT one;\n      INSERT INTO foo VALUES(1);\n    }\n    csql1 { RELEASE one }\n  } {1 {database is locked}}\n  do_test savepoint-14.$tn.6 {\n    sql2 { COMMIT }\n    sql1 {\n      ROLLBACK TO one;\n      INSERT INTO foo VALUES(3);\n      INSERT INTO foo VALUES(4);\n      INSERT INTO foo VALUES(5);\n      RELEASE one;\n    }\n  } {}\n  do_test savepoint-14.$tn.7 {\n    sql2 { CREATE INDEX fooidx ON foo(x); }\n    sql3 { PRAGMA integrity_check }\n  } {ok}\n}\n\ndo_multiclient_test tn {\n  do_test savepoint-15.$tn.1 {\n    sql1 {\n      CREATE TABLE foo(x);\n      INSERT INTO foo VALUES(1);\n      INSERT INTO foo VALUES(2);\n    }\n    sql2 { BEGIN; SELECT * FROM foo; }\n  } {1 2}\n  do_test savepoint-15.$tn.2 {\n    sql1 {\n      PRAGMA locking_mode = EXCLUSIVE;\n      BEGIN;\n        INSERT INTO foo VALUES(3);\n    }\n    csql1 { COMMIT }\n  } {1 {database is locked}}\n  do_test savepoint-15.$tn.3 {\n    sql1 { ROLLBACK }\n    sql2 { COMMIT }\n    sql1 {\n      INSERT INTO foo VALUES(3);\n      PRAGMA locking_mode = NORMAL;\n      INSERT INTO foo VALUES(4);\n    }\n    sql2 { CREATE INDEX fooidx ON foo(x); }\n    sql3 { PRAGMA integrity_check }\n  } {ok}\n}\n\ndo_multiclient_test tn {\n  do_test savepoint-16.$tn.1 {\n    sql1 {\n      CREATE TABLE foo(x);\n      INSERT INTO foo VALUES(1);\n      INSERT INTO foo VALUES(2);\n    }\n  } {}\n  do_test savepoint-16.$tn.2 {\n\n    db eval {SELECT * FROM foo} {\n      sql1 { INSERT INTO foo VALUES(3) }\n      sql2 { SELECT * FROM foo }\n      sql1 { INSERT INTO foo VALUES(4) }\n      break\n    }\n\n    sql2 { CREATE INDEX fooidx ON foo(x); }\n    sql3 { PRAGMA integrity_check }\n  } {ok}\n  do_test savepoint-16.$tn.3 {\n    sql1 { SELECT * FROM foo }\n  } {1 2 3 4}\n}\n\n#-------------------------------------------------------------------------\n# This next block of tests verifies that a problem reported on the mailing\n# list has been resolved. At one point the second \"CREATE TABLE t6\" would\n# fail as table t6 still existed in the internal cache of the db schema\n# (even though it had been removed from the database by the ROLLBACK \n# command).\n#\nsqlite3 db test.db\ndo_execsql_test savepoint-17.1 {\n  BEGIN;\n    CREATE TABLE t6(a, b);\n    INSERT INTO t6 VALUES(1, 2);\n    SAVEPOINT one;\n      INSERT INTO t6 VALUES(3, 4);\n    ROLLBACK TO one;\n    SELECT * FROM t6;\n  ROLLBACK;\n} {1 2}\n\ndo_execsql_test savepoint-17.2 {\n  CREATE TABLE t6(a, b);\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint2.test",
    "content": "# 2008 December 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: savepoint2.test,v 1.5 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# Tests in this file are quite similar to those run by trans.test and\n# avtrans.test.\n#\n\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(x) FROM t3}]\n}\n\ndo_test savepoint2-1 {\n  wal_set_journal_mode\n  execsql {\n    PRAGMA cache_size=10;\n    BEGIN;\n    CREATE TABLE t3(x TEXT);\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    COMMIT;\n    SELECT count(*) FROM t3;\n  }\n} {1024}\nwal_check_journal_mode savepoint2-1.1\n\nunset -nocomplain ::sig\nunset -nocomplain SQL\n\nset iterations 20\n\nset SQL(1) {\n  DELETE FROM t3 WHERE random()%10!=0;\n  INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n  INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n}\nset SQL(2) {\n  DELETE FROM t3 WHERE random()%10!=0;\n  INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n  DELETE FROM t3 WHERE random()%10!=0;\n  INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n} \nset SQL(3) {\n  UPDATE t3 SET x = randstr(10, 400) WHERE random()%10;\n  INSERT INTO t3 SELECT x FROM t3 WHERE random()%10;\n  DELETE FROM t3 WHERE random()%10;\n}\nset SQL(4) {\n  INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE (random()%10 == 0);\n}\n\n\n\nfor {set ii 2} {$ii < ($iterations+2)} {incr ii} {\n\n  # Record the database signature. Optionally (every second run) open a\n  # transaction. In all cases open savepoint \"one\", which may or may\n  # not be a transaction savepoint, depending on whether or not a real\n  # transaction has been opened.\n  #\n  do_test savepoint2-$ii.1 {\n    if {$ii % 2} { execsql BEGIN }\n    set ::sig(one) [signature]\n    execsql \"SAVEPOINT one\"\n  } {}\n\n  # Execute some SQL on the database. Then rollback to savepoint \"one\".\n  # Check that the database signature is as it was when \"one\" was opened.\n  # \n  do_test savepoint2-$ii.2 {\n    execsql $SQL(1)\n    execsql \"ROLLBACK to one\"\n    signature\n  } $::sig(one)\n  integrity_check savepoint2-$ii.2.1\n\n  # Execute some SQL. Then open savepoint \"two\". Savepoint \"two\" is therefore\n  # nested in savepoint \"one\".\n  #\n  do_test savepoint2-$ii.3 {\n    execsql $SQL(1)\n    set ::sig(two) [signature]\n    execsql \"SAVEPOINT two\"\n  } {}\n\n  # More SQL changes. The rollback to savepoint \"two\". Check that the \n  # signature is as it was when savepoint \"two\" was opened.\n  #\n  do_test savepoint2-$ii.4 {\n    execsql $SQL(2)\n    execsql \"ROLLBACK to two\"\n    signature\n  } $::sig(two)\n  integrity_check savepoint2-$ii.4.1\n\n  # More SQL changes. The rollback to savepoint \"two\". Check that the \n  # signature is as it was when savepoint \"two\" was opened.\n  #\n  do_test savepoint2-$ii.5 {\n    execsql $SQL(2)\n    execsql \"SAVEPOINT three\"\n    execsql $SQL(3)\n    execsql \"RELEASE three\"\n    execsql \"ROLLBACK to one\"\n    signature\n  } $::sig(one)\n\n  # By this point the database is in the same state as it was at the \n  # top of the for{} loop (everything having been rolled back by the \n  # \"ROLLBACK TO one\" command above). So make a few changes to the \n  # database and COMMIT the open transaction, so that the next iteration\n  # of the for{} loop works on a different dataset.\n  # \n  # The transaction being committed here may have been opened normally using\n  # \"BEGIN\", or may have been opened using a transaction savepoint created\n  # by the \"SAVEPOINT one\" statement.\n  #\n  do_test savepoint2-$ii.6 {\n    execsql $SQL(4)\n    execsql COMMIT\n    sqlite3_get_autocommit db\n  } {1}\n  integrity_check savepoint2-$ii.6.1\n\n  # Check that the connection is still running in WAL mode.\n  wal_check_journal_mode savepoint2-$ii.7\n}\n\nunset -nocomplain ::sig\nunset -nocomplain SQL\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint4.test",
    "content": "# 2008 December 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: savepoint4.test,v 1.7 2009/06/09 15:25:33 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !crashtest {\n  finish_test\n  return\n}\n\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(x) FROM t1}]\n}\n\nset ITERATIONS 25                   ;# Number of iterations for savepoint4-1\nset ITERATIONS2 13                  ;# Number of iterations for savepoint4-2\nexpr srand(0)\n\ndo_test savepoint4-1 {\n  execsql {\n    PRAGMA cache_size=10;\n    BEGIN;\n    CREATE TABLE t1(x TEXT);\n    INSERT INTO t1 VALUES(randstr(10,400));\n    INSERT INTO t1 VALUES(randstr(10,400));\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {1024}\n\n\nunset -nocomplain ::sig\n\nfor {set ii 1} {$ii<=$ITERATIONS} {incr ii} {\n  set ::sig [signature]\n\n  for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {\n\n    do_test savepoint4-1.$ii.1.$iDelay {\n      set ret [crashsql -delay $iDelay -file test.db-journal {\n        PRAGMA cache_size = 20;\n        SAVEPOINT one;\n          DELETE FROM t1 WHERE random()%2==0;\n          SAVEPOINT two;\n            INSERT INTO t1 SELECT randstr(10,10)||x FROM t1;\n           ROLLBACK TO two;\n            UPDATE t1 SET x = randstr(10, 400) WHERE random()%10;\n          RELEASE two;\n        ROLLBACK TO one;\n        RELEASE one;\n      }]\n      signature\n    } $::sig\n\n    set crashed [lindex $ret 0]\n    integrity_check savepoint4-1.$ii.1.$iDelay.integrity\n  }\n\n  do_test savepoint4-1.$ii.2 {\n    execsql {\n      DELETE FROM t1 WHERE random()%10==0;\n      INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;\n    }\n  } {}\n}\n\ndo_test savepoint4-2 {\n  execsql {\n    PRAGMA cache_size=10;\n    DROP TABLE IF EXISTS t1;\n    BEGIN;\n    CREATE TABLE t1(x TEXT);\n    CREATE INDEX i1 ON t1(x);\n    INSERT INTO t1 VALUES(randstr(10,400));\n    INSERT INTO t1 VALUES(randstr(10,400));\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    INSERT INTO t1 SELECT randstr(10,400) FROM t1;\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {256}\n\nfor {set ii 1} {$ii<=$ITERATIONS2} {incr ii} {\n  set ::sig [signature]\n  set file test.db-journal\n\n  for {set iDelay 1 ; set crashed 1} {$crashed} {incr iDelay} {\n\n    do_test savepoint4-2.$ii.1.$iDelay {\n\n      set ret [crashsql -delay $iDelay -file $file {\n        SAVEPOINT one;\n          INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;\n         ROLLBACK TO one;\n          INSERT INTO t1 SELECT * FROM t1 WHERE rowid<50;\n          SAVEPOINT two;\n            DELETE FROM t1 WHERE (random()%10)==0;\n            SAVEPOINT three;\n              DELETE FROM t1 WHERE (random()%10)==0;\n              SAVEPOINT four;\n                DELETE FROM t1 WHERE (random()%10)==0;\n          RELEASE two;\n\n          SAVEPOINT three;\n            UPDATE t1 SET x = substr(x||x, 12, 100000) WHERE (rowid%12)==0;\n            SAVEPOINT four;\n              UPDATE t1 SET x = substr(x||x, 14, 100000) WHERE (rowid%14)==0;\n           ROLLBACK TO three;\n            UPDATE t1 SET x = substr(x||x, 13, 100000) WHERE (rowid%13)==0;\n          RELEASE three;\n\n        DELETE FROM t1 WHERE rowid > (\n          SELECT rowid FROM t1 ORDER BY rowid ASC LIMIT 1 OFFSET 256\n        );\n        RELEASE one;\n      }]\n\n      set crashed [lindex $ret 0]\n      if {$crashed} {\n        signature\n      } else {\n        set ::sig\n      }\n    } $::sig\n\n    integrity_check savepoint4-2.$ii.1.$iDelay.integrity\n\n    if {$crashed == 0 && $file == \"test.db-journal\"} {\n      set crashed 1\n      set iDelay 0\n      set file test.db\n      set ::sig [signature]\n    }\n  }\n\n  do_test savepoint4-2.$ii.2 {\n    execsql {\n      DELETE FROM t1 WHERE random()%10==0;\n      INSERT INTO t1 SELECT randstr(10,10)||x FROM t1 WHERE random()%9==0;\n    }\n  } {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint5.test",
    "content": "# 2009 January 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Verify that a SAVEPOINT on a new, empty database followed by a\n# ROLLBACK TO that savepoint starts over again with another new\n# empty database.\n#\n# $Id: savepoint5.test,v 1.1 2009/01/02 21:08:09 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test savepoint5-1.1 {\n  db eval {\n    SAVEPOINT sp1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT count(*) FROM sqlite_master;\n    SELECT * FROM t1;\n  }\n} {1 1}\ndo_test savepoint5-1.2 {\n  db eval {\n    ROLLBACK TO sp1;\n    SELECT count(*) FROM sqlite_master;\n  }\n} {0}\ndo_test savepoint5-1.3 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT count(*) FROM sqlite_master;\n    SELECT * FROM t1;\n  }\n} {1 1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint6.test",
    "content": "# 2009 January 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: savepoint6.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc sql {zSql} {\n  uplevel db eval [list $zSql]\n  #puts stderr \"$zSql ;\"\n}\n\nset DATABASE_SCHEMA {\n    PRAGMA auto_vacuum = incremental;\n    CREATE TABLE t1(x, y);\n    CREATE UNIQUE INDEX i1 ON t1(x);\n    CREATE INDEX i2 ON t1(y);\n}\n\nif {0==[info exists ::G(savepoint6_iterations)]} {\n  set ::G(savepoint6_iterations) 1000\n}\n\n#--------------------------------------------------------------------------\n# In memory database state.\n#\n# ::lSavepoint is a list containing one entry for each active savepoint. The\n# first entry in the list corresponds to the most recently opened savepoint.\n# Each entry consists of two elements:\n#\n#   1. The savepoint name.\n#\n#   2. A serialized Tcl array representing the contents of table t1 at the\n#      start of the savepoint. The keys of the array are the x values. The\n#      values are the y values.\n#  \n# Array ::aEntry contains the contents of database table t1. Array keys are\n# x values, the array data values are y values.\n#\nset lSavepoint [list]\narray set aEntry [list]\n\nproc x_to_y {x} {\n  set nChar [expr int(rand()*250) + 250]\n  set str \" $nChar [string repeat $x. $nChar]\"\n  string range $str 1 $nChar\n}\n#--------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Procs to operate on database:\n#\n#   savepoint NAME\n#   rollback  NAME\n#   release   NAME\n#\n#   insert_rows XVALUES\n#   delete_rows XVALUES\n#\nproc savepoint {zName} {\n  catch { sql \"SAVEPOINT $zName\" }\n  lappend ::lSavepoint [list $zName [array get ::aEntry]]\n}\n\nproc rollback {zName} {\n  catch { sql \"ROLLBACK TO $zName\" }\n  for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {\n    set zSavepoint [lindex $::lSavepoint $i 0]\n    if {$zSavepoint eq $zName} {\n      unset -nocomplain ::aEntry\n      array set ::aEntry [lindex $::lSavepoint $i 1]\n\n\n      if {$i+1 < [llength $::lSavepoint]} {\n        set ::lSavepoint [lreplace $::lSavepoint [expr $i+1] end]\n      }\n      break\n    }\n  }\n}\n\nproc release {zName} {\n  catch { sql \"RELEASE $zName\" }\n  for {set i [expr {[llength $::lSavepoint]-1}]} {$i>=0} {incr i -1} {\n    set zSavepoint [lindex $::lSavepoint $i 0]\n    if {$zSavepoint eq $zName} {\n      set ::lSavepoint [lreplace $::lSavepoint $i end]\n      break\n    }\n  }\n\n  if {[llength $::lSavepoint] == 0} {\n    #puts stderr \"-- End of transaction!!!!!!!!!!!!!\"\n  }\n}\n\nproc insert_rows {lX} {\n  foreach x $lX {\n    set y [x_to_y $x]\n\n    # Update database [db]\n    sql \"INSERT OR REPLACE INTO t1 VALUES($x, '$y')\"\n\n    # Update the Tcl database.\n    set ::aEntry($x) $y\n  }\n}\n\nproc delete_rows {lX} {\n  foreach x $lX {\n    # Update database [db]\n    sql \"DELETE FROM t1 WHERE x = $x\"\n\n    # Update the Tcl database.\n    unset -nocomplain ::aEntry($x)\n  }\n}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Proc to compare database content with the in-memory representation.\n#\n#   checkdb\n#\nproc checkdb {} {\n  set nEntry [db one {SELECT count(*) FROM t1}]\n  set nEntry2 [array size ::aEntry]\n  if {$nEntry != $nEntry2} {\n    error \"$nEntry entries in database, $nEntry2 entries in array\"\n  }\n  db eval {SELECT x, y FROM t1} {\n    if {![info exists ::aEntry($x)]} {\n      error \"Entry $x exists in database, but not in array\"\n    }\n    if {$::aEntry($x) ne $y} {\n      error \"Entry $x is set to {$y} in database, {$::aEntry($x)} in array\"\n    }\n  }\n\n  db eval { PRAGMA integrity_check }\n}\n#-------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------\n# Proc to return random set of x values.\n#\n#   random_integers\n#\nproc random_integers {nRes nRange} {\n  set ret [list]\n  for {set i 0} {$i<$nRes} {incr i} {\n    lappend ret [expr int(rand()*$nRange)]\n  }\n  return $ret\n} \n#-------------------------------------------------------------------------\n\nproc database_op {} {\n  set i [expr int(rand()*2)] \n  if {$i==0} {\n    insert_rows [random_integers 100 1000]\n  }\n  if {$i==1} {\n    delete_rows [random_integers 100 1000]\n    set i [expr int(rand()*3)] \n    if {$i==0} {\n      sql {PRAGMA incremental_vacuum}\n    }\n  }\n}\n\nproc savepoint_op {} {\n  set names {one two three four five}\n  set cmds  {savepoint savepoint savepoint savepoint release rollback}\n\n  set C [lindex $cmds [expr int(rand()*6)]]\n  set N [lindex $names [expr int(rand()*5)]]\n\n  #puts stderr \"   $C $N ;  \"\n  #flush stderr\n\n  $C $N\n  return ok\n}\n\nexpr srand(0)\n\n############################################################################\n############################################################################\n# Start of test cases.\n\ndo_test savepoint6-1.1 {\n  sql $DATABASE_SCHEMA\n} {}\ndo_test savepoint6-1.2 {\n  insert_rows {\n    497 166 230 355 779 588 394 317 290 475 362 193 805 851 564 \n    763 44 930 389 819 765 760 966 280 538 414 500 18 25 287 320 \n    30 382 751 87 283 981 429 630 974 421 270 810 405 \n  }\n\n  savepoint one\n  insert_rows 858\n  delete_rows 930\n  savepoint two\n    execsql {PRAGMA incremental_vacuum}\n    savepoint three\n      insert_rows 144\n     rollback three\n    rollback two\n  release one\n\n  execsql {SELECT count(*) FROM t1}\n} {44}\n\nforeach zSetup [list {\n  set testname normal\n  sqlite3 db test.db\n} {\n  if {[wal_is_wal_mode]} continue\n  set testname tempdb\n  sqlite3 db \"\"\n} {\n  if {[permutation] eq \"journaltest\"} {\n    continue\n  }\n  set testname nosync\n  sqlite3 db test.db\n  sql { PRAGMA synchronous = off }\n} {\n  set testname smallcache\n  sqlite3 db test.db\n  sql { PRAGMA cache_size = 10 }\n}] {\n\n  unset -nocomplain ::lSavepoint\n  unset -nocomplain ::aEntry\n\n  catch { db close }\n  forcedelete test.db test.db-wal test.db-journal\n  eval $zSetup\n  sql $DATABASE_SCHEMA\n\n  wal_set_journal_mode\n\n  do_test savepoint6-$testname.setup {\n    savepoint one\n    insert_rows [random_integers 100 1000]\n    release one\n    checkdb\n  } {ok}\n  \n  for {set i 0} {$i < $::G(savepoint6_iterations)} {incr i} {\n    do_test savepoint6-$testname.$i.1 {\n      savepoint_op\n      checkdb\n    } {ok}\n  \n    do_test savepoint6-$testname.$i.2 {\n      database_op\n      database_op\n      checkdb\n    } {ok}\n  }\n\n  wal_check_journal_mode savepoint6-$testname.walok\n}\n\nunset -nocomplain ::lSavepoint\nunset -nocomplain ::aEntry\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepoint7.test",
    "content": "# 2012 March 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Focus on the interaction between RELEASE and ROLLBACK TO with\n# pending query aborts.  See ticket [27ca74af3c083f787a1c44b11fbb7c53bdbbcf1e].\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The RELEASE of an inner savepoint should not effect pending queries.\n#\ndo_test savepoint7-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b,c);\n    CREATE TABLE t2(x,y,z);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(4,5,6);\n    INSERT INTO t1 VALUES(7,8,9);\n    SAVEPOINT x1;\n  }\n  db eval {SELECT * FROM t1} {\n    db eval {\n      SAVEPOINT x2;\n      CREATE TABLE IF NOT EXISTS t3(xyz);\n      INSERT INTO t2 VALUES($a,$b,$c);\n      RELEASE x2;\n    }\n  }\n  db eval {SELECT * FROM t2; RELEASE x1}\n} {1 2 3 4 5 6 7 8 9}\n\ndo_test savepoint7-1.2 {\n  db eval {DELETE FROM t2;}\n  db eval {SELECT * FROM t1} {\n    db eval {\n      SAVEPOINT x2;\n      INSERT INTO t2 VALUES($a,$b,$c);\n      RELEASE x2;\n    }\n  }\n  db eval {SELECT * FROM t2;}\n} {1 2 3 4 5 6 7 8 9}\n\ndo_test savepoint7-1.3 {\n  db eval {DELETE FROM t2; BEGIN;}\n  db eval {SELECT * FROM t1} {\n    db eval {\n      SAVEPOINT x2;\n      INSERT INTO t2 VALUES($a,$b,$c);\n      RELEASE x2;\n    }\n  }\n  db eval {SELECT * FROM t2; ROLLBACK;}\n} {1 2 3 4 5 6 7 8 9}\n\n# However, a ROLLBACK of an inner savepoint will abort all queries, including\n# queries in outer contexts.\n#\ndo_test savepoint7-2.1 {\n  db eval {DELETE FROM t2; SAVEPOINT x1; CREATE TABLE t4(abc);}\n  set rc [catch {\n    db eval {SELECT * FROM t1} {\n      db eval {\n        SAVEPOINT x2;\n        INSERT INTO t2 VALUES($a,$b,$c);\n        ROLLBACK TO x2;\n      }\n    }\n  } msg]\n  db eval {RELEASE x1}\n  list $rc $msg [db eval {SELECT * FROM t2}]\n} {1 {abort due to ROLLBACK} {}}\n\ndo_test savepoint7-2.2 {\n  db eval {DELETE FROM t2;}\n  set rc [catch {\n    db eval {SELECT * FROM t1} {\n      db eval {\n        SAVEPOINT x2;\n        CREATE TABLE t5(pqr);\n        INSERT INTO t2 VALUES($a,$b,$c);\n        ROLLBACK TO x2;\n      }\n    }\n  } msg]\n  list $rc $msg [db eval {SELECT * FROM t2}]\n} {1 {abort due to ROLLBACK} {}}\n\n# Ticket: https://www.sqlite.org/src/tktview/7f7f8026eda387d544b\n# Segfault in the in-memory journal logic triggered by a tricky\n# combination of SAVEPOINT operations.\n#\nunset -nocomplain i\nfor {set i 248} {$i<=253} {incr i} {\n  do_test savepoint7-3.$i {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval {\n      PRAGMA page_size=1024;\n      PRAGMA temp_store=MEMORY;\n      BEGIN;\n      CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);\n      WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<$::i)\n      INSERT INTO t1(x,y) SELECT x*10, printf('%04d%.800c',x,'*') FROM c;\n      SAVEPOINT one;\n        SELECT count(*) FROM t1;\n        WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<$::i)\n        INSERT INTO t1(x,y) SELECT x*10+1, printf('%04d%.800c',x,'*') FROM c;\n      ROLLBACK TO one;\n        SELECT count(*) FROM t1;\n        SAVEPOINT twoB;\n          WITH RECURSIVE c(x) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<10)\n          INSERT INTO t1(x,y) SELECT x*10+2, printf('%04d%.800c',x,'*') FROM c;\n        ROLLBACK TO twoB;\n      RELEASE one;\n      COMMIT;\n    }\n  } [list $i $i]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/savepointfault.test",
    "content": "# 2008 December 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nsource $testdir/malloc_common.tcl\n\nset testprefix savepointfault\n\ndo_malloc_test 1 -sqlprep {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n} -sqlbody {\n  SAVEPOINT one;\n    INSERT INTO t1 VALUES(4, 5, 6);\n    SAVEPOINT two;\n      DELETE FROM t1;\n    ROLLBACK TO two;\n  RELEASE one;\n}\n\ndo_malloc_test 2 -sqlprep {\n  PRAGMA cache_size = 10;\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));\n  INSERT INTO t1 SELECT \n    randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n  INSERT INTO t1 \n    SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;\n} -sqlbody {\n  PRAGMA cache_size = 10;\n  SAVEPOINT one;\n    DELETE FROM t1 WHERE rowid < 5;\n    SAVEPOINT two;\n      DELETE FROM t1 WHERE rowid > 10;\n    ROLLBACK TO two;\n  ROLLBACK TO one;\n  RELEASE one;\n}\n\ndo_ioerr_test 3 -sqlprep {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));\n  INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));\n} -sqlbody {\n  BEGIN;\n    UPDATE t1 SET a = 3 WHERE a = 1;\n    SAVEPOINT one;\n      UPDATE t1 SET a = 4 WHERE a = 2;\n  COMMIT;\n} -cleanup {\n  db eval {\n    SAVEPOINT one;\n    RELEASE one;\n  }\n}\n\n# The following test does a really big savepoint rollback. One involving\n# more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()\n# operation in pagerPlaybackSavepoint() to fail.\n#do_malloc_test 4 -sqlprep {\n#  BEGIN;\n#    CREATE TABLE t1(a, b);\n#    CREATE INDEX i1 ON t1(a);\n#    CREATE INDEX i2 ON t1(b);\n#    INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500));        --     1\n#    INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500));        --     2\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --     4\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --     8\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --    16\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --    32\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --    64\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --   128\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --   256\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --   512\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --  1024\n#    INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; --  2048\n#  COMMIT;\n#  BEGIN;\n#    SAVEPOINT abc;\n#      UPDATE t1 SET a = randstr(500,500);\n#} -sqlbody {\n#    ROLLBACK TO abc;\n#}\n\n\n# Cause a specific malloc in savepoint rollback code to fail.\n#\ndo_malloc_test 4 -start 7 -sqlprep {\n  PRAGMA auto_vacuum = incremental;\n  PRAGMA cache_size = 1000;\n\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  CREATE TABLE t3(a, b);\n  INSERT INTO t1 VALUES(1, randstr(500,500));\n  INSERT INTO t1 VALUES(2, randstr(500,500));\n  INSERT INTO t1 VALUES(3, randstr(500,500));\n  DELETE FROM t1;\n\n  BEGIN;\n    INSERT INTO t1 VALUES(1, randstr(500,500));\n    INSERT INTO t1 VALUES(2, randstr(500,500));\n    INSERT INTO t1 VALUES(3, randstr(500,500));\n    DROP TABLE t3;                  -- Page 5 of the database file is now free.\n    DROP TABLE t2;                  -- Page 4 of the database file is now free.\n\n    SAVEPOINT abc;\n      PRAGMA incremental_vacuum;\n} -sqlbody {\n  ROLLBACK TO abc;\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/scanstatus.test",
    "content": "# 2014 November 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix scanstatus\n\nifcapable !scanstatus {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t2 VALUES('a', 'b');\n  INSERT INTO t2 VALUES('c', 'd');\n  INSERT INTO t2 VALUES('e', 'f');\n}\n\nproc do_scanstatus_test {tn res} {\n  set stmt [db version -last-stmt-ptr]\n  set idx 0\n  set ret [list]\n  while {1} {\n    set r [sqlite3_stmt_scanstatus $stmt $idx]\n    if {[llength $r]==0} break\n    lappend ret {*}$r\n    incr idx\n  }\n\n  uplevel [list do_test $tn [list set {} $ret] [list {*}$res]]\n}\n\ndo_execsql_test 1.1 { SELECT count(*) FROM t1, t2; } 6\ndo_scanstatus_test 1.2 {\n  nLoop 1 nVisit 2 nEst 1048576.0 zName t1 zExplain {SCAN TABLE t1}\n  nLoop 2 nVisit 6 nEst 1048576.0 zName t2 zExplain {SCAN TABLE t2}\n}\n\ndo_execsql_test 1.3 {\n  ANALYZE;\n  SELECT count(*) FROM t1, t2;\n} 6\ndo_scanstatus_test 1.4 {\n  nLoop 1 nVisit 2 nEst 2.0 zName t1 zExplain {SCAN TABLE t1}\n  nLoop 2 nVisit 6 nEst 3.0 zName t2 zExplain {SCAN TABLE t2}\n}\n\ndo_execsql_test 1.5 { ANALYZE }\ndo_execsql_test 1.6 {\n  SELECT count(*) FROM t1, t2 WHERE t2.rowid>1;\n} 4\ndo_scanstatus_test 1.7 {\n  nLoop 1 nVisit 2 nEst 2.0 zName t2 zExplain \n  {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid>?)}\n  nLoop 2 nVisit 4 nEst 2.0 zName t1 zExplain {SCAN TABLE t1}\n}\n\ndo_execsql_test 1.8 {\n  SELECT count(*) FROM t1, t2 WHERE t2.rowid>1;\n} 4\n\ndo_scanstatus_test 1.9 {\n  nLoop 2 nVisit 4 nEst 2.0 zName t2 zExplain \n  {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid>?)}\n  nLoop 4 nVisit 8 nEst 2.0 zName t1 zExplain {SCAN TABLE t1}\n}\n\ndo_test 1.9 {\n  sqlite3_stmt_scanstatus_reset [db version -last-stmt-ptr]\n} {}\n\ndo_scanstatus_test 1.10 {\n  nLoop 0 nVisit 0 nEst 2.0 zName t2 zExplain \n  {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid>?)}\n  nLoop 0 nVisit 0 nEst 2.0 zName t1 zExplain {SCAN TABLE t1}\n}\n\n#-------------------------------------------------------------------------\n# Try a few different types of scans.\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE x1(i INTEGER PRIMARY KEY, j);\n  INSERT INTO x1 VALUES(1, 'one');\n  INSERT INTO x1 VALUES(2, 'two');\n  INSERT INTO x1 VALUES(3, 'three');\n  INSERT INTO x1 VALUES(4, 'four');\n  CREATE INDEX x1j ON x1(j);\n\n  SELECT * FROM x1 WHERE i=2;\n} {2 two}\n\ndo_scanstatus_test 2.2 {\n  nLoop 1 nVisit 1 nEst 1.0 zName x1 \n  zExplain {SEARCH TABLE x1 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\ndo_execsql_test 2.3.1 {\n  SELECT * FROM x1 WHERE j='two'\n} {2 two}\ndo_scanstatus_test 2.3.2 {\n  nLoop 1 nVisit 1 nEst 10.0 zName x1j \n  zExplain {SEARCH TABLE x1 USING COVERING INDEX x1j (j=?)}\n}\n\ndo_execsql_test 2.4.1 {\n  SELECT * FROM x1 WHERE j<'two'\n} {4 four 1 one 3 three}\ndo_scanstatus_test 2.4.2 {\n  nLoop 1 nVisit 3 nEst 262144.0 zName x1j \n  zExplain {SEARCH TABLE x1 USING COVERING INDEX x1j (j<?)}\n}\n\ndo_execsql_test 2.5.1 {\n  SELECT * FROM x1 WHERE j>='two'\n} {2 two}\ndo_scanstatus_test 2.5.2 {\n  nLoop 1 nVisit 1 nEst 262144.0 zName x1j \n  zExplain {SEARCH TABLE x1 USING COVERING INDEX x1j (j>?)}\n}\n\ndo_execsql_test 2.6.1 {\n  SELECT * FROM x1 WHERE j BETWEEN 'three' AND 'two'\n} {3 three 2 two}\ndo_scanstatus_test 2.6.2 {\n  nLoop 1 nVisit 2 nEst 16384.0 zName x1j \n  zExplain {SEARCH TABLE x1 USING COVERING INDEX x1j (j>? AND j<?)}\n}\n\ndo_execsql_test 2.7.1 {\n  CREATE TABLE x2(i INTEGER, j, k);\n  INSERT INTO x2 SELECT i, j, i || ' ' || j FROM x1;\n  CREATE INDEX x2j ON x2(j);\n  CREATE INDEX x2ij ON x2(i, j);\n  SELECT * FROM x2 WHERE j BETWEEN 'three' AND 'two'\n} {3 three {3 three} 2 two {2 two}}\n\ndo_scanstatus_test 2.7.2 {\n  nLoop 1 nVisit 2 nEst 16384.0 zName x2j \n  zExplain {SEARCH TABLE x2 USING INDEX x2j (j>? AND j<?)}\n}\n\ndo_execsql_test 2.8.1 {\n  SELECT * FROM x2 WHERE i=1 AND j='two'\n}\ndo_scanstatus_test 2.8.2 {\n  nLoop 1 nVisit 0 nEst 8.0 zName x2ij \n  zExplain {SEARCH TABLE x2 USING INDEX x2ij (i=? AND j=?)}\n}\n\ndo_execsql_test 2.9.1 {\n  SELECT * FROM x2 WHERE i=5 AND j='two'\n}\ndo_scanstatus_test 2.9.2 {\n  nLoop 1 nVisit 0 nEst 8.0 zName x2ij \n  zExplain {SEARCH TABLE x2 USING INDEX x2ij (i=? AND j=?)}\n}\n\ndo_execsql_test 2.10.1 {\n  SELECT * FROM x2 WHERE i=3 AND j='three'\n} {3 three {3 three}}\ndo_scanstatus_test 2.10.2 {\n  nLoop 1 nVisit 1 nEst 8.0 zName x2ij \n  zExplain {SEARCH TABLE x2 USING INDEX x2ij (i=? AND j=?)}\n}\n\n#-------------------------------------------------------------------------\n# Try with queries that use the OR optimization.\n#\ndo_execsql_test 3.1 {\n  CREATE TABLE a1(a, b, c, d);\n  CREATE INDEX a1a ON a1(a);\n  CREATE INDEX a1bc ON a1(b, c);\n\n  WITH d(x) AS (SELECT 1 UNION ALL SELECT x+1 AS n FROM d WHERE n<=100)\n  INSERT INTO a1 SELECT x, x, x, x FROM d;\n}\n\ndo_execsql_test 3.2.1 {\n  SELECT d FROM a1 WHERE (a=4 OR b=13)\n} {4 13}\ndo_scanstatus_test 3.2.2 {\n  nLoop 1 nVisit 1 nEst 10.0 zName a1a \n  zExplain {SEARCH TABLE a1 USING INDEX a1a (a=?)}\n  nLoop 1 nVisit 1 nEst 10.0 zName a1bc \n  zExplain {SEARCH TABLE a1 USING INDEX a1bc (b=?)}\n}\n\ndo_execsql_test 3.2.1 {\n  SELECT count(*) FROM a1 WHERE (a BETWEEN 4 AND 12) OR (b BETWEEN 40 AND 60)\n} {30}\ndo_scanstatus_test 3.2.2 {\n  nLoop 1 nVisit 9 nEst 16384.0 zName a1a \n  zExplain {SEARCH TABLE a1 USING INDEX a1a (a>? AND a<?)}\n  nLoop 1 nVisit 21 nEst 16384.0 zName a1bc\n  zExplain {SEARCH TABLE a1 USING INDEX a1bc (b>? AND b<?)}\n}\n\ndo_execsql_test 3.3.1 {\n  SELECT count(*) FROM a1 AS x, a1 AS y \n  WHERE (x.a BETWEEN 4 AND 12) AND (y.b BETWEEN 1 AND 10)\n} {90}\ndo_scanstatus_test 3.2.2 {\n  nLoop 1 nVisit 10 nEst 16384.0 zName a1bc \n  zExplain {SEARCH TABLE a1 AS y USING COVERING INDEX a1bc (b>? AND b<?)}\n  nLoop 10 nVisit 90 nEst 16384.0 zName a1a\n  zExplain {SEARCH TABLE a1 AS x USING COVERING INDEX a1a (a>? AND a<?)}\n}\n\ndo_execsql_test 3.4.1 {\n  SELECT count(*) FROM a1 WHERE a IN (1, 5, 10, 15);\n} {4}\ndo_scanstatus_test 3.4.2 {\n  nLoop 1 nVisit 4 nEst 40.0 zName a1a \n  zExplain {SEARCH TABLE a1 USING COVERING INDEX a1a (a=?)}\n}\n\ndo_execsql_test 3.4.1 {\n  SELECT count(*) FROM a1 WHERE rowid IN (1, 5, 10, 15);\n} {4}\ndo_scanstatus_test 3.4.2 {\n  nLoop 1 nVisit 4 nEst 4.0 zName a1\n  zExplain {SEARCH TABLE a1 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\n#-------------------------------------------------------------------------\n# Test that scanstatus() data is not available for searches performed\n# by triggers.\n#\n# It is available for searches performed as part of FK processing, but \n# not FK action processing.\n#\ndo_execsql_test 4.0 {\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(x PRIMARY KEY, y, z);\n  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n    SELECT * FROM t2 WHERE x BETWEEN 20 AND 40;\n  END;\n  WITH d(x) AS (SELECT 1 UNION ALL SELECT x+1 AS n FROM d WHERE n<=100)\n  INSERT INTO t2 SELECT x, x*2, x*3 FROM d;\n}\n\ndo_execsql_test    4.1.1 { INSERT INTO t1 VALUES(1, 2, 3); }\ndo_scanstatus_test 4.1.2 { }\n\ndo_execsql_test 4.2 {\n  CREATE TABLE p1(x PRIMARY KEY);\n  INSERT INTO p1 VALUES(1), (2), (3), (4);\n  CREATE TABLE c1(y REFERENCES p1);\n  INSERT INTO c1 VALUES(1), (2), (3);\n  PRAGMA foreign_keys=on;\n}\ndo_execsql_test    4.2.1 { DELETE FROM p1 WHERE x=4 }\ndo_scanstatus_test 4.2.2 { \n  nLoop 1 nVisit 1 nEst 1.0 zName sqlite_autoindex_p1_1 \n  zExplain {SEARCH TABLE p1 USING INDEX sqlite_autoindex_p1_1 (x=?)}\n\n  nLoop 1 nVisit 3 nEst 262144.0 zName c1 zExplain {SCAN TABLE c1}\n}\n\n#-------------------------------------------------------------------------\n# Further tests of different scan types.\n#\nreset_db\nproc tochar {i} {\n  set alphabet {a b c d e f g h i j k l m n o p q r s t u v w x y z}\n  return [lindex $alphabet [expr $i % [llength $alphabet]]]\n}\ndb func tochar tochar\ndo_execsql_test 5.0 {\n  CREATE TABLE t1(a PRIMARY KEY, b, c);\n  INSERT INTO t1 VALUES(0, 1, 'a');\n  INSERT INTO t1 VALUES(1, 0, 'b');\n  INSERT INTO t1 VALUES(2, 1, 'c');\n  INSERT INTO t1 VALUES(3, 0, 'd');\n  INSERT INTO t1 VALUES(4, 1, 'e');\n  INSERT INTO t1 VALUES(5, 0, 'a');\n  INSERT INTO t1 VALUES(6, 1, 'b');\n  INSERT INTO t1 VALUES(7, 0, 'c');\n  INSERT INTO t1 VALUES(8, 1, 'd');\n  INSERT INTO t1 VALUES(9, 0, 'e');\n  CREATE INDEX t1bc ON t1(b, c);\n\n  CREATE TABLE t2(x, y);\n  CREATE INDEX t2xy ON t2(x, y);\n  WITH data(i, x, y) AS (\n    SELECT 0, 0, tochar(0) \n    UNION ALL\n    SELECT i+1, (i+1)%2, tochar(i+1) FROM data WHERE i<500\n  ) INSERT INTO t2 SELECT x, y FROM data;\n\n  CREATE TABLE t3(x, y);\n  INSERT INTO t3 SELECT * FROM t2;\n\n  ANALYZE;\n}\n\ndo_execsql_test 5.1.1 {\n  SELECT count(*) FROM t1 WHERE a IN (SELECT b FROM t1 AS ii)\n} {2}\ndo_scanstatus_test 5.1.2 { \n  nLoop 1 nVisit 10 nEst 10.0 zName t1bc \n  zExplain {SCAN TABLE t1 AS ii USING COVERING INDEX t1bc}\n  nLoop 1 nVisit 2 nEst 8.0 zName sqlite_autoindex_t1_1\n  zExplain {SEARCH TABLE t1 USING COVERING INDEX sqlite_autoindex_t1_1 (a=?)}\n}\n\ndo_execsql_test 5.2.1 {\n  SELECT count(*) FROM t1 WHERE a IN (0, 1)\n} {2}\ndo_scanstatus_test 5.2.2 { \n  nLoop 1 nVisit 2 nEst 2.0 zName sqlite_autoindex_t1_1\n  zExplain {SEARCH TABLE t1 USING COVERING INDEX sqlite_autoindex_t1_1 (a=?)}\n}\n\ndo_eqp_test 5.3.1 {\n  SELECT count(*) FROM t2 WHERE y = 'j';\n} {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}}\ndo_execsql_test 5.3.2 {\n  SELECT count(*) FROM t2 WHERE y = 'j';\n} {19}\ndo_scanstatus_test 5.3.3 { \n  nLoop 1 nVisit 19 nEst 56.0 zName t2xy zExplain\n  {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}\n}\n\ndo_eqp_test 5.4.1 {\n  SELECT count(*) FROM t1, t2 WHERE y = c;\n} {\n  0 0 0 {SCAN TABLE t1 USING COVERING INDEX t1bc}\n  0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}\n}\ndo_execsql_test 5.4.2 {\n  SELECT count(*) FROM t1, t2 WHERE y = c;\n} {200}\ndo_scanstatus_test 5.4.3 { \n  nLoop 1 nVisit 10 nEst 10.0 zName t1bc \n  zExplain {SCAN TABLE t1 USING COVERING INDEX t1bc}\n  nLoop 10 nVisit 200 nEst 56.0 zName t2xy \n  zExplain {SEARCH TABLE t2 USING COVERING INDEX t2xy (ANY(x) AND y=?)}\n}\n\ndo_eqp_test 5.5.1 {\n  SELECT count(*) FROM t1, t3 WHERE y = c;\n} {\n  0 0 1 {SCAN TABLE t3} \n  0 1 0 {SEARCH TABLE t1 USING AUTOMATIC COVERING INDEX (c=?)}\n}\ndo_execsql_test 5.5.2 {\n  SELECT count(*) FROM t1, t3 WHERE y = c;\n} {200}\ndo_scanstatus_test 5.5.3 { \n  nLoop 1 nVisit 501 nEst 480.0 zName t3 zExplain {SCAN TABLE t3}\n  nLoop 501 nVisit 200 nEst 20.0 zName auto-index zExplain\n  {SEARCH TABLE t1 USING AUTOMATIC COVERING INDEX (c=?)}\n}\n\n#-------------------------------------------------------------------------\n# Virtual table scans\n#\nifcapable fts3 {\n  do_execsql_test 6.0 {\n    CREATE VIRTUAL TABLE ft1 USING fts4;\n    INSERT INTO ft1 VALUES('a d c f g h e i f c');\n    INSERT INTO ft1 VALUES('g c h b g b f f f g');\n    INSERT INTO ft1 VALUES('h h c c h f a e d d');\n    INSERT INTO ft1 VALUES('e j i j i e b c f g');\n    INSERT INTO ft1 VALUES('g f b g j c h a d f');\n    INSERT INTO ft1 VALUES('j i a e g f a i a c');\n    INSERT INTO ft1 VALUES('f d g g j j c a h g');\n    INSERT INTO ft1 VALUES('b d h a d j j j b i');\n    INSERT INTO ft1 VALUES('j e a b j e c b c i');\n    INSERT INTO ft1 VALUES('a d e f b j j c g d');\n  }\n  do_execsql_test 6.1.1 {\n    SELECT count(*) FROM ft1 WHERE ft1 MATCH 'd'\n  } {6}\n  do_scanstatus_test 6.1.2 { \n    nLoop 1 nVisit 6 nEst 24.0 zName ft1 zExplain \n    {SCAN TABLE ft1 VIRTUAL TABLE INDEX 3:}\n  }\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema.test",
    "content": "# 2005 Jan 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests the various conditions under which an SQLITE_SCHEMA\n# error should be returned.\n#\n# $Id: schema.test,v 1.9 2009/02/04 17:40:58 drh Exp $\n\n#---------------------------------------------------------------------\n# When any of the following types of SQL statements or actions are \n# executed, all pre-compiled statements are invalidated. An attempt\n# to execute an invalidated statement always returns SQLITE_SCHEMA.\n#\n# CREATE/DROP TABLE...................................schema-1.*\n# CREATE/DROP VIEW....................................schema-2.*\n# CREATE/DROP TRIGGER.................................schema-3.*\n# CREATE/DROP INDEX...................................schema-4.*\n# DETACH..............................................schema-5.*\n# Deleting a user-function............................schema-6.*\n# Deleting a collation sequence.......................schema-7.*\n# Setting or changing the authorization function......schema-8.*\n# Rollback of a DDL statement.........................schema-12.*\n#\n# Test cases schema-9.* and schema-10.* test some specific bugs\n# that came up during development.\n#\n# Test cases schema-11.* test that it is impossible to delete or\n# change a collation sequence or user-function while SQL statements\n# are executing. Adding new collations or functions is allowed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test schema-1.1 {\n  set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    CREATE TABLE abc(a, b, c);\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ERROR}\ndo_test schema-1.2 {\n  sqlite3_finalize $::STMT\n} {SQLITE_SCHEMA}\ndo_test schema-1.3 {\n  set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    DROP TABLE abc;\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ERROR}\ndo_test schema-1.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_SCHEMA}\n\nifcapable view {\n  do_test schema-2.1 {\n    set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM sqlite_master;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-2.2 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n  do_test schema-2.3 {\n    set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      DROP VIEW v1;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-2.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n}\n\nifcapable trigger {\n  do_test schema-3.1 {\n    execsql {\n      CREATE TABLE abc(a, b, c);\n    }\n    set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      CREATE TRIGGER abc_trig AFTER INSERT ON abc BEGIN\n        SELECT 1, 2, 3;\n      END;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-3.2 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n  do_test schema-3.3 {\n    set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      DROP TRIGGER abc_trig;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-3.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n}\n\ndo_test schema-4.1 {\n  catchsql {\n    CREATE TABLE abc(a, b, c);\n  }\n  set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    CREATE INDEX abc_index ON abc(a);\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ERROR}\ndo_test schema-4.2 {\n  sqlite3_finalize $::STMT\n} {SQLITE_SCHEMA}\ndo_test schema-4.3 {\n  set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    DROP INDEX abc_index;\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ERROR}\ndo_test schema-4.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_SCHEMA}\n\n#---------------------------------------------------------------------\n# Tests 5.1 to 5.4 check that prepared statements are invalidated when\n# a database is DETACHed (but not when one is ATTACHed).\n#\nifcapable attach {\n  do_test schema-5.1 {\n    set sql {SELECT * FROM abc;}\n    set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n    execsql {\n      ATTACH 'test2.db' AS aux;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema-5.2 {\n    sqlite3_reset $::STMT\n  } {SQLITE_OK}\n  do_test schema-5.3 {\n    execsql {\n      DETACH aux;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-5.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n}\n\n#---------------------------------------------------------------------\n# Tests 6.* check that prepared statements are invalidated when\n# a user-function is deleted (but not when one is added).\ndo_test schema-6.1 {\n  set sql {SELECT * FROM abc;}\n  set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n  db function hello_function {}\n  sqlite3_step $::STMT\n} {SQLITE_DONE}\ndo_test schema-6.2 {\n  sqlite3_reset $::STMT\n} {SQLITE_OK}\ndo_test schema-6.3 {\n  sqlite_delete_function $::DB hello_function\n  sqlite3_step $::STMT\n} {SQLITE_ERROR}\ndo_test schema-6.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_SCHEMA}\n\n#---------------------------------------------------------------------\n# Tests 7.* check that prepared statements are invalidated when\n# a collation sequence is deleted (but not when one is added).\n#\nifcapable utf16 {\n  do_test schema-7.1 {\n    set sql {SELECT * FROM abc;}\n    set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n    add_test_collate $::DB 1 1 1\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema-7.2 {\n    sqlite3_reset $::STMT\n  } {SQLITE_OK}\n  do_test schema-7.3 {\n    add_test_collate $::DB 0 0 0 \n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-7.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n}\n\n#---------------------------------------------------------------------\n# Tests 8.1 and 8.2 check that prepared statements are invalidated when\n# the authorization function is set.\n#\nifcapable auth {\n  do_test schema-8.1 {\n    set ::STMT [sqlite3_prepare $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    db auth {}\n    sqlite3_step $::STMT\n  } {SQLITE_ERROR}\n  do_test schema-8.3 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_SCHEMA}\n}\n\n#---------------------------------------------------------------------\n# schema-9.1: Test that if a table is dropped by one database connection, \n#             other database connections are aware of the schema change.\n# schema-9.2: Test that if a view is dropped by one database connection,\n#             other database connections are aware of the schema change.\n#\ndo_test schema-9.1 {\n  sqlite3 db2 test.db\n  execsql {\n    DROP TABLE abc;\n  } db2\n  db2 close\n  catchsql {\n    SELECT * FROM abc;\n  }\n} {1 {no such table: abc}}\nexecsql {\n  CREATE TABLE abc(a, b, c);\n}\nifcapable view {\n  do_test schema-9.2 {\n    execsql {\n      CREATE VIEW abcview AS SELECT * FROM abc;\n    }\n    sqlite3 db2 test.db\n    execsql {\n      DROP VIEW abcview;\n    } db2\n    db2 close\n    catchsql {\n      SELECT * FROM abcview;\n    }\n  } {1 {no such table: abcview}}\n}\n\n#---------------------------------------------------------------------\n# Test that if a CREATE TABLE statement fails because there are other\n# btree cursors open on the same database file it does not corrupt\n# the sqlite_master table.\n#\n# 2007-05-02: These tests have been overcome by events.  Open btree\n# cursors no longer block CREATE TABLE.  But there is no reason not\n# to keep the tests in the test suite.\n#\ndo_test schema-10.1 {\n  execsql {\n    INSERT INTO abc VALUES(1, 2, 3);\n  }\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema-10.2 {\n  catchsql {\n    CREATE TABLE t2(a, b, c);\n  }\n} {0 {}}\ndo_test schema-10.3 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema-10.4 {\n  sqlite3 db2 test.db\n  execsql {\n    SELECT * FROM abc\n  } db2\n} {1 2 3}\ndo_test schema-10.5 {\n  db2 close\n} {}\n\n#---------------------------------------------------------------------\n# Attempting to delete or replace a user-function or collation sequence \n# while there are active statements returns an SQLITE_BUSY error.\n#\n# schema-11.1 - 11.4: User function.\n# schema-11.5 - 11.8: Collation sequence.\n#\ndo_test schema-11.1 {\n  db function tstfunc {}\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema-11.2 {\n  sqlite_delete_function $::DB tstfunc\n} {SQLITE_BUSY}\ndo_test schema-11.3 {\n  set rc [catch {\n    db function tstfunc {}\n  } msg]\n  list $rc $msg\n} {1 {unable to delete/modify user-function due to active statements}}\ndo_test schema-11.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema-11.5 {\n  db collate tstcollate {}\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema-11.6 {\n  sqlite_delete_collation $::DB tstcollate\n} {SQLITE_BUSY}\ndo_test schema-11.7 {\n  set rc [catch {\n    db collate tstcollate {}\n  } msg]\n  list $rc $msg\n} {1 {unable to delete/modify collation sequence due to active statements}}\ndo_test schema-11.8 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\n# The following demonstrates why statements need to be expired whenever\n# there is a rollback (explicit or otherwise).\n#\ndo_test schema-12.1 {\n  # Begin a transaction and create a table. This increments \n  # the schema cookie. Then compile an SQL statement, using\n  # the current (incremented) value of the cookie.\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(a, b, c);\n  }\n  set ::STMT [sqlite3_prepare $::DB \"CREATE TABLE t4(a,b,c)\" -1 TAIL]\n\n  # Rollback the transaction, resetting the schema cookie to the value\n  # it had at the start of this test case. Then create a table, \n  # incrementing the schema cookie.\n  execsql {\n    ROLLBACK;\n    CREATE TABLE t4(a, b, c);\n  }\n\n  # The schema cookie now has the same value as it did when SQL statement\n  # $::STMT was prepared. So unless it has been expired, it would be\n  # possible to run the \"CREATE TABLE t4\" statement and create a\n  # duplicate table.\n  list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]\n} {SQLITE_ERROR SQLITE_SCHEMA}\n\nifcapable {auth} {\n\ndo_test schema-13.1 {\n  set S [sqlite3_prepare_v2 db \"SELECT * FROM sqlite_master\" -1 dummy]\n  db function hello hello\n  db function hello {}\n  db auth auth\n  proc auth {args} {\n    if {[lindex $args 0] == \"SQLITE_READ\"} {return SQLITE_DENY}\n    return SQLITE_OK\n  }\n  sqlite3_step $S\n} {SQLITE_AUTH}\n\ndo_test schema-13.2 {\n  sqlite3_step $S\n} {SQLITE_AUTH}\n\ndo_test schema-13.3 {\n  sqlite3_finalize $S\n} {SQLITE_AUTH}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema2.test",
    "content": "# 2006 November 08\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file tests the various conditions under which an SQLITE_SCHEMA\n# error should be returned.  This is a copy of schema.test that\n# has been altered to use sqlite3_prepare_v2 instead of sqlite3_prepare\n#\n# $Id: schema2.test,v 1.4 2009/02/04 17:40:58 drh Exp $\n\n#---------------------------------------------------------------------\n# When any of the following types of SQL statements or actions are \n# executed, all pre-compiled statements are invalidated. An attempt\n# to execute an invalidated statement always returns SQLITE_SCHEMA.\n#\n# CREATE/DROP TABLE...................................schema2-1.*\n# CREATE/DROP VIEW....................................schema2-2.*\n# CREATE/DROP TRIGGER.................................schema2-3.*\n# CREATE/DROP INDEX...................................schema2-4.*\n# DETACH..............................................schema2-5.*\n# Deleting a user-function............................schema2-6.*\n# Deleting a collation sequence.......................schema2-7.*\n# Setting or changing the authorization function......schema2-8.*\n#\n# Test cases schema2-9.* and schema2-10.* test some specific bugs\n# that came up during development.\n#\n# Test cases schema2-11.* test that it is impossible to delete or\n# change a collation sequence or user-function while SQL statements\n# are executing. Adding new collations or functions is allowed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test schema2-1.1 {\n  set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    CREATE TABLE abc(a, b, c);\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-1.2 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema2-1.3 {\n  set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    DROP TABLE abc;\n  }\n  sqlite3_step $::STMT\n} {SQLITE_DONE}\ndo_test schema2-1.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\n\nifcapable view {\n  do_test schema2-2.1 {\n    set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      CREATE VIEW v1 AS SELECT * FROM sqlite_master;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ROW}\n  do_test schema2-2.2 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n  do_test schema2-2.3 {\n    set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      DROP VIEW v1;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema2-2.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n}\n\nifcapable trigger {\n  do_test schema2-3.1 {\n    execsql {\n      CREATE TABLE abc(a, b, c);\n    }\n    set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      CREATE TRIGGER abc_trig AFTER INSERT ON abc BEGIN\n        SELECT 1, 2, 3;\n      END;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ROW}\n  do_test schema2-3.2 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n  do_test schema2-3.3 {\n    set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    execsql {\n      DROP TRIGGER abc_trig;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_ROW}\n  do_test schema2-3.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n}\n\ndo_test schema2-4.1 {\n  catchsql {\n    CREATE TABLE abc(a, b, c);\n  }\n  set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    CREATE INDEX abc_index ON abc(a);\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-4.2 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema2-4.3 {\n  set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n  execsql {\n    DROP INDEX abc_index;\n  }\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-4.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\n#---------------------------------------------------------------------\n# Tests 5.1 to 5.4 check that prepared statements are invalidated when\n# a database is DETACHed (but not when one is ATTACHed).\n#\nifcapable attach {\n  do_test schema2-5.1 {\n    set sql {SELECT * FROM abc;}\n    set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n    execsql {\n      ATTACH 'test2.db' AS aux;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema2-5.2 {\n    sqlite3_reset $::STMT\n  } {SQLITE_OK}\n  do_test schema2-5.3 {\n    execsql {\n      DETACH aux;\n    }\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema2-5.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n}\n\n#---------------------------------------------------------------------\n# Tests 6.* check that prepared statements are invalidated when\n# a user-function is deleted (but not when one is added).\ndo_test schema2-6.1 {\n  set sql {SELECT * FROM abc;}\n  set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n  db function hello_function {}\n  sqlite3_step $::STMT\n} {SQLITE_DONE}\ndo_test schema2-6.2 {\n  sqlite3_reset $::STMT\n} {SQLITE_OK}\ndo_test schema2-6.3 {\n  sqlite_delete_function $::DB hello_function\n  sqlite3_step $::STMT\n} {SQLITE_DONE}\ndo_test schema2-6.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\n#---------------------------------------------------------------------\n# Tests 7.* check that prepared statements are invalidated when\n# a collation sequence is deleted (but not when one is added).\n#\nifcapable utf16 {\n  do_test schema2-7.1 {\n    set sql {SELECT * FROM abc;}\n    set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n    add_test_collate $::DB 1 1 1\n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema2-7.2 {\n    sqlite3_reset $::STMT\n  } {SQLITE_OK}\n  do_test schema2-7.3 {\n    add_test_collate $::DB 0 0 0 \n    sqlite3_step $::STMT\n  } {SQLITE_DONE}\n  do_test schema2-7.4 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n}\n\n#---------------------------------------------------------------------\n# Tests 8.1 and 8.2 check that prepared statements are invalidated when\n# the authorization function is set.\n#\nifcapable auth {\n  do_test schema2-8.1 {\n    set ::STMT [sqlite3_prepare_v2 $::DB {SELECT * FROM sqlite_master} -1 TAIL]\n    db auth {}\n    sqlite3_step $::STMT\n  } {SQLITE_ROW}\n  do_test schema2-8.3 {\n    sqlite3_finalize $::STMT\n  } {SQLITE_OK}\n}\n\n#---------------------------------------------------------------------\n# schema2-9.1: Test that if a table is dropped by one database connection, \n#             other database connections are aware of the schema change.\n# schema2-9.2: Test that if a view is dropped by one database connection,\n#             other database connections are aware of the schema change.\n#\ndo_test schema2-9.1 {\n  sqlite3 db2 test.db\n  execsql {\n    DROP TABLE abc;\n  } db2\n  db2 close\n  catchsql {\n    SELECT * FROM abc;\n  }\n} {1 {no such table: abc}}\nexecsql {\n  CREATE TABLE abc(a, b, c);\n}\nifcapable view {\n  do_test schema2-9.2 {\n    execsql {\n      CREATE VIEW abcview AS SELECT * FROM abc;\n    }\n    sqlite3 db2 test.db\n    execsql {\n      DROP VIEW abcview;\n    } db2\n    db2 close\n    catchsql {\n      SELECT * FROM abcview;\n    }\n  } {1 {no such table: abcview}}\n}\n\n#---------------------------------------------------------------------\n# Test that if a CREATE TABLE statement fails because there are other\n# btree cursors open on the same database file it does not corrupt\n# the sqlite_master table.\n#\n# 2007-05-02: These tests have been overcome by events.  Open btree\n# cursors no longer block CREATE TABLE.  But there is no reason not\n# to keep the tests in the test suite.\n#\ndo_test schema2-10.1 {\n  execsql {\n    INSERT INTO abc VALUES(1, 2, 3);\n  }\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-10.2 {\n  catchsql {\n    CREATE TABLE t2(a, b, c);\n  }\n} {0 {}}\ndo_test schema2-10.3 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema2-10.4 {\n  sqlite3 db2 test.db\n  execsql {\n    SELECT * FROM abc\n  } db2\n} {1 2 3}\ndo_test schema2-10.5 {\n  db2 close\n} {}\n\n#---------------------------------------------------------------------\n# Attempting to delete or replace a user-function or collation sequence \n# while there are active statements returns an SQLITE_BUSY error.\n#\n# schema2-11.1 - 11.4: User function.\n# schema2-11.5 - 11.8: Collation sequence.\n#\ndo_test schema2-11.1 {\n  db function tstfunc {}\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-11.2 {\n  sqlite_delete_function $::DB tstfunc\n} {SQLITE_BUSY}\ndo_test schema2-11.3 {\n  set rc [catch {\n    db function tstfunc {}\n  } msg]\n  list $rc $msg\n} {1 {unable to delete/modify user-function due to active statements}}\ndo_test schema2-11.4 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test schema2-11.5 {\n  db collate tstcollate {}\n  set sql {SELECT * FROM abc}\n  set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 TAIL]\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test schema2-11.6 {\n  sqlite_delete_collation $::DB tstcollate\n} {SQLITE_BUSY}\ndo_test schema2-11.7 {\n  set rc [catch {\n    db collate tstcollate {}\n  } msg]\n  list $rc $msg\n} {1 {unable to delete/modify collation sequence due to active statements}}\ndo_test schema2-11.8 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema3.test",
    "content": "# 2010 Jun 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/lock_common.tcl\n\n# This block tests that if one client modifies the database schema, a\n# second client updates its internal cache of the database schema before\n# executing any queries. Specifically, it does not return a \"no such column\"\n# or \"no such table\" error if the table or column in question does exist\n# but was added after the second client loaded its cache of the database\n# schema.\n#\n# Types of schema modifications:\n#\n#   1. Adding a database table.\n#   2. Adding a database view.\n#   3. Adding a database index.\n#   4. Adding a database trigger.\n#   5. Adding a column to an existing table (ALTER TABLE).\n#\ndo_multiclient_test tn {\n\n  # Have connections [db1] and [db2] load the current database schema.\n  #\n  sql1 { SELECT * FROM sqlite_master }\n  sql2 { SELECT * FROM sqlite_master }\n\n  foreach {tn2 c1 c2} {\n    1  { CREATE TABLE t1(a, b) }       { SELECT * FROM t1            }\n    2  { CREATE TABLE t2(a, b) }       { UPDATE t2 SET a = b         }\n    3  { CREATE TABLE t3(a, b) }       { DELETE FROM t3              }\n    4  { CREATE TABLE t4(a, b) }       { INSERT INTO t4 VALUES(1, 2) }\n    5  { CREATE TABLE t5(a, b) }       { DROP TABLE t5 }\n    6  { CREATE TABLE t6(a, b) }       { CREATE INDEX i1 ON t6(a) }\n\n    7  { ALTER TABLE t1 ADD COLUMN c } { SELECT a, b, c FROM t1 }\n    8  { ALTER TABLE t2 ADD COLUMN c } { UPDATE t2 SET a = c }\n    9  { ALTER TABLE t2 ADD COLUMN d } { UPDATE t2 SET d = c }\n    10 { ALTER TABLE t3 ADD COLUMN c } { DELETE FROM t3 WHERE c>10 }\n    11 { ALTER TABLE t4 ADD COLUMN c } { INSERT INTO t4(a,b,c) VALUES(1,2,3) }\n    12 { ALTER TABLE t6 ADD COLUMN c } { CREATE INDEX i2 ON t6(c) }\n    13 { ALTER TABLE t6 ADD COLUMN d } { \n         CREATE TRIGGER tr1 AFTER UPDATE OF d ON t6 BEGIN\n           SELECT 1, 2, 3;\n         END;\n    }\n\n    14 { CREATE INDEX i3 ON t1(a) }    { DROP INDEX i3 }\n    15 { CREATE INDEX i4 ON t2(a) }    {\n         SELECT * FROM t2 INDEXED BY i4 ORDER BY a\n    }\n\n    16 { CREATE TRIGGER tr2 AFTER INSERT ON t3 BEGIN SELECT 1 ; END } {\n         DROP TRIGGER tr2\n    }\n\n    17  { CREATE VIEW v1 AS SELECT * FROM t1 } { SELECT a,b,c   FROM v1 }\n    18  { ALTER TABLE t1 ADD COLUMN d        } { SELECT a,b,c,d FROM v1 }\n\n    19  { CREATE TABLE t7(a, b) } {\n          DROP TABLE IF EXISTS t7; CREATE TABLE t7(c, d);\n    }\n    20  { CREATE INDEX i5 ON t7(c, d) } {\n          DROP INDEX IF EXISTS i5; CREATE INDEX i5 ON t7(c)\n    }\n    21  { CREATE TRIGGER tr3 BEFORE DELETE ON t7 BEGIN SELECT 1, 2, 3 ; END } {\n          DROP TRIGGER IF EXISTS tr3;\n          CREATE TRIGGER tr3 AFTER INSERT ON t7 BEGIN SELECT 1, 2, 3 ; END \n    }\n\n    22  { CREATE TABLE t8(a, b) }       {\n         CREATE TRIGGER tr4 AFTER UPDATE OF a ON t8 BEGIN\n           SELECT 1, 2, 3;\n         END;\n    }\n  } {\n    do_test schema3-1.$tn.$tn2 {\n      sql1 $c1\n      sql2 $c2\n    } {}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema4.test",
    "content": "# 2010 September 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus of this file is testing that a trigger may have the same\n# name as an index, view or table in the same database.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#--------------------------------------------------------------------------\n# Test organization:\n#\n#   schema4-1.*: Dropping and creating triggers and other objects where\n#     triggers and at least on other object share a name.\n#\n#   schema4-2.*: Renaming tables where there is a trigger that shares the\n#     name of the table or one of its indices.\n#\n\ndo_execsql_test schema4-1.1 {\n  CREATE TABLE log(x, a, b);\n  CREATE TABLE tbl(a, b);\n\n  CREATE TABLE t1(a, b);\n  CREATE VIEW v1 AS SELECT * FROM tbl;\n  CREATE INDEX i1 ON tbl(a);\n} {}\n\ndo_execsql_test schema4-1.2 {\n  CREATE TRIGGER t1 AFTER INSERT ON tbl BEGIN\n    INSERT INTO log VALUES('after insert', new.a, new.b);\n  END;\n  CREATE TRIGGER v1 AFTER UPDATE ON tbl BEGIN\n    INSERT INTO log VALUES('after update', new.a, new.b);\n  END;\n  CREATE TRIGGER i1 AFTER DELETE ON tbl BEGIN\n    INSERT INTO log VALUES('after delete', old.a, old.b);\n  END;\n} {}\n\ndo_execsql_test schema4-1.3 {\n  INSERT INTO tbl VALUES(1, 2);\n  UPDATE tbl SET b=a+b, a=a+1;\n  DELETE FROM tbl;\n\n  SELECT x, a, b FROM log;\n} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}\n\ndo_execsql_test schema4-1.4 {\n  DELETE FROM log;\n\n  DROP INDEX i1;\n  DROP TABLE t1;\n  DROP VIEW v1;\n\n  INSERT INTO tbl VALUES(1, 2);\n  UPDATE tbl SET b=a+b, a=a+1;\n  DELETE FROM tbl;\n\n  SELECT x, a, b FROM log;\n} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}\n\ndb close\nsqlite3 db test.db\n\ndo_execsql_test schema4-1.5 {\n  DELETE FROM log;\n  INSERT INTO tbl VALUES(1, 2);\n  UPDATE tbl SET b=a+b, a=a+1;\n  DELETE FROM tbl;\n  SELECT x, a, b FROM log;\n} {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}\n\ndo_execsql_test schema4-1.6 {\n  CREATE TABLE t1(a, b);\n  CREATE VIEW v1 AS SELECT * FROM tbl;\n  CREATE INDEX i1 ON tbl(a);\n} {}\n\nifcapable fts3 {\n  do_execsql_test schema4-1.7 {\n    DROP TABLE t1;\n    CREATE VIRTUAL TABLE t1 USING fts3;\n  } {}\n\n  do_execsql_test schema4-1.8 {\n    DELETE FROM log;\n    DROP TABLE t1;\n    INSERT INTO tbl VALUES(1, 2);\n    UPDATE tbl SET b=a+b, a=a+1;\n    DELETE FROM tbl;\n    SELECT x, a, b FROM log;\n  } {{after insert} 1 2 {after update} 2 3 {after delete} 2 3}\n}\n\nifcapable altertable {\n  drop_all_tables\n  do_execsql_test schema4-2.1 {\n    CREATE TABLE log(x, a, b);\n    CREATE TABLE tbl(a, b);\n  \n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n  } {}\n  \n  do_execsql_test schema4-2.2 {\n    CREATE TRIGGER t1 AFTER INSERT ON tbl BEGIN\n      INSERT INTO log VALUES('after insert', new.a, new.b);\n    END;\n    CREATE TRIGGER i1 AFTER DELETE ON tbl BEGIN\n      INSERT INTO log VALUES('after delete', old.a, old.b);\n    END;\n  } {}\n\n  do_execsql_test schema4-2.3 { ALTER TABLE t1 RENAME TO t2 } {}\n\n  do_execsql_test schema4-2.4 { \n    INSERT INTO tbl VALUES('a', 'b');\n    DELETE FROM tbl;\n    SELECT * FROM log;\n  } {{after insert} a b {after delete} a b}\n\n  db close\n  sqlite3 db test.db\n\n  do_execsql_test schema4-2.5 { \n    DELETE FROM log;\n    INSERT INTO tbl VALUES('c', 'd');\n    DELETE FROM tbl;\n    SELECT * FROM log;\n  } {{after insert} c d {after delete} c d}\n\n  do_execsql_test schema4-2.6 {\n    CREATE TEMP TRIGGER x1 AFTER UPDATE ON tbl BEGIN\n      INSERT INTO log VALUES('after update', new.a, new.b);\n    END;\n\n    CREATE TEMP TABLE x1(x);\n    INSERT INTO x1 VALUES(123);\n  } {}\n\n  do_execsql_test schema4-2.8 {\n    select sql from temp.sqlite_master WHERE type='table';\n  } {{CREATE TABLE x1(x)}}\n\n  do_execsql_test schema4-2.7 { ALTER TABLE tbl RENAME TO tbl2 } {}\n\n  do_execsql_test schema4-2.9 {\n    select sql from sqlite_temp_master WHERE type='table';\n  } {{CREATE TABLE x1(x)}}\n\n  do_execsql_test schema4-2.10 { \n    DELETE FROM log;\n    INSERT INTO tbl2 VALUES('e', 'f');\n    UPDATE tbl2 SET a='g', b='h';\n    DELETE FROM tbl2;\n    SELECT * FROM log;\n  } {{after insert} e f {after update} g h {after delete} g h}\n\n  do_execsql_test schema4-2.11 {\n    INSERT INTO x1 VALUES(456);\n    SELECT * FROM x1\n  } {123 456}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema5.test",
    "content": "# 2010 September 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file checks corner cases in the CREATE TABLE syntax to make\n# sure that legacy syntax (syntax that is disallowed according to the\n# syntax diagrams) is still accepted, so that older databases that use\n# that syntax can still be read.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Table constraints should be separated by commas, but they do not have\n# to be.\n#\ndo_test schema5-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b,c, PRIMARY KEY(a) UNIQUE (a) CONSTRAINT one);\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {1 2 3}\ndo_test schema5-1.2 {\n  catchsql {INSERT INTO t1 VALUES(1,3,4);}\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test schema5-1.3 {\n  db eval {\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c,\n        CONSTRAINT one PRIMARY KEY(a) CONSTRAINT two CHECK(b<10) UNIQUE(b)\n        CONSTRAINT three\n    );\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {1 2 3}\ndo_test schema5-1.4 {\n  catchsql {INSERT INTO t1 VALUES(10,11,12);}\n} {1 {CHECK constraint failed: two}}\ndo_test schema5-1.5 {\n  db eval {\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c,\n       UNIQUE(a) CONSTRAINT one,\n       PRIMARY KEY(b,c) CONSTRAINT two\n    );\n    INSERT INTO t1 VALUES(1,2,3);\n  }\n} {}\ndo_test schema5-1.6 {\n  catchsql {INSERT INTO t1 VALUES(1,3,4)}\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test schema5-1.7 {\n  catchsql {INSERT INTO t1 VALUES(10,2,3)}\n} {1 {UNIQUE constraint failed: t1.b, t1.c}}\n\n\n\n    \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/schema6.test",
    "content": "# 2017-07-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests to show that certain CREATE TABLE statements\n# generate identical database files.  For example, changes in identifier\n# names, white-space, and formatting of the CREATE TABLE statement should\n# produce identical table content.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix schema6\ndo_not_use_codec\n\n# Command:   check_same_database_content TESTNAME SQL1 SQL2 SQL3 ...\n#\n# This command creates fresh databases using SQL1 and subsequent arguments\n# and checks to make sure the content of all database files is byte-for-byte\n# identical.  Page 1 of the database files is allowed to be different, since\n# page 1 contains the sqlite_master table which is expected to vary.\n#\nproc check_same_database_content {basename args} {\n  set i 0\n  set hash {}\n  foreach sql $args {\n    catch {db close}\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval $sql\n    set pgsz [db one {PRAGMA page_size}]\n    db close\n    set sz [file size test.db]\n    set thishash [md5file test.db $pgsz [expr {$sz-$pgsz}]]\n    if {$i==0} {\n      set hash $thishash\n    } else {\n      do_test $basename-$i \"set x $thishash\" $hash\n    }\n    incr i\n  }\n}\n\n# Command:   check_different_database_content TESTNAME SQL1 SQL2 SQL3 ...\n#\n# This command creates fresh databases using SQL1 and subsequent arguments\n# and checks to make sure the content of all database files is different\n# in ways other than on page 1.\n#\nproc check_different_database_content {basename args} {\n  set i 0\n  set hashes {}\n  foreach sql $args {\n    forcedelete test.db\n    sqlite3 db test.db\n    db eval $sql\n    set pgsz [db one {PRAGMA page_size}]\n    db close\n    set sz [file size test.db]\n    set thishash [md5file test.db $pgsz [expr {$sz-$pgsz}]]\n    set j [lsearch $hashes $thishash]\n    if {$j>=0} {\n      do_test $basename-$i \"set x {$i is the same as $j}\" \"All are different\"\n    } else {\n      do_test $basename-$i \"set x {All are different}\" \"All are different\"\n    }\n    lappend hashes $thishash\n    incr i\n  }\n}\n\ncheck_same_database_content 100 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(xyz INTEGER, abc, PRIMARY KEY(xyz), UNIQUE(abc));\n  INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(xyz INTEGER, abc, UNIQUE(abc), PRIMARY KEY(xyz));\n  INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY ASC, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE UNIQUE INDEX t1b ON t1(b);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n  CREATE UNIQUE INDEX t1b ON t1(b);\n}\n\ncheck_same_database_content 110 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE, UNIQUE(a));\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b);\n  CREATE UNIQUE INDEX t1b ON t1(b);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n  CREATE UNIQUE INDEX t1b ON t1(b);\n}\n\ncheck_same_database_content 120 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(xyz INTEGER, abc, PRIMARY KEY(xyz), UNIQUE(abc))WITHOUT ROWID;\n  INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(xyz INTEGER, abc, UNIQUE(abc), PRIMARY KEY(xyz))WITHOUT ROWID;\n  INSERT INTO t1(xyz,abc) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY ASC, b UNIQUE) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER UNIQUE PRIMARY KEY, b UNIQUE, UNIQUE(a))\n       WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;\n  CREATE UNIQUE INDEX t1b ON t1(b);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n  CREATE UNIQUE INDEX t1b ON t1(b);\n}\n\ncheck_different_database_content 130 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY UNIQUE, b UNIQUE);\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n} {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE) WITHOUT ROWID;\n  INSERT INTO t1(a,b) VALUES(123,'Four score and seven years ago...');\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/securedel.test",
    "content": "# 2010 January 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Tests for the secure_delete pragma.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nunset -nocomplain DEFAULT_SECDEL\nset DEFAULT_SECDEL 0\nifcapable secure_delete {\n  set DEFAULT_SECDEL 1\n}\n\n\ndo_test securedel-1.0 {\n  db eval {PRAGMA secure_delete;}\n} $DEFAULT_SECDEL\n\nforcedelete test2.db test2.db-journal\ndo_test securedel-1.1 {\n  db eval {\n    ATTACH 'test2.db' AS db2;\n    PRAGMA main.secure_delete=ON;\n    PRAGMA db2.secure_delete;\n  }\n} [list 1 $DEFAULT_SECDEL]\ndo_test securedel-1.2 {\n  db eval {\n    PRAGMA main.secure_delete=OFF;\n    PRAGMA db2.secure_delete;\n  }\n} [list 0 $DEFAULT_SECDEL]\ndo_test securedel-1.3 {\n  db eval {\n    PRAGMA secure_delete=OFF;\n    PRAGMA db2.secure_delete;\n  }\n} {0 0}\ndo_test securedel-1.4 {\n  db eval {\n    PRAGMA secure_delete=ON;\n    PRAGMA db2.secure_delete;\n  }\n} {1 1}\ndo_test securedel-1.5 {\n  db eval {\n    PRAGMA secure_delete=FAST;\n    PRAGMA db2.secure_delete;\n  }\n} {2 2}\ndo_test securedel-1.6 {\n  db eval {\n    PRAGMA secure_delete=ON;\n    PRAGMA db2.secure_delete;\n  }\n} {1 1}\ndo_test securedel-1.7 {\n  db eval {\n    PRAGMA main.secure_delete=FAST;\n    PRAGMA db2.secure_delete;\n  }\n} {2 1}\ndo_test securedel-1.8 {\n  db eval {\n    PRAGMA main.secure_delete=ON;\n    PRAGMA db2.secure_delete;\n  }\n} {1 1}\n\ndo_test securedel-2.1 {\n  db eval {\n    DETACH db2;\n    ATTACH 'test2.db' AS db2;\n    PRAGMA db2.secure_delete;\n  }\n} 1\ndo_test securedel-2.2 {\n  db eval {\n    DETACH db2;\n    PRAGMA main.secure_delete=OFF;\n    ATTACH 'test2.db' AS db2;\n    PRAGMA db2.secure_delete;\n  }\n} {0 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/securedel2.test",
    "content": "# 2012 August 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Tests for the secure_delete pragma.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix securedel2\n\n# Generate 1000 pseudo-random 64-bit blobs.\n#\nfor {set i 1} {$i <= 1000} {incr i} {\n  set aBlob($i) [string range [db one {SELECT quote(randomblob(8))}] 2 end-1]\n}\n\nproc detect_blob_prepare {zFile} {\n  set nByte [file size $zFile]\n  set ::detect_blob_data [hexio_read $zFile 0 $nByte]\n}\n\nproc detect_blob {zFile iBlob} {\n  if {$zFile != \"\"} { detect_blob_prepare $zFile }\n  string match \"*$::aBlob($iBlob)*\" $::detect_blob_data\n}\n\ndo_test 1.1 {\n  execsql { PRAGMA secure_delete = 1 }\n  execsql { PRAGMA auto_vacuum = 0 }\n  execsql { CREATE TABLE t1(x, y) }\n  for {set i 1} {$i <= 1000} {incr i} {\n    set x \"X'[string repeat $aBlob($i) 1]'\"\n    set y \"X'[string repeat $aBlob($i) 500]'\"\n    execsql \"INSERT INTO t1 VALUES($x, $y)\"\n  }\n} {}\n\ndo_test         1.2   { detect_blob test.db 1 } {1}\n\nforcecopy test.db test.db.bak\ndo_execsql_test 1.3.1 { PRAGMA secure_delete = 0 } {0}\ndo_execsql_test 1.3.2 { DELETE FROM t1 WHERE rowid = 1 }\ndo_test         1.3.3 { detect_blob test.db 1 } {1}\n\ndb close\nforcecopy test.db.bak test.db\nsqlite3 db test.db\ndo_execsql_test 1.4.1 { PRAGMA secure_delete = 1 } {1}\ndo_execsql_test 1.4.2 { DELETE FROM t1 WHERE rowid = 1 }\ndo_test         1.4.3 { detect_blob test.db 1 } {0}\n\ndo_execsql_test 1.5.1 { DELETE FROM t1 WHERE rowid>850 } {}\ndo_test 1.5.2 { \n  set n 0\n  detect_blob_prepare test.db\n  for {set i 851} {$i <= 1000} {incr i 5} {\n    incr n [detect_blob {} $i]\n  }\n  set n\n} {0}\n\ndb close\nsqlite3 db test.db\ndo_test 1.6.1 { \n  execsql {\n    PRAGMA cache_size = 200;\n    PRAGMA secure_delete = 1;\n    CREATE TABLE t2(x);\n    SELECT * FROM t1;\n  }\n  for {set i 100} {$i < 5000} {incr i} {\n    execsql { INSERT INTO t2 VALUES(randomblob($i)) }\n  }\n  execsql { DELETE FROM t1 }\n} {}\n\ndo_test 1.6.2 { \n  set n 0\n  detect_blob_prepare test.db\n  for {set i 2} {$i <= 850} {incr i 5} {\n    incr n [detect_blob {} $i]\n  }\n  set n\n} {0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select1.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n# $Id: select1.test,v 1.70 2009/05/28 01:00:56 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Try to select on a non-existant table.\n#\ndo_test select1-1.1 {\n  set v [catch {execsql {SELECT * FROM test1}} msg]\n  lappend v $msg\n} {1 {no such table: test1}}\n\n\nexecsql {CREATE TABLE test1(f1 int, f2 int)}\n\ndo_test select1-1.2 {\n  set v [catch {execsql {SELECT * FROM test1, test2}} msg]\n  lappend v $msg\n} {1 {no such table: test2}}\ndo_test select1-1.3 {\n  set v [catch {execsql {SELECT * FROM test2, test1}} msg]\n  lappend v $msg\n} {1 {no such table: test2}}\n\nexecsql {INSERT INTO test1(f1,f2) VALUES(11,22)}\n\n\n# Make sure the columns are extracted correctly.\n#\ndo_test select1-1.4 {\n  execsql {SELECT f1 FROM test1}\n} {11}\ndo_test select1-1.5 {\n  execsql {SELECT f2 FROM test1}\n} {22}\ndo_test select1-1.6 {\n  execsql {SELECT f2, f1 FROM test1}\n} {22 11}\ndo_test select1-1.7 {\n  execsql {SELECT f1, f2 FROM test1}\n} {11 22}\ndo_test select1-1.8 {\n  execsql {SELECT * FROM test1}\n} {11 22}\ndo_test select1-1.8.1 {\n  execsql {SELECT *, * FROM test1}\n} {11 22 11 22}\ndo_test select1-1.8.2 {\n  execsql {SELECT *, min(f1,f2), max(f1,f2) FROM test1}\n} {11 22 11 22}\ndo_test select1-1.8.3 {\n  execsql {SELECT 'one', *, 'two', * FROM test1}\n} {one 11 22 two 11 22}\n\nexecsql {CREATE TABLE test2(r1 real, r2 real)}\nexecsql {INSERT INTO test2(r1,r2) VALUES(1.1,2.2)}\n\ndo_test select1-1.9 {\n  execsql {SELECT * FROM test1, test2}\n} {11 22 1.1 2.2}\ndo_test select1-1.9.1 {\n  execsql {SELECT *, 'hi' FROM test1, test2}\n} {11 22 1.1 2.2 hi}\ndo_test select1-1.9.2 {\n  execsql {SELECT 'one', *, 'two', * FROM test1, test2}\n} {one 11 22 1.1 2.2 two 11 22 1.1 2.2}\ndo_test select1-1.10 {\n  execsql {SELECT test1.f1, test2.r1 FROM test1, test2}\n} {11 1.1}\ndo_test select1-1.11 {\n  execsql {SELECT test1.f1, test2.r1 FROM test2, test1}\n} {11 1.1}\ndo_test select1-1.11.1 {\n  execsql {SELECT * FROM test2, test1}\n} {1.1 2.2 11 22}\ndo_test select1-1.11.2 {\n  execsql {SELECT * FROM test1 AS a, test1 AS b}\n} {11 22 11 22}\ndo_test select1-1.12 {\n  execsql {SELECT max(test1.f1,test2.r1), min(test1.f2,test2.r2)\n           FROM test2, test1}\n} {11 2.2}\ndo_test select1-1.13 {\n  execsql {SELECT min(test1.f1,test2.r1), max(test1.f2,test2.r2)\n           FROM test1, test2}\n} {1.1 22}\n\nset long {This is a string that is too big to fit inside a NBFS buffer}\ndo_test select1-2.0 {\n  execsql \"\n    DROP TABLE test2;\n    DELETE FROM test1;\n    INSERT INTO test1 VALUES(11,22);\n    INSERT INTO test1 VALUES(33,44);\n    CREATE TABLE t3(a,b);\n    INSERT INTO t3 VALUES('abc',NULL);\n    INSERT INTO t3 VALUES(NULL,'xyz');\n    INSERT INTO t3 SELECT * FROM test1;\n    CREATE TABLE t4(a,b);\n    INSERT INTO t4 VALUES(NULL,'$long');\n    SELECT * FROM t3;\n  \"\n} {abc {} {} xyz 11 22 33 44}\n\n# Error messges from sqliteExprCheck\n#\ndo_test select1-2.1 {\n  set v [catch {execsql {SELECT count(f1,f2) FROM test1}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function count()}}\ndo_test select1-2.2 {\n  set v [catch {execsql {SELECT count(f1) FROM test1}} msg]\n  lappend v $msg\n} {0 2}\ndo_test select1-2.3 {\n  set v [catch {execsql {SELECT Count() FROM test1}} msg]\n  lappend v $msg\n} {0 2}\ndo_test select1-2.4 {\n  set v [catch {execsql {SELECT COUNT(*) FROM test1}} msg]\n  lappend v $msg\n} {0 2}\ndo_test select1-2.5 {\n  set v [catch {execsql {SELECT COUNT(*)+1 FROM test1}} msg]\n  lappend v $msg\n} {0 3}\ndo_test select1-2.5.1 {\n  execsql {SELECT count(*),count(a),count(b) FROM t3}\n} {4 3 3}\ndo_test select1-2.5.2 {\n  execsql {SELECT count(*),count(a),count(b) FROM t4}\n} {1 0 1}\ndo_test select1-2.5.3 {\n  execsql {SELECT count(*),count(a),count(b) FROM t4 WHERE b=5}\n} {0 0 0}\ndo_test select1-2.6 {\n  set v [catch {execsql {SELECT min(*) FROM test1}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function min()}}\ndo_test select1-2.7 {\n  set v [catch {execsql {SELECT Min(f1) FROM test1}} msg]\n  lappend v $msg\n} {0 11}\ndo_test select1-2.8 {\n  set v [catch {execsql {SELECT MIN(f1,f2) FROM test1}} msg]\n  lappend v [lsort $msg]\n} {0 {11 33}}\ndo_test select1-2.8.1 {\n  execsql {SELECT coalesce(min(a),'xyzzy') FROM t3}\n} {11}\ndo_test select1-2.8.2 {\n  execsql {SELECT min(coalesce(a,'xyzzy')) FROM t3}\n} {11}\ndo_test select1-2.8.3 {\n  execsql {SELECT min(b), min(b) FROM t4}\n} [list $long $long]\ndo_test select1-2.9 {\n  set v [catch {execsql {SELECT MAX(*) FROM test1}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function MAX()}}\ndo_test select1-2.10 {\n  set v [catch {execsql {SELECT Max(f1) FROM test1}} msg]\n  lappend v $msg\n} {0 33}\ndo_test select1-2.11 {\n  set v [catch {execsql {SELECT max(f1,f2) FROM test1}} msg]\n  lappend v [lsort $msg]\n} {0 {22 44}}\ndo_test select1-2.12 {\n  set v [catch {execsql {SELECT MAX(f1,f2)+1 FROM test1}} msg]\n  lappend v [lsort $msg]\n} {0 {23 45}}\ndo_test select1-2.13 {\n  set v [catch {execsql {SELECT MAX(f1)+1 FROM test1}} msg]\n  lappend v $msg\n} {0 34}\ndo_test select1-2.13.1 {\n  execsql {SELECT coalesce(max(a),'xyzzy') FROM t3}\n} {abc}\ndo_test select1-2.13.2 {\n  execsql {SELECT max(coalesce(a,'xyzzy')) FROM t3}\n} {xyzzy}\ndo_test select1-2.14 {\n  set v [catch {execsql {SELECT SUM(*) FROM test1}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function SUM()}}\ndo_test select1-2.15 {\n  set v [catch {execsql {SELECT Sum(f1) FROM test1}} msg]\n  lappend v $msg\n} {0 44}\ndo_test select1-2.16 {\n  set v [catch {execsql {SELECT sum(f1,f2) FROM test1}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function sum()}}\ndo_test select1-2.17 {\n  set v [catch {execsql {SELECT SUM(f1)+1 FROM test1}} msg]\n  lappend v $msg\n} {0 45}\ndo_test select1-2.17.1 {\n  execsql {SELECT sum(a) FROM t3}\n} {44.0}\ndo_test select1-2.18 {\n  set v [catch {execsql {SELECT XYZZY(f1) FROM test1}} msg]\n  lappend v $msg\n} {1 {no such function: XYZZY}}\ndo_test select1-2.19 {\n  set v [catch {execsql {SELECT SUM(min(f1,f2)) FROM test1}} msg]\n  lappend v $msg\n} {0 44}\ndo_test select1-2.20 {\n  set v [catch {execsql {SELECT SUM(min(f1)) FROM test1}} msg]\n  lappend v $msg\n} {1 {misuse of aggregate function min()}}\n\n# Ticket #2526\n#\ndo_test select1-2.21 {\n  catchsql {\n     SELECT min(f1) AS m FROM test1 GROUP BY f1 HAVING max(m+5)<10\n  }\n} {1 {misuse of aliased aggregate m}}\ndo_test select1-2.22 {\n  catchsql {\n     SELECT coalesce(min(f1)+5,11) AS m FROM test1\n      GROUP BY f1\n     HAVING max(m+5)<10\n  }\n} {1 {misuse of aliased aggregate m}}\ndo_test select1-2.23 {\n  execsql {\n    CREATE TABLE tkt2526(a,b,c PRIMARY KEY);\n    INSERT INTO tkt2526 VALUES('x','y',NULL);\n    INSERT INTO tkt2526 VALUES('x','z',NULL);\n  }\n  catchsql {\n    SELECT count(a) AS cn FROM tkt2526 GROUP BY a HAVING cn<max(cn)\n  }\n} {1 {misuse of aliased aggregate cn}}\n\n# WHERE clause expressions\n#\ndo_test select1-3.1 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<11}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test select1-3.2 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1<=11}} msg]\n  lappend v $msg\n} {0 11}\ndo_test select1-3.3 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1=11}} msg]\n  lappend v $msg\n} {0 11}\ndo_test select1-3.4 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>=11}} msg]\n  lappend v [lsort $msg]\n} {0 {11 33}}\ndo_test select1-3.5 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1>11}} msg]\n  lappend v [lsort $msg]\n} {0 33}\ndo_test select1-3.6 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE f1!=11}} msg]\n  lappend v [lsort $msg]\n} {0 33}\ndo_test select1-3.7 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE min(f1,f2)!=11}} msg]\n  lappend v [lsort $msg]\n} {0 33}\ndo_test select1-3.8 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE max(f1,f2)!=11}} msg]\n  lappend v [lsort $msg]\n} {0 {11 33}}\ndo_test select1-3.9 {\n  set v [catch {execsql {SELECT f1 FROM test1 WHERE count(f1,f2)!=11}} msg]\n  lappend v $msg\n} {1 {wrong number of arguments to function count()}}\n\n# ORDER BY expressions\n#\ndo_test select1-4.1 {\n  set v [catch {execsql {SELECT f1 FROM test1 ORDER BY f1}} msg]\n  lappend v $msg\n} {0 {11 33}}\ndo_test select1-4.2 {\n  set v [catch {execsql {SELECT f1 FROM test1 ORDER BY -f1}} msg]\n  lappend v $msg\n} {0 {33 11}}\ndo_test select1-4.3 {\n  set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1,f2)}} msg]\n  lappend v $msg\n} {0 {11 33}}\ndo_test select1-4.4 {\n  set v [catch {execsql {SELECT f1 FROM test1 ORDER BY min(f1)}} msg]\n  lappend v $msg\n} {1 {misuse of aggregate: min()}}\ndo_catchsql_test select1-4.5 {\n  INSERT INTO test1(f1) SELECT f1 FROM test1 ORDER BY min(f1);\n} {1 {misuse of aggregate: min()}}\n\n# The restriction not allowing constants in the ORDER BY clause\n# has been removed.  See ticket #1768\n#do_test select1-4.5 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY 8.4;\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n#do_test select1-4.6 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY '8.4';\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n#do_test select1-4.7.1 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY 'xyz';\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n#do_test select1-4.7.2 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY -8.4;\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n#do_test select1-4.7.3 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY +8.4;\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n#do_test select1-4.7.4 {\n#  catchsql {\n#    SELECT f1 FROM test1 ORDER BY 4294967296; -- constant larger than 32 bits\n#  }\n#} {1 {ORDER BY terms must not be non-integer constants}}\n\ndo_test select1-4.5 {\n  execsql {\n    SELECT f1 FROM test1 ORDER BY 8.4\n  }\n} {11 33}\ndo_test select1-4.6 {\n  execsql {\n    SELECT f1 FROM test1 ORDER BY '8.4'\n  }\n} {11 33}\n\ndo_test select1-4.8 {\n  execsql {\n    CREATE TABLE t5(a,b);\n    INSERT INTO t5 VALUES(1,10);\n    INSERT INTO t5 VALUES(2,9);\n    SELECT * FROM t5 ORDER BY 1;\n  }\n} {1 10 2 9}\ndo_test select1-4.9.1 {\n  execsql {\n    SELECT * FROM t5 ORDER BY 2;\n  }\n} {2 9 1 10}\ndo_test select1-4.9.2 {\n  execsql {\n    SELECT * FROM t5 ORDER BY +2;\n  }\n} {2 9 1 10}\ndo_test select1-4.10.1 {\n  catchsql {\n    SELECT * FROM t5 ORDER BY 3;\n  }\n} {1 {1st ORDER BY term out of range - should be between 1 and 2}}\ndo_test select1-4.10.2 {\n  catchsql {\n    SELECT * FROM t5 ORDER BY -1;\n  }\n} {1 {1st ORDER BY term out of range - should be between 1 and 2}}\ndo_test select1-4.11 {\n  execsql {\n    INSERT INTO t5 VALUES(3,10);\n    SELECT * FROM t5 ORDER BY 2, 1 DESC;\n  }\n} {2 9 3 10 1 10}\ndo_test select1-4.12 {\n  execsql {\n    SELECT * FROM t5 ORDER BY 1 DESC, b;\n  }\n} {3 10 2 9 1 10}\ndo_test select1-4.13 {\n  execsql {\n    SELECT * FROM t5 ORDER BY b DESC, 1;\n  }\n} {1 10 3 10 2 9}\n\n\n# ORDER BY ignored on an aggregate query\n#\ndo_test select1-5.1 {\n  set v [catch {execsql {SELECT max(f1) FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 33}\n\nexecsql {CREATE TABLE test2(t1 text, t2 text)}\nexecsql {INSERT INTO test2 VALUES('abc','xyz')}\n\n# Check for column naming\n#\ndo_test select1-6.1 {\n  set v [catch {execsql2 {SELECT f1 FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {f1 11 f1 33}}\ndo_test select1-6.1.1 {\n  db eval {PRAGMA full_column_names=on}\n  set v [catch {execsql2 {SELECT f1 FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {test1.f1 11 test1.f1 33}}\ndo_test select1-6.1.2 {\n  set v [catch {execsql2 {SELECT f1 as 'f1' FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {f1 11 f1 33}}\ndo_test select1-6.1.3 {\n  set v [catch {execsql2 {SELECT * FROM test1 WHERE f1==11}} msg]\n  lappend v $msg\n} {0 {f1 11 f2 22}}\ndo_test select1-6.1.4 {\n  set v [catch {execsql2 {SELECT DISTINCT * FROM test1 WHERE f1==11}} msg]\n  db eval {PRAGMA full_column_names=off}\n  lappend v $msg\n} {0 {f1 11 f2 22}}\ndo_test select1-6.1.5 {\n  set v [catch {execsql2 {SELECT * FROM test1 WHERE f1==11}} msg]\n  lappend v $msg\n} {0 {f1 11 f2 22}}\ndo_test select1-6.1.6 {\n  set v [catch {execsql2 {SELECT DISTINCT * FROM test1 WHERE f1==11}} msg]\n  lappend v $msg\n} {0 {f1 11 f2 22}}\ndo_test select1-6.2 {\n  set v [catch {execsql2 {SELECT f1 as xyzzy FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {xyzzy 11 xyzzy 33}}\ndo_test select1-6.3 {\n  set v [catch {execsql2 {SELECT f1 as \"xyzzy\" FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {xyzzy 11 xyzzy 33}}\ndo_test select1-6.3.1 {\n  set v [catch {execsql2 {SELECT f1 as 'xyzzy ' FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {{xyzzy } 11 {xyzzy } 33}}\ndo_test select1-6.4 {\n  set v [catch {execsql2 {SELECT f1+F2 as xyzzy FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {xyzzy 33 xyzzy 77}}\ndo_test select1-6.4a {\n  set v [catch {execsql2 {SELECT f1+F2 FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {f1+F2 33 f1+F2 77}}\ndo_test select1-6.5 {\n  set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {test1.f1+F2 33 test1.f1+F2 77}}\ndo_test select1-6.5.1 {\n  execsql2 {PRAGMA full_column_names=on}\n  set v [catch {execsql2 {SELECT test1.f1+F2 FROM test1 ORDER BY f2}} msg]\n  execsql2 {PRAGMA full_column_names=off}\n  lappend v $msg\n} {0 {test1.f1+F2 33 test1.f1+F2 77}}\ndo_test select1-6.6 {\n  set v [catch {execsql2 {SELECT test1.f1+F2, t1 FROM test1, test2 \n         ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {test1.f1+F2 33 t1 abc test1.f1+F2 77 t1 abc}}\ndo_test select1-6.7 {\n  set v [catch {execsql2 {SELECT A.f1, t1 FROM test1 as A, test2 \n         ORDER BY f2}} msg]\n  lappend v $msg\n} {0 {f1 11 t1 abc f1 33 t1 abc}}\ndo_test select1-6.8 {\n  set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as B \n         ORDER BY f2}} msg]\n  lappend v $msg\n} {1 {ambiguous column name: f1}}\ndo_test select1-6.8b {\n  set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B \n         ORDER BY f2}} msg]\n  lappend v $msg\n} {1 {ambiguous column name: f2}}\ndo_test select1-6.8c {\n  set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as A \n         ORDER BY f2}} msg]\n  lappend v $msg\n} {1 {ambiguous column name: A.f1}}\ndo_test select1-6.9.1 {\n  set v [catch {execsql {SELECT A.f1, B.f1 FROM test1 as A, test1 as B \n         ORDER BY A.f1, B.f1}} msg]\n  lappend v $msg\n} {0 {11 11 11 33 33 11 33 33}}\ndo_test select1-6.9.2 {\n  set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B \n         ORDER BY A.f1, B.f1}} msg]\n  lappend v $msg\n} {0 {f1 11 f1 11 f1 33 f1 33 f1 11 f1 11 f1 33 f1 33}}\n\ndo_test select1-6.9.3 {\n  db eval {\n     PRAGMA short_column_names=OFF;\n     PRAGMA full_column_names=OFF;\n  }\n  execsql2 {\n     SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1\n  }\n} {{test1 . f1} 11 {test1 . f2} 22}\ndo_test select1-6.9.4 {\n  db eval {\n     PRAGMA short_column_names=OFF;\n     PRAGMA full_column_names=ON;\n  }\n  execsql2 {\n     SELECT test1 . f1, test1 . f2 FROM test1 LIMIT 1\n  }\n} {test1.f1 11 test1.f2 22}\ndo_test select1-6.9.5 {\n  db eval {\n     PRAGMA short_column_names=OFF;\n     PRAGMA full_column_names=ON;\n  }\n  execsql2 {\n     SELECT 123.45;\n  }\n} {123.45 123.45}\ndo_test select1-6.9.6 {\n  execsql2 {\n     SELECT * FROM test1 a, test1 b LIMIT 1\n  }\n} {a.f1 11 a.f2 22 b.f1 11 b.f2 22}\ndo_test select1-6.9.7 {\n  set x [execsql2 {\n     SELECT * FROM test1 a, (select 5, 6) LIMIT 1\n  }]\n  regsub -all {subquery_[0-9a-fA-F_]+} $x {subquery} x\n  set x\n} {a.f1 11 a.f2 22 subquery.5 5 subquery.6 6}\ndo_test select1-6.9.8 {\n  set x [execsql2 {\n     SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1\n  }]\n  regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x\n  set x\n} {a.f1 11 a.f2 22 b.x 5 b.y 6}\ndo_test select1-6.9.9 {\n  execsql2 {\n     SELECT a.f1, b.f2 FROM test1 a, test1 b LIMIT 1\n  }\n} {test1.f1 11 test1.f2 22}\ndo_test select1-6.9.10 {\n  execsql2 {\n     SELECT f1, t1 FROM test1, test2 LIMIT 1\n  }\n} {test1.f1 11 test2.t1 abc}\ndo_test select1-6.9.11 {\n  db eval {\n     PRAGMA short_column_names=ON;\n     PRAGMA full_column_names=ON;\n  }\n  execsql2 {\n     SELECT a.f1, b.f2 FROM test1 a, test1 b LIMIT 1\n  }\n} {test1.f1 11 test1.f2 22}\ndo_test select1-6.9.12 {\n  execsql2 {\n     SELECT f1, t1 FROM test1, test2 LIMIT 1\n  }\n} {test1.f1 11 test2.t1 abc}\ndo_test select1-6.9.13 {\n  db eval {\n     PRAGMA short_column_names=ON;\n     PRAGMA full_column_names=OFF;\n  }\n  execsql2 {\n     SELECT a.f1, b.f1 FROM test1 a, test1 b LIMIT 1\n  }\n} {f1 11 f1 11}\ndo_test select1-6.9.14 {\n  execsql2 {\n     SELECT f1, t1 FROM test1, test2 LIMIT 1\n  }\n} {f1 11 t1 abc}\ndo_test select1-6.9.15 {\n  db eval {\n     PRAGMA short_column_names=OFF;\n     PRAGMA full_column_names=ON;\n  }\n  execsql2 {\n     SELECT a.f1, b.f1 FROM test1 a, test1 b LIMIT 1\n  }\n} {test1.f1 11 test1.f1 11}\ndo_test select1-6.9.16 {\n  execsql2 {\n     SELECT f1, t1 FROM test1, test2 LIMIT 1\n  }\n} {test1.f1 11 test2.t1 abc}\n\n\ndb eval {\n  PRAGMA short_column_names=ON;\n  PRAGMA full_column_names=OFF;\n}\n\nifcapable compound {\ndo_test select1-6.10 {\n  set v [catch {execsql2 {\n    SELECT f1 FROM test1 UNION SELECT f2 FROM test1\n    ORDER BY f2;\n  }} msg]\n  lappend v $msg\n} {0 {f1 11 f1 22 f1 33 f1 44}}\ndo_test select1-6.11 {\n  set v [catch {execsql2 {\n    SELECT f1 FROM test1 UNION SELECT f2+100 FROM test1\n    ORDER BY f2+101;\n  }} msg]\n  lappend v $msg\n} {1 {1st ORDER BY term does not match any column in the result set}}\n\n# Ticket #2296\nifcapable subquery&&compound {\ndo_test select1-6.20 {\n   execsql {\n     CREATE TABLE t6(a TEXT, b TEXT);\n     INSERT INTO t6 VALUES('a','0');\n     INSERT INTO t6 VALUES('b','1');\n     INSERT INTO t6 VALUES('c','2');\n     INSERT INTO t6 VALUES('d','3');\n     SELECT a FROM t6 WHERE b IN \n        (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x\n                 ORDER BY 1 LIMIT 1)\n   }\n} {a}\ndo_test select1-6.21 {\n   execsql {\n     SELECT a FROM t6 WHERE b IN \n        (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x\n                 ORDER BY 1 DESC LIMIT 1)\n   }\n} {d}\ndo_test select1-6.22 {\n   execsql {\n     SELECT a FROM t6 WHERE b IN \n        (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x\n                 ORDER BY b LIMIT 2)\n     ORDER BY a;\n   }\n} {a b}\ndo_test select1-6.23 {\n   execsql {\n     SELECT a FROM t6 WHERE b IN \n        (SELECT b FROM t6 WHERE a<='b' UNION SELECT '3' AS x\n                 ORDER BY x DESC LIMIT 2)\n     ORDER BY a;\n   }\n} {b d}\n}\n\n} ;#ifcapable compound\n\ndo_test select1-7.1 {\n  set v [catch {execsql {\n     SELECT f1 FROM test1 WHERE f2=;\n  }} msg]\n  lappend v $msg\n} {1 {near \";\": syntax error}}\nifcapable compound {\ndo_test select1-7.2 {\n  set v [catch {execsql {\n     SELECT f1 FROM test1 UNION SELECT WHERE;\n  }} msg]\n  lappend v $msg\n} {1 {near \"WHERE\": syntax error}}\n} ;# ifcapable compound\ndo_test select1-7.3 {\n  set v [catch {execsql {SELECT f1 FROM test1 as 'hi', test2 as}} msg]\n  lappend v $msg\n} {1 {near \"as\": syntax error}}\ndo_test select1-7.4 {\n  set v [catch {execsql {\n     SELECT f1 FROM test1 ORDER BY;\n  }} msg]\n  lappend v $msg\n} {1 {near \";\": syntax error}}\ndo_test select1-7.5 {\n  set v [catch {execsql {\n     SELECT f1 FROM test1 ORDER BY f1 desc, f2 where;\n  }} msg]\n  lappend v $msg\n} {1 {near \"where\": syntax error}}\ndo_test select1-7.6 {\n  set v [catch {execsql {\n     SELECT count(f1,f2 FROM test1;\n  }} msg]\n  lappend v $msg\n} {1 {near \"FROM\": syntax error}}\ndo_test select1-7.7 {\n  set v [catch {execsql {\n     SELECT count(f1,f2+) FROM test1;\n  }} msg]\n  lappend v $msg\n} {1 {near \")\": syntax error}}\ndo_test select1-7.8 {\n  set v [catch {execsql {\n     SELECT f1 FROM test1 ORDER BY f2, f1+;\n  }} msg]\n  lappend v $msg\n} {1 {near \";\": syntax error}}\ndo_test select1-7.9 {\n  catchsql {\n     SELECT f1 FROM test1 LIMIT 5+3 OFFSET 11 ORDER BY f2;\n  }\n} {1 {near \"ORDER\": syntax error}}\n\ndo_test select1-8.1 {\n  execsql {SELECT f1 FROM test1 WHERE 4.3+2.4 OR 1 ORDER BY f1}\n} {11 33}\ndo_test select1-8.2 {\n  execsql {\n    SELECT f1 FROM test1 WHERE ('x' || f1) BETWEEN 'x10' AND 'x20'\n    ORDER BY f1\n  }\n} {11}\ndo_test select1-8.3 {\n  execsql {\n    SELECT f1 FROM test1 WHERE 5-3==2\n    ORDER BY f1\n  }\n} {11 33}\n\n# TODO: This test is failing because f1 is now being loaded off the\n# disk as a vdbe integer, not a string. Hence the value of f1/(f1-11)\n# changes because of rounding. Disable the test for now.\nif 0 {\ndo_test select1-8.4 {\n  execsql {\n    SELECT coalesce(f1/(f1-11),'x'),\n           coalesce(min(f1/(f1-11),5),'y'),\n           coalesce(max(f1/(f1-33),6),'z')\n    FROM test1 ORDER BY f1\n  }\n} {x y 6 1.5 1.5 z}\n}\ndo_test select1-8.5 {\n  execsql {\n    SELECT min(1,2,3), -max(1,2,3)\n    FROM test1 ORDER BY f1\n  }\n} {1 -3 1 -3}\n\n\n# Check the behavior when the result set is empty\n#\n# SQLite v3 always sets r(*).\n#\n# do_test select1-9.1 {\n#   catch {unset r}\n#   set r(*) {}\n#   db eval {SELECT * FROM test1 WHERE f1<0} r {}\n#   set r(*)\n# } {}\ndo_test select1-9.2 {\n  execsql {PRAGMA empty_result_callbacks=on}\n  catch {unset r}\n  set r(*) {}\n  db eval {SELECT * FROM test1 WHERE f1<0} r {}\n  set r(*)\n} {f1 f2}\nifcapable subquery {\n  do_test select1-9.3 {\n    set r(*) {}\n    db eval {SELECT * FROM test1 WHERE f1<(select count(*) from test2)} r {}\n    set r(*)\n  } {f1 f2}\n}\ndo_test select1-9.4 {\n  set r(*) {}\n  db eval {SELECT * FROM test1 ORDER BY f1} r {}\n  set r(*)\n} {f1 f2}\ndo_test select1-9.5 {\n  set r(*) {}\n  db eval {SELECT * FROM test1 WHERE f1<0 ORDER BY f1} r {}\n  set r(*)\n} {f1 f2}\nunset r\n\n# Check for ORDER BY clauses that refer to an AS name in the column list\n#\ndo_test select1-10.1 {\n  execsql {\n    SELECT f1 AS x FROM test1 ORDER BY x\n  }\n} {11 33}\ndo_test select1-10.2 {\n  execsql {\n    SELECT f1 AS x FROM test1 ORDER BY -x\n  }\n} {33 11}\ndo_test select1-10.3 {\n  execsql {\n    SELECT f1-23 AS x FROM test1 ORDER BY abs(x)\n  }\n} {10 -12}\ndo_test select1-10.4 {\n  execsql {\n    SELECT f1-23 AS x FROM test1 ORDER BY -abs(x)\n  }\n} {-12 10}\ndo_test select1-10.5 {\n  execsql {\n    SELECT f1-22 AS x, f2-22 as y FROM test1\n  }\n} {-11 0 11 22}\ndo_test select1-10.6 {\n  execsql {\n    SELECT f1-22 AS x, f2-22 as y FROM test1 WHERE x>0 AND y<50\n  }\n} {11 22}\ndo_test select1-10.7 {\n  execsql {\n    SELECT f1 COLLATE nocase AS x FROM test1 ORDER BY x\n  }\n} {11 33}\n\n# Check the ability to specify \"TABLE.*\" in the result set of a SELECT\n#\ndo_test select1-11.1 {\n  execsql {\n    DELETE FROM t3;\n    DELETE FROM t4;\n    INSERT INTO t3 VALUES(1,2);\n    INSERT INTO t4 VALUES(3,4);\n    SELECT * FROM t3, t4;\n  }\n} {1 2 3 4}\ndo_test select1-11.2.1 {\n  execsql {\n    SELECT * FROM t3, t4;\n  }\n} {1 2 3 4}\ndo_test select1-11.2.2 {\n  execsql2 {\n    SELECT * FROM t3, t4;\n  }\n} {a 3 b 4 a 3 b 4}\ndo_test select1-11.4.1 {\n  execsql {\n    SELECT t3.*, t4.b FROM t3, t4;\n  }\n} {1 2 4}\ndo_test select1-11.4.2 {\n  execsql {\n    SELECT \"t3\".*, t4.b FROM t3, t4;\n  }\n} {1 2 4}\ndo_test select1-11.5.1 {\n  execsql2 {\n    SELECT t3.*, t4.b FROM t3, t4;\n  }\n} {a 1 b 4 b 4}\ndo_test select1-11.6 {\n  execsql2 {\n    SELECT x.*, y.b FROM t3 AS x, t4 AS y;\n  }\n} {a 1 b 4 b 4}\ndo_test select1-11.7 {\n  execsql {\n    SELECT t3.b, t4.* FROM t3, t4;\n  }\n} {2 3 4}\ndo_test select1-11.8 {\n  execsql2 {\n    SELECT t3.b, t4.* FROM t3, t4;\n  }\n} {b 4 a 3 b 4}\ndo_test select1-11.9 {\n  execsql2 {\n    SELECT x.b, y.* FROM t3 AS x, t4 AS y;\n  }\n} {b 4 a 3 b 4}\ndo_test select1-11.10 {\n  catchsql {\n    SELECT t5.* FROM t3, t4;\n  }\n} {1 {no such table: t5}}\ndo_test select1-11.11 {\n  catchsql {\n    SELECT t3.* FROM t3 AS x, t4;\n  }\n} {1 {no such table: t3}}\nifcapable subquery {\n  do_test select1-11.12 {\n    execsql2 {\n      SELECT t3.* FROM t3, (SELECT max(a), max(b) FROM t4)\n    }\n  } {a 1 b 2}\n  do_test select1-11.13 {\n    execsql2 {\n      SELECT t3.* FROM (SELECT max(a), max(b) FROM t4), t3\n    }\n  } {a 1 b 2}\n  do_test select1-11.14 {\n    execsql2 {\n      SELECT * FROM t3, (SELECT max(a), max(b) FROM t4) AS 'tx'\n    }\n  } {a 1 b 2 max(a) 3 max(b) 4}\n  do_test select1-11.15 {\n    execsql2 {\n      SELECT y.*, t3.* FROM t3, (SELECT max(a), max(b) FROM t4) AS y\n    }\n  } {max(a) 3 max(b) 4 a 1 b 2}\n}\ndo_test select1-11.16 {\n  execsql2 {\n    SELECT y.* FROM t3 as y, t4 as z\n  }\n} {a 1 b 2}\n\n# Tests of SELECT statements without a FROM clause.\n#\ndo_test select1-12.1 {\n  execsql2 {\n    SELECT 1+2+3\n  }\n} {1+2+3 6}\ndo_test select1-12.2 {\n  execsql2 {\n    SELECT 1,'hello',2\n  }\n} {1 1 'hello' hello 2 2}\ndo_test select1-12.3 {\n  execsql2 {\n    SELECT 1 AS 'a','hello' AS 'b',2 AS 'c'\n  }\n} {a 1 b hello c 2}\ndo_test select1-12.4 {\n  execsql {\n    DELETE FROM t3;\n    INSERT INTO t3 VALUES(1,2);\n  }\n} {}\n\nifcapable compound {\ndo_test select1-12.5 {\n  execsql {\n    SELECT * FROM t3 UNION SELECT 3 AS 'a', 4 ORDER BY a;\n  }\n} {1 2 3 4}\n\ndo_test select1-12.6 {\n  execsql {\n    SELECT 3, 4 UNION SELECT * FROM t3;\n  }\n} {1 2 3 4}\n} ;# ifcapable compound\n\nifcapable subquery {\n  do_test select1-12.7 {\n    execsql {\n      SELECT * FROM t3 WHERE a=(SELECT 1);\n    }\n  } {1 2}\n  do_test select1-12.8 {\n    execsql {\n      SELECT * FROM t3 WHERE a=(SELECT 2);\n    }\n  } {}\n}\n\nifcapable {compound && subquery} {\n  do_test select1-12.9 {\n    execsql2 {\n      SELECT x FROM (\n        SELECT a AS x, b AS y FROM t3 UNION SELECT a,b FROM t4 ORDER BY a,b\n      ) ORDER BY x;\n    }\n  } {x 1 x 3}\n  do_test select1-12.10 {\n    execsql2 {\n      SELECT z.x FROM (\n        SELECT a AS x,b AS y FROM t3 UNION SELECT a, b FROM t4 ORDER BY a,b\n      ) AS 'z' ORDER BY x;\n    }\n  } {x 1 x 3}\n} ;# ifcapable compound\n\n\n# Check for a VDBE stack growth problem that existed at one point.\n#\nifcapable subquery {\n  do_test select1-13.1 {\n    execsql {\n      BEGIN;\n      create TABLE abc(a, b, c, PRIMARY KEY(a, b));\n      INSERT INTO abc VALUES(1, 1, 1);\n    }\n    for {set i 0} {$i<10} {incr i} {\n      execsql {\n        INSERT INTO abc SELECT a+(select max(a) FROM abc), \n            b+(select max(a) FROM abc), c+(select max(a) FROM abc) FROM abc;\n      }\n    }\n    execsql {COMMIT}\n  \n    # This used to seg-fault when the problem existed.\n    execsql {\n      SELECT count(\n        (SELECT a FROM abc WHERE a = NULL AND b >= upper.c) \n      ) FROM abc AS upper;\n    }\n  } {0}\n}\n\nforeach tab [db eval {SELECT name FROM sqlite_master WHERE type = 'table'}] {\n  db eval \"DROP TABLE $tab\"\n}\ndb close\nsqlite3 db test.db\n\ndo_test select1-14.1 {\n  execsql { \n    SELECT * FROM sqlite_master WHERE rowid>10; \n    SELECT * FROM sqlite_master WHERE rowid=10;\n    SELECT * FROM sqlite_master WHERE rowid<10;\n    SELECT * FROM sqlite_master WHERE rowid<=10;\n    SELECT * FROM sqlite_master WHERE rowid>=10;\n    SELECT * FROM sqlite_master;\n  }\n} {}\ndo_test select1-14.2 {\n  execsql { \n    SELECT 10 IN (SELECT rowid FROM sqlite_master);\n  }\n} {0}\n\nif {[db one {PRAGMA locking_mode}]==\"normal\"} {\n  # Check that ticket #3771 has been fixed.  This test does not\n  # work with locking_mode=EXCLUSIVE so disable in that case.\n  #\n  do_test select1-15.1 {\n    execsql {\n      CREATE TABLE t1(a);\n      CREATE INDEX i1 ON t1(a);\n      INSERT INTO t1 VALUES(1);\n      INSERT INTO t1 VALUES(2);\n      INSERT INTO t1 VALUES(3);\n    }\n  } {}\n  do_test select1-15.2 {\n    sqlite3 db2 test.db\n    execsql { DROP INDEX i1 } db2\n    db2 close\n  } {}\n  do_test select1-15.3 {\n    execsql { SELECT 2 IN (SELECT a FROM t1) }\n  } {1}\n}\n\n# Crash bug reported on the mailing list on 2012-02-23\n#\ndo_test select1-16.1 {\n  catchsql {SELECT 1 FROM (SELECT *)}\n} {1 {no tables specified}}\n\n# 2015-04-17:  assertion fix.\ndo_catchsql_test select1-16.2 {\n  SELECT 1 FROM sqlite_master LIMIT 1,#1;\n} {1 {near \"#1\": syntax error}}\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select2.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n# $Id: select2.test,v 1.28 2009/01/15 15:23:59 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a table with some data\n#\nexecsql {CREATE TABLE tbl1(f1 int, f2 int)}\nexecsql {BEGIN}\nfor {set i 0} {$i<=30} {incr i} {\n  execsql \"INSERT INTO tbl1 VALUES([expr {$i%9}],[expr {$i%10}])\"\n}\nexecsql {COMMIT}\n\n# Do a second query inside a first.\n#\ndo_test select2-1.1 {\n  set sql {SELECT DISTINCT f1 FROM tbl1 ORDER BY f1}\n  set r {}\n  catch {unset data}\n  db eval $sql data {\n    set f1 $data(f1)\n    lappend r $f1:\n    set sql2 \"SELECT f2 FROM tbl1 WHERE f1=$f1 ORDER BY f2\"\n    db eval $sql2 d2 {\n      lappend r $d2(f2)\n    }\n  }\n  set r\n} {0: 0 7 8 9 1: 0 1 8 9 2: 0 1 2 9 3: 0 1 2 3 4: 2 3 4 5: 3 4 5 6: 4 5 6 7: 5 6 7 8: 6 7 8}\n\ndo_test select2-1.2 {\n  set sql {SELECT DISTINCT f1 FROM tbl1 WHERE f1>3 AND f1<5}\n  set r {}\n  db eval $sql data {\n    set f1 $data(f1)\n    lappend r $f1:\n    set sql2 \"SELECT f2 FROM tbl1 WHERE f1=$f1 ORDER BY f2\"\n    db eval $sql2 d2 {\n      lappend r $d2(f2)\n    }\n  }\n  set r\n} {4: 2 3 4}\nunset data\n\n# Create a largish table. Do this twice, once using the TCL cache and once\n# without.  Compare the performance to make sure things go faster with the\n# cache turned on.\n#\nifcapable tclvar {\n  do_test select2-2.0.1 {\n    set t1 [time {\n      execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}\n      for {set i 1} {$i<=30000} {incr i} {\n        set i2 [expr {$i*2}]\n        set i3 [expr {$i*3}]\n        db eval {INSERT INTO tbl2 VALUES($i,$i2,$i3)}\n      }\n      execsql {COMMIT}\n    }]\n    list\n  } {}\n  puts \"time with cache: $::t1\"\n}\ncatch {execsql {DROP TABLE tbl2}}\ndo_test select2-2.0.2 {\n  set t2 [time {\n    execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int); BEGIN;}\n    for {set i 1} {$i<=30000} {incr i} {\n      set i2 [expr {$i*2}]\n      set i3 [expr {$i*3}]\n      execsql \"INSERT INTO tbl2 VALUES($i,$i2,$i3)\"\n    }\n    execsql {COMMIT}\n  }]\n  list\n} {}\nputs \"time without cache: $t2\"\n#ifcapable tclvar {\n#  do_test select2-2.0.3 {\n#    expr {[lindex $t1 0]<[lindex $t2 0]}\n#  } 1\n#}\n\ndo_test select2-2.1 {\n  execsql {SELECT count(*) FROM tbl2}\n} {30000}\ndo_test select2-2.2 {\n  execsql {SELECT count(*) FROM tbl2 WHERE f2>1000}\n} {29500}\n\ndo_test select2-3.1 {\n  execsql {SELECT f1 FROM tbl2 WHERE 1000=f2}\n} {500}\n\ndo_test select2-3.2a {\n  execsql {CREATE INDEX idx1 ON tbl2(f2)}\n} {}\ndo_test select2-3.2b {\n  execsql {SELECT f1 FROM tbl2 WHERE 1000=f2}\n} {500}\ndo_test select2-3.2c {\n  execsql {SELECT f1 FROM tbl2 WHERE f2=1000}\n} {500}\ndo_test select2-3.2d {\n  set sqlite_search_count 0\n  execsql {SELECT * FROM tbl2 WHERE 1000=f2}\n  set sqlite_search_count\n} {3}\ndo_test select2-3.2e {\n  set sqlite_search_count 0\n  execsql {SELECT * FROM tbl2 WHERE f2=1000}\n  set sqlite_search_count\n} {3}\n\n# Make sure queries run faster with an index than without\n#\ndo_test select2-3.3 {\n  execsql {DROP INDEX idx1}\n  set sqlite_search_count 0\n  execsql {SELECT f1 FROM tbl2 WHERE f2==2000}\n  set sqlite_search_count\n} {29999}\n\n# Make sure we can optimize functions in the WHERE clause that\n# use fields from two or more different table.  (Bug #6)\n#\ndo_test select2-4.1 {\n  execsql {\n    CREATE TABLE aa(a);\n    CREATE TABLE bb(b);\n    INSERT INTO aa VALUES(1);\n    INSERT INTO aa VALUES(3);\n    INSERT INTO bb VALUES(2);\n    INSERT INTO bb VALUES(4);\n    SELECT * FROM aa, bb WHERE max(a,b)>2;\n  }\n} {1 4 3 2 3 4}\ndo_test select2-4.2 {\n  execsql {\n    INSERT INTO bb VALUES(0);\n    SELECT * FROM aa CROSS JOIN bb WHERE b;\n  }\n} {1 2 1 4 3 2 3 4}\ndo_test select2-4.3 {\n  execsql {\n    SELECT * FROM aa CROSS JOIN bb WHERE NOT b;\n  }\n} {1 0 3 0}\ndo_test select2-4.4 {\n  execsql {\n    SELECT * FROM aa, bb WHERE min(a,b);\n  }\n} {1 2 1 4 3 2 3 4}\ndo_test select2-4.5 {\n  execsql {\n    SELECT * FROM aa, bb WHERE NOT min(a,b);\n  }\n} {1 0 3 0}\ndo_test select2-4.6 {\n  execsql {\n    SELECT * FROM aa, bb WHERE CASE WHEN a=b-1 THEN 1 END;\n  }\n} {1 2 3 4}\ndo_test select2-4.7 {\n  execsql {\n    SELECT * FROM aa, bb WHERE CASE WHEN a=b-1 THEN 0 ELSE 1 END;\n  }\n} {1 4 1 0 3 2 3 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select3.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing aggregate functions and the\n# GROUP BY and HAVING clauses of SELECT statements.\n#\n# $Id: select3.test,v 1.23 2008/01/16 18:20:42 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test select3-1.0 {\n  execsql {\n    CREATE TABLE t1(n int, log int);\n    BEGIN;\n  }\n  for {set i 1} {$i<32} {incr i} {\n    for {set j 0} {(1<<$j)<$i} {incr j} {}\n    execsql \"INSERT INTO t1 VALUES($i,$j)\"\n  }\n  execsql {\n    COMMIT\n  }\n  execsql {SELECT DISTINCT log FROM t1 ORDER BY log}\n} {0 1 2 3 4 5}\n\n# Basic aggregate functions.\n#\ndo_test select3-1.1 {\n  execsql {SELECT count(*) FROM t1}\n} {31}\ndo_test select3-1.2 {\n  execsql {\n    SELECT min(n),min(log),max(n),max(log),sum(n),sum(log),avg(n),avg(log)\n    FROM t1\n  }\n} {1 0 31 5 496 124 16.0 4.0}\ndo_test select3-1.3 {\n  execsql {SELECT max(n)/avg(n), max(log)/avg(log) FROM t1}\n} {1.9375 1.25}\n\n# Try some basic GROUP BY clauses\n#\ndo_test select3-2.1 {\n  execsql {SELECT log, count(*) FROM t1 GROUP BY log ORDER BY log}\n} {0 1 1 1 2 2 3 4 4 8 5 15}\ndo_test select3-2.2 {\n  execsql {SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log}\n} {0 1 1 2 2 3 3 5 4 9 5 17}\ndo_test select3-2.3.1 {\n  execsql {SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log}\n} {0 1.0 1 2.0 2 3.5 3 6.5 4 12.5 5 24.0}\ndo_test select3-2.3.2 {\n  execsql {SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log}\n} {0 2.0 1 3.0 2 4.5 3 7.5 4 13.5 5 25.0}\ndo_test select3-2.4 {\n  execsql {SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}\n} {0 0.0 1 0.0 2 0.5 3 1.5 4 3.5 5 7.0}\ndo_test select3-2.5 {\n  execsql {SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log}\n} {1 0.0 3 0.0 5 0.5 7 1.5 9 3.5 11 7.0}\ndo_test select3-2.6 {\n  execsql {\n    SELECT log*2+1 as x, count(*) FROM t1 GROUP BY x ORDER BY x\n  }\n} {1 1 3 1 5 2 7 4 9 8 11 15}\ndo_test select3-2.7 {\n  execsql {\n    SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY y, x\n  }\n} {1 1 3 1 5 2 7 4 9 8 11 15}\ndo_test select3-2.8 {\n  execsql {\n    SELECT log*2+1 AS x, count(*) AS y FROM t1 GROUP BY x ORDER BY 10-(x+y)\n  }\n} {11 15 9 8 7 4 5 2 3 1 1 1}\n#do_test select3-2.9 {\n#  catchsql {\n#    SELECT log, count(*) FROM t1 GROUP BY 'x' ORDER BY log;\n#  }\n#} {1 {GROUP BY terms must not be non-integer constants}}\ndo_test select3-2.10 {\n  catchsql {\n    SELECT log, count(*) FROM t1 GROUP BY 0 ORDER BY log;\n  }\n} {1 {1st GROUP BY term out of range - should be between 1 and 2}}\ndo_test select3-2.11 {\n  catchsql {\n    SELECT log, count(*) FROM t1 GROUP BY 3 ORDER BY log;\n  }\n} {1 {1st GROUP BY term out of range - should be between 1 and 2}}\ndo_test select3-2.12 {\n  catchsql {\n    SELECT log, count(*) FROM t1 GROUP BY 1 ORDER BY log;\n  }\n} {0 {0 1 1 1 2 2 3 4 4 8 5 15}}\n\n# Cannot have an empty GROUP BY\ndo_test select3-2.13 {\n  catchsql {\n    SELECT log, count(*) FROM t1 GROUP BY ORDER BY log;\n  }\n} {1 {near \"ORDER\": syntax error}}\ndo_test select3-2.14 {\n  catchsql {\n    SELECT log, count(*) FROM t1 GROUP BY;\n  }\n} {1 {near \";\": syntax error}}\n\n# Cannot have a HAVING without a GROUP BY\n#\ndo_test select3-3.1 {\n  set v [catch {execsql {SELECT log, count(*) FROM t1 HAVING log>=4}} msg]\n  lappend v $msg\n} {1 {a GROUP BY clause is required before HAVING}}\n\n# Toss in some HAVING clauses\n#\ndo_test select3-4.1 {\n  execsql {SELECT log, count(*) FROM t1 GROUP BY log HAVING log>=4 ORDER BY log}\n} {4 8 5 15}\ndo_test select3-4.2 {\n  execsql {\n    SELECT log, count(*) FROM t1 \n    GROUP BY log \n    HAVING count(*)>=4 \n    ORDER BY log\n  }\n} {3 4 4 8 5 15}\ndo_test select3-4.3 {\n  execsql {\n    SELECT log, count(*) FROM t1 \n    GROUP BY log \n    HAVING count(*)>=4 \n    ORDER BY max(n)+0\n  }\n} {3 4 4 8 5 15}\ndo_test select3-4.4 {\n  execsql {\n    SELECT log AS x, count(*) AS y FROM t1 \n    GROUP BY x\n    HAVING y>=4 \n    ORDER BY max(n)+0\n  }\n} {3 4 4 8 5 15}\ndo_test select3-4.5 {\n  execsql {\n    SELECT log AS x FROM t1 \n    GROUP BY x\n    HAVING count(*)>=4 \n    ORDER BY max(n)+0\n  }\n} {3 4 5}\n\ndo_test select3-5.1 {\n  execsql {\n    SELECT log, count(*), avg(n), max(n+log*2) FROM t1 \n    GROUP BY log \n    ORDER BY max(n+log*2)+0, avg(n)+0\n  }\n} {0 1 1.0 1 1 1 2.0 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24.0 41}\ndo_test select3-5.2 {\n  execsql {\n    SELECT log, count(*), avg(n), max(n+log*2) FROM t1 \n    GROUP BY log \n    ORDER BY max(n+log*2)+0, min(log,avg(n))+0\n  }\n} {0 1 1.0 1 1 1 2.0 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24.0 41}\n\n# Test sorting of GROUP BY results in the presence of an index\n# on the GROUP BY column.\n#\ndo_test select3-6.1 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log;\n  }\n} {0 1 1 2 2 3 3 5 4 9 5 17}\ndo_test select3-6.2 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log DESC;\n  }\n} {5 17 4 9 3 5 2 3 1 2 0 1}\ndo_test select3-6.3 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1;\n  }\n} {0 1 1 2 2 3 3 5 4 9 5 17}\ndo_test select3-6.4 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1 DESC;\n  }\n} {5 17 4 9 3 5 2 3 1 2 0 1}\ndo_test select3-6.5 {\n  execsql {\n    CREATE INDEX i1 ON t1(log);\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log;\n  }\n} {0 1 1 2 2 3 3 5 4 9 5 17}\ndo_test select3-6.6 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY log DESC;\n  }\n} {5 17 4 9 3 5 2 3 1 2 0 1}\ndo_test select3-6.7 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1;\n  }\n} {0 1 1 2 2 3 3 5 4 9 5 17}\ndo_test select3-6.8 {\n  execsql {\n    SELECT log, min(n) FROM t1 GROUP BY log ORDER BY 1 DESC;\n  }\n} {5 17 4 9 3 5 2 3 1 2 0 1}\n\n# Sometimes an aggregate query can return no rows at all.\n#\ndo_test select3-7.1 {\n  execsql {\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 VALUES(1,2);\n    SELECT a, sum(b) FROM t2 WHERE b=5 GROUP BY a;\n  }\n} {}\ndo_test select3-7.2 {\n  execsql {\n    SELECT a, sum(b) FROM t2 WHERE b=5;\n  }\n} {{} {}}\n\n# If a table column is of type REAL but we are storing integer values\n# in it, the values are stored as integers to take up less space.  The\n# values are converted by to REAL as they are read out of the table.\n# Make sure the GROUP BY clause does this conversion correctly.\n# Ticket #2251.\n#\ndo_test select3-8.1 {\n  execsql {\n    CREATE TABLE A (\n      A1 DOUBLE,\n      A2 VARCHAR COLLATE NOCASE,\n      A3 DOUBLE\n    );\n    INSERT INTO A VALUES(39136,'ABC',1201900000);\n    INSERT INTO A VALUES(39136,'ABC',1207000000);\n    SELECT typeof(sum(a3)) FROM a;\n  }\n} {real}\ndo_test select3-8.2 {\n  execsql {\n    SELECT typeof(sum(a3)) FROM a GROUP BY a1;\n  }\n} {real}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select4.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing UNION, INTERSECT and EXCEPT operators\n# in SELECT statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Most tests in this file depend on compound-select. But there are a couple\n# right at the end that test DISTINCT, so we cannot omit the entire file.\n#\nifcapable compound {\n\n# Build some test data\n#\nexecsql {\n  CREATE TABLE t1(n int, log int);\n  BEGIN;\n}\nfor {set i 1} {$i<32} {incr i} {\n  for {set j 0} {(1<<$j)<$i} {incr j} {}\n  execsql \"INSERT INTO t1 VALUES($i,$j)\"\n}\nexecsql {\n  COMMIT;\n}\n\ndo_test select4-1.0 {\n  execsql {SELECT DISTINCT log FROM t1 ORDER BY log}\n} {0 1 2 3 4 5}\n\n# Union All operator\n#\ndo_test select4-1.1a {\n  lsort [execsql {SELECT DISTINCT log FROM t1}]\n} {0 1 2 3 4 5}\ndo_test select4-1.1b {\n  lsort [execsql {SELECT n FROM t1 WHERE log=3}]\n} {5 6 7 8}\ndo_test select4-1.1c {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }\n} {0 1 2 3 4 5 5 6 7 8}\ndo_test select4-1.1d {\n  execsql {\n    CREATE TABLE t2 AS\n      SELECT DISTINCT log FROM t1\n      UNION ALL\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log;\n    SELECT * FROM t2;\n  }\n} {0 1 2 3 4 5 5 6 7 8}\nexecsql {DROP TABLE t2}\ndo_test select4-1.1e {\n  execsql {\n    CREATE TABLE t2 AS\n      SELECT DISTINCT log FROM t1\n      UNION ALL\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log DESC;\n    SELECT * FROM t2;\n  }\n} {8 7 6 5 5 4 3 2 1 0}\nexecsql {DROP TABLE t2}\ndo_test select4-1.1f {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=2\n  }\n} {0 1 2 3 4 5 3 4}\ndo_test select4-1.1g {\n  execsql {\n    CREATE TABLE t2 AS \n      SELECT DISTINCT log FROM t1\n      UNION ALL\n      SELECT n FROM t1 WHERE log=2;\n    SELECT * FROM t2;\n  }\n} {0 1 2 3 4 5 3 4}\nexecsql {DROP TABLE t2}\nifcapable subquery {\n  do_test select4-1.2 {\n    execsql {\n      SELECT log FROM t1 WHERE n IN \n        (SELECT DISTINCT log FROM t1 UNION ALL\n         SELECT n FROM t1 WHERE log=3)\n      ORDER BY log;\n    }\n  } {0 1 2 2 3 3 3 3}\n}\n\n# EVIDENCE-OF: R-02644-22131 In a compound SELECT statement, only the\n# last or right-most simple SELECT may have an ORDER BY clause.\n#\ndo_test select4-1.3 {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {ORDER BY clause should come after UNION ALL not before}}\ndo_catchsql_test select4-1.4 {\n  SELECT (VALUES(0) INTERSECT SELECT(0) UNION SELECT(0) ORDER BY 1 UNION\n          SELECT 0 UNION SELECT 0 ORDER BY 1);\n} {1 {ORDER BY clause should come after UNION not before}}\n\n# Union operator\n#\ndo_test select4-2.1 {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    UNION\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }\n} {0 1 2 3 4 5 6 7 8}\nifcapable subquery {\n  do_test select4-2.2 {\n    execsql {\n      SELECT log FROM t1 WHERE n IN \n        (SELECT DISTINCT log FROM t1 UNION\n         SELECT n FROM t1 WHERE log=3)\n      ORDER BY log;\n    }\n  } {0 1 2 2 3 3 3 3}\n}\ndo_test select4-2.3 {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log\n    UNION\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {ORDER BY clause should come after UNION not before}}\ndo_test select4-2.4 {\n  set v [catch {execsql {\n    SELECT 0 ORDER BY (SELECT 0) UNION SELECT 0;\n  }} msg]\n  lappend v $msg\n} {1 {ORDER BY clause should come after UNION not before}}\ndo_execsql_test select4-2.5 {\n  SELECT 123 AS x ORDER BY (SELECT x ORDER BY 1);\n} {123}\n\n# Except operator\n#\ndo_test select4-3.1.1 {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    EXCEPT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }\n} {0 1 2 3 4}\ndo_test select4-3.1.2 {\n  execsql {\n    CREATE TABLE t2 AS \n      SELECT DISTINCT log FROM t1\n      EXCEPT\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log;\n    SELECT * FROM t2;\n  }\n} {0 1 2 3 4}\nexecsql {DROP TABLE t2}\ndo_test select4-3.1.3 {\n  execsql {\n    CREATE TABLE t2 AS \n      SELECT DISTINCT log FROM t1\n      EXCEPT\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log DESC;\n    SELECT * FROM t2;\n  }\n} {4 3 2 1 0}\nexecsql {DROP TABLE t2}\nifcapable subquery {\n  do_test select4-3.2 {\n    execsql {\n      SELECT log FROM t1 WHERE n IN \n        (SELECT DISTINCT log FROM t1 EXCEPT\n         SELECT n FROM t1 WHERE log=3)\n      ORDER BY log;\n    }\n  } {0 1 2 2}\n}\ndo_test select4-3.3 {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log\n    EXCEPT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {ORDER BY clause should come after EXCEPT not before}}\n\n# Intersect operator\n#\ndo_test select4-4.1.1 {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    INTERSECT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }\n} {5}\n\ndo_test select4-4.1.2 {\n  execsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT 6\n    INTERSECT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY t1.log;\n  }\n} {5 6}\n\ndo_test select4-4.1.3 {\n  execsql {\n    CREATE TABLE t2 AS\n      SELECT DISTINCT log FROM t1 UNION ALL SELECT 6\n      INTERSECT\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log;\n    SELECT * FROM t2;\n  }\n} {5 6}\nexecsql {DROP TABLE t2}\ndo_test select4-4.1.4 {\n  execsql {\n    CREATE TABLE t2 AS\n      SELECT DISTINCT log FROM t1 UNION ALL SELECT 6\n      INTERSECT\n      SELECT n FROM t1 WHERE log=3\n      ORDER BY log DESC;\n    SELECT * FROM t2;\n  }\n} {6 5}\nexecsql {DROP TABLE t2}\nifcapable subquery {\n  do_test select4-4.2 {\n    execsql {\n      SELECT log FROM t1 WHERE n IN \n        (SELECT DISTINCT log FROM t1 INTERSECT\n         SELECT n FROM t1 WHERE log=3)\n      ORDER BY log;\n    }\n  } {3}\n}\ndo_test select4-4.3 {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log\n    INTERSECT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {ORDER BY clause should come after INTERSECT not before}}\ndo_catchsql_test select4-4.4 {\n  SELECT 3 IN (\n    SELECT 0 ORDER BY 1\n    INTERSECT\n    SELECT 1\n    INTERSECT \n    SELECT 2\n    ORDER BY 1\n  );\n} {1 {ORDER BY clause should come after INTERSECT not before}}\n\n# Various error messages while processing UNION or INTERSECT\n#\ndo_test select4-5.1 {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t2\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {no such table: t2}}\ndo_test select4-5.2 {\n  set v [catch {execsql {\n    SELECT DISTINCT log AS \"xyzzy\" FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY xyzzy;\n  }} msg]\n  lappend v $msg\n} {0 {0 1 2 3 4 5 5 6 7 8}}\ndo_test select4-5.2b {\n  set v [catch {execsql {\n    SELECT DISTINCT log AS xyzzy FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY \"xyzzy\";\n  }} msg]\n  lappend v $msg\n} {0 {0 1 2 3 4 5 5 6 7 8}}\ndo_test select4-5.2c {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY \"xyzzy\";\n  }} msg]\n  lappend v $msg\n} {1 {1st ORDER BY term does not match any column in the result set}}\ndo_test select4-5.2d {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1\n    INTERSECT\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY \"xyzzy\";\n  }} msg]\n  lappend v $msg\n} {1 {1st ORDER BY term does not match any column in the result set}}\ndo_test select4-5.2e {\n  set v [catch {execsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY n;\n  }} msg]\n  lappend v $msg\n} {0 {0 1 2 3 4 5 5 6 7 8}}\ndo_test select4-5.2f {\n  catchsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }\n} {0 {0 1 2 3 4 5 5 6 7 8}}\ndo_test select4-5.2g {\n  catchsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY 1;\n  }\n} {0 {0 1 2 3 4 5 5 6 7 8}}\ndo_test select4-5.2h {\n  catchsql {\n    SELECT DISTINCT log FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY 2;\n  }\n} {1 {1st ORDER BY term out of range - should be between 1 and 1}}\ndo_test select4-5.2i {\n  catchsql {\n    SELECT DISTINCT 1, log FROM t1\n    UNION ALL\n    SELECT 2, n FROM t1 WHERE log=3\n    ORDER BY 2, 1;\n  }\n} {0 {1 0 1 1 1 2 1 3 1 4 1 5 2 5 2 6 2 7 2 8}}\ndo_test select4-5.2j {\n  catchsql {\n    SELECT DISTINCT 1, log FROM t1\n    UNION ALL\n    SELECT 2, n FROM t1 WHERE log=3\n    ORDER BY 1, 2 DESC;\n  }\n} {0 {1 5 1 4 1 3 1 2 1 1 1 0 2 8 2 7 2 6 2 5}}\ndo_test select4-5.2k {\n  catchsql {\n    SELECT DISTINCT 1, log FROM t1\n    UNION ALL\n    SELECT 2, n FROM t1 WHERE log=3\n    ORDER BY n, 1;\n  }\n} {0 {1 0 1 1 1 2 1 3 1 4 1 5 2 5 2 6 2 7 2 8}}\ndo_test select4-5.3 {\n  set v [catch {execsql {\n    SELECT DISTINCT log, n FROM t1\n    UNION ALL\n    SELECT n FROM t1 WHERE log=3\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test select4-5.3-3807-1 {\n  catchsql {\n    SELECT 1 UNION SELECT 2, 3 UNION SELECT 4, 5 ORDER BY 1;\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test select4-5.4 {\n  set v [catch {execsql {\n    SELECT log FROM t1 WHERE n=2\n    UNION ALL\n    SELECT log FROM t1 WHERE n=3\n    UNION ALL\n    SELECT log FROM t1 WHERE n=4\n    UNION ALL\n    SELECT log FROM t1 WHERE n=5\n    ORDER BY log;\n  }} msg]\n  lappend v $msg\n} {0 {1 2 2 3}}\n\ndo_test select4-6.1 {\n  execsql {\n    SELECT log, count(*) as cnt FROM t1 GROUP BY log\n    UNION\n    SELECT log, n FROM t1 WHERE n=7\n    ORDER BY cnt, log;\n  }\n} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}\ndo_test select4-6.2 {\n  execsql {\n    SELECT log, count(*) FROM t1 GROUP BY log\n    UNION\n    SELECT log, n FROM t1 WHERE n=7\n    ORDER BY count(*), log;\n  }\n} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}\n\n# NULLs are indistinct for the UNION operator.\n# Make sure the UNION operator recognizes this\n#\ndo_test select4-6.3 {\n  execsql {\n    SELECT NULL UNION SELECT NULL UNION\n    SELECT 1 UNION SELECT 2 AS 'x'\n    ORDER BY x;\n  }\n} {{} 1 2}\ndo_test select4-6.3.1 {\n  execsql {\n    SELECT NULL UNION ALL SELECT NULL UNION ALL\n    SELECT 1 UNION ALL SELECT 2 AS 'x'\n    ORDER BY x;\n  }\n} {{} {} 1 2}\n\n# Make sure the DISTINCT keyword treats NULLs as indistinct.\n#\nifcapable subquery {\n  do_test select4-6.4 {\n    execsql {\n      SELECT * FROM (\n         SELECT NULL, 1 UNION ALL SELECT NULL, 1\n      );\n    }\n  } {{} 1 {} 1}\n  do_test select4-6.5 {\n    execsql {\n      SELECT DISTINCT * FROM (\n         SELECT NULL, 1 UNION ALL SELECT NULL, 1\n      );\n    }\n  } {{} 1}\n  do_test select4-6.6 {\n    execsql {\n      SELECT DISTINCT * FROM (\n         SELECT 1,2  UNION ALL SELECT 1,2\n      );\n    }\n  } {1 2}\n}\n\n# Test distinctness of NULL in other ways.\n#\ndo_test select4-6.7 {\n  execsql {\n    SELECT NULL EXCEPT SELECT NULL\n  }\n} {}\n\n\n# Make sure column names are correct when a compound select appears as\n# an expression in the WHERE clause.\n#\ndo_test select4-7.1 {\n  execsql {\n    CREATE TABLE t2 AS SELECT log AS 'x', count(*) AS 'y' FROM t1 GROUP BY log;\n    SELECT * FROM t2 ORDER BY x;\n  }\n} {0 1 1 1 2 2 3 4 4 8 5 15}  \nifcapable subquery {\n  do_test select4-7.2 {\n    execsql2 {\n      SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 INTERSECT SELECT x FROM t2)\n      ORDER BY n\n    }\n  } {n 1 log 0 n 2 log 1 n 3 log 2 n 4 log 2 n 5 log 3}\n  do_test select4-7.3 {\n    execsql2 {\n      SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 EXCEPT SELECT x FROM t2)\n      ORDER BY n LIMIT 2\n    }\n  } {n 6 log 3 n 7 log 3}\n  do_test select4-7.4 {\n    execsql2 {\n      SELECT * FROM t1 WHERE n IN (SELECT n FROM t1 UNION SELECT x FROM t2)\n      ORDER BY n LIMIT 2\n    }\n  } {n 1 log 0 n 2 log 1}\n} ;# ifcapable subquery\n\n} ;# ifcapable compound\n\n# Make sure DISTINCT works appropriately on TEXT and NUMERIC columns.\ndo_test select4-8.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(a text, b float, c text);\n    INSERT INTO t3 VALUES(1, 1.1, '1.1');\n    INSERT INTO t3 VALUES(2, 1.10, '1.10');\n    INSERT INTO t3 VALUES(3, 1.10, '1.1');\n    INSERT INTO t3 VALUES(4, 1.1, '1.10');\n    INSERT INTO t3 VALUES(5, 1.2, '1.2');\n    INSERT INTO t3 VALUES(6, 1.3, '1.3');\n    COMMIT;\n  }\n  execsql {\n    SELECT DISTINCT b FROM t3 ORDER BY c;\n  }\n} {1.1 1.2 1.3}\ndo_test select4-8.2 {\n  execsql {\n    SELECT DISTINCT c FROM t3 ORDER BY c;\n  }\n} {1.1 1.10 1.2 1.3}\n\n# Make sure the names of columns are taken from the right-most subquery\n# right in a compound query.  Ticket #1721\n#\nifcapable compound {\n\ndo_test select4-9.1 {\n  execsql2 {\n    SELECT x, y FROM t2 UNION SELECT a, b FROM t3 ORDER BY x LIMIT 1\n  }\n} {x 0 y 1}\ndo_test select4-9.2 {\n  execsql2 {\n    SELECT x, y FROM t2 UNION ALL SELECT a, b FROM t3 ORDER BY x LIMIT 1\n  }\n} {x 0 y 1}\ndo_test select4-9.3 {\n  execsql2 {\n    SELECT x, y FROM t2 EXCEPT SELECT a, b FROM t3 ORDER BY x LIMIT 1\n  }\n} {x 0 y 1}\ndo_test select4-9.4 {\n  execsql2 {\n    SELECT x, y FROM t2 INTERSECT SELECT 0 AS a, 1 AS b;\n  }\n} {x 0 y 1}\ndo_test select4-9.5 {\n  execsql2 {\n    SELECT 0 AS x, 1 AS y\n    UNION\n    SELECT 2 AS p, 3 AS q\n    UNION\n    SELECT 4 AS a, 5 AS b\n    ORDER BY x LIMIT 1\n  }\n} {x 0 y 1}\n\nifcapable subquery {\ndo_test select4-9.6 {\n  execsql2 {\n    SELECT * FROM (\n      SELECT 0 AS x, 1 AS y\n      UNION\n      SELECT 2 AS p, 3 AS q\n      UNION\n      SELECT 4 AS a, 5 AS b\n    ) ORDER BY 1 LIMIT 1;\n  }\n} {x 0 y 1}\ndo_test select4-9.7 {\n  execsql2 {\n    SELECT * FROM (\n      SELECT 0 AS x, 1 AS y\n      UNION\n      SELECT 2 AS p, 3 AS q\n      UNION\n      SELECT 4 AS a, 5 AS b\n    ) ORDER BY x LIMIT 1;\n  }\n} {x 0 y 1}\n} ;# ifcapable subquery\n\ndo_test select4-9.8 {\n  execsql {\n    SELECT 0 AS x, 1 AS y\n    UNION\n    SELECT 2 AS y, -3 AS x\n    ORDER BY x LIMIT 1;\n  }\n} {0 1}\n\ndo_test select4-9.9.1 {\n  execsql2 {\n    SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a\n  }\n} {a 1 b 2 a 3 b 4}\n\nifcapable subquery {\ndo_test select4-9.9.2 {\n  execsql2 {\n    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)\n     WHERE b=3\n  }\n} {}\ndo_test select4-9.10 {\n  execsql2 {\n    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS b, 4 AS a)\n     WHERE b=2\n  }\n} {a 1 b 2}\ndo_test select4-9.11 {\n  execsql2 {\n    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)\n     WHERE b=2\n  }\n} {a 1 b 2}\ndo_test select4-9.12 {\n  execsql2 {\n    SELECT * FROM (SELECT 1 AS a, 2 AS b UNION ALL SELECT 3 AS e, 4 AS b)\n     WHERE b>0\n  }\n} {a 1 b 2 a 3 b 4}\n} ;# ifcapable subquery\n\n# Try combining DISTINCT, LIMIT, and OFFSET.  Make sure they all work\n# together.\n#\ndo_test select4-10.1 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log\n  }\n} {0 1 2 3 4 5}\ndo_test select4-10.2 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 4\n  }\n} {0 1 2 3}\ndo_test select4-10.3 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 0\n  }\n} {}\ndo_test select4-10.4 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT -1\n  }\n} {0 1 2 3 4 5}\ndo_test select4-10.5 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT -1 OFFSET 2\n  }\n} {2 3 4 5}\ndo_test select4-10.6 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 3 OFFSET 2\n  }\n} {2 3 4}\ndo_test select4-10.7 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY +log LIMIT 3 OFFSET 20\n  }\n} {}\ndo_test select4-10.8 {\n  execsql {\n    SELECT DISTINCT log FROM t1 ORDER BY log LIMIT 0 OFFSET 3\n  }\n} {}\ndo_test select4-10.9 {\n  execsql {\n    SELECT DISTINCT max(n), log FROM t1 ORDER BY +log; -- LIMIT 2 OFFSET 1\n  }\n} {31 5}\n\n# Make sure compound SELECTs with wildly different numbers of columns\n# do not cause assertion faults due to register allocation issues.\n#\ndo_test select4-11.1 {\n  catchsql {\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    UNION\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test select4-11.2 {\n  catchsql {\n    SELECT x FROM t2\n    UNION\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test select4-11.3 {\n  catchsql {\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test select4-11.4 {\n  catchsql {\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test select4-11.5 {\n  catchsql {\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}\ndo_test select4-11.6 {\n  catchsql {\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n  }\n} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}\ndo_test select4-11.7 {\n  catchsql {\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    INTERSECT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}\ndo_test select4-11.8 {\n  catchsql {\n    SELECT x FROM t2\n    INTERSECT\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n  }\n} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}\n\ndo_test select4-11.11 {\n  catchsql {\n    SELECT x FROM t2\n    UNION\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n    INTERSECT\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n  }\n} {1 {SELECTs to the left and right of INTERSECT do not have the same number of result columns}}\ndo_test select4-11.12 {\n  catchsql {\n    SELECT x FROM t2\n    UNION\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of EXCEPT do not have the same number of result columns}}\ndo_test select4-11.13 {\n  catchsql {\n    SELECT x FROM t2\n    UNION\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\ndo_test select4-11.14 {\n  catchsql {\n    SELECT x FROM t2\n    UNION\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    UNION\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test select4-11.15 {\n  catchsql {\n    SELECT x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x FROM t2\n    UNION\n    SELECT x FROM t2\n    INTERSECT\n    SELECT x FROM t2\n    UNION ALL\n    SELECT x FROM t2\n    EXCEPT\n    SELECT x FROM t2\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\ndo_test select4-11.16 {\n  catchsql {\n    INSERT INTO t2(rowid) VALUES(2) UNION SELECT 3,4 UNION SELECT 5,6 ORDER BY 1;\n  }\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\n\ndo_test select4-12.1 {\n  sqlite3 db2 :memory:\n  catchsql {\n    SELECT 1 UNION SELECT 2,3 UNION SELECT 4,5 ORDER BY 1;\n  } db2\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\n\n} ;# ifcapable compound\n\n\n# Ticket [3557ad65a076c] - Incorrect DISTINCT processing with an\n# indexed query using IN.\n#\ndo_test select4-13.1 {\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t13(a,b);\n    INSERT INTO t13 VALUES(1,1);\n    INSERT INTO t13 VALUES(2,1);\n    INSERT INTO t13 VALUES(3,1);\n    INSERT INTO t13 VALUES(2,2);\n    INSERT INTO t13 VALUES(3,2);\n    INSERT INTO t13 VALUES(4,2);\n    CREATE INDEX t13ab ON t13(a,b);\n    SELECT DISTINCT b from t13 WHERE a IN (1,2,3);\n  }\n} {1 2}\n\n# 2014-02-18: Make sure compound SELECTs work with VALUES clauses\n#\ndo_execsql_test select4-14.1 {\n  CREATE TABLE t14(a,b,c);\n  INSERT INTO t14 VALUES(1,2,3),(4,5,6);\n  SELECT * FROM t14 INTERSECT VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);\n} {1 2 3}\ndo_execsql_test select4-14.2 {\n  SELECT * FROM t14 INTERSECT VALUES(1,2,3);\n} {1 2 3}\ndo_execsql_test select4-14.3 {\n  SELECT * FROM t14\n   UNION VALUES(3,2,1),(2,3,1),(1,2,3),(7,8,9),(4,5,6)\n   UNION SELECT * FROM t14 ORDER BY 1, 2, 3\n} {1 2 3 2 3 1 3 2 1 4 5 6 7 8 9}\ndo_execsql_test select4-14.4 {\n  SELECT * FROM t14\n   UNION VALUES(3,2,1)\n   UNION SELECT * FROM t14 ORDER BY 1, 2, 3\n} {1 2 3 3 2 1 4 5 6}\ndo_execsql_test select4-14.5 {\n  SELECT * FROM t14 EXCEPT VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);\n} {4 5 6}\ndo_execsql_test select4-14.6 {\n  SELECT * FROM t14 EXCEPT VALUES(1,2,3)\n} {4 5 6}\ndo_execsql_test select4-14.7 {\n  SELECT * FROM t14 EXCEPT VALUES(1,2,3) EXCEPT VALUES(4,5,6)\n} {}\ndo_execsql_test select4-14.8 {\n  SELECT * FROM t14 EXCEPT VALUES('a','b','c') EXCEPT VALUES(4,5,6)\n} {1 2 3}\ndo_execsql_test select4-14.9 {\n  SELECT * FROM t14 UNION ALL VALUES(3,2,1),(2,3,1),(1,2,3),(2,1,3);\n} {1 2 3 4 5 6 3 2 1 2 3 1 1 2 3 2 1 3}\ndo_execsql_test select4-14.10 {\n  SELECT (VALUES(1),(2),(3),(4))\n} {1}\ndo_execsql_test select4-14.11 {\n  SELECT (SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4)\n} {1}\ndo_execsql_test select4-14.12 {\n  VALUES(1) UNION VALUES(2);\n} {1 2}\ndo_execsql_test select4-14.13 {\n  VALUES(1),(2),(3) EXCEPT VALUES(2);\n} {1 3}\ndo_execsql_test select4-14.14 {\n  VALUES(1),(2),(3) EXCEPT VALUES(1),(3);\n} {2}\ndo_execsql_test select4-14.15 {\n  SELECT * FROM (SELECT 123), (SELECT 456) ON likely(0 OR 1) OR 0;\n} {123 456}\ndo_execsql_test select4-14.16 {\n  VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 99;\n} {1 2 3 4 5}\ndo_execsql_test select4-14.17 {\n  VALUES(1),(2),(3),(4) UNION ALL SELECT 5 LIMIT 3;\n} {1 2 3}\n\n# Ticket https://www.sqlite.org/src/info/d06a25c84454a372\n# Incorrect answer due to two co-routines using the same registers and expecting\n# those register values to be preserved across a Yield.\n#\ndo_execsql_test select4-15.1 {\n  DROP TABLE IF EXISTS tx;\n  CREATE TABLE tx(id INTEGER PRIMARY KEY, a, b);\n  INSERT INTO tx(a,b) VALUES(33,456);\n  INSERT INTO tx(a,b) VALUES(33,789);\n\n  SELECT DISTINCT t0.id, t0.a, t0.b\n    FROM tx AS t0, tx AS t1\n   WHERE t0.a=t1.a AND t1.a=33 AND t0.b=456\n  UNION\n  SELECT DISTINCT t0.id, t0.a, t0.b\n    FROM tx AS t0, tx AS t1\n   WHERE t0.a=t1.a AND t1.a=33 AND t0.b=789\n   ORDER BY 1;\n} {1 33 456 2 33 789}\n\n# Enhancement (2016-03-15):  Use a co-routine for subqueries if the\n# subquery is guaranteed to be the outer-most query\n#\ndo_execsql_test select4-16.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,\n  PRIMARY KEY(a,b DESC)) WITHOUT ROWID;\n\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n  INSERT INTO t1(a,b,c,d)\n    SELECT x%10, x/10, x, printf('xyz%dabc',x) FROM c;\n\n  SELECT t3.c FROM \n    (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2\n    JOIN t1 AS t3\n  WHERE t2.a=t3.a AND t2.m=t3.b\n  ORDER BY t3.a;\n} {95 96 97 98 99}\ndo_execsql_test select4-16.2 {\n  SELECT t3.c FROM \n    (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2\n    CROSS JOIN t1 AS t3\n  WHERE t2.a=t3.a AND t2.m=t3.b\n  ORDER BY t3.a;\n} {95 96 97 98 99}\ndo_execsql_test select4-16.3 {\n  SELECT t3.c FROM \n    (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2\n    LEFT JOIN t1 AS t3\n  WHERE t2.a=t3.a AND t2.m=t3.b\n  ORDER BY t3.a;\n} {95 96 97 98 99}\n\n# Ticket https://www.sqlite.org/src/tktview/f7f8c97e975978d45  on 2016-04-25\n#\n# The where push-down optimization from 2015-06-02 is suppose to disable\n# on aggregate subqueries.  But if the subquery is a compound where the\n# last SELECT is non-aggregate but some other SELECT is an aggregate, the\n# test is incomplete and the optimization is not properly disabled.\n# \n# The following test cases verify that the fix works.\n#\ndo_execsql_test select4-17.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a int, b int);\n  INSERT INTO t1 VALUES(1,2),(1,18),(2,19);\n  SELECT x, y FROM (\n    SELECT 98 AS x, 99 AS y\n    UNION\n    SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a\n  ) AS w WHERE y>=20\n  ORDER BY +x;\n} {1 20 98 99}\ndo_execsql_test select4-17.2 {\n  SELECT x, y FROM (\n    SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a\n    UNION\n    SELECT 98 AS x, 99 AS y\n  ) AS w WHERE y>=20\n  ORDER BY +x;\n} {1 20 98 99}\ndo_catchsql_test select4-17.3 {\n  SELECT x, y FROM (\n    SELECT a AS x, sum(b) AS y FROM t1 GROUP BY a LIMIT 3\n    UNION\n    SELECT 98 AS x, 99 AS y\n  ) AS w WHERE y>=20\n  ORDER BY +x;\n} {1 {LIMIT clause should come after UNION not before}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select5.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing aggregate functions and the\n# GROUP BY and HAVING clauses of SELECT statements.\n#\n# $Id: select5.test,v 1.20 2008/08/21 14:15:59 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\nexecsql {\n  CREATE TABLE t1(x int, y int);\n  BEGIN;\n}\nfor {set i 1} {$i<32} {incr i} {\n  for {set j 0} {(1<<$j)<$i} {incr j} {}\n  execsql \"INSERT INTO t1 VALUES([expr {32-$i}],[expr {10-$j}])\"\n}\nexecsql {\n  COMMIT\n}\n\ndo_test select5-1.0 {\n  execsql {SELECT DISTINCT y FROM t1 ORDER BY y}\n} {5 6 7 8 9 10}\n\n# Sort by an aggregate function.\n#\ndo_test select5-1.1 {\n  execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY y}\n} {5 15 6 8 7 4 8 2 9 1 10 1}\ndo_test select5-1.2 {\n  execsql {SELECT y, count(*) FROM t1 GROUP BY y ORDER BY count(*), y}\n} {9 1 10 1 8 2 7 4 6 8 5 15}\ndo_test select5-1.3 {\n  execsql {SELECT count(*), y FROM t1 GROUP BY y ORDER BY count(*), y}\n} {1 9 1 10 2 8 4 7 8 6 15 5}\n\n# Some error messages associated with aggregates and GROUP BY\n#\ndo_test select5-2.1.1 {\n  catchsql {\n    SELECT y, count(*) FROM t1 GROUP BY z ORDER BY y\n  }\n} {1 {no such column: z}}\ndo_test select5-2.1.2 {\n  catchsql {\n    SELECT y, count(*) FROM t1 GROUP BY temp.t1.y ORDER BY y\n  }\n} {1 {no such column: temp.t1.y}}\ndo_test select5-2.2 {\n  set v [catch {execsql {\n    SELECT y, count(*) FROM t1 GROUP BY z(y) ORDER BY y\n  }} msg]\n  lappend v $msg\n} {1 {no such function: z}}\ndo_test select5-2.3 {\n  set v [catch {execsql {\n    SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<3 ORDER BY y\n  }} msg]\n  lappend v $msg\n} {0 {8 2 9 1 10 1}}\ndo_test select5-2.4 {\n  set v [catch {execsql {\n    SELECT y, count(*) FROM t1 GROUP BY y HAVING z(y)<3 ORDER BY y\n  }} msg]\n  lappend v $msg\n} {1 {no such function: z}}\ndo_test select5-2.5 {\n  set v [catch {execsql {\n    SELECT y, count(*) FROM t1 GROUP BY y HAVING count(*)<z ORDER BY y\n  }} msg]\n  lappend v $msg\n} {1 {no such column: z}}\n\n# Get the Agg function to rehash in vdbe.c\n#\ndo_test select5-3.1 {\n  execsql {\n    SELECT x, count(*), avg(y) FROM t1 GROUP BY x HAVING x<4 ORDER BY x\n  }\n} {1 1 5.0 2 1 5.0 3 1 5.0}\n\n# Run various aggregate functions when the count is zero.\n#\ndo_test select5-4.1 {\n  execsql {\n    SELECT avg(x) FROM t1 WHERE x>100\n  }\n} {{}}\ndo_test select5-4.2 {\n  execsql {\n    SELECT count(x) FROM t1 WHERE x>100\n  }\n} {0}\ndo_test select5-4.3 {\n  execsql {\n    SELECT min(x) FROM t1 WHERE x>100\n  }\n} {{}}\ndo_test select5-4.4 {\n  execsql {\n    SELECT max(x) FROM t1 WHERE x>100\n  }\n} {{}}\ndo_test select5-4.5 {\n  execsql {\n    SELECT sum(x) FROM t1 WHERE x>100\n  }\n} {{}}\n\n# Some tests for queries with a GROUP BY clause but no aggregate functions.\n#\n# Note: The query in test cases 5.1 through 5.5 are not legal SQL. So if the \n# implementation changes in the future and it returns different results,\n# this is not such a big deal.\n#\ndo_test select5-5.1 {\n  execsql {\n    CREATE TABLE t2(a, b, c);\n    INSERT INTO t2 VALUES(1, 2, 3);\n    INSERT INTO t2 VALUES(1, 4, 5);\n    INSERT INTO t2 VALUES(6, 4, 7);\n    CREATE INDEX t2_idx ON t2(a);\n  } \n} {}\ndo_test select5-5.2 {\n  execsql {\n    SELECT a FROM t2 GROUP BY a;\n  } \n} {1 6}\ndo_test select5-5.3 {\n  execsql {\n    SELECT a FROM t2 WHERE a>2 GROUP BY a;\n  } \n} {6}\ndo_test select5-5.4 {\n  execsql {\n    SELECT a, b FROM t2 GROUP BY a, b;\n  } \n} {1 2 1 4 6 4}\ndo_test select5-5.5 {\n  execsql {\n    SELECT a, b FROM t2 GROUP BY a;\n  } \n} {1 4 6 4}\n\n# Test rendering of columns for the GROUP BY clause.\n#\ndo_test select5-5.11 {\n  execsql {\n    SELECT max(c), b*a, b, a FROM t2 GROUP BY b*a, b, a\n  }\n} {3 2 2 1 5 4 4 1 7 24 4 6}\n\n# NULL compare equal to each other for the purposes of processing\n# the GROUP BY clause.\n#\ndo_test select5-6.1 {\n  execsql {\n    CREATE TABLE t3(x,y);\n    INSERT INTO t3 VALUES(1,NULL);\n    INSERT INTO t3 VALUES(2,NULL);\n    INSERT INTO t3 VALUES(3,4);\n    SELECT count(x), y FROM t3 GROUP BY y ORDER BY 1\n  }\n} {1 4 2 {}}\ndo_test select5-6.2 {\n  execsql {\n    CREATE TABLE t4(x,y,z);\n    INSERT INTO t4 VALUES(1,2,NULL);\n    INSERT INTO t4 VALUES(2,3,NULL);\n    INSERT INTO t4 VALUES(3,NULL,5);\n    INSERT INTO t4 VALUES(4,NULL,6);\n    INSERT INTO t4 VALUES(4,NULL,6);\n    INSERT INTO t4 VALUES(5,NULL,NULL);\n    INSERT INTO t4 VALUES(5,NULL,NULL);\n    INSERT INTO t4 VALUES(6,7,8);\n    SELECT max(x), count(x), y, z FROM t4 GROUP BY y, z ORDER BY 1\n  }\n} {1 1 2 {} 2 1 3 {} 3 1 {} 5 4 2 {} 6 5 2 {} {} 6 1 7 8}\n\ndo_test select5-7.2 {\n  execsql {\n    SELECT count(*), count(x) as cnt FROM t4 GROUP BY y ORDER BY cnt;\n  }\n} {1 1 1 1 1 1 5 5}\n\n# See ticket #3324.\n#\ndo_test select5-8.1 {\n  execsql {\n    CREATE TABLE t8a(a,b);\n    CREATE TABLE t8b(x);\n    INSERT INTO t8a VALUES('one', 1);\n    INSERT INTO t8a VALUES('one', 2);\n    INSERT INTO t8a VALUES('two', 3);\n    INSERT INTO t8a VALUES('one', NULL);\n    INSERT INTO t8b(rowid,x) VALUES(1,111);\n    INSERT INTO t8b(rowid,x) VALUES(2,222);\n    INSERT INTO t8b(rowid,x) VALUES(3,333);\n    SELECT a, count(b) FROM t8a, t8b WHERE b=t8b.rowid GROUP BY a ORDER BY a;\n  }\n} {one 2 two 1}\ndo_test select5-8.2 {\n  execsql {\n    SELECT a, count(b) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;\n  }\n} {one 2 two 1}\ndo_test select5-8.3 {\n  execsql {\n    SELECT t8a.a, count(t8a.b) FROM t8a, t8b WHERE t8a.b=t8b.rowid\n     GROUP BY 1 ORDER BY 1;\n  }\n} {one 2 two 1}\ndo_test select5-8.4 {\n  execsql {\n    SELECT a, count(*) FROM t8a, t8b WHERE b=+t8b.rowid GROUP BY a ORDER BY a;\n  }\n} {one 2 two 1}\ndo_test select5-8.5 {\n  execsql {\n    SELECT a, count(b) FROM t8a, t8b WHERE b<x GROUP BY a ORDER BY a;\n  }\n} {one 6 two 3}\ndo_test select5-8.6 {\n  execsql {\n    SELECT a, count(t8a.b) FROM t8a, t8b WHERE b=t8b.rowid \n     GROUP BY a ORDER BY 2;\n  }\n} {two 1 one 2}\ndo_test select5-8.7 {\n  execsql {\n    SELECT a, count(b) FROM t8a, t8b GROUP BY a ORDER BY 2;\n  }\n} {two 3 one 6}\ndo_test select5-8.8 {\n  execsql {\n    SELECT a, count(*) FROM t8a, t8b GROUP BY a ORDER BY 2;\n  }\n} {two 3 one 9}\n\n\n\n \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select6.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing SELECT statements that contain\n# subqueries in their FROM clause.\n#\n# $Id: select6.test,v 1.29 2009/01/09 01:12:28 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Omit this whole file if the library is build without subquery support.\nifcapable !subquery {\n  finish_test\n  return\n}\nset ::testprefix select6\n\ndo_test select6-1.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES(1,1);\n    INSERT INTO t1 VALUES(2,2);\n    INSERT INTO t1 VALUES(3,2);\n    INSERT INTO t1 VALUES(4,3);\n    INSERT INTO t1 VALUES(5,3);\n    INSERT INTO t1 VALUES(6,3);\n    INSERT INTO t1 VALUES(7,3);\n    INSERT INTO t1 VALUES(8,4);\n    INSERT INTO t1 VALUES(9,4);\n    INSERT INTO t1 VALUES(10,4);\n    INSERT INTO t1 VALUES(11,4);\n    INSERT INTO t1 VALUES(12,4);\n    INSERT INTO t1 VALUES(13,4);\n    INSERT INTO t1 VALUES(14,4);\n    INSERT INTO t1 VALUES(15,4);\n    INSERT INTO t1 VALUES(16,5);\n    INSERT INTO t1 VALUES(17,5);\n    INSERT INTO t1 VALUES(18,5);\n    INSERT INTO t1 VALUES(19,5);\n    INSERT INTO t1 VALUES(20,5);\n    COMMIT;\n    SELECT DISTINCT y FROM t1 ORDER BY y;\n  }\n} {1 2 3 4 5}\n\ndo_test select6-1.1 {\n  execsql2 {SELECT * FROM (SELECT x, y FROM t1 WHERE x<2)}\n} {x 1 y 1}\ndo_test select6-1.2 {\n  execsql {SELECT count(*) FROM (SELECT y FROM t1)}\n} {20}\ndo_test select6-1.3 {\n  execsql {SELECT count(*) FROM (SELECT DISTINCT y FROM t1)}\n} {5}\ndo_test select6-1.4 {\n  execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT y FROM t1))}\n} {5}\ndo_test select6-1.5 {\n  execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT y FROM t1))}\n} {5}\n\ndo_test select6-1.6 {\n  execsql {\n    SELECT * \n    FROM (SELECT count(*),y FROM t1 GROUP BY y) AS a,\n         (SELECT max(x),y FROM t1 GROUP BY y) as b\n    WHERE a.y=b.y ORDER BY a.y\n  }\n} {1 1 1 1 2 2 3 2 4 3 7 3 8 4 15 4 5 5 20 5}\ndo_test select6-1.7 {\n  execsql {\n    SELECT a.y, a.[count(*)], [max(x)], [count(*)]\n    FROM (SELECT count(*),y FROM t1 GROUP BY y) AS a,\n         (SELECT max(x),y FROM t1 GROUP BY y) as b\n    WHERE a.y=b.y ORDER BY a.y\n  }\n} {1 1 1 1 2 2 3 2 3 4 7 4 4 8 15 8 5 5 20 5}\ndo_test select6-1.8 {\n  execsql {\n    SELECT q, p, r\n    FROM (SELECT count(*) as p , y as q FROM t1 GROUP BY y) AS a,\n         (SELECT max(x) as r, y as s FROM t1 GROUP BY y) as b\n    WHERE q=s ORDER BY s\n  }\n} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}\ndo_test select6-1.9 {\n  execsql {\n    SELECT q, p, r, b.[min(x)+y]\n    FROM (SELECT count(*) as p , y as q FROM t1 GROUP BY y) AS a,\n         (SELECT max(x) as r, y as s, min(x)+y FROM t1 GROUP BY y) as b\n    WHERE q=s ORDER BY s\n  }\n} {1 1 1 2 2 2 3 4 3 4 7 7 4 8 15 12 5 5 20 21}\n\ndo_test select6-2.0 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t2 SELECT * FROM t1;\n    SELECT DISTINCT b FROM t2 ORDER BY b;\n  }\n} {1 2 3 4 5}\ndo_test select6-2.1 {\n  execsql2 {SELECT * FROM (SELECT a, b FROM t2 WHERE a<2)}\n} {a 1 b 1}\ndo_test select6-2.2 {\n  execsql {SELECT count(*) FROM (SELECT b FROM t2)}\n} {20}\ndo_test select6-2.3 {\n  execsql {SELECT count(*) FROM (SELECT DISTINCT b FROM t2)}\n} {5}\ndo_test select6-2.4 {\n  execsql {SELECT count(*) FROM (SELECT DISTINCT * FROM (SELECT b FROM t2))}\n} {5}\ndo_test select6-2.5 {\n  execsql {SELECT count(*) FROM (SELECT * FROM (SELECT DISTINCT b FROM t2))}\n} {5}\n\ndo_test select6-2.6 {\n  execsql {\n    SELECT * \n    FROM (SELECT count(*),b FROM t2 GROUP BY b) AS a,\n         (SELECT max(a),b FROM t2 GROUP BY b) as b\n    WHERE a.b=b.b ORDER BY a.b\n  }\n} {1 1 1 1 2 2 3 2 4 3 7 3 8 4 15 4 5 5 20 5}\ndo_test select6-2.7 {\n  execsql {\n    SELECT a.b, a.[count(*)], [max(a)], [count(*)]\n    FROM (SELECT count(*),b FROM t2 GROUP BY b) AS a,\n         (SELECT max(a),b FROM t2 GROUP BY b) as b\n    WHERE a.b=b.b ORDER BY a.b\n  }\n} {1 1 1 1 2 2 3 2 3 4 7 4 4 8 15 8 5 5 20 5}\ndo_test select6-2.8 {\n  execsql {\n    SELECT q, p, r\n    FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY b) AS a,\n         (SELECT max(a) as r, b as s FROM t2 GROUP BY b) as b\n    WHERE q=s ORDER BY s\n  }\n} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}\ndo_test select6-2.9 {\n  execsql {\n    SELECT a.q, a.p, b.r\n    FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY q) AS a,\n         (SELECT max(a) as r, b as s FROM t2 GROUP BY s) as b\n    WHERE a.q=b.s ORDER BY a.q\n  }\n} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}\n\ndo_test select6-3.1 {\n  execsql2 {\n    SELECT * FROM (SELECT * FROM (SELECT * FROM t1 WHERE x=3));\n  }\n} {x 3 y 2}\ndo_test select6-3.2 {\n  execsql {\n    SELECT * FROM\n      (SELECT a.q, a.p, b.r\n       FROM (SELECT count(*) as p , b as q FROM t2 GROUP BY q) AS a,\n            (SELECT max(a) as r, b as s FROM t2 GROUP BY s) as b\n       WHERE a.q=b.s ORDER BY a.q)\n    ORDER BY \"a.q\"\n  }\n} {1 1 1 2 2 3 3 4 7 4 8 15 5 5 20}\ndo_test select6-3.3 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)\n  }\n} {10.5 3.7 14.2}\ndo_test select6-3.4 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)\n  }\n} {11.5 4.0 15.5}\ndo_test select6-3.5 {\n  execsql {\n    SELECT x,y,x+y FROM (SELECT avg(a) as 'x', avg(b) as 'y' FROM t2 WHERE a=4)\n  }\n} {4.0 3.0 7.0}\ndo_test select6-3.6 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)\n    WHERE a>10\n  }\n} {10.5 3.7 14.2}\ndo_test select6-3.7 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1)\n    WHERE a<10\n  }\n} {}\ndo_test select6-3.8 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)\n    WHERE a>10\n  }\n} {11.5 4.0 15.5}\ndo_test select6-3.9 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', avg(y) as 'b' FROM t1 WHERE y=4)\n    WHERE a<10\n  }\n} {}\ndo_test select6-3.10 {\n  execsql {\n    SELECT a,b,a+b FROM (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)\n    ORDER BY a\n  }\n} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}\ndo_test select6-3.11 {\n  execsql {\n    SELECT a,b,a+b FROM \n       (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b)\n    WHERE b<4 ORDER BY a\n  }\n} {1.0 1 2.0 2.5 2 4.5 5.5 3 8.5}\ndo_test select6-3.12 {\n  execsql {\n    SELECT a,b,a+b FROM \n       (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)\n    WHERE b<4 ORDER BY a\n  }\n} {2.5 2 4.5 5.5 3 8.5}\ndo_test select6-3.13 {\n  execsql {\n    SELECT a,b,a+b FROM \n       (SELECT avg(x) as 'a', y as 'b' FROM t1 GROUP BY b HAVING a>1)\n    ORDER BY a\n  }\n} {2.5 2 4.5 5.5 3 8.5 11.5 4 15.5 18.0 5 23.0}\ndo_test select6-3.14 {\n  execsql {\n    SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)\n    ORDER BY [count(*)]\n  }\n} {1 1 2 2 4 3 5 5 8 4}\ndo_test select6-3.15 {\n  execsql {\n    SELECT [count(*)],y FROM (SELECT count(*), y FROM t1 GROUP BY y)\n    ORDER BY y\n  }\n} {1 1 2 2 4 3 8 4 5 5}\n\ndo_test select6-4.1 {\n  execsql {\n    SELECT a,b,c FROM \n      (SELECT x AS 'a', y AS 'b', x+y AS 'c' FROM t1 WHERE y=4)\n    WHERE a<10 ORDER BY a;\n  }\n} {8 4 12 9 4 13}\ndo_test select6-4.2 {\n  execsql {\n    SELECT y FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y\n  }\n} {1 2 3 4}\ndo_test select6-4.3 {\n  execsql {\n    SELECT DISTINCT y FROM (SELECT y FROM t1) WHERE y<5 ORDER BY y\n  }\n} {1 2 3 4}\ndo_test select6-4.4 {\n  execsql {\n    SELECT avg(y) FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y\n  }\n} {2.5}\ndo_test select6-4.5 {\n  execsql {\n    SELECT avg(y) FROM (SELECT DISTINCT y FROM t1 WHERE y<5) ORDER BY y\n  }\n} {2.5}\n\ndo_test select6-5.1 {\n  execsql {\n    SELECT a,x,b FROM\n      (SELECT x+3 AS 'a', x FROM t1 WHERE y=3) AS 'p',\n      (SELECT x AS 'b' FROM t1 WHERE y=4) AS 'q'\n    WHERE a=b\n    ORDER BY a\n  }\n} {8 5 8 9 6 9 10 7 10}\ndo_test select6-5.2 {\n  execsql {\n    SELECT a,x,b FROM\n      (SELECT x+3 AS 'a', x FROM t1 WHERE y=3),\n      (SELECT x AS 'b' FROM t1 WHERE y=4)\n    WHERE a=b\n    ORDER BY a\n  }\n} {8 5 8 9 6 9 10 7 10}\n\n# Tests of compound sub-selects\n#\ndo_test select6-6.1 {\n  execsql {\n    DELETE FROM t1 WHERE x>4;\n    SELECT * FROM t1\n  }\n} {1 1 2 2 3 2 4 3}\nifcapable compound {\n  do_test select6-6.2 {\n    execsql {\n      SELECT * FROM (\n        SELECT x AS 'a' FROM t1 UNION ALL SELECT x+10 AS 'a' FROM t1\n      ) ORDER BY a;\n    }\n  } {1 2 3 4 11 12 13 14}\n  do_test select6-6.3 {\n    execsql {\n      SELECT * FROM (\n        SELECT x AS 'a' FROM t1 UNION ALL SELECT x+1 AS 'a' FROM t1\n      ) ORDER BY a;\n    }\n  } {1 2 2 3 3 4 4 5}\n  do_test select6-6.4 {\n    execsql {\n      SELECT * FROM (\n        SELECT x AS 'a' FROM t1 UNION SELECT x+1 AS 'a' FROM t1\n      ) ORDER BY a;\n    }\n  } {1 2 3 4 5}\n  do_test select6-6.5 {\n    execsql {\n      SELECT * FROM (\n        SELECT x AS 'a' FROM t1 INTERSECT SELECT x+1 AS 'a' FROM t1\n      ) ORDER BY a;\n    }\n  } {2 3 4}\n  do_test select6-6.6 {\n    execsql {\n      SELECT * FROM (\n        SELECT x AS 'a' FROM t1 EXCEPT SELECT x*2 AS 'a' FROM t1\n      ) ORDER BY a;\n    }\n  } {1 3}\n} ;# ifcapable compound\n\n# Subselects with no FROM clause\n#\ndo_test select6-7.1 {\n  execsql {\n    SELECT * FROM (SELECT 1)\n  }\n} {1}\ndo_test select6-7.2 {\n  execsql {\n    SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c')\n  }\n} {abc 2 1 1 2 abc}\ndo_test select6-7.3 {\n  execsql {\n    SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c' WHERE 0)\n  }\n} {}\ndo_test select6-7.4 {\n  execsql2 {\n    SELECT c,b,a,* FROM (SELECT 1 AS 'a', 2 AS 'b', 'abc' AS 'c' WHERE 1)\n  }\n} {c abc b 2 a 1 a 1 b 2 c abc}\n\n# The remaining tests in this file depend on the EXPLAIN keyword.\n# Skip these tests if EXPLAIN is disabled in the current build.\n#\nifcapable {!explain} {\n  finish_test\n  return\n}\n\n# The following procedure compiles the SQL given as an argument and returns\n# TRUE if that SQL uses any transient tables and returns FALSE if no\n# transient tables are used.  This is used to make sure that the\n# sqliteFlattenSubquery() routine in select.c is doing its job.\n#\nproc is_flat {sql} {\n  return [expr 0>[lsearch [execsql \"EXPLAIN $sql\"] OpenEphemeral]]\n}\n\n# Check that the flattener works correctly for deeply nested subqueries\n# involving joins.\n#\ndo_test select6-8.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(p,q);\n    INSERT INTO t3 VALUES(1,11);\n    INSERT INTO t3 VALUES(2,22);\n    CREATE TABLE t4(q,r);\n    INSERT INTO t4 VALUES(11,111);\n    INSERT INTO t4 VALUES(22,222);\n    COMMIT;\n    SELECT * FROM t3 NATURAL JOIN t4;\n  }\n} {1 11 111 2 22 222}\ndo_test select6-8.2 {\n  execsql {\n    SELECT y, p, q, r FROM\n       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,\n       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n\n    WHERE  y=p\n  }\n} {1 1 11 111 2 2 22 222 2 2 22 222}\n# If view support is omitted from the build, then so is the query \n# \"flattener\". So omit this test and test select6-8.6 in that case.\nifcapable view {\ndo_test select6-8.3 {\n  is_flat {\n    SELECT y, p, q, r FROM\n       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,\n       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n\n    WHERE  y=p\n  }\n} {1}\n} ;# ifcapable view\ndo_test select6-8.4 {\n  execsql {\n    SELECT DISTINCT y, p, q, r FROM\n       (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,\n       (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n\n    WHERE  y=p\n  }\n} {1 1 11 111 2 2 22 222}\ndo_test select6-8.5 {\n  execsql {\n    SELECT * FROM \n      (SELECT y, p, q, r FROM\n         (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,\n         (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n\n      WHERE  y=p) AS e,\n      (SELECT r AS z FROM t4 WHERE q=11) AS f\n    WHERE e.r=f.z\n  }\n} {1 1 11 111 111}\nifcapable view {\ndo_test select6-8.6 {\n  is_flat {\n    SELECT * FROM \n      (SELECT y, p, q, r FROM\n         (SELECT t1.y AS y, t2.b AS b FROM t1, t2 WHERE t1.x=t2.a) AS m,\n         (SELECT t3.p AS p, t3.q AS q, t4.r AS r FROM t3 NATURAL JOIN t4) as n\n      WHERE  y=p) AS e,\n      (SELECT r AS z FROM t4 WHERE q=11) AS f\n    WHERE e.r=f.z\n  }\n} {1}\n} ;# ifcapable view\n\n# Ticket #1634\n#\ndo_test select6-9.1 {\n  execsql {\n    SELECT a.x, b.x FROM t1 AS a, (SELECT x FROM t1 LIMIT 2) AS b\n     ORDER BY 1, 2\n  }\n} {1 1 1 2 2 1 2 2 3 1 3 2 4 1 4 2}\ndo_test select6-9.2 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT 2);\n  }\n} {1 2}\ndo_test select6-9.3 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT 2 OFFSET 1);\n  }\n} {2 3}\ndo_test select6-9.4 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1) LIMIT 2;\n  }\n} {1 2}\ndo_test select6-9.5 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1) LIMIT 2 OFFSET 1;\n  }\n} {2 3}\ndo_test select6-9.6 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT 2) LIMIT 3;\n  }\n} {1 2}\ndo_test select6-9.7 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT -1) LIMIT 3;\n  }\n} {1 2 3}\ndo_test select6-9.8 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT -1);\n  }\n} {1 2 3 4}\ndo_test select6-9.9 {\n  execsql {\n    SELECT x FROM (SELECT x FROM t1 LIMIT -1 OFFSET 1);\n  }\n} {2 3 4}\ndo_test select6-9.10 {\n  execsql {\n    SELECT x, y FROM (SELECT x, (SELECT 10+x) y FROM t1 LIMIT -1 OFFSET 1);\n  }\n} {2 12 3 13 4 14}\ndo_test select6-9.11 {\n  execsql {\n    SELECT x, y FROM (SELECT x, (SELECT 10)+x y FROM t1 LIMIT -1 OFFSET 1);\n  }\n} {2 12 3 13 4 14}\n\n\n#-------------------------------------------------------------------------\n# Test that if a UNION ALL sub-query that would otherwise be eligible for\n# flattening consists of two or more SELECT statements that do not all \n# return the same number of result columns, the error is detected.\n#\ndo_execsql_test 10.1 {\n  CREATE TABLE t(i,j,k);\n  CREATE TABLE j(l,m);\n  CREATE TABLE k(o);\n}\n\nset err [list 1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}]\n\ndo_execsql_test 10.2 {\n  SELECT * FROM (SELECT * FROM t), j;\n}\ndo_catchsql_test 10.3 {\n  SELECT * FROM t UNION ALL SELECT * FROM j\n} $err\ndo_catchsql_test 10.4 {\n  SELECT * FROM (SELECT i FROM t UNION ALL SELECT l, m FROM j)\n} $err\ndo_catchsql_test 10.5 {\n  SELECT * FROM (SELECT j FROM t UNION ALL SELECT * FROM j)\n} $err\ndo_catchsql_test 10.6 {\n  SELECT * FROM (SELECT * FROM t UNION ALL SELECT * FROM j)\n} $err\ndo_catchsql_test 10.7 {\n  SELECT * FROM (\n    SELECT * FROM t UNION ALL \n    SELECT l,m,l FROM j UNION ALL\n    SELECT * FROM k\n  )\n} $err\ndo_catchsql_test 10.8 {\n  SELECT * FROM (\n    SELECT * FROM k UNION ALL\n    SELECT * FROM t UNION ALL \n    SELECT l,m,l FROM j \n  )\n} $err\n\n# 2015-02-09 Ticket [2f7170d73bf9abf80339187aa3677dce3dbcd5ca]\n# \"misuse of aggregate\" error if aggregate column from FROM\n# subquery is used in correlated subquery \n#\ndo_execsql_test 11.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(w INT, x INT);\n  INSERT INTO t1(w,x)\n   VALUES(1,10),(2,20),(3,30),\n         (2,21),(3,31),\n         (3,32);\n  CREATE INDEX t1wx ON t1(w,x);\n\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(w INT, y VARCHAR(8));\n  INSERT INTO t2(w,y) VALUES(1,'one'),(2,'two'),(3,'three'),(4,'four');\n  CREATE INDEX t2wy ON t2(w,y);\n\n  SELECT cnt, xyz, (SELECT y FROM t2 WHERE w=cnt), '|'\n    FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)\n   ORDER BY cnt, xyz;\n} {1 1 one | 2 2 two | 3 3 three |}\ndo_execsql_test 11.2 {\n  SELECT cnt, xyz, lower((SELECT y FROM t2 WHERE w=cnt)), '|'\n    FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)\n   ORDER BY cnt, xyz;\n} {1 1 one | 2 2 two | 3 3 three |}\ndo_execsql_test 11.3 {\n  SELECT cnt, xyz, '|'\n    FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)\n   WHERE (SELECT y FROM t2 WHERE w=cnt)!='two'\n   ORDER BY cnt, xyz;\n} {1 1 | 3 3 |}\ndo_execsql_test 11.4 {\n  SELECT cnt, xyz, '|'\n    FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)\n   ORDER BY lower((SELECT y FROM t2 WHERE w=cnt));\n} {1 1 | 3 3 | 2 2 |}\ndo_execsql_test 11.5 {\n  SELECT cnt, xyz, \n         CASE WHEN (SELECT y FROM t2 WHERE w=cnt)=='two'\n              THEN 'aaa' ELSE 'bbb'\n          END, '|'\n    FROM (SELECT count(*) AS cnt, w AS xyz FROM t1 GROUP BY 2)\n   ORDER BY +cnt;\n} {1 1 bbb | 2 2 aaa | 3 3 bbb |}\n\ndo_execsql_test 11.100 {\n  DROP TABLE t1;\n  DROP TABLE t2;\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(y, z);\n  SELECT ( SELECT y FROM t2 WHERE z = cnt )\n    FROM ( SELECT count(*) AS cnt FROM t1 );\n} {{}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select7.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing compute SELECT statements and nested\n# views.\n#\n# $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix select7\n\nifcapable compound {\n\n# A 3-way INTERSECT.  Ticket #875\nifcapable tempdb {\n  do_test select7-1.1 {\n    execsql {\n      create temp table t1(x);\n      insert into t1 values('amx');\n      insert into t1 values('anx');\n      insert into t1 values('amy');\n      insert into t1 values('bmy');\n      select * from t1 where x like 'a__'\n        intersect select * from t1 where x like '_m_'\n        intersect select * from t1 where x like '__x';\n    }\n  } {amx}\n}\n\n\n# Nested views do not handle * properly.  Ticket #826.\n#\nifcapable view {\ndo_test select7-2.1 {\n  execsql {\n    CREATE TABLE x(id integer primary key, a TEXT NULL);\n    INSERT INTO x (a) VALUES ('first');\n    CREATE TABLE tempx(id integer primary key, a TEXT NULL);\n    INSERT INTO tempx (a) VALUES ('t-first');\n    CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id;\n    CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id;\n    CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b;\n    SELECT * FROM tv2;\n  }\n} {1 1}\n} ;# ifcapable view\n\n} ;# ifcapable compound\n\n# Do not allow GROUP BY without an aggregate. Ticket #1039.\n#\n# Change: force any query with a GROUP BY clause to be processed as\n# an aggregate query, whether it contains aggregates or not.\n#\nifcapable subquery {\n  # do_test select7-3.1 {\n  #   catchsql {\n  #     SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name\n  #   }\n  # } {1 {GROUP BY may only be used on aggregate queries}}\n  do_test select7-3.1 {\n    catchsql {\n      SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name\n    }\n  } [list 0 [execsql {SELECT * FROM sqlite_master ORDER BY name}]]\n}\n\n# Ticket #2018 - Make sure names are resolved correctly on all\n# SELECT statements of a compound subquery.\n#\nifcapable {subquery && compound} {\n  do_test select7-4.1 {\n    execsql {\n      CREATE TABLE IF NOT EXISTS photo(pk integer primary key, x);\n      CREATE TABLE IF NOT EXISTS tag(pk integer primary key, fk int, name);\n    \n      SELECT P.pk from PHOTO P WHERE NOT EXISTS ( \n           SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk \n           EXCEPT \n           SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'\n      );\n    }\n  } {}\n  do_test select7-4.2 {\n    execsql {\n      INSERT INTO photo VALUES(1,1);\n      INSERT INTO photo VALUES(2,2);\n      INSERT INTO photo VALUES(3,3);\n      INSERT INTO tag VALUES(11,1,'one');\n      INSERT INTO tag VALUES(12,1,'two');\n      INSERT INTO tag VALUES(21,1,'one-b');\n      SELECT P.pk from PHOTO P WHERE NOT EXISTS ( \n           SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk \n           EXCEPT \n           SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'\n      );\n    }\n  } {2 3}\n}\n\n# ticket #2347\n#\nifcapable {subquery && compound} {\n  do_test select7-5.1 {\n    catchsql {\n      CREATE TABLE t2(a,b);\n      SELECT 5 IN (SELECT a,b FROM t2);\n    }\n  } {1 {sub-select returns 2 columns - expected 1}}\n  do_test select7-5.2 {\n    catchsql {\n      SELECT 5 IN (SELECT * FROM t2);\n    }\n  } {1 {sub-select returns 2 columns - expected 1}}\n  do_test select7-5.3 {\n    catchsql {\n      SELECT 5 IN (SELECT a,b FROM t2 UNION SELECT b,a FROM t2);\n    }\n  } {1 {sub-select returns 2 columns - expected 1}}\n  do_test select7-5.4 {\n    catchsql {\n      SELECT 5 IN (SELECT * FROM t2 UNION SELECT * FROM t2);\n    }\n  } {1 {sub-select returns 2 columns - expected 1}}\n}\n\n# Verify that an error occurs if you have too many terms on a\n# compound select statement.\n#\nif {[clang_sanitize_address]==0} {\n  ifcapable compound {\n    if {$SQLITE_MAX_COMPOUND_SELECT>0} {\n      set sql {SELECT 0}\n      set result 0\n        for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {\n          append sql \" UNION ALL SELECT $i\"\n            lappend result $i\n        }\n      do_test select7-6.1 {\n        catchsql $sql\n      } [list 0 $result]\n      append sql { UNION ALL SELECT 99999999}\n      do_test select7-6.2 {\n        catchsql $sql\n      } {1 {too many terms in compound SELECT}}\n    }\n  }\n}\n\n# This block of tests verifies that bug aa92c76cd4 is fixed.\n#\ndo_test select7-7.1 {\n  execsql {\n    CREATE TABLE t3(a REAL);\n    INSERT INTO t3 VALUES(44.0);\n    INSERT INTO t3 VALUES(56.0);\n  }\n} {}\ndo_test select7-7.2 {\n  execsql {\n    pragma vdbe_trace = 0;\n    SELECT (CASE WHEN a=0 THEN 0 ELSE (a + 25) / 50 END) AS categ, count(*)\n    FROM t3 GROUP BY categ\n  }\n} {1.38 1 1.62 1}\ndo_test select7-7.3 {\n  execsql {\n    CREATE TABLE t4(a REAL);\n    INSERT INTO t4 VALUES( 2.0 );\n    INSERT INTO t4 VALUES( 3.0 );\n  }\n} {}\ndo_test select7-7.4 {\n  execsql {\n    SELECT (CASE WHEN a=0 THEN 'zero' ELSE a/2 END) AS t FROM t4 GROUP BY t;\n  }\n} {1.0 1.5}\ndo_test select7-7.5 {\n  execsql { SELECT a=0, typeof(a) FROM t4 }\n} {0 real 0 real}\ndo_test select7-7.6 {\n  execsql { SELECT a=0, typeof(a) FROM t4 GROUP BY a }\n} {0 real 0 real}\n\ndo_test select7-7.7 {\n  execsql {\n    CREATE TABLE t5(a TEXT, b INT);\n    INSERT INTO t5 VALUES(123, 456);\n    SELECT typeof(a), a FROM t5 GROUP BY a HAVING a<b;\n  }\n} {text 123}\n\ndo_execsql_test 8.0 { \n  CREATE TABLE t01(x, y);\n  CREATE TABLE t02(x, y);\n}\n\ndo_catchsql_test 8.1 {\n  SELECT * FROM (\n    SELECT * FROM t01 UNION SELECT x FROM t02\n  ) WHERE y=1\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\n\ndo_catchsql_test 8.2 {\n  CREATE VIEW v0 as SELECT x, y FROM t01 UNION SELECT x FROM t02;\n  EXPLAIN QUERY PLAN SELECT * FROM v0 WHERE x='0' OR y;\n} {1 {SELECTs to the left and right of UNION do not have the same number of result columns}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select8.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The focus of this file is testing that LIMIT and OFFSET work for\n# unusual combinations SELECT statements.\n#\n# $Id: select8.test,v 1.1 2008/01/12 12:48:09 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nexecsql {\n  CREATE TABLE songs(songid, artist, timesplayed);\n  INSERT INTO songs VALUES(1,'one',1);\n  INSERT INTO songs VALUES(2,'one',2);\n  INSERT INTO songs VALUES(3,'two',3);\n  INSERT INTO songs VALUES(4,'three',5);\n  INSERT INTO songs VALUES(5,'one',7);\n  INSERT INTO songs VALUES(6,'two',11);\n}\nset result [execsql {\n  SELECT DISTINCT artist,sum(timesplayed) AS total      \n  FROM songs      \n  GROUP BY LOWER(artist)      \n}]\ndo_test select8-1.1 {\n  execsql {\n    SELECT DISTINCT artist,sum(timesplayed) AS total      \n    FROM songs      \n    GROUP BY LOWER(artist)      \n    LIMIT 1 OFFSET 1\n  }\n} [lrange $result 2 3]\ndo_test select8-1.2 {\n  execsql {\n    SELECT DISTINCT artist,sum(timesplayed) AS total      \n    FROM songs      \n    GROUP BY LOWER(artist)      \n    LIMIT 2 OFFSET 1\n  }\n} [lrange $result 2 5]\ndo_test select8-1.3 {\n  execsql {\n    SELECT DISTINCT artist,sum(timesplayed) AS total      \n    FROM songs      \n    GROUP BY LOWER(artist)      \n    LIMIT -1 OFFSET 2\n  }\n} [lrange $result 4 end]\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/select9.test",
    "content": "# 2008 June 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# $Id: select9.test,v 1.4 2008/07/01 14:39:35 danielk1977 Exp $\n\n# The tests in this file are focused on test compound SELECT statements \n# that have any or all of an ORDER BY, LIMIT or OFFSET clauses. As of\n# version 3.6.0, SQLite contains code to use SQL indexes where possible \n# to optimize such statements.\n#\n\n# TODO Points:\n#\n#   * Are there any \"column affinity\" issues to consider?\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#-------------------------------------------------------------------------\n# test_compound_select TESTNAME SELECT RESULT\n#\n#   This command is used to run multiple LIMIT/OFFSET test cases based on \n#   the single SELECT statement passed as the second argument. The SELECT\n#   statement may not contain a LIMIT or OFFSET clause. This proc tests\n#   many statements of the form:\n#    \n#     \"$SELECT limit $X offset $Y\"\n#    \n#   for various values of $X and $Y.\n#    \n#   The third argument, $RESULT, should contain the expected result of\n#   the command [execsql $SELECT].\n#    \n#   The first argument, $TESTNAME, is used as the base test case name to\n#   pass to [do_test] for each individual LIMIT OFFSET test case.\n# \nproc test_compound_select {testname sql result} {\n\n  set nCol 1\n  db eval $sql A {\n    set nCol [llength $A(*)]\n    break\n  }\n  set nRow [expr {[llength $result] / $nCol}]\n\n  set ::compound_sql $sql\n  do_test $testname { \n    execsql $::compound_sql\n  } $result\n#return\n\n  set iLimitIncr  1\n  set iOffsetIncr 1\n  if {[info exists ::G(isquick)] && $::G(isquick) && $nRow>=5} {\n    set iOffsetIncr [expr $nRow / 5]\n    set iLimitIncr [expr $nRow / 5]\n  }\n\n  set iLimitEnd   [expr $nRow+$iLimitIncr]\n  set iOffsetEnd  [expr $nRow+$iOffsetIncr]\n\n  for {set iOffset 0} {$iOffset < $iOffsetEnd} {incr iOffset $iOffsetIncr} {\n    for {set iLimit 0} {$iLimit < $iLimitEnd} {incr iLimit} {\n  \n      set ::compound_sql \"$sql LIMIT $iLimit\"\n      if {$iOffset != 0} {\n        append ::compound_sql \" OFFSET $iOffset\"\n      }\n  \n      set iStart [expr {$iOffset*$nCol}]\n      set iEnd [expr {($iOffset*$nCol) + ($iLimit*$nCol) -1}]\n  \n      do_test $testname.limit=$iLimit.offset=$iOffset { \n        execsql $::compound_sql\n      } [lrange $result $iStart $iEnd]\n    }\n  }\n}\n\n#-------------------------------------------------------------------------\n# test_compound_select_flippable TESTNAME SELECT RESULT\n#\n#   This command is for testing statements of the form:\n#\n#     <simple select 1> <compound op> <simple select 2> ORDER BY <order by>\n#\n#   where each <simple select> is a simple (non-compound) select statement\n#   and <compound op> is one of \"INTERSECT\", \"UNION ALL\" or \"UNION\".\n#\n#   This proc calls [test_compound_select] twice, once with the select\n#   statement as it is passed to this command, and once with the positions\n#   of <select statement 1> and <select statement 2> exchanged.\n#\nproc test_compound_select_flippable {testname sql result} {\n  test_compound_select $testname $sql $result\n\n  set select [string trim $sql]\n  set RE {(.*)(UNION ALL|INTERSECT|UNION)(.*)(ORDER BY.*)}\n  set rc [regexp $RE $select -> s1 op s2 order_by]\n  if {!$rc} {error \"Statement is unflippable: $select\"}\n\n  set flipsql \"$s2 $op $s1 $order_by\"\n  test_compound_select $testname.flipped $flipsql $result\n}\n\n#############################################################################\n# Begin tests.\n#\n\n# Create and populate a sample database.\n#\ndo_test select9-1.0 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(d, e, f);\n    BEGIN;\n      INSERT INTO t1 VALUES(1,  'one',   'I');\n      INSERT INTO t1 VALUES(3,  NULL,    NULL);\n      INSERT INTO t1 VALUES(5,  'five',  'V');\n      INSERT INTO t1 VALUES(7,  'seven', 'VII');\n      INSERT INTO t1 VALUES(9,  NULL,    NULL);\n      INSERT INTO t1 VALUES(2,  'two',   'II');\n      INSERT INTO t1 VALUES(4,  'four',  'IV');\n      INSERT INTO t1 VALUES(6,  NULL,    NULL);\n      INSERT INTO t1 VALUES(8,  'eight', 'VIII');\n      INSERT INTO t1 VALUES(10, 'ten',   'X');\n\n      INSERT INTO t2 VALUES(1,  'two',      'IV');\n      INSERT INTO t2 VALUES(2,  'four',     'VIII');\n      INSERT INTO t2 VALUES(3,  NULL,       NULL);\n      INSERT INTO t2 VALUES(4,  'eight',    'XVI');\n      INSERT INTO t2 VALUES(5,  'ten',      'XX');\n      INSERT INTO t2 VALUES(6,  NULL,       NULL);\n      INSERT INTO t2 VALUES(7,  'fourteen', 'XXVIII');\n      INSERT INTO t2 VALUES(8,  'sixteen',  'XXXII');\n      INSERT INTO t2 VALUES(9,  NULL,       NULL);\n      INSERT INTO t2 VALUES(10, 'twenty',   'XL');\n\n    COMMIT;\n  }\n} {}\n\n# Each iteration of this loop runs the same tests with a different set\n# of indexes present within the database schema. The data returned by\n# the compound SELECT statements in the test cases should be the same \n# in each case.\n#\nset iOuterLoop 1\nforeach indexes [list {\n  /* Do not create any indexes. */\n} {\n  CREATE INDEX i1 ON t1(a)\n} {\n  CREATE INDEX i2 ON t1(b)\n} {\n  CREATE INDEX i3 ON t2(d)\n} {\n  CREATE INDEX i4 ON t2(e)\n}] {\n\n  do_test select9-1.$iOuterLoop.1 {\n    execsql $indexes\n  } {}\n\n  # Test some 2-way UNION ALL queries. No WHERE clauses.\n  #\n  test_compound_select select9-1.$iOuterLoop.2 {\n    SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 \n  } {1 one 3 {} 5 five 7 seven 9 {} 2 two 4 four 6 {} 8 eight 10 ten 1 two 2 four 3 {} 4 eight 5 ten 6 {} 7 fourteen 8 sixteen 9 {} 10 twenty}\n  test_compound_select select9-1.$iOuterLoop.3 {\n    SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 1 \n  } {1 one 1 two 2 two 2 four 3 {} 3 {} 4 four 4 eight 5 five 5 ten 6 {} 6 {} 7 seven 7 fourteen 8 eight 8 sixteen 9 {} 9 {} 10 ten 10 twenty}\n  test_compound_select select9-1.$iOuterLoop.4 {\n    SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 2 \n  } {3 {} 9 {} 6 {} 3 {} 6 {} 9 {} 8 eight 4 eight 5 five 4 four 2 four 7 fourteen 1 one 7 seven 8 sixteen 10 ten 5 ten 10 twenty 2 two 1 two}\n  test_compound_select_flippable select9-1.$iOuterLoop.5 {\n    SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 1, 2\n  } {1 one 1 two 2 four 2 two 3 {} 3 {} 4 eight 4 four 5 five 5 ten 6 {} 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 9 {} 10 ten 10 twenty}\n  test_compound_select_flippable select9-1.$iOuterLoop.6 {\n    SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY 2, 1\n  } {3 {} 3 {} 6 {} 6 {} 9 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}\n\n  # Test some 2-way UNION queries.\n  #\n  test_compound_select select9-1.$iOuterLoop.7 {\n    SELECT a, b FROM t1 UNION SELECT d, e FROM t2 \n  } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}\n\n  test_compound_select select9-1.$iOuterLoop.8 {\n    SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 1 \n  } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}\n\n  test_compound_select select9-1.$iOuterLoop.9 {\n    SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 2 \n  } {3 {} 6 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}\n\n  test_compound_select_flippable select9-1.$iOuterLoop.10 {\n    SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 1, 2\n  } {1 one 1 two 2 four 2 two 3 {} 4 eight 4 four 5 five 5 ten 6 {} 7 fourteen 7 seven 8 eight 8 sixteen 9 {} 10 ten 10 twenty}\n\n  test_compound_select_flippable select9-1.$iOuterLoop.11 {\n    SELECT a, b FROM t1 UNION SELECT d, e FROM t2 ORDER BY 2, 1\n  } {3 {} 6 {} 9 {} 4 eight 8 eight 5 five 2 four 4 four 7 fourteen 1 one 7 seven 8 sixteen 5 ten 10 ten 10 twenty 1 two 2 two}\n\n  # Test some 2-way INTERSECT queries.\n  #\n  test_compound_select select9-1.$iOuterLoop.11 {\n    SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 \n  } {3 {} 6 {} 9 {}}\n  test_compound_select_flippable select9-1.$iOuterLoop.12 {\n    SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 1\n  } {3 {} 6 {} 9 {}}\n  test_compound_select select9-1.$iOuterLoop.13 {\n    SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 2\n  } {3 {} 6 {} 9 {}}\n  test_compound_select_flippable select9-1.$iOuterLoop.14 {\n    SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 2, 1\n  } {3 {} 6 {} 9 {}}\n  test_compound_select_flippable select9-1.$iOuterLoop.15 {\n    SELECT a, b FROM t1 INTERSECT SELECT d, e FROM t2 ORDER BY 1, 2\n  } {3 {} 6 {} 9 {}}\n\n  # Test some 2-way EXCEPT queries.\n  #\n  test_compound_select select9-1.$iOuterLoop.16 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 \n  } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}\n\n  test_compound_select select9-1.$iOuterLoop.17 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 1 \n  } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}\n\n  test_compound_select select9-1.$iOuterLoop.18 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 2 \n  } {8 eight 5 five 4 four 1 one 7 seven 10 ten 2 two}\n\n  test_compound_select select9-1.$iOuterLoop.19 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 1, 2\n  } {1 one 2 two 4 four 5 five 7 seven 8 eight 10 ten}\n\n  test_compound_select select9-1.$iOuterLoop.20 {\n    SELECT a, b FROM t1 EXCEPT SELECT d, e FROM t2 ORDER BY 2, 1\n  } {8 eight 5 five 4 four 1 one 7 seven 10 ten 2 two}\n\n  incr iOuterLoop\n}\n\ndo_test select9-2.0 {\n  execsql {\n    DROP INDEX i1;\n    DROP INDEX i2;\n    DROP INDEX i3;\n    DROP INDEX i4;\n  }\n} {}\n\nproc reverse {lhs rhs} {\n  return [string compare $rhs $lhs]\n}\ndb collate reverse reverse\n\n# This loop is similar to the previous one (test cases select9-1.*) \n# except that the simple select statements have WHERE clauses attached\n# to them. Sometimes the WHERE clause may be satisfied using the same\n# index used for ORDER BY, sometimes not.\n#\nset iOuterLoop 1\nforeach indexes [list {\n  /* Do not create any indexes. */\n} {\n  CREATE INDEX i1 ON t1(a)\n} {\n  DROP INDEX i1;\n  CREATE INDEX i1 ON t1(b, a)\n} {\n  CREATE INDEX i2 ON t2(d DESC, e COLLATE REVERSE ASC);\n} {\n  CREATE INDEX i3 ON t1(a DESC);\n}] {\n  do_test select9-2.$iOuterLoop.1 {\n    execsql $indexes\n  } {}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.2 {\n    SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5 ORDER BY 1\n  } {1 one I 2 two II 3 {} {} 4 four IV 5 ten XX 6 {} {} 7 fourteen XXVIII 8 sixteen XXXII 9 {} {} 10 twenty XL}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.2 {\n    SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5 ORDER BY 2, 1\n  } {3 {} {} 6 {} {} 9 {} {} 4 four IV 7 fourteen XXVIII 1 one I 8 sixteen XXXII 5 ten XX 10 twenty XL 2 two II}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.3 {\n    SELECT * FROM t1 WHERE a<5 UNION SELECT * FROM t2 WHERE d>=5 \n    ORDER BY 2 COLLATE reverse, 1\n  } {3 {} {} 6 {} {} 9 {} {} 2 two II 10 twenty XL 5 ten XX 8 sixteen XXXII 1 one I 7 fourteen XXVIII 4 four IV}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.4 {\n    SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5 ORDER BY 1\n  } {1 one I 2 two II 3 {} {} 4 four IV 5 ten XX 6 {} {} 7 fourteen XXVIII 8 sixteen XXXII 9 {} {} 10 twenty XL}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.5 {\n    SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5 ORDER BY 2, 1\n  } {3 {} {} 6 {} {} 9 {} {} 4 four IV 7 fourteen XXVIII 1 one I 8 sixteen XXXII 5 ten XX 10 twenty XL 2 two II}\n\n  test_compound_select_flippable select9-2.$iOuterLoop.6 {\n    SELECT * FROM t1 WHERE a<5 UNION ALL SELECT * FROM t2 WHERE d>=5 \n    ORDER BY 2 COLLATE reverse, 1\n  } {3 {} {} 6 {} {} 9 {} {} 2 two II 10 twenty XL 5 ten XX 8 sixteen XXXII 1 one I 7 fourteen XXVIII 4 four IV}\n\n  test_compound_select select9-2.$iOuterLoop.4 {\n    SELECT a FROM t1 WHERE a<8 EXCEPT SELECT d FROM t2 WHERE d<=3 ORDER BY 1\n  } {4 5 6 7}\n\n  test_compound_select select9-2.$iOuterLoop.4 {\n    SELECT a FROM t1 WHERE a<8 INTERSECT SELECT d FROM t2 WHERE d<=3 ORDER BY 1\n  } {1 2 3}\n\n}\n\ndo_test select9-2.X {\n  execsql {\n    DROP INDEX i1;\n    DROP INDEX i2;\n    DROP INDEX i3;\n  }\n} {}\n\n# This procedure executes the SQL.  Then it checks the generated program\n# for the SQL and appends a \"nosort\" to the result if the program contains the\n# SortCallback opcode.  If the program does not contain the SortCallback\n# opcode it appends \"sort\"\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# If the right indexes exist, the following query:\n#\n#     SELECT t1.a FROM t1 UNION ALL SELECT t2.d FROM t2 ORDER BY 1\n#\n# can use indexes to run without doing a in-memory sort operation.\n# This block of tests (select9-3.*) is used to check if the same \n# is possible with:\n#\n#     CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2\n#     SELECT a FROM v1 ORDER BY 1\n#\n# It turns out that it is.\n#\ndo_test select9-3.1 {\n  cksort { SELECT a FROM t1 ORDER BY 1 }\n} {1 2 3 4 5 6 7 8 9 10 sort}\ndo_test select9-3.2 {\n  execsql { CREATE INDEX i1 ON t1(a) }\n  cksort { SELECT a FROM t1 ORDER BY 1 }\n} {1 2 3 4 5 6 7 8 9 10 nosort}\ndo_test select9-3.3 {\n  cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }\n} {1 1 2 2 3 sort}\ndo_test select9-3.4 {\n  execsql { CREATE INDEX i2 ON t2(d) }\n  cksort { SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 5 }\n} {1 1 2 2 3 nosort}\ndo_test select9-3.5 {\n  execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION ALL SELECT d FROM t2 }\n  cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }\n} {1 1 2 2 3 nosort}\ndo_test select9-3.X {\n  execsql {\n    DROP INDEX i1;\n    DROP INDEX i2;\n    DROP VIEW v1;\n  }\n} {}\n\n# This block of tests is the same as the preceding one, except that\n# \"UNION\" is tested instead of \"UNION ALL\".\n#\ndo_test select9-4.1 {\n  cksort { SELECT a FROM t1 ORDER BY 1 }\n} {1 2 3 4 5 6 7 8 9 10 sort}\ndo_test select9-4.2 {\n  execsql { CREATE INDEX i1 ON t1(a) }\n  cksort { SELECT a FROM t1 ORDER BY 1 }\n} {1 2 3 4 5 6 7 8 9 10 nosort}\ndo_test select9-4.3 {\n  cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }\n} {1 2 3 4 5 sort}\ndo_test select9-4.4 {\n  execsql { CREATE INDEX i2 ON t2(d) }\n  cksort { SELECT a FROM t1 UNION SELECT d FROM t2 ORDER BY 1 LIMIT 5 }\n} {1 2 3 4 5 nosort}\ndo_test select9-4.5 {\n  execsql { CREATE VIEW v1 AS SELECT a FROM t1 UNION SELECT d FROM t2 }\n  cksort { SELECT a FROM v1 ORDER BY 1 LIMIT 5 }\n} {1 2 3 4 5 sort}\ndo_test select9-4.X {\n  execsql {\n    DROP INDEX i1;\n    DROP INDEX i2;\n    DROP VIEW v1;\n  }\n} {}\n\n# Testing to make sure that queries involving a view of a compound select\n# are planned efficiently.  This detects a problem reported on the mailing\n# list on 2012-04-26.  See\n#\n#  http://www.mail-archive.com/sqlite-users%40sqlite.org/msg69746.html\n#\n# For additional information.\n#\ndo_test select9-5.1 {\n  db eval {\n    CREATE TABLE t51(x, y);\n    CREATE TABLE t52(x, y);\n    CREATE VIEW v5 as\n       SELECT x, y FROM t51\n       UNION ALL\n       SELECT x, y FROM t52;\n    CREATE INDEX t51x ON t51(x);\n    CREATE INDEX t52x ON t52(x);\n    EXPLAIN QUERY PLAN\n       SELECT * FROM v5 WHERE x='12345' ORDER BY y;\n  }\n} {~/SCAN TABLE/}  ;# Uses indices with \"*\"\ndo_test select9-5.2 {\n  db eval {\n    EXPLAIN QUERY PLAN\n       SELECT x, y FROM v5 WHERE x='12345' ORDER BY y;\n  }\n} {~/SCAN TABLE/}  ;# Uses indices with \"x, y\"\ndo_test select9-5.3 {\n  db eval {\n    EXPLAIN QUERY PLAN\n       SELECT x, y FROM v5 WHERE +x='12345' ORDER BY y;\n  }\n} {/SCAN TABLE/}   ;# Full table scan if the \"+x\" prevents index usage.\n\n# 2013-07-09:  Ticket [490a4b7235624298]: \n# \"WHERE 0\" on the first element of a UNION causes an assertion fault\n#\ndo_execsql_test select9-6.1 {\n  CREATE TABLE t61(a);\n  CREATE TABLE t62(b);\n  INSERT INTO t61 VALUES(111);\n  INSERT INTO t62 VALUES(222);\n  SELECT a FROM t61 WHERE 0 UNION SELECT b FROM t62;\n} {222}\ndo_execsql_test select9-6.2 {\n  SELECT a FROM t61 WHERE 0 UNION ALL SELECT b FROM t62;\n} {222}\ndo_execsql_test select9-6.3 {\n  SELECT a FROM t61 UNION SELECT b FROM t62 WHERE 0;\n} {111}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectA.test",
    "content": "# 2008 June 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The focus of this file is testing the compound-SELECT merge\n# optimization.  Or, in other words, making sure that all\n# possible combinations of UNION, UNION ALL, EXCEPT, and\n# INTERSECT work together with an ORDER BY clause (with or w/o\n# explicit sort order and explicit collating secquites) and\n# with and without optional LIMIT and OFFSET clauses.\n#\n# $Id: selectA.test,v 1.6 2008/08/21 14:24:29 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix selectA\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test selectA-1.0 {\n  execsql {\n    CREATE TABLE t1(a,b,c COLLATE NOCASE);\n    INSERT INTO t1 VALUES(1,'a','a');\n    INSERT INTO t1 VALUES(9.9, 'b', 'B');\n    INSERT INTO t1 VALUES(NULL, 'C', 'c');\n    INSERT INTO t1 VALUES('hello', 'd', 'D');\n    INSERT INTO t1 VALUES(x'616263', 'e', 'e');\n    SELECT * FROM t1;\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e}\ndo_test selectA-1.1 {\n  execsql {\n    CREATE TABLE t2(x,y,z COLLATE NOCASE);\n    INSERT INTO t2 VALUES(NULL,'U','u');\n    INSERT INTO t2 VALUES('mad', 'Z', 'z');\n    INSERT INTO t2 VALUES(x'68617265', 'm', 'M');\n    INSERT INTO t2 VALUES(5.2e6, 'X', 'x');\n    INSERT INTO t2 VALUES(-23, 'Y', 'y');\n    SELECT * FROM t2;\n  }\n} {{} U u mad Z z hare m M 5200000.0 X x -23 Y y}\ndo_test selectA-1.2 {\n  execsql {\n    CREATE TABLE t3(a,b,c COLLATE NOCASE);\n    INSERT INTO t3 SELECT * FROM t1;\n    INSERT INTO t3 SELECT * FROM t2;\n    INSERT INTO t3 SELECT * FROM t1;\n    INSERT INTO t3 SELECT * FROM t2;\n    INSERT INTO t3 SELECT * FROM t1;\n    INSERT INTO t3 SELECT * FROM t2;\n    SELECT count(*) FROM t3;\n  }\n} {30}\n\ndo_test selectA-2.1 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.1.1 {   # Ticket #3314\n  execsql {\n    SELECT t1.a, t1.b, t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.1.2 {   # Ticket #3314\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY t1.a, t1.b, t1.c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.2 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.3 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.4 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.5 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.6 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.7 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.8 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.9 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.10 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.11 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.12 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.13 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.14 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.15 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.16 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.17 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.18 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.19 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.20 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.21 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.22 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.23 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.24 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.25 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.26 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.27 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.28 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.29 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.30 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.31 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.32 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.33 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.34 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.35 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY y COLLATE NOCASE,x,z\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.36 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.37 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.38 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.39 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.40 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY z COLLATE BINARY DESC,x,y\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.41 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-2.42 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-2.43 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-2.44 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-2.45 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-2.46 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-2.47 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-2.48 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-2.49 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-2.50 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-2.51 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-2.52 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-2.53 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY b, a DESC\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-2.54 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY b\n  }\n} {hello d D abc e e}\ndo_test selectA-2.55 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY b DESC, c\n  }\n} {abc e e hello d D}\ndo_test selectA-2.56 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY b, c DESC, a\n  }\n} {hello d D abc e e}\ndo_test selectA-2.57 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY b COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.58 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY b\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-2.59 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY c, a DESC\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.60 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY c\n  }\n} {hello d D abc e e}\ndo_test selectA-2.61 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c\n  }\n} {hello d D abc e e}\ndo_test selectA-2.62 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-2.63 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.64 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.65 {\n  execsql {\n    SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.66 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.67 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-2.68 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-2.69 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.70 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.71 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t1\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    INTERSECT SELECT a,b,c FROM t1\n    EXCEPT SELECT x,y,z FROM t2\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT y,x,z FROM t2\n    INTERSECT SELECT a,b,c FROM t1\n    EXCEPT SELECT c,b,a FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-2.72 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.73 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.74 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.75 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.76 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.77 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.78 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.79 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.80 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.81 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.82 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.83 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-2.84 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-2.85 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-2.86 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE,x,z\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.87 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.88 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.89 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-2.90 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.91 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY z COLLATE BINARY DESC,x,y\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-2.92 {\n  execsql {\n    SELECT x,y,z FROM t2\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT c,b,a FROM t1\n    UNION SELECT a,b,c FROM t3\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT c,b,a FROM t1\n    UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-2.93 {\n  execsql {\n    SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));\n  }\n} {A}\ndo_test selectA-2.94 {\n  execsql {\n    SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));\n  }\n} {a}\ndo_test selectA-2.95 {\n  execsql {\n    SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));\n  }\n} {{}}\ndo_test selectA-2.96 {\n  execsql {\n    SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));\n  }\n} {m}\n\n\ndo_test selectA-3.0 {\n  execsql {\n    CREATE UNIQUE INDEX t1a ON t1(a);\n    CREATE UNIQUE INDEX t1b ON t1(b);\n    CREATE UNIQUE INDEX t1c ON t1(c);\n    CREATE UNIQUE INDEX t2x ON t2(x);\n    CREATE UNIQUE INDEX t2y ON t2(y);\n    CREATE UNIQUE INDEX t2z ON t2(z);\n    SELECT name FROM sqlite_master WHERE type='index'\n  }\n} {t1a t1b t1c t2x t2y t2z}\ndo_test selectA-3.1 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.1.1 {  # Ticket #3314\n  execsql {\n    SELECT t1.a,b,t1.c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,t1.b,t1.c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.2 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.3 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.4 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.5 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.6 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.7 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.8 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.9 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.10 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION ALL SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.11 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.12 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.13 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.14 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.15 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.16 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.17 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.18 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.19 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.20 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION ALL SELECT a,b,c FROM t1\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.21 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.22 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.23 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.24 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.25 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.26 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.27 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.28 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.29 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.30 {\n  execsql {\n    SELECT a,b,c FROM t1 UNION SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.31 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.32 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.33 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.34 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.35 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY y COLLATE NOCASE,x,z\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.36 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.37 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.38 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.39 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.40 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t1\n    ORDER BY z COLLATE BINARY DESC,x,y\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.41 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-3.42 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-3.43 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-3.44 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a,b,c\n  }\n} {hello d D abc e e}\ndo_test selectA-3.45 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-3.46 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a,b,c\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-3.47 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-3.48 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-3.49 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-3.50 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a DESC\n  }\n} {abc e e hello d D}\ndo_test selectA-3.51 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-3.52 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY a DESC\n  }\n} {9.9 b B 1 a a {} C c}\ndo_test selectA-3.53 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY b, a DESC\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-3.54 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY b\n  }\n} {hello d D abc e e}\ndo_test selectA-3.55 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY b DESC, c\n  }\n} {abc e e hello d D}\ndo_test selectA-3.56 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY b, c DESC, a\n  }\n} {hello d D abc e e}\ndo_test selectA-3.57 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY b COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.58 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY b\n  }\n} {{} C c 1 a a 9.9 b B}\ndo_test selectA-3.59 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY c, a DESC\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.60 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b>='d'\n    ORDER BY c\n  }\n} {hello d D abc e e}\ndo_test selectA-3.61 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b>='d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY c COLLATE BINARY, b DESC, c, a, b, c, a, b, c\n  }\n} {hello d D abc e e}\ndo_test selectA-3.62 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-3.63 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.64 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.65 {\n  execsql {\n    SELECT a,b,c FROM t3 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.66 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.67 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t3 WHERE b<'d'\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-3.68 {\n  execsql {\n    SELECT a,b,c FROM t1 EXCEPT SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c DESC, a\n  }\n} {abc e e hello d D}\ndo_test selectA-3.69 {\n  execsql {\n    SELECT a,b,c FROM t1 INTERSECT SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c COLLATE NOCASE\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.70 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d' INTERSECT SELECT a,b,c FROM t1\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.71 {\n  execsql {\n    SELECT a,b,c FROM t1 WHERE b<'d'\n    INTERSECT SELECT a,b,c FROM t1\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT b,c,a FROM t3\n    INTERSECT SELECT a,b,c FROM t1\n    EXCEPT SELECT x,y,z FROM t2\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT y,x,z FROM t2\n    INTERSECT SELECT a,b,c FROM t1\n    EXCEPT SELECT c,b,a FROM t3\n    ORDER BY c\n  }\n} {1 a a 9.9 b B {} C c}\ndo_test selectA-3.72 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.73 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.74 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.75 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.76 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE,a,c\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.77 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY b COLLATE NOCASE DESC,a,c\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.78 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.79 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.80 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.81 {\n  execsql {\n    SELECT a,b,c FROM t3 UNION SELECT x,y,z FROM t2\n    ORDER BY c COLLATE BINARY DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.82 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a,b,c\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.83 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a DESC,b,c\n  }\n} {hare m M abc e e mad Z z hello d D 5200000.0 X x 9.9 b B 1 a a -23 Y y {} C c {} U u}\ndo_test selectA-3.84 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY a,c,b\n  }\n} {{} C c {} U u -23 Y y 1 a a 9.9 b B 5200000.0 X x hello d D mad Z z abc e e hare m M}\ndo_test selectA-3.85 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY b,a,c\n  }\n} {{} C c {} U u 5200000.0 X x -23 Y y mad Z z 1 a a 9.9 b B hello d D abc e e hare m M}\ndo_test selectA-3.86 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE,x,z\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.87 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.88 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c,b,a\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.89 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c,a,b\n  }\n} {1 a a 9.9 b B {} C c hello d D abc e e hare m M {} U u 5200000.0 X x -23 Y y mad Z z}\ndo_test selectA-3.90 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY c DESC,a,b\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.91 {\n  execsql {\n    SELECT x,y,z FROM t2 UNION SELECT a,b,c FROM t3\n    ORDER BY z COLLATE BINARY DESC,x,y\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u abc e e {} C c 1 a a hare m M hello d D 9.9 b B}\ndo_test selectA-3.92 {\n  execsql {\n    SELECT x,y,z FROM t2\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT c,b,a FROM t1\n    UNION SELECT a,b,c FROM t3\n    INTERSECT SELECT a,b,c FROM t3\n    EXCEPT SELECT c,b,a FROM t1\n    UNION SELECT a,b,c FROM t3\n    ORDER BY y COLLATE NOCASE DESC,x,z\n  }\n} {mad Z z -23 Y y 5200000.0 X x {} U u hare m M abc e e hello d D {} C c 9.9 b B 1 a a}\ndo_test selectA-3.93 {\n  execsql {\n    SELECT upper((SELECT c FROM t1 UNION SELECT z FROM t2 ORDER BY 1));\n  }\n} {A}\ndo_test selectA-3.94 {\n  execsql {\n    SELECT lower((SELECT c FROM t1 UNION ALL SELECT z FROM t2 ORDER BY 1));\n  }\n} {a}\ndo_test selectA-3.95 {\n  execsql {\n    SELECT lower((SELECT c FROM t1 INTERSECT SELECT z FROM t2 ORDER BY 1));\n  }\n} {{}}\ndo_test selectA-3.96 {\n  execsql {\n    SELECT lower((SELECT z FROM t2 EXCEPT SELECT c FROM t1 ORDER BY 1));\n  }\n} {m}\ndo_test selectA-3.97 {\n  execsql {\n    SELECT upper((SELECT x FROM (\n      SELECT x,y,z FROM t2\n      INTERSECT SELECT a,b,c FROM t3\n      EXCEPT SELECT c,b,a FROM t1\n      UNION SELECT a,b,c FROM t3\n      INTERSECT SELECT a,b,c FROM t3\n      EXCEPT SELECT c,b,a FROM t1\n      UNION SELECT a,b,c FROM t3\n      ORDER BY y COLLATE NOCASE DESC,x,z)))\n  }\n} {MAD}\ndo_execsql_test selectA-3.98 {\n  WITH RECURSIVE\n    xyz(n) AS (\n      SELECT upper((SELECT x FROM (\n        SELECT x,y,z FROM t2\n        INTERSECT SELECT a,b,c FROM t3\n        EXCEPT SELECT c,b,a FROM t1\n        UNION SELECT a,b,c FROM t3\n        INTERSECT SELECT a,b,c FROM t3\n        EXCEPT SELECT c,b,a FROM t1\n        UNION SELECT a,b,c FROM t3\n        ORDER BY y COLLATE NOCASE DESC,x,z)))\n      UNION ALL\n      SELECT n || '+' FROM xyz WHERE length(n)<5\n    )\n  SELECT n FROM xyz ORDER BY +n;\n} {MAD MAD+ MAD++}\n\n#-------------------------------------------------------------------------\n# At one point the following code exposed a temp register reuse problem.\n#\nproc f {args} { return 1 }\ndb func f f\n\ndo_execsql_test 4.1.1 {\n  CREATE TABLE t4(a, b);\n  CREATE TABLE t5(c, d);\n\n  INSERT INTO t5 VALUES(1, 'x');\n  INSERT INTO t5 VALUES(2, 'x');\n  INSERT INTO t4 VALUES(3, 'x');\n  INSERT INTO t4 VALUES(4, 'x');\n\n  CREATE INDEX i1 ON t4(a);\n  CREATE INDEX i2 ON t5(c);\n}\n\ndo_eqp_test 4.1.2 {\n  SELECT c, d FROM t5 \n  UNION ALL\n  SELECT a, b FROM t4 WHERE f()==f()\n  ORDER BY 1,2\n} {\n  1 0 0 {SCAN TABLE t5 USING INDEX i2} \n  1 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n  2 0 0 {SCAN TABLE t4 USING INDEX i1} \n  2 0 0 {USE TEMP B-TREE FOR RIGHT PART OF ORDER BY}\n  0 0 0 {COMPOUND SUBQUERIES 1 AND 2 (UNION ALL)}\n}\n\ndo_execsql_test 4.1.3 {\n  SELECT c, d FROM t5 \n  UNION ALL\n  SELECT a, b FROM t4 WHERE f()==f()\n  ORDER BY 1,2\n} {\n  1 x 2 x 3 x 4 x\n}\n\ndo_execsql_test 4.2.1 {\n  CREATE TABLE t6(a, b);\n  CREATE TABLE t7(c, d);\n\n  INSERT INTO t7 VALUES(2, 9);\n  INSERT INTO t6 VALUES(3, 0);\n  INSERT INTO t6 VALUES(4, 1);\n  INSERT INTO t7 VALUES(5, 6);\n  INSERT INTO t6 VALUES(6, 0);\n  INSERT INTO t7 VALUES(7, 6);\n\n  CREATE INDEX i6 ON t6(a);\n  CREATE INDEX i7 ON t7(c);\n}\n\ndo_execsql_test 4.2.2 {\n  SELECT c, f(d,c,d,c,d) FROM t7\n  UNION ALL\n  SELECT a, b FROM t6 \n  ORDER BY 1,2\n} {/2 . 3 . 4 . 5 . 6 . 7 ./}\n\n\nproc strip_rnd {explain} {\n  regexp -all {sqlite_sq_[0123456789ABCDEF]*} $explain sqlite_sq\n}\n\nproc do_same_test {tn q1 args} {\n  set r2 [strip_rnd [db eval \"EXPLAIN $q1\"]]\n  set i 1\n  foreach q $args {\n    set tst [subst -nocommands {strip_rnd [db eval \"EXPLAIN $q\"]}]\n    uplevel do_test $tn.$i [list $tst] [list $r2]\n    incr i\n  }\n}\n\ndo_execsql_test 5.0 {\n  CREATE TABLE t8(a, b);\n  CREATE TABLE t9(c, d);\n} {}\n\ndo_same_test 5.1 {\n  SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY a;\n} {\n  SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t8.a;\n} {\n  SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY 1;\n} {\n  SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY c;\n} {\n  SELECT a, b FROM t8 INTERSECT SELECT c, d FROM t9 ORDER BY t9.c;\n}\n\ndo_same_test 5.2 {\n  SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY a COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t8.a COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY 1 COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY c COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 UNION SELECT c, d FROM t9 ORDER BY t9.c COLLATE NOCASE\n}\n\ndo_same_test 5.3 {\n  SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY b, c COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY 2, 1 COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, a COLLATE NOCASE\n} {\n  SELECT a, b FROM t8 EXCEPT SELECT * FROM t9 ORDER BY t9.d, c COLLATE NOCASE\n} {\n  SELECT * FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, t8.a COLLATE NOCASE\n}\n\ndo_catchsql_test 5.4 {\n  SELECT * FROM t8 UNION SELECT * FROM t9 ORDER BY a+b COLLATE NOCASE\n} {1 {1st ORDER BY term does not match any column in the result set}}\n\ndo_execsql_test 6.1 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t1(a INTEGER);\n  CREATE TABLE t2(b TEXT);\n  INSERT INTO t2(b) VALUES('12345');\n  SELECT * FROM (SELECT a FROM t1 UNION SELECT b FROM t2) WHERE a=a;\n} {12345}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectB.test",
    "content": "# 2008 June 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# $Id: selectB.test,v 1.10 2009/04/02 16:59:47 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nproc test_transform {testname sql1 sql2 results} {\n  set ::vdbe1 [list]\n  set ::vdbe2 [list]\n  db eval \"explain $sql1\" { lappend ::vdbe1 $opcode }\n  db eval \"explain $sql2\" { lappend ::vdbe2 $opcode }\n\n  do_test $testname.transform {\n    set ::vdbe1\n  } $::vdbe2\n\n  set ::sql1 $sql1\n  do_test $testname.sql1 {\n    execsql $::sql1\n  } $results\n\n  set ::sql2 $sql2\n  do_test $testname.sql2 {\n    execsql $::sql2\n  } $results\n}\n\ndo_test selectB-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(d, e, f);\n\n    INSERT INTO t1 VALUES( 2,  4,  6);\n    INSERT INTO t1 VALUES( 8, 10, 12);\n    INSERT INTO t1 VALUES(14, 16, 18);\n\n    INSERT INTO t2 VALUES(3,   6,  9);\n    INSERT INTO t2 VALUES(12, 15, 18);\n    INSERT INTO t2 VALUES(21, 24, 27);\n  }\n} {}\n\nfor {set ii 1} {$ii <= 2} {incr ii} {\n\n  if {$ii == 2} {\n    do_test selectB-2.1 {\n      execsql {\n        CREATE INDEX i1 ON t1(a);\n        CREATE INDEX i2 ON t2(d);\n      }\n    } {}\n  }\n\n  test_transform selectB-$ii.2 {\n    SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2\n  } {2 8 14 3 12 21}\n  \n  test_transform selectB-$ii.3 {\n    SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1\n  } {2 3 8 12 14 21}\n  \n  test_transform selectB-$ii.4 {\n    SELECT * FROM \n      (SELECT a FROM t1 UNION ALL SELECT d FROM t2) \n    WHERE a>10 ORDER BY 1\n  } {\n    SELECT a FROM t1 WHERE a>10 UNION ALL SELECT d FROM t2 WHERE d>10 ORDER BY 1\n  } {12 14 21}\n  \n  test_transform selectB-$ii.5 {\n    SELECT * FROM \n      (SELECT a FROM t1 UNION ALL SELECT d FROM t2) \n    WHERE a>10 ORDER BY a\n  } {\n    SELECT a FROM t1 WHERE a>10 \n      UNION ALL \n    SELECT d FROM t2 WHERE d>10 \n    ORDER BY a\n  } {12 14 21}\n  \n  test_transform selectB-$ii.6 {\n    SELECT * FROM \n      (SELECT a FROM t1 UNION ALL SELECT d FROM t2 WHERE d > 12) \n    WHERE a>10 ORDER BY a\n  } {\n    SELECT a FROM t1 WHERE a>10\n      UNION ALL \n    SELECT d FROM t2 WHERE d>12 AND d>10\n    ORDER BY a\n  } {14 21}\n  \n  test_transform selectB-$ii.7 {\n    SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1 \n    LIMIT 2\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 2\n  } {2 3}\n  \n  test_transform selectB-$ii.8 {\n    SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2) ORDER BY 1 \n    LIMIT 2 OFFSET 3\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 LIMIT 2 OFFSET 3\n  } {12 14}\n\n  test_transform selectB-$ii.9 {\n    SELECT * FROM (\n      SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1\n    ) \n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1\n  } {2 8 14 3 12 21 6 12 18}\n  \n  test_transform selectB-$ii.10 {\n    SELECT * FROM (\n      SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1\n    ) ORDER BY 1\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1\n    ORDER BY 1\n  } {2 3 6 8 12 12 14 18 21}\n  \n  test_transform selectB-$ii.11 {\n    SELECT * FROM (\n      SELECT a FROM t1 UNION ALL SELECT d FROM t2 UNION ALL SELECT c FROM t1\n    ) WHERE a>=10 ORDER BY 1 LIMIT 3\n  } {\n    SELECT a FROM t1 WHERE a>=10 UNION ALL SELECT d FROM t2 WHERE d>=10\n    UNION ALL SELECT c FROM t1 WHERE c>=10\n    ORDER BY 1 LIMIT 3\n  } {12 12 14}\n\n  test_transform selectB-$ii.12 {\n    SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 2)\n  } {\n    SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 2\n  } {2 8}\n\n  # An ORDER BY in a compound subqueries defeats flattening.  Ticket #3773\n  # test_transform selectB-$ii.13 {\n  #   SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a ASC)\n  # } {\n  #   SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 ASC\n  # } {2 3 8 12 14 21}\n  # \n  # test_transform selectB-$ii.14 {\n  #  SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a DESC)\n  # } {\n  #  SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 DESC\n  # } {21 14 12 8 3 2}\n  #\n  # test_transform selectB-$ii.14 {\n  #   SELECT * FROM (\n  #     SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY a DESC\n  #   ) LIMIT 2 OFFSET 2\n  # } {\n  #   SELECT a FROM t1 UNION ALL SELECT d FROM t2 ORDER BY 1 DESC\n  #    LIMIT 2 OFFSET 2\n  # } {12 8}\n  #\n  # test_transform selectB-$ii.15 {\n  #   SELECT * FROM (\n  #     SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY a ASC, e DESC\n  #  )\n  # } {\n  #   SELECT a, b FROM t1 UNION ALL SELECT d, e FROM t2 ORDER BY a ASC, e DESC\n  # } {2 4 3 6 8 10 12 15 14 16 21 24}\n}\n\ndo_test selectB-3.0 {\n  execsql {\n    DROP INDEX i1;\n    DROP INDEX i2;\n  }\n} {}\n\nfor {set ii 3} {$ii <= 6} {incr ii} {\n\n  switch $ii {\n    4 {\n      optimization_control db query-flattener off\n    }\n    5 {\n      optimization_control db query-flattener on\n      do_test selectB-5.0 {\n        execsql {\n          CREATE INDEX i1 ON t1(a);\n          CREATE INDEX i2 ON t1(b);\n          CREATE INDEX i3 ON t1(c);\n          CREATE INDEX i4 ON t2(d);\n          CREATE INDEX i5 ON t2(e);\n          CREATE INDEX i6 ON t2(f);\n        }\n      } {}\n    }\n    6 {\n      optimization_control db query-flattener off\n    }\n  }\n\n  do_test selectB-$ii.1 {\n    execsql {\n      SELECT DISTINCT * FROM \n        (SELECT c FROM t1 UNION ALL SELECT e FROM t2) \n      ORDER BY 1;\n    }\n  } {6 12 15 18 24}\n  \n  do_test selectB-$ii.2 {\n    execsql {\n      SELECT c, count(*) FROM \n        (SELECT c FROM t1 UNION ALL SELECT e FROM t2) \n      GROUP BY c ORDER BY 1;\n    }\n  } {6 2 12 1 15 1 18 1 24 1}\n  do_test selectB-$ii.3 {\n    execsql {\n      SELECT c, count(*) FROM \n        (SELECT c FROM t1 UNION ALL SELECT e FROM t2) \n      GROUP BY c HAVING count(*)>1;\n    }\n  } {6 2}\n  do_test selectB-$ii.4 {\n    execsql {\n      SELECT t4.c, t3.a FROM \n        (SELECT c FROM t1 UNION ALL SELECT e FROM t2) AS t4, t1 AS t3\n      WHERE t3.a=14\n      ORDER BY 1\n    }\n  } {6 14 6 14 12 14 15 14 18 14 24 14}\n  \n  do_test selectB-$ii.5 {\n    execsql {\n      SELECT d FROM t2 \n      EXCEPT \n      SELECT a FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)\n    }\n  } {}\n  do_test selectB-$ii.6 {\n    execsql {\n      SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)\n      EXCEPT \n      SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT d FROM t2)\n    }\n  } {}\n  do_test selectB-$ii.7 {\n    execsql {\n      SELECT c FROM t1\n      EXCEPT \n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n    }\n  } {12}\n  do_test selectB-$ii.8 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      EXCEPT \n      SELECT c FROM t1\n    }\n  } {9 15 24 27}\n  do_test selectB-$ii.9 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      EXCEPT \n      SELECT c FROM t1\n      ORDER BY c DESC\n    }\n  } {27 24 15 9}\n  \n  do_test selectB-$ii.10 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      UNION \n      SELECT c FROM t1\n      ORDER BY c DESC\n    }\n  } {27 24 18 15 12 9 6}\n  do_test selectB-$ii.11 {\n    execsql {\n      SELECT c FROM t1\n      UNION \n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      ORDER BY c\n    }\n  } {6 9 12 15 18 24 27}\n  do_test selectB-$ii.12 {\n    execsql {\n      SELECT c FROM t1 UNION SELECT e FROM t2 UNION ALL SELECT f FROM t2\n      ORDER BY c\n    }\n  } {6 9 12 15 18 18 24 27}\n  do_test selectB-$ii.13 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      UNION \n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      ORDER BY 1\n    }\n  } {6 9 15 18 24 27}\n  \n  do_test selectB-$ii.14 {\n    execsql {\n      SELECT c FROM t1\n      INTERSECT \n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      ORDER BY 1\n    }\n  } {6 18}\n  do_test selectB-$ii.15 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      INTERSECT \n      SELECT c FROM t1\n      ORDER BY 1\n    }\n  } {6 18}\n  do_test selectB-$ii.16 {\n    execsql {\n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      INTERSECT \n      SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2)\n      ORDER BY 1\n    }\n  } {6 9 15 18 24 27}\n\n  do_test selectB-$ii.17 {\n    execsql {\n      SELECT * FROM (\n        SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4\n      ) LIMIT 2\n    }\n  } {2 8}\n\n  do_test selectB-$ii.18 {\n    execsql {\n      SELECT * FROM (\n        SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4 OFFSET 2\n      ) LIMIT 2\n    }\n  } {14 3}\n\n  do_test selectB-$ii.19 {\n    execsql {\n      SELECT * FROM (\n        SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2\n      )\n    }\n  } {0 1 1 0}\n\n  do_test selectB-$ii.20 {\n    execsql {\n      SELECT DISTINCT * FROM (\n        SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2\n      )\n    }\n  } {0 1}\n\n  do_test selectB-$ii.21 {\n    execsql {\n      SELECT * FROM (SELECT * FROM t1 UNION ALL SELECT * FROM t2) ORDER BY a+b\n    }\n  } {2 4 6 3 6 9 8 10 12 12 15 18 14 16 18 21 24 27}\n\n  do_test selectB-$ii.22 {\n    execsql {\n      SELECT * FROM (SELECT 345 UNION ALL SELECT d FROM t2) ORDER BY 1;\n    }\n  } {3 12 21 345}\n\n  do_test selectB-$ii.23 {\n    execsql {\n      SELECT x, y FROM (\n        SELECT a AS x, b AS y FROM t1\n        UNION ALL\n        SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 JOIN t2 ON (c=d)\n        UNION ALL\n        SELECT a*100, b*100 FROM t1\n      ) ORDER BY 1;\n    }\n  } {2 4 8 10 14 16 80.1 180.1 200 400 800 1000 1400 1600}\n\n  do_test selectB-$ii.24 {\n    execsql {\n      SELECT x, y FROM (\n        SELECT a AS x, b AS y FROM t1\n        UNION ALL\n        SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d)\n        UNION ALL\n        SELECT a*100, b*100 FROM t1\n      ) ORDER BY 1;\n    }\n  } {2 4 8 10 14 16 20.1 {} 80.1 180.1 140.1 {} 200 400 800 1000 1400 1600}\n\n  do_test selectB-$ii.25 {\n    execsql {\n      SELECT x+y FROM (\n        SELECT a AS x, b AS y FROM t1\n        UNION ALL\n        SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d)\n        UNION ALL\n        SELECT a*100, b*100 FROM t1\n      ) WHERE y+x NOT NULL ORDER BY 1;\n    }\n  } {6 18 30 260.2 600 1800 3000}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectC.test",
    "content": "# 2008 September 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# $Id: selectC.test,v 1.5 2009/05/17 15:26:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix selectC\n\n# Ticket #\ndo_test selectC-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1,'aaa','bbb');\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 VALUES(2,'ccc','ddd');\n\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE y IN ('aaabbb','xxx');\n  }\n} {1 aaabbb}\ndo_test selectC-1.2 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE b||c IN ('aaabbb','xxx');\n  }\n} {1 aaabbb}\ndo_test selectC-1.3 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE y='aaabbb'\n  }\n} {1 aaabbb}\ndo_test selectC-1.4 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE b||c='aaabbb'\n  }\n} {1 aaabbb}\ndo_test selectC-1.5 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE x=2\n  }\n} {2 cccddd}\ndo_test selectC-1.6 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE a=2\n  }\n} {2 cccddd}\ndo_test selectC-1.7 {\n  execsql {\n    SELECT DISTINCT a AS x, b||c AS y\n      FROM t1\n     WHERE +y='aaabbb'\n  }\n} {1 aaabbb}\ndo_test selectC-1.8 {\n  execsql {\n    SELECT a AS x, b||c AS y\n      FROM t1\n     GROUP BY x, y\n    HAVING y='aaabbb'\n  }\n} {1 aaabbb}\ndo_test selectC-1.9 {\n  execsql {\n    SELECT a AS x, b||c AS y\n      FROM t1\n     GROUP BY x, y\n    HAVING b||c='aaabbb'\n  }\n} {1 aaabbb}\ndo_test selectC-1.10 {\n  execsql {\n    SELECT a AS x, b||c AS y\n      FROM t1\n     WHERE y='aaabbb'\n     GROUP BY x, y\n  }\n} {1 aaabbb}\ndo_test selectC-1.11 {\n  execsql {\n    SELECT a AS x, b||c AS y\n      FROM t1\n     WHERE b||c='aaabbb'\n     GROUP BY x, y\n  }\n} {1 aaabbb}\nproc longname_toupper x {return [string toupper $x]}\ndb function uppercaseconversionfunctionwithaverylongname longname_toupper\ndo_test selectC-1.12.1 {\n  execsql {\n    SELECT DISTINCT upper(b) AS x\n      FROM t1\n     ORDER BY x\n  }\n} {AAA CCC}\ndo_test selectC-1.12.2 {\n  execsql {\n    SELECT DISTINCT uppercaseconversionfunctionwithaverylongname(b) AS x\n      FROM t1\n     ORDER BY x\n  }\n} {AAA CCC}\ndo_test selectC-1.13.1 {\n  execsql {\n    SELECT upper(b) AS x\n      FROM t1\n     GROUP BY x\n     ORDER BY x\n  }\n} {AAA CCC}\ndo_test selectC-1.13.2 {\n  execsql {\n    SELECT uppercaseconversionfunctionwithaverylongname(b) AS x\n      FROM t1\n     GROUP BY x\n     ORDER BY x\n  }\n} {AAA CCC}\ndo_test selectC-1.14.1 {\n  execsql {\n    SELECT upper(b) AS x\n      FROM t1\n     ORDER BY x DESC\n  }\n} {CCC AAA AAA}\ndo_test selectC-1.14.2 {\n  execsql {\n    SELECT uppercaseconversionfunctionwithaverylongname(b) AS x\n      FROM t1\n     ORDER BY x DESC\n  }\n} {CCC AAA AAA}\n\n# The following query used to leak memory.  Verify that has been fixed.\n#\nifcapable trigger&&compound {\n  do_test selectC-2.1 {\n    catchsql {\n      CREATE TABLE t21a(a,b);\n      INSERT INTO t21a VALUES(1,2);\n      CREATE TABLE t21b(n);\n      CREATE TRIGGER r21 AFTER INSERT ON t21b BEGIN\n        SELECT a FROM t21a WHERE a>new.x UNION ALL\n        SELECT b FROM t21a WHERE b>new.x ORDER BY 1 LIMIT 2;\n      END;\n      INSERT INTO t21b VALUES(6);\n    }\n  } {1 {no such column: new.x}}\n}\n\n# Check that ticket [883034dcb5] is fixed.\n#\ndo_test selectC-3.1 {\n  execsql {\n    CREATE TABLE person (\n        org_id          TEXT NOT NULL,\n        nickname        TEXT NOT NULL,\n        license         TEXT,\n        CONSTRAINT person_pk PRIMARY KEY (org_id, nickname),\n        CONSTRAINT person_license_uk UNIQUE (license)\n    );\n    INSERT INTO person VALUES('meyers', 'jack', '2GAT123');\n    INSERT INTO person VALUES('meyers', 'hill', 'V345FMP');\n    INSERT INTO person VALUES('meyers', 'jim', '2GAT138');\n    INSERT INTO person VALUES('smith', 'maggy', '');\n    INSERT INTO person VALUES('smith', 'jose', 'JJZ109');\n    INSERT INTO person VALUES('smith', 'jack', 'THX138');\n    INSERT INTO person VALUES('lakeside', 'dave', '953OKG');\n    INSERT INTO person VALUES('lakeside', 'amy', NULL);\n    INSERT INTO person VALUES('lake-apts', 'tom', NULL);\n    INSERT INTO person VALUES('acorn', 'hideo', 'CQB421');\n    \n    SELECT \n      org_id, \n      count((NOT (org_id IS NULL)) AND (NOT (nickname IS NULL)))\n    FROM person \n    WHERE (CASE WHEN license != '' THEN 1 ELSE 0 END)\n    GROUP BY 1;\n  }\n} {acorn 1 lakeside 1 meyers 3 smith 2}\ndo_test selectC-3.2 {\n  execsql {\n    CREATE TABLE t2(a PRIMARY KEY, b);\n    INSERT INTO t2 VALUES('abc', 'xxx');\n    INSERT INTO t2 VALUES('def', 'yyy');\n    SELECT a, max(b || a) FROM t2 WHERE (b||b||b)!='value' GROUP BY a;\n  }\n} {abc xxxabc def yyydef}\ndo_test selectC-3.3 {\n  execsql {\n    SELECT b, max(a || b) FROM t2 WHERE (b||b||b)!='value' GROUP BY a;\n  }\n} {xxx abcxxx yyy defyyy}\n\n\nproc udf {} { incr ::udf }\nset ::udf 0\ndb function udf udf\n\ndo_execsql_test selectC-4.1 {\n  create table t_distinct_bug (a, b, c);\n  insert into t_distinct_bug values ('1', '1', 'a');\n  insert into t_distinct_bug values ('1', '2', 'b');\n  insert into t_distinct_bug values ('1', '3', 'c');\n  insert into t_distinct_bug values ('1', '1', 'd');\n  insert into t_distinct_bug values ('1', '2', 'e');\n  insert into t_distinct_bug values ('1', '3', 'f');\n} {}\n\ndo_execsql_test selectC-4.2 {\n  select a from (select distinct a, b from t_distinct_bug)\n} {1 1 1}\n\ndo_execsql_test selectC-4.3 {\n  select a, udf() from (select distinct a, b from t_distinct_bug)\n} {1 1 1 2 1 3}\n\n#-------------------------------------------------------------------------\n# Test that the problem in ticket #190c2507 has been fixed.\n#\ndo_execsql_test 5.0 {\n  CREATE TABLE x1(a);\n  CREATE TABLE x2(b);\n  CREATE TABLE x3(c);\n  CREATE VIEW vvv AS SELECT b FROM x2 ORDER BY 1;\n\n  INSERT INTO x1 VALUES('a'), ('b');\n  INSERT INTO x2 VALUES(22), (23), (25), (24), (21);\n  INSERT INTO x3 VALUES(302), (303), (301);\n}\n\ndo_execsql_test 5.1 {\n  CREATE TABLE x4 AS SELECT b FROM vvv UNION ALL SELECT c from x3;\n  SELECT * FROM x4;\n} {21 22 23 24 25 302 303 301}\n\ndo_execsql_test 5.2 {\n  SELECT * FROM x1, x4\n} {\n  a 21 a 22 a 23 a 24 a 25 a 302 a 303 a 301\n  b 21 b 22 b 23 b 24 b 25 b 302 b 303 b 301\n}\n\ndo_execsql_test 5.3 {\n  SELECT * FROM x1, (SELECT b FROM vvv UNION ALL SELECT c from x3);\n} {\n  a 21 a 22 a 23 a 24 a 25 a 302 a 303 a 301\n  b 21 b 22 b 23 b 24 b 25 b 302 b 303 b 301\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectD.test",
    "content": "# 2012 December 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for name resolution in SELECT\n# statements that have parenthesized FROM clauses.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\nfor {set i 1} {$i<=2} {incr i} {\n  db close\n  forcedelete test$i.db\n  sqlite3 db test$i.db\n  if {$i==2} {\n    optimization_control db query-flattener off\n  }\n  do_test selectD-$i.0 {\n    db eval {\n      ATTACH ':memory:' AS aux1;\n      CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(111,'x1');\n      CREATE TABLE t2(a,b); INSERT INTO t2 VALUES(222,'x2');\n      CREATE TEMP TABLE t3(a,b); INSERT INTO t3 VALUES(333,'x3');\n      CREATE TABLE main.t4(a,b); INSERT INTO main.t4 VALUES(444,'x4');\n      CREATE TABLE aux1.t4(a,b); INSERT INTO aux1.t4 VALUES(555,'x5');\n    }\n  } {}\n  do_test selectD-$i.1 {\n    db eval {\n      SELECT *\n        FROM (t1), (t2), (t3), (t4)\n       WHERE t4.a=t3.a+111 \n         AND t3.a=t2.a+111\n         AND t2.a=t1.a+111;\n    }\n  } {111 x1 222 x2 333 x3 444 x4}\n  do_test selectD-$i.2.1 {\n    db eval {\n      SELECT *\n        FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)\n                              ON t3.a=t2.a+111)\n                     ON t2.a=t1.a+111;\n    }\n  } {111 x1 222 x2 333 x3 444 x4}\n  do_test selectD-$i.2.2 {\n    db eval {\n      SELECT t3.a\n        FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)\n                              ON t3.a=t2.a+111)\n                     ON t2.a=t1.a+111;\n    }\n  } {333}\n  do_test selectD-$i.2.3 {\n    db eval {\n      SELECT t3.*\n        FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)\n                              ON t3.a=t2.a+111)\n                     ON t2.a=t1.a+111;\n    }\n  } {333 x3}\n  do_test selectD-$i.2.3 {\n    db eval {\n      SELECT t3.*, t2.*\n        FROM t1 JOIN (t2 JOIN (t3 JOIN t4 ON t4.a=t3.a+111)\n                              ON t3.a=t2.a+111)\n                     ON t2.a=t1.a+111;\n    }\n  } {333 x3 222 x2}\n  do_test selectD-$i.2.4 {\n    db eval {\n      SELECT *\n        FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux1.t4 ON aux1.t4.a=main.t4.a+111)\n                              ON main.t4.a=t2.a+222)\n                     ON t2.a=t1.a+111;\n    }\n  } {111 x1 222 x2 444 x4 555 x5}\n  do_test selectD-$i.2.5 {\n    db eval {\n      SELECT *\n        FROM t1 JOIN (t2 JOIN (main.t4 AS x JOIN aux1.t4 ON aux1.t4.a=x.a+111)\n                              ON x.a=t2.a+222)\n                     ON t2.a=t1.a+111;\n    }\n  } {111 x1 222 x2 444 x4 555 x5}\n  do_test selectD-$i.2.6 {\n    catchsql {\n      SELECT *\n        FROM t1 JOIN (t2 JOIN (main.t4 JOIN aux.t4 ON aux.t4.a=main.t4.a+111)\n                              ON main.t4.a=t2.a+222)\n                     ON t2.a=t1.a+111;\n    }\n  } {1 {no such table: aux.t4}}\n  do_test selectD-$i.2.7 {\n    db eval {\n      SELECT x.a, y.b\n        FROM t1 JOIN (t2 JOIN (main.t4 x JOIN aux1.t4 y ON y.a=x.a+111)\n                              ON x.a=t2.a+222)\n                     ON t2.a=t1.a+111;\n    }\n  } {444 x5}\n  do_test selectD-$i.3 {\n    db eval {\n      UPDATE t2 SET a=111;\n      UPDATE t3 SET a=111;\n      UPDATE t4 SET a=111;\n      SELECT *\n        FROM t1 JOIN (t2 JOIN (t3 JOIN t4 USING(a)) USING (a)) USING (a);\n    }\n  } {111 x1 x2 x3 x4}\n  do_test selectD-$i.4 {\n    db eval {\n      UPDATE t2 SET a=111;\n      UPDATE t3 SET a=111;\n      UPDATE t4 SET a=111;\n      SELECT *\n        FROM t1 LEFT JOIN (t2 LEFT JOIN (t3 LEFT JOIN t4 USING(a))\n                                        USING (a))\n                           USING (a);\n    }\n  } {111 x1 x2 x3 x4}\n  do_test selectD-$i.5 {\n    db eval {\n      UPDATE t3 SET a=222;\n      UPDATE t4 SET a=222;\n      SELECT *\n        FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))\n             ON t1.a=t3.a-111;\n    }\n  } {111 x1 x2 222 x3 x4}\n  do_test selectD-$i.6 {\n    db eval {\n      UPDATE t4 SET a=333;\n      SELECT *\n        FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))\n             ON t1.a=t3.a-111;\n    }\n  } {111 x1 x2 222 x3 {}}\n  do_test selectD-$i.7 {\n    db eval {\n      SELECT t1.*, t2.*, t3.*, t4.b\n        FROM (t1 LEFT JOIN t2 USING(a)) JOIN (t3 LEFT JOIN t4 USING(a))\n             ON t1.a=t3.a-111;\n    }\n  } {111 x1 111 x2 222 x3 {}}\n}\n\n# The following test was added on 2013-04-24 in order to verify that\n# the datatypes and affinities of sub-sub-queries are set prior to computing\n# the datatypes and affinities of the parent sub-queries because the \n# latter computation depends on the former.\n#\ndo_execsql_test selectD-4.1 {\n  CREATE TABLE t41(a INTEGER PRIMARY KEY, b INTEGER);\n  CREATE TABLE t42(d INTEGER PRIMARY KEY, e INTEGER);\n  CREATE TABLE t43(f INTEGER PRIMARY KEY, g INTEGER);\n  EXPLAIN QUERY PLAN\n  SELECT * \n   FROM t41\n   LEFT JOIN (SELECT count(*) AS cnt, x1.d\n                FROM (t42 INNER JOIN t43 ON d=g) AS x1\n               WHERE x1.d>5\n               GROUP BY x1.d) AS x2\n                  ON t41.b=x2.d;\n} {/.*SEARCH SUBQUERY 1 AS x2 USING AUTOMATIC.*/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectE.test",
    "content": "# 2013-05-07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for compound SELECT statements\n# that have ORDER BY clauses with collating sequences that differ\n# from the collating sequence used for comparison in the compound.\n# \n# Ticket 6709574d2a8d8b9be3a9cb1afbf4ff2de48ea4e7:\n# drh added on 2013-05-06 15:21:16:\n#\n# In the code shown below (which is intended to be run from the\n# sqlite3.exe command-line tool) the three SELECT statements should all\n# generate the same answer. But the third one does not. It is as if the\n# COLLATE clause on the ORDER BY somehow got pulled into the EXCEPT\n# operator. Note that the \".print\" commands are instructions to the\n# sqlite3.exe shell program to output delimiter lines so that you can more\n# easily tell where the output of one query ends and the next query\n# begins. \n# \n#     CREATE TABLE t1(a);\n#     INSERT INTO t1 VALUES('abc'),('def');\n#     CREATE TABLE t2(a);\n#     INSERT INTO t2 VALUES('DEF');\n# \n#     SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a;\n#     .print -----\n#     SELECT a FROM (SELECT a FROM t1 EXCEPT SELECT a FROM t2)\n#      ORDER BY a COLLATE nocase;\n#     .print -----\n#     SELECT a FROM t1 EXCEPT SELECT a FROM t2 ORDER BY a COLLATE nocase;\n# \n# Bisecting shows that this problem was introduced in SQLite version 3.6.0\n# by check-in [8bbfa97837a74ef] on 2008-06-15. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test selectE-1.0 {\n  db eval {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES('abc'),('def'),('ghi');\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES('DEF'),('abc');\n    CREATE TABLE t3(a);\n    INSERT INTO t3 VALUES('def'),('jkl');\n\n    SELECT a FROM t1 EXCEPT SELECT a FROM t2\n     ORDER BY a COLLATE nocase;\n  }\n} {def ghi}\ndo_test selectE-1.1 {\n  db eval {\n    SELECT a FROM t2 EXCEPT SELECT a FROM t3\n     ORDER BY a COLLATE nocase;\n  }\n} {abc DEF}\ndo_test selectE-1.2 {\n  db eval {\n    SELECT a FROM t2 EXCEPT SELECT a FROM t3\n     ORDER BY a COLLATE binary;\n  }\n} {DEF abc}\ndo_test selectE-1.3 {\n  db eval {\n    SELECT a FROM t2 EXCEPT SELECT a FROM t3\n     ORDER BY a;\n  }\n} {DEF abc}\n\ndo_test selectE-2.1 {\n  db eval {\n    DELETE FROM t2;\n    DELETE FROM t3;\n    INSERT INTO t2 VALUES('ABC'),('def'),('GHI'),('jkl');\n    INSERT INTO t3 SELECT lower(a) FROM t2;\n    SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3\n     ORDER BY 1\n  }\n} {}\ndo_test selectE-2.2 {\n  db eval {\n    SELECT a COLLATE nocase FROM t2 EXCEPT SELECT a FROM t3\n     ORDER BY 1 COLLATE binary\n  }\n} {}\n\ndo_catchsql_test selectE-3.1 {\n  SELECT 1 EXCEPT SELECT 2 ORDER BY 1 COLLATE nocase EXCEPT SELECT 3;\n} {1 {ORDER BY clause should come after EXCEPT not before}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectF.test",
    "content": "# 2014-03-03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file verifies that an OP_Copy operation is used instead of OP_SCopy\n# in a compound select in a case where the source register might be changed\n# before the copy is used.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix selectF\n\ndo_execsql_test 1 {\n  BEGIN TRANSACTION;\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO \"t1\" VALUES(1,'one','I');\n  CREATE TABLE t2(d, e, f);\n  INSERT INTO \"t2\" VALUES(5,'ten','XX');\n  INSERT INTO \"t2\" VALUES(6,NULL,NULL);\n\n  CREATE INDEX i1 ON t1(b, a);\n  COMMIT;\n}\n\n#explain_i {\n#  SELECT * FROM t2\n#  UNION ALL \n#  SELECT * FROM t1 WHERE a<5 \n#  ORDER BY 2, 1\n#}\n\ndo_execsql_test 2 {\n  SELECT * FROM t2\n  UNION ALL \n  SELECT * FROM t1 WHERE a<5 \n  ORDER BY 2, 1\n} {6 {} {} 1 one I 5 ten XX}\n\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/selectG.test",
    "content": "# 2015-01-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file verifies that INSERT operations with a very large number of\n# VALUE terms works and does not hit the SQLITE_LIMIT_COMPOUND_SELECT limit.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix selectG\n\n# Do an INSERT with a VALUES clause that contains 100,000 entries.  Verify\n# that this insert happens quickly (in less than 10 seconds).  Actually, the\n# insert will normally happen in less than 0.5 seconds on a workstation, but\n# we allow plenty of overhead for slower machines.  The speed test checks\n# for an O(N*N) inefficiency that was once in the code and that would make\n# the insert run for over a minute.\n#\ndo_test 100 {\n  set sql \"CREATE TABLE t1(x);\\nINSERT INTO t1(x) VALUES\"\n  for {set i 1} {$i<100000} {incr i} {\n    append sql \"($i),\"\n  }\n  append sql \"($i);\"\n  set microsec [lindex [time {db eval $sql}] 0]\n  db eval {\n    SELECT count(x), sum(x), avg(x), $microsec<10000000 FROM t1;\n  }\n} {100000 5000050000 50000.5 1}\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/server1.test",
    "content": "# 2006 January 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the server mode of SQLite.\n#\n# This file is derived from thread1.test\n#\n# $Id: server1.test,v 1.5 2007/08/29 18:20:17 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Skip this whole file if the server testing code is not enabled\n#\nif {[llength [info command client_step]]==0 || [sqlite3 -has-codec]} {\n  finish_test\n  return\n}\n\n# The sample server implementation does not work right when memory\n# management is enabled.\n#\nifcapable (memorymanage||mutex_noop) {\n  finish_test\n  return\n}\n\n# Create some data to work with\n#\ndo_test server1-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,'abcdefgh');\n    INSERT INTO t1 SELECT a+1, b||b FROM t1;\n    INSERT INTO t1 SELECT a+2, b||b FROM t1;\n    INSERT INTO t1 SELECT a+4, b||b FROM t1;\n    SELECT count(*), max(length(b)) FROM t1;\n  }\n} {8 64}\n\n# Interleave two threads on read access.  Then make sure a third\n# thread can write the database.  In other words:\n#\n#    read-lock A\n#    read-lock B\n#    unlock A\n#    unlock B\n#    write-lock C\n#\ndo_test server1-1.2 {\n  client_create A test.db\n  client_create B test.db\n  client_create C test.db\n  client_compile A {SELECT a FROM t1}\n  client_step A\n  client_result A\n} SQLITE_ROW\ndo_test server1-1.3 {\n  client_argc A\n} 1\ndo_test server1-1.4 {\n  client_argv A 0\n} 1\ndo_test server1-1.5 {\n  client_compile B {SELECT b FROM t1}\n  client_step B\n  client_result B\n} SQLITE_ROW\ndo_test server1-1.6 {\n  client_argc B\n} 1\ndo_test server1-1.7 {\n  client_argv B 0\n} abcdefgh\ndo_test server1-1.8 {\n  client_finalize A\n  client_result A\n} SQLITE_OK\ndo_test server1-1.9 {\n  client_finalize B\n  client_result B\n} SQLITE_OK\ndo_test server1-1.10 {\n  client_compile C {CREATE TABLE t2(x,y)}\n  client_step C\n  client_result C\n} SQLITE_DONE\ndo_test server1-1.11 {\n  client_finalize C\n  client_result C\n} SQLITE_OK\ndo_test server1-1.12 {\n  catchsql {SELECT name FROM sqlite_master}\n  execsql {SELECT name FROM sqlite_master}\n} {t1 t2}\n\n\n# Read from table t1.  Do not finalize the statement.  This\n# will leave the lock pending.\n#\ndo_test server1-2.1 {\n  client_halt *\n  client_create A test.db\n  client_compile A {SELECT a FROM t1}\n  client_step A\n  client_result A\n} SQLITE_ROW\n\n# Read from the same table from another thread.  This is allows.\n#\ndo_test server1-2.2 {\n  client_create B test.db\n  client_compile B {SELECT b FROM t1}\n  client_step B\n  client_result B\n} SQLITE_ROW\n\n# Write to a different table from another thread.  This is allowed\n# because in server mode with a shared cache we have table-level locking.\n#\ndo_test server1-2.3 {\n  client_create C test.db\n  client_compile C {INSERT INTO t2 VALUES(98,99)}\n  client_step C\n  client_result C\n  client_finalize C\n  client_result C\n} SQLITE_OK\n\n# But we cannot insert into table t1 because threads A and B have it locked.\n#\ndo_test server1-2.4 {\n  client_compile C {INSERT INTO t1 VALUES(98,99)}\n  client_step C\n  client_result C\n  client_finalize C\n  client_result C\n} SQLITE_LOCKED\ndo_test server1-2.5 {\n  client_finalize B\n  client_wait B\n  client_compile C {INSERT INTO t1 VALUES(98,99)}\n  client_step C\n  client_result C\n  client_finalize C\n  client_result C\n} SQLITE_LOCKED\n\n# Insert into t1 is successful after finishing the other two threads.\ndo_test server1-2.6 {\n  client_finalize A\n  client_wait A\n  client_compile C {INSERT INTO t1 VALUES(98,99)}\n  client_step C\n  client_result C\n  client_finalize C\n  client_result C\n} SQLITE_OK\n\nclient_halt *   \nsqlite3_enable_shared_cache 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/session.test",
    "content": "# 2008 June 23\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all rtree related tests.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nifcapable session {\n  # First run tests with sqlite3_extended_error_codes() set, then\n  # again with it clear.\n  run_test_suite session_eec\n  run_test_suite session\n  run_test_suite session_strm\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared.test",
    "content": "# 2005 December 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: shared.test,v 1.36 2009/03/16 13:19:36 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndb close\n\n# These tests cannot be run without the ATTACH command.\n#\nifcapable !shared_cache||!attach {\n  finish_test\n  return\n}\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\nforeach av [list 0 1] {\n\n# Open the database connection and execute the auto-vacuum pragma\nforcedelete test.db\nsqlite3 db test.db\n\nifcapable autovacuum {\n  do_test shared-[expr $av+1].1.0 {\n    execsql \"pragma auto_vacuum=$::av\"\n    execsql {pragma auto_vacuum}\n  } \"$av\"\n} else {\n  if {$av} {\n    db close\n    break\n  }\n}\n\n# if we're using proxy locks, we use 2 filedescriptors for a db\n# that is open but NOT yet locked, after a lock is taken we'll have 3, \n# normally sqlite uses 1 (proxy locking adds the conch and the local lock)\nset using_proxy 0\nforeach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] {\n  set using_proxy $value\n}\nset extrafds_prelock 0\nset extrafds_postlock 0\nif {$using_proxy>0} {\n  set extrafds_prelock 1\n  set extrafds_postlock 2\n} \n\n# $av is currently 0 if this loop iteration is to test with auto-vacuum turned\n# off, and 1 if it is turned on. Increment it so that (1 -> no auto-vacuum) \n# and (2 -> auto-vacuum). The sole reason for this is so that it looks nicer\n# when we use this variable as part of test-case names.\n#\nincr av\n\n# Test organization:\n#\n# shared-1.*: Simple test to verify basic sanity of table level locking when\n#             two connections share a pager cache.\n# shared-2.*: Test that a read transaction can co-exist with a \n#             write-transaction, including a simple test to ensure the \n#             external locking protocol is still working.\n# shared-3.*: Simple test of read-uncommitted mode.\n# shared-4.*: Check that the schema is locked and unlocked correctly.\n# shared-5.*: Test that creating/dropping schema items works when databases\n#             are attached in different orders to different handles.\n# shared-6.*: Locking, UNION ALL queries and sub-queries.\n# shared-7.*: Autovacuum and shared-cache.\n# shared-8.*: Tests related to the text encoding of shared-cache databases.\n# shared-9.*: TEMP triggers and shared-cache databases.\n# shared-10.*: Tests of sqlite3_close().\n# shared-11.*: Test transaction locking.\n#\n\ndo_test shared-$av.1.1 {\n  # Open a second database on the file test.db. It should use the same pager\n  # cache and schema as the original connection. Verify that only 1 file is \n  # opened.\n  sqlite3 db2 test.db\n  set ::sqlite_open_file_count\n  expr $sqlite_open_file_count-$extrafds_postlock\n} {1}\ndo_test shared-$av.1.2 {\n  # Add a table and a single row of data via the first connection. \n  # Ensure that the second connection can see them.\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n  } db\n  execsql {\n    SELECT * FROM abc;\n  } db2\n} {1 2 3}\ndo_test shared-$av.1.3 {\n  # Have the first connection begin a transaction and obtain a read-lock\n  # on table abc. This should not prevent the second connection from \n  # querying abc.\n  execsql {\n    BEGIN;\n    SELECT * FROM abc;\n  }\n  execsql {\n    SELECT * FROM abc;\n  } db2\n} {1 2 3}\ndo_test shared-$av.1.4 {\n  # Try to insert a row into abc via connection 2. This should fail because\n  # of the read-lock connection 1 is holding on table abc (obtained in the\n  # previous test case).\n  catchsql {\n    INSERT INTO abc VALUES(4, 5, 6);\n  } db2\n} {1 {database table is locked: abc}}\ndo_test shared-$av.1.5 {\n  # Using connection 2 (the one without the open transaction), try to create\n  # a new table. This should fail because of the open read transaction \n  # held by connection 1.\n  catchsql {\n    CREATE TABLE def(d, e, f);\n  } db2\n} {1 {database table is locked: sqlite_master}}\ndo_test shared-$av.1.6 {\n  # Upgrade connection 1's transaction to a write transaction. Create\n  # a new table - def - and insert a row into it. Because the connection 1\n  # transaction modifies the schema, it should not be possible for \n  # connection 2 to access the database at all until the connection 1 \n  # has finished the transaction.\n  execsql {\n    CREATE TABLE def(d, e, f);\n    INSERT INTO def VALUES('IV', 'V', 'VI');\n  }\n} {}\ndo_test shared-$av.1.7 {\n  # Read from the sqlite_master table with connection 1 (inside the \n  # transaction). Then test that we can not do this with connection 2. This\n  # is because of the schema-modified lock established by connection 1 \n  # in the previous test case.\n  execsql {\n    SELECT * FROM sqlite_master;\n  }\n  catchsql {\n    SELECT * FROM sqlite_master;\n  } db2\n} {1 {database schema is locked: main}}\ndo_test shared-$av.1.8 {\n  # Commit the connection 1 transaction.\n  execsql {\n    COMMIT;\n  }\n} {}\n\ndo_test shared-$av.2.1 {\n  # Open connection db3 to the database. Use a different path to the same\n  # file so that db3 does *not* share the same pager cache as db and db2\n  # (there should be two open file handles).\n  if {$::tcl_platform(platform)==\"unix\"} {\n    sqlite3 db3 ./test.db\n  } else {\n    sqlite3 db3 TEST.DB\n  }\n  set ::sqlite_open_file_count\n  expr $sqlite_open_file_count-($extrafds_prelock+$extrafds_postlock)\n} {2}\ndo_test shared-$av.2.2 {\n  # Start read transactions on db and db2 (the shared pager cache). Ensure\n  # db3 cannot write to the database.\n  execsql {\n    BEGIN;\n    SELECT * FROM abc;\n  }\n  execsql {\n    BEGIN;\n    SELECT * FROM abc;\n  } db2\n  catchsql {\n    INSERT INTO abc VALUES(1, 2, 3);\n  } db2\n} {1 {database table is locked: abc}}\ndo_test shared-$av.2.3 {\n  # Turn db's transaction into a write-transaction. db3 should still be\n  # able to read from table def (but will not see the new row). Connection\n  # db2 should not be able to read def (because of the write-lock).\n\n# Todo: The failed \"INSERT INTO abc ...\" statement in the above test\n# has started a write-transaction on db2 (should this be so?). This \n# would prevent connection db from starting a write-transaction. So roll the\n# db2 transaction back and replace it with a new read transaction.\n  execsql {\n    ROLLBACK;\n    BEGIN;\n    SELECT * FROM abc;\n  } db2\n\n  execsql {\n    INSERT INTO def VALUES('VII', 'VIII', 'IX');\n  }\n  concat [\n    catchsql { SELECT * FROM def; } db3\n  ] [\n    catchsql { SELECT * FROM def; } db2\n  ]\n} {0 {IV V VI} 1 {database table is locked: def}}\ndo_test shared-$av.2.4 {\n  # Commit the open transaction on db. db2 still holds a read-transaction.\n  # This should prevent db3 from writing to the database, but not from \n  # reading.\n  execsql {\n    COMMIT;\n  }\n  concat [\n    catchsql { SELECT * FROM def; } db3\n  ] [\n    catchsql { INSERT INTO def VALUES('X', 'XI', 'XII'); } db3\n  ]\n} {0 {IV V VI VII VIII IX} 1 {database is locked}}\n\ncatchsql COMMIT db2\n\ndo_test shared-$av.3.1.1 {\n  # This test case starts a linear scan of table 'seq' using a \n  # read-uncommitted connection. In the middle of the scan, rows are added\n  # to the end of the seq table (ahead of the current cursor position).\n  # The uncommitted rows should be included in the results of the scan.\n  execsql \"\n    CREATE TABLE seq(i PRIMARY KEY, x);\n    INSERT INTO seq VALUES(1, '[string repeat X 500]');\n    INSERT INTO seq VALUES(2, '[string repeat X 500]');\n  \"\n  execsql {SELECT * FROM sqlite_master} db2\n  execsql {PRAGMA read_uncommitted = 1} db2\n\n  set ret [list]\n  db2 eval {SELECT i FROM seq ORDER BY i} {\n    if {$i < 4} {\n      set max [execsql {SELECT max(i) FROM seq}]\n      db eval {\n        INSERT INTO seq SELECT i + :max, x FROM seq;\n      }\n    }\n    lappend ret $i\n  }\n  set ret\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}\ndo_test shared-$av.3.1.2 {\n  # Another linear scan through table seq using a read-uncommitted connection.\n  # This time, delete each row as it is read. Should not affect the results of\n  # the scan, but the table should be empty after the scan is concluded \n  # (test 3.1.3 verifies this).\n  set ret [list]\n  db2 eval {SELECT i FROM seq} {\n    db eval {DELETE FROM seq WHERE i = :i}\n    lappend ret $i\n  }\n  set ret\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16}\ndo_test shared-$av.3.1.3 {\n  execsql {\n    SELECT * FROM seq;\n  }\n} {}\n\ncatch {db close}\ncatch {db2 close}\ncatch {db3 close}\n\n#--------------------------------------------------------------------------\n# Tests shared-4.* test that the schema locking rules are applied \n# correctly. i.e.:\n#\n# 1. All transactions require a read-lock on the schemas of databases they\n#    access.\n# 2. Transactions that modify a database schema require a write-lock on that\n#    schema.\n# 3. It is not possible to compile a statement while another handle has a \n#    write-lock on the schema.\n#\n\n# Open two database handles db and db2. Each has a single attach database\n# (as well as main):\n#\n#     db.main   ->   ./test.db\n#     db.test2  ->   ./test2.db\n#     db2.main  ->   ./test2.db\n#     db2.test  ->   ./test.db\n#\nforcedelete test.db\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db  test.db\nsqlite3 db2 test2.db\ndo_test shared-$av.4.1.1 {\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-($extrafds_prelock*2)\n} {2}\ndo_test shared-$av.4.1.2 {\n  execsql {ATTACH 'test2.db' AS test2}\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-($extrafds_postlock*2)\n} {2}\ndo_test shared-$av.4.1.3 {\n  execsql {ATTACH 'test.db' AS test} db2\n  set sqlite_open_file_count\n  expr $sqlite_open_file_count-($extrafds_postlock*2)\n} {2}\n\n# Sanity check: Create a table in ./test.db via handle db, and test that handle\n# db2 can \"see\" the new table immediately. A handle using a seperate pager\n# cache would have to reload the database schema before this were possible.\n#\ndo_test shared-$av.4.2.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE def(d, e, f);\n    INSERT INTO abc VALUES('i', 'ii', 'iii');\n    INSERT INTO def VALUES('I', 'II', 'III');\n  }\n} {}\ndo_test shared-$av.4.2.2 {\n  execsql {\n    SELECT * FROM test.abc;\n  } db2\n} {i ii iii}\n\n# Open a read-transaction and read from table abc via handle 2. Check that\n# handle 1 can read table abc. Check that handle 1 cannot modify table abc\n# or the database schema. Then check that handle 1 can modify table def.\n#\ndo_test shared-$av.4.3.1 {\n  execsql {\n    BEGIN;\n    SELECT * FROM test.abc;\n  } db2\n} {i ii iii}\ndo_test shared-$av.4.3.2 {\n  catchsql {\n    INSERT INTO abc VALUES('iv', 'v', 'vi');\n  }\n} {1 {database table is locked: abc}}\ndo_test shared-$av.4.3.3 {\n  catchsql {\n    CREATE TABLE ghi(g, h, i);\n  }\n} {1 {database table is locked: sqlite_master}}\ndo_test shared-$av.4.3.3 {\n  catchsql {\n    INSERT INTO def VALUES('IV', 'V', 'VI');\n  }\n} {0 {}}\ndo_test shared-$av.4.3.4 {\n  # Cleanup: commit the transaction opened by db2.\n  execsql {\n    COMMIT\n  } db2\n} {}\n\n# Open a write-transaction using handle 1 and modify the database schema.\n# Then try to execute a compiled statement to read from the same \n# database via handle 2 (fails to get the lock on sqlite_master). Also\n# try to compile a read of the same database using handle 2 (also fails).\n# Finally, compile a read of the other database using handle 2. This\n# should also fail.\n#\nifcapable compound {\n  do_test shared-$av.4.4.1.2 {\n    # Sanity check 1: Check that the schema is what we think it is when viewed\n    # via handle 1.\n    execsql {\n      CREATE TABLE test2.ghi(g, h, i);\n      SELECT 'test.db:'||name FROM sqlite_master \n      UNION ALL\n      SELECT 'test2.db:'||name FROM test2.sqlite_master;\n    }\n  } {test.db:abc test.db:def test2.db:ghi}\n  do_test shared-$av.4.4.1.2 {\n    # Sanity check 2: Check that the schema is what we think it is when viewed\n    # via handle 2.\n    execsql {\n      SELECT 'test2.db:'||name FROM sqlite_master \n      UNION ALL\n      SELECT 'test.db:'||name FROM test.sqlite_master;\n    } db2\n  } {test2.db:ghi test.db:abc test.db:def}\n}\n\ndo_test shared-$av.4.4.2 {\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set sql {SELECT * FROM abc}\n  set ::STMT1 [sqlite3_prepare $::DB2 $sql -1 DUMMY]\n  execsql {\n    BEGIN;\n    CREATE TABLE jkl(j, k, l);\n  }\n  sqlite3_step $::STMT1\n} {SQLITE_ERROR}\ndo_test shared-$av.4.4.3 {\n  sqlite3_finalize $::STMT1\n} {SQLITE_LOCKED}\ndo_test shared-$av.4.4.4 {\n  set rc [catch {\n    set ::STMT1 [sqlite3_prepare $::DB2 $sql -1 DUMMY]\n  } msg]\n  list $rc $msg\n} {1 {(6) database schema is locked: test}}\ndo_test shared-$av.4.4.5 {\n  set rc [catch {\n    set ::STMT1 [sqlite3_prepare $::DB2 \"SELECT * FROM ghi\" -1 DUMMY]\n  } msg]\n  list $rc $msg\n} {1 {(6) database schema is locked: test}}\n\n\ncatch {db2 close}\ncatch {db close}\n\n#--------------------------------------------------------------------------\n# Tests shared-5.* \n#\nforeach db [list test.db test1.db test2.db test3.db] {\n  forcedelete $db ${db}-journal\n}\ndo_test shared-$av.5.1.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n  execsql {\n    ATTACH 'test1.db' AS test1;\n    ATTACH 'test2.db' AS test2;\n    ATTACH 'test3.db' AS test3;\n  } db1\n  execsql {\n    ATTACH 'test3.db' AS test3;\n    ATTACH 'test2.db' AS test2;\n    ATTACH 'test1.db' AS test1;\n  } db2\n} {}\ndo_test shared-$av.5.1.2 {\n  execsql {\n    CREATE TABLE test1.t1(a, b);\n    CREATE INDEX test1.i1 ON t1(a, b);\n  } db1\n} {}\nifcapable view {\n  do_test shared-$av.5.1.3 {\n    execsql {\n      CREATE VIEW test1.v1 AS SELECT * FROM t1;\n    } db1\n  } {}\n}\nifcapable trigger {\n  do_test shared-$av.5.1.4 {\n    execsql {\n      CREATE TRIGGER test1.trig1 AFTER INSERT ON t1 BEGIN\n        INSERT INTO t1 VALUES(new.a, new.b);\n      END;\n    } db1\n  } {}\n}\ndo_test shared-$av.5.1.5 {\n  execsql {\n    DROP INDEX i1;\n  } db2\n} {}\nifcapable view {\n  do_test shared-$av.5.1.6 {\n    execsql {\n      DROP VIEW v1;\n    } db2\n  } {}\n}\nifcapable trigger {\n  do_test shared-$av.5.1.7 {\n    execsql {\n      DROP TRIGGER trig1;\n    } db2\n  } {}\n}\ndo_test shared-$av.5.1.8 {\n  execsql {\n    DROP TABLE t1;\n  } db2\n} {}\nifcapable compound {\n  do_test shared-$av.5.1.9 {\n    execsql {\n      SELECT * FROM sqlite_master UNION ALL SELECT * FROM test1.sqlite_master\n    } db1\n  } {}\n}\n\n#--------------------------------------------------------------------------\n# Tests shared-6.* test that a query obtains all the read-locks it needs\n# before starting execution of the query. This means that there is no chance\n# some rows of data will be returned before a lock fails and SQLITE_LOCK\n# is returned.\n#\ndo_test shared-$av.6.1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t2 VALUES(3, 4);\n  } db1\n} {}\nifcapable compound {\n  do_test shared-$av.6.1.2 {\n    execsql {\n      SELECT * FROM t1 UNION ALL SELECT * FROM t2;\n    } db2\n  } {1 2 3 4}\n}\ndo_test shared-$av.6.1.3 {\n  # Establish a write lock on table t2 via connection db2. Then make a \n  # UNION all query using connection db1 that first accesses t1, followed \n  # by t2. If the locks are grabbed at the start of the statement (as \n  # they should be), no rows are returned. If (as was previously the case)\n  # they are grabbed as the tables are accessed, the t1 rows will be \n  # returned before the query fails.\n  #\n  execsql {\n    BEGIN;\n    INSERT INTO t2 VALUES(5, 6);\n  } db2\n  set ret [list]\n  catch {\n    db1 eval {SELECT * FROM t1 UNION ALL SELECT * FROM t2} {\n      lappend ret $a $b\n    }\n  }\n  set ret\n} {}\ndo_test shared-$av.6.1.4 {\n  execsql {\n    COMMIT;\n    BEGIN;\n    INSERT INTO t1 VALUES(7, 8);\n  } db2\n  set ret [list]\n  catch {\n    db1 eval {\n      SELECT (CASE WHEN a>4 THEN (SELECT a FROM t1) ELSE 0 END) AS d FROM t2;\n    } {\n      lappend ret $d\n    }\n  }\n  set ret\n} {}\n\ncatch {db1 close}\ncatch {db2 close}\nforeach f [list test.db test2.db] {\n  forcedelete $f ${f}-journal\n}\n\n#--------------------------------------------------------------------------\n# Tests shared-7.* test auto-vacuum does not invalidate cursors from\n# other shared-cache users when it reorganizes the database on \n# COMMIT.\n#\ndo_test shared-$av.7.1 {\n  # This test case sets up a test database in auto-vacuum mode consisting \n  # of two tables, t1 and t2. Both have a single index. Table t1 is \n  # populated first (so consists of pages toward the start of the db file), \n  # t2 second (pages toward the end of the file). \n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE t2(a PRIMARY KEY, b);\n  }\n  set ::contents {}\n  for {set i 0} {$i < 100} {incr i} {\n    set a [string repeat \"$i \" 20]\n    set b [string repeat \"$i \" 20]\n    db eval {\n      INSERT INTO t1 VALUES(:a, :b);\n    }\n    lappend ::contents [list [expr $i+1] $a $b]\n  }\n  execsql {\n    INSERT INTO t2 SELECT * FROM t1;\n    COMMIT;\n  }\n} {}\ndo_test shared-$av.7.2 {\n  # This test case deletes the contents of table t1 (the one at the start of\n  # the file) while many cursors are open on table t2 and its index. All of\n  # the non-root pages will be moved from the end to the start of the file\n  # when the DELETE is committed - this test verifies that moving the pages\n  # does not disturb the open cursors.\n  #\n\n  proc lockrow {db tbl oids body} {\n    set ret [list]\n    db eval \"SELECT oid AS i, a, b FROM $tbl ORDER BY a\" {\n      if {$i==[lindex $oids 0]} {\n        set noids [lrange $oids 1 end]\n        if {[llength $noids]==0} {\n          set subret [eval $body]\n        } else {\n          set subret [lockrow $db $tbl $noids $body]\n        }\n      }\n      lappend ret [list $i $a $b]\n    }\n    return [linsert $subret 0 $ret]\n  }\n  proc locktblrows {db tbl body} {\n    set oids [db eval \"SELECT oid FROM $tbl\"]\n    lockrow $db $tbl $oids $body\n  }\n\n  set scans [locktblrows db t2 {\n    execsql {\n      DELETE FROM t1;\n    } db2\n  }]\n  set error 0\n\n  # Test that each SELECT query returned the expected contents of t2.\n  foreach s $scans {\n    if {[lsort -integer -index 0 $s]!=$::contents} {\n      set error 1\n    }\n  }\n  set error\n} {0}\n\ncatch {db close}\ncatch {db2 close}\nunset -nocomplain contents\n\n#--------------------------------------------------------------------------\n# The following tests try to trick the shared-cache code into assuming\n# the wrong encoding for a database.\n#\nforcedelete test.db test.db-journal\nifcapable utf16 {\n  do_test shared-$av.8.1.1 {\n    sqlite3 db test.db\n    execsql {\n      PRAGMA encoding = 'UTF-16';\n      SELECT * FROM sqlite_master;\n    }\n  } {}\n  do_test shared-$av.8.1.2 {\n    string range [execsql {PRAGMA encoding;}] 0 end-2\n  } {UTF-16}\n\n  do_test shared-$av.8.1.3 {\n    sqlite3 db2 test.db\n    execsql {\n      PRAGMA encoding = 'UTF-8';\n      CREATE TABLE abc(a, b, c);\n    } db2\n  } {}\n  do_test shared-$av.8.1.4 {\n    execsql {\n      SELECT * FROM sqlite_master;\n    }\n  } \"table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}\"\n  do_test shared-$av.8.1.5 {\n    db2 close\n    execsql {\n      PRAGMA encoding;\n    }\n  } {UTF-8}\n\n  forcedelete test2.db test2.db-journal\n  do_test shared-$av.8.2.1 {\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      SELECT * FROM aux.sqlite_master;\n    }\n  } {}\n  do_test shared-$av.8.2.2 {\n    sqlite3 db2 test2.db\n    execsql {\n      PRAGMA encoding = 'UTF-16';\n      CREATE TABLE def(d, e, f);\n    } db2\n    string range [execsql {PRAGMA encoding;} db2] 0 end-2\n  } {UTF-16}\n\n  catch {db close}\n  catch {db2 close}\n  forcedelete test.db test2.db\n\n  do_test shared-$av.8.3.2 {\n    sqlite3 db test.db\n    execsql { CREATE TABLE def(d, e, f) }\n    execsql { PRAGMA encoding }\n  } {UTF-8}\n  do_test shared-$av.8.3.3 {\n    set zDb16 \"[encoding convertto unicode test.db]\\x00\\x00\"\n    set db16 [sqlite3_open16 $zDb16 {}]\n\n    set stmt [sqlite3_prepare $db16 \"SELECT sql FROM sqlite_master\" -1 DUMMY]\n    sqlite3_step $stmt\n    set sql [sqlite3_column_text $stmt 0]\n    sqlite3_finalize $stmt\n    set sql\n  } {CREATE TABLE def(d, e, f)}\n  do_test shared-$av.8.3.4 {\n    set stmt [sqlite3_prepare $db16 \"PRAGMA encoding\" -1 DUMMY]\n    sqlite3_step $stmt\n    set enc [sqlite3_column_text $stmt 0]\n    sqlite3_finalize $stmt\n    set enc\n  } {UTF-8}\n\n  sqlite3_close $db16\n\n# Bug #2547 is causing this to fail.\nif 0 {\n  do_test shared-$av.8.2.3 {\n    catchsql {\n      SELECT * FROM aux.sqlite_master;\n    }\n  } {1 {attached databases must use the same text encoding as main database}}\n}\n}\n\ncatch {db close}\ncatch {db2 close}\nforcedelete test.db test2.db\n\n#---------------------------------------------------------------------------\n# The following tests - shared-9.* - test interactions between TEMP triggers\n# and shared-schemas.\n#\nifcapable trigger&&tempdb {\n\ndo_test shared-$av.9.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE abc_mirror(a, b, c);\n    CREATE TEMP TRIGGER BEFORE INSERT ON abc BEGIN \n      INSERT INTO abc_mirror(a, b, c) VALUES(new.a, new.b, new.c);\n    END;\n    INSERT INTO abc VALUES(1, 2, 3);\n    SELECT * FROM abc_mirror;\n  }\n} {1 2 3}\ndo_test shared-$av.9.2 {\n  execsql {\n    INSERT INTO abc VALUES(4, 5, 6);\n    SELECT * FROM abc_mirror;\n  } db2\n} {1 2 3}\ndo_test shared-$av.9.3 {\n  db close\n  db2 close\n} {}\n\n} ; # End shared-9.*\n\n#---------------------------------------------------------------------------\n# The following tests - shared-10.* - test that the library behaves \n# correctly when a connection to a shared-cache is closed. \n#\ndo_test shared-$av.10.1 {\n  # Create a small sample database with two connections to it (db and db2).\n  forcedelete test.db\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n  execsql {\n    CREATE TABLE ab(a PRIMARY KEY, b);\n    CREATE TABLE de(d PRIMARY KEY, e);\n    INSERT INTO ab VALUES('Chiang Mai', 100000);\n    INSERT INTO ab VALUES('Bangkok', 8000000);\n    INSERT INTO de VALUES('Ubon', 120000);\n    INSERT INTO de VALUES('Khon Kaen', 200000);\n  }\n} {}\ndo_test shared-$av.10.2 {\n  # Open a read-transaction with the first connection, a write-transaction\n  # with the second.\n  execsql {\n    BEGIN;\n    SELECT * FROM ab;\n  }\n  execsql {\n    BEGIN;\n    INSERT INTO de VALUES('Pataya', 30000);\n  } db2\n} {}\ndo_test shared-$av.10.3 {\n  # An external connection should be able to read the database, but not\n  # prepare a write operation.\n  if {$::tcl_platform(platform)==\"unix\"} {\n    sqlite3 db3 ./test.db\n  } else {\n    sqlite3 db3 TEST.DB\n  }\n  execsql {\n    SELECT * FROM ab;\n  } db3\n  catchsql {\n    BEGIN;\n    INSERT INTO de VALUES('Pataya', 30000);\n  } db3\n} {1 {database is locked}}\ndo_test shared-$av.10.4 {\n  # Close the connection with the write-transaction open\n  db2 close\n} {}\ndo_test shared-$av.10.5 {\n  # Test that the db2 transaction has been automatically rolled back.\n  # If it has not the ('Pataya', 30000) entry will still be in the table.\n  execsql {\n    SELECT * FROM de;\n  }\n} {Ubon 120000 {Khon Kaen} 200000}\ndo_test shared-$av.10.5 {\n  # Closing db2 should have dropped the shared-cache back to a read-lock.\n  # So db3 should be able to prepare a write...\n  catchsql {INSERT INTO de VALUES('Pataya', 30000);} db3\n} {0 {}}\ndo_test shared-$av.10.6 {\n  # ... but not commit it.\n  catchsql {COMMIT} db3\n} {1 {database is locked}}\ndo_test shared-$av.10.7 {\n  # Commit the (read-only) db transaction. Check via db3 to make sure the \n  # contents of table \"de\" are still as they should be.\n  execsql {\n    COMMIT;\n  }\n  execsql {\n    SELECT * FROM de;\n  } db3\n} {Ubon 120000 {Khon Kaen} 200000 Pataya 30000}\ndo_test shared-$av.10.9 {\n  # Commit the external transaction.\n  catchsql {COMMIT} db3\n} {0 {}}\nintegrity_check shared-$av.10.10\ndo_test shared-$av.10.11 {\n  db close\n  db3 close\n} {}\n\ndo_test shared-$av.11.1 {\n  forcedelete test.db\n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE TABLE abc2(a, b, c);\n    BEGIN;\n    INSERT INTO abc VALUES(1, 2, 3);\n  }\n} {}\ndo_test shared-$av.11.2 {\n  catchsql {BEGIN;} db2\n  catchsql {SELECT * FROM abc;} db2\n} {1 {database table is locked: abc}}\ndo_test shared-$av.11.3 {\n  catchsql {BEGIN} db2\n} {1 {cannot start a transaction within a transaction}}\ndo_test shared-$av.11.4 {\n  catchsql {SELECT * FROM abc2;} db2\n} {0 {}}\ndo_test shared-$av.11.5 {\n  catchsql {INSERT INTO abc2 VALUES(1, 2, 3);} db2\n} {1 {database table is locked}}\ndo_test shared-$av.11.6 {\n  catchsql {SELECT * FROM abc2}\n} {0 {}}\ndo_test shared-$av.11.6 {\n  execsql {\n    ROLLBACK;\n    PRAGMA read_uncommitted = 1;\n  } db2\n} {}\ndo_test shared-$av.11.7 {\n  execsql {\n    INSERT INTO abc2 VALUES(4, 5, 6);\n    INSERT INTO abc2 VALUES(7, 8, 9);\n  }\n} {}\ndo_test shared-$av.11.8 {\n  set res [list]\n  db2 eval {\n    SELECT abc.a as I, abc2.a as II FROM abc, abc2;\n  } {\n    execsql {\n      DELETE FROM abc WHERE 1;\n    }\n    lappend res $I $II\n  }\n  set res\n} {1 4 {} 7}\nif {[llength [info command sqlite3_shared_cache_report]]==1} {\n  ifcapable curdir {\n    do_test shared-$av.11.9 {\n      string tolower [sqlite3_shared_cache_report]\n    } [string tolower [list [file nativename [file normalize test.db]] 2]]\n  }\n}\n\ndo_test shared-$av.11.11 {\n  db close\n  db2 close\n} {}\n\n# This tests that if it is impossible to free any pages, SQLite will\n# exceed the limit set by PRAGMA cache_size.\nforcedelete test.db test.db-journal\nsqlite3 db test.db \nifcapable pager_pragmas {\n  do_test shared-$av.12.1 {\n    execsql {\n      PRAGMA cache_size = 10;\n      PRAGMA cache_size;\n    }\n  } {10}\n}\ndo_test shared-$av.12.2 {\n  set ::db_handles [list]\n  for {set i 1} {$i < 15} {incr i} {\n    lappend ::db_handles db$i\n    sqlite3 db$i test.db \n    execsql \"CREATE TABLE db${i}(a, b, c)\" db$i \n    execsql \"INSERT INTO db${i} VALUES(1, 2, 3)\"\n  }\n} {}\nproc nested_select {handles} {\n  [lindex $handles 0] eval \"SELECT * FROM [lindex $handles 0]\" {\n    lappend ::res $a $b $c\n    if {[llength $handles]>1} {\n      nested_select [lrange $handles 1 end]\n    }\n  }\n}\ndo_test shared-$av.12.3 {\n  set ::res [list]\n  nested_select $::db_handles\n  set ::res\n} [string range [string repeat \"1 2 3 \" [llength $::db_handles]] 0 end-1]\n\ndo_test shared-$av.12.X {\n  db close\n  foreach h $::db_handles { \n    $h close\n  }\n} {}\n\n# Internally, locks are acquired on shared B-Tree structures in the order\n# that the structures appear in the virtual memory address space. This\n# test case attempts to cause the order of the structures in memory \n# to be different from the order in which they are attached to a given\n# database handle. This covers an extra line or two.\n#\ndo_test shared-$av.13.1 {\n  forcedelete test2.db test3.db test4.db test5.db\n  sqlite3 db :memory:\n  execsql {\n    ATTACH 'test2.db' AS aux2;\n    ATTACH 'test3.db' AS aux3;\n    ATTACH 'test4.db' AS aux4;\n    ATTACH 'test5.db' AS aux5;\n    DETACH aux2;\n    DETACH aux3;\n    DETACH aux4;\n    ATTACH 'test2.db' AS aux2;\n    ATTACH 'test3.db' AS aux3;\n    ATTACH 'test4.db' AS aux4;\n  }\n} {}\ndo_test shared-$av.13.2 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE aux2.t2(a, b, c);\n    CREATE TABLE aux3.t3(a, b, c);\n    CREATE TABLE aux4.t4(a, b, c);\n    CREATE TABLE aux5.t5(a, b, c);\n    SELECT count(*) FROM \n      aux2.sqlite_master, \n      aux3.sqlite_master, \n      aux4.sqlite_master, \n      aux5.sqlite_master\n  }\n} {1}\ndo_test shared-$av.13.3 {\n  db close\n} {}\n\n# Test that nothing horrible happens if a connection to a shared B-Tree \n# structure is closed while some other connection has an open cursor.\n#\ndo_test shared-$av.14.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {SELECT name FROM sqlite_master}\n} {db1 db2 db3 db4 db5 db6 db7 db8 db9 db10 db11 db12 db13 db14}\ndo_test shared-$av.14.2 {\n  set res [list]\n  db eval {SELECT name FROM sqlite_master} {\n    if {$name eq \"db7\"} {\n      db2 close\n    }\n    lappend res $name\n  }\n  set res\n} {db1 db2 db3 db4 db5 db6 db7 db8 db9 db10 db11 db12 db13 db14}\ndo_test shared-$av.14.3 {\n  db close\n} {}\n\n# Populate a database schema using connection [db]. Then drop it using\n# [db2]. This is to try to find any points where shared-schema elements\n# are allocated using the lookaside buffer of [db].\n# \n# Mutexes are enabled for this test as that activates a couple of useful\n# assert() statements in the C code.\n#\ndo_test shared-$av-15.1 {\n  forcedelete test.db\n  sqlite3 db test.db -fullmutex 1\n  sqlite3 db2 test.db -fullmutex 1\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(a, b);\n    CREATE VIEW v1 AS SELECT * FROM t1; \n    CREATE VIEW v2 AS SELECT * FROM t1, v1 \n                      WHERE t1.c=v1.c GROUP BY t1.a ORDER BY v1.b; \n    CREATE TRIGGER tr1 AFTER INSERT ON t1 \n      WHEN new.a!=1\n    BEGIN\n      DELETE FROM t1 WHERE a=5;\n      INSERT INTO t1 VALUES(1, 2, 3);\n      UPDATE t1 SET c=c+1;\n    END;\n\n    INSERT INTO t1 VALUES(5, 6, 7);\n    INSERT INTO t1 VALUES(8, 9, 10);\n    INSERT INTO t1 VALUES(11, 12, 13);\n    ANALYZE;\n    SELECT * FROM t1;\n  }\n} {1 2 6 8 9 12 1 2 5 11 12 14 1 2 4}\ndo_test shared-$av-15.2 {\n  execsql { DROP TABLE t1 } db2\n} {}\ndb close\ndb2 close\n\n# Shared cache on a :memory: database.  This only works for URI filenames.\n#\ndo_test shared-$av-16.1 {\n  sqlite3 db1 file::memory: -uri 1\n  sqlite3 db2 file::memory: -uri 1\n  db1 eval {\n    CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);\n  }\n  db2 eval {\n    SELECT x FROM t1 ORDER BY x;\n  }\n} {1 2 3}\ndo_test shared-$av-16.2 {\n  db2 eval {\n    INSERT INTO t1 VALUES(99);\n    DELETE FROM t1 WHERE x=2;\n  }\n  db1 eval {\n    SELECT x FROM t1 ORDER BY x;\n  }\n} {1 3 99}\n\n# Verify that there is no cache sharing ordinary (non-URI) filenames are\n# used.\n#\ndo_test shared-$av-16.3 {\n  db1 close\n  db2 close\n  sqlite3 db1 :memory:\n  sqlite3 db2 :memory:\n  db1 eval {\n    CREATE TABLE t1(x); INSERT INTO t1 VALUES(4),(5),(6);\n  }\n  catchsql {\n    SELECT * FROM t1;\n  } db2\n} {1 {no such table: t1}}\n\n# Shared cache on named memory databases.\n#\ndo_test shared-$av-16.4 {\n  db1 close\n  db2 close\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db1 file:test.db?mode=memory -uri 1\n  sqlite3 db2 file:test.db?mode=memory -uri 1\n  db1 eval {\n    CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);\n  }\n  db2 eval {\n    SELECT x FROM t1 ORDER BY x;\n  }\n} {1 2 3}\ndo_test shared-$av-16.5 {\n  db2 eval {\n    INSERT INTO t1 VALUES(99);\n    DELETE FROM t1 WHERE x=2;\n  }\n  db1 eval {\n    SELECT x FROM t1 ORDER BY x;\n  }\n} {1 3 99}\ndo_test shared-$av-16.6 {\n  file exists test.db\n} {0}  ;# Verify that the database is in-memory\n\n# Shared cache on named memory databases with different names.\n#\ndo_test shared-$av-16.7 {\n  db1 close\n  db2 close\n  forcedelete test1.db test2.db\n  sqlite3 db1 file:test1.db?mode=memory -uri 1\n  sqlite3 db2 file:test2.db?mode=memory -uri 1\n  db1 eval {\n    CREATE TABLE t1(x); INSERT INTO t1 VALUES(1),(2),(3);\n  }\n  catchsql {\n    SELECT x FROM t1 ORDER BY x;\n  } db2\n} {1 {no such table: t1}}\ndo_test shared-$av-16.8 {\n  file exists test1.db\n} {0}  ;# Verify that the database is in-memory\n\n# Shared cache on named memory databases attached to readonly connections.\n#\ndo_test shared-$av-16.8.1 {\n  db1 close\n  db2 close\n\n  sqlite3 db test1.db\n  db eval { \n    CREATE TABLE yy(a, b);\n    INSERT INTO yy VALUES(77, 88);\n  }\n  db close\n\n  sqlite3 db1 test1.db -uri 1 -readonly 1\n  sqlite3 db2 test2.db -uri 1 \n\n  db1 eval { \n    ATTACH 'file:mem?mode=memory&cache=shared' AS shared; \n    CREATE TABLE shared.xx(a, b);\n    INSERT INTO xx VALUES(55, 66);\n  }\n  db2 eval { \n    ATTACH 'file:mem?mode=memory&cache=shared' AS shared;\n    SELECT * FROM xx;\n  }\n} {55 66}\n\ndo_test shared-$av-16.8.2 { db1 eval { SELECT * FROM yy } } {77 88}\ndo_test shared-$av-16.8.3 { \n  list [catch {db1 eval { INSERT INTO yy VALUES(1, 2) }} msg] $msg\n} {1 {attempt to write a readonly database}}\n\ndb1 close\ndb2 close\n\n}  ;# end of autovacuum on/off loop\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared2.test",
    "content": "# 2005 January 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: shared2.test,v 1.8 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\ndb close\n\nifcapable !shared_cache {\n  finish_test\n  return\n}\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Test that if we delete all rows from a table any read-uncommitted \n# cursors are correctly invalidated. Test on both table and index btrees.\ndo_test shared2-1.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n\n  # Set up some data. Table \"numbers\" has 64 rows after this block \n  # is executed.\n  execsql {\n    BEGIN;\n    CREATE TABLE numbers(a PRIMARY KEY, b);\n    INSERT INTO numbers(oid) VALUES(NULL);\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    INSERT INTO numbers(oid) SELECT NULL FROM numbers;\n    UPDATE numbers set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';\n    COMMIT;\n  } db1\n} {}\ndo_test shared2-1.2 {\n  # Put connection 2 in read-uncommitted mode and start a SELECT on table \n  # 'numbers'. Half way through the SELECT, use connection 1 to delete the\n  # contents of this table.\n  execsql {\n    pragma read_uncommitted = 1;\n  } db2\n  set count [execsql {SELECT count(*) FROM numbers} db2]\n  db2 eval {SELECT a FROM numbers ORDER BY oid} {\n    if {$a==32} {\n      execsql {\n        BEGIN;\n        DELETE FROM numbers;\n      } db1\n    }\n  }\n  list $a $count\n} {32 64}\ndo_test shared2-1.3 {\n  # Same test as 1.2, except scan using the index this time.\n  execsql {\n    ROLLBACK;\n  } db1\n  set count [execsql {SELECT count(*) FROM numbers} db2]\n  db2 eval {SELECT a, b FROM numbers ORDER BY a} {\n    if {$a==32} {\n      execsql {\n        DELETE FROM numbers;\n      } db1\n    }\n  }\n  list $a $count\n} {32 64}\n\n\ndb1 close\ndb2 close\n\ndo_test shared2-3.2 {\n  sqlite3_enable_shared_cache 1\n} {1}\n\nforcedelete test.db\n\nsqlite3 db test.db\ndo_test shared2-4.1 {\n  execsql {\n    CREATE TABLE t0(a, b);\n    CREATE TABLE t1(a, b DEFAULT 'hello world');\n  }\n} {}\ndb close\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test shared2-4.2 {\n  execsql { SELECT a, b FROM t0 } db\n  execsql { INSERT INTO t1(a) VALUES(1) } db2\n} {}\n\ndo_test shared2-4.3 {\n  db2 close\n  db close\n} {}\n\n# At one point, this was causing a crash.\n#\ndo_test shared2-5.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql { CREATE TABLE t2(a, b, c) }\n  \n  # The following statement would crash when attempting to sqlite3_free()\n  # a pointer allocated from a lookaside buffer.\n  execsql { CREATE INDEX i1 ON t2(a) } db2\n} {}\n\ndb close\ndb2 close\n\n# The following test verifies that shared-cache mode does not automatically\n# turn on exclusive-locking mode for some reason.\ndo_multiclient_test {tn} {\n  sql1 { CREATE TABLE t1(a, b) }\n  sql2 { CREATE TABLE t2(a, b) }\n  do_test shared2-6.$tn.1 { sql1 { SELECT * FROM t2 } } {}\n  do_test shared2-6.$tn.2 { sql2 { SELECT * FROM t1 } } {}\n}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared3.test",
    "content": "# 2005 January 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: shared3.test,v 1.4 2008/08/20 14:49:25 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix shared3\ndb close\n\nifcapable !shared_cache {\n  finish_test\n  return\n}\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Ticket #1824\n#\ndo_test shared3-1.1 {\n  forcedelete test.db test.db-journal\n  sqlite3 db1 test.db\n  db1 eval {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES('abc','This is a test string');\n  }\n  db1 close\n  sqlite3 db1 test.db\n  db1 eval {SELECT * FROM t1}\n} {abc {This is a test string}}\ndo_test shared3-1.2 {\n  sqlite3 db2 test.db\n  db2 eval {SELECT y FROM t1 WHERE x='abc'}\n} {{This is a test string}}\n\ndb1 close\ndb2 close\n\ndo_test shared3-2.1 {\n  sqlite3 db1 test.db\n  execsql {\n    PRAGMA main.cache_size = 10;\n  } db1\n} {}\ndo_test shared3-2.2 {\n  execsql { PRAGMA main.cache_size } db1\n} {10}\ndo_test shared3-2.3 {\n  sqlite3 db2 test.db\n  execsql { PRAGMA main.cache_size } db1\n} {10}\ndo_test shared3-2.4 {\n  execsql { PRAGMA main.cache_size } db2\n} {10}\ndo_test shared3-2.5 {\n  execsql { PRAGMA main.cache_size } db1\n} {10}\n\n# The cache-size should now be 10 pages. However at one point there was\n# a bug that caused the cache size to return to the default value when\n# a second connection was opened on the shared-cache (as happened in\n# test case shared3-2.3 above). The goal of the following tests is to\n# ensure that the cache-size really is 10 pages.\n#\nif {$::tcl_platform(platform)==\"unix\"} {\n  set alternative_name ./test.db\n} else {\n  set alternative_name TEST.DB\n}\ndo_test shared3-2.6 {\n  sqlite3 db3 $alternative_name\n  catchsql {select count(*) from sqlite_master} db3\n} {0 1}\ndo_test shared3-2.7 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(10, randomblob(5000))\n  } db1\n  catchsql {select count(*) from sqlite_master} db3\n} {0 1}\ndo_test shared3-2.8 {\n  db3 close\n  execsql {\n    INSERT INTO t1 VALUES(10, randomblob(10000))\n  } db1\n\n  # If the pager-cache is really still limited to 10 pages, then the INSERT\n  # statement above should have caused the pager to grab an exclusive lock\n  # on the database file so that the cache could be spilled.\n  #\n  catch { sqlite3 db3 $alternative_name }\n  catchsql {select count(*) from sqlite_master} db3\n} {1 {database is locked}}\n\ndb1 close\ndb2 close\ndb3 close\n\n#-------------------------------------------------------------------------\n# At one point this was causing a faulty assert to fail.\n#\nforcedelete test.db\nsqlite3 db test.db\nsqlite3 db2 test.db\ndo_execsql_test 3.1 {\n  PRAGMA auto_vacuum = 2;\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(randomblob(500), randomblob(500));\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n  INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;\n}\ndo_test 3.2 {\n  execsql { SELECT count(*) FROM sqlite_master } db2\n} {1}\ndo_execsql_test 3.3 {\n  BEGIN;\n    DELETE FROM t1 WHERE 1;\n    PRAGMA incremental_vacuum;\n} {}\ndo_test 3.4 {\n  execsql { SELECT count(*) FROM sqlite_master } db2\n} {1}\ndo_test 3.5 {\n  execsql { COMMIT }\n} {}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared4.test",
    "content": "# 2008 July 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the btree mutex protocol for shared cache mode.\n#\n# $Id: shared4.test,v 1.2 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndb close\n\n# This script is only valid if we are running shared-cache mode in a\n# threadsafe-capable database engine.\n#\nifcapable !shared_cache||!compound {\n  finish_test\n  return\n}\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Prepare multiple databases in shared cache mode.\n#\ndo_test shared4-1.1 {\n  forcedelete test1.db test1.db-journal\n  forcedelete test2.db test2.db-journal\n  forcedelete test3.db test3.db-journal\n  forcedelete test4.db test4.db-journal\n  sqlite3 db1 test1.db\n  sqlite3 db2 test2.db\n  sqlite3 db3 test3.db\n  sqlite3 db4 test4.db\n  db1 eval {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(111);\n  }\n  db2 eval {\n    CREATE TABLE t2(b);\n    INSERT INTO t2 VALUES(222);\n  }\n  db3 eval {\n    CREATE TABLE t3(c);\n    INSERT INTO t3 VALUES(333);\n  }\n  db4 eval {\n    CREATE TABLE t4(d);\n    INSERT INTO t4 VALUES(444);\n  }\n  db1 eval {\n    ATTACH DATABASE 'test2.db' AS two;\n    ATTACH DATABASE 'test3.db' AS three;\n    ATTACH DATABASE 'test4.db' AS four;\n  }\n  db2 eval {\n    ATTACH DATABASE 'test4.db' AS four;\n    ATTACH DATABASE 'test3.db' AS three;\n    ATTACH DATABASE 'test1.db' AS one;\n  }\n  db3 eval {\n    ATTACH DATABASE 'test1.db' AS one;\n    ATTACH DATABASE 'test2.db' AS two;\n    ATTACH DATABASE 'test4.db' AS four;\n  }\n  db4 eval {\n    ATTACH DATABASE 'test3.db' AS three;\n    ATTACH DATABASE 'test2.db' AS two;\n    ATTACH DATABASE 'test1.db' AS one;\n  }\n  db1 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4;\n  }\n} {111 222 333 444}\ndo_test shared4-1.2 {\n  db2 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT c FROM t3;\n  }\n} {111 222 444 333}\ndo_test shared4-1.3 {\n  db3 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT d FROM t4;\n  }\n} {111 333 222 444}\ndo_test shared4-1.4 {\n  db4 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT b FROM t2;\n  }\n} {111 333 444 222}\ndo_test shared4-1.5 {\n  db3 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT c FROM t3;\n  }\n} {111 444 222 333}\ndo_test shared4-1.6 {\n  db4 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT b FROM t2;\n  }\n} {111 444 333 222}\ndo_test shared4-1.7 {\n  db1 eval {\n     SELECT b FROM t2 UNION ALL\n     SELECT a FROM t1 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4;\n  }\n} {222 111 333 444}\ndo_test shared4-1.8 {\n  db2 eval {\n     SELECT b FROM t2 UNION ALL\n     SELECT a FROM t1 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT c FROM t3;\n  }\n} {222 111 444 333}\ndo_test shared4-1.9 {\n  db3 eval {\n     SELECT b FROM t2 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT a FROM t1 UNION ALL\n     SELECT d FROM t4;\n  }\n} {222 333 111 444}\ndo_test shared4-1.10 {\n  db4 eval {\n     SELECT b FROM t2 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT a FROM t1;\n  }\n} {222 333 444 111}\ndo_test shared4-1.11 {\n  db1 eval {\n     SELECT c FROM t3 UNION ALL\n     SELECT a FROM t1 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT d FROM t4;\n  }\n} {333 111 222 444}\ndo_test shared4-1.12 {\n  db2 eval {\n     SELECT c FROM t3 UNION ALL\n     SELECT a FROM t1 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT b FROM t2;\n  }\n} {333 111 444 222}\n\ndo_test shared4-2.1 {\n  db1 eval {\n    UPDATE t1 SET a=a+1000;\n    UPDATE t2 SET b=b+2000;\n    UPDATE t3 SET c=c+3000;\n    UPDATE t4 SET d=d+4000;\n  }\n  db2 eval {\n    UPDATE t1 SET a=a+10000;\n    UPDATE t2 SET b=b+20000;\n    UPDATE t3 SET c=c+30000;\n    UPDATE t4 SET d=d+40000;\n  }\n  db3 eval {\n    UPDATE t1 SET a=a+100000;\n    UPDATE t2 SET b=b+200000;\n    UPDATE t3 SET c=c+300000;\n    UPDATE t4 SET d=d+400000;\n  }\n  db4 eval {\n    UPDATE t1 SET a=a+1000000;\n    UPDATE t2 SET b=b+2000000;\n    UPDATE t3 SET c=c+3000000;\n    UPDATE t4 SET d=d+4000000;\n  }\n  db1 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4;\n  }\n} {1111111 2222222 3333333 4444444}\ndo_test shared4-2.2 {\n  db2 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT c FROM t3;\n  }\n} {1111111 2222222 4444444 3333333}\ndo_test shared4-2.3 {\n  db3 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT b FROM t2 UNION ALL\n     SELECT d FROM t4;\n  }\n} {1111111 3333333 2222222 4444444}\ndo_test shared4-2.4 {\n  db4 eval {\n     SELECT a FROM t1 UNION ALL\n     SELECT c FROM t3 UNION ALL\n     SELECT d FROM t4 UNION ALL\n     SELECT b FROM t2;\n  }\n} {1111111 3333333 4444444 2222222}\n\n\ndb1 close\ndb2 close\ndb3 close\ndb4 close\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared6.test",
    "content": "# 2009 April 01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: shared6.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !shared_cache { finish_test ; return }\n\ndo_test shared6-1.1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(c, d);\n    CREATE TABLE t3(e, f);\n  }\n  db close\n} {}\ndo_test shared6-1.1.2 {\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n  sqlite3_enable_shared_cache\n} {1}\n\ndo_test shared6-1.1.3 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n} {}\n\n# Exclusive shared-cache locks. Test the following:\n#\n#   1.2.1: If [db1] has an exclusive lock, [db2] cannot read.\n#   1.2.2: If [db1] has an exclusive lock, [db1] can read.\n#   1.2.3: If [db1] has a non-exclusive write-lock, [db2] can read.\n# \ndo_test shared6-1.2.1 {\n  execsql { SELECT * FROM t1 } db2    ;# Cache a compiled statement\n  execsql { BEGIN EXCLUSIVE } db1\n  catchsql { SELECT * FROM t1 } db2   ;# Execute the cached compiled statement\n} {1 {database table is locked}}\ndo_test shared6-1.2.2 {\n  execsql { SELECT * FROM t1 } db1\n} {}\ndo_test shared6-1.2.3 {\n  execsql {\n    COMMIT;\n    BEGIN;\n    INSERT INTO t2 VALUES(3, 4);\n  } db1\n  execsql { SELECT * FROM t1 } db2\n} {}\ndo_test shared6-1.2.X {\n  execsql { COMMIT } db1\n} {}\n\n# Regular shared-cache locks. Verify the following:\n#\n#   1.3.1: If [db1] has a write-lock on t1, [db1] can read from t1.\n#   1.3.2: If [db1] has a write-lock on t1, [db2] can read from t2.\n#   1.3.3: If [db1] has a write-lock on t1, [db2] cannot read from t1.\n#   1.3.4: If [db1] has a write-lock on t1, [db2] cannot write to t1.\n#   1.3.5: If [db1] has a read-lock on t1, [db2] can read from t1.\n#   1.3.6: If [db1] has a read-lock on t1, [db2] cannot write to t1.\n#\ndo_test shared6-1.3.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  } db1\n  execsql { SELECT * FROM t1 } db1\n} {1 2}\ndo_test shared6-1.3.2 {\n  execsql { SELECT * FROM t2 } db2\n} {3 4}\ndo_test shared6-1.3.3 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked: t1}}\ndo_test shared6-1.3.4 {\n  catchsql { INSERT INTO t2 VALUES(1, 2) } db2\n} {1 {database table is locked}}\ndo_test shared6-1.3.5 {\n  execsql {\n    COMMIT;\n    BEGIN;\n    SELECT * FROM t1;\n  } db1\n  execsql { SELECT * FROM t1 } db2\n} {1 2}\ndo_test shared6-1.3.5 {\n  catchsql { INSERT INTO t1 VALUES(5, 6) } db2\n} {1 {database table is locked: t1}}\ndo_test shared6-1.3.X {\n  execsql { COMMIT } db1\n} {}\n\n# Read-uncommitted mode.\n#\n# For these tests, connection [db2] is in read-uncommitted mode.\n#\n#   1.4.1: If [db1] has a write-lock on t1, [db2] can still read from t1.\n#   1.4.2: If [db1] has a write-lock on the db schema (sqlite_master table), \n#          [db2] cannot read from the schema.\n#   1.4.3: If [db1] has a read-lock on t1, [db2] cannot write to t1.\n#\ndo_test shared6-1.4.1 {\n  execsql { PRAGMA read_uncommitted = 1 } db2\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(5, 6);\n  } db1\n  execsql { SELECT * FROM t1 } db2\n} {1 2 5 6}\ndo_test shared6-1.4.2 {\n  execsql { CREATE TABLE t4(a, b) } db1\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked}}\ndo_test shared6-1.4.3 {\n  execsql {\n    COMMIT;\n    BEGIN;\n    SELECT * FROM t1;\n  } db1\n  catchsql { INSERT INTO t1 VALUES(7, 8) } db2\n} {1 {database table is locked: t1}}\n\ndo_test shared6-1.X {\n  db1 close\n  db2 close\n} {}\n\n#-------------------------------------------------------------------------\n# The following tests - shared6-2.* - test that two database connections\n# that connect to the same file using different VFS implementations do\n# not share a cache.\n#\nif {$::tcl_platform(platform) eq \"unix\"} {\n  do_test shared6-2.1 {\n    sqlite3 db1 test.db -vfs unix\n    sqlite3 db2 test.db -vfs unix\n    sqlite3 db3 test.db -vfs unix-none\n    sqlite3 db4 test.db -vfs unix-none\n  } {}\n\n  do_test shared6-2.2 {\n    execsql { BEGIN; INSERT INTO t1 VALUES(9, 10); } db1\n    catchsql { SELECT * FROM t1 } db2\n  } {1 {database table is locked: t1}}\n  do_test shared6-2.3 {\n    execsql { SELECT * FROM t1 } db3\n  } {1 2 5 6}\n\n  do_test shared6-2.3 {\n    execsql { COMMIT } db1\n    execsql { BEGIN; INSERT INTO t1 VALUES(11, 12); } db3\n    catchsql { SELECT * FROM t1 } db4\n  } {1 {database table is locked: t1}}\n\n  do_test shared6-2.4 {\n    execsql { SELECT * FROM t1 } db1\n  } {1 2 5 6 9 10}\n\n  do_test shared6-2.5 {\n    execsql { COMMIT } db3\n  } {}\n\n  do_test shared6-2.X {\n    db1 close\n    db2 close\n    db3 close\n    db4 close\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Test that it is possible to open an exclusive transaction while \n# already holding a read-lock on the database file. And that it is\n# not possible if some other connection holds such a lock.\n#\ndo_test shared6-3.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n  sqlite3 db3 test.db\n} {}\ndb1 eval {SELECT * FROM t1} {\n  # Within this block [db1] is holding a read-lock on t1. Test that\n  # this means t1 cannot be written by [db2].\n  #\n  do_test shared6-3.2 {\n    catchsql { INSERT INTO t1 VALUES(1, 2) } db2\n  } {1 {database table is locked: t1}}\n\n  do_test shared6-3.3 {\n    execsql { BEGIN EXCLUSIVE } db1\n  } {}\n  break\n}\ndo_test shared6-3.4 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database schema is locked: main}}\ndo_test shared6-3.5 {\n  execsql COMMIT db1\n} {}\ndb2 eval {SELECT * FROM t1} {\n  do_test shared6-3.6 {\n    catchsql { BEGIN EXCLUSIVE } db1\n  } {1 {database table is locked}}\n  break\n}\ndo_test shared6-3.7 {\n  execsql { BEGIN } db1\n  execsql { BEGIN } db2\n} {}\ndb2 eval {SELECT * FROM t1} {\n  do_test shared6-3.8 {\n    catchsql { INSERT INTO t1 VALUES(1, 2) } db1\n  } {1 {database table is locked: t1}}\n  break\n}\ndo_test shared6-3.9 {\n  execsql { BEGIN ; ROLLBACK } db3\n} {}\ndo_test shared6-3.10 {\n  catchsql { SELECT * FROM t1 } db3\n} {1 {database table is locked}}\ndo_test shared6-3.X {\n  db1 close\n  db2 close\n  db3 close\n} {}\n\ndo_test shared6-4.1 {\n  #forcedelete test.db test.db-journal\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n\n  set ::STMT [sqlite3_prepare_v2 db1 \"SELECT * FROM t1\" -1 DUMMY]\n  execsql { CREATE TABLE t5(a, b) } db2\n} {}\ndo_test shared6-4.2 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test shared6-4.X {\n  \n  db1 close\n  db2 close\n} {}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared7.test",
    "content": "# 2009 April 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Make sure that attaching the same database multiple times in\n# shared cache mode fails.\n#\n# $Id: shared7.test,v 1.1 2009/04/30 13:30:33 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !shared_cache { finish_test ; return }\n\ndo_test shared7-1.1 {\n  set ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n  sqlite3_enable_shared_cache\n} {1}\n\n# EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach\n# the same database file more than once results in an error.\n#\ndo_test shared7-1.2 {\n  db close\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(x);\n  }\n  catchsql {\n    ATTACH 'test.db' AS err1;\n  }\n} {1 {database is already attached}}\n\ndo_test shared7-1.3 {\n  forcedelete test2.db test2.db-journal\n  db eval {\n    ATTACH 'test2.db' AS test2;\n    CREATE TABLE test2.t2(y);\n  }\n  catchsql {\n    ATTACH 'test2.db' AS err2;\n  }\n} {1 {database is already attached}}\ndo_test shared7-1.4 {\n  catchsql {\n    ATTACH 'test.db' AS err1;\n  }\n} {1 {database is already attached}}\n\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared8.test",
    "content": "# 2012 May 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file are intended to show that closing one database\n# connection to a shared-cache while there exist other connections (a)\n# does not cause the schema to be reloaded and (b) does not cause any\n# other problems.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !shared_cache { finish_test ; return }\nset testprefix shared8\n\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\ndo_test 0.0 { sqlite3_enable_shared_cache } {1}\n\nproc roman {n} {\n  array set R {1 i 2 ii 3 iii 4 iv 5 v 6 vi 7 vii 8 viii 9 ix 10 x}\n  set R($n)\n}\n\n#-------------------------------------------------------------------------\n# The following tests work as follows:\n#\n#    1.0: Open connection [db1] and populate the database.\n#\n#    1.1: Using \"PRAGMA writable_schema\", destroy the database schema on\n#         disk. The schema is still in memory, so it is possible to keep\n#         using it, but any attempt to reload it from disk will fail.\n#\n#    1.3-4: Open connection db2. Check that it can see the db schema. Then\n#           close db1 and check that db2 still works. This shows that closing\n#           db1 did not reset the in-memory schema.\n#\n#    1.5-7: Similar to 1.3-4.\n#\n#    1.8: Close all database connections (deleting the in-memory schema).\n#         Then open a new connection and check that it cannot read the db.\n#         \ndo_test 1.0 {\n  sqlite3 db1 test.db\n  db1 func roman roman\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 2);\n    INSERT INTO t1 VALUES(3, 3);\n    INSERT INTO t1 VALUES(4, 4);\n    CREATE VIEW v1 AS SELECT a, roman(b) FROM t1;\n    SELECT * FROM v1;\n  } db1\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.1 {\n  execsql { \n    PRAGMA writable_schema = 1;\n    DELETE FROM sqlite_master WHERE 1;\n    PRAGMA writable_schema = 0;\n    SELECT * FROM sqlite_master;\n  } db1\n} {}\n\ndo_test 1.2 {\n  execsql { SELECT * FROM v1 } db1\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.3 {\n  sqlite3 db2 test.db\n  db2 func roman roman\n  execsql { SELECT * FROM v1 } db2\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.4 {\n  db1 close\n  execsql { SELECT * FROM v1 } db2\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.5 {\n  sqlite3 db3 test.db\n  db3 func roman roman\n  execsql { SELECT * FROM v1 } db3\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.6 {\n  execsql { SELECT * FROM v1 } db2\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.7 {\n  db2 close\n  execsql { SELECT * FROM v1 } db3\n} {1 i 2 ii 3 iii 4 iv}\n\ndo_test 1.8 {\n  db3 close\n  sqlite3 db4 test.db\n  catchsql { SELECT * FROM v1 } db4\n} {1 {no such table: v1}}\n\n\nforeach db {db1 db2 db3 db4} { catch { $db close } }\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared9.test",
    "content": "# 2012 October 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file are intended to show if two connections attach\n# to the same shared cache using different database names, views and\n# virtual tables may still be accessed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset testprefix shared9\n\nifcapable !view||!trigger {\n  finish_test\n  return\n}\n\ndb close\nset enable_shared_cache [sqlite3_enable_shared_cache 1]\n\nsqlite3 db1 test.db\nsqlite3 db2 test.db\nforcedelete test.db2\n\ndo_test 1.1 {\n  db1 eval {\n    ATTACH 'test.db2' AS 'fred';\n    CREATE TABLE fred.t1(a, b, c);\n    CREATE VIEW fred.v1 AS SELECT * FROM t1;\n\n    CREATE TABLE fred.t2(a, b);\n    CREATE TABLE fred.t3(a, b);\n    CREATE TRIGGER fred.trig AFTER INSERT ON t2 BEGIN\n      DELETE FROM t3;\n      INSERT INTO t3 SELECT * FROM t2;\n    END;\n    INSERT INTO t2 VALUES(1, 2);\n    SELECT * FROM t3;\n  }\n} {1 2}\n\ndo_test 1.2 { db2 eval \"ATTACH 'test.db2' AS 'jones'\" } {}\ndo_test 1.3 { db2 eval \"SELECT * FROM v1\"             } {}\ndo_test 1.4 { db2 eval \"INSERT INTO t2 VALUES(3, 4)\"  } {}\n\nifcapable fts3 {\n  do_test 1.5 {\n    db1 eval {\n      CREATE VIRTUAL TABLE fred.t4 USING fts4;\n      INSERT INTO t4 VALUES('hello world');\n    }\n  } {}\n\n  do_test 1.6 {\n    db2 eval {\n      INSERT INTO t4 VALUES('shared cache');\n      SELECT * FROM t4 WHERE t4 MATCH 'hello';\n    }\n  } {{hello world}}\n\n  do_test 1.7 {\n    db1 eval {\n      SELECT * FROM t4 WHERE t4 MATCH 'c*';\n    }\n  } {{shared cache}}\n}\n\ndb1 close\ndb2 close\n\n#-------------------------------------------------------------------------\n# The following tests attempt to find a similar problem with collation \n# sequence names - pointers to database handle specific allocations leaking \n# into schema objects and being used after the original handle has been\n# closed.\n#\nforcedelete test.db test.db2\nsqlite3 db1 test.db\nsqlite3 db2 test.db\nforeach x {collate1 collate2 collate3} {\n  proc $x {a b} { string compare $a $b }\n  db1 collate $x $x\n  db2 collate $x $x\n}\ndo_test 2.1 {\n  db1 eval {\n    CREATE TABLE t1(a, b, c COLLATE collate1);\n    CREATE INDEX i1 ON t1(a COLLATE collate2, c, b);\n  }\n} {}\ndo_test 2.2 {\n  db1 close\n  db2 eval \"INSERT INTO t1 VALUES('abc', 'def', 'ghi')\"\n} {}\ndb2 close\n\n#-------------------------------------------------------------------------\n# At one point, the following would cause a collation sequence belonging\n# to connection [db1] to be invoked by a call to [db2 eval]. Which is a\n# problem if [db1] has already been closed.\n#\nforcedelete test.db test.db2\nsqlite3 db1 test.db\nsqlite3 db2 test.db\n\nproc mycollate_db1 {a b} {set ::invoked_mycollate_db1 1 ; string compare $a $b}\nproc mycollate_db2 {a b} {string compare $a $b}\n\ndb1 collate mycollate mycollate_db1\ndb2 collate mycollate mycollate_db2\n\ndo_test 2.3 {\n  set ::invoked_mycollate_db1 0\n  db1 eval {\n    CREATE TABLE t1(a COLLATE mycollate, CHECK (a IN ('one', 'two', 'three')));\n    INSERT INTO t1 VALUES('one');\n  }\n  db1 close\n  set ::invoked_mycollate_db1\n} {1}\ndo_test 2.4 {\n  set ::invoked_mycollate_db1 0\n  db2 eval {\n    INSERT INTO t1 VALUES('two');\n  }\n  db2 close\n  set ::invoked_mycollate_db1\n} {0}\n\nforcedelete test.db test.db2\nsqlite3 db1 test.db\nsqlite3 db2 test.db\ndb1 collate mycollate mycollate_db1\ndb2 collate mycollate mycollate_db2\n\ndo_test 2.13 {\n  set ::invoked_mycollate_db1 0\n  db1 eval {\n    CREATE TABLE t1(a, CHECK (a COLLATE mycollate IN ('one', 'two', 'three')));\n    INSERT INTO t1 VALUES('one');\n  }\n  db1 close\n  set ::invoked_mycollate_db1\n} {1}\ndo_test 2.14 {\n  set ::invoked_mycollate_db1 0\n  db2 eval {\n    INSERT INTO t1 VALUES('two');\n  }\n  db2 close\n  set ::invoked_mycollate_db1\n} {0}\n\n#-------------------------------------------------------------------------\n# This test verifies that a bug causing a busy-handler belonging to one\n# shared-cache connection to be executed as a result of an sqlite3_step()\n# on another has been fixed.\n#\nforcedelete test.db test.db2\nsqlite3 db1 test.db\nsqlite3 db2 test.db\n\nproc busyhandler {handle args} {\n  set ::busyhandler_invoked_for $handle\n  return 1\n}\ndb1 busy [list busyhandler db1]\ndb2 busy [list busyhandler db2]\n\ndo_test 3.1 {\n  db1 eval {\n    BEGIN; \n      CREATE TABLE t1(a, b);\n      CREATE TABLE t2(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t2 VALUES(1, 2);\n  }\n  # Keep this next COMMIT as a separate statement. This ensures that COMMIT\n  # has already been compiled and loaded into the tcl interface statement \n  # cache when it is attempted below.\n  db1 eval COMMIT\n  db1 eval {\n    BEGIN;\n      INSERT INTO t1 VALUES(3, 4);\n  }\n} {}\n\ndo_test 3.2 {\n  set ::tf [launch_testfixture]\n  testfixture $::tf {\n    sqlite3 db test.db\n    db eval {\n      BEGIN;\n        SELECT * FROM t1;\n    }\n  }\n} {1 2}\n\ndo_test 3.3 {\n  db2 eval { SELECT * FROM t2 }\n} {1 2}\n\ndo_test 3.4 {\n  list [catch { db1 eval COMMIT } msg] $msg\n} {1 {database is locked}}\n\n# At one point the following would fail, showing that the busy-handler\n# belonging to [db2] was invoked instead.\ndo_test 3.5 {\n  set ::busyhandler_invoked_for\n} {db1}\ndo_test 3.6 {\n  close $::tf\n  db1 eval COMMIT\n} {}\n  \ndb1 close\ndb2 close\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sharedA.test",
    "content": "# 2013 May 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test some specific circumstances to do with shared cache mode.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\ndb close\nset ::testprefix sharedA\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n#-------------------------------------------------------------------------\n#\ndo_test 0.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n\n  db1 eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(100));\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    CREATE INDEX i1 ON t1(x);\n  }\n\n  db1 eval {\n    BEGIN;\n    DROP INDEX i1;\n  }\n\n  db2 close\n\n  db1 eval {\n    INSERT INTO t1 SELECT randomblob(100) FROM t1;\n    ROLLBACK;\n    PRAGMA integrity_check;\n  }\n} {ok}\n\ndb1 close\nforcedelete test.db\n\n\n#-------------------------------------------------------------------------\n#\ndo_test 1.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n  db2 eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(123);\n  }\n  db1 eval { \n    SELECT * FROM t1;\n    CREATE INDEX i1 ON t1(x);\n  }\n} {123}\n\ndo_test 1.2 {\n  db2 eval { SELECT * FROM t1 ORDER BY x; }\n\n  db1 eval {\n    BEGIN; DROP INDEX i1;\n  }\n  db1 close\n\n  db2 eval { SELECT * FROM t1 ORDER BY x; }\n} {123}\n\ndo_test 1.3 {\n  db2 close\n} {}\n\n#-------------------------------------------------------------------------\n#\n# sqlite3RollbackAll() loops through all attached b-trees and rolls\n# back each one separately.  Then if the SQLITE_InternChanges flag is\n# set, it resets the schema.  Both of the above steps must be done\n# while holding a mutex, otherwise another thread might slip in and\n# try to use the new schema with the old data.\n#\n# The following sequence of tests attempt to verify that the actions\n# taken by sqlite3RollbackAll() are thread-atomic (that they cannot be\n# interrupted by a separate thread.)  \n#\n# Note that a TCL interpreter can only be used within the thread in which\n# it was originally created (because it uses thread-local-storage).  \n# The tvfs callbacks must therefore only run on the main thread.  \n# There is some trickery in the read_callback procedure to ensure that\n# this is the case.\n#\ntestvfs tvfs\n\n# Set up two databases and two database connections.\n#\n#   db1:  main(test.db), two(test2.db)\n#   db2:  main(test.db)\n#\n# The cache for test.db is shared between db1 and db2.\n#\ndo_test 2.1 {\n  forcedelete test.db test.db2\n  sqlite3 db1 test.db -vfs tvfs\n  db1 eval { ATTACH 'test.db2' AS two }\n\n  db1 eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    CREATE TABLE two.t2(x);\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n\n  sqlite3 db2 test.db -vfs tvfs\n  db2 eval { SELECT * FROM t1 }\n} {1 2 3}\n\n# Create a prepared statement on db2 that will attempt a schema change\n# in test.db.  Meanwhile, start a transaction on db1 that changes\n# the schema of test.db and that creates a rollback journal on test2.db\n#\ndo_test 2.2 {\n  set ::STMT [sqlite3_prepare db2 \"CREATE INDEX i1 ON t1(x)\" -1 tail]\n  db1 eval {\n    BEGIN;\n      CREATE INDEX i1 ON t1(x);\n      INSERT INTO t2 VALUES('value!');\n  }\n} {}\n\n# Set up a callback that will cause db2 to try to execute its\n# schema change when db1 accesses the journal file of test2.db.\n#\n# This callback will be invoked after the content of test.db has\n# be rolled back but before the schema has been reset.  If the\n# sqlite3RollbackAll() operation is not thread-atomic, then the\n# db2 statement in the callback will see old content with the newer\n# schema, which is wrong.\n#\ntvfs filter xRead\ntvfs script read_callback\nunset -nocomplain ::some_time_laster\nunset -nocomplain ::thread_result\nproc read_callback {call file args} { \n  if {[string match *test.db2-journal $file]} {\n    tvfs filter {}   ;# Ensure that tvfs callbacks to do run on the\n                      # child thread\n    sqlthread spawn ::thread_result [subst -nocommands {\n      sqlite3_step $::STMT\n      set rc [sqlite3_finalize $::STMT]\n    }]\n    after 1000 { set ::some_time_later 1 }\n    vwait ::some_time_later\n  }\n}\ndo_test 2.3 { db1 eval ROLLBACK } {}\n\n# Verify that the db2 statement invoked by the callback detected the\n# schema change.\n#\nif {[info exists ::thread_result]==0} { vwait ::thread_result }\ndo_test 2.4 { \n  list $::thread_result [sqlite3_errmsg db2] \n} {SQLITE_SCHEMA {database schema has changed}}\n\ndb1 close\ndb2 close\ntvfs delete\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sharedB.test",
    "content": "# 2014-12-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Open two database connections on the same database in shared cache\n# mode.  Hold one open while repeatedly closing, reopening, and using\n# the second.\n#\n# This test is designed to demostrate that the fix for ticket\n# [e4a18565a36884b00edf66541f38c693827968ab] works.  \n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\ndb close\nset ::testprefix sharedB\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n#-------------------------------------------------------------------------\n#\ndo_test 1.1 {\n  sqlite3 db1 test.db\n  sqlite3 db2 test.db\n\n  db1 eval {\n    CREATE TABLE t1(x,y TEXT COLLATE nocase);\n    WITH RECURSIVE\n      c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)\n    INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c;\n    CREATE INDEX t1yx ON t1(y,x);\n  }\n  db2 eval {\n    SELECT x FROM t1 WHERE y='X014Y';\n  }\n} {14}\n\nfor {set j 1} {$j<=100} {incr j} {\n  do_test 1.2.$j {\n    db2 close\n    sqlite3 db2 test.db\n    db2 eval {\n      SELECT x FROM t1 WHERE y='X014Y';\n    }\n  } {14}\n}\n\ndb1 close\ndb2 close\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shared_err.test",
    "content": "# 2005 December 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of the tests in this file are IO errors that occur in a shared\n# cache context. What happens to connection B if one connection A encounters\n# an IO-error whilst reading or writing the file-system?\n#\n# $Id: shared_err.test,v 1.24 2008/10/12 00:27:54 shane Exp $\n\nproc skip {args} {}\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\ndb close\n\nifcapable !shared_cache||!subquery {\n  finish_test\n  return\n}\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\ndo_ioerr_test shared_ioerr-1 -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    CREATE TABLE t1(a,b,c);\n    BEGIN;\n    SELECT * FROM sqlite_master;\n  } db2\n} -sqlbody {\n  SELECT * FROM sqlite_master;\n  INSERT INTO t1 VALUES(1,2,3);\n  BEGIN TRANSACTION;\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(4,5,6);\n  ROLLBACK;\n  SELECT * FROM t1;\n  BEGIN TRANSACTION;\n  INSERT INTO t1 VALUES(1,2,3);\n  INSERT INTO t1 VALUES(4,5,6);\n  COMMIT;\n  SELECT * FROM t1;\n  DELETE FROM t1 WHERE a<100;\n} -cleanup {\n  do_test shared_ioerr-1.$n.cleanup.1 {\n    set res [catchsql {\n      SELECT * FROM t1;\n    } db2]\n    set possible_results [list               \\\n      \"1 {disk I/O error}\"                   \\\n      \"0 {1 2 3}\"                            \\\n      \"0 {1 2 3 1 2 3 4 5 6}\"                \\\n      \"0 {1 2 3 1 2 3 4 5 6 1 2 3 4 5 6}\"    \\\n      \"0 {}\"                                 \\\n      \"1 {database disk image is malformed}\" \\\n    ]\n    set rc [expr [lsearch -exact $possible_results $res] >= 0]\n    if {$rc != 1} {\n      puts \"\"\n      puts \"Result: $res\"\n    }\n    set rc\n  } {1}\n\n  # The \"database disk image is malformed\" is a special case that can\n  # occur if an IO error occurs during a rollback in the {SELECT * FROM t1}\n  # statement above. This test is to make sure there is no real database\n  # corruption.\n  db2 close\n  do_test shared_ioerr-1.$n.cleanup.2 {\n    execsql {pragma integrity_check} db\n  } {ok}\n}\n\ndo_ioerr_test shared_ioerr-2 -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1(oid) VALUES(NULL);\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    INSERT INTO t1(oid) SELECT NULL FROM t1;\n    UPDATE t1 set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';\n    CREATE INDEX i1 ON t1(a);\n    COMMIT;\n    BEGIN;\n    SELECT * FROM sqlite_master;\n  } db2\n} -tclbody {\n  set ::residx 0\n  execsql {DELETE FROM t1 WHERE 0 = (a % 2);}\n  incr ::residx\n\n  # When this transaction begins the table contains 512 entries. The\n  # two statements together add 512+146 more if it succeeds. \n  # (1024/7==146)\n  execsql {BEGIN;}\n  execsql {INSERT INTO t1 SELECT a+1, b FROM t1;}\n  execsql {INSERT INTO t1 SELECT 'string' || a, b FROM t1 WHERE 0 = (a%7);}\n  execsql {COMMIT;}\n\n  incr ::residx\n} -cleanup {\n  catchsql ROLLBACK\n  do_test shared_ioerr-2.$n.cleanup.1 {\n    set res [catchsql {\n      SELECT max(a), min(a), count(*) FROM (SELECT a FROM t1 order by a);\n    } db2]\n    set possible_results [list \\\n      {0 {1024 1 1024}}        \\\n      {0 {1023 1 512}}         \\\n      {0 {string994 1 1170}}   \\\n    ]\n    set idx [lsearch -exact $possible_results $res]\n    set success [expr {$idx==$::residx || $res==\"1 {disk I/O error}\"}]\n    if {!$success} {\n      puts \"\"\n      puts \"Result: \\\"$res\\\" ($::residx)\"\n    }\n    set success\n  } {1}\n  db2 close\n}\n\n# This test is designed to provoke an IO error when a cursor position is\n# \"saved\" (because another cursor is going to modify the underlying table). \n# \ndo_ioerr_test shared_ioerr-3 -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n  } db2\n  for {set i 0} {$i < 200} {incr i} {\n    set a [string range [string repeat \"[format %03d $i].\" 5] 0 end-1]\n\n    set b [string repeat $i 2000]\n    execsql {INSERT INTO t1 VALUES($a, $b)} db2\n  }\n  execsql {COMMIT} db2\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set ::STMT [sqlite3_prepare $::DB2 \"SELECT a FROM t1 ORDER BY a\" -1 DUMMY]\n  sqlite3_step $::STMT       ;# Cursor points at 000.000.000.000\n  sqlite3_step $::STMT       ;# Cursor points at 001.001.001.001\n\n} -tclbody {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES('201.201.201.201.201', NULL);\n    UPDATE t1 SET a = '202.202.202.202.202' WHERE a LIKE '201%';\n    COMMIT;\n  }\n} -cleanup {\n  set ::steprc  [sqlite3_step $::STMT]\n  set ::column  [sqlite3_column_text $::STMT 0]\n  set ::finalrc [sqlite3_finalize $::STMT]\n\n  # There are three possible outcomes here (assuming persistent IO errors):\n  #\n  # 1. If the [sqlite3_step] did not require any IO (required pages in\n  #    the cache), then the next row (\"002...\") may be retrieved \n  #    successfully.\n  #\n  # 2. If the [sqlite3_step] does require IO, then [sqlite3_step] returns\n  #    SQLITE_ERROR and [sqlite3_finalize] returns IOERR.\n  #\n  # 3. If, after the initial IO error, SQLite tried to rollback the\n  #    active transaction and a second IO error was encountered, then\n  #    statement $::STMT will have been aborted. This means [sqlite3_stmt]\n  #    returns SQLITE_ABORT, and the statement cursor does not move. i.e.\n  #    [sqlite3_column] still returns the current row (\"001...\") and\n  #    [sqlite3_finalize] returns SQLITE_OK.\n  #\n\n  do_test shared_ioerr-3.$n.cleanup.1 {\n    expr {\n      $::steprc eq \"SQLITE_ROW\" || \n      $::steprc eq \"SQLITE_ERROR\" ||\n      $::steprc eq \"SQLITE_ABORT\" \n    }\n  } {1}\n  do_test shared_ioerr-3.$n.cleanup.2 {\n    expr {\n      ($::steprc eq \"SQLITE_ROW\" && $::column eq \"002.002.002.002.002\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::column eq \"\") ||\n      ($::steprc eq \"SQLITE_ABORT\" && $::column eq \"001.001.001.001.001\") \n    }\n  } {1}\n  do_test shared_ioerr-3.$n.cleanup.3 {\n    expr {\n      ($::steprc eq \"SQLITE_ROW\" && $::finalrc eq \"SQLITE_OK\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::finalrc eq \"SQLITE_IOERR\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::finalrc eq \"SQLITE_ABORT\")\n    }\n  } {1}\n\n# db2 eval {select * from sqlite_master}\n  db2 close\n}\n\n# This is a repeat of the previous test except that this time we\n# are doing a reverse-order scan of the table when the cursor is\n# \"saved\".\n# \ndo_ioerr_test shared_ioerr-3rev -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    PRAGMA cache_size = 10;\n    BEGIN;\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n  } db2\n  for {set i 0} {$i < 200} {incr i} {\n    set a [string range [string repeat \"[format %03d $i].\" 5] 0 end-1]\n\n    set b [string repeat $i 2000]\n    execsql {INSERT INTO t1 VALUES($a, $b)} db2\n  }\n  execsql {COMMIT} db2\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set ::STMT [sqlite3_prepare $::DB2 \\\n           \"SELECT a FROM t1 ORDER BY a DESC\" -1 DUMMY]\n  sqlite3_step $::STMT       ;# Cursor points at 199.199.199.199.199\n  sqlite3_step $::STMT       ;# Cursor points at 198.198.198.198.198\n\n} -tclbody {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES('201.201.201.201.201', NULL);\n    UPDATE t1 SET a = '202.202.202.202.202' WHERE a LIKE '201%';\n    COMMIT;\n  }\n} -cleanup {\n  set ::steprc  [sqlite3_step $::STMT]\n  set ::column  [sqlite3_column_text $::STMT 0]\n  set ::finalrc [sqlite3_finalize $::STMT]\n\n  # There are three possible outcomes here (assuming persistent IO errors):\n  #\n  # 1. If the [sqlite3_step] did not require any IO (required pages in\n  #    the cache), then the next row (\"002...\") may be retrieved \n  #    successfully.\n  #\n  # 2. If the [sqlite3_step] does require IO, then [sqlite3_step] returns\n  #    SQLITE_ERROR and [sqlite3_finalize] returns IOERR.\n  #\n  # 3. If, after the initial IO error, SQLite tried to rollback the\n  #    active transaction and a second IO error was encountered, then\n  #    statement $::STMT will have been aborted. This means [sqlite3_stmt]\n  #    returns SQLITE_ABORT, and the statement cursor does not move. i.e.\n  #    [sqlite3_column] still returns the current row (\"001...\") and\n  #    [sqlite3_finalize] returns SQLITE_OK.\n  #\n\n  do_test shared_ioerr-3rev.$n.cleanup.1 {\n    expr {\n      $::steprc eq \"SQLITE_ROW\" || \n      $::steprc eq \"SQLITE_ERROR\" ||\n      $::steprc eq \"SQLITE_ABORT\" \n    }\n  } {1}\n  do_test shared_ioerr-3rev.$n.cleanup.2 {\n    expr {\n      ($::steprc eq \"SQLITE_ROW\" && $::column eq \"197.197.197.197.197\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::column eq \"\") ||\n      ($::steprc eq \"SQLITE_ABORT\" && $::column eq \"198.198.198.198.198\") \n    }\n  } {1}\n  do_test shared_ioerr-3rev.$n.cleanup.3 {\n    expr {\n      ($::steprc eq \"SQLITE_ROW\" && $::finalrc eq \"SQLITE_OK\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::finalrc eq \"SQLITE_IOERR\") ||\n      ($::steprc eq \"SQLITE_ERROR\" && $::finalrc eq \"SQLITE_ABORT\")\n    }\n  } {1}\n\n# db2 eval {select * from sqlite_master}\n  db2 close\n}\n\n# Provoke a malloc() failure when a cursor position is being saved. This\n# only happens with index cursors (because they malloc() space to save the\n# current key value). It does not happen with tables, because an integer\n# key does not require a malloc() to store. \n#\n# The library should return an SQLITE_NOMEM to the caller. The query that\n# owns the cursor (the one for which the position is not saved) should\n# continue unaffected.\n# \ndo_malloc_test shared_err-4 -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    BEGIN;\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n  } db2\n  for {set i 0} {$i < 5} {incr i} {\n    set a [string repeat $i 10]\n    set b [string repeat $i 2000]\n    execsql {INSERT INTO t1 VALUES($a, $b)} db2\n  }\n  execsql {COMMIT} db2\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set ::STMT [sqlite3_prepare $::DB2 \"SELECT a FROM t1 ORDER BY a\" -1 DUMMY]\n  sqlite3_step $::STMT       ;# Cursor points at 0000000000\n  sqlite3_step $::STMT       ;# Cursor points at 1111111111\n} -tclbody {\n  execsql {\n    INSERT INTO t1 VALUES(6, NULL);\n  }\n} -cleanup {\n  do_test shared_malloc-4.$::n.cleanup.1 {\n    set ::rc [sqlite3_step $::STMT]\n    expr {$::rc==\"SQLITE_ROW\" || $::rc==\"SQLITE_ERROR\"}\n  } {1}\n  if {$::rc==\"SQLITE_ROW\"} {\n    do_test shared_malloc-4.$::n.cleanup.2 {\n      sqlite3_column_text $::STMT 0\n    } {2222222222}\n  }\n  do_test shared_malloc-4.$::n.cleanup.3 {\n   set rc [sqlite3_finalize $::STMT]\n   expr {$rc==\"SQLITE_OK\" || $rc==\"SQLITE_ABORT\" ||\n         $rc==\"SQLITE_NOMEM\" || $rc==\"SQLITE_IOERR\"}\n  } {1}\n# db2 eval {select * from sqlite_master}\n  db2 close\n}\n\ndo_malloc_test shared_err-5 -tclbody {\n  db close\n  sqlite3 dbX test.db\n  sqlite3 dbY test.db\n  dbX close\n  dbY close\n} -cleanup {\n  catch {dbX close}\n  catch {dbY close}\n}\n\ndo_malloc_test shared_err-6 -tclbody {\n  catch {db close}\n  ifcapable deprecated {\n    sqlite3_thread_cleanup\n  }\n  sqlite3_enable_shared_cache 0\n} -cleanup {\n  sqlite3_enable_shared_cache 1\n}\n\n# As of 3.5.0, sqlite3_enable_shared_cache can be called at\n# any time and from any thread\n#do_test shared_err-misuse-7.1 {\n#  sqlite3 db test.db\n#  catch {\n#    sqlite3_enable_shared_cache 0\n#  } msg\n#  set msg\n#} {bad parameter or other API misuse}\n\n# Again provoke a malloc() failure when a cursor position is being saved, \n# this time during a ROLLBACK operation by some other handle. \n#\n# The library should return an SQLITE_NOMEM to the caller. The query that\n# owns the cursor (the one for which the position is not saved) should\n# be aborted.\n# \nset ::aborted 0\ndo_malloc_test shared_err-8 -tclprep {\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA read_uncommitted = 1;\n    BEGIN;\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n  } db2\n  for {set i 0} {$i < 2} {incr i} {\n    set a [string repeat $i 10]\n    set b [string repeat $i 2000]\n    execsql {INSERT INTO t1 VALUES($a, $b)} db2\n  }\n  execsql {COMMIT} db2\n  execsql BEGIN\n  execsql ROLLBACK\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set ::STMT [sqlite3_prepare $::DB2 \"SELECT a FROM t1 ORDER BY a\" -1 DUMMY]\n  sqlite3_step $::STMT       ;# Cursor points at 0000000000\n  sqlite3_step $::STMT       ;# Cursor points at 1111111111\n} -tclbody {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(6, NULL);\n    ROLLBACK}\n} -cleanup {\n  # UPDATE: As of [5668], if the rollback fails SQLITE_CORRUPT is returned. \n  # So these tests have been updated to expect SQLITE_CORRUPT and its\n  # associated English language error message.\n  #\n  do_test shared_malloc-8.$::n.cleanup.1 {\n    set res [catchsql {SELECT a FROM t1} db2]\n    set ans [lindex $res 1]\n    if {[lindex $res 0]} {\n       set r [expr {\n         $ans==\"disk I/O error\" ||\n         $ans==\"out of memory\" ||\n         $ans==\"database disk image is malformed\"\n       }]\n    } else {\n       set r [expr {[lrange $ans 0 1]==\"0000000000 1111111111\"}]\n    }\n  } {1}\n  do_test shared_malloc-8.$::n.cleanup.2 {\n    set rc1 [sqlite3_step $::STMT]\n    set rc2 [sqlite3_finalize $::STMT]\n    if {$rc2==\"SQLITE_ABORT\"} {\n      incr ::aborted\n    }\n    expr {\n      ($rc1==\"SQLITE_DONE\" && $rc2==\"SQLITE_OK\") || \n      ($rc1==\"SQLITE_ERROR\" && $rc2==\"SQLITE_ABORT\") ||\n      ($rc1==\"SQLITE_ERROR\" && $rc2==\"SQLITE_NOMEM\") ||\n      ($rc1==\"SQLITE_ERROR\" && $rc2==\"SQLITE_IOERR\") ||\n      ($rc1==\"SQLITE_ERROR\" && $rc2==\"SQLITE_CORRUPT\")\n    }\n  } {1}\n  db2 close\n}\n\n# When this test case was written, OOM errors in write statements would \n# cause transaction rollback, which would trip cursors in other statements,\n# aborting them. This no longer happens.\n#\ndo_test shared_malloc-8.X {\n  # Test that one or more queries were aborted due to the malloc() failure.\n  # expr $::aborted>=1\n  expr $::aborted==0\n} {1}\n\n# This test is designed to catch a specific bug that was present during\n# development of 3.5.0. If a malloc() failed while setting the page-size,\n# a buffer (Pager.pTmpSpace) was being freed. This could cause a seg-fault\n# later if another connection tried to use the pager.\n#\n# This test will crash 3.4.2.\n#\ndo_malloc_test shared_err-9 -tclprep {\n  sqlite3 db2 test.db\n} -sqlbody {\n  PRAGMA page_size = 4096;\n  PRAGMA page_size = 1024;\n} -cleanup {\n  db2 eval {\n    CREATE TABLE abc(a, b, c);\n    BEGIN;\n    INSERT INTO abc VALUES(1, 2, 3);\n    ROLLBACK;\n  }     \n  db2 close\n}     \n\ncatch {db close}\ncatch {db2 close}\ndo_malloc_test shared_err-10 -tclprep {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  \n  db eval { SELECT * FROM sqlite_master }\n  db2 eval { \n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n  }\n} -tclbody {\n  catch {db eval {SELECT * FROM sqlite_master}}\n  error 1\n} -cleanup {\n  execsql { SELECT * FROM sqlite_master }\n}\n\ndo_malloc_test shared_err-11 -tclprep {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  \n  db eval { SELECT * FROM sqlite_master }\n  db2 eval { \n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n  }\n} -tclbody {\n  catch {db eval {SELECT * FROM sqlite_master}}\n  catch {sqlite3_errmsg16 db}\n  error 1\n} -cleanup {\n  execsql { SELECT * FROM sqlite_master }\n}\n\ncatch {db close}\ncatch {db2 close}\n\ndo_malloc_test shared_err-12 -sqlbody {\n  CREATE TABLE abc(a, b, c);\n  INSERT INTO abc VALUES(1, 2, 3);\n}\n\ncatch {db close}\ncatch {db2 close}\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sharedlock.test",
    "content": "# 2009 July 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sharedlock\ndb close\n\nifcapable !shared_cache {\n  finish_test\n  return\n}\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\nsqlite3 db  test.db\nsqlite3 db2 test.db\n\ndo_test sharedlock-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n  }\n} {}\n\ndo_test sharedlock-1.2 {\n  set res [list]\n  db eval { SELECT * FROM t1 ORDER BY rowid } {\n    lappend res $a $b\n    if {$a == 1} { catch { db  eval \"INSERT INTO t1 VALUES(3, 'three')\" } }\n\n    # This should fail. Connection [db] has a read-lock on t1, which should\n    # prevent connection [db2] from obtaining the write-lock it needs to\n    # modify t1. At one point there was a bug causing the previous INSERT\n    # to drop the read-lock belonging to [db].\n    if {$a == 2} { catch { db2 eval \"INSERT INTO t1 VALUES(4, 'four')\"  } }\n  }\n  set res\n} {1 one 2 two 3 three}\n\n\n#-------------------------------------------------------------------------\n# Test that a write-lock is taken on a table when its entire contents\n# are deleted using the OP_Clear optimization.\n#\nforeach {tn delete_sql} {\n  1 { DELETE FROM t2 WHERE 1 }\n  2 { DELETE FROM t2 }\n} {\n  do_execsql_test 2.1 {\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t2(x, y);\n    INSERT INTO t2 VALUES(1, 2);\n    INSERT INTO t2 VALUES(3, 4);\n  }\n\n  do_test 2.2 { execsql { SELECT * FROM t2 } db2 } {1 2 3 4}\n\n  do_execsql_test 2.3 \" BEGIN; $delete_sql; \"\n\n  do_test 2.4 { \n    catchsql { SELECT * FROM t2 } db2 \n  } {1 {database table is locked: t2}}\n\n  do_execsql_test 2.5 COMMIT\n}\n\n\ndb close\ndb2 close\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell1.test",
    "content": "# 2009 Nov 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the CLI shell tool.\n#\n#\n\n# Test plan:\n#\n#   shell1-1.*: Basic command line option handling.\n#   shell1-2.*: Basic \"dot\" command token parsing.\n#   shell1-3.*: Basic test that \"dot\" command can be called.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\nsqlite3 db test.db\n\n#----------------------------------------------------------------------------\n# Test cases shell1-1.*: Basic command line option handling.\n#\n\n# invalid option\ndo_test shell1-1.1.1 {\n  set res [catchcmd \"-bad test.db\" \"\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {Error: unknown option: -bad} $res]\n} {1 1}\ndo_test shell1-1.1.1b {\n  set res [catchcmd \"test.db -bad\" \"\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {Error: unknown option: -bad} $res]\n} {1 1}\n# error on extra options\ndo_test shell1-1.1.2 {\n  catchcmd \"test.db \\\"select+3\\\" \\\"select+4\\\"\" \"\"\n} {0 {3\n4}}\n# error on extra options\ndo_test shell1-1.1.3 {\n  catchcmd \"test.db FOO test.db BAD\" \".quit\"\n} {1 {Error: near \"FOO\": syntax error}}\n\n# -help\ndo_test shell1-1.2.1 {\n  set res [catchcmd \"-help test.db\" \"\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {Usage} $res] \\\n       [regexp {\\-init} $res] \\\n       [regexp {\\-version} $res]\n} {1 1 1 1}\n\n# -init filename       read/process named file\ndo_test shell1-1.3.1 {\n  catchcmd \"-init FOO test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.3.2 {\n  catchcmd \"-init FOO test.db .quit BAD\" \"\"\n} {0 {}}\ndo_test shell1-1.3.3 {\n  catchcmd \"-init FOO test.db BAD .quit\" \"\"\n} {1 {Error: near \"BAD\": syntax error}}\n\n# -echo                print commands before execution\ndo_test shell1-1.4.1 {\n  catchcmd \"-echo test.db\" \"\"\n} {0 {}}\n\n# -[no]header          turn headers on or off\ndo_test shell1-1.5.1 {\n  catchcmd \"-header test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.5.2 {\n  catchcmd \"-noheader test.db\" \"\"\n} {0 {}}\n\n# -bail                stop after hitting an error\ndo_test shell1-1.6.1 {\n  catchcmd \"-bail test.db\" \"\"\n} {0 {}}\n\n# -interactive         force interactive I/O\ndo_test shell1-1.7.1 {\n  set res [catchcmd \"-interactive test.db\" \".quit\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {SQLite version} $res] \\\n       [regexp {Enter \".help\" for usage hints} $res]\n} {0 1 1}\n\n# -batch               force batch I/O\ndo_test shell1-1.8.1 {\n  catchcmd \"-batch test.db\" \"\"\n} {0 {}}\n\n# -column              set output mode to 'column'\ndo_test shell1-1.9.1 {\n  catchcmd \"-column test.db\" \"\"\n} {0 {}}\n\n# -csv                 set output mode to 'csv'\ndo_test shell1-1.10.1 {\n  catchcmd \"-csv test.db\" \"\"\n} {0 {}}\n\n# -html                set output mode to HTML\ndo_test shell1-1.11.1 {\n  catchcmd \"-html test.db\" \"\"\n} {0 {}}\n\n# -line                set output mode to 'line'\ndo_test shell1-1.12.1 {\n  catchcmd \"-line test.db\" \"\"\n} {0 {}}\n\n# -list                set output mode to 'list'\ndo_test shell1-1.13.1 {\n  catchcmd \"-list test.db\" \"\"\n} {0 {}}\n\n# -separator 'x'       set output field separator (|)\ndo_test shell1-1.14.1 {\n  catchcmd \"-separator 'x' test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.14.2 {\n  catchcmd \"-separator x test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.14.3 {\n  set res [catchcmd \"-separator\" \"\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {Error: missing argument to -separator} $res]\n} {1 1}\n\n# -stats               print memory stats before each finalize\ndo_test shell1-1.14b.1 {\n  catchcmd \"-stats test.db\" \"\"\n} {0 {}}\n\n# -nullvalue 'text'    set text string for NULL values\ndo_test shell1-1.15.1 {\n  catchcmd \"-nullvalue 'x' test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.15.2 {\n  catchcmd \"-nullvalue x test.db\" \"\"\n} {0 {}}\ndo_test shell1-1.15.3 {\n  set res [catchcmd \"-nullvalue\" \"\"]\n  set rc [lindex $res 0]\n  list $rc \\\n       [regexp {Error: missing argument to -nullvalue} $res]\n} {1 1}\n\n# -version             show SQLite version\ndo_test shell1-1.16.1 {\n  set x [catchcmd \"-version test.db\" \"\"]\n} {/3.[0-9.]+ 20\\d\\d-[01]\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d [0-9a-f]+/}\n\n#----------------------------------------------------------------------------\n# Test cases shell1-2.*: Basic \"dot\" command token parsing.\n#\n\n# check first token handling\ndo_test shell1-2.1.1 {\n  catchcmd \"test.db\" \".foo\"\n} {1 {Error: unknown command or invalid arguments:  \"foo\". Enter \".help\" for help}}\ndo_test shell1-2.1.2 {\n  catchcmd \"test.db\" \".\\\"foo OFF\\\"\"\n} {1 {Error: unknown command or invalid arguments:  \"foo OFF\". Enter \".help\" for help}}\ndo_test shell1-2.1.3 {\n  catchcmd \"test.db\" \".\\'foo OFF\\'\"\n} {1 {Error: unknown command or invalid arguments:  \"foo OFF\". Enter \".help\" for help}}\n\n# unbalanced quotes\ndo_test shell1-2.2.1 {\n  catchcmd \"test.db\" \".\\\"foo OFF\"\n} {1 {Error: unknown command or invalid arguments:  \"foo OFF\". Enter \".help\" for help}}\ndo_test shell1-2.2.2 {\n  catchcmd \"test.db\" \".\\'foo OFF\"\n} {1 {Error: unknown command or invalid arguments:  \"foo OFF\". Enter \".help\" for help}}\ndo_test shell1-2.2.3 {\n  catchcmd \"test.db\" \".explain \\\"OFF\"\n} {0 {}}\ndo_test shell1-2.2.4 {\n  catchcmd \"test.db\" \".explain \\'OFF\"\n} {0 {}}\ndo_test shell1-2.2.5 {\n  catchcmd \"test.db\" \".mode \\\"insert FOO\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\ndo_test shell1-2.2.6 {\n  catchcmd \"test.db\" \".mode \\'insert FOO\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\n\n# check multiple tokens, and quoted tokens\ndo_test shell1-2.3.1 {\n  catchcmd \"test.db\" \".explain 1\"\n} {0 {}}\ndo_test shell1-2.3.2 {\n  catchcmd \"test.db\" \".explain on\"\n} {0 {}}\ndo_test shell1-2.3.3 {\n  catchcmd \"test.db\" \".explain \\\"1 2 3\\\"\"\n} {1 {ERROR: Not a boolean value: \"1 2 3\". Assuming \"no\".}}\ndo_test shell1-2.3.4 {\n  catchcmd \"test.db\" \".explain \\\"OFF\\\"\"\n} {0 {}}\ndo_test shell1-2.3.5 {\n  catchcmd \"test.db\" \".\\'explain\\' \\'OFF\\'\"\n} {0 {}}\ndo_test shell1-2.3.6 {\n  catchcmd \"test.db\" \".explain \\'OFF\\'\"\n} {0 {}}\ndo_test shell1-2.3.7 {\n  catchcmd \"test.db\" \".\\'explain\\' \\'OFF\\'\"\n} {0 {}}\n\n# check quoted args are unquoted\ndo_test shell1-2.4.1 {\n  catchcmd \"test.db\" \".mode FOO\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\ndo_test shell1-2.4.2 {\n  catchcmd \"test.db\" \".mode csv\"\n} {0 {}}\ndo_test shell1-2.4.2 {\n  catchcmd \"test.db\" \".mode \\\"csv\\\"\"\n} {0 {}}\n\n\n#----------------------------------------------------------------------------\n# Test cases shell1-3.*: Basic test that \"dot\" command can be called.\n#\n\n# .backup ?DB? FILE      Backup DB (default \"main\") to FILE\ndo_test shell1-3.1.1 {\n  catchcmd \"test.db\" \".backup\"\n} {1 {missing FILENAME argument on .backup}}\ndo_test shell1-3.1.2 {\n  catchcmd \"test.db\" \".backup FOO\"\n} {0 {}}\ndo_test shell1-3.1.3 {\n  catchcmd \"test.db\" \".backup FOO BAR\"\n} {1 {Error: unknown database FOO}}\ndo_test shell1-3.1.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".backup FOO BAR BAD\"\n} {1 {too many arguments to .backup}}\n\n# .bail ON|OFF           Stop after hitting an error.  Default OFF\ndo_test shell1-3.2.1 {\n  catchcmd \"test.db\" \".bail\"\n} {1 {Usage: .bail on|off}}\ndo_test shell1-3.2.2 {\n  catchcmd \"test.db\" \".bail ON\"\n} {0 {}}\ndo_test shell1-3.2.3 {\n  catchcmd \"test.db\" \".bail OFF\"\n} {0 {}}\ndo_test shell1-3.2.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".bail OFF BAD\"\n} {1 {Usage: .bail on|off}}\n\nifcapable vtab {\n# .databases             List names and files of attached databases\ndo_test shell1-3.3.1 {\n  catchcmd \"-csv test.db\" \".databases\"\n} \"/0.+main.+[string map {/ \".{1,2}\"} [string range [get_pwd] 0 10]].*/\"\ndo_test shell1-3.3.2 {\n  # extra arguments ignored\n  catchcmd \"test.db\" \".databases BAD\"\n} \"/0.+main.+[string map {/ \".{1,2}\"} [string range [get_pwd] 0 10]].*/\"\n}\n\n# .dump ?TABLE? ...      Dump the database in an SQL text format\n#                          If TABLE specified, only dump tables matching\n#                          LIKE pattern TABLE.\ndo_test shell1-3.4.1 {\n  set res [catchcmd \"test.db\" \".dump\"]\n  list [regexp {BEGIN TRANSACTION;} $res] \\\n       [regexp {COMMIT;} $res]\n} {1 1}\ndo_test shell1-3.4.2 {\n  set res [catchcmd \"test.db\" \".dump FOO\"]\n  list [regexp {BEGIN TRANSACTION;} $res] \\\n       [regexp {COMMIT;} $res]\n} {1 1}\ndo_test shell1-3.4.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".dump FOO BAD\"\n} {1 {Usage: .dump ?--preserve-rowids? ?--newlines? ?LIKE-PATTERN?}}\n\n# .echo ON|OFF           Turn command echo on or off\ndo_test shell1-3.5.1 {\n  catchcmd \"test.db\" \".echo\"\n} {1 {Usage: .echo on|off}}\ndo_test shell1-3.5.2 {\n  catchcmd \"test.db\" \".echo ON\"\n} {0 {}}\ndo_test shell1-3.5.3 {\n  catchcmd \"test.db\" \".echo OFF\"\n} {0 {}}\ndo_test shell1-3.5.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".echo OFF BAD\"\n} {1 {Usage: .echo on|off}}\n\n# .exit                  Exit this program\ndo_test shell1-3.6.1 {\n  catchcmd \"test.db\" \".exit\"\n} {0 {}}\n\n# .explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.\ndo_test shell1-3.7.1 {\n  catchcmd \"test.db\" \".explain\"\n  # explain is the exception to the booleans.  without an option, it turns it on.\n} {0 {}}\ndo_test shell1-3.7.2 {\n  catchcmd \"test.db\" \".explain ON\"\n} {0 {}}\ndo_test shell1-3.7.3 {\n  catchcmd \"test.db\" \".explain OFF\"\n} {0 {}}\ndo_test shell1-3.7.4 {\n  # extra arguments ignored\n  catchcmd \"test.db\" \".explain OFF BAD\"\n} {0 {}}\n\n\n# .header(s) ON|OFF      Turn display of headers on or off\ndo_test shell1-3.9.1 {\n  catchcmd \"test.db\" \".header\"\n} {1 {Usage: .headers on|off}}\ndo_test shell1-3.9.2 {\n  catchcmd \"test.db\" \".header ON\"\n} {0 {}}\ndo_test shell1-3.9.3 {\n  catchcmd \"test.db\" \".header OFF\"\n} {0 {}}\ndo_test shell1-3.9.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".header OFF BAD\"\n} {1 {Usage: .headers on|off}}\n\ndo_test shell1-3.9.5 {\n  catchcmd \"test.db\" \".headers\"\n} {1 {Usage: .headers on|off}}\ndo_test shell1-3.9.6 {\n  catchcmd \"test.db\" \".headers ON\"\n} {0 {}}\ndo_test shell1-3.9.7 {\n  catchcmd \"test.db\" \".headers OFF\"\n} {0 {}}\ndo_test shell1-3.9.8 {\n  # too many arguments\n  catchcmd \"test.db\" \".headers OFF BAD\"\n} {1 {Usage: .headers on|off}}\n\n# .help                  Show this message\ndo_test shell1-3.10.1 {\n  set res [catchcmd \"test.db\" \".help\"]\n  # look for a few of the possible help commands\n  list [regexp {.help} $res] \\\n       [regexp {.quit} $res] \\\n       [regexp {.show} $res]\n} {1 1 1}\ndo_test shell1-3.10.2 {\n  # we allow .help to take extra args (it is help after all)\n  set res [catchcmd \"test.db\" \".help BAD\"]\n  # look for a few of the possible help commands\n  list [regexp {.help} $res] \\\n       [regexp {.quit} $res] \\\n       [regexp {.show} $res]\n} {1 1 1}\n\n# .import FILE TABLE     Import data from FILE into TABLE\ndo_test shell1-3.11.1 {\n  catchcmd \"test.db\" \".import\"\n} {1 {Usage: .import FILE TABLE}}\ndo_test shell1-3.11.2 {\n  catchcmd \"test.db\" \".import FOO\"\n} {1 {Usage: .import FILE TABLE}}\n#do_test shell1-3.11.2 {\n#  catchcmd \"test.db\" \".import FOO BAR\"\n#} {1 {Error: no such table: BAR}}\ndo_test shell1-3.11.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".import FOO BAR BAD\"\n} {1 {Usage: .import FILE TABLE}}\n\n# .indexes ?TABLE?       Show names of all indexes\n#                          If TABLE specified, only show indexes for tables\n#                          matching LIKE pattern TABLE.\ndo_test shell1-3.12.1 {\n  catchcmd \"test.db\" \".indexes\"\n} {0 {}}\ndo_test shell1-3.12.2 {\n  catchcmd \"test.db\" \".indexes FOO\"\n} {0 {}}\ndo_test shell1-3.12.2-legacy {\n  catchcmd \"test.db\" \".indices FOO\"\n} {0 {}}\ndo_test shell1-3.12.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".indexes FOO BAD\"\n} {1 {Usage: .indexes ?LIKE-PATTERN?}}\n\n# .mode MODE ?TABLE?     Set output mode where MODE is one of:\n#                          ascii    Columns/rows delimited by 0x1F and 0x1E\n#                          csv      Comma-separated values\n#                          column   Left-aligned columns.  (See .width)\n#                          html     HTML <table> code\n#                          insert   SQL insert statements for TABLE\n#                          line     One value per line\n#                          list     Values delimited by .separator strings\n#                          tabs     Tab-separated values\n#                          tcl      TCL list elements\ndo_test shell1-3.13.1 {\n  catchcmd \"test.db\" \".mode\"\n} {0 {current output mode: list}}\ndo_test shell1-3.13.2 {\n  catchcmd \"test.db\" \".mode FOO\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\ndo_test shell1-3.13.3 {\n  catchcmd \"test.db\" \".mode csv\"\n} {0 {}}\ndo_test shell1-3.13.4 {\n  catchcmd \"test.db\" \".mode column\"\n} {0 {}}\ndo_test shell1-3.13.5 {\n  catchcmd \"test.db\" \".mode html\"\n} {0 {}}\ndo_test shell1-3.13.6 {\n  catchcmd \"test.db\" \".mode insert\"\n} {0 {}}\ndo_test shell1-3.13.7 {\n  catchcmd \"test.db\" \".mode line\"\n} {0 {}}\ndo_test shell1-3.13.8 {\n  catchcmd \"test.db\" \".mode list\"\n} {0 {}}\ndo_test shell1-3.13.9 {\n  catchcmd \"test.db\" \".mode tabs\"\n} {0 {}}\ndo_test shell1-3.13.10 {\n  catchcmd \"test.db\" \".mode tcl\"\n} {0 {}}\ndo_test shell1-3.13.11 {\n  # extra arguments ignored\n  catchcmd \"test.db\" \".mode tcl BAD\"\n} {0 {}}\n\n# don't allow partial mode type matches\ndo_test shell1-3.13.12 {\n  catchcmd \"test.db\" \".mode l\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\ndo_test shell1-3.13.13 {\n  catchcmd \"test.db\" \".mode li\"\n} {1 {Error: mode should be one of: ascii column csv html insert line list quote tabs tcl}}\ndo_test shell1-3.13.14 {\n  catchcmd \"test.db\" \".mode lin\"\n} {0 {}}\n\n# .nullvalue STRING      Print STRING in place of NULL values\ndo_test shell1-3.14.1 {\n  catchcmd \"test.db\" \".nullvalue\"\n} {1 {Usage: .nullvalue STRING}}\ndo_test shell1-3.14.2 {\n  catchcmd \"test.db\" \".nullvalue FOO\"\n} {0 {}}\ndo_test shell1-3.14.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".nullvalue FOO BAD\"\n} {1 {Usage: .nullvalue STRING}}\n\n# .output FILENAME       Send output to FILENAME\ndo_test shell1-3.15.1 {\n  catchcmd \"test.db\" \".output\"\n} {0 {}}\ndo_test shell1-3.15.2 {\n  catchcmd \"test.db\" \".output FOO\"\n} {0 {}}\ndo_test shell1-3.15.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".output FOO BAD\"\n} {1 {Usage: .output FILE}}\n\n# .output stdout         Send output to the screen\ndo_test shell1-3.16.1 {\n  catchcmd \"test.db\" \".output stdout\"\n} {0 {}}\ndo_test shell1-3.16.2 {\n  # too many arguments\n  catchcmd \"test.db\" \".output stdout BAD\"\n} {1 {Usage: .output FILE}}\n\n# .prompt MAIN CONTINUE  Replace the standard prompts\ndo_test shell1-3.17.1 {\n  catchcmd \"test.db\" \".prompt\"\n} {0 {}}\ndo_test shell1-3.17.2 {\n  catchcmd \"test.db\" \".prompt FOO\"\n} {0 {}}\ndo_test shell1-3.17.3 {\n  catchcmd \"test.db\" \".prompt FOO BAR\"\n} {0 {}}\ndo_test shell1-3.17.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".prompt FOO BAR BAD\"\n} {0 {}}\n\n# .quit                  Exit this program\ndo_test shell1-3.18.1 {\n  catchcmd \"test.db\" \".quit\"\n} {0 {}}\ndo_test shell1-3.18.2 {\n  # too many arguments\n  catchcmd \"test.db\" \".quit BAD\"\n} {0 {}}\n\n# .read FILENAME         Execute SQL in FILENAME\ndo_test shell1-3.19.1 {\n  catchcmd \"test.db\" \".read\"\n} {1 {Usage: .read FILE}}\ndo_test shell1-3.19.2 {\n  forcedelete FOO\n  catchcmd \"test.db\" \".read FOO\"\n} {1 {Error: cannot open \"FOO\"}}\ndo_test shell1-3.19.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".read FOO BAD\"\n} {1 {Usage: .read FILE}}\n\n# .restore ?DB? FILE     Restore content of DB (default \"main\") from FILE\ndo_test shell1-3.20.1 {\n  catchcmd \"test.db\" \".restore\"\n} {1 {Usage: .restore ?DB? FILE}}\ndo_test shell1-3.20.2 {\n  catchcmd \"test.db\" \".restore FOO\"\n} {0 {}}\ndo_test shell1-3.20.3 {\n  catchcmd \"test.db\" \".restore FOO BAR\"\n} {1 {Error: unknown database FOO}}\ndo_test shell1-3.20.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".restore FOO BAR BAD\"\n} {1 {Usage: .restore ?DB? FILE}}\n\nifcapable vtab {\n# .schema ?TABLE?        Show the CREATE statements\n#                          If TABLE specified, only show tables matching\n#                          LIKE pattern TABLE.\ndo_test shell1-3.21.1 {\n  catchcmd \"test.db\" \".schema\"\n} {0 {}}\ndo_test shell1-3.21.2 {\n  catchcmd \"test.db\" \".schema FOO\"\n} {0 {}}\ndo_test shell1-3.21.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".schema FOO BAD\"\n} {1 {Usage: .schema ?--indent? ?LIKE-PATTERN?}}\n\ndo_test shell1-3.21.4 {\n  catchcmd \"test.db\" {\n     CREATE TABLE t1(x);\n     CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;\n     CREATE VIEW v1 AS SELECT y+1 FROM v2;\n  }\n  catchcmd \"test.db\" \".schema\"\n} {0 {CREATE TABLE t1(x);\nCREATE VIEW v2 AS SELECT x+1 AS y FROM t1;\nCREATE VIEW v1 AS SELECT y+1 FROM v2;}}\ndb eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}\n}\n\n# .separator STRING  Change column separator used by output and .import\ndo_test shell1-3.22.1 {\n  catchcmd \"test.db\" \".separator\"\n} {1 {Usage: .separator COL ?ROW?}}\ndo_test shell1-3.22.2 {\n  catchcmd \"test.db\" \".separator FOO\"\n} {0 {}}\ndo_test shell1-3.22.3 {\n  catchcmd \"test.db\" \".separator ABC XYZ\"\n} {0 {}}\ndo_test shell1-3.22.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".separator FOO BAD BAD2\"\n} {1 {Usage: .separator COL ?ROW?}}\n\n# .show                  Show the current values for various settings\ndo_test shell1-3.23.1 {\n  set res [catchcmd \"test.db\" \".show\"]\n  list [regexp {echo:} $res] \\\n       [regexp {explain:} $res] \\\n       [regexp {headers:} $res] \\\n       [regexp {mode:} $res] \\\n       [regexp {nullvalue:} $res] \\\n       [regexp {output:} $res] \\\n       [regexp {colseparator:} $res] \\\n       [regexp {rowseparator:} $res] \\\n       [regexp {stats:} $res] \\\n       [regexp {width:} $res]\n} {1 1 1 1 1 1 1 1 1 1}\ndo_test shell1-3.23.2 {\n  # too many arguments\n  catchcmd \"test.db\" \".show BAD\"\n} {1 {Usage: .show}}\n\n# .stats ON|OFF          Turn stats on or off\n#do_test shell1-3.23b.1 {\n#  catchcmd \"test.db\" \".stats\"\n#} {1 {Usage: .stats on|off}}\ndo_test shell1-3.23b.2 {\n  catchcmd \"test.db\" \".stats ON\"\n} {0 {}}\ndo_test shell1-3.23b.3 {\n  catchcmd \"test.db\" \".stats OFF\"\n} {0 {}}\ndo_test shell1-3.23b.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".stats OFF BAD\"\n} {1 {Usage: .stats ?on|off?}}\n\n# .tables ?TABLE?        List names of tables\n#                          If TABLE specified, only list tables matching\n#                          LIKE pattern TABLE.\ndo_test shell1-3.24.1 {\n  catchcmd \"test.db\" \".tables\"\n} {0 {}}\ndo_test shell1-3.24.2 {\n  catchcmd \"test.db\" \".tables FOO\"\n} {0 {}}\ndo_test shell1-3.24.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".tables FOO BAD\"\n} {0 {}}\n\n# .timeout MS            Try opening locked tables for MS milliseconds\ndo_test shell1-3.25.1 {\n  catchcmd \"test.db\" \".timeout\"\n} {0 {}}\ndo_test shell1-3.25.2 {\n  catchcmd \"test.db\" \".timeout zzz\"\n  # this should be treated the same as a '0' timeout\n} {0 {}}\ndo_test shell1-3.25.3 {\n  catchcmd \"test.db\" \".timeout 1\"\n} {0 {}}\ndo_test shell1-3.25.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".timeout 1 BAD\"\n} {0 {}}\n\n# .width NUM NUM ...     Set column widths for \"column\" mode\ndo_test shell1-3.26.1 {\n  catchcmd \"test.db\" \".width\"\n} {0 {}}\ndo_test shell1-3.26.2 {\n  catchcmd \"test.db\" \".width xxx\"\n  # this should be treated the same as a '0' width for col 1\n} {0 {}}\ndo_test shell1-3.26.3 {\n  catchcmd \"test.db\" \".width xxx yyy\"\n  # this should be treated the same as a '0' width for col 1 and 2\n} {0 {}}\ndo_test shell1-3.26.4 {\n  catchcmd \"test.db\" \".width 1 1\"\n  # this should be treated the same as a '1' width for col 1 and 2\n} {0 {}}\ndo_test shell1-3.26.5 {\n  catchcmd \"test.db\" \".mode column\\n.width 10 -10\\nSELECT 'abcdefg', 123456;\"\n  # this should be treated the same as a '1' width for col 1 and 2\n} {0 {abcdefg         123456}}\ndo_test shell1-3.26.6 {\n  catchcmd \"test.db\" \".mode column\\n.width -10 10\\nSELECT 'abcdefg', 123456;\"\n  # this should be treated the same as a '1' width for col 1 and 2\n} {0 {   abcdefg  123456    }}\n\n\n# .timer ON|OFF          Turn the CPU timer measurement on or off\ndo_test shell1-3.27.1 {\n  catchcmd \"test.db\" \".timer\"\n} {1 {Usage: .timer on|off}}\ndo_test shell1-3.27.2 {\n  catchcmd \"test.db\" \".timer ON\"\n} {0 {}}\ndo_test shell1-3.27.3 {\n  catchcmd \"test.db\" \".timer OFF\"\n} {0 {}}\ndo_test shell1-3.27.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".timer OFF BAD\"\n} {1 {Usage: .timer on|off}}\n\ndo_test shell1-3-28.1 {\n  catchcmd test.db \\\n     \".log stdout\\nSELECT coalesce(sqlite_log(123,'hello'),'456');\"\n} \"0 {(123) hello\\n456}\"\n\ndo_test shell1-3-29.1 {\n  catchcmd \"test.db\" \".print this is a test\"\n} {0 {this is a test}}\n\n# dot-command argument quoting\ndo_test shell1-3-30.1 {\n  catchcmd {test.db} {.print \"this\\\"is'a\\055test\" 'this\\\"is\\\\a\\055test'}\n} {0 {this\"is'a-test this\\\"is\\\\a\\055test}}\ndo_test shell1-3-31.1 {\n  catchcmd {test.db} {.print \"this\\nis\\ta\\\\test\" 'this\\nis\\ta\\\\test'}\n} [list 0 \"this\\nis\\ta\\\\test this\\\\nis\\\\ta\\\\\\\\test\"]\n\n\n# Test the output of the \".dump\" command\n#\ndo_test shell1-4.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');\n    CREATE TABLE t3(x,y);\n    INSERT INTO t3 VALUES(1,null), (2,''), (3,1),\n                         (4,2.25), (5,'hello'), (6,x'807f');\n  }\n  catchcmd test.db {.dump}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE t1(x);\nINSERT INTO t1 VALUES(NULL);\nINSERT INTO t1 VALUES('');\nINSERT INTO t1 VALUES(1);\nINSERT INTO t1 VALUES(2.25);\nINSERT INTO t1 VALUES('hello');\nINSERT INTO t1 VALUES(X'807f');\nCREATE TABLE t3(x,y);\nINSERT INTO t3 VALUES(1,NULL);\nINSERT INTO t3 VALUES(2,'');\nINSERT INTO t3 VALUES(3,1);\nINSERT INTO t3 VALUES(4,2.25);\nINSERT INTO t3 VALUES(5,'hello');\nINSERT INTO t3 VALUES(6,X'807f');\nCOMMIT;}}\n\n\nifcapable vtab {\n\n# The --preserve-rowids option to .dump\n#\ndo_test shell1-4.1.1 {\n  catchcmd test.db {.dump --preserve-rowids}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE t1(x);\nINSERT INTO t1(rowid,x) VALUES(1,NULL);\nINSERT INTO t1(rowid,x) VALUES(2,'');\nINSERT INTO t1(rowid,x) VALUES(3,1);\nINSERT INTO t1(rowid,x) VALUES(4,2.25);\nINSERT INTO t1(rowid,x) VALUES(5,'hello');\nINSERT INTO t1(rowid,x) VALUES(6,X'807f');\nCREATE TABLE t3(x,y);\nINSERT INTO t3(rowid,x,y) VALUES(1,1,NULL);\nINSERT INTO t3(rowid,x,y) VALUES(2,2,'');\nINSERT INTO t3(rowid,x,y) VALUES(3,3,1);\nINSERT INTO t3(rowid,x,y) VALUES(4,4,2.25);\nINSERT INTO t3(rowid,x,y) VALUES(5,5,'hello');\nINSERT INTO t3(rowid,x,y) VALUES(6,6,X'807f');\nCOMMIT;}}\n\n# If the table contains an INTEGER PRIMARY KEY, do not record a separate\n# rowid column in the output.\n#\ndo_test shell1-4.1.2 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n  db eval {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(1,null), (2,''), (3,1),\n                         (4,2.25), (5,'hello'), (6,x'807f');\n  }\n  catchcmd test2.db {.dump --preserve-rowids}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE t1(x INTEGER PRIMARY KEY, y);\nINSERT INTO t1 VALUES(1,NULL);\nINSERT INTO t1 VALUES(2,'');\nINSERT INTO t1 VALUES(3,1);\nINSERT INTO t1 VALUES(4,2.25);\nINSERT INTO t1 VALUES(5,'hello');\nINSERT INTO t1 VALUES(6,X'807f');\nCOMMIT;}}\n\n# Verify that the table named [table] is correctly quoted and that\n# an INTEGER PRIMARY KEY DESC is not an alias for the rowid.\n#\ndo_test shell1-4.1.3 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n  db eval {\n    CREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);\n    INSERT INTO [table] VALUES(1,null), (12,''), (23,1),\n                         (34,2.25), (45,'hello'), (56,x'807f');\n  }\n  catchcmd test2.db {.dump --preserve-rowids}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE [table](x INTEGER PRIMARY KEY DESC, y);\nINSERT INTO \"table\"(rowid,x,y) VALUES(1,1,NULL);\nINSERT INTO \"table\"(rowid,x,y) VALUES(2,12,'');\nINSERT INTO \"table\"(rowid,x,y) VALUES(3,23,1);\nINSERT INTO \"table\"(rowid,x,y) VALUES(4,34,2.25);\nINSERT INTO \"table\"(rowid,x,y) VALUES(5,45,'hello');\nINSERT INTO \"table\"(rowid,x,y) VALUES(6,56,X'807f');\nCOMMIT;}}\n\n# Do not record rowids for a WITHOUT ROWID table.  Also check correct quoting\n# of table names that contain odd characters.\n#\ndo_test shell1-4.1.4 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n  db eval {\n    CREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;\n    INSERT INTO [ta<>ble] VALUES(1,null), (12,''), (23,1),\n                         (34,2.25), (45,'hello'), (56,x'807f');\n  }\n  catchcmd test2.db {.dump --preserve-rowids}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE [ta<>ble](x INTEGER PRIMARY KEY, y) WITHOUT ROWID;\nINSERT INTO \"ta<>ble\" VALUES(1,NULL);\nINSERT INTO \"ta<>ble\" VALUES(12,'');\nINSERT INTO \"ta<>ble\" VALUES(23,1);\nINSERT INTO \"ta<>ble\" VALUES(34,2.25);\nINSERT INTO \"ta<>ble\" VALUES(45,'hello');\nINSERT INTO \"ta<>ble\" VALUES(56,X'807f');\nCOMMIT;}}\n\n# Do not record rowids if the rowid is inaccessible\n#\ndo_test shell1-4.1.5 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n  db eval {\n    CREATE TABLE t1(_ROWID_,rowid,oid);\n    INSERT INTO t1 VALUES(1,null,'alpha'), (12,'',99), (23,1,x'b0b1b2');\n  }\n  catchcmd test2.db {.dump --preserve-rowids}\n} {0 {PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\nCREATE TABLE t1(_ROWID_,rowid,oid);\nINSERT INTO t1 VALUES(1,NULL,'alpha');\nINSERT INTO t1 VALUES(12,'',99);\nINSERT INTO t1 VALUES(23,1,X'b0b1b2');\nCOMMIT;}}\n\n} else {\n\ndo_test shell1-4.1.6 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n  db eval {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(1,null), (2,''), (3,1),\n                         (4,2.25), (5,'hello'), (6,x'807f');\n  }\n  catchcmd test2.db {.dump --preserve-rowids}\n} {1 {The --preserve-rowids option is not compatible with SQLITE_OMIT_VIRTUALTABLE}}\n\n}\n\n\n# Test the output of \".mode insert\"\n#\ndo_test shell1-4.2.1 {\n  catchcmd test.db \".mode insert t1\\nselect * from t1;\"\n} {0 {INSERT INTO t1 VALUES(NULL);\nINSERT INTO t1 VALUES('');\nINSERT INTO t1 VALUES(1);\nINSERT INTO t1 VALUES(2.25);\nINSERT INTO t1 VALUES('hello');\nINSERT INTO t1 VALUES(X'807f');}}\n\n# Test the output of \".mode insert\" with headers\n#\ndo_test shell1-4.2.2 {\n  catchcmd test.db \".mode insert t1\\n.headers on\\nselect * from t1;\"\n} {0 {INSERT INTO t1(x) VALUES(NULL);\nINSERT INTO t1(x) VALUES('');\nINSERT INTO t1(x) VALUES(1);\nINSERT INTO t1(x) VALUES(2.25);\nINSERT INTO t1(x) VALUES('hello');\nINSERT INTO t1(x) VALUES(X'807f');}}\n\n# Test the output of \".mode insert\"\n#\ndo_test shell1-4.2.3 {\n  catchcmd test.db \".mode insert t3\\nselect * from t3;\"\n} {0 {INSERT INTO t3 VALUES(1,NULL);\nINSERT INTO t3 VALUES(2,'');\nINSERT INTO t3 VALUES(3,1);\nINSERT INTO t3 VALUES(4,2.25);\nINSERT INTO t3 VALUES(5,'hello');\nINSERT INTO t3 VALUES(6,X'807f');}}\n\n# Test the output of \".mode insert\" with headers\n#\ndo_test shell1-4.2.4 {\n  catchcmd test.db \".mode insert t3\\n.headers on\\nselect * from t3;\"\n} {0 {INSERT INTO t3(x,y) VALUES(1,NULL);\nINSERT INTO t3(x,y) VALUES(2,'');\nINSERT INTO t3(x,y) VALUES(3,1);\nINSERT INTO t3(x,y) VALUES(4,2.25);\nINSERT INTO t3(x,y) VALUES(5,'hello');\nINSERT INTO t3(x,y) VALUES(6,X'807f');}}\n\n# Test the output of \".mode tcl\"\n#\ndo_test shell1-4.3 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA encoding=UTF8;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');\n  }\n  catchcmd test.db \".mode tcl\\nselect * from t1;\"\n} {0 {\"\"\n\"\"\n\"1\"\n\"2.25\"\n\"hello\"\n\"\\200\\177\"}}\n\n# Test the output of \".mode tcl\" with multiple columns\n#\ndo_test shell1-4.4 {\n  db eval {\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(null, ''), (1, 2.25), ('hello', x'807f');\n  }\n  catchcmd test.db \".mode tcl\\nselect * from t2;\"\n} {0 {\"\" \"\"\n\"1\" \"2.25\"\n\"hello\" \"\\200\\177\"}}\n\n# Test the output of \".mode tcl\" with \".nullvalue\"\n#\ndo_test shell1-4.5 {\n  catchcmd test.db \".mode tcl\\n.nullvalue NULL\\nselect * from t2;\"\n} {0 {\"NULL\" \"\"\n\"1\" \"2.25\"\n\"hello\" \"\\200\\177\"}}\n\n# Test the output of \".mode tcl\" with Tcl reserved characters\n#\ndo_test shell1-4.6 {\n  db eval {\n    CREATE TABLE tcl1(x);\n    INSERT INTO tcl1 VALUES('\"'), ('['), (']'), ('\\{'), ('\\}'), (';'), ('$');\n  }\n  foreach {x y} [catchcmd test.db \".mode tcl\\nselect * from tcl1;\"] break\n  list $x $y [llength $y]\n} {0 {\"\\\"\"\n\"[\"\n\"]\"\n\"\\\\{\"\n\"\\\\}\"\n\";\"\n\"$\"} 7}\n\n# Test using arbitrary byte data with the shell via standard input/output.\n#\ndo_test shell1-5.0 {\n  #\n  # NOTE: Skip NUL byte because it appears to be incompatible with command\n  #       shell argument parsing.\n  #\n  for {set i 1} {$i < 256} {incr i} {\n    #\n    # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats\n    #       command channels opened for it as textual ones), the carriage\n    #       return character (and on Windows, the end-of-file character)\n    #       cannot be used here.\n    #\n    if {$i==0x0D || ($tcl_platform(platform)==\"windows\" && $i==0x1A)} {\n      continue\n    }\n    if {$i>=0xE0 && $tcl_platform(os)==\"OpenBSD\"}  continue\n    if {$i>=0xE0 && $i<=0xEF && $tcl_platform(os)==\"Linux\"}  continue\n    set hex [format %02X $i]\n    set char [subst \\\\x$hex]; set oldChar $char\n    set escapes [list]\n    if {$tcl_platform(platform)==\"windows\"} {\n      #\n      # NOTE: On Windows, we need to escape all the whitespace characters,\n      #       the alarm (\\a) character, and those with special meaning to\n      #       the SQLite shell itself.\n      #\n      set escapes [list \\\n          \\a \\\\a \\b \\\\b \\t \\\\t \\n \\\\n \\v \\\\v \\f \\\\f \\r \\\\r \\\n          \" \" \"\\\" \\\"\" \\\" \\\\\\\" ' \\\"'\\\" \\\\ \\\\\\\\]\n    } else {\n      #\n      # NOTE: On Unix, we need to escape most of the whitespace characters\n      #       and those with special meaning to the SQLite shell itself.\n      #       The alarm (\\a), backspace (\\b), and carriage-return (\\r)\n      #       characters do not appear to require escaping on Unix.  For\n      #       the alarm and backspace characters, this is probably due to\n      #       differences in the command shell.  For the carriage-return,\n      #       it is probably due to differences in how Tcl handles command\n      #       channel end-of-line translations.\n      #\n      set escapes [list \\\n          \\t \\\\t \\n \\\\n \\v \\\\v \\f \\\\f \\\n          \" \" \"\\\" \\\"\" \\\" \\\\\\\" ' \\\"'\\\" \\\\ \\\\\\\\]\n    }\n    set char [string map $escapes $char]\n    set x [catchcmdex test.db \".print $char\\n\"]\n    set code [lindex $x 0]\n    set res [lindex $x 1]\n    if {$code ne \"0\"} {\n      error \"failed with error: $res\"\n    }\n    if {$res ne \"$oldChar\\n\"} {\n      if {[llength $res] > 0} {\n        set got [format %02X [scan $res %c]]\n      } else {\n        set got <empty>\n      }\n      error \"failed with byte $hex mismatch, got $got\"\n    }\n  }\n} {}\n\n# These test cases do not work on MinGW\nif 0 {\n\n# The string used here is the word \"test\" in Chinese.\n# In UTF-8, it is encoded as: \\xE6\\xB5\\x8B\\xE8\\xAF\\x95\nset test \\u6D4B\\u8BD5\n\ndo_test shell1-6.0 {\n  set fileName $test; append fileName .db\n  catch {forcedelete $fileName}\n  set x [catchcmdex $fileName \"CREATE TABLE t1(x);\\n.schema\\n\"]\n  set code [lindex $x 0]\n  set res [string trim [lindex $x 1]]\n  if {$code ne \"0\"} {\n    error \"failed with error: $res\"\n  }\n  if {$res ne \"CREATE TABLE t1(x);\"} {\n    error \"failed with mismatch: $res\"\n  }\n  if {![file exists $fileName]} {\n    error \"file \\\"$fileName\\\" (Unicode) does not exist\"\n  }\n  forcedelete $fileName\n} {}\n\ndo_test shell1-6.1 {\n  catch {forcedelete test3.db}\n  set x [catchcmdex test3.db \\\n      \"CREATE TABLE [encoding convertto utf-8 $test](x);\\n.schema\\n\"]\n  set code [lindex $x 0]\n  set res [string trim [lindex $x 1]]\n  if {$code ne \"0\"} {\n    error \"failed with error: $res\"\n  }\n  if {$res ne \"CREATE TABLE ${test}(x);\"} {\n    error \"failed with mismatch: $res\"\n  }\n  forcedelete test3.db\n} {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell2.test",
    "content": "# 2009 Nov 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the CLI shell tool.\n#\n# $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $\n#\n\n# Test plan:\n#\n#   shell2-1.*: Misc. test of various tickets and reported errors.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\nsqlite3 db test.db\n\n\n#----------------------------------------------------------------------------\n#   shell2-1.*: Misc. test of various tickets and reported errors.\n#\n\n# Batch mode not creating databases.  \n# Reported on mailing list by Ken Zalewski.\n# Ticket [aeff892c57].\ndo_test shell2-1.1.1 {\n  forcedelete foo.db\n  set rc [ catchcmd \"-batch foo.db\" \"CREATE TABLE t1(a);\" ]\n  set fexist [file exist foo.db]\n  list $rc $fexist\n} {{0 {}} 1}\n\n# Shell silently ignores extra parameters.\n# Ticket [f5cb008a65].\ndo_test shell2-1.2.1 {\n  set rc [catch { eval exec $CLI \\\":memory:\\\" \\\"select+3\\\" \\\"select+4\\\" } msg]\n  list $rc $msg\n} {0 {3\n4}}\n\n# Test a problem reported on the mailing list. The shell was at one point\n# returning the generic SQLITE_ERROR message (\"SQL error or missing database\")\n# instead of the \"too many levels...\" message in the test below.\n#\ndo_test shell2-1.3 {\n  catchcmd \"-batch test.db\" {\n    PRAGMA recursive_triggers = ON;\n    CREATE TABLE t5(a PRIMARY KEY, b, c);\n    INSERT INTO t5 VALUES(1, 2, 3);\n    CREATE TRIGGER au_tble AFTER UPDATE ON t5 BEGIN\n      UPDATE OR IGNORE t5 SET a = new.a, c = 10;\n    END;\n\n    UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;\n  }\n} {1 {Error: near line 9: too many levels of trigger recursion}}\n\n\n\n# Shell not echoing all commands with echo on.\n# Ticket [eb620916be].\n\n# Test with echo off\n# NB. whitespace is important\ndo_test shell2-1.4.1 {\n  forcedelete foo.db\n  catchcmd \"foo.db\" {CREATE TABLE foo(a);\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;}\n} {0 1}\n\n# Test with echo on using command line option\n# NB. whitespace is important\ndo_test shell2-1.4.2 {\n  forcedelete foo.db\n  catchcmd \"-echo foo.db\" {CREATE TABLE foo(a);\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;}\n} {0 {CREATE TABLE foo(a);\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;\n1}}\n\n# Test with echo on using dot command\n# NB. whitespace is important\ndo_test shell2-1.4.3 {\n  forcedelete foo.db\n  catchcmd \"foo.db\" {.echo ON\nCREATE TABLE foo(a);\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;}\n} {0 {CREATE TABLE foo(a);\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;\n1}}\n\n# Test with echo on using dot command and \n# turning off mid- processing.\n# NB. whitespace is important\ndo_test shell2-1.4.4 {\n  forcedelete foo.db\n  catchcmd \"foo.db\" {.echo ON\nCREATE TABLE foo(a);\n.echo OFF\nINSERT INTO foo(a) VALUES(1);\nSELECT * FROM foo;}\n} {0 {CREATE TABLE foo(a);\n.echo OFF\n1}}\n\n# Test with echo on using dot command and \n# multiple commands per line.\n# NB. whitespace is important\ndo_test shell2-1.4.5 {\n  forcedelete foo.db\n  catchcmd \"foo.db\" {.echo ON\nCREATE TABLE foo1(a);\nINSERT INTO foo1(a) VALUES(1);\nCREATE TABLE foo2(b);\nINSERT INTO foo2(b) VALUES(1);\nSELECT * FROM foo1; SELECT * FROM foo2;\nINSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);\nSELECT * FROM foo1; SELECT * FROM foo2;\n}\n} {0 {CREATE TABLE foo1(a);\nINSERT INTO foo1(a) VALUES(1);\nCREATE TABLE foo2(b);\nINSERT INTO foo2(b) VALUES(1);\nSELECT * FROM foo1;\n1\nSELECT * FROM foo2;\n1\nINSERT INTO foo1(a) VALUES(2);\nINSERT INTO foo2(b) VALUES(2);\nSELECT * FROM foo1;\n1\n2\nSELECT * FROM foo2;\n1\n2\n}}\n\n# Test with echo on and headers on using dot command and \n# multiple commands per line.\n# NB. whitespace is important\ndo_test shell2-1.4.6 {\n  forcedelete foo.db\n  catchcmd \"foo.db\" {.echo ON\n.headers ON\nCREATE TABLE foo1(a);\nINSERT INTO foo1(a) VALUES(1);\nCREATE TABLE foo2(b);\nINSERT INTO foo2(b) VALUES(1);\nSELECT * FROM foo1; SELECT * FROM foo2;\nINSERT INTO foo1(a) VALUES(2); INSERT INTO foo2(b) VALUES(2);\nSELECT * FROM foo1; SELECT * FROM foo2;\n}\n} {0 {.headers ON\nCREATE TABLE foo1(a);\nINSERT INTO foo1(a) VALUES(1);\nCREATE TABLE foo2(b);\nINSERT INTO foo2(b) VALUES(1);\nSELECT * FROM foo1;\na\n1\nSELECT * FROM foo2;\nb\n1\nINSERT INTO foo1(a) VALUES(2);\nINSERT INTO foo2(b) VALUES(2);\nSELECT * FROM foo1;\na\n1\n2\nSELECT * FROM foo2;\nb\n1\n2\n}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell3.test",
    "content": "# 2009 Dec 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the CLI shell tool.\n#\n# $Id: shell2.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $\n#\n\n# Test plan:\n#\n#   shell3-1.*: Basic tests for running SQL statments from command line.\n#   shell3-2.*: Basic tests for running SQL file from command line.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\nsqlite3 db test.db\n\n# There are inconsistencies in command-line argument quoting on Windows.\n# In particular, individual applications are responsible for command-line\n# parsing in Windows, not the shell.  Depending on whether the sqlite3.exe\n# program is compiled with MinGW or MSVC, the command-line parsing is\n# different.  This causes problems for the tests below.  To avoid\n# issues, these tests are disabled for windows.\n#\nif {$::tcl_platform(platform)==\"windows\"} {\n  finish_test\n  return\n}\n\n#----------------------------------------------------------------------------\n#   shell3-1.*: Basic tests for running SQL statments from command line.\n#\n\n# Run SQL statement from command line\ndo_test shell3-1.1 {\n  forcedelete foo.db\n  set rc [ catchcmd \"foo.db \\\"CREATE TABLE t1(a);\\\"\" ]\n  set fexist [file exist foo.db]\n  list $rc $fexist\n} {{0 {}} 1}\ndo_test shell3-1.2 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 t1}\ndo_test shell3-1.3 {\n  catchcmd \"foo.db \\\"DROP TABLE t1;\\\"\"\n} {0 {}}\ndo_test shell3-1.4 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 {}}\ndo_test shell3-1.5 {\n  catchcmd \"foo.db \\\"CREATE TABLE t1(a); DROP TABLE t1;\\\"\"\n} {0 {}}\ndo_test shell3-1.6 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 {}}\ndo_test shell3-1.7 {\n  catchcmd \"foo.db \\\"CREATE TABLE\\\"\"\n} {1 {Error: near \"TABLE\": syntax error}}\n\n#----------------------------------------------------------------------------\n#   shell3-2.*: Basic tests for running SQL file from command line.\n#\n\n# Run SQL file from command line\ndo_test shell3-2.1 {\n  forcedelete foo.db\n  set rc [ catchcmd \"foo.db\" \"CREATE TABLE t1(a);\" ]\n  set fexist [file exist foo.db]\n  list $rc $fexist\n} {{0 {}} 1}\ndo_test shell3-2.2 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 t1}\ndo_test shell3-2.3 {\n  catchcmd \"foo.db\" \"DROP TABLE t1;\"\n} {0 {}}\ndo_test shell3-2.4 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 {}}\ndo_test shell3-2.5 {\n  catchcmd \"foo.db\" \"CREATE TABLE t1(a); DROP TABLE t1;\"\n} {0 {}}\ndo_test shell3-2.6 {\n  catchcmd \"foo.db\" \".tables\"\n} {0 {}}\ndo_test shell3-2.7 {\n  catchcmd \"foo.db\" \"CREATE TABLE\"\n} {1 {Error: near line 1: near \"TABLE\": syntax error}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell4.test",
    "content": "# 2010 July 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the CLI shell tool.\n# These tests are specific to the .stats command.\n#\n# 2015-03-19:  Added tests for .trace\n\n# Test plan:\n#\n#   shell4-1.*: Basic tests specific to the \"stats\" command.\n#   shell4-2.*: Basic tests for \".trace\"\n#   shell4-3.*: The \".read\" command takes the shell out of interactive mode\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\nsqlite3 db test.db\n\n#----------------------------------------------------------------------------\n# Test cases shell4-1.*: Tests specific to the \"stats\" command.\n#\n\n# should default to off\ndo_test shell4-1.1.1 {\n  set res [catchcmd \"test.db\" \".show\"]\n  list [regexp {stats: off} $res]\n} {1}\n\ndo_test shell4-1.1.2 {\n  set res [catchcmd \"test.db\" \".show\"]\n  list [regexp {stats: on} $res]\n} {0}\n\n# -stats should turn it on\ndo_test shell4-1.2.1 {\n  set res [catchcmd \"-stats test.db\" \".show\"]\n  list [regexp {stats: on} $res]\n} {1}\n\ndo_test shell4-1.2.2 {\n  set res [catchcmd \"-stats test.db\" \".show\"]\n  list [regexp {stats: off} $res]\n} {0}\n\n# .stats ON|OFF          Turn stats on or off\n#do_test shell4-1.3.1 {\n#  catchcmd \"test.db\" \".stats\"\n#} {1 {Usage: .stats on|off}}\ndo_test shell4-1.3.2 {\n  catchcmd \"test.db\" \".stats ON\"\n} {0 {}}\ndo_test shell4-1.3.3 {\n  catchcmd \"test.db\" \".stats OFF\"\n} {0 {}}\ndo_test shell4-1.3.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".stats OFF BAD\"\n} {1 {Usage: .stats ?on|off?}}\n\n# NB. whitespace is important\ndo_test shell4-1.4.1 {\n  set res [catchcmd \"test.db\" {.show}]\n  list [regexp {stats: off} $res]\n} {1}\n\ndo_test shell4-1.4.2 {\n  set res [catchcmd \"test.db\" {.stats ON\n.show\n}]\n  list [regexp {stats: on} $res]\n} {1}\n\ndo_test shell4-1.4.3 {\n  set res [catchcmd \"test.db\" {.stats OFF\n.show\n}]\n  list [regexp {stats: off} $res]\n} {1}\n\n# make sure stats not present when off\ndo_test shell4-1.5.1 {\n  set res [catchcmd \"test.db\" {SELECT 1;}]\n  list [regexp {Memory Used} $res] \\\n       [regexp {Heap Usage} $res] \\\n       [regexp {Autoindex Inserts} $res]\n} {0 0 0}\n\n# make sure stats are present when on\ndo_test shell4-1.5.2 {\n  set res [catchcmd \"test.db\" {.stats ON\nSELECT 1;\n}]\n  list [regexp {Memory Used} $res] \\\n       [regexp {Heap Usage} $res] \\\n       [regexp {Autoindex Inserts} $res]\n} {1 1 1}\n\ndo_test shell4-2.1 {\n  catchcmd \":memory:\" \"CREATE TABLE t1(x);\\n.trace\"\n} {1 {Usage: .trace FILE|off}}\ndo_test shell4-2.2 {\n  catchcmd \":memory:\" \"CREATE TABLE t1(x);\\n.trace off\\n.trace off\\n\"\n} {0 {}}\ndo_test shell4-2.3 {\n  catchcmd \":memory:\" \".trace stdout\\n.trace\\n.trace off\\n.dump\\n\"\n} {/^1 {PRAGMA.*Usage:.*}$/}\nifcapable trace {\ndo_test shell4-2.4 {\n  catchcmd \":memory:\" \".trace stdout\\nCREATE TABLE t1(x);SELECT * FROM t1;\"\n} {0 {CREATE TABLE t1(x);\nSELECT * FROM t1;}}\ndo_test shell4-2.5 {\n  catchcmd \":memory:\" \"CREATE TABLE t1(x);\\n.trace stdout\\nSELECT * FROM t1;\"\n} {0 {SELECT * FROM t1;}}\n}\n\ndo_test shell4-3.1 {\n  set fd [open t1.txt wb]\n  puts $fd \"SELECT 'squirrel';\"\n  close $fd\n  exec $::CLI :memory: --interactive \".read t1.txt\"\n} {squirrel}\ndo_test shell4-3.2 {\n  set fd [open t1.txt wb]\n  puts $fd \"SELECT 'pound: \\302\\243';\"\n  close $fd\n  exec $::CLI :memory: --interactive \".read t1.txt\"\n} {pound: £}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell5.test",
    "content": "# 2010 August 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The focus of this file is testing the CLI shell tool.\n# These tests are specific to the .import command.\n#\n# $Id: shell5.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $\n#\n\n# Test plan:\n#\n#   shell5-1.*: Basic tests specific to the \".import\" command.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\n\n#----------------------------------------------------------------------------\n# Test cases shell5-1.*: Basic handling of the .import and .separator commands.\n#\n\n# .import FILE TABLE     Import data from FILE into TABLE\ndo_test shell5-1.1.1 {\n  catchcmd \"test.db\" \".import\"\n} {1 {Usage: .import FILE TABLE}}\ndo_test shell5-1.1.2 {\n  catchcmd \"test.db\" \".import FOO\"\n} {1 {Usage: .import FILE TABLE}}\n#do_test shell5-1.1.2 {\n#  catchcmd \"test.db\" \".import FOO BAR\"\n#} {1 {Error: no such table: BAR}}\ndo_test shell5-1.1.3 {\n  # too many arguments\n  catchcmd \"test.db\" \".import FOO BAR BAD\"\n} {1 {Usage: .import FILE TABLE}}\n\n# .separator STRING      Change separator used by output mode and .import\ndo_test shell5-1.2.1 {\n  catchcmd \"test.db\" \".separator\"\n} {1 {Usage: .separator COL ?ROW?}}\ndo_test shell5-1.2.2 {\n  catchcmd \"test.db\" \".separator ONE\"\n} {0 {}}\ndo_test shell5-1.2.3 {\n  catchcmd \"test.db\" \".separator ONE TWO\"\n} {0 {}}\ndo_test shell5-1.2.4 {\n  # too many arguments\n  catchcmd \"test.db\" \".separator ONE TWO THREE\"\n} {1 {Usage: .separator COL ?ROW?}}\n\n# column separator should default to \"|\"\ndo_test shell5-1.3.1.1 {\n  set res [catchcmd \"test.db\" \".show\"]\n  list [regexp {colseparator: \\\"\\|\\\"} $res]\n} {1}\n\n# row separator should default to \"\\n\"\ndo_test shell5-1.3.1.2 {\n  set res [catchcmd \"test.db\" \".show\"]\n  list [regexp {rowseparator: \\\"\\\\n\\\"} $res]\n} {1}\n\n# set separator to different value.\n# check that .show reports new value\ndo_test shell5-1.3.2 {\n  set res [catchcmd \"test.db\" {.separator ,\n.show}]\n  list [regexp {separator: \\\",\\\"} $res]\n} {1}\n\n# import file doesn't exist\ndo_test shell5-1.4.1 {\n  forcedelete FOO\n  set res [catchcmd \"test.db\" {CREATE TABLE t1(a, b);\n.import FOO t1}]\n} {1 {Error: cannot open \"FOO\"}}\n\n# empty import file\ndo_test shell5-1.4.2 {\n  forcedelete shell5.csv\n  set in [open shell5.csv w]\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 0}\n\n# import file with 1 row, 1 column (expecting 2 cols)\ndo_test shell5-1.4.3 {\n  set in [open shell5.csv w]\n  puts $in \"1\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1}]\n} {1 {shell5.csv:1: expected 2 columns but found 1 - filling the rest with NULL}}\n\n# import file with 1 row, 3 columns (expecting 2 cols)\ndo_test shell5-1.4.4 {\n  set in [open shell5.csv w]\n  puts $in \"1|2|3\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1}]\n} {1 {shell5.csv:1: expected 2 columns but found 3 - extras ignored}}\n\n# import file with 1 row, 2 columns\ndo_test shell5-1.4.5 {\n  set in [open shell5.csv w]\n  puts $in \"1|2\"\n  close $in\n  set res [catchcmd \"test.db\" {DELETE FROM t1;\n.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 1}\n\n# import file with 2 rows, 2 columns\n# note we end up with 3 rows because of the 1 row \n# imported above.\ndo_test shell5-1.4.6 {\n  set in [open shell5.csv w]\n  puts $in \"2|3\"\n  puts $in \"3|4\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 3}\n\n# import file with 1 row, 2 columns, using a comma\ndo_test shell5-1.4.7 {\n  set in [open shell5.csv w]\n  puts $in \"4,5\"\n  close $in\n  set res [catchcmd \"test.db\" {.separator ,\n.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 4}\n\n# import file with 1 row, 2 columns, text data\ndo_test shell5-1.4.8.1 {\n  set in [open shell5.csv w]\n  puts $in \"5|Now is the time for all good men to come to the aid of their country.\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 5}\n\ndo_test shell5-1.4.8.2 {\n  catchcmd \"test.db\" {SELECT b FROM t1 WHERE a='5';}\n} {0 {Now is the time for all good men to come to the aid of their country.}}\n\n# import file with 1 row, 2 columns, quoted text data\n# note that currently sqlite doesn't support quoted fields, and\n# imports the entire field, quotes and all.\ndo_test shell5-1.4.9.1 {\n  set in [open shell5.csv w]\n  puts $in \"6|'Now is the time for all good men to come to the aid of their country.'\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 6}\n\ndo_test shell5-1.4.9.2 {\n  catchcmd \"test.db\" {SELECT b FROM t1 WHERE a='6';}\n} {0 {'Now is the time for all good men to come to the aid of their country.'}}\n\n# import file with 1 row, 2 columns, quoted text data\ndo_test shell5-1.4.10.1 {\n  set in [open shell5.csv w]\n  puts $in \"7|\\\"Now is the time for all good men to come to the aid of their country.\\\"\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT COUNT(*) FROM t1;}]\n} {0 7}\n\ndo_test shell5-1.4.10.2 {\n  catchcmd \"test.db\" {SELECT b FROM t1 WHERE a='7';}\n} {0 {Now is the time for all good men to come to the aid of their country.}}\n\n# import file with 2 rows, 2 columns and an initial BOM\n#\ndo_test shell5-1.4.11 {\n  set in [open shell5.csv wb]\n  puts -nonewline $in \"\\xef\\xbb\\xbf\"\n  puts $in \"2|3\"\n  puts $in \"4|5\"\n  close $in\n  set res [catchcmd \"test.db\" {CREATE TABLE t2(x INT, y INT);\n.import shell5.csv t2\n.mode quote\n.header on\nSELECT * FROM t2;}]\n string map {\\n | \\n\\r |} $res\n} {0 {'x','y'|2,3|4,5}}\n\n# import file with 2 rows, 2 columns or text with an initial BOM\n#\ndo_test shell5-1.4.12 {\n  set in [open shell5.csv wb]\n  puts $in \"\\xef\\xbb\\xbf\\\"two\\\"|3\"\n  puts $in \"4|5\"\n  close $in\n  set res [catchcmd \"test.db\" {DELETE FROM t2;\n.import shell5.csv t2\n.mode quote\n.header on\nSELECT * FROM t2;}]\n string map {\\n | \\n\\r |} $res\n} {0 {'x','y'|'two',3|4,5}}\n\n# check importing very long field\ndo_test shell5-1.5.1 {\n  set str [string repeat X 999]\n  set in [open shell5.csv w]\n  puts $in \"8|$str\"\n  close $in\n  set res [catchcmd \"test.db\" {.import shell5.csv t1\nSELECT length(b) FROM t1 WHERE a='8';}]\n} {0 999}\n\n# try importing into a table with a large number of columns.\n# This is limited by SQLITE_MAX_VARIABLE_NUMBER, which defaults to 999.\nset cols 999\ndo_test shell5-1.6.1 {\n  set data {}\n  for {set i 1} {$i<$cols} {incr i} {\n    append data \"c$i|\"\n  }\n  append data \"c$cols\\n\";\n  for {set i 1} {$i<$cols} {incr i} {\n    append data \"$i|\"\n  }\n  append data \"$cols\"\n  set in [open shell5.csv w]\n  puts $in $data\n  close $in\n  set res [catchcmd \"test.db\" {DROP TABLE IF EXISTS t2;\n.import shell5.csv t2\nSELECT COUNT(*) FROM t2;}]\n} {0 1}\n\n# try importing a large number of rows\nset rows 9999\ndo_test shell5-1.7.1 {\n  set in [open shell5.csv w]\n  puts $in a\n  for {set i 1} {$i<=$rows} {incr i} {\n    puts $in $i\n  }\n  close $in\n  set res [catchcmd \"test.db\" {.mode csv\n.import shell5.csv t3\nSELECT COUNT(*) FROM t3;}]\n} [list 0 $rows]\n\n# Inport from a pipe.  (Unix only, as it requires \"awk\")\nif {$tcl_platform(platform)==\"unix\"} {\n  do_test shell5-1.8 {\n    forcedelete test.db\n    catchcmd test.db {.mode csv\n.import \"|awk 'END{print \\\"x,y\\\";for(i=1;i<=5;i++){print i \\\",this is \\\" i}}'\" t1\nSELECT * FROM t1;}\n  } {0 {1,\"this is 1\"\n2,\"this is 2\"\n3,\"this is 3\"\n4,\"this is 4\"\n5,\"this is 5\"}}\n}\n\n# Import columns containing quoted strings\ndo_test shell5-1.9 {\n  set out [open shell5.csv w]\n  fconfigure $out -translation lf\n  puts $out {1,\"\",11}\n  puts $out {2,\"x\",22}\n  puts $out {3,\"\"\"\",33}\n  puts $out {4,\"hello\",44}\n  puts $out \"5,55,\\\"\\\"\\r\"\n  puts $out {6,66,\"x\"}\n  puts $out {7,77,\"\"\"\"}\n  puts $out {8,88,\"hello\"}\n  puts $out {\"\",9,99}\n  puts $out {\"x\",10,110}\n  puts $out {\"\"\"\",11,121}\n  puts $out {\"hello\",12,132}\n  close $out\n  forcedelete test.db\n  catchcmd test.db {.mode csv\n    CREATE TABLE t1(a,b,c);\n.import shell5.csv t1\n  }\n  sqlite3 db test.db\n  db eval {SELECT *, '|' FROM t1 ORDER BY rowid}\n} {1 {} 11 | 2 x 22 | 3 {\"} 33 | 4 hello 44 | 5 55 {} | 6 66 x | 7 77 {\"} | 8 88 hello | {} 9 99 | x 10 110 | {\"} 11 121 | hello 12 132 |}\ndb close\n\n# Import columns containing quoted strings\ndo_test shell5-1.10 {\n  set out [open shell5.csv w]\n  fconfigure $out -translation lf\n  puts $out {column1,column2,column3,column4}\n  puts $out \"field1,field2,\\\"x3 \\\"\\\"\\r\\ndata\\\"\\\" 3\\\",field4\"\n  puts $out \"x1,x2,\\\"x3 \\\"\\\"\\ndata\\\"\\\" 3\\\",x4\"\n  close $out\n  forcedelete test.db\n  catchcmd test.db {.mode csv\n    CREATE TABLE t1(a,b,c,d);\n.import shell5.csv t1\n  }\n  sqlite3 db test.db\n  db eval {SELECT hex(c) FROM t1 ORDER BY rowid}\n} {636F6C756D6E33 783320220D0A64617461222033 783320220A64617461222033}\n\n# Blank last column with \\r\\n line endings.\ndo_test shell5-1.11 {\n  set out [open shell5.csv w]\n  fconfigure $out -translation binary\n  puts $out \"column1,column2,column3\\r\"\n  puts $out \"a,b, \\r\"\n  puts $out \"x,y,\\r\"\n  puts $out \"p,q,r\\r\"\n  close $out\n  catch {db close}\n  forcedelete test.db\n  catchcmd test.db {.mode csv\n.import shell5.csv t1\n  }\n  sqlite3 db test.db\n  db eval {SELECT *, '|' FROM t1}\n} {a b { } | x y {} | p q r |}\ndb close\n\n#----------------------------------------------------------------------------\n# \nreset_db\nsqlite3 db test.db\ndo_test shell5-2.1 {\n  set fd [open shell5.csv w]\n  puts $fd \",hello\"\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t1(a, b);\n.import shell5.csv t1\n  }]\n  db eval { SELECT * FROM t1 }\n} {{} hello}\n\ndo_test shell5-2.2 {\n  set fd [open shell5.csv w]\n  puts $fd {\"\",hello}\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t2(a, b);\n.import shell5.csv t2\n  }]\n  db eval { SELECT * FROM t2 }\n} {{} hello}\n\ndo_test shell5-2.3 {\n  set fd [open shell5.csv w]\n  puts $fd {\"x\"\"y\",hello}\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t3(a, b);\n.import shell5.csv t3\n  }]\n  db eval { SELECT * FROM t3 }\n} {x\\\"y hello}\n\ndo_test shell5-2.4 {\n  set fd [open shell5.csv w]\n  puts $fd {\"xy\"\"\",hello}\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t4(a, b);\n.import shell5.csv t4\n  }]\n  db eval { SELECT * FROM t4 }\n} {xy\\\" hello}\n\ndo_test shell5-2.5 {\n  set fd [open shell5.csv w]\n  puts $fd {\"one\",\"2\"}\n  puts $fd {}\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t4(a, b);\n.import shell5.csv t4\n  }]\n  db eval { SELECT * FROM t4 }\n} {xy\\\" hello one 2 {} {}}\n\n#----------------------------------------------------------------------------\n# Tests for the shell \"ascii\" import/export mode.\n#\ndo_test shell5-3.1 {\n  set fd [open shell5.csv w]\n  fconfigure $fd -encoding binary -translation binary\n  puts -nonewline $fd \"\\\"test 1\\\"\\x1F,test 2\\r\\n\\x1E\"\n  puts -nonewline $fd \"test 3\\x1Ftest 4\\n\"\n  close $fd\n  catchcmd test.db {\n.mode ascii\nCREATE TABLE t5(a, b);\n.import shell5.csv t5\n  }\n  db eval { SELECT * FROM t5 }\n} \"\\{\\\"test 1\\\"} \\{,test 2\\r\\n\\} \\{test 3\\} \\{test 4\\n\\}\"\n\ndo_test shell5-3.2 {\n  set x [catchcmd test.db {\n.mode ascii\nSELECT * FROM t5;\n  }]\n  # Handle platform end-of-line differences\n  regsub -all {[\\n\\r]?\\n} $x <EOL> x\n  set x\n} \"0 \\{\\\"test 1\\\"\\x1F,test 2<EOL>\\x1Etest 3\\x1Ftest 4<EOL>\\x1E\\}\"\n\ndo_test shell5-4.1 {\n  forcedelete shell5.csv\n  set fd [open shell5.csv w]\n  puts $fd \"1,2,3\"\n  puts $fd \"4,5\"\n  puts $fd \"6,7,8\"\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t6(a, b, c);\n.import shell5.csv t6\n  }]\n  db eval { SELECT * FROM t6 ORDER BY a }\n} {1 2 3 4 5 {} 6 7 8}\n\ndo_test shell5-4.2 {\n  forcedelete shell5.csv\n  set fd [open shell5.csv w]\n  puts $fd \"1,2,3\"\n  puts $fd \"4,5\"\n  puts $fd \"6,7,8,9\"\n  close $fd\n  catchcmd test.db [string trim {\n.mode csv\nCREATE TABLE t7(a, b, c);\n.import shell5.csv t7\n  }]\n  db eval { SELECT * FROM t7 ORDER BY a }\n} {1 2 3 4 5 {} 6 7 8}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell6.test",
    "content": "# 2016 December 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the shell tool \".lint fkey-indexes\" command.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !vtab {finish_test; return}\nset testprefix shell6\nset CLI [test_find_cli]\ndb close\nforcedelete test.db test.db-journal test.db-wal\n\nforeach {tn schema output} {\n  1 {\n    CREATE TABLE p1(a PRIMARY KEY, b);\n    CREATE TABLE c1(x, y REFERENCES p1);\n  } {\n    CREATE INDEX 'c1_y' ON 'c1'('y'); --> p1(a)\n  }\n\n  2 {\n    CREATE TABLE p1(a PRIMARY KEY, b);\n    CREATE TABLE c2(x REFERENCES p1, y REFERENCES p1);\n  } {\n    CREATE INDEX 'c2_y' ON 'c2'('y'); --> p1(a)\n    CREATE INDEX 'c2_x' ON 'c2'('x'); --> p1(a)\n  }\n\n  3 {\n    CREATE TABLE 'p 1'(a, b, c, PRIMARY KEY(c, b));\n    CREATE TABLE 'c 1'(x, y, z, FOREIGN KEY (z, y) REFERENCES 'p 1');\n  } {\n    CREATE INDEX 'c 1_z_y' ON 'c 1'('z', 'y'); --> p 1(c,b)\n  }\n\n  4 {\n    CREATE TABLE p1(a, 'b b b' PRIMARY KEY);\n    CREATE TABLE c1('x y z' REFERENCES p1);\n    CREATE INDEX i1 ON c1('x y z') WHERE \"x y z\" IS NOT NULL;\n  } {\n  }\n\n  5 {\n    CREATE TABLE p1(a, 'b b b' PRIMARY KEY);\n    CREATE TABLE c1('x y z' REFERENCES p1);\n    CREATE INDEX i1 ON c1('x y z') WHERE \"x y z\" IS NOT 12;\n  } {\n    CREATE INDEX 'c1_x y z' ON 'c1'('x y z'); --> p1(b b b)\n  }\n\n  6 {\n    CREATE TABLE x1(a, b, c, UNIQUE(a, b));\n    CREATE TABLE y1(a, b, c, FOREIGN KEY(b, a) REFERENCES x1(a, b));\n    CREATE INDEX y1i ON y1(a, c, b);\n  } {\n    CREATE INDEX 'y1_b_a' ON 'y1'('b', 'a'); --> x1(a,b)\n  }\n\n  6 {\n    CREATE TABLE x1(a COLLATE nocase, b, UNIQUE(a));\n    CREATE TABLE y1(a COLLATE rtrim REFERENCES x1(a));\n  } {\n    CREATE INDEX 'y1_a' ON 'y1'('a' COLLATE nocase); --> x1(a)\n  }\n\n  7 {\n    CREATE TABLE x1(a PRIMARY KEY COLLATE nocase, b);\n    CREATE TABLE y1(a REFERENCES x1);\n  } {\n    CREATE INDEX 'y1_a' ON 'y1'('a' COLLATE nocase); --> x1(a)\n  }\n\n  8 {\n    CREATE TABLE x1(a, b COLLATE nocase, c COLLATE rtrim, PRIMARY KEY(c, b, a));\n    CREATE TABLE y1(d, e, f, FOREIGN KEY(d, e, f) REFERENCES x1);\n  } {\n    CREATE INDEX 'y1_d_e_f' ON 'y1'('d' COLLATE rtrim, 'e' COLLATE nocase, 'f'); --> x1(c,b,a)\n  }\n\n  9 {\n    CREATE TABLE p1(a, b UNIQUE);\n    CREATE TABLE c1(x INTEGER PRIMARY KEY REFERENCES p1(b));\n  } {\n  }\n\n} {\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql $schema\n\n  set expected \"\"\n  foreach line [split $output \"\\n\"] {\n    set line [string trim $line]\n    if {$line!=\"\"} {\n      append expected \"$line\\n\"\n    }\n  }\n\n  do_test 1.$tn.1 {\n    set RES [catchcmd test.db [list .lint fkey-indexes]]\n  } [list 0 [string trim $expected]]\n\n  do_test 1.$tn.2 {\n    execsql [lindex $RES 1]\n    catchcmd test.db [list .lint fkey-indexes]\n  } {0 {}}\n\n  db close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shell7.test",
    "content": "# 2016 December 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the readfile() function built into the shell tool. Specifically,\n# that it does not truncate the blob read at the first embedded 0x00\n# byte.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix shell7\nset CLI [test_find_cli]\n\n\ndo_execsql_test 1.0 { \n  CREATE TABLE f1(tn INTEGER PRIMARY KEY, x BLOB); \n  CREATE TABLE f2(tn INTEGER PRIMARY KEY, x BLOB); \n\n  INSERT INTO f1 VALUES(1, X'01020304');\n  INSERT INTO f1 VALUES(2, X'01000304');\n  INSERT INTO f1 VALUES(3, randomblob(200));\n}\n\nforeach {tn l x} [db eval { SELECT tn, length(x) AS l, x FROM f1 }] {\n  forcedelete shell7_test.bin\n  set fd [open shell7_test.bin w]\n  fconfigure $fd -encoding binary\n  fconfigure $fd -translation binary\n  puts -nonewline $fd $x\n  close $fd\n\n  do_test 1.$tn.1 { file size shell7_test.bin } $l\n  do_test 1.$tn.2 { \n    catchcmd test.db \"INSERT INTO f2 VALUES($tn, readfile('shell7_test.bin'));\"\n  } {0 {}}\n\n  do_execsql_test 1.$tn.3 { \n    SELECT (SELECT x FROM f1 WHERE tn=1)==(SELECT x FROM f2 WHERE tn=1)\n  } {1}\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shortread1.test",
    "content": "# 2007 Sep 13\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file attempts to duplicate an error scenario seen on a\n# customer system using version 3.2.2.  The problem appears to\n# have been fixed (perhaps by accident) with check-in [3503].\n# These tests will prevent an accidental recurrance.\n#\n# $Id: shortread1.test,v 1.1 2007/09/14 01:48:12 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test shortread1-1.1 {\n  execsql {\n    CREATE TABLE t1(a TEXT);\n    BEGIN;\n    INSERT INTO t1 VALUES(hex(randomblob(5000)));\n    INSERT INTO t1 VALUES(hex(randomblob(100)));\n    PRAGMA freelist_count;\n  }\n} {0}\ndo_test shortread1-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE rowid=1;\n    PRAGMA freelist_count;\n  }\n} {11}\ndo_test shortread1-1.3 {\n  sqlite3_release_memory [expr {1024*9}]\n  execsql {\n    INSERT INTO t1 VALUES(hex(randomblob(5000)));\n    PRAGMA freelist_count;\n  }\n} {0}\ndo_test shortread1-1.4 {\n  execsql {\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/show_speedtest1_rtree.tcl",
    "content": "#!/usr/bin/tclsh\n#\n# This script displays the field of rectangles used by --testset rtree\n# of speedtest1.  Run this script as follows:\n#\n#      rm test.db\n#      ./speedtest1 --testset rtree --size 25 test.db\n#      sqlite3 --separator ' ' test.db 'SELECT * FROM rt1' >data.txt\n#      wish show_speedtest1_rtree.tcl\n#\n# The filename \"data.txt\" is hard coded into this script and so that name\n# must be used on lines 3 and 4 above.  Elsewhere, different filenames can\n# be used.  The --size N parameter can be adjusted as desired.\n#\npackage require Tk\nset f [open data.txt rb]\nset data [read $f]\nclose $f\ncanvas .c\nframe .b\nbutton .b.b1 -text X-Y -command refill-xy\nbutton .b.b2 -text X-Z -command refill-xz\nbutton .b.b3 -text Y-Z -command refill-yz\npack .b.b1 .b.b2 .b.b3 -side left\npack .c -side top -fill both -expand 1\npack .b -side top\nproc resize_canvas_to_fit {} {\n  foreach {x0 y0 x1 y1} [.c bbox all] break\n  set w [expr {$x1-$x0}]\n  set h [expr {$y1-$y0}]\n  .c config -width $w -height $h\n}\nproc refill-xy {} {\n  .c delete all\n  foreach {id x0 x1 y0 y1 z0 z1} $::data {\n    .c create rectangle $x0 $y0 $x1 $y1\n  }\n  .c scale all 0 0 0.05 0.05\n  resize_canvas_to_fit\n}\nproc refill-xz {} {\n  .c delete all\n  foreach {id x0 x1 y0 y1 z0 z1} $::data {\n    .c create rectangle $x0 $z0 $x1 $z1\n  }\n  .c scale all 0 0 0.05 0.05\n  resize_canvas_to_fit\n}\nproc refill-yz {} {\n  .c delete all\n  foreach {id x0 x1 y0 y1 z0 z1} $::data {\n    .c create rectangle $y0 $z0 $y1 $z1\n  }\n  .c scale all 0 0 0.05 0.05\n  resize_canvas_to_fit\n}\nrefill-xy\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/shrink.test",
    "content": "# 2011 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains test cases for sqlite3_db_release_memory and\n# the PRAGMA shrink_memory statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ntest_set_config_pagecache 0 0\n\nunset -nocomplain baseline\ndo_test shrink-1.1 {\n  db eval {\n    PRAGMA cache_size = 2000;\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES(randomblob(1000000),1);\n  }\n  set ::baseline sqlite3_memory_used\n  # EVIDENCE-OF: R-58814-63508 The sqlite3_db_release_memory(D) interface\n  # attempts to free as much heap memory as possible from database\n  # connection D.\n  sqlite3_db_release_memory db\n  expr {$::baseline > [sqlite3_memory_used]+500000}\n} {1}\ndo_test shrink-1.2 {\n  set baseline [sqlite3_memory_used]\n  db eval {\n    UPDATE t1 SET y=y+1;\n  }\n  expr {$::baseline+500000 < [sqlite3_memory_used]}\n} {1}\ndo_test shrink-1.3 {\n  set baseline [sqlite3_memory_used]\n  db eval {PRAGMA shrink_memory}\n  expr {$::baseline > [sqlite3_memory_used]+500000}\n} {1}\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sidedelete.test",
    "content": "# 2007 Dec 12\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains test cases for stressing database\n# changes that involve side effects that delete rows from\n# the table being changed.  Ticket #2832 shows that in\n# older versions of SQLite that behavior was implemented\n# incorrectly and resulted in corrupt database files.\n#\n# $Id: sidedelete.test,v 1.2 2008/08/04 03:51:24 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The sequence table is created to store a sequence of integers\n# starting with 1.  This is used to reinitialize other tables\n# as part of other tests.\n#\ndo_test sidedelete-1.1 {\n  execsql {\n    CREATE TABLE sequence(a INTEGER PRIMARY KEY);\n    INSERT INTO sequence VALUES(1);\n    INSERT INTO sequence VALUES(2);\n  }\n  for {set i 0} {$i<8} {incr i} {\n    execsql {\n      INSERT INTO sequence SELECT a+(SELECT max(a) FROM sequence) FROM sequence;\n    }\n  }\n  execsql {SELECT count(*) FROM sequence}\n} {512}\n\n# Make a series of changes using an UPDATE OR REPLACE and a\n# correlated subquery.  This would cause database corruption\n# prior to the fix for ticket #2832.\n#\ndo_test sidedelete-2.0 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TABLE chng(a PRIMARY KEY, b);\n    SELECT count(*) FROM t1;\n    SELECT count(*) FROM chng;\n  }\n} {0 0}\nfor {set i 2} {$i<=100} {incr i} {\n  set n [expr {($i+2)/2}]\n  do_test sidedelete-2.$i.1 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 SELECT a, a FROM sequence WHERE a<=$i;\n      DELETE FROM chng;\n      INSERT INTO chng SELECT a*2, a*2+1 FROM sequence WHERE a<=$i/2;\n      UPDATE OR REPLACE t1 SET a=(SELECT b FROM chng WHERE a=t1.a);\n      SELECT count(*), sum(a) FROM t1;\n    }\n  } [list $n [expr {$n*$n-1}]]\n  integrity_check sidedelete-2.$i.2\n}\n\n# This will cause stacks leaks but not database corruption prior\n# to the #2832 fix.\n#\ndo_test sidedelete-3.0 {\n  execsql {\n     DROP TABLE t1;\n     CREATE TABLE t1(a PRIMARY KEY);\n     SELECT * FROM t1;\n  }\n} {}\nfor {set i 1} {$i<=100} {incr i} {\n  set n [expr {($i+1)/2}]\n  do_test sidedelete-3.$i.1 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 SELECT a FROM sequence WHERE a<=$i;\n      UPDATE OR REPLACE t1 SET a=a+1;\n      SELECT count(*), sum(a) FROM t1;\n    }\n  } [list $n [expr {$n*($n+1)}]]\n  integrity_check sidedelete-3.$i.2\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/skipscan1.test",
    "content": "# 2013-11-13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests of the \"skip-scan\" query strategy.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test skipscan1-1.1 {\n  CREATE TABLE t1(a TEXT, b INT, c INT, d INT);\n  CREATE INDEX t1abc ON t1(a,b,c);\n  INSERT INTO t1 VALUES('abc',123,4,5);\n  INSERT INTO t1 VALUES('abc',234,5,6);\n  INSERT INTO t1 VALUES('abc',234,6,7);\n  INSERT INTO t1 VALUES('abc',345,7,8);\n  INSERT INTO t1 VALUES('def',567,8,9);\n  INSERT INTO t1 VALUES('def',345,9,10);\n  INSERT INTO t1 VALUES('bcd',100,6,11);\n\n  /* Fake the sqlite_stat1 table so that the query planner believes\n  ** the table contains thousands of rows and that the first few\n  ** columns are not selective. */\n  ANALYZE;\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1 VALUES('t1','t1abc','10000 5000 2000 10');\n  ANALYZE sqlite_master;\n} {}\n\n# Simple queries that leave the first one or two columns of the\n# index unconstrainted.\n#\ndo_execsql_test skipscan1-1.2 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE b=345 ORDER BY a;\n} {abc 345 7 8 | def 345 9 10 |}\ndo_execsql_test skipscan1-1.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a;\n} {/* USING INDEX t1abc (ANY(a) AND b=?)*/}\ndo_execsql_test skipscan1-1.2sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a;\n} {~/*ORDER BY*/}\n\ndo_execsql_test skipscan1-1.3 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;\n} {def 345 9 10 | abc 345 7 8 |}\ndo_execsql_test skipscan1-1.3eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;\n} {/* USING INDEX t1abc (ANY(a) AND b=?)*/}\ndo_execsql_test skipscan1-1.3sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE d<>99 AND b=345 ORDER BY a DESC;\n} {~/*ORDER BY*/}\n\ndo_execsql_test skipscan1-1.4 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;\n} {abc 234 6 7 | bcd 100 6 11 |}\ndo_execsql_test skipscan1-1.4eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;\n} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}\ndo_execsql_test skipscan1-1.4sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c=6 ORDER BY a, b, c;\n} {~/*ORDER BY*/}\n\ndo_execsql_test skipscan1-1.5 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;\n} {abc 234 6 7 | abc 345 7 8 | bcd 100 6 11 |}\ndo_execsql_test skipscan1-1.5eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;\n} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}\ndo_execsql_test skipscan1-1.5sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c IN (6,7) ORDER BY a, b, c;\n} {~/*ORDER BY*/}\n\ndo_execsql_test skipscan1-1.6 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;\n} {abc 234 6 7 | abc 345 7 8 | bcd 100 6 11 |}\ndo_execsql_test skipscan1-1.6eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;\n} {/* USING INDEX t1abc (ANY(a) AND ANY(b) AND c>? AND c<?)*/}\ndo_execsql_test skipscan1-1.6sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE c BETWEEN 6 AND 7 ORDER BY a, b, c;\n} {~/*ORDER BY*/}\n\ndo_execsql_test skipscan1-1.7 {\n  SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7\n   ORDER BY a, b;\n} {abc 234 6 7 | abc 345 7 8 |}\ndo_execsql_test skipscan1-1.7eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7\n   ORDER BY a, b;\n} {/* USING INDEX t1abc (ANY(a) AND b=? AND c>? AND c<?)*/}\ndo_execsql_test skipscan1-1.7sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t1 WHERE b IN (234, 345) AND c BETWEEN 6 AND 7\n   ORDER BY a, b;\n} {~/*ORDER BY*/}\n\n\n# Joins\n#\ndo_execsql_test skipscan1-1.51 {\n  CREATE TABLE t1j(x TEXT, y INTEGER);\n  INSERT INTO t1j VALUES('one',1),('six',6),('ninty-nine',99);\n  INSERT INTO sqlite_stat1 VALUES('t1j',null,'3');\n  ANALYZE sqlite_master;\n  SELECT x, a, b, c, d, '|' FROM t1j, t1 WHERE c=y ORDER BY +a;\n} {six abc 234 6 7 | six bcd 100 6 11 |}\ndo_execsql_test skipscan1-1.51eqp {\n  EXPLAIN QUERY PLAN\n  SELECT x, a, b, c, d, '|' FROM t1j, t1 WHERE c=y ORDER BY +a;\n} {/* INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}\n\ndo_execsql_test skipscan1-1.52 {\n  SELECT x, a, b, c, d, '|' FROM t1j LEFT JOIN t1 ON c=y ORDER BY +y, +a;\n} {one {} {} {} {} | six abc 234 6 7 | six bcd 100 6 11 | ninty-nine {} {} {} {} |}\ndo_execsql_test skipscan1-1.52eqp {\n  EXPLAIN QUERY PLAN\n  SELECT x, a, b, c, d, '|' FROM t1j LEFT JOIN t1 ON c=y ORDER BY +y, +a;\n} {/* INDEX t1abc (ANY(a) AND ANY(b) AND c=?)*/}\n\ndo_execsql_test skipscan1-2.1 {\n  CREATE TABLE t2(a TEXT, b INT, c INT, d INT,\n                  PRIMARY KEY(a,b,c));\n  INSERT INTO t2 SELECT * FROM t1;\n\n  /* Fake the sqlite_stat1 table so that the query planner believes\n  ** the table contains thousands of rows and that the first few\n  ** columns are not selective. */\n  ANALYZE;\n  UPDATE sqlite_stat1 SET stat='10000 5000 2000 10' WHERE idx NOT NULL;\n  ANALYZE sqlite_master;\n} {}\n\ndo_execsql_test skipscan1-2.2 {\n  SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;\n} {abc 345 7 8 | def 345 9 10 |}\ndo_execsql_test skipscan1-2.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;\n} {/* USING INDEX sqlite_autoindex_t2_1 (ANY(a) AND b=?)*/}\ndo_execsql_test skipscan1-2.2sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t2 WHERE d<>99 AND b=345 ORDER BY a;\n} {~/*ORDER BY*/}\n\n\ndo_execsql_test skipscan1-3.1 {\n  CREATE TABLE t3(a TEXT, b INT, c INT, d INT,\n                  PRIMARY KEY(a,b,c)) WITHOUT ROWID;\n  INSERT INTO t3 SELECT * FROM t1;\n\n  /* Fake the sqlite_stat1 table so that the query planner believes\n  ** the table contains thousands of rows and that the first few\n  ** columns are not selective. */\n  ANALYZE;\n  UPDATE sqlite_stat1 SET stat='10000 5000 2000 10' WHERE idx NOT NULL;\n  ANALYZE sqlite_master;\n} {}\n\ndo_execsql_test skipscan1-3.2 {\n  SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;\n} {abc 345 7 8 | def 345 9 10 |}\ndo_execsql_test skipscan1-3.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;\n} {/* PRIMARY KEY (ANY(a) AND b=?)*/}\ndo_execsql_test skipscan1-3.2sort {\n  EXPLAIN QUERY PLAN\n  SELECT a,b,c,d,'|' FROM t3 WHERE b=345 ORDER BY a;\n} {~/*ORDER BY*/}\n\n# Ticket 520070ec7fbaac: Array overrun in the skip-scan optimization\n# 2013-12-22\n#\ndo_execsql_test skipscan1-4.1 {\n  CREATE TABLE t4(a,b,c,d,e,f,g,h,i);\n  CREATE INDEX t4all ON t4(a,b,c,d,e,f,g,h);\n  INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);\n  ANALYZE;\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1 \n    VALUES('t4','t4all','655360 163840 40960 10240 2560 640 160 40 10');\n  ANALYZE sqlite_master;\n  SELECT i FROM t4 WHERE a=1;\n  SELECT i FROM t4 WHERE b=2;\n  SELECT i FROM t4 WHERE c=3;\n  SELECT i FROM t4 WHERE d=4;\n  SELECT i FROM t4 WHERE e=5;\n  SELECT i FROM t4 WHERE f=6;\n  SELECT i FROM t4 WHERE g=7;\n  SELECT i FROM t4 WHERE h=8;\n} {9 9 9 9 9 9 9 9}\n\n# Make sure skip-scan cost computation in the query planner takes into\n# account the fact that the seek must occur multiple times.\n#\n# Prior to 2014-03-10, the costs were computed incorrectly which would\n# cause index t5i2 to be used instead of t5i1 on the skipscan1-5.3.\n#\ndo_execsql_test skipscan1-5.1 {\n  CREATE TABLE t5(\n    id INTEGER PRIMARY KEY,\n    loc TEXT,\n    lang INTEGER,\n    utype INTEGER,\n    xa INTEGER,\n    xd INTEGER,\n    xh INTEGER\n  );\n  CREATE INDEX t5i1 on t5(loc, xh, xa, utype, lang);\n  CREATE INDEX t5i2 ON t5(xd,loc,utype,lang);\n  EXPLAIN QUERY PLAN\n    SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';\n} {/.*COVERING INDEX t5i1 .*/}\ndo_execsql_test skipscan1-5.2 {\n  ANALYZE;\n  DELETE FROM sqlite_stat1;\n  DROP TABLE IF EXISTS sqlite_stat4;\n  DROP TABLE IF EXISTS sqlite_stat3;\n  INSERT INTO sqlite_stat1 VALUES('t5','t5i1','2702931 3 2 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('t5','t5i2','2702931 686 2 2 2');\n  ANALYZE sqlite_master;\n} {}\ndb cache flush\ndo_execsql_test skipscan1-5.3 {\n  EXPLAIN QUERY PLAN\n    SELECT xh, loc FROM t5 WHERE loc >= 'M' AND loc < 'N';\n} {/.*COVERING INDEX t5i1 .*/}\n\n# The column used by the skip-scan needs to be sufficiently selective.\n# See the private email from Adi Zaimi to drh@sqlite.org on 2014-09-22.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test skipscan1-6.1 {\n  CREATE TABLE t1(a,b,c,d,e,f,g,h varchar(300));\n  CREATE INDEX t1ab ON t1(a,b);\n  ANALYZE sqlite_master;\n  -- Only two distinct values for the skip-scan column.  Skip-scan is not used.\n  INSERT INTO sqlite_stat1 VALUES('t1','t1ab','500000 250000 125000');\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {~/ANY/}\ndo_execsql_test skipscan1-6.2 {\n  -- Four distinct values for the skip-scan column.  Skip-scan is used.\n  UPDATE sqlite_stat1 SET stat='500000 250000 62500';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {/ANY.a. AND b=/}\ndo_execsql_test skipscan1-6.3 {\n  -- Two distinct values for the skip-scan column again.  Skip-scan is not used.\n  UPDATE sqlite_stat1 SET stat='500000 125000 62500';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {~/ANY/}\n\n# If the sqlite_stat1 entry includes the \"noskipscan\" token, then never use\n# skipscan with that index.\n#\ndo_execsql_test skipscan1-7.1 {\n  UPDATE sqlite_stat1 SET stat='500000 125000 1 sz=100';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {/ANY/}\ndo_execsql_test skipscan1-7.2 {\n  UPDATE sqlite_stat1 SET stat='500000 125000 1 noskipscan sz=100';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {~/ANY/}\ndo_execsql_test skipscan1-7.3 {\n  UPDATE sqlite_stat1 SET stat='500000 125000 1 sz=100 noskipscan';\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b=1;\n} {~/ANY/}\n\n# Ticket 8fd39115d8f46ece70e7d4b3c481d1bd86194746  2015-07-23\n# Incorrect code generated for a skipscan within an OR optimization\n# on a WITHOUT ROWID table.\n#\ndo_execsql_test skipscan1-8.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x, y, PRIMARY KEY(x,y)) WITHOUT ROWID;\n  INSERT INTO t1(x,y) VALUES(1,'AB');\n  INSERT INTO t1(x,y) VALUES(2,'CD');\n  ANALYZE;\n  DROP TABLE IF EXISTS sqlite_stat4;\n  DELETE FROM sqlite_stat1;\n  INSERT INTO sqlite_stat1(tbl,idx,stat) VALUES('t1','t1','1000000 100 1');\n  ANALYZE sqlite_master;\n  SELECT * FROM t1\n   WHERE (y = 'AB' AND x <= 4)\n      OR (y = 'EF' AND x = 5);\n} {1 AB}\ndo_execsql_test skipscan1-8.1eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t1\n   WHERE (y = 'AB' AND x <= 4)\n      OR (y = 'EF' AND x = 5);\n} {/ANY/}\ndo_execsql_test skipscan1-8.2 {\n  SELECT * FROM t1\n   WHERE y = 'AB' OR (y = 'CD' AND x = 2)\n  ORDER BY +x;\n} {1 AB 2 CD}\n\n# Segfault reported on the mailing list by Keith Medcalf on 2016-09-18.\n# A skip-scan with a \"column IN (SELECT ...)\" on the second term of the\n# index.\n#\ndo_execsql_test skipscan1-9.2 {\n  CREATE TABLE t9a(a,b,c);\n  CREATE INDEX t9a_ab ON t9a(a,b);\n  CREATE TABLE t9b(x,y);\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('t9a','t9a_ab','1000000 250000 1');\n  ANALYZE sqlite_master;\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t9a WHERE b IN (SELECT x FROM t9b WHERE y!=5);\n} {/USING INDEX t9a_ab .ANY.a. AND b=./}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/skipscan2.test",
    "content": "# 2013-11-27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests of the \"skip-scan\" query strategy.\n#\n# The test cases in this file are derived from the description of\n# the skip-scan query strategy in the \"optoverview.html\" document.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test skipscan2-1.1 {\n  CREATE TABLE people(\n    name TEXT PRIMARY KEY,\n    role TEXT NOT NULL,\n    height INT NOT NULL, -- in cm\n    CHECK( role IN ('student','teacher') )\n  );\n  CREATE INDEX people_idx1 ON people(role, height);\n} {}\ndo_execsql_test skipscan2-1.2 {\n  INSERT INTO people VALUES('Alice','student',156);\n  INSERT INTO people VALUES('Bob','student',161);\n  INSERT INTO people VALUES('Cindy','student',155);\n  INSERT INTO people VALUES('David','student',181);\n  INSERT INTO people VALUES('Emily','teacher',158);\n  INSERT INTO people VALUES('Fred','student',163);\n  INSERT INTO people VALUES('Ginny','student',169);\n  INSERT INTO people VALUES('Harold','student',172);\n  INSERT INTO people VALUES('Imma','student',179);\n  INSERT INTO people VALUES('Jack','student',181);\n  INSERT INTO people VALUES('Karen','student',163);\n  INSERT INTO people VALUES('Logan','student',177);\n  INSERT INTO people VALUES('Megan','teacher',159);\n  INSERT INTO people VALUES('Nathan','student',163);\n  INSERT INTO people VALUES('Olivia','student',161);\n  INSERT INTO people VALUES('Patrick','teacher',180);\n  INSERT INTO people VALUES('Quiana','student',182);\n  INSERT INTO people VALUES('Robert','student',159);\n  INSERT INTO people VALUES('Sally','student',166);\n  INSERT INTO people VALUES('Tom','student',171);\n  INSERT INTO people VALUES('Ursula','student',170);\n  INSERT INTO people VALUES('Vance','student',179);\n  INSERT INTO people VALUES('Willma','student',175);\n  INSERT INTO people VALUES('Xavier','teacher',185);\n  INSERT INTO people VALUES('Yvonne','student',149);\n  INSERT INTO people VALUES('Zach','student',170);\n}\n\n# Without ANALYZE, a skip-scan is not used\n#\ndo_execsql_test skipscan2-1.3 {\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-1.3eqp {\n  EXPLAIN QUERY PLAN\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {~/*INDEX people_idx1 */}\n\n# Now do an ANALYZE.  A skip-scan can be used after ANALYZE.\n#\ndo_execsql_test skipscan2-1.4 {\n  ANALYZE;\n  -- We do not have enough people above to actually force the use\n  -- of a skip-scan.  So make a manual adjustment to the stat1 table\n  -- to make it seem like there are many more.\n  UPDATE sqlite_stat1 SET stat='10000 5000 20' WHERE idx='people_idx1';\n  UPDATE sqlite_stat1 SET stat='10000 1' WHERE idx='sqlite_autoindex_people_1';\n  ANALYZE sqlite_master;\n}\ndb cache flush\ndo_execsql_test skipscan2-1.5 {\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-1.5eqp {\n  EXPLAIN QUERY PLAN\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {/*INDEX people_idx1 */}\n\n# Same answer with other formulations of the same query\n#\ndo_execsql_test skipscan2-1.6 {\n  SELECT name FROM people\n   WHERE role IN (SELECT DISTINCT role FROM people)\n     AND height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-1.7 {\n  SELECT name FROM people WHERE role='teacher' AND height>=180\n  UNION ALL\n  SELECT name FROM people WHERE role='student' AND height>=180\n  ORDER BY 1;\n} {David Jack Patrick Quiana Xavier}\n\n# Add 8 more people, bringing the total to 34.  Then the number of\n# duplicates in the left-column of the index will be 17 and \n# skip-scan should not be used after an (unfudged) ANALYZE.\n#\ndo_execsql_test skipscan2-1.8 {\n  INSERT INTO people VALUES('Angie','student',166);\n  INSERT INTO people VALUES('Brad','student',176);\n  INSERT INTO people VALUES('Claire','student',168);\n  INSERT INTO people VALUES('Donald','student',162);\n  INSERT INTO people VALUES('Elaine','student',177);\n  INSERT INTO people VALUES('Frazier','student',159);\n  INSERT INTO people VALUES('Grace','student',179);\n  INSERT INTO people VALUES('Horace','student',166);\n  ANALYZE;\n  SELECT stat FROM sqlite_stat1 WHERE idx='people_idx1';\n} {{34 17 2}}\ndb cache flush\ndo_execsql_test skipscan2-1.9 {\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-1.9eqp {\n  EXPLAIN QUERY PLAN\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {~/*INDEX people_idx1 */}\n\n# Add 2 more people, bringing the total to 36.  Then the number of\n# duplicates in the left-column of the index will be 18 and \n# skip-scan will be used after an (unfudged) ANALYZE.\n#\ndo_execsql_test skipscan2-1.10 {\n  INSERT INTO people VALUES('Ingrad','student',155);\n  INSERT INTO people VALUES('Jacob','student',179);\n  ANALYZE;\n  SELECT stat FROM sqlite_stat1 WHERE idx='people_idx1';\n} {{36 18 2}}\ndb cache flush\ndo_execsql_test skipscan2-1.11 {\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-1.11eqp {\n  EXPLAIN QUERY PLAN\n  SELECT name FROM people WHERE height>=180 ORDER BY +name;\n} {/*INDEX people_idx1 */}\n\n\n# Repeat using a WITHOUT ROWID table.\n#\ndo_execsql_test skipscan2-2.1 {\n  CREATE TABLE peoplew(\n    name TEXT PRIMARY KEY,\n    role TEXT NOT NULL,\n    height INT NOT NULL, -- in cm\n    CHECK( role IN ('student','teacher') )\n  ) WITHOUT ROWID;\n  CREATE INDEX peoplew_idx1 ON peoplew(role, height);\n  INSERT INTO peoplew(name,role,height)\n     SELECT name, role, height FROM  people;\n  ALTER TABLE people RENAME TO old_people;\n  SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-2.2 {\n  SELECT name FROM peoplew\n   WHERE role IN (SELECT DISTINCT role FROM peoplew)\n     AND height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-2.2 {\n  SELECT name FROM peoplew WHERE role='teacher' AND height>=180\n  UNION ALL\n  SELECT name FROM peoplew WHERE role='student' AND height>=180\n  ORDER BY 1;\n} {David Jack Patrick Quiana Xavier}\n\n# Now do an ANALYZE.  A skip-scan can be used after ANALYZE.\n#\ndo_execsql_test skipscan2-2.4 {\n  ANALYZE;\n}\ndb cache flush\ndo_execsql_test skipscan2-2.5 {\n  SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;\n} {David Jack Patrick Quiana Xavier}\ndo_execsql_test skipscan2-2.5eqp {\n  EXPLAIN QUERY PLAN\n  SELECT name FROM peoplew WHERE height>=180 ORDER BY +name;\n} {/*INDEX peoplew_idx1 */}\n\n# A skip-scan on a PK index of a WITHOUT ROWID table.\n#\ndo_execsql_test skipscan2-3.1 {\n  CREATE TABLE t3(a, b, c, PRIMARY KEY(a, b)) WITHOUT ROWID;\n}\ndo_test skipscan2-3.2 {\n  for {set i 0} {$i < 1000} {incr i} {\n    execsql { INSERT INTO t3 VALUES($i%2, $i, 'xyz') }\n  }\n  execsql { ANALYZE }\n} {}\ndo_eqp_test skipscan2-3.3eqp {\n  SELECT * FROM t3 WHERE b=42;\n} {0 0 0 {SEARCH TABLE t3 USING PRIMARY KEY (ANY(a) AND b=?)}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/skipscan3.test",
    "content": "# 2014-08-20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests of the \"skip-scan\" query strategy.\n# In particular, this file looks at skipping intermediate terms\n# in an index.  For example, if (a,b,c) are indexed, and we have\n# \"WHERE a=?1 AND c=?2\" - verify that skip-scan can still be used.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test skipscan3-1.1 {\n  CREATE TABLE t1(a,b,c,d,PRIMARY KEY(a,b,c));\n  WITH RECURSIVE\n    c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n  INSERT INTO t1(a,b,c,d)\n    SELECT 1, 1, x, printf('x%04d',x) FROM c;\n  ANALYZE;\n} {}\n\n# This version has long used skip-scan because of the \"+a\"\n#\ndo_execsql_test skipscan3-1.2eqp {\n  EXPLAIN QUERY PLAN SELECT d FROM t1 WHERE +a=1 AND c=32;\n} {/*ANY(a) AND ANY(b)*/}\ndo_execsql_test skipscan3-1.2 {\n  SELECT d FROM t1 WHERE +a=1 AND c=32;\n} {x0032}\n\n# This version (with \"a\" instead of \"+a\") should use skip-scan but\n# did not prior to changes implemented on 2014-08-20\n#\ndo_execsql_test skipscan3-1.3eqp {\n  EXPLAIN QUERY PLAN SELECT d FROM t1 WHERE a=1 AND c=32;\n} {/*ANY(a) AND ANY(b)*/}\ndo_execsql_test skipscan3-1.3 {\n  SELECT d FROM t1 WHERE a=1 AND c=32;\n} {x0032}\n\n# Repeat the test on a WITHOUT ROWID table\n#\ndo_execsql_test skipscan3-2.1 {\n  CREATE TABLE t2(a,b,c,d,PRIMARY KEY(a,b,c)) WITHOUT ROWID;\n  WITH RECURSIVE\n    c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n  INSERT INTO t2(a,b,c,d)\n    SELECT 1, 1, x, printf('x%04d',x) FROM c;\n  ANALYZE;\n} {}\ndo_execsql_test skipscan3-2.2eqp {\n  EXPLAIN QUERY PLAN SELECT d FROM t2 WHERE +a=1 AND c=32;\n} {/*ANY(a) AND ANY(b)*/}\ndo_execsql_test skipscan3-2.2 {\n  SELECT d FROM t2 WHERE +a=1 AND c=32;\n} {x0032}\ndo_execsql_test skipscan3-2.3eqp {\n  EXPLAIN QUERY PLAN SELECT d FROM t2 WHERE a=1 AND c=32;\n} {/*ANY(a) AND ANY(b)*/}\ndo_execsql_test skipscan3-2.3 {\n  SELECT d FROM t2 WHERE a=1 AND c=32;\n} {x0032}\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/skipscan5.test",
    "content": "# 2013-11-13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests of the \"skip-scan\" query strategy. In \n# particular it tests that stat4 data can be used by a range query\n# that uses the skip-scan approach.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix skipscan5\n\nifcapable !stat4 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a INT, b INT, c INT);\n  CREATE INDEX i1 ON t1(a, b);\n} {}\n\nexpr srand(4)\ndo_test 1.2 {\n  for {set i 0} {$i < 100} {incr i} {\n    set a [expr int(rand()*4.0) + 1]\n    set b [expr int(rand()*20.0) + 1]\n    execsql { INSERT INTO t1 VALUES($a, $b, NULL) }\n  }\n  execsql ANALYZE\n} {}\n\nforeach {tn q res} {\n  1  \"b = 5\"                   {/*ANY(a) AND b=?*/}\n  2  \"b > 12 AND b < 16\"       {/*ANY(a) AND b>? AND b<?*/}\n  3  \"b > 2 AND b < 16\"        {/*SCAN TABLE t1*/}\n  4  \"b > 18 AND b < 25\"       {/*ANY(a) AND b>? AND b<?*/}\n  5  \"b > 15\"                  {/*ANY(a) AND b>?*/}\n  6  \"b > 5\"                   {/*SCAN TABLE t1*/}\n  7  \"b < 15\"                  {/*SCAN TABLE t1*/}\n  8  \"b < 5\"                   {/*ANY(a) AND b<?*/}\n  9  \"5 > b\"                   {/*ANY(a) AND b<?*/}\n  10 \"b = '5'\"                 {/*ANY(a) AND b=?*/}\n  11 \"b > '12' AND b < '16'\"   {/*ANY(a) AND b>? AND b<?*/}\n  12 \"b > '2' AND b < '16'\"    {/*SCAN TABLE t1*/}\n  13 \"b > '18' AND b < '25'\"   {/*ANY(a) AND b>? AND b<?*/}\n  14 \"b > '15'\"                {/*ANY(a) AND b>?*/}\n  15 \"b > '5'\"                 {/*SCAN TABLE t1*/}\n  16 \"b < '15'\"                {/*SCAN TABLE t1*/}\n  17 \"b < '5'\"                 {/*ANY(a) AND b<?*/}\n  18 \"'5' > b\"                 {/*ANY(a) AND b<?*/}\n} {\n  set sql \"EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE $q\"\n  do_execsql_test 1.3.$tn $sql $res\n}\n\n\n#-------------------------------------------------------------------------\n# Test that range-query/skip-scan estimation works with text values.\n# And on UTF-16 databases when there is no UTF-16 collation sequence\n# available.\n#\n\nproc test_collate {enc lhs rhs} {\n  string compare $lhs $rhs\n}\n\nforeach {tn dbenc coll} {\n  1 UTF-8   { add_test_collate db 0 0 1 }\n  2 UTF-16  { add_test_collate db 1 0 0 }\n  3 UTF-8   { add_test_collate db 0 1 0 }\n} {\n  reset_db\n  eval $coll\n\n  do_execsql_test 2.$tn.1 \" PRAGMA encoding = '$dbenc' \"\n  do_execsql_test 2.$tn.2 {\n    CREATE TABLE t2(a TEXT, b TEXT, c TEXT COLLATE test_collate, d TEXT);\n    CREATE INDEX i2 ON t2(a, b, c);\n  }\n\n  set vocab(d) { :) }\n  set vocab(c) { a b c d e f g h i j k l m n o p q r s t }\n  set vocab(b) { one two three }\n  set vocab(a) { sql }\n\n  do_test 2.$tn.3 {\n    for {set i 0} {$i < 100} {incr i} {\n      foreach var {a b c d} { \n        set $var [lindex $vocab($var) [expr $i % [llength $vocab($var)]]]\n      }\n      execsql { INSERT INTO t2 VALUES($a, $b, $c, $d) }\n    }\n    execsql ANALYZE\n  } {}\n\n  foreach {tn2 q res} {\n    1 { c BETWEEN 'd' AND 'e' }       {/*ANY(a) AND ANY(b) AND c>? AND c<?*/}\n    2 { c BETWEEN 'b' AND 'r' }       {/*SCAN TABLE t2*/}\n    3 { c > 'q' }                     {/*ANY(a) AND ANY(b) AND c>?*/}\n    4 { c > 'e' }                     {/*SCAN TABLE t2*/}\n    5 { c < 'q' }                     {/*SCAN TABLE t2*/}\n    6 { c < 'c' }                     {/*ANY(a) AND ANY(b) AND c<?*/}\n  } {\n    set sql \"EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE $q\" \n    do_execsql_test 2.$tn.$tn2 $sql $res\n  }\n\n}\n\n#-------------------------------------------------------------------------\n# Test that range-query/skip-scan estimation works on columns that contain\n# a variety of types.\n#\n\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE t3(a, b, c);\n  CREATE INDEX i3 ON t3(a, b);\n}\n\nset values {\n    NULL NULL NULL\n    NULL -9567 -9240\n    -8725 -8659 -8248.340244520614\n    -8208 -7939 -7746.985758536954\n    -7057 -6550 -5916\n    -5363 -4935.781822975623 -4935.063633571875\n    -3518.4554911770183 -2537 -2026\n    -1511.2603881914456 -1510.4195994839156 -1435\n    -1127.4210136045804 -1045 99\n    1353 1457 1563.2908193223611\n    2245 2286 2552\n    2745.18831295203 2866.279926554429 3075.0468527316334\n    3447 3867 4237.892420141907\n    4335 5052.9775000424015 5232.178240656935\n    5541.784919585003 5749.725576373621 5758\n    6005 6431 7263.477992854769\n    7441 7541 8667.279760663994\n    8857 9199.638673662972 'dl'\n    'dro' 'h' 'igprfq'\n    'jnbd' 'k' 'kordee'\n    'lhwcv' 'mzlb' 'nbjked'\n    'nufpo' 'nxqkdq' 'shelln'\n    'tvzn' 'wpnt' 'wylf'\n    'ydkgu' 'zdb' X''\n    X'0a' X'203f6429f1f33f' X'23858e324545e0362b'\n    X'3f9f8a' X'516f7ddd4b' X'68f1df0930ac6b'\n    X'9ea60d' X'a06f' X'aefd342a39ce36df'\n    X'afaa020fe2' X'be201c' X'c47d97b209601e45'\n}\n\ndo_test 3.2 {\n  set c 0\n  foreach v $values {\n    execsql \"INSERT INTO t3 VALUES($c % 2, $v, $c)\"\n    incr c\n  }\n  execsql ANALYZE\n} {}\n\nforeach {tn q res} {\n  1 \"b BETWEEN -10000 AND -8000\"       {/*ANY(a) AND b>? AND b<?*/}\n  2 \"b BETWEEN -10000 AND 'qqq'\"       {/*SCAN TABLE t3*/}\n  3 \"b < X'5555'\"                      {/*SCAN TABLE t3*/}\n  4 \"b > X'5555'\"                      {/*ANY(a) AND b>?*/}\n  5 \"b > 'zzz'\"                        {/*ANY(a) AND b>?*/}\n  6 \"b < 'zzz'\"                        {/*SCAN TABLE t3*/}\n} {\n  set sql \"EXPLAIN QUERY PLAN SELECT * FROM t3 WHERE $q\" \n  do_execsql_test 3.3.$tn $sql $res\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/skipscan6.test",
    "content": "# 2014-10-21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests of the \"skip-scan\" query strategy. In \n# particular, this file verifies that use of all columns of an index\n# is always preferred over the use of a skip-scan on some columns of\n# the same index.  Because of difficulties in scoring a skip-scan,\n# the skip-scan can sometimes come out with a lower raw score when\n# using STAT4.  But the query planner should detect this and use the\n# full index rather than the skip-scan.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix skipscan6\n\nifcapable !stat4 {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(\n    aa int,\n    bb int,\n    cc int,\n    dd int,\n    ee int\n  );\n  CREATE INDEX ix on t1(aa, bb, cc,  dd DESC);\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('t1','ix','2695116 1347558 264 18 2');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 196859 196859 32 1','0 15043 15043 92468 92499','0 19 286 81846 92499',X'0609010804031552977BD725BD28');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 14687 161 1 1','0 289067 299306 299457 299457','0 199 6772 273984 299457',X'060902020403013406314D67456415B819');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 19313 19308 22 1','0 325815 325815 343725 343746','0 261 9545 315009 343746',X'060902080403018A49B0A3AD1ED931');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 25047 9051 15 1','0 350443 350443 356590 356604','0 266 9795 325519 356604',X'06090208040301914C2DD2E91F93CF');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 42327 9906 7 1','0 376381 376381 380291 380297','0 268 10100 344232 380297',X'06090208040301934BF672511F7ED3');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 24513 2237 1 1','0 455150 467779 470015 470015','0 286 10880 425401 470015',X'06090202040301A703464A28F2611EF1EE');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18730 18724 15 1','0 479663 479663 498271 498285','0 287 10998 450793 498285',X'06090208040301A8494AF3A41EC50C');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 119603 47125 1 1','0 572425 572425 598915 598915','0 404 14230 546497 598915',X'06090208040302474FD1929A03194F');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 1454 1454 1 1','0 898346 898346 898373 898373','0 952 31165 827562 898373',X'06090208040304FD53F6A2A2097F64');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 57138 7069 1 1','0 1122389 1122389 1129457 1129457','0 1967 46801 1045943 1129457',X'06090208040309884BC4C52F1F6EB7');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 285 11 1 1','0 1197683 1197824 1197831 1197831','0 2033 50990 1112280 1197831',X'06090202040309D80346503FE2A9038E4F');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 25365 9773 1 1','0 1301013 1301013 1310785 1310785','0 2561 58806 1217877 1310785',X'0609020804030C5F4C8F88AB0AF2A2');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 45180 7222 1 1','0 1326378 1326378 1333599 1333599','0 2562 59921 1240187 1333599',X'0609020804030C604CAB75490B0351');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 8537 41 1 1','0 1496959 1497288 1497289 1497289','0 3050 68246 1394126 1497289',X'0609020204030EA0057F527459B0257C4B');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 26139 26131 17 1','0 1507977 1507977 1520578 1520594','0 3074 69188 1416111 1520594',X'0609020804030EB95169453423D4EA');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 102894 29678 1 1','0 1537421 1550467 1564894 1564894','0 3109 69669 1459820 1564894',X'0609020204030EE3183652A6ED3006EBCB');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 319 3 1 1','0 1796728 1796746 1796747 1796747','0 3650 86468 1682243 1796747',X'0609020204031163033550D0C41018C28D');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 127 127 1 1','0 2096194 2096194 2096205 2096205','0 5145 106437 1951535 2096205',X'060902080403180F53BB1AF727EE50');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 66574 5252 1 1','0 2230524 2265961 2271212 2271212','0 5899 114976 2085829 2271212',X'0609020204031B8A05195009976D223B90');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 19440 19440 1 1','0 2391680 2391680 2395663 2395663','0 6718 123714 2184781 2395663',X'0609020804031F7452E00A7B07431A');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18321 2177 1 1','0 2522928 2523231 2525407 2525407','0 7838 139084 2299958 2525407',X'06090201040324A7475231103B1AA7B8');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 22384 1361 1 1','0 2541249 2544834 2546194 2546194','0 7839 139428 2308416 2546194',X'06090202040324A8011652323D4B1AA9EB');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','2677151 18699 855 1 1','0 2563633 2578178 2579032 2579032','0 7840 139947 2321671 2579032',X'06090202040324A9077452323D7D1052C5');\n  INSERT INTO sqlite_stat4 VALUES('t1','ix','17965 1579 1579 1 1','2677151 2690666 2690666 2692244 2692244','1 9870 153959 2418294 2692244',X'060102080403021B8A4FE1AB84032B35');\n  ANALYZE sqlite_master;\n} {}\ndo_execsql_test 1.2 {\n  EXPLAIN QUERY PLAN\n  SELECT COUNT(*)\n    FROM t1\n   WHERE bb=21\n     AND aa=1\n     AND dd BETWEEN 1413833728 and 1413837331;\n} {/INDEX ix .aa=. AND bb=../}\n\ndo_execsql_test 2.1 {\n  DROP INDEX ix;\n  CREATE INDEX good on t1(bb, aa, dd DESC);\n  CREATE INDEX bad on t1(aa, bb, cc,  dd DESC);\n  DELETE FROM sqlite_stat1;\n  DELETE FROM sqlite_stat4;\n  INSERT INTO sqlite_stat1 VALUES('t1','good','2695116 299 264 2');\n  INSERT INTO sqlite_stat1 VALUES('t1','bad','2695116 1347558 264 18 2');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','197030 196859 32 1','15086 15086 92511 92536','19 25 81644 92536',X'05010904031552977BD725BD22');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','14972 14687 1 1','289878 289878 299457 299457','199 244 267460 299457',X'050209040301344F7E569402C419');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','19600 19313 22 1','327127 327127 346222 346243','261 319 306884 346243',X'0502090403018A49503BC01EC577');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','25666 25047 15 1','352087 352087 372692 372706','266 327 325601 372706',X'050209040301914C2DD2E91F93CF');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','42392 42327 26 1','378657 378657 382547 382572','268 331 333529 382572',X'05020904030193533B2FE326ED48');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','24619 24513 11 1','457872 457872 461748 461758','286 358 399322 461758',X'050209040301A752B1557825EA7C');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','18969 18730 15 1','482491 482491 501105 501119','287 360 433605 501119',X'050209040301A8494AF3A41EC50C');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','119710 119603 1 1','576500 576500 598915 598915','404 505 519877 598915',X'05020904030247539A7A7912F617');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','11955 11946 1 1','889796 889796 898373 898373','938 1123 794694 898373',X'050209040304EF4DF9C4150BBB28');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','57197 57138 24 1','1129865 1129865 1151492 1151515','1967 2273 1027048 1151515',X'05020904030988533510BC26E20A');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','3609 3543 1 1','1196265 1196265 1197831 1197831','2002 2313 1070108 1197831',X'050209040309B050E95CD718D94D');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','25391 25365 13 1','1309378 1309378 1315567 1315579','2561 2936 1178358 1315579',X'05020904030C5F53DF9E13283570');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','45232 45180 17 1','1334769 1334769 1337946 1337962','2562 2938 1198998 1337962',X'05020904030C60541CACEE28BCAC');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','5496 5493 1 1','1495882 1495882 1497289 1497289','3043 3479 1348695 1497289',X'05020904030E99515C62AD0F0B34');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','26348 26139 17 1','1517381 1517381 1529990 1530006','3074 3519 1378320 1530006',X'05020904030EB95169453423D4EA');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','102927 102894 10 1','1547088 1547088 1649950 1649959','3109 3559 1494260 1649959',X'05020904030EE34D309F671FFA47');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','3602 3576 1 1','1793873 1793873 1796747 1796747','3601 4128 1630783 1796747',X'050209040311294FE88B432219B9');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','154 154 1 1','2096059 2096059 2096205 2096205','5037 5779 1893039 2096205',X'050209040317994EFF05A016DCED');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','68153 66574 60 1','2244039 2244039 2268892 2268951','5899 6749 2027553 2268951',X'05020904031B8A532DBC5A26D2BA');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','321 321 1 1','2395618 2395618 2395663 2395663','6609 7528 2118435 2395663',X'05020904031EFA54078EEE1E2D65');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','19449 19440 22 1','2407769 2407769 2426049 2426070','6718 7651 2146904 2426070',X'05020904031F7450E6118C2336BD');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','18383 18321 56 1','2539949 2539949 2551080 2551135','7838 8897 2245459 2551135',X'050209040324A752EA2E1E2642B2');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','22479 22384 60 1','2558332 2558332 2565233 2565292','7839 8899 2251202 2565292',X'050209040324A853926538279A5F');\n  INSERT INTO sqlite_stat4 VALUES('t1','good','18771 18699 63 1','2580811 2580811 2596914 2596976','7840 8901 2263572 2596976',X'050209040324A9526C1DE9256E72');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 196859 196859 32 1','0 15043 15043 92468 92499','0 19 286 81846 92499',X'0609010804031552977BD725BD28');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 14687 161 1 1','0 289067 299306 299457 299457','0 199 6772 273984 299457',X'060902020403013406314D67456415B819');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 19313 19308 22 1','0 325815 325815 343725 343746','0 261 9545 315009 343746',X'060902080403018A49B0A3AD1ED931');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 25047 9051 15 1','0 350443 350443 356590 356604','0 266 9795 325519 356604',X'06090208040301914C2DD2E91F93CF');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 42327 9906 7 1','0 376381 376381 380291 380297','0 268 10100 344232 380297',X'06090208040301934BF672511F7ED3');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 24513 2237 1 1','0 455150 467779 470015 470015','0 286 10880 425401 470015',X'06090202040301A703464A28F2611EF1EE');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18730 18724 15 1','0 479663 479663 498271 498285','0 287 10998 450793 498285',X'06090208040301A8494AF3A41EC50C');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 119603 47125 1 1','0 572425 572425 598915 598915','0 404 14230 546497 598915',X'06090208040302474FD1929A03194F');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 1454 1454 1 1','0 898346 898346 898373 898373','0 952 31165 827562 898373',X'06090208040304FD53F6A2A2097F64');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 57138 7069 1 1','0 1122389 1122389 1129457 1129457','0 1967 46801 1045943 1129457',X'06090208040309884BC4C52F1F6EB7');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 285 11 1 1','0 1197683 1197824 1197831 1197831','0 2033 50990 1112280 1197831',X'06090202040309D80346503FE2A9038E4F');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 25365 9773 1 1','0 1301013 1301013 1310785 1310785','0 2561 58806 1217877 1310785',X'0609020804030C5F4C8F88AB0AF2A2');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 45180 7222 1 1','0 1326378 1326378 1333599 1333599','0 2562 59921 1240187 1333599',X'0609020804030C604CAB75490B0351');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 8537 41 1 1','0 1496959 1497288 1497289 1497289','0 3050 68246 1394126 1497289',X'0609020204030EA0057F527459B0257C4B');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 26139 26131 17 1','0 1507977 1507977 1520578 1520594','0 3074 69188 1416111 1520594',X'0609020804030EB95169453423D4EA');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 102894 29678 1 1','0 1537421 1550467 1564894 1564894','0 3109 69669 1459820 1564894',X'0609020204030EE3183652A6ED3006EBCB');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 319 3 1 1','0 1796728 1796746 1796747 1796747','0 3650 86468 1682243 1796747',X'0609020204031163033550D0C41018C28D');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 127 127 1 1','0 2096194 2096194 2096205 2096205','0 5145 106437 1951535 2096205',X'060902080403180F53BB1AF727EE50');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 66574 5252 1 1','0 2230524 2265961 2271212 2271212','0 5899 114976 2085829 2271212',X'0609020204031B8A05195009976D223B90');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 19440 19440 1 1','0 2391680 2391680 2395663 2395663','0 6718 123714 2184781 2395663',X'0609020804031F7452E00A7B07431A');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18321 2177 1 1','0 2522928 2523231 2525407 2525407','0 7838 139084 2299958 2525407',X'06090201040324A7475231103B1AA7B8');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 22384 1361 1 1','0 2541249 2544834 2546194 2546194','0 7839 139428 2308416 2546194',X'06090202040324A8011652323D4B1AA9EB');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','2677151 18699 855 1 1','0 2563633 2578178 2579032 2579032','0 7840 139947 2321671 2579032',X'06090202040324A9077452323D7D1052C5');\n  INSERT INTO sqlite_stat4 VALUES('t1','bad','17965 1579 1579 1 1','2677151 2690666 2690666 2692244 2692244','1 9870 153959 2418294 2692244',X'060102080403021B8A4FE1AB84032B35');\n  ANALYZE sqlite_master;\n} {}\ndo_execsql_test 2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT COUNT(*)\n    FROM t1\n   WHERE bb=21\n     AND aa=1\n     AND dd BETWEEN 1413833728 and 1413837331;\n} {/INDEX good .bb=. AND aa=. AND dd>. AND dd<../}\n\n\n# Create a table containing 100 rows. Column \"a\" contains a copy of the\n# rowid value - sequentially increasing integers from 1 to 100. Column\n# \"b\" contains the value of (a % 5). Columns \"c\" and \"d\" both contain\n# constant values (i.e. the same for every row).\n#\n# Then create a second table t2. t2 is the same as t3 except for the\n# order in which the indexes are created.\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE t3(a, b, c, d);\n  CREATE INDEX t3_ba ON t3(b, a, c);\n  CREATE INDEX t3_a ON t3(a);\n\n  WITH d(a, b) AS (\n    SELECT 1, 1 \n    UNION ALL\n    SELECT a+1, (a+1) % 5 FROM d WHERE a<100\n  )\n  INSERT INTO t3 SELECT a, b, 'c', 'd' FROM d;\n\n  CREATE TABLE t2(a, b, c, d);\n  CREATE INDEX t2_a ON t2(a);\n  CREATE INDEX t2_ba ON t2(b, a, c);\n  INSERT INTO t2 SELECT * FROM t3;\n\n  ANALYZE;\n  SELECT * FROM sqlite_stat1;\n} {\n  t2 t2_ba   {100 20 1 1}\n  t2 t2_a    {100 1} \n  t3 t3_a    {100 1} \n  t3 t3_ba   {100 20 1 1}\n}\n\n# Use index \"t3_a\", as (a=?) is expected to match only a single row.\n#\ndo_eqp_test 3.1 {\n  SELECT * FROM t3 WHERE a = ? AND c = ?\n} {\n  0 0 0 {SEARCH TABLE t3 USING INDEX t3_a (a=?)}\n}\n\n# The same query on table t2. This should use index \"t2_a\", for the\n# same reason. At one point though, it was mistakenly using a skip-scan.\n#\ndo_eqp_test 3.2 {\n  SELECT * FROM t2 WHERE a = ? AND c = ?\n} {\n  0 0 0 {SEARCH TABLE t2 USING INDEX t2_a (a=?)}\n}\n\nfinish_test\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/snapshot.test",
    "content": "# 2015 December 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this file is the sqlite3_snapshot_xxx() APIs.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !snapshot {finish_test; return}\nset testprefix snapshot\n\n# This test does not work with the inmemory_journal permutation. The reason\n# is that each connection opened as part of this permutation executes\n# \"PRAGMA journal_mode=memory\", which fails if the database is in wal mode\n# and there are one or more existing connections.\nif {[permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\nforeach {tn tcl} {\n  1 {\n    proc snapshot_get {DB DBNAME} {\n      uplevel [list sqlite3_snapshot_get $DB $DBNAME]\n    }\n    proc snapshot_open {DB DBNAME SNAPSHOT} {\n      uplevel [list sqlite3_snapshot_open $DB $DBNAME $SNAPSHOT]\n    }\n    proc snapshot_free {SNAPSHOT} {\n      uplevel [list sqlite3_snapshot_free $SNAPSHOT]\n    }\n    proc snapshot_cmp {SNAPSHOT1 SNAPSHOT2} {\n      uplevel [list sqlite3_snapshot_cmp $SNAPSHOT1 $SNAPSHOT2]\n    }\n  }\n\n  2 {\n    proc snapshot_get {DB DBNAME} {\n      uplevel [list sqlite3_snapshot_get_blob $DB $DBNAME]\n    }\n    proc snapshot_open {DB DBNAME SNAPSHOT} {\n      uplevel [list sqlite3_snapshot_open_blob $DB $DBNAME $SNAPSHOT]\n    }\n    proc snapshot_free {SNAPSHOT} {\n    }\n    proc snapshot_cmp {SNAPSHOT1 SNAPSHOT2} {\n      uplevel [list sqlite3_snapshot_cmp_blob $SNAPSHOT1 $SNAPSHOT2]\n    }\n  }\n} {\n\n  reset_db\n  eval $tcl\n\n  #-------------------------------------------------------------------------\n  # Check some error conditions in snapshot_get(). It is an error if:\n  #\n  #  1) snapshot_get() is called on a non-WAL database, or\n  #  2) there is an open write transaction on the database.\n  #  3) the database handle is in auto-commit mode\n  #\n  do_execsql_test $tn.1.0 {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n\n  do_test $tn.1.1.1 {\n    execsql { BEGIN; SELECT * FROM t1; }\n    list [catch { snapshot_get db main } msg] $msg\n  } {1 SQLITE_ERROR}\n  do_execsql_test $tn.1.1.2 COMMIT\n\n  do_test $tn.1.2.1 {\n    execsql {\n      PRAGMA journal_mode = WAL;\n      BEGIN;\n        INSERT INTO t1 VALUES(5, 6);\n        INSERT INTO t1 VALUES(7, 8);\n    }\n    list [catch { snapshot_get db main } msg] $msg\n  } {1 SQLITE_ERROR}\n  do_execsql_test $tn.1.2.2 COMMIT\n\n  do_test $tn.1.3.1 {\n    list [catch { snapshot_get db main } msg] $msg\n  } {1 SQLITE_ERROR}\n  do_test $tn.1.3.2 {\n    db trans { set snap [snapshot_get db main] }\n    snapshot_free $snap\n  } {}\n\n  #-------------------------------------------------------------------------\n  # Check that a simple case works. Reuse the database created by the\n  # block of tests above.\n  #\n  do_execsql_test $tn.2.1.0 {\n    BEGIN;\n      SELECT * FROM t1;\n  } {1 2 3 4 5 6 7 8}\n\n  do_test $tn.2.1.1 {\n    set snapshot [snapshot_get db main]\n    execsql {\n      COMMIT;\n      INSERT INTO t1 VALUES(9, 10);\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 7 8 9 10}\n\n  do_test $tn.2.1.2 {\n    execsql BEGIN\n    snapshot_open db main $snapshot\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 7 8}\n\n  do_test $tn.2.1.3 {\n    snapshot_free $snapshot\n    execsql COMMIT\n  } {}\n\n  do_test $tn.2.2.0 {\n    sqlite3 db2 test.db\n    execsql {\n      BEGIN;\n        SELECT * FROM t1;\n    } db2\n  } {1 2 3 4 5 6 7 8 9 10}\n\n  do_test $tn.2.2.1 {\n    set snapshot [snapshot_get db2 main]\n    execsql {\n      INSERT INTO t1 VALUES(11, 12);\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 7 8 9 10 11 12}\n\n  do_test $tn.2.2.2 {\n    execsql BEGIN\n    snapshot_open db main $snapshot\n    execsql {\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 7 8 9 10}\n\n  do_test $tn.2.2.3 {\n    snapshot_free $snapshot\n    execsql COMMIT\n    execsql COMMIT db2\n    db2 close\n  } {}\n\n  do_test $tn.2.3.1 {\n    execsql { DELETE FROM t1 WHERE a>6 }\n    db trans { set snapshot [snapshot_get db main] }\n    execsql {\n      INSERT INTO t1 VALUES('a', 'b');\n      INSERT INTO t1 VALUES('c', 'd');\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4 5 6 a b c d}\n  do_test $tn.2.3.2 {\n    execsql BEGIN\n    snapshot_open db main $snapshot\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6}\n\n  do_test $tn.2.3.3 {\n    catchsql {\n      INSERT INTO t1 VALUES('x','y')\n    }\n  } {1 {database is locked}}\n  do_test $tn.2.3.4 {\n    execsql COMMIT\n    snapshot_free $snapshot\n  } {}\n\n  #-------------------------------------------------------------------------\n  # Check some errors in snapshot_open(). It is an error if:\n  #\n  #   1) the db is in auto-commit mode,\n  #   2) the db has an open (read or write) transaction,\n  #   3) the db is not a wal database,\n  #\n  # Reuse the database created by earlier tests.\n  #\n  do_execsql_test $tn.3.0.0 {\n    CREATE TABLE t2(x, y);\n    INSERT INTO t2 VALUES('a', 'b');\n    INSERT INTO t2 VALUES('c', 'd');\n    BEGIN;\n      SELECT * FROM t2;\n  } {a b c d}\n  do_test $tn.3.0.1 {\n    set snapshot [snapshot_get db main]\n    execsql { COMMIT }\n    execsql { INSERT INTO t2 VALUES('e', 'f'); }\n  } {}\n\n  do_test $tn.3.1 {\n    list [catch {snapshot_open db main $snapshot } msg] $msg\n  } {1 SQLITE_ERROR}\n\n  do_test $tn.3.2.1 {\n    execsql {\n      BEGIN;\n        SELECT * FROM t2;\n    }\n  } {a b c d e f}\n  do_test $tn.3.2.2 {\n    list [catch {snapshot_open db main $snapshot } msg] $msg\n  } {1 SQLITE_ERROR}\n\n  do_test $tn.3.2.3 {\n    execsql {\n      COMMIT;\n      BEGIN;\n        INSERT INTO t2 VALUES('g', 'h');\n    }\n    list [catch {snapshot_open db main $snapshot } msg] $msg\n  } {1 SQLITE_ERROR}\n  do_execsql_test $tn.3.2.4 COMMIT\n\n  do_test $tn.3.3.1 {\n    execsql { PRAGMA journal_mode = DELETE }\n    execsql { BEGIN }\n    list [catch {snapshot_open db main $snapshot } msg] $msg\n  } {1 SQLITE_ERROR}\n\n  do_test $tn.$tn.3.3.2 {\n    snapshot_free $snapshot\n    execsql COMMIT\n  } {}\n\n  #-------------------------------------------------------------------------\n  # Check that SQLITE_BUSY_SNAPSHOT is returned if the specified snapshot\n  # no longer exists because the wal file has been checkpointed.\n  #\n  #   1. Reading a snapshot from the middle of a wal file is not possible\n  #      after the wal file has been checkpointed.\n  #\n  #   2. That a snapshot from the end of a wal file can not be read once\n  #      the wal file has been wrapped.\n  #\n  do_execsql_test $tn.4.1.0 {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t3(i, j);\n    INSERT INTO t3 VALUES('o', 't');\n    INSERT INTO t3 VALUES('t', 'f');\n    BEGIN;\n      SELECT * FROM t3;\n  } {wal o t t f}\n\n  do_test $tn.4.1.1 {\n    set snapshot [snapshot_get db main]\n    execsql COMMIT\n  } {}\n  do_test $tn.4.1.2 {\n    execsql { \n      INSERT INTO t3 VALUES('f', 's'); \n      BEGIN;\n    }\n    snapshot_open db main $snapshot\n    execsql { SELECT * FROM t3 }\n  } {o t t f}\n\n  do_test $tn.4.1.3 {\n    execsql { \n      COMMIT;\n      PRAGMA wal_checkpoint;\n      BEGIN;\n    }\n    list [catch {snapshot_open db main $snapshot} msg] $msg\n  } {1 SQLITE_BUSY_SNAPSHOT}\n  do_test $tn.4.1.4 {\n    snapshot_free $snapshot\n    execsql COMMIT\n  } {}\n\n  do_test $tn.4.2.1 {\n    execsql {\n      INSERT INTO t3 VALUES('s', 'e');\n      INSERT INTO t3 VALUES('n', 't');\n      BEGIN;\n        SELECT * FROM t3;\n    }\n  } {o t t f f s s e n t}\n  do_test $tn.4.2.2 {\n    set snapshot [snapshot_get db main]\n    execsql {\n      COMMIT;\n      PRAGMA wal_checkpoint;\n      BEGIN;\n    }\n    snapshot_open db main $snapshot\n    execsql { SELECT * FROM t3 }\n  } {o t t f f s s e n t}\n  do_test $tn.4.2.3 {\n    execsql {\n      COMMIT;\n      INSERT INTO t3 VALUES('e', 't');\n      BEGIN;\n    }\n    list [catch {snapshot_open db main $snapshot} msg] $msg\n  } {1 SQLITE_BUSY_SNAPSHOT}\n  do_test $tn.4.2.4 {\n    snapshot_free $snapshot\n  } {}\n\n  #-------------------------------------------------------------------------\n  # Check that SQLITE_BUSY is returned if a checkpoint is running when\n  # sqlite3_snapshot_open() is called.\n  #\n  reset_db\n  db close\n  testvfs tvfs\n  sqlite3 db test.db -vfs tvfs\n\n  do_execsql_test $tn.5.1 {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE x1(x, xx, xxx);\n    INSERT INTO x1 VALUES('z', 'zz', 'zzz');\n    BEGIN;\n      SELECT * FROM x1;\n  } {wal z zz zzz}\n\n  do_test $tn.5.2 {\n    set ::snapshot [snapshot_get db main]\n    sqlite3 db2 test.db -vfs tvfs\n    execsql {\n      INSERT INTO x1 VALUES('a', 'aa', 'aaa');\n      COMMIT;\n    }\n  } {}\n\n  set t53 0\n  proc write_callback {args} {\n    do_test $tn.5.3.[incr ::t53] {\n      execsql BEGIN\n      list [catch { snapshot_open db main $::snapshot } msg] $msg\n    } {1 SQLITE_BUSY}\n    catchsql COMMIT\n  }\n\n  tvfs filter xWrite\n  tvfs script write_callback\n  db2 eval { PRAGMA wal_checkpoint }\n  db close\n  db2 close\n  tvfs delete\n  snapshot_free $snapshot\n\n  #-------------------------------------------------------------------------\n  # Test that sqlite3_snapshot_get() may be called immediately after\n  # \"BEGIN; PRAGMA user_version;\". And that sqlite3_snapshot_open() may\n  # be called after opening the db handle and running the script\n  # \"PRAGMA user_version; BEGIN\".\n  reset_db\n  do_execsql_test $tn.6.1 {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE x1(x, xx, xxx);\n    INSERT INTO x1 VALUES('z', 'zz', 'zzz');\n    BEGIN;\n      PRAGMA user_version;\n  } {wal 0}\n  do_test $tn.6.2 {\n    set ::snapshot [snapshot_get db main]\n    execsql {\n      INSERT INTO x1 VALUES('a', 'aa', 'aaa');\n      COMMIT;\n    }\n  } {}\n  do_test $tn.6.3 {\n    sqlite3 db2 test.db \n    db2 eval \"PRAGMA user_version ; BEGIN\"\n    snapshot_open db2 main $::snapshot\n    db2 eval { SELECT * FROM x1 }\n  } {z zz zzz}\n  do_test $tn.6.4 {\n    db2 close\n    sqlite3 db2 test.db \n    db2 eval \"PRAGMA application_id\"\n    db2 eval \"BEGIN\"\n    snapshot_open db2 main $::snapshot\n    db2 eval { SELECT * FROM x1 }\n  } {z zz zzz}\n\n  do_test $tn.6.5 {\n    db2 close\n    sqlite3 db2 test.db \n    db2 eval \"BEGIN\"\n    list [catch {snapshot_open db2 main $::snapshot} msg] $msg\n  } {1 SQLITE_ERROR}\n\n  snapshot_free $snapshot\n\n  #-------------------------------------------------------------------------\n  # The following tests investigate the sqlite3_snapshot_cmp() API.\n  #\n\n  # Compare snapshots $p1 and $p2, checking that the result is $r.\n  #\n  proc do_snapshot_cmp_test {tn p1 p2 r} {\n    uplevel [list do_test $tn.1 [list snapshot_cmp $p1 $p2] $r]\n    uplevel [list do_test $tn.2 [list snapshot_cmp $p2 $p1] [expr $r*-1]]\n    uplevel [list do_test $tn.3 [list snapshot_cmp $p1 $p1] 0]\n    uplevel [list do_test $tn.4 [list snapshot_cmp $p2 $p2] 0]\n  }\n\n  catch { db2 close }\n  reset_db\n\n  do_execsql_test $tn.7.1 {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t1(x);\n  } wal\n\n  do_test $tn.7.1.2 {\n    execsql { BEGIN ; PRAGMA application_id }\n    set p1 [snapshot_get db main]\n    execsql {\n      INSERT INTO t1 VALUES(10);\n      COMMIT;\n    }\n    execsql { BEGIN ; PRAGMA application_id }\n    set p2 [snapshot_get db main]\n    execsql COMMIT\n  } {}\n\n  do_snapshot_cmp_test $tn.7.1.3 $p1 $p2 -1\n  snapshot_free $p1\n  snapshot_free $p2\n\n  do_execsql_test $tn.7.2.1 {\n    INSERT INTO t1 VALUES(11);\n    INSERT INTO t1 VALUES(12);\n    INSERT INTO t1 VALUES(13);\n    BEGIN; \n      PRAGMA application_id;\n  } {0}\n  do_test $tn.7.2.2 {\n    set p1 [snapshot_get db main]\n    execsql {\n      COMMIT;\n      INSERT INTO t1 VALUES(14);\n      PRAGMA wal_checkpoint;\n      BEGIN;\n        PRAGMA application_id;\n    }\n    set p2 [snapshot_get db main]\n    execsql COMMIT\n  } {}\n\n  do_snapshot_cmp_test $tn.7.2.3 $p1 $p2 -1\n  snapshot_free $p2\n\n  do_test $tn.7.3.1 {\n    execsql {\n      INSERT INTO t1 VALUES(14);\n      BEGIN;\n        PRAGMA application_id;\n    }\n    set p2 [snapshot_get db main]\n    execsql COMMIT\n  } {}\n\n  do_snapshot_cmp_test $tn.7.3.2 $p1 $p2 -1\n  snapshot_free $p1\n  snapshot_free $p2\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/snapshot2.test",
    "content": "# 2016 November 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this file is the sqlite3_snapshot_xxx() APIs.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !snapshot {finish_test; return}\nset testprefix snapshot2\n\n# This test does not work with the inmemory_journal permutation. The reason\n# is that each connection opened as part of this permutation executes\n# \"PRAGMA journal_mode=memory\", which fails if the database is in wal mode\n# and there are one or more existing connections.\nif {[permutation]==\"inmemory_journal\"} {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Check that it is not possible to obtain a snapshot immediately after\n# a wal mode database with an empty wal file is opened. But it is after\n# the file has been written, even by some other connection.\n#\ndo_execsql_test 1.0 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(4, 5, 6);\n} {wal}\n\ndb close\ndo_test 1.1.1 { list [file exists test.db] [file exists test.db-wal] } {1 0}\n\nsqlite3 db test.db\ndo_execsql_test 1.1.2 { SELECT * FROM t1 } {1 2 3 4 5 6}\n\ndo_test 1.1.3 {\n  execsql BEGIN\n  list [catch { sqlite3_snapshot_get_blob db main } msg] $msg\n} {1 SQLITE_ERROR}\nexecsql COMMIT\n\ndo_test 1.1.4 {\n  execsql { INSERT INTO t1 VALUES(7, 8, 9) }\n  execsql BEGIN\n  string length [sqlite3_snapshot_get_blob db main]\n} 48\nexecsql COMMIT\n\ndb close\ndo_test 1.2.1 { list [file exists test.db] [file exists test.db-wal] } {1 0}\n\nsqlite3 db test.db\ndo_execsql_test 1.2.2 { SELECT * FROM t1 } {1 2 3 4 5 6 7 8 9}\n\ndo_test 1.2.3 {\n  execsql BEGIN\n  list [catch { sqlite3_snapshot_get_blob db main } msg] $msg\n} {1 SQLITE_ERROR}\nexecsql COMMIT\n\ndo_test 1.2.4 {\n  sqlite3 db2 test.db\n  execsql { INSERT INTO t1 VALUES(10, 11, 12) } db2\n  execsql BEGIN\n  string length [sqlite3_snapshot_get_blob db main]\n} 48\nexecsql COMMIT\ndb2 close\n\n#-------------------------------------------------------------------------\n# Simple tests for sqlite3_snapshot_recover().\n#\nreset_db\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(x);\n  PRAGMA journal_mode = wal;\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n} {wal}\n\ndo_test 2.1 {\n  db trans { set snap [sqlite3_snapshot_get_blob db main] }\n  sqlite3_db_config db NO_CKPT_ON_CLOSE 1\n  db close\n  sqlite3 db test.db\n\n  execsql {SELECT * FROM sqlite_master}\n  execsql BEGIN\n  sqlite3_snapshot_open_blob db main $snap\n  execsql COMMIT;\n  execsql { INSERT INTO t1 VALUES(3); }\n} {}\n\ndo_test 2.2 {\n  sqlite3_db_config db NO_CKPT_ON_CLOSE 1\n  db close\n  sqlite3 db test.db\n\n  execsql {SELECT * FROM sqlite_master}\n  execsql BEGIN\n  list [catch { sqlite3_snapshot_open_blob db main $snap } msg] $msg\n} {1 SQLITE_BUSY_SNAPSHOT}\n\ndo_test 2.3 {\n  execsql COMMIT\n  sqlite3_snapshot_recover db main\n  execsql BEGIN\n  sqlite3_snapshot_open_blob db main $snap\n  execsql { SELECT * FROM t1 }\n} {1 2}\n\ndo_test 2.4 {\n  execsql COMMIT\n  execsql { SELECT * FROM t1 }\n} {1 2 3}\n\ndo_test 2.5 {\n  execsql { PRAGMA wal_checkpoint }\n  sqlite3_db_config db NO_CKPT_ON_CLOSE 1\n  db close\n  sqlite3 db test.db\n\n  sqlite3_snapshot_recover db main\n  execsql BEGIN\n  list [catch { sqlite3_snapshot_open_blob db main $snap } msg] $msg\n} {1 SQLITE_BUSY_SNAPSHOT}\n\n#-------------------------------------------------------------------------\n# Check that calling sqlite3_snapshot_recover() does not confuse the\n# pager cache.\nreset_db\ndo_execsql_test 3.0 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES('a', 'b');\n  INSERT INTO t1 VALUES('c', 'd');\n} {wal}\ndo_test 3.1 {\n  sqlite3 db2 test.db\n  execsql { INSERT INTO t1 VALUES('e', 'f') } db2\n  db2 close\n  sqlite3_snapshot_recover db main\n} {}\ndo_execsql_test 3.2 {\n  SELECT * FROM t1;\n} {a b c d e f}\n\n#-------------------------------------------------------------------------\n# Check that sqlite3_snapshot_recover() returns an error if it is called\n# with an open read-transaction. Or on a database that does not exist. Or\n# on the temp database. Or on a db that is not in wal mode.\n#\ndo_test 4.1 {\n  sqlite3_snapshot_recover db main\n} {}\ndo_test 4.2 {\n  execsql {\n    BEGIN;\n      SELECT * FROM sqlite_master;\n  }\n  list [catch { sqlite3_snapshot_recover db main } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test 4.3 {\n  execsql COMMIT\n  sqlite3_snapshot_recover db main\n} {}\ndo_test 4.4 {\n  list [catch { sqlite3_snapshot_recover db aux } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test 4.5 {\n  forcedelete test.db2\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    PRAGMA aux.journal_mode = wal;\n    CREATE TABLE aux.t2(x, y);\n  }\n  list [catch { sqlite3_snapshot_recover db aux } msg] $msg\n} {0 {}}\ndo_test 4.6 {\n  list [catch { sqlite3_snapshot_recover db temp } msg] $msg\n} {1 SQLITE_ERROR}\ndo_test 4.7 {\n  execsql {\n    PRAGMA aux.journal_mode = delete;\n  }\n  list [catch { sqlite3_snapshot_recover db aux } msg] $msg\n} {1 SQLITE_ERROR}\n\n#-------------------------------------------------------------------------\nreset_db\nsqlite3 db2 test.db \ndo_execsql_test 5.0 {\n  CREATE TABLE t2(x);\n  PRAGMA journal_mode = wal;\n  INSERT INTO t2 VALUES('abc');\n  INSERT INTO t2 VALUES('def');\n  INSERT INTO t2 VALUES('ghi');\n} {wal}\n\ndo_test 5.1 {\n  execsql { \n    SELECT * FROM t2;\n    BEGIN;\n  } db2\n  set snap [sqlite3_snapshot_get_blob db2 main]\n  db2 eval END\n} {}\n\ndo_test 5.2 {\n  execsql BEGIN db2\n  sqlite3_snapshot_open_blob db2 main $snap\n  db2 eval { SELECT * FROM t2 ; END }\n} {abc def ghi}\n\ndo_test 5.3 {\n  execsql { PRAGMA wal_checkpoint = RESTART }\n  execsql BEGIN db2\n  sqlite3_snapshot_open_blob db2 main $snap\n  db2 eval { SELECT * FROM t2 ; END }\n} {abc def ghi}\n\ndo_test 5.4 {\n  execsql { INSERT INTO t2 VALUES('jkl') } \n  execsql BEGIN db2\n  list [catch { sqlite3_snapshot_open_blob db2 main $snap } msg] $msg\n} {1 SQLITE_BUSY_SNAPSHOT}\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/snapshot_fault.test",
    "content": "# 2015 December 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this file is the sqlite3_snapshot_xxx() APIs.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !snapshot {finish_test; return}\nset testprefix snapshot_fault\n\n#-------------------------------------------------------------------------\n# Check that an sqlite3_snapshot_open() client cannot be tricked into\n# reading a corrupt snapshot even if a second client fails while \n# checkpointing the db.\n#\ndo_faultsim_test 1.0 -prep {\n  faultsim_delete_and_reopen\n  sqlite3 db2 test.db\n  db2 eval { \n    CREATE TABLE t1(a, b UNIQUE, c UNIQUE);\n    INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));\n    BEGIN;\n      SELECT a FROM t1;\n  }\n  set ::snapshot [sqlite3_snapshot_get db2 main] \n  db2 eval COMMIT\n  db2 eval {\n    UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;\n    INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));\n  }\n} -body {\n  db eval { PRAGMA wal_checkpoint }\n} -test {\n  db2 eval BEGIN\n  if {[catch { sqlite3_snapshot_open db2 main $::snapshot } msg]} {\n    if {$msg != \"SQLITE_BUSY_SNAPSHOT\" && $msg != \"SQLITE_BUSY\"} {\n      error \"error is $msg\" \n    }\n  } else {\n    set res [db2 eval { \n      SELECT a FROM t1;\n      PRAGMA integrity_check;\n    }]\n    if {$res != \"1 2 3 ok\"} { error \"res is $res\" }\n  }\n\n  sqlite3_snapshot_free $::snapshot\n}\n\n#-------------------------------------------------------------------------\n# This test is similar to the previous one. Except, after the \n# \"PRAGMA wal_checkpoint\" command fails the db is closed and reopened\n# so as to require wal file recovery. It should not be possible to open\n# a snapshot that is part of the body of a recovered wal file.\n#\ndo_faultsim_test 2.0 -prep {\n  faultsim_delete_and_reopen\n  db eval { \n    CREATE TABLE t1(a, b UNIQUE, c UNIQUE);\n    INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));\n    BEGIN;\n      SELECT a FROM t1;\n  }\n  set ::snapshot [sqlite3_snapshot_get db main] \n  db eval COMMIT\n\n  db eval {\n    UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;\n    INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));\n  }\n} -body {\n  db eval { PRAGMA wal_checkpoint }\n} -test {\n\n  db_save\n  db close\n  db_restore_and_reopen\n  db eval { SELECT * FROM t1 }\n  \n  db eval BEGIN\n  if {[catch { sqlite3_snapshot_open db main $::snapshot } msg]} {\n    if {$msg != \"SQLITE_BUSY_SNAPSHOT\" && $msg != \"SQLITE_BUSY\"} {\n      error \"error is $msg\" \n    }\n  } else {\n    # This branch should actually never be taken. But it was useful in\n    # determining whether or not this test was actually working (by \n    # running a modified version of SQLite that allowed snapshots to be\n    # opened following a recovery).\n    error \"TEST HAS FAILED\"\n\n    set res [db eval { \n      SELECT a FROM t1;\n      PRAGMA integrity_check;\n    }]\n    if {$res != \"1 2 3 ok\"} { error \"res is $res\" }\n  }\n\n  sqlite3_snapshot_free $::snapshot\n}\n\n#-------------------------------------------------------------------------\n# Test the handling of faults that occur within sqlite3_snapshot_open().\n#\ndo_faultsim_test 3.0 -prep {\n  faultsim_delete_and_reopen\n  db eval { \n    CREATE TABLE t1(a, b UNIQUE, c UNIQUE);\n    INSERT INTO t1 VALUES(1, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(2, randomblob(500), randomblob(500));\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(3, randomblob(500), randomblob(500));\n    BEGIN;\n      SELECT a FROM t1;\n  }\n  set ::snapshot [sqlite3_snapshot_get db main] \n  db eval COMMIT\n  db eval {\n    UPDATE t1 SET b=randomblob(501), c=randomblob(501) WHERE a=1;\n    INSERT INTO t1 VALUES(4, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(5, randomblob(500), randomblob(500));\n    INSERT INTO t1 VALUES(6, randomblob(500), randomblob(500));\n    BEGIN;\n  }\n} -body {\n  if { [catch { sqlite3_snapshot_open db main $::snapshot } msg] } {\n    error $msg\n  }\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_IOERR} {1 SQLITE_NOMEM} \\\n                              {1 SQLITE_IOERR_NOMEM} {1 SQLITE_IOERR_READ}\n  if {$testrc==0} {\n    set res [db eval { \n      SELECT a FROM t1;\n      PRAGMA integrity_check;\n    }]\n    if {$res != \"1 2 3 ok\"} { error \"res is $res\" }\n  }\n\n  sqlite3_snapshot_free $::snapshot\n}\n\n#-------------------------------------------------------------------------\n# Test the handling of faults that occur within sqlite3_snapshot_recover().\n#\nreset_db\ndo_execsql_test 4.0 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(zzz);\n  INSERT INTO t1 VALUES('abc');\n  INSERT INTO t1 VALUES('def');\n} {wal}\nfaultsim_save_and_close\n\ndo_test 4.0.1 {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM sqlite_master } \n  sqlite3_snapshot_recover db main\n} {}\ndb close\n\ndo_faultsim_test 4.0 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM sqlite_master } \n} -body {\n  sqlite3_snapshot_recover db main\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_NOMEM} {1 SQLITE_IOERR_NOMEM}\n}\n\n# The following test cases contrive to call sqlite3_snapshot_recover()\n# before all pages of the *-shm file have been mapped. This tests an\n# extra branch of error handling logic in snapshot_recover().\n#\nreset_db\ndo_execsql_test 4.1.0 {\n  PRAGMA page_size = 512;\n  PRAGMA journal_mode = wal;\n  PRAGMA wal_autocheckpoint = 0;\n  CREATE TABLE t1(zzz);\n  INSERT INTO t1 VALUES(randomblob( 500 * 9500 ));\n  PRAGMA user_version = 211;\n} {wal 0}\n\ndo_test 4.1.1 {\n  list [file size test.db-shm] [file size test.db]\n} {98304 512}\n\nfaultsim_save_and_close\ndo_faultsim_test 4.1 -faults shm* -prep {\n  catch { db2 close } \n  catch { db close } \n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db\n  db2 eval { SELECT * FROM sqlite_master } \n  db eval BEGIN\n  sqlite3_snapshot_get_blob db main\n  db eval COMMIT\n} -body {\n  sqlite3_snapshot_recover db main\n} -test {\n  faultsim_test_result {0 {}} {1 SQLITE_IOERR}\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/soak.test",
    "content": "# 2007 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file is the driver for the \"soak\" tests. It is a peer of the\n# quick.test and all.test scripts.\n#\n# $Id: soak.test,v 1.4 2008/11/13 18:29:51 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nrename finish_test really_finish_test\nproc finish_test {} {}\n\n# By default, guarantee that the tests will run for at least 1 hour.\n#\nset TIMEOUT 3600\n\n# Process command-line arguments. \n#\nif {[llength $argv]>0} {\n  foreach {name value} $argv {\n    switch -- $name {\n      -timeout {\n        set TIMEOUT $value\n      }\n      default {\n         puts stderr \"Unknown option: $name\"\n         exit\n      }\n    }\n  }\n}\nset argv [list]\n\n# Test plan:\n#\n# The general principle is to run those SQLite tests that use\n# pseudo-random data in some way over and over again for a very \n# long time. The number of tests run depends on the value of \n# global variable $TIMEOUT - tests are run for at least $TIMEOUT \n# seconds.\n#\n#   fuzz.test     (pseudo-random SQL statements)\n#   trans.test    (pseudo-random changes to a database followed by rollbacks)\n#   fuzz_malloc.test\n#   corruptC.test (pseudo-random corruption to a database)\n#\n# Many database changes maintaining some kind of invariant. \n# Storing checksums etc.\n#\n\n# List of test files that are run by this file.\n#\nset SOAKTESTS {\n  fuzz.test\n  fuzz_malloc.test\n  trans.test\n  corruptC.test\n}\n\nset G(isquick) 1\n\nset soak_starttime  [clock seconds]\nset soak_finishtime [expr {$soak_starttime + $TIMEOUT}]\n\n# Loop until the timeout is reached or an error occurs.\n#\nfor {set iRun 0} {[clock seconds] < $soak_finishtime} {incr iRun} {\n\n  set iIdx [expr {$iRun % [llength $SOAKTESTS]}]\n  source [file join $testdir [lindex $SOAKTESTS $iIdx]]\n  catch {db close}\n\n  if {$sqlite_open_file_count>0} {\n    puts \"$tail did not close all files: $sqlite_open_file_count\"\n    fail_test $tail\n    set sqlite_open_file_count 0\n  }\n\n  if {[set_test_counter errors]>0} break\n}\n\nreally_finish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/softheap1.test",
    "content": "# 2007 Aug 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This test script reproduces the problem reported by ticket #2565,\n# A database corruption bug that occurs in auto_vacuum mode when\n# the soft_heap_limit is set low enough to be triggered.\n#\n# $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !integrityck {\n  finish_test\n  return\n}\n\n# EVIDENCE-OF: R-26343-45930 This pragma invokes the\n# sqlite3_soft_heap_limit64() interface with the argument N, if N is\n# specified and is a non-negative integer.\n#\n# EVIDENCE-OF: R-64451-07163 The soft_heap_limit pragma always returns\n# the same integer that would be returned by the\n# sqlite3_soft_heap_limit64(-1) C-language function.\n#\ndo_test softheap1-1.0 {\n  execsql {PRAGMA soft_heap_limit}\n} [sqlite3_soft_heap_limit -1]\ndo_test softheap1-1.1 {\n  execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;}\n} {123456 123456}\ndo_test softheap1-1.2 {\n  sqlite3_soft_heap_limit -1\n} {123456}\ndo_test softheap1-1.3 {\n  execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;}\n} {123456 123456}\ndo_test softheap1-1.4 {\n  execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;}\n} {0 0}\n\nsqlite3_soft_heap_limit 5000\ndo_test softheap1-2.0 {\n  execsql {PRAGMA soft_heap_limit}\n} {5000}\ndo_test softheap1-2.1 {\n  execsql {\n    PRAGMA auto_vacuum=1;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(hex(randomblob(1000)));\n    BEGIN;\n  }\n  execsql {\n    CREATE TABLE t2 AS SELECT * FROM t1;\n  }\n  execsql {\n    ROLLBACK;\n  }\n  execsql {\n    PRAGMA integrity_check;\n  }\n} {ok}\n\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sort.test",
    "content": "# 2001 September 15.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sorter (code in vdbesort.c).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sort\ndb close\nsqlite3_shutdown\nsqlite3_config_pmasz 10\nsqlite3_initialize\nsqlite3 db test.db\n\n# Create a bunch of data to sort against\n#\ndo_test sort-1.0 {\n  execsql {\n    CREATE TABLE t1(\n       n int,\n       v varchar(10),\n       log int,\n       roman varchar(10),\n       flt real\n    );\n    INSERT INTO t1 VALUES(1,'one',0,'I',3.141592653);\n    INSERT INTO t1 VALUES(2,'two',1,'II',2.15);\n    INSERT INTO t1 VALUES(3,'three',1,'III',4221.0);\n    INSERT INTO t1 VALUES(4,'four',2,'IV',-0.0013442);\n    INSERT INTO t1 VALUES(5,'five',2,'V',-11);\n    INSERT INTO t1 VALUES(6,'six',2,'VI',0.123);\n    INSERT INTO t1 VALUES(7,'seven',2,'VII',123.0);\n    INSERT INTO t1 VALUES(8,'eight',3,'VIII',-1.6);\n  }\n  execsql {SELECT count(*) FROM t1}\n} {8}\n\ndo_test sort-1.1 {\n  execsql {SELECT n FROM t1 ORDER BY n}\n} {1 2 3 4 5 6 7 8}\ndo_test sort-1.1.1 {\n  execsql {SELECT n FROM t1 ORDER BY n ASC}\n} {1 2 3 4 5 6 7 8}\ndo_test sort-1.1.1 {\n  execsql {SELECT ALL n FROM t1 ORDER BY n ASC}\n} {1 2 3 4 5 6 7 8}\ndo_test sort-1.2 {\n  execsql {SELECT n FROM t1 ORDER BY n DESC}\n} {8 7 6 5 4 3 2 1}\ndo_test sort-1.3a {\n  execsql {SELECT v FROM t1 ORDER BY v}\n} {eight five four one seven six three two}\ndo_test sort-1.3b {\n  execsql {SELECT n FROM t1 ORDER BY v}\n} {8 5 4 1 7 6 3 2}\ndo_test sort-1.4 {\n  execsql {SELECT n FROM t1 ORDER BY v DESC}\n} {2 3 6 7 1 4 5 8}\ndo_test sort-1.5 {\n  execsql {SELECT flt FROM t1 ORDER BY flt}\n} {-11.0 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}\ndo_test sort-1.6 {\n  execsql {SELECT flt FROM t1 ORDER BY flt DESC}\n} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11.0}\ndo_test sort-1.7 {\n  execsql {SELECT roman FROM t1 ORDER BY roman}\n} {I II III IV V VI VII VIII}\ndo_test sort-1.8 {\n  execsql {SELECT n FROM t1 ORDER BY log, flt}\n} {1 2 3 5 4 6 7 8}\ndo_test sort-1.8.1 {\n  execsql {SELECT n FROM t1 ORDER BY log asc, flt}\n} {1 2 3 5 4 6 7 8}\ndo_test sort-1.8.2 {\n  execsql {SELECT n FROM t1 ORDER BY log, flt ASC}\n} {1 2 3 5 4 6 7 8}\ndo_test sort-1.8.3 {\n  execsql {SELECT n FROM t1 ORDER BY log ASC, flt asc}\n} {1 2 3 5 4 6 7 8}\ndo_test sort-1.9 {\n  execsql {SELECT n FROM t1 ORDER BY log, flt DESC}\n} {1 3 2 7 6 4 5 8}\ndo_test sort-1.9.1 {\n  execsql {SELECT n FROM t1 ORDER BY log ASC, flt DESC}\n} {1 3 2 7 6 4 5 8}\ndo_test sort-1.10 {\n  execsql {SELECT n FROM t1 ORDER BY log DESC, flt}\n} {8 5 4 6 7 2 3 1}\ndo_test sort-1.11 {\n  execsql {SELECT n FROM t1 ORDER BY log DESC, flt DESC}\n} {8 7 6 4 5 3 2 1}\n\n# These tests are designed to reach some hard-to-reach places\n# inside the string comparison routines.\n#\n# (Later) The sorting behavior changed in 2.7.0.  But we will\n# keep these tests.  You can never have too many test cases!\n#\ndo_test sort-2.1.1 {\n  execsql {\n    UPDATE t1 SET v='x' || -flt;\n    UPDATE t1 SET v='x-2b' where v=='x-0.123';\n    SELECT v FROM t1 ORDER BY v;\n  }\n} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11.0}\ndo_test sort-2.1.2 {\n  execsql {\n    SELECT v FROM t1 ORDER BY substr(v,2,999);\n  }\n} {x-123.0 x-2.15 x-2b x-3.141592653 x-4221.0 x0.0013442 x1.6 x11.0}\ndo_test sort-2.1.3 {\n  execsql {\n    SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;\n  }\n} {x-4221.0 x-123.0 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11.0}\ndo_test sort-2.1.4 {\n  execsql {\n    SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;\n  }\n} {x11.0 x1.6 x0.0013442 x-4221.0 x-3.141592653 x-2b x-2.15 x-123.0}\ndo_test sort-2.1.5 {\n  execsql {\n    SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;\n  }\n} {x11.0 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123.0 x-4221.0}\n\n# This is a bug fix for 2.2.4.\n# Strings are normally mapped to upper-case for a caseless comparison.\n# But this can cause problems for characters in between 'Z' and 'a'.\n#\ndo_test sort-3.1 {\n  execsql {\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 VALUES('AGLIENTU',1);\n    INSERT INTO t2 VALUES('AGLIE`',2);\n    INSERT INTO t2 VALUES('AGNA',3);\n    SELECT a, b FROM t2 ORDER BY a;\n  }\n} {AGLIENTU 1 AGLIE` 2 AGNA 3}\ndo_test sort-3.2 {\n  execsql {\n    SELECT a, b FROM t2 ORDER BY a DESC;\n  }\n} {AGNA 3 AGLIE` 2 AGLIENTU 1}\ndo_test sort-3.3 {\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES('aglientu',1);\n    INSERT INTO t2 VALUES('aglie`',2);\n    INSERT INTO t2 VALUES('agna',3);\n    SELECT a, b FROM t2 ORDER BY a;\n  }\n} {aglie` 2 aglientu 1 agna 3}\ndo_test sort-3.4 {\n  execsql {\n    SELECT a, b FROM t2 ORDER BY a DESC;\n  }\n} {agna 3 aglientu 1 aglie` 2}\n\n# Version 2.7.0 testing.\n#\ndo_test sort-4.1 {\n  execsql {\n    INSERT INTO t1 VALUES(9,'x2.7',3,'IX',4.0e5);\n    INSERT INTO t1 VALUES(10,'x5.0e10',3,'X',-4.0e5);\n    INSERT INTO t1 VALUES(11,'x-4.0e9',3,'XI',4.1e4);\n    INSERT INTO t1 VALUES(12,'x01234567890123456789',3,'XII',-4.2e3);\n    SELECT n FROM t1 ORDER BY n;\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test sort-4.2 {\n  execsql {\n    SELECT n||'' FROM t1 ORDER BY 1;\n  }\n} {1 10 11 12 2 3 4 5 6 7 8 9}\ndo_test sort-4.3 {\n  execsql {\n    SELECT n+0 FROM t1 ORDER BY 1;\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test sort-4.4 {\n  execsql {\n    SELECT n||'' FROM t1 ORDER BY 1 DESC;\n  }\n} {9 8 7 6 5 4 3 2 12 11 10 1}\ndo_test sort-4.5 {\n  execsql {\n    SELECT n+0 FROM t1 ORDER BY 1 DESC;\n  }\n} {12 11 10 9 8 7 6 5 4 3 2 1}\ndo_test sort-4.6 {\n  execsql {\n    SELECT v FROM t1 ORDER BY 1;\n  }\n} {x-123.0 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221.0 x0.0013442 x01234567890123456789 x1.6 x11.0 x2.7 x5.0e10}\ndo_test sort-4.7 {\n  execsql {\n    SELECT v FROM t1 ORDER BY 1 DESC;\n  }\n} {x5.0e10 x2.7 x11.0 x1.6 x01234567890123456789 x0.0013442 x-4221.0 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123.0}\ndo_test sort-4.8 {\n  execsql {\n    SELECT substr(v,2,99) FROM t1 ORDER BY 1;\n  }\n} {-123.0 -2.15 -2b -3.141592653 -4.0e9 -4221.0 0.0013442 01234567890123456789 1.6 11.0 2.7 5.0e10}\n#do_test sort-4.9 {\n#  execsql {\n#    SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;\n#  }\n#} {-4000000000 -4221 -123 -3.141592653 -2.15 -2 0.0013442 1.6 2.7 11 50000000000 1.23456789012346e+18}\n\ndo_test sort-5.1 {\n  execsql {\n    create table t3(a,b);\n    insert into t3 values(5,NULL);\n    insert into t3 values(6,NULL);\n    insert into t3 values(3,NULL);\n    insert into t3 values(4,'cd');\n    insert into t3 values(1,'ab');\n    insert into t3 values(2,NULL);\n    select a from t3 order by b, a;\n  }\n} {2 3 5 6 1 4}\ndo_test sort-5.2 {\n  execsql {\n    select a from t3 order by b, a desc;\n  }\n} {6 5 3 2 1 4}\ndo_test sort-5.3 {\n  execsql {\n    select a from t3 order by b desc, a;\n  }\n} {4 1 2 3 5 6}\ndo_test sort-5.4 {\n  execsql {\n    select a from t3 order by b desc, a desc;\n  }\n} {4 1 6 5 3 2}\n\ndo_test sort-6.1 {\n  execsql {\n    create index i3 on t3(b,a);\n    select a from t3 order by b, a;\n  }\n} {2 3 5 6 1 4}\ndo_test sort-6.2 {\n  execsql {\n    select a from t3 order by b, a desc;\n  }\n} {6 5 3 2 1 4}\ndo_test sort-6.3 {\n  execsql {\n    select a from t3 order by b desc, a;\n  }\n} {4 1 2 3 5 6}\ndo_test sort-6.4 {\n  execsql {\n    select a from t3 order by b desc, a desc;\n  }\n} {4 1 6 5 3 2}\n\ndo_test sort-7.1 {\n  execsql {\n    CREATE TABLE t4(\n      a INTEGER,\n      b VARCHAR(30)\n    );\n    INSERT INTO t4 VALUES(1,1);\n    INSERT INTO t4 VALUES(2,2);\n    INSERT INTO t4 VALUES(11,11);\n    INSERT INTO t4 VALUES(12,12);\n    SELECT a FROM t4 ORDER BY 1;\n  }\n} {1 2 11 12}\ndo_test sort-7.2 {\n  execsql {\n    SELECT b FROM t4 ORDER BY 1\n  }\n} {1 11 12 2}\n\n# Omit tests sort-7.3 to sort-7.8 if view support was disabled at\n# compilatation time.\nifcapable view {\ndo_test sort-7.3 {\n  execsql {\n    CREATE VIEW v4 AS SELECT * FROM t4;\n    SELECT a FROM v4 ORDER BY 1;\n  }\n} {1 2 11 12}\ndo_test sort-7.4 {\n  execsql {\n    SELECT b FROM v4 ORDER BY 1;\n  }\n} {1 11 12 2}\n\nifcapable compound {\ndo_test sort-7.5 {\n  execsql {\n    SELECT a FROM t4 UNION SELECT a FROM v4 ORDER BY 1;\n  }\n} {1 2 11 12}\ndo_test sort-7.6 {\n  execsql {\n    SELECT b FROM t4 UNION SELECT a FROM v4 ORDER BY 1;\n  }\n} {1 2 11 12 1 11 12 2}  ;# text from t4.b and numeric from v4.a\ndo_test sort-7.7 {\n  execsql {\n    SELECT a FROM t4 UNION SELECT b FROM v4 ORDER BY 1;\n  }\n} {1 2 11 12 1 11 12 2} ;# numeric from t4.a and text from v4.b\ndo_test sort-7.8 {\n  execsql {\n    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1;\n  }\n} {1 11 12 2}\n} ;# ifcapable compound\n} ;# ifcapable view\n\n#### Version 3 works differently here:\n#do_test sort-7.9 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE numeric;\n#  }\n#} {1 2 11 12}\n#do_test sort-7.10 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE integer;\n#  }\n#} {1 2 11 12}\n#do_test sort-7.11 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE text;\n#  }\n#} {1 11 12 2}\n#do_test sort-7.12 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE blob;\n#  }\n#} {1 11 12 2}\n#do_test sort-7.13 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE clob;\n#  }\n#} {1 11 12 2}\n#do_test sort-7.14 {\n#  execsql {\n#    SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE varchar;\n#  }\n#} {1 11 12 2}\n\n# Ticket #297\n#\ndo_test sort-8.1 {\n  execsql {\n    CREATE TABLE t5(a real, b text);\n    INSERT INTO t5 VALUES(100,'A1');\n    INSERT INTO t5 VALUES(100.0,'A2');\n    SELECT * FROM t5 ORDER BY a, b;\n  }\n} {100.0 A1 100.0 A2}\n\n\nifcapable {bloblit} {\n# BLOBs should sort after TEXT\n#\ndo_test sort-9.1 {\n  execsql {\n    CREATE TABLE t6(x, y);\n    INSERT INTO t6 VALUES(1,1);\n    INSERT INTO t6 VALUES(2,'1');\n    INSERT INTO t6 VALUES(3,x'31');\n    INSERT INTO t6 VALUES(4,NULL);\n    SELECT x FROM t6 ORDER BY y;\n  }\n} {4 1 2 3}\ndo_test sort-9.2 {\n  execsql {\n    SELECT x FROM t6 ORDER BY y DESC;\n  }\n} {3 2 1 4}\ndo_test sort-9.3 {\n  execsql {\n    SELECT x FROM t6 WHERE y<1\n  }\n} {}\ndo_test sort-9.4 {\n  execsql {\n    SELECT x FROM t6 WHERE y<'1'\n  }\n} {1}\ndo_test sort-9.5 {\n  execsql {\n    SELECT x FROM t6 WHERE y<x'31'\n  }\n} {1 2}\ndo_test sort-9.6 {\n  execsql {\n    SELECT x FROM t6 WHERE y>1\n  }\n} {2 3}\ndo_test sort-9.7 {\n  execsql {\n    SELECT x FROM t6 WHERE y>'1'\n  }\n} {3}\n} ;# endif bloblit\n\n# Ticket #1092 - ORDER BY on rowid fields.\ndo_test sort-10.1 {\n  execsql {\n    CREATE TABLE t7(c INTEGER PRIMARY KEY);\n    INSERT INTO t7 VALUES(1);\n    INSERT INTO t7 VALUES(2);\n    INSERT INTO t7 VALUES(3);\n    INSERT INTO t7 VALUES(4);\n  }\n} {}\ndo_test sort-10.2 {\n  execsql {\n    SELECT c FROM t7 WHERE c<=3 ORDER BY c DESC;\n  }\n} {3 2 1}\ndo_test sort-10.3 {\n  execsql {\n    SELECT c FROM t7 WHERE c<3 ORDER BY c DESC;\n  }\n} {2 1}\n\n# ticket #1358.  Just because one table in a join gives a unique\n# result does not mean they all do.  We cannot disable sorting unless\n# all tables in the join give unique results.\n#\ndo_test sort-11.1 {\n  execsql {\n    create table t8(a unique, b, c);\n    insert into t8 values(1,2,3);\n    insert into t8 values(2,3,4);\n    create table t9(x,y);\n    insert into t9 values(2,4);\n    insert into t9 values(2,3);\n    select y from t8, t9 where a=1 order by a, y;\n  }\n} {3 4}\n\n# Trouble reported on the mailing list.  Check for overly aggressive\n# (which is to say, incorrect) optimization of order-by with a rowid\n# in a join.\n#\ndo_test sort-12.1 {\n  execsql {\n    create table a (id integer primary key);\n    create table b (id integer primary key, aId integer, text);\n    insert into a values (1);\n    insert into b values (2, 1, 'xxx');\n    insert into b values (1, 1, 'zzz');\n    insert into b values (3, 1, 'yyy');\n    select a.id, b.id, b.text from a join b on (a.id = b.aId)\n      order by a.id, b.text;\n  }\n} {1 2 xxx 1 3 yyy 1 1 zzz}\n\n#-------------------------------------------------------------------------\n# Check that the sorter in vdbesort.c sorts in a stable fashion.\n#\ndo_execsql_test sort-13.0 {\n  CREATE TABLE t10(a, b);\n}\ndo_test sort-13.1 {\n  db transaction {\n    for {set i 0} {$i < 100000} {incr i} {\n      execsql { INSERT INTO t10 VALUES( $i/10, $i%10 ) }\n    }\n  }\n} {}\ndo_execsql_test sort-13.2 {\n  SELECT a, b FROM t10 ORDER BY a;\n} [db eval {SELECT a, b FROM t10 ORDER BY a, b}]\ndo_execsql_test sort-13.3 {\n  PRAGMA cache_size = 5;\n  SELECT a, b FROM t10 ORDER BY a;\n} [db eval {SELECT a, b FROM t10 ORDER BY a, b}]\n\n#-------------------------------------------------------------------------\n#\nforeach {tn mmap_limit nWorker tmpstore coremutex fakeheap softheaplimit} {\n          1          0       3     file      true    false             0\n          2          0       3     file      true     true             0\n          3          0       0     file      true    false             0\n          4    1000000       3     file      true    false             0\n          5          0       0   memory     false     true             0\n          6          0       0     file     false     true       1000000     \n          7          0       0     file     false     true         10000\n} {\n  db close\n  sqlite3_shutdown\n  if {$coremutex} {\n    sqlite3_config multithread\n  } else {\n    sqlite3_config singlethread\n  }\n  sqlite3_initialize\n  sorter_test_fakeheap $fakeheap\n  sqlite3_soft_heap_limit $softheaplimit\n\n  reset_db\n  sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit\n  execsql \"PRAGMA temp_store = $tmpstore; PRAGMA threads = $nWorker\"\n  \n  \n  set ten [string repeat X 10300]\n  set one [string repeat y   200]\n\n  if {$softheaplimit} {\n    execsql { PRAGMA cache_size = 20 };\n  } else {\n    execsql { PRAGMA cache_size = 5 };\n  }\n\n  do_execsql_test 15.$tn.1 {\n    WITH rr AS (\n      SELECT 4, $ten UNION ALL\n      SELECT 2, $one UNION ALL\n      SELECT 1, $ten UNION ALL\n      SELECT 3, $one\n    )\n    SELECT * FROM rr ORDER BY 1;\n  } [list 1 $ten 2 $one 3 $one 4 $ten]\n\n  do_execsql_test 15.$tn.2 {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(4);\n    INSERT INTO t1 VALUES(5);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(6);\n    INSERT INTO t1 VALUES(1);\n    CREATE INDEX i1 ON t1(a);\n    SELECT * FROM t1 ORDER BY a;\n  } {1 2 3 4 5 6}\n\n  do_execsql_test 15.$tn.3 {\n    WITH rr AS (\n      SELECT 4, $ten UNION ALL\n      SELECT 2, $one\n    )\n    SELECT * FROM rr ORDER BY 1;\n  } [list 2 $one 4 $ten]\n\n  sorter_test_fakeheap 0\n}\n\ndb close\nsqlite3_shutdown\nset t(0) singlethread\nset t(1) multithread\nset t(2) serialized\nsqlite3_config $t($sqlite_options(threadsafe))\nsqlite3_initialize\nsqlite3_soft_heap_limit 0\n\nreset_db\ndo_catchsql_test 16.1 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(1, NULL, 3);\n  INSERT INTO t1 VALUES(NULL, 2, 3);\n  INSERT INTO t1 VALUES(1, 2, NULL);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  CREATE UNIQUE INDEX i1 ON t1(b, a, c);\n} {0 {}}\nreset_db\ndo_catchsql_test 16.2 {\n  CREATE TABLE t1(a, b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(1, NULL, 3);\n  INSERT INTO t1 VALUES(1, 2, 3);\n  INSERT INTO t1 VALUES(1, 2, NULL);\n  INSERT INTO t1 VALUES(4, 5, 6);\n  CREATE UNIQUE INDEX i1 ON t1(b, a, c);\n} {1 {UNIQUE constraint failed: t1.b, t1.a, t1.c}}\n\nreset_db\ndo_execsql_test 17.1 {\n  SELECT * FROM sqlite_master ORDER BY sql;\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sort2.test",
    "content": "# 2014 March 25.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# Specifically, the tests in this file attempt to verify that \n# multi-threaded sorting works.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sort2\ndb close\nsqlite3_shutdown\nsqlite3_config_pmasz 10\nsqlite3_initialize\nsqlite3 db test.db\n\nforeach {tn script} {\n  1 { }\n  2 {\n    catch { db close }\n    reset_db\n    catch { db eval {PRAGMA threads=7} }\n  }\n} {\n  eval $script\n\n  do_execsql_test $tn.1 {\n    PRAGMA cache_size = 5;\n    WITH r(x,y) AS (\n      SELECT 1, randomblob(100)\n      UNION ALL\n      SELECT x+1, randomblob(100) FROM r\n      LIMIT 100000\n    )\n    SELECT count(x), length(y) FROM r GROUP BY (x%5)\n  } {\n    20000 100 20000 100 20000 100 20000 100 20000 100\n  }\n\n  do_execsql_test $tn.2.1 {\n    CREATE TABLE t1(a, b);\n    WITH r(x,y) AS (\n      SELECT 1, randomblob(100)\n      UNION ALL\n      SELECT x+1, randomblob(100) FROM r\n      LIMIT 10000\n    ) INSERT INTO t1 SELECT * FROM r;\n  }\n  \n  do_execsql_test $tn.2.2 {\n    CREATE UNIQUE INDEX i1 ON t1(b, a);\n  }\n  \n  do_execsql_test $tn.2.3 {\n    CREATE UNIQUE INDEX i2 ON t1(a);\n  }\n  \n  do_execsql_test $tn.2.4 { PRAGMA integrity_check } {ok}\n  \n  # Because it uses so much data, this test can take 12-13 seconds even on\n  # a modern workstation. So it is omitted from \"veryquick\" and other\n  # permutations.test tests.\n  if {[isquick]==0} {\n    do_execsql_test $tn.3 {\n      PRAGMA cache_size = 5;\n      WITH r(x,y) AS (\n          SELECT 1, randomblob(100)\n          UNION ALL\n          SELECT x+1, randomblob(100) FROM r\n          LIMIT 1000000\n          )\n        SELECT count(x), length(y) FROM r GROUP BY (x%5)\n    } {\n      200000 100 200000 100 200000 100 200000 100 200000 100\n    }\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sort3.test",
    "content": "# 2014 March 25.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The tests in this file verify that sorting works when the library is\n# configured to use mmap(), but the temporary files generated by the\n# sorter are too large to be completely mapped.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sort3\n\n#-------------------------------------------------------------------------\n# Sort some large ( > 4KiB) records.\n#\nproc cksum {x} {\n  set i1 1\n  set i2 2\n  binary scan $x c* L\n  foreach {a b} $L {\n    set i1 [expr (($i2<<3) + $a) & 0x7FFFFFFF]\n    set i2 [expr (($i1<<3) + $b) & 0x7FFFFFFF]\n  }\n  list $i1 $i2\n}\ndb func cksum cksum\n\ndo_execsql_test 1.0 {\n  PRAGMA cache_size = 5;\n  CREATE TABLE t11(a, b);\n  INSERT INTO t11 VALUES(randomblob(5000), NULL);\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --2\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --3\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --4\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --5\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --6\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --7\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --8\n  INSERT INTO t11 SELECT randomblob(5000), NULL FROM t11; --9\n  UPDATE t11 SET b = cksum(a);\n}\n\nforeach {tn mmap_limit} {\n  1 0\n  2 1000000\n} {\n  do_test 1.$tn {\n    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit\n    set prev \"\"\n    db eval { SELECT * FROM t11 ORDER BY b } {\n      if {$b != [cksum $a]} {error \"checksum failed\"}\n      if {[string compare $b $prev] < 0} {error \"sort failed\"}\n      set prev $b\n    }\n    set {} {}\n  } {}\n}\n\n\n# Sort roughly 20MB of data. Once with a mmap limit of 5MB and once without.\n#\nforeach {itest limit} {\n  1 5000000\n  2 0x7FFFFFFF\n} {\n  sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $limit\n  do_execsql_test 2.$itest {\n    WITH r(x,y) AS (\n        SELECT 1, randomblob(1000)\n        UNION ALL\n        SELECT x+1, randomblob(1000) FROM r\n        LIMIT 20000\n    )\n    SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);\n  } {\n    4000 4000000 \n    4000 4000000 \n    4000 4000000 \n    4000 4000000 \n    4000 4000000\n  }\n}\n\n# Sort more than 2GB of data. At one point this was causing a problem.\n# This test might take one minute or more to run.\n#\ndo_execsql_test 3 {\n  PRAGMA cache_size = 20000;\n  WITH r(x,y) AS (\n    SELECT 1, randomblob(1000)\n    UNION ALL\n    SELECT x+1, randomblob(1000) FROM r\n    LIMIT 2200000\n  )\n  SELECT count(*), sum(length(y)) FROM r GROUP BY (x%5);\n} {\n  440000 440000000 \n  440000 440000000 \n  440000 440000000 \n  440000 440000000 \n  440000 440000000\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sort4.test",
    "content": "# 2014 May 6.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# The tests in this file are brute force tests of the multi-threaded\n# sorter.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sort4\ndb close\nsqlite3_shutdown\nsqlite3_config_pmasz 10\nsqlite3_initialize\nsqlite3 db test.db\n\n\n# Configure the sorter to use 3 background threads.\n#\n# EVIDENCE-OF: R-19249-32353 SQLITE_LIMIT_WORKER_THREADS The maximum\n# number of auxiliary worker threads that a single prepared statement\n# may start.\n#\ndo_test sort4-init001 {\n  db eval {PRAGMA threads=5}\n  sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS -1\n} {5}\ndo_test sort4-init002 {\n  sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS 3\n  db eval {PRAGMA threads}\n} {3}\n\n\n# Minimum number of seconds to run for. If the value is 0, each test\n# is run exactly once. Otherwise, tests are repeated until the timeout\n# expires.\nset SORT4TIMEOUT 0\nif {[permutation] == \"multithread\"} { set SORT4TIMEOUT 300 }\n\n#--------------------------------------------------------------------\n# Set up a table \"t1\" containing $nRow rows. Each row contains also\n# contains blob fields that collectively contain at least $nPayload \n# bytes of content. The table schema is as follows:\n#\n#   CREATE TABLE t1(a INTEGER, <extra-columns>, b INTEGER);\n#\n# For each row, the values of columns \"a\" and \"b\" are set to the same\n# pseudo-randomly selected integer. The \"extra-columns\", of which there\n# are at most eight, are named c0, c1, c2 etc. Column c0 contains a 4\n# byte string. Column c1 an 8 byte string. Field c2 16 bytes, and so on.\n#\n# This table is intended to be used for testing queries of the form: \n#\n#   SELECT a, <cols>, b FROM t1 ORDER BY a;\n#\n# The test code checks that rows are returned in order, and that the \n# values of \"a\" and \"b\" are the same for each row (the idea being that\n# if field \"b\" at the end of the sorter record has not been corrupted, \n# the rest of the record is probably Ok as well).\n#\nproc populate_table {nRow nPayload} {\n  set nCol 0\n\n  set n 0\n  for {set nCol 0} {$n < $nPayload} {incr nCol} {\n    incr n [expr (4 << $nCol)]\n  }\n\n  set cols [lrange [list xxx c0 c1 c2 c3 c4 c5 c6 c7] 1 $nCol]\n  set data [lrange [list xxx \\\n      randomblob(4) randomblob(8) randomblob(16) randomblob(32) \\\n      randomblob(64) randomblob(128) randomblob(256) randomblob(512) \\\n  ] 1 $nCol]\n\n  execsql { DROP TABLE IF EXISTS t1 }\n\n  db transaction {\n    execsql \"CREATE TABLE t1(a, [join $cols ,], b);\"\n    set insert \"INSERT INTO t1 VALUES(:k, [join $data ,], :k)\"\n    for {set i 0} {$i < $nRow} {incr i} {\n      set k [expr int(rand()*1000000000)]\n      execsql $insert\n    }\n  }\n}\n\n# Helper for [do_sorter_test]\n#\nproc sorter_test {nRow nRead nPayload} {\n  set res [list]\n\n  set nLoad [expr ($nRow > $nRead) ? $nRead : $nRow]\n\n  set nPayload [expr (($nPayload+3)/4) * 4]\n  set cols [list]\n  foreach {mask col} { \n    0x04  c0 0x08  c1 0x10  c2 0x20  c3 \n    0x40  c4 0x80  c5 0x100 c6 0x200 c7 \n  } {\n    if {$nPayload & $mask} { lappend cols $col }\n  }\n\n  # Create two SELECT statements. Statement $sql1 uses the sorter to sort\n  # $nRow records of a bit over $nPayload bytes each read from the \"t1\"\n  # table created by [populate_table] proc above. Rows are sorted in order\n  # of the integer field in each \"t1\" record.\n  #\n  # The second SQL statement sorts the same set of rows as the first, but\n  # uses a LIMIT clause, causing SQLite to use a temp table instead of the\n  # sorter for sorting.\n  #\n  set sql1 \"SELECT a, [join $cols ,], b FROM t1 WHERE rowid<=$nRow ORDER BY a\"\n  set sql2 \"SELECT a FROM t1 WHERE rowid<=$nRow ORDER BY a LIMIT $nRead\"\n\n  # Pass the two SQL statements to a helper command written in C. This\n  # command steps statement $sql1 $nRead times and compares the integer\n  # values in the rows returned with the results of executing $sql2. If\n  # the comparison fails (indicating some bug in the sorter), a Tcl\n  # exception is thrown.\n  #\n  sorter_test_sort4_helper db $sql1 $nRead $sql2\n  set {} {} \n}\n\n# Usage:\n#\n#   do_sorter_test <testname> <args>...\n#\n# where <args> are any of the following switches:\n#\n#   -rows N          (number of rows to have sorter sort)\n#   -read N          (number of rows to read out of sorter)\n#   -payload N       (bytes of payload to read with each row)\n#   -cachesize N     (Value for \"PRAGMA cache_size = ?\")\n#   -repeats N       (number of times to repeat test)\n#   -fakeheap BOOL   (true to use separate allocations for in-memory records)\n#\nproc do_sorter_test {tn args} {\n  set a(-rows)      1000\n  set a(-repeats)   1\n  set a(-read)      100\n  set a(-payload)   100\n  set a(-cachesize) 100\n  set a(-fakeheap)  0\n\n  foreach {s val} $args {\n    if {[info exists a($s)]==0} { \n      unset a(-cachesize)\n      set optlist \"[join [array names a] ,] or -cachesize\"\n      error \"Unknown option $s, expected $optlist\"\n    }\n    set a($s) $val\n  }\n  if {[permutation] == \"memsys3\" || [permutation] == \"memsys5\"} {\n    set a(-fakeheap) 0\n  }\n  if {$a(-fakeheap)} { sorter_test_fakeheap 1 }\n\n\n  db eval \"PRAGMA cache_size = $a(-cachesize)\"\n  do_test $tn [subst -nocommands {\n    for {set i 0} {[set i] < $a(-repeats)} {incr i} {\n      sorter_test $a(-rows) $a(-read) $a(-payload)\n    }\n  }] {}\n\n  if {$a(-fakeheap)} { sorter_test_fakeheap 0 }\n}\n\nproc clock_seconds {} {\n  db one {SELECT strftime('%s')}\n}\n\n#-------------------------------------------------------------------------\n# Begin tests here.\n\n# Create a test database.\ndo_test 1 {\n  execsql \"PRAGMA page_size = 4096\"\n  populate_table 100000 500\n} {}\n\nset iTimeLimit [expr [clock_seconds] + $SORT4TIMEOUT]\n\nfor {set t 2} {1} {incr tn} {\n  do_sorter_test $t.2 -repeats 10 -rows 1000   -read 100\n  do_sorter_test $t.3 -repeats 10 -rows 100000 -read 1000\n  do_sorter_test $t.4 -repeats 10 -rows 100000 -read 1000 -payload 500\n  do_sorter_test $t.5 -repeats 10 -rows 100000 -read 100000 -payload 8\n  do_sorter_test $t.6 -repeats 10 -rows 100000 -read 10 -payload 8\n  do_sorter_test $t.7 -repeats 10 -rows 10000 -read 10000 -payload 8 -fakeheap 1\n  do_sorter_test $t.8 -repeats 10 -rows 100000 -read 10000 -cachesize 250\n\n  set iNow [clock_seconds]\n  if {$iNow>=$iTimeLimit} break\n  do_test \"$testprefix-([expr $iTimeLimit-$iNow] seconds remain)\" {} {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sort5.test",
    "content": "# 2014 September 15.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sort5\n\n\n#-------------------------------------------------------------------------\n# Verify that sorting works with a version 1 sqlite3_io_methods structure.\n#\ntestvfs tvfs -iversion 1 -default true\nreset_db\ndo_execsql_test 1.0 {\n  PRAGMA mmap_size = 10000000;\n  PRAGMA cache_size = 10;\n  CREATE TABLE t1(a, b);\n} {0}\n\ndo_test 1.1 {\n  execsql BEGIN\n  for {set i 0} {$i < 2000} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, randomblob(2000)) }\n  }\n  execsql COMMIT\n} {}\n\ndo_execsql_test 1.2 {\n  CREATE INDEX i1 ON t1(b);\n}\n\ndb close\ntvfs delete\n\n#-------------------------------------------------------------------------\n# Test that the PMA size is determined correctly. The PMA size should be\n# roughly the same amount of memory allocated to the main pager cache, or\n# 250 pages if this is larger.\n#\ntestvfs tvfs\ntvfs script tv_callback\ntvfs filter {xOpen xWrite}\n\nproc tv_callback {method args} {\n  global iTemp\n  global F\n  switch $method {\n    xOpen {\n      if {[lindex $args 0]==\"\"} { return \"temp[incr iTemp]\" }\n      return \"SQLITE_OK\"\n    }\n\n    xWrite {\n      foreach {filename id off amt} $args {}\n      if {[info exists F($id)]==0 || $F($id)<($off + $amt)} {\n        set F($id) [expr $off+$amt]\n      }\n    }\n  }\n}\n\ncatch { db close }\nforcedelete test.db\nsqlite3 db test.db -vfs tvfs\nexecsql { CREATE TABLE t1(x) }\n\n# Each iteration of the following loop attempts to sort 10001 records\n# each a bit over 100 bytes in size. In total a little more than 1MiB \n# of data.\n#\nforeach {tn pgsz cachesz bTemp} {\n  1 4096   1000  0\n  2 1024   1000  1\n\n  3 4096  -1000  1\n  4 1024  -1000  1\n\n  5 4096  -9000  0\n  6 1024  -9000  0\n} {\n  do_execsql_test 2.$tn.0 \"\n    PRAGMA page_size = $pgsz;\n    VACUUM;\n    PRAGMA cache_size = $cachesz;\n  \"\n\n  if {[db one {PRAGMA page_size}]!=$pgsz} {\n    # SEE is not able to change page sizes and that messes up the\n    # results that follow.\n    continue\n  }\n\n  do_test 2.$tn.1 {\n    set ::iTemp 0\n    catch { array unset F }\n    execsql {\n      WITH x(i, j) AS (\n        SELECT 1, randomblob(100)\n        UNION ALL\n        SELECT i+1, randomblob(100) FROM x WHERE i<10000\n      )\n      SELECT * FROM x ORDER BY j;\n    }\n    expr {[array names F]!=\"\"}\n  } $bTemp\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sortfault.test",
    "content": "# 2014 March 25.\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# Specifically, it tests the effects of fault injection on the sorter\n# module (code in vdbesort.c).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sortfault\ndb close\nsqlite3_shutdown\nsqlite3_config_pmasz 10\nsqlite3_initialize\nsqlite3 db test.db\n\n\ndo_execsql_test 1.0 {\n  PRAGMA cache_size = 5;\n}\n\nforeach {tn mmap_limit nWorker tmpstore threadsmode fakeheap lookaside} {\n          1          0       0     file multithread    false     false\n          2     100000       0     file multithread    false     false\n          3     100000       1     file multithread    false     false\n          4    2000000       0     file singlethread   false      true\n} {\n  if {$sqlite_options(threadsafe)} { set threadsmode singlethread }\n\n  db eval \"PRAGMA threads=$nWorker\"\n  sqlite3_config $threadsmode\n  if { $lookaside } {\n    sqlite3_config_lookaside 100 500\n  } else {\n    sqlite3_config_lookaside 0 0\n  }\n  sqlite3_initialize\n  sorter_test_fakeheap $fakeheap\n\n  set str [string repeat a 1000]\n  puts $threadsmode\n\n  do_faultsim_test 1.$tn -prep {\n    sqlite3 db test.db\n    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit\n    execsql { PRAGMA cache_size = 5 }\n  } -body {\n    execsql { \n      WITH r(x,y) AS (\n          SELECT 1, $::str\n          UNION ALL\n          SELECT x+1, $::str FROM r\n          LIMIT 200\n      )\n      SELECT count(x), length(y) FROM r GROUP BY (x%5)\n    }\n  } -test {\n    faultsim_test_result {0 {40 1000 40 1000 40 1000 40 1000 40 1000}}\n  }\n\n  do_faultsim_test 2.$tn -faults oom* -prep {\n    sqlite3 db test.db\n    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit\n    add_test_utf16bin_collate db\n    execsql { PRAGMA cache_size = 5 }\n  } -body {\n    execsql { \n      WITH r(x,y) AS (\n          SELECT 100, $::str\n          UNION ALL\n          SELECT x-1, $::str FROM r\n          LIMIT 100\n      )\n      SELECT count(x), length(y) FROM r GROUP BY y COLLATE utf16bin, (x%5)\n    }\n  } -test {\n    faultsim_test_result {0 {20 1000 20 1000 20 1000 20 1000 20 1000}}\n  }\n\n  if {$mmap_limit > 1000000} {\n    set str2 [string repeat $str 10]\n\n    sqlite3_memdebug_vfs_oom_test 0\n    sqlite3 db test.db\n    sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit\n    execsql { PRAGMA cache_size = 5 }\n\n    do_faultsim_test 3.$tn -faults oom-trans* -body {\n      execsql { \n        WITH r(x,y) AS (\n            SELECT 300, $::str2\n            UNION ALL\n            SELECT x-1, $::str2 FROM r\n            LIMIT 300\n        )\n        SELECT count(x), length(y) FROM r GROUP BY y, (x%5)\n      }\n    } -test {\n      faultsim_test_result {0 {60 10000 60 10000 60 10000 60 10000 60 10000}}\n    }\n\n    sqlite3_memdebug_vfs_oom_test 1\n  }\n}\n\ncatch { db close }\nsqlite3_shutdown\nset t(0) singlethread\nset t(1) multithread\nset t(2) serialized\nsqlite3_config $t($sqlite_options(threadsafe))\nsqlite3_config_lookaside 100 500\nsqlite3_initialize\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.0 { \n  CREATE TABLE t1(a, b, c); \n  INSERT INTO t1 VALUES(1, 2, 3);\n}\ndo_test 4.1 { \n  for {set i 0} {$i < 256} {incr i} {\n    execsql { \n      INSERT INTO t1 SELECT\n        ((a<<3) + b) & 2147483647,\n        ((b<<3) + c) & 2147483647,\n        ((c<<3) + a) & 2147483647\n      FROM t1 ORDER BY rowid DESC LIMIT 1;\n    }\n  }\n} {}\n\nfaultsim_save_and_close\n\ndo_faultsim_test 4.2 -faults oom* -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { CREATE UNIQUE INDEX i1 ON t1(a,b,c) }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nset a [string repeat a 500]\nset b [string repeat b 500]\nset c [string repeat c 500]\ndo_execsql_test 5.0 { \n  CREATE TABLE t1(a, b, c); \n  INSERT INTO t1 VALUES($a, $b, $c); \n  INSERT INTO t1 VALUES($c, $b, $a); \n}\n\ndo_faultsim_test 5.1 -faults oom* -body {\n  execsql { SELECT * FROM t1 ORDER BY a }\n} -test {\n  faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]]\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed1.test",
    "content": "# 2006 November 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed.\n#\n# $Id: speed1.test,v 1.11 2009/04/09 01:23:49 drh Exp $\n#\n\nsqlite3_shutdown\n#sqlite3_config_scratch 29000 1\nset old_lookaside [sqlite3_config_lookaside 1000 300]\n#sqlite3_config_pagecache 1024 10000\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed1.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Create a database schema.\n#\ndo_test speed1-1.0 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA cache_size=8192;\n    PRAGMA locking_mode=EXCLUSIVE;\n    CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n    CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n  }\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1;\n  }\n} {i2a i2b t1 t2}\n\n\n# 50000 INSERTs on an unindexed table\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\\n\"\n}\ndb eval BEGIN\nspeed_trial speed1-insert1 50000 row $sql\ndb eval COMMIT\n\n# 50000 INSERTs on an indexed table\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"INSERT INTO t2 VALUES($i,$r,'[number_name $r]');\\n\"\n}\ndb eval BEGIN\nspeed_trial speed1-insert2 50000 row $sql\ndb eval COMMIT\n\n\n\n# 50 SELECTs on an integer comparison.  There is no index so\n# a full table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\ndb eval BEGIN\nspeed_trial speed1-select1 [expr {50*50000}] row $sql\ndb eval COMMIT\n\n# 50 SELECTs on an LIKE comparison.  There is no index so a full\n# table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  append sql \\\n    \"SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';\"\n}\ndb eval BEGIN\nspeed_trial speed1-select2 [expr {50*50000}] row $sql\ndb eval COMMIT\n\n# Create indices\n#\ndb eval BEGIN\nspeed_trial speed1-createidx 150000 row {\n  CREATE INDEX i1a ON t1(a);\n  CREATE INDEX i1b ON t1(b);\n  CREATE INDEX i1c ON t1(c);\n}\ndb eval COMMIT\n\n# 5000 SELECTs on an integer comparison where the integer is\n# indexed.\n#\nset sql {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\ndb eval BEGIN\nspeed_trial speed1-select3 5000 stmt $sql\ndb eval COMMIT\n\n# 100000 random SELECTs against rowid.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c FROM t1 WHERE rowid=$id;\"\n}\ndb eval BEGIN\nspeed_trial speed1-select4 100000 row $sql\ndb eval COMMIT\n\n# 100000 random SELECTs against a unique indexed column.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c FROM t1 WHERE a=$id;\"\n}\ndb eval BEGIN\nspeed_trial speed1-select5 100000 row $sql\ndb eval COMMIT\n\n# 50000 random SELECTs against an indexed column text column\n#\nset sql {}\ndb eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {\n  append sql \"SELECT c FROM t1 WHERE c='$c';\"\n}\ndb eval BEGIN\nspeed_trial speed1-select6 50000 row $sql\ndb eval COMMIT\n\n\n# Vacuum\nspeed_trial speed1-vacuum 100000 row VACUUM\n\n# 5000 updates of ranges where the field being compared is indexed.\n#\nset sql {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*2}]\n  set upr [expr {($i+1)*2}]\n  append sql \"UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;\"\n}\ndb eval BEGIN\nspeed_trial speed1-update1 5000 stmt $sql\ndb eval COMMIT\n\n# 50000 single-row updates.  An index is used to find the row quickly.\n#\nset sql {}\nfor {set i 0} {$i<50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"UPDATE t1 SET b=$r WHERE a=$i;\"\n}\ndb eval BEGIN\nspeed_trial speed1-update2 50000 row $sql\ndb eval COMMIT\n\n# 1 big text update that touches every row in the table.\n#\nspeed_trial speed1-update3 50000 row {\n  UPDATE t1 SET c=a;\n}\n\n# Many individual text updates.  Each row in the table is\n# touched through an index.\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"UPDATE t1 SET c='[number_name $r]' WHERE a=$i;\"\n}\ndb eval BEGIN\nspeed_trial speed1-update4 50000 row $sql\ndb eval COMMIT\n\n# Delete all content in a table.\n#\nspeed_trial speed1-delete1 50000 row {DELETE FROM t1}\n\n# Copy one table into another\n#\nspeed_trial speed1-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Delete all content in a table, one row at a time.\n#\nspeed_trial speed1-delete2 50000 row {DELETE FROM t1 WHERE 1}\n\n# Refill the table yet again\n#\nspeed_trial speed1-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Drop the table and recreate it without its indices.\n#\ndb eval BEGIN\nspeed_trial speed1-drop1 50000 row {\n   DROP TABLE t1;\n   CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n}\ndb eval COMMIT\n\n# Refill the table yet again.  This copy should be faster because\n# there are no indices to deal with.\n#\nspeed_trial speed1-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Select 20000 rows from the table at random.\n#\nspeed_trial speed1-random1 50000 row {\n  SELECT rowid FROM t1 ORDER BY random() LIMIT 20000\n}\n\n# Delete 20000 random rows from the table.\n#\nspeed_trial speed1-random-del1 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1-1.1 {\n  db one {SELECT count(*) FROM t1}\n} 30000\n\n    \n# Delete 20000 more rows at random from the table.\n#\nspeed_trial speed1-random-del2 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1-1.2 {\n  db one {SELECT count(*) FROM t1}\n} 10000\nspeed_trial_summary speed1\n\ndb close\nsqlite3_shutdown\neval sqlite3_config_lookaside $old_lookaside\nsqlite3_initialize\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed1p.explain",
    "content": "# 2008 March 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed.  \n#\n# This is a copy of speed1.test modified to user prepared statements.\n#\n# $Id: speed1p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed1.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Create a database schema.\n#\ndo_test speed1p-1.0 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA cache_size=8192;\n    PRAGMA locking_mode=EXCLUSIVE;\n    CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n    CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n  }\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1;\n  }\n} {i2a i2b t1 t2}\n\n\n# 50000 INSERTs on an unindexed table\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  set x [number_name $r]\n  lappend list $i $r $x\n}\nset script {\n  foreach {i r x} $::list {\n    db eval {INSERT INTO t1 VALUES($i,$r,$x)}\n  }\n}\nexplain {INSERT INTO t1 VALUES($i,$r,$x)}\ndb eval BEGIN\nspeed_trial_tcl speed1p-insert1 50000 row $script\ndb eval COMMIT\n\n# 50000 INSERTs on an indexed table\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  set x [number_name $r]\n  lappend list $i $r $x\n}\nset script {\n  foreach {i r x} $::list {\n    db eval {INSERT INTO t2 VALUES($i,$r,$x)}\n  }\n}\nexplain {INSERT INTO t2 VALUES($i,$r,$x)}\ndb eval BEGIN\nspeed_trial_tcl speed1p-insert2 50000 row $script\ndb eval COMMIT\n\n\n\n# 50 SELECTs on an integer comparison.  There is no index so\n# a full table scan is required.\n#\nset list {}\nfor {set i 0} {$i<50} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval  {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\n  }\n}\nexplain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select1 [expr {50*50000}] row $script\ndb eval COMMIT\n\n# 50 SELECTs on an LIKE comparison.  There is no index so a full\n# table scan is required.\n#\nset list {}\nfor {set i 0} {$i<50} {incr i} {\n  lappend list \"%[number_name $i]%\"\n}\nset script {\n  foreach pattern $::list {\n    db eval {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}\n  }\n}\nexplain {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select2 [expr {50*50000}] row $script\ndb eval COMMIT\n\n# Create indices\n#\nexplain {CREATE INDEX i1a ON t1(a)}\nexplain {CREATE INDEX i1b ON t1(b)}\ndb eval BEGIN\nspeed_trial speed1p-createidx 150000 row {\n  CREATE INDEX i1a ON t1(a);\n  CREATE INDEX i1b ON t1(b);\n  CREATE INDEX i1c ON t1(c);\n}\ndb eval COMMIT\n\n# 5000 SELECTs on an integer comparison where the integer is\n# indexed.\n#\nset list {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\n  }\n}\nexplain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select3 5000 stmt $script\ndb eval COMMIT\n\n# 100000 random SELECTs against rowid.\n#\nset list {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  lappend list $id\n}\nset script {\n  foreach id $::list {\n    db eval {SELECT c FROM t1 WHERE rowid=$id}\n  }\n}\nexplain {SELECT c FROM t1 WHERE rowid=$id}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select4 100000 row $script\ndb eval COMMIT\n\n# 100000 random SELECTs against a unique indexed column.\n#\nset list {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  lappend list $id\n}\nset script {\n  foreach id $::list {\n    db eval {SELECT c FROM t1 WHERE a=$id}\n  }\n}\nexplain {SELECT c FROM t1 WHERE a=$id}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select5 100000 row $script\ndb eval COMMIT\n\n# 50000 random SELECTs against an indexed column text column\n#\nset list [db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000}]\nset script {\n  foreach c $::list {\n    db eval {SELECT c FROM t1 WHERE c=$c}\n  }\n}\nexplain {SELECT c FROM t1 WHERE c=$c}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select6 50000 row $script\ndb eval COMMIT\n\n\n# Vacuum\nspeed_trial speed1p-vacuum 100000 row VACUUM\n\n# 5000 updates of ranges where the field being compared is indexed.\n#\nset list {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*2}]\n  set upr [expr {($i+1)*2}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}\n  }\n}\nexplain {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update1 5000 stmt $script\ndb eval COMMIT\n\n# 50000 single-row updates.  An index is used to find the row quickly.\n#\nset list {}\nfor {set i 0} {$i<50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  lappend list $i $r\n}\nset script {\n  foreach {i r} $::list {\n    db eval {UPDATE t1 SET b=$r WHERE a=$i}\n  }\n}\nexplain {UPDATE t1 SET b=$r WHERE a=$i}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update2 50000 row $script\ndb eval COMMIT\n\n# 1 big text update that touches every row in the table.\n#\nexplain {UPDATE t1 SET c=a}\nspeed_trial speed1p-update3 50000 row {\n  UPDATE t1 SET c=a;\n}\n\n# Many individual text updates.  Each row in the table is\n# touched through an index.\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  lappend list $i [number_name $r]\n}\nset script {\n  foreach {i x} $::list {\n    db eval {UPDATE t1 SET c=$x WHERE a=$i}\n  }\n}\nexplain {UPDATE t1 SET c=$x WHERE a=$i}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update4 50000 row $script\ndb eval COMMIT\n\n# Delete all content in a table.\n#\nexplain {DELETE FROM t1}\nspeed_trial speed1p-delete1 50000 row {DELETE FROM t1}\n\n# Copy one table into another\n#\nexplain {INSERT INTO t1 SELECT * FROM t2}\nspeed_trial speed1p-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Delete all content in a table, one row at a time.\n#\nexplain {DELETE FROM t1 WHERE 1}\nspeed_trial speed1p-delete2 50000 row {DELETE FROM t1 WHERE 1}\n\n# Refill the table yet again\n#\nspeed_trial speed1p-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Drop the table and recreate it without its indices.\n#\nexplain {DROP TABLE t1}\nexplain {CREATE TABLE tX(a INTEGER, b INTEGER, c TEXT)}\ndb eval BEGIN\nspeed_trial speed1p-drop1 50000 row {\n   DROP TABLE t1;\n   CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n}\ndb eval COMMIT\n\n# Refill the table yet again.  This copy should be faster because\n# there are no indices to deal with.\n#\nspeed_trial speed1p-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Select 20000 rows from the table at random.\n#\nexplain {SELECT rowid FROM t1 ORDER BY random() LIMIT 20000}\nspeed_trial speed1p-random1 50000 row {\n  SELECT rowid FROM t1 ORDER BY random() LIMIT 20000\n}\n\n# Delete 20000 random rows from the table.\n#\nexplain {DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)}\nspeed_trial speed1p-random-del1 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1p-1.1 {\n  db one {SELECT count(*) FROM t1}\n} 30000\n\n    \n# Delete 20000 more rows at random from the table.\n#\nspeed_trial speed1p-random-del2 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1p-1.2 {\n  db one {SELECT count(*) FROM t1}\n} 10000\nspeed_trial_summary speed1\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed1p.test",
    "content": "# 2008 March 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed.  \n#\n# This is a copy of speed1.test modified to user prepared statements.\n#\n# $Id: speed1p.test,v 1.7 2009/04/09 01:23:49 drh Exp $\n#\n\nsqlite3_shutdown\n#sqlite3_config_scratch 29000 1\nset old_lookaside [sqlite3_config_lookaside 2048 300]\n#sqlite3_config_pagecache 1024 11000\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\nsqlite3_memdebug_vfs_oom_test 0\n\n# Set a uniform random seed\nexpr srand(0)\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Create a database schema.\n#\ndo_test speed1p-1.0 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA cache_size=500;\n    PRAGMA locking_mode=EXCLUSIVE;\n    CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n    CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n  }\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1;\n  }\n} {i2a i2b t1 t2}\n\n# 50000 INSERTs on an unindexed table\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  set x [number_name $r]\n  lappend list $i $r $x\n}\nset script {\n  foreach {i r x} $::list {\n    db eval {INSERT INTO t1 VALUES($i,$r,$x)}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-insert1 50000 row $script\ndb eval COMMIT\n\n# 50000 INSERTs on an indexed table\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  set x [number_name $r]\n  lappend list $i $r $x\n}\nset script {\n  foreach {i r x} $::list {\n    db eval {INSERT INTO t2 VALUES($i,$r,$x)}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-insert2 50000 row $script\ndb eval COMMIT\n\n\n\n# 50 SELECTs on an integer comparison.  There is no index so\n# a full table scan is required.\n#\nset list {}\nfor {set i 0} {$i<50} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval  {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select1 [expr {50*50000}] row $script\ndb eval COMMIT\n\n# 50 SELECTs on an LIKE comparison.  There is no index so a full\n# table scan is required.\n#\nset list {}\nfor {set i 0} {$i<50} {incr i} {\n  lappend list \"%[number_name $i]%\"\n}\nset script {\n  foreach pattern $::list {\n    db eval {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select2 [expr {50*50000}] row $script\ndb eval COMMIT\n\n# Create indices\n#\ndb eval BEGIN\nspeed_trial speed1p-createidx 150000 row {\n  CREATE INDEX i1a ON t1(a);\n  CREATE INDEX i1b ON t1(b);\n  CREATE INDEX i1c ON t1(c);\n}\ndb eval COMMIT\n\n# 5000 SELECTs on an integer comparison where the integer is\n# indexed.\n#\nset list {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select3 5000 stmt $script\ndb eval COMMIT\n\n# 100000 random SELECTs against rowid.\n#\nset list {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  lappend list $id\n}\nset script {\n  foreach id $::list {\n    db eval {SELECT c FROM t1 WHERE rowid=$id}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select4 100000 row $script\ndb eval COMMIT\n\n# 100000 random SELECTs against a unique indexed column.\n#\nset list {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  lappend list $id\n}\nset script {\n  foreach id $::list {\n    db eval {SELECT c FROM t1 WHERE a=$id}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select5 100000 row $script\ndb eval COMMIT\n\n# 50000 random SELECTs against an indexed column text column\n#\nset list [db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000}]\nset script {\n  foreach c $::list {\n    db eval {SELECT c FROM t1 WHERE c=$c}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-select6 50000 row $script\ndb eval COMMIT\n\n\n# Vacuum\nspeed_trial speed1p-vacuum 100000 row VACUUM\n\n# 5000 updates of ranges where the field being compared is indexed.\n#\nset list {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*2}]\n  set upr [expr {($i+1)*2}]\n  lappend list $lwr $upr\n}\nset script {\n  foreach {lwr upr} $::list {\n    db eval {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update1 5000 stmt $script\ndb eval COMMIT\n\n# 50000 single-row updates.  An index is used to find the row quickly.\n#\nset list {}\nfor {set i 0} {$i<50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  lappend list $i $r\n}\nset script {\n  foreach {i r} $::list {\n    db eval {UPDATE t1 SET b=$r WHERE a=$i}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update2 50000 row $script\ndb eval COMMIT\n\n# 1 big text update that touches every row in the table.\n#\nspeed_trial speed1p-update3 50000 row {\n  UPDATE t1 SET c=a;\n}\n\n# Many individual text updates.  Each row in the table is\n# touched through an index.\n#\nset list {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  lappend list $i [number_name $r]\n}\nset script {\n  foreach {i x} $::list {\n    db eval {UPDATE t1 SET c=$x WHERE a=$i}\n  }\n}\ndb eval BEGIN\nspeed_trial_tcl speed1p-update4 50000 row $script\ndb eval COMMIT\n\n# Delete all content in a table.\n#\nspeed_trial speed1p-delete1 50000 row {DELETE FROM t1}\n\n# Copy one table into another\n#\nspeed_trial speed1p-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Delete all content in a table, one row at a time.\n#\nspeed_trial speed1p-delete2 50000 row {DELETE FROM t1 WHERE 1}\n\n# Refill the table yet again\n#\nspeed_trial speed1p-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Drop the table and recreate it without its indices.\n#\ndb eval BEGIN\nspeed_trial speed1p-drop1 50000 row {\n   DROP TABLE t1;\n   CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n}\ndb eval COMMIT\n\n# Refill the table yet again.  This copy should be faster because\n# there are no indices to deal with.\n#\nspeed_trial speed1p-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Select 20000 rows from the table at random.\n#\nspeed_trial speed1p-random1 50000 row {\n  SELECT rowid FROM t1 ORDER BY random() LIMIT 20000\n}\n\n# Delete 20000 random rows from the table.\n#\nspeed_trial speed1p-random-del1 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1p-1.1 {\n  db one {SELECT count(*) FROM t1}\n} 30000\n    \n# Delete 20000 more rows at random from the table.\n#\nspeed_trial speed1p-random-del2 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed1p-1.2 {\n  db one {SELECT count(*) FROM t1}\n} 10000\nspeed_trial_summary speed1\n\ndb close\nsqlite3_shutdown\neval sqlite3_config_lookaside $old_lookaside\nsqlite3_initialize\nautoinstall_test_functions\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed2.test",
    "content": "# 2006 November 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed.\n#\n# $Id: speed2.test,v 1.7 2007/04/16 15:02:20 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed2\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed2.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Create a database schema.\n#\ndo_test speed2-1.0 {\n  execsql {\n    PRAGMA page_size=1024;\n    PRAGMA cache_size=8192;\n    PRAGMA locking_mode=EXCLUSIVE;\n    CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n    CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n  }\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1;\n  }\n} {i2a i2b t1 t2}\n\n\n# 50000 INSERTs on an unindexed table\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"INSERT INTO t1 VALUES($i,$r,'[number_name $r]');\\n\"\n}\ndb eval BEGIN\nspeed_trial speed2-insert1 50000 row $sql\ndb eval COMMIT\n\n# 50000 INSERTs on an indexed table\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"INSERT INTO t2 VALUES($i,$r,'[number_name $r]');\\n\"\n}\ndb eval BEGIN\nspeed_trial speed2-insert2 50000 row $sql\ndb eval COMMIT\n\n\n\n# 50 SELECTs on an integer comparison.  There is no index so\n# a full table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\nspeed_trial speed2-select1a [expr {50*50000}] row $sql\n\n# 50 SELECTs on an LIKE comparison.  There is no index so a full\n# table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  append sql \\\n    \"SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';\"\n}\nspeed_trial speed2-select2a [expr {50*50000}] row $sql\n\n# Vacuum\nspeed_trial speed2-vacuum1 100000 row VACUUM\n\n# 50 SELECTs on an integer comparison.  There is no index so\n# a full table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\nspeed_trial speed2-select1b [expr {50*50000}] row $sql\n\n# 50 SELECTs on an LIKE comparison.  There is no index so a full\n# table scan is required.\n#\nset sql {}\nfor {set i 0} {$i<50} {incr i} {\n  append sql \\\n    \"SELECT count(*), avg(b) FROM t1 WHERE c LIKE '%[number_name $i]%';\"\n}\nspeed_trial speed2-select2b [expr {50*50000}] row $sql\n\n# Create indices\n#\ndb eval BEGIN\nspeed_trial speed2-createidx 150000 row {\n  CREATE INDEX i1a ON t1(a);\n  CREATE INDEX i1b ON t1(b);\n  CREATE INDEX i1c ON t1(c);\n}\ndb eval COMMIT\n\n# 5000 SELECTs on an integer comparison where the integer is\n# indexed.\n#\nset sql {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\nspeed_trial speed2-select3a 5000 stmt $sql\n\n# 100000 random SELECTs against rowid.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c=='hi' FROM t1 WHERE rowid=$id;\\n\"\n}\nspeed_trial speed2-select4a 100000 row $sql\n\n# 100000 random SELECTs against a unique indexed column.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c FROM t1 WHERE a=$id;\"\n}\nspeed_trial speed2-select5a 100000 row $sql\n\n# 50000 random SELECTs against an indexed column text column\n#\nset sql {}\ndb eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {\n  append sql \"SELECT c FROM t1 WHERE c='$c';\"\n}\nspeed_trial speed2-select6a 50000 row $sql\n\n# Vacuum\nspeed_trial speed2-vacuum2 100000 row VACUUM\n\n\n# 5000 SELECTs on an integer comparison where the integer is\n# indexed.\n#\nset sql {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*100}]\n  set upr [expr {($i+10)*100}]\n  append sql \"SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr;\"\n}\nspeed_trial speed2-select3b 5000 stmt $sql\n\n# 100000 random SELECTs against rowid.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c=='hi' FROM t1 WHERE rowid=$id;\\n\"\n}\nspeed_trial speed2-select4b 100000 row $sql\n\n# 100000 random SELECTs against a unique indexed column.\n#\nset sql {}\nfor {set i 1} {$i<=100000} {incr i} {\n  set id [expr {int(rand()*50000)+1}]\n  append sql \"SELECT c FROM t1 WHERE a=$id;\"\n}\nspeed_trial speed2-select5b 100000 row $sql\n\n# 50000 random SELECTs against an indexed column text column\n#\nset sql {}\ndb eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000} {\n  append sql \"SELECT c FROM t1 WHERE c='$c';\"\n}\nspeed_trial speed2-select6b 50000 row $sql\n\n# 5000 updates of ranges where the field being compared is indexed.\n#\nset sql {}\nfor {set i 0} {$i<5000} {incr i} {\n  set lwr [expr {$i*2}]\n  set upr [expr {($i+1)*2}]\n  append sql \"UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr;\"\n}\ndb eval BEGIN\nspeed_trial speed2-update1 5000 stmt $sql\ndb eval COMMIT\n\n# 50000 single-row updates.  An index is used to find the row quickly.\n#\nset sql {}\nfor {set i 0} {$i<50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"UPDATE t1 SET b=$r WHERE a=$i;\"\n}\ndb eval BEGIN\nspeed_trial speed2-update2 50000 row $sql\ndb eval COMMIT\n\n# 1 big text update that touches every row in the table.\n#\nspeed_trial speed2-update3 50000 row {\n  UPDATE t1 SET c=a;\n}\n\n# Many individual text updates.  Each row in the table is\n# touched through an index.\n#\nset sql {}\nfor {set i 1} {$i<=50000} {incr i} {\n  set r [expr {int(rand()*500000)}]\n  append sql \"UPDATE t1 SET c='[number_name $r]' WHERE a=$i;\"\n}\ndb eval BEGIN\nspeed_trial speed2-update4 50000 row $sql\ndb eval COMMIT\n\n# Delete all content in a table.\n#\nspeed_trial speed2-delete1 50000 row {DELETE FROM t1}\n\n# Copy one table into another\n#\nspeed_trial speed2-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Delete all content in a table, one row at a time.\n#\nspeed_trial speed2-delete2 50000 row {DELETE FROM t1 WHERE 1}\n\n# Refill the table yet again\n#\nspeed_trial speed2-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Drop the table and recreate it without its indices.\n#\ndb eval BEGIN\nspeed_trial speed2-drop1 50000 row {\n   DROP TABLE t1;\n   CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);\n}\ndb eval COMMIT\n\n# Refill the table yet again.  This copy should be faster because\n# there are no indices to deal with.\n#\nspeed_trial speed2-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}\n\n# Select 20000 rows from the table at random.\n#\nspeed_trial speed2-random1 50000 row {\n  SELECT rowid FROM t1 ORDER BY random() LIMIT 20000\n}\n\n# Delete 20000 random rows from the table.\n#\nspeed_trial speed2-random-del1 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed2-1.1 {\n  db one {SELECT count(*) FROM t1}\n} 30000\n\n    \n# Delete 20000 more rows at random from the table.\n#\nspeed_trial speed2-random-del2 20000 row {\n  DELETE FROM t1 WHERE rowid IN\n    (SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)\n}\ndo_test speed2-1.2 {\n  db one {SELECT count(*) FROM t1}\n} 10000\nspeed_trial_summary speed2\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed3.test",
    "content": "# 2007 May 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library. The \n# focus of this script is testing that the overflow-page related\n# enhancements added after version 3.3.17 speed things up.\n#\n# $Id: speed3.test,v 1.6 2009/07/09 02:48:24 shane Exp $\n#\n\n#---------------------------------------------------------------------\n# Test plan:\n#\n# If auto-vacuum is enabled for the database, the following cases\n# should show performance improvement with respect to 3.3.17.\n#\n#   + When deleting rows that span overflow pages. This is faster\n#     because the overflow pages no longer need to be read before\n#     they can be moved to the free list (test cases speed3-1.X). \n#\n#   + When reading a column value stored on an overflow page that\n#     is not the first overflow page for the row. The improvement\n#     in this case is because the overflow pages between the tree\n#     page and the overflow page containing the value do not have\n#     to be read (test cases speed3-2.X).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !tclvar||!attach {\n  finish_test\n  return\n}\n\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset ::NROW 1000\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\nproc populate_t1 {db} {\n  $db transaction {\n    for {set ii 0} {$ii < $::NROW} {incr ii} {\n      set N [number_name $ii]\n      set repeats [expr {(10000/[string length $N])+1}]\n      set text [string range [string repeat $N $repeats] 0 10000]\n      $db eval {INSERT INTO main.t1 VALUES($ii, $text, $ii)}\n    }\n    $db eval {INSERT INTO aux.t1 SELECT * FROM main.t1}\n  }\n}\n\n\nproc io_log {db} {\n  db_enter db\n  array set stats1 [btree_pager_stats [btree_from_db db]]\n  array set stats2 [btree_pager_stats [btree_from_db db 2]]\n  db_leave db\n# puts \"1: [array get stats1]\"\n# puts \"2: [array get stats2]\"\n  puts \"Incrvacuum: Read $stats1(read), wrote $stats1(write)\"\n  puts \"Normal    : Read $stats2(read), wrote $stats2(write)\"\n}\n\nproc speed3_reset_db {} {\n  db close\n  sqlite3 db test.db\n  db eval { \n    PRAGMA main.cache_size = 200000;\n    PRAGMA main.auto_vacuum = 'incremental';\n    ATTACH 'test2.db' AS 'aux'; \n    PRAGMA aux.auto_vacuum = 'none';\n  }\n}\n\nforcedelete test2.db test2.db-journal\nspeed3_reset_db\n\n# Set up a database in auto-vacuum mode and create a database schema.\n#\ndo_test speed3-0.1 {\n  execsql {\n    CREATE TABLE main.t1(a INTEGER, b TEXT, c INTEGER);\n  }\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1;\n  }\n} {t1}\ndo_test speed3-0.2 {\n  execsql {\n    CREATE TABLE aux.t1(a INTEGER, b TEXT, c INTEGER);\n  }\n  execsql {\n    SELECT name FROM aux.sqlite_master ORDER BY 1;\n  }\n} {t1}\ndo_test speed3-0.3 {\n  populate_t1 db\n  execsql {\n    SELECT count(*) FROM main.t1;\n    SELECT count(*) FROM aux.t1;\n  }\n} \"$::NROW $::NROW\"\ndo_test speed3-0.4 {\n  execsql {\n    PRAGMA main.auto_vacuum;\n    PRAGMA aux.auto_vacuum;\n  }\n} {2 0}\n\n# Delete all content in a table, one row at a time.\n#\n#io_log db\nspeed3_reset_db\nspeed_trial speed3-1.incrvacuum $::NROW row {DELETE FROM main.t1 WHERE 1}\nspeed_trial speed3-1.normal     $::NROW row {DELETE FROM aux.t1 WHERE 1}\nio_log db\n\n# Select the \"C\" column (located at the far end of the overflow \n# chain) from each table row.\n#\n#db eval {PRAGMA incremental_vacuum(500000)}\npopulate_t1 db\nspeed3_reset_db\nspeed_trial speed3-2.incrvacuum $::NROW row {SELECT c FROM main.t1}\nspeed_trial speed3-2.normal     $::NROW row {SELECT c FROM aux.t1}\nio_log db\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed4.test",
    "content": "# 2007 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed. More specifically,\n# the focus is on the speed of:\n#\n#   * joins\n#   * views\n#   * sub-selects\n#   * triggers\n#\n# $Id: speed4.test,v 1.2 2008/07/12 14:52:20 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed1.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Summary of tests:\n#\n#   speed4-join1: Join three tables using IPK index.\n#   speed4-join2: Join three tables using an index.\n#   speed4-join3: Join two tables without an index.\n#\n#   speed4-view1:  Querying a view.\n#   speed4-table1: Same queries as in speed4-view1, but run directly against\n#                  the tables for comparison purposes.\n#\n#   speed4-subselect1: A SELECT statement that uses many sub-queries..\n#\n#   speed4-trigger1: An INSERT statement that fires a trigger.\n#   speed4-trigger2: An UPDATE statement that fires a trigger.\n#   speed4-trigger3: A DELETE statement that fires a trigger.\n#   speed4-notrigger1: Same operation as trigger1, but without the trigger.\n#   speed4-notrigger2:        \"          trigger2           \"\n#   speed4-notrigger3:        \"          trigger3           \"\n#\n\n# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.\n# This creates a database of around 16MB.\nexecsql {\n  BEGIN;\n  CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n\n  CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;\n  CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;\n  CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;\n}\nfor {set jj 1} {$jj <= 3} {incr jj} {\n  set stmt [string map \"%T% t$jj\" {INSERT INTO %T% VALUES(NULL, $i, $t)}]\n  for {set ii 0} {$ii < 50000} {incr ii} {\n    set i [expr {int(rand()*50000)}]\n    set t [number_name $i]\n    execsql $stmt\n  }\n}\nexecsql {\n  CREATE INDEX i1 ON t1(t);\n  CREATE INDEX i2 ON t2(t);\n  CREATE INDEX i3 ON t3(t);\n  COMMIT;\n}\n\n# Before running these tests, disable the compiled statement cache built into\n# the Tcl interface. This is because we want to test the speed of SQL\n# compilation as well as execution.\n#\ndb cache size 0\n\n# Join t1, t2, t3 on IPK.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid\"\nspeed_trial speed4-join1 50000 row $sql\n\n# Join t1, t2, t3 on the non-IPK index.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t\"\nspeed_trial speed4-join2 50000 row $sql\n\n# Run 10000 simple queries against the views.\nset sql \"\"\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  append sql \"SELECT * FROM v[expr {($ii%3)+1}] WHERE rowid = [expr {$ii*3}];\"\n}\nspeed_trial speed4-view1 10000 stmt $sql\n\n# Run the same 10000 simple queries as in the previous test case against\n# the underlying tables. The compiled vdbe programs should be identical, so\n# the only difference in running time is the extra time taken to compile\n# the view definitions.\n#\nset sql \"\"\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  append sql \"SELECT t FROM t[expr {($ii%3)+1}] WHERE rowid = [expr {$ii*3}];\"\n}\nspeed_trial speed4-table1 10000 stmt $sql\n\n# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.\n#\nset sql \"\"\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  append sql \"\n    SELECT (SELECT t FROM t1 WHERE rowid = [expr {$ii*3}]), \n           (SELECT t FROM t2 WHERE rowid = [expr {$ii*3}]), \n           (SELECT t FROM t3 WHERE rowid = [expr {$ii*3}])\n  ;\"\n}\nspeed_trial speed4-subselect1 10000 stmt $sql\n\n# The following block tests the speed of some DML statements that cause\n# triggers to fire.\n#\nexecsql {\n  CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN\n    INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN\n    INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN\n    INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);\n  END;\n  BEGIN;\n}\nset sql \"\"\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  append sql \"INSERT INTO t4 VALUES(NULL, $ii, '[number_name $ii]');\"\n}\nspeed_trial speed4-trigger1 10000 stmt $sql\nset sql \"\"\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  append sql \"\n    UPDATE t4 SET i = $ii2, t = '[number_name $ii2]' WHERE rowid = $ii;\n  \"\n}\nspeed_trial speed4-trigger2 10000 stmt $sql\nset sql \"\"\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  append sql \"DELETE FROM t4 WHERE rowid = $ii;\"\n}\nspeed_trial speed4-trigger3 10000 stmt $sql\nexecsql {COMMIT}\n\n# The following block contains the same tests as the above block that\n# tests triggers, with one crucial difference: no triggers are defined.\n# So the difference in speed between these tests and the preceding ones\n# is the amount of time taken to compile and execute the trigger programs.\n#\nexecsql {\n  DROP TABLE t4;\n  DROP TABLE log;\n  VACUUM;\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  BEGIN;\n}\nset sql \"\"\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  append sql \"INSERT INTO t4 VALUES(NULL, $ii, '[number_name $ii]');\"\n}\nspeed_trial speed4-notrigger1 10000 stmt $sql\nset sql \"\"\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  append sql \"\n    UPDATE t4 SET i = $ii2, t = '[number_name $ii2]' WHERE rowid = $ii;\n  \"\n}\nspeed_trial speed4-notrigger2 10000 stmt $sql\nset sql \"\"\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  append sql \"DELETE FROM t4 WHERE rowid = $ii;\"\n}\nspeed_trial speed4-notrigger3 10000 stmt $sql\nexecsql {COMMIT}\n\nspeed_trial_summary speed4\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed4p.explain",
    "content": "# 2007 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed. More specifically,\n# the focus is on the speed of:\n#\n#   * joins\n#   * views\n#   * sub-selects\n#   * triggers\n#\n# $Id: speed4p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed1.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Summary of tests:\n#\n#   speed4p-join1: Join three tables using IPK index.\n#   speed4p-join2: Join three tables using an index.\n#   speed4p-join3: Join two tables without an index.\n#\n#   speed4p-view1:  Querying a view.\n#   speed4p-table1: Same queries as in speed4p-view1, but run directly against\n#                  the tables for comparison purposes.\n#\n#   speed4p-subselect1: A SELECT statement that uses many sub-queries..\n#\n#   speed4p-trigger1: An INSERT statement that fires a trigger.\n#   speed4p-trigger2: An UPDATE statement that fires a trigger.\n#   speed4p-trigger3: A DELETE statement that fires a trigger.\n#   speed4p-notrigger1: Same operation as trigger1, but without the trigger.\n#   speed4p-notrigger2:        \"          trigger2           \"\n#   speed4p-notrigger3:        \"          trigger3           \"\n#\n\n# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.\n# This creates a database of around 16MB.\nexecsql {\n  PRAGMA page_size=1024;\n  PRAGMA cache_size=8192;\n  PRAGMA locking_mode=EXCLUSIVE;\n  BEGIN;\n  CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n\n  CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;\n  CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;\n  CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;\n}\nfor {set jj 1} {$jj <= 3} {incr jj} {\n  set stmt [string map \"%T% t$jj\" {INSERT INTO %T% VALUES(NULL, $i, $t)}]\n  for {set ii 0} {$ii < 50000} {incr ii} {\n    set i [expr {int(rand()*50000)}]\n    set t [number_name $i]\n    execsql $stmt\n  }\n}\nexecsql {\n  CREATE INDEX i1 ON t1(t);\n  CREATE INDEX i2 ON t2(t);\n  CREATE INDEX i3 ON t3(t);\n  COMMIT;\n}\n\n# Before running these tests, disable the compiled statement cache built into\n# the Tcl interface. This is because we want to test the speed of SQL\n# compilation as well as execution.\n#\ndb cache size 0\n\n# Join t1, t2, t3 on IPK.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid\"\nexplain $sql\nspeed_trial speed4p-join1 50000 row $sql\n\n# Join t1, t2, t3 on the non-IPK index.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t\"\nexplain $sql\nspeed_trial speed4p-join2 50000 row $sql\n\n# Run 10000 simple queries against the views.\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    set t [expr {$ii%3+1}]\n    db eval \"SELECT * FROM v$t WHERE rowid = \\$v\"\n  }\n}\nexplain {SELECT * FROm v1 WHERE rowid=$v}\nspeed_trial_tcl speed4p-view1 10000 stmt $script\n\n# Run the same 10000 simple queries as in the previous test case against\n# the underlying tables. The compiled vdbe programs should be identical, so\n# the only difference in running time is the extra time taken to compile\n# the view definitions.\n#\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    set t [expr {$ii%3+1}]\n    db eval \"SELECT t FROM t$t WHERE rowid = \\$v\"\n  }\n}\nexplain {SELECT * FROM t1 WHERE rowid=$v}\nspeed_trial_tcl speed4p-table1 10000 stmt $script\n\n# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.\n#\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    db eval {\n      SELECT (SELECT t FROM t1 WHERE rowid = $v), \n             (SELECT t FROM t2 WHERE rowid = $v), \n             (SELECT t FROM t3 WHERE rowid = $v)\n    }\n  }\n}\nexplain {\n      SELECT (SELECT t FROM t1 WHERE rowid = $v), \n             (SELECT t FROM t2 WHERE rowid = $v), \n             (SELECT t FROM t3 WHERE rowid = $v)\n}\nspeed_trial_tcl speed4p-subselect1 10000 stmt $script\n\n# The following block tests the speed of some DML statements that cause\n# triggers to fire.\n#\nexecsql {\n  CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN\n    INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN\n    INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN\n    INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);\n  END;\n  BEGIN;\n}\nset list {}\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  lappend list $ii [number_name $ii]\n}\nset script {\n  foreach {ii name} $::list {\n    db eval {INSERT INTO t4 VALUES(NULL, $ii, $name)}\n  }\n}\nexplain {INSERT INTO t4 VALUES(NULL, $ii, $name)}\nspeed_trial_tcl speed4p-trigger1 10000 stmt $script\n\nset list {}\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  lappend list $ii $ii2 [number_name $ii2]\n}\nset script {\n  foreach {ii ii2 name} $::list {\n    db eval {\n      UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;\n    }\n  }\n}\nexplain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}\nspeed_trial_tcl speed4p-trigger2 10000 stmt $script\n\nset script {\n  for {set ii 1} {$ii < 20000} {incr ii 2} {\n    db eval {DELETE FROM t4 WHERE rowid = $ii}\n  }\n}\nexplain {DELETE FROM t4 WHERE rowid = $ii}\nspeed_trial_tcl speed4p-trigger3 10000 stmt $script\nexecsql {COMMIT}\n\n# The following block contains the same tests as the above block that\n# tests triggers, with one crucial difference: no triggers are defined.\n# So the difference in speed between these tests and the preceding ones\n# is the amount of time taken to compile and execute the trigger programs.\n#\nexecsql {\n  DROP TABLE t4;\n  DROP TABLE log;\n  VACUUM;\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  BEGIN;\n}\nset list {}\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  lappend list $ii [number_name $ii]\n}\nset script {\n  foreach {ii name} $::list {\n    db eval {INSERT INTO t4 VALUES(NULL, $ii, $name);}\n  }\n}\nexplain {INSERT INTO t4 VALUES(NULL, $ii, $name)}\nspeed_trial_tcl speed4p-notrigger1 10000 stmt $script\n\nset list {}\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  lappend list $ii $ii2 [number_name $ii2]\n}\nset script {\n  foreach {ii ii2 name} $::list {\n    db eval {\n      UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;\n    }\n  }\n}\nexplain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}\nspeed_trial_tcl speed4p-notrigger2 10000 stmt $script\n\nset script {\n  for {set ii 1} {$ii < 20000} {incr ii 2} {\n    db eval {DELETE FROM t4 WHERE rowid = $ii}\n  }\n}\nexplain {DELETE FROM t4 WHERE rowid = $ii}\nspeed_trial_tcl speed4p-notrigger3 10000 stmt $script\nexecsql {COMMIT}\n\nspeed_trial_summary speed4\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speed4p.test",
    "content": "# 2007 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is measuring executing speed. More specifically,\n# the focus is on the speed of:\n#\n#   * joins\n#   * views\n#   * sub-selects\n#   * triggers\n#\n# $Id: speed4p.test,v 1.4 2008/04/10 13:32:37 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nspeed_trial_init speed1\n\n# Set a uniform random seed\nexpr srand(0)\n\nset sqlout [open speed1.txt w]\nproc tracesql {sql} {\n  puts $::sqlout $sql\\;\n}\n#db trace tracesql\n\n# The number_name procedure below converts its argment (an integer)\n# into a string which is the English-language name for that number.\n#\n# Example:\n#\n#     puts [number_name 123]   ->  \"one hundred twenty three\"\n#\nset ones {zero one two three four five six seven eight nine\n          ten eleven twelve thirteen fourteen fifteen sixteen seventeen\n          eighteen nineteen}\nset tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}\nproc number_name {n} {\n  if {$n>=1000} {\n    set txt \"[number_name [expr {$n/1000}]] thousand\"\n    set n [expr {$n%1000}]\n  } else {\n    set txt {}\n  }\n  if {$n>=100} {\n    append txt \" [lindex $::ones [expr {$n/100}]] hundred\"\n    set n [expr {$n%100}]\n  }\n  if {$n>=20} {\n    append txt \" [lindex $::tens [expr {$n/10}]]\"\n    set n [expr {$n%10}]\n  }\n  if {$n>0} {\n    append txt \" [lindex $::ones $n]\"\n  }\n  set txt [string trim $txt]\n  if {$txt==\"\"} {set txt zero}\n  return $txt\n}\n\n# Summary of tests:\n#\n#   speed4p-join1: Join three tables using IPK index.\n#   speed4p-join2: Join three tables using an index.\n#   speed4p-join3: Join two tables without an index.\n#\n#   speed4p-view1:  Querying a view.\n#   speed4p-table1: Same queries as in speed4p-view1, but run directly against\n#                  the tables for comparison purposes.\n#\n#   speed4p-subselect1: A SELECT statement that uses many sub-queries..\n#\n#   speed4p-trigger1: An INSERT statement that fires a trigger.\n#   speed4p-trigger2: An UPDATE statement that fires a trigger.\n#   speed4p-trigger3: A DELETE statement that fires a trigger.\n#   speed4p-notrigger1: Same operation as trigger1, but without the trigger.\n#   speed4p-notrigger2:        \"          trigger2           \"\n#   speed4p-notrigger3:        \"          trigger3           \"\n#\n\n# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.\n# This creates a database of around 16MB.\nexecsql {\n  PRAGMA page_size=1024;\n  PRAGMA cache_size=8192;\n  PRAGMA locking_mode=EXCLUSIVE;\n  BEGIN;\n  CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n\n  CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;\n  CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;\n  CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;\n}\nfor {set jj 1} {$jj <= 3} {incr jj} {\n  set stmt [string map \"%T% t$jj\" {INSERT INTO %T% VALUES(NULL, $i, $t)}]\n  for {set ii 0} {$ii < 50000} {incr ii} {\n    set i [expr {int(rand()*50000)}]\n    set t [number_name $i]\n    execsql $stmt\n  }\n}\nexecsql {\n  CREATE INDEX i1 ON t1(t);\n  CREATE INDEX i2 ON t2(t);\n  CREATE INDEX i3 ON t3(t);\n  COMMIT;\n}\n\n# Join t1, t2, t3 on IPK.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid\"\nspeed_trial speed4p-join1 50000 row $sql\n\n# Join t1, t2, t3 on the non-IPK index.\nset sql \"SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t\"\nspeed_trial speed4p-join2 50000 row $sql\n\n# Run 10000 simple queries against the views.\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    set t [expr {$ii%3+1}]\n    db eval \"SELECT * FROM v$t WHERE rowid = \\$v\"\n  }\n}\nspeed_trial_tcl speed4p-view1 10000 stmt $script\n\n# Run the same 10000 simple queries as in the previous test case against\n# the underlying tables. The compiled vdbe programs should be identical, so\n# the only difference in running time is the extra time taken to compile\n# the view definitions.\n#\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    set t [expr {$ii%3+1}]\n    db eval \"SELECT t FROM t$t WHERE rowid = \\$v\"\n  }\n}\nspeed_trial_tcl speed4p-table1 10000 stmt $script\n\n# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.\n#\nset script {\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    db eval {\n      SELECT (SELECT t FROM t1 WHERE rowid = $v), \n             (SELECT t FROM t2 WHERE rowid = $v), \n             (SELECT t FROM t3 WHERE rowid = $v)\n    }\n  }\n}\nspeed_trial_tcl speed4p-subselect1 10000 stmt $script\n\n# Single-row updates performance.\n#\nset script {\n  db eval BEGIN\n  for {set ii 1} {$ii < 10000} {incr ii} {\n    set v [expr {$ii*3}]\n    db eval {UPDATE t1 SET i=i+1 WHERE rowid=$ii}\n  }\n  db eval COMMIT\n}\nspeed_trial_tcl speed4p-rowid-update 10000 stmt $script\n\n\ndb eval {\n   CREATE TABLE t5(t TEXT PRIMARY KEY, i INTEGER);\n}\nspeed_trial speed4p-insert-ignore 50000 row {\n  INSERT OR IGNORE INTO t5 SELECT t, i FROM t1;\n}\n\nset list [db eval {SELECT t FROM t5}]\nset script {\n  db eval BEGIN\n  foreach t $::list {\n    db eval {UPDATE t5 SET i=i+1 WHERE t=$t}\n  }\n  db eval COMMIT\n}\nspeed_trial_tcl speed4p-unique-update [llength $list] stmt $script\n\n# The following block tests the speed of some DML statements that cause\n# triggers to fire.\n#\nexecsql {\n  CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN\n    INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN\n    INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);\n  END;\n  CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN\n    INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);\n  END;\n  BEGIN;\n}\nset list {}\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  lappend list $ii [number_name $ii]\n}\nset script {\n  foreach {ii name} $::list {\n    db eval {INSERT INTO t4 VALUES(NULL, $ii, $name)}\n  }\n}\nspeed_trial_tcl speed4p-trigger1 10000 stmt $script\n\nset list {}\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  lappend list $ii $ii2 [number_name $ii2]\n}\nset script {\n  foreach {ii ii2 name} $::list {\n    db eval {\n      UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;\n    }\n  }\n}\nspeed_trial_tcl speed4p-trigger2 10000 stmt $script\n\nset script {\n  for {set ii 1} {$ii < 20000} {incr ii 2} {\n    db eval {DELETE FROM t4 WHERE rowid = $ii}\n  }\n}\nspeed_trial_tcl speed4p-trigger3 10000 stmt $script\nexecsql {COMMIT}\n\n# The following block contains the same tests as the above block that\n# tests triggers, with one crucial difference: no triggers are defined.\n# So the difference in speed between these tests and the preceding ones\n# is the amount of time taken to compile and execute the trigger programs.\n#\nexecsql {\n  DROP TABLE t4;\n  DROP TABLE log;\n  VACUUM;\n  CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);\n  BEGIN;\n}\nset list {}\nfor {set ii 1} {$ii < 10000} {incr ii} {\n  lappend list $ii [number_name $ii]\n}\nset script {\n  foreach {ii name} $::list {\n    db eval {INSERT INTO t4 VALUES(NULL, $ii, $name);}\n  }\n}\nspeed_trial_tcl speed4p-notrigger1 10000 stmt $script\n\nset list {}\nfor {set ii 1} {$ii < 20000} {incr ii 2} {\n  set ii2 [expr {$ii*2}]\n  lappend list $ii $ii2 [number_name $ii2]\n}\nset script {\n  foreach {ii ii2 name} $::list {\n    db eval {\n      UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;\n    }\n  }\n}\nspeed_trial_tcl speed4p-notrigger2 10000 stmt $script\n\nset script {\n  for {set ii 1} {$ii < 20000} {incr ii 2} {\n    db eval {DELETE FROM t4 WHERE rowid = $ii}\n  }\n}\nspeed_trial_tcl speed4p-notrigger3 10000 stmt $script\nexecsql {COMMIT}\n\nspeed_trial_summary speed4\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/speedtest1.c",
    "content": "/*\n** A program for performance testing.\n**\n** The available command-line options are described below:\n*/\nstatic const char zHelp[] =\n  \"Usage: %s [--options] DATABASE\\n\"\n  \"Options:\\n\"\n  \"  --autovacuum        Enable AUTOVACUUM mode\\n\"\n  \"  --cachesize N       Set the cache size to N\\n\" \n  \"  --exclusive         Enable locking_mode=EXCLUSIVE\\n\"\n  \"  --explain           Like --sqlonly but with added EXPLAIN keywords\\n\"\n  \"  --heap SZ MIN       Memory allocator uses SZ bytes & min allocation MIN\\n\"\n  \"  --incrvacuum        Enable incremenatal vacuum mode\\n\"\n  \"  --journal M         Set the journal_mode to M\\n\"\n  \"  --key KEY           Set the encryption key to KEY\\n\"\n  \"  --lookaside N SZ    Configure lookaside for N slots of SZ bytes each\\n\"\n  \"  --mmap SZ           MMAP the first SZ bytes of the database file\\n\"\n  \"  --multithread       Set multithreaded mode\\n\"\n  \"  --nomemstat         Disable memory statistics\\n\"\n  \"  --nosync            Set PRAGMA synchronous=OFF\\n\"\n  \"  --notnull           Add NOT NULL constraints to table columns\\n\"\n  \"  --pagesize N        Set the page size to N\\n\"\n  \"  --pcache N SZ       Configure N pages of pagecache each of size SZ bytes\\n\"\n  \"  --primarykey        Use PRIMARY KEY instead of UNIQUE where appropriate\\n\"\n  \"  --repeat N          Repeat each SELECT N times (default: 1)\\n\"\n  \"  --reprepare         Reprepare each statement upon every invocation\\n\"\n  \"  --serialized        Set serialized threading mode\\n\"\n  \"  --singlethread      Set single-threaded mode - disables all mutexing\\n\"\n  \"  --sqlonly           No-op.  Only show the SQL that would have been run.\\n\"\n  \"  --shrink-memory     Invoke sqlite3_db_release_memory() frequently.\\n\"\n  \"  --size N            Relative test size.  Default=100\\n\"\n  \"  --stats             Show statistics at the end\\n\"\n  \"  --temp N            N from 0 to 9.  0: no temp table. 9: all temp tables\\n\"\n  \"  --testset T         Run test-set T (main, cte, rtree, orm, debug)\\n\"\n  \"  --trace             Turn on SQL tracing\\n\"\n  \"  --threads N         Use up to N threads for sorting\\n\"\n  \"  --utf16be           Set text encoding to UTF-16BE\\n\"\n  \"  --utf16le           Set text encoding to UTF-16LE\\n\"\n  \"  --verify            Run additional verification steps.\\n\"\n  \"  --without-rowid     Use WITHOUT ROWID where appropriate\\n\"\n;\n\n\n#include \"sqlite3.h\"\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <ctype.h>\n#ifndef _WIN32\n# include <unistd.h>\n#else\n# include <io.h>\n#endif\n#define ISSPACE(X) isspace((unsigned char)(X))\n#define ISDIGIT(X) isdigit((unsigned char)(X))\n\n#if SQLITE_VERSION_NUMBER<3005000\n# define sqlite3_int64 sqlite_int64\n#endif\n\n/* All global state is held in this structure */\nstatic struct Global {\n  sqlite3 *db;               /* The open database connection */\n  sqlite3_stmt *pStmt;       /* Current SQL statement */\n  sqlite3_int64 iStart;      /* Start-time for the current test */\n  sqlite3_int64 iTotal;      /* Total time */\n  int bWithoutRowid;         /* True for --without-rowid */\n  int bReprepare;            /* True to reprepare the SQL on each rerun */\n  int bSqlOnly;              /* True to print the SQL once only */\n  int bExplain;              /* Print SQL with EXPLAIN prefix */\n  int bVerify;               /* Try to verify that results are correct */\n  int bMemShrink;            /* Call sqlite3_db_release_memory() often */\n  int eTemp;                 /* 0: no TEMP.  9: always TEMP. */\n  int szTest;                /* Scale factor for test iterations */\n  int nRepeat;               /* Repeat selects this many times */\n  const char *zWR;           /* Might be WITHOUT ROWID */\n  const char *zNN;           /* Might be NOT NULL */\n  const char *zPK;           /* Might be UNIQUE or PRIMARY KEY */\n  unsigned int x, y;         /* Pseudo-random number generator state */\n  int nResult;               /* Size of the current result */\n  char zResult[3000];        /* Text of the current result */\n} g;\n\n/* Return \" TEMP\" or \"\", as appropriate for creating a table.\n*/\nstatic const char *isTemp(int N){\n  return g.eTemp>=N ? \" TEMP\" : \"\";\n}\n\n\n/* Print an error message and exit */\nstatic void fatal_error(const char *zMsg, ...){\n  va_list ap;\n  va_start(ap, zMsg);\n  vfprintf(stderr, zMsg, ap);\n  va_end(ap);\n  exit(1);\n}\n\n/*\n** Return the value of a hexadecimal digit.  Return -1 if the input\n** is not a hex digit.\n*/\nstatic int hexDigitValue(char c){\n  if( c>='0' && c<='9' ) return c - '0';\n  if( c>='a' && c<='f' ) return c - 'a' + 10;\n  if( c>='A' && c<='F' ) return c - 'A' + 10;\n  return -1;\n}\n\n/* Provide an alternative to sqlite3_stricmp() in older versions of\n** SQLite */\n#if SQLITE_VERSION_NUMBER<3007011\n# define sqlite3_stricmp strcmp\n#endif\n\n/*\n** Interpret zArg as an integer value, possibly with suffixes.\n*/\nstatic int integerValue(const char *zArg){\n  sqlite3_int64 v = 0;\n  static const struct { char *zSuffix; int iMult; } aMult[] = {\n    { \"KiB\", 1024 },\n    { \"MiB\", 1024*1024 },\n    { \"GiB\", 1024*1024*1024 },\n    { \"KB\",  1000 },\n    { \"MB\",  1000000 },\n    { \"GB\",  1000000000 },\n    { \"K\",   1000 },\n    { \"M\",   1000000 },\n    { \"G\",   1000000000 },\n  };\n  int i;\n  int isNeg = 0;\n  if( zArg[0]=='-' ){\n    isNeg = 1;\n    zArg++;\n  }else if( zArg[0]=='+' ){\n    zArg++;\n  }\n  if( zArg[0]=='0' && zArg[1]=='x' ){\n    int x;\n    zArg += 2;\n    while( (x = hexDigitValue(zArg[0]))>=0 ){\n      v = (v<<4) + x;\n      zArg++;\n    }\n  }else{\n    while( isdigit(zArg[0]) ){\n      v = v*10 + zArg[0] - '0';\n      zArg++;\n    }\n  }\n  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){\n    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){\n      v *= aMult[i].iMult;\n      break;\n    }\n  }\n  if( v>0x7fffffff ) fatal_error(\"parameter too large - max 2147483648\");\n  return (int)(isNeg? -v : v);\n}\n\n/* Return the current wall-clock time, in milliseconds */\nsqlite3_int64 speedtest1_timestamp(void){\n#if SQLITE_VERSION_NUMBER<3005000\n  return 0;\n#else\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n#if SQLITE_VERSION_NUMBER>=3007000\n  if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else\n#endif\n  {\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n#endif\n}\n\n/* Return a pseudo-random unsigned integer */\nunsigned int speedtest1_random(void){\n  g.x = (g.x>>1) ^ ((1+~(g.x&1)) & 0xd0000001);\n  g.y = g.y*1103515245 + 12345;\n  return g.x ^ g.y;\n}\n\n/* Map the value in within the range of 1...limit into another\n** number in a way that is chatic and invertable.\n*/\nunsigned swizzle(unsigned in, unsigned limit){\n  unsigned out = 0;\n  while( limit ){\n    out = (out<<1) | (in&1);\n    in >>= 1;\n    limit >>= 1;\n  }\n  return out;\n}\n\n/* Round up a number so that it is a power of two minus one\n*/\nunsigned roundup_allones(unsigned limit){\n  unsigned m = 1;\n  while( m<limit ) m = (m<<1)+1;\n  return m;\n}\n\n/* The speedtest1_numbername procedure below converts its argment (an integer)\n** into a string which is the English-language name for that number.\n** The returned string should be freed with sqlite3_free().\n**\n** Example:\n**\n**     speedtest1_numbername(123)   ->  \"one hundred twenty three\"\n*/\nint speedtest1_numbername(unsigned int n, char *zOut, int nOut){\n  static const char *ones[] = {  \"zero\", \"one\", \"two\", \"three\", \"four\", \"five\", \n                  \"six\", \"seven\", \"eight\", \"nine\", \"ten\", \"eleven\", \"twelve\", \n                  \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\",\n                  \"eighteen\", \"nineteen\" };\n  static const char *tens[] = { \"\", \"ten\", \"twenty\", \"thirty\", \"forty\",\n                 \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\" };\n  int i = 0;\n\n  if( n>=1000000000 ){\n    i += speedtest1_numbername(n/1000000000, zOut+i, nOut-i);\n    sqlite3_snprintf(nOut-i, zOut+i, \" billion\");\n    i += (int)strlen(zOut+i);\n    n = n % 1000000000;\n  }\n  if( n>=1000000 ){\n    if( i && i<nOut-1 ) zOut[i++] = ' ';\n    i += speedtest1_numbername(n/1000000, zOut+i, nOut-i);\n    sqlite3_snprintf(nOut-i, zOut+i, \" million\");\n    i += (int)strlen(zOut+i);\n    n = n % 1000000;\n  }\n  if( n>=1000 ){\n    if( i && i<nOut-1 ) zOut[i++] = ' ';\n    i += speedtest1_numbername(n/1000, zOut+i, nOut-i);\n    sqlite3_snprintf(nOut-i, zOut+i, \" thousand\");\n    i += (int)strlen(zOut+i);\n    n = n % 1000;\n  }\n  if( n>=100 ){\n    if( i && i<nOut-1 ) zOut[i++] = ' ';\n    sqlite3_snprintf(nOut-i, zOut+i, \"%s hundred\", ones[n/100]);\n    i += (int)strlen(zOut+i);\n    n = n % 100;\n  }\n  if( n>=20 ){\n    if( i && i<nOut-1 ) zOut[i++] = ' ';\n    sqlite3_snprintf(nOut-i, zOut+i, \"%s\", tens[n/10]);\n    i += (int)strlen(zOut+i);\n    n = n % 10;\n  }\n  if( n>0 ){\n    if( i && i<nOut-1 ) zOut[i++] = ' ';\n    sqlite3_snprintf(nOut-i, zOut+i, \"%s\", ones[n]);\n    i += (int)strlen(zOut+i);\n  }\n  if( i==0 ){\n    sqlite3_snprintf(nOut-i, zOut+i, \"zero\");\n    i += (int)strlen(zOut+i);\n  }\n  return i;\n}\n\n\n/* Start a new test case */\n#define NAMEWIDTH 60\nstatic const char zDots[] =\n  \".......................................................................\";\nvoid speedtest1_begin_test(int iTestNum, const char *zTestName, ...){\n  int n = (int)strlen(zTestName);\n  char *zName;\n  va_list ap;\n  va_start(ap, zTestName);\n  zName = sqlite3_vmprintf(zTestName, ap);\n  va_end(ap);\n  n = (int)strlen(zName);\n  if( n>NAMEWIDTH ){\n    zName[NAMEWIDTH] = 0;\n    n = NAMEWIDTH;\n  }\n  if( g.bSqlOnly ){\n    printf(\"/* %4d - %s%.*s */\\n\", iTestNum, zName, NAMEWIDTH-n, zDots);\n  }else{\n    printf(\"%4d - %s%.*s \", iTestNum, zName, NAMEWIDTH-n, zDots);\n    fflush(stdout);\n  }\n  sqlite3_free(zName);\n  g.nResult = 0;\n  g.iStart = speedtest1_timestamp();\n  g.x = 0xad131d0b;\n  g.y = 0x44f9eac8;\n}\n\n/* Complete a test case */\nvoid speedtest1_end_test(void){\n  sqlite3_int64 iElapseTime = speedtest1_timestamp() - g.iStart;\n  if( !g.bSqlOnly ){\n    g.iTotal += iElapseTime;\n    printf(\"%4d.%03ds\\n\", (int)(iElapseTime/1000), (int)(iElapseTime%1000));\n  }\n  if( g.pStmt ){\n    sqlite3_finalize(g.pStmt);\n    g.pStmt = 0;\n  }\n}\n\n/* Report end of testing */\nvoid speedtest1_final(void){\n  if( !g.bSqlOnly ){\n    printf(\"       TOTAL%.*s %4d.%03ds\\n\", NAMEWIDTH-5, zDots,\n           (int)(g.iTotal/1000), (int)(g.iTotal%1000));\n  }\n}\n\n/* Print an SQL statement to standard output */\nstatic void printSql(const char *zSql){\n  int n = (int)strlen(zSql);\n  while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ){ n--; }\n  if( g.bExplain ) printf(\"EXPLAIN \");\n  printf(\"%.*s;\\n\", n, zSql);\n  if( g.bExplain\n#if SQLITE_VERSION_NUMBER>=3007017 \n   && ( sqlite3_strglob(\"CREATE *\", zSql)==0\n     || sqlite3_strglob(\"DROP *\", zSql)==0\n     || sqlite3_strglob(\"ALTER *\", zSql)==0\n      )\n#endif\n  ){\n    printf(\"%.*s;\\n\", n, zSql);\n  }\n}\n\n/* Shrink memory used, if appropriate and if the SQLite version is capable\n** of doing so.\n*/\nvoid speedtest1_shrink_memory(void){\n#if SQLITE_VERSION_NUMBER>=3007010\n  if( g.bMemShrink ) sqlite3_db_release_memory(g.db);\n#endif\n}\n\n/* Run SQL */\nvoid speedtest1_exec(const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( g.bSqlOnly ){\n    printSql(zSql);\n  }else{\n    char *zErrMsg = 0;\n    int rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg);\n    if( zErrMsg ) fatal_error(\"SQL error: %s\\n%s\\n\", zErrMsg, zSql);\n    if( rc!=SQLITE_OK ) fatal_error(\"exec error: %s\\n\", sqlite3_errmsg(g.db));\n  }\n  sqlite3_free(zSql);\n  speedtest1_shrink_memory();\n}\n\n/* Prepare an SQL statement */\nvoid speedtest1_prepare(const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( g.bSqlOnly ){\n    printSql(zSql);\n  }else{\n    int rc;\n    if( g.pStmt ) sqlite3_finalize(g.pStmt);\n    rc = sqlite3_prepare_v2(g.db, zSql, -1, &g.pStmt, 0);\n    if( rc ){\n      fatal_error(\"SQL error: %s\\n\", sqlite3_errmsg(g.db));\n    }\n  }\n  sqlite3_free(zSql);\n}\n\n/* Run an SQL statement previously prepared */\nvoid speedtest1_run(void){\n  int i, n, len;\n  if( g.bSqlOnly ) return;\n  assert( g.pStmt );\n  g.nResult = 0;\n  while( sqlite3_step(g.pStmt)==SQLITE_ROW ){\n    n = sqlite3_column_count(g.pStmt);\n    for(i=0; i<n; i++){\n      const char *z = (const char*)sqlite3_column_text(g.pStmt, i);\n      if( z==0 ) z = \"nil\";\n      len = (int)strlen(z);\n      if( g.nResult+len<sizeof(g.zResult)-2 ){\n        if( g.nResult>0 ) g.zResult[g.nResult++] = ' ';\n        memcpy(g.zResult + g.nResult, z, len+1);\n        g.nResult += len;\n      }\n    }\n  }\n#if SQLITE_VERSION_NUMBER>=3006001\n  if( g.bReprepare ){\n    sqlite3_stmt *pNew;\n    sqlite3_prepare_v2(g.db, sqlite3_sql(g.pStmt), -1, &pNew, 0);\n    sqlite3_finalize(g.pStmt);\n    g.pStmt = pNew;\n  }else\n#endif\n  {\n    sqlite3_reset(g.pStmt);\n  }\n  speedtest1_shrink_memory();\n}\n\n#ifndef SQLITE_OMIT_DEPRECATED\n/* The sqlite3_trace() callback function */\nstatic void traceCallback(void *NotUsed, const char *zSql){\n  int n = (int)strlen(zSql);\n  while( n>0 && (zSql[n-1]==';' || ISSPACE(zSql[n-1])) ) n--;\n  fprintf(stderr,\"%.*s;\\n\", n, zSql);\n}\n#endif /* SQLITE_OMIT_DEPRECATED */\n\n/* Substitute random() function that gives the same random\n** sequence on each run, for repeatability. */\nstatic void randomFunc(\n  sqlite3_context *context,\n  int NotUsed,\n  sqlite3_value **NotUsed2\n){\n  sqlite3_result_int64(context, (sqlite3_int64)speedtest1_random());\n}\n\n/* Estimate the square root of an integer */\nstatic int est_square_root(int x){\n  int y0 = x/2;\n  int y1;\n  int n;\n  for(n=0; y0>0 && n<10; n++){\n    y1 = (y0 + x/y0)/2;\n    if( y1==y0 ) break;\n    y0 = y1;\n  }\n  return y0;\n}\n\n\n#if SQLITE_VERSION_NUMBER<3005004\n/*\n** An implementation of group_concat().  Used only when testing older\n** versions of SQLite that lack the built-in group_concat().\n*/\nstruct groupConcat {\n  char *z;\n  int nAlloc;\n  int nUsed;\n};\nstatic void groupAppend(struct groupConcat *p, const char *z, int n){\n  if( p->nUsed+n >= p->nAlloc ){\n    int n2 = (p->nAlloc+n+1)*2;\n    char *z2 = sqlite3_realloc(p->z, n2);\n    if( z2==0 ) return;\n    p->z = z2;\n    p->nAlloc = n2;\n  }\n  memcpy(p->z+p->nUsed, z, n);\n  p->nUsed += n;\n}\nstatic void groupStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const char *zVal;\n  struct groupConcat *p;\n  const char *zSep;\n  int nVal, nSep;\n  assert( argc==1 || argc==2 );\n  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;\n  p= (struct groupConcat*)sqlite3_aggregate_context(context, sizeof(*p));\n\n  if( p ){\n    int firstTerm = p->nUsed==0;\n    if( !firstTerm ){\n      if( argc==2 ){\n        zSep = (char*)sqlite3_value_text(argv[1]);\n        nSep = sqlite3_value_bytes(argv[1]);\n      }else{\n        zSep = \",\";\n        nSep = 1;\n      }\n      if( nSep ) groupAppend(p, zSep, nSep);\n    }\n    zVal = (char*)sqlite3_value_text(argv[0]);\n    nVal = sqlite3_value_bytes(argv[0]);\n    if( zVal ) groupAppend(p, zVal, nVal);\n  }\n}\nstatic void groupFinal(sqlite3_context *context){\n  struct groupConcat *p;\n  p = sqlite3_aggregate_context(context, 0);\n  if( p && p->z ){\n    p->z[p->nUsed] = 0;\n    sqlite3_result_text(context, p->z, p->nUsed, sqlite3_free);\n  }\n}\n#endif\n\n/*\n** The main and default testset\n*/\nvoid testset_main(void){\n  int i;                        /* Loop counter */\n  int n;                        /* iteration count */\n  int sz;                       /* Size of the tables */\n  int maxb;                     /* Maximum swizzled value */\n  unsigned x1 = 0, x2 = 0;      /* Parameters */\n  int len = 0;                  /* Length of the zNum[] string */\n  char zNum[2000];              /* A number name */\n\n  sz = n = g.szTest*500;\n  zNum[0] = 0;\n  maxb = roundup_allones(sz);\n  speedtest1_begin_test(100, \"%d INSERTs into table with no index\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\"CREATE%s TABLE t1(a INTEGER %s, b INTEGER %s, c TEXT %s);\",\n                  isTemp(9), g.zNN, g.zNN, g.zNN);\n  speedtest1_prepare(\"INSERT INTO t1 VALUES(?1,?2,?3); --  %d times\", n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1);\n    sqlite3_bind_int(g.pStmt, 2, i);\n    sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz;\n  speedtest1_begin_test(110, \"%d ordered INSERTS with one index/PK\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\n     \"CREATE%s TABLE t2(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s\",\n     isTemp(5), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);\n  speedtest1_prepare(\"INSERT INTO t2 VALUES(?1,?2,?3); -- %d times\", n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    sqlite3_bind_int(g.pStmt, 1, i);\n    sqlite3_bind_int64(g.pStmt, 2, (sqlite3_int64)x1);\n    sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz;\n  speedtest1_begin_test(120, \"%d unordered INSERTS with one index/PK\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\n      \"CREATE%s TABLE t3(a INTEGER %s %s, b INTEGER %s, c TEXT %s) %s\",\n      isTemp(3), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);\n  speedtest1_prepare(\"INSERT INTO t3 VALUES(?1,?2,?3); -- %d times\", n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    sqlite3_bind_int(g.pStmt, 2, i);\n    sqlite3_bind_int64(g.pStmt, 1, (sqlite3_int64)x1);\n    sqlite3_bind_text(g.pStmt, 3, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n#if SQLITE_VERSION_NUMBER<3005004\n  sqlite3_create_function(g.db, \"group_concat\", 1, SQLITE_UTF8, 0,\n                          0, groupStep, groupFinal);\n#endif\n\n  n = 25;\n  speedtest1_begin_test(130, \"%d SELECTS, numeric BETWEEN, unindexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\\n\"\n    \" WHERE b BETWEEN ?1 AND ?2; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      x2 = speedtest1_random()%10 + sz/5000 + x1;\n    }\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = 10;\n  speedtest1_begin_test(140, \"%d SELECTS, LIKE, unindexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT count(*), avg(b), sum(length(c)), group_concat(c) FROM t1\\n\"\n    \" WHERE c LIKE ?1; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      zNum[0] = '%';\n      len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);\n      zNum[len] = '%';\n      zNum[len+1] = 0;\n    }\n    sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = 10;\n  speedtest1_begin_test(142, \"%d SELECTS w/ORDER BY, unindexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT a, b, c FROM t1 WHERE c LIKE ?1\\n\"\n    \" ORDER BY a; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      zNum[0] = '%';\n      len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);\n      zNum[len] = '%';\n      zNum[len+1] = 0;\n    }\n    sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  n = 10; /* g.szTest/5; */\n  speedtest1_begin_test(145, \"%d SELECTS w/ORDER BY and LIMIT, unindexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT a, b, c FROM t1 WHERE c LIKE ?1\\n\"\n    \" ORDER BY a LIMIT 10; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      zNum[0] = '%';\n      len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2);\n      zNum[len] = '%';\n      zNum[len+1] = 0;\n    }\n    sqlite3_bind_text(g.pStmt, 1, zNum, len+1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(150, \"CREATE INDEX five times\");\n  speedtest1_exec(\"BEGIN;\");\n  speedtest1_exec(\"CREATE UNIQUE INDEX t1b ON t1(b);\");\n  speedtest1_exec(\"CREATE INDEX t1c ON t1(c);\");\n  speedtest1_exec(\"CREATE UNIQUE INDEX t2b ON t2(b);\");\n  speedtest1_exec(\"CREATE INDEX t2c ON t2(c DESC);\");\n  speedtest1_exec(\"CREATE INDEX t3bc ON t3(b,c);\");\n  speedtest1_exec(\"COMMIT;\");\n  speedtest1_end_test();\n\n\n  n = sz/5;\n  speedtest1_begin_test(160, \"%d SELECTS, numeric BETWEEN, indexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\\n\"\n    \" WHERE b BETWEEN ?1 AND ?2; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      x2 = speedtest1_random()%10 + sz/5000 + x1;\n    }\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz/5;\n  speedtest1_begin_test(161, \"%d SELECTS, numeric BETWEEN, PK\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t2\\n\"\n    \" WHERE a BETWEEN ?1 AND ?2; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = speedtest1_random()%maxb;\n      x2 = speedtest1_random()%10 + sz/5000 + x1;\n    }\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz/5;\n  speedtest1_begin_test(170, \"%d SELECTS, text BETWEEN, indexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT count(*), avg(b), sum(length(c)), group_concat(a) FROM t1\\n\"\n    \" WHERE c BETWEEN ?1 AND (?1||'~'); -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    if( (i-1)%g.nRepeat==0 ){\n      x1 = swizzle(i, maxb);\n      len = speedtest1_numbername(x1, zNum, sizeof(zNum)-1);\n    }\n    sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  n = sz;\n  speedtest1_begin_test(180, \"%d INSERTS with three indexes\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\n    \"CREATE%s TABLE t4(\\n\"\n    \"  a INTEGER %s %s,\\n\"\n    \"  b INTEGER %s,\\n\"\n    \"  c TEXT %s\\n\"\n    \") %s\",\n    isTemp(1), g.zNN, g.zPK, g.zNN, g.zNN, g.zWR);\n  speedtest1_exec(\"CREATE INDEX t4b ON t4(b)\");\n  speedtest1_exec(\"CREATE INDEX t4c ON t4(c)\");\n  speedtest1_exec(\"INSERT INTO t4 SELECT * FROM t1\");\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  n = sz;\n  speedtest1_begin_test(190, \"DELETE and REFILL one table\", n);\n  speedtest1_exec(\"DELETE FROM t2;\");\n  speedtest1_exec(\"INSERT INTO t2 SELECT * FROM t1;\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(200, \"VACUUM\");\n  speedtest1_exec(\"VACUUM\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(210, \"ALTER TABLE ADD COLUMN, and query\");\n  speedtest1_exec(\"ALTER TABLE t2 ADD COLUMN d DEFAULT 123\");\n  speedtest1_exec(\"SELECT sum(d) FROM t2\");\n  speedtest1_end_test();\n\n\n  n = sz/5;\n  speedtest1_begin_test(230, \"%d UPDATES, numeric BETWEEN, indexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"UPDATE t2 SET d=b*2 WHERE b BETWEEN ?1 AND ?2; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    x1 = speedtest1_random()%maxb;\n    x2 = speedtest1_random()%10 + sz/5000 + x1;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz;\n  speedtest1_begin_test(240, \"%d UPDATES of individual rows\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"UPDATE t2 SET d=b*3 WHERE a=?1; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    x1 = speedtest1_random()%sz + 1;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  speedtest1_begin_test(250, \"One big UPDATE of the whole %d-row table\", sz);\n  speedtest1_exec(\"UPDATE t2 SET d=b*4\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(260, \"Query added column after filling\");\n  speedtest1_exec(\"SELECT sum(d) FROM t2\");\n  speedtest1_end_test();\n\n\n\n  n = sz/5;\n  speedtest1_begin_test(270, \"%d DELETEs, numeric BETWEEN, indexed\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"DELETE FROM t2 WHERE b BETWEEN ?1 AND ?2; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    x1 = speedtest1_random()%maxb + 1;\n    x2 = speedtest1_random()%10 + sz/5000 + x1;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  n = sz;\n  speedtest1_begin_test(280, \"%d DELETEs of individual rows\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"DELETE FROM t3 WHERE a=?1; -- %d times\", n\n  );\n  for(i=1; i<=n; i++){\n    x1 = speedtest1_random()%sz + 1;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(290, \"Refill two %d-row tables using REPLACE\", sz);\n  speedtest1_exec(\"REPLACE INTO t2(a,b,c) SELECT a,b,c FROM t1\");\n  speedtest1_exec(\"REPLACE INTO t3(a,b,c) SELECT a,b,c FROM t1\");\n  speedtest1_end_test();\n\n  speedtest1_begin_test(300, \"Refill a %d-row table using (b&1)==(a&1)\", sz);\n  speedtest1_exec(\"DELETE FROM t2;\");\n  speedtest1_exec(\"INSERT INTO t2(a,b,c)\\n\"\n                  \" SELECT a,b,c FROM t1  WHERE (b&1)==(a&1);\");\n  speedtest1_exec(\"INSERT INTO t2(a,b,c)\\n\"\n                  \" SELECT a,b,c FROM t1  WHERE (b&1)<>(a&1);\");\n  speedtest1_end_test();\n\n\n  n = sz/5;\n  speedtest1_begin_test(310, \"%d four-ways joins\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_prepare(\n    \"SELECT t1.c FROM t1, t2, t3, t4\\n\"\n    \" WHERE t4.a BETWEEN ?1 AND ?2\\n\"\n    \"   AND t3.a=t4.b\\n\"\n    \"   AND t2.a=t3.b\\n\"\n    \"   AND t1.c=t2.c\"\n  );\n  for(i=1; i<=n; i++){\n    x1 = speedtest1_random()%sz + 1;\n    x2 = speedtest1_random()%10 + x1 + 4;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    sqlite3_bind_int(g.pStmt, 2, x2);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  speedtest1_begin_test(320, \"subquery in result set\", n);\n  speedtest1_prepare(\n    \"SELECT sum(a), max(c),\\n\"\n    \"       avg((SELECT a FROM t2 WHERE 5+t2.b=t1.b) AND rowid<?1), max(c)\\n\"\n    \" FROM t1 WHERE rowid<?1;\"\n  );\n  sqlite3_bind_int(g.pStmt, 1, est_square_root(g.szTest)*50);\n  speedtest1_run();\n  speedtest1_end_test();\n\n  sz = n = g.szTest*700;\n  zNum[0] = 0;\n  maxb = roundup_allones(sz/3);\n  speedtest1_begin_test(400, \"%d REPLACE ops on an IPK\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\"CREATE%s TABLE t5(a INTEGER PRIMARY KEY, b %s);\",\n                  isTemp(9), g.zNN);\n  speedtest1_prepare(\"REPLACE INTO t5 VALUES(?1,?2); --  %d times\",n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(i, zNum, sizeof(zNum));\n    sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1);\n    sqlite3_bind_text(g.pStmt, 2, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n  speedtest1_begin_test(410, \"%d SELECTS on an IPK\", n);\n  speedtest1_prepare(\"SELECT b FROM t5 WHERE a=?1; --  %d times\",n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    sqlite3_bind_int(g.pStmt, 1, (sqlite3_int64)x1);\n    speedtest1_run();\n  }\n  speedtest1_end_test();\n\n  sz = n = g.szTest*700;\n  zNum[0] = 0;\n  maxb = roundup_allones(sz/3);\n  speedtest1_begin_test(500, \"%d REPLACE on TEXT PK\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\"CREATE%s TABLE t6(a TEXT PRIMARY KEY, b %s)%s;\",\n                  isTemp(9), g.zNN,\n                  sqlite3_libversion_number()>=3008002 ? \"WITHOUT ROWID\" : \"\");\n  speedtest1_prepare(\"REPLACE INTO t6 VALUES(?1,?2); --  %d times\",n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    sqlite3_bind_int(g.pStmt, 2, i);\n    sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n  speedtest1_begin_test(510, \"%d SELECTS on a TEXT PK\", n);\n  speedtest1_prepare(\"SELECT b FROM t6 WHERE a=?1; --  %d times\",n);\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i,maxb);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    sqlite3_bind_text(g.pStmt, 1, zNum, -1, SQLITE_STATIC);\n    speedtest1_run();\n  }\n  speedtest1_end_test();\n  speedtest1_begin_test(520, \"%d SELECT DISTINCT\", n);\n  speedtest1_exec(\"SELECT DISTINCT b FROM t5;\");\n  speedtest1_exec(\"SELECT DISTINCT b FROM t6;\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(980, \"PRAGMA integrity_check\");\n  speedtest1_exec(\"PRAGMA integrity_check\");\n  speedtest1_end_test();\n\n\n  speedtest1_begin_test(990, \"ANALYZE\");\n  speedtest1_exec(\"ANALYZE\");\n  speedtest1_end_test();\n}\n\n/*\n** A testset for common table expressions.  This exercises code\n** for views, subqueries, co-routines, etc.\n*/\nvoid testset_cte(void){\n  static const char *azPuzzle[] = {\n    /* Easy */\n    \"534...9..\"\n    \"67.195...\"\n    \".98....6.\"\n    \"8...6...3\"\n    \"4..8.3..1\"\n    \"....2...6\"\n    \".6....28.\"\n    \"...419..5\"\n    \"...28..79\",\n\n    /* Medium */\n    \"53....9..\"\n    \"6..195...\"\n    \".98....6.\"\n    \"8...6...3\"\n    \"4..8.3..1\"\n    \"....2...6\"\n    \".6....28.\"\n    \"...419..5\"\n    \"....8..79\",\n\n    /* Hard */\n    \"53.......\"\n    \"6..195...\"\n    \".98....6.\"\n    \"8...6...3\"\n    \"4..8.3..1\"\n    \"....2...6\"\n    \".6....28.\"\n    \"...419..5\"\n    \"....8..79\",\n  };\n  const char *zPuz;\n  double rSpacing;\n  int nElem;\n\n  if( g.szTest<25 ){\n    zPuz = azPuzzle[0];\n  }else if( g.szTest<70 ){\n    zPuz = azPuzzle[1];\n  }else{\n    zPuz = azPuzzle[2];\n  }\n  speedtest1_begin_test(100, \"Sudoku with recursive 'digits'\");\n  speedtest1_prepare(\n    \"WITH RECURSIVE\\n\"\n    \"  input(sud) AS (VALUES(?1)),\\n\"\n    \"  digits(z,lp) AS (\\n\"\n    \"    VALUES('1', 1)\\n\"\n    \"    UNION ALL\\n\"\n    \"    SELECT CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9\\n\"\n    \"  ),\\n\"\n    \"  x(s, ind) AS (\\n\"\n    \"    SELECT sud, instr(sud, '.') FROM input\\n\"\n    \"    UNION ALL\\n\"\n    \"    SELECT\\n\"\n    \"      substr(s, 1, ind-1) || z || substr(s, ind+1),\\n\"\n    \"      instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\\n\"\n    \"     FROM x, digits AS z\\n\"\n    \"    WHERE ind>0\\n\"\n    \"      AND NOT EXISTS (\\n\"\n    \"            SELECT 1\\n\"\n    \"              FROM digits AS lp\\n\"\n    \"             WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\\n\"\n    \"                OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\\n\"\n    \"                OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\\n\"\n    \"                        + ((ind-1)/27) * 27 + lp\\n\"\n    \"                        + ((lp-1) / 3) * 6, 1)\\n\"\n    \"         )\\n\"\n    \"  )\\n\"\n    \"SELECT s FROM x WHERE ind=0;\"\n  );\n  sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);\n  speedtest1_run();\n  speedtest1_end_test();\n\n  speedtest1_begin_test(200, \"Sudoku with VALUES 'digits'\");\n  speedtest1_prepare(\n    \"WITH RECURSIVE\\n\"\n    \"  input(sud) AS (VALUES(?1)),\\n\"\n    \"  digits(z,lp) AS (VALUES('1',1),('2',2),('3',3),('4',4),('5',5),\\n\"\n    \"                         ('6',6),('7',7),('8',8),('9',9)),\\n\"\n    \"  x(s, ind) AS (\\n\"\n    \"    SELECT sud, instr(sud, '.') FROM input\\n\"\n    \"    UNION ALL\\n\"\n    \"    SELECT\\n\"\n    \"      substr(s, 1, ind-1) || z || substr(s, ind+1),\\n\"\n    \"      instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\\n\"\n    \"     FROM x, digits AS z\\n\"\n    \"    WHERE ind>0\\n\"\n    \"      AND NOT EXISTS (\\n\"\n    \"            SELECT 1\\n\"\n    \"              FROM digits AS lp\\n\"\n    \"             WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\\n\"\n    \"                OR z.z = substr(s, ((ind-1)%%9) + (lp-1)*9 + 1, 1)\\n\"\n    \"                OR z.z = substr(s, (((ind-1)/3) %% 3) * 3\\n\"\n    \"                        + ((ind-1)/27) * 27 + lp\\n\"\n    \"                        + ((lp-1) / 3) * 6, 1)\\n\"\n    \"         )\\n\"\n    \"  )\\n\"\n    \"SELECT s FROM x WHERE ind=0;\"\n  );\n  sqlite3_bind_text(g.pStmt, 1, zPuz, -1, SQLITE_STATIC);\n  speedtest1_run();\n  speedtest1_end_test();\n\n  rSpacing = 5.0/g.szTest;\n  speedtest1_begin_test(300, \"Mandelbrot Set with spacing=%f\", rSpacing);\n  speedtest1_prepare(\n   \"WITH RECURSIVE \\n\"\n   \"  xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+?1 FROM xaxis WHERE x<1.2),\\n\"\n   \"  yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+?2 FROM yaxis WHERE y<1.0),\\n\"\n   \"  m(iter, cx, cy, x, y) AS (\\n\"\n   \"    SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis\\n\"\n   \"    UNION ALL\\n\"\n   \"    SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m \\n\"\n   \"     WHERE (x*x + y*y) < 4.0 AND iter<28\\n\"\n   \"  ),\\n\"\n   \"  m2(iter, cx, cy) AS (\\n\"\n   \"    SELECT max(iter), cx, cy FROM m GROUP BY cx, cy\\n\"\n   \"  ),\\n\"\n   \"  a(t) AS (\\n\"\n   \"    SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') \\n\"\n   \"    FROM m2 GROUP BY cy\\n\"\n   \"  )\\n\"\n   \"SELECT group_concat(rtrim(t),x'0a') FROM a;\"\n  );\n  sqlite3_bind_double(g.pStmt, 1, rSpacing*.05);\n  sqlite3_bind_double(g.pStmt, 2, rSpacing);\n  speedtest1_run();\n  speedtest1_end_test();\n\n  nElem = 10000*g.szTest;\n  speedtest1_begin_test(400, \"EXCEPT operator on %d-element tables\", nElem);\n  speedtest1_prepare(\n    \"WITH RECURSIVE \\n\"\n    \"  t1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM t1 WHERE x<%d),\\n\"\n    \"  t2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM t2 WHERE y<%d)\\n\"\n    \"SELECT count(x), avg(x) FROM (\\n\"\n    \"  SELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1\\n\"\n    \");\",\n    nElem, nElem\n  );\n  speedtest1_run();\n  speedtest1_end_test();\n\n}\n\n#ifdef SQLITE_ENABLE_RTREE\n/* Generate two numbers between 1 and mx.  The first number is less than\n** the second.  Usually the numbers are near each other but can sometimes\n** be far apart.\n*/\nstatic void twoCoords(\n  int p1, int p2,                   /* Parameters adjusting sizes */\n  unsigned mx,                      /* Range of 1..mx */\n  unsigned *pX0, unsigned *pX1      /* OUT: write results here */\n){\n  unsigned d, x0, x1, span;\n\n  span = mx/100 + 1;\n  if( speedtest1_random()%3==0 ) span *= p1;\n  if( speedtest1_random()%p2==0 ) span = mx/2;\n  d = speedtest1_random()%span + 1;\n  x0 = speedtest1_random()%(mx-d) + 1;\n  x1 = x0 + d;\n  *pX0 = x0;\n  *pX1 = x1;\n}\n#endif\n\n#ifdef SQLITE_ENABLE_RTREE\n/* The following routine is an R-Tree geometry callback.  It returns\n** true if the object overlaps a slice on the Y coordinate between the\n** two values given as arguments.  In other words\n**\n**     SELECT count(*) FROM rt1 WHERE id MATCH xslice(10,20);\n**\n** Is the same as saying:\n**\n**     SELECT count(*) FROM rt1 WHERE y1>=10 AND y0<=20;\n*/\nstatic int xsliceGeometryCallback(\n  sqlite3_rtree_geometry *p,\n  int nCoord,\n  double *aCoord,\n  int *pRes\n){\n  *pRes = aCoord[3]>=p->aParam[0] && aCoord[2]<=p->aParam[1];\n  return SQLITE_OK;\n}\n#endif /* SQLITE_ENABLE_RTREE */\n\n#ifdef SQLITE_ENABLE_RTREE\n/*\n** A testset for the R-Tree virtual table\n*/\nvoid testset_rtree(int p1, int p2){\n  unsigned i, n;\n  unsigned mxCoord;\n  unsigned x0, x1, y0, y1, z0, z1;\n  unsigned iStep;\n  int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*500 );\n\n  mxCoord = 15000;\n  n = g.szTest*500;\n  speedtest1_begin_test(100, \"%d INSERTs into an r-tree\", n);\n  speedtest1_exec(\"BEGIN\");\n  speedtest1_exec(\"CREATE VIRTUAL TABLE rt1 USING rtree(id,x0,x1,y0,y1,z0,z1)\");\n  speedtest1_prepare(\"INSERT INTO rt1(id,x0,x1,y0,y1,z0,z1)\"\n                     \"VALUES(?1,?2,?3,?4,?5,?6,?7)\");\n  for(i=1; i<=n; i++){\n    twoCoords(p1, p2, mxCoord, &x0, &x1);\n    twoCoords(p1, p2, mxCoord, &y0, &y1);\n    twoCoords(p1, p2, mxCoord, &z0, &z1);\n    sqlite3_bind_int(g.pStmt, 1, i);\n    sqlite3_bind_int(g.pStmt, 2, x0);\n    sqlite3_bind_int(g.pStmt, 3, x1);\n    sqlite3_bind_int(g.pStmt, 4, y0);\n    sqlite3_bind_int(g.pStmt, 5, y1);\n    sqlite3_bind_int(g.pStmt, 6, z0);\n    sqlite3_bind_int(g.pStmt, 7, z1);\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT\");\n  speedtest1_end_test();\n\n  speedtest1_begin_test(101, \"Copy from rtree to a regular table\");\n  speedtest1_exec(\"CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)\");\n  speedtest1_exec(\"INSERT INTO t1 SELECT * FROM rt1\");\n  speedtest1_end_test();\n\n  n = g.szTest*100;\n  speedtest1_begin_test(110, \"%d one-dimensional intersect slice queries\", n);\n  speedtest1_prepare(\"SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2\");\n  iStep = mxCoord/n;\n  for(i=0; i<n; i++){\n    sqlite3_bind_int(g.pStmt, 1, i*iStep);\n    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n    speedtest1_run();\n    aCheck[i] = atoi(g.zResult);\n  }\n  speedtest1_end_test();\n\n  if( g.bVerify ){\n    n = g.szTest*100;\n    speedtest1_begin_test(111, \"Verify result from 1-D intersect slice queries\");\n    speedtest1_prepare(\"SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2\");\n    iStep = mxCoord/n;\n    for(i=0; i<n; i++){\n      sqlite3_bind_int(g.pStmt, 1, i*iStep);\n      sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n      speedtest1_run();\n      if( aCheck[i]!=atoi(g.zResult) ){\n        fatal_error(\"Count disagree step %d: %d..%d.  %d vs %d\",\n                    i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));\n      }\n    }\n    speedtest1_end_test();\n  }\n  \n  n = g.szTest*100;\n  speedtest1_begin_test(120, \"%d one-dimensional overlap slice queries\", n);\n  speedtest1_prepare(\"SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2\");\n  iStep = mxCoord/n;\n  for(i=0; i<n; i++){\n    sqlite3_bind_int(g.pStmt, 1, i*iStep);\n    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n    speedtest1_run();\n    aCheck[i] = atoi(g.zResult);\n  }\n  speedtest1_end_test();\n\n  if( g.bVerify ){\n    n = g.szTest*100;\n    speedtest1_begin_test(121, \"Verify result from 1-D overlap slice queries\");\n    speedtest1_prepare(\"SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2\");\n    iStep = mxCoord/n;\n    for(i=0; i<n; i++){\n      sqlite3_bind_int(g.pStmt, 1, i*iStep);\n      sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n      speedtest1_run();\n      if( aCheck[i]!=atoi(g.zResult) ){\n        fatal_error(\"Count disagree step %d: %d..%d.  %d vs %d\",\n                    i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));\n      }\n    }\n    speedtest1_end_test();\n  }\n  \n\n  n = g.szTest*100;\n  speedtest1_begin_test(125, \"%d custom geometry callback queries\", n);\n  sqlite3_rtree_geometry_callback(g.db, \"xslice\", xsliceGeometryCallback, 0);\n  speedtest1_prepare(\"SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)\");\n  iStep = mxCoord/n;\n  for(i=0; i<n; i++){\n    sqlite3_bind_int(g.pStmt, 1, i*iStep);\n    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n    speedtest1_run();\n    if( aCheck[i]!=atoi(g.zResult) ){\n      fatal_error(\"Count disagree step %d: %d..%d.  %d vs %d\",\n                  i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));\n    }\n  }\n  speedtest1_end_test();\n\n  n = g.szTest*400;\n  speedtest1_begin_test(130, \"%d three-dimensional intersect box queries\", n);\n  speedtest1_prepare(\"SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2\"\n                     \" AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2\");\n  iStep = mxCoord/n;\n  for(i=0; i<n; i++){\n    sqlite3_bind_int(g.pStmt, 1, i*iStep);\n    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);\n    speedtest1_run();\n    aCheck[i] = atoi(g.zResult);\n  }\n  speedtest1_end_test();\n\n  n = g.szTest*500;\n  speedtest1_begin_test(140, \"%d rowid queries\", n);\n  speedtest1_prepare(\"SELECT * FROM rt1 WHERE id=?1\");\n  for(i=1; i<=n; i++){\n    sqlite3_bind_int(g.pStmt, 1, i);\n    speedtest1_run();\n  }\n  speedtest1_end_test();\n}\n#endif /* SQLITE_ENABLE_RTREE */\n\n/*\n** A testset that does key/value storage on tables with many columns.\n** This is the kind of workload generated by ORMs such as CoreData.\n*/\nvoid testset_orm(void){\n  unsigned i, j, n;\n  unsigned nRow;\n  unsigned x1, len;\n  char zNum[2000];              /* A number name */\n  static const char zType[] =   /* Types for all non-PK columns, in order */\n    \"IBBIIITIVVITBTBFBFITTFBTBVBVIFTBBFITFFVBIFIVBVVVBTVTIBBFFIVIBTB\"\n    \"TVTTFTVTVFFIITIFBITFTTFFFVBIIBTTITFTFFVVVFIIITVBBVFFTVVB\";\n\n  nRow = n = g.szTest*250;\n  speedtest1_begin_test(100, \"Fill %d rows\", n);\n  speedtest1_exec(\n    \"BEGIN;\"\n    \"CREATE TABLE ZLOOKSLIKECOREDATA (\"\n    \"  ZPK INTEGER PRIMARY KEY,\"\n    \"  ZTERMFITTINGHOUSINGCOMMAND INTEGER,\"\n    \"  ZBRIEFGOBYDODGERHEIGHT BLOB,\"\n    \"  ZCAPABLETRIPDOORALMOND BLOB,\"\n    \"  ZDEPOSITPAIRCOLLEGECOMET INTEGER,\"\n    \"  ZFRAMEENTERSIMPLEMOUTH INTEGER,\"\n    \"  ZHOPEFULGATEHOLECHALK INTEGER,\"\n    \"  ZSLEEPYUSERGRANDBOWL TIMESTAMP,\"\n    \"  ZDEWPEACHCAREERCELERY INTEGER,\"\n    \"  ZHANGERLITHIUMDINNERMEET VARCHAR,\"\n    \"  ZCLUBRELEASELIZARDADVICE VARCHAR,\"\n    \"  ZCHARGECLICKHUMANEHIRE INTEGER,\"\n    \"  ZFINGERDUEPIZZAOPTION TIMESTAMP,\"\n    \"  ZFLYINGDOCTORTABLEMELODY BLOB,\"\n    \"  ZLONGFINLEAVEIMAGEOIL TIMESTAMP,\"\n    \"  ZFAMILYVISUALOWNERMATTER BLOB,\"\n    \"  ZGOLDYOUNGINITIALNOSE FLOAT,\"\n    \"  ZCAUSESALAMITERMCYAN BLOB,\"\n    \"  ZSPREADMOTORBISCUITBACON FLOAT,\"\n    \"  ZGIFTICEFISHGLUEHAIR INTEGER,\"\n    \"  ZNOTICEPEARPOLICYJUICE TIMESTAMP,\"\n    \"  ZBANKBUFFALORECOVERORBIT TIMESTAMP,\"\n    \"  ZLONGDIETESSAYNATURE FLOAT,\"\n    \"  ZACTIONRANGEELEGANTNEUTRON BLOB,\"\n    \"  ZCADETBRIGHTPLANETBANK TIMESTAMP,\"\n    \"  ZAIRFORGIVEHEADFROG BLOB,\"\n    \"  ZSHARKJUSTFRUITMOVIE VARCHAR,\"\n    \"  ZFARMERMORNINGMIRRORCONCERN BLOB,\"\n    \"  ZWOODPOETRYCOBBLERBENCH VARCHAR,\"\n    \"  ZHAFNIUMSCRIPTSALADMOTOR INTEGER,\"\n    \"  ZPROBLEMCLUBPOPOVERJELLY FLOAT,\"\n    \"  ZEIGHTLEADERWORKERMOST TIMESTAMP,\"\n    \"  ZGLASSRESERVEBARIUMMEAL BLOB,\"\n    \"  ZCLAMBITARUGULAFAJITA BLOB,\"\n    \"  ZDECADEJOYOUSWAVEHABIT FLOAT,\"\n    \"  ZCOMPANYSUMMERFIBERELF INTEGER,\"\n    \"  ZTREATTESTQUILLCHARGE TIMESTAMP,\"\n    \"  ZBROWBALANCEKEYCHOWDER FLOAT,\"\n    \"  ZPEACHCOPPERDINNERLAKE FLOAT,\"\n    \"  ZDRYWALLBEYONDBROWNBOWL VARCHAR,\"\n    \"  ZBELLYCRASHITEMLACK BLOB,\"\n    \"  ZTENNISCYCLEBILLOFFICER INTEGER,\"\n    \"  ZMALLEQUIPTHANKSGLUE FLOAT,\"\n    \"  ZMISSREPLYHUMANLIVING INTEGER,\"\n    \"  ZKIWIVISUALPRIDEAPPLE VARCHAR,\"\n    \"  ZWISHHITSKINMOTOR BLOB,\"\n    \"  ZCALMRACCOONPROGRAMDEBIT VARCHAR,\"\n    \"  ZSHINYASSISTLIVINGCRAB VARCHAR,\"\n    \"  ZRESOLVEWRISTWRAPAPPLE VARCHAR,\"\n    \"  ZAPPEALSIMPLESECONDHOUSING BLOB,\"\n    \"  ZCORNERANCHORTAPEDIVER TIMESTAMP,\"\n    \"  ZMEMORYREQUESTSOURCEBIG VARCHAR,\"\n    \"  ZTRYFACTKEEPMILK TIMESTAMP,\"\n    \"  ZDIVERPAINTLEATHEREASY INTEGER,\"\n    \"  ZSORTMISTYQUOTECABBAGE BLOB,\"\n    \"  ZTUNEGASBUFFALOCAPITAL BLOB,\"\n    \"  ZFILLSTOPLAWJOYFUL FLOAT,\"\n    \"  ZSTEELCAREFULPLATENUMBER FLOAT,\"\n    \"  ZGIVEVIVIDDIVINEMEANING INTEGER,\"\n    \"  ZTREATPACKFUTURECONVERT VARCHAR,\"\n    \"  ZCALMLYGEMFINISHEFFECT INTEGER,\"\n    \"  ZCABBAGESOCKEASEMINUTE BLOB,\"\n    \"  ZPLANETFAMILYPUREMEMORY TIMESTAMP,\"\n    \"  ZMERRYCRACKTRAINLEADER BLOB,\"\n    \"  ZMINORWAYPAPERCLASSY TIMESTAMP,\"\n    \"  ZEAGLELINEMINEMAIL VARCHAR,\"\n    \"  ZRESORTYARDGREENLET TIMESTAMP,\"\n    \"  ZYARDOREGANOVIVIDJEWEL TIMESTAMP,\"\n    \"  ZPURECAKEVIVIDNEATLY FLOAT,\"\n    \"  ZASKCONTACTMONITORFUN TIMESTAMP,\"\n    \"  ZMOVEWHOGAMMAINCH VARCHAR,\"\n    \"  ZLETTUCEBIRDMEETDEBATE TIMESTAMP,\"\n    \"  ZGENENATURALHEARINGKITE VARCHAR,\"\n    \"  ZMUFFINDRYERDRAWFORTUNE FLOAT,\"\n    \"  ZGRAYSURVEYWIRELOVE FLOAT,\"\n    \"  ZPLIERSPRINTASKOREGANO INTEGER,\"\n    \"  ZTRAVELDRIVERCONTESTLILY INTEGER,\"\n    \"  ZHUMORSPICESANDKIDNEY TIMESTAMP,\"\n    \"  ZARSENICSAMPLEWAITMUON INTEGER,\"\n    \"  ZLACEADDRESSGROUNDCAREFUL FLOAT,\"\n    \"  ZBAMBOOMESSWASABIEVENING BLOB,\"\n    \"  ZONERELEASEAVERAGENURSE INTEGER,\"\n    \"  ZRADIANTWHENTRYCARD TIMESTAMP,\"\n    \"  ZREWARDINSIDEMANGOINTENSE FLOAT,\"\n    \"  ZNEATSTEWPARTIRON TIMESTAMP,\"\n    \"  ZOUTSIDEPEAHENCOUNTICE TIMESTAMP,\"\n    \"  ZCREAMEVENINGLIPBRANCH FLOAT,\"\n    \"  ZWHALEMATHAVOCADOCOPPER FLOAT,\"\n    \"  ZLIFEUSELEAFYBELL FLOAT,\"\n    \"  ZWEALTHLINENGLEEFULDAY VARCHAR,\"\n    \"  ZFACEINVITETALKGOLD BLOB,\"\n    \"  ZWESTAMOUNTAFFECTHEARING INTEGER,\"\n    \"  ZDELAYOUTCOMEHORNAGENCY INTEGER,\"\n    \"  ZBIGTHINKCONVERTECONOMY BLOB,\"\n    \"  ZBASEGOUDAREGULARFORGIVE TIMESTAMP,\"\n    \"  ZPATTERNCLORINEGRANDCOLBY TIMESTAMP,\"\n    \"  ZCYANBASEFEEDADROIT INTEGER,\"\n    \"  ZCARRYFLOORMINNOWDRAGON TIMESTAMP,\"\n    \"  ZIMAGEPENCILOTHERBOTTOM FLOAT,\"\n    \"  ZXENONFLIGHTPALEAPPLE TIMESTAMP,\"\n    \"  ZHERRINGJOKEFEATUREHOPEFUL FLOAT,\"\n    \"  ZCAPYEARLYRIVETBRUSH FLOAT,\"\n    \"  ZAGEREEDFROGBASKET VARCHAR,\"\n    \"  ZUSUALBODYHALIBUTDIAMOND VARCHAR,\"\n    \"  ZFOOTTAPWORDENTRY VARCHAR,\"\n    \"  ZDISHKEEPBLESTMONITOR FLOAT,\"\n    \"  ZBROADABLESOLIDCASUAL INTEGER,\"\n    \"  ZSQUAREGLEEFULCHILDLIGHT INTEGER,\"\n    \"  ZHOLIDAYHEADPONYDETAIL INTEGER,\"\n    \"  ZGENERALRESORTSKYOPEN TIMESTAMP,\"\n    \"  ZGLADSPRAYKIDNEYGUPPY VARCHAR,\"\n    \"  ZSWIMHEAVYMENTIONKIND BLOB,\"\n    \"  ZMESSYSULFURDREAMFESTIVE BLOB,\"\n    \"  ZSKYSKYCLASSICBRIEF VARCHAR,\"\n    \"  ZDILLASKHOKILEMON FLOAT,\"\n    \"  ZJUNIORSHOWPRESSNOVA FLOAT,\"\n    \"  ZSIZETOEAWARDFRESH TIMESTAMP,\"\n    \"  ZKEYFAILAPRICOTMETAL VARCHAR,\"\n    \"  ZHANDYREPAIRPROTONAIRPORT VARCHAR,\"\n    \"  ZPOSTPROTEINHANDLEACTOR BLOB\"\n    \");\"\n  );\n  speedtest1_prepare(\n    \"INSERT INTO ZLOOKSLIKECOREDATA(ZPK,ZAIRFORGIVEHEADFROG,\"\n    \"ZGIFTICEFISHGLUEHAIR,ZDELAYOUTCOMEHORNAGENCY,ZSLEEPYUSERGRANDBOWL,\"\n    \"ZGLASSRESERVEBARIUMMEAL,ZBRIEFGOBYDODGERHEIGHT,\"\n    \"ZBAMBOOMESSWASABIEVENING,ZFARMERMORNINGMIRRORCONCERN,\"\n    \"ZTREATPACKFUTURECONVERT,ZCAUSESALAMITERMCYAN,ZCALMRACCOONPROGRAMDEBIT,\"\n    \"ZHOLIDAYHEADPONYDETAIL,ZWOODPOETRYCOBBLERBENCH,ZHAFNIUMSCRIPTSALADMOTOR,\"\n    \"ZUSUALBODYHALIBUTDIAMOND,ZOUTSIDEPEAHENCOUNTICE,ZDIVERPAINTLEATHEREASY,\"\n    \"ZWESTAMOUNTAFFECTHEARING,ZSIZETOEAWARDFRESH,ZDEWPEACHCAREERCELERY,\"\n    \"ZSTEELCAREFULPLATENUMBER,ZCYANBASEFEEDADROIT,ZCALMLYGEMFINISHEFFECT,\"\n    \"ZHANDYREPAIRPROTONAIRPORT,ZGENENATURALHEARINGKITE,ZBROADABLESOLIDCASUAL,\"\n    \"ZPOSTPROTEINHANDLEACTOR,ZLACEADDRESSGROUNDCAREFUL,ZIMAGEPENCILOTHERBOTTOM,\"\n    \"ZPROBLEMCLUBPOPOVERJELLY,ZPATTERNCLORINEGRANDCOLBY,ZNEATSTEWPARTIRON,\"\n    \"ZAPPEALSIMPLESECONDHOUSING,ZMOVEWHOGAMMAINCH,ZTENNISCYCLEBILLOFFICER,\"\n    \"ZSHARKJUSTFRUITMOVIE,ZKEYFAILAPRICOTMETAL,ZCOMPANYSUMMERFIBERELF,\"\n    \"ZTERMFITTINGHOUSINGCOMMAND,ZRESORTYARDGREENLET,ZCABBAGESOCKEASEMINUTE,\"\n    \"ZSQUAREGLEEFULCHILDLIGHT,ZONERELEASEAVERAGENURSE,ZBIGTHINKCONVERTECONOMY,\"\n    \"ZPLIERSPRINTASKOREGANO,ZDECADEJOYOUSWAVEHABIT,ZDRYWALLBEYONDBROWNBOWL,\"\n    \"ZCLUBRELEASELIZARDADVICE,ZWHALEMATHAVOCADOCOPPER,ZBELLYCRASHITEMLACK,\"\n    \"ZLETTUCEBIRDMEETDEBATE,ZCAPABLETRIPDOORALMOND,ZRADIANTWHENTRYCARD,\"\n    \"ZCAPYEARLYRIVETBRUSH,ZAGEREEDFROGBASKET,ZSWIMHEAVYMENTIONKIND,\"\n    \"ZTRAVELDRIVERCONTESTLILY,ZGLADSPRAYKIDNEYGUPPY,ZBANKBUFFALORECOVERORBIT,\"\n    \"ZFINGERDUEPIZZAOPTION,ZCLAMBITARUGULAFAJITA,ZLONGFINLEAVEIMAGEOIL,\"\n    \"ZLONGDIETESSAYNATURE,ZJUNIORSHOWPRESSNOVA,ZHOPEFULGATEHOLECHALK,\"\n    \"ZDEPOSITPAIRCOLLEGECOMET,ZWEALTHLINENGLEEFULDAY,ZFILLSTOPLAWJOYFUL,\"\n    \"ZTUNEGASBUFFALOCAPITAL,ZGRAYSURVEYWIRELOVE,ZCORNERANCHORTAPEDIVER,\"\n    \"ZREWARDINSIDEMANGOINTENSE,ZCADETBRIGHTPLANETBANK,ZPLANETFAMILYPUREMEMORY,\"\n    \"ZTREATTESTQUILLCHARGE,ZCREAMEVENINGLIPBRANCH,ZSKYSKYCLASSICBRIEF,\"\n    \"ZARSENICSAMPLEWAITMUON,ZBROWBALANCEKEYCHOWDER,ZFLYINGDOCTORTABLEMELODY,\"\n    \"ZHANGERLITHIUMDINNERMEET,ZNOTICEPEARPOLICYJUICE,ZSHINYASSISTLIVINGCRAB,\"\n    \"ZLIFEUSELEAFYBELL,ZFACEINVITETALKGOLD,ZGENERALRESORTSKYOPEN,\"\n    \"ZPURECAKEVIVIDNEATLY,ZKIWIVISUALPRIDEAPPLE,ZMESSYSULFURDREAMFESTIVE,\"\n    \"ZCHARGECLICKHUMANEHIRE,ZHERRINGJOKEFEATUREHOPEFUL,ZYARDOREGANOVIVIDJEWEL,\"\n    \"ZFOOTTAPWORDENTRY,ZWISHHITSKINMOTOR,ZBASEGOUDAREGULARFORGIVE,\"\n    \"ZMUFFINDRYERDRAWFORTUNE,ZACTIONRANGEELEGANTNEUTRON,ZTRYFACTKEEPMILK,\"\n    \"ZPEACHCOPPERDINNERLAKE,ZFRAMEENTERSIMPLEMOUTH,ZMERRYCRACKTRAINLEADER,\"\n    \"ZMEMORYREQUESTSOURCEBIG,ZCARRYFLOORMINNOWDRAGON,ZMINORWAYPAPERCLASSY,\"\n    \"ZDILLASKHOKILEMON,ZRESOLVEWRISTWRAPAPPLE,ZASKCONTACTMONITORFUN,\"\n    \"ZGIVEVIVIDDIVINEMEANING,ZEIGHTLEADERWORKERMOST,ZMISSREPLYHUMANLIVING,\"\n    \"ZXENONFLIGHTPALEAPPLE,ZSORTMISTYQUOTECABBAGE,ZEAGLELINEMINEMAIL,\"\n    \"ZFAMILYVISUALOWNERMATTER,ZSPREADMOTORBISCUITBACON,ZDISHKEEPBLESTMONITOR,\"\n    \"ZMALLEQUIPTHANKSGLUE,ZGOLDYOUNGINITIALNOSE,ZHUMORSPICESANDKIDNEY)\"\n    \"VALUES(?1,?26,?20,?93,?8,?33,?3,?81,?28,?60,?18,?47,?109,?29,?30,?104,?86,\"\n    \"?54,?92,?117,?9,?58,?97,?61,?119,?73,?107,?120,?80,?99,?31,?96,?85,?50,?71,\"\n    \"?42,?27,?118,?36,?2,?67,?62,?108,?82,?94,?76,?35,?40,?11,?88,?41,?72,?4,\"\n    \"?83,?102,?103,?112,?77,?111,?22,?13,?34,?15,?23,?116,?7,?5,?90,?57,?56,\"\n    \"?75,?51,?84,?25,?63,?37,?87,?114,?79,?38,?14,?10,?21,?48,?89,?91,?110,\"\n    \"?69,?45,?113,?12,?101,?68,?105,?46,?95,?74,?24,?53,?39,?6,?64,?52,?98,\"\n    \"?65,?115,?49,?70,?59,?32,?44,?100,?55,?66,?16,?19,?106,?43,?17,?78);\"\n  );\n  for(i=0; i<n; i++){\n    x1 = speedtest1_random();\n    speedtest1_numbername(x1%1000, zNum, sizeof(zNum));\n    len = (int)strlen(zNum);\n    sqlite3_bind_int(g.pStmt, 1, i^0xf);\n    for(j=0; zType[j]; j++){\n      switch( zType[j] ){\n        case 'I':\n        case 'T':\n          sqlite3_bind_int64(g.pStmt, j+2, x1);\n          break;\n        case 'F':\n          sqlite3_bind_double(g.pStmt, j+2, (double)x1);\n          break;\n        case 'V':\n        case 'B':\n          sqlite3_bind_text64(g.pStmt, j+2, zNum, len,\n                              SQLITE_STATIC, SQLITE_UTF8);\n          break;\n      }\n    }\n    speedtest1_run();\n  }\n  speedtest1_exec(\"COMMIT;\");\n  speedtest1_end_test();\n\n  n = g.szTest*250;\n  speedtest1_begin_test(110, \"Query %d rows by rowid\", n);\n  speedtest1_prepare(\n    \"SELECT ZCYANBASEFEEDADROIT,ZJUNIORSHOWPRESSNOVA,ZCAUSESALAMITERMCYAN,\"\n    \"ZHOPEFULGATEHOLECHALK,ZHUMORSPICESANDKIDNEY,ZSWIMHEAVYMENTIONKIND,\"\n    \"ZMOVEWHOGAMMAINCH,ZAPPEALSIMPLESECONDHOUSING,ZHAFNIUMSCRIPTSALADMOTOR,\"\n    \"ZNEATSTEWPARTIRON,ZLONGFINLEAVEIMAGEOIL,ZDEWPEACHCAREERCELERY,\"\n    \"ZXENONFLIGHTPALEAPPLE,ZCALMRACCOONPROGRAMDEBIT,ZUSUALBODYHALIBUTDIAMOND,\"\n    \"ZTRYFACTKEEPMILK,ZWEALTHLINENGLEEFULDAY,ZLONGDIETESSAYNATURE,\"\n    \"ZLIFEUSELEAFYBELL,ZTREATPACKFUTURECONVERT,ZMEMORYREQUESTSOURCEBIG,\"\n    \"ZYARDOREGANOVIVIDJEWEL,ZDEPOSITPAIRCOLLEGECOMET,ZSLEEPYUSERGRANDBOWL,\"\n    \"ZBRIEFGOBYDODGERHEIGHT,ZCLUBRELEASELIZARDADVICE,ZCAPABLETRIPDOORALMOND,\"\n    \"ZDRYWALLBEYONDBROWNBOWL,ZASKCONTACTMONITORFUN,ZKIWIVISUALPRIDEAPPLE,\"\n    \"ZNOTICEPEARPOLICYJUICE,ZPEACHCOPPERDINNERLAKE,ZSTEELCAREFULPLATENUMBER,\"\n    \"ZGLADSPRAYKIDNEYGUPPY,ZCOMPANYSUMMERFIBERELF,ZTENNISCYCLEBILLOFFICER,\"\n    \"ZIMAGEPENCILOTHERBOTTOM,ZWESTAMOUNTAFFECTHEARING,ZDIVERPAINTLEATHEREASY,\"\n    \"ZSKYSKYCLASSICBRIEF,ZMESSYSULFURDREAMFESTIVE,ZMERRYCRACKTRAINLEADER,\"\n    \"ZBROADABLESOLIDCASUAL,ZGLASSRESERVEBARIUMMEAL,ZTUNEGASBUFFALOCAPITAL,\"\n    \"ZBANKBUFFALORECOVERORBIT,ZTREATTESTQUILLCHARGE,ZBAMBOOMESSWASABIEVENING,\"\n    \"ZREWARDINSIDEMANGOINTENSE,ZEAGLELINEMINEMAIL,ZCALMLYGEMFINISHEFFECT,\"\n    \"ZKEYFAILAPRICOTMETAL,ZFINGERDUEPIZZAOPTION,ZCADETBRIGHTPLANETBANK,\"\n    \"ZGOLDYOUNGINITIALNOSE,ZMISSREPLYHUMANLIVING,ZEIGHTLEADERWORKERMOST,\"\n    \"ZFRAMEENTERSIMPLEMOUTH,ZBIGTHINKCONVERTECONOMY,ZFACEINVITETALKGOLD,\"\n    \"ZPOSTPROTEINHANDLEACTOR,ZHERRINGJOKEFEATUREHOPEFUL,ZCABBAGESOCKEASEMINUTE,\"\n    \"ZMUFFINDRYERDRAWFORTUNE,ZPROBLEMCLUBPOPOVERJELLY,ZGIVEVIVIDDIVINEMEANING,\"\n    \"ZGENENATURALHEARINGKITE,ZGENERALRESORTSKYOPEN,ZLETTUCEBIRDMEETDEBATE,\"\n    \"ZBASEGOUDAREGULARFORGIVE,ZCHARGECLICKHUMANEHIRE,ZPLANETFAMILYPUREMEMORY,\"\n    \"ZMINORWAYPAPERCLASSY,ZCAPYEARLYRIVETBRUSH,ZSIZETOEAWARDFRESH,\"\n    \"ZARSENICSAMPLEWAITMUON,ZSQUAREGLEEFULCHILDLIGHT,ZSHINYASSISTLIVINGCRAB,\"\n    \"ZCORNERANCHORTAPEDIVER,ZDECADEJOYOUSWAVEHABIT,ZTRAVELDRIVERCONTESTLILY,\"\n    \"ZFLYINGDOCTORTABLEMELODY,ZSHARKJUSTFRUITMOVIE,ZFAMILYVISUALOWNERMATTER,\"\n    \"ZFARMERMORNINGMIRRORCONCERN,ZGIFTICEFISHGLUEHAIR,ZOUTSIDEPEAHENCOUNTICE,\"\n    \"ZSPREADMOTORBISCUITBACON,ZWISHHITSKINMOTOR,ZHOLIDAYHEADPONYDETAIL,\"\n    \"ZWOODPOETRYCOBBLERBENCH,ZAIRFORGIVEHEADFROG,ZBROWBALANCEKEYCHOWDER,\"\n    \"ZDISHKEEPBLESTMONITOR,ZCLAMBITARUGULAFAJITA,ZPLIERSPRINTASKOREGANO,\"\n    \"ZRADIANTWHENTRYCARD,ZDELAYOUTCOMEHORNAGENCY,ZPURECAKEVIVIDNEATLY,\"\n    \"ZPATTERNCLORINEGRANDCOLBY,ZHANDYREPAIRPROTONAIRPORT,ZAGEREEDFROGBASKET,\"\n    \"ZSORTMISTYQUOTECABBAGE,ZFOOTTAPWORDENTRY,ZRESOLVEWRISTWRAPAPPLE,\"\n    \"ZDILLASKHOKILEMON,ZFILLSTOPLAWJOYFUL,ZACTIONRANGEELEGANTNEUTRON,\"\n    \"ZRESORTYARDGREENLET,ZCREAMEVENINGLIPBRANCH,ZWHALEMATHAVOCADOCOPPER,\"\n    \"ZGRAYSURVEYWIRELOVE,ZBELLYCRASHITEMLACK,ZHANGERLITHIUMDINNERMEET,\"\n    \"ZCARRYFLOORMINNOWDRAGON,ZMALLEQUIPTHANKSGLUE,ZTERMFITTINGHOUSINGCOMMAND,\"\n    \"ZONERELEASEAVERAGENURSE,ZLACEADDRESSGROUNDCAREFUL\"\n    \" FROM ZLOOKSLIKECOREDATA WHERE ZPK=?1;\"\n  );\n  for(i=0; i<n; i++){\n    x1 = speedtest1_random()%nRow;\n    sqlite3_bind_int(g.pStmt, 1, x1);\n    speedtest1_run();\n  }\n  speedtest1_end_test();\n}\n\n/*\n** A testset used for debugging speedtest1 itself.\n*/\nvoid testset_debug1(void){\n  unsigned i, n;\n  unsigned x1, x2;\n  char zNum[2000];              /* A number name */\n\n  n = g.szTest;\n  for(i=1; i<=n; i++){\n    x1 = swizzle(i, n);\n    x2 = swizzle(x1, n);\n    speedtest1_numbername(x1, zNum, sizeof(zNum));\n    printf(\"%5d %5d %5d %s\\n\", i, x1, x2, zNum);\n  }\n}\n\n#ifdef __linux__\n#include <sys/types.h>\n#include <unistd.h>\n\n/*\n** Attempt to display I/O stats on Linux using /proc/PID/io\n*/\nstatic void displayLinuxIoStats(FILE *out){\n  FILE *in;\n  char z[200];\n  sqlite3_snprintf(sizeof(z), z, \"/proc/%d/io\", getpid());\n  in = fopen(z, \"rb\");\n  if( in==0 ) return;\n  while( fgets(z, sizeof(z), in)!=0 ){\n    static const struct {\n      const char *zPattern;\n      const char *zDesc;\n    } aTrans[] = {\n      { \"rchar: \",                  \"Bytes received by read():\" },\n      { \"wchar: \",                  \"Bytes sent to write():\"    },\n      { \"syscr: \",                  \"Read() system calls:\"      },\n      { \"syscw: \",                  \"Write() system calls:\"     },\n      { \"read_bytes: \",             \"Bytes rcvd from storage:\"  },\n      { \"write_bytes: \",            \"Bytes sent to storage:\"    },\n      { \"cancelled_write_bytes: \",  \"Cancelled write bytes:\"    },\n    };\n    int i;\n    for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){\n      int n = (int)strlen(aTrans[i].zPattern);\n      if( strncmp(aTrans[i].zPattern, z, n)==0 ){\n        fprintf(out, \"-- %-28s %s\", aTrans[i].zDesc, &z[n]);\n        break;\n      }\n    }\n  }\n  fclose(in);\n}   \n#endif\n\n#if SQLITE_VERSION_NUMBER<3006018\n#  define sqlite3_sourceid(X) \"(before 3.6.18)\"\n#endif\n\nstatic int xCompileOptions(void *pCtx, int nVal, char **azVal, char **azCol){\n  printf(\"-- Compile option: %s\\n\", azVal[0]);\n  return SQLITE_OK;\n}\n\nint main(int argc, char **argv){\n  int doAutovac = 0;            /* True for --autovacuum */\n  int cacheSize = 0;            /* Desired cache size.  0 means default */\n  int doExclusive = 0;          /* True for --exclusive */\n  int nHeap = 0, mnHeap = 0;    /* Heap size from --heap */\n  int doIncrvac = 0;            /* True for --incrvacuum */\n  const char *zJMode = 0;       /* Journal mode */\n  const char *zKey = 0;         /* Encryption key */\n  int nLook = -1, szLook = 0;   /* --lookaside configuration */\n  int noSync = 0;               /* True for --nosync */\n  int pageSize = 0;             /* Desired page size.  0 means default */\n  int nPCache = 0, szPCache = 0;/* --pcache configuration */\n  int doPCache = 0;             /* True if --pcache is seen */\n  int showStats = 0;            /* True for --stats */\n  int nThread = 0;              /* --threads value */\n  int mmapSize = 0;             /* How big of a memory map to use */\n  const char *zTSet = \"main\";   /* Which --testset torun */\n  int doTrace = 0;              /* True for --trace */\n  const char *zEncoding = 0;    /* --utf16be or --utf16le */\n  const char *zDbName = 0;      /* Name of the test database */\n\n  void *pHeap = 0;              /* Allocated heap space */\n  void *pLook = 0;              /* Allocated lookaside space */\n  void *pPCache = 0;            /* Allocated storage for pcache */\n  int iCur, iHi;                /* Stats values, current and \"highwater\" */\n  int i;                        /* Loop counter */\n  int rc;                       /* API return code */\n\n  /* Display the version of SQLite being tested */\n  printf(\"-- Speedtest1 for SQLite %s %.50s\\n\",\n         sqlite3_libversion(), sqlite3_sourceid());\n\n  /* Process command-line arguments */\n  g.zWR = \"\";\n  g.zNN = \"\";\n  g.zPK = \"UNIQUE\";\n  g.szTest = 100;\n  g.nRepeat = 1;\n  for(i=1; i<argc; i++){\n    const char *z = argv[i];\n    if( z[0]=='-' ){\n      do{ z++; }while( z[0]=='-' );\n      if( strcmp(z,\"autovacuum\")==0 ){\n        doAutovac = 1;\n      }else if( strcmp(z,\"cachesize\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        i++;\n        cacheSize = integerValue(argv[i]);\n      }else if( strcmp(z,\"exclusive\")==0 ){\n        doExclusive = 1;\n      }else if( strcmp(z,\"explain\")==0 ){\n        g.bSqlOnly = 1;\n        g.bExplain = 1;\n      }else if( strcmp(z,\"heap\")==0 ){\n        if( i>=argc-2 ) fatal_error(\"missing arguments on %s\\n\", argv[i]);\n        nHeap = integerValue(argv[i+1]);\n        mnHeap = integerValue(argv[i+2]);\n        i += 2;\n      }else if( strcmp(z,\"incrvacuum\")==0 ){\n        doIncrvac = 1;\n      }else if( strcmp(z,\"journal\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        zJMode = argv[++i];\n      }else if( strcmp(z,\"key\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        zKey = argv[++i];\n      }else if( strcmp(z,\"lookaside\")==0 ){\n        if( i>=argc-2 ) fatal_error(\"missing arguments on %s\\n\", argv[i]);\n        nLook = integerValue(argv[i+1]);\n        szLook = integerValue(argv[i+2]);\n        i += 2;\n#if SQLITE_VERSION_NUMBER>=3006000\n      }else if( strcmp(z,\"multithread\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n      }else if( strcmp(z,\"nomemstat\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);\n#endif\n#if SQLITE_VERSION_NUMBER>=3007017\n      }else if( strcmp(z, \"mmap\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        mmapSize = integerValue(argv[++i]);\n #endif\n      }else if( strcmp(z,\"nosync\")==0 ){\n        noSync = 1;\n      }else if( strcmp(z,\"notnull\")==0 ){\n        g.zNN = \"NOT NULL\";\n      }else if( strcmp(z,\"pagesize\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        pageSize = integerValue(argv[++i]);\n      }else if( strcmp(z,\"pcache\")==0 ){\n        if( i>=argc-2 ) fatal_error(\"missing arguments on %s\\n\", argv[i]);\n        nPCache = integerValue(argv[i+1]);\n        szPCache = integerValue(argv[i+2]);\n        doPCache = 1;\n        i += 2;\n      }else if( strcmp(z,\"primarykey\")==0 ){\n        g.zPK = \"PRIMARY KEY\";\n      }else if( strcmp(z,\"repeat\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing arguments on %s\\n\", argv[i]);\n        g.nRepeat = integerValue(argv[i+1]);\n        i += 1;\n      }else if( strcmp(z,\"reprepare\")==0 ){\n        g.bReprepare = 1;\n#if SQLITE_VERSION_NUMBER>=3006000\n      }else if( strcmp(z,\"serialized\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_SERIALIZED);\n      }else if( strcmp(z,\"singlethread\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);\n#endif\n      }else if( strcmp(z,\"sqlonly\")==0 ){\n        g.bSqlOnly = 1;\n      }else if( strcmp(z,\"shrink-memory\")==0 ){\n        g.bMemShrink = 1;\n      }else if( strcmp(z,\"size\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        g.szTest = integerValue(argv[++i]);\n      }else if( strcmp(z,\"stats\")==0 ){\n        showStats = 1;\n      }else if( strcmp(z,\"temp\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        i++;\n        if( argv[i][0]<'0' || argv[i][0]>'9' || argv[i][1]!=0 ){\n          fatal_error(\"argument to --temp should be integer between 0 and 9\");\n        }\n        g.eTemp = argv[i][0] - '0';\n      }else if( strcmp(z,\"testset\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        zTSet = argv[++i];\n      }else if( strcmp(z,\"trace\")==0 ){\n        doTrace = 1;\n      }else if( strcmp(z,\"threads\")==0 ){\n        if( i>=argc-1 ) fatal_error(\"missing argument on %s\\n\", argv[i]);\n        nThread = integerValue(argv[++i]);\n      }else if( strcmp(z,\"utf16le\")==0 ){\n        zEncoding = \"utf16le\";\n      }else if( strcmp(z,\"utf16be\")==0 ){\n        zEncoding = \"utf16be\";\n      }else if( strcmp(z,\"verify\")==0 ){\n        g.bVerify = 1;\n      }else if( strcmp(z,\"without-rowid\")==0 ){\n        g.zWR = \"WITHOUT ROWID\";\n        g.zPK = \"PRIMARY KEY\";\n      }else if( strcmp(z, \"help\")==0 || strcmp(z,\"?\")==0 ){\n        printf(zHelp, argv[0]);\n        exit(0);\n      }else{\n        fatal_error(\"unknown option: %s\\nUse \\\"%s -?\\\" for help\\n\",\n                    argv[i], argv[0]);\n      }\n    }else if( zDbName==0 ){\n      zDbName = argv[i];\n    }else{\n      fatal_error(\"surplus argument: %s\\nUse \\\"%s -?\\\" for help\\n\",\n                  argv[i], argv[0]);\n    }\n  }\n  if( zDbName!=0 ) unlink(zDbName);\n#if SQLITE_VERSION_NUMBER>=3006001\n  if( nHeap>0 ){\n    pHeap = malloc( nHeap );\n    if( pHeap==0 ) fatal_error(\"cannot allocate %d-byte heap\\n\", nHeap);\n    rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap);\n    if( rc ) fatal_error(\"heap configuration failed: %d\\n\", rc);\n  }\n  if( doPCache ){\n    if( nPCache>0 && szPCache>0 ){\n      pPCache = malloc( nPCache*(sqlite3_int64)szPCache );\n      if( pPCache==0 ) fatal_error(\"cannot allocate %lld-byte pcache\\n\",\n                                   nPCache*(sqlite3_int64)szPCache);\n    }\n    rc = sqlite3_config(SQLITE_CONFIG_PAGECACHE, pPCache, szPCache, nPCache);\n    if( rc ) fatal_error(\"pcache configuration failed: %d\\n\", rc);\n  }\n  if( nLook>=0 ){\n    sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);\n  }\n#endif\n \n  /* Open the database and the input file */\n  if( sqlite3_open(zDbName, &g.db) ){\n    fatal_error(\"Cannot open database file: %s\\n\", zDbName);\n  }\n#if SQLITE_VERSION_NUMBER>=3006001\n  if( nLook>0 && szLook>0 ){\n    pLook = malloc( nLook*szLook );\n    rc = sqlite3_db_config(g.db, SQLITE_DBCONFIG_LOOKASIDE, pLook, szLook,nLook);\n    if( rc ) fatal_error(\"lookaside configuration failed: %d\\n\", rc);\n  }\n#endif\n\n  /* Set database connection options */\n  sqlite3_create_function(g.db, \"random\", 0, SQLITE_UTF8, 0, randomFunc, 0, 0);\n#ifndef SQLITE_OMIT_DEPRECATED\n  if( doTrace ) sqlite3_trace(g.db, traceCallback, 0);\n#endif\n  if( mmapSize>0 ){\n    speedtest1_exec(\"PRAGMA mmap_size=%d\", mmapSize);\n  }\n  speedtest1_exec(\"PRAGMA threads=%d\", nThread);\n  if( zKey ){\n    speedtest1_exec(\"PRAGMA key('%s')\", zKey);\n  }\n  if( zEncoding ){\n    speedtest1_exec(\"PRAGMA encoding=%s\", zEncoding);\n  }\n  if( doAutovac ){\n    speedtest1_exec(\"PRAGMA auto_vacuum=FULL\");\n  }else if( doIncrvac ){\n    speedtest1_exec(\"PRAGMA auto_vacuum=INCREMENTAL\");\n  }\n  if( pageSize ){\n    speedtest1_exec(\"PRAGMA page_size=%d\", pageSize);\n  }\n  if( cacheSize ){\n    speedtest1_exec(\"PRAGMA cache_size=%d\", cacheSize);\n  }\n  if( noSync ) speedtest1_exec(\"PRAGMA synchronous=OFF\");\n  if( doExclusive ){\n    speedtest1_exec(\"PRAGMA locking_mode=EXCLUSIVE\");\n  }\n  if( zJMode ){\n    speedtest1_exec(\"PRAGMA journal_mode=%s\", zJMode);\n  }\n\n  if( g.bExplain ) printf(\".explain\\n.echo on\\n\");\n  if( strcmp(zTSet,\"main\")==0 ){\n    testset_main();\n  }else if( strcmp(zTSet,\"debug1\")==0 ){\n    testset_debug1();\n  }else if( strcmp(zTSet,\"orm\")==0 ){\n    testset_orm();\n  }else if( strcmp(zTSet,\"cte\")==0 ){\n    testset_cte();\n  }else if( strcmp(zTSet,\"rtree\")==0 ){\n#ifdef SQLITE_ENABLE_RTREE\n    testset_rtree(6, 147);\n#else\n    fatal_error(\"compile with -DSQLITE_ENABLE_RTREE to enable \"\n                \"the R-Tree tests\\n\");\n#endif\n  }else{\n    fatal_error(\"unknown testset: \\\"%s\\\"\\nChoices: main debug1 cte rtree\\n\",\n                 zTSet);\n  }\n  speedtest1_final();\n\n  if( showStats ){\n    sqlite3_exec(g.db, \"PRAGMA compile_options\", xCompileOptions, 0, 0);\n  }\n\n  /* Database connection statistics printed after both prepared statements\n  ** have been finalized */\n#if SQLITE_VERSION_NUMBER>=3007009\n  if( showStats ){\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHi, 0);\n    printf(\"-- Lookaside Slots Used:        %d (max %d)\\n\", iCur,iHi);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHi, 0);\n    printf(\"-- Successful lookasides:       %d\\n\", iHi);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHi,0);\n    printf(\"-- Lookaside size faults:       %d\\n\", iHi);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHi,0);\n    printf(\"-- Lookaside OOM faults:        %d\\n\", iHi);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHi, 0);\n    printf(\"-- Pager Heap Usage:            %d bytes\\n\", iCur);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHi, 1);\n    printf(\"-- Page cache hits:             %d\\n\", iCur);\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHi, 1);\n    printf(\"-- Page cache misses:           %d\\n\", iCur);\n#if SQLITE_VERSION_NUMBER>=3007012\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHi, 1);\n    printf(\"-- Page cache writes:           %d\\n\", iCur); \n#endif\n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHi, 0);\n    printf(\"-- Schema Heap Usage:           %d bytes\\n\", iCur); \n    sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0);\n    printf(\"-- Statement Heap Usage:        %d bytes\\n\", iCur); \n  }\n#endif\n\n  sqlite3_close(g.db);\n\n#if SQLITE_VERSION_NUMBER>=3006001\n  /* Global memory usage statistics printed after the database connection\n  ** has closed.  Memory usage should be zero at this point. */\n  if( showStats ){\n    sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHi, 0);\n    printf(\"-- Memory Used (bytes):         %d (max %d)\\n\", iCur,iHi);\n#if SQLITE_VERSION_NUMBER>=3007000\n    sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHi, 0);\n    printf(\"-- Outstanding Allocations:     %d (max %d)\\n\", iCur,iHi);\n#endif\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHi, 0);\n    printf(\"-- Pcache Overflow Bytes:       %d (max %d)\\n\", iCur,iHi);\n    sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0);\n    printf(\"-- Largest Allocation:          %d bytes\\n\",iHi);\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0);\n    printf(\"-- Largest Pcache Allocation:   %d bytes\\n\",iHi);\n  }\n#endif\n\n#ifdef __linux__\n  if( showStats ){\n    displayLinuxIoStats(stdout);\n  }\n#endif\n\n  /* Release memory */\n  free( pLook );\n  free( pPCache );\n  free( pHeap );\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/spellfix.test",
    "content": "# 2012 July 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix spellfix\n\nifcapable !vtab { finish_test ; return }\n\nload_static_extension db spellfix nextchar\n\nset vocab {\nrabbi rabbit rabbits rabble rabid rabies raccoon raccoons race raced racer\nracers races racetrack racial racially racing rack racked racket racketeer\nracketeering racketeers rackets racking racks radar radars radial radially\nradian radiance radiant radiantly radiate radiated radiates radiating radiation\nradiations radiator radiators radical radically radicals radices radii radio\nradioactive radioastronomy radioed radiography radioing radiology radios radish\nradishes radium radius radix radon raft rafter rafters rafts rag rage raged\nrages ragged raggedly raggedness raging rags ragweed raid raided raider raiders\nraiding raids rail railed railer railers railing railroad railroaded railroader\nrailroaders railroading railroads rails railway railways raiment rain rainbow\nraincoat raincoats raindrop raindrops rained rainfall rainier rainiest raining\nrains rainstorm rainy raise raised raiser raisers raises raisin raising rake\nraked rakes raking rallied rallies rally rallying ram ramble rambler rambles\nrambling ramblings ramification ramifications ramp rampage rampant rampart\nramps ramrod rams ran ranch ranched rancher ranchers ranches ranching rancid\nrandom randomization randomize randomized randomizes randomly randomness randy\nrang range ranged rangeland ranger rangers ranges ranging rangy rank ranked\nranker rankers rankest ranking rankings rankle rankly rankness ranks ransack\nransacked ransacking ransacks ransom ransomer ransoming ransoms rant ranted\nranter ranters ranting rants rap rapacious rape raped raper rapes rapid\nrapidity rapidly rapids rapier raping rapport rapprochement raps rapt raptly\nrapture raptures rapturous rare rarely rareness rarer rarest rarity rascal\nrascally rascals rash rasher rashly rashness rasp raspberry rasped rasping\nrasps raster rat rate rated rater raters rates rather ratification ratified\nratifies ratify ratifying rating ratings ratio ration rational rationale\nrationales rationalities rationality rationalization rationalizations\nrationalize rationalized rationalizes rationalizing rationally rationals\nrationing rations ratios rats rattle rattled rattler rattlers rattles\nrattlesnake rattlesnakes rattling raucous ravage ravaged ravager ravagers\nravages ravaging rave raved raven ravening ravenous ravenously ravens raves\nravine ravines raving ravings raw rawer rawest rawly rawness ray rays raze\nrazor razors re reabbreviate reabbreviated reabbreviates reabbreviating reach\nreachability reachable reachably reached reacher reaches reaching reacquired\nreact reacted reacting reaction reactionaries reactionary reactions reactivate\nreactivated reactivates reactivating reactivation reactive reactively\nreactivity reactor reactors reacts read readability readable reader readers\nreadied readier readies readiest readily readiness reading readings readjusted\nreadout readouts reads ready readying real realest realign realigned realigning\nrealigns realism realist realistic realistically realists realities reality\n}\n\ndo_test 1.1 {\n  execsql { CREATE VIRTUAL TABLE t1 USING spellfix1 }\n  foreach word $vocab {\n    execsql { INSERT INTO t1(word) VALUES($word) }\n  }\n} {}\n\nforeach {tn word res} {\n  1   raxpi*     {rasping 5 rasped 5 ragweed 5 raspberry 6 rasp 4}\n  2   ril*       {rail 4 railed 4 railer 4 railers 4 railing 4}\n  3   rilis*     {realism 6 realist 6 realistic 6 realistically 6 realists 6}\n  4   reail*     {real 3 realest 3 realign 3 realigned 3 realigning 3}\n  5   ras*       {rascal 3 rascally 3 rascals 3 rash 3 rasher 3}\n  6   realistss* {realists 8 realigns 8 realistic 9 realistically 9 realest 7}\n  7   realistss  {realists 8 realist 7 realigns 8 realistic 9 realest 7}\n  8   rllation*  {realities 9 reality 7 rallied 7 railed 4}\n  9   renstom*   {rainstorm 8 ransom 6 ransomer 6 ransoming 6 ransoms 6}\n} {\n  do_execsql_test 1.2.$tn {\n    SELECT word, matchlen FROM t1 WHERE word MATCH $word \n     ORDER BY score, word LIMIT 5\n  } $res\n}\n\n# Tests of the next_char function.\n#\ndo_test 1.10 {\n  db eval {\n    CREATE TABLE vocab(w TEXT PRIMARY KEY);\n    INSERT INTO vocab SELECT word FROM t1;\n  }\n} {}\ndo_execsql_test 1.11 {\n  SELECT next_char('re','vocab','w');\n} {a}\ndo_execsql_test 1.11sub {\n  SELECT next_char('re','(SELECT w AS x FROM vocab)','x');\n} {a}\ndo_execsql_test 1.12 {\n  SELECT next_char('r','vocab','w');\n} {ae}\ndo_execsql_test 1.13 {\n  SELECT next_char('','vocab','w');\n} {r}\ndo_test 1.14 {\n  catchsql {SELECT next_char('','xyzzy','a')}\n} {1 {no such table: xyzzy}}\n\ndo_execsql_test 1.20 {\n  CREATE TABLE vocab2(w TEXT);\n  CREATE INDEX vocab2w ON vocab2(w COLLATE nocase);\n  INSERT INTO vocab2 VALUES('abc'), ('ABD'), ('aBe'), ('AbF');\n  SELECT next_char('ab', 'vocab2', 'w', null, 'nocase');\n} {cDeF}\ndo_execsql_test 1.21 {\n  SELECT next_char('ab','vocab2','w',null,null);\n} {c}\ndo_execsql_test 1.22 {\n  SELECT next_char('AB','vocab2','w',null,'NOCASE');\n} {cDeF}\ndo_execsql_test 1.23 {\n  SELECT next_char('ab','vocab2','w',null,'binary');\n} {c}\n\ndo_execsql_test 1.30 {\n  SELECT rowid FROM t1 WHERE word='rabbit';\n} {2}\ndo_execsql_test 1.31 {\n  UPDATE t1 SET rowid=2000 WHERE word='rabbit';\n  SELECT rowid FROM t1 WHERE word='rabbit';\n} {2000}\ndo_execsql_test 1.32 {\n  INSERT INTO t1(rowid, word) VALUES(3000,'melody');\n  SELECT rowid, word, matchlen FROM t1 WHERE word MATCH 'melotti'\n   ORDER BY score LIMIT 3;\n} {3000 melody 6}\ndo_test 1.33 {\n  catchsql {INSERT INTO t1(rowid, word) VALUES(3000,'garden');}\n} {1 {constraint failed}}\n\ndo_execsql_test 2.1 {\n  CREATE VIRTUAL TABLE t2 USING spellfix1;\n  INSERT INTO t2 (word, soundslike) VALUES('school', 'skuul');\n  INSERT INTO t2 (word, soundslike) VALUES('psalm', 'sarm');\n  SELECT word, matchlen FROM t2 WHERE word MATCH 'sar*' LIMIT 5;\n} {psalm 4}\n\ndo_execsql_test 2.2 {\n  SELECT word, matchlen FROM t2 WHERE word MATCH 'skol*' LIMIT 5;\n} {school 6}\n\nset vocab {\nkangaroo kanji kappa karate keel keeled keeling keels keen keener keenest\nkeenly keenness keep keeper keepers keeping keeps ken kennel kennels kept\nkerchief kerchiefs kern kernel kernels kerosene ketchup kettle\nkettles key keyboard keyboards keyed keyhole keying keynote keypad keypads keys\nkeystroke keystrokes keyword keywords kick kicked kicker kickers kicking\nkickoff kicks kid kidded kiddie kidding kidnap kidnapper kidnappers kidnapping\nkidnappings kidnaps kidney kidneys kids kill killed killer killers killing\nkillingly killings killjoy kills kilobit kilobits kiloblock kilobyte kilobytes\nkilogram kilograms kilohertz kilohm kilojoule kilometer kilometers kiloton\nkilovolt kilowatt kiloword kimono kin kind kinder kindergarten kindest\nkindhearted kindle kindled kindles kindling kindly kindness kindred kinds\nkinetic king kingdom kingdoms kingly kingpin kings kink kinky kinship kinsman\nkiosk kiss kissed kisser kissers kisses kissing kit kitchen kitchenette\nkitchens kite kited kites kiting kits kitten kittenish kittens kitty klaxon\nkludge kludges klystron knack knapsack knapsacks knave knaves knead kneads knee\nkneecap kneed kneeing kneel kneeled kneeling kneels knees knell knells knelt\nknew knife knifed knifes knifing knight knighted knighthood knighting knightly\nknights knit knits knives knob knobs knock knockdown knocked knocker knockers\nknocking knockout knocks knoll knolls knot knots knotted knotting know knowable\nknower knowhow knowing knowingly knowledge knowledgeable known knows knuckle\nknuckled knuckles koala kosher kudo\n}\n\ndo_execsql_test 3.1 {\n  CREATE TABLE costs(iLang, cFrom, cTo, iCost);\n  INSERT INTO costs VALUES(0, 'a', 'e', 1);\n  INSERT INTO costs VALUES(0, 'e', 'i', 1);\n  INSERT INTO costs VALUES(0, 'i', 'o', 1);\n  INSERT INTO costs VALUES(0, 'o', 'u', 1);\n  INSERT INTO costs VALUES(0, 'u', 'a', 1);\n  CREATE VIRTUAL TABLE t3 USING spellfix1(edit_cost_table=costs);\n}\n\ndo_test 3.2 {\n  foreach w $vocab {\n    execsql { INSERT INTO t3(word) VALUES($w) }\n  }\n} {}\n\nforeach {tn word res} {\n  1   kos*     {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3}\n  2   kellj*   {killjoy 5 kill 4 killed 4 killer 4 killers 4}\n  3   kellj    {kill 4 kills 5 killjoy 7 keel 4 killed 6}\n} {\n  do_execsql_test 3.2.$tn {\n    SELECT word, matchlen FROM t3 WHERE word MATCH $word\n     ORDER BY score, word LIMIT 5\n  } $res\n}\n\ndo_execsql_test 4.0 {\n  INSERT INTO t3(command) VALUES('edit_cost_table=NULL');\n}\nforeach {tn word res} {\n  1   kosher     {kosher 0 kisser 51 kissers 76 kissed 126 kisses 126}\n  2   kellj      {keels 60 killjoy 68 kills 80 keel 120 kill 125}\n  3   kashar     {kosher 80 kisser 91 kissers 116 kissed 166 kisses 166}\n} {\n  do_execsql_test 4.1.$tn {\n    SELECT word, distance FROM t3 WHERE word MATCH $word\n     ORDER BY score, word LIMIT 5\n  } $res\n}\ndo_execsql_test 5.0 {\n  CREATE TABLE costs2(iLang, cFrom, cTo, iCost);\n  INSERT INTO costs2 VALUES(0, 'a', 'o', 1);\n  INSERT INTO costs2 VALUES(0, 'e', 'o', 4);\n  INSERT INTO costs2 VALUES(0, 'i', 'o', 8);\n  INSERT INTO costs2 VALUES(0, 'u', 'o', 16);\n  INSERT INTO t3(command) VALUES('edit_cost_table=\"costs2\"');\n}\n\nforeach {tn word res} {\n  1   kasher     {kosher 1}\n  2   kesher     {kosher 4}\n  3   kisher     {kosher 8}\n  4   kosher     {kosher 0}\n  5   kusher     {kosher 16}\n} {\n  do_execsql_test 5.1.$tn {\n    SELECT word, distance FROM t3 WHERE word MATCH $word\n     ORDER BY score, word LIMIT 1\n  } $res\n}\n\n#-------------------------------------------------------------------------\n# Try some queries by rowid.\n#\ndo_execsql_test 6.1.1 {\n  SELECT word FROM t3 WHERE rowid = 10;\n} {keener}\ndo_execsql_test 6.1.2 {\n  SELECT word, distance FROM t3 WHERE rowid = 10;\n} {keener {}}\ndo_execsql_test 6.1.3 {\n  SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner';\n} {keener 300}\n\nifcapable trace {\n  proc trace_callback {sql} {\n    if {[string range $sql 0 2] == \"-- \"} {\n      lappend ::trace [string range $sql 3 end]\n    }\n  }\n  \n  proc do_tracesql_test {tn sql {res {}}} {\n    set ::trace [list]\n    uplevel [list do_test $tn [subst -nocommands {\n      set vals [execsql {$sql}]\n      concat [set vals] [set ::trace]\n    }] [list {*}$res]]\n  }\n  \n  db trace trace_callback\n  do_tracesql_test 6.2.1 {\n    SELECT word FROM t3 WHERE rowid = 10;\n  } {keener\n    {SELECT word, rank, NULL, langid, id FROM \"main\".\"t3_vocab\" WHERE rowid=?}\n  }\n  do_tracesql_test 6.2.2 {\n    SELECT word, distance FROM t3 WHERE rowid = 10;\n  } {keener {}\n    {SELECT word, rank, NULL, langid, id FROM \"main\".\"t3_vocab\" WHERE rowid=?}\n  }\n  do_tracesql_test 6.2.3 {\n    SELECT word, distance FROM t3 WHERE rowid = 10 AND word MATCH 'kiiner';\n  } {keener 300\n    {SELECT id, word, rank, k1  FROM \"main\".\"t3_vocab\" WHERE langid=0 AND k2>=?1 AND k2<?2}\n  }\n}\n\n#------------------------------------------------------------------------- \n# Test that the spellfix1 table supports conflict handling (OR REPLACE \n# and so on).\n#\ndo_execsql_test 7.1 {\n  CREATE VIRTUAL TABLE t4 USING spellfix1;\n  PRAGMA table_info = t4;\n} {\n  0 word {} 0 {} 0 \n  1 rank {} 0 {} 0 \n  2 distance {} 0 {} 0 \n  3 langid {} 0 {} 0 \n  4 score {} 0 {} 0 \n  5 matchlen {} 0 {} 0\n}\n\ndo_execsql_test 7.2.1 {\n  INSERT INTO t4(rowid, word) VALUES(1, 'Archilles');\n  INSERT INTO t4(rowid, word) VALUES(2, 'Pluto');\n  INSERT INTO t4(rowid, word) VALUES(3, 'Atrides');\n  INSERT OR REPLACE INTO t4(rowid, word) VALUES(2, 'Apollo');\n  SELECT rowid, word FROM t4;\n} {\n  1 Archilles   2 Apollo   3 Atrides\n}\ndo_catchsql_test 7.2.2 {\n  INSERT OR ABORT INTO t4(rowid, word) VALUES(1, 'Leto');\n} {1 {constraint failed}}\ndo_catchsql_test 7.2.3 {\n  INSERT OR ROLLBACK INTO t4(rowid, word) VALUES(3, 'Zeus');\n} {1 {constraint failed}}\ndo_catchsql_test 7.2.4 {\n  INSERT OR FAIL INTO t4(rowid, word) VALUES(3, 'Zeus');\n} {1 {constraint failed}}\ndo_execsql_test 7.2.5 {\n  INSERT OR IGNORE INTO t4(rowid, word) VALUES(3, 'Zeus');\n  SELECT rowid, word FROM t4;\n} {\n  1 Archilles   2 Apollo   3 Atrides\n}\n\ndo_execsql_test 7.3.1 {\n  UPDATE OR REPLACE t4 SET rowid=3 WHERE rowid=1;\n  SELECT rowid, word FROM t4;\n} {2 Apollo 3 Archilles}\ndo_catchsql_test 7.3.2 {\n  UPDATE OR ABORT t4 SET rowid=3 WHERE rowid=2;\n} {1 {constraint failed}}\ndo_catchsql_test 7.3.3 {\n  UPDATE OR ROLLBACK t4 SET rowid=3 WHERE rowid=2;\n} {1 {constraint failed}}\ndo_catchsql_test 7.3.4 {\n  UPDATE OR FAIL t4 SET rowid=3 WHERE rowid=2;\n} {1 {constraint failed}}\ndo_execsql_test 7.3.5 {\n  UPDATE OR IGNORE t4 SET rowid=3 WHERE rowid=2;\n  SELECT rowid, word FROM t4;\n} {2 Apollo  3 Archilles}\n\ndo_execsql_test 7.4.1 {\n  DELETE FROM t4;\n  INSERT INTO t4(rowid, word) VALUES(10, 'Agamemnon');\n  INSERT INTO t4(rowid, word) VALUES(20, 'Patroclus');\n  INSERT INTO t4(rowid, word) VALUES(30, 'Chryses');\n\n  CREATE TABLE t5(i, w);\n  INSERT INTO t5 VALUES(5,  'Poseidon');\n  INSERT INTO t5 VALUES(20, 'Chronos');\n  INSERT INTO t5 VALUES(30, 'Hera');\n}\n\ndb_save_and_close\nforeach {tn conflict err bRollback res} {\n  0 \"\"            {1 {constraint failed}} 0\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  1 \"OR REPLACE\"  {0 {}} 0\n                  {5 Poseidon 10 Agamemnon 20 Chronos 30 Hera}\n  2 \"OR ABORT\"    {1 {constraint failed}} 0\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  3 \"OR ROLLBACK\" {1 {constraint failed}} 1\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  5 \"OR IGNORE\"   {0 {}} 0\n                  {5 Poseidon 10 Agamemnon 20 Patroclus 30 Chryses}\n} {\n  db_restore_and_reopen\n  load_static_extension db spellfix nextchar\n\n  execsql BEGIN\n  set sql \"INSERT $conflict INTO t4(rowid, word) SELECT i, w FROM t5\"\n  do_catchsql_test 7.4.2.$tn.1 $sql $err\n  do_execsql_test 7.4.2.$tn.2 { SELECT rowid, word FROM t4 } $res\n\n  do_test 7.4.2.$tn.3 { sqlite3_get_autocommit db } $bRollback\n  catchsql ROLLBACK\n}\n\nforeach {tn conflict err bRollback res} {\n  0 \"\"            {1 {constraint failed}} 0\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  1 \"OR REPLACE\"  {0 {}} 0\n                  {15 Agamemnon 45 Chryses}\n  2 \"OR ABORT\"    {1 {constraint failed}} 0\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  3 \"OR ROLLBACK\" {1 {constraint failed}} 1\n                  {10 Agamemnon 20 Patroclus 30 Chryses}\n  5 \"OR IGNORE\"   {0 {}} 0\n                  {15 Agamemnon 20 Patroclus 45 Chryses}\n} {\n  db_restore_and_reopen\n  load_static_extension db spellfix nextchar\n\n  execsql BEGIN\n  set sql \"UPDATE $conflict t4 SET rowid=rowid + (rowid/2)\"\n  do_catchsql_test 7.5.2.$tn.1 $sql $err\n  do_execsql_test 7.5.2.$tn.2 { SELECT rowid, word FROM t4 } $res\n  do_test 7.5.2.$tn.3 { sqlite3_get_autocommit db } $bRollback\n  catchsql ROLLBACK\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/spellfix2.test",
    "content": "# 2012 July 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix spellfix2\n\nifcapable !vtab { finish_test ; return }\nload_static_extension db spellfix nextchar\n\ndo_execsql_test 1.0 {\n  CREATE VIRTUAL TABLE demo USING spellfix1;\n  INSERT INTO demo(word) VALUES ('amsterdam');\n  INSERT INTO demo(word) VALUES ('amsterdammetje');\n  INSERT INTO demo(word) VALUES ('amsterdamania');\n  INSERT INTO demo(word) VALUES ('amsterdamweg');\n  INSERT INTO demo(word) VALUES ('amsterdamsestraat');\n  INSERT INTO demo(word) VALUES ('amsterdamlaan');\n}\n\ndo_execsql_test 1.1 {\n  SELECT word, distance, matchlen FROM demo \n  WHERE word MATCH 'amstedam*' AND top=3\n  ORDER BY +word;\n} {\n   amsterdam      100 9\n   amsterdamania  100 9\n   amsterdammetje 100 9\n}\n\ndo_execsql_test 1.2 {\n  SELECT word, distance, matchlen FROM demo WHERE \n  word MATCH 'amstedam*' AND top=3 AND distance <= 100\n  ORDER BY +word;\n} {\n   amsterdam      100 9\n   amsterdamania  100 9\n   amsterdammetje 100 9\n}\n\ndo_execsql_test 1.3 {\n  SELECT word, distance, matchlen FROM demo WHERE \n  word MATCH 'amstedam*' AND distance <= 100\n  ORDER BY +word;\n} {\n   amsterdam         100 9\n   amsterdamania     100 9\n   amsterdamlaan     100 9\n   amsterdammetje    100 9\n   amsterdamsestraat 100 9\n   amsterdamweg      100 9\n}\n\ndo_test 1.4 {\n  foreach l {a b c d e f g h i j k l m n o p q r s t u v w x y z} {\n    execsql { INSERT INTO demo(word) VALUES ('amsterdam' || $l) }\n  }\n} {}\n\ndo_execsql_test 1.5 {\n  SELECT count(*) FROM demo WHERE word MATCH 'amstedam*' AND distance <= 100;\n  SELECT count(*) FROM demo \n  WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20;\n} {\n  32 20\n}\n\ndo_execsql_test 1.6 {\n  SELECT word, distance, matchlen FROM demo \n  WHERE word MATCH 'amstedam*' AND distance <= 100\n  ORDER BY distance, word;\n} {\n  amsterdam         100 9        amsterdama        100 9\n  amsterdamania     100 9        amsterdamb        100 9\n  amsterdamc        100 9        amsterdamd        100 9\n  amsterdame        100 9        amsterdamf        100 9\n  amsterdamg        100 9        amsterdamh        100 9\n  amsterdami        100 9        amsterdamj        100 9\n  amsterdamk        100 9        amsterdaml        100 9\n  amsterdamlaan     100 9        amsterdamm        100 9\n  amsterdammetje    100 9        amsterdamn        100 9\n  amsterdamo        100 9        amsterdamp        100 9\n  amsterdamq        100 9        amsterdamr        100 9\n  amsterdams        100 9        amsterdamsestraat 100 9\n  amsterdamt        100 9        amsterdamu        100 9\n  amsterdamv        100 9        amsterdamw        100 9\n  amsterdamweg      100 9        amsterdamx        100 9\n  amsterdamy        100 9        amsterdamz        100 9\n}\n\ndo_execsql_test 1.7 {\n  SELECT word, distance, matchlen FROM demo \n  WHERE word MATCH 'amstedam*' AND distance <= 100 AND top=20\n  ORDER BY distance, word;\n} {\n  amsterdam         100 9        amsterdama        100 9\n  amsterdamania     100 9        amsterdamb        100 9\n  amsterdamc        100 9        amsterdame        100 9\n  amsterdamf        100 9        amsterdamg        100 9\n  amsterdamh        100 9        amsterdami        100 9\n  amsterdamm        100 9        amsterdammetje    100 9\n  amsterdamn        100 9        amsterdamo        100 9\n  amsterdamp        100 9        amsterdamu        100 9\n  amsterdamv        100 9        amsterdamw        100 9\n  amsterdamweg      100 9        amsterdamy        100 9\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/spellfix3.test",
    "content": "# 2015-12-17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix spellfix3\n\nifcapable !vtab { finish_test ; return }\n\nload_static_extension db spellfix\n\ndo_execsql_test 100 {\n  SELECT spellfix1_scriptcode('And God said, “Let there be light”');\n} {215}\ndo_execsql_test 110 {\n  SELECT spellfix1_scriptcode('Бог сказал: \"Да будет свет\"');\n} {220}\ndo_execsql_test 120 {\n  SELECT spellfix1_scriptcode('και ειπεν ο θεος γενηθητω φως και εγενετο φως');\n} {200}\ndo_execsql_test 130 {\n  SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר אֱלֹהִ֖ים יְהִ֣י א֑וֹר וַֽיְהִי־אֽוֹר׃');\n} {125}\ndo_execsql_test 140 {\n  SELECT spellfix1_scriptcode('فِي ذَلِكَ الوَقتِ، قالَ اللهُ: لِيَكُنْ نُورٌ. فَصَارَ نُورٌ.');\n} {160}\ndo_execsql_test 200 {\n  SELECT spellfix1_scriptcode('+3.14159');\n} {215}\ndo_execsql_test 210 {\n  SELECT spellfix1_scriptcode('And God said: \"Да будет свет\"');\n} {998}\ndo_execsql_test 220 {\n  SELECT spellfix1_scriptcode('+3.14159 light');\n} {215}\ndo_execsql_test 230 {\n  SELECT spellfix1_scriptcode('+3.14159 свет');\n} {220}\ndo_execsql_test 240 {\n  SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר +3.14159');\n} {125}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sqldiff1.test",
    "content": "# 2015-05-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Quick tests for the sqldiff tool\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset PROG [test_find_sqldiff]\n\ndb close\nforcedelete test.db test2.db\nsqlite3 db test.db\n\ndo_test sqldiff-1.0 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    CREATE TABLE t2(a INT PRIMARY KEY, b) WITHOUT ROWID;\n    WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n    INSERT INTO t1(a,b) SELECT x, printf('abc-%d-xyz',x) FROM c;\n    INSERT INTO t2(a,b) SELECT a, b FROM t1;\n  }\n  db backup test2.db\n  db eval {\n    ATTACH 'test2.db' AS x2;\n    DELETE FROM x2.t1 WHERE a=49;\n    DELETE FROM x2.t2 WHERE a=48;\n    INSERT INTO x2.t1(a,b) VALUES(1234,'hello');\n    INSERT INTO x2.t2(a,b) VALUES(50.5,'xyzzy');\n    CREATE TABLE x2.t3(a,b,c);\n    INSERT INTO x2.t3 VALUES(111,222,333);\n    CREATE TABLE main.t4(x,y,z);\n    INSERT INTO t4 SELECT * FROM t3;\n  }\n  set line \"exec $PROG test.db test2.db\"\n  unset -nocomplain ::MSG\n  catch {eval $line} ::MSG\n} {0}\ndo_test sqldiff-1.1 {\n  set ::MSG\n} {DELETE FROM t1 WHERE a=49;\nINSERT INTO t1(a,b) VALUES(1234,'hello');\nDELETE FROM t2 WHERE a=48;\nINSERT INTO t2(a,b) VALUES(50.5,'xyzzy');\nCREATE TABLE t3(a,b,c);\nINSERT INTO t3(rowid,a,b,c) VALUES(1,111,222,333);\nDROP TABLE t4;}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sqllimits1.test",
    "content": "# 2007 May 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests to verify that the limits defined in\n# sqlite source file limits.h are enforced.\n#\n# $Id: sqllimits1.test,v 1.33 2009/06/25 01:47:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Verify that the default per-connection limits are the same as\n# the compile-time hard limits.\n#\nsqlite3 db2 :memory:\ndo_test sqllimits1-1.1 {\n  sqlite3_limit db SQLITE_LIMIT_LENGTH -1\n} $SQLITE_MAX_LENGTH\ndo_test sqllimits1-1.2 {\n  sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1\n} $SQLITE_MAX_SQL_LENGTH\ndo_test sqllimits1-1.3 {\n  sqlite3_limit db SQLITE_LIMIT_COLUMN -1\n} $SQLITE_MAX_COLUMN\ndo_test sqllimits1-1.4 {\n  sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1\n} $SQLITE_MAX_EXPR_DEPTH\ndo_test sqllimits1-1.5 {\n  sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1\n} $SQLITE_MAX_COMPOUND_SELECT\ndo_test sqllimits1-1.6 {\n  sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1\n} $SQLITE_MAX_VDBE_OP\ndo_test sqllimits1-1.7 {\n  sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1\n} $SQLITE_MAX_FUNCTION_ARG\ndo_test sqllimits1-1.8 {\n  sqlite3_limit db SQLITE_LIMIT_ATTACHED -1\n} $SQLITE_MAX_ATTACHED\ndo_test sqllimits1-1.9 {\n  sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1\n} $SQLITE_MAX_LIKE_PATTERN_LENGTH\ndo_test sqllimits1-1.10 {\n  sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1\n} $SQLITE_MAX_VARIABLE_NUMBER\ndo_test sqllimits1-1.11 {\n  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH -1\n} $SQLITE_MAX_TRIGGER_DEPTH\ndo_test sqllimits1-1.12 {\n  sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS 99999\n  sqlite3_limit db SQLITE_LIMIT_WORKER_THREADS -1\n} $SQLITE_MAX_WORKER_THREADS\n\n# Limit parameters out of range.\n#\ndo_test sqllimits1-1.20 {\n  sqlite3_limit db SQLITE_LIMIT_TOOSMALL 123\n} {-1}\ndo_test sqllimits1-1.21 {\n  sqlite3_limit db SQLITE_LIMIT_TOOSMALL 123\n} {-1}\ndo_test sqllimits1-1.22 {\n  sqlite3_limit db SQLITE_LIMIT_TOOBIG 123\n} {-1}\ndo_test sqllimits1-1.23 {\n  sqlite3_limit db SQLITE_LIMIT_TOOBIG 123\n} {-1}\n\n\n# Decrease all limits by half.  Verify that the new limits take.\n#\nif {$SQLITE_MAX_LENGTH>=2} {\n  do_test sqllimits1-2.1.1 {\n    sqlite3_limit db SQLITE_LIMIT_LENGTH \\\n                    [expr {$::SQLITE_MAX_LENGTH/2}]\n  } $SQLITE_MAX_LENGTH\n  do_test sqllimits1-2.1.2 {\n    sqlite3_limit db SQLITE_LIMIT_LENGTH -1\n  } [expr {$SQLITE_MAX_LENGTH/2}]\n}\nif {$SQLITE_MAX_SQL_LENGTH>=2} {\n  do_test sqllimits1-2.2.1 {\n    sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH \\\n                    [expr {$::SQLITE_MAX_SQL_LENGTH/2}]\n  } $SQLITE_MAX_SQL_LENGTH\n  do_test sqllimits1-2.2.2 {\n    sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1\n  } [expr {$SQLITE_MAX_SQL_LENGTH/2}]\n}\nif {$SQLITE_MAX_COLUMN>=2} {\n  do_test sqllimits1-2.3.1 {\n    sqlite3_limit db SQLITE_LIMIT_COLUMN \\\n                    [expr {$::SQLITE_MAX_COLUMN/2}]\n  } $SQLITE_MAX_COLUMN\n  do_test sqllimits1-2.3.2 {\n    sqlite3_limit db SQLITE_LIMIT_COLUMN -1\n  } [expr {$SQLITE_MAX_COLUMN/2}]\n}\nif {$SQLITE_MAX_EXPR_DEPTH>=2} {\n  do_test sqllimits1-2.4.1 {\n    sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH \\\n                    [expr {$::SQLITE_MAX_EXPR_DEPTH/2}]\n  } $SQLITE_MAX_EXPR_DEPTH\n  do_test sqllimits1-2.4.2 {\n    sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1\n  } [expr {$SQLITE_MAX_EXPR_DEPTH/2}]\n}\nif {$SQLITE_MAX_COMPOUND_SELECT>=2} {\n  do_test sqllimits1-2.5.1 {\n    sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT \\\n                    [expr {$::SQLITE_MAX_COMPOUND_SELECT/2}]\n  } $SQLITE_MAX_COMPOUND_SELECT\n  do_test sqllimits1-2.5.2 {\n    sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1\n  } [expr {$SQLITE_MAX_COMPOUND_SELECT/2}]\n}\nif {$SQLITE_MAX_VDBE_OP>=2} {\n  do_test sqllimits1-2.6.1 {\n    sqlite3_limit db SQLITE_LIMIT_VDBE_OP \\\n                    [expr {$::SQLITE_MAX_VDBE_OP/2}]\n  } $SQLITE_MAX_VDBE_OP\n  do_test sqllimits1-2.6.2 {\n    sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1\n  } [expr {$SQLITE_MAX_VDBE_OP/2}]\n}\nif {$SQLITE_MAX_FUNCTION_ARG>=2} {\n  do_test sqllimits1-2.7.1 {\n    sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG \\\n                    [expr {$::SQLITE_MAX_FUNCTION_ARG/2}]\n  } $SQLITE_MAX_FUNCTION_ARG\n  do_test sqllimits1-2.7.2 {\n    sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1\n  } [expr {$SQLITE_MAX_FUNCTION_ARG/2}]\n}\nif {$SQLITE_MAX_ATTACHED>=2} {\n  do_test sqllimits1-2.8.1 {\n    sqlite3_limit db SQLITE_LIMIT_ATTACHED \\\n                    [expr {$::SQLITE_MAX_ATTACHED/2}]\n  } $SQLITE_MAX_ATTACHED\n  do_test sqllimits1-2.8.2 {\n    sqlite3_limit db SQLITE_LIMIT_ATTACHED -1\n  } [expr {$SQLITE_MAX_ATTACHED/2}]\n}\nif {$SQLITE_MAX_LIKE_PATTERN_LENGTH>=2} {\n  do_test sqllimits1-2.9.1 {\n    sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH \\\n                    [expr {$::SQLITE_MAX_LIKE_PATTERN_LENGTH/2}]\n  } $SQLITE_MAX_LIKE_PATTERN_LENGTH\n  do_test sqllimits1-2.9.2 {\n    sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1\n  } [expr {$SQLITE_MAX_LIKE_PATTERN_LENGTH/2}]\n}\nif {$SQLITE_MAX_VARIABLE_NUMBER>=2} {\n  do_test sqllimits1-2.10.1 {\n    sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER \\\n                    [expr {$::SQLITE_MAX_VARIABLE_NUMBER/2}]\n  } $SQLITE_MAX_VARIABLE_NUMBER\n  do_test sqllimits1-2.10.2 {\n    sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1\n  } [expr {$SQLITE_MAX_VARIABLE_NUMBER/2}]\n}\n\n# In a separate database connection, verify that the limits are unchanged.\n#\ndo_test sqllimits1-3.1 {\n  sqlite3_limit db2 SQLITE_LIMIT_LENGTH -1\n} $SQLITE_MAX_LENGTH\ndo_test sqllimits1-3.2 {\n  sqlite3_limit db2 SQLITE_LIMIT_SQL_LENGTH -1\n} $SQLITE_MAX_SQL_LENGTH\ndo_test sqllimits1-3.3 {\n  sqlite3_limit db2 SQLITE_LIMIT_COLUMN -1\n} $SQLITE_MAX_COLUMN\ndo_test sqllimits1-3.4 {\n  sqlite3_limit db2 SQLITE_LIMIT_EXPR_DEPTH -1\n} $SQLITE_MAX_EXPR_DEPTH\ndo_test sqllimits1-3.5 {\n  sqlite3_limit db2 SQLITE_LIMIT_COMPOUND_SELECT -1\n} $SQLITE_MAX_COMPOUND_SELECT\ndo_test sqllimits1-3.6 {\n  sqlite3_limit db2 SQLITE_LIMIT_VDBE_OP -1\n} $SQLITE_MAX_VDBE_OP\ndo_test sqllimits1-3.7 {\n  sqlite3_limit db2 SQLITE_LIMIT_FUNCTION_ARG -1\n} $SQLITE_MAX_FUNCTION_ARG\ndo_test sqllimits1-3.8 {\n  sqlite3_limit db2 SQLITE_LIMIT_ATTACHED -1\n} $SQLITE_MAX_ATTACHED\ndo_test sqllimits1-3.9 {\n  sqlite3_limit db2 SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1\n} $SQLITE_MAX_LIKE_PATTERN_LENGTH\ndo_test sqllimits1-3.10 {\n  sqlite3_limit db2 SQLITE_LIMIT_VARIABLE_NUMBER -1\n} $SQLITE_MAX_VARIABLE_NUMBER\ndb2 close\n\n# Attempt to set all limits to the maximum 32-bit integer.  Verify\n# that the limit does not exceed the compile-time upper bound.\n#\ndo_test sqllimits1-4.1.1 {\n  sqlite3_limit db SQLITE_LIMIT_LENGTH 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_LENGTH -1\n} $SQLITE_MAX_LENGTH\ndo_test sqllimits1-4.2.1 {\n  sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH -1\n} $SQLITE_MAX_SQL_LENGTH\ndo_test sqllimits1-4.3.1 {\n  sqlite3_limit db SQLITE_LIMIT_COLUMN 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_COLUMN -1\n} $SQLITE_MAX_COLUMN\ndo_test sqllimits1-4.4.1 {\n  sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_EXPR_DEPTH -1\n} $SQLITE_MAX_EXPR_DEPTH\ndo_test sqllimits1-4.5.1 {\n  sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_COMPOUND_SELECT -1\n} $SQLITE_MAX_COMPOUND_SELECT\ndo_test sqllimits1-4.6.1 {\n  sqlite3_limit db SQLITE_LIMIT_VDBE_OP 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_VDBE_OP -1\n} $SQLITE_MAX_VDBE_OP\ndo_test sqllimits1-4.7.1 {\n  sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG -1\n} $SQLITE_MAX_FUNCTION_ARG\ndo_test sqllimits1-4.8.1 {\n  sqlite3_limit db SQLITE_LIMIT_ATTACHED 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_ATTACHED -1\n} $SQLITE_MAX_ATTACHED\ndo_test sqllimits1-4.9.1 {\n  sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH -1\n} $SQLITE_MAX_LIKE_PATTERN_LENGTH\ndo_test sqllimits1-4.10.1 {\n  sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER 0x7fffffff\n  sqlite3_limit db SQLITE_LIMIT_VARIABLE_NUMBER -1\n} $SQLITE_MAX_VARIABLE_NUMBER\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-5.* test that the SQLITE_MAX_LENGTH limit\n# is enforced.\n#\n# EVIDENCE-OF: R-61987-00541 SQLITE_LIMIT_LENGTH The maximum size of any\n# string or BLOB or table row, in bytes.\n#\ndb close\nsqlite3 db test.db\nset LARGESIZE 99999\nset SQLITE_LIMIT_LENGTH 100000\nsqlite3_limit db SQLITE_LIMIT_LENGTH $SQLITE_LIMIT_LENGTH\n\ndo_test sqllimits1-5.1.1 {\n  catchsql { SELECT randomblob(2147483647) }\n} {1 {string or blob too big}}\ndo_test sqllimits1-5.1.2 {\n  catchsql { SELECT zeroblob(2147483647) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.2 {\n  catchsql { SELECT LENGTH(randomblob($::LARGESIZE)) }\n} [list 0 $LARGESIZE]\n\ndo_test sqllimits1-5.3 {\n  catchsql { SELECT quote(randomblob($::LARGESIZE)) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.4 {\n  catchsql { SELECT LENGTH(zeroblob($::LARGESIZE)) }\n} [list 0 $LARGESIZE]\n\ndo_test sqllimits1-5.5 {\n  catchsql { SELECT quote(zeroblob($::LARGESIZE)) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.6 {\n  catchsql { SELECT zeroblob(-1) }\n} {0 {{}}}\n\ndo_test sqllimits1-5.9 {\n  set ::str [string repeat A 65537]\n  set ::rep [string repeat B 65537]\n  catchsql { SELECT replace($::str, 'A', $::rep) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.10 {\n  set ::str [string repeat %J 2100]\n  catchsql { SELECT strftime($::str, '2003-10-31') }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.11 {\n  set ::str1 [string repeat A [expr {$SQLITE_LIMIT_LENGTH - 10}]]\n  set ::str2 [string repeat B [expr {$SQLITE_LIMIT_LENGTH - 10}]]\n  catchsql { SELECT $::str1 || $::str2 }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.12 {\n  set ::str1 [string repeat ' [expr {$SQLITE_LIMIT_LENGTH - 10}]]\n  catchsql { SELECT quote($::str1) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.13 {\n  set ::str1 [string repeat ' [expr {$SQLITE_LIMIT_LENGTH - 10}]]\n  catchsql { SELECT hex($::str1) }\n} {1 {string or blob too big}}\n\ndo_test sqllimits1-5.14.1 {\n  set ::STMT [sqlite3_prepare db \"SELECT ?\" -1 TAIL]\n  sqlite3_bind_zeroblob $::STMT 1 [expr {$SQLITE_LIMIT_LENGTH + 1}]\n} {}\ndo_test sqllimits1-5.14.2 {\n  sqlite3_step $::STMT \n} {SQLITE_ERROR}\ndo_test sqllimits1-5.14.3 {\n  sqlite3_reset $::STMT \n} {SQLITE_TOOBIG}\ndo_test sqllimits1-5.14.4 {\n  set np1 [expr {$SQLITE_LIMIT_LENGTH + 1}]\n  set ::str1 [string repeat A $np1]\n  catch {sqlite3_bind_text $::STMT 1 $::str1 -1} res\n  set res\n} {SQLITE_TOOBIG}\nifcapable utf16 {\n  do_test sqllimits1-5.14.5 {\n    catch {sqlite3_bind_text16 $::STMT 1 $::str1 -1} res\n    set res\n  } {SQLITE_TOOBIG}\n}\ndo_test sqllimits1-5.14.6 {\n  catch {sqlite3_bind_text $::STMT 1 $::str1 $np1} res\n  set res\n} {SQLITE_TOOBIG}\nifcapable utf16 {\n  do_test sqllimits1-5.14.7 {\n    catch {sqlite3_bind_text16 $::STMT 1 $::str1 $np1} res\n    set res\n  } {SQLITE_TOOBIG}\n}\ndo_test sqllimits1-5.14.8 {\n  set n [expr {$np1-1}]\n  catch {sqlite3_bind_text $::STMT 1 $::str1 $n} res\n  set res\n} {}\ndo_test sqllimits1-5.14.9 {\n  catch {sqlite3_bind_text16 $::STMT 1 $::str1 $n} res\n  set res\n} {}\nsqlite3_finalize $::STMT \n\ndo_test sqllimits1-5.15 {\n  execsql {\n    CREATE TABLE t4(x);\n    INSERT INTO t4 VALUES(1);\n    INSERT INTO t4 VALUES(2);\n    INSERT INTO t4 SELECT 2+x FROM t4;\n  }\n  catchsql {\n    SELECT group_concat(hex(randomblob(20000))) FROM t4;\n  }\n} {1 {string or blob too big}}\ndb eval {DROP TABLE t4}\n\nsqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 0x7fffffff\nset strvalue [string repeat A $::SQLITE_LIMIT_LENGTH]\ndo_test sqllimits1-5.16 {\n  catchsql \"SELECT '$strvalue'\"\n} [list 0 $strvalue]\ndo_test sqllimits1-5.17.1 {\n  catchsql \"SELECT 'A$strvalue'\"\n} [list 1 {string or blob too big}]\ndo_test sqllimits1-5.17.2 {\n  sqlite3_limit db SQLITE_LIMIT_LENGTH 0x7fffffff\n  catchsql {SELECT 'A' || $::strvalue}\n} [list 0 A$strvalue]\ndo_test sqllimits1-5.17.3 {\n  sqlite3_limit db SQLITE_LIMIT_LENGTH $SQLITE_LIMIT_LENGTH\n  catchsql {SELECT 'A' || $::strvalue}\n} [list 1 {string or blob too big}]\nset blobvalue [string repeat 41 $::SQLITE_LIMIT_LENGTH]\ndo_test sqllimits1-5.18 {\n  catchsql \"SELECT x'$blobvalue'\"\n} [list 0 $strvalue]\ndo_test sqllimits1-5.19 {\n  catchsql \"SELECT '41$blobvalue'\"\n} [list 1 {string or blob too big}]\nunset blobvalue\n\nifcapable datetime {\n  set strvalue [string repeat D [expr {$SQLITE_LIMIT_LENGTH-12}]]\n  do_test sqllimits1-5.20 {\n    catchsql {SELECT strftime('%Y ' || $::strvalue, '2008-01-02')}\n  } [list 0 [list \"2008 $strvalue\"]]\n  do_test sqllimits1-5.21 {\n    catchsql {SELECT strftime('%Y-%m-%d ' || $::strvalue, '2008-01-02')}\n  } {1 {string or blob too big}}\n}\nunset strvalue\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-6.* test that the SQLITE_MAX_SQL_LENGTH limit\n# is enforced.\n#\n# EVIDENCE-OF: R-09808-17554 SQLITE_LIMIT_SQL_LENGTH The maximum length\n# of an SQL statement, in bytes.\n#\ndo_test sqllimits1-6.1 {\n  sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 50000\n  set sql \"SELECT 1 WHERE 1==1\"\n  set tail \" /* A comment to take up space in order to make the string\\\n                longer without increasing the expression depth */\\\n                AND   1  ==  1\"\n  set N [expr {(50000 / [string length $tail])+1}]\n  append sql [string repeat $tail $N]\n  catchsql $sql\n} {1 {string or blob too big}}\ndo_test sqllimits1-6.3 {\n  sqlite3_limit db SQLITE_LIMIT_SQL_LENGTH 50000\n  set sql \"SELECT 1 WHERE 1==1\"\n  set tail \" /* A comment to take up space in order to make the string\\\n                longer without increasing the expression depth */\\\n                AND   1  ==  1\"\n  set N [expr {(50000 / [string length $tail])+1}]\n  append sql [string repeat $tail $N]\n  set nbytes [string length $sql]\n  append sql { AND 0}\n  set rc [catch {sqlite3_prepare db $sql $nbytes TAIL} STMT]\n  lappend rc $STMT\n} {1 {(18) statement too long}}\ndo_test sqllimits1-6.4 {\n  sqlite3_errmsg db\n} {statement too long}\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-7.* test that the limit set using the\n# max_page_count pragma.\n#\ndo_test sqllimits1-7.1 {\n  execsql {\n    PRAGMA max_page_count = 1000;\n  }\n} {1000}\ndo_test sqllimits1-7.2 {\n  execsql { CREATE TABLE trig (a INTEGER, b INTEGER); }\n\n  # Set up a tree of triggers to fire when a row is inserted\n  # into table \"trig\".\n  #\n  # INSERT -> insert_b -> update_b -> insert_a -> update_a      (chain 1)\n  #                    -> update_a -> insert_a -> update_b      (chain 2)\n  #        -> insert_a -> update_b -> insert_b -> update_a      (chain 3)\n  #                    -> update_a -> insert_b -> update_b      (chain 4)\n  #\n  # Table starts with N rows.\n  #\n  #   Chain 1: insert_b (update N rows)\n  #              -> update_b (insert 1 rows)\n  #                -> insert_a (update N rows)\n  #                  -> update_a (insert 1 rows)\n  #\n  # chains 2, 3 and 4 are similar. Each inserts more than N^2 rows, where\n  # N is the number of rows at the conclusion of the previous chain.\n  #\n  # Therefore, a single insert adds (N^16 plus some) rows to the database.\n  # A really long loop...\n  #     \n  execsql {\n    CREATE TRIGGER update_b BEFORE UPDATE ON trig\n      FOR EACH ROW BEGIN\n        INSERT INTO trig VALUES (65, 'update_b');\n      END;\n\n    CREATE TRIGGER update_a AFTER UPDATE ON trig\n      FOR EACH ROW BEGIN\n        INSERT INTO trig VALUES (65, 'update_a');\n      END;\n\n    CREATE TRIGGER insert_b BEFORE INSERT ON trig\n      FOR EACH ROW BEGIN\n        UPDATE trig SET a = 1;\n      END;\n\n    CREATE TRIGGER insert_a AFTER INSERT ON trig\n      FOR EACH ROW BEGIN\n        UPDATE trig SET a = 1;\n      END;\n  }\n} {}\n\ndo_test sqllimits1-7.3 {\n  execsql {\n    INSERT INTO trig VALUES (1,1); \n  }\n} {}\n\ndo_test sqllimits1-7.4 {\n  execsql {\n    SELECT COUNT(*) FROM trig;\n  }\n} {7}\n\n# This tries to insert so many rows it fills up the database (limited\n# to 1MB, so not that noteworthy an achievement).\n#\ndo_test sqllimits1-7.5 {\n  catchsql {\n    INSERT INTO trig VALUES (1,10);\n  }\n} {1 {database or disk is full}}\n\ndo_test sqllimits1-7.6 {\n  catchsql {\n    SELECT COUNT(*) FROM trig;\n  }\n} {0 7}\n\n# Now check the response of the library to opening a file larger than\n# the current max_page_count value. The response is to change the\n# internal max_page_count value to match the actual size of the file.\nif {[db eval {PRAGMA auto_vacuum}]} {\n   set fsize 1700\n} else {\n   set fsize 1691\n}\ndo_test sqllimits1-7.7.1 {\n  execsql {\n    PRAGMA max_page_count = 1000000;\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a||b||c, b||c||a, c||a||b FROM abc;\n    INSERT INTO abc SELECT a, b, c FROM abc;\n    INSERT INTO abc SELECT b, a, c FROM abc;\n    INSERT INTO abc SELECT c, b, a FROM abc;\n  }\n  expr [file size test.db] / 1024\n} $fsize\ndo_test sqllimits1-7.7.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA max_page_count = 1000;\n  }\n  execsql {\n    SELECT count(*) FROM sqlite_master;\n  }\n} {6}\ndo_test sqllimits1-7.7.3 {\n  execsql {\n    PRAGMA max_page_count;\n  }\n} $fsize\ndo_test sqllimits1-7.7.4 {\n  execsql {\n    DROP TABLE abc;\n  }\n} {}\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-8.* test the SQLITE_MAX_COLUMN limit.\n#\n# EVIDENCE-OF: R-43996-29471 SQLITE_LIMIT_COLUMN The maximum number of\n# columns in a table definition or in the result set of a SELECT or the\n# maximum number of columns in an index or in an ORDER BY or GROUP BY\n# clause.\n#\nset SQLITE_LIMIT_COLUMN 200\nsqlite3_limit db SQLITE_LIMIT_COLUMN $SQLITE_LIMIT_COLUMN\ndo_test sqllimits1-8.1 {\n  # Columns in a table.\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"c$i\"\n  }\n  catchsql \"CREATE TABLE t([join $cols ,])\" \n} {1 {too many columns on t}}\n\ndo_test sqllimits1-8.2 {\n  # Columns in the result-set of a SELECT.\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"sql AS sql$i\"\n  }\n  catchsql \"SELECT [join $cols ,] FROM sqlite_master\"\n} {1 {too many columns in result set}}\n\ndo_test sqllimits1-8.3 {\n  # Columns in the result-set of a sub-SELECT.\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"sql AS sql$i\"\n  }\n  catchsql \"SELECT sql4 FROM (SELECT [join $cols ,] FROM sqlite_master)\"\n} {1 {too many columns in result set}}\n\ndo_test sqllimits1-8.4 {\n  # Columns in an index.\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols c\n  }\n  set sql1 \"CREATE TABLE t1(c);\"\n  set sql2 \"CREATE INDEX i1 ON t1([join $cols ,]);\"\n  catchsql \"$sql1 ; $sql2\"\n} {1 {too many columns in index}}\n\ndo_test sqllimits1-8.5 {\n  # Columns in a GROUP BY clause.\n  catchsql \"SELECT * FROM t1 GROUP BY [join $cols ,]\"\n} {1 {too many terms in GROUP BY clause}}\n\ndo_test sqllimits1-8.6 {\n  # Columns in an ORDER BY clause.\n  catchsql \"SELECT * FROM t1 ORDER BY [join $cols ,]\"\n} {1 {too many terms in ORDER BY clause}}\n\ndo_test sqllimits1-8.7 {\n  # Assignments in an UPDATE statement.\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"c = 1\"\n  }\n  catchsql \"UPDATE t1 SET [join $cols ,];\"\n} {1 {too many columns in set list}}\n\ndo_test sqllimits1-8.8 {\n  # Columns in a view definition:\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"c$i\"\n  }\n  execsql \"CREATE VIEW v1 AS SELECT [join $cols ,] FROM t1;\"\n  catchsql {SELECT * FROM v1}\n} {1 {too many columns in result set}}\n\ndo_test sqllimits1-8.9 {\n  # Columns in a view definition (testing * expansion):\n  set cols [list]\n  for {set i 0} {$i < $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols \"c$i\"\n  }\n  execsql {DROP VIEW IF EXISTS v1}\n  catchsql \"CREATE TABLE t2([join $cols ,])\"\n  catchsql \"CREATE VIEW v1 AS SELECT *, c1 AS o FROM t2;\"\n  catchsql \"SELECT * FROM v1\"\n} {1 {too many columns in result set}}\n\ndo_test sqllimits1-8.10 {\n  # ORDER BY columns\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols c\n  }\n  set sql \"SELECT c FROM t1 ORDER BY [join $cols ,]\"\n  catchsql $sql\n} {1 {too many terms in ORDER BY clause}}\ndo_test sqllimits1-8.11 {\n  # ORDER BY columns\n  set cols [list]\n  for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {\n    lappend cols [expr {$i%3 + 1}]\n  }\n  set sql \"SELECT c, c+1, c+2 FROM t1 UNION SELECT c-1, c-2, c-3 FROM t1\"\n  append sql \" ORDER BY [join $cols ,]\"\n  catchsql $sql\n} {1 {too many terms in ORDER BY clause}}\n\n\n#--------------------------------------------------------------------\n# These tests - sqllimits1-9.* - test that the SQLITE_LIMIT_EXPR_DEPTH\n# limit is enforced. The limit refers to the number of terms in \n# the expression.\n#\n# EVIDENCE-OF: R-12723-08526 SQLITE_LIMIT_EXPR_DEPTH The maximum depth\n# of the parse tree on any expression.\n#\nif {$SQLITE_MAX_EXPR_DEPTH==0} {\n  puts -nonewline stderr \"WARNING: Compile with -DSQLITE_MAX_EXPR_DEPTH to run \"\n  puts stderr \"tests sqllimits1-9.X\"\n} else {\n  do_test sqllimits1-9.1 {\n    set max $::SQLITE_MAX_EXPR_DEPTH\n    set expr \"(1 [string repeat {AND 1 } $max])\"\n    catchsql [subst {\n      SELECT $expr\n    }]\n  } \"1 {Expression tree is too large (maximum depth $::SQLITE_MAX_EXPR_DEPTH)}\"\n  \n  # Attempting to beat the expression depth limit using nested SELECT\n  # queries causes a parser stack overflow. \n  do_test sqllimits1-9.2 {\n    set max $::SQLITE_MAX_EXPR_DEPTH\n    set expr \"SELECT 1\"\n    for {set i 0} {$i <= $max} {incr i} {\n      set expr \"SELECT ($expr)\"\n    }\n    catchsql [subst { $expr }]\n  } \"1 {parser stack overflow}\"\n  \nif 0 {  \n  do_test sqllimits1-9.3 {\n    execsql {\n      PRAGMA max_page_count = 1000000;  -- 1 GB\n      CREATE TABLE v0(a);\n      INSERT INTO v0 VALUES(1);\n    }\n    db transaction {\n      for {set i 1} {$i < 200} {incr i} {\n        set expr \"(a [string repeat {AND 1 } 50]) AS a\"\n        execsql [subst {\n          CREATE VIEW v${i} AS SELECT $expr FROM v[expr {$i-1}]\n        }]\n      }\n    }\n  } {}\n  \n  do_test sqllimits1-9.4 {\n    catchsql {\n      SELECT a FROM v199\n    }\n  } \"1 {Expression tree is too large (maximum depth $::SQLITE_MAX_EXPR_DEPTH)}\"\n}\n}\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-10.* test that the SQLITE_MAX_VDBE_OP\n# limit works as expected. The limit refers to the number of opcodes\n# in a single VDBE program.\n#\n# TODO\n\n#--------------------------------------------------------------------\n# Test the SQLITE_LIMIT_FUNCTION_ARG limit works. Test case names\n# match the pattern \"sqllimits1-11.*\".\n#\n# EVIDENCE-OF: R-59001-45278 SQLITE_LIMIT_FUNCTION_ARG The maximum\n# number of arguments on a function.\n#\nfor {set max 5} {$max<=$SQLITE_MAX_FUNCTION_ARG} {incr max} {\n  do_test sqllimits1-11.$max.1 {\n    set vals [list]\n    sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG $::max\n    for {set i 0} {$i < $::max} {incr i} {\n      lappend vals $i\n    }\n    catchsql \"SELECT max([join $vals ,])\"\n  } \"0 [expr {$::max - 1}]\"\n  do_test sqllimits1-11.$max.2 {\n    set vals [list]\n    for {set i 0} {$i <= $::max} {incr i} {\n      lappend vals $i\n    }\n    catchsql \"SELECT max([join $vals ,])\"\n  } {1 {too many arguments on function max}}\n\n  # Test that it is SQLite, and not the implementation of the\n  # user function that is throwing the error.\n  proc myfunc {args} {error \"I don't like to be called!\"}\n  do_test sqllimits1-11.$max.2 {\n    db function myfunc myfunc\n    set vals [list]\n    for {set i 0} {$i <= $::max} {incr i} {\n      lappend vals $i\n    }\n    catchsql \"SELECT myfunc([join $vals ,])\"\n  } {1 {too many arguments on function myfunc}}\n}\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-12.*: Test the SQLITE_MAX_ATTACHED limit.\n#\n# EVIDENCE-OF: R-41778-26203 SQLITE_LIMIT_ATTACHED The maximum number of\n# attached databases.\n#\nifcapable attach {\n  do_test sqllimits1-12.1 {\n    set max $::SQLITE_MAX_ATTACHED\n    for {set i 0} {$i < ($max)} {incr i} {\n      forcedelete test${i}.db test${i}.db-journal\n    }\n    for {set i 0} {$i < ($max)} {incr i} {\n      execsql \"ATTACH 'test${i}.db' AS aux${i}\"\n    }\n    catchsql \"ATTACH 'test${i}.db' AS aux${i}\"\n  } \"1 {too many attached databases - max $::SQLITE_MAX_ATTACHED}\"\n  do_test sqllimits1-12.2 {\n    set max $::SQLITE_MAX_ATTACHED\n    for {set i 0} {$i < ($max)} {incr i} {\n      execsql \"DETACH aux${i}\"\n    }\n  } {}\n}\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-13.*: Check that the SQLITE_MAX_VARIABLE_NUMBER \n# limit works.\n#\n# EVIDENCE-OF: R-42363-29104 SQLITE_LIMIT_VARIABLE_NUMBER The maximum\n# index number of any parameter in an SQL statement.\n#\ndo_test sqllimits1-13.1 {\n  set max $::SQLITE_MAX_VARIABLE_NUMBER\n  catchsql \"SELECT ?[expr {$max+1}] FROM t1\"\n} \"1 {variable number must be between ?1 and ?$::SQLITE_MAX_VARIABLE_NUMBER}\"\ndo_test sqllimits1-13.2 {\n  set max $::SQLITE_MAX_VARIABLE_NUMBER\n  set vals [list]\n  for {set i 0} {$i < ($max+3)} {incr i} {\n    lappend vals ?\n  }\n  catchsql \"SELECT [join $vals ,] FROM t1\"\n} \"1 {too many SQL variables}\"\n\n\n#--------------------------------------------------------------------\n# Test cases sqllimits1-15.* verify that the \n# SQLITE_MAX_LIKE_PATTERN_LENGTH limit is enforced. This limit only\n# applies to the built-in LIKE operator, supplying an external \n# implementation by overriding the like() scalar function bypasses\n# this limitation.\n#\n# EVIDENCE-OF: R-12940-37052 SQLITE_LIMIT_LIKE_PATTERN_LENGTH The\n# maximum length of the pattern argument to the LIKE or GLOB operators.\n#\n# These tests check that the limit is not incorrectly applied to\n# the left-hand-side of the LIKE operator (the string being tested\n# against the pattern).\n#\nset SQLITE_LIMIT_LIKE_PATTERN 1000\nsqlite3_limit db SQLITE_LIMIT_LIKE_PATTERN_LENGTH $SQLITE_LIMIT_LIKE_PATTERN\ndo_test sqllimits1-15.1 {\n  set max $::SQLITE_LIMIT_LIKE_PATTERN\n  set ::pattern [string repeat \"A%\" [expr $max/2]]\n  set ::string  [string repeat \"A\" [expr {$max*2}]]\n  execsql {\n    SELECT $::string LIKE $::pattern;\n  }\n} {1}\ndo_test sqllimits1-15.2 {\n  set max $::SQLITE_LIMIT_LIKE_PATTERN\n  set ::pattern [string repeat \"A%\" [expr {($max/2) + 1}]]\n  set ::string  [string repeat \"A\" [expr {$max*2}]]\n  catchsql {\n    SELECT $::string LIKE $::pattern;\n  }\n} {1 {LIKE or GLOB pattern too complex}}\n\n#--------------------------------------------------------------------\n# This test case doesn't really belong with the other limits tests.\n# It is in this file because it is taxing to run, like the limits tests.\n#\ndo_test sqllimits1-16.1 {\n  set ::N [expr int(([expr pow(2,32)]/50) + 1)]\n  expr (($::N*50) & 0xffffffff)<55\n} {1}\ndo_test sqllimits1-16.2 {\n  set ::format \"[string repeat A 60][string repeat \"%J\" $::N]\"\n  catchsql {\n    SELECT strftime($::format, 1);\n  }\n} {1 {string or blob too big}}\n\ndo_catchsql_test sqllimits1.17.0 {\n  SELECT *,*,*,*,*,*,*,* FROM (\n  SELECT *,*,*,*,*,*,*,* FROM (\n  SELECT *,*,*,*,*,*,*,* FROM (\n  SELECT *,*,*,*,*,*,*,* FROM (\n  SELECT *,*,*,*,*,*,*,* FROM (\n    SELECT 1,2,3,4,5,6,7,8,9,10\n  )\n  ))))\n} \"1 {too many columns in result set}\"\n\n\nforeach {key value} [array get saved] {\n  catch {set $key $value}\n}\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sqllog.test",
    "content": "# 2015 November 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the test_sqllog.c module.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sqllog\n\nifcapable !sqllog {\n  finish_test\n  return\n}\n\nproc readfile {f} {\n  set fd [open $f]\n  set txt [read $fd]\n  close $fd\n  set txt\n}\n\nproc delete_all_sqllog_files {} {\n  forcedelete {*}[glob -nocomplain sqllog_*.sql]\n  forcedelete {*}[glob -nocomplain sqllog_*.db]\n  forcedelete {*}[glob -nocomplain sqllog_*.idx]\n}\n\nproc touch {f} {\n  set fd [open $f w+]\n  close $fd\n}\n\ndb close\nsqlite3_shutdown\nset ::env(SQLITE_SQLLOG_DIR) [pwd]\n\ndelete_all_sqllog_files\n\nsqlite3 db test.db\nset a a\nset b b\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES($a, $b);\n  SELECT * FROM t1;\n} {1 2 a b}\ndb close\n\ndo_test 1.1 {\n  readfile [lindex [glob sqllog_*.sql] 0]\n} [string trimleft {\n/-- Main database is '.*/sqllog_.*_0.db'\nCREATE TABLE t1\\(x, y\\);; -- clock=0\nINSERT INTO t1 VALUES\\(1, 2\\);; -- clock=1\nINSERT INTO t1 VALUES\\('a', 'b'\\);; -- clock=2\nSELECT . FROM t1;; -- clock=3\n/}]\n\ndo_test 1.2 {\n  file size [lindex [glob sqllog_*_0.db] 0]\n} 1024\n\n#-------------------------------------------------------------------------\ncatch { db close }\nsqlite3_shutdown\ndelete_all_sqllog_files\nforcedelete test.db-sqllog\n\nset ::env(SQLITE_SQLLOG_CONDITIONAL) 1\nsqlite3 db test.db\ndo_execsql_test 2.1 {\n  INSERT INTO t1 VALUES(4, 5);\n  SELECT * FROM t1;\n} {1 2 a b 4 5}\n\ndo_test 2.2 {\n  glob -nocomplain sqllog_*\n} {}\n\ndb close\ntouch test.db-sqllog\nsqlite3 db test.db\ndo_execsql_test 2.3 {\n  INSERT INTO t1 VALUES(6, 7);\n  SELECT * FROM t1;\n} {1 2 a b 4 5 6 7}\ndb close\n\ndo_test 2.4 {\n  readfile [lindex [glob sqllog_*.sql] 0]\n} [string trimleft {\n/-- Main database is '.*/sqllog_.*_0.db'\nINSERT INTO t1 VALUES\\(6, 7\\);; -- clock=0\nSELECT . FROM t1;; -- clock=1\n/}]\n\ncatch { db close }\nsqlite3_shutdown\nunset ::env(SQLITE_SQLLOG_DIR)\nunset ::env(SQLITE_SQLLOG_CONDITIONAL)\nsqlite3_config_sqllog\nsqlite3_initialize\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/stat.test",
    "content": "# 2010 July 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the SELECT statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix stat\n\nifcapable !vtab||!compound {\n  finish_test\n  return\n}\n\n# This module uses hard-coded results that depend on exact measurements of\n# pages sizes at the byte level, and hence will not work if the reserved_bytes\n# value is nonzero.\nif {[nonzero_reserved_bytes]} {finish_test; return;}\n\nset ::asc 1\nproc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }\ndb func a_string a_string\n\nregister_dbstat_vtab db\ndo_execsql_test stat-0.0 {\n  PRAGMA table_info(dbstat);\n} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}\n\n# Attempts to drop an eponymous virtual table are a no-op.\ndo_execsql_test stat-0.1 {\n  DROP TABLE dbstat;\n  PRAGMA table_info=dbstat;\n} {/0 name TEXT .* 1 path TEXT .* 9 pgsize INTEGER/}\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndb func a_string a_string\nregister_dbstat_vtab db\ndo_execsql_test stat-0.2 {\n  PRAGMA auto_vacuum = OFF;\n  CREATE VIRTUAL TABLE temp.stat USING dbstat;\n  SELECT * FROM stat;\n} {}\n\n\nif {[wal_is_capable]} {\n  do_execsql_test stat-0.1 {\n    PRAGMA journal_mode = WAL;\n    PRAGMA journal_mode = delete;\n    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n      FROM stat;\n  } {wal delete sqlite_master / 1 leaf 0 0 916 0}\n}\n\ndo_test stat-1.0 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(b);\n    INSERT INTO t1(rowid, a, b) VALUES(2, 2, 3);\n    INSERT INTO t1(rowid, a, b) VALUES(3, 4, 5);\n  }\n} {}\ndo_test stat-1.1 {\n  execsql {\n    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n      FROM stat WHERE name = 't1';\n  }\n} {t1 / 2 leaf 2 10 998 5}\ndo_test stat-1.2 {\n  execsql {\n    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n      FROM stat WHERE name = 'i1';\n  }\n} {i1 / 3 leaf 2 10 1000 5}\ndo_test stat-1.3 {\n  execsql {\n    SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n      FROM stat WHERE name = 'sqlite_master';\n  }\n} {sqlite_master / 1 leaf 2 77 831 40}\ndo_test stat-1.4 {\n  execsql {\n    DROP TABLE t1;\n  }\n} {}\n\ndo_execsql_test stat-2.1 {\n  CREATE TABLE t3(a PRIMARY KEY, b);\n  INSERT INTO t3(rowid, a, b) VALUES(2, a_string(111), a_string(222));\n  INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3\n   ORDER BY rowid;\n  INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3\n   ORDER BY rowid;\n  INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3\n   ORDER BY rowid;\n  INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3\n   ORDER BY rowid;\n  INSERT INTO t3 SELECT a_string(110+rowid), a_string(221+rowid) FROM t3\n   ORDER BY rowid;\n  SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n    FROM stat WHERE name != 'sqlite_master';\n} [list \\\n  sqlite_autoindex_t3_1 / 3 internal 3 368 623 125       \\\n  sqlite_autoindex_t3_1 /000/ 8 leaf 8 946 46 123        \\\n  sqlite_autoindex_t3_1 /001/ 9 leaf 8 988 2 131         \\\n  sqlite_autoindex_t3_1 /002/ 15 leaf 7 857 137 132      \\\n  sqlite_autoindex_t3_1 /003/ 20 leaf 6 739 257 129      \\\n  t3 / 2 internal 15 0 907 0                             \\\n  t3 /000/ 4 leaf 2 678 328 340                          \\\n  t3 /001/ 5 leaf 2 682 324 342                          \\\n  t3 /002/ 6 leaf 2 682 324 342                          \\\n  t3 /003/ 7 leaf 2 690 316 346                          \\\n  t3 /004/ 10 leaf 2 682 324 342                         \\\n  t3 /005/ 11 leaf 2 690 316 346                         \\\n  t3 /006/ 12 leaf 2 698 308 350                         \\\n  t3 /007/ 13 leaf 2 706 300 354                         \\\n  t3 /008/ 14 leaf 2 682 324 342                         \\\n  t3 /009/ 16 leaf 2 690 316 346                         \\\n  t3 /00a/ 17 leaf 2 698 308 350                         \\\n  t3 /00b/ 18 leaf 2 706 300 354                         \\\n  t3 /00c/ 19 leaf 2 714 292 358                         \\\n  t3 /00d/ 21 leaf 2 722 284 362                         \\\n  t3 /00e/ 22 leaf 2 730 276 366                         \\\n  t3 /00f/ 23 leaf 2 738 268 370                         \\\n]\n\n# With every index entry overflowing, make sure no pages are missed \n# (other than the locking page which is 64 in this test build.)\n#\ndo_execsql_test stat-2.2 {\n  UPDATE t3 SET a=a||hex(randomblob(700));\n  VACUUM;\n  SELECT pageno FROM stat EXCEPT SELECT pageno-1 FROM stat;\n} {64 136}\n\ndo_execsql_test stat-2.3 { DROP TABLE t3; VACUUM; } {}\n\ndo_execsql_test stat-3.1 {\n  CREATE TABLE t4(x);\n  CREATE INDEX i4 ON t4(x);\n  INSERT INTO t4(rowid, x) VALUES(2, a_string(7777));\n  SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n    FROM stat WHERE name != 'sqlite_master';\n} [list \\\n  i4 / 3 leaf 1 103 905 7782                 \\\n  i4 /000+000000 4 overflow 0 1020 0 0       \\\n  i4 /000+000001 5 overflow 0 1020 0 0      \\\n  i4 /000+000002 6 overflow 0 1020 0 0      \\\n  i4 /000+000003 7 overflow 0 1020 0 0      \\\n  i4 /000+000004 8 overflow 0 1020 0 0      \\\n  i4 /000+000005 9 overflow 0 1020 0 0      \\\n  i4 /000+000006 10 overflow 0 1020 0 0      \\\n  i4 /000+000007 11 overflow 0 539 481 0     \\\n  t4 / 2 leaf 1 640 367 7780                 \\\n  t4 /000+000000 12 overflow 0 1020 0 0      \\\n  t4 /000+000001 13 overflow 0 1020 0 0      \\\n  t4 /000+000002 14 overflow 0 1020 0 0      \\\n  t4 /000+000003 15 overflow 0 1020 0 0      \\\n  t4 /000+000004 16 overflow 0 1020 0 0      \\\n  t4 /000+000005 17 overflow 0 1020 0 0      \\\n  t4 /000+000006 18 overflow 0 1020 0 0      \\\n]\n\ndo_execsql_test stat-4.1 {\n  CREATE TABLE t5(x);\n  CREATE INDEX i5 ON t5(x);\n  SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n    FROM stat WHERE name = 't5' OR name = 'i5';\n} [list  \\\n  i5 / 20 leaf 0 0 1016 0 \\\n  t5 / 19 leaf 0 0 1016 0 \\\n]\n\ndb close\nforcedelete test.db\nsqlite3 db test.db\nregister_dbstat_vtab db\ndo_execsql_test stat-5.1 {\n  PRAGMA auto_vacuum = OFF;\n  CREATE TABLE tx(y);\n  ATTACH ':memory:' AS aux1;\n  CREATE VIRTUAL TABLE temp.stat USING dbstat(aux1);\n  CREATE TABLE aux1.t1(x);\n  INSERT INTO t1 VALUES(zeroblob(1513));\n  INSERT INTO t1 VALUES(zeroblob(1514));\n  SELECT name, path, pageno, pagetype, ncell, payload, unused, mx_payload\n    FROM stat WHERE name = 't1';\n} [list \\\n  t1 / 2 leaf 2 993 5 1517                \\\n  t1 /000+000000 3 overflow 0 1020 0 0    \\\n  t1 /001+000000 4 overflow 0 1020 0 0    \\\n]\n\ndo_catchsql_test stat-6.1 {\n  CREATE VIRTUAL TABLE temp.s2 USING dbstat(mainx);\n} {1 {no such database: mainx}}\n\n#-------------------------------------------------------------------------\n# Test that the argument passed to the dbstat constructor is dequoted\n# before it is matched against the names of attached databases.\n#\nforcedelete test.db2\ndo_execsql_test 7.1 {\n  ATTACH 'test.db2' AS '123';\n  PRAGMA \"123\".auto_vacuum = OFF;\n  CREATE TABLE \"123\".x1(a, b);\n  INSERT INTO x1 VALUES(1, 2);\n}\n\ndo_execsql_test 7.1.1 {\n  SELECT * FROM dbstat('123');\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\ndo_execsql_test 7.1.2 {\n  SELECT * FROM dbstat(123);\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\ndo_execsql_test 7.1.3 {\n  CREATE VIRTUAL TABLE x2 USING dbstat('123');\n  SELECT * FROM x2;\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\ndo_execsql_test 7.1.4 {\n  CREATE VIRTUAL TABLE x3 USING dbstat(123);\n  SELECT * FROM x3;\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\n\ndo_execsql_test 7.2 {\n  DETACH 123;\n  DROP TABLE x2;\n  DROP TABLE x3;\n  ATTACH 'test.db2' AS '123corp';\n}\ndo_execsql_test 7.2.1 {\n  SELECT * FROM dbstat('123corp');\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\ndo_catchsql_test 7.2.2 {\n  SELECT * FROM dbstat(123corp);\n} {1 {unrecognized token: \"123corp\"}}\ndo_execsql_test 7.2.3 {\n  CREATE VIRTUAL TABLE x2 USING dbstat('123corp');\n  SELECT * FROM x2;\n} {\n  sqlite_master / 1 leaf 1 37 875 37 0 1024 \n  x1 / 2 leaf 1 4 1008 4 1024 1024\n}\ndo_catchsql_test 7.2.4 {\n  CREATE VIRTUAL TABLE x3 USING dbstat(123corp);\n  SELECT * FROM x3;\n} {1 {unrecognized token: \"123corp\"}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/statfault.test",
    "content": "# 2015 April 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix statfault\n\nifcapable !vtab||!compound {\n  finish_test\n  return\n}\n\nregister_dbstat_vtab db\ndo_execsql_test statfault-1 {\n  CREATE TABLE t1(a, b UNIQUE);\n  INSERT INTO t1 VALUES(1, randomblob(500));\n  INSERT INTO t1 VALUES(randomblob(500), 1);\n  INSERT INTO t1 VALUES(2, randomblob(250));\n  INSERT INTO t1 VALUES(randomblob(250), 2);\n  CREATE VIRTUAL TABLE sss USING dbstat;\n} {}\nfaultsim_save_and_close\n\ndo_faultsim_test 1 -faults * -prep {\n  faultsim_restore_and_reopen\n  register_dbstat_vtab db\n  execsql { SELECT 1 FROM sqlite_master LIMIT 1 }\n} -body {\n  execsql { SELECT count(*) FROM sss }\n} -test {\n  faultsim_test_result {0 8} \n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/stmt.test",
    "content": "# 2010 February 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# The tests in this file check that SQLite uses (or does not use) a\n# statement journal for various SQL statements.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test stmt-1.1 {\n  execsql { CREATE TABLE t1(a integer primary key, b INTEGER NOT NULL) }\n} {}\n\n# The following tests verify the method used for the tests in this file -\n# that if a statement journal is required by a statement it is opened and\n# remains open until the current transaction is committed or rolled back.\n#\n# This only work if SQLITE_TEMP_STORE!=3\n#\nif {$::TEMP_STORE==3} {\n  finish_test\n  return\n}\ndo_test stmt-1.2 {\n  set sqlite_open_file_count\n} {1}\ndo_test stmt-1.3 {\n  execsql {\n    PRAGMA temp_store = file;\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 1);\n  }\n  set sqlite_open_file_count\n} {2}\ndo_test stmt-1.4 {\n  execsql {\n    INSERT INTO t1 SELECT a+1, b+1 FROM t1;\n  }\n  set sqlite_open_file_count\n  # 2016-03-04: statement-journal open deferred\n} {2}\ndo_test stmt-1.5 {\n  execsql COMMIT\n  set sqlite_open_file_count\n} {1}\ndo_test stmt-1.6.1 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 SELECT a+2, b+2 FROM t1;\n  }\n  set sqlite_open_file_count\n} {2}\ndo_test stmt-1.6.2 {\n  execsql { INSERT INTO t1 SELECT a+4, b+4 FROM t1 }\n  set sqlite_open_file_count\n  # 2016-03-04: statement-journal open deferred\n} {2}\ndo_test stmt-1.7 {\n  execsql COMMIT\n  set sqlite_open_file_count\n} {1}\n\n\nproc filecount {testname sql expected} {\n  uplevel [list do_test $testname [subst -nocommand {\n    execsql BEGIN\n    execsql { $sql }\n    set ret [set sqlite_open_file_count]\n    execsql ROLLBACK\n    set ret\n  }] $expected]\n}\n\nfilecount stmt-2.1 { INSERT INTO t1 VALUES(9, 9)  } 2\nfilecount stmt-2.2 { REPLACE INTO t1 VALUES(9, 9) } 2\nfilecount stmt-2.3 { INSERT INTO t1 SELECT 9, 9   } 2\nfilecount stmt-2.4 { \n    INSERT INTO t1 SELECT 9, 9;\n    INSERT INTO t1 SELECT 10, 10;\n} 2\n\ndo_test stmt-2.5 {\n  execsql { CREATE INDEX i1 ON t1(b) }\n} {}\nfilecount stmt-2.6 { \n  REPLACE INTO t1 VALUES(5, 5);\n  REPLACE INTO t1 VALUES(5, 5); \n} 2\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/stmtvtab1.test",
    "content": "# 2017-06-29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Testing of the STMT virtual table.\n#\n# This also validates the SQLITE_STMTSTATUS_REPREPARE and\n# SQLITE_STMTSTATUS_RUN values for sqlite3_stmt_status().\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stmtvtab {\n  finish_test\n  return\n}\n\ndb cache flush\ndb cache size 20\nunset -nocomplain x y z\nset x giraffe\nset y mango\nset z alabama\ndo_execsql_test stmtvtab1-100 {\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES($a,$b,$c);\n  CREATE INDEX t1a ON t1(a);\n  SELECT run, sql FROM sqlite_stmt ORDER BY 1;\n} {1 {SELECT run, sql FROM sqlite_stmt ORDER BY 1;} 1 {CREATE INDEX t1a ON t1(a);} 1 {INSERT INTO t1 VALUES($a,$b,$c);} 1 {CREATE TABLE t1(a,b,c);}}\nset x neon\nset y event\nset z future\ndo_execsql_test stmtvtab1-110 {\n  INSERT INTO t1 VALUES($a,$b,$c);\n  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;\n} {1 2 {INSERT INTO t1 VALUES($a,$b,$c);}}\nset x network\nset y fit\nset z metal\ndo_execsql_test stmtvtab1-120 {\n  INSERT INTO t1 VALUES($a,$b,$c);\n  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;\n} {1 3 {INSERT INTO t1 VALUES($a,$b,$c);}}\nset x history\nset y detail\nset z grace\ndo_execsql_test stmtvtab1-130 {\n  CREATE INDEX t1b ON t1(b);\n  INSERT INTO t1 VALUES($a,$b,$c);\n  SELECT reprep,run,SQL FROM sqlite_stmt WHERE sql LIKE '%INSERT%' AND NOT busy;\n} {2 4 {INSERT INTO t1 VALUES($a,$b,$c);}}\n\n# All statements are still in cache\n#\ndo_execsql_test stmtvtab1-140 {\n  SELECT count(*) FROM sqlite_stmt WHERE NOT busy;\n} {6}\n\n# None of the prepared statements should use more than a couple thousand\n# bytes of memory\n#\n#db eval {SELECT mem, sql FROM sqlite_stmt} {puts [format {%5d %s} $mem $sql]}\ndo_execsql_test stmtvtab1-150 {\n  SELECT count(*) FROM sqlite_stmt WHERE mem>5000;\n} {0}\n\n# Flushing the cache clears all of the prepared statements.\n#\ndb cache flush\ndo_execsql_test stmtvtab1-160 {\n  SELECT * FROM sqlite_stmt WHERE NOT busy;\n} {}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/subjournal.test",
    "content": "# 2017 May 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix subjournal\n\ndo_execsql_test 1.0 {\n  PRAGMA temp_store = memory;\n  CREATE TABLE t1(a,b,c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n} {}\ndo_execsql_test 1.1 {\n  BEGIN;\n    INSERT INTO t1 VALUES(4, 5, 6);\n    SAVEPOINT one;\n      INSERT INTO t1 VALUES(7, 8, 9);\n    ROLLBACK TO one;\n    SELECT * FROM t1;\n} {1 2 3 4 5 6}\ndo_execsql_test 1.2 {\n  COMMIT;\n}\n\ndo_execsql_test 2.0 {\n  PRAGMA cache_size = 5;\n  CREATE TABLE t2(a BLOB);\n  CREATE INDEX i2 ON t2(a);\n  WITH s(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100\n  ) INSERT INTO t2 SELECT randomblob(500) FROM s;\n}\n\ndo_test 2.1 {\n  forcedelete test.db2\n  sqlite3 db2 test2.db\n  sqlite3_backup B db2 main db main\n  set nPage [db one {PRAGMA page_count}]\n  B step [expr $nPage-10]\n} {SQLITE_OK}\n\ndo_execsql_test 2.2 {\n  BEGIN;\n    UPDATE t2 SET a=randomblob(499);\n    SAVEPOINT two;\n      UPDATE t2 SET a=randomblob(498);\n    ROLLBACK TO two;\n  COMMIT;\n  PRAGMA integrity_check;\n} {ok}\n\ndo_test 2.3 {\n  B step 1000\n} {SQLITE_DONE}\ndo_test 2.4 {\n  B finish\n  execsql { PRAGMA integrity_check } db2\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/subquery.test",
    "content": "# 2005 January 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing correlated subqueries\n#\n# $Id: subquery.test,v 1.17 2009/01/09 01:12:28 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test subquery-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    INSERT INTO t1 VALUES(5,6);\n    INSERT INTO t1 VALUES(7,8);\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(1,1);\n    INSERT INTO t2 VALUES(3,9);\n    INSERT INTO t2 VALUES(5,25);\n    INSERT INTO t2 VALUES(7,49);\n    COMMIT;\n  }\n  execsql {\n    SELECT a, (SELECT y FROM t2 WHERE x=a) FROM t1 WHERE b<8\n  }\n} {1 1 3 9 5 25}\ndo_test subquery-1.2 {\n  execsql {\n    UPDATE t1 SET b=b+(SELECT y FROM t2 WHERE x=a);\n    SELECT * FROM t1;\n  }\n} {1 3 3 13 5 31 7 57}\n\ndo_test subquery-1.3 {\n  execsql {\n    SELECT b FROM t1 WHERE EXISTS(SELECT * FROM t2 WHERE y=a)\n  }\n} {3}\ndo_test subquery-1.4 {\n  execsql {\n    SELECT b FROM t1 WHERE NOT EXISTS(SELECT * FROM t2 WHERE y=a)\n  }\n} {13 31 57}\n\n# Simple tests to make sure correlated subqueries in WHERE clauses\n# are used by the query optimizer correctly.\ndo_test subquery-1.5 {\n  execsql {\n    SELECT a, x FROM t1, t2 WHERE t1.a = (SELECT x);\n  }\n} {1 1 3 3 5 5 7 7}\ndo_test subquery-1.6 {\n  execsql {\n    CREATE INDEX i1 ON t1(a);\n    SELECT a, x FROM t1, t2 WHERE t1.a = (SELECT x);\n  }\n} {1 1 3 3 5 5 7 7}\ndo_test subquery-1.7 {\n  execsql {\n    SELECT a, x FROM t2, t1 WHERE t1.a = (SELECT x);\n  }\n} {1 1 3 3 5 5 7 7}\n\n# Try an aggregate in both the subquery and the parent query.\ndo_test subquery-1.8 {\n  execsql {\n    SELECT count(*) FROM t1 WHERE a > (SELECT count(*) FROM t2);\n  }\n} {2}\n\n# Test a correlated subquery disables the \"only open the index\" optimization.\ndo_test subquery-1.9.1 {\n  execsql {\n    SELECT (y*2)>b FROM t1, t2 WHERE a=x;\n  }\n} {0 1 1 1}\ndo_test subquery-1.9.2 {\n  execsql {\n    SELECT a FROM t1 WHERE (SELECT (y*2)>b FROM t2 WHERE a=x); \n  }\n} {3 5 7}\n\n# Test that the flattening optimization works with subquery expressions.\ndo_test subquery-1.10.1 {\n  execsql {\n    SELECT (SELECT a), b FROM t1;\n  }\n} {1 3 3 13 5 31 7 57}\ndo_test subquery-1.10.2 {\n  execsql {\n    SELECT * FROM (SELECT (SELECT a), b FROM t1);\n  }\n} {1 3 3 13 5 31 7 57}\ndo_test subquery-1.10.3 {\n  execsql {\n    SELECT * FROM (SELECT (SELECT sum(a) FROM t1));\n  }\n} {16}\ndo_test subquery-1.10.4 {\n  execsql {\n    CREATE TABLE t5 (val int, period text PRIMARY KEY);\n    INSERT INTO t5 VALUES(5, '2001-3');\n    INSERT INTO t5 VALUES(10, '2001-4');\n    INSERT INTO t5 VALUES(15, '2002-1');\n    INSERT INTO t5 VALUES(5, '2002-2');\n    INSERT INTO t5 VALUES(10, '2002-3');\n    INSERT INTO t5 VALUES(15, '2002-4');\n    INSERT INTO t5 VALUES(10, '2003-1');\n    INSERT INTO t5 VALUES(5, '2003-2');\n    INSERT INTO t5 VALUES(25, '2003-3');\n    INSERT INTO t5 VALUES(5, '2003-4');\n\n    SELECT period, vsum\n    FROM (SELECT \n      a.period,\n      (select sum(val) from t5 where period between a.period and '2002-4') vsum\n      FROM t5 a where a.period between '2002-1' and '2002-4')\n    WHERE vsum < 45 ;\n  }\n} {2002-2 30 2002-3 25 2002-4 15}\ndo_test subquery-1.10.5 {\n  execsql {\n    SELECT period, vsum from\n      (select a.period,\n      (select sum(val) from t5 where period between a.period and '2002-4') vsum\n    FROM t5 a where a.period between '2002-1' and '2002-4') \n    WHERE vsum < 45 ;\n  }\n} {2002-2 30 2002-3 25 2002-4 15}\ndo_test subquery-1.10.6 {\n  execsql {\n    DROP TABLE t5;\n  }\n} {}\n\n\n\n#------------------------------------------------------------------\n# The following test cases - subquery-2.* - are not logically\n# organized. They're here largely because they were failing during\n# one stage of development of sub-queries.\n#\ndo_test subquery-2.1 {\n  execsql {\n    SELECT (SELECT 10);\n  }\n} {10}\ndo_test subquery-2.2.1 {\n  execsql {\n    CREATE TABLE t3(a PRIMARY KEY, b);\n    INSERT INTO t3 VALUES(1, 2);\n    INSERT INTO t3 VALUES(3, 1);\n  }\n} {}\ndo_test subquery-2.2.2 {\n  execsql {\n    SELECT * FROM t3 WHERE a IN (SELECT b FROM t3);\n  }\n} {1 2}\ndo_test subquery-2.2.3 {\n  execsql {\n    DROP TABLE t3;\n  }\n} {}\ndo_test subquery-2.3.1 {\n  execsql {\n    CREATE TABLE t3(a TEXT);\n    INSERT INTO t3 VALUES('10');\n  }\n} {}\ndo_test subquery-2.3.2 {\n  execsql {\n    SELECT a IN (10.0, 20) FROM t3;\n  }\n} {0}\ndo_test subquery-2.3.3 {\n  execsql {\n    DROP TABLE t3;\n  }\n} {}\ndo_test subquery-2.4.1 {\n  execsql {\n    CREATE TABLE t3(a TEXT);\n    INSERT INTO t3 VALUES('XX');\n  }\n} {}\ndo_test subquery-2.4.2 {\n  execsql {\n    SELECT count(*) FROM t3 WHERE a IN (SELECT 'XX')\n  }\n} {1}\ndo_test subquery-2.4.3 {\n  execsql {\n    DROP TABLE t3;\n  }\n} {}\ndo_test subquery-2.5.1 {\n  execsql {\n    CREATE TABLE t3(a INTEGER);\n    INSERT INTO t3 VALUES(10);\n\n    CREATE TABLE t4(x TEXT);\n    INSERT INTO t4 VALUES('10.0');\n  }\n} {}\ndo_test subquery-2.5.2 {\n  # In the expr \"x IN (SELECT a FROM t3)\" the RHS of the IN operator\n  # has text affinity and the LHS has integer affinity.  The rule is\n  # that we try to convert both sides to an integer before doing the\n  # comparision.  Hence, the integer value 10 in t3 will compare equal\n  # to the string value '10.0' in t4 because the t4 value will be\n  # converted into an integer.\n  execsql {\n    SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);\n  }\n} {10.0}\ndo_test subquery-2.5.3.1 {\n  # The t4i index cannot be used to resolve the \"x IN (...)\" constraint\n  # because the constraint has integer affinity but t4i has text affinity.\n  execsql {\n    CREATE INDEX t4i ON t4(x);\n    SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);\n  }\n} {10.0}\ndo_test subquery-2.5.3.2 {\n  # Verify that the t4i index was not used in the previous query\n  execsql {\n    EXPLAIN QUERY PLAN\n    SELECT * FROM t4 WHERE x IN (SELECT a FROM t3);\n  }\n} {~/t4i/}\ndo_test subquery-2.5.4 {\n  execsql {\n    DROP TABLE t3;\n    DROP TABLE t4;\n  }\n} {}\n\n#------------------------------------------------------------------\n# The following test cases - subquery-3.* - test tickets that\n# were raised during development of correlated subqueries.\n#\n\n# Ticket 1083\nifcapable view {\n  do_test subquery-3.1 {\n    catchsql { DROP TABLE t1; }\n    catchsql { DROP TABLE t2; }\n    execsql {\n      CREATE TABLE t1(a,b);\n      INSERT INTO t1 VALUES(1,2);\n      CREATE VIEW v1 AS SELECT b FROM t1 WHERE a>0;\n      CREATE TABLE t2(p,q);\n      INSERT INTO t2 VALUES(2,9);\n      SELECT * FROM v1 WHERE EXISTS(SELECT * FROM t2 WHERE p=v1.b);\n    }\n  } {2}\n  do_test subquery-3.1.1 {\n    execsql {\n      SELECT * FROM v1 WHERE EXISTS(SELECT 1);\n    }\n  } {2}\n} else {\n  catchsql { DROP TABLE t1; }\n  catchsql { DROP TABLE t2; }\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    CREATE TABLE t2(p,q);\n    INSERT INTO t2 VALUES(2,9);\n  }\n}\n\n# Ticket 1084\ndo_test subquery-3.2 {\n  catchsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n  }\n  execsql {\n    SELECT (SELECT t1.a) FROM t1;\n  }\n} {1}\n\n# Test Cases subquery-3.3.* test correlated subqueries where the\n# parent query is an aggregate query. Ticket #1105 is an example\n# of such a query.\n#\ndo_test subquery-3.3.1 {\n  execsql {\n    SELECT a, (SELECT b) FROM t1 GROUP BY a;\n  }\n} {1 2}\ndo_test subquery-3.3.2 {\n  catchsql {DROP TABLE t2}\n  execsql {\n    CREATE TABLE t2(c, d);\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(2, 'two');\n    SELECT a, (SELECT d FROM t2 WHERE a=c) FROM t1 GROUP BY a;\n  }\n} {1 one}\ndo_test subquery-3.3.3 {\n  execsql {\n    INSERT INTO t1 VALUES(2, 4);\n    SELECT max(a), (SELECT d FROM t2 WHERE a=c) FROM t1;\n  }\n} {2 two}\ndo_test subquery-3.3.4 {\n  execsql {\n    SELECT a, (SELECT (SELECT d FROM t2 WHERE a=c)) FROM t1 GROUP BY a;\n  }\n} {1 one 2 two}\ndo_test subquery-3.3.5 {\n  execsql {\n    SELECT a, (SELECT count(*) FROM t2 WHERE a=c) FROM t1;\n  }\n} {1 1 2 1}\n\n# The following tests check for aggregate subqueries in an aggregate\n# query.\n#\ndo_test subquery-3.4.1 {\n  execsql {\n    CREATE TABLE t34(x,y);\n    INSERT INTO t34 VALUES(106,4), (107,3), (106,5), (107,5);\n    SELECT a.x, avg(a.y)\n      FROM t34 AS a\n     GROUP BY a.x\n     HAVING NOT EXISTS( SELECT b.x, avg(b.y)\n                          FROM t34 AS b\n                         GROUP BY b.x\n                         HAVING avg(a.y) > avg(b.y));\n  }\n} {107 4.0}\ndo_test subquery-3.4.2 {\n  execsql {\n    SELECT a.x, avg(a.y) AS avg1\n      FROM t34 AS a\n     GROUP BY a.x\n     HAVING NOT EXISTS( SELECT b.x, avg(b.y) AS avg2\n                          FROM t34 AS b\n                         GROUP BY b.x\n                         HAVING avg1 > avg2);\n  }\n} {107 4.0}\ndo_test subquery-3.4.3 {\n  execsql {\n    SELECT\n       a.x,\n       avg(a.y),\n       NOT EXISTS ( SELECT b.x, avg(b.y)\n                      FROM t34 AS b\n                      GROUP BY b.x\n                     HAVING avg(a.y) > avg(b.y)),\n       EXISTS ( SELECT c.x, avg(c.y)\n                  FROM t34 AS c\n                  GROUP BY c.x\n                 HAVING avg(a.y) > avg(c.y))\n      FROM t34 AS a\n     GROUP BY a.x\n     ORDER BY a.x;\n  }\n} {106 4.5 0 1 107 4.0 1 0}\n\ndo_test subquery-3.5.1 {\n  execsql {\n    CREATE TABLE t35a(x); INSERT INTO t35a VALUES(1),(2),(3);\n    CREATE TABLE t35b(y); INSERT INTO t35b VALUES(98), (99);\n    SELECT max((SELECT avg(y) FROM t35b)) FROM t35a;\n  }\n} {98.5}\ndo_test subquery-3.5.2 {\n  execsql {\n    SELECT max((SELECT count(y) FROM t35b)) FROM t35a;\n  }\n} {2}\ndo_test subquery-3.5.3 {\n  execsql {\n    SELECT max((SELECT count() FROM t35b)) FROM t35a;\n  }\n} {2}\ndo_test subquery-3.5.4 {\n  catchsql {\n    SELECT max((SELECT count(x) FROM t35b)) FROM t35a;\n  }\n} {1 {misuse of aggregate: count()}}\ndo_test subquery-3.5.5 {\n  catchsql {\n    SELECT max((SELECT count(x) FROM t35b)) FROM t35a;\n  }\n} {1 {misuse of aggregate: count()}}\ndo_test subquery-3.5.6 {\n  catchsql {\n    SELECT max((SELECT a FROM (SELECT count(x) AS a FROM t35b))) FROM t35a;\n  }\n} {1 {misuse of aggregate: count()}}\ndo_test subquery-3.5.7 {\n  execsql {\n    SELECT max((SELECT a FROM (SELECT count(y) AS a FROM t35b))) FROM t35a;\n  }\n} {2}\n\n\n#------------------------------------------------------------------\n# These tests - subquery-4.* - use the TCL statement cache to try \n# and expose bugs to do with re-using statements that have been \n# passed to sqlite3_reset().\n#\n# One problem was that VDBE memory cells were not being initialized\n# to NULL on the second and subsequent executions.\n#\ndo_test subquery-4.1.1 {\n  execsql {\n    SELECT (SELECT a FROM t1);\n  }\n} {1}\ndo_test subquery-4.2 {\n  execsql {\n    DELETE FROM t1;\n    SELECT (SELECT a FROM t1);\n  }\n} {{}}\ndo_test subquery-4.2.1 {\n  execsql {\n    CREATE TABLE t3(a PRIMARY KEY);\n    INSERT INTO t3 VALUES(10);\n  }\n  execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1)}\n} {}\ndo_test subquery-4.2.2 {\n  execsql {INSERT INTO t3 VALUES((SELECT max(a) FROM t3)+1)}\n} {}\n\n#------------------------------------------------------------------\n# The subquery-5.* tests make sure string literals in double-quotes\n# are handled efficiently.  Double-quote literals are first checked\n# to see if they match any column names.  If there is not column name\n# match then those literals are used a string constants.  When a\n# double-quoted string appears, we want to make sure that the search\n# for a matching column name did not cause an otherwise static subquery\n# to become a dynamic (correlated) subquery.\n#\ndo_test subquery-5.1 {\n  proc callcntproc {n} {\n    incr ::callcnt\n    return $n\n  }\n  set callcnt 0\n  db function callcnt callcntproc\n  execsql {\n    CREATE TABLE t4(x,y);\n    INSERT INTO t4 VALUES('one',1);\n    INSERT INTO t4 VALUES('two',2);\n    INSERT INTO t4 VALUES('three',3);\n    INSERT INTO t4 VALUES('four',4);\n    CREATE TABLE t5(a,b);\n    INSERT INTO t5 VALUES(1,11);\n    INSERT INTO t5 VALUES(2,22);\n    INSERT INTO t5 VALUES(3,33);\n    INSERT INTO t5 VALUES(4,44);\n    SELECT b FROM t5 WHERE a IN \n       (SELECT callcnt(y)+0 FROM t4 WHERE x=\"two\")\n  }\n} {22}\ndo_test subquery-5.2 {\n  # This is the key test.  The subquery should have only run once.  If\n  # The double-quoted identifier \"two\" were causing the subquery to be\n  # processed as a correlated subquery, then it would have run 4 times.\n  set callcnt\n} {1}\n\n\n# Ticket #1380.  Make sure correlated subqueries on an IN clause work\n# correctly when the left-hand side of the IN operator is constant.\n#\ndo_test subquery-6.1 {\n  set callcnt 0\n  execsql {\n    SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=y)\n  }\n} {one two three four}\ndo_test subquery-6.2 {\n  set callcnt\n} {4}\ndo_test subquery-6.3 {\n  set callcnt 0\n  execsql {\n    SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=1)\n  }\n} {one two three four}\ndo_test subquery-6.4 {\n  set callcnt\n} {1}\n\nif 0 {   #############  disable until we get #2652 fixed\n# Ticket #2652.  Allow aggregate functions of outer queries inside\n# a non-aggregate subquery.\n#\ndo_test subquery-7.1 {\n  execsql {\n    CREATE TABLE t7(c7);\n    INSERT INTO t7 VALUES(1);\n    INSERT INTO t7 VALUES(2);\n    INSERT INTO t7 VALUES(3);\n    CREATE TABLE t8(c8);\n    INSERT INTO t8 VALUES(100);\n    INSERT INTO t8 VALUES(200);\n    INSERT INTO t8 VALUES(300);\n    CREATE TABLE t9(c9);\n    INSERT INTO t9 VALUES(10000);\n    INSERT INTO t9 VALUES(20000);\n    INSERT INTO t9 VALUES(30000);\n\n    SELECT (SELECT c7+c8 FROM t7) FROM t8;\n  }\n} {101 201 301}\ndo_test subquery-7.2 {\n  execsql {\n    SELECT (SELECT max(c7)+c8 FROM t7) FROM t8;\n  }\n} {103 203 303}\ndo_test subquery-7.3 {\n  execsql {\n    SELECT (SELECT c7+max(c8) FROM t8) FROM t7\n  }\n} {301}\ndo_test subquery-7.4 {\n  execsql {\n    SELECT (SELECT max(c7)+max(c8) FROM t8) FROM t7\n  }\n} {303}\ndo_test subquery-7.5 {\n  execsql {\n    SELECT (SELECT c8 FROM t8 WHERE rowid=max(c7)) FROM t7\n  }\n} {300}\ndo_test subquery-7.6 {\n  execsql {\n    SELECT (SELECT (SELECT max(c7+c8+c9) FROM t9) FROM t8) FROM t7\n  }\n} {30101 30102 30103}\ndo_test subquery-7.7 {\n  execsql {\n    SELECT (SELECT (SELECT c7+max(c8+c9) FROM t9) FROM t8) FROM t7\n  }\n} {30101 30102 30103}\ndo_test subquery-7.8 {\n  execsql {\n    SELECT (SELECT (SELECT max(c7)+c8+c9 FROM t9) FROM t8) FROM t7\n  }\n} {10103}\ndo_test subquery-7.9 {\n  execsql {\n    SELECT (SELECT (SELECT c7+max(c8)+c9 FROM t9) FROM t8) FROM t7\n  }\n} {10301 10302 10303}\ndo_test subquery-7.10 {\n  execsql {\n    SELECT (SELECT (SELECT c7+c8+max(c9) FROM t9) FROM t8) FROM t7\n  }\n} {30101 30102 30103}\ndo_test subquery-7.11 {\n  execsql {\n    SELECT (SELECT (SELECT max(c7)+max(c8)+max(c9) FROM t9) FROM t8) FROM t7\n  }\n} {30303}\n}  ;############# Disabled\n\n# 2015-04-21.\n# Verify that a memory leak in the table column type and collation analysis\n# is plugged.\n#\ndo_execsql_test subquery-8.1 {\n  CREATE TABLE t8(a TEXT, b INT);\n  SELECT (SELECT 0 FROM (SELECT * FROM t1)) AS x WHERE x;\n  SELECT (SELECT 0 FROM (SELECT * FROM (SELECT 0))) AS x WHERE x;\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/subquery2.test",
    "content": "# 2011 September 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing correlated subqueries\n#\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix subquery2\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test subquery2-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    INSERT INTO t1 VALUES(5,6);\n    INSERT INTO t1 VALUES(7,8);\n    CREATE TABLE t2(c,d);\n    INSERT INTO t2 VALUES(1,1);\n    INSERT INTO t2 VALUES(3,9);\n    INSERT INTO t2 VALUES(5,25);\n    INSERT INTO t2 VALUES(7,49);\n    CREATE TABLE t3(e,f);\n    INSERT INTO t3 VALUES(1,1);\n    INSERT INTO t3 VALUES(3,27);\n    INSERT INTO t3 VALUES(5,125);\n    INSERT INTO t3 VALUES(7,343);\n    COMMIT;\n  }\n  execsql {\n    SELECT a FROM t1\n     WHERE b IN (SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));\n  }\n} {1 3 5 7}\ndo_test subquery2-1.2 {\n  execsql {\n    CREATE INDEX t1b ON t1(b);\n    SELECT a FROM t1\n     WHERE b IN (SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));\n  }\n} {1 3 5 7}\n\ndo_test subquery2-1.11 {\n  execsql {\n    SELECT a FROM t1\n     WHERE +b=(SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));\n  }\n} {1}\ndo_test subquery2-1.12 {\n  execsql {\n    SELECT a FROM t1\n     WHERE b=(SELECT x+1 FROM (SELECT DISTINCT f/(a*a) AS x FROM t3));\n  }\n} {1}\n\ndo_test subquery2-1.21 {\n  execsql {\n    SELECT a FROM t1\n     WHERE +b=(SELECT x+1 FROM \n                 (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))\n  }\n} {1 3 5 7}\ndo_test subquery2-1.22 {\n  execsql {\n    SELECT a FROM t1\n     WHERE b=(SELECT x+1 FROM \n                 (SELECT DISTINCT f/d AS x FROM t2 JOIN t3 ON d*a=f))\n  }\n} {1 3 5 7}\n\n#-------------------------------------------------------------------------\n# Test that ticket d6b36be38a has been fixed.\ndo_execsql_test 2.1 {\n  CREATE TABLE t4(a, b);\n  CREATE TABLE t5(a, b);\n  INSERT INTO t5 VALUES(3, 5);\n\n  INSERT INTO t4 VALUES(1, 1);\n  INSERT INTO t4 VALUES(2, 3);\n  INSERT INTO t4 VALUES(3, 6);\n  INSERT INTO t4 VALUES(4, 10);\n  INSERT INTO t4 VALUES(5, 15);\n}\n\ndo_execsql_test 2.2 {\n  SELECT * \n  FROM (SELECT * FROM t4 ORDER BY a LIMIT -1 OFFSET 1) \n  LIMIT (SELECT a FROM t5)\n} {2 3   3 6   4 10}\n\n############################################################################\n# Ticket http://www.sqlite.org/src/info/d11a6e908f (2014-09-20)\n# Query planner fault on three-way nested join with compound inner SELECT \n#\ndo_execsql_test 3.0 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t1 (id INTEGER PRIMARY KEY, data TEXT);\n  INSERT INTO t1(id,data) VALUES(9,'nine-a');\n  INSERT INTO t1(id,data) VALUES(10,'ten-a');\n  INSERT INTO t1(id,data) VALUES(11,'eleven-a');\n  CREATE TABLE t2 (id INTEGER PRIMARY KEY, data TEXT);\n  INSERT INTO t2(id,data) VALUES(9,'nine-b');\n  INSERT INTO t2(id,data) VALUES(10,'ten-b');\n  INSERT INTO t2(id,data) VALUES(11,'eleven-b');\n  \n  SELECT id FROM (\n    SELECT id,data FROM (\n       SELECT * FROM t1 UNION ALL SELECT * FROM t2\n    )\n    WHERE id=10 ORDER BY data\n  );\n} {10 10}\ndo_execsql_test 3.1 {\n  SELECT data FROM (\n     SELECT 'dummy', data FROM (\n       SELECT data FROM t1 UNION ALL SELECT data FROM t1\n     ) ORDER BY data\n  );\n} {eleven-a eleven-a nine-a nine-a ten-a ten-a}\ndo_execsql_test 3.2 {\n  DROP TABLE IF EXISTS t3;\n  DROP TABLE IF EXISTS t4;\n  CREATE TABLE t3(id INTEGER, data TEXT);\n  CREATE TABLE t4(id INTEGER, data TEXT);\n  INSERT INTO t3 VALUES(4, 'a'),(2,'c');\n  INSERT INTO t4 VALUES(3, 'b'),(1,'d');\n\n  SELECT data, id FROM (\n    SELECT id, data FROM (\n       SELECT * FROM t3 UNION ALL SELECT * FROM t4\n    ) ORDER BY data\n  );\n} {a 4 b 3 c 2 d 1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/subselect.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing SELECT statements that are part of\n# expressions.\n#\n# $Id: subselect.test,v 1.16 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Omit this whole file if the library is build without subquery support.\nifcapable !subquery {\n  finish_test\n  return\n}\n\n# Basic sanity checking.  Try a simple subselect.\n#\ndo_test subselect-1.1 {\n  execsql {\n    CREATE TABLE t1(a int, b int);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    INSERT INTO t1 VALUES(5,6);\n  }\n  execsql {SELECT * FROM t1 WHERE a = (SELECT count(*) FROM t1)}\n} {3 4}\n\n# Try a select with more than one result column.\n#\ndo_test subselect-1.2 {\n  set v [catch {execsql {SELECT * FROM t1 WHERE a = (SELECT * FROM t1)}} msg]\n  lappend v $msg\n} {1 {row value misused}}\n\n# A subselect without an aggregate.\n#\ndo_test subselect-1.3a {\n  execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=2)}\n} {2}\ndo_test subselect-1.3b {\n  execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=4)}\n} {4}\ndo_test subselect-1.3c {\n  execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=6)}\n} {6}\ndo_test subselect-1.3d {\n  execsql {SELECT b from t1 where a = (SELECT a FROM t1 WHERE b=8)}\n} {}\nifcapable compound {\n  do_test subselect-1.3e {\n    execsql {\n      SELECT b FROM t1\n       WHERE a = (SELECT a FROM t1 UNION SELECT b FROM t1 ORDER BY 1);\n    }\n  } {2}\n}\n\n# What if the subselect doesn't return any value.  We should get\n# NULL as the result.  Check it out.\n#\ndo_test subselect-1.4 {\n  execsql {SELECT b from t1 where a = coalesce((SELECT a FROM t1 WHERE b=5),1)}\n} {2}\n\n# Try multiple subselects within a single expression.\n#\ndo_test subselect-1.5 {\n  execsql {\n    CREATE TABLE t2(x int, y int);\n    INSERT INTO t2 VALUES(1,2);\n    INSERT INTO t2 VALUES(2,4);\n    INSERT INTO t2 VALUES(3,8);\n    INSERT INTO t2 VALUES(4,16);\n  }\n  execsql {\n    SELECT y from t2 \n    WHERE x = (SELECT sum(b) FROM t1 where a notnull) - (SELECT sum(a) FROM t1)\n  }\n} {8}\n\n# Try something useful.  Delete every entry from t2 where the\n# x value is less than half of the maximum.\n#\ndo_test subselect-1.6 {\n  execsql {DELETE FROM t2 WHERE x < 0.5*(SELECT max(x) FROM t2)}\n  execsql {SELECT x FROM t2 ORDER BY x}\n} {2 3 4}\n\n# Make sure sorting works for SELECTs there used as a scalar expression.\n#\ndo_test subselect-2.1 {\n  execsql {\n    SELECT (SELECT a FROM t1 ORDER BY a), (SELECT a FROM t1 ORDER BY a DESC)\n  }\n} {1 5}\ndo_test subselect-2.2 {\n  execsql {\n    SELECT 1 IN (SELECT a FROM t1 ORDER BY a);\n  }\n} {1}\ndo_test subselect-2.3 {\n  execsql {\n    SELECT 2 IN (SELECT a FROM t1 ORDER BY a DESC);\n  }\n} {0}\n\n# Verify that the ORDER BY clause is honored in a subquery.\n#\nifcapable compound {\ndo_test subselect-3.1 {\n  execsql {\n    CREATE TABLE t3(x int);\n    INSERT INTO t3 SELECT a FROM t1 UNION ALL SELECT b FROM t1;\n    SELECT * FROM t3 ORDER BY x;\n  }\n} {1 2 3 4 5 6}\n} ;# ifcapable compound\nifcapable !compound {\ndo_test subselect-3.1 {\n  execsql {\n    CREATE TABLE t3(x int);\n    INSERT INTO t3 SELECT a FROM t1; \n    INSERT INTO t3 SELECT b FROM t1;\n    SELECT * FROM t3 ORDER BY x;\n  }\n} {1 2 3 4 5 6}\n} ;# ifcapable !compound\n\ndo_test subselect-3.2 {\n  execsql {\n    SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x LIMIT 2);\n  }\n} {3}\ndo_test subselect-3.3 {\n  execsql {\n    SELECT sum(x) FROM (SELECT x FROM t3 ORDER BY x DESC LIMIT 2);\n  }\n} {11}\ndo_test subselect-3.4 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x);\n  }\n} {1}\ndo_test subselect-3.5 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x DESC);\n  }\n} {6}\ndo_test subselect-3.6 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1);\n  }\n} {1}\ndo_test subselect-3.7 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1);\n  }\n} {6}\ndo_test subselect-3.8 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x LIMIT 1 OFFSET 2);\n  }\n} {3}\ndo_test subselect-3.9 {\n  execsql {\n    SELECT (SELECT x FROM t3 ORDER BY x DESC LIMIT 1 OFFSET 2);\n  }\n} {4}\ndo_test subselect-3.10 {\n  execsql {\n    SELECT x FROM t3 WHERE x IN\n       (SELECT x FROM t3 ORDER BY x DESC LIMIT 1 OFFSET 2);\n  }\n} {4}\n\n# Ticket #2295.\n# Make sure type affinities work correctly on subqueries with\n# an ORDER BY clause.\n#\ndo_test subselect-4.1 {\n  execsql {\n    CREATE TABLE t4(a TEXT, b TEXT);\n    INSERT INTO t4 VALUES('a','1');\n    INSERT INTO t4 VALUES('b','2');\n    INSERT INTO t4 VALUES('c','3');\n    SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b);\n  }\n} {a b c}\ndo_test subselect-4.2 {\n  execsql {\n    SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b LIMIT 1);\n  }\n} {a}\ndo_test subselect-4.3 {\n  execsql {\n    SELECT a FROM t4 WHERE b IN (SELECT b FROM t4 ORDER BY b DESC LIMIT 1);\n  }\n} {c}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/substr.test",
    "content": "# 2007 May 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the built-in SUBSTR() functions.\n#\n# $Id: substr.test,v 1.7 2009/02/03 13:10:54 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !tclvar {\n  finish_test\n  return\n}\n\n# Create a table to work with.\n#\nexecsql { \n  CREATE TABLE t1(t text, b blob)\n}\nproc substr-test {id string i1 i2 result} {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1(t) VALUES($string)\n  }\n  do_test substr-$id.1 [subst {\n    execsql {\n      SELECT substr(t, $i1, $i2) FROM t1\n    }\n  }] [list $result]\n  set qstr '[string map {' ''} $string]'\n  do_test substr-$id.2 [subst {\n    execsql {\n      SELECT substr($qstr, $i1, $i2)\n    }\n  }] [list $result]\n}\nproc subblob-test {id hex i1 i2 hexresult} {\n  db eval \"\n    DELETE FROM t1;\n    INSERT INTO t1(b) VALUES(x'$hex')\n  \"\n  do_test substr-$id.1 [subst {\n    execsql {\n      SELECT hex(substr(b, $i1, $i2)) FROM t1\n    }\n  }] [list $hexresult]\n  do_test substr-$id.2 [subst {\n    execsql {\n      SELECT hex(substr(x'$hex', $i1, $i2))\n    }\n  }] [list $hexresult]\n}\n\n# Basic SUBSTR functionality\n#\nsubstr-test 1.1 abcdefg 1 1 a\nsubstr-test 1.2 abcdefg 2 1 b\nsubstr-test 1.3 abcdefg 1 2 ab\nsubstr-test 1.4 abcdefg 1 100 abcdefg\nsubstr-test 1.5 abcdefg 0 2 a\nsubstr-test 1.6 abcdefg -1 1 g\nsubstr-test 1.7 abcdefg -1 10 g\nsubstr-test 1.8 abcdefg -5 3 cde\nsubstr-test 1.9 abcdefg -7 3 abc\nsubstr-test 1.10 abcdefg -100 98 abcde\nsubstr-test 1.11 abcdefg 5 -1 d\nsubstr-test 1.12 abcdefg 5 -4 abcd\nsubstr-test 1.13 abcdefg 5 -5 abcd\nsubstr-test 1.14 abcdefg -5 -1 b\nsubstr-test 1.15 abcdefg -5 -2 ab\nsubstr-test 1.16 abcdefg -5 -3 ab\nsubstr-test 1.17 abcdefg 100 200 {}\nsubstr-test 1.18 abcdefg 200 100 {}\n\n# Make sure NULL is returned if any parameter is NULL\n#\ndo_test substr-1.90 {\n  db eval {SELECT ifnull(substr(NULL,1,1),'nil')}\n} nil\ndo_test substr-1.91 {\n  db eval {SELECT ifnull(substr(NULL,1),'nil')}\n} nil\ndo_test substr-1.92 {\n  db eval {SELECT ifnull(substr('abcdefg',NULL,1),'nil')}\n} nil\ndo_test substr-1.93 {\n  db eval {SELECT ifnull(substr('abcdefg',NULL),'nil')}\n} nil\ndo_test substr-1.94 {\n  db eval {SELECT ifnull(substr('abcdefg',1,NULL),'nil')}\n} nil\n\n# Make sure everything works with long unicode characters\n#\nsubstr-test 2.1 \\u1234\\u2345\\u3456 1 1 \\u1234\nsubstr-test 2.2 \\u1234\\u2345\\u3456 2 1 \\u2345\nsubstr-test 2.3 \\u1234\\u2345\\u3456 1 2 \\u1234\\u2345\nsubstr-test 2.4 \\u1234\\u2345\\u3456 -1 1 \\u3456\nsubstr-test 2.5 a\\u1234b\\u2345c\\u3456c -5 3 b\\u2345c\nsubstr-test 2.6 a\\u1234b\\u2345c\\u3456c -2 -3 b\\u2345c\n\n# Basic functionality for BLOBs\n#\nsubblob-test 3.1 61626364656667 1 1 61\nsubblob-test 3.2 61626364656667 2 1 62\nsubblob-test 3.3 61626364656667 1 2 6162\nsubblob-test 3.4 61626364656667 1 100 61626364656667\nsubblob-test 3.5 61626364656667 0 2 61\nsubblob-test 3.6 61626364656667 -1 1 67\nsubblob-test 3.7 61626364656667 -1 10 67\nsubblob-test 3.8 61626364656667 -5 3 636465\nsubblob-test 3.9 61626364656667 -7 3 616263\nsubblob-test 3.10 61626364656667 -100 98 6162636465\nsubblob-test 3.11 61626364656667 100 200 {}\nsubblob-test 3.12 61626364656667 200 100 {}\n\n# If these blobs were strings, then they would contain multi-byte\n# characters.  But since they are blobs, the substr indices refer\n# to bytes.\n#\nsubblob-test 4.1 61E188B462E28D8563E3919663 1 1 61\nsubblob-test 4.2 61E188B462E28D8563E3919663 2 1 E1\nsubblob-test 4.3 61E188B462E28D8563E3919663 1 2 61E1\nsubblob-test 4.4 61E188B462E28D8563E3919663 -2 1 96\nsubblob-test 4.5 61E188B462E28D8563E3919663 -5 4 63E39196\nsubblob-test 4.6 61E188B462E28D8563E3919663 -100 98 61E188B462E28D8563E391 \n\n# Two-argument SUBSTR\n#\nproc substr-2-test {id string idx result} {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1(t) VALUES($string)\n  }\n  do_test substr-$id.1 [subst {\n    execsql {\n      SELECT substr(t, $idx) FROM t1\n    }\n  }] [list $result]\n  set qstr '[string map {' ''} $string]'\n  do_test substr-$id.2 [subst {\n    execsql {\n      SELECT substr($qstr, $idx)\n    }\n  }] [list $result]\n}\nsubstr-2-test 5.1 abcdefghijklmnop 5 efghijklmnop\nsubstr-2-test 5.2 abcdef -5 bcdef\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/subtype1.test",
    "content": "# 2015-09-10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests for sqlite3_value_subtype() and\n# sqlite3_result_subtype() interfaces.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test subtype1-100 {\n  SELECT test_getsubtype('hello');\n} {0}\ndo_execsql_test subtype1-110 {\n  SELECT test_getsubtype(test_setsubtype('hello',123));\n} {123}\ndo_execsql_test subtype1-120 {\n  SELECT typeof(test_setsubtype('hello',123));\n} {text}\ndo_execsql_test subtype1-130 {\n  SELECT test_setsubtype('hello',123);\n} {hello}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/superlock.test",
    "content": "# 2010 November 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\n\nset testprefix superlock\ndo_not_use_codec\n\n# Test organization:\n#\n#   1.*: Test superlock on a rollback database. Test that once the db is\n#        superlocked, it is not possible for a second client to read from\n#        it.\n#\n#   2.*: Test superlock on a WAL database with zero frames in the WAL file.\n#        Test that once the db is superlocked, it is not possible to read,\n#        write or checkpoint the db.\n#\n#   3.*: As 2.*, for WAL databases with one or more frames in the WAL.\n#\n#   4.*: As 2.*, for WAL databases with one or more checkpointed frames \n#        in the WAL.\n#\n#   5.*: Test that a call to sqlite3demo_superlock() uses the busy handler\n#        correctly to wait for existing clients to clear on a WAL database.\n#        And returns SQLITE_BUSY if no busy handler is defined or the busy\n#        handler returns 0 before said clients relinquish their locks.\n#\n#   6.*: Test that if a superlocked WAL database is overwritten, existing\n#        clients run the recovery to build the new wal-index after the \n#        superlock is released.\n#        \n#\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  PRAGMA journal_mode = DELETE;\n} {delete}\n\nifcapable !wal {\n  finish_test\n  return\n}\n\ndo_test 1.2 { sqlite3demo_superlock unlock test.db } {unlock}\ndo_catchsql_test 1.3 { SELECT * FROM t1 } {1 {database is locked}}\ndo_test 1.4 { unlock } {}\n\ndo_execsql_test 2.1 { \n  INSERT INTO t1 VALUES(3, 4);\n  PRAGMA journal_mode = WAL;\n} {wal}\n\ndo_test 2.2 { sqlite3demo_superlock unlock test.db } {unlock}\ndo_catchsql_test 2.3 { SELECT * FROM t1 }           {1 {database is locked}}\ndo_catchsql_test 2.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}\ndo_catchsql_test 2.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}\ndo_test 2.6 { unlock } {}\n\ndo_execsql_test 3.1 { INSERT INTO t1 VALUES(3, 4) } \n\ndo_test 3.2 { sqlite3demo_superlock unlock test.db } {unlock}\ndo_catchsql_test 3.3 { SELECT * FROM t1 }           {1 {database is locked}}\ndo_catchsql_test 3.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}\ndo_catchsql_test 3.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}\ndo_test 3.6 { unlock } {}\n\n# At this point the WAL file consists of a single frame only - written\n# by test case 3.1. If the ZERO_DAMAGE flag were not set, it would consist\n# of two frames - the frame written by 3.1 and a padding frame.\ndo_execsql_test 4.1 { PRAGMA wal_checkpoint } {0 1 1}\n\ndo_test 4.2 { sqlite3demo_superlock unlock test.db } {unlock}\ndo_catchsql_test 4.3 { SELECT * FROM t1 }           {1 {database is locked}}\ndo_catchsql_test 4.4 { INSERT INTO t1 VALUES(5, 6)} {1 {database is locked}}\ndo_catchsql_test 4.5 { PRAGMA wal_checkpoint }      {0 {1 -1 -1}}\ndo_test 4.6 { unlock } {}\n\ndo_multiclient_test tn {\n\n  proc busyhandler {x} {\n    switch -- $x {\n      1 { sql1 \"COMMIT\" }\n      2 { sql2 \"COMMIT\" }\n      3 { sql3 \"COMMIT\" }\n    }\n    lappend ::busylist $x\n    return 1\n  }\n  set ::busylist [list]\n\n  do_test 5.$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      PRAGMA journal_mode = WAL;\n      INSERT INTO t1 VALUES(1, 2);\n    }\n  } {wal}\n\n  do_test 5.$tn.2 {\n    sql1 { BEGIN ; SELECT * FROM t1 }\n    sql2 { BEGIN ; INSERT INTO t1 VALUES(3, 4) }\n    sql3 { BEGIN ; SELECT * FROM t1 }\n  } {1 2}\n\n  do_test 5.$tn.3 {\n    set ::busylist [list]\n    sqlite3demo_superlock unlock test.db \"\" busyhandler\n    set ::busylist\n  } {0 1 2 3}\n\n  do_test 5.$tn.4 { csql2 { SELECT * FROM t1 } } {1 {database is locked}}\n  do_test 5.$tn.5 { \n    csql3 { INSERT INTO t1 VALUES(5, 6) } \n  } {1 {database is locked}}\n  do_test 5.$tn.6 { csql1 \"PRAGMA wal_checkpoint\" } {0 {1 -1 -1}}\n\n  do_test 5.$tn.7 { unlock } {}\n\n  \n  do_test 5.$tn.8 {\n    sql1 { BEGIN ; SELECT * FROM t1 }\n    sql2 { BEGIN ; INSERT INTO t1 VALUES(5, 6) }\n    sql3 { BEGIN ; SELECT * FROM t1 }\n  } {1 2 3 4}\n\n  do_test 5.$tn.9 { \n    list [catch {sqlite3demo_superlock unlock test.db} msg] $msg\n  } {1 {database is locked}}\n  do_test 5.$tn.10 { \n    sql1 COMMIT\n    list [catch {sqlite3demo_superlock unlock test.db} msg] $msg\n  } {1 {database is locked}}\n  do_test 5.$tn.11 { \n    sql2 COMMIT\n    list [catch {sqlite3demo_superlock unlock test.db} msg] $msg\n  } {1 {database is locked}}\n  do_test 5.$tn.12 { \n    sql3 COMMIT\n    list [catch {sqlite3demo_superlock unlock test.db} msg] $msg\n  } {0 unlock}\n  unlock\n\n\n  do_test 5.$tn.13 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6}\n  do_test 5.$tn.14 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}\n  do_test 5.$tn.15 { sqlite3demo_superlock unlock test.db } {unlock}\n  do_test 5.$tn.16 { unlock } {}\n  do_test 5.$tn.17 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}\n  do_test 5.$tn.18 { sql1 { SELECT * FROM t1 } } {1 2 3 4 5 6}\n  do_test 5.$tn.19 { sql2 { SELECT * FROM t1 } } {1 2 3 4 5 6}\n}\n\nproc read_content {file} {\n  if {[file exists $file]==0} {return \"\"}\n  set fd [open $file]\n  fconfigure $fd -encoding binary -translation binary\n  set content [read $fd]\n  close $fd\n  return $content\n}\n\nproc write_content {file content} {\n  set fd [open $file w+]\n  fconfigure $fd -encoding binary -translation binary\n  puts -nonewline $fd $content\n  close $fd\n}\n\n# Both $file1 and $file2 are database files. This function takes a \n# superlock on each, then exchanges the content of the two files (i.e.\n# overwrites $file1 with the initial contents of $file2, and overwrites\n# $file2 with the initial contents of $file1). The contents of any WAL \n# file is also exchanged.\n#\nproc db_swap {file1 file2} {\n  sqlite3demo_superlock unlock1 $file1\n  sqlite3demo_superlock unlock2 $file2\n\n  set db1 [read_content $file1]\n  set db2 [read_content $file2]\n  write_content $file1 $db2\n  write_content $file2 $db1\n\n  set wal1 [read_content ${file1}-wal]\n  set wal2 [read_content ${file2}-wal]\n  write_content ${file1}-wal $wal2\n  write_content ${file2}-wal $wal1\n\n  unlock1\n  unlock2\n}\n\nforcedelete test.db\nsqlite3 db  test.db\ndo_execsql_test 6.1 {\n  ATTACH 'test.db2' AS aux;\n  PRAGMA aux.journal_mode = wal;\n  CREATE TABLE aux.t2(x, y);\n  INSERT INTO aux.t2 VALUES('a', 'b');\n  PRAGMA schema_version = 450;\n  DETACH aux;\n\n  PRAGMA main.journal_mode = wal;\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  SELECT * FROM t1;\n} {wal wal 1 2 3 4}\n\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.2 { SELECT * FROM t1 } {1 {no such table: t1}}\ndo_catchsql_test 6.3 { SELECT * FROM t2 } {0 {a b}}\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.4 { SELECT * FROM t1 } {0 {1 2 3 4}}\ndo_catchsql_test 6.5 { SELECT * FROM t2 } {1 {no such table: t2}}\n\ndo_execsql_test  6.6 { PRAGMA wal_checkpoint } {0 0 0}\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.7 { SELECT * FROM t1 } {1 {no such table: t1}}\ndo_catchsql_test 6.8 { SELECT * FROM t2 } {0 {a b}}\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.9 { SELECT * FROM t1 } {0 {1 2 3 4}}\ndo_catchsql_test 6.10 { SELECT * FROM t2 } {1 {no such table: t2}}\n\nif {[nonzero_reserved_bytes]} {\n  # Vacuum with a size change is not allowed with the codec\n  do_execsql_test  6.11codec { \n    PRAGMA journal_mode = delete;\n    VACUUM;\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(5, 6);\n  } {delete wal}\n} else {\n  do_execsql_test  6.11 { \n    PRAGMA journal_mode = delete;\n    PRAGMA page_size = 512;\n    VACUUM;\n    PRAGMA journal_mode = wal;\n    INSERT INTO t1 VALUES(5, 6);\n  } {delete wal}\n}\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.12 { SELECT * FROM t1 } {1 {no such table: t1}}\ndo_catchsql_test 6.13 { SELECT * FROM t2 } {0 {a b}}\n\ndb_swap test.db2 test.db\ndo_catchsql_test 6.14 { SELECT * FROM t1 } {0 {1 2 3 4 5 6}}\ndo_catchsql_test 6.15 { SELECT * FROM t2 } {1 {no such table: t2}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/swarmvtab.test",
    "content": "# 2017-07-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the \"swarmvtab\" extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix swarmvtab\ndo_not_use_codec\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nload_static_extension db unionvtab\n\nset nFile $sqlite_open_file_count\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t0(a INTEGER PRIMARY KEY, b TEXT);\n  WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<400) \n  INSERT INTO t0 SELECT i, hex(randomblob(50)) FROM s;\n\n  CREATE TABLE dir(f, t, imin, imax);\n}\n\ndo_test 1.1 {\n  for {set i 0} {$i < 40} {incr i} {\n    set iMin [expr $i*10 + 1]\n    set iMax [expr $iMin+9]\n\n    forcedelete \"test.db$i\"\n    execsql [subst {\n      ATTACH 'test.db$i' AS aux;\n      CREATE TABLE aux.t$i (a INTEGER PRIMARY KEY, b TEXT);\n      INSERT INTO aux.t$i SELECT * FROM t0 WHERE a BETWEEN $iMin AND $iMax;\n      DETACH aux;\n      INSERT INTO dir VALUES('test.db$i', 't$i', $iMin, $iMax);\n    }]\n  }\n\n  execsql {\n    CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');\n  }\n} {}\n\ndo_execsql_test 1.2 { \n  DROP TABLE s1; \n} {}\n\ndo_execsql_test 1.3 {\n  CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');\n  SELECT count(*) FROM s1 WHERE rowid<50;\n} {49}\n\nproc do_compare_test {tn where} {\n  set sql [subst {\n    SELECT (SELECT group_concat(a || ',' || b, ',') FROM t0 WHERE $where) \n           IS \n           (SELECT group_concat(a || ',' || b, ',') FROM s1 WHERE $where)\n  }]\n\n  uplevel [list do_execsql_test $tn $sql 1]\n}\n\ndo_compare_test 1.4.1 \"rowid = 700\"\ndo_compare_test 1.4.2 \"rowid = -1\"\ndo_compare_test 1.4.3 \"rowid = 0\"\ndo_compare_test 1.4.4 \"rowid = 55\"\ndo_compare_test 1.4.5 \"rowid BETWEEN 20 AND 100\"\ndo_compare_test 1.4.6 \"rowid > 350\"\ndo_compare_test 1.4.7 \"rowid >= 350\"\ndo_compare_test 1.4.8 \"rowid >= 200\"\ndo_compare_test 1.4.9 \"1\"\n\n# Multiple simultaneous cursors.\n#\ndo_execsql_test 1.5.1.(5-seconds-or-so) {\n  SELECT count(*) FROM s1 a, s1 b WHERE b.rowid<=200;\n} {80000}\ndo_execsql_test 1.5.2 {\n  SELECT count(*) FROM s1 a, s1 b, s1 c \n  WHERE a.rowid=b.rowid AND b.rowid=c.rowid;\n} {400}\n\n# Empty source tables.\n#\ndo_test 1.6.0 {\n  for {set i 0} {$i < 20} {incr i} {\n    sqlite3 db2 test.db$i\n    db2 eval \" DELETE FROM t$i \"\n    db2 close\n  }\n  db eval { DELETE FROM t0 WHERE rowid<=200 }\n} {}\n\ndo_compare_test 1.6.1 \"rowid = 700\"\ndo_compare_test 1.6.2 \"rowid = -1\"\ndo_compare_test 1.6.3 \"rowid = 0\"\ndo_compare_test 1.6.4 \"rowid = 55\"\ndo_compare_test 1.6.5 \"rowid BETWEEN 20 AND 100\"\ndo_compare_test 1.6.6 \"rowid > 350\"\ndo_compare_test 1.6.7 \"rowid >= 350\"\ndo_compare_test 1.6.8 \"rowid >= 200\"\ndo_compare_test 1.6.9 \"1\"\ndo_compare_test 1.6.10 \"rowid >= 5\"\n\ndo_test 1.x {\n  set sqlite_open_file_count\n} [expr $nFile+9]\n\ndo_test 1.y { db close } {}\n\n# Delete all the database files created above.\n#\nfor {set i 0} {$i < 40} {incr i} { forcedelete \"test.db$i\" }\n\n#-------------------------------------------------------------------------\n# Test some error conditions:\n#\n#   2.1: Database file does not exist.\n#   2.2: Table does not exist.\n#   2.3: Table schema does not match.\n#   2.4: Syntax error in SELECT statement.\n#\nreset_db\nload_static_extension db unionvtab\ndo_test 2.0.1 {\n  db eval {\n    CREATE TABLE t0(a INTEGER PRIMARY KEY, b TEXT);\n    WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<400) \n      INSERT INTO t0 SELECT i, hex(randomblob(50)) FROM s;\n    CREATE TABLE dir(f, t, imin, imax);\n  }\n\n  for {set i 0} {$i < 40} {incr i} {\n    set iMin [expr $i*10 + 1]\n    set iMax [expr $iMin+9]\n\n    forcedelete \"test.db$i\"\n    db eval [subst {\n      ATTACH 'test.db$i' AS aux;\n      CREATE TABLE aux.t$i (a INTEGER PRIMARY KEY, b TEXT);\n      INSERT INTO aux.t$i SELECT * FROM t0 WHERE a BETWEEN $iMin AND $iMax;\n      DETACH aux;\n      INSERT INTO dir VALUES('test.db$i', 't$i', $iMin, $iMax);\n    }]\n  }\n  execsql {\n    CREATE VIRTUAL TABLE temp.s1 USING swarmvtab('SELECT * FROM dir');\n  }\n} {}\n\ndo_test 2.0.2 {\n  forcedelete test.db5\n\n  sqlite3 db2 test.db15\n  db2 eval { DROP TABLE t15 }\n  db2 close\n\n  sqlite3 db2 test.db25\n  db2 eval { \n    DROP TABLE t25;\n    CREATE TABLE t25(x, y, z PRIMARY KEY);\n  }\n  db2 close\n} {}\n\ndo_catchsql_test 2.1 {\n  SELECT * FROM s1 WHERE rowid BETWEEN 1 AND 100;\n} {1 {unable to open database file}}\ndo_catchsql_test 2.2 {\n  SELECT * FROM s1 WHERE rowid BETWEEN 101 AND 200;\n} {1 {no such rowid table: t15}}\ndo_catchsql_test 2.3 {\n  SELECT * FROM s1 WHERE rowid BETWEEN 201 AND 300;\n} {1 {source table schema mismatch}}\n\ndo_catchsql_test 2.4 {\n  CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir');\n} {1 {sql error: near \"FROMdir\": syntax error}}\ndo_catchsql_test 2.5 {\n  CREATE VIRTUAL TABLE temp.x1 USING swarmvtab('SELECT * FROMdir', 'fetchdb');\n} {1 {sql error: near \"FROMdir\": syntax error}}\n\nfor {set i 0} {$i < 40} {incr i} {\n  forcedelete \"test.db$i\"\n}\n\n#-------------------------------------------------------------------------\n# Test the outcome of the fetch function throwing an exception.\n#\nproc fetch_db {file} {\n  error \"fetch_db error!\"\n}\n\ndb func fetch_db fetch_db\n\ndo_catchsql_test 3.1 {\n  CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(\n    'VALUES\n        (\"test.db1\", \"t1\", 1, 10),\n        (\"test.db2\", \"t1\", 11, 20)\n    ', 'fetch_db_no_such_function'\n  );\n} {1 {no such function: fetch_db_no_such_function}}\n\ndo_catchsql_test 3.2 {\n  CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(\n    'VALUES\n        (\"test.db1\", \"t1\", 1, 10),\n        (\"test.db2\", \"t1\", 11, 20)\n    ', 'fetch_db'\n  );\n} {1 {fetch_db error!}}\n\ndo_execsql_test 3.3.1 {\n  ATTACH 'test.db1' AS aux;\n  CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO aux.t1 VALUES(1, NULL);\n  INSERT INTO aux.t1 VALUES(2, NULL);\n  INSERT INTO aux.t1 VALUES(9, NULL);\n  DETACH aux;\n  CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(\n    'VALUES\n        (\"test.db1\", \"t1\", 1, 10),\n        (\"test.db2\", \"t1\", 11, 20)\n    ', 'fetch_db'\n  );\n} {}\n\ndo_catchsql_test 3.3.2 { SELECT * FROM xyz } {1 {fetch_db error!}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/swarmvtab2.test",
    "content": "# 2017-07-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the \"swarmvtab\" extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix swarmvtab\ndo_not_use_codec\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n\ndb close\nforeach name [glob -nocomplain test*.db] {\n  forcedelete $name\n}\nsqlite3 db test.db\nload_static_extension db unionvtab\nproc create_database {filename} {\n  sqlite3 dbx $filename\n  set num [regsub -all {[^0-9]+} $filename {}]\n  set num [string trimleft $num 0]\n  set start [expr {$num*1000}]\n  set end [expr {$start+999}]\n  dbx eval {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY,b);\n    WITH RECURSIVE c(x) AS (\n      VALUES($start) UNION ALL SELECT x+1 FROM c WHERE x<$end\n    )\n    INSERT INTO t2(a,b) SELECT x, printf('**%05d**',x) FROM c;\n  }\n  dbx close\n}\ndb func create_database create_database\ndo_execsql_test 100 {\n  CREATE TABLE t1(filename, tablename, istart, iend);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<99)\n  INSERT INTO t1 SELECT printf('test%03d.db',x),'t2',x*1000,x*1000+999 FROM c;\n  CREATE VIRTUAL TABLE temp.v1 USING swarmvtab(\n    'SELECT * FROM t1', 'create_database'\n  );\n} {}\ndo_execsql_test 110 {\n  SELECT b FROM v1 WHERE a=3875;\n} {**03875**}\ndo_test 120 {\n  lsort [glob -nocomplain test?*.db]\n} {test001.db test003.db}\ndo_execsql_test 130 {\n  SELECT b FROM v1 WHERE a BETWEEN 3999 AND 4000 ORDER BY a;\n} {**03999** **04000**}\ndo_test 140 {\n  lsort [glob -nocomplain test?*.db]\n} {test001.db test003.db test004.db}\ndo_execsql_test 150 {\n  SELECT b FROM v1 WHERE a>=99998;\n} {**99998** **99999**}\ndo_test 160 {\n  lsort -dictionary [glob -nocomplain test?*.db]\n} {test001.db test003.db test004.db test099.db}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/swarmvtabfault.test",
    "content": "# 2017-07-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is error handling in the swarmvtab extension.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix swarmvtabfault\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nproc fetch_db {file} {\n  forcedelete $file\n  sqlite3 dbX $file\n  set rc [catch {\n    dbX eval { CREATE TABLE t1(a INTEGER PRIMARY KEY, b) }\n  } res]\n  dbX close\n  if {$rc!=0} {error $res}\n}\n\nforcedelete test.db1\nforcedelete test.db2\n\ndo_execsql_test 1.0 {\n  ATTACH 'test.db1' AS aux;\n  CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b);\n  INSERT INTO aux.t1 VALUES(1, NULL);\n  INSERT INTO aux.t1 VALUES(2, NULL);\n  INSERT INTO aux.t1 VALUES(9, NULL);\n  DETACH aux;\n} {}\n\nfaultsim_save_and_close\ndo_faultsim_test 1.1 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  db func fetch_db fetch_db\n  load_static_extension db unionvtab\n  db eval {\n    CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(\n        'VALUES\n        (\"test.db1\", \"t1\", 1, 10),\n        (\"test.db2\", \"t1\", 11, 20)\n        ', 'fetch_db'\n    );\n  }\n} -body {\n  execsql { SELECT a FROM xyz }\n} -test {\n  faultsim_test_result {0 {1 2 9}} {1 {sql error: out of memory}}\n}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/symlink.test",
    "content": "# 2015 October 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that SQLite can follow symbolic links.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix symlink\n\n# This only runs on unix.\nif {$::tcl_platform(platform)!=\"unix\"} {\n  finish_test\n  return\n}\n\n# Ensure that test.db has been created.\n#\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x, y);\n}\n\n# Test that SQLite follows symlinks when opening files.\n#\nforcedelete test.db2\ndo_test 1.1 {\n  file link test.db2 test.db\n  sqlite3 db2 test.db2\n  sqlite3_db_filename db2 main\n} [file join [pwd] test.db]\n\n# Test that if the symlink points to a file that does not exists, it is\n# created when it is opened.\n#\ndo_test 1.2.1 {\n  db2 close\n  db close\n  forcedelete test.db\n  file exists test.db\n} 0\ndo_test 1.2.2 {\n  sqlite3 db2 test.db2\n  file exists test.db\n} 1\ndo_test 1.2.3 {\n  sqlite3_db_filename db2 main\n} [file join [pwd] test.db]\ndb2 close\n\n# Test that a loop of symlinks cannot be opened.\n#\ndo_test 1.3 {\n  forcedelete test.db\n  # Note: Tcl [file link] command is too smart to create loops of symlinks.\n  exec ln -s test.db2 test.db\n  list [catch { sqlite3 db test.db } msg] $msg\n} {1 {unable to open database file}}\n\n# Test that overly large paths cannot be opened.\n#\ndo_test 1.4 {\n  set name \"test.db[string repeat x 502]\"\n  list [catch { sqlite3 db $name } msg] $msg\n} {1 {unable to open database file}}\ndo_test 1.5 {\n  set r [expr 510 - [string length test.db] - [string length [pwd]]]\n  set name \"test.db[string repeat x $r]\"\n  list [catch { sqlite3 db $name } msg] $msg\n} {1 {unable to open database file}}\n\n#-------------------------------------------------------------------------\n# Test that journal and wal files are created next to the real file,\n# not the symlink.\n#\ndo_test 2.0 {\n  catch { db close }\n  catch { db2 close }\n  forcedelete test.db test.db2 test.db3\n  sqlite3 db test.db\n  execsql { CREATE TABLE t1(x) }\n  file link test.db2 test.db\n  file link test.db3 test.db2\n  set {} {}\n} {}\n\nforeach {tn f} {1 test.db2 2 test.db3} {\n  do_test 2.$tn.1 {\n    sqlite3 db2 $f\n    file exists test.db-journal\n  } 0\n  do_test 2.$tn.2 {\n    execsql {\n      BEGIN;\n        INSERT INTO t1 VALUES(1);\n    } db2\n    file exists test.db-journal\n  } 1\n  do_test 2.$tn.3 {\n    list [file exists test2.db-journal] [file exists test3.db-journal]\n  } {0 0}\n  do_test 2.$tn.4 {\n    execsql {\n      COMMIT;\n      PRAGMA journal_mode = wal;\n      INSERT INTO t1 VALUES(2);\n    } db2\n    file exists test.db-wal\n  } 1\n  do_test 2.$tn.5 {\n    list [file exists test2.db-wal] [file exists test3.db-wal]\n  } {0 0}\n  do_execsql_test 2.$tn.6 {\n    SELECT * FROM t1;\n  } {1 2}\n  db2 close\n  do_execsql_test 2.$tn.7 {\n    DELETE FROM t1;\n    PRAGMA journal_mode = delete;\n  } delete\n}\n\n# Try to open a ridiculously long pathname.  Bug found by\n# Kostya Serebryany using libFuzzer on 2015-11-30.\n#\ndo_test 3.1 {\n  db close\n  catch {sqlite3 db [string repeat [string repeat x 100]/ 6]} res\n  set res\n} {unable to open database file}\n\n#-------------------------------------------------------------------------\n# Test that relative symlinks that are not located in the cwd work.\n#\ndo_test 4.1 {\n  forcedelete x y z\n  file mkdir x\n  file mkdir y\n  file mkdir z\n  sqlite3 db x/test.db\n  file link y/test.db ../x/test.db\n  file link z/test.db ../y/test.db\n  execsql {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 VALUES('hello', 'world');\n  }\n} {wal}\n\ndo_test 4.2.1 {\n  db close\n  sqlite3 db y/test.db\n  db eval { SELECT * FROM t1 }\n} {hello world}\ndo_test 4.2.2 {\n  list [file exists x/test.db-wal] [file exists y/test.db-wal]\n} {1 0}\n\ndo_test 4.3.1 {\n  db close\n  sqlite3 db z/test.db\n  db eval { SELECT * FROM t1 }\n} {hello world}\ndo_test 4.3.2 {\n  list [file exists x/test.db-wal] [file exists y/test.db-wal] \\\n       [file exists z/test.db-wal]\n} {1 0 0}\n\ndo_test 4.4.0 {\n  forcedelete w\n  file mkdir w\n  file link w/test.db [file join [pwd] x/test.db] \n  set {} {}\n} {}\ndo_test 4.4.1 {\n  db close\n  sqlite3 db w/test.db\n  db eval { SELECT * FROM t1 }\n} {hello world}\ndo_test 4.4.2 {\n  list [file exists x/test.db-wal] [file exists w/test.db-wal]\n} {1 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sync.test",
    "content": "# 2005 August 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that fsync is disabled when\n# pragma synchronous=off even for multi-database commits.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n#\n# These tests are only applicable when pager pragma are\n# enabled. Also, since every test uses an ATTACHed database, they\n# are only run when ATTACH is enabled.\n#\nifcapable !pager_pragmas||!attach {\n  finish_test\n  return\n}\n\nset sqlite_sync_count 0\nproc cond_incr_sync_count {adj} {\n  global sqlite_sync_count\n  if {$::tcl_platform(platform) == \"windows\"} {\n    incr sqlite_sync_count $adj\n  } else {\n    ifcapable !dirsync {\n      incr sqlite_sync_count $adj\n    }\n  }\n}\n\ndo_test sync-1.1 {\n  set sqlite_sync_count 0\n  forcedelete test2.db\n  forcedelete test2.db-journal\n  execsql {\n    PRAGMA fullfsync=OFF;\n    CREATE TABLE t1(a,b);\n    ATTACH DATABASE 'test2.db' AS db2;\n    CREATE TABLE db2.t2(x,y);\n  }\n  cond_incr_sync_count 2\n  set sqlite_sync_count\n} 8\nifcapable pager_pragmas {\n  do_test sync-1.2 {\n    set sqlite_sync_count 0\n    execsql {\n      PRAGMA main.synchronous=on;\n      PRAGMA db2.synchronous=on;\n      BEGIN;\n      INSERT INTO t1 VALUES(1,2);\n      INSERT INTO t2 VALUES(3,4);\n      COMMIT;\n    }\n    cond_incr_sync_count 4\n    set sqlite_sync_count\n  } 9\n}\ndo_test sync-1.3 {\n  set sqlite_sync_count 0\n  execsql {\n    PRAGMA main.synchronous=full;\n    PRAGMA db2.synchronous=full;\n    BEGIN;\n    INSERT INTO t1 VALUES(3,4);\n    INSERT INTO t2 VALUES(5,6);\n    COMMIT;\n  }\n  cond_incr_sync_count 4\n  set sqlite_sync_count\n} 11\nifcapable pager_pragmas {\nif {[permutation]!=\"journaltest\"} {\n  do_test sync-1.4 {\n    set sqlite_sync_count 0\n    execsql {\n      PRAGMA main.synchronous=off;\n      PRAGMA db2.synchronous=off;\n      BEGIN;\n      INSERT INTO t1 VALUES(5,6);\n      INSERT INTO t2 VALUES(7,8);\n      COMMIT;\n    }\n    set sqlite_sync_count\n  } 0\n}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sync2.test",
    "content": "# 2017 March 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# Specificly, it tests that \"PRAGMA synchronous\" appears to work.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix sync2\n\n#\n# These tests are only applicable when pager pragma are\n# enabled. Also, since every test uses an ATTACHed database, they\n# are only run when ATTACH is enabled.\n#\nifcapable !pager_pragmas||!attach||!dirsync {\n  finish_test\n  return\n}\nif {$::tcl_platform(platform)!=\"unix\" \n  || [permutation] == \"journaltest\"\n  || [permutation] == \"inmemory_journal\"\n} {\n  finish_test\n  return\n}\n\nproc execsql_sync {sql} {\n  set s $::sqlite_sync_count\n  set res [execsql $sql]\n  concat [expr $::sqlite_sync_count-$s] $res\n}\n\nproc do_execsql_sync_test {tn sql res} {\n  uplevel [list do_test $tn [list execsql_sync $sql] [list {*}$res]]\n}\n\n#-----------------------------------------------------------------------\n# Tests for journal mode.\n#\nsqlite3 db test.db\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n}\n\ndo_execsql_sync_test 1.1 { INSERT INTO t1 VALUES(3, 4) } 4\n\n# synchronous=normal. So, 1 sync on the directory, 1 on the journal, 1 \n# on the db file. 3 in total.\ndo_execsql_test      1.2.1 { PRAGMA main.synchronous = NORMAL }\ndo_execsql_test      1.2.2 { PRAGMA main.synchronous }     1\ndo_execsql_sync_test 1.2.3 { INSERT INTO t1 VALUES(5, 6) } 3\n\n# synchronous=off. No syncs.\ndo_execsql_test      1.3.1 { PRAGMA main.synchronous = OFF }\ndo_execsql_test      1.3.2 { PRAGMA main.synchronous }     0\ndo_execsql_sync_test 1.3.3 { INSERT INTO t1 VALUES(7, 8) } 0\n \n# synchronous=full, journal_mode=delete. So, 1 sync on the directory,\n# 2 on the journal, 1 on the db file. 4 in total.\ndo_execsql_test      1.4.1 { PRAGMA main.synchronous = FULL }\ndo_execsql_test      1.4.2 { PRAGMA main.synchronous }      2\ndo_execsql_sync_test 1.4.3 { INSERT INTO t1 VALUES(9, 10) } 4\n\n#-----------------------------------------------------------------------\n# Tests for wal mode.\n#\ndo_execsql_test      1.5 { PRAGMA journal_mode = wal } {wal}\n\n# sync=full, journal_mode=wal. One sync on the directory, two on the \n# wal file.\ndo_execsql_sync_test 1.6 { INSERT INTO t1 VALUES(11, 12) } 3\n\n# One sync on the wal file.\ndo_execsql_sync_test 1.7 { INSERT INTO t1 VALUES(13, 14) } 1\n\n# No syncs.\ndo_execsql_test      1.8.1 { PRAGMA main.synchronous = NORMAL }\ndo_execsql_test      1.8.2 { PRAGMA main.synchronous }          1\ndo_execsql_sync_test 1.8.3 { INSERT INTO t1 VALUES(15, 16) }    0\n\n# One sync on wal file, one on the db file.\ndo_execsql_sync_test 1.9   { PRAGMA wal_checkpoint }  {2 0 3 3}\n\n# No syncs.\ndo_execsql_test      1.10.1 { PRAGMA main.synchronous = OFF }\ndo_execsql_test      1.10.2 { PRAGMA main.synchronous }          0\ndo_execsql_sync_test 1.10.3 { INSERT INTO t1 VALUES(17, 18) }    0\n\n#-----------------------------------------------------------------------\n# Tests for the compile time settings SQLITE_DEFAULT_SYNCHRONOUS and\n# SQLITE_DEFAULT_WAL_SYNCHRONOUS. These tests only run if the former\n# is set to \"2\" and the latter to \"1\". This is not the default, but\n# it is currently the recommended configuration.\n#\n#   https://sqlite.org/compile.html#recommended_compile_time_options\n#\nif {$SQLITE_DEFAULT_SYNCHRONOUS==2 && $SQLITE_DEFAULT_WAL_SYNCHRONOUS==1} {\n\n  db close\n  sqlite3 db test.db\n\n  # Wal mode, sync=normal. The first transaction does one sync on directory,\n  # one on the wal file. The second does no syncs.\n  do_execsql_sync_test 1.11.1 { INSERT INTO t1 VALUES(19, 20) } 2\n  do_execsql_sync_test 1.11.2 { INSERT INTO t1 VALUES(21, 22) } 0\n  do_execsql_test 1.11.3      { PRAGMA main.synchronous }       1\n\n  # One sync on wal file, one on the db file.\n  do_execsql_sync_test 1.12   { PRAGMA wal_checkpoint }  {2 0 2 2}\n\n  # First transaction syncs the wal file once, the second not at all.\n  # one on the wal file. The second does no syncs.\n  do_execsql_sync_test 1.13.1 { INSERT INTO t1 VALUES(22, 23) } 1\n  do_execsql_sync_test 1.13.2 { INSERT INTO t1 VALUES(24, 25) } 0\n\n  do_execsql_test 1.14 { PRAGMA journal_mode = delete } {delete}\n  \n  # Delete mode, sync=full. The first transaction does one sync on \n  # directory, two on the journal file, one on the db. The second does \n  # the same.\n  do_execsql_sync_test 1.15.1 { INSERT INTO t1 VALUES(26, 27) } 4\n  do_execsql_sync_test 1.15.2 { INSERT INTO t1 VALUES(28, 29) } 4\n  do_execsql_test 1.15.3      { PRAGMA main.synchronous }       2\n\n  # Switch back to wal mode.\n  do_execsql_test 1.16 { PRAGMA journal_mode = wal } {wal}\n\n  do_execsql_sync_test 1.17.1 { INSERT INTO t1 VALUES(30, 31) } 2\n  do_execsql_sync_test 1.17.2 { INSERT INTO t1 VALUES(32, 33) } 0\n  do_execsql_test 1.17.3      { PRAGMA main.synchronous }       1\n\n  # Now set synchronous=off, then switch back to delete mode. Check\n  # that the db handle is still using synchronous=off.\n  do_execsql_test 1.18.3      { PRAGMA main.synchronous=off }\n  do_execsql_test 1.18 { PRAGMA journal_mode = delete } {delete}\n\n  do_execsql_sync_test 1.19.1 { INSERT INTO t1 VALUES(34, 35) } 0\n  do_execsql_sync_test 1.19.2 { INSERT INTO t1 VALUES(36, 37) } 0\n  do_execsql_test 1.19.3      { PRAGMA main.synchronous }       0\n\n  # Close and reopen the db. Back to synchronous=normal.\n  db close\n  sqlite3 db test.db\n  do_execsql_sync_test 1.20.1 { INSERT INTO t1 VALUES(38, 39) } 4\n  do_execsql_sync_test 1.20.2 { INSERT INTO t1 VALUES(40, 41) } 4\n  do_execsql_test 1.20.3      { PRAGMA main.synchronous }       2\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/syscall.test",
    "content": "# 2011 March 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {[llength [info commands test_syscall]]==0} {\n  finish_test\n  return\n} \n\nif {[test_syscall defaultvfs] != \"unix\"} {\n  finish_test\n  return\n}\nset testprefix syscall\n\n#-------------------------------------------------------------------------\n# Tests for the xSetSystemCall method.\n#\ndo_test 1.1.1 {\n  list [catch { test_syscall reset open } msg] $msg\n} {0 {}}\ndo_test 1.1.2 {\n  list [catch { test_syscall reset nosuchcall } msg] $msg\n} {1 SQLITE_NOTFOUND}\ndo_test 1.1.3 {\n  list [catch { test_syscall reset open } msg] $msg\n} {0 {}}\ndo_test 1.1.4 {\n  list [catch { test_syscall reset \"\"} msg] $msg\n} {1 SQLITE_NOTFOUND}\n\ndo_test 1.2 { test_syscall reset } {}\n\ndo_test 1.3.1 { test_syscall install {open getcwd access} } {}\ndo_test 1.3.2 { test_syscall reset } {}\n\n#-------------------------------------------------------------------------\n# Tests for the xGetSystemCall method.\n#\ndo_test 2.1.1 { test_syscall exists open } 1\ndo_test 2.1.2 { test_syscall exists nosuchcall } 0\n\n#-------------------------------------------------------------------------\n# Tests for the xNextSystemCall method.\n#\nforeach s {\n    open close access getcwd stat fstat ftruncate\n    fcntl read pread write pwrite fchmod fallocate\n    pread64 pwrite64 unlink openDirectory mkdir rmdir \n    statvfs fchown geteuid umask mmap munmap mremap\n    getpagesize readlink lstat ioctl\n} {\n  if {[test_syscall exists $s]} {lappend syscall_list $s}\n}\ndo_test 3.1 { lsort [test_syscall list] } [lsort $syscall_list]\n\n#-------------------------------------------------------------------------\n# This test verifies that if a call to open() fails and errno is set to\n# EINTR, the call is retried. If it succeeds, execution continues as if\n# nothing happened. \n#\ntest_syscall reset\nforcedelete test.db2\ndo_execsql_test 4.1 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE aux.t2(x, y);\n  INSERT INTO t2 VALUES(3, 4);\n}\n\ndb_save_and_close\ntest_syscall install open\nforeach jrnl [list wal delete] {\n  for {set i 1} {$i < 20} {incr i} {\n    db_restore_and_reopen\n    test_syscall fault $i 0\n    test_syscall errno open EINTR\n  \n    do_test 4.2.$jrnl.$i {\n      sqlite3 db test.db\n      execsql { ATTACH 'test.db2' AS aux }\n      execsql \"PRAGMA main.journal_mode = $jrnl\"\n      execsql \"PRAGMA aux.journal_mode = $jrnl\"\n      execsql {\n        BEGIN;\n          INSERT INTO t1 VALUES(5, 6);\n          INSERT INTO t2 VALUES(7, 8);\n        COMMIT;\n      }\n\n      db close\n      sqlite3 db test.db\n      execsql { ATTACH 'test.db2' AS aux }\n      execsql {\n        SELECT * FROM t1;\n        SELECT * FROM t2;\n      }\n    } {1 2 5 6 3 4 7 8}\n  }\n}\n\n#-------------------------------------------------------------------------\n# This test verifies that closing database handles does not drop locks\n# held by other database handles in the same process on the same file.\n#\n# The os_unix.c module has to take precautions to prevent this as the\n# close() system call drops locks held by other file-descriptors on the\n# same file. From the Linux man page:\n#\n#   close() closes a file descriptor, so that it no longer refers to any file\n#   and may be reused. Any record locks (see fcntl(2)) held on the file it \n#   was associated with, and owned by the process, are removed (regardless \n#   of the file descriptor that was used to obtain the lock).\n#\ncatch { db close }\nforcedelete test.db test.db2\n\ndo_multiclient_test tn {\n  code1 {\n    sqlite3 dbX1 test.db\n    sqlite3 dbX2 test.db\n  }\n\n  do_test syscall-5.$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      BEGIN;\n        INSERT INTO t1 VALUES(3, 4);\n    }\n  } {}\n\n  do_test syscall-5.$tn.2 { sql2 { SELECT * FROM t1 } } {1 2}\n  do_test syscall-5.$tn.3 { \n    csql2 { INSERT INTO t1 VALUES(5, 6) }\n  } {1 {database is locked}}\n\n  do_test syscall-5.$tn.4 { \n    code1 {\n      dbX1 close\n      dbX2 close\n    }\n  } {}\n\n  do_test syscall-5.$tn.5 { \n    csql2 { INSERT INTO t1 VALUES(5, 6) }\n  } {1 {database is locked}}\n\n  do_test syscall-5.$tn.6 { sql1 { COMMIT } } {}\n\n  do_test syscall-5.$tn.7 { \n    csql2 { INSERT INTO t1 VALUES(5, 6) }\n  } {0 {}}\n}\n\ncatch {db close}\ndo_test 6.1 {\n  sqlite3 db1 test.db1\n  sqlite3 db2 test.db2\n  sqlite3 db3 test.db3\n  sqlite3 dbM \"\"\n\n  db2 close\n  db3 close\n  dbM close\n  db1 close\n} {}\n\ndo_test 6.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA temp_store = file;\n\n    PRAGMA main.cache_size = 10;\n    PRAGMA temp.cache_size = 10;\n    CREATE TABLE temp.tt(a, b);\n    INSERT INTO tt VALUES(randomblob(500), randomblob(600));\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n    INSERT INTO tt SELECT randomblob(500), randomblob(600) FROM tt;\n  }\n\n  db close\n} {}\n\n#-------------------------------------------------------------------------\n# Test that a database file a single byte in size is treated as an empty\n# file. Whereas a file 2 bytes or larger might be considered corrupt.\n#\ncatch { db close }\nforcedelete test.db test.db2\n\nproc create_db_file {nByte} {\n  set fd [open test.db w]\n  fconfigure $fd -translation binary -encoding binary\n  puts -nonewline $fd [string range \"xSQLite\" 1 $nByte]\n  close $fd\n}\n\nforeach {nByte res} {\n  1      {0 {}}\n  2      {1 {file is not a database}}\n  3      {1 {file is not a database}}\n} {\n  do_test 7.$nByte {\n    create_db_file $nByte\n    list [catch {\n      sqlite3 db test.db\n      execsql { CREATE TABLE t1(a, b) }\n    } msg] $msg\n  } $res\n  catch { db close }\n}\n\n#-------------------------------------------------------------------------\n# \ncatch { db close }\nforcedelete test.db test.db2\n\ndo_test 8.1 {\n  sqlite3 db test.db\n  file_control_chunksize_test db main 4096\n  file size test.db\n} {0}\nforeach {tn hint size} {\n  1  1000    4096 \n  2  1000    4096 \n  3  3000    4096 \n  4  4096    4096 \n  5  4197    8192 \n} {\n  do_test 8.2.$tn {\n    file_control_sizehint_test db main $hint\n    file size test.db\n  } $size\n}\n\ndo_test 8.3 {\n  db close\n  forcedelete test.db test.db2\n  sqlite3 db test.db\n  file_control_chunksize_test db main 16\n  file size test.db\n} {0}\nforeach {tn hint size} {\n  1  5       16 \n  2  13      16 \n  3  45      48 \n  4  48      48 \n  5  49      64 \n} {\n  do_test 8.4.$tn {\n    file_control_sizehint_test db main $hint\n    file size test.db\n  } $size\n}\n\ntest_syscall reset\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/sysfault.test",
    "content": "# 2011 March 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {[llength [info commands test_syscall]]==0} {\n  finish_test\n  return\n} \n\nset testprefix sysfault\n\nset FAULTSIM(vfsfault-transient) [list             \\\n  -injectinstall   vfsfault_install                \\\n  -injectstart     vfsfault_injectstart_t          \\\n  -injectstop      vfsfault_injectstop             \\\n  -injecterrlist   {}                              \\\n  -injectuninstall {test_syscall uninstall}        \\\n]\nset FAULTSIM(vfsfault-persistent) [list            \\\n  -injectinstall   vfsfault_install                \\\n  -injectstart     vfsfault_injectstart_p          \\\n  -injectstop      vfsfault_injectstop             \\\n  -injecterrlist   {}                              \\\n  -injectuninstall {test_syscall uninstall}        \\\n]\n\nproc vfsfault_injectstart_t {iFail} { test_syscall fault $iFail 0 }\nproc vfsfault_injectstart_p {iFail} { test_syscall fault $iFail 1 }\nproc vfsfault_injectstop    {}      { test_syscall fault }\n\nfaultsim_save_and_close\n\n\nset open_and_write_body {\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    PRAGMA journal_mode = WAL;\n    INSERT INTO t1 VALUES(3, 4);\n    SELECT * FROM t1;\n    CREATE TEMP TABLE t2(x);\n    INSERT INTO t2 VALUES('y');\n  }\n}\n\nproc vfsfault_install {} { test_syscall install {open getcwd} }\ndo_faultsim_test 1 -faults vfsfault-* -prep {\n  faultsim_restore\n} -body $open_and_write_body -test {\n  faultsim_test_result {0 {wal 1 2 3 4}}       \\\n    {1 {unable to open database file}}         \\\n    {1 {attempt to write a readonly database}}\n}\n\n#-------------------------------------------------------------------------\n# Errors in the fstat() function when opening and writing a file. Cases\n# where fstat() fails and sets errno to ENOMEM and EOVERFLOW are both\n# tested. EOVERFLOW is interpreted as meaning that a file on disk is\n# too large to be opened by the OS.\n#\nforeach {tn errno errlist} {\n  1 ENOMEM       {{disk I/O error}}\n  2 EOVERFLOW    {{disk I/O error} {large file support is disabled}}\n} {\n  proc vfsfault_install {} { test_syscall install fstat }\n  set errs [list]\n  foreach e $errlist { lappend errs [list 1 $e] }\n  do_faultsim_test 1.2.$tn -faults vfsfault-* -prep {\n    faultsim_restore\n  } -body \"\n    test_syscall errno fstat $errno\n    $open_and_write_body \n  \" -test \"\n    faultsim_test_result {0 {wal 1 2 3 4}} $errs\n  \"\n}\n\n#-------------------------------------------------------------------------\n# Various errors in locking functions. \n#\nforeach vfs {unix unix-excl} {\n  foreach {tn errno errlist} {\n    1 EAGAIN       {{database is locked} {disk I/O error}}\n    2 ETIMEDOUT    {{database is locked} {disk I/O error}}\n    3 EBUSY        {{database is locked} {disk I/O error}}\n    4 EINTR        {{database is locked} {disk I/O error}}\n    5 ENOLCK       {{database is locked} {disk I/O error}}\n    6 EACCES       {{database is locked} {disk I/O error}}\n    7 EPERM        {{access permission denied} {disk I/O error}}\n    8 EDEADLK      {{disk I/O error}}\n    9 ENOMEM       {{disk I/O error}}\n  } {\n    proc vfsfault_install {} { test_syscall install fcntl }\n    set errs [list]\n    foreach e $errlist { lappend errs [list 1 $e] }\n  \n    set body [string map [list %VFS% $vfs] {\n      sqlite3 db test.db\n      db eval {\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n      }\n      set fd [open test.db-journal w]\n      puts $fd \"hello world\"\n      close $fd\n      sqlite3 db test.db -vfs %VFS%\n      db eval {\n        SELECT * FROM t1;\n      }\n    }]\n  \n    do_faultsim_test 1.3.$vfs.$tn -faults vfsfault-* -prep {\n      faultsim_restore\n    } -body \"\n      test_syscall errno fcntl $errno\n      $body\n    \" -test \"\n      faultsim_test_result {0 {1 2}} $errs\n    \"\n  }\n}\n\n#-------------------------------------------------------------------------\n# Check that a single EINTR error does not affect processing.\n#\nproc vfsfault_install {} { \n  test_syscall reset\n  test_syscall install {open ftruncate close read pread pread64 write fallocate}\n}\n\nforcedelete test.db test.db2\nsqlite3 db test.db\ndo_test 2.setup {\n  execsql {\n    CREATE TABLE t1(a, b, c, PRIMARY KEY(a));\n    INSERT INTO t1 VALUES('abc', 'def', 'ghi');\n    ATTACH 'test.db2' AS 'aux';\n    CREATE TABLE aux.t2(x);\n    INSERT INTO t2 VALUES(1);\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test 2.1 -faults vfsfault-transient -prep {\n  catch { db close }\n  faultsim_restore\n} -body {\n  test_syscall errno open      EINTR\n  test_syscall errno ftruncate EINTR\n  test_syscall errno close     EINTR\n  test_syscall errno read      EINTR\n  test_syscall errno pread     EINTR\n  test_syscall errno pread64   EINTR\n  test_syscall errno write     EINTR\n  test_syscall errno fallocate EINTR\n\n  sqlite3 db test.db\n  file_control_chunksize_test db main 8192\n\n  set res [db eval {\n    ATTACH 'test.db2' AS 'aux';\n    SELECT * FROM t1;\n    PRAGMA journal_mode = truncate;\n    BEGIN;\n      INSERT INTO t1 VALUES('jkl', 'mno', 'pqr');\n      INSERT INTO t1 VALUES(randomblob(10000), 0, 0);\n      UPDATE t2 SET x = 2;\n    COMMIT;\n    DELETE FROM t1 WHERE length(a)>3;\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }]\n  db close\n  set res\n} -test {\n  faultsim_test_result {0 {abc def ghi truncate abc def ghi jkl mno pqr 2}}\n}\n\ndo_faultsim_test 2.2 -faults vfsfault-* -prep {\n  catch { db close }\n  faultsim_restore\n} -body {\n  sqlite3 db test.db\n  set res [db eval {\n    ATTACH 'test.db2' AS 'aux';\n    SELECT * FROM t1;\n    PRAGMA journal_mode = truncate;\n    BEGIN;\n      INSERT INTO t1 VALUES('jkl', 'mno', 'pqr');\n      UPDATE t2 SET x = 2;\n    COMMIT;\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }]\n  db close\n  set res\n} -test {\n  faultsim_test_result {0 {abc def ghi truncate abc def ghi jkl mno pqr 2}} \\\n    {1 {unable to open database file}}                                      \\\n    {1 {unable to open database: test.db2}}                                 \\\n    {1 {attempt to write a readonly database}}                              \\\n    {1 {disk I/O error}}                                                  \n}\n\n#-------------------------------------------------------------------------\n\nproc vfsfault_install {} { \n  test_syscall reset\n  test_syscall install {fstat fallocate}\n}\ndo_faultsim_test 3 -faults vfsfault-* -prep {\n  faultsim_delete_and_reopen\n  file_control_chunksize_test db main 8192\n  execsql {\n    PRAGMA synchronous=OFF;\n    CREATE TABLE t1(a, b);\n    BEGIN;\n      SELECT * FROM t1;\n  }\n} -body {\n  test_syscall errno fstat     EIO\n  test_syscall errno fallocate EIO\n\n  execsql {\n    INSERT INTO t1 VALUES(randomblob(10000), randomblob(10000));\n    SELECT length(a) + length(b) FROM t1;\n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 20000}\n}\n\n#-------------------------------------------------------------------------\n# Test errors in mmap().\n#\nproc vfsfault_install {} { \n  test_syscall reset\n  test_syscall install {mmap}\n}\n\nfaultsim_delete_and_reopen\nexecsql {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 4 -faults vfsfault-* -prep {\n  faultsim_restore_and_reopen\n  file_control_chunksize_test db main 8192\n  execsql { \n    PRAGMA mmap_size = 1000000;\n  }\n} -body {\n  test_syscall errno mmap     EACCES\n\n  execsql {\n    SELECT * FROM t1;\n  }\n} -test {\n  faultsim_test_result {0 {1 2}} {1 {disk I/O error}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tabfunc01.test",
    "content": "# 2015-08-19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests for table-valued-functions implemented using\n# eponymous virtual tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tabfunc01\n\nifcapable !vtab {\n  finish_test\n  return\n}\nload_static_extension db series\nload_static_extension db carray\nload_static_extension db remember\n\ndo_execsql_test tabfunc01-1.1 {\n  SELECT *, '|' FROM generate_series WHERE start=1 AND stop=9 AND step=2;\n} {1 | 3 | 5 | 7 | 9 |}\ndo_execsql_test tabfunc01-1.2 {\n  SELECT *, '|' FROM generate_series LIMIT 5;\n} {0 | 1 | 2 | 3 | 4 |}\ndo_catchsql_test tabfunc01-1.3 {\n  CREATE VIRTUAL TABLE t1 USING generate_series;\n} {1 {no such module: generate_series}}\ndo_execsql_test tabfunc01-1.4 {\n  SELECT * FROM generate_series(1,9,2);\n} {1 3 5 7 9}\ndo_execsql_test tabfunc01-1.5 {\n  SELECT * FROM generate_series(1,9);\n} {1 2 3 4 5 6 7 8 9}\ndo_execsql_test tabfunc01-1.6 {\n  SELECT * FROM generate_series(1,10) WHERE step=3;\n} {1 4 7 10}\ndo_catchsql_test tabfunc01-1.7 {\n  SELECT * FROM generate_series(1,9,2,11);\n} {1 {too many arguments on generate_series() - max 3}}\n\ndo_execsql_test tabfunc01-1.8 {\n  SELECT * FROM generate_series(0,32,5) ORDER BY rowid DESC;\n} {30 25 20 15 10 5 0}\ndo_execsql_test tabfunc01-1.9 {\n  SELECT rowid, * FROM generate_series(0,32,5) ORDER BY value DESC;\n} {1 30 2 25 3 20 4 15 5 10 6 5 7 0}\ndo_execsql_test tabfunc01-1.10 {\n  SELECT rowid, * FROM generate_series(0,32,5) ORDER BY +value DESC;\n} {7 30 6 25 5 20 4 15 3 10 2 5 1 0}\n\ndo_execsql_test tabfunc01-1.20 {\n  CREATE VIEW v1(a,b) AS VALUES(1,2),(3,4);\n  SELECT * FROM v1;\n} {1 2 3 4}\ndo_catchsql_test tabfunc01-1.21.1 {\n  SELECT * FROM v1(55);\n} {1 {'v1' is not a function}}\ndo_catchsql_test tabfunc01-1.21.2 {\n  SELECT * FROM v1();\n} {1 {'v1' is not a function}}\ndo_execsql_test tabfunc01-1.22 {\n  CREATE VIEW v2(x) AS SELECT value FROM generate_series(1,5);\n  SELECT * FROM v2;\n} {1 2 3 4 5}\ndo_catchsql_test tabfunc01-1.23.1 {\n  SELECT * FROM v2(55);\n} {1 {'v2' is not a function}}\ndo_catchsql_test tabfunc01-1.23.2 {\n  SELECT * FROM v2();\n} {1 {'v2' is not a function}}\ndo_execsql_test tabfunc01-1.24 {\n  CREATE TABLE t0(x);\n  INSERT INTO t0(x) VALUES(123),(456),(789);\n  SELECT * FROM t0 ORDER BY x;\n} {123 456 789}\ndo_catchsql_test tabfunc01-1.25 {\n  SELECT * FROM t0(55) ORDER BY x;\n} {1 {'t0' is not a function}}\ndo_catchsql_test tabfunc01-1.26 {\n  WITH w0 AS (SELECT * FROM t0)\n  INSERT INTO t0(x) SELECT * FROM w0()\n} {1 {'w0' is not a function}}\n\ndo_execsql_test tabfunc01-2.1 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1(x) VALUES(2),(3);\n  SELECT *, '|' FROM t1, generate_series(1,x) ORDER BY 1, 2\n} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}\ndo_execsql_test tabfunc01-2.2 {\n  SELECT *, '|' FROM (SELECT x FROM t1) AS y, generate_series(1,y.x)\n  ORDER BY 1, 2;\n} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}\n\ndo_execsql_test tabfunc01-2.50 {\n  SELECT * FROM generate_series() LIMIT 5;\n} {0 1 2 3 4}\n\ndo_execsql_test tabfunc01-3.1 {\n  SELECT DISTINCT value FROM generate_series(1,x), t1 ORDER BY 1;\n} {1 2 3}\n\n# Eponymous virtual table exists in the \"main\" schema only\n#\ndo_execsql_test tabfunc01-4.1 {\n  SELECT * FROM main.generate_series(1,4)\n} {1 2 3 4}\ndo_catchsql_test tabfunc01-4.2 {\n  SELECT * FROM temp.generate_series(1,4)\n} {1 {no such table: temp.generate_series}}\ndo_catchsql_test tabfunc01-4.3 {\n  ATTACH ':memory:' AS aux1;\n  CREATE TABLE aux1.t1(a,b,c);\n  SELECT * FROM aux1.generate_series(1,4)\n} {1 {no such table: aux1.generate_series}}\n\n# The next series of tests is verifying that virtual table are able\n# to optimize the IN operator, even on terms that are not marked \"omit\".\n# When the generate_series virtual table is compiled for the testfixture,\n# the special -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 option is used, which\n# causes the xBestIndex method of generate_series to leave the\n# sqlite3_index_constraint_usage.omit flag set to 0, which should cause\n# the SQLite core to verify the start=, stop=, and step= constraints on\n# each step of output.  At one point, the IN operator could not be used\n# by virtual tables unless omit was set.\n#\ndo_execsql_test tabfunc01-500 {\n  SELECT * FROM generate_series WHERE start IN (1,7) AND stop=20 AND step=10\n  ORDER BY +1;\n} {1 7 11 17}\n\n# Table-valued functions on the RHS of an IN operator\n#\ndo_execsql_test tabfunc01-600 {\n  CREATE TABLE t600(a INTEGER PRIMARY KEY, b TEXT);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)\n    INSERT INTO t600(a,b) SELECT x, printf('(%03d)',x) FROM c;\n  SELECT b FROM t600 WHERE a IN generate_series(2,52,10);\n} {(002) (012) (022) (032) (042) (052)}\n\n\ndo_test tabfunc01-700 {\n  set PTR1 [intarray_addr 5 7 13 17 23]\n  db eval {\n    SELECT b FROM t600, carray(inttoptr($PTR1),5) WHERE a=value;\n  }\n} {(005) (007) (013) (017) (023)}\ndo_test tabfunc01-701 {\n  db eval {\n    SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int32');\n  }\n} {(005) (007) (013) (017) (023)}\ndo_test tabfunc01-702 {\n  db eval {\n    SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),4,'int32');\n  }\n} {(005) (007) (013) (017)}\ndo_catchsql_test tabfunc01-710 {\n  SELECT b FROM t600 WHERE a IN carray(inttoptr($PTR1),5,'int33');\n} {1 {unknown datatype: 'int33'}}\n\ndo_test tabfunc01-720 {\n  set PTR2 [int64array_addr 5 7 13 17 23]\n  db eval {\n    SELECT b FROM t600, carray(inttoptr($PTR2),5,'int64') WHERE a=value;\n  }\n} {(005) (007) (013) (017) (023)}\ndo_test tabfunc01-721 {\n  db eval {\n    SELECT remember(123,inttoptr($PTR2));\n    SELECT value FROM carray(inttoptr($PTR2),5,'int64');\n  }\n} {123 123 7 13 17 23}\ndo_test tabfunc01-722 {\n  set PTR3 [expr {$PTR2+16}]\n  db eval {\n    SELECT remember(987,inttoptr($PTR3));\n    SELECT value FROM carray(inttoptr($PTR2),5,'int64');\n  }\n} {987 123 7 987 17 23}\n\ndo_test tabfunc01-730 {\n  set PTR4 [doublearray_addr 5.0 7.0 13.0 17.0 23.0]\n  db eval {\n    SELECT b FROM t600, carray(inttoptr($PTR4),5,'double') WHERE a=value;\n  }\n} {(005) (007) (013) (017) (023)}\n\ndo_test tabfunc01-740 {\n  set PTR5 [textarray_addr x5 x7 x13 x17 x23]\n  db eval {\n    SELECT b FROM t600, carray(inttoptr($PTR5),5,'char*')\n     WHERE a=trim(value,'x');\n  }\n} {(005) (007) (013) (017) (023)}\n\ndo_test tabfunc01-750 {\n  db eval {\n    SELECT aa.value, bb.value, '|'\n      FROM carray(inttoptr($PTR4),5,'double') AS aa\n      JOIN carray(inttoptr($PTR5),5,'char*') AS bb ON aa.rowid=bb.rowid;\n  }\n} {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |}\n\n# Free up memory allocations\nintarray_addr\nint64array_addr\ndoublearray_addr\ntextarray_addr\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/table.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE TABLE statement.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a basic table and verify it is added to sqlite_master\n#\ndo_test table-1.1 {\n  execsql {\n    CREATE TABLE test1 (\n      one varchar(10),\n      two text\n    )\n  }\n  execsql {\n    SELECT sql FROM sqlite_master WHERE type!='meta'\n  }\n} {{CREATE TABLE test1 (\n      one varchar(10),\n      two text\n    )}}\n\n\n# Verify the other fields of the sqlite_master file.\n#\ndo_test table-1.3 {\n  execsql {SELECT name, tbl_name, type FROM sqlite_master WHERE type!='meta'}\n} {test1 test1 table}\n\n# Close and reopen the database.  Verify that everything is\n# still the same.\n#\ndo_test table-1.4 {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT name, tbl_name, type from sqlite_master WHERE type!='meta'}\n} {test1 test1 table}\n\n# Drop the database and make sure it disappears.\n#\ndo_test table-1.5 {\n  execsql {DROP TABLE test1}\n  execsql {SELECT * FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Close and reopen the database.  Verify that the table is\n# still gone.\n#\ndo_test table-1.6 {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Repeat the above steps, but this time quote the table name.\n#\ndo_test table-1.10 {\n  execsql {CREATE TABLE \"create\" (f1 int)}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {create}\ndo_test table-1.11 {\n  execsql {DROP TABLE \"create\"}\n  execsql {SELECT name FROM \"sqlite_master\" WHERE type!='meta'}\n} {}\ndo_test table-1.12 {\n  execsql {CREATE TABLE test1(\"f1 ho\" int)}\n  execsql {SELECT name as \"X\" FROM sqlite_master WHERE type!='meta'}\n} {test1}\ndo_test table-1.13 {\n  execsql {DROP TABLE \"TEST1\"}\n  execsql {SELECT name FROM \"sqlite_master\" WHERE type!='meta'}\n} {}\n\n\n\n# Verify that we cannot make two tables with the same name\n#\ndo_test table-2.1 {\n  execsql {CREATE TABLE TEST2(one text)}\n  catchsql {CREATE TABLE test2(two text default 'hi')}\n} {1 {table test2 already exists}}\ndo_test table-2.1.1 {\n  catchsql {CREATE TABLE \"test2\" (two)}\n} {1 {table \"test2\" already exists}}\ndo_test table-2.1b {\n  set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]\n  lappend v $msg\n} {1 {object name reserved for internal use: sqlite_master}}\ndo_test table-2.1c {\n  db close\n  sqlite3 db test.db\n  set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]\n  lappend v $msg\n} {1 {object name reserved for internal use: sqlite_master}}\ndo_test table-2.1d {\n  catchsql {CREATE TABLE IF NOT EXISTS test2(x,y)}\n} {0 {}}\ndo_test table-2.1e {\n  catchsql {CREATE TABLE IF NOT EXISTS test2(x UNIQUE, y TEXT PRIMARY KEY)}\n} {0 {}}\ndo_test table-2.1f {\n  execsql {DROP TABLE test2; SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Verify that we cannot make a table with the same name as an index\n#\ndo_test table-2.2a {\n  execsql {CREATE TABLE test2(one text)}\n  execsql {CREATE INDEX test3 ON test2(one)}\n  catchsql {CREATE TABLE test3(two text)}\n} {1 {there is already an index named test3}}\ndo_test table-2.2b {\n  db close\n  sqlite3 db test.db\n  set v [catch {execsql {CREATE TABLE test3(two text)}} msg]\n  lappend v $msg\n} {1 {there is already an index named test3}}\ndo_test table-2.2c {\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {test2 test3}\ndo_test table-2.2d {\n  execsql {DROP INDEX test3}\n  set v [catch {execsql {CREATE TABLE test3(two text)}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test table-2.2e {\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {test2 test3}\ndo_test table-2.2f {\n  execsql {DROP TABLE test2; DROP TABLE test3}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {}\n\n# Create a table with many field names\n#\nset big_table \\\n{CREATE TABLE big(\n  f1 varchar(20),\n  f2 char(10),\n  f3 varchar(30) primary key,\n  f4 text,\n  f5 text,\n  f6 text,\n  f7 text,\n  f8 text,\n  f9 text,\n  f10 text,\n  f11 text,\n  f12 text,\n  f13 text,\n  f14 text,\n  f15 text,\n  f16 text,\n  f17 text,\n  f18 text,\n  f19 text,\n  f20 text\n)}\ndo_test table-3.1 {\n  execsql $big_table\n  execsql {SELECT sql FROM sqlite_master WHERE type=='table'}\n} \\{$big_table\\}\ndo_test table-3.2 {\n  set v [catch {execsql {CREATE TABLE BIG(xyz foo)}} msg]\n  lappend v $msg\n} {1 {table BIG already exists}}\ndo_test table-3.3 {\n  set v [catch {execsql {CREATE TABLE biG(xyz foo)}} msg]\n  lappend v $msg\n} {1 {table biG already exists}}\ndo_test table-3.4 {\n  set v [catch {execsql {CREATE TABLE bIg(xyz foo)}} msg]\n  lappend v $msg\n} {1 {table bIg already exists}}\ndo_test table-3.5 {\n  db close\n  sqlite3 db test.db\n  set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg]\n  lappend v $msg\n} {1 {table Big already exists}}\ndo_test table-3.6 {\n  execsql {DROP TABLE big}\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Try creating large numbers of tables\n#\nset r {}\nfor {set i 1} {$i<=100} {incr i} {\n  lappend r [format test%03d $i]\n}\ndo_test table-4.1 {\n  for {set i 1} {$i<=100} {incr i} {\n    set sql \"CREATE TABLE [format test%03d $i] (\"\n    for {set k 1} {$k<$i} {incr k} {\n      append sql \"field$k text,\"\n    }\n    append sql \"last_field text)\"\n    execsql $sql\n  }\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} $r\ndo_test table-4.1b {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} $r\n\n# Drop the even numbered tables\n#\nset r {}\nfor {set i 1} {$i<=100} {incr i 2} {\n  lappend r [format test%03d $i]\n}\ndo_test table-4.2 {\n  for {set i 2} {$i<=100} {incr i 2} {\n    # if {$i==38} {execsql {pragma vdbe_trace=on}}\n    set sql \"DROP TABLE [format TEST%03d $i]\"\n    execsql $sql\n  }\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} $r\n#exit\n\n# Drop the odd number tables\n#\ndo_test table-4.3 {\n  for {set i 1} {$i<=100} {incr i 2} {\n    set sql \"DROP TABLE [format test%03d $i]\"\n    execsql $sql\n  }\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}\n} {}\n\n# Try to drop a table that does not exist\n#\ndo_test table-5.1.1 {\n  catchsql {DROP TABLE test009}\n} {1 {no such table: test009}}\ndo_test table-5.1.2 {\n  catchsql {DROP TABLE IF EXISTS test009}\n} {0 {}}\n\n# Try to drop sqlite_master\n#\ndo_test table-5.2 {\n  catchsql {DROP TABLE IF EXISTS sqlite_master}\n} {1 {table sqlite_master may not be dropped}}\n\n# Dropping sqlite_statN tables is OK.\n#\ndo_test table-5.2.1 {\n  db eval {\n    ANALYZE;\n    DROP TABLE IF EXISTS sqlite_stat1;\n    DROP TABLE IF EXISTS sqlite_stat2;\n    DROP TABLE IF EXISTS sqlite_stat3;\n    DROP TABLE IF EXISTS sqlite_stat4;\n    SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*';\n  }\n} {}\n\ndo_test table-5.2.2 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t0(a,b);\n    CREATE INDEX t ON t0(a);\n    PRAGMA writable_schema=ON;\n    UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE';\n    BEGIN;\n    CREATE TABLE t1(x);\n    ROLLBACK;\n    DROP TABLE IF EXISTS t99;\n  }\n} {}\ndb close\nforcedelete test.db\nsqlite3 db test.db\n\n# Make sure an EXPLAIN does not really create a new table\n#\ndo_test table-5.3 {\n  ifcapable {explain} {\n    execsql {EXPLAIN CREATE TABLE test1(f1 int)}\n  }\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {}\n\n# Make sure an EXPLAIN does not really drop an existing table\n#\ndo_test table-5.4 {\n  execsql {CREATE TABLE test1(f1 int)}\n  ifcapable {explain} {\n    execsql {EXPLAIN DROP TABLE test1}\n  }\n  execsql {SELECT name FROM sqlite_master WHERE type!='meta'}\n} {test1}\n\n# Create a table with a goofy name\n#\n#do_test table-6.1 {\n#  execsql {CREATE TABLE 'Spaces In This Name!'(x int)}\n#  execsql {INSERT INTO 'spaces in this name!' VALUES(1)}\n#  set list [glob -nocomplain testdb/spaces*.tbl]\n#} {testdb/spaces+in+this+name+.tbl}\n\n# Try using keywords as table names or column names.\n# \ndo_test table-7.1 {\n  set v [catch {execsql {\n    CREATE TABLE weird(\n      desc text,\n      asc text,\n      key int,\n      [14_vac] boolean,\n      fuzzy_dog_12 varchar(10),\n      begin blob,\n      end clob\n    )\n  }} msg]\n  lappend v $msg\n} {0 {}}\ndo_test table-7.2 {\n  execsql {\n    INSERT INTO weird VALUES('a','b',9,0,'xyz','hi','y''all');\n    SELECT * FROM weird;\n  }\n} {a b 9 0 xyz hi y'all}\ndo_test table-7.3 {\n  execsql2 {\n    SELECT * FROM weird;\n  }\n} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}\ndo_test table-7.3 {\n  execsql {\n    CREATE TABLE savepoint(release);\n    INSERT INTO savepoint(release) VALUES(10);\n    UPDATE savepoint SET release = 5;\n    SELECT release FROM savepoint;\n  }\n} {5}\n\n# Try out the CREATE TABLE AS syntax\n#\ndo_test table-8.1 {\n  execsql2 {\n    CREATE TABLE t2 AS SELECT * FROM weird;\n    SELECT * FROM t2;\n  }\n} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}\ndo_test table-8.1.1 {\n  execsql {\n    SELECT sql FROM sqlite_master WHERE name='t2';\n  }\n} {{CREATE TABLE t2(\n  \"desc\" TEXT,\n  \"asc\" TEXT,\n  \"key\" INT,\n  \"14_vac\" NUM,\n  fuzzy_dog_12 TEXT,\n  \"begin\",\n  \"end\" TEXT\n)}}\ndo_test table-8.2 {\n  execsql {\n    CREATE TABLE \"t3\"\"xyz\"(a,b,c);\n    INSERT INTO [t3\"xyz] VALUES(1,2,3);\n    SELECT * FROM [t3\"xyz];\n  }\n} {1 2 3}\ndo_test table-8.3 {\n  execsql2 {\n    CREATE TABLE [t4\"abc] AS SELECT count(*) as cnt, max(b+c) FROM [t3\"xyz];\n    SELECT * FROM [t4\"abc];\n  }\n} {cnt 1 max(b+c) 5}\n\n# Update for v3: The declaration type of anything except a column is now a\n# NULL pointer, so the created table has no column types. (Changed result\n# from {{CREATE TABLE 't4\"abc'(cnt NUMERIC,\"max(b+c)\" NUMERIC)}}).\ndo_test table-8.3.1 {\n  execsql {\n    SELECT sql FROM sqlite_master WHERE name='t4\"abc'\n  }\n} {{CREATE TABLE \"t4\"\"abc\"(cnt,\"max(b+c)\")}}\n\nifcapable tempdb {\n  do_test table-8.4 {\n    execsql2 {\n      CREATE TEMPORARY TABLE t5 AS SELECT count(*) AS [y'all] FROM [t3\"xyz];\n      SELECT * FROM t5;\n    }\n  } {y'all 1}\n}\n\ndo_test table-8.5 {\n  db close\n  sqlite3 db test.db\n  execsql2 {\n    SELECT * FROM [t4\"abc];\n  }\n} {cnt 1 max(b+c) 5}\ndo_test table-8.6 {\n  execsql2 {\n    SELECT * FROM t2;\n  }\n} {desc a asc b key 9 14_vac 0 fuzzy_dog_12 xyz begin hi end y'all}\ndo_test table-8.7 {\n  catchsql {\n    SELECT * FROM t5;\n  }\n} {1 {no such table: t5}}\ndo_test table-8.8 {\n  catchsql {\n    CREATE TABLE t5 AS SELECT * FROM no_such_table;\n  }\n} {1 {no such table: no_such_table}}\n\ndo_test table-8.9 {\n  execsql {\n    CREATE TABLE t10(\"col.1\" [char.3]);\n    CREATE TABLE t11 AS SELECT * FROM t10;\n    SELECT sql FROM sqlite_master WHERE name = 't11';\n  }\n} {{CREATE TABLE t11(\"col.1\" TEXT)}}\ndo_test table-8.10 {\n  execsql {\n    CREATE TABLE t12(\n      a INTEGER,\n      b VARCHAR(10),\n      c VARCHAR(1,10),\n      d VARCHAR(+1,-10),\n      e VARCHAR (+1,-10),\n      f \"VARCHAR (+1,-10, 5)\",\n      g BIG INTEGER\n    );\n    CREATE TABLE t13 AS SELECT * FROM t12;\n    SELECT sql FROM sqlite_master WHERE name = 't13';\n  }\n} {{CREATE TABLE t13(\n  a INT,\n  b TEXT,\n  c TEXT,\n  d TEXT,\n  e TEXT,\n  f TEXT,\n  g INT\n)}}\n\n# Make sure we cannot have duplicate column names within a table.\n#\ndo_test table-9.1 {\n  catchsql {\n    CREATE TABLE t6(a,b,a);\n  }\n} {1 {duplicate column name: a}}\ndo_test table-9.2 {\n  catchsql {\n    CREATE TABLE t6(a varchar(100), b blob, a integer);\n  }\n} {1 {duplicate column name: a}}\n\n# Check the foreign key syntax.\n#\nifcapable {foreignkey} {\ndo_test table-10.1 {\n  catchsql {\n    CREATE TABLE t6(a REFERENCES t4(a) NOT NULL);\n    INSERT INTO t6 VALUES(NULL);\n  }\n} {1 {NOT NULL constraint failed: t6.a}}\ndo_test table-10.2 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a REFERENCES t4(a) MATCH PARTIAL);\n  }\n} {0 {}}\ndo_test table-10.3 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a REFERENCES t4 MATCH FULL ON DELETE SET NULL NOT NULL);\n  }\n} {0 {}}\ndo_test table-10.4 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a REFERENCES t4 MATCH FULL ON UPDATE SET DEFAULT DEFAULT 1);\n  }\n} {0 {}}\ndo_test table-10.5 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a NOT NULL NOT DEFERRABLE INITIALLY IMMEDIATE);\n  }\n} {0 {}}\ndo_test table-10.6 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a NOT NULL DEFERRABLE INITIALLY DEFERRED);\n  }\n} {0 {}}\ndo_test table-10.7 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a,\n      FOREIGN KEY (a) REFERENCES t4(b) DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {0 {}}\ndo_test table-10.8 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a,b,c,\n      FOREIGN KEY (b,c) REFERENCES t4(x,y) MATCH PARTIAL\n        ON UPDATE SET NULL ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {0 {}}\ndo_test table-10.9 {\n  catchsql {\n    DROP TABLE t6;\n    CREATE TABLE t6(a,b,c,\n      FOREIGN KEY (b,c) REFERENCES t4(x)\n    );\n  }\n} {1 {number of columns in foreign key does not match the number of columns in the referenced table}}\ndo_test table-10.10 {\n  catchsql {DROP TABLE t6}\n  catchsql {\n    CREATE TABLE t6(a,b,c,\n      FOREIGN KEY (b,c) REFERENCES t4(x,y,z)\n    );\n  }\n} {1 {number of columns in foreign key does not match the number of columns in the referenced table}}\ndo_test table-10.11 {\n  catchsql {DROP TABLE t6}\n  catchsql {\n    CREATE TABLE t6(a,b, c REFERENCES t4(x,y));\n  }\n} {1 {foreign key on c should reference only one column of table t4}}\ndo_test table-10.12 {\n  catchsql {DROP TABLE t6}\n  catchsql {\n    CREATE TABLE t6(a,b,c,\n      FOREIGN KEY (b,x) REFERENCES t4(x,y)\n    );\n  }\n} {1 {unknown column \"x\" in foreign key definition}}\ndo_test table-10.13 {\n  catchsql {DROP TABLE t6}\n  catchsql {\n    CREATE TABLE t6(a,b,c,\n      FOREIGN KEY (x,b) REFERENCES t4(x,y)\n    );\n  }\n} {1 {unknown column \"x\" in foreign key definition}}\n} ;# endif foreignkey\n\n# Test for the \"typeof\" function. More tests for the\n# typeof() function are found in bind.test and types.test.\n#\ndo_test table-11.1 {\n  execsql {\n    CREATE TABLE t7(\n       a integer primary key,\n       b number(5,10),\n       c character varying (8),\n       d VARCHAR(9),\n       e clob,\n       f BLOB,\n       g Text,\n       h\n    );\n    INSERT INTO t7(a) VALUES(1);\n    SELECT typeof(a), typeof(b), typeof(c), typeof(d),\n           typeof(e), typeof(f), typeof(g), typeof(h)\n    FROM t7 LIMIT 1;\n  }\n} {integer null null null null null null null} \ndo_test table-11.2 {\n  execsql {\n    SELECT typeof(a+b), typeof(a||b), typeof(c+d), typeof(c||d)\n    FROM t7 LIMIT 1;\n  }\n} {null null null null}\n\n# Test that when creating a table using CREATE TABLE AS, column types are\n# assigned correctly for (SELECT ...) and 'x AS y' expressions.\ndo_test table-12.1 {\n  ifcapable subquery {\n    execsql {\n      CREATE TABLE t8 AS SELECT b, h, a as i, (SELECT f FROM t7) as j FROM t7;\n    }\n  } else {\n    execsql {\n      CREATE TABLE t8 AS SELECT b, h, a as i, f as j FROM t7;\n    }\n  }\n} {}\ndo_test table-12.2 {\n  execsql {\n    SELECT sql FROM sqlite_master WHERE tbl_name = 't8'\n  }\n} {{CREATE TABLE t8(b NUM,h,i INT,j)}}\n\n#--------------------------------------------------------------------\n# Test cases table-13.*\n#\n# Test the ability to have default values of CURRENT_TIME, CURRENT_DATE\n# and CURRENT_TIMESTAMP.\n#\ndo_test table-13.1 {\n  execsql {\n    CREATE TABLE tablet8(\n       a integer primary key,\n       tm text DEFAULT CURRENT_TIME,\n       dt text DEFAULT CURRENT_DATE,\n       dttm text DEFAULT CURRENT_TIMESTAMP\n    );\n    SELECT * FROM tablet8;\n  }\n} {}\nset i 0\nunset -nocomplain date time seconds\nforeach {date time seconds} {\n  1976-07-04 12:00:00 205329600\n  1994-04-16 14:00:00 766504800\n  2000-01-01 00:00:00 946684800\n  2003-12-31 12:34:56 1072874096\n} {\n  incr i\n  set sqlite_current_time $seconds\n  do_test table-13.2.$i {\n    execsql \"\n      INSERT INTO tablet8(a) VALUES($i);\n      SELECT tm, dt, dttm FROM tablet8 WHERE a=$i;\n    \"\n  } [list $time $date [list $date $time]]\n}\nset sqlite_current_time 0\n\n#--------------------------------------------------------------------\n# Test cases table-14.*\n#\n# Test that a table cannot be created or dropped while other virtual\n# machines are active. This is required because otherwise when in \n# auto-vacuum mode the btree-layer may need to move the root-pages of \n# a table for which there is an open cursor.\n#\n# 2007-05-02:  A open btree cursor no longer blocks CREATE TABLE.\n# But DROP TABLE is still prohibited because we do not want to\n# delete a table out from under a running query.\n#\n\n# db eval {\n#   pragma vdbe_trace = 0;\n# }\n# Try to create a table from within a callback:\nunset -nocomplain result\ndo_test table-14.1 {\n  set rc [\n    catch {\n      db eval {SELECT * FROM tablet8 LIMIT 1} {} {\n        db eval {CREATE TABLE t9(a, b, c)}\n      }\n    } msg\n  ]\n  set result [list $rc $msg]\n} {0 {}}\n\n# Try to drop a table from within a callback:\ndo_test table-14.2 {\n  set rc [\n    catch {\n      db eval {SELECT * FROM tablet8 LIMIT 1} {} {\n        db eval {DROP TABLE t9;}\n      }\n    } msg\n  ] \n  set result [list $rc $msg]\n} {1 {database table is locked}}\n\nifcapable attach {\n  # Now attach a database and ensure that a table can be created in the \n  # attached database whilst in a callback from a query on the main database.\n  do_test table-14.3 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' as aux;\n    }\n    db eval {SELECT * FROM tablet8 LIMIT 1} {} {\n      db eval {CREATE TABLE aux.t1(a, b, c)}\n    }\n  } {}\n  \n  # On the other hand, it should be impossible to drop a table when any VMs \n  # are active. This is because VerifyCookie instructions may have already\n  # been executed, and btree root-pages may not move after this (which a\n  # delete table might do).\n  do_test table-14.4 {\n    set rc [\n      catch {\n        db eval {SELECT * FROM tablet8 LIMIT 1} {} {\n          db eval {DROP TABLE aux.t1;}\n        }\n      } msg\n    ] \n    set result [list $rc $msg]\n  } {1 {database table is locked}}\n}\n\n# Create and drop 2000 tables. This is to check that the balance_shallow()\n# routine works correctly on the sqlite_master table. At one point it\n# contained a bug that would prevent the right-child pointer of the\n# child page from being copied to the root page.\n#\ndo_test table-15.1 {\n  execsql {BEGIN}\n  for {set i 0} {$i<2000} {incr i} {\n    execsql \"CREATE TABLE tbl$i (a, b, c)\"\n  }\n  execsql {COMMIT}\n} {}\ndo_test table-15.2 {\n  execsql {BEGIN}\n  for {set i 0} {$i<2000} {incr i} {\n    execsql \"DROP TABLE tbl$i\"\n  }\n  execsql {COMMIT}\n} {}\n\n# Ticket 3a88d85f36704eebe134f7f48aebf00cd6438c1a (2014-08-05)\n# The following SQL script segfaults while running the INSERT statement:\n#\n#    CREATE TABLE t1(x DEFAULT(max(1)));\n#    INSERT INTO t1(rowid) VALUES(1);\n#\n# The problem appears to be the use of an aggregate function as part of\n# the default value for a column. This problem has been in the code since\n# at least 2006-01-01 and probably before that. This problem was detected\n# and reported on the sqlite-users@sqlite.org mailing list by Zsbán Ambrus. \n#\ndo_execsql_test table-16.1 {\n  CREATE TABLE t16(x DEFAULT(max(1)));\n  INSERT INTO t16(x) VALUES(123);\n  SELECT rowid, x FROM t16;\n} {1 123}\ndo_catchsql_test table-16.2 {\n  INSERT INTO t16(rowid) VALUES(4);\n} {1 {unknown function: max()}}\ndo_execsql_test table-16.3 {\n  DROP TABLE t16;\n  CREATE TABLE t16(x DEFAULT(abs(1)));\n  INSERT INTO t16(rowid) VALUES(4);\n  SELECT rowid, x FROM t16;\n} {4 1}\ndo_catchsql_test table-16.4 {\n  DROP TABLE t16;\n  CREATE TABLE t16(x DEFAULT(avg(1)));\n  INSERT INTO t16(rowid) VALUES(123);\n  SELECT rowid, x FROM t16;\n} {1 {unknown function: avg()}}\ndo_catchsql_test table-16.5 {\n  DROP TABLE t16;\n  CREATE TABLE t16(x DEFAULT(count()));\n  INSERT INTO t16(rowid) VALUES(123);\n  SELECT rowid, x FROM t16;\n} {1 {unknown function: count()}}\ndo_catchsql_test table-16.6 {\n  DROP TABLE t16;\n  CREATE TABLE t16(x DEFAULT(group_concat('x',',')));\n  INSERT INTO t16(rowid) VALUES(123);\n  SELECT rowid, x FROM t16;\n} {1 {unknown function: group_concat()}}\ndo_catchsql_test table-16.7 {\n  INSERT INTO t16 DEFAULT VALUES;\n} {1 {unknown function: group_concat()}}\n\n# Ticket [https://www.sqlite.org/src/info/094d39a4c95ee4abbc417f04214617675ba15c63]\n# describes a assertion fault that occurs on a CREATE TABLE .. AS SELECT statement.\n# the following test verifies that the problem has been fixed.\n#\ndo_execsql_test table-17.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a TEXT);\n  INSERT INTO t1(a) VALUES(1),(2);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(x TEXT, y TEXT);\n  INSERT INTO t2(x,y) VALUES(3,4);\n  DROP TABLE IF EXISTS t3;\n  CREATE TABLE t3 AS\n    SELECT a AS p, coalesce(y,a) AS q FROM t1 LEFT JOIN t2 ON a=x;\n  SELECT p, q, '|' FROM t3 ORDER BY p;\n} {1 1 | 2 2 |}\n\n# 2015-06-16\n# Ticket [https://www.sqlite.org/src/tktview/873cae2b6e25b1991ce5e9b782f9cd0409b96063]\n# Make sure a CREATE TABLE AS statement correctly rolls back partial changes to the\n# sqlite_master table when the SELECT on the right-hand side aborts.\n#\ndo_catchsql_test table-18.1 {\n  DROP TABLE IF EXISTS t1;\n  BEGIN;\n  CREATE TABLE t1 AS SELECT zeroblob(2e20);\n} {1 {string or blob too big}}\ndo_execsql_test table-18.2 {\n  COMMIT;\n  PRAGMA integrity_check;\n} {ok}\n\n# 2015-09-09\n# Ticket [https://www.sqlite.org/src/info/acd12990885d9276]\n# \"CREATE TABLE ... AS SELECT ... FROM sqlite_master\" fails because the row\n# in the sqlite_master table for the next table is initially populated\n# with a NULL instead of a record created by OP_Record.\n#\ndo_execsql_test table-19.1 {\n  CREATE TABLE t19 AS SELECT * FROM sqlite_master;\n  SELECT name FROM t19 ORDER BY name;\n} {{} savepoint t10 t11 t12 t13 t16 t2 t3 t3\\\"xyz t4\\\"abc t7 t8 t9 tablet8 test1 weird}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tableapi.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the sqlite_exec_printf() and\n# sqlite_get_table_printf() APIs.\n#\n# $Id: tableapi.test,v 1.21 2009/07/17 14:37:25 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !gettable {\n  finish_test\n  return\n}\n\nifcapable memdebug {\n  source $testdir/malloc_common.tcl\n}\n\ndo_test tableapi-1.0 {\n  set ::dbx [sqlite3_open test.db]\n  catch {sqlite_exec_printf $::dbx {DROP TABLE xyz} {}}\n  sqlite3_exec_printf $::dbx {CREATE TABLE %s(a int, b text)} xyz\n} {0 {}}\ndo_test tableapi-1.1 {\n  sqlite3_exec_printf $::dbx {\n    INSERT INTO xyz VALUES(1,'%q')\n  } {Hi Y'all}\n} {0 {}}\ndo_test tableapi-1.2 {\n  sqlite3_exec_printf $::dbx {SELECT * FROM xyz} {}\n} {0 {a b 1 {Hi Y'all}}}\n\ndo_test tableapi-2.1 {\n  sqlite3_get_table_printf $::dbx {\n    BEGIN TRANSACTION;\n    SELECT * FROM xyz WHERE b='%q'\n  } {Hi Y'all}\n} {0 1 2 a b 1 {Hi Y'all}}\ndo_test tableapi-2.2 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz\n  } {}\n} {0 1 2 a b 1 {Hi Y'all}}\ndo_test tableapi-2.3 {\n  for {set i 2} {$i<=50} {incr i} {\n    sqlite3_get_table_printf $::dbx \\\n       \"INSERT INTO xyz VALUES($i,'(%s)')\" $i\n  }\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz ORDER BY a\n  } {}\n} {0 50 2 a b 1 {Hi Y'all} 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10 (10) 11 (11) 12 (12) 13 (13) 14 (14) 15 (15) 16 (16) 17 (17) 18 (18) 19 (19) 20 (20) 21 (21) 22 (22) 23 (23) 24 (24) 25 (25) 26 (26) 27 (27) 28 (28) 29 (29) 30 (30) 31 (31) 32 (32) 33 (33) 34 (34) 35 (35) 36 (36) 37 (37) 38 (38) 39 (39) 40 (40) 41 (41) 42 (42) 43 (43) 44 (44) 45 (45) 46 (46) 47 (47) 48 (48) 49 (49) 50 (50)}\ndo_test tableapi-2.3.1 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz  WHERE a>49 ORDER BY a\n  } {}\n} {0 1 2 a b 50 (50)}\ndo_test tableapi-2.3.2 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>47 ORDER BY a\n  } {}\n} {0 3 2 a b 48 (48) 49 (49) 50 (50)}\ndo_test tableapi-2.3.3 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>47 ORDER BY a; invalid\n  } {}\n} {1 {near \"invalid\": syntax error}}\ndo_test tableapi-2.3.4 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>47 ORDER BY a\n  } {} 8\n} {0 a b 48 (48) 49 (49) 50 (50)}\ndo_test tableapi-2.4 {\n  set manyquote ''''''''\n  append manyquote $manyquote\n  append manyquote $manyquote\n  append manyquote $manyquote\n  append manyquote $manyquote\n  append manyquote $manyquote\n  append manyquote $manyquote\n  set ::big_str \"$manyquote Hello $manyquote\"\n  sqlite3_get_table_printf $::dbx {\n    INSERT INTO xyz VALUES(51,'%q')\n  } $::big_str\n} {0 0 0}\ndo_test tableapi-2.5 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>49 ORDER BY a;\n  } {}\n} \"0 2 2 a b 50 (50) 51 \\173$::big_str\\175\"\ndo_test tableapi-2.6 {\n  sqlite3_get_table_printf $::dbx {\n    INSERT INTO xyz VALUES(52,NULL)\n  } {}\n  ifcapable subquery {\n    sqlite3_get_table_printf $::dbx {\n      SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC\n    } {}\n  } else {\n    sqlite3_get_table_printf $::dbx {\n      SELECT * FROM xyz WHERE a=42 OR a=50 OR a=52 ORDER BY a DESC\n    } {}\n  }\n} {0 3 2 a b 52 NULL 50 (50) 42 (42)}\ndo_test tableapi-2.7 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>1000\n  } {}\n} {0 0 0}\n\n# Repeat all tests with the empty_result_callbacks pragma turned on\n#\ndo_test tableapi-3.1 {\n  sqlite3_get_table_printf $::dbx {\n    ROLLBACK;\n    PRAGMA empty_result_callbacks = ON;\n    SELECT * FROM xyz WHERE b='%q'\n  } {Hi Y'all}\n} {0 1 2 a b 1 {Hi Y'all}}\ndo_test tableapi-3.2 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz\n  } {}\n} {0 1 2 a b 1 {Hi Y'all}}\ndo_test tableapi-3.3 {\n  for {set i 2} {$i<=50} {incr i} {\n    sqlite3_get_table_printf $::dbx \\\n       \"INSERT INTO xyz VALUES($i,'(%s)')\" $i\n  }\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz ORDER BY a\n  } {}\n} {0 50 2 a b 1 {Hi Y'all} 2 (2) 3 (3) 4 (4) 5 (5) 6 (6) 7 (7) 8 (8) 9 (9) 10 (10) 11 (11) 12 (12) 13 (13) 14 (14) 15 (15) 16 (16) 17 (17) 18 (18) 19 (19) 20 (20) 21 (21) 22 (22) 23 (23) 24 (24) 25 (25) 26 (26) 27 (27) 28 (28) 29 (29) 30 (30) 31 (31) 32 (32) 33 (33) 34 (34) 35 (35) 36 (36) 37 (37) 38 (38) 39 (39) 40 (40) 41 (41) 42 (42) 43 (43) 44 (44) 45 (45) 46 (46) 47 (47) 48 (48) 49 (49) 50 (50)}\ndo_test tableapi-3.3.1 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz  WHERE a>49 ORDER BY a\n  } {}\n} {0 1 2 a b 50 (50)}\ndo_test tableapi-3.3.2 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>47 ORDER BY a\n  } {}\n} {0 3 2 a b 48 (48) 49 (49) 50 (50)}\ndo_test tableapi-3.4 {\n  sqlite3_get_table_printf $::dbx {\n    INSERT INTO xyz VALUES(51,'%q')\n  } $::big_str\n} {0 0 0}\ndo_test tableapi-3.5 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>49 ORDER BY a;\n  } {}\n} \"0 2 2 a b 50 (50) 51 \\173$::big_str\\175\"\ndo_test tableapi-3.6 {\n  sqlite3_get_table_printf $::dbx {\n    INSERT INTO xyz VALUES(52,NULL)\n  } {}\n  ifcapable subquery {\n    sqlite3_get_table_printf $::dbx {\n      SELECT * FROM xyz WHERE a IN (42,50,52) ORDER BY a DESC\n    } {}\n  } else {\n    sqlite3_get_table_printf $::dbx {\n      SELECT * FROM xyz WHERE a=42 OR a=50 OR a=52 ORDER BY a DESC\n    } {}\n  }\n} {0 3 2 a b 52 NULL 50 (50) 42 (42)}\ndo_test tableapi-3.7 {\n  sqlite3_get_table_printf $::dbx {\n    SELECT * FROM xyz WHERE a>1000\n  } {}\n} {0 0 2 a b}\n\ndo_test tableapi-4.1 {\n  set rc [catch {\n    sqlite3_get_table_printf $::dbx {\n      SELECT * FROM xyz;  SELECT * FROM sqlite_master\n    } {}\n  } msg]\n  concat $rc $msg\n} {0 1 {sqlite3_get_table() called with two or more incompatible queries}}\n\n# A report on the mailing list says that the sqlite_get_table() api fails\n# on queries involving more than 40 columns.  The following code attempts\n# to test that complaint\n#\ndo_test tableapi-5.1 {\n  set sql \"CREATE TABLE t2(\"\n  set sep \"\"\n  for {set i 1} {$i<=100} {incr i} {\n    append sql ${sep}x$i\n    set sep ,\n  }\n  append sql )\n  sqlite3_get_table_printf $::dbx $sql {}\n  set sql \"INSERT INTO t2 VALUES(\"\n  set sep \"\"\n  for {set i 1} {$i<=100} {incr i} {\n    append sql ${sep}$i\n    set sep ,\n  }\n  append sql )\n  sqlite3_get_table_printf $::dbx $sql {}\n  sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {}\n} {0 1 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100}\ndo_test tableapi-5.2 {\n  set sql \"INSERT INTO t2 VALUES(\"\n  set sep \"\"\n  for {set i 1} {$i<=100} {incr i} {\n    append sql ${sep}[expr {$i+1000}]\n    set sep ,\n  }\n  append sql )\n  sqlite3_get_table_printf $::dbx $sql {}\n  sqlite3_get_table_printf $::dbx {SELECT * FROM t2} {}\n} {0 2 100 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60 x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75 x76 x77 x78 x79 x80 x81 x82 x83 x84 x85 x86 x87 x88 x89 x90 x91 x92 x93 x94 x95 x96 x97 x98 x99 x100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100}\n\nifcapable schema_pragmas {\n  do_test tableapi-6.1 {\n    sqlite3_get_table_printf $::dbx {PRAGMA user_version} {}\n  } {0 1 1 user_version 0}\n}\n\n# do_malloc_test closes and deletes the usual db connections and files on\n# each iteration.  $::dbx is a seperate connection, and on Windows, will\n# cause the file deletion of test.db to fail, so we move the close of $::dbx\n# up to here before the do_malloc_test.\ndo_test tableapi-99.0 {\n  sqlite3_close $::dbx\n} {SQLITE_OK}\n\nifcapable memdebug {\n  do_malloc_test tableapi-7 -sqlprep {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    INSERT INTO t1 SELECT a+4, b+4 FROM t1;\n    INSERT INTO t1 SELECT a+8, b+8 FROM t1;\n  } -tclbody {\n    set r [sqlite3_get_table_printf db {SELECT rowid, a, b FROM t1} {}]\n    if {[llength $r]<26} {error \"out of memory\"}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tableopts.test",
    "content": "# 2013-10-19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the operation of table-options in the WITH clause of the\n# CREATE TABLE statement.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tableopt-1.1 {\n  catchsql {\n    CREATE TABLE t1(a,b) WITHOUT rowid;\n  }\n} {1 {PRIMARY KEY missing on table t1}}\ndo_test tableopt-1.1b {\n  catchsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT,b) WITHOUT rowid;\n  }\n} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}}\ndo_test tableopt-1.2 {\n  catchsql {\n    CREATE TABLE t1(a,b) WITHOUT unknown2;\n  }\n} {1 {unknown table option: unknown2}}\n\ndo_execsql_test tableopt-2.1 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a,b)) WITHOUT rowid;\n  INSERT INTO t1 VALUES(1,2,3),(2,3,4);\n  SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;\n} {3 4}\ndo_test tableopt-2.1.1 {\n  catchsql {\n    SELECT rowid, * FROM t1;\n  }\n} {1 {no such column: rowid}}\ndo_test tableopt-2.1.2 {\n  catchsql {\n    SELECT _rowid_, * FROM t1;\n  }\n} {1 {no such column: _rowid_}}\ndo_test tableopt-2.1.3 {\n  catchsql {\n    SELECT oid, * FROM t1;\n  }\n} {1 {no such column: oid}}\ndo_execsql_test tableopt-2.2 {\n  VACUUM;\n  SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;\n} {3 4}\ndo_test tableopt-2.3 {\n  sqlite3 db2 test.db\n  db2 eval {SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;}\n} {3 4}\ndb2 close\n\n# Make sure the \"without\" keyword is still usable as a table or\n# column name.\n#\ndo_execsql_test tableopt-3.1 {\n  CREATE TABLE without(x INTEGER PRIMARY KEY, without TEXT);\n  INSERT INTO without VALUES(1, 'xyzzy'), (2, 'fizzle');\n  SELECT * FROM without WHERE without='xyzzy';\n} {1 xyzzy}\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tclsqlite.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for TCL interface to the\n# SQLite library. \n#\n# Actually, all tests are based on the TCL interface, so the main\n# interface is pretty well tested.  This file contains some addition\n# tests for fringe issues that the main test suite does not cover.\n#\n# $Id: tclsqlite.test,v 1.73 2009/03/16 13:19:36 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Check the error messages generated by tclsqlite\n#\nset r \"sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?\"\nif {[sqlite3 -has-codec]} {\n  append r \" ?-key CODECKEY?\"\n}\ndo_test tcl-1.1 {\n  set v [catch {sqlite3 bogus} msg]\n  regsub {really_sqlite3} $msg {sqlite3} msg\n  lappend v $msg\n} [list 1 \"wrong # args: should be \\\"$r\\\"\"]\ndo_test tcl-1.2 {\n  set v [catch {db bogus} msg]\n  lappend v $msg\n} {1 {bad option \"bogus\": must be authorizer, backup, busy, cache, changes, close, collate, collation_needed, commit_hook, complete, copy, enable_load_extension, errorcode, eval, exists, function, incrblob, interrupt, last_insert_rowid, nullvalue, onecolumn, preupdate, profile, progress, rekey, restore, rollback_hook, status, timeout, total_changes, trace, trace_v2, transaction, unlock_notify, update_hook, version, or wal_hook}}\ndo_test tcl-1.2.1 {\n  set v [catch {db cache bogus} msg]\n  lappend v $msg\n} {1 {bad option \"bogus\": must be flush or size}}\ndo_test tcl-1.2.2 {\n  set v [catch {db cache} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db cache option ?arg?\"}}\ndo_test tcl-1.3 {\n  execsql {CREATE TABLE t1(a int, b int)}\n  execsql {INSERT INTO t1 VALUES(10,20)}\n  set v [catch {\n    db eval {SELECT * FROM t1} data {\n      error \"The error message\"\n    }\n  } msg]\n  lappend v $msg\n} {1 {The error message}}\ndo_test tcl-1.4 {\n  set v [catch {\n    db eval {SELECT * FROM t2} data {\n      error \"The error message\"\n    }\n  } msg]\n  lappend v $msg\n} {1 {no such table: t2}}\ndo_test tcl-1.5 {\n  set v [catch {\n    db eval {SELECT * FROM t1} data {\n      break\n    }\n  } msg]\n  lappend v $msg\n} {0 {}}\ncatch {expr x*} msg\ndo_test tcl-1.6 {\n  set v [catch {\n    db eval {SELECT * FROM t1} data {\n      expr x*\n    }\n  } msg]\n  lappend v $msg\n} [list 1 $msg]\ndo_test tcl-1.7 {\n  set v [catch {db} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db SUBCOMMAND ...\"}}\nif {[catch {db auth {}}]==0} {\n  do_test tcl-1.8 {\n    set v [catch {db authorizer 1 2 3} msg]\n    lappend v $msg\n  } {1 {wrong # args: should be \"db authorizer ?CALLBACK?\"}}\n}\ndo_test tcl-1.9 {\n  set v [catch {db busy 1 2 3} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db busy CALLBACK\"}}\ndo_test tcl-1.10 {\n  set v [catch {db progress 1} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db progress N CALLBACK\"}}\ndo_test tcl-1.11 {\n  set v [catch {db changes xyz} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db changes \"}}\ndo_test tcl-1.12 {\n  set v [catch {db commit_hook a b c} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db commit_hook ?CALLBACK?\"}}\nifcapable {complete} {\n  do_test tcl-1.13 {\n    set v [catch {db complete} msg]\n    lappend v $msg\n  } {1 {wrong # args: should be \"db complete SQL\"}}\n}\ndo_test tcl-1.14 {\n  set v [catch {db eval} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db eval ?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?\"}}\ndo_test tcl-1.15 {\n  set v [catch {db function} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db function NAME ?SWITCHES? SCRIPT\"}}\ndo_test tcl-1.16 {\n  set v [catch {db last_insert_rowid xyz} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db last_insert_rowid \"}}\ndo_test tcl-1.17 {\n  set v [catch {db rekey} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db rekey KEY\"}}\ndo_test tcl-1.18 {\n  set v [catch {db timeout} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db timeout MILLISECONDS\"}}\ndo_test tcl-1.19 {\n  set v [catch {db collate} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db collate NAME SCRIPT\"}}\ndo_test tcl-1.20 {\n  set v [catch {db collation_needed} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db collation_needed SCRIPT\"}}\ndo_test tcl-1.21 {\n  set v [catch {db total_changes xyz} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db total_changes \"}}\ndo_test tcl-1.22 {\n  set v [catch {db copy} msg]\n  lappend v $msg\n} {1 {wrong # args: should be \"db copy CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?\"}}\ndo_test tcl-1.23 {\n  set v [catch {sqlite3 db2 test.db -vfs nosuchvfs} msg]\n  lappend v $msg\n} {1 {no such vfs: nosuchvfs}}\n\ncatch {unset ::result}\ndo_test tcl-2.1 {\n  execsql \"CREATE TABLE t\\u0123x(a int, b\\u1235 float)\"\n} {}\nifcapable schema_pragmas {\n  do_test tcl-2.2 {\n    execsql \"PRAGMA table_info(t\\u0123x)\"\n  } \"0 a int 0 {} 0 1 b\\u1235 float 0 {} 0\"\n}\ndo_test tcl-2.3 {\n  execsql \"INSERT INTO t\\u0123x VALUES(1,2.3)\"\n  db eval \"SELECT * FROM t\\u0123x\" result break\n  set result(*)\n} \"a b\\u1235\"\n\n\n# Test the onecolumn method\n#\ndo_test tcl-3.1 {\n  execsql {\n    INSERT INTO t1 SELECT a*2, b*2 FROM t1;\n    INSERT INTO t1 SELECT a*2+1, b*2+1 FROM t1;\n    INSERT INTO t1 SELECT a*2+3, b*2+3 FROM t1;\n  }\n  set rc [catch {db onecolumn {SELECT * FROM t1 ORDER BY a}} msg]\n  lappend rc $msg\n} {0 10}\ndo_test tcl-3.2 {\n  db onecolumn {SELECT * FROM t1 WHERE a<0}\n} {}\ndo_test tcl-3.3 {\n  set rc [catch {db onecolumn} errmsg]\n  lappend rc $errmsg\n} {1 {wrong # args: should be \"db onecolumn SQL\"}}\ndo_test tcl-3.4 {\n  set rc [catch {db onecolumn {SELECT bogus}} errmsg]\n  lappend rc $errmsg\n} {1 {no such column: bogus}}\nifcapable {tclvar} {\n  do_test tcl-3.5 {\n    set b 50\n    set rc [catch {db one {SELECT * FROM t1 WHERE b>$b}} msg]\n    lappend rc $msg\n  } {0 41}\n  do_test tcl-3.6 {\n    set b 500\n    set rc [catch {db one {SELECT * FROM t1 WHERE b>$b}} msg]\n    lappend rc $msg\n  } {0 {}}\n  do_test tcl-3.7 {\n    set b 500\n    set rc [catch {db one {\n      INSERT INTO t1 VALUES(99,510);\n      SELECT * FROM t1 WHERE b>$b\n    }} msg]\n    lappend rc $msg\n  } {0 99}\n}\nifcapable {!tclvar} {\n   execsql {INSERT INTO t1 VALUES(99,510)}\n}\n\n# Turn the busy handler on and off\n#\ndo_test tcl-4.1 {\n  proc busy_callback {cnt} {\n    break\n  }\n  db busy busy_callback\n  db busy\n} {busy_callback}\ndo_test tcl-4.2 {\n  db busy {}\n  db busy\n} {}\n\nifcapable {tclvar} {\n  # Parsing of TCL variable names within SQL into bound parameters.\n  #\n  do_test tcl-5.1 {\n    execsql {CREATE TABLE t3(a,b,c)}\n    catch {unset x}\n    set x(1) A\n    set x(2) B\n    execsql {\n      INSERT INTO t3 VALUES($::x(1),$::x(2),$::x(3));\n      SELECT * FROM t3\n    }\n  } {A B {}}\n  do_test tcl-5.2 {\n    execsql {\n      SELECT typeof(a), typeof(b), typeof(c) FROM t3\n    }\n  } {text text null}\n  do_test tcl-5.3 {\n    catch {unset x}\n    set x [binary format h12 686900686f00]\n    execsql {\n      UPDATE t3 SET a=$::x;\n    }\n    db eval {\n      SELECT a FROM t3\n    } break\n    binary scan $a h12 adata\n    set adata\n  } {686900686f00}\n  do_test tcl-5.4 {\n    execsql {\n      SELECT typeof(a), typeof(b), typeof(c) FROM t3\n    }\n  } {blob text null}\n}\n\n# Operation of \"break\" and \"continue\" within row scripts\n#\ndo_test tcl-6.1 {\n  db eval {SELECT * FROM t1} {\n    break\n  }\n  lappend a $b\n} {10 20}\ndo_test tcl-6.2 {\n  set cnt 0\n  db eval {SELECT * FROM t1} {\n    if {$a>40} continue\n    incr cnt\n  }\n  set cnt\n} {4}\ndo_test tcl-6.3 {\n  set cnt 0\n  db eval {SELECT * FROM t1} {\n    if {$a<40} continue\n    incr cnt\n  }\n  set cnt\n} {5}\ndo_test tcl-6.4 {\n  proc return_test {x} {\n    db eval {SELECT * FROM t1} {\n      if {$a==$x} {return $b}\n    }\n  }\n  return_test 10\n} 20\ndo_test tcl-6.5 {\n  return_test 20\n} 40\ndo_test tcl-6.6 {\n  return_test 99\n} 510\ndo_test tcl-6.7 {\n  return_test 0\n} {}\n\ndo_test tcl-7.1 {\n  db version\n  expr 0\n} {0}\n\n# modify and reset the NULL representation\n#\ndo_test tcl-8.1 {\n  db nullvalue NaN\n  execsql {INSERT INTO t1 VALUES(30,NULL)}\n  db eval {SELECT * FROM t1 WHERE b IS NULL}\n} {30 NaN}\nproc concatFunc args {return [join $args {}]}\ndo_test tcl-8.2 {\n  db function concat concatFunc\n  db eval {SELECT concat('a', b, 'z') FROM t1 WHERE b is NULL}\n} {aNaNz}\ndo_test tcl-8.3 {\n  db nullvalue NULL\n  db nullvalue\n} {NULL}\ndo_test tcl-8.4 {\n  db nullvalue {}\n  db eval {SELECT * FROM t1 WHERE b IS NULL}\n} {30 {}}\ndo_test tcl-8.5 {\n  db function concat concatFunc\n  db eval {SELECT concat('a', b, 'z') FROM t1 WHERE b is NULL}\n} {az}\n\n# Test the return type of user-defined functions\n#\ndo_test tcl-9.1 {\n  db function ret_str {return \"hi\"}\n  execsql {SELECT typeof(ret_str())}\n} {text}\ndo_test tcl-9.2 {\n  db function ret_dbl {return [expr {rand()*0.5}]}\n  execsql {SELECT typeof(ret_dbl())}\n} {real}\ndo_test tcl-9.3 {\n  db function ret_int {return [expr {int(rand()*200)}]}\n  execsql {SELECT typeof(ret_int())}\n} {integer}\n\n# Recursive calls to the same user-defined function\n#\nifcapable tclvar {\n  do_test tcl-9.10 {\n    proc userfunc_r1 {n} {\n      if {$n<=0} {return 0}\n      set nm1 [expr {$n-1}]\n      return [expr {[db eval {SELECT r1($nm1)}]+$n}]\n    }\n    db function r1 userfunc_r1\n    execsql {SELECT r1(10)}\n  } {55}\n  do_test tcl-9.11 {\n    execsql {SELECT r1(100)}\n  } {5050}\n}\n\n# Tests for the new transaction method\n#\ndo_test tcl-10.1 {\n  db transaction {}\n} {}\ndo_test tcl-10.2 {\n  db transaction deferred {}\n} {}\ndo_test tcl-10.3 {\n  db transaction immediate {}\n} {}\ndo_test tcl-10.4 {\n  db transaction exclusive {}\n} {}\ndo_test tcl-10.5 {\n  set rc [catch {db transaction xyzzy {}} msg]\n  lappend rc $msg\n} {1 {bad transaction type \"xyzzy\": must be deferred, exclusive, or immediate}}\ndo_test tcl-10.6 {\n  set rc [catch {db transaction {error test-error}} msg]\n  lappend rc $msg\n} {1 test-error}\ndo_test tcl-10.7 {\n  db transaction {\n    db eval {CREATE TABLE t4(x)}\n    db transaction {\n      db eval {INSERT INTO t4 VALUES(1)}\n    }\n  }\n  db eval {SELECT * FROM t4}\n} 1\ndo_test tcl-10.8 {\n  catch {\n    db transaction {\n      db eval {INSERT INTO t4 VALUES(2)}\n      db eval {INSERT INTO t4 VALUES(3)}\n      db eval {INSERT INTO t4 VALUES(4)}\n      error test-error\n    }\n  }\n  db eval {SELECT * FROM t4}\n} 1\ndo_test tcl-10.9 {\n  db transaction {\n    db eval {INSERT INTO t4 VALUES(2)}\n    catch {\n      db transaction {\n        db eval {INSERT INTO t4 VALUES(3)}\n        db eval {INSERT INTO t4 VALUES(4)}\n        error test-error\n      }\n    }\n  }\n  db eval {SELECT * FROM t4}\n} {1 2}\ndo_test tcl-10.10 {\n  for {set i 0} {$i<1} {incr i} {\n    db transaction {\n      db eval {INSERT INTO t4 VALUES(5)}\n      continue\n    }\n    error \"This line should not be run\"\n  }\n  db eval {SELECT * FROM t4}\n} {1 2 5}\ndo_test tcl-10.11 {\n  for {set i 0} {$i<10} {incr i} {\n    db transaction {\n      db eval {INSERT INTO t4 VALUES(6)}\n      break\n    }\n  }\n  db eval {SELECT * FROM t4}\n} {1 2 5 6}\ndo_test tcl-10.12 {\n  set rc [catch {\n    for {set i 0} {$i<10} {incr i} {\n      db transaction {\n        db eval {INSERT INTO t4 VALUES(7)}\n        return\n      }\n    }\n  }]\n} {2}\ndo_test tcl-10.13 {\n  db eval {SELECT * FROM t4}\n} {1 2 5 6 7}\n\n# Now test that [db transaction] commands may be nested with \n# the expected results.\n#\ndo_test tcl-10.14 {\n  db transaction {\n    db eval {\n      DELETE FROM t4;\n      INSERT INTO t4 VALUES('one');\n    }\n\n    catch { \n      db transaction {\n        db eval { INSERT INTO t4 VALUES('two') }\n        db transaction {\n          db eval { INSERT INTO t4 VALUES('three') }\n          error \"throw an error!\"\n        }\n      }\n    }\n  }\n\n  db eval {SELECT * FROM t4}\n} {one}\ndo_test tcl-10.15 {\n  # Make sure a transaction has not been left open.\n  db eval {BEGIN ; COMMIT}\n} {}\ndo_test tcl-10.16 {\n  db transaction {\n    db eval { INSERT INTO t4 VALUES('two'); }\n    db transaction {\n      db eval { INSERT INTO t4 VALUES('three') }\n      db transaction {\n        db eval { INSERT INTO t4 VALUES('four') }\n      }\n    }\n  }\n  db eval {SELECT * FROM t4}\n} {one two three four}\ndo_test tcl-10.17 {\n  catch {\n    db transaction {\n      db eval { INSERT INTO t4 VALUES('A'); }\n      db transaction {\n        db eval { INSERT INTO t4 VALUES('B') }\n        db transaction {\n          db eval { INSERT INTO t4 VALUES('C') }\n          error \"throw an error!\"\n        }\n      }\n    }\n  }\n  db eval {SELECT * FROM t4}\n} {one two three four}\ndo_test tcl-10.18 {\n  # Make sure a transaction has not been left open.\n  db eval {BEGIN ; COMMIT}\n} {}\n\n# Mess up a [db transaction] command by locking the database using a\n# second connection when it tries to commit. Make sure the transaction\n# is not still open after the \"database is locked\" exception is thrown.\n#\ndo_test tcl-10.18 {\n  sqlite3 db2 test.db\n  db2 eval {\n    BEGIN;\n    SELECT * FROM sqlite_master;\n  }\n\n  set rc [catch {\n    db transaction {\n      db eval {INSERT INTO t4 VALUES('five')}\n    }\n  } msg]\n  list $rc $msg\n} {1 {database is locked}}\ndo_test tcl-10.19 {\n  db eval {BEGIN ; COMMIT}\n} {}\n\n# Thwart a [db transaction] command by locking the database using a\n# second connection with \"BEGIN EXCLUSIVE\". Make sure no transaction is \n# open after the \"database is locked\" exception is thrown.\n#\ndo_test tcl-10.20 {\n  db2 eval {\n    COMMIT;\n    BEGIN EXCLUSIVE;\n  }\n  set rc [catch {\n    db transaction {\n      db eval {INSERT INTO t4 VALUES('five')}\n    }\n  } msg]\n  list $rc $msg\n} {1 {database is locked}}\ndo_test tcl-10.21 {\n  db2 close\n  db eval {BEGIN ; COMMIT}\n} {}\ndo_test tcl-10.22 {\n  sqlite3 db2 test.db\n  db transaction exclusive {\n    catch { db2 eval {SELECT * FROM sqlite_master} } msg\n    set msg \"db2: $msg\"\n  }\n  set msg\n} {db2: database is locked}\ndb2 close\n\ndo_test tcl-11.1 {\n  db eval {INSERT INTO t4 VALUES(6)}\n  db exists {SELECT x,x*2,x+x FROM t4 WHERE x==6}\n} {1}\ndo_test tcl-11.2 {\n  db exists {SELECT 0 FROM t4 WHERE x==6}\n} {1}\ndo_test tcl-11.3 {\n  db exists {SELECT 1 FROM t4 WHERE x==8}\n} {0}\ndo_test tcl-11.3.1 {\n  tcl_objproc db exists {SELECT 1 FROM t4 WHERE x==8}\n} {0}\n\ndo_test tcl-12.1 {\n  unset -nocomplain a b c version\n  set version [db version]\n  scan $version \"%d.%d.%d\" a b c\n  expr $a*1000000 + $b*1000 + $c\n} [sqlite3_libversion_number]\n\n\n# Check to see that when bindings of the form @aaa are used instead\n# of $aaa, that objects are treated as bytearray and are inserted\n# as BLOBs.\n#\nifcapable tclvar {\n  do_test tcl-13.1 {\n    db eval {CREATE TABLE t5(x BLOB)}\n    set x abc123\n    db eval {INSERT INTO t5 VALUES($x)}\n    db eval {SELECT typeof(x) FROM t5}\n  } {text}\n  do_test tcl-13.2 {\n    binary scan $x H notUsed\n    db eval {\n      DELETE FROM t5;\n      INSERT INTO t5 VALUES($x);\n      SELECT typeof(x) FROM t5;\n    }\n  } {text}\n  do_test tcl-13.3 {\n    db eval {\n      DELETE FROM t5;\n      INSERT INTO t5 VALUES(@x);\n      SELECT typeof(x) FROM t5;\n    }\n  } {blob}\n  do_test tcl-13.4 {\n    set y 1234\n    db eval {\n      DELETE FROM t5;\n      INSERT INTO t5 VALUES(@y);\n      SELECT hex(x), typeof(x) FROM t5\n    }\n  } {31323334 blob}\n}\n\ndb func xCall xCall\nproc xCall {} { return \"value\" }\ndo_execsql_test tcl-14.1 {\n  CREATE TABLE t6(x);\n  INSERT INTO t6 VALUES(1);\n}\ndo_test tcl-14.2 {\n  db one {SELECT x FROM t6 WHERE xCall()!='value'}\n} {}\n\n# Verify that the \"exists\" and \"onecolumn\" methods work when\n# a \"profile\" is registered.\n#\ncatch {db close}\nsqlite3 db :memory:\nproc noop-profile {args} {\n  return\n}\ndo_test tcl-15.0 {\n  db eval {CREATE TABLE t1(a); INSERT INTO t1 VALUES(1),(2),(3);}\n  db onecolumn {SELECT a FROM t1 WHERE a>2}\n} {3}\ndo_test tcl-15.1 {\n  db exists {SELECT a FROM t1 WHERE a>2}\n} {1}\ndo_test tcl-15.2 {\n  db exists {SELECT a FROM t1 WHERE a>3}\n} {0}\ndb profile noop-profile\ndo_test tcl-15.3 {\n  db onecolumn {SELECT a FROM t1 WHERE a>2}\n} {3}\ndo_test tcl-15.4 {\n  db exists {SELECT a FROM t1 WHERE a>2}\n} {1}\ndo_test tcl-15.5 {\n  db exists {SELECT a FROM t1 WHERE a>3}\n} {0}\n\n\n# 2017-06-26: The --withoutnulls flag to \"db eval\".\n#\n# In the \"db eval --withoutnulls SQL ARRAY\" form, NULL results cause the\n# corresponding array entry to be unset.  The default behavior (without\n# the -withoutnulls flags) is for the corresponding array value to get\n# the [db nullvalue] string.\n#\ncatch {db close}\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test tcl-16.100 {\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(1,2),(2,NULL),(3,'xyz');\n}\ndo_test tcl-16.101 {\n  set res {}\n  unset -nocomplain x\n  db eval {SELECT * FROM t1} x {\n    lappend res $x(a) [array names x]\n  }\n  set res\n} {1 {a b *} 2 {a b *} 3 {a b *}}\ndo_test tcl-16.102 {\n  set res [catch {\n    db eval -unknown {SELECT * FROM t1} x {\n      lappend res $x(a) [array names x]\n    }\n  } rc]\n  lappend res $rc\n} {1 {unknown option: \"-unknown\"}}\ndo_test tcl-16.103 {\n  set res {}\n  unset -nocomplain x\n  db eval -withoutnulls {SELECT * FROM t1} x {\n    lappend res $x(a) [array names x]\n  }\n  set res\n} {1 {a b *} 2 {a *} 3 {a b *}}\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tempdb.test",
    "content": "# 2008 April 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n# The focus of this file is in making sure that rolling back\n# a statement journal works correctly.\n#\n# $Id: tempdb.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Use a temporary database.\n#\ndb close\nsqlite3 db {}\n\n# Force a statement journal rollback on a database file that\n# has never been opened.\n#\ndo_test tempdb-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(x UNIQUE);\n    CREATE TABLE t2(y);\n    INSERT INTO t2 VALUES('hello');\n    INSERT INTO t2 VALUES(NULL);\n  }\n  # Because of the transaction, the temporary database file\n  # has not even been opened yet.  The following statement\n  # will cause a statement journal rollback on this non-existant\n  # file.\n  catchsql {\n    INSERT INTO t1\n    SELECT CASE WHEN y IS NULL THEN test_error('oops', 11) ELSE y END\n      FROM t2;\n  }\n} {1 oops}\n\n# Verify that no writes occurred in t1.\n#\ndo_test tempdb-1.2 {\n  execsql {\n    SELECT * FROM t1\n  }\n} {}\n\ndo_test tempdb-2.1 {\n  # Set $::jrnl_in_memory if the journal file is expected to be in-memory.\n  # Similarly, set $::subj_in_memory if the sub-journal file is expected\n  # to be in memory. These variables are used to calculate the expected\n  # number of open files in the test cases below.\n  #\n  set jrnl_in_memory [expr {[permutation] eq \"inmemory_journal\"}]\n  set subj_in_memory [expr {$jrnl_in_memory || $TEMP_STORE>=2}]\n\n  db close\n  sqlite3 db test.db\n} {}\ndo_test tempdb-2.2 {\n  execsql {\n    CREATE TABLE t1 (a PRIMARY KEY, b, c);\n    CREATE TABLE t2 (a, b, c);\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2, 3);\n      INSERT INTO t1 VALUES(4, 5, 6);\n      INSERT INTO t2 VALUES(7, 8, 9);\n      INSERT INTO t2 SELECT * FROM t1;\n  }\n  catchsql { INSERT INTO t1 SELECT * FROM t2 }\n  set sqlite_open_file_count\n} [expr 1 + (0==$jrnl_in_memory)]\ndo_test tempdb-2.3 {\n  execsql {\n    PRAGMA temp_store = 'memory';\n    ROLLBACK;\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2, 3);\n      INSERT INTO t1 VALUES(4, 5, 6);\n      INSERT INTO t2 SELECT * FROM t1;\n  }\n  catchsql { INSERT INTO t1 SELECT * FROM t2 }\n  set sqlite_open_file_count\n} [expr 1 + (0==$jrnl_in_memory)]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tempdb2.test",
    "content": "# 2016 March 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tempdb2\n\ndb close\nsqlite3 db \"\"\n\nproc int2str {i} { string range [string repeat \"$i.\" 450] 0 899 }\ndb func int2str int2str\n\n#-------------------------------------------------------------------------\n#\n#  1.1: Write a big transaction to the db. One so large that it forces\n#       the file to be created and the cache flushed to disk on COMMIT.\n#\n#  1.2: Write a small transaction - one small enough that it remains in\n#       memory on COMMIT. All the pages of table [t1] are now dirty.\n#\n#  1.3: Delete the contents of [t1]. This moves all of its leaves to the\n#       free-list and causes the btree layer to call PagerDontWrite() on\n#       each of them.\n#\n#       Then do a big update on table [t2]. So big that the former leaves\n#       of [t1] are forced out of the cache. Then roll back the transaction.\n#       If the PagerDontWrite() calls are honoured and the data is not written\n#       to disk, the update made in test 1.2 will be lost at this point. Or, if\n#       they are ignored (as they should be for temp databases), the update\n#       will be safely written out to disk before the cache entries are\n#       discarded.\n#\ndo_execsql_test 1.1 {\n  PRAGMA page_size=1024;\n  PRAGMA cache_size=50;\n\n  BEGIN;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, int2str(1));\n    INSERT INTO t1 VALUES(2, int2str(1));\n    INSERT INTO t1 VALUES(3, int2str(1));\n\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    WITH c(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100 ) \n    INSERT INTO t2 SELECT x, int2str(x) FROM c;\n  COMMIT;\n\n  PRAGMA lock_status;\n} {main unlocked temp closed}\n\ndo_execsql_test 1.2 {\n  UPDATE t1 SET b=int2str(2);\n  SELECT b=int2str(2) FROM t1\n} {1 1 1}\n\ndo_execsql_test 1.3 {\n  BEGIN;\n    DELETE FROM t1;\n    UPDATE t2 SET b=int2str(a+1);\n  ROLLBACK;\n}\n\ndo_execsql_test 1.4 {\n  SELECT b=int2str(2) FROM t1\n} {1 1 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tempfault.test",
    "content": "# 2016 April 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for fault-injection when SQLite is used with\n# a temp file database.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset testprefix tempfault\n\n# sqlite3_memdebug_vfs_oom_test 0\n\ndo_faultsim_test 1 -faults * -prep {\n  sqlite3 db \"\"\n  db eval {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n} -body {\n  execsql { INSERT INTO t1 VALUES(5, 6) }\n} -test {\n  faultsim_test_result {0 {}}\n  set rc [catch { execsql { SELECT * FROM t1 } } msg]\n  if {$rc==0 && $msg != \"1 2 3 4 5 6\" && $msg != \"1 2 3 4\"} {\n    error \"data mismatch 1: $msg\"\n  }\n  if {$testrc==0 && $msg != \"1 2 3 4 5 6\"} {\n    error \"data mismatch 2: $msg\"\n  }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test 2 -faults * -prep {\n  sqlite3 db \"\"\n  db eval {\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(b, a);\n    WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)\n    INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n  }\n} -body {\n  execsql { UPDATE t1 SET a = randomblob(99) }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check db\n}\n\ncatch { db close }\ndo_faultsim_test 2.1 -faults * -prep {\n  if {[info commands db]==\"\"} {\n    sqlite3 db \"\"\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA cache_size = 10;\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(b, a);\n      WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100)\n          INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n    }\n  } \n} -body {\n  execsql { UPDATE t1 SET a = randomblob(99) }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check db\n}\n\ndo_faultsim_test 3 -faults * -prep {\n  sqlite3 db \"\"\n  db eval {\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(b, a);\n    WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)\n    INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n  }\n} -body {\n  execsql { \n    BEGIN;\n      UPDATE t1 SET a = randomblob(99);\n      SAVEPOINT abc;\n        UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;\n      ROLLBACK TO abc;\n        UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;\n      ROLLBACK TO abc;\n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n  faultsim_integrity_check db\n}\n\ndo_faultsim_test 4 -faults * -prep {\n  sqlite3 db \"\"\n  db eval {\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(b, a);\n    WITH x(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<50)\n    INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n  }\n} -body {\n  execsql { \n    BEGIN;\n      UPDATE t1 SET a = randomblob(99);\n      SAVEPOINT abc;\n        UPDATE t1 SET a = randomblob(98) WHERE (rowid%10)==0;\n      ROLLBACK TO abc;\n        UPDATE t1 SET a = randomblob(97) WHERE (rowid%5)==0;\n      ROLLBACK TO abc;\n    COMMIT;\n  }\n} -test {\n  faultsim_test_result {0 {}}\n}\n\nsqlite3_memdebug_vfs_oom_test 1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/temptable.test",
    "content": "# 2001 October 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for temporary tables and indices.\n#\n# $Id: temptable.test,v 1.21 2009/06/16 17:49:36 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !tempdb {\n  finish_test\n  return\n}\n\n# Create an alternative connection to the database\n#\ndo_test temptable-1.0 {\n  sqlite3 db2 ./test.db\n  set dummy {}\n} {}\n\n# Create a permanent table.\n#\ndo_test temptable-1.1 {\n  execsql {CREATE TABLE t1(a,b,c);}\n  execsql {INSERT INTO t1 VALUES(1,2,3);}\n  execsql {SELECT * FROM t1}\n} {1 2 3}\ndo_test temptable-1.2 {\n  catch {db2 eval {SELECT * FROM sqlite_master}}\n  db2 eval {SELECT * FROM t1}\n} {1 2 3}\ndo_test temptable-1.3 {\n  execsql {SELECT name FROM sqlite_master}\n} {t1}\ndo_test temptable-1.4 {\n  db2 eval {SELECT name FROM sqlite_master}\n} {t1}\n\n# Create a temporary table.  Verify that only one of the two\n# processes can see it.\n#\ndo_test temptable-1.5 {\n  db2 eval {\n    CREATE TEMP TABLE t2(x,y,z);\n    INSERT INTO t2 VALUES(4,5,6);\n  }\n  db2 eval {SELECT * FROM t2}\n} {4 5 6}\ndo_test temptable-1.6 {\n  catch {execsql {SELECT * FROM sqlite_master}}\n  catchsql {SELECT * FROM t2}\n} {1 {no such table: t2}}\ndo_test temptable-1.7 {\n  catchsql {INSERT INTO t2 VALUES(8,9,0);}\n} {1 {no such table: t2}}\ndo_test temptable-1.8 {\n  db2 eval {INSERT INTO t2 VALUES(8,9,0);}\n  db2 eval {SELECT * FROM t2 ORDER BY x}\n} {4 5 6 8 9 0}\ndo_test temptable-1.9 {\n  db2 eval {DELETE FROM t2 WHERE x==8}\n  db2 eval {SELECT * FROM t2 ORDER BY x}\n} {4 5 6}\ndo_test temptable-1.10 {\n  db2 eval {DELETE FROM t2}\n  db2 eval {SELECT * FROM t2}\n} {}\ndo_test temptable-1.11 {\n  db2 eval {\n     INSERT INTO t2 VALUES(7,6,5);\n     INSERT INTO t2 VALUES(4,3,2);\n     SELECT * FROM t2 ORDER BY x;\n  }\n} {4 3 2 7 6 5}\ndo_test temptable-1.12 {\n  db2 eval {DROP TABLE t2;}\n  set r [catch {db2 eval {SELECT * FROM t2}} msg]\n  lappend r $msg\n} {1 {no such table: t2}}\n\n# Make sure temporary tables work with transactions\n#\ndo_test temptable-2.1 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TEMPORARY TABLE t2(x,y);\n    INSERT INTO t2 VALUES(1,2);\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test temptable-2.2 {\n  execsql {ROLLBACK}\n  catchsql {SELECT * FROM t2}\n} {1 {no such table: t2}}\ndo_test temptable-2.3 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TEMPORARY TABLE t2(x,y);\n    INSERT INTO t2 VALUES(1,2);\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test temptable-2.4 {\n  execsql {COMMIT}\n  catchsql {SELECT * FROM t2}\n} {0 {1 2}}\ndo_test temptable-2.5 {\n  set r [catch {db2 eval {SELECT * FROM t2}} msg]\n  lappend r $msg\n} {1 {no such table: t2}}\n\n# Make sure indices on temporary tables are also temporary.\n#\ndo_test temptable-3.1 {\n  execsql {\n    CREATE INDEX i2 ON t2(x);\n    SELECT name FROM sqlite_master WHERE type='index';\n  }\n} {}\ndo_test temptable-3.2 {\n  execsql {\n    SELECT y FROM t2 WHERE x=1;\n  }\n} {2}\ndo_test temptable-3.3 {\n  execsql {\n    DROP INDEX i2;\n    SELECT y FROM t2 WHERE x=1;\n  }\n} {2}\ndo_test temptable-3.4 {\n  execsql {\n    CREATE INDEX i2 ON t2(x);\n    DROP TABLE t2;\n  }\n  catchsql {DROP INDEX i2}\n} {1 {no such index: i2}}\n\n# Check for correct name collision processing. A name collision can\n# occur when process A creates a temporary table T then process B\n# creates a permanent table also named T.  The temp table in process A\n# hides the existence of the permanent table.\n#\ndo_test temptable-4.1 {\n  execsql {\n    CREATE TEMP TABLE t2(x,y);\n    INSERT INTO t2 VALUES(10,20);\n    SELECT * FROM t2;\n  } db2\n} {10 20}\ndo_test temptable-4.2 {\n  execsql {\n    CREATE TABLE t2(x,y,z);\n    INSERT INTO t2 VALUES(9,8,7);\n    SELECT * FROM t2;\n  }\n} {9 8 7}\ndo_test temptable-4.3 {\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {0 {10 20}}\ndo_test temptable-4.4.1 {\n  catchsql {\n    SELECT * FROM temp.t2;\n  } db2\n} {0 {10 20}}\ndo_test temptable-4.4.2 {\n  catchsql {\n    SELECT * FROM main.t2;\n  } db2\n} {0 {9 8 7}}\n#do_test temptable-4.4.3 {\n#  catchsql {\n#    SELECT name FROM main.sqlite_master WHERE type='table';\n#  } db2\n#} {1 {database schema has changed}}\ndo_test temptable-4.4.4 {\n  catchsql {\n    SELECT name FROM main.sqlite_master WHERE type='table';\n  } db2\n} {0 {t1 t2}}\ndo_test temptable-4.4.5 {\n  catchsql {\n    SELECT * FROM main.t2;\n  } db2\n} {0 {9 8 7}}\ndo_test temptable-4.4.6 {\n  # TEMP takes precedence over MAIN\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {0 {10 20}}\ndo_test temptable-4.5 {\n  catchsql {\n    DROP TABLE t2;     -- should drop TEMP\n    SELECT * FROM t2;  -- data should be from MAIN\n  } db2\n} {0 {9 8 7}}\ndo_test temptable-4.6 {\n  db2 close\n  sqlite3 db2 ./test.db\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {0 {9 8 7}}\ndo_test temptable-4.7 {\n  catchsql {\n    DROP TABLE t2;\n    SELECT * FROM t2;\n  }\n} {1 {no such table: t2}}\ndo_test temptable-4.8 {\n  db2 close\n  sqlite3 db2 ./test.db\n  execsql {\n    CREATE TEMP TABLE t2(x unique,y);\n    INSERT INTO t2 VALUES(1,2);\n    SELECT * FROM t2;\n  } db2\n} {1 2}\ndo_test temptable-4.9 {\n  execsql {\n    CREATE TABLE t2(x unique, y);\n    INSERT INTO t2 VALUES(3,4);\n    SELECT * FROM t2;\n  }\n} {3 4}\ndo_test temptable-4.10.1 {\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {0 {1 2}}\n# Update: The schema is reloaded in test temptable-4.10.1. And tclsqlite.c\n#         handles it and retries the query anyway.\n# do_test temptable-4.10.2 {\n#   catchsql {\n#     SELECT name FROM sqlite_master WHERE type='table'\n#   } db2\n# } {1 {database schema has changed}}\ndo_test temptable-4.10.3 {\n  catchsql {\n    SELECT name FROM sqlite_master WHERE type='table'\n  } db2\n} {0 {t1 t2}}\ndo_test temptable-4.11 {\n  execsql {\n    SELECT * FROM t2;\n  } db2\n} {1 2}\ndo_test temptable-4.12 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {3 4}\ndo_test temptable-4.13 {\n  catchsql {\n    DROP TABLE t2;     -- drops TEMP.T2\n    SELECT * FROM t2;  -- uses MAIN.T2\n  } db2\n} {0 {3 4}}\ndo_test temptable-4.14 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {3 4}\ndo_test temptable-4.15 {\n  db2 close\n  sqlite3 db2 ./test.db\n  execsql {\n    SELECT * FROM t2;\n  } db2\n} {3 4}\n\n# Now create a temporary table in db2 and a permanent index in db.  The\n# temporary table in db2 should mask the name of the permanent index,\n# but the permanent index should still be accessible and should still\n# be updated when its corresponding table changes.\n#\ndo_test temptable-5.1 {\n  execsql {\n    CREATE TEMP TABLE mask(a,b,c)\n  } db2\n  if {[permutation]==\"prepare\"} { db2 cache flush }\n  execsql {\n    CREATE INDEX mask ON t2(x);\n    SELECT * FROM t2;\n  }\n} {3 4}\n#do_test temptable-5.2 {\n#  catchsql {\n#    SELECT * FROM t2;\n#  } db2\n#} {1 {database schema has changed}}\ndo_test temptable-5.3 {\n  catchsql {\n    SELECT * FROM t2;\n  } db2\n} {0 {3 4}}\ndo_test temptable-5.4 {\n  execsql {\n    SELECT y FROM t2 WHERE x=3\n  }\n} {4}\ndo_test temptable-5.5 {\n  execsql {\n    SELECT y FROM t2 WHERE x=3\n  } db2\n} {4}\ndo_test temptable-5.6 {\n  execsql {\n    INSERT INTO t2 VALUES(1,2);\n    SELECT y FROM t2 WHERE x=1;\n  } db2\n} {2}\ndo_test temptable-5.7 {\n  execsql {\n    SELECT y FROM t2 WHERE x=3\n  } db2\n} {4}\ndo_test temptable-5.8 {\n  execsql {\n    SELECT y FROM t2 WHERE x=1;\n  }\n} {2}\ndo_test temptable-5.9 {\n  execsql {\n    SELECT y FROM t2 WHERE x=3\n  }\n} {4}\n\ndb2 close\n\n# Test for correct operation of read-only databases\n#\ndo_test temptable-6.1 {\n  execsql {\n    CREATE TABLE t8(x);\n    INSERT INTO t8 VALUES('xyzzy');\n    SELECT * FROM t8;\n  }\n} {xyzzy}\ndo_test temptable-6.2 {\n  db close\n  catch {file attributes test.db -permissions 0444}\n  catch {file attributes test.db -readonly 1}\n  sqlite3 db test.db\n  if {[file writable test.db]} {\n    error \"Unable to make the database file test.db readonly - rerun this test as an unprivileged user\"\n  }\n  execsql {\n    SELECT * FROM t8;\n  }\n} {xyzzy}\ndo_test temptable-6.3 {\n  if {[file writable test.db]} {\n    error \"Unable to make the database file test.db readonly - rerun this test as an unprivileged user\"\n  }\n  catchsql {\n    CREATE TABLE t9(x,y);\n  }\n} {1 {attempt to write a readonly database}}\ndo_test temptable-6.4 {\n  catchsql {\n    CREATE TEMP TABLE t9(x,y);\n  }\n} {0 {}}\ndo_test temptable-6.5 {\n  catchsql {\n    INSERT INTO t9 VALUES(1,2);\n    SELECT * FROM t9;\n  }\n} {0 {1 2}}\ndo_test temptable-6.6 {\n  if {[file writable test.db]} {\n    error \"Unable to make the database file test.db readonly - rerun this test as an unprivileged user\"\n  }\n  catchsql {\n    INSERT INTO t8 VALUES('hello');\n    SELECT * FROM t8;\n  }\n} {1 {attempt to write a readonly database}}\ndo_test temptable-6.7 {\n  catchsql {\n    SELECT * FROM t8,t9;\n  }\n} {0 {xyzzy 1 2}}\ndo_test temptable-6.8 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM t8,t9;\n  }\n} {1 {no such table: t9}}\n\nforcedelete test2.db test2.db-journal\nifcapable attach {\n  do_test temptable-7.1 {\n    catchsql {\n      ATTACH 'test2.db' AS two;\n      CREATE TEMP TABLE two.abc(x,y);\n    }\n  } {1 {temporary table name must be unqualified}}\n}\n\n# Need to do the following for tcl 8.5 on mac. On that configuration, the\n# -readonly flag is taken so seriously that a subsequent [forcedelete]\n# (required before the next test file can be executed) will fail.\n#\ncatch {file attributes test.db -readonly 0}\n\ndo_test temptable-8.0 {\n  db close\n  catch {forcedelete test.db}\n  sqlite3 db test.db\n} {}\ndo_test temptable-8.1 {\n  execsql { CREATE TEMP TABLE tbl2(a, b); }\n  execsql {\n    CREATE TABLE tbl(a, b);\n    INSERT INTO tbl VALUES(1, 2);\n  }\n  execsql {SELECT * FROM tbl}\n} {1 2}\ndo_test temptable-8.2 {\n  execsql { CREATE TEMP TABLE tbl(a, b); }\n  execsql {SELECT * FROM tbl}\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/temptable2.test",
    "content": "# 2016 March 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix temptable2\n\ndo_execsql_test 1.1 {\n  CREATE TEMP TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n}\n\ndo_execsql_test 1.2 {\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100000 )\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM X;\n} {}\n\ndo_execsql_test 1.3 {\n  PRAGMA temp.integrity_check;\n} {ok}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TEMP TABLE t2(a, b);\n  INSERT INTO t2 VALUES(1, 2);\n} {}\n\ndo_execsql_test 2.2 {\n  BEGIN;\n    INSERT INTO t2 VALUES(3, 4);\n    SELECT * FROM t2;\n} {1 2 3 4}\n\ndo_execsql_test 2.3 {\n  ROLLBACK;\n  SELECT * FROM t2;\n} {1 2}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 3.1.1 {\n  PRAGMA main.cache_size = 10;\n  PRAGMA temp.cache_size = 10;\n\n  CREATE TEMP TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 )\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n\n  SELECT count(*) FROM t1;\n} {1000}\ndo_execsql_test 3.1.2 {\n  BEGIN;\n    UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==0;\n  ROLLBACK;\n}\ndo_execsql_test 3.1.3 {\n  SELECT count(*) FROM t1;\n} {1000}\ndo_execsql_test 3.1.4 { PRAGMA temp.integrity_check } {ok}\n\ndo_execsql_test 3.2.1 {\n  BEGIN;\n    UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==0;\n    SAVEPOINT abc;\n      UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==1;\n    ROLLBACK TO abc;\n    UPDATE t1 SET b=randomblob(100) WHERE (rowid%10)==2;\n  COMMIT;\n}\ndo_execsql_test 3.2.2 { PRAGMA temp.integrity_check } {ok}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 4.1.1 {\n  PRAGMA main.cache_size = 10;\n  PRAGMA temp.cache_size = 10;\n\n  CREATE TEMP TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<10 )\n  INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n\n  SELECT count(*) FROM t1;\n  PRAGMA temp.page_count;\n} {10 9}\n\ndo_execsql_test 4.1.2 {\n  BEGIN;\n    UPDATE t1 SET b=randomblob(100);\n  ROLLBACK;\n}\n\ndo_execsql_test 4.1.3 {\n  CREATE TEMP TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;\n\n  SELECT count(*) FROM t2;\n  SELECT count(*) FROM t1;\n} {500 10}\n\ndo_test 4.1.4 {\n  set n [db one { PRAGMA temp.page_count }]\n  expr ($n >280 && $n < 300) \n} 1\n\ndo_execsql_test 4.1.4 { PRAGMA temp.integrity_check } {ok}\n\n#-------------------------------------------------------------------------\n#\nreset_db\ndo_execsql_test 5.1.1 {\n  PRAGMA main.cache_size = 10;\n  PRAGMA temp.cache_size = 10;\n\n  CREATE TEMP TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;\n\n  CREATE TEMP TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES(1, 2);\n}\n\n# Test that the temp database is now much bigger than the configured\n# cache size (10 pages).\ndo_test 5.1.2 {\n  set n [db one { PRAGMA temp.page_count }]\n  expr ($n > 270 && $n < 290)\n} {1}\n\ndo_execsql_test 5.1.3 {\n  BEGIN;\n    UPDATE t1 SET a=2;\n    UPDATE t2 SET a=randomblob(100);\n    SELECT count(*) FROM t1;\n  ROLLBACK;\n} {1}\n\ndo_execsql_test 5.1.4 {\n  UPDATE t2 SET a=randomblob(100);\n\n  SELECT * FROM t1;\n} {1 2}\n\ndo_execsql_test 5.1.5 { PRAGMA temp.integrity_check } {ok}\n\n#-------------------------------------------------------------------------\n# Test this:\n#\n#   1. Page is DIRTY at the start of a transaction.\n#   2. Page is written out as part of the transaction.\n#   3. Page is then read back in.\n#   4. Transaction is rolled back. Is the page now clean or dirty?\n#\n# This actually does work. Step 4 marks the page as clean. But it also\n# writes to the database file itself. So marking it clean is correct - \n# the page does match the contents of the db file.\n#\nreset_db\n\ndo_execsql_test 6.1 {\n  PRAGMA main.cache_size = 10;\n  PRAGMA temp.cache_size = 10;\n\n  CREATE TEMP TABLE t1(x);\n  INSERT INTO t1 VALUES('one');\n\n  CREATE TEMP TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x;\n}\n\ndo_execsql_test 6.2 {\n  UPDATE t1 SET x='two';             -- step 1\n  BEGIN;\n    UPDATE t2 SET a=randomblob(100); -- step 2\n    SELECT * FROM t1;                -- step 3\n  ROLLBACK;                          -- step 4\n\n  SELECT count(*) FROM t2;\n  SELECT * FROM t1;\n} {two 500 two}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nsqlite3 db \"\"\ndo_execsql_test 7.1 {\n  PRAGMA auto_vacuum=INCREMENTAL;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(zeroblob(900));\n  INSERT INTO t1 VALUES(zeroblob(900));\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  INSERT INTO t1 SELECT x FROM t1;\n  BEGIN;\n  DELETE FROM t1 WHERE rowid%2;\n  PRAGMA incremental_vacuum(4);\n  ROLLBACK;\n  PRAGMA integrity_check;\n} {ok}\n\n#-------------------------------------------------------------------------\n# Try changing the page size using a backup operation when pages are\n# stored in main-memory only.\n#\nreset_db\ndo_execsql_test 8.1 {\n  PRAGMA auto_vacuum = OFF;\n  CREATE TABLE t2(a, b);\n  CREATE INDEX i2 ON t2(a, b);\n  WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<20 )\n  INSERT INTO t2 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2;\n  PRAGMA page_count;\n} {13}\n\ndo_test 8.2 {\n  sqlite3 tmp \"\"\n  execsql {\n    PRAGMA auto_vacuum = OFF;\n    PRAGMA page_size = 8192;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<100 )\n    INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x ORDER BY 1, 2;\n    PRAGMA page_count;\n  } tmp\n} {10}\n\ndo_test 8.3 {\n  sqlite3_backup B tmp main db main\n  B step 5\n  B finish\n} {SQLITE_READONLY}\n\ndo_test 8.4 {\n  execsql {\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n    PRAGMA page_size;\n  } tmp\n} {100 ok 8192}\n\ndo_test 8.5 { \n  tmp eval { UPDATE t1 SET a=randomblob(100) }\n} {}\n\ndo_test 8.6 {\n  sqlite3_backup B tmp main db main\n  B step 1000\n  B finish\n} {SQLITE_READONLY}\n\ntmp close\n\n#-------------------------------------------------------------------------\n# Try inserts and deletes with a large db in auto-vacuum mode. Check\n#\nforeach {tn mode} {\n  1 delete\n  2 wal\n} {\n  reset_db\n  sqlite3 db \"\"\n  do_execsql_test 9.$tn.1.1 {\n    PRAGMA cache_size = 15;\n    PRAGMA auto_vacuum = 1;\n  }\n  execsql \"PRAGMA journal_mode = $mode\"\n\n  do_execsql_test 9.$tn.1.2 {\n    CREATE TABLE tx(a, b);\n    CREATE INDEX i1 ON tx(a);\n    CREATE INDEX i2 ON tx(b);\n    WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<1000 )\n      INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;\n  }\n\n  for {set i 2} {$i<20} {incr i} {\n    do_execsql_test 9.$tn.$i.1 { DELETE FROM tx WHERE (random()%3)==0 }\n\n    do_execsql_test 9.$tn.$i.2 { PRAGMA integrity_check } ok\n\n      do_execsql_test 9.$tn.$i.3 { \n        WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<400 )\n          INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;\n      }\n\n    do_execsql_test 9.$tn.$i.4 { PRAGMA integrity_check } ok\n\n    do_execsql_test 9.$tn.$i.5 { \n      BEGIN;\n      DELETE FROM tx WHERE (random()%3)==0;\n      WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )\n        INSERT INTO tx SELECT randomblob(100), randomblob(100) FROM x;\n      COMMIT;\n    }\n\n    do_execsql_test 9.$tn.$i.6 { PRAGMA integrity_check } ok\n  }\n}\n\n#-------------------------------------------------------------------------\n# When using mmap mode with a temp file, SQLite must search the cache \n# before using a mapped page even when there is no write transaction\n# open. For a temp file, the on-disk version may not be up to date.\n#\nsqlite3 db \"\"\ndo_execsql_test 10.0 {\n  PRAGMA cache_size = 50;\n  PRAGMA page_size = 1024;\n  CREATE TABLE t1(a, b, PRIMARY KEY(a)) WITHOUT ROWID;\n  CREATE INDEX i1 ON t1(a);\n  CREATE TABLE t2(x, y);\n  INSERT INTO t2 VALUES(1, 2);\n}\n\ndo_execsql_test 10.1 {\n  BEGIN;\n    WITH x(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM x WHERE i<500 )\n      INSERT INTO t1 SELECT randomblob(100), randomblob(100) FROM x;\n  COMMIT;\n  INSERT INTO t2 VALUES(3, 4);\n}\n\nifcapable mmap {\n  if {[permutation]!=\"journaltest\"} {\n    # The journaltest permutation does not support mmap, so this part of\n    # the test is omitted.\n    do_execsql_test 10.2 { PRAGMA mmap_size = 512000 } 512000\n  }\n}\n\ndo_execsql_test 10.3 { SELECT * FROM t2 } {1 2 3 4}\ndo_execsql_test 10.4 { PRAGMA integrity_check } ok\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/temptable3.test",
    "content": "# 2016-05-10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix temptable3\n\ndb close\nsqlite3 db {}\ndo_execsql_test 1.1 {\n  PRAGMA cache_size = 1;\n  PRAGMA page_size = 1024;\n  PRAGMA auto_vacuum = 2;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES( randomblob(800) );\n  INSERT INTO t1 VALUES( randomblob(800) );\n  CREATE TABLE t2(x);\n  PRAGMA integrity_check;\n} {ok}\n\ndb close\nsqlite3 db {}\ndo_execsql_test 1.2 {\n  PRAGMA cache_size = 1;\n  PRAGMA auto_vacuum = 2;\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(x UNIQUE);\n  INSERT INTO t2 VALUES(1), (2), (3);\n  DROP TABLE t1;\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/temptrigger.test",
    "content": "# 2009 February 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: temptrigger.test,v 1.3 2009/04/15 13:07:19 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix temptrigger\n\nifcapable {!trigger || !shared_cache} { finish_test ; return }\n\n# Test cases:\n#\n#   temptrigger-1.*: Shared cache problem.\n#   temptrigger-2.*: A similar shared cache problem.\n#   temptrigger-3.*: Attached database problem.\n#\n\n#-------------------------------------------------------------------------\n# Test case temptrigger-1.* demonstrates a problem with temp triggers\n# in shared-cache mode. If process 1 connections to a shared-cache and\n# creates a temp trigger, the temp trigger is linked into the shared-cache\n# schema. If process 2 reloads the shared-cache schema from disk, then\n# it does not recreate the temp trigger belonging to process 1. From the\n# point of view of process 1, the temp trigger just disappeared.\n# \n#   temptrigger-1.1: In shared cache mode, create a table in the main \n#                    database and add a temp trigger to it.\n#\n#   temptrigger-1.2: Check that the temp trigger is correctly fired. Check\n#                    that the temp trigger is not fired by statements\n#                    executed by a second connection connected to the \n#                    same shared cache.\n#\n#   temptrigger-1.3: Using the second connection to the shared-cache, cause\n#                    the shared-cache schema to be reloaded.\n#\n#   temptrigger-1.4: Check that the temp trigger is still fired correctly.\n#\n#   temptrigger-1.5: Check that the temp trigger can be dropped without error.\n#\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache]\nsqlite3_enable_shared_cache 1\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test temptrigger-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TEMP TABLE tt1(a, b);\n    CREATE TEMP TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n      INSERT INTO tt1 VALUES(new.a, new.b);\n    END;\n  }\n} {}\n\ndo_test temptrigger-1.2.1 {\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test temptrigger-1.2.2 {\n  execsql { SELECT * FROM tt1 }\n} {1 2}\ndo_test temptrigger-1.2.3 {\n  execsql { INSERT INTO t1 VALUES(3, 4) } db2\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test temptrigger-1.2.4 {\n  execsql { SELECT * FROM tt1 }\n} {1 2}\n\n# Cause the shared-cache schema to be reloaded.\n#\ndo_test temptrigger-1.3 {\n  execsql { BEGIN; CREATE TABLE t3(a, b); ROLLBACK; } db2\n} {}\n\ndo_test temptrigger-1.4 {\n  execsql { INSERT INTO t1 VALUES(5, 6) }\n  execsql { SELECT * FROM tt1 }\n} {1 2 5 6}\n\ndo_test temptrigger-1.5 {\n  # Before the bug was fixed, the following 'DROP TRIGGER' hit an \n  # assert if executed.\n  #execsql { DROP TRIGGER tr1 }\n} {}\n\ncatch {db close}\ncatch {db2 close}\n\n#-------------------------------------------------------------------------\n# Tests temptrigger-2.* are similar to temptrigger-1.*, except that\n# temptrigger-2.3 simply opens and closes a connection to the shared-cache.\n# It does not do anything special to cause the schema to be reloaded.\n# \ndo_test temptrigger-2.1 {\n  sqlite3 db test.db\n  execsql {\n    DELETE FROM t1;\n    CREATE TEMP TABLE tt1(a, b);\n    CREATE TEMP TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n      INSERT INTO tt1 VALUES(new.a, new.b);\n    END;\n  }\n} {}\ndo_test temptrigger-2.2 {\n  execsql {\n    INSERT INTO t1 VALUES(10, 20);\n    SELECT * FROM tt1;\n  }\n} {10 20}\ndo_test temptrigger-2.3 {\n  sqlite3 db2 test.db\n  db2 close\n} {}\ndo_test temptrigger-2.4 {\n  execsql {\n    INSERT INTO t1 VALUES(30, 40);\n    SELECT * FROM tt1;\n  }\n} {10 20 30 40}\ndo_test temptrigger-2.5 {\n  #execsql { DROP TRIGGER tr1 }\n} {}\n\ncatch {db close}\ncatch {db2 close}\nsqlite3_enable_shared_cache $::enable_shared_cache\n\n#-------------------------------------------------------------------------\n# Test case temptrigger-3.* demonstrates a problem with temp triggers\n# on tables located in attached databases. At one point when SQLite reloaded \n# the schema of an attached database (because some other connection had \n# changed the schema cookie) it was not re-creating temp triggers attached \n# to tables located within the attached database.\n# \n#   temptrigger-3.1: Attach database 'test2.db' to connection [db]. Add a\n#                    temp trigger to a table in 'test2.db'.\n#\n#   temptrigger-3.2: Check that the temp trigger is correctly fired.\n#\n#   temptrigger-3.3: Update the schema of 'test2.db' using an external\n#                    connection. This forces [db] to reload the 'test2.db'\n#                    schema. Check that the temp trigger is still fired\n#                    correctly.\n#\n#   temptrigger-3.4: Check that the temp trigger can be dropped without error.\n# \ndo_test temptrigger-3.1 {\n  catch { forcedelete test2.db test2.db-journal }\n  catch { forcedelete test.db test.db-journal }\n  sqlite3 db test.db \n  sqlite3 db2 test2.db \n  execsql { CREATE TABLE t2(a, b) } db2\n  execsql {\n    ATTACH 'test2.db' AS aux;\n    CREATE TEMP TABLE tt2(a, b);\n    CREATE TEMP TRIGGER tr2 AFTER INSERT ON aux.t2 BEGIN\n      INSERT INTO tt2 VALUES(new.a, new.b);\n    END;\n  }\n} {}\n\ndo_test temptrigger-3.2.1 {\n  execsql { \n    INSERT INTO aux.t2 VALUES(1, 2);\n    SELECT * FROM aux.t2;\n  }\n} {1 2}\ndo_test temptrigger-3.2.2 {\n  execsql { SELECT * FROM tt2 }\n} {1 2}\n\ndo_test temptrigger-3.3.1 {\n  execsql { CREATE TABLE t3(a, b) } db2\n  execsql { \n    INSERT INTO aux.t2 VALUES(3, 4);\n    SELECT * FROM aux.t2;\n  }\n} {1 2 3 4}\ndo_test temptrigger-3.3.2 {\n  execsql { SELECT * FROM tt2 }\n} {1 2 3 4}\n\ndo_test temptrigger-3.4 {\n  # Before the bug was fixed, the following 'DROP TRIGGER' hit an \n  # assert if executed.\n  #execsql { DROP TRIGGER tr2 }\n} {}\n\ncatch { db close }\ncatch { db2 close }\n\n\n#-------------------------------------------------------------------------\n# Test that creating a temp table after a temp trigger on the same name\n# has been created is an error.\n#\nreset_db\ndo_execsql_test 4.0 {\n  CREATE TABLE t1(x);\n  CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN\n    SELECT 1,2,3;\n  END;\n}\n\ndo_execsql_test 4.1 {\n  CREATE TEMP TABLE t1(x);\n}\n\n#-------------------------------------------------------------------------\n# Test that no harm is done if the table a temp trigger is attached to is\n# deleted by an external connection.\n#\nreset_db\ndo_execsql_test 5.0 {\n  CREATE TABLE t1(x);\n  CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END;\n}\n\ndo_test 5.1 {\n  sqlite3 db2 test.db\n  execsql { DROP TABLE t1 } db2\n} {}\n\ndo_execsql_test 5.2 {\n  SELECT * FROM sqlite_master;\n  SELECT * FROM temp.sqlite_master;\n} {\n  trigger tr1 t1 0 \n  {CREATE TRIGGER tr1 BEFORE INSERT ON t1 BEGIN SELECT 1,2,3; END}\n}\ndb2 close\n\n#-------------------------------------------------------------------------\n# Check that if a second connection creates a table in an attached database\n# with the same name as a table in the main database that has a temp\n# trigger attached to it nothing goes awry.\n#\nreset_db\nforcedelete test.db2\n\ndo_execsql_test 6.0 {\n  CREATE TABLE t1(x);\n  CREATE TEMP TRIGGER tr1 BEFORE INSERT ON t1 BEGIN \n    SELECT raise(ABORT, 'error'); \n  END;\n  ATTACH 'test.db2' AS aux;\n}\n\ndo_test 6.1 {\n  sqlite3 db2 test.db2\n  execsql { CREATE TABLE t1(a, b, c); } db2\n} {}\n\ndo_execsql_test 6.2 {\n  SELECT type,name,tbl_name,sql FROM aux.sqlite_master;\n  INSERT INTO aux.t1 VALUES(1,2,3);\n} {\n  table t1 t1 {CREATE TABLE t1(a, b, c)}\n}\n\ndo_catchsql_test 6.3 {\n  INSERT INTO main.t1 VALUES(1);\n} {1 error}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tester.tcl",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements some common TCL routines used for regression\n# testing the SQLite library\n#\n# $Id: tester.tcl,v 1.143 2009/04/09 01:23:49 drh Exp $\n\n#-------------------------------------------------------------------------\n# The commands provided by the code in this file to help with creating\n# test cases are as follows:\n#\n# Commands to manipulate the db and the file-system at a high level:\n#\n#      is_relative_file\n#      test_pwd\n#      get_pwd\n#      copy_file              FROM TO\n#      delete_file            FILENAME\n#      drop_all_tables        ?DB?\n#      drop_all_indexes       ?DB?\n#      forcecopy              FROM TO\n#      forcedelete            FILENAME\n#\n# Test the capability of the SQLite version built into the interpreter to\n# determine if a specific test can be run:\n#\n#      capable                EXPR\n#      ifcapable              EXPR\n#\n# Calulate checksums based on database contents:\n#\n#      dbcksum                DB DBNAME\n#      allcksum               ?DB?\n#      cksum                  ?DB?\n#\n# Commands to execute/explain SQL statements:\n#\n#      memdbsql               SQL\n#      stepsql                DB SQL\n#      execsql2               SQL\n#      explain_no_trace       SQL\n#      explain                SQL ?DB?\n#      catchsql               SQL ?DB?\n#      execsql                SQL ?DB?\n#\n# Commands to run test cases:\n#\n#      do_ioerr_test          TESTNAME ARGS...\n#      crashsql               ARGS...\n#      integrity_check        TESTNAME ?DB?\n#      verify_ex_errcode      TESTNAME EXPECTED ?DB?\n#      do_test                TESTNAME SCRIPT EXPECTED\n#      do_execsql_test        TESTNAME SQL EXPECTED\n#      do_catchsql_test       TESTNAME SQL EXPECTED\n#      do_timed_execsql_test  TESTNAME SQL EXPECTED\n#\n# Commands providing a lower level interface to the global test counters:\n#\n#      set_test_counter       COUNTER ?VALUE?\n#      omit_test              TESTNAME REASON ?APPEND?\n#      fail_test              TESTNAME\n#      incr_ntest\n#\n# Command run at the end of each test file:\n#\n#      finish_test\n#\n# Commands to help create test files that run with the \"WAL\" and other\n# permutations (see file permutations.test):\n#\n#      wal_is_wal_mode\n#      wal_set_journal_mode   ?DB?\n#      wal_check_journal_mode TESTNAME?DB?\n#      permutation\n#      presql\n#\n# Command to test whether or not --verbose=1 was specified on the command\n# line (returns 0 for not-verbose, 1 for verbose and 2 for \"verbose in the\n# output file only\").\n#\n#      verbose\n#\n\n# Set the precision of FP arithmatic used by the interpreter. And\n# configure SQLite to take database file locks on the page that begins\n# 64KB into the database file instead of the one 1GB in. This means\n# the code that handles that special case can be tested without creating\n# very large database files.\n#\nset tcl_precision 15\nsqlite3_test_control_pending_byte 0x0010000\n\n\n# If the pager codec is available, create a wrapper for the [sqlite3]\n# command that appends \"-key {xyzzy}\" to the command line. i.e. this:\n#\n#     sqlite3 db test.db\n#\n# becomes\n#\n#     sqlite3 db test.db -key {xyzzy}\n#\nif {[info command sqlite_orig]==\"\"} {\n  rename sqlite3 sqlite_orig\n  proc sqlite3 {args} {\n    if {[llength $args]>=2 && [string index [lindex $args 0] 0]!=\"-\"} {\n      # This command is opening a new database connection.\n      #\n      if {[info exists ::G(perm:sqlite3_args)]} {\n        set args [concat $args $::G(perm:sqlite3_args)]\n      }\n      if {[sqlite_orig -has-codec] && ![info exists ::do_not_use_codec]} {\n        lappend args -key {xyzzy}\n      }\n\n      set res [uplevel 1 sqlite_orig $args]\n      if {[info exists ::G(perm:presql)]} {\n        [lindex $args 0] eval $::G(perm:presql)\n      }\n      if {[info exists ::G(perm:dbconfig)]} {\n        set ::dbhandle [lindex $args 0]\n        uplevel #0 $::G(perm:dbconfig)\n      }\n      set res\n    } else {\n      # This command is not opening a new database connection. Pass the\n      # arguments through to the C implementation as the are.\n      #\n      uplevel 1 sqlite_orig $args\n    }\n  }\n}\n\nproc getFileRetries {} {\n  if {![info exists ::G(file-retries)]} {\n    #\n    # NOTE: Return the default number of retries for [file] operations.  A\n    #       value of zero or less here means \"disabled\".\n    #\n    return [expr {$::tcl_platform(platform) eq \"windows\" ? 50 : 0}]\n  }\n  return $::G(file-retries)\n}\n\nproc getFileRetryDelay {} {\n  if {![info exists ::G(file-retry-delay)]} {\n    #\n    # NOTE: Return the default number of milliseconds to wait when retrying\n    #       failed [file] operations.  A value of zero or less means \"do not\n    #       wait\".\n    #\n    return 100; # TODO: Good default?\n  }\n  return $::G(file-retry-delay)\n}\n\n# Return the string representing the name of the current directory.  On\n# Windows, the result is \"normalized\" to whatever our parent command shell\n# is using to prevent case-mismatch issues.\n#\nproc get_pwd {} {\n  if {$::tcl_platform(platform) eq \"windows\"} {\n    #\n    # NOTE: Cannot use [file normalize] here because it would alter the\n    #       case of the result to what Tcl considers canonical, which would\n    #       defeat the purpose of this procedure.\n    #\n    return [string map [list \\\\ /] \\\n        [string trim [exec -- $::env(ComSpec) /c echo %CD%]]]\n  } else {\n    return [pwd]\n  }\n}\n\n# Copy file $from into $to. This is used because some versions of\n# TCL for windows (notably the 8.4.1 binary package shipped with the\n# current mingw release) have a broken \"file copy\" command.\n#\nproc copy_file {from to} {\n  do_copy_file false $from $to\n}\n\nproc forcecopy {from to} {\n  do_copy_file true $from $to\n}\n\nproc do_copy_file {force from to} {\n  set nRetry [getFileRetries]     ;# Maximum number of retries.\n  set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.\n\n  # On windows, sometimes even a [file copy -force] can fail. The cause is\n  # usually \"tag-alongs\" - programs like anti-virus software, automatic backup\n  # tools and various explorer extensions that keep a file open a little longer\n  # than we expect, causing the delete to fail.\n  #\n  # The solution is to wait a short amount of time before retrying the copy.\n  #\n  if {$nRetry > 0} {\n    for {set i 0} {$i<$nRetry} {incr i} {\n      set rc [catch {\n        if {$force} {\n          file copy -force $from $to\n        } else {\n          file copy $from $to\n        }\n      } msg]\n      if {$rc==0} break\n      if {$nDelay > 0} { after $nDelay }\n    }\n    if {$rc} { error $msg }\n  } else {\n    if {$force} {\n      file copy -force $from $to\n    } else {\n      file copy $from $to\n    }\n  }\n}\n\n# Check if a file name is relative\n#\nproc is_relative_file { file } {\n  return [expr {[file pathtype $file] != \"absolute\"}]\n}\n\n# If the VFS supports using the current directory, returns [pwd];\n# otherwise, it returns only the provided suffix string (which is\n# empty by default).\n#\nproc test_pwd { args } {\n  if {[llength $args] > 0} {\n    set suffix1 [lindex $args 0]\n    if {[llength $args] > 1} {\n      set suffix2 [lindex $args 1]\n    } else {\n      set suffix2 $suffix1\n    }\n  } else {\n    set suffix1 \"\"; set suffix2 \"\"\n  }\n  ifcapable curdir {\n    return \"[get_pwd]$suffix1\"\n  } else {\n    return $suffix2\n  }\n}\n\n# Delete a file or directory\n#\nproc delete_file {args} {\n  do_delete_file false {*}$args\n}\n\nproc forcedelete {args} {\n  do_delete_file true {*}$args\n}\n\nproc do_delete_file {force args} {\n  set nRetry [getFileRetries]     ;# Maximum number of retries.\n  set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.\n\n  foreach filename $args {\n    # On windows, sometimes even a [file delete -force] can fail just after\n    # a file is closed. The cause is usually \"tag-alongs\" - programs like\n    # anti-virus software, automatic backup tools and various explorer\n    # extensions that keep a file open a little longer than we expect, causing\n    # the delete to fail.\n    #\n    # The solution is to wait a short amount of time before retrying the\n    # delete.\n    #\n    if {$nRetry > 0} {\n      for {set i 0} {$i<$nRetry} {incr i} {\n        set rc [catch {\n          if {$force} {\n            file delete -force $filename\n          } else {\n            file delete $filename\n          }\n        } msg]\n        if {$rc==0} break\n        if {$nDelay > 0} { after $nDelay }\n      }\n      if {$rc} { error $msg }\n    } else {\n      if {$force} {\n        file delete -force $filename\n      } else {\n        file delete $filename\n      }\n    }\n  }\n}\n\nif {$::tcl_platform(platform) eq \"windows\"} {\n  proc do_remove_win32_dir {args} {\n    set nRetry [getFileRetries]     ;# Maximum number of retries.\n    set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.\n\n    foreach dirName $args {\n      # On windows, sometimes even a [remove_win32_dir] can fail just after\n      # a directory is emptied. The cause is usually \"tag-alongs\" - programs\n      # like anti-virus software, automatic backup tools and various explorer\n      # extensions that keep a file open a little longer than we expect,\n      # causing the delete to fail.\n      #\n      # The solution is to wait a short amount of time before retrying the\n      # removal.\n      #\n      if {$nRetry > 0} {\n        for {set i 0} {$i < $nRetry} {incr i} {\n          set rc [catch {\n            remove_win32_dir $dirName\n          } msg]\n          if {$rc == 0} break\n          if {$nDelay > 0} { after $nDelay }\n        }\n        if {$rc} { error $msg }\n      } else {\n        remove_win32_dir $dirName\n      }\n    }\n  }\n\n  proc do_delete_win32_file {args} {\n    set nRetry [getFileRetries]     ;# Maximum number of retries.\n    set nDelay [getFileRetryDelay]  ;# Delay in ms before retrying.\n\n    foreach fileName $args {\n      # On windows, sometimes even a [delete_win32_file] can fail just after\n      # a file is closed. The cause is usually \"tag-alongs\" - programs like\n      # anti-virus software, automatic backup tools and various explorer\n      # extensions that keep a file open a little longer than we expect,\n      # causing the delete to fail.\n      #\n      # The solution is to wait a short amount of time before retrying the\n      # delete.\n      #\n      if {$nRetry > 0} {\n        for {set i 0} {$i < $nRetry} {incr i} {\n          set rc [catch {\n            delete_win32_file $fileName\n          } msg]\n          if {$rc == 0} break\n          if {$nDelay > 0} { after $nDelay }\n        }\n        if {$rc} { error $msg }\n      } else {\n        delete_win32_file $fileName\n      }\n    }\n  }\n}\n\nproc execpresql {handle args} {\n  trace remove execution $handle enter [list execpresql $handle]\n  if {[info exists ::G(perm:presql)]} {\n    $handle eval $::G(perm:presql)\n  }\n}\n\n# This command should be called after loading tester.tcl from within\n# all test scripts that are incompatible with encryption codecs.\n#\nproc do_not_use_codec {} {\n  set ::do_not_use_codec 1\n  reset_db\n}\nunset -nocomplain do_not_use_codec\n\n# Return true if the \"reserved_bytes\" integer on database files is non-zero.\n#\nproc nonzero_reserved_bytes {} {\n  return [sqlite3 -has-codec]\n}\n\n# Print a HELP message and exit\n#\nproc print_help_and_quit {} {\n  puts {Options:\n  --pause                  Wait for user input before continuing\n  --soft-heap-limit=N      Set the soft-heap-limit to N\n  --maxerror=N             Quit after N errors\n  --verbose=(0|1)          Control the amount of output.  Default '1'\n  --output=FILE            set --verbose=2 and output to FILE.  Implies -q\n  -q                       Shorthand for --verbose=0\n  --help                   This message\n}\n  exit 1\n}\n\n# The following block only runs the first time this file is sourced. It\n# does not run in slave interpreters (since the ::cmdlinearg array is\n# populated before the test script is run in slave interpreters).\n#\nif {[info exists cmdlinearg]==0} {\n\n  # Parse any options specified in the $argv array. This script accepts the\n  # following options:\n  #\n  #   --pause\n  #   --soft-heap-limit=NN\n  #   --maxerror=NN\n  #   --malloctrace=N\n  #   --backtrace=N\n  #   --binarylog=N\n  #   --soak=N\n  #   --file-retries=N\n  #   --file-retry-delay=N\n  #   --start=[$permutation:]$testfile\n  #   --match=$pattern\n  #   --verbose=$val\n  #   --output=$filename\n  #   -q                                      Reduce output\n  #   --testdir=$dir                          Run tests in subdirectory $dir\n  #   --help\n  #\n  set cmdlinearg(soft-heap-limit)    0\n  set cmdlinearg(maxerror)        1000\n  set cmdlinearg(malloctrace)        0\n  set cmdlinearg(backtrace)         10\n  set cmdlinearg(binarylog)          0\n  set cmdlinearg(soak)               0\n  set cmdlinearg(file-retries)       0\n  set cmdlinearg(file-retry-delay)   0\n  set cmdlinearg(start)             \"\"\n  set cmdlinearg(match)             \"\"\n  set cmdlinearg(verbose)           \"\"\n  set cmdlinearg(output)            \"\"\n  set cmdlinearg(testdir)           \"testdir\"\n\n  set leftover [list]\n  foreach a $argv {\n    switch -regexp -- $a {\n      {^-+pause$} {\n        # Wait for user input before continuing. This is to give the user an\n        # opportunity to connect profiling tools to the process.\n        puts -nonewline \"Press RETURN to begin...\"\n        flush stdout\n        gets stdin\n      }\n      {^-+soft-heap-limit=.+$} {\n        foreach {dummy cmdlinearg(soft-heap-limit)} [split $a =] break\n      }\n      {^-+maxerror=.+$} {\n        foreach {dummy cmdlinearg(maxerror)} [split $a =] break\n      }\n      {^-+malloctrace=.+$} {\n        foreach {dummy cmdlinearg(malloctrace)} [split $a =] break\n        if {$cmdlinearg(malloctrace)} {\n          sqlite3_memdebug_log start\n        }\n      }\n      {^-+backtrace=.+$} {\n        foreach {dummy cmdlinearg(backtrace)} [split $a =] break\n        sqlite3_memdebug_backtrace $cmdlinearg(backtrace)\n      }\n      {^-+binarylog=.+$} {\n        foreach {dummy cmdlinearg(binarylog)} [split $a =] break\n        set cmdlinearg(binarylog) [file normalize $cmdlinearg(binarylog)]\n      }\n      {^-+soak=.+$} {\n        foreach {dummy cmdlinearg(soak)} [split $a =] break\n        set ::G(issoak) $cmdlinearg(soak)\n      }\n      {^-+file-retries=.+$} {\n        foreach {dummy cmdlinearg(file-retries)} [split $a =] break\n        set ::G(file-retries) $cmdlinearg(file-retries)\n      }\n      {^-+file-retry-delay=.+$} {\n        foreach {dummy cmdlinearg(file-retry-delay)} [split $a =] break\n        set ::G(file-retry-delay) $cmdlinearg(file-retry-delay)\n      }\n      {^-+start=.+$} {\n        foreach {dummy cmdlinearg(start)} [split $a =] break\n\n        set ::G(start:file) $cmdlinearg(start)\n        if {[regexp {(.*):(.*)} $cmdlinearg(start) -> s.perm s.file]} {\n          set ::G(start:permutation) ${s.perm}\n          set ::G(start:file)        ${s.file}\n        }\n        if {$::G(start:file) == \"\"} {unset ::G(start:file)}\n      }\n      {^-+match=.+$} {\n        foreach {dummy cmdlinearg(match)} [split $a =] break\n\n        set ::G(match) $cmdlinearg(match)\n        if {$::G(match) == \"\"} {unset ::G(match)}\n      }\n\n      {^-+output=.+$} {\n        foreach {dummy cmdlinearg(output)} [split $a =] break\n        set cmdlinearg(output) [file normalize $cmdlinearg(output)]\n        if {$cmdlinearg(verbose)==\"\"} {\n          set cmdlinearg(verbose) 2\n        }\n      }\n      {^-+verbose=.+$} {\n        foreach {dummy cmdlinearg(verbose)} [split $a =] break\n        if {$cmdlinearg(verbose)==\"file\"} {\n          set cmdlinearg(verbose) 2\n        } elseif {[string is boolean -strict $cmdlinearg(verbose)]==0} {\n          error \"option --verbose= must be set to a boolean or to \\\"file\\\"\"\n        }\n      }\n      {^-+testdir=.*$} {\n        foreach {dummy cmdlinearg(testdir)} [split $a =] break\n      }\n      {.*help.*} {\n         print_help_and_quit\n      }\n      {^-q$} {\n        set cmdlinearg(output) test-out.txt\n        set cmdlinearg(verbose) 2\n      }\n\n      default {\n        if {[file tail $a]==$a} {\n          lappend leftover $a\n        } else {\n          lappend leftover [file normalize $a]\n        }\n      }\n    }\n  }\n  set testdir [file normalize $testdir]\n  set cmdlinearg(TESTFIXTURE_HOME) [pwd]\n  set cmdlinearg(INFO_SCRIPT) [file normalize [info script]]\n  set argv0 [file normalize $argv0]\n  if {$cmdlinearg(testdir)!=\"\"} {\n    file mkdir $cmdlinearg(testdir)\n    cd $cmdlinearg(testdir)\n  }\n  set argv $leftover\n\n  # Install the malloc layer used to inject OOM errors. And the 'automatic'\n  # extensions. This only needs to be done once for the process.\n  #\n  sqlite3_shutdown\n  install_malloc_faultsim 1\n  sqlite3_initialize\n  autoinstall_test_functions\n\n  # If the --binarylog option was specified, create the logging VFS. This\n  # call installs the new VFS as the default for all SQLite connections.\n  #\n  if {$cmdlinearg(binarylog)} {\n    vfslog new binarylog {} vfslog.bin\n  }\n\n  # Set the backtrace depth, if malloc tracing is enabled.\n  #\n  if {$cmdlinearg(malloctrace)} {\n    sqlite3_memdebug_backtrace $cmdlinearg(backtrace)\n  }\n\n  if {$cmdlinearg(output)!=\"\"} {\n    puts \"Copying output to file $cmdlinearg(output)\"\n    set ::G(output_fd) [open $cmdlinearg(output) w]\n    fconfigure $::G(output_fd) -buffering line\n  }\n\n  if {$cmdlinearg(verbose)==\"\"} {\n    set cmdlinearg(verbose) 1\n  }\n}\n\n# Update the soft-heap-limit each time this script is run. In that\n# way if an individual test file changes the soft-heap-limit, it\n# will be reset at the start of the next test file.\n#\nsqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)\n\n# Create a test database\n#\nproc reset_db {} {\n  catch {db close}\n  forcedelete test.db\n  forcedelete test.db-journal\n  forcedelete test.db-wal\n  sqlite3 db ./test.db\n  set ::DB [sqlite3_connection_pointer db]\n  if {[info exists ::SETUP_SQL]} {\n    db eval $::SETUP_SQL\n  }\n}\nreset_db\n\n# Abort early if this script has been run before.\n#\nif {[info exists TC(count)]} return\n\n# Make sure memory statistics are enabled.\n#\nsqlite3_config_memstatus 1\n\n# Initialize the test counters and set up commands to access them.\n# Or, if this is a slave interpreter, set up aliases to write the\n# counters in the parent interpreter.\n#\nif {0==[info exists ::SLAVE]} {\n  set TC(errors)    0\n  set TC(count)     0\n  set TC(fail_list) [list]\n  set TC(omit_list) [list]\n  set TC(warn_list) [list]\n\n  proc set_test_counter {counter args} {\n    if {[llength $args]} {\n      set ::TC($counter) [lindex $args 0]\n    }\n    set ::TC($counter)\n  }\n}\n\n# Record the fact that a sequence of tests were omitted.\n#\nproc omit_test {name reason {append 1}} {\n  set omitList [set_test_counter omit_list]\n  if {$append} {\n    lappend omitList [list $name $reason]\n  }\n  set_test_counter omit_list $omitList\n}\n\n# Record the fact that a test failed.\n#\nproc fail_test {name} {\n  set f [set_test_counter fail_list]\n  lappend f $name\n  set_test_counter fail_list $f\n  set_test_counter errors [expr [set_test_counter errors] + 1]\n\n  set nFail [set_test_counter errors]\n  if {$nFail>=$::cmdlinearg(maxerror)} {\n    output2 \"*** Giving up...\"\n    finalize_testing\n  }\n}\n\n# Remember a warning message to be displayed at the conclusion of all testing\n#\nproc warning {msg {append 1}} {\n  output2 \"Warning: $msg\"\n  set warnList [set_test_counter warn_list]\n  if {$append} {\n    lappend warnList $msg\n  }\n  set_test_counter warn_list $warnList\n}\n\n\n# Increment the number of tests run\n#\nproc incr_ntest {} {\n  set_test_counter count [expr [set_test_counter count] + 1]\n}\n\n# Return true if --verbose=1 was specified on the command line. Otherwise,\n# return false.\n#\nproc verbose {} {\n  return $::cmdlinearg(verbose)\n}\n\n# Use the following commands instead of [puts] for test output within\n# this file. Test scripts can still use regular [puts], which is directed\n# to stdout and, if one is open, the --output file.\n#\n# output1: output that should be printed if --verbose=1 was specified.\n# output2: output that should be printed unconditionally.\n# output2_if_no_verbose: output that should be printed only if --verbose=0.\n#\nproc output1 {args} {\n  set v [verbose]\n  if {$v==1} {\n    uplevel output2 $args\n  } elseif {$v==2} {\n    uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]\n  }\n}\nproc output2 {args} {\n  set nArg [llength $args]\n  uplevel puts $args\n}\nproc output2_if_no_verbose {args} {\n  set v [verbose]\n  if {$v==0} {\n    uplevel output2 $args\n  } elseif {$v==2} {\n    uplevel puts [lrange $args 0 end-1] stdout [lrange $args end end]\n  }\n}\n\n# Override the [puts] command so that if no channel is explicitly \n# specified the string is written to both stdout and to the file \n# specified by \"--output=\", if any.\n#\nproc puts_override {args} {\n  set nArg [llength $args]\n  if {$nArg==1 || ($nArg==2 && [string first [lindex $args 0] -nonewline]==0)} {\n    uplevel puts_original $args\n    if {[info exists ::G(output_fd)]} {\n      uplevel puts [lrange $args 0 end-1] $::G(output_fd) [lrange $args end end]\n    }\n  } else {\n    # A channel was explicitly specified.\n    uplevel puts_original $args\n  }\n}\nrename puts puts_original\nproc puts {args} { uplevel puts_override $args }\n\n\n# Invoke the do_test procedure to run a single test\n#\n# The $expected parameter is the expected result.  The result is the return\n# value from the last TCL command in $cmd.\n#\n# Normally, $expected must match exactly.  But if $expected is of the form\n# \"/regexp/\" then regular expression matching is used.  If $expected is\n# \"~/regexp/\" then the regular expression must NOT match.  If $expected is\n# of the form \"#/value-list/\" then each term in value-list must be numeric\n# and must approximately match the corresponding numeric term in $result.\n# Values must match within 10%.  Or if the $expected term is A..B then the\n# $result term must be in between A and B.\n#\nproc do_test {name cmd expected} {\n  global argv cmdlinearg\n\n  fix_testname name\n\n  sqlite3_memdebug_settitle $name\n\n#  if {[llength $argv]==0} {\n#    set go 1\n#  } else {\n#    set go 0\n#    foreach pattern $argv {\n#      if {[string match $pattern $name]} {\n#        set go 1\n#        break\n#      }\n#    }\n#  }\n\n  if {[info exists ::G(perm:prefix)]} {\n    set name \"$::G(perm:prefix)$name\"\n  }\n\n  incr_ntest\n  output1 -nonewline $name...\n  flush stdout\n\n  if {![info exists ::G(match)] || [string match $::G(match) $name]} {\n    if {[catch {uplevel #0 \"$cmd;\\n\"} result]} {\n      output2_if_no_verbose -nonewline $name...\n      output2 \"\\nError: $result\"\n      fail_test $name\n    } else {\n      if {[regexp {^[~#]?/.*/$} $expected]} {\n        # \"expected\" is of the form \"/PATTERN/\" then the result if correct if\n        # regular expression PATTERN matches the result.  \"~/PATTERN/\" means\n        # the regular expression must not match.\n        if {[string index $expected 0]==\"~\"} {\n          set re [string range $expected 2 end-1]\n          if {[string index $re 0]==\"*\"} {\n            # If the regular expression begins with * then treat it as a glob instead\n            set ok [string match $re $result]\n          } else {\n            set re [string map {# {[-0-9.]+}} $re]\n            set ok [regexp $re $result]\n          }\n          set ok [expr {!$ok}]\n        } elseif {[string index $expected 0]==\"#\"} {\n          # Numeric range value comparison.  Each term of the $result is matched\n          # against one term of $expect.  Both $result and $expected terms must be\n          # numeric.  The values must match within 10%.  Or if $expected is of the\n          # form A..B then the $result term must be between A and B.\n          set e2 [string range $expected 2 end-1]\n          foreach i $result j $e2 {\n            if {[regexp {^(-?\\d+)\\.\\.(-?\\d)$} $j all A B]} {\n              set ok [expr {$i+0>=$A && $i+0<=$B}]\n            } else {\n              set ok [expr {$i+0>=0.9*$j && $i+0<=1.1*$j}]\n            }\n            if {!$ok} break\n          }\n          if {$ok && [llength $result]!=[llength $e2]} {set ok 0}\n        } else {\n          set re [string range $expected 1 end-1]\n          if {[string index $re 0]==\"*\"} {\n            # If the regular expression begins with * then treat it as a glob instead\n            set ok [string match $re $result]\n          } else {\n            set re [string map {# {[-0-9.]+}} $re]\n            set ok [regexp $re $result]\n          }\n        }\n      } elseif {[regexp {^~?\\*.*\\*$} $expected]} {\n        # \"expected\" is of the form \"*GLOB*\" then the result if correct if\n        # glob pattern GLOB matches the result.  \"~/GLOB/\" means\n        # the glob must not match.\n        if {[string index $expected 0]==\"~\"} {\n          set e [string range $expected 1 end]\n          set ok [expr {![string match $e $result]}]\n        } else {\n          set ok [string match $expected $result]\n        }\n      } else {\n        set ok [expr {[string compare $result $expected]==0}]\n      }\n      if {!$ok} {\n        # if {![info exists ::testprefix] || $::testprefix eq \"\"} {\n        #   error \"no test prefix\"\n        # }\n        output1 \"\"\n        output2 \"! $name expected: \\[$expected\\]\\n! $name got:      \\[$result\\]\"\n        fail_test $name\n      } else {\n        output1 \" Ok\"\n      }\n    }\n  } else {\n    output1 \" Omitted\"\n    omit_test $name \"pattern mismatch\" 0\n  }\n  flush stdout\n}\n\nproc dumpbytes {s} {\n  set r \"\"\n  for {set i 0} {$i < [string length $s]} {incr i} {\n    if {$i > 0} {append r \" \"}\n    append r [format %02X [scan [string index $s $i] %c]]\n  }\n  return $r\n}\n\nproc catchcmd {db {cmd \"\"}} {\n  global CLI\n  set out [open cmds.txt w]\n  puts $out $cmd\n  close $out\n  set line \"exec $CLI $db < cmds.txt\"\n  set rc [catch { eval $line } msg]\n  list $rc $msg\n}\n\nproc catchcmdex {db {cmd \"\"}} {\n  global CLI\n  set out [open cmds.txt w]\n  fconfigure $out -encoding binary -translation binary\n  puts -nonewline $out $cmd\n  close $out\n  set line \"exec -keepnewline -- $CLI $db < cmds.txt\"\n  set chans [list stdin stdout stderr]\n  foreach chan $chans {\n    catch {\n      set modes($chan) [fconfigure $chan]\n      fconfigure $chan -encoding binary -translation binary -buffering none\n    }\n  }\n  set rc [catch { eval $line } msg]\n  foreach chan $chans {\n    catch {\n      eval fconfigure [list $chan] $modes($chan)\n    }\n  }\n  # puts [dumpbytes $msg]\n  list $rc $msg\n}\n\nproc filepath_normalize {p} {\n  # test cases should be written to assume \"unix\"-like file paths\n  if {$::tcl_platform(platform)!=\"unix\"} {\n    # lreverse*2 as a hack to remove any unneeded {} after the string map\n    lreverse [lreverse [string map {\\\\ /} [regsub -nocase -all {[a-z]:[/\\\\]+} $p {/}]]]\n  } {\n    set p\n  }\n}\nproc do_filepath_test {name cmd expected} {\n  uplevel [list do_test $name [\n    subst -nocommands { filepath_normalize [ $cmd ] }\n  ] [filepath_normalize $expected]]\n}\n\nproc realnum_normalize {r} {\n  # different TCL versions display floating point values differently.\n  string map {1.#INF inf Inf inf .0e e} [regsub -all {(e[+-])0+} $r {\\1}]\n}\nproc do_realnum_test {name cmd expected} {\n  uplevel [list do_test $name [\n    subst -nocommands { realnum_normalize [ $cmd ] }\n  ] [realnum_normalize $expected]]\n}\n\nproc fix_testname {varname} {\n  upvar $varname testname\n  if {[info exists ::testprefix]\n   && [string is digit [string range $testname 0 0]]\n  } {\n    set testname \"${::testprefix}-$testname\"\n  }\n}\n\nproc normalize_list {L} {\n  set L2 [list]\n  foreach l $L {lappend L2 $l}\n  set L2\n}\n\n# Either:\n#\n#   do_execsql_test TESTNAME SQL ?RES?\n#   do_execsql_test -db DB TESTNAME SQL ?RES?\n#\nproc do_execsql_test {args} {\n  set db db\n  if {[lindex $args 0]==\"-db\"} {\n    set db [lindex $args 1]\n    set args [lrange $args 2 end]\n  }\n\n  if {[llength $args]==2} {\n    foreach {testname sql} $args {}\n    set result \"\"\n  } elseif {[llength $args]==3} {\n    foreach {testname sql result} $args {}\n  } else {\n    error [string trim {\n      wrong # args: should be \"do_execsql_test ?-db DB? testname sql ?result?\"\n    }]\n  }\n\n  fix_testname testname\n\n  uplevel do_test                 \\\n      [list $testname]            \\\n      [list \"execsql {$sql} $db\"] \\\n      [list [list {*}$result]]\n}\n\nproc do_catchsql_test {testname sql result} {\n  fix_testname testname\n  uplevel do_test [list $testname] [list \"catchsql {$sql}\"] [list $result]\n}\nproc do_timed_execsql_test {testname sql {result {}}} {\n  fix_testname testname\n  uplevel do_test [list $testname] [list \"execsql_timed {$sql}\"]\\\n                                   [list [list {*}$result]]\n}\nproc do_eqp_test {name sql res} {\n  uplevel do_execsql_test $name [list \"EXPLAIN QUERY PLAN $sql\"] [list $res]\n}\n\n#-------------------------------------------------------------------------\n#   Usage: do_select_tests PREFIX ?SWITCHES? TESTLIST\n#\n# Where switches are:\n#\n#   -errorformat FMTSTRING\n#   -count\n#   -query SQL\n#   -tclquery TCL\n#   -repair TCL\n#\nproc do_select_tests {prefix args} {\n\n  set testlist [lindex $args end]\n  set switches [lrange $args 0 end-1]\n\n  set errfmt \"\"\n  set countonly 0\n  set tclquery \"\"\n  set repair \"\"\n\n  for {set i 0} {$i < [llength $switches]} {incr i} {\n    set s [lindex $switches $i]\n    set n [string length $s]\n    if {$n>=2 && [string equal -length $n $s \"-query\"]} {\n      set tclquery [list execsql [lindex $switches [incr i]]]\n    } elseif {$n>=2 && [string equal -length $n $s \"-tclquery\"]} {\n      set tclquery [lindex $switches [incr i]]\n    } elseif {$n>=2 && [string equal -length $n $s \"-errorformat\"]} {\n      set errfmt [lindex $switches [incr i]]\n    } elseif {$n>=2 && [string equal -length $n $s \"-repair\"]} {\n      set repair [lindex $switches [incr i]]\n    } elseif {$n>=2 && [string equal -length $n $s \"-count\"]} {\n      set countonly 1\n    } else {\n      error \"unknown switch: $s\"\n    }\n  }\n\n  if {$countonly && $errfmt!=\"\"} {\n    error \"Cannot use -count and -errorformat together\"\n  }\n  set nTestlist [llength $testlist]\n  if {$nTestlist%3 || $nTestlist==0 } {\n    error \"SELECT test list contains [llength $testlist] elements\"\n  }\n\n  eval $repair\n  foreach {tn sql res} $testlist {\n    if {$tclquery != \"\"} {\n      execsql $sql\n      uplevel do_test ${prefix}.$tn [list $tclquery] [list [list {*}$res]]\n    } elseif {$countonly} {\n      set nRow 0\n      db eval $sql {incr nRow}\n      uplevel do_test ${prefix}.$tn [list [list set {} $nRow]] [list $res]\n    } elseif {$errfmt==\"\"} {\n      uplevel do_execsql_test ${prefix}.${tn} [list $sql] [list [list {*}$res]]\n    } else {\n      set res [list 1 [string trim [format $errfmt {*}$res]]]\n      uplevel do_catchsql_test ${prefix}.${tn} [list $sql] [list $res]\n    }\n    eval $repair\n  }\n\n}\n\nproc delete_all_data {} {\n  db eval {SELECT tbl_name AS t FROM sqlite_master WHERE type = 'table'} {\n    db eval \"DELETE FROM '[string map {' ''} $t]'\"\n  }\n}\n\n# Run an SQL script.\n# Return the number of microseconds per statement.\n#\nproc speed_trial {name numstmt units sql} {\n  output2 -nonewline [format {%-21.21s } $name...]\n  flush stdout\n  set speed [time {sqlite3_exec_nr db $sql}]\n  set tm [lindex $speed 0]\n  if {$tm == 0} {\n    set rate [format %20s \"many\"]\n  } else {\n    set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]\n  }\n  set u2 $units/s\n  output2 [format {%12d uS %s %s} $tm $rate $u2]\n  global total_time\n  set total_time [expr {$total_time+$tm}]\n  lappend ::speed_trial_times $name $tm\n}\nproc speed_trial_tcl {name numstmt units script} {\n  output2 -nonewline [format {%-21.21s } $name...]\n  flush stdout\n  set speed [time {eval $script}]\n  set tm [lindex $speed 0]\n  if {$tm == 0} {\n    set rate [format %20s \"many\"]\n  } else {\n    set rate [format %20.5f [expr {1000000.0*$numstmt/$tm}]]\n  }\n  set u2 $units/s\n  output2 [format {%12d uS %s %s} $tm $rate $u2]\n  global total_time\n  set total_time [expr {$total_time+$tm}]\n  lappend ::speed_trial_times $name $tm\n}\nproc speed_trial_init {name} {\n  global total_time\n  set total_time 0\n  set ::speed_trial_times [list]\n  sqlite3 versdb :memory:\n  set vers [versdb one {SELECT sqlite_source_id()}]\n  versdb close\n  output2 \"SQLite $vers\"\n}\nproc speed_trial_summary {name} {\n  global total_time\n  output2 [format {%-21.21s %12d uS TOTAL} $name $total_time]\n\n  if { 0 } {\n    sqlite3 versdb :memory:\n    set vers [lindex [versdb one {SELECT sqlite_source_id()}] 0]\n    versdb close\n    output2 \"CREATE TABLE IF NOT EXISTS time(version, script, test, us);\"\n    foreach {test us} $::speed_trial_times {\n      output2 \"INSERT INTO time VALUES('$vers', '$name', '$test', $us);\"\n    }\n  }\n}\n\n# Run this routine last\n#\nproc finish_test {} {\n  catch {db close}\n  catch {db1 close}\n  catch {db2 close}\n  catch {db3 close}\n  if {0==[info exists ::SLAVE]} { finalize_testing }\n}\nproc finalize_testing {} {\n  global sqlite_open_file_count\n\n  set omitList [set_test_counter omit_list]\n\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n\n  vfs_unlink_test\n  sqlite3 db {}\n  # sqlite3_clear_tsd_memdebug\n  db close\n  sqlite3_reset_auto_extension\n\n  sqlite3_soft_heap_limit 0\n  set nTest [incr_ntest]\n  set nErr [set_test_counter errors]\n\n  set nKnown 0\n  if {[file readable known-problems.txt]} {\n    set fd [open known-problems.txt]\n    set content [read $fd]\n    close $fd\n    foreach x $content {set known_error($x) 1}\n    foreach x [set_test_counter fail_list] {\n      if {[info exists known_error($x)]} {incr nKnown}\n    }\n  }\n  if {$nKnown>0} {\n    output2 \"[expr {$nErr-$nKnown}] new errors and $nKnown known errors\\\n         out of $nTest tests\"\n  } else {\n    set cpuinfo {}\n    if {[catch {exec hostname} hname]==0} {set cpuinfo [string trim $hname]}\n    append cpuinfo \" $::tcl_platform(os)\"\n    append cpuinfo \" [expr {$::tcl_platform(pointerSize)*8}]-bit\"\n    append cpuinfo \" [string map {E -e} $::tcl_platform(byteOrder)]\"\n    output2 \"SQLite [sqlite3 -sourceid]\"\n    output2 \"$nErr errors out of $nTest tests on $cpuinfo\"\n  }\n  if {$nErr>$nKnown} {\n    output2 -nonewline \"!Failures on these tests:\"\n    foreach x [set_test_counter fail_list] {\n      if {![info exists known_error($x)]} {output2 -nonewline \" $x\"}\n    }\n    output2 \"\"\n  }\n  foreach warning [set_test_counter warn_list] {\n    output2 \"Warning: $warning\"\n  }\n  run_thread_tests 1\n  if {[llength $omitList]>0} {\n    output2 \"Omitted test cases:\"\n    set prec {}\n    foreach {rec} [lsort $omitList] {\n      if {$rec==$prec} continue\n      set prec $rec\n      output2 [format {.  %-12s %s} [lindex $rec 0] [lindex $rec 1]]\n    }\n  }\n  if {$nErr>0 && ![working_64bit_int]} {\n    output2 \"******************************************************************\"\n    output2 \"N.B.:  The version of TCL that you used to build this test harness\"\n    output2 \"is defective in that it does not support 64-bit integers.  Some or\"\n    output2 \"all of the test failures above might be a result from this defect\"\n    output2 \"in your TCL build.\"\n    output2 \"******************************************************************\"\n  }\n  if {$::cmdlinearg(binarylog)} {\n    vfslog finalize binarylog\n  }\n  if {$sqlite_open_file_count} {\n    output2 \"$sqlite_open_file_count files were left open\"\n    incr nErr\n  }\n  if {[lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1]>0 ||\n              [sqlite3_memory_used]>0} {\n    output2 \"Unfreed memory: [sqlite3_memory_used] bytes in\\\n         [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] allocations\"\n    incr nErr\n    ifcapable memdebug||mem5||(mem3&&debug) {\n      output2 \"Writing unfreed memory log to \\\"./memleak.txt\\\"\"\n      sqlite3_memdebug_dump ./memleak.txt\n    }\n  } else {\n    output2 \"All memory allocations freed - no leaks\"\n    ifcapable memdebug||mem5 {\n      sqlite3_memdebug_dump ./memusage.txt\n    }\n  }\n  show_memstats\n  output2 \"Maximum memory usage: [sqlite3_memory_highwater 1] bytes\"\n  output2 \"Current memory usage: [sqlite3_memory_highwater] bytes\"\n  if {[info commands sqlite3_memdebug_malloc_count] ne \"\"} {\n    output2 \"Number of malloc()  : [sqlite3_memdebug_malloc_count] calls\"\n  }\n  if {$::cmdlinearg(malloctrace)} {\n    output2 \"Writing mallocs.sql...\"\n    memdebug_log_sql\n    sqlite3_memdebug_log stop\n    sqlite3_memdebug_log clear\n\n    if {[sqlite3_memory_used]>0} {\n      output2 \"Writing leaks.sql...\"\n      sqlite3_memdebug_log sync\n      memdebug_log_sql leaks.sql\n    }\n  }\n  foreach f [glob -nocomplain test.db-*-journal] {\n    forcedelete $f\n  }\n  foreach f [glob -nocomplain test.db-mj*] {\n    forcedelete $f\n  }\n  exit [expr {$nErr>0}]\n}\n\n# Display memory statistics for analysis and debugging purposes.\n#\nproc show_memstats {} {\n  set x [sqlite3_status SQLITE_STATUS_MEMORY_USED 0]\n  set y [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0]\n  set val [format {now %10d  max %10d  max-size %10d} \\\n              [lindex $x 1] [lindex $x 2] [lindex $y 2]]\n  output1 \"Memory used:          $val\"\n  set x [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0]\n  set val [format {now %10d  max %10d} [lindex $x 1] [lindex $x 2]]\n  output1 \"Allocation count:     $val\"\n  set x [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0]\n  set y [sqlite3_status SQLITE_STATUS_PAGECACHE_SIZE 0]\n  set val [format {now %10d  max %10d  max-size %10d} \\\n              [lindex $x 1] [lindex $x 2] [lindex $y 2]]\n  output1 \"Page-cache used:      $val\"\n  set x [sqlite3_status SQLITE_STATUS_PAGECACHE_OVERFLOW 0]\n  set val [format {now %10d  max %10d} [lindex $x 1] [lindex $x 2]]\n  output1 \"Page-cache overflow:  $val\"\n  ifcapable yytrackmaxstackdepth {\n    set x [sqlite3_status SQLITE_STATUS_PARSER_STACK 0]\n    set val [format {               max %10d} [lindex $x 2]]\n    output2 \"Parser stack depth:    $val\"\n  }\n}\n\n# A procedure to execute SQL\n#\nproc execsql {sql {db db}} {\n  # puts \"SQL = $sql\"\n  uplevel [list $db eval $sql]\n}\nproc execsql_timed {sql {db db}} {\n  set tm [time {\n    set x [uplevel [list $db eval $sql]]\n  } 1]\n  set tm [lindex $tm 0]\n  output1 -nonewline \" ([expr {$tm*0.001}]ms) \"\n  set x\n}\n\n# Execute SQL and catch exceptions.\n#\nproc catchsql {sql {db db}} {\n  # puts \"SQL = $sql\"\n  set r [catch [list uplevel [list $db eval $sql]] msg]\n  lappend r $msg\n  return $r\n}\n\n# Do an VDBE code dump on the SQL given\n#\nproc explain {sql {db db}} {\n  output2 \"\"\n  output2 \"addr  opcode        p1      p2      p3      p4               p5  #\"\n  output2 \"----  ------------  ------  ------  ------  ---------------  --  -\"\n  $db eval \"explain $sql\" {} {\n    output2 [format {%-4d  %-12.12s  %-6d  %-6d  %-6d  % -17s %s  %s} \\\n      $addr $opcode $p1 $p2 $p3 $p4 $p5 $comment\n    ]\n  }\n}\n\nproc explain_i {sql {db db}} {\n  output2 \"\"\n  output2 \"addr  opcode        p1      p2      p3      p4                p5  #\"\n  output2 \"----  ------------  ------  ------  ------  ----------------  --  -\"\n\n\n  # Set up colors for the different opcodes. Scheme is as follows:\n  #\n  #   Red:   Opcodes that write to a b-tree.\n  #   Blue:  Opcodes that reposition or seek a cursor. \n  #   Green: The ResultRow opcode.\n  #\n  if { [catch {fconfigure stdout -mode}]==0 } {\n    set R \"\\033\\[31;1m\"        ;# Red fg\n    set G \"\\033\\[32;1m\"        ;# Green fg\n    set B \"\\033\\[34;1m\"        ;# Red fg\n    set D \"\\033\\[39;0m\"        ;# Default fg\n  } else {\n    set R \"\"\n    set G \"\"\n    set B \"\"\n    set D \"\"\n  }\n  foreach opcode {\n      Seek SeekGE SeekGT SeekLE SeekLT NotFound Last Rewind\n      NoConflict Next Prev VNext VPrev VFilter\n      SorterSort SorterNext NextIfOpen\n  } {\n    set color($opcode) $B\n  }\n  foreach opcode {ResultRow} {\n    set color($opcode) $G\n  }\n  foreach opcode {IdxInsert Insert Delete IdxDelete} {\n    set color($opcode) $R\n  }\n\n  set bSeenGoto 0\n  $db eval \"explain $sql\" {} {\n    set x($addr) 0\n    set op($addr) $opcode\n\n    if {$opcode == \"Goto\" && ($bSeenGoto==0 || ($p2 > $addr+10))} {\n      set linebreak($p2) 1\n      set bSeenGoto 1\n    }\n\n    if {$opcode==\"Once\"} {\n      for {set i $addr} {$i<$p2} {incr i} {\n        set star($i) $addr\n      }\n    }\n\n    if {$opcode==\"Next\"  || $opcode==\"Prev\" \n     || $opcode==\"VNext\" || $opcode==\"VPrev\"\n     || $opcode==\"SorterNext\" || $opcode==\"NextIfOpen\"\n    } {\n      for {set i $p2} {$i<$addr} {incr i} {\n        incr x($i) 2\n      }\n    }\n\n    if {$opcode == \"Goto\" && $p2<$addr && $op($p2)==\"Yield\"} {\n      for {set i [expr $p2+1]} {$i<$addr} {incr i} {\n        incr x($i) 2\n      }\n    }\n\n    if {$opcode == \"Halt\" && $comment == \"End of coroutine\"} {\n      set linebreak([expr $addr+1]) 1\n    }\n  }\n\n  $db eval \"explain $sql\" {} {\n    if {[info exists linebreak($addr)]} {\n      output2 \"\"\n    }\n    set I [string repeat \" \" $x($addr)]\n\n    if {[info exists star($addr)]} {\n      set ii [expr $x($star($addr))]\n      append I \"  \"\n      set I [string replace $I $ii $ii *]\n    }\n\n    set col \"\"\n    catch { set col $color($opcode) }\n\n    output2 [format {%-4d  %s%s%-12.12s%s  %-6d  %-6d  %-6d  % -17s %s  %s} \\\n      $addr $I $col $opcode $D $p1 $p2 $p3 $p4 $p5 $comment\n    ]\n  }\n  output2 \"----  ------------  ------  ------  ------  ----------------  --  -\"\n}\n\n# Show the VDBE program for an SQL statement but omit the Trace\n# opcode at the beginning.  This procedure can be used to prove\n# that different SQL statements generate exactly the same VDBE code.\n#\nproc explain_no_trace {sql} {\n  set tr [db eval \"EXPLAIN $sql\"]\n  return [lrange $tr 7 end]\n}\n\n# Another procedure to execute SQL.  This one includes the field\n# names in the returned list.\n#\nproc execsql2 {sql} {\n  set result {}\n  db eval $sql data {\n    foreach f $data(*) {\n      lappend result $f $data($f)\n    }\n  }\n  return $result\n}\n\n# Use a temporary in-memory database to execute SQL statements\n#\nproc memdbsql {sql} {\n  sqlite3 memdb :memory:\n  set result [memdb eval $sql]\n  memdb close\n  return $result\n}\n\n# Use the non-callback API to execute multiple SQL statements\n#\nproc stepsql {dbptr sql} {\n  set sql [string trim $sql]\n  set r 0\n  while {[string length $sql]>0} {\n    if {[catch {sqlite3_prepare $dbptr $sql -1 sqltail} vm]} {\n      return [list 1 $vm]\n    }\n    set sql [string trim $sqltail]\n#    while {[sqlite_step $vm N VAL COL]==\"SQLITE_ROW\"} {\n#      foreach v $VAL {lappend r $v}\n#    }\n    while {[sqlite3_step $vm]==\"SQLITE_ROW\"} {\n      for {set i 0} {$i<[sqlite3_data_count $vm]} {incr i} {\n        lappend r [sqlite3_column_text $vm $i]\n      }\n    }\n    if {[catch {sqlite3_finalize $vm} errmsg]} {\n      return [list 1 $errmsg]\n    }\n  }\n  return $r\n}\n\n# Do an integrity check of the entire database\n#\nproc integrity_check {name {db db}} {\n  ifcapable integrityck {\n    do_test $name [list execsql {PRAGMA integrity_check} $db] {ok}\n  }\n}\n\n# Check the extended error code\n#\nproc verify_ex_errcode {name expected {db db}} {\n  do_test $name [list sqlite3_extended_errcode $db] $expected\n}\n\n\n# Return true if the SQL statement passed as the second argument uses a\n# statement transaction.\n#\nproc sql_uses_stmt {db sql} {\n  set stmt [sqlite3_prepare $db $sql -1 dummy]\n  set uses [uses_stmt_journal $stmt]\n  sqlite3_finalize $stmt\n  return $uses\n}\n\nproc fix_ifcapable_expr {expr} {\n  set ret \"\"\n  set state 0\n  for {set i 0} {$i < [string length $expr]} {incr i} {\n    set char [string range $expr $i $i]\n    set newstate [expr {[string is alnum $char] || $char eq \"_\"}]\n    if {$newstate && !$state} {\n      append ret {$::sqlite_options(}\n    }\n    if {!$newstate && $state} {\n      append ret )\n    }\n    append ret $char\n    set state $newstate\n  }\n  if {$state} {append ret )}\n  return $ret\n}\n\n# Returns non-zero if the capabilities are present; zero otherwise.\n#\nproc capable {expr} {\n  set e [fix_ifcapable_expr $expr]; return [expr ($e)]\n}\n\n# Evaluate a boolean expression of capabilities.  If true, execute the\n# code.  Omit the code if false.\n#\nproc ifcapable {expr code {else \"\"} {elsecode \"\"}} {\n  #regsub -all {[a-z_0-9]+} $expr {$::sqlite_options(&)} e2\n  set e2 [fix_ifcapable_expr $expr]\n  if ($e2) {\n    set c [catch {uplevel 1 $code} r]\n  } else {\n    set c [catch {uplevel 1 $elsecode} r]\n  }\n  return -code $c $r\n}\n\n# This proc execs a seperate process that crashes midway through executing\n# the SQL script $sql on database test.db.\n#\n# The crash occurs during a sync() of file $crashfile. When the crash\n# occurs a random subset of all unsynced writes made by the process are\n# written into the files on disk. Argument $crashdelay indicates the\n# number of file syncs to wait before crashing.\n#\n# The return value is a list of two elements. The first element is a\n# boolean, indicating whether or not the process actually crashed or\n# reported some other error. The second element in the returned list is the\n# error message. This is \"child process exited abnormally\" if the crash\n# occurred.\n#\n#   crashsql -delay CRASHDELAY -file CRASHFILE ?-blocksize BLOCKSIZE? $sql\n#\nproc crashsql {args} {\n\n  set blocksize \"\"\n  set crashdelay 1\n  set prngseed 0\n  set opendb { sqlite3 db test.db -vfs crash }\n  set tclbody {}\n  set crashfile \"\"\n  set dc \"\"\n  set dfltvfs 0\n  set sql [lindex $args end]\n\n  for {set ii 0} {$ii < [llength $args]-1} {incr ii 2} {\n    set z [lindex $args $ii]\n    set n [string length $z]\n    set z2 [lindex $args [expr $ii+1]]\n\n    if     {$n>1 && [string first $z -delay]==0}     {set crashdelay $z2} \\\n    elseif {$n>1 && [string first $z -opendb]==0}    {set opendb $z2} \\\n    elseif {$n>1 && [string first $z -seed]==0}      {set prngseed $z2} \\\n    elseif {$n>1 && [string first $z -file]==0}      {set crashfile $z2}  \\\n    elseif {$n>1 && [string first $z -tclbody]==0}   {set tclbody $z2}  \\\n    elseif {$n>1 && [string first $z -blocksize]==0} {set blocksize \"-s $z2\" } \\\n    elseif {$n>1 && [string first $z -characteristics]==0} {set dc \"-c {$z2}\" }\\\n    elseif {$n>1 && [string first $z -dfltvfs]==0} {set dfltvfs $z2 }\\\n    else   { error \"Unrecognized option: $z\" }\n  }\n\n  if {$crashfile eq \"\"} {\n    error \"Compulsory option -file missing\"\n  }\n\n  # $crashfile gets compared to the native filename in\n  # cfSync(), which can be different then what TCL uses by\n  # default, so here we force it to the \"nativename\" format.\n  set cfile [string map {\\\\ \\\\\\\\} [file nativename [file join [get_pwd] $crashfile]]]\n\n  set f [open crash.tcl w]\n  puts $f \"sqlite3_crash_enable 1 $dfltvfs\"\n  puts $f \"sqlite3_crashparams $blocksize $dc $crashdelay $cfile\"\n  puts $f \"sqlite3_test_control_pending_byte $::sqlite_pending_byte\"\n\n  # This block sets the cache size of the main database to 10\n  # pages. This is done in case the build is configured to omit\n  # \"PRAGMA cache_size\".\n  if {$opendb!=\"\"} {\n    puts $f $opendb \n    puts $f {db eval {SELECT * FROM sqlite_master;}}\n    puts $f {set bt [btree_from_db db]}\n    puts $f {btree_set_cache_size $bt 10}\n  }\n\n  if {$prngseed} {\n    set seed [expr {$prngseed%10007+1}]\n    # puts seed=$seed\n    puts $f \"db eval {SELECT randomblob($seed)}\"\n  }\n\n  if {[string length $tclbody]>0} {\n    puts $f $tclbody\n  }\n  if {[string length $sql]>0} {\n    puts $f \"db eval {\"\n    puts $f   \"$sql\"\n    puts $f \"}\"\n  }\n  close $f\n  set r [catch {\n    exec [info nameofexec] crash.tcl >@stdout\n  } msg]\n\n  # Windows/ActiveState TCL returns a slightly different\n  # error message.  We map that to the expected message\n  # so that we don't have to change all of the test\n  # cases.\n  if {$::tcl_platform(platform)==\"windows\"} {\n    if {$msg==\"child killed: unknown signal\"} {\n      set msg \"child process exited abnormally\"\n    }\n  }\n\n  lappend r $msg\n}\n\n#   crash_on_write ?-devchar DEVCHAR? CRASHDELAY SQL\n#\nproc crash_on_write {args} {\n\n  set nArg [llength $args]\n  if {$nArg<2 || $nArg%2} {\n    error \"bad args: $args\"\n  }\n  set zSql [lindex $args end]\n  set nDelay [lindex $args end-1]\n\n  set devchar {}\n  for {set ii 0} {$ii < $nArg-2} {incr ii 2} {\n    set opt [lindex $args $ii]\n    switch -- [lindex $args $ii] {\n      -devchar {\n        set devchar [lindex $args [expr $ii+1]]\n      }\n\n      default { error \"unrecognized option: $opt\" }\n    }\n  }\n\n  set f [open crash.tcl w]\n  puts $f \"sqlite3_crash_on_write $nDelay\"\n  puts $f \"sqlite3_test_control_pending_byte $::sqlite_pending_byte\"\n  puts $f \"sqlite3 db test.db -vfs writecrash\"\n  puts $f \"db eval {$zSql}\"\n  puts $f \"set {} {}\"\n\n  close $f\n  set r [catch {\n    exec [info nameofexec] crash.tcl >@stdout\n  } msg]\n\n  # Windows/ActiveState TCL returns a slightly different\n  # error message.  We map that to the expected message\n  # so that we don't have to change all of the test\n  # cases.\n  if {$::tcl_platform(platform)==\"windows\"} {\n    if {$msg==\"child killed: unknown signal\"} {\n      set msg \"child process exited abnormally\"\n    }\n  }\n\n  lappend r $msg\n}\n\nproc run_ioerr_prep {} {\n  set ::sqlite_io_error_pending 0\n  catch {db close}\n  catch {db2 close}\n  catch {forcedelete test.db}\n  catch {forcedelete test.db-journal}\n  catch {forcedelete test2.db}\n  catch {forcedelete test2.db-journal}\n  set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]\n  sqlite3_extended_result_codes $::DB $::ioerropts(-erc)\n  if {[info exists ::ioerropts(-tclprep)]} {\n    eval $::ioerropts(-tclprep)\n  }\n  if {[info exists ::ioerropts(-sqlprep)]} {\n    execsql $::ioerropts(-sqlprep)\n  }\n  expr 0\n}\n\n# Usage: do_ioerr_test <test number> <options...>\n#\n# This proc is used to implement test cases that check that IO errors\n# are correctly handled. The first argument, <test number>, is an integer\n# used to name the tests executed by this proc. Options are as follows:\n#\n#     -tclprep          TCL script to run to prepare test.\n#     -sqlprep          SQL script to run to prepare test.\n#     -tclbody          TCL script to run with IO error simulation.\n#     -sqlbody          TCL script to run with IO error simulation.\n#     -exclude          List of 'N' values not to test.\n#     -erc              Use extended result codes\n#     -persist          Make simulated I/O errors persistent\n#     -start            Value of 'N' to begin with (default 1)\n#\n#     -cksum            Boolean. If true, test that the database does\n#                       not change during the execution of the test case.\n#\nproc do_ioerr_test {testname args} {\n\n  set ::ioerropts(-start) 1\n  set ::ioerropts(-cksum) 0\n  set ::ioerropts(-erc) 0\n  set ::ioerropts(-count) 100000000\n  set ::ioerropts(-persist) 1\n  set ::ioerropts(-ckrefcount) 0\n  set ::ioerropts(-restoreprng) 1\n  array set ::ioerropts $args\n\n  # TEMPORARY: For 3.5.9, disable testing of extended result codes. There are\n  # a couple of obscure IO errors that do not return them.\n  set ::ioerropts(-erc) 0\n\n  # Create a single TCL script from the TCL and SQL specified\n  # as the body of the test.\n  set ::ioerrorbody {}\n  if {[info exists ::ioerropts(-tclbody)]} {\n    append ::ioerrorbody \"$::ioerropts(-tclbody)\\n\"\n  }\n  if {[info exists ::ioerropts(-sqlbody)]} {\n    append ::ioerrorbody \"db eval {$::ioerropts(-sqlbody)}\"\n  }\n\n  save_prng_state\n  if {$::ioerropts(-cksum)} {\n    run_ioerr_prep\n    eval $::ioerrorbody\n    set ::goodcksum [cksum]\n  }\n\n  set ::go 1\n  #reset_prng_state\n  for {set n $::ioerropts(-start)} {$::go} {incr n} {\n    set ::TN $n\n    incr ::ioerropts(-count) -1\n    if {$::ioerropts(-count)<0} break\n\n    # Skip this IO error if it was specified with the \"-exclude\" option.\n    if {[info exists ::ioerropts(-exclude)]} {\n      if {[lsearch $::ioerropts(-exclude) $n]!=-1} continue\n    }\n    if {$::ioerropts(-restoreprng)} {\n      restore_prng_state\n    }\n\n    # Delete the files test.db and test2.db, then execute the TCL and\n    # SQL (in that order) to prepare for the test case.\n    do_test $testname.$n.1 {\n      run_ioerr_prep\n    } {0}\n\n    # Read the 'checksum' of the database.\n    if {$::ioerropts(-cksum)} {\n      set ::checksum [cksum]\n    }\n\n    # Set the Nth IO error to fail.\n    do_test $testname.$n.2 [subst {\n      set ::sqlite_io_error_persist $::ioerropts(-persist)\n      set ::sqlite_io_error_pending $n\n    }] $n\n\n    # Execute the TCL script created for the body of this test. If\n    # at least N IO operations performed by SQLite as a result of\n    # the script, the Nth will fail.\n    do_test $testname.$n.3 {\n      set ::sqlite_io_error_hit 0\n      set ::sqlite_io_error_hardhit 0\n      set r [catch $::ioerrorbody msg]\n      set ::errseen $r\n      set rc [sqlite3_errcode $::DB]\n      if {$::ioerropts(-erc)} {\n        # If we are in extended result code mode, make sure all of the\n        # IOERRs we get back really do have their extended code values.\n        # If an extended result code is returned, the sqlite3_errcode\n        # TCLcommand will return a string of the form:  SQLITE_IOERR+nnnn\n        # where nnnn is a number\n        if {[regexp {^SQLITE_IOERR} $rc] && ![regexp {IOERR\\+\\d} $rc]} {\n          return $rc\n        }\n      } else {\n        # If we are not in extended result code mode, make sure no\n        # extended error codes are returned.\n        if {[regexp {\\+\\d} $rc]} {\n          return $rc\n        }\n      }\n      # The test repeats as long as $::go is non-zero.  $::go starts out\n      # as 1.  When a test runs to completion without hitting an I/O\n      # error, that means there is no point in continuing with this test\n      # case so set $::go to zero.\n      #\n      if {$::sqlite_io_error_pending>0} {\n        set ::go 0\n        set q 0\n        set ::sqlite_io_error_pending 0\n      } else {\n        set q 1\n      }\n\n      set s [expr $::sqlite_io_error_hit==0]\n      if {$::sqlite_io_error_hit>$::sqlite_io_error_hardhit && $r==0} {\n        set r 1\n      }\n      set ::sqlite_io_error_hit 0\n\n      # One of two things must have happened. either\n      #   1.  We never hit the IO error and the SQL returned OK\n      #   2.  An IO error was hit and the SQL failed\n      #\n      #puts \"s=$s r=$r q=$q\"\n      expr { ($s && !$r && !$q) || (!$s && $r && $q) }\n    } {1}\n\n    set ::sqlite_io_error_hit 0\n    set ::sqlite_io_error_pending 0\n\n    # Check that no page references were leaked. There should be\n    # a single reference if there is still an active transaction,\n    # or zero otherwise.\n    #\n    # UPDATE: If the IO error occurs after a 'BEGIN' but before any\n    # locks are established on database files (i.e. if the error\n    # occurs while attempting to detect a hot-journal file), then\n    # there may 0 page references and an active transaction according\n    # to [sqlite3_get_autocommit].\n    #\n    if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-ckrefcount)} {\n      do_test $testname.$n.4 {\n        set bt [btree_from_db db]\n        db_enter db\n        array set stats [btree_pager_stats $bt]\n        db_leave db\n        set nRef $stats(ref)\n        expr {$nRef == 0 || ([sqlite3_get_autocommit db]==0 && $nRef == 1)}\n      } {1}\n    }\n\n    # If there is an open database handle and no open transaction,\n    # and the pager is not running in exclusive-locking mode,\n    # check that the pager is in \"unlocked\" state. Theoretically,\n    # if a call to xUnlock() failed due to an IO error the underlying\n    # file may still be locked.\n    #\n    ifcapable pragma {\n      if { [info commands db] ne \"\"\n        && $::ioerropts(-ckrefcount)\n        && [db one {pragma locking_mode}] eq \"normal\"\n        && [sqlite3_get_autocommit db]\n      } {\n        do_test $testname.$n.5 {\n          set bt [btree_from_db db]\n          db_enter db\n          array set stats [btree_pager_stats $bt]\n          db_leave db\n          set stats(state)\n        } 0\n      }\n    }\n\n    # If an IO error occurred, then the checksum of the database should\n    # be the same as before the script that caused the IO error was run.\n    #\n    if {$::go && $::sqlite_io_error_hardhit && $::ioerropts(-cksum)} {\n      do_test $testname.$n.6 {\n        catch {db close}\n        catch {db2 close}\n        set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]\n        set nowcksum [cksum]\n        set res [expr {$nowcksum==$::checksum || $nowcksum==$::goodcksum}]\n        if {$res==0} {\n          output2 \"now=$nowcksum\"\n          output2 \"the=$::checksum\"\n          output2 \"fwd=$::goodcksum\"\n        }\n        set res\n      } 1\n    }\n\n    set ::sqlite_io_error_hardhit 0\n    set ::sqlite_io_error_pending 0\n    if {[info exists ::ioerropts(-cleanup)]} {\n      catch $::ioerropts(-cleanup)\n    }\n  }\n  set ::sqlite_io_error_pending 0\n  set ::sqlite_io_error_persist 0\n  unset ::ioerropts\n}\n\n# Return a checksum based on the contents of the main database associated\n# with connection $db\n#\nproc cksum {{db db}} {\n  set txt [$db eval {\n      SELECT name, type, sql FROM sqlite_master order by name\n  }]\\n\n  foreach tbl [$db eval {\n      SELECT name FROM sqlite_master WHERE type='table' order by name\n  }] {\n    append txt [$db eval \"SELECT * FROM $tbl\"]\\n\n  }\n  foreach prag {default_synchronous default_cache_size} {\n    append txt $prag-[$db eval \"PRAGMA $prag\"]\\n\n  }\n  set cksum [string length $txt]-[md5 $txt]\n  # puts $cksum-[file size test.db]\n  return $cksum\n}\n\n# Generate a checksum based on the contents of the main and temp tables\n# database $db. If the checksum of two databases is the same, and the\n# integrity-check passes for both, the two databases are identical.\n#\nproc allcksum {{db db}} {\n  set ret [list]\n  ifcapable tempdb {\n    set sql {\n      SELECT name FROM sqlite_master WHERE type = 'table' UNION\n      SELECT name FROM sqlite_temp_master WHERE type = 'table' UNION\n      SELECT 'sqlite_master' UNION\n      SELECT 'sqlite_temp_master' ORDER BY 1\n    }\n  } else {\n    set sql {\n      SELECT name FROM sqlite_master WHERE type = 'table' UNION\n      SELECT 'sqlite_master' ORDER BY 1\n    }\n  }\n  set tbllist [$db eval $sql]\n  set txt {}\n  foreach tbl $tbllist {\n    append txt [$db eval \"SELECT * FROM $tbl\"]\n  }\n  foreach prag {default_cache_size} {\n    append txt $prag-[$db eval \"PRAGMA $prag\"]\\n\n  }\n  # puts txt=$txt\n  return [md5 $txt]\n}\n\n# Generate a checksum based on the contents of a single database with\n# a database connection.  The name of the database is $dbname.\n# Examples of $dbname are \"temp\" or \"main\".\n#\nproc dbcksum {db dbname} {\n  if {$dbname==\"temp\"} {\n    set master sqlite_temp_master\n  } else {\n    set master $dbname.sqlite_master\n  }\n  set alltab [$db eval \"SELECT name FROM $master WHERE type='table'\"]\n  set txt [$db eval \"SELECT * FROM $master\"]\\n\n  foreach tab $alltab {\n    append txt [$db eval \"SELECT * FROM $dbname.$tab\"]\\n\n  }\n  return [md5 $txt]\n}\n\nproc memdebug_log_sql {{filename mallocs.sql}} {\n\n  set data [sqlite3_memdebug_log dump]\n  set nFrame [expr [llength [lindex $data 0]]-2]\n  if {$nFrame < 0} { return \"\" }\n\n  set database temp\n\n  set tbl \"CREATE TABLE ${database}.malloc(zTest, nCall, nByte, lStack);\"\n\n  set sql \"\"\n  foreach e $data {\n    set nCall [lindex $e 0]\n    set nByte [lindex $e 1]\n    set lStack [lrange $e 2 end]\n    append sql \"INSERT INTO ${database}.malloc VALUES\"\n    append sql \"('test', $nCall, $nByte, '$lStack');\\n\"\n    foreach f $lStack {\n      set frames($f) 1\n    }\n  }\n\n  set tbl2 \"CREATE TABLE ${database}.frame(frame INTEGER PRIMARY KEY, line);\\n\"\n  set tbl3 \"CREATE TABLE ${database}.file(name PRIMARY KEY, content);\\n\"\n\n  foreach f [array names frames] {\n    set addr [format %x $f]\n    set cmd \"addr2line -e [info nameofexec] $addr\"\n    set line [eval exec $cmd]\n    append sql \"INSERT INTO ${database}.frame VALUES($f, '$line');\\n\"\n\n    set file [lindex [split $line :] 0]\n    set files($file) 1\n  }\n\n  foreach f [array names files] {\n    set contents \"\"\n    catch {\n      set fd [open $f]\n      set contents [read $fd]\n      close $fd\n    }\n    set contents [string map {' ''} $contents]\n    append sql \"INSERT INTO ${database}.file VALUES('$f', '$contents');\\n\"\n  }\n\n  set fd [open $filename w]\n  puts $fd \"BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;\"\n  close $fd\n}\n\n# Drop all tables in database [db]\nproc drop_all_tables {{db db}} {\n  ifcapable trigger&&foreignkey {\n    set pk [$db one \"PRAGMA foreign_keys\"]\n    $db eval \"PRAGMA foreign_keys = OFF\"\n  }\n  foreach {idx name file} [db eval {PRAGMA database_list}] {\n    if {$idx==1} {\n      set master sqlite_temp_master\n    } else {\n      set master $name.sqlite_master\n    }\n    foreach {t type} [$db eval \"\n      SELECT name, type FROM $master\n      WHERE type IN('table', 'view') AND name NOT LIKE 'sqliteX_%' ESCAPE 'X'\n    \"] {\n      $db eval \"DROP $type \\\"$t\\\"\"\n    }\n  }\n  ifcapable trigger&&foreignkey {\n    $db eval \"PRAGMA foreign_keys = $pk\"\n  }\n}\n\n# Drop all auxiliary indexes from the main database opened by handle [db].\n#\nproc drop_all_indexes {{db db}} {\n  set L [$db eval {\n    SELECT name FROM sqlite_master WHERE type='index' AND sql LIKE 'create%'\n  }]\n  foreach idx $L { $db eval \"DROP INDEX $idx\" }\n}\n\n\n#-------------------------------------------------------------------------\n# If a test script is executed with global variable $::G(perm:name) set to\n# \"wal\", then the tests are run in WAL mode. Otherwise, they should be run\n# in rollback mode. The following Tcl procs are used to make this less\n# intrusive:\n#\n#   wal_set_journal_mode ?DB?\n#\n#     If running a WAL test, execute \"PRAGMA journal_mode = wal\" using\n#     connection handle DB. Otherwise, this command is a no-op.\n#\n#   wal_check_journal_mode TESTNAME ?DB?\n#\n#     If running a WAL test, execute a tests case that fails if the main\n#     database for connection handle DB is not currently a WAL database.\n#     Otherwise (if not running a WAL permutation) this is a no-op.\n#\n#   wal_is_wal_mode\n#\n#     Returns true if this test should be run in WAL mode. False otherwise.\n#\nproc wal_is_wal_mode {} {\n  expr {[permutation] eq \"wal\"}\n}\nproc wal_set_journal_mode {{db db}} {\n  if { [wal_is_wal_mode] } {\n    $db eval \"PRAGMA journal_mode = WAL\"\n  }\n}\nproc wal_check_journal_mode {testname {db db}} {\n  if { [wal_is_wal_mode] } {\n    $db eval { SELECT * FROM sqlite_master }\n    do_test $testname [list $db eval \"PRAGMA main.journal_mode\"] {wal}\n  }\n}\n\nproc wal_is_capable {} {\n  ifcapable !wal { return 0 }\n  if {[permutation]==\"journaltest\"} { return 0 }\n  return 1\n}\n\nproc permutation {} {\n  set perm \"\"\n  catch {set perm $::G(perm:name)}\n  set perm\n}\nproc presql {} {\n  set presql \"\"\n  catch {set presql $::G(perm:presql)}\n  set presql\n}\n\nproc isquick {} {\n  set ret 0\n  catch {set ret $::G(isquick)}\n  set ret\n}\n\n#-------------------------------------------------------------------------\n#\nproc slave_test_script {script} {\n\n  # Create the interpreter used to run the test script.\n  interp create tinterp\n\n  # Populate some global variables that tester.tcl expects to see.\n  foreach {var value} [list              \\\n    ::argv0 $::argv0                     \\\n    ::argv  {}                           \\\n    ::SLAVE 1                            \\\n  ] {\n    interp eval tinterp [list set $var $value]\n  }\n\n  # If output is being copied into a file, share the file-descriptor with\n  # the interpreter.\n  if {[info exists ::G(output_fd)]} {\n    interp share {} $::G(output_fd) tinterp\n  }\n\n  # The alias used to access the global test counters.\n  tinterp alias set_test_counter set_test_counter\n\n  # Set up the ::cmdlinearg array in the slave.\n  interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]]\n\n  # Set up the ::G array in the slave.\n  interp eval tinterp [list array set ::G [array get ::G]]\n\n  # Load the various test interfaces implemented in C.\n  load_testfixture_extensions tinterp\n\n  # Run the test script.\n  interp eval tinterp $script\n\n  # Check if the interpreter call [run_thread_tests]\n  if { [interp eval tinterp {info exists ::run_thread_tests_called}] } {\n    set ::run_thread_tests_called 1\n  }\n\n  # Delete the interpreter used to run the test script.\n  interp delete tinterp\n}\n\nproc slave_test_file {zFile} {\n  set tail [file tail $zFile]\n\n  if {[info exists ::G(start:permutation)]} {\n    if {[permutation] != $::G(start:permutation)} return\n    unset ::G(start:permutation)\n  }\n  if {[info exists ::G(start:file)]} {\n    if {$tail != $::G(start:file) && $tail!=\"$::G(start:file).test\"} return\n    unset ::G(start:file)\n  }\n\n  # Remember the value of the shared-cache setting. So that it is possible\n  # to check afterwards that it was not modified by the test script.\n  #\n  ifcapable shared_cache { set scs [sqlite3_enable_shared_cache] }\n\n  # Run the test script in a slave interpreter.\n  #\n  unset -nocomplain ::run_thread_tests_called\n  reset_prng_state\n  set ::sqlite_open_file_count 0\n  set time [time { slave_test_script [list source $zFile] }]\n  set ms [expr [lindex $time 0] / 1000]\n\n  # Test that all files opened by the test script were closed. Omit this\n  # if the test script has \"thread\" in its name. The open file counter\n  # is not thread-safe.\n  #\n  if {[info exists ::run_thread_tests_called]==0} {\n    do_test ${tail}-closeallfiles { expr {$::sqlite_open_file_count>0} } {0}\n  }\n  set ::sqlite_open_file_count 0\n\n  # Test that the global \"shared-cache\" setting was not altered by\n  # the test script.\n  #\n  ifcapable shared_cache {\n    set res [expr {[sqlite3_enable_shared_cache] == $scs}]\n    do_test ${tail}-sharedcachesetting [list set {} $res] 1\n  }\n\n  # Add some info to the output.\n  #\n  output2 \"Time: $tail $ms ms\"\n  show_memstats\n}\n\n# Open a new connection on database test.db and execute the SQL script\n# supplied as an argument. Before returning, close the new conection and\n# restore the 4 byte fields starting at header offsets 28, 92 and 96\n# to the values they held before the SQL was executed. This simulates\n# a write by a pre-3.7.0 client.\n#\nproc sql36231 {sql} {\n  set B [hexio_read test.db 92 8]\n  set A [hexio_read test.db 28 4]\n  sqlite3 db36231 test.db\n  catch { db36231 func a_string a_string }\n  execsql $sql db36231\n  db36231 close\n  hexio_write test.db 28 $A\n  hexio_write test.db 92 $B\n  return \"\"\n}\n\nproc db_save {} {\n  foreach f [glob -nocomplain sv_test.db*] { forcedelete $f }\n  foreach f [glob -nocomplain test.db*] {\n    set f2 \"sv_$f\"\n    forcecopy $f $f2\n  }\n}\nproc db_save_and_close {} {\n  db_save\n  catch { db close }\n  return \"\"\n}\nproc db_restore {} {\n  foreach f [glob -nocomplain test.db*] { forcedelete $f }\n  foreach f2 [glob -nocomplain sv_test.db*] {\n    set f [string range $f2 3 end]\n    forcecopy $f2 $f\n  }\n}\nproc db_restore_and_reopen {{dbfile test.db}} {\n  catch { db close }\n  db_restore\n  sqlite3 db $dbfile\n}\nproc db_delete_and_reopen {{file test.db}} {\n  catch { db close }\n  foreach f [glob -nocomplain test.db*] { forcedelete $f }\n  sqlite3 db $file\n}\n\n# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config\n# to configure the size of the PAGECACHE allocation using the parameters\n# provided to this command. Save the old PAGECACHE parameters in a global \n# variable so that [test_restore_config_pagecache] can restore the previous\n# configuration.\n#\n# Before returning, reopen connection [db] on file test.db.\n#\nproc test_set_config_pagecache {sz nPg} {\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n\n  sqlite3_shutdown\n  set ::old_pagecache_config [sqlite3_config_pagecache $sz $nPg]\n  sqlite3_initialize\n  autoinstall_test_functions\n  reset_db\n}\n\n# Close any connections named [db], [db2] or [db3]. Then use sqlite3_config\n# to configure the size of the PAGECACHE allocation to the size saved in\n# the global variable by an earlier call to [test_set_config_pagecache].\n#\n# Before returning, reopen connection [db] on file test.db.\n#\nproc test_restore_config_pagecache {} {\n  catch {db close}\n  catch {db2 close}\n  catch {db3 close}\n\n  sqlite3_shutdown\n  eval sqlite3_config_pagecache $::old_pagecache_config\n  unset ::old_pagecache_config \n  sqlite3_initialize\n  autoinstall_test_functions\n  sqlite3 db test.db\n}\n\nproc test_find_binary {nm} {\n  if {$::tcl_platform(platform)==\"windows\"} {\n    set ret \"$nm.exe\"\n  } else {\n    set ret $nm\n  }\n  set ret [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]]\n  if {![file executable $ret]} {\n    finish_test\n    return \"\"\n  }\n  return $ret\n}\n\n# Find the name of the 'shell' executable (e.g. \"sqlite3.exe\") to use for\n# the tests in shell[1-5].test. If no such executable can be found, invoke\n# [finish_test ; return] in the callers context.\n#\nproc test_find_cli {} {\n  set prog [test_find_binary sqlite3]\n  if {$prog==\"\"} { return -code return }\n  return $prog\n}\n\n# Find the name of the 'sqldiff' executable (e.g. \"sqlite3.exe\") to use for\n# the tests in sqldiff tests. If no such executable can be found, invoke\n# [finish_test ; return] in the callers context.\n#\nproc test_find_sqldiff {} {\n  set prog [test_find_binary sqldiff]\n  if {$prog==\"\"} { return -code return }\n  return $prog\n}\n\n\n# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set\n# to non-zero, then set the global variable $AUTOVACUUM to 1.\nset AUTOVACUUM $sqlite_options(default_autovacuum)\n\n# Make sure the FTS enhanced query syntax is disabled.\nset sqlite_fts3_enable_parentheses 0\n\n# During testing, assume that all database files are well-formed.  The\n# few test cases that deliberately corrupt database files should rescind \n# this setting by invoking \"database_can_be_corrupt\"\n#\ndatabase_never_corrupt\n\nsource $testdir/thread_common.tcl\nsource $testdir/malloc_common.tcl\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread001.test",
    "content": "# 2007 September 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: thread001.test,v 1.10 2009/03/26 14:48:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache]\n\nset ::NTHREAD 10\n\n# Run this test three times: \n# \n#    1) All threads use the same database handle.\n#    2) All threads use their own database handles.\n#    3) All threads use their own database handles, shared-cache is enabled.\n#\n#\n#\nforeach {tn same_db shared_cache} [list \\\n         1  1       0                   \\\n         2  0       0                   \\\n         3  0       1                   \\\n] {\n  # Empty the database.\n  #\n  catchsql { DROP TABLE ab; }\n\n  do_test thread001.$tn.0 {\n    db close\n    sqlite3_enable_shared_cache $shared_cache\n    sqlite3_enable_shared_cache $shared_cache\n  } $shared_cache\n  sqlite3 db test.db -fullmutex 1 -key xyzzy\n\n  set dbconfig \"\"\n  if {$same_db} {\n    set dbconfig [list set ::DB [sqlite3_connection_pointer db]]\n  }\n\n  # Set up a database and a schema. The database contains a single\n  # table with two columns. The first column (\"a\") is an INTEGER PRIMARY \n  # KEY. The second contains the md5sum of all rows in the table with\n  # a smaller value stored in column \"a\".\n  #\n  do_test thread001.$tn.1 {\n    execsql {\n      CREATE TABLE ab(a INTEGER PRIMARY KEY, b);\n      CREATE INDEX ab_i ON ab(b);\n      INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab;\n      SELECT count(*) FROM ab;\n    }\n  } {1}\n  do_test thread001.$tn.2 {\n    execsql {\n      SELECT \n        (SELECT md5sum(a, b) FROM ab WHERE a < (SELECT max(a) FROM ab)) ==\n        (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))\n    }\n  } {1}\n  do_test thread001.$tn.3 {\n    execsql { PRAGMA integrity_check }\n  } {ok}\n\n  set thread_program {\n    #sqlthread parent {puts STARTING..}\n    set needToClose 0\n    if {![info exists ::DB]} {\n      set ::DB [sqlthread open test.db xyzzy]\n      #sqlthread parent \"puts \\\"OPEN $::DB\\\"\"\n      set needToClose 1\n    }\n  \n    for {set i 0} {$i < 100} {incr i} {\n      # Test that the invariant is true.\n      do_test t1 {\n        execsql {\n          SELECT \n            (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) ==\n            (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))\n        }\n      } {1}\n  \n      # Add another row to the database.\n      execsql { INSERT INTO ab SELECT NULL, md5sum(a, b) FROM ab }\n    }\n  \n    if {$needToClose} {\n      #sqlthread parent \"puts \\\"CLOSE $::DB\\\"\"\n      sqlite3_close $::DB\n    }\n    #sqlthread parent \"puts \\\"DONE\\\"\"\n  \n    list OK\n  }\n  \n  # Kick off $::NTHREAD threads:\n  #\n  array unset finished\n  for {set i 0} {$i < $::NTHREAD} {incr i} {\n    thread_spawn finished($i) $dbconfig $thread_procs $thread_program\n  }\n  \n  # Wait for all threads to finish,  then check they all returned \"OK\".\n  #\n  for {set i 0} {$i < $::NTHREAD} {incr i} {\n    if {![info exists finished($i)]} {\n      vwait finished($i)\n    }\n    do_test thread001.$tn.4.$i {\n      set ::finished($i)\n    } OK\n  }\n  \n  # Check the database still looks Ok.\n  #\n  do_test thread001.$tn.5 {\n    execsql { SELECT count(*) FROM ab; }\n  } [expr {1 + $::NTHREAD*100}]\n  do_test thread001.$tn.6 {\n    execsql {\n      SELECT \n        (SELECT md5sum(a, b) FROM ab WHERE +a < (SELECT max(a) FROM ab)) ==\n        (SELECT b FROM ab WHERE a = (SELECT max(a) FROM ab))\n    }\n  } {1}\n  do_test thread001.$tn.7 {\n    execsql { PRAGMA integrity_check }\n  } {ok}\n}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nset sqlite_open_file_count 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread002.test",
    "content": "# 2007 September 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#   This test attempts to deadlock SQLite in shared-cache mode.\n#     \n#\n# $Id: thread002.test,v 1.9 2009/03/26 14:48:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\n\nset do_not_use_codec 1\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\n\n\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\nset ::NTHREAD 10\n\ndo_test thread002.1 {\n  # Create 3 databases with identical schemas:\n  for {set ii 0} {$ii < 3} {incr ii} {\n    forcedelete test${ii}.db\n    sqlite3 db test${ii}.db\n    execsql {\n      CREATE TABLE t1(k, v);\n      CREATE INDEX t1_i ON t1(v);\n      INSERT INTO t1(v) VALUES(1.0);\n    }\n    db close\n  }\n} {}\n\nset thread_program {\n  set ::DB [sqlite3_open test.db]\n  for {set ii 1} {$ii <= 3} {incr ii} {\n    set T [lindex $order [expr $ii-1]]\n    execsql \"ATTACH 'test${T}.db' AS aux${ii}\"\n  }\n\n  for {set ii 0} {$ii < 100} {incr ii} {\n    execsql { SELECT * FROM aux1.t1 }\n    execsql { INSERT INTO aux1.t1(v) SELECT sum(v) FROM aux2.t1 }\n  \n    execsql { SELECT * FROM aux2.t1 }\n    execsql { INSERT INTO aux2.t1(v) SELECT sum(v) FROM aux3.t1 }\n  \n    execsql { SELECT * FROM aux3.t1 }\n    execsql { INSERT INTO aux3.t1(v) SELECT sum(v) FROM aux1.t1 }\n\n    execsql { CREATE TABLE IF NOT EXISTS aux1.t2(a,b) }\n    execsql { DROP TABLE IF EXISTS aux1.t2 }\n\n    # if {($ii%10)==0} {puts -nonewline . ; flush stdout}\n    puts -nonewline . ; flush stdout\n  }\n\n  sqlite3_close $::DB\n  list OK\n}\n\nset order_list [list {0 1 2} {0 2 1} {1 0 2} {1 2 0} {2 0 1} {2 1 0}]\n\narray unset finished\nfor {set ii 0} {$ii < $::NTHREAD} {incr ii} {\n  set order [lindex $order_list [expr $ii%6]]\n  thread_spawn finished($ii) $thread_procs \"set order {$order}\" $thread_program\n}\n\n# Wait for all threads to finish,  then check they all returned \"OK\".\n#\nfor {set i 0} {$i < $::NTHREAD} {incr i} {\n  if {![info exists finished($i)]} {\n    vwait finished($i)\n  }\n  do_test thread002.2.$i {\n    set ::finished($i)\n  } OK\n}\n\n# Check all three databases are Ok.\nfor {set ii 0} {$ii < 3} {incr ii} {\n  do_test thread002.3.$ii {\n    sqlite3 db test${ii}.db\n    set res [list                         \\\n      [execsql {SELECT count(*) FROM t1}] \\\n      [execsql {PRAGMA integrity_check}]  \\\n    ]\n    db close\n    set res\n  } [list [expr 1 + $::NTHREAD*100] ok]\n}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nset sqlite_open_file_count 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread003.test",
    "content": "# 2007 September 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#   This file contains tests that attempt to break the pcache module\n#   by bombarding it with simultaneous requests from multiple threads.\n#     \n# $Id: thread003.test,v 1.8 2009/03/26 14:48:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\n\n# Set up a couple of different databases full of pseudo-randomly \n# generated data.\n#\ndo_test thread003.1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n  }\n  for {set ii 0} {$ii < 5000} {incr ii} {\n    execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))}\n  }\n  execsql { \n    CREATE INDEX i1 ON t1(a, b); \n    COMMIT;\n  }\n} {}\ndo_test thread003.1.2 {\n  expr {([file size test.db] / 1024) > 2000}\n} {1}\ndo_test thread003.1.3 {\n  db close\n  forcedelete test2.db\n  sqlite3 db test2.db\n} {}\ndo_test thread003.1.4 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n  }\n  for {set ii 0} {$ii < 5000} {incr ii} {\n    execsql {INSERT INTO t1 VALUES($ii, randomblob(200), randomblob(200))}\n  }\n  execsql { \n    CREATE INDEX i1 ON t1(a, b); \n    COMMIT;\n  }\n} {}\ndo_test thread003.1.5 {\n  expr {([file size test.db] / 1024) > 2000}\n} {1}\ndo_test thread003.1.6 {\n  db close\n} {}\n\n\n# This test opens a connection on each of the large (>2MB) database files\n# created by the previous block. The connections do not share a cache.\n# Both \"cache_size\" parameters are set to 15, so there is a maximum of\n# 30 pages available globally.\n#\n# Then, in separate threads, the databases are randomly queried over and\n# over again. This will force the connections to recycle clean pages from\n# each other. If there is a thread-safety problem, a segfault or assertion\n# failure may eventually occur.\n#\nset nSecond 30\nputs \"Starting thread003.2 (should run for ~$nSecond seconds)\"\ndo_test thread003.2 {\n  foreach zFile {test.db test2.db} {\n    set SCRIPT [format {\n      set iEnd [expr {[clock_seconds] + %d}]\n      set ::DB [sqlthread open %s xyzzy]\n  \n      # Set the cache size to 15 pages per cache. 30 available globally.\n      execsql { PRAGMA cache_size = 15 }\n  \n      while {[clock_seconds] < $iEnd} {\n        set iQuery [expr {int(rand()*5000)}]\n        execsql \" SELECT * FROM t1 WHERE a = $iQuery \"\n      }\n  \n      sqlite3_close $::DB\n      expr 1\n    } $nSecond $zFile]\n  \n    unset -nocomplain finished($zFile)\n    thread_spawn finished($zFile) $thread_procs $SCRIPT\n  }\n  foreach zFile {test.db test2.db} {\n    if {![info exists finished($zFile)]} {\n      vwait finished($zFile)\n    }\n  }\n  expr 0\n} {0}\n\n# This test is the same as the test above, except that each thread also\n# writes to the database. This causes pages to be moved back and forth \n# between the caches internal dirty and clean lists, which is another\n# opportunity for a thread-related bug to present itself.\n#\nset nSecond 30\nputs \"Starting thread003.3 (should run for ~$nSecond seconds)\"\ndo_test thread003.3 {\n  foreach zFile {test.db test2.db} {\n    set SCRIPT [format {\n      set iStart [clock_seconds]\n      set iEnd [expr {[clock_seconds] + %d}]\n      set ::DB [sqlthread open %s xyzzy]\n  \n      # Set the cache size to 15 pages per cache. 30 available globally.\n      execsql { PRAGMA cache_size = 15 }\n  \n      while {[clock_seconds] < $iEnd} {\n        set iQuery [expr {int(rand()*5000)}]\n        execsql \"SELECT * FROM t1 WHERE a = $iQuery\"\n        execsql \"UPDATE t1 SET b = randomblob(200) \n                 WHERE a < $iQuery AND a > $iQuery + 20\n        \"\n      }\n  \n      sqlite3_close $::DB\n      expr 1\n    } $nSecond $zFile]\n  \n    unset -nocomplain finished($zFile)\n    thread_spawn finished($zFile) $thread_procs $SCRIPT\n  }\n  foreach zFile {test.db test2.db} {\n    if {![info exists finished($zFile)]} {\n      vwait finished($zFile)\n    }\n  }\n  expr 0\n} {0}\n\n# In this test case, one thread is continually querying the database.\n# The other thread does not have a database connection, but calls\n# sqlite3_release_memory() over and over again.\n#\nset nSecond 30\nputs \"Starting thread003.4 (should run for ~$nSecond seconds)\"\nunset -nocomplain finished(1)\nunset -nocomplain finished(2)\ndo_test thread003.4 {\n  thread_spawn finished(1) $thread_procs [format {\n    set iEnd [expr {[clock_seconds] + %d}]\n    set ::DB [sqlthread open test.db xyzzy]\n\n    # Set the cache size to 15 pages per cache. 30 available globally.\n    execsql { PRAGMA cache_size = 15 }\n\n    while {[clock_seconds] < $iEnd} {\n      set iQuery [expr {int(rand()*5000)}]\n      execsql \"SELECT * FROM t1 WHERE a = $iQuery\"\n    }\n\n    sqlite3_close $::DB\n    expr 1\n  } $nSecond] \n  thread_spawn finished(2) [format {\n    set iEnd [expr {[clock_seconds] + %d}]\n\n    while {[clock_seconds] < $iEnd} {\n      sqlite3_release_memory 1000\n    }\n  } $nSecond]\n  \n  foreach ii {1 2} {\n    if {![info exists finished($ii)]} {\n      vwait finished($ii)\n    }\n  }\n  expr 0\n} {0}\n\nset sqlite_open_file_count 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread004.test",
    "content": "# 2009 February 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: thread004.test,v 1.3 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\nifcapable !shared_cache {\n  finish_test\n  return\n}\nif { [info commands sqlite3_table_column_metadata] eq \"\" } {\n  finish_test\n  return\n}\n\n# Use shared-cache mode for this test.\n# \ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache]\nsqlite3_enable_shared_cache 1\n\n# Create a table in database test.db\n#\nsqlite3 db test.db\ndo_test thread004-1.1 {\n  execsql { CREATE TABLE t1(a, b, c) }\n} {}\n\ndo_test thread004-1.2 {\n\n  set ThreadOne {\n    set iStart [clock_seconds]\n    while {[clock_seconds]<$iStart+20} {\n      set ::DB [sqlite3_open test.db]\n      sqlite3_close $::DB\n    }\n  }\n  set ThreadTwo {\n    set ::DB [sqlite3_open test.db]\n    set iStart [clock_seconds]\n    set nErr 0\n    while {[clock_seconds] <$iStart+20} {\n      incr nErr [catch {sqlite3_table_column_metadata $::DB main t1 a}]\n    }\n    sqlite3_close $::DB\n    set nErr\n  }\n  \n  # Run two threads. The first thread opens and closes database test.db\n  # repeatedly. Each time this happens, the in-memory schema used by\n  # all connections to test.db is discarded.\n  #\n  # The second thread calls sqlite3_table_column_metadata() over and\n  # over again. Each time it is called, the database schema is loaded\n  # if it is not already in memory. At one point this was crashing.\n  #\n  unset -nocomplain finished\n  thread_spawn finished(1) $thread_procs $ThreadOne\n  thread_spawn finished(2) $thread_procs $ThreadTwo\n  \n  foreach t {1 2} {\n    if {![info exists finished($t)]} { vwait finished($t) }\n  }\n\n  set finished(2)\n} {0}\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread005.test",
    "content": "# 2009 March 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test a race-condition that shows up in shared-cache mode.\n#\n# $Id: thread005.test,v 1.5 2009/03/26 14:48:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\nifcapable !shared_cache {\n  finish_test\n  return\n}\n\ndb close\n\n# Use shared-cache mode for these tests.\n# \nset ::enable_shared_cache [sqlite3_enable_shared_cache]\nsqlite3_enable_shared_cache 1\n\n#-------------------------------------------------------------------------\n# This test attempts to hit the race condition fixed by commit [6363].\n#\nproc runsql {zSql {db {}}} {\n  set rc SQLITE_OK\n  while {$rc==\"SQLITE_OK\" && $zSql ne \"\"} {\n    set STMT [sqlite3_prepare_v2 $db $zSql -1 zSql]\n    while {[set rc [sqlite3_step $STMT]] eq \"SQLITE_ROW\"} { }\n    set rc [sqlite3_finalize $STMT]\n  }\n  return $rc\n}\ndo_test thread005-1.1 {\n  sqlite3 db test.db\n  db eval { CREATE TABLE t1(a, b) }\n  db close\n} {}\nfor {set ii 2} {$ii < 500} {incr ii} {\n  unset -nocomplain finished\n  thread_spawn finished(0) {sqlite3_open test.db}\n  thread_spawn finished(1) {sqlite3_open test.db}\n  if {![info exists finished(0)]} { vwait finished(0) }\n  if {![info exists finished(1)]} { vwait finished(1) }\n\n  do_test thread005-1.$ii {\n    runsql { BEGIN }                       $finished(0)\n    runsql { INSERT INTO t1 VALUES(1, 2) } $finished(0)\n\n    # If the race-condition was hit, then $finished(0 and $finished(1)\n    # will not use the same pager cache. In this case the next statement\n    # can be executed succesfully. However, if the race-condition is not\n    # hit, then $finished(1) will be blocked by the write-lock held by \n    # $finished(0) on the shared-cache table t1 and the statement will\n    # return SQLITE_LOCKED.\n    #\n    runsql { SELECT * FROM t1 }            $finished(1)\n  } {SQLITE_LOCKED}\n\n  sqlite3_close $finished(0)\n  sqlite3_close $finished(1)\n}\n\n\n#-------------------------------------------------------------------------\n# This test tries to exercise a race-condition that existed in shared-cache\n# mode at one point. The test uses two threads; each has a database connection\n# open on the same shared cache. The schema of the database is:\n#\n#    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n#\n# One thread is a reader and the other thread a reader and a writer. The \n# writer thread repeats the following transaction as fast as possible:\n# \n#      BEGIN;\n#        DELETE FROM t1 WHERE a = (SELECT max(a) FROM t1);\n#        INSERT INTO t1 VALUES(NULL, NULL);\n#        UPDATE t1 SET b = a WHERE a = (SELECT max(a) FROM t1);\n#        SELECT count(*) FROM t1 WHERE b IS NULL;\n#      COMMIT;\n#\n# The reader thread does the following over and over as fast as possible:\n#\n#      BEGIN;\n#        SELECT count(*) FROM t1 WHERE b IS NULL;\n#      COMMIT;\n#\n# The test runs for 20 seconds or until one of the \"SELECT count(*)\" \n# statements returns a non-zero value. If an SQLITE_LOCKED error occurs,\n# the connection issues a ROLLBACK immediately to abandon the current\n# transaction.\n#\n# If everything is working correctly, the \"SELECT count(*)\" statements \n# should never return a value other than 0. The \"INSERT\" statement \n# executed by the writer adds a row with \"b IS NULL\" to the table, but\n# the subsequent UPDATE statement sets its \"b\" value to an integer\n# immediately afterwards.\n#\n# However, before the race-condition was fixed, if the reader's SELECT\n# statement hit an error (say an SQLITE_LOCKED) at the same time as the\n# writer was executing the UPDATE statement, then it could incorrectly\n# rollback the statement-transaction belonging to the UPDATE statement.\n# The UPDATE statement would still be reported as successful to the user,\n# but it would have no effect on the database contents.\n# \n# Note that it has so far only proved possible to hit this race-condition\n# when using an ATTACHed database. There doesn't seem to be any reason\n# for this, other than that operating on an ATTACHed database means there\n# are a few more mutex grabs and releases during the window of time open\n# for the race-condition. Maybe this encourages the scheduler to context\n# switch or something...\n#\n\nforcedelete test.db test2.db\nunset -nocomplain finished\n\ndo_test thread005-2.1 {\n  sqlite3 db test.db\n  execsql { ATTACH 'test2.db' AS aux }\n  execsql {\n    CREATE TABLE aux.t1(a INTEGER PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 2);\n  }\n  db close\n} {}\n\n\nset ThreadProgram {\n  proc execsql {zSql {db {}}} {\n    if {$db eq \"\"} {set db $::DB}\n\n    set lRes [list]\n    set rc SQLITE_OK\n\n    while {$rc==\"SQLITE_OK\" && $zSql ne \"\"} {\n      set STMT [sqlite3_prepare_v2 $db $zSql -1 zSql]\n      while {[set rc [sqlite3_step $STMT]] eq \"SQLITE_ROW\"} {\n        for {set i 0} {$i < [sqlite3_column_count $STMT]} {incr i} {\n          lappend lRes [sqlite3_column_text $STMT 0]\n        }\n      }\n      set rc [sqlite3_finalize $STMT]\n    }\n\n    if {$rc != \"SQLITE_OK\"} { error \"$rc [sqlite3_errmsg $db]\" }\n    return $lRes\n  }\n\n  if {$isWriter} {\n    set Sql {\n      BEGIN;\n        DELETE FROM t1 WHERE a = (SELECT max(a) FROM t1);\n        INSERT INTO t1 VALUES(NULL, NULL);\n        UPDATE t1 SET b = a WHERE a = (SELECT max(a) FROM t1);\n        SELECT count(*) FROM t1 WHERE b IS NULL;\n      COMMIT;\n    }\n  } else {\n    set Sql {\n      BEGIN;\n      SELECT count(*) FROM t1 WHERE b IS NULL;\n      COMMIT;\n    }\n  }\n\n  set ::DB [sqlite3_open test.db]\n\n  execsql { ATTACH 'test2.db' AS aux }\n\n  set result \"ok\"\n  set finish [expr [clock_seconds]+5]\n  while {$result eq \"ok\" && [clock_seconds] < $finish} {\n    set rc [catch {execsql $Sql} msg]\n    if {$rc} {\n      if {[string match \"SQLITE_LOCKED*\" $msg]} {\n        catch { execsql ROLLBACK }\n      } else {\n        sqlite3_close $::DB\n        error $msg\n      }\n    } elseif {$msg ne \"0\"} {\n      set result \"failed\"\n    }\n  }\n\n  sqlite3_close $::DB\n  set result\n}\n\n# There is a race-condition in btree.c that means that if two threads\n# attempt to open the same database at roughly the same time, and there\n# does not already exist a shared-cache corresponding to that database,\n# then two shared-caches can be created instead of one. Things still more\n# or less work, but the two database connections do not use the same\n# shared-cache.\n#\n# If the threads run by this test hit this race-condition, the tests\n# fail (because SQLITE_BUSY may be unexpectedly returned instead of\n# SQLITE_LOCKED). To prevent this from happening, open a couple of\n# connections to test.db and test2.db now to make sure that there are\n# already shared-caches in memory for all databases opened by the\n# test threads.\n#\nsqlite3 db test.db\nsqlite3 db test2.db\n\nputs \"Running thread-tests for ~20 seconds\"\nthread_spawn finished(0) {set isWriter 0} $ThreadProgram\nthread_spawn finished(1) {set isWriter 1} $ThreadProgram\nif {![info exists finished(0)]} { vwait finished(0) }\nif {![info exists finished(1)]} { vwait finished(1) }\n\ncatch { db close }\ncatch { db2 close }\n\ndo_test thread005-2.2 {\n  list $finished(0) $finished(1)\n} {ok ok}\n\ndo_test thread005-2.3 {\n  sqlite3 db test.db\n  execsql { ATTACH 'test2.db' AS aux }\n  execsql { SELECT count(*) FROM t1 WHERE b IS NULL }\n} {0}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread1.test",
    "content": "# 2003 December 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is multithreading behavior\n#\n# $Id: thread1.test,v 1.8 2008/10/07 15:25:49 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Skip this whole file if the thread testing code is not enabled\n#\nif {[run_thread_tests]==0} { finish_test ; return }\nif {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} {\n  finish_test\n  return\n}\n\n# Create some data to work with\n#\ndo_test thread1-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,'abcdefgh');\n    INSERT INTO t1 SELECT a+1, b||b FROM t1;\n    INSERT INTO t1 SELECT a+2, b||b FROM t1;\n    INSERT INTO t1 SELECT a+4, b||b FROM t1;\n    SELECT count(*), max(length(b)) FROM t1;\n  }\n} {8 64}\n\n# Interleave two threads on read access.  Then make sure a third\n# thread can write the database.  In other words:\n#\n#    read-lock A\n#    read-lock B\n#    unlock A\n#    unlock B\n#    write-lock C\n#\n# At one point, the write-lock of C would fail on Linux. \n#\ndo_test thread1-1.2 {\n  thread_create A test.db\n  thread_create B test.db\n  thread_create C test.db\n  thread_compile A {SELECT a FROM t1}\n  thread_step A\n  thread_result A\n} SQLITE_ROW\ndo_test thread1-1.3 {\n  thread_argc A\n} 1\ndo_test thread1-1.4 {\n  thread_argv A 0\n} 1\ndo_test thread1-1.5 {\n  thread_compile B {SELECT b FROM t1}\n  thread_step B\n  thread_result B\n} SQLITE_ROW\ndo_test thread1-1.6 {\n  thread_argc B\n} 1\ndo_test thread1-1.7 {\n  thread_argv B 0\n} abcdefgh\ndo_test thread1-1.8 {\n  thread_finalize A\n  thread_result A\n} SQLITE_OK\ndo_test thread1-1.9 {\n  thread_finalize B\n  thread_result B\n} SQLITE_OK\ndo_test thread1-1.10 {\n  thread_compile C {CREATE TABLE t2(x,y)}\n  thread_step C\n  thread_result C\n} SQLITE_DONE\ndo_test thread1-1.11 {\n  thread_finalize C\n  thread_result C\n} SQLITE_OK\ndo_test thread1-1.12 {\n  catchsql {SELECT name FROM sqlite_master}\n  execsql {SELECT name FROM sqlite_master}\n} {t1 t2}\n\n\n#\n# The following tests - thread1-2.* - test the following scenario:\n#\n# 1:  Read-lock thread A\n# 2:  Read-lock thread B\n# 3:  Attempt to write in thread C -> SQLITE_BUSY\n# 4:  Check db write failed from main thread.\n# 5:  Unlock from thread A.\n# 6:  Attempt to write in thread C -> SQLITE_BUSY\n# 7:  Check db write failed from main thread.\n# 8:  Unlock from thread B.\n# 9:  Attempt to write in thread C -> SQLITE_DONE\n# 10: Finalize the write from thread C\n# 11: Check db write succeeded from main thread.\n#\ndo_test thread1-2.1 {\n  thread_halt *\n  thread_create A test.db\n  thread_compile A {SELECT a FROM t1}\n  thread_step A\n  thread_result A\n} SQLITE_ROW\ndo_test thread1-2.2 {\n  thread_create B test.db\n  thread_compile B {SELECT b FROM t1}\n  thread_step B\n  thread_result B\n} SQLITE_ROW\ndo_test thread1-2.3 {\n  thread_create C test.db\n  thread_compile C {INSERT INTO t2 VALUES(98,99)}\n  thread_step C\n  thread_result C\n  thread_finalize C\n  thread_result C\n} SQLITE_BUSY\n\ndo_test thread1-2.4 {\n  execsql {SELECT * FROM t2}\n} {}\n\ndo_test thread1-2.5 {\n  thread_finalize A\n  thread_result A\n} SQLITE_OK\ndo_test thread1-2.6 {\n  thread_compile C {INSERT INTO t2 VALUES(98,99)}\n  thread_step C\n  thread_result C\n  thread_finalize C\n  thread_result C\n} SQLITE_BUSY\ndo_test thread1-2.7 {\n  execsql {SELECT * FROM t2}\n} {}\ndo_test thread1-2.8 {\n  thread_finalize B\n  thread_result B\n} SQLITE_OK\ndo_test thread1-2.9 {\n  thread_compile C {INSERT INTO t2 VALUES(98,99)}\n  thread_step C\n  thread_result C\n} SQLITE_DONE\ndo_test thread1-2.10 {\n  thread_finalize C\n  thread_result C\n} SQLITE_OK\ndo_test thread1-2.11 {\n  execsql {SELECT * FROM t2}\n} {98 99}\n\nthread_halt *   \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread2.test",
    "content": "# 2006 January 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is multithreading behavior\n#\n# $Id: thread2.test,v 1.3 2008/10/07 15:25:49 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[run_thread_tests]==0} { finish_test ; return }\n\n# Skip this whole file if the thread testing code is not enabled\n#\nif {[llength [info command thread_step]]==0 || [sqlite3 -has-codec]} {\n  finish_test\n  return\n}\n\n# Create some data to work with\n#\ndo_test thread1-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,'abcdefgh');\n    INSERT INTO t1 SELECT a+1, b||b FROM t1;\n    INSERT INTO t1 SELECT a+2, b||b FROM t1;\n    INSERT INTO t1 SELECT a+4, b||b FROM t1;\n    SELECT count(*), max(length(b)) FROM t1;\n  }\n} {8 64}\n\n# Use the thread_swap command to move the database connections between\n# threads, then verify that they still work.\n#\ndo_test thread2-1.2 {\n  db close\n  thread_create A test.db\n  thread_create B test.db\n  thread_swap A B\n  thread_compile A {SELECT a FROM t1 LIMIT 1}\n  thread_result A\n} {SQLITE_OK}\ndo_test thread2-1.3 {\n  thread_step A\n  thread_result A\n} {SQLITE_ROW}\ndo_test thread2-1.4 {\n  thread_argv A 0\n} {1}\ndo_test thread2-1.5 {\n  thread_finalize A\n  thread_result A\n} {SQLITE_OK}\ndo_test thread2-1.6 {\n  thread_compile B {SELECT a FROM t1 LIMIT 1}\n  thread_result B\n} {SQLITE_OK}\ndo_test thread2-1.7 {\n  thread_step B\n  thread_result B\n} {SQLITE_ROW}\ndo_test thread2-1.8 {\n  thread_argv B 0\n} {1}\ndo_test thread2-1.9 {\n  thread_finalize B\n  thread_result B\n} {SQLITE_OK}\n\n# Swap them again.\n#\ndo_test thread2-2.2 {\n  thread_swap A B\n  thread_compile A {SELECT a FROM t1 LIMIT 1}\n  thread_result A\n} {SQLITE_OK}\ndo_test thread2-2.3 {\n  thread_step A\n  thread_result A\n} {SQLITE_ROW}\ndo_test thread2-2.4 {\n  thread_argv A 0\n} {1}\ndo_test thread2-2.5 {\n  thread_finalize A\n  thread_result A\n} {SQLITE_OK}\ndo_test thread2-2.6 {\n  thread_compile B {SELECT a FROM t1 LIMIT 1}\n  thread_result B\n} {SQLITE_OK}\ndo_test thread2-2.7 {\n  thread_step B\n  thread_result B\n} {SQLITE_ROW}\ndo_test thread2-2.8 {\n  thread_argv B 0\n} {1}\ndo_test thread2-2.9 {\n  thread_finalize B\n  thread_result B\n} {SQLITE_OK}\nthread_halt A\nthread_halt B\n\n# Also important to halt the worker threads, which are using spin\n# locks and eating away CPU cycles.\n#\nthread_halt *   \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/thread_common.tcl",
    "content": "# 2007 September 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: thread_common.tcl,v 1.5 2009/03/26 14:48:07 danielk1977 Exp $\n\nif {[info exists ::thread_procs]} {\n  return 0\n}\n\n# The following script is sourced by every thread spawned using \n# [sqlthread spawn]:\nset thread_procs {\n\n  # Execute the supplied SQL using database handle $::DB.\n  #\n  proc execsql {sql} {\n\n    set rc SQLITE_LOCKED\n    while {$rc eq \"SQLITE_LOCKED\" \n        || $rc eq \"SQLITE_BUSY\" \n        || $rc eq \"SQLITE_SCHEMA\"} {\n      set res [list]\n\n      enter_db_mutex $::DB\n      set err [catch {\n        set ::STMT [sqlite3_prepare_v2 $::DB $sql -1 dummy_tail]\n      } msg]\n\n      if {$err == 0} {\n        while {[set rc [sqlite3_step $::STMT]] eq \"SQLITE_ROW\"} {\n          for {set i 0} {$i < [sqlite3_column_count $::STMT]} {incr i} {\n            lappend res [sqlite3_column_text $::STMT 0]\n          }\n        }\n        set rc [sqlite3_finalize $::STMT]\n      } else {\n        if {[lindex $msg 0]==\"(6)\"} {\n          set rc SQLITE_LOCKED\n        } else {\n          set rc SQLITE_ERROR\n        }\n      }\n\n      if {[string first locked [sqlite3_errmsg $::DB]]>=0} {\n        set rc SQLITE_LOCKED\n      }\n      if {$rc ne \"SQLITE_OK\"} {\n        set errtxt \"$rc - [sqlite3_errmsg $::DB] (debug1)\"\n      }\n      leave_db_mutex $::DB\n\n      if {$rc eq \"SQLITE_LOCKED\" || $rc eq \"SQLITE_BUSY\"} {\n        #sqlthread parent \"puts \\\"thread [sqlthread id] is busy.  rc=$rc\\\"\"\n        after 200\n      } else {\n        #sqlthread parent \"puts \\\"thread [sqlthread id] ran $sql\\\"\"\n      }\n    }\n\n    if {$rc ne \"SQLITE_OK\"} {\n      error $errtxt\n    }\n    set res\n  }\n\n  proc do_test {name script result} {\n    set res [eval $script]\n    if {$res ne $result} {\n      error \"$name failed: expected \\\"$result\\\" got \\\"$res\\\"\"\n    }\n  }\n}\n\nproc thread_spawn {varname args} {\n  sqlthread spawn $varname [join $args {;}]\n}\n\n# Return true if this build can run the multi-threaded tests.\n#\nproc run_thread_tests {{print_warning 0}} {\n  ifcapable !mutex { \n    set zProblem \"SQLite build is not threadsafe\"\n  }\n  ifcapable mutex_noop { \n    set zProblem \"SQLite build uses SQLITE_MUTEX_NOOP\"\n  }\n  if {[info commands sqlthread] eq \"\"} {\n    set zProblem \"SQLite build is not threadsafe\"\n  }\n  if {![info exists ::tcl_platform(threaded)]} {\n    set zProblem \"Linked against a non-threadsafe Tcl build\"\n  }\n  if {[info exists zProblem]} {\n    puts \"WARNING: Multi-threaded tests skipped: $zProblem\"\n    return 0\n  }\n  set ::run_thread_tests_called 1\n  return 1;\n}\n\nreturn 0\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/threadtest1.c",
    "content": "/*\n** 2002 January 15\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a simple standalone program used to test whether\n** or not the SQLite library is threadsafe.\n**\n** Testing the thread safety of SQLite is difficult because there are very\n** few places in the code that are even potentially unsafe, and those\n** places execute for very short periods of time.  So even if the library\n** is compiled with its mutexes disabled, it is likely to work correctly\n** in a multi-threaded program most of the time.  \n**\n** This file is NOT part of the standard SQLite library.  It is used for\n** testing only.\n*/\n#include \"sqlite.h\"\n#include <pthread.h>\n#include <sched.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n\n/*\n** Enable for tracing\n*/\nstatic int verbose = 0;\n\n/*\n** Come here to die.\n*/\nstatic void Exit(int rc){\n  exit(rc);\n}\n\nextern char *sqlite3_mprintf(const char *zFormat, ...);\nextern char *sqlite3_vmprintf(const char *zFormat, va_list);\n\n/*\n** When a lock occurs, yield.\n*/\nstatic int db_is_locked(void *NotUsed, int iCount){\n  /* sched_yield(); */\n  if( verbose ) printf(\"BUSY %s #%d\\n\", (char*)NotUsed, iCount);\n  usleep(100);\n  return iCount<25;\n}\n\n/*\n** Used to accumulate query results by db_query()\n*/\nstruct QueryResult {\n  const char *zFile;  /* Filename - used for error reporting */\n  int nElem;          /* Number of used entries in azElem[] */\n  int nAlloc;         /* Number of slots allocated for azElem[] */\n  char **azElem;      /* The result of the query */\n};\n\n/*\n** The callback function for db_query\n*/\nstatic int db_query_callback(\n  void *pUser,     /* Pointer to the QueryResult structure */\n  int nArg,        /* Number of columns in this result row */\n  char **azArg,    /* Text of data in all columns */\n  char **NotUsed   /* Names of the columns */\n){\n  struct QueryResult *pResult = (struct QueryResult*)pUser;\n  int i;\n  if( pResult->nElem + nArg >= pResult->nAlloc ){\n    if( pResult->nAlloc==0 ){\n      pResult->nAlloc = nArg+1;\n    }else{\n      pResult->nAlloc = pResult->nAlloc*2 + nArg + 1;\n    }\n    pResult->azElem = realloc( pResult->azElem, pResult->nAlloc*sizeof(char*));\n    if( pResult->azElem==0 ){\n      fprintf(stdout,\"%s: malloc failed\\n\", pResult->zFile);\n      return 1;\n    }\n  }\n  if( azArg==0 ) return 0;\n  for(i=0; i<nArg; i++){\n    pResult->azElem[pResult->nElem++] =\n        sqlite3_mprintf(\"%s\",azArg[i] ? azArg[i] : \"\"); \n  }\n  return 0;\n}\n\n/*\n** Execute a query against the database.  NULL values are returned\n** as an empty string.  The list is terminated by a single NULL pointer.\n*/\nchar **db_query(sqlite *db, const char *zFile, const char *zFormat, ...){\n  char *zSql;\n  int rc;\n  char *zErrMsg = 0;\n  va_list ap;\n  struct QueryResult sResult;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  memset(&sResult, 0, sizeof(sResult));\n  sResult.zFile = zFile;\n  if( verbose ) printf(\"QUERY %s: %s\\n\", zFile, zSql);\n  rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);\n  if( rc==SQLITE_SCHEMA ){\n    if( zErrMsg ) free(zErrMsg);\n    rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);\n  }\n  if( verbose ) printf(\"DONE %s %s\\n\", zFile, zSql);\n  if( zErrMsg ){\n    fprintf(stdout,\"%s: query failed: %s - %s\\n\", zFile, zSql, zErrMsg);\n    free(zErrMsg);\n    free(zSql);\n    Exit(1);\n  }\n  sqlite3_free(zSql);\n  if( sResult.azElem==0 ){\n    db_query_callback(&sResult, 0, 0, 0);\n  }\n  sResult.azElem[sResult.nElem] = 0;\n  return sResult.azElem;\n}\n\n/*\n** Execute an SQL statement.\n*/\nvoid db_execute(sqlite *db, const char *zFile, const char *zFormat, ...){\n  char *zSql;\n  int rc;\n  char *zErrMsg = 0;\n  va_list ap;\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  if( verbose ) printf(\"EXEC %s: %s\\n\", zFile, zSql);\n  do{\n    rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg);\n  }while( rc==SQLITE_BUSY );\n  if( verbose ) printf(\"DONE %s: %s\\n\", zFile, zSql);\n  if( zErrMsg ){\n    fprintf(stdout,\"%s: command failed: %s - %s\\n\", zFile, zSql, zErrMsg);\n    free(zErrMsg);\n    sqlite3_free(zSql);\n    Exit(1);\n  }\n  sqlite3_free(zSql);\n}\n\n/*\n** Free the results of a db_query() call.\n*/\nvoid db_query_free(char **az){\n  int i;\n  for(i=0; az[i]; i++){\n    sqlite3_free(az[i]);\n  }\n  free(az);\n}\n\n/*\n** Check results\n*/\nvoid db_check(const char *zFile, const char *zMsg, char **az, ...){\n  va_list ap;\n  int i;\n  char *z;\n  va_start(ap, az);\n  for(i=0; (z = va_arg(ap, char*))!=0; i++){\n    if( az[i]==0 || strcmp(az[i],z)!=0 ){\n      fprintf(stdout,\"%s: %s: bad result in column %d: %s\\n\",\n        zFile, zMsg, i+1, az[i]);\n      db_query_free(az);\n      Exit(1);\n    }\n  }\n  va_end(ap);\n  db_query_free(az);\n}\n\npthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;\npthread_cond_t sig = PTHREAD_COND_INITIALIZER;\nint thread_cnt = 0;\n\nstatic void *worker_bee(void *pArg){\n  const char *zFilename = (char*)pArg;\n  char *azErr;\n  int i, cnt;\n  int t = atoi(zFilename);\n  char **az;\n  sqlite *db;\n\n  pthread_mutex_lock(&lock);\n  thread_cnt++;\n  pthread_mutex_unlock(&lock);\n  printf(\"%s: START\\n\", zFilename);\n  fflush(stdout);\n  for(cnt=0; cnt<10; cnt++){\n    sqlite3_open(&zFilename[2], &db);\n    if( db==0 ){\n      fprintf(stdout,\"%s: can't open\\n\", zFilename);\n      Exit(1);\n    }\n    sqlite3_busy_handler(db, db_is_locked, zFilename);\n    db_execute(db, zFilename, \"CREATE TABLE t%d(a,b,c);\", t);\n    for(i=1; i<=100; i++){\n      db_execute(db, zFilename, \"INSERT INTO t%d VALUES(%d,%d,%d);\",\n         t, i, i*2, i*i);\n    }\n    az = db_query(db, zFilename, \"SELECT count(*) FROM t%d\", t);\n    db_check(zFilename, \"tX size\", az, \"100\", 0);  \n    az = db_query(db, zFilename, \"SELECT avg(b) FROM t%d\", t);\n    db_check(zFilename, \"tX avg\", az, \"101\", 0);  \n    db_execute(db, zFilename, \"DELETE FROM t%d WHERE a>50\", t);\n    az = db_query(db, zFilename, \"SELECT avg(b) FROM t%d\", t);\n    db_check(zFilename, \"tX avg2\", az, \"51\", 0);\n    for(i=1; i<=50; i++){\n      char z1[30], z2[30];\n      az = db_query(db, zFilename, \"SELECT b, c FROM t%d WHERE a=%d\", t, i);\n      sprintf(z1, \"%d\", i*2);\n      sprintf(z2, \"%d\", i*i);\n      db_check(zFilename, \"readback\", az, z1, z2, 0);\n    }\n    db_execute(db, zFilename, \"DROP TABLE t%d;\", t);\n    sqlite3_close(db);\n  }\n  printf(\"%s: END\\n\", zFilename);\n  /* unlink(zFilename); */\n  fflush(stdout);\n  pthread_mutex_lock(&lock);\n  thread_cnt--;\n  if( thread_cnt<=0 ){\n    pthread_cond_signal(&sig);\n  }\n  pthread_mutex_unlock(&lock);\n  return 0;\n}\n\nint main(int argc, char **argv){\n  char *zFile;\n  int i, n;\n  pthread_t id;\n  if( argc>2 && strcmp(argv[1], \"-v\")==0 ){\n    verbose = 1;\n    argc--;\n    argv++;\n  }\n  if( argc<2 || (n=atoi(argv[1]))<1 ) n = 10;\n  for(i=0; i<n; i++){\n    char zBuf[200];\n    sprintf(zBuf, \"testdb-%d\", (i+1)/2);\n    unlink(zBuf);\n  }\n  for(i=0; i<n; i++){\n    zFile = sqlite3_mprintf(\"%d.testdb-%d\", i%2+1, (i+2)/2);\n    if( (i%2)==0 ){\n      /* Remove both the database file and any old journal for the file\n      ** being used by this thread and the next one. */\n      char *zDb = &zFile[2];\n      char *zJournal = sqlite3_mprintf(\"%s-journal\", zDb);\n      unlink(zDb);\n      unlink(zJournal);\n      free(zJournal);\n    }\n      \n    pthread_create(&id, 0, worker_bee, (void*)zFile);\n    pthread_detach(id);\n  }\n  pthread_mutex_lock(&lock);\n  while( thread_cnt>0 ){\n    pthread_cond_wait(&sig, &lock);\n  }\n  pthread_mutex_unlock(&lock);\n  for(i=0; i<n; i++){\n    char zBuf[200];\n    sprintf(zBuf, \"testdb-%d\", (i+1)/2);\n    unlink(zBuf);\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/threadtest2.c",
    "content": "/*\n** 2004 January 13\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a simple standalone program used to test whether\n** or not the SQLite library is threadsafe.\n**\n** This file is NOT part of the standard SQLite library.  It is used for\n** testing only.\n*/\n#include <stdio.h>\n#include <unistd.h>\n#include <pthread.h>\n#include <string.h>\n#include <stdlib.h>\n#include \"sqlite.h\"\n\n/*\n** Name of the database\n*/\n#define DB_FILE \"test.db\"\n\n/* \n** When this variable becomes non-zero, all threads stop\n** what they are doing.\n*/\nvolatile int all_stop = 0;\n\n/* \n** Callback from the integrity check.  If the result is anything other\n** than \"ok\" it means the integrity check has failed.  Set the \"all_stop\"\n** global variable to stop all other activity.  Print the error message\n** or print OK if the string \"ok\" is seen.\n*/\nint check_callback(void *pid, int argc, char **argv, char **notUsed2){\n  int id = (int)pid;\n  if( strcmp(argv[0],\"ok\") ){\n    all_stop = 1;\n    fprintf(stderr,\"%d: %s\\n\", id, argv[0]);\n  }else{\n    /* fprintf(stderr,\"%d: OK\\n\", id); */\n  }\n  return 0;\n}\n\n/*\n** Do an integrity check on the database.  If the first integrity check\n** fails, try it a second time.\n*/\nint integrity_check(sqlite *db, int id){\n  int rc;\n  if( all_stop ) return 0;\n  /* fprintf(stderr,\"%d: CHECK\\n\", id); */\n  rc = sqlite3_exec(db, \"pragma integrity_check\", check_callback, 0, 0);\n  if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){\n    fprintf(stderr,\"%d, Integrity check returns %d\\n\", id, rc);\n  }\n  if( all_stop ){\n    sqlite3_exec(db, \"pragma integrity_check\", check_callback, 0, 0);\n  }\n  return 0;\n}\n\n/*\n** This is the worker thread\n*/\nvoid *worker(void *workerArg){\n  sqlite *db;\n  int id = (int)workerArg;\n  int rc;\n  int cnt = 0;\n  fprintf(stderr, \"Starting worker %d\\n\", id);\n  while( !all_stop && cnt++<10000 ){\n    if( cnt%100==0 ) printf(\"%d: %d\\n\", id, cnt);\n    while( (sqlite3_open(DB_FILE, &db))!=SQLITE_OK ) sched_yield();\n    sqlite3_exec(db, \"PRAGMA synchronous=OFF\", 0, 0, 0);\n    /* integrity_check(db, id); */\n    if( all_stop ){ sqlite3_close(db); break; }\n    /* fprintf(stderr, \"%d: BEGIN\\n\", id); */\n    rc = sqlite3_exec(db, \"INSERT INTO t1 VALUES('bogus data')\", 0, 0, 0);\n    /* fprintf(stderr, \"%d: END rc=%d\\n\", id, rc); */\n    sqlite3_close(db);\n  }\n  fprintf(stderr, \"Worker %d finished\\n\", id);\n  return 0;\n}\n\n/*\n** Initialize the database and start the threads\n*/\nint main(int argc, char **argv){\n  sqlite *db;\n  int i, rc;\n  pthread_t aThread[5];\n\n  if( strcmp(DB_FILE,\":memory:\") ){\n    char *zJournal = sqlite3_mprintf(\"%s-journal\", DB_FILE);\n    unlink(DB_FILE);\n    unlink(zJournal);\n    sqlite3_free(zJournal);\n  }  \n  sqlite3_open(DB_FILE, &db);\n  if( db==0 ){\n    fprintf(stderr,\"unable to initialize database\\n\");\n    exit(1);\n  }\n  rc = sqlite3_exec(db, \"CREATE TABLE t1(x);\", 0,0,0);\n  if( rc ){\n    fprintf(stderr,\"cannot create table t1: %d\\n\", rc);\n    exit(1);\n  }\n  sqlite3_close(db);\n  for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){\n    pthread_create(&aThread[i], 0, worker, (void*)i);\n  }\n  for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){\n    pthread_join(aThread[i], 0);\n  }\n  if( !all_stop ){\n    printf(\"Everything seems ok.\\n\");\n    return 0;\n  }else{\n    printf(\"We hit an error.\\n\");\n    return 1;\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/threadtest3.c",
    "content": "/*\n** 2010-07-22\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** The code in this file runs a few multi-threaded test cases using the\n** SQLite library. It can be compiled to an executable on unix using the\n** following command:\n**\n**   gcc -O2 threadtest3.c sqlite3.c -ldl -lpthread -lm\n**\n** Even though threadtest3.c is the only C source code file mentioned on\n** the compiler command-line, #include macros are used to pull in additional\n** C code files named \"tt3_*.c\".\n**\n** After compiling, run this program with an optional argument telling\n** which test to run.  All tests are run if no argument is given.  The\n** argument can be a glob pattern to match multiple tests.  Examples:\n**\n**        ./a.out                 -- Run all tests\n**        ./a.out walthread3      -- Run the \"walthread3\" test\n**        ./a.out 'wal*'          -- Run all of the wal* tests\n**        ./a.out --help          -- List all available tests\n**\n** The exit status is non-zero if any test fails.\n*/\n\n/* \n** The \"Set Error Line\" macro.\n*/\n#define SEL(e) ((e)->iLine = ((e)->rc ? (e)->iLine : __LINE__))\n\n/* Database functions */\n#define opendb(w,x,y,z)         (SEL(w), opendb_x(w,x,y,z))\n#define closedb(y,z)            (SEL(y), closedb_x(y,z))\n\n/* Functions to execute SQL */\n#define sql_script(x,y,z)       (SEL(x), sql_script_x(x,y,z))\n#define integrity_check(x,y)    (SEL(x), integrity_check_x(x,y))\n#define execsql_i64(x,y,...)    (SEL(x), execsql_i64_x(x,y,__VA_ARGS__))\n#define execsql_text(x,y,z,...) (SEL(x), execsql_text_x(x,y,z,__VA_ARGS__))\n#define execsql(x,y,...)        (SEL(x), (void)execsql_i64_x(x,y,__VA_ARGS__))\n#define sql_script_printf(x,y,z,...) (                \\\n    SEL(x), sql_script_printf_x(x,y,z,__VA_ARGS__)    \\\n) \n\n/* Thread functions */\n#define launch_thread(w,x,y,z)     (SEL(w), launch_thread_x(w,x,y,z))\n#define join_all_threads(y,z)      (SEL(y), join_all_threads_x(y,z))\n\n/* Timer functions */\n#define setstoptime(y,z)        (SEL(y), setstoptime_x(y,z))\n#define timetostop(z)           (SEL(z), timetostop_x(z))\n\n/* Report/clear errors. */\n#define test_error(z, ...)      test_error_x(z, sqlite3_mprintf(__VA_ARGS__))\n#define clear_error(y,z)        clear_error_x(y, z)\n\n/* File-system operations */\n#define filesize(y,z)           (SEL(y), filesize_x(y,z))\n#define filecopy(x,y,z)         (SEL(x), filecopy_x(x,y,z))\n\n#define PTR2INT(x) ((int)((intptr_t)x))\n#define INT2PTR(x) ((void*)((intptr_t)x))\n\n/*\n** End of test code/infrastructure interface macros.\n*************************************************************************/\n\n\n\n\n#include <sqlite3.h>\n#include <unistd.h>\n#include <stdio.h>\n#include <pthread.h>\n#include <assert.h>\n#include <sys/types.h> \n#include <sys/stat.h> \n#include <string.h>\n#include <fcntl.h>\n#include <errno.h>\n\n#include \"test_multiplex.h\"\n\n/* Required to link test_multiplex.c */\n#ifndef SQLITE_OMIT_WSD\nint sqlite3PendingByte = 0x40000000;\n#endif\n\n/*\n * This code implements the MD5 message-digest algorithm.\n * The algorithm is due to Ron Rivest.  This code was\n * written by Colin Plumb in 1993, no copyright is claimed.\n * This code is in the public domain; do with it what you wish.\n *\n * Equivalent code is available from RSA Data Security, Inc.\n * This code has been tested against that, and is equivalent,\n * except that you don't need to include two pages of legalese\n * with every copy.\n *\n * To compute the message digest of a chunk of bytes, declare an\n * MD5Context structure, pass it to MD5Init, call MD5Update as\n * needed on buffers full of bytes, and then call MD5Final, which\n * will fill a supplied 16-byte array with the digest.\n */\n\n/*\n * If compiled on a machine that doesn't have a 32-bit integer,\n * you just set \"uint32\" to the appropriate datatype for an\n * unsigned 32-bit integer.  For example:\n *\n *       cc -Duint32='unsigned long' md5.c\n *\n */\n#ifndef uint32\n#  define uint32 unsigned int\n#endif\n\nstruct MD5Context {\n  int isInit;\n  uint32 buf[4];\n  uint32 bits[2];\n  union {\n    unsigned char in[64];\n    uint32 in32[16];\n  } u;\n};\ntypedef struct MD5Context MD5Context;\n\n/*\n * Note: this code is harmless on little-endian machines.\n */\nstatic void byteReverse (unsigned char *buf, unsigned longs){\n  uint32 t;\n  do {\n    t = (uint32)((unsigned)buf[3]<<8 | buf[2]) << 16 |\n          ((unsigned)buf[1]<<8 | buf[0]);\n    *(uint32 *)buf = t;\n    buf += 4;\n  } while (--longs);\n}\n/* The four core functions - F1 is optimized somewhat */\n\n/* #define F1(x, y, z) (x & y | ~x & z) */\n#define F1(x, y, z) (z ^ (x & (y ^ z)))\n#define F2(x, y, z) F1(z, x, y)\n#define F3(x, y, z) (x ^ y ^ z)\n#define F4(x, y, z) (y ^ (x | ~z))\n\n/* This is the central step in the MD5 algorithm. */\n#define MD5STEP(f, w, x, y, z, data, s) \\\n  ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )\n\n/*\n * The core of the MD5 algorithm, this alters an existing MD5 hash to\n * reflect the addition of 16 longwords of new data.  MD5Update blocks\n * the data and converts bytes into longwords for this routine.\n */\nstatic void MD5Transform(uint32 buf[4], const uint32 in[16]){\n  register uint32 a, b, c, d;\n\n  a = buf[0];\n  b = buf[1];\n  c = buf[2];\n  d = buf[3];\n\n  MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478,  7);\n  MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);\n  MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);\n  MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);\n  MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf,  7);\n  MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);\n  MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);\n  MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);\n  MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8,  7);\n  MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);\n  MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);\n  MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);\n  MD5STEP(F1, a, b, c, d, in[12]+0x6b901122,  7);\n  MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);\n  MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);\n  MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);\n\n  MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562,  5);\n  MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340,  9);\n  MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);\n  MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);\n  MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d,  5);\n  MD5STEP(F2, d, a, b, c, in[10]+0x02441453,  9);\n  MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);\n  MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);\n  MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6,  5);\n  MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6,  9);\n  MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);\n  MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);\n  MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905,  5);\n  MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8,  9);\n  MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);\n  MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);\n\n  MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942,  4);\n  MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);\n  MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);\n  MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);\n  MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44,  4);\n  MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);\n  MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);\n  MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);\n  MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6,  4);\n  MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);\n  MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);\n  MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);\n  MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039,  4);\n  MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);\n  MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);\n  MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);\n\n  MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244,  6);\n  MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);\n  MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);\n  MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);\n  MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3,  6);\n  MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);\n  MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);\n  MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);\n  MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f,  6);\n  MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);\n  MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);\n  MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);\n  MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82,  6);\n  MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);\n  MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);\n  MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);\n\n  buf[0] += a;\n  buf[1] += b;\n  buf[2] += c;\n  buf[3] += d;\n}\n\n/*\n * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious\n * initialization constants.\n */\nstatic void MD5Init(MD5Context *ctx){\n  ctx->isInit = 1;\n  ctx->buf[0] = 0x67452301;\n  ctx->buf[1] = 0xefcdab89;\n  ctx->buf[2] = 0x98badcfe;\n  ctx->buf[3] = 0x10325476;\n  ctx->bits[0] = 0;\n  ctx->bits[1] = 0;\n}\n\n/*\n * Update context to reflect the concatenation of another buffer full\n * of bytes.\n */\nstatic \nvoid MD5Update(MD5Context *ctx, const unsigned char *buf, unsigned int len){\n  uint32 t;\n\n  /* Update bitcount */\n\n  t = ctx->bits[0];\n  if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)\n    ctx->bits[1]++; /* Carry from low to high */\n  ctx->bits[1] += len >> 29;\n\n  t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */\n\n  /* Handle any leading odd-sized chunks */\n\n  if ( t ) {\n    unsigned char *p = (unsigned char *)ctx->u.in + t;\n\n    t = 64-t;\n    if (len < t) {\n      memcpy(p, buf, len);\n      return;\n    }\n    memcpy(p, buf, t);\n    byteReverse(ctx->u.in, 16);\n    MD5Transform(ctx->buf, (uint32 *)ctx->u.in);\n    buf += t;\n    len -= t;\n  }\n\n  /* Process data in 64-byte chunks */\n\n  while (len >= 64) {\n    memcpy(ctx->u.in, buf, 64);\n    byteReverse(ctx->u.in, 16);\n    MD5Transform(ctx->buf, (uint32 *)ctx->u.in);\n    buf += 64;\n    len -= 64;\n  }\n\n  /* Handle any remaining bytes of data. */\n\n  memcpy(ctx->u.in, buf, len);\n}\n\n/*\n * Final wrapup - pad to 64-byte boundary with the bit pattern \n * 1 0* (64-bit count of bits processed, MSB-first)\n */\nstatic void MD5Final(unsigned char digest[16], MD5Context *ctx){\n  unsigned count;\n  unsigned char *p;\n\n  /* Compute number of bytes mod 64 */\n  count = (ctx->bits[0] >> 3) & 0x3F;\n\n  /* Set the first char of padding to 0x80.  This is safe since there is\n     always at least one byte free */\n  p = ctx->u.in + count;\n  *p++ = 0x80;\n\n  /* Bytes of padding needed to make 64 bytes */\n  count = 64 - 1 - count;\n\n  /* Pad out to 56 mod 64 */\n  if (count < 8) {\n    /* Two lots of padding:  Pad the first block to 64 bytes */\n    memset(p, 0, count);\n    byteReverse(ctx->u.in, 16);\n    MD5Transform(ctx->buf, (uint32 *)ctx->u.in);\n\n    /* Now fill the next block with 56 bytes */\n    memset(ctx->u.in, 0, 56);\n  } else {\n    /* Pad block to 56 bytes */\n    memset(p, 0, count-8);\n  }\n  byteReverse(ctx->u.in, 14);\n\n  /* Append length in bits and transform */\n  ctx->u.in32[14] = ctx->bits[0];\n  ctx->u.in32[15] = ctx->bits[1];\n\n  MD5Transform(ctx->buf, (uint32 *)ctx->u.in);\n  byteReverse((unsigned char *)ctx->buf, 4);\n  memcpy(digest, ctx->buf, 16);\n  memset(ctx, 0, sizeof(*ctx));    /* In case it is sensitive */\n}\n\n/*\n** Convert a 128-bit MD5 digest into a 32-digit base-16 number.\n*/\nstatic void MD5DigestToBase16(unsigned char *digest, char *zBuf){\n  static char const zEncode[] = \"0123456789abcdef\";\n  int i, j;\n\n  for(j=i=0; i<16; i++){\n    int a = digest[i];\n    zBuf[j++] = zEncode[(a>>4)&0xf];\n    zBuf[j++] = zEncode[a & 0xf];\n  }\n  zBuf[j] = 0;\n}\n\n/*\n** During testing, the special md5sum() aggregate function is available.\n** inside SQLite.  The following routines implement that function.\n*/\nstatic void md5step(sqlite3_context *context, int argc, sqlite3_value **argv){\n  MD5Context *p;\n  int i;\n  if( argc<1 ) return;\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  if( p==0 ) return;\n  if( !p->isInit ){\n    MD5Init(p);\n  }\n  for(i=0; i<argc; i++){\n    const char *zData = (char*)sqlite3_value_text(argv[i]);\n    if( zData ){\n      MD5Update(p, (unsigned char*)zData, strlen(zData));\n    }\n  }\n}\nstatic void md5finalize(sqlite3_context *context){\n  MD5Context *p;\n  unsigned char digest[16];\n  char zBuf[33];\n  p = sqlite3_aggregate_context(context, sizeof(*p));\n  MD5Final(digest,p);\n  MD5DigestToBase16(digest, zBuf);\n  sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);\n}\n\n/*\n** End of copied md5sum() code.\n**************************************************************************/\n\ntypedef sqlite3_int64 i64;\n\ntypedef struct Error Error;\ntypedef struct Sqlite Sqlite;\ntypedef struct Statement Statement;\n\ntypedef struct Threadset Threadset;\ntypedef struct Thread Thread;\n\n/* Total number of errors in this process so far. */\nstatic int nGlobalErr = 0;\n\nstruct Error {\n  int rc;\n  int iLine;\n  char *zErr;\n};\n\nstruct Sqlite {\n  sqlite3 *db;                    /* Database handle */\n  Statement *pCache;              /* Linked list of cached statements */\n  int nText;                      /* Size of array at aText[] */\n  char **aText;                   /* Stored text results */\n};\n\nstruct Statement {\n  sqlite3_stmt *pStmt;            /* Pre-compiled statement handle */\n  Statement *pNext;               /* Next statement in linked-list */\n};\n\nstruct Thread {\n  int iTid;                       /* Thread number within test */\n  void* pArg;                     /* Pointer argument passed by caller */\n\n  pthread_t tid;                  /* Thread id */\n  char *(*xProc)(int, void*);     /* Thread main proc */\n  Thread *pNext;                  /* Next in this list of threads */\n};\n\nstruct Threadset {\n  int iMaxTid;                    /* Largest iTid value allocated so far */\n  Thread *pThread;                /* Linked list of threads */\n};\n\nstatic void free_err(Error *p){\n  sqlite3_free(p->zErr);\n  p->zErr = 0;\n  p->rc = 0;\n}\n\nstatic void print_err(Error *p){\n  if( p->rc!=SQLITE_OK ){\n    int isWarn = 0;\n    if( p->rc==SQLITE_SCHEMA ) isWarn = 1;\n    if( sqlite3_strglob(\"* - no such table: *\",p->zErr)==0 ) isWarn = 1;\n    printf(\"%s: (%d) \\\"%s\\\" at line %d\\n\", isWarn ? \"Warning\" : \"Error\",\n            p->rc, p->zErr, p->iLine);\n    if( !isWarn ) nGlobalErr++;\n    fflush(stdout);\n  }\n}\n\nstatic void print_and_free_err(Error *p){\n  print_err(p);\n  free_err(p);\n}\n\nstatic void system_error(Error *pErr, int iSys){\n  pErr->rc = iSys;\n  pErr->zErr = (char *)sqlite3_malloc(512);\n  strerror_r(iSys, pErr->zErr, 512);\n  pErr->zErr[511] = '\\0';\n}\n\nstatic void sqlite_error(\n  Error *pErr, \n  Sqlite *pDb, \n  const char *zFunc\n){\n  pErr->rc = sqlite3_errcode(pDb->db);\n  pErr->zErr = sqlite3_mprintf(\n      \"sqlite3_%s() - %s (%d)\", zFunc, sqlite3_errmsg(pDb->db),\n      sqlite3_extended_errcode(pDb->db)\n  );\n}\n\nstatic void test_error_x(\n  Error *pErr,\n  char *zErr\n){\n  if( pErr->rc==SQLITE_OK ){\n    pErr->rc = 1;\n    pErr->zErr = zErr;\n  }else{\n    sqlite3_free(zErr);\n  }\n}\n\nstatic void clear_error_x(\n  Error *pErr,\n  int rc\n){\n  if( pErr->rc==rc ){\n    pErr->rc = SQLITE_OK;\n    sqlite3_free(pErr->zErr);\n    pErr->zErr = 0;\n  }\n}\n\nstatic int busyhandler(void *pArg, int n){\n  usleep(10*1000);\n  return 1;\n}\n\nstatic void opendb_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* OUT: Database handle */\n  const char *zFile,              /* Database file name */\n  int bDelete                     /* True to delete db file before opening */\n){\n  if( pErr->rc==SQLITE_OK ){\n    int rc;\n    int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_URI;\n    if( bDelete ) unlink(zFile);\n    rc = sqlite3_open_v2(zFile, &pDb->db, flags, 0);\n    if( rc ){\n      sqlite_error(pErr, pDb, \"open\");\n      sqlite3_close(pDb->db);\n      pDb->db = 0;\n    }else{\n      sqlite3_create_function(\n          pDb->db, \"md5sum\", -1, SQLITE_UTF8, 0, 0, md5step, md5finalize\n      );\n      sqlite3_busy_handler(pDb->db, busyhandler, 0);\n      sqlite3_exec(pDb->db, \"PRAGMA synchronous=OFF\", 0, 0, 0);\n    }\n  }\n}\n\nstatic void closedb_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb                     /* OUT: Database handle */\n){\n  int rc;\n  int i;\n  Statement *pIter;\n  Statement *pNext;\n  for(pIter=pDb->pCache; pIter; pIter=pNext){\n    pNext = pIter->pNext;\n    sqlite3_finalize(pIter->pStmt);\n    sqlite3_free(pIter);\n  }\n  for(i=0; i<pDb->nText; i++){\n    sqlite3_free(pDb->aText[i]);\n  }\n  sqlite3_free(pDb->aText);\n  rc = sqlite3_close(pDb->db);\n  if( rc && pErr->rc==SQLITE_OK ){\n    pErr->zErr = sqlite3_mprintf(\"%s\", sqlite3_errmsg(pDb->db));\n  }\n  memset(pDb, 0, sizeof(Sqlite));\n}\n\nstatic void sql_script_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  const char *zSql                /* SQL script to execute */\n){\n  if( pErr->rc==SQLITE_OK ){\n    pErr->rc = sqlite3_exec(pDb->db, zSql, 0, 0, &pErr->zErr);\n  }\n}\n\nstatic void sql_script_printf_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  const char *zFormat,            /* SQL printf format string */\n  ...                             /* Printf args */\n){\n  va_list ap;                     /* ... printf arguments */\n  va_start(ap, zFormat);\n  if( pErr->rc==SQLITE_OK ){\n    char *zSql = sqlite3_vmprintf(zFormat, ap);\n    pErr->rc = sqlite3_exec(pDb->db, zSql, 0, 0, &pErr->zErr);\n    sqlite3_free(zSql);\n  }\n  va_end(ap);\n}\n\nstatic Statement *getSqlStatement(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  const char *zSql                /* SQL statement */\n){\n  Statement *pRet;\n  int rc;\n\n  for(pRet=pDb->pCache; pRet; pRet=pRet->pNext){\n    if( 0==strcmp(sqlite3_sql(pRet->pStmt), zSql) ){\n      return pRet;\n    }\n  }\n\n  pRet = sqlite3_malloc(sizeof(Statement));\n  rc = sqlite3_prepare_v2(pDb->db, zSql, -1, &pRet->pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    sqlite_error(pErr, pDb, \"prepare_v2\");\n    return 0;\n  }\n  assert( 0==strcmp(sqlite3_sql(pRet->pStmt), zSql) );\n\n  pRet->pNext = pDb->pCache;\n  pDb->pCache = pRet;\n  return pRet;\n}\n\nstatic sqlite3_stmt *getAndBindSqlStatement(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  va_list ap                      /* SQL followed by parameters */\n){\n  Statement *pStatement;          /* The SQLite statement wrapper */\n  sqlite3_stmt *pStmt;            /* The SQLite statement to return */\n  int i;                          /* Used to iterate through parameters */\n\n  pStatement = getSqlStatement(pErr, pDb, va_arg(ap, const char *));\n  if( !pStatement ) return 0;\n  pStmt = pStatement->pStmt;\n  for(i=1; i<=sqlite3_bind_parameter_count(pStmt); i++){\n    const char *zName = sqlite3_bind_parameter_name(pStmt, i);\n    void * pArg = va_arg(ap, void*);\n\n    switch( zName[1] ){\n      case 'i':\n        sqlite3_bind_int64(pStmt, i, *(i64 *)pArg);\n        break;\n\n      default:\n        pErr->rc = 1;\n        pErr->zErr = sqlite3_mprintf(\"Cannot discern type: \\\"%s\\\"\", zName);\n        pStmt = 0;\n        break;\n    }\n  }\n\n  return pStmt;\n}\n\nstatic i64 execsql_i64_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  ...                             /* SQL and pointers to parameter values */\n){\n  i64 iRet = 0;\n  if( pErr->rc==SQLITE_OK ){\n    sqlite3_stmt *pStmt;          /* SQL statement to execute */\n    va_list ap;                   /* ... arguments */\n    va_start(ap, pDb);\n    pStmt = getAndBindSqlStatement(pErr, pDb, ap);\n    if( pStmt ){\n      int first = 1;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        if( first && sqlite3_column_count(pStmt)>0 ){\n          iRet = sqlite3_column_int64(pStmt, 0);\n        }\n        first = 0;\n      }\n      if( SQLITE_OK!=sqlite3_reset(pStmt) ){\n        sqlite_error(pErr, pDb, \"reset\");\n      }\n    }\n    va_end(ap);\n  }\n  return iRet;\n}\n\nstatic char * execsql_text_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb,                    /* Database handle */\n  int iSlot,                      /* Db handle slot to store text in */\n  ...                             /* SQL and pointers to parameter values */\n){\n  char *zRet = 0;\n\n  if( iSlot>=pDb->nText ){\n    int nByte = sizeof(char *)*(iSlot+1);\n    pDb->aText = (char **)sqlite3_realloc(pDb->aText, nByte);\n    memset(&pDb->aText[pDb->nText], 0, sizeof(char*)*(iSlot+1-pDb->nText));\n    pDb->nText = iSlot+1;\n  }\n\n  if( pErr->rc==SQLITE_OK ){\n    sqlite3_stmt *pStmt;          /* SQL statement to execute */\n    va_list ap;                   /* ... arguments */\n    va_start(ap, iSlot);\n    pStmt = getAndBindSqlStatement(pErr, pDb, ap);\n    if( pStmt ){\n      int first = 1;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        if( first && sqlite3_column_count(pStmt)>0 ){\n          zRet = sqlite3_mprintf(\"%s\", sqlite3_column_text(pStmt, 0));\n          sqlite3_free(pDb->aText[iSlot]);\n          pDb->aText[iSlot] = zRet;\n        }\n        first = 0;\n      }\n      if( SQLITE_OK!=sqlite3_reset(pStmt) ){\n        sqlite_error(pErr, pDb, \"reset\");\n      }\n    }\n    va_end(ap);\n  }\n\n  return zRet;\n}\n\nstatic void integrity_check_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Sqlite *pDb                     /* Database handle */\n){\n  if( pErr->rc==SQLITE_OK ){\n    Statement *pStatement;        /* Statement to execute */\n    char *zErr = 0;               /* Integrity check error */\n\n    pStatement = getSqlStatement(pErr, pDb, \"PRAGMA integrity_check\");\n    if( pStatement ){\n      sqlite3_stmt *pStmt = pStatement->pStmt;\n      while( SQLITE_ROW==sqlite3_step(pStmt) ){\n        const char *z = (const char*)sqlite3_column_text(pStmt, 0);\n        if( strcmp(z, \"ok\") ){\n          if( zErr==0 ){\n            zErr = sqlite3_mprintf(\"%s\", z);\n          }else{\n            zErr = sqlite3_mprintf(\"%z\\n%s\", zErr, z);\n          }\n        }\n      }\n      sqlite3_reset(pStmt);\n\n      if( zErr ){\n        pErr->zErr = zErr;\n        pErr->rc = 1;\n      }\n    }\n  }\n}\n\nstatic void *launch_thread_main(void *pArg){\n  Thread *p = (Thread *)pArg;\n  return (void *)p->xProc(p->iTid, p->pArg);\n}\n\nstatic void launch_thread_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Threadset *pThreads,            /* Thread set */\n  char *(*xProc)(int, void*),     /* Proc to run */\n  void *pArg                      /* Argument passed to thread proc */\n){\n  if( pErr->rc==SQLITE_OK ){\n    int iTid = ++pThreads->iMaxTid;\n    Thread *p;\n    int rc;\n\n    p = (Thread *)sqlite3_malloc(sizeof(Thread));\n    memset(p, 0, sizeof(Thread));\n    p->iTid = iTid;\n    p->pArg = pArg;\n    p->xProc = xProc;\n\n    rc = pthread_create(&p->tid, NULL, launch_thread_main, (void *)p);\n    if( rc!=0 ){\n      system_error(pErr, rc);\n      sqlite3_free(p);\n    }else{\n      p->pNext = pThreads->pThread;\n      pThreads->pThread = p;\n    }\n  }\n}\n\nstatic void join_all_threads_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Threadset *pThreads             /* Thread set */\n){\n  Thread *p;\n  Thread *pNext;\n  for(p=pThreads->pThread; p; p=pNext){\n    void *ret;\n    pNext = p->pNext;\n    int rc;\n    rc = pthread_join(p->tid, &ret);\n    if( rc!=0 ){\n      if( pErr->rc==SQLITE_OK ) system_error(pErr, rc);\n    }else{\n      printf(\"Thread %d says: %s\\n\", p->iTid, (ret==0 ? \"...\" : (char *)ret));\n      fflush(stdout);\n    }\n    sqlite3_free(p);\n  }\n  pThreads->pThread = 0;\n}\n\nstatic i64 filesize_x(\n  Error *pErr,\n  const char *zFile\n){\n  i64 iRet = 0;\n  if( pErr->rc==SQLITE_OK ){\n    struct stat sStat;\n    if( stat(zFile, &sStat) ){\n      iRet = -1;\n    }else{\n      iRet = sStat.st_size;\n    }\n  }\n  return iRet;\n}\n\nstatic void filecopy_x(\n  Error *pErr,\n  const char *zFrom,\n  const char *zTo\n){\n  if( pErr->rc==SQLITE_OK ){\n    i64 nByte = filesize_x(pErr, zFrom);\n    if( nByte<0 ){\n      test_error_x(pErr, sqlite3_mprintf(\"no such file: %s\", zFrom));\n    }else{\n      i64 iOff;\n      char aBuf[1024];\n      int fd1;\n      int fd2;\n      unlink(zTo);\n\n      fd1 = open(zFrom, O_RDONLY);\n      if( fd1<0 ){\n        system_error(pErr, errno);\n        return;\n      }\n      fd2 = open(zTo, O_RDWR|O_CREAT|O_EXCL, 0644);\n      if( fd2<0 ){\n        system_error(pErr, errno);\n        close(fd1);\n        return;\n      }\n\n      iOff = 0;\n      while( iOff<nByte ){\n        int nCopy = sizeof(aBuf);\n        if( nCopy+iOff>nByte ){\n          nCopy = nByte - iOff;\n        }\n        if( nCopy!=read(fd1, aBuf, nCopy) ){\n          system_error(pErr, errno);\n          break;\n        }\n        if( nCopy!=write(fd2, aBuf, nCopy) ){\n          system_error(pErr, errno);\n          break;\n        }\n        iOff += nCopy;\n      }\n\n      close(fd1);\n      close(fd2);\n    }\n  }\n}\n\n/* \n** Used by setstoptime() and timetostop().\n*/\nstatic double timelimit = 0.0;\n\nstatic double currentTime(void){\n  double t;\n  static sqlite3_vfs *pTimelimitVfs = 0;\n  if( pTimelimitVfs==0 ) pTimelimitVfs = sqlite3_vfs_find(0);\n  if( pTimelimitVfs->iVersion>=2 && pTimelimitVfs->xCurrentTimeInt64!=0 ){\n    sqlite3_int64 tm;\n    pTimelimitVfs->xCurrentTimeInt64(pTimelimitVfs, &tm);\n    t = tm/86400000.0;\n  }else{\n    pTimelimitVfs->xCurrentTime(pTimelimitVfs, &t);\n  }\n  return t;\n}\n\nstatic void setstoptime_x(\n  Error *pErr,                    /* IN/OUT: Error code */\n  int nMs                         /* Milliseconds until \"stop time\" */\n){\n  if( pErr->rc==SQLITE_OK ){\n    double t = currentTime();\n    timelimit = t + ((double)nMs)/(1000.0*60.0*60.0*24.0);\n  }\n}\n\nstatic int timetostop_x(\n  Error *pErr                     /* IN/OUT: Error code */\n){\n  int ret = 1;\n  if( pErr->rc==SQLITE_OK ){\n    double t = currentTime();\n    ret = (t >= timelimit);\n  }\n  return ret;\n}\n\n\n/*************************************************************************\n**************************************************************************\n**************************************************************************\n** End infrastructure. Begin tests.\n*/\n\n#define WALTHREAD1_NTHREAD  10\n#define WALTHREAD3_NTHREAD  6\n\nstatic char *walthread1_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int nIter = 0;                  /* Iterations so far */\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    const char *azSql[] = {\n      \"SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1)\",\n      \"SELECT x FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1)\",\n    };\n    char *z1, *z2, *z3;\n\n    execsql(&err, &db, \"BEGIN\");\n    integrity_check(&err, &db);\n    z1 = execsql_text(&err, &db, 1, azSql[0]);\n    z2 = execsql_text(&err, &db, 2, azSql[1]);\n    z3 = execsql_text(&err, &db, 3, azSql[0]);\n    execsql(&err, &db, \"COMMIT\");\n\n    if( strcmp(z1, z2) || strcmp(z1, z3) ){\n      test_error(&err, \"Failed read: %s %s %s\", z1, z2, z3);\n    }\n\n    sql_script(&err, &db,\n        \"BEGIN;\"\n          \"INSERT INTO t1 VALUES(randomblob(100));\"\n          \"INSERT INTO t1 VALUES(randomblob(100));\"\n          \"INSERT INTO t1 SELECT md5sum(x) FROM t1;\"\n        \"COMMIT;\"\n    );\n    nIter++;\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"%d iterations\", nIter);\n}\n\nstatic char *walthread1_ckpt_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int nCkpt = 0;                  /* Checkpoints so far */\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    usleep(500*1000);\n    execsql(&err, &db, \"PRAGMA wal_checkpoint\");\n    if( err.rc==SQLITE_OK ) nCkpt++;\n    clear_error(&err, SQLITE_BUSY);\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"%d checkpoints\", nCkpt);\n}\n\nstatic void walthread1(int nMs){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  Threadset threads = {0};        /* Test threads */\n  int i;                          /* Iterator variable */\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db,\n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(x PRIMARY KEY);\"\n      \"INSERT INTO t1 VALUES(randomblob(100));\"\n      \"INSERT INTO t1 VALUES(randomblob(100));\"\n      \"INSERT INTO t1 SELECT md5sum(x) FROM t1;\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n  for(i=0; i<WALTHREAD1_NTHREAD; i++){\n    launch_thread(&err, &threads, walthread1_thread, 0);\n  }\n  launch_thread(&err, &threads, walthread1_ckpt_thread, 0);\n  join_all_threads(&err, &threads);\n\n  print_and_free_err(&err);\n}\n\nstatic char *walthread2_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int anTrans[2] = {0, 0};        /* Number of WAL and Rollback transactions */\n  int iArg = PTR2INT(pArg);\n\n  const char *zJournal = \"PRAGMA journal_mode = WAL\";\n  if( iArg ){ zJournal = \"PRAGMA journal_mode = DELETE\"; }\n\n  while( !timetostop(&err) ){\n    int journal_exists = 0;\n    int wal_exists = 0;\n\n    opendb(&err, &db, \"test.db\", 0);\n\n    sql_script(&err, &db, zJournal);\n    clear_error(&err, SQLITE_BUSY);\n    sql_script(&err, &db, \"BEGIN\");\n    sql_script(&err, &db, \"INSERT INTO t1 VALUES(NULL, randomblob(100))\");\n\n    journal_exists = (filesize(&err, \"test.db-journal\") >= 0);\n    wal_exists = (filesize(&err, \"test.db-wal\") >= 0);\n    if( (journal_exists+wal_exists)!=1 ){\n      test_error(&err, \"File system looks incorrect (%d, %d)\", \n          journal_exists, wal_exists\n      );\n    }\n    anTrans[journal_exists]++;\n\n    sql_script(&err, &db, \"COMMIT\");\n    integrity_check(&err, &db);\n    closedb(&err, &db);\n  }\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"W %d R %d\", anTrans[0], anTrans[1]);\n}\n\nstatic void walthread2(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \"CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE)\");\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n  launch_thread(&err, &threads, walthread2_thread, 0);\n  launch_thread(&err, &threads, walthread2_thread, 0);\n  launch_thread(&err, &threads, walthread2_thread, (void*)1);\n  launch_thread(&err, &threads, walthread2_thread, (void*)1);\n  join_all_threads(&err, &threads);\n\n  print_and_free_err(&err);\n}\n\nstatic char *walthread3_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  i64 iNextWrite;                 /* Next value this thread will write */\n  int iArg = PTR2INT(pArg);\n\n  opendb(&err, &db, \"test.db\", 0);\n  sql_script(&err, &db, \"PRAGMA wal_autocheckpoint = 10\");\n\n  iNextWrite = iArg+1;\n  while( 1 ){\n    i64 sum1;\n    i64 sum2;\n    int stop = 0;                 /* True to stop executing (test timed out) */\n\n    while( 0==(stop = timetostop(&err)) ){\n      i64 iMax = execsql_i64(&err, &db, \"SELECT max(cnt) FROM t1\");\n      if( iMax+1==iNextWrite ) break;\n    }\n    if( stop ) break;\n\n    sum1 = execsql_i64(&err, &db, \"SELECT sum(cnt) FROM t1\");\n    sum2 = execsql_i64(&err, &db, \"SELECT sum(sum1) FROM t1\");\n    execsql_i64(&err, &db, \n        \"INSERT INTO t1 VALUES(:iNextWrite, :iSum1, :iSum2)\",\n        &iNextWrite, &sum1, &sum2\n    );\n    integrity_check(&err, &db);\n\n    iNextWrite += WALTHREAD3_NTHREAD;\n  }\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return 0;\n}\n\nstatic void walthread3(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n  int i;\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(cnt PRIMARY KEY, sum1, sum2);\"\n      \"CREATE INDEX i1 ON t1(sum1);\"\n      \"CREATE INDEX i2 ON t1(sum2);\"\n      \"INSERT INTO t1 VALUES(0, 0, 0);\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n  for(i=0; i<WALTHREAD3_NTHREAD; i++){\n    launch_thread(&err, &threads, walthread3_thread, INT2PTR(i));\n  }\n  join_all_threads(&err, &threads);\n\n  print_and_free_err(&err);\n}\n\nstatic char *walthread4_reader_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    integrity_check(&err, &db);\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return 0;\n}\n\nstatic char *walthread4_writer_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  i64 iRow = 1;\n\n  opendb(&err, &db, \"test.db\", 0);\n  sql_script(&err, &db, \"PRAGMA wal_autocheckpoint = 15;\");\n  while( !timetostop(&err) ){\n    execsql_i64(\n        &err, &db, \"REPLACE INTO t1 VALUES(:iRow, randomblob(300))\", &iRow\n    );\n    iRow++;\n    if( iRow==10 ) iRow = 0;\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return 0;\n}\n\nstatic void walthread4(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n  launch_thread(&err, &threads, walthread4_reader_thread, 0);\n  launch_thread(&err, &threads, walthread4_writer_thread, 0);\n  join_all_threads(&err, &threads);\n\n  print_and_free_err(&err);\n}\n\nstatic char *walthread5_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  i64 nRow;\n\n  opendb(&err, &db, \"test.db\", 0);\n  nRow = execsql_i64(&err, &db, \"SELECT count(*) FROM t1\");\n  closedb(&err, &db);\n\n  if( nRow!=65536 ) test_error(&err, \"Bad row count: %d\", (int)nRow);\n  print_and_free_err(&err);\n  return 0;\n}\nstatic void walthread5(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n      \"PRAGMA wal_autocheckpoint = 0;\"\n      \"PRAGMA page_size = 1024;\"\n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(x);\"\n      \"BEGIN;\"\n      \"INSERT INTO t1 VALUES(randomblob(900));\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     2 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     4 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     8 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    16 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    32 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    64 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   128 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   256 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   512 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  1024 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  2048 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  4096 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  8192 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 16384 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 32768 */\"\n      \"INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 65536 */\"\n      \"COMMIT;\"\n  );\n  filecopy(&err, \"test.db\", \"test_sv.db\");\n  filecopy(&err, \"test.db-wal\", \"test_sv.db-wal\");\n  closedb(&err, &db);\n\n  filecopy(&err, \"test_sv.db\", \"test.db\");\n  filecopy(&err, \"test_sv.db-wal\", \"test.db-wal\");\n\n  if( err.rc==SQLITE_OK ){\n    printf(\"  WAL file is %d bytes,\", (int)filesize(&err,\"test.db-wal\"));\n    printf(\" DB file is %d.\\n\", (int)filesize(&err,\"test.db\"));\n  }\n\n  setstoptime(&err, nMs);\n  launch_thread(&err, &threads, walthread5_thread, 0);\n  launch_thread(&err, &threads, walthread5_thread, 0);\n  launch_thread(&err, &threads, walthread5_thread, 0);\n  launch_thread(&err, &threads, walthread5_thread, 0);\n  launch_thread(&err, &threads, walthread5_thread, 0);\n  join_all_threads(&err, &threads);\n\n  if( err.rc==SQLITE_OK ){\n    printf(\"  WAL file is %d bytes,\", (int)filesize(&err,\"test.db-wal\"));\n    printf(\" DB file is %d.\\n\", (int)filesize(&err,\"test.db\"));\n  }\n\n  print_and_free_err(&err);\n}\n\n/*------------------------------------------------------------------------\n** Test case \"cgt_pager_1\"\n*/\n#define CALLGRINDTEST1_NROW 10000\nstatic void cgt_pager_1_populate(Error *pErr, Sqlite *pDb){\n  const char *zInsert = \"INSERT INTO t1 VALUES(:iRow, zeroblob(:iBlob))\";\n  i64 iRow;\n  sql_script(pErr, pDb, \"BEGIN\");\n  for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){\n    i64 iBlob = 600 + (iRow%300);\n    execsql(pErr, pDb, zInsert, &iRow, &iBlob);\n  }\n  sql_script(pErr, pDb, \"COMMIT\");\n}\nstatic void cgt_pager_1_update(Error *pErr, Sqlite *pDb){\n  const char *zUpdate = \"UPDATE t1 SET b = zeroblob(:iBlob) WHERE a = :iRow\";\n  i64 iRow;\n  sql_script(pErr, pDb, \"BEGIN\");\n  for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){\n    i64 iBlob = 600 + ((iRow+100)%300);\n    execsql(pErr, pDb, zUpdate, &iBlob, &iRow);\n  }\n  sql_script(pErr, pDb, \"COMMIT\");\n}\nstatic void cgt_pager_1_read(Error *pErr, Sqlite *pDb){\n  i64 iRow;\n  sql_script(pErr, pDb, \"BEGIN\");\n  for(iRow=1; iRow<=CALLGRINDTEST1_NROW; iRow++){\n    execsql(pErr, pDb, \"SELECT * FROM t1 WHERE a = :iRow\", &iRow);\n  }\n  sql_script(pErr, pDb, \"COMMIT\");\n}\nstatic void cgt_pager_1(int nMs){\n  void (*xSub)(Error *, Sqlite *);\n  Error err = {0};\n  Sqlite db = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db,\n      \"PRAGMA cache_size = 2000;\"\n      \"PRAGMA page_size = 1024;\"\n      \"CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);\"\n  );\n\n  xSub = cgt_pager_1_populate; xSub(&err, &db);\n  xSub = cgt_pager_1_update;   xSub(&err, &db);\n  xSub = cgt_pager_1_read;     xSub(&err, &db);\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n}\n\n/*------------------------------------------------------------------------\n** Test case \"dynamic_triggers\"\n**\n**   Two threads executing statements that cause deeply nested triggers\n**   to fire. And one thread busily creating and deleting triggers. This\n**   is an attempt to find a bug reported to us.\n*/\n\nstatic char *dynamic_triggers_1(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int nDrop = 0;\n  int nCreate = 0;\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    int i;\n\n    for(i=1; i<9; i++){\n      char *zSql = sqlite3_mprintf(\n        \"CREATE TRIGGER itr%d BEFORE INSERT ON t%d BEGIN \"\n          \"INSERT INTO t%d VALUES(new.x, new.y);\"\n        \"END;\", i, i, i+1\n      );\n      execsql(&err, &db, zSql);\n      sqlite3_free(zSql);\n      nCreate++;\n    }\n\n    for(i=1; i<9; i++){\n      char *zSql = sqlite3_mprintf(\n        \"CREATE TRIGGER dtr%d BEFORE DELETE ON t%d BEGIN \"\n          \"DELETE FROM t%d WHERE x = old.x; \"\n        \"END;\", i, i, i+1\n      );\n      execsql(&err, &db, zSql);\n      sqlite3_free(zSql);\n      nCreate++;\n    }\n\n    for(i=1; i<9; i++){\n      char *zSql = sqlite3_mprintf(\"DROP TRIGGER itr%d\", i);\n      execsql(&err, &db, zSql);\n      sqlite3_free(zSql);\n      nDrop++;\n    }\n\n    for(i=1; i<9; i++){\n      char *zSql = sqlite3_mprintf(\"DROP TRIGGER dtr%d\", i);\n      execsql(&err, &db, zSql);\n      sqlite3_free(zSql);\n      nDrop++;\n    }\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"%d created, %d dropped\", nCreate, nDrop);\n}\n\nstatic char *dynamic_triggers_2(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  i64 iVal = 0;\n  int nInsert = 0;\n  int nDelete = 0;\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    do {\n      iVal = (iVal+1)%100;\n      execsql(&err, &db, \"INSERT INTO t1 VALUES(:iX, :iY+1)\", &iVal, &iVal);\n      nInsert++;\n    } while( iVal );\n\n    do {\n      iVal = (iVal+1)%100;\n      execsql(&err, &db, \"DELETE FROM t1 WHERE x = :iX\", &iVal);\n      nDelete++;\n    } while( iVal );\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"%d inserts, %d deletes\", nInsert, nDelete);\n}\n\nstatic void dynamic_triggers(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n      \"PRAGMA page_size = 1024;\"\n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(x, y);\"\n      \"CREATE TABLE t2(x, y);\"\n      \"CREATE TABLE t3(x, y);\"\n      \"CREATE TABLE t4(x, y);\"\n      \"CREATE TABLE t5(x, y);\"\n      \"CREATE TABLE t6(x, y);\"\n      \"CREATE TABLE t7(x, y);\"\n      \"CREATE TABLE t8(x, y);\"\n      \"CREATE TABLE t9(x, y);\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n\n  sqlite3_enable_shared_cache(1);\n  launch_thread(&err, &threads, dynamic_triggers_2, 0);\n  launch_thread(&err, &threads, dynamic_triggers_2, 0);\n\n  sleep(2);\n  sqlite3_enable_shared_cache(0);\n\n  launch_thread(&err, &threads, dynamic_triggers_2, 0);\n  launch_thread(&err, &threads, dynamic_triggers_1, 0);\n\n  join_all_threads(&err, &threads);\n\n  print_and_free_err(&err);\n}\n\n\n\n#include \"tt3_checkpoint.c\"\n#include \"tt3_index.c\"\n#include \"tt3_lookaside1.c\"\n#include \"tt3_vacuum.c\"\n#include \"tt3_stress.c\"\n\nint main(int argc, char **argv){\n  struct ThreadTest {\n    void (*xTest)(int);   /* Routine for running this test */\n    const char *zTest;    /* Name of this test */\n    int nMs;              /* How long to run this test, in milliseconds */\n  } aTest[] = {\n    { walthread1, \"walthread1\", 20000 },\n    { walthread2, \"walthread2\", 20000 },\n    { walthread3, \"walthread3\", 20000 },\n    { walthread4, \"walthread4\", 20000 },\n    { walthread5, \"walthread5\",  1000 },\n    \n    { cgt_pager_1,      \"cgt_pager_1\", 0 },\n    { dynamic_triggers, \"dynamic_triggers\", 20000 },\n\n    { checkpoint_starvation_1, \"checkpoint_starvation_1\", 10000 },\n    { checkpoint_starvation_2, \"checkpoint_starvation_2\", 10000 },\n\n    { create_drop_index_1, \"create_drop_index_1\", 10000 },\n    { lookaside1,          \"lookaside1\", 10000 },\n    { vacuum1,             \"vacuum1\", 10000 },\n    { stress1,             \"stress1\", 10000 },\n    { stress2,             \"stress2\", 60000 },\n  };\n  static char *substArgv[] = { 0, \"*\", 0 };\n  int i, iArg;\n  int nTestfound = 0;\n\n  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n  if( argc<2 ){\n    argc = 2;\n    argv = substArgv;\n  }\n\n  /* Loop through the command-line arguments to ensure that each argument\n  ** selects at least one test. If not, assume there is a typo on the \n  ** command-line and bail out with the usage message.  */\n  for(iArg=1; iArg<argc; iArg++){\n    const char *zArg = argv[iArg];\n    if( zArg[0]=='-' ){\n      if( sqlite3_stricmp(zArg, \"-multiplexor\")==0 ){\n        /* Install the multiplexor VFS as the default */\n        int rc = sqlite3_multiplex_initialize(0, 1);\n        if( rc!=SQLITE_OK ){\n          fprintf(stderr, \"Failed to install multiplexor VFS (%d)\\n\", rc);\n          return 253;\n        }\n      }\n      else {\n        goto usage;\n      }\n\n      continue;\n    }\n\n    for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){\n      if( sqlite3_strglob(zArg, aTest[i].zTest)==0 ) break;\n    }\n    if( i>=sizeof(aTest)/sizeof(aTest[0]) ) goto usage;   \n  }\n\n  for(iArg=1; iArg<argc; iArg++){\n    if( argv[iArg][0]=='-' ) continue;\n    for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){\n      char const *z = aTest[i].zTest;\n      if( sqlite3_strglob(argv[iArg],z)==0 ){\n        printf(\"Running %s for %d seconds...\\n\", z, aTest[i].nMs/1000);\n        fflush(stdout);\n        aTest[i].xTest(aTest[i].nMs);\n        nTestfound++;\n      }\n    }\n  }\n  if( nTestfound==0 ) goto usage;\n\n  printf(\"%d errors out of %d tests\\n\", nGlobalErr, nTestfound);\n  return (nGlobalErr>0 ? 255 : 0);\n\n usage:\n  printf(\"Usage: %s [-multiplexor] [testname|testprefix*]...\\n\", argv[0]);\n  printf(\"Available tests are:\\n\");\n  for(i=0; i<sizeof(aTest)/sizeof(aTest[0]); i++){\n    printf(\"   %s\\n\", aTest[i].zTest);\n  }\n\n  return 254;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/threadtest4.c",
    "content": "/*\n** 2014-12-11\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file implements a simple standalone program used to stress the\n** SQLite library when accessing the same set of databases simultaneously\n** from multiple threads in shared-cache mode.\n**\n** This test program runs on unix-like systems only.  It uses pthreads.\n** To compile:\n**\n**     gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread\n**\n** To run:\n**\n**     ./a.out 10\n**\n** The argument is the number of threads.  There are also options, such\n** as -wal and -multithread and -serialized.\n**\n** Consider also compiling with clang instead of gcc and adding the\n** -fsanitize=thread option.\n*/\n#include \"sqlite3.h\"\n#include <pthread.h>\n#include <sched.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <unistd.h>\n#include <stdarg.h>\n\n/*\n** An instance of the following structure is passed into each worker\n** thread.\n*/\ntypedef struct WorkerInfo WorkerInfo;\nstruct WorkerInfo {\n  int tid;                    /* Thread ID */\n  int nWorker;                /* Total number of workers */\n  unsigned wkrFlags;          /* Flags */\n  sqlite3 *mainDb;            /* Database connection of the main thread */\n  sqlite3 *db;                /* Database connection of this thread */\n  int nErr;                   /* Number of errors seen by this thread */\n  int nTest;                  /* Number of tests run by this thread */\n  char *zMsg;                 /* Message returned by this thread */\n  pthread_t id;               /* Thread id */\n  pthread_mutex_t *pWrMutex;  /* Hold this mutex while writing */\n};\n\n/*\n** Allowed values for WorkerInfo.wkrFlags\n*/\n#define TT4_SERIALIZED    0x0000001   /* The --serialized option is used */\n#define TT4_WAL           0x0000002   /* WAL mode in use */\n#define TT4_TRACE         0x0000004   /* Trace activity */\n\n\n/*\n** Report an OOM error and die if the argument is NULL\n*/\nstatic void check_oom(void *x){\n  if( x==0 ){\n    fprintf(stderr, \"out of memory\\n\");\n    exit(1);\n  }\n}\n\n/*\n** Allocate memory.  If the allocation fails, print an error message and\n** kill the process.\n*/\nstatic void *safe_malloc(int sz){\n  void *x = sqlite3_malloc(sz>0?sz:1);\n  check_oom(x);\n  return x;\n}\n\n/*\n** Print a trace message for a worker\n*/\nstatic void worker_trace(WorkerInfo *p, const char *zFormat, ...){\n  va_list ap;\n  char *zMsg;\n  if( (p->wkrFlags & TT4_TRACE)==0 ) return;\n  va_start(ap, zFormat);\n  zMsg = sqlite3_vmprintf(zFormat, ap);\n  check_oom(zMsg);\n  va_end(ap);\n  fprintf(stderr, \"TRACE(%02d): %s\\n\", p->tid, zMsg);\n  sqlite3_free(zMsg);\n}\n\n/*\n** Prepare a single SQL query\n*/\nstatic sqlite3_stmt *prep_sql(sqlite3 *db, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  check_oom(zSql);\n  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    fprintf(stderr, \"SQL error (%d,%d): %s\\nWhile preparing: [%s]\\n\",\n            rc, sqlite3_extended_errcode(db), sqlite3_errmsg(db), zSql);\n    exit(1);\n  }\n  sqlite3_free(zSql);\n  return pStmt;\n}\n\n/*\n** Run a SQL statements.  Panic if unable.\n*/\nstatic void run_sql(WorkerInfo *p, const char *zFormat, ...){\n  va_list ap;\n  char *zSql;\n  int rc;\n  sqlite3_stmt *pStmt = 0;\n  int nRetry = 0;\n\n  va_start(ap, zFormat);\n  zSql = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n  check_oom(zSql);\n  rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);\n  if( rc!=SQLITE_OK ){\n    fprintf(stderr, \"SQL error (%d,%d): %s\\nWhile preparing: [%s]\\n\",\n            rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);\n    exit(1);\n  }\n  worker_trace(p, \"running [%s]\", zSql);\n  while( (rc = sqlite3_step(pStmt))!=SQLITE_DONE ){\n    if( (rc&0xff)==SQLITE_BUSY || (rc&0xff)==SQLITE_LOCKED ){\n      sqlite3_reset(pStmt);\n      nRetry++;\n      if( nRetry<10 ){\n        worker_trace(p, \"retry %d for [%s]\", nRetry, zSql);\n        sched_yield();\n        continue;\n      }else{\n        fprintf(stderr, \"Deadlock in thread %d while running [%s]\\n\",\n                p->tid, zSql);\n        exit(1);\n      }\n    }\n    if( rc!=SQLITE_ROW ){\n      fprintf(stderr, \"SQL error (%d,%d): %s\\nWhile running [%s]\\n\",\n              rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);\n      exit(1);\n    }\n  }\n  sqlite3_free(zSql);\n  sqlite3_finalize(pStmt);\n}\n\n\n/*\n** Open the database connection for WorkerInfo.  The order in which\n** the files are opened is a function of the tid value.\n*/\nstatic void worker_open_connection(WorkerInfo *p, int iCnt){\n  char *zFile;\n  int x;\n  int rc;\n  static const unsigned char aOrder[6][3] = {\n    { 1, 2, 3},\n    { 1, 3, 2},\n    { 2, 1, 3},\n    { 2, 3, 1},\n    { 3, 1, 2},\n    { 3, 2, 1}\n  };\n  x = (p->tid + iCnt) % 6;\n  zFile = sqlite3_mprintf(\"tt4-test%d.db\", aOrder[x][0]);\n  check_oom(zFile);\n  worker_trace(p, \"open %s\", zFile);\n  rc = sqlite3_open_v2(zFile, &p->db,\n                       SQLITE_OPEN_READWRITE|SQLITE_OPEN_SHAREDCACHE, 0);\n  if( rc!=SQLITE_OK ){\n    fprintf(stderr, \"sqlite_open_v2(%s) failed on thread %d\\n\",\n            zFile, p->tid);\n    exit(1);\n  }\n  sqlite3_free(zFile);\n  run_sql(p, \"PRAGMA read_uncommitted=ON;\");\n  sqlite3_busy_timeout(p->db, 10000);\n  run_sql(p, \"PRAGMA synchronous=OFF;\");\n  run_sql(p, \"ATTACH 'tt4-test%d.db' AS aux1\", aOrder[x][1]);\n  run_sql(p, \"ATTACH 'tt4-test%d.db' AS aux2\", aOrder[x][2]);\n}\n\n/*\n** Close the worker database connection\n*/\nstatic void worker_close_connection(WorkerInfo *p){\n  if( p->db ){\n    worker_trace(p, \"close\");\n    sqlite3_close(p->db);\n    p->db = 0;\n  }\n}\n\n/*\n** Delete all content in the three databases associated with a\n** single thread.  Make this happen all in a single transaction if\n** inTrans is true, or separately for each database if inTrans is\n** false.\n*/\nstatic void worker_delete_all_content(WorkerInfo *p, int inTrans){\n  if( inTrans ){\n    pthread_mutex_lock(p->pWrMutex);\n    run_sql(p, \"BEGIN\");\n    run_sql(p, \"DELETE FROM t1 WHERE tid=%d\", p->tid);\n    run_sql(p, \"DELETE FROM t2 WHERE tid=%d\", p->tid);\n    run_sql(p, \"DELETE FROM t3 WHERE tid=%d\", p->tid);\n    run_sql(p, \"COMMIT\");\n    pthread_mutex_unlock(p->pWrMutex);\n    p->nTest++;\n  }else{\n    pthread_mutex_lock(p->pWrMutex);\n    run_sql(p, \"DELETE FROM t1 WHERE tid=%d\", p->tid);\n    pthread_mutex_unlock(p->pWrMutex);\n    p->nTest++;\n    pthread_mutex_lock(p->pWrMutex);\n    run_sql(p, \"DELETE FROM t2 WHERE tid=%d\", p->tid);\n    pthread_mutex_unlock(p->pWrMutex);\n    p->nTest++;\n    pthread_mutex_lock(p->pWrMutex);\n    run_sql(p, \"DELETE FROM t3 WHERE tid=%d\", p->tid);\n    pthread_mutex_unlock(p->pWrMutex);\n    p->nTest++;\n  }\n}\n\n/*\n** Create rows mn through mx in table iTab for the given worker\n*/\nstatic void worker_add_content(WorkerInfo *p, int mn, int mx, int iTab){\n  char *zTabDef;\n  switch( iTab ){\n    case 1:  zTabDef = \"t1(tid,sp,a,b,c)\";  break;\n    case 2:  zTabDef = \"t2(tid,sp,d,e,f)\";  break;\n    case 3:  zTabDef = \"t3(tid,sp,x,y,z)\";  break;\n  }\n  pthread_mutex_lock(p->pWrMutex);\n  run_sql(p, \n     \"WITH RECURSIVE\\n\"\n     \" c(i) AS (VALUES(%d) UNION ALL SELECT i+1 FROM c WHERE i<%d)\\n\"\n     \"INSERT INTO %s SELECT %d, zeroblob(3000), i, printf('%%d',i), i FROM c;\",\n     mn, mx, zTabDef, p->tid\n  );\n  pthread_mutex_unlock(p->pWrMutex);\n  p->nTest++;\n}\n\n/*\n** Set an error message on a worker\n*/\nstatic void worker_error(WorkerInfo *p, const char *zFormat, ...){\n  va_list ap;\n  p->nErr++;\n  sqlite3_free(p->zMsg);\n  va_start(ap, zFormat);\n  p->zMsg = sqlite3_vmprintf(zFormat, ap);\n  va_end(ap);\n}\n\n/*\n** Each thread runs the following function.\n*/\nstatic void *worker_thread(void *pArg){\n  WorkerInfo *p = (WorkerInfo*)pArg;\n  int iOuter;\n  int i;\n  int rc;\n  sqlite3_stmt *pStmt;\n\n  printf(\"worker %d startup\\n\", p->tid);  fflush(stdout);\n  for(iOuter=1; iOuter<=p->nWorker; iOuter++){\n    worker_open_connection(p, iOuter);\n    for(i=0; i<4; i++){\n      worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter)%3 + 1);\n      worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+1)%3 + 1);\n      worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+2)%3 + 1);\n    }\n\n    pStmt = prep_sql(p->db, \"SELECT count(a) FROM t1 WHERE tid=%d\", p->tid);\n    worker_trace(p, \"query [%s]\", sqlite3_sql(pStmt));\n    rc = sqlite3_step(pStmt);\n    if( rc!=SQLITE_ROW ){\n      worker_error(p, \"Failed to step: %s\", sqlite3_sql(pStmt));\n    }else if( sqlite3_column_int(pStmt, 0)!=400 ){\n      worker_error(p, \"Wrong result: %d\", sqlite3_column_int(pStmt,0));\n    }\n    sqlite3_finalize(pStmt);\n    if( p->nErr ) break;\n\n    if( ((iOuter+p->tid)%3)==0 ){\n      sqlite3_db_release_memory(p->db);\n      p->nTest++;\n    }\n\n    pthread_mutex_lock(p->pWrMutex);\n    run_sql(p, \"BEGIN;\");\n    run_sql(p, \"UPDATE t1 SET c=NULL WHERE a=55\");\n    run_sql(p, \"UPDATE t2 SET f=NULL WHERE d=42\");\n    run_sql(p, \"UPDATE t3 SET z=NULL WHERE x=31\");\n    run_sql(p, \"ROLLBACK;\");\n    p->nTest++;\n    pthread_mutex_unlock(p->pWrMutex);\n\n\n    if( iOuter==p->tid ){\n      pthread_mutex_lock(p->pWrMutex);\n      run_sql(p, \"VACUUM\");\n      pthread_mutex_unlock(p->pWrMutex);\n    }\n\n    pStmt = prep_sql(p->db,\n       \"SELECT t1.rowid, t2.rowid, t3.rowid\"\n       \"  FROM t1, t2, t3\"\n       \" WHERE t1.tid=%d AND t2.tid=%d AND t3.tid=%d\"\n       \"   AND t1.a<>t2.d AND t2.d<>t3.x\"\n       \" ORDER BY 1, 2, 3\"\n       ,p->tid, p->tid, p->tid);\n    worker_trace(p, \"query [%s]\", sqlite3_sql(pStmt));\n    for(i=0; i<p->nWorker; i++){\n      rc = sqlite3_step(pStmt);\n      if( rc!=SQLITE_ROW ){\n        worker_error(p, \"Failed to step: %s\", sqlite3_sql(pStmt));\n        break;\n      }\n      sched_yield();\n    }\n    sqlite3_finalize(pStmt);\n    if( p->nErr ) break;\n\n    worker_delete_all_content(p, (p->tid+iOuter)%2);\n    worker_close_connection(p);\n    p->db = 0;\n  }\n  worker_close_connection(p);\n  printf(\"worker %d finished\\n\", p->tid); fflush(stdout);\n  return 0;\n}\n\nint main(int argc, char **argv){\n  int nWorker = 0;         /* Number of worker threads */\n  int i;                   /* Loop counter */\n  WorkerInfo *aInfo;       /* Information for each worker */\n  unsigned wkrFlags = 0;   /* Default worker flags */\n  int nErr = 0;            /* Number of errors */\n  int nTest = 0;           /* Number of tests */\n  int rc;                  /* Return code */\n  sqlite3 *db = 0;         /* Main database connection */\n  pthread_mutex_t wrMutex; /* The write serialization mutex */\n  WorkerInfo infoTop;      /* WorkerInfo for the main thread */\n  WorkerInfo *p;           /* Pointer to infoTop */\n\n  sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n  for(i=1; i<argc; i++){\n    const char *z = argv[i];\n    if( z[0]=='-' ){\n      if( z[1]=='-' && z[2]!=0 ) z++;\n      if( strcmp(z,\"-multithread\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_MULTITHREAD);\n        wkrFlags &= ~TT4_SERIALIZED;\n      }else if( strcmp(z,\"-serialized\")==0 ){\n        sqlite3_config(SQLITE_CONFIG_SERIALIZED);\n        wkrFlags |= TT4_SERIALIZED;\n      }else if( strcmp(z,\"-wal\")==0 ){\n        wkrFlags |= TT4_WAL;\n      }else if( strcmp(z,\"-trace\")==0 ){\n        wkrFlags |= TT4_TRACE;\n      }else{\n        fprintf(stderr, \"unknown command-line option: %s\\n\", argv[i]);\n        exit(1);\n      }\n    }else if( z[0]>='1' && z[0]<='9' && nWorker==0 ){\n      nWorker = atoi(z);\n      if( nWorker<2 ){\n        fprintf(stderr, \"minimum of 2 threads\\n\");\n        exit(1);\n      }\n    }else{\n      fprintf(stderr, \"extra command-line argument: \\\"%s\\\"\\n\", argv[i]);\n      exit(1);\n    }\n  }\n  if( nWorker==0 ){ \n    fprintf(stderr,\n       \"usage:  %s ?OPTIONS? N\\n\"\n       \"N is the number of threads and must be at least 2.\\n\"\n       \"Options:\\n\"\n       \"  --serialized\\n\"\n       \"  --multithread\\n\"\n       \"  --wal\\n\"\n       \"  --trace\\n\"\n       ,argv[0]\n    );\n    exit(1);\n  }\n  if( !sqlite3_threadsafe() ){\n    fprintf(stderr, \"requires a threadsafe build of SQLite\\n\");\n    exit(1);\n  }\n  sqlite3_initialize();\n  sqlite3_enable_shared_cache(1);\n  pthread_mutex_init(&wrMutex, 0);\n\n  /* Initialize the test database files */\n  (void)unlink(\"tt4-test1.db\");\n  (void)unlink(\"tt4-test2.db\");\n  (void)unlink(\"tt4-test3.db\");\n  rc = sqlite3_open(\"tt4-test1.db\", &db);\n  if( rc!=SQLITE_OK ){\n    fprintf(stderr, \"Unable to open test database: tt4-test2.db\\n\");\n    exit(1);\n  }\n  memset(&infoTop, 0, sizeof(infoTop));\n  infoTop.db = db;\n  infoTop.wkrFlags = wkrFlags;\n  p = &infoTop;\n  if( wkrFlags & TT4_WAL ){\n    run_sql(p, \"PRAGMA journal_mode=WAL\");\n  }\n  run_sql(p, \"PRAGMA synchronous=OFF\");\n  run_sql(p, \"CREATE TABLE IF NOT EXISTS t1(tid INTEGER, sp, a, b, c)\");\n  run_sql(p, \"CREATE INDEX t1tid ON t1(tid)\");\n  run_sql(p, \"CREATE INDEX t1ab ON t1(a,b)\");\n  run_sql(p, \"ATTACH 'tt4-test2.db' AS 'test2'\");\n  run_sql(p, \"CREATE TABLE IF NOT EXISTS test2.t2(tid INTEGER, sp, d, e, f)\");\n  run_sql(p, \"CREATE INDEX test2.t2tid ON t2(tid)\");\n  run_sql(p, \"CREATE INDEX test2.t2de ON t2(d,e)\");\n  run_sql(p, \"ATTACH 'tt4-test3.db' AS 'test3'\");\n  run_sql(p, \"CREATE TABLE IF NOT EXISTS test3.t3(tid INTEGER, sp, x, y, z)\");\n  run_sql(p, \"CREATE INDEX test3.t3tid ON t3(tid)\");\n  run_sql(p, \"CREATE INDEX test3.t3xy ON t3(x,y)\");\n  aInfo = safe_malloc( sizeof(*aInfo)*nWorker );\n  memset(aInfo, 0, sizeof(*aInfo)*nWorker);\n  for(i=0; i<nWorker; i++){\n    aInfo[i].tid = i+1;\n    aInfo[i].nWorker = nWorker;\n    aInfo[i].wkrFlags = wkrFlags;\n    aInfo[i].mainDb = db;\n    aInfo[i].pWrMutex = &wrMutex;\n    rc = pthread_create(&aInfo[i].id, 0, worker_thread, &aInfo[i]);\n    if( rc!=0 ){\n      fprintf(stderr, \"thread creation failed for thread %d\\n\", i+1);\n      exit(1);\n    }\n    sched_yield();\n  }\n  for(i=0; i<nWorker; i++){\n    pthread_join(aInfo[i].id, 0);\n    printf(\"Joined thread %d: %d errors in %d tests\",\n           aInfo[i].tid, aInfo[i].nErr, aInfo[i].nTest);\n    if( aInfo[i].zMsg ){\n      printf(\": %s\\n\", aInfo[i].zMsg);\n    }else{\n      printf(\"\\n\");\n    }\n    nErr += aInfo[i].nErr;\n    nTest += aInfo[i].nTest;\n    fflush(stdout);\n  }\n  sqlite3_close(db);\n  sqlite3_free(aInfo);\n  printf(\"Total %d errors in %d tests\\n\", nErr, nTest);\n  return nErr;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/time-wordcount.sh",
    "content": "#!/bin/sh\n#\n# This script runs the wordcount program in different ways and generates\n# an output useful for performance comparisons.\n#\n\n# Select the source text to be analyzed.\n#\nif test \"x$1\" = \"x\";\nthen echo \"Usage: $0 FILENAME [ARGS...]\"; exit 1;\nfi\n\n# Do test runs\n#\nrm -f wcdb1.db\n./wordcount --tag A: --timer --summary wcdb1.db $* --insert\nrm -f wcdb2.db\n./wordcount --tag B: --timer --summary wcdb2.db $* --insert --without-rowid\nrm -f wcdb1.db\n./wordcount --tag C: --timer --summary wcdb1.db $* --replace\nrm -f wcdb2.db\n./wordcount --tag D: --timer --summary wcdb2.db $* --replace --without-rowid\nrm -f wcdb1.db\n./wordcount --tag E: --timer --summary wcdb1.db $* --select\nrm -f wcdb2.db\n./wordcount --tag F: --timer --summary wcdb2.db $* --select --without-rowid\n./wordcount --tag G: --timer --summary wcdb1.db $* --query\n./wordcount --tag H: --timer --summary wcdb1.db $* --query --without-rowid\n./wordcount --tag I: --timer --summary wcdb1.db $* --delete\n./wordcount --tag J: --timer --summary wcdb2.db $* --delete --without-rowid\n\n# Clean up temporary files created.\n#\nrm -f wcdb1.db wcdb2.db\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-02a8e81d44.test",
    "content": "# 2010 April 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [02a8e81d44] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt-02a838-1.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(4);\n    INSERT INTO t1 VALUES(5);\n    SELECT * FROM (SELECT a FROM t1 LIMIT 1) UNION ALL SELECT 3;\n  }\n} {1 3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-26ff0c2d1e.test",
    "content": "# 2010 May 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing a bug found in the OP_Variable optimizer\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test bug-20100512-1 {\n  set DB [sqlite3_connection_pointer db]\n  set SQL {SELECT case when 1 then 99 else ? end + ?}\n  set STMT [sqlite3_prepare_v2 $DB $SQL -1 TAIL]\n  set TAIL\n} {}\ndo_test bug-20100512-2 {\n  sqlite3_bind_parameter_count $STMT\n} 2\ndo_test bug-20100512-3 {\n  sqlite3_bind_int $STMT 1 123\n  sqlite3_bind_int $STMT 2 456\n  sqlite3_step $STMT\n  sqlite3_column_int $STMT 0\n} {555}\nsqlite3_finalize $STMT\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-2a5629202f.test",
    "content": "# 2012 April 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The tests in this file were used while developing the SQLite 4 code. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-2a5629202f\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set data [execsql $sql]\n  if {[db status sort]} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t8(b TEXT, c TEXT);\n  INSERT INTO t8 VALUES('a',  'one');\n  INSERT INTO t8 VALUES('b',  'two');\n  INSERT INTO t8 VALUES(NULL, 'three');\n  INSERT INTO t8 VALUES(NULL, 'four');\n}\n\ndo_execsql_test 1.2 {\n  SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c\n} {null/four null/three a/one b/two}\n\ndo_execsql_test 1.3 {\n  CREATE UNIQUE INDEX i1 ON t8(b);\n  SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c\n} {null/four null/three a/one b/two}\n\ndo_execsql_test 1.4 {\n  DROP INDEX i1;\n  CREATE UNIQUE INDEX i1 ON t8(b, c);\n  SELECT coalesce(b, 'null') || '/' || c FROM t8 x ORDER BY x.b, x.c\n} {null/four null/three a/one b/two}\n\n#-------------------------------------------------------------------------\n#\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t2(a, b NOT NULL, c);\n  CREATE UNIQUE INDEX t2ab ON t2(a, b);\n  CREATE UNIQUE INDEX t2ba ON t2(b, a);\n}\n\ndo_test 2.2 {\n  cksort { SELECT * FROM t2 WHERE a = 10 ORDER BY a, b, c }\n} {nosort}\n\ndo_test 2.3 {\n  cksort { SELECT * FROM t2 WHERE b = 10 ORDER BY a, b, c }\n} {sort}\n\ndo_test 2.4 {\n  cksort { SELECT * FROM t2 WHERE a IS NULL ORDER BY a, b, c }\n} {sort}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-2d1a5c67d.test",
    "content": "# 2011 May 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has\n# been resolved.\n#\n# \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-2d1a5c67d\n\nifcapable {!vtab} {finish_test; return}\nif {[wal_is_capable]==0} {finish_test; return}\n\nfor {set ii 1} {$ii<=10} {incr ii} {\n  do_test tkt-2d1a5c67d.1.$ii {\n    db close\n    forcedelete test.db test.db-wal\n    sqlite3 db test.db\n    db eval \"PRAGMA cache_size=$::ii\"\n    db eval {\n      PRAGMA journal_mode=WAL;\n      CREATE TABLE t1(a,b);\n      CREATE INDEX t1b ON t1(b);\n      CREATE TABLE t2(x,y UNIQUE);\n      INSERT INTO t2 VALUES(3,4);\n      BEGIN;\n      INSERT INTO t1(a,b) VALUES(1,2);\n      SELECT 'A', * FROM t2 WHERE y=4;\n      SELECT 'B', * FROM t1;\n      COMMIT;\n      SELECT 'C', * FROM t1;\n    }\n  } {wal A 3 4 B 1 2 C 1 2}\n}\n\ndb close\nforcedelete test.db test.db-wal\nsqlite3 db test.db\nload_static_extension db wholenumber\ndb eval {\n  PRAGMA journal_mode=WAL;\n  CREATE TABLE t1(a,b);\n  CREATE INDEX t1b ON t1(b);\n  CREATE TABLE t2(x,y);\n  CREATE VIRTUAL TABLE nums USING wholenumber;\n  INSERT INTO t2 SELECT value, randomblob(1000) FROM nums\n                 WHERE value BETWEEN 1 AND 1000;\n}\n\nfor {set ii 1} {$ii<=10} {incr ii} {\n  do_test tkt-2d1a5c67d.2.$ii {\n    db eval \"PRAGMA cache_size=$::ii\"\n    db eval {\n      DELETE FROM t1;\n      BEGIN;\n      INSERT INTO t1(a,b) VALUES(1,2);\n      SELECT sum(length(y)) FROM t2;\n      COMMIT;\n      SELECT * FROM t1;\n    }\n  } {1000000 1 2}\n}\n\ndb close\nsqlite3 db test.db\n\n\ndo_execsql_test 3.1 {\n  PRAGMA cache_size = 10;\n  CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t4(a);\n}\n\ndo_execsql_test 3.2 {\n  INSERT INTO t3 VALUES(NULL, randomblob(500));\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 2\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 4\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 8\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 16\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 32\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 64\n  INSERT INTO t3 SELECT NULL, b||b FROM t3;     -- 128\n}\n\ndo_execsql_test 3.3 {\n  BEGIN;\n    INSERT INTO t4 VALUES('xyz');\n}\n\ndo_test 3.4 {\n  set blobs [list]\n  for {set i 1} {$i<100} {incr i} {\n    set b [db incrblob -readonly t3 b $i]\n    read $b\n    lappend blobs $b\n  }\n\n  execsql COMMIT\n  execsql { SELECT * FROM t4 WHERE a = 'xyz' }\n} {xyz}\n\ndo_test 3.5 {\n  foreach b $blobs { close $b }\n  execsql { SELECT * FROM t4 WHERE a = 'xyz' }\n} {xyz}\n\n# Check that recovery works on the WAL file.\n#\nforcedelete test.db2-wal test.db2\ndo_test 3.6 {\n  copy_file test.db-wal test.db2-wal\n  copy_file test.db test.db2\n  sqlite3 db2 test.db2\n  execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2\n} {xyz}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-2ea2425d34.test",
    "content": "# 2009 September 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [2ea2425d34be] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-2ea24-1.1 {\n  db eval {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,'abc');\n    INSERT INTO t1 VALUES(2,'def');\n    INSERT INTO t1 VALUES(3,'ghi');\n    SELECT a FROM t1 WHERE length(b)<10 AND b<>'def' ORDER BY a;\n  }\n} {1 3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-31338dca7e.test",
    "content": "# 2009 December 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [31338dca7e] has been\n# fixed.  Ticket [31338dca7e] demonstrates problems with the OR-clause\n# optimization in joins where the WHERE clause is of the form\n#\n#     (x AND y) OR z\n#\n# And the x and y subterms from from different tables of the join.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-31338-1.1 {\n  db eval {\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(y);\n    INSERT INTO t1 VALUES(111);\n    INSERT INTO t1 VALUES(222);\n    INSERT INTO t2 VALUES(333);\n    INSERT INTO t2 VALUES(444);\n    SELECT * FROM t1, t2\n     WHERE (x=111 AND y!=444) OR x=222\n     ORDER BY x, y;\n  }\n} {111 333 222 333 222 444}\n\ndo_test tkt-31338-1.2 {\n  db eval {\n    CREATE INDEX t1x ON t1(x);\n    SELECT * FROM t1, t2\n     WHERE (x=111 AND y!=444) OR x=222\n     ORDER BY x, y;\n  }\n} {111 333 222 333 222 444}\n\ndo_test tkt-31338-2.1 {\n  db eval {\n    CREATE TABLE t3(v,w);\n    CREATE TABLE t4(x,y);\n    CREATE TABLE t5(z);\n    INSERT INTO t3 VALUES(111,222);\n    INSERT INTO t3 VALUES(333,444);\n    INSERT INTO t4 VALUES(222,333);\n    INSERT INTO t4 VALUES(444,555);\n    INSERT INTO t5 VALUES(888);\n    INSERT INTO t5 VALUES(999);\n    \n    SELECT * FROM t3, t4, t5\n     WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)\n     ORDER BY v, w, x, y, z;\n  }\n} {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}\n\ndo_test tkt-31338-2.2 {\n  db eval {\n   CREATE INDEX t3v ON t3(v);\n   CREATE INDEX t4x ON t4(x);\n    SELECT * FROM t3, t4, t5\n     WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)\n     ORDER BY v, w, x, y, z;\n  }\n} {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}\n\n\n# Ticket [2c2de252666662f5459904fc33a9f2956cbff23c]\n#\ndo_test tkt-31338-3.1 {\n  foreach x [db eval {SELECT name FROM sqlite_master WHERE type='table'}] {\n     db eval \"DROP TABLE $x\"\n  }\n  db eval {\n    CREATE TABLE t1(a,b,c,d);\n    CREATE TABLE t2(e,f);\n    INSERT INTO t1 VALUES(1,2,3,4);\n    INSERT INTO t2 VALUES(10,-8);\n    CREATE INDEX t1a ON t1(a);\n    CREATE INDEX t1b ON t1(b);\n    CREATE TABLE t3(g);\n    INSERT INTO t3 VALUES(4);\n    CREATE TABLE t4(h);\n    INSERT INTO t4 VALUES(5);\n\n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (a=1 AND h=4)\n         OR (b IN (\n               SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 1 2 3 4 {}}\ndo_test tkt-31338-3.2 {\n  db eval {    \n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (a=1 AND h=4)\n         OR (b=2 AND b NOT IN (\n               SELECT x+1 FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 1 2 3 4 {}}\ndo_test tkt-31338-3.3 {\n  db eval {    \n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (+a=1 AND h=4)\n         OR (b IN (\n               SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 1 2 3 4 {}}\ndo_test tkt-31338-3.4 {\n  db eval {    \n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (a=1 AND h=4)\n         OR (+b IN (\n               SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 1 2 3 4 {}}\n\ndo_test tkt-31338-3.5 {\n  db eval {\n    CREATE TABLE t5(a,b,c,d,e,f);\n    CREATE TABLE t6(g,h);\n    CREATE TRIGGER t6r AFTER INSERT ON t6 BEGIN\n      INSERT INTO t5    \n        SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n         WHERE (a=1 AND h=4)\n            OR (b IN (\n               SELECT x FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n    END;\n    INSERT INTO t6 VALUES(88,99);\n    SELECT * FROM t5;\n  }    \n} {4 1 2 3 4 {}}\n\ndo_test tkt-31338-3.6 {\n  db eval {    \n    INSERT INTO t1 VALUES(2,4,3,4);\n    INSERT INTO t1 VALUES(99,101,3,4);\n    INSERT INTO t1 VALUES(98,97,3,4);\n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (a=1 AND h=4)\n         OR (b IN (\n               SELECT x+a FROM (SELECT e+f AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 2 4 3 4 {} 4 99 101 3 4 {}}\n\ndo_test tkt-31338-3.7 {\n  db eval {\n    SELECT * FROM t3 LEFT JOIN t1 ON d=g LEFT JOIN t4 ON c=h\n     WHERE (a=1 AND h=4)\n         OR (b IN (\n               SELECT x FROM (SELECT e+f+a AS x, e FROM t2 ORDER BY 1 LIMIT 2)\n               GROUP BY e\n            ));\n  }    \n} {4 2 4 3 4 {} 4 99 101 3 4 {}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-313723c356.test",
    "content": "# 2010 September 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [313723c356] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nif {![wal_is_capable]} { finish_test ; return }\n\ndo_execsql_test tkt-313723c356.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = WAL;\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a, b);\n  INSERT INTO t1 VALUES(randomblob(400), randomblob(400));\n  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n  INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;\n} {wal}\nfaultsim_save_and_close\n\ndo_faultsim_test tkt-313723c356.2 -faults shmerr* -prep {\n  faultsim_restore_and_reopen\n  sqlite3 db2 test.db\n  db eval  { SELECT * FROM t1 }\n  db2 eval { UPDATE t1 SET a = randomblob(399) }\n  db2 close\n} -body {\n  # At this point, the cache contains all of table t1 and none of index i1. The\n  # cache is out of date. When the bug existed and the right xShmLock() fails\n  # in the following statement, the internal cache of the WAL header was\n  # being updated, but the contents of the page-cache not flushed. This causes\n  # the integrity-check in the \"-test\" code to fail, as it is comparing the\n  # cached (out-of-date) version of table t1 with the on disk (up-to-date)\n  # version of index i1.\n  #\n  execsql { SELECT min(rowid) FROM t1 }\n} -test {\n  faultsim_test_result {0 1}\n  faultsim_integrity_check\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-385a5b56b9.test",
    "content": "# 2012 April 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The tests in this file were used while developing the SQLite 4 code. \n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-385a5b56b9\n\ndo_execsql_test 1.0 { \n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, NULL);\n  INSERT INTO t1 VALUES(2, NULL);\n  INSERT INTO t1 VALUES(1, NULL);\n}\n\ndo_execsql_test 1.1 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}\ndo_execsql_test 1.2 { CREATE UNIQUE INDEX i1 ON t1(x, y) }\ndo_execsql_test 1.3 { SELECT DISTINCT x, y FROM t1 } {1 {} 2 {}}\n\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(x, y NOT NULL);\n  CREATE UNIQUE INDEX t2x ON t2(x);\n  CREATE UNIQUE INDEX t2y ON t2(y);\n}\n\ndo_eqp_test 2.1 { SELECT DISTINCT x FROM t2 } {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2x}\n}\n\ndo_eqp_test 2.2 { SELECT DISTINCT y FROM t2 } {\n  0 0 0 {SCAN TABLE t2 USING COVERING INDEX t2y}\n}\n\ndo_eqp_test 2.3 { SELECT DISTINCT x, y FROM t2 WHERE y=10 } {\n  0 0 0 {SEARCH TABLE t2 USING INDEX t2y (y=?)}\n}\n\ndo_eqp_test 2.4 { SELECT DISTINCT x, y FROM t2 WHERE x=10 } {\n  0 0 0 {SEARCH TABLE t2 USING INDEX t2x (x=?)}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-38cb5df375.test",
    "content": "# 2010 October 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [38cb5df375078d3f9711482d2a1615d09f6b3f33] has\n# been resolved.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt-38cb5df375.0 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT a+2 FROM t1;\n    INSERT INTO t1 SELECT a+4 FROM t1;\n  }\n} {}\n\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.1.$ii {\n    execsql {\n      SELECT * FROM (SELECT * FROM t1 ORDER BY a)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.2.$ii {\n    execsql {\n      SELECT 9 FROM (SELECT * FROM t1)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)\n      LIMIT $::ii;\n    }\n  } [lrange {9 9 9 9 9 9 9 9 1 2 3 4 5 6 7 8} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.3.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.4.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      LIMIT $::ii;\n    }\n  } [lrange {0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4} {\n  do_test tkt-38cb5df375.5.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1)\n      UNION SELECT 9 FROM (SELECT a FROM t1)\n      LIMIT $::ii;\n    }\n  } [lrange {0 9} 0 [expr {$ii-1}]]\n}\n\nforeach ii {1 2 3 4 5 6 7 8 9 10 11} {\n  do_test tkt-38cb5df375.11.$ii {\n    execsql {\n      SELECT * FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11} {\n  do_test tkt-38cb5df375.12.$ii {\n    execsql {\n      SELECT 9 FROM (SELECT * FROM t1)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)\n      LIMIT $::ii;\n    }\n  } [lrange {9 9 9 9 9 9 9 9 1 2 3} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6} {\n  do_test tkt-38cb5df375.13.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 1 2 3} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6} {\n  do_test tkt-38cb5df375.14.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 3)\n      LIMIT $::ii;\n    }\n  } [lrange {0 0 0 9 9 9} 0 [expr {$ii-1}]]\n}\n\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.21.$ii {\n    execsql {\n      SELECT * FROM (SELECT * FROM t1 ORDER BY a)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.22.$ii {\n    execsql {\n      SELECT 9 FROM (SELECT * FROM t1)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 6 7 8 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.23.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a)\n      ORDER BY 1 DESC\n      LIMIT $::ii;\n    }\n  } [lrange {8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16} {\n  do_test tkt-38cb5df375.24.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\n\nforeach ii {1 2 3 4 5 6 7 8 9 10 11} {\n  do_test tkt-38cb5df375.31.$ii {\n    execsql {\n      SELECT * FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9 10 11} {\n  do_test tkt-38cb5df375.32.$ii {\n    execsql {\n      SELECT 9 FROM (SELECT * FROM t1)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 9 9 9 9 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.33.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 4)\n      UNION ALL SELECT 90+a FROM (SELECT a FROM t1 ORDER BY a LIMIT 3)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 91 92 93} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.34.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 2)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 5)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 1 2 2 3 4 5} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.35.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)\n      UNION ALL SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 1 2 2 3 4 5} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.35b.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)\n      UNION ALL SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 11 12} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.35c.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)\n      UNION SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 4 5 11 12} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.35d.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)\n      INTERSECT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.35e.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 5)\n      EXCEPT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {3 4 5} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.36.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {0 0 0 9 9 9 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.37.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)\n      UNION SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {0 9} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7} {\n  do_test tkt-38cb5df375.38.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)\n      EXCEPT SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {0} 0 [expr {$ii-1}]]\n}\n\nforeach ii {1 2 3 4 5 6 7 8 9} {\n  do_test tkt-38cb5df375.41.$ii {\n    execsql {\n      SELECT 0 FROM (SELECT * FROM t1 LIMIT 3)\n      UNION ALL SELECT 9 FROM (SELECT a FROM t1 LIMIT 4)\n      UNION ALL SELECT 88 FROM (SELECT a FROM t1 LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {0 0 0 9 9 9 9 88 88} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9} {\n  do_test tkt-38cb5df375.42.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)\n      UNION ALL SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 4)\n      UNION ALL SELECT a+20 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 11 12 13 14 21 22} 0 [expr {$ii-1}]]\n}\nforeach ii {1 2 3 4 5 6 7 8 9} {\n  do_test tkt-38cb5df375.43.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a LIMIT 3)\n      UNION SELECT a+10 FROM (SELECT a FROM t1 ORDER BY a LIMIT 4)\n      UNION SELECT a+20 FROM (SELECT a FROM t1 ORDER BY a LIMIT 2)\n      ORDER BY 1\n      LIMIT $::ii;\n    }\n  } [lrange {1 2 3 11 12 13 14 21 22} 0 [expr {$ii-1}]]\n}\n\nforeach ii {1 2 3 4 5 6 7} {\n  set jj [expr {7-$ii}]\n  do_test tkt-38cb5df375.51.$ii {\n    execsql {\n      SELECT a FROM (SELECT * FROM t1 ORDER BY a)\n      EXCEPT SELECT a FROM (SELECT a FROM t1 ORDER BY a LIMIT $::ii)\n      ORDER BY a DESC\n      LIMIT $::jj;\n    }\n  } [lrange {8 7 6 5 4 3 2 1} 0 [expr {$jj-1}]]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-3998683a16.test",
    "content": "# 2010 September 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [3998683a16a7076e08f5585c1f4816414c8c653a] where in\n# floating point values with a decimal point at the beginning or end\n# of the mantissa are used.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-3998683a16.1 {\n  db eval {\n    CREATE TABLE t1(x, y REAL);\n    INSERT INTO t1 VALUES(1, '1.0');\n    INSERT INTO t1 VALUES(2, '.125');\n    INSERT INTO t1 VALUES(3, '123.');\n    INSERT INTO t1 VALUES(4, '123.e+2');\n    INSERT INTO t1 VALUES(5, '.125e+3');\n    INSERT INTO t1 VALUES(6, '123e4');\n    INSERT INTO t1 VALUES(11, '  1.0');\n    INSERT INTO t1 VALUES(12, '  .125');\n    INSERT INTO t1 VALUES(13, '  123.');\n    INSERT INTO t1 VALUES(14, '  123.e+2');\n    INSERT INTO t1 VALUES(15, '  .125e+3');\n    INSERT INTO t1 VALUES(16, '  123e4');\n    INSERT INTO t1 VALUES(21, '1.0  ');\n    INSERT INTO t1 VALUES(22, '.125  ');\n    INSERT INTO t1 VALUES(23, '123.  ');\n    INSERT INTO t1 VALUES(24, '123.e+2  ');\n    INSERT INTO t1 VALUES(25, '.125e+3  ');\n    INSERT INTO t1 VALUES(26, '123e4  ');\n    SELECT x FROM t1 WHERE typeof(y)=='real' ORDER BY x;\n  }\n} {1 2 3 4 5 6 11 12 13 14 15 16 21 22 23 24 25 26}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-3a77c9714e.test",
    "content": "# 2011 December 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [3a77c9714e] has been\n# fixed.  \n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nset testprefix \"tkt-3a77c9714e\"\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(t1_id INTEGER PRIMARY KEY, t1_title TEXT);\n  CREATE TABLE t2(t2_id INTEGER PRIMARY KEY, t2_title TEXT);\n  CREATE TABLE t3(t3_id INTEGER PRIMARY KEY, t3_title TEXT);\n\n  INSERT INTO t1 (t1_id, t1_title) VALUES (888, 'ABCDEF');\n  INSERT INTO t2 (t2_id, t2_title) VALUES (999, 'ABCDEF');\n  INSERT INTO t3 (t3_id, t3_title) VALUES (999, 'ABCDEF');\n}\n\ndo_execsql_test 1.2 {\n  SELECT t1_title, t2_title\n  FROM t1 LEFT JOIN t2\n  WHERE\n    t2_id = (SELECT t3_id FROM\n     ( SELECT t3_id FROM t3 WHERE t3_title=t1_title LIMIT 500 )\n  )\n} {ABCDEF ABCDEF}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE [Beginnings] (\n    [Id] INTEGER PRIMARY KEY AUTOINCREMENT,[Title] TEXT, [EndingId] INTEGER\n  );\n  CREATE TABLE [Endings] (Id INT,Title TEXT,EndingId INT);\n  INSERT INTO Beginnings (Id, Title, EndingId) VALUES (1, 'FACTOR', 18);\n  INSERT INTO Beginnings (Id, Title, EndingId) VALUES (2, 'SWIMM', 18);\n  INSERT INTO Endings (Id, Title, EndingId) VALUES (1, 'ING', 18);\n}\n\ndo_execsql_test 2.2 {\n  SELECT\n    SrcWord, Beginnings.Title\n    FROM \n      (SELECT 'FACTORING' AS SrcWord UNION SELECT 'SWIMMING' AS SrcWord )\n    LEFT JOIN \n      Beginnings\n    WHERE Beginnings.Id= (\n      SELECT BeginningId FROM (\n        SELECT SrcWord, B.Id as BeginningId, B.Title || E.Title As Connected\n        FROM Beginnings B LEFT JOIN Endings E ON B.EndingId=E.EndingId\n        WHERE Connected=SrcWord LIMIT 1\n      )\n    )\n} {FACTORING FACTOR SWIMMING SWIMM} \n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-3fe897352e.test",
    "content": "# 2009 October 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [3fe897352e8d8] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The following tests use hex_to_utf16be() and hex_to_utf16le() which \n# which are only available if SQLite is built with UTF16 support.\nifcapable {!utf16} {\n  finish_test\n  return\n}\n\ndo_test tkt-3fe89-1.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    PRAGMA encoding=UTF8;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(hex_to_utf16be('D800'));\n    SELECT hex(x) FROM t1;\n  }\n} {EDA080}\ndo_test tkt-3fe89-1.2 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(hex_to_utf16le('00D8'));\n    SELECT hex(x) FROM t1;\n  }\n} {EDA080}\ndo_test tkt-3fe89-1.3 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(hex_to_utf16be('DFFF'));\n    SELECT hex(x) FROM t1;\n  }\n} {EDBFBF}\ndo_test tkt-3fe89-1.4 {\n  db eval {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(hex_to_utf16le('FFDF'));\n    SELECT hex(x) FROM t1;\n  }\n} {EDBFBF}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-4a03edc4c8.test",
    "content": "# 2009 September 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that\n# ticket [4a03edc4c8c028c93e9269f64fc5e97f632c1166] has been fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-4a03ed-1.1 {\n  db eval {\n    CREATE TABLE t1(\n      a INTEGER PRIMARY KEY ON CONFLICT REPLACE,\n      b UNIQUE ON CONFLICT FAIL\n    );\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 2);\n  }\n  catchsql {\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n  }\n} {1 {UNIQUE constraint failed: t1.b}}\ndo_test tkt-4a03ed-1.2 {\n  db eval {\n    PRAGMA integrity_check;\n  }\n} {ok}\ndo_test tkt-4a03ed-1.3 {\n  db eval {\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 1 2 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-4c86b126f2.test",
    "content": "# 2014-02-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [4c86b126f22ad548fee0125337bdc9366912d9ac].\n#\n# When SQLite is compiled using SQLITE_ENABLE_STAT3 or SQLITE_ENABLE_STAT4,\n# it gets the wrong answer...\n#\n# The problem was introduced in SQLite 3.8.1.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test tkt-4c86b126f2-1.1 {\n  CREATE TABLE nodes(\n     local_relpath  TEXT PRIMARY KEY,\n     moved_to  TEXT\n  );\n  INSERT INTO nodes VALUES('A',NULL);\n  INSERT INTO nodes VALUES('A/B',NULL);\n  INSERT INTO nodes VALUES('',NULL);\n  INSERT INTO nodes VALUES('A/B/C-move',NULL);\n  INSERT INTO nodes VALUES('A/B/C','A/B/C-move');\n  INSERT INTO nodes VALUES('A/B-move',NULL);\n  INSERT INTO nodes VALUES('A/B-move/C-move',NULL);\n  INSERT INTO nodes VALUES('A/B-move/C','x');\n  SELECT local_relpath, moved_to\n   FROM nodes\n  WHERE (local_relpath = 'A/B' OR\n           ((local_relpath > 'A/B/') AND (local_relpath < 'A/B0')))\n    AND moved_to IS NOT NULL;\n} {A/B/C A/B/C-move}\n\ndo_execsql_test tkt-4c86b126f2-2.1 {\n  CREATE TABLE t1(x TEXT UNIQUE, y TEXT UNIQUE, z);\n  INSERT INTO t1 VALUES('ghi','jkl','y');\n  SELECT * FROM t1 WHERE (x='ghi' OR y='jkl') AND z IS NOT NULL;\n} {ghi jkl y}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-4dd95f6943.test",
    "content": "# 2013 March 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix tkt-4dd95f6943\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES (3), (4), (2), (1), (5), (6);\n}\n\nforeach {tn1 idx} {\n  1 { CREATE INDEX i1 ON t1(x ASC) }\n  2 { CREATE INDEX i1 ON t1(x DESC) }\n} {\n  do_execsql_test 1.$tn1.1 { DROP INDEX IF EXISTS i1; }\n  do_execsql_test 1.$tn1.2 $idx\n\n  do_execsql_test 1.$tn1.3 {\n    SELECT x FROM t1 WHERE x IN(2, 4, 5) ORDER BY x ASC;\n  } {2 4 5}\n\n  do_execsql_test 1.$tn1.4 {\n    SELECT x FROM t1 WHERE x IN(2, 4, 5) ORDER BY x DESC;\n  } {5 4 2}\n}\n\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(x, y);\n  INSERT INTO t2 VALUES (5, 3), (5, 4), (5, 2), (5, 1), (5, 5), (5, 6);\n  INSERT INTO t2 VALUES (1, 3), (1, 4), (1, 2), (1, 1), (1, 5), (1, 6);\n  INSERT INTO t2 VALUES (3, 3), (3, 4), (3, 2), (3, 1), (3, 5), (3, 6);\n  INSERT INTO t2 VALUES (2, 3), (2, 4), (2, 2), (2, 1), (2, 5), (2, 6);\n  INSERT INTO t2 VALUES (4, 3), (4, 4), (4, 2), (4, 1), (4, 5), (4, 6);\n  INSERT INTO t2 VALUES (6, 3), (6, 4), (6, 2), (6, 1), (6, 5), (6, 6);\n\n  CREATE TABLE t3(a, b);\n  INSERT INTO t3 VALUES (2, 2), (4, 4), (5, 5);\n  CREATE UNIQUE INDEX t3i1 ON t3(a ASC);\n  CREATE UNIQUE INDEX t3i2 ON t3(b DESC);\n}\n\nforeach {tn1 idx} {\n  1 { CREATE INDEX i1 ON t2(x ASC,  y ASC) }\n  2 { CREATE INDEX i1 ON t2(x ASC,  y DESC) }\n  3 { CREATE INDEX i1 ON t2(x DESC, y ASC) }\n  4 { CREATE INDEX i1 ON t2(x DESC, y DESC) }\n\n  5 { CREATE INDEX i1 ON t2(y ASC,  x ASC) }\n  6 { CREATE INDEX i1 ON t2(y ASC,  x DESC) }\n  7 { CREATE INDEX i1 ON t2(y DESC, x ASC) }\n  8 { CREATE INDEX i1 ON t2(y DESC, x DESC) }\n} {\n  do_execsql_test 2.$tn1.1 { DROP INDEX IF EXISTS i1; }\n  do_execsql_test 2.$tn1.2 $idx\n\n  foreach {tn2 inexpr} {\n    3  \"(2, 4, 5)\"\n    4  \"(SELECT a FROM t3)\"\n    5  \"(SELECT b FROM t3)\"\n  } {\n    do_execsql_test 2.$tn1.$tn2.1 \"\n      SELECT x, y FROM t2 WHERE x = 1 AND y IN $inexpr ORDER BY x ASC, y ASC;\n    \" {1 2  1 4  1 5}\n\n    do_execsql_test 2.$tn1.$tn2.2 \"\n      SELECT x, y FROM t2 WHERE x = 2 AND y IN $inexpr ORDER BY x ASC, y DESC;\n    \" {2 5  2 4  2 2}\n\n    do_execsql_test 2.$tn1.$tn2.3 \"\n      SELECT x, y FROM t2 WHERE x = 3 AND y IN $inexpr ORDER BY x DESC, y ASC;\n    \" {3 2  3 4  3 5}\n\n    do_execsql_test 2.$tn1.$tn2.4 \"\n      SELECT x, y FROM t2 WHERE x = 4 AND y IN $inexpr ORDER BY x DESC, y DESC;\n    \" {4 5  4 4  4 2}\n    \n    do_execsql_test 2.$tn1.$tn2.5 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr \n      ORDER BY a, x ASC, y ASC;\n    \" {4 1 2  4 1 4  4 1 5}\n    do_execsql_test 2.$tn1.$tn2.6 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr \n      ORDER BY x ASC, y ASC;\n    \" {2 1 2  2 1 4  2 1 5}\n\n    do_execsql_test 2.$tn1.$tn2.7 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr \n      ORDER BY a, x ASC, y DESC;\n    \" {4 1 5  4 1 4  4 1 2}\n    do_execsql_test 2.$tn1.8 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr \n      ORDER BY x ASC, y DESC;\n    \" {2 1 5  2 1 4  2 1 2}\n\n    do_execsql_test 2.$tn1.$tn2.9 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr \n      ORDER BY a, x DESC, y ASC;\n    \" {4 1 2  4 1 4  4 1 5}\n    do_execsql_test 2.$tn1.10 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr \n      ORDER BY x DESC, y ASC;\n    \" {2 1 2  2 1 4  2 1 5}\n\n    do_execsql_test 2.$tn1.$tn2.11 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 4 AND x = 1 AND y IN $inexpr \n      ORDER BY a, x DESC, y DESC;\n    \" {4 1 5  4 1 4  4 1 2}\n    do_execsql_test 2.$tn1.$tn2.12 \"\n      SELECT a, x, y FROM t2, t3 WHERE a = 2 AND x = 1 AND y IN $inexpr \n      ORDER BY x DESC, y DESC;\n    \" {2 1 5  2 1 4  2 1 2}\n  }\n}\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t7(x);\n  INSERT INTO t7 VALUES (1), (2), (3);\n  CREATE INDEX i7 ON t7(x);\n\n  CREATE TABLE t8(y);\n  INSERT INTO t8 VALUES (1), (2), (3);\n}\n\nforeach {tn idxdir sortdir sortdata} {\n  1 ASC  ASC  {1 2 3}\n  2 ASC  DESC {3 2 1}\n  3 DESC ASC  {1 2 3}\n  4 ASC  DESC {3 2 1}\n} {\n\n  do_execsql_test 3.$tn \"\n    DROP INDEX IF EXISTS i8;\n    CREATE UNIQUE INDEX i8 ON t8(y $idxdir);\n    SELECT x FROM t7 WHERE x IN (SELECT y FROM t8) ORDER BY x $sortdir;\n  \" $sortdata\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-4ef7e3cfca.test",
    "content": "# 2014-03-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that ticket [4ef7e3cfca] has been\n# fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-4ef7e3cfca\n\ndo_catchsql_test 1.1 {\n  CREATE TABLE x(a);\n  CREATE TRIGGER t AFTER INSERT ON x BEGIN\n    SELECT * FROM x WHERE abc.a = 1;\n  END;\n  INSERT INTO x VALUES('assert');\n} {1 {no such column: abc.a}}\n\nreset_db\ndo_execsql_test 2.1 {\n  CREATE TABLE w(a);\n  CREATE TABLE x(a);\n  CREATE TABLE y(a);\n  CREATE TABLE z(a);\n\n  INSERT INTO x(a) VALUES(5);\n  INSERT INTO y(a) VALUES(10);\n\n  CREATE TRIGGER t AFTER INSERT ON w BEGIN\n    INSERT INTO z\n    SELECT (SELECT x.a + y.a FROM y) FROM x;\n  END;\n  INSERT INTO w VALUES('incorrect');\n}\ndo_execsql_test 2.2 {\n  SELECT * FROM z;\n} {15}\n\nreset_db\ndo_execsql_test 3.1 {\n  CREATE TABLE w(a);\n  CREATE TABLE x(b);\n  CREATE TABLE y(a);\n  CREATE TABLE z(a);\n\n  INSERT INTO x(b) VALUES(5);\n  INSERT INTO y(a) VALUES(10);\n\n  CREATE TRIGGER t AFTER INSERT ON w BEGIN\n    INSERT INTO z\n    SELECT (SELECT x.b + y.a FROM y) FROM x;\n  END;\n  INSERT INTO w VALUES('assert');\n}\ndo_execsql_test 3.2 {\n  SELECT * FROM z;\n} {15}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-54844eea3f.test",
    "content": "# 2011 July 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that bug [54844eea3f] has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix tkt-54844eea3f\n\ndo_test 1.0 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(4);\n\n    CREATE TABLE t2(b INTEGER PRIMARY KEY);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    INSERT INTO t2 SELECT b+2 FROM t2;\n    INSERT INTO t2 SELECT b+4 FROM t2;\n    INSERT INTO t2 SELECT b+8 FROM t2;\n    INSERT INTO t2 SELECT b+16 FROM t2;\n\n    CREATE TABLE t3(c INTEGER PRIMARY KEY);\n    INSERT INTO t3 VALUES(1);\n    INSERT INTO t3 VALUES(2);\n    INSERT INTO t3 VALUES(3);\n  }\n} {}\n\ndo_test 1.1 {\n  execsql {\n    SELECT 'test-2', t3.c, (\n          SELECT count(*) \n          FROM t1 JOIN (SELECT DISTINCT t3.c AS p FROM t2) AS x ON t1.a=x.p\n    )\n    FROM t3;\n  }\n} {test-2 1 1 test-2 2 0 test-2 3 0}\n\ndo_test 1.2 {\n  execsql {\n    CREATE TABLE t4(a, b, c);\n    INSERT INTO t4 VALUES('a', 1, 'one');\n    INSERT INTO t4 VALUES('a', 2, 'two');\n    INSERT INTO t4 VALUES('b', 1, 'three');\n    INSERT INTO t4 VALUES('b', 2, 'four');\n    SELECT ( \n      SELECT c FROM (\n        SELECT * FROM t4 WHERE a=out.a ORDER BY b LIMIT 10 OFFSET 1\n      ) WHERE b=out.b\n    ) FROM t4 AS out;\n  }\n} {{} two {} four}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-5d863f876e.test",
    "content": "# 2011 January 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [5d863f876e] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix tkt-5d863f876e\nif {![wal_is_capable]} {finish_test ; return }\n\ndo_multiclient_test tn {\n  do_test $tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      CREATE INDEX i1 ON t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      PRAGMA journal_mode = WAL;\n      VACUUM;\n      PRAGMA journal_mode = DELETE;\n    }\n  } {wal delete}\n\n  do_test $tn.2 {\n    sql2 { SELECT * FROM t1 } \n  } {1 2 3 4}\n\n  do_test $tn.3 {\n    sql1 {\n      INSERT INTO t1 VALUES(5, 6);\n      PRAGMA journal_mode = WAL;\n      VACUUM;\n      PRAGMA journal_mode = DELETE;\n    }\n  } {wal delete}\n\n  do_test $tn.2 {\n    sql2 { PRAGMA integrity_check }\n  } {ok}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-5e10420e8d.test",
    "content": "# 2010 August 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test tkt-5e10420e8d.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA auto_vacuum = incremental;\n\n  CREATE TABLE t1(x);\n  CREATE TABLE t2(x);\n  CREATE TABLE t3(x);\n} {}\n\ndo_execsql_test tkt-5e10420e8d.2 {\n  INSERT INTO t3 VALUES(randomblob(500 + 1024*248));\n  INSERT INTO t1 VALUES(randomblob(1500));\n  INSERT INTO t2 VALUES(randomblob(500 + 1024*248));\n\n  DELETE FROM t3;\n  DELETE FROM t2;\n  DELETE FROM t1;\n} {}\n\ndo_execsql_test tkt-5e10420e8d.3 {\n  PRAGMA incremental_vacuum(248)\n} {}\n\ndo_execsql_test tkt-5e10420e8d.4 {\n  PRAGMA incremental_vacuum(1)\n} {}\n\ndb close\nsqlite3 db test.db\n\ndo_execsql_test tkt-5e10420e8d.5 {\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-5ee23731f.test",
    "content": "# 2009 October 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [5ee23731f15] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-5ee237-1.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(x UNIQUE);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT x+2 FROM t1;\n    INSERT INTO t1 SELECT x+4 FROM t1;\n    INSERT INTO t1 SELECT x+8 FROM t1;\n  }\n  db close\n  sqlite3 db test.db -readonly 1\n  set rc [catch {\n    db eval {SELECT rowid, x FROM t1 ORDER BY x} {\n      db eval {UPDATE t1 SET x=x+1 WHERE rowid=:rowid}\n    }\n  } msg]\n  lappend rc $msg\n} {1 {attempt to write a readonly database}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-6bfb98dfc0.test",
    "content": "# 2013 March 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [6bfb98dfc0]\n#\n# The final INSERT in the script below reports that the database is\n# corrupt (SQLITE_CORRUPT) and aborts even though the database is not\n# corrupt.\n#\n#    PRAGMA page_size=512;\n#    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n#    INSERT INTO t1 VALUES(1,randomblob(400));\n#    INSERT INTO t1 VALUES(2,randomblob(400));\n#    INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;\n#    INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;\n#    INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;\n#    INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;\n#    INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;\n#    INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;\n#    CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN\n#      DELETE FROM t1;\n#      INSERT INTO t1 VALUES(75, randomblob(400));\n#      INSERT INTO t1 VALUES(76, randomblob(400));\n#    END;\n#    INSERT INTO t1 VALUES(74, randomblob(400));\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-6bfb98dfc0.100 {\n  db eval {\n    PRAGMA page_size=512;\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y);\n    INSERT INTO t1 VALUES(1,randomblob(400));\n    INSERT INTO t1 VALUES(2,randomblob(400));\n    INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1;\n    INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1;\n    INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1;\n    INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1;\n    INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1;\n    INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10;\n    CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES(75, randomblob(400));\n      INSERT INTO t1 VALUES(76, randomblob(400));\n    END;\n    INSERT INTO t1 VALUES(74, randomblob(400));\n    SELECT x, length(y) FROM t1 ORDER BY x;\n  }\n} {75 400 76 400}\n    \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-752e1646fc.test",
    "content": "# 2010 April 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [752e1646fc] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-752e1646fc-1.1 {\n  execsql {\n    CREATE TABLE \"test\" (\"letter\" VARCHAR(1) PRIMARY KEY, \"number\" INTEGER NOT NULL);\n    INSERT INTO \"test\" (\"letter\", \"number\") VALUES('b', 1); \n    INSERT INTO \"test\" (\"letter\", \"number\") VALUES('a', 2); \n    INSERT INTO \"test\" (\"letter\", \"number\") VALUES('c', 2); \n    SELECT DISTINCT \"number\" FROM (SELECT \"letter\", \"number\" FROM \"test\" ORDER BY \"letter\", \"number\" LIMIT 1) AS \"test\";\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-78e04e52ea.test",
    "content": "# 2009 December 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# Verify that we can create zero-length tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-78e04-1.0 {\n  execsql {\n    CREATE TABLE \"\"(\"\" UNIQUE, x CHAR(100));\n    CREATE TABLE t2(x);\n    INSERT INTO \"\"(\"\") VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    SELECT * FROM \"\", t2;\n  }\n} {1 {} 2}\ndo_test tkt-78e04-1.1 {\n  catchsql {\n    INSERT INTO \"\"(\"\") VALUES(1);\n  }\n} {1 {UNIQUE constraint failed: .}}\ndo_test tkt-78e04-1.2 {\n  execsql {\n    PRAGMA table_info(\"\");\n  }\n} {0 {} {} 0 {} 0 1 x CHAR(100) 0 {} 0}\ndo_test tkt-78e04-1.3 {\n  execsql {\n    CREATE INDEX i1 ON \"\"(\"\" COLLATE nocase);\n  }\n} {}\ndo_test tkt-78e04-1.4 {\n  execsql {\n    EXPLAIN QUERY PLAN SELECT \"\" FROM \"\" WHERE \"\" LIKE '1abc%';\n  }\n} {0 0 0 {SCAN TABLE  USING COVERING INDEX i1}}\ndo_test tkt-78e04-1.5 {\n  execsql {\n    DROP TABLE \"\";\n    SELECT name FROM sqlite_master;\n  }\n} {t2}\n\ndo_test tkt-78e04-2.1 {\n  execsql {\n    CREATE INDEX \"\" ON t2(x);\n    EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=5;\n  }\n} {0 0 0 {SEARCH TABLE t2 USING COVERING INDEX  (x=?)}}\ndo_test tkt-78e04-2.2 {\n  execsql {\n    DROP INDEX \"\";\n    EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE x=2;\n  }\n} {0 0 0 {SCAN TABLE t2}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-7a31705a7e6.test",
    "content": "# 2013 February 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [7a31705a7e6c95d514e6f20a6900f436bbc9fed8] in the\n# name resolver has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test tkt-7a31705a7e6-1.1 {\n  CREATE TABLE t1 (a INTEGER PRIMARY KEY);\n  CREATE TABLE t2 (a INTEGER PRIMARY KEY, b INTEGER);\n  CREATE TABLE t2x (b INTEGER PRIMARY KEY);\n  SELECT t1.a FROM ((t1 JOIN t2 ON t1.a=t2.a) AS x JOIN t2x ON x.b=t2x.b) as y;\n} {}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-7bbfb7d442.test",
    "content": "# 2011 December 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [7bbfb7d442] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-7bbfb7d442\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a, b);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n  INSERT INTO t1 VALUES(3, 'three');\n\n  CREATE TABLE t2(c, d);\n  INSERT INTO t2 VALUES('one', 'I');\n  INSERT INTO t2 VALUES('two', 'II');\n  INSERT INTO t2 VALUES('three', 'III');\n\n  CREATE TABLE t3(t3_a PRIMARY KEY, t3_d);\n  CREATE TRIGGER t3t AFTER INSERT ON t3 WHEN new.t3_d IS NULL BEGIN\n    UPDATE t3 SET t3_d = (\n      SELECT d FROM \n        (SELECT * FROM t2 WHERE (new.t3_a%2)=(rowid%2) LIMIT 10),\n        (SELECT * FROM t1 WHERE (new.t3_a%2)=(rowid%2) LIMIT 10)\n      WHERE a = new.t3_a AND b = c\n    ) WHERE t3_a = new.t3_a;\n  END;\n}\n\ndo_execsql_test 1.2 {\n  INSERT INTO t3(t3_a) VALUES(1);\n  INSERT INTO t3(t3_a) VALUES(2);\n  INSERT INTO t3(t3_a) VALUES(3);\n  SELECT * FROM t3;\n} {1 I 2 II 3 III}\n\ndo_execsql_test 1.3 { DELETE FROM t3 }\n\nifcapable compound {\n  do_execsql_test 1.4 {\n    INSERT INTO t3(t3_a) SELECT 1 UNION SELECT 2 UNION SELECT 3;\n    SELECT * FROM t3;\n  } {1 I 2 II 3 III}\n}\n\n\n\n#-------------------------------------------------------------------------\n# The following test case - 2.* - is from the original bug report as \n# posted to the mailing list.\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE InventoryControl (\n    InventoryControlId INTEGER PRIMARY KEY AUTOINCREMENT,\n    SKU INTEGER NOT NULL,\n    Variant INTEGER NOT NULL DEFAULT 0,\n    ControlDate DATE NOT NULL,\n    ControlState INTEGER NOT NULL DEFAULT -1,\n    DeliveredQty VARCHAR(30)\n  );\n  \n  CREATE TRIGGER TGR_InventoryControl_AfterInsert\n  AFTER INSERT ON InventoryControl \n  FOR EACH ROW WHEN NEW.ControlState=-1 BEGIN \n\n  INSERT OR REPLACE INTO InventoryControl(\n        InventoryControlId,SKU,Variant,ControlDate,ControlState,DeliveredQty\n  ) SELECT\n          T1.InventoryControlId AS InventoryControlId,\n          T1.SKU AS SKU,\n          T1.Variant AS Variant,\n          T1.ControlDate AS ControlDate,\n          1 AS ControlState,\n          COALESCE(T2.DeliveredQty,0) AS DeliveredQty\n      FROM (\n          SELECT\n              NEW.InventoryControlId AS InventoryControlId,\n              II.SKU AS SKU,\n              II.Variant AS Variant,\n              COALESCE(LastClosedIC.ControlDate,NEW.ControlDate) AS ControlDate\n          FROM\n              InventoryItem II\n          LEFT JOIN\n              InventoryControl LastClosedIC\n              ON  LastClosedIC.InventoryControlId IN ( SELECT 99999 )\n          WHERE\n              II.SKU=NEW.SKU AND\n              II.Variant=NEW.Variant\n      )   T1\n      LEFT JOIN (\n          SELECT\n              TD.SKU AS SKU,\n              TD.Variant AS Variant,\n              10 AS DeliveredQty\n          FROM\n              TransactionDetail TD\n          WHERE\n              TD.SKU=NEW.SKU AND\n              TD.Variant=NEW.Variant\n      )   T2\n      ON  T2.SKU=T1.SKU AND\n          T2.Variant=T1.Variant;\n  END;\n  \n  CREATE TABLE InventoryItem (\n    SKU INTEGER NOT NULL,\n    Variant INTEGER NOT NULL DEFAULT 0,\n    DeptCode INTEGER NOT NULL,\n    GroupCode INTEGER NOT NULL,\n    ItemDescription VARCHAR(120) NOT NULL,\n    PRIMARY KEY(SKU, Variant)\n  );\n  \n  INSERT INTO InventoryItem VALUES(220,0,1,170,'Scoth Tampon Recurer');\n  INSERT INTO InventoryItem VALUES(31,0,1,110,'Fromage');\n  \n  CREATE TABLE TransactionDetail (\n    TransactionId INTEGER NOT NULL,\n    SKU INTEGER NOT NULL,\n    Variant INTEGER NOT NULL DEFAULT 0,\n    PRIMARY KEY(TransactionId, SKU, Variant)\n  );\n  INSERT INTO TransactionDetail(TransactionId, SKU, Variant) VALUES(44, 31, 0);\n  \n  \n  INSERT INTO InventoryControl(SKU, Variant, ControlDate) SELECT \n      II.SKU AS SKU, II.Variant AS Variant, '2011-08-30' AS ControlDate \n      FROM InventoryItem II;\n}\n\ndo_execsql_test 2.2 {\n  SELECT SKU, DeliveredQty FROM InventoryControl WHERE SKU=31\n} {31 10}\n\ndo_execsql_test 2.3 {\n  SELECT CASE WHEN DeliveredQty=10 THEN \"TEST PASSED!\" ELSE \"TEST FAILED!\" END \n  FROM InventoryControl WHERE SKU=31; \n} {{TEST PASSED!}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-80ba201079.test",
    "content": "# 2010 December 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [80ba201079ea608071d22a57856b940ea3ac53ce] is\n# resolved.  That ticket is about an incorrect result that appears when\n# an index is added.  The root cause is that a constant is being used\n# without initialization when the OR optimization applies in the WHERE clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix tkt-80ba201079\n\ndo_test tkt-80ba2-100 {\n  db eval {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES('A');\n    CREATE TABLE t2(b);\n    INSERT INTO t2 VALUES('B');\n    CREATE TABLE t3(c);\n    INSERT INTO t3 VALUES('C');\n    SELECT * FROM t1, t2\n     WHERE (a='A' AND b='X')\n        OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));\n  }\n} {A B}\ndo_test tkt-80ba2-101 {\n  db eval {\n    CREATE INDEX i1 ON t1(a);\n    SELECT * FROM t1, t2\n     WHERE (a='A' AND b='X')\n        OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));\n  }\n} {A B}\ndo_test tkt-80ba2-102 {\n  optimization_control db factor-constants 0\n  db cache flush\n  db eval {\n    SELECT * FROM t1, t2\n     WHERE (a='A' AND b='X')\n        OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));\n  }\n} {A B}\noptimization_control db all 1\n\n# Verify that the optimization_control command is actually working\n#\ndo_test tkt-80ba2-150 {\n  optimization_control db factor-constants 1\n  db cache flush\n  set x1 [db eval {EXPLAIN \n    SELECT * FROM t1, t2\n     WHERE (a='A' AND b='X')\n        OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));}]\n  optimization_control db factor-constants 0\n  db cache flush\n  set x2 [db eval {EXPLAIN \n    SELECT * FROM t1, t2\n     WHERE (a='A' AND b='X')\n        OR (a='A' AND EXISTS (SELECT * FROM t3 WHERE c='C'));}]\n\n  expr {$x1==$x2}\n} {0}\n\ndo_test tkt-80ba2-200 {\n  db eval {\n    CREATE TABLE entry_types (\n                        id     integer primary key,\n                        name   text\n                    );\n    INSERT INTO \"entry_types\" VALUES(100,'cli_command');\n    INSERT INTO \"entry_types\" VALUES(300,'object_change');\n    CREATE TABLE object_changes (\n                        change_id    integer primary key,\n                        system_id    int,\n                        obj_id       int,\n                        obj_context  text,\n                        change_type  int,\n                        command_id   int\n                    );\n    INSERT INTO \"object_changes\" VALUES(1551,1,114608,'exported_pools',1,2114);\n    INSERT INTO \"object_changes\" VALUES(2048,1,114608,'exported_pools',2,2319);\n    CREATE TABLE timeline (\n                        rowid        integer primary key,\n                        timestamp    text,\n                        system_id    int,\n                        entry_type   int,\n                        entry_id     int\n                    );\n    INSERT INTO \"timeline\" VALUES(6735,'2010-11-21 17:08:27.000',1,300,2048);\n    INSERT INTO \"timeline\" VALUES(6825,'2010-11-21 17:09:21.000',1,300,2114);\n    SELECT entry_type,\n           entry_types.name,\n           entry_id\n      FROM timeline JOIN entry_types ON entry_type = entry_types.id\n     WHERE (entry_types.name = 'cli_command' AND entry_id=2114)\n        OR (entry_types.name = 'object_change'\n             AND entry_id IN (SELECT change_id\n                              FROM object_changes\n                               WHERE obj_context = 'exported_pools'));\n  }\n} {300 object_change 2048}\ndo_test tkt-80ba2-201 {\n  db eval {\n    CREATE INDEX timeline_entry_id_idx on timeline(entry_id);\n    SELECT entry_type,\n           entry_types.name,\n           entry_id\n      FROM timeline JOIN entry_types ON entry_type = entry_types.id\n     WHERE (entry_types.name = 'cli_command' AND entry_id=2114)\n        OR (entry_types.name = 'object_change'\n             AND entry_id IN (SELECT change_id\n                              FROM object_changes\n                               WHERE obj_context = 'exported_pools'));\n  }\n} {300 object_change 2048}\ndo_test tkt-80ba2-202 {\n  optimization_control db factor-constants 0\n  db cache flush\n  db eval {\n    SELECT entry_type,\n           entry_types.name,\n           entry_id\n      FROM timeline JOIN entry_types ON entry_type = entry_types.id\n     WHERE (entry_types.name = 'cli_command' AND entry_id=2114)\n        OR (entry_types.name = 'object_change'\n             AND entry_id IN (SELECT change_id\n                              FROM object_changes\n                               WHERE obj_context = 'exported_pools'));\n  }\n} {300 object_change 2048}\n\n#-------------------------------------------------------------------------\n#\n\ndrop_all_tables\ndo_execsql_test 301 {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n  CREATE TABLE t2(d, e);\n\n  INSERT INTO t1 VALUES('A', 'B', 'C');\n  INSERT INTO t2 VALUES('D', 'E');\n}\n\ndo_execsql_test 302 {\n  SELECT * FROM t1, t2 WHERE\n    (a='A' AND d='E') OR\n    (b='B' AND c IN ('C', 'D', 'E'))\n} {A B C D E}\n\ndo_execsql_test 303 {\n  SELECT * FROM t1, t2 WHERE\n    (a='A' AND d='E') OR\n    (b='B' AND c IN (SELECT c FROM t1))\n} {A B C D E}\n\nifcapable compound {\n  do_execsql_test 304 {\n    SELECT * FROM t1, t2 WHERE\n      (a='A' AND d='E') OR\n      (b='B' AND c IN (SELECT 'B' UNION SELECT 'C' UNION SELECT 'D'))\n  } {A B C D E}\n}\n\ndo_execsql_test 305 {\n  SELECT * FROM t1, t2 WHERE\n    (b='B' AND c IN ('C', 'D', 'E')) OR\n    (a='A' AND d='E')\n} {A B C D E}\n\ndo_execsql_test 306 {\n  SELECT * FROM t1, t2 WHERE\n    (b='B' AND c IN (SELECT c FROM t1)) OR\n    (a='A' AND d='E')\n} {A B C D E}\n\nifcapable compound {\n  do_execsql_test 307 {\n    SELECT * FROM t1, t2 WHERE\n      (b='B' AND c IN (SELECT 'B' UNION SELECT 'C' UNION SELECT 'D')) OR\n      (a='A' AND d='E')\n  } {A B C D E}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-80e031a00f.test",
    "content": "# 2010 July 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [80e031a00f45dca877ed92b225209cfa09280f4f] has been\n# resolved.  That ticket is about IN and NOT IN operators with empty-set\n# right-hand sides.  Such expressions should always return TRUE or FALSE\n# even if the left-hand side is NULL.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\n# EVIDENCE-OF: R-52275-55503 When the right operand is an empty set, the\n# result of IN is false and the result of NOT IN is true, regardless of\n# the left operand and even if the left operand is NULL.\n#\n# EVIDENCE-OF: R-13595-45863 Note that SQLite allows the parenthesized\n# list of scalar values on the right-hand side of an IN or NOT IN\n# operator to be an empty list but most other SQL database database\n# engines and the SQL92 standard require the list to contain at least\n# one element.\n#\ndo_execsql_test tkt-80e031a00f.1 {SELECT 1 IN ()} 0\ndo_execsql_test tkt-80e031a00f.1b {SELECT 1 IN (2)} 0\ndo_execsql_test tkt-80e031a00f.1c {SELECT 1 IN (2,3,4,5,6,7,8,9)} 0\ndo_execsql_test tkt-80e031a00f.2 {SELECT 1 NOT IN ()} 1\ndo_execsql_test tkt-80e031a00f.2b {SELECT 1 NOT IN (2)} 1\ndo_execsql_test tkt-80e031a00f.2c {SELECT 1 NOT IN (2,3,4,5,6,7,8,9)} 1\ndo_execsql_test tkt-80e031a00f.3 {SELECT null IN ()} 0\ndo_execsql_test tkt-80e031a00f.4 {SELECT null NOT IN ()} 1\ndo_execsql_test tkt-80e031a00f.5 {\n  CREATE TABLE t1(x);\n  SELECT 1 IN t1;\n} 0\ndo_execsql_test tkt-80e031a00f.6 {SELECT 1 NOT IN t1} 1\ndo_execsql_test tkt-80e031a00f.7 {SELECT null IN t1} 0\ndo_execsql_test tkt-80e031a00f.8 {SELECT null NOT IN t1} 1\ndo_execsql_test tkt-80e031a00f.9 {\n  CREATE TABLE t2(y INTEGER PRIMARY KEY);\n  SELECT 1 IN t2;\n} 0\ndo_execsql_test tkt-80e031a00f.10 {SELECT 1 NOT IN t2} 1\ndo_execsql_test tkt-80e031a00f.11 {SELECT null IN t2} 0\ndo_execsql_test tkt-80e031a00f.12 {SELECT null NOT IN t2} 1\ndo_execsql_test tkt-80e031a00f.13 {\n  CREATE TABLE t3(z INT UNIQUE);\n  SELECT 1 IN t3;\n} 0\ndo_execsql_test tkt-80e031a00f.14 {SELECT 1 NOT IN t3} 1\ndo_execsql_test tkt-80e031a00f.15 {SELECT null IN t3} 0\ndo_execsql_test tkt-80e031a00f.16 {SELECT null NOT IN t3} 1\ndo_execsql_test tkt-80e031a00f.17 {SELECT 1 IN (SELECT x+y FROM t1, t2)} 0\ndo_execsql_test tkt-80e031a00f.18 {SELECT 1 NOT IN (SELECT x+y FROM t1,t2)} 1\ndo_execsql_test tkt-80e031a00f.19 {SELECT null IN (SELECT x+y FROM t1,t2)} 0\ndo_execsql_test tkt-80e031a00f.20 {SELECT null NOT IN (SELECT x+y FROM t1,t2)} 1\ndo_execsql_test tkt-80e031a00f.21 {SELECT 1.23 IN ()} 0\ndo_execsql_test tkt-80e031a00f.22 {SELECT 1.23 NOT IN ()} 1\ndo_execsql_test tkt-80e031a00f.23 {SELECT 1.23 IN t1} 0\ndo_execsql_test tkt-80e031a00f.24 {SELECT 1.23 NOT IN t1} 1\ndo_execsql_test tkt-80e031a00f.25 {SELECT 'hello' IN ()} 0\ndo_execsql_test tkt-80e031a00f.26 {SELECT 'hello' NOT IN ()} 1\ndo_execsql_test tkt-80e031a00f.27 {SELECT 'hello' IN t1} 0\ndo_execsql_test tkt-80e031a00f.28 {SELECT 'hello' NOT IN t1} 1\ndo_execsql_test tkt-80e031a00f.29 {SELECT x'303132' IN ()} 0\ndo_execsql_test tkt-80e031a00f.30 {SELECT x'303132' NOT IN ()} 1\ndo_execsql_test tkt-80e031a00f.31 {SELECT x'303132' IN t1} 0\ndo_execsql_test tkt-80e031a00f.32 {SELECT x'303132' NOT IN t1} 1\n\n# EVIDENCE-OF: R-50221-42915 The result of an IN or NOT IN operator is\n# determined by the following matrix: Left operand is NULL Right operand\n# contains NULL Right operand is an empty set Left operand found within\n# right operand Result of IN operator Result of NOT IN operator no no no\n# no false true does not matter no yes no false true no does not matter\n# no yes true false no yes no no NULL NULL yes does not matter no does\n# not matter NULL NULL\n#\n# Row 1:\ndo_execsql_test tkt-80e031a00f.100 {SELECT 1 IN (2,3,4)} 0\ndo_execsql_test tkt-80e031a00f.101 {SELECT 1 NOT IN (2,3,4)} 1\ndo_execsql_test tkt-80e031a00f.102 {SELECT 'a' IN ('b','c','d')} 0\ndo_execsql_test tkt-80e031a00f.103 {SELECT 'a' NOT IN ('b','c','d')} 1\ndo_test tkt-80e031a00f.104 {\n  db eval {\n     CREATE TABLE t4(a UNIQUE);\n     CREATE TABLE t5(b INTEGER PRIMARY KEY);\n     CREATE TABLE t6(c);\n     INSERT INTO t4 VALUES(2);\n     INSERT INTO t4 VALUES(3);\n     INSERT INTO t4 VALUES(4);\n     INSERT INTO t5 SELECT * FROM t4;\n     INSERT INTO t6 SELECT * FROM t4;\n     CREATE TABLE t4n(a UNIQUE);\n     CREATE TABLE t6n(c);\n     INSERT INTO t4n SELECT * FROM t4;\n     INSERT INTO t4n VALUES(null);\n     INSERT INTO t6n SELECT * FROM t4n;\n     CREATE TABLE t7(a UNIQUE);\n     CREATE TABLE t8(c);\n     INSERT INTO t7 VALUES('b');\n     INSERT INTO t7 VALUES('c');\n     INSERT INTO t7 VALUES('d');\n     INSERT INTO t8 SELECT * FROM t7;\n     CREATE TABLE t7n(a UNIQUE);\n     CREATE TABLE t8n(c);\n     INSERT INTO t7n SELECT * FROM t7;\n     INSERT INTO t7n VALUES(null);\n     INSERT INTO t8n SELECT * FROM t7n;\n  }\n  execsql {SELECT 1 IN t4}\n} 0\ndo_execsql_test tkt-80e031a00f.105 {SELECT 1 NOT IN t4} 1\ndo_execsql_test tkt-80e031a00f.106 {SELECT 1 IN t5} 0\ndo_execsql_test tkt-80e031a00f.107 {SELECT 1 NOT IN t5} 1\ndo_execsql_test tkt-80e031a00f.108 {SELECT 1 IN t6} 0\ndo_execsql_test tkt-80e031a00f.109 {SELECT 1 NOT IN t6} 1\ndo_execsql_test tkt-80e031a00f.110 {SELECT 'a' IN t7} 0\ndo_execsql_test tkt-80e031a00f.111 {SELECT 'a' NOT IN t7} 1\ndo_execsql_test tkt-80e031a00f.112 {SELECT 'a' IN t8} 0\ndo_execsql_test tkt-80e031a00f.113 {SELECT 'a' NOT IN t8} 1\n#\n# Row 2 is tested by cases 1-32 above.\n# Row 3:\ndo_execsql_test tkt-80e031a00f.300 {SELECT 2 IN (2,3,4,null)} 1\ndo_execsql_test tkt-80e031a00f.301 {SELECT 3 NOT IN (2,3,4,null)} 0\ndo_execsql_test tkt-80e031a00f.302 {SELECT 4 IN (2,3,4)} 1\ndo_execsql_test tkt-80e031a00f.303 {SELECT 2 NOT IN (2,3,4)} 0\ndo_execsql_test tkt-80e031a00f.304 {SELECT 'b' IN ('b','c','d')} 1\ndo_execsql_test tkt-80e031a00f.305 {SELECT 'c' NOT IN ('b','c','d')} 0\ndo_execsql_test tkt-80e031a00f.306 {SELECT 'd' IN ('b','c',null,'d')} 1\ndo_execsql_test tkt-80e031a00f.307 {SELECT 'b' NOT IN (null,'b','c','d')} 0\ndo_execsql_test tkt-80e031a00f.308 {SELECT 2 IN t4} 1\ndo_execsql_test tkt-80e031a00f.309 {SELECT 3 NOT IN t4} 0\ndo_execsql_test tkt-80e031a00f.310 {SELECT 4 IN t4n} 1\ndo_execsql_test tkt-80e031a00f.311 {SELECT 2 NOT IN t4n} 0\ndo_execsql_test tkt-80e031a00f.312 {SELECT 2 IN t5} 1\ndo_execsql_test tkt-80e031a00f.313 {SELECT 3 NOT IN t5} 0\ndo_execsql_test tkt-80e031a00f.314 {SELECT 2 IN t6} 1\ndo_execsql_test tkt-80e031a00f.315 {SELECT 3 NOT IN t6} 0\ndo_execsql_test tkt-80e031a00f.316 {SELECT 4 IN t6n} 1\ndo_execsql_test tkt-80e031a00f.317 {SELECT 2 NOT IN t6n} 0\ndo_execsql_test tkt-80e031a00f.318 {SELECT 'b' IN t7} 1\ndo_execsql_test tkt-80e031a00f.319 {SELECT 'c' NOT IN t7} 0\ndo_execsql_test tkt-80e031a00f.320 {SELECT 'c' IN t7n} 1\ndo_execsql_test tkt-80e031a00f.321 {SELECT 'd' NOT IN t7n} 0\ndo_execsql_test tkt-80e031a00f.322 {SELECT 'b' IN t8} 1\ndo_execsql_test tkt-80e031a00f.323 {SELECT 'c' NOT IN t8} 0\ndo_execsql_test tkt-80e031a00f.324 {SELECT 'c' IN t8n} 1\ndo_execsql_test tkt-80e031a00f.325 {SELECT 'd' NOT IN t8n} 0\ndo_execsql_test tkt-80e031a00f.326 {SELECT 'a' IN (NULL,'a')} 1\ndo_execsql_test tkt-80e031a00f.327 {SELECT 'a' IN (NULL,'b')} {{}}\ndo_execsql_test tkt-80e031a00f.328 {SELECT 'a' NOT IN (NULL,'a')} 0\ndo_execsql_test tkt-80e031a00f.329 {SELECT 'a' NOT IN (NULL,'b')} {{}}\n#\n# Row 4:\ndo_execsql_test tkt-80e031a00f.400 {SELECT 1 IN (2,3,4,null)} {{}}\ndo_execsql_test tkt-80e031a00f.401 {SELECT 1 NOT IN (2,3,4,null)} {{}}\ndo_execsql_test tkt-80e031a00f.402 {SELECT 'a' IN ('b','c',null,'d')} {{}}\ndo_execsql_test tkt-80e031a00f.403 {SELECT 'a' NOT IN (null,'b','c','d')} {{}}\ndo_execsql_test tkt-80e031a00f.404 {SELECT 1 IN t4n} {{}}\ndo_execsql_test tkt-80e031a00f.405 {SELECT 5 NOT IN t4n} {{}}\ndo_execsql_test tkt-80e031a00f.406 {SELECT 6 IN t6n} {{}}\ndo_execsql_test tkt-80e031a00f.407 {SELECT 7 NOT IN t6n} {{}}\ndo_execsql_test tkt-80e031a00f.408 {SELECT 'a' IN t7n} {{}}\ndo_execsql_test tkt-80e031a00f.409 {SELECT 'e' NOT IN t7n} {{}}\ndo_execsql_test tkt-80e031a00f.410 {SELECT 'f' IN t8n} {{}}\ndo_execsql_test tkt-80e031a00f.411 {SELECT 'g' NOT IN t8n} {{}}\n#\n# Row 5:\ndo_execsql_test tkt-80e031a00f.500 {SELECT null IN (2,3,4,null)} {{}}\ndo_execsql_test tkt-80e031a00f.501 {SELECT null NOT IN (2,3,4,null)} {{}}\ndo_execsql_test tkt-80e031a00f.502 {SELECT null IN (2,3,4)} {{}}\ndo_execsql_test tkt-80e031a00f.503 {SELECT null NOT IN (2,3,4)} {{}}\ndo_execsql_test tkt-80e031a00f.504 {SELECT null IN ('b','c','d')} {{}}\ndo_execsql_test tkt-80e031a00f.505 {SELECT null NOT IN ('b','c','d')} {{}}\ndo_execsql_test tkt-80e031a00f.506 {SELECT null IN ('b','c',null,'d')} {{}}\ndo_execsql_test tkt-80e031a00f.507 {SELECT null NOT IN (null,'b','c','d')} {{}}\ndo_execsql_test tkt-80e031a00f.508 {SELECT null IN t4} {{}}\ndo_execsql_test tkt-80e031a00f.509 {SELECT null NOT IN t4} {{}}\ndo_execsql_test tkt-80e031a00f.510 {SELECT null IN t4n} {{}}\ndo_execsql_test tkt-80e031a00f.511 {SELECT null NOT IN t4n} {{}}\ndo_execsql_test tkt-80e031a00f.512 {SELECT null IN t5} {{}}\ndo_execsql_test tkt-80e031a00f.513 {SELECT null NOT IN t5} {{}}\ndo_execsql_test tkt-80e031a00f.514 {SELECT null IN t6} {{}}\ndo_execsql_test tkt-80e031a00f.515 {SELECT null NOT IN t6} {{}}\ndo_execsql_test tkt-80e031a00f.516 {SELECT null IN t6n} {{}}\ndo_execsql_test tkt-80e031a00f.517 {SELECT null NOT IN t6n} {{}}\ndo_execsql_test tkt-80e031a00f.518 {SELECT null IN t7} {{}}\ndo_execsql_test tkt-80e031a00f.519 {SELECT null NOT IN t7} {{}}\ndo_execsql_test tkt-80e031a00f.520 {SELECT null IN t7n} {{}}\ndo_execsql_test tkt-80e031a00f.521 {SELECT null NOT IN t7n} {{}}\ndo_execsql_test tkt-80e031a00f.522 {SELECT null IN t8} {{}}\ndo_execsql_test tkt-80e031a00f.523 {SELECT null NOT IN t8} {{}}\ndo_execsql_test tkt-80e031a00f.524 {SELECT null IN t8n} {{}}\ndo_execsql_test tkt-80e031a00f.525 {SELECT null NOT IN t8n} {{}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-8454a207b9.test",
    "content": "# 2010 September 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [8454a207b9fd2243c4c6b7a73f67ea0315717c1a].  Verify\n# that a negative default value on an added text column actually comes\n# out negative.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-8454a207b9.1 {\n  db eval {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    ALTER TABLE t1 ADD COLUMN b TEXT DEFAULT -123.0;\n    SELECT b, typeof(b) FROM t1;\n  }\n} {-123.0 text}\ndo_test tkt-8454a207b9.2 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN c TEXT DEFAULT -123.5;\n    SELECT c, typeof(c) FROM t1;\n  }\n} {-123.5 text}\ndo_test tkt-8454a207b9.3 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT -'hello';\n    SELECT d, typeof(d) FROM t1;\n  }\n} {0 text}\ndo_test tkt-8454a207b9.4 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN e DEFAULT -123.0;\n    SELECT e, typeof(e) FROM t1;\n  }\n} {-123 integer}\ndo_test tkt-8454a207b9.5 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN f DEFAULT -123.5;\n    SELECT f, typeof(f) FROM t1;\n  }\n} {-123.5 real}\ndo_test tkt-8454a207b9.6 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN g DEFAULT -9223372036854775808;\n    SELECT g, typeof(g) FROM t1;\n  }\n} {-9223372036854775808 integer}\ndo_test tkt-8454a207b9.7 {\n  db eval {\n    ALTER TABLE t1 ADD COLUMN h DEFAULT 9223372036854775807;\n    SELECT h, typeof(h) FROM t1;\n  }\n} {9223372036854775807 integer}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-868145d012.test",
    "content": "# 2013 March 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [868145d012a1] is fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test tkt-868145d012.100 {\n  CREATE TABLE p (\n    id INTEGER PRIMARY KEY,\n    uid VARCHAR(36),\n    t INTEGER\n  );\n  \n  CREATE TABLE pa (\n    id INTEGER PRIMARY KEY,\n    a_uid VARCHAR(36)\n  );\n  \n  CREATE TABLE a (\n    id INTEGER PRIMARY KEY,\n    uid VARCHAR(36),\n    t INTEGER\n  );\n  \n  INSERT INTO pa VALUES(1,'1234');\n  INSERT INTO pa VALUES(2,'2345');\n  INSERT INTO p VALUES(3,'1234',97);\n  INSERT INTO p VALUES(4,'1234',98);\n  INSERT INTO a VALUES(5,'1234',98);\n  INSERT INTO a VALUES(6,'1234',99);\n} {}\ndo_execsql_test tkt-868145d012.110 {\n  SELECT DISTINCT pa.id, p.id, a.id\n  FROM\n    pa\n    LEFT JOIN p ON p.uid='1234'\n    LEFT JOIN a ON a.uid=pa.a_uid\n  WHERE\n    a.t=p.t\n  ;\n} {1 4 5}\ndo_execsql_test tkt-868145d012.120 {\n  SELECT DISTINCT pa.id, p.id, a.id\n  FROM\n    pa\n    LEFT JOIN p ON p.uid='1234'\n    LEFT JOIN a ON a.uid=pa.a_uid AND a.t=p.t\n  ORDER BY 1, 2, 3\n  ;\n} {1 3 {} 1 4 5 2 3 {} 2 4 {}}\n\n    \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-8c63ff0ec.test",
    "content": "# 2014-02-25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases to show that ticket [8c63ff0eca81a9132d8d67b31cd6ae9712a2cc6f]\n# \"Incorrect query result on a UNION ALL\" which was caused by using the same\n# temporary register in concurrent co-routines, as been fixed.\n# \n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix tkt-8c63ff0ec\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, d, e);\n  INSERT INTO t1 VALUES(1,20,30,40,50),(3,60,70,80,90);\n  CREATE TABLE t2(x INTEGER PRIMARY KEY);\n  INSERT INTO t2 VALUES(2);\n  CREATE TABLE t3(z);\n  INSERT INTO t3 VALUES(2),(2),(2),(2);\n  \n  SELECT a, b+c FROM t1\n  UNION ALL\n  SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2\n  ORDER BY a;\n} {1 50 2 5 2 5 2 5 2 5 3 130}\ndo_execsql_test 1.2 {\n  SELECT a, b+c+d FROM t1\n  UNION ALL\n  SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2\n  ORDER BY a;\n} {1 90 2 5 2 5 2 5 2 5 3 210}\ndo_execsql_test 1.3 {\n  SELECT a, b+c+d+e FROM t1\n  UNION ALL\n  SELECT x, 5 FROM t2 JOIN t3 ON z=x WHERE x=2\n  ORDER BY a;\n} {1 140 2 5 2 5 2 5 2 5 3 300}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-91e2e8ba6f.test",
    "content": "# 2011 June 23\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for SQLite. Specifically, it tests that SQLite\n# does not crash and an error is returned if localhost() fails. This \n# is the problem reported by ticket 91e2e8ba6f.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix tkt-91e2e8ba6f\n\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(x INTEGER, y REAL);\n  INSERT INTO t1 VALUES(11, 11);\n} {}\n\ndo_execsql_test 1.2 {\n  SELECT x/10, y/10 FROM t1;\n} {1 1.1}\n\ndo_execsql_test 1.3 {\n  SELECT x/10, y/10 FROM (SELECT * FROM t1);\n} {1 1.1}\n\ndo_execsql_test 1.4 {\n  SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0);\n} {1 1.1}\n\ndo_execsql_test 1.5 {\n  SELECT x/10, y/10 FROM (SELECT * FROM t1 LIMIT 5 OFFSET 0) LIMIT 5 OFFSET 0;\n} {1 1.1}\n\ndo_execsql_test 1.6 {\n  SELECT a.x/10, a.y/10 FROM \n    (SELECT * FROM t1 LIMIT 5 OFFSET 0) AS a, t1 AS b WHERE a.x = b.x\n  LIMIT 5 OFFSET 0;\n} {1 1.1}\n\ndo_execsql_test 1.7 {\n  CREATE VIEW v1 AS SELECT * FROM t1 LIMIT 5;\n  SELECT a.x/10, a.y/10 FROM v1 AS a, t1 AS b WHERE a.x = b.x LIMIT 5 OFFSET 0;\n} {1 1.1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-94c04eaadb.test",
    "content": "# 2009 October 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[info commands sqlite3async_initialize] eq \"\"} {\n  # The async logic is not built into this system\n  finish_test\n  return\n}\n\n# Create a database.\ndo_test tkt-94c94-1.1 {\n  execsql { CREATE TABLE t1(a, b) }\n} {}\n\n# Grow the file to larger than 4096MB (2^32 bytes)\ndb close\nif {[catch {fake_big_file 4096 [get_pwd]/test.db} msg]} {\n  puts \"**** Unable to create a file larger than 4096 MB. *****\"\n  finish_test\n  return\n}\n\n# Switch to async mode.\nsqlite3async_initialize \"\" 1\nsqlite3 db test.db\nsqlite3 db2 test.db\n\n# Read from and write to the db just past the 4096MB mark.\n#\ndo_test tkt-94c94-2.1 {\n  execsql { CREATE TABLE t2(x, y) } db\n} {}\ndo_test tkt-94c94-2.2 {\n  execsql { INSERT INTO t2 VALUES(1, 2) } db2\n} {}\ndo_test tkt-94c94-2.3 {\n  execsql { SELECT * FROM t2 } db\n} {1 2}\ndo_test tkt-94c94-2.4 {\n  sqlite3async_control halt idle\n  sqlite3async_start\n  sqlite3async_wait\n} {}\ndo_test tkt-94c94-2.5 {\n  execsql { SELECT * FROM t2 } db\n} {1 2}\ndo_test tkt-94c94-2.6 {\n  sqlite3async_start\n  sqlite3async_wait\n} {}\n\ndb close\ndb2 close\nsqlite3async_start\nsqlite3async_wait\nsqlite3async_control halt never\nsqlite3async_shutdown\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-9a8b09f8e6.test",
    "content": "# 2014 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [9a8b09f8e6] has been\n# fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-9a8b09f8e6\n\ndo_test 1.1 {\n  execsql {\n    CREATE TABLE t1(x TEXT);\n    INSERT INTO t1 VALUES('1');\n  }\n} {}\n\ndo_test 1.2 {\n  execsql {\n    CREATE TABLE t2(x INTEGER);\n    INSERT INTO t2 VALUES(1);\n  }\n} {}\n\ndo_test 1.3 {\n  execsql {\n    CREATE TABLE t3(x REAL);\n    INSERT INTO t3 VALUES(1.0);\n  }\n} {}\n\ndo_test 1.4 {\n  execsql {\n    CREATE TABLE t4(x REAL);\n    INSERT INTO t4 VALUES(1.11);\n  }\n} {}\n\ndo_test 1.5 {\n  execsql {\n    CREATE TABLE t5(x, y);\n    INSERT INTO t5 VALUES('1', 'one');\n    INSERT INTO t5 VALUES(1, 'two');\n    INSERT INTO t5 VALUES('1.0', 'three');\n    INSERT INTO t5 VALUES(1.0, 'four');\n  }\n} {}\n\ndo_test 2.1 {\n  execsql {\n    SELECT x FROM t1 WHERE x IN (1);\n  }\n} {1}\n\ndo_test 2.2 {\n  execsql {\n    SELECT x FROM t1 WHERE x IN (1.0);\n  }\n} {}\n\ndo_test 2.3 {\n  execsql {\n    SELECT x FROM t1 WHERE x IN ('1');\n  }\n} {1}\n\ndo_test 2.4 {\n  execsql {\n    SELECT x FROM t1 WHERE x IN ('1.0');\n  }\n} {}\n\ndo_test 2.5 {\n  execsql {\n    SELECT x FROM t1 WHERE 1 IN (x);\n  }\n} {}\n\ndo_test 2.6 {\n  execsql {\n    SELECT x FROM t1 WHERE 1.0 IN (x);\n  }\n} {}\n\ndo_test 2.7 {\n  execsql {\n    SELECT x FROM t1 WHERE '1' IN (x);\n  }\n} {1}\n\ndo_test 2.8 {\n  execsql {\n    SELECT x FROM t1 WHERE '1.0' IN (x);\n  }\n} {}\n\ndo_test 3.1 {\n  execsql {\n    SELECT x FROM t2 WHERE x IN (1);\n  }\n} {1}\n\ndo_test 3.2 {\n  execsql {\n    SELECT x FROM t2 WHERE x IN (1.0);\n  }\n} {1}\n\ndo_test 3.3 {\n  execsql {\n    SELECT x FROM t2 WHERE x IN ('1');\n  }\n} {1}\n\ndo_test 3.4 {\n  execsql {\n    SELECT x FROM t2 WHERE x IN ('1.0');\n  }\n} {1}\n\ndo_test 3.5 {\n  execsql {\n    SELECT x FROM t2 WHERE 1 IN (x);\n  }\n} {1}\n\ndo_test 3.6 {\n  execsql {\n    SELECT x FROM t2 WHERE 1.0 IN (x);\n  }\n} {1}\n\ndo_test 3.7 {\n  execsql {\n    SELECT x FROM t2 WHERE '1' IN (x);\n  }\n} {}\n\ndo_test 3.8 {\n  execsql {\n    SELECT x FROM t2 WHERE '1.0' IN (x);\n  }\n} {}\n\ndo_test 4.1 {\n  execsql {\n    SELECT x FROM t3 WHERE x IN (1);\n  }\n} {1.0}\n\ndo_test 4.2 {\n  execsql {\n    SELECT x FROM t3 WHERE x IN (1.0);\n  }\n} {1.0}\n\ndo_test 4.3 {\n  execsql {\n    SELECT x FROM t3 WHERE x IN ('1');\n  }\n} {1.0}\n\ndo_test 4.4 {\n  execsql {\n    SELECT x FROM t3 WHERE x IN ('1.0');\n  }\n} {1.0}\n\ndo_test 4.5 {\n  execsql {\n    SELECT x FROM t3 WHERE 1 IN (x);\n  }\n} {1.0}\n\ndo_test 4.6 {\n  execsql {\n    SELECT x FROM t3 WHERE 1.0 IN (x);\n  }\n} {1.0}\n\ndo_test 4.7 {\n  execsql {\n    SELECT x FROM t3 WHERE '1' IN (x);\n  }\n} {}\n\ndo_test 4.8 {\n  execsql {\n    SELECT x FROM t3 WHERE '1.0' IN (x);\n  }\n} {}\n\ndo_test 5.1 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN (1);\n  }\n} {}\n\ndo_test 5.2 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN (1.0);\n  }\n} {}\n\ndo_test 5.3 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN ('1');\n  }\n} {}\n\ndo_test 5.4 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN ('1.0');\n  }\n} {}\n\ndo_test 5.5 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN (1.11);\n  }\n} {1.11}\n\ndo_test 5.6 {\n  execsql {\n    SELECT x FROM t4 WHERE x IN ('1.11');\n  }\n} {1.11}\n\ndo_test 5.7 {\n  execsql {\n    SELECT x FROM t4 WHERE 1 IN (x);\n  }\n} {}\n\ndo_test 5.8 {\n  execsql {\n    SELECT x FROM t4 WHERE 1.0 IN (x);\n  }\n} {}\n\ndo_test 5.9 {\n  execsql {\n    SELECT x FROM t4 WHERE '1' IN (x);\n  }\n} {}\n\ndo_test 5.10 {\n  execsql {\n    SELECT x FROM t4 WHERE '1.0' IN (x);\n  }\n} {}\n\ndo_test 5.11 {\n  execsql {\n    SELECT x FROM t4 WHERE 1.11 IN (x);\n  }\n} {1.11}\n\ndo_test 5.12 {\n  execsql {\n    SELECT x FROM t4 WHERE '1.11' IN (x);\n  }\n} {}\n\ndo_test 6.1 {\n  execsql {\n    SELECT x, y FROM t5 WHERE x IN (1);\n  }\n} {1 two 1.0 four}\n\ndo_test 6.2 {\n  execsql {\n    SELECT x, y FROM t5 WHERE x IN (1.0);\n  }\n} {1 two 1.0 four}\n\ndo_test 6.3 {\n  execsql {\n    SELECT x, y FROM t5 WHERE x IN ('1');\n  }\n} {1 one}\n\ndo_test 6.4 {\n  execsql {\n    SELECT x, y FROM t5 WHERE x IN ('1.0');\n  }\n} {1.0 three}\n\ndo_test 6.5 {\n  execsql {\n    SELECT x, y FROM t5 WHERE 1 IN (x);\n  }\n} {1 two 1.0 four}\n\ndo_test 6.6 {\n  execsql {\n    SELECT x, y FROM t5 WHERE 1.0 IN (x);\n  }\n} {1 two 1.0 four}\n\ndo_test 6.7 {\n  execsql {\n    SELECT x, y FROM t5 WHERE '1' IN (x);\n  }\n} {1 one}\n\ndo_test 6.8 {\n  execsql {\n    SELECT x, y FROM t5 WHERE '1.0' IN (x);\n  }\n} {1.0 three}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-9d68c883.test",
    "content": "# 2010 April 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests that bug  9d68c883132c8e9ffcd5b0c148c990807b5df1b7\n# is fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-9d68c88-1.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 2;\n    CREATE TABLE t3(x);\n    CREATE TABLE t4(x);\n    CREATE TABLE t5(x);\n    INSERT INTO t5 VALUES(randomblob(1500));\n    CREATE TABLE t7(x);\n    CREATE TABLE t8(x);\n  }\n} {}\n\n\nfor {set i 0} {$i < 100} {incr i} {\n  db close\n  sqlite3_simulate_device -sectorsize 8192\n  sqlite3 db test.db -vfs devsym\n\n  do_test tkt-9d68c88-2.$i {\n    execsql {\n      BEGIN;\n        DELETE FROM t5;\n        INSERT INTO t8 VALUES('hello world');\n    }\n  \n    sqlite3_memdebug_fail $i -repeat 0\n    catchsql { DROP TABLE t7; }\n    sqlite3_memdebug_fail -1\n\n    catchsql { ROLLBACK }\n    execsql { PRAGMA integrity_check }\n  } {ok}\n}\n\ncatch { db close } \nunregister_devsim\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-9f2eb3abac.test",
    "content": "\n# 2013 August 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix tkt-9f2eb3abac\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e));\n  SELECT * FROM t1 WHERE a=? AND b=? AND c=? AND d=? AND e=?;\n} {}\n\ndo_execsql_test 1.2 {\n  CREATE TABLE \"a\" (\n      \"b\" integer NOT NULL,\n      \"c\" integer NOT NULL,\n      PRIMARY KEY (\"b\", \"c\")\n      );\n\n  CREATE TABLE \"d\" (\n      \"e\" integer NOT NULL,\n      \"g\" integer NOT NULL,\n      \"f\" integer NOT NULL,\n      \"h\" integer NOT NULL,\n      \"i\" character(10) NOT NULL,\n      \"j\" int,\n      PRIMARY KEY (\"e\", \"g\", \"f\", \"h\")\n      );\n\n  CREATE TABLE \"d_to_a\" (\n      \"f_e\" integer NOT NULL,\n      \"f_g\" integer NOT NULL,\n      \"f_f\" integer NOT NULL,\n      \"f_h\" integer NOT NULL,\n      \"t_b\" integer NOT NULL,\n      \"t_c\" integer NOT NULL,\n      \"r\" character NOT NULL,\n      \"s\" integer,\n      PRIMARY KEY (\"f_e\", \"f_g\", \"f_f\", \"f_h\", \"t_b\", \"t_c\")\n      );\n\n  INSERT INTO d (g, e, h, f, j, i) VALUES ( 1, 1, 1, 1, 1, 1 );\n  INSERT INTO a (b, c) VALUES ( 1, 1 );\n  INSERT INTO d_to_a VALUES (1, 1, 1, 1, 1, 1, 1, 1);\n\n  DELETE FROM d_to_a \n  WHERE f_g = 1 AND f_e = 1 AND f_h = 1 AND f_f = 1 AND t_b = 1 AND t_c = 1;\n\n  SELECT * FROM d_to_a;\n} {}\n\nfaultsim_delete_and_reopen\ndo_execsql_test 2.0 { CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,d,e)) }\ndo_execsql_test 2.1 { CREATE TABLE t2(x) }\nfaultsim_save_and_close\n\ndo_faultsim_test 3 -faults oom* -prep {\n  faultsim_restore_and_reopen\n  execsql { SELECT 1 FROM sqlite_master }\n} -body {\n  execsql { SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=? AND e=? }\n} -test {\n  faultsim_test_result {0 {}} \n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-a7b7803e.test",
    "content": "# 2012 December 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has\n# been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\ndo_test tkt-a7b7803e.1 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(0,'first'),(99,'fuzzy');\n    SELECT (t1.a==0) AS x, b\n      FROM t1\n     WHERE a=0 OR x;\n  }\n} {1 first}\ndo_test tkt-a7b7803e.2 {\n  db eval {\n    SELECT a, (t1.b='fuzzy') AS x\n      FROM t1\n     WHERE x\n  }\n} {99 1}\ndo_test tkt-a7b7803e.3 {\n  db eval {\n    SELECT (a=99) AS x, (t1.b='fuzzy') AS y, *\n      FROM t1\n     WHERE x AND y\n  }\n} {1 1 99 fuzzy}\ndo_test tkt-a7b7803e.4 {\n  db eval {\n    SELECT (a=99) AS x, (t1.b='first') AS y, *\n      FROM t1\n     WHERE x OR y\n     ORDER BY a\n  }\n} {0 1 0 first 1 0 99 fuzzy}\ndo_test tkt-a7b7803e.5 {\n  db eval {\n    SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b\n      FROM t1 M, t1 N\n     WHERE x OR y\n     ORDER BY M.a, N.a\n  }\n} {0 first 1 first 1 fuzzy 1 first 1 fuzzy 0 fuzzy}\ndo_test tkt-a7b7803e.6 {\n  db eval {\n    SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b\n      FROM t1 M, t1 N\n     WHERE x AND y\n     ORDER BY M.a, N.a\n  }\n} {1 fuzzy 1 first}\ndo_test tkt-a7b7803e.7 {\n  db eval {\n    SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b\n      FROM t1 M JOIN t1 N ON x AND y\n     ORDER BY M.a, N.a\n  }\n} {1 fuzzy 1 first}\ndo_test tkt-a7b7803e.8 {\n  db eval {\n    SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b\n      FROM t1 M JOIN t1 N ON x\n     ORDER BY M.a, N.a\n  }\n} {1 fuzzy 1 first 1 fuzzy 0 fuzzy}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-a8a0d2996a.test",
    "content": "# 2014-03-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Tests to verify that arithmetic operators do not change the type of\n# input operands.  Ticket [a8a0d2996a]\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-a8a0d2996a\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t(x,y);\n  INSERT INTO t VALUES('1','1');\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';\n} {text text}\ndo_execsql_test 1.1 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';\n} {text text}\ndo_execsql_test 1.2 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';\n} {text text}\ndo_execsql_test 1.3 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';\n} {text text}\ndo_execsql_test 1.4 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';\n} {text text}\n\ndo_execsql_test 2.0 {\n  UPDATE t SET x='1xyzzy';\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';\n} {text text}\ndo_execsql_test 2.1 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';\n} {text text}\ndo_execsql_test 2.2 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';\n} {text text}\ndo_execsql_test 2.3 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';\n} {text text}\ndo_execsql_test 2.4 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';\n} {text text}\n\n\ndo_execsql_test 3.0 {\n  UPDATE t SET x='1.0';\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1';\n} {text text}\ndo_execsql_test 3.1 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1';\n} {text text}\ndo_execsql_test 3.2 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1';\n} {text text}\ndo_execsql_test 3.3 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1';\n} {text text}\ndo_execsql_test 3.4 {\n  SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1';\n} {text text}\n\ndo_execsql_test 4.0 {\n  SELECT 1+1.;\n} {2.0}\ndo_execsql_test 4.1 {\n  SELECT '1.23e64'/'1.0000e+62';\n} {123.0}\ndo_execsql_test 4.2 {\n  SELECT '100x'+'-2y';\n} {98}\ndo_execsql_test 4.3 {\n  SELECT '100x'+'4.5y';\n} {104.5}\ndo_execsql_test 4.4 {\n  SELECT '-9223372036854775807x'-'1x';\n} {-9.22337203685478e+18}\ndo_execsql_test 4.5 {\n  SELECT '9223372036854775806x'+'1x';\n} {9.22337203685478e+18}\ndo_execsql_test 4.6 {\n  SELECT '1234x'/'10y';\n} {123.4}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-b1d3a2e531.test",
    "content": "# 2011 August 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys. Specifically, it tests\n# that ticket b1d3a2e531 has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey||!trigger} {\n  finish_test\n  return\n}\nset testprefix tkt-b1d3a2e531\n\ndo_execsql_test 1.0 { PRAGMA foreign_keys = ON }\n\ndo_execsql_test 1.1 {\n  CREATE TABLE pp(x PRIMARY KEY);\n  CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);\n  INSERT INTO pp VALUES('abc');\n  INSERT INTO cc VALUES('abc');\n}\ndo_execsql_test 1.2 {\n  BEGIN;\n    DROP TABLE pp;\n    DROP TABLE cc;\n  COMMIT;\n}\ndo_execsql_test 1.3 {\n  CREATE TABLE pp(x PRIMARY KEY);\n  CREATE TABLE cc(y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);\n  INSERT INTO pp VALUES('abc');\n  INSERT INTO cc VALUES('abc');\n}\ndo_execsql_test 1.4 {\n  BEGIN;\n    DROP TABLE cc;\n    DROP TABLE pp;\n  COMMIT;\n}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE pp(x PRIMARY KEY);\n  CREATE TABLE cc(\n    y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED\n  );\n  INSERT INTO pp VALUES(5);\n  INSERT INTO cc VALUES(5);\n}\ndo_execsql_test 2.2 {\n  BEGIN;\n    DROP TABLE pp;\n    DROP TABLE cc;\n  COMMIT;\n}\ndo_execsql_test 2.3 {\n  CREATE TABLE pp(x PRIMARY KEY);\n  CREATE TABLE cc(\n    y INTEGER PRIMARY KEY REFERENCES pp DEFERRABLE INITIALLY DEFERRED\n  );\n  INSERT INTO pp VALUES(5);\n  INSERT INTO cc VALUES(5);\n}\ndo_execsql_test 2.4 {\n  BEGIN;\n    DROP TABLE cc;\n    DROP TABLE pp;\n  COMMIT;\n}\n\ndo_execsql_test 3.1 {\n  CREATE TABLE pp1(x PRIMARY KEY);\n  CREATE TABLE cc1(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);\n\n  CREATE TABLE pp2(x PRIMARY KEY);\n  CREATE TABLE cc2(y REFERENCES pp1 DEFERRABLE INITIALLY DEFERRED);\n\n  INSERT INTO pp1 VALUES(2200);\n  INSERT INTO cc1 VALUES(NULL);\n\n  INSERT INTO pp2 VALUES(2200);\n  INSERT INTO cc2 VALUES(2200);\n}\ndo_catchsql_test 3.2 {\n  BEGIN;\n    DELETE FROM pp2;\n    DROP TABLE pp1;\n    DROP TABLE cc1;\n  COMMIT;\n} {1 {FOREIGN KEY constraint failed}}\ndo_catchsql_test 3.3 {\n    DROP TABLE cc2;\n  COMMIT;\n} {0 {}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-b351d95f9.test",
    "content": "# 2010 September 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [b351d95f9cd5ef17e9d9dbae18f5ca8611190001] has been\n# resolved.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\ndo_test tkt-b351d95.1 {\n  execsql {\n    CREATE table t1(a,b);\n    INSERT INTO t1 VALUES('name1','This is a test');\n    INSERT INTO t1 VALUES('name2','xyz');\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 SELECT a, CASE b WHEN 'xyz' THEN null ELSE b END FROM t1;\n    SELECT x, y FROM t2 ORDER BY x;\n  }\n} {name1 {This is a test} name2 {}}\n\ndo_test tkt-b351d95.2 {\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1;\n    SELECT x, y FROM t2 ORDER BY x;\n  }\n} {name1 {This is a test} name2 xyz}\ndo_test tkt-b351d95.3 {\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t2 SELECT a, coalesce(b,a) FROM t1;\n    SELECT x, y BETWEEN 'xy' AND 'xz' FROM t2 ORDER BY x;\n  }\n} {name1 0 name2 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-b72787b1.test",
    "content": "# 2011 February 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [b72787b1a7] has been\n# fixed.  From the ticket:\n#\n#     The sqlite3ExpirePreparedStatements routine marks all statements\n#     as expired. This includes statements that are not expired.\n#\n#     Steps to reproduce:\n#\n#        * Prepare a statement (A)\n#        * Alter the schema to invalidate cookie in A\n#        * Prepare a statement (B)\n#        * Run B and have A run as part of B\n#        * A will find a bad cookie and cause *all* statements\n#          to be expired including the currently running B by calling\n#          sqlite3ExpirePreparedStatements\n#        * When control returns to B it will then abort \n#\n#     The bug is that sqlite3ExpirePreparedStatements expires all statements.\n#     Note that B was prepared after the schema change and hence is perfectly\n#     valid and then is marked as expired while running.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\nunset -nocomplain ::STMT\nproc runsql {} {\n  db eval {CREATE TABLE IF NOT EXISTS t4(q)}\n  sqlite3_step $::STMT\n  set rc [sqlite3_column_int $::STMT 0]\n  sqlite3_reset $::STMT\n  return $rc\n}\n\ndo_test tkt-b72787b1.1 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    CREATE TABLE t2(y);\n    INSERT INTO t2 SELECT x+2 FROM t1;\n    INSERT INTO t2 SELECT x+4 FROM t1;\n  }\n  db func runsql ::runsql\n  set DB [sqlite3_connection_pointer db]\n  set sql {SELECT max(x) FROM t1}\n  set ::STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n\n  # The runsql() call on the second row of the first query will\n  # cause all $::STMT to hit an expired cookie.  Prior to the fix\n  # for [b72787b1a7, the bad cookie would expire all statements, including\n  # the following compound SELECT, which would cause a fault when the\n  # second SELECT was reached.  After the fix, the current statement\n  # continues to completion.\n  db eval {\n    SELECT CASE WHEN y=3 THEN y+100 WHEN y==4 THEN runsql()+200\n                ELSE 300+y END FROM t2\n    UNION ALL\n    SELECT * FROM t1;\n  }\n} {103 202 305 306 1 2}\n\nsqlite3_finalize $::STMT\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-b75a9ca6b0.test",
    "content": "# 2014-04-21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Test that ticket [b75a9ca6b0] has been fixed.\n#\n# Ticket [b75a9ca6b0] concerns queries that have both a GROUP BY\n# and an ORDER BY.  This code verifies that SQLite is able to\n# optimize out the ORDER BY in some circumstances, but retains the\n# ORDER BY when necessary.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-b75a9ca6b0\n\ndo_execsql_test 1 {\n  CREATE TABLE t1 (x, y);\n  INSERT INTO t1 VALUES (1, 3); \n  INSERT INTO t1 VALUES (2, 2);\n  INSERT INTO t1 VALUES (3, 1);\n}\n\ndo_execsql_test 1.1 {\n  CREATE INDEX i1 ON t1(x, y);\n} \n\nset idxscan {0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}}\nset tblscan {0 0 0 {SCAN TABLE t1}}\nset grpsort {0 0 0 {USE TEMP B-TREE FOR GROUP BY}}\nset sort    {0 0 0 {USE TEMP B-TREE FOR ORDER BY}}\n\nforeach {tn q res eqp} [subst -nocommands {\n  1 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x,y\"\n  {1 3  2 2  3 1} {$idxscan}\n\n  2 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x\"\n  {1 3  2 2  3 1} {$idxscan $sort}\n\n  3 \"SELECT * FROM t1 GROUP BY y, x ORDER BY y, x\"\n  {3 1  2 2  1 3} {$idxscan $sort}\n  \n  4 \"SELECT * FROM t1 GROUP BY x ORDER BY x\"\n  {1 3  2 2  3 1} {$idxscan}\n\n  5 \"SELECT * FROM t1 GROUP BY y ORDER BY y\"\n  {3 1  2 2  1 3} {$tblscan $grpsort}\n\n  6 \"SELECT * FROM t1 GROUP BY y ORDER BY x\"\n  {1 3  2 2  3 1} {$tblscan $grpsort $sort}\n\n  7 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x, y DESC\"\n  {1 3  2 2  3 1} {$idxscan $sort}\n\n  8 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x DESC, y DESC\"\n  {3 1  2 2  1 3} {$idxscan $sort}\n\n  9 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x ASC, y ASC\"\n  {1 3  2 2  3 1} {$idxscan}\n\n  10 \"SELECT * FROM t1 GROUP BY x, y ORDER BY x COLLATE nocase, y\"\n  {1 3  2 2  3 1} {$idxscan $sort}\n\n}] {\n  do_execsql_test 1.$tn.1 $q $res\n  do_eqp_test     1.$tn.2 $q $eqp\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-ba7cbfaedc.test",
    "content": "# 2014-10-11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n#\n# Test that ticket [ba7cbfaedc] has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-ba7cbfaedc\n\ndo_execsql_test 1 {\n  CREATE TABLE t1 (x, y);\n  INSERT INTO t1 VALUES (3, 'a');\n  INSERT INTO t1 VALUES (1, 'a'); \n  INSERT INTO t1 VALUES (2, 'b');\n  INSERT INTO t1 VALUES (2, 'a');\n  INSERT INTO t1 VALUES (3, 'b');\n  INSERT INTO t1 VALUES (1, 'b'); \n}\n\ndo_execsql_test 1.1 {\n  CREATE INDEX i1 ON t1(x, y);\n}\n\nforeach {n idx} {\n  1 { CREATE INDEX i1 ON t1(x, y) }\n  2 { CREATE INDEX i1 ON t1(x DESC, y) }\n  3 { CREATE INDEX i1 ON t1(x, y DESC) }\n  4 { CREATE INDEX i1 ON t1(x DESC, y DESC) }\n} {\n  catchsql { DROP INDEX i1 }\n  execsql $idx\n  foreach {tn q res} {\n    1 \"GROUP BY x, y ORDER BY x, y\"            {1 a 1 b   2 a 2 b   3 a 3 b}\n    2 \"GROUP BY x, y ORDER BY x DESC, y\"       {3 a 3 b   2 a 2 b   1 a 1 b}\n    3 \"GROUP BY x, y ORDER BY x, y DESC\"       {1 b 1 a   2 b 2 a   3 b 3 a}\n    4 \"GROUP BY x, y ORDER BY x DESC, y DESC\"  {3 b 3 a   2 b 2 a   1 b 1 a}\n  } {\n    do_execsql_test 1.$n.$tn \"SELECT * FROM t1 $q\" $res\n  }\n}\n\ndo_execsql_test 2.0 {\n  drop table if exists t1;\n  create table t1(id int);\n  insert into t1(id) values(1),(2),(3),(4),(5);\n  create index t1_idx_id on t1(id asc);\n  select * from t1 group by id order by id;\n  select * from t1 group by id order by id asc;\n  select * from t1 group by id order by id desc;\n} {\n  1 2 3 4 5   1 2 3 4 5   5 4 3 2 1\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-bd484a090c.test",
    "content": "# 2011 June 21\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for SQLite. Specifically, it tests that SQLite\n# does not crash and an error is returned if localhost() fails. This \n# is the problem reported by ticket bd484a090c.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix tkt-bd484a090c\n\n\ndo_test 1.1 {\n  lindex [catchsql { SELECT datetime('now', 'localtime') }] 0\n} {0}\ndo_test 1.2 {\n  lindex [catchsql { SELECT datetime('now', 'utc') }] 0\n} {0}\n\nsqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 1\n\ndo_test 2.1 {\n  catchsql { SELECT datetime('now', 'localtime') }\n} {1 {local time unavailable}}\ndo_test 2.2 {\n  catchsql { SELECT datetime('now', 'utc') }\n} {1 {local time unavailable}}\n\nsqlite3_test_control SQLITE_TESTCTRL_LOCALTIME_FAULT 0\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-bdc6bbbb38.test",
    "content": "# 2012 May 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [bdc6bbbb38] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-bdc6bbbb38\n\n# If SQLITE_ENABLE_FTS3 is defined, omit this file.\nifcapable !fts3 { finish_test ; return }\nset sqlite_fts3_enable_parentheses 1\n\nforeach {tn idxdir} {1 ASC 2 DESC} {\n  execsql { DROP TABLE IF EXISTS t2 }\n\n  do_execsql_test $tn.1.1 \"CREATE VIRTUAL TABLE t2 USING fts4(x, order=$idxdir)\"\n  do_execsql_test $tn.1.2 { INSERT INTO t2 VALUES('a b c') }\n\n  do_execsql_test $tn.1.3 {\n    SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC\n  } {\n    {0 0 0 1 0 2 2 1}\n  }\n  do_execsql_test $tn.1.4 {\n    SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b' \n    ORDER BY docid ASC\n  } {\n    {[a] [b] c}\n  }\n  do_execsql_test $tn.1.5 { INSERT INTO t2 VALUES('a c d') }\n  do_execsql_test $tn.1.6 {\n    SELECT offsets(t2) FROM t2 WHERE t2 MATCH 'a AND d OR b' ORDER BY docid ASC\n  } {\n    {0 0 0 1 0 2 2 1}\n    {0 0 0 1 0 1 4 1}\n  }\n  do_execsql_test $tn.1.7 {\n    SELECT snippet(t2,'[',']') FROM t2 WHERE t2 MATCH 'a AND d OR b'\n    ORDER BY docid ASC\n  } {\n    {[a] [b] c}\n    {[a] c [d]}\n  }\n\n  execsql { DROP TABLE IF EXISTS t3 }\n  do_execsql_test $tn.2.1 \"CREATE VIRTUAL TABLE t3 USING fts4(x, order=$idxdir)\"\n  do_execsql_test $tn.2.2 { INSERT INTO t3 VALUES('a c d') }\n  do_execsql_test $tn.2.3 {\n    SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC\n  } {\n    {0 0 0 1 0 1 4 1}\n  }\n  do_execsql_test $tn.2.4 {\n    SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'\n      ORDER BY docid DESC\n  } {\n    {[a] c [d]}\n  }\n  do_execsql_test $tn.2.5 { \n    INSERT INTO t3 VALUES('a b c');\n  }\n  do_execsql_test $tn.2.6 {\n    SELECT offsets(t3) FROM t3 WHERE t3 MATCH 'a AND d OR b' ORDER BY docid DESC\n  } {\n    {0 0 0 1 0 2 2 1}\n    {0 0 0 1 0 1 4 1}\n  }\n  do_execsql_test $tn.2.7 {\n    SELECT snippet(t3,'[',']') FROM t3 WHERE t3 MATCH 'a AND d OR b'\n      ORDER BY docid DESC\n  } {\n    {[a] [b] c}\n    {[a] c [d]}\n  }\n}\n\nset sqlite_fts3_enable_parentheses 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-c48d99d690.test",
    "content": "\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix tkt-c48d99d690\n\ndo_test 1.0 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a, b);\n    INSERT INTO t1 VALUES('one'  , 1);\n    INSERT INTO t1 VALUES('two'  , 5);\n    INSERT INTO t1 VALUES('two'  , 2);\n    INSERT INTO t1 VALUES('three', 3);\n    PRAGMA count_changes = 1;\n  }\n} {}\n\ndo_test 1.1 {\n  execsql { INSERT INTO t2 SELECT * FROM t1 }\n} {4}\n\ndo_test 1.2 { execsql VACUUM } {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-cbd054fa6b.test",
    "content": "# 2010 March 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements tests to verify that ticket [cbd054fa6b] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stat4&&!stat3 {\n  finish_test\n  return\n}\n\nproc s {blob} {\n  set ret \"\"\n  binary scan $blob c* bytes\n  foreach b $bytes {\n    set t [binary format c $b]\n    if {[string is print $t]} {\n      append ret $t\n    } else {\n      append ret .\n    }\n  }\n  return $ret\n}\ndb function s s\n\ndo_test tkt-cbd05-1.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT UNIQUE NOT NULL);\n    CREATE INDEX t1_x ON t1(b);\n    INSERT INTO t1 VALUES (NULL, '');\n    INSERT INTO t1 VALUES (NULL, 'A');\n    INSERT INTO t1 VALUES (NULL, 'B');\n    INSERT INTO t1 VALUES (NULL, 'C');\n    INSERT INTO t1 VALUES (NULL, 'D');\n    INSERT INTO t1 VALUES (NULL, 'E');\n    INSERT INTO t1 VALUES (NULL, 'F');\n    INSERT INTO t1 VALUES (NULL, 'G');\n    INSERT INTO t1 VALUES (NULL, 'H');\n    INSERT INTO t1 VALUES (NULL, 'I');\n    SELECT count(*) FROM t1;\n  }\n} {10}\ndo_test tkt-cbd05-1.2 {\n  db eval { ANALYZE; }\n  ifcapable stat4 {\n    db eval {\n      PRAGMA writable_schema = 1;\n      CREATE VIEW vvv AS \n      SELECT tbl,idx,neq,nlt,ndlt,test_extract(sample,0) AS sample\n      FROM sqlite_stat4;\n      PRAGMA writable_schema = 0;\n    }\n  } else {\n    db eval {\n      CREATE VIEW vvv AS \n      SELECT tbl,idx,neq,nlt,ndlt,sample FROM sqlite_stat3;\n    }\n  }\n} {}\ndo_test tkt-cbd05-1.3 {\n  execsql { \n    SELECT tbl,idx,group_concat(s(sample),' ') \n    FROM vvv \n    WHERE idx = 't1_x' \n    GROUP BY tbl,idx\n  }\n} {t1 t1_x { A B C D E F G H I}}\n\ndo_test tkt-cbd05-2.1 {\n  db eval {\n    DROP TABLE t1;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE NOT NULL);\n    CREATE INDEX t1_x ON t1(b);\n    INSERT INTO t1 VALUES(NULL, X'');\n    INSERT INTO t1 VALUES(NULL, X'41');\n    INSERT INTO t1 VALUES(NULL, X'42');\n    INSERT INTO t1 VALUES(NULL, X'43');\n    INSERT INTO t1 VALUES(NULL, X'44');\n    INSERT INTO t1 VALUES(NULL, X'45');\n    INSERT INTO t1 VALUES(NULL, X'46');\n    INSERT INTO t1 VALUES(NULL, X'47');\n    INSERT INTO t1 VALUES(NULL, X'48');\n    INSERT INTO t1 VALUES(NULL, X'49');\n    SELECT count(*) FROM t1;\n  }\n} {10}\ndo_test tkt-cbd05-2.2 {\n  db eval {\n    ANALYZE;\n  }\n} {}\ndo_test tkt-cbd05-2.3 {\n  execsql { \n    SELECT tbl,idx,group_concat(s(sample),' ') \n    FROM vvv \n    WHERE idx = 't1_x' \n    GROUP BY tbl,idx\n  }\n} {t1 t1_x { A B C D E F G H I}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-d11f09d36e.test",
    "content": "# 2010 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test that the bug reported by ticket d11f09d36e7cb0821e01f4 has\n# been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\ndo_test tkt-d11f09d36e.1 {\n  execsql {\n    PRAGMA synchronous = NORMAL;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(x, y, UNIQUE(x, y));\n    BEGIN;\n  }\n  for {set i 0} {$i < 10000} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i) }\n  }\n  execsql COMMIT\n} {}\ndo_test tkt-d11f09d36e.2 {\n  execsql {\n    BEGIN;\n      UPDATE t1 set x = x+10000;\n    ROLLBACK;\n  }\n} {}\ndo_test tkt-d11f09d36e.3 {\n  execsql { PRAGMA integrity_check }\n} {ok}\ndo_test tkt-d11f09d36e.4 {\n  execsql {\n    SAVEPOINT tr;\n      UPDATE t1 set x = x+10000;\n    ROLLBACK TO tr;\n    RELEASE tr;\n  }\n} {}\ndo_test tkt-d11f09d36e.5 {\n  execsql { PRAGMA integrity_check }\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-d635236375.test",
    "content": "# 2011 August 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that bug [d63523637517386191d634e]\n# has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset ::testprefix tkt-d635236375\n\ndo_test 1.0 {\n  execsql {\n    CREATE TABLE t1(id1 INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(9999);\n    CREATE TABLE t2(id2 INTEGER PRIMARY KEY);\n    INSERT INTO t2 VALUES(12345);\n    INSERT INTO t2 VALUES(54321);\n    SELECT DISTINCT id1 AS x, id1 AS y FROM t1, t2;\n  }\n} {9999 9999}\ndo_test 1.1 {\n  execsql {\n    SELECT count(*) FROM t1, t2 GROUP BY id1, id1;\n  }\n} {2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-d82e3f3721.test",
    "content": "# 2009 September 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [d82e3f3721] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt-d82e3-1.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    INSERT INTO t1 VALUES(null,'abc');\n    INSERT INTO t1 VALUES(null,'def');\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES(null,'ghi');\n    SELECT * FROM t1;\n  }\n} {3 ghi}\ndo_test tkt-d82e3-1.2 {\n  db eval {\n    CREATE TEMP TABLE t2(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n    INSERT INTO t2 VALUES(null,'jkl');\n    INSERT INTO t2 VALUES(null,'mno');\n    DELETE FROM t2;\n    INSERT INTO t2 VALUES(null,'pqr');\n    SELECT * FROM t2;\n  }\n} {3 pqr}\ndo_test tkt-d82e3-1.3 {\n  db eval {\n    SELECT 'main', * FROM main.sqlite_sequence\n    UNION ALL\n    SELECT 'temp', * FROM temp.sqlite_sequence\n    ORDER BY 2\n  }\n} {main t1 3 temp t2 3}\ndo_test tkt-d82e3-1.4 {\n  db eval {\n    VACUUM;\n    SELECT 'main', * FROM main.sqlite_sequence\n    UNION ALL\n    SELECT 'temp', * FROM temp.sqlite_sequence\n    ORDER BY 2\n  }\n} {main t1 3 temp t2 3}\n\nsqlite3 db2 test.db\ndo_test tkt-d82e3-2.1 {\n  db eval {\n    CREATE TEMP TABLE t3(x);\n    INSERT INTO t3 VALUES(1);\n  }\n  db2 eval {\n    CREATE TABLE t3(y,z);\n    INSERT INTO t3 VALUES(8,9);\n  }\n  db eval {\n    SELECT * FROM temp.t3 JOIN main.t3;\n  }\n} {1 8 9}\ndo_test tkt-d82e3-2.2 {\n  db eval {\n    VACUUM;\n    SELECT * FROM temp.t3 JOIN main.t3;\n  }\n} {1 8 9}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-f3e5abed55.test",
    "content": "# 2010 July 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\nforeach f [glob -nocomplain test.db*mj*] { forcedelete $f }\nforcedelete test.db2\n\ndo_test tkt-f3e5abed55-1.1 {\n  execsql {\n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE main.t1(a, b);\n    CREATE TABLE aux.t2(c, d);\n  }\n} {}\n\ndo_test tkt-f3e5abed55-1.2 {\n  glob -nocomplain test.db*mj*\n} {}\n\ndo_test tkt-f3e5abed55-1.3 {\n  sqlite3 db2 test.db\n  execsql { BEGIN; SELECT * FROM t1 } db2\n} {}\n\ndo_test tkt-f3e5abed55-1.4 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t2 VALUES(1, 2);\n  }\n  catchsql COMMIT\n} {1 {database is locked}}\n\ndo_test tkt-f3e5abed55-1.5 {\n  execsql COMMIT db2\n  execsql COMMIT\n} {}\n\ndo_test tkt-f3e5abed55-1.6 {\n  glob -nocomplain test.db*mj*\n} {}\nforeach f [glob -nocomplain test.db*mj*] { forcedelete $f }\ndb close\ndb2 close\n\n\n\n# Set up a testvfs so that the next time SQLite tries to delete the\n# file \"test.db-journal\", a snapshot of the current file-system contents\n# is taken.\n#\n# This test will not work with an in-memory journal.\n#\nif {[permutation]!=\"inmemory_journal\"} {\n  testvfs tvfs -default 1\n  tvfs script xDelete\n  tvfs filter xDelete\n  proc xDelete {method file args} {\n    if {[file tail $file] == \"test.db-journal\"} {\n      faultsim_save\n      tvfs filter {}\n    }\n    return \"SQLITE_OK\"\n  }\n  \n  sqlite3 db  test.db\n  sqlite3 db2 test.db\n  do_test tkt-f3e5abed55-2.1 {\n    execsql {\n      ATTACH 'test.db2' AS aux;\n      BEGIN;\n        INSERT INTO t1 VALUES(3, 4);\n        INSERT INTO t2 VALUES(3, 4);\n    }\n  } {}\n  do_test tkt-f3e5abed55-2.2 {\n    execsql { BEGIN; SELECT * FROM t1 } db2\n  } {1 2}\n  do_test tkt-f3e5abed55-2.3 {\n    catchsql COMMIT\n  } {1 {database is locked}}\n  \n  do_test tkt-f3e5abed55-2.4 {\n    execsql COMMIT db2\n    execsql {\n      COMMIT;\n      SELECT * FROM t1;\n      SELECT * FROM t2;\n    }\n  } {1 2 3 4 1 2 3 4}\n  do_test tkt-f3e5abed55-2.5 {\n    db close\n    db2 close\n    faultsim_restore_and_reopen\n    execsql {\n      ATTACH 'test.db2' AS aux;\n      SELECT * FROM t1;\n      SELECT * FROM t2;\n    }\n  } {1 2 3 4 1 2 3 4}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-f67b41381a.test",
    "content": "# 2014 April 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Test that ticket f67b41381a has been resolved.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tkt-f67b41381a\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(1);\n  ALTER TABLE t1 ADD COLUMN b DEFAULT 2;\n  CREATE TABLE t2(a, b);\n  INSERT INTO t2 SELECT * FROM t1;\n  SELECT * FROM t2;\n} {1 2}\n\ndb cache size 0\nforeach {tn tbls xfer} {\n  1 { CREATE TABLE t1(a, b); CREATE TABLE t2(a, b)             }             1\n  2 { CREATE TABLE t1(a, b DEFAULT 'x'); CREATE TABLE t2(a, b) }             0\n  3 { CREATE TABLE t1(a, b DEFAULT 'x'); CREATE TABLE t2(a, b DEFAULT 'x') } 1\n  4 { CREATE TABLE t1(a, b DEFAULT NULL); CREATE TABLE t2(a, b) }            0\n  5 { CREATE TABLE t1(a DEFAULT 2, b); CREATE TABLE t2(a DEFAULT 1, b) }     1\n  6 { CREATE TABLE t1(a DEFAULT 1, b); CREATE TABLE t2(a DEFAULT 1, b) }     1\n  7 { CREATE TABLE t1(a DEFAULT 1, b DEFAULT 1);\n      CREATE TABLE t2(a DEFAULT 3, b DEFAULT 1) }                            1\n  8 { CREATE TABLE t1(a DEFAULT 1, b DEFAULT 1);\n      CREATE TABLE t2(a DEFAULT 3, b DEFAULT 3) }                            0\n\n} {\n\n  execsql { DROP TABLE t1; DROP TABLE t2 }\n  execsql $tbls\n\n  set res 1\n  db eval { EXPLAIN INSERT INTO t1 SELECT * FROM t2 } {\n    if {$opcode == \"Column\"} { set res 0 }\n  }\n\n  do_test 2.$tn [list set res] $xfer\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-f777251dc7a.test",
    "content": "# 2009 October 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket [f777251dc7a] has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt-f7772-1.1 {\n  execsql {\n     CREATE TEMP TABLE t1(x UNIQUE);\n     INSERT INTO t1 VALUES(1);\n     CREATE TABLE t2(x, y);\n     INSERT INTO t2 VALUES(1, 2);\n     CREATE TEMP TABLE t3(w, z);\n  }\n} {}\n\nproc force_rollback {} {\n  catch {db eval {INSERT OR ROLLBACK INTO t1 VALUES(1)}}\n}\ndb function force_rollback force_rollback\n\ndo_test tkt-f7772-1.2 {\n  catchsql {\n    BEGIN IMMEDIATE;\n    CREATE TABLE xyzzy(abc);\n    SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2;\n  }\n} {1 {abort due to ROLLBACK}}\ndo_test tkt-f7772-1.3 {\n  sqlite3_get_autocommit db\n} {1}\n\ndo_test tkt-f7772-2.1 {\n  execsql {\n     DROP TABLE IF EXISTS t1;\n     DROP TABLE IF EXISTS t2;\n     DROP TABLE IF EXISTS t3;\n\n     CREATE TEMP TABLE t1(x UNIQUE);\n     INSERT INTO t1 VALUES(1);\n     CREATE TABLE t2(x, y);\n     INSERT INTO t2 VALUES(1, 2);\n  }\n} {}\ndo_test tkt-f7772-2.2 {\n  execsql {\n    BEGIN IMMEDIATE;\n    CREATE TEMP TABLE t3(w, z);\n  }\n  catchsql {\n    SELECT x, force_rollback(), EXISTS(SELECT 1 FROM t3 WHERE w=x) FROM t2\n  }\n} {1 {abort due to ROLLBACK}}\ndo_test tkt-f7772-2.3 {\n  sqlite3_get_autocommit db\n} {1}\n\ndo_test tkt-f7772-3.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    DROP TABLE IF EXISTS t3;\n\n    CREATE TEMP TABLE t1(x);\n    CREATE TABLE t2(x);\n    CREATE TABLE t3(x);\n  \n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n  }\n} {}\n\nproc ins {} { db eval {INSERT INTO t3 VALUES('hello')} }\ndb function ins ins\n\ndo_test tkt-f7772-3.2 {\n  execsql {\n    SELECT ins() AS x FROM t2 UNION ALL SELECT ins() AS x FROM t1\n  }\n} {{} {} {} {}}\ndo_test tkt-f7772-3.3 {\n  execsql { SELECT * FROM t3 }\n} {hello hello hello hello}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-f7b4edec.test",
    "content": "# 2011 March 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket \n# [f7b4edece25c994857dc139207f55a53c8319fae] has been fixed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Open two database connections to the same database file in\n# shared cache mode.  Create update hooks that will fire on\n# each connection.\n#\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\nsqlite3 db1 test.db\nsqlite3 db2 test.db\nunset -nocomplain HOOKS\nset HOOKS {}\nproc update_hook {args} { lappend ::HOOKS $args }\ndb1 update_hook update_hook\ndb2 update_hook update_hook\n\n# Create a prepared statement\n#\ndo_test tkt-f7b4edec-1 {\n  execsql { CREATE TABLE t1(x, y); } db1\n  execsql { INSERT INTO t1 VALUES(1, 2) } db1\n  set ::HOOKS\n} {{INSERT main t1 1}}\n\n# In the second database connection cause the schema to be reparsed\n# without changing the schema cookie.\n#\nset HOOKS {}\ndo_test tkt-f7b4edec-2 {\n  execsql {\n    BEGIN;\n      DROP TABLE t1;\n      CREATE TABLE t1(x, y);\n    ROLLBACK;\n  } db2\n  set ::HOOKS\n} {}\n\n# Rerun the prepared statement that was created prior to the \n# schema reparse.  Verify that the update-hook gives the correct\n# output.\n#\nset HOOKS {}\ndo_test tkt-f7b4edec-3 {\n  execsql { INSERT INTO t1 VALUES(1, 2) } db1\n  set ::HOOKS\n} {{INSERT main t1 2}}\n\n# Be sure to restore the original shared-cache mode setting before\n# returning.\n#\ndb1 close\ndb2 close\nsqlite3_enable_shared_cache $::enable_shared_cache\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-f973c7ac31.test",
    "content": "# 2010 June 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-f973c7ac3-1.0 {\n  execsql {\n    CREATE TABLE t(c1 INTEGER, c2 INTEGER);\n    INSERT INTO t VALUES(5, 5);\n    INSERT INTO t VALUES(5, 4);\n  }\n} {}\n\nforeach {tn sql} {\n  1 \"\"\n  2 \"CREATE INDEX i1 ON t(c1, c2)\"\n} {\n\n  execsql $sql\n\n  do_test tkt-f973c7ac3-1.$tn.1 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 DESC \n    }\n  } {}\n  do_test tkt-f973c7ac3-1.$tn.2 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 DESC \n    }\n  } {5 5 5 4}\n  do_test tkt-f973c7ac3-1.$tn.3 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 DESC \n    }\n  } {5 5 5 4}\n  do_test tkt-f973c7ac3-1.$tn.4 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 DESC \n    }\n  } {5 5 5 4}\n  do_test tkt-f973c7ac3-1.$tn.5 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 DESC \n    }\n  } {5 5 5 4}\n\n  do_test tkt-f973c7ac3-1.$tn.6 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='2' ORDER BY c2 ASC \n    }\n  } {}\n  do_test tkt-f973c7ac3-1.$tn.7 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<=5 ORDER BY c2 ASC \n    }\n  } {5 4 5 5}\n  do_test tkt-f973c7ac3-1.$tn.8 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>0 AND c2<='5' ORDER BY c2 ASC \n    }\n  } {5 4 5 5}\n  do_test tkt-f973c7ac3-1.$tn.9 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<=5 ORDER BY c2 ASC \n    }\n  } {5 4 5 5}\n  do_test tkt-f973c7ac3-1.$tn.10 {\n    execsql { \n      SELECT * FROM t WHERE c1 = 5 AND c2>'0' AND c2<='5' ORDER BY c2 ASC \n    }\n  } {5 4 5 5}\n} \n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-fa7bf5ec.test",
    "content": "# 2011 October 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [fa7bf5ec94801e7e2030e41eefe5d9dd96eaacfd] has\n# been resolved.\n#\n# The problem described by this ticket was that the sqlite3ExprCompare()\n# function was saying that expressions (x='a') and (x='A') were identical\n# because it was using sqlite3StrICmp() instead of strcmp() to compare string\n# literals.  That was causing the query optimizer for aggregate queries to \n# believe that both count() operations were identical, and thus only \n# computing the first count() and making a copy of the result for the \n# second count().\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-fa7bf5ec-1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES ('a');\n    INSERT INTO t1 VALUES ('A');\n    INSERT INTO t1 VALUES ('A');\n    SELECT count(CASE WHEN x='a' THEN 1 END),\n           count(CASE WHEN x='A' THEN 1 END)\n      FROM t1;\n  }\n} {1 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-fc62af4523.test",
    "content": "# 2010 June 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [fc62af4523] has been resolved.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\ndo_test tkt-fc62af4523.1 {\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA journal_mode = persist;\n    CREATE TABLE t1(a UNIQUE, b UNIQUE);\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300);\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; --  2\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; --  4\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; --  8\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 16\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 32\n    INSERT INTO t1 SELECT randomblob(200), randomblob(300) FROM t1; -- 64\n  }\n  execsql {\n    PRAGMA integrity_check;\n    SELECT count(*) FROM t1;\n  }\n} {ok 64}\n\n# Launch an external process. Have it write (but not commit) a large\n# transaction to the database.\n#\nset ::chan [launch_testfixture]\nproc buddy {code} { testfixture $::chan $code }\ndo_test tkt-fc62af4523.2 {\n  testfixture $::chan {\n    sqlite3 db test.db\n    db eval {\n      PRAGMA cache_size = 10;\n      BEGIN;\n        UPDATE t1 SET b = randomblob(400);\n        UPDATE t1 SET a = randomblob(201);\n    }\n  }\n  file exists test.db-journal\n} {1}\n\n# Now do \"PRAGMA journal_mode = DELETE\" in this process. At one point\n# this was causing SQLite to delete the journal file from the file-system,\n# even though the external process is currently using it.\n#\ndo_test tkt-fc62af4523.3 { execsql { PRAGMA journal_mode = DELETE } } {delete}\ndo_test tkt-fc62af4523.4 { file exists test.db-journal } {1}\n\n# Cause the external process to crash. Since it has already written \n# uncommitted data into the database file, the next reader will have\n# to do a hot-journal rollback to recover the database.\n#\n# Or, if this test is run in a version with the bug present, the journal\n# file has already been deleted. In this case we are left with a corrupt\n# database file and no hot-journal to fix it with.\n#\ndo_test tkt-fc62af4523.5 {\n  testfixture $::chan sqlite_abort\n} {ERROR: Child process hung up}\nafter 200\ndo_test tkt-fc62af4523.6 {\n  execsql {\n    PRAGMA integrity_check;\n    SELECT count(*) FROM t1;\n  }\n} {ok 64}\n\ncatch { close $::chan }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt-fc7bd6358f.test",
    "content": "# 2013 March 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that ticket [fc7bd6358f]:\n#\n# The following SQL yields an incorrect result (zero rows) in all\n# versions of SQLite between 3.6.14 and 3.7.15.2:\n#\n#    CREATE TABLE t(textid TEXT);\n#    INSERT INTO t VALUES('12');\n#    INSERT INTO t VALUES('34');\n#    CREATE TABLE i(intid INTEGER PRIMARY KEY);\n#    INSERT INTO i VALUES(12);\n#    INSERT INTO i VALUES(34);\n#\n#    SELECT t1.textid AS a, i.intid AS b, t2.textid AS c\n#      FROM t t1, i, t t2\n#     WHERE t1.textid = i.intid\n#       AND t1.textid = t2.textid;\n#\n# The correct result should be two rows, one with 12|12|12 and the other\n# with 34|34|34. With this bug, no rows are returned. Bisecting shows that\n# this bug was introduced with check-in [dd4d67a67454] on 2009-04-23. \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt-fc7bd6358f.100 {\n  db eval {\n    CREATE TABLE t(textid TEXT);\n    INSERT INTO t VALUES('12');\n    INSERT INTO t VALUES('34');\n    CREATE TABLE i(intid INTEGER PRIMARY KEY);\n    INSERT INTO i VALUES(12);\n    INSERT INTO i VALUES(34);\n  }\n} {}\nunset -nocomplain from\nunset -nocomplain where\nunset -nocomplain a\nunset -nocomplain b\nforeach {a from} {\n  1 {FROM t t1, i, t t2}\n  2 {FROM i, t t1, t t2}\n  3 {FROM t t1, t t2, i}\n} {\n  foreach {b where} {\n    1 {WHERE t1.textid=i.intid AND t1.textid=t2.textid}\n    2 {WHERE i.intid=t1.textid AND t1.textid=t2.textid}\n    3 {WHERE t1.textid=i.intid AND i.intid=t2.textid}\n    4 {WHERE t1.textid=i.intid AND t2.textid=i.intid}\n    5 {WHERE i.intid=t1.textid AND i.intid=t2.textid}\n    6 {WHERE i.intid=t1.textid AND t2.textid=i.intid}\n    7 {WHERE t1.textid=t2.textid AND i.intid=t2.textid}\n    8 {WHERE t1.textid=t2.textid AND t2.textid=i.intid}\n  } {\n    do_test tkt-fc7bd6358f.110.$a.$b.1 {\n       db eval {PRAGMA automatic_index=ON}\n       db eval \"SELECT t1.textid, i.intid, t2.textid $from $where\"\n    } {12 12 12 34 34 34}\n    do_test tkt-fc7bd6358f.110.$a.$b.2 {\n       db eval {PRAGMA automatic_index=OFF}\n       db eval \"SELECT t1.textid, i.intid, t2.textid $from $where\"\n    } {12 12 12 34 34 34}\n  }\n}\n\n    \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1435.test",
    "content": "# 2005 September 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1435 has been\n# fixed.  \n#\n#\n# $Id: tkt1435.test,v 1.2 2006/01/17 09:35:02 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !memorydb {\n  finish_test\n  return\n}\n\n# Construct the sample database.\n#\ndo_test tkt1435-1.0 {\n  sqlite3 db :memory:\n  execsql {\n    CREATE TABLE Instances(\n    \tinstanceId INTEGER PRIMARY KEY,\n    \ttroveName STR,\n    \tversionId INT,\n    \tflavorId INT,\n    \ttimeStamps STR,\n    \tisPresent INT,\n    \tpinned BOOLEAN\n    );\n    INSERT INTO \"Instances\"\n       VALUES(1, 'libhello:runtime', 1, 1, 1126929880.094, 1, 1);\n    INSERT INTO \"Instances\"\n       VALUES(2, 'libhello:user', 1, 1, 1126929880.094, 1, 0);\n    INSERT INTO \"Instances\"\n       VALUES(3, 'libhello:script', 1, 1, 1126929880.094, 1, 0);\n    INSERT INTO \"Instances\"\n       VALUES(4, 'libhello', 1, 1, 1126929880.094, 1, 0);\n    \n    CREATE TABLE Versions(versionId INTEGER PRIMARY KEY,version STR UNIQUE);\n    INSERT INTO \"Versions\" VALUES(0, NULL);\n    INSERT INTO \"Versions\" VALUES(1, '/localhost@rpl:linux/0-1-1');\n    \n    CREATE TABLE Flavors(flavorId integer primary key, flavor str unique);\n    INSERT INTO \"Flavors\" VALUES(0, NULL);\n    INSERT INTO \"Flavors\" VALUES(1, '1#x86');\n    \n    CREATE TEMPORARY TABLE tlList (\n       row INTEGER PRIMARY KEY,\n       name STRING,\n       version STRING,\n       flavor STRING\n    );\n    \n    INSERT INTO tlList \n      values(NULL, 'libhello:script', '/localhost@rpl:linux/0-1-1', '1#x86');\n    INSERT INTO tlList \n      values(NULL, 'libhello:user', '/localhost@rpl:linux/0-1-1', '1#x86');\n    INSERT INTO tlList \n      values(NULL, 'libhello:runtime', '/localhost@rpl:linux/0-1-1', '1#x86');\n  }\n} {}\n\n# Run the query with an index\n#\ndo_test tkt1435-1.1 {\n  execsql {\n    select row, pinned from tlList, Instances, Versions, Flavors\n        where\n            Instances.troveName = tlList.name\n        and Versions.version = tlList.version\n        and Instances.versionId = Versions.versionId\n        and (    Flavors.flavor = tlList.flavor or Flavors.flavor is NULL\n             and tlList.flavor = '')\n        and Instances.flavorId = Flavors.flavorId\n    order by row asc;\n  }\n} {1 0 2 0 3 1}\n\n# Create a indices, analyze and rerun the query. \n# Verify that the results are the same\n#\ndo_test tkt1435-1.2 {\n  execsql {\n    CREATE INDEX InstancesNameIdx ON Instances(troveName);\n    CREATE UNIQUE INDEX InstancesIdx \n      ON Instances(troveName, versionId, flavorId);\n    ANALYZE;\n    select row, pinned from tlList, Instances, Versions, Flavors\n        where\n            Instances.troveName = tlList.name\n        and Versions.version = tlList.version\n        and Instances.versionId = Versions.versionId\n        and (    Flavors.flavor = tlList.flavor or Flavors.flavor is NULL\n             and tlList.flavor = '')\n        and Instances.flavorId = Flavors.flavorId\n    order by row asc;\n  }\n} {1 0 2 0 3 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1443.test",
    "content": "# 2005 September 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1433 has been\n# fixed.  \n#\n# The problem in ticket #1433 was that the dependencies on the right-hand\n# side of an IN operator were not being checked correctly.  So in an\n# expression of the form:\n#\n#         t1.x IN (1,t2.b,3)\n#\n# the optimizer was missing the fact that the right-hand side of the IN\n# depended on table t2.  It was checking dependencies based on the\n# Expr.pRight field rather than Expr.pList and Expr.pSelect.  \n#\n# Such a bug could be verifed using a less elaborate test case.  But\n# this test case (from the original bug poster) exercises so many different\n# parts of the system all at once, that it seemed like a good one to\n# include in the test suite. \n#\n# NOTE:  Yes, in spite of the name of this file (tkt1443.test) this\n# test is for ticket #1433 not #1443.  I mistyped the name when I was\n# creating the file and I had already checked in the file by the wrong\n# name be the time I noticed the error.  With CVS it is a really hassle\n# to change filenames, so I'll just leave it as is.  No harm done.\n#\n# $Id: tkt1443.test,v 1.4 2006/01/17 09:35:02 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery||!memorydb {\n  finish_test\n  return\n}\n\n# Construct the sample database.\n#\ndo_test tkt1443-1.0 {\n  sqlite3 db :memory:\n  execsql {\n    CREATE TABLE Items(\n    \titemId integer primary key,\n    \t item str unique\n    );\n    INSERT INTO \"Items\" VALUES(0, 'ALL');\n    INSERT INTO \"Items\" VALUES(1, 'double:source');\n    INSERT INTO \"Items\" VALUES(2, 'double');\n    INSERT INTO \"Items\" VALUES(3, 'double:runtime');\n    INSERT INTO \"Items\" VALUES(4, '.*:runtime');\n    \n    CREATE TABLE Labels(\n    \tlabelId INTEGER PRIMARY KEY,\n    \tlabel STR UNIQUE\n    );\n    INSERT INTO \"Labels\" VALUES(0, 'ALL');\n    INSERT INTO \"Labels\" VALUES(1, 'localhost@rpl:linux');\n    INSERT INTO \"Labels\" VALUES(2, 'localhost@rpl:branch');\n    \n    CREATE TABLE LabelMap(\n    \titemId INTEGER,\n    \tlabelId INTEGER,\n    \tbranchId integer\n    );\n    INSERT INTO \"LabelMap\" VALUES(1, 1, 1);\n    INSERT INTO \"LabelMap\" VALUES(2, 1, 1);\n    INSERT INTO \"LabelMap\" VALUES(3, 1, 1);\n    INSERT INTO \"LabelMap\" VALUES(1, 2, 2);\n    INSERT INTO \"LabelMap\" VALUES(2, 2, 3);\n    INSERT INTO \"LabelMap\" VALUES(3, 2, 3);\n    \n    CREATE TABLE Users (\n    \tuserId INTEGER PRIMARY KEY,\n    \tuser STRING UNIQUE,\n    \tsalt BINARY,\n    \tpassword STRING\n    );\n    INSERT INTO \"Users\" VALUES(1, 'test', 'æ$d',\n               '43ba0f45014306bd6df529551ffdb3df');\n    INSERT INTO \"Users\" VALUES(2, 'limited', 'ª>S',\n               'cf07c8348fdf675cc1f7696b7d45191b');\n    CREATE TABLE UserGroups (\n    \tuserGroupId INTEGER PRIMARY KEY,\n    \tuserGroup STRING UNIQUE\n    );\n    INSERT INTO \"UserGroups\" VALUES(1, 'test');\n    INSERT INTO \"UserGroups\" VALUES(2, 'limited');\n    \n    CREATE TABLE UserGroupMembers (\n    \tuserGroupId INTEGER,\n    \tuserId INTEGER\n    );\n    INSERT INTO \"UserGroupMembers\" VALUES(1, 1);\n    INSERT INTO \"UserGroupMembers\" VALUES(2, 2);\n    \n    CREATE TABLE Permissions (\n    \tuserGroupId INTEGER,\n    \tlabelId INTEGER NOT NULL,\n    \titemId INTEGER NOT NULL,\n    \twrite INTEGER,\n    \tcapped INTEGER,\n    \tadmin INTEGER\n    );\n    INSERT INTO \"Permissions\" VALUES(1, 0, 0, 1, 0, 1);\n    INSERT INTO \"Permissions\" VALUES(2, 2, 4, 0, 0, 0);\n  }\n} {}\n\n# Run the query with an index\n#\ndo_test tkt1443-1.1 {\n  execsql {\n    select distinct\n        Items.Item as trove, UP.pattern as pattern\n    from\n       ( select\n           Permissions.labelId as labelId,\n           PerItems.item as pattern\n         from\n           Users, UserGroupMembers, Permissions\n           left outer join Items as PerItems\n                 on Permissions.itemId = PerItems.itemId\n         where\n               Users.user = 'limited'\n           and Users.userId = UserGroupMembers.userId\n           and UserGroupMembers.userGroupId = Permissions.userGroupId\n       ) as UP join LabelMap on ( UP.labelId = 0 or\n                                  UP.labelId = LabelMap.labelId ),\n       Labels, Items\n    where\n        Labels.label = 'localhost@rpl:branch'\n    and Labels.labelId = LabelMap.labelId\n    and LabelMap.itemId = Items.itemId\n    ORDER BY +trove, +pattern\n  }\n} {double .*:runtime double:runtime .*:runtime double:source .*:runtime}\n\n# Create an index and rerun the query. \n# Verify that the results are the same\n#\ndo_test tkt1443-1.2 {\n  execsql {\n    CREATE UNIQUE INDEX PermissionsIdx\n         ON Permissions(userGroupId, labelId, itemId);\n    select distinct\n        Items.Item as trove, UP.pattern as pattern\n    from\n       ( select\n           Permissions.labelId as labelId,\n           PerItems.item as pattern\n         from\n           Users, UserGroupMembers, Permissions\n           left outer join Items as PerItems\n                 on Permissions.itemId = PerItems.itemId\n         where\n               Users.user = 'limited'\n           and Users.userId = UserGroupMembers.userId\n           and UserGroupMembers.userGroupId = Permissions.userGroupId\n       ) as UP join LabelMap on ( UP.labelId = 0 or\n                                  UP.labelId = LabelMap.labelId ),\n       Labels, Items\n    where\n        Labels.label = 'localhost@rpl:branch'\n    and Labels.labelId = LabelMap.labelId\n    and LabelMap.itemId = Items.itemId\n    ORDER BY +trove, +pattern\n  }\n} {double .*:runtime double:runtime .*:runtime double:source .*:runtime}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1444.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1444 has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound||!view {\n  finish_test\n  return \n}\n\n# The use of a VIEW that contained an ORDER BY clause within a UNION ALL\n# was causing problems.  See ticket #1444.\n#\ndo_test tkt1444-1.1 {\n  execsql {\n    CREATE TABLE DemoTable (x INTEGER, TextKey TEXT, DKey Real);\n    CREATE INDEX DemoTableIdx ON DemoTable (TextKey);\n    INSERT INTO DemoTable VALUES(9,8,7);\n    INSERT INTO DemoTable VALUES(1,2,3);\n    CREATE VIEW DemoView AS SELECT * FROM DemoTable ORDER BY TextKey;\n    SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1;\n  }\n} {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0}\ndo_test tkt1444-1.2 {\n  execsql {\n    SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView;\n  }\n} {9 8 7.0 1 2 3.0 1 2 3.0 9 8 7.0}\ndo_test tkt1444-1.3 {\n  execsql {\n    DROP VIEW DemoView;\n    CREATE VIEW DemoView AS SELECT * FROM DemoTable;\n    SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView ORDER BY 1;\n  }\n} {1 2 3.0 1 2 3.0 9 8 7.0 9 8 7.0}\ndo_test tkt1444-1.4 {\n  execsql {\n    SELECT * FROM DemoTable UNION ALL SELECT * FROM DemoView;\n  }\n} {9 8 7.0 1 2 3.0 9 8 7.0 1 2 3.0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1449.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1449 has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Somewhere in tkt1449-1.1 is a VIEW definition that uses a subquery and\n# a compound SELECT. So we cannot run this file if any of these features\n# are not available.\nifcapable !subquery||!compound||!view {\n  finish_test\n  return\n}\n\n# The following schema generated problems in ticket #1449.  We've retained\n# the original schema here because it is some unbelievably complex, it seemed\n# like a good test case for SQLite.\n#\ndo_test tkt1449-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE ACLS(ISSUEID text(50) not null, OBJECTID text(50) not null, PARTICIPANTID text(50) not null, PERMISSIONBITS int not null, constraint PK_ACLS primary key (ISSUEID, OBJECTID, PARTICIPANTID));\n    CREATE TABLE ACTIONITEMSTATUSES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, FRIENDLYNAME text(100) not null, REVISION int not null, SHORTNAME text(30) not null, LONGNAME text(200) not null, ATTACHMENTHANDLING int not null, RESULT int not null, NOTIFYCREATOR text(1) null, NOTIFYASSIGNEE text(1) null, NOTIFYFYI text(1) null, NOTIFYCLOSURETEAM text(1) null, NOTIFYCOORDINATORS text(1) null, COMMENTREQUIRED text(1) not null, constraint PK_ACTIONITEMSTATUSES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE ACTIONITEMTYPES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, REVISION int not null, LABEL text(200) not null, INSTRUCTIONS text not null, EMAILINSTRUCTIONS text null, ALLOWEDSTATUSES text not null, INITIALSTATUS text(100) not null, COMMENTREQUIRED text(1) not null, ATTACHMENTHANDLING int not null, constraint PK_ACTIONITEMTYPES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE ATTACHMENTS(TQUNID text(36) not null, OBJECTID text(50) null, ISSUEID text(50) null, DATASTREAM blob not null, CONTENTENCODING text(50) null, CONTENTCHARSET text(50) null, CONTENTTYPE text(100) null, CONTENTID text(100) null, CONTENTLOCATION text(100) null, CONTENTNAME text(100) not null, constraint PK_ATTACHMENTS primary key (TQUNID));\n    CREATE TABLE COMPLIANCEPOLICIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, BODY text null, constraint PK_COMPLIANCEPOLICIES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE DBHISTORY(DATETIME text(25) not null, OPERATION text(20) not null, KUBIVERSION text(100) not null, FROMVERSION int null, TOVERSION int null);\n    CREATE TABLE DBINFO(FINGERPRINT text(32) not null, VERSION int not null);\n    CREATE TABLE DETACHEDATTACHMENTS (TQUNID text(36) not null, ISSUEID text(50) not null, OBJECTID text(50) not null, PATH text(300) not null, DETACHEDFILELASTMODTIMESTAMP text(25) null, CONTENTID text(100) not null, constraint PK_DETACHEDATTACHMENTS primary key (TQUNID));\n    CREATE TABLE DOCREFERENCES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, REFERENCEDOCUMENTID text(50) null, constraint PK_DOCREFERENCES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE DQ (TQUNID text(36) not null, ISSUEID text(50) not null, DEPENDSID text(50) null, DEPENDSTYPE int null, DEPENDSCOMMANDSTREAM blob null, DEPENDSNODEIDSEQNOKEY text(100) null, DEPENDSACLVERSION int null, constraint PK_DQ primary key (TQUNID));\n    CREATE TABLE EMAILQ(TIMEQUEUED int not null, NODEID text(50) not null, MIME blob not null, TQUNID text(36) not null);\n    CREATE TABLE ENTERPRISEDATA(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, DATE1 text(25) null, DATE2 text(25) null, DATE3 text(25) null, DATE4 text(25) null, DATE5 text(25) null, DATE6 text(25) null, DATE7 text(25) null, DATE8 text(25) null, DATE9 text(25) null, DATE10 text(25) null, VALUE1 int null, VALUE2 int null, VALUE3 int null, VALUE4 int null, VALUE5 int null, VALUE6 int null, VALUE7 int null, VALUE8 int null, VALUE9 int null, VALUE10 int null, VALUE11 int null, VALUE12 int null, VALUE13 int null, VALUE14 int null, VALUE15 int null, VALUE16 int null, VALUE17 int null, VALUE18 int null, VALUE19 int null, VALUE20 int null, STRING1 text(300) null, STRING2 text(300) null, STRING3 text(300) null, STRING4 text(300) null, STRING5 text(300) null, STRING6 text(300) null, STRING7 text(300) null, STRING8 text(300) null, STRING9 text(300) null, STRING10 text(300) null, LONGSTRING1 text null, LONGSTRING2 text null, LONGSTRING3 text null, LONGSTRING4 text null, LONGSTRING5 text null, LONGSTRING6 text null, LONGSTRING7 text null, LONGSTRING8 text null, LONGSTRING9 text null, LONGSTRING10 text null, constraint PK_ENTERPRISEDATA primary key (ISSUEID, OBJECTID));\n    CREATE TABLE FILEMORGUE(TQUNID text(36) not null, PATH text(300) not null, DELETEFOLDERWHENEMPTY text(1) null, constraint PK_FILEMORGUE primary key (TQUNID));\n    CREATE TABLE FILES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, FILENAME text(300) not null, VISIBLENAME text(300) not null, VERSIONSTRING text(300) not null, DOCUMENTHASH text(40) not null, ISFINAL text(1) null, DOCREFERENCEID text(50) not null, constraint PK_FILES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE FOLDERS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, CONTAINERNAME text(300) null, CONTAINERACLSETTINGS text null, constraint PK_FOLDERS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE GLOBALSETTINGS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, SINGULARPROJECTLABEL text(30) not null, PLURALPROJECTLABEL text(30) not null, PROJECTREQUIRED text(1) not null, CUSTOMPROJECTSALLOWED text(1) not null, ACTIONITEMSPECXML text null, PROJECTLISTXML text null, ENTERPRISEDATALABELS text null, ENTERPRISEDATATABXSL text null, constraint PK_GLOBALSETTINGS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE GLOBALSTRINGPROPERTIES(ID int not null, VALUE text(300) not null, constraint PK_GLOBALSTRINGPROPERTIES primary key (ID));\n    CREATE TABLE IMQ(TQUNID text(36) not null, DATETIMEQUEUED text(25) not null, ISSUEID text(50) not null, KUBIBUILD text(30) not null, FAILCOUNT int not null, LASTRUN text(25) null, ENVELOPESTREAM blob not null, PAYLOADSTREAM blob not null, constraint PK_IMQ primary key (TQUNID));\n    CREATE TABLE INVITATIONNODES(INVITATIONID text(50) not null, RECIPIENTNODEID text(50) not null, DATECREATED text(25) not null, constraint PK_INVITATIONNODES primary key (INVITATIONID, RECIPIENTNODEID));\n    CREATE TABLE INVITATIONS (INVITATIONID text(50) not null, SENDERNODEID text(50) not null, RECIPIENTEMAILADDR text(200) not null, RECIPIENTUSERID text(50) null, RECIPIENTNODES text null, ISSUEID text(50) not null, ENVELOPE text not null, MESSAGEBLOB blob not null, INVITATIONSTATE int not null, TQUNID text(36) not null, DATECREATED text(25) not null);\n    CREATE TABLE ISSUES (CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, CONTAINERNAME text(300) null, CONTAINERACLSETTINGS text null, ISINITIALIZED text(1) null, BLINDINVITES text null, ISSYSTEMISSUE text(1) not null, ISSUETYPE int not null, ACTIVITYTYPEID text(50) null, ISINCOMPLETE text(1) not null, constraint PK_ISSUES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE ISSUESETTINGS (CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, ISSUENAME text(300) not null, ISSUEACLSETTINGS text not null, ISSUEDUEDATE text(25) null, ISSUEPRIORITY int null, ISSUESTATUS int null, DESCRIPTION text null, PROJECTID text(100) null, PROJECTNAME text null, PROJECTNAMEISCUSTOM text(1) null, ISSYSTEMISSUE text(1) not null, ACTIONITEMREVNUM int not null, constraint PK_ISSUESETTINGS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE KMTPMSG (MSGID integer not null, SENDERID text(50) null, RECIPIENTIDLIST text not null, ISSUEID text(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, RECEIVEDDATE text(25) not null, constraint PK_KMTPMSG primary key (MSGID));\n    CREATE TABLE KMTPNODEQ(NODEID text(50) not null, MSGID int not null, RECEIVEDDATE text(25) not null, SENDCOUNT int not null);\n    CREATE TABLE KMTPQ(MSGID integer not null, SENDERID text(50) null, RECIPIENTIDLIST text not null, ISSUEID text(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, constraint PK_KMTPQ primary key (MSGID));\n    CREATE TABLE LOGENTRIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, ACTIONTYPE int not null, ASSOCIATEDOBJECTIDS text null, OLDENTITIES text null, NEWENTITIES text null, OTHERENTITIES text null, constraint PK_LOGENTRIES primary key (ISSUEID, OBJECTID));\n    CREATE TABLE LSBI(TQUNID text(36) not null, ISSUEID text(50) not null, TABLEITEMID text(50) null, TABLENODEID text(50) null, TABLECMD int null, TABLECONTAINERID text(50) null, TABLESEQNO int null, DIRTYCONTENT text null, STUBBED text(1) null, ENTITYSTUBDATA text null, UPDATENUMBER int not null, constraint PK_LSBI primary key (TQUNID));\n    CREATE TABLE LSBN(TQUNID text(36) not null, ISSUEID text(50) not null, NODEID text(50) not null, STORESEQNO int not null, SYNCSEQNO int not null, LASTMSGDATE text(25) null, constraint PK_LSBN primary key (TQUNID));\n    CREATE TABLE MMQ(TQUNID text(36) not null, ISSUEID text(50) not null, TABLEREQUESTNODE text(50) null, MMQENTRYINDEX text(60) null, DIRECTION int null, NODEID text(50) null, TABLEFIRSTSEQNO int null, TABLELASTSEQNO int null, NEXTRESENDTIMEOUT text(25) null, TABLETIMEOUTMULTIPLIER int null, constraint PK_MMQ primary key (TQUNID));\n    CREATE TABLE NODEREG(NODEID text(50) not null, USERID text(50) null, CREATETIME text(25) not null, TQUNID text(36) not null);\n    CREATE TABLE NODES (NODEID text(50) not null, USERID text(50) null, NODESTATE int not null, NODECERT text null, KUBIVERSION int not null, KUBIBUILD text(30) not null, TQUNID text(36) not null, LASTBINDDATE text(25) null, LASTUNBINDDATE text(25) null, LASTBINDIP text(15) null, NUMBINDS int not null, NUMSENDS int not null, NUMPOLLS int not null, NUMRECVS int not null);\n    CREATE TABLE PARTICIPANTNODES(ISSUEID text(50) not null, OBJECTID text(50) not null, NODEID text(50) not null, USERID text(50) null, NODESTATE int not null, NODECERT text null, KUBIVERSION int not null, KUBIBUILD text(30) not null, TQUNID text(36) not null);\n    CREATE TABLE PARTICIPANTS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARTICIPANTSTATE int not null, PARTICIPANTROLE int not null, PARTICIPANTTEAM int not null, ISREQUIREDMEMBER text(1) null, USERID text(50) null, ISAGENT text(1) null, NAME text(150) not null, EMAILADDRESS text(200) not null, ISEMAILONLY text(1) not null, INVITATION text null, ACCEPTRESENDCOUNT int null, ACCEPTRESENDTIMEOUT text(25) null, ACCEPTLASTSENTTONODEID text(50) null, constraint PK_PARTICIPANTS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE PARTICIPANTSETTINGS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARTICIPANTID text(50) not null, TASKPIMSYNC text(1) null, MOBILESUPPORT text(1) null, NOTIFYBYEMAIL text(1) null, MARKEDCRITICAL text(1) null, constraint PK_PARTICIPANTSETTINGS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE PARTITIONS(PARTITIONID text(50) not null, NAME text(100) not null, LDAPDN text(300) not null, SERVERNODEID text(50) not null, TQUNID text(36) not null);\n    CREATE TABLE PROJECTS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, NAME text(100) not null, ID text(100) null, constraint PK_PROJECTS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE TASKCOMPLETIONS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, TASKID text(50) not null, DISPOSITION int not null, STATUSID text(50) not null, SHORTNAME text(30) not null, LONGNAME text(200) not null, constraint PK_TASKCOMPLETIONS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE TASKS(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, PARENTENTITYID text(50) null, BODY text null, BODYCONTENTTYPE text(100) null, ISOBSOLETE text(1) null, DUETIME text(25) null, ASSIGNEDTO text(50) not null, TARGETOBJECTIDS text null, RESPONSEID text(50) not null, TYPEID text(50) not null, LABEL text(200) not null, INSTRUCTIONS text not null, ALLOWEDSTATUSES text not null, ISSERIALREVIEW text(1) null, DAYSTOREVIEW int null, REVIEWERIDS text(500) null, REVIEWTYPE int null, REVIEWGROUP text(300) null, constraint PK_TASKS primary key (ISSUEID, OBJECTID));\n    CREATE TABLE USERS (USERID text(50) not null, USERSID text(100) not null, ENTERPRISEUSER text(1) not null, USEREMAILADDRESS text(200) null, EMAILVALIDATED text(1) null, VALIDATIONCOOKIE text(50) null, CREATETIME text(25) not null, TQUNID text(36) not null, PARTITIONID text(50) null);\n    CREATE VIEW CRITICALISSUES as \n    \n   \n   \t\tselect\n    \t\t\tUSERID, ISSUEID, ISSUENAME, min(DATE1) DATE1\n    \t\t\tfrom (\n    \t\t\tselect p.USERID USERID, p.ISSUEID ISSUEID, iset.ISSUENAME ISSUENAME, t.DUETIME DATE1\n    \t\t\t\tfrom PARTICIPANTS p\n    \t\t\t\tjoin TASKS t on t.ASSIGNEDTO = p.OBJECTID\n    \t\t\t\tjoin TASKCOMPLETIONS tc on tc.TASKID = t.OBJECTID\n    \t\t\t\tjoin ISSUESETTINGS iset on iset.ISSUEID = p.ISSUEID\n    \t\t\t\twhere (t.ISOBSOLETE = 'n' or t.ISOBSOLETE is null)\n    \t\t\t\tand tc.DISPOSITION = 1\n    \t\t\t\tand iset.ISSUESTATUS = 1\n    \t\t\tunion\n    \t\t\tselect p.USERID USERID, p.ISSUEID ISSUEID, iset.ISSUENAME ISSUENAME, iset.ISSUEDUEDATE DATE1\n    \t\t\t\tfrom PARTICIPANTS p\n    \t\t\t\tjoin PARTICIPANTSETTINGS ps on ps.PARTICIPANTID = p.OBJECTID\n    \t\t\t\tjoin ISSUESETTINGS iset on iset.ISSUEID = p.ISSUEID\n    \t\t\t\twhere ps.MARKEDCRITICAL = 'y'\n    \t\t\t\tand iset.ISSUESTATUS = 1\n    \t\t\t) as CRITICALDATA\n    \t\t\tgroup by USERID, ISSUEID, ISSUENAME;\n    CREATE VIEW CURRENTFILES as \n    \n   \n   \t\tselect\n    \t\t\td.ISSUEID as ISSUEID,\n    \t\t\td.REFERENCEDOCUMENTID as OBJECTID,\n    \t\t\tf.VISIBLENAME as VISIBLENAME\n    \t\t\tfrom\n    \t\t\t\tDOCREFERENCES d\n    \t\t\t\tjoin FILES f on f.OBJECTID = d.REFERENCEDOCUMENTID;\n    CREATE VIEW ISSUEDATA as \n    \n   \n   \t\tselect\n    \t\t\tISSUES.OBJECTID as ISSUEID,\n    \t\t\tISSUES.CREATIONDATE as CREATIONDATE,\n    \t\t\tISSUES.AUTHORID as AUTHORID,\n    \t\t\tISSUES.LASTMODIFIEDDATE as LASTMODIFIEDDATE,\n    \t\t\tISSUES.LASTMODIFIEDBYID as LASTMODIFIEDBYID,\n    \t\t\tISSUESETTINGS.ISSUENAME as ISSUENAME,\n    \t\t\tISSUES.ISINITIALIZED as ISINITIALIZED,\n    \t\t\tISSUES.ISSYSTEMISSUE as ISSYSTEMISSUE,\n    \t\t\tISSUES.ISSUETYPE as ISSUETYPE,\n    \t\t\tISSUES.ISINCOMPLETE as ISINCOMPLETE,\n    \t\t\tISSUESETTINGS.REVISIONNUM as ISSUESETTINGS_REVISIONNUM,\n    \t\t\tISSUESETTINGS.LASTMODIFIEDDATE as ISSUESETTINGS_LASTMODIFIEDDATE,\n    \t\t\tISSUESETTINGS.LASTMODIFIEDBYID as ISSUESETTINGS_LASTMODIFIEDBYID,\n    \t\t\tISSUESETTINGS.ISSUEDUEDATE as ISSUEDUEDATE,\n    \t\t\tISSUESETTINGS.ISSUEPRIORITY as ISSUEPRIORITY,\n    \t\t\tISSUESETTINGS.ISSUESTATUS as ISSUESTATUS,\n    \t\t\tISSUESETTINGS.DESCRIPTION as DESCRIPTION,\n    \t\t\tISSUESETTINGS.PROJECTID as PROJECTID,\n    \t\t\tISSUESETTINGS.PROJECTNAME as PROJECTNAME,\n    \t\t\tISSUESETTINGS.PROJECTNAMEISCUSTOM as PROJECTNAMEISCUSTOM,\n    \t\t\tENTERPRISEDATA.REVISIONNUM as ENTERPRISEDATA_REVISIONNUM,\n    \t\t\tENTERPRISEDATA.CREATIONDATE as ENTERPRISEDATA_CREATIONDATE,\n    \t\t\tENTERPRISEDATA.AUTHORID as ENTERPRISEDATA_AUTHORID,\n    \t\t\tENTERPRISEDATA.LASTMODIFIEDDATE as ENTERPRISEDATA_LASTMODIFIEDDATE,\n    \t\t\tENTERPRISEDATA.LASTMODIFIEDBYID as ENTERPRISEDATA_LASTMODIFIEDBYID,\n    \t\t\tENTERPRISEDATA.DATE1 as DATE1,\n    \t\t\tENTERPRISEDATA.DATE2 as DATE2,\n    \t\t\tENTERPRISEDATA.DATE3 as DATE3,\n    \t\t\tENTERPRISEDATA.DATE4 as DATE4,\n    \t\t\tENTERPRISEDATA.DATE5 as DATE5,\n    \t\t\tENTERPRISEDATA.DATE6 as DATE6,\n    \t\t\tENTERPRISEDATA.DATE7 as DATE7,\n    \t\t\tENTERPRISEDATA.DATE8 as DATE8,\n    \t\t\tENTERPRISEDATA.DATE9 as DATE9,\n    \t\t\tENTERPRISEDATA.DATE10 as DATE10,\n    \t\t\tENTERPRISEDATA.VALUE1 as VALUE1,\n    \t\t\tENTERPRISEDATA.VALUE2 as VALUE2,\n    \t\t\tENTERPRISEDATA.VALUE3 as VALUE3,\n    \t\t\tENTERPRISEDATA.VALUE4 as VALUE4,\n    \t\t\tENTERPRISEDATA.VALUE5 as VALUE5,\n    \t\t\tENTERPRISEDATA.VALUE6 as VALUE6,\n    \t\t\tENTERPRISEDATA.VALUE7 as VALUE7,\n    \t\t\tENTERPRISEDATA.VALUE8 as VALUE8,\n    \t\t\tENTERPRISEDATA.VALUE9 as VALUE9,\n    \t\t\tENTERPRISEDATA.VALUE10 as VALUE10,\n    \t\t\tENTERPRISEDATA.VALUE11 as VALUE11,\n    \t\t\tENTERPRISEDATA.VALUE12 as VALUE12,\n    \t\t\tENTERPRISEDATA.VALUE13 as VALUE13,\n    \t\t\tENTERPRISEDATA.VALUE14 as VALUE14,\n    \t\t\tENTERPRISEDATA.VALUE15 as VALUE15,\n    \t\t\tENTERPRISEDATA.VALUE16 as VALUE16,\n    \t\t\tENTERPRISEDATA.VALUE17 as VALUE17,\n    \t\t\tENTERPRISEDATA.VALUE18 as VALUE18,\n    \t\t\tENTERPRISEDATA.VALUE19 as VALUE19,\n    \t\t\tENTERPRISEDATA.VALUE20 as VALUE20,\n    \t\t\tENTERPRISEDATA.STRING1 as STRING1,\n    \t\t\tENTERPRISEDATA.STRING2 as STRING2,\n    \t\t\tENTERPRISEDATA.STRING3 as STRING3,\n    \t\t\tENTERPRISEDATA.STRING4 as STRING4,\n    \t\t\tENTERPRISEDATA.STRING5 as STRING5,\n    \t\t\tENTERPRISEDATA.STRING6 as STRING6,\n    \t\t\tENTERPRISEDATA.STRING7 as STRING7,\n    \t\t\tENTERPRISEDATA.STRING8 as STRING8,\n    \t\t\tENTERPRISEDATA.STRING9 as STRING9,\n    \t\t\tENTERPRISEDATA.STRING10 as STRING10,\n    \t\t\tENTERPRISEDATA.LONGSTRING1 as LONGSTRING1,\n    \t\t\tENTERPRISEDATA.LONGSTRING2 as LONGSTRING2,\n    \t\t\tENTERPRISEDATA.LONGSTRING3 as LONGSTRING3,\n    \t\t\tENTERPRISEDATA.LONGSTRING4 as LONGSTRING4,\n    \t\t\tENTERPRISEDATA.LONGSTRING5 as LONGSTRING5,\n    \t\t\tENTERPRISEDATA.LONGSTRING6 as LONGSTRING6,\n    \t\t\tENTERPRISEDATA.LONGSTRING7 as LONGSTRING7,\n    \t\t\tENTERPRISEDATA.LONGSTRING8 as LONGSTRING8,\n    \t\t\tENTERPRISEDATA.LONGSTRING9 as LONGSTRING9,\n    \t\t\tENTERPRISEDATA.LONGSTRING10 as LONGSTRING10\n    \t\tfrom\n    \t\t\tISSUES \n    \t\t\tjoin ISSUESETTINGS on ISSUES.OBJECTID = ISSUESETTINGS.ISSUEID\n    \t\t\tleft outer join ENTERPRISEDATA on ISSUES.OBJECTID = ENTERPRISEDATA.ISSUEID;\n    CREATE VIEW ITEMS as \n    \n   select 'FILES' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, FILENAME, VISIBLENAME, VERSIONSTRING, DOCUMENTHASH, ISFINAL, DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from FILES\n    union all\n    select 'LOGENTRIES' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, ACTIONTYPE, ASSOCIATEDOBJECTIDS, OLDENTITIES, NEWENTITIES, OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from LOGENTRIES\n    union all\n    select 'LSBI' as TABLENAME, NULL as CLASSID, NULL as SEQNO, NULL as LASTMODONNODEID, NULL as PREVMODONNODEID, ISSUEID, NULL as OBJECTID, NULL as REVISIONNUM, NULL as CONTAINERID, NULL as AUTHORID, NULL as CREATIONDATE, NULL as LASTMODIFIEDDATE, UPDATENUMBER, NULL as PREVREVISIONNUM, NULL as LASTCMD, NULL as LASTCMDACLVERSION, NULL as USERDEFINEDFIELD, NULL as LASTMODIFIEDBYID, NULL as PARENTENTITYID, NULL as BODY, NULL as BODYCONTENTTYPE, NULL as ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, TQUNID, TABLEITEMID, TABLENODEID, TABLECMD, TABLECONTAINERID, TABLESEQNO, DIRTYCONTENT, STUBBED, ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from LSBI where TABLECMD=3\n    union all\n    select 'PARTICIPANTS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, NULL as PARENTENTITYID, NULL as BODY, NULL as BODYCONTENTTYPE, NULL as ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, PARTICIPANTSTATE, PARTICIPANTROLE, PARTICIPANTTEAM, ISREQUIREDMEMBER, USERID, ISAGENT, NAME, EMAILADDRESS, ISEMAILONLY, INVITATION, ACCEPTRESENDCOUNT, ACCEPTRESENDTIMEOUT, ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from PARTICIPANTS\n    union all\n    select 'TASKCOMPLETIONS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, TASKID, DISPOSITION, STATUSID, SHORTNAME, LONGNAME, NULL as DUETIME, NULL as ASSIGNEDTO, NULL as TARGETOBJECTIDS, NULL as RESPONSEID, NULL as TYPEID, NULL as LABEL, NULL as INSTRUCTIONS, NULL as ALLOWEDSTATUSES, NULL as ISSERIALREVIEW, NULL as DAYSTOREVIEW, NULL as REVIEWERIDS, NULL as REVIEWTYPE, NULL as REVIEWGROUP from TASKCOMPLETIONS\n    union all\n    select 'TASKS' as TABLENAME, CLASSID, SEQNO, LASTMODONNODEID, PREVMODONNODEID, ISSUEID, OBJECTID, REVISIONNUM, CONTAINERID, AUTHORID, CREATIONDATE, LASTMODIFIEDDATE, UPDATENUMBER, PREVREVISIONNUM, LASTCMD, LASTCMDACLVERSION, USERDEFINEDFIELD, LASTMODIFIEDBYID, PARENTENTITYID, BODY, BODYCONTENTTYPE, ISOBSOLETE, NULL as FILENAME, NULL as VISIBLENAME, NULL as VERSIONSTRING, NULL as DOCUMENTHASH, NULL as ISFINAL, NULL as DOCREFERENCEID, NULL as ACTIONTYPE, NULL as ASSOCIATEDOBJECTIDS, NULL as OLDENTITIES, NULL as NEWENTITIES, NULL as OTHERENTITIES, NULL as TQUNID, NULL as TABLEITEMID, NULL as TABLENODEID, NULL as TABLECMD, NULL as TABLECONTAINERID, NULL as TABLESEQNO, NULL as DIRTYCONTENT, NULL as STUBBED, NULL as ENTITYSTUBDATA, NULL as PARTICIPANTSTATE, NULL as PARTICIPANTROLE, NULL as PARTICIPANTTEAM, NULL as ISREQUIREDMEMBER, NULL as USERID, NULL as ISAGENT, NULL as NAME, NULL as EMAILADDRESS, NULL as ISEMAILONLY, NULL as INVITATION, NULL as ACCEPTRESENDCOUNT, NULL as ACCEPTRESENDTIMEOUT, NULL as ACCEPTLASTSENTTONODEID, NULL as TASKID, NULL as DISPOSITION, NULL as STATUSID, NULL as SHORTNAME, NULL as LONGNAME, DUETIME, ASSIGNEDTO, TARGETOBJECTIDS, RESPONSEID, TYPEID, LABEL, INSTRUCTIONS, ALLOWEDSTATUSES, ISSERIALREVIEW, DAYSTOREVIEW, REVIEWERIDS, REVIEWTYPE, REVIEWGROUP from TASKS;\n    CREATE VIEW TASKINFO as \n    \n   \n   \t\tselect\n    \t\t\tt.ISSUEID as ISSUEID,\n    \t\t\tt.OBJECTID as OBJECTID,\n    \t\t\tt.ASSIGNEDTO as ASSIGNEDTO,\n    \t\t\tt.TARGETOBJECTIDS as TARGETOBJECTIDS,\n    \t\t\tt.DUETIME as DUETIME,\n    \t\t\tt.ISOBSOLETE as ISOBSOLETE,\n    \t\t\ttc.DISPOSITION as DISPOSITION\n    \t\t\tfrom\n    \t\t\t\tTASKS t\n    \t\t\t\tjoin TASKCOMPLETIONS tc on tc.TASKID = t.OBJECTID;\n    CREATE INDEX DQ_ISSUEID_DEPENDSID on DQ (ISSUEID, DEPENDSID);\n    CREATE INDEX EMAILQ_TIMEQUEUED on EMAILQ (TIMEQUEUED);\n    CREATE INDEX FOLDERS_CONTAINERID_ISSUEID on FOLDERS (CONTAINERID, ISSUEID);\n    CREATE INDEX IMQ_DATETIMEQUEUED on IMQ (DATETIMEQUEUED);\n    CREATE INDEX INVITATIONS_RECIPIENTUSERID_INVITATIONID on INVITATIONS (RECIPIENTUSERID, INVITATIONID);\n    CREATE INDEX INVITATIONS_TQUNID on INVITATIONS (TQUNID);\n    CREATE INDEX ISSUESETTINGS_CONTAINERID on ISSUESETTINGS (CONTAINERID);\n    CREATE INDEX KMTPMSG_RECEIVEDDATE on KMTPMSG (RECEIVEDDATE desc);\n    CREATE INDEX KMTPNODEQ_MSGID on KMTPNODEQ (MSGID);\n    CREATE INDEX KMTPNODEQ_NODEID_MSGID on KMTPNODEQ (NODEID, MSGID);\n    CREATE INDEX KMTPNODEQ_RECEIVEDDATE on KMTPNODEQ (RECEIVEDDATE desc);\n    CREATE INDEX LSBI_ISSUEID_TABLEITEMID on LSBI (ISSUEID, TABLEITEMID);\n    CREATE INDEX LSBN_ISSUEID_NODEID on LSBN (ISSUEID, NODEID);\n    CREATE INDEX MMQ_ISSUEID_MMQENTRYINDEX on MMQ (ISSUEID, MMQENTRYINDEX);\n    CREATE INDEX NODEREG_NODEID_USERID on NODEREG (NODEID, USERID);\n    CREATE INDEX NODEREG_TQUNID on NODEREG (TQUNID);\n    CREATE INDEX NODEREG_USERID_NODEID on NODEREG (USERID, NODEID);\n    CREATE INDEX NODES_NODEID on NODES (NODEID);\n    CREATE INDEX NODES_TQUNID on NODES (TQUNID);\n    CREATE INDEX PARTICIPANTNODES_ISSUEID_OBJECTID_NODEID on PARTICIPANTNODES (ISSUEID, OBJECTID, NODEID);\n    CREATE INDEX PARTICIPANTNODES_TQUNID on PARTICIPANTNODES (TQUNID);\n    CREATE INDEX PARTICIPANTSETTINGS_PARTICIPANTID on PARTICIPANTSETTINGS (PARTICIPANTID);\n    CREATE INDEX PARTITIONS_LDAPDN on PARTITIONS (LDAPDN);\n    CREATE INDEX PARTITIONS_PARTITIONID_SERVERNODEID on PARTITIONS (PARTITIONID, SERVERNODEID);\n    CREATE INDEX PARTITIONS_SERVERNODEID_PARTITIONID on PARTITIONS (SERVERNODEID, PARTITIONID);\n    CREATE INDEX PARTITIONS_TQUNID on PARTITIONS (TQUNID);\n    CREATE INDEX TASKCOMPLETIONS_TASKID on TASKCOMPLETIONS (TASKID);\n    CREATE INDEX TASKS_ASSIGNEDTO on TASKS (ASSIGNEDTO);\n    CREATE INDEX USERS_PARTITIONID_USERID on USERS (PARTITIONID, USERID);\n    CREATE INDEX USERS_TQUNID on USERS (TQUNID);\n    CREATE INDEX USERS_USERID_PARTITIONID on USERS (USERID, PARTITIONID);\n    CREATE INDEX USERS_USERSID_USERID on USERS (USERSID, USERID);\n    COMMIT;\n  }\n} {}\n\n# Given the schema above, the following query was cause an assertion fault\n# do to an uninitialized field in a Select structure.\n#\ndo_test tkt1449-1.2 {\n  execsql {\n    select NEWENTITIES from ITEMS where ((ISSUEID = 'x') and (OBJECTID = 'y'))\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1473.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1473 has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return \n}\n\ndo_test tkt1473-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    SELECT * FROM t1\n  }\n} {1 2 3 4}\n\ndo_test tkt1473-1.2 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0\n  }\n} {1}\ndo_test tkt1473-1.3 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0\n  }\n} {1}\ndo_test tkt1473-1.4 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4\n  }\n} {1 2}\ndo_test tkt1473-1.5 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4\n  }\n} {1 2}\ndo_test tkt1473-1.6 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4\n  }\n} {2}\ndo_test tkt1473-1.7 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4\n  }\n} {2}\ndo_test tkt1473-1.8 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0\n  }\n} {}\ndo_test tkt1473-1.9 {\n  execsql {\n    SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0\n  }\n} {}\n\n# Everything from this point on depends on sub-queries. So skip it\n# if sub-queries are not available.\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test tkt1473-2.2 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)\n  }\n} {1}\ndo_test tkt1473-2.3 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)\n  }\n} {1}\ndo_test tkt1473-2.4 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-2.5 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-2.6 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)\n  }\n} {2}\ndo_test tkt1473-2.7 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)\n  }\n} {2}\ndo_test tkt1473-2.8 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)\n  }\n} {{}}\ndo_test tkt1473-2.9 {\n  execsql {\n    SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)\n  }\n} {{}}\n\ndo_test tkt1473-3.2 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)\n  }\n} {1}\ndo_test tkt1473-3.3 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)\n  }\n} {1}\ndo_test tkt1473-3.4 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-3.5 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-3.6 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-3.7 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)\n  }\n} {1}\ndo_test tkt1473-3.8 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)\n  }\n} {0}\ndo_test tkt1473-3.9 {\n  execsql {\n    SELECT EXISTS\n      (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)\n  }\n} {0}\n\ndo_test tkt1473-4.1 {\n  execsql {\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(1,2);\n    INSERT INTO t2 SELECT x+2, y+2 FROM t2;\n    INSERT INTO t2 SELECT x+4, y+4 FROM t2;\n    INSERT INTO t2 SELECT x+8, y+8 FROM t2;\n    INSERT INTO t2 SELECT x+16, y+16 FROM t2;\n    INSERT INTO t2 SELECT x+32, y+32 FROM t2;\n    INSERT INTO t2 SELECT x+64, y+64 FROM t2;\n    SELECT count(*), sum(x), sum(y) FROM t2;\n  }\n} {64 4096 4160}\ndo_test tkt1473-4.2 {\n  execsql {\n    SELECT 1 FROM t2 WHERE x=0\n    UNION ALL\n    SELECT 2 FROM t2 WHERE x=1\n    UNION ALL\n    SELECT 3 FROM t2 WHERE x=2\n    UNION ALL\n    SELECT 4 FROM t2 WHERE x=3\n    UNION ALL\n    SELECT 5 FROM t2 WHERE x=4\n    UNION ALL\n    SELECT 6 FROM t2 WHERE y=0\n    UNION ALL\n    SELECT 7 FROM t2 WHERE y=1\n    UNION ALL\n    SELECT 8 FROM t2 WHERE y=2\n    UNION ALL\n    SELECT 9 FROM t2 WHERE y=3\n    UNION ALL\n    SELECT 10 FROM t2 WHERE y=4\n  }\n} {2 4 8 10}\ndo_test tkt1473-4.3 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=3\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {2}\ndo_test tkt1473-4.4 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=3\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {4}\ndo_test tkt1473-4.5 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {8}\ndo_test tkt1473-4.6 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {10}\ndo_test tkt1473-4.7 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {{}}\n\ndo_test tkt1473-5.3 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=3\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\ndo_test tkt1473-5.4 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=3\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\n\ndo_test tkt1473-5.5 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=2\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {1}\ndo_test tkt1473-5.6 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\ndo_test tkt1473-5.7 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION ALL\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION ALL\n      SELECT 3 FROM t2 WHERE x=2\n      UNION ALL\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION ALL\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION ALL\n      SELECT 7 FROM t2 WHERE y=1\n      UNION ALL\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION ALL\n      SELECT 9 FROM t2 WHERE y=3\n      UNION ALL\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {0}\n\ndo_test tkt1473-6.3 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=3\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=2\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\ndo_test tkt1473-6.4 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=3\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=2\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\n\ndo_test tkt1473-6.5 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=-1\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=2\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {1}\ndo_test tkt1473-6.6 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\ndo_test tkt1473-6.7 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {0}\ndo_test tkt1473-6.8 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=4\n    )\n  }\n} {1}\ndo_test tkt1473-6.9 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0\n      UNION\n      SELECT 2 FROM t2 WHERE x=-1\n      UNION\n      SELECT 3 FROM t2 WHERE x=2\n      UNION\n      SELECT 4 FROM t2 WHERE x=-2\n      UNION\n      SELECT 5 FROM t2 WHERE x=4\n      UNION ALL\n      SELECT 6 FROM t2 WHERE y=0\n      UNION\n      SELECT 7 FROM t2 WHERE y=1\n      UNION\n      SELECT 8 FROM t2 WHERE y=-3\n      UNION\n      SELECT 9 FROM t2 WHERE y=3\n      UNION\n      SELECT 10 FROM t2 WHERE y=-4\n    )\n  }\n} {0}\n\ndo_test tkt1473-7.1 {\n  execsql {\n    SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2\n  }\n} {1}\ndo_test tkt1473-7.2 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {1}\ndo_test tkt1473-7.3 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {1}\ndo_test tkt1473-7.4 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {{}}\ndo_test tkt1473-7.5 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {0}\n\ndo_test tkt1473-8.1 {\n  execsql {\n    SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2\n  }\n} {}\ndo_test tkt1473-8.1 {\n  execsql {\n    SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2\n  }\n} {1}\ndo_test tkt1473-8.3 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {{}}\ndo_test tkt1473-8.4 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2\n    )\n  }\n} {1}\ndo_test tkt1473-8.5 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2\n    )\n  }\n} {0}\ndo_test tkt1473-8.6 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2\n    )\n  }\n} {1}\ndo_test tkt1473-8.7 {\n  execsql {\n    SELECT (\n      SELECT 1 FROM t2 WHERE x=0 INTERSECT SELECT 1 FROM t2 WHERE y=2\n    )\n  }\n} {{}}\ndo_test tkt1473-8.8 {\n  execsql {\n    SELECT EXISTS (\n      SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=0\n    )\n  }\n} {0}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1501.test",
    "content": "# 2005 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1501 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt1501-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    SELECT a, b, 'abc' FROM t1\n      UNION\n      SELECT b, a, 'xyz' FROM t1\n      ORDER BY 2, 3;\n  }\n} {2 1 xyz 1 2 abc}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1512.test",
    "content": "# 2005 September 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1512 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!vacuum || !autovacuum} {\n  finish_test\n  return\n}\nif {[db one {PRAGMA auto_vacuum}]} {\n  finish_test\n  return\n}\n\ndo_test tkt1512-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(3,4);\n    SELECT * FROM t1\n  }\n} {1 2 3 4}\ndo_test tkt1512-1.2 {\n  file size test.db\n} {2048}\ndo_test tkt1512-1.3 {\n  execsql {\n    DROP TABLE t1;\n  }\n  file size test.db\n} {2048}\ndo_test tkt1512-1.4 {\n  execsql {\n    VACUUM;\n  }\n  file size test.db\n} {1024}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1514.test",
    "content": "# 2005 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1514 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt1514-1.1 {\n  catchsql {\n    CREATE TABLE t1(a,b);\n    SELECT a FROM t1 WHERE max(b)<10 GROUP BY a;\n  }\n} {1 {misuse of aggregate: max()}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1536.test",
    "content": "# 2005 November 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1536 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt1536-1.1 {\n  execsql {\n    CREATE TABLE t1(\n      a INTEGER PRIMARY KEY,\n      b TEXT\n    );\n    INSERT INTO t1 VALUES(1,'01');\n    SELECT typeof(a), typeof(b) FROM t1;\n  }\n} {integer text}\ndo_test tkt1536-1.2 {\n  execsql {\n    INSERT INTO t1(b) SELECT b FROM t1;\n    SELECT b FROM t1 WHERE rowid=2;\n  }\n} {01}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1537.test",
    "content": "# 2005 November 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1537 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt1537-1.1 {\n  execsql {\n    CREATE TABLE t1(id, a1, a2);\n    INSERT INTO t1 VALUES(1, NULL, NULL);\n    INSERT INTO t1 VALUES(2, 1, 3);\n    CREATE TABLE t2(id, b);\n    INSERT INTO t2 VALUES(3, 1);\n    INSERT INTO t2 VALUES(4, NULL);\n    SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b;\n  }\n} {1 {} {} {} {} 2 1 3 3 1}\ndo_test tkt1537-1.2 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;\n  }\n} {1 {} {} {} {} 2 1 3 3 1}\ndo_test tkt1537-1.3 {\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;\n  }\n} {3 1 2 1 3 4 {} {} {} {}}\nifcapable subquery {\n  do_test tkt1537-1.4 {\n    execsql {\n      SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);\n    }\n  } {1 {} {} {} {} 2 1 3 3 1}\n  do_test tkt1537-1.5 {\n    execsql {\n      SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);\n    }\n  } {3 1 2 1 3 4 {} {} {} {}}\n}\ndo_test tkt1537-1.6 {\n  execsql {\n    CREATE INDEX t1a1 ON t1(a1);\n    CREATE INDEX t1a2 ON t1(a2);\n    CREATE INDEX t2b ON t2(b);\n    SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;\n  }\n} {1 {} {} {} {} 2 1 3 3 1}\ndo_test tkt1537-1.7 {\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;\n  }\n} {3 1 2 1 3 4 {} {} {} {}}\n\nifcapable subquery {\n  do_test tkt1537-1.8 {\n    execsql {\n      SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);\n    }\n  } {1 {} {} {} {} 2 1 3 3 1}\n  do_test tkt1537-1.9 {\n    execsql {\n      SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);\n    }\n  } {3 1 2 1 3 4 {} {} {} {}}\n}\n\nexecsql {\n  DROP INDEX t1a1;\n  DROP INDEX t1a2;\n  DROP INDEX t2b;\n}\n\ndo_test tkt1537-2.1 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;\n  }\n} {1 {} {} {} {} 2 1 3 3 1}\ndo_test tkt1537-2.2 {\n  execsql {\n    CREATE INDEX t2b ON t2(b);\n    SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;\n  }\n} {1 {} {} {} {} 2 1 3 3 1}\ndo_test tkt1537-2.3 {\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;\n  }\n} {3 1 2 1 3 4 {} {} {} {}}\ndo_test tkt1537-2.4 {\n  execsql {\n    CREATE INDEX t1a1 ON t1(a1);\n    CREATE INDEX t1a2 ON t1(a2);\n    SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;\n  }\n} {3 1 2 1 3 4 {} {} {} {}}\n\ndo_test tkt1537-3.1 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1;\n  }\n} {1 {} {} {} {}}\ndo_test tkt1537-3.2 {\n  execsql { \n    SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3;\n  }\n} {3 1 {} {} {}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1567.test",
    "content": "# 2005 December 19 2005\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1567 is\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt1567-1.1 {\n  execsql {\n    CREATE TABLE t1(a TEXT PRIMARY KEY);\n  }\n  set bigstr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n  for {set i 0} {$i<100} {incr i} {\n    set x [format %5d [expr $i*2]]\n    set sql \"INSERT INTO t1 VALUES('$x-$bigstr')\"\n    execsql $sql\n  }\n} {}\nintegrity_check tkt1567-1.2\n\ndo_test tkt1567-1.3 {\n  execsql {\n    BEGIN;\n    UPDATE t1 SET a = a||'x' WHERE rowid%2==0;\n  }\n} {}\ndo_test tkt1567-1.4 {\n  catchsql {\n    UPDATE t1 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test tkt1567-1.5 {\n  execsql {\n    COMMIT;\n  }\n} {}\nintegrity_check tkt1567-1.6\n\ndo_test tkt1567-2.1 {\n  execsql {\n    CREATE TABLE t2(a TEXT PRIMARY KEY, rowid INT) WITHOUT rowid;\n  }\n  set bigstr abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n  for {set i 0} {$i<100} {incr i} {\n    set x [format %5d [expr $i*2]]\n    set sql \"INSERT INTO t2 VALUES('$x-$bigstr', $i+1)\"\n    execsql $sql\n  }\n} {}\nintegrity_check tkt1567-2.2\n\ndo_test tkt1567-2.3 {\n  execsql {\n    BEGIN;\n    UPDATE t2 SET a = a||'x' WHERE rowid%2==0;\n  }\n} {}\ndo_test tkt1567-2.4 {\n  catchsql {\n    UPDATE t2 SET a = CASE WHEN rowid<90 THEN substr(a,1,10) ELSE '9999' END;\n  }\n} {1 {UNIQUE constraint failed: t2.a}}\ndo_test tkt1567-2.5 {\n  execsql {\n    COMMIT;\n  }\n} {}\nintegrity_check tkt1567-2.6\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1644.test",
    "content": "# 2006 January 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1644 is\n# fixed.  Ticket #1644 complains that precompiled statements\n# are not expired correctly as a result of changes to TEMP\n# views and triggers.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !tempdb||!view {\n  finish_test\n  return\n}  \n\n# Create two tables T1 and T2 and make V1 point to T1.\ndo_test tkt1644-1.1 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    CREATE TABLE t2(b);\n    INSERT INTO t2 VALUES(99);\n    CREATE TEMP VIEW v1 AS SELECT * FROM t1;\n    SELECT * FROM v1;\n  }\n} {1}\n\n# The \"SELECT * FROM v1\" should be in the TCL interface cache below.\n# It will continue to point to T1 unless the cache is invalidated when\n# the view changes.\n#\ndo_test tkt1644-1.2 {\n  execsql {\n    DROP VIEW v1;\n    CREATE TEMP VIEW v1 AS SELECT * FROM t2;\n    SELECT * FROM v1;\n  }\n} {99}\n\n# Cache an access to the T1 table.\n#\ndo_test tkt1644-1.3 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} {1}\n\n# Create a temp table T1.  Make sure the cache is invalidated so that\n# the statement is recompiled and refers to the empty temp table.\n#\ndo_test tkt1644-1.4 {\n  execsql {\n    CREATE TEMP TABLE t1(x);\n  }\n  execsql {\n    SELECT * FROM t1;\n  }\n} {}\n\nifcapable view {\n  do_test tkt1644-2.1 {\n    execsql {\n      CREATE TEMP TABLE temp_t1(a, b);\n    }\n    set ::DB [sqlite3_connection_pointer db]\n    set ::STMT [sqlite3_prepare $::DB \"SELECT * FROM temp_t1\" -1 DUMMY]\n    execsql {\n      DROP TABLE temp_t1;\n    }\n    list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]\n  } {SQLITE_ERROR SQLITE_SCHEMA}\n  \n  do_test tkt1644-2.2 {\n    execsql {\n      CREATE TABLE real_t1(a, b);\n      CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1;\n    }\n    set ::DB [sqlite3_connection_pointer db]\n    set ::STMT [sqlite3_prepare $::DB \"SELECT * FROM temp_v1\" -1 DUMMY]\n    execsql {\n      DROP VIEW temp_v1;\n    }\n    list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]\n  } {SQLITE_ERROR SQLITE_SCHEMA}\n\n  do_test tkt1644-2.3 {\n    execsql {\n      CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1 LIMIT 10 OFFSET 10;\n    }\n    set ::DB [sqlite3_connection_pointer db]\n    set ::STMT [sqlite3_prepare $::DB \"SELECT * FROM temp_v1\" -1 DUMMY]\n    execsql {\n      DROP VIEW temp_v1;\n    }\n    list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]\n  } {SQLITE_ERROR SQLITE_SCHEMA}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1667.test",
    "content": "# 2006 February 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1667 has been\n# fixed.  \n#\n#\n# $Id: tkt1667.test,v 1.4 2009/02/05 17:00:54 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !autovacuum||!tclvar {\n  finish_test\n  return\n}\n\ndb close\nforcedelete test.db test.db-journal\n\n# Set the pending byte offset such that the page it is on is\n# the first autovacuum pointer map page in the file (assume a page \n# size of 1024).\n\nset first_ptrmap_page   [expr 1024/5 + 3]\nsqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)]\n\nsqlite3 db test.db\n\ndo_test tkt1667-1 {\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    BEGIN;\n    CREATE TABLE t1(a, b);\n  }\n  for {set i 0} {$i < 500} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, randstr(1000, 2000))\n    }\n  }\n  execsql {\n    COMMIT;\n  }\n} {}\nfor {set i 0} {$i < 500} {incr i} {\n  do_test tkt1667-2.$i.1 {\n    execsql {\n      DELETE FROM t1 WHERE a = $i;\n    }\n  } {}\n  integrity_check tkt1667-2.$i.2\n}\n\ndo_test tkt1667-3 {\n  execsql {\n    BEGIN;\n  }\n  for {set i 0} {$i < 500} {incr i} {\n    execsql {\n      INSERT INTO t1 VALUES($i, randstr(1000, 2000))\n    }\n  }\n  execsql {\n    COMMIT;\n  }\n} {}\ndo_test tkt1667-4.1 {\n  execsql {\n    DELETE FROM t1;\n  }\n} {}\nintegrity_check tkt1667-4.2\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt1873.test",
    "content": "# 2006 June 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #1873 has been\n# fixed.  \n#\n#\n# $Id: tkt1873.test,v 1.2 2007/10/09 08:29:33 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !attach {\n  finish_test\n  return\n}\n\nforcedelete test2.db test2.db-journal\n\ndo_test tkt1873-1.1 {\n  execsql {\n    CREATE TABLE t1(x, y);\n    ATTACH 'test2.db' AS aux;\n    CREATE TABLE aux.t2(x, y);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t2 VALUES(5, 6);\n    INSERT INTO t2 VALUES(7, 8);\n  }\n} {}\n\ndo_test tkt1873-1.2 {\n  set rc [catch {\n    db eval {SELECT * FROM t2 LIMIT 1} {\n      db eval {DETACH aux}\n    }\n  } msg]\n  list $rc $msg\n} {1 {database aux is locked}}\n\ndo_test tkt1873-1.3 {\n  set rc [catch {\n    db eval {SELECT * FROM t1 LIMIT 1} {\n      db eval {DETACH aux}\n    }\n  } msg]\n  list $rc $msg\n} {0 {}}\n\ndo_test tkt1873-1.4 {\n  catchsql {\n    select * from t2;\n  }\n} {1 {no such table: t2}}\n\ndo_test tkt1873-1.5 {\n  catchsql {\n    ATTACH 'test2.db' AS aux;\n    select * from t2;\n  }\n} {0 {5 6 7 8}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2141.test",
    "content": "# 2007 January 03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #2141 has been\n# fixed.  \n#\n#\n# $Id: tkt2141.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test tkt2141-1.1 {\n  execsql {\n      CREATE TABLE tab1 (t1_id integer PRIMARY KEY, t1_desc);\n      INSERT INTO tab1 VALUES(1,'rec 1 tab 1');\n      CREATE TABLE tab2 (t2_id integer PRIMARY KEY, t2_id_t1, t2_desc);\n      INSERT INTO tab2 VALUES(1,1,'rec 1 tab 2');\n      CREATE TABLE tab3 (t3_id integer PRIMARY KEY, t3_id_t2, t3_desc);\n      INSERT INTO tab3 VALUES(1,1,'aa');\n      SELECT *\n      FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1\n      WHERE t2.t2_id IN\n           (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2\n             WHERE t3_id IN (1,2) GROUP BY t2_id);\n  }\n} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}\ndo_test tkt2141-1.2 {\n  execsql {\n      SELECT *\n      FROM tab1 t1 LEFT JOIN tab2 t2 ON t1.t1_id = t2.t2_id_t1\n      WHERE t2.t2_id IN\n           (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2\n             WHERE t3_id IN (1,2));\n  }\n} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}\ndo_test tkt2141-1.3 {\n  execsql {\n      SELECT *\n      FROM tab1 t1 LEFT JOIN tab2 t2\n      WHERE t2.t2_id IN\n           (SELECT t2_id FROM tab2, tab3 ON t2_id = t3_id_t2\n             WHERE t3_id IN (1,2));\n  }\n} {1 {rec 1 tab 1} 1 1 {rec 1 tab 2}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2192.test",
    "content": "# 2007 January 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #2192 has been\n# fixed.  \n#\n#\n# $Id: tkt2192.test,v 1.3 2008/08/04 03:51:24 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !datetime||!compound {\n  finish_test\n  return\n}\n\ndo_test tkt2192-1.1 {\n  execsql {\n    -- Raw data (RBS) --------\n    \n    create table records (\n      date          real,\n      type          text,\n      description   text,\n      value         integer,\n      acc_name      text,\n      acc_no        text\n    );\n    \n    -- Direct Debits ----------------\n    create view direct_debits as\n      select * from records where type = 'D/D';\n    \n    create view monthly_direct_debits as\n      select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value\n        from direct_debits\n       group by strftime('%Y-%m', date);\n    \n    -- Expense Categories ---------------\n    create view energy as\n      select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value\n        from direct_debits\n       where description like '%NPOWER%'\n       group by strftime('%Y-%m', date);\n    \n    create view phone_internet as\n      select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value\n        from direct_debits\n       where description like '%BT DIRECT%'\n          or description like '%SUPANET%'\n          or description like '%ORANGE%'\n       group by strftime('%Y-%m', date);\n    \n    create view credit_cards as\n      select strftime('%Y-%m', date) as date, (-1 * sum(value)) as value\n        from direct_debits where description like '%VISA%'\n       group by strftime('%Y-%m', date);\n    \n    -- Overview ---------------------\n    \n    create view expense_overview as\n      select 'Energy' as expense, date, value from energy\n      union\n      select 'Phone/Internet' as expense, date, value from phone_internet\n      union\n      select 'Credit Card' as expense, date, value from credit_cards;\n    \n    create view jan as\n      select 'jan', expense, value from expense_overview\n       where date like '%-01';\n    \n    create view nov as\n      select 'nov', expense, value from expense_overview\n       where date like '%-11';\n    \n    create view summary as\n      select * from jan join nov on (jan.expense = nov.expense);\n  }\n} {}\ndo_test tkt2192-1.2 {\n  # set ::sqlite_addop_trace 1\n  execsql {\n    select * from summary;\n  }\n} {}\ndo_test tkt2192-2.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    CREATE VIEW v1 AS\n      SELECT * FROM t1 WHERE b%7=0 UNION SELECT * FROM t1 WHERE b%5=0;\n    INSERT INTO t1 VALUES(1,7);\n    INSERT INTO t1 VALUES(2,10);\n    INSERT INTO t1 VALUES(3,14);\n    INSERT INTO t1 VALUES(4,15);\n    INSERT INTO t1 VALUES(1,16);\n    INSERT INTO t1 VALUES(2,17);\n    INSERT INTO t1 VALUES(3,20);\n    INSERT INTO t1 VALUES(4,21);\n    INSERT INTO t1 VALUES(1,22);\n    INSERT INTO t1 VALUES(2,24);\n    INSERT INTO t1 VALUES(3,25);\n    INSERT INTO t1 VALUES(4,26);\n    INSERT INTO t1 VALUES(1,27);\n \n    SELECT b FROM v1 ORDER BY b;\n  }\n} {7 10 14 15 20 21 25}\ndo_test tkt2192-2.2 {\n  execsql {\n    SELECT * FROM v1 ORDER BY a, b;\n  }\n} {1 7 2 10 3 14 3 20 3 25 4 15 4 21}\ndo_test tkt2192-2.3 {\n  execsql {\n    SELECT x.a || '/' || x.b || '/' || y.b\n      FROM v1 AS x JOIN v1 AS y ON x.a=y.a AND x.b<y.b\n     ORDER BY x.a, x.b, y.b\n  }\n} {3/14/20 3/14/25 3/20/25 4/15/21}\ndo_test tkt2192-2.4 {\n  execsql {\n    CREATE VIEW v2 AS\n    SELECT x.a || '/' || x.b || '/' || y.b AS z\n      FROM v1 AS x JOIN v1 AS y ON x.a=y.a AND x.b<y.b\n     ORDER BY x.a, x.b, y.b;\n    SELECT * FROM v2;\n  }\n} {3/14/20 3/14/25 3/20/25 4/15/21}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2213.test",
    "content": "# 2007 Febuary 05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #2213 has been\n# fixed.  \n#\n#\n# $Id: tkt2213.test,v 1.2 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt2213-1 {\n  sqlite3_create_function db\n  catchsql {\n    SELECT tkt2213func(tkt2213func('abcd'));\n  }\n} {0 abcd}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2251.test",
    "content": "# 2007 Febuary 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that table column values\n# are pulled out of the database correctly.\n#\n# Long ago, the OP_Column opcode was sufficient to pull out the\n# value of a table column.  But then we added the ALTER TABLE ADD COLUMN\n# feature.  An added column might not actually exist in every row,\n# and so the OP_Column opcode has to contain a default value.  Later\n# still we added a feature whereby a REAL value with no fractional\n# part is stored in the database file as an integer to save space.\n# After extracting the value, we have to call OP_RealAffinity to\n# convert it back to a REAL.\n#\n# The sqlite3ExprCodeGetColumn() routine was added to take care of\n# all of the complications above.  The tests in this file attempt\n# to verify that sqlite3ExprCodeGetColumn() is used instead of a\n# raw OP_Column in all places where a table column is extracted from\n# the database.\n#\n# $Id: tkt2251.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !altertable {\n  finish_test\n  return\n}\n\n# Create sample data.  Verify that the default value and type of an added\n# column is correct for aggregates.\ndo_test tkt2251-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(9);\n    INSERT INTO t1 VALUES(9);\n    INSERT INTO t1 VALUES(9);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(2);\n    ALTER TABLE t1 ADD COLUMN b REAL DEFAULT 4.0;\n    SELECT avg(b), typeof(avg(b)) FROM t1;\n  }\n} {4.0 real}\ndo_test tkt2251-1.2 {\n  execsql {\n    SELECT sum(b), typeof(sum(b)) FROM t1;\n  }\n} {32.0 real}\ndo_test tkt2251-1.3 {\n  execsql {\n    SELECT a, sum(b), typeof(sum(b)) FROM t1 GROUP BY a ORDER BY a;\n  }\n} {1 8.0 real 2 8.0 real 3 4.0 real 9 12.0 real}\n\n# Make sure that the REAL value comes out when values are accessed\n# by index.\n#\ndo_test tkt2251-2.1 {\n  execsql {\n    SELECT b, typeof(b) FROM t1 WHERE a=3;\n  }\n} {4.0 real}\ndo_test tkt2251-2.2 {\n  execsql {\n    CREATE INDEX t1i1 ON t1(a,b);\n    SELECT b, typeof(b) FROM t1 WHERE a=3;\n  }\n} {4.0 real}\ndo_test tkt2251-2.3 {\n  execsql {\n    REINDEX;\n    SELECT b, typeof(b) FROM t1 WHERE a=3;\n  }\n} {4.0 real}\n\n# Make sure the correct REAL value is used when copying from one\n# table to another.\n#\ndo_test tkt2251-3.1 {\n  execsql {\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 SELECT * FROM t1;\n    SELECT y, typeof(y) FROM t2 WHERE x=3;\n  }\n} {4.0 real}\ndo_test tkt2251-3.2 {\n  execsql {\n    CREATE TABLE t3 AS SELECT * FROM t1;\n    SELECT b, typeof(b) FROM t3 WHERE a=3;\n  }\n} {4.0 real}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2285.test",
    "content": "# 2005 September 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically.\n# it contains tests to verify that ticket #2285 has been fixed.  \n#\n# $Id: tkt2285.test,v 1.2 2008/07/12 14:52:20 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !tempdb {\n  finish_test\n  return\n}\n\ndo_test tkt2285-1.1 {\n  execsql {\n    PRAGMA locking_mode = EXCLUSIVE;\n  }\n  execsql {\n    BEGIN;\n    CREATE TABLE abc(a, b, c);\n    ROLLBACK;\n  }\n} {}\n\ndo_test tkt2285-1.2 {\n  execsql {\n    SELECT * FROM sqlite_master;\n  }\n} {}\n\nifcapable tempdb {\n  do_test tkt2285-2.1 {\n    execsql {\n      BEGIN;\n      CREATE TEMP TABLE abc(a, b, c);\n      ROLLBACK;\n    }\n  } {}\n  do_test tkt2285-2.2 {\n    execsql {\n      SELECT * FROM sqlite_temp_master;\n    }\n  } {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2332.test",
    "content": "# 2007 May 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt2332.test,v 1.4 2007/09/12 17:01:45 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !incrblob||!tclvar {\n  finish_test\n  return\n}\n\ndo_test tkt2332.1 {\n  execsql {\n    CREATE TABLE blobs (k INTEGER PRIMARY KEY, v BLOB);\n    PRAGMA cache_size = 100;\n  }\n} {}\n\nset ::iKey 1\nforeach Len [list 10000 100000 1000000] {\n  do_test tkt2332.$Len.1 {\n    set val \"[expr rand()][expr rand()][expr rand()][expr rand()][expr rand()]\"\n    set ::blobstr [string range \\\n      [string repeat $val [expr ($Len/[string length $val])+1]] 0 [expr $Len-1]\n    ]\n\n    db eval { INSERT INTO blobs VALUES($::iKey, zeroblob($Len)) }\n  } {}\n\n  do_test tkt2332.$Len.2 {\n    execsql {\n      SELECT length(v) FROM blobs WHERE k = $::iKey;\n    }\n  } $Len\n\n  do_test tkt2332.$Len.3 {\n    set ::fd [db incrblob blobs v $::iKey]\n    puts -nonewline $::fd $::blobstr\n    close $::fd\n  } {}\n\n  do_test tkt2332.$Len.4 {\n    execsql { SELECT length(v) FROM blobs WHERE k = $::iKey; }\n  } $Len\n\n  do_test tkt2332.$Len.5 {\n    lindex [execsql {SELECT v FROM blobs WHERE k = $::iKey}] 0\n  } $::blobstr\n\n  incr ::iKey\n}\n\n# Free memory:\nunset ::blobstr\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2339.test",
    "content": "# 2007 May 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt2339.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery||!compound {\n  finish_test\n  return\n}\n\ndo_test tkt2339.1 {\n  execsql {\n    create table t1(num int);\n    insert into t1 values (1);\n    insert into t1 values (2);\n    insert into t1 values (3);\n    insert into t1 values (4);\n    \n    create table t2(num int);\n    insert into t2 values (11);\n    insert into t2 values (12);\n    insert into t2 values (13);\n    insert into t2 values (14);\n    \n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    UNION\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)\n  }\n} {3 4 13 14}\ndo_test tkt2339.2 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    UNION ALL\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)\n  }\n} {4 3 14 13}\ndo_test tkt2339.3 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC)\n    UNION ALL\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)\n  }\n} {4 3 2 1 14 13}\ndo_test tkt2339.4 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    UNION ALL\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)\n  }\n} {4 3 14 13 12 11}\ndo_test tkt2339.5 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    UNION\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)\n  }\n} {3 4 11 12 13 14}\ndo_test tkt2339.6 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    EXCEPT\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC)\n  }\n} {3 4}\ndo_test tkt2339.7 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 LIMIT 2)\n    UNION\n    SELECT * FROM (SELECT * FROM t2 ORDER BY num DESC LIMIT 2)\n  }\n} {1 2 13 14}\ndo_test tkt2339.8 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 LIMIT 2)\n    UNION\n    SELECT * FROM (SELECT * FROM t2 LIMIT 2)\n  }\n} {1 2 11 12}\ndo_test tkt2339.9 {\n  execsql {\n    SELECT * FROM (SELECT * FROM t1 ORDER BY num DESC LIMIT 2)\n    UNION\n    SELECT * FROM (SELECT * FROM t2 LIMIT 2)\n  }\n} {3 4 11 12}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2391.test",
    "content": "#\n# 2007 May 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# $Id: tkt2391.test,v 1.1 2007/05/29 12:11:30 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt2391.1 {\n  execsql {\n    CREATE TABLE folders(folderid, parentid, foldername COLLATE binary);\n    INSERT INTO folders VALUES(1, 3, 'FolderA');\n    INSERT INTO folders VALUES(1, 3, 'folderB');\n    INSERT INTO folders VALUES(4, 0, 'FolderC');\n  }\n} {}\n\ndo_test tkt2391.2 {\n  execsql {\n    SELECT count(*) FROM folders WHERE foldername < 'FolderC';\n  }\n} {1}\n\ndo_test tkt2391.3 {\n  execsql {\n    SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase;\n  }\n} {2}\n\n# This demonstrates the bug. Creating the index causes SQLite to ignore\n# the \"COLLATE nocase\" clause and use the default collation sequence \n# for column \"foldername\" instead (happens to be BINARY in this case).\n#\ndo_test tkt2391.4 {\n  execsql {\n    CREATE INDEX f_i ON folders(foldername);\n    SELECT count(*) FROM folders WHERE foldername < 'FolderC' COLLATE nocase;\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2409.test",
    "content": "# 2007 June 13\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #2409 has been\n# fixed. More specifically, they verify that if SQLite cannot\n# obtain an EXCLUSIVE lock while trying to spill the cache during\n# any statement other than a COMMIT, an I/O error is returned instead\n# of SQLITE_BUSY.\n#\n# $Id: tkt2409.test,v 1.6 2008/08/28 17:46:19 drh Exp $\n\n# Test Outline:\n#\n#   tkt-2409-1.*: Cause a cache-spill during an INSERT that is within\n#       a db transaction but does not start a statement transaction.\n#       Verify that the transaction is automatically rolled back\n#       and SQLITE_IOERR_BLOCKED is returned\n#\n#       UPDATE: As of the pcache modifications, failing to upgrade to\n#       an exclusive lock when attempting a cache-spill is no longer an\n#       error. The pcache module allocates more space and keeps working\n#       in memory if this occurs.\n#\n#   tkt-2409-2.*: Cause a cache-spill while updating the change-counter\n#       during a database COMMIT. Verify that the transaction is not\n#       rolled back and SQLITE_BUSY is returned.\n#\n#   tkt-2409-3.*: Similar to 2409-1.*, but using many INSERT statements\n#       within a transaction instead of just one.\n#\n#       UPDATE: Again, pcache now just keeps working in main memory.\n#\n#   tkt-2409-4.*: Similar to 2409-1.*, but rig it so that the\n#       INSERT statement starts a statement transaction. Verify that\n#       SQLITE_BUSY is returned and the transaction is not rolled back.\n#\n#       UPDATE: This time, SQLITE_BUSY is not returned. pcache just uses\n#       more malloc()'d memory.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !pager_pragmas {\n  finish_test\n  return\n}\n\nsqlite3_extended_result_codes $::DB 1\n\n# Aquire a read-lock on the database using handle [db2].\n#\nproc read_lock_db {} {\n  if {$::STMT eq \"\"} {\n    set ::STMT [sqlite3_prepare db2 {SELECT rowid FROM sqlite_master} -1 TAIL]\n    set rc [sqlite3_step $::STMT]\n    if {$rc eq \"SQLITE_ERROR\"} {\n      unread_lock_db\n      read_lock_db\n    }\n  }\n}\n\n# Release any read-lock obtained using [read_lock_db]\n#\nproc unread_lock_db {} {\n  if {$::STMT ne \"\"} {\n    sqlite3_finalize $::STMT\n    set ::STMT \"\"\n  }\n}\n\n# Open the db handle used by [read_lock_db].\n#\nsqlite3 db2 test.db\nset ::STMT \"\"\n\ndo_test tkt2409-1.1 {\n  execsql {\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x TEXT UNIQUE NOT NULL, y BLOB);\n  }\n  read_lock_db\n  set ::zShort [string repeat 0123456789 1]\n  set ::zLong  [string repeat 0123456789 1500]\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 VALUES($::zShort, $::zLong);\n  }\n} {0 {}}\n\ndo_test tkt2409-1.2 {\n  sqlite3_errcode $::DB\n} {SQLITE_OK}\n\n# Check the integrity of the cache.\n#\nintegrity_check tkt2409-1.3\n\n# Check that the transaction was rolled back. Because the INSERT\n# statement in which the \"I/O error\" occurred did not open a statement\n# transaction, SQLite had no choice but to roll back the transaction.\n#\ndo_test tkt2409-1.4 {\n  unread_lock_db\n  catchsql { ROLLBACK }\n} {0 {}}\n\nset ::zShort [string repeat 0123456789 1]\nset ::zLong  [string repeat 0123456789 1500]\nset ::rc 1\nfor {set iCache 10} {$::rc} {incr iCache} {\n  execsql \"PRAGMA cache_size = $iCache\"\n  do_test tkt2409-2.1.$iCache {\n    read_lock_db\n    set ::rc [catch {\n      execsql {\n        BEGIN;\n        INSERT INTO t1 VALUES($::zShort, $::zLong);\n      }\n    } msg]\n    expr {($::rc == 1 && $msg eq \"disk I/O error\") || $::rc == 0}\n  } {1}\n}\n\ndo_test tkt2409-2.2 {\n  catchsql {\n    ROLLBACK;\n    BEGIN;\n    INSERT INTO t1 VALUES($::zShort, $::zLong);\n    COMMIT;\n  }\n} {1 {database is locked}}\n\ndo_test tkt2409-2.3 {\n  unread_lock_db\n  catchsql {\n    COMMIT;\n  }\n} {0 {}}\n\n\ndo_test tkt2409-3.1 {\n  db close\n  set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]\n  sqlite3_extended_result_codes $::DB 1\n  execsql {\n    PRAGMA cache_size=10;\n    DELETE FROM t1;\n  }\n  read_lock_db\n  set ::zShort [string repeat 0123456789 1]\n  set ::zLong  [string repeat 0123456789 1500]\n  catchsql {\n    BEGIN;\n    INSERT INTO t1 SELECT $::zShort, $::zLong;\n  }\n} {0 {}}\n\ndo_test tkt2409-3.2 {\n  sqlite3_errcode $::DB\n} {SQLITE_OK}\n\n# Check the integrity of the cache.\n#\nintegrity_check tkt2409-3.3\n\n# Check that the transaction was rolled back. Because the INSERT\n# statement in which the \"I/O error\" occurred did not open a statement\n# transaction, SQLite had no choice but to roll back the transaction.\n#\ndo_test tkt2409-3.4 {\n  unread_lock_db\n  catchsql { ROLLBACK }\n} {0 {}}\nintegrity_check tkt2409-3.5\n\nexpr {srand(1)}\ndo_test tkt2409-4.1 {\n  execsql {\n    PRAGMA cache_size=20;\n    DROP TABLE t1;\n    CREATE TABLE t1 (x TEXT UNIQUE NOT NULL);\n  }\n\n  unset -nocomplain t1\n  array unset t1\n  set t1(0) 1\n  set sql \"\"\n  for {set i 0} {$i<5000} {incr i} {\n    set r 0\n    while {[info exists t1($r)]} {\n      set r [expr {int(rand()*1000000000)}]\n    }\n    set t1($r) 1\n    append sql \"INSERT INTO t1 VALUES('some-text-$r');\"\n  }\n\n  read_lock_db\n  execsql BEGIN\n  catchsql $sql\n} {0 {}}\n\ndo_test tkt2409-4.2 {\n  sqlite3_errcode $::DB\n} {SQLITE_OK}\n\n# Check the integrity of the cache.\n#\nintegrity_check tkt2409-4.3\n\ndo_test tkt2409-4.4 {\n  catchsql { ROLLBACK }\n} {0 {}}\nintegrity_check tkt2409-4.5\n\nunread_lock_db\ndb2 close\nunset -nocomplain t1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2450.test",
    "content": "# 2007 June 24\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2450 has been fixed.\n#\n# $Id: tkt2450.test,v 1.1 2007/06/24 06:32:18 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt2450-1 {\n  execsql {\n    CREATE TABLE \"t a\" (\"\"\"cb\"\"\");\n    INSERT INTO \"t a\" (\"\"\"cb\"\"\") VALUES (1);\n    SELECT \"\"\"cb\"\"\" FROM \"t a\";\n  }\n} {1}\n\ndo_test tkt2450-2 {\n  execsql {\n    SELECT * FROM \"t a\";\n  }\n} {1}\n\ndo_test tkt2450-3 {\n  execsql {\n    SELECT \"t a\".* FROM \"t a\";\n  }\n} {1}\n\ndo_test tkt2450-3 {\n  execsql {\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(2);\n    SELECT * FROM \"t a\", t1;\n  }\n} {1 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2565.test",
    "content": "# 2009 January 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This script attempts to reproduce the circumstances of ticket #2565.\n#\n# More specifically, this script attempts to generate rollback journals\n# that contain headers with nRec==0 that are followed by additional\n# valid headers.\n#\n# $Id: tkt2565.test,v 1.2 2009/04/09 01:23:49 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Use the alternative pcache and rig it to call pagerStress()\n# very frequently.\n#\ndb close\nsqlite3_shutdown\nsqlite3_config_alt_pcache 1 100 0 1\n\n# Open two database connections to database \"test.db\".\n#\nproc reopen_database {} {\n  catch {db close}\n  sqlite3 db test.db\n  db cache size 0\n  execsql {\n    pragma page_size=512;\n    pragma auto_vacuum=2;\n    pragma cache_size=16;\n  }\n}\n\n# Open two database connections and create a single table in the db.\n#\ndo_test tkt2565-1.0 {\n  reopen_database\n  execsql { CREATE TABLE A(Id INTEGER, Name TEXT) }\n} {}\n\nfor {set iFail 1} {$iFail<200} {incr iFail} {\n  reopen_database\n  execsql { pragma locking_mode=exclusive }\n  set nRow [db one {SELECT count(*) FROM a}]\n  \n  # Dirty (at least) one of the pages in the cache.\n  do_test tkt2565-1.$iFail.1 {\n    execsql {\n      BEGIN EXCLUSIVE;\n      INSERT INTO a VALUES(1, 'ABCDEFGHIJKLMNOP');\n    }\n  } {}\n  \n  # Now try to commit the transaction. Cause an IO error to occur\n  # within this operation, which moves the pager into the error state.\n  #\n  set ::sqlite_io_error_persist 1\n  set ::sqlite_io_error_pending $iFail\n  do_test tkt2565-1.$iFail.2 {\n    set rc [catchsql {COMMIT}]\n    list\n  } {}\n  set ::sqlite_io_error_persist 0\n  set ::sqlite_io_error_pending 0\n  if {!$::sqlite_io_error_hit} break\n  set ::sqlite_io_error_hit 0\n}\n\n# Make sure this test script doesn't leave any files open.\n#\ndo_test tkt2565-1.X {\n  catch { db close }\n  set sqlite_open_file_count\n} 0\n\n# Restore the pcache configuration for subsequent tests.\n#\nsqlite3_shutdown\nsqlite3_config_alt_pcache 0\nsqlite3_initialize\nautoinstall_test_functions\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2640.test",
    "content": "# 2007 Sep 12\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2640 has been fixed.\n#\n# $Id: tkt2640.test,v 1.3 2008/08/04 03:51:24 danielk1977 Exp $\n#\n\n# The problem in ticket #2640 was that the query optimizer was \n# not recognizing all uses of tables within subqueries in the\n# WHERE clause.  If the subquery contained a compound SELECT,\n# then tables that were used by terms of the compound other than\n# the last term would not be recognized as dependencies.\n# So if one of the SELECT statements within a compound made\n# use of a table that occurs later in a join, the query\n# optimizer would not recognize this and would try to evaluate\n# the subquery too early, before that tables value had been\n# established.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery||!compound {\n  finish_test\n  return\n}\n\ndo_test tkt2640-1.1 {\n  execsql {\n    CREATE TABLE persons(person_id, name);\n    INSERT INTO persons VALUES(1,'fred');\n    INSERT INTO persons VALUES(2,'barney');\n    INSERT INTO persons VALUES(3,'wilma');\n    INSERT INTO persons VALUES(4,'pebbles');\n    INSERT INTO persons VALUES(5,'bambam');\n    CREATE TABLE directors(person_id);\n    INSERT INTO directors VALUES(5);\n    INSERT INTO directors VALUES(3);\n    CREATE TABLE writers(person_id);\n    INSERT INTO writers VALUES(2);\n    INSERT INTO writers VALUES(3);\n    INSERT INTO writers VALUES(4);\n    SELECT DISTINCT p.name\n      FROM persons p, directors d\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\ndo_test tkt2640-1.2 {\n  execsql {\n    SELECT DISTINCT p.name\n      FROM persons p CROSS JOIN directors d\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\ndo_test tkt2640-1.3 {\n  execsql {\n    SELECT DISTINCT p.name\n      FROM directors d CROSS JOIN persons p\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=p.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\ndo_test tkt2640-1.4 {\n  execsql {\n    SELECT DISTINCT p.name\n      FROM persons p, directors d\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\ndo_test tkt2640-1.5 {\n  execsql {\n    SELECT DISTINCT p.name\n      FROM persons p CROSS JOIN directors d\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\ndo_test tkt2640-1.6 {\n  execsql {\n    SELECT DISTINCT p.name\n      FROM directors d CROSS JOIN persons p\n     WHERE d.person_id=p.person_id\n       AND NOT EXISTS (\n             SELECT person_id FROM directors d1 WHERE d1.person_id=d.person_id\n             EXCEPT\n             SELECT person_id FROM writers w\n           );\n  }\n} {wilma}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2643.test",
    "content": "# 2007 Sep 12\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2643 has been fixed.\n#\n# $Id: tkt2643.test,v 1.1 2007/09/13 17:54:41 drh Exp $\n#\n\n# The problem in ticket #2643 has to do with the query optimizer\n# making bad assumptions about index cost when data from ANALYZE\n# is available.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt2643-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(2,3,4);\n    ANALYZE;\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    CREATE INDEX i1 ON t1(c);\n    SELECT count(*) FROM t1 WHERE c IS NOT NULL\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2686.test",
    "content": "# 2007 Oct 3\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2686 has been fixed.\n#\n# $Id: tkt2686.test,v 1.3 2008/02/02 02:48:52 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndb eval {\n  PRAGMA page_size=1024;\n  PRAGMA max_page_count=50;\n  PRAGMA auto_vacuum=0;\n  CREATE TABLE filler (fill);\n}\nfor {set i 1} {$i<2000} {incr i} {\n  do_test tkt2686-$i.1 {\n    db eval BEGIN\n    set rc [catch {\n      while 1 {\n        db eval {INSERT INTO filler (fill) VALUES (randstr(1000, 10000)) }\n      }\n    } msg]\n    lappend rc $msg\n  } {1 {database or disk is full}}\n  do_test tkt2686-$i.2 {\n    execsql {\n      DELETE FROM filler \n       WHERE rowid <= (SELECT MAX(rowid) FROM filler LIMIT 20)\n    }\n  } {}\n  integrity_check tkt2686-$i.3\n  catch {db eval COMMIT}\n}\n\ndb close\nforcedelete test.db test.db-journal\nsqlite3 db test.db\n\ndb eval {\n  PRAGMA page_size=1024;\n  PRAGMA max_page_count=50;\n  PRAGMA auto_vacuum=1;\n  CREATE TABLE filler (fill);\n}\nfor {set i 10000} {$i<12000} {incr i} {\n  do_test tkt2686-$i.1 {\n    db eval BEGIN\n    set rc [catch {\n      while 1 {\n        db eval {INSERT INTO filler (fill) VALUES (randstr(1000, 10000)) }\n      }\n    } msg]\n    lappend rc $msg\n  } {1 {database or disk is full}}\n  do_test tkt2686-$i.2 {\n    execsql {\n      DELETE FROM filler \n       WHERE rowid <= (SELECT MAX(rowid) FROM filler LIMIT 20)\n    }\n  } {}\n  integrity_check tkt2686-$i.3\n  catch {db eval COMMIT}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2767.test",
    "content": "# 2007 Oct 3\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2767 has been fixed.\n# Ticket #2767 is for a VDBE stack overflow on BEFORE\n# triggers that run RAISE(IGNORE).\n#\n# $Id: tkt2767.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !trigger { finish_test ; return }\n\ndo_test tkt2767-1.1 {\n  execsql {\n    -- Construct a table with many rows of data\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 SELECT x+2 FROM t1;\n    INSERT INTO t1 SELECT x+4 FROM t1;\n    INSERT INTO t1 SELECT x+8 FROM t1;\n    INSERT INTO t1 SELECT x+16 FROM t1;\n\n    -- BEFORE triggers that invoke raise(ignore).  The effect of\n    -- these triggers should be to make INSERTs, UPDATEs, and DELETEs\n    -- into no-ops.\n    CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN\n      SELECT raise(ignore);\n    END;\n    CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN\n      SELECT raise(ignore);\n    END;\n    CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN\n      SELECT raise(ignore);\n    END;\n\n    -- Verify the table content\n    SELECT count(*), sum(x) FROM t1;\n  }\n} {32 528}\n\n# Try to delete all elements of the table.  This will invoke the\n# DELETE trigger 32 times, which should overflow the VDBE stack if\n# the problem of #2767 is not fixed.  If the problem is fixed, all\n# the deletes should be no-ops so the table should remain unchanged.\n#\ndo_test tkt2767-1.2 {\n  execsql {\n    DELETE FROM t1 WHERE x>0;\n    SELECT count(*), sum(x) FROM t1;\n  }\n} {32 528}\n\n# Try to update all elements of the table.  This will invoke the\n# UPDATE trigger 32 times, which should overflow the VDBE stack if\n# the problem of #2767 is not fixed.  If the problem is fixed, all\n# the updates should be no-ops so the table should remain unchanged.\n#\ndo_test tkt2767-1.3 {\n  execsql {\n    UPDATE t1 SET x=x+1;\n    SELECT count(*), sum(x) FROM t1;\n  }\n} {32 528}\n\n# Invoke the insert trigger.  The insert trigger was working\n# even prior to the fix of #2767.  But it seems good to go ahead\n# and verify that it works.\n#\ndo_test tkt2767-1.4 {\n  execsql {\n    INSERT INTO t1 SELECT x+32 FROM t1;\n    SELECT count(*), sum(x) FROM t1;\n  }\n} {32 528}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2817.test",
    "content": "# 2007 December 02 \n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# Specifically, it tests that bug 2817 is fixed.\n#\n# $Id: tkt2817.test,v 1.2 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt2817-1.0 {\n  execsql {\n    CREATE TEMP TABLE tbl(a, b, c);\n    -- INSERT INTO tbl VALUES(1, 'abc', 'def');\n    -- INSERT INTO tbl VALUES(2, 'ghi', 'jkl');\n  }\n} {}\ndo_test tkt2817-1.1 {\n  execsql {\n    CREATE TABLE main.tbl(a, b, c); \n    CREATE INDEX main.tbli ON tbl(a, b, c);\n    INSERT INTO main.tbl SELECT a, b, c FROM temp.tbl;\n  }\n} {}\n\n# When bug #2817 existed, this test was failing.\n#\nintegrity_check tkt2817-1.2\n\n# So was this one.\n#\ndb close\nsqlite3 db test.db\nintegrity_check tkt2817-1.3\n\n\n# These tests - tkt2817-2.* - are the same as the previous block, except\n# for the fact that the temp-table and the main table do not share the\n# same name. #2817 did not cause a problem with these tests.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_test tkt2817-2.0 {\n  execsql {\n    CREATE TEMP TABLE tmp(a, b, c);\n    INSERT INTO tmp VALUES(1, 'abc', 'def');\n    INSERT INTO tmp VALUES(2, 'ghi', 'jkl');\n  }\n} {}\ndo_test tkt2817-2.1 {\n  execsql {\n    CREATE TABLE main.tbl(a, b, c); \n    CREATE INDEX main.tbli ON tbl(a, b, c);\n    INSERT INTO main.tbl SELECT a, b, c FROM temp.tmp;\n  }\n} {}\nintegrity_check tkt2817-2.2\ndb close\nsqlite3 db test.db\nintegrity_check tkt2817-2.3\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2820.test",
    "content": "# 2007 Dec 4\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2820 has been fixed.\n# Ticket #2820 observes that a DROP TABLE statement that\n# occurs while a query is in process will fail with a\n# \"database is locked\" error, but the entry in the sqlite_master\n# table will still be removed.  This is incorrect.  The\n# entry in the sqlite_master table should persist when \n# the DROP fails due to an error.\n#\n# $Id: tkt2820.test,v 1.1 2007/12/04 16:54:53 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc test_schema_change {testid init ddl res} {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  execsql $init\n  do_test tkt2820-$testid.1 {\n    set STMT [sqlite3_prepare db {SELECT * FROM sqlite_master} -1 DUMMY]\n    sqlite3_step $STMT\n  } {SQLITE_ROW}\n#if {$testid==3} {execsql {PRAGMA vdbe_trace=ON}}\n  do_test tkt2820-$testid.2 \"catchsql [list $ddl]\" \\\n       {1 {database table is locked}}\n  do_test tkt2820-$testid.3 {\n    sqlite3_finalize $STMT\n    execsql {SELECT name FROM sqlite_master ORDER BY 1}\n  } $res\n  integrity_check tkt2820-$testid.4\n  db close\n  sqlite3 db test.db\n  integrity_check tkt2820-$testid.5\n}\n\ntest_schema_change 1 {\n  CREATE TABLE t1(a);\n} {\n  DROP TABLE t1\n} {t1}\ntest_schema_change 2 {\n  CREATE TABLE t1(a);\n  CREATE TABLE t2(b);\n} {\n  DROP TABLE t2\n} {t1 t2}\ntest_schema_change 3 {\n  CREATE TABLE t1(a);\n  CREATE INDEX i1 ON t1(a);\n} {\n  DROP INDEX i1\n} {i1 t1}\n\n# We further observe that prior to the fix associated with ticket #2820,\n# no statement journal would be created on an SQL statement that was run\n# while a second statement was active, as long as we are in autocommit\n# mode.  This is incorrect.\n#\ndo_test tkt2820-4.1 {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n  }\n\n  # The INSERT statement within the loop should fail on a\n  # constraint violation on the second inserted row.  This\n  # should cause the entire INSERT to rollback using a statement\n  # journal.\n  #\n  db eval {SELECT name FROM sqlite_master} {\n    catch {db eval {\n      INSERT INTO t1 SELECT a+1 FROM t1 ORDER BY a DESC\n    }}\n  }\n  db eval {SELECT a FROM t1 ORDER BY a}\n} {1 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2822.test",
    "content": "# 2007 Dec 4\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that the issues surrounding expressions in\n# ORDER BY clauses on compound SELECT statements raised by ticket\n# #2822 have been dealt with.\n#\n# $Id: tkt2822.test,v 1.6 2008/08/20 16:35:10 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\n# The ORDER BY matching algorithm is three steps:\n# \n#   (1)  If the ORDER BY term is an integer constant i, then\n#        sort by the i-th column of the result set.\n# \n#   (2)  If the ORDER BY term is an identifier (not x.y or x.y.z\n#        but simply x) then look for a column alias with the same\n#        name.  If found, then sort by that column.\n# \n#   (3)  Evaluate the term as an expression and sort by the\n#        value of the expression.\n# \n# For a compound SELECT the rules are modified slightly.\n# In the third rule, the expression must exactly match one\n# of the result columns.  The sequences of three rules is\n# attempted first on the left-most SELECT.  If that doesn't\n# work, we move to the right, one by one.\n#\n# Rule (3) is not in standard SQL - it is an SQLite extension,\n# though one copied from PostgreSQL.  The rule for compound\n# queries where a search is made of SELECTs to the right\n# if the left-most SELECT does not match is not a part of\n# standard SQL either.  This extension is unique to SQLite\n# as far as we know.\n#\n# Rule (2) was added by the changes ticket #2822.  Prior to\n# that changes, SQLite did not support rule (2), making it\n# technically in violation of standard SQL semantics.  \n# No body noticed because rule (3) has the same effect as\n# rule (2) except in some obscure cases.\n#\n\n\n# Test plan:\n#\n#   tkt2822-1.* - Simple identifier as ORDER BY expression.\n#   tkt2822-2.* - More complex ORDER BY expressions.\n\ndo_test tkt2822-0.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(a, b, c);\n\n    INSERT INTO t1 VALUES(1, 3, 9);\n    INSERT INTO t1 VALUES(3, 9, 27);\n    INSERT INTO t1 VALUES(5, 15, 45);\n\n    INSERT INTO t2 VALUES(2, 6, 18);\n    INSERT INTO t2 VALUES(4, 12, 36);\n    INSERT INTO t2 VALUES(6, 18, 54);\n  }\n} {}\n\n# Test the \"ORDER BY <integer>\" syntax.\n#\ndo_test tkt2822-1.1 {\n  execsql {\n    SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY 1;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\ndo_test tkt2822-1.2 {\n  execsql {\n    SELECT a, CAST (b AS TEXT), c FROM t1 \n      UNION ALL \n    SELECT a, b, c FROM t2 \n      ORDER BY 2;\n  }\n} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}\n\n# Test the \"ORDER BY <identifier>\" syntax.\n#\ndo_test tkt2822-2.1 {\n  execsql {\n    SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY a;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\n\ndo_test tkt2822-2.2 {\n  execsql {\n    SELECT a, CAST (b AS TEXT) AS x, c FROM t1 \n      UNION ALL \n    SELECT a, b, c FROM t2 \n      ORDER BY x;\n  }\n} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}\ndo_test tkt2822-2.3 {\n  execsql {\n    SELECT t1.a, b, c FROM t1 UNION ALL SELECT t2.a, b, c FROM t2 ORDER BY a;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\n\n# Test the \"ORDER BY <expression>\" syntax.\n#\ndo_test tkt2822-3.1 {\n  execsql {\n    SELECT a, CAST (b AS TEXT) AS x, c FROM t1 \n      UNION ALL \n    SELECT a, b, c FROM t2 \n      ORDER BY CAST (b AS TEXT);\n  }\n} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}\ndo_test tkt2822-3.2 {\n  execsql {\n    SELECT t1.a, b, c FROM t1 UNION ALL SELECT t2.a, b, c FROM t2 ORDER BY t1.a;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\n\n# Test that if a match cannot be found in the leftmost SELECT, an\n# attempt is made to find a match in subsequent SELECT statements.\n#\ndo_test tkt2822-3.3 {\n  execsql {\n    SELECT a, b, c FROM t1 UNION ALL SELECT a AS x, b, c FROM t2 ORDER BY x;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\ndo_test tkt2822-3.4 {\n  # But the leftmost SELECT takes precedence.\n  execsql {\n    SELECT a AS b, CAST (b AS TEXT) AS a, c FROM t1 \n      UNION ALL \n    SELECT a, b, c FROM t2 \n      ORDER BY a;\n  }\n} {2 6 18 4 12 36 6 18 54 5 15 45 1 3 9 3 9 27}\ndo_test tkt2822-3.5 {\n  execsql {\n    SELECT a, b, c FROM t2 \n      UNION ALL \n    SELECT a AS b, CAST (b AS TEXT) AS a, c FROM t1 \n      ORDER BY a;\n  }\n} {1 3 9 2 6 18 3 9 27 4 12 36 5 15 45 6 18 54}\n\n# Test some error conditions (ORDER BY clauses that match no column).\n#\ndo_test tkt2822-4.1 {\n  catchsql {\n    SELECT a, b, c FROM t1 UNION ALL SELECT a, b, c FROM t2 ORDER BY x\n  }\n} {1 {1st ORDER BY term does not match any column in the result set}}\ndo_test tkt2822-4.2 {\n  catchsql {\n    SELECT a, CAST (b AS TEXT) AS x, c FROM t1 \n      UNION ALL \n    SELECT a, b, c FROM t2 \n      ORDER BY CAST (b AS INTEGER);\n  }\n} {1 {1st ORDER BY term does not match any column in the result set}}\n\n# Tests for rule (2).\n#\n# The \"ORDER BY b\" should match the column alias (rule 2), not the\n# the t3.b value (rule 3).  \n#\ndo_test tkt2822-5.1 {\n  execsql {\n    CREATE TABLE t3(a,b);\n    INSERT INTO t3 VALUES(1,8);\n    INSERT INTO t3 VALUES(9,2);\n\n    SELECT a AS b FROM t3 ORDER BY b;\n  }\n} {1 9}\ndo_test tkt2822-5.2 {\n  # Case does not matter.  b should match B\n  execsql {\n    SELECT a AS b FROM t3 ORDER BY B;\n  }\n} {1 9}\ndo_test tkt2822-5.3 {\n  # Quoting should not matter\n  execsql {\n    SELECT a AS 'b' FROM t3 ORDER BY \"B\";\n  }\n} {1 9}\ndo_test tkt2822-5.4 {\n  # Quoting should not matter\n  execsql {\n    SELECT a AS \"b\" FROM t3 ORDER BY [B];\n  }\n} {1 9}\n\n# In \"ORDER BY +b\" the term is now an expression rather than\n# a label.  It therefore matches by rule (3) instead of rule (2).\n# \ndo_test tkt2822-5.5 {\n  execsql {\n    SELECT a AS b FROM t3 ORDER BY +b;\n  }\n} {9 1}\n\n# Tests for rule 2 in compound queries\n#\ndo_test tkt2822-6.1 {\n  execsql {\n    CREATE TABLE t6a(p,q);\n    INSERT INTO t6a VALUES(1,8);\n    INSERT INTO t6a VALUES(9,2);\n    CREATE TABLE t6b(x,y);\n    INSERT INTO t6b VALUES(1,7);\n    INSERT INTO t6b VALUES(7,2);\n\n    SELECT p, q FROM t6a UNION ALL SELECT x, y FROM t6b ORDER BY 1, 2\n  }\n} {1 7 1 8 7 2 9 2}\ndo_test tkt2822-6.2 {\n  execsql {\n    SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b\n    ORDER BY PX, YX\n  }\n} {1 7 1 8 7 2 9 2}\ndo_test tkt2822-6.3 {\n  execsql {\n    SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b\n    ORDER BY XX, QX\n  }\n} {1 7 1 8 7 2 9 2}\ndo_test tkt2822-6.4 {\n  execsql {\n    SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b\n    ORDER BY QX, XX\n  }\n} {7 2 9 2 1 7 1 8}\ndo_test tkt2822-6.5 {\n  execsql {\n    SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b\n    ORDER BY t6b.x, QX\n  }\n} {1 7 1 8 7 2 9 2}\ndo_test tkt2822-6.6 {\n  execsql {\n    SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b\n    ORDER BY t6a.q, XX\n  }\n} {7 2 9 2 1 7 1 8}\n\n# More error message tests.  This is really more of a test of the\n# %r ordinal value formatting capablity added to sqlite3_snprintf()\n# by ticket #2822.\n#\ndo_test tkt2822-7.1 {\n  execsql {\n    CREATE TABLE t7(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,\n                    a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25);\n  }\n  catchsql {\n    SELECT * FROM t7 ORDER BY 0;\n  }\n} {1 {1st ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.2.1 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 0;\n  }\n} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.2.2 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 26;\n  }\n} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.2.3 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 65536;\n  }\n} {1 {2nd ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.3 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 0;\n  }\n} {1 {3rd ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.4 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 0;\n  }\n} {1 {4th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.9 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 0;\n  }\n} {1 {9th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.10 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 0;\n  }\n} {1 {10th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.11 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0;\n  }\n} {1 {11th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.12 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 0;\n  }\n} {1 {12th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.13 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 0;\n  }\n} {1 {13th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.20 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\n                             11,12,13,14,15,16,17,18,19, 0\n  }\n} {1 {20th ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.21 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\n                             11,12,13,14,15,16,17,18,19, 20, 0\n  }\n} {1 {21st ORDER BY term out of range - should be between 1 and 25}}\ndo_test tkt2822-7.22 {\n  catchsql {\n    SELECT * FROM t7 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\n                             11,12,13,14,15,16,17,18,19, 20, 21, 0\n  }\n} {1 {22nd ORDER BY term out of range - should be between 1 and 25}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2832.test",
    "content": "# 2007 Dec 12\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2832 has been fixed.\n#\n# $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !trigger { finish_test ; return }\n\ndo_test tkt2832-1.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(3);\n  }\n} {}\ndo_test tkt2832-1.2 {\n  execsql {\n    UPDATE OR REPLACE t1 SET a = 1;\n    SELECT * FROM t1;\n  }\n} {1}\n\ndo_test tkt2832-2.1 {\n  execsql {\n    CREATE TABLE t2(a, b);\n    CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN\n      DELETE FROM t2 WHERE a = new.a + 1;\n    END;\n    INSERT INTO t2 VALUES(1, 2);\n    INSERT INTO t2 VALUES(2, 3);\n  }\n} {}\ndo_test tkt2832-2.2 {\n  execsql { \n    UPDATE t2 SET b = 5 \n  }\n} {}\n\ndo_test tkt2832-3.1 {\n  execsql {\n    CREATE TABLE t3(a, b);\n    CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN\n      DELETE FROM t3 WHERE a = old.a + 1;\n    END;\n    INSERT INTO t3 VALUES(1, 2);\n    INSERT INTO t3 VALUES(2, 3);\n  }\n} {}\ndo_test tkt2832-3.2 {\n  execsql { DELETE FROM t3 WHERE 1 }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2854.test",
    "content": "# 2007 December 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt2854.test,v 1.4 2009/03/16 13:19:36 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndb close\n\nifcapable !shared_cache {\n  finish_test\n  return\n}\n\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\n# Open 3 database connections. Connection \"db\" and \"db2\" share a cache.\n# Connection \"db3\" has its own cache.\n#\ndo_test tkt2854-1.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n\n  # This is taken from shared.test.  The Windows VFS expands \n  # ./test.db (and test.db) to be the same thing so the path\n  # matches and they share a cache.  By changing the case \n  # for Windows platform, we get around this and get a separate\n  # connection.\n  if {$::tcl_platform(platform)==\"unix\"} {\n    sqlite3 db3 ./test.db\n  } else {\n    sqlite3 db3 TEST.DB\n  }\n\n  db eval {\n    CREATE TABLE abc(a, b, c);\n  }\n} {}\n\n# Check that an exclusive lock cannot be obtained if some other \n# shared-cache connection has a read-lock on a table.\n#\ndo_test tkt2854-1.2 {\n  execsql { \n    BEGIN;\n    SELECT * FROM abc;\n  } db2\n} {}\ndo_test tkt2854-1.3 {\n  catchsql { BEGIN EXCLUSIVE } db\n} {1 {database table is locked}}\ndo_test tkt2854-1.4 {\n  execsql { SELECT * FROM abc } db3\n} {}\ndo_test tkt2854-1.5 {\n  catchsql { INSERT INTO abc VALUES(1, 2, 3) } db3\n} {1 {database is locked}}\ndo_test tkt2854-1.6 {\n  execsql { COMMIT } db2\n} {}\n\n# Check that an exclusive lock prevents other shared-cache users from\n# starting a transaction.\n#\ndo_test tkt2854-1.7 {\n  set ::DB2 [sqlite3_connection_pointer db2]\n  set ::STMT1 [sqlite3_prepare $DB2 \"SELECT * FROM abc\" -1 TAIL]\n  set ::STMT2 [sqlite3_prepare $DB2 \"BEGIN EXCLUSIVE\" -1 TAIL]\n  set ::STMT3 [sqlite3_prepare $DB2 \"BEGIN IMMEDIATE\" -1 TAIL]\n  set ::STMT4 [sqlite3_prepare $DB2 \"BEGIN\" -1 TAIL]\n  set ::STMT5 [sqlite3_prepare $DB2 \"COMMIT\" -1 TAIL]\n  execsql { BEGIN EXCLUSIVE } db\n} {}\ndo_test tkt2854-1.8 {\n  catchsql { BEGIN EXCLUSIVE } db2\n} {1 {database schema is locked: main}}\ndo_test tkt2854-1.9 {\n  catchsql { BEGIN IMMEDIATE } db2\n} {1 {database schema is locked: main}}\ndo_test tkt2854-1.10 {\n  # This fails because the schema of main cannot be verified.\n  catchsql { BEGIN } db2\n} {1 {database schema is locked: main}}\n\n# Check that an exclusive lock prevents other shared-cache users from\n# reading the database. Use stored statements so that the error occurs\n# at the b-tree level, not the schema level.\n#\ndo_test tkt2854-1.11 {\n  list [sqlite3_step $::STMT1] [sqlite3_finalize $::STMT1]\n} {SQLITE_ERROR SQLITE_LOCKED}\ndo_test tkt2854-1.12 {\n  list [sqlite3_step $::STMT2] [sqlite3_finalize $::STMT2]\n} {SQLITE_ERROR SQLITE_LOCKED}\ndo_test tkt2854-1.13 {\n  list [sqlite3_step $::STMT3] [sqlite3_finalize $::STMT3]\n} {SQLITE_ERROR SQLITE_LOCKED}\ndo_test tkt2854-1.14 {\n  # A regular \"BEGIN\" doesn't touch any databases. So it succeeds.\n  list [sqlite3_step $::STMT4] [sqlite3_finalize $::STMT4]\n} {SQLITE_DONE SQLITE_OK}\ndo_test tkt2854-1.15 {\n  # As does a COMMIT.\n  list [sqlite3_step $::STMT5] [sqlite3_finalize $::STMT5]\n} {SQLITE_DONE SQLITE_OK}\n\n# Try to read the database using connection \"db3\" (which does not share\n# a cache with \"db\"). The database should be locked.\ndo_test tkt2854-1.16 {\n  catchsql { SELECT * FROM abc } db3\n} {1 {database is locked}}\ndo_test tkt2854-1.17 {\n  execsql { COMMIT } db\n} {}\ndo_test tkt2854-1.18 {\n  execsql { SELECT * FROM abc } db2\n} {}\n\n# Check that if an attempt to obtain an exclusive lock fails because an\n# attached db cannot be locked, the internal exclusive flag used by\n# shared-cache users is correctly cleared.\ndo_test tkt2854-1.19 {\n  forcedelete test2.db test2.db-journal\n  sqlite3 db4 test2.db\n  execsql { CREATE TABLE def(d, e, f) } db4\n  execsql { ATTACH 'test2.db' AS aux } db\n} {}\ndo_test tkt2854-1.20 {\n  execsql {BEGIN IMMEDIATE} db4\n  catchsql {BEGIN EXCLUSIVE} db\n} {1 {database table is locked}}\ndo_test tkt2854-1.21 {\n  execsql {SELECT * FROM abc} db2\n} {}\n\ndb close\ndb2 close\ndb3 close\ndb4 close\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2920.test",
    "content": "# 2008 Feb 1\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2920 is fixed.\n#\n# $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create a database file that is full.\n#\ndo_test tkt2920-1.1 {\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA max_page_count=40;\n    PRAGMA auto_vacuum=0;\n    CREATE TABLE filler (fill);\n  }\n  file size test.db\n} {2048}\ndo_test tkt2920-1.2 {\n  db eval BEGIN\n  for {set i 0} {$i<34} {incr i} {\n    db eval {INSERT INTO filler VALUES(randomblob(1024))}\n  }\n  db eval COMMIT\n}  {}\n\n# Try to add a single new page to the full database.  We get\n# a disk full error.  But this does not corrupt the database.\n#\ndo_test tkt2920-1.3 {\n  db eval BEGIN\n  catchsql {\n     INSERT INTO filler VALUES(randomblob(1024))\n  }\n} {1 {database or disk is full}}\nintegrity_check tkt2920-1.4\n\n# Increase the maximum size of the database file by 1 page,\n# but then try to add a two-page record.  This also fails.\n#\ndo_test tkt2920-1.5 {\n  db eval {PRAGMA max_page_count=41}\n  catchsql {\n     INSERT INTO filler VALUES(randomblob(2048))\n  }\n} {1 {database or disk is full}}\nintegrity_check tkt2920-1.6\n\n# Increase the maximum size of the database by one more page.\n# This time the insert works.\n#\ndo_test tkt2920-1.7 {\n  db eval {PRAGMA max_page_count=42}\n  catchsql {\n     INSERT INTO filler VALUES(randomblob(2048))\n  }\n} {0 {}}\nintegrity_check tkt2920-1.8\n\n# The previous errors cancelled the transaction.\n#\ndo_test tkt2920-1.9 {\n  catchsql {COMMIT}\n} {1 {cannot commit - no transaction is active}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2927.test",
    "content": "# 2008 Feb 6\n#\n# The author disclaims copyright to this source code. In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file is to test that ticket #2927 is fixed.\n#\n# $Id: tkt2927.test,v 1.4 2008/08/04 03:51:24 danielk1977 Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\n# Create a database.\n#\ndo_test tkt2927-1.1 {\n  db eval {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1,11);\n    INSERT INTO t1 VALUES(2,22);\n    INSERT INTO t1 VALUES(3,33);\n    INSERT INTO t1 VALUES(4,44);\n    INSERT INTO t1 VALUES(5,55);\n    SELECT * FROM t1;\n  }\n} {1 11 2 22 3 33 4 44 5 55}\n\n\ndo_test tkt2927-2.1 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION ALL\n    SELECT a, b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.2 {\n#set sqlite_addop_trace 1\n  db eval {\n    SELECT a, b FROM t1\n    UNION ALL\n    SELECT a, abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.3 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION ALL\n    SELECT abs(a), b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.4 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION ALL\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.5 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION ALL\n    SELECT a, b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.6 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION ALL\n    SELECT a, abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.7 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION ALL\n    SELECT abs(a), b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.8 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION ALL\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.9 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION ALL\n    SELECT a, b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.10 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION ALL\n    SELECT a, abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.11 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION ALL\n    SELECT abs(a), b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.12 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION ALL\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.13 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a, b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.14 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a, abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.15 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT abs(a), b FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-2.16 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {1 11 2 22 3 33 4 44 5 55 1 11 2 22 3 33 4 44 5 55}\n\n\ndo_test tkt2927-3.1 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION \n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.2 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION \n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.3 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION \n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.4 {\n  db eval {\n    SELECT a, b FROM t1\n    UNION \n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.5 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION \n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.6 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION \n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.7 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION \n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.8 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    UNION \n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.9 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION \n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.10 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION \n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.11 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION \n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.12 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    UNION \n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.13 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION \n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.14 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION \n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.15 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION \n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-3.16 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    UNION \n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\n\n\ndo_test tkt2927-4.1 {\n  db eval {\n    SELECT a+b, a-b, a, b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.2 {\n  db eval {\n    SELECT a+b, a-b, a, b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.3 {\n  db eval {\n    SELECT a+b, a-b, a, b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.4 {\n  db eval {\n    SELECT a+b, a-b, a, b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.5 {\n  db eval {\n    SELECT a+b, a-b, a, abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.6 {\n  db eval {\n    SELECT a+b, a-b, a, abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.7 {\n  db eval {\n    SELECT a+b, a-b, a, abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.8 {\n  db eval {\n    SELECT a+b, a-b, a, abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.9 {\n  db eval {\n    SELECT a+b, a-b, abs(a), b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.10 {\n  db eval {\n    SELECT a+b, a-b, abs(a), b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.11 {\n  db eval {\n    SELECT a+b, a-b, abs(a), b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.12 {\n  db eval {\n    SELECT a+b, a-b, abs(a), b FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.13 {\n  db eval {\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.14 {\n  db eval {\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, a, abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.15 {\n  db eval {\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), b FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\ndo_test tkt2927-4.16 {\n  db eval {\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n    UNION ALL\n    SELECT a+b, a-b, abs(a), abs(b) FROM t1\n  }\n} {12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55 12 -10 1 11 24 -20 2 22 36 -30 3 33 48 -40 4 44 60 -50 5 55}\n\n\ndo_test tkt2927-5.1 {\n  db eval {\n    SELECT a, b FROM t1\n    EXCEPT\n    SELECT a, b FROM t1\n  }\n} {}\ndo_test tkt2927-5.2 {\n  db eval {\n    SELECT a, b FROM t1\n    EXCEPT\n    SELECT a, abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.3 {\n  db eval {\n    SELECT a, b FROM t1\n    EXCEPT\n    SELECT abs(a), b FROM t1\n  }\n} {}\ndo_test tkt2927-5.4 {\n  db eval {\n    SELECT a, b FROM t1\n    EXCEPT\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.5 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    EXCEPT\n    SELECT a, b FROM t1\n  }\n} {}\ndo_test tkt2927-5.6 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    EXCEPT\n    SELECT a, abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.7 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    EXCEPT\n    SELECT abs(a), b FROM t1\n  }\n} {}\ndo_test tkt2927-5.8 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    EXCEPT\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.9 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    EXCEPT\n    SELECT a, b FROM t1\n  }\n} {}\ndo_test tkt2927-5.10 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    EXCEPT\n    SELECT a, abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.11 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    EXCEPT\n    SELECT abs(a), b FROM t1\n  }\n} {}\ndo_test tkt2927-5.12 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    EXCEPT\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.13 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    EXCEPT\n    SELECT a, b FROM t1\n  }\n} {}\ndo_test tkt2927-5.14 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    EXCEPT\n    SELECT a, abs(b) FROM t1\n  }\n} {}\ndo_test tkt2927-5.15 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    EXCEPT\n    SELECT abs(a), b FROM t1\n  }\n} {}\ndo_test tkt2927-5.16 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    EXCEPT\n    SELECT abs(a), abs(b) FROM t1\n  }\n} {}\n\n\ndo_test tkt2927-6.1 {\n  db eval {\n    SELECT a, b FROM t1\n    INTERSECT\n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.2 {\n  db eval {\n    SELECT a, b FROM t1\n    INTERSECT\n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.3 {\n  db eval {\n    SELECT a, b FROM t1\n    INTERSECT\n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.4 {\n  db eval {\n    SELECT a, b FROM t1\n    INTERSECT\n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.5 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    INTERSECT\n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.6 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    INTERSECT\n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.7 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    INTERSECT\n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.8 {\n  db eval {\n    SELECT a, abs(b) FROM t1\n    INTERSECT\n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.9 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    INTERSECT\n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.10 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    INTERSECT\n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.11 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    INTERSECT\n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.12 {\n  db eval {\n    SELECT abs(a), b FROM t1\n    INTERSECT\n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.13 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    INTERSECT\n    SELECT a, b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.14 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    INTERSECT\n    SELECT a, abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.15 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    INTERSECT\n    SELECT abs(a), b FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\ndo_test tkt2927-6.16 {\n  db eval {\n    SELECT abs(a), abs(b) FROM t1\n    INTERSECT\n    SELECT abs(a), abs(b) FROM t1\n    ORDER BY 1\n  }\n} {1 11 2 22 3 33 4 44 5 55}\n\n# Ticket #3092 is the same bug.  But another test case never hurts.\n#\ndo_test tkt2927-7.1 {\n  db eval {\n    CREATE TABLE host (\n     hostname text not null primary key,\n     consoleHost text,\n     consolePort text\n    );\n    INSERT INTO \"host\" VALUES('aald04','aalp03','4');\n    INSERT INTO \"host\" VALUES('aald17','aalp01','1');\n    CREATE VIEW consolemap1a as\n      select hostname, consolehost, '/dev/cuaD0.' || (consoleport-1) consoleport\n        from host where consolehost='aalp01';\n    CREATE VIEW consolemap1b as\n      select hostname hostname, consolehost consolehost, '/dev/cuaD' ||\n             substr('01',1+((consoleport-1)/16),1) ||\n             substr('0123456789abcdef',1+((consoleport-1)%16),1) consoleport\n        from host where consolehost='aalp03';\n    CREATE VIEW consolemap1 as\n      select * from consolemap1a\n      union\n      select * from consolemap1b;\n    SELECT * from consolemap1b;\n  }\n} {aald04 aalp03 /dev/cuaD03}\ndo_test tkt2927-7.2 {\n  db eval {\n    SELECT * FROM consolemap1\n  }\n} {aald04 aalp03 /dev/cuaD03 aald17 aalp01 /dev/cuaD0.0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt2942.test",
    "content": "# 2008 February 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #2942.  \n#\n# Queries of the form:\n#\n#     SELECT group_concat(x) FROM (SELECT * FROM table ORDER BY 1);\n#\n# The ORDER BY would be dropped by the query flattener.  This used\n# to not matter because aggregate functions sum(), min(), max(), avg(),\n# and so forth give the same result regardless of the order of inputs.\n# But with the addition of the group_concat() function, suddenly the\n# order does matter.\n#\n# $Id: tkt2942.test,v 1.1 2008/02/15 14:33:04 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test tkt2942.1 {\n  execsql {\n    create table t1(num int);\n    insert into t1 values (2);\n    insert into t1 values (1);\n    insert into t1 values (3);\n    insert into t1 values (4);\n    SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num DESC);\n  }\n} {4,3,2,1}\ndo_test tkt2942.2 {\n  execsql {\n    SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num);\n  }\n} {1,2,3,4}\ndo_test tkt2942.3 {\n  execsql {\n    SELECT group_concat(num) FROM (SELECT num FROM t1);\n  }\n} {2,1,3,4}\ndo_test tkt2942.4 {\n  execsql {\n    SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY rowid DESC);\n  }\n} {4,3,1,2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3080.test",
    "content": "# 2008 April 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3080\n#\n# Make sure that application-defined functions are able to recursively\n# invoke SQL statements that create and drop virtual tables.\n#\n# $Id: tkt3080.test,v 1.2 2008/11/05 16:37:35 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3080.1 {\n  db function execsql execsql\n  db eval {\n    SELECT execsql('CREATE TABLE t1(x)');\n  }\n  execsql {SELECT name FROM sqlite_master}\n} {t1}\ndo_test tkt3080.2 {\n  db eval {\n    INSERT INTO t1 VALUES('CREATE TABLE t2(y);');\n    SELECT execsql(x) FROM t1;\n  }\n  db eval {\n    SELECT name FROM sqlite_master;\n  }\n} {t1 t2}\ndo_test tkt3080.3 {\n  execsql {\n    INSERT INTO t1 VALUES('CREATE TABLE t3(z); DROP TABLE t3;');\n  }\n  catchsql {\n    SELECT execsql(x) FROM t1 WHERE rowid=2;\n  }\n} {1 {database table is locked}}\ndo_test tkt3080.4 {\n  db eval {\n    SELECT name FROM sqlite_master;\n  }\n} {t1 t2 t3}\n\nifcapable vtab {\n  register_echo_module [sqlite3_connection_pointer db]\n  do_test tkt3080.10 {\n     set sql {\n       CREATE VIRTUAL TABLE t4 USING echo(t2);\n       INSERT INTO t4 VALUES(123);\n       DROP TABLE t4;\n     }\n     execsql {\n       DELETE FROM t1;\n       INSERT INTO t1 VALUES($sql);\n     }\n     db eval {\n       SELECT execsql(x) FROM t1\n     }\n     execsql {SELECT name FROM sqlite_master}\n  } {t1 t2 t3}\n  do_test tkt3080.11 {\n     execsql {SELECT * FROM t2}\n  } {123}\n}\n  \n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3093.test",
    "content": "# 2008 May 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3093\n#\n# Verify that a busy callback waiting on a reserved lock resolves\n# once the lock clears.\n#\n# $Id: tkt3093.test,v 1.2 2008/05/02 14:23:55 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Set up a test database\n#\ndo_test tkt3093.1 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    SELECT * FROM t1\n  }\n} {1}\n\n# Establish a separate, independent connection to that database.\n#\ndo_test tkt3093.2 {\n  catch {sqlite3_enable_shared_cache 0}\n  sqlite3 db2 test.db\n  db2 eval {\n    SELECT * FROM t1\n  }\n} {1}\n\n# Make sure that clearing a lock allows a pending request for\n# a reserved lock to continue.\n#\ndo_test tkt3093.3 {\n  # This will be the busy callback for connection db2.  On the first\n  # busy callback, commit the transaction in db.  This should clear\n  # the lock so that there should not be a second callback.  If the\n  # busy handler is called a second time, then fail so that we get\n  # timeout.\n  proc busy_callback {cnt} {\n    if {$cnt==0} {\n      db eval COMMIT\n      return 0\n    } else {\n      return 1\n    }\n  }\n  db2 busy ::busy_callback\n\n  # Start a write transaction on db.\n  db eval {\n     BEGIN;\n     INSERT INTO t1 VALUES(2);\n  }\n\n  # Attempt to modify the database on db2\n  catchsql {\n     UPDATE t1 SET x=x+1;\n  } db2\n} {0 {}}\n\n# Verify that everything worked as expected.  The db transaction should\n# have gone first and added entry 2.  Then the db2 transaction would have\n# run and added one to each entry.\n#\ndo_test tkt3093.4 {\n  db eval {SELECT * FROM t1}\n} {2 3}\ndo_test tkt3093.5 {\n  db2 eval {SELECT * FROM t1}\n} {2 3}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3121.test",
    "content": "# 2008 May 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt3121.test,v 1.2 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# Register the module\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test vtabD-1.1 {\n  execsql {\n    PRAGMA encoding = 'utf16';\n\n    CREATE TABLE r1(field);\n    CREATE TABLE r2(col PRIMARY KEY, descr);\n\n    INSERT INTO r1 VALUES('abcd');\n    INSERT INTO r2 VALUES('abcd', 'A nice description');\n    INSERT INTO r2 VALUES('efgh', 'Another description');\n\n    CREATE VIRTUAL TABLE t1 USING echo(r1);\n    CREATE VIRTUAL TABLE t2 USING echo(r2);\n  }\n} {}\n\ndo_test vtabD-1.2 {\n  execsql {\n    select\n      t1.field as Field,\n      t2.descr as Descr\n    from t1 inner join t2 on t1.field = t2.col order by t1.field\n  }\n} {abcd {A nice description}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3201.test",
    "content": "# 2008 July 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n# Specifically, it tests that bug #3201 has been fixed.\n#\n# $Id: tkt3201.test,v 1.3 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3201-1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n  }\n} {}\n\ndo_test tkt3201-2 {\n  execsql {\n    SELECT l.a, r.a FROM t1 AS l, t1 AS r WHERE l.a < r.a;\n  }\n} {1 2}\n\ndo_test tkt3201-3 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t2 VALUES(2, 'two');\n  }\n  execsql {\n    SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;\n  }\n} {1 2}\n\ndo_test tkt3201-4 {\n  execsql {\n    DELETE FROM t1 WHERE a = 2;\n  }\n  execsql {\n    SELECT l.a, r.a FROM t1 AS l, t2 AS r WHERE l.a < r.a;\n  }\n} {1 2}\n\ndo_test tkt3201-5 {\n  execsql {\n    DELETE FROM t1 WHERE a = 2;\n  }\n  execsql {\n    SELECT t1.a, t1.b, t2.a, t2.b FROM t1, t2;\n  }\n} {1 one 2 two}\n\ndo_test tkt3201-6 {\n  execsql {\n    CREATE TABLE t3(c INTEGER PRIMARY KEY, d TEXT);\n    INSERT INTO t3 VALUES(2, 'two');\n  }\n  execsql { SELECT a, b, c, d FROM t1, t3 }\n} {1 one 2 two}\n\ndo_test tkt3201-7 {\n  execsql { SELECT a, b, c, d FROM t1, t3 WHERE a < c }\n} {1 one 2 two}\n\n# Ticket [efc02f977919]\n#\nifcapable trigger {\n  do_test tkt3201-4.0 {\n    db eval {\n     CREATE TABLE t4(x);\n     CREATE TABLE t4_log(x);\n     CREATE TRIGGER r4_1 AFTER INSERT ON t4 WHEN new.x=1 BEGIN\n       INSERT INTO t4_log(x) VALUES(new.x);\n     END;\n     CREATE TRIGGER r4_2 AFTER INSERT ON t4 WHEN new.x=2 BEGIN\n       INSERT INTO t4_log(x) VALUES(new.x);\n     END;\n     CREATE TRIGGER r4_3 AFTER INSERT ON t4 WHEN new.x=3 BEGIN\n       INSERT INTO t4_log(x) VALUES(new.x);\n     END;\n     CREATE TRIGGER r4_4 AFTER INSERT ON t4 WHEN new.x=4 BEGIN\n       INSERT INTO t4_log(x) VALUES(new.x);\n     END;\n     INSERT INTO t4 VALUES(1);\n     INSERT INTO t4 VALUES(2);\n     INSERT INTO t4 VALUES(3);\n     INSERT INTO t4 VALUES(4);\n     SELECT * FROM t4_log;\n    }\n  } {1 2 3 4}\n}\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3292.test",
    "content": "# 2008 August 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n# Specifically, it tests the behavior of the sqlite3VdbeRecordCompare()\n# routine in cases where the rowid is 0 or 1 in file format 4\n# (meaning that the rowid has type code 8 or 9 with zero bytes of\n# data).  Ticket #3292.\n#\n# $Id: tkt3292.test,v 1.1 2008/08/13 14:07:41 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3292-1.1 {\n  execsql {\n    PRAGMA legacy_file_format=OFF;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);\n    INSERT INTO t1 VALUES(0, 1);\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 1);\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b>=1;\n  }\n} {0 1 1 1 2 1}\ndo_test tkt3292-1.2 {\n  execsql {\n    INSERT INTO t1 VALUES(3, 0);\n    INSERT INTO t1 VALUES(4, 2);\n    SELECT * FROM t1 WHERE b>=1;\n  }\n} {0 1 1 1 2 1 4 2}\n\n\ndo_test tkt3292-2.1 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c, d);\n    INSERT INTO t2 VALUES(0, 1, 'hello', x'012345');\n    INSERT INTO t2 VALUES(1, 1, 'hello', x'012345');\n    INSERT INTO t2 VALUES(2, 1, 'hello', x'012345');\n    CREATE INDEX i2 ON t2(b,c,d);\n    SELECT a FROM t2 WHERE b=1 AND c='hello' AND d>=x'012345';\n  }\n} {0 1 2}\ndo_test tkt3292-2.2 {\n  execsql {\n    INSERT INTO t2 VALUES(3, 1, 'hello', x'012344');\n    INSERT INTO t2 VALUES(4, 1, 'hello', x'012346');\n    SELECT a FROM t2 WHERE b=1 AND c='hello' AND d>=x'012345';\n  }\n} {0 1 2 4}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3298.test",
    "content": "# 2008 August 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file tests changes to the name resolution logic that occurred\n# in august of 2008 and where associated with tickets #3298 and #3301\n#\n# $Id: tkt3298.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !trigger { finish_test ; return }\n\ndo_test tkt3298-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);\n    INSERT INTO t1 VALUES(0, 1);\n    INSERT INTO t1 VALUES(1, 1);\n    INSERT INTO t1 VALUES(2, 1);\n    CREATE VIEW v1 AS SELECT a AS x, b+1 AS y FROM t1;\n    CREATE TRIGGER r1 INSTEAD OF UPDATE ON v1\n      BEGIN\n        UPDATE t1 SET b=new.y-1 WHERE a=new.x;\n      END;\n    CREATE TRIGGER r2 INSTEAD OF DELETE ON v1\n      BEGIN\n        DELETE FROM t1 WHERE a=old.x;\n      END;\n    SELECT * FROM v1 ORDER BY x;\n  }\n} {0 2 1 2 2 2}\ndo_test tkt3298-1.2 {\n  execsql {\n    UPDATE v1 SET y=3 WHERE x=0;\n    SELECT * FROM v1 ORDER by x;\n  }\n} {0 3 1 2 2 2}\ndo_test tkt3298-1.3 {\n  execsql {\n    UPDATE v1 SET y=4 WHERE v1.x=2;\n    SELECT * FROM v1 ORDER by x;\n  }\n} {0 3 1 2 2 4}\ndo_test tkt3298-1.4 {\n  execsql {\n    DELETE FROM v1 WHERE x=1;\n    SELECT * FROM v1 ORDER BY x;\n  }\n} {0 3 2 4}\ndo_test tkt3298-1.5 {\n  execsql {\n    DELETE FROM v1 WHERE v1.x=2;\n    SELECT * FROM v1 ORDER BY x;\n  }\n} {0 3}\n\n# Ticket #3301\n#\ndo_test tkt3298-2.1 {\n  execsql {\n    CREATE TABLE t2(p,q);\n    INSERT INTO t2 VALUES(1,11);\n    INSERT INTO t2 VALUES(2,22);\n    CREATE TABLE t3(x,y);\n    INSERT INTO t3 VALUES(1,'one');\n\n    SELECT *, (SELECT z FROM (SELECT y AS z FROM t3 WHERE x=t1.a+1) ) FROM t1;\n  }\n} {0 2 one}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3334.test",
    "content": "# 2008 August 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library. \n# Specifically, it tests that bug #3334 has been fixed by the\n# addition of restriction (19) to the subquery flattener optimization.\n#\n# $Id: tkt3334.test,v 1.1 2008/08/26 12:56:14 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3334-1.0 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,934);\n    INSERT INTO t1 VALUES(2,221);\n    INSERT INTO t1 VALUES(1,372);\n    INSERT INTO t1 VALUES(3,552);\n    INSERT INTO t1 VALUES(1,719);\n    INSERT INTO t1 VALUES(4,102);\n    SELECT * FROM t1 ORDER BY b;\n  }\n} {4 102 2 221 1 372 3 552 1 719 1 934}\n\ndo_test tkt3334-1.1 {\n  execsql {\n    SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;\n  }\n} {}\ndo_test tkt3334-1.2 {\n  execsql {\n    SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 2) WHERE a=1;\n  }\n} {0}\ndo_test tkt3334-1.3 {\n  execsql {\n    SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;\n  }\n} {1}\ndo_test tkt3334-1.4 {\n  execsql {\n    SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 3) WHERE a=1;\n  }\n} {1}\ndo_test tkt3334-1.5 {\n  execsql {\n    SELECT a FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;\n  }\n} {1 1 1}\ndo_test tkt3334-1.6 {\n  execsql {\n    SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b LIMIT 99) WHERE a=1;\n  }\n} {3}\ndo_test tkt3334-1.7 {\n  execsql {\n    SELECT a FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;\n  }\n} {1 1 1}\ndo_test tkt3334-1.8 {\n  execsql {\n    SELECT count(*) FROM (SELECT a FROM t1 ORDER BY b) WHERE a=1;\n  }\n} {3}\ndo_test tkt3334-1.9 {\n  execsql {\n    SELECT a FROM (SELECT a FROM t1) WHERE a=1;\n  }\n} {1 1 1}\ndo_test tkt3334-1.10 {\n  execsql {\n    SELECT count(*) FROM (SELECT a FROM t1) WHERE a=1;\n  }\n} {3}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3346.test",
    "content": "# 2008 September 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the fix for ticket #3346\n#\n# $Id: tkt3346.test,v 1.3 2008/12/09 13:12:57 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3346-1.1 {\n  db eval {\n   CREATE TABLE t1(a,b);\n   INSERT INTO t1 VALUES(2,'bob');\n   INSERT INTO t1 VALUES(1,'alice');\n   INSERT INTO t1 VALUES(3,'claire');\n   SELECT *, ( SELECT y FROM (SELECT x.b='alice' AS y) )\n     FROM ( SELECT * FROM t1 ) AS x;\n  }\n} {2 bob 0 1 alice 1 3 claire 0}\ndo_test tkt3346-1.2 {\n  db eval {\n    SELECT b FROM (SELECT * FROM t1) AS x\n     WHERE (SELECT y FROM (SELECT x.b='alice' AS y))=0\n  }\n} {bob claire}\ndo_test tkt3346-1.3 {\n  db eval {\n    SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x\n     WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=(x.a||x.b)\n  }\n} {alice bob claire}\ndo_test tkt3346-1.4 {\n  db eval {\n    SELECT b FROM (SELECT * FROM t1 ORDER BY a) AS x\n     WHERE (SELECT y FROM (SELECT a||b y FROM t1 WHERE t1.b=x.b))=('2'||x.b)\n  }\n} {bob}\n\n# Ticket #3530\n#\n# As shown by ticket #3346 above (see also ticket #3298) it is important\n# that a subquery in the result-set be able to look up through multiple\n# FROM levels in order to view tables in the FROM clause at the top level.\n#\n# But ticket #3530 shows us that a subquery in the FROM clause should not\n# be able to look up to higher levels:\n#\ndo_test tkt3346-2.1 {\n  catchsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n    \n    SELECT * FROM (SELECT * FROM t1 WHERE 1=x.a) AS x;\n  }\n} {1 {no such column: x.a}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3357.test",
    "content": "# 2008 September 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the fix for ticket #3357.\n#\n# $Id: tkt3357.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3357-1.1 {\n  execsql {\n    create table a(id integer primary key, b_id integer, myvalue varchar);\n    create table b(id integer primary key, bvalue varchar);\n    insert into a(b_id, myvalue) values(1,'Test');\n    insert into a(b_id, myvalue) values(1,'Test2');\n    insert into a(b_id, myvalue) values(1,'Test3');\n    insert into b(bvalue) values('btest');\n  }\n} {}\n\ndo_test tkt3357-1.2 {\n  execsql {\n    SELECT cc.id, cc.b_id, cc.myvalue, dd.bvalue \n    FROM (\n      SELECT DISTINCT a.id, a.b_id, a.myvalue FROM a\n      INNER JOIN b ON a.b_id = b.id WHERE b.bvalue = 'btest'\n    ) cc\n    LEFT OUTER JOIN b dd ON cc.b_id = dd.id\n  }\n} {1 1 Test btest 2 1 Test2 btest 3 1 Test3 btest}\n\ndo_test tkt3357-1.3 {\n  execsql {\n    SELECT cc.id, cc.b_id, cc.myvalue\n    FROM (\n      SELECT a.id, a.b_id, a.myvalue \n      FROM a, b WHERE a.b_id = b.id\n    ) cc\n    LEFT OUTER JOIN b dd ON cc.b_id = dd.id\n  }\n} {1 1 Test 2 1 Test2 3 1 Test3}\n\ndo_test tkt3357-1.4 {\n  execsql {\n    SELECT cc.id, cc.b_id, cc.myvalue\n    FROM (\n      SELECT DISTINCT a.id, a.b_id, a.myvalue \n      FROM a, b WHERE a.b_id = b.id\n    ) cc\n    LEFT OUTER JOIN b dd ON cc.b_id = dd.id\n  }\n} {1 1 Test 2 1 Test2 3 1 Test3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3419.test",
    "content": "# 2008 October 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the fix for ticket #3419.\n# Ticket #3419 is really a duplication of #3408 and had already\n# been fixed by the time it was reported.  But it never hurts to\n# add new test cases.\n#\n# $Id: tkt3419.test,v 1.1 2008/10/06 15:31:13 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3419-1.1 {\n  execsql {\n    create table a(id integer primary key);\n    create table b(id integer primary key, a_id integer);\n    create table c(id integer primary key, b_id integer);\n  \n    insert into a values (1);\n    insert into a values (2);\n  \n    insert into b values (3, 1);\n    insert into b values (4, 1);\n    insert into b values (5, 1);\n    insert into b values (6, 1);\n    insert into b values (9, 2);\n  \n    insert into c values (4, 3);\n    insert into c values (5, 5);\n    insert into c values (6, 4);\n    insert into c values (7, 6);\n    insert into c values (8, 9);\n  \n    select * FROM a, b, c WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {2 9 2 8 9}\ndo_test tkt3419-1.2 {\n  execsql {\n    select * FROM a, c, b WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {2 8 9 9 2}\ndo_test tkt3419-1.3 {\n  execsql {\n    select * FROM b, a, c WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {9 2 2 8 9}\ndo_test tkt3419-1.4 {\n  execsql {\n    select * FROM b, c, a WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {9 2 8 9 2}\ndo_test tkt3419-1.5 {\n  execsql {\n    select * FROM c, a, b WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {8 9 2 9 2}\ndo_test tkt3419-1.6 {\n  execsql {\n    select * FROM c, b, a WHERE a.id=2 AND b.a_id = a.id AND b.id=c.b_id;\n  }\n} {8 9 9 2 2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3424.test",
    "content": "# 2008 October 06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n#\n# $Id: tkt3424.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3424-1.1 {\n  execsql {\n    CREATE TABLE names(id INTEGER, data TEXT, code TEXT);\n    INSERT INTO names VALUES(1,'E1','AAA');\n    INSERT INTO names VALUES(2,NULL,'BBB');\n\n    CREATE TABLE orig(code TEXT, data TEXT);\n    INSERT INTO orig VALUES('AAA','E1');\n    INSERT INTO orig VALUES('AAA','E2');\n    INSERT INTO orig VALUES('AAA','E3');\n    INSERT INTO orig VALUES('AAA','E4');\n    INSERT INTO orig VALUES('AAA','E5');\n  }\n} {}\n\ndo_test tkt3424-1.2 {\n  execsql {\n    SELECT * FROM \n    names LEFT OUTER JOIN orig\n    ON names.data = orig.data AND names.code = orig.code;\n  }\n} {1 E1 AAA AAA E1 2 {} BBB {} {}}\n\ndo_test tkt3424-1.3 {\n  execsql { CREATE INDEX udx_orig_code_data ON orig(code, data) }\n} {}\n\ndo_test tkt3424-1.4 {\n  execsql {\n    SELECT * FROM \n    names LEFT OUTER JOIN orig\n    ON names.data = orig.data AND names.code = orig.code;\n  }\n} {1 E1 AAA AAA E1 2 {} BBB {} {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3442.test",
    "content": "# 2008 October 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3442 has been\n# fixed.  \n#\n#\n# $Id: tkt3442.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# Create a schema with some indexes.\n#\ndo_test tkt3442-1.1 {\n  execsql {\n     CREATE TABLE listhash(\n       key INTEGER PRIMARY KEY,\n       id TEXT,\n       node INTEGER\n     );\n     CREATE UNIQUE INDEX ididx ON listhash(id);\n  }\n} {}\n\n\n# Explain Query Plan\n#\nproc EQP {sql} {\n  uplevel \"execsql {EXPLAIN QUERY PLAN $sql}\"\n}\n\n\n# These tests perform an EXPLAIN QUERY PLAN on both versions of the \n# SELECT referenced in ticket #3442 (both '5000' and \"5000\") \n# and verify that the query plan is the same.\n#\nifcapable explain {\n  do_test tkt3442-1.2 {\n    EQP { SELECT node FROM listhash WHERE id='5000' LIMIT 1; }\n  } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}\n  do_test tkt3442-1.3 {\n    EQP { SELECT node FROM listhash WHERE id=\"5000\" LIMIT 1; }\n  } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}\n}\n\n\n# Some extra tests testing other permutations of 5000.\n#\nifcapable explain {\n  do_test tkt3442-1.4 {\n    EQP { SELECT node FROM listhash WHERE id=5000 LIMIT 1; }\n  } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}\n}\ndo_test tkt3442-1.5 {\n  catchsql {\n    SELECT node FROM listhash WHERE id=[5000] LIMIT 1;\n  }\n} {1 {no such column: 5000}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3457.test",
    "content": "# 2008 October 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# $Id: tkt3457.test,v 1.3 2009/06/26 07:12:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {$tcl_platform(platform) != \"unix\"} {\n  finish_test\n  return\n}\n\n#-----------------------------------------------------------------------\n# To roll back a hot-journal file, the application needs read and write \n# permission on the journal file in question. The following tests test\n# the outcome of trying to rollback a hot-journal file when this is not\n# the case.\n# \n#   tkt3457-1.2: Application has neither read, nor write permission on\n#                the hot-journal file. Result: SQLITE_CANTOPEN.\n#                \n#   tkt3457-1.3: Application has write but not read permission on\n#                the hot-journal file. Result: SQLITE_CANTOPEN.\n#\n#   tkt3457-1.4: Application has read but not write permission on\n#                the hot-journal file. Result: SQLITE_CANTOPEN.\n#\n#   tkt3457-1.5: Application has read/write permission on the hot-journal \n#                file. Result: SQLITE_OK.\n# \ndo_test tkt3457-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    BEGIN;\n    INSERT INTO t1 VALUES(4, 5, 6);\n  }\n\n  forcecopy test.db bak.db\n  forcecopy test.db-journal bak.db-journal\n\n  # Fix the first journal-header in the journal-file. Because the\n  # journal file has not yet been synced, the 8-byte magic string at the\n  # start of the first journal-header has not been written by SQLite.\n  # So write it now.\n  set fd [open bak.db-journal a+]\n  fconfigure $fd -encoding binary -translation binary\n  seek $fd 0\n  puts -nonewline $fd \"\\xd9\\xd5\\x05\\xf9\\x20\\xa1\\x63\\xd7\"\n  close $fd\n\n  execsql COMMIT\n} {}\n\n# Disable fchmod to make sure SQLite itself does not try to change the\n# permission bits on us\n#\ncatch {\n  test_syscall install fchmod\n  test_syscall fault 1 1\n}\n\ndo_test tkt3457-1.2 {\n  forcecopy bak.db-journal test.db-journal\n  file attributes test.db-journal -permissions ---------\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ndo_test tkt3457-1.3 {\n  forcecopy bak.db-journal test.db-journal\n  file attributes test.db-journal -permissions -w--w--w-\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ndo_test tkt3457-1.4 {\n  forcecopy bak.db-journal test.db-journal\n  file attributes test.db-journal -permissions r--r--r--\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\n\ndo_test tkt3457-1.5 {\n  forcecopy bak.db-journal test.db-journal\n  file attributes test.db-journal -permissions rw-rw-rw-\n  catchsql { SELECT * FROM t1 }\n} {0 {1 2 3 4 5 6}}\n\n# Reenable fchmod\ncatch {\n  test_syscall uninstall\n  test_syscall fault 0 0\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3461.test",
    "content": "# 2008 October 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3461 has been\n# fixed.  \n#\n# $Id: tkt3461.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n####################################\n####################################\n# REMOVE THESE TWO LINES:\n####################################\n####################################\n#finish_test\n#return\n\ndo_test tkt3461-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} {}\n\ndo_test tkt3461-1.2 {\n  execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 }\n} {1 3}\n\ndo_test tkt3461-1.3 {\n  # explain { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }\n  # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }\n  execsql { SELECT a, b+1 AS b_plus_one FROM t1 WHERE a=1 OR b_plus_one }\n} {1 3}\n\ndo_test tkt3461-2.1 {\n  execsql { \n    SELECT a, b+1 AS b_plus_one \n    FROM t1 \n    WHERE CASE WHEN a=1 THEN 1 ELSE b_plus_one END \n  }\n} {1 3}\n\ndo_test tkt3461-3.1 {\n  execsql {\n    CREATE TABLE t2(c, d);\n    INSERT INTO t2 VALUES(3, 4);\n  }\n  # execsql { PRAGMA vdbe_trace = 1; PRAGMA vdbe_listing=1 }\n  execsql { \n    SELECT a, b+1 AS b_plus_one, c, d \n    FROM t1 LEFT JOIN t2 \n    ON (a=c AND d=b_plus_one)\n  }\n} {1 3 {} {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3493.test",
    "content": "# 2008 October 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that affinities and collation sequences are correctly applied\n# in aggregate queries.\n#\n# $Id: tkt3493.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3493-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE A (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);\n    INSERT INTO A VALUES(1,'123');\n    INSERT INTO A VALUES(2,'456');\n    CREATE TABLE B (id INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT);\n    INSERT INTO B VALUES(1,1);\n    INSERT INTO B VALUES(2,2);\n    CREATE TABLE A_B (B_id INTEGER NOT NULL, A_id INTEGER);\n    INSERT INTO A_B VALUES(1,1);\n    INSERT INTO A_B VALUES(2,2);\n    COMMIT;\n  }\n} {}\ndo_test tkt3493-1.2 {\n  execsql {\n    SELECT \n      CASE \n         WHEN B.val = 1 THEN 'XYZ' \n         ELSE A.val \n      END AS Col1\n    FROM B  \n    LEFT OUTER JOIN A_B ON B.id = A_B.B_id  \n    LEFT OUTER JOIN A ON A.id = A_B.A_id\n    ORDER BY Col1 ASC;\n  }\n} {456 XYZ}\ndo_test tkt3493-1.3 {\n  execsql {\n    SELECT DISTINCT\n      CASE \n         WHEN B.val = 1 THEN 'XYZ' \n         ELSE A.val \n      END AS Col1\n    FROM B  \n    LEFT OUTER JOIN A_B ON B.id = A_B.B_id  \n    LEFT OUTER JOIN A ON A.id = A_B.A_id\n    ORDER BY Col1 ASC;\n  }\n} {456 XYZ}\ndo_test tkt3493-1.4 {\n  execsql {\n    SELECT b.val, CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1 FROM b;\n  }\n} {1 xyz 2 2}\ndo_test tkt3493-1.5 {\n  execsql {\n    SELECT DISTINCT \n      b.val, \n      CASE WHEN b.val = 1 THEN 'xyz' ELSE b.val END AS col1 \n    FROM b;\n  }\n} {1 xyz 2 2}\ndo_test tkt3493-1.6 {\n  execsql {\n    SELECT DISTINCT \n      b.val, \n      CASE WHEN b.val = '1' THEN 'xyz' ELSE b.val END AS col1 \n    FROM b;\n  }\n} {1 xyz 2 2}\n\n\ndo_test tkt3493-2.1 {\n  execsql {\n    CREATE TABLE t1(a TEXT, b INT);\n    INSERT INTO t1 VALUES(123, 456);\n  }\n} {}\ndo_test tkt3493-2.2.1 {\n  execsql { SELECT a=123 FROM t1 GROUP BY a }\n} {1}\ndo_test tkt3493-2.2.2 {\n  execsql { SELECT a=123 FROM t1 }\n} {1}\ndo_test tkt3493-2.2.3 {\n  execsql { SELECT a='123' FROM t1 }\n} {1}\ndo_test tkt3493-2.2.4 {\n  execsql { SELECT count(*), a=123 FROM t1 }\n} {1 1}\ndo_test tkt3493-2.2.5 {\n  execsql { SELECT count(*), +a=123 FROM t1 }\n} {1 0}\ndo_test tkt3493-2.3.3 {\n  execsql { SELECT b='456' FROM t1 GROUP BY a }\n} {1}\ndo_test tkt3493-2.3.1 {\n  execsql { SELECT b='456' FROM t1 GROUP BY b }\n} {1}\ndo_test tkt3493-2.3.2 {\n  execsql { SELECT b='456' FROM t1 }\n} {1}\ndo_test tkt3493-2.4.1 {\n  execsql { SELECT typeof(a), a FROM t1 GROUP BY a HAVING a=123 }\n} {text 123}\ndo_test tkt3493-2.4.2 {\n  execsql { SELECT typeof(a), a FROM t1 GROUP BY b HAVING a=123 }\n} {text 123}\ndo_test tkt3493-2.5.1 {\n  execsql { SELECT typeof(b), b FROM t1 GROUP BY a HAVING b='456' }\n} {integer 456}\ndo_test tkt3493-2.5.2 {\n  execsql { SELECT typeof(b), b FROM t1 GROUP BY b HAVING b='456' }\n} {integer 456}\n\ndo_test tkt3493-3.1 {\n  execsql {\n    CREATE TABLE t2(a COLLATE NOCASE, b COLLATE BINARY);\n    INSERT INTO t2 VALUES('aBc', 'DeF');\n  }\n} {}\ndo_test tkt3493-3.2.1 {\n  execsql { SELECT a='abc' FROM t2 GROUP BY a }\n} {1}\ndo_test tkt3493-3.2.2 {\n  execsql { SELECT a='abc' FROM t2 }\n} {1}\n\ndo_test tkt3493-3.3.1 {\n  execsql { SELECT a>b FROM t2 GROUP BY a, b}\n} {0}\ndo_test tkt3493-3.3.2 {\n  execsql { SELECT a>b COLLATE BINARY FROM t2 GROUP BY a, b}\n} {1}\ndo_test tkt3493-3.3.3 {\n  execsql { SELECT b>a FROM t2 GROUP BY a, b}\n} {0}\ndo_test tkt3493-3.3.4 {\n  execsql { SELECT b>a COLLATE NOCASE FROM t2 GROUP BY a, b}\n} {1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3508.test",
    "content": "# 2008 November 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n#\n# $Id: tkt3508.test,v 1.5 2009/05/28 01:00:56 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3508-1.1 {\n  catchsql {\n    CREATE TABLE modificationsTmp (\n      SUBSTRATE_HPRD_ID VARCHAR(80),\n      SUBSTRATE_GENE_SYMBOL VARCHAR(80),\n      SUBSTRATE_ISOFORM_ID VARCHAR(80),\n      SUBSTRATE_REFSEQ_ID VARCHAR(80),\n      SITE INTEGER,\n      RESIDUE VARCHAR(80),\n      ENZYME_NAME VARCHAR(80),\n      ENZYME_HPRD_ID VARCHAR(80),\n      MODIFICATION_TYPE VARCHAR(80),\n      EXPERIMENT_TYPE VARCHAR(80),\n      REFERENCE_ID VARCHAR(80)\n    );\n    select SUBSTRATE_HPRD_ID, count(substrate_refseq_id) as c\n      from modificationsTmp where c > 1 group by SUBSTRATE_HPRD_ID;\n  }\n} {1 {misuse of aggregate: count()}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3522.test",
    "content": "# 2008 December 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is a verification that the bugs identified in ticket\n# #3522 have been fixed.\n#\n# $Id: tkt3522.test,v 1.1 2008/12/05 00:00:07 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3522-1.1 {\n  db eval {\n    CREATE TABLE tab4(\n       col0 INTEGER,\n       col1 INTEGER,\n       col2 INTEGER,\n       col3 INTEGER,\n       col4 INTEGER\n    );\n    SELECT cor1.*\n      FROM tab4 AS cor0\n      JOIN tab4 AS cor1 USING ( col4, col3, col2, col1, col0 );\n  }\n} {}\ndo_test tkt3522-1.2 {\n  db eval {\n    CREATE TABLE tab1(col0 INTEGER);\n    CREATE TABLE tab2(col0 INTEGER);\n    SELECT cor0.* FROM tab1 NATURAL JOIN tab2 AS cor0;\n  }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3527.test",
    "content": "# 2008 December 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is a verification that the bugs identified in ticket\n# #3527 have been fixed.\n#\n# $Id: tkt3527.test,v 1.1 2008/12/08 13:42:36 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt3527-1.1 {\n  db eval {\n    CREATE TABLE Element (\n     Code INTEGER PRIMARY KEY,\n     Name VARCHAR(60)\n    );\n    \n    CREATE TABLE ElemOr (\n     CodeOr INTEGER NOT NULL,\n     Code INTEGER NOT NULL,\n     PRIMARY KEY(CodeOr,Code)\n    );\n    \n    CREATE TABLE ElemAnd (\n     CodeAnd INTEGER,\n     Code INTEGER,\n     Attr1 INTEGER,\n     Attr2 INTEGER,\n     Attr3 INTEGER,\n     PRIMARY KEY(CodeAnd,Code)\n    );\n    \n    INSERT INTO Element VALUES(1,'Elem1');\n    INSERT INTO Element VALUES(2,'Elem2');\n    INSERT INTO Element VALUES(3,'Elem3');\n    INSERT INTO Element VALUES(4,'Elem4');\n    INSERT INTO Element VALUES(5,'Elem5');\n    INSERT INTO ElemOr Values(3,4);\n    INSERT INTO ElemOr Values(3,5);\n    INSERT INTO ElemAnd VALUES(1,3,'a','b','c');\n    INSERT INTO ElemAnd VALUES(1,2,'x','y','z');\n    \n    CREATE VIEW ElemView1 AS\n    SELECT\n      CAST(Element.Code AS VARCHAR(50)) AS ElemId,\n     Element.Code AS ElemCode,\n     Element.Name AS ElemName,\n     ElemAnd.Code AS InnerCode,\n     ElemAnd.Attr1 AS Attr1,\n     ElemAnd.Attr2 AS Attr2,\n     ElemAnd.Attr3 AS Attr3,\n     0 AS Level,\n     0 AS IsOrElem\n    FROM Element JOIN ElemAnd ON ElemAnd.CodeAnd=Element.Code\n    WHERE ElemAnd.CodeAnd NOT IN (SELECT CodeOr FROM ElemOr)\n    UNION ALL\n    SELECT\n      CAST(ElemOr.CodeOr AS VARCHAR(50)) AS ElemId,\n      Element.Code AS ElemCode,\n      Element.Name AS ElemName,\n      ElemOr.Code AS InnerCode,\n      NULL AS Attr1,\n      NULL AS Attr2,\n      NULL AS Attr3,\n      0 AS Level,\n      1 AS IsOrElem\n    FROM ElemOr JOIN Element ON Element.Code=ElemOr.CodeOr\n    ORDER BY ElemId, InnerCode;\n    \n    CREATE VIEW ElemView2 AS\n    SELECT\n      ElemId,\n      ElemCode,\n      ElemName,\n      InnerCode,\n      Attr1,\n      Attr2,\n      Attr3,\n      Level,\n      IsOrElem\n    FROM ElemView1\n    UNION ALL\n    SELECT\n      Element.ElemId || '.' || InnerElem.ElemId AS ElemId,\n      InnerElem.ElemCode,\n      InnerElem.ElemName,\n      InnerElem.InnerCode,\n      InnerElem.Attr1,\n      InnerElem.Attr2,\n      InnerElem.Attr3,\n      InnerElem.Level+1,\n      InnerElem.IsOrElem\n    FROM ElemView1 AS Element\n    JOIN ElemView1 AS InnerElem\n         ON Element.Level=0 AND Element.InnerCode=InnerElem.ElemCode\n    ORDER BY ElemId, InnerCode;\n \n    SELECT * FROM ElemView1;\n  }\n} {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}\n   \ndo_test tkt3527-1.2 {\n  db eval {\n    SELECT * FROM ElemView2;\n  }\n} {1 1 Elem1 2 x y z 0 0 1 1 Elem1 3 a b c 0 0 1.3 3 Elem3 4 {} {} {} 1 1 1.3 3 Elem3 5 {} {} {} 1 1 3 3 Elem3 4 {} {} {} 0 1 3 3 Elem3 5 {} {} {} 0 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3541.test",
    "content": "# 2008 December 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file is a verification that the bugs identified in ticket\n# #3541 have been fixed.\n#\n# $Id: tkt3541.test,v 1.1 2008/12/15 15:27:52 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3541-1.1 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(123);\n    SELECT CASE ~max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;\n  }\n} {123}\ndo_test tkt3541-1.2 {\n  db eval {\n    SELECT CASE NOT max(x) WHEN min(x) THEN 1 ELSE max(x) END FROM t1;\n  }\n} {123}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3554.test",
    "content": "# 2008 December 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3554 has been\n# fixed.  \n#\n# $Id: tkt3554.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !trigger {\n  finish_test\n  return\n}\n\ndo_test tkt3544-1.1 {\n  execsql {\n    CREATE TABLE test ( obj, t1, t2, PRIMARY KEY(obj, t1, t2) );\n  \n    CREATE TRIGGER test_insert BEFORE INSERT ON test BEGIN\n      UPDATE test SET t1 = new.t1 \n        WHERE obj = new.obj AND new.t1 < t1 AND new.t2 >= t1;\n  \n      UPDATE test SET t2 = new.t2 \n        WHERE obj = new.obj AND new.t2 > t2 AND new.t1 <= t2;\n  \n      SELECT RAISE(IGNORE) WHERE EXISTS (\n        SELECT obj FROM test \n        WHERE obj = new.obj AND new.t1 >= t1 AND new.t2 <= t2\n      );\n    END;\n  }\n} {}\n\ndo_test tkt3544-1.2 {\n  execsql {\n    INSERT INTO test VALUES('a', 10000, 11000);\n    SELECT * FROM test;\n  }\n} {a 10000 11000}\n\n\ndo_test tkt3544-1.3 {\n  execsql {\n    INSERT INTO test VALUES('a', 9000, 10500);\n  }\n  execsql { SELECT * FROM test }\n} {a 9000 11000}\n\ndo_test tkt3544-1.4 {\n  execsql {\n    INSERT INTO test VALUES('a', 10000, 12000);\n  }\n  execsql { SELECT * FROM test }\n} {a 9000 12000}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3581.test",
    "content": "# 2008 January 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3581 has been\n# fixed.  \n#\n# $Id: tkt3581.test,v 1.1 2009/01/14 01:10:40 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3581-1.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    INSERT INTO t1 VALUES(0,544,846);\n    INSERT INTO t1 VALUES(1,345,51);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b, c);\n    INSERT INTO t2 SELECT * FROM t1;\n    CREATE INDEX i2 on t2(c);\n  }\n} {}\n\ndo_test tkt3581-1.2 {\n  db eval {\n    SELECT a FROM t1\n     WHERE (b > 45 AND c < 356)\n        OR b <= 733\n        OR b >= 557\n        OR (b >= 614 AND c < 251)\n     ORDER BY b;\n  }\n} {1 0}\n\ndo_test tkt3581-1.3 {\n  db eval {\n    SELECT a FROM t2\n     WHERE (b > 45 AND c < 356)\n        OR b <= 733\n        OR b >= 557\n        OR (b >= 614 AND c < 251)\n     ORDER BY b;\n  }\n} {1 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt35xx.test",
    "content": "# 2008 November 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# When a transaction rolls back, make sure that dirty pages in the\n# page cache which are not in the rollback journal are reinitialized\n# in the btree layer.\n#\n# $Id: tkt35xx.test,v 1.4 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt35xx-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n  }\n} {}\n\n# Trigger the problem using explicit rollback.\n#\ndo_test tkt35xx-1.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    CREATE TABLE t1(a,b,c);\n    CREATE INDEX i1 ON t1(c);\n    INSERT INTO t1 VALUES(0, 0, zeroblob(676));\n    INSERT INTO t1 VALUES(1, 1, zeroblob(676));\n    DELETE FROM t1;\n    BEGIN;\n    INSERT INTO t1 VALUES(0, 0, zeroblob(676));\n    INSERT INTO t1 VALUES(1, 1, zeroblob(676));\n    ROLLBACK;\n    INSERT INTO t1 VALUES(0, 0, zeroblob(676));\n  }\n  execsql {\n    INSERT INTO t1 VALUES(1, 1, zeroblob(676));\n  }\n} {}\n\n# Trigger the problem using statement rollback.\n#\ndb close\ndelete_file test.db\nsqlite3 db test.db\nset big [string repeat abcdefghij 22]    ;# 220 byte string\ndo_test tkt35xx-1.2.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t3 VALUES(1, $big);\n    INSERT INTO t3 VALUES(2, $big);\n    INSERT INTO t3 VALUES(3, $big);\n    INSERT INTO t3 VALUES(4, $big);\n    CREATE TABLE t4(c, d);\n    INSERT INTO t4 VALUES(5, $big);\n    INSERT INTO t4 VALUES(1, $big);\n  }\n} {}\ndo_test tkt35xx-1.2.2 {\n  catchsql {\n    BEGIN;\n    CREATE TABLE t5(e PRIMARY KEY, f);\n    DROP TABLE t5;\n    INSERT INTO t3(a, b) SELECT c, d FROM t4;\n  }\n} {1 {UNIQUE constraint failed: t3.a}}\ndo_test tkt35xx-1.2.3 {\n  # Show that the transaction has not been rolled back.\n  catchsql BEGIN\n} {1 {cannot start a transaction within a transaction}}\ndo_test tkt35xx-1.2.4 {\n  execsql { SELECT count(*) FROM t3 }\n} {4}\ndo_test tkt35xx-1.2.5 {\n  # Before the bug was fixed, if SQLITE_DEBUG was defined an assert()\n  # would fail during the following INSERT statement. If SQLITE_DEBUG\n  # was not defined, then the statement would pass and the transaction\n  # would be committed. But, the \"SELECT count(*)\" in tkt35xx-1.2.6 would\n  # return 1, not 5. Data magically disappeared!\n  #\n  execsql { \n    INSERT INTO t3 VALUES(5, $big);\n    COMMIT;\n  }\n} {}\ndo_test tkt35xx-1.2.6 {\n  execsql { SELECT count(*) FROM t3 }\n} {5}\nintegrity_check tkt35xx-1.2.7\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3630.test",
    "content": "# 2009 February 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# \n# This file checks to make sure the \"TEMP\" or \"TEMPORARY\" keyword is\n# omitted from the schema of a table that is created using that\n# keyword.  Ticket #3630.\n#\n# $Id: tkt3630.test,v 1.1 2009/02/02 18:03:22 drh Exp $\n#\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\n\ndo_test tkt3630-1 {\n  db eval {\n    CREATE TEMP TABLE temp1(a,b,c);\n    SELECT * FROM temp.sqlite_master WHERE sql GLOB '*TEMP*';\n  }\n} {}\ndo_test tkt3630-2 {\n  db eval {\n    CREATE TABLE main1(a,b,c);\n    CREATE TEMP TABLE temp2 AS SELECT * FROM main1;\n    SELECT * FROM sqlite_temp_master WHERE sql GLOB '*TEMP*';\n  }\n} {}\n\nifcapable altertable {\n  do_test tkt3630-3 {\n    db eval {\n      ALTER TABLE temp2 ADD COLUMN d;\n      ALTER TABLE temp2 RENAME TO temp2rn;\n      SELECT name FROM temp.sqlite_master WHERE name LIKE 'temp2%';\n    }\n  } {temp2rn}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3718.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the execution of SQL statements from\n# within callbacks generated by VMs that themselves open statement \n# transactions.\n#\n# $Id: tkt3718.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3718-1.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n    INSERT INTO t1 VALUES(4, 'four');\n    INSERT INTO t1 VALUES(5, 'five');\n    CREATE TABLE t2(a PRIMARY KEY, b);\n  }\n} {}\n\n# SQL scalar function:\n#\n#   f1(<arg>)\n#\n# Uses database handle [db] to execute \"SELECT f2(<arg>)\". Returns either\n# the results or error message from the \"SELECT f2(<arg>)\" query to the\n# caller.\n#\nproc f1 {args} {\n  set a [lindex $args 0]\n  catch { db eval {SELECT f2($a)} } msg\n  set msg\n}\n\n# SQL scalar function:\n#\n#   f2(<arg>)\n#\n# Return the value of <arg>. Unless <arg> is \"three\", in which case throw\n# an exception.\n#\nproc f2 {args} {\n  set a [lindex $args 0]\n  if {$a == \"three\"} { error \"Three!!\" }\n  return $a\n}\n\ndb func f1 f1\ndb func f2 f2\n\n# The second INSERT statement below uses the f1 user function such that\n# half-way through the INSERT operation f1() will run an SQL statement\n# that throws an exception. At one point, before #3718 was fixed, this\n# caused the statement transaction belonging to the INSERT statement to\n# be rolled back. The result was that some (but not all) of the rows that \n# should have been inserted went missing.\n#\ndo_test tkt3718-1.2 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT a, b FROM t1;\n    INSERT INTO t2 SELECT a+5, f1(b) FROM t1;\n    COMMIT;\n  }\n  execsql {\n    SELECT a FROM t2;\n  }\n} {1 2 3 4 5 6 7 8 9 10}\n\n# This test turns on the count_changes pragma (causing DML statements to\n# return SQLITE_ROW once, with a single integer result value reporting the\n# number of rows affected by the statement). It then executes an INSERT\n# statement that requires a statement journal. After stepping the statement\n# once, so that it returns SQLITE_ROW, a second SQL statement that throws an\n# exception is run. At one point, before #3718 was fixed, this caused the\n# statement transaction belonging to the INSERT statement to be rolled back.\n# The result was that none of the rows were actually inserted.\n# \n#\ndo_test tkt3718-1.3 {\n  execsql { \n    DELETE FROM t2 WHERE a > 5;\n    PRAGMA count_changes = 1;\n    BEGIN;\n  }\n  db eval {INSERT INTO t2 SELECT a+5, b||'+5' FROM t1} {\n    catch { db eval {SELECT f2('three')} } msg\n  }\n  execsql {\n    COMMIT;\n    SELECT a FROM t2;\n  }\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_test tkt3718-1.4 {\n  execsql {pragma count_changes=0}\n} {}\n\n# This SQL function executes the SQL specified as an argument against\n# database [db].\n#\nproc sql {doit zSql} {\n  if {$doit} { catchsql $zSql }\n}\ndb func sql [list sql]\n\n# The following tests, tkt3718-2.*, test that a nested statement \n# transaction can be successfully committed or reverted without \n# affecting the parent statement transaction.\n#\ndo_test tkt3718-2.1 {\n  execsql { SELECT sql(1, 'DELETE FROM t2 WHERE a = '||a ) FROM t2 WHERE a>5 }\n  execsql { SELECT a from t2 }\n} {1 2 3 4 5}\ndo_test tkt3718-2.2 {\n  execsql {\n    DELETE FROM t2 WHERE a > 5;\n    BEGIN;\n    INSERT INTO t2 SELECT a+5, sql(a==3,\n        'INSERT INTO t2 SELECT a+10, f2(b) FROM t1'\n    ) FROM t1;\n  }\n  execsql {\n    COMMIT;\n    SELECT a FROM t2;\n  }\n} {1 2 3 4 5 6 7 8 9 10}\ndo_test tkt3718-2.3 {\n  execsql {\n    DELETE FROM t2 WHERE a > 5;\n    BEGIN;\n    INSERT INTO t2 SELECT a+5, sql(a==3,\n        'INSERT INTO t2 SELECT a+10, b FROM t1'\n    ) FROM t1;\n    COMMIT;\n  }\n  execsql { SELECT a FROM t2 ORDER BY a+0}\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15}\nintegrity_check tkt3718.2-4\n\n# The next set of tests, tkt3718-3.*, test that a statement transaction\n# that has a committed statement transaction nested inside of it can\n# be committed or reverted.\n#\nforeach {tn io ii results} {\n  1 0 10 {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\n  2 1 10 {6 7 8 9 10 16 17 18 19 20}\n  3 0 11 {1 2 3 4 5 6 7 8 9 10 16 17 18 19 20}\n  4 1 11 {6 7 8 9 10 16 17 18 19 20}\n} {\n  do_test tkt3718-3.$tn {\n    execsql { \n      DELETE FROM t2;\n      INSERT INTO t2 SELECT a+5, b FROM t1;\n      INSERT INTO t2 SELECT a+15, b FROM t1;\n    }\n\n    catchsql \"\n      BEGIN;\n      INSERT INTO t2 SELECT a+$io, sql(a==3,\n          'INSERT INTO t2 SELECT a+$ii, b FROM t1'\n      ) FROM t1;\n    \"\n\n    execsql { COMMIT }\n\n    execsql { SELECT a FROM t2 ORDER BY a+0}\n  } $results\n\n  integrity_check tkt3718-3.$tn.integrity\n}\n\n# This is the same test as tkt3718-3.*, but with 3 levels of nesting.\n#\nforeach {tn i1 i2 i3 results} {\n  1   0 10 20   {5 10 15 20 25 30}\n  2   0 10 21   {5 10 15 20 30}\n  3   0 11 20   {5 10 20 30}\n  4   0 11 21   {5 10 20 30}\n  5   1 10 20   {10 20 30}\n  6   1 10 21   {10 20 30}\n  7   1 11 20   {10 20 30}\n  8   1 11 21   {10 20 30}\n} {\n  do_test tkt3718-4.$tn {\n    execsql { \n      DELETE FROM t2;\n      INSERT INTO t2 SELECT a+5, b FROM t1;\n      INSERT INTO t2 SELECT a+15, b FROM t1;\n      INSERT INTO t2 SELECT a+25, b FROM t1;\n    }\n\n    catchsql \"\n      BEGIN;\n      INSERT INTO t2 SELECT a+$i1, sql(a==3,\n          'INSERT INTO t2 SELECT a+$i2, sql(a==3, \n             ''INSERT INTO t2 SELECT a+$i3, b FROM t1''\n           ) FROM t1'\n      ) FROM t1;\n    \"\n\n    execsql { COMMIT }\n\n    execsql { SELECT a FROM t2 WHERE (a%5)==0 ORDER BY a+0}\n  } $results\n\n  do_test tkt3718-4.$tn.extra {\n    execsql {\n      SELECT \n        (SELECT sum(a) FROM t2)==(SELECT sum(a*5-10) FROM t2 WHERE (a%5)==0)\n    }\n  } {1}\n\n  integrity_check tkt3718-4.$tn.integrity\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3731.test",
    "content": "# 2009 March 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt3731.test,v 1.1 2009/03/17 22:33:01 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# The tests in this file were written before SQLite supported recursive\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\ndo_test tkt3731-1.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN\n      INSERT INTO t1 VALUES(new.a || '+', new.b || '+');\n    END;\n  }\n} {}\n\ndo_test tkt3731-1.2 {\n  execsql {\n    INSERT INTO t1 VALUES('a', 'b');\n    INSERT INTO t1 VALUES('c', 'd');\n    SELECT * FROM t1;\n  }\n} {a b a+ b+ c d c+ d+}\n\ndo_test tkt3731-1.3 {\n  execsql {\n    DELETE FROM t1;\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES('e', 'f');\n    INSERT INTO t2 VALUES('g', 'h');\n    INSERT INTO t1 SELECT * FROM t2;\n    SELECT * FROM t1;\n  }\n} {e f e+ f+ g h g+ h+}\n\nintegrity_check tkt3731-1.4\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3757.test",
    "content": "# 2009 March 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3757:  The cost functions on the query optimizer for the\n# IN operator can be improved.\n#\n# $Id: tkt3757.test,v 1.1 2009/03/29 00:13:04 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Evaluate SQL.  Return the result set followed by the\n# and the number of full-scan steps.\n#\nproc count_steps {sql} {\n  set r [db eval $sql]\n  lappend r scan [db status step] sort [db status sort]\n}\n\n# Construct tables\n#\ndo_test tkt3757-1.1 {\n  db eval {\n     CREATE TABLE t1(x INTEGER, y INTEGER, z TEXT);\n     CREATE INDEX t1i1 ON t1(y,z);\n     INSERT INTO t1 VALUES(1,2,'three');\n     CREATE TABLE t2(a INTEGER, b TEXT);\n     INSERT INTO t2 VALUES(2, 'two');\n     ANALYZE;\n     SELECT * FROM sqlite_stat1 ORDER BY 1, 2;\n  }\n} {t1 t1i1 {1 1 1} t2 {} 1}\n\n# Modify statistics in order to make the optimizer then that:\n#\n#   (1)  Table T1 has about 250K entries\n#   (2)  There are only about 5 distinct values of T1.\n#\n# Then run a query with \"t1.y IN (SELECT ..)\" in the WHERE clause.\n# Make sure the index is used.\n#\ndo_test tkt3757-1.2 {\n  db eval {\n    DELETE FROM sqlite_stat1;\n    INSERT INTO sqlite_stat1 VALUES('t1','t1i1','250000 50000 30');\n  }\n  count_steps {\n    SELECT * FROM t1 WHERE y IN (SELECT a FROM t2)\n  }\n} {1 2 three scan 0 sort 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3761.test",
    "content": "# 2009 March 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3761:  Make sure that an incremental vacuum on an in-memory\n# database can be rolled back.\n#\n# $Id: tkt3761.test,v 1.1 2009/03/31 02:54:40 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3761-1.1 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n    PRAGMA auto_vacuum=INCREMENTAL;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    BEGIN;\n    DELETE FROM t1 WHERE rowid%2;\n    PRAGMA incremental_vacuum(4);\n    ROLLBACK;\n  }\n  db eval {PRAGMA integrity_check}\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3762.test",
    "content": "# 2009 March 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3762:  Make sure that an incremental vacuum that reduces the\n# size of the database file such that if a pointer-map page is eliminated\n# it can be correctly rolled back.\n#\n# That ticket #3762 has been fixed has already been verified by the\n# savepoint6.test test script.  But this script is simplier and a\n# redundant test never hurts.\n#\n# $Id: tkt3762.test,v 1.1 2009/03/31 00:50:36 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3762-1.1 {\n  db eval {\n    PRAGMA auto_vacuum=INCREMENTAL;\n    PRAGMA page_size=1024;\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 VALUES(zeroblob(900));\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    INSERT INTO t1 SELECT x FROM t1;\n    DELETE FROM t1 WHERE rowid>202;\n    VACUUM;\n    \n    BEGIN;\n    DELETE FROM t1 WHERE rowid IN (10,11,12) ;\n    PRAGMA incremental_vacuum(10);\n    UPDATE t1 SET x=zeroblob(900) WHERE rowid BETWEEN 100 AND 110;\n    INSERT INTO t1 VALUES(zeroblob(39000));\n    SELECT count(*) FROM t1;\n    ROLLBACK;\n  }\n  db eval {PRAGMA integrity_check}\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3773.test",
    "content": "# 2009 April 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3773:  Be careful not to over-optimize when a compound\n# subquery contains an ORDER BY clause.\n#\n#\n# $Id: tkt3773.test,v 1.1 2009/04/02 16:59:47 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !compound {\n  finish_test\n  return\n}\n\ndo_test tkt3773-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(2,1);\n    INSERT INTO t1 VALUES(33,3);\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(123,2);\n    INSERT INTO t2 VALUES(4,4);\n    SELECT a FROM (\n      SELECT a, b FROM t1\n      UNION ALL\n      SELECT x, y FROM t2\n      ORDER BY 2\n    );\n  }\n} {2 123 33 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3791.test",
    "content": "# 2009 April 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3791:  A segfault when inserting into a table that contains\n# an arbitrary expression as its default value.\n#\n# $Id: tkt3791.test,v 1.1 2009/04/08 12:21:31 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3791-1.1 {\n  db eval {\n    CREATE TABLE t1(x, y DEFAULT(datetime('now')));\n    INSERT INTO t1(x) VALUES(1);\n    SELECT x, length(y) FROM t1;\n  }\n} {1 19}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3793.test",
    "content": "# 2009 April 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3793 has been\n# fixed.  \n#\n# $Id: tkt3793.test,v 1.2 2009/06/01 16:42:18 shane Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !shared_cache||!attach {\n  finish_test\n  return\n}\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\ndo_test tkt3793-1.1 {\n  # This is taken from shared.test.  The Windows VFS expands \n  # ./test.db (and test.db) to be the same thing so the path\n  # matches and they share a cache.  By changing the case \n  # for Windows platform, we get around this and get a separate\n  # connection.\n  if {$::tcl_platform(platform)==\"unix\"} {\n    sqlite3 db1 test.db\n    sqlite3 db2 test.db\n  } else {\n    sqlite3 db1 TEST.DB\n    sqlite3 db2 TEST.DB\n  }\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(randstr(50,50), randstr(50,50));\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t1 SELECT randstr(50,50), randstr(50,50) FROM t1;\n    INSERT INTO t2 SELECT * FROM t1;\n    COMMIT;\n  }\n} {}\n\nproc busyhandler {db args} { set ::busyconnection $db ; return 1 }\ndb2 busy {busyhandler db2}\ndb1 busy {busyhandler db1}\n\n# Establish a read-lock on the database file using connection [db].\n#\ndo_test tkt3793-1.2 {\n  execsql {\n    BEGIN;\n    SELECT count(*) FROM t1;\n  }\n} {1024}\n\n# Set the size of the cache shared by [db1] and [db2] to 10. Then update\n# more than 10 pages of table t1. At this point the shared-cache will\n# hold a RESERVED lock on the database file. Even though there are now\n# more than 10 dirty pages in memory, it cannot upgrade to an EXCLUSIVE \n# lock because of the read-lock held by [db].\n#\ndo_test tkt3793-1.3 {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n    UPDATE t1 SET b = randstr(50,50);\n  } db1\n} {}\n\nset x 0\n\n# Run one SELECT query on the shared-cache using [db1], then from within \n# the callback run another via [db2]. Because of the large number of dirty\n# pages within the cache, each time a new page is read from the database\n# SQLite will attempt to upgrade to an EXCLUSIVE lock, and hence invoke\n# the busy-handler. The tests here verify that the correct busy-handler\n# function is invoked (the busy-handler associated with the database\n# connection that called sqlite3_step()). When bug #3793 existed, sometimes\n# the [db2] busy-handler was invoked from within the call to sqlite3_step()\n# associated with [db1]. \n#\n# Note: Before the bug was fixed, if [db2] was opened with the \"-fullmutex 1\"\n# option, then this test case would cause an assert() to fail.\n#\nifcapable threadsafe {\n  set ::busyconnection db1\n  db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} {\n    do_test tkt3793-2.[incr x] { set ::busyconnection } db1\n    set ::busyconnection db2\n  \n    db2 eval { SELECT count(*) FROM t2 }\n    do_test tkt3793-2.[incr x] { set ::busyconnection } db2\n    set ::busyconnection db1\n  }\n}\n  \ndo_test tkt3793-3 {\n  db1 close\n  db2 close\n} {}\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3810.test",
    "content": "# 2009 August 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to make sure #3810 is fixed.\n#\n# $Id: tkt3810.test,v 1.4 2009/08/06 17:43:31 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Create a table using the first database connection.\n#\ndo_test tkt3810-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(123);\n    SELECT * FROM t1;\n    CREATE TABLE t2(y);\n    CREATE TABLE t3(z);\n  }\n} 123\n\n# Create a second connection to the same database.  Make sure the\n# schema of the database has been parsed by the second connection.\n#\ndo_test tkt3810-2 {\n  sqlite3 db2 test.db\n  execsql {\n    SELECT * FROM t1;\n  } db2\n} 123\n\n# DROP the table using the second connection.  The table no longer exists\n# but the first connection does not yet know this.  Then try to create a TEMP\n# trigger in the first connection that references the table that was dropped.\n#\ndo_test tkt3810-3 {\n  execsql {DROP TABLE t1} db2\n  execsql {\n     CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN\n       INSERT INTO t2 VALUES(new.rowid);\n     END;\n  }\n  catchsql {\n    SELECT * FROM t3;\n  }\n} {0 {}}\n\n# Trigger still exists in the sqlite_temp_master table, but now it is\n# an orphan.\n#\ndo_test tkt3810-4 {\n  execsql {SELECT name FROM temp.sqlite_master ORDER BY name}\n} {r1}\n\n# Because it is an orphan, it cannot be dropped.\n#\ndo_test tkt3810-5 {\n  catchsql {DROP TRIGGER r1}\n} {1 {no such trigger: r1}}\n\n# Create a table t1 then drop the table in order to drop the orphaned\n# trigger.\n#\ndo_test tkt3810-6 {\n  execsql {CREATE TABLE t1(x)} db2\n  execsql {DROP TABLE t1}\n  execsql {\n    SELECT name FROM sqlite_temp_master;\n  }\n} {}\n\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3824.test",
    "content": "# 2009 April 24                                                                 \n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3824\n#\n# When you use an \"IS NULL\" constraint on a UNIQUE index, the result\n# is not necessarily UNIQUE.  Make sure the optimizer does not assume\n# uniqueness.\n#\n# $Id: tkt3824.test,v 1.2 2009/04/24 20:32:31 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc execsql_status {sql {db db}} {\n  set result [uplevel $db eval [list $sql]]\n  if {[db status sort]} {\n    concat $result sort\n  } else {\n    concat $result nosort\n  }\n}\n\ndo_test tkt3824-1.1 {\n  db eval {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,NULL);\n    INSERT INTO t1 VALUES(9,NULL);\n    INSERT INTO t1 VALUES(5,NULL);\n    INSERT INTO t1 VALUES(123,NULL);\n    INSERT INTO t1 VALUES(-10,NULL);\n    CREATE UNIQUE INDEX t1b ON t1(b);\n  }\n  execsql_status {\n    SELECT a FROM t1 WHERE b IS NULL ORDER BY a;\n  }\n} {-10 1 5 9 123 sort}\ndo_test tkt3824-1.2 {\n  execsql_status {\n    SELECT a FROM t1 WHERE b IS NULL ORDER BY b, a;\n  }\n} {-10 1 5 9 123 sort}\n\ndo_test tkt3824-2.1 {\n  db eval {\n    CREATE TABLE t2(a,b,c);\n    INSERT INTO t2 VALUES(1,1,NULL);\n    INSERT INTO t2 VALUES(9,2,NULL);\n    INSERT INTO t2 VALUES(5,2,NULL);\n    INSERT INTO t2 VALUES(123,3,NULL);\n    INSERT INTO t2 VALUES(-10,3,NULL);\n    CREATE UNIQUE INDEX t2bc ON t2(b,c);\n  }\n  execsql_status {\n    SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY a;\n  }\n} {5 9 sort}\ndo_test tkt3824-2.2 {\n  execsql_status {\n    SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY b, a;\n  }\n} {5 9 sort}\ndo_test tkt3824-2.3 {\n  lsort [execsql_status {\n    SELECT a FROM t2 WHERE b=2 AND c IS NULL ORDER BY b;\n  }]\n} {5 9 nosort}\n\ndo_test tkt3824-3.1 {\n  db eval {\n    CREATE TABLE t3(x,y);\n    INSERT INTO t3 SELECT a, b FROM t1;\n    INSERT INTO t3 VALUES(234,567);\n    CREATE UNIQUE INDEX t3y ON t3(y);\n    DELETE FROM t3 WHERE y IS NULL;\n    SELECT * FROM t3;\n  }\n} {234 567}\n\ndo_test tkt3824-4.1 {\n  db eval {\n    CREATE TABLE t4(x,y);\n    INSERT INTO t4 SELECT a, b FROM t1;\n    INSERT INTO t4 VALUES(234,567);\n    CREATE UNIQUE INDEX t4y ON t4(y);\n    UPDATE t4 SET rowid=rowid+100 WHERE y IS NULL;\n    SELECT rowid, x FROM t4 ORDER BY rowid;\n  }\n} {6 234 101 1 102 9 103 5 104 123 105 -10}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3832.test",
    "content": "# 2009 April 30                                                            \n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3832\n#\n# A segfault when using a BEFORE trigger on an INSERT and inserting\n# a NULL into the INTEGER PRIMARY KEY.\n#\n# $Id: tkt3832.test,v 1.1 2009/05/01 02:08:04 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n\ndo_test tkt3832-1.1 {\n  db eval {\n    CREATE TABLE t1(a INT, b INTEGER PRIMARY KEY);\n    CREATE TABLE log(x);\n    CREATE TRIGGER t1r1 BEFORE INSERT ON t1 BEGIN\n      INSERT INTO log VALUES(new.b);\n    END;\n    INSERT INTO t1 VALUES(NULL,5);\n    INSERT INTO t1 SELECT b, a FROM t1 ORDER BY b;\n    SELECT rowid, * FROM t1;\n    SELECT rowid, * FROM log;\n  }\n} {5 {} 5 6 5 6 1 5 2 -1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3838.test",
    "content": "# 2009 May 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3838\n#\n# The ticket reports that the encoding is UTF8 on the DEFAULT VALUE of\n# a column added using ALTER TABLE even when the database is UTF16.\n# Verify that this has been fixed.\n#\n# $Id: tkt3838.test,v 1.1 2009/05/05 12:54:50 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !altertable {\n  finish_test\n  return\n}\n\ndo_realnum_test tkt3838-1.1 {\n  db eval {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    ALTER TABLE t1 ADD COLUMN b INTEGER DEFAULT '999';\n    ALTER TABLE t1 ADD COLUMN c REAL DEFAULT '9e99';\n    ALTER TABLE t1 ADD COLUMN d TEXT DEFAULT 'xyzzy';\n    UPDATE t1 SET x=x+1;\n    SELECT * FROM t1;\n  }\n} {2 999 9e+99 xyzzy}\n\nifcapable trigger {\n  do_test tkt3838-1.2 {\n    db eval {\n      CREATE TABLE log(y);\n      CREATE TRIGGER r1 AFTER INSERT ON T1 BEGIN\n        INSERT INTO log VALUES(new.x);\n      END;\n      INSERT INTO t1(x) VALUES(123);\n      ALTER TABLE T1 RENAME TO XYZ2;\n      INSERT INTO xyz2(x) VALUES(456);\n      ALTER TABLE xyz2 RENAME TO pqr3;\n      INSERT INTO pqr3(x) VALUES(789);\n      SELECT * FROM log;\n    }\n  } {123 456 789}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3841.test",
    "content": "# 2009 May 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Ticket #3841\n#\n# The sqlite3_aggregate_count() is not being reset when an aggregate\n# functio is used in a correlated subquery.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !subquery {\n  finish_test\n  return\n}\n\ndo_test tkt3841.1 {\n  execsql {\n    CREATE TABLE table2 (key TEXT, x TEXT);\n    CREATE TABLE list (key TEXT, value TEXT);\n  \n    INSERT INTO table2 VALUES (\"a\", \"alist\");\n    INSERT INTO table2 VALUES (\"b\", \"blist\");\n    INSERT INTO list VALUES (\"a\", 1);\n    INSERT INTO list VALUES (\"a\", 2);\n    INSERT INTO list VALUES (\"a\", 3);\n    INSERT INTO list VALUES (\"b\", 4);\n    INSERT INTO list VALUES (\"b\", 5);\n    INSERT INTO list VALUES (\"b\", 6);\n\n    SELECT\n      table2.x,\n      (SELECT group_concat(list.value)\n        FROM list\n        WHERE list.key = table2.key)\n    FROM table2;\n  }\n} {alist 1,2,3 blist 4,5,6}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3871.test",
    "content": "\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test tkt3871-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n  }\n  for {set i 0} {$i < 500} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i*$i) }\n  }\n  execsql COMMIT\n  execsql { \n    CREATE VIRTUAL TABLE e USING echo(t1);\n    SELECT count(*) FROM e;\n  }\n} {500}\n\ndo_test tkt3871-1.2 {\n  execsql { SELECT * FROM e WHERE a = 1 OR a = 2 }\n} {1 1 2 4}\ndo_test tkt3871-1.3 {\n  set echo_module \"\"\n  execsql { SELECT * FROM e WHERE a = 1 OR a = 2 }\n  set echo_module\n} [list \\\n  xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 1 \\\n  xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 2 \\\n]\n\ndo_test tkt3871-1.4 {\n  execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 }\n} {1 1 2 4 3 9}\ndo_test tkt3871-1.5 {\n  set echo_module \"\"\n  execsql { SELECT * FROM e WHERE a = 1 OR a = 2 OR b = 9 }\n  set echo_module\n} [list \\\n  xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 1 \\\n  xFilter {SELECT rowid, a, b FROM 't1' WHERE a = ?} 2 \\\n  xFilter {SELECT rowid, a, b FROM 't1' WHERE b = ?} 9\n]\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3879.test",
    "content": "# 2009 May 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to verify ticket #3879 is fixed.\n#\n# $Id: tkt3879.test,v 1.2 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3879.1.1 {\n  execsql {\n    CREATE TABLE t1 (a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES ('w',  1);\n    INSERT INTO t1 VALUES ('z', -1);\n  \n    CREATE TABLE t2 (m INTEGER PRIMARY KEY, n, a, p);\n    INSERT INTO t2 VALUES (25, 13, 'w', 1);\n    INSERT INTO t2 VALUES (26, 25, 'z', 153);\n    INSERT INTO t2 VALUES (27, 25, 'z', 68);\n\n    CREATE TABLE t3 (m);\n    INSERT INTO t3 VALUES (25);\n  }\n} {}\n\ndo_test tkt3879.1.2 {\n  execsql {\n    SELECT 111, t1.b*123\n    FROM t3, t2 AS j0, t2 AS j1, t1\n    WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m;\n  }\n} {111 123 111 123}\n\ndo_test tkt3879.1.3 {\n  execsql {\n    SELECT 222, t1.b*123\n    FROM t3, t2 AS j0, t2 AS j1, t1\n    WHERE j0.m=t3.m AND t1.a=j0.a AND j1.n=j0.m\n    ORDER BY t1.b;\n  }\n} {222 123 222 123}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3911.test",
    "content": "# 2009 June 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to verify ticket #3911 is fixed.\n#\n# $Id: tkt3911.test,v 1.1 2009/06/12 03:27:28 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3911.1 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(11,12);\n\n    CREATE TABLE t2(b,c);\n    INSERT INTO t2 VALUES(2,3);\n    INSERT INTO t2 VALUES(22,23);\n\n    SELECT * FROM t1 JOIN t2 USING(b);\n  }\n} {1 2 3}\ndo_test tkt3911.2 {\n  db eval {\n    SELECT * FROM t1 JOIN (t2) AS x USING (b);\n  }\n} {1 2 3}\ndo_test tkt3911.3 {\n  db eval {\n    SELECT * FROM t1 JOIN (SELECT * FROM t2) AS x USING (b);\n  }\n} {1 2 3}\n\ndo_test tkt3911.4 {\n  db eval {\n    CREATE TABLE t3(m,a);\n    INSERT INTO t3 VALUES('one',1);\n    INSERT INTO t3 VALUES('two',2);\n\n    SELECT * FROM t3 JOIN (SELECT * FROM t1 NATURAL JOIN t2) AS x USING(a);\n  }\n} {one 1 2 3}\ndo_test tkt3911.5 {\n  db eval {\n    SELECT * FROM t3 JOIN (SELECT * FROM t1 JOIN t2 USING (b)) AS x USING(a);\n  }\n} {one 1 2 3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3918.test",
    "content": "# 2009 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt3918.test,v 1.1 2009/06/17 11:13:28 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3918.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = incremental;\n    CREATE TABLE t1(i, x);\n  }\n} {}\ndo_test tkt3918.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, randstr(1000,1000));\n    INSERT INTO t1 VALUES(2, zeroblob(248*1020 + 100));\n    INSERT INTO t1 VALUES(3, zeroblob(2*1020 + 100));\n  }\n} {}\n\n# This set of statements sets up the free list so that the\n# first free-list trunk page contains only a single leaf.\n# The leaf page is also the last page in the database. The\n# second free-list trunk page contains, amongst other things,\n# page number 4.\ndo_test tkt3918.3 {\n  execsql {\n    DELETE FROM t1 WHERE i = 2;\n    DELETE FROM t1 WHERE i = 1;\n    DELETE FROM t1 WHERE i = 3;\n  }\n} {}\n\n# Incrementally vacuum the database to reduce its size by a single\n# page. This will remove the single leaf from the first page in\n# the linked list of free-list trunk pages.\ndo_test tkt3918.4 {\n  execsql { PRAGMA incremental_vacuum = 1 }\n} {}\n\n# Create another table. This operation will attempt to extract \n# page 4 from the database free-list. Bug 3918 caused sqlite to\n# incorrectly report corruption here.\ndo_test tkt3918.5 {\n  execsql { CREATE TABLE t2(a, b) }\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3922.test",
    "content": "# 2009 June 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt3922.test,v 1.2 2009/06/26 14:17:47 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nif {[working_64bit_int]} {\n  do_test tkt3922.1 {\n    execsql {\n      CREATE TABLE t1(a NUMBER);\n      INSERT INTO t1 VALUES('-9223372036854775808');\n      SELECT a, typeof(a) FROM t1;\n    }\n  } {-9223372036854775808 integer}\n} else {\n  # this alternate version of tkt3922.1 doesn't\n  # really test the same thing as the original, \n  # but is needed to create the table and \n  # provided simply as a place holder for \n  # platforms without working 64bit support.\n  do_test tkt3922.1 {\n    execsql {\n      CREATE TABLE t1(a NUMBER);\n      INSERT INTO t1 VALUES('-1');\n      SELECT a, typeof(a) FROM t1;\n    }\n  } {-1 integer}\n}\ndo_realnum_test tkt3922.2 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('-9223372036854775809');\n    SELECT a, typeof(a) FROM t1;\n  }\n} {-9.22337203685478e+18 real}\ndo_realnum_test tkt3922.3 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('-9223372036854776832');\n    SELECT a, typeof(a) FROM t1;\n  }\n} {-9.22337203685478e+18 real}\ndo_realnum_test tkt3922.4 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('-9223372036854776833');\n    SELECT a, typeof(a) FROM t1;\n  }\n} {-9.22337203685478e+18 real}\nif {[working_64bit_int]} {\n  do_test tkt3922.5 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES('9223372036854775807');\n      SELECT a, typeof(a) FROM t1;\n    }\n  } {9223372036854775807 integer}\n} else {\n  # this alternate version of tkt3922.5 doesn't\n  # really test the same thing as the original, \n  # but provided simply as a place holder for \n  # platforms without working 64bit support.\n  do_test tkt3922.5 {\n    execsql {\n      DELETE FROM t1;\n      INSERT INTO t1 VALUES('1');\n      SELECT a, typeof(a) FROM t1;\n    }\n  } {1 integer}\n}\ndo_realnum_test tkt3922.6 {\n  execsql {\n    DELETE FROM t1;\n    INSERT INTO t1 VALUES('9223372036854775808');\n    SELECT a, typeof(a) FROM t1;\n  }\n} {9.22337203685478e+18 real}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3929.test",
    "content": "# 2009 June 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to verify ticket #3929 is fixed.\n#\n# $Id: tkt3929.test,v 1.1 2009/06/23 11:53:09 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\ndo_test tkt3929-1.0 {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a, b);\n    CREATE TRIGGER t1_t1 AFTER INSERT ON t1 BEGIN\n      UPDATE t1 SET b = 'value: ' || a WHERE t1.rowid = new.rowid;\n    END;\n  }\n} {}\n\ndo_test tkt3929-1.1 {\n  execsql {\n    INSERT INTO t1(a) VALUES(1);\n    INSERT INTO t1(a) VALUES(2);\n    SELECT * FROM t1;\n  }\n} {1 {value: 1} 2 {value: 2}}\n\n# Before it was fixed, the following provoked the bug, causing either an\n# assertion failure or a \"database is malformed\" error.\n#\ndo_test tkt3930-1.2 {\n  for {set i 3} {$i < 100} {incr i} {\n    execsql { INSERT INTO t1(a) VALUES($i) }\n  }\n} {}\n\nintegrity_check tkt3930-1.3\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3935.test",
    "content": "# 2009 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #3935 has been fixed.\n#\n# $Id: tkt3935.test,v 1.2 2009/07/01 16:12:08 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3935.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(c, d);\n  }\n} {}\n\ndo_test tkt3935.2 {\n  execsql { SELECT j1.b FROM ( SELECT * FROM t1 INNER JOIN t2 ON a=c ) AS j1 }\n} {}\ndo_test tkt3935.3 {\n  execsql { SELECT j1.b FROM (t1 INNER JOIN t2 ON a=c) AS j1 }\n} {}\n\n\ndo_test tkt3935.4 {\n  catchsql { SELECT a FROM (t1) AS t ON b USING(a) }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.5 {\n  catchsql { SELECT a FROM (t1) AS t ON b }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.6 {\n  catchsql { SELECT a FROM (SELECT * FROM t1) AS t ON b USING(a) }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.7 {\n  catchsql { SELECT a FROM (SELECT * FROM t1) AS t ON b }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.8 {\n  catchsql { SELECT a FROM t1 AS t ON b }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.9 {\n  catchsql { SELECT a FROM t1 AS t ON b USING(a) }\n} {1 {a JOIN clause is required before ON}}\ndo_test tkt3935.10 {\n  catchsql { SELECT a FROM t1 AS t USING(a) }\n} {1 {a JOIN clause is required before USING}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3992.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: tkt3992.test,v 1.1 2009/07/27 10:05:06 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tkt3992-1.1 {\n  execsql {\n    CREATE TABLE parameters1(\n       mountcnt    INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),\n       version     REAL NOT NULL\n    );\n    INSERT INTO parameters1(mountcnt, version) VALUES(1, 1.0);\n\n    CREATE TABLE parameters2(\n       mountcnt    INT NOT NULL CHECK (typeof(mountcnt) == 'integer'),\n       version     REAL CHECK (typeof(version) == 'real')\n    );\n    INSERT INTO parameters2(mountcnt, version) VALUES(1, 1.0);\n  }\n} {}\n\ndo_test tkt3992-1.2 {\n  execsql {\n    UPDATE parameters1 SET mountcnt = mountcnt + 1;\n    SELECT * FROM parameters1;\n  }\n} {2 1.0}\n\ndo_test tkt3992-1.3 {\n  execsql {\n    UPDATE parameters2 SET mountcnt = mountcnt + 1;\n    SELECT * FROM parameters2;\n  }\n} {2 1.0}\n\nifcapable altertable {\n  do_test tkt3992-2.1 {\n    execsql {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      ALTER TABLE t1 ADD COLUMN c DEFAULT 3;\n      SELECT * FROM t1;\n    }\n  } {1 2 3}\n  do_test tkt3992-2.2 {\n    execsql {\n      UPDATE t1 SET a = 'one';\n      SELECT * FROM t1;\n    }\n  } {one 2 3}\n}\n\nifcapable trigger {\n  db function tcl eval\n  do_test tkt3992-2.3 {\n    execsql {\n      CREATE TABLE t2(a REAL, b REAL, c REAL);\n      INSERT INTO t2 VALUES(1, 2, 3);\n      CREATE TRIGGER tr2 BEFORE UPDATE ON t2 BEGIN\n        SELECT tcl('set res', typeof(new.c));\n      END;\n  \n      UPDATE t2 SET a = 'I';\n    }\n    set res\n  } {real}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt3997.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests to make sure #3997 is fixed.\n#\n# $Id: tkt3997.test,v 1.1 2009/07/28 13:30:31 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc reverse {lhs rhs} {\n  return [string compare $rhs $lhs]\n}\nproc usual {lhs rhs} {\n  return [string compare $lhs $rhs]\n}\n\ndb collate reverse reverse\ndb collate usual usual\n\ndo_test tkt3997-1.1 {\n  execsql {\n    create table mytext(name BLOB);\n    INSERT INTO mytext VALUES('abc');\n    INSERT INTO mytext VALUES('acd');\n    INSERT INTO mytext VALUES('afe');\n  }\n} {}\ndo_test tkt3997-1.2 {\n  execsql { \n    SELECT name \n    FROM mytext \n    ORDER BY name COLLATE reverse \n  }\n} {afe acd abc}\ndo_test tkt3997-1.3 {\n  execsql { \n    SELECT name \n    FROM (SELECT name FROM mytext)  \n    ORDER BY name COLLATE reverse \n  }\n} {afe acd abc}\n\ndo_test tkt3997-2.1 {\n  execsql { \n    CREATE TABLE mytext2(name COLLATE reverse);\n    INSERT INTO mytext2 SELECT name FROM mytext;\n  }\n} {}\ndo_test tkt3997-2.2 {\n  execsql { \n    SELECT name \n    FROM (SELECT name FROM mytext2)  \n    ORDER BY name\n  }\n} {afe acd abc}\ndo_test tkt3997-2.3 {\n  execsql { \n    SELECT name \n    FROM (SELECT name FROM mytext2)\n    ORDER BY name COLLATE usual\n  }\n} {abc acd afe}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tkt4018.test",
    "content": "# 2009 August 20\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to verify that ticket #4018 has been\n# fixed.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\ndo_not_use_codec\n\nproc testsql {sql} {\n  set fd [open tf_main.tcl w]\n  puts $fd [subst -nocommands {\n    sqlite3_test_control_pending_byte 0x0010000\n    sqlite3 db test.db\n    set rc [catch { db eval {$sql} } msg]\n    puts -nonewline \"[set rc] {[set msg]}\"\n    flush stdout\n    exit\n  }]\n  close $fd\n  set fd [open \"| [info nameofexec] ./tf_main.tcl\" r] \n  set res [read $fd]\n  close $fd\n  return $res\n}\n\ndo_test tkt4018-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    BEGIN;\n    SELECT * FROM t1;\n  }\n} {}\n\n# The database is locked by connection [db]. Open and close a second\n# connection to test.db 10000 times. If file-descriptors are not being\n# reused, then the process will quickly exceed its maximum number of\n# file descriptors (1024 by default on linux).\ndo_test tkt4018-1.2 {\n  for {set i 0} {$i < 10000} {incr i} {\n    sqlite3 db2 test.db\n    db2 close\n  }\n} {}\n\n# Now check that connection [db] is still holding a SHARED lock by\n# having a second process try to write the db.\ndo_test tkt4018-1.3 {\n  testsql {INSERT INTO t1 VALUES(3, 4)}\n} {1 {database is locked}}\n\n# Sanity checking. Have [db] release the lock and then retry the\n# INSERT from the previous test case.\ndo_test tkt4018-1.4 {\n  db eval COMMIT\n  testsql {INSERT INTO t1 VALUES(3, 4)}\n} {0 {}}\n\n# Check that reusing a file descriptor cannot change a read-only \n# connection into a read-write connection.\ndo_test tkt4018-2.1 {\n  sqlite3 db2 test.db\n  execsql {INSERT INTO t1 VALUES(1, 2)} db2\n} {}\ndo_test tkt4018-2.2 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 2 3 4}\ndo_test tkt4018-2.3 {\n  db2 close\n  sqlite3 db2 test.db -readonly 1\n  execsql COMMIT\n  catchsql {INSERT INTO t1 VALUES(5, 6)} db2\n} {1 {attempt to write a readonly database}}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tokenize.test",
    "content": "# 2008 July 7\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the tokenizer\n#\n# $Id: tokenize.test,v 1.1 2008/07/08 00:06:51 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test tokenize-1.1 {\n  catchsql {SELECT 1.0e+}\n} {1 {unrecognized token: \"1.0e\"}}\ndo_test tokenize-1.2 {\n  catchsql {SELECT 1.0E+}\n} {1 {unrecognized token: \"1.0E\"}}\ndo_test tokenize-1.3 {\n  catchsql {SELECT 1.0e-}\n} {1 {unrecognized token: \"1.0e\"}}\ndo_test tokenize-1.4 {\n  catchsql {SELECT 1.0E-}\n} {1 {unrecognized token: \"1.0E\"}}\ndo_test tokenize-1.5 {\n  catchsql {SELECT 1.0e+/}\n} {1 {unrecognized token: \"1.0e\"}}\ndo_test tokenize-1.6 {\n  catchsql {SELECT 1.0E+:}\n} {1 {unrecognized token: \"1.0E\"}}\ndo_test tokenize-1.7 {\n  catchsql {SELECT 1.0e-:}\n} {1 {unrecognized token: \"1.0e\"}}\ndo_test tokenize-1.8 {\n  catchsql {SELECT 1.0E-/}\n} {1 {unrecognized token: \"1.0E\"}}\ndo_test tokenize-1.9 {\n  catchsql {SELECT 1.0F+5}\n} {1 {unrecognized token: \"1.0F\"}}\ndo_test tokenize-1.10 {\n  catchsql {SELECT 1.0d-10}\n} {1 {unrecognized token: \"1.0d\"}}\ndo_test tokenize-1.11 {\n  catchsql {SELECT 1.0e,5}\n} {1 {unrecognized token: \"1.0e\"}}\ndo_test tokenize-1.12 {\n  catchsql {SELECT 1.0E.10}\n} {1 {unrecognized token: \"1.0E\"}}\n\ndo_test tokenize-2.1 {\n  catchsql {SELECT 1, 2 /*}\n} {1 {near \"*\": syntax error}}\ndo_test tokenize-2.2 {\n  catchsql {SELECT 1, 2 /* }\n} {0 {1 2}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tpch01.test",
    "content": "# 2013-09-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# TPC-H test queries.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix tpch01\n\ndo_execsql_test tpch01-1.0 {\n  CREATE TABLE NATION  ( N_NATIONKEY  INTEGER NOT NULL,\n                              N_NAME       CHAR(25) NOT NULL,\n                              N_REGIONKEY  INTEGER NOT NULL,\n                              N_COMMENT    VARCHAR(152));\n  CREATE TABLE REGION  ( R_REGIONKEY  INTEGER NOT NULL,\n                              R_NAME       CHAR(25) NOT NULL,\n                              R_COMMENT    VARCHAR(152));\n  CREATE TABLE PART  ( P_PARTKEY     INTEGER NOT NULL,\n                            P_NAME        VARCHAR(55) NOT NULL,\n                            P_MFGR        CHAR(25) NOT NULL,\n                            P_BRAND       CHAR(10) NOT NULL,\n                            P_TYPE        VARCHAR(25) NOT NULL,\n                            P_SIZE        INTEGER NOT NULL,\n                            P_CONTAINER   CHAR(10) NOT NULL,\n                            P_RETAILPRICE DECIMAL(15,2) NOT NULL,\n                            P_COMMENT     VARCHAR(23) NOT NULL );\n  CREATE TABLE SUPPLIER ( S_SUPPKEY     INTEGER NOT NULL,\n                               S_NAME        CHAR(25) NOT NULL,\n                               S_ADDRESS     VARCHAR(40) NOT NULL,\n                               S_NATIONKEY   INTEGER NOT NULL,\n                               S_PHONE       CHAR(15) NOT NULL,\n                               S_ACCTBAL     DECIMAL(15,2) NOT NULL,\n                               S_COMMENT     VARCHAR(101) NOT NULL);\n  CREATE TABLE PARTSUPP ( PS_PARTKEY     INTEGER NOT NULL,\n                               PS_SUPPKEY     INTEGER NOT NULL,\n                               PS_AVAILQTY    INTEGER NOT NULL,\n                               PS_SUPPLYCOST  DECIMAL(15,2)  NOT NULL,\n                               PS_COMMENT     VARCHAR(199) NOT NULL );\n  CREATE TABLE CUSTOMER ( C_CUSTKEY     INTEGER NOT NULL,\n                               C_NAME        VARCHAR(25) NOT NULL,\n                               C_ADDRESS     VARCHAR(40) NOT NULL,\n                               C_NATIONKEY   INTEGER NOT NULL,\n                               C_PHONE       CHAR(15) NOT NULL,\n                               C_ACCTBAL     DECIMAL(15,2)   NOT NULL,\n                               C_MKTSEGMENT  CHAR(10) NOT NULL,\n                               C_COMMENT     VARCHAR(117) NOT NULL);\n  CREATE TABLE ORDERS  ( O_ORDERKEY       INTEGER NOT NULL,\n                             O_CUSTKEY        INTEGER NOT NULL,\n                             O_ORDERSTATUS    CHAR(1) NOT NULL,\n                             O_TOTALPRICE     DECIMAL(15,2) NOT NULL,\n                             O_ORDERDATE      DATE NOT NULL,\n                             O_ORDERPRIORITY  CHAR(15) NOT NULL,  \n                             O_CLERK          CHAR(15) NOT NULL, \n                             O_SHIPPRIORITY   INTEGER NOT NULL,\n                             O_COMMENT        VARCHAR(79) NOT NULL);\n  CREATE TABLE LINEITEM ( L_ORDERKEY    INTEGER NOT NULL,\n                               L_PARTKEY     INTEGER NOT NULL,\n                               L_SUPPKEY     INTEGER NOT NULL,\n                               L_LINENUMBER  INTEGER NOT NULL,\n                               L_QUANTITY    DECIMAL(15,2) NOT NULL,\n                               L_EXTENDEDPRICE  DECIMAL(15,2) NOT NULL,\n                               L_DISCOUNT    DECIMAL(15,2) NOT NULL,\n                               L_TAX         DECIMAL(15,2) NOT NULL,\n                               L_RETURNFLAG  CHAR(1) NOT NULL,\n                               L_LINESTATUS  CHAR(1) NOT NULL,\n                               L_SHIPDATE    DATE NOT NULL,\n                               L_COMMITDATE  DATE NOT NULL,\n                               L_RECEIPTDATE DATE NOT NULL,\n                               L_SHIPINSTRUCT CHAR(25) NOT NULL,\n                               L_SHIPMODE     CHAR(10) NOT NULL,\n                               L_COMMENT      VARCHAR(44) NOT NULL);\n  CREATE INDEX npki on nation(N_NATIONKEY);\n  CREATE INDEX rpki on region(R_REGIONKEY);\n  CREATE INDEX ppki on part(P_PARTKEY);\n  CREATE INDEX spki on supplier(S_SUPPKEY);\n  CREATE INDEX pspki on partsupp(PS_PARTKEY, PS_SUPPKEY);\n  CREATE INDEX cpki on customer(C_CUSTKEY);\n  CREATE INDEX opki on orders(O_ORDERKEY);\n  CREATE INDEX lpki on lineitem(L_ORDERKEY, L_LINENUMBER);\n  CREATE INDEX nrki on nation(n_regionkey);\n  CREATE INDEX snki on supplier(s_nationkey);\n  CREATE INDEX cnki on customer(c_nationkey);\n  CREATE INDEX ocki on orders(O_CUSTKEY);\n  CREATE INDEX odi on orders(O_ORDERDATE);\n  CREATE INDEX lpki2 on lineitem(L_PARTKEY);\n  CREATE INDEX lski on lineitem(L_SUPPKEY);\n  CREATE INDEX lsdi on lineitem(L_SHIPDATE);\n  CREATE INDEX lcdi on lineitem(L_COMMITDATE);\n  CREATE INDEX lrdi on lineitem(L_RECEIPTDATE);\n  CREATE INDEX bootleg_nni on nation(N_NAME);\n  CREATE INDEX bootleg_psi on part(p_size);\n  CREATE INDEX bootleg_pti on part(p_type);\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lrdi','600572 236');\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lcdi','600572 244');\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lsdi','600572 238');\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lski','600572 601');\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki2','600572 31');\n  INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki','600572 5 1');\n  INSERT INTO sqlite_stat1 VALUES('ORDERS','odi','150000 63');\n  INSERT INTO sqlite_stat1 VALUES('ORDERS','ocki','150000 15');\n  INSERT INTO sqlite_stat1 VALUES('ORDERS','opki','150000 1');\n  INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cnki','15000 600');\n  INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cpki','15000 1');\n  INSERT INTO sqlite_stat1 VALUES('PARTSUPP','pspki','80000 4 1');\n  INSERT INTO sqlite_stat1 VALUES('SUPPLIER','snki','1000 40');\n  INSERT INTO sqlite_stat1 VALUES('SUPPLIER','spki','1000 1');\n  INSERT INTO sqlite_stat1 VALUES('PART','bootleg_pti','20000 134');\n  INSERT INTO sqlite_stat1 VALUES('PART','bootleg_psi','20000 400');\n  INSERT INTO sqlite_stat1 VALUES('PART','ppki','20000 1');\n  INSERT INTO sqlite_stat1 VALUES('REGION','rpki','5 1');\n  INSERT INTO sqlite_stat1 VALUES('NATION','bootleg_nni','25 1');\n  INSERT INTO sqlite_stat1 VALUES('NATION','nrki','25 5');\n  INSERT INTO sqlite_stat1 VALUES('NATION','npki','25 1');\n  ANALYZE sqlite_master;\n} {}\n\ndo_test tpch01-1.1 {\n  unset -nocomplain ::eqpres\n  set ::eqpres [db eval {EXPLAIN QUERY PLAN\n       select\n               o_year,\n               sum(case\n                       when nation = 'EGYPT' then volume\n                       else 0\n               end) / sum(volume) as mkt_share\n       from\n               (\n                       select\n                               strftime('%Y', o_orderdate) as o_year,\n                               l_extendedprice * (1 - l_discount) as volume,\n                               n2.n_name as nation\n                       from\n                               part,\n                               supplier,\n                               lineitem,\n                               orders,\n                               customer,\n                               nation n1,\n                               nation n2,\n                               region\n                       where\n                               p_partkey = l_partkey\n                               and s_suppkey = l_suppkey\n                               and l_orderkey = o_orderkey\n                               and o_custkey = c_custkey\n                               and c_nationkey = n1.n_nationkey\n                               and n1.n_regionkey = r_regionkey\n                               and r_name = 'MIDDLE EAST'\n                               and s_nationkey = n2.n_nationkey\n                               and o_orderdate between  '1995-01-01' and '1996-12-31'\n                               and p_type = 'LARGE PLATED STEEL'\n               ) as all_nations\n       group by\n               o_year\n       order by\n               o_year;}]\n  set ::eqpres\n} {/0 0 0 {SEARCH TABLE part USING INDEX bootleg_pti .P_TYPE=..} 0 1 2 {SEARCH TABLE lineitem USING INDEX lpki2 .L_PARTKEY=..}.*/}\ndo_test tpch01-1.1b {\n  set ::eqpres\n} {/.* customer .* nation AS n1 .*/}\ndo_test tpch01-1.1c {\n  set ::eqpres\n} {/.* supplier .* nation AS n2 .*/}\n\ndo_eqp_test tpch01-1.2 {\nselect\n    c_custkey,    c_name,    sum(l_extendedprice * (1 - l_discount)) as revenue,\n    c_acctbal,    n_name,    c_address,    c_phone,    c_comment\nfrom\n    customer,    orders,    lineitem,    nation\nwhere\n    c_custkey = o_custkey    and l_orderkey = o_orderkey\n    and o_orderdate >=  '1994-08-01'    and o_orderdate < date('1994-08-01', '+3 month')\n    and l_returnflag = 'R'    and c_nationkey = n_nationkey\ngroup by\n    c_custkey,    c_name,    c_acctbal,    c_phone,    n_name, c_address,    c_comment\norder by\n    revenue desc;\n} {0 0 1 {SEARCH TABLE orders USING INDEX odi (O_ORDERDATE>? AND O_ORDERDATE<?)} 0 1 0 {SEARCH TABLE customer USING INDEX cpki (C_CUSTKEY=?)} 0 2 3 {SEARCH TABLE nation USING INDEX npki (N_NATIONKEY=?)} 0 3 2 {SEARCH TABLE lineitem USING INDEX lpki (L_ORDERKEY=?)} 0 0 0 {USE TEMP B-TREE FOR GROUP BY} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trace.test",
    "content": "# 2004 Jun 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the \"sqlite3_trace()\" API.\n#\n# $Id: trace.test,v 1.8 2009/04/07 14:14:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !trace {\n  finish_test\n  return\n}\n\nset ::stmtlist {}\ndo_test trace-1.1 {\n  set rc [catch {db trace 1 2 3} msg]\n  lappend rc $msg\n} {1 {wrong # args: should be \"db trace ?CALLBACK?\"}}\nproc trace_proc cmd {\n  lappend ::stmtlist [string trim $cmd]\n}\ndo_test trace-1.2 {\n  db trace trace_proc\n  db trace\n} {trace_proc}\ndo_test trace-1.3 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    SELECT * FROM t1;\n  }\n} {1 2}\ndo_test trace-1.4 {\n  set ::stmtlist\n} {{CREATE TABLE t1(a,b);} {INSERT INTO t1 VALUES(1,2);} {SELECT * FROM t1;}}\ndo_test trace-1.5 {\n  db trace {}\n  db trace\n} {}\ndo_test trace-1.6 {\n  db eval {\n     CREATE TABLE t1b(x TEXT PRIMARY KEY, y);\n     INSERT INTO t1b VALUES('abc','def'),('ghi','jkl'),('mno','pqr');\n  }\n  set ::stmtlist {}\n  set xyzzy a*\n  db trace trace_proc\n  db eval {\n     SELECT y FROM t1b WHERE x GLOB $xyzzy\n  }\n} {def}\ndo_test trace-1.7 {\n  set ::stmtlist\n} {{SELECT y FROM t1b WHERE x GLOB 'a*'}}\ndb trace {}\n\n# If we prepare a statement and execute it multiple times, the trace\n# happens on each execution.\n#\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test trace-2.1 {\n  set STMT [sqlite3_prepare $DB {INSERT INTO t1 VALUES(2,3)} -1 TAIL]\n  db trace trace_proc\n  proc trace_proc sql {\n    global TRACE_OUT\n    lappend TRACE_OUT [string trim $sql]\n  }\n  set TRACE_OUT {}\n  sqlite3_step $STMT\n  set TRACE_OUT\n} {{INSERT INTO t1 VALUES(2,3)}}\ndo_test trace-2.2 {\n  set TRACE_OUT {}\n  sqlite3_reset $STMT\n  set TRACE_OUT \n} {}\ndo_test trace-2.3 {\n  sqlite3_step $STMT\n  set TRACE_OUT\n} {{INSERT INTO t1 VALUES(2,3)}}\ndo_test trace-2.4 {\n  set TRACE_OUT {}\n  execsql {SELECT * FROM t1}\n} {1 2 2 3 2 3}\ndo_test trace-2.5 {\n  set TRACE_OUT\n} {{SELECT * FROM t1}}\ncatch {sqlite3_finalize $STMT}\n\ndo_test trace-2.6 {\n  set TRACE_OUT {}\n  db eval VACUUM\n  set TRACE_OUT\n} {VACUUM}\n\n# Similar tests, but this time for profiling.\n# \ndo_test trace-3.1 {\n  set rc [catch {db profile 1 2 3} msg]\n  lappend rc $msg\n} {1 {wrong # args: should be \"db profile ?CALLBACK?\"}}\nset ::stmtlist {}\nproc profile_proc {cmd tm} {\n  lappend ::stmtlist [string trim $cmd]\n}\ndo_test trace-3.2 {\n  db trace {}\n  db profile profile_proc\n  db profile\n} {profile_proc}\ndo_test trace-3.3 {\n  execsql {\n    CREATE TABLE t2(a,b);\n    INSERT INTO t2 VALUES(1,2);\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test trace-3.4 {\n  set ::stmtlist\n} {{CREATE TABLE t2(a,b);} {INSERT INTO t2 VALUES(1,2);} {SELECT * FROM t2;}}\ndo_test trace-3.5 {\n  db profile {}\n  db profile\n} {}\n\n# If we prepare a statement and execute it multiple times, the profile\n# happens on each execution.\n#\ndb close\nsqlite3 db test.db; set DB [sqlite3_connection_pointer db]\ndo_test trace-4.1 {\n  set STMT [sqlite3_prepare $DB {INSERT INTO t2 VALUES(2,3)} -1 TAIL]\n  db trace trace_proc\n  proc profile_proc {sql tm} {\n    global TRACE_OUT\n    lappend TRACE_OUT [string trim $sql]\n  }\n  set TRACE_OUT {}\n  sqlite3_step $STMT\n  set TRACE_OUT\n} {{INSERT INTO t2 VALUES(2,3)}}\ndo_test trace-4.2 {\n  set TRACE_OUT {}\n  sqlite3_reset $STMT\n  set TRACE_OUT \n} {}\ndo_test trace-4.3 {\n  sqlite3_step $STMT\n  set TRACE_OUT\n} {{INSERT INTO t2 VALUES(2,3)}}\ndo_test trace-4.4 {\n  set TRACE_OUT {}\n  execsql {SELECT * FROM t1}\n} {1 2 2 3 2 3}\ndo_test trace-4.5 {\n  set TRACE_OUT\n} {{SELECT * FROM t1}}\ncatch {sqlite3_finalize $STMT}\n\n# 3.8.11: Profile output even if the statement is not run to completion.\ndo_test trace-4.6 {\n  set TRACE_OUT {}\n  db eval {SELECT * FROM t1} {} {if {$a>=1} break}\n  set TRACE_OUT\n} {{SELECT * FROM t1}}\n\n\n# Trigger tracing.\n#\nifcapable trigger {\n  do_test trace-5.1 {\n    db eval {\n      CREATE TRIGGER r1t1 AFTER UPDATE ON t1 BEGIN\n        UPDATE t2 SET a=new.a WHERE rowid=new.rowid;\n      END;\n      CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN\n        SELECT 'hello';\n      END;\n    }\n    set TRACE_OUT {}\n    proc trace_proc cmd {\n      lappend ::TRACE_OUT [string trim $cmd]\n    }\n    db eval {\n      UPDATE t1 SET a=a+1;\n    }\n    set TRACE_OUT\n  } {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}\n}\n\n# With 3.6.21, we add the ability to expand host parameters in the trace\n# output.  Test this feature.\n#\ndo_test trace-6.1 {\n  set ::t6int [expr {3+3}]\n  set ::t6real [expr {1.5*4.0}]\n  set ::t6str {test-six y'all}\n  db eval {SELECT x'3031323334' AS x} {set ::t6blob $x}\n  unset -nocomplain t6null\n  set TRACE_OUT {}\n  execsql {SELECT $::t6int, $::t6real, $t6str, $t6blob, $t6null}\n} {6 6.0 {test-six y'all} 01234 {}}\ndo_test trace-6.2 {\n  set TRACE_OUT\n} {{SELECT 6, 6.0, 'test-six y''all', x'3031323334', NULL}}\ndo_test trace-6.3 {\n  set TRACE_OUT {}\n  execsql {SELECT $::t6int, ?1, $::t6int}\n} {6 6 6}\ndo_test trace-6.4 {\n  set TRACE_OUT\n} {{SELECT 6, 6, 6}}\ndo_test trace-6.5 {\n  execsql {CREATE TABLE t6([$::t6int],\"?1\"); INSERT INTO t6 VALUES(1,2)}\n  set TRACE_OUT {}\n  execsql {SELECT '$::t6int', [$::t6int], $::t6int, ?1, \"?1\", $::t6int FROM t6}\n} {{$::t6int} 1 6 6 2 6}\ndo_test trace-6.6 {\n  set TRACE_OUT\n} {{SELECT '$::t6int', [$::t6int], 6, 6, \"?1\", 6 FROM t6}}\n\n# Do these same tests with a UTF16 database.\n#\ndo_test trace-6.100 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n     PRAGMA encoding=UTF16be;\n     CREATE TABLE t6([$::t6str],\"?1\");\n     INSERT INTO t6 VALUES(1,2);\n  }\n  db trace trace_proc\n  set TRACE_OUT {}\n  execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, \"?1\", $::t6str FROM t6}\n} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}\ndo_test trace-6.101 {\n  set TRACE_OUT\n} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', \"?1\", 'test-six y''all' FROM t6}}\n\ndo_test trace-6.200 {\n  db close\n  sqlite3 db :memory:\n  db eval {\n     PRAGMA encoding=UTF16le;\n     CREATE TABLE t6([$::t6str],\"?1\");\n     INSERT INTO t6 VALUES(1,2);\n  }\n  db trace trace_proc\n  set TRACE_OUT {}\n  execsql {SELECT '$::t6str', [$::t6str], $::t6str, ?1, \"?1\", $::t6str FROM t6}\n} {{$::t6str} 1 {test-six y'all} {test-six y'all} 2 {test-six y'all}}\ndo_test trace-6.201 {\n  set TRACE_OUT\n} {{SELECT '$::t6str', [$::t6str], 'test-six y''all', 'test-six y''all', \"?1\", 'test-six y''all' FROM t6}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trace2.test",
    "content": "# 2011 Jan 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for the \"sqlite3_trace()\" API. Specifically,\n# it tests the special handling of nested SQL statements (those executed\n# by virtual table or user function callbacks). These statements are treated\n# differently in two respects:\n#\n#   1. Each line of the statement is prefixed with \"-- \" to turn it into\n#      an SQL comment.\n#\n#   2. Parameter expansion is not performed.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !trace { finish_test ; return }\nset ::testprefix trace2\n\nproc sql {zSql} { db one $zSql }\nproc trace {zSql} { lappend ::trace $zSql }\n\ndb func sql sql\ndb trace trace\n\nproc do_trace_test {tn sql expected} {\n  # Test that the list of string passed to the trace callback when $sql\n  # is executed is equivalent to the list of strings in $expected.\n  #\n  set ::trace [list]\n  execsql $sql\n  uplevel do_test $tn [list {set ::trace}] [list [list {*}$expected]]\n}\n\nproc do_trace_select_test {tn sql expected} {\n\n  uplevel [list do_trace_test ${tn}.a $sql $expected]\n\n  # Now execute each SQL statement passed to the trace callback in the\n  # block above. Check that this causes the same set of strings to be\n  # passed to the trace callback again. i.e. that executing the output\n  # of the trace callback is equivalent to the SQL script in $sql.\n  #\n  set sqllist $::trace\n  set ::trace [list]\n  foreach item $sqllist { execsql $item }\n  uplevel do_test $tn.b [list {set ::trace}] [list $sqllist]\n}\n\ndo_trace_select_test 1.1  {\n  SELECT 1, 2, 3;\n} {\n  \"SELECT 1, 2, 3;\"\n}\n\ndo_trace_select_test 1.2  {\n  SELECT sql('SELECT 1, 2, 3');\n} {\n  \"SELECT sql('SELECT 1, 2, 3');\"\n  \"-- SELECT 1, 2, 3\"\n}\n\ndo_trace_select_test 1.3  {\n  SELECT sql('SELECT 1, \n    2, \n    3'\n  );\n} {\n  \"SELECT sql('SELECT 1, \n    2, \n    3'\n  );\"\n  \"-- SELECT 1, \n--     2, \n--     3\"\n}\n\ndo_trace_select_test 1.4  {\n  SELECT sql('SELECT 1, \n\n\n    3'\n  );\n} {\n  \"SELECT sql('SELECT 1, \n\n\n    3'\n  );\"\n  \"-- SELECT 1, \n-- \n-- \n--     3\"\n}\n\ndo_trace_select_test 1.5  {\n  SELECT $var, sql('SELECT 1, \n    $var, \n    3'\n  );\n} {\n  \"SELECT NULL, sql('SELECT 1, \n    $var, \n    3'\n  );\"\n  \"-- SELECT 1, \n--     $var, \n--     3\"\n}\n\nifcapable fts3 {\n  do_execsql_test 2.1 {\n    CREATE VIRTUAL TABLE x1 USING fts4;\n    INSERT INTO x1 VALUES('Cloudy, with a high near 16');\n    INSERT INTO x1 VALUES('Wind chill values as low as -13');\n  }\n\n  do_trace_test 2.2 {\n    INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');\n  } {\n    \"INSERT INTO x1 VALUES('North northwest wind between 8 and 14 mph');\" \n    \"-- DELETE FROM 'main'.'x1_segdir' WHERE level = ?\"\n    \"-- INSERT INTO 'main'.'x1_content' VALUES(?,(?))\" \n    \"-- REPLACE INTO 'main'.'x1_docsize' VALUES(?,?)\" \n    \"-- SELECT value FROM 'main'.'x1_stat' WHERE id=?\" \n    \"-- REPLACE INTO 'main'.'x1_stat' VALUES(?,?)\" \n    \"-- SELECT (SELECT max(idx) FROM 'main'.'x1_segdir' WHERE level = ?) + 1\" \n    \"-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)\"\n    \"-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)\"\n    \"-- SELECT level, idx, end_block FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ? ORDER BY level DESC, idx ASC\"\n  }\n\n  do_trace_test 2.3 {\n    INSERT INTO x1(x1) VALUES('optimize');\n  } {\n    \"INSERT INTO x1(x1) VALUES('optimize');\"\n    \"-- SELECT ? UNION SELECT level / (1024 * ?) FROM 'main'.'x1_segdir'\"\n    \"-- SELECT idx, start_block, leaves_end_block, end_block, root FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?ORDER BY level DESC, idx ASC\"\n    \"-- SELECT max(level) FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?\"\n    \"-- SELECT coalesce((SELECT max(blockid) FROM 'main'.'x1_segments') + 1, 1)\"\n    \"-- DELETE FROM 'main'.'x1_segdir' WHERE level BETWEEN ? AND ?\"\n    \"-- REPLACE INTO 'main'.'x1_segdir' VALUES(?,?,?,?,?,?)\"\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trace3.test",
    "content": "# 2016 July 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The focus of\n# this test file is the \"sqlite3_trace_v2()\" and \"sqlite3_expanded_sql()\"\n# APIs.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !trace { finish_test ; return }\nset ::testprefix trace3\n\nproc trace_v2_error { args } {\n  lappend ::stmtlist(error) [string trim $args]\n  error \"trace error\"; # this will be ignored.\n}\nproc trace_v2_record { args } {\n  lappend ::stmtlist(record) [string trim $args]\n}\nproc trace_v2_nop { args } {}; # do nothing.\n\ndo_test trace3-1.0 {\n  execsql {\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,NULL);\n    INSERT INTO t1 VALUES(2,-1);\n    INSERT INTO t1 VALUES(3,0);\n    INSERT INTO t1 VALUES(4,1);\n    INSERT INTO t1 VALUES(5,-2147483648);\n    INSERT INTO t1 VALUES(6,2147483647);\n    INSERT INTO t1 VALUES(7,-9223372036854775808);\n    INSERT INTO t1 VALUES(8,9223372036854775807);\n    INSERT INTO t1 VALUES(9,-1.0);\n    INSERT INTO t1 VALUES(10,0.0);\n    INSERT INTO t1 VALUES(11,1.0);\n    INSERT INTO t1 VALUES(12,'');\n    INSERT INTO t1 VALUES(13,'1');\n    INSERT INTO t1 VALUES(14,'one');\n    INSERT INTO t1 VALUES(15,x'abcd0123');\n    INSERT INTO t1 VALUES(16,x'4567cdef');\n  }\n} {}\n\ndo_test trace3-1.1 {\n  set rc [catch {db trace_v2 1 2 3} msg]\n  lappend rc $msg\n} {1 {wrong # args: should be \"db trace_v2 ?CALLBACK? ?MASK?\"}}\ndo_test trace3-1.2 {\n  set rc [catch {db trace_v2 1 bad} msg]\n  lappend rc $msg\n} {1 {bad trace type \"bad\": must be statement, profile, row, or close}}\n\ndo_test trace3-2.1 {\n  db trace_v2 trace_v2_nop\n  db trace_v2\n} {trace_v2_nop}\n\ndo_test trace3-3.1 {\n  unset -nocomplain ::stmtlist\n  db trace_v2 trace_v2_nop\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  array get ::stmtlist\n} {}\ndo_test trace3-3.2 {\n  set ::stmtlist(error) {}\n  db trace_v2 trace_v2_error\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(error)\n} {/^\\{-?\\d+ \\{SELECT a, b FROM t1 ORDER BY a;\\}\\}$/}\ndo_test trace3-3.3 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} {/^\\{-?\\d+ \\{SELECT a, b FROM t1 ORDER BY a;\\}\\}$/}\ndo_test trace3-3.4 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record statement\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} {/^\\{-?\\d+ \\{SELECT a, b FROM t1 ORDER BY a;\\}\\}$/}\ndo_test trace3-3.5 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record 1\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} {/^\\{-?\\d+ \\{SELECT a, b FROM t1 ORDER BY a;\\}\\}$/}\n\ndo_test trace3-4.1 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record profile\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} {/^\\{-?\\d+ -?\\d+\\}$/}\ndo_test trace3-4.2 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record 2\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} {/^\\{-?\\d+ -?\\d+\\}$/}\n\ndo_test trace3-5.1 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record row\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} \"/^[string trim [string repeat {-?\\d+ } 16]]\\$/\"\ndo_test trace3-5.2 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record 4\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} \"/^[string trim [string repeat {-?\\d+ } 16]]\\$/\"\n\ndo_test trace3-6.1 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record {profile row}\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} \"/^[string trim [string repeat {-?\\d+ } 16]] \\\\\\{-?\\\\d+ -?\\\\d+\\\\\\}\\$/\"\ndo_test trace3-6.2 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record {statement profile row}\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  set ::stmtlist(record)\n} \"/^\\\\\\{-?\\\\d+ \\\\\\{SELECT a, b FROM t1 ORDER BY a;\\\\\\}\\\\\\} [string trim \\\n[string repeat {-?\\d+ } 16]] \\\\\\{-?\\\\d+ -?\\\\d+\\\\\\}\\$/\"\n\ndo_test trace3-7.1 {\n  set DB [sqlite3_connection_pointer db]\n\n  set STMT [sqlite3_prepare_v2 $DB \\\n      \"SELECT a, b FROM t1 WHERE b = ? ORDER BY a;\" -1 TAIL]\n} {/^[0-9A-Fa-f]+$/}\n\ndo_test trace3-8.1 {\n  list [sqlite3_bind_null $STMT 1] [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = NULL ORDER BY a;}}\ndo_test trace3-8.2 {\n  list [sqlite3_bind_int $STMT 1 123] [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}\ndo_test trace3-8.3 {\n  list [sqlite3_bind_int64 $STMT 1 123] [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 123 ORDER BY a;}}\ndo_test trace3-8.4 {\n  list [sqlite3_bind_text $STMT 1 \"some string\" 11] \\\n      [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 'some string' ORDER BY a;}}\ndo_test trace3-8.5 {\n  list [sqlite3_bind_text $STMT 1 \"some 'bad' string\" 17] \\\n      [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 'some ''bad'' string' ORDER BY a;}}\ndo_test trace3-8.6 {\n  list [sqlite3_bind_double $STMT 1 123] [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 123.0 ORDER BY a;}}\ndo_test trace3-8.7 {\n  list [sqlite3_bind_text16 $STMT 1 \\\n      [encoding convertto unicode hi\\000yall\\000] 16] \\\n      [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = 'hi' ORDER BY a;}}\ndo_test trace3-8.8 {\n  list [sqlite3_bind_blob $STMT 1 \"\\x12\\x34\\x56\" 3] \\\n      [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = x'123456' ORDER BY a;}}\ndo_test trace3-8.9 {\n  list [sqlite3_bind_blob $STMT 1 \"\\xAB\\xCD\\xEF\" 3] \\\n      [sqlite3_expanded_sql $STMT]\n} {{} {SELECT a, b FROM t1 WHERE b = x'abcdef' ORDER BY a;}}\n\ndo_test trace3-9.1 {\n  sqlite3_finalize $STMT\n} {SQLITE_OK}\n\ndo_test trace3-10.1 {\n  db trace_v2 \"\"\n  db trace_v2\n} {}\ndo_test trace3-10.2 {\n  unset -nocomplain ::stmtlist\n  db trace_v2 \"\" {statement profile row}\n  execsql {\n    SELECT a, b FROM t1 ORDER BY a;\n  }\n  array get ::stmtlist\n} {}\n\ndo_test trace3-11.1 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record close\n  db close\n  set ::stmtlist(record)\n} {/^-?\\d+$/}\n\nreset_db\n\ndo_test trace3-11.2 {\n  set ::stmtlist(record) {}\n  db trace_v2 trace_v2_record 8\n  db close\n  set ::stmtlist(record)\n} {/^-?\\d+$/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trans.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is database locks.\n#\n# $Id: trans.test,v 1.41 2009/04/28 16:37:59 danielk1977 Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Create several tables to work with.\n#\nwal_set_journal_mode\ndo_test trans-1.0 {\n  execsql {\n    CREATE TABLE one(a int PRIMARY KEY, b text);\n    INSERT INTO one VALUES(1,'one');\n    INSERT INTO one VALUES(2,'two');\n    INSERT INTO one VALUES(3,'three');\n    SELECT b FROM one ORDER BY a;\n  }\n} {one two three}\nintegrity_check trans-1.0.1\ndo_test trans-1.1 {\n  execsql {\n    CREATE TABLE two(a int PRIMARY KEY, b text);\n    INSERT INTO two VALUES(1,'I');\n    INSERT INTO two VALUES(5,'V');\n    INSERT INTO two VALUES(10,'X');\n    SELECT b FROM two ORDER BY a;\n  }\n} {I V X}\ndo_test trans-1.9 {\n  sqlite3 altdb test.db\n  execsql {SELECT b FROM one ORDER BY a} altdb\n} {one two three}\ndo_test trans-1.10 {\n  execsql {SELECT b FROM two ORDER BY a} altdb\n} {I V X}\nintegrity_check trans-1.11\nwal_check_journal_mode trans-1.12\n\n# Basic transactions\n#\ndo_test trans-2.1 {\n  set v [catch {execsql {BEGIN}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.2 {\n  set v [catch {execsql {END}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.3 {\n  set v [catch {execsql {BEGIN TRANSACTION}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.4 {\n  set v [catch {execsql {COMMIT TRANSACTION}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.5 {\n  set v [catch {execsql {BEGIN TRANSACTION 'foo'}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.6 {\n  set v [catch {execsql {ROLLBACK TRANSACTION 'foo'}} msg]\n  lappend v $msg\n} {0 {}}\ndo_test trans-2.10 {\n  execsql {\n    BEGIN;\n    SELECT a FROM one ORDER BY a;\n    SELECT a FROM two ORDER BY a;\n    END;\n  }\n} {1 2 3 1 5 10}\nintegrity_check trans-2.11\nwal_check_journal_mode trans-2.12\n\n# Check the locking behavior\n#\ndo_test trans-3.1 {\n  execsql {\n    BEGIN;\n    UPDATE one SET a = 0 WHERE 0;\n    SELECT a FROM one ORDER BY a;\n  }\n} {1 2 3}\ndo_test trans-3.2 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\n\ndo_test trans-3.3 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test trans-3.4 {\n  catchsql {\n    INSERT INTO one VALUES(4,'four');\n  }\n} {0 {}}\ndo_test trans-3.5 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\ndo_test trans-3.6 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test trans-3.7 {\n  catchsql {\n    INSERT INTO two VALUES(4,'IV');\n  }\n} {0 {}}\ndo_test trans-3.8 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 5 10}}\ndo_test trans-3.9 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3}}\ndo_test trans-3.10 {\n  execsql {END TRANSACTION}\n} {}\n\ndo_test trans-3.11 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test trans-3.12 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\ndo_test trans-3.13 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test trans-3.14 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\nintegrity_check trans-3.15\nwal_check_journal_mode trans-3.16\n\ndo_test trans-4.1 {\n  set v [catch {execsql {\n    COMMIT;\n  } db} msg]\n  lappend v $msg\n} {1 {cannot commit - no transaction is active}}\ndo_test trans-4.2 {\n  set v [catch {execsql {\n    ROLLBACK;\n  } db} msg]\n  lappend v $msg\n} {1 {cannot rollback - no transaction is active}}\ndo_test trans-4.3 {\n  catchsql {\n    BEGIN TRANSACTION;\n    UPDATE two SET a = 0 WHERE 0;\n    SELECT a FROM two ORDER BY a;\n  } db\n} {0 {1 4 5 10}}\ndo_test trans-4.4 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 4 5 10}}\ndo_test trans-4.5 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3 4}}\ndo_test trans-4.6 {\n  catchsql {\n    BEGIN TRANSACTION;\n    SELECT a FROM one ORDER BY a;\n  } db\n} {1 {cannot start a transaction within a transaction}}\ndo_test trans-4.7 {\n  catchsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb\n} {0 {1 4 5 10}}\ndo_test trans-4.8 {\n  catchsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb\n} {0 {1 2 3 4}}\ndo_test trans-4.9 {\n  set v [catch {execsql {\n    END TRANSACTION;\n    SELECT a FROM two ORDER BY a;\n  } db} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test trans-4.10 {\n  set v [catch {execsql {\n    SELECT a FROM two ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 4 5 10}}\ndo_test trans-4.11 {\n  set v [catch {execsql {\n    SELECT a FROM one ORDER BY a;\n  } altdb} msg]\n  lappend v $msg\n} {0 {1 2 3 4}}\nintegrity_check trans-4.12\nwal_check_journal_mode trans-4.13\nwal_check_journal_mode trans-4.14 altdb\ndo_test trans-4.98 {\n  altdb close\n  execsql {\n    DROP TABLE one;\n    DROP TABLE two;\n  }\n} {}\nintegrity_check trans-4.99\n\n# Check out the commit/rollback behavior of the database\n#\ndo_test trans-5.1 {\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test trans-5.2 {\n  execsql {BEGIN TRANSACTION}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test trans-5.3 {\n  execsql {CREATE TABLE one(a text, b int)}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {one}\ndo_test trans-5.4 {\n  execsql {SELECT a,b FROM one ORDER BY b}\n} {}\ndo_test trans-5.5 {\n  execsql {INSERT INTO one(a,b) VALUES('hello', 1)}\n  execsql {SELECT a,b FROM one ORDER BY b}\n} {hello 1}\ndo_test trans-5.6 {\n  execsql {ROLLBACK}\n  execsql {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}\n} {}\ndo_test trans-5.7 {\n  set v [catch {\n    execsql {SELECT a,b FROM one ORDER BY b}\n  } msg]\n  lappend v $msg\n} {1 {no such table: one}}\n\n# Test commits and rollbacks of table CREATE TABLEs, CREATE INDEXs\n# DROP TABLEs and DROP INDEXs\n#\ndo_test trans-5.8 {\n  execsql {\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name\n  }\n} {}\ndo_test trans-5.9 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a int, b int, c int);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {t1}\ndo_test trans-5.10 {\n  execsql {\n    CREATE INDEX i1 ON t1(a);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test trans-5.11 {\n  execsql {\n    COMMIT;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test trans-5.12 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE t2(a int, b int, c int);\n    CREATE INDEX i2a ON t2(a);\n    CREATE INDEX i2b ON t2(b);\n    DROP TABLE t1;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2a i2b t2}\ndo_test trans-5.13 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test trans-5.14 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {t1}\ndo_test trans-5.15 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i1 t1}\ndo_test trans-5.16 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE TABLE t2(x int, y int, z int);\n    CREATE INDEX i2x ON t2(x);\n    CREATE INDEX i2y ON t2(y);\n    INSERT INTO t2 VALUES(1,2,3);\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test trans-5.17 {\n  execsql {\n    COMMIT;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test trans-5.18 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test trans-5.19 {\n  execsql {\n    SELECT x FROM t2 WHERE y=2;\n  }\n} {1}\ndo_test trans-5.20 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    DROP TABLE t2;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {}\ndo_test trans-5.21 {\n  set r [catch {execsql {\n    SELECT * FROM t2\n  }} msg]\n  lappend r $msg\n} {1 {no such table: t2}}\ndo_test trans-5.22 {\n  execsql {\n    ROLLBACK;\n    SELECT name fROM sqlite_master \n    WHERE type='table' OR type='index'\n    ORDER BY name;\n  }\n} {i2x i2y t1 t2}\ndo_test trans-5.23 {\n  execsql {\n    SELECT * FROM t2;\n  }\n} {1 2 3}\nintegrity_check trans-5.23\n\n\n# Try to DROP and CREATE tables and indices with the same name\n# within a transaction.  Make sure ROLLBACK works.\n#\ndo_test trans-6.1 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p,q,r);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {a 1 b 2 c 3}\ndo_test trans-6.2 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p,q,r);\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test trans-6.3 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test trans-6.4 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test trans-6.5 {\n  execsql2 {\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test trans-6.6 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test trans-6.7 {\n  catchsql {\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {1 {no such table: t1}}\n\n# Repeat on a table with an automatically generated index.\n#\ndo_test trans-6.10 {\n  execsql2 {\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p unique,q,r);\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {a 1 b 2 c 3}\ndo_test trans-6.11 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(p unique,q,r);\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {}\ndo_test trans-6.12 {\n  execsql2 {\n    INSERT INTO t1 VALUES(1,2,3);\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test trans-6.13 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test trans-6.14 {\n  execsql2 {\n    ROLLBACK;\n    SELECT * FROM t1;\n  }\n} {p 1 q 2 r 3}\ndo_test trans-6.15 {\n  execsql2 {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a unique,b,c);\n    INSERT INTO t1 VALUES(4,5,6);\n    SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n} {a 4 b 5 c 6}\ndo_test trans-6.16 {\n  catchsql {\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {1 {no such table: t1}}\n\ndo_test trans-6.20 {\n  execsql {\n    CREATE TABLE t1(a integer primary key,b,c);\n    INSERT INTO t1 VALUES(1,-2,-3);\n    INSERT INTO t1 VALUES(4,-5,-6);\n    SELECT * FROM t1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.21 {\n  execsql {\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.22 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE b<1;\n    ROLLBACK;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.23 {\n  execsql {\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.24 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\n\ndo_test trans-6.25 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE INDEX i1 ON t1(c);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.26 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.27 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.28 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\n\n# The following repeats steps 6.20 through 6.28, but puts a \"unique\"\n# constraint the first field of the table in order to generate an\n# automatic index.\n#\ndo_test trans-6.30 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    CREATE TABLE t1(a int unique,b,c);\n    COMMIT;\n    INSERT INTO t1 VALUES(1,-2,-3);\n    INSERT INTO t1 VALUES(4,-5,-6);\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.31 {\n  execsql {\n    CREATE INDEX i1 ON t1(b);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.32 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE b<1;\n    ROLLBACK;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.33 {\n  execsql {\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.34 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP TABLE t1;\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\n\ndo_test trans-6.35 {\n  execsql {\n    BEGIN TRANSACTION;\n    DROP INDEX i1;\n    CREATE INDEX i1 ON t1(c);\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.36 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.37 {\n  execsql {\n    DROP INDEX i1;\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\ndo_test trans-6.38 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM t1 WHERE b<1;\n  }\n} {4 -5 -6 1 -2 -3}\ndo_test trans-6.39 {\n  execsql {\n    SELECT * FROM t1 WHERE c<1;\n  }\n} {1 -2 -3 4 -5 -6}\nintegrity_check trans-6.40\n\n# Test to make sure rollback restores the database back to its original\n# state.\n#\ndo_test trans-7.1 {\n  execsql {BEGIN}\n  for {set i 0} {$i<1000} {incr i} {\n    set r1 [expr {rand()}]\n    set r2 [expr {rand()}]\n    set r3 [expr {rand()}]\n    execsql \"INSERT INTO t2 VALUES($r1,$r2,$r3)\"\n  }\n  execsql {COMMIT}\n  set ::checksum [execsql {SELECT md5sum(x,y,z) FROM t2}]\n  set ::checksum2 [\n    execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n  ]\n  execsql {SELECT count(*) FROM t2}\n} {1001}\ndo_test trans-7.2 {\n  execsql {SELECT md5sum(x,y,z) FROM t2}\n} $checksum\ndo_test trans-7.2.1 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\ndo_test trans-7.3 {\n  execsql {\n    BEGIN;\n    DELETE FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test trans-7.4 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT * FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test trans-7.5 {\n  execsql {\n    BEGIN;\n    DELETE FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test trans-7.6 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT * FROM t2;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test trans-7.7 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3 AS SELECT * FROM t2;\n    INSERT INTO t2 SELECT * FROM t3;\n    ROLLBACK;\n    SELECT md5sum(x,y,z) FROM t2;\n  }\n} $checksum\ndo_test trans-7.8 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test trans-7.9 {\n    execsql {\n      BEGIN;\n      CREATE TEMP TABLE t3 AS SELECT * FROM t2;\n      INSERT INTO t2 SELECT * FROM t3;\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test trans-7.10 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test trans-7.11 {\n    execsql {\n      BEGIN;\n      CREATE TEMP TABLE t3 AS SELECT * FROM t2;\n      INSERT INTO t2 SELECT * FROM t3;\n      DROP INDEX i2x;\n      DROP INDEX i2y;\n      CREATE INDEX i3a ON t3(x);\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test trans-7.12 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nifcapable tempdb {\n  do_test trans-7.13 {\n    execsql {\n      BEGIN;\n      DROP TABLE t2;\n      ROLLBACK;\n      SELECT md5sum(x,y,z) FROM t2;\n    }\n  } $checksum\n}\ndo_test trans-7.14 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nintegrity_check trans-7.15\nwal_check_journal_mode trans-7.16\n\n# Arrange for another process to begin modifying the database but abort\n# and die in the middle of the modification.  Then have this process read\n# the database.  This process should detect the journal file and roll it\n# back.  Verify that this happens correctly.\n#\nset fd [open test.tcl w]\nputs $fd {\n  sqlite3_test_control_pending_byte 0x0010000\n  sqlite3 db test.db\n  db eval {\n    PRAGMA default_cache_size=20;\n    BEGIN;\n    CREATE TABLE t3 AS SELECT * FROM t2;\n    DELETE FROM t2;\n  }\n  sqlite_abort\n}\nclose $fd\ndo_test trans-8.1 {\n  catch {exec [info nameofexec] test.tcl}\n  execsql {SELECT md5sum(x,y,z) FROM t2}\n} $checksum\ndo_test trans-8.2 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nintegrity_check trans-8.3\nset fd [open test.tcl w]\nputs $fd {\n  sqlite3_test_control_pending_byte 0x0010000\n  sqlite3 db test.db\n  db eval {\n    PRAGMA journal_mode=persist;\n    PRAGMA default_cache_size=20;\n    BEGIN;\n    CREATE TABLE t3 AS SELECT * FROM t2;\n    DELETE FROM t2;\n  }\n  sqlite_abort\n}\nclose $fd\ndo_test trans-8.4 {\n  catch {exec [info nameofexec] test.tcl}\n  execsql {SELECT md5sum(x,y,z) FROM t2}\n} $checksum\ndo_test trans-8.5 {\n  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}\n} $checksum2\nintegrity_check trans-8.6\nwal_check_journal_mode trans-8.7\n\n# In the following sequence of tests, compute the MD5 sum of the content\n# of a table, make lots of modifications to that table, then do a rollback.\n# Verify that after the rollback, the MD5 checksum is unchanged.\n#\ndo_test trans-9.1 {\n  execsql {\n    PRAGMA default_cache_size=10;\n  }\n  db close\n  sqlite3 db test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(x TEXT);\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 VALUES(randstr(10,400));\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    INSERT INTO t3 SELECT randstr(10,400) FROM t3;\n    COMMIT;\n    SELECT count(*) FROM t3;\n  }\n} {1024}\nwal_check_journal_mode trans-9.1.1\n\n# The following procedure computes a \"signature\" for table \"t3\".  If\n# T3 changes in any way, the signature should change.  \n#\n# This is used to test ROLLBACK.  We gather a signature for t3, then\n# make lots of changes to t3, then rollback and take another signature.\n# The two signatures should be the same.\n#\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(x) FROM t3}]\n}\n\n# Repeat the following group of tests 20 times for quick testing and\n# 40 times for full testing.  Each iteration of the test makes table\n# t3 a little larger, and thus takes a little longer, so doing 40 tests\n# is more than 2.0 times slower than doing 20 tests.  Considerably more.\n#\n# Also, if temporary tables are stored in memory and the test pcache\n# is in use, only 20 iterations. Otherwise the test pcache runs out\n# of page slots and SQLite reports \"out of memory\".\n#\nif {[info exists G(isquick)] || (\n  $TEMP_STORE==3 && [regexp {^pcache[[:digit:]]*$} [permutation]]\n) } {\n  set limit 20\n} elseif {[info exists G(issoak)]} {\n  set limit 100\n} else {\n  set limit 40\n}\n\n# Do rollbacks.  Make sure the signature does not change.\n#\nfor {set i 2} {$i<=$limit} {incr i} {\n  set ::sig [signature]\n  set cnt [lindex $::sig 0]\n  if {$i%2==0} {\n    execsql {PRAGMA fullfsync=ON}\n  } else {\n    execsql {PRAGMA fullfsync=OFF}\n  }\n  set sqlite_sync_count 0\n  set sqlite_fullsync_count 0\n  do_test trans-9.$i.1-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     signature\n  } $sig\n  do_test trans-9.$i.2-$cnt {\n     execsql {\n       BEGIN;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       DELETE FROM t3 WHERE random()%10!=0;\n       INSERT INTO t3 SELECT randstr(10,10)||x FROM t3;\n       ROLLBACK;\n     }\n     signature\n  } $sig\n  if {$i<$limit} {\n    do_test trans-9.$i.3-$cnt {\n       execsql {\n         INSERT INTO t3 SELECT randstr(10,400) FROM t3 WHERE random()%10==0;\n       }\n    } {}\n    catch flush_async_queue\n    if {$tcl_platform(platform)==\"unix\"} {\n      do_test trans-9.$i.4-$cnt {\n         expr {$sqlite_sync_count>0}\n      } 1\n      ifcapable pager_pragmas {\n        do_test trans-9.$i.5-$cnt {\n           expr {$sqlite_fullsync_count>0}\n        } [expr {$i%2==0}]\n      } else {\n        do_test trans-9.$i.5-$cnt {\n          expr {$sqlite_fullsync_count==0}\n        } {1}\n      }\n    }\n  }\n\n  wal_check_journal_mode trans-9.$i.6-$cnt\n  set ::pager_old_format 0\n}\n   \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trans2.test",
    "content": "# 2008 August 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is transactions\n#\n# $Id: trans2.test,v 1.1 2008/08/27 18:56:36 drh Exp $\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# A procedure to scramble the elements of list $inlist into a random order.\n#\nproc scramble {inlist} {\n  set y {}\n  foreach x $inlist {\n    lappend y [list [expr {rand()}] $x]\n  }\n  set y [lsort $y]\n  set outlist {}\n  foreach x $y {\n    lappend outlist [lindex $x 1]\n  }\n  return $outlist\n}\n\n# Generate a UUID using randomness.\n#\nexpr srand(1)\nproc random_uuid {} {\n  set u {}\n  for {set i 0} {$i<5} {incr i} {\n    append u [format %06x [expr {int(rand()*16777216)}]]\n  }\n  return $u\n}\n\n# Compute hashes on the u1 and u2 fields of the sample data.\n#\nproc hash1 {} {\n  global data\n  set x \"\"\n  foreach rec [lsort -integer -index 0 $data] {\n    append x [lindex $rec 1]\n  }\n  return [md5 $x]\n}\nproc hash2 {} {\n  global data\n  set x \"\"\n  foreach rec [lsort -integer -index 0 $data] {\n    append x [lindex $rec 3]\n  }\n  return [md5 $x]\n}\n\n# Create the initial data set\n#\nunset -nocomplain data i max_rowid todel n rec max1 id origres newres\nunset -nocomplain inssql modsql s j z\nset data {}\nfor {set i 0} {$i<400} {incr i} {\n  set rec [list $i [random_uuid] [expr {int(rand()*5000)+1000}] [random_uuid]]\n  lappend data $rec\n}\nset max_rowid [expr {$i-1}]\n\n# Create the T1 table used to hold test data.  Populate that table with\n# the initial data set and check hashes to make sure everything is correct.\n#\ndo_test trans2-1.1 {\n  execsql {\n    PRAGMA cache_size=100;\n    CREATE TABLE t1(\n      id INTEGER PRIMARY KEY,\n      u1 TEXT UNIQUE,\n      z BLOB NOT NULL,\n      u2 TEXT UNIQUE\n    );\n  }\n  foreach rec [scramble $data] {\n    foreach {id u1 z u2} $rec break\n    db eval {INSERT INTO t1 VALUES($id,$u1,zeroblob($z),$u2)}\n  }\n  db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n} [list [hash1] [hash2]]\n\n# Repeat the main test loop multiple times.\n#\nfor {set i 2} {$i<=30} {incr i} {\n  # Delete one row out of every 10 in the database.  This will add\n  # many pages to the freelist.\n  #\n  set todel {}\n  set n [expr {[llength $data]/10}]\n  set data [scramble $data]\n  foreach rec [lrange $data 0 $n] {\n    lappend todel [lindex $rec 0]\n  }\n  set data [lrange $data [expr {$n+1}] end]\n  set max1 [lindex [lindex $data 0] 0]\n  foreach rec $data {\n    set id [lindex $rec 0]\n    if {$id>$max1} {set max1 $id}\n  }\n  set origres [list [hash1] [hash2]]\n  do_test trans2-$i.1 {\n    db eval \"DELETE FROM t1 WHERE id IN ([join $todel ,])\"\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $origres\n  integrity_check trans2-$i.2\n\n  # Begin a transaction and insert many new records.\n  #\n  set newdata {}\n  foreach id $todel {\n    set rec [list $id [random_uuid] \\\n                      [expr {int(rand()*5000)+1000}] [random_uuid]]\n    lappend newdata $rec\n    lappend data $rec\n  }\n  for {set j 1} {$j<50} {incr j} {\n    set id [expr {$max_rowid+$j}]\n    lappend todel $id\n    set rec [list $id [random_uuid] \\\n                      [expr {int(rand()*5000)+1000}] [random_uuid]]\n    lappend newdata $rec\n    lappend data $rec\n  }\n  set max_rowid [expr {$max_rowid+$j-1}]\n  set modsql {}\n  set inssql {}\n  set newres [list [hash1] [hash2]]\n  do_test trans2-$i.3 {\n    db eval BEGIN\n    foreach rec [scramble $newdata] {\n      foreach {id u1 z u2} $rec break\n      set s \"INSERT INTO t1 VALUES($id,'$u1',zeroblob($z),'$u2');\"\n      append modsql $s\\n\n      append inssql $s\\n\n      db eval $s\n    }\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $newres\n  integrity_check trans2-$i.4\n\n  # Do a large update that aborts do to a constraint failure near\n  # the end.  This stresses the statement journal mechanism.\n  #\n  do_test trans2-$i.10 {\n    catchsql {\n      UPDATE t1 SET u1=u1||'x',\n          z = CASE WHEN id<$max_rowid\n                   THEN zeroblob((random()&65535)%5000 + 1000) END;\n    }\n  } {1 {NOT NULL constraint failed: t1.z}}\n  do_test trans2-$i.11 {\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $newres\n\n  # Delete all of the newly inserted records.  Verify that the database\n  # is back to its original state.\n  #\n  do_test trans2-$i.20 {\n    set s \"DELETE FROM t1 WHERE id IN ([join $todel ,]);\"\n    append modsql $s\\n\n    db eval $s\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $origres\n\n  # Do another large update that aborts do to a constraint failure near\n  # the end.  This stresses the statement journal mechanism.\n  #\n  do_test trans2-$i.30 {\n    catchsql {\n      UPDATE t1 SET u1=u1||'x',\n          z = CASE WHEN id<$max1\n                   THEN zeroblob((random()&65535)%5000 + 1000) END;\n    }\n  } {1 {NOT NULL constraint failed: t1.z}}\n  do_test trans2-$i.31 {\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $origres\n\n  # Redo the inserts\n  #\n  do_test trans2-$i.40 {\n    db eval $inssql\n    append modsql $inssql\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $newres\n\n  # Rollback the transaction.  Verify that the content is restored.\n  #\n  do_test trans2-$i.90 {\n    db eval ROLLBACK\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $origres\n  integrity_check trans2-$i.91\n\n  # Repeat all the changes, but this time commit.\n  #\n  do_test trans2-$i.92 {\n    db eval BEGIN\n    catchsql {\n      UPDATE t1 SET u1=u1||'x',\n          z = CASE WHEN id<$max1\n                   THEN zeroblob((random()&65535)%5000 + 1000) END;\n    }\n    db eval $modsql\n    catchsql {\n      UPDATE t1 SET u1=u1||'x',\n          z = CASE WHEN id<$max1\n                   THEN zeroblob((random()&65535)%5000 + 1000) END;\n    }\n    db eval COMMIT\n    db eval {SELECT md5sum(u1), md5sum(u2) FROM t1 ORDER BY id}\n  } $newres\n  integrity_check trans2-$i.93\n}\n\nunset -nocomplain data i max_rowid todel n rec max1 id origres newres\nunset -nocomplain inssql modsql s j z\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trans3.test",
    "content": "# 2008 November 3\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the response of COMMIT and ROLLBACK when\n# statements are still pending.\n#\n# $Id: trans3.test,v 1.2 2008/11/05 16:37:35 drh Exp $\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nunset -nocomplain ecode\n\ndo_test trans3-1.1 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    SELECT * FROM t1;\n  }\n} {1 2 3}\ndo_test trans3-1.2 {\n  db eval BEGIN\n  db eval {INSERT INTO t1 VALUES(4);}\n  set ::ecode {}\n  set x [catch {\n     db eval {SELECT * FROM t1 LIMIT 1} {\n        if {[catch {db eval COMMIT} errmsg]} {\n           set ::ecode [sqlite3_extended_errcode db]\n           error $errmsg\n        }\n     }\n  } errmsg]\n  lappend x $errmsg\n} {0 {}}\ndo_test trans3-1.3 {\n  set ::ecode\n} {}\ndo_test trans3-1.3.1 {\n  sqlite3_get_autocommit db\n} 1\ndo_test trans3-1.4 {\n  db eval {SELECT * FROM t1}\n} {1 2 3 4}\ndo_test trans3-1.5 {\n  db eval {BEGIN; CREATE TABLE xyzzy(abc);}\n  db eval {INSERT INTO t1 VALUES(5);}\n  set ::ecode {}\n  set x [catch {\n     db eval {SELECT * FROM t1} {\n        if {[catch {db eval ROLLBACK} errmsg]} {\n           set ::ecode [sqlite3_extended_errcode db]\n           error $errmsg\n        }\n     }\n  } errmsg]\n  lappend x $errmsg\n} {1 {abort due to ROLLBACK}}\ndo_test trans3-1.6 {\n  set ::ecode\n} {}\ndo_test trans3-1.7 {\n  db eval {SELECT * FROM t1}\n} {1 2 3 4}\nunset -nocomplain ecode\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/transitive1.test",
    "content": "# 2013 April 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#*************************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing of transitive WHERE clause constraints\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test transitive1-100 {\n  CREATE TABLE t1(a TEXT, b TEXT, c TEXT COLLATE NOCASE);\n  INSERT INTO t1 VALUES('abc','abc','Abc');\n  INSERT INTO t1 VALUES('def','def','def');\n  INSERT INTO t1 VALUES('ghi','ghi','GHI');\n  CREATE INDEX t1a1 ON t1(a);\n  CREATE INDEX t1a2 ON t1(a COLLATE nocase);\n\n  SELECT * FROM t1 WHERE a=b AND c=b AND c='DEF';\n} {def def def}\ndo_execsql_test transitive1-110 {\n  SELECT * FROM t1 WHERE a=b AND c=b AND c>='DEF' ORDER BY +a;\n} {def def def ghi ghi GHI}\ndo_execsql_test transitive1-120 {\n  SELECT * FROM t1 WHERE a=b AND c=b AND c<='DEF' ORDER BY +a;\n} {abc abc Abc def def def}\n\ndo_execsql_test transitive1-200 {\n  CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);\n  INSERT INTO t2 VALUES(100,100,100);\n  INSERT INTO t2 VALUES(20,20,20);\n  INSERT INTO t2 VALUES(3,3,3);\n\n  SELECT * FROM t2 WHERE a=b AND c=b AND c=20;\n} {20 20 20}\ndo_execsql_test transitive1-210 {\n  SELECT * FROM t2 WHERE a=b AND c=b AND c>=20 ORDER BY +a;\n} {3 3 3 20 20 20}\ndo_execsql_test transitive1-220 {\n  SELECT * FROM t2 WHERE a=b AND c=b AND c<=20 ORDER BY +a;\n} {20 20 20 100 100 100}\n\n# Test cases for ticket [[d805526eae253103] 2013-07-08\n# \"Incorrect join result or assertion fault due to transitive constraints\"\n#\ndo_execsql_test transitive1-300 {\n  CREATE TABLE t301(w INTEGER PRIMARY KEY, x);\n  CREATE TABLE t302(y INTEGER UNIQUE, z);\n  INSERT INTO t301 VALUES(1,2),(3,4),(5,6);\n  INSERT INTO t302 VALUES(1,3),(3,6),(5,7);\n  SELECT *\n    FROM t301 CROSS JOIN t302\n   WHERE w=y AND y IS NOT NULL\n   ORDER BY +w;\n} {1 2 1 3 3 4 3 6 5 6 5 7}\ndo_execsql_test transitive1-301 {\n  SELECT *\n    FROM t301 CROSS JOIN t302\n   WHERE w=y AND y IS NOT NULL\n   ORDER BY w;\n} {1 2 1 3 3 4 3 6 5 6 5 7}\ndo_execsql_test transitive1-302 {\n  SELECT *\n    FROM t301 CROSS JOIN t302\n   WHERE w IS y AND y IS NOT NULL\n   ORDER BY w;\n} {1 2 1 3 3 4 3 6 5 6 5 7}\ndo_execsql_test transitive1-310 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y>1\n   ORDER BY +w\n} {3 4 3 6 5 6 5 7}\ndo_execsql_test transitive1-311 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y>1\n   ORDER BY w\n} {3 4 3 6 5 6 5 7}\ndo_execsql_test transitive1-312 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y>1\n   ORDER BY w DESC\n} {5 6 5 7 3 4 3 6}\ndo_execsql_test transitive1-320 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y BETWEEN 2 AND 4;\n} {3 4 3 6}\ndo_execsql_test transitive1-331 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y BETWEEN 1 AND 4\n   ORDER BY w;\n} {1 2 1 3 3 4 3 6}\ndo_execsql_test transitive1-332 {\n  SELECT *\n    FROM t301 CROSS JOIN t302 ON w=y\n   WHERE y BETWEEN 1 AND 4\n   ORDER BY w DESC;\n} {3 4 3 6 1 2 1 3}\n\n# Ticket [c620261b5b5dc] circa 2013-10-28.\n# Make sure constraints are not used with LEFT JOINs.\n#\n# The next case is from the ticket report.  It outputs no rows in 3.8.1\n# prior to the bug-fix.\n#\ndo_execsql_test transitive1-400 {\n  CREATE TABLE t401(a);\n  CREATE TABLE t402(b);\n  CREATE TABLE t403(c INTEGER PRIMARY KEY);\n  INSERT INTO t401 VALUES(1);\n  INSERT INTO t403 VALUES(1);\n  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c=a;\n} {1-row}\ndo_execsql_test transitive1-401 {\n  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c=a;\n} {1-row}\ndo_execsql_test transitive1-402 {\n  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b=a JOIN t403 ON c IS a;\n} {1-row}\ndo_execsql_test transitive1-403 {\n  SELECT '1-row' FROM t401 LEFT JOIN t402 ON b IS a JOIN t403 ON c IS a;\n} {1-row}\n\n\n# The following is a script distilled from the XBMC project where the\n# bug was originally encountered.  The correct answer is a single row\n# of output.  Before the bug was fixed, zero rows were generated.\n#\ndo_execsql_test transitive1-410 {\n  CREATE TABLE bookmark ( idBookmark integer primary key, idFile integer, timeInSeconds double, totalTimeInSeconds double, thumbNailImage text, player text, playerState text, type integer);\n  CREATE TABLE path ( idPath integer primary key, strPath text, strContent text, strScraper text, strHash text, scanRecursive integer, useFolderNames bool, strSettings text, noUpdate bool, exclude bool, dateAdded text);\n  INSERT INTO \"path\" VALUES(1,'/tmp/tvshows/','tvshows','metadata.tvdb.com','989B1CE5680A14F5F86123F751169B49',0,0,'<settings><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"en\" /></settings>',0,0,NULL);\n  INSERT INTO \"path\" VALUES(2,'/tmp/tvshows/The.Big.Bang.Theory/','','','85E1DAAB2F5FF6EAE8AEDF1B5C882D1E',NULL,NULL,NULL,NULL,NULL,'2013-10-23 18:58:43');\n  CREATE TABLE files ( idFile integer primary key, idPath integer, strFilename text, playCount integer, lastPlayed text, dateAdded text);\n  INSERT INTO \"files\" VALUES(1,2,'The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv',NULL,NULL,'2013-10-23 18:57:36');\n  CREATE TABLE tvshow ( idShow integer primary key,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 text,c13 text,c14 text,c15 text,c16 text,c17 text,c18 text,c19 text,c20 text,c21 text,c22 text,c23 text);\n  INSERT INTO \"tvshow\" VALUES(1,'The Big Bang Theory','Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of \"beautiful minds\" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard''s roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.','','','9.200000','2007-09-24','<thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g13.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g23.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g18.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g17.jpg</thumb><thumb aspect=\"banner\">http://\n  thetvdb.com/banners/graphical/80379-g6.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g5.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g2.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g11.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g12.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g19.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g3.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g4.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g15.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g22.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g7.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g10.jpg</thumb><thumb\n  aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g24.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g8.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g9.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g14.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g16.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/graphical/80379-g21.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/text/80379-4.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/text/80379-2.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/text/80379-3.jpg</thumb><thumb aspect=\"banner\">http://thetvdb.com/banners/text/80379-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"0\">http://thetvdb.com/banners/seasons/80379-0-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\"\n  season=\"1\">http://thetvdb.com/banners/seasons/80379-1-12.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-9.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-11.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-9.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"7\">http://thetvdb.com/banners/seasons/80379-7-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-9.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"0\">http://thetvdb.com/banners/seasons/80379-0-2.jpg</thumb><thumb aspect=\"\n  poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-9.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-10.jpg</\n  thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"7\">http://thetvdb.com/banners/seasons/80379-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-\n  1-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"7\">http://thetvdb.com/banners/seasons/80379-7-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"0\">http://thetvdb.com/banners/seasons/80379-0.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/\n  seasons/80379-1-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-11.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-10.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://\n  thetvdb.com/banners/seasons/80379-1-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasons/80379-1-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasons/80379-3-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"6\">http://thetvdb.com/banners/seasons/80379-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasons/80379-2-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasons/80379-5-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\"\n  season=\"3\">http://thetvdb.com/banners/seasons/80379-3-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasons/80379-4-6.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"5\">http://thetvdb.com/banners/seasonswide/80379-5.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasonswide/80379-3-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasonswide/80379-1-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasonswide/80379-2-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasonswide/80379-4-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"0\">http://thetvdb.com/banners/seasonswide/80379-0.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"0\">http://thetvdb.com/banners/seasonswide/80379-0-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"1\">http://thetvdb.com/banners/seasonswide/80379-1.jpg</\n  thumb><thumb aspect=\"banner\" type=\"season\" season=\"2\">http://thetvdb.com/banners/seasonswide/80379-2.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"4\">http://thetvdb.com/banners/seasonswide/80379-4.jpg</thumb><thumb aspect=\"banner\" type=\"season\" season=\"3\">http://thetvdb.com/banners/seasonswide/80379-3.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-19.jpg</\n  thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-21.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect=\"poster\">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb\n  aspect=\"poster\">http://thetvdb.com/banners/posters/80379-5.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-22.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-18.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-13.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-10.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-16.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-1.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-9.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-2.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-19.jpg</thumb><thumb aspect=\"\n  poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-8.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-4.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-20.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-23.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-7.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-3.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-12.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-11.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-15.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-21.jpg</\n  thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-14.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-17.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-6.jpg</thumb><thumb aspect=\"poster\" type=\"season\" season=\"-1\">http://thetvdb.com/banners/posters/80379-5.jpg</thumb>','','Comedy','','<episodeguide><url cache=\"80379-en.xml\">http://thetvdb.com/api/1D62F2F90030C444/series/80379/all/en.zip</url></episodeguide>','<fanart url=\"http://thetvdb.com/banners/\"><thumb dim=\"1920x1080\" colors=\"|192,185,169|19,20,25|57,70,89|\" preview=\"_cache/fanart/original/80379-2.jpg\">fanart/original/80379-2.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|94,28,16|194,18,38|0,0,8|\" preview=\"_cache/fanart/original/80379-34.jpg\">fanart/original/80379-34.jpg</thumb><thumb dim=\"1280x720\" colors=\"|254,157,210|11,12,7|191,152,111|\" preview=\"_cache/fanart/original/80379-4.jpg\">fanart/original/80379-\n  4.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-42.jpg\">fanart/original/80379-42.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|236,187,155|136,136,128|254,254,252|\" preview=\"_cache/fanart/original/80379-37.jpg\">fanart/original/80379-37.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|112,102,152|116,109,116|235,152,146|\" preview=\"_cache/fanart/original/80379-14.jpg\">fanart/original/80379-14.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|150,158,161|174,75,121|150,98,58|\" preview=\"_cache/fanart/original/80379-16.jpg\">fanart/original/80379-16.jpg</thumb><thumb dim=\"1280x720\" colors=\"|224,200,176|11,1,28|164,96,0|\" preview=\"_cache/fanart/original/80379-1.jpg\">fanart/original/80379-1.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-35.jpg\">fanart/original/80379-35.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-40.jpg\">fanart/original/80379-40.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|255,255,255|30,19,13|155,112,70|\"\n  preview=\"_cache/fanart/original/80379-31.jpg\">fanart/original/80379-31.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|241,195,172|84,54,106|254,221,206|\" preview=\"_cache/fanart/original/80379-29.jpg\">fanart/original/80379-29.jpg</thumb><thumb dim=\"1280x720\" colors=\"|197,167,175|219,29,39|244,208,192|\" preview=\"_cache/fanart/original/80379-11.jpg\">fanart/original/80379-11.jpg</thumb><thumb dim=\"1280x720\" colors=\"|195,129,97|244,192,168|219,148,118|\" preview=\"_cache/fanart/original/80379-24.jpg\">fanart/original/80379-24.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|14,10,11|255,255,255|175,167,164|\" preview=\"_cache/fanart/original/80379-30.jpg\">fanart/original/80379-30.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-19.jpg\">fanart/original/80379-19.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|246,199,69|98,55,38|161,127,82|\" preview=\"_cache/fanart/original/80379-9.jpg\">fanart/original/80379-9.jpg</thumb><thumb dim=\"1280x720\" colors=\"|129,22,14|48,50,39|223,182,64|\" preview=\"_cache/\n  fanart/original/80379-13.jpg\">fanart/original/80379-13.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-45.jpg\">fanart/original/80379-45.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-33.jpg\">fanart/original/80379-33.jpg</thumb><thumb dim=\"1280x720\" colors=\"|103,77,60|224,180,153|129,100,84|\" preview=\"_cache/fanart/original/80379-10.jpg\">fanart/original/80379-10.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-23.jpg\">fanart/original/80379-23.jpg</thumb><thumb dim=\"1280x720\" colors=\"|219,29,39|0,4,10|88,117,135|\" preview=\"_cache/fanart/original/80379-12.jpg\">fanart/original/80379-12.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|226,209,165|51,18,9|89,54,24|\" preview=\"_cache/fanart/original/80379-5.jpg\">fanart/original/80379-5.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-26.jpg\">fanart/original/80379-26.jpg</thumb><thumb dim=\"1280x720\" colors=\"|249,251,229|126,47,53|251,226,\n  107|\" preview=\"_cache/fanart/original/80379-27.jpg\">fanart/original/80379-27.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|233,218,65|30,27,46|173,53,18|\" preview=\"_cache/fanart/original/80379-32.jpg\">fanart/original/80379-32.jpg</thumb><thumb dim=\"1280x720\" colors=\"|248,248,248|64,54,78|188,193,196|\" preview=\"_cache/fanart/original/80379-3.jpg\">fanart/original/80379-3.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-25.jpg\">fanart/original/80379-25.jpg</thumb><thumb dim=\"1280x720\" colors=\"|159,150,133|59,39,32|168,147,104|\" preview=\"_cache/fanart/original/80379-7.jpg\">fanart/original/80379-7.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|221,191,157|11,7,6|237,146,102|\" preview=\"_cache/fanart/original/80379-21.jpg\">fanart/original/80379-21.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-28.jpg\">fanart/original/80379-28.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-36.jpg\">fanart/original/80379-36.jpg</thumb><thumb\n  dim=\"1920x1080\" colors=\"|253,237,186|33,25,22|245,144,38|\" preview=\"_cache/fanart/original/80379-38.jpg\">fanart/original/80379-38.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|174,111,68|243,115,50|252,226,45|\" preview=\"_cache/fanart/original/80379-20.jpg\">fanart/original/80379-20.jpg</thumb><thumb dim=\"1920x1080\" colors=\"|63,56,123|87,59,47|63,56,123|\" preview=\"_cache/fanart/original/80379-17.jpg\">fanart/original/80379-17.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-43.jpg\">fanart/original/80379-43.jpg</thumb><thumb dim=\"1280x720\" colors=\"|69,68,161|142,118,142|222,191,137|\" preview=\"_cache/fanart/original/80379-22.jpg\">fanart/original/80379-22.jpg</thumb><thumb dim=\"1280x720\" colors=\"|1,108,206|242,209,192|250,197,163|\" preview=\"_cache/fanart/original/80379-15.jpg\">fanart/original/80379-15.jpg</thumb><thumb dim=\"1280x720\" colors=\"|239,229,237|0,0,0|167,136,115|\" preview=\"_cache/fanart/original/80379-18.jpg\">fanart/original/80379-18.jpg</thumb><thumb dim=\"1280x720\" colors=\"\"\n  preview=\"_cache/fanart/original/80379-6.jpg\">fanart/original/80379-6.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-8.jpg\">fanart/original/80379-8.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-41.jpg\">fanart/original/80379-41.jpg</thumb><thumb dim=\"1920x1080\" colors=\"\" preview=\"_cache/fanart/original/80379-44.jpg\">fanart/original/80379-44.jpg</thumb><thumb dim=\"1280x720\" colors=\"\" preview=\"_cache/fanart/original/80379-39.jpg\">fanart/original/80379-39.jpg</thumb></fanart>','80379','TV-PG','CBS','','/tmp/tvshows/The.Big.Bang.Theory/','1',NULL,NULL,NULL,NULL,NULL,NULL);\n  CREATE TABLE episode ( idEpisode integer primary key, idFile integer,c00 text,c01 text,c02 text,c03 text,c04 text,c05 text,c06 text,c07 text,c08 text,c09 text,c10 text,c11 text,c12 varchar(24),c13 varchar(24),c14 text,c15 text,c16 text,c17 varchar(24),c18 text,c19 text,c20 text,c21 text,c22 text,c23 text, idShow integer);\n  INSERT INTO \"episode\" VALUES(1,1,'Pilot','Brilliant physicist roommates Leonard and Sheldon meet their new neighbor Penny, who begins showing them that as much as they know about science, they know little about actual living.','','7.700000','Chuck Lorre / Bill Prady','2007-09-24','<thumb>http://thetvdb.com/banners/episodes/80379/332484.jpg</thumb>','',NULL,'1800','James Burrows','','1','1','','-1','-1','-1','/tmp/tvshows/The.Big.Bang.Theory/The.Big.Bang.Theory.S01E01.WEB-DL.AAC2.0.H264.mkv','2','332484',NULL,NULL,NULL,1);\n  CREATE TABLE tvshowlinkpath (idShow integer, idPath integer);\n  INSERT INTO \"tvshowlinkpath\" VALUES(1,2);\n  CREATE TABLE seasons ( idSeason integer primary key, idShow integer, season integer);\n  INSERT INTO \"seasons\" VALUES(1,1,-1);\n  INSERT INTO \"seasons\" VALUES(2,1,0);\n  INSERT INTO \"seasons\" VALUES(3,1,1);\n  INSERT INTO \"seasons\" VALUES(4,1,2);\n  INSERT INTO \"seasons\" VALUES(5,1,3);\n  INSERT INTO \"seasons\" VALUES(6,1,4);\n  INSERT INTO \"seasons\" VALUES(7,1,5);\n  INSERT INTO \"seasons\" VALUES(8,1,6);\n  INSERT INTO \"seasons\" VALUES(9,1,7);\n  CREATE TABLE art(art_id INTEGER PRIMARY KEY, media_id INTEGER, media_type TEXT, type TEXT, url TEXT);\n  INSERT INTO \"art\" VALUES(1,1,'actor','thumb','http://thetvdb.com/banners/actors/73597.jpg');\n  INSERT INTO \"art\" VALUES(2,2,'actor','thumb','http://thetvdb.com/banners/actors/73596.jpg');\n  INSERT INTO \"art\" VALUES(3,3,'actor','thumb','http://thetvdb.com/banners/actors/73595.jpg');\n  INSERT INTO \"art\" VALUES(4,4,'actor','thumb','http://thetvdb.com/banners/actors/73599.jpg');\n  INSERT INTO \"art\" VALUES(5,5,'actor','thumb','http://thetvdb.com/banners/actors/73598.jpg');\n  INSERT INTO \"art\" VALUES(6,6,'actor','thumb','http://thetvdb.com/banners/actors/283158.jpg');\n  INSERT INTO \"art\" VALUES(7,7,'actor','thumb','http://thetvdb.com/banners/actors/283157.jpg');\n  INSERT INTO \"art\" VALUES(8,8,'actor','thumb','http://thetvdb.com/banners/actors/91271.jpg');\n  INSERT INTO \"art\" VALUES(9,9,'actor','thumb','http://thetvdb.com/banners/actors/294178.jpg');\n  INSERT INTO \"art\" VALUES(10,10,'actor','thumb','http://thetvdb.com/banners/actors/283159.jpg');\n  INSERT INTO \"art\" VALUES(11,1,'tvshow','banner','http://thetvdb.com/banners/graphical/80379-g13.jpg');\n  INSERT INTO \"art\" VALUES(12,1,'tvshow','fanart','http://thetvdb.com/banners/fanart/original/80379-2.jpg');\n  INSERT INTO \"art\" VALUES(13,1,'tvshow','poster','http://thetvdb.com/banners/posters/80379-22.jpg');\n  INSERT INTO \"art\" VALUES(14,1,'season','poster','http://thetvdb.com/banners/posters/80379-22.jpg');\n  INSERT INTO \"art\" VALUES(15,2,'season','banner','http://thetvdb.com/banners/seasonswide/80379-0.jpg');\n  INSERT INTO \"art\" VALUES(16,2,'season','poster','http://thetvdb.com/banners/seasons/80379-0-4.jpg');\n  INSERT INTO \"art\" VALUES(17,3,'season','banner','http://thetvdb.com/banners/seasonswide/80379-1-2.jpg');\n  INSERT INTO \"art\" VALUES(18,3,'season','poster','http://thetvdb.com/banners/seasons/80379-1-12.jpg');\n  INSERT INTO \"art\" VALUES(19,4,'season','banner','http://thetvdb.com/banners/seasonswide/80379-2-2.jpg');\n  INSERT INTO \"art\" VALUES(20,4,'season','poster','http://thetvdb.com/banners/seasons/80379-2-11.jpg');\n  INSERT INTO \"art\" VALUES(21,5,'season','banner','http://thetvdb.com/banners/seasonswide/80379-3-2.jpg');\n  INSERT INTO \"art\" VALUES(22,5,'season','poster','http://thetvdb.com/banners/seasons/80379-3-9.jpg');\n  INSERT INTO \"art\" VALUES(23,6,'season','banner','http://thetvdb.com/banners/seasonswide/80379-4-2.jpg');\n  INSERT INTO \"art\" VALUES(24,6,'season','poster','http://thetvdb.com/banners/seasons/80379-4-8.jpg');\n  INSERT INTO \"art\" VALUES(25,7,'season','banner','http://thetvdb.com/banners/seasonswide/80379-5.jpg');\n  INSERT INTO \"art\" VALUES(26,7,'season','poster','http://thetvdb.com/banners/seasons/80379-5-9.jpg');\n  INSERT INTO \"art\" VALUES(27,8,'season','poster','http://thetvdb.com/banners/seasons/80379-6-8.jpg');\n  INSERT INTO \"art\" VALUES(28,9,'season','poster','http://thetvdb.com/banners/seasons/80379-7-3.jpg');\n  INSERT INTO \"art\" VALUES(29,1,'episode','thumb','http://thetvdb.com/banners/episodes/80379/332484.jpg');\n  CREATE INDEX ix_bookmark ON bookmark (idFile, type);\n  CREATE INDEX ix_path ON path ( strPath );\n  CREATE INDEX ix_files ON files ( idPath, strFilename );\n  CREATE UNIQUE INDEX ix_episode_file_1 on episode (idEpisode, idFile);\n  CREATE UNIQUE INDEX id_episode_file_2 on episode (idFile, idEpisode);\n  CREATE INDEX ix_episode_season_episode on episode (c12, c13);\n  CREATE INDEX ix_episode_bookmark on episode (c17);\n  CREATE INDEX ix_episode_show1 on episode(idEpisode,idShow);\n  CREATE INDEX ix_episode_show2 on episode(idShow,idEpisode);\n  CREATE UNIQUE INDEX ix_tvshowlinkpath_1 ON tvshowlinkpath ( idShow, idPath );\n  CREATE UNIQUE INDEX ix_tvshowlinkpath_2 ON tvshowlinkpath ( idPath, idShow );\n  CREATE INDEX ixEpisodeBasePath ON episode ( c19 );\n  CREATE INDEX ixTVShowBasePath on tvshow ( c17 );\n  CREATE INDEX ix_seasons ON seasons (idShow, season);\n  CREATE INDEX ix_art ON art(media_id, media_type, type);\n  CREATE VIEW episodeview\n  AS\n    SELECT episode.*,\n           files.strfilename           AS strFileName,\n           path.strpath                AS strPath,\n           files.playcount             AS playCount,\n           files.lastplayed            AS lastPlayed,\n           files.dateadded             AS dateAdded,\n           tvshow.c00                  AS strTitle,\n           tvshow.c14                  AS strStudio,\n           tvshow.c05                  AS premiered,\n           tvshow.c13                  AS mpaa,\n           tvshow.c16                  AS strShowPath,\n           bookmark.timeinseconds      AS resumeTimeInSeconds,\n           bookmark.totaltimeinseconds AS totalTimeInSeconds,\n           seasons.idseason            AS idSeason\n    FROM   episode\n           JOIN files\n             ON files.idfile = episode.idfile\n           JOIN tvshow\n             ON tvshow.idshow = episode.idshow\n           LEFT JOIN seasons\n                  ON seasons.idshow = episode.idshow\n                     AND seasons.season = episode.c12\n           JOIN path\n             ON files.idpath = path.idpath\n           LEFT JOIN bookmark\n                  ON bookmark.idfile = episode.idfile\n                     AND bookmark.type = 1; \n  CREATE VIEW tvshowview\n  AS\n    SELECT tvshow.*,\n           path.strpath                              AS strPath,\n           path.dateadded                            AS dateAdded,\n           Max(files.lastplayed)                     AS lastPlayed,\n           NULLIF(Count(episode.c12), 0)             AS totalCount,\n           Count(files.playcount)                    AS watchedcount,\n           NULLIF(Count(DISTINCT( episode.c12 )), 0) AS totalSeasons\n    FROM   tvshow\n           LEFT JOIN tvshowlinkpath\n                  ON tvshowlinkpath.idshow = tvshow.idshow\n           LEFT JOIN path\n                  ON path.idpath = tvshowlinkpath.idpath\n           LEFT JOIN episode\n                  ON episode.idshow = tvshow.idshow\n           LEFT JOIN files\n                  ON files.idfile = episode.idfile\n    GROUP  BY tvshow.idshow; \n  SELECT\n    episodeview.c12,\n    path.strPath,\n    tvshowview.c00,\n    tvshowview.c01,\n    tvshowview.c05,\n    tvshowview.c08,\n    tvshowview.c14,\n    tvshowview.c13,\n    seasons.idSeason,\n    count(1),\n    count(files.playCount)\n  FROM episodeview\n      JOIN tvshowview ON tvshowview.idShow = episodeview.idShow\n      JOIN seasons ON (seasons.idShow = tvshowview.idShow\n                       AND seasons.season = episodeview.c12)\n      JOIN files ON files.idFile = episodeview.idFile\n      JOIN tvshowlinkpath ON tvshowlinkpath.idShow = tvshowview.idShow\n      JOIN path ON path.idPath = tvshowlinkpath.idPath\n  WHERE tvshowview.idShow = 1\n  GROUP BY episodeview.c12;\n} {1 /tmp/tvshows/The.Big.Bang.Theory/ {The Big Bang Theory} {Leonard Hofstadter and Sheldon Cooper are brilliant physicists, the kind of \"beautiful minds\" that understand how the universe works. But none of that genius helps them interact with people, especially women. All this begins to change when a free-spirited beauty named Penny moves in next door. Sheldon, Leonard's roommate, is quite content spending his nights playing Klingon Boggle with their socially dysfunctional friends, fellow CalTech scientists Howard Wolowitz and Raj Koothrappali. However, Leonard sees in Penny a whole new universe of possibilities... including love.} 2007-09-24 Comedy CBS TV-PG 3 1 0}\n\n##############################################################################\n# 2015-05-18.  Make sure transitive constraints are avoided when column\n# affinities and collating sequences get in the way.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test transitive1-500 {\n  CREATE TABLE x(i INTEGER PRIMARY KEY, y TEXT);\n  INSERT INTO x VALUES(10, '10');\n  SELECT * FROM x WHERE x.y>='1' AND x.y<'2' AND x.i=x.y;\n} {10 10}\ndo_execsql_test transitive1-510 {\n  CREATE TABLE t1(x TEXT); \n  CREATE TABLE t2(y TEXT); \n  INSERT INTO t1 VALUES('abc');\n  INSERT INTO t2 VALUES('ABC');\n  SELECT * FROM t1 CROSS JOIN t2 WHERE (x=y COLLATE nocase) AND y='ABC';\n} {abc ABC}\ndo_execsql_test transitive1-520 {\n  CREATE TABLE t3(i INTEGER PRIMARY KEY, t TEXT);\n  INSERT INTO t3 VALUES(10, '10');\n  SELECT * FROM t3 WHERE i=t AND t = '10 ';\n} {}\ndo_execsql_test transitive1-530 {\n  CREATE TABLE u1(x TEXT, y INTEGER, z TEXT);\n  CREATE INDEX i1 ON u1(x);\n  INSERT INTO u1 VALUES('00013', 13, '013');\n  SELECT * FROM u1 WHERE x=y AND y=z AND z='013';\n} {00013 13 013}\ndo_execsql_test transitive1-540 {\n  CREATE TABLE b1(x, y);\n  INSERT INTO b1 VALUES('abc', 'ABC');\n  CREATE INDEX b1x ON b1(x);\n  SELECT * FROM b1 WHERE (x=y COLLATE nocase) AND y='ABC';\n} {abc ABC}\ndo_execsql_test transitive1-550 {\n  CREATE TABLE c1(x, y COLLATE nocase, z);\n  INSERT INTO c1 VALUES('ABC', 'ABC', 'abc');\n  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';\n} {ABC ABC abc}\ndo_execsql_test transitive1-560 {\n  CREATE INDEX c1x ON c1(x);\n  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';\n} {ABC ABC abc}\ndo_execsql_test transitive1-560eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM c1 WHERE x=y AND y=z AND z='abc';\n} {/SCAN TABLE c1/}\ndo_execsql_test transitive1-570 {\n  SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';\n} {}\ndo_execsql_test transitive1-570eqp {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM c1 WHERE x=y AND z=y AND z='abc';\n} {/SEARCH TABLE c1 USING INDEX c1x/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger1.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests creating and dropping triggers, and interaction thereof\n# with the database COMMIT/ROLLBACK logic.\n#\n# 1. CREATE and DROP TRIGGER tests\n# trigger1-1.1: Error if table does not exist\n# trigger1-1.2: Error if trigger already exists\n# trigger1-1.3: Created triggers are deleted if the transaction is rolled back\n# trigger1-1.4: DROP TRIGGER removes trigger\n# trigger1-1.5: Dropped triggers are restored if the transaction is rolled back\n# trigger1-1.6: Error if dropped trigger doesn't exist\n# trigger1-1.7: Dropping the table automatically drops all triggers\n# trigger1-1.8: A trigger created on a TEMP table is not inserted into sqlite_master\n# trigger1-1.9: Ensure that we cannot create a trigger on sqlite_master\n# trigger1-1.10:\n# trigger1-1.11:\n# trigger1-1.12: Ensure that INSTEAD OF triggers cannot be created on tables\n# trigger1-1.13: Ensure that AFTER triggers cannot be created on views\n# trigger1-1.14: Ensure that BEFORE triggers cannot be created on views\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !trigger||!compound {\n  finish_test\n  return\n}\n\ndo_test trigger1-1.1.1 {\n   catchsql {\n     CREATE TRIGGER trig UPDATE ON no_such_table BEGIN\n       SELECT * from sqlite_master;\n     END;\n   } \n} {1 {no such table: main.no_such_table}}\n\nifcapable tempdb {\n  do_test trigger1-1.1.2 {\n     catchsql {\n       CREATE TEMP TRIGGER trig UPDATE ON no_such_table BEGIN\n         SELECT * from sqlite_master;\n       END;\n     } \n  } {1 {no such table: no_such_table}}\n}\n\nexecsql {\n    CREATE TABLE t1(a);\n}\ndo_test trigger1-1.1.3 {\n  catchsql {\n     CREATE TRIGGER trig UPDATE ON t1 FOR EACH STATEMENT BEGIN\n        SELECT * FROM sqlite_master;\n     END;\n  }\n} {1 {near \"STATEMENT\": syntax error}}\nexecsql {\n        CREATE TRIGGER tr1 INSERT ON t1 BEGIN\n          INSERT INTO t1 values(1);\n         END;\n}\ndo_test trigger1-1.2.0 {\n    catchsql {\n        CREATE TRIGGER IF NOT EXISTS tr1 DELETE ON t1 BEGIN\n            SELECT * FROM sqlite_master;\n         END\n     }\n} {0 {}}\ndo_test trigger1-1.2.1 {\n    catchsql {\n        CREATE TRIGGER tr1 DELETE ON t1 BEGIN\n            SELECT * FROM sqlite_master;\n         END\n     }\n} {1 {trigger tr1 already exists}}\ndo_test trigger1-1.2.2 {\n    catchsql {\n        CREATE TRIGGER \"tr1\" DELETE ON t1 BEGIN\n            SELECT * FROM sqlite_master;\n         END\n     }\n} {1 {trigger \"tr1\" already exists}}\ndo_test trigger1-1.2.3 {\n    catchsql {\n        CREATE TRIGGER [tr1] DELETE ON t1 BEGIN\n            SELECT * FROM sqlite_master;\n         END\n     }\n} {1 {trigger [tr1] already exists}}\n\ndo_test trigger1-1.3 {\n    catchsql {\n        BEGIN;\n        CREATE TRIGGER tr2 INSERT ON t1 BEGIN\n            SELECT * from sqlite_master; END;\n        ROLLBACK;\n        CREATE TRIGGER tr2 INSERT ON t1 BEGIN\n            SELECT * from sqlite_master; END;\n    }\n} {0 {}}\n\ndo_test trigger1-1.4 {\n    catchsql {\n        DROP TRIGGER IF EXISTS tr1;\n        CREATE TRIGGER tr1 DELETE ON t1 BEGIN\n            SELECT * FROM sqlite_master;\n        END\n    }\n} {0 {}}\n\ndo_test trigger1-1.5 {\n    execsql {\n        BEGIN;\n        DROP TRIGGER tr2;\n        ROLLBACK;\n        DROP TRIGGER tr2;\n    }\n} {}\n\ndo_test trigger1-1.6.1 {\n    catchsql {\n        DROP TRIGGER IF EXISTS biggles;\n    }\n} {0 {}}\n\ndo_test trigger1-1.6.2 {\n    catchsql {\n        DROP TRIGGER biggles;\n    }\n} {1 {no such trigger: biggles}}\n\ndo_test trigger1-1.7 {\n    catchsql {\n        DROP TABLE t1;\n        DROP TRIGGER tr1;\n    }\n} {1 {no such trigger: tr1}}\n\nifcapable tempdb {\n  execsql {\n    CREATE TEMP TABLE temp_table(a);\n  }\n  do_test trigger1-1.8 {\n    execsql {\n          CREATE TRIGGER temp_trig UPDATE ON temp_table BEGIN\n              SELECT * from sqlite_master;\n          END;\n          SELECT count(*) FROM sqlite_master WHERE name = 'temp_trig';\n    } \n  } {0}\n}\n\ndo_test trigger1-1.9 {\n  catchsql {\n    CREATE TRIGGER tr1 AFTER UPDATE ON sqlite_master BEGIN\n       SELECT * FROM sqlite_master;\n    END;\n  }\n} {1 {cannot create trigger on system table}}\n\n# Check to make sure that a DELETE statement within the body of\n# a trigger does not mess up the DELETE that caused the trigger to\n# run in the first place.\n#\ndo_test trigger1-1.10 {\n  execsql {\n    create table t1(a,b);\n    insert into t1 values(1,'a');\n    insert into t1 values(2,'b');\n    insert into t1 values(3,'c');\n    insert into t1 values(4,'d');\n    create trigger r1 after delete on t1 for each row begin\n      delete from t1 WHERE a=old.a+2;\n    end;\n    delete from t1 where a=1 OR a=3;\n    select * from t1;\n    drop table t1;\n  }\n} {2 b 4 d}\n\ndo_test trigger1-1.11 {\n  execsql {\n    create table t1(a,b);\n    insert into t1 values(1,'a');\n    insert into t1 values(2,'b');\n    insert into t1 values(3,'c');\n    insert into t1 values(4,'d');\n    create trigger r1 after update on t1 for each row begin\n      delete from t1 WHERE a=old.a+2;\n    end;\n    update t1 set b='x-' || b where a=1 OR a=3;\n    select * from t1;\n    drop table t1;\n  }\n} {1 x-a 2 b 4 d}\n\n# Ensure that we cannot create INSTEAD OF triggers on tables\ndo_test trigger1-1.12 {\n  catchsql {\n    create table t1(a,b);\n    create trigger t1t instead of update on t1 for each row begin\n      delete from t1 WHERE a=old.a+2;\n    end;\n  }\n} {1 {cannot create INSTEAD OF trigger on table: t1}}\n\nifcapable view {\n# Ensure that we cannot create BEFORE triggers on views\ndo_test trigger1-1.13 {\n  catchsql {\n    create view v1 as select * from t1;\n    create trigger v1t before update on v1 for each row begin\n      delete from t1 WHERE a=old.a+2;\n    end;\n  }\n} {1 {cannot create BEFORE trigger on view: v1}}\n# Ensure that we cannot create AFTER triggers on views\ndo_test trigger1-1.14 {\n  catchsql {\n    drop view v1;\n    create view v1 as select * from t1;\n    create trigger v1t AFTER update on v1 for each row begin\n      delete from t1 WHERE a=old.a+2;\n    end;\n  }\n} {1 {cannot create AFTER trigger on view: v1}}\n} ;# ifcapable view\n\n# Check for memory leaks in the trigger parser\n#\ndo_test trigger1-2.1 {\n  catchsql {\n    CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN\n      SELECT * FROM;  -- Syntax error\n    END;\n  }\n} {1 {near \";\": syntax error}}\ndo_test trigger1-2.2 {\n  catchsql {\n    CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN\n      SELECT * FROM t1;\n      SELECT * FROM;  -- Syntax error\n    END;\n  }\n} {1 {near \";\": syntax error}}\n\n# Create a trigger that refers to a table that might not exist.\n#\nifcapable tempdb {\n  do_test trigger1-3.1 {\n    execsql {\n      CREATE TEMP TABLE t2(x,y);\n    }\n    catchsql {\n      CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(NEW.a,NEW.b);\n      END;\n    }\n  } {0 {}}\n  do_test trigger1-3.2 {\n    catchsql {\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {1 {no such table: main.t2}}\n  do_test trigger1-3.3 {\n    db close\n    set rc [catch {sqlite3 db test.db} err]\n    if {$rc} {lappend rc $err}\n    set rc\n  } {0}\n  do_test trigger1-3.4 {\n    catchsql {\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {1 {no such table: main.t2}}\n  do_test trigger1-3.5 {\n    catchsql {\n      CREATE TEMP TABLE t2(x,y);\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {1 {no such table: main.t2}}\n  do_test trigger1-3.6.1 {\n    catchsql {\n      DROP TRIGGER r1;\n      CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(NEW.a,NEW.b), (NEW.b*100, NEW.a*100);\n      END;\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {0 {1 2 200 100}}\n  do_test trigger1-3.6.2 {\n    catchsql {\n      DROP TRIGGER r1;\n      DELETE FROM t1;\n      DELETE FROM t2;\n      CREATE TEMP TRIGGER r1 AFTER INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(NEW.a,NEW.b);\n      END;\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t2;\n    }\n  } {0 {1 2}}\n  do_test trigger1-3.7 {\n    execsql {\n      DROP TABLE t2;\n      CREATE TABLE t2(x,y);\n      SELECT * FROM t2;\n    }\n  } {}\n\n  # There are two versions of trigger1-3.8 and trigger1-3.9. One that uses\n  # compound SELECT statements, and another that does not.\n  ifcapable compound {\n  do_test trigger1-3.8 {\n    execsql {\n      INSERT INTO t1 VALUES(3,4);\n      SELECT * FROM t1 UNION ALL SELECT * FROM t2;\n    }\n  } {1 2 3 4 3 4}\n  do_test trigger1-3.9 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      INSERT INTO t1 VALUES(5,6);\n      SELECT * FROM t1 UNION ALL SELECT * FROM t2;\n    }\n  } {1 2 3 4 5 6 3 4}\n  } ;# ifcapable compound\n  ifcapable !compound {\n  do_test trigger1-3.8 {\n    execsql {\n      INSERT INTO t1 VALUES(3,4);\n      SELECT * FROM t1; \n      SELECT * FROM t2;\n    }\n  } {1 2 3 4 3 4}\n  do_test trigger1-3.9 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      INSERT INTO t1 VALUES(5,6);\n      SELECT * FROM t1;\n      SELECT * FROM t2;\n    }\n  } {1 2 3 4 5 6 3 4}\n  } ;# ifcapable !compound\n\n  do_test trigger1-4.1 {\n    execsql {\n      CREATE TEMP TRIGGER r1 BEFORE INSERT ON t1 BEGIN\n        INSERT INTO t2 VALUES(NEW.a,NEW.b);\n      END;\n      INSERT INTO t1 VALUES(7,8);\n      SELECT * FROM t2;\n    }\n  } {3 4 7 8}\n  do_test trigger1-4.2 {\n    sqlite3 db2 test.db\n    execsql {\n      INSERT INTO t1 VALUES(9,10);\n    } db2;\n    db2 close\n    execsql {\n      SELECT * FROM t2;\n    }\n  } {3 4 7 8}\n  do_test trigger1-4.3 {\n    execsql {\n      DROP TABLE t1;\n      SELECT * FROM t2;\n    };\n  } {3 4 7 8}\n  do_test trigger1-4.4 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      SELECT * FROM t2;\n    };\n  } {3 4 7 8}\n} else {\n  execsql {\n    CREATE TABLE t2(x,y);\n    DROP TABLE t1;\n    INSERT INTO t2 VALUES(3, 4);\n    INSERT INTO t2 VALUES(7, 8);\n  }\n}\n\n\nintegrity_check trigger1-5.1\n\n# Create a trigger with the same name as a table.  Make sure the\n# trigger works.  Then drop the trigger.  Make sure the table is\n# still there.\n#\nset view_v1 {}\nifcapable view {\n  set view_v1 {view v1}\n}\ndo_test trigger1-6.1 {\n  execsql {SELECT type, name FROM sqlite_master}\n} [concat $view_v1 {table t2}]\ndo_test trigger1-6.2 {\n  execsql {\n    CREATE TRIGGER t2 BEFORE DELETE ON t2 BEGIN\n      SELECT RAISE(ABORT,'deletes are not permitted');\n    END;\n    SELECT type, name FROM sqlite_master;\n  }\n} [concat $view_v1 {table t2 trigger t2}]\ndo_test trigger1-6.3 {\n  catchsql {DELETE FROM t2}\n} {1 {deletes are not permitted}}\nverify_ex_errcode trigger1-6.3b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger1-6.4 {\n  execsql {SELECT * FROM t2}\n} {3 4 7 8}\ndo_test trigger1-6.5 {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT type, name FROM sqlite_master}\n} [concat $view_v1 {table t2 trigger t2}]\ndo_test trigger1-6.6 {\n  execsql {\n    DROP TRIGGER t2;\n    SELECT type, name FROM sqlite_master;\n  }\n} [concat $view_v1 {table t2}]\ndo_test trigger1-6.7 {\n  execsql {SELECT * FROM t2}\n} {3 4 7 8}\ndo_test trigger1-6.8 {\n  db close\n  sqlite3 db test.db\n  execsql {SELECT * FROM t2}\n} {3 4 7 8}\n\nintegrity_check trigger1-7.1\n\n# Check to make sure the name of a trigger can be quoted so that keywords\n# can be used as trigger names.  Ticket #468\n#\ndo_test trigger1-8.1 {\n  execsql {\n    CREATE TRIGGER 'trigger' AFTER INSERT ON t2 BEGIN SELECT 1; END;\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {trigger}\ndo_test trigger1-8.2 {\n  execsql {\n    DROP TRIGGER 'trigger';\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {}\ndo_test trigger1-8.3 {\n  execsql {\n    CREATE TRIGGER \"trigger\" AFTER INSERT ON t2 BEGIN SELECT 1; END;\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {trigger}\ndo_test trigger1-8.4 {\n  execsql {\n    DROP TRIGGER \"trigger\";\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {}\ndo_test trigger1-8.5 {\n  execsql {\n    CREATE TRIGGER [trigger] AFTER INSERT ON t2 BEGIN SELECT 1; END;\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {trigger}\ndo_test trigger1-8.6 {\n  execsql {\n    DROP TRIGGER [trigger];\n    SELECT name FROM sqlite_master WHERE type='trigger';\n  }\n} {}\n\nifcapable conflict {\n  # Make sure REPLACE works inside of triggers.\n  #\n  # There are two versions of trigger1-9.1 and trigger1-9.2. One that uses\n  # compound SELECT statements, and another that does not.\n  ifcapable compound {\n    do_test trigger1-9.1 {\n      execsql {\n        CREATE TABLE t3(a,b);\n        CREATE TABLE t4(x UNIQUE, b);\n        CREATE TRIGGER r34 AFTER INSERT ON t3 BEGIN\n          REPLACE INTO t4 VALUES(new.a,new.b);\n        END;\n        INSERT INTO t3 VALUES(1,2);\n        SELECT * FROM t3 UNION ALL SELECT 99, 99 UNION ALL SELECT * FROM t4;\n      }\n    } {1 2 99 99 1 2}\n    do_test trigger1-9.2 {\n      execsql {\n        INSERT INTO t3 VALUES(1,3);\n        SELECT * FROM t3 UNION ALL SELECT 99, 99 UNION ALL SELECT * FROM t4;\n      }\n    } {1 2 1 3 99 99 1 3}\n  } else {\n    do_test trigger1-9.1 {\n      execsql {\n        CREATE TABLE t3(a,b);\n        CREATE TABLE t4(x UNIQUE, b);\n        CREATE TRIGGER r34 AFTER INSERT ON t3 BEGIN\n          REPLACE INTO t4 VALUES(new.a,new.b);\n        END;\n        INSERT INTO t3 VALUES(1,2);\n        SELECT * FROM t3; SELECT 99, 99; SELECT * FROM t4;\n      }\n    } {1 2 99 99 1 2}\n    do_test trigger1-9.2 {\n      execsql {\n        INSERT INTO t3 VALUES(1,3);\n        SELECT * FROM t3; SELECT 99, 99; SELECT * FROM t4;\n      }\n    } {1 2 1 3 99 99 1 3}\n  }\n  execsql {\n    DROP TABLE t3;\n    DROP TABLE t4;\n  }\n}\n\n\n# Ticket #764. At one stage TEMP triggers would fail to re-install when the\n# schema was reloaded. The following tests ensure that TEMP triggers are\n# correctly re-installed.\n#\n# Also verify that references within trigger programs are resolved at\n# statement compile time, not trigger installation time. This means, for\n# example, that you can drop and re-create tables referenced by triggers. \nifcapable tempdb&&attach {\n  do_test trigger1-10.0 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' AS aux;\n    }\n  } {}\n  do_test trigger1-10.1 {\n    execsql {\n      CREATE TABLE main.t4(a, b, c);\n      CREATE TABLE temp.t4(a, b, c);\n      CREATE TABLE aux.t4(a, b, c);\n      CREATE TABLE insert_log(db, a, b, c);\n    }\n  } {}\n  do_test trigger1-10.2 {\n    execsql {\n      CREATE TEMP TRIGGER trig1 AFTER INSERT ON main.t4 BEGIN \n        INSERT INTO insert_log VALUES('main', new.a, new.b, new.c);\n      END;\n      CREATE TEMP TRIGGER trig2 AFTER INSERT ON temp.t4 BEGIN \n        INSERT INTO insert_log VALUES('temp', new.a, new.b, new.c);\n      END;\n      CREATE TEMP TRIGGER trig3 AFTER INSERT ON aux.t4 BEGIN \n        INSERT INTO insert_log VALUES('aux', new.a, new.b, new.c);\n      END;\n    }\n  } {}\n  do_test trigger1-10.3 {\n    execsql {\n      INSERT INTO main.t4 VALUES(1, 2, 3);\n      INSERT INTO temp.t4 VALUES(4, 5, 6);\n      INSERT INTO aux.t4  VALUES(7, 8, 9);\n    }\n  } {}\n  do_test trigger1-10.4 {\n    execsql {\n      SELECT * FROM insert_log;\n    }\n  } {main 1 2 3 temp 4 5 6 aux 7 8 9}\n  do_test trigger1-10.5 {\n    execsql {\n      BEGIN;\n      INSERT INTO main.t4 VALUES(1, 2, 3);\n      INSERT INTO temp.t4 VALUES(4, 5, 6);\n      INSERT INTO aux.t4  VALUES(7, 8, 9);\n      ROLLBACK;\n    }\n  } {}\n  do_test trigger1-10.6 {\n    execsql {\n      SELECT * FROM insert_log;\n    }\n  } {main 1 2 3 temp 4 5 6 aux 7 8 9}\n  do_test trigger1-10.7 {\n    execsql {\n      DELETE FROM insert_log;\n      INSERT INTO main.t4 VALUES(11, 12, 13);\n      INSERT INTO temp.t4 VALUES(14, 15, 16);\n      INSERT INTO aux.t4  VALUES(17, 18, 19);\n    }\n  } {}\n  do_test trigger1-10.8 {\n    execsql {\n      SELECT * FROM insert_log;\n    }\n  } {main 11 12 13 temp 14 15 16 aux 17 18 19}\n  do_test trigger1-10.9 {\n  # Drop and re-create the insert_log table in a different database. Note\n  # that we can change the column names because the trigger programs don't\n  # use them explicitly.\n    execsql {\n      DROP TABLE insert_log;\n      CREATE TABLE aux.insert_log(db, d, e, f);\n    }\n  } {}\n  do_test trigger1-10.10 {\n    execsql {\n      INSERT INTO main.t4 VALUES(21, 22, 23);\n      INSERT INTO temp.t4 VALUES(24, 25, 26);\n      INSERT INTO aux.t4  VALUES(27, 28, 29);\n    }\n  } {}\n  do_test trigger1-10.11 {\n    execsql {\n      SELECT * FROM insert_log;\n    }\n  } {main 21 22 23 temp 24 25 26 aux 27 28 29}\n}\n\ndo_test trigger1-11.1 {\n  catchsql {SELECT raise(abort,'message');}\n} {1 {RAISE() may only be used within a trigger-program}}\n\ndo_test trigger1-15.1 {\n  execsql {\n    CREATE TABLE tA(a INTEGER PRIMARY KEY, b, c);\n    CREATE TRIGGER tA_trigger BEFORE UPDATE ON \"tA\" BEGIN SELECT 1; END;\n    INSERT INTO tA VALUES(1, 2, 3);\n  }\n  catchsql { UPDATE tA SET a = 'abc' }\n} {1 {datatype mismatch}}\ndo_test trigger1-15.2 {\n  catchsql { INSERT INTO tA VALUES('abc', 2, 3) }\n} {1 {datatype mismatch}}\n\n# Ticket #3947:  Do not allow qualified table names on INSERT, UPDATE, and\n# DELETE statements within triggers.  Actually, this has never been allowed\n# by the grammar.  But the error message is confusing: one simply gets a\n# \"syntax error\".  That has now been changed to give a full error message.\n#\ndo_test trigger1-16.1 {\n  db eval {\n    CREATE TABLE t16(a,b,c);\n    CREATE INDEX t16a ON t16(a);\n    CREATE INDEX t16b ON t16(b);\n  }\n  catchsql {\n    CREATE TRIGGER main.t16err1 AFTER INSERT ON tA BEGIN\n      INSERT INTO main.t16 VALUES(1,2,3);\n    END;\n  }\n} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}\ndo_test trigger1-16.2 {\n  catchsql {\n    CREATE TRIGGER main.t16err2 AFTER INSERT ON tA BEGIN\n      UPDATE main.t16 SET rowid=rowid+1;\n    END;\n  }\n} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}\ndo_test trigger1-16.3 {\n  catchsql {\n    CREATE TRIGGER main.t16err3 AFTER INSERT ON tA BEGIN\n      DELETE FROM main.t16;\n    END;\n  }\n} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}\ndo_test trigger1-16.4 {\n  catchsql {\n    CREATE TRIGGER main.t16err4 AFTER INSERT ON tA BEGIN\n      UPDATE t16 NOT INDEXED SET rowid=rowid+1;\n    END;\n  }\n} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}\ndo_test trigger1-16.5 {\n  catchsql {\n    CREATE TRIGGER main.t16err5 AFTER INSERT ON tA BEGIN\n      UPDATE t16 INDEXED BY t16a SET rowid=rowid+1 WHERE a=1;\n    END;\n  }\n} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}\ndo_test trigger1-16.6 {\n  catchsql {\n    CREATE TRIGGER main.t16err6 AFTER INSERT ON tA BEGIN\n      DELETE FROM t16 NOT INDEXED WHERE a=123;\n    END;\n  }\n} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}\ndo_test trigger1-16.7 {\n  catchsql {\n    CREATE TRIGGER main.t16err7 AFTER INSERT ON tA BEGIN\n      DELETE FROM t16 INDEXED BY t16a WHERE a=123;\n    END;\n  }\n} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}\n\n#-------------------------------------------------------------------------\n# Test that bug [34cd55d68e0e6e7c] has been fixed.\n#\ndo_execsql_test trigger1-17.0 {\n  CREATE TABLE t17a(ii INT);\n  CREATE TABLE t17b(tt TEXT PRIMARY KEY, ss);\n  CREATE TRIGGER t17a_ai AFTER INSERT ON t17a BEGIN\n    INSERT INTO t17b(tt) VALUES(new.ii);\n  END;\n  CREATE TRIGGER t17b_ai AFTER INSERT ON t17b BEGIN\n    UPDATE t17b SET ss = 4;\n  END;\n  INSERT INTO t17a(ii) VALUES('1');\n  PRAGMA integrity_check;\n} {ok}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger2.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Regression testing of FOR EACH ROW table triggers\n#\n# 1. Trigger execution order tests. \n# These tests ensure that BEFORE and AFTER triggers are fired at the correct\n# times relative to each other and the triggering statement. \n#\n# trigger2-1.1.*: ON UPDATE trigger execution model.\n# trigger2-1.2.*: DELETE trigger execution model.\n# trigger2-1.3.*: INSERT trigger execution model.\n#\n# 2. Trigger program execution tests.\n# These tests ensure that trigger programs execute correctly (ie. that a\n# trigger program can correctly execute INSERT, UPDATE, DELETE * SELECT\n# statements, and combinations thereof).\n#\n# 3. Selective trigger execution \n# This tests that conditional triggers (ie. UPDATE OF triggers and triggers\n# with WHEN clauses) are fired only fired when they are supposed to be.\n#\n# trigger2-3.1: UPDATE OF triggers\n# trigger2-3.2: WHEN clause\n#\n# 4. Cascaded trigger execution \n# Tests that trigger-programs may cause other triggers to fire. Also that a \n# trigger-program is never executed recursively.\n# \n# trigger2-4.1: Trivial cascading trigger\n# trigger2-4.2: Trivial recursive trigger handling \n#\n# 5. Count changes behaviour.\n# Verify that rows altered by triggers are not included in the return value\n# of the \"count changes\" interface.\n#\n# 6. ON CONFLICT clause handling\n# trigger2-6.1[a-f]: INSERT statements\n# trigger2-6.2[a-f]: UPDATE statements\n#\n# 7. & 8. Triggers on views fire correctly.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# The tests in this file were written before SQLite supported recursive\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\n# 1.\nifcapable subquery {\n  set ii 0\n  set tbl_definitions [list \\\n  \t{CREATE TABLE tbl (a, b);}                                      \\\n  \t{CREATE TABLE tbl (a INTEGER PRIMARY KEY, b);}                  \\\n        {CREATE TABLE tbl (a, b PRIMARY KEY);}                          \\\n  \t{CREATE TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);}      \\\n  ]\n  ifcapable tempdb {\n    lappend tbl_definitions \\\n        {CREATE TEMP TABLE tbl (a, b); CREATE INDEX tbl_idx ON tbl(b);} \n    lappend tbl_definitions {CREATE TEMP TABLE tbl (a, b);}\n    lappend tbl_definitions \\\n        {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b);}\n  }\n  foreach tbl_defn $tbl_definitions {\n    incr ii\n    catchsql { DROP INDEX tbl_idx; }\n    catchsql {\n      DROP TABLE rlog;\n      DROP TABLE clog;\n      DROP TABLE tbl;\n      DROP TABLE other_tbl;\n    }\n  \n    execsql $tbl_defn\n  \n    execsql {\n      INSERT INTO tbl VALUES(1, 2);\n      INSERT INTO tbl VALUES(3, 4);\n  \n      CREATE TABLE rlog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);\n      CREATE TABLE clog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);\n  \n      CREATE TRIGGER before_update_row BEFORE UPDATE ON tbl FOR EACH ROW \n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER after_update_row AFTER UPDATE ON tbl FOR EACH ROW \n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER conditional_update_row AFTER UPDATE ON tbl FOR EACH ROW\n        WHEN old.a = 1\n        BEGIN\n        INSERT INTO clog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM clog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n    }\n  \n    do_test trigger2-1.$ii.1 {\n      set r {}\n      foreach v [execsql { \n        UPDATE tbl SET a = a * 10, b = b * 10;\n        SELECT * FROM rlog ORDER BY idx;\n        SELECT * FROM clog ORDER BY idx;\n      }] {\n        lappend r [expr {int($v)}]\n      }\n      set r\n    } [list 1 1 2  4  6 10 20 \\\n            2 1 2 13 24 10 20 \\\n  \t    3 3 4 13 24 30 40 \\\n  \t    4 3 4 40 60 30 40 \\\n            1 1 2 13 24 10 20 ]\n  \n    execsql {\n      DELETE FROM rlog;\n      DELETE FROM tbl;\n      INSERT INTO tbl VALUES (100, 100);\n      INSERT INTO tbl VALUES (300, 200);\n      CREATE TRIGGER delete_before_row BEFORE DELETE ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  0, 0);\n      END;\n  \n      CREATE TRIGGER delete_after_row AFTER DELETE ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  0, 0);\n      END;\n    }\n    do_test trigger2-1.$ii.2 {\n      set r {}\n      foreach v [execsql {\n        DELETE FROM tbl;\n        SELECT * FROM rlog;\n      }] {\n        lappend r [expr {int($v)}]\n      }\n      set r\n    } [list 1 100 100 400 300 0 0 \\\n            2 100 100 300 200 0 0 \\\n            3 300 200 300 200 0 0 \\\n            4 300 200 0 0 0 0 ]\n  \n    execsql {\n      DELETE FROM rlog;\n      CREATE TRIGGER insert_before_row BEFORE INSERT ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  0, 0,\n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER insert_after_row AFTER INSERT ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  0, 0,\n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n    }\n    do_test trigger2-1.$ii.3 {\n      execsql {\n  \n        CREATE TABLE other_tbl(a, b);\n        INSERT INTO other_tbl VALUES(1, 2);\n        INSERT INTO other_tbl VALUES(3, 4);\n        -- INSERT INTO tbl SELECT * FROM other_tbl;\n        INSERT INTO tbl VALUES(5, 6);\n        DROP TABLE other_tbl;\n  \n        SELECT * FROM rlog;\n      }\n    } [list 1 0 0 0 0 5 6 \\\n            2 0 0 5 6 5 6 ]\n  \n    integrity_check trigger2-1.$ii.4\n  }\n  catchsql {\n    DROP TABLE rlog;\n    DROP TABLE clog;\n    DROP TABLE tbl;\n    DROP TABLE other_tbl;\n  }\n}\n\n# 2.\nset ii 0\nforeach tr_program {\n  {UPDATE tbl SET b = old.b;}\n  {INSERT INTO log VALUES(new.c, 2, 3);}\n  {DELETE FROM log WHERE a = 1;}\n  {INSERT INTO tbl VALUES(500, new.b * 10, 700); \n    UPDATE tbl SET c = old.c; \n    DELETE FROM log;}\n  {INSERT INTO log select * from tbl;} \n} {\n  foreach test_varset [ list \\\n    {\n      set statement {UPDATE tbl SET c = 10 WHERE a = 1;} \n      set prep      {INSERT INTO tbl VALUES(1, 2, 3);}\n      set newC 10\n      set newB 2\n      set newA 1\n      set oldA 1\n      set oldB 2\n      set oldC 3\n    } \\\n    {\n      set statement {DELETE FROM tbl WHERE a = 1;}\n      set prep      {INSERT INTO tbl VALUES(1, 2, 3);}\n      set oldA 1\n      set oldB 2\n      set oldC 3\n    } \\\n    {\n      set statement {INSERT INTO tbl VALUES(1, 2, 3);}\n      set newA 1\n      set newB 2\n      set newC 3\n    }\n  ] \\\n  {\n    set statement {}\n    set prep {}\n    set newA {''}\n    set newB {''}\n    set newC {''}\n    set oldA {''}\n    set oldB {''}\n    set oldC {''}\n\n    incr ii\n\n    eval $test_varset\n\n    set statement_type [string range $statement 0 5]\n    set tr_program_fixed $tr_program\n    if {$statement_type == \"DELETE\"} {\n      regsub -all new\\.a $tr_program_fixed {''} tr_program_fixed \n      regsub -all new\\.b $tr_program_fixed {''} tr_program_fixed \n      regsub -all new\\.c $tr_program_fixed {''} tr_program_fixed \n    }\n    if {$statement_type == \"INSERT\"} {\n      regsub -all old\\.a $tr_program_fixed {''} tr_program_fixed \n      regsub -all old\\.b $tr_program_fixed {''} tr_program_fixed \n      regsub -all old\\.c $tr_program_fixed {''} tr_program_fixed \n    }\n\n\n    set tr_program_cooked $tr_program\n    regsub -all new\\.a $tr_program_cooked $newA tr_program_cooked \n    regsub -all new\\.b $tr_program_cooked $newB tr_program_cooked \n    regsub -all new\\.c $tr_program_cooked $newC tr_program_cooked \n    regsub -all old\\.a $tr_program_cooked $oldA tr_program_cooked \n    regsub -all old\\.b $tr_program_cooked $oldB tr_program_cooked \n    regsub -all old\\.c $tr_program_cooked $oldC tr_program_cooked \n\n    catchsql {\n      DROP TABLE tbl;\n      DROP TABLE log;\n    }\n\n    execsql {\n      CREATE TABLE tbl(a PRIMARY KEY, b, c);\n      CREATE TABLE log(a, b, c);\n    }\n\n    set query {SELECT * FROM tbl; SELECT * FROM log;}\n    set prep \"$prep; INSERT INTO log VALUES(1, 2, 3);\\\n             INSERT INTO log VALUES(10, 20, 30);\"\n\n# Check execution of BEFORE programs:\n\n    set before_data [ execsql \"$prep $tr_program_cooked $statement $query\" ]\n\n    execsql \"DELETE FROM tbl; DELETE FROM log; $prep\";\n    execsql \"CREATE TRIGGER the_trigger BEFORE [string range $statement 0 6]\\\n             ON tbl BEGIN $tr_program_fixed END;\"\n\n    do_test trigger2-2.$ii-before \"execsql {$statement $query}\" $before_data\n\n    execsql \"DROP TRIGGER the_trigger;\"\n    execsql \"DELETE FROM tbl; DELETE FROM log;\"\n\n# Check execution of AFTER programs\n    set after_data [ execsql \"$prep $statement $tr_program_cooked $query\" ]\n\n    execsql \"DELETE FROM tbl; DELETE FROM log; $prep\";\n    execsql \"CREATE TRIGGER the_trigger AFTER [string range $statement 0 6]\\\n             ON tbl BEGIN $tr_program_fixed END;\"\n\n    do_test trigger2-2.$ii-after \"execsql {$statement $query}\" $after_data\n    execsql \"DROP TRIGGER the_trigger;\"\n\n    integrity_check trigger2-2.$ii-integrity\n  }\n}\ncatchsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\n\n# 3.\n\n# trigger2-3.1: UPDATE OF triggers\nexecsql {\n  CREATE TABLE tbl (a, b, c, d);\n  CREATE TABLE log (a);\n  INSERT INTO log VALUES (0);\n  INSERT INTO tbl VALUES (0, 0, 0, 0);\n  INSERT INTO tbl VALUES (1, 0, 0, 0);\n  CREATE TRIGGER tbl_after_update_cd BEFORE UPDATE OF c, d ON tbl\n    BEGIN\n      UPDATE log SET a = a + 1;\n    END;\n}\ndo_test trigger2-3.1 {\n  execsql {\n    UPDATE tbl SET b = 1, c = 10; -- 2\n    UPDATE tbl SET b = 10; -- 0\n    UPDATE tbl SET d = 4 WHERE a = 0; --1\n    UPDATE tbl SET a = 4, b = 10; --0\n    SELECT * FROM log;\n  }\n} {3}\nexecsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\n\n# trigger2-3.2: WHEN clause\nset when_triggers [list {t1 BEFORE INSERT ON tbl WHEN new.a > 20}]\nifcapable subquery {\n  lappend when_triggers \\\n      {t2 BEFORE INSERT ON tbl WHEN (SELECT count(*) FROM tbl) = 0}\n}\n\nexecsql {\n  CREATE TABLE tbl (a, b, c, d);\n  CREATE TABLE log (a);\n  INSERT INTO log VALUES (0);\n}\n\nforeach trig $when_triggers {\n  execsql \"CREATE TRIGGER $trig BEGIN UPDATE log set a = a + 1; END;\"\n}\n\nifcapable subquery {\n  set t232 {1 0 1}\n} else {\n  set t232 {0 0 1}\n}\ndo_test trigger2-3.2 {\n  execsql { \n\n    INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 1 (ifcapable subquery)\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n\n    INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 0\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n\n    INSERT INTO tbl VALUES(200, 0, 0, 0);     -- 1\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n  }\n} $t232\nexecsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\nintegrity_check trigger2-3.3\n\n# Simple cascaded trigger\nexecsql {\n  CREATE TABLE tblA(a, b);\n  CREATE TABLE tblB(a, b);\n  CREATE TABLE tblC(a, b);\n\n  CREATE TRIGGER tr1 BEFORE INSERT ON tblA BEGIN\n    INSERT INTO tblB values(new.a, new.b);\n  END;\n\n  CREATE TRIGGER tr2 BEFORE INSERT ON tblB BEGIN\n    INSERT INTO tblC values(new.a, new.b);\n  END;\n}\ndo_test trigger2-4.1 {\n  execsql {\n    INSERT INTO tblA values(1, 2);\n    SELECT * FROM tblA;\n    SELECT * FROM tblB;\n    SELECT * FROM tblC;\n  }\n} {1 2 1 2 1 2}\nexecsql {\n  DROP TABLE tblA;\n  DROP TABLE tblB;\n  DROP TABLE tblC;\n}\n\n# Simple recursive trigger\nexecsql {\n  CREATE TABLE tbl(a, b, c);\n  CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl \n    BEGIN\n      INSERT INTO tbl VALUES (new.a, new.b, new.c);\n    END;\n}\ndo_test trigger2-4.2 {\n  execsql {\n    INSERT INTO tbl VALUES (1, 2, 3);\n    select * from tbl;\n  }\n} {1 2 3 1 2 3}\nexecsql {\n  DROP TABLE tbl;\n}\n\n# 5.\nexecsql {\n  CREATE TABLE tbl(a, b, c);\n  CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl \n    BEGIN\n      INSERT INTO tbl VALUES (1, 2, 3);\n      INSERT INTO tbl VALUES (2, 2, 3);\n      UPDATE tbl set b = 10 WHERE a = 1;\n      DELETE FROM tbl WHERE a = 1;\n      DELETE FROM tbl;\n    END;\n}\ndo_test trigger2-5 {\n  execsql {\n    INSERT INTO tbl VALUES(100, 200, 300);\n  }\n  db changes\n} {1}\nexecsql {\n  DROP TABLE tbl;\n}\n\nifcapable conflict {\n  # Handling of ON CONFLICT by INSERT statements inside triggers\n  execsql {\n    CREATE TABLE tbl (a primary key, b, c);\n    CREATE TRIGGER ai_tbl AFTER INSERT ON tbl BEGIN\n      INSERT OR IGNORE INTO tbl values (new.a, 0, 0);\n    END;\n  }\n  do_test trigger2-6.1a {\n    execsql {\n      BEGIN;\n      INSERT INTO tbl values (1, 2, 3);\n      SELECT * from tbl;\n    }\n  } {1 2 3}\n  do_test trigger2-6.1b {\n    catchsql {\n      INSERT OR ABORT INTO tbl values (2, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.1c {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 3}\n  do_test trigger2-6.1d {\n    catchsql {\n      INSERT OR FAIL INTO tbl values (2, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.1e {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 3 2 2 3}\n  do_test trigger2-6.1f {\n    execsql {\n      INSERT OR REPLACE INTO tbl values (2, 2, 3);\n      SELECT * from tbl;\n    }\n  } {1 2 3 2 0 0}\n  do_test trigger2-6.1g {\n    catchsql {\n      INSERT OR ROLLBACK INTO tbl values (3, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.1h {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {}\n  execsql {DELETE FROM tbl}\n  \n  \n  # Handling of ON CONFLICT by UPDATE statements inside triggers\n  execsql {\n    INSERT INTO tbl values (4, 2, 3);\n    INSERT INTO tbl values (6, 3, 4);\n    CREATE TRIGGER au_tbl AFTER UPDATE ON tbl BEGIN\n      UPDATE OR IGNORE tbl SET a = new.a, c = 10;\n    END;\n  }\n  do_test trigger2-6.2a {\n    execsql {\n      BEGIN;\n      UPDATE tbl SET a = 1 WHERE a = 4;\n      SELECT * from tbl;\n    }\n  } {1 2 10 6 3 4}\n  do_test trigger2-6.2b {\n    catchsql {\n      UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.2c {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 10 6 3 4}\n  do_test trigger2-6.2d {\n    catchsql {\n      UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.2e {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {4 2 10 6 3 4}\n  do_test trigger2-6.2f.1 {\n    execsql {\n      UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4;\n      SELECT * from tbl;\n    }\n  } {1 3 10}\n  do_test trigger2-6.2f.2 {\n    execsql {\n      INSERT INTO tbl VALUES (2, 3, 4);\n      SELECT * FROM tbl;\n    }\n  } {1 3 10 2 3 4}\n  do_test trigger2-6.2g {\n    catchsql {\n      UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test trigger2-6.2h {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {4 2 3 6 3 4}\n  execsql {\n    DROP TABLE tbl;\n  }\n} ; # ifcapable conflict\n\n# 7. Triggers on views\nifcapable view {\n\ndo_test trigger2-7.1 {\n  execsql {\n  CREATE TABLE ab(a, b);\n  CREATE TABLE cd(c, d);\n  INSERT INTO ab VALUES (1, 2);\n  INSERT INTO ab VALUES (0, 0);\n  INSERT INTO cd VALUES (3, 4);\n\n  CREATE TABLE tlog(ii INTEGER PRIMARY KEY, \n      olda, oldb, oldc, oldd, newa, newb, newc, newd);\n\n  CREATE VIEW abcd AS SELECT a, b, c, d FROM ab, cd;\n\n  CREATE TRIGGER before_update INSTEAD OF UPDATE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);\n  END;\n  CREATE TRIGGER after_update INSTEAD OF UPDATE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);\n  END;\n\n  CREATE TRIGGER before_delete INSTEAD OF DELETE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, 0, 0, 0, 0);\n  END;\n  CREATE TRIGGER after_delete INSTEAD OF DELETE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, 0, 0, 0, 0);\n  END;\n\n  CREATE TRIGGER before_insert INSTEAD OF INSERT ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\t0, 0, 0, 0, new.a, new.b, new.c, new.d);\n  END;\n   CREATE TRIGGER after_insert INSTEAD OF INSERT ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\t0, 0, 0, 0, new.a, new.b, new.c, new.d);\n   END;\n  }\n} {};\n\ndo_test trigger2-7.2 {\n  execsql {\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    DELETE FROM abcd WHERE a = 1;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    SELECT * FROM tlog;\n  }\n} [ list 1 1 2 3 4 100 25 3 4 \\\n         2 1 2 3 4 100 25 3 4 \\\n\t 3 1 2 3 4 0 0 0 0 \\\n\t 4 1 2 3 4 0 0 0 0 \\\n\t 5 0 0 0 0 10 20 30 40 \\\n\t 6 0 0 0 0 10 20 30 40 ]\n\ndo_test trigger2-7.3 {\n  execsql {\n    DELETE FROM tlog;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    DELETE FROM abcd WHERE a = 1;\n    SELECT * FROM tlog;\n  }\n} [ list \\\n   1 0 0 0 0 10 20 30 40 \\\n   2 0 0 0 0 10 20 30 40 \\\n   3 1 2 3 4 100 25 3 4 \\\n   4 1 2 3 4 100 25 3 4 \\\n   5 1 2 3 4 0 0 0 0 \\\n   6 1 2 3 4 0 0 0 0 \\\n]\ndo_test trigger2-7.4 {\n  execsql {\n    DELETE FROM tlog;\n    DELETE FROM abcd WHERE a = 1;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    SELECT * FROM tlog;\n  }\n} [ list \\\n   1 1 2 3 4 0 0 0 0 \\\n   2 1 2 3 4 0 0 0 0 \\\n   3 0 0 0 0 10 20 30 40 \\\n   4 0 0 0 0 10 20 30 40 \\\n   5 1 2 3 4 100 25 3 4 \\\n   6 1 2 3 4 100 25 3 4 \\\n]\n\ndo_test trigger2-8.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    CREATE VIEW v1 AS\n      SELECT a+b AS x, b+c AS y, a+c AS z FROM t1;\n    SELECT * FROM v1;\n  }\n} {3 5 4}\ndo_test trigger2-8.2 {\n  execsql {\n    CREATE TABLE v1log(a,b,c,d,e,f);\n    CREATE TRIGGER r1 INSTEAD OF DELETE ON v1 BEGIN\n      INSERT INTO v1log VALUES(OLD.x,NULL,OLD.y,NULL,OLD.z,NULL);\n    END;\n    DELETE FROM v1 WHERE x=1;\n    SELECT * FROM v1log;\n  }\n} {}\ndo_test trigger2-8.3 {\n  execsql {\n    DELETE FROM v1 WHERE x=3;\n    SELECT * FROM v1log;\n  }\n} {3 {} 5 {} 4 {}}\ndo_test trigger2-8.4 {\n  execsql {\n    INSERT INTO t1 VALUES(4,5,6);\n    DELETE FROM v1log;\n    DELETE FROM v1 WHERE y=11;\n    SELECT * FROM v1log;\n  }\n} {9 {} 11 {} 10 {}}\ndo_test trigger2-8.5 {\n  execsql {\n    CREATE TRIGGER r2 INSTEAD OF INSERT ON v1 BEGIN\n      INSERT INTO v1log VALUES(NULL,NEW.x,NULL,NEW.y,NULL,NEW.z);\n    END;\n    DELETE FROM v1log;\n    INSERT INTO v1 VALUES(1,2,3);\n    SELECT * FROM v1log;\n  }\n} {{} 1 {} 2 {} 3}\ndo_test trigger2-8.6 {\n  execsql {\n    CREATE TRIGGER r3 INSTEAD OF UPDATE ON v1 BEGIN\n      INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z);\n    END;\n    DELETE FROM v1log;\n    UPDATE v1 SET x=x+100, y=y+200, z=z+300;\n    SELECT * FROM v1log;\n  }\n} {3 103 5 205 4 304 9 109 11 211 10 310}\n\n# At one point the following was causing a segfault.\ndo_test trigger2-9.1 {\n  execsql {\n    CREATE TABLE t3(a TEXT, b TEXT);\n    CREATE VIEW v3 AS SELECT t3.a FROM t3;\n    CREATE TRIGGER trig1 INSTEAD OF DELETE ON v3 BEGIN\n      SELECT 1;\n    END;\n    DELETE FROM v3 WHERE a = 1;\n  }\n} {}\n\n} ;# ifcapable view\n\nintegrity_check trigger2-9.9\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger3.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the RAISE() function.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# The tests in this file were written before SQLite supported recursive }\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\n# Test that we can cause ROLLBACK, FAIL and ABORT correctly\n#\ncatchsql { CREATE TABLE tbl(a, b ,c) }\nexecsql {\n    CREATE TRIGGER before_tbl_insert BEFORE INSERT ON tbl BEGIN SELECT CASE \n        WHEN (new.a = 4) THEN RAISE(IGNORE) END;\n    END;\n\n    CREATE TRIGGER after_tbl_insert AFTER INSERT ON tbl BEGIN SELECT CASE \n        WHEN (new.a = 1) THEN RAISE(ABORT,    'Trigger abort') \n        WHEN (new.a = 2) THEN RAISE(FAIL,     'Trigger fail') \n        WHEN (new.a = 3) THEN RAISE(ROLLBACK, 'Trigger rollback') END;\n    END;\n}\n# ABORT\ndo_test trigger3-1.1 {\n    catchsql {\n        BEGIN;\n        INSERT INTO tbl VALUES (5, 5, 6);\n        INSERT INTO tbl VALUES (1, 5, 6);\n    }\n} {1 {Trigger abort}}\nverify_ex_errcode trigger3-1.1b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger3-1.2 {\n    execsql {\n        SELECT * FROM tbl;\n        ROLLBACK;\n    }\n} {5 5 6}\ndo_test trigger3-1.3 {\n    execsql {SELECT * FROM tbl}\n} {}\n\n# FAIL\ndo_test trigger3-2.1 {\n    catchsql {\n        BEGIN;\n        INSERT INTO tbl VALUES (5, 5, 6);\n        INSERT INTO tbl VALUES (2, 5, 6);\n    }\n} {1 {Trigger fail}}\nverify_ex_errcode trigger3-2.1b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger3-2.2 {\n    execsql {\n        SELECT * FROM tbl;\n        ROLLBACK;\n    }\n} {5 5 6 2 5 6}\n# ROLLBACK\ndo_test trigger3-3.1 {\n    catchsql {\n        BEGIN;\n        INSERT INTO tbl VALUES (5, 5, 6);\n        INSERT INTO tbl VALUES (3, 5, 6);\n    }\n} {1 {Trigger rollback}}\nverify_ex_errcode trigger3-3.1b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger3-3.2 {\n    execsql {\n        SELECT * FROM tbl;\n    }\n} {}\n\n# Verify that a ROLLBACK trigger works like a FAIL trigger if\n# we are not within a transaction.  Ticket #3035.\n#\ndo_test trigger3-3.3 {\n    catchsql {COMMIT}\n    catchsql {\n        INSERT INTO tbl VALUES (3, 9, 10);\n    }\n} {1 {Trigger rollback}}\nverify_ex_errcode trigger3-3.3b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger3-3.4 {\n    execsql {SELECT * FROM tbl}\n} {}\n\n# IGNORE\ndo_test trigger3-4.1 {\n    catchsql {\n        BEGIN;\n        INSERT INTO tbl VALUES (5, 5, 6);\n        INSERT INTO tbl VALUES (4, 5, 6);\n    }\n} {0 {}}\ndo_test trigger3-4.2 {\n    execsql {\n        SELECT * FROM tbl;\n        ROLLBACK;\n    }\n} {5 5 6}\n\n# Check that we can also do RAISE(IGNORE) for UPDATE and DELETE\nexecsql {DROP TABLE tbl;}\nexecsql {CREATE TABLE tbl (a, b, c);}\nexecsql {INSERT INTO tbl VALUES(1, 2, 3);}\nexecsql {INSERT INTO tbl VALUES(4, 5, 6);}\nexecsql {\n    CREATE TRIGGER before_tbl_update BEFORE UPDATE ON tbl BEGIN\n        SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;\n    END;\n\n    CREATE TRIGGER before_tbl_delete BEFORE DELETE ON tbl BEGIN\n        SELECT CASE WHEN (old.a = 1) THEN RAISE(IGNORE) END;\n    END;\n}\ndo_test trigger3-5.1 {\n    execsql {\n        UPDATE tbl SET c = 10;\n        SELECT * FROM tbl;\n    }\n} {1 2 3 4 5 10}\ndo_test trigger3-5.2 {\n    execsql {\n        DELETE FROM tbl;\n        SELECT * FROM tbl;\n    }\n} {1 2 3}\n\n# Check that RAISE(IGNORE) works correctly for nested triggers:\nexecsql {CREATE TABLE tbl2(a, b, c)}\nexecsql {\n    CREATE TRIGGER after_tbl2_insert AFTER INSERT ON tbl2 BEGIN\n        UPDATE tbl SET c = 10;\n        INSERT INTO tbl2 VALUES (new.a, new.b, new.c);\n    END;\n}\ndo_test trigger3-6 {\n    execsql {\n        INSERT INTO tbl2 VALUES (1, 2, 3);\n        SELECT * FROM tbl2;\n        SELECT * FROM tbl;\n    }\n} {1 2 3 1 2 3 1 2 3}\n\n# Check that things also work for view-triggers\n\nifcapable view {\n\nexecsql {CREATE VIEW tbl_view AS SELECT * FROM tbl}\nexecsql {\n    CREATE TRIGGER tbl_view_insert INSTEAD OF INSERT ON tbl_view BEGIN\n        SELECT CASE WHEN (new.a = 1) THEN RAISE(ROLLBACK, 'View rollback')\n                    WHEN (new.a = 2) THEN RAISE(IGNORE) \n                    WHEN (new.a = 3) THEN RAISE(ABORT, 'View abort') END;\n    END;\n}\n\ndo_test trigger3-7.1 {\n    catchsql {\n        INSERT INTO tbl_view VALUES(1, 2, 3);\n    }\n} {1 {View rollback}}\nverify_ex_errcode trigger3-7.1b SQLITE_CONSTRAINT_TRIGGER\ndo_test trigger3-7.2 {\n    catchsql {\n        INSERT INTO tbl_view VALUES(2, 2, 3);\n    }\n} {0 {}}\ndo_test trigger3-7.3 {\n    catchsql {\n        INSERT INTO tbl_view VALUES(3, 2, 3);\n    }\n} {1 {View abort}}\nverify_ex_errcode trigger3-7.3b SQLITE_CONSTRAINT_TRIGGER\n\n} ;# ifcapable view\n\nintegrity_check trigger3-8.1\n\ncatchsql { DROP TABLE tbl; } \ncatchsql { DROP TABLE tbl2; } \ncatchsql { DROP VIEW tbl_view; }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger4.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the triggers of views.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If either views or triggers are disabled in this build, omit this file.\nifcapable {!trigger || !view} {\n  finish_test\n  return\n}\n\ndo_test trigger4-1.1 {\n  execsql {\n    create table test1(id integer primary key,a);\n    create table test2(id integer,b);\n    create view test as\n      select test1.id as id,a as a,b as b\n      from test1 join test2 on test2.id =  test1.id;\n    create trigger I_test instead of insert on test\n      begin\n        insert into test1 (id,a) values (NEW.id,NEW.a);\n        insert into test2 (id,b) values (NEW.id,NEW.b);\n      end;\n    insert into test values(1,2,3);\n    select * from test1;\n  }\n} {1 2}\ndo_test trigger4-1.2 {\n  execsql {\n    select * from test2;\n  }\n} {1 3}\ndo_test trigger4-1.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    insert into test values(4,5,6);\n    select * from test1;\n  }\n} {1 2 4 5}\ndo_test trigger4-1.4 {\n  execsql {\n    select * from test2;\n  }\n} {1 3 4 6}\n\ndo_test trigger4-2.1 {\n  execsql {\n    create trigger U_test instead of update on test\n      begin\n        update test1 set a=NEW.a where id=NEW.id;\n        update test2 set b=NEW.b where id=NEW.id;\n      end;\n    update test set a=22 where id=1;\n    select * from test1;\n  }\n} {1 22 4 5}\ndo_test trigger4-2.2 {\n  execsql {\n    select * from test2;\n  }\n} {1 3 4 6}\ndo_test trigger4-2.3 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    update test set b=66 where id=4;\n    select * from test1;\n  }\n} {1 22 4 5}\ndo_test trigger4-2.4 {\n  execsql {\n    select * from test2;\n  }\n} {1 3 4 66}\n\ndo_test trigger4-3.1 {\n  catchsql {\n    drop table test2;\n    insert into test values(7,8,9);\n  }\n} {1 {no such table: main.test2}}\ndo_test trigger4-3.2 {\n  db close\n  sqlite3 db test.db\n  catchsql {\n    insert into test values(7,8,9);\n  }\n} {1 {no such table: main.test2}}\ndo_test trigger4-3.3 {\n  catchsql {\n    update test set a=222 where id=1;\n  }\n} {1 {no such table: main.test2}}\ndo_test trigger4-3.4 {\n  execsql {\n    select * from test1;\n  }\n} {1 22 4 5}\ndo_test trigger4-3.5 {\n  execsql {\n    create table test2(id,b);\n    insert into test values(7,8,9);\n    select * from test1;\n  }\n} {1 22 4 5 7 8}\ndo_test trigger4-3.6 {\n  execsql {\n    select * from test2;\n  }\n} {7 9}\ndo_test trigger4-3.7 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    update test set b=99 where id=7;\n    select * from test2;\n  }\n} {7 99}\n\ndo_test trigger4-4.1 {\n    db close\n    forcedelete trigtest.db\n    forcedelete trigtest.db-journal\n    sqlite3 db trigtest.db\n    catchsql {drop table tbl; drop view vw}\n    execsql {\n\tcreate table tbl(a integer primary key, b integer);\n\tcreate view vw as select * from tbl;\n\tcreate trigger t_del_tbl instead of delete on vw for each row begin\n\t  delete from tbl where a = old.a;\n\tend;\n\tcreate trigger t_upd_tbl instead of update on vw for each row begin\n\t  update tbl set a=new.a, b=new.b where a = old.a;\n\tend;\n\tcreate trigger t_ins_tbl instead of insert on vw for each row begin\n\t  insert into tbl values (new.a,new.b);\n\tend;\n\tinsert into tbl values(101,1001);\n\tinsert into tbl values(102,1002);\n\tinsert into tbl select a+2, b+2 from tbl;\n\tinsert into tbl select a+4, b+4 from tbl;\n\tinsert into tbl select a+8, b+8 from tbl;\n\tinsert into tbl select a+16, b+16 from tbl;\n\tinsert into tbl select a+32, b+32 from tbl;\n\tinsert into tbl select a+64, b+64 from tbl;\n\tselect count(*) from vw;\n    }\n} {128}\ndo_test trigger4-4.2 {\n    execsql {select a, b from vw where a<103 or a>226 order by a}\n} {101 1001 102 1002 227 1127 228 1128}\n\n#test delete from view\ndo_test trigger4-5.1 {\n    catchsql {delete from vw where a>101 and a<2000}\n} {0 {}}\ndo_test trigger4-5.2 {\n    execsql {select * from vw}\n} {101 1001}\n\n#test insert into view\ndo_test trigger4-6.1 {\n    catchsql {\n\tinsert into vw values(102,1002);\n\tinsert into vw select a+2, b+2 from vw;\n\tinsert into vw select a+4, b+4 from vw;\n\tinsert into vw select a+8, b+8 from vw;\n\tinsert into vw select a+16, b+16 from vw;\n\tinsert into vw select a+32, b+32 from vw;\n\tinsert into vw select a+64, b+64 from vw;\n    }\n} {0 {}}\ndo_test trigger4-6.2 {\n    execsql {select count(*) from vw}\n} {128}\n\n#test update of view\ndo_test trigger4-7.1 {\n    catchsql {update vw set b=b+1000 where a>101 and a<2000}\n} {0 {}}\ndo_test trigger4-7.2 {\n    execsql {select a, b from vw where a<=102 or a>=227 order by a}\n} {101 1001 102 2002 227 2127 228 2128}\n\nintegrity_check trigger4-99.9\ndb close\nforcedelete trigtest.db trigtest.db-journal\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger5.test",
    "content": "# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the triggers of views.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Ticket #844\n#\ndo_test trigger5-1.1 {\n  execsql {\n    CREATE TABLE Item(\n       a integer PRIMARY KEY NOT NULL ,\n       b double NULL ,\n       c int NOT NULL DEFAULT 0\n    );\n    CREATE TABLE Undo(UndoAction TEXT);\n    INSERT INTO Item VALUES (1,38205.60865,340);\n    CREATE TRIGGER trigItem_UNDO_AD AFTER DELETE ON Item FOR EACH ROW\n    BEGIN\n      INSERT INTO Undo SELECT 'INSERT INTO Item (a,b,c) VALUES ('\n       || coalesce(old.a,'NULL') || ',' || quote(old.b) || ',' || old.c || ');';\n    END;\n    DELETE FROM Item WHERE a = 1;\n    SELECT * FROM Undo;\n  }\n} {{INSERT INTO Item (a,b,c) VALUES (1,38205.60865,340);}}\n\nintegrity_check trigger5-99.9\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger6.test",
    "content": "# 2004 December 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure expression of an INSERT\n# and UPDATE statement are only evaluated once.  See ticket #980.\n# If an expression uses a function that has side-effects or which\n# is not deterministic (ex: random()) then we want to make sure\n# that the same evaluation occurs for the actual INSERT/UPDATE and\n# for the NEW.* fields of any triggers that fire.\n#\n# $Id: trigger6.test,v 1.2 2005/05/05 11:04:50 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\ndo_test trigger6-1.1 {\n  execsql {\n    CREATE TABLE t1(x, y);\n    CREATE TABLE log(a, b, c);\n    CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN\n      INSERT INTO log VALUES(1, new.x, new.y);\n    END;\n    CREATE TRIGGER r2 BEFORE UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES(2, new.x, new.y);\n    END;\n  }\n  set ::trigger6_cnt 0\n  proc trigger6_counter {args} {\n    incr ::trigger6_cnt\n    return $::trigger6_cnt\n  }\n  db function counter trigger6_counter\n  execsql {\n    INSERT INTO t1 VALUES(1,counter());\n    SELECT * FROM t1;\n  }\n} {1 1}\ndo_test trigger6-1.2 {\n  execsql {\n    SELECT * FROM log;\n  }\n} {1 1 1}\ndo_test trigger6-1.3 {\n  execsql {\n    DELETE FROM t1;\n    DELETE FROM log;\n    INSERT INTO t1 VALUES(2,counter(2,3)+4);\n    SELECT * FROM t1;\n  }\n} {2 6}\ndo_test trigger6-1.4 {\n  execsql {\n    SELECT * FROM log;\n  }\n} {1 2 6}\ndo_test trigger6-1.5 {\n  execsql {\n    DELETE FROM log;\n    UPDATE t1 SET y=counter(5);\n    SELECT * FROM t1;\n  }\n} {2 3}\ndo_test trigger6-1.6 {\n  execsql {\n    SELECT * FROM log;\n  }\n} {2 2 3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger7.test",
    "content": "# 2005 August 18\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to increase coverage of trigger.c.\n#\n# $Id: trigger7.test,v 1.3 2008/08/11 18:44:58 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Error messages resulting from qualified trigger names.\n#\ndo_test trigger7-1.1 {\n  execsql {\n    CREATE TABLE t1(x, y);\n  }\n  catchsql {\n    CREATE TEMP TRIGGER main.r1 AFTER INSERT ON t1 BEGIN\n      SELECT 'no nothing';\n    END\n  }\n} {1 {temporary trigger may not have qualified name}}\ndo_test trigger7-1.2 {\n  catchsql {\n    CREATE TRIGGER not_a_db.r1 AFTER INSERT ON t1 BEGIN\n      SELECT 'no nothing';\n    END\n  }\n} {1 {unknown database not_a_db}}\n\n\n# When the UPDATE OF syntax is used, no code is generated for triggers\n# that do not match the update columns.\n#\nifcapable explain {\n  do_test trigger7-2.1 {\n    execsql {\n      CREATE TRIGGER r1 AFTER UPDATE OF x ON t1 BEGIN\n        SELECT '___update_t1.x___';\n      END;\n      CREATE TRIGGER r2 AFTER UPDATE OF y ON t1 BEGIN\n        SELECT '___update_t1.y___';\n      END;\n    }\n    set txt [db eval {EXPLAIN UPDATE t1 SET x=5}]\n    string match *___update_t1.x___* $txt\n  } 1\n  do_test trigger7-2.2 {\n    set txt [db eval {EXPLAIN UPDATE t1 SET x=5}]\n    string match *___update_t1.y___* $txt\n  } 0\n  do_test trigger7-2.3 {\n    set txt [db eval {EXPLAIN UPDATE t1 SET y=5}]\n    string match *___update_t1.x___* $txt\n  } 0\n  do_test trigger7-2.4 {\n    set txt [db eval {EXPLAIN UPDATE t1 SET y=5}]\n    string match *___update_t1.y___* $txt\n  } 1\n  do_test trigger7-2.5 {\n    set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}]\n    string match *___update_t1.x___* $txt\n  } 0\n  do_test trigger7-2.6 {\n    set txt [db eval {EXPLAIN UPDATE t1 SET rowid=5}]\n    string match *___update_t1.x___* $txt\n  } 0\n}\n\n# Test the ability to create many triggers on the same table, then\n# selectively drop those triggers.\n#\ndo_test trigger7-3.1 {\n  execsql {\n    CREATE TABLE t2(x,y,z);\n    CREATE TRIGGER t2r1 AFTER INSERT ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r2 BEFORE INSERT ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r3 AFTER UPDATE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r4 BEFORE UPDATE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r5 AFTER DELETE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r6 BEFORE DELETE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r7 AFTER INSERT ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r8 BEFORE INSERT ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r9 AFTER UPDATE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r10 BEFORE UPDATE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r11 AFTER DELETE ON t2 BEGIN SELECT 1; END;\n    CREATE TRIGGER t2r12 BEFORE DELETE ON t2 BEGIN SELECT 1; END;\n    DROP TRIGGER t2r6;\n  }\n} {}\n\n# This test corrupts the database file so it must be the last test\n# in the series.\n#\ndo_test trigger7-99.1 {\n  execsql {\n    PRAGMA writable_schema=on;\n    UPDATE sqlite_master SET sql='nonsense';\n  }\n  db close\n  catch { sqlite3 db test.db }\n  catchsql { DROP TRIGGER t2r5 }\n} {1 {malformed database schema (t2r12)}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger8.test",
    "content": "# 2006 February 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests to make sure abusively large triggers\n# (triggers with 100s or 1000s of statements) work.\n#\n# $Id: trigger8.test,v 1.2 2008/09/17 16:14:10 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Set variable $nStatement to the number of statements to include in the\n# body of the trigger. On a workstation with virtually unlimited memory, \n# use 10000. But on symbian, which allows each application at most a 32MB\n# heap, use 1000.\n#\nset nStatement 10000\nif {$tcl_platform(platform) == \"symbian\"} {\n  set nStatement 1000\n}\n\nset nStatement 5\ndo_test trigger8-1.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(y);\n  }\n  set sql \"CREATE TRIGGER r${nStatement} AFTER INSERT ON t1 BEGIN\\n\"\n  for {set i 0} {$i<$nStatement} {incr i} {\n    append sql \"  INSERT INTO t2 VALUES($i);\\n\"\n  }\n  append sql \"END;\"\n  execsql $sql\n  execsql {\n    INSERT INTO t1 VALUES(5);\n    SELECT count(*) FROM t2;\n  }\n} $nStatement\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/trigger9.test",
    "content": "# 2008 January 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests some compiler optimizations for SQL statements featuring\n# triggers:\n#\n#\n#\n\n# trigger9-1.* -   Test that if there are no references to OLD.* cols, or a\n#                  reference to only OLD.rowid, the data is not loaded.\n#\n# trigger9-2.* -   Test that for NEW.* records populated by UPDATE \n#                  statements, unused fields are populated with NULL values. \n#\n# trigger9-3.* -   Test that the temporary tables used for OLD.* references\n#                  in \"INSTEAD OF\" triggers have NULL values in unused \n#                  fields.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\nset ::testprefix trigger9\n\nproc has_rowdata {sql} {\n  expr {[lsearch [execsql \"explain $sql\"] RowData]>=0}\n}\n\ndo_test trigger9-1.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x, y, z);\n    INSERT INTO t1 VALUES('1', randstr(10000,10000), '2');\n    INSERT INTO t1 VALUES('2', randstr(10000,10000), '4');\n    INSERT INTO t1 VALUES('3', randstr(10000,10000), '6');\n    CREATE TABLE t2(x);\n  }\n} {}\n\ndo_test trigger9-1.2.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN\n        INSERT INTO t2 VALUES(old.rowid);\n      END;\n      DELETE FROM t1;\n      SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test trigger9-1.2.3 {\n  has_rowdata {DELETE FROM t1}\n} 0\ndo_test trigger9-1.2.4 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-1.3.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN\n        INSERT INTO t2 VALUES(old.x);\n      END;\n      DELETE FROM t1;\n      SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test trigger9-1.3.2 {\n  has_rowdata {DELETE FROM t1}\n} 0\ndo_test trigger9-1.3.3 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-1.4.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE DELETE ON t1 WHEN old.x='1' BEGIN\n        INSERT INTO t2 VALUES(old.rowid);\n      END;\n      DELETE FROM t1;\n      SELECT * FROM t2;\n  }\n} {1}\ndo_test trigger9-1.4.2 {\n  has_rowdata {DELETE FROM t1}\n} 0\ndo_test trigger9-1.4.3 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-1.5.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN\n        INSERT INTO t2 VALUES(old.rowid);\n      END;\n      UPDATE t1 SET y = '';\n      SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test trigger9-1.5.2 {\n  has_rowdata {UPDATE t1 SET y = ''}\n} 0\ndo_test trigger9-1.5.3 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-1.6.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN\n        INSERT INTO t2 VALUES(old.x);\n      END;\n      UPDATE t1 SET y = '';\n      SELECT * FROM t2;\n  }\n} {1 2 3}\ndo_test trigger9-1.6.2 {\n  has_rowdata {UPDATE t1 SET y = ''}\n} 0\ndo_test trigger9-1.6.3 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-1.7.1 {\n  execsql {\n    BEGIN;\n      CREATE TRIGGER trig1 BEFORE UPDATE ON t1 WHEN old.x>='2' BEGIN\n        INSERT INTO t2 VALUES(old.x);\n      END;\n      UPDATE t1 SET y = '';\n      SELECT * FROM t2;\n  }\n} {2 3}\ndo_test trigger9-1.7.2 {\n  has_rowdata {UPDATE t1 SET y = ''}\n} 0\ndo_test trigger9-1.7.3 { execsql { ROLLBACK } } {}\n\ndo_test trigger9-3.1 {\n  execsql {\n    CREATE TABLE t3(a, b);\n    INSERT INTO t3 VALUES(1, 'one');\n    INSERT INTO t3 VALUES(2, 'two');\n    INSERT INTO t3 VALUES(3, 'three');\n  }\n} {}\ndo_test trigger9-3.2 {\n  execsql {\n    BEGIN;\n      CREATE VIEW v1 AS SELECT * FROM t3;\n      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN\n        INSERT INTO t2 VALUES(old.a);\n      END;\n      UPDATE v1 SET b = 'hello';\n      SELECT * FROM t2;\n    ROLLBACK;\n  }\n} {1 2 3}\ndo_test trigger9-3.3 {\n  # In this test the 'c' column of the view is not required by\n  # the INSTEAD OF trigger, but the expression is reused internally as\n  # part of the view's WHERE clause. Check that this does not cause\n  # a problem.\n  #\n  execsql {\n    BEGIN;\n      CREATE VIEW v1 AS SELECT a, b AS c FROM t3 WHERE c > 'one';\n      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN\n        INSERT INTO t2 VALUES(old.a);\n      END;\n      UPDATE v1 SET c = 'hello';\n      SELECT * FROM t2;\n    ROLLBACK;\n  }\n} {2 3}\ndo_test trigger9-3.4 {\n  execsql {\n    BEGIN;\n      INSERT INTO t3 VALUES(3, 'three');\n      INSERT INTO t3 VALUES(3, 'four');\n      CREATE VIEW v1 AS SELECT DISTINCT a, b FROM t3;\n      CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN\n        INSERT INTO t2 VALUES(old.a);\n      END;\n      UPDATE v1 SET b = 'hello';\n      SELECT * FROM t2;\n    ROLLBACK;\n  }\n} {1 2 3 3}\n\nifcapable compound {\n  do_test trigger9-3.5 {\n    execsql {\n      BEGIN;\n        INSERT INTO t3 VALUES(1, 'uno');\n        CREATE VIEW v1 AS SELECT a, b FROM t3 EXCEPT SELECT 1, 'one';\n        CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN\n          INSERT INTO t2 VALUES(old.a);\n        END;\n        UPDATE v1 SET b = 'hello';\n        SELECT * FROM t2;\n      ROLLBACK;\n    }\n  } {1 2 3}\n  do_test trigger9-3.6 {\n    execsql {\n      BEGIN;\n        INSERT INTO t3 VALUES(1, 'zero');\n        CREATE VIEW v1 AS \n          SELECT sum(a) AS a, max(b) AS b FROM t3 GROUP BY t3.a HAVING b>'two';\n        CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN\n          INSERT INTO t2 VALUES(old.a);\n        END;\n        UPDATE v1 SET b = 'hello';\n        SELECT * FROM t2;\n      ROLLBACK;\n    }\n  } {2}\n}\n\nreset_db\ndo_execsql_test 4.1 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE log(x);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  CREATE VIEW v1 AS SELECT a, b FROM t1;\n\n  CREATE TRIGGER tr1 INSTEAD OF DELETE ON v1 BEGIN\n    INSERT INTO log VALUES('delete');\n  END;\n\n  CREATE TRIGGER tr2 INSTEAD OF UPDATE ON v1 BEGIN\n    INSERT INTO log VALUES('update');\n  END;\n\n  CREATE TRIGGER tr3 INSTEAD OF INSERT ON v1 BEGIN\n    INSERT INTO log VALUES('insert');\n  END;\n}\n\ndo_execsql_test 4.2 {\n  DELETE FROM v1 WHERE rowid=1;\n} {}\n\ndo_execsql_test 4.3 {\n  UPDATE v1 SET a=b WHERE rowid=2;\n} {}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerA.test",
    "content": "# 2008 February 12\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests issues relating to firing an INSTEAD OF trigger on a VIEW\n# when one tries to UPDATE or DELETE from the view.  Does the WHERE\n# clause of the UPDATE or DELETE statement get passed down correctly \n# into the query that manifests the view?\n#\n# Ticket #2938\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !trigger||!compound {\n  finish_test\n  return\n}\n\n# Create two table containing some sample data\n#\ndo_test triggerA-1.1 {\n  db eval {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT UNIQUE);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER UNIQUE, c TEXT);\n  }\n  set i 1\n  foreach word {one two three four five six seven eight nine ten} {\n    set j [expr {$i*100 + [string length $word]}]\n    db eval {\n       INSERT INTO t1 VALUES($i,$word);\n       INSERT INTO t2 VALUES(20-$i,$j,$word);\n    }\n    incr i\n  }\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL SELECT count(*) FROM t2;\n  }\n} {10 10}\n\n# Create views of various forms against one or both of the two tables.\n#\ndo_test triggerA-1.2 {\n  db eval {\n     CREATE VIEW v1 AS SELECT y, x FROM t1;\n     SELECT * FROM v1 ORDER BY 1;\n  }\n} {eight 8 five 5 four 4 nine 9 one 1 seven 7 six 6 ten 10 three 3 two 2}\ndo_test triggerA-1.3 {\n  db eval {\n     CREATE VIEW v2 AS SELECT x, y FROM t1 WHERE y GLOB '*e*';\n     SELECT * FROM v2 ORDER BY 1;\n  }\n} {1 one 3 three 5 five 7 seven 8 eight 9 nine 10 ten}\ndo_test triggerA-1.4 {\n  db eval {\n     CREATE VIEW v3 AS\n       SELECT CAST(x AS TEXT) AS c1 FROM t1 UNION SELECT y FROM t1;\n     SELECT * FROM v3 ORDER BY c1;\n  }\n} {1 10 2 3 4 5 6 7 8 9 eight five four nine one seven six ten three two}\ndo_test triggerA-1.5 {\n  db eval {\n     CREATE VIEW v4 AS\n        SELECT CAST(x AS TEXT) AS c1 FROM t1\n        UNION SELECT y FROM t1 WHERE x BETWEEN 3 and 5;\n     SELECT * FROM v4 ORDER BY 1;\n  }\n} {1 10 2 3 4 5 6 7 8 9 five four three}\ndo_test triggerA-1.6 {\n  db eval {\n     CREATE VIEW v5 AS SELECT x, b FROM t1, t2 WHERE y=c;\n     SELECT * FROM v5 ORDER BY x DESC;\n  }\n} {10 1003 9 904 8 805 7 705 6 603 5 504 4 404 3 305 2 203 1 103}\n\n# Create INSTEAD OF triggers on the views.  Run UPDATE and DELETE statements\n# using those triggers.  Verify correct operation.\n#\ndo_test triggerA-2.1 {\n  db eval {\n     CREATE TABLE result2(a,b);\n     CREATE TRIGGER r1d INSTEAD OF DELETE ON v1 BEGIN\n       INSERT INTO result2(a,b) VALUES(old.y, old.x);\n     END;\n     DELETE FROM v1 WHERE x=5;\n     SELECT * FROM result2;\n  }\n} {five 5}\ndo_test triggerA-2.2 {\n  db eval {\n     CREATE TABLE result4(a,b,c,d);\n     CREATE TRIGGER r1u INSTEAD OF UPDATE ON v1 BEGIN\n       INSERT INTO result4(a,b,c,d) VALUES(old.y, old.x, new.y, new.x);\n     END;\n     UPDATE v1 SET y=y||'-extra' WHERE x BETWEEN 3 AND 5;\n     SELECT * FROM result4 ORDER BY a;\n  }\n} {five 5 five-extra 5 four 4 four-extra 4 three 3 three-extra 3}\n\n\ndo_test triggerA-2.3 {\n  db eval {\n     DELETE FROM result2;\n     CREATE TRIGGER r2d INSTEAD OF DELETE ON v2 BEGIN\n       INSERT INTO result2(a,b) VALUES(old.y, old.x);\n     END;\n     DELETE FROM v2 WHERE x=5;\n     SELECT * FROM result2;\n  }\n} {five 5}\ndo_test triggerA-2.4 {\n  db eval {\n     DELETE FROM result4;\n     CREATE TRIGGER r2u INSTEAD OF UPDATE ON v2 BEGIN\n       INSERT INTO result4(a,b,c,d) VALUES(old.y, old.x, new.y, new.x);\n     END;\n     UPDATE v2 SET y=y||'-extra' WHERE x BETWEEN 3 AND 5;\n     SELECT * FROM result4 ORDER BY a;\n  }\n} {five 5 five-extra 5 three 3 three-extra 3}\n\n\ndo_test triggerA-2.5 {\n  db eval {\n     CREATE TABLE result1(a);\n     CREATE TRIGGER r3d INSTEAD OF DELETE ON v3 BEGIN\n       INSERT INTO result1(a) VALUES(old.c1);\n     END;\n     DELETE FROM v3 WHERE c1 BETWEEN '8' AND 'eight';\n     SELECT * FROM result1 ORDER BY a;\n  }\n} {8 9 eight}\ndo_test triggerA-2.6 {\n  db eval {\n     DELETE FROM result2;\n     CREATE TRIGGER r3u INSTEAD OF UPDATE ON v3 BEGIN\n       INSERT INTO result2(a,b) VALUES(old.c1, new.c1);\n     END;\n     UPDATE v3 SET c1 = c1 || '-extra' WHERE c1 BETWEEN '8' and 'eight';\n     SELECT * FROM result2 ORDER BY a;\n  }\n} {8 8-extra 9 9-extra eight eight-extra}\n\n\ndo_test triggerA-2.7 {\n  db eval {\n     DELETE FROM result1;\n     CREATE TRIGGER r4d INSTEAD OF DELETE ON v4 BEGIN\n       INSERT INTO result1(a) VALUES(old.c1);\n     END;\n     DELETE FROM v4 WHERE c1 BETWEEN '8' AND 'eight';\n     SELECT * FROM result1 ORDER BY a;\n  }\n} {8 9}\ndo_test triggerA-2.8 {\n  db eval {\n     DELETE FROM result2;\n     CREATE TRIGGER r4u INSTEAD OF UPDATE ON v4 BEGIN\n       INSERT INTO result2(a,b) VALUES(old.c1, new.c1);\n     END;\n     UPDATE v4 SET c1 = c1 || '-extra' WHERE c1 BETWEEN '8' and 'eight';\n     SELECT * FROM result2 ORDER BY a;\n  }\n} {8 8-extra 9 9-extra}\n\n\ndo_test triggerA-2.9 {\n  db eval {\n     DELETE FROM result2;\n     CREATE TRIGGER r5d INSTEAD OF DELETE ON v5 BEGIN\n       INSERT INTO result2(a,b) VALUES(old.x, old.b);\n     END;\n     DELETE FROM v5 WHERE x=5;\n     SELECT * FROM result2;\n  }\n} {5 504}\ndo_test triggerA-2.10 {\n  db eval {\n     DELETE FROM result4;\n     CREATE TRIGGER r5u INSTEAD OF UPDATE ON v5 BEGIN\n       INSERT INTO result4(a,b,c,d) VALUES(old.x, old.b, new.x, new.b);\n     END;\n     UPDATE v5 SET b = b+9900000 WHERE x BETWEEN 3 AND 5;\n     SELECT * FROM result4 ORDER BY a;\n  }\n} {3 305 3 9900305 4 404 4 9900404 5 504 5 9900504}\ndo_test triggerA-2.11 {\n  db eval {\n     DELETE FROM result4;\n     UPDATE v5 SET b = main.v5.b+9900000 WHERE main.v5.x BETWEEN 3 AND 5;\n     SELECT * FROM result4 ORDER BY a;\n  }\n} {3 305 3 9900305 4 404 4 9900404 5 504 5 9900504}\n\n# Only run the reamining tests if memory debugging is turned on.\n#\nifcapable !memdebug {\n   puts \"Skipping triggerA malloc tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\nsource $testdir/malloc_common.tcl\n\n# Save a copy of the current database configuration.\n#\ndb close\nforcedelete test.db-triggerA\ncopy_file test.db test.db-triggerA\nsqlite3 db test.db\n\n# Run malloc tests on the INSTEAD OF trigger firing.\n#\ndo_malloc_test triggerA-3 -tclprep {\n  db close\n  forcedelete test.db test.db-journal\n  forcecopy test.db-triggerA test.db\n  sqlite3 db test.db\n  sqlite3_extended_result_codes db 1  \n  db eval {SELECT * FROM v5; -- warm up the cache}\n} -sqlbody {\n   DELETE FROM v5 WHERE x=5;\n   UPDATE v5 SET b=b+9900000 WHERE x BETWEEN 3 AND 5;\n}\n\n# Clean up the saved database copy.\n#\nforcedelete test.db-triggerA\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerB.test",
    "content": "# 2008 April 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests updating tables with constraints within a trigger.  Ticket #3055.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Create test tables with constraints.\n#\ndo_test triggerB-1.1 {\n  execsql {\n    CREATE TABLE x(x INTEGER PRIMARY KEY, y INT NOT NULL);\n    INSERT INTO x(y) VALUES(1);\n    INSERT INTO x(y) VALUES(1);\n    CREATE TEMP VIEW vx AS SELECT x, y, 0 AS yy FROM x;\n    CREATE TEMP TRIGGER tx INSTEAD OF UPDATE OF y ON vx\n    BEGIN\n      UPDATE x SET y = new.y WHERE x = new.x;\n    END;\n    SELECT * FROM vx;\n  }\n} {1 1 0 2 1 0}\ndo_test triggerB-1.2 {\n  execsql {\n    UPDATE vx SET y = yy;\n    SELECT * FROM vx;\n  }\n} {1 0 0 2 0 0}\n\n# Added 2008-08-22:\n#\n# Name resolution within triggers.\n#\ndo_test triggerB-2.1 {\n  catchsql {\n    CREATE TRIGGER ty AFTER INSERT ON x BEGIN\n       SELECT wen.x; -- Unrecognized name\n    END;\n    INSERT INTO x VALUES(1,2);\n  }\n} {1 {no such column: wen.x}}\ndo_test triggerB-2.2 {\n  catchsql {\n    CREATE TRIGGER tz AFTER UPDATE ON x BEGIN\n       SELECT dlo.x; -- Unrecognized name\n    END;\n    UPDATE x SET y=y+1;\n  }\n} {1 {no such column: dlo.x}}\n\ndo_test triggerB-2.3 {\n  execsql {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t2 VALUES(1,2);\n    CREATE TABLE changes(x,y);\n    CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN\n      INSERT INTO changes VALUES(new.a, new.b);\n    END;\n  }\n  execsql {\n    UPDATE t2 SET a=a+10;\n    SELECT * FROM changes;\n  }\n} {11 2}\ndo_test triggerB-2.4 {\n  execsql {\n    CREATE TRIGGER r2t2 AFTER DELETE ON t2 BEGIN\n      INSERT INTO changes VALUES(old.a, old.c);\n    END;\n  }\n  catchsql {\n    DELETE FROM t2;\n  }\n} {1 {no such column: old.c}}\n\n# Triggers maintain a mask of columns from the invoking table that are\n# used in the trigger body as NEW.column or OLD.column.  That mask is then\n# used to reduce the amount of information that needs to be loaded into\n# the NEW and OLD pseudo-tables at run-time.\n#\n# These tests cases check the logic for when there are many columns - more\n# than will fit in a bitmask.\n#\ndo_test triggerB-3.1 {\n  execsql {\n    CREATE TABLE t3(\n       c0,  c1,  c2,  c3,  c4,  c5,  c6,  c7,  c8,  c9,\n       c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,\n       c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,\n       c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,\n       c40, c41, c42, c43, c44, c45, c46, c47, c48, c49,\n       c50, c51, c52, c53, c54, c55, c56, c57, c58, c59,\n       c60, c61, c62, c63, c64, c65\n    );\n    CREATE TABLE t3_changes(colnum, oldval, newval);\n    INSERT INTO t3 VALUES(\n       'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9',\n       'a10','a11','a12','a13','a14','a15','a16','a17','a18','a19',\n       'a20','a21','a22','a23','a24','a25','a26','a27','a28','a29',\n       'a30','a31','a32','a33','a34','a35','a36','a37','a38','a39',\n       'a40','a41','a42','a43','a44','a45','a46','a47','a48','a49',\n       'a50','a51','a52','a53','a54','a55','a56','a57','a58','a59',\n       'a60','a61','a62','a63','a64','a65'\n    );\n  }\n  for {set i 0} {$i<=65} {incr i} {\n    set sql [subst {\n      CREATE TRIGGER t3c$i AFTER UPDATE ON t3\n         WHEN old.c$i!=new.c$i BEGIN\n          INSERT INTO t3_changes VALUES($i, old.c$i, new.c$i);\n      END\n    }]\n    db eval $sql\n  }\n  execsql {\n    SELECT * FROM t3_changes\n  }\n} {}\nfor {set i 0} {$i<=64} {incr i} {\n  do_test triggerB-3.2.$i.1 [subst {\n    execsql {\n      UPDATE t3 SET c$i='b$i';\n      SELECT * FROM t3_changes ORDER BY rowid DESC LIMIT 1;\n    }\n  }] [subst {$i a$i b$i}]\n  do_test triggerB-3.2.$i.2 [subst {\n    execsql {\n      SELECT count(*) FROM t3_changes\n    }\n  }] [expr {$i+1}]\n  do_test triggerB-3.2.$i.2 [subst {\n    execsql {\n      SELECT * FROM t3_changes WHERE colnum=$i\n    }\n  }] [subst {$i a$i b$i}]\n}\n  \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerC.test",
    "content": "# 2009 August 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix triggerC\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test organization:\n#\n# triggerC-1.*: Haphazardly designed trigger related tests that were useful\n#               during an upgrade of the triggers sub-system.\n# \n# triggerC-2.*:\n#\n# triggerC-3.*:\n#\n# triggerC-4.*:\n#\n# triggerC-5.*: Test that when recursive triggers are enabled DELETE \n#               triggers are fired when rows are deleted as part of OR\n#               REPLACE conflict resolution. And that they are not fired\n#               if recursive triggers are not enabled.\n#\n# triggerC-6.*: Test that the recursive_triggers pragma returns correct\n#               results when invoked without an argument.\n#\n\n# Enable recursive triggers for this file.\n#\nexecsql { PRAGMA recursive_triggers = on }\n\n#sqlite3_db_config_lookaside db 0 0 0\n\n#-------------------------------------------------------------------------\n# This block of tests, triggerC-1.*, are not aimed at any specific\n# property of the triggers sub-system. They were created to debug\n# specific problems while modifying SQLite to support recursive\n# triggers. They are left here in case they can help debug the\n# same problems again.\n#\ndo_test triggerC-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE log(t, a1, b1, c1, a2, b2, c2);\n    CREATE TRIGGER trig1 BEFORE INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('before', NULL, NULL, NULL, new.a, new.b, new.c);\n    END;\n    CREATE TRIGGER trig2 AFTER INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('after', NULL, NULL, NULL, new.a, new.b, new.c);\n    END;\n    CREATE TRIGGER trig3 BEFORE UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('before', old.a,old.b,old.c, new.a,new.b,new.c);\n    END;\n    CREATE TRIGGER trig4 AFTER UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('after', old.a,old.b,old.c, new.a,new.b,new.c);\n    END;\n\n    CREATE TRIGGER trig5 BEFORE DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('before', old.a,old.b,old.c, NULL,NULL,NULL);\n    END;\n    CREATE TRIGGER trig6 AFTER DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('after', old.a,old.b,old.c, NULL,NULL,NULL);\n    END;\n  }\n} {}\ndo_test triggerC-1.2 {\n  execsql {\n    INSERT INTO t1 VALUES('A', 'B', 'C');\n    SELECT * FROM log;\n  }\n} {before {} {} {} A B C after {} {} {} A B C}\ndo_test triggerC-1.3 {\n  execsql { SELECT * FROM t1 }\n} {A B C}\ndo_test triggerC-1.4 {\n  execsql {\n    DELETE FROM log;\n    UPDATE t1 SET a = 'a';\n    SELECT * FROM log;\n  }\n} {before A B C a B C after A B C a B C}\ndo_test triggerC-1.5 {\n  execsql { SELECT * FROM t1 }\n} {a B C}\ndo_test triggerC-1.6 {\n  execsql {\n    DELETE FROM log;\n    DELETE FROM t1;\n    SELECT * FROM log;\n  }\n} {before a B C {} {} {} after a B C {} {} {}}\ndo_test triggerC-1.7 {\n  execsql { SELECT * FROM t1 }\n} {}\ndo_test triggerC-1.8 {\n  execsql {\n    CREATE TABLE t4(a, b);\n    CREATE TRIGGER t4t AFTER DELETE ON t4 BEGIN\n      SELECT RAISE(ABORT, 'delete is not supported');\n    END;\n  }\n} {}\ndo_test triggerC-1.9 {\n  execsql { INSERT INTO t4 VALUES(1, 2) }\n  catchsql { DELETE FROM t4 }\n} {1 {delete is not supported}}\ndo_test triggerC-1.10 {\n  execsql { SELECT * FROM t4 }\n} {1 2}\ndo_test triggerC-1.11 {\n  execsql {\n    CREATE TABLE t5 (a primary key, b, c);\n    INSERT INTO t5 values (1, 2, 3);\n    CREATE TRIGGER au_tbl AFTER UPDATE ON t5 BEGIN\n      UPDATE OR IGNORE t5 SET a = new.a, c = 10;\n    END;\n  }\n} {}\ndo_test triggerC-1.12 {\n  catchsql { UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1 }\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-1.13 {\n  execsql {\n    CREATE TABLE t6(a INTEGER PRIMARY KEY, b);\n    INSERT INTO t6 VALUES(1, 2);\n    create trigger r1 after update on t6 for each row begin\n      SELECT 1;\n    end;\n    UPDATE t6 SET a=a; \n  }\n} {}\ndo_test triggerC-1.14 {\n  execsql {\n    DROP TABLE t1;\n    CREATE TABLE cnt(n);\n    INSERT INTO cnt VALUES(0);\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c, d, e);\n    CREATE INDEX t1cd ON t1(c,d);\n    CREATE TRIGGER t1r1 AFTER UPDATE ON t1 BEGIN UPDATE cnt SET n=n+1; END;\n    INSERT INTO t1 VALUES(1,2,3,4,5);\n    INSERT INTO t1 VALUES(6,7,8,9,10);\n    INSERT INTO t1 VALUES(11,12,13,14,15);\n  }\n} {}\ndo_test triggerC-1.15 {\n  catchsql { UPDATE OR ROLLBACK t1 SET a=100 }\n} {1 {UNIQUE constraint failed: t1.a}}\n\n\n#-------------------------------------------------------------------------\n# This block of tests, triggerC-2.*, tests that recursive trigger\n# programs (triggers that fire themselves) work. More specifically,\n# this block focuses on recursive INSERT triggers.\n#\ndo_test triggerC-2.1.0 {\n  execsql {\n    CREATE TABLE t2(a PRIMARY KEY);\n  }\n} {}\n\nforeach {n tdefn rc} {\n  1 { \n    CREATE TRIGGER t2_trig AFTER INSERT ON t2 WHEN (new.a>0) BEGIN\n      INSERT INTO t2 VALUES(new.a - 1);\n    END; \n  } {0 {10 9 8 7 6 5 4 3 2 1 0}}\n\n  2 {\n    CREATE TRIGGER t2_trig AFTER INSERT ON t2 BEGIN\n      SELECT CASE WHEN new.a==2 THEN RAISE(IGNORE) ELSE NULL END;\n      INSERT INTO t2 VALUES(new.a - 1);\n    END;\n  } {0 {10 9 8 7 6 5 4 3 2}}\n\n  3 { \n    CREATE TRIGGER t2_trig BEFORE INSERT ON t2 WHEN (new.a>0) BEGIN\n      INSERT INTO t2 VALUES(new.a - 1);\n    END; \n  } {0 {0 1 2 3 4 5 6 7 8 9 10}}\n\n  4 { \n    CREATE TRIGGER t2_trig BEFORE INSERT ON t2 BEGIN\n      SELECT CASE WHEN new.a==2 THEN RAISE(IGNORE) ELSE NULL END;\n      INSERT INTO t2 VALUES(new.a - 1);\n    END;\n  } {0 {3 4 5 6 7 8 9 10}}\n\n  5 { \n    CREATE TRIGGER t2_trig BEFORE INSERT ON t2 BEGIN\n      INSERT INTO t2 VALUES(new.a - 1);\n    END;\n  } {1 {too many levels of trigger recursion}}\n\n  6 { \n    CREATE TRIGGER t2_trig AFTER INSERT ON t2 WHEN (new.a>0) BEGIN\n      INSERT OR IGNORE INTO t2 VALUES(new.a);\n    END;\n  } {0 10}\n\n  7 { \n    CREATE TRIGGER t2_trig BEFORE INSERT ON t2 WHEN (new.a>0) BEGIN\n      INSERT OR IGNORE INTO t2 VALUES(new.a);\n    END;\n  } {1 {too many levels of trigger recursion}}\n} {\n  do_test triggerC-2.1.$n {\n    catchsql { DROP TRIGGER t2_trig }\n    execsql  { DELETE FROM t2 }\n    execsql  $tdefn\n    catchsql {\n      INSERT INTO t2 VALUES(10);\n      SELECT * FROM t2 ORDER BY rowid;\n    }\n  } $rc\n}\n\ndo_test triggerC-2.2 {\n  execsql \"\n    CREATE TABLE t22(x);\n\n    CREATE TRIGGER t22a AFTER INSERT ON t22 BEGIN\n      INSERT INTO t22 SELECT x + (SELECT max(x) FROM t22) FROM t22;\n    END;\n    CREATE TRIGGER t22b BEFORE INSERT ON t22 BEGIN\n      SELECT CASE WHEN (SELECT count(*) FROM t22) >= [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]\n                  THEN RAISE(IGNORE)\n                  ELSE NULL END;\n    END;\n\n    INSERT INTO t22 VALUES(1);\n    SELECT count(*) FROM t22;\n  \"\n} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]\n\ndo_test triggerC-2.3 {\n  execsql \"\n    CREATE TABLE t23(x PRIMARY KEY);\n\n    CREATE TRIGGER t23a AFTER INSERT ON t23 BEGIN\n      INSERT INTO t23 VALUES(new.x + 1);\n    END;\n\n    CREATE TRIGGER t23b BEFORE INSERT ON t23 BEGIN\n      SELECT CASE WHEN new.x>[expr $SQLITE_MAX_TRIGGER_DEPTH / 2]\n                  THEN RAISE(IGNORE)\n                  ELSE NULL END;\n    END;\n\n    INSERT INTO t23 VALUES(1);\n    SELECT count(*) FROM t23;\n  \"\n} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 2]]\n \n\n#-----------------------------------------------------------------------\n# This block of tests, triggerC-3.*, test that SQLite throws an exception\n# when it detects excessive recursion.\n#\ndo_test triggerC-3.1.1 {\n  execsql {\n    CREATE TABLE t3(a, b);\n    CREATE TRIGGER t3i AFTER INSERT ON t3 BEGIN\n      DELETE FROM t3 WHERE rowid = new.rowid;\n    END;\n    CREATE TRIGGER t3d AFTER DELETE ON t3 BEGIN\n      INSERT INTO t3 VALUES(old.a, old.b);\n    END;\n  }\n} {}\ndo_test triggerC-3.1.2 {\n  catchsql { INSERT INTO t3 VALUES(0,0) }\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-3.1.3 {\n  execsql { SELECT * FROM t3 }\n} {}\n\ndo_test triggerC-3.2.1 {\n  execsql \"\n    CREATE TABLE t3b(x);\n    CREATE TRIGGER t3bi AFTER INSERT ON t3b WHEN new.x<[expr $SQLITE_MAX_TRIGGER_DEPTH * 2] BEGIN\n      INSERT INTO t3b VALUES(new.x+1);\n    END;\n  \"\n  catchsql {\n    INSERT INTO t3b VALUES(1);\n  }\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-3.2.2 {\n  db eval {SELECT * FROM t3b}\n} {}\n\ndo_test triggerC-3.3.1 {\n  catchsql \"\n    INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH + 1]);\n  \"\n} {0 {}}\ndo_test triggerC-3.3.2 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} [list $SQLITE_MAX_TRIGGER_DEPTH [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH + 1]]\n\ndo_test triggerC-3.4.1 {\n  catchsql \"\n    DELETE FROM t3b;\n    INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH - 1]);\n  \"\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-3.4.2 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} {0 {} {}}\n\ndo_test triggerC-3.5.1 {\n  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH  [expr $SQLITE_MAX_TRIGGER_DEPTH / 10]\n  catchsql \"\n    INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]);\n  \"\n} {0 {}}\ndo_test triggerC-3.5.2 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} [list [expr $SQLITE_MAX_TRIGGER_DEPTH / 10] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10) + 1]]\n\ndo_test triggerC-3.5.3 {\n  catchsql \"\n    DELETE FROM t3b;\n    INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - ($SQLITE_MAX_TRIGGER_DEPTH / 10)]);\n  \"\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-3.5.4 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} {0 {} {}}\n\ndo_test triggerC-3.6.1 {\n  sqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH 1\n  catchsql \"\n    INSERT INTO t3b VALUES([expr $SQLITE_MAX_TRIGGER_DEPTH * 2]);\n  \"\n} {0 {}}\ndo_test triggerC-3.6.2 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} [list 1 [expr $SQLITE_MAX_TRIGGER_DEPTH * 2] [expr $SQLITE_MAX_TRIGGER_DEPTH * 2]]\n\ndo_test triggerC-3.6.3 {\n  catchsql \"\n    DELETE FROM t3b;\n    INSERT INTO t3b VALUES([expr ($SQLITE_MAX_TRIGGER_DEPTH * 2) - 1]);\n  \"\n} {1 {too many levels of trigger recursion}}\ndo_test triggerC-3.6.4 {\n  db eval {SELECT count(*), max(x), min(x) FROM t3b}\n} {0 {} {}}\nsqlite3_limit db SQLITE_LIMIT_TRIGGER_DEPTH $SQLITE_MAX_TRIGGER_DEPTH\n\n\n#-----------------------------------------------------------------------\n# This next block of tests, triggerC-4.*, checks that affinity \n# transformations and constraint processing is performed at the correct \n# times relative to BEFORE and AFTER triggers.\n#\n# For an INSERT statement, for each row to be inserted:\n#\n#   1. Apply affinities to non-rowid values to be inserted.\n#   2. Fire BEFORE triggers.\n#   3. Process constraints.\n#   4. Insert new record.\n#   5. Fire AFTER triggers.\n#\n# If the value of the rowid field is to be automatically assigned, it is\n# set to -1 in the new.* record. Even if it is explicitly set to NULL\n# by the INSERT statement.\n#\n# For an UPDATE statement, for each row to be deleted:\n#\n#   1. Apply affinities to non-rowid values to be inserted.\n#   2. Fire BEFORE triggers.\n#   3. Process constraints.\n#   4. Insert new record.\n#   5. Fire AFTER triggers.\n#\n# For a DELETE statement, for each row to be deleted:\n#\n#   1. Fire BEFORE triggers.\n#   2. Remove database record.\n#   3. Fire AFTER triggers.\n#\n# When a numeric value that as an exact integer representation is stored\n# in a column with REAL affinity, it is actually stored as an integer.\n# These tests check that the typeof() such values is always 'real',\n# not 'integer'.\n#\n# triggerC-4.1.*: Check that affinity transformations are made before\n#                 triggers are invoked.\n#\ndo_test triggerC-4.1.1 {\n  catchsql { DROP TABLE log }\n  catchsql { DROP TABLE t4 }\n  execsql {\n    CREATE TABLE log(t);\n    CREATE TABLE t4(a TEXT,b INTEGER,c REAL);\n    CREATE TRIGGER t4bi BEFORE INSERT ON t4 BEGIN\n      INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||\n                             new.a     || ' ' || typeof(new.a)     || ' ' ||\n                             new.b     || ' ' || typeof(new.b)     || ' ' ||\n                             new.c     || ' ' || typeof(new.c)\n      );\n    END;\n    CREATE TRIGGER t4ai AFTER INSERT ON t4 BEGIN\n      INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||\n                             new.a     || ' ' || typeof(new.a)     || ' ' ||\n                             new.b     || ' ' || typeof(new.b)     || ' ' ||\n                             new.c     || ' ' || typeof(new.c)\n      );\n    END;\n    CREATE TRIGGER t4bd BEFORE DELETE ON t4 BEGIN\n      INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||\n                             old.a     || ' ' || typeof(old.a)     || ' ' ||\n                             old.b     || ' ' || typeof(old.b)     || ' ' ||\n                             old.c     || ' ' || typeof(old.c)\n      );\n    END;\n    CREATE TRIGGER t4ad AFTER DELETE ON t4 BEGIN\n      INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||\n                             old.a     || ' ' || typeof(old.a)     || ' ' ||\n                             old.b     || ' ' || typeof(old.b)     || ' ' ||\n                             old.c     || ' ' || typeof(old.c)\n      );\n    END;\n    CREATE TRIGGER t4bu BEFORE UPDATE ON t4 BEGIN\n      INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||\n                             old.a     || ' ' || typeof(old.a)     || ' ' ||\n                             old.b     || ' ' || typeof(old.b)     || ' ' ||\n                             old.c     || ' ' || typeof(old.c)\n      );\n      INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||\n                             new.a     || ' ' || typeof(new.a)     || ' ' ||\n                             new.b     || ' ' || typeof(new.b)     || ' ' ||\n                             new.c     || ' ' || typeof(new.c)\n      );\n    END;\n    CREATE TRIGGER t4au AFTER UPDATE ON t4 BEGIN\n      INSERT INTO log VALUES(old.rowid || ' ' || typeof(old.rowid) || ' ' ||\n                             old.a     || ' ' || typeof(old.a)     || ' ' ||\n                             old.b     || ' ' || typeof(old.b)     || ' ' ||\n                             old.c     || ' ' || typeof(old.c)\n      );\n      INSERT INTO log VALUES(new.rowid || ' ' || typeof(new.rowid) || ' ' ||\n                             new.a     || ' ' || typeof(new.a)     || ' ' ||\n                             new.b     || ' ' || typeof(new.b)     || ' ' ||\n                             new.c     || ' ' || typeof(new.c)\n      );\n    END;\n  }\n} {}\nforeach {n insert log} {\n\n  2 { \n   INSERT INTO t4 VALUES('1', '1', '1');\n   DELETE FROM t4;\n  } {\n    -1 integer 1 text 1 integer 1.0 real \n     1 integer 1 text 1 integer 1.0 real\n     1 integer 1 text 1 integer 1.0 real \n     1 integer 1 text 1 integer 1.0 real\n  }\n\n  3 { \n   INSERT INTO t4(rowid,a,b,c) VALUES(45, 45, 45, 45);\n   DELETE FROM t4;\n  } {\n    45 integer 45 text 45 integer 45.0 real\n    45 integer 45 text 45 integer 45.0 real\n    45 integer 45 text 45 integer 45.0 real\n    45 integer 45 text 45 integer 45.0 real\n  }\n\n  4 { \n   INSERT INTO t4(rowid,a,b,c) VALUES(-42.0, -42.0, -42.0, -42.0);\n   DELETE FROM t4;\n  } {\n    -42 integer -42.0 text -42 integer -42.0 real \n    -42 integer -42.0 text -42 integer -42.0 real\n    -42 integer -42.0 text -42 integer -42.0 real \n    -42 integer -42.0 text -42 integer -42.0 real\n  }\n\n  5 { \n   INSERT INTO t4(rowid,a,b,c) VALUES(NULL, -42.4, -42.4, -42.4);\n   DELETE FROM t4;\n  } {\n    -1 integer -42.4 text -42.4 real -42.4 real\n     1 integer -42.4 text -42.4 real -42.4 real\n     1 integer -42.4 text -42.4 real -42.4 real\n     1 integer -42.4 text -42.4 real -42.4 real\n  }\n\n  6 { \n   INSERT INTO t4 VALUES(7, 7, 7);\n   UPDATE t4 SET a=8, b=8, c=8;\n  } {\n    -1 integer 7 text 7 integer 7.0 real\n     1 integer 7 text 7 integer 7.0 real\n     1 integer 7 text 7 integer 7.0 real\n     1 integer 8 text 8 integer 8.0 real\n     1 integer 7 text 7 integer 7.0 real\n     1 integer 8 text 8 integer 8.0 real\n  }\n\n  7 { \n   UPDATE t4 SET rowid=2;\n  } {\n     1 integer 8 text 8 integer 8.0 real\n     2 integer 8 text 8 integer 8.0 real\n     1 integer 8 text 8 integer 8.0 real\n     2 integer 8 text 8 integer 8.0 real\n  }\n\n  8 { \n   UPDATE t4 SET a='9', b='9', c='9';\n  } {\n     2 integer 8 text 8 integer 8.0 real\n     2 integer 9 text 9 integer 9.0 real\n     2 integer 8 text 8 integer 8.0 real\n     2 integer 9 text 9 integer 9.0 real\n  }\n\n  9 { \n   UPDATE t4 SET a='9.1', b='9.1', c='9.1';\n  } {\n     2 integer 9   text 9   integer 9.0 real\n     2 integer 9.1 text 9.1 real    9.1 real\n     2 integer 9   text 9   integer 9.0 real\n     2 integer 9.1 text 9.1 real    9.1 real\n  }\n} {\n  do_test triggerC-4.1.$n {\n    eval concat [execsql \" \n      DELETE FROM log;\n      $insert ; \n      SELECT * FROM log ORDER BY rowid;\n    \"]\n  } [join $log \" \"]\n} \n\n#-------------------------------------------------------------------------\n# This block of tests, triggerC-5.*, test that DELETE triggers are fired\n# if a row is deleted as a result of OR REPLACE conflict resolution.\n#\ndo_test triggerC-5.1.0 {\n  execsql {\n    DROP TABLE IF EXISTS t5;\n    CREATE TABLE t5(a INTEGER PRIMARY KEY, b);\n    CREATE UNIQUE INDEX t5i ON t5(b);\n    INSERT INTO t5 VALUES(1, 'a');\n    INSERT INTO t5 VALUES(2, 'b');\n    INSERT INTO t5 VALUES(3, 'c');\n\n    CREATE TABLE t5g(a, b, c);\n    CREATE TRIGGER t5t BEFORE DELETE ON t5 BEGIN\n      INSERT INTO t5g VALUES(old.a, old.b, (SELECT count(*) FROM t5));\n    END;\n  }\n} {}\nforeach {n dml t5g t5} {\n  1 \"DELETE FROM t5 WHERE a=2\"                        {2 b 3} {1 a 3 c}\n  2 \"INSERT OR REPLACE INTO t5 VALUES(2, 'd')\"        {2 b 3} {1 a 2 d 3 c}\n  3 \"UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3\"      {2 b 3} {1 a 2 c}\n  4 \"INSERT OR REPLACE INTO t5 VALUES(4, 'b')\"        {2 b 3} {1 a 3 c 4 b}\n  5 \"UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'\"  {2 b 3} {1 a 3 b}\n  6 \"INSERT OR REPLACE INTO t5 VALUES(2, 'c')\"        {2 b 3 3 c 2} {1 a 2 c}\n  7 \"UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3\" {1 a 3 2 b 2} {1 b}\n} {\n  do_test triggerC-5.1.$n {\n    execsql \"\n      BEGIN;\n        $dml ;\n        SELECT * FROM t5g ORDER BY rowid;\n        SELECT * FROM t5 ORDER BY rowid;\n      ROLLBACK;\n    \"\n  } [concat $t5g $t5]\n}\ndo_test triggerC-5.2.0 {\n  execsql {\n    DROP TRIGGER t5t;\n    CREATE TRIGGER t5t AFTER DELETE ON t5 BEGIN\n      INSERT INTO t5g VALUES(old.a, old.b, (SELECT count(*) FROM t5));\n    END;\n  }\n} {}\nforeach {n dml t5g t5} {\n  1 \"DELETE FROM t5 WHERE a=2\"                        {2 b 2} {1 a 3 c}\n  2 \"INSERT OR REPLACE INTO t5 VALUES(2, 'd')\"        {2 b 2} {1 a 2 d 3 c}\n  3 \"UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3\"      {2 b 2} {1 a 2 c}\n  4 \"INSERT OR REPLACE INTO t5 VALUES(4, 'b')\"        {2 b 2} {1 a 3 c 4 b}\n  5 \"UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'\"  {2 b 2} {1 a 3 b}\n  6 \"INSERT OR REPLACE INTO t5 VALUES(2, 'c')\"        {2 b 2 3 c 1} {1 a 2 c}\n  7 \"UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3\" {1 a 2 2 b 1} {1 b}\n} {\n  do_test triggerC-5.2.$n {\n    execsql \"\n      BEGIN;\n        $dml ;\n        SELECT * FROM t5g ORDER BY rowid;\n        SELECT * FROM t5 ORDER BY rowid;\n      ROLLBACK;\n    \"\n  } [concat $t5g $t5]\n}\ndo_test triggerC-5.3.0 {\n  execsql { PRAGMA recursive_triggers = off }\n} {}\nforeach {n dml t5g t5} {\n  1 \"DELETE FROM t5 WHERE a=2\"                        {2 b 2} {1 a 3 c}\n  2 \"INSERT OR REPLACE INTO t5 VALUES(2, 'd')\"        {} {1 a 2 d 3 c}\n  3 \"UPDATE OR REPLACE t5 SET a = 2 WHERE a = 3\"      {} {1 a 2 c}\n  4 \"INSERT OR REPLACE INTO t5 VALUES(4, 'b')\"        {} {1 a 3 c 4 b}\n  5 \"UPDATE OR REPLACE t5 SET b = 'b' WHERE b = 'c'\"  {} {1 a 3 b}\n  6 \"INSERT OR REPLACE INTO t5 VALUES(2, 'c')\"        {} {1 a 2 c}\n  7 \"UPDATE OR REPLACE t5 SET a=1, b='b' WHERE a = 3\" {} {1 b}\n} {\n  do_test triggerC-5.3.$n {\n    execsql \"\n      BEGIN;\n        $dml ;\n        SELECT * FROM t5g ORDER BY rowid;\n        SELECT * FROM t5 ORDER BY rowid;\n      ROLLBACK;\n    \"\n  } [concat $t5g $t5]\n}\ndo_test triggerC-5.3.8 {\n  execsql { PRAGMA recursive_triggers = on }\n} {}\n\n#-------------------------------------------------------------------------\n# This block of tests, triggerC-6.*, tests that \"PRAGMA recursive_triggers\"\n# statements return the current value of the recursive triggers flag.\n#\ndo_test triggerC-6.1 {\n  execsql { PRAGMA recursive_triggers }\n} {1}\ndo_test triggerC-6.2 {\n  execsql { \n    PRAGMA recursive_triggers = off;\n    PRAGMA recursive_triggers;\n  }\n} {0}\ndo_test triggerC-6.3 {\n  execsql { \n    PRAGMA recursive_triggers = on;\n    PRAGMA recursive_triggers;\n  }\n} {1}\n\n#-------------------------------------------------------------------------\n# Test some of the \"undefined behaviour\" associated with triggers. The\n# undefined behaviour occurs when a row being updated or deleted is \n# manipulated by a BEFORE trigger.\n# \ndo_test triggerC-7.1 {\n  execsql {\n    CREATE TABLE t8(x);\n    CREATE TABLE t7(a, b);\n    INSERT INTO t7 VALUES(1, 2);\n    INSERT INTO t7 VALUES(3, 4);\n    INSERT INTO t7 VALUES(5, 6);\n    CREATE TRIGGER t7t BEFORE UPDATE ON t7 BEGIN\n      DELETE FROM t7 WHERE a = 1;\n    END;\n    CREATE TRIGGER t7ta AFTER UPDATE ON t7 BEGIN\n      INSERT INTO t8 VALUES('after fired ' || old.rowid || '->' || new.rowid);\n    END;\n  }\n} {}\ndo_test triggerC-7.2 {\n  execsql {\n    BEGIN;\n      UPDATE t7 SET b=7 WHERE a = 5;\n      SELECT * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {3 4 5 7 {after fired 3->3}}\ndo_test triggerC-7.3 {\n  execsql {\n    BEGIN;\n      UPDATE t7 SET b=7 WHERE a = 1;\n      SELECT * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {3 4 5 6}\n\ndo_test triggerC-7.4 {\n  execsql {\n    DROP TRIGGER t7t;\n    CREATE TRIGGER t7t BEFORE UPDATE ON t7 WHEN (old.rowid!=1 OR new.rowid!=8)\n    BEGIN\n      UPDATE t7 set rowid = 8 WHERE rowid=1;\n    END;\n  }\n} {}\ndo_test triggerC-7.5 {\n  execsql {\n    BEGIN;\n      UPDATE t7 SET b=7 WHERE a = 5;\n      SELECT rowid, * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {2 3 4 3 5 7 8 1 2 {after fired 1->8} {after fired 3->3}}\ndo_test triggerC-7.6 {\n  execsql {\n    BEGIN;\n      UPDATE t7 SET b=7 WHERE a = 1;\n      SELECT rowid, * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {2 3 4 3 5 6 8 1 2 {after fired 1->8}}\n\ndo_test triggerC-7.7 {\n  execsql {\n    DROP TRIGGER t7t;\n    DROP TRIGGER t7ta;\n    CREATE TRIGGER t7t BEFORE DELETE ON t7 BEGIN\n      UPDATE t7 set rowid = 8 WHERE rowid=1;\n    END;\n    CREATE TRIGGER t7ta AFTER DELETE ON t7 BEGIN\n      INSERT INTO t8 VALUES('after fired ' || old.rowid);\n    END;\n  }\n} {}\ndo_test triggerC-7.8 {\n  execsql {\n    BEGIN;\n      DELETE FROM t7 WHERE a = 3;\n      SELECT rowid, * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {3 5 6 8 1 2 {after fired 2}}\ndo_test triggerC-7.9 {\n  execsql {\n    BEGIN;\n      DELETE FROM t7 WHERE a = 1;\n      SELECT rowid, * FROM t7;\n      SELECT * FROM t8;\n    ROLLBACK;\n  }\n} {2 3 4 3 5 6 8 1 2}\n\n# Ticket [e25d9ea771febc9c311928c1c01c3163dcb26643]\n# \ndo_test triggerC-9.1 {\n  execsql {\n    CREATE TABLE t9(a,b);\n    CREATE INDEX t9b ON t9(b);\n    INSERT INTO t9 VALUES(1,0);\n    INSERT INTO t9 VALUES(2,1);\n    INSERT INTO t9 VALUES(3,2);\n    INSERT INTO t9 SELECT a+3, a+2 FROM t9;\n    INSERT INTO t9 SELECT a+6, a+5 FROM t9;\n    SELECT a FROM t9 ORDER BY a;\n  }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test triggerC-9.2 {\n  execsql {\n    CREATE TRIGGER t9r1 AFTER DELETE ON t9 BEGIN\n      DELETE FROM t9 WHERE b=old.a;\n    END;\n    DELETE FROM t9 WHERE b=4;\n    SELECT a FROM t9 ORDER BY a;\n  }\n} {1 2 3 4}\n\n# At one point (between versions 3.6.18 and 3.6.20 inclusive), an UPDATE \n# that fired a BEFORE trigger that itself updated the same row as the \n# statement causing it to fire was causing a strange side-effect: The \n# values updated by the statement within the trigger were being overwritten \n# by the values in the new.* array, even if those values were not \n# themselves written by the parent UPDATE statement.\n#\n# Technically speaking this was not a bug. The SQLite documentation says\n# that if a BEFORE UPDATE or BEFORE DELETE trigger modifies or deletes the\n# row that the parent statement is operating on the results are undefined. \n# But as of 3.6.21 behaviour is restored to the way it was in versions\n# 3.6.17 and earlier to avoid causing unnecessary difficulties.\n#\ndo_test triggerC-10.1 {\n  execsql {\n    CREATE TABLE t10(a, updatecnt DEFAULT 0);\n    CREATE TRIGGER t10_bu BEFORE UPDATE OF a ON t10 BEGIN\n      UPDATE t10 SET updatecnt = updatecnt+1 WHERE rowid = old.rowid;\n    END;\n    INSERT INTO t10(a) VALUES('hello');\n  }\n\n  # Before the problem was fixed, table t10 would contain the tuple \n  # (world, 0) after running the following script (because the value\n  # 1 written to column \"updatecnt\" was clobbered by the old value 0).\n  #\n  execsql {\n    UPDATE t10 SET a = 'world';\n    SELECT * FROM t10;\n  }\n} {world 1}\n\ndo_test triggerC-10.2 {\n  execsql {\n    UPDATE t10 SET a = 'tcl', updatecnt = 5;\n    SELECT * FROM t10;\n  }\n} {tcl 5}\n\ndo_test triggerC-10.3 {\n  execsql {\n    CREATE TABLE t11(\n      c1,   c2,  c3,  c4,  c5,  c6,  c7,  c8,  c9, c10,\n      c11, c12, c13, c14, c15, c16, c17, c18, c19, c20,\n      c21, c22, c23, c24, c25, c26, c27, c28, c29, c30,\n      c31, c32, c33, c34, c35, c36, c37, c38, c39, c40\n    );\n\n    CREATE TRIGGER t11_bu BEFORE UPDATE OF c1 ON t11 BEGIN\n      UPDATE t11 SET c31 = c31+1, c32=c32+1 WHERE rowid = old.rowid;\n    END;\n\n    INSERT INTO t11 VALUES(\n      1,   2,  3,  4,  5,  6,  7,  8,  9, 10,\n      11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n      21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n      31, 32, 33, 34, 35, 36, 37, 38, 39, 40\n    );\n  }\n\n  # Before the problem was fixed, table t10 would contain the tuple \n  # (world, 0) after running the following script (because the value\n  # 1 written to column \"updatecnt\" was clobbered by the old value 0).\n  #\n  execsql {\n    UPDATE t11 SET c4=35, c33=22, c1=5;\n    SELECT * FROM t11;\n  } \n} {5 2 3 35 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 32 33 22 34 35 36 37 38 39 40}\n\n#-------------------------------------------------------------------------\n# Test that bug [371bab5d65] has been fixed. BEFORE INSERT and INSTEAD OF\n# INSERT triggers with the DEFAULT VALUES INSERT syntax.\n#\ndo_test triggerC-11.0 {\n  catchsql { DROP TABLE log }\n  execsql  { CREATE TABLE log(a, b) }\n} {}\n\nforeach {testno tbl defaults} {\n  1 \"CREATE TABLE t1(a, b)\"                          {{} {}}\n  2 \"CREATE TABLE t1(a DEFAULT 1, b DEFAULT 'abc')\"  {1 abc}\n  3 \"CREATE TABLE t1(a, b DEFAULT 4.5)\"              {{} 4.5}\n} {\n  do_test triggerC-11.$testno.1 {\n    catchsql { DROP TABLE t1 }\n    execsql { DELETE FROM log }\n    execsql $tbl\n    execsql {\n      CREATE TRIGGER tt1 BEFORE INSERT ON t1 BEGIN \n        INSERT INTO log VALUES(new.a, new.b);\n      END;\n      INSERT INTO t1 DEFAULT VALUES;\n      SELECT * FROM log;\n    }\n  } $defaults\n\n  do_test triggerC-11.$testno.2 {\n    execsql { DELETE FROM log }\n    execsql {\n      CREATE TRIGGER tt2 AFTER INSERT ON t1 BEGIN \n        INSERT INTO log VALUES(new.a, new.b);\n      END;\n      INSERT INTO t1 DEFAULT VALUES;\n      SELECT * FROM log;\n    }\n  } [concat $defaults $defaults]\n\n  do_test triggerC-11.$testno.3 {\n    execsql { DROP TRIGGER tt1 }\n    execsql { DELETE FROM log }\n    execsql {\n      INSERT INTO t1 DEFAULT VALUES;\n      SELECT * FROM log;\n    }\n  } $defaults\n} \ndo_test triggerC-11.4 {\n  catchsql { DROP TABLE t2 }\n  execsql {\n    DELETE FROM log;\n    CREATE TABLE t2(a, b);\n    CREATE VIEW v2 AS SELECT * FROM t2;\n    CREATE TRIGGER tv2 INSTEAD OF INSERT ON v2 BEGIN\n      INSERT INTO log VALUES(new.a, new.b);\n    END;\n    INSERT INTO v2 DEFAULT VALUES;\n    SELECT a, b, a IS NULL, b IS NULL FROM log;\n  }\n} {{} {} 1 1}\n\ndo_test triggerC-12.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n    CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1 ; END ;\n    SELECT count(*) FROM sqlite_master;\n  }\n} {2}\ndo_test triggerC-12.2 {\n  db eval { SELECT * FROM t1 } {\n    if {$a == 3} { execsql { DROP TRIGGER tr1 } }\n  }\n  execsql { SELECT count(*) FROM sqlite_master }\n} {1}\n\ndo_execsql_test triggerC-13.1 {\n  PRAGMA recursive_triggers = ON;\n  CREATE TABLE t12(a, b);\n  INSERT INTO t12 VALUES(1, 2);\n  CREATE TRIGGER tr12 AFTER UPDATE ON t12 BEGIN\n    UPDATE t12 SET a=new.a+1, b=new.b+1;\n  END;\n} {}\ndo_catchsql_test triggerC-13.2 {\n  UPDATE t12 SET a=a+1, b=b+1;\n} {1 {too many levels of trigger recursion}}\n\n#-------------------------------------------------------------------------\n# The following tests seek to verify that constant values (i.e. literals)\n# are not factored out of loops within trigger programs. SQLite does\n# not factor constants out of loops within trigger programs as it may only\n# do so in code generated before the first table or index is opened. And\n# by the time a trigger program is coded, at least one table or index has\n# always been opened.\n#\n# At one point, due to a bug allowing constant factoring within triggers,\n# the following SQL would produce the wrong result.\n#\nset SQL {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(a, c);\n  CREATE INDEX i2 ON t1(b, c);\n  INSERT INTO t1 VALUES(1, 2, 3);\n\n  CREATE TABLE t2(e, f);\n  CREATE INDEX i3 ON t2(e);\n  INSERT INTO t2 VALUES(1234567, 3);\n\n  CREATE TABLE empty(x);\n  CREATE TABLE not_empty(x);\n  INSERT INTO not_empty VALUES(2);\n\n  CREATE TABLE t4(x);\n  CREATE TABLE t5(g, h, i);\n\n  CREATE TRIGGER trig BEFORE INSERT ON t4 BEGIN\n    INSERT INTO t5 SELECT * FROM t1 WHERE \n        (a IN (SELECT x FROM empty) OR b IN (SELECT x FROM not_empty)) \n        AND c IN (SELECT f FROM t2 WHERE e=1234567);\n  END;\n\n  INSERT INTO t4 VALUES(0);\n  SELECT * FROM t5;\n}\n\nreset_db\ndo_execsql_test triggerC-14.1 $SQL {1 2 3}\nreset_db\noptimization_control db factor-constants 0\ndo_execsql_test triggerC-14.2 $SQL {1 2 3}\n\n#-------------------------------------------------------------------------\n# Check that table names used by trigger programs are dequoted exactly\n# once.\n#\ndo_execsql_test 15.1.1 {\n  PRAGMA recursive_triggers = 1;\n  CREATE TABLE node(\n      id int not null primary key, \n      pid int not null default 0 references node,\n      key varchar not null, \n      path varchar default '',\n      unique(pid, key)\n      );\n  CREATE TRIGGER node_delete_referencing AFTER DELETE ON \"node\"\n    BEGIN\n    DELETE FROM \"node\" WHERE pid = old.\"id\";\n  END;\n}\ndo_execsql_test 15.1.2 {\n  INSERT INTO node(id, pid, key) VALUES(9, 0, 'test');\n  INSERT INTO node(id, pid, key) VALUES(90, 9, 'test1');\n  INSERT INTO node(id, pid, key) VALUES(900, 90, 'test2');\n  DELETE FROM node WHERE id=9;\n  SELECT * FROM node;\n}\n\ndo_execsql_test 15.2.1 {\n  CREATE TABLE   x1  (x);\n\n  CREATE TABLE   x2  (a, b);\n  CREATE TABLE '\"x2\"'(a, b);\n\n  INSERT INTO x2 VALUES(1, 2);\n  INSERT INTO x2 VALUES(3, 4);\n  INSERT INTO '\"x2\"' SELECT * FROM x2;\n\n  CREATE TRIGGER x1ai AFTER INSERT ON x1 BEGIN\n    INSERT INTO \"\"\"x2\"\"\" VALUES('x', 'y');\n    DELETE FROM \"\"\"x2\"\"\" WHERE a=1;\n    UPDATE \"\"\"x2\"\"\" SET b = 11 WHERE a = 3;\n  END;\n\n  INSERT INTO x1 VALUES('go!');\n}\n\ndo_execsql_test 15.2.2 { SELECT * FROM x2;       } {1 2 3 4}\ndo_execsql_test 15.2.3 { SELECT * FROM \"\"\"x2\"\"\"; } {3 11 x y}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerD.test",
    "content": "# 2009 December 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Verify that when columns named \"rowid\", \"oid\", and \"_rowid_\" appear\n# in a table as ordinary columns (not as the INTEGER PRIMARY KEY) then\n# the use of these columns in triggers will refer to the column and not\n# to the actual ROWID.  Ticket [34d2ae1c6d08b5271ba5e5592936d4a1d913ffe3]\n#\n# Also, verify that triggers created like this:\n#\n#    CREATE TRIGGER attached.trig AFTER INSERT ON attached.tab ...\n#\n# can be reparsed as a main database.  Ticket [d6ddba6706353915ceedc56b4e3]\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Triggers on tables where the table has ordinary columns named\n# rowid, oid, and _rowid_.\n#\ndo_test triggerD-1.1 {\n  db eval {\n    CREATE TABLE t1(rowid, oid, _rowid_, x);\n    CREATE TABLE log(a,b,c,d,e);\n    CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('r1', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('r2', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('r3.old', old.rowid, old.oid, old._rowid_, old.x);\n      INSERT INTO log VALUES('r3.new', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('r4.old', old.rowid, old.oid, old._rowid_, old.x);\n      INSERT INTO log VALUES('r4.new', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r5 BEFORE DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('r5', old.rowid, old.oid, old._rowid_, old.x);\n    END;\n    CREATE TRIGGER r6 AFTER DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('r6', old.rowid, old.oid, old._rowid_, old.x);\n    END;\n  }\n} {}\ndo_test triggerD-1.2 {\n  db eval {\n    INSERT INTO t1 VALUES(100,200,300,400);\n    SELECT * FROM log\n  }\n} {r1 100 200 300 400 r2 100 200 300 400}\ndo_test triggerD-1.3 {\n  db eval {\n    DELETE FROM log;\n    UPDATE t1 SET rowid=rowid+1;\n    SELECT * FROM log\n  }\n} {r3.old 100 200 300 400 r3.new 101 200 300 400 r4.old 100 200 300 400 r4.new 101 200 300 400}\ndo_test triggerD-1.4 {\n  db eval {\n    DELETE FROM log;\n    DELETE FROM t1;\n    SELECT * FROM log\n  }\n} {r5 101 200 300 400 r6 101 200 300 400}\n\n# Triggers on tables where the table does not have ordinary columns named\n# rowid, oid, and _rowid_.\n#\ndo_test triggerD-2.1 {\n  db eval {\n    DROP TABLE t1;\n    CREATE TABLE t1(w,x,y,z);\n    CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('r1', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN\n      INSERT INTO log VALUES('r2', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('r3.old', old.rowid, old.oid, old._rowid_, old.x);\n      INSERT INTO log VALUES('r3.new', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN\n      INSERT INTO log VALUES('r4.old', old.rowid, old.oid, old._rowid_, old.x);\n      INSERT INTO log VALUES('r4.new', new.rowid, new.oid, new._rowid_, new.x);\n    END;\n    CREATE TRIGGER r5 BEFORE DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('r5', old.rowid, old.oid, old._rowid_, old.x);\n    END;\n    CREATE TRIGGER r6 AFTER DELETE ON t1 BEGIN\n      INSERT INTO log VALUES('r6', old.rowid, old.oid, old._rowid_, old.x);\n    END;\n  }\n} {}\ndo_test triggerD-2.2 {\n  db eval {\n    DELETE FROM log;\n    INSERT INTO t1 VALUES(100,200,300,400);\n    SELECT * FROM log;\n  }\n} {r1 -1 -1 -1 200 r2 1 1 1 200}\ndo_test triggerD-2.3 {\n  db eval {\n    DELETE FROM log;\n    UPDATE t1 SET x=x+1;\n    SELECT * FROM log\n  }\n} {r3.old 1 1 1 200 r3.new 1 1 1 201 r4.old 1 1 1 200 r4.new 1 1 1 201}\ndo_test triggerD-2.4 {\n  db eval {\n    DELETE FROM log;\n    DELETE FROM t1;\n    SELECT * FROM log\n  }\n} {r5 1 1 1 201 r6 1 1 1 201}\n\n\n###########################################################################\n#\n# Ticket [985771e1161200ae5eac3162686ea6711c035d08]:\n#\n# When both a main database table and a TEMP table have the same name,\n# and a main database trigge is created on the main table, the trigger\n# is incorrectly bound to the TEMP table. For example:\n#\n#   CREATE TABLE t1(x);\n#   CREATE TEMP TABLE t1(x);\n#   CREATE TABLE t2(z);\n#   CREATE TRIGGER main.r1 AFTER INSERT ON t1 BEGIN\n#     INSERT INTO t2 VALUES(10000 + new.x);\n#   END;\n#   INSERT INTO main.t1 VALUES(3);\n#   INSERT INTO temp.t1 VALUES(4);\n#   SELECT * FROM t2;\n# \n# The r1 trigger fires when the value 4 is inserted into the temp.t1\n# table, rather than when value 3 is inserted into main.t1.\n#\ndo_test triggerD-3.1 {\n  db eval {\n    CREATE TABLE t300(x);\n    CREATE TEMP TABLE t300(x);\n    CREATE TABLE t301(y);\n    CREATE TRIGGER main.r300 AFTER INSERT ON t300 BEGIN\n      INSERT INTO t301 VALUES(10000 + new.x);\n    END;\n    INSERT INTO main.t300 VALUES(3);\n    INSERT INTO temp.t300 VALUES(4);\n    SELECT * FROM t301;\n  }\n} {10003}\ndo_test triggerD-3.2 {\n  db eval {\n    DELETE FROM t301;\n    CREATE TRIGGER temp.r301 AFTER INSERT ON t300 BEGIN\n      INSERT INTO t301 VALUES(20000 + new.x);\n    END;\n    INSERT INTO main.t300 VALUES(3);\n    INSERT INTO temp.t300 VALUES(4);\n    SELECT * FROM t301;\n  }\n} {10003 20004}\n\n\n#############################################################################\n# \n# Ticket [d6ddba6706353915ceedc56b4e3e72ecb4d77ba4]\n#\n# The following syntax really should not be allowed:\n#\n#    CREATE TRIGGER xyz.trig BEFORE UPDATE ON xyz.tab BEGIN ...\n#\n# But a long-standing bug does allow it.  And the \"xyz.tab\" slips into\n# the sqlite_master table.  We cannot fix the bug simply by disallowing\n# \"xyz.tab\" since that could break legacy applications.  We have to \n# fix the system so that the \"xyz.\" on \"xyz.tab\" is ignored.\n# Verify that this is the case.\n#\ndo_test triggerD-4.1 {\n  db close\n  forcedelete test.db test2.db\n  sqlite3 db test.db\n  db eval {\n    CREATE TABLE t1(x);\n    ATTACH 'test2.db' AS db2;\n    CREATE TABLE db2.t2(y);\n    CREATE TABLE db2.log(z);\n    CREATE TRIGGER db2.trig AFTER INSERT ON db2.t2 BEGIN\n      INSERT INTO log(z) VALUES(new.y);\n    END;\n    INSERT INTO t2 VALUES(123);\n    SELECT * FROM log;\n  }\n} {123}\ndo_test triggerD-4.2 {\n  sqlite3 db2 test2.db\n  db2 eval {\n    INSERT INTO t2 VALUES(234);\n    SELECT * FROM log;\n  }\n} {123 234}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerE.test",
    "content": "# 2009 December 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file tests the effects of SQL variable references embedded in\n# triggers. If the user attempts to create such a trigger, it is an\n# error. However, if an existing trigger definition is read from\n# the sqlite_master table, the variable reference always evaluates\n# to NULL.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\nset testprefix triggerE\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(c, d);\n  CREATE TABLE t3(e, f);\n}\n\n# forcedelete test.db2\n# do_execsql_test 1.1 {\n#   ATTACH 'test.db2' AS aux;\n#   CREATE TABLE aux.t4(x);\n#   INSERT INTO aux.t4 VALUES(5);\n# \n#   CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a IN (SELECT x FROM aux.t4)\n#   BEGIN\n#     SELECT 1;\n#   END;\n# } \n# do_execsql_test 1.2 { INSERT INTO t1 VALUES(1,1); }\n# do_execsql_test 1.3 { INSERT INTO t1 VALUES(5,5); }\n\n#-------------------------------------------------------------------------\n# Attempt to create various triggers that use bound variables.\n#\nset errmsg \"trigger cannot use variables\"\nforeach {tn defn} {\n  1 { AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END; }\n  2 { BEFORE DELETE ON t1 BEGIN SELECT ?; END; }\n  3 { BEFORE DELETE ON t1 BEGIN SELECT * FROM (SELECT * FROM (SELECT ?)); END; }\n  5 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 GROUP BY ?; END; }\n  6 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 LIMIT ?; END; }\n  7 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 ORDER BY ?; END; }\n  8 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = ?; END; }\n  9 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = 1 WHERE d = ?; END; }\n} {\n  catchsql {drop trigger tr1}\n  do_catchsql_test 1.1.$tn \"CREATE TRIGGER tr1 $defn\" [list 1 $errmsg]\n  do_catchsql_test 1.2.$tn \"CREATE TEMP TRIGGER tr1 $defn\" [list 1 $errmsg]\n}\n\n#-------------------------------------------------------------------------\n# Test that variable references within trigger definitions loaded from \n# the sqlite_master table are automatically converted to NULL.\n#\ndo_execsql_test 2.1 {\n  PRAGMA writable_schema = 1;\n  INSERT INTO sqlite_master VALUES('trigger', 'tr1', 't1', 0,\n    'CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN \n        INSERT INTO t2 VALUES(?1, ?2); \n     END'\n  );\n\n  INSERT INTO sqlite_master VALUES('trigger', 'tr2', 't3', 0,\n    'CREATE TRIGGER tr2 AFTER INSERT ON t3 WHEN ?1 IS NULL BEGIN\n        UPDATE t2 SET c=d WHERE c IS ?2;\n     END'\n  );\n}\ndb close\nsqlite3 db test.db\n\ndo_execsql_test 2.2.1 {\n  INSERT INTO t1 VALUES(1, 2);\n  SELECT * FROM t2;\n} {{} {}}\ndo_test 2.2.2 {\n  set one 3\n  execsql {\n    DELETE FROM t2;\n    INSERT INTO t1 VALUES($one, ?1);\n    SELECT * FROM t2;\n  }\n} {{} {}}\ndo_execsql_test 2.2.3 { SELECT * FROM t1 } {1 2 3 3}\n\ndo_execsql_test 2.3 {\n  DELETE FROM t2;\n  INSERT INTO t2 VALUES('x', 'y');\n  INSERT INTO t2 VALUES(NULL, 'z');\n  INSERT INTO t3 VALUES(1, 2);\n  SELECT * FROM t3;\n  SELECT * FROM t2;\n} {1 2 x y z z}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerF.test",
    "content": "# 2017 January 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix triggerF\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n\nforeach {tn sql log} {\n  1 { } { }\n\n  2 { \n    CREATE TRIGGER trd AFTER DELETE ON t1 BEGIN\n      INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));\n    END;\n  } {1one2 2two1 3three1}\n\n  3 { \n    CREATE TRIGGER trd BEFORE DELETE ON t1 BEGIN\n      INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));\n    END;\n  } {1one3 2two2 3three2}\n\n  4 { \n    CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN\n      INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));\n    END;\n    CREATE TRIGGER tr2 BEFORE DELETE ON t1 BEGIN\n      INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));\n    END;\n  } {1one3 1one2 2two2 2two1 3three2 3three1}\n\n} {\n  reset_db\n  do_execsql_test 1.$tn.0 {\n    PRAGMA recursive_triggers = on;\n    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;\n    CREATE TABLE log(t);\n  }\n  \n  execsql $sql\n\n  do_execsql_test 1.$tn.1 {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n\n    DELETE FROM t1 WHERE a=1;\n    INSERT OR REPLACE INTO t1 VALUES(2, 'three');\n    UPDATE OR REPLACE t1 SET a=3 WHERE a=2;\n  }\n\n  do_execsql_test 1.$tn.2 {\n    SELECT * FROM log ORDER BY rowid;\n  } $log\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/triggerG.test",
    "content": "# 2017-03-24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice', here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix triggerG\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# Test cases for ticket \n# https://www.sqlite.org/src/tktview/06796225f59c057cd120f\n#\n# The OP_Once opcode was not working correctly for recursive triggers.\n#\ndo_execsql_test 100 {\n  PRAGMA recursive_triggers = 1;\n  \n  CREATE TABLE t1(a);\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1(a) VALUES(0),(2),(3),(8),(9);\n  CREATE TABLE t2(b);\n  CREATE TABLE t3(c);\n  \n  CREATE TRIGGER tr AFTER INSERT ON t3 BEGIN\n    INSERT INTO t3 SELECT new.c+1 WHERE new.c<5;\n    INSERT INTO t2 SELECT new.c*100+a FROM t1 WHERE a IN (1, 2, 3, 4);\n  END;\n  \n  INSERT INTO t3 VALUES(2);\n  SELECT c FROM t3 ORDER BY c;;\n} {2 3 4 5}\ndo_execsql_test 110 {\n  SELECT b FROM t2 ORDER BY b;\n} {202 203 302 303 402 403 502 503}\n\ndo_execsql_test 200 {\n  DELETE FROM t1;\n  INSERT INTO t1(a) VALUES(0),(2),(3),(8),(9);\n  DELETE FROM t2;\n  DELETE FROM t3;\n  DROP TRIGGER tr;\n  CREATE TRIGGER tr AFTER INSERT ON t3 BEGIN\n    INSERT INTO t3 SELECT new.c+1 WHERE new.c<5;\n    INSERT INTO t2 SELECT new.c*10000+xx.a*100+yy.a\n                     FROM t1 AS xx, t1 AS yy\n                    WHERE xx.a IN (1,2,3,4)\n                      AND yy.a IN (2,3,4,5);\n  END;\n\n  INSERT INTO t3 VALUES(2);\n  SELECT b FROM t2 ORDER BY b;\n} {20202 20203 20302 20303 30202 30203 30302 30303 40202 40203 40302 40303 50202 50203 50302 50303}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tt3_checkpoint.c",
    "content": "/*\n** 2011-02-02\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n** This file is part of the test program \"threadtest3\". Despite being a C\n** file it is not compiled separately, but included by threadtest3.c using\n** the #include directive normally used with header files.\n**\n** This file contains the implementation of test cases:\n**\n**     checkpoint_starvation_1\n**     checkpoint_starvation_2\n*/\n\n/*\n** Both test cases involve 1 writer/checkpointer thread and N reader threads.\n** \n** Each reader thread performs a series of read transactions, one after \n** another. Each read transaction lasts for 100 ms.\n**\n** The writer writes transactions as fast as possible. It uses a callback\n** registered with sqlite3_wal_hook() to try to keep the WAL-size limited to \n** around 50 pages.\n**\n** In test case checkpoint_starvation_1, the auto-checkpoint uses \n** SQLITE_CHECKPOINT_PASSIVE. In checkpoint_starvation_2, it uses RESTART.\n** The expectation is that in the first case the WAL file will grow very \n** large, and in the second will be limited to the 50 pages or thereabouts.\n** However, the overall transaction throughput will be lower for \n** checkpoint_starvation_2, as every checkpoint will block for up to 200 ms\n** waiting for readers to clear.\n*/\n\n/* Frame limit used by the WAL hook for these tests. */\n#define CHECKPOINT_STARVATION_FRAMELIMIT 50\n\n/* Duration in ms of each read transaction */\n#define CHECKPOINT_STARVATION_READMS    100\n\nstruct CheckpointStarvationCtx {\n  int eMode;\n  int nMaxFrame;\n};\ntypedef struct CheckpointStarvationCtx CheckpointStarvationCtx;\n\nstatic int checkpoint_starvation_walhook(\n  void *pCtx, \n  sqlite3 *db, \n  const char *zDb, \n  int nFrame\n){\n  CheckpointStarvationCtx *p = (CheckpointStarvationCtx *)pCtx;\n  if( nFrame>p->nMaxFrame ){\n    p->nMaxFrame = nFrame;\n  }\n  if( nFrame>=CHECKPOINT_STARVATION_FRAMELIMIT ){\n    sqlite3_wal_checkpoint_v2(db, zDb, p->eMode, 0, 0);\n  }\n  return SQLITE_OK;\n}\n\nstatic char *checkpoint_starvation_reader(int iTid, void *pArg){\n  Error err = {0};\n  Sqlite db = {0};\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    i64 iCount1, iCount2;\n    sql_script(&err, &db, \"BEGIN\");\n    iCount1 = execsql_i64(&err, &db, \"SELECT count(x) FROM t1\");\n    usleep(CHECKPOINT_STARVATION_READMS*1000);\n    iCount2 = execsql_i64(&err, &db, \"SELECT count(x) FROM t1\");\n    sql_script(&err, &db, \"COMMIT\");\n\n    if( iCount1!=iCount2 ){\n      test_error(&err, \"Isolation failure - %lld %lld\", iCount1, iCount2);\n    }\n  }\n  closedb(&err, &db);\n\n  print_and_free_err(&err);\n  return 0;\n}\n\nstatic void checkpoint_starvation_main(int nMs, CheckpointStarvationCtx *p){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n  int nInsert = 0;\n  int i;\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n      \"PRAGMA page_size = 1024;\"\n      \"PRAGMA journal_mode = WAL;\"\n      \"CREATE TABLE t1(x);\"\n  );\n\n  setstoptime(&err, nMs);\n\n  for(i=0; i<4; i++){\n    launch_thread(&err, &threads, checkpoint_starvation_reader, 0);\n    usleep(CHECKPOINT_STARVATION_READMS*1000/4);\n  }\n\n  sqlite3_wal_hook(db.db, checkpoint_starvation_walhook, (void *)p);\n  while( !timetostop(&err) ){\n    sql_script(&err, &db, \"INSERT INTO t1 VALUES(randomblob(1200))\");\n    nInsert++;\n  }\n\n  printf(\" Checkpoint mode  : %s\\n\",\n      p->eMode==SQLITE_CHECKPOINT_PASSIVE ? \"PASSIVE\" : \"RESTART\"\n  );\n  printf(\" Peak WAL         : %d frames\\n\", p->nMaxFrame);\n  printf(\" Transaction count: %d transactions\\n\", nInsert);\n\n  join_all_threads(&err, &threads);\n  closedb(&err, &db);\n  print_and_free_err(&err);\n}\n\nstatic void checkpoint_starvation_1(int nMs){\n  Error err = {0};\n  CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_PASSIVE, 0 };\n  checkpoint_starvation_main(nMs, &ctx);\n  if( ctx.nMaxFrame<(CHECKPOINT_STARVATION_FRAMELIMIT*10) ){\n    test_error(&err, \"WAL failed to grow - %d frames\", ctx.nMaxFrame);\n  }\n  print_and_free_err(&err);\n}\n\nstatic void checkpoint_starvation_2(int nMs){\n  Error err = {0};\n  CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 };\n  checkpoint_starvation_main(nMs, &ctx);\n  if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){\n    test_error(&err, \"WAL grew too large - %d frames\", ctx.nMaxFrame);\n  }\n  print_and_free_err(&err);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tt3_index.c",
    "content": "/*\n** 2014 December 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**     create_drop_index_1\n*/\n\n\nstatic char *create_drop_index_thread(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  while( !timetostop(&err) ){\n    opendb(&err, &db, \"test.db\", 0);\n\n    sql_script(&err, &db, \n      \"DROP INDEX IF EXISTS i1;\"\n      \"DROP INDEX IF EXISTS i2;\"\n      \"DROP INDEX IF EXISTS i3;\"\n      \"DROP INDEX IF EXISTS i4;\"\n\n      \"CREATE INDEX IF NOT EXISTS i1 ON t11(a);\"\n      \"CREATE INDEX IF NOT EXISTS i2 ON t11(b);\"\n      \"CREATE INDEX IF NOT EXISTS i3 ON t11(c);\"\n      \"CREATE INDEX IF NOT EXISTS i4 ON t11(d);\"\n\n      \"SELECT * FROM t11 ORDER BY a;\"\n      \"SELECT * FROM t11 ORDER BY b;\"\n      \"SELECT * FROM t11 ORDER BY c;\"\n      \"SELECT * FROM t11 ORDER BY d;\"\n    );\n    clear_error(&err, SQLITE_LOCKED);\n\n    closedb(&err, &db);\n  }\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\nstatic void create_drop_index_1(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n     \"CREATE TABLE t11(a, b, c, d);\"\n     \"WITH data(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM data WHERE x<100) \"\n     \"INSERT INTO t11 SELECT x,x,x,x FROM data;\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n\n  sqlite3_enable_shared_cache(1);\n  launch_thread(&err, &threads, create_drop_index_thread, 0);\n  launch_thread(&err, &threads, create_drop_index_thread, 0);\n  launch_thread(&err, &threads, create_drop_index_thread, 0);\n  launch_thread(&err, &threads, create_drop_index_thread, 0);\n  launch_thread(&err, &threads, create_drop_index_thread, 0);\n\n  join_all_threads(&err, &threads);\n  sqlite3_enable_shared_cache(0);\n  print_and_free_err(&err);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tt3_lookaside1.c",
    "content": "/*\n** 2014 December 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**     lookaside1\n*/\n\n/*\n** The test in this file attempts to expose a specific race condition\n** that is suspected to exist at time of writing.\n*/\n\nstatic char *lookaside1_thread_reader(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  opendb(&err, &db, \"test.db\", 0);\n\n  while( !timetostop(&err) ){\n    sqlite3_stmt *pStmt = 0;\n    int rc;\n\n    sqlite3_prepare_v2(db.db, \"SELECT 1 FROM t1\", -1, &pStmt, 0);\n    while( sqlite3_step(pStmt)==SQLITE_ROW ){\n      execsql(&err, &db, \"SELECT length(x||y||z) FROM t2\");\n    }\n    rc = sqlite3_finalize(pStmt);\n    if( err.rc==SQLITE_OK && rc!=SQLITE_OK ){\n      sqlite_error(&err, &db, \"finalize\");\n    }\n  }\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\nstatic char *lookaside1_thread_writer(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  opendb(&err, &db, \"test.db\", 0);\n\n  do{\n    sql_script(&err, &db, \n      \"BEGIN;\"\n        \"UPDATE t3 SET i=i+1 WHERE x=1;\"\n      \"ROLLBACK;\"\n    );\n  }while( !timetostop(&err) );\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\n\nstatic void lookaside1(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n     \"CREATE TABLE t1(x PRIMARY KEY) WITHOUT ROWID;\"\n     \"WITH data(x,y) AS (\"\n     \"  SELECT 1, quote(randomblob(750)) UNION ALL \"\n     \"  SELECT x*2, y||y FROM data WHERE x<5) \"\n     \"INSERT INTO t1 SELECT y FROM data;\"\n\n     \"CREATE TABLE t3(x PRIMARY KEY,i) WITHOUT ROWID;\"\n     \"INSERT INTO t3 VALUES(1, 1);\"\n\n     \"CREATE TABLE t2(x,y,z);\"\n     \"INSERT INTO t2 VALUES(randomblob(50), randomblob(50), randomblob(50));\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n\n  sqlite3_enable_shared_cache(1);\n  launch_thread(&err, &threads, lookaside1_thread_reader, 0);\n  launch_thread(&err, &threads, lookaside1_thread_reader, 0);\n  launch_thread(&err, &threads, lookaside1_thread_reader, 0);\n  launch_thread(&err, &threads, lookaside1_thread_reader, 0);\n  launch_thread(&err, &threads, lookaside1_thread_reader, 0);\n  launch_thread(&err, &threads, lookaside1_thread_writer, 0);\n  join_all_threads(&err, &threads);\n  sqlite3_enable_shared_cache(0);\n  print_and_free_err(&err);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tt3_stress.c",
    "content": "/*\n** 2014 December 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n**\n*/\n\n\n/*\n** Thread 1. CREATE and DROP a table.\n*/\nstatic char *stress_thread_1(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    sql_script(&err, &db, \"CREATE TABLE IF NOT EXISTS t1(a PRIMARY KEY, b)\");\n    clear_error(&err, SQLITE_LOCKED);\n    sql_script(&err, &db, \"DROP TABLE IF EXISTS t1\");\n    clear_error(&err, SQLITE_LOCKED);\n  }\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\n/*\n** Thread 2. Open and close database connections.\n*/\nstatic char *stress_thread_2(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  while( !timetostop(&err) ){\n    opendb(&err, &db, \"test.db\", 0);\n    sql_script(&err, &db, \"SELECT * FROM sqlite_master;\");\n    clear_error(&err, SQLITE_LOCKED);\n    closedb(&err, &db);\n  }\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\n/*\n** Thread 3. Attempt many small SELECT statements.\n*/\nstatic char *stress_thread_3(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n\n  int i1 = 0;\n  int i2 = 0;\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    sql_script(&err, &db, \"SELECT * FROM t1 ORDER BY a;\");\n    i1++;\n    if( err.rc ) i2++;\n    clear_error(&err, SQLITE_LOCKED);\n    clear_error(&err, SQLITE_ERROR);\n  }\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"read t1 %d/%d attempts\", i2, i1);\n}\n\n/*\n** Thread 5. Attempt INSERT statements.\n*/\nstatic char *stress_thread_4(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int i1 = 0;\n  int i2 = 0;\n  int iArg = PTR2INT(pArg);\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    if( iArg ){\n      closedb(&err, &db);\n      opendb(&err, &db, \"test.db\", 0);\n    }\n    sql_script(&err, &db, \n        \"WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop LIMIT 200) \"\n        \"INSERT INTO t1 VALUES(randomblob(60), randomblob(60));\"\n    );\n    i1++;\n    if( err.rc ) i2++;\n    clear_error(&err, SQLITE_LOCKED);\n    clear_error(&err, SQLITE_ERROR);\n  }\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"wrote t1 %d/%d attempts\", i2, i1);\n}\n\n/*\n** Thread 6. Attempt DELETE operations.\n*/\nstatic char *stress_thread_5(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int iArg = PTR2INT(pArg);\n\n  int i1 = 0;\n  int i2 = 0;\n\n  opendb(&err, &db, \"test.db\", 0);\n  while( !timetostop(&err) ){\n    i64 i = (i1 % 4);\n    if( iArg ){\n      closedb(&err, &db);\n      opendb(&err, &db, \"test.db\", 0);\n    }\n    execsql(&err, &db, \"DELETE FROM t1 WHERE (rowid % 4)==:i\", &i);\n    i1++;\n    if( err.rc ) i2++;\n    clear_error(&err, SQLITE_LOCKED);\n  }\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"deleted from t1 %d/%d attempts\", i2, i1);\n}\n\n\nstatic void stress1(int nMs){\n  Error err = {0};\n  Threadset threads = {0};\n\n  setstoptime(&err, nMs);\n  sqlite3_enable_shared_cache(1);\n\n  launch_thread(&err, &threads, stress_thread_1, 0);\n  launch_thread(&err, &threads, stress_thread_1, 0);\n\n  launch_thread(&err, &threads, stress_thread_2, 0);\n  launch_thread(&err, &threads, stress_thread_2, 0);\n\n  launch_thread(&err, &threads, stress_thread_3, 0);\n  launch_thread(&err, &threads, stress_thread_3, 0);\n\n  launch_thread(&err, &threads, stress_thread_4, 0);\n  launch_thread(&err, &threads, stress_thread_4, 0);\n\n  launch_thread(&err, &threads, stress_thread_5, 0);\n  launch_thread(&err, &threads, stress_thread_5, (void*)1);\n\n  join_all_threads(&err, &threads);\n  sqlite3_enable_shared_cache(0);\n\n  print_and_free_err(&err);\n}\n\n/**************************************************************************\n***************************************************************************\n** Start of test case \"stress2\"\n*/\n\n\n\n/*\n** 1.  CREATE TABLE statements.\n** 2.  DROP TABLE statements.\n** 3.  Small SELECT statements.\n** 4.  Big SELECT statements.\n** 5.  Small INSERT statements.\n** 6.  Big INSERT statements.\n** 7.  Small UPDATE statements.\n** 8.  Big UPDATE statements.\n** 9.  Small DELETE statements.\n** 10. Big DELETE statements.\n** 11. VACUUM.\n** 14. Integrity-check.\n** 17. Switch the journal mode from delete to wal and back again.\n** 19. Open and close database connections rapidly.\n*/\n\n#define STRESS2_TABCNT 5          /* count1 in SDS test */\n\n#define STRESS2_COUNT2 200        /* count2 in SDS test */\n#define STRESS2_COUNT3  57        /* count2 in SDS test */\n\nstatic void stress2_workload1(Error *pErr, Sqlite *pDb, int i){\n  int iTab = (i % (STRESS2_TABCNT-1)) + 1;\n  sql_script_printf(pErr, pDb, \n      \"CREATE TABLE IF NOT EXISTS t%d(x PRIMARY KEY, y, z);\", iTab\n  );\n}\n\nstatic void stress2_workload2(Error *pErr, Sqlite *pDb, int i){\n  int iTab = (i % (STRESS2_TABCNT-1)) + 1;\n  sql_script_printf(pErr, pDb, \"DROP TABLE IF EXISTS t%d;\", iTab);\n}\n\nstatic void stress2_workload3(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb, \"SELECT * FROM t0 WHERE z = 'small'\");\n}\n\nstatic void stress2_workload4(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb, \"SELECT * FROM t0 WHERE z = 'big'\");\n}\n\nstatic void stress2_workload5(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb,\n      \"INSERT INTO t0 VALUES(hex(random()), hex(randomblob(200)), 'small');\"\n  );\n}\n\nstatic void stress2_workload6(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb,\n      \"INSERT INTO t0 VALUES(hex(random()), hex(randomblob(57)), 'big');\"\n  );\n}\n\nstatic void stress2_workload7(Error *pErr, Sqlite *pDb, int i){\n  sql_script_printf(pErr, pDb,\n      \"UPDATE t0 SET y = hex(randomblob(200)) \"\n      \"WHERE x LIKE hex((%d %% 5)) AND z='small';\"\n      ,i\n  );\n}\nstatic void stress2_workload8(Error *pErr, Sqlite *pDb, int i){\n  sql_script_printf(pErr, pDb,\n      \"UPDATE t0 SET y = hex(randomblob(57)) \"\n      \"WHERE x LIKE hex(%d %% 5) AND z='big';\"\n      ,i\n  );\n}\n\nstatic void stress2_workload9(Error *pErr, Sqlite *pDb, int i){\n  sql_script_printf(pErr, pDb,\n      \"DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='small';\", i\n  );\n}\nstatic void stress2_workload10(Error *pErr, Sqlite *pDb, int i){\n  sql_script_printf(pErr, pDb,\n      \"DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='big';\", i\n  );\n}\n\nstatic void stress2_workload11(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb, \"VACUUM\");\n}\n\nstatic void stress2_workload14(Error *pErr, Sqlite *pDb, int i){\n  sql_script(pErr, pDb, \"PRAGMA integrity_check\");\n}\n\nstatic void stress2_workload17(Error *pErr, Sqlite *pDb, int i){\n  sql_script_printf(pErr, pDb, \n      \"PRAGMA journal_mode = %q\", (i%2) ? \"delete\" : \"wal\"\n  );\n}\n\nstatic char *stress2_workload19(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  const char *zDb = (const char*)pArg;\n  while( !timetostop(&err) ){\n    opendb(&err, &db, zDb, 0);\n    sql_script(&err, &db, \"SELECT * FROM sqlite_master;\");\n    clear_error(&err, SQLITE_LOCKED);\n    closedb(&err, &db);\n  }\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\n\ntypedef struct Stress2Ctx Stress2Ctx;\nstruct Stress2Ctx {\n  const char *zDb;\n  void (*xProc)(Error*, Sqlite*, int);\n};\n\nstatic char *stress2_thread_wrapper(int iTid, void *pArg){\n  Stress2Ctx *pCtx = (Stress2Ctx*)pArg;\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  int i1 = 0;\n  int i2 = 0;\n\n  while( !timetostop(&err) ){\n    int cnt;\n    opendb(&err, &db, pCtx->zDb, 0);\n    for(cnt=0; err.rc==SQLITE_OK && cnt<STRESS2_TABCNT; cnt++){\n      pCtx->xProc(&err, &db, i1);\n      i2 += (err.rc==SQLITE_OK);\n      clear_error(&err, SQLITE_LOCKED);\n      i1++;\n    }\n    closedb(&err, &db);\n  }\n\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok %d/%d\", i2, i1);\n}\n\nstatic void stress2_launch_thread_loop(\n  Error *pErr,                    /* IN/OUT: Error code */\n  Threadset *pThreads,            /* Thread set */\n  const char *zDb,                /* Database name */\n  void (*x)(Error*,Sqlite*,int)   /* Run this until error or timeout */\n){\n  Stress2Ctx *pCtx = sqlite3_malloc(sizeof(Stress2Ctx));\n  pCtx->zDb = zDb;\n  pCtx->xProc = x;\n  launch_thread(pErr, pThreads, stress2_thread_wrapper, (void*)pCtx);\n}\n\nstatic void stress2(int nMs){\n  struct Stress2Task {\n    void (*x)(Error*,Sqlite*,int);\n  } aTask[] = {\n    { stress2_workload1 },\n    { stress2_workload2 },\n    { stress2_workload3 },\n    { stress2_workload4 },\n    { stress2_workload5 },\n    { stress2_workload6 },\n    { stress2_workload7 },\n    { stress2_workload8 },\n    { stress2_workload9 },\n    { stress2_workload10 },\n    { stress2_workload11 },\n    { stress2_workload14 },\n    { stress2_workload17 },\n  };\n  const char *zDb = \"test.db\";\n\n  int i;\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  /* To make sure the db file is empty before commencing */\n  opendb(&err, &db, zDb, 1);\n  sql_script(&err, &db, \n      \"CREATE TABLE IF NOT EXISTS t0(x PRIMARY KEY, y, z);\"\n      \"CREATE INDEX IF NOT EXISTS i0 ON t0(y);\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n  sqlite3_enable_shared_cache(1);\n\n  for(i=0; i<sizeof(aTask)/sizeof(aTask[0]); i++){\n    stress2_launch_thread_loop(&err, &threads, zDb, aTask[i].x);\n  }\n  launch_thread(&err, &threads, stress2_workload19, (void*)zDb);\n  launch_thread(&err, &threads, stress2_workload19, (void*)zDb);\n\n  join_all_threads(&err, &threads);\n  sqlite3_enable_shared_cache(0);\n  print_and_free_err(&err);\n}\n\n\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/tt3_vacuum.c",
    "content": "/*\n** 2014 December 9\n**\n** The author disclaims copyright to this source code.  In place of\n** a legal notice, here is a blessing:\n**\n**    May you do good and not evil.\n**    May you find forgiveness for yourself and forgive others.\n**    May you share freely, never taking more than you give.\n**\n*************************************************************************\n**\n** This file contains multi-threaded tests that use shared-cache and \n** the VACUUM command.\n**\n** Tests:\n**\n**     vacuum1\n**\n*/\n\n\nstatic char *vacuum1_thread_writer(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  opendb(&err, &db, \"test.db\", 0);\n  i64 i = 0;\n\n  while( !timetostop(&err) ){\n    i++;\n\n    /* Insert lots of rows. Then delete some. */\n    execsql(&err, &db, \n        \"WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop WHERE i<100) \"\n        \"INSERT INTO t1 SELECT randomblob(50), randomblob(2500) FROM loop\"\n    );\n\n    /* Delete lots of rows */\n    execsql(&err, &db, \"DELETE FROM t1 WHERE rowid = :i\", &i);\n    clear_error(&err, SQLITE_LOCKED);\n\n    /* Select the rows */\n    execsql(&err, &db, \"SELECT * FROM t1 ORDER BY x\");\n    clear_error(&err, SQLITE_LOCKED);\n  }\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\nstatic char *vacuum1_thread_vacuumer(int iTid, void *pArg){\n  Error err = {0};                /* Error code and message */\n  Sqlite db = {0};                /* SQLite database connection */\n  opendb(&err, &db, \"test.db\", 0);\n\n  do{\n    sql_script(&err, &db, \"VACUUM\");\n    clear_error(&err, SQLITE_LOCKED);\n  }while( !timetostop(&err) );\n\n  closedb(&err, &db);\n  print_and_free_err(&err);\n  return sqlite3_mprintf(\"ok\");\n}\n\nstatic void vacuum1(int nMs){\n  Error err = {0};\n  Sqlite db = {0};\n  Threadset threads = {0};\n\n  opendb(&err, &db, \"test.db\", 1);\n  sql_script(&err, &db, \n     \"CREATE TABLE t1(x PRIMARY KEY, y BLOB);\"\n     \"CREATE INDEX i1 ON t1(y);\"\n  );\n  closedb(&err, &db);\n\n  setstoptime(&err, nMs);\n\n  sqlite3_enable_shared_cache(1);\n  launch_thread(&err, &threads, vacuum1_thread_writer, 0);\n  launch_thread(&err, &threads, vacuum1_thread_writer, 0);\n  launch_thread(&err, &threads, vacuum1_thread_writer, 0);\n  launch_thread(&err, &threads, vacuum1_thread_vacuumer, 0);\n  join_all_threads(&err, &threads);\n  sqlite3_enable_shared_cache(0);\n\n  print_and_free_err(&err);\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/types.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specfically\n# it tests that the different storage classes (integer, real, text etc.)\n# all work correctly.\n#\n# $Id: types.test,v 1.20 2009/06/29 06:00:37 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Tests in this file are organized roughly as follows:\n#\n# types-1.*.*: Test that values are stored using the expected storage\n#              classes when various forms of literals are inserted into\n#              columns with different affinities.\n# types-1.1.*: INSERT INTO <table> VALUES(...)\n# types-1.2.*: INSERT INTO <table> SELECT...\n# types-1.3.*: UPDATE <table> SET...\n#\n# types-2.*.*: Check that values can be stored and retrieving using the\n#              various storage classes.\n# types-2.1.*: INTEGER\n# types-2.2.*: REAL\n# types-2.3.*: NULL\n# types-2.4.*: TEXT\n# types-2.5.*: Records with a few different storage classes.\n#\n# types-3.*: Test that the '=' operator respects manifest types.\n#\n\n# Disable encryption on the database for this test.\ndb close\nset DB [sqlite3 db test.db; sqlite3_connection_pointer db]\nsqlite3_rekey $DB {}\n\n# Create a table with one column for each type of affinity\ndo_test types-1.1.0 {\n  execsql {\n    CREATE TABLE t1(i integer, n numeric, t text, o blob);\n  }\n} {}\n\n# Each element of the following list represents one test case.\n#\n# The first value of each sub-list is an SQL literal. The following\n# four value are the storage classes that would be used if the\n# literal were inserted into a column with affinity INTEGER, NUMERIC, TEXT\n# or NONE, respectively.\nset values {\n  { 5.0    integer integer text real    }\n  { 5.1    real    real    text real    }\n  { 5      integer integer text integer }\n  { '5.0'  integer integer text text    }\n  { '5.1'  real    real    text text    }\n  { '-5.0' integer integer text text    }\n  { '-5.0' integer integer text text    }\n  { '5'    integer integer text text    }\n  { 'abc'  text    text    text text    }\n  { NULL   null    null    null null    }\n}\nifcapable {bloblit} {\n  lappend values  { X'00'  blob    blob    blob blob    }\n}\n\n# This code tests that the storage classes specified above (in the $values\n# table) are correctly assigned when values are inserted using a statement\n# of the form:\n#\n# INSERT INTO <table> VALUE(<values>);\n#\nset tnum 1\nforeach val $values {\n  set lit [lindex $val 0]\n  execsql \"DELETE FROM t1;\"\n  execsql \"INSERT INTO t1 VALUES($lit, $lit, $lit, $lit);\"\n  do_test types-1.1.$tnum {\n    execsql {\n      SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;\n    }\n  } [lrange $val 1 end]\n  incr tnum\n}\n\n# This code tests that the storage classes specified above (in the $values\n# table) are correctly assigned when values are inserted using a statement\n# of the form:\n#\n# INSERT INTO t1 SELECT ....\n#\nset tnum 1\nforeach val $values {\n  set lit [lindex $val 0]\n  execsql \"DELETE FROM t1;\"\n  execsql \"INSERT INTO t1 SELECT $lit, $lit, $lit, $lit;\"\n  do_test types-1.2.$tnum {\n    execsql {\n      SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;\n    }\n  } [lrange $val 1 end]\n  incr tnum\n}\n\n# This code tests that the storage classes specified above (in the $values\n# table) are correctly assigned when values are inserted using a statement\n# of the form:\n#\n# UPDATE <table> SET <column> = <value>;\n#\nset tnum 1\nforeach val $values {\n  set lit [lindex $val 0]\n  execsql \"UPDATE t1 SET i = $lit, n = $lit, t = $lit, o = $lit;\"\n  do_test types-1.3.$tnum {\n    execsql {\n      SELECT typeof(i), typeof(n), typeof(t), typeof(o) FROM t1;\n    }\n  } [lrange $val 1 end]\n  incr tnum\n}\n\nexecsql {\n  DROP TABLE t1;\n}\n\n# Open the table with root-page $rootpage at the btree\n# level. Return a list that is the length of each record\n# in the table, in the tables default scanning order.\nproc record_sizes {rootpage} {\n  set bt [btree_open test.db 10]\n  btree_begin_transaction $bt\n  set c [btree_cursor $bt $rootpage 0]\n  btree_first $c\n  while 1 {\n    lappend res [btree_payload_size $c]\n    if {[btree_next $c]} break\n  }\n  btree_close_cursor $c\n  btree_close $bt\n  set res\n}\n\n\n# Create a table and insert some 1-byte integers. Make sure they \n# can be read back OK. These should be 3 byte records.\ndo_test types-2.1.1 {\n  execsql {\n    CREATE TABLE t1(a integer);\n    INSERT INTO t1 VALUES(0);\n    INSERT INTO t1 VALUES(120);\n    INSERT INTO t1 VALUES(-120);\n  }\n} {}\ndo_test types-2.1.2 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} {0 120 -120}\n\n# Try some 2-byte integers (4 byte records)\ndo_test types-2.1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(30000);\n    INSERT INTO t1 VALUES(-30000);\n  }\n} {}\ndo_test types-2.1.4 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} {0 120 -120 30000 -30000}\n\n# 4-byte integers (6 byte records)\ndo_test types-2.1.5 {\n  execsql {\n    INSERT INTO t1 VALUES(2100000000);\n    INSERT INTO t1 VALUES(-2100000000);\n  }\n} {}\ndo_test types-2.1.6 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} {0 120 -120 30000 -30000 2100000000 -2100000000}\n\n# 8-byte integers (10 byte records)\ndo_test types-2.1.7 {\n  execsql {\n    INSERT INTO t1 VALUES(9000000*1000000*1000000);\n    INSERT INTO t1 VALUES(-9000000*1000000*1000000);\n  }\n} {}\ndo_test types-2.1.8 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} [list 0 120 -120 30000 -30000 2100000000 -2100000000 \\\n        9000000000000000000 -9000000000000000000]\n\n# Check that all the record sizes are as we expected.\nifcapable legacyformat {\n  do_test types-2.1.9 {\n    set root [db eval {select rootpage from sqlite_master where name = 't1'}]\n    record_sizes $root\n  } {3 3 3 4 4 6 6 10 10}\n} else {\n  do_test types-2.1.9 {\n    set root [db eval {select rootpage from sqlite_master where name = 't1'}]\n    record_sizes $root\n  } {2 3 3 4 4 6 6 10 10}\n}\n  \n# Insert some reals. These should be 10 byte records.\ndo_test types-2.2.1 {\n  execsql {\n    CREATE TABLE t2(a float);\n    INSERT INTO t2 VALUES(0.0);\n    INSERT INTO t2 VALUES(12345.678);\n    INSERT INTO t2 VALUES(-12345.678);\n  }\n} {}\ndo_test types-2.2.2 {\n  execsql {\n    SELECT a FROM t2;\n  }\n} {0.0 12345.678 -12345.678}\n\n# Check that all the record sizes are as we expected.\nifcapable legacyformat {\n  do_test types-2.2.3 {\n    set root [db eval {select rootpage from sqlite_master where name = 't2'}]\n    record_sizes $root\n  } {3 10 10}\n} else {\n  do_test types-2.2.3 {\n    set root [db eval {select rootpage from sqlite_master where name = 't2'}]\n    record_sizes $root\n  } {2 10 10}\n}\n  \n# Insert a NULL. This should be a two byte record.\ndo_test types-2.3.1 {\n  execsql {\n    CREATE TABLE t3(a nullvalue);\n    INSERT INTO t3 VALUES(NULL);\n  }\n} {}\ndo_test types-2.3.2 {\n  execsql {\n    SELECT a ISNULL FROM t3;\n  }\n} {1}\n\n# Check that all the record sizes are as we expected.\ndo_test types-2.3.3 {\n  set root [db eval {select rootpage from sqlite_master where name = 't3'}]\n  record_sizes $root\n} {2}\n\n# Insert a couple of strings.\ndo_test types-2.4.1 {\n  set string10 abcdefghij\n  set string500 [string repeat $string10 50]\n  set string500000 [string repeat $string10 50000]\n\n  execsql \"\n    CREATE TABLE t4(a string);\n    INSERT INTO t4 VALUES('$string10');\n    INSERT INTO t4 VALUES('$string500');\n    INSERT INTO t4 VALUES('$string500000');\n  \"\n} {}\ndo_test types-2.4.2 {\n  execsql {\n    SELECT a FROM t4;\n  }\n} [list $string10 $string500 $string500000]\n\n# Check that all the record sizes are as we expected. This is dependant on\n# the database encoding.\nif { $sqlite_options(utf16)==0 || [execsql {pragma encoding}] == \"UTF-8\" } {\n  do_test types-2.4.3 {\n    set root [db eval {select rootpage from sqlite_master where name = 't4'}]\n    record_sizes $root\n  } {12 503 500004}\n} else {\n  do_test types-2.4.3 {\n    set root [db eval {select rootpage from sqlite_master where name = 't4'}]\n    record_sizes $root\n  } {22 1003 1000004}\n}\n\ndo_test types-2.5.1 {\n  execsql {\n    DROP TABLE t1;\n    DROP TABLE t2;\n    DROP TABLE t3;\n    DROP TABLE t4;\n    CREATE TABLE t1(a, b, c);\n  }\n} {}\ndo_test types-2.5.2 {\n  set string10 abcdefghij\n  set string500 [string repeat $string10 50]\n  set string500000 [string repeat $string10 50000]\n\n  execsql \"INSERT INTO t1 VALUES(NULL, '$string10', 4000);\"\n  execsql \"INSERT INTO t1 VALUES('$string500', 4000, NULL);\"\n  execsql \"INSERT INTO t1 VALUES(4000, NULL, '$string500000');\"\n} {}\ndo_test types-2.5.3 {\n  execsql {\n    SELECT * FROM t1;\n  }\n} [list {} $string10 4000 $string500 4000 {} 4000 {} $string500000]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/types2.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this file is testing the interaction of manifest types, type affinity\n# and comparison expressions.\n#\n# $Id: types2.test,v 1.7 2007/02/23 03:00:45 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Tests in this file are organized roughly as follows:\n#\n# types2-1.*: The '=' operator in the absence of an index.\n# types2-2.*: The '=' operator implemented using an index.\n# types2-3.*: The '<' operator implemented using an index.\n# types2-4.*: The '>' operator in the absence of an index.\n# types2-5.*: The 'IN(x, y...)' operator in the absence of an index.\n# types2-6.*: The 'IN(x, y...)' operator with an index.\n# types2-7.*: The 'IN(SELECT...)' operator in the absence of an index.\n# types2-8.*: The 'IN(SELECT...)' operator with an index.\n#\n# All tests test the operators using literals and columns, but no\n# other types of expressions. All expressions except columns are\n# handled similarly in the implementation.\n\nexecsql {\n  CREATE TABLE t1(\n    i1 INTEGER,\n    i2 INTEGER,\n    n1 NUMERIC,\n    n2 NUMERIC,\n    t1 TEXT,\n    t2 TEXT,\n    o1 BLOB,\n    o2 BLOB\n  );\n  INSERT INTO t1 VALUES(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);\n}\n\nproc test_bool {testname vars expr res} {\n  if { $vars != \"\" } {\n    execsql \"UPDATE t1 SET $vars\"\n  }\n\n  foreach {t e r} [list $testname $expr $res] {}\n\n  do_test $t.1 \"execsql {SELECT $e FROM t1}\" $r\n  do_test $t.2 \"execsql {SELECT 1 FROM t1 WHERE $expr}\" [expr $r?\"1\":\"\"]\n  do_test $t.3 \"execsql {SELECT 1 FROM t1 WHERE NOT ($e)}\" [expr $r?\"\":\"1\"]\n}\n\n# Compare literals against literals. This should always use a numeric\n# comparison.\n#\n# Changed by ticket #805:  Use no affinity for literal comparisons.\n#\ntest_bool types2-1.1 \"\" {500 = 500.0} 1\ntest_bool types2-1.2 \"\" {'500' = 500.0} 0\ntest_bool types2-1.3 \"\" {500 = '500.0'} 0\ntest_bool types2-1.4 \"\" {'500' = '500.0'} 0\n\n# Compare literals against a column with TEXT affinity\ntest_bool types2-1.5 {t1=500} {500 = t1} 1\ntest_bool types2-1.6 {t1=500} {'500' = t1} 1\ntest_bool types2-1.7 {t1=500} {500.0 = t1} 0\ntest_bool types2-1.8 {t1=500} {'500.0' = t1} 0\ntest_bool types2-1.9 {t1='500'} {500 = t1} 1\ntest_bool types2-1.10 {t1='500'} {'500' = t1} 1\ntest_bool types2-1.11 {t1='500'} {500.0 = t1} 0\ntest_bool types2-1.12 {t1='500'} {'500.0' = t1} 0\n\n# Compare literals against a column with NUMERIC affinity\ntest_bool types2-1.13 {n1=500} {500 = n1} 1\ntest_bool types2-1.14 {n1=500} {'500' = n1} 1\ntest_bool types2-1.15 {n1=500} {500.0 = n1} 1\ntest_bool types2-1.16 {n1=500} {'500.0' = n1} 1\ntest_bool types2-1.17 {n1='500'} {500 = n1} 1\ntest_bool types2-1.18 {n1='500'} {'500' = n1} 1\ntest_bool types2-1.19 {n1='500'} {500.0 = n1} 1\ntest_bool types2-1.20 {n1='500'} {'500.0' = n1} 1\n\n# Compare literals against a column with affinity NONE\ntest_bool types2-1.21 {o1=500} {500 = o1} 1\ntest_bool types2-1.22 {o1=500} {'500' = o1} 0\ntest_bool types2-1.23 {o1=500} {500.0 = o1} 1\ntest_bool types2-1.24 {o1=500} {'500.0' = o1} 0\ntest_bool types2-1.25 {o1='500'} {500 = o1} 0\ntest_bool types2-1.26 {o1='500'} {'500' = o1} 1\ntest_bool types2-1.27 {o1='500'} {500.0 = o1} 0\ntest_bool types2-1.28 {o1='500'} {'500.0' = o1} 0\n\nset vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']\n#              1  2    3    4      5  6    7    8      9  10   11   12\n\nexecsql {\n  CREATE TABLE t2(i INTEGER, n NUMERIC, t TEXT, o XBLOBY);\n  CREATE INDEX t2i1 ON t2(i);\n  CREATE INDEX t2i2 ON t2(n);\n  CREATE INDEX t2i3 ON t2(t);\n  CREATE INDEX t2i4 ON t2(o);\n}\nforeach v $vals {\n  execsql \"INSERT INTO t2 VALUES($v, $v, $v, $v);\"\n}\n\nproc test_boolset {testname where set} {\n  set ::tb_sql \"SELECT rowid FROM t2 WHERE $where\"\n  do_test $testname {\n    lsort -integer [execsql $::tb_sql]\n  } $set\n}\n\ntest_boolset types2-2.1 {i = 10} {1 2 3 4}\ntest_boolset types2-2.2 {i = 10.0} {1 2 3 4}\ntest_boolset types2-2.3 {i = '10'} {1 2 3 4}\ntest_boolset types2-2.4 {i = '10.0'} {1 2 3 4}\n\ntest_boolset types2-2.5 {n = 20} {5 6 7 8}\ntest_boolset types2-2.6 {n = 20.0} {5 6 7 8}\ntest_boolset types2-2.7 {n = '20'} {5 6 7 8}\ntest_boolset types2-2.8 {n = '20.0'} {5 6 7 8}\n\ntest_boolset types2-2.9 {t = 20} {5 7}\ntest_boolset types2-2.10 {t = 20.0} {6 8}\ntest_boolset types2-2.11 {t = '20'} {5 7}\ntest_boolset types2-2.12 {t = '20.0'} {6 8}\n\ntest_boolset types2-2.10 {o = 30} {9 10}\ntest_boolset types2-2.11 {o = 30.0} {9 10}\ntest_boolset types2-2.12 {o = '30'} 11\ntest_boolset types2-2.13 {o = '30.0'} 12\n\ntest_boolset types2-3.1 {i < 20} {1 2 3 4}\ntest_boolset types2-3.2 {i < 20.0} {1 2 3 4}\ntest_boolset types2-3.3 {i < '20'} {1 2 3 4}\ntest_boolset types2-3.4 {i < '20.0'} {1 2 3 4}\n\ntest_boolset types2-3.1 {n < 20} {1 2 3 4}\ntest_boolset types2-3.2 {n < 20.0} {1 2 3 4}\ntest_boolset types2-3.3 {n < '20'} {1 2 3 4}\ntest_boolset types2-3.4 {n < '20.0'} {1 2 3 4}\n\ntest_boolset types2-3.1 {t < 20} {1 2 3 4}\ntest_boolset types2-3.2 {t < 20.0} {1 2 3 4 5 7}\ntest_boolset types2-3.3 {t < '20'} {1 2 3 4}\ntest_boolset types2-3.4 {t < '20.0'} {1 2 3 4 5 7}\n\ntest_boolset types2-3.1 {o < 20} {1 2}\ntest_boolset types2-3.2 {o < 20.0} {1 2}\ntest_boolset types2-3.3 {o < '20'} {1 2 3 4 5 6 9 10}\ntest_boolset types2-3.3 {o < '20.0'} {1 2 3 4 5 6 7 9 10}\n\n# Compare literals against literals (always a numeric comparison).\n# Change (by ticket #805):  No affinity in comparisons\ntest_bool types2-4.1 \"\" {500 > 60.0} 1\ntest_bool types2-4.2 \"\" {'500' > 60.0} 1\ntest_bool types2-4.3 \"\" {500 > '60.0'} 0\ntest_bool types2-4.4 \"\" {'500' > '60.0'} 0\n\n# Compare literals against a column with TEXT affinity\ntest_bool types2-4.5 {t1=500.0} {t1 > 500} 1\ntest_bool types2-4.6 {t1=500.0} {t1 > '500' } 1\ntest_bool types2-4.7 {t1=500.0} {t1 > 500.0 } 0\ntest_bool types2-4.8 {t1=500.0} {t1 > '500.0' } 0\ntest_bool types2-4.9 {t1='500.0'} {t1 > 500 } 1\ntest_bool types2-4.10 {t1='500.0'} {t1 > '500' } 1\ntest_bool types2-4.11 {t1='500.0'} {t1 > 500.0 } 0\ntest_bool types2-4.12 {t1='500.0'} {t1 > '500.0' } 0\n\n# Compare literals against a column with NUMERIC affinity\ntest_bool types2-4.13 {n1=400} {500 > n1} 1\ntest_bool types2-4.14 {n1=400} {'500' > n1} 1\ntest_bool types2-4.15 {n1=400} {500.0 > n1} 1\ntest_bool types2-4.16 {n1=400} {'500.0' > n1} 1\ntest_bool types2-4.17 {n1='400'} {500 > n1} 1\ntest_bool types2-4.18 {n1='400'} {'500' > n1} 1\ntest_bool types2-4.19 {n1='400'} {500.0 > n1} 1\ntest_bool types2-4.20 {n1='400'} {'500.0' > n1} 1\n\n# Compare literals against a column with affinity NONE\ntest_bool types2-4.21 {o1=500} {500 > o1} 0\ntest_bool types2-4.22 {o1=500} {'500' > o1} 1\ntest_bool types2-4.23 {o1=500} {500.0 > o1} 0\ntest_bool types2-4.24 {o1=500} {'500.0' > o1} 1\ntest_bool types2-4.25 {o1='500'} {500 > o1} 0\ntest_bool types2-4.26 {o1='500'} {'500' > o1} 0\ntest_bool types2-4.27 {o1='500'} {500.0 > o1} 0\ntest_bool types2-4.28 {o1='500'} {'500.0' > o1} 1\n\nifcapable subquery {\n  # types2-5.* - The 'IN (x, y....)' operator with no index.\n  # \n  # Compare literals against literals (no affinity applied)\n  test_bool types2-5.1 {} {(NULL IN ('10.0', 20)) ISNULL} 1\n  test_bool types2-5.2 {} {10 IN ('10.0', 20)} 0\n  test_bool types2-5.3 {} {'10' IN ('10.0', 20)} 0\n  test_bool types2-5.4 {} {10 IN (10.0, 20)} 1\n  test_bool types2-5.5 {} {'10.0' IN (10, 20)} 0\n  \n  # Compare literals against a column with TEXT affinity\n  test_bool types2-5.6 {t1='10.0'} {t1 IN (10.0, 20)} 1\n  test_bool types2-5.7 {t1='10.0'} {t1 IN (10, 20)} 0\n  test_bool types2-5.8 {t1='10'} {t1 IN (10.0, 20)} 0\n  test_bool types2-5.9 {t1='10'} {t1 IN (20, '10.0')} 0\n  test_bool types2-5.10 {t1=10} {t1 IN (20, '10')} 1\n  \n  # Compare literals against a column with NUMERIC affinity\n  test_bool types2-5.11 {n1='10.0'} {n1 IN (10.0, 20)} 1\n  test_bool types2-5.12 {n1='10.0'} {n1 IN (10, 20)} 1\n  test_bool types2-5.13 {n1='10'} {n1 IN (10.0, 20)} 1\n  test_bool types2-5.14 {n1='10'} {n1 IN (20, '10.0')} 1\n  test_bool types2-5.15 {n1=10} {n1 IN (20, '10')} 1\n  \n  # Compare literals against a column with affinity NONE\n  test_bool types2-5.16 {o1='10.0'} {o1 IN (10.0, 20)} 0\n  test_bool types2-5.17 {o1='10.0'} {o1 IN (10, 20)} 0\n  test_bool types2-5.18 {o1='10'} {o1 IN (10.0, 20)} 0\n  test_bool types2-5.19 {o1='10'} {o1 IN (20, '10.0')} 0\n  test_bool types2-5.20 {o1=10} {o1 IN (20, '10')} 0\n  test_bool types2-5.21 {o1='10.0'} {o1 IN (10, 20, '10.0')} 1\n  test_bool types2-5.22 {o1='10'} {o1 IN (10.0, 20, '10')} 1\n  test_bool types2-5.23 {o1=10} {n1 IN (20, '10', 10)} 1\n\n  # Ticket #2248:  Comparisons of strings literals that look like\n  # numbers.\n  test_bool types2-5.24 {} {'1' IN ('1')} 1\n  test_bool types2-5.25 {} {'2' IN (2)} 0\n  test_bool types2-5.26 {} {3 IN ('3')} 0\n  test_bool types2-5.27 {} {4 IN (4)} 1\n\n  # The affinity of columns on the right side of IN(...) is ignored.\n  # All values in the expression list are treated as ordinary expressions,\n  # even if they are columns with affinity.\n  test_bool types2-5.30 {t1='10'} {10 IN (5,t1,'abc')} 0\n  test_bool types2-5.31 {t1='10'} {10 IN ('abc',t1,5)} 0\n  test_bool types2-5.32 {t1='010'} {10 IN (5,t1,'abc')} 0\n  test_bool types2-5.33 {t1='010'} {10 IN ('abc',t1,5)} 0\n  test_bool types2-5.34 {t1='10'} {'10' IN (5,t1,'abc')} 1\n  test_bool types2-5.35 {t1='10'} {'10' IN ('abc',t1,5)} 1\n  test_bool types2-5.36 {t1='010'} {'10' IN (5,t1,'abc')} 0\n  test_bool types2-5.37 {t1='010'} {'10' IN ('abc',t1,5)} 0\n  \n  # Columns on both the left and right of IN(...).  Only the column\n  # on the left matters.  The all values on the right are treated like\n  # expressions.\n  test_bool types2-5.40 {t1='10',n1=10} {t1 IN (5,n1,11)} 1\n  test_bool types2-5.41 {t1='010',n1=10} {t1 IN (5,n1,11)} 0\n  test_bool types2-5.42 {t1='10',n1=10} {n1 IN (5,t1,11)} 1\n  test_bool types2-5.43 {t1='010',n1=10} {n1 IN (5,t1,11)} 1\n}\n\n# Tests named types2-6.* use the same infrastructure as the types2-2.*\n# tests. The contents of the vals array is repeated here for easy \n# reference.\n# \n# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']\n#                1  2    3    4      5  6    7    8      9  10   11   12\n\nifcapable subquery {\n  test_boolset types2-6.1 {o IN ('10', 30)} {3 9 10}\n  test_boolset types2-6.2 {o IN (20.0, 30.0)} {5 6 9 10}\n  test_boolset types2-6.3 {t IN ('10', 30)} {1 3 9 11}\n  test_boolset types2-6.4 {t IN (20.0, 30.0)} {6 8 10 12}\n  test_boolset types2-6.5 {n IN ('10', 30)} {1 2 3 4 9 10 11 12}\n  test_boolset types2-6.6 {n IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}\n  test_boolset types2-6.7 {i IN ('10', 30)} {1 2 3 4 9 10 11 12}\n  test_boolset types2-6.8 {i IN (20.0, 30.0)} {5 6 7 8 9 10 11 12}\n\n  # Also test than IN(x, y, z) works on a rowid:\n  test_boolset types2-6.9 {rowid IN (1, 6, 10)} {1 6 10}\n}\n\n# Tests types2-7.* concentrate on expressions of the form \n# \"x IN (SELECT...)\" with no index.\nexecsql {\n  CREATE TABLE t3(i INTEGER, n NUMERIC, t TEXT, o BLOB);\n  INSERT INTO t3 VALUES(1, 1, 1, 1);\n  INSERT INTO t3 VALUES(2, 2, 2, 2);\n  INSERT INTO t3 VALUES(3, 3, 3, 3);\n  INSERT INTO t3 VALUES('1', '1', '1', '1');\n  INSERT INTO t3 VALUES('1.0', '1.0', '1.0', '1.0');\n}\n\nifcapable subquery {\n  test_bool types2-7.1 {i1=1} {i1 IN (SELECT i FROM t3)} 1\n  test_bool types2-7.2 {i1='2.0'} {i1 IN (SELECT i FROM t3)} 1\n  test_bool types2-7.3 {i1='2.0'} {i1 IN (SELECT n FROM t3)} 1\n  test_bool types2-7.4 {i1='2.0'} {i1 IN (SELECT t FROM t3)} 1\n  test_bool types2-7.5 {i1='2.0'} {i1 IN (SELECT o FROM t3)} 1\n  \n  test_bool types2-7.6 {n1=1} {n1 IN (SELECT n FROM t3)} 1\n  test_bool types2-7.7 {n1='2.0'} {n1 IN (SELECT i FROM t3)} 1\n  test_bool types2-7.8 {n1='2.0'} {n1 IN (SELECT n FROM t3)} 1\n  test_bool types2-7.9 {n1='2.0'} {n1 IN (SELECT t FROM t3)} 1\n  test_bool types2-7.10 {n1='2.0'} {n1 IN (SELECT o FROM t3)} 1\n  \n  test_bool types2-7.6 {t1=1} {t1 IN (SELECT t FROM t3)} 1\n  test_bool types2-7.7 {t1='2.0'} {t1 IN (SELECT t FROM t3)} 0\n  test_bool types2-7.8 {t1='2.0'} {t1 IN (SELECT n FROM t3)} 1\n  test_bool types2-7.9 {t1='2.0'} {t1 IN (SELECT i FROM t3)} 1\n  test_bool types2-7.10 {t1='2.0'} {t1 IN (SELECT o FROM t3)} 0\n  test_bool types2-7.11 {t1='1.0'} {t1 IN (SELECT t FROM t3)} 1\n  test_bool types2-7.12 {t1='1.0'} {t1 IN (SELECT o FROM t3)} 1\n  \n  test_bool types2-7.13 {o1=2} {o1 IN (SELECT o FROM t3)} 1\n  test_bool types2-7.14 {o1='2'} {o1 IN (SELECT o FROM t3)} 0\n  test_bool types2-7.15 {o1='2'} {o1 IN (SELECT o||'' FROM t3)} 1\n}\n\n# set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']\n#                1  2    3    4      5  6    7    8      9  10   11   12\nexecsql {\n  CREATE TABLE t4(i INTEGER, n NUMERIC, t VARCHAR(20), o LARGE BLOB);\n  INSERT INTO t4 VALUES(10, 20, 20, 30);\n}\nifcapable subquery {\n  test_boolset types2-8.1 {i IN (SELECT i FROM t4)} {1 2 3 4}\n  test_boolset types2-8.2 {n IN (SELECT i FROM t4)} {1 2 3 4}\n  test_boolset types2-8.3 {t IN (SELECT i FROM t4)} {1 2 3 4}\n  test_boolset types2-8.4 {o IN (SELECT i FROM t4)} {1 2 3 4}\n  test_boolset types2-8.5 {i IN (SELECT t FROM t4)} {5 6 7 8}\n  test_boolset types2-8.6 {n IN (SELECT t FROM t4)} {5 6 7 8}\n  test_boolset types2-8.7 {t IN (SELECT t FROM t4)} {5 7}\n  test_boolset types2-8.8 {o IN (SELECT t FROM t4)} {7}\n  test_boolset types2-8.9 {i IN (SELECT o FROM t4)} {9 10 11 12}\n  test_boolset types2-8.6 {n IN (SELECT o FROM t4)} {9 10 11 12}\n  test_boolset types2-8.7 {t IN (SELECT o FROM t4)} {}\n  test_boolset types2-8.8 {o IN (SELECT o FROM t4)} {9 10}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/types3.test",
    "content": "# 2005 June 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this file is testing the interaction of SQLite manifest types\n# with Tcl dual-representations.\n#\n# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# A variable with only a string representation comes in as TEXT\ndo_test types3-1.1 {\n  set V {}\n  append V x\n  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n} {string text}\n\n# A variable with an integer representation comes in as INTEGER\ndo_test types3-1.2 {\n  set V [expr {int(1+2)}]\n  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n} {int integer}\nset V [expr {1+12345678012345}]\nif {[tcl_variable_type V]==\"wideInt\"} {\n  do_test types3-1.3 {\n    set V [expr {1+123456789012345}]\n    concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n  } {wideInt integer}\n} else {\n  do_test types3-1.3 {\n    set V [expr {1+123456789012345}]\n    concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n  } {int integer}\n}\n\n# A double variable comes in as REAL\ndo_test types3-1.4 {\n  set V [expr {1.0+1}]\n  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n} {double real}\n\n# A byte-array variable comes in a BLOB if it has no string representation\n# or as TEXT if there is a string representation.\n#\ndo_test types3-1.5 {\n  set V [binary format a3 abc]\n  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n} {bytearray blob}\ndo_test types3-1.6 {\n  set V \"abc\"\n  binary scan $V a3 x\n  concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]\n} {bytearray text}\n\n# Check to make sure return values are of the right types.\n#\nifcapable bloblit {\n  do_test types3-2.1 {\n    set V [db one {SELECT x'616263'}]\n    tcl_variable_type V\n  } bytearray\n}\ndo_test types3-2.2 {\n  set V [db one {SELECT 123}]\n  tcl_variable_type V\n} int\nset Vx [expr {1+wide(123456789123456)}]\ndo_test types3-2.3 {\n  set V [db one {SELECT 1234567890123456}]\n  tcl_variable_type V\n} [tcl_variable_type Vx]\ndo_test types3-2.4.1 {\n  set V [db one {SELECT 1234567890123456.1}]\n  tcl_variable_type V\n} double\ndo_test types3-2.4.2 {\n  set V [db one {SELECT 1234567890123.456}]\n  tcl_variable_type V\n} double\ndo_test types3-2.5 {\n  set V [db one {SELECT '1234567890123456.0'}]\n  tcl_variable_type V\n} {}\ndo_test types3-2.6 {\n  set V [db one {SELECT NULL}]\n  tcl_variable_type V\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unionvtab.test",
    "content": "# 2017-07-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is percentile.c extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix unionvtab\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nload_static_extension db unionvtab\n\n#-------------------------------------------------------------------------\n# Warm body tests.\n#\nforcedelete test.db2\ndo_execsql_test 1.0 {\n  ATTACH 'test.db2' AS aux;\n\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n  CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);\n\n\n  INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');\n  INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');\n  INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');\n}\n\ndo_execsql_test 1.1 {\n  CREATE VIRTUAL TABLE temp.uuu USING unionvtab(\n    \"VALUES(NULL, 't1', 1, 9),  ('main', 't2', 10, 19), ('aux', 't3', 20, 29)\"\n  );\n  SELECT * FROM uuu;\n} {\n  1 one 2 two 3 three\n  10 ten 11 eleven 12 twelve\n  20 twenty 21 twenty-one 22 twenty-two\n}\n\ndo_execsql_test 1.2 {\n  PRAGMA table_info(uuu);\n} {\n  0 a INTEGER 0 {} 0 \n  1 b TEXT 0 {} 0\n}\n\ndo_execsql_test 1.3 {\n  SELECT * FROM uuu WHERE rowid = 3;\n  SELECT * FROM uuu WHERE rowid = 11;\n} {3 three 11 eleven}\n\ndo_execsql_test 1.4 {\n  SELECT * FROM uuu WHERE rowid IN (12, 10, 2);\n} {2 two 10 ten 12 twelve}\n\ndo_execsql_test 1.5 {\n  SELECT * FROM uuu WHERE rowid BETWEEN 3 AND 11;\n} {3 three 10 ten 11 eleven}\n\ndo_execsql_test 1.6 {\n  SELECT * FROM uuu WHERE rowid BETWEEN 11 AND 15;\n} {11 eleven 12 twelve}\n\ndo_execsql_test 1.7 {\n  SELECT * FROM uuu WHERE rowid BETWEEN -46 AND 1500;\n} {\n  1 one 2 two 3 three\n  10 ten 11 eleven 12 twelve\n  20 twenty 21 twenty-one 22 twenty-two\n}\n\ndo_execsql_test 1.8 {\n  CREATE TABLE src(db, tbl, min, max);\n  INSERT INTO src VALUES(NULL, 't1', 1, 9);\n  INSERT INTO src VALUES('main', 't2', 10, 19);\n  INSERT INTO src VALUES('aux', 't3', 20, 29);\n  CREATE VIRTUAL TABLE temp.opp USING unionvtab(src);\n  SELECT * FROM opp;\n} {\n  1 one 2 two 3 three\n  10 ten 11 eleven 12 twelve\n  20 twenty 21 twenty-one 22 twenty-two\n}\n\ndo_execsql_test 1.9 {\n  CREATE VIRTUAL TABLE temp.qll USING unionvtab(\n    'SELECT * FROM src WHERE db!=''xyz'''\n  );\n  SELECT * FROM qll WHERE rowid BETWEEN 10 AND 21;\n} {\n  10 ten 11 eleven 12 twelve\n  20 twenty 21 twenty-one\n}\n\n#-------------------------------------------------------------------------\n# Error conditions.\n#\n#   2.1.*: Attempt to create a unionvtab table outside of the TEMP schema.\n#   2.2.*: Tables that do not exist.\n#   2.3.*: Non rowid tables.\n#   2.4.*: Tables with mismatched schemas.\n#   2.5.*: A unionvtab table with zero source tables.\n#\ndo_catchsql_test 2.1.1 {\n  CREATE VIRTUAL TABLE u1 USING unionvtab(\"VALUES(NULL, 't1', 1, 100)\");\n} {1 {unionvtab tables must be created in TEMP schema}}\ndo_catchsql_test 2.1.2 {\n  CREATE VIRTUAL TABLE main.u1 USING unionvtab(\"VALUES('', 't1', 1, 100)\");\n} {1 {unionvtab tables must be created in TEMP schema}}\ndo_catchsql_test 2.1.3 {\n  CREATE VIRTUAL TABLE aux.u1 USING unionvtab(\"VALUES('', 't1', 1, 100)\");\n} {1 {unionvtab tables must be created in TEMP schema}}\n\ndo_catchsql_test 2.2.1 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES(NULL, 't555', 1, 100)\");\n} {1 {no such rowid table: t555}}\ndo_catchsql_test 2.2.2 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES('aux', 't555', 1, 100)\");\n} {1 {no such rowid table: aux.t555}}\ndo_catchsql_test 2.2.3 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES('xua', 't555', 1, 100)\");\n} {1 {no such rowid table: xua.t555}}\n\ndo_execsql_test 2.3.0 {\n  CREATE TABLE wr1(a, b, c PRIMARY KEY) WITHOUT ROWID;\n  CREATE VIEW v1 AS SELECT * FROM t1;\n  CREATE VIEW v2 AS SELECT _rowid_, * FROM t1;\n\n  CREATE TABLE wr2(a, _rowid_ INTEGER, c PRIMARY KEY) WITHOUT ROWID;\n  CREATE TABLE wr3(a, b, _rowid_ PRIMARY KEY) WITHOUT ROWID;\n}\ndo_catchsql_test 2.3.1 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES('main', 'wr1', 1, 2)\");\n} {1 {no such rowid table: main.wr1}}\ndo_catchsql_test 2.3.2 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES(NULL, 'v1', 1, 2)\");\n} {1 {no such rowid table: v1}}\ndo_catchsql_test 2.3.3 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES(NULL, 'v2', 1, 2)\");\n} {1 {no such rowid table: v2}}\ndo_catchsql_test 2.3.4 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES(NULL, 'wr2', 1, 2)\");\n} {1 {no such rowid table: wr2}}\ndo_catchsql_test 2.3.5 {\n  CREATE VIRTUAL TABLE temp.u1 USING unionvtab(\"VALUES(NULL, 'wr3', 1, 2)\");\n} {1 {no such rowid table: wr3}}\n\ndo_execsql_test 2.4.0 {\n  CREATE TABLE x1(a BLOB, b);\n  CREATE TABLE x2(a BLOB, b);\n  CREATE TEMP TABLE x3(a BLOB, b);\n\n  CREATE TABLE aux.y1(one, two, three INTEGER PRIMARY KEY);\n  CREATE TEMP TABLE y2(one, two, three INTEGER PRIMARY KEY);\n  CREATE TABLE y3(one, two, three INTEGER PRIMARY KEY);\n}\n\nforeach {tn dbs res} {\n  1 {x1 x2 x3} {0 {}}\n  2 {y1 y2 y3} {0 {}}\n  3 {x1 y2 y3} {1 {source table schema mismatch}}\n  4 {x1 y2 x3} {1 {source table schema mismatch}}\n  5 {x1 x2 y3} {1 {source table schema mismatch}}\n} {\n  set L [list]\n  set iMin 0\n  foreach e $dbs {\n    set E [split $e .]\n    if {[llength $E]>1} {\n      lappend L \"('[lindex $E 0]', '[lindex $E 1]', $iMin, $iMin)\"\n    } else {\n      lappend L \"(NULL, '$e', $iMin, $iMin)\"\n    }\n    incr iMin\n  }\n\n  set sql \"CREATE VIRTUAL TABLE temp.a1 USING unionvtab(\\\"VALUES [join $L ,]\\\")\"\n  do_catchsql_test 2.4.$tn \"\n    DROP TABLE IF EXISTS temp.a1;\n    CREATE VIRTUAL TABLE temp.a1 USING unionvtab(\\\"VALUES [join $L ,]\\\");\n  \" $res\n}\n\ndo_catchsql_test 2.5 {\n  CREATE VIRTUAL TABLE temp.b1 USING unionvtab(\n    [SELECT 'main', 'b1', 0, 100 WHERE 0]\n  )\n} {1 {no source tables configured}}\n\nforeach {tn sql} {\n  1 { VALUES('main', 't1', 10, 20), ('main', 't2', 30, 29) }\n  2 { VALUES('main', 't1', 10, 20), ('main', 't2', 15, 30) }\n} {\n  do_catchsql_test 2.6.$tn \"\n    CREATE VIRTUAL TABLE temp.a1 USING unionvtab(`$sql`)\n  \" {1 {rowid range mismatch error}}\n}\n\ndo_catchsql_test 2.7.1 {\n  CREATE VIRTUAL TABLE temp.b1 USING unionvtab(1, 2, 3, 4)\n} {1 {wrong number of arguments for unionvtab}}\n\n#-------------------------------------------------------------------------\n#\nreset_db\nload_static_extension db unionvtab\ndo_execsql_test 3.0 {\n  CREATE TABLE tbl1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE tbl2(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE tbl3(a INTEGER PRIMARY KEY, b);\n\n  WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )\n  INSERT INTO tbl1 SELECT ii, '1.' || ii FROM ss;\n\n  WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )\n  INSERT INTO tbl2 SELECT ii, '2.' || ii FROM ss;\n\n  WITH ss(ii) AS ( SELECT 1 UNION ALL SELECT ii+1 FROM ss WHERE ii<100 )\n  INSERT INTO tbl3 SELECT ii, '3.' || ii FROM ss;\n\n  CREATE VIRTUAL TABLE temp.uu USING unionvtab(\n    \"VALUES(NULL,'tbl2', 26, 74), (NULL,'tbl3', 75, 100), (NULL,'tbl1', 1, 25)\"\n  );\n}\n\ndo_execsql_test 3.1 {\n  SELECT * FROM uu WHERE rowid = 10;\n} {10 {1.10}}\ndo_execsql_test 3.2 {\n  SELECT * FROM uu WHERE rowid = 25;\n} {25 {1.25}}\n\ndo_execsql_test 3.3 { SELECT count(*) FROM uu WHERE rowid <= 24 } {24}\n\n# The following queries get the \"wrong\" answers. This is because the\n# module assumes that each source table contains rowids from only within\n# the range specified. For example, (rowid <= 25) matches 100 rows. This\n# is because the module implements (rowid <= 25) as a full table scan\n# of tbl1 only.\ndo_execsql_test 3.4.1 { SELECT count(*) FROM uu WHERE rowid <= 25 } {100}\ndo_execsql_test 3.4.2 { SELECT count(*) FROM uu WHERE rowid <= 26 } {126}\ndo_execsql_test 3.4.3 { SELECT count(*) FROM uu WHERE rowid <= 73 } {173}\ndo_execsql_test 3.4.4 { SELECT count(*) FROM uu WHERE rowid <= 74 } {200}\ndo_execsql_test 3.4.5 { SELECT count(*) FROM uu WHERE rowid <= 75 } {275}\ndo_execsql_test 3.4.6 { SELECT count(*) FROM uu WHERE rowid <= 99 } {299}\ndo_execsql_test 3.4.7 { SELECT count(*) FROM uu WHERE rowid <= 100 } {300}\ndo_execsql_test 3.4.8 { SELECT count(*) FROM uu WHERE rowid <= 101 } {300}\n\ndo_execsql_test 3.5.1 { SELECT count(*) FROM uu WHERE rowid < 25 } {24}\ndo_execsql_test 3.5.2 { SELECT count(*) FROM uu WHERE rowid < 26 } {100}\ndo_execsql_test 3.5.3 { SELECT count(*) FROM uu WHERE rowid < 27 } {126}\ndo_execsql_test 3.5.4 { SELECT count(*) FROM uu WHERE rowid < 73 } {172}\ndo_execsql_test 3.5.5 { SELECT count(*) FROM uu WHERE rowid < 74 } {173}\ndo_execsql_test 3.5.6 { SELECT count(*) FROM uu WHERE rowid < 75 } {200}\ndo_execsql_test 3.5.7 { SELECT count(*) FROM uu WHERE rowid < 76 } {275}\ndo_execsql_test 3.5.8 { SELECT count(*) FROM uu WHERE rowid < 99 } {298}\ndo_execsql_test 3.5.9 { SELECT count(*) FROM uu WHERE rowid < 100 } {299}\ndo_execsql_test 3.5.10 { SELECT count(*) FROM uu WHERE rowid < 101 } {300}\n\ndo_execsql_test 3.6.1 { SELECT count(*) FROM uu WHERE rowid > 24 } {276}\ndo_execsql_test 3.6.1 { SELECT count(*) FROM uu WHERE rowid > 25 } {200}\ndo_execsql_test 3.6.2 { SELECT count(*) FROM uu WHERE rowid > 26 } {174}\ndo_execsql_test 3.6.3 { SELECT count(*) FROM uu WHERE rowid > 27 } {173}\ndo_execsql_test 3.6.4 { SELECT count(*) FROM uu WHERE rowid > 73 } {127}\ndo_execsql_test 3.6.5 { SELECT count(*) FROM uu WHERE rowid > 74 } {100}\ndo_execsql_test 3.6.6 { SELECT count(*) FROM uu WHERE rowid > 75 } {25}\ndo_execsql_test 3.6.7 { SELECT count(*) FROM uu WHERE rowid > 76 } {24}\ndo_execsql_test 3.6.8 { SELECT count(*) FROM uu WHERE rowid > 99 } {1}\ndo_execsql_test 3.6.9 { SELECT count(*) FROM uu WHERE rowid > 100 } {0}\ndo_execsql_test 3.6.10 { SELECT count(*) FROM uu WHERE rowid > 101 } {0}\n\ndo_execsql_test 3.7.1 { SELECT count(*) FROM uu WHERE rowid >= 24 } {277}\ndo_execsql_test 3.7.1 { SELECT count(*) FROM uu WHERE rowid >= 25 } {276}\ndo_execsql_test 3.7.2 { SELECT count(*) FROM uu WHERE rowid >= 26 } {200}\ndo_execsql_test 3.7.3 { SELECT count(*) FROM uu WHERE rowid >= 27 } {174}\ndo_execsql_test 3.7.4 { SELECT count(*) FROM uu WHERE rowid >= 73 } {128}\ndo_execsql_test 3.7.5 { SELECT count(*) FROM uu WHERE rowid >= 74 } {127}\ndo_execsql_test 3.7.6 { SELECT count(*) FROM uu WHERE rowid >= 75 } {100}\ndo_execsql_test 3.7.7 { SELECT count(*) FROM uu WHERE rowid >= 76 } {25}\ndo_execsql_test 3.7.8 { SELECT count(*) FROM uu WHERE rowid >= 99 } {2}\ndo_execsql_test 3.7.9 { SELECT count(*) FROM uu WHERE rowid >= 100 } {1}\ndo_execsql_test 3.7.10 { SELECT count(*) FROM uu WHERE rowid >= 101 } {0}\n\nset L [expr  9223372036854775807]\nset S [expr -9223372036854775808]\n\ndo_execsql_test 3.8.1 { SELECT count(*) FROM uu WHERE rowid >= $S } {300}\ndo_execsql_test 3.8.2 { SELECT count(*) FROM uu WHERE rowid >  $S } {300}\ndo_execsql_test 3.8.3 { SELECT count(*) FROM uu WHERE rowid <= $S } {0}\ndo_execsql_test 3.8.4 { SELECT count(*) FROM uu WHERE rowid <  $S } {0}\n\ndo_execsql_test 3.9.1 { SELECT count(*) FROM uu WHERE rowid >= $L } {0}\ndo_execsql_test 3.9.2 { SELECT count(*) FROM uu WHERE rowid >  $L } {0}\ndo_execsql_test 3.9.3 { SELECT count(*) FROM uu WHERE rowid <= $L } {300}\ndo_execsql_test 3.9.4 { SELECT count(*) FROM uu WHERE rowid <  $L } {300}\n\ndo_execsql_test 3.10.1 { SELECT count(*) FROM uu WHERE a < 25 } {24}\ndo_execsql_test 3.10.2 { SELECT count(*) FROM uu WHERE a < 26 } {100}\ndo_execsql_test 3.10.3 { SELECT count(*) FROM uu WHERE a < 27 } {126}\ndo_execsql_test 3.10.4 { SELECT count(*) FROM uu WHERE a < 73 } {172}\ndo_execsql_test 3.10.5 { SELECT count(*) FROM uu WHERE a < 74 } {173}\ndo_execsql_test 3.10.6 { SELECT count(*) FROM uu WHERE a < 75 } {200}\ndo_execsql_test 3.10.7 { SELECT count(*) FROM uu WHERE a < 76 } {275}\ndo_execsql_test 3.10.8 { SELECT count(*) FROM uu WHERE a < 99 } {298}\ndo_execsql_test 3.10.9 { SELECT count(*) FROM uu WHERE a < 100 } {299}\ndo_execsql_test 3.10.10 { SELECT count(*) FROM uu WHERE a < 101 } {300}\n\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 4.0 {\n  CREATE TABLE s1(k INTEGER PRIMARY KEY, v);\n  INSERT INTO s1 VALUES($S, 'one');\n  INSERT INTO s1 VALUES($S+1, 'two');\n  INSERT INTO s1 VALUES($S+2, 'three');\n\n  CREATE TABLE l1(k INTEGER PRIMARY KEY, v);\n  INSERT INTO l1 VALUES($L, 'six');\n  INSERT INTO l1 VALUES($L-1, 'five');\n  INSERT INTO l1 VALUES($L-2, 'four');\n\n  CREATE VIRTUAL TABLE temp.sl USING unionvtab(\n    \"SELECT NULL, 'l1', 0, 9223372036854775807\n     UNION ALL\n     SELECT NULL, 's1', -9223372036854775808, -1\"\n  );\n}\n\ndo_execsql_test 4.1 {\n  SELECT * FROM sl;\n} {\n  -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five 9223372036854775807 six\n}\n\nforeach {k v} {\n  -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five 9223372036854775807 six\n} {\n  do_execsql_test 4.2.$v { SELECT * FROM sl WHERE rowid=$k } [list $k $v]\n}\n\ndo_execsql_test 4.3.1 {\n  SELECT * FROM sl WHERE rowid>-9223372036854775808\n} {\n  -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five 9223372036854775807 six\n}\ndo_execsql_test 4.3.2 {\n  SELECT * FROM sl WHERE rowid>=-9223372036854775808\n} {\n  -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five 9223372036854775807 six\n}\ndo_execsql_test 4.3.3 {\n  SELECT * FROM sl WHERE rowid<=-9223372036854775808\n} {\n  -9223372036854775808 one\n}\ndo_execsql_test 4.3.4 {\n  SELECT * FROM sl WHERE rowid<-9223372036854775808\n} { }\n\ndo_execsql_test 4.4.1 {\n  SELECT * FROM sl WHERE rowid<9223372036854775807\n} {\n  -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five\n}\ndo_execsql_test 4.4.2 {\n  SELECT * FROM sl WHERE rowid<=9223372036854775807\n} {\n  -9223372036854775808 one -9223372036854775807 two -9223372036854775806 three\n   9223372036854775805 four 9223372036854775806 five 9223372036854775807 six\n}\ndo_execsql_test 4.4.3 {\n  SELECT * FROM sl WHERE rowid>=9223372036854775807\n} {\n  9223372036854775807 six\n}\ndo_execsql_test 4.4.4 {\n  SELECT * FROM sl WHERE rowid>9223372036854775807\n} { }\n\n#-------------------------------------------------------------------------\n# More than 8 source tables.\n#\ndo_execsql_test 5.0 {\n  CREATE TABLE c0(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c1(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c2(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c3(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c4(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c5(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c6(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c7(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c8(one, two INTEGER PRIMARY KEY);\n  CREATE TABLE c9(one, two INTEGER PRIMARY KEY);\n\n  INSERT INTO c0 VALUES('zero', 0);\n  INSERT INTO c1 VALUES('one', 1);\n  INSERT INTO c2 VALUES('two', 2);\n  INSERT INTO c3 VALUES('three', 3);\n  INSERT INTO c4 VALUES('four', 4);\n  INSERT INTO c5 VALUES('five', 5);\n  INSERT INTO c6 VALUES('six', 6);\n  INSERT INTO c7 VALUES('seven', 7);\n  INSERT INTO c8 VALUES('eight', 8);\n  INSERT INTO c9 VALUES('nine', 9);\n\n  CREATE VIRTUAL TABLE temp.cc USING unionvtab([\n    SELECT 'main', 'c9', 9, 9 UNION ALL\n    SELECT 'main', 'c8', 8, 8 UNION ALL\n    SELECT 'main', 'c7', 7, 7 UNION ALL\n    SELECT 'main', 'c6', 6, 6 UNION ALL\n    SELECT 'main', 'c5', 5, 5 UNION ALL\n    SELECT 'main', 'c4', 4, 4 UNION ALL\n    SELECT 'main', 'c3', 3, 3 UNION ALL\n    SELECT 'main', 'c2', 2, 2 UNION ALL\n    SELECT 'main', 'c1', 1, 1 UNION ALL\n    SELECT 'main', 'c0', 0, 0\n  ]);\n\n  SELECT sum(two) FROM cc;\n} {45}\n\ndo_execsql_test 5.1 {\n  SELECT one FROM cc WHERE one>='seven'\n} {zero two three six seven}\n\ndo_execsql_test 5.2 {\n  SELECT y.one FROM cc AS x, cc AS y WHERE x.one=y.one AND x.rowid>5\n} {six seven eight nine}\n\ndo_execsql_test 5.3 {\n  SELECT cc.one FROM c4, cc WHERE cc.rowid>c4.rowid\n} {five six seven eight nine}\n\ndo_execsql_test 5.4 {\n  SELECT * FROM cc WHERE two LIKE '6'\n} {six 6}\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unionvtabfault.test",
    "content": "# 2017-07-15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is percentile.c extension\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix unionvtabfault\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nforcedelete test.db2\ndo_execsql_test 1.0 {\n  ATTACH 'test.db2' AS aux;\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b TEXT);\n  CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b TEXT);\n\n  INSERT INTO t1 VALUES(1, 'one'), (2, 'two'), (3, 'three');\n  INSERT INTO t2 VALUES(10, 'ten'), (11, 'eleven'), (12, 'twelve');\n  INSERT INTO t3 VALUES(20, 'twenty'), (21, 'twenty-one'), (22, 'twenty-two');\n}\nfaultsim_save_and_close\n\ndo_faultsim_test 1.1 -faults * -prep {\n  faultsim_restore_and_reopen\n  load_static_extension db unionvtab\n  execsql { ATTACH 'test.db2' AS aux; }\n  execsql { CREATE TEMP TABLE xyz(x); }\n} -body {\n  execsql {\n    CREATE VIRTUAL TABLE temp.uuu USING unionvtab(\n    \"VALUES(NULL, 't1', 1, 9),  ('main', 't2', 10, 19), ('aux', 't3', 20, 29)\"\n    );\n  }\n} -test {\n  faultsim_test_result {0 {}}             \\\n     {1 {vtable constructor failed: uuu}} \\\n     {1 {sql error: interrupted}}\n}\n\nfaultsim_restore_and_reopen\nload_static_extension db unionvtab\nexecsql { ATTACH 'test.db2' AS aux; }\nexecsql { CREATE TEMP TABLE xyz(x); }\nexecsql {\n  CREATE VIRTUAL TABLE temp.uuu USING unionvtab(\n      \"VALUES(NULL, 't1', 1, 9),  ('main', 't2', 10, 19), ('aux', 't3', 20, 29)\"\n  );\n}\ndo_faultsim_test 1.2 -faults oom* -prep {\n} -body {\n  execsql { SELECT * FROM uuu }\n} -test {\n  faultsim_test_result {0 {1 one 2 two 3 three 10 ten 11 eleven 12 twelve 20 twenty 21 twenty-one 22 twenty-two}} \n}\n\n#-------------------------------------------------------------------------\n# Error while registering the two vtab modules.\ndo_faultsim_test 2.0 -faults * -prep {\n  catch { db close }\n  sqlite3 db :memory:\n} -body {\n  load_static_extension db unionvtab\n} -test {\n  faultsim_test_result {0 {}} {1 {initialization of unionvtab failed: }}\n}\n\n\n\nfinish_test\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unique.test",
    "content": "# 2001 September 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE UNIQUE INDEX statement,\n# and primary keys, and the UNIQUE constraint on table columns\n#\n# $Id: unique.test,v 1.9 2009/05/02 15:46:47 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Try to create a table with two primary keys.\n# (This is allowed in SQLite even that it is not valid SQL)\n#\ndo_test unique-1.1 {\n  catchsql {\n    CREATE TABLE t1(\n       a int PRIMARY KEY,\n       b int PRIMARY KEY,\n       c text\n    );\n  }\n} {1 {table \"t1\" has more than one primary key}}\ndo_test unique-1.1b {\n  catchsql {\n    CREATE TABLE t1(\n       a int PRIMARY KEY,\n       b int UNIQUE,\n       c text\n    );\n  }\n} {0 {}}\ndo_test unique-1.2 {\n  catchsql {\n    INSERT INTO t1(a,b,c) VALUES(1,2,3)\n  }\n} {0 {}}\ndo_test unique-1.3 {\n  catchsql {\n    INSERT INTO t1(a,b,c) VALUES(1,3,4)\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\nverify_ex_errcode unique-1.3b SQLITE_CONSTRAINT_PRIMARYKEY\ndo_test unique-1.4 {\n  execsql {\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 2 3}\ndo_test unique-1.5 {\n  catchsql {\n    INSERT INTO t1(a,b,c) VALUES(3,2,4)\n  }\n} {1 {UNIQUE constraint failed: t1.b}}\nverify_ex_errcode unique-1.5b SQLITE_CONSTRAINT_UNIQUE\ndo_test unique-1.6 {\n  execsql {\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 2 3}\ndo_test unique-1.7 {\n  catchsql {\n    INSERT INTO t1(a,b,c) VALUES(3,4,5)\n  }\n} {0 {}}\ndo_test unique-1.8 {\n  execsql {\n    SELECT * FROM t1 ORDER BY a;\n  }\n} {1 2 3 3 4 5}\nintegrity_check unique-1.9\n\ndo_test unique-2.0 {\n  execsql {\n    DROP TABLE t1;\n    CREATE TABLE t2(a int, b int);\n    INSERT INTO t2(a,b) VALUES(1,2);\n    INSERT INTO t2(a,b) VALUES(3,4);\n    SELECT * FROM t2 ORDER BY a;\n  }\n} {1 2 3 4}\ndo_test unique-2.1 {\n  catchsql {\n    CREATE UNIQUE INDEX i2 ON t2(a)\n  }\n} {0 {}}\ndo_test unique-2.2 {\n  catchsql {\n    SELECT * FROM t2 ORDER BY a\n  }\n} {0 {1 2 3 4}}\ndo_test unique-2.3 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,5);\n  }\n} {1 {UNIQUE constraint failed: t2.a}}\nverify_ex_errcode unique-2.3b SQLITE_CONSTRAINT_UNIQUE\ndo_test unique-2.4 {\n  catchsql {\n    SELECT * FROM t2 ORDER BY a\n  }\n} {0 {1 2 3 4}}\ndo_test unique-2.5 {\n  catchsql {\n    DROP INDEX i2;\n    SELECT * FROM t2 ORDER BY a;\n  }\n} {0 {1 2 3 4}}\ndo_test unique-2.6 {\n  catchsql {\n    INSERT INTO t2 VALUES(1,5)\n  }\n} {0 {}}\ndo_test unique-2.7 {\n  catchsql {\n    SELECT * FROM t2 ORDER BY a, b;\n  }\n} {0 {1 2 1 5 3 4}}\ndo_test unique-2.8 {\n  catchsql {\n    CREATE UNIQUE INDEX i2 ON t2(a);\n  }\n} {1 {UNIQUE constraint failed: t2.a}}\nverify_ex_errcode unique-2.8b SQLITE_CONSTRAINT_UNIQUE\ndo_test unique-2.9 {\n  catchsql {\n    CREATE INDEX i2 ON t2(a);\n  }\n} {0 {}}\nintegrity_check unique-2.10\n\n# Test the UNIQUE keyword as used on two or more fields.\n#\ndo_test unique-3.1 {\n  catchsql {\n    CREATE TABLE t3(\n       a int,\n       b int,\n       c int,\n       d int,\n       unique(a,c,d)\n     );\n  }\n} {0 {}}\ndo_test unique-3.2 {\n  catchsql {\n    INSERT INTO t3(a,b,c,d) VALUES(1,2,3,4);\n    SELECT * FROM t3 ORDER BY a,b,c,d;\n  }\n} {0 {1 2 3 4}}\ndo_test unique-3.3 {\n  catchsql {\n    INSERT INTO t3(a,b,c,d) VALUES(1,2,3,5);\n    SELECT * FROM t3 ORDER BY a,b,c,d;\n  }\n} {0 {1 2 3 4 1 2 3 5}}\ndo_test unique-3.4 {\n  catchsql {\n    INSERT INTO t3(a,b,c,d) VALUES(1,4,3,5);\n    SELECT * FROM t3 ORDER BY a,b,c,d;\n  }\n} {1 {UNIQUE constraint failed: t3.a, t3.c, t3.d}}\nverify_ex_errcode unique-3.4b SQLITE_CONSTRAINT_UNIQUE\nintegrity_check unique-3.5\n\n# Make sure NULLs are distinct as far as the UNIQUE tests are\n# concerned.\n#\ndo_test unique-4.1 {\n  execsql {\n    CREATE TABLE t4(a UNIQUE, b, c, UNIQUE(b,c));\n    INSERT INTO t4 VALUES(1,2,3);\n    INSERT INTO t4 VALUES(NULL, 2, NULL);\n    SELECT * FROM t4;\n  }\n} {1 2 3 {} 2 {}}\ndo_test unique-4.2 {\n  catchsql {\n    INSERT INTO t4 VALUES(NULL, 3, 4);\n  }\n} {0 {}}\ndo_test unique-4.3 {\n  execsql {\n    SELECT * FROM t4\n  }\n} {1 2 3 {} 2 {} {} 3 4}\ndo_test unique-4.4 {\n  catchsql {\n    INSERT INTO t4 VALUES(2, 2, NULL);\n  }\n} {0 {}}\ndo_test unique-4.5 {\n  execsql {\n    SELECT * FROM t4\n  }\n} {1 2 3 {} 2 {} {} 3 4 2 2 {}}\n\n# Ticket #1301.  Any NULL value in a set of unique columns should\n# cause the rows to be distinct.\n#\ndo_test unique-4.6 {\n  catchsql {\n    INSERT INTO t4 VALUES(NULL, 2, NULL);\n  }\n} {0 {}}\ndo_test unique-4.7 {\n  execsql {SELECT * FROM t4}\n} {1 2 3 {} 2 {} {} 3 4 2 2 {} {} 2 {}}\ndo_test unique-4.8 {\n  catchsql {CREATE UNIQUE INDEX i4a ON t4(a,b)}\n} {0 {}}\ndo_test unique-4.9 {\n  catchsql {CREATE UNIQUE INDEX i4b ON t4(a,b,c)}\n} {0 {}}\ndo_test unique-4.10 {\n  catchsql {CREATE UNIQUE INDEX i4c ON t4(b)}\n} {1 {UNIQUE constraint failed: t4.b}}\nverify_ex_errcode unique-4.10b SQLITE_CONSTRAINT_UNIQUE\nintegrity_check unique-4.99\n\n# Test the error message generation logic.  In particular, make sure we\n# do not overflow the static buffer used to generate the error message.\n#\ndo_test unique-5.1 {\n  execsql {\n    CREATE TABLE t5(\n      first_column_with_long_name,\n      second_column_with_long_name,\n      third_column_with_long_name,\n      fourth_column_with_long_name,\n      fifth_column_with_long_name,\n      sixth_column_with_long_name,\n      UNIQUE(\n        first_column_with_long_name,\n        second_column_with_long_name,\n        third_column_with_long_name,\n        fourth_column_with_long_name,\n        fifth_column_with_long_name,\n        sixth_column_with_long_name\n      )\n    );\n    INSERT INTO t5 VALUES(1,2,3,4,5,6);\n    SELECT * FROM t5;\n  }\n} {1 2 3 4 5 6}\ndo_test unique-5.2 {\n  catchsql {\n    INSERT INTO t5 VALUES(1,2,3,4,5,6);\n  }\n} {1 {UNIQUE constraint failed: t5.first_column_with_long_name, t5.second_column_with_long_name, t5.third_column_with_long_name, t5.fourth_column_with_long_name, t5.fifth_column_with_long_name, t5.sixth_column_with_long_name}}\nverify_ex_errcode unique-5.2b SQLITE_CONSTRAINT_UNIQUE\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unique2.test",
    "content": "# 2014-07-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the CREATE UNIQUE INDEX statement\n# to verify that ticket 9a6daf340df99ba93c53bcf8fa83d9f28040d2a8\n# has been fixed:\n#\n#  drh added on 2014-07-30 12:33:04:\n#\n#  The CREATE UNIQUE INDEX on the third line below does not fail even\n#  though the x column values are not all unique.\n#\n#     CREATE TABLE t1(x NOT NULL);\n#     INSERT INTO t1 VALUES(1),(2),(2),(3);\n#     CREATE UNIQUE INDEX t1x ON t1(x);\n#\n# If the index is created before the INSERT, then uniqueness is enforced\n# at the point of the INSERT. Note that the NOT NULL on the indexed column\n# seems to be required in order to exhibit this bug.\n#\n# \"PRAGMA integrity_check\" does not detect the resulting malformed database.\n# That might be considered a separate issue.\n#\n# Bisecting shows that this problem was introduced by the addition of\n#  WITHOUT ROWID support in version 3.8.2, specifically in check-in\n# [c80e229dd9c1230] on 2013-11-07. This problem was reported on the mailing\n# list by Pavel Pimenov.  and primary keys, and the UNIQUE constraint\n# on table columns\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nforeach {id sql} {\n   1 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL) WITHOUT ROWID}\n   2 {CREATE TABLE t1(x TEXT PRIMARY KEY, y NOT NULL)}\n   3 {CREATE TABLE t1(x TEXT PRIMARY KEY, y) WITHOUT ROWID}\n   4 {CREATE TABLE t1(x TEXT PRIMARY KEY, y)}\n} {\n  do_test $id.1 {\n    db eval {DROP TABLE IF EXISTS t1}\n    db eval $sql\n    db eval {INSERT INTO t1(x,y) VALUES(1,1),(2,2),(3,2),(4,3)}\n  } {}\n  do_test $id.2 {\n    catchsql {CREATE UNIQUE INDEX t1y ON t1(y)}\n  } {1 {UNIQUE constraint failed: t1.y}}\n}\n\nforeach {id sql} {\n   5 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}\n   6 {CREATE TABLE t1(w,x,y NOT NULL,z NOT NULL,PRIMARY KEY(w,x))}\n   7 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x)) WITHOUT ROWID}\n   8 {CREATE TABLE t1(w,x,y NOT NULL,z,PRIMARY KEY(w,x))}\n   9 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x)) WITHOUT ROWID}\n  10 {CREATE TABLE t1(w,x,y,z NOT NULL,PRIMARY KEY(w,x))}\n  11 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x)) WITHOUT ROWID}\n  12 {CREATE TABLE t1(w,x,y,z,PRIMARY KEY(w,x))}\n} {\n  do_test $id.1 {\n    db eval {DROP TABLE IF EXISTS t1}\n    db eval $sql\n    db eval {INSERT INTO t1(w,x,y,z) VALUES(1,2,3,4),(2,3,3,4)}\n  } {}\n  do_test $id.2 {\n    catchsql {CREATE UNIQUE INDEX t1yz ON t1(y,z)}\n  } {1 {UNIQUE constraint failed: t1.y, t1.z}}\n}\n\ndo_catchsql_test 13.1 {\n  CREATE TABLE err1(a,b,c,UNIQUE(rowid));\n} {1 {no such column: rowid}}\ndo_catchsql_test 13.2 {\n  CREATE TABLE err1(a,b,c,PRIMARY KEY(rowid));\n} {1 {no such column: rowid}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unixexcl.test",
    "content": "# 2011 March 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for the \"unix-excl\" VFS module (part of \n# os_unix.c).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\n\nif {$::tcl_platform(platform)!=\"unix\" || [info commands test_syscall]==\"\"} {\n  finish_test\n  return\n} \nset testprefix unixexcl\n\n\n\n# Test that when using VFS \"unix-excl\", the first time the database is read\n# a process-wide exclusive lock is taken on it. This means other connections\n# within the process may still access the db normally, but connections from\n# outside the process cannot.\n#\ndo_multiclient_test tn {\n  do_test unixexcl-1.$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES('hello', 'world');\n    }\n  } {}\n  do_test unixexcl-1.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}\n  do_test unixexcl-1.$tn.3 {\n    code1 {\n      db close\n      sqlite3 db test.db -vfs unix-excl\n      db eval { SELECT * FROM t1 }\n    }\n  } {hello world}\n  if {$tn==1} {\n    do_test unixexcl-1.$tn.4.multiproc { \n      csql2 { SELECT * FROM t1 } \n    } {1 {database is locked}}\n  } else {\n    do_test unixexcl-1.$tn.4.singleproc { \n      csql2 { SELECT * FROM t1 } \n    } {0 {hello world}}\n  }\n}\n\n# Test that when using VFS \"unix-excl\", if a file is opened in read-only mode\n# the behaviour is the same as if VFS \"unix\" were used.\n#\ndo_multiclient_test tn {\n  do_test unixexcl-2.$tn.1 {\n    sql1 {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES('hello', 'world');\n    }\n  } {}\n  do_test unixexcl-2.$tn.2 { sql2 { SELECT * FROM t1 } } {hello world}\n  do_test unixexcl-2.$tn.3 {\n    code1 {\n      db close\n      sqlite3 db test.db -readonly yes -vfs unix-excl\n      db eval { SELECT * FROM t1 }\n    }\n  } {hello world}\n  do_test unixexcl-2.$tn.4 { \n    csql2 { SELECT * FROM t1 } \n  } {0 {hello world}}\n}\n\ndo_multiclient_test tn {\n  do_test unixexcl-3.$tn.1 {\n    code1 { db close; sqlite3 db file:test.db?psow=0 -vfs unix-excl -uri 1 }\n    code2 { db2 close; sqlite3 db2 file:test.db?psow=0 -vfs unix-excl -uri 1 }\n    sql1 {\n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = WAL;\n      PRAGMA synchronous = FULL;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    }\n  } {wal}\n\n  if {$tn==1} {\n    do_test unixexcl-3.$tn.1.multiproc {\n      csql2 { SELECT * FROM t1; }\n    } {1 {database is locked}}\n  } else {\n    do_test unixexcl-3.$tn.1.singleproc {\n      sql2 { SELECT * FROM t1; }\n    } {1 2}\n\n    do_test unixexcl-3.$tn.2 {\n      sql2 { \n        BEGIN;\n          SELECT * FROM t1;\n      }\n    } {1 2}\n    do_test unixexcl-3.$tn.3 {\n      sql1 { PRAGMA wal_checkpoint; INSERT INTO t1 VALUES(3, 4); }\n    } {0 5 5}\n    do_test unixexcl-3.$tn.4 {\n      sql2 { SELECT * FROM t1; }\n    } {1 2}\n    do_test unixexcl-3.$tn.5 {\n      sql1 { SELECT * FROM t1; }\n    } {1 2 3 4}\n    do_test unixexcl-3.$tn.6 {\n      sql2 { COMMIT; SELECT * FROM t1; }\n    } {1 2 3 4}\n    do_test unixexcl-3.$tn.7 {\n      sql1 { PRAGMA wal_checkpoint; }\n    } {0 7 7}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/unordered.test",
    "content": "# 2011 April 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  \n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix unordered\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b);\n  CREATE INDEX i1 ON t1(a);\n  INSERT INTO t1 VALUES(1, 'xxx');\n  INSERT INTO t1 SELECT a+1, b FROM t1;\n  INSERT INTO t1 SELECT a+2, b FROM t1;\n  INSERT INTO t1 SELECT a+4, b FROM t1;\n  INSERT INTO t1 SELECT a+8, b FROM t1;\n  INSERT INTO t1 SELECT a+16, b FROM t1;\n  INSERT INTO t1 SELECT a+32, b FROM t1;\n  INSERT INTO t1 SELECT a+64, b FROM t1;\n  ANALYZE;\n} {}\n\nforeach idxmode {ordered unordered} {\n  catchsql { DELETE FROM sqlite_stat2 }\n  catchsql { DELETE FROM sqlite_stat3 }\n  if {$idxmode == \"unordered\"} {\n    execsql { UPDATE sqlite_stat1 SET stat = stat || ' unordered' }\n  }\n  db close\n  sqlite3 db test.db\n  foreach {tn sql r(ordered) r(unordered)} {\n    1   \"SELECT * FROM t1 ORDER BY a\"\n        {0 0 0 {SCAN TABLE t1 USING INDEX i1}}\n        {0 0 0 {SCAN TABLE t1} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}\n    2   \"SELECT * FROM t1 WHERE a > 100\"\n        {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}\n        {0 0 0 {SCAN TABLE t1}}\n    3   \"SELECT * FROM t1 WHERE a = ? ORDER BY rowid\"\n        {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\n        {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)} \n         0 0 0 {USE TEMP B-TREE FOR ORDER BY}}\n    4   \"SELECT max(a) FROM t1\"\n        {0 0 0 {SEARCH TABLE t1 USING COVERING INDEX i1}}\n        {0 0 0 {SEARCH TABLE t1}}\n    5   \"SELECT group_concat(b) FROM t1 GROUP BY a\"\n        {0 0 0 {SCAN TABLE t1 USING INDEX i1}}\n        {0 0 0 {SCAN TABLE t1} 0 0 0 {USE TEMP B-TREE FOR GROUP BY}}\n\n    6   \"SELECT * FROM t1 WHERE a = ?\"\n        {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\n        {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\n    7   \"SELECT count(*) FROM t1\"\n        {0 0 0 {SCAN TABLE t1 USING COVERING INDEX i1}}\n        {0 0 0 {SCAN TABLE t1}}\n  } {\n    do_eqp_test 1.$idxmode.$tn $sql $r($idxmode)\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/update.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the UPDATE statement.\n#\n# $Id: update.test,v 1.19 2008/04/10 18:44:36 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Try to update an non-existent table\n#\ndo_test update-1.1 {\n  set v [catch {execsql {UPDATE test1 SET f2=5 WHERE f1<1}} msg]\n  lappend v $msg\n} {1 {no such table: test1}}\n\n# Try to update a read-only table\n#\ndo_test update-2.1 {\n  set v [catch \\\n       {execsql {UPDATE sqlite_master SET name='xyz' WHERE name='123'}} msg]\n  lappend v $msg\n} {1 {table sqlite_master may not be modified}}\n\n# Create a table to work with\n#\ndo_test update-3.1 {\n  execsql {CREATE TABLE test1(f1 int,f2 int)}\n  for {set i 1} {$i<=10} {incr i} {\n    set sql \"INSERT INTO test1 VALUES($i,[expr {1<<$i}])\"\n    execsql $sql\n  }\n  execsql {SELECT * FROM test1 ORDER BY f1}\n} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}\n\n# Unknown column name in an expression\n#\ndo_test update-3.2 {\n  set v [catch {execsql {UPDATE test1 SET f1=f3*2 WHERE f2==32}} msg]\n  lappend v $msg\n} {1 {no such column: f3}}\ndo_test update-3.3 {\n  set v [catch {execsql {UPDATE test1 SET f1=test2.f1*2 WHERE f2==32}} msg]\n  lappend v $msg\n} {1 {no such column: test2.f1}}\ndo_test update-3.4 {\n  set v [catch {execsql {UPDATE test1 SET f3=f1*2 WHERE f2==32}} msg]\n  lappend v $msg\n} {1 {no such column: f3}}\n\n# Actually do some updates\n#\ndo_test update-3.5 {\n  execsql {UPDATE test1 SET f2=f2*3}\n} {}\ndo_test update-3.5.1 {\n  db changes\n} {10}\n\n# verify that SELECT does not reset the change counter\ndo_test update-3.5.2 {\n  db eval {SELECT count(*) FROM test1}\n} {10}\ndo_test update-3.5.3 {\n  db changes\n} {10}\n\ndo_test update-3.6 {\n  execsql {SELECT * FROM test1 ORDER BY f1}\n} {1 6 2 12 3 24 4 48 5 96 6 192 7 384 8 768 9 1536 10 3072}\ndo_test update-3.7 {\n  execsql {PRAGMA count_changes=on}\n  execsql {UPDATE test1 SET f2=f2/3 WHERE f1<=5}\n} {5}\ndo_test update-3.8 {\n  execsql {SELECT * FROM test1 ORDER BY f1}\n} {1 2 2 4 3 8 4 16 5 32 6 192 7 384 8 768 9 1536 10 3072}\ndo_test update-3.9 {\n  execsql {UPDATE test1 SET f2=f2/3 WHERE f1>5}\n} {5}\ndo_test update-3.10 {\n  execsql {SELECT * FROM test1 ORDER BY f1}\n} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}\n\n# Swap the values of f1 and f2 for all elements\n#\ndo_test update-3.11 {\n  execsql {UPDATE test1 SET F2=f1, F1=f2}\n} {10}\ndo_test update-3.12 {\n  execsql {SELECT * FROM test1 ORDER BY F1}\n} {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1024 10}\ndo_test update-3.13 {\n  execsql {PRAGMA count_changes=off}\n  execsql {UPDATE test1 SET F2=f1, F1=f2}\n} {}\ndo_test update-3.14 {\n  execsql {SELECT * FROM test1 ORDER BY F1}\n} {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}\n\n# Create duplicate entries and make sure updating still\n# works.\n#\ndo_test update-4.0 {\n  execsql {\n    DELETE FROM test1 WHERE f1<=5;\n    INSERT INTO test1(f1,f2) VALUES(8,88);\n    INSERT INTO test1(f1,f2) VALUES(8,888);\n    INSERT INTO test1(f1,f2) VALUES(77,128);\n    INSERT INTO test1(f1,f2) VALUES(777,128);\n  }\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-4.1 {\n  execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}\ndo_test update-4.2 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-4.3 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-4.4 {\n  execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}\ndo_test update-4.5 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}\ndo_test update-4.6 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;\n  }\n} {2}\ndo_test update-4.7 {\n  execsql {\n    PRAGMA count_changes=off;\n    SELECT * FROM test1 ORDER BY f1,f2\n  }\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\n\n# Repeat the previous sequence of tests with an index.\n#\ndo_test update-5.0 {\n  execsql {CREATE INDEX idx1 ON test1(f1)}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-5.1 {\n  execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}\ndo_test update-5.2 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-5.3 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-5.4 {\n  execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}\ndo_test update-5.4.1 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-5.4.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {778 128}\ndo_test update-5.4.3 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-5.5 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}\n} {}\ndo_test update-5.5.1 {\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}\ndo_test update-5.5.2 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-5.5.3 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-5.5.4 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-5.5.5 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-5.6 {\n  execsql {\n    PRAGMA count_changes=on;\n    UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;\n  }\n} {2}\ndo_test update-5.6.1 {\n  execsql {\n    PRAGMA count_changes=off;\n    SELECT * FROM test1 ORDER BY f1,f2\n  }\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-5.6.2 {\n  execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}\n} {77 128}\ndo_test update-5.6.3 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-5.6.4 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-5.6.5 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 256 8 888}\n\n# Repeat the previous sequence of tests with a different index.\n#\nexecsql {PRAGMA synchronous=FULL}\ndo_test update-6.0 {\n  execsql {DROP INDEX idx1}\n  execsql {CREATE INDEX idx1 ON test1(f2)}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-6.1 {\n  execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}\ndo_test update-6.1.1 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 89 8 257 8 889}\ndo_test update-6.1.2 {\n  execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}\n} {8 89}\ndo_test update-6.1.3 {\n  execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}\n} {}\ndo_test update-6.2 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-6.3 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-6.3.1 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 256 8 888}\ndo_test update-6.3.2 {\n  execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}\n} {}\ndo_test update-6.3.3 {\n  execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}\n} {8 88}\ndo_test update-6.4 {\n  execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}\ndo_test update-6.4.1 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-6.4.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {778 128}\ndo_test update-6.4.3 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-6.5 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}\ndo_test update-6.5.1 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-6.5.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-6.5.3 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-6.5.4 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-6.6 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-6.6.1 {\n  execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}\n} {77 128}\ndo_test update-6.6.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-6.6.3 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-6.6.4 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 256 8 888}\n\n# Repeat the previous sequence of tests with multiple\n# indices\n#\ndo_test update-7.0 {\n  execsql {CREATE INDEX idx2 ON test1(f2)}\n  execsql {CREATE INDEX idx3 ON test1(f1,f2)}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-7.1 {\n  execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}\ndo_test update-7.1.1 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 89 8 257 8 889}\ndo_test update-7.1.2 {\n  execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}\n} {8 89}\ndo_test update-7.1.3 {\n  execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}\n} {}\ndo_test update-7.2 {\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-7.3 {\n  # explain {UPDATE test1 SET f2=f2-1 WHERE f1==8 and F2<300}\n  execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-7.3.1 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 256 8 888}\ndo_test update-7.3.2 {\n  execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}\n} {}\ndo_test update-7.3.3 {\n  execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}\n} {8 88}\ndo_test update-7.4 {\n  execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}\ndo_test update-7.4.1 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-7.4.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {778 128}\ndo_test update-7.4.3 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-7.5 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}\ndo_test update-7.5.1 {\n  execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}\n} {78 128}\ndo_test update-7.5.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-7.5.3 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-7.5.4 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 128 8 256 8 888}\ndo_test update-7.6 {\n  execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}\n  execsql {SELECT * FROM test1 ORDER BY f1,f2}\n} {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}\ndo_test update-7.6.1 {\n  execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}\n} {77 128}\ndo_test update-7.6.2 {\n  execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}\n} {}\ndo_test update-7.6.3 {\n  execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}\n} {777 128}\ndo_test update-7.6.4 {\n  execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}\n} {8 88 8 256 8 888}\n\n# Error messages\n#\ndo_test update-9.1 {\n  set v [catch {execsql {\n    UPDATE test1 SET x=11 WHERE f1=1025\n  }} msg]\n  lappend v $msg\n} {1 {no such column: x}}\ndo_test update-9.2 {\n  set v [catch {execsql {\n    UPDATE test1 SET f1=x(11) WHERE f1=1025\n  }} msg]\n  lappend v $msg\n} {1 {no such function: x}}\ndo_test update-9.3 {\n  set v [catch {execsql {\n    UPDATE test1 SET f1=11 WHERE x=1025\n  }} msg]\n  lappend v $msg\n} {1 {no such column: x}}\ndo_test update-9.4 {\n  set v [catch {execsql {\n    UPDATE test1 SET f1=11 WHERE x(f1)=1025\n  }} msg]\n  lappend v $msg\n} {1 {no such function: x}}\n\n# Try doing updates on a unique column where the value does not\n# really change.\n#\ndo_test update-10.1 {\n  execsql {\n    DROP TABLE test1;\n    CREATE TABLE t1(\n       a integer primary key,\n       b UNIQUE, \n       c, d,\n       e, f,\n       UNIQUE(c,d)\n    );\n    INSERT INTO t1 VALUES(1,2,3,4,5,6);\n    INSERT INTO t1 VALUES(2,3,4,4,6,7);\n    SELECT * FROM t1\n  }\n} {1 2 3 4 5 6 2 3 4 4 6 7}\ndo_test update-10.2 {\n  catchsql {\n    UPDATE t1 SET a=1, e=9 WHERE f=6;\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 9 6 2 3 4 4 6 7}}\ndo_test update-10.3 {\n  catchsql {\n    UPDATE t1 SET a=1, e=10 WHERE f=7;\n    SELECT * FROM t1;\n  }\n} {1 {UNIQUE constraint failed: t1.a}}\ndo_test update-10.4 {\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 9 6 2 3 4 4 6 7}}\ndo_test update-10.5 {\n  catchsql {\n    UPDATE t1 SET b=2, e=11 WHERE f=6;\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 11 6 2 3 4 4 6 7}}\ndo_test update-10.6 {\n  catchsql {\n    UPDATE t1 SET b=2, e=12 WHERE f=7;\n    SELECT * FROM t1;\n  }\n} {1 {UNIQUE constraint failed: t1.b}}\ndo_test update-10.7 {\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 11 6 2 3 4 4 6 7}}\ndo_test update-10.8 {\n  catchsql {\n    UPDATE t1 SET c=3, d=4, e=13 WHERE f=6;\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 13 6 2 3 4 4 6 7}}\ndo_test update-10.9 {\n  catchsql {\n    UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;\n    SELECT * FROM t1;\n  }\n} {1 {UNIQUE constraint failed: t1.c, t1.d}}\ndo_test update-10.10 {\n  catchsql {\n    SELECT * FROM t1;\n  }\n} {0 {1 2 3 4 13 6 2 3 4 4 6 7}}\n\n# Make sure we can handle a subquery in the where clause.\n#\nifcapable subquery {\n  do_test update-11.1 {\n    execsql {\n      UPDATE t1 SET e=e+1 WHERE b IN (SELECT b FROM t1);\n      SELECT b,e FROM t1;\n    }\n  } {2 14 3 7}\n  do_test update-11.2 {\n    execsql {\n      UPDATE t1 SET e=e+1 WHERE a IN (SELECT a FROM t1);\n      SELECT a,e FROM t1;\n    }\n  } {1 15 2 8}\n}\n\nintegrity_check update-12.1\n\n# Ticket 602.  Updates should occur in the same order as the records\n# were discovered in the WHERE clause.\n#\ndo_test update-13.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    INSERT INTO t2 SELECT a+2 FROM t2;\n    INSERT INTO t2 SELECT a+4 FROM t2;\n    INSERT INTO t2 SELECT a+8 FROM t2;\n    INSERT INTO t2 SELECT a+16 FROM t2;\n    INSERT INTO t2 SELECT a+32 FROM t2;\n    INSERT INTO t2 SELECT a+64 FROM t2;\n    INSERT INTO t2 SELECT a+128 FROM t2;\n    INSERT INTO t2 SELECT a+256 FROM t2;\n    INSERT INTO t2 SELECT a+512 FROM t2;\n    INSERT INTO t2 SELECT a+1024 FROM t2;\n    COMMIT;\n    SELECT count(*) FROM t2;\n  }\n} {2048}\ndo_test update-13.2 {\n  execsql {\n    SELECT count(*) FROM t2 WHERE a=rowid;\n  }\n} {2048}\ndo_test update-13.3 {\n  execsql {\n    UPDATE t2 SET rowid=rowid-1;\n    SELECT count(*) FROM t2 WHERE a=rowid+1;\n  }\n} {2048}\ndo_test update-13.3 {\n  execsql {\n    UPDATE t2 SET rowid=rowid+10000;\n    UPDATE t2 SET rowid=rowid-9999;\n    SELECT count(*) FROM t2 WHERE a=rowid;\n  }\n} {2048}\ndo_test update-13.4 {\n  execsql {\n    BEGIN;\n    INSERT INTO t2 SELECT a+2048 FROM t2;\n    INSERT INTO t2 SELECT a+4096 FROM t2;\n    INSERT INTO t2 SELECT a+8192 FROM t2;\n    SELECT count(*) FROM t2 WHERE a=rowid;\n    COMMIT;\n  }\n} 16384\ndo_test update-13.5 {\n  execsql {\n    UPDATE t2 SET rowid=rowid-1;\n    SELECT count(*) FROM t2 WHERE a=rowid+1;\n  }\n} 16384\n\nintegrity_check update-13.6\n\nifcapable {trigger} {\n# Test for proper detection of malformed WHEN clauses on UPDATE triggers.\n#\ndo_test update-14.1 {\n  execsql {\n    CREATE TABLE t3(a,b,c);\n    CREATE TRIGGER t3r1 BEFORE UPDATE on t3 WHEN nosuchcol BEGIN\n      SELECT 'illegal WHEN clause';\n    END;\n  }\n} {}\ndo_test update-14.2 {\n  catchsql {\n    UPDATE t3 SET a=1;\n  }\n} {1 {no such column: nosuchcol}}\ndo_test update-14.3 {\n  execsql {\n    CREATE TABLE t4(a,b,c);\n    CREATE TRIGGER t4r1 AFTER UPDATE on t4 WHEN nosuchcol BEGIN\n      SELECT 'illegal WHEN clause';\n    END;\n  }\n} {}\ndo_test update-14.4 {\n  catchsql {\n    UPDATE t4 SET a=1;\n  }\n} {1 {no such column: nosuchcol}}\n\n} ;# ifcapable {trigger}\n\n# Ticket [https://www.sqlite.org/src/tktview/43107840f1c02] on 2014-10-29\n# An assertion fault on UPDATE\n#\ndo_execsql_test update-15.1 {\n  CREATE TABLE t15(a INTEGER PRIMARY KEY, b);\n  INSERT INTO t15(a,b) VALUES(10,'abc'),(20,'def'),(30,'ghi');\n  ALTER TABLE t15 ADD COLUMN c;\n  CREATE INDEX t15c ON t15(c);\n  INSERT INTO t15(a,b)\n   VALUES(5,'zyx'),(15,'wvu'),(25,'tsr'),(35,'qpo');\n  UPDATE t15 SET c=printf(\"y%d\",a) WHERE c IS NULL;\n  SELECT a,b,c,'|' FROM t15 ORDER BY a;\n} {5 zyx y5 | 10 abc y10 | 15 wvu y15 | 20 def y20 | 25 tsr y25 | 30 ghi y30 | 35 qpo y35 |}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/update2.test",
    "content": "# 2017 January 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix update2\n\ndb func repeat [list string repeat]\n\n#-------------------------------------------------------------------------\n# 1.1.* A one-pass UPDATE that does balance() operations on the IPK index\n#       that it is scanning.\n#\n# 1.2.* Same again, but with a WITHOUT ROWID table.\n#\nset nrow [expr 10]\ndo_execsql_test 1.1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE t2(a INTEGER PRIMARY KEY, b);\n  WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<$nrow )\n  INSERT INTO t1(b) SELECT char((i % 26) + 65) FROM s;\n  INSERT INTO t2 SELECT * FROM t1;\n}\n\ndo_execsql_test 1.1.1 {\n  UPDATE t1 SET b = repeat(b, 100)\n}\n\ndo_execsql_test 1.1.2 {\n  SELECT * FROM t1;\n} [db eval { SELECT a, repeat(b, 100) FROM t2 }]\n\ndo_execsql_test 1.2.0 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;\n  WITH s(i) AS ( SELECT 0 UNION ALL SELECT i+1 FROM s WHERE i<$nrow )\n  INSERT INTO t1(a, b) SELECT i+1, char((i % 26) + 65) FROM s;\n}\n\n#explain_i { UPDATE t1 SET b = repeat(b, 100) }\ndo_execsql_test 1.2.1 {\n  UPDATE t1 SET b = repeat(b, 100)\n}\n\ndo_execsql_test 1.2.2 {\n  SELECT * FROM t1;\n} [db eval { SELECT a, repeat(b, 100) FROM t2 }]\n\n\n#-------------------------------------------------------------------------\n# A one-pass UPDATE that does balance() operations on the IPK index\n# that it is scanning.\n#\ndo_execsql_test 2.1 {\n  CREATE TABLE t3(a PRIMARY KEY, b, c);\n  CREATE INDEX t3i ON t3(b);\n} {}\ndo_execsql_test 2.2 { UPDATE t3 SET c=1 WHERE b=?      } {}\ndo_execsql_test 2.3 { UPDATE t3 SET c=1 WHERE rowid=?  } {}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE t4(a PRIMARY KEY, b, c) WITHOUT ROWID;\n  CREATE INDEX t4c ON t4(c);\n  INSERT INTO t4 VALUES(1, 2, 3);\n  INSERT INTO t4 VALUES(2, 3, 4);\n}\n\ndo_execsql_test 3.1 {\n  UPDATE t4 SET c=c+2 WHERE c>2;\n  SELECT a, c FROM t4 ORDER BY a;\n} {1 5 2 6}\n\n#-------------------------------------------------------------------------\n#\nforeach {tn sql} {\n  1 { \n    CREATE TABLE b1(a INTEGER PRIMARY KEY, b, c);\n    CREATE TABLE c1(a INTEGER PRIMARY KEY, b, c, d)\n  }\n  2 { \n    CREATE TABLE b1(a INT PRIMARY KEY, b, c) WITHOUT ROWID;\n    CREATE TABLE c1(a INT PRIMARY KEY, b, c, d) WITHOUT ROWID;\n  }\n} {\n  execsql { DROP TABLE IF EXISTS b1; DROP TABLE IF EXISTS c1; }\n  execsql $sql\n\n  do_execsql_test 4.$tn.0 {\n    CREATE UNIQUE INDEX b1c ON b1(c);\n    INSERT INTO b1 VALUES(1, 'a', 1);\n    INSERT INTO b1 VALUES(2, 'b', 15);\n    INSERT INTO b1 VALUES(3, 'c', 3);\n    INSERT INTO b1 VALUES(4, 'd', 4);\n    INSERT INTO b1 VALUES(5, 'e', 5);\n    INSERT INTO b1 VALUES(6, 'f', 6);\n    INSERT INTO b1 VALUES(7, 'g', 7);\n  }\n\n  do_execsql_test 4.$tn.1 {\n    UPDATE OR REPLACE b1 SET c=c+10 WHERE a BETWEEN 4 AND 7;\n    SELECT * FROM b1 ORDER BY a;\n  } {\n    1 a 1\n    3 c 3\n    4 d 14\n    5 e 15\n    6 f 16\n    7 g 17\n  }\n\n  do_execsql_test 4.$tn.2 {\n    CREATE INDEX c1d ON c1(d, b);\n    CREATE UNIQUE INDEX c1c ON c1(c, b);\n\n    INSERT INTO c1 VALUES(1, 'a', 1,  1);\n    INSERT INTO c1 VALUES(2, 'a', 15, 2);\n    INSERT INTO c1 VALUES(3, 'a', 3,  3);\n    INSERT INTO c1 VALUES(4, 'a', 4,  4);\n    INSERT INTO c1 VALUES(5, 'a', 5,  5);\n    INSERT INTO c1 VALUES(6, 'a', 6,  6);\n    INSERT INTO c1 VALUES(7, 'a', 7,  7);\n  }\n\n  do_execsql_test 4.$tn.3 {\n    UPDATE OR REPLACE c1 SET c=c+10 WHERE d BETWEEN 4 AND 7;\n    SELECT * FROM c1 ORDER BY a;\n  } {\n    1 a 1 1\n    3 a 3 3\n    4 a 14 4\n    5 a 15 5\n    6 a 16 6\n    7 a 17 7\n  }\n\n  do_execsql_test 4.$tn.4 { PRAGMA integrity_check } ok\n\n  do_execsql_test 4.$tn.5 {\n    DROP INDEX c1d;\n    DROP INDEX c1c;\n    DELETE FROM c1;\n\n    INSERT INTO c1 VALUES(1, 'a', 1,  1);\n    INSERT INTO c1 VALUES(2, 'a', 15, 2);\n    INSERT INTO c1 VALUES(3, 'a', 3,  3);\n    INSERT INTO c1 VALUES(4, 'a', 4,  4);\n    INSERT INTO c1 VALUES(5, 'a', 5,  5);\n    INSERT INTO c1 VALUES(6, 'a', 6,  6);\n    INSERT INTO c1 VALUES(7, 'a', 7,  7);\n\n    CREATE INDEX c1d ON c1(d);\n    CREATE UNIQUE INDEX c1c ON c1(c);\n  }\n\n  do_execsql_test 4.$tn.6 {\n    UPDATE OR REPLACE c1 SET c=c+10 WHERE d BETWEEN 4 AND 7;\n    SELECT * FROM c1 ORDER BY a;\n  } {\n    1 a 1 1\n    3 a 3 3\n    4 a 14 4\n    5 a 15 5\n    6 a 16 6\n    7 a 17 7\n  }\n}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 5.0 {\n  CREATE TABLE x1(a INTEGER PRIMARY KEY, b, c);\n  CREATE INDEX x1c ON x1(b, c);\n  INSERT INTO x1 VALUES(1, 'a', 1);\n  INSERT INTO x1 VALUES(2, 'a', 2);\n  INSERT INTO x1 VALUES(3, 'a', 3);\n}\n\ndo_execsql_test 5.1.1 {\n  UPDATE x1 SET c=c+1 WHERE b='a';\n}\n\ndo_execsql_test 5.1.2 {\n  SELECT * FROM x1;\n} {1 a 2 2 a 3 3 a 4}\n\ndo_test 5.2 {\n  catch { array unset A }\n  db eval { EXPLAIN UPDATE x1 SET c=c+1 WHERE b='a' } { incr A($opcode) }\n  set A(NotExists)\n} {1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/uri.test",
    "content": "# 2011 April 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test organization:\n#\n#   1.*: That file names are correctly extracted from URIs.\n#   2.*: That URI options (query parameters) are correctly extracted from URIs.\n#   3.*: That specifying an unknown VFS causes an error.\n#   4.*: Tests for specifying other options (other than \"vfs\").\n#   5.*: Test using a different VFS with an attached database.\n#   6.*: Test that authorities other than \"\" and localhost cause errors.\n#   7.*: Test that a read-write db can be attached to a read-only connection.\n#\n\nset testprefix uri\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\n#-------------------------------------------------------------------------\n# Test that file names are correctly extracted from URIs.\n#\nforeach {tn uri file} {\n  1      test.db                              test.db\n  2      file:test.db                         test.db\n  3      file://PWD/test.db                   test.db\n  4      file:PWD/test.db                     test.db\n  5      file:test.db?mork=1                  test.db\n  6      file:test.db?mork=1&tonglor=2        test.db\n  7      file:test.db?mork=1#boris            test.db\n  8      file:test.db#boris                   test.db\n  9      test.db#boris                        test.db#boris\n  10     file:test%2Edb                       test.db\n  11     file                                 file\n  12     http:test.db                         http:test.db\n  13     file:test.db%00extra                 test.db\n  14     file:testdb%00.db%00extra            testdb\n\n  15     test.db?mork=1#boris                 test.db?mork=1#boris\n  16     file://localhostPWD/test.db%3Fhello  test.db?hello\n} {\n  \n\n  ifcapable !curdir { if {$tn==3} break }\n\n  ifcapable uri_00_error {\n    if {[string first %00 $uri]>=0} continue\n  }\n\n  if {$tcl_platform(platform)==\"windows\"} {\n    #\n    # NOTE: Due to limits on legal characters for file names imposed by\n    #       Windows, we must skip the final two tests here (i.e. the\n    #       question mark is illegal in a file name on Windows).\n    #\n    if {$tn>14} break\n\n    #\n    # NOTE: When running on Tcl 8.6 (or higher?) on Windows, a colon within\n    #       the file name no longer tries to access an alternate data stream\n    #       (ADS) named \"test.db\" for the \"http\" file, causing some spurious\n    #       failures of this test.\n    #\n    if {$tn==12 && $::tcl_version>=8.6} continue\n\n    #\n    # NOTE: On Windows, we need to account for the fact that the current\n    #       directory does not start with a forward slash.\n    #\n    set uri  [string map [list PWD/ /[test_pwd /]] $uri]\n  } else {\n    set uri  [string map [list PWD/ [test_pwd /]] $uri]\n  }\n\n  if {[file isdir $file]} {error \"$file is a directory\"}\n  forcedelete $file\n  do_test 1.$tn.1 { file exists $file } 0\n  set DB [sqlite3_open $uri]\n  do_test 1.$tn.2 { file exists $file } 1\n  sqlite3_close $DB\n  forcedelete $file\n\n  do_test 1.$tn.3 { file exists $file } 0\n  sqlite3 db xxx.db\n  catchsql { ATTACH $uri AS aux }\n  do_test 1.$tn.4 { file exists $file } 1\n  db close\n}\n\n#-------------------------------------------------------------------------\n# Test that URI query parameters are passed through to the VFS layer\n# correctly.\n#\ntestvfs tvfs2\ntestvfs tvfs -default 1\ntvfs filter xOpen\ntvfs script open_method\nproc open_method {method file arglist} {\n  set ::arglist $arglist\n}\nforeach {tn uri kvlist} {\n  1      file:test.db?hello=world                     {hello world}\n  2      file:test.db?hello&world                     {hello {} world {}}\n  3      file:test.db?hello=1&world=2&vfs=tvfs        {hello 1 world 2 vfs tvfs}\n  4      file:test.db?hello=1&world=2&vfs=tvfs2        {}\n  5      file:test.db?%68%65%6C%6C%6F=%77%6F%72%6C%64 {hello world}\n  6      file:testdb%00.db?hello%00extra=world%00ex   {hello world}\n  7      file:testdb%00.db?hello%00=world%00          {hello world}\n  8      file:testdb%00.db?=world&xyz=abc             {xyz abc}\n  9      file:test.db?%00hello=world&xyz=abc          {xyz abc}\n  10     file:test.db?hello=%00world&xyz=             {hello {} xyz {}}\n  11     file:test.db?=#ravada                        {}\n  12     file:test.db?&&&&&&&&hello=world&&&&&&&      {hello world}\n\n  13     test.db?&&&&&&&&hello=world&&&&&&&           {}\n  14     http:test.db?hello&world                     {}\n} {\n\n  ifcapable uri_00_error {\n    if {[string first %00 $uri]>=0} continue\n  }\n\n  if {$tcl_platform(platform) == \"windows\" && $tn>12} {\n    continue\n  }\n\n  set ::arglist \"\"\n  set DB [sqlite3_open $uri]\n  do_test 2.$tn.1 { set ::arglist } $kvlist\n  sqlite3_close $DB\n\n  sqlite3 db xxx.db\n  set ::arglist \"\"\n  execsql { ATTACH $uri AS aux }\n  do_test 2.$tn.2 { set ::arglist } $kvlist\n  db close\n}\ntvfs delete\ntvfs2 delete\n\n#-------------------------------------------------------------------------\n# Test that specifying a non-existent VFS raises an error.\n#\ndo_test 3.1 {\n  list [catch { sqlite3 db \"file:test.db?vfs=nosuchvfs\" } msg] $msg\n} {1 {no such vfs: nosuchvfs}}\n\n#-------------------------------------------------------------------------\n# Test some of the other options (other than \"vfs\").\n#\nforeach {tn mode create_ok write_ok readonly_ok} {\n  1    ro    0   0   1\n  2    rw    0   1   0\n  3    rwc   1   1   0\n} {\n  catch { db close }\n  forcedelete test.db\n\n  set A(1) {0 {}}\n  set A(0) {1 {unable to open database file}}\n  do_test 4.1.$tn.1 {\n    list [catch {sqlite3 db \"file:test.db?mode=$mode\"} msg] $msg\n  } $A($create_ok)\n\n  catch { db close }\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval { CREATE TABLE t1(a, b) }\n  db close\n\n  set A(1) {0 {}}\n  set A(0) {1 {attempt to write a readonly database}}\n  do_test 4.1.$tn.2 {\n    sqlite3 db \"file:test.db?mode=$mode\"\n    catchsql { INSERT INTO t1 VALUES(1, 2) }\n  } $A($write_ok)\n\n  set A(1) {0 {}}\n  set A(0) [list 1 \"access mode not allowed: $mode\"]\n  do_test 4.1.$tn.3 {\n    list [catch {sqlite3 db \"file:test.db?mode=$mode\" -readonly 1} msg] $msg\n  } $A($readonly_ok)\n}\n\nset orig [sqlite3_enable_shared_cache]\nforeach {tn options sc_default is_shared} {\n  1    \"\"                1   1\n  2    \"cache=private\"   1   0\n  3    \"cache=shared\"    1   1\n  4    \"\"                0   0\n  5    \"cache=private\"   0   0\n  6    \"cache=shared\"    0   1\n} {\n  catch { db close }\n  forcedelete test.db\n\n  sqlite3_enable_shared_cache 1\n  sqlite3 db2 test.db\n  db2 eval {CREATE TABLE t1(a, b)}\n\n  sqlite3_enable_shared_cache $sc_default\n  sqlite3 db \"file:test.db?$options\"\n  db eval {SELECT * FROM t1}\n\n  set A(1) {1 {database table is locked: t1}}\n  set A(0) {0 {}}\n  do_test 4.2.$tn {\n    db2 eval {BEGIN; INSERT INTO t1 VALUES(1, 2);}\n    catchsql { SELECT * FROM t1 }\n  } $A($is_shared)\n\n  db2 close\n}\n\ndo_test 4.3.1 {\n  list [catch {sqlite3 db \"file:test.db?mode=rc\"} msg] $msg\n} {1 {no such access mode: rc}}\ndo_test 4.3.2 {\n  list [catch {sqlite3 db \"file:test.db?cache=public\"} msg] $msg\n} {1 {no such cache mode: public}}\n\n#-------------------------------------------------------------------------\n# Test that things work if an ATTACHed database uses a different VFS than\n# the main database. The important point is that for all operations \n# involving the ATTACHed database, the correct versions of the following\n# VFS are used for all operations involving the attached database.\n#\n#     xOpen\n#     xDelete\n#     xAccess\n#     xFullPathname\n#\n\n# This block of code creates two VFS - \"tvfs1\" and \"tvfs2\". Each time one\n# of the above methods is called using \"tvfs1\", global variable ::T1(X) is\n# set, where X is the file-name the method is called on. Calls to the above\n# methods using \"tvfs2\" set entries in the global T2 array.\n#\nifcapable wal {\n  testvfs tvfs1 \n  tvfs1 filter {xOpen xDelete xAccess xFullPathname}\n  tvfs1 script tvfs1_callback\n  proc tvfs1_callback {method filename args} { \n    set ::T1([file tail $filename]) 1 \n    return SQLITE_OK\n  }\n  testvfs tvfs2 \n  tvfs2 filter {xOpen xDelete xAccess xFullPathname}\n  tvfs2 script tvfs2_callback\n  proc tvfs2_callback {method filename args} { \n    set ::T2([file tail $filename]) 1 \n    return SQLITE_OK\n  }\n  \n  catch {db close}\n  eval forcedelete [glob test.db*]\n  do_test 5.1.1 {\n    sqlite3 db file:test.db1?vfs=tvfs1\n    execsql {\n      ATTACH 'file:test.db2?vfs=tvfs2' AS aux;\n      PRAGMA main.journal_mode = PERSIST;\n      PRAGMA aux.journal_mode = PERSIST;\n      CREATE TABLE t1(a, b);\n      CREATE TABLE aux.t2(a, b);\n      PRAGMA main.journal_mode = WAL;\n      PRAGMA aux.journal_mode = WAL;\n      INSERT INTO t1 VALUES('x', 'y');\n      INSERT INTO t2 VALUES('x', 'y');\n    }\n    lsort [array names ::T1]\n  } {test.db1 test.db1-journal test.db1-wal}\n  \n  do_test 5.1.2 {\n    lsort [array names ::T2]\n  } {test.db2 test.db2-journal test.db2-wal}\n  db close\n  \n  tvfs1 delete\n  tvfs2 delete\n}\n\n#-------------------------------------------------------------------------\n# Check that only \"\" and \"localhost\" are acceptable as authorities.\n#\ncatch {db close}\nforeach {tn uri res} {\n  1     \"file://localhost/PWD/test.db\"   {not an error}\n  2     \"file:///PWD/test.db\"            {not an error}\n  3     \"file:/PWD/test.db\"              {not an error}\n  4     \"file://l%6Fcalhost/PWD/test.db\" {invalid uri authority: l%6Fcalhost}\n  5     \"file://lbcalhost/PWD/test.db\"   {invalid uri authority: lbcalhost}\n  6     \"file://x/PWD/test.db\"           {invalid uri authority: x}\n} {\n\n  if {$tcl_platform(platform)==\"windows\"} {\n    set uri  [string map [list PWD [string range [get_pwd] 3 end]] $uri]\n  } else {\n    set uri  [string map [list PWD [string range [get_pwd] 1 end]] $uri]\n  }\n\n  do_test 6.$tn {\n    set DB [sqlite3_open $uri]\n    sqlite3_errmsg $DB\n  } $res\n  catch { sqlite3_close $DB }\n}\n\nforcedelete test.db test.db2\ndo_test 7.1 {\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    ATTACH 'test.db2' AS aux;\n    CREATE TABLE aux.t2(a, b);\n    INSERT INTO t1 VALUES('a', 'b');\n  }\n  db close\n} {}\ndo_test 7.2 {\n  sqlite3 db file:test.db?mode=ro\n  execsql { ATTACH 'file:test.db2?mode=rw' AS aux }\n} {}\ndo_execsql_test  7.3 { \n  INSERT INTO t2 VALUES('c', 'd') \n} {}\ndo_catchsql_test 7.4 { \n  INSERT INTO t1 VALUES(3, 4) \n} {1 {attempt to write a readonly database}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/uri2.test",
    "content": "# 2016 October 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Tests for SQLITE_ENABLE_URI_00_ERROR builds.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !uri_00_error {\n  finish_test\n  return\n}\n\nset testprefix uri2\ndb close\nsqlite3_shutdown\nsqlite3_config_uri 1\n\nforeach {tn uri} {\n  1 file:test.db%00trailing\n  2 file:test.db?%00trailing=1\n  3 file:test.db?trailing=1%00\n  4 file:test.db?trailing=1&abc%00def\n  5 file:test.db?trailing=1&abc%00def\n} {\n  do_test 1.$tn.1 {\n    set rc [catch { sqlite3 db $uri } msg]\n    list $rc $msg\n  } {1 {unexpected %00 in uri}}\n\n  do_test 1.$tn.2 {\n    set DB2 [sqlite3_open $uri]\n    sqlite3_errcode $DB2\n  } {SQLITE_ERROR}\n\n  catch { sqlite3_close $DB2 }\n\n  do_test 1.$tn.2 {\n    sqlite3 db \"\"\n    catchsql { ATTACH $uri AS aux }\n  } {1 {unexpected %00 in uri}}\n\n  do_test 1.$tn.3 {\n    sqlite3_errcode db\n  } {SQLITE_ERROR}\n\n  catch { db close }\n}\n\nreset_db\ndo_test 2.0 {\n  expr {[lsearch [execsql {PRAGMA compile_options}] ENABLE_URI_00_ERROR] >= 0}\n} 1\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/userauth01.test",
    "content": "# 2014-09-10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests of the SQLITE_USER_AUTHENTICATION extension.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix userauth01\n\nifcapable !userauth {\n  finish_test\n  return\n}\n\n# Create a no-authentication-required database\n#\ndo_execsql_test userauth01-1.0 {\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1),(2.5),('three'),(x'4444'),(NULL);\n  SELECT quote(x) FROM t1 ORDER BY x;\n  SELECT name FROM sqlite_master;\n} {NULL 1 2.5 'three' X'4444' t1}\n\n# Calling sqlite3_user_authenticate() on a no-authentication-required\n# database connection is a harmless no-op.  \n#\ndo_test userauth01-1.1 {\n  sqlite3_user_authenticate db alice pw-4-alice\n  execsql {\n    SELECT quote(x) FROM t1 ORDER BY x;\n    SELECT name FROM sqlite_master;\n  }\n} {NULL 1 2.5 'three' X'4444' t1}\n\n# If sqlite3_user_add(D,U,P,N,A) is called on a no-authentication-required\n# database and A is false, then the call fails with an SQLITE_AUTH error.\n#\ndo_test userauth01-1.2 {\n  sqlite3_user_add db bob pw-4-bob 0\n} {SQLITE_AUTH}\ndo_test userauth01-1.3 {\n  execsql {\n    SELECT quote(x) FROM t1 ORDER BY x;\n    SELECT name FROM sqlite_master;\n  }\n} {NULL 1 2.5 'three' X'4444' t1}\n\n# When called on a no-authentication-required\n# database and when A is true, the sqlite3_user_add(D,U,P,N,A) routine\n# converts the database into an authentication-required database and\n# logs the database connection D in using user U with password P,N.\n#  \ndo_test userauth01-1.4 {\n  sqlite3_user_add db alice pw-4-alice 1\n} {SQLITE_OK}\ndo_test userauth01-1.5 {\n  execsql {\n    SELECT quote(x) FROM t1 ORDER BY x;\n    SELECT uname, isadmin FROM sqlite_user ORDER BY uname;\n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n} {NULL 1 2.5 'three' X'4444' alice 1 sqlite_user t1}\n\n# The sqlite3_user_add() interface can be used (by an admin user only)\n# to create a new user.\n#\ndo_test userauth01-1.6 {\n  sqlite3_user_add db bob pw-4-bob 0\n  sqlite3_user_add db cindy pw-4-cindy 0\n  sqlite3_user_add db david pw-4-david 0\n  execsql {\n    SELECT uname, isadmin FROM sqlite_user ORDER BY uname;\n  }\n} {alice 1 bob 0 cindy 0 david 0}\n\n# The sqlite_user table is inaccessible (unreadable and unwriteable) to\n# non-admin users and is read-only for admin users.  However, if the same\n#\ndo_test userauth01-1.7 {\n  sqlite3 db2 test.db\n  sqlite3_user_authenticate db2 cindy pw-4-cindy\n  db2 eval {\n    SELECT quote(x) FROM t1 ORDER BY x;\n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n} {NULL 1 2.5 'three' X'4444' sqlite_user t1}\ndo_test userauth01-1.8 {\n  catchsql {\n    SELECT uname, isadmin FROM sqlite_user ORDER BY uname;\n  } db2\n} {1 {no such table: sqlite_user}}\n\n# Any user can change their own password.  \n#\ndo_test userauth01-1.9 {\n  sqlite3_user_change db2 cindy xyzzy-cindy 0\n} {SQLITE_OK}\ndo_test userauth01-1.10 {\n  sqlite3_user_authenticate db2 cindy pw-4-cindy\n} {SQLITE_AUTH}\ndo_test userauth01-1.11 {\n  sqlite3_user_authenticate db2 cindy xyzzy-cindy\n} {SQLITE_OK}\ndo_test userauth01-1.12 {\n  sqlite3_user_change db alice xyzzy-alice 1\n} {SQLITE_OK}\ndo_test userauth01-1.13 {\n  sqlite3_user_authenticate db alice pw-4-alice\n} {SQLITE_AUTH}\ndo_test userauth01-1.14 {\n  sqlite3_user_authenticate db alice xyzzy-alice\n} {SQLITE_OK}\n\n# No user may change their own admin privilege setting.\n#\ndo_test userauth01-1.15 {\n  sqlite3_user_change db alice xyzzy-alice 0\n} {SQLITE_AUTH}\ndo_test userauth01-1.16 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 0}\ndo_test userauth01-1.17 {\n  sqlite3_user_change db2 cindy xyzzy-cindy 1\n} {SQLITE_AUTH}\ndo_test userauth01-1.18 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 0}\n\n# The sqlite3_user_change() interface can be used to change a users\n# login credentials or admin privilege.\n#\ndo_test userauth01-1.20 {\n  sqlite3_user_change db david xyzzy-david 1\n} {SQLITE_OK}\ndo_test userauth01-1.21 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 1}\ndo_test userauth01-1.22 {\n  sqlite3_user_authenticate db2 david xyzzy-david\n} {SQLITE_OK}\ndo_test userauth01-1.23 {\n  db2 eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 1}\ndo_test userauth01-1.24 {\n  sqlite3_user_change db david pw-4-david 0\n} {SQLITE_OK}\ndo_test userauth01-1.25 {\n  sqlite3_user_authenticate db2 david pw-4-david\n} {SQLITE_OK}\ndo_test userauth01-1.26 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 0}\ndo_test userauth01-1.27 {\n  catchsql {SELECT uname, isadmin FROM sqlite_user ORDER BY uname} db2\n} {1 {no such table: sqlite_user}}\n\n# Only an admin user can change another users login\n# credentials or admin privilege setting.\n#\ndo_test userauth01-1.30 {\n  sqlite3_user_change db2 bob xyzzy-bob 1\n} {SQLITE_AUTH}\ndo_test userauth01-1.31 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 bob 0 cindy 0 david 0}\n\n# The sqlite3_user_delete() interface can be used (by an admin user only)\n# to delete a user.\n#\ndo_test userauth01-1.40 {\n  sqlite3_user_delete db bob\n} {SQLITE_OK}\ndo_test userauth01-1.41 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 cindy 0 david 0}\ndo_test userauth01-1.42 {\n  sqlite3_user_delete db2 cindy\n} {SQLITE_AUTH}\ndo_test userauth01-1.43 {\n  sqlite3_user_delete db2 alice\n} {SQLITE_AUTH}\ndo_test userauth01-1.44 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 cindy 0 david 0}\n\n# The currently logged-in user cannot be deleted\n#\ndo_test userauth01-1.50 {\n  sqlite3_user_delete db alice\n} {SQLITE_AUTH}\ndo_test userauth01-1.51 {\n  db eval {SELECT uname, isadmin FROM sqlite_user ORDER BY uname}\n} {alice 1 cindy 0 david 0}\n\n# When ATTACH-ing new database files to a connection, each newly attached\n# database that is an authentication-required database is checked using\n# the same username and password as supplied to the main database.  If that\n# check fails, then the ATTACH command fails with an SQLITE_AUTH error.\n#\ndo_test userauth01-1.60 {\n  forcedelete test3.db\n  sqlite3 db3 test3.db\n  sqlite3_user_add db3 alice xyzzy-alice 1\n} {SQLITE_OK}\ndo_test userauth01-1.61 {\n  db3 eval {\n    CREATE TABLE t3(a,b,c); INSERT INTO t3 VALUES(1,2,3);\n    SELECT * FROM t3;\n  }\n} {1 2 3}\ndo_test userauth01-1.62 {\n  db eval {\n    ATTACH 'test3.db' AS aux;\n    SELECT * FROM t1, t3 ORDER BY x LIMIT 1;\n    DETACH aux;\n  }\n} {{} 1 2 3}\ndo_test userauth01-1.63 {\n  sqlite3_user_change db alice pw-4-alice 1\n  sqlite3_user_authenticate db alice pw-4-alice\n  catchsql {\n    ATTACH 'test3.db' AS aux;\n  }\n} {1 {unable to open database: test3.db}}\ndo_test userauth01-1.64 {\n  sqlite3_extended_errcode db\n} {SQLITE_AUTH}\ndo_test userauth01-1.65 {\n  db eval {PRAGMA database_list}\n} {~/test3.db/}\n\n# The sqlite3_set_authorizer() callback is modified to take a 7th parameter\n# which is the username of the currently logged in user, or NULL for a\n# no-authentication-required database.\n#\nproc auth {args} {\n  lappend ::authargs $args\n  return SQLITE_OK\n}\ndo_test authuser01-2.1 {\n  unset -nocomplain ::authargs\n  db auth auth\n  db eval {SELECT x FROM t1}\n  set ::authargs\n} {/SQLITE_SELECT {} {} {} {} alice/}  \n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/utf16align.test",
    "content": "# 2006 February 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file contains code to verify that the SQLITE_UTF16_ALIGNED\n# flag passed into the sqlite3_create_collation() function insures\n# that all strings passed to that function are aligned on an even\n# byte boundary.\n#\n# $Id: utf16align.test,v 1.2 2008/11/07 03:29:34 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Skip this entire test if we do not support UTF16\n#\nifcapable !utf16 {\n  finish_test\n  return\n}\n\n# Create a database with a UTF16 encoding.  Put in lots of string\n# data of varying lengths.\n#\ndo_test utf16align-1.0 {\n  set unaligned_string_counter 0\n  add_alignment_test_collations [sqlite3_connection_pointer db]\n  execsql {\n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(\n      id INTEGER PRIMARY KEY,\n      spacer TEXT,\n      a TEXT COLLATE utf16_aligned,\n      b TEXT COLLATE utf16_unaligned\n    );\n    INSERT INTO t1(a) VALUES(\"abc\");\n    INSERT INTO t1(a) VALUES(\"defghi\");\n    INSERT INTO t1(a) VALUES(\"jklmnopqrstuv\");\n    INSERT INTO t1(a) VALUES(\"wxyz0123456789-\");\n    UPDATE t1 SET b=a||'-'||a;\n    INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;\n    INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;\n    INSERT INTO t1(a,b) SELECT a||b, b||a FROM t1;\n    INSERT INTO t1(a,b) VALUES('one','two');\n    INSERT INTO t1(a,b) SELECT a, b FROM t1;\n    UPDATE t1 SET spacer = CASE WHEN rowid&1 THEN 'x' ELSE 'xx' END;\n    SELECT count(*) FROM t1;\n  }\n} 66\ndo_test utf16align-1.1 {\n  set unaligned_string_counter\n} 0\n\n# Creating an index that uses the unaligned collation.  We should see\n# some unaligned strings passed to the collating function.\n#\ndo_test utf16align-1.2 {\n  execsql {\n    CREATE INDEX t1i1 ON t1(spacer, b);\n  }\n  # puts $unaligned_string_counter\n  expr {$unaligned_string_counter>0}\n} 1\n\n# Create another index that uses the aligned collation.  This time\n# there should be no unaligned accesses\n#\ndo_test utf16align-1.3 {\n  set unaligned_string_counter 0\n  execsql {\n    CREATE INDEX t1i2 ON t1(spacer, a);\n  }\n  expr {$unaligned_string_counter>0}\n} 0\nintegrity_check utf16align-1.4\n\n# ticket #3482\n#\ndb close\nsqlite3 db :memory:\ndo_test utf16align-2.1 {\n  db eval {\n    PRAGMA encoding=UTF16be;\n    SELECT hex(ltrim(x'6efcda'));\n  }\n} {6EFC}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuum.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the VACUUM statement.\n#\n# $Id: vacuum.test,v 1.43 2009/01/31 14:54:07 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the VACUUM statement is disabled in the current build, skip all\n# the tests in this file.\n#\nifcapable {!vacuum} {\n  omit_test vacuum.test {Compiled with SQLITE_OMIT_VACUUM}\n  finish_test\n  return\n}\nif $AUTOVACUUM {\n  omit_test vacuum.test {Auto-vacuum is enabled}\n  finish_test\n  return\n}\n\nset fcnt 1\ndo_test vacuum-1.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);\n    INSERT INTO t1 VALUES(NULL,randstr(10,100),randstr(5,50));\n    INSERT INTO t1 VALUES(123456,randstr(10,100),randstr(5,50));\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;\n    CREATE INDEX i1 ON t1(b,c);\n    CREATE UNIQUE INDEX i2 ON t1(c,a);\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    COMMIT;\n    DROP TABLE t2;\n  }\n  set ::size1 [file size test.db]\n  set ::cksum [cksum]\n  expr {$::cksum!=\"\"}\n} {1}\n\n# Create bogus application-defined functions for functions used \n# internally by VACUUM, to ensure that VACUUM falls back\n# to the built-in functions.\n#\nproc failing_app_func {args} {error \"bad function\"}\ndo_test vacuum-1.1b {\n  db func substr failing_app_func\n  db func like failing_app_func\n  db func quote failing_app_func\n  catchsql {SELECT substr(name,1,3) FROM sqlite_master}\n} {1 {bad function}}\n\ndo_test vacuum-1.2 {\n  execsql {\n    VACUUM;\n  }\n  cksum\n} $cksum\nifcapable vacuum {\n  do_test vacuum-1.3 {\n    expr {[file size test.db]<$::size1}\n  } {1}\n}\ndo_test vacuum-1.4 {\n  set sql_script {\n    BEGIN;\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    CREATE TABLE t3 AS SELECT * FROM t1;\n    CREATE VIEW v1 AS SELECT b, c FROM t3;\n    CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN SELECT 1; END;\n    COMMIT;\n    DROP TABLE t2;\n  }\n  # If the library was compiled to omit view support, comment out the\n  # create view in the script $sql_script before executing it. Similarly,\n  # if triggers are not supported, comment out the trigger definition.\n  ifcapable !view {\n    regsub {CREATE VIEW} $sql_script {-- CREATE VIEW} sql_script\n  }\n  ifcapable !trigger {\n    regsub {CREATE TRIGGER} $sql_script {-- CREATE TRIGGER} sql_script\n  }\n  execsql $sql_script\n  set ::size1 [file size test.db]\n  set ::cksum [cksum]\n  expr {$::cksum!=\"\"}\n} {1}\ndo_test vacuum-1.5 {\n  execsql {\n    VACUUM;\n  }\n  cksum\n} $cksum\n\nifcapable vacuum {\n  do_test vacuum-1.6 {\n    expr {[file size test.db]<$::size1}\n  } {1}\n}\nifcapable vacuum {\n  do_test vacuum-2.1.1 {\n    catchsql {\n      BEGIN;\n      VACUUM;\n    }\n  } {1 {cannot VACUUM from within a transaction}}\n  do_test vacuum-2.1.2 {\n    sqlite3_get_autocommit db\n  } {0}\n  do_test vacuum-2.1.3 {\n    db eval {COMMIT}\n  } {}\n}\ndo_test vacuum-2.2 {\n  sqlite3 db2 test.db\n  execsql {\n    BEGIN;\n    CREATE TABLE t4 AS SELECT * FROM t1;\n    CREATE TABLE t5 AS SELECT * FROM t1;\n    COMMIT;\n    DROP TABLE t4;\n    DROP TABLE t5;\n  } db2\n  set ::cksum [cksum db2]\n  catchsql {\n    VACUUM\n  }\n} {0 {}}\ndo_test vacuum-2.3 {\n  cksum\n} $cksum\ndo_test vacuum-2.4 {\n  catch {db2 eval {SELECT count(*) FROM sqlite_master}}\n  cksum db2\n} $cksum\n\n# Make sure the schema cookie is incremented by vacuum.\n#\ndo_test vacuum-2.5 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t6 AS SELECT * FROM t1;\n    CREATE TABLE t7 AS SELECT * FROM t1;\n    COMMIT;\n  }\n  sqlite3 db3 test.db\n  execsql {\n    -- The \"SELECT * FROM sqlite_master\" statement ensures that this test\n    -- works when shared-cache is enabled. If shared-cache is enabled, then\n    -- db3 shares a cache with db2 (but not db - it was opened as \n    -- \"./test.db\").\n    SELECT * FROM sqlite_master;\n    SELECT * FROM t7 LIMIT 1\n  } db3\n  execsql {\n    VACUUM;\n  }\n  execsql {\n    INSERT INTO t7 VALUES(1234567890,'hello','world');\n  } db3\n  execsql {\n    SELECT * FROM t7 WHERE a=1234567890\n  }\n} {1234567890 hello world}\nintegrity_check vacuum-2.6\ndo_test vacuum-2.7 {\n  execsql {\n    SELECT * FROM t7 WHERE a=1234567890\n  } db3\n} {1234567890 hello world}\ndo_test vacuum-2.8 {\n  execsql {\n    INSERT INTO t7 SELECT * FROM t6;\n    SELECT count(*) FROM t7;\n  }\n} 513\nintegrity_check vacuum-2.9\ndo_test vacuum-2.10 {\n  execsql {\n    DELETE FROM t7;\n    SELECT count(*) FROM t7;\n  } db3\n} 0\nintegrity_check vacuum-2.11\ndb3 close\n \n\n# Ticket #427.  Make sure VACUUM works when the EMPTY_RESULT_CALLBACKS\n# pragma is turned on.\n#\ndo_test vacuum-3.1 {\n  db close\n  db2 close\n  delete_file test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA empty_result_callbacks=on;\n    VACUUM;\n  }\n} {}\n\n# Ticket #464.  Make sure VACUUM works with the sqlite3_prepare() API.\n#\ndo_test vacuum-4.1 {\n  db close\n  sqlite3 db test.db; set DB [sqlite3_connection_pointer db]\n  set VM [sqlite3_prepare $DB {VACUUM} -1 TAIL]\n  sqlite3_step $VM\n} {SQLITE_DONE}\ndo_test vacuum-4.2 {\n  sqlite3_finalize $VM\n} SQLITE_OK\n\n# Ticket #515.  VACUUM after deleting and recreating the table that\n# a view refers to. Omit this test if the library is not view-enabled.\n#\nifcapable view {\ndo_test vacuum-5.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  catchsql {\n    CREATE TABLE Test (TestID int primary key);\n    INSERT INTO Test VALUES (NULL);\n    CREATE VIEW viewTest AS SELECT * FROM Test;\n\n    BEGIN;\n    CREATE TABLE tempTest (TestID int primary key, Test2 int NULL);\n    INSERT INTO tempTest SELECT TestID, 1 FROM Test;\n    DROP TABLE Test;\n    CREATE TABLE Test(TestID int primary key, Test2 int NULL);\n    INSERT INTO Test SELECT * FROM tempTest;\n    DROP TABLE tempTest;\n    COMMIT;\n    VACUUM;\n  }\n} {0 {}}\ndo_test vacuum-5.2 {\n  catchsql {\n    VACUUM;\n  }\n} {0 {}}\n} ;# ifcapable view\n\n# Ensure vacuum works with complicated tables names.\ndo_test vacuum-6.1 {\n  execsql {\n    CREATE TABLE \"abc abc\"(a, b, c);\n    INSERT INTO \"abc abc\" VALUES(1, 2, 3);\n    VACUUM;\n  }\n} {}\ndo_test vacuum-6.2 {\n  execsql {\n    select * from \"abc abc\";\n  }\n} {1 2 3}\n\n# Also ensure that blobs survive a vacuum.\nifcapable {bloblit} {\n  do_test vacuum-6.3 {\n    execsql {\n      DELETE FROM \"abc abc\";\n      INSERT INTO \"abc abc\" VALUES(X'00112233', NULL, NULL);\n      VACUUM;\n    }\n  } {}\n  do_test vacuum-6.4 {\n    execsql {\n      select count(*) from \"abc abc\" WHERE a = X'00112233';\n    }\n  } {1}\n}\n\n# Check what happens when an in-memory database is vacuumed. The\n# [delete_file] command covers us in case the library was compiled\n# without in-memory database support.\n#\nforcedelete :memory:\ndo_test vacuum-7.0 {\n  sqlite3 db2 :memory:\n  execsql {\n    CREATE TABLE t1(t);\n    VACUUM;\n  } db2\n} {}\ndo_test vacuum-7.1 {\n  execsql {\n    CREATE TABLE t2(t);\n    CREATE TABLE t3(t);\n    DROP TABLE t2;\n    PRAGMA freelist_count;\n  }\n} {1}\ndo_test vacuum-7.2 {\n  execsql {\n    VACUUM;\n    pragma integrity_check;\n  } db2\n} {ok}\ndo_test vacuum-7.3 {\n  execsql { PRAGMA freelist_count; } db2\n} {0}\nifcapable autovacuum {\n  do_test vacuum-7.4 {\n    execsql { PRAGMA auto_vacuum } db2\n  } {0}\n  do_test vacuum-7.5 {\n    execsql { PRAGMA auto_vacuum = 1} db2\n    execsql { PRAGMA auto_vacuum } db2\n  } {0}\n  do_test vacuum-7.6 {\n    execsql { PRAGMA auto_vacuum = 1} db2\n    execsql { VACUUM } db2\n    execsql { PRAGMA auto_vacuum } db2\n  } {1}\n}\ndb2 close\n\n# Ticket #873.  VACUUM a database that has ' in its name.\n#\ndo_test vacuum-8.1 {\n  forcedelete a'z.db\n  forcedelete a'z.db-journal\n  sqlite3 db2 a'z.db\n  execsql {\n    CREATE TABLE t1(t);\n    VACUUM;\n  } db2\n} {}\ndb2 close\n\n# Ticket #1095:  Vacuum a table that uses AUTOINCREMENT\n#\nifcapable {autoinc} {\n  do_test vacuum-9.1 {\n    execsql {\n      DROP TABLE 'abc abc';\n      CREATE TABLE autoinc(a INTEGER PRIMARY KEY AUTOINCREMENT, b);\n      INSERT INTO autoinc(b) VALUES('hi');\n      INSERT INTO autoinc(b) VALUES('there');\n      DELETE FROM autoinc;\n    }\n    set ::cksum [cksum]\n    expr {$::cksum!=\"\"}\n  } {1}\n  do_test vacuum-9.2 {\n    execsql {\n      VACUUM;\n    }\n    cksum\n  } $::cksum\n  do_test vacuum-9.3 {\n    execsql {\n      INSERT INTO autoinc(b) VALUES('one');\n      INSERT INTO autoinc(b) VALUES('two');\n    }\n    set ::cksum [cksum]\n    expr {$::cksum!=\"\"}\n  } {1}\n  do_test vacuum-9.4 {\n    execsql {\n      VACUUM;\n    }\n    cksum\n  } $::cksum\n}\n\nforcedelete {a'z.db}\n\n# Test that \"PRAGMA count_changes\" does not interfere with VACUUM or cause\n# it to return any rows to the user.\n#\ndo_test vacuum-10.1 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t8(a, b);\n    INSERT INTO t8 VALUES('a', 'b');\n    INSERT INTO t8 VALUES('c', 'd');\n    PRAGMA count_changes = 1;\n  }\n} {}\ndo_test vacuum-10.2 { execsql VACUUM } {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuum2.test",
    "content": "# 2005 February 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the VACUUM statement.\n#\n# $Id: vacuum2.test,v 1.10 2009/02/18 20:31:18 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vacuum2\n\n# Do not use a codec for tests in this file, as the database file is\n# manipulated directly using tcl scripts (using the [hexio_write] command).\n#\ndo_not_use_codec\n\n# If the VACUUM statement is disabled in the current build, skip all\n# the tests in this file.\n#\nifcapable {!vacuum||!autoinc} {\n  finish_test\n  return\n}\nif $AUTOVACUUM {\n  finish_test\n  return\n}\n\n# Ticket #1121 - make sure vacuum works if all autoincrement tables\n# have been deleted.\n#\ndo_test vacuum2-1.1 {\n  execsql {\n    CREATE TABLE t1(x INTEGER PRIMARY KEY AUTOINCREMENT, y);\n    DROP TABLE t1;\n    VACUUM;\n  }\n} {}\n\n# Ticket #2518.  Make sure vacuum increments the change counter\n# in the database header.\n#\ndo_test vacuum2-2.1 {\n  execsql {\n    CREATE TABLE t1(x);\n    CREATE TABLE t2(y);\n    INSERT INTO t1 VALUES(1);\n  }\n  hexio_get_int [hexio_read test.db 24 4]\n} [expr {[hexio_get_int [hexio_read test.db 24 4]]+3}]\ndo_test vacuum2-2.1 {\n  execsql {\n    VACUUM\n  }\n  hexio_get_int [hexio_read test.db 24 4]\n} [expr {[hexio_get_int [hexio_read test.db 24 4]]+1}]\n\n############################################################################\n# Verify that we can use the auto_vacuum pragma to request a new\n# autovacuum setting, do a VACUUM, and the new setting takes effect.\n# Make sure this happens correctly even if there are multiple open\n# connections to the same database file.\n#\nsqlite3 db2 test.db\nset pageSize [db eval {pragma page_size}]\n\n# We are currently not autovacuuming so the database should be 3 pages\n# in size.  1 page for each of sqlite_master, t1, and t2.\n#\ndo_test vacuum2-3.1 {\n  execsql {\n    INSERT INTO t1 VALUES('hello');\n    INSERT INTO t2 VALUES('out there');\n  }\n  expr {[file size test.db]/$pageSize}\n} {3}\nset cksum [cksum]\ndo_test vacuum2-3.2 {\n  cksum db2\n} $cksum\n\n# Convert the database to an autovacuumed database.\nifcapable autovacuum {\n  do_test vacuum2-3.3 {\n    execsql {\n      PRAGMA auto_vacuum=FULL;\n      VACUUM;\n    }\n    expr {[file size test.db]/$pageSize}\n  } {4}\n}\ndo_test vacuum2-3.4 {\n  cksum db2\n} $cksum\ndo_test vacuum2-3.5 {\n  cksum\n} $cksum\ndo_test vacuum2-3.6 {\n  execsql {PRAGMA integrity_check} db2\n} {ok}\ndo_test vacuum2-3.7 {\n  execsql {PRAGMA integrity_check} db\n} {ok}\n\n# Convert the database back to a non-autovacuumed database.\ndo_test vacuum2-3.13 {\n  execsql {\n    PRAGMA auto_vacuum=NONE;\n    VACUUM;\n  }\n  expr {[file size test.db]/$pageSize}\n} {3}\ndo_test vacuum2-3.14 {\n  cksum db2\n} $cksum\ndo_test vacuum2-3.15 {\n  cksum\n} $cksum\ndo_test vacuum2-3.16 {\n  execsql {PRAGMA integrity_check} db2\n} {ok}\ndo_test vacuum2-3.17 {\n  execsql {PRAGMA integrity_check} db\n} {ok}\n\ndb2 close\n\nifcapable autovacuum {\n  do_test vacuum2-4.1 {\n    db close\n    forcedelete test.db\n    sqlite3 db test.db\n    execsql {\n      pragma auto_vacuum=1;\n      create table t(a, b);\n      insert into t values(1, 2);\n      insert into t values(1, 2);\n      pragma auto_vacuum=0;\n      vacuum;\n      pragma auto_vacuum;\n    }\n  } {0}\n  do_test vacuum2-4.2 {\n    execsql {\n      pragma auto_vacuum=1;\n      vacuum;\n      pragma auto_vacuum;\n    }\n  } {1}\n  do_test vacuum2-4.3 {\n    execsql {\n      pragma integrity_check\n    }\n  } {ok}\n  do_test vacuum2-4.4 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      pragma auto_vacuum;\n    }\n  } {1}\n  do_test vacuum2-4.5 {  # Ticket #3663\n    execsql {\n      pragma auto_vacuum=2;\n      vacuum;\n      pragma auto_vacuum;\n    }\n  } {2}\n  do_test vacuum2-4.6 {\n    execsql {\n      pragma integrity_check\n    }\n  } {ok}\n  do_test vacuum2-4.7 {\n    db close\n    sqlite3 db test.db\n    execsql {\n      pragma auto_vacuum;\n    }\n  } {2}\n}\n\n\n#-------------------------------------------------------------------------\n# The following block of tests verify the behaviour of the library when\n# a database is VACUUMed when there are one or more unfinalized SQL \n# statements reading the same database using the same db handle.\n#\ndb close\nforcedelete test.db\nsqlite3 db test.db\ndo_execsql_test vacuum2-5.1 {\n  CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n  INSERT INTO t1 VALUES(1, randomblob(500));\n  INSERT INTO t1 SELECT a+1, randomblob(500) FROM t1;      -- 2\n  INSERT INTO t1 SELECT a+2, randomblob(500) FROM t1;      -- 4 \n  INSERT INTO t1 SELECT a+4, randomblob(500) FROM t1;      -- 8 \n  INSERT INTO t1 SELECT a+8, randomblob(500) FROM t1;      -- 16 \n} {}\n\ndo_test vacuum2-5.2 {\n  list [catch {\n    db eval {SELECT a, b FROM t1} { if {$a == 8} { execsql VACUUM } }\n  } msg] $msg\n} {1 {cannot VACUUM - SQL statements in progress}}\n\ndo_test vacuum2-5.3 {\n  list [catch {\n    db eval {SELECT 1, 2, 3} { execsql VACUUM }\n  } msg] $msg\n} {1 {cannot VACUUM - SQL statements in progress}}\n\ndo_test vacuum2-5.4 {\n  set res \"\"\n  set res2 \"\"\n  db eval {SELECT a, b FROM t1 WHERE a<=10} {\n    if {$a==6} { set res [catchsql VACUUM] }\n    lappend res2 $a\n  }\n  lappend res2 $res\n} {1 2 3 4 5 6 7 8 9 10 {1 {cannot VACUUM - SQL statements in progress}}}\n\n#-------------------------------------------------------------------------\n# Check that if the definition of a collation sequence is changed and\n# VACUUM run, records are store in the (new) correct order following the\n# VACUUM. Even if the modified collation is attached to a PK of a WITHOUT\n# ROWID table.\n\nproc cmp {lhs rhs} { string compare $lhs $rhs }\ndb collate cmp cmp\ndo_execsql_test 6.0 {\n  CREATE TABLE t6(x PRIMARY KEY COLLATE cmp, y) WITHOUT ROWID;\n  CREATE INDEX t6y ON t6(y);\n  INSERT INTO t6 VALUES('i', 'one');\n  INSERT INTO t6 VALUES('ii', 'one');\n  INSERT INTO t6 VALUES('iii', 'one');\n}\nintegrity_check 6.1\nproc cmp {lhs rhs} { string compare $rhs $lhs }\ndo_execsql_test 6.2 VACUUM\nintegrity_check 6.3\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuum3.test",
    "content": "# 2007 March 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is changing the database page size using a \n# VACUUM statement.\n#\n# $Id: vacuum3.test,v 1.9 2008/08/26 21:07:27 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the VACUUM statement is disabled in the current build, skip all\n# the tests in this file.\n#\nifcapable !vacuum {\n  finish_test\n  return\n}\n\n\n#-------------------------------------------------------------------\n# Test cases vacuum3-1.* convert a simple 2-page database between a \n# few different page sizes.\n#\ndo_test vacuum3-1.1 {\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n  }\n} {}\ndo_test vacuum3-1.2 {\n  execsql { PRAGMA page_size }\n} {1024}\ndo_test vacuum3-1.3 {\n  file size test.db\n} {2048}\n\nset I 4\nforeach {request actual database} [list \\\n  2048 2048 4096                        \\\n  1024 1024 2048                        \\\n  1170 1024 2048                        \\\n  256  1024 2048                        \\\n  512  512  1024                        \\\n  4096 4096 8192                        \\\n  1024 1024 2048                        \\\n] {\n  do_test vacuum3-1.$I.1 {\n    execsql \" \n      PRAGMA page_size = $request;\n      VACUUM;\n    \"\n    execsql { PRAGMA page_size }\n  } $actual\n  do_test vacuum3-1.$I.2 {\n    file size test.db\n  } $database\n  do_test vacuum3-1.$I.3 {\n    execsql { SELECT * FROM t1 }\n  } {1 2 3}\n  integrity_check vacuum3-1.$I.4\n\n  incr I\n}\n\n#-------------------------------------------------------------------\n# Test cases vacuum3-2.* convert a simple 3-page database between a \n# few different page sizes.\n#\ndo_test vacuum3-2.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    VACUUM;\n    ALTER TABLE t1 ADD COLUMN d;\n    UPDATE t1 SET d = randomblob(1000);\n  }\n  file size test.db\n} {3072}\ndo_test vacuum3-2.2 {\n  execsql { PRAGMA page_size }\n} {1024}\ndo_test vacuum3-2.3 {\n  set blob [db one {select d from t1}]\n  string length $blob\n} {1000}\n\nset I 4\nforeach {request actual database} [list \\\n  2048 2048 4096                        \\\n  1024 1024 3072                        \\\n  1170 1024 3072                        \\\n  256  1024 3072                        \\\n  512  512  2048                        \\\n  4096 4096 8192                        \\\n  1024 1024 3072                        \\\n] {\n  do_test vacuum3-2.$I.1 {\n    execsql \" \n      PRAGMA page_size = $request;\n      VACUUM;\n    \"\n    execsql { PRAGMA page_size }\n  } $actual\n  do_test vacuum3-2.$I.2 {\n    file size test.db\n  } $database\n  do_test vacuum3-2.$I.3 {\n    execsql { SELECT * FROM t1 }\n  } [list 1 2 3 $blob]\n  integrity_check vacuum3-1.$I.4\n\n  incr I\n}\n\n#-------------------------------------------------------------------\n# Test cases vacuum3-3.* converts a database large enough to include\n# the locking page (in a test environment) between few different \n# page sizes.\n#\nproc signature {} {\n  return [db eval {SELECT count(*), md5sum(a), md5sum(b), md5sum(c) FROM abc}]\n}\ndo_test vacuum3-3.1 {\n  execsql \"\n    PRAGMA page_size = 1024;\n    BEGIN;\n    CREATE TABLE abc(a PRIMARY KEY, b, c);\n    INSERT INTO abc VALUES(randomblob(100), randomblob(200), randomblob(1000));\n    INSERT INTO abc \n        SELECT randomblob(1000), randomblob(200), randomblob(100)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(100), randomblob(200), randomblob(1000)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(100), randomblob(200), randomblob(1000)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(100), randomblob(200), randomblob(1000)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(100), randomblob(200), randomblob(1000)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(25), randomblob(45), randomblob(9456)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(100), randomblob(200), randomblob(1000)\n        FROM abc;\n    INSERT INTO abc \n        SELECT randomblob(25), randomblob(45), randomblob(9456)\n        FROM abc;\n    COMMIT;\n  \"\n} {}\ndo_test vacuum3-3.2 {\n  execsql { PRAGMA page_size }\n} {1024}\n\nset ::sig [signature]\n\nset I 3\nforeach {request actual} [list \\\n  2048 2048                    \\\n  1024 1024                    \\\n  1170 1024                    \\\n  256  1024                    \\\n  512  512                     \\\n  4096 4096                    \\\n  1024 1024                    \\\n] {\n  do_test vacuum3-3.$I.1 {\n    execsql \" \n      PRAGMA page_size = $request;\n      VACUUM;\n    \"\n    execsql { PRAGMA page_size }\n  } $actual\n  do_test vacuum3-3.$I.2 {\n    signature\n  } $::sig\n  integrity_check vacuum3-3.$I.3\n\n  incr I\n}\n\ndo_test vacuum3-4.1 {\n  db close\n  delete_file test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size=1024;\n    CREATE TABLE abc(a, b, c);\n    INSERT INTO abc VALUES(1, 2, 3);\n    INSERT INTO abc VALUES(4, 5, 6);\n  }\n  execsql { SELECT * FROM abc }\n} {1 2 3 4 5 6}\ndo_test vacuum3-4.2 {\n  sqlite3 db2 test.db\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4 5 6}\ndo_test vacuum3-4.3 {\n  execsql { \n    PRAGMA page_size = 2048;\n    VACUUM;\n  }\n  execsql { SELECT * FROM abc }\n} {1 2 3 4 5 6}\ndo_test vacuum3-4.4 {\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4 5 6}\ndo_test vacuum3-4.5 {\n  execsql {\n    PRAGMA page_size=16384;\n    VACUUM;\n  } db2\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4 5 6}\ndo_test vacuum3-4.6 {\n  execsql {\n    PRAGMA page_size=1024;\n    VACUUM;\n  }\n  execsql { SELECT * FROM abc } db2\n} {1 2 3 4 5 6}\n\n# Unable to change the page-size of an in-memory using vacuum.\ndb2 close\nsqlite3 db2 :memory:\ndo_test vacuum3-5.1 {\n  db2 eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1234);\n    PRAGMA page_size=4096;\n    VACUUM;\n    SELECT * FROM t1;\n  }\n} {1234}\ndo_test vacuum3-5.2 {\n  db2 eval {\n    PRAGMA page_size\n  }\n} {1024}\n\nset create_database_sql {\n  BEGIN; \n  CREATE TABLE t1(a, b, c); \n  INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50)); \n  INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1; \n  INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;\n  INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));\n  CREATE TABLE t2 AS SELECT * FROM t1;\n  CREATE TABLE t3 AS SELECT * FROM t1;\n  COMMIT;\n  DROP TABLE t2;\n}\n\ndo_ioerr_test vacuum3-ioerr-1 -cksum true -sqlprep \"\n  PRAGMA page_size = 1024;\n  $create_database_sql\n\" -sqlbody {\n  PRAGMA page_size = 4096;\n  VACUUM;\n} \ndo_ioerr_test vacuum3-ioerr-2 -cksum true -sqlprep \" \n  PRAGMA page_size = 2048;\n  $create_database_sql\n\" -sqlbody {\n  PRAGMA page_size = 512;\n  VACUUM;\n} \n\nifcapable autovacuum {\n  do_ioerr_test vacuum3-ioerr-3 -cksum true -sqlprep \"\n    PRAGMA auto_vacuum = 0;\n    $create_database_sql\n  \" -sqlbody {\n    PRAGMA auto_vacuum = 1;\n    VACUUM;\n  } \n  do_ioerr_test vacuum3-ioerr-4 -cksum true -sqlprep \"\n    PRAGMA auto_vacuum = 1;\n    $create_database_sql\n  \" -sqlbody {\n    PRAGMA auto_vacuum = 0;\n    VACUUM;\n  } \n}\n\nsource $testdir/malloc_common.tcl\nif {$MEMDEBUG} {\n  do_malloc_test vacuum3-malloc-1 -sqlprep { \n    PRAGMA page_size = 2048;\n    BEGIN; \n    CREATE TABLE t1(a, b, c); \n    INSERT INTO t1 VALUES(1, randstr(50,50), randstr(50,50)); \n    INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1; \n    INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;\n    INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));\n    CREATE TABLE t2 AS SELECT * FROM t1;\n    CREATE TABLE t3 AS SELECT * FROM t1;\n    COMMIT;\n    DROP TABLE t2;\n  } -sqlbody {\n    PRAGMA page_size = 512;\n    VACUUM;\n  } \n  do_malloc_test vacuum3-malloc-2 -sqlprep { \n    PRAGMA encoding=UTF16;\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    CREATE TABLE t2(x,y,z);\n    INSERT INTO t2 SELECT * FROM t1;\n  } -sqlbody {\n    VACUUM;\n  } \n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuum4.test",
    "content": "# 2010 February 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements a test of ticket [da1151f97df244a1]:  An\n# assertion fault while VACUUMing an auto_vacuumed database with\n# large schema.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# If the VACUUM statement is disabled in the current build, skip all\n# the tests in this file.\n#\nifcapable !vacuum {\n  finish_test\n  return\n}\n\ndo_test vacuum4-1.1 {\n  db eval {\n    PRAGMA auto_vacuum=FULL;\n    CREATE TABLE t1(\n      c000, c001, c002, c003, c004, c005, c006, c007, c008, c009,\n      c010, c011, c012, c013, c014, c015, c016, c017, c018, c019,\n      c020, c021, c022, c023, c024, c025, c026, c027, c028, c029,\n      c030, c031, c032, c033, c034, c035, c036, c037, c038, c039,\n      c040, c041, c042, c043, c044, c045, c046, c047, c048, c049,\n      c050, c051, c052, c053, c054, c055, c056, c057, c058, c059,\n      c060, c061, c062, c063, c064, c065, c066, c067, c068, c069,\n      c070, c071, c072, c073, c074, c075, c076, c077, c078, c079,\n      c080, c081, c082, c083, c084, c085, c086, c087, c088, c089,\n      c090, c091, c092, c093, c094, c095, c096, c097, c098, c099,\n      c100, c101, c102, c103, c104, c105, c106, c107, c108, c109,\n      c110, c111, c112, c113, c114, c115, c116, c117, c118, c119,\n      c120, c121, c122, c123, c124, c125, c126, c127, c128, c129,\n      c130, c131, c132, c133, c134, c135, c136, c137, c138, c139,\n      c140, c141, c142, c143, c144, c145, c146, c147, c148, c149\n    );\n    CREATE TABLE t2(\n      c000, c001, c002, c003, c004, c005, c006, c007, c008, c009,\n      c010, c011, c012, c013, c014, c015, c016, c017, c018, c019,\n      c020, c021, c022, c023, c024, c025, c026, c027, c028, c029,\n      c030, c031, c032, c033, c034, c035, c036, c037, c038, c039,\n      c040, c041, c042, c043, c044, c045, c046, c047, c048, c049,\n      c050, c051, c052, c053, c054, c055, c056, c057, c058, c059,\n      c060, c061, c062, c063, c064, c065, c066, c067, c068, c069,\n      c070, c071, c072, c073, c074, c075, c076, c077, c078, c079,\n      c080, c081, c082, c083, c084, c085, c086, c087, c088, c089,\n      c090, c091, c092, c093, c094, c095, c096, c097, c098, c099,\n      c100, c101, c102, c103, c104, c105, c106, c107, c108, c109,\n      c110, c111, c112, c113, c114, c115, c116, c117, c118, c119,\n      c120, c121, c122, c123, c124, c125, c126, c127, c128, c129,\n      c130, c131, c132, c133, c134, c135, c136, c137, c138, c139,\n      c140, c141, c142, c143, c144, c145, c146, c147, c148, c149\n    );\n    VACUUM;\n  }\n} {}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuum5.test",
    "content": "# 2016-08-19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements a test for VACUUM on attached databases.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vacuum5\n\n# If the VACUUM statement is disabled in the current build, skip all\n# the tests in this file.\n#\nifcapable !vacuum {\n  finish_test\n  return\n}\n\nforcedelete test2.db test3.db\ndo_execsql_test vacuum5-1.1 {\n  PRAGMA auto_vacuum = 0;\n  CREATE TABLE main.t1(a,b);\n  WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)\n    INSERT INTO t1(a,b) SELECT x, randomblob(1000) FROM c;\n  CREATE TEMP TABLE ttemp(x,y);\n  INSERT INTO ttemp SELECT * FROM t1;\n  ATTACH 'test2.db' AS x2;\n  ATTACH 'test3.db' AS x3;\n  CREATE TABLE x2.t2(c,d);\n  INSERT INTO t2 SELECT * FROM t1;\n  CREATE TABLE x3.t3(e,f);\n  INSERT INTO t3 SELECT * FROM t1;\n  DELETE FROM t1 WHERE (rowid%3)!=0;\n  DELETE FROM t2 WHERE (rowid%4)!=0;\n  DELETE FROM t3 WHERE (rowid%5)!=0;\n  PRAGMA main.integrity_check;\n  PRAGMA x2.integrity_check;\n  PRAGMA x3.integrity_check;\n} {ok ok ok}\nset size1 [file size test.db]\nset size2 [file size test2.db]\nset size3 [file size test3.db]\n\ndo_execsql_test vacuum5-1.2.1 {\n  VACUUM main;\n} {}\ndo_test vacuum5-1.2.2 {\n  expr {[file size test.db]<$size1}\n} {1}\ndo_test vacuum5-1.2.3 {\n  file size test2.db\n} $size2\ndo_test vacuum5-1.2.4 {\n  file size test3.db\n} $size3\nset size1 [file size test.db]\ndo_execsql_test vacuum-1.2.5 {\n  DELETE FROM t1;\n  PRAGMA main.integrity_check;\n} {ok}\n\ndo_execsql_test vacuum5-1.3.1 {\n  VACUUM x2;\n} {}\ndo_test vacuum5-1.3.2 {\n  file size test.db\n} $size1\ndo_test vacuum5-1.3.3 {\n  expr {[file size test2.db]<$size2}\n} 1\ndo_test vacuum5-1.3.4 {\n  file size test3.db\n} $size3\nset size2 [file size test2.db]\ndo_execsql_test vacuum-1.3.5 {\n  DELETE FROM t2;\n  PRAGMA x2.integrity_check;\n} {ok}\n\ndo_execsql_test vacuum5-1.4.1 {\n  VACUUM x3;\n} {}\ndo_test vacuum5-1.3.2 {\n  file size test.db\n} $size1\ndo_test vacuum5-1.3.3 {\n  file size test2.db\n} $size2\ndo_test vacuum5-1.3.4 {\n  expr {[file size test3.db]<$size3}\n} 1\n\n# VACUUM is a no-op on the TEMP table\n#\nset sizeTemp [db one {PRAGMA temp.page_count}]\ndo_execsql_test vacuum5-1.4.1 {\n  VACUUM temp;\n} {}\ndo_execsql_test vacuum5-1.4.2 {\n  PRAGMA temp.page_count;\n} $sizeTemp\n\ndo_catchsql_test vacuum5-2.0 {\n  VACUUM olaf;\n} {1 {unknown database olaf}}\n\n#-------------------------------------------------------------------------\n# Test that a temp file is opened as part of VACUUM.\n#\nif {$::TEMP_STORE<3 && [permutation]!=\"inmemory_journal\"} {\n  db close\n  testvfs tvfs \n  tvfs filter xOpen\n  tvfs script open_cb\n  forcedelete test.db\n\n  set ::openfiles [list]\n  proc open_cb {method args} {\n    lappend ::openfiles [file tail [lindex $args 0]]\n  }\n  sqlite3 db test.db -vfs tvfs\n\n  do_execsql_test 3.0 {\n    PRAGMA temp_store = file;\n    PRAGMA page_size = 1024;\n    PRAGMA cache_size = 50;\n    CREATE TABLE t1(i INTEGER PRIMARY KEY, j UNIQUE);\n    WITH s(i) AS (\n      VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000\n    )\n    INSERT INTO t1 SELECT NULL, randomblob(100) FROM s;\n  }\n\n  do_execsql_test 3.1 { VACUUM }\n\n  db close\n  tvfs delete\n  do_test 3.2 {\n    lrange $::openfiles 0 4\n  } {test.db test.db-journal test.db-journal {} test.db-journal}\n} \n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vacuummem.test",
    "content": "# 2005 February 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that the VACUUM statement correctly\n# frees any memory used for a temporary cache.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vacuummem\n\nif {[permutation]==\"memsubsys1\"} {\n  finish_test\n  return\n}\n\n# If ENABLE_MEMORY_MANAGEMENT is defined, when VACUUM is run the temp db\n# is able to borrow space from the main db (and it does, because the\n# temp db is configure with a very small cache). When the VACUUM is\n# finished and the temp db closed, all the page-cache memory currently \n# assigned to the temp db is freed. If ENABLE_MEMORY_MANAGEMENT is defined\n# this causes the total memory usage to drop much more than expected,\n# causing tests in this file to fail.\n#\nifcapable memorymanage {\n  finish_test\n  return\n}\n\n\nproc memory_used {} { \n  set stat [sqlite3_status SQLITE_STATUS_MEMORY_USED 1]  \n  lindex $stat 1\n}\n\ndo_execsql_test 1.0 {\n  PRAGMA cache_size = -2000;\n  CREATE TABLE t1(a, b, c);\n\n  WITH r(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<100000\n  )\n  INSERT INTO t1 SELECT randomblob(100),randomblob(100),randomblob(100) FROM r;\n\n  CREATE INDEX t1a ON t1(a);\n  CREATE INDEX t1b ON t1(b);\n  CREATE INDEX t1c ON t1(c);\n}\nset ans \"#/[memory_used]/\"\n\ndo_test 1.1 { memory_used } $ans\n\ndo_execsql_test 1.2 VACUUM\n\ndo_test 1.3 { memory_used } $ans\n\ndo_execsql_test 1.4 {\n  SELECT count(*) FROM t1 WHERE +a IS NOT NULL\n} {100000}\n\ndo_test 1.5 { memory_used } $ans\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/varint.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is variable-length integer encoding scheme.\n#\n# $Id: varint.test,v 1.1 2004/05/18 15:57:42 drh Exp $\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test reading and writing of varints.\n#\nset cnt 0\nforeach start {0 100 10000 1000000 0x10000000} {\n  foreach mult {1 0x10 0x100 0x1000 0x10000 0x100000 0x1000000 0x10000000} {\n    foreach incr {1 500 10000 50000000} {\n      incr cnt\n      do_test varint-1.$cnt {\n        btree_varint_test $start $mult 5000 $incr\n      } {}\n    }\n  }\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/veryquick.test",
    "content": "#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file runs all the tests run by quick.test except for those related\n# to malloc or IO error simulation. With these tests omitted, the overall\n# run time is reduced by about 75%.\n#\n# $Id: veryquick.test,v 1.9 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/permutations.test\n\nrun_test_suite veryquick\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/view.test",
    "content": "# 2002 February 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing VIEW statements.\n#\n# $Id: view.test,v 1.39 2008/12/14 14:45:21 danielk1977 Exp $\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Omit this entire file if the library is not configured with views enabled.\nifcapable !view {\n  finish_test\n  return\n}\n\ndo_test view-1.0 {\n  execsql {\n    CREATE TABLE t1(a,b,c);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(4,5,6);\n    INSERT INTO t1 VALUES(7,8,9);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6 7 8 9}\n\ndo_test view-1.1 {\n  execsql {\n    BEGIN;\n    CREATE VIEW IF NOT EXISTS v1 AS SELECT a,b FROM t1;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 2 4 5 7 8}\ndo_test view-1.2 {\n  catchsql {\n    ROLLBACK;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 {no such table: v1}}\ndo_test view-1.3 {\n  execsql {\n    CREATE VIEW v1 AS SELECT a,b FROM t1;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 2 4 5 7 8}\ndo_test view-1.3.1 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 2 4 5 7 8}\ndo_test view-1.4 {\n  catchsql {\n    DROP VIEW IF EXISTS v1;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 {no such table: v1}}\ndo_test view-1.5 {\n  execsql {\n    CREATE VIEW v1 AS SELECT a,b FROM t1;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 2 4 5 7 8}\ndo_test view-1.6 {\n  catchsql {\n    DROP TABLE t1;\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {1 {no such table: main.t1}}\ndo_test view-1.7 {\n  execsql {\n    CREATE TABLE t1(x,a,b,c);\n    INSERT INTO t1 VALUES(1,2,3,4);\n    INSERT INTO t1 VALUES(4,5,6,7);\n    INSERT INTO t1 VALUES(7,8,9,10);\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {2 3 5 6 8 9}\ndo_test view-1.8 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM v1 ORDER BY a;\n  }\n} {2 3 5 6 8 9}\n\ndo_execsql_test view-1.10 {\n  CREATE TABLE t9(x INTEGER);\n  CREATE VIEW v9a AS SELECT x FROM t9;\n  CREATE VIEW v9b AS SELECT * FROM t9;\n  CREATE VIEW v9c(x) AS SELECT x FROM t9;\n  CREATE VIEW v9d(x) AS SELECT * FROM t9;\n} {}\ndo_execsql_test view-1.11 {\n  PRAGMA table_info(v9a);\n} {0 x INTEGER 0 {} 0}\ndo_execsql_test view-1.12 {\n  PRAGMA table_info(v9b);\n} {0 x INTEGER 0 {} 0}\ndo_execsql_test view-1.13 {\n  PRAGMA table_info(v9c);\n} {0 x INTEGER 0 {} 0}\ndo_execsql_test view-1.14 {\n  PRAGMA table_info(v9d);\n} {0 x INTEGER 0 {} 0}\n\ndo_test view-2.1 {\n  execsql {\n    CREATE VIEW v2 AS SELECT * FROM t1 WHERE a>5\n  };  # No semicolon\n  execsql2 {\n    SELECT * FROM v2;\n  }\n} {x 7 a 8 b 9 c 10}\ndo_test view-2.2 {\n  catchsql {\n    INSERT INTO v2 VALUES(1,2,3,4);\n  }\n} {1 {cannot modify v2 because it is a view}}\ndo_test view-2.3 {\n  catchsql {\n    UPDATE v2 SET a=10 WHERE a=5;\n  }\n} {1 {cannot modify v2 because it is a view}}\ndo_test view-2.4 {\n  catchsql {\n    DELETE FROM v2;\n  }\n} {1 {cannot modify v2 because it is a view}}\ndo_test view-2.5 {\n  execsql {\n    INSERT INTO t1 VALUES(11,12,13,14);\n    SELECT * FROM v2 ORDER BY x;\n  }\n} {7 8 9 10 11 12 13 14}\ndo_test view-2.6 {\n  execsql {\n    SELECT x FROM v2 WHERE a>10\n  }\n} {11}\n\n# Test that column name of views are generated correctly.\n#\ndo_test view-3.1 {\n  execsql2 {\n    SELECT * FROM v1 LIMIT 1\n  }\n} {a 2 b 3}\ndo_test view-3.2 {\n  execsql2 {\n    SELECT * FROM v2 LIMIT 1\n  }\n} {x 7 a 8 b 9 c 10}\ndo_test view-3.3.1 {\n  execsql2 {\n    DROP VIEW v1;\n    CREATE VIEW v1 AS SELECT a AS 'xyz', b+c AS 'pqr', c-b FROM t1;\n    SELECT * FROM v1 LIMIT 1\n  }\n} {xyz 2 pqr 7 c-b 1}\ndo_test view-3.3.2 {\n  execsql2 {\n    CREATE VIEW v1b AS SELECT t1.a, b+c, t1.c FROM t1;\n    SELECT * FROM v1b LIMIT 1\n  }\n} {a 2 b+c 7 c 4}\ndo_test view-3.3.3 {\n  execsql2 {\n    CREATE VIEW v1c(x,y,z) AS SELECT a, b+c, c-b FROM t1;\n    SELECT * FROM v1c LIMIT 1;\n  }\n} {x 2 y 7 z 1}\ndo_catchsql_test view-3.3.4 {\n  CREATE VIEW v1err(x,y DESC,z) AS SELECT a, b+c, c-b FROM t1;\n} {1 {syntax error after column name \"y\"}}\ndo_catchsql_test view-3.3.5 {\n  DROP VIEW IF EXISTS v1err;\n  CREATE VIEW v1err(x,y) AS SELECT a, b+c, c-b FROM t1;\n  SELECT * FROM v1err;\n} {1 {expected 2 columns for 'v1err' but got 3}}\ndo_catchsql_test view-3.3.6 {\n  DROP VIEW IF EXISTS v1err;\n  CREATE VIEW v1err(w,x,y,z) AS SELECT a, b+c, c-b FROM t1;\n  SELECT * FROM v1err;\n} {1 {expected 4 columns for 'v1err' but got 3}}\n\nifcapable compound {\ndo_test  view-3.4 {\n  execsql2 {\n    CREATE VIEW v3 AS SELECT a FROM t1 UNION SELECT b FROM t1 ORDER BY b;\n    SELECT * FROM v3 LIMIT 4;\n  }\n} {a 2 a 3 a 5 a 6}\ndo_test view-3.5 {\n  execsql2 {\n    CREATE VIEW v4 AS \n      SELECT a, b FROM t1 \n      UNION\n      SELECT b AS 'x', a AS 'y' FROM t1\n      ORDER BY x, y;\n    SELECT b FROM v4 ORDER BY b LIMIT 4;\n  }\n} {b 2 b 3 b 5 b 6}\n} ;# ifcapable compound\n\n\ndo_test view-4.1 {\n  catchsql {\n    DROP VIEW t1;\n  }\n} {1 {use DROP TABLE to delete table t1}}\ndo_test view-4.2 {\n  execsql {\n    SELECT 1 FROM t1 LIMIT 1;\n  }\n} 1\ndo_test view-4.3 {\n  catchsql {\n    DROP TABLE v1;\n  }\n} {1 {use DROP VIEW to delete view v1}}\ndo_test view-4.4 {\n  execsql {\n     SELECT 1 FROM v1 LIMIT 1;\n  }\n} {1}\ndo_test view-4.5 {\n  catchsql {\n    CREATE INDEX i1v1 ON v1(xyz);\n  }\n} {1 {views may not be indexed}}\n\ndo_test view-5.1 {\n  execsql {\n    CREATE TABLE t2(y,a);\n    INSERT INTO t2 VALUES(22,2);\n    INSERT INTO t2 VALUES(33,3);\n    INSERT INTO t2 VALUES(44,4);\n    INSERT INTO t2 VALUES(55,5);\n    SELECT * FROM t2;\n  }\n} {22 2 33 3 44 4 55 5}\ndo_test view-5.2 {\n  execsql {\n    CREATE VIEW v5 AS\n      SELECT t1.x AS v, t2.y AS w FROM t1 JOIN t2 USING(a);\n    SELECT * FROM v5;\n  }\n} {1 22 4 55}\n\n# Verify that the view v5 gets flattened.  see sqliteFlattenSubquery().\n# This will only work if EXPLAIN is enabled.\n# Ticket #272\n#\nifcapable {explain} {\ndo_test view-5.3 {\n  lsearch [execsql {\n    EXPLAIN SELECT * FROM v5;\n  }] OpenEphemeral\n} {-1}\ndo_test view-5.4 {\n  execsql {\n    SELECT * FROM v5 AS a, t2 AS b WHERE a.w=b.y;\n  }\n} {1 22 22 2 4 55 55 5}\ndo_test view-5.5 {\n  lsearch [execsql {\n    EXPLAIN SELECT * FROM v5 AS a, t2 AS b WHERE a.w=b.y;\n  }] OpenEphemeral\n} {-1}\ndo_test view-5.6 {\n  execsql {\n    SELECT * FROM t2 AS b, v5 AS a WHERE a.w=b.y;\n  }\n} {22 2 1 22 55 5 4 55}\ndo_test view-5.7 {\n  lsearch [execsql {\n    EXPLAIN SELECT * FROM t2 AS b, v5 AS a WHERE a.w=b.y;\n  }] OpenEphemeral\n} {-1}\ndo_test view-5.8 {\n  execsql {\n    SELECT * FROM t1 AS a, v5 AS b, t2 AS c WHERE a.x=b.v AND b.w=c.y;\n  }\n} {1 2 3 4 1 22 22 2 4 5 6 7 4 55 55 5}\ndo_test view-5.9 {\n  lsearch [execsql {\n    EXPLAIN SELECT * FROM t1 AS a, v5 AS b, t2 AS c WHERE a.x=b.v AND b.w=c.y;\n  }] OpenEphemeral\n} {-1}\n} ;# endif explain\n\ndo_test view-6.1 {\n  execsql {\n    SELECT min(x), min(a), min(b), min(c), min(a+b+c) FROM v2;\n  }\n} {7 8 9 10 27}\ndo_test view-6.2 {\n  execsql {\n    SELECT max(x), max(a), max(b), max(c), max(a+b+c) FROM v2;\n  }\n} {11 12 13 14 39}\n\ndo_test view-7.1 {\n  execsql {\n    CREATE TABLE test1(id integer primary key, a);\n    CREATE TABLE test2(id integer, b);\n    INSERT INTO test1 VALUES(1,2);\n    INSERT INTO test2 VALUES(1,3);\n    CREATE VIEW test AS\n      SELECT test1.id, a, b\n      FROM test1 JOIN test2 ON test2.id=test1.id;\n    SELECT * FROM test;\n  }\n} {1 2 3}\ndo_test view-7.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM test;\n  }\n} {1 2 3}\ndo_test view-7.3 {\n  execsql {\n    DROP VIEW test;\n    CREATE VIEW test AS\n      SELECT test1.id, a, b\n      FROM test1 JOIN test2 USING(id);\n    SELECT * FROM test;\n  }\n} {1 2 3}\ndo_test view-7.4 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM test;\n  }\n} {1 2 3}\ndo_test view-7.5 {\n  execsql {\n    DROP VIEW test;\n    CREATE VIEW test AS\n      SELECT test1.id, a, b\n      FROM test1 NATURAL JOIN test2;\n    SELECT * FROM test;\n  }\n} {1 2 3}\ndo_test view-7.6 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM test;\n  }\n} {1 2 3}\n\ndo_test view-8.1 {\n  execsql {\n    CREATE VIEW v6 AS SELECT pqr, xyz FROM v1;\n    SELECT * FROM v6 ORDER BY xyz;\n  }\n} {7 2 13 5 19 8 27 12}\ndo_test view-8.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    SELECT * FROM v6 ORDER BY xyz;\n  }\n} {7 2 13 5 19 8 27 12}\ndo_test view-8.3 {\n  execsql {\n    CREATE VIEW v7(a) AS SELECT pqr+xyz FROM v6;\n    SELECT * FROM v7 ORDER BY a;\n  }\n} {9 18 27 39}\n\nifcapable subquery {\n  do_test view-8.4 {\n    execsql {\n      CREATE VIEW v8 AS SELECT max(cnt) AS mx FROM\n        (SELECT a%2 AS eo, count(*) AS cnt FROM t1 GROUP BY eo);\n      SELECT * FROM v8;\n    }\n  } 3\n  do_test view-8.5 {\n    execsql {\n      SELECT mx+10, mx*2 FROM v8;\n    }\n  } {13 6}\n  do_test view-8.6 {\n    execsql {\n      SELECT mx+10, pqr FROM v6, v8 WHERE xyz=2;\n    }\n  } {13 7}\n  do_test view-8.7 {\n    execsql {\n      SELECT mx+10, pqr FROM v6, v8 WHERE xyz>2;\n    }\n  } {13 13 13 19 13 27}\n} ;# ifcapable subquery\n\n# Tests for a bug found by Michiel de Wit involving ORDER BY in a VIEW.\n#\ndo_test view-9.1 {\n  execsql {\n    INSERT INTO t2 SELECT * FROM t2 WHERE a<5;\n    INSERT INTO t2 SELECT * FROM t2 WHERE a<4;\n    INSERT INTO t2 SELECT * FROM t2 WHERE a<3;\n    SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1;\n  }\n} {1 2 4 8}\ndo_test view-9.2 {\n  execsql {\n    SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1 LIMIT 3;\n  }\n} {1 2 4}\ndo_test view-9.3 {\n  execsql {\n    CREATE VIEW v9 AS \n       SELECT DISTINCT count(*) FROM t2 GROUP BY a ORDER BY 1 LIMIT 3;\n    SELECT * FROM v9;\n  }\n} {1 2 4}\ndo_test view-9.4 {\n  execsql {\n    SELECT * FROM v9 ORDER BY 1 DESC;\n  }\n} {4 2 1}\ndo_test view-9.5 {\n  execsql {\n    CREATE VIEW v10 AS \n       SELECT DISTINCT a, count(*) FROM t2 GROUP BY a ORDER BY 2 LIMIT 3;\n    SELECT * FROM v10;\n  }\n} {5 1 4 2 3 4}\ndo_test view-9.6 {\n  execsql {\n    SELECT * FROM v10 ORDER BY 1;\n  }\n} {3 4 4 2 5 1}\n\n# Tables with columns having peculiar quoted names used in views\n# Ticket #756.\n#\ndo_test view-10.1 {\n  execsql {\n    CREATE TABLE t3(\"9\" integer, [4] text);\n    INSERT INTO t3 VALUES(1,2);\n    CREATE VIEW v_t3_a AS SELECT a.[9] FROM t3 AS a;\n    CREATE VIEW v_t3_b AS SELECT \"4\" FROM t3;\n    SELECT * FROM v_t3_a;\n  }\n} {1}\ndo_test view-10.2 {\n  execsql {\n    SELECT * FROM v_t3_b;\n  }\n} {2}\n\ndo_test view-11.1 {\n  execsql {\n    CREATE TABLE t4(a COLLATE NOCASE);\n    INSERT INTO t4 VALUES('This');\n    INSERT INTO t4 VALUES('this');\n    INSERT INTO t4 VALUES('THIS');\n    SELECT * FROM t4 WHERE a = 'THIS';\n  }\n} {This this THIS}\nifcapable subquery {\n  do_test view-11.2 {\n    execsql {\n      SELECT * FROM (SELECT * FROM t4) WHERE a = 'THIS';\n    }\n  } {This this THIS}\n}\ndo_test view-11.3 {\n  execsql {\n    CREATE VIEW v11 AS SELECT * FROM t4;\n    SELECT * FROM v11 WHERE a = 'THIS';\n  }\n} {This this THIS}\n\n# Ticket #1270:  Do not allow parameters in view definitions.\n#\ndo_test view-12.1 {\n  catchsql {\n    CREATE VIEW v12 AS SELECT a FROM t1 WHERE b=?\n  }\n} {1 {parameters are not allowed in views}}\ndo_test view-12.2 {\n  catchsql {\n    CREATE VIEW v12(x) AS SELECT a FROM t1 WHERE b=?\n  }\n} {1 {parameters are not allowed in views}}\n\nifcapable attach {\n  do_test view-13.1 {\n    forcedelete test2.db\n    catchsql {\n      ATTACH 'test2.db' AS two;\n      CREATE TABLE two.t2(x,y);\n      CREATE VIEW v13 AS SELECT y FROM two.t2;\n    }\n  } {1 {view v13 cannot reference objects in database two}}\n}\n\n# Ticket #1658\n#\ndo_test view-14.1 {\n  catchsql {\n    CREATE TEMP VIEW t1 AS SELECT a,b FROM t1;\n    SELECT * FROM temp.t1;\n  }\n} {1 {view t1 is circularly defined}}\ndo_test view-14.2 {\n  catchsql {\n    DROP VIEW IF EXISTS temp.t1;\n    CREATE TEMP VIEW t1(a,b) AS SELECT a,b FROM t1;\n    SELECT * FROM temp.t1;\n  }\n} {1 {view t1 is circularly defined}}\n\n# Tickets #1688, #1709\n#\ndo_test view-15.1 {\n  execsql2 {\n    CREATE VIEW v15 AS SELECT a AS x, b AS y FROM t1;\n    SELECT * FROM v15 LIMIT 1;\n  }\n} {x 2 y 3}\ndo_test view-15.2 {\n  execsql2 {\n    SELECT x, y FROM v15 LIMIT 1\n  }\n} {x 2 y 3}\n\ndo_test view-16.1 {\n  catchsql {\n    CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1;\n  }\n} {0 {}}\ndo_test view-16.2 {\n  execsql {\n    SELECT sql FROM sqlite_master WHERE name='v1'\n  }\n} {{CREATE VIEW v1 AS SELECT a AS 'xyz', b+c AS 'pqr', c-b FROM t1}}\ndo_test view-16.3 {\n  catchsql {\n    DROP VIEW IF EXISTS nosuchview\n  }\n} {0 {}}\n\n# correct error message when attempting to drop a view that does not\n# exist.\n#\ndo_test view-17.1 {\n  catchsql {\n    DROP VIEW nosuchview\n  }\n} {1 {no such view: nosuchview}}\ndo_test view-17.2 {\n  catchsql {\n    DROP VIEW main.nosuchview\n  }\n} {1 {no such view: main.nosuchview}}\n\ndo_test view-18.1 {\n  execsql {\n    DROP VIEW t1;\n    DROP TABLE t1;\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n\n    CREATE VIEW vv1 AS SELECT * FROM t1;\n    CREATE VIEW vv2 AS SELECT * FROM vv1;\n    CREATE VIEW vv3 AS SELECT * FROM vv2;\n    CREATE VIEW vv4 AS SELECT * FROM vv3;\n    CREATE VIEW vv5 AS SELECT * FROM vv4;\n\n    SELECT * FROM vv5;\n  }\n} {1 2 3 4 5 6}\n\n# Ticket #3308\n# Make sure \"rowid\" columns in a view are named correctly.\n#\ndo_test view-19.1 {\n  execsql {\n    CREATE VIEW v3308a AS SELECT rowid, * FROM t1;\n  }\n  execsql2 {\n    SELECT * FROM v3308a\n  }\n} {rowid 1 a 1 b 2 c 3 rowid 2 a 4 b 5 c 6}\ndo_test view-19.2 {\n  execsql {\n    CREATE VIEW v3308b AS SELECT t1.rowid, t1.a, t1.b+t1.c FROM t1;\n  }\n  execsql2 {\n    SELECT * FROM v3308b\n  }\n} {rowid 1 a 1 t1.b+t1.c 5 rowid 2 a 4 t1.b+t1.c 11}\ndo_test view-19.3 {\n  execsql {\n    CREATE VIEW v3308c AS SELECT t1.oid, A, t1.b+t1.c AS x FROM t1;\n  }\n  execsql2 {\n    SELECT * FROM v3308c\n  }\n} {rowid 1 a 1 x 5 rowid 2 a 4 x 11}\n\n# Ticket #3539 had this crashing (see commit [5940]).\ndo_test view-20.1 {\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    DROP VIEW IF EXISTS v1;\n    CREATE TABLE t1(c1);\n    CREATE VIEW v1 AS SELECT c1 FROM (SELECT t1.c1 FROM t1);\n  }\n} {}\n\n# Ticket [d58ccbb3f1b]: Prevent Table.nRef overflow.\ndb close\nsqlite3 db :memory:\ndo_test view-21.1 {\n  catchsql {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(5);\n    CREATE VIEW v1 AS SELECT x*2 FROM t1;\n    CREATE VIEW v2 AS SELECT * FROM v1 UNION SELECT * FROM v1;\n    CREATE VIEW v4 AS SELECT * FROM v2 UNION SELECT * FROM v2;\n    CREATE VIEW v8 AS SELECT * FROM v4 UNION SELECT * FROM v4;\n    CREATE VIEW v16 AS SELECT * FROM v8 UNION SELECT * FROM v8;\n    CREATE VIEW v32 AS SELECT * FROM v16 UNION SELECT * FROM v16;\n    CREATE VIEW v64 AS SELECT * FROM v32 UNION SELECT * FROM v32;\n    CREATE VIEW v128 AS SELECT * FROM v64 UNION SELECT * FROM v64;\n    CREATE VIEW v256 AS SELECT * FROM v128 UNION SELECT * FROM v128;\n    CREATE VIEW v512 AS SELECT * FROM v256 UNION SELECT * FROM v256;\n    CREATE VIEW v1024 AS SELECT * FROM v512 UNION SELECT * FROM v512;\n    CREATE VIEW v2048 AS SELECT * FROM v1024 UNION SELECT * FROM v1024;\n    CREATE VIEW v4096 AS SELECT * FROM v2048 UNION SELECT * FROM v2048;\n    CREATE VIEW v8192 AS SELECT * FROM v4096 UNION SELECT * FROM v4096;\n    CREATE VIEW v16384 AS SELECT * FROM v8192 UNION SELECT * FROM v8192;\n    CREATE VIEW v32768 AS SELECT * FROM v16384 UNION SELECT * FROM v16384;\n    SELECT * FROM v32768 UNION SELECT * FROM v32768;\n  }\n} {1 {too many references to \"v1\": max 65535}}\nifcapable progress {\n  do_test view-21.2 {\n    db progress 1000 {expr 1}\n    catchsql {\n      SELECT * FROM v32768;\n    }\n  } {1 interrupted}\n}\n\ndb close\nsqlite3 db :memory:\ndo_execsql_test view-22.1 {\n  CREATE VIEW x1 AS SELECT 123 AS '', 234 AS '', 345 AS '';\n  SELECT * FROM x1;\n} {123 234 345}\ndo_test view-22.2 {\n  unset -nocomplain x\n  db eval {SELECT * FROM x1} x break\n  lsort [array names x]\n} {{} * :1 :2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab1.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is creating and dropping virtual tables.\n#\n# $Id: vtab1.test,v 1.57 2008/08/01 17:51:47 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtab1\n\nifcapable !vtab||!schema_pragmas {\n  finish_test\n  return\n}\n\n#----------------------------------------------------------------------\n# Organization of tests in this file:\n#\n# vtab1-1.*: Error conditions and other issues surrounding creation/connection\n#            of a virtual module.\n# vtab1-2.*: Test sqlite3_declare_vtab() and the xConnect/xDisconnect methods.\n# vtab1-3.*: Table scans and WHERE clauses.\n# vtab1-4.*: Table scans and ORDER BY clauses.\n# vtab1-5.*: Test queries that include joins. This brings the\n#            sqlite3_index_info.estimatedCost variable into play.\n# vtab1-6.*: Test UPDATE/INSERT/DELETE on vtables.\n# vtab1-7.*: Test sqlite3_last_insert_rowid().\n#\n# This file uses the \"echo\" module (see src/test8.c). Refer to comments\n# in that file for the special behaviour of the Tcl $echo_module variable.\n#\n# TODO: \n#   * How to test the sqlite3_index_constraint_usage.omit field?\n#   * vtab1-5.*\n#\n# vtab1-14.*: Test 'IN' constraints - i.e. \"SELECT * FROM t1 WHERE id IN(...)\"\n#\n# vtab1-18.*: Check that the LIKE optimization is not applied when the lhs\n#             is a virtual table column.\n#\n\n\n#----------------------------------------------------------------------\n# Test cases vtab1.1.*\n#\n\n# We cannot create a virtual table if the module has not been registered.\n#\ndo_test vtab1-1.1.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING echo;\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.1.2 {\n  catchsql {\n    CREATE VIRTUAL TABLE IF NOT EXISTS t1 USING echo;\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.2 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1\n  }\n} {}\n\n# Register the module\nregister_echo_module [sqlite3_connection_pointer db]\n\n# Once a module has been registered, virtual tables using that module\n# may be created. However if a module xCreate() fails to call\n# sqlite3_declare_vtab() an error will be raised and the table not created.\n#\n# The \"echo\" module does not invoke sqlite3_declare_vtab() if it is\n# passed zero arguments.\n#\ndo_test vtab1-1.3.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING echo;\n  }\n} {1 {vtable constructor did not declare schema: t1}}\ndo_test vtab1-1.3.2 {\n  catchsql {\n    CREATE VIRTUAL TABLE IF NOT EXISTS t1 USING echo;\n  }\n} {1 {vtable constructor did not declare schema: t1}}\ndo_test vtab1-1.4 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1\n  }\n} {}\n\n# The \"echo\" module xCreate method returns an error and does not create\n# the virtual table if it is passed an argument that does not correspond\n# to an existing real table in the same database.\n#\ndo_test vtab1-1.5.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE t1 USING echo(no_such_table);\n  }\n} {1 {vtable constructor failed: t1}}\ndo_test vtab1-1.5.2 {\n  catchsql {\n    CREATE VIRTUAL TABLE IF NOT EXISTS t1 USING echo(no_such_table);\n  }\n} {1 {vtable constructor failed: t1}}\ndo_test vtab1-1.6 {\n  execsql {\n    SELECT name FROM sqlite_master ORDER BY 1\n  }\n} {}\n\n# Ticket #2156.  Using the sqlite3_prepare_v2() API, make sure that\n# a CREATE VIRTUAL TABLE statement can be used multiple times.\n#\ndo_test vtab1-1.2152.1 {\n  set DB [sqlite3_connection_pointer db]\n  set sql {CREATE VIRTUAL TABLE t2152a USING echo(t2152b)}\n  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]\n  sqlite3_step $STMT\n} SQLITE_ERROR\ndo_test vtab-1.2152.2 {\n  sqlite3_reset $STMT\n  sqlite3_step $STMT\n} SQLITE_ERROR\ndo_test vtab-1.2152.3 {\n  sqlite3_reset $STMT\n  db eval {CREATE TABLE t2152b(x,y)}\n  sqlite3_step $STMT\n} SQLITE_DONE\ndo_test vtab-1.2152.4 {\n  sqlite3_finalize $STMT\n  db eval {DROP TABLE t2152a; DROP TABLE t2152b}\n} {}\n\n# Test to make sure nothing goes wrong and no memory is leaked if we \n# select an illegal table-name (i.e a reserved name or the name of a\n# table that already exists).\n#\ndo_test vtab1-1.7.1 {\n  catchsql {\n    CREATE VIRTUAL TABLE sqlite_master USING echo;\n  }\n} {1 {object name reserved for internal use: sqlite_master}}\ndo_test vtab1-1.7.2 {\n  catchsql {\n    CREATE VIRTUAL TABLE IF NOT EXISTS sqlite_master USING echo;\n  }\n} {1 {object name reserved for internal use: sqlite_master}}\ndo_test vtab1-1.8.1 {\n  catchsql {\n    CREATE TABLE treal(a, b, c);\n    CREATE VIRTUAL TABLE treal USING echo(treal);\n  }\n} {1 {table treal already exists}}\ndo_test vtab1-1.8.2 {\n  catchsql {\n    CREATE VIRTUAL TABLE IF NOT EXISTS treal USING echo(treal);\n  }\n} {0 {}}\ndo_test vtab1-1.9 {\n  execsql {\n    DROP TABLE treal;\n    SELECT name FROM sqlite_master ORDER BY 1\n  }\n} {}\n\ndo_test vtab1-1.10 {\n  execsql {\n    CREATE TABLE treal(a, b, c);\n    CREATE VIRTUAL TABLE techo USING echo(treal);\n  }\n  db close\n  sqlite3 db test.db\n  catchsql {\n    SELECT * FROM techo;\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.11 {\n  catchsql {\n    INSERT INTO techo VALUES(1, 2, 3);\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.12 {\n  catchsql {\n    UPDATE techo SET a = 10;\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.13 {\n  catchsql {\n    DELETE FROM techo;\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.14 {\n  catchsql {\n    PRAGMA table_info(techo)\n  }\n} {1 {no such module: echo}}\ndo_test vtab1-1.15 {\n  catchsql {\n    DROP TABLE techo;\n  }\n} {1 {no such module: echo}}\n\nregister_echo_module [sqlite3_connection_pointer db]\nregister_echo_module [sqlite3_connection_pointer db]\n\n# Test an error message returned from a v-table constructor.\n#\ndo_test vtab1-1.16 {\n  execsql {\n    DROP TABLE techo;\n    CREATE TABLE logmsg(log);\n  }\n  catchsql {\n    CREATE VIRTUAL TABLE techo USING echo(treal, logmsg);\n  }\n} {1 {table 'logmsg' already exists}}\n\ndo_test vtab1-1.17 {\n  execsql {\n    DROP TABLE treal;\n    DROP TABLE logmsg;\n    SELECT sql FROM sqlite_master;\n  }\n} {}\n\n#----------------------------------------------------------------------\n# Test cases vtab1.2.*\n#\n# At this point, the database is completely empty. The echo module\n# has already been registered.\n\n# If a single argument is passed to the echo module during table\n# creation, it is assumed to be the name of a table in the same\n# database. The echo module attempts to set the schema of the\n# new virtual table to be the same as the existing database table.\n#\ndo_test vtab1-2.1 {\n  execsql {\n    CREATE TABLE template(a, b, c);\n  }\n  execsql { PRAGMA table_info(template); }\n} [list         \\\n  0 a {} 0 {} 0 \\\n  1 b {} 0 {} 0 \\\n  2 c {} 0 {} 0 \\\n]\ndo_test vtab1-2.2 {\n  execsql {\n    CREATE VIRTUAL TABLE t1 USING echo(template);\n  }\n  execsql { PRAGMA table_info(t1); }\n} [list         \\\n  0 a {} 0 {} 0 \\\n  1 b {} 0 {} 0 \\\n  2 c {} 0 {} 0 \\\n]\n\n# Test that the database can be unloaded. This should invoke the xDisconnect()\n# callback for the successfully create virtual table (t1).\n#\ndo_test vtab1-2.3 {\n  set echo_module [list]\n  db close\n  set echo_module\n} [list xDisconnect]\n\n# Re-open the database. This should not cause any virtual methods to \n# be called. The invocation of xConnect() is delayed until the virtual\n# table schema is first required by the compiler.\n#\ndo_test vtab1-2.4 {\n  set echo_module [list]\n  sqlite3 db test.db\n  db cache size 0\n  set echo_module\n} {}\n\n# Try to query the virtual table schema. This should fail, as the\n# echo module has not been registered with this database connection.\n#\ndo_test vtab1.2.6 {\n  catchsql { PRAGMA table_info(t1); }\n} {1 {no such module: echo}}\n\n# Register the module\nregister_echo_module [sqlite3_connection_pointer db]\n\n# Try to query the virtual table schema again. This time it should\n# invoke the xConnect method and succeed.\n#\ndo_test vtab1.2.7 {\n  execsql { PRAGMA table_info(t1); }\n} [list         \\\n  0 a {} 0 {} 0 \\\n  1 b {} 0 {} 0 \\\n  2 c {} 0 {} 0 \\\n]\ndo_test vtab1.2.8 {\n  set echo_module\n} {xConnect echo main t1 template}\n\n# Drop table t1. This should cause the xDestroy (but not xDisconnect) method \n# to be invoked.\ndo_test vtab1-2.5 {\n  set echo_module \"\"\n  execsql {\n    DROP TABLE t1;\n  }\n  set echo_module\n} {xDestroy}\n\ndo_test vtab1-2.6 {\n  execsql { \n    PRAGMA table_info(t1); \n  }\n} {}\ndo_test vtab1-2.7 {\n  execsql {\n    SELECT sql FROM sqlite_master;\n  }\n} [list {CREATE TABLE template(a, b, c)}]\n# Clean up other test artifacts:\ndo_test vtab1-2.8 {\n  execsql { \n    DROP TABLE template;\n    SELECT sql FROM sqlite_master;\n  }\n} [list]\n\n#----------------------------------------------------------------------\n# Test case vtab1-3 test table scans and the echo module's \n# xBestIndex/xFilter handling of WHERE conditions.\n\ndo_test vtab1-3.1 {\n  set echo_module \"\"\n  execsql {\n    CREATE TABLE treal(a INTEGER, b INTEGER, c); \n    CREATE INDEX treal_idx ON treal(b);\n    CREATE VIRTUAL TABLE t1 USING echo(treal);\n  }\n  set echo_module\n} [list xCreate echo main t1 treal   \\\n        xSync   echo(treal)  \\\n        xCommit echo(treal)  \\\n]\n\n# Test that a SELECT on t1 doesn't crash. No rows are returned\n# because the underlying real table is currently empty.\n#\ndo_test vtab1-3.2 {\n  execsql {\n    SELECT a, b, c FROM t1;\n  }\n} {}\n\n# Put some data into the table treal. Then try a few simple SELECT \n# statements on t1.\n#\ndo_test vtab1-3.3 {\n  execsql {\n    INSERT INTO treal VALUES(1, 2, 3);\n    INSERT INTO treal VALUES(4, 5, 6);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6}\ndo_test vtab1-3.4 {\n  execsql {\n    SELECT a FROM t1;\n  }\n} {1 4}\ndo_test vtab1-3.5 {\n  execsql {\n    SELECT rowid FROM t1;\n  }\n} {1 2}\ndo_test vtab1-3.6 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6}\ndo_test vtab1-3.7 {\n  execsql {\n    SELECT rowid, * FROM t1;\n  }\n} {1 1 2 3 2 4 5 6}\ndo_test vtab1-3.8.1 {\n  execsql {\n    SELECT a AS d, b AS e, c AS f FROM t1;\n  }\n} {1 2 3 4 5 6}\n\n# Execute some SELECT statements with WHERE clauses on the t1 table.\n# Then check the echo_module variable (written to by the module methods\n# in test8.c) to make sure the xBestIndex() and xFilter() methods were\n# called correctly.\n#\ndo_test vtab1-3.8.2 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal'} ]\ndo_test vtab1-3.9 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1 WHERE b = 5;\n  }\n} {4 5 6}\ndo_test vtab1-3.10 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b = ?}   \\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal' WHERE b = ?} 5 ]\ndo_test vtab1-3.10 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1 WHERE b >= 5 AND b <= 10;\n  }\n} {4 5 6}\ndo_test vtab1-3.11 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\\\n        5 10 ]\ndo_test vtab1-3.12 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1 WHERE b BETWEEN 2 AND 10;\n  }\n} {1 2 3 4 5 6}\ndo_test vtab1-3.13 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal' WHERE b >= ? AND b <= ?}\\\n        2 10 ]\n\n# Add a function for the MATCH operator. Everything always matches!\n#proc test_match {lhs rhs} {\n#  lappend ::echo_module MATCH $lhs $rhs\n#  return 1\n#}\n#db function match test_match\n\nset echo_module \"\"\ndo_test vtab1-3.12 {\n  set echo_module \"\"\n  catchsql {\n    SELECT * FROM t1 WHERE a MATCH 'string';\n  }\n} {1 {unable to use function MATCH in the requested context}}\ndo_test vtab1-3.13 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal'}]\nifcapable subquery {\n# The echo module uses a subquery internally to implement the MATCH operator.\ndo_test vtab1-3.14 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM t1 WHERE b MATCH 'string';\n  }\n} {}\ndo_test vtab1-3.15 {\n  set echo_module\n} [list xBestIndex \\\n        {SELECT rowid, a, b, c FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \\\n        xFilter \\\n        {SELECT rowid, a, b, c FROM 'treal' WHERE b LIKE (SELECT '%'||?||'%')} \\\n        string ]\n}; #ifcapable subquery\n\n#----------------------------------------------------------------------\n# Test case vtab1-3 test table scans and the echo module's \n# xBestIndex/xFilter handling of ORDER BY clauses.\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\ndo_test vtab1-4.1 {\n  set echo_module \"\"\n  cksort {\n    SELECT b FROM t1 ORDER BY b;\n  }\n} {2 5 nosort}\ndo_test vtab1-4.2 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b ASC} \\\n        xFilter    {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b ASC} ]\ndo_test vtab1-4.3 {\n  set echo_module \"\"\n  cksort {\n    SELECT b FROM t1 ORDER BY b DESC;\n  }\n} {5 2 nosort}\ndo_test vtab1-4.4 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b DESC} \\\n        xFilter    {SELECT rowid, NULL, b, NULL FROM 'treal' ORDER BY b DESC} ]\ndo_test vtab1-4.3 {\n  set echo_module \"\"\n  cksort {\n    SELECT b FROM t1 ORDER BY b||'';\n  }\n} {2 5 sort}\ndo_test vtab1-4.4 {\n  set echo_module\n} [list xBestIndex {SELECT rowid, NULL, b, NULL FROM 'treal'} \\\n        xFilter    {SELECT rowid, NULL, b, NULL FROM 'treal'} ]\n\nexecsql {\n  DROP TABLE t1;\n  DROP TABLE treal;\n}\n\n#----------------------------------------------------------------------\n# Test cases vtab1-5 test SELECT queries that include joins on virtual \n# tables.\n\nproc filter {log} {\n  set out [list]\n  for {set ii 0} {$ii < [llength $log]} {incr ii} {\n    if {[lindex $log $ii] eq \"xFilter\"} {\n      lappend out xFilter\n      lappend out [lindex $log [expr $ii+1]]\n    }\n  }\n  return $out\n}\n\ndo_test vtab1-5-1 {\n  execsql { \n    CREATE TABLE t1(a, b, c);\n    CREATE TABLE t2(d, e, f);\n    INSERT INTO t1 VALUES(1, 'red', 'green');\n    INSERT INTO t1 VALUES(2, 'blue', 'black');\n    INSERT INTO t2 VALUES(1, 'spades', 'clubs');\n    INSERT INTO t2 VALUES(2, 'hearts', 'diamonds');\n    CREATE VIRTUAL TABLE et1 USING echo(t1);\n    CREATE VIRTUAL TABLE et2 USING echo(t2);\n  }\n} {}\n\ndo_test vtab1-5-2 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM et1, et2;\n  }\n} [list \\\n  1 red green 1 spades clubs     \\\n  1 red green 2 hearts diamonds  \\\n  2 blue black 1 spades clubs    \\\n  2 blue black 2 hearts diamonds \\\n]\ndo_test vtab1-5-3 {\n  filter $echo_module\n} [list \\\n  xFilter {SELECT rowid, a, b, c FROM 't1'} \\\n  xFilter {SELECT rowid, d, e, f FROM 't2'} \\\n  xFilter {SELECT rowid, d, e, f FROM 't2'} \\\n]\ndo_test vtab1-5-4 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM et1, et2 WHERE et2.d = 2;\n  }\n} [list \\\n  1 red green 2 hearts diamonds  \\\n  2 blue black 2 hearts diamonds \\\n]\ndo_test vtab1-5-5 {\n  filter $echo_module\n} [list \\\n  xFilter {SELECT rowid, a, b, c FROM 't1'} \\\n  xFilter {SELECT rowid, d, e, f FROM 't2'} \\\n  xFilter {SELECT rowid, d, e, f FROM 't2'} \\\n]\ndo_test vtab1-5-6 {\n  execsql {\n    CREATE INDEX i1 ON t2(d);\n  }\n\n  db close\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n\n  set ::echo_module \"\"\n  execsql {\n    SELECT * FROM et1, et2 WHERE et2.d = 2;\n  }\n} [list \\\n  1 red green 2 hearts diamonds  \\\n  2 blue black 2 hearts diamonds \\\n]\ndo_test vtab1-5-7 {\n  filter $::echo_module\n} [list \\\n  xFilter {SELECT rowid, a, b, c FROM 't1'}             \\\n  xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \\\n  xFilter {SELECT rowid, d, e, f FROM 't2' WHERE d = ?} \\\n]\n\nexecsql {\n  DROP TABLE t1;\n  DROP TABLE t2;\n  DROP TABLE et1;\n  DROP TABLE et2;\n}\n\n#----------------------------------------------------------------------\n# Test cases vtab1-6 test INSERT, UPDATE and DELETE operations \n# on virtual tables.\ndo_test vtab1-6-1 {\n  execsql { SELECT sql FROM sqlite_master }\n} {}\ndo_test vtab1-6-2 {\n  execsql {\n    CREATE TABLE treal(a PRIMARY KEY, b, c);\n    CREATE VIRTUAL TABLE techo USING echo(treal);\n    SELECT name FROM sqlite_master WHERE type = 'table';\n  }\n} {treal techo}\ndo_test vtab1-6-3.1.1 {\n  execsql {\n    PRAGMA count_changes=ON;\n    INSERT INTO techo VALUES(1, 2, 3);\n  }\n} {1}\ndo_test vtab1-6-3.1.2 {\n  db changes\n} {1}\ndo_test vtab1-6-3.2 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {1 2 3}\ndo_test vtab1-6-4.1 {\n  execsql {\n    UPDATE techo SET a = 5;\n  }\n  db changes\n} {1}\ndo_test vtab1-6-4.2 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {5 2 3}\ndo_test vtab1-6-4.3 {\n  execsql {\n    UPDATE techo SET a=6 WHERE a<0;\n  }\n  db changes\n} {0}\ndo_test vtab1-6-4.4 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {5 2 3}\n\ndo_test vtab1-6-5.1 {\n execsql {\n   UPDATE techo set a = a||b||c;\n }\n db changes\n} {1}\ndo_test vtab1-6-5.2 {\n execsql {\n   SELECT * FROM techo;\n }\n} {523 2 3}\n\ndo_test vtab1-6-6.1 {\n  execsql {\n    UPDATE techo set rowid = 10;\n  }\n  db changes\n} {1}\ndo_test vtab1-6-6.2 {\n  execsql {\n    SELECT rowid FROM techo;\n  }\n} {10}\n\ndo_test vtab1-6-7.1.1 {\n  execsql {\n    INSERT INTO techo VALUES(11,12,13);\n  }\n} {1}\ndo_test vtab1-6-7.1.2 {\n  db changes\n} {1}\ndo_test vtab1-6-7.2 {\n  execsql {\n    SELECT * FROM techo ORDER BY a;\n  }\n} {11 12 13 523 2 3}\ndo_test vtab1-6-7.3 {\n  execsql {\n    UPDATE techo SET b=b+1000\n  }\n  db changes\n} {2}\ndo_test vtab1-6-7.4 {\n  execsql {\n    SELECT * FROM techo ORDER BY a;\n  }\n} {11 1012 13 523 1002 3}\n\n\ndo_test vtab1-6-8.1 {\n  execsql {\n    DELETE FROM techo WHERE a=5;\n  }\n  db changes\n} {0}\ndo_test vtab1-6-8.2 {\n  execsql {\n    SELECT * FROM techo ORDER BY a;\n  }\n} {11 1012 13 523 1002 3}\ndo_test vtab1-6-8.3 {\n  execsql {\n    DELETE FROM techo;\n  }\n  db changes\n} {2}\ndo_test vtab1-6-8.4 {\n  execsql {\n    SELECT * FROM techo ORDER BY a;\n  }\n} {}\nexecsql {PRAGMA count_changes=OFF}\n\nforcedelete test2.db\nforcedelete test2.db-journal\nsqlite3 db2 test2.db\nexecsql {\n  CREATE TABLE techo(a PRIMARY KEY, b, c);\n} db2\nproc check_echo_table {tn} {\n  set ::data1 [execsql {SELECT rowid, * FROM techo}]\n  set ::data2 [execsql {SELECT rowid, * FROM techo} db2]\n  do_test $tn {\n    string equal $::data1 $::data2\n  } 1\n}\nset tn 0\nforeach stmt [list \\\n  {INSERT INTO techo VALUES('abc', 'def', 'ghi')}                        \\\n  {INSERT INTO techo SELECT a||'.'||rowid, b, c FROM techo}              \\\n  {INSERT INTO techo SELECT a||'x'||rowid, b, c FROM techo}              \\\n  {INSERT INTO techo SELECT a||'y'||rowid, b, c FROM techo}              \\\n  {DELETE FROM techo WHERE (oid % 3) = 0}                                \\\n  {UPDATE techo set rowid = 100 WHERE rowid = 1}                         \\\n  {INSERT INTO techo(a, b) VALUES('hello', 'world')}                     \\\n  {DELETE FROM techo}                                                    \\\n] {\n  execsql $stmt\n  execsql $stmt db2\n  check_echo_table vtab1-6.8.[incr tn]\n}\n\ndb2 close\n\n\n\n#----------------------------------------------------------------------\n# Test cases vtab1-7 tests that the value returned by \n# sqlite3_last_insert_rowid() is set correctly when rows are inserted\n# into virtual tables.\ndo_test vtab1.7-1 {\n  execsql {\n    CREATE TABLE real_abc(a PRIMARY KEY, b, c);\n    CREATE VIRTUAL TABLE echo_abc USING echo(real_abc);\n  }\n} {}\ndo_test vtab1.7-2 {\n  execsql {\n    INSERT INTO echo_abc VALUES(1, 2, 3);\n    SELECT last_insert_rowid();\n  }\n} {1}\ndo_test vtab1.7-3 {\n  execsql {\n    INSERT INTO echo_abc(rowid) VALUES(31427);\n    SELECT last_insert_rowid();\n  }\n} {31427}\ndo_test vtab1.7-4 {\n  execsql {\n    INSERT INTO echo_abc SELECT a||'.v2', b, c FROM echo_abc;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-5 {\n  execsql {\n    SELECT rowid, a, b, c FROM echo_abc\n  }\n} [list 1     1    2  3  \\\n        31427 {}   {} {} \\\n        31428 1.v2 2  3  \\\n        31429 {}  {} {}  \\\n]\n\n# Now test that DELETE and UPDATE operations do not modify the value.\ndo_test vtab1.7-6 {\n  execsql {\n    UPDATE echo_abc SET c = 5 WHERE b = 2;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-7 {\n  execsql {\n    UPDATE echo_abc SET rowid = 5 WHERE rowid = 1;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-8 {\n  execsql {\n    DELETE FROM echo_abc WHERE b = 2;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-9 {\n  execsql {\n    SELECT rowid, a, b, c FROM echo_abc\n  }\n} [list 31427 {} {} {} \\\n        31429 {} {} {} \\\n]\ndo_test vtab1.7-10 {\n  execsql {\n    DELETE FROM echo_abc WHERE b = 2;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-11 {\n  execsql {\n    SELECT rowid, a, b, c FROM real_abc\n  }\n} [list 31427 {} {} {} \\\n        31429 {} {} {} \\\n]\ndo_test vtab1.7-12 {\n  execsql {\n    DELETE FROM echo_abc;\n    SELECT last_insert_rowid();\n  }\n} {31429}\ndo_test vtab1.7-13 {\n  execsql {\n    SELECT rowid, a, b, c FROM real_abc\n  }\n} {}\n\nifcapable attach {\n  do_test vtab1.8-1 {\n    set echo_module \"\"\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      CREATE VIRTUAL TABLE aux.e2 USING echo(real_abc);\n    }\n    set echo_module\n  } [list xCreate echo aux e2 real_abc   \\\n          xSync   echo(real_abc)         \\\n          xCommit echo(real_abc)         \\\n  ]\n}\ndo_test vtab1.8-2 {\n  catchsql {\n    DROP TABLE aux.e2;\n  }\n  execsql {\n    DROP TABLE treal;\n    DROP TABLE techo;\n    DROP TABLE echo_abc;\n    DROP TABLE real_abc;\n  }\n} {}\n\ndo_test vtab1.9-1 {\n  set echo_module \"\"\n  execsql {\n    CREATE TABLE r(a, b, c);\n    CREATE VIRTUAL TABLE e USING echo(r, e_log);\n    SELECT name FROM sqlite_master;\n  }\n} {r e e_log}\ndo_test vtab1.9-2 {\n  execsql {\n    DROP TABLE e;\n    SELECT name FROM sqlite_master;\n  }\n} {r}\n\ndo_test vtab1.9-3 {\n  set echo_module \"\"\n  execsql {\n    CREATE VIRTUAL TABLE e USING echo(r, e_log, virtual 1 2 3 varchar(32));\n  }\n  set echo_module\n} [list                                                        \\\n  xCreate echo main e r e_log {virtual 1 2 3 varchar(32)}      \\\n  xSync echo(r)                                                \\\n  xCommit echo(r)                                              \\\n]\n\ndo_test vtab1.10-1 {\n  execsql {\n    CREATE TABLE del(d);\n    CREATE VIRTUAL TABLE e2 USING echo(del);\n  }\n  db close\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    DROP TABLE del;\n  }\n  catchsql {\n    SELECT * FROM e2;\n  }\n} {1 {vtable constructor failed: e2}}\ndo_test vtab1.10-2 {\n  set rc [catch {\n    set ptr [sqlite3_connection_pointer db]\n    sqlite3_declare_vtab $ptr {CREATE TABLE abc(a, b, c)}\n  } msg]\n  list $rc $msg\n} {1 {bad parameter or other API misuse}}\ndo_test vtab1.10-3 {\n  set ::echo_module_begin_fail r\n  catchsql {\n    INSERT INTO e VALUES(1, 2, 3);\n  }\n} {1 {SQL logic error}}\ndo_test vtab1.10-4 {\n  catch {execsql {\n    EXPLAIN SELECT * FROM e WHERE rowid = 2;\n    EXPLAIN QUERY PLAN SELECT * FROM e WHERE rowid = 2 ORDER BY rowid;\n  }}\n} {0}\n\ndo_test vtab1.10-5 {\n  set echo_module \"\"\n  execsql {\n    SELECT * FROM e WHERE rowid||'' MATCH 'pattern';\n  }\n  set echo_module\n} [list \\\n  xBestIndex {SELECT rowid, a, b, c FROM 'r'} \\\n  xFilter {SELECT rowid, a, b, c FROM 'r'}    \\\n]\nproc match_func {args} {return \"\"}\ndo_test vtab1.10-6 {\n  set echo_module \"\"\n  db function match match_func\n  execsql {\n    SELECT * FROM e WHERE match('pattern', rowid, 'pattern2');\n  }\n  set echo_module\n} [list \\\n  xBestIndex {SELECT rowid, a, b, c FROM 'r'} \\\n  xFilter {SELECT rowid, a, b, c FROM 'r'}    \\\n]\n\n\n# Testing the xFindFunction interface\n#\ncatch {rename ::echo_glob_overload {}}\ndo_test vtab1.11-1 {\n  execsql {\n    INSERT INTO r(a,b,c) VALUES(1,'?',99);\n    INSERT INTO r(a,b,c) VALUES(2,3,99);\n    SELECT a GLOB b FROM e\n  }\n} {1 0}\nproc ::echo_glob_overload {a b} {\n return [list $b $a]\n}\ndo_test vtab1.11-2 {\n  execsql {\n    SELECT a like 'b' FROM e\n  }\n} {0 0}\ndo_test vtab1.11-3 {\n  execsql {\n    SELECT a glob '2' FROM e\n  }\n} {{1 2} {2 2}}\ndo_test vtab1.11-4 {\n  execsql {\n    SELECT  glob('2',a) FROM e\n  }\n} {0 1}\ndo_test vtab1.11-5 {\n  execsql {\n    SELECT  glob(a,'2') FROM e\n  }\n} {{2 1} {2 2}}\n \n#----------------------------------------------------------------------\n# Test the outcome if a constraint is encountered half-way through\n# a multi-row INSERT that is inside a transaction\n#\ndo_test vtab1.12-1 {\n  execsql {\n    CREATE TABLE b(a, b, c);\n    CREATE TABLE c(a UNIQUE, b, c);\n    INSERT INTO b VALUES(1, 'A', 'B');\n    INSERT INTO b VALUES(2, 'C', 'D');\n    INSERT INTO b VALUES(3, 'E', 'F');\n    INSERT INTO c VALUES(3, 'G', 'H');\n    CREATE VIRTUAL TABLE echo_c USING echo(c);\n  }\n} {}\n\n# First test outside of a transaction.\ndo_test vtab1.12-2 {\n  catchsql { INSERT INTO echo_c SELECT * FROM b; }\n} {1 {echo-vtab-error: UNIQUE constraint failed: c.a}}\ndo_test vtab1.12-2.1 {\n  sqlite3_errmsg db\n} {echo-vtab-error: UNIQUE constraint failed: c.a}\ndo_test vtab1.12-3 {\n  execsql { SELECT * FROM c }\n} {3 G H}\n\n# Now the real test - wrapped in a transaction.\ndo_test vtab1.12-4 {\n  execsql  {BEGIN}\n  catchsql { INSERT INTO echo_c SELECT * FROM b; }\n} {1 {echo-vtab-error: UNIQUE constraint failed: c.a}}\ndo_test vtab1.12-5 {\n  execsql { SELECT * FROM c }\n} {3 G H}\ndo_test vtab1.12-6 {\n  execsql { COMMIT }\n  execsql { SELECT * FROM c }\n} {3 G H}\n\n# At one point (ticket #2759), a WHERE clause of the form \"<column> IS NULL\"\n# on a virtual table was causing an assert() to fail in the compiler.\n#\n# \"IS NULL\" clauses should not be passed through to the virtual table\n# implementation. They are handled by SQLite after the vtab returns its\n# data.\n#\ndo_test vtab1.13-1 {\n  execsql { \n    SELECT * FROM echo_c WHERE a IS NULL \n  }\n} {}\ndo_test vtab1.13-2 {\n  execsql { \n    INSERT INTO c VALUES(NULL, 15, 16);\n    SELECT * FROM echo_c WHERE a IS NULL \n  }\n} {{} 15 16}\ndo_test vtab1.13-3 {\n  execsql { \n    INSERT INTO c VALUES(15, NULL, 16);\n    SELECT * FROM echo_c WHERE b IS NULL \n  }\n} {15 {} 16}\ndo_test vtab1.13-4 {\n  unset -nocomplain null\n  execsql { \n    SELECT * FROM echo_c WHERE b IS $null\n  }\n} {15 {} 16}\ndo_test vtab1.13-5 {\n  execsql { \n    SELECT * FROM echo_c WHERE b IS NULL AND a = 15;\n  }\n} {15 {} 16}\ndo_test vtab1.13-6 {\n  execsql { \n    SELECT * FROM echo_c WHERE NULL IS b AND a IS 15;\n  }\n} {15 {} 16}\n\n\ndo_test vtab1-14.001 {\n  execsql {SELECT rowid, * FROM echo_c WHERE +rowid IN (1,2,3)}\n} {1 3 G H 2 {} 15 16 3 15 {} 16}\ndo_test vtab1-14.002 {\n  execsql {SELECT rowid, * FROM echo_c WHERE rowid IN (1,2,3)}\n} {1 3 G H 2 {} 15 16 3 15 {} 16}\ndo_test vtab1-14.003 {\n  execsql {SELECT rowid, * FROM echo_c WHERE +rowid IN (0,1,5,2,'a',3,NULL)}\n} {1 3 G H 2 {} 15 16 3 15 {} 16}\ndo_test vtab1-14.004 {\n  execsql {SELECT rowid, * FROM echo_c WHERE rowid IN (0,1,5,'a',2,3,NULL)}\n} {1 3 G H 2 {} 15 16 3 15 {} 16}\ndo_test vtab1-14.005 {\n  execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,1,5,'a',2,3)}\n} {}\ndo_test vtab1-14.006 {\n  execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,5,'a',2,3)}\n} {1 3 G H}\ndo_test vtab1-14.007 {\n  execsql {SELECT rowid, * FROM echo_c WHERE +rowid NOT IN (0,5,'a',2,3,NULL)}\n} {}\ndo_test vtab1-14.008 {\n  execsql {SELECT rowid, * FROM echo_c WHERE rowid NOT IN (0,5,'a',2,3,NULL)}\n} {}\ndo_test vtab1-14.011 {\n  execsql {SELECT * FROM echo_c WHERE +a IN (1,3,8,'x',NULL,15,24)}\n} {3 G H 15 {} 16}\ndo_test vtab1-14.012 {\n  execsql {SELECT * FROM echo_c WHERE a IN (1,3,8,'x',NULL,15,24)}\n} {3 G H 15 {} 16}\ndo_test vtab1-14.013 {\n  execsql {SELECT * FROM echo_c WHERE a NOT IN (1,8,'x',15,24)}\n} {3 G H}\ndo_test vtab1-14.014 {\n  execsql {SELECT * FROM echo_c WHERE a NOT IN (1,8,'x',NULL,15,24)}\n} {}\ndo_test vtab1-14.015 {\n  execsql {SELECT * FROM echo_c WHERE +a NOT IN (1,8,'x',NULL,15,24)}\n} {}\n\n\n\n#do_test vtab1-14.1 {\n#  execsql { DELETE FROM c }\n#  set echo_module \"\"\n#  execsql { SELECT * FROM echo_c WHERE rowid IN (1, 2, 3) }\n#  set echo_module\n#} {/.*xBestIndex {SELECT rowid, . FROM 'c' WHERE rowid = .} xFilter {SELECT rowid, . FROM 'c'} 1/}\n\ndo_test vtab1-14.2 {\n  set echo_module \"\"\n  execsql { SELECT * FROM echo_c WHERE rowid = 1 }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'c' WHERE rowid = ?} \\\n        xFilter {SELECT rowid, a, b, c FROM 'c' WHERE rowid = ?} 1]\n\ndo_test vtab1-14.3 {\n  set echo_module \"\"\n  execsql { SELECT * FROM echo_c WHERE a = 1 }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'c' WHERE a = ?} \\\n        xFilter {SELECT rowid, a, b, c FROM 'c' WHERE a = ?} 1]\n\n#do_test vtab1-14.4 {\n#  set echo_module \"\"\n#  execsql { SELECT * FROM echo_c WHERE a IN (1, 2) }\n#  set echo_module\n#} {/xBestIndex {SELECT rowid, . FROM 'c' WHERE a = .} xFilter {SELECT rowid, . FROM 'c' WHERE a = .} 1/}\n\ndo_test vtab1-15.1 {\n  execsql {\n    CREATE TABLE t1(a, b, c);\n    CREATE VIRTUAL TABLE echo_t1 USING echo(t1);\n  }\n} {}\ndo_test vtab1-15.2 {\n  execsql {\n    INSERT INTO echo_t1(rowid) VALUES(45);\n    SELECT rowid, * FROM echo_t1;\n  }\n} {45 {} {} {}}\ndo_test vtab1-15.3 {\n  execsql {\n    INSERT INTO echo_t1(rowid) VALUES(NULL);\n    SELECT rowid, * FROM echo_t1;\n  }\n} {45 {} {} {} 46 {} {} {}}\ndo_test vtab1-15.4 {\n  catchsql {\n    INSERT INTO echo_t1(rowid) VALUES('new rowid');\n  }\n} {1 {datatype mismatch}}\n\n# The following tests - vtab1-16.* - are designed to test that setting \n# sqlite3_vtab.zErrMsg variable can be used by the vtab interface to \n# return an error message to the user.\n# \ndo_test vtab1-16.1 {\n  execsql {\n    CREATE TABLE t2(a PRIMARY KEY, b, c);\n    INSERT INTO t2 VALUES(1, 2, 3);\n    INSERT INTO t2 VALUES(4, 5, 6);\n    CREATE VIRTUAL TABLE echo_t2 USING echo(t2);\n  }\n} {}\n\nset tn 2\nforeach method [list \\\n    xBestIndex       \\\n    xOpen            \\\n    xFilter          \\\n    xNext            \\\n    xColumn          \\\n    xRowid           \\\n] {\n  do_test vtab1-16.$tn {\n    set echo_module_fail($method,t2) \"the $method method has failed\"\n    catchsql { SELECT rowid, * FROM echo_t2 WHERE a >= 1 }\n  } \"1 {echo-vtab-error: the $method method has failed}\"\n  unset echo_module_fail($method,t2)\n  incr tn\n}\n\nforeach method [list \\\n  xUpdate            \\\n  xBegin             \\\n  xSync              \\\n] {\n  do_test vtab1-16.$tn {\n    set echo_module_fail($method,t2) \"the $method method has failed\"\n    catchsql { INSERT INTO echo_t2 VALUES(7, 8, 9) }\n  } \"1 {echo-vtab-error: the $method method has failed}\"\n  unset echo_module_fail($method,t2)\n  incr tn\n}\n\nifcapable altertable {\n  do_test vtab1-16.$tn {\n    set echo_module_fail(xRename,t2) \"the xRename method has failed\"\n    catchsql { ALTER TABLE echo_t2 RENAME TO another_name }\n  } \"1 {echo-vtab-error: the xRename method has failed}\"\n  unset echo_module_fail(xRename,t2)\n  incr tn\n}\n\n# The following test case exposes an instance in sqlite3_declare_vtab()\n# an error message was set using a call similar to sqlite3_mprintf(zErr),\n# where zErr is an arbitrary string. This is no good if the string contains\n# characters that can be mistaken for printf() formatting directives.\n#\ndo_test vtab1-17.1 {\n  execsql { \n    PRAGMA writable_schema = 1;\n    INSERT INTO sqlite_master VALUES(\n      'table', 't3', 't3', 0, 'INSERT INTO \"%s%s\" VALUES(1)'\n    );\n  }\n  catchsql { CREATE VIRTUAL TABLE t4 USING echo(t3); }\n} {1 {vtable constructor failed: t4}}\n\n# This test verifies that ticket 48f29963 is fixed.\n#\ndo_test vtab1-17.1 {\n  execsql { \n    CREATE TABLE t5(a, b);\n    CREATE VIRTUAL TABLE e5 USING echo_v2(t5);\n    BEGIN;\n      INSERT INTO e5 VALUES(1, 2);\n      DROP TABLE e5;\n      SAVEPOINT one;\n      ROLLBACK TO one;\n    COMMIT;\n  }\n} {}\n\ndo_test vtab1-17.2 {\n  execsql { DELETE FROM sqlite_master WHERE sql LIKE 'insert%' }\n} {}\n\n#-------------------------------------------------------------------------\n# The following tests - vtab1-18.* - test that the optimization of LIKE\n# constraints in where.c plays well with virtual tables.\n#\n#   18.1.*: Case-insensitive LIKE.\n#   18.2.*: Case-sensitive LIKE.\n#\nunset -nocomplain echo_module_begin_fail\n\ndo_execsql_test 18.1.0 {\n  CREATE TABLE t6(a, b TEXT);\n  CREATE INDEX i6 ON t6(b, a);\n  INSERT INTO t6 VALUES(1, 'Peter');\n  INSERT INTO t6 VALUES(2, 'Andrew');\n  INSERT INTO t6 VALUES(3, '8James');\n  INSERT INTO t6 VALUES(4, '8John');\n  INSERT INTO t6 VALUES(5, 'Phillip');\n  INSERT INTO t6 VALUES(6, 'Bartholomew');\n  CREATE VIRTUAL TABLE e6 USING echo(t6);\n}\n\nforeach {tn sql res filter} {\n  1.1 \"SELECT a FROM e6 WHERE b>'8James'\" {4 2 6 1 5}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b > ?} 8James}\n\n  1.2 \"SELECT a FROM e6 WHERE b>='8' AND b<'9'\" {3 4}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b >= ? AND b < ?} 8 9}\n\n  1.3 \"SELECT a FROM e6 WHERE b LIKE '8J%'\" {3 4}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8J%}\n\n  1.4 \"SELECT a FROM e6 WHERE b LIKE '8j%'\" {3 4}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8j%}\n} {\n  set echo_module {}\n  do_execsql_test 18.$tn.1 $sql $res\n  do_test         18.$tn.2 { lrange $::echo_module 2 end } $filter\n}\n\ndo_execsql_test 18.2.0 {  PRAGMA case_sensitive_like = ON }\nforeach {tn sql res filter} {\n  2.1 \"SELECT a FROM e6 WHERE b LIKE '8J%'\" {3 4}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8J%}\n\n  2.2 \"SELECT a FROM e6 WHERE b LIKE '8j%'\" {}\n    {xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8j%}\n} {\n  set echo_module {}\n  do_execsql_test 18.$tn.1 $sql $res\n  do_test         18.$tn.2 { lrange $::echo_module 2 end } $filter\n}\ndo_execsql_test 18.2.x {  PRAGMA case_sensitive_like = OFF }\n\n#-------------------------------------------------------------------------\n# Test that an existing module may not be overridden.\n#\ndo_test 19.1 {\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n} SQLITE_OK\ndo_test 19.2 {\n  register_echo_module [sqlite3_connection_pointer db2]\n} SQLITE_MISUSE\ndo_test 19.3 {\n  db2 close\n} {}\n\n#-------------------------------------------------------------------------\n# Test that the bug fixed by [b0c1ba655d69] really is fixed.\n#\ndo_execsql_test 20.1 {\n  CREATE TABLE t7 (a, b);\n  CREATE TABLE t8 (c, d);\n  CREATE INDEX i2 ON t7(a);\n  CREATE INDEX i3 ON t7(b);\n  CREATE INDEX i4 ON t8(c);\n  CREATE INDEX i5 ON t8(d);\n\n  CREATE VIRTUAL TABLE t7v USING echo(t7);\n  CREATE VIRTUAL TABLE t8v USING echo(t8);\n}\n\ndo_test 20.2 {\n  for {set i 0} {$i < 1000} {incr i} {\n    db eval {INSERT INTO t7 VALUES($i, $i)}\n    db eval {INSERT INTO t8 VALUES($i, $i)}\n  }\n} {}\n\ndo_execsql_test 20.3 {\n  SELECT a, b FROM (\n      SELECT a, b FROM t7 WHERE a=11 OR b=12\n      UNION ALL\n      SELECT c, d FROM t8 WHERE c=5 OR d=6\n  )\n  ORDER BY 1, 2;\n} {5 5 6 6 11 11 12 12}\n\ndo_execsql_test 20.4 {\n  SELECT a, b FROM (\n      SELECT a, b FROM t7v WHERE a=11 OR b=12\n      UNION ALL\n      SELECT c, d FROM t8v WHERE c=5 OR d=6\n  )\n  ORDER BY 1, 2;\n} {5 5 6 6 11 11 12 12}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 21.1 {\n  CREATE TABLE t9(a,b,c);\n  CREATE VIRTUAL TABLE t9v USING echo(t9);\n\n  INSERT INTO t9 VALUES(1,2,3);\n  INSERT INTO t9 VALUES(3,2,1);\n  INSERT INTO t9 VALUES(2,2,2);\n}\n\ndo_execsql_test 21.2 {\n  SELECT * FROM t9v WHERE a<b;\n} {1 2 3}\n\ndo_execsql_test 21.3 {\n  SELECT * FROM t9v WHERE a=b;\n} {2 2 2}\n\n#-------------------------------------------------------------------------\n# At one point executing a CREATE VIRTUAL TABLE statement that specified \n# a database name but no virtual table arguments was causing an internal\n# buffer overread. Valgrind would report errors while running the following \n# tests. Specifically:\n#\n#   CREATE VIRTUAL TABLE t1 USING fts4;          -- Ok - no db name.\n#   CREATE VIRTUAL TABLE main.t1 USING fts4(x);  -- Ok - has vtab arguments.\n#   CREATE VIRTUAL TABLE main.t1 USING fts4;     -- Had the problem. \n#\nifcapable fts3 {\n  forcedelete test.db2\n  set nm [string repeat abcdefghij 100]\n  do_execsql_test 22.1 {\n    ATTACH 'test.db2' AS $nm\n  }\n  \n  execsql \"SELECT * FROM sqlite_master\"\n  do_execsql_test 22.2 \"CREATE VIRTUAL TABLE ${nm}.t1 USING fts4\"\n  \n  do_test 22.3.1 {\n    set sql \"CREATE VIRTUAL TABLE ${nm}.t2 USING fts4\"\n    set stmt [sqlite3_prepare_v2 db $sql -1 dummy]\n    sqlite3_step $stmt\n  } {SQLITE_DONE}\n  \n  do_test 22.3.2 {\n    sqlite3_finalize $stmt\n  } {SQLITE_OK}\n  \n  do_test 22.4.1 {\n    set sql \"CREATE VIRTUAL TABLE ${nm}.t3 USING fts4\"\n    set n [string length $sql]\n    set stmt [sqlite3_prepare db \"${sql}xyz\" $n dummy]\n    sqlite3_step $stmt\n  } {SQLITE_DONE}\n  \n  do_test 22.4.2 {\n    sqlite3_finalize $stmt\n  } {SQLITE_OK}\n}\n\n\n#-------------------------------------------------------------------------\n# The following tests verify that a DROP TABLE command on a virtual\n# table does not cause other operations to crash.\n#\n#   23.1: Dropping a vtab while a SELECT is running on it.\n#\n#   23.2: Dropping a vtab while a SELECT that will, but has not yet,\n#         open a cursor on the vtab, is running. In this case the\n#         DROP TABLE succeeds and the SELECT hits an error.\n#   \n#   23.3: Dropping a vtab from within a user-defined-function callback\n#         in the middle of an \"INSERT INTO vtab SELECT ...\" statement.\n#\nreset_db\nload_static_extension db wholenumber\nload_static_extension db eval\nregister_echo_module db\n\ndo_test 23.1 {\n  execsql { CREATE VIRTUAL TABLE t1 USING wholenumber }\n  set res \"\"\n  db eval { SELECT value FROM t1 WHERE value<10 } {\n    if {$value == 5} {\n      set res [catchsql { DROP TABLE t1 }]\n    }\n  }\n  set res\n} {1 {database table is locked}}\n\ndo_test 23.2 {\n  execsql { \n    CREATE TABLE t2(value);\n    INSERT INTO t2 VALUES(1), (2), (3);\n  }\n\n  set res2 [list [catch {\n    db eval {\n      SELECT value FROM t2 UNION ALL \n      SELECT value FROM t1 WHERE value<10\n    } {\n      if {$value == 2} { set res1 [catchsql { DROP TABLE t1 }] }\n    }\n  } msg] $msg]\n  list $res1 $res2\n} {{0 {}} {1 {database table is locked}}}\n\ndo_test 23.3.1 {\n  execsql { CREATE VIRTUAL TABLE t1e USING echo(t2) }\n  execsql { INSERT INTO t1e SELECT 4 }\n  catchsql { INSERT INTO t1e SELECT eval('DROP TABLE t1e') }\n} {1 {database table is locked}}\ndo_execsql_test 23.3.2 { SELECT * FROM t1e } {1 2 3 4}\n\n#-------------------------------------------------------------------------\n# At one point SQL like this:\n#\n#   SAVEPOINT xyz;       -- Opens SQL transaction\n#     INSERT INTO vtab   -- Write to virtual table\n#     ROLLBACK TO xyz;\n#   RELEASE xyz;\n#\n# was not invoking the xRollbackTo() callback for the ROLLBACK TO \n# operation. Which meant that virtual tables like FTS3 would incorrectly \n# commit the results of the INSERT as part of the \"RELEASE xyz\" command.\n#\n# The following tests check that this has been fixed.\n#\nifcapable fts3 {\n  do_execsql_test 24.0 {\n    CREATE VIRTUAL TABLE t4 USING fts3();\n    SAVEPOINT a;\n    INSERT INTO t4 VALUES('a b c');\n    ROLLBACK TO a;\n    RELEASE a;\n    SELECT * FROM t4;\n  } {}\n\n  do_execsql_test 24.1 { SELECT * FROM t4 WHERE t4 MATCH 'b' } {}\n  do_execsql_test 24.2 { INSERT INTO t4(t4) VALUES('integrity-check') } {}\n\n  do_execsql_test 24.3 {\n    SAVEPOINT a;\n    CREATE VIRTUAL TABLE t5 USING fts3();\n    SAVEPOINT b;\n    ROLLBACK TO a;\n    SAVEPOINT c;\n    RELEASE a;\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab2.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtab2\n\nifcapable !vtab||!schema_pragmas {\n  finish_test\n  return\n}\n\nregister_schema_module [sqlite3_connection_pointer db]\ndo_test vtab2-1.1 {\n  execsql {\n    CREATE VIRTUAL TABLE schema USING schema;\n    SELECT * FROM schema;\n  }\n} [list \\\n  main schema 0 database   {} 0 {} 0 \\\n  main schema 1 tablename  {} 0 {} 0 \\\n  main schema 2 cid        {} 0 {} 0 \\\n  main schema 3 name       {} 0 {} 0 \\\n  main schema 4 type       {} 0 {} 0 \\\n  main schema 5 not_null   {} 0 {} 0 \\\n  main schema 6 dflt_value {} 0 {} 0 \\\n  main schema 7 pk         {} 0 {} 0 \\\n]\n\n# See ticket #2230.\n#\ndo_test vtab2-1.2 {\n  execsql {\n    SELECT length(tablename) FROM schema GROUP by tablename;\n  }\n} {6}\ndo_test vtab2-1.3 {\n  execsql {\n    SELECT tablename FROM schema GROUP by length(tablename);\n  }\n} {schema}\ndo_test vtab2-1.4 {\n  execsql {\n    SELECT length(tablename) FROM schema GROUP by length(tablename);\n  }\n} {6}\n\nregister_tclvar_module [sqlite3_connection_pointer db]\ndo_test vtab2-2.1 {\n  set ::abc 123\n  execsql {\n    CREATE VIRTUAL TABLE vars USING tclvar;\n    SELECT name, arrayname, value FROM vars WHERE name='abc';\n  }\n} [list abc \"\" 123]\ndo_test vtab2-2.2 {\n  set A(1) 1\n  set A(2) 4\n  set A(3) 9\n  execsql {\n    SELECT name, arrayname, value FROM vars WHERE name='A';\n  }\n} [list A 1 1 A 2 4 A 3 9]\nunset -nocomplain result\nunset -nocomplain var\nset result {}\nforeach var [lsort [info vars tcl_*]] {\n  catch {lappend result $var [set $var]}\n}\ndo_test vtab2-2.3 {\n  execsql {\n    SELECT name, value FROM vars\n      WHERE name MATCH 'tcl_*' AND arrayname = '' \n      ORDER BY name;\n  }\n} $result\nunset result\nunset var\n\n# Ticket #2894.\n#\n# Make sure we do call Column(), and Rowid() methods of\n# a virtual table when that table is in a LEFT JOIN.\n#\ndo_test vtab2-3.1 {\n  execsql {\n    SELECT * FROM schema WHERE dflt_value IS NULL LIMIT 1\n  }\n} {main schema 0 database {} 0 {} 0}\ndo_test vtab2-3.2 {\n  execsql {\n    SELECT *, b.rowid\n      FROM schema a LEFT JOIN schema b ON a.dflt_value=b.dflt_value\n     WHERE a.rowid=1\n  }\n} {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}\ndo_test vtab2-3.3 {\n  execsql {\n    SELECT *, b.rowid\n      FROM schema a LEFT JOIN schema b ON a.dflt_value IS b.dflt_value\n                                      AND a.dflt_value IS NOT NULL\n     WHERE a.rowid=1\n  }\n} {main schema 0 database {} 0 {} 0 {} {} {} {} {} {} {} {} {}}\n\ndo_test vtab2-4.1 {\n  execsql {\n    BEGIN TRANSACTION;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(b, c));\n    CREATE TABLE fkey(\n      to_tbl,\n      to_col\n    );\n    INSERT INTO \"fkey\" VALUES('t1',NULL);\n    COMMIT;\n  }\n} {}\ndo_test vtab2-4.2 {\n  execsql { CREATE VIRTUAL TABLE v_col USING schema }\n} {}\ndo_test vtab2-4.3 {\n  execsql { SELECT name FROM v_col WHERE tablename = 't1' AND pk }\n} {a}\ndo_test vtab2-4.4 {\n  execsql {\n    UPDATE fkey \n    SET to_col = (SELECT name FROM v_col WHERE tablename = 't1' AND pk);\n  }\n} {}\ndo_test vtab2-4.5 {\n  execsql { SELECT * FROM fkey }\n} {t1 a}\n\n#-------------------------------------------------------------------------\n#\nifcapable fts3 {\n  reset_db\n  do_execsql_test 5.1 {\n    PRAGMA encoding='UTF16';\n  }\n\n  do_test 5.2 {\n    sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C8 USING fts3 }\n  } {0 {}}\n\n  do_test 5.3 {\n    sqlite3_exec_hex db { CREATE VIRTUAL TABLE %C9 USING s }\n  } {/1 {malformed database schema.* already exists}/}\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab3.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is the authorisation callback and virtual tables.\n#\n# $Id: vtab3.test,v 1.3 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab||!auth {\n  finish_test\n  return\n}\n\nset ::auth_fail 0\nset ::auth_log [list]\nset ::auth_filter [list SQLITE_READ SQLITE_UPDATE SQLITE_SELECT SQLITE_PRAGMA]\n\nproc auth {code arg1 arg2 arg3 arg4 args} {\n  if {[lsearch $::auth_filter $code]>-1} {\n    return SQLITE_OK\n  }\n  lappend ::auth_log $code $arg1 $arg2 $arg3 $arg4\n  incr ::auth_fail -1\n  if {$::auth_fail == 0} {\n    return SQLITE_DENY\n  }\n  return SQLITE_OK\n}\n\ndo_test vtab3-1.1 {\n  execsql {\n    CREATE TABLE elephant(\n      name VARCHAR(32), \n      color VARCHAR(16), \n      age INTEGER, \n      UNIQUE(name, color)\n    );\n  }\n} {}\n\n\ndo_test vtab3-1.2 {\n  register_echo_module [sqlite3_connection_pointer db]\n  db authorizer ::auth\n  execsql {\n    CREATE VIRTUAL TABLE pachyderm USING echo(elephant);\n  }\n  set ::auth_log\n} [list \\\n  SQLITE_INSERT        sqlite_master {}   main {} \\\n  SQLITE_CREATE_VTABLE pachyderm     echo main {} \\\n]\n\ndo_test vtab3-1.3 {\n  set ::auth_log [list]\n  execsql {\n    DROP TABLE pachyderm;\n  }\n  set ::auth_log\n} [list \\\n  SQLITE_DELETE        sqlite_master {}   main {} \\\n  SQLITE_DROP_VTABLE   pachyderm     echo main {} \\\n  SQLITE_DELETE        pachyderm     {}   main {} \\\n  SQLITE_DELETE        sqlite_master {}   main {} \\\n]\n\ndo_test vtab3-1.4 {\n  set ::auth_fail 1\n  catchsql {\n    CREATE VIRTUAL TABLE pachyderm USING echo(elephant);\n  }\n} {1 {not authorized}}\ndo_test vtab3-1.5 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type = 'table';\n  }\n} {elephant}\n\ndo_test vtab3-1.5 {\n  set ::auth_fail 2\n  catchsql {\n    CREATE VIRTUAL TABLE pachyderm USING echo(elephant);\n  }\n} {1 {not authorized}}\ndo_test vtab3-1.6 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type = 'table';\n  }\n} {elephant}\n\ndo_test vtab3-1.5 {\n  set ::auth_fail 3\n  catchsql {\n    CREATE VIRTUAL TABLE pachyderm USING echo(elephant);\n  }\n} {0 {}}\ndo_test vtab3-1.6 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type = 'table';\n  }\n} {elephant pachyderm}\n\nforeach i [list 1 2 3 4] {\n  set ::auth_fail $i\n  do_test vtab3-1.7.$i.1 {\n    set rc [catch {\n      execsql {DROP TABLE pachyderm;}\n    } msg]\n    if {$msg eq \"authorization denied\"} {set msg \"not authorized\"}\n    list $rc $msg\n  } {1 {not authorized}}\n  do_test vtab3-1.7.$i.2 {\n    execsql {\n      SELECT name FROM sqlite_master WHERE type = 'table';\n    }\n  } {elephant pachyderm}\n}\ndo_test vtab3-1.8.1 {\n  set ::auth_fail 0\n  catchsql {\n    DROP TABLE pachyderm;\n  }\n} {0 {}}\ndo_test vtab3-1.8.2 {\n  execsql {\n    SELECT name FROM sqlite_master WHERE type = 'table';\n  }\n} {elephant}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab4.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus is on testing the following virtual table methods:\n#\n#     xBegin\n#     xSync\n#     xCommit\n#     xRollback\n#\n# $Id: vtab4.test,v 1.3 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nunset -nocomplain echo_module\nunset -nocomplain echo_module_sync_fail\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# Register the echo module\ndb cache size 0\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test vtab4-1.1 {\n  execsql {\n    CREATE TABLE treal(a PRIMARY KEY, b, c);\n    CREATE VIRTUAL TABLE techo USING echo(treal);\n  }\n} {}\n\n# Test an INSERT, UPDATE and DELETE statement on the virtual table\n# in an implicit transaction. Each should result in a single call\n# to xBegin, xSync and xCommit.\n#\ndo_test vtab4-1.2 {\n  set echo_module [list]\n  execsql {\n    INSERT INTO techo VALUES(1, 2, 3);\n  }\n  set echo_module\n} {xBegin echo(treal) xSync echo(treal) xCommit echo(treal)}\ndo_test vtab4-1.3 {\n  set echo_module [list]\n  execsql {\n    UPDATE techo SET a = 2;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \\\n        xBegin     echo(treal)                    \\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal'} \\\n        xSync      echo(treal)                    \\\n        xCommit    echo(treal)                    \\\n]\ndo_test vtab4-1.4 {\n  set echo_module [list]\n  execsql {\n    DELETE FROM techo;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \\\n        xBegin     echo(treal)                    \\\n        xFilter    {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \\\n        xSync      echo(treal)                    \\\n        xCommit    echo(treal)                    \\\n]\n\n# Ensure xBegin is not called more than once in a single transaction.\n#\ndo_test vtab4-2.1 {\n  set echo_module [list]\n  execsql {\n    BEGIN;\n    INSERT INTO techo VALUES(1, 2, 3);\n    INSERT INTO techo VALUES(4, 5, 6);\n    INSERT INTO techo VALUES(7, 8, 9);\n    COMMIT;\n  }\n  set echo_module\n} {xBegin echo(treal) xSync echo(treal) xCommit echo(treal)}\n\n# Try a transaction with two virtual tables.\n#\ndo_test vtab4-2.2 {\n  execsql {\n    CREATE TABLE sreal(a, b, c UNIQUE);\n    CREATE VIRTUAL TABLE secho USING echo(sreal);\n  }\n  set echo_module [list]\n  execsql {\n    BEGIN;\n    INSERT INTO secho SELECT * FROM techo;\n    DELETE FROM techo;\n    COMMIT;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'treal'} \\\n        xBegin     echo(sreal)                    \\\n        xFilter    {SELECT rowid, a, b, c FROM 'treal'} \\\n        xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \\\n        xBegin     echo(treal)                    \\\n        xFilter    {SELECT rowid, NULL, NULL, NULL FROM 'treal'} \\\n        xSync   echo(sreal)                       \\\n        xSync   echo(treal)                       \\\n        xCommit echo(sreal)                       \\\n        xCommit echo(treal)                       \\\n]\ndo_test vtab4-2.3 {\n  execsql {\n    SELECT * FROM secho;\n  }\n} {1 2 3 4 5 6 7 8 9}\ndo_test vtab4-2.4 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {}\n\n# Try an explicit ROLLBACK on a transaction with two open virtual tables.\ndo_test vtab4-2.5 {\n  set echo_module [list]\n  execsql {\n    BEGIN;\n    INSERT INTO techo SELECT * FROM secho;\n    DELETE FROM secho;\n    ROLLBACK;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'sreal'} \\\n        xBegin     echo(treal)                    \\\n        xFilter    {SELECT rowid, a, b, c FROM 'sreal'} \\\n        xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \\\n        xBegin     echo(sreal)                    \\\n        xFilter    {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \\\n        xRollback  echo(treal)                    \\\n        xRollback  echo(sreal)                    \\\n]\ndo_test vtab4-2.6 {\n  execsql {\n    SELECT * FROM secho;\n  }\n} {1 2 3 4 5 6 7 8 9}\ndo_test vtab4-2.7 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {}\n\ndo_test vtab4-3.1 {\n  set echo_module [list]\n  set echo_module_sync_fail treal\n  catchsql {\n    INSERT INTO techo VALUES(1, 2, 3);\n  }\n} {1 {unknown error}}\ndo_test vtab4-3.2 {\n  set echo_module\n} {xBegin echo(treal) xSync echo(treal) xRollback echo(treal)}\n\ndo_test vtab4-3.3 {\n  set echo_module [list]\n  set echo_module_sync_fail sreal\n  catchsql {\n    BEGIN;\n    INSERT INTO techo SELECT * FROM secho;\n    DELETE FROM secho;\n    COMMIT;\n  }\n  set echo_module\n} [list xBestIndex {SELECT rowid, a, b, c FROM 'sreal'} \\\n        xBegin     echo(treal)                    \\\n        xFilter    {SELECT rowid, a, b, c FROM 'sreal'} \\\n        xBestIndex {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \\\n        xBegin     echo(sreal)                    \\\n        xFilter    {SELECT rowid, NULL, NULL, NULL FROM 'sreal'} \\\n        xSync      echo(treal)                    \\\n        xSync      echo(sreal)                    \\\n        xRollback  echo(treal)                    \\\n        xRollback  echo(sreal)                    \\\n]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab5.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# $Id: vtab5.test,v 1.8 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# The following tests - vtab5-1.* - ensure that an INSERT, DELETE or UPDATE\n# statement can be executed immediately after a CREATE or schema reload. The\n# point here is testing that the parser always calls xConnect() before the\n# schema of a virtual table is used.\n#\nregister_echo_module [sqlite3_connection_pointer db]\ndo_test vtab5-1.1 {\n  execsql {\n    CREATE TABLE treal(a VARCHAR(16), b INTEGER, c FLOAT);\n    INSERT INTO treal VALUES('a', 'b', 'c');\n    CREATE VIRTUAL TABLE techo USING echo(treal);\n  }\n} {}\ndo_test vtab5.1.2 {\n  execsql {\n    SELECT * FROM techo;\n  }\n} {a b c}\ndo_test vtab5.1.3 {\n  db close\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    INSERT INTO techo VALUES('c', 'd', 'e');\n    SELECT * FROM techo;\n  }\n} {a b c c d e}\ndo_test vtab5.1.4 {\n  db close\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    UPDATE techo SET a = 10;\n    SELECT * FROM techo;\n  }\n} {10 b c 10 d e}\ndo_test vtab5.1.5 {\n  db close\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    DELETE FROM techo WHERE b > 'c';\n    SELECT * FROM techo;\n  }\n} {10 b c}\ndo_test vtab5.1.X {\n  execsql {\n    DROP TABLE techo;\n    DROP TABLE treal;\n  }\n} {}\n\n# The following tests - vtab5-2.* - ensure that collation sequences\n# assigned to virtual table columns via the \"CREATE TABLE\" statement \n# passed to sqlite3_declare_vtab() are used correctly.\n#\ndo_test vtab5.2.1 {\n  execsql {\n    CREATE TABLE strings(str COLLATE NOCASE);\n    INSERT INTO strings VALUES('abc1');\n    INSERT INTO strings VALUES('Abc3');\n    INSERT INTO strings VALUES('ABc2');\n    INSERT INTO strings VALUES('aBc4');\n    SELECT str FROM strings ORDER BY 1;\n  }\n} {abc1 ABc2 Abc3 aBc4}\ndo_test vtab5.2.2 {\n  execsql {\n    CREATE VIRTUAL TABLE echo_strings USING echo(strings);\n    SELECT str FROM echo_strings ORDER BY 1;\n  }\n} {abc1 ABc2 Abc3 aBc4}\ndo_test vtab5.2.3 {\n  execsql {\n    SELECT str||'' FROM echo_strings ORDER BY 1;\n  }\n} {ABc2 Abc3 aBc4 abc1}\n\n# Test that it is impossible to create a triggger on a virtual table.\n#\nifcapable trigger {\n  do_test vtab5.3.1 {\n    catchsql {\n      CREATE TRIGGER trig INSTEAD OF INSERT ON echo_strings BEGIN\n        SELECT 1, 2, 3;\n      END;\n    }\n  } {1 {cannot create triggers on virtual tables}}\n  do_test vtab5.3.2 {\n    catchsql {\n      CREATE TRIGGER trig AFTER INSERT ON echo_strings BEGIN\n        SELECT 1, 2, 3;\n      END;\n    }\n  } {1 {cannot create triggers on virtual tables}}\n  do_test vtab5.3.2 {\n    catchsql {\n      CREATE TRIGGER trig BEFORE INSERT ON echo_strings BEGIN\n        SELECT 1, 2, 3;\n      END;\n    }\n  } {1 {cannot create triggers on virtual tables}}\n}\n\n# Test that it is impossible to create an index on a virtual table.\n#\ndo_test vtab5.4.1 {\n  catchsql {\n    CREATE INDEX echo_strings_i ON echo_strings(str);\n  }\n} {1 {virtual tables may not be indexed}}\n\n# Test that it is impossible to add a column to a virtual table.\n#\nifcapable altertable {\n  do_test vtab5.4.2 {\n    catchsql {\n      ALTER TABLE echo_strings ADD COLUMN col2;\n    }\n  } {1 {virtual tables may not be altered}}\n}\n\n# Test that it is impossible to rename a virtual table.\n# UPDATE: It is now possible.\n#\n# do_test vtab5.4.3 {\n#   catchsql {\n#     ALTER TABLE echo_strings RENAME TO echo_strings2;\n#   }\n# } {1 {virtual tables may not be altered}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab6.test",
    "content": "# 2002 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for joins, including outer joins involving\n# virtual tables. The test cases in this file are copied from the file\n# join.test, and some of the comments still reflect that.\n#\n# $Id: vtab6.test,v 1.5 2009/07/01 16:12:08 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_echo_module [sqlite3_connection_pointer db]\n\nexecsql {\n  CREATE TABLE real_t1(a,b,c);\n  CREATE TABLE real_t2(b,c,d);\n  CREATE TABLE real_t3(c,d,e);\n  CREATE TABLE real_t4(d,e,f);\n  CREATE TABLE real_t5(a INTEGER PRIMARY KEY);\n  CREATE TABLE real_t6(a INTEGER);\n  CREATE TABLE real_t7 (x, y);\n  CREATE TABLE real_t8 (a integer primary key, b);\n  CREATE TABLE real_t9(a INTEGER PRIMARY KEY, b);\n  CREATE TABLE real_t10(x INTEGER PRIMARY KEY, y);\n  CREATE TABLE real_t11(p INTEGER PRIMARY KEY, q);\n  CREATE TABLE real_t12(a,b);\n  CREATE TABLE real_t13(b,c);\n  CREATE TABLE real_t21(a,b,c);\n  CREATE TABLE real_t22(p,q);\n}\nforeach t [list t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t21 t22] {\n  execsql \"CREATE VIRTUAL TABLE $t USING echo(real_$t)\"\n}\n\ndo_test vtab6-1.1 {\n  execsql {\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(2,3,4);\n    INSERT INTO t1 VALUES(3,4,5);\n    SELECT * FROM t1;\n  }  \n} {1 2 3 2 3 4 3 4 5}\ndo_test vtab6-1.2 {\n  execsql {\n    INSERT INTO t2 VALUES(1,2,3);\n    INSERT INTO t2 VALUES(2,3,4);\n    INSERT INTO t2 VALUES(3,4,5);\n    SELECT * FROM t2;\n  }  \n} {1 2 3 2 3 4 3 4 5}\n\ndo_test vtab6-1.3 {\n  execsql2 {\n    SELECT * FROM t1 NATURAL JOIN t2;\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test vtab6-1.3.1 {\n  execsql2 {\n    SELECT * FROM t2 NATURAL JOIN t1;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test vtab6-1.3.2 {\n  execsql2 {\n    SELECT * FROM t2 AS x NATURAL JOIN t1;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test vtab6-1.3.3 {\n  execsql2 {\n    SELECT * FROM t2 NATURAL JOIN t1 AS y;\n  }\n} {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2}\ndo_test vtab6-1.3.4 {\n  execsql {\n    SELECT b FROM t1 NATURAL JOIN t2;\n  }\n} {2 3}\ndo_test vtab6-1.4.1 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test vtab6-1.4.2 {\n  execsql2 {\n    SELECT * FROM t1 AS x INNER JOIN t2 USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test vtab6-1.4.3 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 AS y USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test vtab6-1.4.4 {\n  execsql2 {\n    SELECT * FROM t1 AS x INNER JOIN t2 AS y USING(b,c);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\ndo_test vtab6-1.4.5 {\n  execsql {\n    SELECT b FROM t1 JOIN t2 USING(b);\n  }\n} {2 3}\ndo_test vtab6-1.5 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(b);\n  }\n} {a 1 b 2 c 3 c 3 d 4 a 2 b 3 c 4 c 4 d 5}\ndo_test vtab6-1.6 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(c);\n  }\n} {a 1 b 2 c 3 b 2 d 4 a 2 b 3 c 4 b 3 d 5}\ndo_test vtab6-1.7 {\n  execsql2 {\n    SELECT * FROM t1 INNER JOIN t2 USING(c,b);\n  }\n} {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5}\n\ndo_test vtab6-1.8 {\n  execsql {\n    SELECT * FROM t1 NATURAL CROSS JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test vtab6-1.9 {\n  execsql {\n    SELECT * FROM t1 CROSS JOIN t2 USING(b,c);\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test vtab6-1.10 {\n  execsql {\n    SELECT * FROM t1 NATURAL INNER JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test vtab6-1.11 {\n  execsql {\n    SELECT * FROM t1 INNER JOIN t2 USING(b,c);\n  }\n} {1 2 3 4 2 3 4 5}\ndo_test vtab6-1.12 {\n  execsql {\n    SELECT * FROM t1 natural inner join t2;\n  }\n} {1 2 3 4 2 3 4 5}\n\nifcapable subquery {\n  do_test vtab6-1.13 {\n    execsql2 {\n      SELECT * FROM t1 NATURAL JOIN \n        (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as t3\n    }\n  } {a 1 b 2 c 3 d 4 e 5}\n  do_test vtab6-1.14 {\n    execsql2 {\n      SELECT * FROM (SELECT b as 'c', c as 'd', d as 'e' FROM t2) as 'tx'\n          NATURAL JOIN t1\n    }\n  } {c 3 d 4 e 5 a 1 b 2}\n}\n\ndo_test vtab6-1.15 {\n  execsql {\n    INSERT INTO t3 VALUES(2,3,4);\n    INSERT INTO t3 VALUES(3,4,5);\n    INSERT INTO t3 VALUES(4,5,6);\n    SELECT * FROM t3;\n  }  \n} {2 3 4 3 4 5 4 5 6}\ndo_test vtab6-1.16 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t3;\n  }\n} {1 2 3 4 5 2 3 4 5 6}\ndo_test vtab6-1.17 {\n  execsql2 {\n    SELECT * FROM t1 natural join t2 natural join t3;\n  }\n} {a 1 b 2 c 3 d 4 e 5 a 2 b 3 c 4 d 5 e 6}\ndo_test vtab6-1.18 {\n  execsql {\n    INSERT INTO t4 VALUES(2,3,4);\n    INSERT INTO t4 VALUES(3,4,5);\n    INSERT INTO t4 VALUES(4,5,6);\n    SELECT * FROM t4;\n  }  \n} {2 3 4 3 4 5 4 5 6}\ndo_test vtab6-1.19.1 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t4;\n  }\n} {1 2 3 4 5 6}\ndo_test vtab6-1.19.2 {\n  execsql2 {\n    SELECT * FROM t1 natural join t2 natural join t4;\n  }\n} {a 1 b 2 c 3 d 4 e 5 f 6}\ndo_test vtab6-1.20 {\n  execsql {\n    SELECT * FROM t1 natural join t2 natural join t3 WHERE t1.a=1\n  }\n} {1 2 3 4 5}\n\ndo_test vtab6-2.1 {\n  execsql {\n    SELECT * FROM t1 NATURAL LEFT JOIN t2;\n  }\n} {1 2 3 4 2 3 4 5 3 4 5 {}}\ndo_test vtab6-2.2 {\n  execsql {\n    SELECT * FROM t2 NATURAL LEFT OUTER JOIN t1;\n  }\n} {1 2 3 {} 2 3 4 1 3 4 5 2}\ndo_test vtab6-2.3 {\n  catchsql {\n    SELECT * FROM t1 NATURAL RIGHT OUTER JOIN t2;\n  }\n} {1 {RIGHT and FULL OUTER JOINs are not currently supported}}\ndo_test vtab6-2.4 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d\n  }\n} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3}\ndo_test vtab6-2.4.1 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a IS t2.d\n  }\n} {1 2 3 {} {} {} 2 3 4 {} {} {} 3 4 5 1 2 3}\ndo_test vtab6-2.5 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t1.a>1\n  }\n} {2 3 4 {} {} {} 3 4 5 1 2 3}\ndo_test vtab6-2.6 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.d WHERE t2.b IS NULL OR t2.b>1\n  }\n} {1 2 3 {} {} {} 2 3 4 {} {} {}}\n\ndo_test vtab6-3.1 {\n  catchsql {\n    SELECT * FROM t1 NATURAL JOIN t2 ON t1.a=t2.b;\n  }\n} {1 {a NATURAL join may not have an ON or USING clause}}\ndo_test vtab6-3.2 {\n  catchsql {\n    SELECT * FROM t1 NATURAL JOIN t2 USING(b);\n  }\n} {1 {a NATURAL join may not have an ON or USING clause}}\ndo_test vtab6-3.3 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 ON t1.a=t2.b USING(b);\n  }\n} {1 {cannot have both ON and USING clauses in the same join}}\ndo_test vtab6-3.4 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 USING(a);\n  }\n} {1 {cannot join using column a - column not present in both tables}}\ndo_test vtab6-3.5 {\n  catchsql { SELECT * FROM t1 USING(a) }\n} {1 {a JOIN clause is required before USING}}\ndo_test vtab6-3.6 {\n  catchsql {\n    SELECT * FROM t1 JOIN t2 ON t3.a=t2.b;\n  }\n} {1 {no such column: t3.a}}\ndo_test vtab6-3.7 {\n  catchsql {\n    SELECT * FROM t1 INNER OUTER JOIN t2;\n  }\n} {1 {unknown or unsupported join type: INNER OUTER}}\ndo_test vtab6-3.7 {\n  catchsql {\n    SELECT * FROM t1 LEFT BOGUS JOIN t2;\n  }\n} {1 {unknown or unsupported join type: LEFT BOGUS}}\n\ndo_test vtab6-4.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t6 VALUES(NULL);\n    INSERT INTO t6 VALUES(NULL);\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    INSERT INTO t6 SELECT * FROM t6;\n    COMMIT;\n  }\n  execsql {\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test vtab6-4.2 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test vtab6-4.3 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\ndo_test vtab6-4.4 {\n  execsql {\n    UPDATE t6 SET a='xyz';\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test vtab6-4.6 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test vtab6-4.7 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\ndo_test vtab6-4.8 {\n  execsql {\n    UPDATE t6 SET a=1;\n    SELECT * FROM t6 NATURAL JOIN t5;\n  }\n} {}\ndo_test vtab6-4.9 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a<t5.a;\n  }\n} {}\ndo_test vtab6-4.10 {\n  execsql {\n    SELECT * FROM t6, t5 WHERE t6.a>t5.a;\n  }\n} {}\n\n# A test for ticket #247.\n#\ndo_test vtab6-7.1 {\n  execsql {\n    INSERT INTO t7 VALUES (\"pa1\", 1);\n    INSERT INTO t7 VALUES (\"pa2\", NULL);\n    INSERT INTO t7 VALUES (\"pa3\", NULL);\n    INSERT INTO t7 VALUES (\"pa4\", 2);\n    INSERT INTO t7 VALUES (\"pa30\", 131);\n    INSERT INTO t7 VALUES (\"pa31\", 130);\n    INSERT INTO t7 VALUES (\"pa28\", NULL);\n\n    INSERT INTO t8 VALUES (1, \"pa1\");\n    INSERT INTO t8 VALUES (2, \"pa4\");\n    INSERT INTO t8 VALUES (3, NULL);\n    INSERT INTO t8 VALUES (4, NULL);\n    INSERT INTO t8 VALUES (130, \"pa31\");\n    INSERT INTO t8 VALUES (131, \"pa30\");\n\n    SELECT coalesce(t8.a,999) from t7 LEFT JOIN t8 on y=a;\n  }\n} {1 999 999 2 131 130 999}\n\n# Make sure a left join where the right table is really a view that\n# is itself a join works right.  Ticket #306.\n#\nifcapable view {\ndo_test vtab6-8.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t9 VALUES(1,11);\n    INSERT INTO t9 VALUES(2,22);\n    INSERT INTO t10 VALUES(1,2);\n    INSERT INTO t10 VALUES(3,3);    \n    INSERT INTO t11 VALUES(2,111);\n    INSERT INTO t11 VALUES(3,333);    \n    CREATE VIEW v10_11 AS SELECT x, q FROM t10, t11 WHERE t10.y=t11.p;\n    COMMIT;\n    SELECT * FROM t9 LEFT JOIN v10_11 ON( a=x );\n  }\n} {1 11 1 111 2 22 {} {}}\nifcapable subquery {\n  do_test vtab6-8.2 {\n    execsql {\n      SELECT * FROM t9 LEFT JOIN (SELECT x, q FROM t10, t11 WHERE t10.y=t11.p)\n           ON( a=x);\n    }\n  } {1 11 1 111 2 22 {} {}}\n}\ndo_test vtab6-8.3 {\n  execsql {\n    SELECT * FROM v10_11 LEFT JOIN t9 ON( a=x );\n  }\n} {1 111 1 11 3 333 {} {}}\n} ;# ifcapable view\n\n# Ticket #350 describes a scenario where LEFT OUTER JOIN does not\n# function correctly if the right table in the join is really\n# subquery.\n#\n# To test the problem, we generate the same LEFT OUTER JOIN in two\n# separate selects but with on using a subquery and the other calling\n# the table directly.  Then connect the two SELECTs using an EXCEPT.\n# Both queries should generate the same results so the answer should\n# be an empty set.\n#\nifcapable compound {\ndo_test vtab6-9.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t12 VALUES(1,11);\n    INSERT INTO t12 VALUES(2,22);\n    INSERT INTO t13 VALUES(22,222);\n    COMMIT;\n  }\n} {}\n\nifcapable subquery {\n  do_test vtab6-9.1.1 {\n    execsql {\n      SELECT * FROM t12 NATURAL LEFT JOIN t13\n      EXCEPT\n      SELECT * FROM t12 NATURAL LEFT JOIN (SELECT * FROM t13 WHERE b>0);\n    }\n  } {}\n}\nifcapable view {\n  do_test vtab6-9.2 {\n    execsql {\n      CREATE VIEW v13 AS SELECT * FROM t13 WHERE b>0;\n      SELECT * FROM t12 NATURAL LEFT JOIN t13\n        EXCEPT\n        SELECT * FROM t12 NATURAL LEFT JOIN v13;\n    }\n  } {}\n} ;# ifcapable view\n} ;# ifcapable compound\n\nifcapable subquery {\ndo_test vtab6-10.1 {\n  execsql {\n    CREATE INDEX i22 ON real_t22(q);\n    SELECT a FROM t21 LEFT JOIN t22 ON b=p WHERE q=\n       (SELECT max(m.q) FROM t22 m JOIN t21 n ON n.b=m.p WHERE n.c=1);\n  }  \n} {}\n} ;# ifcapable subquery\n\ndo_test vtab6-11.1.0 {\n  execsql {\n    CREATE TABLE ab_r(a, b);\n    CREATE TABLE bc_r(b, c);\n\n    CREATE VIRTUAL TABLE ab USING echo(ab_r); \n    CREATE VIRTUAL TABLE bc USING echo(bc_r); \n\n    INSERT INTO ab VALUES(1, 2);\n    INSERT INTO bc VALUES(2, 3);\n  }\n} {}\n\ndo_test vtab6-11.1.1 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\ndo_test vtab6-11.1.2 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\nset ::echo_module_cost 1.0\n\ndo_test vtab6-11.1.3 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\ndo_test vtab6-11.1.4 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\n\ndo_test vtab6-11.2.0 {\n  execsql {\n    CREATE INDEX ab_i ON ab_r(b);\n    CREATE INDEX bc_i ON bc_r(b);\n  }\n} {}\n\nunset ::echo_module_cost\n\ndo_test vtab6-11.2.1 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\ndo_test vtab6-11.2.2 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\nset ::echo_module_cost 1.0\n\ndo_test vtab6-11.2.3 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\ndo_test vtab6-11.2.4 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\nunset ::echo_module_cost\ndb close\nsqlite3 db test.db\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test vtab6-11.3.1 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\n\ndo_test vtab6-11.3.2 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\nset ::echo_module_cost 1.0\n\ndo_test vtab6-11.3.3 {\n  execsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 2 3}\ndo_test vtab6-11.3.4 {\n  execsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 2 3}\n\nunset ::echo_module_cost\n\nset ::echo_module_ignore_usable 1\ndb cache flush\n\ndo_test vtab6-11.4.1 {\n  catchsql {\n    SELECT a, b, c FROM ab NATURAL JOIN bc;\n  }\n} {1 {ab.xBestIndex malfunction}}\ndo_test vtab6-11.4.2 {\n  catchsql {\n    SELECT a, b, c FROM bc NATURAL JOIN ab;\n  }\n} {1 {bc.xBestIndex malfunction}}\n\nunset ::echo_module_ignore_usable\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab7.test",
    "content": "# 2006 July 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# of this test is reading and writing to the database from within a\n# virtual table xSync() callback.\n#\n# $Id: vtab7.test,v 1.4 2007/12/04 16:54:53 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# Register the echo module. Code inside the echo module appends elements\n# to the global tcl list variable ::echo_module whenever SQLite invokes\n# certain module callbacks. This includes the xSync(), xCommit() and \n# xRollback() callbacks. For each of these callback, two elements are\n# appended to ::echo_module, as follows:\n#\n#     Module method        Elements appended to ::echo_module\n#     -------------------------------------------------------\n#     xSync()              xSync echo($tablename)\n#     xCommit()            xCommit echo($tablename)\n#     xRollback()          xRollback echo($tablename)\n#     -------------------------------------------------------\n#\n# In each case, $tablename is replaced by the name of the real table (not\n# the echo table). By setting up a tcl trace on the ::echo_module variable,\n# code in this file arranges for a Tcl script to be executed from within\n# the echo module xSync() callback.\n#\nregister_echo_module [sqlite3_connection_pointer db]\ntrace add variable ::echo_module write echo_module_trace\n\n# This Tcl proc is invoked whenever the ::echo_module variable is written.\n#\nproc echo_module_trace {args} {\n  # Filter out writes to ::echo_module that are not xSync, xCommit or \n  # xRollback callbacks.\n  if {[llength $::echo_module] < 2} return\n  set x [lindex $::echo_module end-1]\n  if {$x ne \"xSync\" && $x ne \"xCommit\" && $x ne \"xRollback\"} return\n\n  regexp {^echo.(.*).$} [lindex $::echo_module end] dummy tablename\n  # puts \"Ladies and gentlemen, an $x on $tablename!\"\n\n  if {[info exists ::callbacks($x,$tablename)]} {\n    eval $::callbacks($x,$tablename)\n  }\n}\n\n# The following tests, vtab7-1.*, test that the trace callback on \n# ::echo_module is providing the expected tcl callbacks.\ndo_test vtab7-1.1 {\n  execsql {\n    CREATE TABLE abc(a, b, c);\n    CREATE VIRTUAL TABLE abc2 USING echo(abc);\n  }\n} {}\n\ndo_test vtab7-1.2 {\n  set ::callbacks(xSync,abc) {incr ::counter}\n  set ::counter 0\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n  }\n  set ::counter\n} {1}\n\n# Write to an existing database table from within an xSync callback.\ndo_test vtab7-2.1 {\n  set ::callbacks(xSync,abc) {\n    execsql {INSERT INTO log VALUES('xSync');}\n  }\n  execsql {\n    CREATE TABLE log(msg);\n    INSERT INTO abc2 VALUES(4, 5, 6);\n    SELECT * FROM log;\n  }\n} {xSync}\ndo_test vtab7-2.3 {\n  execsql {\n    INSERT INTO abc2 VALUES(4, 5, 6);\n    SELECT * FROM log;\n  }\n} {xSync xSync}\ndo_test vtab7-2.4 {\n  execsql {\n    INSERT INTO abc2 VALUES(4, 5, 6);\n    SELECT * FROM log;\n  }\n} {xSync xSync xSync}\n\n# Create a database table from within xSync callback.\ndo_test vtab7-2.5 {\n  set ::callbacks(xSync,abc) {\n    execsql { CREATE TABLE newtab(d, e, f); }\n  }\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n} {abc abc2 log newtab}\n\n# Drop a database table from within xSync callback.\n# This is not allowed.  Tables cannot be dropped while\n# any other statement is active.\n#\ndo_test vtab7-2.6 {\n  set ::callbacks(xSync,abc) {\n    set ::rc [catchsql { DROP TABLE newtab }]\n  }\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n} {abc abc2 log newtab}\ndo_test vtab7-2.6.1 {\n  set ::rc\n} {1 {database table is locked}}\nexecsql {DROP TABLE newtab}\n\n# Write to an attached database from xSync().\nifcapable attach {\n  do_test vtab7-3.1 {\n    forcedelete test2.db\n    forcedelete test2.db-journal\n    execsql {\n      ATTACH 'test2.db' AS db2;\n      CREATE TABLE db2.stuff(description, shape, color);\n    }\n    set ::callbacks(xSync,abc) {\n      execsql { INSERT INTO db2.stuff VALUES('abc', 'square', 'green'); }\n    }\n    execsql {\n      INSERT INTO abc2 VALUES(1, 2, 3);\n      SELECT * from stuff;\n    }\n  } {abc square green}\n}\n\n# UPDATE: The next test passes, but leaks memory. So leave it out.\n#\n# The following tests test that writing to the database from within\n# the xCommit callback causes a misuse error.\n# do_test vtab7-4.1 {\n#   unset -nocomplain ::callbacks(xSync,abc)\n#   set ::callbacks(xCommit,abc) {\n#     execsql { INSERT INTO log VALUES('hello') }\n#   }\n#   catchsql {\n#     INSERT INTO abc2 VALUES(1, 2, 3);\n#   }\n# } {1 {bad parameter or other API misuse}}\n\n# These tests, vtab7-4.*, test that an SQLITE_LOCKED error is returned\n# if an attempt to write to a virtual module table or create a new \n# virtual table from within an xSync() callback.\ndo_test vtab7-4.1 {\n  execsql {\n    CREATE TABLE def(d, e, f);\n    CREATE VIRTUAL TABLE def2 USING echo(def);\n  }\n  set ::callbacks(xSync,abc) {\n    set ::error [catchsql { INSERT INTO def2 VALUES(1, 2, 3) }]\n  }\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n  }\n  set ::error\n} {1 {database table is locked}}\ndo_test vtab7-4.2 {\n  set ::callbacks(xSync,abc) {\n    set ::error [catchsql { CREATE VIRTUAL TABLE def3 USING echo(def) }]\n  }\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n  }\n  set ::error\n} {1 {database table is locked}}\n\ndo_test vtab7-4.3 {\n  set ::callbacks(xSync,abc) {\n    set ::error [catchsql { DROP TABLE def2 }]\n  }\n  execsql {\n    INSERT INTO abc2 VALUES(1, 2, 3);\n    SELECT name FROM sqlite_master ORDER BY name;\n  }\n  set ::error\n} {1 {database table is locked}}\n\ntrace remove variable ::echo_module write echo_module_trace\nunset -nocomplain ::callbacks\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab8.test",
    "content": "# 2006 August 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file inserting into virtual tables from a SELECT\n# statement.\n#\n# $Id: vtab8.test,v 1.2 2007/03/02 08:12:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_echo_module [sqlite3_connection_pointer db]\n\n# See ticket #2244\n#\ndo_test vtab1.2244-1 {\n  execsql {\n    CREATE TABLE t2244(a, b);\n    CREATE VIRTUAL TABLE t2244e USING echo(t2244);\n    INSERT INTO t2244 VALUES('AA', 'BB');\n    INSERT INTO t2244 VALUES('CC', 'DD');\n    SELECT rowid, * FROM t2244e;\n  }\n} {1 AA BB 2 CC DD}\ndo_test vtab1.2244-2 {\n  execsql {\n    SELECT * FROM t2244e WHERE rowid = 10;\n  }\n} {}\ndo_test vtab1.2244-3 {\n  execsql {\n    UPDATE t2244e SET a = 'hello world' WHERE 0;\n    SELECT rowid, * FROM t2244e;\n  }\n} {1 AA BB 2 CC DD}\n\ndo_test vtab1-2250-2 {\n  execsql {\n    CREATE TABLE t2250(a, b);\n    INSERT INTO t2250 VALUES(10, 20);\n    CREATE VIRTUAL TABLE t2250e USING echo(t2250);\n    select max(rowid) from t2250;\n    select max(rowid) from t2250e;\n  }\n} {1 1}\n\n# See ticket #2260.\n#\ndo_test vtab1.2260-1 {\n  execsql {\n    CREATE TABLE t2260a_real(a, b);\n    CREATE TABLE t2260b_real(a, b);\n\n    CREATE INDEX i2260 ON t2260a_real(a);\n    CREATE INDEX i2260x ON t2260b_real(a);\n\n    CREATE VIRTUAL TABLE t2260a USING echo(t2260a_real);\n    CREATE VIRTUAL TABLE t2260b USING echo(t2260b_real);\n\n    SELECT * FROM t2260a, t2260b WHERE t2260a.a = t2260b.a AND t2260a.a > 101;\n  }\n} {}\n\nunset -nocomplain echo_module_begin_fail\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab9.test",
    "content": "# 2006 August 29\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file inserting into virtual tables from a SELECT\n# statement.\n#\n# $Id: vtab9.test,v 1.2 2007/04/16 15:06:26 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\ndo_test vtab9-1.1 {\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE t0(a);\n    CREATE VIRTUAL TABLE t1 USING echo(t0);\n    INSERT INTO t1 SELECT 'hello';\n    SELECT rowid, * FROM t1;\n  }\n} {1 hello}\n\ndo_test vtab9-1.2 {\n  execsql {\n    CREATE TABLE t2(a,b,c);\n    CREATE VIRTUAL TABLE t3 USING echo(t2);\n    CREATE TABLE d1(a,b,c);\n    INSERT INTO d1 VALUES(1,2,3);\n    INSERT INTO d1 VALUES('a','b','c');\n    INSERT INTO d1 VALUES(NULL,'x',123.456);\n    INSERT INTO d1 VALUES(x'6869',123456789,-12345);\n    INSERT INTO t3(a,b,c) SELECT * FROM d1;\n    SELECT rowid, * FROM t3;\n  }\n} {1 1 2 3 2 a b c 3 {} x 123.456 4 hi 123456789 -12345}\n\n# do_test vtab9-2.1 {\n#   execsql {\n#     CREATE TABLE t4(a);\n#     CREATE VIRTUAL TABLE t5 USING echo(t4);\n#     INSERT INTO t4 VALUES('hello');\n#     SELECT rowid, a FROM t5;\n#   }\n# } {1 hello}\n# do_test vtab9-2.2 {\n#   execsql {\n#     INSERT INTO t5(rowid, a) VALUES(1, 'goodbye');\n#   }\n# } {1 hello}\n# do_test vtab9-2.3 {\n#   execsql {\n#     REPLACE INTO t5(rowid, a) VALUES(1, 'goodbye');\n#     SELECT * FROM t5;\n#   }\n# } {1 goodbye}\n\nunset -nocomplain echo_module_begin_fail\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabA.test",
    "content": "# 2007 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is 'hidden' virtual table columns.\n#\n# $Id: vtabA.test,v 1.2 2008/07/12 14:52:21 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nproc get_decltype {table col} {\n  set STMT [sqlite3_prepare $::DB \"SELECT $col FROM $table\" -1 TAIL]\n  set decltype [sqlite3_column_decltype $STMT 0]\n  sqlite3_finalize $STMT\n  set decltype\n}\n\nproc get_collist {table} {\n  set ret [list]\n  db eval \"PRAGMA table_info($table)\" { lappend ret $name }\n  set ret\n}\n\n# Register the echo module\nregister_echo_module [sqlite3_connection_pointer db]\n\n# Create a virtual table with a 'hidden' column (column b).\n#\ndo_test vtabA-1.1 {\n  execsql { CREATE TABLE t1(a, b HIDDEN VARCHAR, c INTEGER) }\n} {}\ndo_test vtabA-1.2 {\n  execsql { CREATE VIRTUAL TABLE t1e USING echo(t1) }\n} {}\n\n# Test that the hidden column is not listed by [PRAGMA table_info].\n#\ndo_test vtabA-1.3 {\n  execsql { PRAGMA table_info(t1e) }\n} [list              \\\n  0 a {}      0 {} 0 \\\n  1 c INTEGER 0 {} 0 \\\n]\n\n# Test that the hidden column is not require in the default column\n# list for an INSERT statement.\n#\ndo_test vtabA-1.4 {\n  catchsql {\n    INSERT INTO t1e VALUES('value a', 'value c');\n  }\n} {0 {}}\ndo_test vtabA-1.5 {\n  execsql {\n    SELECT a, b, c FROM t1e;\n  }\n} {{value a} {} {value c}}\n\ndo_test vtabA-1.6 {\n  execsql {\n    SELECT * FROM t1e;\n  }\n} {{value a} {value c}}\ndo_execsql_test vtabA-1.7 {\n  DELETE FROM t1e;\n  INSERT INTO t1e SELECT 'abc','def';\n} {}\ndo_execsql_test vtabA-1.8 {\n  INSERT INTO t1e VALUES('ghi','jkl'),('mno','pqr'),('stu','vwx');\n} {}\ndo_execsql_test vtabA-1.9 {\n  SELECT a,b,c, '|' FROM t1e ORDER BY 1;\n} {abc {} def | ghi {} jkl | mno {} pqr | stu {} vwx |}\n\n\n# Test that the expansion of a '*' expression in the result set of\n# a SELECT does not include the hidden column.\n#\ndo_test vtabA-1.20 {\n  execsql {\n    INSERT INTO t1e SELECT * FROM t1e;\n  }\n} {}\ndo_test vtabA-1.21 {\n  execsql {\n    SELECT * FROM t1e ORDER BY 1;\n  }\n} {abc def abc def ghi jkl ghi jkl mno pqr mno pqr stu vwx stu vwx}\n\n# Test that the declaration type of the hidden column does not include\n# the token \"HIDDEN\".\n#\ndo_test vtabA-1.22 {\n  get_decltype t1e b\n} {VARCHAR}\ndo_test vtabA-1.23 {\n  get_collist t1e\n} {a c}\n\n#----------------------------------------------------------------------\n# These tests vtabA-2.* concentrate on testing that the HIDDEN token\n# is detected and handled correctly in various declarations.\n#\nproc analyse_parse {columns decltype_list} {\n  db eval { DROP TABLE IF EXISTS t1e; }\n  db eval { DROP TABLE IF EXISTS t1; }\n  db eval \" CREATE TABLE t1 $columns \"\n  db eval { CREATE VIRTUAL TABLE t1e USING echo(t1) }\n  set ret [list [get_collist t1e]]\n  foreach c $decltype_list {\n    lappend ret [get_decltype t1e $c]\n  }\n  set ret\n}\n\ndo_test vtabA-2.1 {\n  analyse_parse {(a text, b integer hidden, c hidden)} {a b c}\n} {a text integer {}}\n\ndo_test vtabA-2.2 {\n  analyse_parse {(a hidden   , b integerhidden, c hidden1)} {a b c}\n} {{b c} {} integerhidden hidden1}\n\ndo_test vtabA-2.3 {\n  analyse_parse {(a HiDden, b HIDDEN, c hidden)} {a b c}\n} {{} {} {} {}}\n\ndo_test vtabA-2.4 {\n  analyse_parse {(a whatelse can i hidden test, b HIDDEN hidden)} {a b}\n} {{} {whatelse can i test} hidden}\n\n\n# Ticket [d2f02d37f52bfe23e421f2c60fbb8586ac76ff01]:\n# assertion failure on an UPDATE involving two virtual tables.\n#\ndo_test vtabA-3.1 {\n  db eval {\n    DROP TABLE IF EXISTS t1;\n    DROP TABLE IF EXISTS t2;\n    CREATE TABLE t1(a,b);\n    INSERT INTO t1 VALUES(1,2);\n    CREATE TABLE t2(x,y);\n    INSERT INTO t2 VALUES(3,4);\n    CREATE VIRTUAL TABLE vt1 USING echo(t1);\n    CREATE VIRTUAL TABLE vt2 USING echo(t2);\n    UPDATE vt2 SET x=(SELECT a FROM vt1 WHERE b=2) WHERE y=4;\n    SELECT * FROM t2;\n  }\n} {1 4}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabB.test",
    "content": "# 2008 April 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is is verifying that a virtual table in the\n# TEMP database that is created and dropped within a transaction\n# is handled correctly.  Ticket #2994.\n#\n# Also make sure a virtual table on the right-hand side of an IN operator\n# is materialized rather than being used directly.  Ticket #3082.\n#\n\n#\n# $Id: vtabB.test,v 1.2 2008/04/25 12:10:15 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\ndo_test vtabB-1.1 {\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE t1(x);\n    BEGIN;\n    CREATE VIRTUAL TABLE temp.echo_test1 USING echo(t1);\n    DROP TABLE echo_test1;\n    ROLLBACK;\n  }\n} {}\n\ndo_test vtabB-2.1 {\n  execsql {\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    CREATE TABLE t2(y);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    CREATE VIRTUAL TABLE echo_t2 USING echo(t2);\n    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);\n  }\n} {2}\ndo_test vtab8-2.2 {\n  execsql {\n    SELECT rowid FROM echo_t2\n  }\n} {1 2}\ndo_test vtabB-2.3 {\n  execsql {\n    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);\n  }\n} {2}\ndo_test vtabB-2.4 {\n  execsql {\n    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM echo_t2);\n  }\n} {2}\ndo_test vtabB-2.5 {\n  execsql {\n    SELECT * FROM t1 WHERE x IN (SELECT y FROM t2);\n  }\n} {2}\ndo_test vtabB-2.6 {\n  execsql {\n    SELECT * FROM t1 WHERE x IN (SELECT y FROM echo_t2);\n  }\n} {2}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabC.test",
    "content": "# 2008 April 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is is verifying that the xUpdate, xSync, xCommit\n# and xRollback methods are only invoked after an xBegin or xCreate.\n# Ticket #3083.\n#\n# $Id: vtabC.test,v 1.2 2009/04/07 14:14:23 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nifcapable !trigger { finish_test ; return }\n\n\n# N will be the number of virtual tables we have defined.\n#\nunset -nocomplain N\nfor {set N 1} {$N<=20} {incr N} {\n  db close\n  forcedelete test.db test.db-journal\n  sqlite3 db test.db\n  register_echo_module [sqlite3_connection_pointer db]\n\n  # Create $N tables and $N virtual tables to echo them.\n  #\n  unset -nocomplain tablist\n  set tablist {}\n  do_test vtabC-1.$N.1 {\n    for {set i 1} {$i<=$::N} {incr i} {\n      execsql \"CREATE TABLE t${i}(x)\"\n      execsql \"CREATE VIRTUAL TABLE vt$i USING echo(t$i)\"\n      lappend ::tablist t$i vt$i\n    }\n    execsql {SELECT count(*) FROM sqlite_master}\n  } [expr {$N*2}]\n  do_test vtabC-1.$N.2 {\n    execsql {SELECT name FROM sqlite_master}\n  } $tablist\n\n  # Create a table m and add triggers to make changes on all\n  # of the virtual tables when m is changed.\n  #\n  do_test vtabC-1.$N.3 {\n    execsql {CREATE TABLE m(a)}\n    set sql \"CREATE TRIGGER rins AFTER INSERT ON m BEGIN\\n\"\n    for {set i 1} {$i<=$::N} {incr i} {\n      append sql \"  INSERT INTO vt$i VALUES(NEW.a+$i);\\n\"\n    }\n    append sql \"END;\"\n    execsql $sql\n    execsql {SELECT count(*) FROM sqlite_master}\n  } [expr {$N*2+2}]\n  do_test vtabC-1.$N.4 {\n    execsql {\n      INSERT INTO m VALUES(1000);\n      SELECT * FROM m;\n    }\n  } {1000}\n  for {set j 1} {$j<=$::N} {incr j} {\n    do_test vtabC-1.$N.5.$j {\n      execsql \"SELECT * FROM t$::j\"\n    } [expr {$j+1000}]\n    do_test vtabC-1.$N.6.$j {\n      execsql \"SELECT * FROM vt$::j\"\n    } [expr {$j+1000}]\n  }\n  do_test vtabC-1.$N.7 {\n    set sql \"CREATE TRIGGER rins2 BEFORE INSERT ON m BEGIN\\n\"\n    for {set i 1} {$i<=$::N} {incr i} {\n      append sql \"  INSERT INTO vt$i VALUES(NEW.a+$i*100);\\n\"\n    }\n    for {set i 1} {$i<=$::N} {incr i} {\n      append sql \"  INSERT INTO vt$i VALUES(NEW.a+$i*10000);\\n\"\n    }\n    append sql \"END;\"\n    execsql $sql\n    execsql {SELECT count(*) FROM sqlite_master}\n  } [expr {$N*2+3}]\n  do_test vtabC-1.$N.8 {\n    execsql {\n      INSERT INTO m VALUES(9000000);\n      SELECT * FROM m;\n    }\n  } {1000 9000000}\n  unset -nocomplain res\n  for {set j 1} {$j<=$::N} {incr j} {\n    set res [expr {$j+1000}]\n    lappend res [expr {$j*100+9000000}]\n    lappend res [expr {$j*10000+9000000}]\n    lappend res [expr {$j+9000000}]\n    do_test vtabC-1.$N.9.$j {\n      execsql \"SELECT * FROM t$::j\"\n    } $res\n    do_test vtabC-1.$N.10.$j {\n      execsql \"SELECT * FROM vt$::j\"\n    } $res\n  }\n}\nunset -nocomplain res N i j\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabD.test",
    "content": "# 2009 April 14\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is creating and dropping virtual tables.\n#\n# $Id: vtabD.test,v 1.3 2009/06/05 17:09:12 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab||!schema_pragmas { finish_test ; return }\n\n# Register the echo module\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test vtabD-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n    CREATE VIRTUAL TABLE tv1 USING echo(t1);\n  }\n} {}\ndo_test vtabD-1.2 {\n  execsql BEGIN\n  for {set i 0} {$i < 100000} {incr i} {\n    execsql { INSERT INTO t1 VALUES($i, $i*$i) }\n  }\n  execsql COMMIT\n} {}\ndo_test vtabD-1.3 {\n  execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 4 }\n} {1 1 2 4}\ndo_test vtabD-1.4 {\n  execsql { SELECT * FROM tv1 WHERE a = 1 OR b = 1 }\n} {1 1}\ndo_test vtabD-1.5 {\n  execsql { SELECT * FROM tv1 WHERE (a > 0 AND a < 5) OR (b > 15 AND b < 65) }\n} {1 1 2 4 3 9 4 16 5 25 6 36 7 49 8 64}\n\ndo_test vtabD-1.6 {\n  execsql { SELECT * FROM tv1 WHERE a < 500 OR b = 810000 }\n} [execsql {\n  SELECT * FROM t1 WHERE a < 500;\n  SELECT * FROM t1 WHERE b = 810000 AND NOT (a < 500);\n}]\n\ndo_test vtabD-1.7 {\n  execsql { SELECT * FROM tv1 WHERE a < 90000 OR b = 8100000000 }\n} [execsql {\n  SELECT * FROM t1 WHERE a < 90000;\n  SELECT * FROM t1 WHERE b = 8100000000 AND NOT (a < 90000);\n}]\n\nif {[working_64bit_int]} {\ndo_test vtabD-1.8 {\n  execsql { SELECT * FROM tv1 WHERE a = 90001 OR b = 810000 }\n} {90001 8100180001 900 810000}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabE.test",
    "content": "# 2009 November 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# The focus of this file making sure the register cache logic works\n# correctly with virtual tables.  Ticket [16fbf14cb2].\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_tclvar_module [sqlite3_connection_pointer db]\n\nunset -nocomplain vtabE\nset vtabE(vtabE1) 11\nset vtabE(vtabE2) 22\nunset -nocomplain vtabE1\nset vtabE1(w) x\nset vtabE1(y) z\nunset -nocomplain vtabE2\nset vtabE2(a) b\nset vtabE2(c) d\n\ndo_test vtabE-1 {\n  db eval {\n    CREATE VIRTUAL TABLE t1 USING tclvar;\n    CREATE VIRTUAL TABLE t2 USING tclvar;\n    CREATE TABLE t3(a INTEGER PRIMARY KEY, b);\n    SELECT t1.name, t1.arrayname, t1.value,\n           t2.name, t2.arrayname, t2.value,\n           abs(t3.b + abs(t2.value + abs(t1.value)))\n      FROM t1 LEFT JOIN t2 ON t2.name = t1.arrayname\n           LEFT JOIN t3 ON t3.a=t2.value\n     WHERE t1.name = 'vtabE'\n     ORDER BY t1.value, t2.value;\n  }\n} {vtabE vtabE1 11 vtabE1 w x {} vtabE vtabE1 11 vtabE1 y z {} vtabE vtabE2 22 vtabE2 a b {} vtabE vtabE2 22 vtabE2 c d {}}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabF.test",
    "content": "# 2011 Aug 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. \n# This file checks to make sure IS NOT NULL constraints work on\n# virtual tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab||!schema_pragmas { finish_test ; return }\n\n# Register the echo module\nregister_echo_module [sqlite3_connection_pointer db]\n\ndo_test vtabF-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n    INSERT INTO t1 VALUES(10,110);\n    INSERT INTO t1 VALUES(11,111);\n    INSERT INTO t1 SELECT a+2, b+2 FROM t1;\n    INSERT INTO t1 SELECT null, b+4 FROM t1;\n    INSERT INTO t1 SELECT null, b+8 FROM t1;\n    INSERT INTO t1 SELECT null, b+16 FROM t1;\n    ANALYZE;\n    CREATE VIRTUAL TABLE tv1 USING echo(t1);\n    SELECT b FROM t1 WHERE a IS NOT NULL;\n  }\n} {110 111 112 113}\ndo_test vtabF-1.2 {\n  execsql {SELECT b FROM tv1 WHERE a IS NOT NULL}\n} {110 111 112 113}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabH.test",
    "content": "# 2015 Nov 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests that the GLOB, LIKE and REGEXP operators are correctly exposed\n# to virtual table implementations.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtabH\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_echo_module db\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t6(a, b TEXT);\n  CREATE INDEX i6 ON t6(b, a);\n  CREATE VIRTUAL TABLE e6 USING echo(t6);\n}\n\nforeach {tn sql expect} {\n  1 \"SELECT * FROM e6 WHERE b LIKE '8abc'\" {\n    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b like ?}\n    xFilter {SELECT rowid, a, b FROM 't6' WHERE b like ?} 8abc\n  }\n\n  2 \"SELECT * FROM e6 WHERE b GLOB '8abc'\" {\n    xBestIndex {SELECT rowid, a, b FROM 't6' WHERE b glob ?}\n    xFilter {SELECT rowid, a, b FROM 't6' WHERE b glob ?} 8abc\n  }\n} {\n  do_test 1.$tn {\n    set echo_module {}\n    execsql $sql\n    set ::echo_module\n  } [list {*}$expect]\n}\n\n\n#--------------------------------------------------------------------------\n\nregister_tclvar_module db\nset ::xyz 10\ndo_execsql_test 2.0 {\n  CREATE VIRTUAL TABLE vars USING tclvar;\n  SELECT name, arrayname, value FROM vars WHERE name = 'xyz';\n} {xyz {} 10}\n\nset x1 aback\nset x2 abaft\nset x3 abandon\nset x4 abandonint\nset x5 babble\nset x6 baboon\nset x7 backbone\nset x8 backarrow\nset x9 castle\n\ndb func glob -argcount 2 gfunc\nproc gfunc {a b} {\n  incr ::gfunc\n  return 1\n}\n\ndb func like -argcount 2 lfunc\nproc lfunc {a b} {\n  incr ::gfunc 100\n  return 1\n}\n\ndb func regexp -argcount 2 rfunc\nproc rfunc {a b} {\n  incr ::gfunc 10000\n  return 1\n}\n\nforeach ::tclvar_set_omit {0 1} {\n  foreach {tn expr res cnt} {\n    1 {value GLOB 'aban*'} {x3 abandon x4 abandonint} 2\n    2 {value LIKE '%ac%'}  {x1 aback x7 backbone x8 backarrow} 300\n    3 {value REGEXP '^......$'}  {x5 babble x6 baboon x9 castle} 30000\n  } {\n    db cache flush\n    set ::gfunc 0\n    if {$::tclvar_set_omit} {set cnt 0}\n\n    do_test 2.$tclvar_set_omit.$tn.1 {\n      execsql \"SELECT name, value FROM vars WHERE name MATCH 'x*' AND $expr\"\n    } $res\n\n    do_test 2.$tclvar_set_omit.$tn.2 {\n      set ::gfunc\n    } $cnt\n  }\n}\n\n#-------------------------------------------------------------------------\n#\nif {$tcl_platform(platform)==\"windows\"} {\n  set drive [string range [pwd] 0 1]\n  set ::env(fstreeDrive) $drive\n}\nif {$tcl_platform(platform)!=\"windows\" || \\\n    [regexp -nocase -- {^[A-Z]:} $drive]} {\n  reset_db\n  register_fs_module db\n  do_execsql_test 3.0 {\n    SELECT name FROM fsdir WHERE dir = '.' AND name = 'test.db';\n    SELECT name FROM fsdir WHERE dir = '.' AND name = '.'\n  } {test.db .}\n\n  proc sort_files { names {nocase false} } {\n    if {$nocase && $::tcl_platform(platform) eq \"windows\"} {\n      return [lsort -nocase $names]\n    } else {\n      return [lsort $names]\n    }\n  }\n\n  proc list_root_files {} {\n    if {$::tcl_platform(platform) eq \"windows\"} {\n      set res [list]; set dir $::env(fstreeDrive)/; set names [list]\n      eval lappend names [glob -nocomplain -directory $dir -- *]\n      foreach name $names {\n        if {[string index [file tail $name] 0] eq \".\"} continue\n        if {[file attributes $name -hidden]} continue\n        if {[file attributes $name -system]} continue\n        lappend res $name\n      }\n      return [sort_files $res true]\n    } else {\n      return [sort_files [string map {/ {}} [glob -nocomplain -- /*]]]\n    }\n  }\n\n  proc list_files { pattern } {\n    if {$::tcl_platform(platform) eq \"windows\"} {\n      set res [list]; set names [list]\n      eval lappend names [glob -nocomplain -- $pattern]\n      foreach name $names {\n        if {[string index [file tail $name] 0] eq \".\"} continue\n        if {[file attributes $name -hidden]} continue\n        if {[file attributes $name -system]} continue\n        lappend res $name\n      }\n      return [sort_files $res]\n    } else {\n      return [sort_files [glob -nocomplain -- $pattern]]\n    }\n  }\n\n  # Read the first 5 entries from the root directory.  Except, ignore\n  # files that contain the \"$\" character in their names as these are\n  # special files on some Windows platforms.\n  #\n  set res [list]\n  set root_files [list_root_files]\n  foreach p $root_files {\n    if {$::tcl_platform(platform) eq \"windows\"} {\n      if {![regexp {\\$} $p]} {lappend res $p}\n    } else {\n      lappend res \"/$p\"\n    }\n  }\n  set num_root_files [llength $root_files]\n  do_test 3.1 {\n    sort_files [execsql {\n      SELECT path FROM fstree WHERE path NOT GLOB '*\\$*' LIMIT $num_root_files;\n    }] true\n  } [sort_files $res true]\n\n  # Read all entries in the current directory.\n  #\n  proc contents {pattern} {\n    set res [list]\n    foreach f [list_files $pattern] {\n      lappend res $f\n      if {[file isdir $f]} {\n        set res [concat $res [contents \"$f/*\"]]\n      }\n    }\n    set res\n  }\n  set pwd \"[pwd]/*\"\n  set res [contents $pwd]\n  do_execsql_test 3.2 {\n    SELECT path FROM fstree WHERE path GLOB $pwd ORDER BY 1\n  } [sort_files $res]\n\n  # Add some sub-directories and files to the current directory.\n  #\n  do_test 3.3 {\n    catch { file delete -force subdir }\n    foreach {path sz} {\n      subdir/x1.txt     143\n      subdir/x2.txt     153\n    } {\n      set dir [file dirname $path]\n      catch { file mkdir $dir }\n      set fd [open $path w]\n      puts -nonewline $fd [string repeat 1 $sz]\n      close $fd\n    }\n  } {}\n\n  set pwd [pwd]\n  if {![string match {*[_%]*} $pwd]} {\n    do_execsql_test 3.5 {\n      SELECT path, size FROM fstree \n       WHERE path GLOB $pwd || '/subdir/*' ORDER BY 1\n    } [list \\\n      \"$pwd/subdir/x1.txt\" 143 \\\n      \"$pwd/subdir/x2.txt\" 153 \\\n    ]\n    do_execsql_test 3.6 {\n      SELECT path, size FROM fstree\n       WHERE path LIKE $pwd || '/subdir/%' ORDER BY 1\n    } [list \\\n      \"$pwd/subdir/x1.txt\" 143 \\\n      \"$pwd/subdir/x2.txt\" 153 \\\n    ]\n    do_execsql_test 3.7 {\n      SELECT sum(size) FROM fstree WHERE path LIKE $pwd || '/subdir/%'\n    } 296\n    do_execsql_test 3.8 {\n      SELECT size FROM fstree WHERE path = $pwd || '/subdir/x1.txt'\n    } 143\n  }\n\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabI.test",
    "content": "# 2015 Nov 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. Specifically,\n# it tests the sqlite3_index_info.colUsed variable is set correctly.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtabI\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_echo_module db\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, d, e);\n  CREATE VIRTUAL TABLE e1 USING echo(t1);\n}\n\nforeach {tn query filter} {\n  1 {SELECT * FROM e1} \n    {SELECT rowid, a, b, c, d, e FROM 't1'}\n\n  2 {SELECT a, b FROM e1} \n    {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}\n\n  3 {SELECT count(*) FROM e1 GROUP BY b} \n    {SELECT rowid, NULL, b, NULL, NULL, NULL FROM 't1'}\n\n  4 {SELECT count(*) FROM e1 GROUP BY b HAVING a=?} \n    {SELECT rowid, a, b, NULL, NULL, NULL FROM 't1'}\n\n  5 {SELECT a FROM e1 WHERE c=?}\n    {SELECT rowid, a, NULL, c, NULL, NULL FROM 't1'}\n\n  6 {SELECT a FROM e1 ORDER BY e}\n    {SELECT rowid, a, NULL, NULL, NULL, e FROM 't1'}\n\n  7 {SELECT a FROM e1 ORDER BY e, d}\n    {SELECT rowid, a, NULL, NULL, d, e FROM 't1'}\n} {\n  do_test 1.$tn {\n    set ::echo_module [list]\n    execsql $query\n    set idx [lsearch -exact $::echo_module xFilter]\n    lindex $::echo_module [expr $idx+1]\n  } $filter\n}\n\n#-------------------------------------------------------------------------\n# Tests with a table with more than 64 columns.\n#\nproc all_col_list {} {\n  set L [list]\n  for {set i 1} {$i <= 100} {incr i} { lappend L \"c$i\" }\n  set L\n}\n\nproc part_col_list {cols} {\n  set L [list]\n  for {set i 1} {$i <= 100} {incr i} { \n    set c \"c$i\"\n    if {[lsearch $cols $c]>=0} {\n      lappend L \"c$i\" \n    } else {\n      lappend L NULL\n    }\n  }\n  set L\n}\nproc CL {args} {\n  join [part_col_list $args] \", \"\n}\nproc CLT {args} {\n  set cols $args\n  for {set i 64} {$i <= 100} {incr i} {\n    lappend cols \"c$i\"\n  }\n  join [part_col_list $cols] \", \"\n}\n\ndo_test 2.0 {\n  execsql \"CREATE TABLE t2([join [all_col_list] ,])\"\n  execsql \"CREATE VIRTUAL TABLE e2 USING echo(t2)\"\n} {}\n\nforeach {tn query filter} {\n  1 {SELECT c1, c10, c20 FROM e2} \n    {SELECT rowid, [CL c1 c10 c20] FROM 't2'}\n\n  2 {SELECT c40, c50, c60 FROM e2} \n    {SELECT rowid, [CL c40 c50 c60] FROM 't2'}\n\n  3 {SELECT c7, c80, c90 FROM e2} \n    {SELECT rowid, [CLT c7] FROM 't2'}\n\n  4 {SELECT c64 FROM e2} \n    {SELECT rowid, [CLT c64] FROM 't2'}\n\n  5 {SELECT c63 FROM e2} \n    {SELECT rowid, [CL c63] FROM 't2'}\n\n  6 {SELECT c22 FROM e2 ORDER BY c50, c70} \n    {SELECT rowid, [CLT c22 c50] FROM 't2'}\n\n} {\n  do_test 2.$tn {\n    set ::echo_module [list]\n    execsql $query\n    set idx [lsearch -exact $::echo_module xFilter]\n    lindex $::echo_module [expr $idx+1]\n  } [subst $filter]\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtabJ.test",
    "content": "# 2017-08-10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements tests of writing to WITHOUT ROWID virtual tables\n# using the tclvar eponymous virtual table.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtabJ\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\nregister_tclvar_module db\n\nunset -nocomplain vtabJ\ndo_test 100 {\n  set vtabJ(1) this\n  set vtabJ(two) is\n  set vtabJ(3) {a test}\n  db eval {\n    SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;\n  }\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(two) is}\n\ndo_execsql_test 110 {\n  INSERT INTO tclvar(fullname, value)\n    VALUES('vtabJ(4)',4),('vtabJ(five)',555);\n  SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}\ndo_test 111 {\n  set res {}\n  foreach vname [lsort [array names vtabJ]] {\n    lappend res vtabJ($vname) $vtabJ($vname)\n  }\n  set res\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(4) 4 vtabJ(five) 555 vtabJ(two) is}\n\ndo_test 120 {\n  db eval {\n    INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',444);\n  }\n  set vtabJ(4)\n} {444}\n\ndo_test 130 {\n  db eval {\n    INSERT INTO tclvar(fullname, value) VALUES('vtabJ(4)',NULL);\n  }\n  info exists vtabJ(4)\n} {0}\n\ndo_test 140 {\n  db eval {\n    UPDATE tclvar SET value=55 WHERE fullname='vtabJ(five)';\n  }\n  set vtabJ(five)\n} {55}\n\ndo_test 150 {\n  db eval {\n    UPDATE tclvar SET fullname='vtabJ(5)' WHERE fullname='vtabJ(five)';\n  }\n  set vtabJ(5)\n} {55}\ndo_test 151 {\n  info exists vtabJ(five)\n} {0}\ndo_test 152 {\n  set res {}\n  foreach vname [lsort [array names vtabJ]] {\n    lappend res vtabJ($vname) $vtabJ($vname)\n  }\n  set res\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55 vtabJ(two) is}\n\ndo_execsql_test 160 {\n  SELECT fullname FROM tclvar WHERE arrayname='two'\n} {vtabJ(two)}\ndo_execsql_test 161 {\n  DELETE FROM tclvar WHERE arrayname='two';\n  SELECT fullname, value FROM tclvar WHERE name='vtabJ' ORDER BY fullname;\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}\ndo_test 162 {\n  set res {}\n  foreach vname [lsort [array names vtabJ]] {\n    lappend res vtabJ($vname) $vtabJ($vname)\n  }\n  set res\n} {vtabJ(1) this vtabJ(3) {a test} vtabJ(5) 55}\n\n# Try to trick the module into updating the same variable twice for a\n# single UPDATE statement.\n#\ndo_execsql_test 171 {\n  INSERT INTO tclvar(fullname, value) VALUES('xx', 'a');\n  SELECT name, value FROM tclvar where name = 'xx';\n} {xx a}\ndo_execsql_test 172 {\n  UPDATE tclvar SET value = value || 't' \n  WHERE name = 'xx' OR name = 'x'||'x';\n  SELECT name, value FROM tclvar where name = 'xx';\n} {xx at}\ndo_execsql_test 173 {\n  UPDATE tclvar SET value = value || 't' \n  WHERE name = 'xx' OR name BETWEEN 'xx' AND 'xx';\n  SELECT name, value FROM tclvar where name = 'xx';\n} {xx att}\n\ndo_execsql_test 181 {\n  DELETE FROM tclvar WHERE name BETWEEN 'xx' AND 'xx' OR name='xx';\n  SELECT name, value FROM tclvar where name = 'xx';\n} {}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab_alter.test",
    "content": "# 2007 June 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the ALTER TABLE ... RENAME TO\n# command on virtual tables.\n#\n# $Id: vtab_alter.test,v 1.3 2007/12/13 21:54:11 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab||!altertable {\n  finish_test\n  return\n}\n\n# Register the echo module.\n#\n# This test uses a special feature of the echo module. If the name\n# of the virtual table is a prefix of the name of the underlying\n# real table (for example if the v-table is \"tbl\" and the real table\n# is \"tbl_base\"), then the name of the real table is modified\n# when an \"ALTER TABLE ... RENAME TO\" is executed on the v-table.\n# For example:\n#\n#   sqlite> CREATE TABLE t1_base(a, b, c); \n#   sqlite> CREATE VIRTUAL TABLE t1 USING(t1_base);\n#   sqlite> ALTER TABLE t1 RENAME TO t2;\n#   sqlite> SELECT tbl_name FROM sqlite_master;\n#   t2_base\n#   t2\n#\nregister_echo_module [sqlite3_connection_pointer db]\n\n\n# Try to rename an echo table. Make sure nothing terrible happens.\n#\ndo_test vtab_alter-1.1 {\n  execsql { CREATE TABLE t1(a, b VARCHAR, c INTEGER) }\n} {}\ndo_test vtab_alter-1.2 {\n  execsql { CREATE VIRTUAL TABLE t1echo USING echo(t1) }\n} {}\ndo_test vtab_alter-1.3 {\n  catchsql { SELECT * FROM t1echo }\n} {0 {}}\ndo_test vtab_alter-1.4 {\n  execsql { ALTER TABLE t1echo RENAME TO new }\n} {}\ndo_test vtab_alter-1.5 {\n  catchsql { SELECT * FROM t1echo }\n} {1 {no such table: t1echo}}\ndo_test vtab_alter-1.6 {\n  catchsql { SELECT * FROM new }\n} {0 {}}\n\n# Try to rename an echo table that renames its base table. Make \n# sure nothing terrible happens.\n#\ndo_test vtab_alter-2.1 {\n  execsql { \n    DROP TABLE new;\n    DROP TABLE t1;\n    CREATE TABLE t1_base(a, b, c);\n    CREATE VIRTUAL TABLE t1 USING echo('*_base');\n  }\n} {}\ndo_test vtab_alter-2.2 {\n  execsql { \n    INSERT INTO t1_base VALUES(1, 2, 3);\n    SELECT * FROM t1;\n  }\n} {1 2 3}\ndo_test vtab_alter-2.3 {\n  execsql { ALTER TABLE t1 RENAME TO x }\n} {}\ndo_test vtab_alter-2.4 {\n  execsql { SELECT * FROM x; }\n} {1 2 3}\ndo_test vtab_alter-2.5 {\n  execsql { SELECT * FROM x_base; }\n} {1 2 3}\n\n# Cause an error to occur when the echo module renames its\n# backing store table.\n#\ndo_test vtab_alter-3.1 {\n  execsql  { CREATE TABLE y_base(a, b, c) }\n  catchsql { ALTER TABLE x RENAME TO y }\n} {1 {SQL logic error}}\ndo_test vtab_alter-3.2 {\n  execsql  { SELECT * FROM x }\n} {1 2 3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab_err.test",
    "content": "# 2006 June 10\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# $Id: vtab_err.test,v 1.8 2007/09/03 16:12:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n\n\nunset -nocomplain echo_module_begin_fail\ndo_ioerr_test vtab_err-1 -tclprep {\n  register_echo_module [sqlite3_connection_pointer db]\n} -sqlbody {\n  BEGIN;\n  CREATE TABLE r(a PRIMARY KEY, b, c);\n  CREATE VIRTUAL TABLE e USING echo(r);\n  INSERT INTO e VALUES(1, 2, 3);\n  INSERT INTO e VALUES('a', 'b', 'c');\n  UPDATE e SET c = 10;\n  DELETE FROM e WHERE a = 'a';\n  COMMIT;\n  BEGIN;\n    CREATE TABLE r2(a, b, c);\n    INSERT INTO r2 SELECT * FROM e;\n    INSERT INTO e SELECT a||'x', b, c FROM r2;\n  COMMIT;\n}\n\nifcapable !memdebug {\n   puts \"Skipping vtab_err-2 tests: not compiled with -DSQLITE_MEMDEBUG...\"\n   finish_test\n   return\n}\nsource $testdir/malloc_common.tcl\n\n\ndo_malloc_test vtab_err-2 -tclprep { \n  register_echo_module [sqlite3_connection_pointer db]\n} -sqlbody {\n  BEGIN;\n  CREATE TABLE r(a PRIMARY KEY, b, c);\n  CREATE VIRTUAL TABLE e USING echo(r);\n  INSERT INTO e VALUES(1, 2, 3);\n  INSERT INTO e VALUES('a', 'b', 'c');\n  UPDATE e SET c = 10;\n  DELETE FROM e WHERE a = 'a';\n  COMMIT;\n  BEGIN;\n    CREATE TABLE r2(a, b, c);\n    INSERT INTO r2 SELECT * FROM e;\n    INSERT INTO e SELECT a||'x', b, c FROM r2;\n  COMMIT;\n} \n\nsqlite3_memdebug_fail -1\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/vtab_shared.test",
    "content": "# 2007 April 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file tests interactions between the virtual table and\n# shared-schema functionality.\n#\n# $Id: vtab_shared.test,v 1.3 2009/07/24 17:58:53 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix vtab_shared\n\nifcapable !vtab||!shared_cache {\n  finish_test\n  return\n}\n\ndb close\nsqlite3_enable_shared_cache 1\nsqlite3 db  test.db\nsqlite3 db2 test.db\n\ndo_test vtab_shared-1.1 {\n  register_echo_module [sqlite3_connection_pointer db]\n  execsql {\n    CREATE TABLE t0(a, b, c);\n    INSERT INTO t0 VALUES(1, 2, 3);\n    CREATE VIRTUAL TABLE t1 USING echo(t0);\n  }\n} {}\n\ndo_test vtab_shared-1.2 {\n  execsql { SELECT * FROM t1 } db\n} {1 2 3}\n\n# Fails because the 'echo' module has not been registered with connection db2\ndo_test vtab_shared-1.3 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {no such module: echo}}\n\ndo_test vtab_shared-1.4 {\n  execsql { SELECT * FROM t0 } db2\n} {1 2 3}\n\ndo_test vtab_shared-1.5 {\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { SELECT * FROM t1 } db\n} {1 2 3}\n\n# Works after the module is registered with db2\ndo_test vtab_shared-1.6 {\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3}\n\n# Set a write-lock on table t0 using connection [db]. Then try to read from\n# virtual table t1 using [db2]. That this returns an SQLITE_LOCKED error\n# shows that the correct sqlite3_vtab is being used.\n#\ndo_test vtab_shared-1.8.1 {\n  execsql { \n    BEGIN;\n    INSERT INTO t1 VALUES(4, 5, 6);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6}\ndo_test vtab_shared-1.8.2 {\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database table is locked}}\ndo_test vtab_shared-1.8.3 {\n  catchsql { SELECT *  FROM t0 } db2\n} {1 {database table is locked: t0}}\ndo_test vtab_shared-1.8.4 {\n  execsql { SELECT * FROM t0 } db\n} {1 2 3 4 5 6}\ndo_test vtab_shared-1.8.5 {\n  execsql { COMMIT } db\n  execsql { SELECT *  FROM t1 } db2\n} {1 2 3 4 5 6}\n\n# While a SELECT is active on virtual table t1 via connection [db], close \n# [db2]. This causes the schema to be reset internally. Verify that this\n# does not cause a problem.\n#\nforeach {iTest dbSelect dbClose} {\n  1 db  db2\n  2 db  db2\n  3 db2 db\n} {\n  do_test vtab_shared-1.9.$iTest {\n    set res [list]\n    $dbSelect eval { SELECT * FROM t1 } {\n      if {$a == 1} {$dbClose close}\n      lappend res $a $b $c\n    }\n    sqlite3 $dbClose test.db\n    register_echo_module [sqlite3_connection_pointer $dbClose]\n    set res\n  } {1 2 3 4 5 6}\n}\n\n# Ensure that it is not possible for one connection to DROP a virtual\n# table while a second connection is reading from the database.\n#\ndo_test vtab_shared-1.10 {\n  db eval { SELECT * FROM t1 } {\n    set error [catchsql { DROP TABLE t1 } db2]\n    break\n  }\n  set error\n} {1 {database table is locked: sqlite_master}}\n\ndo_test vtab_shared-1.11 {\n  execsql {\n    CREATE VIRTUAL TABLE t2 USING echo(t0);\n    CREATE VIRTUAL TABLE t3 USING echo(t0);\n  }\n  execsql { SELECT * FROM t3 } db2\n} {1 2 3 4 5 6}\n\nifcapable compound {\n  do_test vtab_shared-1.12.1 {\n    db close\n    execsql { \n      SELECT * FROM t1 UNION ALL\n      SELECT * FROM t2 UNION ALL\n      SELECT * FROM t3 \n    } db2\n  } {1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6}\n  do_test vtab_shared-1.12.2 {\n    sqlite3 db test.db\n    register_echo_module [sqlite3_connection_pointer db]\n    execsql { \n      SELECT * FROM t1 UNION ALL\n      SELECT * FROM t2 UNION ALL\n      SELECT * FROM t3 \n    } db\n  } {1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6}\n}\n\n# Try a rename or two.\n#\nifcapable altertable {\n  do_test vtab_shared-1.13.1 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT * FROM t4 } db\n  } {1 2 3 4 5 6}\n  do_test vtab_shared-1.13.2 {\n    execsql { SELECT * FROM t4 } db2\n  } {1 2 3 4 5 6}\n  do_test vtab_shared-1.13.3 {\n    execsql { ALTER TABLE t2 RENAME TO t5 }\n    execsql { SELECT * FROM t4 } db2\n  } {1 2 3 4 5 6}\n}\n\n# Try an UPDATE/INSERT/DELETE on a shared vtab as the first statement after a\n# schema is loaded.\ndo_test vtab_shared_1.14.1 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { SELECT * FROM t3 }\n} {1 2 3 4 5 6}\ndo_test vtab_shared_1.14.2 {\n  execsql { \n    UPDATE t3 SET c = 'six' WHERE c = 6;\n    SELECT * FROM t3;\n  } db2\n} {1 2 3 4 5 six}\ndo_test vtab_shared_1.14.3 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { SELECT * FROM t3 }\n} {1 2 3 4 5 six}\ndo_test vtab_shared_1.14.4 {\n  execsql { \n    DELETE FROM t3 WHERE c = 'six';\n    SELECT * FROM t3;\n  } db2\n} {1 2 3}\ndo_test vtab_shared_1.14.5 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { SELECT * FROM t3 }\n} {1 2 3}\ndo_test vtab_shared_1.14.6 {\n  execsql { \n    INSERT INTO t3 VALUES(4, 5, 6);\n    SELECT * FROM t3;\n  } db2\n} {1 2 3 4 5 6}\n\ndo_test vtab_shared_1.15.1 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { \n    UPDATE t3 SET c = 'six' WHERE c = 6;\n    SELECT * FROM t3;\n  } db2\n} {1 2 3 4 5 six}\ndo_test vtab_shared_1.15.2 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { \n    DELETE FROM t3 WHERE c = 'six';\n    SELECT * FROM t3;\n  } db2\n} {1 2 3}\ndo_test vtab_shared_1.15.3 {\n  db2 close\n  sqlite3 db2 test.db\n  register_echo_module [sqlite3_connection_pointer db2]\n  execsql { \n    INSERT INTO t3 VALUES(4, 5, 6);\n    SELECT * FROM t3;\n  }\n} {1 2 3 4 5 6}\n\ndb close\ndb2 close\n\n#---------------------------------------------------------------\n# Test calling sqlite3_close() with vtabs on the disconnect list.\n#\nifcapable rtree {\n  reset_db\n  do_test 2.1.1 {\n    sqlite3 db  test.db\n    sqlite3 db2 test.db\n  \n    # Create a virtual table using [db]. \n    execsql {\n      CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2);\n      INSERT INTO rt VALUES(1, 2 ,3);\n      SELECT * FROM rt;\n    }\n  \n    # Drop the virtual table using [db2]. The sqlite3_vtab object belonging\n    # to [db] is moved to the sqlite3.pDisconnect list.\n    execsql { DROP TABLE rt } db2\n  \n    # Immediately close [db]. At one point this would fail due to the \n    # unfinalized statements held by the un-xDisconnect()ed sqlite3_vtab.\n    db close\n  } {}\n  db2 close\n}\n\nifcapable fts3 {\n  # Same test as above, except using fts3 instead of rtree.\n  reset_db\n  do_test 2.2.1 {\n    sqlite3 db  test.db\n    sqlite3 db2 test.db\n    execsql {\n      CREATE VIRTUAL TABLE ft USING fts3;\n      INSERT INTO ft VALUES('hello world');\n      SELECT * FROM ft;\n    } \n    execsql { DROP TABLE ft } db2\n    db close\n  } {}\n  db2 close\n}\n\nsqlite3_enable_shared_cache 0\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal.test",
    "content": "# 2010 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/wal_common.tcl\n\nset testprefix wal\n\nifcapable !wal {finish_test ; return }\ntest_set_config_pagecache 0 0\n\nproc reopen_db {} {\n  catch { db close }\n  forcedelete test.db test.db-wal test.db-wal-summary\n  sqlite3_wal db test.db\n}\n\nset ::blobcnt 0\nproc blob {nByte} {\n  incr ::blobcnt\n  return [string range [string repeat \"${::blobcnt}x\" $nByte] 1 $nByte]\n}\n\nproc sqlite3_wal {args} {\n  eval sqlite3 $args\n  [lindex $args 0] eval { PRAGMA auto_vacuum = 0 }\n  [lindex $args 0] eval { PRAGMA page_size = 1024 }\n  [lindex $args 0] eval { PRAGMA journal_mode = wal }\n  [lindex $args 0] eval { PRAGMA synchronous = normal }\n  [lindex $args 0] function blob blob\n}\n\nproc log_deleted {logfile} {\n  return [expr [file exists $logfile]==0]\n}\n\n#\n# These are 'warm-body' tests used while developing the WAL code. They\n# serve to prove that a few really simple cases work:\n#\n# wal-1.*: Read and write the database.\n# wal-2.*: Test MVCC with one reader, one writer.\n# wal-3.*: Test transaction rollback.\n# wal-4.*: Test savepoint/statement rollback.\n# wal-5.*: Test the temp database.\n# wal-6.*: Test creating databases with different page sizes.\n#\n#\n#\ndo_test wal-0.1 {\n  execsql { PRAGMA auto_vacuum = 0 }\n  execsql { PRAGMA synchronous = normal }\n  execsql { PRAGMA journal_mode = wal }\n} {wal}\ndo_test wal-0.2 {\n  file size test.db\n} {1024}\n\ndo_test wal-1.0 {\n  execsql { \n    BEGIN;\n    CREATE TABLE t1(a, b); \n  }\n  list [file exists test.db-journal] \\\n       [file exists test.db-wal]     \\\n       [file size test.db]\n} {0 1 1024}\ndo_test wal-1.1 {\n  execsql COMMIT\n  list [file exists test.db-journal] [file exists test.db-wal]\n} {0 1}\ndo_test wal-1.2 {\n  # There are now two pages in the log.\n  file size test.db-wal\n} [wal_file_size 2 1024]\n\ndo_test wal-1.3 {\n  execsql { SELECT * FROM sqlite_master }\n} {table t1 t1 2 {CREATE TABLE t1(a, b)}}\n\ndo_test wal-1.4 {\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  execsql { INSERT INTO t1 VALUES(3, 4) }\n  execsql { INSERT INTO t1 VALUES(5, 6) }\n  execsql { INSERT INTO t1 VALUES(7, 8) }\n  execsql { INSERT INTO t1 VALUES(9, 10) }\n} {}\n\ndo_test wal-1.5 {\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_test wal-2.1 {\n  sqlite3_wal db2 ./test.db\n  execsql { BEGIN; SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_test wal-2.2 {\n  execsql { INSERT INTO t1 VALUES(11, 12) }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\n\ndo_test wal-2.3 {\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_test wal-2.4 {\n  execsql { INSERT INTO t1 VALUES(13, 14) }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n\ndo_test wal-2.5 {\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_test wal-2.6 {\n  execsql { COMMIT; SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n\ndo_test wal-3.1 {\n  execsql { BEGIN; DELETE FROM t1 }\n  execsql { SELECT * FROM t1 }\n} {}\ndo_test wal-3.2 {\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\ndo_test wal-3.3 {\n  execsql { ROLLBACK }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\ndb2 close\n\n#-------------------------------------------------------------------------\n# The following tests, wal-4.*, test that savepoints work with WAL \n# databases.\n#\ndo_test wal-4.1 {\n  execsql {\n    DELETE FROM t1;\n    BEGIN;\n      INSERT INTO t1 VALUES('a', 'b');\n      SAVEPOINT sp;\n        INSERT INTO t1 VALUES('c', 'd');\n        SELECT * FROM t1;\n  }\n} {a b c d}\ndo_test wal-4.2 {\n  execsql {\n      ROLLBACK TO sp;\n      SELECT * FROM t1;\n  }\n} {a b}\ndo_test wal-4.3 {\n  execsql {\n    COMMIT;\n    SELECT * FROM t1;\n  }\n} {a b}\n\ndo_test wal-4.4.1 {\n  db close\n  sqlite3 db test.db\n  db func blob blob\n  list [execsql { SELECT * FROM t1 }] [file size test.db-wal]\n} {{a b} 0}\ndo_test wal-4.4.2 {\n  execsql { PRAGMA cache_size = 10 }\n  execsql {\n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 VALUES(blob(400), blob(400));\n    SAVEPOINT tr;\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  2 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  4 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  8 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 16 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 32 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  2 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  4 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  8 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 16 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 32 */\n      SELECT count(*) FROM t2;\n  }\n} {32}\ndo_test wal-4.4.3 {\n  execsql { ROLLBACK TO tr }\n} {}\ndo_test wal-4.4.4 {\n  set logsize [file size test.db-wal]\n  execsql {\n      INSERT INTO t1 VALUES('x', 'y');\n    RELEASE tr;\n  }\n  expr { $logsize == [file size test.db-wal] }\n} {1}\ndo_test wal-4.4.5 {\n  execsql { SELECT count(*) FROM t2 }\n} {1}\ndo_test wal-4.4.6 {\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3 db2 test2.db\n  execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2\n} {1 2}\ndo_test wal-4.4.7 {\n  execsql { PRAGMA integrity_check } db2\n} {ok}\ndb2 close\n\ndo_test wal-4.5.1 {\n  reopen_db\n  db func blob blob\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES('a', 'b');\n  }\n  sqlite3 db test.db\n  db func blob blob\n  list [execsql { SELECT * FROM t1 }] [file size test.db-wal]\n} {{a b} 0}\ndo_test wal-4.5.2 {\n  execsql { PRAGMA cache_size = 10 }\n  execsql {\n    CREATE TABLE t2(a, b);\n    BEGIN;\n    INSERT INTO t2 VALUES(blob(400), blob(400));\n    SAVEPOINT tr;\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  2 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  4 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /*  8 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 16 */\n      INSERT INTO t2 SELECT blob(400), blob(400) FROM t2; /* 32 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  2 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  4 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /*  8 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 16 */\n      INSERT INTO t1 SELECT blob(400), blob(400) FROM t1; /* 32 */\n      SELECT count(*) FROM t2;\n  }\n} {32}\ndo_test wal-4.5.3 {\n  execsql { ROLLBACK TO tr }\n} {}\ndo_test wal-4.5.4 {\n  set logsize [file size test.db-wal]\n  execsql {\n      INSERT INTO t1 VALUES('x', 'y');\n    RELEASE tr;\n    COMMIT;\n  }\n  expr { $logsize == [file size test.db-wal] }\n} {1}\ndo_test wal-4.5.5 {\n  execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 }\n} {1 2}\ndo_test wal-4.5.6 {\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3 db2 test2.db\n  execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2\n} {1 2}\ndo_test wal-4.5.7 {\n  execsql { PRAGMA integrity_check } db2\n} {ok}\ndb2 close\n\ndo_test wal-4.6.1 {\n  execsql {\n    DELETE FROM t2;\n    PRAGMA wal_checkpoint;\n    BEGIN;\n      INSERT INTO t2 VALUES('w', 'x');\n      SAVEPOINT save;\n        INSERT INTO t2 VALUES('y', 'z');\n      ROLLBACK TO save;\n    COMMIT;\n  }\n  execsql { SELECT * FROM t2 }\n} {w x}\n\n\nreopen_db\ndo_test wal-5.1 {\n  execsql {\n    CREATE TEMP TABLE t2(a, b);\n    INSERT INTO t2 VALUES(1, 2);\n  }\n} {}\ndo_test wal-5.2 {\n  execsql {\n    BEGIN;\n      INSERT INTO t2 VALUES(3, 4);\n      SELECT * FROM t2;\n  }\n} {1 2 3 4}\ndo_test wal-5.3 {\n  execsql {\n    ROLLBACK;\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test wal-5.4 {\n  execsql {\n    CREATE TEMP TABLE t3(x UNIQUE);\n    BEGIN;\n      INSERT INTO t2 VALUES(3, 4);\n      INSERT INTO t3 VALUES('abc');\n  }\n  catchsql { INSERT INTO t3 VALUES('abc') }\n} {1 {UNIQUE constraint failed: t3.x}}\ndo_test wal-5.5 {\n  execsql {\n    COMMIT;\n    SELECT * FROM t2;\n  }\n} {1 2 3 4}\ndb close\n\nforeach sector {512 4096} {\n  sqlite3_simulate_device -sectorsize $sector\n  foreach pgsz {512 1024 2048 4096} {\n    forcedelete test.db test.db-wal\n    do_test wal-6.$sector.$pgsz.1 {\n      sqlite3 db test.db -vfs devsym\n      execsql \"\n        PRAGMA page_size = $pgsz;\n        PRAGMA auto_vacuum = 0;\n        PRAGMA journal_mode = wal;\n      \"\n      execsql \"\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n      \"\n      db close\n      file size test.db\n    } [expr $pgsz*2]\n  \n    do_test wal-6.$sector.$pgsz.2 {\n      log_deleted test.db-wal\n    } {1}\n  }\n}\n\ndo_test wal-7.1 {\n  forcedelete test.db test.db-wal\n  sqlite3_wal db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n  list [file size test.db] [file size test.db-wal]\n} [list 1024 [wal_file_size 3 1024]]\ndo_test wal-7.2 {\n  execsql { PRAGMA wal_checkpoint }\n  list [file size test.db] [file size test.db-wal]\n} [list 2048 [wal_file_size 3 1024]]\n\n# Execute some transactions in auto-vacuum mode to test database file\n# truncation.\n#\ndo_test wal-8.1 {\n  reopen_db\n  catch { db close }\n  forcedelete test.db test.db-wal\n\n  sqlite3 db test.db\n  db function blob blob\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA journal_mode = wal;\n    PRAGMA auto_vacuum;\n  }\n} {wal 1}\ndo_test wal-8.2 {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(blob(900));\n    INSERT INTO t1 VALUES(blob(900));\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /*  4 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /*  8 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 16 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 32 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 64 */\n    PRAGMA wal_checkpoint;\n  }\n  file size test.db\n} [expr 68*1024]\ndo_test wal-8.3 {\n  execsql { \n    DELETE FROM t1 WHERE rowid<54;\n    PRAGMA wal_checkpoint;\n  }\n  file size test.db\n} [expr 14*1024]\n\n# Run some \"warm-body\" tests to ensure that log-summary files with more\n# than 256 entries (log summaries that contain index blocks) work Ok.\n#\ndo_test wal-9.1 {\n  reopen_db\n  execsql {\n    PRAGMA cache_size=2000;\n    CREATE TABLE t1(x PRIMARY KEY);\n    INSERT INTO t1 VALUES(blob(900));\n    INSERT INTO t1 VALUES(blob(900));\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /*  4 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /*  8 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 16 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 32 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 64 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 128 */\n    INSERT INTO t1 SELECT blob(900) FROM t1;       /* 256 */\n  }\n  file size test.db\n} 1024\ndo_test wal-9.2 {\n  sqlite3_wal db2 test.db\n  execsql {PRAGMA integrity_check } db2\n} {ok}\n\ndo_test wal-9.3 {\n  forcedelete test2.db test2.db-wal\n  copy_file test.db test2.db\n  copy_file test.db-wal test2.db-wal\n  sqlite3_wal db3 test2.db \n  execsql {PRAGMA integrity_check } db3\n} {ok}\ndb3 close\n\ndo_test wal-9.4 {\n  execsql { PRAGMA wal_checkpoint }\n  db2 close\n  sqlite3_wal db2 test.db\n  execsql {PRAGMA integrity_check } db2\n} {ok}\n\nforeach handle {db db2 db3} { catch { $handle close } }\nunset handle\n\n#-------------------------------------------------------------------------\n# The following block of tests - wal-10.* - test that the WAL locking \n# scheme works in simple cases. This block of tests is run twice. Once\n# using multiple connections in the address space of the current process,\n# and once with all connections except one running in external processes.\n#\ndo_multiclient_test tn {\n\n  # Initialize the database schema and contents.\n  #\n  do_test wal-10.$tn.1 {\n    execsql {\n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = wal;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      SELECT * FROM t1;\n    }\n  } {wal 1 2}\n\n  # Open a transaction and write to the database using [db]. Check that [db2]\n  # is still able to read the snapshot before the transaction was opened.\n  #\n  do_test wal-10.$tn.2 {\n    execsql { BEGIN; INSERT INTO t1 VALUES(3, 4); }\n    sql2 {SELECT * FROM t1}\n  } {1 2}\n\n  # Have [db] commit the transaction. Check that [db2] is now seeing the \n  # new, updated snapshot.\n  #\n  do_test wal-10.$tn.3 {\n    execsql { COMMIT }\n    sql2 {SELECT * FROM t1}\n  } {1 2 3 4}\n\n  # Have [db2] open a read transaction. Then write to the db via [db]. Check\n  # that [db2] is still seeing the original snapshot. Then read with [db3].\n  # [db3] should see the newly committed data.\n  #\n  do_test wal-10.$tn.4 {\n    sql2 { BEGIN ; SELECT * FROM t1}\n  } {1 2 3 4}\n  do_test wal-10.$tn.5 {\n    execsql { INSERT INTO t1 VALUES(5, 6); }\n    sql2 {SELECT * FROM t1}\n  } {1 2 3 4}\n  do_test wal-10.$tn.6 {\n    sql3 {SELECT * FROM t1}\n  } {1 2 3 4 5 6}\n  do_test wal-10.$tn.7 {\n    sql2 COMMIT\n  } {}\n\n  # Have [db2] open a write transaction. Then attempt to write to the \n  # database via [db]. This should fail (writer lock cannot be obtained).\n  #\n  # Then open a read-transaction with [db]. Commit the [db2] transaction\n  # to disk. Verify that [db] still cannot write to the database (because\n  # it is reading an old snapshot).\n  #\n  # Close the current [db] transaction. Open a new one. [db] can now write\n  # to the database (as it is not locked and [db] is reading the latest\n  # snapshot).\n  #\n  do_test wal-10.$tn.7 {\n    sql2 { BEGIN; INSERT INTO t1 VALUES(7, 8) ; }\n    catchsql { INSERT INTO t1 VALUES(9, 10) }\n  } {1 {database is locked}}\n  do_test wal-10.$tn.8 {\n    execsql { BEGIN ; SELECT * FROM t1 }\n  } {1 2 3 4 5 6}\n  do_test wal-10.$tn.9 {\n    sql2 COMMIT\n    catchsql { INSERT INTO t1 VALUES(9, 10) }\n  } {1 {database is locked}}\n  do_test wal-10.$tn.10 {\n    execsql { COMMIT }\n    execsql { BEGIN }\n    execsql { INSERT INTO t1 VALUES(9, 10) }\n    execsql { COMMIT }\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10}\n\n  # Open a read transaction with [db2]. Check that this prevents [db] from\n  # checkpointing the database. But not from writing to it.\n  #\n  do_test wal-10.$tn.11 {\n    sql2 { BEGIN; SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10}\n  do_test wal-10.$tn.12 {\n    catchsql { PRAGMA wal_checkpoint } \n  } {0 {0 7 7}}   ;# Reader no longer block checkpoints\n  do_test wal-10.$tn.13 {\n    execsql { INSERT INTO t1 VALUES(11, 12) }\n    sql2 {SELECT * FROM t1}\n  } {1 2 3 4 5 6 7 8 9 10}\n\n  # Writers do not block checkpoints any more either.\n  #\n  do_test wal-10.$tn.14 {\n    catchsql { PRAGMA wal_checkpoint } \n  } {0 {0 8 7}}\n\n  # The following series of test cases used to verify another blocking\n  # case in WAL - a case which no longer blocks.\n  #\n  do_test wal-10.$tn.15 {\n    sql2 { COMMIT; BEGIN; SELECT * FROM t1; }\n  } {1 2 3 4 5 6 7 8 9 10 11 12}\n  do_test wal-10.$tn.16 {\n    catchsql { PRAGMA wal_checkpoint } \n  } {0 {0 8 8}}\n  do_test wal-10.$tn.17 {\n    execsql { PRAGMA wal_checkpoint } \n  } {0 8 8}\n  do_test wal-10.$tn.18 {\n    sql3 { BEGIN; SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10 11 12}\n  do_test wal-10.$tn.19 {\n    catchsql { INSERT INTO t1 VALUES(13, 14) }\n  } {0 {}}\n  do_test wal-10.$tn.20 {\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n  do_test wal-10.$tn.21 {\n    sql3 COMMIT\n    sql2 COMMIT\n  } {}\n  do_test wal-10.$tn.22 {\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n\n  # Another series of tests that used to demonstrate blocking behavior\n  # but which now work.\n  #\n  do_test wal-10.$tn.23 {\n    execsql { PRAGMA wal_checkpoint }\n  } {0 9 9}\n  do_test wal-10.$tn.24 {\n    sql2 { BEGIN; SELECT * FROM t1; }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14}\n  do_test wal-10.$tn.25 {\n    execsql { PRAGMA wal_checkpoint }\n  } {0 9 9}\n  do_test wal-10.$tn.26 {\n    catchsql { INSERT INTO t1 VALUES(15, 16) }\n  } {0 {}}\n  do_test wal-10.$tn.27 {\n    sql3 { INSERT INTO t1 VALUES(17, 18) }\n  } {}\n  do_test wal-10.$tn.28 {\n    code3 {\n      set ::STMT [sqlite3_prepare db3 \"SELECT * FROM t1\" -1 TAIL]\n      sqlite3_step $::STMT\n    }\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18}\n  do_test wal-10.$tn.29 {\n    execsql { INSERT INTO t1 VALUES(19, 20) }\n    catchsql { PRAGMA wal_checkpoint }\n  } {0 {0 3 0}}\n  do_test wal-10.$tn.30 {\n    code3 { sqlite3_finalize $::STMT }\n    execsql { PRAGMA wal_checkpoint }\n  } {0 3 0}\n\n  # At one point, if a reader failed to upgrade to a writer because it\n  # was reading an old snapshot, the write-locks were not being released.\n  # Test that this bug has been fixed.\n  #\n  do_test wal-10.$tn.31 {\n    sql2 COMMIT\n    execsql { BEGIN ; SELECT * FROM t1 }\n    sql2 { INSERT INTO t1 VALUES(21, 22) }\n    catchsql { INSERT INTO t1 VALUES(23, 24) }\n  } {1 {database is locked}}\n  do_test wal-10.$tn.32 {\n    # This statement would fail when the bug was present.\n    sql2 { INSERT INTO t1 VALUES(23, 24) }\n  } {}\n  do_test wal-10.$tn.33 {\n    execsql { SELECT * FROM t1 ; COMMIT }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}\n  do_test wal-10.$tn.34 {\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24}\n\n  # Test that if a checkpointer cannot obtain the required locks, it\n  # releases all locks before returning a busy error.\n  #\n  do_test wal-10.$tn.35 {\n    execsql { \n      DELETE FROM t1;\n      INSERT INTO t1 VALUES('a', 'b');\n      INSERT INTO t1 VALUES('c', 'd');\n    }\n    sql2 {\n      BEGIN;\n        SELECT * FROM t1;\n    }\n  } {a b c d}\n  do_test wal-10.$tn.36 {\n    catchsql { PRAGMA wal_checkpoint }\n  } {0 {0 8 8}}\n  do_test wal-10.$tn.36 {\n    sql3 { INSERT INTO t1 VALUES('e', 'f') }\n    sql2 { SELECT * FROM t1 }\n  } {a b c d}\n  do_test wal-10.$tn.37 {\n    sql2 COMMIT\n    execsql { PRAGMA wal_checkpoint }\n  } {0 9 9}\n}\n\n#-------------------------------------------------------------------------\n# This block of tests, wal-11.*, test that nothing goes terribly wrong\n# if frames must be written to the log file before a transaction is\n# committed (in order to free up memory).\n#\ndo_test wal-11.1 {\n  reopen_db\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x PRIMARY KEY);\n  }\n  list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]\n} {1 3}\ndo_test wal-11.2 {\n  execsql { PRAGMA wal_checkpoint }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 3 [wal_file_size 3 1024]]\ndo_test wal-11.3 {\n  execsql { INSERT INTO t1 VALUES( blob(900) ) }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 3 [wal_file_size 4 1024]]\n\ndo_test wal-11.4 {\n  execsql { \n    BEGIN;\n      INSERT INTO t1 SELECT blob(900) FROM t1;   -- 2\n      INSERT INTO t1 SELECT blob(900) FROM t1;   -- 4\n      INSERT INTO t1 SELECT blob(900) FROM t1;   -- 8\n      INSERT INTO t1 SELECT blob(900) FROM t1;   -- 16\n  }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 3 [wal_file_size 32 1024]]\ndo_test wal-11.5 {\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {16 ok}\ndo_test wal-11.6 {\n  execsql COMMIT\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 3 [wal_file_size 40 1024]]\ndo_test wal-11.7 {\n  execsql { \n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {16 ok}\ndo_test wal-11.8 {\n  execsql { PRAGMA wal_checkpoint }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 37 [wal_file_size 40 1024]]\ndo_test wal-11.9 {\n  db close\n  list [expr [file size test.db]/1024] [log_deleted test.db-wal]\n} {37 1}\nsqlite3_wal db test.db\n\n# After adding the capability of WAL to overwrite prior uncommitted\n# frame in the WAL-file with revised content, the size of the WAL file\n# following cache-spill is smaller.\n#\n#set nWal 39\n#if {[permutation]!=\"mmap\"} {set nWal 37}\n#ifcapable !mmap {set nWal 37}\nset nWal 34\n\ndo_test wal-11.10 {\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      INSERT INTO t1 SELECT blob(900) FROM t1;   -- 32\n      SELECT count(*) FROM t1;\n  }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 37 [wal_file_size $nWal 1024]]\ndo_test wal-11.11 {\n  execsql {\n      SELECT count(*) FROM t1;\n    ROLLBACK;\n    SELECT count(*) FROM t1;\n  }\n} {32 16}\ndo_test wal-11.12 {\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 37 [wal_file_size $nWal 1024]]\ndo_test wal-11.13 {\n  execsql {\n    INSERT INTO t1 VALUES( blob(900) );\n    SELECT count(*) FROM t1;\n    PRAGMA integrity_check;\n  }\n} {17 ok}\ndo_test wal-11.14 {\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 37 [wal_file_size $nWal 1024]]\n\n\n#-------------------------------------------------------------------------\n# This block of tests, wal-12.*, tests the fix for a problem that \n# could occur if a log that is a prefix of an older log is written \n# into a reused log file.\n#\nreopen_db\ndo_test wal-12.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x, y);\n    CREATE TABLE t2(x, y);\n    INSERT INTO t1 VALUES('A', 1);\n  }\n  list [expr [file size test.db]/1024] [file size test.db-wal]\n} [list 1 [wal_file_size 5 1024]]\ndo_test wal-12.2 {\n  db close\n  sqlite3 db test.db\n  execsql {\n    PRAGMA synchronous = normal;\n    UPDATE t1 SET y = 0 WHERE x = 'A';\n  }\n  list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]\n} {3 1}\ndo_test wal-12.3 {\n  execsql { INSERT INTO t2 VALUES('B', 1) }\n  list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]\n} {3 2}\ndo_test wal-12.4 {\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3_wal db2 test2.db\n  execsql { SELECT * FROM t2 } db2\n} {B 1}\ndb2 close\ndo_test wal-12.5 {\n  execsql {\n    PRAGMA wal_checkpoint;\n    UPDATE t2 SET y = 2 WHERE x = 'B'; \n    PRAGMA wal_checkpoint;\n    UPDATE t1 SET y = 1 WHERE x = 'A';\n    PRAGMA wal_checkpoint;\n    UPDATE t1 SET y = 0 WHERE x = 'A';\n  }\n  execsql {  SELECT * FROM t2 }\n} {B 2}\ndo_test wal-12.6 {\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3_wal db2 test2.db\n  execsql { SELECT * FROM t2 } db2\n} {B 2}\ndb2 close\ndb close\n\n#-------------------------------------------------------------------------\n# Check a fun corruption case has been fixed.\n#\n# The problem was that after performing a checkpoint using a connection\n# that had an out-of-date pager-cache, the next time the connection was\n# used it did not realize the cache was out-of-date and proceeded to\n# operate with an inconsistent cache. Leading to corruption.\n#\ncatch { db close }\ncatch { db2 close }\ncatch { db3 close }\nforcedelete test.db test.db-wal\nsqlite3 db test.db\nsqlite3 db2 test.db\ndo_test wal-14 {\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(randomblob(10), randomblob(100));\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100) FROM t1;\n  }\n\n  db2 eval { \n    INSERT INTO t1 SELECT randomblob(10), randomblob(100);\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100);\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100);\n    INSERT INTO t1 SELECT randomblob(10), randomblob(100);\n  }\n\n  # After executing the \"PRAGMA wal_checkpoint\", connection [db] was being\n  # left with an inconsistent cache. Running the CREATE INDEX statement\n  # in this state led to database corruption.\n  catchsql { \n    PRAGMA wal_checkpoint;\n    CREATE INDEX i1 on t1(b);\n  }\n   \n  db2 eval { PRAGMA integrity_check }\n} {ok}\n\ncatch { db close }\ncatch { db2 close }\n\n#-------------------------------------------------------------------------\n# The following block of tests - wal-15.* - focus on testing the \n# implementation of the sqlite3_wal_checkpoint() interface.\n#\nforcedelete test.db test.db-wal\nsqlite3 db test.db\ndo_test wal-15.1 {\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n  }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} {}\n\n# Test that an error is returned if the database name is not recognized\n#\ndo_test wal-15.2.1 {\n  sqlite3_wal_checkpoint db aux\n} {SQLITE_ERROR}\ndo_test wal-15.2.2 {\n  sqlite3_errcode db\n} {SQLITE_ERROR}\ndo_test wal-15.2.3 {\n  sqlite3_errmsg db\n} {unknown database: aux}\n\n# Test that an error is returned if an attempt is made to checkpoint\n# if a transaction is open on the database.\n#\ndo_test wal-15.3.1 {\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  sqlite3_wal_checkpoint db main\n} {SQLITE_LOCKED}\ndo_test wal-15.3.2 {\n  sqlite3_errcode db\n} {SQLITE_LOCKED}\ndo_test wal-15.3.3 {\n  sqlite3_errmsg db\n} {database table is locked}\n\n# Earlier versions returned an error is returned if the db cannot be \n# checkpointed because of locks held by another connection. Check that\n# this is no longer the case.\n#\nsqlite3 db2 test.db\ndo_test wal-15.4.1 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {1 2}\ndo_test wal-15.4.2 {\n  execsql { COMMIT }\n  sqlite3_wal_checkpoint db\n} {SQLITE_OK}\ndo_test wal-15.4.3 {\n  sqlite3_errmsg db\n} {not an error}\n\n# After [db2] drops its lock, [db] may checkpoint the db.\n#\ndo_test wal-15.4.4 {\n  execsql { COMMIT } db2\n  sqlite3_wal_checkpoint db\n} {SQLITE_OK}\ndo_test wal-15.4.5 {\n  sqlite3_errmsg db\n} {not an error}\ndo_test wal-15.4.6 {\n  file size test.db\n} [expr 1024*2]\n\ncatch { db2 close }\ncatch { db close }\n\n#-------------------------------------------------------------------------\n# The following block of tests - wal-16.* - test that if a NULL pointer or\n# an empty string is passed as the second argument of the wal_checkpoint()\n# API, an attempt is made to checkpoint all attached databases.\n#\nforeach {tn ckpt_cmd ckpt_res ckpt_main ckpt_aux} {\n  1 {sqlite3_wal_checkpoint db}              SQLITE_OK     1 1\n  2 {sqlite3_wal_checkpoint db \"\"}           SQLITE_OK     1 1\n  3 {db eval \"PRAGMA wal_checkpoint\"}        {0 10 10}     1 1\n\n  4 {sqlite3_wal_checkpoint db main}         SQLITE_OK     1 0\n  5 {sqlite3_wal_checkpoint db aux}          SQLITE_OK     0 1\n  6 {sqlite3_wal_checkpoint db temp}         SQLITE_OK     0 0\n  7 {db eval \"PRAGMA main.wal_checkpoint\"}   {0 10 10}     1 0\n  8 {db eval \"PRAGMA aux.wal_checkpoint\"}    {0 13 13}     0 1\n  9 {db eval \"PRAGMA temp.wal_checkpoint\"}   {0 -1 -1}     0 0\n} {\n  do_test wal-16.$tn.1 {\n    forcedelete test2.db test2.db-wal test2.db-journal\n    forcedelete test.db test.db-wal test.db-journal\n\n    sqlite3 db test.db\n    execsql {\n      ATTACH 'test2.db' AS aux;\n      PRAGMA main.auto_vacuum = 0;\n      PRAGMA aux.auto_vacuum = 0;\n      PRAGMA main.journal_mode = WAL;\n      PRAGMA aux.journal_mode = WAL;\n      PRAGMA main.synchronous = NORMAL;\n      PRAGMA aux.synchronous = NORMAL;\n    }\n  } {wal wal}\n\n  do_test wal-16.$tn.2 {\n    execsql {\n      CREATE TABLE main.t1(a, b, PRIMARY KEY(a, b));\n      CREATE TABLE aux.t2(a, b, PRIMARY KEY(a, b));\n\n      INSERT INTO t2 VALUES(1, randomblob(1000));\n      INSERT INTO t2 VALUES(2, randomblob(1000));\n      INSERT INTO t1 SELECT * FROM t2;\n    }\n  \n    list [file size test.db] [file size test.db-wal]\n  } [list [expr 1*1024] [wal_file_size 10 1024]]\n  do_test wal-16.$tn.3 {\n    list [file size test2.db] [file size test2.db-wal]\n  } [list [expr 1*1024] [wal_file_size 13 1024]]\n  \n  do_test wal-16.$tn.4 [list eval $ckpt_cmd] $ckpt_res\n  \n  do_test wal-16.$tn.5 {\n    list [file size test.db] [file size test.db-wal]\n  } [list [expr ($ckpt_main ? 7 : 1)*1024] [wal_file_size 10 1024]]\n\n  do_test wal-16.$tn.6 {\n    list [file size test2.db] [file size test2.db-wal]\n  } [list [expr ($ckpt_aux ? 7 : 1)*1024] [wal_file_size 13 1024]]\n\n  catch { db close }\n}\n\n#-------------------------------------------------------------------------\n# The following tests - wal-17.* - attempt to verify that the correct\n# number of \"padding\" frames are appended to the log file when a transaction\n# is committed in synchronous=FULL mode.\n# \n# Do this by creating a database that uses 512 byte pages. Then writing\n# a transaction that modifies 171 pages. In synchronous=NORMAL mode, this\n# produces a log file of:\n#\n#   32 + (24+512)*171 = 90312 bytes.\n#\n# Slightly larger than 11*8192 = 90112 bytes.\n#\n# Run the test using various different sector-sizes. In each case, the\n# WAL code should write the 90300 bytes of log file containing the \n# transaction, then append as may frames as are required to extend the\n# log file so that no part of the next transaction will be written into\n# a disk-sector used by transaction just committed.\n#\nset old_pending_byte [sqlite3_test_control_pending_byte 0x10000000]\ncatch { db close }\nforeach {tn sectorsize logsize} \"\n  1   128  [wal_file_size 172 512]\n  2   256  [wal_file_size 172 512]\n  3   512  [wal_file_size 172 512] \n  4  1024  [wal_file_size 172 512]\n  5  2048  [wal_file_size 172 512]\n  6  4096  [wal_file_size 176 512]\n  7  8192  [wal_file_size 184 512]\n\" {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3_simulate_device -sectorsize $sectorsize\n  sqlite3 db test.db -vfs devsym\n\n  do_test wal-17.$tn.1 {\n    execsql {\n      PRAGMA auto_vacuum = 0;\n      PRAGMA page_size = 512;\n      PRAGMA cache_size = -2000;\n      PRAGMA journal_mode = WAL;\n      PRAGMA synchronous = FULL;\n    }\n    execsql {\n      BEGIN;\n      CREATE TABLE t(x);\n    }\n    for {set i 0} {$i<166} {incr i} {\n      execsql { INSERT INTO t VALUES(randomblob(400)) }\n    }\n    execsql COMMIT\n\n    file size test.db-wal\n  } $logsize\n\n  do_test wal-17.$tn.2 {\n    file size test.db\n  } 512\n\n  do_test wal-17.$tn.3 {\n    db close\n    file size test.db\n  } [expr 512*171]\n}\nsqlite3_test_control_pending_byte $old_pending_byte\n\n#-------------------------------------------------------------------------\n# This test - wal-18.* - verifies a couple of specific conditions that\n# may be encountered while recovering a log file are handled correctly:\n#\n#   wal-18.1.* When the first 32-bits of a frame checksum is correct but \n#              the second 32-bits are false, and\n#\n#   wal-18.2.* When the page-size field that occurs at the start of a log\n#              file is a power of 2 greater than 16384 or smaller than 512.\n#\nforcedelete test.db test.db-wal test.db-journal\ndo_test wal-18.0 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = WAL;\n    PRAGMA synchronous = OFF;\n\n    CREATE TABLE t1(a, b, UNIQUE(a, b));\n    INSERT INTO t1 VALUES(0, 0);\n    PRAGMA wal_checkpoint;\n\n    INSERT INTO t1 VALUES(1, 2);          -- frames 1 and 2\n    INSERT INTO t1 VALUES(3, 4);          -- frames 3 and 4\n    INSERT INTO t1 VALUES(5, 6);          -- frames 5 and 6\n  }\n\n  forcecopy test.db testX.db\n  forcecopy test.db-wal testX.db-wal\n  db close\n  list [file size testX.db] [file size testX.db-wal]\n} [list [expr 3*1024] [wal_file_size 6 1024]]\n\nunset -nocomplain nFrame result\nforeach {nFrame result} {\n         0      {0 0}\n         1      {0 0}\n         2      {0 0 1 2}\n         3      {0 0 1 2}\n         4      {0 0 1 2 3 4}\n         5      {0 0 1 2 3 4}\n         6      {0 0 1 2 3 4 5 6}\n} {\n  do_test wal-18.1.$nFrame {\n    forcecopy testX.db test.db\n    forcecopy testX.db-wal test.db-wal\n\n    hexio_write test.db-wal [expr 24 + $nFrame*(24+1024) + 20] 00000000\n\n    sqlite3 db test.db\n    execsql { \n      SELECT * FROM t1;\n      PRAGMA integrity_check; \n    }\n  } [concat $result ok]\n  db close\n} \n\nproc randomblob {pgsz} {\n  sqlite3 rbdb :memory:\n  set blob [rbdb one {SELECT randomblob($pgsz)}]\n  rbdb close\n  set blob\n}\n\nproc logcksum {ckv1 ckv2 blob} {\n  upvar $ckv1 c1\n  upvar $ckv2 c2\n\n  # Since the magic number at the start of the -wal file header is\n  # 931071618 that indicates that the content should always be read as\n  # little-endian.\n  # \n  set scanpattern i*\n\n  binary scan $blob $scanpattern values\n  foreach {v1 v2} $values {\n    set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}]\n    set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}]\n  }\n}\n\nforcecopy test.db testX.db\nforeach {tn pgsz works} { \n  1    128    0\n  2    256    0\n  3    512    1\n  4   1024    1\n  5   2048    1\n  6   4096    1\n  7   8192    1\n  8  16384    1\n  9  32768    1\n 10  65536    1\n 11 131072    0\n 11   1016    0\n} {\n\n  if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} {\n    set works 0\n  }\n\n  for {set pg 1} {$pg <= 3} {incr pg} {\n    forcecopy testX.db test.db\n    forcedelete test.db-wal\n  \n    # Check that the database now exists and consists of three pages. And\n    # that there is no associated wal file.\n    #\n    do_test wal-18.2.$tn.$pg.1 { file exists test.db-wal } 0\n    do_test wal-18.2.$tn.$pg.2 { file exists test.db } 1\n    do_test wal-18.2.$tn.$pg.3 { file size test.db } [expr 1024*3]\n  \n    do_test wal-18.2.$tn.$pg.4 {\n\n      # Create a wal file that contains a single frame (database page\n      # number $pg) with the commit flag set. The frame checksum is\n      # correct, but the contents of the database page are corrupt.\n      #\n      # The page-size in the log file header is set to $pgsz. If the\n      # WAL code considers $pgsz to be a valid SQLite database file page-size,\n      # the database will be corrupt (because the garbage frame contents\n      # will be treated as valid content). If $pgsz is invalid (too small\n      # or too large), the db will not be corrupt as the log file will\n      # be ignored.\n      #\n      set walhdr [binary format IIIIII 931071618 3007000 $pgsz 1234 22 23]\n      set framebody [randomblob $pgsz]\n      set framehdr  [binary format IIII $pg 5 22 23]\n      set c1 0\n      set c2 0\n      logcksum c1 c2 $walhdr\n\n      append walhdr [binary format II $c1 $c2]\n      logcksum c1 c2 [string range $framehdr 0 7]\n      logcksum c1 c2 $framebody\n      set framehdr [binary format IIIIII $pg 5 22 23 $c1 $c2]\n\n      set fd [open test.db-wal w]\n      fconfigure $fd -encoding binary -translation binary\n      puts -nonewline $fd $walhdr\n      puts -nonewline $fd $framehdr\n      puts -nonewline $fd $framebody\n      close $fd\n  \n      file size test.db-wal\n    } [wal_file_size 1 $pgsz]\n  \n    do_test wal-18.2.$tn.$pg.5 {\n      sqlite3 db test.db\n      set rc [catch { db one {PRAGMA integrity_check} } msg]\n      expr { $rc!=0 || $msg!=\"ok\" }\n    } $works\n  \n    db close\n  }\n}\n\n#-------------------------------------------------------------------------\n# The following test - wal-19.* - fixes a bug that was present during\n# development.\n#\n# When a database connection in WAL mode is closed, it attempts an\n# EXCLUSIVE lock on the database file. If the lock is obtained, the\n# connection knows that it is the last connection to disconnect from\n# the database, so it runs a checkpoint operation. The bug was that\n# the connection was not updating its private copy of the wal-index \n# header before doing so, meaning that it could checkpoint an old\n# snapshot.\n#\ndo_test wal-19.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3 4}\ndo_test wal-19.2 {\n  execsql {\n    INSERT INTO t1 VALUES(5, 6);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 5 6}\ndo_test wal-19.3 {\n  db close\n  db2 close\n  file exists test.db-wal\n} {0}\ndo_test wal-19.4 {\n  # When the bug was present, the following was returning {1 2 3 4} only,\n  # as [db2] had an out-of-date copy of the wal-index header when it was\n  # closed.\n  #\n  sqlite3 db test.db\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6}\n\n#-------------------------------------------------------------------------\n# This test - wal-20.* - uses two connections. One in this process and\n# the other in an external process. The procedure is:\n#\n#   1. Using connection 1, create the database schema.\n#\n#   2. Using connection 2 (in an external process), add so much\n#      data to the database without checkpointing that a wal-index \n#      larger than 64KB is required.\n#\n#   3. Using connection 1, checkpoint the database. Make sure all\n#      the data is present and the database is not corrupt.\n#\n# At one point, SQLite was failing to grow the mapping of the wal-index\n# file in step 3 and the checkpoint was corrupting the database file.\n#\ndo_test wal-20.1 {\n  catch {db close}\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(900));\n    SELECT count(*) FROM t1;\n  }\n} {wal 1}\ndo_test wal-20.2 {\n  set ::buddy [launch_testfixture]\n  testfixture $::buddy {\n    sqlite3 db test.db\n    db transaction { db eval {\n      PRAGMA wal_autocheckpoint = 0;\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 32 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 64 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 128 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 256 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 512 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 1024 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 2048 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 4096 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 8192 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;       /* 16384 */\n    } }\n  }\n} {0}\ndo_test wal-20.3 {\n  close $::buddy\n  execsql { PRAGMA wal_checkpoint }\n  execsql { SELECT count(*) FROM t1 }\n} {16384}\ndo_test wal-20.4 {\n  db close\n  sqlite3 db test.db\n  execsql { SELECT count(*) FROM t1 }\n} {16384}\nintegrity_check wal-20.5\n\ncatch { db2 close }\ncatch { db close }\n\ndo_test wal-21.1 {\n  faultsim_delete_and_reopen\n  execsql { \n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n    INSERT INTO t1 VALUES(5, 6);\n    INSERT INTO t1 VALUES(7, 8);\n    INSERT INTO t1 VALUES(9, 10);\n    INSERT INTO t1 VALUES(11, 12);\n  }\n} {wal}\ndo_test wal-21.2 {\n  execsql { \n    PRAGMA cache_size = 10;\n    PRAGMA wal_checkpoint;\n    BEGIN;\n      SAVEPOINT s;\n        INSERT INTO t1 SELECT randomblob(900), randomblob(900) FROM t1;\n      ROLLBACK TO s;\n    COMMIT;\n  }\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4 5 6 7 8 9 10 11 12}\ndo_test wal-21.3 {\n  execsql { PRAGMA integrity_check }\n} {ok}\n\n#-------------------------------------------------------------------------\n# Test reading and writing of databases with different page-sizes.\n#\nincr ::do_not_use_codec\nforeach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {\n  do_multiclient_test tn [string map [list %PGSZ% $pgsz] {\n    do_test wal-22.%PGSZ%.$tn.1 {\n      sql1 {\n        PRAGMA main.page_size = %PGSZ%;\n        PRAGMA auto_vacuum = 0;\n        PRAGMA journal_mode = WAL;\n        CREATE TABLE t1(x UNIQUE);\n        INSERT INTO t1 SELECT randomblob(800);\n        INSERT INTO t1 SELECT randomblob(800);\n        INSERT INTO t1 SELECT randomblob(800);\n      }\n    } {wal}\n    do_test wal-22.%PGSZ%.$tn.2 { sql2 { PRAGMA integrity_check } } {ok}\n    do_test wal-22.%PGSZ%.$tn.3 {\n      sql1 {PRAGMA wal_checkpoint}\n      expr {[file size test.db] % %PGSZ%}\n    } {0}\n  }]\n}\nincr ::do_not_use_codec -1\n\n#-------------------------------------------------------------------------\n# Test that when 1 or more pages are recovered from a WAL file, \n# sqlite3_log() is invoked to report this to the user.\n#\nifcapable curdir {\n  set walfile [file nativename [file join [get_pwd] test.db-wal]]\n} else {\n  set walfile test.db-wal\n}\ncatch {db close}\nforcedelete test.db\ndo_test wal-23.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    CREATE TABLE t1(a, b);\n    PRAGMA journal_mode = WAL;\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  faultsim_save_and_close\n\n  sqlite3_shutdown\n  test_sqlite3_log [list lappend ::log]\n  set ::log [list]\n  sqlite3 db test.db\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal-23.2 { set ::log } {}\n\ndo_test wal-23.3 {\n  db close\n  set ::log [list]\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal-23.4 { \n  set ::log \n} [list SQLITE_NOTICE_RECOVER_WAL \\\n    \"recovered 2 frames from WAL file $walfile\"]\n\n\nifcapable autovacuum {\n  # This block tests that if the size of a database is reduced by a \n  # transaction (because of an incremental or auto-vacuum), that no\n  # data is written to the WAL file for the truncated pages as part\n  # of the commit. e.g. if a transaction reduces the size of a database\n  # to N pages, data for page N+1 should not be written to the WAL file \n  # when committing the transaction. At one point such data was being \n  # written.\n  #\n  catch {db close}\n  forcedelete test.db\n  sqlite3 db test.db\n  do_execsql_test 24.1 {\n    PRAGMA auto_vacuum = 2;\n    PRAGMA journal_mode = WAL;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(5000));\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n    INSERT INTO t1 SELECT * FROM t1;\n  } {wal}\n  do_test 24.2 { \n    execsql {\n      DELETE FROM t1;\n      PRAGMA wal_checkpoint;\n    }\n    db close\n    sqlite3 db test.db\n    file exists test.db-wal\n  } 0\n  do_test 24.3 {\n    file size test.db\n  } [expr 84 * 1024]\n  do_test 24.4 {\n    execsql { \n      PRAGMA cache_size = 200;\n      PRAGMA incremental_vacuum;\n      PRAGMA wal_checkpoint;\n    }\n    file size test.db\n  } [expr 3 * 1024]\n\n  # WAL file now contains a single frame - the new root page for table t1.\n  # It would be two frames (the new root page and a padding frame) if the\n  # ZERO_DAMAGE flag were not set.\n  do_test 24.5 {\n    file size test.db-wal\n  } [wal_file_size 1 1024]\n}\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log\nsqlite3_initialize\n\n# Make sure PRAGMA journal_mode=WAL works with ATTACHED databases in\n# all journal modes.\n#\nforeach mode {OFF MEMORY PERSIST DELETE TRUNCATE WAL} {\n  delete_file test.db test2.db\n  sqlite3 db test.db\n  do_test wal-25.$mode {\n    db eval \"PRAGMA journal_mode=$mode\"\n    db eval {ATTACH 'test2.db' AS t2; PRAGMA journal_mode=WAL;}\n  } {wal}\n  db close\n}\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal2.test",
    "content": "# 2010 May 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/wal_common.tcl\n\nset testprefix wal2\n\nifcapable !wal {finish_test ; return }\n\nset sqlite_sync_count 0\nproc cond_incr_sync_count {adj} {\n  global sqlite_sync_count\n  if {$::tcl_platform(platform) == \"windows\"} {\n    incr sqlite_sync_count $adj\n  } {\n    ifcapable !dirsync {\n      incr sqlite_sync_count $adj\n    }\n  }\n}\n\nproc set_tvfs_hdr {file args} {\n\n  # Set $nHdr to the number of bytes in the wal-index header:\n  set nHdr 48\n  set nInt [expr {$nHdr/4}]\n\n  if {[llength $args]>2} {\n    error {wrong # args: should be \"set_tvfs_hdr fileName ?val1? ?val2?\"}\n  }\n\n  set blob [tvfs shm $file]\n  if {$::tcl_platform(byteOrder)==\"bigEndian\"} {set fmt I} {set fmt i}\n\n  if {[llength $args]} {\n    set ia [lindex $args 0]\n    set ib $ia\n    if {[llength $args]==2} {\n      set ib [lindex $args 1]\n    }\n    binary scan $blob a[expr $nHdr*2]a* dummy tail\n    set blob [binary format ${fmt}${nInt}${fmt}${nInt}a* $ia $ib $tail]\n    tvfs shm $file $blob\n  }\n\n  binary scan $blob ${fmt}${nInt} ints\n  return $ints\n}\n\nproc incr_tvfs_hdr {file idx incrval} {\n  set ints [set_tvfs_hdr $file]\n  set v [lindex $ints $idx]\n  incr v $incrval\n  lset ints $idx $v\n  set_tvfs_hdr $file $ints\n}\n\n\n#-------------------------------------------------------------------------\n# Test case wal2-1.*:\n#\n# Set up a small database containing a single table. The database is not\n# checkpointed during the test - all content resides in the log file.\n#\n# Two connections are established to the database file - a writer ([db])\n# and a reader ([db2]). For each of the 8 integer fields in the wal-index\n# header (6 fields and 2 checksum values), do the following:\n#\n#   1. Modify the database using the writer.\n#\n#   2. Attempt to read the database using the reader. Before the reader\n#      has a chance to snapshot the wal-index header, increment one\n#      of the integer fields (so that the reader ends up with a corrupted\n#      header).\n#\n#   3. Check that the reader recovers the wal-index and reads the correct\n#      database content.\n#\ndo_test wal2-1.0 {\n  proc tvfs_cb {method filename args} { \n    set ::filename $filename\n    return SQLITE_OK \n  }\n\n  testvfs tvfs\n  tvfs script tvfs_cb\n  tvfs filter xShmOpen\n\n  sqlite3 db  test.db -vfs tvfs\n  sqlite3 db2 test.db -vfs tvfs\n\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a);\n  } db2\n  execsql {\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n    SELECT count(a), sum(a) FROM t1;\n  }\n} {4 10}\ndo_test wal2-1.1 {\n  execsql { SELECT count(a), sum(a) FROM t1 } db2\n} {4 10}\n\nset RECOVER [list                                      \\\n  {0 1 lock exclusive}   {1 7 lock exclusive}          \\\n  {1 7 unlock exclusive} {0 1 unlock exclusive}        \\\n]\nset READ [list                                         \\\n  {4 1 lock shared}    {4 1 unlock shared}             \\\n]\nset INITSLOT [list                                     \\\n  {4 1 lock exclusive} {4 1 unlock exclusive}          \\\n]\n\nforeach {tn iInsert res wal_index_hdr_mod wal_locks} \"\n         2    5   {5 15}    0             {$RECOVER $READ}\n         3    6   {6 21}    1             {$RECOVER $READ}\n         4    7   {7 28}    2             {$RECOVER $READ}\n         5    8   {8 36}    3             {$RECOVER $READ}\n         6    9   {9 45}    4             {$RECOVER $READ}\n         7   10   {10 55}   5             {$RECOVER $READ}\n         8   11   {11 66}   6             {$RECOVER $READ}\n         9   12   {12 78}   7             {$RECOVER $READ}\n        10   13   {13 91}   8             {$RECOVER $READ}\n        11   14   {14 105}  9             {$RECOVER $READ}\n        12   15   {15 120}  -1            {$INITSLOT $READ}\n\" {\n\n  do_test wal2-1.$tn.1 {\n    execsql { INSERT INTO t1 VALUES($iInsert) }\n    set ::locks [list]\n    proc tvfs_cb {method args} {\n      lappend ::locks [lindex $args 2]\n      return SQLITE_OK\n    }\n    tvfs filter xShmLock\n    if {$::wal_index_hdr_mod >= 0} {\n      incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1\n    }\n    execsql { SELECT count(a), sum(a) FROM t1 } db2\n  } $res\n\n  do_test wal2-1.$tn.2 {\n    set ::locks\n  } $wal_locks\n}\ndb close\ndb2 close\ntvfs delete\nforcedelete test.db test.db-wal test.db-journal\n\n#-------------------------------------------------------------------------\n# This test case is very similar to the previous one, except, after\n# the reader reads the corrupt wal-index header, but before it has\n# a chance to re-read it under the cover of the RECOVER lock, the\n# wal-index header is replaced with a valid, but out-of-date, header.\n#\n# Because the header checksum looks Ok, the reader does not run recovery,\n# it simply drops back to a READ lock and proceeds. But because the\n# header is out-of-date, the reader reads the out-of-date snapshot.\n#\n# After this, the header is corrupted again and the reader is allowed\n# to run recovery. This time, it sees an up-to-date snapshot of the\n# database file.\n#\nset WRITER [list 0 1 lock exclusive]\nset LOCKS  [list \\\n  {0 1 lock exclusive} {0 1 unlock exclusive} \\\n  {4 1 lock exclusive} {4 1 unlock exclusive} \\\n  {4 1 lock shared}    {4 1 unlock shared}    \\\n]\ndo_test wal2-2.0 {\n\n  testvfs tvfs\n  tvfs script tvfs_cb\n  tvfs filter xShmOpen\n  proc tvfs_cb {method args} {\n    set ::filename [lindex $args 0]\n    return SQLITE_OK\n  }\n\n  sqlite3 db  test.db -vfs tvfs\n  sqlite3 db2 test.db -vfs tvfs\n\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a);\n  } db2\n  execsql {\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n    SELECT count(a), sum(a) FROM t1;\n  }\n} {4 10}\ndo_test wal2-2.1 {\n  execsql { SELECT count(a), sum(a) FROM t1 } db2\n} {4 10}\n\nforeach {tn iInsert res0 res1 wal_index_hdr_mod} {\n         2    5   {4 10}   {5 15}    0\n         3    6   {5 15}   {6 21}    1\n         4    7   {6 21}   {7 28}    2\n         5    8   {7 28}   {8 36}    3\n         6    9   {8 36}   {9 45}    4\n         7   10   {9 45}   {10 55}   5\n         8   11   {10 55}  {11 66}   6\n         9   12   {11 66}  {12 78}   7\n} {\n  tvfs filter xShmLock\n\n  do_test wal2-2.$tn.1 {\n    set oldhdr [set_tvfs_hdr $::filename]\n    execsql { INSERT INTO t1 VALUES($iInsert) }\n    execsql { SELECT count(a), sum(a) FROM t1 }\n  } $res1\n\n  do_test wal2-2.$tn.2 {\n    set ::locks [list]\n    proc tvfs_cb {method args} {\n      set lock [lindex $args 2]\n      lappend ::locks $lock\n      if {$lock == $::WRITER} {\n        set_tvfs_hdr $::filename $::oldhdr\n      }\n      return SQLITE_OK\n    }\n\n    if {$::wal_index_hdr_mod >= 0} {\n      incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1\n    }\n    execsql { SELECT count(a), sum(a) FROM t1 } db2\n  } $res0\n\n  do_test wal2-2.$tn.3 {\n    set ::locks\n  } $LOCKS\n\n  do_test wal2-2.$tn.4 {\n    set ::locks [list]\n    proc tvfs_cb {method args} {\n      set lock [lindex $args 2]\n      lappend ::locks $lock\n      return SQLITE_OK\n    }\n\n    if {$::wal_index_hdr_mod >= 0} {\n      incr_tvfs_hdr $::filename $::wal_index_hdr_mod 1\n    }\n    execsql { SELECT count(a), sum(a) FROM t1 } db2\n  } $res1\n}\ndb close\ndb2 close\ntvfs delete\nforcedelete test.db test.db-wal test.db-journal\n\n\nif 0 {\n#-------------------------------------------------------------------------\n# This test case - wal2-3.* - tests the response of the library to an\n# SQLITE_BUSY when attempting to obtain a READ or RECOVER lock.\n#\n#   wal2-3.0 - 2: SQLITE_BUSY when obtaining a READ lock\n#   wal2-3.3 - 6: SQLITE_BUSY when obtaining a RECOVER lock\n#\ndo_test wal2-3.0 {\n  proc tvfs_cb {method args} {\n    if {$method == \"xShmLock\"} {\n      if {[info exists ::locked]} { return SQLITE_BUSY }\n    }\n    return SQLITE_OK\n  }\n\n  proc busyhandler x {\n    if {$x>3} { unset -nocomplain ::locked }\n    return 0\n  }\n\n  testvfs tvfs\n  tvfs script tvfs_cb\n  sqlite3 db test.db -vfs tvfs\n  db busy busyhandler\n\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n  } \n\n  set ::locked 1\n  info exists ::locked\n} {1}\ndo_test wal2-3.1 {\n  execsql { SELECT count(a), sum(a) FROM t1 }\n} {4 10}\ndo_test wal2-3.2 {\n  info exists ::locked\n} {0}\n\ndo_test wal2-3.3 {\n  proc tvfs_cb {method args} {\n    if {$method == \"xShmLock\"} {\n      if {[info exists ::sabotage]} {\n        unset -nocomplain ::sabotage\n        incr_tvfs_hdr [lindex $args 0] 1 1\n      }\n      if {[info exists ::locked] && [lindex $args 2] == \"RECOVER\"} {\n        return SQLITE_BUSY\n      }\n    }\n    return SQLITE_OK\n  }\n  set ::sabotage 1\n  set ::locked 1\n  list [info exists ::sabotage] [info exists ::locked]\n} {1 1}\ndo_test wal2-3.4 {\n  execsql { SELECT count(a), sum(a) FROM t1 }\n} {4 10}\ndo_test wal2-3.5 {\n  list [info exists ::sabotage] [info exists ::locked]\n} {0 0}\ndb close\ntvfs delete\nforcedelete test.db test.db-wal test.db-journal\n\n}\n\n#-------------------------------------------------------------------------\n# Test that a database connection using a VFS that does not support the\n# xShmXXX interfaces cannot open a WAL database.\n#\ndo_test wal2-4.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE data(x);\n    INSERT INTO data VALUES('need xShmOpen to see this');\n    PRAGMA wal_checkpoint;\n  }\n  # Three pages in the WAL file at this point: One copy of page 1 and two\n  # of the root page for table \"data\".\n} {wal 0 3 3}\ndo_test wal2-4.2 {\n  db close\n  testvfs tvfs -noshm 1\n  sqlite3 db test.db -vfs tvfs\n  catchsql { SELECT * FROM data }\n} {1 {unable to open database file}}\ndo_test wal2-4.3 {\n  db close\n  testvfs tvfs\n  sqlite3 db test.db -vfs tvfs\n  catchsql { SELECT * FROM data }\n} {0 {{need xShmOpen to see this}}}\ndb close\ntvfs delete\n\n#-------------------------------------------------------------------------\n# Test that if a database connection is forced to run recovery before it\n# can perform a checkpoint, it does not transition into RECOVER state.\n#\n# UPDATE: This has now changed. When running a checkpoint, if recovery is\n# required the client grabs all exclusive locks (just as it would for a\n# recovery performed as a pre-cursor to a normal database transaction).\n#\nset expected_locks [list]\nlappend expected_locks {1 1 lock exclusive}   ;# Lock checkpoint\nlappend expected_locks {0 1 lock exclusive}   ;# Lock writer\nlappend expected_locks {2 6 lock exclusive}   ;# Lock recovery & all aReadMark[]\nlappend expected_locks {2 6 unlock exclusive} ;# Unlock recovery & aReadMark[]\nlappend expected_locks {0 1 unlock exclusive} ;# Unlock writer\nlappend expected_locks {3 1 lock exclusive}   ;# Lock aReadMark[0]\nlappend expected_locks {3 1 unlock exclusive} ;# Unlock aReadMark[0]\nlappend expected_locks {1 1 unlock exclusive} ;# Unlock checkpoint\ndo_test wal2-5.1 {\n  proc tvfs_cb {method args} {\n    set ::shm_file [lindex $args 0]\n    if {$method == \"xShmLock\"} { lappend ::locks [lindex $args 2] }\n    return $::tvfs_cb_return\n  }\n  set tvfs_cb_return SQLITE_OK\n\n  testvfs tvfs\n  tvfs script tvfs_cb\n\n  sqlite3 db test.db -vfs tvfs\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE x(y);\n    INSERT INTO x VALUES(1);\n  }\n\n  incr_tvfs_hdr $::shm_file 1 1\n  set ::locks [list]\n  execsql { PRAGMA wal_checkpoint }\n  set ::locks\n} $expected_locks\ndb close\ntvfs delete\n\n#-------------------------------------------------------------------------\n# This block, test cases wal2-6.*, tests the operation of WAL with\n# \"PRAGMA locking_mode=EXCLUSIVE\" set.\n#\n#   wal2-6.1.*: Changing to WAL mode before setting locking_mode=exclusive.\n#\n#   wal2-6.2.*: Changing to WAL mode after setting locking_mode=exclusive.\n#\n#   wal2-6.3.*: Changing back to rollback mode from WAL mode after setting \n#               locking_mode=exclusive.\n#\n#   wal2-6.4.*: Check that xShmLock calls are omitted in exclusive locking\n#               mode.\n#\n#   wal2-6.5.*: \n#\n#   wal2-6.6.*: Check that if the xShmLock() to reaquire a WAL read-lock when\n#               exiting exclusive mode fails (i.e. SQLITE_IOERR), then the\n#               connection silently remains in exclusive mode.\n#\ndo_test wal2-6.1.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  execsql {\n    Pragma Journal_Mode = Wal;\n  }\n} {wal}\ndo_test wal2-6.1.2 {\n  execsql { PRAGMA lock_status }\n} {main unlocked temp closed}\ndo_test wal2-6.1.3 {\n  execsql {\n    SELECT * FROM sqlite_master;\n    Pragma Locking_Mode = Exclusive;\n  }\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n    PRAGMA lock_status;\n  }\n} {main exclusive temp closed}\ndo_test wal2-6.1.4 {\n  execsql { \n    PRAGMA locking_mode = normal; \n    PRAGMA lock_status;\n  }\n} {normal main exclusive temp closed}\ndo_test wal2-6.1.5 {\n  execsql { \n    SELECT * FROM t1;\n    PRAGMA lock_status;\n  }\n} {1 2 main shared temp closed}\ndo_test wal2-6.1.6 {\n  execsql {\n    INSERT INTO t1 VALUES(3, 4);\n    PRAGMA lock_status;\n  }\n} {main shared temp closed}\ndb close\n\ndo_test wal2-6.2.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  execsql {\n    Pragma Locking_Mode = Exclusive;\n    Pragma Journal_Mode = Wal;\n    Pragma Lock_Status;\n  }\n} {exclusive wal main exclusive temp closed}\ndo_test wal2-6.2.2 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n    Pragma loCK_STATus;\n  }\n} {main exclusive temp closed}\ndo_test wal2-6.2.3 {\n  db close\n  sqlite3 db test.db\n  execsql { SELECT * FROM sqlite_master }\n  execsql { PRAGMA LOCKING_MODE = EXCLUSIVE }\n} {exclusive}\ndo_test wal2-6.2.4 {\n  execsql {\n    SELECT * FROM t1;\n    pragma lock_status;\n  }\n} {1 2 main shared temp closed}\ndo_test wal2-6.2.5 {\n  execsql {\n    INSERT INTO t1 VALUES(3, 4);\n    pragma lock_status;\n  }\n} {main exclusive temp closed}\ndo_test wal2-6.2.6 {\n  execsql {\n    PRAGMA locking_mode = NORMAL;\n    pragma lock_status;\n  }\n} {normal main exclusive temp closed}\ndo_test wal2-6.2.7 {\n  execsql {\n    BEGIN IMMEDIATE; COMMIT;\n    pragma lock_status;\n  }\n} {main shared temp closed}\ndo_test wal2-6.2.8 {\n  execsql {\n    PRAGMA locking_mode = EXCLUSIVE;\n    BEGIN IMMEDIATE; COMMIT;\n    PRAGMA locking_mode = NORMAL;\n  }\n  execsql {\n    SELECT * FROM t1;\n    pragma lock_status;\n  }\n} {1 2 3 4 main shared temp closed}\ndo_test wal2-6.2.9 {\n  execsql {\n    INSERT INTO t1 VALUES(5, 6);\n    SELECT * FROM t1;\n    pragma lock_status;\n  }\n} {1 2 3 4 5 6 main shared temp closed}\ndb close\n\ndo_test wal2-6.3.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    PRAGMA locking_mode = exclusive;\n    BEGIN;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES('Chico');\n      INSERT INTO t1 VALUES('Harpo');\n    COMMIT;\n  }\n  list [file exists test.db-wal] [file exists test.db-journal]\n} {1 0}\ndo_test wal2-6.3.2 {\n  execsql { PRAGMA journal_mode = DELETE }\n  file exists test.db-wal\n} {0}\ndo_test wal2-6.3.3 {\n  execsql { PRAGMA lock_status }\n} {main exclusive temp closed}\ndo_test wal2-6.3.4 {\n  execsql { \n    BEGIN;\n      INSERT INTO t1 VALUES('Groucho');\n  }\n  list [file exists test.db-wal] [file exists test.db-journal]\n} {0 1}\ndo_test wal2-6.3.5 {\n  execsql { PRAGMA lock_status }\n} {main exclusive temp closed}\ndo_test wal2-6.3.6 {\n  execsql { COMMIT }\n  list [file exists test.db-wal] [file exists test.db-journal]\n} {0 1}\ndo_test wal2-6.3.7 {\n  execsql { PRAGMA lock_status }\n} {main exclusive temp closed}\ndb close\n\n\n# This test - wal2-6.4.* - uses a single database connection and the\n# [testvfs] instrumentation to test that xShmLock() is being called\n# as expected when a WAL database is used with locking_mode=exclusive.\n#\ndo_test wal2-6.4.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  proc tvfs_cb {method args} {\n    set ::shm_file [lindex $args 0]\n    if {$method == \"xShmLock\"} { lappend ::locks [lindex $args 2] }\n    return \"SQLITE_OK\"\n  }\n  testvfs tvfs\n  tvfs script tvfs_cb\n  sqlite3 db test.db -vfs tvfs\n  set {} {}\n} {}\n\nset RECOVERY {\n  {0 1 lock exclusive} {1 7 lock exclusive} \n  {1 7 unlock exclusive} {0 1 unlock exclusive}\n}\nset READMARK0_READ {\n  {3 1 lock shared} {3 1 unlock shared}\n}\nset READMARK0_WRITE {\n  {3 1 lock shared} \n  {0 1 lock exclusive} {3 1 unlock shared} \n  {4 1 lock exclusive} {4 1 unlock exclusive} {4 1 lock shared} \n  {0 1 unlock exclusive} {4 1 unlock shared}\n}\nset READMARK1_SET {\n  {4 1 lock exclusive} {4 1 unlock exclusive}\n}\nset READMARK1_READ {\n  {4 1 lock shared} {4 1 unlock shared}\n}\nset READMARK1_WRITE {\n  {4 1 lock shared} \n    {0 1 lock exclusive} {0 1 unlock exclusive} \n  {4 1 unlock shared}\n}\n\nforeach {tn sql res expected_locks} {\n  2 {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = WAL;\n    BEGIN;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES('Leonard');\n      INSERT INTO t1 VALUES('Arthur');\n    COMMIT;\n  } {wal} {\n    $RECOVERY \n    $READMARK0_WRITE\n  }\n\n  3 {\n    # This test should do the READMARK1_SET locking to populate the \n    # aReadMark[1] slot with the current mxFrame value. Followed by\n    # READMARK1_READ to read the database.\n    #\n    SELECT * FROM t1\n  } {Leonard Arthur} {\n    $READMARK1_SET\n    $READMARK1_READ\n  }\n\n  4 {\n    # aReadMark[1] is already set to mxFrame. So just READMARK1_READ\n    # this time, not READMARK1_SET.\n    #\n    SELECT * FROM t1 ORDER BY x\n  } {Arthur Leonard} { \n    $READMARK1_READ \n  }\n\n  5 {\n    PRAGMA locking_mode = exclusive\n  } {exclusive} { } \n\n  6 {\n    INSERT INTO t1 VALUES('Julius Henry');\n    SELECT * FROM t1;\n  } {Leonard Arthur {Julius Henry}} {\n    $READMARK1_READ\n  }\n\n  7 {\n    INSERT INTO t1 VALUES('Karl');\n    SELECT * FROM t1;\n  } {Leonard Arthur {Julius Henry} Karl} { }\n\n  8 {\n    PRAGMA locking_mode = normal\n  } {normal} { }\n\n  9 {\n    SELECT * FROM t1 ORDER BY x\n  } {Arthur {Julius Henry} Karl Leonard} $READMARK1_READ\n\n  10 { DELETE FROM t1 } {} $READMARK1_WRITE\n\n  11 {\n    SELECT * FROM t1\n  } {} {\n    $READMARK1_SET\n    $READMARK1_READ\n  }\n} {\n\n  set L [list]\n  foreach el [subst $expected_locks] { lappend L $el }\n\n  set S \"\"\n  foreach sq [split $sql \"\\n\"] { \n    set sq [string trim $sq]\n    if {[string match {#*} $sq]==0} {append S \"$sq\\n\"}\n  }\n\n  set ::locks [list]\n  do_test wal2-6.4.$tn.1 { execsql $S } $res\n  do_test wal2-6.4.$tn.2 { set ::locks  } $L\n}\n\ndb close\ntvfs delete\n\ndo_test wal2-6.5.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = wal;\n    PRAGMA locking_mode = exclusive;\n    CREATE TABLE t2(a, b);\n    PRAGMA wal_checkpoint;\n    INSERT INTO t2 VALUES('I', 'II');\n    PRAGMA journal_mode;\n  }\n} {wal exclusive 0 2 2 wal}\ndo_test wal2-6.5.2 {\n  execsql {\n    PRAGMA locking_mode = normal;\n    INSERT INTO t2 VALUES('III', 'IV');\n    PRAGMA locking_mode = exclusive;\n    SELECT * FROM t2;\n  }\n} {normal exclusive I II III IV}\ndo_test wal2-6.5.3 {\n  execsql { PRAGMA wal_checkpoint }\n} {0 2 2}\ndb close\n\nproc lock_control {method filename handle spec} {\n  foreach {start n op type} $spec break\n  if {$op == \"lock\"} { return SQLITE_IOERR }\n  return SQLITE_OK\n}\ndo_test wal2-6.6.1 {\n  testvfs T\n  T script lock_control\n  T filter {}\n  sqlite3 db test.db -vfs T\n  execsql { SELECT * FROM sqlite_master }\n  execsql { PRAGMA locking_mode = exclusive }\n  execsql { INSERT INTO t2 VALUES('V', 'VI') }\n} {}\ndo_test wal2-6.6.2 {\n  execsql { PRAGMA locking_mode = normal }\n  T filter xShmLock\n  execsql { INSERT INTO t2 VALUES('VII', 'VIII') }\n} {}\ndo_test wal2-6.6.3 {\n  # At this point the connection should still be in exclusive-mode, even\n  # though it tried to exit exclusive-mode when committing the INSERT\n  # statement above. To exit exclusive mode, SQLite has to take a read-lock \n  # on the WAL file using xShmLock(). Since that call failed, it remains\n  # in exclusive mode.\n  #\n  sqlite3 db2 test.db -vfs T\n  catchsql { SELECT * FROM t2 } db2\n} {1 {database is locked}}\ndo_test wal2-6.6.2 {\n  db2 close\n  T filter {}\n  execsql { INSERT INTO t2 VALUES('IX', 'X') }\n} {}\ndo_test wal2-6.6.4 {\n  # This time, we have successfully exited exclusive mode. So the second\n  # connection can read the database.\n  sqlite3 db2 test.db -vfs T\n  catchsql { SELECT * FROM t2 } db2\n} {0 {I II III IV V VI VII VIII IX X}}\n\ndb close\ndb2 close\nT delete\n\n#-------------------------------------------------------------------------\n# Test a theory about the checksum algorithm. Theory was false and this\n# test did not provoke a bug.\n#\nforcedelete test.db test.db-wal test.db-journal\ndo_test wal2-7.1.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 4096;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n  }\n  file size test.db\n} {4096}\ndo_test wal2-7.1.2 {\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  # The first 32 bytes of the WAL file contain the WAL header. Offset 48\n  # is the first byte of the checksum for the first frame in the WAL. \n  # The following three lines replaces the contents of that byte with \n  # a different value.\n  set newval FF\n  if {$newval == [hexio_read test2.db-wal 48 1]} { set newval 00 }\n  hexio_write test2.db-wal 48 $newval\n} {1}\ndo_test wal2-7.1.3 {\n  sqlite3 db2 test2.db\n  execsql { PRAGMA wal_checkpoint } db2\n  execsql { SELECT * FROM sqlite_master } db2\n} {}\ndb close\ndb2 close\nforcedelete test.db test.db-wal test.db-journal\ndo_test wal2-8.1.2 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum=OFF;\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(zeroblob(8188*1020));\n    CREATE TABLE t2(y);\n    PRAGMA wal_checkpoint;\n  }\n  execsql {\n    SELECT rootpage>=8192 FROM sqlite_master WHERE tbl_name = 't2';\n  }\n} {1}\ndo_test wal2-8.1.3 {\n  execsql {\n    PRAGMA cache_size = 10;\n    CREATE TABLE t3(z);\n    BEGIN;\n      INSERT INTO t3 VALUES(randomblob(900));\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t2 VALUES('hello');\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n      INSERT INTO t3 SELECT randomblob(900) FROM t3;\n    ROLLBACK;\n  }\n  execsql {\n    INSERT INTO t2 VALUES('goodbye');\n    INSERT INTO t3 SELECT randomblob(900) FROM t3;\n    INSERT INTO t3 SELECT randomblob(900) FROM t3;\n  }\n} {}\ndo_test wal2-8.1.4 {\n  sqlite3 db2 test.db\n  execsql { SELECT * FROM t2 }\n} {goodbye}\ndb2 close\ndb close\n\n#-------------------------------------------------------------------------\n# Test that even if the checksums for both are valid, if the two copies\n# of the wal-index header in the wal-index do not match, the client\n# runs (or at least tries to run) database recovery.\n# \n#\nproc get_name {method args} { set ::filename [lindex $args 0] ; tvfs filter {} }\ntestvfs tvfs\ntvfs script get_name\ntvfs filter xShmOpen\n\nforcedelete test.db test.db-wal test.db-journal\ndo_test wal2-9.1 {\n  sqlite3 db test.db -vfs tvfs\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE x(y);\n    INSERT INTO x VALUES('Barton');\n    INSERT INTO x VALUES('Deakin');\n  }\n\n  # Set $wih(1) to the contents of the wal-index header after\n  # the frames associated with the first two rows in table 'x' have\n  # been inserted. Then insert one more row and set $wih(2)\n  # to the new value of the wal-index header.\n  #\n  # If the $wih(1) is written into the wal-index before running\n  # a read operation, the client will see only the first two rows. If\n  # $wih(2) is written into the wal-index, the client will see\n  # three rows. If an invalid header is written into the wal-index, then\n  # the client will run recovery and see three rows.\n  #\n  set wih(1) [set_tvfs_hdr $::filename]\n  execsql { INSERT INTO x VALUES('Watson') }\n  set wih(2) [set_tvfs_hdr $::filename]\n\n  sqlite3 db2 test.db -vfs tvfs\n  execsql { SELECT * FROM x } db2\n} {Barton Deakin Watson}\n\nforeach {tn hdr1 hdr2 res} [list                                            \\\n  3  $wih(1)                $wih(1)                {Barton Deakin}          \\\n  4  $wih(1)                $wih(2)                {Barton Deakin Watson}   \\\n  5  $wih(2)                $wih(1)                {Barton Deakin Watson}   \\\n  6  $wih(2)                $wih(2)                {Barton Deakin Watson}   \\\n  7  $wih(1)                $wih(1)                {Barton Deakin}          \\\n  8  {0 0 0 0 0 0 0 0 0 0 0 0} {0 0 0 0 0 0 0 0 0 0 0 0} {Barton Deakin Watson}\n] {\n  do_test wal2-9.$tn {\n    set_tvfs_hdr $::filename $hdr1 $hdr2\n    execsql { SELECT * FROM x } db2\n  } $res\n}\n\ndb2 close\ndb close\n\n#-------------------------------------------------------------------------\n# This block of tests - wal2-10.* - focus on the libraries response to\n# new versions of the wal or wal-index formats. \n#\n#   wal2-10.1.*: Test that the library refuses to \"recover\" a new WAL \n#                format.\n#\n#   wal2-10.2.*: Test that the library refuses to read or write a database\n#                if the wal-index version is newer than it understands.\n#\n# At time of writing, the only versions of the wal and wal-index formats\n# that exist are versions 3007000 (corresponding to SQLite version 3.7.0,\n# the first version of SQLite to feature wal mode).\n#\ndo_test wal2-10.1.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    PRAGMA wal_checkpoint;\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  faultsim_save_and_close\n} {}\ndo_test wal2-10.1.2 {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal2-10.1.3 {\n  faultsim_restore_and_reopen\n  set hdr [wal_set_walhdr test.db-wal]\n  lindex $hdr 1\n} {3007000}\ndo_test wal2-10.1.4 {\n  lset hdr 1 3007001\n  wal_set_walhdr test.db-wal $hdr\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\n\ntestvfs tvfs -default 1\ndo_test wal2-10.2.1 {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal2-10.2.2 { \n  set hdr [set_tvfs_hdr $::filename] \n  lindex $hdr 0 \n} {3007000}\ndo_test wal2-10.2.3 { \n  lset hdr 0 3007001\n  wal_fix_walindex_cksum hdr \n  set_tvfs_hdr $::filename $hdr\n  catchsql { SELECT * FROM t1 }\n} {1 {unable to open database file}}\ndb close\ntvfs delete\n\n#-------------------------------------------------------------------------\n# This block of tests - wal2-11.* - tests that it is not possible to put\n# the library into an infinite loop by presenting it with a corrupt\n# hash table (one that appears to contain a single chain of infinite \n# length).\n#\n#   wal2-11.1.*: While reading the hash-table.\n#\n#   wal2-11.2.*: While writing the hash-table.\n#\ntestvfs tvfs -default 1\ndo_test wal2-11.0 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b, c);\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t1 VALUES(7, 8, 9);\n    SELECT * FROM t1;\n  }\n} {wal 1 2 3 4 5 6 7 8 9}\n\ndo_test wal2-11.1.1 {\n  sqlite3 db2 test.db\n  execsql { SELECT name FROM sqlite_master } db2\n} {t1}\n\nif {$::tcl_version>=8.5} {\n  # Set all zeroed slots in the first hash table to invalid values.\n  #\n  set blob [string range [tvfs shm $::filename] 0 16383]\n  set I [string range [tvfs shm $::filename] 16384 end]\n  binary scan $I t* L\n  set I [list]\n  foreach p $L {\n    lappend I [expr $p ? $p : 400]\n  }\n  append blob [binary format t* $I]\n  tvfs shm $::filename $blob\n  do_test wal2-11.2 {\n    catchsql { INSERT INTO t1 VALUES(10, 11, 12) }\n  } {1 {database disk image is malformed}}\n  \n  # Fill up the hash table on the first page of shared memory with 0x55 bytes.\n  #\n  set blob [string range [tvfs shm $::filename] 0 16383]\n  append blob [string repeat [binary format c 55] 16384]\n  tvfs shm $::filename $blob\n  do_test wal2-11.3 {\n    catchsql { SELECT * FROM t1 } db2\n  } {1 {database disk image is malformed}}\n}\n\ndb close\ndb2 close\ntvfs delete\n\n#-------------------------------------------------------------------------\n# If a connection is required to create a WAL or SHM file, it creates \n# the new files with the same file-system permissions as the database \n# file itself. Test this.\n#\nif {$::tcl_platform(platform) == \"unix\"} {\n  faultsim_delete_and_reopen\n  # Changed on 2012-02-13: umask is deliberately ignored for -wal files.\n  #set umask [exec /bin/sh -c umask]\n  set umask 0\n  \n\n  do_test wal2-12.1 {\n    sqlite3 db test.db\n    execsql { \n      CREATE TABLE tx(y, z);\n      PRAGMA journal_mode = WAL;\n    }\n    db close\n    list [file exists test.db-wal] [file exists test.db-shm]\n  } {0 0}\n  \n  foreach {tn permissions} {\n   1 00644\n   2 00666\n   3 00600\n   4 00755\n  } {\n    set effective [format %.5o [expr $permissions & ~$umask]]\n    do_test wal2-12.2.$tn.1 {\n      file attributes test.db -permissions $permissions\n      file attributes test.db -permissions\n    } $permissions\n    do_test wal2-12.2.$tn.2 {\n      list [file exists test.db-wal] [file exists test.db-shm]\n    } {0 0}\n    do_test wal2-12.2.$tn.3 {\n      sqlite3 db test.db\n      execsql { INSERT INTO tx DEFAULT VALUES }\n      list [file exists test.db-wal] [file exists test.db-shm]\n    } {1 1}\n    do_test wal2-12.2.$tn.4 {\n      list [file attr test.db-wal -perm] [file attr test.db-shm -perm]\n    } [list $effective $effective]\n    do_test wal2-12.2.$tn.5 {\n      db close\n      list [file exists test.db-wal] [file exists test.db-shm]\n    } {0 0}\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test the libraries response to discovering that one or more of the\n# database, wal or shm files cannot be opened, or can only be opened\n# read-only.\n#\nif {$::tcl_platform(platform) == \"unix\"} {\n  proc perm {} {\n    set L [list]\n    foreach f {test.db test.db-wal test.db-shm} {\n      if {[file exists $f]} {\n        lappend L [file attr $f -perm]\n      } else {\n        lappend L {}\n      }\n    }\n    set L\n  }\n\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    PRAGMA wal_checkpoint;\n    INSERT INTO t1 VALUES('3.14', '2.72');\n  }\n  do_test wal2-13.1.1 {\n    list [file exists test.db-shm] [file exists test.db-wal]\n  } {1 1}\n  faultsim_save_and_close\n\n  foreach {tn db_perm wal_perm shm_perm can_open can_read can_write} {\n    2   00644   00644   00644   1   1   1\n    3   00644   00400   00644   1   1   0\n    4   00644   00644   00400   1   0   0\n    5   00400   00644   00644   1   1   0\n\n    7   00644   00000   00644   1   0   0\n    8   00644   00644   00000   1   0   0\n    9   00000   00644   00644   0   0   0\n  } {\n    faultsim_restore\n    do_test wal2-13.$tn.1 {\n      file attr test.db     -perm $db_perm\n      file attr test.db-wal -perm $wal_perm\n      file attr test.db-shm -perm $shm_perm\n\n      set     L [file attr test.db -perm]\n      lappend L [file attr test.db-wal -perm]\n      lappend L [file attr test.db-shm -perm]\n    } [list $db_perm $wal_perm $shm_perm]\n\n    # If $can_open is true, then it should be possible to open a database\n    # handle. Otherwise, if $can_open is 0, attempting to open the db\n    # handle throws an \"unable to open database file\" exception.\n    #\n    set r(1) {0 ok}\n    set r(0) {1 {unable to open database file}}\n    do_test wal2-13.$tn.2 {\n      list [catch {sqlite3 db test.db ; set {} ok} msg] $msg\n    } $r($can_open)\n\n    if {$can_open} {\n\n      # If $can_read is true, then the client should be able to read from\n      # the database file. If $can_read is false, attempting to read should\n      # throw the \"unable to open database file\" exception. \n      #\n      set a(0) {1 {unable to open database file}}\n      set a(1) {0 {3.14 2.72}}\n      do_test wal2-13.$tn.3 {\n        catchsql { SELECT * FROM t1 }\n      } $a($can_read)\n  \n      # Now try to write to the db file. If the client can read but not\n      # write, then it should throw the familiar \"unable to open db file\"\n      # exception. If it can read but not write, the exception should\n      # be \"attempt to write a read only database\".\n      #\n      # If the client can read and write, the operation should succeed.\n      #\n      set b(0,0) {1 {unable to open database file}}\n      set b(1,0) {1 {attempt to write a readonly database}}\n      set b(1,1) {0 {}}\n      do_test wal2-13.$tn.4 {\n        catchsql { INSERT INTO t1 DEFAULT VALUES }\n      } $b($can_read,$can_write)\n    }\n    catch { db close }\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test that \"PRAGMA checkpoint_fullsync\" appears to be working.\n#\nforeach {tn sql reslist} {\n  1 { }                                 {10 0 4 0 6 0}\n  2 { PRAGMA checkpoint_fullfsync = 1 } {10 6 4 3 6 3}\n  3 { PRAGMA checkpoint_fullfsync = 0 } {10 0 4 0 6 0}\n} {\n  ifcapable default_ckptfullfsync {\n    if {[string trim $sql]==\"\"} continue\n  }\n  faultsim_delete_and_reopen\n\n  execsql {PRAGMA auto_vacuum = 0; PRAGMA synchronous = FULL;}\n  execsql $sql\n  do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 }   {}\n  do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}\n\n  set sqlite_sync_count 0\n  set sqlite_fullsync_count 0\n\n  do_execsql_test wal2-14.$tn.2 {\n    PRAGMA wal_autocheckpoint = 10;\n    CREATE TABLE t1(a, b);                -- 2 wal syncs\n    INSERT INTO t1 VALUES(1, 2);          -- 2 wal sync\n    PRAGMA wal_checkpoint;                -- 1 wal sync, 1 db sync\n    BEGIN;\n      INSERT INTO t1 VALUES(3, 4);\n      INSERT INTO t1 VALUES(5, 6);\n    COMMIT;                               -- 2 wal sync\n    PRAGMA wal_checkpoint;                -- 1 wal sync, 1 db sync\n  } {10 0 3 3 0 1 1}\n\n  do_test wal2-14.$tn.3 {\n    cond_incr_sync_count 1\n    list $sqlite_sync_count $sqlite_fullsync_count\n  } [lrange $reslist 0 1]\n\n  set sqlite_sync_count 0\n  set sqlite_fullsync_count 0\n\n  do_test wal2-14.$tn.4 {\n    execsql { INSERT INTO t1 VALUES(7, zeroblob(12*4096)) }\n    list $sqlite_sync_count $sqlite_fullsync_count\n  } [lrange $reslist 2 3]\n\n  set sqlite_sync_count 0\n  set sqlite_fullsync_count 0\n\n  do_test wal2-14.$tn.5 {\n    execsql { PRAGMA wal_autocheckpoint = 1000 }\n    execsql { INSERT INTO t1 VALUES(9, 10) }\n    execsql { INSERT INTO t1 VALUES(11, 12) }\n    execsql { INSERT INTO t1 VALUES(13, 14) }\n    db close\n    list $sqlite_sync_count $sqlite_fullsync_count\n  } [lrange $reslist 4 5]\n}\n\ncatch { db close }\n\n# PRAGMA checkpoint_fullsync\n# PRAGMA fullfsync\n# PRAGMA synchronous\n#\nforeach {tn settings restart_sync commit_sync ckpt_sync} {\n  1  {0 0 off}     {0 0}  {0 0}  {0 0}\n  2  {0 0 normal}  {1 0}  {0 0}  {2 0}\n  3  {0 0 full}    {2 0}  {1 0}  {2 0}\n\n  4  {0 1 off}     {0 0}  {0 0}  {0 0}\n  5  {0 1 normal}  {0 1}  {0 0}  {0 2}\n  6  {0 1 full}    {0 2}  {0 1}  {0 2}\n\n  7  {1 0 off}     {0 0}  {0 0}  {0 0}\n  8  {1 0 normal}  {0 1}  {0 0}  {0 2}\n  9  {1 0 full}    {1 1}  {1 0}  {0 2}\n\n  10 {1 1 off}     {0 0}  {0 0}  {0 0}\n  11 {1 1 normal}  {0 1}  {0 0}  {0 2}\n  12 {1 1 full}    {0 2}  {0 1}  {0 2}\n} {\n  forcedelete test.db\n\n  testvfs tvfs -default 1\n  tvfs filter xSync\n  tvfs script xSyncCb\n  proc xSyncCb {method file fileid flags} {\n    incr ::sync($flags)\n  }\n\n  sqlite3 db test.db\n  do_execsql_test 15.$tn.1 \"\n    PRAGMA page_size = 4096;\n    CREATE TABLE t1(x);\n    PRAGMA wal_autocheckpoint = OFF;\n    PRAGMA journal_mode = WAL;\n    PRAGMA checkpoint_fullfsync = [lindex $settings 0];\n    PRAGMA fullfsync = [lindex $settings 1];\n    PRAGMA synchronous = [lindex $settings 2];\n  \" {0 wal}\n\n  do_test 15.$tn.2 {\n    set sync(normal) 0\n    set sync(full) 0\n    execsql { INSERT INTO t1 VALUES('abc') }\n    list $::sync(normal) $::sync(full)\n  } $restart_sync\n\n  do_test 15.$tn.3 {\n    set sync(normal) 0\n    set sync(full) 0\n    execsql { INSERT INTO t1 VALUES('abc') }\n    list $::sync(normal) $::sync(full)\n  } $commit_sync\n\n  do_test 15.$tn.4 {\n    set sync(normal) 0\n    set sync(full) 0\n    execsql { INSERT INTO t1 VALUES('def') }\n    list $::sync(normal) $::sync(full)\n  } $commit_sync\n\n  do_test 15.$tn.5 {\n    set sync(normal) 0\n    set sync(full) 0\n    execsql { PRAGMA wal_checkpoint }\n    list $::sync(normal) $::sync(full)\n  } $ckpt_sync\n  \n  db close\n  tvfs delete\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal3.test",
    "content": "# 2010 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nsource $testdir/malloc_common.tcl\nifcapable !wal {finish_test ; return }\n\nset a_string_counter 1\nproc a_string {n} {\n  global a_string_counter\n  incr a_string_counter\n  string range [string repeat \"${a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\n#-------------------------------------------------------------------------\n# When a rollback or savepoint rollback occurs, the client may remove\n# elements from one of the hash tables in the wal-index. This block\n# of test cases tests that nothing appears to go wrong when this is\n# done.\n#\ndo_test wal3-1.0 {\n  execsql {\n    PRAGMA cache_size = 2000;\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = off;\n    PRAGMA synchronous = normal;\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    BEGIN;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 VALUES( a_string(800) );                  /*    1 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*    2 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*    4 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*    8 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*   16 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*   32 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*   64 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*  128*/\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*  256 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /*  512 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /* 1024 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1;             /* 2048 */\n      INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 1970;  /* 4018 */\n    COMMIT;\n    PRAGMA cache_size = 10;\n  }\n  set x [wal_frame_count test.db-wal 1024]\n  if {[permutation]==\"memsubsys1\"} {\n    if {$x==4251 || $x==4290} {set x 4056}\n  }\n  set x\n} 4056\n\nfor {set i 1} {$i < 50} {incr i} {\n\n  do_test wal3-1.$i.1 {\n    set str [a_string 800]\n    execsql { UPDATE t1 SET x = $str WHERE rowid = $i }\n    lappend L [wal_frame_count test.db-wal 1024]\n    execsql {\n      BEGIN;\n        INSERT INTO t1 SELECT a_string(800) FROM t1 LIMIT 100;\n      ROLLBACK;\n      PRAGMA integrity_check;\n    }\n  } {ok}\n\n  # Check that everything looks OK from the point of view of an \n  # external connection.\n  #\n  sqlite3 db2 test.db\n  do_test wal3-1.$i.2 {\n    execsql { SELECT count(*) FROM t1 } db2\n  } 4018\n  do_test wal3-1.$i.3 {\n    execsql { SELECT x FROM t1 WHERE rowid = $i }\n  } $str\n  do_test wal3-1.$i.4 {\n    execsql { PRAGMA integrity_check } db2\n  } {ok}\n  db2 close\n  \n  # Check that the file-system in its current state can be recovered.\n  # \n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  forcedelete test2.db-journal\n  sqlite3 db2 test2.db\n  do_test wal3-1.$i.5 {\n    execsql { SELECT count(*) FROM t1 } db2\n  } 4018\n  do_test wal3-1.$i.6 {\n    execsql { SELECT x FROM t1 WHERE rowid = $i }\n  } $str\n  do_test wal3-1.$i.7 {\n    execsql { PRAGMA integrity_check } db2\n  } {ok}\n  db2 close\n}\n\nproc byte_is_zero {file offset} {\n  if {[file size test.db] <= $offset} { return 1 }\n  expr { [hexio_read $file $offset 1] == \"00\" }\n}\n\ndo_multiclient_test i {\n\n  set testname(1) multiproc\n  set testname(2) singleproc\n  set tn $testname($i)\n\n  do_test wal3-2.$tn.1 {\n    sql1 { \n      PRAGMA page_size = 1024;\n      PRAGMA journal_mode = WAL;\n    }\n    sql1 {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 'one');\n      BEGIN;\n        SELECT * FROM t1;\n    }\n  } {1 one}\n  do_test wal3-2.$tn.2 {\n    sql2 {\n      CREATE TABLE t2(a, b);\n      INSERT INTO t2 VALUES(2, 'two');\n      BEGIN;\n        SELECT * FROM t2;\n    }\n  } {2 two}\n  do_test wal3-2.$tn.3 {\n    sql3 {\n      CREATE TABLE t3(a, b);\n      INSERT INTO t3 VALUES(3, 'three');\n      BEGIN;\n        SELECT * FROM t3;\n    }\n  } {3 three}\n\n  # Try to checkpoint the database using [db]. It should be possible to\n  # checkpoint everything except the table added by [db3] (checkpointing\n  # these frames would clobber the snapshot currently being used by [db2]).\n  #\n  # After [db2] has committed, a checkpoint can copy the entire log to the\n  # database file. Checkpointing after [db3] has committed is therefore a\n  # no-op, as the entire log has already been backfilled.\n  #\n  do_test wal3-2.$tn.4 {\n    sql1 {\n      COMMIT;\n      PRAGMA wal_checkpoint;\n    }\n    byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]\n  } {1}\n  do_test wal3-2.$tn.5 {\n    sql2 {\n      COMMIT;\n      PRAGMA wal_checkpoint;\n    }\n    list [byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]]   \\\n         [byte_is_zero test.db [expr $AUTOVACUUM ? 5*1024 : 4*1024]]\n  } {0 1}\n  do_test wal3-2.$tn.6 {\n    sql3 {\n      COMMIT;\n      PRAGMA wal_checkpoint;\n    }\n    list [byte_is_zero test.db [expr $AUTOVACUUM ? 4*1024 : 3*1024]]   \\\n         [byte_is_zero test.db [expr $AUTOVACUUM ? 5*1024 : 4*1024]]\n  } {0 1}\n}\ncatch {db close}\n\n#-------------------------------------------------------------------------\n# Test that that for the simple test:\n#\n#   CREATE TABLE x(y);\n#   INSERT INTO x VALUES('z');\n#   PRAGMA wal_checkpoint;\n#\n# in WAL mode the xSync method is invoked as expected for each of\n# synchronous=off, synchronous=normal and synchronous=full.\n#\nforeach {tn syncmode synccount} {\n  1 off     \n    {}\n  2 normal  \n    {test.db-wal normal test.db normal}\n  3 full    \n    {test.db-wal normal test.db-wal normal test.db-wal normal test.db normal}\n} {\n\n  proc sync_counter {args} { \n    foreach {method filename id flags} $args break\n    lappend ::syncs [file tail $filename] $flags\n  }\n  do_test wal3-3.$tn {\n    forcedelete test.db test.db-wal test.db-journal\n  \n    testvfs T\n    T filter {} \n    T script sync_counter\n    sqlite3 db test.db -vfs T\n  \n    execsql \"PRAGMA synchronous = $syncmode\"\n    execsql \"PRAGMA checkpoint_fullfsync = 0\"\n    execsql { PRAGMA journal_mode = WAL }\n    execsql { CREATE TABLE filler(a,b,c); }\n\n    set ::syncs [list]\n    T filter xSync\n    execsql {\n      CREATE TABLE x(y);\n      INSERT INTO x VALUES('z');\n      PRAGMA wal_checkpoint;\n    }\n    T filter {}\n    set ::syncs\n  } $synccount\n\n  db close\n  T delete\n}\n\n\n#-------------------------------------------------------------------------\n# Only one client may run recovery at a time. Test this mechanism.\n#\n# When client-2 tries to open a read transaction while client-1 is \n# running recovery, it fails to obtain a lock on an aReadMark[] slot\n# (because they are all locked by recovery). It then tries to obtain\n# a shared lock on the RECOVER lock to see if there really is a\n# recovery running or not.\n#\n# This block of tests checks the effect of an SQLITE_BUSY or SQLITE_IOERR\n# being returned when client-2 attempts a shared lock on the RECOVER byte.\n#\n# An SQLITE_BUSY should be converted to an SQLITE_BUSY_RECOVERY. An\n# SQLITE_IOERR should be returned to the caller.\n#\ndo_test wal3-5.1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(3, 4);\n  }\n  faultsim_save_and_close\n} {}\n\ntestvfs T -default 1\nT script method_callback\n\nproc method_callback {method args} {\n  if {$method == \"xShmBarrier\"} {\n    incr ::barrier_count\n    if {$::barrier_count == 2} {\n      # This code is executed within the xShmBarrier() callback invoked\n      # by the client running recovery as part of writing the recovered\n      # wal-index header. If a second client attempts to access the \n      # database now, it reads a corrupt (partially written) wal-index\n      # header. But it cannot even get that far, as the first client\n      # is still holding all the locks (recovery takes an exclusive lock\n      # on *all* db locks, preventing access by any other client).\n      #\n      # If global variable ::wal3_do_lockfailure is non-zero, then set\n      # things up so that an IO error occurs within an xShmLock() callback\n      # made by the second client (aka [db2]).\n      #\n      sqlite3 db2 test.db\n      if { $::wal3_do_lockfailure } { T filter xShmLock }\n      set ::testrc [ catch { db2 eval \"SELECT * FROM t1\" } ::testmsg ]\n      T filter {}\n      db2 close\n    }\n  }\n\n  if {$method == \"xShmLock\"} {\n    foreach {file handle spec} $args break\n    if { $spec == \"2 1 lock shared\" } {\n      return SQLITE_IOERR\n    }\n  }\n\n  return SQLITE_OK\n}\n\n# Test a normal SQLITE_BUSY return.\n#\nT filter xShmBarrier\nset testrc \"\"\nset testmsg \"\"\nset barrier_count 0\nset wal3_do_lockfailure 0\ndo_test wal3-5.2 {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal3-5.3 {\n  list $::testrc $::testmsg\n} {1 {database is locked}}\ndb close\n\n# Test an SQLITE_IOERR return.\n#\nT filter xShmBarrier\nset barrier_count 0\nset wal3_do_lockfailure 1\nset testrc \"\"\nset testmsg \"\"\ndo_test wal3-5.4 {\n  faultsim_restore_and_reopen\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\ndo_test wal3-5.5 {\n  list $::testrc $::testmsg\n} {1 {disk I/O error}}\n\ndb close\nT delete\n\n#-------------------------------------------------------------------------\n# When opening a read-transaction on a database, if the entire log has\n# already been copied to the database file, the reader grabs a special\n# kind of read lock (on aReadMark[0]). This set of test cases tests the \n# outcome of the following:\n#\n#   + The reader discovering that between the time when it determined \n#     that the log had been completely backfilled and the lock is obtained\n#     that a writer has written to the log. In this case the reader should\n#     acquire a different read-lock (not aReadMark[0]) and read the new\n#     snapshot.\n#\n#   + The attempt to obtain the lock on aReadMark[0] fails with SQLITE_BUSY.\n#     This can happen if a checkpoint is ongoing. In this case also simply\n#     obtain a different read-lock.\n#\ncatch {db close}\ntestvfs T -default 1\ndo_test wal3-6.1.1 {\n  forcedelete test.db test.db-journal test.db wal\n  sqlite3 db test.db\n  execsql { PRAGMA auto_vacuum = off }\n  execsql { PRAGMA journal_mode = WAL }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES('o', 't');\n    INSERT INTO t1 VALUES('t', 'f');\n  }\n} {}\ndo_test wal3-6.1.2 {\n  sqlite3 db2 test.db\n  sqlite3 db3 test.db\n  execsql { BEGIN ; SELECT * FROM t1 } db3\n} {o t t f}\ndo_test wal3-6.1.3 {\n  execsql { PRAGMA wal_checkpoint } db2\n} {0 4 4}\n\n# At this point the log file has been fully checkpointed. However, \n# connection [db3] holds a lock that prevents the log from being wrapped.\n# Test case 3.6.1.4 has [db] attempt a read-lock on aReadMark[0]. But\n# as it is obtaining the lock, [db2] appends to the log file.\n#\nT filter xShmLock\nT script lock_callback\nproc lock_callback {method file handle spec} {\n  if {$spec == \"3 1 lock shared\"} {\n    # This is the callback for [db] to obtain the read lock on aReadMark[0].\n    # Disable future callbacks using [T filter {}] and write to the log\n    # file using [db2]. [db3] is preventing [db2] from wrapping the log\n    # here, so this is an append.\n    T filter {}\n    db2 eval { INSERT INTO t1 VALUES('f', 's') }\n  }\n  return SQLITE_OK\n}\ndo_test wal3-6.1.4 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  }\n} {o t t f f s}\n\n# [db] should be left holding a read-lock on some slot other than \n# aReadMark[0]. Test this by demonstrating that the read-lock is preventing\n# the log from being wrapped.\n#\ndo_test wal3-6.1.5 {\n  db3 eval COMMIT\n  db2 eval { PRAGMA wal_checkpoint }\n  set sz1 [file size test.db-wal]\n  db2 eval { INSERT INTO t1 VALUES('s', 'e') }\n  set sz2 [file size test.db-wal]\n  expr {$sz2>$sz1}\n} {1}\n\n# Test that if [db2] had not interfered when [db] was trying to grab\n# aReadMark[0], it would have been possible to wrap the log in 3.6.1.5.\n#\ndo_test wal3-6.1.6 {\n  execsql { COMMIT }\n  execsql { PRAGMA wal_checkpoint } db2\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  }\n} {o t t f f s s e}\ndo_test wal3-6.1.7 {\n  db2 eval { PRAGMA wal_checkpoint }\n  set sz1 [file size test.db-wal]\n  db2 eval { INSERT INTO t1 VALUES('n', 't') }\n  set sz2 [file size test.db-wal]\n  expr {$sz2==$sz1}\n} {1}\n\ndb3 close\ndb2 close\ndb close\n\ndo_test wal3-6.2.1 {\n  forcedelete test.db test.db-journal test.db wal\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql { PRAGMA auto_vacuum = off }\n  execsql { PRAGMA journal_mode = WAL }\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES('h', 'h');\n    INSERT INTO t1 VALUES('l', 'b');\n  }\n} {}\n\nT filter xShmLock\nT script lock_callback\nproc lock_callback {method file handle spec} {\n  if {$spec == \"3 1 unlock exclusive\"} {\n    T filter {}\n    set ::R [db2 eval {\n      BEGIN;\n      SELECT * FROM t1;\n    }]\n  }\n}\ndo_test wal3-6.2.2 {\n  execsql { PRAGMA wal_checkpoint }\n} {0 4 4}\ndo_test wal3-6.2.3 {\n  set ::R\n} {h h l b}\ndo_test wal3-6.2.4 {\n  set sz1 [file size test.db-wal]\n  execsql { INSERT INTO t1 VALUES('b', 'c'); }\n  set sz2 [file size test.db-wal]\n  expr {$sz2 > $sz1}\n} {1}\ndo_test wal3-6.2.5 {\n  db2 eval { COMMIT }\n  execsql { PRAGMA wal_checkpoint }\n  set sz1 [file size test.db-wal]\n  execsql { INSERT INTO t1 VALUES('n', 'o'); }\n  set sz2 [file size test.db-wal]\n  expr {$sz2 == $sz1}\n} {1}\n \ndb2 close\ndb close\nT delete\n\n#-------------------------------------------------------------------------\n# When opening a read-transaction on a database, if the entire log has\n# not yet been copied to the database file, the reader grabs a read\n# lock on aReadMark[x], where x>0. The following test cases experiment\n# with the outcome of the following:\n#\n#   + The reader discovering that between the time when it read the\n#     wal-index header and the lock was obtained that a writer has \n#     written to the log. In this case the reader should re-read the \n#     wal-index header and lock a snapshot corresponding to the new \n#     header.\n#\n#   + The value in the aReadMark[x] slot has been modified since it was\n#     read.\n#\ncatch {db close}\ntestvfs T -default 1\ndo_test wal3-7.1.1 {\n  forcedelete test.db test.db-journal test.db wal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE blue(red PRIMARY KEY, green);\n  }\n} {wal}\n\nT script method_callback\nT filter xOpen\nproc method_callback {method args} {\n  if {$method == \"xOpen\"} { return \"reader\" }\n}\ndo_test wal3-7.1.2 {\n  sqlite3 db2 test.db\n  execsql { SELECT * FROM blue } db2\n} {}\n\nT filter xShmLock\nset ::locks [list]\nproc method_callback {method file handle spec} {\n  if {$handle != \"reader\" } { return }\n  if {$method == \"xShmLock\"} {\n    catch { execsql { INSERT INTO blue VALUES(1, 2) } }\n    catch { execsql { INSERT INTO blue VALUES(3, 4) } }\n  }\n  lappend ::locks $spec\n}\ndo_test wal3-7.1.3 {\n  execsql { SELECT * FROM blue } db2\n} {1 2 3 4}\ndo_test wal3-7.1.4 {\n  set ::locks\n} {{4 1 lock shared} {4 1 unlock shared} {5 1 lock shared} {5 1 unlock shared}}\n\nset ::locks [list]\nproc method_callback {method file handle spec} {\n  if {$handle != \"reader\" } { return }\n  if {$method == \"xShmLock\"} {\n    catch { execsql { INSERT INTO blue VALUES(5, 6) } }\n  }\n  lappend ::locks $spec\n}\ndo_test wal3-7.2.1 {\n  execsql { SELECT * FROM blue } db2\n} {1 2 3 4 5 6}\ndo_test wal3-7.2.2 {\n  set ::locks\n} {{5 1 lock shared} {5 1 unlock shared} {4 1 lock shared} {4 1 unlock shared}}\n\ndb close\ndb2 close\nT delete\n\n\n#-------------------------------------------------------------------------\n# When a connection opens a read-lock on the database, it searches for\n# an aReadMark[] slot that is already set to the mxFrame value for the\n# new transaction. If it cannot find one, it attempts to obtain an \n# exclusive lock on an aReadMark[] slot for the purposes of modifying\n# the value, then drops back to a shared-lock for the duration of the\n# transaction.\n#\n# This test case verifies that if an exclusive lock cannot be obtained\n# on any aReadMark[] slot (because there are already several readers),\n# the client takes a shared-lock on a slot without modifying the value\n# and continues.\n#\nset nConn 50\nif { [string match *BSD $tcl_platform(os)] } { set nConn 25 }\ndo_test wal3-9.0 {\n  forcedelete test.db test.db-journal test.db wal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE whoami(x);\n    INSERT INTO whoami VALUES('nobody');\n  }\n} {wal}\nfor {set i 0} {$i < $nConn} {incr i} {\n  set c db$i\n  do_test wal3-9.1.$i {\n    sqlite3 $c test.db\n    execsql { UPDATE whoami SET x = $c }\n    execsql {\n      BEGIN;\n      SELECT * FROM whoami\n    } $c\n  } $c\n}\nfor {set i 0} {$i < $nConn} {incr i} {\n  set c db$i\n  do_test wal3-9.2.$i {\n    execsql { SELECT * FROM whoami } $c\n  } $c\n}\n\nset sz [expr 1024 * (2+$AUTOVACUUM)]\ndo_test wal3-9.3 {\n  for {set i 0} {$i < ($nConn-1)} {incr i} { db$i close }\n  execsql { PRAGMA wal_checkpoint } \n  byte_is_zero test.db [expr $sz-1024]\n} {1}\ndo_test wal3-9.4 {\n  db[expr $nConn-1] close\n  execsql { PRAGMA wal_checkpoint } \n  set sz2 [file size test.db]\n  byte_is_zero test.db [expr $sz-1024]\n} {0}\n\ndo_multiclient_test tn {\n  do_test wal3-10.$tn.1 {\n    sql1 {\n      PRAGMA page_size = 1024;\n      CREATE TABLE t1(x);\n      PRAGMA journal_mode = WAL;\n      PRAGMA wal_autocheckpoint = 100000;\n      BEGIN;\n        INSERT INTO t1 VALUES(randomblob(800));\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 2\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 4\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 8\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 16\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 32\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 64\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 128\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 256\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 512\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 1024\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 2048\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 4096\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   -- 8192\n      COMMIT;\n      CREATE INDEX i1 ON t1(x);\n    }\n\n    expr {[file size test.db-wal] > [expr 1032*9000]}\n  } 1\n\n  do_test wal3-10.$tn.2 {\n    sql2 {PRAGMA integrity_check}\n  } {ok}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal4.test",
    "content": "# 2010 July 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# Verify that an empty database and a non-empty WAL file do not\n# result in database corruption\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nifcapable !wal {finish_test ; return }\n\ndo_test wal4-1.1 {\n  execsql {\n    PRAGMA journal_mode=WAL;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    SELECT x FROM t1 ORDER BY x;\n  }\n} {wal 1 2}\n\ndo_test wal4-1.2 {\n  # Save a copy of the file-system containing the wal and wal-index files \n  # only (no database file).\n  faultsim_save_and_close\n  forcedelete sv_test.db\n} {}\n\ndo_test wal4-1.3 {\n  faultsim_restore_and_reopen\n  catchsql { SELECT * FROM t1 }\n} {1 {no such table: t1}}\n\ndo_faultsim_test wal4-2 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT name FROM sqlite_master }\n} -test {\n  # Result should be zero rows (empty db file).\n  #\n  faultsim_test_result {0 {}}\n\n  # If the SELECT finished successfully, the WAL file should have been\n  # deleted. In no case should the database file have been written, so\n  # it should still be zero bytes in size regardless of whether or not\n  # a fault was injected. Test these assertions:\n  #\n  if { $testrc==0 && [file exists test.db-wal] } { \n    error \"Wal file was not deleted\"\n  }\n  if { [file size test.db]!=0 } { \n    error \"Db file grew to [file size test.db] bytes\"\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal5.test",
    "content": "# 2010 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of \"blocking-checkpoint\"\n# operations.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nifcapable !wal {finish_test ; return }\ndo_not_use_codec\n\nset testprefix wal5\n\nproc db_page_count  {{file test.db}} { expr [file size $file] / 1024 }\nproc wal_page_count {{file test.db}} { wal_frame_count ${file}-wal 1024 }\n\n\n# A checkpoint may be requested either using the C API or by executing\n# an SQL PRAGMA command. To test both methods, all tests in this file are \n# run twice - once using each method to request checkpoints.\n#\nforeach {testprefix do_wal_checkpoint} {\n\n  wal5-pragma {\n    proc do_wal_checkpoint { dbhandle args } {\n      array set a $args\n      foreach key [array names a] {\n        if {[lsearch {-mode -db} $key]<0} { error \"unknown switch: $key\" }\n      }\n\n      set sql \"PRAGMA \"\n      if {[info exists a(-db)]} { append sql \"$a(-db).\" }\n      append sql \"wal_checkpoint\"\n      if {[info exists a(-mode)]} { append sql \" = $a(-mode)\" }\n\n      uplevel [list $dbhandle eval $sql]\n    }\n  }\n\n  wal5-capi {\n    proc do_wal_checkpoint { dbhandle args } {\n      set a(-mode) passive\n      array set a $args\n      foreach key [array names a] {\n        if {[lsearch {-mode -db} $key]<0} { error \"unknown switch: $key\" }\n      }\n\n      set vals {restart full truncate}\n      if {[lsearch -exact $vals $a(-mode)]<0} { set a(-mode) passive }\n\n      set cmd [list sqlite3_wal_checkpoint_v2 $dbhandle $a(-mode)]\n      if {[info exists a(-db)]} { lappend sql $a(-db) }\n\n      uplevel $cmd\n    }\n  }\n} {\n\n  eval $do_wal_checkpoint\n\n  do_multiclient_test tn {\n\n    set ::nBusyHandler 0\n    set ::busy_handler_script \"\"\n    proc busyhandler {n} {\n      incr ::nBusyHandler \n      eval $::busy_handler_script\n      return 0\n    }\n\n    proc reopen_all {} {\n      code1 {db close}\n      code2 {db2 close}\n      code3 {db3 close}\n\n      code1 {sqlite3 db test.db}\n      code2 {sqlite3 db2 test.db}\n      code3 {sqlite3 db3 test.db}\n\n      sql1  { PRAGMA synchronous = NORMAL }\n      code1 { db busy busyhandler }\n    }\n\n    do_test 1.$tn.1 {\n      reopen_all\n      sql1 {\n        PRAGMA page_size = 1024;\n        PRAGMA auto_vacuum = 0;\n        CREATE TABLE t1(x, y);\n        PRAGMA journal_mode = WAL;\n        INSERT INTO t1 VALUES(1, zeroblob(1200));\n        INSERT INTO t1 VALUES(2, zeroblob(1200));\n        INSERT INTO t1 VALUES(3, zeroblob(1200));\n      }\n      expr [file size test.db] / 1024\n    } {2}\n\n    # Have connection 2 grab a read-lock on the current snapshot.\n    do_test 1.$tn.2 { sql2 { BEGIN; SELECT x FROM t1 } } {1 2 3}\n\n    # Attempt a checkpoint.\n    do_test 1.$tn.3 {\n      code1 { do_wal_checkpoint db }\n      list [db_page_count] [wal_page_count]\n    } {5 9}\n\n    # Write to the db again. The log cannot wrap because of the lock still\n    # held by connection 2. The busy-handler has not yet been invoked.\n    do_test 1.$tn.4 {\n      sql1 { INSERT INTO t1 VALUES(4, zeroblob(1200)) }\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } {5 12 0}\n\n    # Now do a blocking-checkpoint. Set the busy-handler up so that connection\n    # 2 releases its lock on the 6th invocation. The checkpointer should then\n    # proceed to checkpoint the entire log file. Next write should go to the \n    # start of the log file.\n    #\n    set ::busy_handler_script { if {$n==5} { sql2 COMMIT } }\n    do_test 1.$tn.5 {\n      code1 { do_wal_checkpoint db -mode restart }\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } {6 12 6}\n    do_test 1.$tn.6 {\n      set ::nBusyHandler 0\n      sql1 { INSERT INTO t1 VALUES(5, zeroblob(1200)) }\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } {6 12 0}\n\n    do_test 1.$tn.7 {\n      reopen_all\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } [expr {[nonzero_reserved_bytes]?\"/# # 0/\":\"7 0 0\"}]\n\n    do_test 1.$tn.8  { sql2 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5}\n    do_test 1.$tn.9  {\n      sql1 { INSERT INTO t1 VALUES(6, zeroblob(1200)) }\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } [expr {[nonzero_reserved_bytes]?\"/# # #/\":\"7 5 0\"}]\n    do_test 1.$tn.10 { sql3 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5 6}\n\n    set ::busy_handler_script { \n      if {$n==5} { sql2 COMMIT } \n      if {$n==6} { set ::db_file_size [db_page_count] }\n      if {$n==7} { sql3 COMMIT }\n    }\n    do_test 1.$tn.11 {\n      code1 { do_wal_checkpoint db -mode restart }\n      list [db_page_count] [wal_page_count] $::nBusyHandler\n    } [expr {[nonzero_reserved_bytes]?\"/# # #/\":\"10 5 8\"}]\n    do_test 1.$tn.12 { set ::db_file_size } 10\n  }\n\n  #-------------------------------------------------------------------------\n  # This block of tests explores checkpoint operations on more than one \n  # database file.\n  #\n  proc setup_and_attach_aux {} {\n    sql1 { ATTACH 'test.db2' AS aux }\n    sql2 { ATTACH 'test.db2' AS aux }\n    sql3 { ATTACH 'test.db2' AS aux }\n    sql1 {\n      PRAGMA aux.auto_vacuum = 0;\n      PRAGMA main.auto_vacuum = 0;\n      PRAGMA main.page_size=1024; PRAGMA main.journal_mode=WAL;\n      PRAGMA aux.page_size=1024;  PRAGMA aux.journal_mode=WAL;\n    }\n  }\n\n  proc file_page_counts {} {\n    list [db_page_count  test.db ] \\\n         [wal_page_count test.db ] \\\n         [db_page_count  test.db2] \\\n         [wal_page_count test.db2]\n  }\n\n  # Test that executing \"PRAGMA wal_checkpoint\" checkpoints all attached\n  # databases, not just the main db.  In capi mode, check that this is\n  # true if a NULL pointer is passed to wal_checkpoint_v2() in place of a \n  # database name.\n  do_multiclient_test tn {\n    setup_and_attach_aux\n    do_test 2.1.$tn.1 {\n      sql1 {\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n        CREATE TABLE aux.t2(a, b);\n        INSERT INTO t2 VALUES(1, 2);\n      }\n    } {}\n    do_test 2.2.$tn.2 { file_page_counts } {1 3 1 3}\n    do_test 2.1.$tn.3 { code1 { do_wal_checkpoint db } } {0 3 3}\n    do_test 2.1.$tn.4 { file_page_counts } {2 3 2 3}\n  }\n\n  do_multiclient_test tn {\n    setup_and_attach_aux\n    do_test 2.2.$tn.1 {\n      execsql {\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n        CREATE TABLE aux.t2(a, b);\n        INSERT INTO t2 VALUES(1, 2);\n        INSERT INTO t2 VALUES(3, 4);\n      }\n    } {}\n    do_test 2.2.$tn.2 { file_page_counts } {1 3 1 4}\n    do_test 2.2.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}\n    do_test 2.2.$tn.4 { code1 { do_wal_checkpoint db -mode restart } } {1 3 3}\n    do_test 2.2.$tn.5 { file_page_counts } {2 3 2 4}\n  }\n\n  do_multiclient_test tn {\n    setup_and_attach_aux\n    do_test 2.3.$tn.1 {\n      execsql {\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n        CREATE TABLE aux.t2(a, b);\n        INSERT INTO t2 VALUES(1, 2);\n      }\n    } {}\n    do_test 2.3.$tn.2 { file_page_counts } {1 3 1 3}\n    do_test 2.3.$tn.3 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2}\n    do_test 2.3.$tn.4 { sql1 { INSERT INTO t1 VALUES(3, 4) } } {}\n    do_test 2.3.$tn.5 { sql1 { INSERT INTO t2 VALUES(3, 4) } } {}\n    do_test 2.3.$tn.6 { file_page_counts } {1 4 1 4}\n    do_test 2.3.$tn.7 { code1 { do_wal_checkpoint db -mode full } } {1 4 3}\n\n    # The checkpoint above only writes page 1 of the db file. The other\n    # page (page 2) is locked by the read-transaction opened by the\n    # [sql2] commmand above. So normally, the db is 1 page in size here.\n    # However, in mmap() mode, the db is pre-allocated to 2 pages at the\n    # start of the checkpoint, even though page 2 cannot be written.\n    set nDb 2\n    if {[permutation]!=\"mmap\"} {set nDb 1}\n    ifcapable !mmap {set nDb 1}\n    do_test 2.3.$tn.8 { file_page_counts } [list $nDb 4 2 4]\n  }\n\n  # Check that checkpoints block on the correct locks. And respond correctly\n  # if they cannot obtain those locks. There are three locks that a checkpoint\n  # may block on (in the following order):\n  #\n  #   1. The writer lock: FULL and RESTART checkpoints block until any writer\n  #      process releases its lock.\n  #\n  #   2. Readers using part of the log file. FULL and RESTART checkpoints block\n  #      until readers using part (but not all) of the log file have finished.\n  #\n  #   3. Readers using any of the log file. After copying data into the\n  #      database file, RESTART checkpoints block until readers using any part\n  #      of the log file have finished.\n  #\n  # This test case involves running a checkpoint while there exist other \n  # processes holding all three types of locks.\n  #\n  foreach {tn1 checkpoint busy_on ckpt_expected expected} {\n    1   PASSIVE   -   {0 3 3}   -\n    2   TYPO      -   {0 3 3}   -\n\n    3   FULL      -   {0 4 4}   2\n    4   FULL      1   {1 3 3}   1\n    5   FULL      2   {1 4 3}   2\n    6   FULL      3   {0 4 4}   2\n\n    7   RESTART   -   {0 4 4}   3\n    8   RESTART   1   {1 3 3}   1\n    9   RESTART   2   {1 4 3}   2\n    10  RESTART   3   {1 4 4}   3\n\n    11  TRUNCATE  -   {0 0 0}   3\n    12  TRUNCATE  1   {1 3 3}   1\n    13  TRUNCATE  2   {1 4 3}   2\n    14  TRUNCATE  3   {1 4 4}   3\n\n  } {\n    do_multiclient_test tn {\n      setup_and_attach_aux\n\n      proc busyhandler {x} {\n        set ::max_busyhandler $x\n        if {$::busy_on!=\"-\" && $x==$::busy_on} { return 1 }\n        switch -- $x {\n          1 { sql2 \"COMMIT ; BEGIN ; SELECT * FROM t1\" }\n          2 { sql3 \"COMMIT\" }\n          3 { sql2 \"COMMIT\" }\n        }\n        return 0\n      }\n      set ::max_busyhandler -\n\n      do_test 2.4.$tn1.$tn.1 {\n        sql1 {\n          CREATE TABLE t1(a, b);\n          INSERT INTO t1 VALUES(1, 2);\n        }\n        sql2 { BEGIN; INSERT INTO t1 VALUES(3, 4) }\n        sql3 { BEGIN; SELECT * FROM t1 }\n      } {1 2}\n\n      do_test 2.4.$tn1.$tn.2 {\n        code1 { db busy busyhandler }\n        code1 { do_wal_checkpoint db -mode [string tolower $checkpoint] }\n      } $ckpt_expected\n      do_test 2.4.$tn1.$tn.3 { set ::max_busyhandler } $expected\n    }\n  }\n\n\n  do_multiclient_test tn {\n\n    code1 $do_wal_checkpoint\n    code2 $do_wal_checkpoint\n    code3 $do_wal_checkpoint\n    \n    do_test 3.$tn.1 {\n      sql1 {\n        PRAGMA auto_vacuum = 0;\n        PRAGMA journal_mode = WAL;\n        PRAGMA synchronous = normal;\n        CREATE TABLE t1(x, y);\n      }\n\n      sql2 { PRAGMA journal_mode }\n      sql3 { PRAGMA journal_mode }\n    } {wal}\n\n    do_test 3.$tn.2 { code2 { do_wal_checkpoint db2 } } {0 2 2}\n\n    do_test 3.$tn.3 { code2 { do_wal_checkpoint db2 } } {0 2 2}\n\n    do_test 3.$tn.4 { code3 { do_wal_checkpoint db3 } } {0 2 2}\n\n    code1 {db  close}\n    code2 {db2 close}\n    code3 {db3 close}\n\n    code1 {sqlite3 db  test.db}\n    code2 {sqlite3 db2 test.db}\n    code3 {sqlite3 db3 test.db}\n\n    do_test 3.$tn.5 { sql3 { PRAGMA journal_mode } } {wal}\n\n    do_test 3.$tn.6 { code3 { do_wal_checkpoint db3 } } {0 0 0}\n  }\n\n  # Test SQLITE_CHECKPOINT_TRUNCATE.\n  #\n  do_multiclient_test tn {\n\n    code1 $do_wal_checkpoint\n    code2 $do_wal_checkpoint\n    code3 $do_wal_checkpoint\n\n    do_test 4.$tn.1 {\n      sql1 {\n        PRAGMA page_size = 1024;\n        PRAGMA auto_vacuum = 0;\n        PRAGMA journal_mode = WAL;\n        PRAGMA synchronous = normal;\n        CREATE TABLE t1(x, y);\n        CREATE INDEX i1 ON t1(x, y);\n        INSERT INTO t1 VALUES(1, 2);\n        INSERT INTO t1 VALUES(3, 4);\n      }\n      file size test.db-wal\n    } [wal_file_size 8 1024]\n\n    do_test 4.$tn.2 { do_wal_checkpoint db -mode truncate } {0 0 0}\n    do_test 4.$tn.3 { file size test.db-wal } 0\n\n    do_test 4.$tn.4 {\n      sql2 { SELECT * FROM t1 }\n    } {1 2 3 4}\n\n    do_test 4.$tn.5 {\n      sql2 { INSERT INTO t1 VALUES('a', 'b') }\n      file size test.db-wal\n    } [wal_file_size 2 1024]\n\n  }\n  \n  # Test that FULL, RESTART and TRUNCATE callbacks block on other clients\n  # and truncate the wal file as required even if the entire wal file has\n  # already been checkpointed when they are invoked.\n  #\n  do_multiclient_test tn {\n\n    code1 $do_wal_checkpoint\n    code2 $do_wal_checkpoint\n    code3 $do_wal_checkpoint\n\n    do_test 5.$tn.1 {\n      sql1 {\n        PRAGMA page_size = 1024;\n        PRAGMA auto_vacuum = 0;\n        PRAGMA journal_mode = WAL;\n        PRAGMA synchronous = normal;\n        CREATE TABLE t1(x, y);\n        CREATE INDEX i1 ON t1(x, y);\n        INSERT INTO t1 VALUES(1, 2);\n        INSERT INTO t1 VALUES(3, 4);\n        INSERT INTO t1 VALUES(5, 6);\n      }\n      file size test.db-wal\n    } [wal_file_size 10 1024]\n\n    do_test 5.$tn.2 { \n      sql2 { BEGIN; SELECT * FROM t1 }\n    } {1 2 3 4 5 6}\n\n    do_test 5.$tn.3 { do_wal_checkpoint db -mode passive } {0 10 10}\n\n    do_test 5.$tn.4 { \n      sql3 { BEGIN; INSERT INTO t1 VALUES(7, 8); }\n    } {}\n\n    do_test 5.$tn.5 { do_wal_checkpoint db -mode passive  } {0 10 10}\n    do_test 5.$tn.6 { do_wal_checkpoint db -mode full     } {1 10 10}\n\n    do_test 5.$tn.7 { sql3 { ROLLBACK } } {}\n\n    do_test 5.$tn.8 { do_wal_checkpoint db -mode full     } {0 10 10}\n    do_test 5.$tn.9 { do_wal_checkpoint db -mode truncate } {1 10 10}\n\n    do_test 5.$tn.10 { \n      file size test.db-wal\n    } [wal_file_size 10 1024]\n\n    proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }\n    db busy xBusyHandler\n\n    do_test 5.$tn.11 { do_wal_checkpoint db -mode truncate } {0 0 0}\n    do_test 5.$tn.12 { file size test.db-wal } 0\n\n    do_test 5.$tn.13 {\n      sql1 {\n        INSERT INTO t1 VALUES(7, 8);\n        INSERT INTO t1 VALUES(9, 10);\n        SELECT * FROM t1;\n      }\n    } {1 2 3 4 5 6 7 8 9 10}\n\n    do_test 5.$tn.14 { \n      sql2 { BEGIN; SELECT * FROM t1 }\n    } {1 2 3 4 5 6 7 8 9 10}\n\n    proc xBusyHandler {n} { return 1 }\n    do_test 5.$tn.15 { do_wal_checkpoint db -mode truncate } {1 4 4}\n    do_test 5.$tn.16 { file size test.db-wal } [wal_file_size 4 1024]\n\n    do_test 5.$tn.17 { do_wal_checkpoint db -mode restart } {1 4 4}\n\n    proc xBusyHandler {n} { sql2 { COMMIT } ; return 0 }\n    db busy xBusyHandler\n    do_test 5.$tn.18 { do_wal_checkpoint db -mode restart } {0 4 4}\n    do_test 5.$tn.19 { file size test.db-wal } [wal_file_size 4 1024]\n\n    do_test 5.$tn.20 { do_wal_checkpoint db -mode truncate } {0 0 0}\n    do_test 5.$tn.21 { file size test.db-wal } 0\n  }\n\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal6.test",
    "content": "# 2010 December 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nset testprefix wal6\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nsource $testdir/malloc_common.tcl\nifcapable !wal {finish_test ; return }\n\n#-------------------------------------------------------------------------\n# Changing to WAL mode in one connection forces the change in others.\n#\ndb close\nforcedelete test.db\n\nset all_journal_modes {delete persist truncate memory off}\nforeach jmode $all_journal_modes {\n\n  do_test wal6-1.0.$jmode {\n    sqlite3 db test.db\n    execsql \"PRAGMA journal_mode = $jmode;\"\n  } $jmode\n\n  do_test wal6-1.1.$jmode {\n    execsql {\n      CREATE TABLE t1(a INTEGER PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1,2);\n      SELECT * FROM t1;\n    }\n  } {1 2}\n\n# Under Windows, you'll get an error trying to delete\n# a file this is already opened.  Close the first connection\n# so the other tests work.\nif {$tcl_platform(platform)==\"windows\"} {\n  if {$jmode==\"persist\" || $jmode==\"truncate\"} {\n    db close\n  }\n}\n\n  do_test wal6-1.2.$jmode {\n    sqlite3 db2 test.db\n    execsql {\n    PRAGMA journal_mode=WAL;\n    INSERT INTO t1 VALUES(3,4);\n    SELECT * FROM t1 ORDER BY a;\n    } db2\n  } {wal 1 2 3 4}\n\nif {$tcl_platform(platform)==\"windows\"} {\n  if {$jmode==\"persist\" || $jmode==\"truncate\"} {\n    sqlite3 db test.db\n  }\n}\n\n  do_test wal6-1.3.$jmode {\n    execsql {\n      SELECT * FROM t1 ORDER BY a;\n    }\n  } {1 2 3 4}\n\n  db close\n  db2 close\n  forcedelete test.db\n\n}\n\n#-------------------------------------------------------------------------\n# Test that SQLITE_BUSY_SNAPSHOT is returned as expected.\n#\nreset_db\nsqlite3 db2 test.db\n\ndo_execsql_test 2.1 {\n  PRAGMA journal_mode = WAL;\n  CREATE TABLE t1(a PRIMARY KEY, b TEXT);\n  INSERT INTO t1 VALUES(1, 'one');\n  INSERT INTO t1 VALUES(2, 'two');\n  BEGIN;\n    SELECT * FROM t1;\n} {wal 1 one 2 two}\n\ndo_test 2.2 {\n  execsql {\n    SELECT * FROM t1;\n    INSERT INTO t1 VALUES(3, 'three');\n  } db2\n} {1 one 2 two}\n\ndo_catchsql_test 2.3 { \n  INSERT INTO t1 VALUES('x', 'x') \n} {1 {database is locked}}\n\ndo_test 2.4 { \n  list [sqlite3_errcode db] [sqlite3_extended_errcode db]\n} {SQLITE_BUSY SQLITE_BUSY_SNAPSHOT}\n\ndo_execsql_test 2.5 {\n  SELECT * FROM t1;\n  COMMIT;\n  INSERT INTO t1 VALUES('x', 'x') \n} {1 one 2 two}\n\nproc test3 {prefix} {\n  do_test $prefix.1 {\n    execsql { SELECT count(*) FROM t1 } \n  } {0}\n  do_test $prefix.2 {\n    execsql { INSERT INTO t1 VALUES('x', 'x') } db2\n  } {}\n  do_test $prefix.3 {\n    execsql { INSERT INTO t1 VALUES('y', 'y') }\n  } {}\n  do_test $prefix.4 {\n    execsql { SELECT count(*) FROM t1 } \n  } {2}\n}\n\ndo_execsql_test 2.6.1 { DELETE FROM t1 }\ntest3 2.6.2\n\ndb func test3 test3\ndo_execsql_test 2.6.3 { DELETE FROM t1 }\ndb eval {SELECT test3('2.6.4')}\n\ndo_test 2.x {\n  db2 close\n} {}\n\n#-------------------------------------------------------------------------\n# Check that if BEGIN IMMEDIATE fails, it does not leave the user with\n# an open read-transaction (unless one was already open before the BEGIN \n# IMMEDIATE). Even if there are other active VMs.\n#\n\nproc test4 {prefix} {\n  do_test $prefix.1 {\n    catchsql { BEGIN IMMEDIATE }\n  } {1 {database is locked}}\n\n  do_test $prefix.2 {\n    execsql { COMMIT } db2\n  } {}\n\n  do_test $prefix.3 {\n    execsql { BEGIN IMMEDIATE }\n  } {}\n  do_test $prefix.4 {\n    execsql { COMMIT }\n  } {}\n}\n\nreset_db\nsqlite3 db2 test.db\ndo_execsql_test 3.1 { \n  PRAGMA journal_mode = WAL;\n  CREATE TABLE ab(a PRIMARY KEY, b);\n} {wal}\n\ndo_test 3.2.1 { \n  execsql { \n    BEGIN;\n      INSERT INTO ab VALUES(1, 2);\n  } db2\n} {}\ntest4 3.2.2\n\ndb func test4 test4\ndo_test 3.3.1 {\n  execsql { \n    BEGIN;\n      INSERT INTO ab VALUES(3, 4);\n  } db2\n} {}\n\ndb eval {SELECT test4('3.3.2')}\n\ndo_test 3.x {\n  db2 close\n} {}\n\n#-------------------------------------------------------------------------\n# Check that if a wal file has been partially checkpointed, no frames are\n# read from the checkpointed part.\n#\nreset_db\ndo_execsql_test 4.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n  PRAGMA wal_checkpoint = truncate;\n} {wal 0 0 0}\n\ndo_test 4.2 {\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  file size test.db-wal\n} [wal_file_size 1 1024]\n\ndo_test 4.3 {\n  sqlite3 db2 test.db\n  execsql { \n    BEGIN;\n    INSERT INTO t2 VALUES(3, 4);\n  }\n  execsql { PRAGMA wal_checkpoint = passive } db2\n} {0 1 1}\n\ndo_test 4.3 {\n  execsql { COMMIT }\n  db2 close\n  hexio_write test.db-wal 0 [string repeat 00 2000]\n  sqlite3 db2 test.db\n} {}\n\ndo_test 4.4.1 { \n  catchsql { SELECT * FROM t1 } db2 \n} {0 {1 2}}\ndo_test 4.4.2 { \n  catchsql { SELECT * FROM t2 } db2 \n} {1 {database disk image is malformed}}\n\n#-------------------------------------------------------------------------\n# Confirm that it is possible to get an SQLITE_BUSY_SNAPSHOT error from\n# \"BEGIN EXCLUSIVE\" if the connection already has an open read-transaction.\n#\ndb close\ndb2 close\nreset_db\nsqlite3 db2 test.db\ndo_execsql_test 5.1 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n} {wal}\ndo_test 5.2 {\n  set res [list]\n  db eval {\n    SELECT * FROM t1\n  } {\n    if {$x==1} {\n      db2 eval { INSERT INTO t1 VALUES(5, 6) }\n    } \n    if {$x==3} {\n      set res [catchsql {BEGIN EXCLUSIVE}]\n      lappend res [sqlite3_extended_errcode db]\n    } \n  }\n  set res\n} {1 {database is locked} SQLITE_BUSY_SNAPSHOT}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal64k.test",
    "content": "# 2010 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix wal64k\n\nifcapable !wal {finish_test ; return }\n\nif {$tcl_platform(platform) != \"unix\"} {\n  finish_test\n  return\n}\n\ndb close\ntest_syscall pagesize 65536\nsqlite3 db test.db\n\ndo_execsql_test 1.0 { \n  PRAGMA journal_mode = WAL;\n  CREATE TABLE t1(x);\n  CREATE INDEX i1 ON t1(x);\n} {wal}\ndo_test 1.1 { file size test.db-shm } {65536}\n\ndo_test 1.2 {\n  execsql BEGIN\n  while {[file size test.db-shm]==65536} {\n    execsql { INSERT INTO t1 VALUES( randstr(900,1100) ) }\n  }\n  execsql COMMIT\n  file size test.db-shm\n} {131072}\n\nintegrity_check 1.3\n\ndb close\ntest_syscall pagesize -1\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal7.test",
    "content": "# 2011 May 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the PRAGMA journal_size_limit when\n# in WAL mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !wal {finish_test ; return }\n\n# Case 1:  No size limit.  Journal can get large.\n#\ndo_test wal7-1.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA journal_mode=WAL;\n    PRAGMA wal_autocheckpoint=50;  -- 50 pages\n    CREATE TABLE t1(x, y UNIQUE);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(zeroblob(200000),4);\n    CREATE TABLE t2(z);\n    DELETE FROM t1;\n    INSERT INTO t2 SELECT x FROM t1;\n  }\n  expr {[file size test.db-wal]>50*1100}\n} 1\ndo_test wal7-1.1 {\n  db eval {PRAGMA wal_checkpoint}\n  expr {[file size test.db-wal]>50*1100}\n} 1\ndo_test wal7-1.2 {\n  db eval {INSERT INTO t2 VALUES('hi');}\n  expr {[file size test.db-wal]>50*1100}\n} 1\n\n# Case 2:  Size limit at half the autocheckpoint size.\n#\ndo_test wal7-2.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA journal_mode=WAL;\n    PRAGMA wal_autocheckpoint=50;  -- 50 pages\n    PRAGMA journal_size_limit=25000;\n    CREATE TABLE t1(x, y UNIQUE);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(zeroblob(200000),4);\n    CREATE TABLE t2(z);\n    DELETE FROM t1;\n    INSERT INTO t2 VALUES(1);\n  }\n  file size test.db-wal\n} 25000\n\n\n# Case 3:  Size limit of zero.\n#\ndo_test wal7-3.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA journal_mode=WAL;\n    PRAGMA wal_autocheckpoint=50;  -- 50 pages\n    PRAGMA journal_size_limit=0;\n    CREATE TABLE t1(x, y UNIQUE);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(zeroblob(200000),4);\n    CREATE TABLE t2(z);\n    DELETE FROM t1;\n    INSERT INTO t2 VALUES(1);\n  }\n  set sz [file size test.db-wal]\n  expr {$sz>0 && $sz<13700}\n} 1\n\n\n# Case 4:  Size limit set before going WAL\n#\ndo_test wal7-4.0 {\n  db close\n  forcedelete test.db\n  sqlite3 db test.db\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA journal_size_limit=25000;\n    PRAGMA journal_mode=WAL;\n    PRAGMA wal_autocheckpoint=50;  -- 50 pages\n    CREATE TABLE t1(x, y UNIQUE);\n    INSERT INTO t1 VALUES(1,2);\n    INSERT INTO t1 VALUES(zeroblob(200000),4);\n    CREATE TABLE t2(z);\n    DELETE FROM t1;\n    INSERT INTO t2 VALUES(1);\n  }\n  set sz [file size test.db-wal]\n} 25000\n\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal8.test",
    "content": "# 2012 February 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n# Specifically, it tests the case where a connection opens an empty\n# file. Then, another connection opens the same file and initializes\n# the connection as a WAL database. Following this, the first connection\n# executes a \"PRAGMA page_size = XXX\" command to set its expected page\n# size, and then queries the database.\n#\n# This is an unusual case, as normally SQLite is able to glean the page\n# size from the database file as soon as it is opened (even before the\n# first read transaction is executed), and the \"PRAGMA page_size = XXX\"\n# is a no-op.\n#\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix wal8\nifcapable !wal {finish_test ; return }\ndo_not_use_codec\n\ndb close\nforcedelete test.db test.db-wal\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test 1.0 {\n  execsql {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  } db2\n} {wal}\n\ndo_catchsql_test 1.1 {\n  PRAGMA page_size = 4096;\n  VACUUM;\n} {0 {}}\n\ndb close\ndb2 close\nforcedelete test.db test.db-wal\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test 2.0 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n    PRAGMA journal_mode = wal;\n  } db2\n} {wal}\n\ndo_catchsql_test 2.1 {\n  PRAGMA page_size = 4096;\n  VACUUM;\n} {0 {}}\n\ndb close\ndb2 close\nforcedelete test.db test.db-wal\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test 3.0 {\n  execsql {\n    PRAGMA journal_mode = wal;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, 2);\n  } db2\n} {wal}\n\ndo_execsql_test 3.1 {\n  PRAGMA page_size = 4096;\n  SELECT name FROM sqlite_master;\n} {t1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal9.test",
    "content": "# 2012 October 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This test case tests that a problem causing a failing assert() has\n# been fixed. The problem occurred if a writer process with a subset\n# of the *shm file mapped rolled back a transaction begun after the\n# entire WAL file was checkpointed into the db file (i.e. a transaction\n# that would have restarted the WAL file from the beginning).\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix wal9\n\nsqlite3 db2 test.db\n\ndo_execsql_test 1.0 {\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = WAL;\n  PRAGMA wal_autocheckpoint = 0;\n  CREATE TABLE t(x);\n} {wal 0}\n\ndo_test 1.1 { \n  execsql \"SELECT * FROM t\" db2\n} {}\n\ndo_execsql_test 1.2 {\n  BEGIN;\n    INSERT INTO t VALUES(randomblob(100));\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n\n    INSERT INTO t SELECT randomblob(100) FROM t;\n    INSERT INTO t SELECT randomblob(100) FROM t;\n  COMMIT;\n} {}\n\n# Check file sizes are as expected. The real requirement here is that \n# the *shm file is now more than one chunk (>32KiB).\n#\n# The sizes of various files are slightly different in normal and \n# auto-vacuum mode.\ndo_test 1.3 { file size test.db     } {1024}\ndo_test 1.4 { expr {[file size test.db-wal]>(1500*1024)} } {1}\ndo_test 1.5 { expr {[file size test.db-shm]>32768} }       {1}\ndo_test 1.6 { \n  foreach {a b c} [db eval {PRAGMA wal_checkpoint}] break\n  list [expr {$a==0}] [expr {$b>14500}] [expr {$c>14500}] [expr {$b==$c}]\n} {1 1 1 1}\n\n# At this point connection [db2] has mapped the first 32KB of the *shm file\n# only. Because the entire WAL file has been checkpointed, it is not \n# necessary to map any more of the *-shm file to read or write the database\n# (since all data will be read directly from the db file). \n#\n# However, at one point if a transaction that had not yet written to the \n# WAL file was rolled back an assert() attempting to verify that the entire \n# *-shm file was mapped would fail. If NDEBUG was defined (and the assert() \n# disabled) this bug caused SQLite to ignore the return code of a mmap() \n# call.\n#\ndo_test 1.7 {\n  execsql { \n    BEGIN;\n      INSERT INTO t VALUES('hello');\n    ROLLBACK;\n  } db2\n} {}\ndb2 close\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wal_common.tcl",
    "content": "# 2010 June 03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains common code used by many different malloc tests\n# within the test suite.\n#\n\nproc wal_file_size {nFrame pgsz} {\n  expr {32 + ($pgsz+24)*$nFrame}\n}\n\nproc wal_frame_count {zFile pgsz} {\n  if {[file exists $zFile]==0} { return 0 }\n  set f [file size $zFile]\n  if {$f < 32} { return 0 }\n  expr {($f - 32) / ($pgsz+24)}\n}\n\nproc wal_cksum_intlist {ckv1 ckv2 intlist} {\n  upvar $ckv1 c1\n  upvar $ckv2 c2\n  foreach {v1 v2} $intlist {\n    set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}]\n    set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}]\n  }\n}\n\n\n# This proc calculates checksums in the same way as those used by SQLite \n# in WAL files. If the $endian argument is \"big\", then checksums are\n# calculated by interpreting data as an array of big-endian integers. If\n# it is \"little\", data is interpreted as an array of little-endian integers.\n#\nproc wal_cksum {endian ckv1 ckv2 blob} {\n  upvar $ckv1 c1\n  upvar $ckv2 c2\n\n  if {$endian!=\"big\" && $endian!=\"little\"} {\n    return -error \"Bad value \\\"$endian\\\" - must be \\\"big\\\" or \\\"little\\\"\"\n  }\n  set scanpattern I*\n  if {$endian == \"little\"} { set scanpattern i* }\n\n  binary scan $blob $scanpattern values\n  wal_cksum_intlist c1 c2 $values\n}\n\nproc wal_set_walhdr {filename {intlist {}}} {\n  if {[llength $intlist]==6} {\n    set blob [binary format I6 $intlist]\n    set endian little\n    if {[lindex $intlist 0] & 0x00000001} { set endian big }\n    set c1 0\n    set c2 0\n    wal_cksum $endian c1 c2 $blob\n    append blob [binary format II $c1 $c2]\n\n    set fd [open $filename r+]\n    fconfigure $fd -translation binary\n    fconfigure $fd -encoding binary\n    seek $fd 0\n    puts -nonewline $fd $blob\n    close $fd\n  }\n\n  set fd [open $filename]\n  fconfigure $fd -translation binary\n  fconfigure $fd -encoding binary\n  set blob [read $fd 24]\n  close $fd\n\n  binary scan $blob I6 ints\n  set ints\n}\n\nproc wal_fix_walindex_cksum {hdrvar} {\n  upvar $hdrvar hdr\n  set c1 0\n  set c2 0\n  wal_cksum_intlist c1 c2 [lrange $hdr 0 9]\n  lset hdr 10 $c1\n  lset hdr 11 $c2\n}\n\n\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walbak.test",
    "content": "# 2010 April 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nsource $testdir/malloc_common.tcl\n\ndo_not_use_codec\n\nifcapable !wal {finish_test ; return }\n\n\n# Test organization:\n# \n#   walback-1.*: Simple tests.\n#\n#   walback-2.*: Test backups when the source db is modified mid-backup.\n#\n#   walback-3.*: Backup of WAL sources into rollback destinations, and \n#                vice-versa.\n#\n\n# Make sure a simple backup from a WAL database works.\n#\ndo_test walbak-1.0 {\n  execsql { \n    PRAGMA synchronous = NORMAL;\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = wal;\n    BEGIN;\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES('I', 'one');\n    COMMIT;\n  }\n} {wal}\ndo_test walbak-1.1 {\n  forcedelete bak.db bak.db-journal bak.db-wal\n  db backup bak.db\n  file size bak.db\n} [expr 3*1024]\ndo_test walbak-1.2 {\n  sqlite3 db2 bak.db\n  execsql { \n    SELECT * FROM t1;\n    PRAGMA main.journal_mode;\n  } db2\n} {I one wal}\ndo_test walbak-1.3 {\n  execsql { PRAGMA integrity_check } db2\n} {ok}\ndb2 close\n\n# Try a VACUUM on a WAL database.\n#\ndo_test walbak-1.4 {\n  execsql { \n    VACUUM;\n    PRAGMA main.journal_mode;\n  }\n} {wal}\ndo_test walbak-1.5 {\n  list [file size test.db] [file size test.db-wal]\n} [list 1024 [wal_file_size 6 1024]]\ndo_test walbak-1.6 {\n  execsql { PRAGMA wal_checkpoint }\n  list [file size test.db] [file size test.db-wal]\n} [list [expr 3*1024] [wal_file_size 6 1024]]\ndo_test walbak-1.6.1 {\n  hexio_read test.db 18 2\n} {0202}\ndo_test walbak-1.7 {\n  execsql { \n    CREATE TABLE t2(a, b);\n    INSERT INTO t2 SELECT * FROM t1;\n    DROP TABLE t1;\n  }\n  list [file size test.db] [file size test.db-wal]\n} [list [expr 3*1024] [wal_file_size 6 1024]]\ndo_test walbak-1.8 {\n  execsql { VACUUM }\n  list [file size test.db] [file size test.db-wal]\n} [list [expr 3*1024] [wal_file_size 8 1024]]\ndo_test walbak-1.9 {\n  execsql { PRAGMA wal_checkpoint }\n  list [file size test.db] [file size test.db-wal]\n} [list [expr 2*1024] [wal_file_size 8 1024]]\n\n#-------------------------------------------------------------------------\n# Backups when the source db is modified mid-backup.\n#\nproc sig {{db db}} {\n  $db eval { \n    PRAGMA integrity_check;\n    SELECT md5sum(a, b) FROM t1; \n  }\n}\ndb close\ndelete_file test.db\nsqlite3 db test.db\ndo_test walbak-2.1 {\n  execsql { PRAGMA journal_mode = WAL }\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(500), randomblob(500));\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /*  2 */\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /*  4 */\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /*  8 */\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 16 */\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 32 */\n      INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1; /* 64 */\n    COMMIT;\n  }\n} {}\ndo_test walbak-2.2 {\n  forcedelete abc.db\n  db backup abc.db\n  sqlite3 db2 abc.db\n  string compare [sig db] [sig db2]\n} {0}\n\ndo_test walbak-2.3 {\n  sqlite3_backup B db2 main db main\n  B step 50\n  execsql { UPDATE t1 SET b = randomblob(500) }\n  list [B step 1000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test walbak-2.4 {\n  string compare [sig db] [sig db2]\n} {0}\n\ndo_test walbak-2.5 {\n  db close\n  sqlite3 db test.db\n  execsql { PRAGMA cache_size = 10 }\n  sqlite3_backup B db2 main db main\n  B step 50\n  execsql {\n    BEGIN;\n      UPDATE t1 SET b = randomblob(500);\n  }\n  expr [file size test.db-wal] > 10*1024\n} {1}\ndo_test walbak-2.6 {\n  B step 1000\n} {SQLITE_BUSY}\ndo_test walbak-2.7 {\n  execsql COMMIT\n  list [B step 1000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test walbak-2.8 {\n  string compare [sig db] [sig db2]\n} {0}\n\ndo_test walbak-2.9 {\n  db close\n  sqlite3 db test.db\n  execsql { PRAGMA cache_size = 10 }\n  sqlite3_backup B db2 main db main\n  B step 50\n  execsql {\n    BEGIN;\n      UPDATE t1 SET b = randomblob(500);\n  }\n  expr [file size test.db-wal] > 10*1024\n} {1}\ndo_test walbak-2.10 {\n  B step 1000\n} {SQLITE_BUSY}\ndo_test walbak-2.11 {\n  execsql ROLLBACK\nset sigB [sig db]\n  list [B step 1000] [B finish]\n} {SQLITE_DONE SQLITE_OK}\ndo_test walbak-2.12 {\n  string compare [sig db] [sig db2]\n} {0}\ndb2 close\ndb close\n\n#-------------------------------------------------------------------------\n# Run some backup operations to copy back and forth between WAL and:\n#\n#   walbak-3.1.*: an in-memory database\n#\n#   walbak-3.2.*: a temporary database\n#\n#   walbak-3.3.*: a database in rollback mode.\n#\n#   walbak-3.4.*: a database in rollback mode that (initially) uses a \n#                 different page-size.\n#\n# Check that this does not confuse any connected clients.\n#\nforeach {tn setup} {\n  1 {\n    sqlite3 db  test.db\n    sqlite3 db2 :memory:\n    db  eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }\n    db2 eval { PRAGMA page_size = 1024 }\n  }\n\n  2 {\n    sqlite3 db  test.db\n    sqlite3 db2 \"\"\n    db  eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }\n    db2 eval { PRAGMA page_size = 1024 }\n  }\n\n  3 {\n    sqlite3 db  test.db\n    sqlite3 db2 test.db2\n    db  eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }\n    db2 eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = PERSIST }\n  }\n\n  4 {\n    sqlite3 db  test.db\n    sqlite3 db2 test.db2\n    db  eval { PRAGMA page_size = 1024 ; PRAGMA journal_mode = WAL }\n    db2 eval { \n      PRAGMA page_size = 2048;\n      PRAGMA journal_mode = PERSIST;\n      CREATE TABLE xx(x);\n    }\n  }\n\n} {\n  if {$tn==4 && [sqlite3 -has-codec]} continue\n  foreach f [glob -nocomplain test.db*] { forcedelete $f }\n\n  eval $setup\n\n  do_test walbak-3.$tn.1 {\n    execsql {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      SELECT * FROM t1;\n    }\n  } {1 2 3 4}\n\n  do_test walbak-3.$tn.2 {\n    sqlite3_backup B db2 main db main\n    B step 10000\n    B finish\n    execsql { SELECT * FROM t1 } db2\n  } {1 2 3 4}\n\n  do_test walbak-3.$tn.3 {\n    execsql {\n      INSERT INTO t1 VALUES(5, 6);\n      INSERT INTO t1 VALUES(7, 8);\n      SELECT * FROM t1;\n    } db2\n  } {1 2 3 4 5 6 7 8}\n\n  do_test walbak-3.$tn.4 {\n    sqlite3_backup B db main db2 main\n    B step 10000\n    B finish\n    execsql { SELECT * FROM t1 }\n  } {1 2 3 4 5 6 7 8}\n\n  # Check that [db] is still in WAL mode.\n  do_test walbak-3.$tn.5 {\n    execsql { PRAGMA journal_mode }\n  } {wal}\n  do_test walbak-3.$tn.6 {\n    execsql { PRAGMA wal_checkpoint }\n    hexio_read test.db 18 2\n  } {0202}\n\n  # If it was not an in-memory database, check that [db2] is still in\n  # rollback mode.\n  if {[file exists test.db2]} {\n    do_test walbak-3.$tn.7 {\n      execsql { PRAGMA journal_mode } db2\n    } {wal}\n    do_test walbak-3.$tn.8 {\n      execsql { PRAGMA wal_checkpoint }\n      hexio_read test.db 18 2\n    } {0202}\n  }\n\n  db  close\n  db2 close\n}\n\n#-------------------------------------------------------------------------\n# Test that the following holds when a backup operation is run:\n#\n#   Source  |  Destination inital  |  Destination final\n#   ---------------------------------------------------\n#   Rollback   Rollback               Rollback\n#   Rollback   WAL                    WAL\n#   WAL        Rollback               WAL\n#   WAL        WAL                    WAL\n#\nforeach {tn src dest dest_final} {\n  1   delete    delete    delete\n  2   delete    wal       wal\n  3   wal       delete    wal\n  4   wal       wal       wal\n} {\n  catch { db close } \n  catch { db2 close } \n  forcedelete test.db test.db2\n\n  do_test walbak-4.$tn.1 {\n    sqlite3 db test.db\n    db eval \"PRAGMA journal_mode = $src\"\n    db eval {\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES('I', 'II');\n      INSERT INTO t1 VALUES('III', 'IV');\n    }\n\n    sqlite3 db2 test.db2\n    db2 eval \"PRAGMA journal_mode = $dest\"\n    db2 eval {\n      CREATE TABLE t2(x, y);\n      INSERT INTO t2 VALUES('1', '2');\n      INSERT INTO t2 VALUES('3', '4');\n    }\n  } {}\n\n  do_test walbak-4.$tn.2 { execsql { PRAGMA journal_mode } db  } $src\n  do_test walbak-4.$tn.3 { execsql { PRAGMA journal_mode } db2 } $dest\n\n  do_test walbak-4.$tn.4 { db backup test.db2 } {}\n  do_test walbak-4.$tn.5 {\n    execsql { SELECT * FROM t1 } db2\n  } {I II III IV}\n  do_test walbak-4.$tn.5 { execsql { PRAGMA journal_mode } db2 } $dest_final\n\n\n  db2 close\n  do_test walbak-4.$tn.6 { file exists test.db2-wal } 0\n  sqlite3 db2 test.db2\n  do_test walbak-4.$tn.7 { execsql { PRAGMA journal_mode } db2 } $dest_final\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walbig.test",
    "content": "# 2010 July 07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script testing the ability of SQLite to handle database\n# files larger than 4GB in WAL mode.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !wal {\n  finish_test\n  return\n}\n\n# Do not use a codec for this file, as the database is manipulated using\n# external methods (the [fake_big_file] and [hexio_write] commands).\n#\ndo_not_use_codec\n\n# If SQLITE_DISABLE_LFS is defined, omit this file.\nifcapable !lfs {\n  finish_test\n  return\n}\n\nset a_string_counter 1\nproc a_string {n} {\n  incr ::a_string_counter\n  string range [string repeat \"${::a_string_counter}.\" $n] 1 $n\n}\ndb func a_string a_string\n\ndo_test walbig-1.0 {\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES(a_string(300), a_string(500));\n    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;\n    INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1;\n  }\n} {wal}\n\ndb close\nif {[catch {fake_big_file 5000 [get_pwd]/test.db}]} {\n  puts \"**** Unable to create a file larger than 5000 MB. *****\"\n  finish_test\n  return\n}\nhexio_write test.db 28 00000000\n\nsqlite3 db test.db\ndb func a_string a_string\ndo_test walbig-1.1 {\n  execsql { INSERT INTO t1 SELECT a_string(300), a_string(500) FROM t1 }\n} {}\ndb close\n\nsqlite3 db test.db\ndo_test walbig-1.2 {\n  execsql { SELECT a FROM t1 ORDER BY a }\n} [lsort [execsql { SELECT a FROM t1 ORDER BY rowid }]]\n\ndo_test walbig-1.3 {\n  execsql { SELECT b FROM t1 ORDER BY b }\n} [lsort [execsql { SELECT b FROM t1 ORDER BY rowid }]]\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walblock.test",
    "content": "# 2015 Mar 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\n\nfinish_test; return;    #  Feature currently not implemented.\nifcapable !wal {finish_test ; return }\nif {$::tcl_platform(platform)!=\"unix\"} { finish_test ; return }\nset testprefix walblock\n\ncatch { db close }\ntestvfs tvfs -fullshm 1\nforeach f [glob test.db*] { forcedelete $f }\n\nsqlite3 db test.db -vfs tvfs\ndo_execsql_test 1.1.0 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n  INSERT INTO t1 VALUES(3, 4);\n  INSERT INTO t1 VALUES(5, 6);\n  PRAGMA journal_mode = wal;\n  INSERT INTO t1 VALUES(7, 8);\n} {wal}\n\ndo_test 1.1.1 { \n  lsort [glob test.db*] \n} {test.db test.db-shm test.db-wal}\n\ndo_test 1.1.2 { \n  set C [launch_testfixture]\n  testfixture $C {\n    sqlite3 db test.db\n    db eval { SELECT * FROM t1 }\n  }\n} {1 2 3 4 5 6 7 8}\n\ndo_test 1.1.3 { \n  set ::out [list]\n  testfixture $C {\n    db eval { SELECT * FROM t1 }\n  } [list set ::out]\n  set ::out\n} {}\n\ndo_test 1.1.4 { \n  vwait ::out\n  set ::out\n} {1 2 3 4 5 6 7 8}\n\n#\n# Test that if a read client cannot read the wal-index header because a\n# write client is in the middle of updating it, the reader blocks until\n# the writer finishes.\n#\n#   1. Open a write transaction using client [db] in this process.\n#\n#   2. Attempt to commit the write transaction. Intercept the xShmBarrier()\n#      call made by the writer between updating the two copies of the\n#      wal-index header.\n#\n#   3. Within the xShmBarrier() callback, make an asynchronous request to\n#      the other process to read from the database. It should block, as it\n#      cannot get read the wal-index header.\n#\n#   4. Still in xShmBarrier(), wait for 5 seconds. Check that the other\n#      process has not answered the request.\n#\n#   5: Finish committing the transaction. Then wait for 0.5 seconds more.\n#      Ensure that the second process has by this stage read the database\n#      and that the snapshot it read included the transaction committed in\n#      step (4).\n#\ndo_execsql_test 1.2.1 {\n  BEGIN;\n    INSERT INTO t1 VALUES(9, 10);\n} {}\n\ntvfs script barrier_callback\ntvfs filter xShmBarrier\nproc barrier_callback {method args} {\n  set ::out \"\"\n  testfixture $::C { db eval { SELECT * FROM t1 } } {set ::out}\n\n  do_test \"1.2.2.(blocking 10 seconds)\" { \n    set ::continue 0\n    after 10000 {set ::continue 1}\n    vwait ::continue\n    set ::out \n  } {}\n}\n\nexecsql COMMIT\n\ndo_test \"1.2.3.(blocking 0.5 seconds)\" { \n  set ::continue 0\n  after 500 {set ::continue 1}\n  vwait ::continue\n  set ::out \n} {1 2 3 4 5 6 7 8 9 10}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walcksum.test",
    "content": "# 2010 May 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\n\nifcapable !wal {finish_test ; return }\n\n# Read and return the contents of file $filename. Treat the content as\n# binary data.\n#\nproc readfile {filename} {\n  set fd [open $filename]\n  fconfigure $fd -encoding binary\n  fconfigure $fd -translation binary\n  set data [read $fd]\n  close $fd\n  return $data\n}\n\n#\n# File $filename must be a WAL file on disk. Check that the checksum of frame\n# $iFrame in the file is correct when interpreting data as $endian-endian\n# integers ($endian must be either \"big\" or \"little\"). If the checksum looks\n# correct, return 1. Otherwise 0.\n#\nproc log_checksum_verify {filename iFrame endian} {\n  set data [readfile $filename]\n\n  foreach {offset c1 c2} [log_checksum_calc $data $iFrame $endian] {}\n\n  binary scan [string range $data $offset [expr $offset+7]] II expect1 expect2\n  set expect1 [expr $expect1&0xFFFFFFFF]\n  set expect2 [expr $expect2&0xFFFFFFFF]\n\n  expr {$c1==$expect1 && $c2==$expect2}\n}\n\n# File $filename must be a WAL file on disk. Compute the checksum for frame\n# $iFrame in the file by interpreting data as $endian-endian integers \n# ($endian must be either \"big\" or \"little\"). Then write the computed \n# checksum into the file.\n#\nproc log_checksum_write {filename iFrame endian} {\n  set data [readfile $filename]\n\n  foreach {offset c1 c2} [log_checksum_calc $data $iFrame $endian] {}\n\n  set bin [binary format II $c1 $c2]\n  set fd [open $filename r+]\n  fconfigure $fd -encoding binary\n  fconfigure $fd -translation binary\n  seek $fd $offset\n  puts -nonewline $fd $bin\n  close $fd\n}\n\n# Calculate and return the checksum for a particular frame in a WAL.\n#\n# Arguments are:\n#\n#   $data         Blob containing the entire contents of a WAL.\n#\n#   $iFrame       Frame number within the $data WAL. Frames are numbered \n#                 starting at 1.\n#\n#   $endian       One of \"big\" or \"little\".\n#\n# Returns a list of three elements, as follows:\n#\n#   * The byte offset of the checksum belonging to frame $iFrame in the WAL.\n#   * The first integer in the calculated version of the checksum.\n#   * The second integer in the calculated version of the checksum.\n#\nproc log_checksum_calc {data iFrame endian} {\n  \n  binary scan [string range $data 8 11] I pgsz\n  if {$iFrame > 1} {\n    set n [wal_file_size [expr $iFrame-2] $pgsz]\n    binary scan [string range $data [expr $n+16] [expr $n+23]] II c1 c2\n  } else {\n    set c1 0\n    set c2 0\n    wal_cksum $endian c1 c2 [string range $data 0 23]\n  }\n\n  set n [wal_file_size [expr $iFrame-1] $pgsz]\n  wal_cksum $endian c1 c2 [string range $data $n [expr $n+7]]\n  wal_cksum $endian c1 c2 [string range $data [expr $n+24] [expr $n+24+$pgsz-1]]\n\n  list [expr $n+16] $c1 $c2\n}\n\n#\n# File $filename must be a WAL file on disk. Set the 'magic' field of the\n# WAL header to indicate that checksums are $endian-endian ($endian must be\n# either \"big\" or \"little\").\n#\n# Also update the wal header checksum (since the wal header contents may\n# have changed).\n#\nproc log_checksum_writemagic {filename endian} {\n  set val [expr {0x377f0682 | ($endian == \"big\" ? 1 : 0)}]\n  set bin [binary format I $val]\n  set fd [open $filename r+]\n  fconfigure $fd -encoding binary\n  fconfigure $fd -translation binary\n  puts -nonewline $fd $bin\n\n  seek $fd 0\n  set blob [read $fd 24]\n  set c1 0\n  set c2 0\n  wal_cksum $endian c1 c2 $blob \n  seek $fd 24\n  puts -nonewline $fd [binary format II $c1 $c2]\n\n  close $fd\n}\n\n#-------------------------------------------------------------------------\n# Test cases walcksum-1.* attempt to verify the following:\n#\n#   * That both native and non-native order checksum log files can \n#      be recovered.\n#\n#   * That when appending to native or non-native checksum log files \n#     SQLite continues to use the right kind of checksums.\n#\n#   * Test point 2 when the appending process is not one that recovered\n#     the log file.\n#\n#   * Test that both native and non-native checksum log files can be\n#     checkpointed. And that after doing so the next write to the log\n#     file occurs using native byte-order checksums. \n#\nset native \"big\"\nif {$::tcl_platform(byteOrder) == \"littleEndian\"} { set native \"little\" }\nforeach endian {big little} {\n\n  # Create a database. Leave some data in the log file.\n  #\n  do_test walcksum-1.$endian.1 {\n    catch { db close }\n    forcedelete test.db test.db-wal test.db-journal\n    sqlite3 db test.db\n    execsql {\n      PRAGMA page_size = 1024;\n      PRAGMA auto_vacuum = 0;\n      PRAGMA synchronous = NORMAL;\n\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1,  'one');\n      INSERT INTO t1 VALUES(2,  'two');\n      INSERT INTO t1 VALUES(3,  'three');\n      INSERT INTO t1 VALUES(5,  'five');\n\n      PRAGMA journal_mode = WAL;\n      INSERT INTO t1 VALUES(8,  'eight');\n      INSERT INTO t1 VALUES(13, 'thirteen');\n      INSERT INTO t1 VALUES(21, 'twentyone');\n    }\n\n    forcecopy test.db test2.db\n    forcecopy test.db-wal test2.db-wal\n    db close\n\n    list [file size test2.db] [file size test2.db-wal]\n  } [list [expr 1024*3] [wal_file_size 6 1024]]\n\n  # Verify that the checksums are valid for all frames and that they\n  # are calculated by interpreting data in native byte-order.\n  #\n  for {set f 1} {$f <= 6} {incr f} {\n    do_test walcksum-1.$endian.2.$f {\n      log_checksum_verify test2.db-wal $f $native\n    } 1\n  }\n\n  # Replace all checksums in the current WAL file with $endian versions.\n  # Then check that it is still possible to recover and read the database.\n  #\n  log_checksum_writemagic test2.db-wal $endian\n  for {set f 1} {$f <= 6} {incr f} {\n    do_test walcksum-1.$endian.3.$f {\n      log_checksum_write test2.db-wal $f $endian\n      log_checksum_verify test2.db-wal $f $endian\n    } {1}\n  }\n  do_test walcksum-1.$endian.4.1 {\n    forcecopy test2.db test.db\n    forcecopy test2.db-wal test.db-wal\n    sqlite3 db test.db\n    execsql { SELECT a FROM t1 }\n  } {1 2 3 5 8 13 21}\n\n  # Following recovery, any frames written to the log should use the same \n  # endianness as the existing frames. Check that this is the case.\n  #\n  do_test walcksum-1.$endian.5.0 {\n    execsql { \n      PRAGMA synchronous = NORMAL;\n      INSERT INTO t1 VALUES(34, 'thirtyfour');\n    }\n    list [file size test.db] [file size test.db-wal]\n  } [list [expr 1024*3] [wal_file_size 8 1024]]\n  for {set f 1} {$f <= 8} {incr f} {\n    do_test walcksum-1.$endian.5.$f {\n      log_checksum_verify test.db-wal $f $endian\n    } {1}\n  }\n\n  # Now connect a second connection to the database. Check that this one\n  # (not the one that did recovery) also appends frames to the log using\n  # the same endianness for checksums as the existing frames.\n  #\n  do_test walcksum-1.$endian.6 {\n    sqlite3 db2 test.db\n    execsql { \n      PRAGMA integrity_check;\n      SELECT a FROM t1;\n    } db2\n  } {ok 1 2 3 5 8 13 21 34}\n  do_test walcksum-1.$endian.7.0 {\n    execsql { \n      PRAGMA synchronous = NORMAL;\n      INSERT INTO t1 VALUES(55, 'fiftyfive');\n    } db2\n    list [file size test.db] [file size test.db-wal]\n  } [list [expr 1024*3] [wal_file_size 10 1024]]\n  for {set f 1} {$f <= 10} {incr f} {\n    do_test walcksum-1.$endian.7.$f {\n      log_checksum_verify test.db-wal $f $endian\n    } {1}\n  }\n\n  # Now that both the recoverer and non-recoverer have added frames to the\n  # log file, check that it can still be recovered.\n  #\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n  do_test walcksum-1.$endian.7.11 {\n    sqlite3 db3 test2.db\n    execsql { \n      PRAGMA integrity_check;\n      SELECT a FROM t1;\n    } db3\n  } {ok 1 2 3 5 8 13 21 34 55}\n  db3 close\n\n  # Run a checkpoint on the database file. Then, check that any frames written\n  # to the start of the log use native byte-order checksums.\n  #\n  do_test walcksum-1.$endian.8.1 {\n    execsql {\n      PRAGMA wal_checkpoint;\n      INSERT INTO t1 VALUES(89, 'eightynine');\n    }\n    log_checksum_verify test.db-wal 1 $native\n  } {1}\n  do_test walcksum-1.$endian.8.2 {\n    log_checksum_verify test.db-wal 2 $native\n  } {1}\n  do_test walcksum-1.$endian.8.3 {\n    log_checksum_verify test.db-wal 3 $native\n  } {0}\n\n  do_test walcksum-1.$endian.9 {\n    execsql { \n      PRAGMA integrity_check;\n      SELECT a FROM t1;\n    } db2\n  } {ok 1 2 3 5 8 13 21 34 55 89}\n\n  catch { db close }\n  catch { db2 close }\n}\n\n#-------------------------------------------------------------------------\n# Test case walcksum-2.* tests that if a statement transaction is rolled\n# back after frames are written to the WAL, and then (after writing some\n# more) the outer transaction is committed, the WAL file is still correctly\n# formatted (and can be recovered by a second process if required).\n#\ndo_test walcksum-2.1 {\n  forcedelete test.db test.db-wal test.db-journal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA synchronous = NORMAL;\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    PRAGMA cache_size = 10;\n    CREATE TABLE t1(x PRIMARY KEY);\n    PRAGMA wal_checkpoint;\n    INSERT INTO t1 VALUES(randomblob(800));\n    BEGIN;\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*   2 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*   4 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*   8 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  16 */\n      SAVEPOINT one;\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  32 */\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  64 */\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 128 */\n        INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 256 */\n      ROLLBACK TO one;\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  32 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /*  64 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 128 */\n      INSERT INTO t1 SELECT randomblob(800) FROM t1;   /* 256 */\n    COMMIT;\n  }\n\n  forcecopy test.db test2.db\n  forcecopy test.db-wal test2.db-wal\n\n  sqlite3 db2 test2.db\n  execsql {\n    PRAGMA integrity_check;\n    SELECT count(*) FROM t1;\n  } db2\n} {ok 256}\ncatch { db close }\ncatch { db2 close }\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walcrash.test",
    "content": "# 2010 February 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library when\n# recovering a database following a simulated system failure in \n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\n#\n# These are 'warm-body' tests of database recovery used while developing \n# the WAL code. They serve to prove that a few really simple cases work:\n#\n# walcrash-1.*: Recover a database.\n# walcrash-2.*: Recover a database where the failed transaction spanned more\n#               than one page.\n# walcrash-3.*: Recover multiple databases where the failed transaction \n#               was a multi-file transaction.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable !wal {finish_test ; return }\n\ndb close\n\nset seed 0\nset REPEATS 100\n\n# walcrash-1.*\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n  do_test walcrash-1.$i.1 {\n    crashsql -delay 4 -file test.db-wal -seed [incr seed] {\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 1);\n      INSERT INTO t1 VALUES(2, 3);\n      INSERT INTO t1 VALUES(3, 6);\n    }\n  } {1 {child process exited abnormally}}\n  do_test walcrash-1.$i.2 {\n    sqlite3 db test.db\n    execsql { SELECT sum(a)==max(b) FROM t1 }\n  } {1}\n  integrity_check walcrash-1.$i.3\n  db close\n  \n  do_test walcrash-1.$i.4 {\n    crashsql -delay 2 -file test.db-wal -seed [incr seed] {\n      INSERT INTO t1 VALUES(4, (SELECT sum(a) FROM t1) + 4);\n      INSERT INTO t1 VALUES(5, (SELECT sum(a) FROM t1) + 5);\n    }\n  } {1 {child process exited abnormally}}\n  do_test walcrash-1.$i.5 {\n    sqlite3 db test.db\n    execsql { SELECT sum(a)==max(b) FROM t1 }\n  } {1}\n  integrity_check walcrash-1.$i.6\n  do_test walcrash-1.$i.7 {\n    execsql { PRAGMA main.journal_mode }\n  } {wal}\n  db close\n}\n\n# walcrash-2.*\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n  do_test walcrash-2.$i.1 {\n    crashsql -delay 5 -file test.db-wal -seed [incr seed] {\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      INSERT INTO t1 VALUES(5, 9);\n    }\n  } {1 {child process exited abnormally}}\n  do_test walcrash-2.$i.2 {\n    sqlite3 db test.db\n    execsql { SELECT sum(a)==max(b) FROM t1 }\n  } {1}\n  integrity_check walcrash-2.$i.3\n  db close\n  \n  do_test walcrash-2.$i.4 {\n    crashsql -delay 2 -file test.db-wal -seed [incr seed] {\n      INSERT INTO t1 VALUES(6, (SELECT sum(a) FROM t1) + 6);\n      INSERT INTO t1 VALUES(7, (SELECT sum(a) FROM t1) + 7);\n    }\n  } {1 {child process exited abnormally}}\n  do_test walcrash-2.$i.5 {\n    sqlite3 db test.db\n    execsql { SELECT sum(a)==max(b) FROM t1 }\n  } {1}\n  integrity_check walcrash-2.$i.6\n  do_test walcrash-2.$i.6 {\n    execsql { PRAGMA main.journal_mode }\n  } {wal}\n  db close\n}\n\n# walcrash-3.*\n#\n# for {set i 1} {$i < $REPEATS} {incr i} {\n#   forcedelete test.db test.db-wal\n#   forcedelete test2.db test2.db-wal\n# \n#   do_test walcrash-3.$i.1 {\n#     crashsql -delay 2 -file test2.db-wal -seed [incr seed] {\n#       PRAGMA journal_mode = WAL;\n#       ATTACH 'test2.db' AS aux;\n#       CREATE TABLE t1(a PRIMARY KEY, b);\n#       CREATE TABLE aux.t2(a PRIMARY KEY, b);\n#       BEGIN;\n#         INSERT INTO t1 VALUES(1, 2);\n#         INSERT INTO t2 VALUES(1, 2);\n#       COMMIT;\n#     }\n#   } {1 {child process exited abnormally}}\n# \n#   do_test walcrash-3.$i.2 {\n#     sqlite3_wal db test.db\n#     execsql { \n#       ATTACH 'test2.db' AS aux;\n#       SELECT * FROM t1 EXCEPT SELECT * FROM t2;\n#     }\n#   } {}\n#   do_test walcrash-3.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}\n#   do_test walcrash-3.$i.4 { execsql { PRAGMA aux.integrity_check  } } {ok}\n# \n#   db close\n# }\n\n# walcrash-4.*\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n  forcedelete test2.db test2.db-wal\n\n  do_test walcrash-4.$i.1 {\n    crashsql -delay 4 -file test.db-wal -seed [incr seed] -blocksize 4096 {\n      PRAGMA journal_mode = WAL;\n      PRAGMA page_size = 1024;\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test walcrash-4.$i.2 {\n    sqlite3 db test.db\n    execsql { \n      SELECT * FROM t1 WHERE a = 1;\n    }\n  } {1 2}\n  do_test walcrash-4.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}\n  do_test walcrash-4.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}\n\n  db close\n}\n\n# walcrash-5.*\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n  forcedelete test2.db test2.db-wal\n\n  do_test walcrash-5.$i.1 {\n    crashsql -delay 13 -file test.db-wal -seed [incr seed] -blocksize 4096 {\n      PRAGMA journal_mode = WAL;\n      PRAGMA page_size = 1024;\n      BEGIN;\n        CREATE TABLE t1(x PRIMARY KEY);\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;           /* 4 */\n      COMMIT;\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 8 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */\n\n      PRAGMA wal_checkpoint;\n      INSERT INTO t1 VALUES(randomblob(900));\n      INSERT INTO t1 VALUES(randomblob(900));\n      INSERT INTO t1 VALUES(randomblob(900));\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test walcrash-5.$i.2 {\n    sqlite3 db test.db\n    execsql { SELECT count(*)==33 OR count(*)==34 FROM t1 WHERE x != 1 }\n  } {1}\n  do_test walcrash-5.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}\n  do_test walcrash-5.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}\n\n  db close\n}\n\n# walcrash-6.*\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n  forcedelete test2.db test2.db-wal\n\n  do_test walcrash-6.$i.1 {\n    crashsql -delay 14 -file test.db-wal -seed [incr seed] -blocksize 512 {\n      PRAGMA journal_mode = WAL;\n      PRAGMA page_size = 1024;\n      BEGIN;\n        CREATE TABLE t1(x PRIMARY KEY);\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 VALUES(randomblob(900));\n        INSERT INTO t1 SELECT randomblob(900) FROM t1;           /* 4 */\n      COMMIT;\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 8 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 12 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 16 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 20 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 24 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 28 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4;   /* 32 */\n\n      PRAGMA wal_checkpoint;\n      INSERT INTO t1 VALUES(randomblob(9000));\n      INSERT INTO t1 VALUES(randomblob(9000));\n      INSERT INTO t1 VALUES(randomblob(9000));\n      INSERT INTO t1 VALUES(randomblob(9000));\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test walcrash-6.$i.2 {\n    sqlite3 db test.db\n    execsql { SELECT count(*) BETWEEN 34 AND 36 FROM t1 WHERE x != 1 }\n  } {1}\n  do_test walcrash-6.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}\n  do_test walcrash-6.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}\n\n  db close\n}\n\n#-------------------------------------------------------------------------\n# This test case simulates a crash while checkpointing the database. Page\n# 1 is one of the pages overwritten by the checkpoint. This is a special\n# case because it means the content of page 1 may be damaged. SQLite will\n# have to determine:\n#\n#   (a) that the database is a WAL database, and \n#   (b) the database page-size\n#\n# based on the log file.\n#\nfor {set i 1} {$i < $REPEATS} {incr i} {\n  forcedelete test.db test.db-wal\n\n  # Select a page-size for this test.\n  #\n  set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]]\n\n  do_test walcrash-7.$i.1 {\n    crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 \"\n      PRAGMA page_size = $pgsz;\n      PRAGMA journal_mode = wal;\n      BEGIN;\n        CREATE TABLE t1(a, b);\n        INSERT INTO t1 VALUES(1, 2);\n      COMMIT;\n      PRAGMA wal_checkpoint;\n      CREATE INDEX i1 ON t1(a);\n      PRAGMA wal_checkpoint;\n    \"\n  } {1 {child process exited abnormally}}\n\n  do_test walcrash-7.$i.2 {\n    sqlite3 db test.db\n    execsql { SELECT b FROM t1 WHERE a = 1 }\n  } {2}\n  do_test walcrash-7.$i.3 { execsql { PRAGMA main.integrity_check } } {ok}\n  do_test walcrash-7.$i.4 { execsql { PRAGMA main.journal_mode } } {wal}\n\n  db close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walcrash2.test",
    "content": "# 2010 May 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nifcapable !wal {finish_test ; return }\n\n\n#-------------------------------------------------------------------------\n# This test case demonstrates a flaw in the wal-index manipulation that\n# existed at one point: If a process crashes mid-transaction, it may have\n# already added some entries to one of the hash-tables in the wal-index.\n# If the transaction were to be explicitly rolled back at this point, the\n# hash-table entries would be removed as part of the rollback. However,\n# if the process crashes, the transaction is implicitly rolled back and\n# the rogue entries remain in the hash table.\n#\n# Normally, this causes no problem - readers can tell the difference \n# between committed and uncommitted entries in the hash table. However,\n# if it happens often enough that all slots in the hash-table become \n# non-zero, the next process that attempts to read or write the hash\n# table falls into an infinite loop.\n#\n# Even if run with an SQLite version affected by the bug, this test case\n# only goes into an infinite loop if SQLite is compiled without SQLITE_DEBUG\n# defined. If SQLITE_DEBUG is defined, the program is halted by a failing\n# assert() before entering the infinite loop.\n#\n# walcrash2-1.1: Create a database. Commit a transaction that adds 8 frames\n#                to the WAL (and 8 entry to the first hash-table in the \n#                wal-index).\n#\n# walcrash2-1.2: Have an external process open a transaction, add 8 entries\n#                to the wal-index hash-table, then crash. Repeat this 1023\n#                times (so that the wal-index contains 8192 entries - all\n#                slots are non-zero).\n#\n# walcrash2-1.3: Using a new database connection, attempt to query the \n#                database. This should cause the process to go into the\n#                infinite loop.\n#\ndo_test walcrash2-1.1 {\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = off;\n    PRAGMA journal_mode = WAL;\n    PRAGMA synchronous = NORMAL;\n    BEGIN;\n      CREATE TABLE t1(x);\n      CREATE TABLE t2(x);\n      CREATE TABLE t3(x);\n      CREATE TABLE t4(x);\n      CREATE TABLE t5(x);\n      CREATE TABLE t6(x);\n      CREATE TABLE t7(x);\n    COMMIT;\n  }\n  file size test.db-wal\n} [wal_file_size 8 1024] \nfor {set nEntry 8} {$nEntry < 8192} {incr nEntry 8} {\n  do_test walcrash2-1.2.[expr $nEntry/8] {\n    set C [launch_testfixture]\n    testfixture $C {\n      sqlite3 db test.db\n      db eval {\n        PRAGMA cache_size = 15;\n        BEGIN;\n          INSERT INTO t1 VALUES(randomblob(900));         --  1 row,  1  page\n          INSERT INTO t1 SELECT * FROM t1;                --  2 rows, 3  pages\n          INSERT INTO t1 SELECT * FROM t1;                --  4 rows, 5  pages\n          INSERT INTO t1 SELECT * FROM t1;                --  8 rows, 9  pages\n          INSERT INTO t1 SELECT * FROM t1;                -- 16 rows, 17 pages\n          INSERT INTO t1 SELECT * FROM t1 LIMIT 3;        -- 20 rows, 20 pages\n      }\n    } \n    close $C\n    file size test.db-wal\n  } [wal_file_size 16 1024]\n}\ndo_test walcrash2-1.3 {\n  sqlite3 db2 test.db\n  execsql { SELECT count(*) FROM t1 } db2\n} {0}\ncatch { db2 close }\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walcrash3.test",
    "content": "# 2011 December 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This test simulates an application crash immediately following a\n# system call to truncate a file. Specifically, the system call that\n# truncates the WAL file if \"PRAGMA journal_size_limit\" is configured.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !wal {finish_test ; return }\nset testprefix walcrash3\n\ndb close\ntestvfs tvfs\ntvfs filter {xTruncate xWrite}\ntvfs script tvfs_callback\nproc tvfs_callback {args} {}\n\nsqlite3 db test.db -vfs tvfs\ndo_execsql_test 1.1 {\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = WAL;\n  PRAGMA wal_autocheckpoint = 128;\n  PRAGMA journal_size_limit = 16384;\n\n  CREATE TABLE t1(a BLOB, b BLOB, UNIQUE(a, b));\n  INSERT INTO t1 VALUES(randomblob(10), randomblob(1000));\n} {wal 128 16384}\n\nproc tvfs_callback {method file arglist} {\n  if {$::state==1} {\n    foreach f [glob -nocomplain xx_test.*] { forcedelete $f }\n    foreach f [glob -nocomplain test.*]    { forcecopy $f \"xx_$f\" }\n    set ::state 2\n  }\n  if {$::state==0 && $method==\"xTruncate\" && [file tail $file]==\"test.db-wal\"} {\n    set ::state 1\n  }\n}\n\nfor {set i 2} {$i<1000} {incr i} {\n\n  # If the WAL file is truncated within the following, within the following\n  # xWrite call the [tvfs_callback] makes a copy of the database and WAL \n  # files set sets $::state to 2. So that the copied files are in the same\n  # state as the real database and WAL files would be if an application crash \n  # occurred immediately following the xTruncate().\n  # \n  set ::state 0\n  do_execsql_test 1.$i.1 {\n    INSERT INTO t1 VALUES(randomblob(10), randomblob(1000));\n  }\n\n  # If a copy was made, open it and run the integrity-check.\n  #\n  if {$::state==2} {\n    sqlite3 db2 xx_test.db\n    do_test 1.$i.2 { execsql { PRAGMA integrity_check  } db2 } \"ok\"\n    do_test 1.$i.3 { execsql { SELECT count(*) FROM t1 } db2 } [expr $i-1]\n    db2 close\n  }\n}\ncatch { db close }\ntvfs delete\n\n#--------------------------------------------------------------------------\n#\ncatch { db close }\nforcedelete test.db\n\ndo_test 2.1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 128;\n    CREATE TABLE t1(a PRIMARY KEY, b);\n    INSERT INTO t1 VALUES(randomblob(25), randomblob(200));\n  }\n\n  for {set i 0} {$i < 1500} {incr i} {\n    execsql { INSERT INTO t1 VALUES(randomblob(25), randomblob(200)) }\n  }\n\n  db_save\n  db close\n} {}\n\nset nInitialErr [set_test_counter errors]\nfor {set i 2} {$i<10000 && [set_test_counter errors]==$nInitialErr} {incr i} {\n\n  do_test 2.$i.1 {\n    catch { db close } \n    db_restore\n    crashsql -delay 2 -file test.db-wal -seed $i {\n      SELECT * FROM sqlite_master;\n      PRAGMA synchronous = full;\n      PRAGMA wal_checkpoint;\n      BEGIN;\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n        INSERT INTO t1 VALUES(randomblob(26), randomblob(200));\n      COMMIT;\n    }\n  } {1 {child process exited abnormally}}\n\n  do_test 2.$i.2 {\n    sqlite3 db test.db\n    execsql { PRAGMA integrity_check } \n  } {ok}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walcrash4.test",
    "content": "# 2010 May 25\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nifcapable !wal {finish_test ; return }\nset testprefix walcrash4\ndo_not_use_codec\n\n#-------------------------------------------------------------------------\n# At one point, if \"PRAGMA synchronous=full\" is set and the platform\n# does not support POWERSAFE_OVERWRITE, and the last frame written to \n# the wal file in a transaction is aligned with a sector boundary, the\n# xSync() call was omitted. \n#\n# The following test verifies that this has been fixed.\n#\ndo_execsql_test 1.0 {\n  PRAGMA autovacuum = 0;\n  PRAGMA page_size = 1024;\n  PRAGMA journal_mode = wal;\n  PRAGMA main.synchronous = full;\n} {wal}\n\nfaultsim_save_and_close\n\n# The error message is different on unix and windows\n#\nif {$::tcl_platform(platform)==\"windows\"} {\n set msg \"child killed: unknown signal\"\n} else {\n set msg \"child process exited abnormally\"\n}\n\nfor {set nExtra 0} {$nExtra < 10} {incr nExtra} {\n  for {set i 0} {$i < 10} {incr i} {\n    do_test 1.nExtra=$nExtra.i=$i.1 {\n      faultsim_restore_and_reopen\n    \n      set fd [open crash.tcl w]\n      puts $fd [subst -nocommands {\n        sqlite3_crash_enable 1\n        sqlite3_test_control_pending_byte $::sqlite_pending_byte\n        sqlite3 db test.db -vfs crash\n        db eval {\n          PRAGMA main.synchronous=FULL;\n          BEGIN;\n          CREATE TABLE t1(x UNIQUE);\n        }\n        for {set e 2} {[set e] < ($nExtra+2)} {incr e} {\n          db eval \"CREATE TABLE t[set e] (x)\"\n        }\n        db eval {\n          INSERT INTO t1 VALUES( randomblob(170000) );\n          COMMIT;\n        }\n        sqlite3_crash_now\n      }]\n      close $fd\n    \n      set r [catch { exec [info nameofexec] crash.tcl >@stdout } msg]\n      list $r $msg\n    } \"1 {$msg}\"\n  \n    do_execsql_test 1.nExtra=$nExtra.i=$i.2 { \n      SELECT count(*) FROM t1;\n      PRAGMA integrity_check;\n    } {1 ok}\n  } \n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walfault.test",
    "content": "# 2010 May 03\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nsource $testdir/lock_common.tcl\n\nifcapable !wal {finish_test ; return }\n\n#-------------------------------------------------------------------------\n# This test case, walfault-1-*, simulates faults while executing a\n#\n#   PRAGMA journal_mode = WAL;\n#\n# statement immediately after creating a new database.\n#\ndo_test walfault-1-pre-1 {\n  faultsim_delete_and_reopen\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { PRAGMA main.journal_mode = WAL }\n} -test {\n\n  faultsim_test_result {0 wal}\n\n  # Test that the connection that encountered an error as part of \n  # \"PRAGMA journal_mode = WAL\" and a new connection use the same\n  # journal mode when accessing the database.\n  #\n  # If \"PRAGMA journal_mode\" is executed immediately, connection [db] (the \n  # one that hit the error in journal_mode=\"WAL\") might return \"wal\" even \n  # if it failed to switch the database to WAL mode. This is not considered \n  # a problem. When it tries to read the database, connection [db] correctly \n  # recognizes that it is a rollback database and switches back to a \n  # rollback compatible journal mode.\n  #\n  if {[permutation] != \"inmemory_journal\"} {\n    set jm  [db one  {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]\n    sqlite3 db2 test.db\n    set jm2 [db2 one {SELECT * FROM sqlite_master ; PRAGMA main.journal_mode}]\n    db2 close\n  \n    if { $jm!=$jm2 } { error \"Journal modes do not match: $jm $jm2\" }\n    if { $testrc==0 && $jm!=\"wal\" } { error \"Journal mode is not WAL\" }\n  }\n}\n\n#--------------------------------------------------------------------------\n# Test case walfault-2-* tests fault injection during recovery of a \n# short WAL file (a dozen frames or thereabouts).\n#\ndo_test walfault-2-pre-1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    BEGIN;\n      CREATE TABLE x(y, z, UNIQUE(y, z));\n      INSERT INTO x VALUES(randomblob(100), randomblob(100));\n    COMMIT;\n    PRAGMA wal_checkpoint;\n\n    INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;\n    INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;\n    INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x;\n  }\n  execsql {\n    SELECT count(*) FROM x\n  }\n} {8}\ndo_test walfault-2-pre-2 {\n  faultsim_save_and_close\n  faultsim_restore_and_reopen\n  execsql { SELECT count(*) FROM x }\n} {8}\ndo_faultsim_test walfault-2 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT count(*) FROM x }\n} -test {\n  faultsim_test_result {0 8}\n  faultsim_integrity_check\n}\n\n#--------------------------------------------------------------------------\n# Test fault injection while writing and checkpointing a small WAL file.\n#\ndo_test walfault-3-pre-1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA auto_vacuum = 1;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE abc(a PRIMARY KEY);\n    INSERT INTO abc VALUES(randomblob(1500));\n  }\n  db close\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval {\n    DELETE FROM abc;\n    PRAGMA wal_checkpoint;\n  }\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#--------------------------------------------------------------------------\n#\nif {[permutation] != \"inmemory_journal\"} {\n  faultsim_delete_and_reopen\n  faultsim_save_and_close\n  do_faultsim_test walfault-4 -prep {\n    faultsim_restore_and_reopen\n  } -body {\n    execsql {\n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(a PRIMARY KEY, b);\n      INSERT INTO t1 VALUES('a', 'b');\n      PRAGMA wal_checkpoint;\n      SELECT * FROM t1;\n    }\n  } -test {\n    # Update: The following changed from {0 {wal 0 7 7 a b}} as a result\n    # of PSOW being set by default.\n    faultsim_test_result {0 {wal 0 5 5 a b}}\n    faultsim_integrity_check\n  } \n}\n\n#--------------------------------------------------------------------------\n#\ndo_test walfault-5-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA journal_mode = WAL;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-5 -faults shmerr* -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA wal_autocheckpoint = 0 }\n  shmfault filter xShmMap\n} -body {\n  execsql {\n    CREATE TABLE t1(x);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(400));           /* 1 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 2 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 4 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 8 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 16 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 32 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 64 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 128 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 256 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 512 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 1024 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 2048 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 4096 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 8192 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 16384 */\n    COMMIT;\n    SELECT count(*) FROM t1;\n  }\n} -test {\n  faultsim_test_result {0 16384}\n  faultsim_integrity_check\n}\n\n#--------------------------------------------------------------------------\n#\ndo_test walfault-6-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    CREATE TABLE t1(x);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(400));           /* 1 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 2 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 4 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 8 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 16 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 32 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 64 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 128 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 256 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 512 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 1024 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 2048 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 4096 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 8192 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 16384 */\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-6 -faults shmerr* -prep {\n  faultsim_restore_and_reopen\n  shmfault filter xShmMap\n} -body {\n  execsql { SELECT count(*) FROM t1 }\n} -test {\n  faultsim_test_result {0 16384}\n  faultsim_integrity_check\n  set n [db one {SELECT count(*) FROM t1}]\n  if {$n != 16384 && $n != 0} { error \"Incorrect number of rows: $n\" }\n}\n\n#--------------------------------------------------------------------------\n#\ndo_test walfault-7-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA page_size = 512;\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    CREATE TABLE t1(x);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(400));           /* 1 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 2 */\n      INSERT INTO t1 SELECT randomblob(400) FROM t1;    /* 4 */\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-7 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  execsql { SELECT count(*) FROM t1 }\n} -test {\n  faultsim_test_result {0 4}\n  set n [db one {SELECT count(*) FROM t1}]\n  if {$n != 4 && $n != 0} { error \"Incorrect number of rows: $n\" }\n}\n\n#--------------------------------------------------------------------------\n#\ndo_test walfault-8-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE abc(a PRIMARY KEY);\n    INSERT INTO abc VALUES(randomblob(900));\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-8 -prep {\n  faultsim_restore_and_reopen\n  execsql { PRAGMA cache_size = 10 }\n} -body {\n  execsql {\n    BEGIN;\n      INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 1 */\n      --INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 2 */\n      --INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 4 */\n      --INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 8 */\n    ROLLBACK;\n    SELECT count(*) FROM abc;\n  }\n} -test {\n  faultsim_test_result {0 1}\n\n  faultsim_integrity_check\n  catch { db eval ROLLBACK }\n  faultsim_integrity_check\n\n  set n [db one {SELECT count(*) FROM abc}]\n  if {$n != 1} { error \"Incorrect number of rows: $n\" }\n}\n\n#--------------------------------------------------------------------------\n#\ndo_test walfault-9-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE abc(a PRIMARY KEY);\n    INSERT INTO abc VALUES(randomblob(900));\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-9 -prep {\n  #if {$iFail<73} { set iFail 73 }\n  #if {$iFail>73} { exit }\n  \n  faultsim_restore_and_reopen\n  execsql { PRAGMA cache_size = 10 }\n} -body {\n  execsql {\n    BEGIN;\n      INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 1 */\n      SAVEPOINT spoint;\n        INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 2 */\n        INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 4 */\n        INSERT INTO abc SELECT randomblob(900) FROM abc;    /* 8 */\n      ROLLBACK TO spoint;\n    COMMIT;\n    SELECT count(*) FROM abc;\n  }\n} -test {\n  faultsim_test_result {0 2}\n  faultsim_integrity_check\n\n  catch { db eval { ROLLBACK TO spoint } }\n  catch { db eval { COMMIT } }\n  set n [db one {SELECT count(*) FROM abc}]\n  if {$n != 1 && $n != 2} { error \"Incorrect number of rows: $n\" }\n}\n\ndo_test walfault-10-pre1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    CREATE TABLE z(zz INTEGER PRIMARY KEY, zzz BLOB);\n    CREATE INDEX zzzz ON z(zzz);\n    INSERT INTO z VALUES(NULL, randomblob(800));\n    INSERT INTO z VALUES(NULL, randomblob(800));\n    INSERT INTO z SELECT NULL, randomblob(800) FROM z;\n    INSERT INTO z SELECT NULL, randomblob(800) FROM z;\n    INSERT INTO z SELECT NULL, randomblob(800) FROM z;\n    INSERT INTO z SELECT NULL, randomblob(800) FROM z;\n    INSERT INTO z SELECT NULL, randomblob(800) FROM z;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-10 -prep {\n  faultsim_restore_and_reopen\n  execsql {\n    PRAGMA cache_size = 10;\n    BEGIN;\n      UPDATE z SET zzz = randomblob(799);\n  }\n\n  set ::stmt [sqlite3_prepare db \"SELECT zzz FROM z WHERE zz IN (1, 2, 3)\" -1]\n  sqlite3_step $::stmt\n} -body {\n  execsql { INSERT INTO z VALUES(NULL, NULL) }\n} -test {\n  sqlite3_finalize $::stmt\n  faultsim_integrity_check\n\n  faultsim_test_result {0 {}}\n  catch { db eval { ROLLBACK } }\n  faultsim_integrity_check\n\n  set n [db eval {SELECT count(*), sum(length(zzz)) FROM z}]\n  if {$n != \"64 51200\"} { error \"Incorrect data: $n\" }\n}\n\n#--------------------------------------------------------------------------\n# Test fault injection while checkpointing a large WAL file, if the \n# checkpoint is the first operation run after opening the database.\n# This means that some of the required wal-index pages are mapped as part of\n# the checkpoint process, which means there are a few more opportunities\n# for IO errors.\n#\n# To speed this up, IO errors are only simulated within xShmMap() calls.\n#\ndo_test walfault-11-pre-1 {\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --    4\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --    8\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --   16\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --   32\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --   64\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --  128\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --  256\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   --  512\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   -- 1024\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   -- 2048\n      INSERT INTO abc SELECT randomblob(1500) FROM abc;   -- 4096\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-11 -faults shmerr* -prep {\n  catch { db2 close }\n  faultsim_restore_and_reopen\n  shmfault filter xShmMap\n} -body {\n  db eval { SELECT count(*) FROM abc }\n  sqlite3 db2 test.db -vfs shmfault\n  db2 eval { PRAGMA wal_checkpoint }\n  set {} {}\n} -test {\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# Test the handling of the various IO/OOM/SHM errors that may occur during \n# a log recovery operation undertaken as part of a call to \n# sqlite3_wal_checkpoint().\n# \ndo_test walfault-12-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-12 -prep {\n  if {[info commands shmfault] == \"\"} {\n    testvfs shmfault -default true\n  }\n  faultsim_restore_and_reopen\n  db eval { SELECT * FROM sqlite_master }\n  shmfault shm test.db [string repeat \"\\000\" 40]\n} -body {\n  set rc [sqlite3_wal_checkpoint db]\n  if {$rc != \"SQLITE_OK\"} { error [sqlite3_errmsg db] }\n} -test {\n  db close\n  faultsim_test_result {0 {}}\n}\n\n#-------------------------------------------------------------------------\n# Test simple recovery, reading and writing a database file using a \n# heap-memory wal-index.\n# \ndo_test walfault-13-pre-1 {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint = 0;\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n  faultsim_save_and_close\n  delete_file sv_test.db-shm\n} {}\n\ndo_faultsim_test walfault-13.1 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { PRAGMA locking_mode = exclusive }\n  db eval { SELECT count(*) FROM abc }\n} -test {\n  faultsim_test_result {0 2}\n  if {[file exists test.db-shm]} { error \"Not using heap-memory mode\" }\n  faultsim_integrity_check\n}\n\ndo_faultsim_test walfault-13.2 -prep {\n  faultsim_restore_and_reopen\n  db eval { PRAGMA locking_mode = exclusive }\n} -body {\n  db eval { PRAGMA journal_mode = delete }\n} -test {\n  faultsim_test_result {0 delete}\n  if {[file exists test.db-shm]} { error \"Not using heap-memory mode\" }\n  faultsim_integrity_check\n}\n\ndo_test walfault-13-pre-2 {\n  faultsim_delete_and_reopen\n  execsql {\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\n\ndo_faultsim_test walfault-13.3 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { \n    PRAGMA locking_mode = exclusive;\n    PRAGMA journal_mode = WAL;\n    INSERT INTO abc VALUES(randomblob(1500));\n  }\n} -test {\n  faultsim_test_result {0 {exclusive wal}}\n  if {[file exists test.db-shm]} { error \"Not using heap-memory mode\" }\n  faultsim_integrity_check\n  set nRow [db eval {SELECT count(*) FROM abc}]\n  if {!(($nRow==2 && $testrc) || $nRow==3)} { error \"Bad db content\" }\n}\n\n#-------------------------------------------------------------------------\n# Test fault-handling when wrapping around to the start of a WAL file.\n#\ndo_test walfault-14-pre {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = WAL;\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-14 -prep {\n  faultsim_restore_and_reopen\n} -body {\n  db eval { \n    PRAGMA wal_checkpoint = full;\n    INSERT INTO abc VALUES(randomblob(1500));\n  }\n} -test {\n  faultsim_test_result {0 {0 9 9}}\n  faultsim_integrity_check\n  set nRow [db eval {SELECT count(*) FROM abc}]\n  if {!(($nRow==2 && $testrc) || $nRow==3)} { error \"Bad db content\" }\n}\n\n#-------------------------------------------------------------------------\n# Test fault-handling when switching out of exclusive-locking mode.\n#\ndo_test walfault-14-pre {\n  faultsim_delete_and_reopen\n  execsql {\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = WAL;\n    BEGIN;\n      CREATE TABLE abc(a PRIMARY KEY);\n      INSERT INTO abc VALUES(randomblob(1500));\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n  faultsim_save_and_close\n} {}\ndo_faultsim_test walfault-14 -prep {\n  faultsim_restore_and_reopen\n  execsql {\n    SELECT count(*) FROM abc;\n    PRAGMA locking_mode = exclusive;\n    BEGIN;\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n} -body {\n  db eval { \n    PRAGMA locking_mode = normal;\n    BEGIN;\n      INSERT INTO abc VALUES(randomblob(1500));\n    COMMIT;\n  }\n} -test {\n  faultsim_integrity_check\n  set nRow [db eval {SELECT count(*) FROM abc}]\n  if {$nRow!=3 && $nRow!=4} { error \"Bad db content\" }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walhook.test",
    "content": "# 2010 April 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n# \n# More specifically, this file contains regression tests for the \n# sqlite3_wal_hook() mechanism, including the sqlite3_wal_autocheckpoint()\n# and \"PRAGMA wal_autocheckpoint\" convenience interfaces.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\n\nifcapable !wal {finish_test ; return }\n\nset ::wal_hook [list]\nproc wal_hook {zDb nEntry} {\n  lappend ::wal_hook $zDb $nEntry\n  return 0\n}\ndb wal_hook wal_hook\n\ndo_test walhook-1.1 {\n  execsql { \n    PRAGMA page_size = 1024;\n    PRAGMA auto_vacuum = 0;\n    PRAGMA journal_mode = wal;\n    PRAGMA synchronous = normal;\n    CREATE TABLE t1(i PRIMARY KEY, j);\n  }\n  set ::wal_hook\n} {main 3}\n\ndo_test walhook-1.2 {\n  set ::wal_hook [list]\n  execsql { INSERT INTO t1 VALUES(1, 'one') }\n  set ::wal_hook\n} {main 5}\ndo_test walhook-1.3 {\n  proc wal_hook {args} { db eval {PRAGMA wal_checkpoint}; return 0 }\n  execsql { INSERT INTO t1 VALUES(2, 'two') }\n  file size test.db\n} [expr 3*1024]\ndo_test walhook-1.4 {\n  proc wal_hook {zDb nEntry} { \n    execsql { PRAGMA wal_checkpoint }\n    return 0\n  }\n  execsql { CREATE TABLE t2(a, b) }\n  file size test.db\n} [expr 4*1024]\n\ndo_test walhook-1.5 {\n  sqlite3 db2 test.db\n  proc wal_hook {zDb nEntry} {\n    execsql { PRAGMA wal_checkpoint } db2\n    return 0\n  }\n  execsql { CREATE TABLE t3(a PRIMARY KEY, b) }\n  file size test.db\n} [expr 6*1024]\n\ndb2 close\ndb close\nsqlite3 db test.db\ndo_test walhook-2.1 {\n  execsql { PRAGMA synchronous = NORMAL }\n  execsql { PRAGMA wal_autocheckpoint }\n} {1000}\ndo_test walhook-2.2 {\n  execsql { PRAGMA wal_autocheckpoint = 10}\n} {10}\ndo_test walhook-2.3 {\n  execsql { PRAGMA wal_autocheckpoint }\n} {10}\n\n#\n# The database connection is configured with \"PRAGMA wal_autocheckpoint = 10\".\n# Check that transactions are written to the log file until it contains at\n# least 10 frames, then the database is checkpointed. Subsequent transactions\n# are written into the start of the log file.\n#\nforeach {tn sql dbpages logpages} {\n  4 \"CREATE TABLE t4(x PRIMARY KEY, y)\"   6   3\n  5 \"INSERT INTO t4 VALUES(1, 'one')\"     6   5\n  6 \"INSERT INTO t4 VALUES(2, 'two')\"     6   7\n  7 \"INSERT INTO t4 VALUES(3, 'three')\"   6   9\n  8 \"INSERT INTO t4 VALUES(4, 'four')\"    8  11\n  9 \"INSERT INTO t4 VALUES(5, 'five')\"    8  11\n} {\n  do_test walhook-2.$tn {\n    execsql $sql\n    list [file size test.db] [file size test.db-wal]\n  } [list [expr $dbpages*1024] [wal_file_size $logpages 1024]]\n}\n\ncatch { db2 close }\ncatch { db close }\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walmode.test",
    "content": "# 2010 April 19\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\n\n# If the library was compiled without WAL support, check that the \n# \"PRAGMA journal_mode=WAL\" treats \"WAL\" as an unrecognized mode.\n#\nifcapable !wal {\n\n  do_test walmode-0.1 {\n    execsql { PRAGMA journal_mode = wal }\n  } {delete}\n  do_test walmode-0.2 {\n    execsql { PRAGMA main.journal_mode = wal }\n  } {delete}\n  do_test walmode-0.3 {\n    execsql { PRAGMA main.journal_mode }\n  } {delete}\n\n  finish_test\n  return\n}\n\ndo_test walmode-1.1 {\n  set sqlite_sync_count 0\n  execsql { PRAGMA page_size = 1024 }\n  execsql { PRAGMA journal_mode = wal }\n} {wal}\ndo_test walmode-1.2 {\n  file size test.db\n} {1024}\n\nset expected_sync_count 3\nif {$::tcl_platform(platform)!=\"windows\"} {\n  ifcapable dirsync {\n    incr expected_sync_count\n  }\n}\ndo_test walmode-1.3 {\n  set sqlite_sync_count\n} $expected_sync_count\n\ndo_test walmode-1.4 {\n  file exists test.db-wal\n} {0}\ndo_test walmode-1.5 {\n  execsql { CREATE TABLE t1(a, b) }\n  file size test.db\n} {1024}\ndo_test walmode-1.6 {\n  file exists test.db-wal\n} {1}\ndo_test walmode-1.7 {\n  db close\n  file exists test.db-wal\n} {0}\n\n# There is now a database file with the read and write versions set to 2\n# in the file system. This file should default to WAL mode.\n#\ndo_test walmode-2.1 {\n  sqlite3 db test.db\n  file exists test.db-wal\n} {0}\ndo_test walmode-2.2 {\n  execsql { SELECT * FROM sqlite_master }\n  file exists test.db-wal\n} {1}\ndo_test walmode-2.3 {\n  db close\n  file exists test.db-wal\n} {0}\n\n# If the first statement executed is \"PRAGMA journal_mode = wal\", and\n# the file is already configured for WAL (read and write versions set\n# to 2), then there should be no need to write the database. The \n# statement should cause the client to connect to the log file.\n#\nset sqlite_sync_count 0\ndo_test walmode-3.1 {\n  sqlite3 db test.db\n  execsql { PRAGMA journal_mode = wal }\n} {wal}\ndo_test walmode-3.2 {\n  list $sqlite_sync_count [file exists test.db-wal] [file size test.db-wal]\n} {0 1 0}\n\n# Test that changing back to journal_mode=persist works.\n#\ndo_test walmode-4.1 {\n  execsql { INSERT INTO t1 VALUES(1, 2) }\n  execsql { PRAGMA journal_mode = persist }\n} {persist}\ndo_test walmode-4.2 {\n  list [file exists test.db-journal] [file exists test.db-wal]\n} {1 0}\ndo_test walmode-4.3 {\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test walmode-4.4 {\n  db close\n  sqlite3 db test.db\n  execsql { SELECT * FROM t1 }\n} {1 2}\ndo_test walmode-4.5 {\n  list [file exists test.db-journal] [file exists test.db-wal]\n} {1 0}\n\n# Test that nothing goes wrong if a connection is prevented from changing\n# from WAL to rollback mode because a second connection has the database\n# open. Or from rollback to WAL.\n#\ndo_test walmode-4.6 {\n  sqlite3 db2 test.db\n  execsql { PRAGMA main.journal_mode } db2\n} {delete}\ndo_test walmode-4.7 {\n  execsql { PRAGMA main.journal_mode = wal } db\n} {wal}\ndo_test walmode-4.8 {\n  execsql { SELECT * FROM t1 } db2\n} {1 2}\ndo_test walmode-4.9 {\n  catchsql { PRAGMA journal_mode = delete } db\n} {1 {database is locked}}\ndo_test walmode-4.10 {\n  execsql { PRAGMA main.journal_mode } db\n} {wal}\n\ndo_test walmode-4.11 {\n  db2 close\n  execsql { PRAGMA journal_mode = delete } db\n} {delete}\ndo_test walmode-4.12 {\n  execsql { PRAGMA main.journal_mode } db\n} {delete}\ndo_test walmode-4.13 {\n  list [file exists test.db-journal] [file exists test.db-wal]\n} {0 0}\ndo_test walmode-4.14 {\n  sqlite3 db2 test.db\n  execsql {\n    BEGIN;\n      SELECT * FROM t1;\n  } db2\n} {1 2}\n\ndo_test walmode-4.16 { execsql { PRAGMA main.journal_mode } db  } {delete}\ndo_test walmode-4.17 { execsql { PRAGMA main.journal_mode } db2 } {delete}\n\ndo_test walmode-4.17 {\n  catchsql { PRAGMA main.journal_mode = wal } db\n} {1 {database is locked}}\ndo_test walmode-4.18 {\n  execsql { PRAGMA main.journal_mode } db\n} {delete}\ncatch { db close }\ncatch { db2 close }\n\n# Test that it is not possible to change a temporary or in-memory database\n# to WAL mode. WAL mode is for persistent file-backed databases only.\n#\n#   walmode-5.1.*: Try to set journal_mode=WAL on [sqlite3 db :memory:] database.\n#   walmode-5.2.*: Try to set journal_mode=WAL on [sqlite3 db \"\"] database.\n#   walmode-5.3.*: Try to set temp.journal_mode=WAL.\n#\ndo_test walmode-5.1.1 {\n  sqlite3 db :memory:\n  execsql { PRAGMA main.journal_mode }\n} {memory}\ndo_test walmode-5.1.2 {\n  execsql { PRAGMA main.journal_mode = wal }\n} {memory}\ndo_test walmode-5.1.3 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n    SELECT * FROM t1;\n    PRAGMA main.journal_mode;\n  }\n} {1 2 memory}\ndo_test walmode-5.1.4 {\n  execsql { PRAGMA main.journal_mode = wal }\n} {memory}\ndo_test walmode-5.1.5 {\n  execsql { \n    INSERT INTO t1 VALUES(3, 4);\n    SELECT * FROM t1;\n    PRAGMA main.journal_mode;\n  }\n} {1 2 3 4 memory}\n\nif {$TEMP_STORE>=2} {\n  set tempJrnlMode memory\n} else {\n  set tempJrnlMode delete\n}\ndo_test walmode-5.2.1 {\n  sqlite3 db \"\"\n  execsql { PRAGMA main.journal_mode }\n} $tempJrnlMode\ndo_test walmode-5.2.2 {\n  execsql { PRAGMA main.journal_mode = wal }\n} $tempJrnlMode\ndo_test walmode-5.2.3 {\n  execsql {\n    BEGIN;\n      CREATE TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n    SELECT * FROM t1;\n    PRAGMA main.journal_mode;\n  }\n} [list 1 2 $tempJrnlMode]\ndo_test walmode-5.2.4 {\n  execsql { PRAGMA main.journal_mode = wal }\n} $tempJrnlMode\ndo_test walmode-5.2.5 {\n  execsql { \n    INSERT INTO t1 VALUES(3, 4);\n    SELECT * FROM t1;\n    PRAGMA main.journal_mode;\n  }\n} [list 1 2 3 4 $tempJrnlMode]\n\ndo_test walmode-5.3.1 {\n  sqlite3 db test.db\n  execsql { PRAGMA temp.journal_mode }\n} $tempJrnlMode\ndo_test walmode-5.3.2 {\n  execsql { PRAGMA temp.journal_mode = wal }\n} $tempJrnlMode\ndo_test walmode-5.3.3 {\n  execsql {\n    BEGIN;\n      CREATE TEMP TABLE t1(a, b);\n      INSERT INTO t1 VALUES(1, 2);\n    COMMIT;\n    SELECT * FROM t1;\n    PRAGMA temp.journal_mode;\n  }\n} [list 1 2 $tempJrnlMode]\ndo_test walmode-5.3.4 {\n  execsql { PRAGMA temp.journal_mode = wal }\n} $tempJrnlMode\ndo_test walmode-5.3.5 {\n  execsql { \n    INSERT INTO t1 VALUES(3, 4);\n    SELECT * FROM t1;\n    PRAGMA temp.journal_mode;\n  }\n} [list 1 2 3 4 $tempJrnlMode]\n\n\n#-------------------------------------------------------------------------\n# Test changing to WAL mode from journal_mode=off or journal_mode=memory\n#\nforeach {tn mode} {\n  1 off\n  2 memory\n  3 persist\n  4 delete\n  5 truncate\n} {\n  do_test walmode-6.$tn {\n    faultsim_delete_and_reopen\n    execsql \"\n      PRAGMA journal_mode = $mode;\n      PRAGMA journal_mode = wal;\n    \"\n  } [list $mode wal]\n}\ndb close\n\n#-------------------------------------------------------------------------\n# Test the effect of a \"PRAGMA journal_mode\" command being the first \n# thing executed by a new connection. This means that the schema is not\n# loaded when sqlite3_prepare_v2() is called to compile the statement.\n#\ndo_test walmode-7.0 {\n  forcedelete test.db\n  sqlite3 db test.db\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a, b);\n  }\n} {wal}\nforeach {tn sql result} {\n  1  \"PRAGMA journal_mode\"                wal\n  2  \"PRAGMA main.journal_mode\"           wal\n  3  \"PRAGMA journal_mode = delete\"       delete\n  4  \"PRAGMA journal_mode\"                delete\n  5  \"PRAGMA main.journal_mode\"           delete\n  6  \"PRAGMA journal_mode = wal\"          wal\n  7  \"PRAGMA journal_mode\"                wal\n  8  \"PRAGMA main.journal_mode\"           wal\n\n  9  \"PRAGMA journal_mode\"                wal\n 10  \"PRAGMA main.journal_mode\"           wal\n 11  \"PRAGMA main.journal_mode = delete\"  delete\n 12  \"PRAGMA journal_mode\"                delete\n 13  \"PRAGMA main.journal_mode\"           delete\n 14  \"PRAGMA main.journal_mode = wal\"     wal\n 15  \"PRAGMA journal_mode\"                wal\n 16  \"PRAGMA main.journal_mode\"           wal\n} {\n  do_test walmode-7.$tn { \n    db close\n    sqlite3 db test.db\n    execsql $sql\n  } $result\n}\ndb close\n\n#-------------------------------------------------------------------------\n# Test the effect of a \"PRAGMA journal_mode\" command on an attached \n# database.\n#\nfaultsim_delete_and_reopen\ndo_execsql_test walmode-8.1 {\n  CREATE TABLE t1(a, b);\n  PRAGMA journal_mode = WAL;\n  ATTACH 'test.db2' AS two;\n  CREATE TABLE two.t2(a, b);\n} {wal}\ndo_execsql_test walmode-8.2 { PRAGMA main.journal_mode }         {wal}\ndo_execsql_test walmode-8.3 { PRAGMA two.journal_mode  }         {delete}\ndo_execsql_test walmode-8.4 { PRAGMA two.journal_mode = DELETE } {delete}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test walmode-8.5  { ATTACH 'test.db2' AS two }          {}\ndo_execsql_test walmode-8.6  { PRAGMA main.journal_mode }          {wal}\ndo_execsql_test walmode-8.7  { PRAGMA two.journal_mode  }          {delete}\ndo_execsql_test walmode-8.8  { INSERT INTO two.t2 DEFAULT VALUES } {}\ndo_execsql_test walmode-8.9  { PRAGMA two.journal_mode  }          {delete}\ndo_execsql_test walmode-8.10 { INSERT INTO t1 DEFAULT VALUES } {}\ndo_execsql_test walmode-8.11 { PRAGMA main.journal_mode  }         {wal}\ndo_execsql_test walmode-8.12 { PRAGMA journal_mode  }              {wal}\n\n# Change to WAL mode on test2.db and make sure (in the tests that follow)\n# that this mode change persists. \ndo_test walmode-8.x1 {\n  execsql {\n     PRAGMA two.journal_mode=WAL;\n     PRAGMA two.journal_mode;\n  }\n} {wal wal}\n\ndb close\nsqlite3 db test.db\ndo_execsql_test walmode-8.13 { PRAGMA journal_mode = WAL }         {wal}\ndo_execsql_test walmode-8.14 { ATTACH 'test.db2' AS two  }         {}\ndo_execsql_test walmode-8.15 { PRAGMA main.journal_mode  }         {wal}\ndo_execsql_test walmode-8.16 { PRAGMA two.journal_mode   }         {wal}\ndo_execsql_test walmode-8.17 { INSERT INTO two.t2 DEFAULT VALUES } {}\ndo_execsql_test walmode-8.18 { PRAGMA two.journal_mode   }         {wal}\n \nsqlite3 db2 test.db2\ndo_test walmode-8.19 { execsql { PRAGMA main.journal_mode } db2 }  {wal}\ndb2 close\n\ndo_execsql_test walmode-8.20 { PRAGMA journal_mode = DELETE } {delete}\ndo_execsql_test walmode-8.21 { PRAGMA main.journal_mode }     {delete}\ndo_execsql_test walmode-8.22 { PRAGMA two.journal_mode }      {delete}\ndo_execsql_test walmode-8.21 { PRAGMA journal_mode = WAL }    {wal}\ndo_execsql_test walmode-8.21 { PRAGMA main.journal_mode }     {wal}\ndo_execsql_test walmode-8.22 { PRAGMA two.journal_mode }      {wal}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walnoshm.test",
    "content": "# 2010 November 1\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that WAL databases may be accessed without\n# using the xShm primitives if the connection is in exclusive-mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix walnoshm\nifcapable !wal {finish_test ; return }\n\ndb close\ntestvfs tvfsshm\ntestvfs tvfs -default 1 -iversion 1 \nsqlite3 db test.db\n\n#--------------------------------------------------------------------------\n# Test that when using a version 1 VFS, a database can only be converted\n# to WAL mode after setting locking_mode=EXCLUSIVE. Also, test that if a\n# WAL database is opened using heap-memory for the WAL index, the connection\n# cannot change back to locking_mode=NORMAL while the database is still in\n# WAL mode.\n#\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(x, y);\n  INSERT INTO t1 VALUES(1, 2);\n}\n\ndo_execsql_test 1.2 { \n  PRAGMA journal_mode = WAL;\n  SELECT * FROM t1;\n} {delete 1 2}\ndo_test 1.3 { file exists test.db-wal } {0}\n\ndo_execsql_test 1.4 { \n  PRAGMA locking_mode = exclusive;\n  PRAGMA journal_mode = WAL;\n  SELECT * FROM t1;\n} {exclusive wal 1 2}\ndo_test 1.5 { file exists test.db-wal } {1}\n\ndo_execsql_test 1.6 { INSERT INTO t1 VALUES(3, 4) }\n\ndo_execsql_test 1.7 {\n  PRAGMA locking_mode = normal;\n} {exclusive}\ndo_execsql_test 1.8 {\n  PRAGMA journal_mode = delete;\n  PRAGMA main.locking_mode;\n} {delete exclusive}\ndo_execsql_test 1.9 {\n  PRAGMA locking_mode = normal;\n} {normal}\ndo_execsql_test 1.10 {\n  SELECT * FROM t1;\n} {1 2 3 4}\ndo_test 1.11 { file exists test.db-wal } {0}\n\n#-------------------------------------------------------------------------\n#\n# 2.1.*: Test that a connection using a version 1 VFS can open a WAL database\n#        and convert it to rollback mode if it is set to use\n#        locking_mode=exclusive.\n#\n# 2.2.*: Test that if the exclusive lock cannot be obtained while attempting\n#        the above, the operation fails and the WAL file is not opened.\n#\ndo_execsql_test 2.1.1 {\n  CREATE TABLE t2(x, y);\n  INSERT INTO t2 VALUES('a', 'b');\n  INSERT INTO t2 VALUES('c', 'd');\n}\ndo_execsql_test 2.1.2 {\n  PRAGMA locking_mode = exclusive;\n  PRAGMA journal_mode = WAL;\n  INSERT INTO t2 VALUES('e', 'f');\n  INSERT INTO t2 VALUES('g', 'h');\n} {exclusive wal}\n\ndo_test 2.1.3 {\n  forcecopy test.db     test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3 db2 test2.db\n  catchsql { SELECT * FROM t2 } db2\n} {1 {unable to open database file}}\ndo_test 2.1.4 {\n  catchsql { PRAGMA journal_mode = delete } db2\n} {1 {unable to open database file}}\ndo_test 2.1.5 {\n  execsql { \n    PRAGMA locking_mode = exclusive; \n    PRAGMA journal_mode = delete;\n    SELECT * FROM t2;\n  } db2\n} {exclusive delete a b c d e f g h}\n\ndo_test 2.2.1 {\n  forcecopy test.db     test2.db\n  forcecopy test.db-wal test2.db-wal\n  sqlite3 db3 test2.db -vfs tvfsshm\n  sqlite3 db2 test2.db\n  execsql { SELECT * FROM t2 } db3\n} {a b c d e f g h}\n\ndo_test 2.2.2 {\n  execsql  { PRAGMA locking_mode = exclusive }  db2\n  catchsql { PRAGMA journal_mode = delete } db2\n} {1 {database is locked}}\n\ndo_test 2.2.3 {\n  # This is to test that [db2] is not holding a PENDING lock (which can \n  # happen when an attempt to obtain an EXCLUSIVE lock fails).\n  sqlite3 db4 test2.db -vfs tvfsshm\n  execsql { SELECT * FROM t2 } db4\n} {a b c d e f g h}\n\ndo_test 2.2.4 {\n  catchsql { SELECT * FROM t2 } db2\n} {1 {database is locked}}\n\ndo_test 2.2.5 {\n  db4 close\n  sqlite3 db4 test2.db -vfs tvfsshm\n  execsql { SELECT * FROM t2 } db4\n} {a b c d e f g h}\n\ndo_test 2.2.6 {\n  db3 close\n  db4 close\n  execsql { SELECT * FROM t2 } db2\n} {a b c d e f g h}\n\ndb2 close\ndb close\n\n#-------------------------------------------------------------------------\n#\n# 3.1: Test that if locking_mode=EXCLUSIVE is set after the wal file is\n#      opened, it is possible to drop back to locking_mode=NORMAL.\n#\n# 3.2: Test that if locking_mode=EXCLUSIVE is set before the wal file is\n#      opened, it is not.\n#\ndo_test 3.1 {\n  sqlite3 db test.db -vfs tvfsshm\n  execsql { \n    SELECT * FROM t1;\n    PRAGMA locking_mode = EXCLUSIVE;\n    INSERT INTO t1 VALUES(5, 6);\n    PRAGMA locking_mode = NORMAL;\n    INSERT INTO t1 VALUES(7, 8);\n  }\n  sqlite3 db2 test.db -vfs tvfsshm\n  execsql { SELECT * FROM t1 } db2\n} {1 2 3 4 5 6 7 8}\ndb close\ndb2 close\ndo_test 3.2 {\n  sqlite3 db  test.db -vfs tvfsshm\n  execsql { \n    PRAGMA locking_mode = EXCLUSIVE;\n    INSERT INTO t1 VALUES(9, 10);\n    PRAGMA locking_mode = NORMAL;\n    INSERT INTO t1 VALUES(11, 12);\n  }\n  sqlite3 db2 test.db -vfs tvfsshm\n  catchsql { SELECT * FROM t1 } db2\n} {1 {database is locked}}\ndb close\ndb2 close\n\ntvfs delete\ntvfsshm delete\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/waloverwrite.test",
    "content": "# 2010 May 5\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nset testprefix waloverwrite\n\nifcapable !wal {finish_test ; return }\n\n# Simple test:\n#\n# Test cases *.1 - *.6:\n#\n#   + Create a database of blobs roughly 50 pages in size.\n#\n#   + Set the db cache size to something much smaller than this (5 pages)\n#\n#   + Within a transaction, loop through the set of blobs 5 times. Update\n#      each blob as it is visited.\n#\n#   + Test that the wal file is roughly 50 pages in size - even though many\n#      database pages have been written to it multiple times.\n#\n#   + Take a copy of the database and wal file. Test that recovery can\n#     be run on it.\n#\n# Test cases *.7 - *.9:\n#\n#   + Same thing, but before committing the statement transaction open\n#     a SAVEPOINT, update the blobs another 5 times, then roll it back.\n#\n#   + Check that if recovery is run on the resulting wal file, the rolled\n#     back changes from within the SAVEPOINT are not present in the db.\n#\n# The above is run twice - once where the wal file is empty at the start of\n# step 3 (tn==1) and once where it already contains a transaction (tn==2).\n#\nforeach {tn xtra} {\n  1 {}\n  2 { UPDATE t1 SET y = randomblob(799) WHERE x=4 }\n} {\n  reset_db\n  do_execsql_test 1.$tn.0 {\n    CREATE TABLE t1(x, y);\n    CREATE TABLE t2(x, y);\n    CREATE INDEX i1y ON t1(y);\n  \n    WITH cnt(i) AS (\n      SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20\n    )\n    INSERT INTO t1 SELECT i, randomblob(800) FROM cnt;\n  } {}\n  \n  do_test 1.$tn.1 {\n    set nPg [db one { PRAGMA page_count } ]\n    expr $nPg>40 && $nPg<50\n  } {1}\n  \n  do_test 1.$tn.2 {\n    db close\n    sqlite3 db test.db\n  \n    execsql {PRAGMA journal_mode = wal}\n    execsql {PRAGMA cache_size = 5}\n    execsql $xtra\n  \n    db transaction {\n      for {set i 0} {$i < 5} {incr i} {\n        foreach x [db eval {SELECT x FROM t1}] {\n          execsql { UPDATE t1 SET y = randomblob(799) WHERE x=$x }\n        }\n      }\n    }\n  \n    set nPg [wal_frame_count test.db-wal 1024]\n    expr $nPg>40 && $nPg<60\n  } {1}\n  \n  do_execsql_test 1.$tn.3 { PRAGMA integrity_check } ok\n  \n  do_test 1.$tn.4 {\n    forcedelete test.db2 test.db2-wal\n    forcecopy test.db test.db2\n    sqlite3 db2 test.db2\n    execsql { SELECT sum(length(y)) FROM t1 } db2\n  } [expr 20*800]\n  \n  do_test 1.$tn.5 {\n    db2 close\n    forcecopy test.db test.db2\n    forcecopy test.db-wal test.db2-wal\n    sqlite3 db2 test.db2\n    execsql { SELECT sum(length(y)) FROM t1 } db2\n  } [expr 20*799]\n  \n  do_test 1.$tn.6 {\n    execsql { PRAGMA integrity_check } db2\n  } ok\n  db2 close\n\n  do_test 1.$tn.7 {\n    execsql { PRAGMA wal_checkpoint }\n    db transaction {\n      for {set i 0} {$i < 1} {incr i} {\n        foreach x [db eval {SELECT x FROM t1}] {\n          execsql { UPDATE t1 SET y = randomblob(798) WHERE x=$x }\n        }\n      }\n\n      execsql {\n        WITH cnt(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<20)\n        INSERT INTO t2 SELECT i, randomblob(800) FROM cnt;\n      }\n\n      execsql {SAVEPOINT abc}\n      for {set i 0} {$i < 5} {incr i} {\n        foreach x [db eval {SELECT x FROM t1}] {\n          execsql { UPDATE t1 SET y = randomblob(797) WHERE x=$x }\n        }\n      }\n      execsql {ROLLBACK TO abc}\n\n    }\n\n    set nPg [wal_frame_count test.db-wal 1024]\n    expr $nPg>55 && $nPg<75\n  } {1}\n\n  do_test 1.$tn.8 {\n    forcedelete test.db2 test.db2-wal\n    forcecopy test.db test.db2\n    sqlite3 db2 test.db2\n    execsql { SELECT sum(length(y)) FROM t1 } db2\n  } [expr 20*799]\n\n  do_test 1.$tn.9 {\n    db2 close\n    forcecopy test.db-wal test.db2-wal\n    sqlite3 db2 test.db2\n    execsql { SELECT sum(length(y)) FROM t1 } db2\n  } [expr 20*798]\n\n  do_test 1.$tn.10 {\n    execsql { PRAGMA integrity_check } db2\n  } ok\n  db2 close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walpersist.test",
    "content": "# 2011 July 26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for using WAL with persistent WAL file mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix walpersist\n\nifcapable !wal {\n  finish_test\n  return\n}\n\ndo_test walpersist-1.0 {\n  db eval {\n    PRAGMA journal_mode=WAL;\n    CREATE TABLE t1(a);\n    INSERT INTO t1 VALUES(randomblob(5000));\n  }\n  file exists test.db-wal\n} {1}\ndo_test walpersist-1.1 {\n  file exists test.db-shm\n} {1}\ndo_test walpersist-1.2 {\n  db close\n  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]\n} {1 0 0}\ndo_test walpersist-1.3 {\n  sqlite3 db test.db\n  db eval {SELECT length(a) FROM t1}\n} {5000}\ndo_test walpersist-1.4 {\n  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]\n} {1 1 1}\ndo_test walpersist-1.5 {\n  file_control_persist_wal db -1\n} {0 0}\ndo_test walpersist-1.6 {\n  file_control_persist_wal db 1\n} {0 1}\ndo_test walpersist-1.7 {\n  file_control_persist_wal db -1\n} {0 1}\ndo_test walpersist-1.8 {\n  file_control_persist_wal db 0\n} {0 0}\ndo_test walpersist-1.9 {\n  file_control_persist_wal db -1\n} {0 0}\ndo_test walpersist-1.10 {\n  file_control_persist_wal db 1\n} {0 1}\ndo_test walpersist-1.11 {\n  db close\n  list [file exists test.db] [file exists test.db-wal] [file exists test.db-shm]\n} {1 1 1}\n\n# Make sure the journal_size_limit works to limit the size of the\n# persisted wal file.  In persistent-wal mode, any non-negative\n# journal_size_limit causes the WAL file to be truncated to zero bytes\n# when closing.\n#\nforcedelete test.db test.db-shm test.db-wal\ndo_test walpersist-2.1 {\n  sqlite3 db test.db\n  db eval {\n    PRAGMA journal_mode=WAL;\n    PRAGMA wal_autocheckpoint=OFF;\n    PRAGMA journal_size_limit=12000;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(randomblob(50000));\n    UPDATE t1 SET x=randomblob(50000);\n  }\n  expr {[file size test.db-wal]>100000}\n} {1}\ndo_test walpersist-2.2 {\n  file_control_persist_wal db 1\n  db close\n  concat [file exists test.db-wal] [file size test.db-wal]\n} {1 0}\ndo_test walpersist-2.3 {\n  sqlite3 db test.db\n  execsql { PRAGMA integrity_check }\n} {ok}\n\ndo_test 3.1 {\n  catch {db close}\n  forcedelete test.db test.db-shm test.db-wal\n  sqlite3 db test.db\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    PRAGMA wal_autocheckpoint=128;\n    PRAGMA journal_size_limit=16384;\n    CREATE TABLE t1(a, b, PRIMARY KEY(a, b));\n  }\n} {wal 128 16384}\ndo_test 3.2 {\n  for {set i 0} {$i<200} {incr i} {\n    execsql { INSERT INTO t1 VALUES(randomblob(500), randomblob(500)) }\n  }\n  file_control_persist_wal db 1\n  db close\n} {}\ndo_test walpersist-3.3 { \n  file size test.db-wal \n} {0}\ndo_test walpersist-3.4 { \n  sqlite3 db test.db\n  execsql { PRAGMA integrity_check }\n} {ok}\n \n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walprotocol.test",
    "content": "# 2016 February 4\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode.\n#\n# More specifically, it tests \"locking protocol\" errors - errors that\n# may be caused if one or more SQLite clients does not follow the expected\n# locking protocol when accessing a wal-mode database. These tests take\n# quite a while to run.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nsource $testdir/wal_common.tcl\nifcapable !wal {finish_test ; return }\n\nset testprefix walprotocol\n\n#-------------------------------------------------------------------------\n# When recovering the contents of a WAL file, a process obtains the WRITER\n# lock, then locks all other bytes before commencing recovery. If it fails\n# to lock all other bytes (because some other process is holding a read\n# lock) it should retry up to 100 times. Then return SQLITE_PROTOCOL to the \n# caller. Test this (test case 1.3).\n#\n# Also test the effect of hitting an SQLITE_BUSY while attempting to obtain\n# the WRITER lock (should be the same). Test case 1.4.\n# \ndo_execsql_test 1.0 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE x(y);\n  INSERT INTO x VALUES('z');\n} {wal}\n\nproc lock_callback {method filename handle lock} {\n  lappend ::locks $lock\n}\ndo_test 1.1 {\n  testvfs T\n  T filter xShmLock \n  T script lock_callback\n  set ::locks [list]\n  sqlite3 db test.db -vfs T\n  execsql { SELECT * FROM x }\n  lrange $::locks 0 3\n} [list {0 1 lock exclusive} {1 7 lock exclusive}      \\\n        {1 7 unlock exclusive} {0 1 unlock exclusive}  \\\n]\ndo_test 1.2 {\n  db close\n  set ::locks [list]\n  sqlite3 db test.db -vfs T\n  execsql { SELECT * FROM x }\n  lrange $::locks 0 3\n} [list {0 1 lock exclusive} {1 7 lock exclusive}      \\\n        {1 7 unlock exclusive} {0 1 unlock exclusive}  \\\n]\nproc lock_callback {method filename handle lock} {\n  if {$lock == \"1 7 lock exclusive\"} { return SQLITE_BUSY }\n  return SQLITE_OK\n}\nputs \"# Warning: This next test case causes SQLite to call xSleep(1) 100 times.\"\nputs \"# Normally this equates to a delay of roughly 10 seconds, but if SQLite\"\nputs \"# is built on unix without HAVE_USLEEP defined, it may be much longer.\"\ndo_test 1.3 {\n  db close\n  set ::locks [list]\n  sqlite3 db test.db -vfs T\n  catchsql { SELECT * FROM x }\n} {1 {locking protocol}}\n\nputs \"# Warning: Same again!\"\nproc lock_callback {method filename handle lock} {\n  if {$lock == \"0 1 lock exclusive\"} { return SQLITE_BUSY }\n  return SQLITE_OK\n}\ndo_test 1.4 {\n  db close\n  set ::locks [list]\n  sqlite3 db test.db -vfs T\n  catchsql { SELECT * FROM x }\n} {1 {locking protocol}}\ndb close\nT delete\n\n#-------------------------------------------------------------------------\n# \ndo_test 2.1 {\n  forcedelete test.db test.db-journal test.db wal\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  execsql {\n    PRAGMA auto_vacuum = off;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE b(c);\n    INSERT INTO b VALUES('Tehran');\n    INSERT INTO b VALUES('Qom');\n    INSERT INTO b VALUES('Markazi');\n    PRAGMA wal_checkpoint;\n  }\n} {wal 0 5 5}\ndo_test 2.2 {\n  execsql { SELECT * FROM b }\n} {Tehran Qom Markazi}\ndo_test 2.3 {\n  db eval { SELECT * FROM b } {\n    db eval { INSERT INTO b VALUES('Qazvin') }\n    set r [db2 eval { SELECT * FROM b }]\n    break\n  }\n  set r\n} {Tehran Qom Markazi Qazvin}\ndo_test 2.4 {\n  execsql {\n    INSERT INTO b VALUES('Gilan');\n    INSERT INTO b VALUES('Ardabil');\n  }\n} {}\ndb2 close\n\nfaultsim_save_and_close\ntestvfs T -default 1\nfaultsim_restore_and_reopen\nT filter xShmLock\nT script lock_callback\n\nproc lock_callback {method file handle spec} {\n  if {$spec == \"1 7 unlock exclusive\"} {\n    T filter {}\n    set ::r [catchsql { SELECT * FROM b } db2]\n  }\n}\nsqlite3 db test.db\nsqlite3 db2 test.db\ndo_test 2.5 {\n  execsql { SELECT * FROM b }\n} {Tehran Qom Markazi Qazvin Gilan Ardabil}\ndo_test 2.6 {\n  set ::r\n} {1 {locking protocol}}\n\ndb close\ndb2 close\n\nfaultsim_restore_and_reopen\nsqlite3 db2 test.db\nT filter xShmLock\nT script lock_callback\nproc lock_callback {method file handle spec} {\n  if {$spec == \"1 7 unlock exclusive\"} {\n    T filter {}\n    set ::r [catchsql { SELECT * FROM b } db2]\n  }\n}\nunset ::r\ndo_test 2.7 {\n  execsql { SELECT * FROM b }\n} {Tehran Qom Markazi Qazvin Gilan Ardabil}\ndo_test 2.8 {\n  set ::r\n} {1 {locking protocol}}\n\ndb close\ndb2 close\nT delete\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walro.test",
    "content": "# 2011 May 09\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file contains tests for using WAL databases in read-only mode.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nset ::testprefix walro\n\n# These tests are only going to work on unix.\n#\nif {$::tcl_platform(platform) != \"unix\"} {\n  finish_test\n  return\n}\n\n# And only if the build is WAL-capable.\n#\nifcapable !wal {\n  finish_test\n  return\n}\n\ndo_multiclient_test tn {\n  \n  # Close all connections and delete the database.\n  #\n  code1 { db close  }\n  code2 { db2 close }\n  code3 { db3 close }\n  forcedelete test.db\n  forcedelete walro\n  \n  # Do not run tests with the connections in the same process.\n  #\n  if {$tn==2} continue\n\n  foreach c {code1 code2 code3} {\n    $c {\n      sqlite3_shutdown\n      sqlite3_config_uri 1\n    }\n  }\n\n  file mkdir walro\n\n  do_test 1.1.1 {\n    code2 { sqlite3 db2 test.db }\n    sql2 { \n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(x, y);\n      INSERT INTO t1 VALUES('a', 'b');\n    }\n    file exists test.db-shm\n  } {1}\n\n  do_test 1.1.2 {\n    file attributes test.db-shm -permissions r--r--r--\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n  } {}\n\n  do_test 1.1.3 { sql1 \"SELECT * FROM t1\" }                {a b}\n  do_test 1.1.4 { sql2 \"INSERT INTO t1 VALUES('c', 'd')\" } {}\n  do_test 1.1.5 { sql1 \"SELECT * FROM t1\" }                {a b c d}\n\n  # Check that the read-only connection cannot write or checkpoint the db.\n  #\n  do_test 1.1.6 { \n    csql1 \"INSERT INTO t1 VALUES('e', 'f')\" \n  } {1 {attempt to write a readonly database}}\n  do_test 1.1.7 { \n    csql1 \"PRAGMA wal_checkpoint\"\n  } {1 {attempt to write a readonly database}}\n\n  do_test 1.1.9  { sql2 \"INSERT INTO t1 VALUES('e', 'f')\" } {}\n  do_test 1.1.10 { sql1 \"SELECT * FROM t1\" }                {a b c d e f}\n\n  do_test 1.1.11 { \n    sql2 {\n      INSERT INTO t1 VALUES('g', 'h');\n      PRAGMA wal_checkpoint;\n    }\n    set {} {}\n  } {}\n  do_test 1.1.12 { sql1 \"SELECT * FROM t1\" }                {a b c d e f g h}\n  do_test 1.1.13  { sql2 \"INSERT INTO t1 VALUES('i', 'j')\" } {}\n\n  do_test 1.2.1 {\n    code2 { db2 close }\n    code1 { db close }\n    list [file exists test.db-wal] [file exists test.db-shm]\n  } {1 1}\n  do_test 1.2.2 {\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n    sql1 { SELECT * FROM t1 }\n  } {a b c d e f g h i j}\n\n  do_test 1.2.3 {\n    code1 { db close }\n    file attributes test.db-shm -permissions rw-r--r--\n    hexio_write test.db-shm 0 01020304 \n    file attributes test.db-shm -permissions r--r--r--\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n    csql1 { SELECT * FROM t1 }\n  } {1 {attempt to write a readonly database}}\n  do_test 1.2.4 {\n    code1 { sqlite3_extended_errcode db } \n  } {SQLITE_READONLY_RECOVERY}\n\n  do_test 1.2.5 {\n    file attributes test.db-shm -permissions rw-r--r--\n    code2 { sqlite3 db2 test.db }\n    sql2 \"SELECT * FROM t1\" \n  } {a b c d e f g h i j}\n  file attributes test.db-shm -permissions r--r--r--\n  do_test 1.2.6 { sql1 \"SELECT * FROM t1\" } {a b c d e f g h i j}\n\n  do_test 1.2.7 { \n    sql2 {\n      PRAGMA wal_checkpoint;\n      INSERT INTO t1 VALUES('k', 'l');\n    }\n    set {} {}\n  } {}\n  do_test 1.2.8 { sql1 \"SELECT * FROM t1\" } {a b c d e f g h i j k l}\n\n  # Now check that if the readonly_shm option is not supplied, or if it\n  # is set to zero, it is not possible to connect to the database without\n  # read-write access to the shm.\n  do_test 1.3.1 {\n    code1 { db close }\n    code1 { sqlite3 db test.db }\n    csql1 { SELECT * FROM t1 }\n  } {1 {unable to open database file}}\n\n  # Also test that if the -shm file can be opened for read/write access,\n  # it is not if readonly_shm=1 is present in the URI.\n  do_test 1.3.2.1 {\n    code1 { db close }\n    code2 { db2 close }\n    file exists test.db-shm\n  } {0}\n  do_test 1.3.2.2 {\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n    csql1 { SELECT * FROM sqlite_master }\n  } {1 {unable to open database file}}\n  do_test 1.3.2.3 {\n    code1 { db close }\n    close [open test.db-shm w]\n    file attributes test.db-shm -permissions r--r--r--\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n    csql1 { SELECT * FROM t1 }\n  } {1 {attempt to write a readonly database}}\n  do_test 1.3.2.4 {\n    code1 { sqlite3_extended_errcode db } \n  } {SQLITE_READONLY_RECOVERY}\n\n  #-----------------------------------------------------------------------\n  # Test cases 1.4.* check that checkpoints and log wraps don't prevent\n  # read-only connections from reading the database.\n  do_test 1.4.1 {\n    code1 { db close }\n    forcedelete test.db-shm\n    file exists test.db-shm\n  } {0}\n\n  # Open one read-only and one read-write connection. Write some data\n  # and then run a checkpoint using the read-write connection. Then\n  # check the read-only connection can still read.\n  do_test 1.4.2 {\n    code1 { sqlite3 db file:test.db?readonly_shm=1 }\n    code2 { sqlite3 db2 test.db }\n    csql2 { \n      INSERT INTO t1 VALUES(1, 2);\n      INSERT INTO t1 VALUES(3, 4);\n      INSERT INTO t1 VALUES(5, 6);\n      PRAGMA wal_checkpoint;\n    }\n  } {0 {0 3 3}}\n  do_test 1.4.3 {\n    csql1 { SELECT * FROM t1 }\n  } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}\n  \n  # Using the read-write connection, open a transaction and write lots\n  # of data - causing a cache spill and a log wrap. Then check that the \n  # read-only connection can still read the database.\n  do_test 1.4.4.1 {\n    csql2 {\n      PRAGMA cache_size = 10;\n      BEGIN;\n      CREATE TABLE t2(x, y);\n      INSERT INTO t2 VALUES('abc', 'xyz');\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      INSERT INTO t2 SELECT x||y, y||x FROM t2;\n    }\n    file size test.db-wal\n  } [expr {[nonzero_reserved_bytes]?148848:147800}]\n  do_test 1.4.4.2 {\n    csql1 { SELECT * FROM t1 }\n  } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}\n  do_test 1.4.4.3 {\n    csql2 COMMIT\n    csql1 { SELECT count(*) FROM t2 }\n  } {0 512}\n  do_test 1.4.5 {\n    code2 { db2 close }\n    code1 { db close }\n  } {}\n}\n\nforcedelete test.db\n\n#-----------------------------------------------------------------------\n# Test cases 2.* check that a read-only connection may read the\n# database file while a checkpoint operation is ongoing.\n#\ndo_multiclient_test tn {\n  \n  # Close all connections and delete the database.\n  #\n  code1 { db close  }\n  code2 { db2 close }\n  code3 { db3 close }\n  forcedelete test.db\n  forcedelete walro\n  \n  # Do not run tests with the connections in the same process.\n  #\n  if {$tn==2} continue\n\n  foreach c {code1 code2 code3} {\n    $c {\n      sqlite3_shutdown\n      sqlite3_config_uri 1\n    }\n  }\n  \n  proc tv_hook {x file args} {\n    if {[file tail $file]==\"test.db-wal\"} {\n      do_test 2.1.2 {\n        code2 { sqlite3 db2 file:test.db?readonly_shm=1 }\n        csql2 { SELECT count(*) FROM t2 }\n      } {0 4}\n      do_test 2.1.3 {\n        code2 { db2 close }\n      } {}\n    } \n  }\n\n  do_test 2.1.1 {\n    testvfs tv -default 1 -fullshm 1\n    tv script tv_hook\n    tv filter {}\n    code1 { sqlite3 db test.db }\n    csql1 { \n      PRAGMA auto_vacuum = 0;\n      PRAGMA journal_mode = WAL;\n      BEGIN;\n        CREATE TABLE t2(x, y);\n        INSERT INTO t2 VALUES('abc', 'xyz');\n        INSERT INTO t2 SELECT x||y, y||x FROM t2;\n        INSERT INTO t2 SELECT x||y, y||x FROM t2;\n      COMMIT;\n    }\n  } {0 wal}\n\n  tv filter xSync\n  set res [csql1 { PRAGMA wal_checkpoint }]\n  do_test 2.1.4 { set res } {0 {0 2 2}}\n\n  do_test 2.1.5 {\n    code1 { db close }\n    code1 { tv delete }\n  } {}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walshared.test",
    "content": "# 2010 August 2\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode with shared-cache turned on.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !wal {finish_test ; return }\n\ndb close\nset ::enable_shared_cache [sqlite3_enable_shared_cache 1]\n\nsqlite3 db  test.db\nsqlite3 db2 test.db\n\ndo_test walshared-1.0 {\n  execsql {\n    PRAGMA cache_size = 10;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);\n    INSERT INTO t1 VALUES(randomblob(100), randomblob(200));\n  }\n} {wal}\n\ndo_test walshared-1.1 {\n  execsql {\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(100), randomblob(200));\n      INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;\n      INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;\n      INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1;\n  }\n} {}\n\ndo_test walshared-1.2 {\n  catchsql { PRAGMA wal_checkpoint }\n} {1 {database table is locked}}\n\ndo_test walshared-1.3 {\n  catchsql { PRAGMA wal_checkpoint } db2\n} {1 {database table is locked}}\n\ndo_test walshared-1.4 {\n  execsql { COMMIT }\n  execsql { PRAGMA integrity_check } db2\n} {ok}\n\n\n\nsqlite3_enable_shared_cache $::enable_shared_cache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walslow.test",
    "content": "# 2010 March 17\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode. The tests in this file use \n# brute force methods, so may take a while to run.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/wal_common.tcl\nsource $testdir/lock_common.tcl\n\nifcapable !wal {finish_test ; return }\n\nset testprefix walslow\n\nproc reopen_db {} {\n  catch { db close }\n  forcedelete test.db test.db-wal\n  sqlite3 db test.db\n  execsql { PRAGMA journal_mode = wal }\n}\n\ndb close\nsave_prng_state\nfor {set seed 1} {$seed<10} {incr seed} {\n  expr srand($seed)\n  restore_prng_state\n  reopen_db\n  do_test walslow-1.seed=$seed.0 {\n    execsql { CREATE TABLE t1(a, b) }\n    execsql { CREATE INDEX i1 ON t1(a) }\n    execsql { CREATE INDEX i2 ON t1(b) }\n  } {}\n\n  for {set iTest 1} {$iTest < 100} {incr iTest} {\n\n    do_test walslow-1.seed=$seed.$iTest.1 {\n      set w [expr int(rand()*2000)]\n      set x [expr int(rand()*2000)]\n      execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) }\n      execsql { PRAGMA integrity_check }\n    } {ok}\n\n    do_test walslow-1.seed=$seed.$iTest.2 {\n      execsql \"PRAGMA wal_checkpoint;\"\n      execsql { PRAGMA integrity_check }\n    } {ok}\n\n    do_test walslow-1.seed=$seed.$iTest.3 {\n      forcedelete testX.db testX.db-wal\n      copy_file test.db testX.db\n      copy_file test.db-wal testX.db-wal\n  \n      sqlite3 db2 testX.db\n      execsql { PRAGMA journal_mode = WAL } db2\n      execsql { PRAGMA integrity_check } db2\n    } {ok}\n  \n    do_test walslow-1.seed=$seed.$iTest.4 {\n      execsql { SELECT count(*) FROM t1 WHERE a!=b } db2\n    } [execsql { SELECT count(*) FROM t1 WHERE a!=b }]\n    db2 close\n  }\n}\n\n#-------------------------------------------------------------------------\n# Test case walslow-3.* tests that the checksum calculation detects single \n# byte changes to frame or frame-header data and considers the frame\n# invalid as a result.\n#\nreset_db\ndo_test 3.1 {\n\n  execsql {\n    PRAGMA synchronous = NORMAL;\n    PRAGMA page_size = 1024;\n    CREATE TABLE t1(a, b);\n    INSERT INTO t1 VALUES(1, randomblob(300));\n    INSERT INTO t1 VALUES(2, randomblob(300));\n    PRAGMA journal_mode = WAL;\n    INSERT INTO t1 VALUES(3, randomblob(300));\n  }\n\n  file size test.db-wal\n} [wal_file_size 1 1024]\ndo_test 3.2 {\n  forcecopy test.db-wal test2.db-wal\n  forcecopy test.db test2.db\n  sqlite3 db2 test2.db\n  execsql { SELECT a FROM t1 } db2\n} {1 2 3}\ndb2 close\nforcecopy test.db test2.db\n\nforeach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} {\n  do_test 3.3.$incr {\n    set FAIL 0\n    for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} {\n\n      forcecopy test.db-wal test2.db-wal\n      set fd [open test2.db-wal r+]\n      fconfigure $fd -encoding binary\n      fconfigure $fd -translation binary\n  \n      seek $fd $iOff\n      binary scan [read $fd 1] c x\n      seek $fd $iOff\n      puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]]\n      close $fd\n    \n      sqlite3 db2 test2.db\n      if { [execsql { SELECT a FROM t1 } db2] != \"1 2\" } {set FAIL 1}\n      db2 close\n    }\n    set FAIL\n  } {0}\n}\n\n\n#-------------------------------------------------------------------------\n# Test large log summaries.\n#\n# In this case \"large\" usually means a log file that requires a wal-index\n# mapping larger than 64KB (the default initial allocation). A 64KB wal-index\n# is large enough for a log file that contains approximately 13100 frames.\n# So the following tests create logs containing at least this many frames.\n#\n# 4.1.*: This test case creates a very large log file within the\n#        file-system (around 200MB). The log file does not contain\n#        any valid frames. Test that the database file can still be\n#        opened and queried, and that the invalid log file causes no \n#        problems.\n#\n# 4.2.*: Test that a process may create a large log file and query\n#        the database (including the log file that it itself created).\n#\n# 4.3.*: Test that if a very large log file is created, and then a\n#        second connection is opened on the database file, it is possible\n#        to query the database (and the very large log) using the\n#        second connection.\n#\n# 4.4.*: Same test as wal-13.3.*. Except in this case the second\n#        connection is opened by an external process.\n#\nset ::blobcnt 0\nproc blob {nByte} {\n  incr ::blobcnt\n  return [string range [string repeat \"${::blobcnt}x\" $nByte] 1 $nByte]\n}\n\nreset_db\ndo_execsql_test 4.1 {\n  PRAGMA journal_mode = wal;\n  CREATE TABLE t1(x, y);\n  INSERT INTO \"t1\" VALUES('A',0);\n  CREATE TABLE t2(x, y);\n  INSERT INTO \"t2\" VALUES('B',2);\n} {wal}\ndb close\n\ndo_test 4.1.1 {\n  list [file exists test.db] [file exists test.db-wal]\n} {1 0}\ndo_test 4.1.2 {\n  set fd [open test.db-wal w]\n  seek $fd [expr 200*1024*1024]\n  puts $fd \"\"\n  close $fd\n  sqlite3 db test.db\n  execsql { SELECT * FROM t2 }\n} {B 2}\ndo_test 4.1.3 {\n  db close\n  file exists test.db-wal\n} {0}\n\ndo_test 4.2.1 {\n  sqlite3 db test.db\n  execsql { SELECT count(*) FROM t2 }\n} {1}\ndo_test 4.2.2 {\n  db function blob blob\n  for {set i 0} {$i < 16} {incr i} {\n    execsql { INSERT INTO t2 SELECT blob(400), blob(400) FROM t2 }\n  }\n  execsql { SELECT count(*) FROM t2 }\n} [expr int(pow(2, 16))]\ndo_test 4.2.3 {\n  expr [file size test.db-wal] > [wal_file_size 33000 1024]\n} 1\n\ndo_multiclient_test tn {\n  incr tn 2\n\n  do_test 4.$tn.0 {\n    sql1 {\n      PRAGMA journal_mode = WAL;\n      CREATE TABLE t1(x);\n      INSERT INTO t1 SELECT randomblob(800);\n    }\n    sql1 { SELECT count(*) FROM t1 }\n  } {1}\n\n  for {set ii 1} {$ii<16} {incr ii} {\n    do_test 4.$tn.$ii.a {\n      sql2 { INSERT INTO t1 SELECT randomblob(800) FROM t1 }\n      sql2 { SELECT count(*) FROM t1 }\n    } [expr (1<<$ii)]\n    do_test 4.$tn.$ii.b {\n      sql1 { SELECT count(*) FROM t1 }\n    } [expr (1<<$ii)]\n    do_test 4.$tn.$ii.c {\n      sql1 { SELECT count(*) FROM t1 }\n    } [expr (1<<$ii)]\n    do_test 4.$tn.$ii.d {\n      sql1 { PRAGMA integrity_check }\n    } {ok}\n  }\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/walthread.test",
    "content": "# 2010 April 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the operation of the library in\n# \"PRAGMA journal_mode=WAL\" mode with multiple threads.\n#\n\nset testdir [file dirname $argv0]\n\nsource $testdir/tester.tcl\nsource $testdir/lock_common.tcl\nif {[run_thread_tests]==0} { finish_test ; return }\nifcapable !wal             { finish_test ; return }\n\nset sqlite_walsummary_mmap_incr 64\n\n# How long, in seconds, to run each test for. If a test is set to run for\n# 0 seconds, it is omitted entirely.\n#\nunset -nocomplain seconds\nset seconds(walthread-1) 20\nset seconds(walthread-2) 20\nset seconds(walthread-3) 20\nset seconds(walthread-4) 20\nset seconds(walthread-5) 1\n\n# The parameter is the name of a variable in the callers context. The\n# variable may or may not exist when this command is invoked.\n#\n# If the variable does exist, its value is returned. Otherwise, this\n# command uses [vwait] to wait until it is set, then returns the value.\n# In other words, this is a version of the [set VARNAME] command that\n# blocks until a variable exists.\n#\nproc wait_for_var {varname} {\n  if {0==[uplevel [list info exists $varname]]} {\n    uplevel [list vwait $varname]\n  }\n  uplevel [list set $varname]\n}\n\n# The argument is the name of a list variable in the callers context. The \n# first element of the list is removed and returned. For example:\n#\n#   set L {a b c}\n#   set x [lshift L]\n#   assert { $x == \"a\" && $L == \"b c\" }\n#\nproc lshift {lvar} {\n  upvar $lvar L\n  set ret [lindex $L 0]\n  set L [lrange $L 1 end]\n  return $ret\n}\n\n\n#-------------------------------------------------------------------------\n#   do_thread_test TESTNAME OPTIONS...\n# \n# where OPTIONS are: \n#\n#   -seconds   SECONDS                How many seconds to run the test for\n#   -init      SCRIPT                 Script to run before test.\n#   -thread    NAME COUNT SCRIPT      Scripts to run in threads (or processes).\n#   -processes BOOLEAN                True to use processes instead of threads.\n#   -check     SCRIPT                 Script to run after test.\n#\nproc do_thread_test {args} {\n\n  set A $args\n\n  set P(testname) [lshift A]\n  set P(seconds) 5\n  set P(init) \"\"\n  set P(threads) [list]\n  set P(processes) 0\n  set P(check) {\n    set ic [db eval \"PRAGMA integrity_check\"]\n    if {$ic != \"ok\"} { error $ic }\n  }\n\n  unset -nocomplain ::done\n\n  while {[llength $A]>0} {\n    set a [lshift A]\n    switch -glob -- $a {\n      -seconds {\n        set P(seconds) [lshift A]\n      }\n\n      -init {\n        set P(init) [lshift A]\n      }\n\n      -processes {\n        set P(processes) [lshift A]\n      }\n\n      -check {\n        set P(check) [lshift A]\n      }\n\n      -thread {\n        set name  [lshift A]\n        set count [lshift A]\n        set prg   [lshift A]\n        lappend P(threads) [list $name $count $prg]\n      }\n\n      default {\n        error \"Unknown option: $a\"\n      }\n    }\n  }\n\n  if {$P(seconds) == 0} {\n    puts \"Skipping $P(testname)\"\n    return\n  }\n\n  puts \"Running $P(testname) for $P(seconds) seconds...\"\n\n  catch { db close }\n  forcedelete test.db test.db-journal test.db-wal\n\n  sqlite3 db test.db\n  eval $P(init)\n  catch { db close }\n\n  foreach T $P(threads) {\n    set name  [lindex $T 0]\n    set count [lindex $T 1]\n    set prg   [lindex $T 2]\n\n    for {set i 1} {$i <= $count} {incr i} {\n      set vars \"\n        set E(pid) $i\n        set E(nthread) $count\n        set E(seconds) $P(seconds)\n      \"\n      set program [string map [list %TEST% $prg %VARS% $vars] {\n\n        %VARS%\n\n        proc usleep {ms} {\n          set ::usleep 0\n          after $ms {set ::usleep 1}\n          vwait ::usleep\n        }\n\n        proc integrity_check {{db db}} {\n          set ic [$db eval {PRAGMA integrity_check}]\n          if {$ic != \"ok\"} {error $ic}\n        }\n\n        proc busyhandler {n} { usleep 10 ; return 0 }\n\n        sqlite3 db test.db\n        db busy busyhandler\n        db eval { SELECT randomblob($E(pid)*5) }\n\n        set ::finished 0\n        after [expr $E(seconds) * 1000] {set ::finished 1}\n        proc tt_continue {} { update ; expr ($::finished==0) }\n\n        set rc [catch { %TEST% } msg]\n\n        catch { db close }\n        list $rc $msg\n      }]\n\n      if {$P(processes)==0} {\n        sqlthread spawn ::done($name,$i) $program\n      } else {\n        testfixture_nb ::done($name,$i) $program\n      }\n    }\n  }\n\n  set report \"  Results:\"\n  foreach T $P(threads) {\n    set name  [lindex $T 0]\n    set count [lindex $T 1]\n    set prg   [lindex $T 2]\n\n    set reslist [list]\n    for {set i 1} {$i <= $count} {incr i} {\n      set res [wait_for_var ::done($name,$i)]\n      lappend reslist [lindex $res 1]\n      do_test $P(testname).$name.$i [list lindex $res 0] 0\n    }\n\n    append report \"   $name $reslist\"\n  }\n  puts $report\n\n  sqlite3 db test.db\n  set res \"\"\n  if {[catch $P(check) msg]} { set res $msg }\n  do_test $P(testname).check [list set {} $res] \"\"\n}\n\n# A wrapper around [do_thread_test] which runs the specified test twice.\n# Once using processes, once using threads. This command takes the same\n# arguments as [do_thread_test], except specifying the -processes switch\n# is illegal.\n#\nproc do_thread_test2 {args} {\n  set name [lindex $args 0]\n  if {[lsearch $args -processes]>=0} { error \"bad option: -processes\"}\n  uplevel [lreplace $args 0 0 do_thread_test \"$name-threads\" -processes 0]\n  uplevel [lreplace $args 0 0 do_thread_test \"$name-processes\" -processes 1]\n}\n\n#--------------------------------------------------------------------------\n# Start 10 threads. Each thread performs both read and write \n# transactions. Each read transaction consists of:\n#\n#   1) Reading the md5sum of all but the last table row,\n#   2) Running integrity check.\n#   3) Reading the value stored in the last table row,\n#   4) Check that the values read in steps 1 and 3 are the same, and that\n#      the md5sum of all but the last table row has not changed.\n#\n# Each write transaction consists of:\n#\n#   1) Modifying the contents of t1 (inserting, updating, deleting rows).\n#   2) Appending a new row to the table containing the md5sum() of all\n#      rows in the table.\n#\n# Each of the N threads runs N read transactions followed by a single write\n# transaction in a loop as fast as possible.\n#\n# There is also a single checkpointer thread. It runs the following loop:\n#\n#   1) Execute \"PRAGMA wal_checkpoint\"\n#   2) Sleep for 500 ms.\n#\ndo_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(x PRIMARY KEY);\n    PRAGMA lock_status;\n    INSERT INTO t1 VALUES(randomblob(100));\n    INSERT INTO t1 VALUES(randomblob(100));\n    INSERT INTO t1 SELECT md5sum(x) FROM t1;\n  }\n} -thread main 10 {\n\n  proc read_transaction {} {\n    set results [db eval {\n      BEGIN;\n        PRAGMA integrity_check;\n        SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1);\n        SELECT x FROM t1 WHERE rowid = (SELECT max(rowid) FROM t1);\n        SELECT md5sum(x) FROM t1 WHERE rowid != (SELECT max(rowid) FROM t1);\n      COMMIT;\n    }]\n\n    if {[llength $results]!=4\n     || [lindex $results 0] != \"ok\"\n     || [lindex $results 1] != [lindex $results 2]\n     || [lindex $results 2] != [lindex $results 3]\n    } {\n      error \"Failed read transaction: $results\"\n    }\n  }\n\n  proc write_transaction {} {\n    db eval {\n      BEGIN;\n        INSERT INTO t1 VALUES(randomblob(101 + $::E(pid)));\n        INSERT INTO t1 VALUES(randomblob(101 + $::E(pid)));\n        INSERT INTO t1 SELECT md5sum(x) FROM t1;\n      COMMIT;\n    }\n  }\n\n  # Turn off auto-checkpoint. Otherwise, an auto-checkpoint run by a\n  # writer may cause the dedicated checkpoint thread to return an\n  # SQLITE_BUSY error.\n  #\n  db eval { PRAGMA wal_autocheckpoint = 0 }\n\n  set nRun 0\n  while {[tt_continue]} {\n    read_transaction\n    write_transaction \n    incr nRun\n  }\n  set nRun\n\n} -thread ckpt 1 {\n  set nRun 0\n  while {[tt_continue]} {\n    db eval \"PRAGMA wal_checkpoint\"\n    usleep 500\n    incr nRun\n  }\n  set nRun\n}\n\n#--------------------------------------------------------------------------\n# This test has clients run the following procedure as fast as possible\n# in a loop:\n#\n#   1. Open a database handle.\n#   2. Execute a read-only transaction on the db.\n#   3. Do \"PRAGMA journal_mode = XXX\", where XXX is one of WAL or DELETE.\n#      Ignore any SQLITE_BUSY error.\n#   4. Execute a write transaction to insert a row into the db.\n#   5. Run \"PRAGMA integrity_check\"\n#\n# At present, there are 4 clients in total. 2 do \"journal_mode = WAL\", and\n# two do \"journal_mode = DELETE\".\n#\n# Each client returns a string of the form \"W w, R r\", where W is the \n# number of write-transactions performed using a WAL journal, and D is\n# the number of write-transactions performed using a rollback journal.\n# For example, \"192 w, 185 r\".\n#\ndo_thread_test2 walthread-2 -seconds $seconds(walthread-2) -init {\n  execsql { CREATE TABLE t1(x INTEGER PRIMARY KEY, y UNIQUE) }\n} -thread RB 2 {\n\n  db close\n  set nRun 0\n  set nDel 0\n  while {[tt_continue]} {\n    sqlite3 db test.db\n    db busy busyhandler\n    db eval { SELECT * FROM sqlite_master }\n    catch { db eval { PRAGMA journal_mode = DELETE } }\n    db eval {\n      BEGIN;\n      INSERT INTO t1 VALUES(NULL, randomblob(100+$E(pid)));\n    }\n    incr nRun 1\n    incr nDel [file exists test.db-journal]\n    if {[file exists test.db-journal] + [file exists test.db-wal] != 1} {\n      error \"File-system looks bad...\"\n    }\n    db eval COMMIT\n\n    integrity_check\n    db close\n  }\n  list $nRun $nDel\n  set {} \"[expr $nRun-$nDel] w, $nDel r\"\n\n} -thread WAL 2 {\n  db close\n  set nRun 0\n  set nDel 0\n  while {[tt_continue]} {\n    sqlite3 db test.db\n    db busy busyhandler\n    db eval { SELECT * FROM sqlite_master }\n    catch { db eval { PRAGMA journal_mode = WAL } }\n    db eval {\n      BEGIN;\n      INSERT INTO t1 VALUES(NULL, randomblob(110+$E(pid)));\n    }\n    incr nRun 1\n    incr nDel [file exists test.db-journal]\n    if {[file exists test.db-journal] + [file exists test.db-wal] != 1} {\n      error \"File-system looks bad...\"\n    }\n    db eval COMMIT\n\n    integrity_check\n    db close\n  }\n  set {} \"[expr $nRun-$nDel] w, $nDel r\"\n}\n\ndo_thread_test walthread-3 -seconds $seconds(walthread-3) -init {\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(cnt PRIMARY KEY, sum1, sum2);\n    CREATE INDEX i1 ON t1(sum1);\n    CREATE INDEX i2 ON t1(sum2);\n    INSERT INTO t1 VALUES(0, 0, 0);\n  }\n} -thread t 10 {\n\n  set nextwrite $E(pid)\n\n  proc wal_hook {zDb nEntry} {\n    if {$nEntry>10} { \n      set rc [catch { db eval {PRAGMA wal_checkpoint} } msg]\n      if {$rc && $msg != \"database is locked\"} { error $msg }\n    }\n    return 0\n  }\n  db wal_hook wal_hook\n\n  while {[tt_continue]} {\n    set max 0\n    while { $max != ($nextwrite-1) && [tt_continue] } {\n      set max [db eval { SELECT max(cnt) FROM t1 }]\n    }\n\n    if {[tt_continue]} {\n      set sum1 [db eval { SELECT sum(cnt) FROM t1 }]\n      set sum2 [db eval { SELECT sum(sum1) FROM t1 }]\n      db eval { INSERT INTO t1 VALUES($nextwrite, $sum1, $sum2) }\n      incr nextwrite $E(nthread)\n      integrity_check\n    }\n  }\n\n  set {} ok\n} -check {\n  puts \"  Final db contains [db eval {SELECT count(*) FROM t1}] rows\"\n  puts \"  Final integrity-check says: [db eval {PRAGMA integrity_check}]\"\n\n  # Check that the contents of the database are Ok.\n  set c 0\n  set s1 0\n  set s2 0\n  db eval { SELECT cnt, sum1, sum2 FROM t1 ORDER BY cnt } {\n    if {$c != $cnt || $s1 != $sum1 || $s2 != $sum2} {\n      error \"database content is invalid\"\n    }\n    incr s2 $s1\n    incr s1 $c\n    incr c 1\n  }\n}\n\ndo_thread_test2 walthread-4 -seconds $seconds(walthread-4) -init {\n  execsql {\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE);\n  }\n} -thread r 1 {\n  # This connection only ever reads the database. Therefore the \n  # busy-handler is not required. Disable it to check that this is true.\n  #\n  # UPDATE: That is no longer entirely true - as we don't use a blocking\n  # lock to enter RECOVER state. Which means there is a small chance a\n  # reader can see an SQLITE_BUSY.\n  #\n  while {[tt_continue]} {\n    integrity_check\n  }\n  set {} ok\n} -thread w 1 {\n\n  proc wal_hook {zDb nEntry} {\n    if {$nEntry>15} {db eval {PRAGMA wal_checkpoint}}\n    return 0\n  }\n  db wal_hook wal_hook\n  set row 1\n  while {[tt_continue]} {\n    db eval { REPLACE INTO t1 VALUES($row, randomblob(300)) }\n    incr row\n    if {$row == 10} { set row 1 }\n  }\n\n  set {} ok\n}\n\n\n# This test case attempts to provoke a deadlock condition that existed in\n# the unix VFS at one point. The problem occurred only while recovering a \n# very large wal file (one that requires a wal-index larger than the \n# initial default allocation of 64KB).\n#\ndo_thread_test walthread-5 -seconds $seconds(walthread-5) -init {\n\n  proc log_file_size {nFrame pgsz} {\n    expr {12 + ($pgsz+16)*$nFrame}\n  }\n\n  execsql {\n    PRAGMA page_size = 1024;\n    PRAGMA journal_mode = WAL;\n    CREATE TABLE t1(x);\n    BEGIN;\n      INSERT INTO t1 VALUES(randomblob(900));\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     2 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     4 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*     8 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    16 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    32 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*    64 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   128 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   256 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*   512 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  1024 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  2048 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  4096 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /*  8192 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 16384 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 32768 */\n      INSERT INTO t1 SELECT randomblob(900) FROM t1;      /* 65536 */\n    COMMIT;\n  }\n\n  forcecopy test.db-wal bak.db-wal\n  forcecopy test.db bak.db\n  db close\n\n  forcecopy bak.db-wal test.db-wal\n  forcecopy bak.db test.db\n\n  if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} {\n    error \"Somehow failed to create a large log file\"\n  }\n  puts \"Database with large log file recovered. Now running clients...\"\n} -thread T 5 {\n  db eval { SELECT count(*) FROM t1 }\n}\nunset -nocomplain seconds\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where.test",
    "content": "# 2001 September 15\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the use of indices in WHERE clases.\n#\n# $Id: where.test,v 1.50 2008/11/03 09:06:06 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test where-1.0 {\n  execsql {\n    CREATE TABLE t1(w int, x int, y int);\n    CREATE TABLE t2(p int, q int, r int, s int);\n  }\n  for {set i 1} {$i<=100} {incr i} {\n    set w $i\n    set x [expr {int(log($i)/log(2))}]\n    set y [expr {$i*$i + 2*$i + 1}]\n    execsql \"INSERT INTO t1 VALUES($w,$x,$y)\"\n  }\n\n  ifcapable subquery {\n    execsql {\n      INSERT INTO t2 SELECT 101-w, x, (SELECT max(y) FROM t1)+1-y, y FROM t1;\n    }\n  } else {\n    set maxy [execsql {select max(y) from t1}]\n    execsql \"\n      INSERT INTO t2 SELECT 101-w, x, $maxy+1-y, y FROM t1;\n    \"\n  }\n\n  execsql {\n    CREATE INDEX i1w ON t1(\"w\");  -- Verify quoted identifier names\n    CREATE INDEX i1xy ON t1(`x`,'y' ASC); -- Old MySQL compatibility\n    CREATE INDEX i2p ON t2(p);\n    CREATE INDEX i2r ON t2(r);\n    CREATE INDEX i2qs ON t2(q, s);\n  }\n} {}\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# Verify that queries use an index.  We are using the special variable\n# \"sqlite_search_count\" which tallys the number of executions of MoveTo\n# and Next operators in the VDBE.  By verifing that the search count is\n# small we can be assured that indices are being used properly.\n#\ndo_test where-1.1.1 {\n  count {SELECT x, y, w FROM t1 WHERE w=10}\n} {3 121 10 3}\ndo_test where-1.1.1b {\n  count {SELECT x, y, w FROM t1 WHERE w IS 10}\n} {3 121 10 3}\ndo_eqp_test where-1.1.2 {\n  SELECT x, y, w FROM t1 WHERE w=10\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_eqp_test where-1.1.2b {\n  SELECT x, y, w FROM t1 WHERE w IS 10\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_test where-1.1.3 {\n  db status step\n} {0}\ndo_test where-1.1.4 {\n  db eval {SELECT x, y, w FROM t1 WHERE +w=10}\n} {3 121 10}\ndo_test where-1.1.5 {\n  db status step\n} {99}\ndo_eqp_test where-1.1.6 {\n  SELECT x, y, w FROM t1 WHERE +w=10\n} {*SCAN TABLE t1*}\ndo_test where-1.1.7 {\n  count {SELECT x, y, w AS abc FROM t1 WHERE abc=10}\n} {3 121 10 3}\ndo_eqp_test where-1.1.8 {\n  SELECT x, y, w AS abc FROM t1 WHERE abc=10\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_test where-1.1.9 {\n  db status step\n} {0}\ndo_test where-1.2.1 {\n  count {SELECT x, y, w FROM t1 WHERE w=11}\n} {3 144 11 3}\ndo_test where-1.2.2 {\n  count {SELECT x, y, w AS abc FROM t1 WHERE abc=11}\n} {3 144 11 3}\ndo_test where-1.3.1 {\n  count {SELECT x, y, w AS abc FROM t1 WHERE 11=w}\n} {3 144 11 3}\ndo_test where-1.3.2 {\n  count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc}\n} {3 144 11 3}\ndo_test where-1.3.3 {\n  count {SELECT x, y, w AS abc FROM t1 WHERE 11 IS abc}\n} {3 144 11 3}\ndo_test where-1.4.1 {\n  count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2}\n} {11 3 144 3}\ndo_test where-1.4.1b {\n  count {SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2}\n} {11 3 144 3}\ndo_eqp_test where-1.4.2 {\n  SELECT w, x, y FROM t1 WHERE 11=w AND x>2\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_eqp_test where-1.4.2b {\n  SELECT w, x, y FROM t1 WHERE 11 IS w AND x>2\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_test where-1.4.3 {\n  count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2}\n} {11 3 144 3}\ndo_eqp_test where-1.4.4 {\n  SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_test where-1.5 {\n  count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2}\n} {3 144 3}\ndo_eqp_test where-1.5.2 {\n  SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2\n} {*SEARCH TABLE t1 USING INDEX i1w (w=?)*}\ndo_test where-1.6 {\n  count {SELECT x, y FROM t1 WHERE y<200 AND x>2 AND w=11}\n} {3 144 3}\ndo_test where-1.7 {\n  count {SELECT x, y FROM t1 WHERE w=11 AND y<200 AND x>2}\n} {3 144 3}\ndo_test where-1.8 {\n  count {SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3}\n} {3 144 3}\ndo_eqp_test where-1.8.2 {\n  SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3\n} {*SEARCH TABLE t1 USING INDEX i1xy (x=? AND y=?)*}\ndo_eqp_test where-1.8.3 {\n  SELECT x, y FROM t1 WHERE y=144 AND x=3\n} {*SEARCH TABLE t1 USING COVERING INDEX i1xy (x=? AND y=?)*}\ndo_test where-1.9 {\n  count {SELECT x, y FROM t1 WHERE y=144 AND w>10 AND x=3}\n} {3 144 3}\ndo_test where-1.10 {\n  count {SELECT x, y FROM t1 WHERE x=3 AND w>=10 AND y=121}\n} {3 121 3}\ndo_test where-1.11 {\n  count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10}\n} {3 100 3}\ndo_test where-1.11b {\n  count {SELECT x, y FROM t1 WHERE x IS 3 AND y IS 100 AND w<10}\n} {3 100 3}\n\n# New for SQLite version 2.1: Verify that that inequality constraints\n# are used correctly.\n#\ndo_test where-1.12 {\n  count {SELECT w FROM t1 WHERE x=3 AND y<100}\n} {8 3}\ndo_test where-1.12b {\n  count {SELECT w FROM t1 WHERE x IS 3 AND y<100}\n} {8 3}\ndo_test where-1.13 {\n  count {SELECT w FROM t1 WHERE x=3 AND 100>y}\n} {8 3}\ndo_test where-1.14 {\n  count {SELECT w FROM t1 WHERE 3=x AND y<100}\n} {8 3}\ndo_test where-1.14b {\n  count {SELECT w FROM t1 WHERE 3 IS x AND y<100}\n} {8 3}\ndo_test where-1.15 {\n  count {SELECT w FROM t1 WHERE 3=x AND 100>y}\n} {8 3}\ndo_test where-1.16 {\n  count {SELECT w FROM t1 WHERE x=3 AND y<=100}\n} {8 9 5}\ndo_test where-1.17 {\n  count {SELECT w FROM t1 WHERE x=3 AND 100>=y}\n} {8 9 5}\ndo_test where-1.18 {\n  count {SELECT w FROM t1 WHERE x=3 AND y>225}\n} {15 3}\ndo_test where-1.18b {\n  count {SELECT w FROM t1 WHERE x IS 3 AND y>225}\n} {15 3}\ndo_test where-1.19 {\n  count {SELECT w FROM t1 WHERE x=3 AND 225<y}\n} {15 3}\ndo_test where-1.20 {\n  count {SELECT w FROM t1 WHERE x=3 AND y>=225}\n} {14 15 5}\ndo_test where-1.21 {\n  count {SELECT w FROM t1 WHERE x=3 AND 225<=y}\n} {14 15 5}\ndo_test where-1.22 {\n  count {SELECT w FROM t1 WHERE x=3 AND y>121 AND y<196}\n} {11 12 5}\ndo_test where-1.22b {\n  count {SELECT w FROM t1 WHERE x IS 3 AND y>121 AND y<196}\n} {11 12 5}\ndo_test where-1.23 {\n  count {SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196}\n} {10 11 12 13 9}\ndo_test where-1.24 {\n  count {SELECT w FROM t1 WHERE x=3 AND 121<y AND 196>y}\n} {11 12 5}\ndo_test where-1.25 {\n  count {SELECT w FROM t1 WHERE x=3 AND 121<=y AND 196>=y}\n} {10 11 12 13 9}\n\n# Need to work on optimizing the BETWEEN operator.  \n#\n# do_test where-1.26 {\n#   count {SELECT w FROM t1 WHERE x=3 AND y BETWEEN 121 AND 196}\n# } {10 11 12 13 9}\n\ndo_test where-1.27 {\n  count {SELECT w FROM t1 WHERE x=3 AND y+1==122}\n} {10 10}\n\ndo_test where-1.28 {\n  count {SELECT w FROM t1 WHERE x+1=4 AND y+1==122}\n} {10 99}\ndo_test where-1.29 {\n  count {SELECT w FROM t1 WHERE y==121}\n} {10 99}\n\n\ndo_test where-1.30 {\n  count {SELECT w FROM t1 WHERE w>97}\n} {98 99 100 3}\ndo_test where-1.31 {\n  count {SELECT w FROM t1 WHERE w>=97}\n} {97 98 99 100 4}\ndo_test where-1.33 {\n  count {SELECT w FROM t1 WHERE w==97}\n} {97 2}\ndo_test where-1.33.1  {\n  count {SELECT w FROM t1 WHERE w<=97 AND w==97}\n} {97 2}\ndo_test where-1.33.2  {\n  count {SELECT w FROM t1 WHERE w<98 AND w==97}\n} {97 2}\ndo_test where-1.33.3  {\n  count {SELECT w FROM t1 WHERE w>=97 AND w==97}\n} {97 2}\ndo_test where-1.33.4  {\n  count {SELECT w FROM t1 WHERE w>96 AND w==97}\n} {97 2}\ndo_test where-1.33.5  {\n  count {SELECT w FROM t1 WHERE w==97 AND w==97}\n} {97 2}\ndo_test where-1.34 {\n  count {SELECT w FROM t1 WHERE w+1==98}\n} {97 99}\ndo_test where-1.35 {\n  count {SELECT w FROM t1 WHERE w<3}\n} {1 2 3}\ndo_test where-1.36 {\n  count {SELECT w FROM t1 WHERE w<=3}\n} {1 2 3 4}\ndo_test where-1.37 {\n  count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w}\n} {1 2 3 99}\n\ndo_test where-1.38 {\n  count {SELECT (w) FROM t1 WHERE (w)>(97)}\n} {98 99 100 3}\ndo_test where-1.39 {\n  count {SELECT (w) FROM t1 WHERE (w)>=(97)}\n} {97 98 99 100 4}\ndo_test where-1.40 {\n  count {SELECT (w) FROM t1 WHERE (w)==(97)}\n} {97 2}\ndo_test where-1.41 {\n  count {SELECT (w) FROM t1 WHERE ((w)+(1))==(98)}\n} {97 99}\n\n\n# Do the same kind of thing except use a join as the data source.\n#\ndo_test where-2.1 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE x=q AND y=s AND r=8977\n  }\n} {34 67 6}\ndo_test where-2.2 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE x=q AND s=y AND r=8977\n  }\n} {34 67 6}\ndo_test where-2.3 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE x=q AND s=y AND r=8977 AND w>10\n  }\n} {34 67 6}\ndo_test where-2.4 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE p<80 AND x=q AND s=y AND r=8977 AND w>10\n  }\n} {34 67 6}\ndo_test where-2.5 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE p<80 AND x=q AND 8977=r AND s=y AND w>10\n  }\n} {34 67 6}\ndo_test where-2.6 {\n  count {\n    SELECT w, p FROM t2, t1\n    WHERE x=q AND p=77 AND s=y AND w>5\n  }\n} {24 77 6}\ndo_test where-2.7 {\n  count {\n    SELECT w, p FROM t1, t2\n    WHERE x=q AND p>77 AND s=y AND w=5\n  }\n} {5 96 6}\n\n# Lets do a 3-way join.\n#\ndo_test where-3.1 {\n  count {\n    SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C\n    WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=11\n  }\n} {11 90 11 8}\ndo_test where-3.2 {\n  count {\n    SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C\n    WHERE C.w=101-B.p AND B.r=10202-A.y AND A.w=12\n  }\n} {12 89 12 8}\ndo_test where-3.3 {\n  count {\n    SELECT A.w, B.p, C.w FROM t1 as A, t2 as B, t1 as C\n    WHERE A.w=15 AND B.p=C.w AND B.r=10202-A.y\n  }\n} {15 86 86 8}\n\n# Test to see that the special case of a constant WHERE clause is\n# handled.\n#\ndo_test where-4.1 {\n  count {\n    SELECT * FROM t1 WHERE 0\n  }\n} {0}\ndo_test where-4.2 {\n  count {\n    SELECT * FROM t1 WHERE 1 LIMIT 1\n  }\n} {1 0 4 0}\ndo_test where-4.3 {\n  execsql {\n    SELECT 99 WHERE 0\n  }\n} {}\ndo_test where-4.4 {\n  execsql {\n    SELECT 99 WHERE 1\n  }\n} {99}\ndo_test where-4.5 {\n  execsql {\n    SELECT 99 WHERE 0.1\n  }\n} {99}\ndo_test where-4.6 {\n  execsql {\n    SELECT 99 WHERE 0.0\n  }\n} {}\ndo_test where-4.7 {\n  execsql {\n    SELECT count(*) FROM t1 WHERE t1.w\n  }\n} {100}\n\n# Verify that IN operators in a WHERE clause are handled correctly.\n# Omit these tests if the build is not capable of sub-queries.\n#\nifcapable subquery {\n  do_test where-5.1 {\n    count {\n      SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 4}\n  do_test where-5.2 {\n    count {\n      SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 102}\n  do_test where-5.3a {\n    count {\n      SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 12}\n  do_test where-5.3b {\n    count {\n      SELECT * FROM t1 WHERE w IN (3,-1,1,2) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 12}\n  do_test where-5.3c {\n    count {\n      SELECT * FROM t1 WHERE w IN (3,2,-1,1,2) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 12}\n  do_test where-5.3d {\n    count {\n      SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1 DESC;\n    }\n  } {3 1 16 2 1 9 1 0 4 11}\n  do_test where-5.4 {\n    count {\n      SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1;\n    }\n  } {1 0 4 2 1 9 3 1 16 102}\n  do_test where-5.5 {\n    count {\n      SELECT * FROM t1 WHERE rowid IN \n         (select rowid from t1 where rowid IN (-1,2,4))\n      ORDER BY 1;\n    }\n  } {2 1 9 4 2 25 3}\n  do_test where-5.6 {\n    count {\n      SELECT * FROM t1 WHERE rowid+0 IN \n         (select rowid from t1 where rowid IN (-1,2,4))\n      ORDER BY 1;\n    }\n  } {2 1 9 4 2 25 103}\n  do_test where-5.7 {\n    count {\n      SELECT * FROM t1 WHERE w IN \n         (select rowid from t1 where rowid IN (-1,2,4))\n      ORDER BY 1;\n    }\n  } {2 1 9 4 2 25 9}\n  do_test where-5.8 {\n    count {\n      SELECT * FROM t1 WHERE w+0 IN \n         (select rowid from t1 where rowid IN (-1,2,4))\n      ORDER BY 1;\n    }\n  } {2 1 9 4 2 25 103}\n  do_test where-5.9 {\n    count {\n      SELECT * FROM t1 WHERE x IN (1,7) ORDER BY 1;\n    }\n  } {2 1 9 3 1 16 6}\n  do_test where-5.10 {\n    count {\n      SELECT * FROM t1 WHERE x+0 IN (1,7) ORDER BY 1;\n    }\n  } {2 1 9 3 1 16 199}\n  do_test where-5.11 {\n    count {\n      SELECT * FROM t1 WHERE y IN (6400,8100) ORDER BY 1;\n    }\n  } {79 6 6400 89 6 8100 199}\n  do_test where-5.12 {\n    count {\n      SELECT * FROM t1 WHERE x=6 AND y IN (6400,8100) ORDER BY 1;\n    }\n  } {79 6 6400 89 6 8100 7}\n  do_test where-5.13 {\n    count {\n      SELECT * FROM t1 WHERE x IN (1,7) AND y NOT IN (6400,8100) ORDER BY 1;\n    }\n  } {2 1 9 3 1 16 6}\n  do_test where-5.14 {\n    count {\n      SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1;\n    }\n  } {2 1 9 5}\n  do_test where-5.15 {\n    count {\n      SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1;\n    }\n  } {2 1 9 3 1 16 9}\n  do_test where-5.100 {\n    db eval {\n      SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)\n       ORDER BY x, y\n    }\n  } {2 1 9 54 5 3025 62 5 3969}\n  do_test where-5.101 {\n    db eval {\n      SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)\n       ORDER BY x DESC, y DESC\n    }\n  } {62 5 3969 54 5 3025 2 1 9}\n  do_test where-5.102 {\n    db eval {\n      SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)\n       ORDER BY x DESC, y\n    }\n  } {54 5 3025 62 5 3969 2 1 9}\n  do_test where-5.103 {\n    db eval {\n      SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969)\n       ORDER BY x, y DESC\n    }\n  } {2 1 9 62 5 3969 54 5 3025}\n}\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set data [execsql $sql]\n  if {[db status sort]} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n# Check out the logic that attempts to implement the ORDER BY clause\n# using an index rather than by sorting.\n#\ndo_test where-6.1 {\n  execsql {\n    CREATE TABLE t3(a,b,c);\n    CREATE INDEX t3a ON t3(a);\n    CREATE INDEX t3bc ON t3(b,c);\n    CREATE INDEX t3acb ON t3(a,c,b);\n    INSERT INTO t3 SELECT w, 101-w, y FROM t1;\n    SELECT count(*), sum(a), sum(b), sum(c) FROM t3;\n  }\n} {100 5050 5050 348550}\ndo_test where-6.2 {\n  cksort {\n    SELECT * FROM t3 ORDER BY a LIMIT 3\n  }\n} {1 100 4 2 99 9 3 98 16 nosort}\ndo_test where-6.3 {\n  cksort {\n    SELECT * FROM t3 ORDER BY a+1 LIMIT 3\n  }\n} {1 100 4 2 99 9 3 98 16 sort}\ndo_test where-6.4 {\n  cksort {\n    SELECT * FROM t3 WHERE a<10 ORDER BY a LIMIT 3\n  }\n} {1 100 4 2 99 9 3 98 16 nosort}\ndo_test where-6.5 {\n  cksort {\n    SELECT * FROM t3 WHERE a>0 AND a<10 ORDER BY a LIMIT 3\n  }\n} {1 100 4 2 99 9 3 98 16 nosort}\ndo_test where-6.6 {\n  cksort {\n    SELECT * FROM t3 WHERE a>0 ORDER BY a LIMIT 3\n  }\n} {1 100 4 2 99 9 3 98 16 nosort}\ndo_test where-6.7.1 {\n  cksort {\n    SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 10\n  }\n} {/1 100 4 2 99 9 3 98 16 .* nosort/}\ndo_test where-6.7.2 {\n  cksort {\n    SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 1\n  }\n} {1 100 4 sort}\nifcapable subquery {\n  do_test where-6.8a {\n    cksort {\n      SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3\n    }\n  } {1 100 4 2 99 9 3 98 16 nosort}\n  do_test where-6.8b {\n    cksort {\n      SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a DESC LIMIT 3\n    }\n  } {9 92 100 7 94 64 5 96 36 nosort}\n}\ndo_test where-6.9.1 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.1.1 {\n  cksort {\n    SELECT * FROM t3 WHERE a>=1 AND a=1 AND c>0 ORDER BY a LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.1.2 {\n  cksort {\n    SELECT * FROM t3 WHERE a<2 AND a=1 AND c>0 ORDER BY a LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.2 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.3 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.4 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.5 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c DESC LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.6 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c DESC LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.7 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c,a LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.8 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c ASC LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.9.9 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a ASC, c DESC LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.10 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.11 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.12 {\n  cksort {\n    SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a,c,b LIMIT 3\n  }\n} {1 100 4 nosort}\ndo_test where-6.13 {\n  cksort {\n    SELECT * FROM t3 WHERE a>0 ORDER BY a DESC LIMIT 3\n  }\n} {100 1 10201 99 2 10000 98 3 9801 nosort}\ndo_test where-6.13.1 {\n  cksort {\n    SELECT * FROM t3 WHERE a>0 ORDER BY -a LIMIT 3\n  }\n} {100 1 10201 99 2 10000 98 3 9801 sort}\ndo_test where-6.14 {\n  cksort {\n    SELECT * FROM t3 ORDER BY b LIMIT 3\n  }\n} {100 1 10201 99 2 10000 98 3 9801 nosort}\ndo_test where-6.15 {\n  cksort {\n    SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t3.a LIMIT 3\n  }\n} {1 0 2 1 3 1 nosort}\ndo_test where-6.16 {\n  cksort {\n    SELECT t3.a, t1.x FROM t3, t1 WHERE t3.a=t1.w ORDER BY t1.x, t3.a LIMIT 3\n  }\n} {1 0 2 1 3 1 sort}\ndo_test where-6.19 {\n  cksort {\n    SELECT y FROM t1 ORDER BY w LIMIT 3;\n  }\n} {4 9 16 nosort}\ndo_test where-6.20 {\n  cksort {\n    SELECT y FROM t1 ORDER BY rowid LIMIT 3;\n  }\n} {4 9 16 nosort}\ndo_test where-6.21 {\n  cksort {\n    SELECT y FROM t1 ORDER BY rowid, y LIMIT 3;\n  }\n} {4 9 16 nosort}\ndo_test where-6.22 {\n  cksort {\n    SELECT y FROM t1 ORDER BY rowid, y DESC LIMIT 3;\n  }\n} {4 9 16 nosort}\ndo_test where-6.23 {\n  cksort {\n    SELECT y FROM t1 WHERE y>4 ORDER BY rowid, w, x LIMIT 3;\n  }\n} {9 16 25 nosort}\ndo_test where-6.24 {\n  cksort {\n    SELECT y FROM t1 WHERE y>=9 ORDER BY rowid, x DESC, w LIMIT 3;\n  }\n} {9 16 25 nosort}\ndo_test where-6.25 {\n  cksort {\n    SELECT y FROM t1 WHERE y>4 AND y<25 ORDER BY rowid;\n  }\n} {9 16 nosort}\ndo_test where-6.26 {\n  cksort {\n    SELECT y FROM t1 WHERE y>=4 AND y<=25 ORDER BY oid;\n  }\n} {4 9 16 25 nosort}\ndo_test where-6.27 {\n  cksort {\n    SELECT y FROM t1 WHERE y<=25 ORDER BY _rowid_, w+y;\n  }\n} {4 9 16 25 nosort}\n\n\n# Tests for reverse-order sorting.\n#\ndo_test where-7.1 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 ORDER BY y;\n  }\n} {8 9 10 11 12 13 14 15 nosort}\ndo_test where-7.2 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 ORDER BY y DESC;\n  }\n} {15 14 13 12 11 10 9 8 nosort}\ndo_test where-7.3 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>100 ORDER BY y LIMIT 3;\n  }\n} {10 11 12 nosort}\ndo_test where-7.4 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>100 ORDER BY y DESC LIMIT 3;\n  }\n} {15 14 13 nosort}\ndo_test where-7.5 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>121 ORDER BY y DESC;\n  }\n} {15 14 13 12 11 nosort}\ndo_test where-7.6 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=121 ORDER BY y DESC;\n  }\n} {15 14 13 12 11 10 nosort}\ndo_test where-7.7 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<196 ORDER BY y DESC;\n  }\n} {12 11 10 nosort}\ndo_test where-7.8 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196 ORDER BY y DESC;\n  }\n} {13 12 11 10 nosort}\ndo_test where-7.9 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>121 AND y<=196 ORDER BY y DESC;\n  }\n} {13 12 11 nosort}\ndo_test where-7.10 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>100 AND y<196 ORDER BY y DESC;\n  }\n} {12 11 10 nosort}\ndo_test where-7.11 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<196 ORDER BY y;\n  }\n} {10 11 12 nosort}\ndo_test where-7.12 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=121 AND y<=196 ORDER BY y;\n  }\n} {10 11 12 13 nosort}\ndo_test where-7.13 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>121 AND y<=196 ORDER BY y;\n  }\n} {11 12 13 nosort}\ndo_test where-7.14 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>100 AND y<196 ORDER BY y;\n  }\n} {10 11 12 nosort}\ndo_test where-7.15 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y<81 ORDER BY y;\n  }\n} {nosort}\ndo_test where-7.16 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y<=81 ORDER BY y;\n  }\n} {8 nosort}\ndo_test where-7.17 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>256 ORDER BY y;\n  }\n} {nosort}\ndo_test where-7.18 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=256 ORDER BY y;\n  }\n} {15 nosort}\ndo_test where-7.19 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y<81 ORDER BY y DESC;\n  }\n} {nosort}\ndo_test where-7.20 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y<=81 ORDER BY y DESC;\n  }\n} {8 nosort}\ndo_test where-7.21 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>256 ORDER BY y DESC;\n  }\n} {nosort}\ndo_test where-7.22 {\n  cksort {\n    SELECT w FROM t1 WHERE x=3 AND y>=256 ORDER BY y DESC;\n  }\n} {15 nosort}\ndo_test where-7.23 {\n  cksort {\n    SELECT w FROM t1 WHERE x=0 AND y<4 ORDER BY y;\n  }\n} {nosort}\ndo_test where-7.24 {\n  cksort {\n    SELECT w FROM t1 WHERE x=0 AND y<=4 ORDER BY y;\n  }\n} {1 nosort}\ndo_test where-7.25 {\n  cksort {\n    SELECT w FROM t1 WHERE x=6 AND y>10201 ORDER BY y;\n  }\n} {nosort}\ndo_test where-7.26 {\n  cksort {\n    SELECT w FROM t1 WHERE x=6 AND y>=10201 ORDER BY y;\n  }\n} {100 nosort}\ndo_test where-7.27 {\n  cksort {\n    SELECT w FROM t1 WHERE x=0 AND y<4 ORDER BY y DESC;\n  }\n} {nosort}\ndo_test where-7.28 {\n  cksort {\n    SELECT w FROM t1 WHERE x=0 AND y<=4 ORDER BY y DESC;\n  }\n} {1 nosort}\ndo_test where-7.29 {\n  cksort {\n    SELECT w FROM t1 WHERE x=6 AND y>10201 ORDER BY y DESC;\n  }\n} {nosort}\ndo_test where-7.30 {\n  cksort {\n    SELECT w FROM t1 WHERE x=6 AND y>=10201 ORDER BY y DESC;\n  }\n} {100 nosort}\ndo_test where-7.31 {\n  cksort {\n    SELECT y FROM t1 ORDER BY rowid DESC LIMIT 3\n  }\n} {10201 10000 9801 nosort}\ndo_test where-7.32 {\n  cksort {\n    SELECT y FROM t1 WHERE y<25 ORDER BY rowid DESC\n  }\n} {16 9 4 nosort}\ndo_test where-7.33 {\n  cksort {\n    SELECT y FROM t1 WHERE y<=25 ORDER BY rowid DESC\n  }\n} {25 16 9 4 nosort}\ndo_test where-7.34 {\n  cksort {\n    SELECT y FROM t1 WHERE y<25 AND y>4 ORDER BY rowid DESC, y DESC\n  }\n} {16 9 nosort}\ndo_test where-7.35 {\n  cksort {\n    SELECT y FROM t1 WHERE y<25 AND y>=4 ORDER BY rowid DESC\n  }\n} {16 9 4 nosort}\n\ndo_test where-8.1 {\n  execsql {\n    CREATE TABLE t4 AS SELECT * FROM t1;\n    CREATE INDEX i4xy ON t4(x,y);\n  }\n  cksort {\n    SELECT w FROM t4 WHERE x=4 and y<1000 ORDER BY y DESC limit 3;\n  }\n} {30 29 28 nosort}\ndo_test where-8.2 {\n  execsql {\n    DELETE FROM t4;\n  }\n  cksort {\n    SELECT w FROM t4 WHERE x=4 and y<1000 ORDER BY y DESC limit 3;\n  }\n} {nosort}\n\n# Make sure searches with an index work with an empty table.\n#\ndo_test where-9.1 {\n  execsql {\n    CREATE TABLE t5(x PRIMARY KEY);\n    SELECT * FROM t5 WHERE x<10;\n  }\n} {}\ndo_test where-9.2 {\n  execsql {\n    SELECT * FROM t5 WHERE x<10 ORDER BY x DESC;\n  }\n} {}\ndo_test where-9.3 {\n  execsql {\n    SELECT * FROM t5 WHERE x=10;\n  }\n} {}\n\ndo_test where-10.1 {\n  execsql {\n    SELECT 1 WHERE abs(random())<0\n  }\n} {}\ndo_test where-10.2 {\n  proc tclvar_func {vname} {return [set ::$vname]}\n  db function tclvar tclvar_func\n  set ::v1 0\n  execsql {\n    SELECT count(*) FROM t1 WHERE tclvar('v1');\n  }\n} {0}\ndo_test where-10.3 {\n  set ::v1 1\n  execsql {\n    SELECT count(*) FROM t1 WHERE tclvar('v1');\n  }\n} {100}\ndo_test where-10.4 {\n  set ::v1 1\n  proc tclvar_func {vname} {\n    upvar #0 $vname v\n    set v [expr {!$v}]\n    return $v\n  }\n  execsql {\n    SELECT count(*) FROM t1 WHERE tclvar('v1');\n  }\n} {50}\n\n# Ticket #1376.  The query below was causing a segfault.\n# The problem was the age-old error of calling realloc() on an\n# array while there are still pointers to individual elements of\n# that array.\n#\ndo_test where-11.1 {\n  execsql {\n   CREATE TABLE t99(Dte INT, X INT);\n   DELETE FROM t99 WHERE (Dte = 2451337) OR (Dte = 2451339) OR\n     (Dte BETWEEN 2451345 AND 2451347) OR (Dte = 2451351) OR \n     (Dte BETWEEN 2451355 AND 2451356) OR (Dte = 2451358) OR\n     (Dte = 2451362) OR (Dte = 2451365) OR (Dte = 2451367) OR\n     (Dte BETWEEN 2451372 AND 2451376) OR (Dte BETWEEN 2451382 AND 2451384) OR\n     (Dte = 2451387) OR (Dte BETWEEN 2451389 AND 2451391) OR \n     (Dte BETWEEN 2451393 AND 2451395) OR (Dte = 2451400) OR \n     (Dte = 2451402) OR (Dte = 2451404) OR (Dte BETWEEN 2451416 AND 2451418) OR \n     (Dte = 2451422) OR (Dte = 2451426) OR (Dte BETWEEN 2451445 AND 2451446) OR\n     (Dte = 2451456) OR (Dte = 2451458) OR (Dte BETWEEN 2451465 AND 2451467) OR\n     (Dte BETWEEN 2451469 AND 2451471) OR (Dte = 2451474) OR\n     (Dte BETWEEN 2451477 AND 2451501) OR (Dte BETWEEN 2451503 AND 2451509) OR\n     (Dte BETWEEN 2451511 AND 2451514) OR (Dte BETWEEN 2451518 AND 2451521) OR\n     (Dte BETWEEN 2451523 AND 2451531) OR (Dte BETWEEN 2451533 AND 2451537) OR\n     (Dte BETWEEN 2451539 AND 2451544) OR (Dte BETWEEN 2451546 AND 2451551) OR\n     (Dte BETWEEN 2451553 AND 2451555) OR (Dte = 2451557) OR\n     (Dte BETWEEN 2451559 AND 2451561) OR (Dte = 2451563) OR\n     (Dte BETWEEN 2451565 AND 2451566) OR (Dte BETWEEN 2451569 AND 2451571) OR \n     (Dte = 2451573) OR (Dte = 2451575) OR (Dte = 2451577) OR (Dte = 2451581) OR\n     (Dte BETWEEN 2451583 AND 2451586) OR (Dte BETWEEN 2451588 AND 2451592) OR \n     (Dte BETWEEN 2451596 AND 2451598) OR (Dte = 2451600) OR\n     (Dte BETWEEN 2451602 AND 2451603) OR (Dte = 2451606) OR (Dte = 2451611);\n  }\n} {}\n\n# Ticket #2116:  Make sure sorting by index works well with nn INTEGER PRIMARY\n# KEY.\n#\ndo_test where-12.1 {\n  execsql {\n    CREATE TABLE t6(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t6 VALUES(1,'one');\n    INSERT INTO t6 VALUES(4,'four');\n    CREATE INDEX t6i1 ON t6(b);\n  }\n  cksort {\n    SELECT * FROM t6 ORDER BY b;\n  }\n} {4 four 1 one nosort}\ndo_test where-12.2 {\n  cksort {\n    SELECT * FROM t6 ORDER BY b, a;\n  }\n} {4 four 1 one nosort}\ndo_test where-12.3 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a;\n  }\n} {1 one 4 four nosort}\ndo_test where-12.4 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a, b;\n  }\n} {1 one 4 four nosort}\ndo_test where-12.5 {\n  cksort {\n    SELECT * FROM t6 ORDER BY b DESC;\n  }\n} {1 one 4 four nosort}\ndo_test where-12.6 {\n  cksort {\n    SELECT * FROM t6 ORDER BY b DESC, a DESC;\n  }\n} {1 one 4 four nosort}\ndo_test where-12.7 {\n  cksort {\n    SELECT * FROM t6 ORDER BY b DESC, a ASC;\n  }\n} {1 one 4 four sort}\ndo_test where-12.8 {\n  cksort {\n    SELECT * FROM t6 ORDER BY b ASC, a DESC;\n  }\n} {4 four 1 one sort}\ndo_test where-12.9 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a DESC;\n  }\n} {4 four 1 one nosort}\ndo_test where-12.10 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a DESC, b DESC;\n  }\n} {4 four 1 one nosort}\ndo_test where-12.11 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a DESC, b ASC;\n  }\n} {4 four 1 one nosort}\ndo_test where-12.12 {\n  cksort {\n    SELECT * FROM t6 ORDER BY a ASC, b DESC;\n  }\n} {1 one 4 four nosort}\ndo_test where-13.1 {\n  execsql {\n    CREATE TABLE t7(a INTEGER PRIMARY KEY, b TEXT);\n    INSERT INTO t7 VALUES(1,'one');\n    INSERT INTO t7 VALUES(4,'four');\n    CREATE INDEX t7i1 ON t7(b);\n  }\n  cksort {\n    SELECT * FROM t7 ORDER BY b;\n  }\n} {4 four 1 one nosort}\ndo_test where-13.2 {\n  cksort {\n    SELECT * FROM t7 ORDER BY b, a;\n  }\n} {4 four 1 one nosort}\ndo_test where-13.3 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a;\n  }\n} {1 one 4 four nosort}\ndo_test where-13.4 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a, b;\n  }\n} {1 one 4 four nosort}\ndo_test where-13.5 {\n  cksort {\n    SELECT * FROM t7 ORDER BY b DESC;\n  }\n} {1 one 4 four nosort}\ndo_test where-13.6 {\n  cksort {\n    SELECT * FROM t7 ORDER BY b DESC, a DESC;\n  }\n} {1 one 4 four nosort}\ndo_test where-13.7 {\n  cksort {\n    SELECT * FROM t7 ORDER BY b DESC, a ASC;\n  }\n} {1 one 4 four sort}\ndo_test where-13.8 {\n  cksort {\n    SELECT * FROM t7 ORDER BY b ASC, a DESC;\n  }\n} {4 four 1 one sort}\ndo_test where-13.9 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a DESC;\n  }\n} {4 four 1 one nosort}\ndo_test where-13.10 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a DESC, b DESC;\n  }\n} {4 four 1 one nosort}\ndo_test where-13.11 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a DESC, b ASC;\n  }\n} {4 four 1 one nosort}\ndo_test where-13.12 {\n  cksort {\n    SELECT * FROM t7 ORDER BY a ASC, b DESC;\n  }\n} {1 one 4 four nosort}\n\n# Ticket #2211.\n#\n# When optimizing out ORDER BY clauses, make sure that trailing terms\n# of the ORDER BY clause do not reference other tables in a join.\n#\nif {[permutation] != \"no_optimization\"} {\ndo_test where-14.1 {\n  execsql {\n    CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE, c CHAR(100));\n    INSERT INTO t8(a,b) VALUES(1,'one');\n    INSERT INTO t8(a,b) VALUES(4,'four');\n  }\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b\n  } \n} {1/4 1/1 4/4 4/1 nosort}\ndo_test where-14.2 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b DESC\n  } \n} {1/1 1/4 4/1 4/4 nosort}\ndo_test where-14.3 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b\n  } \n} {1/4 1/1 4/4 4/1 nosort}\ndo_test where-14.4 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b DESC\n  } \n} {1/4 1/1 4/4 4/1 nosort}\ndo_test where-14.5 {\n  # This test case changed from \"nosort\" to \"sort\". See ticket 2a5629202f.\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b\n  } \n} {/4/[14] 4/[14] 1/[14] 1/[14] sort/}\ndo_test where-14.6 {\n  # This test case changed from \"nosort\" to \"sort\". See ticket 2a5629202f.\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b DESC\n  } \n} {/4/[14] 4/[14] 1/[14] 1/[14] sort/}\ndo_test where-14.7 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b\n  } \n} {4/1 4/4 1/1 1/4 sort}\ndo_test where-14.7.1 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, y.a||y.b\n  } \n} {4/1 4/4 1/1 1/4 sort}\ndo_test where-14.7.2 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, x.a||x.b\n  } \n} {4/4 4/1 1/4 1/1 nosort}\ndo_test where-14.8 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b DESC\n  } \n} {4/4 4/1 1/4 1/1 sort}\ndo_test where-14.9 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b\n  } \n} {4/4 4/1 1/4 1/1 sort}\ndo_test where-14.10 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b DESC\n  } \n} {4/1 4/4 1/1 1/4 sort}\ndo_test where-14.11 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b\n  } \n} {4/1 4/4 1/1 1/4 sort}\ndo_test where-14.12 {\n  cksort {\n    SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b DESC\n  } \n} {4/4 4/1 1/4 1/1 sort}\n} ;# {permutation != \"no_optimization\"}\n\n# Ticket #2445.\n#\n# There was a crash that could occur when a where clause contains an\n# alias for an expression in the result set, and that expression retrieves\n# a column of the second or subsequent table in a join.\n#\ndo_test where-15.1 {\n  execsql {\n    CREATE TEMP TABLE t1 (a, b, c, d, e);\n    CREATE TEMP TABLE t2 (f);\n    SELECT t1.e AS alias FROM t2, t1 WHERE alias = 1 ;\n  }\n} {}\n\n# Ticket #3408.\n# \n# The branch of code in where.c that generated rowid lookups was\n# incorrectly deallocating a constant register, meaning that if the \n# vdbe code ran more than once, the second time around the constant\n# value may have been clobbered by some other value.\n# \ndo_test where-16.1 {\n  execsql {\n    CREATE TABLE a1(id INTEGER PRIMARY KEY, v);\n    CREATE TABLE a2(id INTEGER PRIMARY KEY, v);\n    INSERT INTO a1 VALUES(1, 'one');\n    INSERT INTO a1 VALUES(2, 'two');\n    INSERT INTO a2 VALUES(1, 'one');\n    INSERT INTO a2 VALUES(2, 'two');\n  }\n} {}\ndo_test where-16.2 {\n  execsql {\n    SELECT * FROM a2 CROSS JOIN a1 WHERE a1.id=1 AND a1.v='one';\n  }\n} {1 one 1 one 2 two 1 one}\n\n# The actual problem reported in #3408.\ndo_test where-16.3 {\n  execsql {\n    CREATE TEMP TABLE foo(idx INTEGER);\n    INSERT INTO foo VALUES(1);\n    INSERT INTO foo VALUES(1);\n    INSERT INTO foo VALUES(1);\n    INSERT INTO foo VALUES(2);\n    INSERT INTO foo VALUES(2);\n    CREATE TEMP TABLE bar(stuff INTEGER);\n    INSERT INTO bar VALUES(100);\n    INSERT INTO bar VALUES(200);\n    INSERT INTO bar VALUES(300);\n  }\n} {}\ndo_test where-16.4 {\n  execsql {\n    SELECT bar.RowID id FROM foo, bar WHERE foo.idx = bar.RowID AND id = 2;\n  }\n} {2 2}\n\nintegrity_check {where-99.0}\n\n#---------------------------------------------------------------------\n# These tests test that a bug surrounding the use of ForceInt has been\n# fixed in where.c.\n#\ndo_test where-17.1 {\n  execsql {\n    CREATE TABLE tbooking (\n      id INTEGER PRIMARY KEY,\n      eventtype INTEGER NOT NULL\n    );\n    INSERT INTO tbooking VALUES(42, 3);\n    INSERT INTO tbooking VALUES(43, 4);\n  }\n} {}\ndo_test where-17.2 {\n  execsql {\n    SELECT a.id\n    FROM tbooking AS a\n    WHERE a.eventtype=3;\n  }\n} {42}\ndo_test where-17.3 {\n  execsql {\n    SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)\n    FROM tbooking AS a\n    WHERE a.eventtype=3;\n  }\n} {42 43}\ndo_test where-17.4 {\n  execsql {\n    SELECT a.id, (SELECT b.id FROM tbooking AS b WHERE b.id>a.id)\n    FROM (SELECT 1.5 AS id) AS a\n  }\n} {1.5 42}\ndo_test where-17.5 {\n  execsql {\n    CREATE TABLE tother(a, b);\n    INSERT INTO tother VALUES(1, 3.7);\n    SELECT id, a FROM tbooking, tother WHERE id>a;\n  }\n} {42 1 43 1}\n\n# Ticket [be84e357c035d068135f20bcfe82761bbf95006b]  2013-09-03\n# Segfault during query involving LEFT JOIN column in the ORDER BY clause.\n#\ndo_execsql_test where-18.1 {\n  CREATE TABLE t181(a);\n  CREATE TABLE t182(b,c);\n  INSERT INTO t181 VALUES(1);\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL;\n} {1}\ndo_execsql_test where-18.2 {\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c;\n} {1}\ndo_execsql_test where-18.3 {\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c;\n} {1}\ndo_execsql_test where-18.4 {\n  INSERT INTO t181 VALUES(1),(1),(1),(1);\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c;\n} {1}\ndo_execsql_test where-18.5 {\n  INSERT INTO t181 VALUES(2);\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL, +a;\n} {1 2}\ndo_execsql_test where-18.6 {\n  INSERT INTO t181 VALUES(2);\n  SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +a, +c IS NULL;\n} {1 2}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where2.test",
    "content": "# 2005 July 28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the use of indices in WHERE clauses\n# based on recent changes to the optimizer.\n#\n# $Id: where2.test,v 1.15 2009/02/02 01:50:40 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test where2-1.0 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t1(w int, x int, y int, z int);\n  }\n  for {set i 1} {$i<=100} {incr i} {\n    set w $i\n    set x [expr {int(log($i)/log(2))}]\n    set y [expr {$i*$i + 2*$i + 1}]\n    set z [expr {$x+$y}]\n    ifcapable tclvar {\n      execsql {INSERT INTO t1 VALUES($::w,$::x,$::y,$::z)}\n    } else {\n      execsql {INSERT INTO t1 VALUES(:w,:x,:y,:z)}\n    }\n  }\n  execsql {\n    CREATE UNIQUE INDEX i1w ON t1(w);\n    CREATE INDEX i1xy ON t1(x,y);\n    CREATE INDEX i1zyx ON t1(z,y,x);\n    COMMIT;\n  }\n} {}\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# This procedure executes the SQL.  Then it checks to see if the OP_Sort\n# opcode was executed.  If an OP_Sort did occur, then \"sort\" is appended\n# to the result.  If no OP_Sort happened, then \"nosort\" is appended.\n#\n# This procedure is used to check to make sure sorting is or is not\n# occurring as expected.\n#\nproc cksort {sql} {\n  set data [execsql $sql]\n  if {[db status sort]} {set x sort} {set x nosort}\n  lappend data $x\n  return $data\n}\n\n# This procedure executes the SQL.  Then it appends to the result the\n# \"sort\" or \"nosort\" keyword (as in the cksort procedure above) then\n# it appends the name of the table and index used.\n#\nproc queryplan {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  if {$::sqlite_sort_count} {set x sort} {set x nosort}\n  lappend data $x\n  set eqp [execsql \"EXPLAIN QUERY PLAN $sql\"]\n  # puts eqp=$eqp\n  foreach {a b c x} $eqp {\n    if {[regexp { TABLE (\\w+ AS )?(\\w+) USING.* INDEX (\\w+)\\y} \\\n        $x all as tab idx]} {\n      lappend data $tab $idx\n    } elseif {[regexp { TABLE (\\w+ AS )?(\\w+)\\y} $x all as tab]} {\n      lappend data $tab *\n    }\n  }\n  return $data   \n}\n\n\n# Prefer a UNIQUE index over another index.\n#\ndo_test where2-1.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=85 AND x=6 AND y=7396\n  }\n} {85 6 7396 7402 nosort t1 i1w}\n\n# Always prefer a rowid== constraint over any other index.\n#\ndo_test where2-1.3 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=85 AND x=6 AND y=7396 AND rowid=85\n  }\n} {85 6 7396 7402 nosort t1 *}\n\n# When constrained by a UNIQUE index, the ORDER BY clause is always ignored.\n#\ndo_test where2-2.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=85 ORDER BY random();\n  }\n} {85 6 7396 7402 nosort t1 i1w}\ndo_test where2-2.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE x=6 AND y=7396 ORDER BY random();\n  }\n} {85 6 7396 7402 sort t1 i1xy}\ndo_test where2-2.3 {\n  queryplan {\n    SELECT * FROM t1 WHERE rowid=85 AND x=6 AND y=7396 ORDER BY random();\n  }\n} {85 6 7396 7402 nosort t1 *}\n\n# Ticket [65bdeb9739605cc22966f49208452996ff29a640] 2014-02-26\n# Make sure \"ORDER BY random\" does not gets optimized out.\n#\ndo_test where2-2.4 {\n  db eval {\n    CREATE TABLE x1(a INTEGER PRIMARY KEY, b DEFAULT 1);\n    WITH RECURSIVE\n       cnt(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM cnt WHERE x<50)\n    INSERT INTO x1 SELECT x, 1 FROM cnt;\n    CREATE TABLE x2(x INTEGER PRIMARY KEY);\n    INSERT INTO x2 VALUES(1);\n  }\n  set sql {SELECT * FROM x1, x2 WHERE x=1 ORDER BY random()}\n  set out1 [db eval $sql]\n  set out2 [db eval $sql]\n  set out3 [db eval $sql]\n  expr {$out1!=$out2 && $out2!=$out3}\n} {1}\ndo_execsql_test where2-2.5 {\n  -- random() is not optimized out\n  EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY random();\n} {/ random/}\ndo_execsql_test where2-2.5b {\n  -- random() is not optimized out\n  EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY random();\n} {/ SorterOpen /}\ndo_execsql_test where2-2.6 {\n  -- other constant functions are optimized out\n  EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY abs(5);\n} {~/ abs/}\ndo_execsql_test where2-2.6b {\n  -- other constant functions are optimized out\n  EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY abs(5);\n} {~/ SorterOpen /}\n\n\n\n# Efficient handling of forward and reverse table scans.\n#\ndo_test where2-3.1 {\n  queryplan {\n    SELECT * FROM t1 ORDER BY rowid LIMIT 2\n  }\n} {1 0 4 4 2 1 9 10 nosort t1 *}\ndo_test where2-3.2 {\n  queryplan {\n    SELECT * FROM t1 ORDER BY rowid DESC LIMIT 2\n  }\n} {100 6 10201 10207 99 6 10000 10006 nosort t1 *}\n\n# The IN operator can be used by indices at multiple layers\n#\nifcapable subquery {\n  do_test where2-4.1 {\n    queryplan {\n      SELECT * FROM t1 WHERE z IN (10207,10006) AND y IN (10000,10201)\n                       AND x>0 AND x<10\n      ORDER BY w\n    }\n  } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}\n  do_test where2-4.2 {\n    queryplan {\n      SELECT * FROM t1 WHERE z IN (10207,10006) AND y=10000\n                       AND x>0 AND x<10\n      ORDER BY w\n    }\n  } {99 6 10000 10006 sort t1 i1zyx}\n  do_test where2-4.3 {\n    queryplan {\n      SELECT * FROM t1 WHERE z=10006 AND y IN (10000,10201)\n                       AND x>0 AND x<10\n      ORDER BY w\n    }\n  } {99 6 10000 10006 sort t1 i1zyx}\n  ifcapable compound {\n    do_test where2-4.4 {\n      queryplan {\n        SELECT * FROM t1 WHERE z IN (SELECT 10207 UNION SELECT 10006)\n                         AND y IN (10000,10201)\n                         AND x>0 AND x<10\n        ORDER BY w\n      }\n    } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}\n    do_test where2-4.5 {\n      queryplan {\n        SELECT * FROM t1 WHERE z IN (SELECT 10207 UNION SELECT 10006)\n                         AND y IN (SELECT 10000 UNION SELECT 10201)\n                         AND x>0 AND x<10\n        ORDER BY w\n      }\n    } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}\n  }\n  do_test where2-4.6a {\n    queryplan {\n      SELECT * FROM t1\n       WHERE x IN (1,2,3,4,5,6,7,8)\n         AND y IN (10000,10001,10002,10003,10004,10005)\n       ORDER BY x\n    }\n  } {99 6 10000 10006 nosort t1 i1xy}\n  do_test where2-4.6b {\n    queryplan {\n      SELECT * FROM t1\n       WHERE x IN (1,2,3,4,5,6,7,8)\n         AND y IN (10000,10001,10002,10003,10004,10005)\n       ORDER BY x DESC\n    }\n  } {99 6 10000 10006 nosort t1 i1xy}\n  do_test where2-4.6c {\n    queryplan {\n      SELECT * FROM t1\n       WHERE x IN (1,2,3,4,5,6,7,8)\n         AND y IN (10000,10001,10002,10003,10004,10005)\n       ORDER BY x, y\n    }\n  } {99 6 10000 10006 nosort t1 i1xy}\n  do_test where2-4.6d {\n    queryplan {\n      SELECT * FROM t1\n       WHERE x IN (1,2,3,4,5,6,7,8)\n         AND y IN (10000,10001,10002,10003,10004,10005)\n       ORDER BY x, y DESC\n    }\n  } {99 6 10000 10006 sort t1 i1xy}\n\n  # Duplicate entires on the RHS of an IN operator do not cause duplicate\n  # output rows.\n  #\n  do_test where2-4.6x {\n    queryplan {\n      SELECT * FROM t1 WHERE z IN (10207,10006,10006,10207)\n      ORDER BY w\n    }\n  } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}\n  do_test where2-4.6y {\n    queryplan {\n      SELECT * FROM t1 WHERE z IN (10207,10006,10006,10207)\n      ORDER BY w DESC\n    }\n  } {100 6 10201 10207 99 6 10000 10006 sort t1 i1zyx}\n  ifcapable compound {\n    do_test where2-4.7 {\n      queryplan {\n        SELECT * FROM t1 WHERE z IN (\n           SELECT 10207 UNION ALL SELECT 10006\n           UNION ALL SELECT 10006 UNION ALL SELECT 10207)\n        ORDER BY w\n      }\n    } {99 6 10000 10006 100 6 10201 10207 sort t1 i1zyx}\n  }\n\n} ;# ifcapable subquery\n\n# The use of an IN operator disables the index as a sorter.\n#\ndo_test where2-5.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=99 ORDER BY w\n  }\n} {99 6 10000 10006 nosort t1 i1w}\n\nifcapable subquery {\n  do_test where2-5.2a {\n    queryplan {\n      SELECT * FROM t1 WHERE w IN (99) ORDER BY w\n    }\n  } {99 6 10000 10006 nosort t1 i1w}\n  do_test where2-5.2b {\n    queryplan {\n      SELECT * FROM t1 WHERE w IN (99) ORDER BY w DESC\n    }\n  } {99 6 10000 10006 nosort t1 i1w}\n}\n\n# Verify that OR clauses get translated into IN operators.\n#\nset ::idx {}\nifcapable subquery {set ::idx i1w}\ndo_test where2-6.1.1 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=99 OR w=100 ORDER BY +w\n  }\n} [list 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]\ndo_test where2-6.1.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE 99=w OR 100=w ORDER BY +w\n  }\n} [list 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]\ndo_test where2-6.2 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=99 OR w=100 OR 6=w ORDER BY +w\n  }\n} [list 6 2 49 51 99 6 10000 10006 100 6 10201 10207 sort t1 $::idx]\n\ndo_test where2-6.3 {\n  queryplan {\n    SELECT * FROM t1 WHERE w=99 OR w=100 OR 6=+w ORDER BY +w\n  }\n} {6 2 49 51 99 6 10000 10006 100 6 10201 10207 sort t1 *}\ndo_test where2-6.4 {\n  queryplan {\n    SELECT *, '|' FROM t1 WHERE w=99 OR +w=100 OR 6=w ORDER BY +w\n  }\n} {6 2 49 51 | 99 6 10000 10006 | 100 6 10201 10207 | sort t1 *}\ndo_test where2-6.5 {\n  queryplan {\n    SELECT *, '|' FROM t1 WHERE w=99 OR y=10201 OR 6=w ORDER BY +w\n  }\n} {6 2 49 51 | 99 6 10000 10006 | 100 6 10201 10207 | sort t1 *}\n\nset ::idx {}\nifcapable subquery {set ::idx i1zyx}\ndo_test where2-6.5 {\n  queryplan {\n    SELECT b.* FROM t1 a, t1 b\n     WHERE a.w=1 AND (a.y=b.z OR b.z=10)\n     ORDER BY +b.w\n  }\n} [list 1 0 4 4 2 1 9 10 sort a i1w b $::idx]\ndo_test where2-6.6 {\n  queryplan {\n    SELECT b.* FROM t1 a, t1 b\n     WHERE a.w=1 AND (b.z=10 OR a.y=b.z OR b.z=10)\n     ORDER BY +b.w\n  }\n} [list 1 0 4 4 2 1 9 10 sort a i1w b $::idx]\n\nif {[permutation] != \"no_optimization\"} {\n\n# Ticket #2249.  Make sure the OR optimization is not attempted if\n# comparisons between columns of different affinities are needed.\n#\ndo_test where2-6.7 {\n  execsql {\n    CREATE TABLE t2249a(a TEXT UNIQUE, x CHAR(100));\n    CREATE TABLE t2249b(b INTEGER);\n    INSERT INTO t2249a(a) VALUES('0123');\n    INSERT INTO t2249b VALUES(123);\n  }\n  queryplan {\n    -- Because a is type TEXT and b is type INTEGER, both a and b\n    -- will attempt to convert to NUMERIC before the comparison.\n    -- They will thus compare equal.\n    --\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=b;\n  }\n} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.9 {\n  queryplan {\n    -- The + operator removes affinity from the rhs.  No conversions\n    -- occur and the comparison is false.  The result is an empty set.\n    --\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b;\n  }\n} {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.9.2 {\n  # The same thing but with the expression flipped around.\n  queryplan {\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a\n  }\n} {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.10 {\n  queryplan {\n    -- Use + on both sides of the comparison to disable indices\n    -- completely.  Make sure we get the same result.\n    --\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +a=+b;\n  }\n} {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.11 {\n  # This will not attempt the OR optimization because of the a=b\n  # comparison.\n  queryplan {\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=b OR a='hello';\n  }\n} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.11.2 {\n  # Permutations of the expression terms.\n  queryplan {\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE b=a OR a='hello';\n  }\n} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.11.3 {\n  # Permutations of the expression terms.\n  queryplan {\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE 'hello'=a OR b=a;\n  }\n} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\ndo_test where2-6.11.4 {\n  # Permutations of the expression terms.\n  queryplan {\n    SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR b=a;\n  }\n} {123 0123 nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\nifcapable explain&&subquery {\n  # These tests are not run if subquery support is not included in the\n  # build. This is because these tests test the \"a = 1 OR a = 2\" to\n  # \"a IN (1, 2)\" optimisation transformation, which is not enabled if\n  # subqueries and the IN operator is not available.\n  #\n  do_test where2-6.12 {\n    # In this case, the +b disables the affinity conflict and allows\n    # the OR optimization to be used again.  The result is now an empty\n    # set, the same as in where2-6.9.\n    queryplan {\n      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR a='hello';\n    }\n  } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\n  do_test where2-6.12.2 {\n    # In this case, the +b disables the affinity conflict and allows\n    # the OR optimization to be used again.  The result is now an empty\n    # set, the same as in where2-6.9.\n    queryplan {\n      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a='hello' OR +b=a;\n    }\n  } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\n  do_test where2-6.12.3 {\n    # In this case, the +b disables the affinity conflict and allows\n    # the OR optimization to be used again.  The result is now an empty\n    # set, the same as in where2-6.9.\n    queryplan {\n      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE +b=a OR a='hello';\n    }\n  } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\n  do_test where2-6.13 {\n    # The addition of +a on the second term disabled the OR optimization.\n    # But we should still get the same empty-set result as in where2-6.9.\n    queryplan {\n      SELECT b,a FROM t2249b CROSS JOIN t2249a WHERE a=+b OR +a='hello';\n    }\n  } {nosort t2249b * t2249a sqlite_autoindex_t2249a_1}\n}\n\n# Variations on the order of terms in a WHERE clause in order\n# to make sure the OR optimizer can recognize them all.\ndo_test where2-6.20 {\n  queryplan {\n    SELECT x.a, y.a FROM t2249a x CROSS JOIN t2249a y WHERE x.a=y.a\n  }\n} {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}\nifcapable explain&&subquery {\n  # These tests are not run if subquery support is not included in the\n  # build. This is because these tests test the \"a = 1 OR a = 2\" to\n  # \"a IN (1, 2)\" optimisation transformation, which is not enabled if\n  # subqueries and the IN operator is not available.\n  #\n  do_test where2-6.21 {\n    queryplan {\n      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y\n       WHERE x.a=y.a OR y.a='hello'\n    }\n  } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}\n  do_test where2-6.22 {\n    queryplan {\n      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y\n       WHERE y.a=x.a OR y.a='hello'\n    }\n  } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}\n  do_test where2-6.23 {\n    queryplan {\n      SELECT x.a,y.a FROM t2249a x CROSS JOIN t2249a y\n       WHERE y.a='hello' OR x.a=y.a\n    }\n  } {0123 0123 nosort x sqlite_autoindex_t2249a_1 y sqlite_autoindex_t2249a_1}\n}\n\n# Unique queries (queries that are guaranteed to return only a single\n# row of result) do not call the sorter.  But all tables must give\n# a unique result.  If any one table in the join does not give a unique\n# result then sorting is necessary.\n#\ndo_test where2-7.1 {\n  cksort {\n    create table t8(a unique, b, c);\n    insert into t8 values(1,2,3);\n    insert into t8 values(2,3,4);\n    create table t9(x,y);\n    insert into t9 values(2,4);\n    insert into t9 values(2,3);\n    select y from t8, t9 where a=1 order by a, y;\n  }\n} {3 4 sort}\ndo_test where2-7.2 {\n  cksort {\n    select * from t8 where a=1 order by b, c\n  }\n} {1 2 3 nosort}\ndo_test where2-7.3 {\n  cksort {\n    select * from t8, t9 where a=1 and y=3 order by b, x\n  }\n} {1 2 3 2 3 sort}\ndo_test where2-7.4 {\n  cksort {\n    create unique index i9y on t9(y);\n    select * from t8, t9 where a=1 and y=3 order by b, x\n  }\n} {1 2 3 2 3 nosort}\n\n} ;# if {[permutation] != \"no_optimization\"}\n\n# Ticket #1807.  Using IN constrains on multiple columns of\n# a multi-column index.\n#\nifcapable subquery {\n  do_test where2-8.1 {\n    execsql {\n      SELECT * FROM t1 WHERE x IN (20,21) AND y IN (1,2)\n    }\n  } {}\n  do_test where2-8.2 {\n    execsql {\n      SELECT * FROM t1 WHERE x IN (1,2) AND y IN (-5,-6)\n    }\n  } {}\n  execsql {CREATE TABLE tx AS SELECT * FROM t1}\n  do_test where2-8.3 {\n    execsql {\n      SELECT w FROM t1\n       WHERE x IN (SELECT x FROM tx WHERE rowid<0)\n         AND +y IN (SELECT y FROM tx WHERE rowid=1)\n    }\n  } {}\n  do_test where2-8.4 {\n    execsql {\n      SELECT w FROM t1\n       WHERE x IN (SELECT x FROM tx WHERE rowid=1)\n         AND y IN (SELECT y FROM tx WHERE rowid<0)\n    }\n  } {}\n  #set sqlite_where_trace 1\n  do_test where2-8.5 {\n    execsql {\n      CREATE INDEX tx_xyz ON tx(x, y, z, w);\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 12 AND 14)\n    }\n  } {12 13 14}\n  do_test where2-8.6 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 12 AND 14)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {12 13 14}\n  do_test where2-8.7 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 12 AND 14)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {10 11 12 13 14 15}\n  do_test where2-8.8 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {10 11 12 13 14 15 16 17 18 19 20}\n  do_test where2-8.9 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 2 AND 4)\n    }\n  } {}\n  do_test where2-8.10 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 2 AND 4)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.11 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 2 AND 4)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.12 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN -4 AND -2)\n    }\n  } {}\n  do_test where2-8.13 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN -4 AND -2)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.14 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN -4 AND -2)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.15 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 200 AND 300)\n    }\n  } {}\n  do_test where2-8.16 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 200 AND 300)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.17 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE w BETWEEN 200 AND 300)\n         AND y IN (SELECT y FROM t1 WHERE w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.18 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 200 AND 300)\n    }\n  } {}\n  do_test where2-8.19 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 10 AND 20)\n         AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 200 AND 300)\n         AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 10 AND 20)\n    }\n  } {}\n  do_test where2-8.20 {\n    execsql {\n      SELECT w FROM tx\n       WHERE x IN (SELECT x FROM t1 WHERE +w BETWEEN 200 AND 300)\n         AND y IN (SELECT y FROM t1 WHERE +w BETWEEN 10 AND 20)\n         AND z IN (SELECT z FROM t1 WHERE +w BETWEEN 10 AND 20)\n    }\n  } {}\n}  \n\n# Make sure WHERE clauses of the form A=1 AND (B=2 OR B=3) are optimized\n# when we have an index on A and B.\n#\nifcapable or_opt&&tclvar {\n  do_test where2-9.1 {\n    execsql {\n      BEGIN;\n      CREATE TABLE t10(a,b,c);\n      INSERT INTO t10 VALUES(1,1,1);\n      INSERT INTO t10 VALUES(1,2,2);\n      INSERT INTO t10 VALUES(1,3,3);\n    }\n    for {set i 4} {$i<=1000} {incr i} {\n      execsql {INSERT INTO t10 VALUES(1,$i,$i)}\n    }\n    execsql {\n      CREATE INDEX i10 ON t10(a,b);\n      COMMIT;\n      SELECT count(*) FROM t10;\n    }\n  } 1000\n  ifcapable subquery {\n    do_test where2-9.2 {\n      count {\n        SELECT * FROM t10 WHERE a=1 AND (b=2 OR b=3)\n      }\n    } {1 2 2 1 3 3 7}\n  }\n}\n\n# Indices with redundant columns\n#\ndo_test where2-11.1 {\n  execsql {\n    CREATE TABLE t11(a,b,c,d);\n    CREATE INDEX i11aba ON t11(a,b,a,c); -- column A occurs twice.\n    INSERT INTO t11 VALUES(1,2,3,4);\n    INSERT INTO t11 VALUES(5,6,7,8);\n    INSERT INTO t11 VALUES(1,2,9,10);\n    INSERT INTO t11 VALUES(5,11,12,13);\n    SELECT c FROM t11 WHERE a=1 AND b=2 ORDER BY c;\n  }\n} {3 9}\ndo_test where2-11.2 {\n  execsql {\n    CREATE INDEX i11cccccccc ON t11(c,c,c,c,c,c,c,c); -- repeated column\n    SELECT d FROM t11 WHERE c=9;\n  }\n} {10}\ndo_test where2-11.3 {\n  execsql {\n    SELECT d FROM t11 WHERE c IN (1,2,3,4,5);\n  }\n} {4}\ndo_test where2-11.4 {\n  execsql {\n    SELECT d FROM t11 WHERE c=7 OR (a=1 AND b=2) ORDER BY d;\n  }\n} {4 8 10}\n\n# Verify that the OR clause is used in an outer loop even when\n# the OR clause scores slightly better on an inner loop.\nif {[permutation] != \"no_optimization\"} {\ndo_execsql_test where2-12.1 {\n  CREATE TABLE t12(x INTEGER PRIMARY KEY, y INT, z CHAR(100));\n  CREATE INDEX t12y ON t12(y);\n  EXPLAIN QUERY PLAN\n    SELECT a.x, b.x\n      FROM t12 AS a JOIN t12 AS b ON a.y=b.x\n     WHERE (b.x=$abc OR b.y=$abc);\n} {/.*SEARCH TABLE t12 AS b .*SEARCH TABLE t12 AS b .*/}\n}\n\n# Verify that all necessary OP_OpenRead opcodes occur in the OR optimization.\n#\ndo_execsql_test where2-13.1 {\n  CREATE TABLE t13(a,b);\n  CREATE INDEX t13a ON t13(a);\n  INSERT INTO t13 VALUES(4,5);\n  SELECT * FROM t13 WHERE (1=2 AND a=3) OR a=4;\n} {4 5}\n\n# https://www.sqlite.org/src/info/5e3c886796e5512e  (2016-03-09)\n# Correlated subquery on the RHS of an IN operator \n#\ndo_execsql_test where2-14.1 {\n  CREATE TABLE t14a(x INTEGER PRIMARY KEY);\n  INSERT INTO t14a(x) VALUES(1),(2),(3),(4);\n  CREATE TABLE t14b(y INTEGER PRIMARY KEY);\n  INSERT INTO t14b(y) VALUES(1);\n  SELECT x FROM t14a WHERE x NOT IN (SELECT x FROM t14b);\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where3.test",
    "content": "# 2006 January 31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the join reordering optimization\n# in cases that include a LEFT JOIN.\n#\n# $Id: where3.test,v 1.4 2008/04/17 19:14:02 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# The following is from ticket #1652.\n#\n# A comma join then a left outer join:  A,B left join C.\n# Arrange indices so that the B table is chosen to go first.\n# Also put an index on C, but make sure that A is chosen before C.\n#\ndo_test where3-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(p, q);\n    CREATE TABLE t3(x, y);\n    \n    INSERT INTO t1 VALUES(111,'one');\n    INSERT INTO t1 VALUES(222,'two');\n    INSERT INTO t1 VALUES(333,'three');\n    \n    INSERT INTO t2 VALUES(1,111);\n    INSERT INTO t2 VALUES(2,222);\n    INSERT INTO t2 VALUES(4,444);\n    CREATE INDEX t2i1 ON t2(p);\n    \n    INSERT INTO t3 VALUES(999,'nine');\n    CREATE INDEX t3i1 ON t3(x);\n    \n    SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x WHERE p=2 AND a=q;\n  }\n} {222 two 2 222 {} {}}\n\nifcapable explain&&!cursorhints {\n  do_test where3-1.1.1 {\n     explain_no_trace {SELECT * FROM t1, t2 LEFT JOIN t3 ON q=x\n                        WHERE p=2 AND a=q}\n  } [explain_no_trace {SELECT * FROM t1, t2 LEFT JOIN t3 ON x=q\n                        WHERE p=2 AND a=q}]\n}\n\n# Ticket #1830\n#\n# This is similar to the above but with the LEFT JOIN on the\n# other side.\n#\ndo_test where3-1.2 {\n  execsql {\n    CREATE TABLE parent1(parent1key, child1key, Child2key, child3key);\n    CREATE TABLE child1 ( child1key NVARCHAR, value NVARCHAR );\n    CREATE UNIQUE INDEX PKIDXChild1 ON child1 ( child1key );\n    CREATE TABLE child2 ( child2key NVARCHAR, value NVARCHAR );\n\n    INSERT INTO parent1(parent1key,child1key,child2key)\n       VALUES ( 1, 'C1.1', 'C2.1' );\n    INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.1', 'Value for C1.1' );\n    INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.1', 'Value for C2.1' );\n\n    INSERT INTO parent1 ( parent1key, child1key, child2key )\n       VALUES ( 2, 'C1.2', 'C2.2' );\n    INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.2', 'Value for C2.2' );\n\n    INSERT INTO parent1 ( parent1key, child1key, child2key )\n       VALUES ( 3, 'C1.3', 'C2.3' );\n    INSERT INTO child1 ( child1key, value ) VALUES ( 'C1.3', 'Value for C1.3' );\n    INSERT INTO child2 ( child2key, value ) VALUES ( 'C2.3', 'Value for C2.3' );\n\n    SELECT parent1.parent1key, child1.value, child2.value\n    FROM parent1\n    LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key\n    INNER JOIN child2 ON child2.child2key = parent1.child2key;\n  }\n} {1 {Value for C1.1} {Value for C2.1} 2 {} {Value for C2.2} 3 {Value for C1.3} {Value for C2.3}}\n\nifcapable explain&&!cursorhints {\n  do_test where3-1.2.1 {\n     explain_no_trace {\n       SELECT parent1.parent1key, child1.value, child2.value\n       FROM parent1\n       LEFT OUTER JOIN child1 ON child1.child1key = parent1.child1key\n       INNER JOIN child2 ON child2.child2key = parent1.child2key;\n     }\n  } [explain_no_trace {\n       SELECT parent1.parent1key, child1.value, child2.value\n       FROM parent1\n       LEFT OUTER JOIN child1 ON parent1.child1key = child1.child1key \n       INNER JOIN child2 ON child2.child2key = parent1.child2key;\n     }]\n}\n\n# This procedure executes the SQL.  Then it appends \n# the names of the table and index used\n#\nproc queryplan {sql} {\n  set ::sqlite_sort_count 0\n  set data [execsql $sql]\n  set eqp [execsql \"EXPLAIN QUERY PLAN $sql\"]\n  # puts eqp=$eqp\n  foreach {a b c x} $eqp {\n    if {[regexp { TABLE (\\w+ AS )?(\\w+) USING.* INDEX (\\w+)\\y} \\\n        $x all as tab idx]} {\n      lappend data $tab $idx\n    } elseif {[regexp { TABLE (\\w+ AS )?(\\w+)\\y} $x all as tab]} {\n      lappend data $tab *\n    }\n  }\n  return $data   \n}\n\n\n# If you have a from clause of the form:   A B C left join D\n# then make sure the query optimizer is able to reorder the \n# A B C part anyway it wants. \n#\n# Following the fix to ticket #1652, there was a time when\n# the C table would not reorder.  So the following reorderings\n# were possible:\n#\n#            A B C left join D\n#            B A C left join D\n#\n# But these reorders were not allowed\n#\n#            C A B left join D\n#            A C B left join D\n#            C B A left join D\n#            B C A left join D\n#\n# The following tests are here to verify that the latter four\n# reorderings are allowed again.\n#\ndo_test where3-2.1 {\n  execsql {\n    CREATE TABLE tA(apk integer primary key, ax);\n    CREATE TABLE tB(bpk integer primary key, bx);\n    CREATE TABLE tC(cpk integer primary key, cx);\n    CREATE TABLE tD(dpk integer primary key, dx);\n  }\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=bx AND bpk=ax\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.1.1 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk\n     WHERE cpk=bx AND bpk=ax\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.1.2 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk\n     WHERE bx=cpk AND bpk=ax\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.1.3 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON cx=dpk\n     WHERE bx=cpk AND ax=bpk\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.1.4 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE bx=cpk AND ax=bpk\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.1.5 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=bx AND ax=bpk\n  }\n} {tA * tB * tC * tD *}\ndo_test where3-2.2 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=bx AND apk=bx\n  }\n} {tB * tA * tC * tD *}\ndo_test where3-2.3 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=bx AND apk=bx\n  }\n} {tB * tA * tC * tD *}\ndo_test where3-2.4 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE apk=cx AND bpk=ax\n  }\n} {tC * tA * tB * tD *}\ndo_test where3-2.5 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=ax AND bpk=cx\n  }\n} {tA * tC * tB * tD *}\ndo_test where3-2.6 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE bpk=cx AND apk=bx\n  }\n} {tC * tB * tA * tD *}\ndo_test where3-2.7 {\n  queryplan {\n    SELECT * FROM tA, tB, tC LEFT JOIN tD ON dpk=cx\n     WHERE cpk=bx AND apk=cx\n  }\n} {tB * tC * tA * tD *}\n\n# Ticket [13f033c865f878953]\n# If the outer loop must be a full table scan, do not let ANALYZE trick\n# the planner into use a table for the outer loop that might be indexable\n# if held until an inner loop.\n# \ndo_execsql_test where3-3.0 {\n  CREATE TABLE t301(a INTEGER PRIMARY KEY,b,c);\n  CREATE INDEX t301c ON t301(c);\n  INSERT INTO t301 VALUES(1,2,3);\n  INSERT INTO t301 VALUES(2,2,3);\n  CREATE TABLE t302(x, y);\n  INSERT INTO t302 VALUES(4,5);\n  ANALYZE;\n  explain query plan SELECT * FROM t302, t301 WHERE t302.x=5 AND t301.a=t302.y;\n} {\n  0 0 0 {SCAN TABLE t302} \n  0 1 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?)}\n}\ndo_execsql_test where3-3.1 {\n  explain query plan\n  SELECT * FROM t301, t302 WHERE t302.x=5 AND t301.a=t302.y;\n} {\n  0 0 1 {SCAN TABLE t302} \n  0 1 0 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?)}\n}\ndo_execsql_test where3-3.2 {\n  SELECT * FROM t301 WHERE c=3 AND a IS NULL;\n} {}\ndo_execsql_test where3-3.3 {\n  SELECT * FROM t301 WHERE c=3 AND a IS NOT NULL;\n} {1 2 3 2 2 3}\n\nif 0 {  # Query planner no longer does this\n# Verify that when there are multiple tables in a join which must be\n# full table scans that the query planner attempts put the table with\n# the fewest number of output rows as the outer loop.\n#\ndo_execsql_test where3-4.0 {\n  CREATE TABLE t400(a INTEGER PRIMARY KEY, b, c);\n  CREATE TABLE t401(p INTEGER PRIMARY KEY, q, r);\n  CREATE TABLE t402(x INTEGER PRIMARY KEY, y, z);\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t400, t401, t402 WHERE t402.z GLOB 'abc*';\n} {\n  0 0 2 {SCAN TABLE t402} \n  0 1 0 {SCAN TABLE t400} \n  0 2 1 {SCAN TABLE t401}\n}\ndo_execsql_test where3-4.1 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t400, t401, t402 WHERE t401.r GLOB 'abc*';\n} {\n  0 0 1 {SCAN TABLE t401} \n  0 1 0 {SCAN TABLE t400} \n  0 2 2 {SCAN TABLE t402}\n}\ndo_execsql_test where3-4.2 {\n  EXPLAIN QUERY PLAN\n  SELECT * FROM t400, t401, t402 WHERE t400.c GLOB 'abc*';\n} {\n  0 0 0 {SCAN TABLE t400} \n  0 1 1 {SCAN TABLE t401} \n  0 2 2 {SCAN TABLE t402}\n}\n} ;# endif\n\n# Verify that a performance regression encountered by firefox\n# has been fixed.\n#\ndo_execsql_test where3-5.0 {\n  CREATE TABLE aaa (id INTEGER PRIMARY KEY, type INTEGER,\n                    fk INTEGER DEFAULT NULL, parent INTEGER,\n                    position INTEGER, title LONGVARCHAR,\n                    keyword_id INTEGER, folder_type TEXT,\n                    dateAdded INTEGER, lastModified INTEGER);\n  CREATE INDEX aaa_111 ON aaa (fk, type);\n  CREATE INDEX aaa_222 ON aaa (parent, position);\n  CREATE INDEX aaa_333 ON aaa (fk, lastModified);\n  CREATE TABLE bbb (id INTEGER PRIMARY KEY, type INTEGER,\n                    fk INTEGER DEFAULT NULL, parent INTEGER,\n                    position INTEGER, title LONGVARCHAR,\n                    keyword_id INTEGER, folder_type TEXT,\n                    dateAdded INTEGER, lastModified INTEGER);\n  CREATE INDEX bbb_111 ON bbb (fk, type);\n  CREATE INDEX bbb_222 ON bbb (parent, position);\n  CREATE INDEX bbb_333 ON bbb (fk, lastModified);\n\n  EXPLAIN QUERY PLAN\n   SELECT bbb.title AS tag_title \n     FROM aaa JOIN bbb ON bbb.id = aaa.parent  \n    WHERE aaa.fk = 'constant'\n      AND LENGTH(bbb.title) > 0\n      AND bbb.parent = 4\n    ORDER BY bbb.title COLLATE NOCASE ASC;\n} {\n  0 0 0 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?)} \n  0 1 1 {SEARCH TABLE bbb USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndo_execsql_test where3-5.1 {\n  EXPLAIN QUERY PLAN\n   SELECT bbb.title AS tag_title \n     FROM aaa JOIN aaa AS bbb ON bbb.id = aaa.parent  \n    WHERE aaa.fk = 'constant'\n      AND LENGTH(bbb.title) > 0\n      AND bbb.parent = 4\n    ORDER BY bbb.title COLLATE NOCASE ASC;\n} {\n  0 0 0 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?)} \n  0 1 1 {SEARCH TABLE aaa AS bbb USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndo_execsql_test where3-5.2 {\n  EXPLAIN QUERY PLAN\n   SELECT bbb.title AS tag_title \n     FROM bbb JOIN aaa ON bbb.id = aaa.parent  \n    WHERE aaa.fk = 'constant'\n      AND LENGTH(bbb.title) > 0\n      AND bbb.parent = 4\n    ORDER BY bbb.title COLLATE NOCASE ASC;\n} {\n  0 0 1 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?)} \n  0 1 0 {SEARCH TABLE bbb USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\ndo_execsql_test where3-5.3 {\n  EXPLAIN QUERY PLAN\n   SELECT bbb.title AS tag_title \n     FROM aaa AS bbb JOIN aaa ON bbb.id = aaa.parent  \n    WHERE aaa.fk = 'constant'\n      AND LENGTH(bbb.title) > 0\n      AND bbb.parent = 4\n    ORDER BY bbb.title COLLATE NOCASE ASC;\n} {\n  0 0 1 {SEARCH TABLE aaa USING INDEX aaa_333 (fk=?)} \n  0 1 0 {SEARCH TABLE aaa AS bbb USING INTEGER PRIMARY KEY (rowid=?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\n# Name resolution with NATURAL JOIN and USING\n#\ndo_test where3-6.setup {\n  db eval {\n    CREATE TABLE t6w(a, w);\n    INSERT INTO t6w VALUES(1, 'w-one');\n    INSERT INTO t6w VALUES(2, 'w-two');\n    INSERT INTO t6w VALUES(9, 'w-nine');\n    CREATE TABLE t6x(a, x);\n    INSERT INTO t6x VALUES(1, 'x-one');\n    INSERT INTO t6x VALUES(3, 'x-three');\n    INSERT INTO t6x VALUES(9, 'x-nine');\n    CREATE TABLE t6y(a, y);\n    INSERT INTO t6y VALUES(1, 'y-one');\n    INSERT INTO t6y VALUES(4, 'y-four');\n    INSERT INTO t6y VALUES(9, 'y-nine');\n    CREATE TABLE t6z(a, z);\n    INSERT INTO t6z VALUES(1, 'z-one');\n    INSERT INTO t6z VALUES(5, 'z-five');\n    INSERT INTO t6z VALUES(9, 'z-nine');\n  }\n} {}\nset cnt 0\nforeach predicate {\n   {}\n   {ORDER BY a}\n   {ORDER BY t6w.a}\n   {WHERE a>0}\n   {WHERE t6y.a>0}\n   {WHERE a>0 ORDER BY a}\n} {\n  incr cnt\n  do_test where3-6.$cnt.1 {\n    set sql \"SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y\"\n    append sql \" NATURAL JOIN t6z \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.2 {\n    set sql \"SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)\"\n    append sql \" JOIN t6z USING(a) \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.3 {\n    set sql \"SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)\"\n    append sql \" JOIN t6z USING(a) \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.4 {\n    set sql \"SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y\"\n    append sql \" JOIN t6z USING(a) \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.5 {\n    set sql \"SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)\"\n    append sql \" NATURAL JOIN t6z \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.6 {\n    set sql \"SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y\"\n    append sql \" NATURAL JOIN t6z \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.7 {\n    set sql \"SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)\"\n    append sql \" NATURAL JOIN t6z \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n  do_test where3-6.$cnt.8 {\n    set sql \"SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y\"\n    append sql \" JOIN t6z USING(a) \"\n    append sql $::predicate\n    db eval $sql\n  } {1 w-one x-one y-one z-one 9 w-nine x-nine y-nine z-nine}\n}\n\ndo_execsql_test where3-7-setup {\n  CREATE TABLE t71(x1 INTEGER PRIMARY KEY, y1);\n  CREATE TABLE t72(x2 INTEGER PRIMARY KEY, y2);\n  CREATE TABLE t73(x3, y3);\n  CREATE TABLE t74(x4, y4);\n  INSERT INTO t71 VALUES(123,234);\n  INSERT INTO t72 VALUES(234,345);\n  INSERT INTO t73 VALUES(123,234);\n  INSERT INTO t74 VALUES(234,345);\n  INSERT INTO t74 VALUES(234,678);\n} {}\nforeach disabled_opt {none omit-noop-join all} {\n  optimization_control db all 1\n  optimization_control db $disabled_opt 0\n  do_execsql_test where3-7.$disabled_opt.1 {\n    SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.2 {\n    SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 WHERE y2 IS NULL;\n  } {}\n  do_execsql_test where3-7.$disabled_opt.3 {\n    SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 WHERE y2 IS NOT NULL;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.4 {\n    SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 AND y2 IS NULL;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.5 {\n    SELECT x1 FROM t71 LEFT JOIN t72 ON x2=y1 AND y2 IS NOT NULL;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.6 {\n    SELECT x3 FROM t73 LEFT JOIN t72 ON x2=y3;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.7 {\n    SELECT DISTINCT x3 FROM t73 LEFT JOIN t72 ON x2=y3;\n  } {123}\n  do_execsql_test where3-7.$disabled_opt.8 {\n    SELECT x3 FROM t73 LEFT JOIN t74 ON x4=y3;\n  } {123 123}\n  do_execsql_test where3-7.$disabled_opt.9 {\n    SELECT DISTINCT x3 FROM t73 LEFT JOIN t74 ON x4=y3;\n  } {123}\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where4.test",
    "content": "# 2006 October 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the use of indices in WHERE clauses.\n# This file was created when support for optimizing IS NULL phrases\n# was added.  And so the principle purpose of this file is to test\n# that IS NULL phrases are correctly optimized.  But you can never\n# have too many tests, so some other tests are thrown in as well.\n#\n# $Id: where4.test,v 1.6 2007/12/10 05:03:48 danielk1977 Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix where4\n\nifcapable !tclvar||!bloblit {\n  finish_test\n  return\n}\n\n# Build some test data\n#\ndo_test where4-1.0 {\n  execsql {\n    CREATE TABLE t1(w, x, y);\n    CREATE INDEX i1wxy ON t1(w,x,y);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 VALUES(1,NULL,3);\n    INSERT INTO t1 VALUES('a','b','c');\n    INSERT INTO t1 VALUES('a',NULL,'c');\n    INSERT INTO t1 VALUES(X'78',x'79',x'7a');\n    INSERT INTO t1 VALUES(X'78',NULL,X'7A');\n    INSERT INTO t1 VALUES(NULL,NULL,NULL);\n    SELECT count(*) FROM t1;\n  }\n} {7}\n\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_search_count 0\n  return [concat [execsql $sql] $::sqlite_search_count]\n}\n\n# Verify that queries use an index.  We are using the special variable\n# \"sqlite_search_count\" which tallys the number of executions of MoveTo\n# and Next operators in the VDBE.  By verifing that the search count is\n# small we can be assured that indices are being used properly.\n#\ndo_test where4-1.1 {\n  count {SELECT rowid FROM t1 WHERE w IS NULL}\n} {7 2}\ndo_test where4-1.1b {\n  unset -nocomplain null\n  count {SELECT rowid FROM t1 WHERE w IS $null}\n} {7 2}\ndo_test where4-1.2 {\n  count {SELECT rowid FROM t1 WHERE +w IS NULL}\n} {7 6}\ndo_test where4-1.3 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL}\n} {2 2}\ndo_test where4-1.4 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND +x IS NULL}\n} {2 3}\ndo_test where4-1.5 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND x>0}\n} {1 2}\ndo_test where4-1.6 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND x<9}\n} {1 2}\ndo_test where4-1.7 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL AND y=3}\n} {2 2}\ndo_test where4-1.8 {\n  count {SELECT rowid FROM t1 WHERE w=1 AND x IS NULL AND y>2}\n} {2 2}\ndo_test where4-1.9 {\n  count {SELECT rowid FROM t1 WHERE w='a' AND x IS NULL AND y='c'}\n} {4 2}\ndo_test where4-1.10 {\n  count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL}\n} {6 2}\ndo_test where4-1.11 {\n  count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL AND y=123}\n} {0}\ndo_test where4-1.12 {\n  count {SELECT rowid FROM t1 WHERE w=x'78' AND x IS NULL AND y=x'7A'}\n} {6 2}\ndo_test where4-1.13 {\n  count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL}\n} {7 2}\ndo_test where4-1.14 {\n  count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y IS NULL}\n} {7 2}\ndo_test where4-1.15 {\n  count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y<0}\n} {1}\ndo_test where4-1.16 {\n  count {SELECT rowid FROM t1 WHERE w IS NULL AND x IS NULL AND y>=0}\n} {1}\n\ndo_test where4-2.1 {\n  execsql {SELECT rowid FROM t1 ORDER BY w, x, y}\n} {7 2 1 4 3 6 5}\ndo_test where4-2.2 {\n  execsql {SELECT rowid FROM t1 ORDER BY w DESC, x, y}\n} {6 5 4 3 2 1 7}\ndo_test where4-2.3 {\n  execsql {SELECT rowid FROM t1 ORDER BY w, x DESC, y}\n} {7 1 2 3 4 5 6}\n\n\n# Ticket #2177\n#\n# Suppose you have a left join where the right table of the left\n# join (the one that can be NULL) has an index on two columns.\n# The first indexed column is used in the ON clause of the join.\n# The second indexed column is used in the WHERE clause with an IS NULL\n# constraint.  It is not allowed to use the IS NULL optimization to\n# optimize the query because the second column might be NULL because\n# the right table did not match - something the index does not know\n# about.\n#\ndo_test where4-3.1 {\n  execsql {\n    CREATE TABLE t2(a);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    INSERT INTO t2 VALUES(3);\n    CREATE TABLE t3(x,y,UNIQUE(\"x\",'y' ASC)); -- Goofy syntax allowed\n    INSERT INTO t3 VALUES(1,11);\n    INSERT INTO t3 VALUES(2,NULL);\n \n    SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE +y IS NULL;\n  }\n} {2 2 {} 3 {} {}}\ndo_test where4-3.2 {\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE y IS NULL;\n  }\n} {2 2 {} 3 {} {}}\ndo_test where4-3.3 {\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE NULL is y;\n  }\n} {2 2 {} 3 {} {}}\ndo_test where4-3.4 {\n  unset -nocomplain null\n  execsql {\n    SELECT * FROM t2 LEFT JOIN t3 ON a=x WHERE y IS $null;\n  }\n} {2 2 {} 3 {} {}}\n\n# Ticket #2189.  Probably the same bug as #2177.\n#\ndo_test where4-4.1 {\n  execsql {\n    CREATE TABLE test(col1 TEXT PRIMARY KEY);\n    INSERT INTO test(col1) values('a');\n    INSERT INTO test(col1) values('b');\n    INSERT INTO test(col1) values('c');\n    CREATE TABLE test2(col1 TEXT PRIMARY KEY);\n    INSERT INTO test2(col1) values('a');\n    INSERT INTO test2(col1) values('b');\n    INSERT INTO test2(col1) values('c');\n    SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1\n      WHERE +t2.col1 IS NULL;\n  }\n} {}\ndo_test where4-4.2 {\n  execsql {\n    SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1\n      WHERE t2.col1 IS NULL;\n  }\n} {}\ndo_test where4-4.3 {\n  execsql {\n    SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1\n      WHERE +t1.col1 IS NULL;\n  }\n} {}\ndo_test where4-4.4 {\n  execsql {\n    SELECT * FROM test t1 LEFT OUTER JOIN test2 t2 ON t1.col1 = t2.col1\n      WHERE t1.col1 IS NULL;\n  }\n} {}\n\n# Ticket #2273.  Problems with IN operators and NULLs.\n#\nifcapable subquery {\ndo_test where4-5.1 {\n  execsql {\n    -- Allow the 'x' syntax for backwards compatibility\n    CREATE TABLE t4(x,y,z,PRIMARY KEY('x' ASC, \"y\" ASC));\n  }\n  execsql {\n    SELECT *\n      FROM t2 LEFT JOIN t4 b1\n              LEFT JOIN t4 b2 ON b2.x=b1.x AND b2.y IN (b1.y);\n  }\n} {1 {} {} {} {} {} {} 2 {} {} {} {} {} {} 3 {} {} {} {} {} {}}\ndo_test where4-5.2 {\n  execsql {\n    INSERT INTO t4 VALUES(1,1,11);\n    INSERT INTO t4 VALUES(1,2,12);\n    INSERT INTO t4 VALUES(1,3,13);\n    INSERT INTO t4 VALUES(2,2,22);\n    SELECT rowid FROM t4 WHERE x IN (1,9,2,5) AND y IN (1,3,NULL,2) AND z!=13;\n  }\n} {1 2 4}\ndo_test where4-5.3 {\n  execsql {\n    SELECT rowid FROM t4 WHERE x IN (1,9,NULL,2) AND y IN (1,3,2) AND z!=13;\n  }\n} {1 2 4}\ndo_test where4-6.1 {\n  execsql {\n    CREATE TABLE t5(a,b,c,d,e,f,UNIQUE(a,b,c,d,e,f));\n    INSERT INTO t5 VALUES(1,1,1,1,1,11111);\n    INSERT INTO t5 VALUES(2,2,2,2,2,22222);\n    INSERT INTO t5 VALUES(1,2,3,4,5,12345);\n    INSERT INTO t5 VALUES(2,3,4,5,6,23456);\n  }\n  execsql {\n    SELECT rowid FROM t5\n     WHERE a IN (1,9,2) AND b=2 AND c IN (1,2,3,4) AND d>0\n  }\n} {3 2}\ndo_test where4-6.2 {\n  execsql {\n    SELECT rowid FROM t5\n     WHERE a IN (1,NULL,2) AND b=2 AND c IN (1,2,3,4) AND d>0\n  }\n} {3 2}\ndo_test where4-7.1 {\n  execsql {\n    CREATE TABLE t6(y,z,PRIMARY KEY(y,z));\n  }\n  execsql {\n    SELECT * FROM t6 WHERE y=NULL AND z IN ('hello');\n  }\n} {}\n\nintegrity_check {where4-99.0}\n\ndo_test where4-7.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t8(a, b, c, d);\n    CREATE INDEX t8_i ON t8(a, b, c);\n    CREATE TABLE t7(i);\n\n    INSERT INTO t7 VALUES(1);\n    INSERT INTO t7 SELECT i*2 FROM t7;\n    INSERT INTO t7 SELECT i*2 FROM t7;\n    INSERT INTO t7 SELECT i*2 FROM t7;\n    INSERT INTO t7 SELECT i*2 FROM t7;\n    INSERT INTO t7 SELECT i*2 FROM t7;\n    INSERT INTO t7 SELECT i*2 FROM t7;\n\n    COMMIT;\n  }\n} {}\n\n# At one point the sub-select inside the aggregate sum() function in the\n# following query was leaking a couple of stack entries. This query \n# runs the SELECT in a loop enough times that an assert() fails. Or rather,\n# did fail before the bug was fixed.\n#\ndo_test where4-7.2 {\n  execsql {\n    SELECT sum((\n      SELECT d FROM t8 WHERE a = i AND b = i AND c < NULL\n    )) FROM t7;\n  }\n} {{}}\n\n}; #ifcapable subquery\n\n#-------------------------------------------------------------------------\n# Verify that \"IS ?\" with a NULL bound to the variable also functions\n# correctly.\n\nunset -nocomplain null\n\ndo_execsql_test 8.1 {\n  CREATE TABLE u9(a UNIQUE, b);\n  INSERT INTO u9 VALUES(NULL, 1);\n  INSERT INTO u9 VALUES(NULL, 2);\n}\ndo_execsql_test 8.2 { SELECT * FROM u9 WHERE a IS NULL  } {{} 1 {} 2}\ndo_execsql_test 8.2 { SELECT * FROM u9 WHERE a IS $null } {{} 1 {} 2}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where5.test",
    "content": "# 2007 June 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing NULL comparisons in the WHERE clause.\n# See ticket #2404.\n#\n# $Id: where5.test,v 1.2 2007/06/08 08:43:10 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test where5-1.0 {\n  execsql {\n    CREATE TABLE t1(x TEXT);\n    CREATE TABLE t2(x INTEGER);\n    CREATE TABLE t3(x INTEGER PRIMARY KEY);\n    INSERT INTO t1 VALUES(-1);\n    INSERT INTO t1 VALUES(0);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t2 SELECT * FROM t1;\n    INSERT INTO t3 SELECT * FROM t2;\n  }\n  execsql {\n    SELECT * FROM t1 WHERE x<0\n  }\n} {-1}\ndo_test where5-1.1 {\n  execsql {\n    SELECT * FROM t1 WHERE x<=0\n  }\n} {-1 0}\ndo_test where5-1.2 {\n  execsql {\n    SELECT * FROM t1 WHERE x=0\n  }\n} {0}\ndo_test where5-1.3 {\n  execsql {\n    SELECT * FROM t1 WHERE x>=0\n  }\n} {0 1}\ndo_test where5-1.4 {\n  execsql {\n    SELECT * FROM t1 WHERE x>0\n  }\n} {1}\ndo_test where5-1.5 {\n  execsql {\n    SELECT * FROM t1 WHERE x<>0\n  }\n} {-1 1}\ndo_test where5-1.6 {\n  execsql {\n    SELECT * FROM t1 WHERE x<NULL\n  }\n} {}\ndo_test where5-1.7 {\n  execsql {\n    SELECT * FROM t1 WHERE x<=NULL\n  }\n} {}\ndo_test where5-1.8 {\n  execsql {\n    SELECT * FROM t1 WHERE x=NULL\n  }\n} {}\ndo_test where5-1.9 {\n  execsql {\n    SELECT * FROM t1 WHERE x>=NULL\n  }\n} {}\ndo_test where5-1.10 {\n  execsql {\n    SELECT * FROM t1 WHERE x>NULL\n  }\n} {}\ndo_test where5-1.11 {\n  execsql {\n    SELECT * FROM t1 WHERE x!=NULL\n  }\n} {}\ndo_test where5-1.12 {\n  execsql {\n    SELECT * FROM t1 WHERE x IS NULL\n  }\n} {}\ndo_test where5-1.13 {\n  execsql {\n    SELECT * FROM t1 WHERE x IS NOT NULL\n  }\n} {-1 0 1}\n\n\ndo_test where5-2.0 {\n  execsql {\n    SELECT * FROM t2 WHERE x<0\n  }\n} {-1}\ndo_test where5-2.1 {\n  execsql {\n    SELECT * FROM t2 WHERE x<=0\n  }\n} {-1 0}\ndo_test where5-2.2 {\n  execsql {\n    SELECT * FROM t2 WHERE x=0\n  }\n} {0}\ndo_test where5-2.3 {\n  execsql {\n    SELECT * FROM t2 WHERE x>=0\n  }\n} {0 1}\ndo_test where5-2.4 {\n  execsql {\n    SELECT * FROM t2 WHERE x>0\n  }\n} {1}\ndo_test where5-2.5 {\n  execsql {\n    SELECT * FROM t2 WHERE x<>0\n  }\n} {-1 1}\ndo_test where5-2.6 {\n  execsql {\n    SELECT * FROM t2 WHERE x<NULL\n  }\n} {}\ndo_test where5-2.7 {\n  execsql {\n    SELECT * FROM t2 WHERE x<=NULL\n  }\n} {}\ndo_test where5-2.8 {\n  execsql {\n    SELECT * FROM t2 WHERE x=NULL\n  }\n} {}\ndo_test where5-2.9 {\n  execsql {\n    SELECT * FROM t2 WHERE x>=NULL\n  }\n} {}\ndo_test where5-2.10 {\n  execsql {\n    SELECT * FROM t2 WHERE x>NULL\n  }\n} {}\ndo_test where5-2.11 {\n  execsql {\n    SELECT * FROM t2 WHERE x!=NULL\n  }\n} {}\ndo_test where5-2.12 {\n  execsql {\n    SELECT * FROM t2 WHERE x IS NULL\n  }\n} {}\ndo_test where5-2.13 {\n  execsql {\n    SELECT * FROM t2 WHERE x IS NOT NULL\n  }\n} {-1 0 1}\n\n\ndo_test where5-3.0 {\n  execsql {\n    SELECT * FROM t3 WHERE x<0\n  }\n} {-1}\ndo_test where5-3.1 {\n  execsql {\n    SELECT * FROM t3 WHERE x<=0\n  }\n} {-1 0}\ndo_test where5-3.2 {\n  execsql {\n    SELECT * FROM t3 WHERE x=0\n  }\n} {0}\ndo_test where5-3.3 {\n  execsql {\n    SELECT * FROM t3 WHERE x>=0\n  }\n} {0 1}\ndo_test where5-3.4 {\n  execsql {\n    SELECT * FROM t3 WHERE x>0\n  }\n} {1}\ndo_test where5-3.5 {\n  execsql {\n    SELECT * FROM t3 WHERE x<>0\n  }\n} {-1 1}\ndo_test where5-3.6 {\n  execsql {\n    SELECT * FROM t3 WHERE x<NULL\n  }\n} {}\ndo_test where5-3.7 {\n  execsql {\n    SELECT * FROM t3 WHERE x<=NULL\n  }\n} {}\ndo_test where5-3.8 {\n  execsql {\n    SELECT * FROM t3 WHERE x=NULL\n  }\n} {}\ndo_test where5-3.9 {\n  execsql {\n    SELECT * FROM t3 WHERE x>=NULL\n  }\n} {}\ndo_test where5-3.10 {\n  execsql {\n    SELECT * FROM t3 WHERE x>NULL\n  }\n} {}\ndo_test where5-3.11 {\n  execsql {\n    SELECT * FROM t3 WHERE x!=NULL\n  }\n} {}\ndo_test where5-3.12 {\n  execsql {\n    SELECT * FROM t3 WHERE x IS NULL\n  }\n} {}\ndo_test where5-3.13 {\n  execsql {\n    SELECT * FROM t3 WHERE x IS NOT NULL\n  }\n} {-1 0 1}\n\ndo_test where5-4.0 {\n  execsql {\n    SELECT x<NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.1 {\n  execsql {\n    SELECT x<=NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.2 {\n  execsql {\n    SELECT x==NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.3 {\n  execsql {\n    SELECT x>NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.4 {\n  execsql {\n    SELECT x>=NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.5 {\n  execsql {\n    SELECT x!=NULL FROM t3\n  }\n} {{} {} {}}\ndo_test where5-4.6 {\n  execsql {\n    SELECT x IS NULL FROM t3\n  }\n} {0 0 0}\ndo_test where5-4.7 {\n  execsql {\n    SELECT x IS NOT NULL FROM t3\n  }\n} {1 1 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where6.test",
    "content": "# 2007 June 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that terms in the ON clause of\n# a LEFT OUTER JOIN are not used with indices.  See ticket #3015.\n#\n# $Id: where6.test,v 1.2 2008/04/17 19:14:02 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Build some test data\n#\ndo_test where6-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c);\n    INSERT INTO t1 VALUES(1,3,1);\n    INSERT INTO t1 VALUES(2,4,2);\n    CREATE TABLE t2(x INTEGER PRIMARY KEY);\n    INSERT INTO t2 VALUES(3);\n\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-1.2 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-1.3 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-1.4 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;\n  }\n} {1 3 1 3 2 4 2 {}}\n\nifcapable explain {\n  do_test where6-1.5 {\n     explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}\n  } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]\n  do_test where6-1.6 {\n     explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}\n  } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]\n}\n\ndo_test where6-1.11 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;\n  }\n} {1 3 1 3}\ndo_test where6-1.12 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;\n  }\n} {1 3 1 3}\ndo_test where6-1.13 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;\n  }\n} {1 3 1 3}\n\n\n\ndo_test where6-2.1 {\n  execsql {\n    CREATE INDEX i1 ON t1(c);\n\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-2.2 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-2.3 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;\n  }\n} {1 3 1 3 2 4 2 {}}\ndo_test where6-2.4 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;\n  }\n} {1 3 1 3 2 4 2 {}}\n\nifcapable explain {\n  do_test where6-2.5 {\n     explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}\n  } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]\n  do_test where6-2.6 {\n     explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}\n  } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]\n}\n\n\ndo_test where6-2.11 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;\n  }\n} {1 3 1 3}\ndo_test where6-2.12 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;\n  }\n} {1 3 1 3}\ndo_test where6-2.13 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c;\n  }\n} {1 3 1 3}\ndo_test where6-2.14 {\n  execsql {\n    SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;\n  }\n} {1 3 1 3}\n\n# Ticket [ebdbadade5b]:\n# If the ON close on a LEFT JOIN is of the form x=y where both x and y\n# are indexed columns on tables to left of the join, then do not use that \n# term with indices to either table.\n#\ndo_test where6-3.1 {\n  db eval {\n    CREATE TABLE t4(x UNIQUE);\n    INSERT INTO t4 VALUES('abc');\n    INSERT INTO t4 VALUES('def');\n    INSERT INTO t4 VALUES('ghi');\n    CREATE TABLE t5(a, b, c, PRIMARY KEY(a,b));\n    INSERT INTO t5 VALUES('abc','def',123);\n    INSERT INTO t5 VALUES('def','ghi',456);\n\n    SELECT t4a.x, t4b.x, t5.c, t6.v\n      FROM t4 AS t4a\n           INNER JOIN t4 AS t4b\n           LEFT JOIN t5 ON t5.a=t4a.x AND t5.b=t4b.x\n           LEFT JOIN (SELECT 1 AS v) AS t6 ON t4a.x=t4b.x\n     ORDER BY 1, 2, 3;\n  }\n} {abc abc {} 1 abc def 123 {} abc ghi {} {} def abc {} {} def def {} 1 def ghi 456 {} ghi abc {} {} ghi def {} {} ghi ghi {} 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where7.test",
    "content": "# 2008 December 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the multi-index OR clause optimizer.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !or_opt {\n  finish_test\n  return\n}\n\n# Evaluate SQL.  Return the result set followed by the\n# and the number of full-scan steps.\n#\nproc count_steps {sql} {\n  set r [db eval $sql]\n  lappend r scan [db status step] sort [db status sort]\n}\n\nproc count_steps_sort {sql} {\n  set r [lsort -integer [db eval $sql]]\n  return \"$r scan [db status step] sort [db status sort]\"\n}\n\n# Build some test data\n#\ndo_test where7-1.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d);\n    INSERT INTO t1 VALUES(1,2,3,4);\n    INSERT INTO t1 VALUES(2,3,4,5);\n    INSERT INTO t1 VALUES(3,4,6,8);\n    INSERT INTO t1 VALUES(4,5,10,15);\n    INSERT INTO t1 VALUES(5,10,100,1000);\n    CREATE INDEX t1b ON t1(b);\n    CREATE INDEX t1c ON t1(c);\n    SELECT * FROM t1;\n  }\n} {1 2 3 4 2 3 4 5 3 4 6 8 4 5 10 15 5 10 100 1000}\ndo_execsql_test where7-1.1.1 {\n  CREATE TABLE t(a);\n  CREATE INDEX ta ON t(a);\n  INSERT INTO t(a) VALUES(1),(2);\n  SELECT * FROM t ORDER BY a;\n  SELECT * FROM t WHERE a<2 OR a<3 ORDER BY a;\n  PRAGMA count_changes=ON;\n  DELETE FROM t WHERE a<2 OR a<3;\n  SELECT * FROM t;\n  PRAGMA count_changes=OFF;\n  DROP TABLE t;\n} {1 2 1 2 2}\ndo_test where7-1.2 {\n  count_steps {\n    SELECT a FROM t1 WHERE b=3 OR c=6 ORDER BY a\n  }\n} {2 3 scan 0 sort 1}\ndo_test where7-1.3 {\n  count_steps {\n    SELECT a FROM t1 WHERE b=3 OR +c=6 ORDER BY a\n  }\n} {2 3 scan 4 sort 0}\ndo_test where7-1.4 {\n  count_steps {\n    SELECT a FROM t1 WHERE +b=3 OR c=6 ORDER BY 1\n  }\n} {2 3 scan 4 sort 0}\ndo_test where7-1.5 {\n  count_steps {\n    SELECT a FROM t1 WHERE 3=b OR c=6 ORDER BY rowid\n  }\n} {2 3 scan 0 sort 1}\ndo_test where7-1.6 {\n  count_steps {\n    SELECT a FROM t1 WHERE (3=b OR c=6) AND +a>0 ORDER BY a\n  }\n} {2 3 scan 0 sort 1}\ndo_test where7-1.7 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b=3 OR c>10)\n  }\n} {2 5 scan 0 sort 0}\ndo_test where7-1.8 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b=3 OR c>=10)\n  }\n} {2 4 5 scan 0 sort 0}\ndo_test where7-1.9 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b=3 OR c>=10 OR c=4)\n  }\n} {2 4 5 scan 0 sort 0}\ndo_test where7-1.10 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b=3 OR c>=10 OR c=4 OR b>10)\n  }\n} {2 4 5 scan 0 sort 0}\ndo_test where7-1.11 {\n  count_steps {\n    SELECT a FROM t1 WHERE (d=5 AND b=3) OR c==100 ORDER BY a;\n  }\n} {2 5 scan 0 sort 1}\ndo_test where7-1.12 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b BETWEEN 2 AND 4) OR c=100 ORDER BY a\n  }\n} {1 2 3 5 scan 0 sort 1}\ndo_test where7-1.13 {\n  count_steps {\n    SELECT a FROM t1 WHERE (b BETWEEN 0 AND 2) OR (c BETWEEN 9 AND 999)\n    ORDER BY +a DESC\n  }\n} {5 4 1 scan 0 sort 1}\n\ndo_test where7-1.14 {\n  count_steps {\n    SELECT a FROM t1 WHERE (d=8 OR c=6 OR b=4) AND +a>0\n  }\n} {3 scan 4 sort 0}\ndo_test where7-1.15 {\n  count_steps {\n    SELECT a FROM t1 WHERE +a>=0 AND (d=8 OR c=6 OR b=4)\n  }\n} {3 scan 4 sort 0}\n\ndo_test where7-1.20 {\n  set sql \"SELECT a FROM t1 WHERE a=11 OR b=11\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR a=$i OR b=$i\"\n  }\n  append sql \" ORDER BY a\"\n  count_steps $sql\n} {scan 0 sort 1}\ndo_test where7-1.21 {\n  set sql \"SELECT a FROM t1 WHERE b=11 OR c=11\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR b=$i OR c=$i\"\n  }\n  append sql \" ORDER BY a\"\n  count_steps $sql\n} {5 scan 0 sort 1}\ndo_test where7-1.22 {\n  set sql \"SELECT a FROM t1 WHERE (b=11 OR c=11\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR b=$i OR c=$i\"\n  }\n  append sql \") AND d>=0 AND d<9999 ORDER BY a\"\n  count_steps $sql\n} {5 scan 0 sort 1}\ndo_test where7-1.23 {\n  set sql \"SELECT a FROM t1 WHERE (b=11 OR c=11\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR (b=$i AND d!=0) OR (c=$i AND d IS NOT NULL)\"\n  }\n  append sql \") AND d>=0 AND d<9999 ORDER BY a\"\n  count_steps $sql\n} {5 scan 0 sort 1}\n\ndo_test where7-1.31 {\n  set sql \"SELECT a FROM t1 WHERE (a=11 AND b=11)\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR (a=$i AND b=$i)\"\n  }\n  append sql \" ORDER BY a\"\n  count_steps $sql\n} {scan 0 sort 1}\ndo_test where7-1.32 {\n  set sql \"SELECT a FROM t1 WHERE (b=11 AND c=11)\"\n  for {set i 12} {$i<400} {incr i} {\n    append sql \" OR (b=$i AND c=$i)\"\n  }\n  append sql \" ORDER BY a\"\n  count_steps $sql\n} {scan 0 sort 1}\n\n\ndo_test where7-2.1 {\n  db eval {\n    CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);\n    INSERT INTO t2 VALUES(1,11,1001,1.001,100.1,'bcdefghij','yxwvuts');\n    INSERT INTO t2 VALUES(2,22,1001,2.002,100.1,'cdefghijk','yxwvuts');\n    INSERT INTO t2 VALUES(3,33,1001,3.0029999999999997,100.1,'defghijkl','xwvutsr');\n    INSERT INTO t2 VALUES(4,44,2002,4.004,200.2,'efghijklm','xwvutsr');\n    INSERT INTO t2 VALUES(5,55,2002,5.004999999999999,200.2,'fghijklmn','xwvutsr');\n    INSERT INTO t2 VALUES(6,66,2002,6.005999999999999,200.2,'ghijklmno','xwvutsr');\n    INSERT INTO t2 VALUES(7,77,3003,7.007,300.29999999999995,'hijklmnop','xwvutsr');\n    INSERT INTO t2 VALUES(8,88,3003,8.008,300.29999999999995,'ijklmnopq','wvutsrq');\n    INSERT INTO t2 VALUES(9,99,3003,9.008999999999999,300.29999999999995,'jklmnopqr','wvutsrq');\n    INSERT INTO t2 VALUES(10,110,4004,10.009999999999998,400.4,'klmnopqrs','wvutsrq');\n    INSERT INTO t2 VALUES(11,121,4004,11.011,400.4,'lmnopqrst','wvutsrq');\n    INSERT INTO t2 VALUES(12,132,4004,12.011999999999999,400.4,'mnopqrstu','wvutsrq');\n    INSERT INTO t2 VALUES(13,143,5005,13.012999999999998,500.5,'nopqrstuv','vutsrqp');\n    INSERT INTO t2 VALUES(14,154,5005,14.014,500.5,'opqrstuvw','vutsrqp');\n    INSERT INTO t2 VALUES(15,165,5005,15.014999999999999,500.5,'pqrstuvwx','vutsrqp');\n    INSERT INTO t2 VALUES(16,176,6006,16.016,600.5999999999999,'qrstuvwxy','vutsrqp');\n    INSERT INTO t2 VALUES(17,187,6006,17.017,600.5999999999999,'rstuvwxyz','vutsrqp');\n    INSERT INTO t2 VALUES(18,198,6006,18.017999999999997,600.5999999999999,'stuvwxyza','utsrqpo');\n    INSERT INTO t2 VALUES(19,209,7007,19.019,700.6999999999999,'tuvwxyzab','utsrqpo');\n    INSERT INTO t2 VALUES(20,220,7007,20.019999999999996,700.6999999999999,'uvwxyzabc','utsrqpo');\n    INSERT INTO t2 VALUES(21,231,7007,21.020999999999997,700.6999999999999,'vwxyzabcd','utsrqpo');\n    INSERT INTO t2 VALUES(22,242,8008,22.022,800.8,'wxyzabcde','utsrqpo');\n    INSERT INTO t2 VALUES(23,253,8008,23.022999999999996,800.8,'xyzabcdef','tsrqpon');\n    INSERT INTO t2 VALUES(24,264,8008,24.023999999999997,800.8,'yzabcdefg','tsrqpon');\n    INSERT INTO t2 VALUES(25,275,9009,25.025,900.9,'zabcdefgh','tsrqpon');\n    INSERT INTO t2 VALUES(26,286,9009,26.025999999999996,900.9,'abcdefghi','tsrqpon');\n    INSERT INTO t2 VALUES(27,297,9009,27.026999999999997,900.9,'bcdefghij','tsrqpon');\n    INSERT INTO t2 VALUES(28,308,10010,28.028,1001.0,'cdefghijk','srqponm');\n    INSERT INTO t2 VALUES(29,319,10010,29.028999999999996,1001.0,'defghijkl','srqponm');\n    INSERT INTO t2 VALUES(30,330,10010,30.029999999999998,1001.0,'efghijklm','srqponm');\n    INSERT INTO t2 VALUES(31,341,11011,31.030999999999995,1101.1,'fghijklmn','srqponm');\n    INSERT INTO t2 VALUES(32,352,11011,32.032,1101.1,'ghijklmno','srqponm');\n    INSERT INTO t2 VALUES(33,363,11011,33.032999999999994,1101.1,'hijklmnop','rqponml');\n    INSERT INTO t2 VALUES(34,374,12012,34.034,1201.1999999999998,'ijklmnopq','rqponml');\n    INSERT INTO t2 VALUES(35,385,12012,35.035,1201.1999999999998,'jklmnopqr','rqponml');\n    INSERT INTO t2 VALUES(36,396,12012,36.035999999999994,1201.1999999999998,'klmnopqrs','rqponml');\n    INSERT INTO t2 VALUES(37,407,13013,37.037,1301.3,'lmnopqrst','rqponml');\n    INSERT INTO t2 VALUES(38,418,13013,38.038,1301.3,'mnopqrstu','qponmlk');\n    INSERT INTO t2 VALUES(39,429,13013,39.038999999999994,1301.3,'nopqrstuv','qponmlk');\n    INSERT INTO t2 VALUES(40,440,14014,40.03999999999999,1401.3999999999999,'opqrstuvw','qponmlk');\n    INSERT INTO t2 VALUES(41,451,14014,41.041,1401.3999999999999,'pqrstuvwx','qponmlk');\n    INSERT INTO t2 VALUES(42,462,14014,42.041999999999994,1401.3999999999999,'qrstuvwxy','qponmlk');\n    INSERT INTO t2 VALUES(43,473,15015,43.04299999999999,1501.5,'rstuvwxyz','ponmlkj');\n    INSERT INTO t2 VALUES(44,484,15015,44.044,1501.5,'stuvwxyza','ponmlkj');\n    INSERT INTO t2 VALUES(45,495,15015,45.044999999999995,1501.5,'tuvwxyzab','ponmlkj');\n    INSERT INTO t2 VALUES(46,506,16016,46.04599999999999,1601.6,'uvwxyzabc','ponmlkj');\n    INSERT INTO t2 VALUES(47,517,16016,47.047,1601.6,'vwxyzabcd','ponmlkj');\n    INSERT INTO t2 VALUES(48,528,16016,48.047999999999995,1601.6,'wxyzabcde','onmlkji');\n    INSERT INTO t2 VALUES(49,539,17017,49.04899999999999,1701.6999999999998,'xyzabcdef','onmlkji');\n    INSERT INTO t2 VALUES(50,550,17017,50.05,1701.6999999999998,'yzabcdefg','onmlkji');\n    INSERT INTO t2 VALUES(51,561,17017,51.050999999999995,1701.6999999999998,'zabcdefgh','onmlkji');\n    INSERT INTO t2 VALUES(52,572,18018,52.05199999999999,1801.8,'abcdefghi','onmlkji');\n    INSERT INTO t2 VALUES(53,583,18018,53.053,1801.8,'bcdefghij','nmlkjih');\n    INSERT INTO t2 VALUES(54,594,18018,54.053999999999995,1801.8,'cdefghijk','nmlkjih');\n    INSERT INTO t2 VALUES(55,605,19019,55.05499999999999,1901.8999999999999,'defghijkl','nmlkjih');\n    INSERT INTO t2 VALUES(56,616,19019,56.056,1901.8999999999999,'efghijklm','nmlkjih');\n    INSERT INTO t2 VALUES(57,627,19019,57.056999999999995,1901.8999999999999,'fghijklmn','nmlkjih');\n    INSERT INTO t2 VALUES(58,638,20020,58.05799999999999,2002.0,'ghijklmno','mlkjihg');\n    INSERT INTO t2 VALUES(59,649,20020,59.05899999999999,2002.0,'hijklmnop','mlkjihg');\n    INSERT INTO t2 VALUES(60,660,20020,60.059999999999995,2002.0,'ijklmnopq','mlkjihg');\n    INSERT INTO t2 VALUES(61,671,21021,61.06099999999999,2102.1,'jklmnopqr','mlkjihg');\n    INSERT INTO t2 VALUES(62,682,21021,62.06199999999999,2102.1,'klmnopqrs','mlkjihg');\n    INSERT INTO t2 VALUES(63,693,21021,63.062999999999995,2102.1,'lmnopqrst','lkjihgf');\n    INSERT INTO t2 VALUES(64,704,22022,64.064,2202.2,'mnopqrstu','lkjihgf');\n    INSERT INTO t2 VALUES(65,715,22022,65.065,2202.2,'nopqrstuv','lkjihgf');\n    INSERT INTO t2 VALUES(66,726,22022,66.06599999999999,2202.2,'opqrstuvw','lkjihgf');\n    INSERT INTO t2 VALUES(67,737,23023,67.067,2302.2999999999997,'pqrstuvwx','lkjihgf');\n    INSERT INTO t2 VALUES(68,748,23023,68.068,2302.2999999999997,'qrstuvwxy','kjihgfe');\n    INSERT INTO t2 VALUES(69,759,23023,69.06899999999999,2302.2999999999997,'rstuvwxyz','kjihgfe');\n    INSERT INTO t2 VALUES(70,770,24024,70.07,2402.3999999999996,'stuvwxyza','kjihgfe');\n    INSERT INTO t2 VALUES(71,781,24024,71.071,2402.3999999999996,'tuvwxyzab','kjihgfe');\n    INSERT INTO t2 VALUES(72,792,24024,72.07199999999999,2402.3999999999996,'uvwxyzabc','kjihgfe');\n    INSERT INTO t2 VALUES(73,803,25025,73.073,2502.5,'vwxyzabcd','jihgfed');\n    INSERT INTO t2 VALUES(74,814,25025,74.074,2502.5,'wxyzabcde','jihgfed');\n    INSERT INTO t2 VALUES(75,825,25025,75.07499999999999,2502.5,'xyzabcdef','jihgfed');\n    INSERT INTO t2 VALUES(76,836,26026,76.076,2602.6,'yzabcdefg','jihgfed');\n    INSERT INTO t2 VALUES(77,847,26026,77.077,2602.6,'zabcdefgh','jihgfed');\n    INSERT INTO t2 VALUES(78,858,26026,78.07799999999999,2602.6,'abcdefghi','ihgfedc');\n    INSERT INTO t2 VALUES(79,869,27027,79.079,2702.7,'bcdefghij','ihgfedc');\n    INSERT INTO t2 VALUES(80,880,27027,80.07999999999998,2702.7,'cdefghijk','ihgfedc');\n    INSERT INTO t2 VALUES(81,891,27027,81.08099999999999,2702.7,'defghijkl','ihgfedc');\n    INSERT INTO t2 VALUES(82,902,28028,82.082,2802.7999999999997,'efghijklm','ihgfedc');\n    INSERT INTO t2 VALUES(83,913,28028,83.08299999999998,2802.7999999999997,'fghijklmn','hgfedcb');\n    INSERT INTO t2 VALUES(84,924,28028,84.08399999999999,2802.7999999999997,'ghijklmno','hgfedcb');\n    INSERT INTO t2 VALUES(85,935,29029,85.085,2902.8999999999996,'hijklmnop','hgfedcb');\n    INSERT INTO t2 VALUES(86,946,29029,86.08599999999998,2902.8999999999996,'ijklmnopq','hgfedcb');\n    INSERT INTO t2 VALUES(87,957,29029,87.08699999999999,2902.8999999999996,'jklmnopqr','hgfedcb');\n    INSERT INTO t2 VALUES(88,968,30030,88.088,3003.0,'klmnopqrs','gfedcba');\n    INSERT INTO t2 VALUES(89,979,30030,89.08899999999998,3003.0,'lmnopqrst','gfedcba');\n    INSERT INTO t2 VALUES(90,990,30030,90.08999999999999,3003.0,'mnopqrstu','gfedcba');\n    INSERT INTO t2 VALUES(91,1001,31031,91.091,3103.1,'nopqrstuv','gfedcba');\n    INSERT INTO t2 VALUES(92,1012,31031,92.09199999999998,3103.1,'opqrstuvw','gfedcba');\n    INSERT INTO t2 VALUES(93,1023,31031,93.09299999999999,3103.1,'pqrstuvwx','fedcbaz');\n    INSERT INTO t2 VALUES(94,1034,32032,94.094,3203.2,'qrstuvwxy','fedcbaz');\n    INSERT INTO t2 VALUES(95,1045,32032,95.09499999999998,3203.2,'rstuvwxyz','fedcbaz');\n    INSERT INTO t2 VALUES(96,1056,32032,96.09599999999999,3203.2,'stuvwxyza','fedcbaz');\n    INSERT INTO t2 VALUES(97,1067,33033,97.097,3303.2999999999997,'tuvwxyzab','fedcbaz');\n    INSERT INTO t2 VALUES(98,1078,33033,98.09799999999998,3303.2999999999997,'uvwxyzabc','edcbazy');\n    INSERT INTO t2 VALUES(99,1089,33033,99.09899999999999,3303.2999999999997,'vwxyzabcd','edcbazy');\n    INSERT INTO t2 VALUES(100,1100,34034,100.1,3403.3999999999996,'wxyzabcde','edcbazy');\n    CREATE INDEX t2b ON t2(b);\n    CREATE INDEX t2c ON t2(c);\n    CREATE INDEX t2d ON t2(d);\n    CREATE INDEX t2e ON t2(e);\n    CREATE INDEX t2f ON t2(f);\n    CREATE INDEX t2g ON t2(g);\n    CREATE TABLE t3(a INTEGER PRIMARY KEY,b,c,d,e,f TEXT,g);\n    INSERT INTO t3 SELECT * FROM t2;\n    CREATE INDEX t3b ON t3(b,c);\n    CREATE INDEX t3c ON t3(c,e);\n    CREATE INDEX t3d ON t3(d,g);\n    CREATE INDEX t3e ON t3(e,f,g);\n    CREATE INDEX t3f ON t3(f,b,d,c);\n    CREATE INDEX t3g ON t3(g,f);\n  }\n} {}\n\ndo_test where7-2.2.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1070\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n  }\n} {6 18 20 32 39 58 84 89 96 100 scan 0 sort 0}\ndo_test where7-2.2.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1070\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n  }\n} {6 18 20 32 39 58 84 89 96 100 scan 0 sort 0}\ndo_test where7-2.3.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR b=220\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n  }\n} {20 33 35 41 47 67 69 70 98 scan 0 sort 0}\ndo_test where7-2.3.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR b=220\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n  }\n} {20 33 35 41 47 67 69 70 98 scan 0 sort 0}\ndo_test where7-2.4.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=190\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR b=407\n  }\n} {33 37 49 51 scan 0 sort 0}\ndo_test where7-2.4.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=190\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR b=407\n  }\n} {33 37 49 51 scan 0 sort 0}\ndo_test where7-2.5.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=795\n         OR b=1103\n         OR b=583\n  }\n} {13 39 53 65 91 scan 0 sort 0}\ndo_test where7-2.5.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=795\n         OR b=1103\n         OR b=583\n  }\n} {13 39 53 65 91 scan 0 sort 0}\ndo_test where7-2.6.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=74\n         OR a=50\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR c=21021\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n  }\n} {16 18 50 61 62 63 74 82 84 85 scan 0 sort 0}\ndo_test where7-2.6.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=74\n         OR a=50\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR c=21021\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n  }\n} {16 18 50 61 62 63 74 82 84 85 scan 0 sort 0}\ndo_test where7-2.7.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR c=14014\n         OR b=828\n  }\n} {8 10 34 36 40 41 42 94 scan 0 sort 0}\ndo_test where7-2.7.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR c=14014\n         OR b=828\n  }\n} {8 10 34 36 40 41 42 94 scan 0 sort 0}\ndo_test where7-2.8.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE 1000000<b\n         OR b=308\n  }\n} {28 scan 0 sort 0}\ndo_test where7-2.8.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE 1000000<b\n         OR b=308\n  }\n} {28 scan 0 sort 0}\ndo_test where7-2.9.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=949\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=63\n  }\n} {22 24 63 scan 0 sort 0}\ndo_test where7-2.9.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=949\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=63\n  }\n} {22 24 63 scan 0 sort 0}\ndo_test where7-2.10.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=396\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n  }\n} {36 49 51 68 70 scan 0 sort 0}\ndo_test where7-2.10.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=396\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n  }\n} {36 49 51 68 70 scan 0 sort 0}\ndo_test where7-2.11.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR c=11011\n         OR c=20020\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n  }\n} {18 31 32 33 58 59 60 72 74 scan 0 sort 0}\ndo_test where7-2.11.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR c=11011\n         OR c=20020\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n  }\n} {18 31 32 33 58 59 60 72 74 scan 0 sort 0}\ndo_test where7-2.12.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR b=792\n         OR a=97\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR b=916\n         OR a=69\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR c=6006\n  }\n} {16 17 18 31 50 69 72 81 83 87 97 scan 0 sort 0}\ndo_test where7-2.12.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR b=792\n         OR a=97\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR b=916\n         OR a=69\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR c=6006\n  }\n} {16 17 18 31 50 69 72 81 83 87 97 scan 0 sort 0}\ndo_test where7-2.13.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 50 AND 52) AND a!=51)\n         OR c=9009\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=539\n         OR b=297\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=957\n         OR f='xyzabcdef'\n         OR b=619\n  }\n} {10 15 21 23 25 26 27 49 50 52 75 87 scan 0 sort 0}\ndo_test where7-2.13.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 50 AND 52) AND a!=51)\n         OR c=9009\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=539\n         OR b=297\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=957\n         OR f='xyzabcdef'\n         OR b=619\n  }\n} {10 15 21 23 25 26 27 49 50 52 75 87 scan 0 sort 0}\ndo_test where7-2.14.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n  }\n} {47 48 49 scan 0 sort 0}\ndo_test where7-2.14.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n  }\n} {47 48 49 scan 0 sort 0}\ndo_test where7-2.15.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=20\n         OR a=67\n         OR b=58\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {19 20 21 67 scan 0 sort 0}\ndo_test where7-2.15.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=20\n         OR a=67\n         OR b=58\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {19 20 21 67 scan 0 sort 0}\ndo_test where7-2.16.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=938\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {17 67 scan 0 sort 0}\ndo_test where7-2.16.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=938\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {17 67 scan 0 sort 0}\ndo_test where7-2.17.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR b=308\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR b=443\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR f='uvwxyzabc'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {12 14 15 16 17 20 24 25 28 29 46 50 51 68 72 76 77 98 scan 0 sort 0}\ndo_test where7-2.17.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR b=308\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR b=443\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR f='uvwxyzabc'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {12 14 15 16 17 20 24 25 28 29 46 50 51 68 72 76 77 98 scan 0 sort 0}\ndo_test where7-2.18.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=762\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=19\n  }\n} {19 46 56 scan 0 sort 0}\ndo_test where7-2.18.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=762\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=19\n  }\n} {19 46 56 scan 0 sort 0}\ndo_test where7-2.19.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=46\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR a=73\n         OR c=20020\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR b=267\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n  }\n} {2 4 20 46 58 59 60 63 68 70 73 scan 0 sort 0}\ndo_test where7-2.19.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=46\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR a=73\n         OR c=20020\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR b=267\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n  }\n} {2 4 20 46 58 59 60 63 68 70 73 scan 0 sort 0}\ndo_test where7-2.20.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 27 AND 29) AND a!=28)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {27 29 91 scan 0 sort 0}\ndo_test where7-2.20.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 27 AND 29) AND a!=28)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {27 29 91 scan 0 sort 0}\ndo_test where7-2.21.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=13013\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR f='bcdefghij'\n         OR b=586\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR a=9\n  }\n} {1 6 9 27 37 38 39 53 55 58 59 61 75 79 87 89 98 scan 0 sort 0}\ndo_test where7-2.21.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=13013\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR f='bcdefghij'\n         OR b=586\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR a=9\n  }\n} {1 6 9 27 37 38 39 53 55 58 59 61 75 79 87 89 98 scan 0 sort 0}\ndo_test where7-2.22.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=399\n         OR c=28028\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n  }\n} {42 82 83 84 98 scan 0 sort 0}\ndo_test where7-2.22.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=399\n         OR c=28028\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n  }\n} {42 82 83 84 98 scan 0 sort 0}\ndo_test where7-2.23.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR c=14014\n         OR c=33033\n         OR a=89\n         OR b=770\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR a=35\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR b=253\n         OR c=14014\n  }\n} {4 19 23 30 35 40 41 42 56 70 82 89 95 96 97 98 99 scan 0 sort 0}\ndo_test where7-2.23.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR c=14014\n         OR c=33033\n         OR a=89\n         OR b=770\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR a=35\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR b=253\n         OR c=14014\n  }\n} {4 19 23 30 35 40 41 42 56 70 82 89 95 96 97 98 99 scan 0 sort 0}\ndo_test where7-2.24.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=330\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR a=16\n  }\n} {6 16 21 30 32 34 scan 0 sort 0}\ndo_test where7-2.24.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=330\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR a=16\n  }\n} {6 16 21 30 32 34 scan 0 sort 0}\ndo_test where7-2.25.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=5005\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {2 13 14 15 36 38 47 scan 0 sort 0}\ndo_test where7-2.25.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=5005\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {2 13 14 15 36 38 47 scan 0 sort 0}\ndo_test where7-2.26.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=33\n  }\n} {30 33 58 64 66 68 scan 0 sort 0}\ndo_test where7-2.26.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=33\n  }\n} {30 33 58 64 66 68 scan 0 sort 0}\ndo_test where7-2.27.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1026\n         OR b=410\n  }\n} { scan 0 sort 0}\ndo_test where7-2.27.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1026\n         OR b=410\n  }\n} { scan 0 sort 0}\ndo_test where7-2.28.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=18018\n         OR a=94\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=1012\n         OR a=3\n         OR d>1e10\n         OR b=905\n         OR b=1089\n  }\n} {3 15 26 41 52 53 54 67 92 93 94 99 scan 0 sort 0}\ndo_test where7-2.28.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=18018\n         OR a=94\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=1012\n         OR a=3\n         OR d>1e10\n         OR b=905\n         OR b=1089\n  }\n} {3 15 26 41 52 53 54 67 92 93 94 99 scan 0 sort 0}\ndo_test where7-2.29.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=100\n         OR c=11011\n         OR b=297\n         OR a=63\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR a=76\n         OR b=1026\n         OR a=26\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR c=30030\n  }\n} {24 26 27 31 32 33 50 63 76 84 88 89 90 100 scan 0 sort 0}\ndo_test where7-2.29.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=100\n         OR c=11011\n         OR b=297\n         OR a=63\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR a=76\n         OR b=1026\n         OR a=26\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR c=30030\n  }\n} {24 26 27 31 32 33 50 63 76 84 88 89 90 100 scan 0 sort 0}\ndo_test where7-2.30.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=561\n         OR b=1070\n         OR a=59\n         OR b=715\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n  }\n} {23 49 51 59 65 75 scan 0 sort 0}\ndo_test where7-2.30.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=561\n         OR b=1070\n         OR a=59\n         OR b=715\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n  }\n} {23 49 51 59 65 75 scan 0 sort 0}\ndo_test where7-2.31.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=1056\n         OR b=1012\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {19 26 52 57 59 67 69 78 92 95 96 scan 0 sort 0}\ndo_test where7-2.31.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=1056\n         OR b=1012\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {19 26 52 57 59 67 69 78 92 95 96 scan 0 sort 0}\ndo_test where7-2.32.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='rstuvwxyz'\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n  }\n} {17 43 69 74 90 92 95 98 scan 0 sort 0}\ndo_test where7-2.32.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='rstuvwxyz'\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n  }\n} {17 43 69 74 90 92 95 98 scan 0 sort 0}\ndo_test where7-2.33.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR c=12012\n         OR a=18\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n  }\n} {9 15 17 18 26 34 35 36 41 43 52 61 67 69 76 78 87 93 95 scan 0 sort 0}\ndo_test where7-2.33.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR c=12012\n         OR a=18\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n  }\n} {9 15 17 18 26 34 35 36 41 43 52 61 67 69 76 78 87 93 95 scan 0 sort 0}\ndo_test where7-2.34.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=77\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n  }\n} {58 77 scan 0 sort 0}\ndo_test where7-2.34.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=77\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n  }\n} {58 77 scan 0 sort 0}\ndo_test where7-2.35.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=498\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR c=33033\n         OR b=11\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {1 7 9 11 27 67 69 88 97 98 99 scan 0 sort 0}\ndo_test where7-2.35.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=498\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR c=33033\n         OR b=11\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {1 7 9 11 27 67 69 88 97 98 99 scan 0 sort 0}\ndo_test where7-2.36.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n  }\n} {6 58 60 scan 0 sort 0}\ndo_test where7-2.36.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n  }\n} {6 58 60 scan 0 sort 0}\ndo_test where7-2.37.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1059\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR c=4004\n         OR b=806\n  }\n} {10 11 12 43 scan 0 sort 0}\ndo_test where7-2.37.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1059\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR c=4004\n         OR b=806\n  }\n} {10 11 12 43 scan 0 sort 0}\ndo_test where7-2.38.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=165\n         OR b=201\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR a=32\n  }\n} {15 32 99 scan 0 sort 0}\ndo_test where7-2.38.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=165\n         OR b=201\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR a=32\n  }\n} {15 32 99 scan 0 sort 0}\ndo_test where7-2.39.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n  }\n} {22 48 69 74 100 scan 0 sort 0}\ndo_test where7-2.39.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n  }\n} {22 48 69 74 100 scan 0 sort 0}\ndo_test where7-2.40.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=352\n         OR b=278\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=660\n         OR a=18\n         OR a=34\n         OR b=132\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR c=18018\n  }\n} {2 12 18 28 30 32 34 52 53 54 60 80 89 90 92 scan 0 sort 0}\ndo_test where7-2.40.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=352\n         OR b=278\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=660\n         OR a=18\n         OR a=34\n         OR b=132\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR c=18018\n  }\n} {2 12 18 28 30 32 34 52 53 54 60 80 89 90 92 scan 0 sort 0}\ndo_test where7-2.41.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 73 scan 0 sort 0}\ndo_test where7-2.41.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 73 scan 0 sort 0}\ndo_test where7-2.42.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR b=297\n         OR b=113\n         OR b=176\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=67\n         OR c=26026\n  }\n} {3 14 16 21 27 29 55 67 75 76 77 78 81 83 scan 0 sort 0}\ndo_test where7-2.42.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR b=297\n         OR b=113\n         OR b=176\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=67\n         OR c=26026\n  }\n} {3 14 16 21 27 29 55 67 75 76 77 78 81 83 scan 0 sort 0}\ndo_test where7-2.43.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=83\n         OR b=44\n         OR b=1023\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=1023\n         OR f='ijklmnopq'\n  }\n} {4 6 8 11 13 34 60 78 83 86 93 scan 0 sort 0}\ndo_test where7-2.43.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=83\n         OR b=44\n         OR b=1023\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=1023\n         OR f='ijklmnopq'\n  }\n} {4 6 8 11 13 34 60 78 83 86 93 scan 0 sort 0}\ndo_test where7-2.44.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=935\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=487\n         OR b=619\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {17 32 34 39 42 85 scan 0 sort 0}\ndo_test where7-2.44.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=935\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=487\n         OR b=619\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {17 32 34 39 42 85 scan 0 sort 0}\ndo_test where7-2.45.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=938\n         OR b=641\n         OR c=17017\n         OR a=82\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n  }\n} {37 39 49 50 51 56 58 65 68 82 94 scan 0 sort 0}\ndo_test where7-2.45.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=938\n         OR b=641\n         OR c=17017\n         OR a=82\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n  }\n} {37 39 49 50 51 56 58 65 68 82 94 scan 0 sort 0}\ndo_test where7-2.46.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR c=22022\n  }\n} {64 65 66 79 scan 0 sort 0}\ndo_test where7-2.46.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR c=22022\n  }\n} {64 65 66 79 scan 0 sort 0}\ndo_test where7-2.47.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=7007\n         OR b=91\n         OR b=212\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR c=28028\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n  }\n} {19 20 21 65 82 83 84 scan 0 sort 0}\ndo_test where7-2.47.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=7007\n         OR b=91\n         OR b=212\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR c=28028\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n  }\n} {19 20 21 65 82 83 84 scan 0 sort 0}\ndo_test where7-2.48.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR a=51\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {12 28 30 51 scan 0 sort 0}\ndo_test where7-2.48.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR a=51\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {12 28 30 51 scan 0 sort 0}\ndo_test where7-2.49.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR c=4004\n         OR b=322\n         OR c=13013\n         OR a=6\n  }\n} {2 6 9 10 11 12 23 37 38 39 scan 0 sort 0}\ndo_test where7-2.49.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR c=4004\n         OR b=322\n         OR c=13013\n         OR a=6\n  }\n} {2 6 9 10 11 12 23 37 38 39 scan 0 sort 0}\ndo_test where7-2.50.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=297\n         OR b=143\n         OR a=46\n         OR b=660\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR b=355\n         OR a=93\n         OR b=297\n  }\n} {13 17 23 27 41 46 49 60 75 93 scan 0 sort 0}\ndo_test where7-2.50.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=297\n         OR b=143\n         OR a=46\n         OR b=660\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR b=355\n         OR a=93\n         OR b=297\n  }\n} {13 17 23 27 41 46 49 60 75 93 scan 0 sort 0}\ndo_test where7-2.51.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=190\n         OR a=62\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n  }\n} {62 99 scan 0 sort 0}\ndo_test where7-2.51.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=190\n         OR a=62\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n  }\n} {62 99 scan 0 sort 0}\ndo_test where7-2.52.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1089\n         OR b=102\n         OR a=6\n         OR b=608\n  }\n} {6 99 scan 0 sort 0}\ndo_test where7-2.52.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1089\n         OR b=102\n         OR a=6\n         OR b=608\n  }\n} {6 99 scan 0 sort 0}\ndo_test where7-2.53.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=473\n         OR b=1100\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=20\n         OR b=1089\n         OR b=330\n         OR b=124\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {15 20 30 43 53 56 58 99 100 scan 0 sort 0}\ndo_test where7-2.53.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=473\n         OR b=1100\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=20\n         OR b=1089\n         OR b=330\n         OR b=124\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {15 20 30 43 53 56 58 99 100 scan 0 sort 0}\ndo_test where7-2.54.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=223\n         OR a=12\n         OR b=1048\n         OR b=256\n         OR a=72\n         OR c>=34035\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=674\n         OR a=22\n  }\n} {12 22 35 68 70 72 scan 0 sort 0}\ndo_test where7-2.54.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=223\n         OR a=12\n         OR b=1048\n         OR b=256\n         OR a=72\n         OR c>=34035\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=674\n         OR a=22\n  }\n} {12 22 35 68 70 72 scan 0 sort 0}\ndo_test where7-2.55.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='yzabcdefg'\n         OR c=14014\n         OR a=1\n         OR a=9\n         OR b=960\n  }\n} {1 9 24 40 41 42 50 76 78 scan 0 sort 0}\ndo_test where7-2.55.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='yzabcdefg'\n         OR c=14014\n         OR a=1\n         OR a=9\n         OR b=960\n  }\n} {1 9 24 40 41 42 50 76 78 scan 0 sort 0}\ndo_test where7-2.56.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n  }\n} {19 49 96 98 scan 0 sort 0}\ndo_test where7-2.56.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n  }\n} {19 49 96 98 scan 0 sort 0}\ndo_test where7-2.57.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=748\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=630\n  }\n} {9 20 67 68 scan 0 sort 0}\ndo_test where7-2.57.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=748\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=630\n  }\n} {9 20 67 68 scan 0 sort 0}\ndo_test where7-2.58.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=223\n         OR b=267\n         OR a=40\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR c<=10\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR b=528\n  }\n} {40 48 55 57 69 71 scan 0 sort 0}\ndo_test where7-2.58.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=223\n         OR b=267\n         OR a=40\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR c<=10\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR b=528\n  }\n} {40 48 55 57 69 71 scan 0 sort 0}\ndo_test where7-2.59.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='rstuvwxyz'\n         OR a=41\n         OR b=462\n         OR a=68\n         OR a=84\n         OR a=69\n  }\n} {17 41 42 43 68 69 84 95 scan 0 sort 0}\ndo_test where7-2.59.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='rstuvwxyz'\n         OR a=41\n         OR b=462\n         OR a=68\n         OR a=84\n         OR a=69\n  }\n} {17 41 42 43 68 69 84 95 scan 0 sort 0}\ndo_test where7-2.60.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=979\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n  }\n} {3 5 13 89 scan 0 sort 0}\ndo_test where7-2.60.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=979\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n  }\n} {3 5 13 89 scan 0 sort 0}\ndo_test where7-2.61.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR a=8\n         OR a=62\n         OR b=726\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {8 9 10 14 50 52 59 61 62 66 scan 0 sort 0}\ndo_test where7-2.61.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR a=8\n         OR a=62\n         OR b=726\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {8 9 10 14 50 52 59 61 62 66 scan 0 sort 0}\ndo_test where7-2.62.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=495\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR b=924\n         OR c=11011\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=231\n         OR b=872\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {18 20 21 31 32 33 45 47 73 76 84 99 scan 0 sort 0}\ndo_test where7-2.62.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=495\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR b=924\n         OR c=11011\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=231\n         OR b=872\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {18 20 21 31 32 33 45 47 73 76 84 99 scan 0 sort 0}\ndo_test where7-2.63.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=24\n         OR b=473\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR b=509\n         OR b=924\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {21 24 43 84 86 96 scan 0 sort 0}\ndo_test where7-2.63.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=24\n         OR b=473\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR b=509\n         OR b=924\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {21 24 43 84 86 96 scan 0 sort 0}\ndo_test where7-2.64.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=363\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {2 5 8 23 25 28 33 34 54 56 58 60 80 86 93 100 scan 0 sort 0}\ndo_test where7-2.64.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=363\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {2 5 8 23 25 28 33 34 54 56 58 60 80 86 93 100 scan 0 sort 0}\ndo_test where7-2.65.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=42\n         OR e IS NULL\n         OR b=495\n         OR 1000000<b\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR a=45\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=85\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {20 42 45 46 65 69 72 85 98 scan 0 sort 0}\ndo_test where7-2.65.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=42\n         OR e IS NULL\n         OR b=495\n         OR 1000000<b\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR a=45\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=85\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {20 42 45 46 65 69 72 85 98 scan 0 sort 0}\ndo_test where7-2.66.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=17017\n         OR f='ijklmnopq'\n         OR a=39\n  }\n} {8 34 39 49 50 51 60 86 scan 0 sort 0}\ndo_test where7-2.66.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=17017\n         OR f='ijklmnopq'\n         OR a=39\n  }\n} {8 34 39 49 50 51 60 86 scan 0 sort 0}\ndo_test where7-2.67.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c>=34035\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=91\n  }\n} {11 19 27 37 63 89 91 96 98 100 scan 0 sort 0}\ndo_test where7-2.67.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c>=34035\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=91\n  }\n} {11 19 27 37 63 89 91 96 98 100 scan 0 sort 0}\ndo_test where7-2.68.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=649\n         OR b=231\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=58\n  }\n} {9 21 28 29 35 48 59 61 87 91 scan 0 sort 0}\ndo_test where7-2.68.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=649\n         OR b=231\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=58\n  }\n} {9 21 28 29 35 48 59 61 87 91 scan 0 sort 0}\ndo_test where7-2.69.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=979\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n  }\n} {78 89 scan 0 sort 0}\ndo_test where7-2.69.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=979\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n  }\n} {78 89 scan 0 sort 0}\ndo_test where7-2.70.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=825\n         OR b=1004\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {56 58 60 62 75 scan 0 sort 0}\ndo_test where7-2.70.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=825\n         OR b=1004\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {56 58 60 62 75 scan 0 sort 0}\ndo_test where7-2.71.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=65\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR c=22022\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR b=671\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=91\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR b=1004\n         OR b=960\n  }\n} {5 31 47 49 51 57 61 64 65 66 83 91 98 scan 0 sort 0}\ndo_test where7-2.71.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=65\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR c=22022\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR b=671\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=91\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR b=1004\n         OR b=960\n  }\n} {5 31 47 49 51 57 61 64 65 66 83 91 98 scan 0 sort 0}\ndo_test where7-2.72.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=762\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {56 58 93 scan 0 sort 0}\ndo_test where7-2.72.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=762\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {56 58 93 scan 0 sort 0}\ndo_test where7-2.73.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR a=14\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR b=212\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n  }\n} {11 14 23 54 78 85 scan 0 sort 0}\ndo_test where7-2.73.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR a=14\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR b=212\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n  }\n} {11 14 23 54 78 85 scan 0 sort 0}\ndo_test where7-2.74.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR b=168\n         OR b=25\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {66 79 89 scan 0 sort 0}\ndo_test where7-2.74.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR b=168\n         OR b=25\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {66 79 89 scan 0 sort 0}\ndo_test where7-2.75.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=28028\n         OR f='jklmnopqr'\n         OR b=1015\n  }\n} {9 35 61 82 83 84 87 scan 0 sort 0}\ndo_test where7-2.75.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=28028\n         OR f='jklmnopqr'\n         OR b=1015\n  }\n} {9 35 61 82 83 84 87 scan 0 sort 0}\ndo_test where7-2.76.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=31031\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=49\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n  }\n} {15 41 49 56 62 67 87 89 91 92 93 100 scan 0 sort 0}\ndo_test where7-2.76.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=31031\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=49\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n  }\n} {15 41 49 56 62 67 87 89 91 92 93 100 scan 0 sort 0}\ndo_test where7-2.77.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=80\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=971\n         OR a=60\n  }\n} {4 6 25 29 60 80 scan 0 sort 0}\ndo_test where7-2.77.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=80\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=971\n         OR a=60\n  }\n} {4 6 25 29 60 80 scan 0 sort 0}\ndo_test where7-2.78.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=1089\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {30 32 43 85 89 99 scan 0 sort 0}\ndo_test where7-2.78.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=1089\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {30 32 43 85 89 99 scan 0 sort 0}\ndo_test where7-2.79.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=399\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR a=10\n         OR b=1026\n  }\n} {9 10 11 57 90 scan 0 sort 0}\ndo_test where7-2.79.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=399\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR a=10\n         OR b=1026\n  }\n} {9 10 11 57 90 scan 0 sort 0}\ndo_test where7-2.80.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=465\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 43 65 76 scan 0 sort 0}\ndo_test where7-2.80.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=465\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 43 65 76 scan 0 sort 0}\ndo_test where7-2.81.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=25\n         OR b=792\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n  }\n} {19 25 45 71 72 97 scan 0 sort 0}\ndo_test where7-2.81.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=25\n         OR b=792\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n  }\n} {19 25 45 71 72 97 scan 0 sort 0}\ndo_test where7-2.82.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=979\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=13\n         OR a=15\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR a=27\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR a=32\n         OR a=39\n  }\n} {6 8 13 15 21 27 32 39 67 89 98 100 scan 0 sort 0}\ndo_test where7-2.82.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=979\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=13\n         OR a=15\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR a=27\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR a=32\n         OR a=39\n  }\n} {6 8 13 15 21 27 32 39 67 89 98 100 scan 0 sort 0}\ndo_test where7-2.83.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='hijklmnop'\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR b=528\n         OR c=30030\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n  }\n} {1 7 21 31 33 42 48 58 59 77 79 85 88 89 90 scan 0 sort 0}\ndo_test where7-2.83.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='hijklmnop'\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR b=528\n         OR c=30030\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n  }\n} {1 7 21 31 33 42 48 58 59 77 79 85 88 89 90 scan 0 sort 0}\ndo_test where7-2.84.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=69\n         OR e IS NULL\n         OR b=352\n         OR 1000000<b\n         OR b=289\n  }\n} {32 scan 0 sort 0}\ndo_test where7-2.84.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=69\n         OR e IS NULL\n         OR b=352\n         OR 1000000<b\n         OR b=289\n  }\n} {32 scan 0 sort 0}\ndo_test where7-2.85.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR b=748\n         OR b=696\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n  }\n} {4 30 43 56 67 68 82 scan 0 sort 0}\ndo_test where7-2.85.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR b=748\n         OR b=696\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n  }\n} {4 30 43 56 67 68 82 scan 0 sort 0}\ndo_test where7-2.86.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=87\n         OR a=80\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=784\n         OR a=49\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n  }\n} {34 36 40 49 68 71 73 80 87 scan 0 sort 0}\ndo_test where7-2.86.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=87\n         OR a=80\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=784\n         OR a=49\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n  }\n} {34 36 40 49 68 71 73 80 87 scan 0 sort 0}\ndo_test where7-2.87.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 14 AND 16) AND a!=15)\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR c=1001\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR c=33033\n  }\n} {1 2 3 8 9 14 16 78 85 86 97 98 99 scan 0 sort 0}\ndo_test where7-2.87.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 14 AND 16) AND a!=15)\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR c=1001\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR c=33033\n  }\n} {1 2 3 8 9 14 16 78 85 86 97 98 99 scan 0 sort 0}\ndo_test where7-2.88.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=311\n         OR b=1103\n         OR b=88\n  }\n} {8 scan 0 sort 0}\ndo_test where7-2.88.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=311\n         OR b=1103\n         OR b=88\n  }\n} {8 scan 0 sort 0}\ndo_test where7-2.89.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 65 AND 67) AND a!=66)\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR c=5005\n         OR b=1045\n         OR c=8008\n         OR f='bcdefghij'\n  }\n} {1 13 14 15 22 23 24 26 27 28 53 65 67 79 95 scan 0 sort 0}\ndo_test where7-2.89.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 65 AND 67) AND a!=66)\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR c=5005\n         OR b=1045\n         OR c=8008\n         OR f='bcdefghij'\n  }\n} {1 13 14 15 22 23 24 26 27 28 53 65 67 79 95 scan 0 sort 0}\ndo_test where7-2.90.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=66\n         OR b=553\n         OR a=64\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR a=62\n         OR b=1081\n         OR b=770\n         OR b=762\n         OR b=803\n         OR (g='srqponm' AND f GLOB 'efghi*')\n  }\n} {6 17 30 62 64 70 73 93 scan 0 sort 0}\ndo_test where7-2.90.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=66\n         OR b=553\n         OR a=64\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR a=62\n         OR b=1081\n         OR b=770\n         OR b=762\n         OR b=803\n         OR (g='srqponm' AND f GLOB 'efghi*')\n  }\n} {6 17 30 62 64 70 73 93 scan 0 sort 0}\ndo_test where7-2.91.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR c=17017\n         OR b=168\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {10 19 45 49 50 51 71 77 79 97 scan 0 sort 0}\ndo_test where7-2.91.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR c=17017\n         OR b=168\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {10 19 45 49 50 51 71 77 79 97 scan 0 sort 0}\ndo_test where7-2.92.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=34034\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR a=44\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=31031\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR b=619\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n  }\n} {3 12 23 29 31 44 55 68 78 81 91 92 93 100 scan 0 sort 0}\ndo_test where7-2.92.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=34034\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR a=44\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=31031\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR b=619\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n  }\n} {3 12 23 29 31 44 55 68 78 81 91 92 93 100 scan 0 sort 0}\ndo_test where7-2.93.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=48\n         OR c=15015\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=110\n         OR f='klmnopqrs'\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR b=674\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n  }\n} {10 36 43 44 45 48 52 62 65 67 88 94 96 97 99 scan 0 sort 0}\ndo_test where7-2.93.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=48\n         OR c=15015\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=110\n         OR f='klmnopqrs'\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR b=674\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n  }\n} {10 36 43 44 45 48 52 62 65 67 88 94 96 97 99 scan 0 sort 0}\ndo_test where7-2.94.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=72\n         OR b=913\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=121\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n  }\n} {2 11 28 72 83 scan 0 sort 0}\ndo_test where7-2.94.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=72\n         OR b=913\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=121\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n  }\n} {2 11 28 72 83 scan 0 sort 0}\ndo_test where7-2.95.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=18\n         OR b=286\n         OR b=1015\n         OR a=49\n         OR b=264\n  }\n} {18 24 26 49 scan 0 sort 0}\ndo_test where7-2.95.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=18\n         OR b=286\n         OR b=1015\n         OR a=49\n         OR b=264\n  }\n} {18 24 26 49 scan 0 sort 0}\ndo_test where7-2.96.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=69\n         OR a=11\n         OR c=1001\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR a=57\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n  }\n} {1 2 3 11 48 50 54 56 57 scan 0 sort 0}\ndo_test where7-2.96.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=69\n         OR a=11\n         OR c=1001\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR a=57\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n  }\n} {1 2 3 11 48 50 54 56 57 scan 0 sort 0}\ndo_test where7-2.97.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=231\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {21 84 scan 0 sort 0}\ndo_test where7-2.97.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=231\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {21 84 scan 0 sort 0}\ndo_test where7-2.98.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=25\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR b=289\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {3 5 17 23 81 83 85 87 scan 0 sort 0}\ndo_test where7-2.98.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=25\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR b=289\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {3 5 17 23 81 83 85 87 scan 0 sort 0}\ndo_test where7-2.99.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='defghijkl'\n         OR b=465\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR c=9009\n         OR b=990\n         OR b=132\n         OR a=35\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR a=81\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n  }\n} {3 12 25 26 27 29 35 46 55 71 73 78 81 90 scan 0 sort 0}\ndo_test where7-2.99.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='defghijkl'\n         OR b=465\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR c=9009\n         OR b=990\n         OR b=132\n         OR a=35\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR a=81\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n  }\n} {3 12 25 26 27 29 35 46 55 71 73 78 81 90 scan 0 sort 0}\ndo_test where7-2.100.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=26026\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR f='lmnopqrst'\n         OR a=6\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {6 9 11 37 59 61 63 76 77 78 89 scan 0 sort 0}\ndo_test where7-2.100.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=26026\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR f='lmnopqrst'\n         OR a=6\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {6 9 11 37 59 61 63 76 77 78 89 scan 0 sort 0}\ndo_test where7-2.101.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n  }\n} {7 98 100 scan 0 sort 0}\ndo_test where7-2.101.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n  }\n} {7 98 100 scan 0 sort 0}\ndo_test where7-2.102.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=11011\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=630\n         OR c=19019\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR a=24\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {24 31 32 33 51 53 55 56 57 89 95 scan 0 sort 0}\ndo_test where7-2.102.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=11011\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=630\n         OR c=19019\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR a=24\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {24 31 32 33 51 53 55 56 57 89 95 scan 0 sort 0}\ndo_test where7-2.103.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=993\n         OR a=81\n         OR b=366\n         OR b=69\n  }\n} {81 91 93 scan 0 sort 0}\ndo_test where7-2.103.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=993\n         OR a=81\n         OR b=366\n         OR b=69\n  }\n} {81 91 93 scan 0 sort 0}\ndo_test where7-2.104.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='stuvwxyza'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=1037\n         OR f='zabcdefgh'\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {1 3 18 24 25 44 50 51 70 76 77 90 96 scan 0 sort 0}\ndo_test where7-2.104.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='stuvwxyza'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=1037\n         OR f='zabcdefgh'\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {1 3 18 24 25 44 50 51 70 76 77 90 96 scan 0 sort 0}\ndo_test where7-2.105.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n  }\n} {4 6 30 32 scan 0 sort 0}\ndo_test where7-2.105.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n  }\n} {4 6 30 32 scan 0 sort 0}\ndo_test where7-2.106.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=847\n         OR b=190\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=704\n  }\n} {9 23 35 38 40 61 64 70 72 77 87 scan 0 sort 0}\ndo_test where7-2.106.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=847\n         OR b=190\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=704\n  }\n} {9 23 35 38 40 61 64 70 72 77 87 scan 0 sort 0}\ndo_test where7-2.107.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=88\n         OR f='vwxyzabcd'\n         OR f='fghijklmn'\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n  }\n} {5 8 21 31 47 57 73 83 89 99 scan 0 sort 0}\ndo_test where7-2.107.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=88\n         OR f='vwxyzabcd'\n         OR f='fghijklmn'\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n  }\n} {5 8 21 31 47 57 73 83 89 99 scan 0 sort 0}\ndo_test where7-2.108.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=498\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR a=1\n  }\n} {1 69 scan 0 sort 0}\ndo_test where7-2.108.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=498\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR a=1\n  }\n} {1 69 scan 0 sort 0}\ndo_test where7-2.109.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR a=5\n         OR b=179\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR a=69\n  }\n} {5 17 43 47 49 69 95 scan 0 sort 0}\ndo_test where7-2.109.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR a=5\n         OR b=179\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR a=69\n  }\n} {5 17 43 47 49 69 95 scan 0 sort 0}\ndo_test where7-2.110.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=971\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=828\n         OR a=81\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=627\n         OR b=355\n         OR b=377\n         OR a=44\n  }\n} {1 7 23 25 44 57 81 scan 0 sort 0}\ndo_test where7-2.110.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=971\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=828\n         OR a=81\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=627\n         OR b=355\n         OR b=377\n         OR a=44\n  }\n} {1 7 23 25 44 57 81 scan 0 sort 0}\ndo_test where7-2.111.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=850\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n  }\n} {6 8 scan 0 sort 0}\ndo_test where7-2.111.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=850\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n  }\n} {6 8 scan 0 sort 0}\ndo_test where7-2.112.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {17 43 66 69 95 scan 0 sort 0}\ndo_test where7-2.112.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {17 43 66 69 95 scan 0 sort 0}\ndo_test where7-2.113.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=726\n         OR b=740\n         OR a=33\n         OR c=8008\n         OR f='rstuvwxyz'\n         OR b=168\n  }\n} {17 22 23 24 33 43 66 69 95 scan 0 sort 0}\ndo_test where7-2.113.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=726\n         OR b=740\n         OR a=33\n         OR c=8008\n         OR f='rstuvwxyz'\n         OR b=168\n  }\n} {17 22 23 24 33 43 66 69 95 scan 0 sort 0}\ndo_test where7-2.114.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=396\n  }\n} {17 19 36 scan 0 sort 0}\ndo_test where7-2.114.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=396\n  }\n} {17 19 36 scan 0 sort 0}\ndo_test where7-2.115.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=77\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n         OR c<=10\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 48 50 77 scan 0 sort 0}\ndo_test where7-2.115.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=77\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n         OR c<=10\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 48 50 77 scan 0 sort 0}\ndo_test where7-2.116.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=253\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=396\n         OR b=630\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR c=3003\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {1 7 8 9 12 13 14 15 20 22 23 27 36 49 53 79 scan 0 sort 0}\ndo_test where7-2.116.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=253\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=396\n         OR b=630\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR c=3003\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {1 7 8 9 12 13 14 15 20 22 23 27 36 49 53 79 scan 0 sort 0}\ndo_test where7-2.117.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=957\n         OR b=242\n         OR b=113\n         OR b=957\n         OR b=311\n         OR b=143\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n  }\n} {9 10 13 22 35 48 61 87 scan 0 sort 0}\ndo_test where7-2.117.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=957\n         OR b=242\n         OR b=113\n         OR b=957\n         OR b=311\n         OR b=143\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n  }\n} {9 10 13 22 35 48 61 87 scan 0 sort 0}\ndo_test where7-2.118.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n         OR b=451\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {41 66 74 76 94 96 scan 0 sort 0}\ndo_test where7-2.118.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n         OR b=451\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {41 66 74 76 94 96 scan 0 sort 0}\ndo_test where7-2.119.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR b=451\n         OR b=363\n         OR b=330\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n  }\n} {3 30 33 41 52 54 81 83 89 scan 0 sort 0}\ndo_test where7-2.119.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR b=451\n         OR b=363\n         OR b=330\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n  }\n} {3 30 33 41 52 54 81 83 89 scan 0 sort 0}\ndo_test where7-2.120.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR e IS NULL\n         OR b=759\n  }\n} {15 68 69 95 scan 0 sort 0}\ndo_test where7-2.120.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR e IS NULL\n         OR b=759\n  }\n} {15 68 69 95 scan 0 sort 0}\ndo_test where7-2.121.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {19 21 45 71 74 97 scan 0 sort 0}\ndo_test where7-2.121.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {19 21 45 71 74 97 scan 0 sort 0}\ndo_test where7-2.122.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1037\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n  }\n} {27 43 45 47 75 77 82 scan 0 sort 0}\ndo_test where7-2.122.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1037\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n  }\n} {27 43 45 47 75 77 82 scan 0 sort 0}\ndo_test where7-2.123.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1045\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR c=12012\n  }\n} {34 35 36 37 38 39 95 scan 0 sort 0}\ndo_test where7-2.123.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1045\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR c=12012\n  }\n} {34 35 36 37 38 39 95 scan 0 sort 0}\ndo_test where7-2.124.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR b=421\n         OR b=429\n         OR b=498\n         OR b=33\n         OR b=198\n         OR c=14014\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n  }\n} {3 18 23 39 40 41 42 49 75 97 scan 0 sort 0}\ndo_test where7-2.124.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR b=421\n         OR b=429\n         OR b=498\n         OR b=33\n         OR b=198\n         OR c=14014\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n  }\n} {3 18 23 39 40 41 42 49 75 97 scan 0 sort 0}\ndo_test where7-2.125.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=47\n         OR c=31031\n         OR a=38\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR b=242\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR b=352\n         OR a=49\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {8 22 31 32 34 38 49 57 60 70 86 91 92 93 scan 0 sort 0}\ndo_test where7-2.125.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=47\n         OR c=31031\n         OR a=38\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR b=242\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR b=352\n         OR a=49\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {8 22 31 32 34 38 49 57 60 70 86 91 92 93 scan 0 sort 0}\ndo_test where7-2.126.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=704\n         OR a=7\n         OR a=8\n         OR a=46\n         OR b=740\n         OR b=993\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {7 8 38 46 64 87 scan 0 sort 0}\ndo_test where7-2.126.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=704\n         OR a=7\n         OR a=8\n         OR a=46\n         OR b=740\n         OR b=993\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {7 8 38 46 64 87 scan 0 sort 0}\ndo_test where7-2.127.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=32032\n         OR a=76\n  }\n} {62 64 76 94 95 96 scan 0 sort 0}\ndo_test where7-2.127.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=32032\n         OR a=76\n  }\n} {62 64 76 94 95 96 scan 0 sort 0}\ndo_test where7-2.128.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=528\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {19 48 91 scan 0 sort 0}\ndo_test where7-2.128.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=528\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {19 48 91 scan 0 sort 0}\ndo_test where7-2.129.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=65\n  }\n} {26 65 97 scan 0 sort 0}\ndo_test where7-2.129.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=65\n  }\n} {26 65 97 scan 0 sort 0}\ndo_test where7-2.130.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR 1000000<b\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR a=24\n  }\n} {2 24 50 71 scan 0 sort 0}\ndo_test where7-2.130.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR 1000000<b\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR a=24\n  }\n} {2 24 50 71 scan 0 sort 0}\ndo_test where7-2.131.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=60\n         OR a=39\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=36\n         OR b=814\n         OR a=14\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=440\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n  }\n} {5 14 25 39 40 51 60 61 74 77 93 95 scan 0 sort 0}\ndo_test where7-2.131.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=60\n         OR a=39\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=36\n         OR b=814\n         OR a=14\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=440\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n  }\n} {5 14 25 39 40 51 60 61 74 77 93 95 scan 0 sort 0}\ndo_test where7-2.132.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f IS NULL\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {39 41 scan 0 sort 0}\ndo_test where7-2.132.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f IS NULL\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {39 41 scan 0 sort 0}\ndo_test where7-2.133.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=44\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {4 17 19 scan 0 sort 0}\ndo_test where7-2.133.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=44\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {4 17 19 scan 0 sort 0}\ndo_test where7-2.134.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR a=82\n  }\n} {80 82 scan 0 sort 0}\ndo_test where7-2.134.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR a=82\n  }\n} {80 82 scan 0 sort 0}\ndo_test where7-2.135.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR c=24024\n         OR b=946\n         OR a=19\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n  }\n} {19 47 70 71 72 84 86 scan 0 sort 0}\ndo_test where7-2.135.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR c=24024\n         OR b=946\n         OR a=19\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n  }\n} {19 47 70 71 72 84 86 scan 0 sort 0}\ndo_test where7-2.136.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=27\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=1045\n         OR a=84\n         OR f='qrstuvwxy'\n  }\n} {16 19 27 42 45 68 71 82 84 89 91 94 95 97 scan 0 sort 0}\ndo_test where7-2.136.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=27\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=1045\n         OR a=84\n         OR f='qrstuvwxy'\n  }\n} {16 19 27 42 45 68 71 82 84 89 91 94 95 97 scan 0 sort 0}\ndo_test where7-2.137.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=704\n         OR b=949\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR c=24024\n         OR b=553\n         OR a=18\n         OR a=92\n  }\n} {18 22 64 70 71 72 92 scan 0 sort 0}\ndo_test where7-2.137.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=704\n         OR b=949\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR c=24024\n         OR b=553\n         OR a=18\n         OR a=92\n  }\n} {18 22 64 70 71 72 92 scan 0 sort 0}\ndo_test where7-2.138.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=902\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=25\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR f='zabcdefgh'\n         OR b=385\n  }\n} {1 16 18 25 27 35 51 53 61 77 79 82 scan 0 sort 0}\ndo_test where7-2.138.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=902\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=25\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR f='zabcdefgh'\n         OR b=385\n  }\n} {1 16 18 25 27 35 51 53 61 77 79 82 scan 0 sort 0}\ndo_test where7-2.139.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=22\n         OR b=36\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n  }\n} {22 31 57 59 81 83 scan 0 sort 0}\ndo_test where7-2.139.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=22\n         OR b=36\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n  }\n} {22 31 57 59 81 83 scan 0 sort 0}\ndo_test where7-2.140.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=253\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {23 60 scan 0 sort 0}\ndo_test where7-2.140.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=253\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {23 60 scan 0 sort 0}\ndo_test where7-2.141.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=641\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {1 15 27 36 38 41 53 67 79 93 scan 0 sort 0}\ndo_test where7-2.141.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=641\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {1 15 27 36 38 41 53 67 79 93 scan 0 sort 0}\ndo_test where7-2.142.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=30030\n         OR a=18\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=11\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=52\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=13\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {1 13 18 22 40 44 46 52 65 88 89 90 scan 0 sort 0}\ndo_test where7-2.142.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=30030\n         OR a=18\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=11\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=52\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=13\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {1 13 18 22 40 44 46 52 65 88 89 90 scan 0 sort 0}\ndo_test where7-2.143.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=23023\n         OR f='efghijklm'\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=1045\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {4 20 24 30 39 41 46 50 56 67 68 69 72 76 82 95 98 scan 0 sort 0}\ndo_test where7-2.143.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=23023\n         OR f='efghijklm'\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=1045\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {4 20 24 30 39 41 46 50 56 67 68 69 72 76 82 95 98 scan 0 sort 0}\ndo_test where7-2.144.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=476\n         OR a=11\n         OR a=52\n         OR b=858\n         OR b=264\n         OR f='wxyzabcde'\n         OR c=18018\n         OR b=597\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {11 22 24 48 52 53 54 69 74 78 100 scan 0 sort 0}\ndo_test where7-2.144.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=476\n         OR a=11\n         OR a=52\n         OR b=858\n         OR b=264\n         OR f='wxyzabcde'\n         OR c=18018\n         OR b=597\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {11 22 24 48 52 53 54 69 74 78 100 scan 0 sort 0}\ndo_test where7-2.145.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=91\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR b=102\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR b=784\n  }\n} {12 21 22 36 59 61 85 89 91 scan 0 sort 0}\ndo_test where7-2.145.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=91\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR b=102\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR b=784\n  }\n} {12 21 22 36 59 61 85 89 91 scan 0 sort 0}\ndo_test where7-2.146.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=990\n         OR a=52\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {14 38 52 90 91 scan 0 sort 0}\ndo_test where7-2.146.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=990\n         OR a=52\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {14 38 52 90 91 scan 0 sort 0}\ndo_test where7-2.147.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=22022\n         OR b=960\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=48\n         OR b=729\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR a=44\n         OR b=773\n  }\n} {41 43 44 45 48 64 65 66 scan 0 sort 0}\ndo_test where7-2.147.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=22022\n         OR b=960\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=48\n         OR b=729\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR a=44\n         OR b=773\n  }\n} {41 43 44 45 48 64 65 66 scan 0 sort 0}\ndo_test where7-2.148.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=421\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR c=22022\n         OR b=825\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n  }\n} {2 6 17 19 22 24 29 32 58 64 65 66 68 70 75 84 89 scan 0 sort 0}\ndo_test where7-2.148.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=421\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR c=22022\n         OR b=825\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n  }\n} {2 6 17 19 22 24 29 32 58 64 65 66 68 70 75 84 89 scan 0 sort 0}\ndo_test where7-2.149.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=484\n         OR b=1026\n         OR a=90\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=608\n         OR a=32\n  }\n} {32 44 74 90 scan 0 sort 0}\ndo_test where7-2.149.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=484\n         OR b=1026\n         OR a=90\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=608\n         OR a=32\n  }\n} {32 44 74 90 scan 0 sort 0}\ndo_test where7-2.150.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c<=10\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR b=154\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=880\n         OR a=55\n         OR b=773\n         OR b=319\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {14 29 55 76 77 80 83 scan 0 sort 0}\ndo_test where7-2.150.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c<=10\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR b=154\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=880\n         OR a=55\n         OR b=773\n         OR b=319\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {14 29 55 76 77 80 83 scan 0 sort 0}\ndo_test where7-2.151.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR f='mnopqrstu'\n         OR a=62\n  }\n} {8 12 38 62 64 90 scan 0 sort 0}\ndo_test where7-2.151.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR f='mnopqrstu'\n         OR a=62\n  }\n} {8 12 38 62 64 90 scan 0 sort 0}\ndo_test where7-2.152.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=33\n         OR b=1045\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR c=13013\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR b=124\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {33 37 38 39 40 88 90 95 scan 0 sort 0}\ndo_test where7-2.152.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=33\n         OR b=1045\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR c=13013\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR b=124\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {33 37 38 39 40 88 90 95 scan 0 sort 0}\ndo_test where7-2.153.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=883\n         OR c=32032\n         OR f='fghijklmn'\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=421\n         OR b=803\n         OR c=4004\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n  }\n} {2 5 10 11 12 28 31 49 51 54 57 73 80 83 94 95 96 scan 0 sort 0}\ndo_test where7-2.153.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=883\n         OR c=32032\n         OR f='fghijklmn'\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=421\n         OR b=803\n         OR c=4004\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n  }\n} {2 5 10 11 12 28 31 49 51 54 57 73 80 83 94 95 96 scan 0 sort 0}\ndo_test where7-2.154.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=99\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {9 16 42 68 72 94 scan 0 sort 0}\ndo_test where7-2.154.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=99\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {9 16 42 68 72 94 scan 0 sort 0}\ndo_test where7-2.155.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='defghijkl'\n         OR b=308\n  }\n} {3 28 29 55 81 scan 0 sort 0}\ndo_test where7-2.155.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='defghijkl'\n         OR b=308\n  }\n} {3 28 29 55 81 scan 0 sort 0}\ndo_test where7-2.156.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=795\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR f='jklmnopqr'\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=1056\n  }\n} {2 9 28 35 51 54 61 80 87 96 scan 0 sort 0}\ndo_test where7-2.156.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=795\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR f='jklmnopqr'\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=1056\n  }\n} {2 9 28 35 51 54 61 80 87 96 scan 0 sort 0}\ndo_test where7-2.157.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=47\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=410\n         OR b=682\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR f='hijklmnop'\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=168\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR a=32\n         OR a=72\n  }\n} {7 32 33 40 47 51 59 62 72 85 94 98 100 scan 0 sort 0}\ndo_test where7-2.157.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=47\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=410\n         OR b=682\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR f='hijklmnop'\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=168\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR a=32\n         OR a=72\n  }\n} {7 32 33 40 47 51 59 62 72 85 94 98 100 scan 0 sort 0}\ndo_test where7-2.158.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=616\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=96\n  }\n} {25 27 38 56 96 scan 0 sort 0}\ndo_test where7-2.158.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=616\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=96\n  }\n} {25 27 38 56 96 scan 0 sort 0}\ndo_test where7-2.159.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=352\n  }\n} {32 66 scan 0 sort 0}\ndo_test where7-2.159.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=352\n  }\n} {32 66 scan 0 sort 0}\ndo_test where7-2.160.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=795\n         OR c=13013\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=597\n  }\n} {28 37 38 39 scan 0 sort 0}\ndo_test where7-2.160.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=795\n         OR c=13013\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=597\n  }\n} {28 37 38 39 scan 0 sort 0}\ndo_test where7-2.161.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=23\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=641\n         OR b=352\n         OR b=179\n         OR b=806\n         OR b=839\n         OR b=33\n  }\n} {3 23 32 68 scan 0 sort 0}\ndo_test where7-2.161.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=23\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=641\n         OR b=352\n         OR b=179\n         OR b=806\n         OR b=839\n         OR b=33\n  }\n} {3 23 32 68 scan 0 sort 0}\ndo_test where7-2.162.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1070\n         OR b=1078\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR c=12012\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR b=319\n         OR c=5005\n         OR 1000000<b\n         OR b=1037\n         OR b=234\n  }\n} {11 13 14 15 29 34 35 36 84 98 scan 0 sort 0}\ndo_test where7-2.162.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1070\n         OR b=1078\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR c=12012\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR b=319\n         OR c=5005\n         OR 1000000<b\n         OR b=1037\n         OR b=234\n  }\n} {11 13 14 15 29 34 35 36 84 98 scan 0 sort 0}\ndo_test where7-2.163.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='cdefghijk'\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {2 17 28 43 54 59 69 80 81 95 scan 0 sort 0}\ndo_test where7-2.163.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='cdefghijk'\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {2 17 28 43 54 59 69 80 81 95 scan 0 sort 0}\ndo_test where7-2.164.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=65\n         OR c=14014\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=47\n         OR b=220\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n  }\n} {20 37 40 41 42 47 65 88 scan 0 sort 0}\ndo_test where7-2.164.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=65\n         OR c=14014\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=47\n         OR b=220\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n  }\n} {20 37 40 41 42 47 65 88 scan 0 sort 0}\ndo_test where7-2.165.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=891\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR b=484\n         OR a=62\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n  }\n} {35 44 57 62 81 86 scan 0 sort 0}\ndo_test where7-2.165.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=891\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR b=484\n         OR a=62\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n  }\n} {35 44 57 62 81 86 scan 0 sort 0}\ndo_test where7-2.166.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=363\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR a=39\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {2 10 25 33 39 46 54 58 60 scan 0 sort 0}\ndo_test where7-2.166.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=363\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR a=39\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {2 10 25 33 39 46 54 58 60 scan 0 sort 0}\ndo_test where7-2.167.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=30030\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=850\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {20 46 52 72 88 89 90 98 scan 0 sort 0}\ndo_test where7-2.167.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=30030\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=850\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {20 46 52 72 88 89 90 98 scan 0 sort 0}\ndo_test where7-2.168.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=80\n  }\n} {23 91 scan 0 sort 0}\ndo_test where7-2.168.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=80\n  }\n} {23 91 scan 0 sort 0}\ndo_test where7-2.169.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=462\n         OR a=51\n         OR b=344\n         OR b=333\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n  }\n} {42 51 59 61 63 77 scan 0 sort 0}\ndo_test where7-2.169.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=462\n         OR a=51\n         OR b=344\n         OR b=333\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n  }\n} {42 51 59 61 63 77 scan 0 sort 0}\ndo_test where7-2.170.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=586\n         OR a=21\n         OR b=638\n  }\n} {21 58 scan 0 sort 0}\ndo_test where7-2.170.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=586\n         OR a=21\n         OR b=638\n  }\n} {21 58 scan 0 sort 0}\ndo_test where7-2.171.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=179\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n  }\n} {2 4 13 40 42 72 74 scan 0 sort 0}\ndo_test where7-2.171.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=179\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n  }\n} {2 4 13 40 42 72 74 scan 0 sort 0}\ndo_test where7-2.172.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=333\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=407\n         OR a=5\n         OR b=817\n         OR b=891\n  }\n} {5 37 53 62 81 scan 0 sort 0}\ndo_test where7-2.172.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=333\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=407\n         OR a=5\n         OR b=817\n         OR b=891\n  }\n} {5 37 53 62 81 scan 0 sort 0}\ndo_test where7-2.173.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b<0\n         OR b=352\n         OR b=517\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR b=1012\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n  }\n} {11 12 13 14 32 47 92 97 scan 0 sort 0}\ndo_test where7-2.173.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b<0\n         OR b=352\n         OR b=517\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR b=1012\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n  }\n} {11 12 13 14 32 47 92 97 scan 0 sort 0}\ndo_test where7-2.174.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c<=10\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR a=32\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR d<0.0\n  }\n} {12 14 32 41 scan 0 sort 0}\ndo_test where7-2.174.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c<=10\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR a=32\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR d<0.0\n  }\n} {12 14 32 41 scan 0 sort 0}\ndo_test where7-2.175.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=1045\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=26\n         OR (g='gfedcba' AND f GLOB 'opqrs*')\n  }\n} {20 22 26 78 92 95 scan 0 sort 0}\ndo_test where7-2.175.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=1045\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=26\n         OR (g='gfedcba' AND f GLOB 'opqrs*')\n  }\n} {20 22 26 78 92 95 scan 0 sort 0}\ndo_test where7-2.176.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=49\n         OR b=58\n  }\n} {49 scan 0 sort 0}\ndo_test where7-2.176.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=49\n         OR b=58\n  }\n} {49 scan 0 sort 0}\ndo_test where7-2.177.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR c=32032\n         OR b=289\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {3 14 16 17 19 75 94 95 96 scan 0 sort 0}\ndo_test where7-2.177.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR c=32032\n         OR b=289\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {3 14 16 17 19 75 94 95 96 scan 0 sort 0}\ndo_test where7-2.178.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 15 AND 17) AND a!=16)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR b=33\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {3 15 17 43 57 59 69 95 scan 0 sort 0}\ndo_test where7-2.178.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 15 AND 17) AND a!=16)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR b=33\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {3 15 17 43 57 59 69 95 scan 0 sort 0}\ndo_test where7-2.179.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=828\n         OR b=341\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=902\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=242\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n  }\n} {1 2 16 22 31 42 64 66 68 82 91 94 95 scan 0 sort 0}\ndo_test where7-2.179.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=828\n         OR b=341\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=902\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=242\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n  }\n} {1 2 16 22 31 42 64 66 68 82 91 94 95 scan 0 sort 0}\ndo_test where7-2.180.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=982\n         OR b=781\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR d>1e10\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n  }\n} {56 66 68 71 scan 0 sort 0}\ndo_test where7-2.180.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=982\n         OR b=781\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR d>1e10\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n  }\n} {56 66 68 71 scan 0 sort 0}\ndo_test where7-2.181.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=31\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR a=76\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=176\n  }\n} {8 16 23 31 34 57 59 60 69 74 76 86 scan 0 sort 0}\ndo_test where7-2.181.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=31\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR a=76\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=176\n  }\n} {8 16 23 31 34 57 59 60 69 74 76 86 scan 0 sort 0}\ndo_test where7-2.182.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=14\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR f='zabcdefgh'\n  }\n} {12 25 47 51 55 59 60 61 77 88 90 scan 0 sort 0}\ndo_test where7-2.182.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=14\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR f='zabcdefgh'\n  }\n} {12 25 47 51 55 59 60 61 77 88 90 scan 0 sort 0}\ndo_test where7-2.183.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR b=286\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=91\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {25 26 31 43 45 scan 0 sort 0}\ndo_test where7-2.183.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR b=286\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=91\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {25 26 31 43 45 scan 0 sort 0}\ndo_test where7-2.184.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR c=19019\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR b=374\n  }\n} {22 34 48 55 56 57 65 74 100 scan 0 sort 0}\ndo_test where7-2.184.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR c=19019\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR b=374\n  }\n} {22 34 48 55 56 57 65 74 100 scan 0 sort 0}\ndo_test where7-2.185.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE g IS NULL\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n  }\n} {48 scan 0 sort 0}\ndo_test where7-2.185.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE g IS NULL\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n  }\n} {48 scan 0 sort 0}\ndo_test where7-2.186.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=4\n         OR b=407\n  }\n} {4 37 scan 0 sort 0}\ndo_test where7-2.186.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=4\n         OR b=407\n  }\n} {4 37 scan 0 sort 0}\ndo_test where7-2.187.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=564\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=234\n         OR b=641\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR a=98\n  }\n} {1 5 12 13 27 39 53 65 66 68 79 91 98 scan 0 sort 0}\ndo_test where7-2.187.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=564\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=234\n         OR b=641\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR a=98\n  }\n} {1 5 12 13 27 39 53 65 66 68 79 91 98 scan 0 sort 0}\ndo_test where7-2.188.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=73\n         OR b=44\n         OR b=539\n         OR c=11011\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=69\n         OR b=1001\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n  }\n} {4 23 26 31 32 33 34 49 73 81 91 95 scan 0 sort 0}\ndo_test where7-2.188.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=73\n         OR b=44\n         OR b=539\n         OR c=11011\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=69\n         OR b=1001\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n  }\n} {4 23 26 31 32 33 34 49 73 81 91 95 scan 0 sort 0}\ndo_test where7-2.189.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=264\n         OR b=143\n         OR a=48\n  }\n} {13 24 48 scan 0 sort 0}\ndo_test where7-2.189.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=264\n         OR b=143\n         OR a=48\n  }\n} {13 24 48 scan 0 sort 0}\ndo_test where7-2.190.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1001\n         OR b=1070\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR b=14\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR a=66\n  }\n} {18 56 58 66 72 74 91 scan 0 sort 0}\ndo_test where7-2.190.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1001\n         OR b=1070\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR b=14\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR a=66\n  }\n} {18 56 58 66 72 74 91 scan 0 sort 0}\ndo_test where7-2.191.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=23023\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR a=66\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=51\n         OR a=23\n         OR c=4004\n  }\n} {10 11 12 23 51 66 67 68 69 83 scan 0 sort 0}\ndo_test where7-2.191.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=23023\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR a=66\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=51\n         OR a=23\n         OR c=4004\n  }\n} {10 11 12 23 51 66 67 68 69 83 scan 0 sort 0}\ndo_test where7-2.192.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=36\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR a=80\n  }\n} {37 80 scan 0 sort 0}\ndo_test where7-2.192.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=36\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR a=80\n  }\n} {37 80 scan 0 sort 0}\ndo_test where7-2.193.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=55\n         OR f='efghijklm'\n         OR a=8\n         OR a=80\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=256\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {4 8 30 34 37 39 55 56 60 72 80 82 86 scan 0 sort 0}\ndo_test where7-2.193.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=55\n         OR f='efghijklm'\n         OR a=8\n         OR a=80\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=256\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {4 8 30 34 37 39 55 56 60 72 80 82 86 scan 0 sort 0}\ndo_test where7-2.194.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=836\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=91\n         OR b=594\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {2 8 28 47 54 76 80 87 91 scan 0 sort 0}\ndo_test where7-2.194.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=836\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=91\n         OR b=594\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {2 8 28 47 54 76 80 87 91 scan 0 sort 0}\ndo_test where7-2.195.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=6006\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {12 16 17 18 24 43 50 52 62 64 88 90 scan 0 sort 0}\ndo_test where7-2.195.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=6006\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {12 16 17 18 24 43 50 52 62 64 88 90 scan 0 sort 0}\ndo_test where7-2.196.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 83 AND 85) AND a!=84)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR a=13\n         OR b=121\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR b=660\n         OR b=792\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n  }\n} {6 11 12 13 14 16 18 44 60 72 83 85 scan 0 sort 0}\ndo_test where7-2.196.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 83 AND 85) AND a!=84)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR a=13\n         OR b=121\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR b=660\n         OR b=792\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n  }\n} {6 11 12 13 14 16 18 44 60 72 83 85 scan 0 sort 0}\ndo_test where7-2.197.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1089\n         OR b=495\n         OR b=157\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR f='wxyzabcde'\n  }\n} {1 7 20 22 45 46 48 59 72 74 98 99 100 scan 0 sort 0}\ndo_test where7-2.197.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1089\n         OR b=495\n         OR b=157\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR f='wxyzabcde'\n  }\n} {1 7 20 22 45 46 48 59 72 74 98 99 100 scan 0 sort 0}\ndo_test where7-2.198.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='bcdefghij'\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR b=157\n         OR b=267\n         OR c=34034\n  }\n} {1 27 32 40 42 53 79 100 scan 0 sort 0}\ndo_test where7-2.198.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='bcdefghij'\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR b=157\n         OR b=267\n         OR c=34034\n  }\n} {1 27 32 40 42 53 79 100 scan 0 sort 0}\ndo_test where7-2.199.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=19\n         OR a=23\n         OR c<=10\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {19 23 66 scan 0 sort 0}\ndo_test where7-2.199.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=19\n         OR a=23\n         OR c<=10\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {19 23 66 scan 0 sort 0}\ndo_test where7-2.200.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=792\n         OR b=803\n         OR b=36\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 3 27 53 72 73 79 scan 0 sort 0}\ndo_test where7-2.200.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=792\n         OR b=803\n         OR b=36\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 3 27 53 72 73 79 scan 0 sort 0}\ndo_test where7-2.201.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR f='jklmnopqr'\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR b=891\n         OR a=40\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n  }\n} {9 20 35 40 50 61 67 71 73 76 78 81 87 scan 0 sort 0}\ndo_test where7-2.201.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR f='jklmnopqr'\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR b=891\n         OR a=40\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n  }\n} {9 20 35 40 50 61 67 71 73 76 78 81 87 scan 0 sort 0}\ndo_test where7-2.202.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=32\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=95\n         OR d>1e10\n         OR b=429\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR c=10010\n         OR ((a BETWEEN 83 AND 85) AND a!=84)\n  }\n} {15 28 29 30 32 39 54 76 83 85 88 95 scan 0 sort 0}\ndo_test where7-2.202.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=32\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=95\n         OR d>1e10\n         OR b=429\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR c=10010\n         OR ((a BETWEEN 83 AND 85) AND a!=84)\n  }\n} {15 28 29 30 32 39 54 76 83 85 88 95 scan 0 sort 0}\ndo_test where7-2.203.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'defgh*')\n         OR a=22\n         OR a=26\n         OR a=81\n         OR a=53\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR c=30030\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=82\n         OR b=594\n  }\n} {3 8 22 26 53 54 81 82 88 89 90 92 94 scan 0 sort 0}\ndo_test where7-2.203.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'defgh*')\n         OR a=22\n         OR a=26\n         OR a=81\n         OR a=53\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR c=30030\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=82\n         OR b=594\n  }\n} {3 8 22 26 53 54 81 82 88 89 90 92 94 scan 0 sort 0}\ndo_test where7-2.204.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 34 AND 36) AND a!=35)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR a=83\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=1092\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR b=25\n  }\n} {12 30 34 36 57 68 83 86 99 scan 0 sort 0}\ndo_test where7-2.204.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 34 AND 36) AND a!=35)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR a=83\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=1092\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR b=25\n  }\n} {12 30 34 36 57 68 83 86 99 scan 0 sort 0}\ndo_test where7-2.205.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=20\n         OR b=421\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR a=50\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {5 20 40 50 53 scan 0 sort 0}\ndo_test where7-2.205.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=20\n         OR b=421\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR a=50\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {5 20 40 50 53 scan 0 sort 0}\ndo_test where7-2.206.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=960\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {13 39 65 91 scan 0 sort 0}\ndo_test where7-2.206.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=960\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {13 39 65 91 scan 0 sort 0}\ndo_test where7-2.207.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=891\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR f='nopqrstuv'\n  }\n} {13 31 39 65 81 91 scan 0 sort 0}\ndo_test where7-2.207.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=891\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR f='nopqrstuv'\n  }\n} {13 31 39 65 81 91 scan 0 sort 0}\ndo_test where7-2.208.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=157\n         OR b=289\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=1001\n         OR b=707\n  }\n} {32 34 91 scan 0 sort 0}\ndo_test where7-2.208.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=157\n         OR b=289\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=1001\n         OR b=707\n  }\n} {32 34 91 scan 0 sort 0}\ndo_test where7-2.209.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=957\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n  }\n} {48 50 87 100 scan 0 sort 0}\ndo_test where7-2.209.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=957\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n  }\n} {48 50 87 100 scan 0 sort 0}\ndo_test where7-2.210.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR a=77\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {40 77 85 scan 0 sort 0}\ndo_test where7-2.210.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR a=77\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {40 77 85 scan 0 sort 0}\ndo_test where7-2.211.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=11\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=99\n  }\n} {1 14 16 38 66 96 99 scan 0 sort 0}\ndo_test where7-2.211.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=11\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=99\n  }\n} {1 14 16 38 66 96 99 scan 0 sort 0}\ndo_test where7-2.212.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='fghijklmn'\n         OR a=16\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=80\n  }\n} {3 5 9 11 16 31 52 57 60 62 71 83 90 92 scan 0 sort 0}\ndo_test where7-2.212.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='fghijklmn'\n         OR a=16\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=80\n  }\n} {3 5 9 11 16 31 52 57 60 62 71 83 90 92 scan 0 sort 0}\ndo_test where7-2.213.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR a=44\n         OR a=43\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR b=25\n  }\n} {12 43 44 66 scan 0 sort 0}\ndo_test where7-2.213.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR a=44\n         OR a=43\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR b=25\n  }\n} {12 43 44 66 scan 0 sort 0}\ndo_test where7-2.214.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='vwxyzabcd'\n         OR a=73\n         OR b=597\n  }\n} {21 47 73 99 scan 0 sort 0}\ndo_test where7-2.214.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='vwxyzabcd'\n         OR a=73\n         OR b=597\n  }\n} {21 47 73 99 scan 0 sort 0}\ndo_test where7-2.215.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=22\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n         OR e IS NULL\n         OR a=1\n  }\n} {1 2 61 63 scan 0 sort 0}\ndo_test where7-2.215.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=22\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n         OR e IS NULL\n         OR a=1\n  }\n} {1 2 61 63 scan 0 sort 0}\ndo_test where7-2.216.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'opqrs*')\n         OR b=1015\n         OR c=16016\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR f='abcdefghi'\n         OR b=605\n         OR a=63\n  }\n} {3 19 26 45 46 47 48 52 55 63 71 78 92 97 scan 0 sort 0}\ndo_test where7-2.216.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'opqrs*')\n         OR b=1015\n         OR c=16016\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR f='abcdefghi'\n         OR b=605\n         OR a=63\n  }\n} {3 19 26 45 46 47 48 52 55 63 71 78 92 97 scan 0 sort 0}\ndo_test where7-2.217.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=641\n         OR b=795\n  }\n} {1 44 scan 0 sort 0}\ndo_test where7-2.217.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=641\n         OR b=795\n  }\n} {1 44 scan 0 sort 0}\ndo_test where7-2.218.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='fghijklmn'\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n  }\n} {5 15 31 44 57 83 scan 0 sort 0}\ndo_test where7-2.218.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='fghijklmn'\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n  }\n} {5 15 31 44 57 83 scan 0 sort 0}\ndo_test where7-2.219.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 99 AND 101) AND a!=100)\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR a=92\n         OR b=1100\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n  }\n} {30 32 72 74 85 87 92 98 99 100 scan 0 sort 0}\ndo_test where7-2.219.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 99 AND 101) AND a!=100)\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR a=92\n         OR b=1100\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n  }\n} {30 32 72 74 85 87 92 98 99 100 scan 0 sort 0}\ndo_test where7-2.220.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=880\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=1089\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR f IS NULL\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 12 16 31 57 69 71 80 83 86 97 99 scan 0 sort 0}\ndo_test where7-2.220.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=880\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=1089\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR f IS NULL\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 12 16 31 57 69 71 80 83 86 97 99 scan 0 sort 0}\ndo_test where7-2.221.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1026\n         OR b=407\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR b=564\n         OR c=23023\n         OR b=891\n         OR c=22022\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n  }\n} {9 11 21 22 24 31 34 37 64 65 66 67 68 69 81 scan 0 sort 0}\ndo_test where7-2.221.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1026\n         OR b=407\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR b=564\n         OR c=23023\n         OR b=891\n         OR c=22022\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n  }\n} {9 11 21 22 24 31 34 37 64 65 66 67 68 69 81 scan 0 sort 0}\ndo_test where7-2.222.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=72\n         OR a=43\n  }\n} {43 71 72 73 scan 0 sort 0}\ndo_test where7-2.222.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=72\n         OR a=43\n  }\n} {43 71 72 73 scan 0 sort 0}\ndo_test where7-2.223.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR c=18018\n         OR b=792\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n  }\n} {8 20 46 52 53 54 61 67 69 72 74 77 79 81 91 98 scan 0 sort 0}\ndo_test where7-2.223.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR c=18018\n         OR b=792\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n  }\n} {8 20 46 52 53 54 61 67 69 72 74 77 79 81 91 98 scan 0 sort 0}\ndo_test where7-2.224.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=429\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR b=1070\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {4 17 30 33 39 40 56 82 scan 0 sort 0}\ndo_test where7-2.224.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=429\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR b=1070\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {4 17 30 33 39 40 56 82 scan 0 sort 0}\ndo_test where7-2.225.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=572\n  }\n} {52 61 scan 0 sort 0}\ndo_test where7-2.225.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=572\n  }\n} {52 61 scan 0 sort 0}\ndo_test where7-2.226.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 62 AND 64) AND a!=63)\n         OR f='abcdefghi'\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n  }\n} {8 26 52 62 64 78 scan 0 sort 0}\ndo_test where7-2.226.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 62 AND 64) AND a!=63)\n         OR f='abcdefghi'\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n  }\n} {8 26 52 62 64 78 scan 0 sort 0}\ndo_test where7-2.227.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=40\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {40 85 87 scan 0 sort 0}\ndo_test where7-2.227.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=40\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {40 85 87 scan 0 sort 0}\ndo_test where7-2.228.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=43\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=1\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR a=75\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {1 43 44 46 59 61 75 77 83 scan 0 sort 0}\ndo_test where7-2.228.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=43\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=1\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR a=75\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {1 43 44 46 59 61 75 77 83 scan 0 sort 0}\ndo_test where7-2.229.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=231\n         OR a=87\n  }\n} {8 21 34 60 86 87 91 scan 0 sort 0}\ndo_test where7-2.229.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=231\n         OR a=87\n  }\n} {8 21 34 60 86 87 91 scan 0 sort 0}\ndo_test where7-2.230.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=77\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR c=24024\n         OR c=5005\n  }\n} {13 14 15 33 65 70 71 72 77 scan 0 sort 0}\ndo_test where7-2.230.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=77\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR c=24024\n         OR c=5005\n  }\n} {13 14 15 33 65 70 71 72 77 scan 0 sort 0}\ndo_test where7-2.231.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=682\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n  }\n} {22 29 34 60 62 64 65 66 89 91 scan 0 sort 0}\ndo_test where7-2.231.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=682\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n  }\n} {22 29 34 60 62 64 65 66 89 91 scan 0 sort 0}\ndo_test where7-2.232.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=212\n         OR b=121\n         OR c=2002\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n  }\n} {4 5 6 11 75 84 86 scan 0 sort 0}\ndo_test where7-2.232.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=212\n         OR b=121\n         OR c=2002\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n  }\n} {4 5 6 11 75 84 86 scan 0 sort 0}\ndo_test where7-2.233.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR f='abcdefghi'\n         OR b=267\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR a=82\n         OR a=54\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=1078\n  }\n} {16 20 26 52 54 55 78 82 98 scan 0 sort 0}\ndo_test where7-2.233.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR f='abcdefghi'\n         OR b=267\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR a=82\n         OR a=54\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=1078\n  }\n} {16 20 26 52 54 55 78 82 98 scan 0 sort 0}\ndo_test where7-2.234.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR f='hijklmnop'\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n  }\n} {7 33 34 59 85 93 scan 0 sort 0}\ndo_test where7-2.234.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR f='hijklmnop'\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n  }\n} {7 33 34 59 85 93 scan 0 sort 0}\ndo_test where7-2.235.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR a=18\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR 1000000<b\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 14 18 31 33 37 40 51 53 59 66 85 92 94 98 100 scan 0 sort 0}\ndo_test where7-2.235.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR a=18\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR 1000000<b\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 14 18 31 33 37 40 51 53 59 66 85 92 94 98 100 scan 0 sort 0}\ndo_test where7-2.236.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1001\n         OR b=168\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n  }\n} {7 33 59 85 89 91 scan 0 sort 0}\ndo_test where7-2.236.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1001\n         OR b=168\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n  }\n} {7 33 59 85 89 91 scan 0 sort 0}\ndo_test where7-2.237.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=51\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR b=330\n  }\n} {30 51 96 98 scan 0 sort 0}\ndo_test where7-2.237.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=51\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR b=330\n  }\n} {30 51 96 98 scan 0 sort 0}\ndo_test where7-2.238.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=704\n         OR a=62\n         OR f='pqrstuvwx'\n         OR b=495\n         OR c=26026\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b<0\n         OR b=597\n  }\n} {15 41 45 62 64 67 68 71 76 77 78 93 scan 0 sort 0}\ndo_test where7-2.238.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=704\n         OR a=62\n         OR f='pqrstuvwx'\n         OR b=495\n         OR c=26026\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b<0\n         OR b=597\n  }\n} {15 41 45 62 64 67 68 71 76 77 78 93 scan 0 sort 0}\ndo_test where7-2.239.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=520\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR f IS NULL\n  }\n} {2 47 49 87 89 scan 0 sort 0}\ndo_test where7-2.239.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=520\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR f IS NULL\n  }\n} {2 47 49 87 89 scan 0 sort 0}\ndo_test where7-2.240.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=14014\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=572\n         OR c=15015\n  }\n} {40 41 42 43 44 45 52 95 scan 0 sort 0}\ndo_test where7-2.240.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=14014\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=572\n         OR c=15015\n  }\n} {40 41 42 43 44 45 52 95 scan 0 sort 0}\ndo_test where7-2.241.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=850\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR b=88\n         OR f='hijklmnop'\n         OR b=806\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=88\n  }\n} {3 7 8 15 17 29 33 46 55 59 65 81 85 scan 0 sort 0}\ndo_test where7-2.241.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=850\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR b=88\n         OR f='hijklmnop'\n         OR b=806\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=88\n  }\n} {3 7 8 15 17 29 33 46 55 59 65 81 85 scan 0 sort 0}\ndo_test where7-2.242.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=817\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR a=36\n         OR b=960\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR b=374\n         OR b=938\n         OR b=773\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n  }\n} {34 36 55 58 63 77 scan 0 sort 0}\ndo_test where7-2.242.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=817\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR a=36\n         OR b=960\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR b=374\n         OR b=938\n         OR b=773\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n  }\n} {34 36 55 58 63 77 scan 0 sort 0}\ndo_test where7-2.243.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=146\n  }\n} {69 scan 0 sort 0}\ndo_test where7-2.243.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=146\n  }\n} {69 scan 0 sort 0}\ndo_test where7-2.244.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='pqrstuvwx'\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR b=704\n         OR a=18\n  }\n} {6 8 15 18 41 64 67 76 78 93 scan 0 sort 0}\ndo_test where7-2.244.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='pqrstuvwx'\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR b=704\n         OR a=18\n  }\n} {6 8 15 18 41 64 67 76 78 93 scan 0 sort 0}\ndo_test where7-2.245.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=399\n         OR b=1004\n         OR c=16016\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=671\n         OR a=25\n         OR a=30\n         OR a=8\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n  }\n} {5 8 19 25 30 31 45 46 47 48 61 71 97 scan 0 sort 0}\ndo_test where7-2.245.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=399\n         OR b=1004\n         OR c=16016\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=671\n         OR a=25\n         OR a=30\n         OR a=8\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n  }\n} {5 8 19 25 30 31 45 46 47 48 61 71 97 scan 0 sort 0}\ndo_test where7-2.246.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=561\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=594\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=861\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR b=949\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n  }\n} {18 28 30 39 41 51 54 90 scan 0 sort 0}\ndo_test where7-2.246.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=561\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=594\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=861\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR b=949\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n  }\n} {18 28 30 39 41 51 54 90 scan 0 sort 0}\ndo_test where7-2.247.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=83\n         OR c=26026\n         OR a=49\n         OR a=57\n         OR c=23023\n         OR f='uvwxyzabc'\n  }\n} {7 20 46 49 57 67 68 69 72 76 77 78 83 98 scan 0 sort 0}\ndo_test where7-2.247.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=83\n         OR c=26026\n         OR a=49\n         OR a=57\n         OR c=23023\n         OR f='uvwxyzabc'\n  }\n} {7 20 46 49 57 67 68 69 72 76 77 78 83 98 scan 0 sort 0}\ndo_test where7-2.248.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE d>1e10\n         OR b=355\n         OR f='stuvwxyza'\n         OR b=22\n  }\n} {2 18 44 70 96 scan 0 sort 0}\ndo_test where7-2.248.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE d>1e10\n         OR b=355\n         OR f='stuvwxyza'\n         OR b=22\n  }\n} {2 18 44 70 96 scan 0 sort 0}\ndo_test where7-2.249.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=451\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n  }\n} {8 34 41 60 86 scan 0 sort 0}\ndo_test where7-2.249.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=451\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n  }\n} {8 34 41 60 86 scan 0 sort 0}\ndo_test where7-2.250.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=47\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 27 53 79 scan 0 sort 0}\ndo_test where7-2.250.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=47\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 27 53 79 scan 0 sort 0}\ndo_test where7-2.251.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1037\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=344\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {12 66 68 86 scan 0 sort 0}\ndo_test where7-2.251.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1037\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=344\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {12 66 68 86 scan 0 sort 0}\ndo_test where7-2.252.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=506\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=429\n         OR b=275\n  }\n} {20 22 25 39 46 86 scan 0 sort 0}\ndo_test where7-2.252.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=506\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=429\n         OR b=275\n  }\n} {20 22 25 39 46 86 scan 0 sort 0}\ndo_test where7-2.253.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR a=28\n         OR b=443\n         OR b=363\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR a=60\n         OR b=80\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=616\n  }\n} {28 33 47 56 60 62 scan 0 sort 0}\ndo_test where7-2.253.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR a=28\n         OR b=443\n         OR b=363\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR a=60\n         OR b=80\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=616\n  }\n} {28 33 47 56 60 62 scan 0 sort 0}\ndo_test where7-2.254.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=660\n  }\n} {33 60 scan 0 sort 0}\ndo_test where7-2.254.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=660\n  }\n} {33 60 scan 0 sort 0}\ndo_test where7-2.255.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=43\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=586\n         OR c=17017\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR a=87\n         OR b=968\n  }\n} {7 21 43 47 49 50 51 64 66 73 87 88 99 scan 0 sort 0}\ndo_test where7-2.255.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=43\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=586\n         OR c=17017\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR a=87\n         OR b=968\n  }\n} {7 21 43 47 49 50 51 64 66 73 87 88 99 scan 0 sort 0}\ndo_test where7-2.256.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='klmnopqrs'\n         OR b=982\n         OR b=575\n         OR b=110\n         OR b=99\n  }\n} {9 10 36 62 88 scan 0 sort 0}\ndo_test where7-2.256.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='klmnopqrs'\n         OR b=982\n         OR b=575\n         OR b=110\n         OR b=99\n  }\n} {9 10 36 62 88 scan 0 sort 0}\ndo_test where7-2.257.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='rqponml' AND f GLOB 'jklmn*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR c>=34035\n         OR b=850\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=924\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=355\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {4 32 34 35 37 56 78 84 86 scan 0 sort 0}\ndo_test where7-2.257.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='rqponml' AND f GLOB 'jklmn*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR c>=34035\n         OR b=850\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=924\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=355\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {4 32 34 35 37 56 78 84 86 scan 0 sort 0}\ndo_test where7-2.258.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=982\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR b=374\n  }\n} {34 46 81 83 scan 0 sort 0}\ndo_test where7-2.258.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=982\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR b=374\n  }\n} {34 46 81 83 scan 0 sort 0}\ndo_test where7-2.259.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=814\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n  }\n} {19 74 87 89 scan 0 sort 0}\ndo_test where7-2.259.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=814\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n  }\n} {19 74 87 89 scan 0 sort 0}\ndo_test where7-2.260.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=993\n  }\n} {12 39 scan 0 sort 0}\ndo_test where7-2.260.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=993\n  }\n} {12 39 scan 0 sort 0}\ndo_test where7-2.261.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=234\n         OR a=22\n         OR b=289\n         OR b=795\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=242\n         OR a=59\n         OR b=1045\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n  }\n} {8 22 59 91 95 scan 0 sort 0}\ndo_test where7-2.261.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=234\n         OR a=22\n         OR b=289\n         OR b=795\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=242\n         OR a=59\n         OR b=1045\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n  }\n} {8 22 59 91 95 scan 0 sort 0}\ndo_test where7-2.262.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=245\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR c=3003\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n  }\n} {1 7 8 9 10 26 33 52 68 70 71 73 78 scan 0 sort 0}\ndo_test where7-2.262.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=245\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR c=3003\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n  }\n} {1 7 8 9 10 26 33 52 68 70 71 73 78 scan 0 sort 0}\ndo_test where7-2.263.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=220\n         OR b=443\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR a=62\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR b=1023\n         OR a=100\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {18 20 44 55 62 70 87 93 96 97 100 scan 0 sort 0}\ndo_test where7-2.263.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=220\n         OR b=443\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR a=62\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR b=1023\n         OR a=100\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {18 20 44 55 62 70 87 93 96 97 100 scan 0 sort 0}\ndo_test where7-2.264.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=11011\n         OR f='tuvwxyzab'\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {19 31 32 33 45 47 71 84 97 scan 0 sort 0}\ndo_test where7-2.264.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=11011\n         OR f='tuvwxyzab'\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {19 31 32 33 45 47 71 84 97 scan 0 sort 0}\ndo_test where7-2.265.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=79\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR b=462\n  }\n} {39 42 79 93 95 scan 0 sort 0}\ndo_test where7-2.265.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=79\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR b=462\n  }\n} {39 42 79 93 95 scan 0 sort 0}\ndo_test where7-2.266.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=146\n         OR 1000000<b\n         OR b=99\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n  }\n} {9 33 75 77 scan 0 sort 0}\ndo_test where7-2.266.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=146\n         OR 1000000<b\n         OR b=99\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n  }\n} {9 33 75 77 scan 0 sort 0}\ndo_test where7-2.267.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=935\n         OR b=473\n         OR a=28\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR a=62\n         OR b=619\n         OR a=82\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR c=14014\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {20 28 40 41 42 43 62 64 67 82 85 scan 0 sort 0}\ndo_test where7-2.267.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=935\n         OR b=473\n         OR a=28\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR a=62\n         OR b=619\n         OR a=82\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR c=14014\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {20 28 40 41 42 43 62 64 67 82 85 scan 0 sort 0}\ndo_test where7-2.268.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=443\n         OR b=33\n         OR b=762\n         OR b=575\n         OR c=16016\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR b=1092\n  }\n} {3 40 41 43 46 47 48 72 scan 0 sort 0}\ndo_test where7-2.268.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=443\n         OR b=33\n         OR b=762\n         OR b=575\n         OR c=16016\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR b=1092\n  }\n} {3 40 41 43 46 47 48 72 scan 0 sort 0}\ndo_test where7-2.269.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=806\n         OR b=872\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR f='uvwxyzabc'\n         OR b=748\n         OR b=586\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=891\n  }\n} {15 17 20 32 34 46 68 72 80 81 88 98 scan 0 sort 0}\ndo_test where7-2.269.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=806\n         OR b=872\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR f='uvwxyzabc'\n         OR b=748\n         OR b=586\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=891\n  }\n} {15 17 20 32 34 46 68 72 80 81 88 98 scan 0 sort 0}\ndo_test where7-2.270.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=693\n         OR f='fghijklmn'\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=96\n  }\n} {5 31 33 39 57 63 71 73 83 96 scan 0 sort 0}\ndo_test where7-2.270.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=693\n         OR f='fghijklmn'\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=96\n  }\n} {5 31 33 39 57 63 71 73 83 96 scan 0 sort 0}\ndo_test where7-2.271.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=451\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR a=84\n  }\n} {41 84 86 96 97 98 99 scan 0 sort 0}\ndo_test where7-2.271.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=451\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR a=84\n  }\n} {41 84 86 96 97 98 99 scan 0 sort 0}\ndo_test where7-2.272.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=75\n         OR b=960\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR b=616\n         OR b=330\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR a=26\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {16 18 24 26 30 53 56 63 72 75 scan 0 sort 0}\ndo_test where7-2.272.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=75\n         OR b=960\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR b=616\n         OR b=330\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR a=26\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {16 18 24 26 30 53 56 63 72 75 scan 0 sort 0}\ndo_test where7-2.273.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=762\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {53 scan 0 sort 0}\ndo_test where7-2.273.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=762\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {53 scan 0 sort 0}\ndo_test where7-2.274.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=14\n         OR a=23\n         OR b=748\n         OR b=407\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=979\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n  }\n} {4 15 17 23 37 68 87 89 scan 0 sort 0}\ndo_test where7-2.274.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=14\n         OR a=23\n         OR b=748\n         OR b=407\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=979\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n  }\n} {4 15 17 23 37 68 87 89 scan 0 sort 0}\ndo_test where7-2.275.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 36 AND 38) AND a!=37)\n         OR a=92\n  }\n} {36 38 92 scan 0 sort 0}\ndo_test where7-2.275.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 36 AND 38) AND a!=37)\n         OR a=92\n  }\n} {36 38 92 scan 0 sort 0}\ndo_test where7-2.276.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=14014\n         OR b=927\n         OR b=176\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=220\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR a=4\n  }\n} {4 16 20 24 34 36 40 41 42 scan 0 sort 0}\ndo_test where7-2.276.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=14014\n         OR b=927\n         OR b=176\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=220\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR a=4\n  }\n} {4 16 20 24 34 36 40 41 42 scan 0 sort 0}\ndo_test where7-2.277.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=29\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=979\n         OR b=275\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR b=539\n         OR a=87\n  }\n} {19 25 29 41 49 56 58 87 89 scan 0 sort 0}\ndo_test where7-2.277.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=29\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=979\n         OR b=275\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR b=539\n         OR a=87\n  }\n} {19 25 29 41 49 56 58 87 89 scan 0 sort 0}\ndo_test where7-2.278.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR f='fghijklmn'\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=74\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {4 5 6 7 9 31 36 43 45 57 59 69 74 83 scan 0 sort 0}\ndo_test where7-2.278.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR f='fghijklmn'\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=74\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {4 5 6 7 9 31 36 43 45 57 59 69 74 83 scan 0 sort 0}\ndo_test where7-2.279.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n  }\n} {8 34 42 49 51 60 79 80 82 86 scan 0 sort 0}\ndo_test where7-2.279.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n  }\n} {8 34 42 49 51 60 79 80 82 86 scan 0 sort 0}\ndo_test where7-2.280.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 58 AND 60) AND a!=59)\n         OR b=696\n         OR f='tuvwxyzab'\n         OR b=374\n         OR b=110\n         OR a=90\n  }\n} {10 19 34 45 58 60 71 90 97 scan 0 sort 0}\ndo_test where7-2.280.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 58 AND 60) AND a!=59)\n         OR b=696\n         OR f='tuvwxyzab'\n         OR b=374\n         OR b=110\n         OR a=90\n  }\n} {10 19 34 45 58 60 71 90 97 scan 0 sort 0}\ndo_test where7-2.281.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR c=23023\n         OR b=377\n         OR b=858\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {6 57 67 68 69 78 scan 0 sort 0}\ndo_test where7-2.281.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR c=23023\n         OR b=377\n         OR b=858\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {6 57 67 68 69 78 scan 0 sort 0}\ndo_test where7-2.282.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=322\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR b=432\n         OR b=55\n         OR a=53\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=25\n  }\n} {5 7 19 33 38 48 53 59 74 85 93 scan 0 sort 0}\ndo_test where7-2.282.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=322\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR b=432\n         OR b=55\n         OR a=53\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=25\n  }\n} {5 7 19 33 38 48 53 59 74 85 93 scan 0 sort 0}\ndo_test where7-2.283.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=484\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=616\n         OR c=5005\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n  }\n} {13 14 15 27 29 44 56 74 scan 0 sort 0}\ndo_test where7-2.283.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=484\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=616\n         OR c=5005\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n  }\n} {13 14 15 27 29 44 56 74 scan 0 sort 0}\ndo_test where7-2.284.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=916\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=1048\n         OR c=6006\n         OR b=762\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR b=751\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n  }\n} {13 14 16 17 18 39 40 59 61 65 66 73 91 92 scan 0 sort 0}\ndo_test where7-2.284.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=916\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=1048\n         OR c=6006\n         OR b=762\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR b=751\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n  }\n} {13 14 16 17 18 39 40 59 61 65 66 73 91 92 scan 0 sort 0}\ndo_test where7-2.285.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR b=927\n         OR b=275\n         OR b=396\n         OR c=4004\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR b=319\n         OR ((a BETWEEN 83 AND 85) AND a!=84)\n         OR a=3\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n  }\n} {3 10 11 12 14 25 29 32 36 73 75 83 85 scan 0 sort 0}\ndo_test where7-2.285.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR b=927\n         OR b=275\n         OR b=396\n         OR c=4004\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR b=319\n         OR ((a BETWEEN 83 AND 85) AND a!=84)\n         OR a=3\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n  }\n} {3 10 11 12 14 25 29 32 36 73 75 83 85 scan 0 sort 0}\ndo_test where7-2.286.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR b=718\n         OR f='vwxyzabcd'\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {9 11 19 21 22 35 45 47 61 66 68 71 73 87 97 98 99 scan 0 sort 0}\ndo_test where7-2.286.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR b=718\n         OR f='vwxyzabcd'\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {9 11 19 21 22 35 45 47 61 66 68 71 73 87 97 98 99 scan 0 sort 0}\ndo_test where7-2.287.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=187\n         OR b=1056\n         OR b=861\n         OR b=1081\n         OR b=572\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=11\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR a=89\n         OR b=421\n  }\n} {4 11 17 52 89 96 99 scan 0 sort 0}\ndo_test where7-2.287.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=187\n         OR b=1056\n         OR b=861\n         OR b=1081\n         OR b=572\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=11\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR a=89\n         OR b=421\n  }\n} {4 11 17 52 89 96 99 scan 0 sort 0}\ndo_test where7-2.288.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=231\n         OR b=388\n         OR d<0.0\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR b=1045\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n  }\n} {12 21 39 95 scan 0 sort 0}\ndo_test where7-2.288.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=231\n         OR b=388\n         OR d<0.0\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR b=1045\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n  }\n} {12 21 39 95 scan 0 sort 0}\ndo_test where7-2.289.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=528\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=762\n  }\n} {48 53 scan 0 sort 0}\ndo_test where7-2.289.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=528\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=762\n  }\n} {48 53 scan 0 sort 0}\ndo_test where7-2.290.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='stuvwxyza'\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR b=916\n  }\n} {18 44 70 90 92 96 scan 0 sort 0}\ndo_test where7-2.290.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='stuvwxyza'\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR b=916\n  }\n} {18 44 70 90 92 96 scan 0 sort 0}\ndo_test where7-2.291.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n  }\n} {4 19 52 76 96 98 scan 0 sort 0}\ndo_test where7-2.291.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n  }\n} {4 19 52 76 96 98 scan 0 sort 0}\ndo_test where7-2.292.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=102\n         OR c=6006\n         OR b=231\n         OR b=212\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR c=30030\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n  }\n} {16 17 18 21 36 52 88 89 90 scan 0 sort 0}\ndo_test where7-2.292.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=102\n         OR c=6006\n         OR b=231\n         OR b=212\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR c=30030\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n  }\n} {16 17 18 21 36 52 88 89 90 scan 0 sort 0}\ndo_test where7-2.293.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=47\n         OR a=82\n         OR c=25025\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR f='qrstuvwxy'\n         OR a=5\n  }\n} {5 16 40 42 47 68 73 74 75 82 94 scan 0 sort 0}\ndo_test where7-2.293.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=47\n         OR a=82\n         OR c=25025\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR f='qrstuvwxy'\n         OR a=5\n  }\n} {5 16 40 42 47 68 73 74 75 82 94 scan 0 sort 0}\ndo_test where7-2.294.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=429\n         OR a=30\n         OR f='vwxyzabcd'\n         OR b=762\n         OR a=60\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n  }\n} {4 21 30 39 47 60 73 99 scan 0 sort 0}\ndo_test where7-2.294.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=429\n         OR a=30\n         OR f='vwxyzabcd'\n         OR b=762\n         OR a=60\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n  }\n} {4 21 30 39 47 60 73 99 scan 0 sort 0}\ndo_test where7-2.295.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR a=3\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=498\n         OR a=100\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=69\n  }\n} {3 13 31 39 58 63 65 69 91 100 scan 0 sort 0}\ndo_test where7-2.295.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR a=3\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=498\n         OR a=100\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR a=69\n  }\n} {3 13 31 39 58 63 65 69 91 100 scan 0 sort 0}\ndo_test where7-2.296.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=300\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR b=58\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=286\n         OR b=234\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR f='ghijklmno'\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n  }\n} {6 7 26 32 43 45 55 57 58 82 84 scan 0 sort 0}\ndo_test where7-2.296.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=300\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR b=58\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=286\n         OR b=234\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR f='ghijklmno'\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n  }\n} {6 7 26 32 43 45 55 57 58 82 84 scan 0 sort 0}\ndo_test where7-2.297.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=95\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=594\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {5 7 18 20 23 25 31 33 37 39 45 53 54 55 56 57 58 59 72 74 83 85 95 scan 0 sort 0}\ndo_test where7-2.297.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=95\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=594\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {5 7 18 20 23 25 31 33 37 39 45 53 54 55 56 57 58 59 72 74 83 85 95 scan 0 sort 0}\ndo_test where7-2.298.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=949\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n  }\n} {5 14 scan 0 sort 0}\ndo_test where7-2.298.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=949\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n  }\n} {5 14 scan 0 sort 0}\ndo_test where7-2.299.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=960\n         OR a=44\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR a=39\n         OR b=828\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR d<0.0\n         OR b=770\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR b=594\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {3 5 6 18 39 44 54 70 89 91 96 scan 0 sort 0}\ndo_test where7-2.299.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=960\n         OR a=44\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR a=39\n         OR b=828\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR d<0.0\n         OR b=770\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR b=594\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {3 5 6 18 39 44 54 70 89 91 96 scan 0 sort 0}\ndo_test where7-2.300.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR b=198\n         OR a=51\n         OR b=1056\n         OR b=748\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n  }\n} {9 11 18 40 42 51 68 96 scan 0 sort 0}\ndo_test where7-2.300.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR b=198\n         OR a=51\n         OR b=1056\n         OR b=748\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n  }\n} {9 11 18 40 42 51 68 96 scan 0 sort 0}\ndo_test where7-2.301.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1081\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=1004\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n         OR b=660\n         OR b=957\n         OR b=869\n  }\n} {29 31 60 66 68 79 87 91 scan 0 sort 0}\ndo_test where7-2.301.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1081\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=1004\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n         OR b=660\n         OR b=957\n         OR b=869\n  }\n} {29 31 60 66 68 79 87 91 scan 0 sort 0}\ndo_test where7-2.302.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=927\n         OR c=12012\n         OR f='yzabcdefg'\n         OR b=880\n         OR a=63\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n  }\n} {24 34 35 36 44 50 58 63 76 80 86 scan 0 sort 0}\ndo_test where7-2.302.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=927\n         OR c=12012\n         OR f='yzabcdefg'\n         OR b=880\n         OR a=63\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n  }\n} {24 34 35 36 44 50 58 63 76 80 86 scan 0 sort 0}\ndo_test where7-2.303.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=69\n         OR b=1103\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='wxyzabcde'\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR f='pqrstuvwx'\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR a=59\n         OR b=946\n  }\n} {15 18 22 26 41 44 48 52 59 67 69 70 73 74 78 86 88 93 96 100 scan 0 sort 0}\ndo_test where7-2.303.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=69\n         OR b=1103\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='wxyzabcde'\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR f='pqrstuvwx'\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR a=59\n         OR b=946\n  }\n} {15 18 22 26 41 44 48 52 59 67 69 70 73 74 78 86 88 93 96 100 scan 0 sort 0}\ndo_test where7-2.304.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR a=68\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 47 68 75 scan 0 sort 0}\ndo_test where7-2.304.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR a=68\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 47 68 75 scan 0 sort 0}\ndo_test where7-2.305.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n  }\n} {10 63 scan 0 sort 0}\ndo_test where7-2.305.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n  }\n} {10 63 scan 0 sort 0}\ndo_test where7-2.306.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=32\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR c=7007\n         OR b=968\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n  }\n} {15 17 18 19 20 21 32 86 88 92 94 scan 0 sort 0}\ndo_test where7-2.306.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=32\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR c=7007\n         OR b=968\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n  }\n} {15 17 18 19 20 21 32 86 88 92 94 scan 0 sort 0}\ndo_test where7-2.307.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='cdefghijk'\n         OR b=1103\n  }\n} {2 28 54 80 scan 0 sort 0}\ndo_test where7-2.307.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='cdefghijk'\n         OR b=1103\n  }\n} {2 28 54 80 scan 0 sort 0}\ndo_test where7-2.308.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR c=14014\n         OR b=990\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR c=14014\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=740\n         OR c=3003\n  }\n} {7 8 9 13 14 21 23 40 41 42 56 90 scan 0 sort 0}\ndo_test where7-2.308.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR c=14014\n         OR b=990\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR c=14014\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=740\n         OR c=3003\n  }\n} {7 8 9 13 14 21 23 40 41 42 56 90 scan 0 sort 0}\ndo_test where7-2.309.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR a=67\n         OR b=135\n         OR f='bcdefghij'\n         OR b=924\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n  }\n} {1 22 27 53 60 67 79 84 scan 0 sort 0}\ndo_test where7-2.309.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR a=67\n         OR b=135\n         OR f='bcdefghij'\n         OR b=924\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n  }\n} {1 22 27 53 60 67 79 84 scan 0 sort 0}\ndo_test where7-2.310.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=96\n         OR a=13\n  }\n} {13 96 scan 0 sort 0}\ndo_test where7-2.310.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=96\n         OR a=13\n  }\n} {13 96 scan 0 sort 0}\ndo_test where7-2.311.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 34 AND 36) AND a!=35)\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 35 AND 37) AND a!=36)\n         OR a=49\n         OR a=38\n         OR b=157\n         OR a=4\n         OR b=311\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=396\n  }\n} {4 27 34 35 36 37 38 49 50 97 99 scan 0 sort 0}\ndo_test where7-2.311.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 34 AND 36) AND a!=35)\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 35 AND 37) AND a!=36)\n         OR a=49\n         OR a=38\n         OR b=157\n         OR a=4\n         OR b=311\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=396\n  }\n} {4 27 34 35 36 37 38 49 50 97 99 scan 0 sort 0}\ndo_test where7-2.312.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=82\n         OR b=333\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR b=99\n         OR a=63\n         OR a=35\n         OR b=176\n  }\n} {9 16 22 35 48 63 74 82 100 scan 0 sort 0}\ndo_test where7-2.312.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=82\n         OR b=333\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR b=99\n         OR a=63\n         OR a=35\n         OR b=176\n  }\n} {9 16 22 35 48 63 74 82 100 scan 0 sort 0}\ndo_test where7-2.313.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=90\n         OR a=81\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR f='mnopqrstu'\n         OR b=927\n         OR b=311\n         OR a=34\n         OR b=715\n         OR f='rstuvwxyz'\n  }\n} {12 17 34 38 43 51 53 64 65 69 81 90 95 scan 0 sort 0}\ndo_test where7-2.313.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=90\n         OR a=81\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR f='mnopqrstu'\n         OR b=927\n         OR b=311\n         OR a=34\n         OR b=715\n         OR f='rstuvwxyz'\n  }\n} {12 17 34 38 43 51 53 64 65 69 81 90 95 scan 0 sort 0}\ndo_test where7-2.314.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=484\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='lmnopqrst'\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR b<0\n         OR b=231\n         OR a=14\n  }\n} {7 10 11 12 14 21 37 39 44 63 64 89 scan 0 sort 0}\ndo_test where7-2.314.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=484\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='lmnopqrst'\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR b<0\n         OR b=231\n         OR a=14\n  }\n} {7 10 11 12 14 21 37 39 44 63 64 89 scan 0 sort 0}\ndo_test where7-2.315.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=905\n         OR f='hijklmnop'\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR b=817\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n  }\n} {7 11 20 22 26 33 37 45 59 63 80 85 89 scan 0 sort 0}\ndo_test where7-2.315.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=905\n         OR f='hijklmnop'\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR b=817\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n  }\n} {7 11 20 22 26 33 37 45 59 63 80 85 89 scan 0 sort 0}\ndo_test where7-2.316.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=311\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=48\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR c=32032\n         OR f='opqrstuvw'\n         OR b=300\n         OR b=1001\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n  }\n} {14 40 43 47 48 61 66 85 91 92 94 95 96 scan 0 sort 0}\ndo_test where7-2.316.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=311\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=48\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR c=32032\n         OR f='opqrstuvw'\n         OR b=300\n         OR b=1001\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n  }\n} {14 40 43 47 48 61 66 85 91 92 94 95 96 scan 0 sort 0}\ndo_test where7-2.317.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR b=1070\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR a=22\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR f='tuvwxyzab'\n         OR a=72\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {11 19 22 45 53 55 61 71 72 95 97 99 scan 0 sort 0}\ndo_test where7-2.317.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR b=1070\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR a=22\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR f='tuvwxyzab'\n         OR a=72\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {11 19 22 45 53 55 61 71 72 95 97 99 scan 0 sort 0}\ndo_test where7-2.318.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR a=21\n         OR b=1026\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=473\n  }\n} {8 16 21 34 36 43 scan 0 sort 0}\ndo_test where7-2.318.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR a=21\n         OR b=1026\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=473\n  }\n} {8 16 21 34 36 43 scan 0 sort 0}\ndo_test where7-2.319.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=100\n         OR a=29\n         OR c=15015\n         OR a=87\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {29 43 44 45 71 73 87 88 100 scan 0 sort 0}\ndo_test where7-2.319.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=100\n         OR a=29\n         OR c=15015\n         OR a=87\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {29 43 44 45 71 73 87 88 100 scan 0 sort 0}\ndo_test where7-2.320.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR b=542\n         OR b=638\n  }\n} {1 58 scan 0 sort 0}\ndo_test where7-2.320.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR b=542\n         OR b=638\n  }\n} {1 58 scan 0 sort 0}\ndo_test where7-2.321.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=1070\n         OR a=91\n         OR b=1015\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n  }\n} {5 7 12 80 91 93 scan 0 sort 0}\ndo_test where7-2.321.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=1070\n         OR a=91\n         OR b=1015\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n  }\n} {5 7 12 80 91 93 scan 0 sort 0}\ndo_test where7-2.322.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=7\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=1015\n         OR b=839\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR b=410\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR a=71\n  }\n} {1 2 7 28 36 54 71 80 scan 0 sort 0}\ndo_test where7-2.322.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=7\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=1015\n         OR b=839\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR b=410\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR a=71\n  }\n} {1 2 7 28 36 54 71 80 scan 0 sort 0}\ndo_test where7-2.323.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=880\n         OR b=982\n         OR a=52\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR a=24\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {24 47 49 50 52 60 76 80 scan 0 sort 0}\ndo_test where7-2.323.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=880\n         OR b=982\n         OR a=52\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR a=24\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n  }\n} {24 47 49 50 52 60 76 80 scan 0 sort 0}\ndo_test where7-2.324.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 22 31 57 67 69 83 scan 0 sort 0}\ndo_test where7-2.324.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 22 31 57 67 69 83 scan 0 sort 0}\ndo_test where7-2.325.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='abcdefghi'\n         OR a=5\n         OR b=124\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=432\n         OR 1000000<b\n         OR a=58\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=77\n         OR b=605\n  }\n} {5 7 26 45 52 55 58 69 78 scan 0 sort 0}\ndo_test where7-2.325.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='abcdefghi'\n         OR a=5\n         OR b=124\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=432\n         OR 1000000<b\n         OR a=58\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=77\n         OR b=605\n  }\n} {5 7 26 45 52 55 58 69 78 scan 0 sort 0}\ndo_test where7-2.326.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=583\n         OR a=62\n  }\n} {53 62 89 scan 0 sort 0}\ndo_test where7-2.326.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=583\n         OR a=62\n  }\n} {53 62 89 scan 0 sort 0}\ndo_test where7-2.327.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR f='pqrstuvwx'\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR b=278\n         OR a=10\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR f='uvwxyzabc'\n  }\n} {5 10 15 20 28 41 46 54 63 65 67 68 72 84 86 93 98 scan 0 sort 0}\ndo_test where7-2.327.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR f='pqrstuvwx'\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR b=278\n         OR a=10\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR f='uvwxyzabc'\n  }\n} {5 10 15 20 28 41 46 54 63 65 67 68 72 84 86 93 98 scan 0 sort 0}\ndo_test where7-2.328.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=564\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR b=77\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=968\n         OR b=847\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {7 14 40 56 57 58 59 66 77 85 88 90 92 scan 0 sort 0}\ndo_test where7-2.328.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=564\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR b=77\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=968\n         OR b=847\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n  }\n} {7 14 40 56 57 58 59 66 77 85 88 90 92 scan 0 sort 0}\ndo_test where7-2.329.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=539\n         OR b=594\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR f='abcdefghi'\n         OR a=6\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=762\n  }\n} {6 17 26 49 52 54 63 65 78 scan 0 sort 0}\ndo_test where7-2.329.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=539\n         OR b=594\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR f='abcdefghi'\n         OR a=6\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=762\n  }\n} {6 17 26 49 52 54 63 65 78 scan 0 sort 0}\ndo_test where7-2.330.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=869\n         OR b=630\n  }\n} {79 scan 0 sort 0}\ndo_test where7-2.330.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=869\n         OR b=630\n  }\n} {79 scan 0 sort 0}\ndo_test where7-2.331.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR b=693\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=968\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR b=132\n         OR f='nopqrstuv'\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {12 13 28 30 39 63 65 72 86 88 91 scan 0 sort 0}\ndo_test where7-2.331.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR b=693\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR b=968\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR b=132\n         OR f='nopqrstuv'\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {12 13 28 30 39 63 65 72 86 88 91 scan 0 sort 0}\ndo_test where7-2.332.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=32032\n         OR b=814\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR b=814\n         OR a=78\n         OR a=37\n  }\n} {37 74 78 90 94 95 96 scan 0 sort 0}\ndo_test where7-2.332.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=32032\n         OR b=814\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR b=814\n         OR a=78\n         OR a=37\n  }\n} {37 74 78 90 94 95 96 scan 0 sort 0}\ndo_test where7-2.333.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=190\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=924\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=759\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n  }\n} {1 40 59 69 84 scan 0 sort 0}\ndo_test where7-2.333.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=190\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=924\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=759\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n  }\n} {1 40 59 69 84 scan 0 sort 0}\ndo_test where7-2.334.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=97\n         OR b=201\n         OR b=597\n         OR a=6\n         OR f='cdefghijk'\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=300\n         OR b=693\n         OR b=333\n         OR b=740\n  }\n} {2 6 28 54 63 74 76 80 97 scan 0 sort 0}\ndo_test where7-2.334.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=97\n         OR b=201\n         OR b=597\n         OR a=6\n         OR f='cdefghijk'\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=300\n         OR b=693\n         OR b=333\n         OR b=740\n  }\n} {2 6 28 54 63 74 76 80 97 scan 0 sort 0}\ndo_test where7-2.335.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=26026\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR c=17017\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {2 4 32 43 49 50 51 60 72 74 76 77 78 scan 0 sort 0}\ndo_test where7-2.335.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=26026\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR c=17017\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n  }\n} {2 4 32 43 49 50 51 60 72 74 76 77 78 scan 0 sort 0}\ndo_test where7-2.336.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=638\n         OR b=495\n         OR a=44\n         OR b=374\n         OR a=22\n         OR c=12012\n  }\n} {13 15 22 34 35 36 44 45 58 70 scan 0 sort 0}\ndo_test where7-2.336.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=638\n         OR b=495\n         OR a=44\n         OR b=374\n         OR a=22\n         OR c=12012\n  }\n} {13 15 22 34 35 36 44 45 58 70 scan 0 sort 0}\ndo_test where7-2.337.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=8008\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR b=300\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR a=41\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=135\n         OR b=605\n  }\n} {1 2 22 23 24 39 41 49 55 100 scan 0 sort 0}\ndo_test where7-2.337.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=8008\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR b=300\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR a=41\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=135\n         OR b=605\n  }\n} {1 2 22 23 24 39 41 49 55 100 scan 0 sort 0}\ndo_test where7-2.338.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=762\n         OR b=484\n         OR b=190\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=1023\n  }\n} {4 17 30 41 43 44 56 61 69 74 82 93 95 97 scan 0 sort 0}\ndo_test where7-2.338.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=762\n         OR b=484\n         OR b=190\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=1023\n  }\n} {4 17 30 41 43 44 56 61 69 74 82 93 95 97 scan 0 sort 0}\ndo_test where7-2.339.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR a=34\n         OR f='rstuvwxyz'\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=729\n  }\n} {10 17 34 43 69 82 95 scan 0 sort 0}\ndo_test where7-2.339.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR a=34\n         OR f='rstuvwxyz'\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=729\n  }\n} {10 17 34 43 69 82 95 scan 0 sort 0}\ndo_test where7-2.340.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=1004\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR g IS NULL\n  }\n} {37 41 scan 0 sort 0}\ndo_test where7-2.340.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=1004\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR g IS NULL\n  }\n} {37 41 scan 0 sort 0}\ndo_test where7-2.341.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=73\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR a=9\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR a=44\n         OR a=23\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {1 9 23 36 37 38 44 51 53 55 63 73 78 scan 0 sort 0}\ndo_test where7-2.341.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=73\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR a=9\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR a=44\n         OR a=23\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {1 9 23 36 37 38 44 51 53 55 63 73 78 scan 0 sort 0}\ndo_test where7-2.342.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=487\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR a=11\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=13\n         OR a=15\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR a=36\n  }\n} {11 12 13 14 15 29 36 69 71 77 78 79 scan 0 sort 0}\ndo_test where7-2.342.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=487\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR a=11\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=13\n         OR a=15\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR a=36\n  }\n} {11 12 13 14 15 29 36 69 71 77 78 79 scan 0 sort 0}\ndo_test where7-2.343.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=938\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR b=245\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n  }\n} {32 35 54 57 59 scan 0 sort 0}\ndo_test where7-2.343.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=938\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR b=245\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n  }\n} {32 35 54 57 59 scan 0 sort 0}\ndo_test where7-2.344.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1078\n         OR c=19019\n         OR a=38\n         OR a=59\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR c=25025\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n  }\n} {30 32 38 51 55 56 57 59 73 74 75 76 79 95 97 98 scan 0 sort 0}\ndo_test where7-2.344.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1078\n         OR c=19019\n         OR a=38\n         OR a=59\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR c=25025\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n  }\n} {30 32 38 51 55 56 57 59 73 74 75 76 79 95 97 98 scan 0 sort 0}\ndo_test where7-2.345.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='cdefghijk'\n         OR b=168\n         OR b=561\n         OR a=81\n         OR a=87\n  }\n} {2 28 51 54 80 81 87 scan 0 sort 0}\ndo_test where7-2.345.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='cdefghijk'\n         OR b=168\n         OR b=561\n         OR a=81\n         OR a=87\n  }\n} {2 28 51 54 80 81 87 scan 0 sort 0}\ndo_test where7-2.346.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR a=48\n         OR b=113\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=880\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {9 11 20 22 33 48 53 73 80 85 87 88 scan 0 sort 0}\ndo_test where7-2.346.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR a=48\n         OR b=113\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=880\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {9 11 20 22 33 48 53 73 80 85 87 88 scan 0 sort 0}\ndo_test where7-2.347.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=517\n         OR b=187\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR b=1092\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {6 17 47 84 86 scan 0 sort 0}\ndo_test where7-2.347.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=517\n         OR b=187\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR b=1092\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n  }\n} {6 17 47 84 86 scan 0 sort 0}\ndo_test where7-2.348.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=982\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=234\n         OR c=15015\n         OR a=47\n         OR f='qrstuvwxy'\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR b=814\n         OR b=440\n         OR b=454\n  }\n} {16 40 42 43 44 45 47 65 68 74 94 scan 0 sort 0}\ndo_test where7-2.348.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=982\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=234\n         OR c=15015\n         OR a=47\n         OR f='qrstuvwxy'\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR b=814\n         OR b=440\n         OR b=454\n  }\n} {16 40 42 43 44 45 47 65 68 74 94 scan 0 sort 0}\ndo_test where7-2.349.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=7007\n         OR b=429\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=231\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR c=22022\n         OR f='bcdefghij'\n  }\n} {1 19 20 21 25 26 27 39 47 53 64 65 66 79 scan 0 sort 0}\ndo_test where7-2.349.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=7007\n         OR b=429\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=231\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR c=22022\n         OR f='bcdefghij'\n  }\n} {1 19 20 21 25 26 27 39 47 53 64 65 66 79 scan 0 sort 0}\ndo_test where7-2.350.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=17017\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR b=784\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR f='zabcdefgh'\n  }\n} {16 18 22 24 25 49 50 51 54 56 62 77 88 90 scan 0 sort 0}\ndo_test where7-2.350.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=17017\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR b=784\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR f='zabcdefgh'\n  }\n} {16 18 22 24 25 49 50 51 54 56 62 77 88 90 scan 0 sort 0}\ndo_test where7-2.351.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=344\n         OR b=275\n         OR c<=10\n  }\n} {25 scan 0 sort 0}\ndo_test where7-2.351.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=344\n         OR b=275\n         OR c<=10\n  }\n} {25 scan 0 sort 0}\ndo_test where7-2.352.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=76\n         OR b=154\n         OR a=30\n         OR c=3003\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR b=564\n         OR b=55\n         OR a=38\n  }\n} {5 7 8 9 14 23 30 38 44 46 49 75 76 88 scan 0 sort 0}\ndo_test where7-2.352.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=76\n         OR b=154\n         OR a=30\n         OR c=3003\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR b=564\n         OR b=55\n         OR a=38\n  }\n} {5 7 8 9 14 23 30 38 44 46 49 75 76 88 scan 0 sort 0}\ndo_test where7-2.353.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=52\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {52 54 66 68 scan 0 sort 0}\ndo_test where7-2.353.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=52\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {52 54 66 68 scan 0 sort 0}\ndo_test where7-2.354.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=792\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n  }\n} {9 72 scan 0 sort 0}\ndo_test where7-2.354.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=792\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n  }\n} {9 72 scan 0 sort 0}\ndo_test where7-2.355.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR c=21021\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR f='zabcdefgh'\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=781\n         OR a=64\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {1 11 25 51 61 62 63 64 65 71 73 77 scan 0 sort 0}\ndo_test where7-2.355.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR c=21021\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR f='zabcdefgh'\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR b=781\n         OR a=64\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {1 11 25 51 61 62 63 64 65 71 73 77 scan 0 sort 0}\ndo_test where7-2.356.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR a=34\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR b=319\n         OR b=330\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {28 29 30 34 36 67 90 scan 0 sort 0}\ndo_test where7-2.356.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (d>=90.0 AND d<91.0 AND d NOT NULL)\n         OR a=34\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR b=319\n         OR b=330\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n  }\n} {28 29 30 34 36 67 90 scan 0 sort 0}\ndo_test where7-2.357.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=45\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n  }\n} {15 41 45 67 81 93 scan 0 sort 0}\ndo_test where7-2.357.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=45\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n  }\n} {15 41 45 67 81 93 scan 0 sort 0}\ndo_test where7-2.358.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=165\n         OR b=836\n  }\n} {15 53 54 76 scan 0 sort 0}\ndo_test where7-2.358.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=165\n         OR b=836\n  }\n} {15 53 54 76 scan 0 sort 0}\ndo_test where7-2.359.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1034\n         OR f='vwxyzabcd'\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n  }\n} {21 47 57 59 73 91 94 99 scan 0 sort 0}\ndo_test where7-2.359.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1034\n         OR f='vwxyzabcd'\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n  }\n} {21 47 57 59 73 91 94 99 scan 0 sort 0}\ndo_test where7-2.360.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=440\n         OR a=19\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=22022\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR a=92\n         OR b=1026\n         OR b=608\n  }\n} {19 40 47 64 65 66 92 scan 0 sort 0}\ndo_test where7-2.360.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=440\n         OR a=19\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=22022\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR a=92\n         OR b=1026\n         OR b=608\n  }\n} {19 40 47 64 65 66 92 scan 0 sort 0}\ndo_test where7-2.361.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=37\n         OR b=88\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR c=23023\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=56\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR f='ijklmnopq'\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {8 13 15 16 22 34 37 42 56 60 67 68 69 85 86 87 94 scan 0 sort 0}\ndo_test where7-2.361.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=37\n         OR b=88\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR c=23023\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=56\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR f='ijklmnopq'\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n  }\n} {8 13 15 16 22 34 37 42 56 60 67 68 69 85 86 87 94 scan 0 sort 0}\ndo_test where7-2.362.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=74\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n  }\n} {20 22 24 42 44 74 97 scan 0 sort 0}\ndo_test where7-2.362.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=74\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n  }\n} {20 22 24 42 44 74 97 scan 0 sort 0}\ndo_test where7-2.363.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='uvwxyzabc'\n         OR b=869\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n  }\n} {20 46 49 51 72 79 98 scan 0 sort 0}\ndo_test where7-2.363.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='uvwxyzabc'\n         OR b=869\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n  }\n} {20 46 49 51 72 79 98 scan 0 sort 0}\ndo_test where7-2.364.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=682\n         OR b=583\n         OR b=685\n         OR b=817\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n  }\n} {34 36 53 62 scan 0 sort 0}\ndo_test where7-2.364.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=682\n         OR b=583\n         OR b=685\n         OR b=817\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n  }\n} {34 36 53 62 scan 0 sort 0}\ndo_test where7-2.365.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=583\n         OR a=39\n         OR b=627\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n  }\n} {39 53 57 72 74 scan 0 sort 0}\ndo_test where7-2.365.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=583\n         OR a=39\n         OR b=627\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n  }\n} {39 53 57 72 74 scan 0 sort 0}\ndo_test where7-2.366.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR b=212\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=20\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=627\n  }\n} {2 4 20 24 26 53 57 68 73 scan 0 sort 0}\ndo_test where7-2.366.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR b=212\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=20\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=627\n  }\n} {2 4 20 24 26 53 57 68 73 scan 0 sort 0}\ndo_test where7-2.367.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=157\n         OR b=1026\n  }\n} {8 34 60 77 86 scan 0 sort 0}\ndo_test where7-2.367.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=157\n         OR b=1026\n  }\n} {8 34 60 77 86 scan 0 sort 0}\ndo_test where7-2.368.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=553\n         OR a=16\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR f='zabcdefgh'\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 11 16 25 31 33 51 67 77 80 82 scan 0 sort 0}\ndo_test where7-2.368.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=553\n         OR a=16\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR f='zabcdefgh'\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 11 16 25 31 33 51 67 77 80 82 scan 0 sort 0}\ndo_test where7-2.369.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=858\n         OR c=9009\n         OR b=792\n         OR b=88\n         OR b=154\n  }\n} {8 14 25 26 27 72 78 scan 0 sort 0}\ndo_test where7-2.369.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=858\n         OR c=9009\n         OR b=792\n         OR b=88\n         OR b=154\n  }\n} {8 14 25 26 27 72 78 scan 0 sort 0}\ndo_test where7-2.370.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f IS NULL\n         OR a=37\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR b=168\n         OR b=22\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=506\n  }\n} {2 21 37 46 48 55 57 scan 0 sort 0}\ndo_test where7-2.370.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f IS NULL\n         OR a=37\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR b=168\n         OR b=22\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=506\n  }\n} {2 21 37 46 48 55 57 scan 0 sort 0}\ndo_test where7-2.371.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=29\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=209\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR b=146\n  }\n} {19 25 26 28 29 42 45 51 69 71 77 97 scan 0 sort 0}\ndo_test where7-2.371.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=29\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=209\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR b=146\n  }\n} {19 25 26 28 29 42 45 51 69 71 77 97 scan 0 sort 0}\ndo_test where7-2.372.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=63\n         OR a=69\n         OR b=333\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR b=135\n         OR b=25\n         OR b=1037\n         OR b=682\n         OR c=27027\n         OR a=46\n  }\n} {6 46 62 63 69 79 80 81 scan 0 sort 0}\ndo_test where7-2.372.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=63\n         OR a=69\n         OR b=333\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR b=135\n         OR b=25\n         OR b=1037\n         OR b=682\n         OR c=27027\n         OR a=46\n  }\n} {6 46 62 63 69 79 80 81 scan 0 sort 0}\ndo_test where7-2.373.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=113\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {40 42 52 53 55 59 61 100 scan 0 sort 0}\ndo_test where7-2.373.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=113\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {40 42 52 53 55 59 61 100 scan 0 sort 0}\ndo_test where7-2.374.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1026\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n  }\n} {48 scan 0 sort 0}\ndo_test where7-2.374.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1026\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n  }\n} {48 scan 0 sort 0}\ndo_test where7-2.375.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='rqponml' AND f GLOB 'ijklm*')\n         OR a=99\n         OR a=100\n         OR b=429\n         OR b=682\n         OR b=495\n         OR f='efghijklm'\n         OR a=10\n         OR f='mnopqrstu'\n         OR b=946\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n  }\n} {4 10 12 30 34 38 39 45 56 62 64 82 86 90 95 99 100 scan 0 sort 0}\ndo_test where7-2.375.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='rqponml' AND f GLOB 'ijklm*')\n         OR a=99\n         OR a=100\n         OR b=429\n         OR b=682\n         OR b=495\n         OR f='efghijklm'\n         OR a=10\n         OR f='mnopqrstu'\n         OR b=946\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n  }\n} {4 10 12 30 34 38 39 45 56 62 64 82 86 90 95 99 100 scan 0 sort 0}\ndo_test where7-2.376.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR c=23023\n         OR b=462\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {11 17 19 42 67 68 69 scan 0 sort 0}\ndo_test where7-2.376.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR c=23023\n         OR b=462\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {11 17 19 42 67 68 69 scan 0 sort 0}\ndo_test where7-2.377.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=539\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR c=6006\n         OR a=18\n         OR c=24024\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR c=19019\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n  }\n} {9 11 16 17 18 38 43 44 46 49 55 56 57 70 71 72 87 scan 0 sort 0}\ndo_test where7-2.377.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=539\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR c=6006\n         OR a=18\n         OR c=24024\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR c=19019\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n  }\n} {9 11 16 17 18 38 43 44 46 49 55 56 57 70 71 72 87 scan 0 sort 0}\ndo_test where7-2.378.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=20\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=121\n         OR a=10\n         OR b=792\n  }\n} {10 11 15 20 72 94 scan 0 sort 0}\ndo_test where7-2.378.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR a=20\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=121\n         OR a=10\n         OR b=792\n  }\n} {10 11 15 20 72 94 scan 0 sort 0}\ndo_test where7-2.379.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=99\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {9 14 40 66 85 87 92 scan 0 sort 0}\ndo_test where7-2.379.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=99\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {9 14 40 66 85 87 92 scan 0 sort 0}\ndo_test where7-2.380.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR b=715\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n  }\n} {6 23 25 32 58 65 79 81 84 scan 0 sort 0}\ndo_test where7-2.380.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR b=715\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n  }\n} {6 23 25 32 58 65 79 81 84 scan 0 sort 0}\ndo_test where7-2.381.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR a=46\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n  }\n} {28 46 97 scan 0 sort 0}\ndo_test where7-2.381.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR a=46\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n  }\n} {28 46 97 scan 0 sort 0}\ndo_test where7-2.382.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR b=1056\n         OR b=146\n  }\n} {18 81 96 97 99 scan 0 sort 0}\ndo_test where7-2.382.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR b=1056\n         OR b=146\n  }\n} {18 81 96 97 99 scan 0 sort 0}\ndo_test where7-2.383.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=15\n         OR b=388\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR a=36\n         OR b=737\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR a=75\n  }\n} {15 21 23 36 67 75 82 84 89 scan 0 sort 0}\ndo_test where7-2.383.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=15\n         OR b=388\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR a=36\n         OR b=737\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR a=75\n  }\n} {15 21 23 36 67 75 82 84 89 scan 0 sort 0}\ndo_test where7-2.384.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=9009\n         OR a=34\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=715\n         OR b=619\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n  }\n} {16 25 26 27 34 65 95 98 100 scan 0 sort 0}\ndo_test where7-2.384.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=9009\n         OR a=34\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=715\n         OR b=619\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n  }\n} {16 25 26 27 34 65 95 98 100 scan 0 sort 0}\ndo_test where7-2.385.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=242\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=300\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {1 11 13 21 22 24 26 27 32 34 39 41 53 61 74 76 79 93 95 scan 0 sort 0}\ndo_test where7-2.385.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=242\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=300\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {1 11 13 21 22 24 26 27 32 34 39 41 53 61 74 76 79 93 95 scan 0 sort 0}\ndo_test where7-2.386.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=85\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=212\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=36\n         OR b=231\n         OR b=1048\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR c=19019\n  }\n} {21 25 27 33 43 55 56 57 69 71 85 92 scan 0 sort 0}\ndo_test where7-2.386.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=85\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=212\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=36\n         OR b=231\n         OR b=1048\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR c=19019\n  }\n} {21 25 27 33 43 55 56 57 69 71 85 92 scan 0 sort 0}\ndo_test where7-2.387.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR b=1059\n         OR b=630\n  }\n} {8 28 30 scan 0 sort 0}\ndo_test where7-2.387.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR b=1059\n         OR b=630\n  }\n} {8 28 30 scan 0 sort 0}\ndo_test where7-2.388.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='ghijklmno'\n         OR f='nopqrstuv'\n         OR b=297\n  }\n} {6 13 27 32 39 58 65 84 91 scan 0 sort 0}\ndo_test where7-2.388.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='ghijklmno'\n         OR f='nopqrstuv'\n         OR b=297\n  }\n} {6 13 27 32 39 58 65 84 91 scan 0 sort 0}\ndo_test where7-2.389.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1001\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR a=58\n         OR b=333\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=572\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 15 33 43 49 50 52 58 59 68 70 85 87 89 91 scan 0 sort 0}\ndo_test where7-2.389.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1001\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR a=58\n         OR b=333\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=572\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 15 33 43 49 50 52 58 59 68 70 85 87 89 91 scan 0 sort 0}\ndo_test where7-2.390.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1034\n         OR f='lmnopqrst'\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n  }\n} {11 37 38 63 89 94 scan 0 sort 0}\ndo_test where7-2.390.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1034\n         OR f='lmnopqrst'\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n  }\n} {11 37 38 63 89 94 scan 0 sort 0}\ndo_test where7-2.391.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=15015\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=58\n         OR b=674\n         OR b=979\n  }\n} {43 44 45 59 87 89 scan 0 sort 0}\ndo_test where7-2.391.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=15015\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=58\n         OR b=674\n         OR b=979\n  }\n} {43 44 45 59 87 89 scan 0 sort 0}\ndo_test where7-2.392.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=660\n         OR b=341\n  }\n} {31 60 62 scan 0 sort 0}\ndo_test where7-2.392.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=660\n         OR b=341\n  }\n} {31 60 62 scan 0 sort 0}\ndo_test where7-2.393.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=528\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR b=630\n         OR a=19\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR f='wxyzabcde'\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=377\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR a=77\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n  }\n} {8 19 22 43 44 48 64 74 77 100 scan 0 sort 0}\ndo_test where7-2.393.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=528\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR b=630\n         OR a=19\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR f='wxyzabcde'\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=377\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR a=77\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n  }\n} {8 19 22 43 44 48 64 74 77 100 scan 0 sort 0}\ndo_test where7-2.394.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=506\n         OR a=70\n  }\n} {46 70 scan 0 sort 0}\ndo_test where7-2.394.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=506\n         OR a=70\n  }\n} {46 70 scan 0 sort 0}\ndo_test where7-2.395.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=64\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR c=14014\n         OR b=586\n         OR c=27027\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {26 28 40 41 42 52 57 64 74 78 79 80 81 86 scan 0 sort 0}\ndo_test where7-2.395.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=64\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR c=14014\n         OR b=586\n         OR c=27027\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {26 28 40 41 42 52 57 64 74 78 79 80 81 86 scan 0 sort 0}\ndo_test where7-2.396.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=46\n         OR b=297\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=275\n         OR b=91\n         OR b=1015\n         OR c=12012\n         OR a=23\n         OR b=278\n  }\n} {23 25 27 34 35 36 46 57 59 75 scan 0 sort 0}\ndo_test where7-2.396.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=46\n         OR b=297\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=275\n         OR b=91\n         OR b=1015\n         OR c=12012\n         OR a=23\n         OR b=278\n  }\n} {23 25 27 34 35 36 46 57 59 75 scan 0 sort 0}\ndo_test where7-2.397.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR a=23\n         OR b=737\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n  }\n} {18 20 23 25 27 61 67 68 69 70 71 98 scan 0 sort 0}\ndo_test where7-2.397.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR a=23\n         OR b=737\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n  }\n} {18 20 23 25 27 61 67 68 69 70 71 98 scan 0 sort 0}\ndo_test where7-2.398.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=814\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR b=377\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n  }\n} {71 74 79 scan 0 sort 0}\ndo_test where7-2.398.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=814\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR b=377\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n  }\n} {71 74 79 scan 0 sort 0}\ndo_test where7-2.399.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=18\n         OR b=1059\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=795\n  }\n} {9 18 25 46 51 53 77 scan 0 sort 0}\ndo_test where7-2.399.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=18\n         OR b=1059\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=795\n  }\n} {9 18 25 46 51 53 77 scan 0 sort 0}\ndo_test where7-2.400.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR a=93\n         OR a=11\n         OR f='nopqrstuv'\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=17\n         OR b=366\n  }\n} {11 13 17 22 24 27 37 39 63 65 89 91 93 scan 0 sort 0}\ndo_test where7-2.400.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR a=93\n         OR a=11\n         OR f='nopqrstuv'\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=17\n         OR b=366\n  }\n} {11 13 17 22 24 27 37 39 63 65 89 91 93 scan 0 sort 0}\ndo_test where7-2.401.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=685\n         OR a=33\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=715\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=6\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {6 16 33 37 39 40 41 42 59 61 65 80 82 93 95 scan 0 sort 0}\ndo_test where7-2.401.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=685\n         OR a=33\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=715\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=6\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n  }\n} {6 16 33 37 39 40 41 42 59 61 65 80 82 93 95 scan 0 sort 0}\ndo_test where7-2.402.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=89\n         OR b=1037\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n  }\n} {60 89 scan 0 sort 0}\ndo_test where7-2.402.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=89\n         OR b=1037\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n  }\n} {60 89 scan 0 sort 0}\ndo_test where7-2.403.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=663\n         OR b=531\n         OR b=146\n         OR b=102\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR a=26\n  }\n} {26 28 44 46 87 89 97 scan 0 sort 0}\ndo_test where7-2.403.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=663\n         OR b=531\n         OR b=146\n         OR b=102\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR a=26\n  }\n} {26 28 44 46 87 89 97 scan 0 sort 0}\ndo_test where7-2.404.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=726\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=2002\n         OR c=15015\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=201\n  }\n} {4 5 6 12 35 43 44 45 64 66 70 73 75 scan 0 sort 0}\ndo_test where7-2.404.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=726\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=2002\n         OR c=15015\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=201\n  }\n} {4 5 6 12 35 43 44 45 64 66 70 73 75 scan 0 sort 0}\ndo_test where7-2.405.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=924\n         OR f='lmnopqrst'\n         OR b=1048\n  }\n} {11 37 63 72 84 89 scan 0 sort 0}\ndo_test where7-2.405.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=924\n         OR f='lmnopqrst'\n         OR b=1048\n  }\n} {11 37 63 72 84 89 scan 0 sort 0}\ndo_test where7-2.406.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=198\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=286\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {12 14 18 20 22 26 58 63 65 67 scan 0 sort 0}\ndo_test where7-2.406.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=198\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=286\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {12 14 18 20 22 26 58 63 65 67 scan 0 sort 0}\ndo_test where7-2.407.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=242\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR f='bcdefghij'\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=38\n         OR b=187\n  }\n} {1 17 19 22 27 38 53 57 59 79 88 99 scan 0 sort 0}\ndo_test where7-2.407.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=242\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR f='bcdefghij'\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=38\n         OR b=187\n  }\n} {1 17 19 22 27 38 53 57 59 79 88 99 scan 0 sort 0}\ndo_test where7-2.408.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=630\n         OR a=55\n         OR c=26026\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {10 23 55 68 76 77 78 scan 0 sort 0}\ndo_test where7-2.408.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=630\n         OR a=55\n         OR c=26026\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {10 23 55 68 76 77 78 scan 0 sort 0}\ndo_test where7-2.409.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='uvwxyzabc'\n         OR f='xyzabcdef'\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=69\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n  }\n} {8 20 23 31 34 46 49 51 53 60 70 72 75 79 86 98 scan 0 sort 0}\ndo_test where7-2.409.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='uvwxyzabc'\n         OR f='xyzabcdef'\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=69\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n  }\n} {8 20 23 31 34 46 49 51 53 60 70 72 75 79 86 98 scan 0 sort 0}\ndo_test where7-2.410.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1026\n         OR b=454\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR b=179\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='qrstuvwxy'\n  }\n} {16 26 42 52 68 78 92 94 scan 0 sort 0}\ndo_test where7-2.410.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1026\n         OR b=454\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR b=179\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='qrstuvwxy'\n  }\n} {16 26 42 52 68 78 92 94 scan 0 sort 0}\ndo_test where7-2.411.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 6 AND 8) AND a!=7)\n         OR b=619\n         OR a=20\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=946\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=64\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR b=1001\n         OR b=858\n  }\n} {6 8 13 17 19 20 61 64 78 86 91 scan 0 sort 0}\ndo_test where7-2.411.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 6 AND 8) AND a!=7)\n         OR b=619\n         OR a=20\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=946\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=64\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR b=1001\n         OR b=858\n  }\n} {6 8 13 17 19 20 61 64 78 86 91 scan 0 sort 0}\ndo_test where7-2.412.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=902\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=86\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {27 82 86 97 scan 0 sort 0}\ndo_test where7-2.412.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=902\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=86\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {27 82 86 97 scan 0 sort 0}\ndo_test where7-2.413.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=32\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR c=32032\n  }\n} {4 32 38 56 94 95 96 scan 0 sort 0}\ndo_test where7-2.413.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=32\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR c=32032\n  }\n} {4 32 38 56 94 95 96 scan 0 sort 0}\ndo_test where7-2.414.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=168\n         OR c=2002\n         OR b=77\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR f='qrstuvwxy'\n  }\n} {4 5 6 7 16 27 42 68 94 scan 0 sort 0}\ndo_test where7-2.414.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=168\n         OR c=2002\n         OR b=77\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR f='qrstuvwxy'\n  }\n} {4 5 6 7 16 27 42 68 94 scan 0 sort 0}\ndo_test where7-2.415.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='abcdefghi'\n         OR b=506\n  }\n} {26 46 52 78 scan 0 sort 0}\ndo_test where7-2.415.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='abcdefghi'\n         OR b=506\n  }\n} {26 46 52 78 scan 0 sort 0}\ndo_test where7-2.416.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=264\n         OR c=34034\n         OR a=96\n  }\n} {24 96 100 scan 0 sort 0}\ndo_test where7-2.416.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=264\n         OR c=34034\n         OR a=96\n  }\n} {24 96 100 scan 0 sort 0}\ndo_test where7-2.417.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR a=27\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n  }\n} {19 27 32 55 57 scan 0 sort 0}\ndo_test where7-2.417.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=32.0 AND d<33.0 AND d NOT NULL)\n         OR a=27\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n  }\n} {19 27 32 55 57 scan 0 sort 0}\ndo_test where7-2.418.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR b=77\n  }\n} {7 74 scan 0 sort 0}\ndo_test where7-2.418.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR b=77\n  }\n} {7 74 scan 0 sort 0}\ndo_test where7-2.419.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=27027\n         OR f='vwxyzabcd'\n         OR b=1048\n         OR a=96\n         OR a=99\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR b=561\n         OR b=352\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR a=95\n  }\n} {18 21 32 37 47 51 56 58 73 79 80 81 95 96 99 scan 0 sort 0}\ndo_test where7-2.419.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=27027\n         OR f='vwxyzabcd'\n         OR b=1048\n         OR a=96\n         OR a=99\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR b=561\n         OR b=352\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR a=95\n  }\n} {18 21 32 37 47 51 56 58 73 79 80 81 95 96 99 scan 0 sort 0}\ndo_test where7-2.420.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=275\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='ghijklmno'\n         OR b=619\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=476\n         OR a=83\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n  }\n} {6 10 12 25 32 47 49 58 83 84 91 93 99 scan 0 sort 0}\ndo_test where7-2.420.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=275\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='ghijklmno'\n         OR b=619\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=476\n         OR a=83\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n  }\n} {6 10 12 25 32 47 49 58 83 84 91 93 99 scan 0 sort 0}\ndo_test where7-2.421.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=542\n         OR a=17\n         OR f='jklmnopqr'\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR a=23\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {5 7 9 17 23 25 35 39 61 87 scan 0 sort 0}\ndo_test where7-2.421.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=542\n         OR a=17\n         OR f='jklmnopqr'\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n         OR a=23\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {5 7 9 17 23 25 35 39 61 87 scan 0 sort 0}\ndo_test where7-2.422.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR b=363\n         OR b=454\n  }\n} {33 74 scan 0 sort 0}\ndo_test where7-2.422.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR b=363\n         OR b=454\n  }\n} {33 74 scan 0 sort 0}\ndo_test where7-2.423.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1059\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=47\n         OR b=660\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR a=84\n  }\n} {34 35 36 60 76 84 scan 0 sort 0}\ndo_test where7-2.423.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1059\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=47\n         OR b=660\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR a=84\n  }\n} {34 35 36 60 76 84 scan 0 sort 0}\ndo_test where7-2.424.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='ghijklmno'\n         OR b=1012\n  }\n} {6 32 58 84 92 scan 0 sort 0}\ndo_test where7-2.424.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='ghijklmno'\n         OR b=1012\n  }\n} {6 32 58 84 92 scan 0 sort 0}\ndo_test where7-2.425.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=597\n         OR f='lmnopqrst'\n         OR a=24\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR b=1023\n         OR a=53\n         OR a=78\n         OR f='efghijklm'\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {4 11 24 30 31 33 37 53 56 63 78 82 85 89 93 96 scan 0 sort 0}\ndo_test where7-2.425.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=597\n         OR f='lmnopqrst'\n         OR a=24\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR b=1023\n         OR a=53\n         OR a=78\n         OR f='efghijklm'\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {4 11 24 30 31 33 37 53 56 63 78 82 85 89 93 96 scan 0 sort 0}\ndo_test where7-2.426.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=198\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=388\n  }\n} {18 94 scan 0 sort 0}\ndo_test where7-2.426.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=198\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=388\n  }\n} {18 94 scan 0 sort 0}\ndo_test where7-2.427.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='tuvwxyzab'\n         OR b=388\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR b=957\n         OR b=663\n         OR b=847\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n  }\n} {19 45 71 73 77 84 86 87 96 97 scan 0 sort 0}\ndo_test where7-2.427.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='tuvwxyzab'\n         OR b=388\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR b=957\n         OR b=663\n         OR b=847\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n  }\n} {19 45 71 73 77 84 86 87 96 97 scan 0 sort 0}\ndo_test where7-2.428.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR a=56\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {56 81 84 scan 0 sort 0}\ndo_test where7-2.428.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR a=56\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n  }\n} {56 81 84 scan 0 sort 0}\ndo_test where7-2.429.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c>=34035\n         OR b=168\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 27 53 79 89 scan 0 sort 0}\ndo_test where7-2.429.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c>=34035\n         OR b=168\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n  }\n} {1 27 53 79 89 scan 0 sort 0}\ndo_test where7-2.430.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 79 AND 81) AND a!=80)\n         OR b=564\n         OR c=6006\n         OR b=979\n  }\n} {16 17 18 79 81 89 scan 0 sort 0}\ndo_test where7-2.430.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 79 AND 81) AND a!=80)\n         OR b=564\n         OR c=6006\n         OR b=979\n  }\n} {16 17 18 79 81 89 scan 0 sort 0}\ndo_test where7-2.431.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR f='rstuvwxyz'\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n  }\n} {17 29 39 40 43 69 95 scan 0 sort 0}\ndo_test where7-2.431.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR f='rstuvwxyz'\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n  }\n} {17 29 39 40 43 69 95 scan 0 sort 0}\ndo_test where7-2.432.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=58\n         OR b=484\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR b=671\n         OR a=69\n  }\n} {44 61 68 69 scan 0 sort 0}\ndo_test where7-2.432.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=58\n         OR b=484\n         OR (d>=68.0 AND d<69.0 AND d NOT NULL)\n         OR b=671\n         OR a=69\n  }\n} {44 61 68 69 scan 0 sort 0}\ndo_test where7-2.433.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='mnopqrstu'\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=861\n         OR b=77\n         OR f='qrstuvwxy'\n  }\n} {7 12 16 38 42 64 68 73 90 94 scan 0 sort 0}\ndo_test where7-2.433.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='mnopqrstu'\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=861\n         OR b=77\n         OR f='qrstuvwxy'\n  }\n} {7 12 16 38 42 64 68 73 90 94 scan 0 sort 0}\ndo_test where7-2.434.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=113\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=113\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=6006\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR b=946\n         OR a=86\n  }\n} {4 14 16 17 18 51 62 64 86 scan 0 sort 0}\ndo_test where7-2.434.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=113\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=113\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n         OR c=6006\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR b=946\n         OR a=86\n  }\n} {4 14 16 17 18 51 62 64 86 scan 0 sort 0}\ndo_test where7-2.435.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR c=22022\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=25025\n  }\n} {8 10 64 65 66 73 74 75 79 81 85 scan 0 sort 0}\ndo_test where7-2.435.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR c=22022\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=25025\n  }\n} {8 10 64 65 66 73 74 75 79 81 85 scan 0 sort 0}\ndo_test where7-2.436.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=47\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=92\n         OR b=795\n         OR b=25\n         OR c=7007\n         OR a=93\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n  }\n} {14 18 19 20 21 40 44 46 66 74 76 92 93 95 scan 0 sort 0}\ndo_test where7-2.436.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=47\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=92\n         OR b=795\n         OR b=25\n         OR c=7007\n         OR a=93\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n  }\n} {14 18 19 20 21 40 44 46 66 74 76 92 93 95 scan 0 sort 0}\ndo_test where7-2.437.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR a=13\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR c=29029\n         OR b=311\n         OR b=366\n         OR a=94\n         OR a=72\n  }\n} {6 13 66 72 85 86 87 94 scan 0 sort 0}\ndo_test where7-2.437.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR a=13\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR c=29029\n         OR b=311\n         OR b=366\n         OR a=94\n         OR a=72\n  }\n} {6 13 66 72 85 86 87 94 scan 0 sort 0}\ndo_test where7-2.438.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=26026\n         OR a=96\n         OR a=22\n         OR b=341\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=872\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n  }\n} {2 22 25 27 31 76 77 78 96 scan 0 sort 0}\ndo_test where7-2.438.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=26026\n         OR a=96\n         OR a=22\n         OR b=341\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=872\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n  }\n} {2 22 25 27 31 76 77 78 96 scan 0 sort 0}\ndo_test where7-2.439.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=41\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR b=913\n  }\n} {6 23 36 41 51 63 65 82 83 scan 0 sort 0}\ndo_test where7-2.439.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=41\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR b=913\n  }\n} {6 23 36 41 51 63 65 82 83 scan 0 sort 0}\ndo_test where7-2.440.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 42 AND 44) AND a!=43)\n         OR a=90\n  }\n} {42 44 90 scan 0 sort 0}\ndo_test where7-2.440.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 42 AND 44) AND a!=43)\n         OR a=90\n  }\n} {42 44 90 scan 0 sort 0}\ndo_test where7-2.441.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR b=484\n  }\n} {21 44 scan 0 sort 0}\ndo_test where7-2.441.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR b=484\n  }\n} {21 44 scan 0 sort 0}\ndo_test where7-2.442.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=377\n         OR b=363\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR b=737\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR b=506\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR a=16\n  }\n} {16 22 25 33 46 55 57 67 100 scan 0 sort 0}\ndo_test where7-2.442.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=377\n         OR b=363\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR b=737\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR b=506\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR a=16\n  }\n} {16 22 25 33 46 55 57 67 100 scan 0 sort 0}\ndo_test where7-2.443.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=102\n         OR b=212\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=487\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n  }\n} {37 77 82 scan 0 sort 0}\ndo_test where7-2.443.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=102\n         OR b=212\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=487\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n  }\n} {37 77 82 scan 0 sort 0}\ndo_test where7-2.444.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=154\n         OR a=51\n         OR b=520\n  }\n} {14 51 scan 0 sort 0}\ndo_test where7-2.444.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=154\n         OR a=51\n         OR b=520\n  }\n} {14 51 scan 0 sort 0}\ndo_test where7-2.445.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=872\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=957\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR a=67\n         OR a=72\n  }\n} {21 42 47 58 60 67 72 73 87 99 scan 0 sort 0}\ndo_test where7-2.445.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=872\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=957\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR a=67\n         OR a=72\n  }\n} {21 42 47 58 60 67 72 73 87 99 scan 0 sort 0}\ndo_test where7-2.446.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=66\n         OR b=102\n         OR b=396\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR b=759\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR f='ghijklmno'\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {6 7 9 14 32 36 58 69 84 90 92 97 100 scan 0 sort 0}\ndo_test where7-2.446.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=66\n         OR b=102\n         OR b=396\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR b=759\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR f='ghijklmno'\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n  }\n} {6 7 9 14 32 36 58 69 84 90 92 97 100 scan 0 sort 0}\ndo_test where7-2.447.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR a=72\n         OR b=1100\n         OR b=102\n         OR b=135\n  }\n} {24 48 50 69 71 72 76 100 scan 0 sort 0}\ndo_test where7-2.447.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR a=72\n         OR b=1100\n         OR b=102\n         OR b=135\n  }\n} {24 48 50 69 71 72 76 100 scan 0 sort 0}\ndo_test where7-2.448.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=99\n         OR a=76\n  }\n} {9 76 scan 0 sort 0}\ndo_test where7-2.448.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=99\n         OR a=76\n  }\n} {9 76 scan 0 sort 0}\ndo_test where7-2.449.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=891\n         OR b=806\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=861\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n  }\n} {19 34 81 82 84 85 87 scan 0 sort 0}\ndo_test where7-2.449.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=891\n         OR b=806\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=861\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n  }\n} {19 34 81 82 84 85 87 scan 0 sort 0}\ndo_test where7-2.450.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1034\n         OR b=91\n  }\n} {94 scan 0 sort 0}\ndo_test where7-2.450.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1034\n         OR b=91\n  }\n} {94 scan 0 sort 0}\ndo_test where7-2.451.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=47\n         OR a=91\n         OR d>1e10\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n  }\n} {28 91 scan 0 sort 0}\ndo_test where7-2.451.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=47\n         OR a=91\n         OR d>1e10\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n  }\n} {28 91 scan 0 sort 0}\ndo_test where7-2.452.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1023\n         OR f='zabcdefgh'\n         OR b=451\n         OR b=443\n         OR c>=34035\n         OR b=58\n  }\n} {25 41 51 77 93 scan 0 sort 0}\ndo_test where7-2.452.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1023\n         OR f='zabcdefgh'\n         OR b=451\n         OR b=443\n         OR c>=34035\n         OR b=58\n  }\n} {25 41 51 77 93 scan 0 sort 0}\ndo_test where7-2.453.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=971\n         OR b=36\n         OR a=11\n         OR f='hijklmnop'\n  }\n} {7 11 33 59 85 scan 0 sort 0}\ndo_test where7-2.453.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=971\n         OR b=36\n         OR a=11\n         OR f='hijklmnop'\n  }\n} {7 11 33 59 85 scan 0 sort 0}\ndo_test where7-2.454.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=619\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR c=11011\n         OR b=550\n         OR b=1059\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR b=737\n  }\n} {3 18 29 31 32 33 50 55 67 78 81 84 91 92 93 scan 0 sort 0}\ndo_test where7-2.454.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=619\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR c=11011\n         OR b=550\n         OR b=1059\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR b=737\n  }\n} {3 18 29 31 32 33 50 55 67 78 81 84 91 92 93 scan 0 sort 0}\ndo_test where7-2.455.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR a=78\n         OR a=27\n         OR b=792\n         OR b=946\n         OR c=22022\n         OR a=23\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=388\n  }\n} {13 23 27 39 59 61 64 65 66 72 78 80 86 91 99 scan 0 sort 0}\ndo_test where7-2.455.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR a=78\n         OR a=27\n         OR b=792\n         OR b=946\n         OR c=22022\n         OR a=23\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=388\n  }\n} {13 23 27 39 59 61 64 65 66 72 78 80 86 91 99 scan 0 sort 0}\ndo_test where7-2.456.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=32032\n         OR f IS NULL\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR b=825\n  }\n} {4 37 39 74 75 94 95 96 scan 0 sort 0}\ndo_test where7-2.456.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=32032\n         OR f IS NULL\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR b=825\n  }\n} {4 37 39 74 75 94 95 96 scan 0 sort 0}\ndo_test where7-2.457.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=1078\n         OR b=198\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR b=55\n         OR b=517\n         OR b=740\n  }\n} {5 7 18 21 47 54 67 73 84 98 99 scan 0 sort 0}\ndo_test where7-2.457.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=1078\n         OR b=198\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR b=55\n         OR b=517\n         OR b=740\n  }\n} {5 7 18 21 47 54 67 73 84 98 99 scan 0 sort 0}\ndo_test where7-2.458.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR c=25025\n         OR b=550\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {8 22 50 53 73 74 75 scan 0 sort 0}\ndo_test where7-2.458.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR c=25025\n         OR b=550\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n  }\n} {8 22 50 53 73 74 75 scan 0 sort 0}\ndo_test where7-2.459.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=432\n         OR f='opqrstuvw'\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n  }\n} {14 40 66 68 92 scan 0 sort 0}\ndo_test where7-2.459.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=432\n         OR f='opqrstuvw'\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n  }\n} {14 40 66 68 92 scan 0 sort 0}\ndo_test where7-2.460.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=847\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR b=583\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=938\n  }\n} {11 14 16 26 37 40 42 53 63 65 75 77 89 scan 0 sort 0}\ndo_test where7-2.460.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=847\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR b=583\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR b=938\n  }\n} {11 14 16 26 37 40 42 53 63 65 75 77 89 scan 0 sort 0}\ndo_test where7-2.461.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=671\n         OR a=56\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR b=157\n         OR a=83\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR c=21021\n         OR b=319\n         OR b=187\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=839\n  }\n} {17 29 49 56 61 62 63 65 67 73 75 83 scan 0 sort 0}\ndo_test where7-2.461.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=671\n         OR a=56\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR b=157\n         OR a=83\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR c=21021\n         OR b=319\n         OR b=187\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=839\n  }\n} {17 29 49 56 61 62 63 65 67 73 75 83 scan 0 sort 0}\ndo_test where7-2.462.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=586\n         OR d<0.0\n         OR c=9009\n  }\n} {25 26 27 72 scan 0 sort 0}\ndo_test where7-2.462.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=586\n         OR d<0.0\n         OR c=9009\n  }\n} {25 26 27 72 scan 0 sort 0}\ndo_test where7-2.463.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=82\n         OR a=34\n         OR f='jklmnopqr'\n         OR a=82\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=454\n         OR b=355\n         OR c=21021\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=30\n  }\n} {9 16 30 34 35 61 62 63 65 82 87 scan 0 sort 0}\ndo_test where7-2.463.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=82\n         OR a=34\n         OR f='jklmnopqr'\n         OR a=82\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=454\n         OR b=355\n         OR c=21021\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=30\n  }\n} {9 16 30 34 35 61 62 63 65 82 87 scan 0 sort 0}\ndo_test where7-2.464.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=53\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=594\n         OR b=80\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR d>1e10\n  }\n} {18 20 23 44 46 49 53 54 scan 0 sort 0}\ndo_test where7-2.464.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 44 AND 46) AND a!=45)\n         OR a=53\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=594\n         OR b=80\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR d>1e10\n  }\n} {18 20 23 44 46 49 53 54 scan 0 sort 0}\ndo_test where7-2.465.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='opqrstuvw'\n         OR a=7\n  }\n} {7 14 40 66 92 scan 0 sort 0}\ndo_test where7-2.465.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='opqrstuvw'\n         OR a=7\n  }\n} {7 14 40 66 92 scan 0 sort 0}\ndo_test where7-2.466.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=627\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=90\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n  }\n} {33 43 45 57 75 77 90 scan 0 sort 0}\ndo_test where7-2.466.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=627\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR a=90\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n  }\n} {33 43 45 57 75 77 90 scan 0 sort 0}\ndo_test where7-2.467.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=59\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR f='wxyzabcde'\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR a=70\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {5 9 14 16 22 23 25 48 51 59 69 70 71 74 77 100 scan 0 sort 0}\ndo_test where7-2.467.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=59\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR f='wxyzabcde'\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR a=70\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {5 9 14 16 22 23 25 48 51 59 69 70 71 74 77 100 scan 0 sort 0}\ndo_test where7-2.468.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=69\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n  }\n} {69 81 scan 0 sort 0}\ndo_test where7-2.468.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=69\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n  }\n} {69 81 scan 0 sort 0}\ndo_test where7-2.469.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=41\n         OR a=43\n         OR a=92\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n  }\n} {41 43 62 92 95 scan 0 sort 0}\ndo_test where7-2.469.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=41\n         OR a=43\n         OR a=92\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n  }\n} {41 43 62 92 95 scan 0 sort 0}\ndo_test where7-2.470.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=300\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=935\n         OR b=190\n  }\n} {52 85 scan 0 sort 0}\ndo_test where7-2.470.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=300\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR b=935\n         OR b=190\n  }\n} {52 85 scan 0 sort 0}\ndo_test where7-2.471.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='fghijklmn'\n         OR f='fghijklmn'\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR b=465\n         OR b=586\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=88\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=726\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {4 5 8 20 30 31 32 51 53 57 66 83 scan 0 sort 0}\ndo_test where7-2.471.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='fghijklmn'\n         OR f='fghijklmn'\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR b=465\n         OR b=586\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=88\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=726\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {4 5 8 20 30 31 32 51 53 57 66 83 scan 0 sort 0}\ndo_test where7-2.472.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=814\n         OR a=20\n         OR 1000000<b\n         OR b=792\n  }\n} {20 25 34 51 72 74 77 85 97 100 scan 0 sort 0}\ndo_test where7-2.472.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=814\n         OR a=20\n         OR 1000000<b\n         OR b=792\n  }\n} {20 25 34 51 72 74 77 85 97 100 scan 0 sort 0}\ndo_test where7-2.473.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR c=1001\n         OR b=484\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR c<=10\n         OR a=92\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR b=1026\n  }\n} {1 2 3 25 44 53 55 65 72 92 scan 0 sort 0}\ndo_test where7-2.473.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR c=1001\n         OR b=484\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR c<=10\n         OR a=92\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR b=1026\n  }\n} {1 2 3 25 44 53 55 65 72 92 scan 0 sort 0}\ndo_test where7-2.474.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=54\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR b=993\n         OR c=22022\n         OR a=68\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR a=62\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=1015\n  }\n} {3 29 54 55 62 64 65 66 68 81 99 scan 0 sort 0}\ndo_test where7-2.474.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=54\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR b=993\n         OR c=22022\n         OR a=68\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR a=62\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR b=1015\n  }\n} {3 29 54 55 62 64 65 66 68 81 99 scan 0 sort 0}\ndo_test where7-2.475.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=319\n         OR a=50\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR a=96\n  }\n} {10 29 50 55 92 96 scan 0 sort 0}\ndo_test where7-2.475.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=319\n         OR a=50\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR a=96\n  }\n} {10 29 50 55 92 96 scan 0 sort 0}\ndo_test where7-2.476.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=971\n         OR c=18018\n         OR b=564\n         OR b=583\n         OR b=80\n  }\n} {52 53 54 scan 0 sort 0}\ndo_test where7-2.476.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=971\n         OR c=18018\n         OR b=564\n         OR b=583\n         OR b=80\n  }\n} {52 53 54 scan 0 sort 0}\ndo_test where7-2.477.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR b=1026\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 35 scan 0 sort 0}\ndo_test where7-2.477.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR b=1026\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 35 scan 0 sort 0}\ndo_test where7-2.478.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=407\n         OR b=454\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=627\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {9 13 34 35 37 39 46 57 61 65 87 91 scan 0 sort 0}\ndo_test where7-2.478.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=407\n         OR b=454\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=627\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {9 13 34 35 37 39 46 57 61 65 87 91 scan 0 sort 0}\ndo_test where7-2.479.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=34034\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR a=67\n  }\n} {6 18 20 24 26 32 58 67 79 84 100 scan 0 sort 0}\ndo_test where7-2.479.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=34034\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR a=67\n  }\n} {6 18 20 24 26 32 58 67 79 84 100 scan 0 sort 0}\ndo_test where7-2.480.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=97\n         OR b=575\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n  }\n} {1 2 4 16 42 68 81 94 97 scan 0 sort 0}\ndo_test where7-2.480.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=97\n         OR b=575\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n  }\n} {1 2 4 16 42 68 81 94 97 scan 0 sort 0}\ndo_test where7-2.481.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=561\n         OR b=773\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=201\n         OR a=99\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR b=946\n         OR b=993\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n  }\n} {19 23 36 38 46 51 86 94 99 scan 0 sort 0}\ndo_test where7-2.481.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=561\n         OR b=773\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=201\n         OR a=99\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR b=946\n         OR b=993\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n  }\n} {19 23 36 38 46 51 86 94 99 scan 0 sort 0}\ndo_test where7-2.482.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=806\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=916\n         OR b<0\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=154\n         OR c=10010\n         OR b=451\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n  }\n} {14 24 26 28 29 30 41 62 72 scan 0 sort 0}\ndo_test where7-2.482.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=806\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=916\n         OR b<0\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=154\n         OR c=10010\n         OR b=451\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n  }\n} {14 24 26 28 29 30 41 62 72 scan 0 sort 0}\ndo_test where7-2.483.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=836\n         OR d>1e10\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR f='pqrstuvwx'\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR f='abcdefghi'\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR a=33\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR b=476\n  }\n} {3 5 15 19 20 21 26 33 41 52 57 67 76 78 88 90 93 scan 0 sort 0}\ndo_test where7-2.483.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=836\n         OR d>1e10\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR f='pqrstuvwx'\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR f='abcdefghi'\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR a=33\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR b=476\n  }\n} {3 5 15 19 20 21 26 33 41 52 57 67 76 78 88 90 93 scan 0 sort 0}\ndo_test where7-2.484.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=48\n         OR a=92\n         OR a=1\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR b=905\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {1 4 7 28 30 37 48 51 53 56 82 92 scan 0 sort 0}\ndo_test where7-2.484.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=48\n         OR a=92\n         OR a=1\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR b=905\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n  }\n} {1 4 7 28 30 37 48 51 53 56 82 92 scan 0 sort 0}\ndo_test where7-2.485.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=212\n         OR a=42\n         OR a=92\n  }\n} {4 17 42 92 scan 0 sort 0}\ndo_test where7-2.485.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=212\n         OR a=42\n         OR a=92\n  }\n} {4 17 42 92 scan 0 sort 0}\ndo_test where7-2.486.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=740\n         OR b=564\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=11\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR b=322\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR b=902\n         OR c>=34035\n  }\n} {6 11 22 44 46 51 82 scan 0 sort 0}\ndo_test where7-2.486.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=740\n         OR b=564\n         OR (g='onmlkji' AND f GLOB 'zabcd*')\n         OR a=11\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR b=322\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR b=902\n         OR c>=34035\n  }\n} {6 11 22 44 46 51 82 scan 0 sort 0}\ndo_test where7-2.487.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 52 AND 54) AND a!=53)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=27\n         OR a=48\n         OR b=927\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR f='abcdefghi'\n         OR b=91\n         OR b=55\n  }\n} {5 8 26 27 48 52 54 56 58 78 89 91 96 scan 0 sort 0}\ndo_test where7-2.487.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 52 AND 54) AND a!=53)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=27\n         OR a=48\n         OR b=927\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n         OR f='abcdefghi'\n         OR b=91\n         OR b=55\n  }\n} {5 8 26 27 48 52 54 56 58 78 89 91 96 scan 0 sort 0}\ndo_test where7-2.488.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='srqponm' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR a=20\n         OR b=11\n  }\n} {1 20 30 88 90 scan 0 sort 0}\ndo_test where7-2.488.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='srqponm' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR a=20\n         OR b=11\n  }\n} {1 20 30 88 90 scan 0 sort 0}\ndo_test where7-2.489.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=55\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR a=50\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n  }\n} {5 13 27 50 51 52 64 73 scan 0 sort 0}\ndo_test where7-2.489.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=55\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR a=50\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n  }\n} {5 13 27 50 51 52 64 73 scan 0 sort 0}\ndo_test where7-2.490.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='rqponml' AND f GLOB 'ijklm*')\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n  }\n} {22 34 48 74 100 scan 0 sort 0}\ndo_test where7-2.490.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='rqponml' AND f GLOB 'ijklm*')\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n  }\n} {22 34 48 74 100 scan 0 sort 0}\ndo_test where7-2.491.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=704\n         OR b=924\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR b=113\n  }\n} {64 84 90 scan 0 sort 0}\ndo_test where7-2.491.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=704\n         OR b=924\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR b=113\n  }\n} {64 84 90 scan 0 sort 0}\ndo_test where7-2.492.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=289\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 20 22 scan 0 sort 0}\ndo_test where7-2.492.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=289\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 20 22 scan 0 sort 0}\ndo_test where7-2.493.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=935\n         OR b=1001\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=31\n         OR a=56\n  }\n} {31 56 78 80 85 91 scan 0 sort 0}\ndo_test where7-2.493.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=935\n         OR b=1001\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=31\n         OR a=56\n  }\n} {31 56 78 80 85 91 scan 0 sort 0}\ndo_test where7-2.494.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=726\n         OR f='abcdefghi'\n         OR b=179\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=539\n         OR b=66\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {6 9 19 26 35 49 52 60 61 66 78 86 87 88 scan 0 sort 0}\ndo_test where7-2.494.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=726\n         OR f='abcdefghi'\n         OR b=179\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=539\n         OR b=66\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {6 9 19 26 35 49 52 60 61 66 78 86 87 88 scan 0 sort 0}\ndo_test where7-2.495.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=179\n         OR b=685\n  }\n} { scan 0 sort 0}\ndo_test where7-2.495.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=179\n         OR b=685\n  }\n} { scan 0 sort 0}\ndo_test where7-2.496.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=201\n         OR b=682\n         OR b=443\n         OR b=836\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR b=110\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n  }\n} {2 10 11 13 28 39 51 53 54 62 65 76 80 91 scan 0 sort 0}\ndo_test where7-2.496.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=201\n         OR b=682\n         OR b=443\n         OR b=836\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR ((a BETWEEN 51 AND 53) AND a!=52)\n         OR b=110\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n  }\n} {2 10 11 13 28 39 51 53 54 62 65 76 80 91 scan 0 sort 0}\ndo_test where7-2.497.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=462\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=22\n         OR b=594\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n  }\n} {4 6 18 22 24 42 44 50 54 57 61 70 74 76 96 scan 0 sort 0}\ndo_test where7-2.497.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=462\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR a=22\n         OR b=594\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n  }\n} {4 6 18 22 24 42 44 50 54 57 61 70 74 76 96 scan 0 sort 0}\ndo_test where7-2.498.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR f='vwxyzabcd'\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR a=37\n         OR a=50\n  }\n} {1 10 13 21 22 37 47 50 73 99 scan 0 sort 0}\ndo_test where7-2.498.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR f='vwxyzabcd'\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR a=37\n         OR a=50\n  }\n} {1 10 13 21 22 37 47 50 73 99 scan 0 sort 0}\ndo_test where7-2.499.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 83 AND 85) AND a!=84)\n         OR b=784\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR b=825\n         OR a=80\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=531\n         OR a=100\n  }\n} {20 23 46 72 75 80 83 85 97 98 100 scan 0 sort 0}\ndo_test where7-2.499.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 83 AND 85) AND a!=84)\n         OR b=784\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR b=825\n         OR a=80\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=531\n         OR a=100\n  }\n} {20 23 46 72 75 80 83 85 97 98 100 scan 0 sort 0}\ndo_test where7-2.500.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=220\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {19 20 53 scan 0 sort 0}\ndo_test where7-2.500.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR b=220\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {19 20 53 scan 0 sort 0}\ndo_test where7-2.501.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=92\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=990\n  }\n} {9 90 92 scan 0 sort 0}\ndo_test where7-2.501.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=92\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=990\n  }\n} {9 90 92 scan 0 sort 0}\ndo_test where7-2.502.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 77 AND 79) AND a!=78)\n         OR b=894\n         OR c=28028\n         OR b=905\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR b=1037\n  }\n} {26 45 52 70 77 78 79 82 83 84 scan 0 sort 0}\ndo_test where7-2.502.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 77 AND 79) AND a!=78)\n         OR b=894\n         OR c=28028\n         OR b=905\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR b=1037\n  }\n} {26 45 52 70 77 78 79 82 83 84 scan 0 sort 0}\ndo_test where7-2.503.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR b=773\n         OR f='defghijkl'\n  }\n} {3 29 55 72 81 scan 0 sort 0}\ndo_test where7-2.503.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR b=773\n         OR f='defghijkl'\n  }\n} {3 29 55 72 81 scan 0 sort 0}\ndo_test where7-2.504.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=861\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {12 37 scan 0 sort 0}\ndo_test where7-2.504.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=861\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {12 37 scan 0 sort 0}\ndo_test where7-2.505.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=704\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=25\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=487\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n  }\n} {10 23 51 64 77 79 83 84 89 scan 0 sort 0}\ndo_test where7-2.505.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=704\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=25\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=487\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n  }\n} {10 23 51 64 77 79 83 84 89 scan 0 sort 0}\ndo_test where7-2.506.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=19\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=674\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=355\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c=28028\n         OR b=649\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n  }\n} {17 19 31 41 49 59 60 72 74 82 83 84 scan 0 sort 0}\ndo_test where7-2.506.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=19\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=674\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=355\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c=28028\n         OR b=649\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n  }\n} {17 19 31 41 49 59 60 72 74 82 83 84 scan 0 sort 0}\ndo_test where7-2.507.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 76 AND 78) AND a!=77)\n         OR a=1\n         OR a=22\n         OR b=836\n         OR c=24024\n  }\n} {1 22 70 71 72 76 78 scan 0 sort 0}\ndo_test where7-2.507.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 76 AND 78) AND a!=77)\n         OR a=1\n         OR a=22\n         OR b=836\n         OR c=24024\n  }\n} {1 22 70 71 72 76 78 scan 0 sort 0}\ndo_test where7-2.508.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=135\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {20 39 41 scan 0 sort 0}\ndo_test where7-2.508.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=135\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {20 39 41 scan 0 sort 0}\ndo_test where7-2.509.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {9 35 61 86 87 scan 0 sort 0}\ndo_test where7-2.509.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {9 35 61 86 87 scan 0 sort 0}\ndo_test where7-2.510.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'wxyza*')\n         OR f='ghijklmno'\n  }\n} {6 32 58 74 84 scan 0 sort 0}\ndo_test where7-2.510.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'wxyza*')\n         OR f='ghijklmno'\n  }\n} {6 32 58 74 84 scan 0 sort 0}\ndo_test where7-2.511.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=825\n         OR b=902\n         OR a=40\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR a=30\n         OR a=10\n         OR a=73\n  }\n} {10 28 30 40 73 75 82 scan 0 sort 0}\ndo_test where7-2.511.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=825\n         OR b=902\n         OR a=40\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR a=30\n         OR a=10\n         OR a=73\n  }\n} {10 28 30 40 73 75 82 scan 0 sort 0}\ndo_test where7-2.512.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=5\n         OR b=432\n         OR b=979\n         OR b=762\n         OR b=352\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR c=27027\n         OR c=20020\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {5 22 23 24 32 36 38 58 59 60 79 80 81 89 scan 0 sort 0}\ndo_test where7-2.512.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR a=5\n         OR b=432\n         OR b=979\n         OR b=762\n         OR b=352\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR c=27027\n         OR c=20020\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {5 22 23 24 32 36 38 58 59 60 79 80 81 89 scan 0 sort 0}\ndo_test where7-2.513.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=99\n         OR a=54\n  }\n} {5 7 9 10 36 54 62 88 scan 0 sort 0}\ndo_test where7-2.513.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=99\n         OR a=54\n  }\n} {5 7 9 10 36 54 62 88 scan 0 sort 0}\ndo_test where7-2.514.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=300\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n         OR b=319\n         OR f='fghijklmn'\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n  }\n} {5 29 31 42 44 57 62 73 83 scan 0 sort 0}\ndo_test where7-2.514.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=300\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n         OR b=319\n         OR f='fghijklmn'\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n  }\n} {5 29 31 42 44 57 62 73 83 scan 0 sort 0}\ndo_test where7-2.515.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=671\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=1004\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=748\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {5 7 18 20 23 27 61 68 82 86 88 scan 0 sort 0}\ndo_test where7-2.515.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=671\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=1004\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=748\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {5 7 18 20 23 27 61 68 82 86 88 scan 0 sort 0}\ndo_test where7-2.516.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=47\n         OR b=784\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=16\n         OR a=25\n         OR b=572\n  }\n} {16 21 23 25 47 52 scan 0 sort 0}\ndo_test where7-2.516.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=47\n         OR b=784\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=16\n         OR a=25\n         OR b=572\n  }\n} {16 21 23 25 47 52 scan 0 sort 0}\ndo_test where7-2.517.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR b=110\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR c=26026\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR b=850\n         OR a=6\n  }\n} {6 10 67 69 74 76 77 78 91 scan 0 sort 0}\ndo_test where7-2.517.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR b=110\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR c=26026\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR b=850\n         OR a=6\n  }\n} {6 10 67 69 74 76 77 78 91 scan 0 sort 0}\ndo_test where7-2.518.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n         OR b=135\n         OR a=28\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=737\n  }\n} {1 3 19 28 62 67 74 76 scan 0 sort 0}\ndo_test where7-2.518.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 74 AND 76) AND a!=75)\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='mlkjihg' AND f GLOB 'klmno*')\n         OR b=135\n         OR a=28\n         OR ((a BETWEEN 1 AND 3) AND a!=2)\n         OR b=737\n  }\n} {1 3 19 28 62 67 74 76 scan 0 sort 0}\ndo_test where7-2.519.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=242\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {20 22 scan 0 sort 0}\ndo_test where7-2.519.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=242\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {20 22 scan 0 sort 0}\ndo_test where7-2.520.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=528\n         OR a=41\n         OR f='cdefghijk'\n         OR a=98\n         OR b=759\n         OR a=43\n         OR b=286\n         OR f='hijklmnop'\n  }\n} {2 7 26 28 33 41 43 48 54 59 69 80 85 98 scan 0 sort 0}\ndo_test where7-2.520.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=528\n         OR a=41\n         OR f='cdefghijk'\n         OR a=98\n         OR b=759\n         OR a=43\n         OR b=286\n         OR f='hijklmnop'\n  }\n} {2 7 26 28 33 41 43 48 54 59 69 80 85 98 scan 0 sort 0}\ndo_test where7-2.521.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR a=52\n  }\n} {6 15 52 61 scan 0 sort 0}\ndo_test where7-2.521.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR a=52\n  }\n} {6 15 52 61 scan 0 sort 0}\ndo_test where7-2.522.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR a=86\n         OR c=33033\n         OR c=2002\n         OR a=92\n  }\n} {2 4 5 6 78 86 92 97 98 99 scan 0 sort 0}\ndo_test where7-2.522.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 2 AND 4) AND a!=3)\n         OR a=86\n         OR c=33033\n         OR c=2002\n         OR a=92\n  }\n} {2 4 5 6 78 86 92 97 98 99 scan 0 sort 0}\ndo_test where7-2.523.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR b=517\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR f='defghijkl'\n         OR b=707\n         OR c>=34035\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR a=80\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {3 23 29 31 33 35 47 49 55 63 67 69 80 81 scan 0 sort 0}\ndo_test where7-2.523.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 47 AND 49) AND a!=48)\n         OR b=517\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR f='defghijkl'\n         OR b=707\n         OR c>=34035\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR a=80\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {3 23 29 31 33 35 47 49 55 63 67 69 80 81 scan 0 sort 0}\ndo_test where7-2.524.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=209\n         OR b=399\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n  }\n} {19 96 97 scan 0 sort 0}\ndo_test where7-2.524.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=209\n         OR b=399\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n  }\n} {19 96 97 scan 0 sort 0}\ndo_test where7-2.525.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=597\n         OR a=95\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=432\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n  }\n} {18 20 24 38 50 55 76 92 95 scan 0 sort 0}\ndo_test where7-2.525.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=597\n         OR a=95\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=432\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n  }\n} {18 20 24 38 50 55 76 92 95 scan 0 sort 0}\ndo_test where7-2.526.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR b=157\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=3\n         OR b=663\n         OR a=2\n         OR c=21021\n         OR b=330\n         OR b=231\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n  }\n} {2 3 21 27 30 61 62 63 78 80 88 scan 0 sort 0}\ndo_test where7-2.526.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR b=157\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=3\n         OR b=663\n         OR a=2\n         OR c=21021\n         OR b=330\n         OR b=231\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n  }\n} {2 3 21 27 30 61 62 63 78 80 88 scan 0 sort 0}\ndo_test where7-2.527.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR f IS NULL\n  }\n} {64 66 83 scan 0 sort 0}\ndo_test where7-2.527.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR f IS NULL\n  }\n} {64 66 83 scan 0 sort 0}\ndo_test where7-2.528.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 99 AND 101) AND a!=100)\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR 1000000<b\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=990\n  }\n} {75 90 93 99 scan 0 sort 0}\ndo_test where7-2.528.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 99 AND 101) AND a!=100)\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR 1000000<b\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=990\n  }\n} {75 90 93 99 scan 0 sort 0}\ndo_test where7-2.529.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=165\n         OR a=69\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n  }\n} {15 44 69 scan 0 sort 0}\ndo_test where7-2.529.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=165\n         OR a=69\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n  }\n} {15 44 69 scan 0 sort 0}\ndo_test where7-2.530.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=784\n         OR b=583\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=814\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=619\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {46 53 54 55 58 74 80 scan 0 sort 0}\ndo_test where7-2.530.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=784\n         OR b=583\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=814\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=619\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {46 53 54 55 58 74 80 scan 0 sort 0}\ndo_test where7-2.531.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=86\n         OR b=484\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR b=418\n         OR b=509\n         OR a=42\n         OR b=825\n         OR a=91\n         OR b=1023\n         OR b=814\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n  }\n} {38 42 44 74 75 79 86 91 93 99 scan 0 sort 0}\ndo_test where7-2.531.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=86\n         OR b=484\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR b=418\n         OR b=509\n         OR a=42\n         OR b=825\n         OR a=91\n         OR b=1023\n         OR b=814\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n  }\n} {38 42 44 74 75 79 86 91 93 99 scan 0 sort 0}\ndo_test where7-2.532.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=231\n         OR a=81\n         OR a=72\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=396\n  }\n} {21 24 26 36 72 81 86 scan 0 sort 0}\ndo_test where7-2.532.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=231\n         OR a=81\n         OR a=72\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=396\n  }\n} {21 24 26 36 72 81 86 scan 0 sort 0}\ndo_test where7-2.533.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR a=63\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR a=71\n         OR b=22\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR a=53\n  }\n} {2 21 53 59 61 63 70 71 72 74 76 78 scan 0 sort 0}\ndo_test where7-2.533.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR a=63\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR a=71\n         OR b=22\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR a=53\n  }\n} {2 21 53 59 61 63 70 71 72 74 76 78 scan 0 sort 0}\ndo_test where7-2.534.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=861\n         OR b=649\n         OR b=146\n         OR f='abcdefghi'\n  }\n} {26 52 59 78 scan 0 sort 0}\ndo_test where7-2.534.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=861\n         OR b=649\n         OR b=146\n         OR f='abcdefghi'\n  }\n} {26 52 59 78 scan 0 sort 0}\ndo_test where7-2.535.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR c=5005\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR a=93\n         OR c=24024\n         OR b=619\n         OR b=234\n         OR b=55\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n  }\n} {5 9 13 14 15 21 35 47 50 52 56 61 70 71 72 73 87 93 99 scan 0 sort 0}\ndo_test where7-2.535.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR c=5005\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR a=93\n         OR c=24024\n         OR b=619\n         OR b=234\n         OR b=55\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n  }\n} {5 9 13 14 15 21 35 47 50 52 56 61 70 71 72 73 87 93 99 scan 0 sort 0}\ndo_test where7-2.536.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=355\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=806\n         OR b=462\n         OR b=531\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR f='mnopqrstu'\n  }\n} {12 38 42 49 63 64 69 90 scan 0 sort 0}\ndo_test where7-2.536.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=355\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=806\n         OR b=462\n         OR b=531\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR f='mnopqrstu'\n  }\n} {12 38 42 49 63 64 69 90 scan 0 sort 0}\ndo_test where7-2.537.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR f='pqrstuvwx'\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=495\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR a=75\n  }\n} {15 41 45 56 60 62 67 70 75 93 scan 0 sort 0}\ndo_test where7-2.537.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR f='pqrstuvwx'\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n         OR b=495\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR a=75\n  }\n} {15 41 45 56 60 62 67 70 75 93 scan 0 sort 0}\ndo_test where7-2.538.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=748\n         OR b=913\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR a=22\n  }\n} {4 5 21 22 68 83 scan 0 sort 0}\ndo_test where7-2.538.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=748\n         OR b=913\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR a=22\n  }\n} {4 5 21 22 68 83 scan 0 sort 0}\ndo_test where7-2.539.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=19\n         OR b=902\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR b=168\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR a=50\n         OR f='uvwxyzabc'\n         OR b=836\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR a=50\n  }\n} {19 20 46 50 63 65 67 72 76 77 79 82 98 scan 0 sort 0}\ndo_test where7-2.539.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=19\n         OR b=902\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR b=168\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR a=50\n         OR f='uvwxyzabc'\n         OR b=836\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR a=50\n  }\n} {19 20 46 50 63 65 67 72 76 77 79 82 98 scan 0 sort 0}\ndo_test where7-2.540.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=12012\n         OR b=993\n         OR b=839\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR a=87\n  }\n} {30 32 34 35 36 87 scan 0 sort 0}\ndo_test where7-2.540.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=12012\n         OR b=993\n         OR b=839\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR a=87\n  }\n} {30 32 34 35 36 87 scan 0 sort 0}\ndo_test where7-2.541.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=814\n         OR c=30030\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR a=16\n         OR b=1048\n         OR b=113\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR b=729\n         OR a=54\n  }\n} {3 16 34 40 54 61 74 88 89 90 scan 0 sort 0}\ndo_test where7-2.541.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=814\n         OR c=30030\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR a=16\n         OR b=1048\n         OR b=113\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR b=729\n         OR a=54\n  }\n} {3 16 34 40 54 61 74 88 89 90 scan 0 sort 0}\ndo_test where7-2.542.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=399\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=814\n         OR c=22022\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR a=1\n         OR b=311\n         OR b=121\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=198\n  }\n} {1 6 8 11 18 32 37 58 63 64 65 66 71 74 84 89 scan 0 sort 0}\ndo_test where7-2.542.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=399\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=814\n         OR c=22022\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR a=1\n         OR b=311\n         OR b=121\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=198\n  }\n} {1 6 8 11 18 32 37 58 63 64 65 66 71 74 84 89 scan 0 sort 0}\ndo_test where7-2.543.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=146\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR a=57\n  }\n} {52 57 scan 0 sort 0}\ndo_test where7-2.543.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=146\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR a=57\n  }\n} {52 57 scan 0 sort 0}\ndo_test where7-2.544.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR f='fghijklmn'\n         OR a=70\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n  }\n} {4 5 31 57 70 83 100 scan 0 sort 0}\ndo_test where7-2.544.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR f='fghijklmn'\n         OR a=70\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n  }\n} {4 5 31 57 70 83 100 scan 0 sort 0}\ndo_test where7-2.545.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=42\n         OR b=333\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR b=1089\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR a=22\n         OR b=594\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 12 15 22 31 35 42 54 57 83 99 scan 0 sort 0}\ndo_test where7-2.545.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=42\n         OR b=333\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR b=1089\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR a=22\n         OR b=594\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n  }\n} {5 12 15 22 31 35 42 54 57 83 99 scan 0 sort 0}\ndo_test where7-2.546.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=113\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='mnopqrstu'\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=902\n  }\n} {3 5 12 16 17 25 26 38 52 64 67 69 78 82 90 scan 0 sort 0}\ndo_test where7-2.546.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=113\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR f='mnopqrstu'\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=902\n  }\n} {3 5 12 16 17 25 26 38 52 64 67 69 78 82 90 scan 0 sort 0}\ndo_test where7-2.547.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='onmlkji' AND f GLOB 'zabcd*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=13\n  }\n} {13 15 41 51 67 93 scan 0 sort 0}\ndo_test where7-2.547.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='onmlkji' AND f GLOB 'zabcd*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR a=13\n  }\n} {13 15 41 51 67 93 scan 0 sort 0}\ndo_test where7-2.548.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=410\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=418\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {38 65 82 88 100 scan 0 sort 0}\ndo_test where7-2.548.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='edcbazy' AND f GLOB 'wxyza*')\n         OR b=410\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=418\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n  }\n} {38 65 82 88 100 scan 0 sort 0}\ndo_test where7-2.549.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=5\n         OR a=95\n         OR a=56\n         OR a=46\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n  }\n} {5 10 41 46 56 61 95 100 scan 0 sort 0}\ndo_test where7-2.549.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=5\n         OR a=95\n         OR a=56\n         OR a=46\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n  }\n} {5 10 41 46 56 61 95 100 scan 0 sort 0}\ndo_test where7-2.550.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR a=13\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=9\n         OR a=27\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=484\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=594\n  }\n} {9 13 27 37 44 54 75 87 88 90 scan 0 sort 0}\ndo_test where7-2.550.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR a=13\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=9\n         OR a=27\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=484\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR b=594\n  }\n} {9 13 27 37 44 54 75 87 88 90 scan 0 sort 0}\ndo_test where7-2.551.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=539\n         OR b=418\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=759\n  }\n} {15 38 49 69 scan 0 sort 0}\ndo_test where7-2.551.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=539\n         OR b=418\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR b=759\n  }\n} {15 38 49 69 scan 0 sort 0}\ndo_test where7-2.552.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1001\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR c=34034\n         OR a=84\n  }\n} {8 54 84 91 100 scan 0 sort 0}\ndo_test where7-2.552.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1001\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR c=34034\n         OR a=84\n  }\n} {8 54 84 91 100 scan 0 sort 0}\ndo_test where7-2.553.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=795\n         OR b=671\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR b=322\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR c=34034\n         OR b=410\n  }\n} {15 38 41 60 61 63 67 71 73 93 100 scan 0 sort 0}\ndo_test where7-2.553.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=795\n         OR b=671\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR b=322\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR c=34034\n         OR b=410\n  }\n} {15 38 41 60 61 63 67 71 73 93 100 scan 0 sort 0}\ndo_test where7-2.554.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=13013\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=47\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=828\n  }\n} {37 38 39 42 61 69 79 94 scan 0 sort 0}\ndo_test where7-2.554.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=13013\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=47\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=828\n  }\n} {37 38 39 42 61 69 79 94 scan 0 sort 0}\ndo_test where7-2.555.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=451\n         OR b=836\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n  }\n} {41 48 76 scan 0 sort 0}\ndo_test where7-2.555.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=451\n         OR b=836\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n  }\n} {41 48 76 scan 0 sort 0}\ndo_test where7-2.556.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=575\n         OR b=748\n         OR b=520\n         OR b=154\n         OR a=70\n         OR f='efghijklm'\n  }\n} {4 14 30 56 68 70 82 scan 0 sort 0}\ndo_test where7-2.556.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=575\n         OR b=748\n         OR b=520\n         OR b=154\n         OR a=70\n         OR f='efghijklm'\n  }\n} {4 14 30 56 68 70 82 scan 0 sort 0}\ndo_test where7-2.557.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='tuvwxyzab'\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n  }\n} {19 45 56 71 97 scan 0 sort 0}\ndo_test where7-2.557.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='tuvwxyzab'\n         OR (g='nmlkjih' AND f GLOB 'efghi*')\n  }\n} {19 45 56 71 97 scan 0 sort 0}\ndo_test where7-2.558.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=806\n         OR a=47\n         OR d<0.0\n         OR b=982\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR e IS NULL\n         OR c=32032\n         OR b=795\n  }\n} {2 12 47 87 94 95 96 97 99 scan 0 sort 0}\ndo_test where7-2.558.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=806\n         OR a=47\n         OR d<0.0\n         OR b=982\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR e IS NULL\n         OR c=32032\n         OR b=795\n  }\n} {2 12 47 87 94 95 96 97 99 scan 0 sort 0}\ndo_test where7-2.559.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=62\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n  }\n} {23 49 62 75 89 91 99 scan 0 sort 0}\ndo_test where7-2.559.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=62\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n  }\n} {23 49 62 75 89 91 99 scan 0 sort 0}\ndo_test where7-2.560.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=1056\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=729\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=220\n         OR b=498\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {9 20 57 73 96 98 scan 0 sort 0}\ndo_test where7-2.560.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=1056\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=729\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR b=220\n         OR b=498\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {9 20 57 73 96 98 scan 0 sort 0}\ndo_test where7-2.561.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=44\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n  }\n} {4 10 38 scan 0 sort 0}\ndo_test where7-2.561.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=44\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n  }\n} {4 10 38 scan 0 sort 0}\ndo_test where7-2.562.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=883\n         OR b=311\n         OR b=880\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR a=88\n         OR b=154\n         OR a=94\n         OR a=37\n         OR c=31031\n  }\n} {14 37 41 57 59 80 88 91 92 93 94 scan 0 sort 0}\ndo_test where7-2.562.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=883\n         OR b=311\n         OR b=880\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR a=88\n         OR b=154\n         OR a=94\n         OR a=37\n         OR c=31031\n  }\n} {14 37 41 57 59 80 88 91 92 93 94 scan 0 sort 0}\ndo_test where7-2.563.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='onmlkji' AND f GLOB 'xyzab*')\n         OR a=10\n         OR b=190\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR b=385\n         OR a=82\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR c=22022\n  }\n} {8 10 35 49 55 63 64 65 66 67 69 82 90 scan 0 sort 0}\ndo_test where7-2.563.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='onmlkji' AND f GLOB 'xyzab*')\n         OR a=10\n         OR b=190\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR b=385\n         OR a=82\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR c=22022\n  }\n} {8 10 35 49 55 63 64 65 66 67 69 82 90 scan 0 sort 0}\ndo_test where7-2.564.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1070\n         OR a=33\n         OR b=363\n         OR a=47\n  }\n} {33 47 scan 0 sort 0}\ndo_test where7-2.564.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1070\n         OR a=33\n         OR b=363\n         OR a=47\n  }\n} {33 47 scan 0 sort 0}\ndo_test where7-2.565.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=1001\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=49\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=33033\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR g IS NULL\n         OR b=220\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n  }\n} {1 2 3 18 20 33 35 49 60 62 63 65 70 81 97 98 99 scan 0 sort 0}\ndo_test where7-2.565.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=1001\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=49\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=33033\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR g IS NULL\n         OR b=220\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n  }\n} {1 2 3 18 20 33 35 49 60 62 63 65 70 81 97 98 99 scan 0 sort 0}\ndo_test where7-2.566.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=212\n         OR b=418\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n  }\n} {31 33 38 71 scan 0 sort 0}\ndo_test where7-2.566.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=212\n         OR b=418\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n  }\n} {31 33 38 71 scan 0 sort 0}\ndo_test where7-2.567.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=344\n         OR f='nopqrstuv'\n         OR b=704\n         OR a=84\n  }\n} {13 39 64 65 84 91 scan 0 sort 0}\ndo_test where7-2.567.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=344\n         OR f='nopqrstuv'\n         OR b=704\n         OR a=84\n  }\n} {13 39 64 65 84 91 scan 0 sort 0}\ndo_test where7-2.568.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n  }\n} {5 30 32 scan 0 sort 0}\ndo_test where7-2.568.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n  }\n} {5 30 32 scan 0 sort 0}\ndo_test where7-2.569.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {26 52 78 87 scan 0 sort 0}\ndo_test where7-2.569.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {26 52 78 87 scan 0 sort 0}\ndo_test where7-2.570.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 0 AND 2) AND a!=1)\n         OR b=1100\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR b=421\n         OR b=465\n         OR b=894\n         OR c=13013\n         OR b=47\n         OR b=674\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n  }\n} {2 37 38 39 70 100 scan 0 sort 0}\ndo_test where7-2.570.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 0 AND 2) AND a!=1)\n         OR b=1100\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR b=421\n         OR b=465\n         OR b=894\n         OR c=13013\n         OR b=47\n         OR b=674\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n  }\n} {2 37 38 39 70 100 scan 0 sort 0}\ndo_test where7-2.571.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=18018\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR b=410\n         OR b=858\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {49 52 53 54 78 scan 0 sort 0}\ndo_test where7-2.571.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=18018\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR b=410\n         OR b=858\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {49 52 53 54 78 scan 0 sort 0}\ndo_test where7-2.572.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=781\n  }\n} {47 71 scan 0 sort 0}\ndo_test where7-2.572.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=781\n  }\n} {47 71 scan 0 sort 0}\ndo_test where7-2.573.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1070\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR a=54\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR a=9\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n  }\n} {7 9 25 33 47 50 52 54 59 63 85 scan 0 sort 0}\ndo_test where7-2.573.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1070\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR a=54\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR a=9\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n  }\n} {7 9 25 33 47 50 52 54 59 63 85 scan 0 sort 0}\ndo_test where7-2.574.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=55\n         OR a=62\n         OR a=63\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n  }\n} {34 50 55 62 63 99 scan 0 sort 0}\ndo_test where7-2.574.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=55\n         OR a=62\n         OR a=63\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n  }\n} {34 50 55 62 63 99 scan 0 sort 0}\ndo_test where7-2.575.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=421\n         OR b=146\n         OR b=22\n         OR f='efghijklm'\n  }\n} {2 4 30 56 82 scan 0 sort 0}\ndo_test where7-2.575.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=421\n         OR b=146\n         OR b=22\n         OR f='efghijklm'\n  }\n} {2 4 30 56 82 scan 0 sort 0}\ndo_test where7-2.576.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=553\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=583\n         OR a=56\n  }\n} {21 23 48 53 56 59 61 scan 0 sort 0}\ndo_test where7-2.576.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=553\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=583\n         OR a=56\n  }\n} {21 23 48 53 56 59 61 scan 0 sort 0}\ndo_test where7-2.577.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=83\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR a=1\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=245\n  }\n} {1 17 19 29 49 51 77 83 scan 0 sort 0}\ndo_test where7-2.577.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=83\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR a=1\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=245\n  }\n} {1 17 19 29 49 51 77 83 scan 0 sort 0}\ndo_test where7-2.578.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=3003\n         OR b=619\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {7 8 9 19 21 scan 0 sort 0}\ndo_test where7-2.578.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=3003\n         OR b=619\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {7 8 9 19 21 scan 0 sort 0}\ndo_test where7-2.579.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=924\n         OR a=92\n         OR a=63\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n  }\n} {60 63 84 92 97 scan 0 sort 0}\ndo_test where7-2.579.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=924\n         OR a=92\n         OR a=63\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n  }\n} {60 63 84 92 97 scan 0 sort 0}\ndo_test where7-2.580.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=440\n         OR f='vwxyzabcd'\n         OR b=190\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=88\n         OR b=58\n  }\n} {8 11 21 37 40 42 47 63 73 89 99 scan 0 sort 0}\ndo_test where7-2.580.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=440\n         OR f='vwxyzabcd'\n         OR b=190\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=88\n         OR b=58\n  }\n} {8 11 21 37 40 42 47 63 73 89 99 scan 0 sort 0}\ndo_test where7-2.581.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=495\n         OR c=24024\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=1001\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR d>1e10\n         OR b=531\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR b=1089\n  }\n} {25 45 49 70 71 72 82 91 99 scan 0 sort 0}\ndo_test where7-2.581.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=495\n         OR c=24024\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=1001\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR d>1e10\n         OR b=531\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR b=1089\n  }\n} {25 45 49 70 71 72 82 91 99 scan 0 sort 0}\ndo_test where7-2.582.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n  }\n} {41 48 scan 0 sort 0}\ndo_test where7-2.582.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=41.0 AND d<42.0 AND d NOT NULL)\n  }\n} {41 48 scan 0 sort 0}\ndo_test where7-2.583.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR d>1e10\n         OR b=22\n         OR c=5005\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {1 2 13 14 15 22 24 52 71 73 80 82 91 93 scan 0 sort 0}\ndo_test where7-2.583.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR d>1e10\n         OR b=22\n         OR c=5005\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {1 2 13 14 15 22 24 52 71 73 80 82 91 93 scan 0 sort 0}\ndo_test where7-2.584.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 9 AND 11) AND a!=10)\n         OR b=1078\n         OR b=806\n         OR b=605\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n  }\n} {9 11 15 23 25 41 55 67 76 93 98 scan 0 sort 0}\ndo_test where7-2.584.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 9 AND 11) AND a!=10)\n         OR b=1078\n         OR b=806\n         OR b=605\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n  }\n} {9 11 15 23 25 41 55 67 76 93 98 scan 0 sort 0}\ndo_test where7-2.585.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=572\n         OR c=10010\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=29\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 28 29 30 33 52 59 68 84 85 86 scan 0 sort 0}\ndo_test where7-2.585.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=572\n         OR c=10010\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=29\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n  }\n} {7 28 29 30 33 52 59 68 84 85 86 scan 0 sort 0}\ndo_test where7-2.586.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 94 AND 96) AND a!=95)\n         OR b=858\n         OR b=806\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n  }\n} {63 77 78 94 96 scan 0 sort 0}\ndo_test where7-2.586.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 94 AND 96) AND a!=95)\n         OR b=858\n         OR b=806\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n  }\n} {63 77 78 94 96 scan 0 sort 0}\ndo_test where7-2.587.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='vwxyzabcd'\n         OR a=72\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=935\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR c=13013\n  }\n} {21 36 37 38 39 40 47 72 73 85 99 scan 0 sort 0}\ndo_test where7-2.587.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='vwxyzabcd'\n         OR a=72\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=935\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR c=13013\n  }\n} {21 36 37 38 39 40 47 72 73 85 99 scan 0 sort 0}\ndo_test where7-2.588.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=5005\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR b=143\n         OR a=68\n         OR a=77\n         OR b=80\n  }\n} {13 14 15 43 44 68 77 88 scan 0 sort 0}\ndo_test where7-2.588.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=5005\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR b=143\n         OR a=68\n         OR a=77\n         OR b=80\n  }\n} {13 14 15 43 44 68 77 88 scan 0 sort 0}\ndo_test where7-2.589.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=99\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n  }\n} {5 6 12 14 68 72 76 78 99 scan 0 sort 0}\ndo_test where7-2.589.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=99\n         OR ((a BETWEEN 12 AND 14) AND a!=13)\n  }\n} {5 6 12 14 68 72 76 78 99 scan 0 sort 0}\ndo_test where7-2.590.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR b=971\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 13 40 88 90 scan 0 sort 0}\ndo_test where7-2.590.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR b=971\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {5 13 40 88 90 scan 0 sort 0}\ndo_test where7-2.591.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR b=806\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=1015\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {10 13 36 39 43 62 65 68 70 88 91 scan 0 sort 0}\ndo_test where7-2.591.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR b=806\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR b=1015\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n  }\n} {10 13 36 39 43 62 65 68 70 88 91 scan 0 sort 0}\ndo_test where7-2.592.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='nopqrstuv'\n         OR b=993\n         OR a=76\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=20020\n         OR a=26\n         OR b=1048\n         OR b=561\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR a=56\n  }\n} {13 26 36 39 51 55 56 57 58 59 60 65 76 79 91 scan 0 sort 0}\ndo_test where7-2.592.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='nopqrstuv'\n         OR b=993\n         OR a=76\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR c=20020\n         OR a=26\n         OR b=1048\n         OR b=561\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n         OR a=56\n  }\n} {13 26 36 39 51 55 56 57 58 59 60 65 76 79 91 scan 0 sort 0}\ndo_test where7-2.593.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=781\n         OR b=671\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=113\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=385\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {15 16 35 39 41 60 61 71 83 scan 0 sort 0}\ndo_test where7-2.593.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=781\n         OR b=671\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR b=113\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=385\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {15 16 35 39 41 60 61 71 83 scan 0 sort 0}\ndo_test where7-2.594.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=410\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=674\n         OR b=825\n         OR b=704\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=76\n         OR c=32032\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {9 43 45 58 60 61 64 75 76 85 87 94 95 96 scan 0 sort 0}\ndo_test where7-2.594.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=410\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=674\n         OR b=825\n         OR b=704\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=76\n         OR c=32032\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {9 43 45 58 60 61 64 75 76 85 87 94 95 96 scan 0 sort 0}\ndo_test where7-2.595.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=869\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n  }\n} {43 79 scan 0 sort 0}\ndo_test where7-2.595.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=869\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n  }\n} {43 79 scan 0 sort 0}\ndo_test where7-2.596.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=869\n         OR a=34\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n  }\n} {34 79 87 scan 0 sort 0}\ndo_test where7-2.596.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=869\n         OR a=34\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n  }\n} {34 79 87 scan 0 sort 0}\ndo_test where7-2.597.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='rqponml' AND f GLOB 'hijkl*')\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=8\n         OR a=72\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {8 33 44 72 90 95 97 scan 0 sort 0}\ndo_test where7-2.597.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='rqponml' AND f GLOB 'hijkl*')\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=8\n         OR a=72\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {8 33 44 72 90 95 97 scan 0 sort 0}\ndo_test where7-2.598.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=20\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=341\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=814\n         OR b=1026\n         OR a=14\n         OR a=13\n         OR b=1037\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {13 14 20 26 31 56 58 74 76 scan 0 sort 0}\ndo_test where7-2.598.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=20\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=341\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=814\n         OR b=1026\n         OR a=14\n         OR a=13\n         OR b=1037\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {13 14 20 26 31 56 58 74 76 scan 0 sort 0}\ndo_test where7-2.599.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=443\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=839\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR c=7007\n  }\n} {10 13 19 20 21 49 51 scan 0 sort 0}\ndo_test where7-2.599.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=443\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=839\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR c=7007\n  }\n} {10 13 19 20 21 49 51 scan 0 sort 0}\ndo_test where7-2.600.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR a=21\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=506\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=88\n         OR b=190\n  }\n} {3 8 9 14 16 21 25 42 46 51 68 77 94 97 scan 0 sort 0}\ndo_test where7-2.600.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR a=21\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=506\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=88\n         OR b=190\n  }\n} {3 8 9 14 16 21 25 42 46 51 68 77 94 97 scan 0 sort 0}\ndo_test where7-2.601.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR f='bcdefghij'\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=762\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {1 27 30 41 53 54 61 63 68 70 76 79 scan 0 sort 0}\ndo_test where7-2.601.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=41.0 AND d<42.0 AND d NOT NULL)\n         OR f='bcdefghij'\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=762\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {1 27 30 41 53 54 61 63 68 70 76 79 scan 0 sort 0}\ndo_test where7-2.602.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR f='qrstuvwxy'\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n  }\n} {16 42 56 68 85 94 scan 0 sort 0}\ndo_test where7-2.602.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR f='qrstuvwxy'\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n  }\n} {16 42 56 68 85 94 scan 0 sort 0}\ndo_test where7-2.603.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR a=21\n         OR b<0\n         OR f='bcdefghij'\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {1 14 16 21 27 53 57 79 89 scan 0 sort 0}\ndo_test where7-2.603.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR a=21\n         OR b<0\n         OR f='bcdefghij'\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {1 14 16 21 27 53 57 79 89 scan 0 sort 0}\ndo_test where7-2.604.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=1067\n         OR b=231\n         OR b=113\n         OR b=22\n         OR a=55\n         OR b=663\n  }\n} {2 21 40 55 83 97 scan 0 sort 0}\ndo_test where7-2.604.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=1067\n         OR b=231\n         OR b=113\n         OR b=22\n         OR a=55\n         OR b=663\n  }\n} {2 21 40 55 83 97 scan 0 sort 0}\ndo_test where7-2.605.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=1\n         OR b=454\n         OR b=396\n         OR b=1059\n         OR a=69\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=440\n         OR b=825\n  }\n} {1 21 36 40 47 69 73 75 99 scan 0 sort 0}\ndo_test where7-2.605.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=1\n         OR b=454\n         OR b=396\n         OR b=1059\n         OR a=69\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR b=440\n         OR b=825\n  }\n} {1 21 36 40 47 69 73 75 99 scan 0 sort 0}\ndo_test where7-2.606.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR b=308\n         OR c<=10\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR f='ghijklmno'\n         OR b=289\n         OR a=5\n         OR b=267\n         OR b=949\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {5 6 7 9 26 28 32 58 84 scan 0 sort 0}\ndo_test where7-2.606.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR b=308\n         OR c<=10\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR f='ghijklmno'\n         OR b=289\n         OR a=5\n         OR b=267\n         OR b=949\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n  }\n} {5 6 7 9 26 28 32 58 84 scan 0 sort 0}\ndo_test where7-2.607.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=993\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=663\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=869\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=121\n  }\n} {11 17 24 43 45 50 76 79 81 95 97 scan 0 sort 0}\ndo_test where7-2.607.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR b=993\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR b=663\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=869\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=121\n  }\n} {11 17 24 43 45 50 76 79 81 95 97 scan 0 sort 0}\ndo_test where7-2.608.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=770\n  }\n} {4 27 70 87 scan 0 sort 0}\ndo_test where7-2.608.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=770\n  }\n} {4 27 70 87 scan 0 sort 0}\ndo_test where7-2.609.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {19 45 57 71 80 82 90 97 scan 0 sort 0}\ndo_test where7-2.609.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {19 45 57 71 80 82 90 97 scan 0 sort 0}\ndo_test where7-2.610.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=22\n         OR c=31031\n         OR b=894\n         OR a=31\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR a=94\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=21\n         OR b=1001\n  }\n} {2 21 31 84 86 91 92 93 94 95 scan 0 sort 0}\ndo_test where7-2.610.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=22\n         OR c=31031\n         OR b=894\n         OR a=31\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR a=94\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=21\n         OR b=1001\n  }\n} {2 21 31 84 86 91 92 93 94 95 scan 0 sort 0}\ndo_test where7-2.611.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='onmlkji' AND f GLOB 'zabcd*')\n         OR b=1092\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR a=77\n         OR a=63\n         OR b=762\n         OR b=894\n         OR b=685\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n  }\n} {13 46 51 63 77 80 scan 0 sort 0}\ndo_test where7-2.611.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='onmlkji' AND f GLOB 'zabcd*')\n         OR b=1092\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR a=77\n         OR a=63\n         OR b=762\n         OR b=894\n         OR b=685\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n  }\n} {13 46 51 63 77 80 scan 0 sort 0}\ndo_test where7-2.612.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=231\n  }\n} {10 21 93 95 scan 0 sort 0}\ndo_test where7-2.612.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=231\n  }\n} {10 21 93 95 scan 0 sort 0}\ndo_test where7-2.613.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=828\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n  }\n} {8 10 26 52 78 scan 0 sort 0}\ndo_test where7-2.613.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=828\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n  }\n} {8 10 26 52 78 scan 0 sort 0}\ndo_test where7-2.614.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=520\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR a=21\n  }\n} {4 6 13 21 31 33 39 47 50 65 91 100 scan 0 sort 0}\ndo_test where7-2.614.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=520\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR a=21\n  }\n} {4 6 13 21 31 33 39 47 50 65 91 100 scan 0 sort 0}\ndo_test where7-2.615.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=553\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR b=1034\n         OR b=418\n         OR a=57\n         OR f='mnopqrstu'\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n  }\n} {12 38 57 63 64 90 94 99 scan 0 sort 0}\ndo_test where7-2.615.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=553\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR b=1034\n         OR b=418\n         OR a=57\n         OR f='mnopqrstu'\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n  }\n} {12 38 57 63 64 90 94 99 scan 0 sort 0}\ndo_test where7-2.616.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=43\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=418\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=594\n         OR a=21\n         OR a=78\n         OR a=91\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {21 38 43 47 54 70 78 80 91 scan 0 sort 0}\ndo_test where7-2.616.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=43\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR b=418\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=594\n         OR a=21\n         OR a=78\n         OR a=91\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {21 38 43 47 54 70 78 80 91 scan 0 sort 0}\ndo_test where7-2.617.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=671\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n  }\n} {48 61 95 97 scan 0 sort 0}\ndo_test where7-2.617.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=671\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n  }\n} {48 61 95 97 scan 0 sort 0}\ndo_test where7-2.618.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR b=726\n         OR b=663\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR a=25\n         OR f='qrstuvwxy'\n  }\n} {2 13 16 25 42 66 68 94 scan 0 sort 0}\ndo_test where7-2.618.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=2.0 AND d<3.0 AND d NOT NULL)\n         OR b=726\n         OR b=663\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR a=25\n         OR f='qrstuvwxy'\n  }\n} {2 13 16 25 42 66 68 94 scan 0 sort 0}\ndo_test where7-2.619.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=806\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR b=275\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n  }\n} {10 12 25 50 80 82 scan 0 sort 0}\ndo_test where7-2.619.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=806\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR b=275\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n  }\n} {10 12 25 50 80 82 scan 0 sort 0}\ndo_test where7-2.620.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=24024\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=429\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR b=110\n         OR a=39\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n  }\n} {2 10 23 39 70 71 72 scan 0 sort 0}\ndo_test where7-2.620.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=24024\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=429\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR b=110\n         OR a=39\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n  }\n} {2 10 23 39 70 71 72 scan 0 sort 0}\ndo_test where7-2.621.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=66\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=198\n         OR b=682\n         OR c=23023\n  }\n} {18 62 66 67 68 69 70 scan 0 sort 0}\ndo_test where7-2.621.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=66\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=198\n         OR b=682\n         OR c=23023\n  }\n} {18 62 66 67 68 69 70 scan 0 sort 0}\ndo_test where7-2.622.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=806\n         OR b=253\n         OR a=36\n  }\n} {23 36 scan 0 sort 0}\ndo_test where7-2.622.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=806\n         OR b=253\n         OR a=36\n  }\n} {23 36 scan 0 sort 0}\ndo_test where7-2.623.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=509\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=718\n         OR a=4\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n  }\n} {4 13 16 22 24 56 58 69 scan 0 sort 0}\ndo_test where7-2.623.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=509\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (g='vutsrqp' AND f GLOB 'nopqr*')\n         OR b=718\n         OR a=4\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n  }\n} {4 13 16 22 24 56 58 69 scan 0 sort 0}\ndo_test where7-2.624.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=1026\n         OR a=93\n         OR c=18018\n  }\n} {52 53 54 77 93 scan 0 sort 0}\ndo_test where7-2.624.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=1026\n         OR a=93\n         OR c=18018\n  }\n} {52 53 54 77 93 scan 0 sort 0}\ndo_test where7-2.625.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=388\n         OR a=44\n  }\n} {44 scan 0 sort 0}\ndo_test where7-2.625.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=388\n         OR a=44\n  }\n} {44 scan 0 sort 0}\ndo_test where7-2.626.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=9009\n         OR b=542\n         OR f='cdefghijk'\n         OR b=319\n         OR b=616\n  }\n} {2 25 26 27 28 29 54 56 80 scan 0 sort 0}\ndo_test where7-2.626.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=9009\n         OR b=542\n         OR f='cdefghijk'\n         OR b=319\n         OR b=616\n  }\n} {2 25 26 27 28 29 54 56 80 scan 0 sort 0}\ndo_test where7-2.627.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=990\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=531\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR f='qrstuvwxy'\n  }\n} {6 16 32 41 42 43 57 58 67 68 84 86 90 94 97 scan 0 sort 0}\ndo_test where7-2.627.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=990\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=531\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR f='qrstuvwxy'\n  }\n} {6 16 32 41 42 43 57 58 67 68 84 86 90 94 97 scan 0 sort 0}\ndo_test where7-2.628.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=60\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR b=627\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=883\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR f='yzabcdefg'\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {24 38 50 57 59 60 73 76 78 93 99 scan 0 sort 0}\ndo_test where7-2.628.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=60\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR b=627\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=883\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR f='yzabcdefg'\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {24 38 50 57 59 60 73 76 78 93 99 scan 0 sort 0}\ndo_test where7-2.629.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=696\n         OR b=938\n         OR a=18\n         OR b=957\n         OR c=18018\n         OR c=3003\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {7 8 9 18 33 35 52 53 54 87 scan 0 sort 0}\ndo_test where7-2.629.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=696\n         OR b=938\n         OR a=18\n         OR b=957\n         OR c=18018\n         OR c=3003\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {7 8 9 18 33 35 52 53 54 87 scan 0 sort 0}\ndo_test where7-2.630.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=29029\n         OR a=73\n  }\n} {73 85 86 87 scan 0 sort 0}\ndo_test where7-2.630.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=29029\n         OR a=73\n  }\n} {73 85 86 87 scan 0 sort 0}\ndo_test where7-2.631.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=28\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=69\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=781\n         OR a=64\n         OR b=91\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR a=16\n         OR b=278\n         OR a=26\n  }\n} {16 26 27 28 64 71 82 85 87 scan 0 sort 0}\ndo_test where7-2.631.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=28\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=69\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=781\n         OR a=64\n         OR b=91\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR a=16\n         OR b=278\n         OR a=26\n  }\n} {16 26 27 28 64 71 82 85 87 scan 0 sort 0}\ndo_test where7-2.632.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=70\n         OR c=3003\n  }\n} {7 8 9 70 scan 0 sort 0}\ndo_test where7-2.632.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=70\n         OR c=3003\n  }\n} {7 8 9 70 scan 0 sort 0}\ndo_test where7-2.633.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=31031\n         OR a=76\n         OR b=1023\n         OR b=33\n  }\n} {3 76 91 92 93 scan 0 sort 0}\ndo_test where7-2.633.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=31031\n         OR a=76\n         OR b=1023\n         OR b=33\n  }\n} {3 76 91 92 93 scan 0 sort 0}\ndo_test where7-2.634.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=1001\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {62 86 91 scan 0 sort 0}\ndo_test where7-2.634.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=1001\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {62 86 91 scan 0 sort 0}\ndo_test where7-2.635.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='yzabcdefg'\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n         OR a=100\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR a=62\n         OR a=67\n         OR b=605\n         OR c=23023\n         OR a=26\n         OR b=982\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n  }\n} {3 5 24 26 34 48 50 55 62 67 68 69 76 100 scan 0 sort 0}\ndo_test where7-2.635.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='yzabcdefg'\n         OR ((a BETWEEN 48 AND 50) AND a!=49)\n         OR a=100\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR a=62\n         OR a=67\n         OR b=605\n         OR c=23023\n         OR a=26\n         OR b=982\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n  }\n} {3 5 24 26 34 48 50 55 62 67 68 69 76 100 scan 0 sort 0}\ndo_test where7-2.636.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=220\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR f IS NULL\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=784\n  }\n} {20 24 25 26 27 scan 0 sort 0}\ndo_test where7-2.636.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=220\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR f IS NULL\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR b=784\n  }\n} {20 24 25 26 27 scan 0 sort 0}\ndo_test where7-2.637.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR b=751\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR a=67\n         OR b=102\n  }\n} {10 17 43 67 69 88 95 scan 0 sort 0}\ndo_test where7-2.637.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR b=751\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR a=67\n         OR b=102\n  }\n} {10 17 43 67 69 88 95 scan 0 sort 0}\ndo_test where7-2.638.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR b=256\n         OR c=7007\n         OR c=26026\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR a=66\n  }\n} {19 20 21 66 69 74 76 77 78 80 82 scan 0 sort 0}\ndo_test where7-2.638.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR b=256\n         OR c=7007\n         OR c=26026\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR a=66\n  }\n} {19 20 21 66 69 74 76 77 78 80 82 scan 0 sort 0}\ndo_test where7-2.639.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=2002\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=33\n         OR b=817\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {3 4 5 6 8 10 21 34 41 43 45 60 81 86 scan 0 sort 0}\ndo_test where7-2.639.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=2002\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=33\n         OR b=817\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {3 4 5 6 8 10 21 34 41 43 45 60 81 86 scan 0 sort 0}\ndo_test where7-2.640.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR a=80\n         OR a=53\n         OR a=62\n         OR a=49\n         OR a=53\n         OR a=56\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n  }\n} {28 49 53 56 62 80 81 83 scan 0 sort 0}\ndo_test where7-2.640.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR a=80\n         OR a=53\n         OR a=62\n         OR a=49\n         OR a=53\n         OR a=56\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n  }\n} {28 49 53 56 62 80 81 83 scan 0 sort 0}\ndo_test where7-2.641.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 7 AND 9) AND a!=8)\n         OR b=652\n         OR a=72\n         OR b=209\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR a=38\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR d>1e10\n  }\n} {7 9 19 23 38 66 68 72 scan 0 sort 0}\ndo_test where7-2.641.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 7 AND 9) AND a!=8)\n         OR b=652\n         OR a=72\n         OR b=209\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR a=38\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR d>1e10\n  }\n} {7 9 19 23 38 66 68 72 scan 0 sort 0}\ndo_test where7-2.642.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=949\n         OR e IS NULL\n  }\n} { scan 0 sort 0}\ndo_test where7-2.642.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=949\n         OR e IS NULL\n  }\n} { scan 0 sort 0}\ndo_test where7-2.643.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=179\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR b=509\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR f='bcdefghij'\n  }\n} {1 26 27 29 49 53 58 60 79 scan 0 sort 0}\ndo_test where7-2.643.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=179\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR b=509\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR f='bcdefghij'\n  }\n} {1 26 27 29 49 53 58 60 79 scan 0 sort 0}\ndo_test where7-2.644.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=23\n         OR a=43\n         OR c=19019\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=18018\n  }\n} {23 43 47 52 53 54 55 56 57 scan 0 sort 0}\ndo_test where7-2.644.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=23\n         OR a=43\n         OR c=19019\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR c=18018\n  }\n} {23 43 47 52 53 54 55 56 57 scan 0 sort 0}\ndo_test where7-2.645.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=36\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=231\n  }\n} {21 22 36 scan 0 sort 0}\ndo_test where7-2.645.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=36\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=231\n  }\n} {21 22 36 scan 0 sort 0}\ndo_test where7-2.646.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=21\n         OR b=355\n         OR a=97\n  }\n} {21 97 scan 0 sort 0}\ndo_test where7-2.646.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=21\n         OR b=355\n         OR a=97\n  }\n} {21 97 scan 0 sort 0}\ndo_test where7-2.647.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=421\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=704\n         OR a=90\n         OR a=78\n         OR 1000000<b\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {28 42 53 55 64 78 80 81 90 scan 0 sort 0}\ndo_test where7-2.647.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=421\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=704\n         OR a=90\n         OR a=78\n         OR 1000000<b\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n  }\n} {28 42 53 55 64 78 80 81 90 scan 0 sort 0}\ndo_test where7-2.648.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {93 95 scan 0 sort 0}\ndo_test where7-2.648.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {93 95 scan 0 sort 0}\ndo_test where7-2.649.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE d<0.0\n         OR a=78\n         OR b=539\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR e IS NULL\n         OR a=48\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {8 10 25 27 48 49 57 78 scan 0 sort 0}\ndo_test where7-2.649.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE d<0.0\n         OR a=78\n         OR b=539\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR e IS NULL\n         OR a=48\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {8 10 25 27 48 49 57 78 scan 0 sort 0}\ndo_test where7-2.650.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 94 AND 96) AND a!=95)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=22\n  }\n} {2 78 94 96 scan 0 sort 0}\ndo_test where7-2.650.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 94 AND 96) AND a!=95)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=22\n  }\n} {2 78 94 96 scan 0 sort 0}\ndo_test where7-2.651.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=275\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR f='ijklmnopq'\n  }\n} {8 25 34 37 53 57 59 60 86 92 scan 0 sort 0}\ndo_test where7-2.651.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=275\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR f='ijklmnopq'\n  }\n} {8 25 34 37 53 57 59 60 86 92 scan 0 sort 0}\ndo_test where7-2.652.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=256\n         OR c=13013\n         OR b=44\n         OR f='jklmnopqr'\n         OR b=883\n  }\n} {4 9 35 37 38 39 61 87 scan 0 sort 0}\ndo_test where7-2.652.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=256\n         OR c=13013\n         OR b=44\n         OR f='jklmnopqr'\n         OR b=883\n  }\n} {4 9 35 37 38 39 61 87 scan 0 sort 0}\ndo_test where7-2.653.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='zabcdefgh'\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR a=54\n         OR b=770\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR a=81\n         OR b=190\n         OR a=2\n  }\n} {2 3 25 51 54 70 77 81 96 98 scan 0 sort 0}\ndo_test where7-2.653.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='zabcdefgh'\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR a=54\n         OR b=770\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR a=81\n         OR b=190\n         OR a=2\n  }\n} {2 3 25 51 54 70 77 81 96 98 scan 0 sort 0}\ndo_test where7-2.654.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=12012\n         OR a=16\n         OR a=15\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR a=69\n         OR b=748\n         OR a=61\n         OR b=473\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n  }\n} {12 15 16 34 35 36 43 61 68 69 70 71 72 scan 0 sort 0}\ndo_test where7-2.654.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR c=12012\n         OR a=16\n         OR a=15\n         OR ((a BETWEEN 70 AND 72) AND a!=71)\n         OR a=69\n         OR b=748\n         OR a=61\n         OR b=473\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n  }\n} {12 15 16 34 35 36 43 61 68 69 70 71 72 scan 0 sort 0}\ndo_test where7-2.655.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=223\n         OR a=14\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR b=539\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=21\n  }\n} {14 21 33 35 41 48 49 61 74 76 scan 0 sort 0}\ndo_test where7-2.655.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=223\n         OR a=14\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR b=539\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR a=21\n  }\n} {14 21 33 35 41 48 49 61 74 76 scan 0 sort 0}\ndo_test where7-2.656.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=99\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=73\n         OR a=56\n         OR b=253\n         OR b=880\n  }\n} {5 23 31 56 57 73 80 83 99 scan 0 sort 0}\ndo_test where7-2.656.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=99\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=73\n         OR a=56\n         OR b=253\n         OR b=880\n  }\n} {5 23 31 56 57 73 80 83 99 scan 0 sort 0}\ndo_test where7-2.657.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=927\n         OR b=300\n         OR b=223\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=154\n         OR b=759\n  }\n} {9 14 69 95 scan 0 sort 0}\ndo_test where7-2.657.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=927\n         OR b=300\n         OR b=223\n         OR (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=154\n         OR b=759\n  }\n} {9 14 69 95 scan 0 sort 0}\ndo_test where7-2.658.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=242\n         OR b=905\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR a=24\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR b=1100\n         OR b=850\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n  }\n} {22 24 55 57 66 67 69 86 96 100 scan 0 sort 0}\ndo_test where7-2.658.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=242\n         OR b=905\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'ijklm*')\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR a=24\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n         OR b=1100\n         OR b=850\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n  }\n} {22 24 55 57 66 67 69 86 96 100 scan 0 sort 0}\ndo_test where7-2.659.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=190\n         OR a=72\n         OR b=377\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR b=476\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n  }\n} {2 26 52 72 78 93 scan 0 sort 0}\ndo_test where7-2.659.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=190\n         OR a=72\n         OR b=377\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR b=476\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n  }\n} {2 26 52 72 78 93 scan 0 sort 0}\ndo_test where7-2.660.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=245\n         OR b=638\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR f='opqrstuvw'\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=817\n         OR a=85\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n  }\n} {14 40 58 62 64 66 67 85 86 92 scan 0 sort 0}\ndo_test where7-2.660.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=245\n         OR b=638\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR f='opqrstuvw'\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR b=817\n         OR a=85\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n  }\n} {14 40 58 62 64 66 67 85 86 92 scan 0 sort 0}\ndo_test where7-2.661.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=968\n  }\n} {22 24 88 scan 0 sort 0}\ndo_test where7-2.661.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=968\n  }\n} {22 24 88 scan 0 sort 0}\ndo_test where7-2.662.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=22\n         OR b=993\n         OR f='tuvwxyzab'\n  }\n} {2 19 45 60 62 71 74 76 97 scan 0 sort 0}\ndo_test where7-2.662.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 60 AND 62) AND a!=61)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=22\n         OR b=993\n         OR f='tuvwxyzab'\n  }\n} {2 19 45 60 62 71 74 76 97 scan 0 sort 0}\ndo_test where7-2.663.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR c<=10\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=553\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR b=1045\n  }\n} {55 57 72 73 75 77 85 95 scan 0 sort 0}\ndo_test where7-2.663.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 55 AND 57) AND a!=56)\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR c<=10\n         OR ((a BETWEEN 75 AND 77) AND a!=76)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=553\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR b=1045\n  }\n} {55 57 72 73 75 77 85 95 scan 0 sort 0}\ndo_test where7-2.664.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=440\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=89\n         OR c=18018\n         OR b=154\n         OR b=506\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR a=78\n         OR b=751\n  }\n} {1 3 5 14 27 31 40 44 46 52 53 54 57 78 79 83 89 scan 0 sort 0}\ndo_test where7-2.664.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=440\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 44 AND 46) AND a!=45)\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=89\n         OR c=18018\n         OR b=154\n         OR b=506\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR a=78\n         OR b=751\n  }\n} {1 3 5 14 27 31 40 44 46 52 53 54 57 78 79 83 89 scan 0 sort 0}\ndo_test where7-2.665.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=407\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR b=209\n         OR b=814\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR a=44\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=1092\n  }\n} {10 19 36 37 38 44 65 74 99 scan 0 sort 0}\ndo_test where7-2.665.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=407\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR b=209\n         OR b=814\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR a=44\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=1092\n  }\n} {10 19 36 37 38 44 65 74 99 scan 0 sort 0}\ndo_test where7-2.666.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=1103\n         OR b=190\n         OR b=737\n         OR a=97\n         OR b=451\n         OR b=583\n         OR a=63\n         OR c=8008\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n  }\n} {22 23 24 26 41 45 47 53 63 67 97 scan 0 sort 0}\ndo_test where7-2.666.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 24 AND 26) AND a!=25)\n         OR b=1103\n         OR b=190\n         OR b=737\n         OR a=97\n         OR b=451\n         OR b=583\n         OR a=63\n         OR c=8008\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n  }\n} {22 23 24 26 41 45 47 53 63 67 97 scan 0 sort 0}\ndo_test where7-2.667.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=12\n         OR b=935\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=1070\n         OR a=24\n         OR a=95\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR a=40\n         OR b=935\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {12 24 27 29 40 53 85 87 95 scan 0 sort 0}\ndo_test where7-2.667.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=12\n         OR b=935\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=1070\n         OR a=24\n         OR a=95\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR a=40\n         OR b=935\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {12 24 27 29 40 53 85 87 95 scan 0 sort 0}\ndo_test where7-2.668.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=858\n         OR a=82\n         OR b=209\n         OR b=374\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR c=22022\n  }\n} {19 34 40 64 65 66 76 78 82 scan 0 sort 0}\ndo_test where7-2.668.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=858\n         OR a=82\n         OR b=209\n         OR b=374\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR c=22022\n  }\n} {19 34 40 64 65 66 76 78 82 scan 0 sort 0}\ndo_test where7-2.669.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=27\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR b=121\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=67\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR c=1001\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {1 2 3 7 8 9 11 19 21 27 30 32 37 50 52 67 scan 0 sort 0}\ndo_test where7-2.669.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=27\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR b=121\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=67\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR c=1001\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n  }\n} {1 2 3 7 8 9 11 19 21 27 30 32 37 50 52 67 scan 0 sort 0}\ndo_test where7-2.670.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=99\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n  }\n} {1 9 46 57 98 scan 0 sort 0}\ndo_test where7-2.670.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=99\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=98.0 AND d<99.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n  }\n} {1 9 46 57 98 scan 0 sort 0}\ndo_test where7-2.671.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=3\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=355\n         OR b=814\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR a=81\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=542\n         OR b=795\n  }\n} {3 42 62 74 79 81 scan 0 sort 0}\ndo_test where7-2.671.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=3\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR b=355\n         OR b=814\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR a=81\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=542\n         OR b=795\n  }\n} {3 42 62 74 79 81 scan 0 sort 0}\ndo_test where7-2.672.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR b=363\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=619\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR a=73\n  }\n} {1 14 31 33 56 64 66 73 scan 0 sort 0}\ndo_test where7-2.672.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR b=363\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 64 AND 66) AND a!=65)\n         OR b=619\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n         OR a=73\n  }\n} {1 14 31 33 56 64 66 73 scan 0 sort 0}\ndo_test where7-2.673.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=935\n         OR a=42\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=330\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {9 30 35 42 55 61 85 87 scan 0 sort 0}\ndo_test where7-2.673.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=935\n         OR a=42\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=330\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {9 30 35 42 55 61 85 87 scan 0 sort 0}\ndo_test where7-2.674.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=79\n         OR b=201\n         OR b=99\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR a=64\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR a=89\n  }\n} {9 16 19 21 42 64 68 79 89 94 scan 0 sort 0}\ndo_test where7-2.674.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=79\n         OR b=201\n         OR b=99\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR a=64\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR a=89\n  }\n} {9 16 19 21 42 64 68 79 89 94 scan 0 sort 0}\ndo_test where7-2.675.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=784\n         OR a=85\n         OR b=663\n         OR c=17017\n         OR b=561\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=495\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR b=352\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {32 39 41 45 49 50 51 65 68 85 scan 0 sort 0}\ndo_test where7-2.675.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=784\n         OR a=85\n         OR b=663\n         OR c=17017\n         OR b=561\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR b=495\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR b=352\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {32 39 41 45 49 50 51 65 68 85 scan 0 sort 0}\ndo_test where7-2.676.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR f='klmnopqrs'\n         OR f='lmnopqrst'\n  }\n} {10 11 19 36 37 62 63 88 89 100 scan 0 sort 0}\ndo_test where7-2.676.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR f='klmnopqrs'\n         OR f='lmnopqrst'\n  }\n} {10 11 19 36 37 62 63 88 89 100 scan 0 sort 0}\ndo_test where7-2.677.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=46\n         OR a=44\n  }\n} {44 46 90 92 scan 0 sort 0}\ndo_test where7-2.677.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=46\n         OR a=44\n  }\n} {44 46 90 92 scan 0 sort 0}\ndo_test where7-2.678.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=36\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR b=682\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR b=91\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR c=12012\n         OR b=267\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {18 20 34 35 36 39 43 53 55 62 76 95 97 scan 0 sort 0}\ndo_test where7-2.678.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=36\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR b=682\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR b=91\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR c=12012\n         OR b=267\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n  }\n} {18 20 34 35 36 39 43 53 55 62 76 95 97 scan 0 sort 0}\ndo_test where7-2.679.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=594\n         OR f='hijklmnop'\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=707\n         OR b=363\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=157\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n  }\n} {7 12 24 33 54 58 59 65 67 85 scan 0 sort 0}\ndo_test where7-2.679.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=594\n         OR f='hijklmnop'\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=707\n         OR b=363\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=157\n         OR (g='tsrqpon' AND f GLOB 'yzabc*')\n  }\n} {7 12 24 33 54 58 59 65 67 85 scan 0 sort 0}\ndo_test where7-2.680.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=2\n         OR a=84\n         OR b=399\n         OR b=828\n         OR a=21\n         OR b=748\n         OR c=13013\n         OR a=57\n         OR f='mnopqrstu'\n  }\n} {2 12 21 27 37 38 39 57 64 68 84 90 scan 0 sort 0}\ndo_test where7-2.680.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=2\n         OR a=84\n         OR b=399\n         OR b=828\n         OR a=21\n         OR b=748\n         OR c=13013\n         OR a=57\n         OR f='mnopqrstu'\n  }\n} {2 12 21 27 37 38 39 57 64 68 84 90 scan 0 sort 0}\ndo_test where7-2.681.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=674\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR c=3003\n         OR a=19\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {7 8 9 19 20 22 38 40 46 55 scan 0 sort 0}\ndo_test where7-2.681.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'defgh*')\n         OR b=674\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR c=3003\n         OR a=19\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {7 8 9 19 20 22 38 40 46 55 scan 0 sort 0}\ndo_test where7-2.682.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=652\n         OR a=83\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=102\n         OR b=300\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {49 83 97 scan 0 sort 0}\ndo_test where7-2.682.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=652\n         OR a=83\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=102\n         OR b=300\n         OR (d>=49.0 AND d<50.0 AND d NOT NULL)\n  }\n} {49 83 97 scan 0 sort 0}\ndo_test where7-2.683.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 53 AND 55) AND a!=54)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR c=4004\n         OR a=95\n         OR b=707\n         OR f='vwxyzabcd'\n         OR b=286\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=693\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n  }\n} {6 8 10 11 12 21 26 43 45 47 53 55 63 73 95 99 scan 0 sort 0}\ndo_test where7-2.683.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 53 AND 55) AND a!=54)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR c=4004\n         OR a=95\n         OR b=707\n         OR f='vwxyzabcd'\n         OR b=286\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=693\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n  }\n} {6 8 10 11 12 21 26 43 45 47 53 55 63 73 95 99 scan 0 sort 0}\ndo_test where7-2.684.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=209\n         OR b=198\n         OR a=52\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR d<0.0\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=168\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n  }\n} {7 18 19 20 24 33 35 42 46 52 59 64 72 85 98 scan 0 sort 0}\ndo_test where7-2.684.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=209\n         OR b=198\n         OR a=52\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR d<0.0\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=168\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='uvwxyzabc'\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n  }\n} {7 18 19 20 24 33 35 42 46 52 59 64 72 85 98 scan 0 sort 0}\ndo_test where7-2.685.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR f='rstuvwxyz'\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=14\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n  }\n} {4 6 8 12 14 17 21 26 43 47 69 73 84 89 91 95 99 scan 0 sort 0}\ndo_test where7-2.685.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR f='rstuvwxyz'\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR a=14\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n  }\n} {4 6 8 12 14 17 21 26 43 47 69 73 84 89 91 95 99 scan 0 sort 0}\ndo_test where7-2.686.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 13 AND 15) AND a!=14)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR f='mnopqrstu'\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR a=38\n         OR c=26026\n  }\n} {2 12 13 15 33 35 38 64 76 77 78 90 93 95 97 scan 0 sort 0}\ndo_test where7-2.686.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 13 AND 15) AND a!=14)\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR f='mnopqrstu'\n         OR (g='fedcbaz' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR a=38\n         OR c=26026\n  }\n} {2 12 13 15 33 35 38 64 76 77 78 90 93 95 97 scan 0 sort 0}\ndo_test where7-2.687.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=7\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {7 32 33 35 39 44 71 73 scan 0 sort 0}\ndo_test where7-2.687.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=7\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {7 32 33 35 39 44 71 73 scan 0 sort 0}\ndo_test where7-2.688.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=6006\n         OR b=938\n         OR b=484\n         OR b=652\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR f='opqrstuvw'\n  }\n} {14 15 16 17 18 40 41 44 58 66 67 92 93 scan 0 sort 0}\ndo_test where7-2.688.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=6006\n         OR b=938\n         OR b=484\n         OR b=652\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR f='opqrstuvw'\n  }\n} {14 15 16 17 18 40 41 44 58 66 67 92 93 scan 0 sort 0}\ndo_test where7-2.689.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=27027\n         OR b=968\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=487\n         OR b=924\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR c=14014\n         OR b=1001\n  }\n} {40 41 42 51 70 79 80 81 84 88 91 scan 0 sort 0}\ndo_test where7-2.689.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=27027\n         OR b=968\n         OR (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR b=487\n         OR b=924\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n         OR c=14014\n         OR b=1001\n  }\n} {40 41 42 51 70 79 80 81 84 88 91 scan 0 sort 0}\ndo_test where7-2.690.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=25\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=443\n         OR b=564\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=531\n         OR b=1081\n         OR a=96\n  }\n} {10 19 25 43 45 69 71 90 96 97 scan 0 sort 0}\ndo_test where7-2.690.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=25\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=443\n         OR b=564\n         OR (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=531\n         OR b=1081\n         OR a=96\n  }\n} {10 19 25 43 45 69 71 90 96 97 scan 0 sort 0}\ndo_test where7-2.691.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=36\n         OR (g='srqponm' AND f GLOB 'defgh*')\n  }\n} {29 scan 0 sort 0}\ndo_test where7-2.691.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=36\n         OR (g='srqponm' AND f GLOB 'defgh*')\n  }\n} {29 scan 0 sort 0}\ndo_test where7-2.692.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR b=531\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n  }\n} {3 70 93 95 scan 0 sort 0}\ndo_test where7-2.692.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR b=531\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n  }\n} {3 70 93 95 scan 0 sort 0}\ndo_test where7-2.693.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=256\n         OR b=1034\n  }\n} {94 scan 0 sort 0}\ndo_test where7-2.693.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=256\n         OR b=1034\n  }\n} {94 scan 0 sort 0}\ndo_test where7-2.694.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR b=784\n         OR b=718\n         OR a=18\n         OR a=3\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR c=28028\n  }\n} {3 18 19 21 24 26 47 58 60 73 82 83 84 99 scan 0 sort 0}\ndo_test where7-2.694.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR (d>=83.0 AND d<84.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR b=784\n         OR b=718\n         OR a=18\n         OR a=3\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR c=28028\n  }\n} {3 18 19 21 24 26 47 58 60 73 82 83 84 99 scan 0 sort 0}\ndo_test where7-2.695.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=473\n         OR b=649\n         OR ((a BETWEEN 46 AND 48) AND a!=47)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=1100\n         OR b=1012\n         OR a=72\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR b=176\n         OR b=355\n  }\n} {16 18 43 46 48 59 72 91 92 100 scan 0 sort 0}\ndo_test where7-2.695.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=473\n         OR b=649\n         OR ((a BETWEEN 46 AND 48) AND a!=47)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR b=1100\n         OR b=1012\n         OR a=72\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR b=176\n         OR b=355\n  }\n} {16 18 43 46 48 59 72 91 92 100 scan 0 sort 0}\ndo_test where7-2.696.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR f='cdefghijk'\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n  }\n} {2 15 19 28 29 30 32 54 80 91 scan 0 sort 0}\ndo_test where7-2.696.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR f='cdefghijk'\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n  }\n} {2 15 19 28 29 30 32 54 80 91 scan 0 sort 0}\ndo_test where7-2.697.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=883\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=938\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR f='defghijkl'\n         OR c=2002\n         OR b=990\n  }\n} {3 4 5 6 17 19 22 29 55 60 81 90 scan 0 sort 0}\ndo_test where7-2.697.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=883\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=938\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR f='defghijkl'\n         OR c=2002\n         OR b=990\n  }\n} {3 4 5 6 17 19 22 29 55 60 81 90 scan 0 sort 0}\ndo_test where7-2.698.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 7 AND 9) AND a!=8)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR b=902\n         OR b=25\n  }\n} {7 9 76 82 scan 0 sort 0}\ndo_test where7-2.698.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 7 AND 9) AND a!=8)\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR b=902\n         OR b=25\n  }\n} {7 9 76 82 scan 0 sort 0}\ndo_test where7-2.699.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'abcde*')\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=1092\n         OR b=495\n  }\n} {26 45 55 68 70 74 76 scan 0 sort 0}\ndo_test where7-2.699.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'abcde*')\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n         OR b=1092\n         OR b=495\n  }\n} {26 45 55 68 70 74 76 scan 0 sort 0}\ndo_test where7-2.700.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=46\n         OR a=74\n  }\n} {46 74 90 92 scan 0 sort 0}\ndo_test where7-2.700.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=46\n         OR a=74\n  }\n} {46 74 90 92 scan 0 sort 0}\ndo_test where7-2.701.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=18\n         OR b=66\n         OR b=498\n         OR b=143\n         OR b=1034\n         OR b=289\n         OR b=319\n  }\n} {6 13 18 29 94 scan 0 sort 0}\ndo_test where7-2.701.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=18\n         OR b=66\n         OR b=498\n         OR b=143\n         OR b=1034\n         OR b=289\n         OR b=319\n  }\n} {6 13 18 29 94 scan 0 sort 0}\ndo_test where7-2.702.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR f='lmnopqrst'\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=872\n         OR a=44\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n  }\n} {11 13 25 28 30 37 38 40 44 45 51 54 63 77 79 89 scan 0 sort 0}\ndo_test where7-2.702.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?abcd*' AND f GLOB 'zabc*')\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR f='lmnopqrst'\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=872\n         OR a=44\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n  }\n} {11 13 25 28 30 37 38 40 44 45 51 54 63 77 79 89 scan 0 sort 0}\ndo_test where7-2.703.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=20\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=1004\n         OR b=77\n         OR b=927\n         OR a=99\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {7 17 20 46 66 71 72 73 75 98 99 scan 0 sort 0}\ndo_test where7-2.703.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR a=20\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=1004\n         OR b=77\n         OR b=927\n         OR a=99\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {7 17 20 46 66 71 72 73 75 98 99 scan 0 sort 0}\ndo_test where7-2.704.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=11\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n  }\n} {1 21 23 45 76 scan 0 sort 0}\ndo_test where7-2.704.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=11\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n  }\n} {1 21 23 45 76 scan 0 sort 0}\ndo_test where7-2.705.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=572\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {52 57 scan 0 sort 0}\ndo_test where7-2.705.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=572\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {52 57 scan 0 sort 0}\ndo_test where7-2.706.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR f='lmnopqrst'\n         OR (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR a=23\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {10 11 23 36 37 44 54 56 62 63 69 81 88 89 scan 0 sort 0}\ndo_test where7-2.706.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 54 AND 56) AND a!=55)\n         OR f='lmnopqrst'\n         OR (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR a=23\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {10 11 23 36 37 44 54 56 62 63 69 81 88 89 scan 0 sort 0}\ndo_test where7-2.707.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=836\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=605\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR b=759\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR a=40\n         OR f='ghijklmno'\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n  }\n} {6 24 32 38 40 46 50 55 58 69 70 76 84 85 89 91 scan 0 sort 0}\ndo_test where7-2.707.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=836\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=605\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR b=759\n         OR (f GLOB '?zabc*' AND f GLOB 'yzab*')\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR a=40\n         OR f='ghijklmno'\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n  }\n} {6 24 32 38 40 46 50 55 58 69 70 76 84 85 89 91 scan 0 sort 0}\ndo_test where7-2.708.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n  }\n} {42 51 scan 0 sort 0}\ndo_test where7-2.708.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n  }\n} {42 51 scan 0 sort 0}\ndo_test where7-2.709.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=27027\n         OR b=872\n         OR a=56\n  }\n} {56 79 80 81 scan 0 sort 0}\ndo_test where7-2.709.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=27027\n         OR b=872\n         OR a=56\n  }\n} {56 79 80 81 scan 0 sort 0}\ndo_test where7-2.710.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=685\n         OR b=256\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=44\n         OR a=63\n         OR a=15\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {15 22 24 44 63 78 80 scan 0 sort 0}\ndo_test where7-2.710.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=685\n         OR b=256\n         OR ((a BETWEEN 78 AND 80) AND a!=79)\n         OR a=44\n         OR a=63\n         OR a=15\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {15 22 24 44 63 78 80 scan 0 sort 0}\ndo_test where7-2.711.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'efghi*')\n         OR a=34\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=67\n         OR a=28\n  }\n} {6 8 28 34 56 67 75 scan 0 sort 0}\ndo_test where7-2.711.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'efghi*')\n         OR a=34\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR a=67\n         OR a=28\n  }\n} {6 8 28 34 56 67 75 scan 0 sort 0}\ndo_test where7-2.712.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR a=52\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='ghijklmno'\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=319\n         OR a=34\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR f='hijklmnop'\n  }\n} {6 7 12 18 24 29 32 33 34 41 52 58 59 68 70 84 85 scan 0 sort 0}\ndo_test where7-2.712.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR a=52\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR f='ghijklmno'\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=319\n         OR a=34\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR f='hijklmnop'\n  }\n} {6 7 12 18 24 29 32 33 34 41 52 58 59 68 70 84 85 scan 0 sort 0}\ndo_test where7-2.713.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR a=47\n  }\n} {41 47 69 71 scan 0 sort 0}\ndo_test where7-2.713.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR a=47\n  }\n} {41 47 69 71 scan 0 sort 0}\ndo_test where7-2.714.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=7007\n  }\n} {19 20 21 33 35 scan 0 sort 0}\ndo_test where7-2.714.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=7007\n  }\n} {19 20 21 33 35 scan 0 sort 0}\ndo_test where7-2.715.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=531\n         OR a=12\n         OR b=583\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=61\n         OR b=187\n  }\n} {12 17 53 61 93 95 scan 0 sort 0}\ndo_test where7-2.715.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=531\n         OR a=12\n         OR b=583\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR a=61\n         OR b=187\n  }\n} {12 17 53 61 93 95 scan 0 sort 0}\ndo_test where7-2.716.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=31031\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=256\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=715\n         OR b=212\n         OR b=99\n         OR c=29029\n  }\n} {9 12 38 45 65 66 68 77 79 85 86 87 91 92 93 scan 0 sort 0}\ndo_test where7-2.716.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=31031\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=256\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=715\n         OR b=212\n         OR b=99\n         OR c=29029\n  }\n} {9 12 38 45 65 66 68 77 79 85 86 87 91 92 93 scan 0 sort 0}\ndo_test where7-2.717.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR b=33\n         OR a=62\n         OR b=916\n         OR b=1012\n         OR a=2\n         OR a=51\n         OR b=286\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=80\n  }\n} {2 3 26 40 42 51 62 92 96 scan 0 sort 0}\ndo_test where7-2.717.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR b=33\n         OR a=62\n         OR b=916\n         OR b=1012\n         OR a=2\n         OR a=51\n         OR b=286\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=80\n  }\n} {2 3 26 40 42 51 62 92 96 scan 0 sort 0}\ndo_test where7-2.718.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=847\n         OR f='efghijklm'\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n  }\n} {4 6 30 56 77 82 scan 0 sort 0}\ndo_test where7-2.718.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=847\n         OR f='efghijklm'\n         OR (d>=6.0 AND d<7.0 AND d NOT NULL)\n  }\n} {4 6 30 56 77 82 scan 0 sort 0}\ndo_test where7-2.719.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n  }\n} {25 62 64 scan 0 sort 0}\ndo_test where7-2.719.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR ((a BETWEEN 62 AND 64) AND a!=63)\n  }\n} {25 62 64 scan 0 sort 0}\ndo_test where7-2.720.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 43 AND 45) AND a!=44)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR a=43\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR b=729\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n  }\n} {14 31 33 43 45 53 scan 0 sort 0}\ndo_test where7-2.720.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 43 AND 45) AND a!=44)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR a=43\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR b=729\n         OR (g='vutsrqp' AND f GLOB 'opqrs*')\n  }\n} {14 31 33 43 45 53 scan 0 sort 0}\ndo_test where7-2.721.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='efghijklm'\n         OR a=70\n         OR b=278\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=8008\n         OR f='opqrstuvw'\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {4 5 14 22 23 24 25 30 33 35 40 56 66 70 82 92 scan 0 sort 0}\ndo_test where7-2.721.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='efghijklm'\n         OR a=70\n         OR b=278\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR c=8008\n         OR f='opqrstuvw'\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n  }\n} {4 5 14 22 23 24 25 30 33 35 40 56 66 70 82 92 scan 0 sort 0}\ndo_test where7-2.722.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR c<=10\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR a=35\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=1089\n         OR a=73\n         OR b=737\n         OR c=18018\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {6 23 31 32 35 40 42 52 53 54 58 62 67 73 84 99 scan 0 sort 0}\ndo_test where7-2.722.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR c<=10\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR a=35\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=1089\n         OR a=73\n         OR b=737\n         OR c=18018\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n  }\n} {6 23 31 32 35 40 42 52 53 54 58 62 67 73 84 99 scan 0 sort 0}\ndo_test where7-2.723.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 0 AND 2) AND a!=1)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=762\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR a=80\n  }\n} {2 39 41 79 80 95 scan 0 sort 0}\ndo_test where7-2.723.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 0 AND 2) AND a!=1)\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=762\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n         OR a=80\n  }\n} {2 39 41 79 80 95 scan 0 sort 0}\ndo_test where7-2.724.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=737\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=979\n         OR a=36\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR a=55\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n  }\n} {20 28 30 36 46 50 55 67 72 80 82 89 95 98 scan 0 sort 0}\ndo_test where7-2.724.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=737\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=979\n         OR a=36\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n         OR a=55\n         OR (g='fedcbaz' AND f GLOB 'rstuv*')\n  }\n} {20 28 30 36 46 50 55 67 72 80 82 89 95 98 scan 0 sort 0}\ndo_test where7-2.725.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=75\n         OR a=61\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {52 61 75 91 scan 0 sort 0}\ndo_test where7-2.725.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=75\n         OR a=61\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n  }\n} {52 61 75 91 scan 0 sort 0}\ndo_test where7-2.726.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1004\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR a=56\n  }\n} {7 56 61 scan 0 sort 0}\ndo_test where7-2.726.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1004\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR a=56\n  }\n} {7 56 61 scan 0 sort 0}\ndo_test where7-2.727.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=93\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR a=83\n         OR b=828\n         OR b=454\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=924\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR a=50\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {38 50 58 66 83 84 89 91 93 scan 0 sort 0}\ndo_test where7-2.727.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=93\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR a=83\n         OR b=828\n         OR b=454\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=924\n         OR (g='lkjihgf' AND f GLOB 'opqrs*')\n         OR a=50\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n  }\n} {38 50 58 66 83 84 89 91 93 scan 0 sort 0}\ndo_test where7-2.728.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='stuvwxyza'\n         OR a=44\n         OR c=2002\n  }\n} {4 5 6 18 44 70 96 scan 0 sort 0}\ndo_test where7-2.728.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='stuvwxyza'\n         OR a=44\n         OR c=2002\n  }\n} {4 5 6 18 44 70 96 scan 0 sort 0}\ndo_test where7-2.729.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=55\n         OR a=65\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {14 40 55 65 66 92 scan 0 sort 0}\ndo_test where7-2.729.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=55\n         OR a=65\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {14 40 55 65 66 92 scan 0 sort 0}\ndo_test where7-2.730.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 72 AND 74) AND a!=73)\n         OR b=605\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR f='ijklmnopq'\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR c=9009\n         OR b=374\n  }\n} {8 12 13 25 26 27 34 43 55 60 72 74 86 88 scan 0 sort 0}\ndo_test where7-2.730.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 72 AND 74) AND a!=73)\n         OR b=605\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR f='ijklmnopq'\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR c=9009\n         OR b=374\n  }\n} {8 12 13 25 26 27 34 43 55 60 72 74 86 88 scan 0 sort 0}\ndo_test where7-2.731.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=476\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR b=982\n         OR a=43\n         OR b=355\n  }\n} {8 43 scan 0 sort 0}\ndo_test where7-2.731.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=476\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR b=982\n         OR a=43\n         OR b=355\n  }\n} {8 43 scan 0 sort 0}\ndo_test where7-2.732.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=85\n         OR b=718\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {1 25 27 53 79 85 93 scan 0 sort 0}\ndo_test where7-2.732.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=85\n         OR b=718\n         OR (g='fedcbaz' AND f GLOB 'pqrst*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {1 25 27 53 79 85 93 scan 0 sort 0}\ndo_test where7-2.733.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {73 96 98 scan 0 sort 0}\ndo_test where7-2.733.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {73 96 98 scan 0 sort 0}\ndo_test where7-2.734.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=176\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR b=619\n         OR b=597\n         OR b=198\n         OR a=27\n         OR b=91\n         OR a=77\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {16 18 25 27 29 77 80 scan 0 sort 0}\ndo_test where7-2.734.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=176\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR b=619\n         OR b=597\n         OR b=198\n         OR a=27\n         OR b=91\n         OR a=77\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n  }\n} {16 18 25 27 29 77 80 scan 0 sort 0}\ndo_test where7-2.735.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=41\n         OR b=528\n         OR c=3003\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=22\n  }\n} {2 7 8 9 20 22 41 48 scan 0 sort 0}\ndo_test where7-2.735.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=41\n         OR b=528\n         OR c=3003\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR b=22\n  }\n} {2 7 8 9 20 22 41 48 scan 0 sort 0}\ndo_test where7-2.736.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=465\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=37\n         OR b=1056\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=1023\n  }\n} {4 16 29 37 42 63 65 68 93 94 96 scan 0 sort 0}\ndo_test where7-2.736.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR b=465\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=37\n         OR b=1056\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=1023\n  }\n} {4 16 29 37 42 63 65 68 93 94 96 scan 0 sort 0}\ndo_test where7-2.737.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=76\n         OR a=8\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=495\n         OR b=663\n         OR a=98\n         OR b=748\n  }\n} {8 27 45 68 76 98 scan 0 sort 0}\ndo_test where7-2.737.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=76\n         OR a=8\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR b=495\n         OR b=663\n         OR a=98\n         OR b=748\n  }\n} {8 27 45 68 76 98 scan 0 sort 0}\ndo_test where7-2.738.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1081\n         OR b=542\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=828\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR a=18\n  }\n} {18 47 61 64 67 scan 0 sort 0}\ndo_test where7-2.738.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1081\n         OR b=542\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=828\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR a=18\n  }\n} {18 47 61 64 67 scan 0 sort 0}\ndo_test where7-2.739.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='abcdefghi'\n         OR a=14\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR c=27027\n         OR a=47\n  }\n} {13 14 26 47 52 78 79 80 81 scan 0 sort 0}\ndo_test where7-2.739.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='abcdefghi'\n         OR a=14\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR c=27027\n         OR a=47\n  }\n} {13 14 26 47 52 78 79 80 81 scan 0 sort 0}\ndo_test where7-2.740.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=31031\n         OR b=737\n         OR a=37\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR a=91\n         OR b=77\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n  }\n} {7 37 65 67 91 92 93 94 98 100 scan 0 sort 0}\ndo_test where7-2.740.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=31031\n         OR b=737\n         OR a=37\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR a=91\n         OR b=77\n         OR (d>=94.0 AND d<95.0 AND d NOT NULL)\n  }\n} {7 37 65 67 91 92 93 94 98 100 scan 0 sort 0}\ndo_test where7-2.741.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=17\n         OR b=484\n         OR c=3003\n         OR b=121\n         OR a=53\n  }\n} {7 8 9 11 17 44 53 scan 0 sort 0}\ndo_test where7-2.741.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=17\n         OR b=484\n         OR c=3003\n         OR b=121\n         OR a=53\n  }\n} {7 8 9 11 17 44 53 scan 0 sort 0}\ndo_test where7-2.742.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=880\n         OR b=696\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR b=308\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {5 28 65 80 96 98 scan 0 sort 0}\ndo_test where7-2.742.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=880\n         OR b=696\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR b=308\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n  }\n} {5 28 65 80 96 98 scan 0 sort 0}\ndo_test where7-2.743.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR a=24\n         OR f IS NULL\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR c=12012\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n  }\n} {24 25 34 35 36 57 77 88 scan 0 sort 0}\ndo_test where7-2.743.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR a=24\n         OR f IS NULL\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR c=12012\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n  }\n} {24 25 34 35 36 57 77 88 scan 0 sort 0}\ndo_test where7-2.744.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=94\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=792\n         OR a=77\n         OR a=26\n         OR b=641\n         OR a=38\n  }\n} {26 38 72 74 77 85 94 scan 0 sort 0}\ndo_test where7-2.744.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=94\n         OR (d>=74.0 AND d<75.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=792\n         OR a=77\n         OR a=26\n         OR b=641\n         OR a=38\n  }\n} {26 38 72 74 77 85 94 scan 0 sort 0}\ndo_test where7-2.745.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR b=14\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=121\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {11 15 17 27 30 51 53 63 86 89 91 scan 0 sort 0}\ndo_test where7-2.745.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR b=14\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR ((a BETWEEN 15 AND 17) AND a!=16)\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=121\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n  }\n} {11 15 17 27 30 51 53 63 86 89 91 scan 0 sort 0}\ndo_test where7-2.746.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=517\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR f='opqrstuvw'\n  }\n} {14 40 47 66 69 71 92 scan 0 sort 0}\ndo_test where7-2.746.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=517\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR f='opqrstuvw'\n  }\n} {14 40 47 66 69 71 92 scan 0 sort 0}\ndo_test where7-2.747.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=267\n         OR c=19019\n         OR a=42\n         OR b=938\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {1 9 17 21 22 24 32 34 35 42 43 55 56 57 61 69 84 87 95 scan 0 sort 0}\ndo_test where7-2.747.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=267\n         OR c=19019\n         OR a=42\n         OR b=938\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n  }\n} {1 9 17 21 22 24 32 34 35 42 43 55 56 57 61 69 84 87 95 scan 0 sort 0}\ndo_test where7-2.748.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=179\n         OR a=50\n         OR (g='srqponm' AND f GLOB 'defgh*')\n  }\n} {29 50 scan 0 sort 0}\ndo_test where7-2.748.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=179\n         OR a=50\n         OR (g='srqponm' AND f GLOB 'defgh*')\n  }\n} {29 50 scan 0 sort 0}\ndo_test where7-2.749.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR f='xyzabcdef'\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=575\n         OR b=385\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=46\n         OR b=220\n         OR a=63\n  }\n} {17 18 20 23 35 46 49 51 63 65 75 scan 0 sort 0}\ndo_test where7-2.749.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR f='xyzabcdef'\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=575\n         OR b=385\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=46\n         OR b=220\n         OR a=63\n  }\n} {17 18 20 23 35 46 49 51 63 65 75 scan 0 sort 0}\ndo_test where7-2.750.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1056\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=1078\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR c=31031\n         OR b=869\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=245\n         OR a=92\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=880\n  }\n} {66 77 79 80 91 92 93 96 98 scan 0 sort 0}\ndo_test where7-2.750.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1056\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=1078\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR c=31031\n         OR b=869\n         OR (g='jihgfed' AND f GLOB 'zabcd*')\n         OR b=245\n         OR a=92\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=880\n  }\n} {66 77 79 80 91 92 93 96 98 scan 0 sort 0}\ndo_test where7-2.751.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1078\n         OR c=28028\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR c=9009\n         OR a=17\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n  }\n} {16 17 19 25 26 27 38 39 40 42 61 68 82 83 84 94 98 scan 0 sort 0}\ndo_test where7-2.751.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1078\n         OR c=28028\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR c=9009\n         OR a=17\n         OR (d>=39.0 AND d<40.0 AND d NOT NULL)\n  }\n} {16 17 19 25 26 27 38 39 40 42 61 68 82 83 84 94 98 scan 0 sort 0}\ndo_test where7-2.752.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=762\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR f='tuvwxyzab'\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR b=1034\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n  }\n} {14 19 31 33 44 45 57 58 71 94 97 scan 0 sort 0}\ndo_test where7-2.752.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=762\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR f='tuvwxyzab'\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR b=1034\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n  }\n} {14 19 31 33 44 45 57 58 71 94 97 scan 0 sort 0}\ndo_test where7-2.753.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=47\n         OR b=187\n         OR a=56\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {17 30 32 56 68 70 89 91 scan 0 sort 0}\ndo_test where7-2.753.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=47\n         OR b=187\n         OR a=56\n         OR ((a BETWEEN 30 AND 32) AND a!=31)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {17 30 32 56 68 70 89 91 scan 0 sort 0}\ndo_test where7-2.754.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=11011\n         OR a=14\n         OR c=16016\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR f='jklmnopqr'\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=916\n  }\n} {9 14 21 25 30 31 32 33 35 46 47 48 61 87 96 scan 0 sort 0}\ndo_test where7-2.754.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=11011\n         OR a=14\n         OR c=16016\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR f='jklmnopqr'\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=916\n  }\n} {9 14 21 25 30 31 32 33 35 46 47 48 61 87 96 scan 0 sort 0}\ndo_test where7-2.755.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=949\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR c<=10\n         OR a=14\n         OR b=608\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=121\n         OR b=333\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {11 14 17 28 66 93 95 98 scan 0 sort 0}\ndo_test where7-2.755.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=949\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n         OR c<=10\n         OR a=14\n         OR b=608\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=121\n         OR b=333\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n  }\n} {11 14 17 28 66 93 95 98 scan 0 sort 0}\ndo_test where7-2.756.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=355\n         OR b=627\n         OR b=1001\n         OR b=1026\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n  }\n} {57 58 60 69 91 scan 0 sort 0}\ndo_test where7-2.756.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'rstuv*')\n         OR b=355\n         OR b=627\n         OR b=1001\n         OR b=1026\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n  }\n} {57 58 60 69 91 scan 0 sort 0}\ndo_test where7-2.757.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n  }\n} {4 79 scan 0 sort 0}\ndo_test where7-2.757.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n  }\n} {4 79 scan 0 sort 0}\ndo_test where7-2.758.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=685\n         OR a=14\n         OR b=990\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR f='efghijklm'\n         OR c=1001\n         OR b=784\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {1 2 3 4 14 26 30 32 56 69 82 90 scan 0 sort 0}\ndo_test where7-2.758.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=685\n         OR a=14\n         OR b=990\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR f='efghijklm'\n         OR c=1001\n         OR b=784\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n  }\n} {1 2 3 4 14 26 30 32 56 69 82 90 scan 0 sort 0}\ndo_test where7-2.759.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=54\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR c=26026\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n  }\n} {39 54 76 77 78 97 99 scan 0 sort 0}\ndo_test where7-2.759.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=54\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR c=26026\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n  }\n} {39 54 76 77 78 97 99 scan 0 sort 0}\ndo_test where7-2.760.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR c=24024\n         OR a=98\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR a=5\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR f='pqrstuvwx'\n         OR f='bcdefghij'\n         OR b=1001\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {1 5 15 21 27 31 33 36 41 53 67 70 71 72 77 79 84 91 93 98 scan 0 sort 0}\ndo_test where7-2.760.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR c=24024\n         OR a=98\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR a=5\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR f='pqrstuvwx'\n         OR f='bcdefghij'\n         OR b=1001\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {1 5 15 21 27 31 33 36 41 53 67 70 71 72 77 79 84 91 93 98 scan 0 sort 0}\ndo_test where7-2.761.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=781\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR f='lmnopqrst'\n         OR a=39\n         OR a=100\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {1 11 14 37 39 40 54 56 58 63 66 71 89 92 99 100 scan 0 sort 0}\ndo_test where7-2.761.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=781\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR f='lmnopqrst'\n         OR a=39\n         OR a=100\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n  }\n} {1 11 14 37 39 40 54 56 58 63 66 71 89 92 99 100 scan 0 sort 0}\ndo_test where7-2.762.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=4004\n         OR b=718\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=50\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR b=363\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR b=1023\n  }\n} {10 11 12 33 34 40 50 93 scan 0 sort 0}\ndo_test where7-2.762.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=4004\n         OR b=718\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR a=50\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR b=363\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n         OR b=1023\n  }\n} {10 11 12 33 34 40 50 93 scan 0 sort 0}\ndo_test where7-2.763.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1081\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR b=473\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR b=586\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {20 26 43 45 46 55 72 98 scan 0 sort 0}\ndo_test where7-2.763.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1081\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR b=473\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n         OR b=586\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR (f GLOB '?vwxy*' AND f GLOB 'uvwx*')\n  }\n} {20 26 43 45 46 55 72 98 scan 0 sort 0}\ndo_test where7-2.764.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n  }\n} {7 13 33 58 59 85 scan 0 sort 0}\ndo_test where7-2.764.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n  }\n} {7 13 33 58 59 85 scan 0 sort 0}\ndo_test where7-2.765.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR a=47\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR f='lmnopqrst'\n  }\n} {11 37 47 63 68 76 78 84 85 89 scan 0 sort 0}\ndo_test where7-2.765.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR ((a BETWEEN 76 AND 78) AND a!=77)\n         OR a=47\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR f='lmnopqrst'\n  }\n} {11 37 47 63 68 76 78 84 85 89 scan 0 sort 0}\ndo_test where7-2.766.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c>=34035\n         OR a=29\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR f='abcdefghi'\n         OR b=993\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n  }\n} {19 21 26 29 45 47 52 54 73 78 99 scan 0 sort 0}\ndo_test where7-2.766.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c>=34035\n         OR a=29\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (f GLOB '?wxyz*' AND f GLOB 'vwxy*')\n         OR f='abcdefghi'\n         OR b=993\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n  }\n} {19 21 26 29 45 47 52 54 73 78 99 scan 0 sort 0}\ndo_test where7-2.767.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=696\n         OR b=154\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR a=22\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR a=52\n         OR a=21\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n  }\n} {14 16 21 22 24 47 52 63 70 scan 0 sort 0}\ndo_test where7-2.767.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=696\n         OR b=154\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR a=22\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR a=52\n         OR a=21\n         OR (d>=70.0 AND d<71.0 AND d NOT NULL)\n  }\n} {14 16 21 22 24 47 52 63 70 scan 0 sort 0}\ndo_test where7-2.768.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=693\n         OR b=201\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR b=520\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=407\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR c>=34035\n         OR b=135\n  }\n} {23 25 36 37 38 63 scan 0 sort 0}\ndo_test where7-2.768.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=693\n         OR b=201\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n         OR b=520\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR b=407\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR c>=34035\n         OR b=135\n  }\n} {23 25 36 37 38 63 scan 0 sort 0}\ndo_test where7-2.769.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=707\n         OR b=14\n         OR b=1089\n         OR b=352\n  }\n} {32 43 99 scan 0 sort 0}\ndo_test where7-2.769.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR b=707\n         OR b=14\n         OR b=1089\n         OR b=352\n  }\n} {32 43 99 scan 0 sort 0}\ndo_test where7-2.770.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=278\n         OR b=278\n         OR b=825\n         OR f='rstuvwxyz'\n         OR b=938\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {17 19 43 45 69 75 95 scan 0 sort 0}\ndo_test where7-2.770.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=278\n         OR b=278\n         OR b=825\n         OR f='rstuvwxyz'\n         OR b=938\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR ((a BETWEEN 43 AND 45) AND a!=44)\n  }\n} {17 19 43 45 69 75 95 scan 0 sort 0}\ndo_test where7-2.771.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=1045\n         OR c=27027\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n  }\n} {11 32 34 37 63 79 80 81 89 95 scan 0 sort 0}\ndo_test where7-2.771.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=1045\n         OR c=27027\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n  }\n} {11 32 34 37 63 79 80 81 89 95 scan 0 sort 0}\ndo_test where7-2.772.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=87\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=487\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {47 87 90 scan 0 sort 0}\ndo_test where7-2.772.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=87\n         OR (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=487\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n  }\n} {47 87 90 scan 0 sort 0}\ndo_test where7-2.773.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=69\n         OR b=608\n         OR b=814\n         OR a=67\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=1059\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR a=18\n         OR b=407\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {10 12 18 30 32 37 58 61 67 74 scan 0 sort 0}\ndo_test where7-2.773.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR b=69\n         OR b=608\n         OR b=814\n         OR a=67\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR b=1059\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR a=18\n         OR b=407\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {10 12 18 30 32 37 58 61 67 74 scan 0 sort 0}\ndo_test where7-2.774.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=223\n         OR b=80\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n  }\n} {74 76 97 99 scan 0 sort 0}\ndo_test where7-2.774.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=223\n         OR b=80\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR ((a BETWEEN 74 AND 76) AND a!=75)\n  }\n} {74 76 97 99 scan 0 sort 0}\ndo_test where7-2.775.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=220\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=363\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {10 12 20 33 52 54 55 66 scan 0 sort 0}\ndo_test where7-2.775.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=220\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=363\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'defgh*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {10 12 20 33 52 54 55 66 scan 0 sort 0}\ndo_test where7-2.776.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=498\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR b=880\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=828\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR b=113\n  }\n} {5 15 60 62 80 scan 0 sort 0}\ndo_test where7-2.776.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=498\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR b=880\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=828\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR b=113\n  }\n} {5 15 60 62 80 scan 0 sort 0}\ndo_test where7-2.777.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1059\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=960\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=894\n         OR c=2002\n  }\n} {4 5 6 12 16 20 42 68 94 scan 0 sort 0}\ndo_test where7-2.777.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1059\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=960\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR b=894\n         OR c=2002\n  }\n} {4 5 6 12 16 20 42 68 94 scan 0 sort 0}\ndo_test where7-2.778.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=14\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n  }\n} {85 scan 0 sort 0}\ndo_test where7-2.778.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=14\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n  }\n} {85 scan 0 sort 0}\ndo_test where7-2.779.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=806\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR b=795\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR c=23023\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n  }\n} {21 23 33 67 68 69 86 88 99 scan 0 sort 0}\ndo_test where7-2.779.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=806\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n         OR b=795\n         OR ((a BETWEEN 99 AND 101) AND a!=100)\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR c=23023\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n  }\n} {21 23 33 67 68 69 86 88 99 scan 0 sort 0}\ndo_test where7-2.780.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=726\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR f='abcdefghi'\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR b=869\n  }\n} {8 10 15 26 41 52 66 67 78 79 92 93 scan 0 sort 0}\ndo_test where7-2.780.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=726\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR f='abcdefghi'\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR b=869\n  }\n} {8 10 15 26 41 52 66 67 78 79 92 93 scan 0 sort 0}\ndo_test where7-2.781.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=59\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=1081\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n  }\n} {5 7 59 96 scan 0 sort 0}\ndo_test where7-2.781.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=59\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n         OR b=1081\n         OR (g='fedcbaz' AND f GLOB 'stuvw*')\n  }\n} {5 7 59 96 scan 0 sort 0}\ndo_test where7-2.782.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'nopqr*')\n         OR b=1037\n         OR b=132\n         OR c=1001\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=32\n  }\n} {1 2 3 12 18 20 32 39 58 68 91 scan 0 sort 0}\ndo_test where7-2.782.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'nopqr*')\n         OR b=1037\n         OR b=132\n         OR c=1001\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=32\n  }\n} {1 2 3 12 18 20 32 39 58 68 91 scan 0 sort 0}\ndo_test where7-2.783.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=24\n         OR b=927\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR a=7\n         OR b=462\n         OR b=608\n         OR b=781\n         OR b=253\n         OR c=25025\n         OR b=132\n  }\n} {7 12 23 24 42 52 71 73 74 75 scan 0 sort 0}\ndo_test where7-2.783.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=24\n         OR b=927\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR a=7\n         OR b=462\n         OR b=608\n         OR b=781\n         OR b=253\n         OR c=25025\n         OR b=132\n  }\n} {7 12 23 24 42 52 71 73 74 75 scan 0 sort 0}\ndo_test where7-2.784.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=1001\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR a=83\n  }\n} {23 25 61 83 91 scan 0 sort 0}\ndo_test where7-2.784.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=1001\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR a=83\n  }\n} {23 25 61 83 91 scan 0 sort 0}\ndo_test where7-2.785.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=36\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR ((a BETWEEN 46 AND 48) AND a!=47)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n  }\n} {3 26 28 29 31 33 46 48 55 60 73 77 80 81 82 91 scan 0 sort 0}\ndo_test where7-2.785.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=36\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR ((a BETWEEN 46 AND 48) AND a!=47)\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR (d>=91.0 AND d<92.0 AND d NOT NULL)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n  }\n} {3 26 28 29 31 33 46 48 55 60 73 77 80 81 82 91 scan 0 sort 0}\ndo_test where7-2.786.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=69\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=98\n         OR b=300\n         OR a=41\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR a=33\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {1 2 10 12 28 33 37 39 41 54 58 60 69 80 98 scan 0 sort 0}\ndo_test where7-2.786.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=69\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=98\n         OR b=300\n         OR a=41\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR a=33\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n  }\n} {1 2 10 12 28 33 37 39 41 54 58 60 69 80 98 scan 0 sort 0}\ndo_test where7-2.787.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=619\n         OR c=6006\n         OR b=91\n         OR b=297\n         OR b=165\n  }\n} {1 15 16 17 18 22 24 27 53 68 70 71 79 90 94 96 scan 0 sort 0}\ndo_test where7-2.787.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 68 AND 70) AND a!=69)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR ((a BETWEEN 94 AND 96) AND a!=95)\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=619\n         OR c=6006\n         OR b=91\n         OR b=297\n         OR b=165\n  }\n} {1 15 16 17 18 22 24 27 53 68 70 71 79 90 94 96 scan 0 sort 0}\ndo_test where7-2.788.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 9 AND 11) AND a!=10)\n         OR a=55\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n  }\n} {9 11 55 75 scan 0 sort 0}\ndo_test where7-2.788.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 9 AND 11) AND a!=10)\n         OR a=55\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n  }\n} {9 11 55 75 scan 0 sort 0}\ndo_test where7-2.789.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=737\n         OR b=201\n         OR a=7\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR b=957\n  }\n} {2 7 26 67 84 86 87 scan 0 sort 0}\ndo_test where7-2.789.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=737\n         OR b=201\n         OR a=7\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (g='yxwvuts' AND f GLOB 'cdefg*')\n         OR b=957\n  }\n} {2 7 26 67 84 86 87 scan 0 sort 0}\ndo_test where7-2.790.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=74\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR a=89\n  }\n} {18 44 67 70 74 79 89 90 92 95 96 97 scan 0 sort 0}\ndo_test where7-2.790.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 90 AND 92) AND a!=91)\n         OR a=74\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR (f GLOB '?tuvw*' AND f GLOB 'stuv*')\n         OR a=89\n  }\n} {18 44 67 70 74 79 89 90 92 95 96 97 scan 0 sort 0}\ndo_test where7-2.791.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=179\n         OR b=1081\n         OR b=377\n         OR b=495\n         OR b=564\n         OR b=289\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n  }\n} {39 45 scan 0 sort 0}\ndo_test where7-2.791.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=179\n         OR b=1081\n         OR b=377\n         OR b=495\n         OR b=564\n         OR b=289\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n  }\n} {39 45 scan 0 sort 0}\ndo_test where7-2.792.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=69\n         OR a=12\n         OR b=718\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {12 20 22 69 scan 0 sort 0}\ndo_test where7-2.792.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=69\n         OR a=12\n         OR b=718\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n  }\n} {12 20 22 69 scan 0 sort 0}\ndo_test where7-2.793.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR f='klmnopqrs'\n         OR b=674\n         OR a=96\n         OR a=99\n         OR b=608\n         OR b=707\n         OR f='cdefghijk'\n         OR a=91\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {2 10 23 25 28 36 54 62 80 88 91 96 99 scan 0 sort 0}\ndo_test where7-2.793.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR f='klmnopqrs'\n         OR b=674\n         OR a=96\n         OR a=99\n         OR b=608\n         OR b=707\n         OR f='cdefghijk'\n         OR a=91\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {2 10 23 25 28 36 54 62 80 88 91 96 99 scan 0 sort 0}\ndo_test where7-2.794.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=564\n         OR b=784\n         OR b=418\n         OR b=275\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR a=58\n         OR c=11011\n         OR b=660\n  }\n} {9 25 31 32 33 35 38 58 60 61 87 88 scan 0 sort 0}\ndo_test where7-2.794.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=564\n         OR b=784\n         OR b=418\n         OR b=275\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n         OR a=58\n         OR c=11011\n         OR b=660\n  }\n} {9 25 31 32 33 35 38 58 60 61 87 88 scan 0 sort 0}\ndo_test where7-2.795.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=509\n         OR b=1004\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR f='pqrstuvwx'\n  }\n} {15 25 28 30 41 57 59 67 93 scan 0 sort 0}\ndo_test where7-2.795.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR b=509\n         OR b=1004\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR ((a BETWEEN 57 AND 59) AND a!=58)\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR f='pqrstuvwx'\n  }\n} {15 25 28 30 41 57 59 67 93 scan 0 sort 0}\ndo_test where7-2.796.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=440\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n  }\n} {40 52 54 scan 0 sort 0}\ndo_test where7-2.796.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=440\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n  }\n} {40 52 54 scan 0 sort 0}\ndo_test where7-2.797.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR f='abcdefghi'\n  }\n} {26 52 78 95 scan 0 sort 0}\ndo_test where7-2.797.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR f='abcdefghi'\n  }\n} {26 52 78 95 scan 0 sort 0}\ndo_test where7-2.798.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=19\n         OR a=29\n         OR b=476\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=91\n  }\n} {19 29 41 scan 0 sort 0}\ndo_test where7-2.798.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=19\n         OR a=29\n         OR b=476\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=91\n  }\n} {19 29 41 scan 0 sort 0}\ndo_test where7-2.799.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='lmnopqrst'\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=47\n         OR a=71\n  }\n} {8 11 37 47 63 71 89 scan 0 sort 0}\ndo_test where7-2.799.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='lmnopqrst'\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR a=47\n         OR a=71\n  }\n} {8 11 37 47 63 71 89 scan 0 sort 0}\ndo_test where7-2.800.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=531\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=44\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=707\n         OR b=322\n  }\n} {4 12 32 34 49 84 95 97 scan 0 sort 0}\ndo_test where7-2.800.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=531\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=44\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR b=707\n         OR b=322\n  }\n} {4 12 32 34 49 84 95 97 scan 0 sort 0}\ndo_test where7-2.801.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR f='jklmnopqr'\n  }\n} {3 9 29 35 55 61 81 82 87 89 scan 0 sort 0}\ndo_test where7-2.801.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?efgh*' AND f GLOB 'defg*')\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR f='jklmnopqr'\n  }\n} {3 9 29 35 55 61 81 82 87 89 scan 0 sort 0}\ndo_test where7-2.802.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=946\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=47\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR b=80\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {8 23 42 47 60 62 78 86 93 scan 0 sort 0}\ndo_test where7-2.802.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=946\n         OR (g='ihgfedc' AND f GLOB 'abcde*')\n         OR a=47\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR b=80\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n  }\n} {8 23 42 47 60 62 78 86 93 scan 0 sort 0}\ndo_test where7-2.803.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=48\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR b=1015\n         OR a=57\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=165\n  }\n} {4 9 15 35 47 48 49 50 55 57 61 87 98 100 scan 0 sort 0}\ndo_test where7-2.803.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=48\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR b=1015\n         OR a=57\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR ((a BETWEEN 47 AND 49) AND a!=48)\n         OR ((a BETWEEN 98 AND 100) AND a!=99)\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR b=165\n  }\n} {4 9 15 35 47 48 49 50 55 57 61 87 98 100 scan 0 sort 0}\ndo_test where7-2.804.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 97 AND 99) AND a!=98)\n         OR a=73\n         OR b=1048\n         OR c>=34035\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR a=72\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=638\n  }\n} {58 72 73 80 91 93 97 99 scan 0 sort 0}\ndo_test where7-2.804.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 97 AND 99) AND a!=98)\n         OR a=73\n         OR b=1048\n         OR c>=34035\n         OR (g='ihgfedc' AND f GLOB 'cdefg*')\n         OR a=72\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=638\n  }\n} {58 72 73 80 91 93 97 99 scan 0 sort 0}\ndo_test where7-2.805.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR a=39\n         OR b=165\n  }\n} {15 28 30 39 scan 0 sort 0}\ndo_test where7-2.805.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 28 AND 30) AND a!=29)\n         OR a=39\n         OR b=165\n  }\n} {15 28 30 39 scan 0 sort 0}\ndo_test where7-2.806.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=50\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR a=32\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR a=14\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=946\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR b=124\n  }\n} {14 17 32 43 45 50 53 55 61 63 69 86 93 95 97 scan 0 sort 0}\ndo_test where7-2.806.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=50\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR a=32\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR a=14\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR b=946\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR b=124\n  }\n} {14 17 32 43 45 50 53 55 61 63 69 86 93 95 97 scan 0 sort 0}\ndo_test where7-2.807.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {52 66 88 90 scan 0 sort 0}\ndo_test where7-2.807.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 88 AND 90) AND a!=89)\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {52 66 88 90 scan 0 sort 0}\ndo_test where7-2.808.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=6\n         OR f='tuvwxyzab'\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=286\n         OR b=781\n  }\n} {6 19 26 45 59 71 97 scan 0 sort 0}\ndo_test where7-2.808.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=6\n         OR f='tuvwxyzab'\n         OR (g='mlkjihg' AND f GLOB 'hijkl*')\n         OR b=286\n         OR b=781\n  }\n} {6 19 26 45 59 71 97 scan 0 sort 0}\ndo_test where7-2.809.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR f='vwxyzabcd'\n         OR b=275\n  }\n} {9 11 21 25 35 37 43 47 61 63 73 77 79 81 87 89 99 100 scan 0 sort 0}\ndo_test where7-2.809.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR f='vwxyzabcd'\n         OR b=275\n  }\n} {9 11 21 25 35 37 43 47 61 63 73 77 79 81 87 89 99 100 scan 0 sort 0}\ndo_test where7-2.810.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR a=59\n  }\n} {4 30 59 64 89 91 scan 0 sort 0}\ndo_test where7-2.810.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR (g='xwvutsr' AND f GLOB 'efghi*')\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'nopqr*')\n         OR a=59\n  }\n} {4 30 59 64 89 91 scan 0 sort 0}\ndo_test where7-2.811.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR b=663\n         OR f='ghijklmno'\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR f='ghijklmno'\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR b=1081\n  }\n} {6 8 10 14 16 19 22 32 48 58 64 71 74 84 99 100 scan 0 sort 0}\ndo_test where7-2.811.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR b=663\n         OR f='ghijklmno'\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR f='ghijklmno'\n         OR (d>=64.0 AND d<65.0 AND d NOT NULL)\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n         OR b=1081\n  }\n} {6 8 10 14 16 19 22 32 48 58 64 71 74 84 99 100 scan 0 sort 0}\ndo_test where7-2.812.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR a=96\n         OR b=355\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR b=597\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR b=168\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n  }\n} {10 15 30 32 36 62 81 88 92 94 96 scan 0 sort 0}\ndo_test where7-2.812.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 30 AND 32) AND a!=31)\n         OR a=96\n         OR b=355\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR b=597\n         OR ((a BETWEEN 92 AND 94) AND a!=93)\n         OR (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR (f GLOB '?lmno*' AND f GLOB 'klmn*')\n         OR b=168\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n  }\n} {10 15 30 32 36 62 81 88 92 94 96 scan 0 sort 0}\ndo_test where7-2.813.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=957\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=40\n  }\n} {9 40 47 58 60 87 89 scan 0 sort 0}\ndo_test where7-2.813.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=47.0 AND d<48.0 AND d NOT NULL)\n         OR b=957\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR a=40\n  }\n} {9 40 47 58 60 87 89 scan 0 sort 0}\ndo_test where7-2.814.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 12 AND 14) AND a!=13)\n         OR a=36\n         OR a=75\n         OR b=179\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR b=850\n         OR a=62\n  }\n} {12 14 18 36 43 62 65 75 scan 0 sort 0}\ndo_test where7-2.814.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 12 AND 14) AND a!=13)\n         OR a=36\n         OR a=75\n         OR b=179\n         OR (d>=43.0 AND d<44.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'stuvw*')\n         OR (d>=65.0 AND d<66.0 AND d NOT NULL)\n         OR b=850\n         OR a=62\n  }\n} {12 14 18 36 43 62 65 75 scan 0 sort 0}\ndo_test where7-2.815.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=79\n         OR a=66\n         OR b=487\n         OR a=1\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR c=5005\n         OR a=47\n         OR c=5005\n         OR b=319\n         OR b=1037\n  }\n} {1 13 14 15 21 23 29 47 54 66 79 scan 0 sort 0}\ndo_test where7-2.815.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=79\n         OR a=66\n         OR b=487\n         OR a=1\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR c=5005\n         OR a=47\n         OR c=5005\n         OR b=319\n         OR b=1037\n  }\n} {1 13 14 15 21 23 29 47 54 66 79 scan 0 sort 0}\ndo_test where7-2.816.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=176\n         OR b=297\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR f='ijklmnopq'\n  }\n} {8 16 25 27 34 60 86 scan 0 sort 0}\ndo_test where7-2.816.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=176\n         OR b=297\n         OR (g='tsrqpon' AND f GLOB 'zabcd*')\n         OR f='ijklmnopq'\n  }\n} {8 16 25 27 34 60 86 scan 0 sort 0}\ndo_test where7-2.817.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR b=319\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR a=21\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {9 10 11 21 29 31 33 72 90 92 scan 0 sort 0}\ndo_test where7-2.817.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n         OR b=319\n         OR ((a BETWEEN 31 AND 33) AND a!=32)\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR a=21\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {9 10 11 21 29 31 33 72 90 92 scan 0 sort 0}\ndo_test where7-2.818.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=396\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=1012\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=784\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=979\n         OR c<=10\n         OR b=913\n         OR b=66\n  }\n} {6 9 22 35 36 60 61 72 83 87 89 92 scan 0 sort 0}\ndo_test where7-2.818.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR b=396\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR b=1012\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR b=784\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR b=979\n         OR c<=10\n         OR b=913\n         OR b=66\n  }\n} {6 9 22 35 36 60 61 72 83 87 89 92 scan 0 sort 0}\ndo_test where7-2.819.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=3\n         OR b=803\n  }\n} {3 73 scan 0 sort 0}\ndo_test where7-2.819.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=3\n         OR b=803\n  }\n} {3 73 scan 0 sort 0}\ndo_test where7-2.820.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n  }\n} {16 19 23 25 42 45 68 71 79 81 94 97 scan 0 sort 0}\ndo_test where7-2.820.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (f GLOB '?rstu*' AND f GLOB 'qrst*')\n         OR ((a BETWEEN 23 AND 25) AND a!=24)\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n  }\n} {16 19 23 25 42 45 68 71 79 81 94 97 scan 0 sort 0}\ndo_test where7-2.821.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=1001\n         OR a=16\n         OR b=132\n         OR b=1012\n         OR f='xyzabcdef'\n         OR b=682\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n  }\n} {1 2 3 12 16 23 49 52 62 75 92 scan 0 sort 0}\ndo_test where7-2.821.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=1001\n         OR a=16\n         OR b=132\n         OR b=1012\n         OR f='xyzabcdef'\n         OR b=682\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n  }\n} {1 2 3 12 16 23 49 52 62 75 92 scan 0 sort 0}\ndo_test where7-2.822.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=96\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n  }\n} {19 96 scan 0 sort 0}\ndo_test where7-2.822.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=96\n         OR (d>=19.0 AND d<20.0 AND d NOT NULL)\n  }\n} {19 96 scan 0 sort 0}\ndo_test where7-2.823.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=2\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR a=23\n         OR b=1092\n         OR c=19019\n         OR b=245\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=572\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {2 11 12 22 23 24 38 52 55 56 57 64 68 70 90 97 99 scan 0 sort 0}\ndo_test where7-2.823.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=2\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n         OR a=23\n         OR b=1092\n         OR c=19019\n         OR b=245\n         OR ((a BETWEEN 97 AND 99) AND a!=98)\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR b=572\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n  }\n} {2 11 12 22 23 24 38 52 55 56 57 64 68 70 90 97 99 scan 0 sort 0}\ndo_test where7-2.824.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=993\n         OR c=17017\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=333\n  }\n} {16 29 37 49 50 51 53 85 scan 0 sort 0}\ndo_test where7-2.824.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR b=993\n         OR c=17017\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=333\n  }\n} {16 29 37 49 50 51 53 85 scan 0 sort 0}\ndo_test where7-2.825.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=330\n         OR a=73\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=828\n         OR b=363\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {30 33 37 40 61 73 scan 0 sort 0}\ndo_test where7-2.825.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=330\n         OR a=73\n         OR (d>=61.0 AND d<62.0 AND d NOT NULL)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=828\n         OR b=363\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n  }\n} {30 33 37 40 61 73 scan 0 sort 0}\ndo_test where7-2.826.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'lmnop*')\n         OR a=41\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=825\n  }\n} {29 41 75 89 scan 0 sort 0}\ndo_test where7-2.826.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'lmnop*')\n         OR a=41\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=825\n  }\n} {29 41 75 89 scan 0 sort 0}\ndo_test where7-2.827.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 46 AND 48) AND a!=47)\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=905\n         OR b=176\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=561\n         OR c=8008\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR b=935\n         OR c=1001\n  }\n} {1 2 3 10 16 22 23 24 46 48 51 84 85 89 91 scan 0 sort 0}\ndo_test where7-2.827.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 46 AND 48) AND a!=47)\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n         OR b=905\n         OR b=176\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR b=561\n         OR c=8008\n         OR (g='hgfedcb' AND f GLOB 'ghijk*')\n         OR b=935\n         OR c=1001\n  }\n} {1 2 3 10 16 22 23 24 46 48 51 84 85 89 91 scan 0 sort 0}\ndo_test where7-2.828.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 75 AND 77) AND a!=76)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {72 75 77 scan 0 sort 0}\ndo_test where7-2.828.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 75 AND 77) AND a!=76)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {72 75 77 scan 0 sort 0}\ndo_test where7-2.829.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 5 AND 7) AND a!=6)\n         OR a=28\n  }\n} {5 7 28 scan 0 sort 0}\ndo_test where7-2.829.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 5 AND 7) AND a!=6)\n         OR a=28\n  }\n} {5 7 28 scan 0 sort 0}\ndo_test where7-2.830.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=781\n         OR b=410\n  }\n} {71 scan 0 sort 0}\ndo_test where7-2.830.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=781\n         OR b=410\n  }\n} {71 scan 0 sort 0}\ndo_test where7-2.831.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 18 AND 20) AND a!=19)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR b=861\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR a=28\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=311\n  }\n} {6 15 18 20 25 28 32 40 42 51 56 58 63 72 77 84 scan 0 sort 0}\ndo_test where7-2.831.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 18 AND 20) AND a!=19)\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR f='zabcdefgh'\n         OR b=861\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n         OR a=28\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=311\n  }\n} {6 15 18 20 25 28 32 40 42 51 56 58 63 72 77 84 scan 0 sort 0}\ndo_test where7-2.832.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=575\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=418\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR b=792\n         OR b=861\n         OR b=220\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {12 15 20 38 41 64 67 72 73 89 90 91 93 scan 0 sort 0}\ndo_test where7-2.832.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=575\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR b=418\n         OR (f GLOB '?qrst*' AND f GLOB 'pqrs*')\n         OR b=792\n         OR b=861\n         OR b=220\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n  }\n} {12 15 20 38 41 64 67 72 73 89 90 91 93 scan 0 sort 0}\ndo_test where7-2.833.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=517\n         OR b=913\n         OR b=253\n         OR b=198\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=17\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {17 18 23 27 47 83 85 scan 0 sort 0}\ndo_test where7-2.833.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=517\n         OR b=913\n         OR b=253\n         OR b=198\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR a=17\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n  }\n} {17 18 23 27 47 83 85 scan 0 sort 0}\ndo_test where7-2.834.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=693\n         OR a=73\n         OR b=627\n         OR c=5005\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=267\n         OR b=872\n         OR a=27\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {13 14 15 27 28 42 57 62 63 73 88 scan 0 sort 0}\ndo_test where7-2.834.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=693\n         OR a=73\n         OR b=627\n         OR c=5005\n         OR (d>=62.0 AND d<63.0 AND d NOT NULL)\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR b=267\n         OR b=872\n         OR a=27\n         OR (g='gfedcba' AND f GLOB 'klmno*')\n  }\n} {13 14 15 27 28 42 57 62 63 73 88 scan 0 sort 0}\ndo_test where7-2.835.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=10\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=1059\n         OR a=70\n         OR a=93\n  }\n} {10 13 15 70 93 95 97 scan 0 sort 0}\ndo_test where7-2.835.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=10\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=1059\n         OR a=70\n         OR a=93\n  }\n} {10 13 15 70 93 95 97 scan 0 sort 0}\ndo_test where7-2.836.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=30\n         OR a=32\n         OR b=1037\n         OR b=198\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR a=25\n  }\n} {13 18 25 30 32 scan 0 sort 0}\ndo_test where7-2.836.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=30\n         OR a=32\n         OR b=1037\n         OR b=198\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR a=25\n  }\n} {13 18 25 30 32 scan 0 sort 0}\ndo_test where7-2.837.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=66\n         OR b=322\n         OR b=465\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=454\n  }\n} {6 7 38 46 64 77 79 89 scan 0 sort 0}\ndo_test where7-2.837.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR b=66\n         OR b=322\n         OR b=465\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR (d>=7.0 AND d<8.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n         OR (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=454\n  }\n} {6 7 38 46 64 77 79 89 scan 0 sort 0}\ndo_test where7-2.838.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=924\n         OR ((a BETWEEN 35 AND 37) AND a!=36)\n         OR c=15015\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR b=803\n  }\n} {3 5 35 37 43 44 45 52 73 84 scan 0 sort 0}\ndo_test where7-2.838.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=924\n         OR ((a BETWEEN 35 AND 37) AND a!=36)\n         OR c=15015\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR b=803\n  }\n} {3 5 35 37 43 44 45 52 73 84 scan 0 sort 0}\ndo_test where7-2.839.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1100\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR a=75\n         OR a=45\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR a=27\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=850\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n  }\n} {12 27 45 55 57 68 70 72 74 75 77 90 100 scan 0 sort 0}\ndo_test where7-2.839.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1100\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 72 AND 74) AND a!=73)\n         OR ((a BETWEEN 68 AND 70) AND a!=69)\n         OR a=75\n         OR a=45\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR a=27\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR b=850\n         OR ((a BETWEEN 55 AND 57) AND a!=56)\n  }\n} {12 27 45 55 57 68 70 72 74 75 77 90 100 scan 0 sort 0}\ndo_test where7-2.840.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=751\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=89\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {36 38 56 71 89 96 98 scan 0 sort 0}\ndo_test where7-2.840.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=751\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR (d>=71.0 AND d<72.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR a=89\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {36 38 56 71 89 96 98 scan 0 sort 0}\ndo_test where7-2.841.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR a=1\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n  }\n} {1 9 19 scan 0 sort 0}\ndo_test where7-2.841.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='wvutsrq' AND f GLOB 'jklmn*')\n         OR (g='yxwvuts' AND f GLOB 'bcdef*')\n         OR a=1\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n  }\n} {1 9 19 scan 0 sort 0}\ndo_test where7-2.842.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=927\n         OR c=15015\n         OR f='klmnopqrs'\n         OR c=8008\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR b=960\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=443\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n  }\n} {10 22 23 24 34 36 41 43 44 45 62 76 88 scan 0 sort 0}\ndo_test where7-2.842.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=927\n         OR c=15015\n         OR f='klmnopqrs'\n         OR c=8008\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR b=960\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=443\n         OR (g='rqponml' AND f GLOB 'ijklm*')\n  }\n} {10 22 23 24 34 36 41 43 44 45 62 76 88 scan 0 sort 0}\ndo_test where7-2.843.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=212\n         OR f='cdefghijk'\n  }\n} {2 28 37 54 80 scan 0 sort 0}\ndo_test where7-2.843.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR b=212\n         OR f='cdefghijk'\n  }\n} {2 28 37 54 80 scan 0 sort 0}\ndo_test where7-2.844.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=685\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR b=520\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR a=53\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=938\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR c=25025\n  }\n} {43 53 63 73 74 75 76 91 93 scan 0 sort 0}\ndo_test where7-2.844.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=685\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR b=520\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR a=53\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=938\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR c=25025\n  }\n} {43 53 63 73 74 75 76 91 93 scan 0 sort 0}\ndo_test where7-2.845.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=583\n         OR b=894\n         OR c=26026\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n  }\n} {53 76 77 78 84 scan 0 sort 0}\ndo_test where7-2.845.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=583\n         OR b=894\n         OR c=26026\n         OR (d>=84.0 AND d<85.0 AND d NOT NULL)\n  }\n} {53 76 77 78 84 scan 0 sort 0}\ndo_test where7-2.846.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='abcdefghi'\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n  }\n} {26 52 78 100 scan 0 sort 0}\ndo_test where7-2.846.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='abcdefghi'\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n  }\n} {26 52 78 100 scan 0 sort 0}\ndo_test where7-2.847.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1103\n         OR b=638\n         OR b=792\n         OR b=1034\n         OR b=308\n         OR f='nopqrstuv'\n         OR b=264\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n  }\n} {13 24 28 33 35 39 58 65 72 91 94 scan 0 sort 0}\ndo_test where7-2.847.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1103\n         OR b=638\n         OR b=792\n         OR b=1034\n         OR b=308\n         OR f='nopqrstuv'\n         OR b=264\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR (d>=58.0 AND d<59.0 AND d NOT NULL)\n  }\n} {13 24 28 33 35 39 58 65 72 91 94 scan 0 sort 0}\ndo_test where7-2.848.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='defghijkl'\n         OR b=814\n         OR f='yzabcdefg'\n  }\n} {3 24 29 50 55 74 76 81 scan 0 sort 0}\ndo_test where7-2.848.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='defghijkl'\n         OR b=814\n         OR f='yzabcdefg'\n  }\n} {3 24 29 50 55 74 76 81 scan 0 sort 0}\ndo_test where7-2.849.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=209\n         OR b=806\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {8 17 19 scan 0 sort 0}\ndo_test where7-2.849.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=209\n         OR b=806\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'rstuv*')\n  }\n} {8 17 19 scan 0 sort 0}\ndo_test where7-2.850.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='opqrstuvw'\n         OR b=69\n         OR b=366\n  }\n} {14 40 66 92 scan 0 sort 0}\ndo_test where7-2.850.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='opqrstuvw'\n         OR b=69\n         OR b=366\n  }\n} {14 40 66 92 scan 0 sort 0}\ndo_test where7-2.851.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=45\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR a=69\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {4 45 69 71 72 scan 0 sort 0}\ndo_test where7-2.851.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=45\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR a=69\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {4 45 69 71 72 scan 0 sort 0}\ndo_test where7-2.852.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=9009\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n  }\n} {9 10 25 26 27 67 85 scan 0 sort 0}\ndo_test where7-2.852.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=9009\n         OR (d>=85.0 AND d<86.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR (d>=9.0 AND d<10.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'pqrst*')\n  }\n} {9 10 25 26 27 67 85 scan 0 sort 0}\ndo_test where7-2.853.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=98\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=47\n         OR c=24024\n         OR a=27\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n  }\n} {20 27 45 47 63 70 71 72 98 100 scan 0 sort 0}\ndo_test where7-2.853.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=98\n         OR (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR a=47\n         OR c=24024\n         OR a=27\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n  }\n} {20 27 45 47 63 70 71 72 98 100 scan 0 sort 0}\ndo_test where7-2.854.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=19\n  }\n} {19 22 44 scan 0 sort 0}\ndo_test where7-2.854.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=19\n  }\n} {19 22 44 scan 0 sort 0}\ndo_test where7-2.855.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=12012\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n  }\n} {16 18 34 35 36 80 98 scan 0 sort 0}\ndo_test where7-2.855.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=12012\n         OR (d>=80.0 AND d<81.0 AND d NOT NULL)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n  }\n} {16 18 34 35 36 80 98 scan 0 sort 0}\ndo_test where7-2.856.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR b=429\n         OR f='jklmnopqr'\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {9 12 35 38 39 40 48 61 64 77 79 87 90 scan 0 sort 0}\ndo_test where7-2.856.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR b=429\n         OR f='jklmnopqr'\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR ((a BETWEEN 77 AND 79) AND a!=78)\n  }\n} {9 12 35 38 39 40 48 61 64 77 79 87 90 scan 0 sort 0}\ndo_test where7-2.857.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=190\n  }\n} {64 scan 0 sort 0}\ndo_test where7-2.857.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=190\n  }\n} {64 scan 0 sort 0}\ndo_test where7-2.858.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=674\n         OR b=289\n  }\n} {76 scan 0 sort 0}\ndo_test where7-2.858.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'yzabc*')\n         OR b=674\n         OR b=289\n  }\n} {76 scan 0 sort 0}\ndo_test where7-2.859.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=17\n         OR b=539\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n  }\n} {17 21 47 49 scan 0 sort 0}\ndo_test where7-2.859.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=17\n         OR b=539\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (g='utsrqpo' AND f GLOB 'vwxyz*')\n  }\n} {17 21 47 49 scan 0 sort 0}\ndo_test where7-2.860.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=924\n         OR c=27027\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {65 67 79 80 81 84 scan 0 sort 0}\ndo_test where7-2.860.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=924\n         OR c=27027\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {65 67 79 80 81 84 scan 0 sort 0}\ndo_test where7-2.861.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=564\n         OR f='mnopqrstu'\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=1103\n  }\n} {12 28 30 38 64 90 scan 0 sort 0}\ndo_test where7-2.861.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=564\n         OR f='mnopqrstu'\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=1103\n  }\n} {12 28 30 38 64 90 scan 0 sort 0}\ndo_test where7-2.862.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=231\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR a=38\n         OR a=4\n         OR b=784\n  }\n} {4 21 24 38 scan 0 sort 0}\ndo_test where7-2.862.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=231\n         OR (d>=24.0 AND d<25.0 AND d NOT NULL)\n         OR a=38\n         OR a=4\n         OR b=784\n  }\n} {4 21 24 38 scan 0 sort 0}\ndo_test where7-2.863.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='ghijklmno'\n         OR a=26\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=81\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=275\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=311\n         OR b=894\n         OR b=872\n  }\n} {3 6 25 26 28 30 32 58 68 81 84 87 scan 0 sort 0}\ndo_test where7-2.863.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='ghijklmno'\n         OR a=26\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR a=81\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR ((a BETWEEN 28 AND 30) AND a!=29)\n         OR b=275\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR b=311\n         OR b=894\n         OR b=872\n  }\n} {3 6 25 26 28 30 32 58 68 81 84 87 scan 0 sort 0}\ndo_test where7-2.864.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=91\n         OR b=619\n  }\n} {91 scan 0 sort 0}\ndo_test where7-2.864.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=91\n         OR b=619\n  }\n} {91 scan 0 sort 0}\ndo_test where7-2.865.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=85\n         OR f IS NULL\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=154\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {4 14 25 40 42 49 51 66 68 85 87 89 scan 0 sort 0}\ndo_test where7-2.865.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=4.0 AND d<5.0 AND d NOT NULL)\n         OR a=85\n         OR f IS NULL\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=154\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n  }\n} {4 14 25 40 42 49 51 66 68 85 87 89 scan 0 sort 0}\ndo_test where7-2.866.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=44\n         OR b=55\n         OR a=30\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR 1000000<b\n         OR a=24\n         OR b=1089\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {5 19 24 30 33 44 45 71 75 97 99 scan 0 sort 0}\ndo_test where7-2.866.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=44\n         OR b=55\n         OR a=30\n         OR (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR 1000000<b\n         OR a=24\n         OR b=1089\n         OR (d>=75.0 AND d<76.0 AND d NOT NULL)\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {5 19 24 30 33 44 45 71 75 97 99 scan 0 sort 0}\ndo_test where7-2.867.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=36\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {16 33 35 80 82 scan 0 sort 0}\ndo_test where7-2.867.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=16.0 AND d<17.0 AND d NOT NULL)\n         OR ((a BETWEEN 80 AND 82) AND a!=81)\n         OR b=36\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {16 33 35 80 82 scan 0 sort 0}\ndo_test where7-2.868.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR c=26026\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=56\n         OR b=506\n         OR b=781\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n  }\n} {28 35 37 39 46 56 71 76 77 78 97 scan 0 sort 0}\ndo_test where7-2.868.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR c=26026\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=56\n         OR b=506\n         OR b=781\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n  }\n} {28 35 37 39 46 56 71 76 77 78 97 scan 0 sort 0}\ndo_test where7-2.869.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR f='xyzabcdef'\n         OR b=517\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n  }\n} {23 25 27 39 47 49 68 75 76 89 91 98 scan 0 sort 0}\ndo_test where7-2.869.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 25 AND 27) AND a!=26)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR ((a BETWEEN 89 AND 91) AND a!=90)\n         OR f='xyzabcdef'\n         OR b=517\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n  }\n} {23 25 27 39 47 49 68 75 76 89 91 98 scan 0 sort 0}\ndo_test where7-2.870.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=54\n         OR a=59\n  }\n} {54 59 scan 0 sort 0}\ndo_test where7-2.870.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=54\n         OR a=59\n  }\n} {54 59 scan 0 sort 0}\ndo_test where7-2.871.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR b=762\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR a=25\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {24 25 48 65 67 scan 0 sort 0}\ndo_test where7-2.871.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='tsrqpon' AND f GLOB 'yzabc*')\n         OR b=762\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR a=25\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n  }\n} {24 25 48 65 67 scan 0 sort 0}\ndo_test where7-2.872.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=839\n         OR f='defghijkl'\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=498\n  }\n} {3 14 16 29 52 55 59 60 81 85 95 scan 0 sort 0}\ndo_test where7-2.872.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=59.0 AND d<60.0 AND d NOT NULL)\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=839\n         OR f='defghijkl'\n         OR (d>=95.0 AND d<96.0 AND d NOT NULL)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR b=498\n  }\n} {3 14 16 29 52 55 59 60 81 85 95 scan 0 sort 0}\ndo_test where7-2.873.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=256\n         OR c=19019\n         OR a=54\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=498\n         OR b=77\n  }\n} {7 46 54 55 56 57 scan 0 sort 0}\ndo_test where7-2.873.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=256\n         OR c=19019\n         OR a=54\n         OR (d>=46.0 AND d<47.0 AND d NOT NULL)\n         OR b=498\n         OR b=77\n  }\n} {7 46 54 55 56 57 scan 0 sort 0}\ndo_test where7-2.874.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=256\n         OR b=586\n         OR a=74\n         OR b=113\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=495\n  }\n} {45 61 74 99 scan 0 sort 0}\ndo_test where7-2.874.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='mlkjihg' AND f GLOB 'jklmn*')\n         OR b=256\n         OR b=586\n         OR a=74\n         OR b=113\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=495\n  }\n} {45 61 74 99 scan 0 sort 0}\ndo_test where7-2.875.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=12\n         OR a=50\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n  }\n} {12 33 50 66 68 scan 0 sort 0}\ndo_test where7-2.875.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=12\n         OR a=50\n         OR (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n  }\n} {12 33 50 66 68 scan 0 sort 0}\ndo_test where7-2.876.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=308\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR a=83\n         OR c=23023\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR a=58\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR c=4004\n  }\n} {10 11 12 17 19 28 30 53 57 58 65 67 68 69 73 83 scan 0 sort 0}\ndo_test where7-2.876.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=308\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR a=83\n         OR c=23023\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR (g='lkjihgf' AND f GLOB 'nopqr*')\n         OR a=58\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR c=4004\n  }\n} {10 11 12 17 19 28 30 53 57 58 65 67 68 69 73 83 scan 0 sort 0}\ndo_test where7-2.877.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=476\n         OR a=26\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=762\n         OR b=157\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n  }\n} {17 26 54 87 scan 0 sort 0}\ndo_test where7-2.877.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=476\n         OR a=26\n         OR (d>=87.0 AND d<88.0 AND d NOT NULL)\n         OR b=762\n         OR b=157\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n  }\n} {17 26 54 87 scan 0 sort 0}\ndo_test where7-2.878.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR a=1\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=278\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR f='qrstuvwxy'\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {1 3 16 42 52 68 72 74 77 82 84 93 94 95 98 scan 0 sort 0}\ndo_test where7-2.878.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR a=1\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=278\n         OR (g='xwvutsr' AND f GLOB 'defgh*')\n         OR f='qrstuvwxy'\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 82 AND 84) AND a!=83)\n         OR (g='edcbazy' AND f GLOB 'uvwxy*')\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n  }\n} {1 3 16 42 52 68 72 74 77 82 84 93 94 95 98 scan 0 sort 0}\ndo_test where7-2.879.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=124\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=759\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {12 38 41 43 45 47 64 69 72 90 92 96 scan 0 sort 0}\ndo_test where7-2.879.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=124\n         OR (d>=92.0 AND d<93.0 AND d NOT NULL)\n         OR ((a BETWEEN 41 AND 43) AND a!=42)\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=759\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n  }\n} {12 38 41 43 45 47 64 69 72 90 92 96 scan 0 sort 0}\ndo_test where7-2.880.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=872\n         OR b=267\n         OR b=814\n         OR b=99\n         OR c<=10\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR b=44\n         OR f='zabcdefgh'\n         OR b=979\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {4 8 9 10 25 33 51 74 77 89 scan 0 sort 0}\ndo_test where7-2.880.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=872\n         OR b=267\n         OR b=814\n         OR b=99\n         OR c<=10\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR b=44\n         OR f='zabcdefgh'\n         OR b=979\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {4 8 9 10 25 33 51 74 77 89 scan 0 sort 0}\ndo_test where7-2.881.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR f='xyzabcdef'\n  }\n} {23 26 49 75 scan 0 sort 0}\ndo_test where7-2.881.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR f='xyzabcdef'\n  }\n} {23 26 49 75 scan 0 sort 0}\ndo_test where7-2.882.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=487\n         OR b=355\n         OR c=9009\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=113\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=90\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR f='nopqrstuv'\n  }\n} {8 13 24 25 26 27 32 34 39 65 66 87 90 91 scan 0 sort 0}\ndo_test where7-2.882.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=487\n         OR b=355\n         OR c=9009\n         OR (d>=8.0 AND d<9.0 AND d NOT NULL)\n         OR ((a BETWEEN 32 AND 34) AND a!=33)\n         OR b=113\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=90\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n         OR f='nopqrstuv'\n  }\n} {8 13 24 25 26 27 32 34 39 65 66 87 90 91 scan 0 sort 0}\ndo_test where7-2.883.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=275\n  }\n} {25 34 scan 0 sort 0}\ndo_test where7-2.883.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR b=275\n  }\n} {25 34 scan 0 sort 0}\ndo_test where7-2.884.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=355\n         OR a=44\n         OR b=374\n         OR c=25025\n         OR b=198\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR d<0.0\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c=9009\n  }\n} {4 6 18 25 26 27 34 41 44 69 71 73 74 75 scan 0 sort 0}\ndo_test where7-2.884.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=355\n         OR a=44\n         OR b=374\n         OR c=25025\n         OR b=198\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR d<0.0\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR c=9009\n  }\n} {4 6 18 25 26 27 34 41 44 69 71 73 74 75 scan 0 sort 0}\ndo_test where7-2.885.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=814\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {19 45 54 71 74 97 scan 0 sort 0}\ndo_test where7-2.885.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?uvwx*' AND f GLOB 'tuvw*')\n         OR b=814\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n  }\n} {19 45 54 71 74 97 scan 0 sort 0}\ndo_test where7-2.886.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=333\n         OR b=275\n  }\n} {25 64 scan 0 sort 0}\ndo_test where7-2.886.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'mnopq*')\n         OR b=333\n         OR b=275\n  }\n} {25 64 scan 0 sort 0}\ndo_test where7-2.887.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {33 35 82 scan 0 sort 0}\ndo_test where7-2.887.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='ihgfedc' AND f GLOB 'efghi*')\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n  }\n} {33 35 82 scan 0 sort 0}\ndo_test where7-2.888.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=253\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=286\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n  }\n} {10 11 13 14 23 26 40 66 92 scan 0 sort 0}\ndo_test where7-2.888.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 11 AND 13) AND a!=12)\n         OR b=253\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=286\n         OR (d>=10.0 AND d<11.0 AND d NOT NULL)\n  }\n} {10 11 13 14 23 26 40 66 92 scan 0 sort 0}\ndo_test where7-2.889.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR b=421\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR f='ijklmnopq'\n         OR b=891\n         OR b=1056\n  }\n} {5 8 15 26 28 34 60 81 86 90 96 scan 0 sort 0}\ndo_test where7-2.889.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 26 AND 28) AND a!=27)\n         OR b=421\n         OR (g='xwvutsr' AND f GLOB 'fghij*')\n         OR f='ijklmnopq'\n         OR b=891\n         OR b=1056\n  }\n} {5 8 15 26 28 34 60 81 86 90 96 scan 0 sort 0}\ndo_test where7-2.890.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='fghijklmn'\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR b=671\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n  }\n} {5 7 31 39 57 61 83 99 scan 0 sort 0}\ndo_test where7-2.890.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='fghijklmn'\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR (g='edcbazy' AND f GLOB 'vwxyz*')\n         OR b=671\n         OR (g='xwvutsr' AND f GLOB 'hijkl*')\n  }\n} {5 7 31 39 57 61 83 99 scan 0 sort 0}\ndo_test where7-2.891.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {4 6 11 31 63 68 scan 0 sort 0}\ndo_test where7-2.891.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='lkjihgf' AND f GLOB 'lmnop*')\n         OR (g='srqponm' AND f GLOB 'fghij*')\n         OR ((a BETWEEN 4 AND 6) AND a!=5)\n         OR (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR (d>=11.0 AND d<12.0 AND d NOT NULL)\n  }\n} {4 6 11 31 63 68 scan 0 sort 0}\ndo_test where7-2.892.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=11011\n         OR a=20\n         OR b=432\n         OR b=410\n         OR a=86\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=638\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR b=190\n  }\n} {20 31 32 33 58 60 86 89 scan 0 sort 0}\ndo_test where7-2.892.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=11011\n         OR a=20\n         OR b=432\n         OR b=410\n         OR a=86\n         OR (d>=89.0 AND d<90.0 AND d NOT NULL)\n         OR b=638\n         OR ((a BETWEEN 58 AND 60) AND a!=59)\n         OR b=190\n  }\n} {20 31 32 33 58 60 86 89 scan 0 sort 0}\ndo_test where7-2.893.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=88\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n         OR a=76\n         OR b=69\n         OR b=847\n         OR b=275\n  }\n} {8 25 42 44 76 77 scan 0 sort 0}\ndo_test where7-2.893.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=88\n         OR ((a BETWEEN 42 AND 44) AND a!=43)\n         OR a=76\n         OR b=69\n         OR b=847\n         OR b=275\n  }\n} {8 25 42 44 76 77 scan 0 sort 0}\ndo_test where7-2.894.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=781\n         OR b=77\n         OR b=58\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n  }\n} {7 67 69 71 scan 0 sort 0}\ndo_test where7-2.894.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=781\n         OR b=77\n         OR b=58\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n  }\n} {7 67 69 71 scan 0 sort 0}\ndo_test where7-2.895.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR a=46\n         OR b=187\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n  }\n} {17 20 46 50 67 69 71 scan 0 sort 0}\ndo_test where7-2.895.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 67 AND 69) AND a!=68)\n         OR (d>=69.0 AND d<70.0 AND d NOT NULL)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR a=46\n         OR b=187\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n  }\n} {17 20 46 50 67 69 71 scan 0 sort 0}\ndo_test where7-2.896.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=99\n         OR c=3003\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=300\n         OR b=718\n         OR c>=34035\n         OR b=264\n  }\n} {7 8 9 24 57 97 99 scan 0 sort 0}\ndo_test where7-2.896.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=99\n         OR c=3003\n         OR (d>=57.0 AND d<58.0 AND d NOT NULL)\n         OR b=300\n         OR b=718\n         OR c>=34035\n         OR b=264\n  }\n} {7 8 9 24 57 97 99 scan 0 sort 0}\ndo_test where7-2.897.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=872\n         OR b=209\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=355\n         OR b=729\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR a=58\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=608\n  }\n} {14 19 40 58 65 66 67 81 83 92 scan 0 sort 0}\ndo_test where7-2.897.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=872\n         OR b=209\n         OR ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=355\n         OR b=729\n         OR ((a BETWEEN 81 AND 83) AND a!=82)\n         OR a=58\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR b=608\n  }\n} {14 19 40 58 65 66 67 81 83 92 scan 0 sort 0}\ndo_test where7-2.898.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=29029\n         OR f='efghijklm'\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR a=26\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n  }\n} {3 4 26 29 30 48 55 56 81 82 85 86 87 scan 0 sort 0}\ndo_test where7-2.898.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=29029\n         OR f='efghijklm'\n         OR (d>=48.0 AND d<49.0 AND d NOT NULL)\n         OR a=26\n         OR (f GLOB '?efgh*' AND f GLOB 'defg*')\n  }\n} {3 4 26 29 30 48 55 56 81 82 85 86 87 scan 0 sort 0}\ndo_test where7-2.899.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=59\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR a=7\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=762\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {7 12 14 26 40 59 66 92 scan 0 sort 0}\ndo_test where7-2.899.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=59\n         OR (g='wvutsrq' AND f GLOB 'mnopq*')\n         OR a=7\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=762\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n  }\n} {7 12 14 26 40 59 66 92 scan 0 sort 0}\ndo_test where7-2.900.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=539\n         OR b=399\n  }\n} {49 91 scan 0 sort 0}\ndo_test where7-2.900.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'nopqr*')\n         OR b=539\n         OR b=399\n  }\n} {49 91 scan 0 sort 0}\ndo_test where7-2.901.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR a=92\n  }\n} {71 73 92 96 98 scan 0 sort 0}\ndo_test where7-2.901.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 71 AND 73) AND a!=72)\n         OR ((a BETWEEN 96 AND 98) AND a!=97)\n         OR a=92\n  }\n} {71 73 92 96 98 scan 0 sort 0}\ndo_test where7-2.902.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR f='lmnopqrst'\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {9 11 35 36 37 57 61 63 87 89 scan 0 sort 0}\ndo_test where7-2.902.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR (g='rqponml' AND f GLOB 'klmno*')\n         OR f='lmnopqrst'\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n  }\n} {9 11 35 36 37 57 61 63 87 89 scan 0 sort 0}\ndo_test where7-2.903.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 69 AND 71) AND a!=70)\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=652\n  }\n} {69 71 91 93 scan 0 sort 0}\ndo_test where7-2.903.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 69 AND 71) AND a!=70)\n         OR ((a BETWEEN 91 AND 93) AND a!=92)\n         OR b=652\n  }\n} {69 71 91 93 scan 0 sort 0}\ndo_test where7-2.904.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1067\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=520\n         OR b=399\n         OR b=209\n         OR a=68\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n  }\n} {18 19 53 54 55 68 73 94 97 scan 0 sort 0}\ndo_test where7-2.904.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1067\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=520\n         OR b=399\n         OR b=209\n         OR a=68\n         OR (g='fedcbaz' AND f GLOB 'qrstu*')\n  }\n} {18 19 53 54 55 68 73 94 97 scan 0 sort 0}\ndo_test where7-2.905.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR a=57\n         OR b=55\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n  }\n} {2 5 20 21 22 23 34 37 57 79 scan 0 sort 0}\ndo_test where7-2.905.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR a=57\n         OR b=55\n         OR (d>=34.0 AND d<35.0 AND d NOT NULL)\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR ((a BETWEEN 0 AND 2) AND a!=1)\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n  }\n} {2 5 20 21 22 23 34 37 57 79 scan 0 sort 0}\ndo_test where7-2.906.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=2\n         OR b=784\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=850\n  }\n} {2 21 23 81 scan 0 sort 0}\ndo_test where7-2.906.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 21 AND 23) AND a!=22)\n         OR a=2\n         OR b=784\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='ihgfedc' AND f GLOB 'defgh*')\n         OR b=850\n  }\n} {2 21 23 81 scan 0 sort 0}\ndo_test where7-2.907.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=748\n         OR b=209\n         OR a=100\n  }\n} {19 45 51 68 100 scan 0 sort 0}\ndo_test where7-2.907.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=51.0 AND d<52.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=748\n         OR b=209\n         OR a=100\n  }\n} {19 45 51 68 100 scan 0 sort 0}\ndo_test where7-2.908.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR a=18\n         OR a=30\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR b=792\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR c=26026\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {8 9 10 11 18 19 21 30 33 37 63 72 76 77 78 84 86 89 scan 0 sort 0}\ndo_test where7-2.908.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'zabcd*')\n         OR a=18\n         OR a=30\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n         OR ((a BETWEEN 84 AND 86) AND a!=85)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR b=792\n         OR (f GLOB '?mnop*' AND f GLOB 'lmno*')\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR c=26026\n         OR (g='rqponml' AND f GLOB 'hijkl*')\n  }\n} {8 9 10 11 18 19 21 30 33 37 63 72 76 77 78 84 86 89 scan 0 sort 0}\ndo_test where7-2.909.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=968\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR a=78\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n  }\n} {16 22 48 63 65 72 74 78 88 90 92 100 scan 0 sort 0}\ndo_test where7-2.909.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=968\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR (d>=72.0 AND d<73.0 AND d NOT NULL)\n         OR a=78\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n  }\n} {16 22 48 63 65 72 74 78 88 90 92 100 scan 0 sort 0}\ndo_test where7-2.910.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=10010\n         OR f='pqrstuvwx'\n  }\n} {15 28 29 30 41 67 93 scan 0 sort 0}\ndo_test where7-2.910.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=10010\n         OR f='pqrstuvwx'\n  }\n} {15 28 29 30 41 67 93 scan 0 sort 0}\ndo_test where7-2.911.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=86\n         OR a=10\n         OR b=528\n         OR b=253\n         OR a=80\n         OR a=87\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n  }\n} {10 23 37 48 80 86 87 scan 0 sort 0}\ndo_test where7-2.911.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=86\n         OR a=10\n         OR b=528\n         OR b=253\n         OR a=80\n         OR a=87\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n  }\n} {10 23 37 48 80 86 87 scan 0 sort 0}\ndo_test where7-2.912.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=825\n         OR a=100\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR a=60\n  }\n} {42 60 75 77 100 scan 0 sort 0}\ndo_test where7-2.912.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR b=825\n         OR a=100\n         OR (d>=77.0 AND d<78.0 AND d NOT NULL)\n         OR a=60\n  }\n} {42 60 75 77 100 scan 0 sort 0}\ndo_test where7-2.913.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=883\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR a=81\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR f='mnopqrstu'\n  }\n} {3 4 12 30 35 38 45 56 64 78 81 82 90 94 scan 0 sort 0}\ndo_test where7-2.913.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=94.0 AND d<95.0 AND d NOT NULL)\n         OR b=883\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR (d>=3.0 AND d<4.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR a=81\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR f='mnopqrstu'\n  }\n} {3 4 12 30 35 38 45 56 64 78 81 82 90 94 scan 0 sort 0}\ndo_test where7-2.914.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=443\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=663\n         OR b=905\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=883\n         OR c=22022\n         OR b=638\n  }\n} {14 16 58 64 65 66 96 scan 0 sort 0}\ndo_test where7-2.914.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=443\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n         OR b=663\n         OR b=905\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR b=883\n         OR c=22022\n         OR b=638\n  }\n} {14 16 58 64 65 66 96 scan 0 sort 0}\ndo_test where7-2.915.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=234\n         OR a=53\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR b=319\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 20 22 27 29 40 53 84 86 scan 0 sort 0}\ndo_test where7-2.915.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 84 AND 86) AND a!=85)\n         OR b=234\n         OR a=53\n         OR ((a BETWEEN 20 AND 22) AND a!=21)\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR b=319\n         OR (g='qponmlk' AND f GLOB 'opqrs*')\n         OR ((a BETWEEN 14 AND 16) AND a!=15)\n  }\n} {14 16 20 22 27 29 40 53 84 86 scan 0 sort 0}\ndo_test where7-2.916.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=179\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR a=46\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR a=25\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=938\n  }\n} {5 13 14 25 40 46 53 55 66 72 92 95 97 scan 0 sort 0}\ndo_test where7-2.916.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=179\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR a=46\n         OR (g='kjihgfe' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 53 AND 55) AND a!=54)\n         OR a=25\n         OR (d>=5.0 AND d<6.0 AND d NOT NULL)\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=938\n  }\n} {5 13 14 25 40 46 53 55 66 72 92 95 97 scan 0 sort 0}\ndo_test where7-2.917.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n  }\n} {15 57 scan 0 sort 0}\ndo_test where7-2.917.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n  }\n} {15 57 scan 0 sort 0}\ndo_test where7-2.918.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=748\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=32\n         OR b=110\n         OR b=297\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR f='ghijklmno'\n         OR b=473\n         OR b=135\n  }\n} {6 10 13 22 27 32 43 58 60 62 68 84 scan 0 sort 0}\ndo_test where7-2.918.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=748\n         OR (g='utsrqpo' AND f GLOB 'wxyza*')\n         OR a=32\n         OR b=110\n         OR b=297\n         OR (d>=13.0 AND d<14.0 AND d NOT NULL)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR f='ghijklmno'\n         OR b=473\n         OR b=135\n  }\n} {6 10 13 22 27 32 43 58 60 62 68 84 scan 0 sort 0}\ndo_test where7-2.919.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=905\n         OR a=97\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR c=27027\n         OR f='bcdefghij'\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n  }\n} {1 4 25 27 30 33 38 40 53 54 56 79 80 81 82 85 97 scan 0 sort 0}\ndo_test where7-2.919.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=33.0 AND d<34.0 AND d NOT NULL)\n         OR b=905\n         OR a=97\n         OR (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR c=27027\n         OR f='bcdefghij'\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR (d>=25.0 AND d<26.0 AND d NOT NULL)\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n  }\n} {1 4 25 27 30 33 38 40 53 54 56 79 80 81 82 85 97 scan 0 sort 0}\ndo_test where7-2.920.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 64 AND 66) AND a!=65)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n  }\n} {64 66 90 92 scan 0 sort 0}\ndo_test where7-2.920.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 64 AND 66) AND a!=65)\n         OR ((a BETWEEN 90 AND 92) AND a!=91)\n  }\n} {64 66 90 92 scan 0 sort 0}\ndo_test where7-2.921.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=594\n         OR b=80\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=421\n         OR b=418\n         OR b=828\n         OR a=88\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {23 27 38 54 60 88 scan 0 sort 0}\ndo_test where7-2.921.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=594\n         OR b=80\n         OR (g='tsrqpon' AND f GLOB 'bcdef*')\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=421\n         OR b=418\n         OR b=828\n         OR a=88\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {23 27 38 54 60 88 scan 0 sort 0}\ndo_test where7-2.922.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=366\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR c=16016\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR c=9009\n  }\n} {17 25 26 27 28 46 47 48 75 100 scan 0 sort 0}\ndo_test where7-2.922.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'xyzab*')\n         OR b=366\n         OR (d>=28.0 AND d<29.0 AND d NOT NULL)\n         OR c=16016\n         OR (g='edcbazy' AND f GLOB 'wxyza*')\n         OR c=9009\n  }\n} {17 25 26 27 28 46 47 48 75 100 scan 0 sort 0}\ndo_test where7-2.923.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=33\n         OR f='qrstuvwxy'\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR b=858\n  }\n} {3 16 20 42 68 78 94 scan 0 sort 0}\ndo_test where7-2.923.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=33\n         OR f='qrstuvwxy'\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR b=858\n  }\n} {3 16 20 42 68 78 94 scan 0 sort 0}\ndo_test where7-2.924.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=861\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=682\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=286\n  }\n} {22 26 29 48 62 74 93 95 100 scan 0 sort 0}\ndo_test where7-2.924.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=861\n         OR (f GLOB '?xyza*' AND f GLOB 'wxyz*')\n         OR (d>=29.0 AND d<30.0 AND d NOT NULL)\n         OR b=682\n         OR ((a BETWEEN 93 AND 95) AND a!=94)\n         OR b=286\n  }\n} {22 26 29 48 62 74 93 95 100 scan 0 sort 0}\ndo_test where7-2.925.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=740\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR a=88\n  }\n} {27 29 88 scan 0 sort 0}\ndo_test where7-2.925.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=740\n         OR ((a BETWEEN 27 AND 29) AND a!=28)\n         OR a=88\n  }\n} {27 29 88 scan 0 sort 0}\ndo_test where7-2.926.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='abcdefghi'\n         OR c=9009\n         OR b=663\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR b=91\n  }\n} {10 25 26 27 52 78 scan 0 sort 0}\ndo_test where7-2.926.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='abcdefghi'\n         OR c=9009\n         OR b=663\n         OR (g='wvutsrq' AND f GLOB 'klmno*')\n         OR b=91\n  }\n} {10 25 26 27 52 78 scan 0 sort 0}\ndo_test where7-2.927.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=1015\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=916\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=69\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {13 29 31 39 42 65 68 83 91 scan 0 sort 0}\ndo_test where7-2.927.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='kjihgfe' AND f GLOB 'qrstu*')\n         OR ((a BETWEEN 29 AND 31) AND a!=30)\n         OR (f GLOB '?opqr*' AND f GLOB 'nopq*')\n         OR b=1015\n         OR (g='qponmlk' AND f GLOB 'qrstu*')\n         OR b=916\n         OR (d>=31.0 AND d<32.0 AND d NOT NULL)\n         OR b=69\n         OR (g='hgfedcb' AND f GLOB 'fghij*')\n  }\n} {13 29 31 39 42 65 68 83 91 scan 0 sort 0}\ndo_test where7-2.928.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=88\n         OR a=1\n         OR f='uvwxyzabc'\n         OR b=498\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR a=63\n         OR f='mnopqrstu'\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=495\n         OR a=35\n         OR a=22\n  }\n} {1 12 20 22 35 38 45 46 60 63 64 72 88 90 98 scan 0 sort 0}\ndo_test where7-2.928.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=88\n         OR a=1\n         OR f='uvwxyzabc'\n         OR b=498\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR a=63\n         OR f='mnopqrstu'\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR b=495\n         OR a=35\n         OR a=22\n  }\n} {1 12 20 22 35 38 45 46 60 63 64 72 88 90 98 scan 0 sort 0}\ndo_test where7-2.929.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=869\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=289\n         OR a=62\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n  }\n} {9 11 35 62 79 scan 0 sort 0}\ndo_test where7-2.929.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=869\n         OR (g='rqponml' AND f GLOB 'jklmn*')\n         OR b=289\n         OR a=62\n         OR ((a BETWEEN 9 AND 11) AND a!=10)\n  }\n} {9 11 35 62 79 scan 0 sort 0}\ndo_test where7-2.930.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=542\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR a=7\n         OR f='klmnopqrs'\n  }\n} {7 10 19 21 22 24 36 62 88 scan 0 sort 0}\ndo_test where7-2.930.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=542\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR a=7\n         OR f='klmnopqrs'\n  }\n} {7 10 19 21 22 24 36 62 88 scan 0 sort 0}\ndo_test where7-2.931.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 57 AND 59) AND a!=58)\n         OR b=1078\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=429\n  }\n} {20 21 23 39 57 59 60 98 scan 0 sort 0}\ndo_test where7-2.931.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 57 AND 59) AND a!=58)\n         OR b=1078\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (g='mlkjihg' AND f GLOB 'ijklm*')\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR b=429\n  }\n} {20 21 23 39 57 59 60 98 scan 0 sort 0}\ndo_test where7-2.932.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=264\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=1048\n         OR a=15\n  }\n} {15 24 82 85 87 scan 0 sort 0}\ndo_test where7-2.932.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR b=264\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR b=1048\n         OR a=15\n  }\n} {15 24 82 85 87 scan 0 sort 0}\ndo_test where7-2.933.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=93\n         OR f='ijklmnopq'\n         OR f='mnopqrstu'\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n  }\n} {8 12 34 38 60 64 67 69 86 90 93 scan 0 sort 0}\ndo_test where7-2.933.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=93\n         OR f='ijklmnopq'\n         OR f='mnopqrstu'\n         OR ((a BETWEEN 67 AND 69) AND a!=68)\n  }\n} {8 12 34 38 60 64 67 69 86 90 93 scan 0 sort 0}\ndo_test where7-2.934.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR b=858\n         OR a=58\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR c=21021\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n         OR b=616\n         OR b=784\n         OR b=55\n  }\n} {5 45 47 49 56 58 61 62 63 78 scan 0 sort 0}\ndo_test where7-2.934.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR b=858\n         OR a=58\n         OR (g='onmlkji' AND f GLOB 'xyzab*')\n         OR c=21021\n         OR ((a BETWEEN 45 AND 47) AND a!=46)\n         OR b=616\n         OR b=784\n         OR b=55\n  }\n} {5 45 47 49 56 58 61 62 63 78 scan 0 sort 0}\ndo_test where7-2.935.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=682\n         OR b=99\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR b=531\n  }\n} {2 9 28 54 62 80 scan 0 sort 0}\ndo_test where7-2.935.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=682\n         OR b=99\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR b=531\n  }\n} {2 9 28 54 62 80 scan 0 sort 0}\ndo_test where7-2.936.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR b=726\n         OR a=79\n         OR a=47\n         OR b=212\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR c=8008\n  }\n} {8 22 23 24 26 34 47 52 56 58 60 66 70 78 79 86 scan 0 sort 0}\ndo_test where7-2.936.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (f GLOB '?jklm*' AND f GLOB 'ijkl*')\n         OR b=726\n         OR a=79\n         OR a=47\n         OR b=212\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n         OR c=8008\n  }\n} {8 22 23 24 26 34 47 52 56 58 60 66 70 78 79 86 scan 0 sort 0}\ndo_test where7-2.937.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='uvwxyzabc'\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR a=5\n         OR b=33\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR a=59\n         OR b=44\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {3 4 5 14 20 23 46 49 59 60 62 72 75 98 scan 0 sort 0}\ndo_test where7-2.937.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='uvwxyzabc'\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR a=5\n         OR b=33\n         OR (f GLOB '?yzab*' AND f GLOB 'xyza*')\n         OR a=59\n         OR b=44\n         OR (d>=14.0 AND d<15.0 AND d NOT NULL)\n         OR (d>=59.0 AND d<60.0 AND d NOT NULL)\n  }\n} {3 4 5 14 20 23 46 49 59 60 62 72 75 98 scan 0 sort 0}\ndo_test where7-2.938.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=564\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR b=451\n         OR b=330\n         OR a=47\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {17 19 30 41 47 93 scan 0 sort 0}\ndo_test where7-2.938.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=564\n         OR (d>=93.0 AND d<94.0 AND d NOT NULL)\n         OR b=451\n         OR b=330\n         OR a=47\n         OR ((a BETWEEN 17 AND 19) AND a!=18)\n  }\n} {17 19 30 41 47 93 scan 0 sort 0}\ndo_test where7-2.939.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=40\n         OR b=333\n  }\n} {40 scan 0 sort 0}\ndo_test where7-2.939.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=40\n         OR b=333\n  }\n} {40 scan 0 sort 0}\ndo_test where7-2.940.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=924\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR a=100\n         OR c=15015\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n  }\n} {2 6 8 36 40 43 44 45 82 84 100 scan 0 sort 0}\ndo_test where7-2.940.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=924\n         OR ((a BETWEEN 6 AND 8) AND a!=7)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR a=100\n         OR c=15015\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n         OR (d>=2.0 AND d<3.0 AND d NOT NULL)\n  }\n} {2 6 8 36 40 43 44 45 82 84 100 scan 0 sort 0}\ndo_test where7-2.941.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n  }\n} {36 44 63 scan 0 sort 0}\ndo_test where7-2.941.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=63.0 AND d<64.0 AND d NOT NULL)\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n  }\n} {36 44 63 scan 0 sort 0}\ndo_test where7-2.942.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=58\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=31\n         OR f='tuvwxyzab'\n         OR b=341\n         OR b=47\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR a=49\n         OR b=223\n         OR f='qrstuvwxy'\n  }\n} {7 9 16 19 31 42 45 49 63 65 68 71 94 95 97 scan 0 sort 0}\ndo_test where7-2.942.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=58\n         OR ((a BETWEEN 7 AND 9) AND a!=8)\n         OR ((a BETWEEN 63 AND 65) AND a!=64)\n         OR a=31\n         OR f='tuvwxyzab'\n         OR b=341\n         OR b=47\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n         OR a=49\n         OR b=223\n         OR f='qrstuvwxy'\n  }\n} {7 9 16 19 31 42 45 49 63 65 68 71 94 95 97 scan 0 sort 0}\ndo_test where7-2.943.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=96\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=85\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR c=11011\n         OR b=641\n         OR f='vwxyzabcd'\n         OR b=286\n  }\n} {4 10 12 21 23 26 30 31 32 33 37 39 47 56 73 82 85 96 99 scan 0 sort 0}\ndo_test where7-2.943.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=96\n         OR (d>=23.0 AND d<24.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'vwxyz*')\n         OR (f GLOB '?fghi*' AND f GLOB 'efgh*')\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n         OR a=85\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR c=11011\n         OR b=641\n         OR f='vwxyzabcd'\n         OR b=286\n  }\n} {4 10 12 21 23 26 30 31 32 33 37 39 47 56 73 82 85 96 99 scan 0 sort 0}\ndo_test where7-2.944.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR b=1012\n         OR a=7\n         OR b=773\n         OR a=1\n         OR b=726\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=110\n  }\n} {1 3 5 7 10 66 87 89 92 99 scan 0 sort 0}\ndo_test where7-2.944.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR b=1012\n         OR a=7\n         OR b=773\n         OR a=1\n         OR b=726\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR ((a BETWEEN 87 AND 89) AND a!=88)\n         OR b=110\n  }\n} {1 3 5 7 10 66 87 89 92 99 scan 0 sort 0}\ndo_test where7-2.945.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=60\n         OR a=4\n         OR b=520\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR a=44\n         OR a=36\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=715\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n  }\n} {4 7 16 36 44 60 65 76 79 scan 0 sort 0}\ndo_test where7-2.945.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'hijkl*')\n         OR a=60\n         OR a=4\n         OR b=520\n         OR (g='ihgfedc' AND f GLOB 'bcdef*')\n         OR a=44\n         OR a=36\n         OR (d>=76.0 AND d<77.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=715\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n  }\n} {4 7 16 36 44 60 65 76 79 scan 0 sort 0}\ndo_test where7-2.946.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR a=24\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {3 5 15 24 26 52 55 56 58 76 78 99 scan 0 sort 0}\ndo_test where7-2.946.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 56 AND 58) AND a!=57)\n         OR (d>=15.0 AND d<16.0 AND d NOT NULL)\n         OR (d>=55.0 AND d<56.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'yzabc*')\n         OR a=24\n         OR (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR (f GLOB '?bcde*' AND f GLOB 'abcd*')\n  }\n} {3 5 15 24 26 52 55 56 58 76 78 99 scan 0 sort 0}\ndo_test where7-2.947.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=132\n         OR f='ghijklmno'\n         OR b=740\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=1059\n  }\n} {6 12 21 26 32 38 58 84 scan 0 sort 0}\ndo_test where7-2.947.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='utsrqpo' AND f GLOB 'vwxyz*')\n         OR b=132\n         OR f='ghijklmno'\n         OR b=740\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=1059\n  }\n} {6 12 21 26 32 38 58 84 scan 0 sort 0}\ndo_test where7-2.948.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=28\n         OR b=927\n         OR b=520\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=638\n         OR f='vwxyzabcd'\n  }\n} {21 28 47 53 58 73 99 scan 0 sort 0}\ndo_test where7-2.948.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=28\n         OR b=927\n         OR b=520\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n         OR b=638\n         OR f='vwxyzabcd'\n  }\n} {21 28 47 53 58 73 99 scan 0 sort 0}\ndo_test where7-2.949.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=1026\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR b=355\n         OR b=641\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {1 11 53 54 scan 0 sort 0}\ndo_test where7-2.949.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=1026\n         OR (d>=1.0 AND d<2.0 AND d NOT NULL)\n         OR (g='wvutsrq' AND f GLOB 'lmnop*')\n         OR b=355\n         OR b=641\n         OR (d>=53.0 AND d<54.0 AND d NOT NULL)\n  }\n} {1 11 53 54 scan 0 sort 0}\ndo_test where7-2.950.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 46 AND 48) AND a!=47)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=641\n         OR a=3\n         OR a=35\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR a=41\n         OR a=83\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=751\n  }\n} {3 14 35 40 41 46 48 54 60 62 66 81 83 92 scan 0 sort 0}\ndo_test where7-2.950.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 46 AND 48) AND a!=47)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR b=641\n         OR a=3\n         OR a=35\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR a=41\n         OR a=83\n         OR (g='nmlkjih' AND f GLOB 'cdefg*')\n         OR b=751\n  }\n} {3 14 35 40 41 46 48 54 60 62 66 81 83 92 scan 0 sort 0}\ndo_test where7-2.951.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR c=15015\n         OR b=146\n         OR b=1092\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {3 5 43 44 45 60 62 scan 0 sort 0}\ndo_test where7-2.951.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 3 AND 5) AND a!=4)\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR c=15015\n         OR b=146\n         OR b=1092\n         OR (d>=60.0 AND d<61.0 AND d NOT NULL)\n  }\n} {3 5 43 44 45 60 62 scan 0 sort 0}\ndo_test where7-2.952.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'qrstu*')\n         OR f='bcdefghij'\n         OR f='hijklmnop'\n         OR a=65\n         OR f='ijklmnopq'\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR g IS NULL\n         OR a=26\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR a=9\n         OR (d>=32.0 AND d<33.0 AND d NOT NULL)\n  }\n} {1 7 8 9 26 27 32 33 34 38 40 42 53 59 60 65 79 85 86 scan 0 sort 0}\ndo_test where7-2.952.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'qrstu*')\n         OR f='bcdefghij'\n         OR f='hijklmnop'\n         OR a=65\n         OR f='ijklmnopq'\n         OR (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR g IS NULL\n         OR a=26\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR a=9\n         OR (d>=32.0 AND d<33.0 AND d NOT NULL)\n  }\n} {1 7 8 9 26 27 32 33 34 38 40 42 53 59 60 65 79 85 86 scan 0 sort 0}\ndo_test where7-2.953.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=1100\n         OR c=6006\n         OR c=4004\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR c=33033\n  }\n} {10 11 12 16 17 18 24 26 41 70 73 79 81 97 98 99 100 scan 0 sort 0}\ndo_test where7-2.953.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='jihgfed' AND f GLOB 'vwxyz*')\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n         OR (g='kjihgfe' AND f GLOB 'stuvw*')\n         OR (g='qponmlk' AND f GLOB 'pqrst*')\n         OR b=1100\n         OR c=6006\n         OR c=4004\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR c=33033\n  }\n} {10 11 12 16 17 18 24 26 41 70 73 79 81 97 98 99 100 scan 0 sort 0}\ndo_test where7-2.954.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=17\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n  }\n} {17 95 97 scan 0 sort 0}\ndo_test where7-2.954.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=17\n         OR ((a BETWEEN 95 AND 97) AND a!=96)\n  }\n} {17 95 97 scan 0 sort 0}\ndo_test where7-2.955.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=3003\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=93\n  }\n} {7 8 9 67 93 scan 0 sort 0}\ndo_test where7-2.955.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=3003\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=93\n  }\n} {7 8 9 67 93 scan 0 sort 0}\ndo_test where7-2.956.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=737\n  }\n} {12 21 23 42 44 67 scan 0 sort 0}\ndo_test where7-2.956.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR ((a BETWEEN 21 AND 23) AND a!=22)\n         OR (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR b=737\n  }\n} {12 21 23 42 44 67 scan 0 sort 0}\ndo_test where7-2.957.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 36 scan 0 sort 0}\ndo_test where7-2.957.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='rqponml' AND f GLOB 'klmno*')\n         OR ((a BETWEEN 5 AND 7) AND a!=6)\n  }\n} {5 7 36 scan 0 sort 0}\ndo_test where7-2.958.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR c=32032\n         OR f='opqrstuvw'\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=993\n  }\n} {14 40 49 51 66 68 85 92 94 95 96 scan 0 sort 0}\ndo_test where7-2.958.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='hgfedcb' AND f GLOB 'hijkl*')\n         OR c=32032\n         OR f='opqrstuvw'\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR ((a BETWEEN 49 AND 51) AND a!=50)\n         OR b=993\n  }\n} {14 40 49 51 66 68 85 92 94 95 96 scan 0 sort 0}\ndo_test where7-2.959.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=245\n         OR b=528\n         OR b=366\n         OR a=73\n         OR a=49\n         OR b=421\n         OR a=58\n  }\n} {12 38 48 49 58 59 61 73 86 88 scan 0 sort 0}\ndo_test where7-2.959.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=12.0 AND d<13.0 AND d NOT NULL)\n         OR ((a BETWEEN 59 AND 61) AND a!=60)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR b=245\n         OR b=528\n         OR b=366\n         OR a=73\n         OR a=49\n         OR b=421\n         OR a=58\n  }\n} {12 38 48 49 58 59 61 73 86 88 scan 0 sort 0}\ndo_test where7-2.960.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR b=146\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=704\n  }\n} {8 10 20 43 60 62 64 73 75 82 86 88 100 scan 0 sort 0}\ndo_test where7-2.960.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=100.0 AND d<101.0 AND d NOT NULL)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR ((a BETWEEN 86 AND 88) AND a!=87)\n         OR b=146\n         OR (g='ponmlkj' AND f GLOB 'rstuv*')\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR ((a BETWEEN 60 AND 62) AND a!=61)\n         OR (g='ihgfedc' AND f GLOB 'efghi*')\n         OR b=704\n  }\n} {8 10 20 43 60 62 64 73 75 82 86 88 100 scan 0 sort 0}\ndo_test where7-2.961.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=14\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR a=49\n         OR b=333\n  }\n} {3 5 49 65 67 scan 0 sort 0}\ndo_test where7-2.961.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 65 AND 67) AND a!=66)\n         OR b=14\n         OR ((a BETWEEN 3 AND 5) AND a!=4)\n         OR a=49\n         OR b=333\n  }\n} {3 5 49 65 67 scan 0 sort 0}\ndo_test where7-2.962.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=17017\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=971\n         OR a=37\n         OR a=7\n         OR b=641\n         OR a=13\n         OR b=597\n  }\n} {7 13 37 38 49 50 51 scan 0 sort 0}\ndo_test where7-2.962.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=17017\n         OR (g='qponmlk' AND f GLOB 'mnopq*')\n         OR b=971\n         OR a=37\n         OR a=7\n         OR b=641\n         OR a=13\n         OR b=597\n  }\n} {7 13 37 38 49 50 51 scan 0 sort 0}\ndo_test where7-2.963.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='tuvwxyzab'\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {17 19 43 45 69 71 95 97 scan 0 sort 0}\ndo_test where7-2.963.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='tuvwxyzab'\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n  }\n} {17 19 43 45 69 71 95 97 scan 0 sort 0}\ndo_test where7-2.964.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=638\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR b=165\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='stuvwxyza'\n         OR b=652\n         OR b=66\n         OR b=770\n         OR b=91\n  }\n} {6 10 12 15 18 44 58 70 89 96 scan 0 sort 0}\ndo_test where7-2.964.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=638\n         OR (d>=44.0 AND d<45.0 AND d NOT NULL)\n         OR (g='gfedcba' AND f GLOB 'lmnop*')\n         OR b=165\n         OR ((a BETWEEN 10 AND 12) AND a!=11)\n         OR f='stuvwxyza'\n         OR b=652\n         OR b=66\n         OR b=770\n         OR b=91\n  }\n} {6 10 12 15 18 44 58 70 89 96 scan 0 sort 0}\ndo_test where7-2.965.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR a=83\n         OR a=93\n         OR b=858\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n  }\n} {14 18 40 52 66 73 78 83 92 93 scan 0 sort 0}\ndo_test where7-2.965.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=52.0 AND d<53.0 AND d NOT NULL)\n         OR f='opqrstuvw'\n         OR a=83\n         OR a=93\n         OR b=858\n         OR (d>=18.0 AND d<19.0 AND d NOT NULL)\n         OR (g='jihgfed' AND f GLOB 'vwxyz*')\n  }\n} {14 18 40 52 66 73 78 83 92 93 scan 0 sort 0}\ndo_test where7-2.966.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE c=3003\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR a=38\n  }\n} {7 8 9 38 40 42 scan 0 sort 0}\ndo_test where7-2.966.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE c=3003\n         OR ((a BETWEEN 40 AND 42) AND a!=41)\n         OR a=38\n  }\n} {7 8 9 38 40 42 scan 0 sort 0}\ndo_test where7-2.967.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n  }\n} {50 52 60 scan 0 sort 0}\ndo_test where7-2.967.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=60.0 AND d<61.0 AND d NOT NULL)\n         OR ((a BETWEEN 50 AND 52) AND a!=51)\n  }\n} {50 52 60 scan 0 sort 0}\ndo_test where7-2.968.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='qponmlk' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=5\n         OR b=396\n         OR a=13\n  }\n} {5 13 24 26 36 38 scan 0 sort 0}\ndo_test where7-2.968.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='qponmlk' AND f GLOB 'mnopq*')\n         OR ((a BETWEEN 24 AND 26) AND a!=25)\n         OR a=5\n         OR b=396\n         OR a=13\n  }\n} {5 13 24 26 36 38 scan 0 sort 0}\ndo_test where7-2.969.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=748\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR b=531\n         OR b=1092\n         OR b=418\n  }\n} {38 68 69 71 95 97 scan 0 sort 0}\ndo_test where7-2.969.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR b=748\n         OR (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR ((a BETWEEN 69 AND 71) AND a!=70)\n         OR b=531\n         OR b=1092\n         OR b=418\n  }\n} {38 68 69 71 95 97 scan 0 sort 0}\ndo_test where7-2.970.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR a=50\n         OR a=46\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n  }\n} {8 10 14 30 38 40 46 50 66 92 scan 0 sort 0}\ndo_test where7-2.970.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=30.0 AND d<31.0 AND d NOT NULL)\n         OR ((a BETWEEN 8 AND 10) AND a!=9)\n         OR (f GLOB '?pqrs*' AND f GLOB 'opqr*')\n         OR a=50\n         OR a=46\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n  }\n} {8 10 14 30 38 40 46 50 66 92 scan 0 sort 0}\ndo_test where7-2.971.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=24\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=487\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=132\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=795\n         OR b=737\n  }\n} {12 13 15 22 24 54 67 96 scan 0 sort 0}\ndo_test where7-2.971.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=24\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR b=487\n         OR (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR ((a BETWEEN 13 AND 15) AND a!=14)\n         OR b=132\n         OR (d>=54.0 AND d<55.0 AND d NOT NULL)\n         OR b=795\n         OR b=737\n  }\n} {12 13 15 22 24 54 67 96 scan 0 sort 0}\ndo_test where7-2.972.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=34\n         OR c=16016\n         OR b=1078\n         OR b=960\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n  }\n} {34 46 47 48 87 88 98 scan 0 sort 0}\ndo_test where7-2.972.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=88.0 AND d<89.0 AND d NOT NULL)\n         OR a=34\n         OR c=16016\n         OR b=1078\n         OR b=960\n         OR (g='hgfedcb' AND f GLOB 'jklmn*')\n  }\n} {34 46 47 48 87 88 98 scan 0 sort 0}\ndo_test where7-2.973.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1081\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=6\n  }\n} {6 19 21 38 45 73 75 scan 0 sort 0}\ndo_test where7-2.973.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1081\n         OR ((a BETWEEN 19 AND 21) AND a!=20)\n         OR (g='ponmlkj' AND f GLOB 'tuvwx*')\n         OR ((a BETWEEN 73 AND 75) AND a!=74)\n         OR (d>=38.0 AND d<39.0 AND d NOT NULL)\n         OR a=6\n  }\n} {6 19 21 38 45 73 75 scan 0 sort 0}\ndo_test where7-2.974.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR a=92\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR f='fghijklmn'\n         OR a=100\n         OR b=209\n         OR c=9009\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR a=73\n         OR b=902\n  }\n} {5 9 19 25 26 27 31 35 37 52 54 57 61 73 82 83 87 92 95 100 scan 0 sort 0}\ndo_test where7-2.974.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='fedcbaz' AND f GLOB 'rstuv*')\n         OR (g='rqponml' AND f GLOB 'lmnop*')\n         OR a=92\n         OR (f GLOB '?klmn*' AND f GLOB 'jklm*')\n         OR f='fghijklmn'\n         OR a=100\n         OR b=209\n         OR c=9009\n         OR ((a BETWEEN 52 AND 54) AND a!=53)\n         OR a=73\n         OR b=902\n  }\n} {5 9 19 25 26 27 31 35 37 52 54 57 61 73 82 83 87 92 95 100 scan 0 sort 0}\ndo_test where7-2.975.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=110\n         OR f='ghijklmno'\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {6 10 21 32 40 58 84 scan 0 sort 0}\ndo_test where7-2.975.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=40.0 AND d<41.0 AND d NOT NULL)\n         OR b=110\n         OR f='ghijklmno'\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n  }\n} {6 10 21 32 40 58 84 scan 0 sort 0}\ndo_test where7-2.976.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=91\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=77\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n  }\n} {1 7 15 20 27 45 46 51 53 79 scan 0 sort 0}\ndo_test where7-2.976.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 51 AND 53) AND a!=52)\n         OR (g='utsrqpo' AND f GLOB 'uvwxy*')\n         OR (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR b=91\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR b=77\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (g='vutsrqp' AND f GLOB 'pqrst*')\n  }\n} {1 7 15 20 27 45 46 51 53 79 scan 0 sort 0}\ndo_test where7-2.977.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=693\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR a=52\n         OR b=377\n  }\n} {21 26 42 52 56 63 78 scan 0 sort 0}\ndo_test where7-2.977.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=56.0 AND d<57.0 AND d NOT NULL)\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR b=693\n         OR (d>=21.0 AND d<22.0 AND d NOT NULL)\n         OR (d>=26.0 AND d<27.0 AND d NOT NULL)\n         OR (d>=42.0 AND d<43.0 AND d NOT NULL)\n         OR a=52\n         OR b=377\n  }\n} {21 26 42 52 56 63 78 scan 0 sort 0}\ndo_test where7-2.978.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=99\n         OR a=36\n         OR b=297\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=1004\n         OR b=872\n         OR a=95\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=176\n         OR b=300\n  }\n} {16 27 36 66 68 95 99 scan 0 sort 0}\ndo_test where7-2.978.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=99\n         OR a=36\n         OR b=297\n         OR ((a BETWEEN 66 AND 68) AND a!=67)\n         OR b=1004\n         OR b=872\n         OR a=95\n         OR (d>=27.0 AND d<28.0 AND d NOT NULL)\n         OR b=176\n         OR b=300\n  }\n} {16 27 36 66 68 95 99 scan 0 sort 0}\ndo_test where7-2.979.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=737\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=40\n         OR f='uvwxyzabc'\n         OR b=311\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=927\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n  }\n} {5 6 8 20 31 32 40 46 50 53 57 58 67 72 83 84 98 scan 0 sort 0}\ndo_test where7-2.979.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=737\n         OR (g='wvutsrq' AND f GLOB 'ijklm*')\n         OR (f GLOB '?ghij*' AND f GLOB 'fghi*')\n         OR a=40\n         OR f='uvwxyzabc'\n         OR b=311\n         OR (g='nmlkjih' AND f GLOB 'bcdef*')\n         OR (f GLOB '?hijk*' AND f GLOB 'ghij*')\n         OR b=927\n         OR (d>=50.0 AND d<51.0 AND d NOT NULL)\n  }\n} {5 6 8 20 31 32 40 46 50 53 57 58 67 72 83 84 98 scan 0 sort 0}\ndo_test where7-2.980.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE f='fghijklmn'\n         OR b=1078\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR f='fghijklmn'\n  }\n} {5 31 35 57 83 98 scan 0 sort 0}\ndo_test where7-2.980.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE f='fghijklmn'\n         OR b=1078\n         OR (d>=35.0 AND d<36.0 AND d NOT NULL)\n         OR f='fghijklmn'\n  }\n} {5 31 35 57 83 98 scan 0 sort 0}\ndo_test where7-2.981.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR b=487\n         OR f='tuvwxyzab'\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR b=971\n         OR c=19019\n         OR a=39\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR b=550\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=660\n  }\n} {6 12 19 38 39 45 48 50 55 56 57 60 64 71 90 97 scan 0 sort 0}\ndo_test where7-2.981.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='xwvutsr' AND f GLOB 'ghijk*')\n         OR b=487\n         OR f='tuvwxyzab'\n         OR (g='onmlkji' AND f GLOB 'wxyza*')\n         OR b=971\n         OR c=19019\n         OR a=39\n         OR (f GLOB '?nopq*' AND f GLOB 'mnop*')\n         OR b=550\n         OR (g='kjihgfe' AND f GLOB 'tuvwx*')\n         OR b=660\n  }\n} {6 12 19 38 39 45 48 50 55 56 57 60 64 71 90 97 scan 0 sort 0}\ndo_test where7-2.982.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=80\n         OR b=839\n  }\n} { scan 0 sort 0}\ndo_test where7-2.982.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=80\n         OR b=839\n  }\n} { scan 0 sort 0}\ndo_test where7-2.983.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=363\n         OR b=630\n         OR b=935\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR f='yzabcdefg'\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n  }\n} {20 24 29 33 37 39 50 76 85 scan 0 sort 0}\ndo_test where7-2.983.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=363\n         OR b=630\n         OR b=935\n         OR (d>=20.0 AND d<21.0 AND d NOT NULL)\n         OR (g='srqponm' AND f GLOB 'defgh*')\n         OR f='yzabcdefg'\n         OR ((a BETWEEN 37 AND 39) AND a!=38)\n  }\n} {20 24 29 33 37 39 50 76 85 scan 0 sort 0}\ndo_test where7-2.984.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=40\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR f='abcdefghi'\n         OR b=696\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=682\n         OR a=32\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=671\n         OR a=15\n  }\n} {15 16 26 32 34 36 40 52 61 62 78 86 97 scan 0 sort 0}\ndo_test where7-2.984.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=97.0 AND d<98.0 AND d NOT NULL)\n         OR a=40\n         OR (d>=86.0 AND d<87.0 AND d NOT NULL)\n         OR f='abcdefghi'\n         OR b=696\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=682\n         OR a=32\n         OR ((a BETWEEN 34 AND 36) AND a!=35)\n         OR b=671\n         OR a=15\n  }\n} {15 16 26 32 34 36 40 52 61 62 78 86 97 scan 0 sort 0}\ndo_test where7-2.985.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=311\n  }\n} {7 33 59 85 89 scan 0 sort 0}\ndo_test where7-2.985.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (g='gfedcba' AND f GLOB 'lmnop*')\n         OR (f GLOB '?ijkl*' AND f GLOB 'hijk*')\n         OR b=311\n  }\n} {7 33 59 85 89 scan 0 sort 0}\ndo_test where7-2.986.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR a=73\n         OR b=729\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=32\n  }\n} {32 67 73 81 96 scan 0 sort 0}\ndo_test where7-2.986.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=96.0 AND d<97.0 AND d NOT NULL)\n         OR a=73\n         OR b=729\n         OR (d>=81.0 AND d<82.0 AND d NOT NULL)\n         OR (d>=67.0 AND d<68.0 AND d NOT NULL)\n         OR a=32\n  }\n} {32 67 73 81 96 scan 0 sort 0}\ndo_test where7-2.987.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR b=110\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=484\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n  }\n} {10 23 38 40 44 82 98 100 scan 0 sort 0}\ndo_test where7-2.987.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 98 AND 100) AND a!=99)\n         OR b=110\n         OR ((a BETWEEN 38 AND 40) AND a!=39)\n         OR (g='tsrqpon' AND f GLOB 'xyzab*')\n         OR b=484\n         OR (d>=82.0 AND d<83.0 AND d NOT NULL)\n  }\n} {10 23 38 40 44 82 98 100 scan 0 sort 0}\ndo_test where7-2.988.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=135\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=209\n         OR b=363\n         OR c=27027\n         OR b=1026\n         OR c=6006\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n  }\n} {16 17 18 19 33 46 66 73 79 80 81 99 scan 0 sort 0}\ndo_test where7-2.988.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=99.0 AND d<100.0 AND d NOT NULL)\n         OR b=135\n         OR (d>=66.0 AND d<67.0 AND d NOT NULL)\n         OR b=209\n         OR b=363\n         OR c=27027\n         OR b=1026\n         OR c=6006\n         OR (g='ponmlkj' AND f GLOB 'uvwxy*')\n         OR (d>=73.0 AND d<74.0 AND d NOT NULL)\n  }\n} {16 17 18 19 33 46 66 73 79 80 81 99 scan 0 sort 0}\ndo_test where7-2.989.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR a=97\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=674\n         OR c=14014\n         OR b=69\n  }\n} {18 20 22 24 39 40 41 42 45 58 79 97 scan 0 sort 0}\ndo_test where7-2.989.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=79.0 AND d<80.0 AND d NOT NULL)\n         OR ((a BETWEEN 18 AND 20) AND a!=19)\n         OR (g='qponmlk' AND f GLOB 'nopqr*')\n         OR a=97\n         OR (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR ((a BETWEEN 22 AND 24) AND a!=23)\n         OR (g='mlkjihg' AND f GLOB 'ghijk*')\n         OR b=674\n         OR c=14014\n         OR b=69\n  }\n} {18 20 22 24 39 40 41 42 45 58 79 97 scan 0 sort 0}\ndo_test where7-2.990.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=297\n         OR a=83\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n  }\n} {16 18 27 78 83 scan 0 sort 0}\ndo_test where7-2.990.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=297\n         OR a=83\n         OR (d>=78.0 AND d<79.0 AND d NOT NULL)\n         OR ((a BETWEEN 16 AND 18) AND a!=17)\n  }\n} {16 18 27 78 83 scan 0 sort 0}\ndo_test where7-2.991.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=451\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=539\n         OR a=26\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR b=465\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {11 13 26 30 41 49 74 scan 0 sort 0}\ndo_test where7-2.991.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=451\n         OR ((a BETWEEN 11 AND 13) AND a!=12)\n         OR (g='tsrqpon' AND f GLOB 'abcde*')\n         OR b=539\n         OR a=26\n         OR (g='srqponm' AND f GLOB 'efghi*')\n         OR b=465\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n  }\n} {11 13 26 30 41 49 74 scan 0 sort 0}\ndo_test where7-2.992.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n  }\n} {45 63 scan 0 sort 0}\ndo_test where7-2.992.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (d>=45.0 AND d<46.0 AND d NOT NULL)\n         OR (d>=63.0 AND d<64.0 AND d NOT NULL)\n  }\n} {45 63 scan 0 sort 0}\ndo_test where7-2.993.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 16 AND 18) AND a!=17)\n         OR b=872\n         OR c=31031\n  }\n} {16 18 91 92 93 scan 0 sort 0}\ndo_test where7-2.993.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 16 AND 18) AND a!=17)\n         OR b=872\n         OR c=31031\n  }\n} {16 18 91 92 93 scan 0 sort 0}\ndo_test where7-2.994.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR a=13\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR b=322\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR b=377\n         OR f='cdefghijk'\n         OR b=286\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n  }\n} {1 2 13 17 26 27 28 33 35 43 53 54 61 63 69 79 80 95 scan 0 sort 0}\ndo_test where7-2.994.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE (f GLOB '?cdef*' AND f GLOB 'bcde*')\n         OR a=13\n         OR (f GLOB '?stuv*' AND f GLOB 'rstu*')\n         OR b=322\n         OR ((a BETWEEN 33 AND 35) AND a!=34)\n         OR b=377\n         OR f='cdefghijk'\n         OR b=286\n         OR ((a BETWEEN 61 AND 63) AND a!=62)\n  }\n} {1 2 13 17 26 27 28 33 35 43 53 54 61 63 69 79 80 95 scan 0 sort 0}\ndo_test where7-2.995.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=41\n         OR b=990\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR b=605\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=968\n         OR a=66\n  }\n} {16 28 36 41 55 66 88 90 scan 0 sort 0}\ndo_test where7-2.995.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=41\n         OR b=990\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR b=605\n         OR (g='srqponm' AND f GLOB 'cdefg*')\n         OR (d>=36.0 AND d<37.0 AND d NOT NULL)\n         OR (g='vutsrqp' AND f GLOB 'qrstu*')\n         OR b=968\n         OR a=66\n  }\n} {16 28 36 41 55 66 88 90 scan 0 sort 0}\ndo_test where7-2.996.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1059\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {17 19 32 37 39 41 52 57 scan 0 sort 0}\ndo_test where7-2.996.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1059\n         OR (g='srqponm' AND f GLOB 'ghijk*')\n         OR (g='utsrqpo' AND f GLOB 'tuvwx*')\n         OR (g='nmlkjih' AND f GLOB 'fghij*')\n         OR (d>=17.0 AND d<18.0 AND d NOT NULL)\n         OR (d>=37.0 AND d<38.0 AND d NOT NULL)\n         OR (g='onmlkji' AND f GLOB 'abcde*')\n         OR ((a BETWEEN 39 AND 41) AND a!=40)\n  }\n} {17 19 32 37 39 41 52 57 scan 0 sort 0}\ndo_test where7-2.997.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE ((a BETWEEN 41 AND 43) AND a!=42)\n         OR f='nopqrstuv'\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=42\n         OR b=729\n         OR b=297\n         OR a=77\n         OR b=781\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {13 27 36 38 39 41 42 43 44 65 71 77 91 scan 0 sort 0}\ndo_test where7-2.997.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE ((a BETWEEN 41 AND 43) AND a!=42)\n         OR f='nopqrstuv'\n         OR (g='ponmlkj' AND f GLOB 'stuvw*')\n         OR a=42\n         OR b=729\n         OR b=297\n         OR a=77\n         OR b=781\n         OR ((a BETWEEN 36 AND 38) AND a!=37)\n  }\n} {13 27 36 38 39 41 42 43 44 65 71 77 91 scan 0 sort 0}\ndo_test where7-2.998.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE a=12\n         OR f='qrstuvwxy'\n         OR a=47\n         OR b=135\n         OR a=25\n  }\n} {12 16 25 42 47 68 94 scan 0 sort 0}\ndo_test where7-2.998.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE a=12\n         OR f='qrstuvwxy'\n         OR a=47\n         OR b=135\n         OR a=25\n  }\n} {12 16 25 42 47 68 94 scan 0 sort 0}\ndo_test where7-2.999.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=451\n         OR b=660\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR b=781\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=198\n         OR b=1023\n         OR a=98\n         OR d<0.0\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n  }\n} {18 41 50 60 71 74 79 81 93 98 scan 0 sort 0}\ndo_test where7-2.999.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=451\n         OR b=660\n         OR (g='onmlkji' AND f GLOB 'yzabc*')\n         OR b=781\n         OR (g='jihgfed' AND f GLOB 'wxyza*')\n         OR b=198\n         OR b=1023\n         OR a=98\n         OR d<0.0\n         OR ((a BETWEEN 79 AND 81) AND a!=80)\n  }\n} {18 41 50 60 71 74 79 81 93 98 scan 0 sort 0}\ndo_test where7-2.1000.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=685\n         OR a=86\n         OR c=17017\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR a=80\n         OR b=773\n  }\n} {49 50 51 80 85 86 87 90 scan 0 sort 0}\ndo_test where7-2.1000.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=685\n         OR a=86\n         OR c=17017\n         OR ((a BETWEEN 85 AND 87) AND a!=86)\n         OR (g='gfedcba' AND f GLOB 'mnopq*')\n         OR a=80\n         OR b=773\n  }\n} {49 50 51 80 85 86 87 90 scan 0 sort 0}\ndo_test where7-2.1001.1 {\n  count_steps_sort {\n     SELECT a FROM t2\n      WHERE b=1092\n         OR a=23\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR d<0.0\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR a=91\n  }\n} {2 22 23 28 54 80 91 scan 0 sort 0}\ndo_test where7-2.1001.2 {\n  count_steps_sort {\n     SELECT a FROM t3\n      WHERE b=1092\n         OR a=23\n         OR (f GLOB '?defg*' AND f GLOB 'cdef*')\n         OR d<0.0\n         OR (d>=22.0 AND d<23.0 AND d NOT NULL)\n         OR a=91\n  }\n} {2 22 23 28 54 80 91 scan 0 sort 0}\n\n# test case for the performance regression fixed by\n# check-in 28ba6255282b on 2010-10-21 02:05:06\n#\n# The test case that follows is code from an actual\n# application with identifiers change and unused columns\n# removed.\n#\ndo_execsql_test where7-3.1 {\n  CREATE TABLE t301 (\n      c8 INTEGER PRIMARY KEY,\n      c6 INTEGER,\n      c4 INTEGER,\n      c7 INTEGER,\n      FOREIGN KEY (c4) REFERENCES series(c4)\n  );\n  CREATE INDEX t301_c6 on t301(c6);\n  CREATE INDEX t301_c4 on t301(c4);\n  CREATE INDEX t301_c7 on t301(c7);\n  \n  CREATE TABLE t302 (\n      c1 INTEGER PRIMARY KEY,\n      c8 INTEGER,\n      c5 INTEGER,\n      c3 INTEGER,\n      c2 INTEGER,\n      c4 INTEGER,\n      FOREIGN KEY (c8) REFERENCES t301(c8)\n  );\n  CREATE INDEX t302_c3 on t302(c3);\n  CREATE INDEX t302_c8_c3 on t302(c8, c3);\n  CREATE INDEX t302_c5 on t302(c5);\n  \n  EXPLAIN QUERY PLAN\n  SELECT t302.c1 \n    FROM t302 JOIN t301 ON t302.c8 = +t301.c8\n    WHERE t302.c2 = 19571\n      AND t302.c3 > 1287603136\n      AND (t301.c4 = 1407449685622784\n           OR t301.c8 = 1407424651264000)\n   ORDER BY t302.c5 LIMIT 200;\n} {\n  0 0 1 {SEARCH TABLE t301 USING COVERING INDEX t301_c4 (c4=?)} \n  0 0 1 {SEARCH TABLE t301 USING INTEGER PRIMARY KEY (rowid=?)} \n  0 1 0 {SEARCH TABLE t302 USING INDEX t302_c8_c3 (c8=? AND c3>?)} \n  0 0 0 {USE TEMP B-TREE FOR ORDER BY}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where8.test",
    "content": "# 2008 December 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# is testing of where.c. More specifically, the focus is the optimization\n# of WHERE clauses that feature the OR operator.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# Test organization:\n#\n#   where8-1.*: Tests to demonstrate simple cases work with a single table\n#               in the FROM clause.\n#\n#   where8-2.*: Tests surrounding virtual tables and the OR optimization.\n#\n#   where8-3.*: Tests with more than one table in the FROM clause.\n# \n\nproc execsql_status {sql {db db}} {\n  set result [uplevel $db eval [list $sql]]\n  concat $result [db status step] [db status sort]\n}\n\nproc execsql_status2 {sql {db db}} {\n  set ::sqlite_search_count 0\n  set result [uplevel [list execsql_status $sql $db]]\n  concat $result $::sqlite_search_count\n}\n\ndo_test where8-1.1 {\n  execsql {\n    CREATE TABLE t1(a, b TEXT, c);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n\n    INSERT INTO t1 VALUES(1,  'one',   'I');\n    INSERT INTO t1 VALUES(2,  'two',   'II');\n    INSERT INTO t1 VALUES(3,  'three', 'III');\n    INSERT INTO t1 VALUES(4,  'four',  'IV');\n    INSERT INTO t1 VALUES(5,  'five',  'V');\n    INSERT INTO t1 VALUES(6,  'six',   'VI');\n    INSERT INTO t1 VALUES(7,  'seven', 'VII');\n    INSERT INTO t1 VALUES(8,  'eight', 'VIII');\n    INSERT INTO t1 VALUES(9,  'nine',  'IX');\n    INSERT INTO t1 VALUES(10, 'ten',   'X');\n  }\n} {}\n\ndo_test where8-1.2 { \n  execsql_status2 { SELECT c FROM t1 WHERE a = 1 OR b = 'nine' }\n} {I IX 0 0 6}\n\ndo_test where8-1.3 { \n  execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b = 'two' }\n} {IX X II 0 0 6}\n\nifcapable like_match_blobs {\n  do_test where8-1.4a { \n    execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' }\n  } {IX X III II 0 0 10}\n  do_test where8-1.5a { \n    execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' }\n  } {IX X V IV 0 0 10}\n} else {\n  do_test where8-1.4b { \n    execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 't*' }\n  } {IX X III II 0 0 9}\n  do_test where8-1.5 { \n    execsql_status2 { SELECT c FROM t1 WHERE a > 8 OR b GLOB 'f*' }\n  } {IX X V IV 0 0 9}\n}\n\ndo_test where8-1.6 { \n  execsql_status { SELECT c FROM t1 WHERE a = 1 OR b = 'three' ORDER BY rowid }\n} {I III 0 1}\n\ndo_test where8-1.7 { \n  execsql_status { SELECT c FROM t1 WHERE a = 1 OR b = 'three' ORDER BY a }\n} {I III 0 1}\n\ndo_test where8-1.8 {\n  # 18 searches. 9 on the index cursor and 9 on the table cursor.\n  execsql_status2 { SELECT c FROM t1 WHERE a > 1 AND c LIKE 'I%' }\n} {II III IV IX 0 0 18}\n\ndo_test where8-1.9 {\n  execsql_status2 { SELECT c FROM t1 WHERE a >= 9 OR b <= 'eight' }\n} {IX X VIII 0 0 7}\n\ndo_test where8-1.10 {\n  execsql_status2 { \n    SELECT c FROM t1 WHERE (a >= 9 AND c != 'X') OR b <= 'eight' \n  }\n} {IX VIII 0 0 7}\n\ndo_test where8-1.11 {\n  execsql_status2 { \n    SELECT c FROM t1 WHERE (a >= 4 AND a <= 6) OR b = 'nine' \n  }\n} {IV V VI IX 0 0 10}\n\ndo_test where8-1.12.1 {\n  execsql_status2 { \n    SELECT c FROM t1 WHERE a IN(1, 2, 3) OR a = 5\n  }\n} {I II III V 0 0 14}\n\ndo_test where8-1.12.2 {\n  execsql_status2 { \n    SELECT c FROM t1 WHERE +a IN(1, 2, 3) OR +a = 5\n  }\n} {I II III V 9 0 9}\n\ndo_test where8-1.13 {\n  execsql_status2 {\n    SELECT c FROM t1\n    WHERE a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6\n    ORDER BY rowid\n  }\n} {II III IV V VI 0 1 18}\ndo_test where8-1.14 {\n  execsql_status2 {\n    SELECT c FROM t1\n    WHERE \n      a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR\n      b = 'seven' OR a = 8 OR b = 'nine' OR a = 10\n    ORDER BY rowid\n  }\n} {II III IV V VI VII VIII IX X 0 1 33}\n\ndo_test where8-1.15 {\n  execsql_status2 {\n    SELECT c FROM t1 WHERE \n      a BETWEEN 2 AND 4 OR b = 'nine'\n    ORDER BY rowid\n  }\n} {II III IV IX 0 1 12}\n\n\n#--------------------------------------------------------------------------\n# Tests where8-2.*: Virtual tables\n# \n\nif 0 {\nifcapable vtab {\n  # Register the 'echo' module used for testing virtual tables.\n  #\n  register_echo_module [sqlite3_connection_pointer db]\n\n  do_test where8-2.1 {\n    execsql {\n      CREATE VIRTUAL TABLE e1 USING echo(t1);\n      SELECT b FROM e1;\n    }\n  } {one two three four five six seven eight nine ten}\n\n  do_test where8-2.2.1 {\n    set echo_module \"\"\n    execsql {\n      SELECT c FROM e1 WHERE a=1 OR b='three';\n    }\n  } {I III}\n  do_test where8-2.2.2 {\n    set echo_module\n  } {TODO: What should this be?}\n}\n}\n\n#--------------------------------------------------------------------------\n# Tests where8-3.*: Cases with multiple tables in the FROM clause.\n# \ndo_test where8-3.1 {\n  execsql {\n    CREATE TABLE t2(d, e, f);\n    CREATE INDEX i3 ON t2(d);\n    CREATE INDEX i4 ON t2(e);\n\n    INSERT INTO t2 VALUES(1,  NULL,         'I');\n    INSERT INTO t2 VALUES(2,  'four',       'IV');\n    INSERT INTO t2 VALUES(3,  NULL,         'IX');\n    INSERT INTO t2 VALUES(4,  'sixteen',    'XVI');\n    INSERT INTO t2 VALUES(5,  NULL,         'XXV');\n    INSERT INTO t2 VALUES(6,  'thirtysix',  'XXXVI');\n    INSERT INTO t2 VALUES(7,  'fortynine',  'XLIX');\n    INSERT INTO t2 VALUES(8,  'sixtyeight', 'LXIV');\n    INSERT INTO t2 VALUES(9,  'eightyone',  'LXXXIX');\n    INSERT INTO t2 VALUES(10, NULL,         'C');\n  }\n} {}\n\ndo_test where8-3.2 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE b=e\n  }\n} {4 2 9 0}\n\ndo_test where8-3.3 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND d = 6\n  }\n} {2 6 3 6 0 0}\n\ndo_test where8-3.4 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND d = a\n  }\n} {2 2 3 3 0 0}\n\ndo_test where8-3.5 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a = 2 OR a = 3) AND (d = +a OR e = 'sixteen')\n     ORDER BY +a, +d;\n  }\n} {2 2 2 4 3 3 3 4 0 1}\n\ndo_test where8-3.6 {\n  # The first part of the WHERE clause in this query, (a=2 OR a=3) is\n  # transformed into \"a IN (2, 3)\". This is why the sort is required.\n  #\n  execsql_status {\n    SELECT a, d \n    FROM t1, t2 \n    WHERE (a = 2 OR a = 3) AND (d = +a OR e = 'sixteen')\n    ORDER BY t1.rowid\n  }\n} {2 2 2 4 3 3 3 4 0 1}\ndo_test where8-3.7 {\n  execsql_status {\n    SELECT a, d \n    FROM t1, t2 \n    WHERE a = 2 AND (d = a OR e = 'sixteen')\n    ORDER BY t1.rowid\n  }\n} {/2 2 2 4 0 [01]/}\ndo_test where8-3.8 {\n  execsql_status {\n    SELECT a, d \n    FROM t1, t2 \n    WHERE (a = 2 OR b = 'three') AND (d = a OR e = 'sixteen')\n    ORDER BY t1.rowid\n  }\n} {2 2 2 4 3 3 3 4 0 1}\n\ndo_test where8-3.9 {\n  # The \"OR c = 'IX'\" term forces a linear scan.\n  execsql_status {\n    SELECT a, d \n    FROM t1, t2 \n    WHERE (a = 2 OR b = 'three' OR c = 'IX') AND (d = a OR e = 'sixteen')\n    ORDER BY t1.rowid\n  }\n} {2 2 2 4 3 3 3 4 9 9 9 4 9 0}\n\ndo_test where8-3.10 {\n  execsql_status {\n    SELECT d FROM t2 WHERE e IS NULL OR e = 'four'\n  }\n} {1 3 5 10 2 0 0}\n\ndo_test where8-3.11 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 0 0}\ndo_test where8-3.12 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND +a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 9 0}\ndo_test where8-3.13 {\n  execsql_status {\n    SELECT a, d FROM t1, t2 WHERE (a=d OR b=e) AND +a<5\n  }\n} {1 1 2 2 3 3 4 2 4 4 9 0}\n\ndo_test where8-3.14 {\n  execsql_status {\n    SELECT c FROM t1 WHERE a > (SELECT d FROM t2 WHERE e = b) OR a = 5\n  }\n} {IV V 9 0}\n\ndo_test where8-3.15 {\n  execsql_status {\n    SELECT c FROM t1, t2 WHERE a BETWEEN 1 AND 2 OR a = (\n      SELECT sum(e IS NULL) FROM t2 AS inner WHERE t2.d>inner.d\n    )\n    ORDER BY c\n  }\n} {I I I I I I I I I I II II II II II II II II II II III III III III III 9 1}\n\n\ndo_test where8-3.21 {\n  execsql_status {\n    SELECT a, d FROM t1, (t2) WHERE (a=d OR b=e) AND a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 0 0}\ndo_test where8-3.21.1 {\n  execsql_status {\n    SELECT a, d FROM t1, ((t2)) AS t3 WHERE (a=d OR b=e) AND a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 0 0}\nif {[permutation] != \"no_optimization\"} {\ndo_test where8-3.21.2 {\n  execsql_status {\n    SELECT a, d FROM t1, ((SELECT * FROM t2)) AS t3 WHERE (a=d OR b=e) AND a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 0 0}\n}\ndo_test where8-3.22 {\n  execsql_status {\n    SELECT a, d FROM ((((((t1))), (((t2))))))\n     WHERE (a=d OR b=e) AND a<5 ORDER BY a\n  }\n} {1 1 2 2 3 3 4 2 4 4 0 0}\nif {[permutation] != \"no_optimization\"} {\ndo_test where8-3.23 {\n  execsql_status {\n    SELECT * FROM ((SELECT * FROM t2)) AS t3;\n  }\n} {1 {} I 2 four IV 3 {} IX 4 sixteen XVI 5 {} XXV 6 thirtysix XXXVI 7 fortynine XLIX 8 sixtyeight LXIV 9 eightyone LXXXIX 10 {} C 9 0}\n}\n\n#-----------------------------------------------------------------------\n# The following tests - where8-4.* - verify that adding or removing \n# indexes does not change the results returned by various queries.\n#\ndo_test where8-4.1 {\n  execsql {\n    BEGIN;\n    CREATE TABLE t3(a INTEGER, b REAL, c TEXT);\n    CREATE TABLE t4(f INTEGER, g REAL, h TEXT);\n    INSERT INTO t3 VALUES('hills', NULL, 1415926535);\n    INSERT INTO t3 VALUES('and', 'of', NULL);\n    INSERT INTO t3 VALUES('have', 'towering', 53594.08128);\n    INSERT INTO t3 VALUES(NULL, 45.64856692, 'Not');\n    INSERT INTO t3 VALUES('same', 5028841971, NULL);\n    INSERT INTO t3 VALUES('onlookers', 'in', 8214808651);\n    INSERT INTO t3 VALUES(346.0348610, 2643383279, NULL);\n    INSERT INTO t3 VALUES(1415926535, 'of', 'are');\n    INSERT INTO t3 VALUES(NULL, 0.4811174502, 'snapshots');\n    INSERT INTO t3 VALUES('over', 'the', 8628034825);\n    INSERT INTO t3 VALUES(8628034825, 66.59334461, 2847564.823);\n    INSERT INTO t3 VALUES('onlookers', 'same', 'and');\n    INSERT INTO t3 VALUES(NULL, 'light', 6939937510);\n    INSERT INTO t3 VALUES('from', 'their', 'viewed');\n    INSERT INTO t3 VALUES('from', 'Alpine', 'snapshots');\n    INSERT INTO t3 VALUES('from', 'sometimes', 'unalike');\n    INSERT INTO t3 VALUES(1339.360726, 'light', 'have');\n    INSERT INTO t3 VALUES(6939937510, 3282306647, 'other');\n    INSERT INTO t3 VALUES('paintings', 8628034825, 'all');\n    INSERT INTO t3 VALUES('paintings', NULL, 'same');\n    INSERT INTO t3 VALUES('Alpine', 378678316.5, 'unalike');\n    INSERT INTO t3 VALUES('Alpine', NULL, 'same');\n    INSERT INTO t3 VALUES(1339.360726, 2847564.823, 'over');\n    INSERT INTO t3 VALUES('villages', 'their', 'have');\n    INSERT INTO t3 VALUES('unalike', 'remarkably', 'in');\n    INSERT INTO t3 VALUES('and', 8979323846, 'and');\n    INSERT INTO t3 VALUES(NULL, 1415926535, 'an');\n    INSERT INTO t3 VALUES(271.2019091, 8628034825, 0.4811174502);\n    INSERT INTO t3 VALUES('all', 3421170679, 'the');\n    INSERT INTO t3 VALUES('Not', 'and', 1415926535);\n    INSERT INTO t3 VALUES('of', 'other', 'light');\n    INSERT INTO t3 VALUES(NULL, 'towering', 'Not');\n    INSERT INTO t3 VALUES(346.0348610, NULL, 'other');\n    INSERT INTO t3 VALUES('Not', 378678316.5, NULL);\n    INSERT INTO t3 VALUES('snapshots', 8628034825, 'of');\n    INSERT INTO t3 VALUES(3282306647, 271.2019091, 'and');\n    INSERT INTO t3 VALUES(50.58223172, 378678316.5, 5028841971);\n    INSERT INTO t3 VALUES(50.58223172, 2643383279, 'snapshots');\n    INSERT INTO t3 VALUES('writings', 8979323846, 8979323846);\n    INSERT INTO t3 VALUES('onlookers', 'his', 'in');\n    INSERT INTO t3 VALUES('unalike', 8628034825, 1339.360726);\n    INSERT INTO t3 VALUES('of', 'Alpine', 'and');\n    INSERT INTO t3 VALUES('onlookers', NULL, 'from');\n    INSERT INTO t3 VALUES('writings', 'it', 1339.360726);\n    INSERT INTO t3 VALUES('it', 'and', 'villages');\n    INSERT INTO t3 VALUES('an', 'the', 'villages');\n    INSERT INTO t3 VALUES(8214808651, 8214808651, 'same');\n    INSERT INTO t3 VALUES(346.0348610, 'light', 1415926535);\n    INSERT INTO t3 VALUES(NULL, 8979323846, 'and');\n    INSERT INTO t3 VALUES(NULL, 'same', 1339.360726);\n    INSERT INTO t4 VALUES('his', 'from', 'an');\n    INSERT INTO t4 VALUES('snapshots', 'or', NULL);\n    INSERT INTO t4 VALUES('Alpine', 'have', 'it');\n    INSERT INTO t4 VALUES('have', 'peak', 'remarkably');\n    INSERT INTO t4 VALUES('hills', NULL, 'Not');\n    INSERT INTO t4 VALUES('same', 'from', 2643383279);\n    INSERT INTO t4 VALUES('have', 'angle', 8628034825);\n    INSERT INTO t4 VALUES('sometimes', 'it', 2847564.823);\n    INSERT INTO t4 VALUES(0938446095, 'peak', 'of');\n    INSERT INTO t4 VALUES(8628034825, 'and', 'same');\n    INSERT INTO t4 VALUES('and', 271.2019091, 'their');\n    INSERT INTO t4 VALUES('the', 'of', 'remarkably');\n    INSERT INTO t4 VALUES('and', 3421170679, 1415926535);\n    INSERT INTO t4 VALUES('and', 'in', 'all');\n    INSERT INTO t4 VALUES(378678316.5, 0.4811174502, 'snapshots');\n    INSERT INTO t4 VALUES('it', 'are', 'have');\n    INSERT INTO t4 VALUES('angle', 'snapshots', 378678316.5);\n    INSERT INTO t4 VALUES('from', 1415926535, 8628034825);\n    INSERT INTO t4 VALUES('snapshots', 'angle', 'have');\n    INSERT INTO t4 VALUES(3421170679, 0938446095, 'Not');\n    INSERT INTO t4 VALUES('peak', NULL, 0.4811174502);\n    INSERT INTO t4 VALUES('same', 'have', 'Alpine');\n    INSERT INTO t4 VALUES(271.2019091, 66.59334461, 0938446095);\n    INSERT INTO t4 VALUES(8979323846, 'his', 'an');\n    INSERT INTO t4 VALUES(NULL, 'and', 3282306647);\n    INSERT INTO t4 VALUES('remarkably', NULL, 'Not');\n    INSERT INTO t4 VALUES('villages', 4543.266482, 'his');\n    INSERT INTO t4 VALUES(2643383279, 'paintings', 'onlookers');\n    INSERT INTO t4 VALUES(1339.360726, 'of', 'the');\n    INSERT INTO t4 VALUES('peak', 'other', 'peak');\n    INSERT INTO t4 VALUES('it', 'or', 8979323846);\n    INSERT INTO t4 VALUES('onlookers', 'Not', 'towering');\n    INSERT INTO t4 VALUES(NULL, 'peak', 'Not');\n    INSERT INTO t4 VALUES('of', 'have', 6939937510);\n    INSERT INTO t4 VALUES('light', 'hills', 0.4811174502);\n    INSERT INTO t4 VALUES(5028841971, 'Not', 'it');\n    INSERT INTO t4 VALUES('and', 'Not', NULL);\n    INSERT INTO t4 VALUES(346.0348610, 'villages', NULL);\n    INSERT INTO t4 VALUES(8979323846, NULL, 6939937510);\n    INSERT INTO t4 VALUES('an', 'light', 'peak');\n    INSERT INTO t4 VALUES(5028841971, 6939937510, 'light');\n    INSERT INTO t4 VALUES('sometimes', 'peak', 'peak');\n    INSERT INTO t4 VALUES(378678316.5, 5028841971, 'an');\n    INSERT INTO t4 VALUES(378678316.5, 'his', 'Alpine');\n    INSERT INTO t4 VALUES('from', 'of', 'all');\n    INSERT INTO t4 VALUES(0938446095, 'same', NULL);\n    INSERT INTO t4 VALUES(0938446095, 'Alpine', NULL);\n    INSERT INTO t4 VALUES('his', 'of', 378678316.5);\n    INSERT INTO t4 VALUES(271.2019091, 'viewed', 3282306647);\n    INSERT INTO t4 VALUES('hills', 'all', 'peak');\n    CREATE TABLE t5(s);\n    INSERT INTO t5 VALUES('tab-t5');\n    CREATE TABLE t6(t);\n    INSERT INTO t6 VALUES(123456);\n    COMMIT;\n  }\n} {}\n\ncatch {unset results}\ncatch {unset A}\ncatch {unset B}\n\nset A 2\nforeach idxsql {\n  { \n    /* No indexes */ \n  } {\n    CREATE INDEX i5 ON t3(a);\n  } {\n    CREATE INDEX i5 ON t3(a, b);\n    CREATE INDEX i6 ON t4(f);\n  } {\n    CREATE UNIQUE INDEX i5 ON t3(a, b);\n    CREATE INDEX i7 ON t3(c);\n    CREATE INDEX i6 ON t4(f);\n    CREATE INDEX i8 ON t4(h);\n  } {\n    CREATE INDEX i5 ON t3(a, b, c);\n    CREATE INDEX i6 ON t4(f, g, h);\n    CREATE INDEX i7 ON t3(c, b, a);\n    CREATE INDEX i8 ON t4(h, g, f);\n  }\n} {\n\n  execsql {\n    DROP INDEX IF EXISTS i5;\n    DROP INDEX IF EXISTS i6;\n    DROP INDEX IF EXISTS i7;\n    DROP INDEX IF EXISTS i8;\n  }\n  execsql $idxsql\n\n  foreach {B sql} {\n 1  { SELECT * FROM t3 WHERE c LIKE b }\n 2  { SELECT * FROM t3 WHERE c||'' LIKE 'the%' }\n 3  { SELECT * FROM t3 WHERE rowid LIKE '12%' }\n 4  { SELECT * FROM t3 WHERE +c LIKE 'the%' }\n 5  { SELECT * FROM t3 WHERE c LIKE 'the%' }\n 6  { SELECT * FROM t3 WHERE c GLOB '*llo' }\n\n 7  { SELECT * FROM t3 WHERE a = 'angle' }\n 8  { SELECT * FROM t3 WHERE a = 'it' OR b = 6939937510 }\n 9  { SELECT * FROM t3, t4 WHERE a = 'painting' OR a = 'are' OR a = f }\n10  { SELECT * FROM t3, t4 WHERE a = 'all' OR a = 'and' OR a = h }\n11  { SELECT * FROM t3, t4 WHERE a < 'of' OR b > 346 AND c IS NULL }\n12  { SELECT * FROM t3, t4 WHERE 'the' > a OR b > 'have' AND c = 1415926535 }\n\n13  { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a = 3421170679 }\n14  { SELECT * FROM t3 WHERE a BETWEEN 'one' AND 'two' OR a IS NULL }\n15  { SELECT * FROM t3 WHERE c > 'one' OR c >= 'one' OR c LIKE 'one%' }\n16  { SELECT * FROM t3 WHERE c > 'one' OR c = c OR c = a }\n17  { SELECT * FROM t3 WHERE c IS NULL OR a >= 'peak' }\n18  { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') OR a>1 }\n19  { SELECT * FROM t3 WHERE c IN ('other', 'all', 'snapshots') AND a>1 }\n20  { SELECT * FROM t3 WHERE c IS NULL AND a>'one' }\n21  { SELECT * FROM t3 WHERE c IS NULL OR a>'one' }\n22  { SELECT * FROM t3 WHERE b = b AND a > 'are' }\n23  { SELECT * FROM t3 WHERE c <= b OR b < 'snapshots' }\n24  { SELECT * FROM t3 WHERE 'onlookers' >= c AND a <= b OR b = 'angle' }\n25  { SELECT * FROM t3 WHERE b = 'from' }\n26  { SELECT * FROM t3 WHERE b = 4543.266482 }\n27  { SELECT * FROM t3 WHERE c < 3282306647 }\n28  { SELECT * FROM t3 WHERE c IS NULL AND b >= c }\n29  { SELECT * FROM t3 WHERE b > 0.4811174502 AND c = 'other' AND 'viewed' > a }\n30  { SELECT * FROM t3 WHERE c = 'peak' }\n31  { SELECT * FROM t3 WHERE c < 53594.08128 OR c <= b }\n32  { SELECT * FROM t3 WHERE 'writings' <= b }\n33  { SELECT * FROM t3 WHERE 2643383279 = b OR c < b AND b <= 3282306647 }\n34  { SELECT * FROM t3 WHERE a IS NULL }\n35  { SELECT * FROM t3 WHERE 'writings' = a OR b = 378678316.5 }\n36  { SELECT * FROM t3 WHERE 'and' >= c }\n37  { SELECT * FROM t3 WHERE c < 'from' }\n38  { SELECT * FROM t3 WHERE 'his' < c OR b < b }\n39  { SELECT * FROM t3 WHERE 53594.08128 = b AND c >= b }\n40  { SELECT * FROM t3 WHERE 'unalike' < c AND 'are' >= c AND a <= b }\n41  { SELECT * FROM t3 WHERE b >= 4543.266482 OR 'Alpine' > a OR 271.2019091 <= a }\n42  { SELECT * FROM t3 WHERE b = c }\n43  { SELECT * FROM t3 WHERE c > a AND b < 'all' }\n44  { SELECT * FROM t3 WHERE c BETWEEN 'hills' AND 'snapshots' AND c <= 'the' OR c = a }\n45  { SELECT * FROM t3 WHERE b > c AND c >= 'hills' }\n46  { SELECT * FROM t3 WHERE b > 'or' OR a <= 'hills' OR c IS NULL }\n47  { SELECT * FROM t3 WHERE c > b OR b BETWEEN 1339.360726 AND 'onlookers' OR 1415926535 >= b }\n48  { SELECT * FROM t3 WHERE a IS NULL }\n49  { SELECT * FROM t3 WHERE a > 'other' }\n50  { SELECT * FROM t3 WHERE 'the' <= c AND a <= c }\n51  { SELECT * FROM t3 WHERE 346.0348610 = a AND c = b }\n52  { SELECT * FROM t3 WHERE c BETWEEN 50.58223172 AND 'same' AND a < b }\n53  { SELECT * FROM t3 WHERE 'Alpine' <= b AND c >= 'angle' OR b <= 271.2019091 }\n54  { SELECT * FROM t3 WHERE a < a AND 1415926535 > b }\n55  { SELECT * FROM t3 WHERE c > a AND 'have' >= c }\n56  { SELECT * FROM t3 WHERE b <= b AND c > b }\n57  { SELECT * FROM t3 WHERE a IS NULL AND c <= c }\n58  { SELECT * FROM t3 WHERE b < c OR b = c }\n59  { SELECT * FROM t3 WHERE c < b AND b >= 'it' }\n60  { SELECT * FROM t3 WHERE a = b AND a <= b OR b >= a }\n61  { SELECT * FROM t3 WHERE b = c }\n62  { SELECT * FROM t3 WHERE c BETWEEN 'the' AND 271.2019091 OR c <= 3282306647 AND c >= b }\n63  { SELECT * FROM t3 WHERE c >= c AND c < 'writings' }\n64  { SELECT * FROM t3 WHERE c <= 3282306647 AND b > a OR 'unalike' <= a }\n65  { SELECT * FROM t3 WHERE a > c }\n66  { SELECT * FROM t3 WHERE c = 'it' OR b >= b }\n67  { SELECT * FROM t3 WHERE c = a OR b < c }\n68  { SELECT * FROM t3 WHERE b > a }\n69  { SELECT * FROM t3 WHERE a < b OR a > 4543.266482 OR 'same' = b }\n70  { SELECT * FROM t3 WHERE c < c OR b <= c OR a <= b }\n71  { SELECT * FROM t3 WHERE c > a }\n72  { SELECT * FROM t3 WHERE c > b }\n73  { SELECT * FROM t3 WHERE b <= a }\n74  { SELECT * FROM t3 WHERE 3282306647 < b AND a >= 'or' OR a >= 378678316.5 }\n75  { SELECT * FROM t3 WHERE 50.58223172 <= c OR c = c AND b < b }\n76  { SELECT * FROM t3 WHERE 'and' < b OR b < c OR c > 1339.360726 }\n77  { SELECT * FROM t3 WHERE b <= c }\n78  { SELECT * FROM t3 WHERE 'in' <= c }\n79  { SELECT * FROM t3 WHERE c <= b AND a > a AND c < b }\n80  { SELECT * FROM t3 WHERE 'over' < b }\n81  { SELECT * FROM t3 WHERE b >= b OR b < c OR a < b }\n82  { SELECT * FROM t3 WHERE 'towering' <= b OR 'towering' = a AND c > b }\n83  { SELECT * FROM t3 WHERE 'peak' = a OR b BETWEEN 2643383279 AND 'the' }\n84  { SELECT * FROM t3 WHERE 'an' < c AND c > 'the' AND c IS NULL }\n85  { SELECT * FROM t3 WHERE a <= 'sometimes' AND a BETWEEN 'unalike' AND 1339.360726 }\n86  { SELECT * FROM t3 WHERE 1339.360726 < c AND c IS NULL }\n87  { SELECT * FROM t3 WHERE b > 'the' }\n88  { SELECT * FROM t3 WHERE 'and' = a }\n89  { SELECT * FROM t3 WHERE b >= b }\n90  { SELECT * FROM t3 WHERE b >= 8979323846 }\n91  { SELECT * FROM t3 WHERE c <= a }\n92  { SELECT * FROM t3 WHERE a BETWEEN 'have' AND 'light' OR a > b OR a >= 378678316.5 }\n93  { SELECT * FROM t3 WHERE c > 3282306647 }\n94  { SELECT * FROM t3 WHERE b > c }\n95  { SELECT * FROM t3 WHERE b >= a AND 'villages' > a AND b >= c }\n96  { SELECT * FROM t3 WHERE 'angle' > a }\n97  { SELECT * FROM t3 WHERE 'paintings' >= a }\n98  { SELECT * FROM t3 WHERE 'or' >= c }\n99  { SELECT * FROM t3 WHERE c < b }\n\n\n101  { SELECT * FROM t3, t4 WHERE f < 'sometimes' OR 'over' <= g AND h < 1415926535 }\n102  { SELECT * FROM t3, t4 WHERE h >= 'from' AND h < 6939937510 OR g > h }\n103  { SELECT * FROM t3, t4 WHERE c <= h AND g = h AND c >= 'all' }\n104  { SELECT * FROM t3, t4 WHERE c = a }\n105  { SELECT * FROM t3, t4 WHERE 'of' >= h }\n106  { SELECT * FROM t3, t4 WHERE f >= b AND a < g AND h < 'and' }\n107  { SELECT * FROM t3, t4 WHERE f <= 8628034825 AND 0938446095 >= b }\n108  { SELECT * FROM t3, t4 WHERE a < 'the' }\n109  { SELECT * FROM t3, t4 WHERE f = 'sometimes' OR b < 'of' }\n110  { SELECT * FROM t3, t4 WHERE c IS NULL }\n111  { SELECT * FROM t3, t4 WHERE 'have' = b OR g <= 346.0348610 }\n112  { SELECT * FROM t3, t4 WHERE f > b AND b <= h }\n113  { SELECT * FROM t3, t4 WHERE f > c OR 'the' = a OR 50.58223172 = a }\n114  { SELECT * FROM t3, t4 WHERE 2643383279 <= a AND c = a }\n115  { SELECT * FROM t3, t4 WHERE h >= b AND 'it' <= b }\n116  { SELECT * FROM t3, t4 WHERE g BETWEEN 'from' AND 'peak' }\n117  { SELECT * FROM t3, t4 WHERE 'their' > a AND g > b AND f <= c }\n118  { SELECT * FROM t3, t4 WHERE h = 5028841971 AND 'unalike' <= f }\n119  { SELECT * FROM t3, t4 WHERE c IS NULL AND a = 3282306647 OR a <= 'Alpine' }\n120  { SELECT * FROM t3, t4 WHERE 'sometimes' <= f OR 8214808651 >= a AND b <= 53594.08128 }\n121  { SELECT * FROM t3, t4 WHERE 6939937510 <= f OR c < f OR 'sometimes' = c }\n122  { SELECT * FROM t3, t4 WHERE b < 'onlookers' AND 'paintings' = g AND c <= h }\n123  { SELECT * FROM t3, t4 WHERE a BETWEEN 'all' AND 'from' OR c > 346.0348610 }\n124  { SELECT * FROM t3, t4 WHERE 'from' <= b OR a BETWEEN 53594.08128 AND 'their' AND c > a }\n125  { SELECT * FROM t3, t4 WHERE h = 2643383279 }\n126  { SELECT * FROM t3, t4 WHERE a <= 'the' }\n127  { SELECT * FROM t3, t4 WHERE h <= c }\n128  { SELECT * FROM t3, t4 WHERE g <= 346.0348610 AND 66.59334461 >= f AND f <= f }\n129  { SELECT * FROM t3, t4 WHERE g >= c OR 'in' < b OR b > g }\n130  { SELECT * FROM t3, t4 WHERE 'over' > g AND b BETWEEN 'unalike' AND 'remarkably' }\n131  { SELECT * FROM t3, t4 WHERE h <= 2847564.823 }\n132  { SELECT * FROM t3, t4 WHERE h <= 'remarkably' AND 4543.266482 > h }\n133  { SELECT * FROM t3, t4 WHERE a >= c AND 'it' > g AND c < c }\n134  { SELECT * FROM t3, t4 WHERE h <= 66.59334461 AND b > 3421170679 }\n135  { SELECT * FROM t3, t4 WHERE h < 'are' OR f BETWEEN 0938446095 AND 'are' OR b = b }\n136  { SELECT * FROM t3, t4 WHERE h = a OR 66.59334461 <= f }\n137  { SELECT * FROM t3, t4 WHERE f > 'of' OR h <= h OR a = f }\n138  { SELECT * FROM t3, t4 WHERE 'other' >= g }\n139  { SELECT * FROM t3, t4 WHERE b <= 3421170679 }\n140  { SELECT * FROM t3, t4 WHERE 'all' = f AND 4543.266482 = b OR f BETWEEN 'and' AND 'angle' }\n141  { SELECT * FROM t3, t4 WHERE 'light' = f OR h BETWEEN 'remarkably' AND 1415926535 }\n142  { SELECT * FROM t3, t4 WHERE 'hills' = f OR 'the' >= f }\n143  { SELECT * FROM t3, t4 WHERE a > 346.0348610 }\n144  { SELECT * FROM t3, t4 WHERE 5028841971 = h }\n145  { SELECT * FROM t3, t4 WHERE b >= c AND 'the' >= g OR 45.64856692 <= g }\n146  { SELECT * FROM t3, t4 WHERE c < 5028841971 }\n147  { SELECT * FROM t3, t4 WHERE a > a }\n148  { SELECT * FROM t3, t4 WHERE c = 'snapshots' }\n149  { SELECT * FROM t3, t4 WHERE h > 1339.360726 AND 'and' > c }\n150  { SELECT * FROM t3, t4 WHERE 'and' > g OR 'sometimes' = c }\n151  { SELECT * FROM t3, t4 WHERE g >= 'the' AND b >= 'onlookers' }\n152  { SELECT * FROM t3, t4 WHERE h BETWEEN 'other' AND 2643383279 }\n153  { SELECT * FROM t3, t4 WHERE 'it' = b }\n154  { SELECT * FROM t3, t4 WHERE f = c OR c BETWEEN 'and' AND 0.4811174502 }\n155  { SELECT * FROM t3, t4 WHERE b <= 'sometimes' OR c <= 0938446095 }\n156  { SELECT * FROM t3, t4 WHERE 'and' <= b }\n157  { SELECT * FROM t3, t4 WHERE g > a AND f = 'the' AND b < a }\n158  { SELECT * FROM t3, t4 WHERE a < 'an' }\n159  { SELECT * FROM t3, t4 WHERE a BETWEEN 'his' AND 'same' OR 8628034825 > f }\n160  { SELECT * FROM t3, t4 WHERE b = 'peak' }\n161  { SELECT * FROM t3, t4 WHERE f IS NULL AND a >= h }\n162  { SELECT * FROM t3, t4 WHERE a IS NULL OR 2643383279 = c }\n163  { SELECT * FROM t3, t4 WHERE b >= 5028841971 AND f < c AND a IS NULL }\n164  { SELECT * FROM t3, t4 WHERE a >= g }\n165  { SELECT * FROM t3, t4 WHERE c IS NULL }\n166  { SELECT * FROM t3, t4 WHERE h >= h }\n167  { SELECT * FROM t3, t4 WHERE 'over' <= h }\n168  { SELECT * FROM t3, t4 WHERE b < 4543.266482 OR b = 2643383279 OR 8628034825 < b }\n169  { SELECT * FROM t3, t4 WHERE g >= 6939937510 }\n170  { SELECT * FROM t3, t4 WHERE 'or' < a OR b < g }\n171  { SELECT * FROM t3, t4 WHERE h < 'hills' OR 'and' > g }\n172  { SELECT * FROM t3, t4 WHERE 'from' > f OR f <= f }\n173  { SELECT * FROM t3, t4 WHERE 'viewed' > b AND f < c }\n174  { SELECT * FROM t3, t4 WHERE 'of' <= a }\n175  { SELECT * FROM t3, t4 WHERE f > 0938446095 }\n176  { SELECT * FROM t3, t4 WHERE a = g }\n177  { SELECT * FROM t3, t4 WHERE g >= b AND f BETWEEN 'peak' AND 'and' }\n178  { SELECT * FROM t3, t4 WHERE g = a AND 'it' > f }\n179  { SELECT * FROM t3, t4 WHERE a <= b OR 'from' > f }\n180  { SELECT * FROM t3, t4 WHERE f < 'and' }\n181  { SELECT * FROM t3, t4 WHERE 6939937510 < b OR 'sometimes' < h }\n182  { SELECT * FROM t3, t4 WHERE f > g AND f < 'peak' }\n183  { SELECT * FROM t3, t4 WHERE a <= 53594.08128 AND c <= f AND f >= c }\n184  { SELECT * FROM t3, t4 WHERE f = c OR 'it' > b OR g BETWEEN 'the' AND 'all' }\n185  { SELECT * FROM t3, t4 WHERE c <= g OR a = h }\n186  { SELECT * FROM t3, t4 WHERE 'same' = b OR c >= 2643383279 }\n187  { SELECT * FROM t3, t4 WHERE h <= g OR c > 66.59334461 OR a <= f }\n188  { SELECT * FROM t3, t4 WHERE b < c AND f = 'writings' }\n189  { SELECT * FROM t3, t4 WHERE b < a }\n190  { SELECT * FROM t3, t4 WHERE c >= f OR c = 'and' }\n191  { SELECT * FROM t3, t4 WHERE f >= 'peak' AND g > f AND h > g }\n192  { SELECT * FROM t3, t4 WHERE a >= 8979323846 AND 'same' > b OR c = 'and' }\n193  { SELECT * FROM t3, t4 WHERE c >= g OR 'writings' >= c AND b = 'all' }\n194  { SELECT * FROM t3, t4 WHERE 'remarkably' < g }\n195  { SELECT * FROM t3, t4 WHERE a BETWEEN 'or' AND 'paintings' AND g <= f }\n196  { SELECT * FROM t3, t4 WHERE 0938446095 > b OR g <= a OR h > b }\n197  { SELECT * FROM t3, t4 WHERE g = 2643383279 AND f = g }\n198  { SELECT * FROM t3, t4 WHERE g < 8979323846 }\n199  { SELECT * FROM t3, t4 WHERE 'are' <= b }\n200  { SELECT * FROM t3, t4 WHERE (a=1415926535 AND f=8628034825)\n                               OR (a=6939937510 AND f=2643383279) }\n201  { SELECT * FROM t3, t4, t5, t6\n        WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t!=5)\n           OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t=123456) }\n202  { SELECT * FROM t3, t4, t5, t6\n        WHERE (a=1415926535 AND f=8628034825 AND s!='hello' AND t==5)\n           OR (a=6939937510 AND f=2643383279 AND s='tab-t5' AND t!=123456) }\n\n  } {\n    do_test where8-4.$A.$B.1 {\n      unset -nocomplain R\n      set R [execsql $sql]\n      if {![info exists results($B)]} {\n        set results($B) $R\n      }\n      list\n    } {}\n\n    do_test where8-4.$A.$B.2 { lsort $R } [lsort $results($B)]\n  }\n  incr A\n}\ncatch {unset results}\ncatch {unset A}\ncatch {unset B}\n\n# At one point the following tests provoked an invalid write error (writing\n# to memory that had already been freed). It was not possible to demonstrate\n# that this bug could cause a query to return bad data.\n# \ndo_test where8-5.1 {\n  db close\n  sqlite3 db test.db\n  sqlite3_db_config_lookaside db 0 0 0\n  execsql {\n    CREATE TABLE tA(\n      a, b, c, d, e, f, g, h, \n      i, j, k, l, m, n, o, p\n    );\n  }\n  execsql {\n    SELECT * FROM tA WHERE\n      a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND\n      i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND n=6 AND o=7 AND\n      (p = 1 OR p = 2 OR p = 3)\n  }\n} {}\ndo_test where8-5.2 {\n  execsql {\n    SELECT * FROM tA WHERE\n      a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND\n      i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND\n      (p = 1 OR p = 2 OR p = 3) AND n=6 AND o=7\n  }\n} {}\ndo_test where8-5.3 {\n  execsql {\n    INSERT INTO tA VALUES(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8); \n    CREATE UNIQUE INDEX tAI ON tA(p);\n    CREATE TABLE tB(x);\n    INSERT INTO tB VALUES('x');\n  }\n  execsql {\n    SELECT a, x FROM tA LEFT JOIN tB ON (\n      a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND\n      i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND n=6 AND o=7 AND\n      (p = 1 OR p = 2 OR p = 3)\n    )\n  }\n} {1 {}}\n\n# The OR optimization and WITHOUT ROWID\n#\ndo_execsql_test where8-6.1 {\n  CREATE TABLE t600(a PRIMARY KEY, b) WITHOUT rowid;\n  CREATE INDEX t600b ON t600(b);\n  INSERT INTO t600 VALUES('state','screen'),('exact','dolphin'),('green','mercury');\n  SELECT a, b, '|' FROM t600 WHERE a=='state' OR b='mercury' ORDER BY +a;\n} {green mercury | state screen |}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/where9.test",
    "content": "# 2008 December 30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the multi-index OR clause optimizer.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !or_opt||!compound {\n  finish_test\n  return\n}\n\n# Evaluate SQL.  Return the result set followed by the\n# and the number of full-scan steps.\n#\nproc count_steps {sql} {\n  set r [db eval $sql]\n  lappend r scan [db status step] sort [db status sort]\n}\n\n\n# Construct test data.  \n# \ndo_test where9-1.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\n    INSERT INTO t1 VALUES(1,11,1001,1.001,100.1,'bcdefghij','yxwvuts');\n    INSERT INTO t1 VALUES(2,22,1001,2.002,100.1,'cdefghijk','yxwvuts');\n    INSERT INTO t1 VALUES(3,33,1001,3.003,100.1,'defghijkl','xwvutsr');\n    INSERT INTO t1 VALUES(4,44,2002,4.004,200.2,'efghijklm','xwvutsr');\n    INSERT INTO t1 VALUES(5,55,2002,5.005,200.2,'fghijklmn','xwvutsr');\n    INSERT INTO t1 VALUES(6,66,2002,6.006,200.2,'ghijklmno','xwvutsr');\n    INSERT INTO t1 VALUES(7,77,3003,7.007,300.3,'hijklmnop','xwvutsr');\n    INSERT INTO t1 VALUES(8,88,3003,8.008,300.3,'ijklmnopq','wvutsrq');\n    INSERT INTO t1 VALUES(9,99,3003,9.009,300.3,'jklmnopqr','wvutsrq');\n    INSERT INTO t1 VALUES(10,110,4004,10.01,400.4,'klmnopqrs','wvutsrq');\n    INSERT INTO t1 VALUES(11,121,4004,11.011,400.4,'lmnopqrst','wvutsrq');\n    INSERT INTO t1 VALUES(12,132,4004,12.012,400.4,'mnopqrstu','wvutsrq');\n    INSERT INTO t1 VALUES(13,143,5005,13.013,500.5,'nopqrstuv','vutsrqp');\n    INSERT INTO t1 VALUES(14,154,5005,14.014,500.5,'opqrstuvw','vutsrqp');\n    INSERT INTO t1 VALUES(15,165,5005,15.015,500.5,'pqrstuvwx','vutsrqp');\n    INSERT INTO t1 VALUES(16,176,6006,16.016,600.6,'qrstuvwxy','vutsrqp');\n    INSERT INTO t1 VALUES(17,187,6006,17.017,600.6,'rstuvwxyz','vutsrqp');\n    INSERT INTO t1 VALUES(18,198,6006,18.018,600.6,'stuvwxyza','utsrqpo');\n    INSERT INTO t1 VALUES(19,209,7007,19.019,700.7,'tuvwxyzab','utsrqpo');\n    INSERT INTO t1 VALUES(20,220,7007,20.02,700.7,'uvwxyzabc','utsrqpo');\n    INSERT INTO t1 VALUES(21,231,7007,21.021,700.7,'vwxyzabcd','utsrqpo');\n    INSERT INTO t1 VALUES(22,242,8008,22.022,800.8,'wxyzabcde','utsrqpo');\n    INSERT INTO t1 VALUES(23,253,8008,23.023,800.8,'xyzabcdef','tsrqpon');\n    INSERT INTO t1 VALUES(24,264,8008,24.024,800.8,'yzabcdefg','tsrqpon');\n    INSERT INTO t1 VALUES(25,275,9009,25.025,900.9,'zabcdefgh','tsrqpon');\n    INSERT INTO t1 VALUES(26,286,9009,26.026,900.9,'abcdefghi','tsrqpon');\n    INSERT INTO t1 VALUES(27,297,9009,27.027,900.9,'bcdefghij','tsrqpon');\n    INSERT INTO t1 VALUES(28,308,10010,28.028,1001.0,'cdefghijk','srqponm');\n    INSERT INTO t1 VALUES(29,319,10010,29.029,1001.0,'defghijkl','srqponm');\n    INSERT INTO t1 VALUES(30,330,10010,30.03,1001.0,'efghijklm','srqponm');\n    INSERT INTO t1 VALUES(31,341,11011,31.031,1101.1,'fghijklmn','srqponm');\n    INSERT INTO t1 VALUES(32,352,11011,32.032,1101.1,'ghijklmno','srqponm');\n    INSERT INTO t1 VALUES(33,363,11011,33.033,1101.1,'hijklmnop','rqponml');\n    INSERT INTO t1 VALUES(34,374,12012,34.034,1201.2,'ijklmnopq','rqponml');\n    INSERT INTO t1 VALUES(35,385,12012,35.035,1201.2,'jklmnopqr','rqponml');\n    INSERT INTO t1 VALUES(36,396,12012,36.036,1201.2,'klmnopqrs','rqponml');\n    INSERT INTO t1 VALUES(37,407,13013,37.037,1301.3,'lmnopqrst','rqponml');\n    INSERT INTO t1 VALUES(38,418,13013,38.038,1301.3,'mnopqrstu','qponmlk');\n    INSERT INTO t1 VALUES(39,429,13013,39.039,1301.3,'nopqrstuv','qponmlk');\n    INSERT INTO t1 VALUES(40,440,14014,40.04,1401.4,'opqrstuvw','qponmlk');\n    INSERT INTO t1 VALUES(41,451,14014,41.041,1401.4,'pqrstuvwx','qponmlk');\n    INSERT INTO t1 VALUES(42,462,14014,42.042,1401.4,'qrstuvwxy','qponmlk');\n    INSERT INTO t1 VALUES(43,473,15015,43.043,1501.5,'rstuvwxyz','ponmlkj');\n    INSERT INTO t1 VALUES(44,484,15015,44.044,1501.5,'stuvwxyza','ponmlkj');\n    INSERT INTO t1 VALUES(45,495,15015,45.045,1501.5,'tuvwxyzab','ponmlkj');\n    INSERT INTO t1 VALUES(46,506,16016,46.046,1601.6,'uvwxyzabc','ponmlkj');\n    INSERT INTO t1 VALUES(47,517,16016,47.047,1601.6,'vwxyzabcd','ponmlkj');\n    INSERT INTO t1 VALUES(48,528,16016,48.048,1601.6,'wxyzabcde','onmlkji');\n    INSERT INTO t1 VALUES(49,539,17017,49.049,1701.7,'xyzabcdef','onmlkji');\n    INSERT INTO t1 VALUES(50,550,17017,50.05,1701.7,'yzabcdefg','onmlkji');\n    INSERT INTO t1 VALUES(51,561,17017,51.051,1701.7,'zabcdefgh','onmlkji');\n    INSERT INTO t1 VALUES(52,572,18018,52.052,1801.8,'abcdefghi','onmlkji');\n    INSERT INTO t1 VALUES(53,583,18018,53.053,1801.8,'bcdefghij','nmlkjih');\n    INSERT INTO t1 VALUES(54,594,18018,54.054,1801.8,'cdefghijk','nmlkjih');\n    INSERT INTO t1 VALUES(55,605,19019,55.055,1901.9,'defghijkl','nmlkjih');\n    INSERT INTO t1 VALUES(56,616,19019,56.056,1901.9,'efghijklm','nmlkjih');\n    INSERT INTO t1 VALUES(57,627,19019,57.057,1901.9,'fghijklmn','nmlkjih');\n    INSERT INTO t1 VALUES(58,638,20020,58.058,2002.0,'ghijklmno','mlkjihg');\n    INSERT INTO t1 VALUES(59,649,20020,59.059,2002.0,'hijklmnop','mlkjihg');\n    INSERT INTO t1 VALUES(60,660,20020,60.06,2002.0,'ijklmnopq','mlkjihg');\n    INSERT INTO t1 VALUES(61,671,21021,61.061,2102.1,'jklmnopqr','mlkjihg');\n    INSERT INTO t1 VALUES(62,682,21021,62.062,2102.1,'klmnopqrs','mlkjihg');\n    INSERT INTO t1 VALUES(63,693,21021,63.063,2102.1,'lmnopqrst','lkjihgf');\n    INSERT INTO t1 VALUES(64,704,22022,64.064,2202.2,'mnopqrstu','lkjihgf');\n    INSERT INTO t1 VALUES(65,715,22022,65.065,2202.2,'nopqrstuv','lkjihgf');\n    INSERT INTO t1 VALUES(66,726,22022,66.066,2202.2,'opqrstuvw','lkjihgf');\n    INSERT INTO t1 VALUES(67,737,23023,67.067,2302.3,'pqrstuvwx','lkjihgf');\n    INSERT INTO t1 VALUES(68,748,23023,68.068,2302.3,'qrstuvwxy','kjihgfe');\n    INSERT INTO t1 VALUES(69,759,23023,69.069,2302.3,'rstuvwxyz','kjihgfe');\n    INSERT INTO t1 VALUES(70,770,24024,70.07,2402.4,'stuvwxyza','kjihgfe');\n    INSERT INTO t1 VALUES(71,781,24024,71.071,2402.4,'tuvwxyzab','kjihgfe');\n    INSERT INTO t1 VALUES(72,792,24024,72.072,2402.4,'uvwxyzabc','kjihgfe');\n    INSERT INTO t1 VALUES(73,803,25025,73.073,2502.5,'vwxyzabcd','jihgfed');\n    INSERT INTO t1 VALUES(74,814,25025,74.074,2502.5,'wxyzabcde','jihgfed');\n    INSERT INTO t1 VALUES(75,825,25025,75.075,2502.5,'xyzabcdef','jihgfed');\n    INSERT INTO t1 VALUES(76,836,26026,76.076,2602.6,'yzabcdefg','jihgfed');\n    INSERT INTO t1 VALUES(77,847,26026,77.077,2602.6,'zabcdefgh','jihgfed');\n    INSERT INTO t1 VALUES(78,858,26026,78.078,2602.6,'abcdefghi','ihgfedc');\n    INSERT INTO t1 VALUES(79,869,27027,79.079,2702.7,'bcdefghij','ihgfedc');\n    INSERT INTO t1 VALUES(80,880,27027,80.08,2702.7,'cdefghijk','ihgfedc');\n    INSERT INTO t1 VALUES(81,891,27027,81.081,2702.7,'defghijkl','ihgfedc');\n    INSERT INTO t1 VALUES(82,902,28028,82.082,2802.8,'efghijklm','ihgfedc');\n    INSERT INTO t1 VALUES(83,913,28028,83.083,2802.8,'fghijklmn','hgfedcb');\n    INSERT INTO t1 VALUES(84,924,28028,84.084,2802.8,'ghijklmno','hgfedcb');\n    INSERT INTO t1 VALUES(85,935,29029,85.085,2902.9,'hijklmnop','hgfedcb');\n    INSERT INTO t1 VALUES(86,946,29029,86.086,2902.9,'ijklmnopq','hgfedcb');\n    INSERT INTO t1 VALUES(87,957,29029,87.087,2902.9,'jklmnopqr','hgfedcb');\n    INSERT INTO t1 VALUES(88,968,30030,88.088,3003.0,'klmnopqrs','gfedcba');\n    INSERT INTO t1 VALUES(89,979,30030,89.089,3003.0,'lmnopqrst','gfedcba');\n    INSERT INTO t1 VALUES(90,NULL,30030,90.09,3003.0,'mnopqrstu','gfedcba');\n    INSERT INTO t1 VALUES(91,1001,NULL,91.091,3103.1,'nopqrstuv','gfedcba');\n    INSERT INTO t1 VALUES(92,1012,31031,NULL,3103.1,'opqrstuvw','gfedcba');\n    INSERT INTO t1 VALUES(93,1023,31031,93.093,NULL,'pqrstuvwx','fedcbaz');\n    INSERT INTO t1 VALUES(94,1034,32032,94.094,3203.2,NULL,'fedcbaz');\n    INSERT INTO t1 VALUES(95,1045,32032,95.095,3203.2,'rstuvwxyz',NULL);\n    INSERT INTO t1 VALUES(96,NULL,NULL,96.096,3203.2,'stuvwxyza','fedcbaz');\n    INSERT INTO t1 VALUES(97,1067,33033,NULL,NULL,'tuvwxyzab','fedcbaz');\n    INSERT INTO t1 VALUES(98,1078,33033,98.098,3303.3,NULL,NULL);\n    INSERT INTO t1 VALUES(99,NULL,NULL,NULL,NULL,NULL,NULL);\n    CREATE INDEX t1b ON t1(b);\n    CREATE INDEX t1c ON t1(c);\n    CREATE INDEX t1d ON t1(d);\n    CREATE INDEX t1e ON t1(e);\n    CREATE INDEX t1f ON t1(f);\n    CREATE INDEX t1g ON t1(g);\n    CREATE TABLE t2(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\n    INSERT INTO t2 SELECT * FROM t1;\n    CREATE INDEX t2b ON t2(b,c);\n    CREATE INDEX t2c ON t2(c,e);\n    CREATE INDEX t2d ON t2(d,g);\n    CREATE INDEX t2e ON t2(e,f,g);\n    CREATE INDEX t2f ON t2(f,b,d,c);\n    CREATE INDEX t2g ON t2(g,f);\n    CREATE TABLE t3(x,y);\n    INSERT INTO t3 VALUES(1,80);\n    INSERT INTO t3 VALUES(2,80);\n    CREATE TABLE t4(a INTEGER PRIMARY KEY,b,c,d,e,f,g);\n    INSERT INTO t4 SELECT * FROM t1;\n    CREATE INDEX t4b ON t4(b);\n    CREATE INDEX t4c ON t4(c);\n  }\n} {}\n\ndo_test where9-1.2.1 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b IS NULL\n        OR c IS NULL\n        OR d IS NULL\n    ORDER BY a\n  }\n} {90 91 92 96 97 99 scan 0 sort 1}\ndo_test where9-1.2.2 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE +b IS NULL\n        OR c IS NULL\n        OR d IS NULL\n    ORDER BY a\n  }\n} {90 91 92 96 97 99 scan 98 sort 0}\ndo_test where9-1.2.3 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b IS NULL\n        OR +c IS NULL\n        OR d IS NULL\n    ORDER BY a\n  }\n} {90 91 92 96 97 99 scan 98 sort 0}\ndo_test where9-1.2.4 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b IS NULL\n        OR c IS NULL\n        OR +d IS NULL\n    ORDER BY a\n  }\n} {90 91 92 96 97 99 scan 98 sort 0}\ndo_test where9-1.2.5 {\n  count_steps {\n    SELECT a FROM t4\n     WHERE b IS NULL\n        OR c IS NULL\n        OR d IS NULL\n    ORDER BY a\n  }\n} {90 91 92 96 97 99 scan 98 sort 0}\n\ndo_test where9-1.3.1 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    ORDER BY a\n  }\n} {90 91 92 97 scan 0 sort 1}\ndo_test where9-1.3.2 {\n  count_steps {\n    SELECT a FROM t4\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    ORDER BY a\n  }\n} {90 91 92 97 scan 98 sort 0}\ndo_test where9-1.3.3 {\n  count_steps {\n    SELECT a FROM t4\n     WHERE (b NOT NULL AND c NOT NULL AND d IS NULL)\n        OR (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n    ORDER BY a\n  }\n} {90 91 92 97 scan 98 sort 0}\ndo_test where9-1.3.4 {\n  count_steps {\n    SELECT a FROM (t4)\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n    ORDER BY a\n  }\n} {90 91 92 97 scan 98 sort 0}\n\ndo_test where9-1.4 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)\n    ORDER BY a\n  }\n} {87 88 89 90 91 scan 0 sort 1}\ndo_test where9-1.5 {\n  # When this test was originally written, SQLite used a rowset object \n  # to optimize the \"ORDER BY a\" clause. Now that it is using a rowhash,\n  # this is not possible. So we have to comment out one term of the OR\n  # expression in order to prevent SQLite from deeming a full-table\n  # scan to be a better strategy than using multiple indexes, which would\n  # defeat the point of the test.\n  count_steps {\n    SELECT a FROM t1\n     WHERE a=83\n        OR b=913\n        OR c=28028\n        OR (d>=82 AND d<83)\n/*      OR (e>2802 AND e<2803)  */\n        OR f='fghijklmn'\n        OR g='hgfedcb'\n    ORDER BY a\n  }\n} {5 31 57 82 83 84 85 86 87 scan 0 sort 1}\ndo_test where9-1.6 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b=1012\n        OR (d IS NULL AND e IS NOT NULL)\n  }\n} {92 scan 0 sort 0}\ndo_test where9-1.7 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE (b=1012 OR (d IS NULL AND e IS NOT NULL))\n       AND f!=g\n  }\n} {92 scan 0 sort 0}\ndo_test where9-1.8 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE (b=1012 OR (d IS NULL AND e IS NOT NULL))\n       AND f==g\n  }\n} {scan 0 sort 0}\n\ndo_test where9-2.1 {\n  count_steps {\n    SELECT t2.a FROM t1, t2\n     WHERE t1.a=80\n       AND (t1.c=t2.c OR t1.d=t2.d)\n    ORDER BY 1\n  }\n} {79 80 81 scan 0 sort 1}\ndo_test where9-2.2 {\n  count_steps {\n    SELECT t2.a FROM t1, t2\n     WHERE t1.a=80\n       AND ((t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f)\n    ORDER BY 1\n  }\n} {2 28 54 80 scan 0 sort 1}\ndo_test where9-2.3 {\n  count_steps {\n    SELECT coalesce(t2.a,9999)\n      FROM t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f\n     WHERE t1.a=80\n    ORDER BY 1\n  }\n} {2 28 54 80 scan 0 sort 1}\ndo_test where9-2.4 {\n  count_steps {\n    SELECT coalesce(t2.a,9999)\n      FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f\n     WHERE t1.a=80\n    ORDER BY 1\n  }\n} {9999 scan 0 sort 1}\ndo_test where9-2.5 {\n  count_steps {\n    SELECT t1.a, coalesce(t2.a,9999)\n      FROM t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR (t1.f)=t2.f\n     WHERE t1.a=80 OR t1.b=880 OR (t1.c=27027 AND round(t1.d)==80)\n    ORDER BY 1\n  }\n} {80 80 80 2 80 28 80 54 scan 0 sort 1}\ndo_test where9-2.6 {\n  count_steps {\n    SELECT t1.a, coalesce(t2.a,9999)\n      FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f\n     WHERE t1.a=80 OR t1.b=880 OR (t1.c=27027 AND round(t1.d)==80)\n    ORDER BY 1\n  }\n} {80 9999 scan 0 sort 1}\ndo_test where9-2.7 {\n  count_steps {\n    SELECT t3.x, t1.a, coalesce(t2.a,9999)\n      FROM t3 JOIN\n           t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f\n     WHERE t1.a=t3.y OR t1.b=t3.y*11 OR (t1.c=27027 AND round(t1.d)==80)\n    ORDER BY 1, 2\n  }\n} {1 80 9999 2 80 9999 scan 1 sort 1}\ndo_test where9-2.8 {\n  count_steps {\n    SELECT t3.x, t1.a, coalesce(t2.a,9999)\n      FROM t3 JOIN\n           t1 LEFT JOIN t2 ON (t1.c=t2.c AND t1.d=t2.d) OR (t1.f)=t2.f\n     WHERE t1.a=t3.y OR t1.b=t3.y*11 OR (t1.c=27027 AND round(t1.d)==80)\n    ORDER BY 1, 2, 3\n  }\n} {1 80 2 1 80 28 1 80 54 1 80 80 2 80 2 2 80 28 2 80 54 2 80 80 scan 1 sort 1}\n\n\nifcapable explain {\n  do_execsql_test where9-3.1 {\n    EXPLAIN QUERY PLAN\n    SELECT t2.a FROM t1, t2\n    WHERE t1.a=80 AND ((t1.c=t2.c AND t1.d=t2.d) OR t1.f=t2.f)\n  } {\n    0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)} \n    0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?)} \n    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)}\n  }\n  do_execsql_test where9-3.2 {\n    EXPLAIN QUERY PLAN\n    SELECT coalesce(t2.a,9999)\n    FROM t1 LEFT JOIN t2 ON (t1.c+1=t2.c AND t1.d=t2.d) OR (t1.f||'x')=t2.f\n    WHERE t1.a=80\n  } {\n    0 0 0 {SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)} \n    0 1 1 {SEARCH TABLE t2 USING INDEX t2d (d=?)} \n    0 1 1 {SEARCH TABLE t2 USING COVERING INDEX t2f (f=?)}\n  }\n} \n\n# Make sure that INDEXED BY and multi-index OR clauses play well with\n# one another.\n#\ndo_test where9-4.1 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {92 93 97 scan 0 sort 1}\ndo_test where9-4.2 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE b>1000\n       AND (c=31031 OR +d IS NULL)\n     ORDER BY +a\n  }\n} {92 93 97 scan 0 sort 1}\ndo_test where9-4.3 {\n  count_steps {\n    SELECT a FROM t1\n     WHERE +b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {92 93 97 scan 0 sort 1}\ndo_test where9-4.4 {\n  count_steps {\n    SELECT a FROM t1 INDEXED BY t1b\n     WHERE b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {92 93 97 scan 0 sort 1}\ndo_test where9-4.5 {\n  catchsql {\n    SELECT a FROM t1 INDEXED BY t1b\n     WHERE +b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {1 {no query solution}}\ndo_test where9-4.6 {\n  count_steps {\n    SELECT a FROM t1 NOT INDEXED\n     WHERE b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {92 93 97 scan 98 sort 1}\ndo_test where9-4.7 {\n  catchsql {\n    SELECT a FROM t1 INDEXED BY t1c\n     WHERE b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {1 {no query solution}}\ndo_test where9-4.8 {\n  catchsql {\n    SELECT a FROM t1 INDEXED BY t1d\n     WHERE b>1000\n       AND (c=31031 OR d IS NULL)\n     ORDER BY +a\n  }\n} {1 {no query solution}}\n\nifcapable explain {\n  # The (c=31031 OR d IS NULL) clause is preferred over b>1000 because\n  # the former is an equality test which is expected to return fewer rows.\n  #\n  do_execsql_test where9-5.1 {\n    EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c=31031 OR d IS NULL)\n  } {\n    0 0 0 {SEARCH TABLE t1 USING INDEX t1c (c=?)} \n    0 0 0 {SEARCH TABLE t1 USING INDEX t1d (d=?)}\n  }\n\n  # In contrast, b=1000 is preferred over any OR-clause.\n  #\n  do_execsql_test where9-5.2 {\n    EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b=1000 AND (c=31031 OR d IS NULL)\n  } {\n    0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b=?)}\n  }\n\n  # Likewise, inequalities in an AND are preferred over inequalities in\n  # an OR.\n  #\n  do_execsql_test where9-5.3 {\n    EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)\n  } {\n    0 0 0 {SEARCH TABLE t1 USING INDEX t1b (b>?)}\n  }\n}\n\n############################################################################\n# Make sure OR-clauses work correctly on UPDATE and DELETE statements.\n\ndo_test where9-6.2.1 {\n  db eval {SELECT count(*) FROM t1 UNION ALL SELECT a FROM t1 WHERE a>=85}\n} {99 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99}\n\ndo_test where9-6.2.2 {   ;# Deletes entries 90 91 92 96 97 99\n  count_steps {\n     BEGIN;\n     DELETE FROM t1\n     WHERE b IS NULL\n        OR c IS NULL\n        OR d IS NULL\n  }\n} {scan 0 sort 0}\n\ndo_test where9-6.2.3 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a>=85;\n    ROLLBACK;\n  }\n} {93 85 86 87 88 89 93 94 95 98}\n\ndo_test where9-6.2.4 {   ;# Deletes entries 90 91 92 96 97 99\n  count_steps {\n     BEGIN;\n     DELETE FROM t1\n     WHERE +b IS NULL\n        OR c IS NULL\n        OR d IS NULL\n  }\n} {scan 98 sort 0}\n\ndo_test where9-6.2.5 {\n  db eval {\n     SELECT count(*) FROM t1 UNION ALL\n     SELECT a FROM t1 WHERE a>=85;\n     ROLLBACK;\n  }\n} {93 85 86 87 88 89 93 94 95 98}\n\ndo_test where9-6.2.6 {\n  count_steps {\n     BEGIN;\n     UPDATE t1 SET a=a+100\n     WHERE (b IS NULL\n            OR c IS NULL\n            OR d IS NULL)\n       AND a!=92\n       AND a!=97\n  }\n} {scan 0 sort 0}   ;# Add 100 to entries 90 91 96 99\n\ndo_test where9-6.2.7 {\n  db eval {\n     SELECT count(*) FROM t1 UNION ALL\n     SELECT a FROM t1 WHERE a>=85;\n     ROLLBACK\n  }\n} {99 85 86 87 88 89 92 93 94 95 97 98 190 191 196 199}\n\ndo_test where9-6.2.8 {   ;# Deletes entries 90 91 92 97 99\n  count_steps {\n     BEGIN;\n     DELETE FROM t1\n     WHERE (b IS NULL\n            OR c IS NULL\n            OR d IS NULL)\n       AND a!=96\n  }\n} {scan 0 sort 0}\n\ndo_test where9-6.2.9 {\n  db eval {\n     SELECT count(*) FROM t1 UNION ALL SELECT a FROM t1 WHERE a>=85;\n     ROLLBACK;\n  }\n} {94 85 86 87 88 89 93 94 95 96 98}\n\ndo_test where9-6.3.1 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 0 sort 0}   ;# DELETEs rows 90 91 92 97\ndo_test where9-6.3.2 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {95 85 86 87 88 89 93 94 95 96 98 99}\n\ndo_test where9-6.3.3 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 SET a=a+100\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 0 sort 0}   ;# Add 100 to rowids 90 91 92 97\ndo_test where9-6.3.4 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;\n    ROLLBACK;\n  }\n} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}\n\ndo_test where9-6.3.5 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1\n     WHERE (+b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# DELETEs rows 90 91 92 97\ndo_test where9-6.3.6 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {95 85 86 87 88 89 93 94 95 96 98 99}\n\ndo_test where9-6.3.7 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 SET a=a+100\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND +c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# Add 100 to rowids 90 91 92 97\ndo_test where9-6.3.8 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {99 85 86 87 88 89 93 94 95 96 98 99}\n\n\ndo_test where9-6.4.1 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1\n     WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)\n  }\n} {scan 0 sort 0}  ;# DELETE rows 87 88 89 90 91\ndo_test where9-6.4.2 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {94 85 86 92 93 94 95 96 97 98 99}\ndo_test where9-6.4.3 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 SET a=a+100\n     WHERE (b>=950 AND b<=1010) OR (b IS NULL AND c NOT NULL)\n  }\n} {scan 0 sort 0}  ;# Add 100 to rowids 87 88 89 90 91\ndo_test where9-6.4.4 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {99 85 86 92 93 94 95 96 97 98 99}\n\n\ndo_test where9-6.5.1 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1\n     WHERE a=83\n        OR b=913\n        OR c=28028\n        OR (d>=82 AND d<83)\n        OR (e>2802 AND e<2803) \n        OR f='fghijklmn'\n        OR g='hgfedcb'\n  }\n} {scan 0 sort 0}   ;#  DELETE rows 5 31 57 82 83 84 85 86 87\ndo_test where9-6.5.2 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a IN (5,31,57,82,83,84,85,86,87);\n    ROLLBACK;\n  }\n} {90}\n\ndo_test where9-6.5.3 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 SET a=a+100\n     WHERE a=83\n        OR b=913\n        OR c=28028\n        OR (d>=82 AND d<83)\n        OR (e>2802 AND e<2803) \n        OR f='fghijklmn'\n        OR g='hgfedcb'\n  }\n} {scan 0 sort 0}   ;#  Add 100 to rowids 5 31 57 82 83 84 85 86 87\ndo_test where9-6.5.4 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a%100 IN (5,31,57,82,83,84,85,86,87) ORDER BY rowid;\n    ROLLBACK;\n  }\n} {99 105 131 157 182 183 184 185 186 187}\n\ndo_test where9-6.6.1 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND +c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# DELETEs rows 90 91 92 97\ndo_test where9-6.6.2 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {95 85 86 87 88 89 93 94 95 96 98 99}\n\ndo_test where9-6.6.3 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 SET a=a+100\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND +c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# Add 100 to rowids 90 91 92 97\ndo_test where9-6.6.4 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;\n    ROLLBACK;\n  }\n} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}\n\ndo_test where9-6.7.1 {\n  count_steps {\n    BEGIN;\n    DELETE FROM t1 NOT INDEXED\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# DELETEs rows 90 91 92 97\ndo_test where9-6.7.2 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 100;\n    ROLLBACK;\n  }\n} {95 85 86 87 88 89 93 94 95 96 98 99}\n\ndo_test where9-6.7.3 {\n  count_steps {\n    BEGIN;\n    UPDATE t1 NOT INDEXED SET a=a+100\n     WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {scan 98 sort 0}   ;# Add 100 to rowids 90 91 92 97\ndo_test where9-6.7.4 {\n  db eval {\n    SELECT count(*) FROM t1 UNION ALL\n    SELECT a FROM t1 WHERE a BETWEEN 85 AND 200;\n    ROLLBACK;\n  }\n} {99 85 86 87 88 89 93 94 95 96 98 99 190 191 192 197}\n\ndo_test where9-6.8.1 {\n  catchsql {\n    DELETE FROM t1 INDEXED BY t1b\n     WHERE (+b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {1 {no query solution}}\ndo_test where9-6.8.2 {\n  catchsql {\n    UPDATE t1 INDEXED BY t1b SET a=a+100\n     WHERE (+b IS NULL AND c NOT NULL AND d NOT NULL)\n        OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n        OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n  }\n} {1 {no query solution}}\n\nset solution_possible 0\nifcapable stat4||stat3 {\n  if {[permutation] != \"no_optimization\"} { set solution_possible 1 }\n}\nif $solution_possible {\n  # When STAT3 is enabled, the \"b NOT NULL\" terms get translated\n  # into b>NULL, which can be satified by the index t1b.  It is a very\n  # expensive way to do the query, but it works, and so a solution is possible.\n  do_test where9-6.8.3-stat4 {\n    catchsql {\n      UPDATE t1 INDEXED BY t1b SET a=a+100\n       WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n          OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n          OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    }\n  } {0 {}}\n  do_test where9-6.8.4-stat4 {\n    catchsql {\n      DELETE FROM t1 INDEXED BY t1b\n       WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n          OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n          OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    }\n  } {0 {}}\n} else {\n  do_test where9-6.8.3 {\n    catchsql {\n      UPDATE t1 INDEXED BY t1b SET a=a+100\n       WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n          OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n          OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    }\n  } {1 {no query solution}}\n  do_test where9-6.8.4 {\n    catchsql {\n      DELETE FROM t1 INDEXED BY t1b\n       WHERE (b IS NULL AND c NOT NULL AND d NOT NULL)\n          OR (b NOT NULL AND c IS NULL AND d NOT NULL)\n          OR (b NOT NULL AND c NOT NULL AND d IS NULL)\n    }\n  } {1 {no query solution}}\n}\n############################################################################\n# Test cases where terms inside an OR series are combined with AND terms\n# external to the OR clause.  In other words, cases where\n#\n#              x AND (y OR z)\n#\n# is able to use indices on x,y and x,z, or indices y,x and z,x.\n#\ndo_test where9-7.0 {\n  execsql {\n    CREATE TABLE t5(a, b, c, d, e, f, g, x, y);\n    INSERT INTO t5\n     SELECT a, b, c, e, d, f, g,\n            CASE WHEN (a&1)!=0 THEN 'y' ELSE 'n' END,\n            CASE WHEN (a&2)!=0 THEN 'y' ELSE 'n' END\n       FROM t1;\n    CREATE INDEX t5xb ON t5(x, b);\n    CREATE INDEX t5xc ON t5(x, c);\n    CREATE INDEX t5xd ON t5(x, d);\n    CREATE INDEX t5xe ON t5(x, e);\n    CREATE INDEX t5xf ON t5(x, f);\n    CREATE INDEX t5xg ON t5(x, g);\n    CREATE INDEX t5yb ON t5(y, b);\n    CREATE INDEX t5yc ON t5(y, c);\n    CREATE INDEX t5yd ON t5(y, d);\n    CREATE INDEX t5ye ON t5(y, e);\n    CREATE INDEX t5yf ON t5(y, f);\n    CREATE INDEX t5yg ON t5(y, g);\n    CREATE TABLE t6(a, b, c, e, d, f, g, x, y);\n    INSERT INTO t6 SELECT * FROM t5;\n    ANALYZE t5;\n  }\n  ifcapable stat3 {\n    sqlite3 db2 test.db\n    db2 eval { DROP TABLE IF EXISTS sqlite_stat3 }\n    db2 close\n  }\n} {}\ndo_test where9-7.1.1 {\n  count_steps {\n    SELECT a FROM t5 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;\n  }\n} {79 81 83 scan 0 sort 1}\ndo_test where9-7.1.2 {\n  execsql {\n    SELECT a FROM t6 WHERE x='y' AND (b=913 OR c=27027) ORDER BY a;\n  }\n} {79 81 83}\ndo_test where9-7.1.3 {\n  count_steps {\n    SELECT a FROM t5 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;\n  }\n} {80 scan 0 sort 1}\ndo_test where9-7.1.4 {\n  execsql {\n    SELECT a FROM t6 WHERE x='n' AND (b=913 OR c=27027) ORDER BY a;\n  }\n} {80}\ndo_test where9-7.2.1 {\n  count_steps {\n    SELECT a FROM t5 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;\n  }\n} {83 scan 0 sort 1}\ndo_test where9-7.2.2 {\n  execsql {\n    SELECT a FROM t6 WHERE (x='y' OR y='y') AND b=913 ORDER BY a;\n  }\n} {83}\ndo_test where9-7.3.1 {\n  count_steps {\n    SELECT a FROM t5 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;\n  }\n} {79 81 scan 0 sort 1}\ndo_test where9-7.3.2 {\n  execsql {\n    SELECT a FROM t6 WHERE (x='y' OR y='y') AND c=27027 ORDER BY a;\n  }\n} {79 81}\n\n# Fix for ticket [b7c8682cc17f32903f03a610bd0d35ffd3c1e6e4]\n# \"Incorrect result from LEFT JOIN with OR in the WHERE clause\"\n#\ndo_test where9-8.1 {\n  db eval {\n    CREATE TABLE t81(a INTEGER PRIMARY KEY, b, c, d);\n    CREATE TABLE t82(x INTEGER PRIMARY KEY, y);\n    CREATE TABLE t83(p INTEGER PRIMARY KEY, q);\n    \n    INSERT INTO t81 VALUES(2,3,4,5);\n    INSERT INTO t81 VALUES(3,4,5,6);\n    INSERT INTO t82 VALUES(2,4);\n    INSERT INTO t83 VALUES(5,55);\n    \n    SELECT *\n      FROM t81 LEFT JOIN t82 ON y=b JOIN t83\n     WHERE c==p OR d==p\n     ORDER BY +a;\n  }\n} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}\ndo_test where9-8.2 {\n  db eval {\n    SELECT *\n      FROM t81 LEFT JOIN (t82) ON y=b JOIN t83\n     WHERE c==p OR d==p\n     ORDER BY +a;\n  }\n} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}\ndo_test where9-8.3 {\n  db eval {\n    SELECT *\n      FROM (t81) LEFT JOIN (main.t82) ON y=b JOIN t83\n     WHERE c==p OR d==p\n     ORDER BY +a;\n  }\n} {2 3 4 5 {} {} 5 55 3 4 5 6 2 4 5 55}\n\n# Fix for ticket [f2369304e47167e3e644e2f1fe9736063391d7b7]\n# Incorrect results when OR is used in the ON clause of a LEFT JOIN \n#\ndo_test where9-9.1 {\n  db eval {\n    CREATE TABLE t91(x); INSERT INTO t91 VALUES(1);\n    CREATE TABLE t92(y INTEGER PRIMARY KEY,a,b);\n    INSERT INTO t92 VALUES(1,2,3);\n    SELECT 1 FROM t91 LEFT JOIN t92 ON a=2 OR b=3;\n    SELECT 2 FROM t91 LEFT JOIN t92 ON a=2 AND b=3;\n    SELECT 3 FROM t91 LEFT JOIN t92 ON (a=2 OR b=3) AND y IS NULL;\n    SELECT 4 FROM t91 LEFT JOIN t92 ON (a=2 AND b=3) AND y IS NULL;\n    CREATE TEMP TABLE x9 AS SELECT * FROM t91 LEFT JOIN t92 ON a=2 OR b=3;\n    SELECT 5 FROM x9 WHERE y IS NULL;\n    SELECT 6 FROM t91 LEFT JOIN t92 ON a=2 OR b=3 WHERE y IS NULL;\n    SELECT 7 FROM t91 LEFT JOIN t92 ON a=2 AND b=3 WHERE y IS NULL;\n    SELECT 8 FROM t91 LEFT JOIN t92 ON a=22 OR b=33 WHERE y IS NULL;\n    SELECT 9 FROM t91 LEFT JOIN t92 ON a=22 AND b=33 WHERE y IS NULL;\n  }\n} {1 2 3 4 8 9}\n\n# Fix for ticket [bc878246eafe0f52c519e29049b2fe4a99491b27]\n# Incorrect result when OR is used in a join to the right of a LEFT JOIN\n#\ndo_test where9-10.1 {\n  db eval {\n    CREATE TABLE t101 (id INTEGER PRIMARY KEY);\n    INSERT INTO t101 VALUES (1);\n    SELECT * FROM t101 AS t0\n         LEFT JOIN t101 AS t1 ON t1.id BETWEEN 10 AND 20\n         JOIN t101 AS t2 ON (t2.id = t0.id OR (t2.id<>555 AND t2.id=t1.id));\n  }\n} {1 {} 1}\ndo_test where9-10.2 {\n  db eval {\n    CREATE TABLE t102 (id TEXT UNIQUE NOT NULL);\n    INSERT INTO t102 VALUES ('1');\n    SELECT * FROM t102 AS t0\n         LEFT JOIN t102 AS t1 ON t1.id GLOB 'abc%'\n         JOIN t102 AS t2 ON (t2.id = t0.id OR (t2.id<>555 AND t2.id=t1.id));\n  }\n} {1 {} 1}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereA.test",
    "content": "# 2009 February 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus of this file is testing the reverse_select_order pragma.\n#\n# $Id: whereA.test,v 1.3 2009/06/10 19:33:29 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_test whereA-1.1 {\n  db eval {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b UNIQUE, c);\n    INSERT INTO t1 VALUES(1,2,3);\n    INSERT INTO t1 values(2,'hello','world');\n    INSERT INTO t1 VALUES(3,4.53,NULL);\n    SELECT * FROM t1\n  }\n} {1 2 3 2 hello world 3 4.53 {}}\ndo_test whereA-1.2 {\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1;\n  }\n} {3 4.53 {} 2 hello world 1 2 3}\n\ndo_test whereA-1.3 {\n  db close\n  sqlite3 db test.db\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1;\n  }\n} {3 4.53 {} 2 hello world 1 2 3}\ndo_test whereA-1.4 {\n  db close\n  sqlite3 db test.db\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1 ORDER BY rowid;\n  }\n} {1 2 3 2 hello world 3 4.53 {}}\ndo_test whereA-1.5 {\n  db eval {\n    VACUUM;\n    SELECT * FROM t1 ORDER BY rowid;\n  }\n} {1 2 3 2 hello world 3 4.53 {}}\ndo_test whereA-1.6 {\n  db eval {\n    PRAGMA reverse_unordered_selects;\n  }\n} {1}\ndo_test whereA-1.7 {\n  db close\n  sqlite3 db test.db\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    VACUUM;\n    SELECT * FROM t1;\n  }\n} {3 4.53 {} 2 hello world 1 2 3}\ndo_execsql_test whereA-1.8 {\n  SELECT * FROM t1 WHERE b=2 AND a IS NULL;\n} {}\ndo_execsql_test whereA-1.9 {\n  SELECT * FROM t1 WHERE b=2 AND a IS NOT NULL;\n} {1 2 3}\n\ndo_test whereA-2.1 {\n  db eval {\n    PRAGMA reverse_unordered_selects=0;\n    SELECT * FROM t1 WHERE a>0;\n  }\n} {1 2 3 2 hello world 3 4.53 {}}\ndo_test whereA-2.2 {\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1 WHERE a>0;\n  }\n} {3 4.53 {} 2 hello world 1 2 3}\n\ndo_test whereA-2.3 {\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1 WHERE a>0 ORDER BY rowid;\n  }\n} {1 2 3 2 hello world 3 4.53 {}}\n\ndo_test whereA-3.1 {\n  db eval {\n    PRAGMA reverse_unordered_selects=0;\n    SELECT * FROM t1 WHERE b>0;\n  }\n} {1 2 3 3 4.53 {} 2 hello world}\ndo_test whereA-3.2 {\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1 WHERE b>0;\n  }\n} {2 hello world 3 4.53 {} 1 2 3}\ndo_test whereA-3.3 {\n  db eval {\n    PRAGMA reverse_unordered_selects=1;\n    SELECT * FROM t1 WHERE b>0 ORDER BY b;\n  }\n} {1 2 3 3 4.53 {} 2 hello world}\n\ndo_test whereA-4.1 {\n  db eval {\n    CREATE TABLE t2(x);\n    INSERT INTO t2 VALUES(1);\n    INSERT INTO t2 VALUES(2);\n    SELECT x FROM t2;\n  }\n} {2 1}\n# Do an SQL statement.  Append the search count to the end of the result.\n#\nproc count sql {\n  set ::sqlite_sort_count 0\n  return [concat [execsql $sql] $::sqlite_sort_count]\n}\ndo_test whereA-4.2 {   ;# Ticket #3904\n  db eval {\n    CREATE INDEX t2x ON t2(x);\n  }\n  count {\n    SELECT x FROM t2;\n  }\n} {2 1 0}\ndo_test whereA-4.3 {\n  count {\n    SELECT x FROM t2 ORDER BY x;\n  }\n} {1 2 0}\ndo_test whereA-4.4 {\n  count {\n    SELECT x FROM t2 ORDER BY x DESC;\n  }\n} {2 1 0}\ndo_test whereA-4.5 {\n  db eval {DROP INDEX t2x;}\n  count {\n    SELECT x FROM t2 ORDER BY x;\n  }\n} {1 2 1}\ndo_test whereA-4.6 {\n  count {\n    SELECT x FROM t2 ORDER BY x DESC;\n  }\n} {2 1 1}\n\n# Ticket https://sqlite.org/src/tktview/cb91bf4290c211  2017-08-01\n# Assertion fault following PRAGMA reverse_unordered_selects=ON.\n# \ndo_execsql_test whereA-5.1 {\n  PRAGMA reverse_unordered_selects=on;\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(1,2);\n  CREATE INDEX t1b ON t1(b);\n  SELECT a FROM t1 WHERE b=-99 OR b>1;\n} {1}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereB.test",
    "content": "# 2009 August 13\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The\n# focus of this file is testing WHERE clause conditions with\n# subtle affinity issues.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n# For this set of tests:\n#\n#  *   t1.y holds an integer value with affinity NONE\n#  *   t2.b holds a text value with affinity TEXT\n#\n# These values are not equal and because neither affinity is NUMERIC\n# no type conversion occurs.\n#\ndo_test whereB-1.1 {\n  db eval {\n    CREATE TABLE t1(x,y);    -- affinity of t1.y is NONE\n    INSERT INTO t1 VALUES(1,99);\n\n    CREATE TABLE t2(a, b TEXT);  -- affinity of t2.b is TEXT\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,99);\n\n    SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a;\n  }\n} {1 2 0}\ndo_test whereB-1.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-1.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-1.4 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-1.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-1.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-1.102 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n# For this set of tests:\n#\n#  *   t1.y holds a text value with affinity TEXT\n#  *   t2.b holds an integer value with affinity NONE\n#\n# These values are not equal and because neither affinity is NUMERIC\n# no type conversion occurs.\n#\ndo_test whereB-2.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y TEXT);    -- affinity of t1.y is TEXT\n    INSERT INTO t1 VALUES(1,99);\n\n    CREATE TABLE t2(a, b BLOB);  -- affinity of t2.b is NONE\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,99);\n\n    SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a;\n  }\n} {1 2 0}\ndo_test whereB-2.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-2.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-2.4 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-2.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-2.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-2.102 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n# For this set of tests:\n#\n#  *   t1.y holds a text value with affinity NONE\n#  *   t2.b holds an integer value with affinity NONE\n#\n# These values are not equal and because neither affinity is NUMERIC\n# no type conversion occurs.\n#\ndo_test whereB-3.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y BLOB);    -- affinity of t1.y is NONE\n    INSERT INTO t1 VALUES(1,99);\n\n    CREATE TABLE t2(a, b BLOB);  -- affinity of t2.b is NONE\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,'99');\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 0}\ndo_test whereB-3.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-3.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-3.4 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-3.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {}\ndo_test whereB-3.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {}\ndo_test whereB-3.102 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n\n# For this set of tests:\n#\n#  *   t1.y holds a text value with affinity NONE\n#  *   t2.b holds an integer value with affinity NUMERIC\n#\n# Because t2.b has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-4.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y BLOB);    -- affinity of t1.y is NONE\n    INSERT INTO t1 VALUES(1,'99');\n\n    CREATE TABLE t2(a, b NUMERIC);  -- affinity of t2.b is NUMERIC\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,99);\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-4.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-4.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-4.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-4.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-4.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-4.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n\n\n# For this set of tests:\n#\n#  *   t1.y holds a text value with affinity NONE\n#  *   t2.b holds an integer value with affinity INTEGER\n#\n# Because t2.b has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-5.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y BLOB);    -- affinity of t1.y is NONE\n    INSERT INTO t1 VALUES(1,'99');\n\n    CREATE TABLE t2(a, b INT);  -- affinity of t2.b is INTEGER\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,99);\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-5.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-5.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-5.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-5.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-5.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-5.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n\n# For this set of tests:\n#\n#  *   t1.y holds a text value with affinity NONE\n#  *   t2.b holds an integer value with affinity REAL\n#\n# Because t2.b has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-6.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y BLOB);    -- affinity of t1.y is NONE\n    INSERT INTO t1 VALUES(1,'99');\n\n    CREATE TABLE t2(a, b REAL);  -- affinity of t2.b is REAL\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,99.0);\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-6.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-6.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-6.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-6.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-6.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-6.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n\n# For this set of tests:\n#\n#  *   t1.y holds an integer value with affinity NUMERIC\n#  *   t2.b holds a text value with affinity NONE\n#\n# Because t1.y has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-7.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y NUMERIC);  -- affinity of t1.y is NUMERIC\n    INSERT INTO t1 VALUES(1,99);\n\n    CREATE TABLE t2(a, b BLOB);  -- affinity of t2.b is NONE\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,'99');\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-7.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-7.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-7.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-7.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-7.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-7.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n# For this set of tests:\n#\n#  *   t1.y holds an integer value with affinity INTEGER\n#  *   t2.b holds a text value with affinity NONE\n#\n# Because t1.y has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-8.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y INT);  -- affinity of t1.y is INTEGER\n    INSERT INTO t1 VALUES(1,99);\n\n    CREATE TABLE t2(a, b BLOB);  -- affinity of t2.b is NONE\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,'99');\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-8.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-8.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-8.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-8.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-8.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-8.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n# For this set of tests:\n#\n#  *   t1.y holds an integer value with affinity REAL\n#  *   t2.b holds a text value with affinity NONE\n#\n# Because t1.y has a numeric affinity, type conversion should occur\n# and the two fields should be equal.\n#\ndo_test whereB-9.1 {\n  db eval {\n    DROP TABLE t1;\n    DROP TABLE t2;\n\n    CREATE TABLE t1(x, y REAL);  -- affinity of t1.y is REAL\n    INSERT INTO t1 VALUES(1,99.0);\n\n    CREATE TABLE t2(a, b BLOB);  -- affinity of t2.b is NONE\n    CREATE INDEX t2b ON t2(b);\n    INSERT INTO t2 VALUES(2,'99');\n\n    SELECT x, a, y=b FROM t1, t2;\n  }\n} {1 2 1}\ndo_test whereB-9.2 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-9.3 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-9.4 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\ndo_test whereB-9.100 {\n  db eval {\n    DROP INDEX t2b;\n    SELECT x, a, y=b FROM t1, t2 WHERE y=b;\n  }\n} {1 2 1}\ndo_test whereB-9.101 {\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE b=y;\n  }\n} {1 2 1}\ndo_test whereB-9.102 {\n  # In this case the unary \"+\" operator removes the column affinity so\n  # the columns compare false\n  db eval {\n    SELECT x, a, y=b FROM t1, t2 WHERE +y=+b;\n  }\n} {}\n\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereC.test",
    "content": "# 2011 November 16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix whereC\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b INTEGER);\n\n  INSERT INTO t1 VALUES(1, 1, 1);\n  INSERT INTO t1 VALUES(2, 1, 1);\n  INSERT INTO t1 VALUES(3, 1, 2);\n  INSERT INTO t1 VALUES(4, 1, 2);\n  INSERT INTO t1 VALUES(5, 1, 2);\n  INSERT INTO t1 VALUES(6, 1, 3);\n  INSERT INTO t1 VALUES(7, 1, 3);\n\n  INSERT INTO t1 VALUES(8, 2, 1);\n  INSERT INTO t1 VALUES(9, 2, 1);\n  INSERT INTO t1 VALUES(10, 2, 2);\n  INSERT INTO t1 VALUES(11, 2, 2);\n  INSERT INTO t1 VALUES(12, 2, 2);\n  INSERT INTO t1 VALUES(13, 2, 3);\n  INSERT INTO t1 VALUES(14, 2, 3);\n\n  INSERT INTO t1 VALUES(15, 2, 1);\n  INSERT INTO t1 VALUES(16, 2, 1);\n  INSERT INTO t1 VALUES(17, 2, 2);\n  INSERT INTO t1 VALUES(18, 2, 2);\n  INSERT INTO t1 VALUES(19, 2, 2);\n  INSERT INTO t1 VALUES(20, 2, 3);\n  INSERT INTO t1 VALUES(21, 2, 3);\n\n  CREATE INDEX i1 ON t1(a, b);\n}\n\nforeach {tn sql res} {\n  1   \"SELECT i FROM t1 WHERE a=1 AND b=2 AND i>3\"         {4 5}\n  2   \"SELECT i FROM t1 WHERE rowid='12'\"                  {12}\n  3   \"SELECT i FROM t1 WHERE a=1 AND b='2'\"               {3 4 5}\n  4   \"SELECT i FROM t1 WHERE a=1 AND b='2' AND i>'3'\"     {4 5}\n  5   \"SELECT i FROM t1 WHERE a=1 AND b='2' AND i<5\"       {3 4}\n  6   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i<12\"        {10 11}\n  7   \"SELECT i FROM t1 WHERE a IN(1, 2) AND b=2 AND i<11\" {3 4 5 10}\n  8   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 10 AND 12\" {10 11 12}\n  9   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 11 AND 12\" {11 12}\n 10   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 10 AND 11\" {10 11}\n 11   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i BETWEEN 12 AND 10\" {}\n 12   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i<NULL\"      {}\n 13   \"SELECT i FROM t1 WHERE a=2 AND b=2 AND i>=NULL\"     {}\n 14   \"SELECT i FROM t1 WHERE a=1 AND b='2' AND i<4.5\"     {3 4}\n 15   \"SELECT i FROM t1 WHERE rowid IS '12'\"               {12}\n} {\n  do_execsql_test 1.$tn.1 $sql $res\n  do_execsql_test 1.$tn.2 \"$sql ORDER BY i ASC\"  [lsort -integer -inc  $res]\n  do_execsql_test 1.$tn.3 \"$sql ORDER BY i DESC\" [lsort -integer -dec  $res]\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereD.test",
    "content": "# 2012 August 24\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing that an index may be used as a covering\n# index when there are OR expressions in the WHERE clause. \n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix whereD\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t(i,j,k,m,n);\n  CREATE INDEX ijk ON t(i,j,k);\n  CREATE INDEX jmn ON t(j,m,n);\n\n  INSERT INTO t VALUES(3, 3, 'three', 3, 'tres');\n  INSERT INTO t VALUES(2, 2, 'two', 2, 'dos');\n  INSERT INTO t VALUES(1, 1, 'one', 1, 'uno');\n  INSERT INTO t VALUES(4, 4, 'four', 4, 'cuatro');\n}\n\ndo_execsql_test 1.2 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);\n} {one two}\ndo_execsql_test 1.3 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (+i=2 AND j=2);\n} {one two}\ndo_execsql_test 1.4 {\n  SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);\n} {uno dos}\ndo_execsql_test 1.5 {\n  SELECT k, n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2);\n} {one uno two dos}\ndo_execsql_test 1.6 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (i=3 AND j=3);\n} {one two three}\ndo_execsql_test 1.7 {\n  SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (i=3 AND j=3);\n} {uno dos tres}\ndo_execsql_test 1.8 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2);\n} {one two}\ndo_execsql_test 1.9 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (j=3 AND m=3);\n} {one two three}\ndo_execsql_test 1.10 {\n  SELECT n FROM t WHERE (i=1 AND j=1) OR (i=2 AND j=2) OR (j=3 AND m=3);\n} {uno dos tres}\ndo_execsql_test 1.11 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2) OR (i=3 AND j=3);\n} {one two three}\ndo_execsql_test 1.12 {\n  SELECT n FROM t WHERE (i=1 AND j=1) OR (j=2 AND m=2) OR (i=3 AND j=3);\n} {uno dos tres}\ndo_execsql_test 1.13 {\n  SELECT k FROM t WHERE (j=1 AND m=1) OR (i=2 AND j=2) OR (i=3 AND j=3);\n} {one two three}\ndo_execsql_test 1.14 {\n  SELECT k FROM t WHERE (i=1 AND j=1) OR (j=2 AND i=2) OR (i=3 AND j=3);\n} {one two three}\ndo_execsql_test 1.15 {\n  SELECT k FROM t WHERE (i=1 AND j=2) OR (i=2 AND j=1) OR (i=3 AND j=4);\n} {}\ndo_execsql_test 1.16 {\n  SELECT k FROM t WHERE (i=1 AND (j=1 or j=2)) OR (i=3 AND j=3);\n} {one three}\n\ndo_execsql_test 2.0 {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE INDEX t1b ON t1(b);\n  CREATE INDEX t1c ON t1(c);\n  CREATE INDEX t1d ON t1(d);\n  CREATE TABLE t2(x,y);\n  CREATE INDEX t2y ON t2(y);\n  \n  INSERT INTO t1 VALUES(1,2,3,4);\n  INSERT INTO t1 VALUES(5,6,7,8);\n  INSERT INTO t2 VALUES(1,2);\n  INSERT INTO t2 VALUES(2,7);\n  INSERT INTO t2 VALUES(3,4);\n} {}\ndo_execsql_test 2.1 {\n  SELECT a, x FROM t1 JOIN t2 ON +y=d OR x=7 ORDER BY a, x;\n} {1 3}\ndo_execsql_test 2.2 {\n  SELECT a, x FROM t1 JOIN t2 ON y=d OR x=7 ORDER BY a, x;\n} {1 3}\n\n\n# Similar to [do_execsql_test], except that two elements are appended\n# to the result - the string \"search\" and the number of times test variable\n# sqlite3_search_count is incremented by running the supplied SQL. e.g.\n# \n#   do_searchcount_test 1.0 { SELECT * FROM t1 } {x y search 2}\n#\nproc do_searchcount_test {tn sql res} {\n  uplevel [subst -nocommands {\n    do_test $tn {\n      set ::sqlite_search_count 0\n      concat [db eval {$sql}] search [set ::sqlite_search_count]\n    } [list $res]\n  }] \n}\n\ndo_execsql_test 3.0 {\n  CREATE TABLE t3(a, b, c);\n  CREATE UNIQUE INDEX i3 ON t3(a, b);\n  INSERT INTO t3 VALUES(1, 'one', 'i');\n  INSERT INTO t3 VALUES(3, 'three', 'iii');\n  INSERT INTO t3 VALUES(6, 'six', 'vi');\n  INSERT INTO t3 VALUES(2, 'two', 'ii');\n  INSERT INTO t3 VALUES(4, 'four', 'iv');\n  INSERT INTO t3 VALUES(5, 'five', 'v');\n\n  CREATE TABLE t4(x PRIMARY KEY, y);\n  INSERT INTO t4 VALUES('a', 'one');\n  INSERT INTO t4 VALUES('b', 'two');\n}\n\ndo_searchcount_test 3.1 {\n  SELECT a, b FROM t3 WHERE (a=1 AND b='one') OR (a=2 AND b='two')\n} {1 one 2 two search 4}\n\ndo_searchcount_test 3.2 {\n  SELECT a, c FROM t3 WHERE (a=1 AND b='one') OR (a=2 AND b='two')\n} {1 i 2 ii search 6}\n\ndo_searchcount_test 3.4.1 {\n  SELECT y FROM t4 WHERE x='a'\n} {one search 2}\ndo_searchcount_test 3.4.2 {\n  SELECT a, b FROM t3 WHERE \n        (a=1 AND b=(SELECT y FROM t4 WHERE x='a')) \n     OR (a=2 AND b='two')\n} {1 one 2 two search 6}\ndo_searchcount_test 3.4.3 {\n  SELECT a, b FROM t3 WHERE \n        (a=2 AND b='two')\n     OR (a=1 AND b=(SELECT y FROM t4 WHERE x='a')) \n} {2 two 1 one search 6}\ndo_searchcount_test 3.4.4 {\n  SELECT a, b FROM t3 WHERE \n        (a=2 AND b=(SELECT y FROM t4 WHERE x='b')) \n     OR (a=1 AND b=(SELECT y FROM t4 WHERE x='a')) \n} {2 two 1 one search 8}\n\ndo_searchcount_test 3.5.1 {\n  SELECT a, b FROM t3 WHERE (a=1 AND b='one') OR rowid=4\n} {1 one 2 two search 2}\ndo_searchcount_test 3.5.2 {\n  SELECT a, c FROM t3 WHERE (a=1 AND b='one') OR rowid=4\n} {1 i 2 ii search 3}\n\n# Ticket [d02e1406a58ea02d] (2012-10-04)\n# LEFT JOIN with an OR in the ON clause causes segfault \n#\ndo_test 4.1 {\n  db eval {\n    CREATE TABLE t41(a,b,c);\n    INSERT INTO t41 VALUES(1,2,3), (4,5,6);\n    CREATE TABLE t42(d,e,f);\n    INSERT INTO t42 VALUES(3,6,9), (4,8,12);\n    SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b);\n  }\n} {1 2 3 3 6 9 4 5 6 {} {} {}}\ndo_test 4.2 {\n  db eval {\n    CREATE INDEX t42d ON t42(d);\n    CREATE INDEX t42e ON t42(e);\n    SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.e=x.b);\n  }\n} {1 2 3 3 6 9 4 5 6 {} {} {}}\ndo_test 4.3 {\n  db eval {\n    SELECT * FROM t41 AS x LEFT JOIN t42 AS y ON (y.d=x.c) OR (y.d=x.b);\n  }\n} {1 2 3 3 6 9 4 5 6 {} {} {}}\n\n# Ticket [bc1aea7b725f276177]\n# Incorrect result on LEFT JOIN with OR constraints and an ORDER BY clause.\n#\ndo_execsql_test 4.4 {\n  CREATE TABLE t44(a INTEGER, b INTEGER);\n  INSERT INTO t44 VALUES(1,2);\n  INSERT INTO t44 VALUES(3,4);\n  SELECT *\n    FROM t44 AS x\n       LEFT JOIN (SELECT a AS c, b AS d FROM t44) AS y ON a=c\n   WHERE d=4 OR d IS NULL;\n} {3 4 3 4}\ndo_execsql_test 4.5 {\n  SELECT *\n    FROM t44 AS x\n       LEFT JOIN (SELECT a AS c, b AS d FROM t44) AS y ON a=c\n   WHERE d=4 OR d IS NULL\n   ORDER BY a;\n} {3 4 3 4}\ndo_execsql_test 4.6 {\n  CREATE TABLE t46(c INTEGER, d INTEGER);\n  INSERT INTO t46 SELECT a, b FROM t44;\n  SELECT * FROM t44 LEFT JOIN t46 ON a=c\n   WHERE d=4 OR d IS NULL;\n} {3 4 3 4}\ndo_execsql_test 4.7 {\n  SELECT * FROM t44 LEFT JOIN t46 ON a=c\n   WHERE d=4 OR d IS NULL\n   ORDER BY a;\n} {3 4 3 4}\n\n# Verify fix of a bug reported on the mailing list by Peter Reid\n#\ndo_execsql_test 5.1 {\n  DROP TABLE IF EXISTS t;\n  CREATE TABLE t(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,c17);\n  CREATE INDEX tc0 ON t(c0);\n  CREATE INDEX tc1 ON t(c1);\n  CREATE INDEX tc2 ON t(c2);\n  CREATE INDEX tc3 ON t(c3);\n  CREATE INDEX tc4 ON t(c4);\n  CREATE INDEX tc5 ON t(c5);\n  CREATE INDEX tc6 ON t(c6);\n  CREATE INDEX tc7 ON t(c7);\n  CREATE INDEX tc8 ON t(c8);\n  CREATE INDEX tc9 ON t(c9);\n  CREATE INDEX tc10 ON t(c10);\n  CREATE INDEX tc11 ON t(c11);\n  CREATE INDEX tc12 ON t(c12);\n  CREATE INDEX tc13 ON t(c13);\n  CREATE INDEX tc14 ON t(c14);\n  CREATE INDEX tc15 ON t(c15);\n  CREATE INDEX tc16 ON t(c16);\n  CREATE INDEX tc17 ON t(c17);\n  \n  INSERT INTO t(c0, c16) VALUES (1,1);\n  \n  SELECT * FROM t WHERE\n    c0=1 or  c1=1 or  c2=1 or  c3=1 or\n    c4=1 or  c5=1 or  c6=1 or  c7=1 or\n    c8=1 or  c9=1 or c10=1 or c11=1 or\n    c12=1 or c13=1 or c14=1 or c15=1 or\n    c16=1 or c17=1;\n} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 {}}\ndo_execsql_test 5.2 {\n  DELETE FROM t;\n  INSERT INTO t(c0,c17) VALUES(1,1);\n  SELECT * FROM t WHERE\n    c0=1 or  c1=1 or  c2=1 or  c3=1 or\n    c4=1 or  c5=1 or  c6=1 or  c7=1 or\n    c8=1 or  c9=1 or c10=1 or c11=1 or\n    c12=1 or c13=1 or c14=1 or c15=1 or\n    c16=1 or c17=1;\n} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1}\ndo_execsql_test 5.3 {\n  DELETE FROM t;\n  INSERT INTO t(c0,c15) VALUES(1,1);\n  SELECT * FROM t WHERE\n    c0=1 or  c1=1 or  c2=1 or  c3=1 or\n    c4=1 or  c5=1 or  c6=1 or  c7=1 or\n    c8=1 or  c9=1 or c10=1 or c11=1 or\n    c12=1 or c13=1 or c14=1 or c15=1 or\n    c16=1 or c17=1;\n} {1 {} {} {} {} {} {} {} {} {} {} {} {} {} {} 1 {} {}}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 6.1 {\n  CREATE TABLE x1(a, b, c, d, e);\n  CREATE INDEX x1a  ON x1(a);\n  CREATE INDEX x1bc ON x1(b, c);\n  CREATE INDEX x1cd ON x1(c, d);\n\n  INSERT INTO x1 VALUES(1, 2, 3, 4, 'A');\n  INSERT INTO x1 VALUES(5, 6, 7, 8, 'B');\n  INSERT INTO x1 VALUES(9, 10, 11, 12, 'C');\n  INSERT INTO x1 VALUES(13, 14, 15, 16, 'D');\n}\n\ndo_searchcount_test 6.2.1 {\n  SELECT e FROM x1 WHERE b=2 OR c=7;\n} {A B search 6}\ndo_searchcount_test 6.2.2 {\n  SELECT c FROM x1 WHERE b=2 OR c=7;\n} {3 7 search 4}\n\ndo_searchcount_test 6.3.1 {\n  SELECT e FROM x1 WHERE a=1 OR b=10;\n} {A C search 6}\ndo_searchcount_test 6.3.2 {\n  SELECT c FROM x1 WHERE a=1 OR b=10;\n} {3 11 search 5}\ndo_searchcount_test 6.3.3 {\n  SELECT rowid FROM x1 WHERE a=1 OR b=10;\n} {1 3 search 4}\n\ndo_searchcount_test 6.4.1 {\n  SELECT a FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12\n} {1 9 search 6}\ndo_searchcount_test 6.4.2 {\n  SELECT b, c FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12\n} {2 3 10 11 search 5}\ndo_searchcount_test 6.4.3 {\n  SELECT rowid, c FROM x1 WHERE b BETWEEN 1 AND 4 OR c BETWEEN 8 AND 12\n} {1 3 3 11 search 4}\n\ndo_searchcount_test 6.5.1 {\n  SELECT a FROM x1 WHERE rowid = 2 OR c=11\n} {5 9 search 3}\ndo_searchcount_test 6.5.2 {\n  SELECT d FROM x1 WHERE rowid = 2 OR c=11\n} {8 12 search 2}\ndo_searchcount_test 6.5.3 {\n  SELECT d FROM x1 WHERE c=11 OR rowid = 2\n} {12 8 search 2}\ndo_searchcount_test 6.5.4 {\n  SELECT a FROM x1 WHERE c=11 OR rowid = 2 \n} {9 5 search 3}\n\ndo_searchcount_test 6.6.1 {\n  SELECT rowid FROM x1 WHERE a=1 OR b=6 OR c=11\n} {1 2 3 search 6}\ndo_searchcount_test 6.6.2 {\n  SELECT c FROM x1 WHERE a=1 OR b=6 OR c=11\n} {3 7 11 search 7}\ndo_searchcount_test 6.6.3 {\n  SELECT c FROM x1 WHERE c=11 OR a=1 OR b=6 \n} {11 3 7 search 7}\ndo_searchcount_test 6.6.4 {\n  SELECT c FROM x1 WHERE b=6 OR c=11 OR a=1\n} {7 11 3 search 7}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 7.0 {\n  CREATE TABLE y1(a, b);\n  CREATE TABLE y2(x, y);\n  CREATE INDEX y2xy ON y2(x, y);\n  INSERT INTO y1 VALUES(1, 1);\n  INSERT INTO y2 VALUES(3, 3);\n}\n\ndo_execsql_test 7.1 {\n  SELECT * FROM y1 LEFT JOIN y2 ON ((x=1 AND y=b) OR (x=2 AND y=b))\n} {1 1 {} {}}\n\ndo_execsql_test 7.3 {\n  CREATE TABLE foo (Id INTEGER PRIMARY KEY, fa INTEGER, fb INTEGER); \n  CREATE TABLE bar (Id INTEGER PRIMARY KEY, ba INTEGER, bb INTEGER);\n\n  INSERT INTO foo VALUES(1, 1, 1);\n  INSERT INTO foo VALUES(2, 1, 2);\n  INSERT INTO foo VALUES(3, 1, 3);\n  INSERT INTO foo VALUES(4, 1, 4);\n  INSERT INTO foo VALUES(5, 1, 5);\n  INSERT INTO foo VALUES(6, 1, 6);\n  INSERT INTO foo VALUES(7, 1, 7);\n  INSERT INTO foo VALUES(8, 1, 8);\n  INSERT INTO foo VALUES(9, 1, 9);\n\n  INSERT INTO bar VALUES(NULL, 1, 1);\n  INSERT INTO bar VALUES(NULL, 2, 2);\n  INSERT INTO bar VALUES(NULL, 3, 3);\n  INSERT INTO bar VALUES(NULL, 1, 4);\n  INSERT INTO bar VALUES(NULL, 2, 5);\n  INSERT INTO bar VALUES(NULL, 3, 6);\n  INSERT INTO bar VALUES(NULL, 1, 7);\n  INSERT INTO bar VALUES(NULL, 2, 8);\n  INSERT INTO bar VALUES(NULL, 3, 9);\n}\n\ndo_execsql_test 7.4 {\n  SELECT \n    bar.Id, bar.ba, bar.bb, foo.fb\n    FROM foo LEFT JOIN bar\n           ON (bar.ba = 1 AND bar.bb = foo.fb)\n           OR (bar.ba = 5 AND bar.bb = foo.fb);\n} {\n  1 1 1 1 \n  {} {} {} 2 \n  {} {} {} 3 \n  4 1 4 4 \n  {} {} {} 5 \n  {} {} {} 6 \n  7 1 7 7 \n  {} {} {} 8 \n  {} {} {} 9\n}\n\ndo_execsql_test 7.5 {\n  CREATE INDEX idx_bar ON bar(ba, bb);\n  SELECT \n    bar.Id, bar.ba, bar.bb, foo.fb\n    FROM foo LEFT JOIN bar\n           ON (bar.ba = 1 AND bar.bb = foo.fb)\n           OR (bar.ba = 5 AND bar.bb = foo.fb);\n} {\n  1 1 1 1 \n  {} {} {} 2 \n  {} {} {} 3 \n  4 1 4 4 \n  {} {} {} 5 \n  {} {} {} 6 \n  7 1 7 7 \n  {} {} {} 8 \n  {} {} {} 9\n}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereE.test",
    "content": "# 2012 November 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the query planner to make sure it\n# is making good planning decisions.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix whereE\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b);\n  INSERT INTO t1 VALUES(1,10), (2,20), (3,30), (2,22), (3, 33);\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  INSERT INTO t1 SELECT * FROM t1;\n  ALTER TABLE t1 ADD COLUMN c;\n  UPDATE t1 SET c=a*rowid+10000;\n  CREATE INDEX t1ab ON t1(a,b);\n  \n  CREATE TABLE t2(x,y);\n  INSERT INTO t2 VALUES(4,44),(5,55),(6,66),(7,77);\n  INSERT INTO t2 SELECT x+4, (x+4)*11 FROM t2;\n  INSERT INTO t2 SELECT x+8, (x+8)*11 FROM t2;\n  INSERT INTO t2 SELECT x+16, (x+16)*11 FROM t2;\n  INSERT INTO t2 SELECT x+32, (x+32)*11 FROM t2;\n  INSERT INTO t2 SELECT x+64, (x+32)*11 FROM t2;\n  ALTER TABLE t2 ADD COLUMN z;\n  UPDATE t2 SET z=2;\n  CREATE UNIQUE INDEX t2zx ON t2(z,x);\n\n  EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;\n} {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}\ndo_execsql_test 1.2 {\n  EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;\n} {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}\ndo_execsql_test 1.3 {\n  ANALYZE;\n  EXPLAIN QUERY PLAN SELECT x FROM t1, t2 WHERE a=z AND c=x;\n} {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}\ndo_execsql_test 1.4 {\n  EXPLAIN QUERY PLAN SELECT x FROM t2, t1 WHERE a=z AND c=x;\n} {/.*SCAN TABLE t1.*SEARCH TABLE t2.*/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereF.test",
    "content": "# 2012 November 9\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases for query planning decisions.\n\n\n#\n# The tests in this file demonstrate the behaviour of the query planner\n# in determining the order in which joined tables are scanned.\n#\n# Assume there are two tables being joined - t1 and t2. Each has a cost\n# if it is the outer loop, and a cost if it is the inner loop. As follows:\n#\n#   t1(outer) - cost of scanning t1 as the outer loop.\n#   t1(inner) - cost of scanning t1 as the inner loop.\n#   t2(outer) - cost of scanning t2 as the outer loop.\n#   t2(inner) - cost of scanning t2 as the inner loop.\n#\n# Depending on the order in which the planner nests the scans, the total\n# cost of the join query is one of:\n#\n#   t1(outer) * t2(inner)\n#   t2(outer) * t1(inner)\n#\n# The tests in this file attempt to verify that the planner nests joins in\n# the correct order when the following are true:\n#\n#   + (t1(outer) * t2(inner)) > (t1(inner) * t2(outer)\n#   +  t1(outer) < t2(outer)\n#\n# In other words, when the best overall query plan has t2 as the outer loop,\n# but when the outer loop is considered independent of the inner, t1 is the\n# most efficient choice.\n#\n# In order to make them more predictable, automatic indexes are turned off for\n# the tests in this file.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix whereF\n\ndo_execsql_test 1.0 {\n  PRAGMA automatic_index = 0;\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(d, e, f);\n  CREATE UNIQUE INDEX i1 ON t1(a);\n  CREATE UNIQUE INDEX i2 ON t2(d);\n} {}\n\nforeach {tn sql} {\n  1 \"SELECT * FROM t1,           t2 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10\"\n  2 \"SELECT * FROM t2,           t1 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10\"\n  3 \"SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a=t2.e AND t2.d<t1.b AND t1.c!=10\"\n} {\n  do_test 1.$tn {\n    db eval \"EXPLAIN QUERY PLAN $sql\"\n   } {/.*SCAN TABLE t2\\y.*SEARCH TABLE t1\\y.*/}\n}\n\ndo_execsql_test 2.0 {\n  DROP TABLE t1;\n  DROP TABLE t2;\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(d, e, f);\n\n  CREATE UNIQUE INDEX i1 ON t1(a);\n  CREATE UNIQUE INDEX i2 ON t1(b);\n  CREATE UNIQUE INDEX i3 ON t2(d);\n} {}\n\nforeach {tn sql} {\n  1 \"SELECT * FROM t1,           t2 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e\"\n  2 \"SELECT * FROM t2,           t1 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e\"\n  3 \"SELECT * FROM t2 CROSS JOIN t1 WHERE t1.a>? AND t2.d>t1.c AND t1.b=t2.e\"\n} {\n  do_test 2.$tn {\n    db eval \"EXPLAIN QUERY PLAN $sql\"\n   } {/.*SCAN TABLE t2\\y.*SEARCH TABLE t1\\y.*/}\n}\n\ndo_execsql_test 3.0 {\n  DROP TABLE t1;\n  DROP TABLE t2;\n  CREATE TABLE t1(a, b, c);\n  CREATE TABLE t2(d, e, f);\n\n  CREATE UNIQUE INDEX i1 ON t1(a, b);\n  CREATE INDEX i2 ON t2(d);\n} {}\n\nforeach {tn sql} {\n  1 {SELECT t1.a, t1.b, t2.d, t2.e FROM t1, t2 \n     WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}\n\n  2 {SELECT t1.a, t1.b, t2.d, t2.e FROM t2, t1 \n     WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}\n\n  3 {SELECT t1.a, t1.b, t2.d, t2.e FROM t2 CROSS JOIN t1 \n     WHERE t2.d=t1.b AND t1.a=(t2.d+1) AND t1.b = (t2.e+1)}\n} {\n  do_test 3.$tn {\n    db eval \"EXPLAIN QUERY PLAN $sql\"\n   } {/.*SCAN TABLE t2\\y.*SEARCH TABLE t1\\y.*/}\n}\n\ndo_execsql_test 4.0 {\n  CREATE TABLE t4(a,b,c,d,e, PRIMARY KEY(a,b,c));\n  CREATE INDEX t4adc ON t4(a,d,c);\n  CREATE UNIQUE INDEX t4aebc ON t4(a,e,b,c);\n  EXPLAIN QUERY PLAN SELECT rowid FROM t4 WHERE a=? AND b=?;\n} {/a=. AND b=./}\n\n#-------------------------------------------------------------------------\n# Test the following case:\n#\n#   ... FROM t1, t2 WHERE (\n#     t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1)\n#   )\n#\n# where there is an index on t2(f2). The planner should use \"t1\" as the\n# outer loop. The inner loop, on \"t2\", is an OR optimization. One pass\n# for:\n#\n#     t2.rowid = $1\n#\n# and another for:\n#\n#     t2.f2=$1 AND $1!=-1\n#\n# the test is to ensure that on the second pass, the ($1!=-1) condition\n# is tested before any seek operations are performed - i.e. outside of\n# the loop through the f2=$1 range of the t2(f2) index.\n#\nreset_db\ndo_execsql_test 5.0 {\n  CREATE TABLE t1(f1);\n  CREATE TABLE t2(f2);\n  CREATE INDEX t2f ON t2(f2);\n\n  INSERT INTO t1 VALUES(-1);\n  INSERT INTO t1 VALUES(-1);\n  INSERT INTO t1 VALUES(-1);\n  INSERT INTO t1 VALUES(-1);\n\n  WITH w(i) AS (\n    SELECT 1 UNION ALL SELECT i+1 FROM w WHERE i<1000\n  )\n  INSERT INTO t2 SELECT -1 FROM w;\n}\n\ndo_execsql_test 5.1 {\n  SELECT count(*) FROM t1, t2 WHERE t2.rowid = +t1.rowid\n} {4}\ndo_test 5.2 { expr [db status vmstep]<200 } 1\n\ndo_execsql_test 5.3 {\n  SELECT count(*) FROM t1, t2 WHERE (\n    t2.rowid = +t1.rowid OR t2.f2 = t1.f1\n  )\n} {4000}\ndo_test 5.4 { expr [db status vmstep]>1000 } 1\n\ndo_execsql_test 5.5 {\n  SELECT count(*) FROM t1, t2 WHERE (\n    t2.rowid = +t1.rowid OR (t2.f2 = t1.f1 AND t1.f1!=-1)\n  )\n} {4}\ndo_test 5.6 { expr [db status vmstep]<200 } 1\n\n# 2017-09-04 ticket b899b6042f97f52d\n# Segfault on correlated subquery...\n#\nifcapable json1&&vtab {\n  do_execsql_test 6.1 {\n    CREATE TABLE t6(x);\n    SELECT * FROM t6 WHERE 1 IN (SELECT value FROM json_each(x));\n  } {}\n\n  do_execsql_test 6.2 {\n    DROP TABLE t6;\n    CREATE TABLE t6(a,b,c);\n    INSERT INTO t6 VALUES\n     (0,null,'{\"a\":0,\"b\":[3,4,5],\"c\":{\"x\":4.5,\"y\":7.8}}'),\n     (1,null,'{\"a\":1,\"b\":[3,4,5],\"c\":{\"x\":4.5,\"y\":7.8}}'),\n     (2,null,'{\"a\":9,\"b\":[3,4,5],\"c\":{\"x\":4.5,\"y\":7.8}}');\n    SELECT * FROM t6\n     WHERE (EXISTS (SELECT 1 FROM json_each(t6.c) AS x WHERE x.value=1));\n  } {1 {} {{\"a\":1,\"b\":[3,4,5],\"c\":{\"x\":4.5,\"y\":7.8}}}}\n\n  # Another test case derived from a posting by Wout Mertens on the\n  # sqlite-users mailing list on 2017-10-04.\n  do_execsql_test 6.3 {\n    DROP TABLE IF EXISTS t;\n    CREATE TABLE t(json JSON);\n    SELECT * FROM t\n     WHERE(EXISTS(SELECT 1 FROM json_each(t.json,\"$.foo\") j\n                   WHERE j.value = 'meep'));\n  } {}\n  do_execsql_test 6.4 {\n    INSERT INTO t VALUES('{\"xyzzy\":null}');\n    INSERT INTO t VALUES('{\"foo\":\"meep\",\"other\":12345}');\n    INSERT INTO t VALUES('{\"foo\":\"bingo\",\"alt\":5.25}');\n    SELECT * FROM t\n     WHERE(EXISTS(SELECT 1 FROM json_each(t.json,\"$.foo\") j\n                   WHERE j.value = 'meep'));\n  } {{{\"foo\":\"meep\",\"other\":12345}}}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereG.test",
    "content": "# 2013-09-05\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases for query planning decisions and the likely(), unlikely(), and\n# likelihood() functions.\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix whereG\n\ndo_execsql_test whereG-1.0 {\n  CREATE TABLE composer(\n    cid INTEGER PRIMARY KEY,\n    cname TEXT\n  );\n  CREATE TABLE album(\n    aid INTEGER PRIMARY KEY,\n    aname TEXT\n  );\n  CREATE TABLE track(\n    tid INTEGER PRIMARY KEY,\n    cid INTEGER REFERENCES composer,\n    aid INTEGER REFERENCES album,\n    title TEXT\n  );\n  CREATE INDEX track_i1 ON track(cid);\n  CREATE INDEX track_i2 ON track(aid);\n  INSERT INTO composer VALUES(1, 'W. A. Mozart');\n  INSERT INTO composer VALUES(2, 'Beethoven');\n  INSERT INTO composer VALUES(3, 'Thomas Tallis');\n  INSERT INTO composer VALUES(4, 'Joseph Hayden');\n  INSERT INTO composer VALUES(5, 'Thomas Weelkes');\n  INSERT INTO composer VALUES(6, 'J. S. Bach');\n  INSERT INTO composer VALUES(7, 'Orlando Gibbons');\n  INSERT INTO composer VALUES(8, 'Josquin des Prés');\n  INSERT INTO composer VALUES(9, 'Byrd');\n  INSERT INTO composer VALUES(10, 'Francis Poulenc');\n  INSERT INTO composer VALUES(11, 'Mendelsshon');\n  INSERT INTO composer VALUES(12, 'Zoltán Kodály');\n  INSERT INTO composer VALUES(13, 'Handel');\n  INSERT INTO album VALUES(100, 'Kodály: Missa Brevis');\n  INSERT INTO album VALUES(101, 'Messiah');\n  INSERT INTO album VALUES(102, 'Missa Brevis in D-, K.65');\n  INSERT INTO album VALUES(103, 'The complete English anthems');\n  INSERT INTO album VALUES(104, 'Mass in B Minor, BWV 232');\n  INSERT INTO track VALUES(10005, 12, 100, 'Sanctus');\n  INSERT INTO track VALUES(10007, 12, 100, 'Agnus Dei');\n  INSERT INTO track VALUES(10115, 13, 101, 'Surely He Hath Borne Our Griefs');\n  INSERT INTO track VALUES(10129, 13, 101, 'Since By Man Came Death');\n  INSERT INTO track VALUES(10206, 1, 102, 'Agnus Dei');\n  INSERT INTO track VALUES(10301, 3, 103, 'If Ye Love Me');\n  INSERT INTO track VALUES(10402, 6, 104, 'Domine Deus');\n  INSERT INTO track VALUES(10403, 6, 104, 'Qui tollis');\n} {}\ndo_eqp_test whereG-1.1 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE unlikely(cname LIKE '%bach%')\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {/.*composer.*track.*album.*/}\ndo_execsql_test whereG-1.2 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE unlikely(cname LIKE '%bach%')\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {{Mass in B Minor, BWV 232}}\n\ndo_eqp_test whereG-1.3 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE likelihood(cname LIKE '%bach%', 0.5)\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {/.*track.*composer.*album.*/}\ndo_execsql_test whereG-1.4 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE likelihood(cname LIKE '%bach%', 0.5)\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {{Mass in B Minor, BWV 232}}\n\ndo_eqp_test whereG-1.5 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE cname LIKE '%bach%'\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {/.*track.*(composer.*album|album.*composer).*/}\ndo_execsql_test whereG-1.6 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE cname LIKE '%bach%'\n     AND composer.cid=track.cid\n     AND album.aid=track.aid;\n} {{Mass in B Minor, BWV 232}}\n\ndo_eqp_test whereG-1.7 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE cname LIKE '%bach%'\n     AND unlikely(composer.cid=track.cid)\n     AND unlikely(album.aid=track.aid);\n} {/.*track.*(composer.*album|album.*composer).*/}\ndo_execsql_test whereG-1.8 {\n  SELECT DISTINCT aname\n    FROM album, composer, track\n   WHERE cname LIKE '%bach%'\n     AND unlikely(composer.cid=track.cid)\n     AND unlikely(album.aid=track.aid);\n} {{Mass in B Minor, BWV 232}}\n\ndo_test whereG-2.1 {\n  catchsql {\n    SELECT DISTINCT aname\n      FROM album, composer, track\n     WHERE likelihood(cname LIKE '%bach%', -0.01)\n       AND composer.cid=track.cid\n       AND album.aid=track.aid;\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\ndo_test whereG-2.2 {\n  catchsql {\n    SELECT DISTINCT aname\n      FROM album, composer, track\n     WHERE likelihood(cname LIKE '%bach%', 1.01)\n       AND composer.cid=track.cid\n       AND album.aid=track.aid;\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\ndo_test whereG-2.3 {\n  catchsql {\n    SELECT DISTINCT aname\n      FROM album, composer, track\n     WHERE likelihood(cname LIKE '%bach%', track.cid)\n       AND composer.cid=track.cid\n       AND album.aid=track.aid;\n  }\n} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}\n\n# Commuting a term of the WHERE clause should not change the query plan\n#\ndo_execsql_test whereG-3.0 {\n  CREATE TABLE a(a1 PRIMARY KEY, a2);\n  CREATE TABLE b(b1 PRIMARY KEY, b2);\n} {}\ndo_eqp_test whereG-3.1 {\n  SELECT * FROM a, b WHERE b1=a1 AND a2=5;\n} {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}\ndo_eqp_test whereG-3.2 {\n  SELECT * FROM a, b WHERE a1=b1 AND a2=5;\n} {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}\ndo_eqp_test whereG-3.3 {\n  SELECT * FROM a, b WHERE a2=5 AND b1=a1;\n} {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}\ndo_eqp_test whereG-3.4 {\n  SELECT * FROM a, b WHERE a2=5 AND a1=b1;\n} {/.*SCAN TABLE a.*SEARCH TABLE b USING INDEX .*b_1 .b1=..*/}\n\n# Ticket [1e64dd782a126f48d78c43a664844a41d0e6334e]:\n# Incorrect result in a nested GROUP BY/DISTINCT due to the use of an OP_SCopy\n# where an OP_Copy was needed.\n#\ndo_execsql_test whereG-4.0 {\n  CREATE TABLE t4(x);\n  INSERT INTO t4 VALUES('right'),('wrong');\n  SELECT DISTINCT x\n   FROM (SELECT x FROM t4 GROUP BY x)\n   WHERE x='right'\n   ORDER BY x;\n} {right}\n\n#-------------------------------------------------------------------------\n# Test that likelihood() specifications on indexed terms are taken into \n# account by various forms of loops.\n#\n#   5.1.*: open ended range scans\n#   5.2.*: skip-scans\n#\nreset_db\n\ndo_execsql_test 5.1 {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(a, b);\n}\ndo_eqp_test 5.1.2 {\n  SELECT * FROM t1 WHERE a>?\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}\ndo_eqp_test 5.1.3 {\n  SELECT * FROM t1 WHERE likelihood(a>?, 0.9)\n} {0 0 0 {SCAN TABLE t1}}\ndo_eqp_test 5.1.4 {\n  SELECT * FROM t1 WHERE likely(a>?)\n} {0 0 0 {SCAN TABLE t1}}\n\ndo_test 5.2 {\n  for {set i 0} {$i < 100} {incr i} {\n    execsql { INSERT INTO t1 VALUES('abc', $i, $i); }\n  }\n  execsql { INSERT INTO t1 SELECT 'def', b, c FROM t1; }\n  execsql { ANALYZE }\n} {}\ndo_eqp_test 5.2.2 {\n  SELECT * FROM t1 WHERE likelihood(b>?, 0.01)\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>?)}}\ndo_eqp_test 5.2.3 {\n  SELECT * FROM t1 WHERE likelihood(b>?, 0.9)\n} {0 0 0 {SCAN TABLE t1}}\ndo_eqp_test 5.2.4 {\n  SELECT * FROM t1 WHERE likely(b>?)\n} {0 0 0 {SCAN TABLE t1}}\n\ndo_eqp_test 5.3.1 {\n  SELECT * FROM t1 WHERE a=?\n} {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}\ndo_eqp_test 5.3.2 {\n  SELECT * FROM t1 WHERE likelihood(a=?, 0.9)\n} {0 0 0 {SCAN TABLE t1}}\ndo_eqp_test 5.3.3 {\n  SELECT * FROM t1 WHERE likely(a=?)\n} {0 0 0 {SCAN TABLE t1}}\n\n# 2015-06-18\n# Ticket [https://www.sqlite.org/see/tktview/472f0742a1868fb58862bc588ed70]\n#\ndo_execsql_test 6.0 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(i int, x, y, z);\n  INSERT INTO t1 VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(i int, bool char);\n  INSERT INTO t2 VALUES(1,'T'), (2,'F');\n  SELECT count(*) FROM t1 LEFT JOIN t2 ON t1.i=t2.i AND bool='T';\n  SELECT count(*) FROM t1 LEFT JOIN t2 ON likely(t1.i=t2.i) AND bool='T';\n} {4 4}\n\n# 2015-06-20\n# Crash discovered by AFL\n#\ndo_execsql_test 7.0 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a, b, PRIMARY KEY(a,b));\n  INSERT INTO t1 VALUES(9,1),(1,2);\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t2(x, y, PRIMARY KEY(x,y));\n  INSERT INTO t2 VALUES(3,3),(4,4);\n  SELECT likely(a), x FROM t1, t2 ORDER BY 1, 2;\n} {1 3 1 4 9 3 9 4}\ndo_execsql_test 7.1 {\n  SELECT unlikely(a), x FROM t1, t2 ORDER BY 1, 2;\n} {1 3 1 4 9 3 9 4}\ndo_execsql_test 7.2 {\n  SELECT likelihood(a,0.5), x FROM t1, t2 ORDER BY 1, 2;\n} {1 3 1 4 9 3 9 4}\ndo_execsql_test 7.3 {\n  SELECT coalesce(a,a), x FROM t1, t2 ORDER BY 1, 2;\n} {1 3 1 4 9 3 9 4}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereH.test",
    "content": "# 2014-03-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# Test cases for query planning decisions where one candidate index\n# covers a proper superset of the WHERE clause terms of another\n# candidate index.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test whereH-1.1 {\n  CREATE TABLE t1(a,b,c,d);\n  CREATE INDEX t1abc ON t1(a,b,c);\n  CREATE INDEX t1bc ON t1(b,c);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;\n} {/INDEX t1abc /}\ndo_execsql_test whereH-1.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-2.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d);\n  CREATE INDEX t1bc ON t1(b,c);\n  CREATE INDEX t1abc ON t1(a,b,c);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;\n} {/INDEX t1abc /}\ndo_execsql_test whereH-2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c>=? ORDER BY c;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-3.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1cd ON t1(c,d);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-3.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-4.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1cd ON t1(c,d);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-4.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-5.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n  CREATE INDEX t1cd ON t1(c,d);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-5.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-6.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n  CREATE INDEX t1cd ON t1(c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-6.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-7.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n  CREATE INDEX t1cd ON t1(c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-7.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\ndo_execsql_test whereH-8.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e);\n  CREATE INDEX t1abcd ON t1(a,b,c,d);\n  CREATE INDEX t1cd ON t1(c,d);\n  CREATE INDEX t1bcd ON t1(b,c,d);\n\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {/INDEX t1abcd /}\ndo_execsql_test whereH-8.2 {\n  EXPLAIN QUERY PLAN\n  SELECT d FROM t1 WHERE a=? AND b=? AND c=? AND d>=? ORDER BY d;\n} {~/TEMP B-TREE FOR ORDER BY/}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereI.test",
    "content": "# 2014-03-31\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# The focus of this file is testing the OR optimization on WITHOUT ROWID \n# tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix whereI\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;\n  INSERT INTO t1 VALUES(1, 'a', 'z');\n  INSERT INTO t1 VALUES(2, 'b', 'y');\n  INSERT INTO t1 VALUES(3, 'c', 'x');\n  INSERT INTO t1 VALUES(4, 'd', 'w');\n  CREATE INDEX i1 ON t1(b);\n  CREATE INDEX i2 ON t1(c);\n}\n\ndo_eqp_test 1.1 {\n  SELECT a FROM t1 WHERE b='b' OR c='x'\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX i1 (b=?)} \n  0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}\n}\n\ndo_execsql_test 1.2 {\n  SELECT a FROM t1 WHERE b='b' OR c='x'\n} {2 3}\n\ndo_execsql_test 1.3 {\n  SELECT a FROM t1 WHERE b='a' OR c='z'\n} {1}\n\n#----------------------------------------------------------------------\n# Try that again, this time with non integer PRIMARY KEY values.\n#\ndo_execsql_test 2.0 {\n  CREATE TABLE t2(a, b, c, PRIMARY KEY(a)) WITHOUT ROWID;\n  INSERT INTO t2 VALUES('i', 'a', 'z');\n  INSERT INTO t2 VALUES('ii', 'b', 'y');\n  INSERT INTO t2 VALUES('iii', 'c', 'x');\n  INSERT INTO t2 VALUES('iv', 'd', 'w');\n  CREATE INDEX i3 ON t2(b);\n  CREATE INDEX i4 ON t2(c);\n}\n\ndo_eqp_test 2.1 {\n  SELECT a FROM t2 WHERE b='b' OR c='x'\n} {\n  0 0 0 {SEARCH TABLE t2 USING INDEX i3 (b=?)} \n  0 0 0 {SEARCH TABLE t2 USING INDEX i4 (c=?)}\n}\n\ndo_execsql_test 2.2 {\n  SELECT a FROM t2 WHERE b='b' OR c='x'\n} {ii iii}\n\ndo_execsql_test 2.3 {\n  SELECT a FROM t2 WHERE b='a' OR c='z'\n} {i}\n\n#----------------------------------------------------------------------\n# On a table with a multi-column PK.\n#\ndo_execsql_test 3.0 {\n  CREATE TABLE t3(a, b, c, d, PRIMARY KEY(c, b)) WITHOUT ROWID;\n\n  INSERT INTO t3 VALUES('f', 1, 1, 'o');\n  INSERT INTO t3 VALUES('o', 2, 1, 't');\n  INSERT INTO t3 VALUES('t', 1, 2, 't');\n  INSERT INTO t3 VALUES('t', 2, 2, 'f');\n\n  CREATE INDEX t3i1 ON t3(d);\n  CREATE INDEX t3i2 ON t3(a);\n\n  SELECT c||'.'||b FROM t3 WHERE a='t' OR d='t'\n} {\n  2.1 2.2 1.2\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereJ.test",
    "content": "# 2014-06-06\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements regression tests for a complex\n# query planning case.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix whereJ\n\nifcapable !stat4 {\n  finish_test\n  return\n}\n\ndo_execsql_test whereJ-1.0 {\n  CREATE TABLE tx1 (\n    est,\n    cid,\n    sid,\t\n    fid,\n    aid,\n    edate,\n    rstat,\n    ftype,\n    cx,\n    fyear,\n    fp,\n    acode,\n    a1,\n    curx,\n    tdate,\n    gstat,\n    trgtpx,\n    effdate,\n    adate,\n    ytime,\n    mstat\n  );\n  CREATE INDEX ix0 on tx1(a1,curx,aid,cid,sid,ftype,fp,fyear DESC,edate DESC,fid);\n  CREATE INDEX ix1 on tx1(a1,curx,aid,ftype,fp,fyear DESC,fid,edate DESC,cid,sid);\n  CREATE INDEX ix2 on tx1(a1,curx,cid,sid,ftype,fp,fyear DESC,edate DESC,aid,fid);\n  CREATE INDEX ix3 on tx1(a1,curx,fid,ftype,fp,fyear DESC,cid,sid,aid,edate DESC);\n  CREATE INDEX ix4 on tx1(a1,curx,ftype,cid,sid,aid,edate DESC,fid,fp,fyear DESC);\n  CREATE INDEX ix5 on tx1(a1,curx,ftype,aid,fid,cid,sid,edate DESC,fp,fyear DESC);\n  CREATE INDEX ix6 on tx1(ftype,fp,fyear DESC,cid,sid,edate DESC,a1,fid,aid,curx,est,rstat,cx,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);\n  CREATE INDEX ix7 on tx1(cid,a1,curx,sid,ftype,est,fid,aid,edate,rstat,cx,fyear,fp,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);\n  CREATE INDEX ix8 on tx1(cid,sid,edate DESC,aid,est);\n  CREATE INDEX ix9 on tx1(aid,edate DESC,a1,curx);\n} {}\ndo_execsql_test whereJ-1.1 {\n  ANALYZE sqlite_master;\n  DELETE FROM sqlite_stat1;\n  DELETE FROM sqlite_stat4;\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix9','11680827 289 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix8','11680827 286 250 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix7','11680827 286 194 98 88 83 18 7 6 2 2 2 2 2 2 2 2 2 2 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix6','11680827 5840414 5840414 5840414 240 212 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix5','11680827 5840414 2920207 1668690 114 90 8 8 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix4','11680827 5840414 2920207 1668690 92 83 9 2 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix3','11680827 5840414 2920207 2048 1835 1835 1835 12 11 8 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix2','11680827 5840414 2920207 98 88 83 83 83 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix1','11680827 5840414 2920207 117 114 114 114 90 2 2 2');\n  INSERT INTO sqlite_stat1 VALUES('tx1','ix0','11680827 5840414 2920207 117 9 9 9 9 9 2 2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6736 21 21 21 1','29210 29404 29404 29404 29424','44 12184 13020 13079 29424',X'06030409080416C1150133512800B01FCA');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6658 24 21 21 1','452220 453273 453276 453276 453296','622 226258 235279 236774 453296',X'06030409080416F34501332ADC00AA1BD3');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','820 2 2 2 1','1297771 1297869 1297869 1297869 1297869','1964 681724 711020 715822 1297869',X'06030409080317875501332C6C55AF4D');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','26985 2216 2216 2216 1','1797607 1797782 1797782 1797782 1799997','3162 970307 1008879 1016089 1799997',X'0603040809041A08040132401A0099A334');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','10434 19 17 17 1','2118117 2120403 2120405 2120405 2120421','3815 1136110 1181459 1190207 2120421',X'0603040908041AD36901332CD000861A2F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','437 1 1 1 1','2595414 2595739 2595739 2595739 2595739','5005 1409452 1464066 1475163 2595739',X'0603040808031CE7FD01317FD46BFBCC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','12619 38 38 38 1','2595957 2600212 2600212 2600212 2600249','5007 1410347 1464961 1476068 2600249',X'0603040808041CE87E01328F61008CE96A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7534 23 18 18 1','3329985 3334890 3334895 3334895 3334912','6901 1834013 1902216 1917268 3334912',X'060304090804244E1901328F59008CAA39');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','5693 1 1 1 1','3891665 3893609 3893609 3893609 3893609','8357 2164400 2245393 2263185 3893609',X'0603040808043063B70132B66800A28A43');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','44405 2588 2223 1527 1','4220255 4221633 4221998 4222694 4224220','9221 2354858 2441973 2461511 4224220',X'0603040909043377630133517A00B0DE4F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6883 32 28 28 1','4423918 4429926 4429930 4429930 4429957','9690 2452276 2543443 2563995 4429957',X'06030409080434F46801328F5C008CC3DA');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6974 27 26 26 1','5048404 5051129 5051130 5051130 5051155','11703 2817010 2920184 2944013 5051155',X'0603040908043C1C5C0132DEA5009F7473');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','476 2 2 2 1','5191322 5191479 5191479 5191479 5191479','12242 2901130 3006663 3031222 5191479',X'0603040908033DC6080132DEA478849A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','627 4 4 4 1','6488823 6489349 6489349 6489349 6489349','16423 3644815 3778857 3809866 6489349',X'0603040808035AA00E0131F4AE342150');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','145 2 2 1 1','7787091 7787218 7787218 7787219 7787219','20223 4343720 4510110 4547961 7787219',X'0603040809037254890132189C703706');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','20 1 1 1 1','9085074 9085089 9085089 9085089 9085089','25315 5033102 5230788 5275692 9085089',X'06040408080300EAE6CA01326657620652');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','229621 6135 5934 5934 1','9507353 9572696 9572696 9572696 9576801','27189 5255584 5463962 5511784 9576801',X'06040408080300F2FA440132DF1A7D1A60');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6376 24 22 22 1','10381524 10382938 10382940 10382940 10382959','30519 5581705 5804515 5856651 10382959',X'06040409080400F9DBF3013305AC00A688A4');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7761 45 9 9 1','10569039 10572476 10572512 10572512 10572520','31455 5661599 5888691 5941811 10572520',X'06040409080400FB31560132DDD800A05DF5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','8382 37 37 37 1','10866664 10867565 10867565 10867565 10867601','33475 5809193 6042611 6097741 10867601',X'06040409080400FFA4A701332A0E00A93957');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','76136 4099 3018 3018 1','11283107 11308143 11309224 11309224 11312241','37001 6022861 6264510 6322923 11312241',X'060404090804010B0A5C0133517200B0E8E0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','23472 2188 2188 2181 1','11365285 11380281 11380281 11380288 11382468','37055 6026680 6268909 6327509 11382468',X'060404080904010B3C6701332B2E00AA4374');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','59591 4087 4073 4 1','11415316 11448759 11448773 11452842 11452845','37350 6040743 6283483 6342389 11452845',X'060404090904010BFA810133512800B010AE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','43891 3029 3021 4 1','11598477 11622881 11622889 11625906 11625909','39110 6107644 6353109 6413914 11625909',X'0604040909040113B9960133512800B01235');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7340 4977 19 1 1 1','206533 206533 208739 208757 208757 208757','125 164 111403 207397 207399 208757',X'070308040407030187840132B54B0101A0D1401C0000000000004C87E5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8877 8788 45 1 1 1','1221375 1221375 1224509 1224553 1224553 1224553','931 1117 679933 1216705 1216722 1224553',X'07030804040703018D3F0133023D010B9B67401C0000000000007A99EF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7204 7204 39 1 1 1','1240162 1240162 1242572 1242610 1242610 1242610','942 1131 688420 1234655 1234672 1242610',X'07030804040703018D4F0132DB820105D324401C0000000000007EC569');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9608 9608 44 1 1 1','1264939 1264939 1266529 1266572 1266572 1266572','952 1145 699518 1258423 1258440 1266572',X'07030804040704018D61013305B9010D3CEB406E8000000000000081E17A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','6636 6636 1 1 1 1','1294580 1294580 1297869 1297869 1297869 1297869','964 1159 713121 1289522 1289540 1297869',X'07030804030704018D7801328F693482A2403400000000000000A26728');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7822 6629 26 1 1 1','2375708 2375708 2381333 2381358 2381358 2381358','3423 3833 1371902 2366527 2366559 2381358',X'0703080403070301B1F501317F16403B7B403F00000000000060D67A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1403 1303 5 1 1 1','2594767 2594767 2595737 2595739 2595739 2595739','3914 4427 1512042 2580073 2580114 2595739',X'0703080403070301B6480131CC18558082407120000000000029CC12');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7901 6067 26 1 1 1','3424107 3424107 3425939 3425964 3425964 3425964','5872 6630 2032411 3406550 3406594 3425964',X'0703080404070401C3F90132B7A100FDCC04403E00000000000000A014CE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7483 6161 22 1 1 1','3549446 3549446 3555223 3555244 3555244 3555244','5932 6752 2099309 3535259 3535304 3555244',X'0703080403070301C4490131573F4104F8403400000000000067FD1E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','12076 8263 37 1 1 1','3558079 3558079 3560036 3560072 3560072 3560072','5935 6758 2101989 3540078 3540123 3560072',X'0703080404070301C44E0132DD0901076DA9404200000000000076F994');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1123 1113 1 1 1 1','3892913 3892913 3893609 3893609 3893609 3893609','6594 7611 2305483 3871711 3871770 3893609',X'0703080403070301CA280131CA1C215083401C00000000000071F6B2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9344 7315 41 1 1 1','4213510 4213510 4219434 4219474 4219474 4219474','7200 8390 2503024 4196141 4196204 4219474',X'0703080404070301CE8C01317DE800FE4E8B4034000000000000458317');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8062 3291 1 1 1 1','5037060 5037060 5040350 5040350 5040350 5040350','10201 11915 3045602 5012912 5012997 5040350',X'070308040307030213B20130B83A16DF86403600000000000028F8CD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9125 2926 1 1 1 1','5046490 5052665 5055590 5055590 5055590 5055590','10203 11926 3055524 5028097 5028182 5055590',X'070302040307030213B5232A013107F01745AF40330000000000002B57DE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','591 591 1 1 1 1','5190991 5190991 5191479 5191479 5191479 5191479','10649 12426 3145181 5163206 5163296 5191479',X'070308040307030244AD0131315217C1CD401C00000000000003BC32');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 4689 1 1 1 1','6112248 6112248 6116936 6116936 6116936 6116936','13780 16308 3748958 6083681 6083797 6116936',X'0703080403070402A9D1013108B531A21C401C0000000000000092F5C6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7569 7381 28 1 1 1','6280084 6280084 6281842 6281869 6281869 6281869','14559 17217 3856803 6247722 6247841 6281869',X'0703080404070302C14C0132DBF101044CC7401C00000000000074FB16');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8289 7047 28 1 1 1','6290764 6290764 6296854 6296881 6296881 6296881','14569 17229 3863206 6262658 6262777 6296881',X'0703080403070302C16401317CC348B670401C0000000000006824BB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2209 2209 1 1 1 1','6489075 6489075 6489349 6489349 6489349 6489349','15377 18147 3986912 6454194 6454318 6489349',X'0703080403070402EA5901332A656C6F5E401C00000000000000AE7C03');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 6799 1 1 1 1','7314420 7314420 7321218 7321218 7321218 7321218','18403 21722 4532963 7281695 7281847 7321218',X'07030804030703049EE501310667176DC940438000000000005ED2B5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7163 7001 31 1 1 1','7652849 7652849 7658600 7658630 7658630 7658630','19462 22956 4750159 7617449 7617608 7658630',X'070308040407030503EB01317DEF010ADD3F402800000000000061C3EF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1433 1433 2 1 1 1','7785842 7785842 7787219 7787219 7787219 7787219','20001 23575 4834605 7745315 7745477 7787219',X'07030804030703055010013156D81B11AC404380000000000004A313');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2247 2247 1 1 1 1','9083272 9083272 9085089 9085089 9085089 9085089','24940 29143 5668423 9036693 9036887 9085089',X'070308040307031A620A01323EEB5CE39C406FE000000000006F8177');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','107 107 5 1 1 1','10382912 10382912 10382957 10382959 10382959 10382959','31251 36297 6541362 10329764 10330008 10382959',X'0704080403070400955501013350516AA9D0406060000000000000884648');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7340 4770 4527 3331 3331 970 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','206533 206533 206533 206533 206533 206596 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565','125 202 402 512 560 6209 20696 25885 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 207565',X'1703080808080704030408030808010308070808080803018784401C000000000000024FD353493F8801317E4700FFFF0F00FFFFC0F869E0000000002642C5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8877 4669 71 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1221375 1225583 1230181 1230249 1230249 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251','931 1504 2992 3495 3751 39629 120561 147424 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1230251',X'1703090902080704030408090808010108070404040804018D3F03E8405680000000000000822B981EB823013351F00F0C4086E00000000000013351F0013351F053870D7500B22A8C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7204 4801 193 193 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1240162 1240162 1244770 1244770 1244959 1244961 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962','942 1520 3024 3531 3791 40098 122274 149540 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1244962',X'1703080908010703030408030808010308070408040803018D4F07406FE000000000000602CF16DE05013303C300FFFF0300FFFFC0F869E000000000013303C3008000004BD756');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9608 6098 5910 5910 5910 2149 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1264939 1264939 1264939 1264939 1264939 1265217 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365','952 1536 3055 3576 3841 40616 124132 151876 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1267365',X'1703080808080704030408090808010101070404040803018D61401C0000000000000131374D1726AB0132DD780F0C0540390000000000000132DD780132DD784E2789C6190CA9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','6636 4411 4237 4237 4237 33 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1294580 1294580 1294580 1294580 1294580 1297842 1297862 1297862 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','964 1557 3097 3622 3888 41246 126538 154868 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1297869',X'1703080808080703030408090808010308070808080803018D7840420000000000007332F1227B5901321AF80800FFFF40260000000000006D0CEB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7822 4817 260 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2375708 2375708 2380265 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524','3423 5117 10120 11184 11775 86237 242937 294878 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2380524',X'170308090308070304040803080801030807040408080401B1F501831C405C40000000000077646800EAD44C0132697000FFFF0300FFFFC0F869E0000000000132696F0132696F0094935E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1403 1022 82 74 74 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2594767 2594767 2595707 2595707 2595707 2595708 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','3914 5817 11518 12879 13613 98100 278304 342850 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2595739',X'170308090808070303040803080801030807080808080301B648405C400000000000038EAC243F770131A6F700FFFF0E00FFFFC0F869E0000000005C8664');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7901 5298 291 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3424107 3424107 3429114 3429350 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404','5872 8944 17727 19769 20846 145206 401995 498360 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3429404',X'170308090201070404040803080801030807040808080401C3F9232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083157B');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7483 5407 230 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3549446 3549446 3554623 3554845 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852','5932 9041 17921 20139 21264 149060 417718 520064 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3554852',X'170308090201070404040803080801030807040808080401C449232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083162A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','12076 8365 7981 5546 5546 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3558079 3558079 3558079 3558079 3558079 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624','5935 9046 17930 20154 21279 149235 418443 521109 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3563624',X'170308080808070303040803080801030107040408080301C44E4074300000000000029EB13BB98E01328EFE00FFFF0E00FFFF0AC0F869E00000000001328F0001328F0071D802');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1123 916 875 875 875 93 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3892913 3892913 3892913 3892913 3892913 3893531 3893602 3893602 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','6594 10057 19942 22653 23964 165533 468498 587524 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3893609',X'170308080808070403040802080801030107040404080301CA28403F00000000000000832DC71933330132DB8800FC0F00FFFF054050C000000000000132DB870132DB8A4D5E35A2107205');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9344 6359 6022 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','4213510 4213510 4213510 4219523 4219523 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531','7200 11025 21872 25036 26543 181203 517345 652858 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4219531',X'170308080308070303040803080801030807080808080301CE8C0186A0403F00000000000002C2142F19870131554100FFFF0F00FFFFC0F869E0000000000687F7');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8062 4993 241 53 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5037060 5037060 5041812 5042000 5042051 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052','10201 15484 30736 35196 37326 231854 654010 829510 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5042052',X'17030809020107030404080308080103080704080808030213B2245407406FE0000000000002C0AA00F6ABA101332A7E00FFFF0300FFFFC0F869E00000000001332A7E5287C0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9125 5761 264 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5046490 5046490 5051987 5052246 5052246 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250','10203 15488 30744 35230 37365 232178 654964 830718 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5052250',X'17030809030807030304080308080103080708080808030213B501831F406FE00000000000029E627136F901328DD500FFFF0300FFFFC0F869E000000000290DD6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','591 591 566 566 566 27 18 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5190991 5190991 5190991 5190991 5190991 5191461 5191464 5191474 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','10649 16115 31973 36593 38793 239550 673441 853755 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5191479',X'17030808080807030404080108080101080708080808040244AD4045800000000000029E6200EAE8740132690D0A0F0C402E00000000000000941EAF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 3728 83 16 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6112248 6115901 6119546 6119613 6119613 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628','13780 20707 41067 47538 50438 296473 834203 1056686 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6119628',X'170309090208070304040809080801010807040404080402A9D12328407360000000000002172300EABCFF0133517F0F0C404AA6665E02EA960133517F01335239538BC5C1008B5EC9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7569 5785 274 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6280084 6280084 6285595 6285867 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868','14559 21811 43240 50020 53057 307264 862871 1092992 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6285868',X'170308090301070404040803080801030807040808080302C14C01832707405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329461E5109');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8289 5734 266 33 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6290764 6290764 6296232 6296465 6296495 6296495 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497','14569 21827 43272 50056 53096 307563 864043 1094585 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6296497',X'170308090201070404040803080801030807040808080402C164232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600A90415');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2209 1450 1369 1369 1369 597 13 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6489075 6489075 6489075 6489075 6489075 6489139 6489344 6489344 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','15377 22998 45584 52641 55837 319564 895653 1134252 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6489349',X'170308080808070303040802080801030807040404080302EA59401C0000000000000D4B201AD8B30132DF0400FC0600FFFF40180000000000000132DF040132DF054EBA338714FBBA');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 5446 171 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7314420 7314420 7319695 7319855 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865','18403 27319 54152 62541 66337 369851 1032180 1306261 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7319865',X'1703080902010703030408030808010308070408080804049EE503E907405C400000000000029EC32E97BE0133061F00FFFF0300FFFFC0F869E0000000000133061F00A9ECEF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7163 4782 209 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7652849 7652849 7657422 7657626 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630','19462 28830 57147 65962 69945 388539 1084446 1372423 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7657630',X'17030809020107040404080308080103080704080808040503EB03EA07405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600831554');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1433 582 571 571 571 15 15 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7785842 7786693 7786693 7786693 7786693 7787208 7787208 7787208 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','20001 29582 58632 67649 71736 396840 1107204 1400830 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7787219',X'1703090808080703040408090808010108070404040804055010406E80000000000001C7A600FC429201332D890F0C402C00000000000001332D890133505352D7248A008775D8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2247 682 657 657 657 117 45 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1','9083272 9084837 9084837 9084837 9084837 9085088 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','24940 36384 72113 82665 87632 474987 1318830 1664527 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9085089',X'17030908080807030304080208080103010704040408031A620A403E00000000000001C3D332CF850132DE9D00FC0200FFFF054050E000000000000132DE9D0132DE9D4E8C092E790553');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','107 77 69 69 69 11 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1','10382912 10382942 10382942 10382942 10382942 10382952 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','31251 45639 90416 102896 109225 567280 1544395 1943661 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10382959',X'170409080808070303040809080801010807040404080300955501403E000000000000029E686E250B01332D220F0C402E00000000000001332D220133504E52CFCF4F21CD7F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7337 4975 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 206462 206462 210789 210789 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807','0 0 0 125 164 112407 128579 207456 209489 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 210807',X'170808080308040804030807080301030807080808080301878401317F26024FD3531E2DAF404200000000000000FFFF0200FFFFC0F869E0000000002642C4');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8874 8785 45 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1221012 1221012 1224145 1224165 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189','0 0 0 931 1117 679896 773861 1207582 1216653 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1224189',X'1708080803080409040408070809010308070404040803018D3F0133023D01940C420106B14D40420000000000000F00FFFF4070E000000000000133023D0133023D4F2053654AE525');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7200 7200 39 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1239793 1239793 1242199 1242223 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237','0 0 0 942 1131 688381 783660 1225441 1234602 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1242237',X'1708080803080409040308070809010301070404040804018D4F0132DB820113FAB92F19C5401C0000000000000F00FFFF0F403A0000000000000132DB820132DB824D542A4F009B5C72');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9606 9606 44 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1264560 1264560 1266149 1266168 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192','0 0 0 952 1145 699479 796008 1249062 1258369 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1266192',X'1708080803080409040308070809010101070404040803018D61013305B9017CDF4916F8B140280000000000000F0C0A403600000000000001330557013305B9507EA8DD212E79');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 6635 6635 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1294199 1294199 1297868 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','0 0 0 964 1159 713241 812408 1280435 1289849 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1297869',X'1708080803080409030308070803010308070808080803018D78013267DC0EF747387106403F00000000000000FFFF0F00FFFFC0F869E00000000006B968');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7815 6624 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2374939 2374939 2380559 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584','0 0 0 3423 3833 1371803 1539928 2350493 2366415 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2380584',X'170808080308040903030807080301030807080808080301B1F501317F160DDEA51C46AB405280000000000000FFFF0F00FFFFC0F869E0000000006ADDA9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3595 3459 10 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2595336 2595336 2595734 2595737 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','0 0 0 3918 4433 1512586 1693312 2557025 2580917 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2595739',X'170808080308040903030807080101010107040404080301B64F01332ACC029E833D19084028000000000000320F0C054074A0000000000001332A0901332ACC518A316F1F30D6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7894 6061 26 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3422592 3422592 3424418 3424434 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443','0 0 0 5872 6630 2032185 2267240 3366727 3406294 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3424443',X'170808080308040904030807080101030807040404080401C3F90132B7A100D6FD7F6CE97F4070500000000000100F00FFFF40560000000000000132B7310132DB2D4D3F72D9009AE8EE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7479 6158 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3547845 3547845 3553619 3553619 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640','0 0 0 5932 6752 2099067 2343370 3491679 3534981 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3553640',X'170808080308040804030807080301030807080808080301C4490131573F008E7AC03077E0403E00000000000000FFFF0F00FFFFC0F869E00000000065B45A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 12068 8257 37 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3556474 3556474 3558426 3558446 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462','0 0 0 5935 6758 2101744 2346448 3496404 3539797 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3558462',X'170808080308040904030807080201010107040404080301C44E0132DD09016891C11788EB404200000000000000FC0F0C0F400199999999999A0132DD090132DD094DE5DCE3763299');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1510 1497 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3892149 3892149 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','0 0 0 6596 7614 2306358 2572095 3823194 3873232 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3893609',X'170808080308040803030807080301030807080808080301CA2E01312E3A038EE6257265400000000000000000FFFF0600FFFFC0F869E00000000032518F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9341 7313 41 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 4211282 4211282 4217204 4217243 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244','0 0 0 7200 8390 2502650 2792131 4139620 4195704 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4217244',X'170808080308040903030807080301030807080808080301CE8C01317DE8029E9D3B6D23403E00000000000000FFFF0F00FFFFC0F869E00000000008EF7D');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8055 3290 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5033936 5033936 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225','0 0 0 10201 11915 3045026 3383481 4941323 5012256 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5037225',X'17080808030804090303080708030803080708080808030213B20130B83A018A7516DF86403600000000000000FFFF00FFFFC0F869E00000000028F8CD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9117 2923 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5043358 5049528 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450','0 0 0 10203 11926 3054947 3394812 4956408 5027439 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5052450',X'17080808030204080303080708030103080708080808030213B5232A013107F00217231745AF403300000000000000FFFF0200FFFFC0F869E0000000002B57DE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 333 333 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5191271 5191271 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','0 0 0 10672 12452 3147059 3494842 5093162 5165710 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5191479',X'17080808030804080303080708030103080708080808030244F00131CB4201C1C917188E403F00000000000000FFFF0800FFFFC0F869E00000000001C5CB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7374 4684 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6107894 6107894 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577','0 0 0 13780 16308 3748117 4153600 5995776 6082692 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6112577',X'170808080308040803030807080301030807080808080402A9D1013108B5029E6831A21C401C00000000000000FFFF0200FFFFC0F869E0000000000092F5C6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7562 7376 28 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6275521 6275521 6277274 6277291 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301','0 0 0 14559 17217 3855913 4271255 6156622 6246677 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6277301',X'170808080308040904030807080201030107040404080302C14C0132DBF100832DC739FF53403F00000000000000FC0F00FFFF05402C0000000000000132DBF10132DBF34D89B7AA1114CB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8282 7043 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6286191 6286191 6292277 6292277 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304','0 0 0 14569 17229 3862314 4278722 6171137 6261611 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6292304',X'170808080308040804030807080301030807080808080302C16401317CC301B5AA4A1AB270405680000000000000FFFF0F00FFFFC0F869E00000000048FD4C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3101 3101 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6486495 6486495 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 15379 18149 3988504 4417216 6363796 6457879 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6489349',X'170808080308040803030807080301030807080808080302EA6601317F7301C3EB17C4CE401C00000000000000FFFF0F00FFFFC0F869E000000000398198');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7379 6798 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7308682 7308682 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479','0 0 0 18403 21722 4531809 5008068 7172304 7280343 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7315479',X'1708080803080408040308070803010308070808080803049EE501310667008390D0176DC9404380000000000000FFFF0500FFFFC0F869E0000000005ED2B5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 211 211 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7787150 7787150 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 0 0 20027 23602 4837427 5341824 7634169 7750020 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7787219',X'17080808030804080303080708090103080704040808030550B30132B73501A79C17C3D840340000000000000F00FFFF40140000000000000132B6D00132B7400D1DB9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 26 26 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 9085083 9085083 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','0 0 0 24964 29171 5671673 6246216 8904392 9042441 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9085089',X'17080808030804080303080708030103080708080808031AA25C0131CA197A6D831B1D84401C00000000000000FFFF0F00FFFFC0F869E00000000071E307');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1261 1261 9 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 10381872 10381872 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','0 0 0 31297 36344 6545140 7198586 10180602 10336983 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10382959',X'17080808040804080303080708010101080708080808030095A4C401321BB603010141073C401C000000000000080F0C40308000000000007E55BE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','12287 12287 12287 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','11668540 11668540 11668540 11672111 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127','1 1 1 43128 49243 7431284 8170740 11452355 11624787 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11672127',X'1701080803020408040409070803010308070408040804070267C127130133041E00AB540900E64074405C40000000000000FFFF0300FFFFC0F869E0000000000133041E0080000000A3EE16');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24157 24157 29 29 1 1 1 1','0 0 0 1236590 1236590 1251799 1251799 1251827 1251827 1251827 1251827','0 0 0 3120 4771 71527 72755 1238782 1238782 1238782 1251827',X'0C08080803040308040808031A080400FF5594029BB30131CD372B1368');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 1209 1209 129 129 1 1 1 1','0 0 0 1296873 1296873 1297744 1297744 1297869 1297869 1297869 1297869','0 0 0 3203 4902 74577 75831 1284645 1284645 1284645 1297869',X'0C08080803030308040808041A215F04C9D901B0A30131066F0087162A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 12129 9261 428 428 1 1 1 1','0 0 0 1790076 1790076 1790076 1790076 1790503 1790503 1790503 1790503','0 0 0 4938 7561 108783 110860 1774402 1774402 1774402 1790503',X'0C08080803030308040808031CE87E029E6B018700013219C1373BA8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 273 273 5 5 1 1 1 1','0 0 0 2595625 2595625 2595738 2595738 2595739 2595739 2595739 2595739','0 0 0 7863 12132 166423 169877 2575172 2575172 2575172 2595739',X'0C08080803030308040808042F020502DA0E02C73A0133049700A711F8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 7735 7735 29 29 1 1 1 1','0 0 0 2924165 2924165 2929754 2929754 2929782 2929782 2929782 2929782','0 0 0 9123 14045 191316 195293 2907742 2907742 2907742 2929782',X'0C080808030403080408080333776300FF559475928D013329435A824F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 360 229 27 27 1 1 1 1','0 0 0 3893374 3893505 3893605 3893605 3893609 3893609 3893609 3893609','0 0 0 13912 21124 273265 278784 3866425 3866425 3866425 3893609',X'0C08080803030308040808044717710E070B01E88F0131A5B80098D0A5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 683 671 32 32 1 1 1 1','0 0 0 5191447 5191459 5191477 5191477 5191479 5191479 5191479 5191479','0 0 0 20361 30776 381171 389104 5158962 5158962 5158962 5191479',X'0C08080803030308040808037370D10F00290188450132B537354C5E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 213354 213354 113 113 1 1 1 1','0 0 0 6102233 6102233 6155183 6155183 6155295 6155295 6155295 6155295','0 0 0 26812 39489 472780 483115 6119281 6119281 6119281 6155295',X'0C080808040403080408080300F2FA4400FF5594019B6D01324067714AE8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 3675 3675 241 241 1 1 1 1','0 0 0 6486701 6486701 6489287 6489287 6489349 6489349 6489349 6489349','0 0 0 28380 41383 502486 513750 6452691 6452691 6452691 6489349',X'0C080808040304080408080300F6ABAC6C967D009F84B60132DBDD155A2A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24063 24063 38 38 1 1 1 1','0 0 0 7080911 7080911 7102380 7102380 7102417 7102417 7102417 7102417','0 0 0 35724 49844 582928 595393 7065320 7065320 7065320 7102417',X'0C0808080404040804080803010B0A5C00FF559400CCD3EE0133294559DDCD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 20284 20284 38 38 1 1 1 1','0 0 0 7107237 7107237 7126606 7126606 7126643 7126643 7126643 7126643','0 0 0 35764 49885 586473 599030 7089546 7089546 7089546 7126643',X'0C0808080404040804080803010B3C6700FF55940114CE73013329432225CC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 11855 11855 3 1 1 1 1 1','0 7173953 7173953 7665258 7665258 7672559 7672561 7672561 7672561 7672561 7672561','0 1 2 64320 91213 1077048 1100563 7630436 7630436 7630436 7672561',X'0C080908040403020408080400F2FA4400FF559405DD0A23280132DD75009F3468');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 4 4 1 1 1 1 1 1','0 7173953 7173953 7787218 7787218 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74034 102405 1189484 1215034 7745001 7745001 7745001 7787219',X'0C0809080403040804080803010DDABE0368B700FEBFF60133068F22D1E5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 12263 1433 1433 1 1 1 1 1 1','0 7173953 7792016 7797877 7797877 7799309 7799309 7799309 7799309 7799309 7799309','0 1 3 76213 104626 1201397 1227113 7757087 7757087 7757087 7799309',X'0C08090104040408040808030700F2FA4400FF559401C3969E013329461E5052');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8657 8657 605 605 1 1 1 1','7804279 7804279 7804279 8360485 8360485 8364643 8364643 8365247 8365247 8365247 8365247','1 2 4 77865 106290 1217527 1243460 8321843 8321843 8321843 8365247',X'0C09080803030308040808031AD369021FFC0DC36E01328E2F3D9128');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 33421 33421 57 26 1 1 1 1','7804279 7804279 7804279 8873934 8873934 8891008 8891039 8891064 8891064 8891064 8891064','1 2 4 78914 107340 1231432 1257622 8846644 8846644 8846644 8891064',X'0C090808030403020408080433776300FF55940CE166232801332A1800836DFB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 2182 2182 94 94 1 1 1 1','7804279 7804279 7804279 9083187 9083187 9085006 9085006 9085089 9085089 9085089 9085089','1 2 4 79307 107733 1237174 1263453 9040316 9040316 9040316 9085089',X'0C09080803030308040808033AC92C021FFC04AF670132B5FC38DBD0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 6023 6023 50 50 1 1 1 1','7804279 7804279 7804279 9393480 9393480 9395815 9395815 9395864 9395864 9395864 9395864','1 2 4 79973 108402 1245294 1271679 9350536 9350536 9350536 9395864',X'0C09080803030308040808034CDD9A7E1C2301C30D0132908703CC11');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 79 79 6 6 1 1 1 1','7804279 7804279 7804279 10382946 10382946 10382956 10382956 10382959 10382959 10382959 10382959','1 2 4 82501 110947 1276304 1303221 10336296 10336296 10336296 10382959',X'0C090808040303080408080400E9A10A0CC31602A47201332C6C00ABCD60');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8251 8251 280 280 1 1 1 1','7804279 7804279 7804279 11067468 11067468 11072690 11072690 11072969 11072969 11072969 11072969','1 2 4 85529 113989 1307763 1335183 11025935 11025935 11025935 11072969',X'0C090808040404080408080300FFA4A7008A66AD0089DBDD0132B5FF6AE2B8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 44772 44772 58 58 1 1 1 1','7804279 7804279 7804279 11268036 11268036 11269261 11269261 11269318 11269318 11269318 11269318','1 2 4 87132 115597 1321101 1348736 11222284 11222284 11222284 11269318',X'0C0908080404030804080804010B0A5C00FF5594018ACD0133294300B0E291');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 53775 53775 37 19 1 1 1 1','7804279 7804279 7804279 11330929 11330929 11355027 11355045 11355063 11355063 11355063 11355063','1 2 4 87335 115800 1327560 1355328 11308029 11308029 11308029 11355063',X'0C0908080404030204080803010BFA8100FF5594026C24232801332B2E1F8BB5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 39430 39430 39 39 1 1 1 1','7804279 7804279 7804279 11458789 11458789 11476757 11476757 11476795 11476795 11476795 11476795','1 2 4 88502 116970 1340484 1368500 11429761 11429761 11429761 11476795',X'0C09080804040308040808030113B99600FF559402F6AF01332B2E1F8A54');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 157757 157736 5317 5317 1 1 1 1 1 1','7804279 11523070 11523070 11652823 11652823 11658139 11658139 11658139 11658139 11658139 11658139','1 3 5 100045 128561 1480184 1510648 11611105 11611105 11611105 11658139',X'0C0909080404040204080803010BFA8100FF559402594CCB2328013351E85B0F5D');\n} {}\ndo_execsql_test whereJ-1.3 {\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4748 4629 308 1 1 1 1 1','0 0 0 634880 634880 639119 639426 639426 639426 639426 639426','0 0 0 779 907 26900 633919 633920 633920 633920 639426',X'0C0808080308040403080803018C4A00F450A80132671F029EAC271DA5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4608 4608 246 1 1 1 1 1','0 0 0 752580 752580 755578 755823 755823 755823 755823 755823','0 0 0 936 1089 31876 749384 749385 749385 749385 755823',X'0C0808080308030403080804018D4F347FD20131547D018A7500936FE2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4776 4776 240 1 1 1 1 1','0 0 0 762070 762070 764545 764784 764784 764784 764784 764784','0 0 0 940 1097 32187 758274 758275 758275 758275 764784',X'0C0808080308030403080804018D562E0EAB0131A68F029E9300994D36');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5910 5910 257 1 1 1 1 1','0 0 0 771353 771353 772646 772902 772902 772902 772902 772902','0 0 0 946 1103 32460 766333 766334 766334 766334 772902',X'0C0808080308030404080803018D611726F40130E13C00822B980302A0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 1834 1834 46 1 1 1 1 1','0 0 0 1296866 1296866 1297832 1297869 1297869 1297869 1297869 1297869','0 0 0 2621 2842 56932 1287063 1287064 1287064 1287064 1297869',X'0C080808030803040308080301A6E33010BC01317F2005516E3932DB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5007 3959 317 1 1 1 1 1','0 0 0 2152400 2152400 2153781 2154097 2154097 2154097 2154097 2154097','0 0 0 5683 6304 111431 2139450 2139457 2139457 2139457 2154097',X'0C080808030803040308080301C3F91E114001315549029F74635F36');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4768 4609 397 1 1 1 1 1','0 0 0 2200466 2200466 2200700 2201096 2201096 2201096 2201096 2201096','0 0 0 5714 6370 114266 2186220 2186227 2186227 2186227 2201096',X'0C080808030803040308080401C42217887E01312D72036D5B009AF3F8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5177 4669 264 1 1 1 1 1','0 0 0 2234078 2234078 2235865 2236128 2236128 2236128 2236128 2236128','0 0 0 5743 6422 116499 2221108 2221115 2221115 2221115 2236128',X'0C080808030803040308080401C4491EF49D013155450D4B200091BFB3');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 7981 5546 272 1 1 1 1 1','0 0 0 2239923 2239923 2242583 2242854 2242854 2242854 2242854 2242854','0 0 0 5746 6428 116800 2227775 2227782 2227782 2227782 2242854',X'0C080808030803040308080301C44E2EFF35013109E67764687E36D6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 351 336 15 1 1 1 1 1','0 0 0 2595725 2595725 2595725 2595739 2595739 2595739 2595739 2595739','0 0 0 6747 7717 144364 2578697 2578708 2578708 2578708 2595739',X'0C080808030803040308080401CCC91782C20131CC1902D7C0008E7A4F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 6022 4942 304 1 1 1 1 1','0 0 0 2648510 2648510 2648849 2649152 2649152 2649152 2649152 2649152','0 0 0 6934 7959 149030 2631886 2631900 2631900 2631900 2649152',X'0C080808030803040308080301CE8C17887E01312D6E036D5B424939');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4752 1965 5 1 1 1 1 1','0 0 0 3161780 3161780 3163740 3163744 3163744 3163744 3163744 3163744','0 0 0 9707 11219 194477 3143873 3143896 3143896 3143896 3163744',X'0C08080803080404030808030213B20116290C01332B9D0270102494C2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5497 1880 3 1 1 1 1 1','0 0 0 3167643 3167643 3169520 3169522 3169522 3169522 3169522 3169522','0 0 0 9709 11226 194760 3149632 3149655 3149655 3149655 3169522',X'0C08080803080404040808030213B5010B0A5C0133294500FF55941DCA72');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 2185 2126 134 1 1 1 1 1','0 0 0 3891669 3891669 3893607 3893609 3893609 3893609 3893609 3893609','0 0 0 13596 15952 257364 3869701 3869733 3869733 3869733 3893609',X'0C080808030804040308080302BD5F01010F13013350517B8BF356D913');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5511 5355 345 1 1 1 1 1','0 0 0 3931849 3931849 3931954 3932298 3932298 3932298 3932298 3932298','0 0 0 13793 16188 260160 3908172 3908206 3908206 3908206 3932298',X'0C080808030803040308080402C14C17887E01312D75036D5B009AF4B1');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5468 5115 310 1 1 1 1 1','0 0 0 3939090 3939090 3939894 3940203 3940203 3940203 3940203 3940203','0 0 0 13803 16200 260571 3916034 3916068 3916068 3916068 3940203',X'0C080808030803040308080302C164191E7F0131A4FC0606F30CE25A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5275 4792 252 1 1 1 1 1','0 0 0 4590216 4590216 4591340 4591591 4591591 4591591 4591591 4591591','0 0 0 17456 20455 315887 4563939 4563981 4563981 4563981 4591591',X'0C0808080308030403080804049EE51EB67B01317C5204C9D900AE08CD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 339 339 20 1 1 1 1 1','0 0 0 5191257 5191257 5191475 5191479 5191479 5191479 5191479 5191479','0 0 0 20754 24230 366257 5160652 5160701 5160701 5160701 5191479',X'0C08080803080404030808030CEE9300E50D8D013242BE018A755F6BC3');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 13 13 1 1 1 1 1 1','0 0 0 6489337 6489337 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 29449 33987 481632 6453309 6453378 6453378 6453378 6489349',X'0C08080804080304030808030091B3AB600E9801323F54029F7403EF0C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 618063 10 9 1 1 1 1 1 1','0 7173953 7173953 7787217 7787217 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74978 85458 1107555 7744920 7744997 7744997 7744997 7787219',X'0C0809080408030403080804014F459B48960801332ADC01C7A600AA1BA3');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 12263 17 1 1 1 1 1 1 1','0 7173953 7792016 7795570 7795586 7795586 7795586 7795586 7795586 7795586 7795586','0 1 3 78329 89057 1115864 7753287 7753364 7753364 7753364 7795586',X'0C0809010302040404080804070267C1271300E640740133041E00AB540900A3EE16');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 397 397 46 1 1 1 1 1','7804279 7804279 7804279 9084892 9084892 9085088 9085089 9085089 9085089 9085089 9085089','1 2 4 87584 99143 1159195 9040539 9040616 9040616 9040616 9085089',X'0C090808030804040308080301CBAF00E5C288013351810C390F26671E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 141 141 20 1 1 1 1 1','7804279 7804279 7804279 10382921 10382921 10382951 10382959 10382959 10382959 10382959 10382959','1 2 4 95054 107437 1210217 10336699 10336776 10336776 10336776 10382959',X'0C09080803080304030808030DB5C14114E301332A7E018A751F17C1');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 157757 157736 83 16 1 1 1 1 1 1','7804279 11523070 11523070 11587733 11587800 11587815 11587815 11587815 11587815 11587815 11587815','1 3 5 112412 126326 1332792 11540704 11540781 11540781 11540781 11587815',X'0C090908030204040308080402A9D12328010B92880133517F029E9D008B5B23');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 213279 213279 213279 213279 376 212 101 1 1','0 0 12394 12394 12394 12394 18421 18421 18421 18424 18424','0 0 3 3 3 3 810 1027 1949 18324 18424',X'0C0808030808080308030403018A75018788178574013265FC611E2A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 86515 86515 86515 86515 377 377 377 1 1','0 0 271240 271240 271240 271240 274521 274521 274521 274780 274780','0 0 8 8 8 8 9766 10762 19602 273178 274780',X'0C080803080808030803040401A79C01886F174AEF0132678B00A4AEFF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 193482 193482 193482 193482 444 444 444 1 1','0 0 542802 542802 542802 542802 575453 575453 575453 575505 575505','0 0 27 27 27 27 24310 25597 43165 571774 575505',X'0C080803080808030803040401C3EB018CCE55312F013305B700AF487C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 126108 126108 126108 126108 200 200 28 1 1','0 0 747801 747801 747801 747801 762121 762121 762293 762320 762320','0 0 33 33 33 33 30770 32410 56629 757315 762320',X'0C080803080808030803040301C7A6018A9D6AB1100131F17D04364A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 149712 149712 149712 149712 216 216 5 1 1','0 0 1107747 1107747 1107747 1107747 1147090 1147090 1147301 1147305 1147305','0 0 98 98 98 98 51603 53785 94043 1139967 1147305',X'0C080803080808030803040302172301B84D2E828501317B95651924');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 87289 87289 87289 87289 27 27 12 1 1','0 0 1257751 1257751 1257751 1257751 1297850 1297850 1297865 1297869 1297869','0 0 100 100 100 100 57625 60123 107069 1289807 1297869',X'0C0808030808080308040403021FFC02554D00E643C7013242692A9BBC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 192597 192597 192597 192597 291 291 3 1 1','0 0 1464077 1464077 1464077 1464077 1512946 1512946 1513234 1513236 1513236','0 0 134 134 134 134 67476 70262 123260 1502886 1513236',X'0C0808030808080308040404029E6201B94000F8341701330419008B74DA');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 196917 196917 196917 196917 326 326 12 1 1','0 0 1677739 1677739 1677739 1677739 1797333 1797333 1797647 1797658 1797658','0 0 136 136 136 136 76717 80026 143308 1785522 1797658',X'0C0808030808080308040404029E6802B7DC0108ACBA0132DD7B0087795F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 140297 140297 140297 140297 206 188 90 1 1','0 0 1951850 1951850 1951850 1951850 2020506 2020524 2020622 2020711 2020711','0 0 146 146 146 146 85439 89181 160816 2006993 2020711',X'0C0808030808080302040403029E8102171603E800FA82B20132B5AD384ECD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 132041 132041 132041 132041 173 173 20 1 1','0 0 2415706 2415706 2415706 2415706 2428962 2428962 2429115 2429134 2429134','0 0 163 163 163 163 100984 105182 186071 2412732 2429134',X'0C0808030808080308030403029EB1018BF55020D60131A3D23BB156');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 6830 6830 6830 6830 35 35 35 1 1','0 0 2595444 2595444 2595444 2595444 2595711 2595711 2595711 2595739 2595739','0 0 169 169 169 169 108584 113037 199947 2578183 2595739',X'0C0808030808080308030403029EC001878C17A7520131A43A6E513C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 101615 101615 101615 101615 244 33 33 1 1','0 0 2999185 2999185 2999185 2999185 3019255 3019466 3019466 3019498 3019498','0 0 213 213 213 213 131035 136293 237357 2999333 3019498',X'0C080803080808030203040302D7C001B93E03F041A96D013303017C72B6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 26914 26914 26914 26914 87 87 73 1 1','0 0 3868553 3868553 3868553 3868553 3893568 3893568 3893582 3893609 3893609','0 0 387 387 387 387 172456 180121 311050 3869040 3893609',X'0C08080308080803080304040498C86B7EF347CC5A0132B678008A4646');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 97492 97492 97492 97492 410 410 44 1 1','0 0 4948831 4948831 4948831 4948831 5009456 5009456 5009822 5009865 5009865','0 0 751 751 751 751 226745 236274 399260 4980988 5009865',X'0C08080308080803080404030E565F03686C00F89CD001332A115479DC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 1782 1782 1782 1782 52 52 52 1 1','0 0 5190938 5190938 5190938 5190938 5191434 5191434 5191434 5191479 5191479','0 0 800 800 800 800 236362 246237 414618 5161779 5191479',X'0C08080308080803080304040EBD0F0268E064A6DB013242CB00875BAF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 4645 4645 4645 4645 17 17 17 1 1','0 0 6485214 6485214 6485214 6485214 6489339 6489339 6489339 6489349 6489349','0 0 1396 1396 1396 1396 317293 329836 538486 6453712 6489349',X'0C080804080808040803040300ABD9B000A69D33737CBB01328F6B0F6298');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 290196 290196 290196 290196 138 138 26 1 1','0 0 6734628 6734628 6734628 6734628 6744872 6744872 6744984 6745009 6745009','0 0 1641 1641 1641 1641 338986 352099 569319 6708651 6745009',X'0C080804080808030804040400FF5594018819010B3C670133294300B1674C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 630326 24310 1435 1435 1435 1 1 1 1 1','0 7173953 7763625 7786500 7786500 7786500 7787219 7787219 7787219 7787219 7787219','0 1 3518 4119 4119 4119 726018 753845 1215054 7745002 7787219',X'0C080904010808030204040400FF5594070357AB232800F2FA440133294600A90441');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 114188 114188 114188 114188 463 61 61 1 1','7804279 7804279 7809377 7809377 7809377 7809377 7864755 7865157 7865157 7865217 7865217','1 2 3751 4413 4413 4413 740133 768607 1233927 7822883 7865217',X'0C0908030808080302030403018A750213B2245416DF860131CB3A2879CC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 86108 86108 86108 86108 605 605 605 1 1','7804279 7804279 8403815 8403815 8403815 8403815 8463845 8463845 8463845 8464449 8464449','1 2 3805 4467 4467 4467 760796 789718 1255047 8421249 8464449',X'0C0908030808080308030403021FFC0DC36E1AD36901328E2F3D9128');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 60490 60490 60490 60490 44 44 44 1 1','7804279 7804279 9062901 9062901 9062901 9062901 9085056 9085056 9085056 9085089 9085089','1 2 3845 4507 4507 4507 778931 808217 1273550 9040805 9085089',X'0C0908030808080308040403029EB101C30B00E889140132697F092505');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 57304 57304 57304 57304 2 2 2 1 1','7804279 7804279 10328144 10328144 10328144 10328144 10382958 10382958 10382958 10382959 10382959','1 2 4106 4768 4768 4768 823966 853934 1319290 10336860 10382959',X'0C09080308080804080404040E565F00CE8C3100E7F68D0133517900B0B4CE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 174377 174377 174377 174377 81 81 66 1 1','7804279 7804279 11246252 11246252 11246252 11246252 11358749 11358749 11358764 11358829 11358829','1 2 4517 5179 5179 5179 867595 898252 1363807 11311829 11358829',X'0C090804080808030804040300FF55940E584300F2FA44013240670E2E89');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 157757 15066 15066 15066 15066 1 1 1 1 1','7804279 11523070 11657249 11657249 11657249 11657249 11672314 11672314 11672314 11672314 11672314','1 3 5503 6167 6167 6167 1025351 1059076 1524822 11625280 11672314',X'0C090904080808040203040300FF5594025D19032328337763013351F2277A3E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4748 4629 4629 4629 4629 17 1 1 1','0 0 634880 634880 634880 634880 634880 639175 639191 639191 639191','0 0 779 907 907 907 907 415429 633684 633685 639191',X'0C0808030808080804030303018C4A013157983CE7FE05E54B6BB7FB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4608 4608 4608 4608 4608 33 1 1 1','0 0 752580 752580 752580 752580 752580 755506 755538 755538 755538','0 0 936 1089 1089 1089 1089 491324 749126 749127 755538',X'0C0808030808080804030303018D4F0131A682512ECF029E6A70A9E9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4776 4776 4776 4776 4776 27 1 1 1','0 0 762070 762070 762070 762070 762070 763357 763383 763383 763383','0 0 940 1097 1097 1097 1097 495628 756890 756891 763383',X'0C0808030808080804040303018D560132DB8800F3416D029EA654D9AC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5910 5910 5910 5910 5910 37 2 2 1','0 0 771353 771353 771353 771353 771353 775562 775597 775597 775598','0 0 946 1103 1103 1103 1103 501111 769013 769014 775598',X'0C0808030808080804030303018D610131CADE4C6E2D01D5860141A9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 1834 1834 1834 1834 1834 6 1 1 1','0 0 1296866 1296866 1296866 1296866 1296866 1297867 1297869 1297869 1297869','0 0 2621 2842 2842 2842 2842 857867 1287063 1287064 1297869',X'0C080803080808080403030301A6E30132419A1E1B7F0567EE2880C0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5007 3959 3959 3959 3959 25 1 1 1','0 0 2152400 2152400 2152400 2152400 2152400 2155551 2155575 2155575 2155575','0 0 5683 6304 6304 6304 6304 1442790 2140930 2140937 2155575',X'0C080803080808080404030301C3F901317CC701044CC7029E6834F7E2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4768 4609 4609 4609 4609 26 1 1 1','0 0 2200466 2200466 2200466 2200466 2200466 2204364 2204389 2204389 2204389','0 0 5714 6370 6370 6370 6370 1470393 2189496 2189503 2204389',X'0C080803080808080403030301C4220131586B3EB735018A7567CE9E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5177 4669 4669 4669 4669 22 1 1 1','0 0 2234078 2234078 2234078 2234078 2234078 2238366 2238387 2238387 2238387','0 0 5743 6422 6422 6422 6422 1490145 2223355 2223362 2238387',X'0C080803080808080403030301C4490131573F4104F802D9CA67FD1E');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 7981 5546 5546 5546 5546 32 1 1 1','0 0 2239923 2239923 2239923 2239923 2239923 2243388 2243419 2243419 2243419','0 0 5746 6428 6428 6428 6428 1492784 2228358 2228365 2243419',X'0C080803080808080404030301C44E0131A4FE00FDCC04029E8175076B');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 351 336 336 336 336 1 1 1 1','0 0 2595725 2595725 2595725 2595725 2595725 2595739 2595739 2595739 2595739','0 0 6747 7717 7717 7717 7717 1732397 2578697 2578708 2595739',X'0C080803080808080404030301CCC901332A7700F17E5D0E5D6F523B01');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 6022 4942 4942 4942 4942 38 1 1 1','0 0 2648510 2648510 2648510 2648510 2648510 2652126 2652163 2652163 2652163','0 0 6934 7959 7959 7959 7959 1770411 2634884 2634898 2652163',X'0C080803080808080404030301CE8C01317DE800FE4E8B029E81458317');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4752 1965 1965 1965 1965 1 1 1 1','0 0 3161780 3161780 3161780 3161780 3161780 3163744 3163744 3163744 3163744','0 0 9707 11219 11219 11219 11219 2143797 3143873 3143896 3163744',X'0C08080308080808040303030213B20130BC9216F939029E815B86EE');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5497 1880 1880 1880 1880 1 1 1 1','0 0 3167643 3167643 3167643 3167643 3167643 3169522 3169522 3169522 3169522','0 0 9709 11226 11226 11226 11226 2148088 3149632 3149655 3169522',X'0C08080308080808040303030213B50130BBC616FC6501C7A62A1BB2');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 2185 2126 2126 2126 2126 4 1 1 1','0 0 3891670 3891670 3891670 3891670 3891670 3893609 3893609 3893609 3893609','0 0 13596 15952 15953 15953 15953 2677069 3869700 3869732 3893609',X'0C080803080808080403030302BD5F01317CC81782F704C9D95EFF0C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5511 5355 5355 5355 5355 21 1 1 1','0 0 3931850 3931850 3931850 3931850 3931850 3936206 3936226 3936226 3936226','0 0 13793 16188 16189 16189 16189 2705655 3912091 3912125 3936226',X'0C080803080808080403030302C14C01317C514010FA01B64235E688');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5468 5115 5115 5115 5115 27 1 1 1','0 0 3939091 3939091 3939091 3939091 3939091 3943255 3943281 3943281 3943281','0 0 13803 16200 16201 16201 16201 2709082 3919099 3919133 3943281',X'0C080803080808080403030302C16401317CC348B67001C3EB6824BB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5275 4792 4792 4792 4792 31 1 1 1','0 0 4590217 4590217 4590217 4590217 4590217 4591639 4591669 4591669 4591669','0 0 17456 20455 20456 20456 20456 3175906 4564022 4564064 4591669',X'0C0808030808080804040403049EE50132915200FA2F9300EA0DC50554E0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 339 339 339 339 339 2 1 1 1','0 0 5191258 5191258 5191258 5191258 5191258 5191478 5191479 5191479 5191479','0 0 20754 24230 24231 24231 24231 3601696 5160652 5160701 5191479',X'0C08080308080808040303030CEE930132671A1B8AFF01B6426386D0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 13 13 13 13 13 1 1 1 1','0 0 6489339 6489339 6489339 6489339 6489339 6489349 6489349 6489349 6489349','0 0 29449 33987 33989 33989 33989 4540005 6453309 6453378 6489349',X'0C08080408080808040303030091B3AB01321B5A4F26F2018A750B6686');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 630326 19 19 18 18 18 1 1 1 1','0 7173953 7787203 7787203 7787203 7787203 7787203 7787219 7787219 7787219 7787219','0 1 73522 83967 91688 91688 91688 5643606 7744920 7744997 7787219',X'0C080904080808080404030300FF69210132DB2900FB0715029EB573EB9F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 4598 4512 4512 4512 4512 38 1 1 1','7804279 7804279 8237877 8237877 8237877 8237877 8237877 8238986 8239023 8239023 8239023','1 2 76726 87349 95641 95641 95641 5923145 8195880 8195957 8239023',X'0C0908030808080804040404018D3F01332A780111068001FB6F840083BEF9');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 397 397 397 397 397 2 1 1 1','7804279 7804279 9084892 9084892 9084892 9084892 9084892 9085089 9085089 9085089 9085089','1 2 79826 90851 99143 99143 99143 6505397 9040540 9040617 9085089',X'0C090803080808080403030301CBAF0133028A4E35BE715A2A49098C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 141 141 141 141 141 2 1 1 1','7804279 7804279 10382921 10382921 10382921 10382921 10382921 10382958 10382959 10382959 10382959','1 2 87296 99145 107437 107437 107437 7432077 10336699 10336776 10382959',X'0C09080308080808040403030DB5C101332BF7010E37310EB97420BFF6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 157757 83 16 16 16 16 1 1 1 1','7804279 11523070 11587750 11587817 11587817 11587817 11587817 11587832 11587832 11587832 11587832','1 3 104655 118035 126343 126343 126343 8311754 11540721 11540798 11587832',X'0C090903020808080404030402A9D1232801332CC300EB7D35029E83008581B1');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24157 24157 24157 24157 24157 133 1 1 1','0 0 1236590 1236590 1236590 1236590 1236590 1241150 1241282 1241282 1241282','0 0 3120 3120 3120 3120 4771 741878 1223262 1228239 1241282',X'0C08080308080804040408031A080400FF559401321BC20099C49F3BE84C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 1209 1209 1209 1209 1209 2 1 1 1','0 0 1296873 1296873 1296873 1296873 1296873 1297868 1297869 1297869 1297869','0 0 3203 3203 3203 3203 4902 763298 1279554 1284645 1297869',X'0C08080308080803040308031A215F04C9D901317D1501B0A355A290');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 12129 12129 12129 12129 9261 38 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1791737 1791774 1791774 1791774','0 0 4938 4938 4938 4938 7561 1075153 1767990 1775629 1791774',X'0C08080308080803040408031CE87E029E6B01328F6100B473FD5BE552');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 273 273 273 273 273 1 1 1 1','0 0 2595625 2595625 2595625 2595625 2595625 2595739 2595739 2595739 2595739','0 0 7863 7863 7863 7863 12132 1580849 2562484 2575172 2595739',X'0C08080308080803040308032F020502DA0E013241A16B73DE01E021');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 7735 7735 7735 7735 7735 503 1 1 1','0 0 2924165 2924165 2924165 2924165 2924165 2931394 2931896 2931896 2931896','0 0 9123 9123 9123 9123 14045 1794002 2895440 2909856 2931896',X'0C080803080808040404080433776300FF55940133294301C56631008BCB5A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 360 360 360 360 229 1 1 1 1','0 0 3893374 3893374 3893374 3893374 3893505 3893609 3893609 3893609 3893609','0 0 13912 13912 13912 13912 21124 2420346 3846830 3866425 3893609',X'0C08080308080803040308034717710E070B01317F7102C73A396CE1');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 683 683 683 683 671 2 1 1 1','0 0 5191447 5191447 5191447 5191447 5191459 5191479 5191479 5191479 5191479','0 0 20361 20361 20361 20361 30776 3226670 5127525 5158962 5191479',X'0C08080308080803040308037370D10F00290132B59A018F7A694C9B');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 213354 213354 213354 213354 213354 5934 1 1 1','0 0 6102233 6102233 6102233 6102233 6102233 6154276 6155650 6155650 6155650','0 0 26812 26812 26812 26812 39489 3770219 6079715 6119855 6155650',X'0C080804080808040403080300F2FA4400FF55940132DF1A01C0C115D4D4');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 3675 3675 3675 3675 3675 14 1 1 1','0 0 6486701 6486701 6486701 6486701 6486701 6489347 6489349 6489349 6489349','0 0 28380 28380 28380 28380 41383 3868787 6409451 6452691 6489349',X'0C080804080808030403020300F6ABAC6C967D0132B672026C8D03E8155844');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24063 24063 24063 24063 24063 1799 1 1 1','0 0 7080914 7080914 7080914 7080914 7080914 7103178 7104976 7104976 7104976','0 0 35724 35725 35725 35725 49845 4189282 7019641 7067879 7104976',X'0C0808040808080404040804010B0A5C00FF55940133294301D2C35700A877B5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 20284 20284 20284 20284 20284 1518 1 1 1','0 0 7107240 7107240 7107240 7107240 7107240 7124584 7126101 7126101 7126101','0 0 35764 35765 35765 35765 49886 4191089 7040717 7089004 7126101',X'0C0808040808080404040803010B3C6700FF55940133294501F0A829511573');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 13288 11855 11855 11855 11855 5449 1 1 1','0 7173953 7671119 7671119 7671119 7671119 7671119 7676514 7676526 7676526 7676526','0 1 64320 65543 65543 65543 92453 4431581 7580039 7634401 7676526',X'0C080904080808040403080400F2FA4400FF5594013329430186CB00A866E4');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 61 61 61 61 61 14 1 1 1','0 7173953 7787172 7787172 7787172 7787172 7787172 7787217 7787219 7787219 7787219','0 1 73272 75274 75274 75274 103642 4468650 7689369 7745002 7787219',X'0C0809040808080304030803010ABA910DD2420133068F05DE6223042F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8657 8657 8657 8657 8657 18 1 1 1','7804279 7804279 8360485 8360485 8360485 8360485 8360485 8360977 8360994 8360994 8360994','1 2 75785 77865 77865 77865 106290 4756698 8258979 8317590 8360994',X'0C09080308080803040408031AD369021FFC0133517F01B017F259F6C3');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 33421 33421 33421 33421 33421 2221 1 1 1','7804279 7804279 8873934 8873934 8873934 8873934 8873934 8874868 8877088 8877088 8877088','1 2 76834 78914 78914 78914 107340 5041847 8770182 8832668 8877088',X'0C090803080808040404020333776300FF5594013351790241FEE4232825FB3D');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 2182 2182 2182 2182 2182 20 1 1 1','7804279 7804279 9083187 9083187 9083187 9083187 9083187 9085087 9085089 9085089 9085089','1 2 77227 79307 79307 79307 107733 5141706 8974619 9040316 9085089',X'0C09080308080803040308043AC92C021FFC0132B668018BAB00964778');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6008 6008 6008 6008 6008 26 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9128286 9128311 9128311 9128311','1 2 77300 79380 79380 79380 107806 5160088 9016921 9083451 9128311',X'0C09080308080804040408033C1C5C00F024880132DB2100B88E8A420C1B');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6023 6023 6023 6023 6023 91 1 1 1','7804279 7804279 9393480 9393480 9393480 9393480 9393480 9396519 9396609 9396609 9396609','1 2 77893 79973 79973 79973 108402 5311949 9282988 9351281 9396609',X'0C09080308080803040408044CDD9A7E1C230132DE4200D105C800A087F7');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 79 79 79 79 79 1 1 1 1','7804279 7804279 10382946 10382946 10382946 10382946 10382946 10382959 10382959 10382959 10382959','1 2 80421 82501 82501 82501 110947 5821380 10258569 10336296 10382959',X'0C090804080808030403080300E9A10A0CC3160133505F0D25365733C6');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8251 8251 8251 8251 8251 37 1 1 1','7804279 7804279 11067468 11067468 11067468 11067468 11067468 11068084 11068120 11068120 11068120','1 2 83449 85529 85529 85529 113989 6177561 10936213 11021086 11068120',X'0C090804080808040404080400FFA4A7008A66AD01332AD10170A8B10084054A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 44772 44772 44772 44772 44772 3018 1 1 1','7804279 7804279 11268036 11268036 11268036 11268036 11268036 11282829 11285846 11285846 11285846','1 2 85052 87132 87132 87132 115597 6281979 11151347 11238812 11285846',X'0C0908040808080404040804010B0A5C00FF5594013351720249087400B0523C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 53775 53775 53775 53775 53775 4069 1 1 1','7804279 7804279 11330929 11330929 11330929 11330929 11330929 11359035 11363103 11363103 11363103','1 2 85255 87335 87335 87335 115800 6292285 11227544 11316069 11363103',X'0C0908040808080404040804010BFA8100FF5594013351280252F8A000B01818');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 39430 39430 39430 39430 39430 3018 1 1 1','7804279 7804279 11458789 11458789 11458789 11458789 11458789 11468188 11471205 11471205 11471205','1 2 86422 88502 88502 88502 116970 6333877 11333316 11424171 11471205',X'0C09080408080804040408040113B99600FF559401335174024530C4008AC82C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 157757 5317 5317 5317 5317 5317 12 1 1 1','7804279 11523070 11652844 11652844 11652844 11652844 11652844 11658149 11658160 11658160 11658160','1 3 97969 100051 100051 100051 128567 6429914 11517744 11611126 11658160',X'0C0909040808080404040804010BFA8100FF559401332B2E01521E0B008447F4');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24157 29 29 29 29 29 1 1 1','0 0 1236590 1251799 1251799 1251799 1251799 1251799 1251827 1251827 1251827','0 0 3120 62451 63798 63798 63798 63798 1238772 1238782 1251827',X'0C08080303080808080404031A0804029BB30131CD3700FF55942B1368');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 1209 129 129 129 129 129 1 1 1','0 0 1296873 1297744 1297744 1297744 1297744 1297744 1297869 1297869 1297869','0 0 3203 65280 66657 66657 66657 66657 1284635 1284645 1297869',X'0C08080303080808080403041A215F01B0A30131066F04C9D90087162A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 12129 604 604 604 604 604 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1790076 1790679 1790679 1790679','0 0 4938 95334 97612 97612 97612 97612 1774566 1774578 1790679',X'0C08080303080808080403031CE87E01870001317C4D0CED622FE2E8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 273 5 5 5 5 5 1 1 1','0 0 2595625 2595738 2595738 2595738 2595738 2595738 2595739 2595739 2595739','0 0 7863 145612 149427 149427 149427 149427 2575145 2575172 2595739',X'0C08080303080808080403042F020502C73A0133049702DA0E00A711F8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 7735 29 29 29 29 29 1 1 1','0 0 2924165 2929754 2929754 2929754 2929754 2929754 2929782 2929782 2929782','0 0 9123 167852 172269 172269 172269 172269 2907715 2907742 2929782',X'0C080803030808080804040333776375928D0133294300FF55945A824F');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 360 6 6 6 6 6 1 1 1','0 0 3893374 3893607 3893607 3893607 3893607 3893607 3893609 3893609 3893609','0 0 13912 240908 247109 247109 247109 247109 3866384 3866425 3893609',X'0C080803030808080804030347177104AF8701317D220E070B687905');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 683 32 32 32 32 32 2 2 1','0 0 5191447 5191465 5191465 5191465 5191465 5191465 5191479 5191479 5191479','0 0 20361 336764 345696 345696 345696 345696 5158907 5158962 5191479',X'0C08080303080808080403037370D101884501328F690F002900A69C');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 213354 113 113 113 113 113 1 1 1','0 0 6102233 6155183 6155183 6155183 6155183 6155183 6155295 6155295 6155295','0 0 26812 421693 433202 433202 433202 433202 6119212 6119281 6155295',X'0C080804030808080804040300F2FA44019B6D0132406700FF5594714AE8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 3675 241 241 241 241 241 1 1 1','0 0 6486701 6489287 6489287 6489287 6489287 6489287 6489349 6489349 6489349','0 0 28380 450494 462953 462953 462953 462953 6452616 6452691 6489349',X'0C080804040808080804030300F6ABAC009F84B60132DBDD6C967D155A2A');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24063 38 38 38 38 38 1 1 1','0 0 7080914 7102383 7102383 7102383 7102383 7102383 7102420 7102420 7102420','0 0 35724 528136 541855 541858 541858 541858 7065247 7065323 7102420',X'0C0808040408080808040403010B0A5C00CCD3EE0133294500FF559459DDCD');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 20284 38 38 38 38 38 1 1 1','0 0 7107240 7126609 7126609 7126609 7126609 7126609 7126646 7126646 7126646','0 0 35764 531673 545484 545487 545487 545487 7089473 7089549 7126646',X'0C0808040408080808040403010B3C670114CE730133294300FF55942225CC');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 13288 5 1 1 1 1 1 1 1','0 7173953 7671119 7675167 7675171 7675171 7675171 7675171 7675171 7675171 7675171','0 1 64320 967583 993386 999414 999414 999414 7632969 7633046 7675171',X'0C080904030308080804040400F2FA4401D16F0183350132DEFE00FF5594009FA501');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 61 1 1 1 1 1 1 1 1','0 7173953 7787172 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 1 73272 1068631 1096442 1107608 1107608 1107608 7744925 7745002 7787219',X'0C0809040408080808040304010ABA9100AA4C1F013351DB0DD242008BFFEF');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8657 605 605 605 605 605 1 1 1','7804279 7804279 8360485 8364643 8364643 8364643 8364643 8364643 8365247 8365247 8365247','1 2 75785 1096159 1124446 1135923 1135923 1135923 8321766 8321843 8365247',X'0C09080303080808080403031AD3690DC36E01328E2F021FFC3D9128');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 33421 57 26 26 26 26 1 1 1','7804279 7804279 8873934 8891008 8891039 8891039 8891039 8891039 8891064 8891064 8891064','1 2 76834 1110063 1138607 1150084 1150084 1150084 8846567 8846644 8891064',X'0C09080303020808080404043377630CE166232801332A1800FF559400836DFB');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 2182 94 94 94 94 94 1 1 1','7804279 7804279 9083187 9085006 9085006 9085006 9085006 9085006 9085089 9085089 9085089','1 2 77227 1115805 1144438 1155915 1155915 1155915 9040239 9040316 9085089',X'0C09080303080808080403033AC92C04AF670132B5FC021FFC38DBD0');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6008 277 277 277 277 277 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9124662 9124938 9124938 9124938','1 2 77300 1116652 1145304 1156781 1156781 1156781 9080000 9080077 9124938',X'0C09080303080808080404033C1C5C01B49901328DDA00F024883D6052');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6023 50 50 50 50 50 1 1 1','7804279 7804279 9393480 9395815 9395815 9395815 9395815 9395815 9395864 9395864 9395864','1 2 77893 1123924 1152663 1164140 1164140 1164140 9350459 9350536 9395864',X'0C09080303080808080403034CDD9A01C30D013290877E1C2303CC11');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 79 6 6 6 6 6 1 1 1','7804279 7804279 10382946 10382956 10382956 10382956 10382956 10382956 10382959 10382959 10382959','1 2 80421 1154920 1184197 1195674 1195674 1195674 10336219 10336296 10382959',X'0C090804030808080804030400E9A10A02A47201332C6C0CC31600ABCD60');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8251 280 280 280 280 280 1 1 1','7804279 7804279 11067468 11072690 11072690 11072690 11072690 11072690 11072969 11072969 11072969','1 2 83449 1186373 1216159 1227636 1227636 1227636 11025858 11025935 11072969',X'0C090804040808080804040300FFA4A70089DBDD0132B5FF008A66AD6AE2B8');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 44772 58 58 58 58 58 1 1 1','7804279 7804279 11268036 11269261 11269261 11269261 11269261 11269261 11269318 11269318 11269318','1 2 85052 1199706 1229712 1241189 1241189 1241189 11222207 11222284 11269318',X'0C0908040308080808040404010B0A5C018ACD0133294300FF559400B0E291');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 53775 37 19 19 19 19 1 1 1','7804279 7804279 11330929 11355027 11355045 11355045 11355045 11355045 11355063 11355063 11355063','1 2 85255 1206165 1236304 1247781 1247781 1247781 11307952 11308029 11355063',X'0C0908040302080808040403010BFA81026C24232801332B2E00FF55941F8BB5');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 39430 39 39 39 39 39 1 1 1','7804279 7804279 11458789 11476757 11476757 11476757 11476757 11476757 11476795 11476795 11476795','1 2 86422 1219089 1249476 1260953 1260953 1260953 11429684 11429761 11476795',X'0C09080403080808080404030113B99602F6AF01332B2E00FF55941F8A54');\n  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 157757 5317 1 1 1 1 1 1 1 1','7804279 11523070 11652844 11658160 11658160 11658160 11658160 11658160 11658160 11658160 11658160','1 3 97969 1358780 1391643 1403122 1403122 1403122 11611049 11611126 11658160',X'0C0909040402080808040403010BFA8102594CCB2328013351E800FF55945B0F5D');\n  ANALYZE sqlite_master;\n} {}\n\n# Ensure that the query planner implements the GROUP BY using a separate sort\n#\ndo_execsql_test whereJ-1.4 {\n  EXPLAIN QUERY PLAN\n  SELECT aid, sid, MAX(edate) edate\n    FROM tx1\n   WHERE cid = 115790\n     AND sid = 9100\n     AND edate <= 20140430 AND edate >= 20120429\n   GROUP BY aid;\n} {/B-TREE/}\n\n############################################################################\n# Ensure that the sorting cost does not swamp the loop costs and cause\n# distinctions between individual loop costs to get lost, and hence for\n# sub-optimal loops to be chosen.\n#\ndo_execsql_test whereJ-2.1 {\n  CREATE TABLE tab(\n    id INTEGER PRIMARY KEY,\n    minChild INTEGER REFERENCES t1,\n    maxChild INTEGER REFERENCES t1,\n    x INTEGER\n  );\n  EXPLAIN QUERY PLAN\n  SELECT t4.x\n    FROM tab AS t0, tab AS t1, tab AS t2, tab AS t3, tab AS t4\n   WHERE t0.id=0\n     AND t1.id BETWEEN t0.minChild AND t0.maxChild\n     AND t2.id BETWEEN t1.minChild AND t1.maxChild\n     AND t3.id BETWEEN t2.minChild AND t2.maxChild\n     AND t4.id BETWEEN t3.minChild AND t3.maxChild\n  ORDER BY t4.x;\n} {~/SCAN/}\ndo_execsql_test whereJ-2.2 {\n  EXPLAIN QUERY PLAN\n  SELECT t4.x\n    FROM tab AS t0a, tab AS t0b,\n         tab AS t1a, tab AS t1b,\n         tab AS t2a, tab AS t2b,\n         tab AS t3a, tab AS t3b,\n         tab AS t4\n   WHERE 1\n     AND t0a.id=1\n     AND t1a.id BETWEEN t0a.minChild AND t0a.maxChild\n     AND t2a.id BETWEEN t1a.minChild AND t1a.maxChild\n     AND t3a.id BETWEEN t2a.minChild AND t2a.maxChild\n     AND t0b.id=2\n     AND t1b.id BETWEEN t0b.minChild AND t0b.maxChild\n     AND t2b.id BETWEEN t1b.minChild AND t1b.maxChild\n     AND t3b.id BETWEEN t2b.minChild AND t2b.maxChild\n     AND t4.id BETWEEN t3a.minChild AND t3b.maxChild\n  ORDER BY t4.x;\n} {~/SCAN/}\n\n############################################################################\n\n# Create and populate table.\ndo_execsql_test 3.1 { CREATE TABLE t1(a, b, c) }\nfor {set i 0} {$i < 32} {incr i 2} {\n  for {set x 0} {$x < 100} {incr x} {\n    execsql { INSERT INTO t1 VALUES($i, $x, $c) }\n    incr c\n  }\n  execsql { INSERT INTO t1 VALUES($i+1, 5, $c) }\n  incr c\n}\n\ndo_execsql_test 3.2 {\n  SELECT a, count(*) FROM t1 GROUP BY a HAVING a < 8;\n} {\n  0 100 1 1 2 100 3 1 4 100 5 1 6 100 7 1\n}\n\ndo_execsql_test 3.3 {\n  CREATE INDEX idx_ab ON t1(a, b);\n  CREATE INDEX idx_c ON t1(c);\n  ANALYZE;\n} {}\n\n# This one should use index \"idx_c\".\ndo_eqp_test 3.4 {\n  SELECT * FROM t1 WHERE \n    a = 4 AND b BETWEEN 20 AND 80           -- Matches 80 rows\n      AND\n    c BETWEEN 150 AND 160                   -- Matches 10 rows\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX idx_c (c>? AND c<?)}\n}\n\n# This one should use index \"idx_ab\".\ndo_eqp_test 3.5 {\n  SELECT * FROM t1 WHERE \n    a = 5 AND b BETWEEN 20 AND 80           -- Matches 1 row\n      AND\n    c BETWEEN 150 AND 160                   -- Matches 10 rows\n} {\n  0 0 0 {SEARCH TABLE t1 USING INDEX idx_ab (a=? AND b>? AND b<?)}\n}\n\n###########################################################################################\n\n# Reset the database and setup for a test case derived from actual SQLite users\n#\ndb close\nsqlite3 db test.db\ndo_execsql_test 4.1 {\n  CREATE TABLE le(\n    le_id largeint,\n    xid char(31),\n    type smallint,\n    name char(255) DEFAULT '',\n    mtime largeint DEFAULT 0,\n    muuid int DEFAULT 0\n  );\n  CREATE TABLE cx(\n    cx_id largeint,\n    code char(31),\n    type smallint,\n    name char(31),\n    description varchar,\n    role smallint,\n    mtime largeint DEFAULT 0,\n    muuid int DEFAULT 0,\n    le_id largeint DEFAULT 0,\n    imco smallint DEFAULT 0\n  );\n  CREATE TABLE px(\n    px_id largeint,\n    cx_id largeint,\n    px_tid largeint,\n    name char(31),\n    description varchar DEFAULT '',\n    ia smallint,\n    sl smallint,\n    le_id largeint DEFAULT 0,\n    mtime largeint DEFAULT 0,\n    muuid int DEFAULT 0\n  );\n  CREATE INDEX le_id on le (le_id);\n  CREATE INDEX c_id on cx (cx_id);\n  CREATE INDEX c_leid on cx (le_id);\n  CREATE INDEX p_id on px (px_id);\n  CREATE INDEX p_cid0 on px (cx_id);\n  CREATE INDEX p_pt on px (px_tid);\n  CREATE INDEX p_leid on px (le_id);\n} {}\ndo_execsql_test 4.2 {\n  ANALYZE sqlite_master;\n  INSERT INTO sqlite_stat1 VALUES('le','le_id','1979 1');\n  INSERT INTO sqlite_stat1 VALUES('cx','c_leid','852 171');\n  INSERT INTO sqlite_stat1 VALUES('cx','c_id','852 1');\n  INSERT INTO sqlite_stat1 VALUES('px','p_leid','114443 63');\n  INSERT INTO sqlite_stat1 VALUES('px','p_pt','114443 22889');\n  INSERT INTO sqlite_stat1 VALUES('px','p_cid0','114443 181');\n  INSERT INTO sqlite_stat1 VALUES('px','p_id','114443 1');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','162 162','162 162',X'030202013903fb');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','208 208','208 208',X'0302020253012d');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','219 219','219 219',X'030202025e0131');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','248 248','248 248',X'030202027b014e');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','265 265','265 265',X'030202028c015f');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','358 358','358 358',X'03020202e901bc');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','439 439','439 439',X'030202033a020d');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','657 657','657 657',X'030202041402b4');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','659 659','659 659',X'030202041602b6');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','681 681','681 681',X'030202042c02cc');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','831 831','831 831',X'03020204c20482');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','852 852','852 852',X'03020204d70497');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','870 870','870 870',X'03020204e904a9');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','879 879','879 879',X'03020204f204b2');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1099 1099','1099 1099',X'03020205ce058e');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1273 1273','1273 1273',X'030202067c05a9');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1319 1319','1319 1319',X'03020206e30730');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1330 1330','1330 1330',X'0302020700035b');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1539 1539','1539 1539',X'03020207d105d8');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1603 1603','1603 1603',X'03020208390780');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1759 1759','1759 1759',X'030202092f0618');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1843 1843','1843 1843',X'03020209880650');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1915 1915','1915 1915',X'03020209d0068b');\n  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1927 1927','1927 1927',X'03020209dc0697');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 94','0 94',X'0308015f');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 189','0 189',X'03080200be');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 284','0 284',X'0308020120');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 379','0 379',X'030802017f');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 474','0 474',X'03080201de');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 569','0 569',X'030802023d');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 664','0 664',X'030802029f');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 759','0 759',X'03080202fe');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','3 1','846 847','1 847',X'0301024500e6');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','849 849','2 849',X'03010246027e');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','850 850','3 850',X'0301024700c9');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','851 851','4 851',X'03010248027f');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','94 94','94 94',X'03020200b801a8');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','113 113','113 113',X'03020200d101ad');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','171 171','171 171',X'030201011d2a');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','177 177','177 177',X'030202012600f2');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','189 189','189 189',X'030202013501c8');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','206 206','206 206',X'030201014f2d');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','231 231','231 231',X'030202016d00fc');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','284 284','284 284',X'03020201b702d0');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','291 291','291 291',X'03020101c042');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','311 311','311 311',X'03020201d801e7');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','339 339','339 339',X'03020101f74b');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','347 347','347 347',X'03020202030118');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','379 379','379 379',X'030202022f01fa');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','393 393','393 393',X'030201023f55');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','407 407','407 407',X'03020202500201');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','413 413','413 413',X'03020102565a');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','468 468','468 468',X'030201029468');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','474 474','474 474',X'030202029a0211');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','517 517','517 517',X'03020102cc76');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','548 548','548 548',X'03020202f00223');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','569 569','569 569',X'03020203090087');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','664 664','664 664',X'03020203740163');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','759 759','759 759',X'03020203e800b3');\n  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','803 803','803 803',X'030202041b026f');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 12715','0 12715',X'030802345b');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 25431','0 25431',X'0308026718');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 38147','0 38147',X'030803009a5c');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 50863','0 50863',X'03080300cdbe');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 63579','0 63579',X'0308030100e8');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 76295','0 76295',X'03080301351d');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 89011','0 89011',X'03080301674c');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 101727','0 101727',X'030803019b99');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','28 1','110824 110843','16 110843',X'0301037a0107f1');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','53 1','110873 110875','25 110875',X'0302020095275a');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','32 1','110927 110936','27 110936',X'030203009b009b4a');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','51 1','110980 111017','30 111017',X'03020300a4016c00');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','67 1','111047 111059','38 111059',X'03020200af2611');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','60 1','111136 111156','43 111156',X'03020300bc009aeb');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','42 1','111222 111239','59 111239',X'03020300d200b17b');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111264 111266','60 111266',X'03020200d426d6');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','27 1','111733 111757','159 111757',X'030203014e017e1b');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111760 111773','160 111773',X'030203014f00a2b9');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','29 1','111822 111833','167 111833',X'0302030176009c22');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','75 1','113031 113095','1190 113095',X'030203068501912c');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','132 1','113230 113263','1252 113263',X'0302030711009ee6');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110 1','113851 113918','1572 113918',X'03020308e9011ca2');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','78 1','114212 114217','1791 114217',X'03020209e13b24');\n  INSERT INTO sqlite_stat4 VALUES('px','p_leid','112 1','114303 114351','1799 114351',X'03020309ea0128f2');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 12715','0 12715',X'030802477e');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 25431','0 25431',X'0308027c20');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 38147','0 38147',X'03080300c211');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 50863','0 50863',X'03080300fbe5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 63579','0 63579',X'0308030140ff');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 76295','0 76295',X'03080301792d');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 89011','0 89011',X'03080301bb68');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','24217 1','89824 101727','1 101727',X'03090300da12');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','154 1','114041 114154','2 114154',X'0301030200e5e9');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','198 1','114195 114351','3 114351',X'03010303015cb1');\n  INSERT INTO sqlite_stat4 VALUES('px','p_pt','50 1','114393 114441','4 114441',X'0301030401b2ef');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3867 1','3 3736','2 3736',X'03010337015c6a');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4194 1','4177 8209','5 8209',X'0301033b015075');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4335 1','8371 11129','6 11129',X'0301033d0156fc');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1740 1','12706 12715','7 12715',X'0301023e34b9');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1680 1','14446 15487','8 15487',X'0301033f011694');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','7163 1','20116 25431','32 25431',X'03020300a400ed26');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1525 1','29100 29302','42 29302',X'03020200bb00d1');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3703 1','30655 33323','45 33323',X'03020300be013fa5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2612 1','37767 38147','61 38147',X'03020200e32828');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1882 1','40545 41584','63 41584',X'03020300ea01a35a');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6984 1','44110 50863','73 50863',X'0302030102017467');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1728 1','51230 51680','75 51680',X'030203010400b3e0');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2805 1','55491 57936','95 57936',X'030203014101a004');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2837 1','58934 59506','103 59506',X'030203015900a283');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','94 1','63492 63579','137 63579',X'0302030191016319');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3573 1','63591 64497','140 64497',X'030203019c00822e');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','5037 1','70917 73033','160 73033',X'03020301c70091d9');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1940 1','75954 76295','161 76295',X'03020201c817f1');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1927 1','83926 84371','209 84371',X'03020202114295');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1522 1','86601 88117','213 88117',X'030203021b01b7b5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','210 1','88906 89011','226 89011',X'030203022800dbbb');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6165 1','92125 98066','258 98066',X'030203024d0189ac');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2900 1','100721 101727','293 101727',X'030203027500cf39');\n  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1501 1','110012 110154','503 110154',X'0302020380493a');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','11129 11129','11129 11129',X'03030300d84e014d51');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','12715 12715','12715 12715',X'03030200de816f51');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','13030 13030','13030 13030',X'03030200e05b6fc4');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','25431 25431','25431 25431',X'0303030123df00efb0');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','29302 29302','29302 29302',X'030302013a2812c7');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','35463 35463','35463 35463',X'03030301666e00f866');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38147 38147','38147 38147',X'030302017a391b74');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38525 38525','38525 38525',X'030303017c6e00fb58');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','50863 50863','50863 50863',X'03030201b68724dd');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','58461 58461','58461 58461',X'03030201d95b2e1e');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','59506 59506','59506 59506',X'03030301dd7000a0fb');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63468 63468','63468 63468',X'03030301ecea011405');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63579 63579','63579 63579',X'03030201ed5932d5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','64497 64497','64497 64497',X'03030301f0ef00a680');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','73033 73033','73033 73033',X'0303030225b90190e5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','75650 75650','75650 75650',X'030303023a19019362');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','76295 76295','76295 76295',X'030303023e9801940c');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','79152 79152','79152 79152',X'030303024be50196b9');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','83249 83249','83249 83249',X'0303030261750123b1');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','89011 89011','89011 89011',X'030303027b3900c3af');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','98066 98066','98066 98066',X'03030302a76500ce54');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101590 101590','101590 101590',X'03030302b63d00d3b5');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101727 101727','101727 101727',X'03030202b6f24e9b');\n  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','107960 107960','107960 107960',X'03030302d8ce0136ad');\n  ANALYZE sqlite_master;\n} {}\n\n# The following query should do a full table scan of cx in the outer loop.\n# It is not correct to search table px using indx p_pt in the outer loop\n# with cx in the middle loop.  Test case from Bloomberg on 2014-09-05.\n#\ndo_execsql_test 4.2 {\n  EXPLAIN QUERY PLAN\n  SELECT\n     px.name,\n     px.description\n  FROM\n     le,\n     cx,\n     px\n  WHERE\n     cx.code = '2990'\n     AND cx.type=2\n     AND px.cx_id = cx.cx_id\n     AND px.px_tid = 0\n     AND px.le_id = le.le_id;\n} {/.*SCAN TABLE cx.*SEARCH TABLE px.*SEARCH TABLE le.*/}\n\n\n# The following test is derived from a performance problem reported from\n# the field.  Notice the multiple indexes with the same initial tables,\n# and the unusual WHERE clause terms.\n#\ndo_test 5.1 {\n  set res [db eval {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(a,b,c,d,e,f,g,h);\n    CREATE INDEX t1abc ON t1(a,b,c);\n    CREATE INDEX t1abe ON t1(a,b,e);\n    CREATE INDEX t1abf ON t1(a,b,f);\n    ANALYZE;\n    DROP TABLE IF EXISTS sqlite_stat4;\n    DROP TABLE IF EXISTS sqlite_stat3;\n    DELETE FROM sqlite_stat1;\n    INSERT INTO sqlite_stat1(tbl,idx,stat)\n      VALUES('t1','t1abc','2000000 8000 1600 800'),\n            ('t1','t1abe','2000000 8000 1600 150'),\n            ('t1','t1abf','2000000 8000 1600 150');\n    ANALYZE sqlite_master;\n  \n    EXPLAIN QUERY PLAN\n    SELECT * FROM t1\n     WHERE (a=1 OR a=2)\n       AND (b=3 OR b=4)\n       AND (d>=5 AND d<=5)\n       AND ((e>=7 AND e<=7) OR (f>=8 AND f<=8))\n       AND g>0;\n  }]\n} {~/ANY/}\ndo_test 5.2 {set res} {/USING INDEX t1abe/}\ndo_test 5.3 {set res} {/USING INDEX t1abf/}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/whereK.test",
    "content": "# 2015-03-16\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing OR expressions where terms can be\n# factored from either side of the OR and combined into a single new\n# AND term that is beneficial to the search.  Examples:\n#\n#      (x>A OR x=A)              -->    ... AND (x>=A)\n#      (x>A OR (x=A AND y>=B)    -->    ... AND (x>=A)\n#\n\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix whereK\n\ndo_execsql_test 1.1 {\n  CREATE TABLE t1(a,b,c);\n  WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<99)\n    INSERT INTO t1(a,b,c) SELECT x, x/10, x%10 FROM c;\n  CREATE INDEX t1bc ON t1(b,c);\n  SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;\n} {90 91 92 93 94 95 96 97 98 99}\ndo_execsql_test 1.1eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>9 OR b=9 ORDER BY +a;\n} {/SEARCH TABLE t1 USING INDEX t1bc/}\n\ndo_execsql_test 1.2 {\n  SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;\n} {88 89 90 91 92 93 94 95 96 97 98 99}\ndo_execsql_test 1.2eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>8 OR (b=8 AND c>7) ORDER BY +a;\n} {/SEARCH TABLE t1 USING INDEX t1bc/}\n\ndo_execsql_test 1.3 {\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;\n} {88 89 90 91 92 93 94 95 96 97 98 99}\ndo_execsql_test 1.3eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR b>8 ORDER BY +a;\n} {/SEARCH TABLE t1 USING INDEX t1bc/}\n\ndo_execsql_test 1.4 {\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;\n} {88 89 90 91 92 93 94 95 96 97 98 99}\ndo_execsql_test 1.4eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR 8<b ORDER BY +a;\n} {/SEARCH TABLE t1 USING INDEX t1bc/}\n\ndo_execsql_test 1.5 {\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))\n   ORDER BY +a;\n} {88 89 90 91 92 93 97 98 99}\ndo_execsql_test 1.5eqp {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE (b=8 AND c>7) OR (b>8 AND c NOT IN (4,5,6))\n   ORDER BY +a;\n} {/SEARCH TABLE t1 USING INDEX t1bc/}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wherefault.test",
    "content": "# 2008 December 23\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library. The focus\n# is testing of where.c. More specifically, the focus is on handling OOM\n# errors within the code that optimizes WHERE clauses that feature the \n# OR operator.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nsource $testdir/malloc_common.tcl\n\nset testprefix wherefault\n\ndo_malloc_test 1 -sqlprep {\n  CREATE TABLE t1(a, b, c);\n  CREATE INDEX i1 ON t1(a);\n  CREATE INDEX i2 ON t1(b);\n} -sqlbody {\n  SELECT c FROM t1\n  WHERE \n    a = 2 OR b = 'three' OR a = 4 OR b = 'five' OR a = 6 OR\n    b = 'seven' OR a = 8 OR b = 'nine' OR a = 10\n  ORDER BY rowid;\n\n  SELECT c FROM t1 WHERE\n    a = 1 OR a = 2 OR a = 3 OR a = 4 OR a = 5 OR a = 6;\n\n  SELECT c FROM t1 WHERE\n    a BETWEEN 1 AND 3  AND b < 5 AND b > 2 AND c = 4;\n}\n\ndo_malloc_test 2 -tclprep {\n  db eval {\n    BEGIN;\n    CREATE TABLE t1(a, b, c);\n    CREATE INDEX i1 ON t1(a);\n    CREATE INDEX i2 ON t1(b);\n  }\n  for {set i 0} {$i < 1000} {incr i} {\n    set ii [expr $i*$i]\n    set iii [expr $i*$i]\n    db eval { INSERT INTO t1 VALUES($i, $ii, $iii) }\n  }\n  db eval COMMIT\n} -sqlbody {\n  SELECT count(*) FROM t1 WHERE a BETWEEN 5 AND 995 OR b BETWEEN 5 AND 900000;\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wherelimit.test",
    "content": "# 2008 October 6\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the LIMIT ... OFFSET ... clause\n#  of UPDATE and DELETE statements.\n#\n# $Id: wherelimit.test,v 1.2 2008/10/10 18:25:46 shane Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nproc create_test_data {size} {\n  # Build some test data\n  #\n  execsql {\n    DROP TABLE IF EXISTS t1;\n    CREATE TABLE t1(x int, y int);\n    BEGIN;\n  }\n  for {set i 1} {$i<=$size} {incr i} {\n    for {set j 1} {$j<=$size} {incr j} {\n      execsql \"INSERT INTO t1 VALUES([expr {$i}],[expr {$j}])\"\n    }\n  }\n  execsql {\n    COMMIT;\n  }\n  return {}\n}\n\nifcapable {update_delete_limit} {\n\n  # check syntax error support\n  do_test wherelimit-0.1 {\n    catchsql {DELETE FROM t1 ORDER BY x}\n  } {1 {ORDER BY without LIMIT on DELETE}}\n  do_test wherelimit-0.2 {\n    catchsql {DELETE FROM t1 WHERE x=1 ORDER BY x}\n  } {1 {ORDER BY without LIMIT on DELETE}}\n  do_test wherelimit-0.3 {\n    catchsql {UPDATE t1 SET y=1 WHERE x=1 ORDER BY x}\n  } {1 {ORDER BY without LIMIT on UPDATE}}\n\n  # no AS on table sources\n  do_test wherelimit-0.4 {\n    catchsql {DELETE FROM t1 AS a WHERE x=1}\n  } {1 {near \"AS\": syntax error}}\n  do_test wherelimit-0.5 {\n    catchsql {UPDATE t1 AS a SET y=1 WHERE x=1}\n  } {1 {near \"AS\": syntax error}}\n\n  # OFFSET w/o LIMIT\n  do_test wherelimit-0.6 {\n    catchsql {DELETE FROM t1 WHERE x=1 OFFSET 2}\n  } {1 {near \"OFFSET\": syntax error}}\n  do_test wherelimit-0.7 {\n    catchsql {UPDATE t1 SET y=1 WHERE x=1 OFFSET 2}\n  } {1 {near \"OFFSET\": syntax error}}\n\n\n  # check deletes w/o where clauses but with limit/offsets\n  create_test_data 5\n  do_test wherelimit-1.0 {\n    execsql {SELECT count(*) FROM t1}\n  } {25}\n  do_test wherelimit-1.1 {\n    execsql {DELETE FROM t1}\n    execsql {SELECT count(*) FROM t1}\n  } {0}\n  create_test_data 5\n  do_test wherelimit-1.2 {\n    execsql {DELETE FROM t1 LIMIT 5}\n    execsql {SELECT count(*) FROM t1}\n  } {20}\n  do_test wherelimit-1.3 {\n    # limit 5\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 5}\n    execsql {SELECT count(*) FROM t1}\n  } {15}\n  do_test wherelimit-1.4 {\n    # limit 5, offset 2\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET 2}\n    execsql {SELECT count(*) FROM t1}\n  } {10}\n  do_test wherelimit-1.5 {\n    # limit 5, offset -2\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET -2}\n    execsql {SELECT count(*) FROM t1}\n  } {5}\n  do_test wherelimit-1.6 {\n    # limit -5 (no limit), offset 2\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 2, -5}\n    execsql {SELECT count(*) FROM t1}\n  } {2}\n  do_test wherelimit-1.7 {\n    # limit 5, offset -2 (no offset)\n    execsql {DELETE FROM t1 ORDER BY x LIMIT -2, 5}\n    execsql {SELECT count(*) FROM t1}\n  } {0}\n  create_test_data 5\n  do_test wherelimit-1.8 {\n    # limit -5 (no limit), offset -2 (no offset)\n    execsql {DELETE FROM t1 ORDER BY x LIMIT -2, -5}\n    execsql {SELECT count(*) FROM t1}\n  } {0}\n  create_test_data 3\n  do_test wherelimit-1.9 {\n    # limit 5, offset 2\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 2, 5}\n    execsql {SELECT count(*) FROM t1}\n  } {4}\n  do_test wherelimit-1.10 {\n    # limit 5, offset 5\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET 5}\n    execsql {SELECT count(*) FROM t1}\n  } {4}\n  do_test wherelimit-1.11 {\n    # limit 50, offset 30\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 50 OFFSET 30}\n    execsql {SELECT count(*) FROM t1}\n  } {4}\n  do_test wherelimit-1.12 {\n    # limit 50, offset 30\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 30, 50}\n    execsql {SELECT count(*) FROM t1}\n  } {4}\n  do_test wherelimit-1.13 {\n    execsql {DELETE FROM t1 ORDER BY x LIMIT 50 OFFSET 50}\n    execsql {SELECT count(*) FROM t1}\n  } {4}\n\n\n  create_test_data 6\n  do_test wherelimit-2.0 {\n    execsql {SELECT count(*) FROM t1}\n  } {36}\n  do_test wherelimit-2.1 {\n    execsql {DELETE FROM t1 WHERE x=1}\n    execsql {SELECT count(*) FROM t1}\n  } {30}\n  create_test_data 6\n  do_test wherelimit-2.2 {\n    execsql {DELETE FROM t1 WHERE x=1 LIMIT 5}\n    execsql {SELECT count(*) FROM t1}\n  } {31}\n  do_test wherelimit-2.3 {\n    # limit 5\n    execsql {DELETE FROM t1 WHERE x=1 ORDER BY x LIMIT 5}\n    execsql {SELECT count(*) FROM t1}\n  } {30}\n  do_test wherelimit-2.4 {\n    # limit 5, offset 2\n    execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 5 OFFSET 2}\n    execsql {SELECT count(*) FROM t1}\n  } {26}\n  do_test wherelimit-2.5 {\n    # limit 5, offset -2\n    execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 5 OFFSET -2}\n    execsql {SELECT count(*) FROM t1}\n  } {24}\n  do_test wherelimit-2.6 {\n    # limit -5 (no limit), offset 2\n    execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT 2, -5}\n    execsql {SELECT count(*) FROM t1}\n  } {20}\n  do_test wherelimit-2.7 {\n    # limit 5, offset -2 (no offset)\n    execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT -2, 5}\n    execsql {SELECT count(*) FROM t1}\n  } {18}\n  do_test wherelimit-2.8 {\n    # limit -5 (no limit), offset -2 (no offset)\n    execsql {DELETE FROM t1 WHERE x=4 ORDER BY x LIMIT -2, -5}\n    execsql {SELECT count(*) FROM t1}\n  } {12}\n  create_test_data 6\n  do_test wherelimit-2.9 {\n    # limit 5, offset 2\n    execsql {DELETE FROM t1 WHERE x=5 ORDER BY x LIMIT 2, 5}\n    execsql {SELECT count(*) FROM t1}\n  } {32}\n  do_test wherelimit-2.10 {\n    # limit 5, offset 5\n    execsql {DELETE FROM t1 WHERE x=6 ORDER BY x LIMIT 5 OFFSET 5}\n    execsql {SELECT count(*) FROM t1}\n  } {31}\n  do_test wherelimit-2.11 {\n    # limit 50, offset 30\n    execsql {DELETE FROM t1 WHERE x=1 ORDER BY x LIMIT 50 OFFSET 30}\n    execsql {SELECT count(*) FROM t1}\n  } {31}\n  do_test wherelimit-2.12 {\n    # limit 50, offset 30\n    execsql {DELETE FROM t1 WHERE x=2 ORDER BY x LIMIT 30, 50}\n    execsql {SELECT count(*) FROM t1}\n  } {31}\n  do_test wherelimit-2.13 {\n    execsql {DELETE FROM t1 WHERE x=3 ORDER BY x LIMIT 50 OFFSET 50}\n    execsql {SELECT count(*) FROM t1}\n  } {31}\n\n\n  create_test_data 6\n  do_test wherelimit-3.0 {\n    execsql {SELECT count(*) FROM t1}\n  } {36}\n  do_test wherelimit-3.1 {\n    execsql {UPDATE t1 SET y=1 WHERE x=1}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {11}\n  create_test_data 6\n  do_test wherelimit-3.2 {\n    execsql {UPDATE t1 SET y=1 WHERE x=1 LIMIT 5}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {10}\n  do_test wherelimit-3.3 {\n    # limit 5\n    execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5}\n    execsql {SELECT count(*) FROM t1 WHERE y=2}\n  } {9}\n  create_test_data 6\n  do_test wherelimit-3.4 {\n    # limit 5, offset 2\n    execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5 OFFSET 2}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {6}\n  do_test wherelimit-3.5 {\n    # limit 5, offset -2\n    execsql {UPDATE t1 SET y=2 WHERE x=2 ORDER BY x LIMIT 5 OFFSET -2}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {5}\n  do_test wherelimit-3.6 {\n    # limit -5 (no limit), offset 2\n    execsql {UPDATE t1 SET y=3 WHERE x=3 ORDER BY x LIMIT 2, -5}\n    execsql {SELECT count(*) FROM t1 WHERE y=3}\n  } {8}\n  do_test wherelimit-3.7 {\n    # limit 5, offset -2 (no offset)\n    execsql {UPDATE t1 SET y=3 WHERE x=3 ORDER BY x LIMIT -2, 5}\n    execsql {SELECT count(*) FROM t1 WHERE y=3}\n  } {10}\n\n  do_test wherelimit-3.8 {\n    # limit -5 (no limit), offset -2 (no offset)\n    execsql {UPDATE t1 SET y=4 WHERE x=4 ORDER BY x LIMIT -2, -5}\n    execsql {SELECT count(*) FROM t1 WHERE y=4}\n  } {9}\n  create_test_data 6\n  do_test wherelimit-3.9 {\n    # limit 5, offset 2\n    execsql {UPDATE t1 SET y=4 WHERE x=5 ORDER BY x LIMIT 2, 5}\n    execsql {SELECT count(*) FROM t1 WHERE y=4}\n  } {9}\n  do_test wherelimit-3.10 {\n    # limit 5, offset 5\n    execsql {UPDATE t1 SET y=4 WHERE x=6 ORDER BY x LIMIT 5 OFFSET 5}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {6}\n  do_test wherelimit-3.11 {\n    # limit 50, offset 30\n    execsql {UPDATE t1 SET y=1 WHERE x=1 ORDER BY x LIMIT 50 OFFSET 30}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {6}\n  do_test wherelimit-3.12 {\n    # limit 50, offset 30\n    execsql {UPDATE t1 SET y=1 WHERE x=2 ORDER BY x LIMIT 30, 50}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {6}\n  do_test wherelimit-3.13 {\n    execsql {UPDATE t1 SET y=1 WHERE x=3 ORDER BY x LIMIT 50 OFFSET 50}\n    execsql {SELECT count(*) FROM t1 WHERE y=1}\n  } {6}\n\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wild001.test",
    "content": "# 2013-07-01\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This is a test case from content taken \"from the wild\".  In this\n# particular instance, the query was provided with permission by\n# Elan Feingold on 2013-06-27.  His message on the SQLite mailing list\n# on that date reads:\n#\n#------------------------------------------------------------------------------\n# > Can you send (1) the schema (2) the query that is giving problems, and (3)\n# > the content of the sqlite_stat1 table after you have run ANALYZE?   If you\n# > can combine all of the above into a script, that would be great!\n# >\n# > If you send (1..3) above and you give us written permission to include the\n# > query in our test suite, that would be off-the-chain terrific.\n#\n# Please find items 1..3 in this file: http://www.plexapp.com/elan/sqlite_bug.txt\n# \n# You have our permission to include the query in your test suite.\n# \n# Thanks for an amazing product.\n#-----------------------------------------------------------------------------\n#\n# This test case merely creates the schema and populates SQLITE_STAT1 and\n# SQLITE_STAT3 then runs an EXPLAIN QUERY PLAN to ensure that the right plan\n# is discovered.  This test case may need to be adjusted for future revisions\n# of the query planner manage to select a better query plan.  The query plan\n# shown here is known to be very fast with the original data.\n#\n# This test should work the same with and without SQLITE_ENABLE_STAT3\n#\n###############################################################################\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !stat3 {\n  finish_test\n  return\n}\n\ndo_execsql_test wild001.01 {\n  CREATE TABLE \"items\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"secid\" integer, \"parent_id\" integer, \"metadata_type\" integer, \"guid\" varchar(255), \"media_item_count\" integer, \"title\" varchar(255), \"title_sort\" varchar(255) COLLATE NOCASE, \"original_title\" varchar(255), \"studio\" varchar(255), \"rating\" float, \"rating_count\" integer, \"tagline\" varchar(255), \"summary\" text, \"trivia\" text, \"quotes\" text, \"content_rating\" varchar(255), \"content_rating_age\" integer, \"index\" integer, \"absolute_index\" integer, \"duration\" integer, \"user_thumb_url\" varchar(255), \"user_art_url\" varchar(255), \"user_banner_url\" varchar(255), \"user_music_url\" varchar(255), \"user_fields\" varchar(255), \"tags_genre\" varchar(255), \"tags_collection\" varchar(255), \"tags_director\" varchar(255), \"tags_writer\" varchar(255), \"tags_star\" varchar(255), \"originally_available_at\" datetime, \"available_at\" datetime, \"expires_at\" datetime, \"refreshed_at\" datetime, \"year\" integer, \"added_at\" datetime, \"created_at\" datetime, \"updated_at\" datetime, \"deleted_at\" datetime, \"tags_country\" varchar(255), \"extra_data\" varchar(255), \"hash\" varchar(255));\n  CREATE INDEX \"i_secid\" ON \"items\" (\"secid\" );\n  CREATE INDEX \"i_parent_id\" ON \"items\" (\"parent_id\" );\n  CREATE INDEX \"i_created_at\" ON \"items\" (\"created_at\" );\n  CREATE INDEX \"i_index\" ON \"items\" (\"index\" );\n  CREATE INDEX \"i_title\" ON \"items\" (\"title\" );\n  CREATE INDEX \"i_title_sort\" ON \"items\" (\"title_sort\" );\n  CREATE INDEX \"i_guid\" ON \"items\" (\"guid\" );\n  CREATE INDEX \"i_metadata_type\" ON \"items\" (\"metadata_type\" );\n  CREATE INDEX \"i_deleted_at\" ON \"items\" (\"deleted_at\" );\n  CREATE INDEX \"i_secid_ex1\" ON \"items\" (\"secid\", \"metadata_type\", \"added_at\" );\n  CREATE INDEX \"i_hash\" ON \"items\" (\"hash\" );\n  CREATE TABLE \"settings\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, \"account_id\" integer, \"guid\" varchar(255), \"rating\" float, \"view_offset\" integer, \"view_count\" integer, \"last_viewed_at\" datetime, \"created_at\" datetime, \"updated_at\" datetime);\n  CREATE INDEX \"s_account_id\" ON \"settings\" (\"account_id\" );\n  CREATE INDEX \"s_guid\" ON \"settings\" (\"guid\" );\n  ANALYZE;\n  INSERT INTO sqlite_stat1 VALUES('settings','s_guid','4740 1');\n  INSERT INTO sqlite_stat1 VALUES('settings','s_account_id','4740 4740');\n  INSERT INTO sqlite_stat1 VALUES('items','i_hash','27316 2');\n  INSERT INTO sqlite_stat1 VALUES('items','i_secid_ex1','27316 6829 4553 3');\n  INSERT INTO sqlite_stat1 VALUES('items','i_deleted_at','27316 27316');\n  INSERT INTO sqlite_stat1 VALUES('items','i_metadata_type','27316 6829');\n  INSERT INTO sqlite_stat1 VALUES('items','i_guid','27316 2');\n  INSERT INTO sqlite_stat1 VALUES('items','i_title_sort','27316 2');\n  INSERT INTO sqlite_stat1 VALUES('items','i_title','27316 2');\n  INSERT INTO sqlite_stat1 VALUES('items','i_index','27316 144');\n  INSERT INTO sqlite_stat1 VALUES('items','i_created_at','27316 2');\n  INSERT INTO sqlite_stat1 VALUES('items','i_parent_id','27316 15');\n  INSERT INTO sqlite_stat1 VALUES('items','i_secid','27316 6829');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,150,150,'com.plexapp.agents.thetvdb://153021/2/9?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,198,198,'com.plexapp.agents.thetvdb://194031/1/10?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,526,526,'com.plexapp.agents.thetvdb://71256/12/92?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,923,923,'com.plexapp.agents.thetvdb://71256/15/16?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1008,1008,'com.plexapp.agents.thetvdb://71256/15/93?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1053,1053,'com.plexapp.agents.thetvdb://71256/16/21?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1068,1068,'com.plexapp.agents.thetvdb://71256/16/35?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1235,1235,'com.plexapp.agents.thetvdb://71256/17/44?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1255,1255,'com.plexapp.agents.thetvdb://71256/17/62?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1573,1573,'com.plexapp.agents.thetvdb://71663/20/9?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,1580,1580,'com.plexapp.agents.thetvdb://71663/21/16?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2000,2000,'com.plexapp.agents.thetvdb://73141/9/8?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2107,2107,'com.plexapp.agents.thetvdb://73244/6/17?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2256,2256,'com.plexapp.agents.thetvdb://74845/4/7?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2408,2408,'com.plexapp.agents.thetvdb://75978/2/21?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2634,2634,'com.plexapp.agents.thetvdb://79126/1/1?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,2962,2962,'com.plexapp.agents.thetvdb://79274/3/94?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,3160,3160,'com.plexapp.agents.thetvdb://79274/5/129?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,3161,3161,'com.plexapp.agents.thetvdb://79274/5/12?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,3688,3688,'com.plexapp.agents.thetvdb://79274/8/62?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,3714,3714,'com.plexapp.agents.thetvdb://79274/8/86?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,4002,4002,'com.plexapp.agents.thetvdb://79590/13/17?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,4215,4215,'com.plexapp.agents.thetvdb://80727/3/6?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_guid',1,4381,4381,'com.plexapp.agents.thetvdb://83462/3/24?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('settings','s_account_id',4740,0,0,1);\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,1879,1879,'1113f632ccd52ec8b8d7ca3d6d56da4701e48018');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,2721,2721,'1936154b97bb5567163edaebc2806830ae419ccf');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,3035,3035,'1c122331d4b7bfa0dc2c003ab5fb4f7152b9987a');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,3393,3393,'1f81bdbc9acc3321dc592b1a109ca075731b549a');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,6071,6070,'393cf7713efb4519c7a3d1d5403f0d945d15a16a');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,7462,7461,'4677dd37011f8bd9ae7fbbdd3af6dcd8a5b4ab2d');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,8435,8434,'4ffa339485334e81a5e12e03a63b6508d76401cf');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,8716,8714,'52a093852e6599dd5004857b7ff5b5b82c7cdb25');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,9107,9104,'561183e39f866d97ec728e9ff16ac4ad01466111');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,10942,10939,'66e99b72e29610f49499ae09ee04a376210d1f08');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,12143,12139,'71f0602427e173dc2c551535f73fdb6885fe4302');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,14962,14958,'8ca8e4dfba696019830c19ab8a32c7ece9d8534b');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,15179,15174,'8ebf1a5cf33f8ada1fc5853ac06ac4d7e074f825');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,15375,15370,'908bc211bebdf21c79d2d2b54ebaa442ac1f5cae');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,18215,18210,'ab29e4e18ec5a14fef95aa713d69e31c045a22c1');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,18615,18610,'ae84c008cc0c338bf4f28d798a88575746452f6d');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,18649,18644,'aec7c901353e115aa5307e94018ba7507bec3a45');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,19517,19512,'b75025fbf2e9c504e3c1197ff1b69250402a31f8');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,21251,21245,'c7d32f0e3a8f3a0a3dbd00833833d2ccee62f0fd');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,23616,23610,'dd5ff61479a9bd4100de802515d9dcf72d46f07a');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,24287,24280,'e3db00034301b7555419d4ef6f64769298d5845e');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,24949,24942,'ea336abd197ecd7013854a25a4f4eb9dea7927c6');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',1,25574,25567,'f018ea5182ec3f32768ca1c3cefbf3ad160ec20b');\n  INSERT INTO sqlite_stat3 VALUES('items','i_hash',2,26139,26132,'f53709a8d81c12cb0f4f8d58004a25dd063de67c');\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid_ex1',25167,0,0,2);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid_ex1',736,25167,1,3);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid_ex1',15,25903,2,4);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid_ex1',1398,25918,3,5);\n  INSERT INTO sqlite_stat3 VALUES('items','i_deleted_at',27316,0,0,NULL);\n  INSERT INTO sqlite_stat3 VALUES('items','i_metadata_type',2149,0,0,1);\n  INSERT INTO sqlite_stat3 VALUES('items','i_metadata_type',411,2149,1,2);\n  INSERT INTO sqlite_stat3 VALUES('items','i_metadata_type',1440,2560,2,3);\n  INSERT INTO sqlite_stat3 VALUES('items','i_metadata_type',23316,4000,3,4);\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,215,215,'com.plexapp.agents.imdb://tt0065702?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,711,711,'com.plexapp.agents.imdb://tt0198781?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,987,986,'com.plexapp.agents.imdb://tt0454876?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1004,1002,'com.plexapp.agents.imdb://tt0464154?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1056,1053,'com.plexapp.agents.imdb://tt0499549?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1120,1116,'com.plexapp.agents.imdb://tt0903624?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1250,1245,'com.plexapp.agents.imdb://tt1268799?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1270,1264,'com.plexapp.agents.imdb://tt1320261?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',2,1376,1369,'com.plexapp.agents.imdb://tt1772341?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,3035,3027,'com.plexapp.agents.thetvdb://153021/3/14?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,6071,6063,'com.plexapp.agents.thetvdb://71173/1/18?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,6342,6334,'com.plexapp.agents.thetvdb://71256/13/4?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,9107,9099,'com.plexapp.agents.thetvdb://72389/2/19?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,11740,11732,'com.plexapp.agents.thetvdb://73893/2/13?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,12143,12135,'com.plexapp.agents.thetvdb://73976/4/23?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,15179,15171,'com.plexapp.agents.thetvdb://75897/16/12?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,17408,17400,'com.plexapp.agents.thetvdb://76808/2/16?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,17984,17976,'com.plexapp.agents.thetvdb://77068/1/16?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,18215,18207,'com.plexapp.agents.thetvdb://77259/1/1?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,21251,21243,'com.plexapp.agents.thetvdb://78957/8/2?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,24287,24279,'com.plexapp.agents.thetvdb://80337/5/8?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,25513,25505,'com.plexapp.agents.thetvdb://82226/6?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,25548,25540,'com.plexapp.agents.thetvdb://82339/2/10?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_guid',1,26770,26762,'com.plexapp.agents.thetvdb://86901/1/3?lang=en');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',1524,0,0,'');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',2,3034,1391,'Attack of the Giant Squid');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',51,4742,2895,'Brad Sherwood');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',11,4912,2996,'Brian Williams');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',39,5847,3857,'Chip Esten');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',1,6071,4015,'Chuck Versus the DeLorean');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',12,7625,5436,'Denny Siegel');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',30,8924,6618,'Episode 1');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',29,9015,6629,'Episode 2');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',32,9082,6643,'Episode 3');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',28,9135,6654,'Episode 4');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',26,9183,6665,'Episode 5');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',27,9229,6677,'Episode 6');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',22,9266,6688,'Episode 7');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',20,9298,6699,'Episode 8');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',55,11750,8817,'Greg Proops');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',1,12143,9120,'Hardware Jungle');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',33,14712,11435,'Kathy Greenwood');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',3,15179,11840,'Last Call');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',1,18215,14601,'Nature or Nurture?');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',12,18241,14623,'Neil DeGrasse Tyson');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',68,19918,16144,'Pilot');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',7,21251,17298,'Reza Aslan');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title_sort',1,24287,20035,'Technoviking');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1524,0,0,'');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,3035,1429,'Anderson Can''t Dance');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',51,4782,2991,'Brad Sherwood');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',11,4936,3079,'Brian Williams');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',39,5694,3783,'Chip Esten');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,6071,4100,'Clive Warren');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',12,7144,5078,'Denny Siegel');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',30,8249,6097,'Episode 1');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',29,8340,6108,'Episode 2');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',32,8407,6122,'Episode 3');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',28,8460,6133,'Episode 4');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',26,8508,6144,'Episode 5');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',27,8554,6156,'Episode 6');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',22,8591,6167,'Episode 7');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',20,8623,6178,'Episode 8');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,9107,6537,'Fat Albert and the Cosby Kids');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',55,10539,7843,'Greg Proops');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,12143,9276,'Iron Age Remains');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',33,13118,10143,'Kathy Greenwood');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,15179,11972,'Mink');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',68,17411,14035,'Pilot');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',2,18214,14727,'Reflections');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',4,21250,17481,'The Apartment');\n  INSERT INTO sqlite_stat3 VALUES('items','i_title',1,24287,20283,'The Simpsons Already Did It');\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',4315,95,2,1);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1553,4410,3,2);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1485,5963,4,3);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1414,7448,5,4);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1367,8862,6,5);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1328,10229,7,6);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1161,11557,8,7);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1108,12718,9,8);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1033,13826,10,9);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',1014,14859,11,10);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',929,15873,12,11);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',906,16802,13,12);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',844,17708,14,13);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',690,18552,15,14);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',655,19242,16,15);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',625,19897,17,16);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',579,20522,18,17);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',555,21101,19,18);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',526,21656,20,19);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',501,22182,21,20);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',459,22683,22,21);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',439,23142,23,22);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',315,23581,24,23);\n  INSERT INTO sqlite_stat3 VALUES('items','i_index',192,24177,26,25);\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1851,0,0,NULL);\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',373,1857,2,'2011-10-22 14:54:39');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',595,2230,3,'2011-10-22 14:54:41');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',337,2825,4,'2011-10-22 14:54:43');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',361,3378,8,'2011-10-22 14:54:54');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',160,3739,9,'2011-10-22 14:54:56');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',315,4000,11,'2011-10-22 14:54:59');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',321,4334,13,'2011-10-22 14:55:02');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1292,4723,16,'2011-10-22 14:55:06');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',161,6015,17,'2011-10-22 14:55:07');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1,9107,2677,'2012-09-04 18:07:50');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',313,9717,3270,'2012-10-18 16:50:21');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',450,10030,3271,'2012-10-18 16:50:22');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',389,10668,3275,'2012-10-18 16:50:26');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',796,11057,3276,'2012-10-18 16:51:06');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',161,12041,3280,'2012-10-19 19:52:37');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',135,13281,4186,'2013-02-19 00:56:10');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1063,13416,4187,'2013-02-19 00:56:11');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',797,14479,4188,'2013-02-19 00:56:13');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',147,15276,4189,'2013-02-19 00:56:15');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',346,15423,4190,'2013-02-19 00:56:16');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1,18215,6436,'2013-05-05 14:09:54');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',2,21251,8122,'2013-05-24 15:25:45');\n  INSERT INTO sqlite_stat3 VALUES('items','i_created_at',1,24287,11116,'2013-05-26 14:17:39');\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',2560,0,0,NULL);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',18,3022,31,2350);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',10,6068,285,8150);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',158,6346,315,8949);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',34,9094,562,18831);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',20,12139,794,22838);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',134,14033,886,24739);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',159,14167,887,24740);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',161,14326,888,24741);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',161,14487,889,24742);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',124,14648,890,24743);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',157,14772,891,24744);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',126,15043,894,24747);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',40,15169,895,24748);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',161,15243,898,24753);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',138,15404,899,24754);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',160,15542,900,24755);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',161,15702,901,24756);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',161,15863,902,24757);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',124,16024,903,24758);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',155,16148,904,24759);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',26,18208,1043,29704);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',2,21251,1282,32952);\n  INSERT INTO sqlite_stat3 VALUES('items','i_parent_id',13,24279,1583,36068);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid',25167,0,0,2);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid',736,25167,1,3);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid',15,25903,2,4);\n  INSERT INTO sqlite_stat3 VALUES('items','i_secid',1398,25918,3,5);\n  ANALYZE sqlite_master;\n  \n  explain query plan\n  select items.title\n    from items\n         join items as child on child.parent_id=items.id\n         join items as grandchild on grandchild.parent_id=child.id\n         join settings\n                    on settings.guid=grandchild.guid\n                   and settings.account_id=1\n   where items.metadata_type=2\n     and items.secid=2\n     and settings.last_viewed_at is not null\n   group by items.id\n   order by settings.last_viewed_at desc\n   limit 10;\n} [list \\\n 0 0 3 {SEARCH TABLE settings USING INDEX s_account_id (account_id=?)} \\\n 0 1 2 {SEARCH TABLE items AS grandchild USING INDEX i_guid (guid=?)} \\\n 0 2 1 {SEARCH TABLE items AS child USING INTEGER PRIMARY KEY (rowid=?)} \\\n 0 3 0 {SEARCH TABLE items USING INTEGER PRIMARY KEY (rowid=?)} \\\n 0 0 0 {USE TEMP B-TREE FOR GROUP BY} \\\n 0 0 0 {USE TEMP B-TREE FOR ORDER BY}]\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/win32heap.test",
    "content": "# 2013 November 22\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is the Win32 heap implementation.\n#\n\nif {$tcl_platform(platform)!=\"windows\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable !win32malloc {\n  finish_test\n  return\n}\n\nset testprefix win32heap\n\ndo_test 1.1 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap_size 1048576\n  sqlite3_initialize\n} {SQLITE_OK}\n\ndo_test 1.2 {\n  sqlite3 db test.db\n  catchsql {\n    CREATE TABLE t1(x);\n  }\n} {0 {}}\n\ndo_test 1.3 {\n  catchsql {\n    INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));\n  }\n} {1 {out of memory}}\n\ndo_test 1.4 {\n  catchsql {\n    SELECT COUNT(*) FROM t1;\n  }\n} {0 0}\n\ndo_test 1.5 {\n  catch {db close}\n  sqlite3_shutdown\n  sqlite3_config_heap_size 0\n  sqlite3_initialize\n} {SQLITE_OK}\n\ndo_test 1.6 {\n  sqlite3 db test.db\n  catchsql {\n    INSERT INTO t1 (x) VALUES(RANDOMBLOB(1048576));\n  }\n} {0 {}}\n\ndo_test 1.7 {\n  catchsql {\n    SELECT COUNT(*) FROM t1;\n  }\n} {0 1}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/win32lock.test",
    "content": "# 2011 July 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is recovery from transient manditory locks\n# that sometimes appear on database files due to anti-virus software.\n#\n\nif {$tcl_platform(platform)!=\"windows\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nset testprefix win32lock\n\ndb close\nsqlite3_shutdown\ntest_sqlite3_log xLog\nproc xLog {error_code msg} {\n  lappend ::log $msg\n}\nsqlite3 db test.db\ndb eval {PRAGMA mmap_size=0}\n\ndo_test win32lock-1.1 {\n  db eval {\n    PRAGMA cache_size=10;\n    CREATE TABLE t1(x,y);\n    INSERT INTO t1 VALUES(1,randomblob(100000));\n    INSERT INTO t1 VALUES(2,randomblob(50000));\n    INSERT INTO t1 VALUES(3,randomblob(25000));\n    INSERT INTO t1 VALUES(4,randomblob(12500));\n    SELECT x, length(y) FROM t1 ORDER BY rowid;\n  }\n} {1 100000 2 50000 3 25000 4 12500}\n\nunset -nocomplain delay1 rc msg\nset old_pending_byte [sqlite3_test_control_pending_byte 0x40000000]\n\nset win32_lock_ok [list]\nset win32_lock_error [list]\nset delay1 25\nwhile {1} {\n  lock_win32_file test.db 0 $::delay1\n  set ::log {}\n  set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]\n  if {$rc} {\n    lappend win32_lock_error $::delay1\n    do_test win32lock-1.2-$delay1-error {\n       set ::msg\n    } {disk I/O error}\n  } else {\n    lappend win32_lock_ok $::delay1\n    do_test win32lock-1.2-$delay1-ok {\n       set ::msg\n    } {1 100000 2 50000 3 25000 4 12500}\n    if {[info exists ::log] && $::log!=\"\"} {\n      do_test win32lock-1.2-$delay1-log1 {\n        regsub {\\d+} $::log # x\n        regsub { at line \\d+} $x \"\" x\n        set x\n      } {{delayed #ms for lock/sharing conflict}}\n    }\n  }\n  if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break\n  incr delay1 25\n  if {$delay1 > 12500} {\n    puts \"Timed out waiting for \\\"ok\\\" and \\\"error\\\" results.\"\n    break\n  }\n  sqlite3_sleep 10\n}\n\ndo_test win32lock-2.0 {\n  file_control_win32_av_retry db -1 -1\n} {0 10 25}\ndo_test win32lock-2.1 {\n  file_control_win32_av_retry db 1 1\n} {0 1 1}\n\n#\n# NOTE: It is known that the win32lock-2.2-* tests may fail if the system is\n#       experiencing heavy load (i.e. they are very timing sensitive).  This is\n#       primarily due to the AV retry delay being set to 1 millisecond in the\n#       win32lock-2.1 test (above).  While it is important to test this corner\n#       case for the AV retry logic, a failure of this test should probably not\n#       be interpreted as a bug in SQLite or these test cases.\n#\nset win32_lock_ok [list]\nset win32_lock_error [list]\nset delay1 1\nwhile {1} {\n  lock_win32_file test.db 0 $::delay1\n  set ::log {}\n  set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg]\n  if {$rc} {\n    lappend win32_lock_error $::delay1\n    do_test win32lock-2.2-$delay1-error {\n       set ::msg\n    } {disk I/O error}\n  } else {\n    lappend win32_lock_ok $::delay1\n    do_test win32lock-2.2-$delay1-ok {\n       set ::msg\n    } {1 100000 2 50000 3 25000 4 12500}\n    if {[info exists ::log] && $::log!=\"\"} {\n      do_test win32lock-2.2-$delay1-log1 {\n        regsub {\\d+} $::log # x\n        regsub { at line \\d+} $x \"\" x\n        set x\n      } {{delayed #ms for lock/sharing conflict}}\n    }\n  }\n  if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break\n  incr delay1 1\n  if {$delay1 > 500} {\n    puts \"Timed out waiting for \\\"ok\\\" and \\\"error\\\" results.\"\n    break\n  }\n  sqlite3_sleep 10\n}\n\nfile_control_win32_av_retry db 10 25\nsqlite3_test_control_pending_byte $old_pending_byte\ndb close\nforcedelete test.db\n\nsqlite3 db test.db\nsqlite3 db2 test.db\n\ndo_test win32lock-3.0 {\n  db eval {\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n  }\n} {}\n\ndo_test win32lock-3.1 {\n  db eval {\n    BEGIN EXCLUSIVE;\n    INSERT INTO t1 VALUES(4);\n  }\n} {}\n\ndo_test win32lock-3.2 {\n  catchsql {\n    BEGIN EXCLUSIVE;\n    INSERT INTO t1 VALUES(5);\n    COMMIT;\n  } db2\n} {1 {database is locked}}\n\ndo_test win32lock-3.3 {\n  db eval {\n    COMMIT;\n  }\n} {}\n\ndo_test win32lock-3.4 {\n  set handle [lindex [file_control_win32_set_handle db 0] end]\n  list [catchsql {\n    BEGIN EXCLUSIVE;\n    INSERT INTO t1 VALUES(6);\n    COMMIT;\n  }] [file_control_win32_set_handle db $handle] [sqlite3_extended_errcode db]\n} {{1 {disk I/O error}} {0 0} SQLITE_IOERR_LOCK}\n\ndb2 close\ndb close\nsqlite3_shutdown\ntest_sqlite3_log\nsqlite3_initialize\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/win32longpath.test",
    "content": "# 2013 August 27\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this script is testing the file name handling provided\n# by the \"win32-longpath\" VFS.\n#\n\nif {$tcl_platform(platform)!=\"windows\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix win32longpath\n\ndo_test 1.0 {\n  file_control_vfsname db\n} win32\n\ndb close\nset path [file nativename [get_pwd]]\nsqlite3 db [file join $path test.db] -vfs win32-longpath\n\ndo_test 1.1 {\n  file_control_vfsname db\n} win32-longpath\n\ndo_test 1.2 {\n  db eval {\n    BEGIN EXCLUSIVE;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(1);\n    INSERT INTO t1 VALUES(2);\n    INSERT INTO t1 VALUES(3);\n    INSERT INTO t1 VALUES(4);\n    SELECT x FROM t1 ORDER BY x;\n    COMMIT;\n  }\n} {1 2 3 4}\n\nset longPath(1) \\\\\\\\?\\\\$path\\\\[pid]\nmake_win32_dir $longPath(1)\n\nset longPath(2) $longPath(1)\\\\[string repeat X 255]\nmake_win32_dir $longPath(2)\n\nset longPath(3) $longPath(2)\\\\[string repeat Y 255]\nmake_win32_dir $longPath(3)\n\nset fileName $longPath(3)\\\\test.db\n\ndo_test 1.3 {\n  list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg\n} {1 {unable to open database file}}\n\nsqlite3 db3 $fileName -vfs win32-longpath\n\ndo_test 1.4 {\n  db3 eval {\n    BEGIN EXCLUSIVE;\n    CREATE TABLE t1(x);\n    INSERT INTO t1 VALUES(5);\n    INSERT INTO t1 VALUES(6);\n    INSERT INTO t1 VALUES(7);\n    INSERT INTO t1 VALUES(8);\n    SELECT x FROM t1 ORDER BY x;\n    COMMIT;\n  }\n} {5 6 7 8}\n\ndb3 close\n# puts \"  Database exists \\{[exists_win32_path $fileName]\\}\"\n\nsqlite3 db3 $fileName -vfs win32-longpath\n\ndo_test 1.5 {\n  db3 eval {\n    PRAGMA journal_mode = WAL;\n  }\n} {wal}\n\ndo_test 1.6 {\n  db3 eval {\n    BEGIN EXCLUSIVE;\n    INSERT INTO t1 VALUES(9);\n    INSERT INTO t1 VALUES(10);\n    INSERT INTO t1 VALUES(11);\n    INSERT INTO t1 VALUES(12);\n    SELECT x FROM t1 ORDER BY x;\n    COMMIT;\n  }\n} {5 6 7 8 9 10 11 12}\n\ndb3 close\n# puts \"  Database exists \\{[exists_win32_path $fileName]\\}\"\n\ndo_delete_win32_file $fileName\n# puts \"  Files remaining \\{[find_win32_file $longPath(3)\\\\*]\\}\"\n\ndo_remove_win32_dir $longPath(3)\ndo_remove_win32_dir $longPath(2)\ndo_remove_win32_dir $longPath(1)\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/win32nolock.test",
    "content": "# 2016 July 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n\nif {$tcl_platform(platform)!=\"windows\"} return\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix win32nolock\n\ndo_test win32nolock-1.0 {\n  sqlite3 db test.db\n  execsql {\n    CREATE TABLE t1(a, b);\n    BEGIN;\n    INSERT INTO t1 VALUES(1, 2);\n  }\n} {}\n\ndo_test win32nolock-1.1 {\n  execsql COMMIT\n  catchsql { SELECT * FROM t1 }\n} {0 {1 2}}\n\ndb close\n\ndo_test win32nolock-1.2 {\n  sqlite3 db test.db -vfs win32-none\n  sqlite3 db2 test.db -vfs win32-none\n  execsql { PRAGMA mmap_size = 0 } db2\n  execsql {\n    BEGIN;\n    INSERT INTO t1 VALUES(3, 4);\n  }\n} {}\n\ndo_test win32nolock-1.3 {\n  execsql { SELECT * FROM t1 }\n} {1 2 3 4}\n\ndo_test win32nolock-1.4 {\n  execsql { SELECT * FROM t1; } db2\n} {1 2}\n\ndo_test win32nolock-1.5 {\n  execsql {\n    BEGIN;\n    SELECT * FROM t1;\n  } db2\n} {1 2}\n\ndo_test win32nolock-1.6 {\n  execsql COMMIT\n  execsql {SELECT * FROM t1} db2\n} {1 2}\n\nifcapable memorymanage {\n  do_test win32nolock-1.7 {\n    sqlite3_release_memory 1000000\n    execsql {SELECT * FROM t1} db2\n  } {1 2 3 4}\n}\n\ndo_test win32nolock-1.8 {\n  db close\n  db2 close\n} {}\n\ndo_test win32nolock-1.9.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db\n  list [catchsql { BEGIN EXCLUSIVE; } db] \\\n      [catchsql { BEGIN EXCLUSIVE; } db2]\n} {{0 {}} {1 {database is locked}}}\n\ndo_test win32nolock-1.9.2 {\n  db close\n  db2 close\n} {}\n\ndo_test win32nolock-1.10.1 {\n  sqlite3 db test.db -vfs win32-none\n  sqlite3 db2 test.db\n  list [catchsql { BEGIN EXCLUSIVE; } db] \\\n      [catchsql { BEGIN EXCLUSIVE; } db2]\n} {{0 {}} {0 {}}}\n\ndo_test win32nolock-1.10.2 {\n  db close\n  db2 close\n} {}\n\ndo_test win32nolock-1.11.1 {\n  sqlite3 db test.db\n  sqlite3 db2 test.db -vfs win32-none\n  list [catchsql { BEGIN EXCLUSIVE; } db] \\\n      [catchsql { BEGIN EXCLUSIVE; } db2]\n} {{0 {}} {0 {}}}\n\ndo_test win32nolock-1.11.2 {\n  db close\n  db2 close\n} {}\n\ndo_test win32nolock-1.12.1 {\n  sqlite3 db test.db -vfs win32-none\n  sqlite3 db2 test.db -vfs win32-none\n  list [catchsql { BEGIN EXCLUSIVE; } db] \\\n      [catchsql { BEGIN EXCLUSIVE; } db2]\n} {{0 {}} {0 {}}}\n\ndo_test win32nolock-1.12.2 {\n  db close\n  db2 close\n} {}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/with1.test",
    "content": "# 2014 January 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the WITH clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix with1\n\nifcapable {!cte} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x INTEGER, y INTEGER);\n  WITH x(a) AS ( SELECT * FROM t1) SELECT 10\n} {10}\n\ndo_execsql_test 1.1 {\n  SELECT * FROM ( WITH x AS ( SELECT * FROM t1) SELECT 10 );\n} {10}\n\ndo_execsql_test 1.2 {\n  WITH x(a) AS ( SELECT * FROM t1) INSERT INTO t1 VALUES(1,2);\n} {}\n\ndo_execsql_test 1.3 {\n  WITH x(a) AS ( SELECT * FROM t1) DELETE FROM t1;\n} {}\n\ndo_execsql_test 1.4 {\n  WITH x(a) AS ( SELECT * FROM t1) UPDATE t1 SET x = y;\n} {}\n \n#--------------------------------------------------------------------------\n\ndo_execsql_test 2.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n  WITH tmp AS ( SELECT * FROM t1 ) SELECT x FROM tmp;\n} {1 2}\n\ndo_execsql_test 2.2 {\n  WITH tmp(a) AS ( SELECT * FROM t1 ) SELECT a FROM tmp;\n} {1 2}\n\ndo_execsql_test 2.3 {\n  SELECT * FROM (\n    WITH tmp(a) AS ( SELECT * FROM t1 ) SELECT a FROM tmp\n  );\n} {1 2}\n\ndo_execsql_test 2.4 {\n  WITH tmp1(a) AS ( SELECT * FROM t1 ),\n       tmp2(x) AS ( SELECT * FROM tmp1)\n  SELECT * FROM tmp2;\n} {1 2}\n\ndo_execsql_test 2.5 {\n  WITH tmp2(x) AS ( SELECT * FROM tmp1),\n       tmp1(a) AS ( SELECT * FROM t1 )\n  SELECT * FROM tmp2;\n} {1 2}\n\n#-------------------------------------------------------------------------\ndo_catchsql_test 3.1 {\n  WITH tmp2(x) AS ( SELECT * FROM tmp1 ),\n       tmp1(a) AS ( SELECT * FROM tmp2 )\n  SELECT * FROM tmp1;\n} {1 {circular reference: tmp1}}\n\ndo_catchsql_test 3.2 {\n  CREATE TABLE t2(x INTEGER);\n  WITH tmp(a) AS (SELECT * FROM t1),\n       tmp(a) AS (SELECT * FROM t1)\n  SELECT * FROM tmp;\n} {1 {duplicate WITH table name: tmp}}\n\ndo_execsql_test 3.3 {\n  CREATE TABLE t3(x);\n  CREATE TABLE t4(x);\n\n  INSERT INTO t3 VALUES('T3');\n  INSERT INTO t4 VALUES('T4');\n\n  WITH t3(a) AS (SELECT * FROM t4)\n  SELECT * FROM t3;\n} {T4}\n\ndo_execsql_test 3.4 {\n  WITH tmp  AS ( SELECT * FROM t3 ),\n       tmp2 AS ( WITH tmp AS ( SELECT * FROM t4 ) SELECT * FROM tmp )\n  SELECT * FROM tmp2;\n} {T4}\n\ndo_execsql_test 3.5 {\n  WITH tmp  AS ( SELECT * FROM t3 ),\n       tmp2 AS ( WITH xxxx AS ( SELECT * FROM t4 ) SELECT * FROM tmp )\n  SELECT * FROM tmp2;\n} {T3}\n\ndo_catchsql_test 3.6 {\n  WITH tmp AS ( SELECT * FROM t3 ),\n  SELECT * FROM tmp;\n} {1 {near \"SELECT\": syntax error}}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 4.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n  INSERT INTO t1 VALUES(3);\n  INSERT INTO t1 VALUES(4);\n\n  WITH dset AS ( SELECT 2 UNION ALL SELECT 4 )\n  DELETE FROM t1 WHERE x IN dset;\n  SELECT * FROM t1;\n} {1 3}\n\ndo_execsql_test 4.2 {\n  WITH iset AS ( SELECT 2 UNION ALL SELECT 4 )\n  INSERT INTO t1 SELECT * FROM iset;\n  SELECT * FROM t1;\n} {1 3 2 4}\n\ndo_execsql_test 4.3 {\n  WITH uset(a, b) AS ( SELECT 2, 8 UNION ALL SELECT 4, 9 )\n  UPDATE t1 SET x = COALESCE( (SELECT b FROM uset WHERE a=x), x );\n  SELECT * FROM t1;\n} {1 3 8 9}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 5.1 {\n  WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i)\n  SELECT x FROM i LIMIT 10;\n} {1 2 3 4 5 6 7 8 9 10}\n\ndo_catchsql_test 5.2 {\n  WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i ORDER BY 1)\n  SELECT x FROM i LIMIT 10;\n} {0 {1 2 3 4 5 6 7 8 9 10}}\n\ndo_execsql_test 5.2.1 {\n  CREATE TABLE edge(xfrom, xto, seq, PRIMARY KEY(xfrom, xto)) WITHOUT ROWID;\n  INSERT INTO edge VALUES(0, 1, 10);\n  INSERT INTO edge VALUES(1, 2, 20);\n  INSERT INTO edge VALUES(0, 3, 30);\n  INSERT INTO edge VALUES(2, 4, 40);\n  INSERT INTO edge VALUES(3, 4, 40);\n  INSERT INTO edge VALUES(2, 5, 50);\n  INSERT INTO edge VALUES(3, 6, 60);\n  INSERT INTO edge VALUES(5, 7, 70);\n  INSERT INTO edge VALUES(3, 7, 70);\n  INSERT INTO edge VALUES(4, 8, 80);\n  INSERT INTO edge VALUES(7, 8, 80);\n  INSERT INTO edge VALUES(8, 9, 90);\n  \n  WITH RECURSIVE\n    ancest(id, mtime) AS\n      (VALUES(0, 0)\n       UNION\n       SELECT edge.xto, edge.seq FROM edge, ancest\n        WHERE edge.xfrom=ancest.id\n        ORDER BY 2\n      )\n  SELECT * FROM ancest;\n} {0 0 1 10 2 20 3 30 4 40 5 50 6 60 7 70 8 80 9 90}\ndo_execsql_test 5.2.2 {\n  WITH RECURSIVE\n    ancest(id, mtime) AS\n      (VALUES(0, 0)\n       UNION ALL\n       SELECT edge.xto, edge.seq FROM edge, ancest\n        WHERE edge.xfrom=ancest.id\n        ORDER BY 2\n      )\n  SELECT * FROM ancest;\n} {0 0 1 10 2 20 3 30 4 40 4 40 5 50 6 60 7 70 7 70 8 80 8 80 8 80 8 80 9 90 9 90 9 90 9 90}\ndo_execsql_test 5.2.3 {\n  WITH RECURSIVE\n    ancest(id, mtime) AS\n      (VALUES(0, 0)\n       UNION ALL\n       SELECT edge.xto, edge.seq FROM edge, ancest\n        WHERE edge.xfrom=ancest.id\n        ORDER BY 2 LIMIT 4 OFFSET 2\n      )\n  SELECT * FROM ancest;\n} {2 20 3 30 4 40 4 40}\n\ndo_catchsql_test 5.3 {\n  WITH i(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM i LIMIT 5)\n  SELECT x FROM i;\n} {0 {1 2 3 4 5}}\n\ndo_execsql_test 5.4 {\n  WITH i(x) AS ( VALUES(1) UNION ALL SELECT (x+1)%10 FROM i)\n  SELECT x FROM i LIMIT 20;\n} {1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0}\n\ndo_execsql_test 5.5 {\n  WITH i(x) AS ( VALUES(1) UNION SELECT (x+1)%10 FROM i)\n  SELECT x FROM i LIMIT 20;\n} {1 2 3 4 5 6 7 8 9 0}\n\ndo_catchsql_test 5.6.1 {\n  WITH i(x, y) AS ( VALUES(1) )\n  SELECT * FROM i;\n} {1 {table i has 1 values for 2 columns}}\n\ndo_catchsql_test 5.6.2 {\n  WITH i(x) AS ( VALUES(1,2) )\n  SELECT * FROM i;\n} {1 {table i has 2 values for 1 columns}}\n\ndo_catchsql_test 5.6.3 {\n  CREATE TABLE t5(a, b);\n  WITH i(x) AS ( SELECT * FROM t5 )\n  SELECT * FROM i;\n} {1 {table i has 2 values for 1 columns}}\n\ndo_catchsql_test 5.6.4 {\n  WITH i(x) AS ( SELECT 1, 2 UNION ALL SELECT 1 )\n  SELECT * FROM i;\n} {1 {table i has 2 values for 1 columns}}\n\ndo_catchsql_test 5.6.5 {\n  WITH i(x) AS ( SELECT 1 UNION ALL SELECT 1, 2 )\n  SELECT * FROM i;\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\n\ndo_catchsql_test 5.6.6 {\n  WITH i(x) AS ( SELECT 1 UNION ALL SELECT x+1, x*2 FROM i )\n  SELECT * FROM i;\n} {1 {SELECTs to the left and right of UNION ALL do not have the same number of result columns}}\n\ndo_catchsql_test 5.6.7 {\n  WITH i(x) AS ( SELECT 1, 2 UNION SELECT x+1 FROM i )\n  SELECT * FROM i;\n} {1 {table i has 2 values for 1 columns}}\n\n#-------------------------------------------------------------------------\n#\ndo_execsql_test 6.1 {\n  CREATE TABLE f(\n      id INTEGER PRIMARY KEY, parentid REFERENCES f, name TEXT\n  );\n\n  INSERT INTO f VALUES(0, NULL, '');\n  INSERT INTO f VALUES(1, 0, 'bin');\n    INSERT INTO f VALUES(2, 1, 'true');\n    INSERT INTO f VALUES(3, 1, 'false');\n    INSERT INTO f VALUES(4, 1, 'ls');\n    INSERT INTO f VALUES(5, 1, 'grep');\n  INSERT INTO f VALUES(6, 0, 'etc');\n    INSERT INTO f VALUES(7, 6, 'rc.d');\n      INSERT INTO f VALUES(8, 7, 'rc.apache');\n      INSERT INTO f VALUES(9, 7, 'rc.samba');\n  INSERT INTO f VALUES(10, 0, 'home');\n    INSERT INTO f VALUES(11, 10, 'dan');\n      INSERT INTO f VALUES(12, 11, 'public_html');\n        INSERT INTO f VALUES(13, 12, 'index.html');\n          INSERT INTO f VALUES(14, 13, 'logo.gif');\n}\n\ndo_execsql_test 6.2 {\n  WITH flat(fid, fpath) AS (\n    SELECT id, '' FROM f WHERE parentid IS NULL\n    UNION ALL\n    SELECT id, fpath || '/' || name FROM f, flat WHERE parentid=fid\n  )\n  SELECT fpath FROM flat WHERE fpath!='' ORDER BY 1;\n} {\n  /bin \n  /bin/false /bin/grep /bin/ls /bin/true \n  /etc \n  /etc/rc.d \n  /etc/rc.d/rc.apache /etc/rc.d/rc.samba \n  /home \n  /home/dan \n  /home/dan/public_html \n  /home/dan/public_html/index.html \n  /home/dan/public_html/index.html/logo.gif\n}\n\ndo_execsql_test 6.3 {\n  WITH flat(fid, fpath) AS (\n    SELECT id, '' FROM f WHERE parentid IS NULL\n    UNION ALL\n    SELECT id, fpath || '/' || name FROM f, flat WHERE parentid=fid\n  )\n  SELECT count(*) FROM flat;\n} {15}\n\ndo_execsql_test 6.4 {\n  WITH x(i) AS (\n    SELECT 1\n    UNION ALL\n    SELECT i+1 FROM x WHERE i<10\n  )\n  SELECT count(*) FROM x\n} {10}\n\n\n#-------------------------------------------------------------------------\n\ndo_execsql_test 7.1 {\n  CREATE TABLE tree(i, p);\n  INSERT INTO tree VALUES(1, NULL);\n  INSERT INTO tree VALUES(2, 1);\n  INSERT INTO tree VALUES(3, 1);\n  INSERT INTO tree VALUES(4, 2);\n  INSERT INTO tree VALUES(5, 4);\n}\n\ndo_execsql_test 7.2 {\n  WITH t(id, path) AS (\n    SELECT i, '' FROM tree WHERE p IS NULL\n    UNION ALL\n    SELECT i, path || '/' || i FROM tree, t WHERE p = id\n  ) \n  SELECT path FROM t;\n} {{} /2 /3 /2/4 /2/4/5}\n\ndo_execsql_test 7.3 {\n  WITH t(id) AS (\n    VALUES(2)\n    UNION ALL\n    SELECT i FROM tree, t WHERE p = id\n  ) \n  SELECT id FROM t;\n} {2 4 5}\n\ndo_catchsql_test 7.4 {\n  WITH t(id) AS (\n    VALUES(2)\n    UNION ALL\n    SELECT i FROM tree WHERE p IN (SELECT id FROM t)\n  ) \n  SELECT id FROM t;\n} {1 {recursive reference in a subquery: t}}\n\ndo_catchsql_test 7.5 {\n  WITH t(id) AS (\n    VALUES(2)\n    UNION ALL\n    SELECT i FROM tree, t WHERE p = id AND p IN (SELECT id FROM t)\n  ) \n  SELECT id FROM t;\n} {1 {multiple recursive references: t}}\n\ndo_catchsql_test 7.6 {\n  WITH t(id) AS (\n    SELECT i FROM tree WHERE 2 IN (SELECT id FROM t)\n    UNION ALL\n    SELECT i FROM tree, t WHERE p = id\n  ) \n  SELECT id FROM t;\n} {1 {circular reference: t}}\n\n# Compute the mandelbrot set using a recursive query\n#\ndo_execsql_test 8.1-mandelbrot {\n  WITH RECURSIVE\n    xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2),\n    yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0),\n    m(iter, cx, cy, x, y) AS (\n      SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis\n      UNION ALL\n      SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m \n       WHERE (x*x + y*y) < 4.0 AND iter<28\n    ),\n    m2(iter, cx, cy) AS (\n      SELECT max(iter), cx, cy FROM m GROUP BY cx, cy\n    ),\n    a(t) AS (\n      SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') \n      FROM m2 GROUP BY cy\n    )\n  SELECT group_concat(rtrim(t),x'0a') FROM a;\n} {{                                    ....#\n                                   ..#*..\n                                 ..+####+.\n                            .......+####....   +\n                           ..##+*##########+.++++\n                          .+.##################+.\n              .............+###################+.+\n              ..++..#.....*#####################+.\n             ...+#######++#######################.\n          ....+*################################.\n #############################################...\n          ....+*################################.\n             ...+#######++#######################.\n              ..++..#.....*#####################+.\n              .............+###################+.+\n                          .+.##################+.\n                           ..##+*##########+.++++\n                            .......+####....   +\n                                 ..+####+.\n                                   ..#*..\n                                    ....#\n                                    +.}}\n\n# Solve a sudoku puzzle using a recursive query\n#\ndo_execsql_test 8.2-soduko {\n  WITH RECURSIVE\n    input(sud) AS (\n      VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')\n    ),\n  \n    /* A table filled with digits 1..9, inclusive. */\n    digits(z, lp) AS (\n      VALUES('1', 1)\n      UNION ALL SELECT\n      CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9\n    ),\n  \n    /* The tricky bit. */\n    x(s, ind) AS (\n      SELECT sud, instr(sud, '.') FROM input\n      UNION ALL\n      SELECT\n        substr(s, 1, ind-1) || z || substr(s, ind+1),\n        instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )\n       FROM x, digits AS z\n      WHERE ind>0\n        AND NOT EXISTS (\n              SELECT 1\n                FROM digits AS lp\n               WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)\n                  OR z.z = substr(s, ((ind-1)%9) + (lp-1)*9 + 1, 1)\n                  OR z.z = substr(s, (((ind-1)/3) % 3) * 3\n                          + ((ind-1)/27) * 27 + lp\n                          + ((lp-1) / 3) * 6, 1)\n           )\n    )\n  SELECT s FROM x WHERE ind=0;\n} {534678912672195348198342567859761423426853791713924856961537284287419635345286179}\n\n#--------------------------------------------------------------------------\n# Some tests that use LIMIT and OFFSET in the definition of recursive CTEs.\n# \nset I [list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]\nproc limit_test {tn iLimit iOffset} {\n  if {$iOffset < 0} { set iOffset 0 }\n  if {$iLimit < 0 } {\n    set result [lrange $::I $iOffset end]\n  } else {\n    set result [lrange $::I $iOffset [expr $iLimit+$iOffset-1]]\n  }\n  uplevel [list do_execsql_test $tn [subst -nocommands {\n    WITH ii(a) AS (\n      VALUES(1)\n      UNION ALL \n      SELECT a+1 FROM ii WHERE a<20 \n      LIMIT $iLimit OFFSET $iOffset\n    )\n    SELECT * FROM ii\n  }] $result]\n}\n\nlimit_test 9.1    20  0\nlimit_test 9.2     0  0\nlimit_test 9.3    19  1\nlimit_test 9.4    20 -1\nlimit_test 9.5     5  5\nlimit_test 9.6     0 -1\nlimit_test 9.7    40 -1\nlimit_test 9.8    -1 -1\nlimit_test 9.9    -1 -1\n\n#--------------------------------------------------------------------------\n# Test the ORDER BY clause on recursive tables.\n#\n\ndo_execsql_test 10.1 {\n  DROP TABLE IF EXISTS tree;\n  CREATE TABLE tree(id INTEGER PRIMARY KEY, parentid, payload);\n}\n\nproc insert_into_tree {L} {\n  db eval { DELETE FROM tree }\n  foreach key $L {\n    unset -nocomplain parentid\n    foreach seg [split $key /] {\n      if {$seg==\"\"} continue\n      set id [db one {\n        SELECT id FROM tree WHERE parentid IS $parentid AND payload=$seg\n      }]\n      if {$id==\"\"} {\n        db eval { INSERT INTO tree VALUES(NULL, $parentid, $seg) }\n        set parentid [db last_insert_rowid]\n      } else {\n        set parentid $id\n      }\n    }\n  }\n}\n\ninsert_into_tree {\n  /a/a/a\n  /a/b/c\n  /a/b/c/d\n  /a/b/d\n}\ndo_execsql_test 10.2 {\n  WITH flat(fid, p) AS (\n    SELECT id, '/' || payload FROM tree WHERE parentid IS NULL\n    UNION ALL\n    SELECT id, p || '/' || payload FROM flat, tree WHERE parentid=fid\n  )\n  SELECT p FROM flat ORDER BY p;\n} {\n  /a /a/a /a/a/a \n     /a/b /a/b/c /a/b/c/d\n          /a/b/d\n}\n\n# Scan the tree-structure currently stored in table tree. Return a list\n# of nodes visited.\n#\nproc scan_tree {bDepthFirst bReverse} {\n\n  set order \"ORDER BY \"\n  if {$bDepthFirst==0} { append order \"2 ASC,\" }\n  if {$bReverse==0} { \n    append order \" 3 ASC\" \n  } else {\n    append order \" 3 DESC\" \n  }\n\n  db eval \"\n    WITH flat(fid, depth, p) AS (\n        SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL\n        UNION ALL\n        SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid\n        $order\n    )\n    SELECT p FROM flat;\n  \"\n}\n\ninsert_into_tree {\n  /a/b\n  /a/b/c\n  /a/d\n  /a/d/e\n  /a/d/f\n  /g/h\n}\n\n# Breadth first, siblings in ascending order.\n#\ndo_test 10.3 {\n  scan_tree 0 0\n} [list {*}{\n  /a /g\n  /a/b /a/d /g/h\n  /a/b/c /a/d/e /a/d/f\n}]\n\n# Depth first, siblings in ascending order.\n#\ndo_test 10.4 {\n  scan_tree 1 0\n} [list {*}{\n  /a /a/b /a/b/c\n     /a/d /a/d/e \n          /a/d/f\n  /g /g/h\n}]\n\n# Breadth first, siblings in descending order.\n#\ndo_test 10.5 {\n  scan_tree 0 1\n} [list {*}{\n  /g /a \n  /g/h /a/d /a/b \n  /a/d/f /a/d/e /a/b/c \n}]\n\n# Depth first, siblings in ascending order.\n#\ndo_test 10.6 {\n  scan_tree 1 1\n} [list {*}{\n  /g /g/h\n  /a /a/d /a/d/f \n          /a/d/e \n     /a/b /a/b/c\n}]\n\n\n# Test name resolution in ORDER BY clauses.\n#\ndo_catchsql_test 10.7.1 {\n  WITH t(a) AS (\n    SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY a\n  ) \n  SELECT * FROM t\n} {1 {1st ORDER BY term does not match any column in the result set}}\ndo_execsql_test 10.7.2 {\n  WITH t(a) AS (\n    SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY b\n  ) \n  SELECT * FROM t\n} {1 2 3 4 5}\ndo_execsql_test 10.7.3 {\n  WITH t(a) AS (\n    SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY c\n  ) \n  SELECT * FROM t\n} {1 2 3 4 5}\n\n# Test COLLATE clauses attached to ORDER BY.\n#\ninsert_into_tree {\n  /a/b\n  /a/C\n  /a/d\n  /B/e\n  /B/F\n  /B/g\n  /c/h\n  /c/I\n  /c/j\n}\n\ndo_execsql_test 10.8.1 {\n  WITH flat(fid, depth, p) AS (\n    SELECT id, 1, '/' || payload FROM tree WHERE parentid IS NULL\n    UNION ALL\n    SELECT id, depth+1, p||'/'||payload FROM flat, tree WHERE parentid=fid\n    ORDER BY 2, 3 COLLATE nocase\n  )\n  SELECT p FROM flat;\n} {\n  /a /B /c\n  /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j\n}\ndo_execsql_test 10.8.2 {\n  WITH flat(fid, depth, p) AS (\n      SELECT id, 1, ('/' || payload) COLLATE nocase \n      FROM tree WHERE parentid IS NULL\n    UNION ALL\n      SELECT id, depth+1, (p||'/'||payload)\n      FROM flat, tree WHERE parentid=fid\n    ORDER BY 2, 3\n  )\n  SELECT p FROM flat;\n} {\n  /a /B /c\n  /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j\n}\n\ndo_execsql_test 10.8.3 {\n  WITH flat(fid, depth, p) AS (\n      SELECT id, 1, ('/' || payload)\n      FROM tree WHERE parentid IS NULL\n    UNION ALL\n      SELECT id, depth+1, (p||'/'||payload) COLLATE nocase \n      FROM flat, tree WHERE parentid=fid\n    ORDER BY 2, 3\n  )\n  SELECT p FROM flat;\n} {\n  /a /B /c\n  /a/b /a/C /a/d /B/e /B/F /B/g /c/h /c/I /c/j\n}\n\ndo_execsql_test 10.8.4.1 {\n  CREATE TABLE tst(a,b);\n  INSERT INTO tst VALUES('a', 'A');\n  INSERT INTO tst VALUES('b', 'B');\n  INSERT INTO tst VALUES('c', 'C');\n  SELECT a COLLATE nocase FROM tst UNION ALL SELECT b FROM tst ORDER BY 1;\n} {a A b B c C}\ndo_execsql_test 10.8.4.2 {\n  SELECT a FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1;\n} {A B C a b c}\ndo_execsql_test 10.8.4.3 {\n  SELECT a||'' FROM tst UNION ALL SELECT b COLLATE nocase FROM tst ORDER BY 1;\n} {a A b B c C}\n\n# Test cases to illustrate on the ORDER BY clause on a recursive query can be\n# used to control depth-first versus breath-first search in a tree.\n#\ndo_execsql_test 11.1 {\n  CREATE TABLE org(\n    name TEXT PRIMARY KEY,\n    boss TEXT REFERENCES org\n  ) WITHOUT ROWID;\n  INSERT INTO org VALUES('Alice',NULL);\n  INSERT INTO org VALUES('Bob','Alice');\n  INSERT INTO org VALUES('Cindy','Alice');\n  INSERT INTO org VALUES('Dave','Bob');\n  INSERT INTO org VALUES('Emma','Bob');\n  INSERT INTO org VALUES('Fred','Cindy');\n  INSERT INTO org VALUES('Gail','Cindy');\n  INSERT INTO org VALUES('Harry','Dave');\n  INSERT INTO org VALUES('Ingrid','Dave');\n  INSERT INTO org VALUES('Jim','Emma');\n  INSERT INTO org VALUES('Kate','Emma');\n  INSERT INTO org VALUES('Lanny','Fred');\n  INSERT INTO org VALUES('Mary','Fred');\n  INSERT INTO org VALUES('Noland','Gail');\n  INSERT INTO org VALUES('Olivia','Gail');\n  -- The above are all under Alice.  Add a few more records for people\n  -- not in Alice's group, just to prove that they won't be selected.\n  INSERT INTO org VALUES('Xaviar',NULL);\n  INSERT INTO org VALUES('Xia','Xaviar');\n  INSERT INTO org VALUES('Xerxes','Xaviar');\n  INSERT INTO org VALUES('Xena','Xia');\n  -- Find all members of Alice's group, breath-first order  \n  WITH RECURSIVE\n    under_alice(name,level) AS (\n       VALUES('Alice','0')\n       UNION ALL\n       SELECT org.name, under_alice.level+1\n         FROM org, under_alice\n        WHERE org.boss=under_alice.name\n        ORDER BY 2\n    )\n  SELECT group_concat(substr('...............',1,level*3) || name,x'0a')\n    FROM under_alice;\n} {{Alice\n...Bob\n...Cindy\n......Dave\n......Emma\n......Fred\n......Gail\n.........Harry\n.........Ingrid\n.........Jim\n.........Kate\n.........Lanny\n.........Mary\n.........Noland\n.........Olivia}}\n\n# The previous query used \"ORDER BY level\" to yield a breath-first search.\n# Change that to \"ORDER BY level DESC\" for a depth-first search.\n#\ndo_execsql_test 11.2 {\n  WITH RECURSIVE\n    under_alice(name,level) AS (\n       VALUES('Alice','0')\n       UNION ALL\n       SELECT org.name, under_alice.level+1\n         FROM org, under_alice\n        WHERE org.boss=under_alice.name\n        ORDER BY 2 DESC\n    )\n  SELECT group_concat(substr('...............',1,level*3) || name,x'0a')\n    FROM under_alice;\n} {{Alice\n...Bob\n......Dave\n.........Harry\n.........Ingrid\n......Emma\n.........Jim\n.........Kate\n...Cindy\n......Fred\n.........Lanny\n.........Mary\n......Gail\n.........Noland\n.........Olivia}}\n\n# Without an ORDER BY clause, the recursive query should use a FIFO,\n# resulting in a breath-first search.\n#\ndo_execsql_test 11.3 {\n  WITH RECURSIVE\n    under_alice(name,level) AS (\n       VALUES('Alice','0')\n       UNION ALL\n       SELECT org.name, under_alice.level+1\n         FROM org, under_alice\n        WHERE org.boss=under_alice.name\n    )\n  SELECT group_concat(substr('...............',1,level*3) || name,x'0a')\n    FROM under_alice;\n} {{Alice\n...Bob\n...Cindy\n......Dave\n......Emma\n......Fred\n......Gail\n.........Harry\n.........Ingrid\n.........Jim\n.........Kate\n.........Lanny\n.........Mary\n.........Noland\n.........Olivia}}\n\n#--------------------------------------------------------------------------\n# Ticket [31a19d11b97088296ac104aaff113a9790394927] (2014-02-09)\n# Name resolution issue with compound SELECTs and Common Table Expressions \n#\ndo_execsql_test 12.1 {\nWITH RECURSIVE\n  t1(x) AS (VALUES(2) UNION ALL SELECT x+2 FROM t1 WHERE x<20),\n  t2(y) AS (VALUES(3) UNION ALL SELECT y+3 FROM t2 WHERE y<20)\nSELECT x FROM t1 EXCEPT SELECT y FROM t2 ORDER BY 1;\n} {2 4 8 10 14 16 20}\n\n# 2015-03-21\n# Column wildcards on the LHS of a recursive table expression\n#\ndo_catchsql_test 13.1 {\n  WITH RECURSIVE c(i) AS (SELECT * UNION ALL SELECT i+1 FROM c WHERE i<10)\n  SELECT i FROM c;\n} {1 {no tables specified}}\ndo_catchsql_test 13.2 {\n  WITH RECURSIVE c(i) AS (SELECT 5,* UNION ALL SELECT i+1 FROM c WHERE i<10)\n  SELECT i FROM c;\n} {1 {no tables specified}}\ndo_catchsql_test 13.3 {\n  WITH RECURSIVE c(i,j) AS (SELECT 5,* UNION ALL SELECT i+1,11 FROM c WHERE i<10)\n  SELECT i FROM c;\n} {1 {table c has 1 values for 2 columns}}\n\n# 2015-04-12\n#\ndo_execsql_test 14.1 {\n  WITH x AS (SELECT * FROM t) SELECT 0 EXCEPT SELECT 0 ORDER BY 1 COLLATE binary;\n} {}\n\n# 2015-05-27:  Do not allow rowid usage within a CTE\n#\ndo_catchsql_test 15.1 {\n  WITH RECURSIVE\n    d(x) AS (VALUES(1) UNION ALL SELECT rowid+1 FROM d WHERE rowid<10)\n  SELECT x FROM d;\n} {1 {no such column: rowid}}\n\n# 2015-07-05:  Do not allow aggregate recursive queries\n#\ndo_catchsql_test 16.1 {\n  WITH RECURSIVE\n    i(x) AS (VALUES(1) UNION SELECT count(*) FROM i)\n  SELECT * FROM i;\n} {1 {recursive aggregate queries not supported}}\n\n#-------------------------------------------------------------------------\ndo_execsql_test 17.1 {\n  WITH x(a) AS (\n    WITH y(b) AS (SELECT 10)\n    SELECT 9 UNION ALL SELECT * FROM y\n  )\n  SELECT * FROM x\n} {9 10}\n\ndo_execsql_test 17.2 {\n  WITH x AS (\n    WITH y(b) AS (SELECT 10)\n    SELECT * FROM y UNION ALL SELECT * FROM y\n  )\n  SELECT * FROM x\n} {10 10}\n\ndo_test 17.2 {\n  db eval {\n    WITH x AS (\n        WITH y(b) AS (SELECT 10)\n        SELECT * FROM y UNION ALL SELECT * FROM y\n    )\n    SELECT * FROM x\n  } A {\n    # no op\n  }\n  set A(*)\n} {b}\n\ndo_catchsql_test 17.3 {\n  WITH i AS (\n    WITH j AS (SELECT 5)\n    SELECT 5 FROM i UNION SELECT 8 FROM i\n  )\n  SELECT * FROM i;\n} {1 {circular reference: i}}\n\ndo_catchsql_test 17.4 {\n  WITH i AS (\n    WITH j AS (SELECT 5)\n    SELECT 5 FROM t1 UNION SELECT 8 FROM t11\n  )\n  SELECT * FROM i;\n} {1 {no such table: t11}}\n\ndo_execsql_test 17.5 {\n  WITH \n  x1 AS (SELECT 10),\n  x2 AS (SELECT * FROM x1),\n  x3 AS (\n    WITH x1 AS (SELECT 11)\n    SELECT * FROM x2 UNION ALL SELECT * FROM x2\n  )\n  SELECT * FROM x3;\n} {10 10}\n\ndo_execsql_test 17.6 {\n  WITH \n  x1 AS (SELECT 10),\n  x2 AS (SELECT * FROM x1),\n  x3 AS (\n    WITH x1 AS (SELECT 11)\n    SELECT * FROM x2 UNION ALL SELECT * FROM x1\n  )\n  SELECT * FROM x3;\n} {10 11}\n\ndo_execsql_test 17.7 {\n  WITH \n  x1 AS (SELECT 10),\n  x2 AS (SELECT * FROM x1),\n  x3 AS (\n    WITH \n      x1 AS ( SELECT 11 ),\n      x4 AS ( SELECT * FROM x2 )\n    SELECT * FROM x4 UNION ALL SELECT * FROM x1\n  )\n  SELECT * FROM x3;\n} {10 11}\n\ndo_execsql_test 17.8 {\n  WITH \n  x1 AS (SELECT 10),\n  x2 AS (SELECT * FROM x1),\n  x3 AS (\n    WITH \n      x1 AS ( SELECT 11 ),\n      x4 AS ( SELECT * FROM x2 )\n    SELECT * FROM x4 UNION ALL SELECT * FROM x1\n  )\n  SELECT * FROM x3;\n} {10 11}\n\ndo_execsql_test 17.9 {\n  WITH \n  x1 AS (SELECT 10),\n  x2 AS (SELECT 11),\n  x3 AS (\n    SELECT * FROM x1 UNION ALL SELECT * FROM x2\n  ),\n  x4 AS (\n    WITH \n    x1 AS (SELECT 12),\n    x2 AS (SELECT 13)\n    SELECT * FROM x3\n  )\n  SELECT * FROM x4;\n} {10 11}\n\n# Added to test a fix to a faulty assert() discovered by libFuzzer.\n#\ndo_execsql_test 18.1 {\n  WITH xyz(x) AS (VALUES(NULL) UNION SELECT round(1<x) FROM xyz ORDER BY 1)\n  SELECT quote(x) FROM xyz;\n} {NULL}\ndo_execsql_test 18.2 {\n  WITH xyz(x) AS (\n    SELECT printf('%d', 5) * NULL\n    UNION SELECT round(1<1+x) \n    FROM xyz ORDER BY 1\n  )\n  SELECT 1 FROM xyz;\n} 1\n\n# EXPLAIN QUERY PLAN on a self-join of a CTE\n#\ndo_execsql_test 19.1 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(x);\n  EXPLAIN QUERY PLAN\n  WITH\n    x1(a) AS (values(100))\n  INSERT INTO t1(x)\n    SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2);\n  SELECT * FROM t1;\n} {0 0 0 {SCAN SUBQUERY 1} 0 1 1 {SCAN SUBQUERY 1}}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/with2.test",
    "content": "# 2014 January 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the WITH clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix with2\n\nifcapable {!cte} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a);\n  INSERT INTO t1 VALUES(1);\n  INSERT INTO t1 VALUES(2);\n}\n\ndo_execsql_test 1.1 {\n  WITH x1 AS (SELECT * FROM t1)\n  SELECT sum(a) FROM x1;\n} {3}\n\ndo_execsql_test 1.2 {\n  WITH x1 AS (SELECT * FROM t1)\n  SELECT (SELECT sum(a) FROM x1);\n} {3}\n\ndo_execsql_test 1.3 {\n  WITH x1 AS (SELECT * FROM t1)\n  SELECT (SELECT sum(a) FROM x1);\n} {3}\n\ndo_execsql_test 1.4 {\n  CREATE TABLE t2(i);\n  INSERT INTO t2 VALUES(2);\n  INSERT INTO t2 VALUES(3);\n  INSERT INTO t2 VALUES(5);\n\n  WITH x1   AS (SELECT i FROM t2),\n       i(a) AS (\n         SELECT min(i)-1 FROM x1 UNION SELECT a+1 FROM i WHERE a<10\n       )\n  SELECT a FROM i WHERE a NOT IN x1\n} {1 4 6 7 8 9 10}\n\ndo_execsql_test 1.5 {\n  WITH x1 AS (SELECT a FROM t1),\n       x2 AS (SELECT i FROM t2),\n       x3 AS (SELECT * FROM x1, x2 WHERE x1.a IN x2 AND x2.i IN x1)\n  SELECT * FROM x3 \n} {2 2}\n\ndo_execsql_test 1.6 {\n  CREATE TABLE t3 AS SELECT 3 AS x;\n  CREATE TABLE t4 AS SELECT 4 AS x;\n\n  WITH x1 AS (SELECT * FROM t3),\n       x2 AS (\n         WITH t3 AS (SELECT * FROM t4)\n         SELECT * FROM x1\n       )\n  SELECT * FROM x2;\n} {3}\n\ndo_execsql_test 1.7 {\n  WITH x2 AS (\n         WITH t3 AS (SELECT * FROM t4)\n         SELECT * FROM t3\n       )\n  SELECT * FROM x2;\n} {4}\n\ndo_execsql_test 1.8 {\n  WITH x2 AS (\n         WITH t3 AS (SELECT * FROM t4)\n         SELECT * FROM main.t3\n       )\n  SELECT * FROM x2;\n} {3}\n\ndo_execsql_test 1.9 {\n  WITH x1 AS (SELECT * FROM t1)\n  SELECT (SELECT sum(a) FROM x1), (SELECT max(a) FROM x1);\n} {3 2}\n\ndo_execsql_test 1.10 {\n  WITH x1 AS (SELECT * FROM t1)\n  SELECT (SELECT sum(a) FROM x1), (SELECT max(a) FROM x1), a FROM x1;\n} {3 2 1 3 2 2}\n\ndo_execsql_test 1.11 {\n  WITH \n  i(x) AS ( \n    WITH \n    j(x) AS ( SELECT * FROM i ), \n    i(x) AS ( SELECT * FROM t1 )\n    SELECT * FROM j\n  )\n  SELECT * FROM i;\n} {1 2}\n\ndo_execsql_test 1.12 {\n  WITH r(i) AS (\n    VALUES('.')\n    UNION ALL\n    SELECT i || '.' FROM r, (\n      SELECT x FROM x INTERSECT SELECT y FROM y\n    ) WHERE length(i) < 10\n  ),\n  x(x) AS ( VALUES(1) UNION ALL VALUES(2) UNION ALL VALUES(3) ),\n  y(y) AS ( VALUES(2) UNION ALL VALUES(4) UNION ALL VALUES(6) )\n\n  SELECT * FROM r;\n} {. .. ... .... ..... ...... ....... ........ ......... ..........}\n\ndo_execsql_test 1.13 {\n  WITH r(i) AS (\n    VALUES('.')\n    UNION ALL\n    SELECT i || '.' FROM r, ( SELECT x FROM x WHERE x=2 ) WHERE length(i) < 10\n  ),\n  x(x) AS ( VALUES(1) UNION ALL VALUES(2) UNION ALL VALUES(3) )\n\n  SELECT * FROM r ORDER BY length(i) DESC;\n} {.......... ......... ........ ....... ...... ..... .... ... .. .}\n\ndo_execsql_test 1.14 {\n  WITH \n  t4(x) AS ( \n    VALUES(4)\n    UNION ALL \n    SELECT x+1 FROM t4 WHERE x<10\n  )\n  SELECT * FROM t4;\n} {4 5 6 7 8 9 10}\n\ndo_execsql_test 1.15 {\n  WITH \n  t4(x) AS ( \n    VALUES(4)\n    UNION ALL \n    SELECT x+1 FROM main.t4 WHERE x<10\n  )\n  SELECT * FROM t4;\n} {4 5}\n\ndo_catchsql_test 1.16 {\n  WITH \n  t4(x) AS ( \n    VALUES(4)\n    UNION ALL \n    SELECT x+1 FROM t4, main.t4, t4 WHERE x<10\n  )\n  SELECT * FROM t4;\n} {1 {multiple references to recursive table: t4}}\n\n\n#---------------------------------------------------------------------------\n# Check that variables can be used in CTEs.\n#\nset ::min [expr 3]\nset ::max [expr 9]\ndo_execsql_test 2.1 {\n  WITH i(x) AS (\n    VALUES($min) UNION ALL SELECT x+1 FROM i WHERE x < $max\n  )\n  SELECT * FROM i;\n} {3 4 5 6 7 8 9}\n\ndo_execsql_test 2.2 {\n  WITH i(x) AS (\n    VALUES($min) UNION ALL SELECT x+1 FROM i WHERE x < $max\n  )\n  SELECT x FROM i JOIN i AS j USING (x);\n} {3 4 5 6 7 8 9}\n\n#---------------------------------------------------------------------------\n# Check that circular references are rejected.\n#\ndo_catchsql_test 3.1 {\n  WITH i(x, y) AS ( VALUES(1, (SELECT x FROM i)) )\n  SELECT * FROM i;\n} {1 {circular reference: i}}\n\ndo_catchsql_test 3.2 {\n  WITH \n  i(x) AS ( SELECT * FROM j ),\n  j(x) AS ( SELECT * FROM k ),\n  k(x) AS ( SELECT * FROM i )\n  SELECT * FROM i;\n} {1 {circular reference: i}}\n\ndo_catchsql_test 3.3 {\n  WITH \n  i(x) AS ( SELECT * FROM (SELECT * FROM j) ),\n  j(x) AS ( SELECT * FROM (SELECT * FROM i) )\n  SELECT * FROM i;\n} {1 {circular reference: i}}\n\ndo_catchsql_test 3.4 {\n  WITH \n  i(x) AS ( SELECT * FROM (SELECT * FROM j) ),\n  j(x) AS ( SELECT * FROM (SELECT * FROM i) )\n  SELECT * FROM j;\n} {1 {circular reference: j}}\n\ndo_catchsql_test 3.5 {\n  WITH \n  i(x) AS ( \n    WITH j(x) AS ( SELECT * FROM i )\n    SELECT * FROM j\n  )\n  SELECT * FROM i;\n} {1 {circular reference: i}}\n\n#---------------------------------------------------------------------------\n# Try empty and very long column lists.\n#\ndo_catchsql_test 4.1 {\n  WITH x() AS ( SELECT 1,2,3 )\n  SELECT * FROM x;\n} {1 {near \")\": syntax error}}\n\nproc genstmt {n} {\n  for {set i 1} {$i<=$n} {incr i} {\n    lappend cols \"c$i\"\n    lappend vals $i\n  }\n  return \"\n    WITH x([join $cols ,]) AS (SELECT [join $vals ,])\n    SELECT (c$n == $n) FROM x\n  \"\n}\n\ndo_execsql_test  4.2 [genstmt 10] 1\ndo_execsql_test  4.3 [genstmt 100] 1\ndo_execsql_test  4.4 [genstmt 255] 1\nset nLimit [sqlite3_limit db SQLITE_LIMIT_COLUMN -1]\ndo_execsql_test  4.5 [genstmt [expr $nLimit-1]] 1\ndo_execsql_test  4.6 [genstmt $nLimit] 1\ndo_catchsql_test 4.7 [genstmt [expr $nLimit+1]] \\\n  {1 {too many columns in result set}}\n\n#---------------------------------------------------------------------------\n# Check that adding a WITH clause to an INSERT disables the xfer \n# optimization.\n#\nproc do_xfer_test {tn bXfer sql {res {}}} {\n  set ::sqlite3_xferopt_count 0\n  uplevel [list do_test $tn [subst -nocommands {\n    set dres [db eval {$sql}]\n    list [set ::sqlite3_xferopt_count] [set dres]\n  }] [list $bXfer $res]]\n}\n\ndo_execsql_test 5.1 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n}\n\ndo_xfer_test 5.2 1 { INSERT INTO t1 SELECT * FROM t2 }\ndo_xfer_test 5.3 0 { INSERT INTO t1 SELECT a, b FROM t2 }\ndo_xfer_test 5.4 0 { INSERT INTO t1 SELECT b, a FROM t2 }\ndo_xfer_test 5.5 0 { \n  WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM x \n}\ndo_xfer_test 5.6 0 { \n  WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM t2 \n}\ndo_xfer_test 5.7 0 { \n INSERT INTO t1 WITH x AS ( SELECT * FROM t2 ) SELECT * FROM x\n}\ndo_xfer_test 5.8 0 { \n INSERT INTO t1 WITH x(a,b) AS ( SELECT * FROM t2 ) SELECT * FROM x\n}\n\n#---------------------------------------------------------------------------\n# Check that syntax (and other) errors in statements with WITH clauses\n# attached to them do not cause problems (e.g. memory leaks).\n#\ndo_execsql_test 6.1 {\n  DROP TABLE IF EXISTS t1;\n  DROP TABLE IF EXISTS t2;\n  CREATE TABLE t1(a, b);\n  CREATE TABLE t2(a, b);\n}\n\ndo_catchsql_test 6.2 {\n  WITH x AS (SELECT * FROM t1)\n  INSERT INTO t2 VALUES(1, 2,);\n} {1 {near \")\": syntax error}}\n\ndo_catchsql_test 6.3 {\n  WITH x AS (SELECT * FROM t1)\n  INSERT INTO t2 SELECT a, b, FROM t1;\n} {1 {near \"FROM\": syntax error}}\n\ndo_catchsql_test 6.3 {\n  WITH x AS (SELECT * FROM t1)\n  INSERT INTO t2 SELECT a, b FROM abc;\n} {1 {no such table: abc}}\n\ndo_catchsql_test 6.4 {\n  WITH x AS (SELECT * FROM t1)\n  INSERT INTO t2 SELECT a, b, FROM t1 a a a;\n} {1 {near \"FROM\": syntax error}}\n\ndo_catchsql_test 6.5 {\n  WITH x AS (SELECT * FROM t1)\n  DELETE FROM t2 WHERE;\n} {1 {near \";\": syntax error}}\n\ndo_catchsql_test 6.6 { \n  WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHERE\n} {/1 {near .* syntax error}/}\n\ndo_catchsql_test 6.7 { \n  WITH x AS (SELECT * FROM t1) DELETE FROM t2 WHRE 1;\n} {/1 {near .* syntax error}/}\n\ndo_catchsql_test 6.8 { \n  WITH x AS (SELECT * FROM t1) UPDATE t2 SET a = 10, b = ;\n} {/1 {near .* syntax error}/}\n\ndo_catchsql_test 6.9 { \n  WITH x AS (SELECT * FROM t1) UPDATE t2 SET a = 10, b = 1 WHERE a===b;\n} {/1 {near .* syntax error}/}\n\ndo_catchsql_test 6.10 {\n  WITH x(a,b) AS (\n    SELECT 1, 1\n    UNION ALL\n    SELECT a*b,a+b FROM x WHERE c=2\n  )\n  SELECT * FROM x\n} {1 {no such column: c}}\n\n#-------------------------------------------------------------------------\n# Recursive queries in IN(...) expressions.\n#\ndo_execsql_test 7.1 {\n  CREATE TABLE t5(x INTEGER);\n  CREATE TABLE t6(y INTEGER);\n\n  WITH s(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM s WHERE x<49 )\n  INSERT INTO t5 \n  SELECT * FROM s;\n\n  INSERT INTO t6 \n  WITH s(x) AS ( VALUES(2) UNION ALL SELECT x+2 FROM s WHERE x<49 )\n  SELECT * FROM s;\n}\n\ndo_execsql_test 7.2 {\n  SELECT * FROM t6 WHERE y IN (SELECT x FROM t5)\n} {14 28 42}\n\ndo_execsql_test 7.3 {\n  WITH ss AS (SELECT x FROM t5)\n  SELECT * FROM t6 WHERE y IN (SELECT x FROM ss)\n} {14 28 42}\n\ndo_execsql_test 7.4 {\n  WITH ss(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM ss WHERE x<49 )\n  SELECT * FROM t6 WHERE y IN (SELECT x FROM ss)\n} {14 28 42}\n\ndo_execsql_test 7.5 {\n  SELECT * FROM t6 WHERE y IN (\n    WITH ss(x) AS ( VALUES(7) UNION ALL SELECT x+7 FROM ss WHERE x<49 )\n    SELECT x FROM ss\n  )\n} {14 28 42}\n\n#-------------------------------------------------------------------------\n# At one point the following was causing an assertion failure and a \n# memory leak.\n#\ndo_execsql_test 8.1 {\n  CREATE TABLE t7(y);\n  INSERT INTO t7 VALUES(NULL);\n  CREATE VIEW v AS SELECT * FROM t7 ORDER BY y;\n}\n\ndo_execsql_test 8.2 {\n  WITH q(a) AS (\n    SELECT 1\n    UNION \n    SELECT a+1 FROM q, v WHERE a<5\n  )\n  SELECT * FROM q;\n} {1 2 3 4 5}\n\ndo_execsql_test 8.3 {\n  WITH q(a) AS (\n    SELECT 1\n    UNION ALL\n    SELECT a+1 FROM q, v WHERE a<5\n  )\n  SELECT * FROM q;\n} {1 2 3 4 5}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/with3.test",
    "content": "# 2015-11-07\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the WITH clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset ::testprefix with3\n\nifcapable {!cte} {\n  finish_test\n  return\n}\n\n# Test problems found by Kostya Serebryany using \n# LibFuzzer.  (http://llvm.org/docs/LibFuzzer.html)\n#\ndo_catchsql_test 1.0 {\n  WITH i(x) AS (\n    WITH j AS (SELECT 10)\n    SELECT 5 FROM t0 UNION SELECT 8 FROM m\n  )\n  SELECT * FROM i;\n} {1 {no such table: m}}\n\n# Additional test cases that came out of the work to\n# fix for Kostya's problem.\n#\ndo_execsql_test 2.0 {\n WITH\n  x1 AS (SELECT 10),\n  x2 AS (SELECT 11),\n  x3 AS (\n    SELECT * FROM x1 UNION ALL SELECT * FROM x2\n  ),\n  x4 AS (\n    WITH\n    x1 AS (SELECT 12),\n    x2 AS (SELECT 13)\n    SELECT * FROM x3\n  )\n  SELECT * FROM x4;\n\n} {10 11}\n\ndo_execsql_test 2.1 {\n  CREATE TABLE t1(x);\n  WITH\n    x1(a) AS (values(100))\n  INSERT INTO t1(x)\n    SELECT * FROM (WITH x2(y) AS (SELECT * FROM x1) SELECT y+a FROM x1, x2);\n  SELECT * FROM t1;\n} {200}\n\n#-------------------------------------------------------------------------\n# Test that the planner notices LIMIT clauses on recursive WITH queries.\n#\n\nifcapable analyze {\n  do_execsql_test 3.1.1 {\n    CREATE TABLE y1(a, b);\n    CREATE INDEX y1a ON y1(a);\n\n    WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000)\n      INSERT INTO y1 SELECT i%10, i FROM cnt;\n    ANALYZE;\n\n  }\n\n  do_eqp_test 3.1.2 {\n    WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1)\n    SELECT * FROM cnt, y1 WHERE i=a\n  } {\n    3 0 0 {SCAN TABLE cnt} \n    1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)}\n    0 0 0 {SCAN SUBQUERY 1} \n    0 1 1 {SEARCH TABLE y1 USING INDEX y1a (a=?)}\n  }\n\n  do_eqp_test 3.1.3 {\n    WITH cnt(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM cnt LIMIT 1000000)\n    SELECT * FROM cnt, y1 WHERE i=a\n  } {\n    3 0 0 {SCAN TABLE cnt} \n    1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)}\n    0 0 1 {SCAN TABLE y1} \n    0 1 0 {SEARCH SUBQUERY 1 USING AUTOMATIC COVERING INDEX (i=?)}\n  }\n}\n\ndo_execsql_test 3.2.1 {\n  CREATE TABLE w1(pk INTEGER PRIMARY KEY, x INTEGER);\n  CREATE TABLE w2(pk INTEGER PRIMARY KEY);\n}\n\ndo_eqp_test 3.2.2 {\n  WITH RECURSIVE c(w,id) AS (SELECT 0, (SELECT pk FROM w2 LIMIT 1)\n     UNION ALL SELECT c.w + 1, x FROM w1, c LIMIT 1)\n     SELECT * FROM c, w2, w1\n     WHERE c.id=w2.pk AND c.id=w1.pk;\n} {\n  2 0 0 {EXECUTE SCALAR SUBQUERY 3} \n  3 0 0 {SCAN TABLE w2} \n  4 0 0 {SCAN TABLE w1}\n  4 1 1 {SCAN TABLE c} \n  1 0 0 {COMPOUND SUBQUERIES 0 AND 0 (UNION ALL)} 0 0 0 {SCAN SUBQUERY 1}\n  0 1 1 {SEARCH TABLE w2 USING INTEGER PRIMARY KEY (rowid=?)} \n  0 2 2 {SEARCH TABLE w1 USING INTEGER PRIMARY KEY (rowid=?)}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/withM.test",
    "content": "# 2014 January 11\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing the WITH clause.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nsource $testdir/malloc_common.tcl\nset ::testprefix withM\n\nifcapable {!cte} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(x INTEGER, y INTEGER);\n  INSERT INTO t1 VALUES(123, 456);\n}\n\ndo_faultsim_test withM-1.1 -prep {\n  sqlite3 db test.db\n} -body {\n  execsql { \n    WITH tmp AS ( SELECT * FROM t1 )\n    SELECT * FROM tmp;\n  }\n} -test {\n  faultsim_test_result {0 {123 456}}\n  db close\n}\n\ndo_faultsim_test withM-1.2 -prep {\n  sqlite3 db test.db\n} -body {\n  execsql { \n    WITH w1 AS ( SELECT * FROM t1 ),\n         w2 AS ( \n           WITH w3 AS ( SELECT * FROM w1 )\n           SELECT * FROM w3\n         )\n    SELECT * FROM w2;\n  }\n} -test {\n  faultsim_test_result {0 {123 456}}\n  db close\n}\n\ndo_faultsim_test withM-1.3 -prep {\n  sqlite3 db test.db\n} -body {\n  execsql { \n    WITH w1(a,b) AS ( \n      SELECT 1, 1\n      UNION ALL\n      SELECT a+1, b + 2*a + 1 FROM w1\n    )\n    SELECT * FROM w1 LIMIT 5;\n  }\n} -test {\n  faultsim_test_result {0 {1 1 2 4 3 9 4 16 5 25}}\n  db close\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid1.test",
    "content": "# 2013-10-30\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing WITHOUT ROWID tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix without_rowid1\n\n# Create and query a WITHOUT ROWID table.\n#\ndo_execsql_test without_rowid1-1.0 {\n  CREATE TABLE t1(a,b,c,d, PRIMARY KEY(c,a)) WITHOUT ROWID;\n  CREATE INDEX t1bd ON t1(b, d);\n  INSERT INTO t1 VALUES('journal','sherman','ammonia','helena');\n  INSERT INTO t1 VALUES('dynamic','juliet','flipper','command');\n  INSERT INTO t1 VALUES('journal','sherman','gamma','patriot');\n  INSERT INTO t1 VALUES('arctic','sleep','ammonia','helena');\n  SELECT *, '|' FROM t1 ORDER BY c, a;\n} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic juliet flipper command | journal sherman gamma patriot |}\n\nintegrity_check without_rowid1-1.0ic\n\ndo_execsql_test without_rowid1-1.1 {\n  SELECT *, '|' FROM t1 ORDER BY +c, a;\n} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic juliet flipper command | journal sherman gamma patriot |}\n\ndo_execsql_test without_rowid1-1.2 {\n  SELECT *, '|' FROM t1 ORDER BY c DESC, a DESC;\n} {journal sherman gamma patriot | dynamic juliet flipper command | journal sherman ammonia helena | arctic sleep ammonia helena |}\n\ndo_execsql_test without_rowid1-1.11 {\n  SELECT *, '|' FROM t1 ORDER BY b, d;\n} {dynamic juliet flipper command | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}\n\ndo_execsql_test without_rowid1-1.12 {\n  SELECT *, '|' FROM t1 ORDER BY +b, d;\n} {dynamic juliet flipper command | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}\n\n# Trying to insert a duplicate PRIMARY KEY fails.\n#\ndo_test without_rowid1-1.21 {\n  catchsql {\n    INSERT INTO t1 VALUES('dynamic','phone','flipper','harvard');\n  }\n} {1 {UNIQUE constraint failed: t1.c, t1.a}}\n\n# REPLACE INTO works, however.\n#\ndo_execsql_test without_rowid1-1.22 {\n  REPLACE INTO t1 VALUES('dynamic','phone','flipper','harvard');\n  SELECT *, '|' FROM t1 ORDER BY c, a;\n} {arctic sleep ammonia helena | journal sherman ammonia helena | dynamic phone flipper harvard | journal sherman gamma patriot |}\n\ndo_execsql_test without_rowid1-1.23 {\n  SELECT *, '|' FROM t1 ORDER BY b, d;\n} {dynamic phone flipper harvard | journal sherman ammonia helena | journal sherman gamma patriot | arctic sleep ammonia helena |}\n\n# UPDATE statements.\n#\ndo_execsql_test without_rowid1-1.31 {\n  UPDATE t1 SET d=3.1415926 WHERE a='journal';\n  SELECT *, '|' FROM t1 ORDER BY c, a;\n} {arctic sleep ammonia helena | journal sherman ammonia 3.1415926 | dynamic phone flipper harvard | journal sherman gamma 3.1415926 |}\ndo_execsql_test without_rowid1-1.32 {\n  SELECT *, '|' FROM t1 ORDER BY b, d;\n} {dynamic phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}\n\ndo_execsql_test without_rowid1-1.35 {\n  UPDATE t1 SET a=1250 WHERE b='phone';\n  SELECT *, '|' FROM t1 ORDER BY c, a;\n} {arctic sleep ammonia helena | journal sherman ammonia 3.1415926 | 1250 phone flipper harvard | journal sherman gamma 3.1415926 |}\nintegrity_check without_rowid1-1.36\n\ndo_execsql_test without_rowid1-1.37 {\n  SELECT *, '|' FROM t1 ORDER BY b, d;\n} {1250 phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}\n\ndo_execsql_test without_rowid1-1.40 {\n  VACUUM;\n  SELECT *, '|' FROM t1 ORDER BY b, d;\n} {1250 phone flipper harvard | journal sherman ammonia 3.1415926 | journal sherman gamma 3.1415926 | arctic sleep ammonia helena |}\nintegrity_check without_rowid1-1.41\n\n# Verify that ANALYZE works\n#\ndo_execsql_test without_rowid1-1.50 {\n  ANALYZE;\n  SELECT * FROM sqlite_stat1 ORDER BY idx;\n} {t1 t1 {4 2 1} t1 t1bd {4 2 2}}\nifcapable stat3 {\n  do_execsql_test without_rowid1-1.51 {\n    SELECT DISTINCT tbl, idx FROM sqlite_stat3 ORDER BY idx;\n  } {t1 t1 t1 t1bd}\n}\nifcapable stat4 {\n  do_execsql_test without_rowid1-1.52 {\n    SELECT DISTINCT tbl, idx FROM sqlite_stat4 ORDER BY idx;\n  } {t1 t1 t1 t1bd}\n}\n\n#----------\n\ndo_execsql_test 2.1.1 {\n  CREATE TABLE t4 (a COLLATE nocase PRIMARY KEY, b) WITHOUT ROWID;\n  INSERT INTO t4 VALUES('abc', 'def');\n  SELECT * FROM t4;\n} {abc def}\ndo_execsql_test 2.1.2 {\n  UPDATE t4 SET a = 'ABC';\n  SELECT * FROM t4;\n} {ABC def}\n\ndo_execsql_test 2.2.1 {\n  DROP TABLE t4;\n  CREATE TABLE t4 (b, a COLLATE nocase PRIMARY KEY) WITHOUT ROWID;\n  INSERT INTO t4(a, b) VALUES('abc', 'def');\n  SELECT * FROM t4;\n} {def abc}\n\ndo_execsql_test 2.2.2 {\n  UPDATE t4 SET a = 'ABC', b = 'xyz';\n  SELECT * FROM t4;\n} {xyz ABC}\n\ndo_execsql_test 2.3.1 {\n  CREATE TABLE t5 (a, b, PRIMARY KEY(b, a)) WITHOUT ROWID;\n  INSERT INTO t5(a, b) VALUES('abc', 'def');\n  UPDATE t5 SET a='abc', b='def';\n} {}\n\ndo_execsql_test 2.4.1 {\n  CREATE TABLE t6 (\n    a COLLATE nocase, b, c UNIQUE, PRIMARY KEY(b, a)\n  ) WITHOUT ROWID;\n\n  INSERT INTO t6(a, b, c) VALUES('abc', 'def', 'ghi');\n  UPDATE t6 SET a='ABC', c='ghi';\n} {}\n\ndo_execsql_test 2.4.2 {\n  SELECT * FROM t6 ORDER BY b, a;\n  SELECT * FROM t6 ORDER BY c;\n} {ABC def ghi ABC def ghi}\n\n#-------------------------------------------------------------------------\n# Unless the destination table is completely empty, the xfer optimization \n# is disabled for WITHOUT ROWID tables. The following tests check for\n# some problems that might occur if this were not the case.\n#\nreset_db\ndo_execsql_test 3.1.1 {\n  CREATE TABLE t1(a, b, PRIMARY KEY(a)) WITHOUT ROWID;\n  CREATE UNIQUE INDEX i1 ON t1(b);\n\n  CREATE TABLE t2(a, b, PRIMARY KEY(a)) WITHOUT ROWID;\n  CREATE UNIQUE INDEX i2 ON t2(b);\n\n  INSERT INTO t1 VALUES('one', 'two');\n  INSERT INTO t2 VALUES('three', 'two');\n}\n\ndo_execsql_test 3.1.2 {\n  INSERT OR REPLACE INTO t1 SELECT * FROM t2;\n  SELECT * FROM t1;\n} {three two}\n\ndo_execsql_test 3.1.3 {\n  DELETE FROM t1;\n  INSERT INTO t1 SELECT * FROM t2;\n  SELECT * FROM t1;\n} {three two}\n\ndo_catchsql_test 3.1.4 {\n  INSERT INTO t2 VALUES('four', 'four');\n  INSERT INTO t2 VALUES('six', 'two');\n  INSERT INTO t1 SELECT * FROM t2;\n} {1 {UNIQUE constraint failed: t2.b}}\n\ndo_execsql_test 3.1.5 {\n  CREATE TABLE t3(a PRIMARY KEY);\n  CREATE TABLE t4(a PRIMARY KEY);\n\n  INSERT INTO t4 VALUES('i');\n  INSERT INTO t4 VALUES('ii');\n  INSERT INTO t4 VALUES('iii');\n\n  INSERT INTO t3 SELECT * FROM t4;\n  SELECT * FROM t3;\n} {i ii iii}\n\n############################################################################\n# Ticket [c34d0557f740c450709d6e33df72d4f3f651a3cc]\n# Name resolution issue with WITHOUT ROWID\n#\ndo_execsql_test 4.1 {\n  CREATE TABLE t41(a PRIMARY KEY) WITHOUT ROWID;\n  INSERT INTO t41 VALUES('abc');\n  CREATE TABLE t42(x);\n  INSERT INTO t42 VALUES('xyz');\n  SELECT t42.rowid FROM t41, t42;\n} {1}\ndo_execsql_test 4.2 {\n  SELECT t42.rowid FROM t42, t41;\n} {1}\n\n\n#--------------------------------------------------------------------------\n# The following tests verify that the trailing PK fields added to each\n# entry in an index on a WITHOUT ROWID table are used correctly.\n#\ndo_execsql_test 5.0 {\n  CREATE TABLE t45(a PRIMARY KEY, b, c) WITHOUT ROWID;\n  CREATE INDEX i45 ON t45(b);\n\n  INSERT INTO t45 VALUES(2, 'one', 'x');\n  INSERT INTO t45 VALUES(4, 'one', 'x');\n  INSERT INTO t45 VALUES(6, 'one', 'x');\n  INSERT INTO t45 VALUES(8, 'one', 'x');\n  INSERT INTO t45 VALUES(10, 'one', 'x');\n\n  INSERT INTO t45 VALUES(1, 'two', 'x');\n  INSERT INTO t45 VALUES(3, 'two', 'x');\n  INSERT INTO t45 VALUES(5, 'two', 'x');\n  INSERT INTO t45 VALUES(7, 'two', 'x');\n  INSERT INTO t45 VALUES(9, 'two', 'x');\n}\n\ndo_eqp_test 5.1 {\n  SELECT * FROM t45 WHERE b=? AND a>?\n} {/*USING INDEX i45 (b=? AND a>?)*/}\n\ndo_execsql_test 5.2 {\n  SELECT * FROM t45 WHERE b='two' AND a>4\n} {5 two x 7 two x 9 two x}\n\ndo_execsql_test 5.3 {\n  SELECT * FROM t45 WHERE b='one' AND a<8\n} { 2 one x 4 one x 6 one x }\n\ndo_execsql_test 5.4 {\n  CREATE TABLE t46(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;\n  WITH r(x) AS (\n    SELECT 1 UNION ALL SELECT x+1 FROM r WHERE x<100\n  )\n  INSERT INTO t46 SELECT x / 20, x % 20, x % 10, x FROM r;\n}\n\nset queries {\n  1    2    \"c = 5 AND a = 1\"          {/*i46 (c=? AND a=?)*/}\n  2    6    \"c = 4 AND a < 3\"          {/*i46 (c=? AND a<?)*/}\n  3    4    \"c = 2 AND a >= 3\"         {/*i46 (c=? AND a>?)*/}\n  4    1    \"c = 2 AND a = 1 AND b<10\" {/*i46 (c=? AND a=? AND b<?)*/}\n  5    1    \"c = 0 AND a = 0 AND b>5\"  {/*i46 (c=? AND a=? AND b>?)*/}\n}\n\nforeach {tn cnt where eqp} $queries {\n  do_execsql_test 5.5.$tn.1 \"SELECT count(*) FROM t46 WHERE $where\" $cnt\n}\n\ndo_execsql_test 5.6 {\n  CREATE INDEX i46 ON t46(c);\n}\n\nforeach {tn cnt where eqp} $queries {\n  do_execsql_test 5.7.$tn.1 \"SELECT count(*) FROM t46 WHERE $where\" $cnt\n  do_eqp_test 5.7.$tn.2  \"SELECT count(*) FROM t46 WHERE $where\" $eqp\n}\n\n#-------------------------------------------------------------------------\n# Check that redundant UNIQUE constraints do not cause a problem.\n#\ndo_execsql_test 6.0 {\n  CREATE TABLE t47(a, b UNIQUE PRIMARY KEY) WITHOUT ROWID;\n  CREATE INDEX i47 ON t47(a);\n  INSERT INTO t47 VALUES(1, 2);\n  INSERT INTO t47 VALUES(2, 4);\n  INSERT INTO t47 VALUES(3, 6);\n  INSERT INTO t47 VALUES(4, 8);\n\n  VACUUM;\n  PRAGMA integrity_check;\n  SELECT name FROM sqlite_master WHERE tbl_name = 't47';\n} {ok t47 i47}\n\ndo_execsql_test 6.1 {\n  CREATE TABLE t48(\n    a UNIQUE UNIQUE, \n    b UNIQUE, \n    PRIMARY KEY(a), \n    UNIQUE(a)\n  ) WITHOUT ROWID;\n  INSERT INTO t48 VALUES('a', 'b'), ('c', 'd'), ('e', 'f');\n  VACUUM;\n  PRAGMA integrity_check;\n  SELECT name FROM sqlite_master WHERE tbl_name = 't48';\n} {\n  ok  t48   sqlite_autoindex_t48_2\n}\n\n# 2015-05-28: CHECK constraints can refer to the rowid in a\n# rowid table, but not in a WITHOUT ROWID table.\n#\ndo_execsql_test 7.1 {\n  CREATE TABLE t70a(\n     a INT CHECK( rowid!=33 ),\n     b TEXT PRIMARY KEY\n  );\n  INSERT INTO t70a(a,b) VALUES(99,'hello');\n} {}\ndo_catchsql_test 7.2 {\n  INSERT INTO t70a(rowid,a,b) VALUES(33,99,'xyzzy');\n} {1 {CHECK constraint failed: t70a}}\ndo_catchsql_test 7.3 {\n  CREATE TABLE t70b(\n     a INT CHECK( rowid!=33 ),\n     b TEXT PRIMARY KEY\n  ) WITHOUT ROWID;\n} {1 {no such column: rowid}}\n\n# 2017-07-30: OSSFuzz discovered that an extra entry was being\n# added in the sqlite_master table for an \"INTEGER PRIMARY KEY UNIQUE\"\n# WITHOUT ROWID table.  Make sure this has now been fixed.\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test 8.1 {\n  CREATE TABLE t1(x INTEGER PRIMARY KEY UNIQUE, b) WITHOUT ROWID;\n  CREATE INDEX t1x ON t1(x);\n  INSERT INTO t1(x,b) VALUES('funny','buffalo');\n  SELECT type, name, '|' FROM sqlite_master;\n} {table t1 | index t1x |}\n\n\n  \nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid2.test",
    "content": "# 2013-11-02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing WITHOUT ROWID tables, and especially\n# FOREIGN KEY constraints.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey} {\n  finish_test\n  return\n}\n\n# Create a table and some data to work with.\n#\ndo_test without_rowid2-1.0 {\n  execsql {\n    CREATE TABLE t1(\n      a INT PRIMARY KEY,\n      b INT\n           REFERENCES t1 ON DELETE CASCADE\n           REFERENCES t2,\n      c TEXT,\n      FOREIGN KEY (b,c) REFERENCES t2(x,y) ON UPDATE CASCADE\n    ) WITHOUT rowid;\n  }\n} {}\ndo_test without_rowid2-1.1 {\n  execsql {\n    CREATE TABLE t2(\n      x INT PRIMARY KEY,\n      y TEXT\n    ) WITHOUT rowid;\n  }\n} {}\ndo_test without_rowid2-1.2 {\n  execsql {\n    CREATE TABLE t3(\n      a INT REFERENCES t2,\n      b INT REFERENCES t1,\n      FOREIGN KEY (a,b) REFERENCES t2(x,y)\n    );\n  }\n} {}\n\ndo_test without_rowid2-2.1 {\n  execsql {\n    CREATE TABLE t4(a int primary key) WITHOUT rowid;\n    CREATE TABLE t5(x references t4);\n    CREATE TABLE t6(x references t4);\n    CREATE TABLE t7(x references t4);\n    CREATE TABLE t8(x references t4);\n    CREATE TABLE t9(x references t4);\n    CREATE TABLE t10(x references t4);\n    DROP TABLE t7;\n    DROP TABLE t9;\n    DROP TABLE t5;\n    DROP TABLE t8;\n    DROP TABLE t6;\n    DROP TABLE t10;\n  }\n} {}\n\ndo_test without_rowid2-3.1 {\n  execsql {\n    CREATE TABLE t5(a PRIMARY KEY, b, c) WITHOUT rowid;\n    CREATE TABLE t6(\n      d REFERENCES t5,\n      e REFERENCES t5(c)\n    );\n    PRAGMA foreign_key_list(t6);\n  }\n} [concat                                         \\\n  {0 0 t5 e c {NO ACTION} {NO ACTION} NONE}       \\\n  {1 0 t5 d {} {NO ACTION} {NO ACTION} NONE}      \\\n]\ndo_test without_rowid2-3.2 {\n  execsql {\n    CREATE TABLE t7(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5(a, b)\n    );\n    PRAGMA foreign_key_list(t7);\n  }\n} [concat                                   \\\n  {0 0 t5 d a {NO ACTION} {NO ACTION} NONE} \\\n  {0 1 t5 e b {NO ACTION} {NO ACTION} NONE} \\\n]\ndo_test without_rowid2-3.3 {\n  execsql {\n    CREATE TABLE t8(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET NULL\n    );\n    PRAGMA foreign_key_list(t8);\n  }\n} [concat                        \\\n  {0 0 t5 d {} {SET NULL} CASCADE NONE} \\\n  {0 1 t5 e {} {SET NULL} CASCADE NONE} \\\n]\ndo_test without_rowid2-3.4 {\n  execsql {\n    CREATE TABLE t9(d, e, f,\n      FOREIGN KEY (d, e) REFERENCES t5 ON DELETE CASCADE ON UPDATE SET DEFAULT\n    );\n    PRAGMA foreign_key_list(t9);\n  }\n} [concat                        \\\n  {0 0 t5 d {} {SET DEFAULT} CASCADE NONE} \\\n  {0 1 t5 e {} {SET DEFAULT} CASCADE NONE} \\\n]\ndo_test without_rowid2-3.5 {\n  sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0\n} {0 0 0}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid3.test",
    "content": "# 2013-11-02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.\n#\n# This file implements tests for foreign keys on WITHOUT ROWID\n# tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\nifcapable {!foreignkey||!trigger} {\n  finish_test\n  return\n}\n\n#-------------------------------------------------------------------------\n# Test structure:\n#\n# without_rowid3-1.*: Simple tests to check that immediate and deferred foreign key \n#            constraints work when not inside a transaction.\n#            \n# without_rowid3-2.*: Tests to verify that deferred foreign keys work inside\n#            explicit transactions (i.e that processing really is deferred).\n#\n# without_rowid3-3.*: Tests that a statement transaction is rolled back if an\n#            immediate foreign key constraint is violated.\n#\n# without_rowid3-4.*: Test that FK actions may recurse even when recursive triggers\n#            are disabled.\n#\n# without_rowid3-5.*: Check that if foreign-keys are enabled, it is not possible\n#            to write to an FK column using the incremental blob API.\n#\n# without_rowid3-6.*: Test that FK processing is automatically disabled when \n#            running VACUUM.\n#\n# without_rowid3-7.*: Test using an IPK as the key in the child (referencing) table.\n#\n# without_rowid3-8.*: Test that enabling/disabling foreign key support while a \n#            transaction is active is not possible.\n#\n# without_rowid3-9.*: Test SET DEFAULT actions.\n#\n# without_rowid3-10.*: Test errors.\n#\n# without_rowid3-11.*: Test CASCADE actions.\n#\n# without_rowid3-12.*: Test RESTRICT actions.\n#\n# without_rowid3-13.*: Test that FK processing is performed when a row is REPLACED by\n#             an UPDATE or INSERT statement.\n#\n# without_rowid3-14.*: Test the ALTER TABLE and DROP TABLE commands.\n#\n# without_rowid3-15.*: Test that if there are no (known) outstanding foreign key \n#             constraint violations in the database, inserting into a parent\n#             table or deleting from a child table does not cause SQLite\n#             to check if this has repaired an outstanding violation.\n#\n# without_rowid3-16.*: Test that rows that refer to themselves may be inserted, \n#             updated and deleted.\n#\n# without_rowid3-17.*: Test that the \"count_changes\" pragma does not interfere with\n#             FK constraint processing.\n# \n# without_rowid3-18.*: Test that the authorization callback is invoked when processing\n#             FK constraints.\n#\n# without_rowid3-20.*: Test that ON CONFLICT clauses specified as part of statements\n#             do not affect the operation of FK constraints.\n#\n# without_rowid3-genfkey.*: Tests that were used with the shell tool .genfkey\n#            command. Recycled to test the built-in implementation.\n#\n# without_rowid3-dd08e5.*:  Tests to verify that ticket dd08e5a988d00decc4a543daa8d\n#                  has been fixed.\n#\n\n\nexecsql { PRAGMA foreign_keys = on }\n\nset FkeySimpleSchema {\n  PRAGMA foreign_keys = on;\n  CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n  CREATE TABLE t2(c REFERENCES t1(a) /D/ , d);\n\n  CREATE TABLE t3(a PRIMARY KEY, b) WITHOUT rowid;\n  CREATE TABLE t4(c REFERENCES t3 /D/, d);\n\n  CREATE TABLE t7(a, b INT PRIMARY KEY) WITHOUT rowid;\n  CREATE TABLE t8(c REFERENCES t7 /D/, d);\n\n  CREATE TABLE t9(a REFERENCES nosuchtable, b);\n  CREATE TABLE t10(a REFERENCES t9(c) /D/, b);\n}\n\n\nset FkeySimpleTests {\n  1.1  \"INSERT INTO t2 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  1.2  \"INSERT INTO t1 VALUES(1, 2)\"      {0 {}}\n  1.3  \"INSERT INTO t2 VALUES(1, 3)\"      {0 {}}\n  1.4  \"INSERT INTO t2 VALUES(2, 4)\"      {1 {FOREIGN KEY constraint failed}}\n  1.5  \"INSERT INTO t2 VALUES(NULL, 4)\"   {0 {}}\n  1.6  \"UPDATE t2 SET c=2 WHERE d=4\"      {1 {FOREIGN KEY constraint failed}}\n  1.7  \"UPDATE t2 SET c=1 WHERE d=4\"      {0 {}}\n  1.9  \"UPDATE t2 SET c=1 WHERE d=4\"      {0 {}}\n  1.10 \"UPDATE t2 SET c=NULL WHERE d=4\"   {0 {}}\n  1.11 \"DELETE FROM t1 WHERE a=1\"         {1 {FOREIGN KEY constraint failed}}\n  1.12 \"UPDATE t1 SET a = 2\"              {1 {FOREIGN KEY constraint failed}}\n  1.13 \"UPDATE t1 SET a = 1\"              {0 {}}\n\n  2.1  \"INSERT INTO t4 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  2.2  \"INSERT INTO t3 VALUES(1, 2)\"      {0 {}}\n  2.3  \"INSERT INTO t4 VALUES(1, 3)\"      {0 {}}\n\n  4.1  \"INSERT INTO t8 VALUES(1, 3)\"      {1 {FOREIGN KEY constraint failed}}\n  4.2  \"INSERT INTO t7 VALUES(2, 1)\"      {0 {}}\n  4.3  \"INSERT INTO t8 VALUES(1, 3)\"      {0 {}}\n  4.4  \"INSERT INTO t8 VALUES(2, 4)\"      {1 {FOREIGN KEY constraint failed}}\n  4.5  \"INSERT INTO t8 VALUES(NULL, 4)\"   {0 {}}\n  4.6  \"UPDATE t8 SET c=2 WHERE d=4\"      {1 {FOREIGN KEY constraint failed}}\n  4.7  \"UPDATE t8 SET c=1 WHERE d=4\"      {0 {}}\n  4.9  \"UPDATE t8 SET c=1 WHERE d=4\"      {0 {}}\n  4.10 \"UPDATE t8 SET c=NULL WHERE d=4\"   {0 {}}\n  4.11 \"DELETE FROM t7 WHERE b=1\"         {1 {FOREIGN KEY constraint failed}}\n  4.12 \"UPDATE t7 SET b = 2\"              {1 {FOREIGN KEY constraint failed}}\n  4.13 \"UPDATE t7 SET b = 1\"              {0 {}}\n  4.14 \"INSERT INTO t8 VALUES('a', 'b')\"  {1 {FOREIGN KEY constraint failed}}\n  4.15 \"UPDATE t7 SET b = 5\"              {1 {FOREIGN KEY constraint failed}}\n  4.17 \"UPDATE t7 SET a = 10\"             {0 {}}\n\n  5.1  \"INSERT INTO t9 VALUES(1, 3)\"      {1 {no such table: main.nosuchtable}}\n  5.2  \"INSERT INTO t10 VALUES(1, 3)\"  \n                            {1 {foreign key mismatch - \"t10\" referencing \"t9\"}}\n}\n\ndo_test without_rowid3-1.1.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  do_test without_rowid3-1.1.$tn.1 { catchsql $zSql } $res\n  do_test without_rowid3-1.1.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test without_rowid3-1.1.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test without_rowid3-1.1.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test without_rowid3-1.1.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test without_rowid3-1.1.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test without_rowid3-1.1.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\ndrop_all_tables\n\ndo_test without_rowid3-1.2.0 {\n  execsql [string map {/D/ {DEFERRABLE INITIALLY DEFERRED}} $FkeySimpleSchema]\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  do_test without_rowid3-1.2.$tn { catchsql $zSql } $res\n  do_test without_rowid3-1.2.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test without_rowid3-1.2.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test without_rowid3-1.2.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test without_rowid3-1.2.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test without_rowid3-1.2.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test without_rowid3-1.2.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\ndrop_all_tables\n\ndo_test without_rowid3-1.3.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n  execsql { PRAGMA count_changes = 1 }\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  if {$res == \"0 {}\"} { set res {0 1} }\n  do_test without_rowid3-1.3.$tn { catchsql $zSql } $res\n  do_test without_rowid3-1.3.$tn.2 { execsql {PRAGMA foreign_key_check(t1)} } {}\n  do_test without_rowid3-1.3.$tn.3 { execsql {PRAGMA foreign_key_check(t2)} } {}\n  do_test without_rowid3-1.3.$tn.4 { execsql {PRAGMA foreign_key_check(t3)} } {}\n  do_test without_rowid3-1.3.$tn.5 { execsql {PRAGMA foreign_key_check(t4)} } {}\n  do_test without_rowid3-1.3.$tn.6 { execsql {PRAGMA foreign_key_check(t7)} } {}\n  do_test without_rowid3-1.3.$tn.7 { execsql {PRAGMA foreign_key_check(t8)} } {}\n}\nexecsql { PRAGMA count_changes = 0 }\ndrop_all_tables\n\ndo_test without_rowid3-1.4.0 {\n  execsql [string map {/D/ {}} $FkeySimpleSchema]\n  execsql { PRAGMA count_changes = 1 }\n} {}\nforeach {tn zSql res} $FkeySimpleTests {\n  if {$res == \"0 {}\"} { set res {0 1} }\n  execsql BEGIN\n  do_test without_rowid3-1.4.$tn { catchsql $zSql } $res\n  execsql COMMIT\n}\nexecsql { PRAGMA count_changes = 0 }\ndrop_all_tables\n\n# Special test: When the parent key is an IPK, make sure the affinity of\n# the IPK is not applied to the child key value before it is inserted\n# into the child table.\ndo_test without_rowid3-1.5.1 {\n  execsql {\n    CREATE TABLE i(i INT PRIMARY KEY) WITHOUT rowid;\n    CREATE TABLE j(j REFERENCES i);\n    INSERT INTO i VALUES(35);\n    INSERT INTO j VALUES('35.0');\n    SELECT j, typeof(j) FROM j;\n  }\n} {35.0 text}\ndo_test without_rowid3-1.5.2 {\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Same test using a regular primary key with integer affinity.\ndrop_all_tables\ndo_test without_rowid3-1.6.1 {\n  execsql {\n    CREATE TABLE i(i INT UNIQUE);\n    CREATE TABLE j(j REFERENCES i(i));\n    INSERT INTO i VALUES('35.0');\n    INSERT INTO j VALUES('35.0');\n    SELECT j, typeof(j) FROM j;\n    SELECT i, typeof(i) FROM i;\n  }\n} {35.0 text 35 integer}\ndo_test without_rowid3-1.6.2 {\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Use a collation sequence on the parent key.\ndrop_all_tables\ndo_test without_rowid3-1.7.1 {\n  execsql {\n    CREATE TABLE i(i TEXT COLLATE nocase PRIMARY KEY) WITHOUT rowid;\n    CREATE TABLE j(j TEXT COLLATE binary REFERENCES i(i));\n    INSERT INTO i VALUES('SQLite');\n    INSERT INTO j VALUES('sqlite');\n  }\n  catchsql { DELETE FROM i }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Use the parent key collation even if it is default and the child key\n# has an explicit value.\ndrop_all_tables\ndo_test without_rowid3-1.7.2 {\n  execsql {\n    CREATE TABLE i(i TEXT PRIMARY KEY) WITHOUT rowid;  -- Colseq is \"BINARY\"\n    CREATE TABLE j(j TEXT COLLATE nocase REFERENCES i(i));\n    INSERT INTO i VALUES('SQLite');\n  }\n  catchsql { INSERT INTO j VALUES('sqlite') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-1.7.3 {\n  execsql {\n    INSERT INTO i VALUES('sqlite');\n    INSERT INTO j VALUES('sqlite');\n    DELETE FROM i WHERE i = 'SQLite';\n  }\n  catchsql { DELETE FROM i WHERE i = 'sqlite' }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# This section (test cases without_rowid3-2.*) contains tests to check that the\n# deferred foreign key constraint logic works.\n#\nproc without_rowid3-2-test {tn nocommit sql {res {}}} {\n  if {$res eq \"FKV\"} {\n    set expected {1 {FOREIGN KEY constraint failed}}\n  } else {\n    set expected [list 0 $res]\n  }\n  do_test without_rowid3-2.$tn [list catchsql $sql] $expected\n  if {$nocommit} {\n    do_test without_rowid3-2.${tn}c {\n      catchsql COMMIT\n    } {1 {FOREIGN KEY constraint failed}}\n  }\n}\n\nwithout_rowid3-2-test 1 0 {\n  CREATE TABLE node(\n    nodeid PRIMARY KEY,\n    parent REFERENCES node DEFERRABLE INITIALLY DEFERRED\n  ) WITHOUT rowid;\n  CREATE TABLE leaf(\n    cellid PRIMARY KEY,\n    parent REFERENCES node DEFERRABLE INITIALLY DEFERRED\n  ) WITHOUT rowid;\n}\n\nwithout_rowid3-2-test 1  0 \"INSERT INTO node VALUES(1, 0)\"       FKV\nwithout_rowid3-2-test 2  0 \"BEGIN\"\nwithout_rowid3-2-test 3  1   \"INSERT INTO node VALUES(1, 0)\"\nwithout_rowid3-2-test 4  0   \"UPDATE node SET parent = NULL\"\nwithout_rowid3-2-test 5  0 \"COMMIT\"\nwithout_rowid3-2-test 6  0 \"SELECT * FROM node\" {1 {}}\n\nwithout_rowid3-2-test 7  0 \"BEGIN\"\nwithout_rowid3-2-test 8  1   \"INSERT INTO leaf VALUES('a', 2)\"\nwithout_rowid3-2-test 9  1   \"INSERT INTO node VALUES(2, 0)\"\nwithout_rowid3-2-test 10 0   \"UPDATE node SET parent = 1 WHERE nodeid = 2\"\nwithout_rowid3-2-test 11 0 \"COMMIT\"\nwithout_rowid3-2-test 12 0 \"SELECT * FROM node\" {1 {} 2 1}\nwithout_rowid3-2-test 13 0 \"SELECT * FROM leaf\" {a 2}\n\nwithout_rowid3-2-test 14 0 \"BEGIN\"\nwithout_rowid3-2-test 15 1   \"DELETE FROM node WHERE nodeid = 2\"\nwithout_rowid3-2-test 16 0   \"INSERT INTO node VALUES(2, NULL)\"\nwithout_rowid3-2-test 17 0 \"COMMIT\"\nwithout_rowid3-2-test 18 0 \"SELECT * FROM node\" {1 {} 2 {}}\nwithout_rowid3-2-test 19 0 \"SELECT * FROM leaf\" {a 2}\n\nwithout_rowid3-2-test 20 0 \"BEGIN\"\nwithout_rowid3-2-test 21 0   \"INSERT INTO leaf VALUES('b', 1)\"\nwithout_rowid3-2-test 22 0   \"SAVEPOINT save\"\nwithout_rowid3-2-test 23 0     \"DELETE FROM node WHERE nodeid = 1\"\nwithout_rowid3-2-test 24 0   \"ROLLBACK TO save\"\nwithout_rowid3-2-test 25 0 \"COMMIT\"\nwithout_rowid3-2-test 26 0 \"SELECT * FROM node\" {1 {} 2 {}}\nwithout_rowid3-2-test 27 0 \"SELECT * FROM leaf\" {a 2 b 1}\n\nwithout_rowid3-2-test 28 0 \"BEGIN\"\nwithout_rowid3-2-test 29 0   \"INSERT INTO leaf VALUES('c', 1)\"\nwithout_rowid3-2-test 30 0   \"SAVEPOINT save\"\nwithout_rowid3-2-test 31 0     \"DELETE FROM node WHERE nodeid = 1\"\nwithout_rowid3-2-test 32 1   \"RELEASE save\"\nwithout_rowid3-2-test 33 1   \"DELETE FROM leaf WHERE cellid = 'b'\"\nwithout_rowid3-2-test 34 0   \"DELETE FROM leaf WHERE cellid = 'c'\"\nwithout_rowid3-2-test 35 0 \"COMMIT\"\nwithout_rowid3-2-test 36 0 \"SELECT * FROM node\" {2 {}} \nwithout_rowid3-2-test 37 0 \"SELECT * FROM leaf\" {a 2}\n\nwithout_rowid3-2-test 38 0 \"SAVEPOINT outer\"\nwithout_rowid3-2-test 39 1   \"INSERT INTO leaf VALUES('d', 3)\"\nwithout_rowid3-2-test 40 1 \"RELEASE outer\"    FKV\nwithout_rowid3-2-test 41 1   \"INSERT INTO leaf VALUES('e', 3)\"\nwithout_rowid3-2-test 42 0   \"INSERT INTO node VALUES(3, 2)\"\nwithout_rowid3-2-test 43 0 \"RELEASE outer\"\n\nwithout_rowid3-2-test 44 0 \"SAVEPOINT outer\"\nwithout_rowid3-2-test 45 1   \"DELETE FROM node WHERE nodeid=3\"\nwithout_rowid3-2-test 47 0   \"INSERT INTO node VALUES(3, 2)\"\nwithout_rowid3-2-test 48 0 \"ROLLBACK TO outer\"\nwithout_rowid3-2-test 49 0 \"RELEASE outer\"\n\nwithout_rowid3-2-test 50 0 \"SAVEPOINT outer\"\nwithout_rowid3-2-test 51 1   \"INSERT INTO leaf VALUES('f', 4)\"\nwithout_rowid3-2-test 52 1   \"SAVEPOINT inner\"\nwithout_rowid3-2-test 53 1     \"INSERT INTO leaf VALUES('g', 4)\"\nwithout_rowid3-2-test 54 1  \"RELEASE outer\"   FKV\nwithout_rowid3-2-test 55 1   \"ROLLBACK TO inner\"\nwithout_rowid3-2-test 56 0  \"COMMIT\"          FKV\nwithout_rowid3-2-test 57 0   \"INSERT INTO node VALUES(4, NULL)\"\nwithout_rowid3-2-test 58 0 \"RELEASE outer\"\nwithout_rowid3-2-test 59 0 \"SELECT * FROM node\" {2 {} 3 2 4 {}}\nwithout_rowid3-2-test 60 0 \"SELECT * FROM leaf\" {a 2 d 3 e 3 f 4}\n\n# The following set of tests check that if a statement that affects \n# multiple rows violates some foreign key constraints, then strikes a \n# constraint that causes the statement-transaction to be rolled back, \n# the deferred constraint counter is correctly reset to the value it \n# had before the statement-transaction was opened.\n#\nwithout_rowid3-2-test 61 0 \"BEGIN\"\nwithout_rowid3-2-test 62 0   \"DELETE FROM leaf\"\nwithout_rowid3-2-test 63 0   \"DELETE FROM node\"\nwithout_rowid3-2-test 64 1   \"INSERT INTO leaf VALUES('a', 1)\"\nwithout_rowid3-2-test 65 1   \"INSERT INTO leaf VALUES('b', 2)\"\nwithout_rowid3-2-test 66 1   \"INSERT INTO leaf VALUES('c', 1)\"\ndo_test without_rowid3-2-test-67 {\n  catchsql          \"INSERT INTO node SELECT parent, 3 FROM leaf\"\n} {1 {UNIQUE constraint failed: node.nodeid}}\nwithout_rowid3-2-test 68 0 \"COMMIT\"           FKV\nwithout_rowid3-2-test 69 1   \"INSERT INTO node VALUES(1, NULL)\"\nwithout_rowid3-2-test 70 0   \"INSERT INTO node VALUES(2, NULL)\"\nwithout_rowid3-2-test 71 0 \"COMMIT\"\n\nwithout_rowid3-2-test 72 0 \"BEGIN\"\nwithout_rowid3-2-test 73 1   \"DELETE FROM node\"\nwithout_rowid3-2-test 74 0   \"INSERT INTO node(nodeid) SELECT DISTINCT parent FROM leaf\"\nwithout_rowid3-2-test 75 0 \"COMMIT\"\n\n#-------------------------------------------------------------------------\n# Test cases without_rowid3-3.* test that a program that executes foreign key\n# actions (CASCADE, SET DEFAULT, SET NULL etc.) or tests FK constraints\n# opens a statement transaction if required.\n#\n# without_rowid3-3.1.*: Test UPDATE statements.\n# without_rowid3-3.2.*: Test DELETE statements.\n#\ndrop_all_tables\ndo_test without_rowid3-3.1.1 {\n  execsql {\n    CREATE TABLE ab(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE cd(\n      c PRIMARY KEY REFERENCES ab ON UPDATE CASCADE ON DELETE CASCADE, \n      d\n    ) WITHOUT rowid;\n    CREATE TABLE ef(\n      e REFERENCES cd ON UPDATE CASCADE, \n      f, CHECK (e!=5)\n    );\n  }\n} {}\ndo_test without_rowid3-3.1.2 {\n  execsql {\n    INSERT INTO ab VALUES(1, 'b');\n    INSERT INTO cd VALUES(1, 'd');\n    INSERT INTO ef VALUES(1, 'e');\n  }\n} {}\ndo_test without_rowid3-3.1.3 {\n  catchsql { UPDATE ab SET a = 5 }\n} {1 {CHECK constraint failed: ef}}\ndo_test without_rowid3-3.1.4 {\n  execsql { SELECT * FROM ab }\n} {1 b}\ndo_test without_rowid3-3.1.4 {\n  execsql BEGIN;\n  catchsql { UPDATE ab SET a = 5 }\n} {1 {CHECK constraint failed: ef}}\ndo_test without_rowid3-3.1.5 {\n  execsql COMMIT;\n  execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }\n} {1 b 1 d 1 e}\n\ndo_test without_rowid3-3.2.1 {\n  execsql BEGIN;\n  catchsql { DELETE FROM ab }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-3.2.2 {\n  execsql COMMIT\n  execsql { SELECT * FROM ab; SELECT * FROM cd; SELECT * FROM ef }\n} {1 b 1 d 1 e}\n\n#-------------------------------------------------------------------------\n# Test cases without_rowid3-4.* test that recursive foreign key actions \n# (i.e. CASCADE) are allowed even if recursive triggers are disabled.\n#\ndrop_all_tables\ndo_test without_rowid3-4.1 {\n  execsql {\n    CREATE TABLE t1(\n      node PRIMARY KEY, \n      parent REFERENCES t1 ON DELETE CASCADE\n    ) WITHOUT rowid;\n    CREATE TABLE t2(node PRIMARY KEY, parent) WITHOUT rowid;\n    CREATE TRIGGER t2t AFTER DELETE ON t2 BEGIN\n      DELETE FROM t2 WHERE parent = old.node;\n    END;\n    INSERT INTO t1 VALUES(1, NULL);\n    INSERT INTO t1 VALUES(2, 1);\n    INSERT INTO t1 VALUES(3, 1);\n    INSERT INTO t1 VALUES(4, 2);\n    INSERT INTO t1 VALUES(5, 2);\n    INSERT INTO t1 VALUES(6, 3);\n    INSERT INTO t1 VALUES(7, 3);\n    INSERT INTO t2 SELECT * FROM t1;\n  }\n} {}\ndo_test without_rowid3-4.2 {\n  execsql { PRAGMA recursive_triggers = off }\n  execsql { \n    BEGIN;\n      DELETE FROM t1 WHERE node = 1;\n      SELECT node FROM t1;\n  }\n} {}\ndo_test without_rowid3-4.3 {\n  execsql { \n      DELETE FROM t2 WHERE node = 1;\n      SELECT node FROM t2;\n    ROLLBACK;\n  }\n} {4 5 6 7}\ndo_test without_rowid3-4.4 {\n  execsql { PRAGMA recursive_triggers = on }\n  execsql { \n    BEGIN;\n      DELETE FROM t1 WHERE node = 1;\n      SELECT node FROM t1;\n  }\n} {}\ndo_test without_rowid3-4.3 {\n  execsql { \n      DELETE FROM t2 WHERE node = 1;\n      SELECT node FROM t2;\n    ROLLBACK;\n  }\n} {}\n\n#-------------------------------------------------------------------------\n# Test cases without_rowid3-5.* verify that the incremental blob API may not\n# write to a foreign key column while foreign-keys are enabled.\n#\ndrop_all_tables\nifcapable incrblob {\n  do_test without_rowid3-5.1 {\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n      CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1(a)) WITHOUT rowid;\n      INSERT INTO t1 VALUES('hello', 'world');\n      INSERT INTO t2 VALUES('key', 'hello');\n    }\n  } {}\n  do_test without_rowid3-5.2 {\n    set rc [catch { set fd [db incrblob t2 b 1] } msg]\n    list $rc $msg\n  } {1 {cannot open table without rowid: t2}}\n  do_test without_rowid3-5.5 {\n    execsql { PRAGMA foreign_keys = on }\n  } {}\n}\n\ndrop_all_tables\nifcapable vacuum {\n  do_test without_rowid3-6.1 {\n    execsql {\n      CREATE TABLE t1(a REFERENCES t2(c), b);\n      CREATE TABLE t2(c UNIQUE, b);\n      INSERT INTO t2 VALUES(1, 2);\n      INSERT INTO t1 VALUES(1, 2);\n      VACUUM;\n    }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# Test that it is possible to use an INT PRIMARY KEY as the child key\n# of a foreign constraint.\n# \ndrop_all_tables\ndo_test without_rowid3-7.1 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(c INT PRIMARY KEY REFERENCES t1, b) WITHOUT rowid;\n  }\n} {}\ndo_test without_rowid3-7.2 {\n  catchsql { INSERT INTO t2 VALUES(1, 'A'); }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-7.3 {\n  execsql { \n    INSERT INTO t1 VALUES(1, 2);\n    INSERT INTO t1 VALUES(2, 3);\n    INSERT INTO t2 VALUES(1, 'A');\n  }\n} {}\ndo_test without_rowid3-7.4 {\n  execsql { UPDATE t2 SET c = 2 }\n} {}\ndo_test without_rowid3-7.5 {\n  catchsql { UPDATE t2 SET c = 3 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-7.6 {\n  catchsql { DELETE FROM t1 WHERE a = 2 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-7.7 {\n  execsql { DELETE FROM t1 WHERE a = 1 }\n} {}\ndo_test without_rowid3-7.8 {\n  catchsql { UPDATE t1 SET a = 3 }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Test that it is not possible to enable/disable FK support while a\n# transaction is open.\n# \ndrop_all_tables\nproc without_rowid3-8-test {tn zSql value} {\n  do_test without_rowid3-2.8.$tn.1 [list execsql $zSql] {}\n  do_test without_rowid3-2.8.$tn.2 { execsql \"PRAGMA foreign_keys\" } $value\n}\nwithout_rowid3-8-test  1 { PRAGMA foreign_keys = 0     } 0\nwithout_rowid3-8-test  2 { PRAGMA foreign_keys = 1     } 1\nwithout_rowid3-8-test  3 { BEGIN                       } 1\nwithout_rowid3-8-test  4 { PRAGMA foreign_keys = 0     } 1\nwithout_rowid3-8-test  5 { COMMIT                      } 1\nwithout_rowid3-8-test  6 { PRAGMA foreign_keys = 0     } 0\nwithout_rowid3-8-test  7 { BEGIN                       } 0\nwithout_rowid3-8-test  8 { PRAGMA foreign_keys = 1     } 0\nwithout_rowid3-8-test  9 { COMMIT                      } 0\nwithout_rowid3-8-test 10 { PRAGMA foreign_keys = 1     } 1\nwithout_rowid3-8-test 11 { PRAGMA foreign_keys = off   } 0\nwithout_rowid3-8-test 12 { PRAGMA foreign_keys = on    } 1\nwithout_rowid3-8-test 13 { PRAGMA foreign_keys = no    } 0\nwithout_rowid3-8-test 14 { PRAGMA foreign_keys = yes   } 1\nwithout_rowid3-8-test 15 { PRAGMA foreign_keys = false } 0\nwithout_rowid3-8-test 16 { PRAGMA foreign_keys = true  } 1\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-9.*, test SET DEFAULT actions.\n#\ndrop_all_tables\ndo_test without_rowid3-9.1.1 {\n  execsql {\n    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(\n      c INT PRIMARY KEY,\n      d INTEGER DEFAULT 1 REFERENCES t1 ON DELETE SET DEFAULT\n    ) WITHOUT rowid;\n    DELETE FROM t1;\n  }\n} {}\ndo_test without_rowid3-9.1.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t2 VALUES(1, 2);\n    SELECT * FROM t2;\n    DELETE FROM t1 WHERE a = 2;\n    SELECT * FROM t2;\n  }\n} {1 2 1 1}\ndo_test without_rowid3-9.1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(2, 'two');\n    UPDATE t2 SET d = 2;\n    DELETE FROM t1 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {1 2}\ndo_test without_rowid3-9.1.4 {\n  execsql { SELECT * FROM t1 }\n} {2 two}\ndo_test without_rowid3-9.1.5 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test without_rowid3-9.2.1 {\n  execsql {\n    CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;\n    CREATE TABLE cc(d DEFAULT 3, e DEFAULT 1, f DEFAULT 2,\n        FOREIGN KEY(f, d) REFERENCES pp \n        ON UPDATE SET DEFAULT \n        ON DELETE SET NULL\n    );\n    INSERT INTO pp VALUES(1, 2, 3);\n    INSERT INTO pp VALUES(4, 5, 6);\n    INSERT INTO pp VALUES(7, 8, 9);\n  }\n} {}\ndo_test without_rowid3-9.2.2 {\n  execsql {\n    INSERT INTO cc VALUES(6, 'A', 5);\n    INSERT INTO cc VALUES(6, 'B', 5);\n    INSERT INTO cc VALUES(9, 'A', 8);\n    INSERT INTO cc VALUES(9, 'B', 8);\n    UPDATE pp SET b = 1 WHERE a = 7;\n    SELECT * FROM cc;\n  }\n} {6 A 5 6 B 5 3 A 2 3 B 2}\ndo_test without_rowid3-9.2.3 {\n  execsql {\n    DELETE FROM pp WHERE a = 4;\n    SELECT * FROM cc;\n  }\n} {{} A {} {} B {} 3 A 2 3 B 2}\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-10.*, test \"foreign key mismatch\" and \n# other errors.\n#\nset tn 0\nforeach zSql [list {\n  CREATE TABLE p(a PRIMARY KEY, b) WITHOUT rowid;\n  CREATE TABLE c(x REFERENCES p(c));\n} {\n  CREATE TABLE c(x REFERENCES v(y));\n  CREATE VIEW v AS SELECT x AS y FROM c;\n} {\n  CREATE TABLE p(a, b, PRIMARY KEY(a, b)) WITHOUT rowid;\n  CREATE TABLE c(x REFERENCES p);\n} {\n  CREATE TABLE p(a COLLATE binary, b);\n  CREATE UNIQUE INDEX i ON p(a COLLATE nocase);\n  CREATE TABLE c(x REFERENCES p(a));\n}] {\n  drop_all_tables\n  do_test without_rowid3-10.1.[incr tn] {\n    execsql $zSql\n    catchsql { INSERT INTO c DEFAULT VALUES }\n  } {/1 {foreign key mismatch - \"c\" referencing \".\"}/}\n}\n\n# \"rowid\" cannot be used as part of a child or parent key definition \n# unless it happens to be the name of an explicitly declared column.\n#\ndo_test without_rowid3-10.2.1 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(c, d, FOREIGN KEY(rowid) REFERENCES t1(a));\n  }\n} {1 {unknown column \"rowid\" in foreign key definition}}\ndo_test without_rowid3-10.2.2 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(rowid, d, FOREIGN KEY(rowid) REFERENCES t1(a));\n  }\n} {0 {}}\ndo_test without_rowid3-10.2.1 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(a, b);\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));\n    INSERT INTO t1(rowid, a, b) VALUES(1, 1, 1);\n    INSERT INTO t2 VALUES(1, 1);\n  }\n} {1 {foreign key mismatch - \"t2\" referencing \"t1\"}}\ndo_test without_rowid3-10.2.2 {\n  drop_all_tables\n  catchsql {\n    CREATE TABLE t1(rowid PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(rowid));\n    INSERT INTO t1(rowid, b) VALUES(1, 1);\n    INSERT INTO t2 VALUES(1, 1);\n  }\n} {0 {}}\n\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-11.*, test CASCADE actions.\n#\ndrop_all_tables\ndo_test without_rowid3-11.1.1 {\n  execsql {\n    CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE t2(c, d, FOREIGN KEY(c) REFERENCES t1(a) ON UPDATE CASCADE);\n\n    INSERT INTO t1 VALUES(10, 100);\n    INSERT INTO t2 VALUES(10, 100);\n    UPDATE t1 SET a = 15;\n    SELECT * FROM t2;\n  }\n} {15 100}\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-12.*, test RESTRICT actions.\n#\ndrop_all_tables\ndo_test without_rowid3-12.1.1 {\n  execsql {\n    CREATE TABLE t1(a, b PRIMARY KEY) WITHOUT rowid;\n    CREATE TABLE t2(\n      x REFERENCES t1 ON UPDATE RESTRICT DEFERRABLE INITIALLY DEFERRED \n    );\n    INSERT INTO t1 VALUES(1, 'one');\n    INSERT INTO t1 VALUES(2, 'two');\n    INSERT INTO t1 VALUES(3, 'three');\n  }\n} {}\ndo_test without_rowid3-12.1.2 { \n  execsql \"BEGIN\"\n  execsql \"INSERT INTO t2 VALUES('two')\"\n} {}\ndo_test without_rowid3-12.1.3 { \n  execsql \"UPDATE t1 SET b = 'four' WHERE b = 'one'\"\n} {}\ndo_test without_rowid3-12.1.4 { \n  catchsql \"UPDATE t1 SET b = 'five' WHERE b = 'two'\"\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-12.1.5 { \n  execsql \"DELETE FROM t1 WHERE b = 'two'\"\n} {}\ndo_test without_rowid3-12.1.6 { \n  catchsql \"COMMIT\"\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-12.1.7 { \n  execsql {\n    INSERT INTO t1 VALUES(2, 'two');\n    COMMIT;\n  }\n} {}\n\ndrop_all_tables\ndo_test without_rowid3-12.2.1 {\n  execsql {\n    CREATE TABLE t1(x COLLATE NOCASE PRIMARY KEY) WITHOUT rowid;\n    CREATE TRIGGER tt1 AFTER DELETE ON t1 \n      WHEN EXISTS ( SELECT 1 FROM t2 WHERE old.x = y )\n    BEGIN\n      INSERT INTO t1 VALUES(old.x);\n    END;\n    CREATE TABLE t2(y REFERENCES t1);\n    INSERT INTO t1 VALUES('A');\n    INSERT INTO t1 VALUES('B');\n    INSERT INTO t2 VALUES('a');\n    INSERT INTO t2 VALUES('b');\n\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\ndo_test without_rowid3-12.2.2 {\n  execsql { DELETE FROM t1 }\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\ndo_test without_rowid3-12.2.3 {\n  execsql {\n    DROP TABLE t2;\n    CREATE TABLE t2(y REFERENCES t1 ON DELETE RESTRICT);\n    INSERT INTO t2 VALUES('a');\n    INSERT INTO t2 VALUES('b');\n  }\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-12.2.4 {\n  execsql {\n    SELECT * FROM t1;\n    SELECT * FROM t2;\n  }\n} {A B a b}\n\ndrop_all_tables\ndo_test without_rowid3-12.3.1 {\n  execsql {\n    CREATE TABLE up(\n      c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,\n      c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,\n      c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,\n      c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,\n      PRIMARY KEY(c34, c35)\n    ) WITHOUT rowid;\n    CREATE TABLE down(\n      c00, c01, c02, c03, c04, c05, c06, c07, c08, c09,\n      c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,\n      c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,\n      c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,\n      FOREIGN KEY(c39, c38) REFERENCES up ON UPDATE CASCADE\n    );\n  }\n} {}\ndo_test without_rowid3-12.3.2 {\n  execsql {\n    INSERT INTO up(c34, c35) VALUES('yes', 'no');\n    INSERT INTO down(c39, c38) VALUES('yes', 'no');\n    UPDATE up SET c34 = 'possibly';\n    SELECT c38, c39 FROM down;\n    DELETE FROM down;\n  }\n} {no possibly}\ndo_test without_rowid3-12.3.3 {\n  catchsql { INSERT INTO down(c39, c38) VALUES('yes', 'no') }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-12.3.4 {\n  execsql { \n    INSERT INTO up(c34, c35) VALUES('yes', 'no');\n    INSERT INTO down(c39, c38) VALUES('yes', 'no');\n  }\n  catchsql { DELETE FROM up WHERE c34 = 'yes' }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-12.3.5 {\n  execsql { \n    DELETE FROM up WHERE c34 = 'possibly';\n    SELECT c34, c35 FROM up;\n    SELECT c39, c38 FROM down;\n  }\n} {yes no yes no}\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-13.*, test that FK processing is performed\n# when rows are REPLACEd.\n#\ndrop_all_tables\ndo_test without_rowid3-13.1.1 {\n  execsql {\n    CREATE TABLE pp(a UNIQUE, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;\n    CREATE TABLE cc(d, e, f UNIQUE, FOREIGN KEY(d, e) REFERENCES pp);\n    INSERT INTO pp VALUES(1, 2, 3);\n    INSERT INTO cc VALUES(2, 3, 1);\n  }\n} {}\nforeach {tn stmt} {\n  1   \"REPLACE INTO pp VALUES(1, 4, 5)\"\n} {\n  do_test without_rowid3-13.1.$tn.1 {\n    catchsql $stmt\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-13.1.$tn.2 {\n    execsql {\n      SELECT * FROM pp;\n      SELECT * FROM cc;\n    }\n  } {1 2 3 2 3 1}\n  do_test without_rowid3-13.1.$tn.3 {\n    execsql BEGIN;\n    catchsql $stmt\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-13.1.$tn.4 {\n    execsql {\n      COMMIT;\n      SELECT * FROM pp;\n      SELECT * FROM cc;\n    }\n  } {1 2 3 2 3 1}\n}\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-14.*, test that the \"DROP TABLE\" and \"ALTER\n# TABLE\" commands work as expected wrt foreign key constraints.\n#\n# without_rowid3-14.1*: ALTER TABLE ADD COLUMN\n# without_rowid3-14.2*: ALTER TABLE RENAME TABLE\n# without_rowid3-14.3*: DROP TABLE\n#\ndrop_all_tables\nifcapable altertable {\n  do_test without_rowid3-14.1.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      CREATE TABLE t1(a PRIMARY KEY) WITHOUT rowid;\n      CREATE TABLE t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test without_rowid3-14.1.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n  \n  \n  # Test the sqlite_rename_parent() function directly.\n  #\n  proc test_rename_parent {zCreate zOld zNew} {\n    db eval {SELECT sqlite_rename_parent($zCreate, $zOld, $zNew)}\n  }\n  do_test without_rowid3-14.2.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test without_rowid3-14.2.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test without_rowid3-14.2.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test without_rowid3-14.2.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;\n      CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid;\n      CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid}       \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test without_rowid3-14.2.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\") WITHOUT rowid}      \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)\n            WITHOUT rowid}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test without_rowid3-14.2.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test without_rowid3-14.2.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test without_rowid3-14.2.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n\n  # Repeat for TEMP tables\n  #\n  drop_all_tables\n  do_test without_rowid3-14.1tmp.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      CREATE TEMP TABLE t1(a PRIMARY KEY) WITHOUT rowid;\n      CREATE TEMP TABLE t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1tmp.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1tmp.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test without_rowid3-14.1tmp.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1tmp.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1tmp.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM temp.sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n\n  do_test without_rowid3-14.2tmp.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test without_rowid3-14.2tmp.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test without_rowid3-14.2tmp.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test without_rowid3-14.2tmp.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;\n      CREATE TEMP TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid;\n      CREATE TEMP TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM sqlite_temp_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid}       \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test without_rowid3-14.2tmp.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM temp.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\") WITHOUT rowid}      \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)\n            WITHOUT rowid}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test without_rowid3-14.2tmp.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2tmp.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test without_rowid3-14.2tmp.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2tmp.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test without_rowid3-14.2tmp.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n\n  # Repeat for ATTACH-ed tables\n  #\n  drop_all_tables\n  do_test without_rowid3-14.1aux.1 {\n    # Adding a column with a REFERENCES clause is not supported.\n    execsql { \n      ATTACH ':memory:' AS aux;\n      CREATE TABLE aux.t1(a PRIMARY KEY) WITHOUT rowid;\n      CREATE TABLE aux.t2(a, b);\n    }\n    catchsql { ALTER TABLE t2 ADD COLUMN c REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1aux.2 {\n    catchsql { ALTER TABLE t2 ADD COLUMN d DEFAULT NULL REFERENCES t1 }\n  } {0 {}}\n  do_test without_rowid3-14.1aux.3 {\n    catchsql { ALTER TABLE t2 ADD COLUMN e REFERENCES t1 DEFAULT NULL}\n  } {0 {}}\n  do_test without_rowid3-14.1aux.4 {\n    catchsql { ALTER TABLE t2 ADD COLUMN f REFERENCES t1 DEFAULT 'text'}\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1aux.5 {\n    catchsql { ALTER TABLE t2 ADD COLUMN g DEFAULT CURRENT_TIME REFERENCES t1 }\n  } {1 {Cannot add a REFERENCES column with non-NULL default value}}\n  do_test without_rowid3-14.1aux.6 {\n    execsql { \n      PRAGMA foreign_keys = off;\n      ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;\n      PRAGMA foreign_keys = on;\n      SELECT sql FROM aux.sqlite_master WHERE name='t2';\n    }\n  } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}\n\n  do_test without_rowid3-14.2aux.1.1 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  do_test without_rowid3-14.2aux.1.2 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3\n  } {{CREATE TABLE t1(a REFERENCES t2)}}\n  do_test without_rowid3-14.2aux.1.3 {\n    test_rename_parent {CREATE TABLE t1(a REFERENCES \"t2\")} t2 t3\n  } {{CREATE TABLE t1(a REFERENCES \"t3\")}}\n  \n  # Test ALTER TABLE RENAME TABLE a bit.\n  #\n  do_test without_rowid3-14.2aux.2.1 {\n    drop_all_tables\n    execsql {\n      CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;\n      CREATE TABLE aux.t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid;\n      CREATE TABLE aux.t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1);\n    }\n    execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid}       \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES t1, c REFERENCES t2)\n            WITHOUT rowid}    \\\n    {CREATE TABLE t3(a REFERENCES t1, b REFERENCES t2, c REFERENCES t1)}  \\\n  ]\n  do_test without_rowid3-14.2aux.2.2 {\n    execsql { ALTER TABLE t1 RENAME TO t4 }\n    execsql { SELECT sql FROM aux.sqlite_master WHERE type = 'table'}\n  } [list \\\n    {CREATE TABLE \"t4\"(a PRIMARY KEY, b REFERENCES \"t4\") WITHOUT rowid}      \\\n    {CREATE TABLE t2(a PRIMARY KEY, b REFERENCES \"t4\", c REFERENCES t2)\n            WITHOUT rowid}     \\\n    {CREATE TABLE t3(a REFERENCES \"t4\", b REFERENCES t2, c REFERENCES \"t4\")} \\\n  ]\n  do_test without_rowid3-14.2aux.2.3 {\n    catchsql { INSERT INTO t3 VALUES(1, 2, 3) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2aux.2.4 {\n    execsql { INSERT INTO t4 VALUES(1, NULL) }\n  } {}\n  do_test without_rowid3-14.2aux.2.5 {\n    catchsql { UPDATE t4 SET b = 5 }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-14.2aux.2.6 {\n    catchsql { UPDATE t4 SET b = 1 }\n  } {0 {}}\n  do_test without_rowid3-14.2aux.2.7 {\n    execsql { INSERT INTO t3 VALUES(1, NULL, 1) }\n  } {}\n}\n\ndo_test without_rowid3-2.14.3.1 {\n  drop_all_tables\n  execsql {\n    CREATE TABLE t1(a, b REFERENCES nosuchtable);\n    DROP TABLE t1;\n  }\n} {}\ndo_test without_rowid3-2.14.3.2 {\n  execsql {\n    CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT rowid;\n    INSERT INTO t1 VALUES('a', 1);\n    CREATE TABLE t2(x REFERENCES t1);\n    INSERT INTO t2 VALUES('a');\n  }\n} {}\ndo_test without_rowid3-2.14.3.3 {\n  catchsql { DROP TABLE t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-2.14.3.4 {\n  execsql {\n    DELETE FROM t2;\n    DROP TABLE t1;\n  }\n} {}\ndo_test without_rowid3-2.14.3.4 {\n  catchsql { INSERT INTO t2 VALUES('x') }\n} {1 {no such table: main.t1}}\ndo_test without_rowid3-2.14.3.5 {\n  execsql {\n    CREATE TABLE t1(x PRIMARY KEY) WITHOUT rowid;\n    INSERT INTO t1 VALUES('x');\n  }\n  execsql { INSERT INTO t2 VALUES('x') }\n} {}\ndo_test without_rowid3-2.14.3.6 {\n  catchsql { DROP TABLE t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-2.14.3.7 {\n  execsql {\n    DROP TABLE t2;\n    DROP TABLE t1;\n  }\n} {}\ndo_test without_rowid3-2.14.3.8 {\n  execsql {\n    CREATE TABLE pp(x, y, PRIMARY KEY(x, y)) WITHOUT ROWID;\n    CREATE TABLE cc(a, b, FOREIGN KEY(a, b) REFERENCES pp(x, z));\n  }\n  catchsql { INSERT INTO cc VALUES(1, 2) }\n} {1 {foreign key mismatch - \"cc\" referencing \"pp\"}}\ndo_test without_rowid3-2.14.3.9 {\n  execsql { DROP TABLE cc }\n} {}\ndo_test without_rowid3-2.14.3.10 {\n  execsql {\n    CREATE TABLE cc(a, b, \n      FOREIGN KEY(a, b) REFERENCES pp DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n  execsql {\n    INSERT INTO pp VALUES('a', 'b');\n    INSERT INTO cc VALUES('a', 'b');\n    BEGIN;\n      DROP TABLE pp;\n      CREATE TABLE pp(a, b, c, PRIMARY KEY(b, c)) WITHOUT rowid;\n      INSERT INTO pp VALUES(1, 'a', 'b');\n    COMMIT;\n  }\n} {}\ndo_test without_rowid3-2.14.3.11 {\n  execsql { \n    BEGIN;\n      DROP TABLE cc;\n      DROP TABLE pp;\n    COMMIT;\n  }\n} {}\ndo_test without_rowid3-2.14.3.12 {\n  execsql {\n    CREATE TABLE b1(a, b);\n    CREATE TABLE b2(a, b REFERENCES b1);\n    DROP TABLE b1;\n  }\n} {}\ndo_test without_rowid3-2.14.3.13 {\n  execsql {\n    CREATE TABLE b3(a, b REFERENCES b2 DEFERRABLE INITIALLY DEFERRED);\n    DROP TABLE b2;\n  }\n} {}\n\n# Test that nothing goes wrong when dropping a table that refers to a view.\n# Or dropping a view that an existing FK (incorrectly) refers to. Or either\n# of the above scenarios with a virtual table.\ndrop_all_tables\ndo_test without_rowid3-2.14.4.1 {\n  execsql {\n    CREATE TABLE t1(x REFERENCES v); \n    CREATE VIEW v AS SELECT * FROM t1;\n  }\n} {}\ndo_test without_rowid3-2.14.4.2 {\n  execsql {\n    DROP VIEW v;\n  }\n} {}\nifcapable vtab {\n  register_echo_module db\n  do_test without_rowid3-2.14.4.3 {\n    execsql { CREATE VIRTUAL TABLE v USING echo(t1) }\n  } {}\n  do_test without_rowid3-2.14.4.2 {\n    execsql {\n      DROP TABLE v;\n    }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# The following tests, without_rowid3-15.*, test that unnecessary FK related scans \n# and lookups are avoided when the constraint counters are zero.\n#\ndrop_all_tables\nproc execsqlS {zSql} {\n  set ::sqlite_search_count 0\n  set ::sqlite_found_count 0\n  set res [uplevel [list execsql $zSql]]\n  concat [expr $::sqlite_found_count + $::sqlite_search_count] $res\n}\ndo_test without_rowid3-15.1.1 {\n  execsql {\n    CREATE TABLE pp(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE cc(x, y REFERENCES pp DEFERRABLE INITIALLY DEFERRED);\n    INSERT INTO pp VALUES(1, 'one');\n    INSERT INTO pp VALUES(2, 'two');\n    INSERT INTO cc VALUES('neung', 1);\n    INSERT INTO cc VALUES('song', 2);\n  }\n} {}\ndo_test without_rowid3-15.1.2 {\n  execsqlS { INSERT INTO pp VALUES(3, 'three') }\n} {0}\ndo_test without_rowid3-15.1.3 {\n  execsql {\n    BEGIN;\n      INSERT INTO cc VALUES('see', 4);    -- Violates deferred constraint\n  }\n  execsqlS { INSERT INTO pp VALUES(5, 'five') }\n} {2}\ndo_test without_rowid3-15.1.4 {\n  execsql { DELETE FROM cc WHERE x = 'see' }\n  execsqlS { INSERT INTO pp VALUES(6, 'six') }\n} {0}\ndo_test without_rowid3-15.1.5 {\n  execsql COMMIT\n} {}\ndo_test without_rowid3-15.1.6 {\n  execsql BEGIN\n  execsqlS {\n    DELETE FROM cc WHERE x = 'neung';\n    ROLLBACK;\n  }\n} {1}\ndo_test without_rowid3-15.1.7 {\n  execsql { \n    BEGIN;\n    DELETE FROM pp WHERE a = 2;\n  }\n  execsqlS {\n    DELETE FROM cc WHERE x = 'neung';\n    ROLLBACK;\n  }\n} {2}\n\n#-------------------------------------------------------------------------\n# This next block of tests, without_rowid3-16.*, test that rows that refer to\n# themselves may be inserted and deleted.\n#\nforeach {tn zSchema} {\n  1 { CREATE TABLE self(a INTEGER PRIMARY KEY, b REFERENCES self(a))\n             WITHOUT rowid }\n  2 { CREATE TABLE self(a PRIMARY KEY, b REFERENCES self(a)) WITHOUT rowid }\n  3 { CREATE TABLE self(a UNIQUE, b INT PRIMARY KEY REFERENCES self(a))\n             WITHOUT rowid }\n} {\n  drop_all_tables\n  do_test without_rowid3-16.1.$tn.1 {\n    execsql $zSchema\n    execsql { INSERT INTO self VALUES(13, 13) }\n  } {}\n  do_test without_rowid3-16.1.$tn.2 {\n    execsql { UPDATE self SET a = 14, b = 14 }\n  } {}\n\n  do_test without_rowid3-16.1.$tn.3 {\n    catchsql { UPDATE self SET b = 15 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test without_rowid3-16.1.$tn.4 {\n    catchsql { UPDATE self SET a = 15 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test without_rowid3-16.1.$tn.5 {\n    catchsql { UPDATE self SET a = 15, b = 16 }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  do_test without_rowid3-16.1.$tn.6 {\n    catchsql { UPDATE self SET a = 17, b = 17 }\n  } {0 {}}\n\n  do_test without_rowid3-16.1.$tn.7 {\n    execsql { DELETE FROM self }\n  } {}\n  do_test without_rowid3-16.1.$tn.8 {\n    catchsql { INSERT INTO self VALUES(20, 21) }\n  } {1 {FOREIGN KEY constraint failed}}\n}\n\n# Additional tests cases using multi-column self-referential\n# FOREIGN KEY constraints.\n#\ndrop_all_tables\ndo_execsql_test without_rowid3-16.4.1.1 {\n  PRAGMA foreign_keys=ON;\n  CREATE TABLE t1(a,b,c,d,e,f,\n     UNIQUE (a,b),\n     PRIMARY KEY (e,c),\n     FOREIGN KEY (d,f) REFERENCES t1(e,c)\n  ) WITHOUT rowid;\n  INSERT INTO t1 VALUES(1,2,3,5,5,3);\n  INSERT INTO t1 VALUES(2,3,4,6,6,4);\n  INSERT INTO t1 VALUES('x','y',1.5,'fizzle','fizzle',1.5);\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 3 5 5 3 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_execsql_test without_rowid3-16.4.1.2 {\n  UPDATE t1 SET c=99, f=99 WHERE a=1;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 99 5 5 99 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_execsql_test without_rowid3-16.4.1.3 {\n  UPDATE t1 SET e=876, d=876 WHERE a=2;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_test without_rowid3-16.4.1.4 {\n  catchsql {\n    UPDATE t1 SET c=11, e=22 WHERE a=1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test without_rowid3-16.4.1.5 {\n  catchsql {\n    UPDATE t1 SET d=11, f=22 WHERE a=1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test without_rowid3-16.4.1.6 {\n  DELETE FROM t1 WHERE a=1;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_execsql_test without_rowid3-16.4.2.1 {\n  DROP TABLE t1;\n  CREATE TABLE t1(a,b,c,d,e,f,\n     PRIMARY KEY (a,b),\n     UNIQUE (e,c),\n     FOREIGN KEY (d,f) REFERENCES t1(e,c)\n  ) WITHOUT rowid;\n  INSERT INTO t1 VALUES(1,2,3,5,5,3);\n  INSERT INTO t1 VALUES(2,3,4,6,6,4);\n  INSERT INTO t1 VALUES('x','y',1.5,'fizzle','fizzle',1.5);\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 3 5 5 3 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_execsql_test without_rowid3-16.4.2.2 {\n  UPDATE t1 SET c=99, f=99 WHERE a=1;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 99 5 5 99 | 2 3 4 6 6 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_execsql_test without_rowid3-16.4.2.3 {\n  UPDATE t1 SET e=876, d=876 WHERE a=2;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {1 2 99 5 5 99 | 2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}\n\ndo_test without_rowid3-16.4.2.4 {\n  catchsql {\n    UPDATE t1 SET c=11, e=22 WHERE a=1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_test without_rowid3-16.4.2.5 {\n  catchsql {\n    UPDATE t1 SET d=11, f=22 WHERE a=1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\ndo_execsql_test without_rowid3-16.4.2.6 {\n  DELETE FROM t1 WHERE a=1;\n  SELECT *, '|' FROM t1 ORDER BY a, b;\n} {2 3 4 876 876 4 | x y 1.5 fizzle fizzle 1.5 |}\n\n\n#-------------------------------------------------------------------------\n# This next block of tests, without_rowid3-17.*, tests that if \"PRAGMA count_changes\"\n# is turned on statements that violate immediate FK constraints return\n# SQLITE_CONSTRAINT immediately, not after returning a number of rows.\n# Whereas statements that violate deferred FK constraints return the number\n# of rows before failing.\n#\n# Also test that rows modified by FK actions are not counted in either the\n# returned row count or the values returned by sqlite3_changes(). Like\n# trigger related changes, they are included in sqlite3_total_changes() though.\n#\ndrop_all_tables\ndo_test without_rowid3-17.1.1 {\n  execsql { PRAGMA count_changes = 1 }\n  execsql { \n    CREATE TABLE one(a, b, c, UNIQUE(b, c));\n    CREATE TABLE two(d, e, f, FOREIGN KEY(e, f) REFERENCES one(b, c));\n    INSERT INTO one VALUES(1, 2, 3);\n  }\n} {1}\ndo_test without_rowid3-17.1.2 {\n  set STMT [sqlite3_prepare_v2 db \"INSERT INTO two VALUES(4, 5, 6)\" -1 dummy]\n  sqlite3_step $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-17.1.2b SQLITE_CONSTRAINT_FOREIGNKEY\nifcapable autoreset {\n  do_test without_rowid3-17.1.3 {\n    sqlite3_step $STMT\n  } {SQLITE_CONSTRAINT}\n  verify_ex_errcode without_rowid3-17.1.3b SQLITE_CONSTRAINT_FOREIGNKEY\n} else {\n  do_test without_rowid3-17.1.3 {\n    sqlite3_step $STMT\n  } {SQLITE_MISUSE}\n}\ndo_test without_rowid3-17.1.4 {\n  sqlite3_finalize $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-17.1.4b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test without_rowid3-17.1.5 {\n  execsql {\n    INSERT INTO one VALUES(2, 3, 4);\n    INSERT INTO one VALUES(3, 4, 5);\n    INSERT INTO two VALUES(1, 2, 3);\n    INSERT INTO two VALUES(2, 3, 4);\n    INSERT INTO two VALUES(3, 4, 5);\n  }\n} {1 1 1 1 1}\ndo_test without_rowid3-17.1.6 {\n  catchsql {\n    BEGIN;\n      INSERT INTO one VALUES(0, 0, 0);\n      UPDATE two SET e=e+1, f=f+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-17.1.7 {\n  execsql { SELECT * FROM one }\n} {1 2 3 2 3 4 3 4 5 0 0 0}\ndo_test without_rowid3-17.1.8 {\n  execsql { SELECT * FROM two }\n} {1 2 3 2 3 4 3 4 5}\ndo_test without_rowid3-17.1.9 {\n  execsql COMMIT\n} {}\ndo_test without_rowid3-17.1.10 {\n  execsql {\n    CREATE TABLE three(\n      g, h, i, \n      FOREIGN KEY(h, i) REFERENCES one(b, c) DEFERRABLE INITIALLY DEFERRED\n    );\n  }\n} {}\ndo_test without_rowid3-17.1.11 {\n  set STMT [sqlite3_prepare_v2 db \"INSERT INTO three VALUES(7, 8, 9)\" -1 dummy]\n  sqlite3_step $STMT\n} {SQLITE_ROW}\ndo_test without_rowid3-17.1.12 {\n  sqlite3_column_text $STMT 0\n} {1}\ndo_test without_rowid3-17.1.13 {\n  sqlite3_step $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-17.1.13b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test without_rowid3-17.1.14 {\n  sqlite3_finalize $STMT\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-17.1.14b SQLITE_CONSTRAINT_FOREIGNKEY\n\ndrop_all_tables\ndo_test without_rowid3-17.2.1 {\n  execsql {\n    CREATE TABLE high(\"a'b!\" PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE low(\n      c, \n      \"d&6\" REFERENCES high ON UPDATE CASCADE ON DELETE CASCADE\n    );\n  }\n} {}\ndo_test without_rowid3-17.2.2 {\n  execsql {\n    INSERT INTO high VALUES('a', 'b');\n    INSERT INTO low VALUES('b', 'a');\n  }\n  db changes\n} {1}\nset nTotal [db total_changes]\ndo_test without_rowid3-17.2.3 {\n  execsql { UPDATE high SET \"a'b!\" = 'c' }\n} {1}\ndo_test without_rowid3-17.2.4 {\n  db changes\n} {1}\ndo_test without_rowid3-17.2.5 {\n  expr [db total_changes] - $nTotal\n} {2}\ndo_test without_rowid3-17.2.6 {\n  execsql { SELECT * FROM high ; SELECT * FROM low }\n} {c b b c}\ndo_test without_rowid3-17.2.7 {\n  execsql { DELETE FROM high }\n} {1}\ndo_test without_rowid3-17.2.8 {\n  db changes\n} {1}\ndo_test without_rowid3-17.2.9 {\n  expr [db total_changes] - $nTotal\n} {4}\ndo_test without_rowid3-17.2.10 {\n  execsql { SELECT * FROM high ; SELECT * FROM low }\n} {}\nexecsql { PRAGMA count_changes = 0 }\n\n#-------------------------------------------------------------------------\n# Test that the authorization callback works.\n#\n\nifcapable auth {\n  do_test without_rowid3-18.1 {\n    execsql {\n      CREATE TABLE long(a, b PRIMARY KEY, c) WITHOUT rowid;\n      CREATE TABLE short(d, e, f REFERENCES long);\n      CREATE TABLE mid(g, h, i REFERENCES long DEFERRABLE INITIALLY DEFERRED);\n    }\n  } {}\n\n  proc auth {args} {eval lappend ::authargs [lrange $args 0 4]; return SQLITE_OK}\n  db auth auth\n\n  # An insert on the parent table must read the child key of any deferred\n  # foreign key constraints. But not the child key of immediate constraints.\n  set authargs {}\n  do_test without_rowid3-18.2 {\n    execsql { INSERT INTO long VALUES(1, 2, 3) }\n    set authargs\n  } {SQLITE_INSERT long {} main {} SQLITE_READ mid i main {}}\n\n  # An insert on the child table of an immediate constraint must read the\n  # parent key columns (to see if it is a violation or not).\n  set authargs {}\n  do_test without_rowid3-18.3 {\n    execsql { INSERT INTO short VALUES(1, 3, 2) }\n    set authargs\n  } {SQLITE_INSERT short {} main {} SQLITE_READ long b main {}}\n  \n  # As must an insert on the child table of a deferred constraint.\n  set authargs {}\n  do_test without_rowid3-18.4 {\n    execsql { INSERT INTO mid VALUES(1, 3, 2) }\n    set authargs\n  } {SQLITE_INSERT mid {} main {} SQLITE_READ long b main {}}\n\n  do_test without_rowid3-18.5 {\n    execsql {\n      CREATE TABLE nought(a, b PRIMARY KEY, c) WITHOUT rowid;\n      CREATE TABLE cross(d, e, f,\n        FOREIGN KEY(e) REFERENCES nought(b) ON UPDATE CASCADE\n      );\n    }\n    execsql { INSERT INTO nought VALUES(2, 1, 2) }\n    execsql { INSERT INTO cross VALUES(0, 1, 0) }\n    set authargs [list]\n    execsql { UPDATE nought SET b = 5 }\n    set authargs\n  } {SQLITE_UPDATE nought b main {} SQLITE_READ cross e main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {} SQLITE_UPDATE cross e main {} SQLITE_READ nought b main {} SQLITE_READ cross e main {} SQLITE_READ nought b main {} SQLITE_READ nought b main {}}\n\n  do_test without_rowid3-18.6 {\n    execsql {SELECT * FROM cross}\n  } {0 5 0}\n\n  do_test without_rowid3-18.7 {\n    execsql {\n      CREATE TABLE one(a INT PRIMARY KEY, b) WITHOUT rowid;\n      CREATE TABLE two(b, c REFERENCES one);\n      INSERT INTO one VALUES(101, 102);\n    }\n    set authargs [list]\n    execsql { INSERT INTO two VALUES(100, 101); }\n    set authargs\n  } {SQLITE_INSERT two {} main {} SQLITE_READ one a main {}}\n\n  # Return SQLITE_IGNORE to requests to read from the parent table. This\n  # causes inserts of non-NULL keys into the child table to fail.\n  #\n  rename auth {}\n  proc auth {args} {\n    if {[lindex $args 1] == \"long\"} {return SQLITE_IGNORE}\n    return SQLITE_OK\n  }\n  do_test without_rowid3-18.8 {\n    catchsql { INSERT INTO short VALUES(1, 3, 2) }\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-18.9 {\n    execsql { INSERT INTO short VALUES(1, 3, NULL) }\n  } {}\n  do_test without_rowid3-18.10 {\n    execsql { SELECT * FROM short }\n  } {1 3 2 1 3 {}}\n  do_test without_rowid3-18.11 {\n    catchsql { UPDATE short SET f = 2 WHERE f IS NULL }\n  } {1 {FOREIGN KEY constraint failed}}\n\n  db auth {}\n  unset authargs\n}\n\n\ndo_test without_rowid3-19.1 {\n  execsql {\n    CREATE TABLE main(id INT PRIMARY KEY) WITHOUT rowid;\n    CREATE TABLE sub(id INT REFERENCES main(id));\n    INSERT INTO main VALUES(1);\n    INSERT INTO main VALUES(2);\n    INSERT INTO sub VALUES(2);\n  }\n} {}\ndo_test without_rowid3-19.2 {\n  set S [sqlite3_prepare_v2 db \"DELETE FROM main WHERE id = ?\" -1 dummy]\n  sqlite3_bind_int $S 1 2\n  sqlite3_step $S\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-19.2b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test without_rowid3-19.3 {\n  sqlite3_reset $S\n} {SQLITE_CONSTRAINT}\nverify_ex_errcode without_rowid3-19.3b SQLITE_CONSTRAINT_FOREIGNKEY\ndo_test without_rowid3-19.4 {\n  sqlite3_bind_int $S 1 1\n  sqlite3_step $S\n} {SQLITE_DONE}\ndo_test without_rowid3-19.4 {\n  sqlite3_finalize $S\n} {SQLITE_OK}\n\ndrop_all_tables\ndo_test without_rowid3-20.1 {\n  execsql {\n    CREATE TABLE pp(a PRIMARY KEY, b) WITHOUT rowid;\n    CREATE TABLE cc(c PRIMARY KEY, d REFERENCES pp) WITHOUT rowid;\n  }\n} {}\n\nforeach {tn insert} {\n  1 \"INSERT\"\n  2 \"INSERT OR IGNORE\"\n  3 \"INSERT OR ABORT\"\n  4 \"INSERT OR ROLLBACK\"\n  5 \"INSERT OR REPLACE\"\n  6 \"INSERT OR FAIL\"\n} {\n  do_test without_rowid3-20.2.$tn.1 {\n    catchsql \"$insert INTO cc VALUES(1, 2)\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.2.$tn.2 {\n    execsql { SELECT * FROM cc }\n  } {}\n  do_test without_rowid3-20.2.$tn.3 {\n    execsql {\n      BEGIN;\n        INSERT INTO pp VALUES(2, 'two');\n        INSERT INTO cc VALUES(1, 2);\n    }\n    catchsql \"$insert INTO cc VALUES(3, 4)\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.2.$tn.4 {\n    execsql { COMMIT ; SELECT * FROM cc }\n  } {1 2}\n  do_test without_rowid3-20.2.$tn.5 {\n    execsql { DELETE FROM cc ; DELETE FROM pp }\n  } {}\n}\n\nforeach {tn update} {\n  1 \"UPDATE\"\n  2 \"UPDATE OR IGNORE\"\n  3 \"UPDATE OR ABORT\"\n  4 \"UPDATE OR ROLLBACK\"\n  5 \"UPDATE OR REPLACE\"\n  6 \"UPDATE OR FAIL\"\n} {\n  do_test without_rowid3-20.3.$tn.1 {\n    execsql {\n      INSERT INTO pp VALUES(2, 'two');\n      INSERT INTO cc VALUES(1, 2);\n    }\n  } {}\n  do_test without_rowid3-20.3.$tn.2 {\n    catchsql \"$update pp SET a = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.3.$tn.3 {\n    execsql { SELECT * FROM pp }\n  } {2 two}\n  do_test without_rowid3-20.3.$tn.4 {\n    catchsql \"$update cc SET d = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.3.$tn.5 {\n    execsql { SELECT * FROM cc }\n  } {1 2}\n  do_test without_rowid3-20.3.$tn.6 {\n    execsql {\n      BEGIN;\n        INSERT INTO pp VALUES(3, 'three');\n    }\n    catchsql \"$update pp SET a = 1 WHERE a = 2\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.3.$tn.7 {\n    execsql { COMMIT ; SELECT * FROM pp }\n  } {2 two 3 three}\n  do_test without_rowid3-20.3.$tn.8 {\n    execsql {\n      BEGIN;\n        INSERT INTO cc VALUES(2, 2);\n    }\n    catchsql \"$update cc SET d = 1 WHERE c = 1\"\n  } {1 {FOREIGN KEY constraint failed}}\n  do_test without_rowid3-20.3.$tn.9 {\n    execsql { COMMIT ; SELECT * FROM cc }\n  } {1 2 2 2}\n  do_test without_rowid3-20.3.$tn.10 {\n    execsql { DELETE FROM cc ; DELETE FROM pp }\n  } {}\n}\n\n#-------------------------------------------------------------------------\n# The following block of tests, those prefixed with \"without_rowid3-genfkey.\",\n# are the same tests that were used to test the \".genfkey\" command provided \n# by the shell tool. So these tests show that the built-in foreign key \n# implementation is more or less compatible with the triggers generated \n# by genfkey.\n#\ndrop_all_tables\ndo_test without_rowid3-genfkey.1.1 {\n  execsql {\n    CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;\n    CREATE TABLE t2(e REFERENCES t1, f);\n    CREATE TABLE t3(g, h, i, FOREIGN KEY (h, i) REFERENCES t1(b, c));\n  }\n} {}\ndo_test without_rowid3-genfkey.1.2 {\n  catchsql { INSERT INTO t2 VALUES(1, 2) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.3 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t2 VALUES(1, 2);\n  }\n} {}\ndo_test without_rowid3-genfkey.1.4 {\n  execsql { INSERT INTO t2 VALUES(NULL, 3) }\n} {}\ndo_test without_rowid3-genfkey.1.5 {\n  catchsql { UPDATE t2 SET e = 5 WHERE e IS NULL }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.6 {\n  execsql { UPDATE t2 SET e = 1 WHERE e IS NULL }\n} {}\ndo_test without_rowid3-genfkey.1.7 {\n  execsql { UPDATE t2 SET e = NULL WHERE f = 3 }\n} {}\ndo_test without_rowid3-genfkey.1.8 {\n  catchsql { UPDATE t1 SET a = 10 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.9 {\n  catchsql { UPDATE t1 SET a = NULL }\n} {1 {NOT NULL constraint failed: t1.a}}\ndo_test without_rowid3-genfkey.1.10 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.11 {\n  execsql { UPDATE t2 SET e = NULL }\n} {}\ndo_test without_rowid3-genfkey.1.12 {\n  execsql { \n    UPDATE t1 SET a = 10;\n    DELETE FROM t1;\n    DELETE FROM t2;\n  }\n} {}\ndo_test without_rowid3-genfkey.1.13 {\n  execsql {\n    INSERT INTO t3 VALUES(1, NULL, NULL);\n    INSERT INTO t3 VALUES(1, 2, NULL);\n    INSERT INTO t3 VALUES(1, NULL, 3);\n  }\n} {}\ndo_test without_rowid3-genfkey.1.14 {\n  catchsql { INSERT INTO t3 VALUES(3, 1, 4) }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.15 {\n  execsql { \n    INSERT INTO t1 VALUES(1, 1, 4);\n    INSERT INTO t3 VALUES(3, 1, 4);\n  }\n} {}\ndo_test without_rowid3-genfkey.1.16 {\n  catchsql { DELETE FROM t1 }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.17 {\n  catchsql { UPDATE t1 SET b = 10}\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-genfkey.1.18 {\n  execsql { UPDATE t1 SET a = 10}\n} {}\ndo_test without_rowid3-genfkey.1.19 {\n  catchsql { UPDATE t3 SET h = 'hello' WHERE i = 3}\n} {1 {FOREIGN KEY constraint failed}}\n\ndrop_all_tables\ndo_test without_rowid3-genfkey.2.1 {\n  execsql {\n    CREATE TABLE t1(a INT PRIMARY KEY, b, c, UNIQUE(b, c)) WITHOUT rowid;\n    CREATE TABLE t2(e REFERENCES t1 ON UPDATE CASCADE ON DELETE CASCADE, f);\n    CREATE TABLE t3(g, h, i, \n        FOREIGN KEY (h, i) \n        REFERENCES t1(b, c) ON UPDATE CASCADE ON DELETE CASCADE\n    );\n  }\n} {}\ndo_test without_rowid3-genfkey.2.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(4, 'four');\n  }\n} {}\ndo_test without_rowid3-genfkey.2.3 {\n  execsql {\n    UPDATE t1 SET a = 2 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {2 one 4 four}\ndo_test without_rowid3-genfkey.2.4 {\n  execsql {\n    DELETE FROM t1 WHERE a = 4;\n    SELECT * FROM t2;\n  }\n} {2 one}\n\ndo_test without_rowid3-genfkey.2.5 {\n  execsql {\n    INSERT INTO t3 VALUES('hello', 2, 3);\n    UPDATE t1 SET c = 2;\n    SELECT * FROM t3;\n  }\n} {hello 2 2}\ndo_test without_rowid3-genfkey.2.6 {\n  execsql {\n    DELETE FROM t1;\n    SELECT * FROM t3;\n  }\n} {}\n\ndrop_all_tables\ndo_test without_rowid3-genfkey.3.1 {\n  execsql {\n    CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c, UNIQUE(c, b)) WITHOUT rowid;\n    CREATE TABLE t2(e REFERENCES t1 ON UPDATE SET NULL ON DELETE SET NULL, f);\n    CREATE TABLE t3(g, h, i, \n        FOREIGN KEY (h, i) \n        REFERENCES t1(b, c) ON UPDATE SET NULL ON DELETE SET NULL\n    );\n  }\n} {}\ndo_test without_rowid3-genfkey.3.2 {\n  execsql {\n    INSERT INTO t1 VALUES(1, 2, 3);\n    INSERT INTO t1 VALUES(4, 5, 6);\n    INSERT INTO t2 VALUES(1, 'one');\n    INSERT INTO t2 VALUES(4, 'four');\n  }\n} {}\ndo_test without_rowid3-genfkey.3.3 {\n  execsql {\n    UPDATE t1 SET a = 2 WHERE a = 1;\n    SELECT * FROM t2;\n  }\n} {{} one 4 four}\ndo_test without_rowid3-genfkey.3.4 {\n  execsql {\n    DELETE FROM t1 WHERE a = 4;\n    SELECT * FROM t2;\n  }\n} {{} one {} four}\ndo_test without_rowid3-genfkey.3.5 {\n  execsql {\n    INSERT INTO t3 VALUES('hello', 2, 3);\n    UPDATE t1 SET c = 2;\n    SELECT * FROM t3;\n  }\n} {hello {} {}}\ndo_test without_rowid3-genfkey.3.6 {\n  execsql {\n    UPDATE t3 SET h = 2, i = 2;\n    DELETE FROM t1;\n    SELECT * FROM t3;\n  }\n} {hello {} {}}\n\n#-------------------------------------------------------------------------\n# Verify that ticket dd08e5a988d00decc4a543daa8dbbfab9c577ad8 has been\n# fixed.\n#\ndo_test without_rowid3-dd08e5.1.1 {\n  execsql {\n    PRAGMA foreign_keys=ON;\n    CREATE TABLE tdd08(a INTEGER PRIMARY KEY, b) WITHOUT rowid;\n    CREATE UNIQUE INDEX idd08 ON tdd08(a,b);\n    INSERT INTO tdd08 VALUES(200,300);\n\n    CREATE TABLE tdd08_b(w,x,y, FOREIGN KEY(x,y) REFERENCES tdd08(a,b));\n    INSERT INTO tdd08_b VALUES(100,200,300);\n  }\n} {}\ndo_test without_rowid3-dd08e5.1.2 {\n  catchsql {\n    DELETE FROM tdd08;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-dd08e5.1.3 {\n  execsql {\n    SELECT * FROM tdd08;\n  }\n} {200 300}\ndo_test without_rowid3-dd08e5.1.4 {\n  catchsql {\n    INSERT INTO tdd08_b VALUES(400,500,300);\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-dd08e5.1.5 {\n  catchsql {\n    UPDATE tdd08_b SET x=x+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-dd08e5.1.6 {\n  catchsql {\n    UPDATE tdd08 SET a=a+1;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\n#-------------------------------------------------------------------------\n# Verify that ticket ce7c133ea6cc9ccdc1a60d80441f80b6180f5eba\n# fixed.\n#\ndo_test without_rowid3-ce7c13.1.1 {\n  execsql {\n    CREATE TABLE tce71(a INTEGER PRIMARY KEY, b) WITHOUT rowid;\n    CREATE UNIQUE INDEX ice71 ON tce71(a,b);\n    INSERT INTO tce71 VALUES(100,200);\n    CREATE TABLE tce72(w, x, y, FOREIGN KEY(x,y) REFERENCES tce71(a,b));\n    INSERT INTO tce72 VALUES(300,100,200);\n    UPDATE tce71 set b = 200 where a = 100;\n    SELECT * FROM tce71, tce72;\n  }\n} {100 200 300 100 200}\ndo_test without_rowid3-ce7c13.1.2 {\n  catchsql {\n    UPDATE tce71 set b = 201 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-ce7c13.1.3 {\n  catchsql {\n    UPDATE tce71 set a = 101 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-ce7c13.1.4 {\n  execsql {\n    CREATE TABLE tce73(a INTEGER PRIMARY KEY, b, UNIQUE(a,b)) WITHOUT rowid;\n    INSERT INTO tce73 VALUES(100,200);\n    CREATE TABLE tce74(w, x, y, FOREIGN KEY(x,y) REFERENCES tce73(a,b));\n    INSERT INTO tce74 VALUES(300,100,200);\n    UPDATE tce73 set b = 200 where a = 100;\n    SELECT * FROM tce73, tce74;\n  }\n} {100 200 300 100 200}\ndo_test without_rowid3-ce7c13.1.5 {\n  catchsql {\n    UPDATE tce73 set b = 201 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\ndo_test without_rowid3-ce7c13.1.6 {\n  catchsql {\n    UPDATE tce73 set a = 101 where a = 100;\n  }\n} {1 {FOREIGN KEY constraint failed}}\n\n# Confirm that changes() works on WITHOUT ROWID tables that use the\n# xfer optimization.\n#\ndb close\nsqlite3 db :memory:\ndo_execsql_test without_rowid3-30.1 {\n  CREATE TABLE t1(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;\n  CREATE TABLE t2(a,b,PRIMARY KEY(a,b)) WITHOUT ROWID;\n  INSERT INTO t1 VALUES(1,2),(3,4),(5,6);\n  SELECT changes();\n} {3}\ndo_execsql_test without_rowid3-30.2 {\n  INSERT INTO t2 SELECT * FROM t1;\n  SELECT changes();\n} {3}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid4.test",
    "content": "# 2013-11-04\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Regression testing of FOR EACH ROW table triggers on WITHOUT ROWID\n# tables.\n#\n# 1. Trigger execution order tests. \n# These tests ensure that BEFORE and AFTER triggers are fired at the correct\n# times relative to each other and the triggering statement. \n#\n# without_rowid4-1.1.*: ON UPDATE trigger execution model.\n# without_rowid4-1.2.*: DELETE trigger execution model.\n# without_rowid4-1.3.*: INSERT trigger execution model.\n#\n# 2. Trigger program execution tests.\n# These tests ensure that trigger programs execute correctly (ie. that a\n# trigger program can correctly execute INSERT, UPDATE, DELETE * SELECT\n# statements, and combinations thereof).\n#\n# 3. Selective trigger execution \n# This tests that conditional triggers (ie. UPDATE OF triggers and triggers\n# with WHEN clauses) are fired only fired when they are supposed to be.\n#\n# without_rowid4-3.1: UPDATE OF triggers\n# without_rowid4-3.2: WHEN clause\n#\n# 4. Cascaded trigger execution \n# Tests that trigger-programs may cause other triggers to fire. Also that a \n# trigger-program is never executed recursively.\n# \n# without_rowid4-4.1: Trivial cascading trigger\n# without_rowid4-4.2: Trivial recursive trigger handling \n#\n# 5. Count changes behaviour.\n# Verify that rows altered by triggers are not included in the return value\n# of the \"count changes\" interface.\n#\n# 6. ON CONFLICT clause handling\n# without_rowid4-6.1[a-f]: INSERT statements\n# without_rowid4-6.2[a-f]: UPDATE statements\n#\n# 7. & 8. Triggers on views fire correctly.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nifcapable {!trigger} {\n  finish_test\n  return\n}\n\n# The tests in this file were written before SQLite supported recursive\n# trigger invocation, and some tests depend on that to pass. So disable\n# recursive triggers for this file.\ncatchsql { pragma recursive_triggers = off } \n\n# 1.\nifcapable subquery {\n  set ii 0\n  set tbl_definitions [list \\\n  \t{CREATE TABLE tbl (a INTEGER PRIMARY KEY, b) WITHOUT rowid;}    \\\n        {CREATE TABLE tbl (a, b PRIMARY KEY) WITHOUT rowid;}            \\\n  \t{CREATE TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid;\n         CREATE INDEX tbl_idx ON tbl(b);}      \\\n  ]\n  ifcapable tempdb {\n    lappend tbl_definitions \\\n        {CREATE TEMP TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid;\n         CREATE INDEX tbl_idx ON tbl(b);} \n    lappend tbl_definitions \\\n        {CREATE TEMP TABLE tbl (a PRIMARY KEY, b) WITHOUT rowid}\n    lappend tbl_definitions \\\n        {CREATE TEMPORARY TABLE tbl (a INTEGER PRIMARY KEY, b) WITHOUT rowid;}\n  }\n  foreach tbl_defn $tbl_definitions {\n    incr ii\n    catchsql { DROP INDEX tbl_idx; }\n    catchsql {\n      DROP TABLE rlog;\n      DROP TABLE clog;\n      DROP TABLE tbl;\n      DROP TABLE other_tbl;\n    }\n  \n    execsql $tbl_defn\n  \n    execsql {\n      INSERT INTO tbl VALUES(1, 2);\n      INSERT INTO tbl VALUES(3, 4);\n  \n      CREATE TABLE rlog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);\n      CREATE TABLE clog (idx, old_a, old_b, db_sum_a, db_sum_b, new_a, new_b);\n  \n      CREATE TRIGGER before_update_row BEFORE UPDATE ON tbl FOR EACH ROW \n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER after_update_row AFTER UPDATE ON tbl FOR EACH ROW \n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER conditional_update_row AFTER UPDATE ON tbl FOR EACH ROW\n        WHEN old.a = 1\n        BEGIN\n        INSERT INTO clog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM clog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n    }\n  \n    do_test without_rowid4-1.$ii.1 {\n      set r {}\n      foreach v [execsql { \n        UPDATE tbl SET a = a * 10, b = b * 10;\n        SELECT * FROM rlog ORDER BY idx;\n        SELECT * FROM clog ORDER BY idx;\n      }] {\n        lappend r [expr {int($v)}]\n      }\n      set r\n    } [list 1 1 2  4  6 10 20 \\\n            2 1 2 13 24 10 20 \\\n  \t    3 3 4 13 24 30 40 \\\n  \t    4 3 4 40 60 30 40 \\\n            1 1 2 13 24 10 20 ]\n  \n    execsql {\n      DELETE FROM rlog;\n      DELETE FROM tbl;\n      INSERT INTO tbl VALUES (100, 100);\n      INSERT INTO tbl VALUES (300, 200);\n      CREATE TRIGGER delete_before_row BEFORE DELETE ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  0, 0);\n      END;\n  \n      CREATE TRIGGER delete_after_row AFTER DELETE ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  old.a, old.b, \n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  0, 0);\n      END;\n    }\n    do_test without_rowid4-1.$ii.2 {\n      set r {}\n      foreach v [execsql {\n        DELETE FROM tbl;\n        SELECT * FROM rlog;\n      }] {\n        lappend r [expr {int($v)}]\n      }\n      set r\n    } [list 1 100 100 400 300 0 0 \\\n            2 100 100 300 200 0 0 \\\n            3 300 200 300 200 0 0 \\\n            4 300 200 0 0 0 0 ]\n  \n    execsql {\n      DELETE FROM rlog;\n      CREATE TRIGGER insert_before_row BEFORE INSERT ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  0, 0,\n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n  \n      CREATE TRIGGER insert_after_row AFTER INSERT ON tbl FOR EACH ROW\n        BEGIN\n        INSERT INTO rlog VALUES ( (SELECT coalesce(max(idx),0) + 1 FROM rlog), \n  \t  0, 0,\n  \t  (SELECT coalesce(sum(a),0) FROM tbl),\n          (SELECT coalesce(sum(b),0) FROM tbl), \n  \t  new.a, new.b);\n      END;\n    }\n    do_test without_rowid4-1.$ii.3 {\n      execsql {\n  \n        CREATE TABLE other_tbl(a, b);\n        INSERT INTO other_tbl VALUES(1, 2);\n        INSERT INTO other_tbl VALUES(3, 4);\n        -- INSERT INTO tbl SELECT * FROM other_tbl;\n        INSERT INTO tbl VALUES(5, 6);\n        DROP TABLE other_tbl;\n  \n        SELECT * FROM rlog;\n      }\n    } [list 1 0 0 0 0 5 6 \\\n            2 0 0 5 6 5 6 ]\n  \n    integrity_check without_rowid4-1.$ii.4\n  }\n  catchsql {\n    DROP TABLE rlog;\n    DROP TABLE clog;\n    DROP TABLE tbl;\n    DROP TABLE other_tbl;\n  }\n}\n\n# 2.\nset ii 0\nforeach tr_program {\n  {UPDATE tbl SET b = old.b;}\n  {INSERT INTO log VALUES(new.c, 2, 3);}\n  {DELETE FROM log WHERE a = 1;}\n  {INSERT INTO tbl VALUES(500, new.b * 10, 700); \n    UPDATE tbl SET c = old.c; \n    DELETE FROM log;}\n  {INSERT INTO log select * from tbl;} \n} {\n  foreach test_varset [ list \\\n    {\n      set statement {UPDATE tbl SET c = 10 WHERE a = 1;} \n      set prep      {INSERT INTO tbl VALUES(1, 2, 3);}\n      set newC 10\n      set newB 2\n      set newA 1\n      set oldA 1\n      set oldB 2\n      set oldC 3\n    } \\\n    {\n      set statement {DELETE FROM tbl WHERE a = 1;}\n      set prep      {INSERT INTO tbl VALUES(1, 2, 3);}\n      set oldA 1\n      set oldB 2\n      set oldC 3\n    } \\\n    {\n      set statement {INSERT INTO tbl VALUES(1, 2, 3);}\n      set newA 1\n      set newB 2\n      set newC 3\n    }\n  ] \\\n  {\n    set statement {}\n    set prep {}\n    set newA {''}\n    set newB {''}\n    set newC {''}\n    set oldA {''}\n    set oldB {''}\n    set oldC {''}\n\n    incr ii\n\n    eval $test_varset\n\n    set statement_type [string range $statement 0 5]\n    set tr_program_fixed $tr_program\n    if {$statement_type == \"DELETE\"} {\n      regsub -all new\\.a $tr_program_fixed {''} tr_program_fixed \n      regsub -all new\\.b $tr_program_fixed {''} tr_program_fixed \n      regsub -all new\\.c $tr_program_fixed {''} tr_program_fixed \n    }\n    if {$statement_type == \"INSERT\"} {\n      regsub -all old\\.a $tr_program_fixed {''} tr_program_fixed \n      regsub -all old\\.b $tr_program_fixed {''} tr_program_fixed \n      regsub -all old\\.c $tr_program_fixed {''} tr_program_fixed \n    }\n\n\n    set tr_program_cooked $tr_program\n    regsub -all new\\.a $tr_program_cooked $newA tr_program_cooked \n    regsub -all new\\.b $tr_program_cooked $newB tr_program_cooked \n    regsub -all new\\.c $tr_program_cooked $newC tr_program_cooked \n    regsub -all old\\.a $tr_program_cooked $oldA tr_program_cooked \n    regsub -all old\\.b $tr_program_cooked $oldB tr_program_cooked \n    regsub -all old\\.c $tr_program_cooked $oldC tr_program_cooked \n\n    catchsql {\n      DROP TABLE tbl;\n      DROP TABLE log;\n    }\n\n    execsql {\n      CREATE TABLE tbl(a PRIMARY KEY, b, c) WITHOUT rowid;\n      CREATE TABLE log(a, b, c);\n    }\n\n    set query {SELECT * FROM tbl; SELECT * FROM log;}\n    set prep \"$prep; INSERT INTO log VALUES(1, 2, 3);\\\n             INSERT INTO log VALUES(10, 20, 30);\"\n\n# Check execution of BEFORE programs:\n\n    set before_data [ execsql \"$prep $tr_program_cooked $statement $query\" ]\n\n    execsql \"DELETE FROM tbl; DELETE FROM log; $prep\";\n    execsql \"CREATE TRIGGER the_trigger BEFORE [string range $statement 0 6]\\\n             ON tbl BEGIN $tr_program_fixed END;\"\n\n    do_test without_rowid4-2.$ii-before \"execsql {$statement $query}\" $before_data\n\n    execsql \"DROP TRIGGER the_trigger;\"\n    execsql \"DELETE FROM tbl; DELETE FROM log;\"\n\n# Check execution of AFTER programs\n    set after_data [ execsql \"$prep $statement $tr_program_cooked $query\" ]\n\n    execsql \"DELETE FROM tbl; DELETE FROM log; $prep\";\n    execsql \"CREATE TRIGGER the_trigger AFTER [string range $statement 0 6]\\\n             ON tbl BEGIN $tr_program_fixed END;\"\n\n    do_test without_rowid4-2.$ii-after \"execsql {$statement $query}\" $after_data\n    execsql \"DROP TRIGGER the_trigger;\"\n\n    integrity_check without_rowid4-2.$ii-integrity\n  }\n}\ncatchsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\n\n# 3.\n\n# without_rowid4-3.1: UPDATE OF triggers\nexecsql {\n  CREATE TABLE tbl (a, b, c, d, PRIMARY KEY(a,b,c,d)) WITHOUT rowid;\n  CREATE TABLE log (a);\n  INSERT INTO log VALUES (0);\n  INSERT INTO tbl VALUES (0, 0, 0, 0);\n  INSERT INTO tbl VALUES (1, 0, 0, 0);\n  CREATE TRIGGER tbl_after_update_cd BEFORE UPDATE OF c, d ON tbl\n    BEGIN\n      UPDATE log SET a = a + 1;\n    END;\n}\ndo_test without_rowid4-3.1 {\n  execsql {\n    UPDATE tbl SET b = 1, c = 10; -- 2\n    UPDATE tbl SET b = 10; -- 0\n    UPDATE tbl SET d = 4 WHERE a = 0; --1\n    UPDATE tbl SET a = 4, b = 10; --0\n    SELECT * FROM log;\n  }\n} {3}\nexecsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\n\n# without_rowid4-3.2: WHEN clause\nset when_triggers [list {t1 BEFORE INSERT ON tbl WHEN new.a > 20}]\nifcapable subquery {\n  lappend when_triggers \\\n      {t2 BEFORE INSERT ON tbl WHEN (SELECT count(*) FROM tbl) = 0}\n}\n\nexecsql {\n  CREATE TABLE tbl (a, b, c, d);\n  CREATE TABLE log (a);\n  INSERT INTO log VALUES (0);\n}\n\nforeach trig $when_triggers {\n  execsql \"CREATE TRIGGER $trig BEGIN UPDATE log set a = a + 1; END;\"\n}\n\nifcapable subquery {\n  set t232 {1 0 1}\n} else {\n  set t232 {0 0 1}\n}\ndo_test without_rowid4-3.2 {\n  execsql { \n\n    INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 1 (ifcapable subquery)\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n\n    INSERT INTO tbl VALUES(0, 0, 0, 0);     -- 0\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n\n    INSERT INTO tbl VALUES(200, 0, 0, 0);     -- 1\n    SELECT * FROM log;\n    UPDATE log SET a = 0;\n  }\n} $t232\nexecsql {\n  DROP TABLE tbl;\n  DROP TABLE log;\n}\nintegrity_check without_rowid4-3.3\n\n# Simple cascaded trigger\nexecsql {\n  CREATE TABLE tblA(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;\n  CREATE TABLE tblB(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;\n  CREATE TABLE tblC(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;\n\n  CREATE TRIGGER tr1 BEFORE INSERT ON tblA BEGIN\n    INSERT INTO tblB values(new.a, new.b);\n  END;\n\n  CREATE TRIGGER tr2 BEFORE INSERT ON tblB BEGIN\n    INSERT INTO tblC values(new.a, new.b);\n  END;\n}\ndo_test without_rowid4-4.1 {\n  execsql {\n    INSERT INTO tblA values(1, 2);\n    SELECT * FROM tblA;\n    SELECT * FROM tblB;\n    SELECT * FROM tblC;\n  }\n} {1 2 1 2 1 2}\nexecsql {\n  DROP TABLE tblA;\n  DROP TABLE tblB;\n  DROP TABLE tblC;\n}\n\n# Simple recursive trigger\nexecsql {\n  CREATE TABLE tbl(a, b, c, PRIMARY KEY(c,a,b)) WITHOUT rowid;\n  CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl \n    BEGIN\n      INSERT INTO tbl VALUES (new.a, new.b, new.c+1);\n    END;\n}\ndo_test without_rowid4-4.2 {\n  execsql {\n    INSERT INTO tbl VALUES (1, 2, 3);\n    select * from tbl;\n  }\n} {1 2 3 1 2 4}\nexecsql {\n  DROP TABLE tbl;\n}\n\n# 5.\nexecsql {\n  CREATE TABLE tbl(a, b, c, PRIMARY KEY(c,a,b)) WITHOUT rowid;\n  CREATE TRIGGER tbl_trig BEFORE INSERT ON tbl \n    BEGIN\n      INSERT INTO tbl VALUES (1, 2, 3);\n      INSERT INTO tbl VALUES (2, 2, 3);\n      UPDATE tbl set b = 10 WHERE a = 1;\n      DELETE FROM tbl WHERE a = 1;\n      DELETE FROM tbl;\n    END;\n}\ndo_test without_rowid4-5 {\n  execsql {\n    INSERT INTO tbl VALUES(100, 200, 300);\n  }\n  db changes\n} {1}\nexecsql {\n  DROP TABLE tbl;\n}\n\nifcapable conflict {\n  # Handling of ON CONFLICT by INSERT statements inside triggers\n  execsql {\n    CREATE TABLE tbl (a PRIMARY KEY, b, c) WITHOUT rowid;\n    CREATE TRIGGER ai_tbl AFTER INSERT ON tbl BEGIN\n      INSERT OR IGNORE INTO tbl values (new.a, 0, 0);\n    END;\n  }\n  do_test without_rowid4-6.1a {\n    execsql {\n      BEGIN;\n      INSERT INTO tbl values (1, 2, 3);\n      SELECT * from tbl;\n    }\n  } {1 2 3}\n  do_test without_rowid4-6.1b {\n    catchsql {\n      INSERT OR ABORT INTO tbl values (2, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.1c {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 3}\n  do_test without_rowid4-6.1d {\n    catchsql {\n      INSERT OR FAIL INTO tbl values (2, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.1e {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 3 2 2 3}\n  do_test without_rowid4-6.1f {\n    execsql {\n      INSERT OR REPLACE INTO tbl values (2, 2, 3);\n      SELECT * from tbl;\n    }\n  } {1 2 3 2 0 0}\n  do_test without_rowid4-6.1g {\n    catchsql {\n      INSERT OR ROLLBACK INTO tbl values (3, 2, 3);\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.1h {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {}\n  execsql {DELETE FROM tbl}\n  \n  \n  # Handling of ON CONFLICT by UPDATE statements inside triggers\n  execsql {\n    INSERT INTO tbl values (4, 2, 3);\n    INSERT INTO tbl values (6, 3, 4);\n    CREATE TRIGGER au_tbl AFTER UPDATE ON tbl BEGIN\n      UPDATE OR IGNORE tbl SET a = new.a, c = 10;\n    END;\n  }\n  do_test without_rowid4-6.2a {\n    execsql {\n      BEGIN;\n      UPDATE tbl SET a = 1 WHERE a = 4;\n      SELECT * from tbl;\n    }\n  } {1 2 10 6 3 4}\n  do_test without_rowid4-6.2b {\n    catchsql {\n      UPDATE OR ABORT tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.2c {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {1 2 10 6 3 4}\n  do_test without_rowid4-6.2d {\n    catchsql {\n      UPDATE OR FAIL tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.2e {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {4 2 10 6 3 4}\n  do_test without_rowid4-6.2f.1 {\n    execsql {\n      UPDATE OR REPLACE tbl SET a = 1 WHERE a = 4;\n      SELECT * from tbl;\n    }\n  } {1 3 10}\n  do_test without_rowid4-6.2f.2 {\n    execsql {\n      INSERT INTO tbl VALUES (2, 3, 4);\n      SELECT * FROM tbl;\n    }\n  } {1 3 10 2 3 4}\n  do_test without_rowid4-6.2g {\n    catchsql {\n      UPDATE OR ROLLBACK tbl SET a = 4 WHERE a = 1;\n    }\n  } {1 {UNIQUE constraint failed: tbl.a}}\n  do_test without_rowid4-6.2h {\n    execsql {\n      SELECT * from tbl;\n    }\n  } {4 2 3 6 3 4}\n  execsql {\n    DROP TABLE tbl;\n  }\n} ; # ifcapable conflict\n\n# 7. Triggers on views\nifcapable view {\n\ndo_test without_rowid4-7.1 {\n  execsql {\n  CREATE TABLE ab(a, b, PRIMARY KEY(a,b)) WITHOUT rowid;\n  CREATE TABLE cd(c, d, PRIMARY KEY(c,d)) WITHOUT rowid;\n  INSERT INTO ab VALUES (1, 2);\n  INSERT INTO ab VALUES (0, 0);\n  INSERT INTO cd VALUES (3, 4);\n\n  CREATE TABLE tlog(ii INTEGER PRIMARY KEY, \n      olda, oldb, oldc, oldd, newa, newb, newc, newd);\n\n  CREATE VIEW abcd AS SELECT a, b, c, d FROM ab, cd;\n\n  CREATE TRIGGER before_update INSTEAD OF UPDATE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);\n  END;\n  CREATE TRIGGER after_update INSTEAD OF UPDATE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, new.a, new.b, new.c, new.d);\n  END;\n\n  CREATE TRIGGER before_delete INSTEAD OF DELETE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, 0, 0, 0, 0);\n  END;\n  CREATE TRIGGER after_delete INSTEAD OF DELETE ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\told.a, old.b, old.c, old.d, 0, 0, 0, 0);\n  END;\n\n  CREATE TRIGGER before_insert INSTEAD OF INSERT ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\t0, 0, 0, 0, new.a, new.b, new.c, new.d);\n  END;\n   CREATE TRIGGER after_insert INSTEAD OF INSERT ON abcd BEGIN\n    INSERT INTO tlog VALUES(NULL, \n\t0, 0, 0, 0, new.a, new.b, new.c, new.d);\n   END;\n  }\n} {};\n\ndo_test without_rowid4-7.2 {\n  execsql {\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    DELETE FROM abcd WHERE a = 1;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    SELECT * FROM tlog;\n  }\n} [ list 1 1 2 3 4 100 25 3 4 \\\n         2 1 2 3 4 100 25 3 4 \\\n\t 3 1 2 3 4 0 0 0 0 \\\n\t 4 1 2 3 4 0 0 0 0 \\\n\t 5 0 0 0 0 10 20 30 40 \\\n\t 6 0 0 0 0 10 20 30 40 ]\n\ndo_test without_rowid4-7.3 {\n  execsql {\n    DELETE FROM tlog;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    DELETE FROM abcd WHERE a = 1;\n    SELECT * FROM tlog;\n  }\n} [ list \\\n   1 0 0 0 0 10 20 30 40 \\\n   2 0 0 0 0 10 20 30 40 \\\n   3 1 2 3 4 100 25 3 4 \\\n   4 1 2 3 4 100 25 3 4 \\\n   5 1 2 3 4 0 0 0 0 \\\n   6 1 2 3 4 0 0 0 0 \\\n]\ndo_test without_rowid4-7.4 {\n  execsql {\n    DELETE FROM tlog;\n    DELETE FROM abcd WHERE a = 1;\n    INSERT INTO abcd VALUES(10, 20, 30, 40);\n    UPDATE abcd SET a = 100, b = 5*5 WHERE a = 1;\n    SELECT * FROM tlog;\n  }\n} [ list \\\n   1 1 2 3 4 0 0 0 0 \\\n   2 1 2 3 4 0 0 0 0 \\\n   3 0 0 0 0 10 20 30 40 \\\n   4 0 0 0 0 10 20 30 40 \\\n   5 1 2 3 4 100 25 3 4 \\\n   6 1 2 3 4 100 25 3 4 \\\n]\n\ndo_test without_rowid4-8.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c, PRIMARY KEY(a,b,c)) WITHOUT rowid;\n    INSERT INTO t1 VALUES(1,2,3);\n    CREATE VIEW v1 AS\n      SELECT a+b AS x, b+c AS y, a+c AS z FROM t1;\n    SELECT * FROM v1;\n  }\n} {3 5 4}\ndo_test without_rowid4-8.2 {\n  execsql {\n    CREATE TABLE v1log(a,b,c,d,e,f);\n    CREATE TRIGGER r1 INSTEAD OF DELETE ON v1 BEGIN\n      INSERT INTO v1log VALUES(OLD.x,NULL,OLD.y,NULL,OLD.z,NULL);\n    END;\n    DELETE FROM v1 WHERE x=1;\n    SELECT * FROM v1log;\n  }\n} {}\ndo_test without_rowid4-8.3 {\n  execsql {\n    DELETE FROM v1 WHERE x=3;\n    SELECT * FROM v1log;\n  }\n} {3 {} 5 {} 4 {}}\ndo_test without_rowid4-8.4 {\n  execsql {\n    INSERT INTO t1 VALUES(4,5,6);\n    DELETE FROM v1log;\n    DELETE FROM v1 WHERE y=11;\n    SELECT * FROM v1log;\n  }\n} {9 {} 11 {} 10 {}}\ndo_test without_rowid4-8.5 {\n  execsql {\n    CREATE TRIGGER r2 INSTEAD OF INSERT ON v1 BEGIN\n      INSERT INTO v1log VALUES(NULL,NEW.x,NULL,NEW.y,NULL,NEW.z);\n    END;\n    DELETE FROM v1log;\n    INSERT INTO v1 VALUES(1,2,3);\n    SELECT * FROM v1log;\n  }\n} {{} 1 {} 2 {} 3}\ndo_test without_rowid4-8.6 {\n  execsql {\n    CREATE TRIGGER r3 INSTEAD OF UPDATE ON v1 BEGIN\n      INSERT INTO v1log VALUES(OLD.x,NEW.x,OLD.y,NEW.y,OLD.z,NEW.z);\n    END;\n    DELETE FROM v1log;\n    UPDATE v1 SET x=x+100, y=y+200, z=z+300;\n    SELECT * FROM v1log;\n  }\n} {3 103 5 205 4 304 9 109 11 211 10 310}\n\n# At one point the following was causing a segfault.\ndo_test without_rowid4-9.1 {\n  execsql {\n    CREATE TABLE t3(a TEXT, b TEXT);\n    CREATE VIEW v3 AS SELECT t3.a FROM t3;\n    CREATE TRIGGER trig1 INSTEAD OF DELETE ON v3 BEGIN\n      SELECT 1;\n    END;\n    DELETE FROM v3 WHERE a = 1;\n  }\n} {}\n\n} ;# ifcapable view\n\nintegrity_check without_rowid4-9.9\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid5.test",
    "content": "# 2013-11-26\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Requirements testing for WITHOUT ROWID tables.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\n\n# EVIDENCE-OF: R-36924-43758 By default, every row in SQLite has a\n# special column, usually called the \"rowid\", that uniquely identifies\n# that row within the table.\n#\n# EVIDENCE-OF: R-32341-39358 However if the phrase \"WITHOUT ROWID\" is\n# added to the end of a CREATE TABLE statement, then the special \"rowid\"\n# column is omitted.\n#\ndo_execsql_test without_rowid5-1.1 {\n  CREATE TABLE t1(a PRIMARY KEY,b,c);\n  CREATE TABLE t1w(a PRIMARY KEY,b,c) WITHOUT ROWID;\n  INSERT INTO t1 VALUES(1565,681,1148),(1429,1190,1619),(425,358,1306);\n  INSERT INTO t1w SELECT a,b,c FROM t1;\n  SELECT rowid, _rowid_, oid FROM t1 ORDER BY a DESC;\n} {1 1 1 2 2 2 3 3 3}\ndo_catchsql_test without_rowid5-1.2 {\n  SELECT rowid FROM t1w;\n} {1 {no such column: rowid}}\ndo_catchsql_test without_rowid5-1.3 {\n  SELECT _rowid_ FROM t1w;\n} {1 {no such column: _rowid_}}\ndo_catchsql_test without_rowid5-1.4 {\n  SELECT oid FROM t1w;\n} {1 {no such column: oid}}\n\n# EVIDENCE-OF: R-00217-01605 To create a WITHOUT ROWID table, simply add\n# the keywords \"WITHOUT ROWID\" to the end of the CREATE TABLE statement.\n# For example: CREATE TABLE IF NOT EXISTS wordcount( word TEXT PRIMARY\n# KEY, cnt INTEGER ) WITHOUT ROWID;\n#\ndo_execsql_test without_rowid5-2.1 {\n  CREATE TABLE IF NOT EXISTS wordcount(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) WITHOUT ROWID;\n  INSERT INTO wordcount VALUES('one',1);\n} {}\ndo_catchsql_test without_rowid5-2.2 {\n  SELECT rowid FROM wordcount;\n} {1 {no such column: rowid}}\n\n# EVIDENCE-OF: R-24770-17719 As with all SQL syntax, the case of the\n# keywords does not matter. One can write \"WITHOUT rowid\" or \"without\n# rowid\" or \"WiThOuT rOwId\" and it will mean the same thing.\n#\ndo_execsql_test without_rowid5-2.3 {\n  CREATE TABLE IF NOT EXISTS wordcount_b(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) WITHOUT rowid;\n  INSERT INTO wordcount_b VALUES('one',1);\n} {}\ndo_catchsql_test without_rowid5-2.4 {\n  SELECT rowid FROM wordcount_b;\n} {1 {no such column: rowid}}\ndo_execsql_test without_rowid5-2.5 {\n  CREATE TABLE IF NOT EXISTS wordcount_c(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) without rowid;\n  INSERT INTO wordcount_c VALUES('one',1);\n} {}\ndo_catchsql_test without_rowid5-2.6 {\n  SELECT rowid FROM wordcount_c;\n} {1 {no such column: rowid}}\ndo_execsql_test without_rowid5-2.7 {\n  CREATE TABLE IF NOT EXISTS wordcount_d(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) WITHOUT rowid;\n  INSERT INTO wordcount_d VALUES('one',1);\n} {}\ndo_catchsql_test without_rowid5-2.8 {\n  SELECT rowid FROM wordcount_d;\n} {1 {no such column: rowid}}\n\n# EVIDENCE-OF: R-01418-51310 However, only \"rowid\" works as the keyword\n# in the CREATE TABLE statement.\n#\ndo_catchsql_test without_rowid5-3.1 {\n  CREATE TABLE IF NOT EXISTS error1(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) WITHOUT _rowid_;\n} {1 {unknown table option: _rowid_}}  \ndo_catchsql_test without_rowid5-3.2 {\n  CREATE TABLE IF NOT EXISTS error2(\n    word TEXT PRIMARY KEY,\n    cnt INTEGER\n  ) WITHOUT oid;\n} {1 {unknown table option: oid}}  \n\n# EVIDENCE-OF: R-58033-17334 An error is raised if a CREATE TABLE\n# statement with the WITHOUT ROWID clause lacks a PRIMARY KEY.\n#\n# EVIDENCE-OF: R-63443-09418 Every WITHOUT ROWID table must have a\n# PRIMARY KEY.\n#\n# EVIDENCE-OF: R-27966-31616 An attempt to create a WITHOUT ROWID table\n# without a PRIMARY KEY results in an error.\n#\ndo_catchsql_test without_rowid5-4.1 {\n  CREATE TABLE IF NOT EXISTS error3(\n    word TEXT UNIQUE,\n    cnt INTEGER\n  ) WITHOUT ROWID;\n} {1 {PRIMARY KEY missing on table error3}}\n\n# EVIDENCE-OF: R-48230-36247 The special behaviors associated \"INTEGER\n# PRIMARY KEY\" do not apply on WITHOUT ROWID tables.\n#\ndo_execsql_test without_rowid5-5.1 {\n  CREATE TABLE ipk(key INTEGER PRIMARY KEY, val TEXT) WITHOUT ROWID;\n  INSERT INTO ipk VALUES('rival','bonus'); -- ok to insert non-integer key\n  SELECT * FROM ipk;\n} {rival bonus}\ndo_catchsql_test without_rowid5-5.2a {\n  BEGIN;\n  INSERT INTO ipk VALUES(NULL,'sample'); -- no automatic generation of keys\n} {1 {NOT NULL constraint failed: ipk.key}}\ndo_execsql_test without_rowid5-5.2b {\n  ROLLBACK;\n} {}\n\n# EVIDENCE-OF: R-33142-02092 AUTOINCREMENT does not work on WITHOUT\n# ROWID tables.\n#\n# EVIDENCE-OF: R-53084-07740 An error is raised if the \"AUTOINCREMENT\"\n# keyword is used in the CREATE TABLE statement for a WITHOUT ROWID\n# table.\n#\ndo_catchsql_test without_rowid5-5.3 {\n  CREATE TABLE ipk2(key INTEGER PRIMARY KEY AUTOINCREMENT, val TEXT)WITHOUT ROWID;\n} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}}\n\n# EVIDENCE-OF: R-27831-00579 NOT NULL is enforced on every column of the\n# PRIMARY KEY in a WITHOUT ROWID table.\n#\n# EVIDENCE-OF: R-29781-51289 So, ordinary rowid tables in SQLite violate\n# the SQL standard and allow NULL values in PRIMARY KEY fields.\n#\n# EVIDENCE-OF: R-27472-62612 But WITHOUT ROWID tables do follow the\n# standard and will throw an error on any attempt to insert a NULL into\n# a PRIMARY KEY column.\n#\ndo_execsql_test without_rowid5-5.4 {\n  CREATE TABLE nn(a, b, c, d, e, PRIMARY KEY(c,a,e));\n  CREATE TABLE nnw(a, b, c, d, e, PRIMARY KEY(c,a,e)) WITHOUT ROWID;\n  INSERT INTO nn VALUES(1,2,3,4,5);\n  INSERT INTO nnw VALUES(1,2,3,4,5);\n} {}\ndo_execsql_test without_rowid5-5.5 {\n  INSERT INTO nn VALUES(NULL, 3,4,5,6);\n  INSERT INTO nn VALUES(3,4,NULL,7,8);\n  INSERT INTO nn VALUES(4,5,6,7,NULL);\n  SELECT count(*) FROM nn;\n} {4}\ndo_catchsql_test without_rowid5-5.6 {\n  INSERT INTO nnw VALUES(NULL, 3,4,5,6);\n} {1 {NOT NULL constraint failed: nnw.a}}\ndo_catchsql_test without_rowid5-5.7 {\n  INSERT INTO nnw VALUES(3,4,NULL,7,8)\n} {1 {NOT NULL constraint failed: nnw.c}}\ndo_catchsql_test without_rowid5-5.8 {\n  INSERT INTO nnw VALUES(4,5,6,7,NULL)\n} {1 {NOT NULL constraint failed: nnw.e}}\ndo_execsql_test without_rowid5-5.9 {\n  SELECT count(*) FROM nnw;\n} {1}\n\n# EVIDENCE-OF: R-12643-30541 The incremental blob I/O mechanism does not\n# work for WITHOUT ROWID tables.\n#\n# EVIDENCE-OF: R-40134-30296 Table zTable is a WITHOUT ROWID table\n#\ndo_execsql_test without_rowid5-6.1 {\n  CREATE TABLE b1(a INTEGER PRIMARY KEY, b BLOB) WITHOUT ROWID;\n  INSERT INTO b1 VALUES(1,x'0102030405060708090a0b0c0d0e0f');\n} {}\ndo_test without_rowid5-6.2 {\n  set rc [catch {db incrblob b1 b 1} msg]\n  lappend rc $msg\n} {1 {cannot open table without rowid: b1}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/without_rowid6.test",
    "content": "# 2014-12-28\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Verify that WITHOUT ROWID tables work correctly when the PRIMARY KEY\n# has redundant columns.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\n\ndo_execsql_test without_rowid6-100 {\n  CREATE TABLE t1(a,b,c,d,e, PRIMARY KEY(a,b,c,a,b,c,d,a,b,c)) WITHOUT ROWID;\n  CREATE INDEX t1a ON t1(b, b);\n  WITH RECURSIVE\n    c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<1000)\n  INSERT INTO t1(a,b,c,d,e) SELECT i, i+1000, printf('x%dy',i), 0, 0 FROM c;\n  ANALYZE;\n} {}\ndo_execsql_test without_rowid6-110 {\n  SELECT c FROM t1 WHERE a=123;\n} {x123y}\ndo_execsql_test without_rowid6-120 {\n  SELECT c FROM t1 WHERE b=1123;\n} {x123y}\ndo_execsql_test without_rowid6-130 {\n  SELECT c FROM t1 ORDER BY a DESC LIMIT 5;\n} {x1000y x999y x998y x997y x996y}\ndo_execsql_test without_rowid6-140 {\n  SELECT c FROM t1 ORDER BY b LIMIT 5;\n} {x1y x2y x3y x4y x5y}\n\n# Column t1.b starts out as a unique index, but that index is\n# subsequently converted into a PRIMARY KEY.\n#\ndo_execsql_test without_rowid6-200 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\n    a UNIQUE,\n    b UNIQUE,\n    c UNIQUE,\n    PRIMARY KEY(b)\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {4 1}\ndo_execsql_test without_rowid6-210 {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {/SEARCH TABLE t1 USING PRIMARY KEY .b>../}\ndo_execsql_test without_rowid6-220 {\n  PRAGMA index_list(t1);\n} {/sqlite_autoindex_t1_2 1 pk/}\n\ndo_execsql_test without_rowid6-300 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\n    a UNIQUE,\n    b PRIMARY KEY,\n    c UNIQUE,\n    UNIQUE(b)\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {4 1}\ndo_execsql_test without_rowid6-310 {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {/SEARCH TABLE t1 USING PRIMARY KEY .b>../}\ndo_execsql_test without_rowid6-320 {\n  PRAGMA index_list(t1);\n} {/sqlite_autoindex_t1_2 1 pk/}\n\ndo_execsql_test without_rowid6-400 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(\n    a UNIQUE,\n    b UNIQUE PRIMARY KEY,\n    c UNIQUE\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {4 1}\ndo_execsql_test without_rowid6-410 {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {/SEARCH TABLE t1 USING PRIMARY KEY .b>../}\ndo_execsql_test without_rowid6-420 {\n  PRAGMA index_list(t1);\n} {/sqlite_autoindex_t1_2 1 pk/}\n\ndo_execsql_test without_rowid6-500 {\n  DROP TABLE IF EXISTS t1;\n  CREATE TABLE t1(a,b,c,\n    UNIQUE(b,c),\n    PRIMARY KEY(b,c)\n  ) WITHOUT ROWID;\n  INSERT INTO t1(a,b,c) VALUES(1,8,3),(4,5,6),(7,2,9);\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {4 1}\ndo_execsql_test without_rowid6-510 {\n  EXPLAIN QUERY PLAN\n  SELECT a FROM t1 WHERE b>3 ORDER BY b;\n} {/SEARCH TABLE t1 USING PRIMARY KEY .b>../}\ndo_execsql_test without_rowid6-520 {\n  PRAGMA index_list(t1);\n} {/sqlite_autoindex_t1_1 1 pk/}\n\ndo_catchsql_test without_rowid6-600 {\n  CREATE TABLE t6(a,b,c,PRIMARY KEY(a,rowid,b))WITHOUT ROWID;\n} {1 {no such column: rowid}}\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/wordcount.c",
    "content": "/*\n** This C program extracts all \"words\" from an input document and adds them\n** to an SQLite database.  A \"word\" is any contiguous sequence of alphabetic\n** characters.  All digits, punctuation, and whitespace characters are \n** word separators.  The database stores a single entry for each distinct\n** word together with a count of the number of occurrences of that word.\n** A fresh database is created automatically on each run.\n**\n**     wordcount DATABASE INPUTFILE\n**\n** The INPUTFILE name can be omitted, in which case input it taken from\n** standard input.\n**\n** Option:\n**\n**\n** Modes:\n**\n** Insert mode means:\n**    (1) INSERT OR IGNORE INTO wordcount VALUES($new,1)\n**    (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new -- if (1) is a noop\n**\n** Update mode means:\n**    (1) INSERT OR IGNORE INTO wordcount VALUES($new,0)\n**    (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new\n**\n** Replace mode means:\n**    (1) REPLACE INTO wordcount\n**        VALUES($new,ifnull((SELECT cnt FROM wordcount WHERE word=$new),0)+1);\n**\n** Select mode means:\n**    (1) SELECT 1 FROM wordcount WHERE word=$new\n**    (2) INSERT INTO wordcount VALUES($new,1) -- if (1) returns nothing\n**    (3) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new  --if (1) return TRUE\n**\n** Delete mode means:\n**    (1) DELETE FROM wordcount WHERE word=$new\n**\n** Query mode means:\n**    (1) SELECT cnt FROM wordcount WHERE word=$new\n**\n** Note that delete mode and query mode are only useful for preexisting\n** databases.  The wordcount table is created using IF NOT EXISTS so this\n** utility can be run multiple times on the same database file.  The\n** --without-rowid, --nocase, and --pagesize parameters are only effective\n** when creating a new database and are harmless no-ops on preexisting\n** databases.\n**\n******************************************************************************\n**\n** Compile as follows:\n**\n**    gcc -I. wordcount.c sqlite3.c -ldl -lpthreads\n**\n** Or:\n**\n**    gcc -I. -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \\\n**        wordcount.c sqlite3.c\n*/\n#include <stdio.h>\n#include <string.h>\n#include <ctype.h>\n#include <stdlib.h>\n#include <stdarg.h>\n#include \"sqlite3.h\"\n#ifndef _WIN32\n# include <unistd.h>\n#else\n# include <io.h>\n#endif\n#define ISALPHA(X) isalpha((unsigned char)(X))\n\nconst char zHelp[] = \n\"Usage: wordcount [OPTIONS] DATABASE [INPUT]\\n\"\n\" --all                Repeat the test for all test modes\\n\"\n\" --cachesize NNN      Use a cache size of NNN\\n\"\n\" --commit NNN         Commit after every NNN operations\\n\"\n\" --delete             Use DELETE mode\\n\"\n\" --insert             Use INSERT mode (the default)\\n\"\n\" --journal MMMM       Use PRAGMA journal_mode=MMMM\\n\"\n\" --nocase             Add the NOCASE collating sequence to the words.\\n\"\n\" --nosync             Use PRAGMA synchronous=OFF\\n\"\n\" --pagesize NNN       Use a page size of NNN\\n\"\n\" --query              Use QUERY mode\\n\"\n\" --replace            Use REPLACE mode\\n\"\n\" --select             Use SELECT mode\\n\"\n\" --stats              Show sqlite3_status() results at the end.\\n\"\n\" --summary            Show summary information on the collected data.\\n\"\n\" --tag NAME           Tag all output using NAME.  Use only stdout.\\n\"\n\" --timer              Time the operation of this program\\n\"\n\" --trace              Enable sqlite3_trace() output.\\n\"\n\" --update             Use UPDATE mode\\n\"\n\" --without-rowid      Use a WITHOUT ROWID table to store the words.\\n\"\n;\n\n/* Output tag */\nchar *zTag = \"--\";\n\n/* Return the current wall-clock time */\nstatic sqlite3_int64 realTime(void){\n  static sqlite3_vfs *clockVfs = 0;\n  sqlite3_int64 t;\n  if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);\n  if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){\n    clockVfs->xCurrentTimeInt64(clockVfs, &t);\n  }else{\n    double r;\n    clockVfs->xCurrentTime(clockVfs, &r);\n    t = (sqlite3_int64)(r*86400000.0);\n  }\n  return t;\n}\n\n/* Print an error message and exit */\nstatic void fatal_error(const char *zMsg, ...){\n  va_list ap;\n  va_start(ap, zMsg);\n  vfprintf(stderr, zMsg, ap);\n  va_end(ap);\n  exit(1);\n}\n\n/* Print a usage message and quit */\nstatic void usage(void){\n  printf(\"%s\",zHelp);\n  exit(0);\n}\n\n/* The sqlite3_trace() callback function */\nstatic void traceCallback(void *NotUsed, const char *zSql){\n  printf(\"%s;\\n\", zSql);\n}\n\n/* An sqlite3_exec() callback that prints results on standard output,\n** each column separated by a single space. */\nstatic int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){\n  int i;\n  printf(\"%s\", zTag);\n  for(i=0; i<nArg; i++){\n    printf(\" %s\", azArg[i] ? azArg[i] : \"(null)\");\n  }\n  printf(\"\\n\");\n  return 0;\n}\n\n\n/*\n** Add one character to a hash\n*/\nstatic void addCharToHash(unsigned int *a, unsigned char x){\n  if( a[0]<4 ){\n    a[1] = (a[1]<<8) | x;\n    a[0]++;\n  }else{\n    a[2] = (a[2]<<8) | x;\n    a[0]++;\n    if( a[0]==8 ){\n      a[3] += a[1] + a[4];\n      a[4] += a[2] + a[3];\n      a[0] = a[1] = a[2] = 0;\n    }\n  }    \n}\n\n/*\n** Compute the final hash value.\n*/\nstatic void finalHash(unsigned int *a, char *z){\n  a[3] += a[1] + a[4] + a[0];\n  a[4] += a[2] + a[3];\n  sqlite3_snprintf(17, z, \"%08x%08x\", a[3], a[4]);\n}\n\n\n/*\n** Implementation of a checksum() aggregate SQL function\n*/\nstatic void checksumStep(\n  sqlite3_context *context,\n  int argc,\n  sqlite3_value **argv\n){\n  const unsigned char *zVal;\n  int nVal, i, j;\n  unsigned int *a;\n  a = (unsigned*)sqlite3_aggregate_context(context, sizeof(unsigned int)*5);\n\n  if( a ){\n    for(i=0; i<argc; i++){\n      nVal = sqlite3_value_bytes(argv[i]);\n      zVal = (const unsigned char*)sqlite3_value_text(argv[i]);\n      if( zVal ) for(j=0; j<nVal; j++) addCharToHash(a, zVal[j]);\n      addCharToHash(a, '|');\n    }\n    addCharToHash(a, '\\n');\n  }\n}\nstatic void checksumFinalize(sqlite3_context *context){\n  unsigned int *a;\n  char zResult[24];\n  a = sqlite3_aggregate_context(context, 0);\n  if( a ){\n    finalHash(a, zResult);\n    sqlite3_result_text(context, zResult, -1, SQLITE_TRANSIENT);\n  }\n}\n\n/* Define operating modes */\n#define MODE_INSERT     0\n#define MODE_REPLACE    1\n#define MODE_SELECT     2\n#define MODE_UPDATE     3\n#define MODE_DELETE     4\n#define MODE_QUERY      5\n#define MODE_COUNT      6\n#define MODE_ALL      (-1)\n\n/* Mode names */\nstatic const char *azMode[] = {\n  \"--insert\",\n  \"--replace\",\n  \"--select\",\n  \"--update\",\n  \"--delete\",\n  \"--query\"\n};\n\n/*\n** Determine if another iteration of the test is required.  Return true\n** if so.  Return zero if all iterations have finished.\n*/\nstatic int allLoop(\n  int iMode,                /* The selected test mode */\n  int *piLoopCnt,           /* Iteration loop counter */\n  int *piMode2,             /* The test mode to use on the next iteration */\n  int *pUseWithoutRowid     /* Whether or not to use --without-rowid */\n){\n  int i;\n  if( iMode!=MODE_ALL ){\n    if( *piLoopCnt ) return 0;\n    *piMode2 = iMode;\n    *piLoopCnt = 1;\n    return 1;\n  }\n  if( (*piLoopCnt)>=MODE_COUNT*2 ) return 0;\n  i = (*piLoopCnt)++;\n  *pUseWithoutRowid = i&1;\n  *piMode2 = i>>1;\n  return 1;\n}\n\nint main(int argc, char **argv){\n  const char *zFileToRead = 0;  /* Input file.  NULL for stdin */\n  const char *zDbName = 0;      /* Name of the database file to create */\n  int useWithoutRowid = 0;      /* True for --without-rowid */\n  int iMode = MODE_INSERT;      /* One of MODE_xxxxx */\n  int iMode2;                   /* Mode to use for current --all iteration */\n  int iLoopCnt = 0;             /* Which iteration when running --all */\n  int useNocase = 0;            /* True for --nocase */\n  int doTrace = 0;              /* True for --trace */\n  int showStats = 0;            /* True for --stats */\n  int showSummary = 0;          /* True for --summary */\n  int showTimer = 0;            /* True for --timer */\n  int cacheSize = 0;            /* Desired cache size.  0 means default */\n  int pageSize = 0;             /* Desired page size.  0 means default */\n  int commitInterval = 0;       /* How often to commit.  0 means never */\n  int noSync = 0;               /* True for --nosync */\n  const char *zJMode = 0;       /* Journal mode */\n  int nOp = 0;                  /* Operation counter */\n  int i, j;                     /* Loop counters */\n  sqlite3 *db;                  /* The SQLite database connection */\n  char *zSql;                   /* Constructed SQL statement */\n  sqlite3_stmt *pInsert = 0;    /* The INSERT statement */\n  sqlite3_stmt *pUpdate = 0;    /* The UPDATE statement */\n  sqlite3_stmt *pSelect = 0;    /* The SELECT statement */\n  sqlite3_stmt *pDelete = 0;    /* The DELETE statement */\n  FILE *in;                     /* The open input file */\n  int rc;                       /* Return code from an SQLite interface */\n  int iCur, iHiwtr;             /* Statistics values, current and \"highwater\" */\n  FILE *pTimer = stderr;        /* Output channel for the timer */\n  sqlite3_int64 sumCnt = 0;     /* Sum in QUERY mode */\n  sqlite3_int64 startTime;      /* Time of start */\n  sqlite3_int64 totalTime = 0;  /* Total time */\n  char zInput[2000];            /* A single line of input */\n\n  /* Process command-line arguments */\n  for(i=1; i<argc; i++){\n    const char *z = argv[i];\n    if( z[0]=='-' ){\n      do{ z++; }while( z[0]=='-' );\n      if( strcmp(z,\"without-rowid\")==0 ){\n        useWithoutRowid = 1;\n      }else if( strcmp(z,\"replace\")==0 ){\n        iMode = MODE_REPLACE;\n      }else if( strcmp(z,\"select\")==0 ){\n        iMode = MODE_SELECT;\n      }else if( strcmp(z,\"insert\")==0 ){\n        iMode = MODE_INSERT;\n      }else if( strcmp(z,\"update\")==0 ){\n        iMode = MODE_UPDATE;\n      }else if( strcmp(z,\"delete\")==0 ){\n        iMode = MODE_DELETE;\n      }else if( strcmp(z,\"query\")==0 ){\n        iMode = MODE_QUERY;\n      }else if( strcmp(z,\"all\")==0 ){\n        iMode = MODE_ALL;\n        showTimer = -99;\n      }else if( strcmp(z,\"nocase\")==0 ){\n        useNocase = 1;\n      }else if( strcmp(z,\"trace\")==0 ){\n        doTrace = 1;\n      }else if( strcmp(z,\"nosync\")==0 ){\n        noSync = 1;\n      }else if( strcmp(z,\"stats\")==0 ){\n        showStats = 1;\n      }else if( strcmp(z,\"summary\")==0 ){\n        showSummary = 1;\n      }else if( strcmp(z,\"timer\")==0 ){\n        showTimer = i;\n      }else if( strcmp(z,\"cachesize\")==0 && i<argc-1 ){\n        i++;\n        cacheSize = atoi(argv[i]);\n      }else if( strcmp(z,\"pagesize\")==0 && i<argc-1 ){\n        i++;\n        pageSize = atoi(argv[i]);\n      }else if( strcmp(z,\"commit\")==0 && i<argc-1 ){\n        i++;\n        commitInterval = atoi(argv[i]);\n      }else if( strcmp(z,\"journal\")==0 && i<argc-1 ){\n        zJMode = argv[++i];\n      }else if( strcmp(z,\"tag\")==0 && i<argc-1 ){\n        zTag = argv[++i];\n        pTimer = stdout;\n      }else if( strcmp(z, \"help\")==0 || strcmp(z,\"?\")==0 ){\n        usage();\n      }else{\n        fatal_error(\"unknown option: \\\"%s\\\"\\n\"\n                    \"Use --help for a list of options\\n\",\n                    argv[i]);\n      }\n    }else if( zDbName==0 ){\n      zDbName = argv[i];\n    }else if( zFileToRead==0 ){\n      zFileToRead = argv[i];\n    }else{\n      fatal_error(\"surplus argument: \\\"%s\\\"\\n\", argv[i]);\n    }\n  }\n  if( zDbName==0 ){\n    usage();\n  }\n  startTime = realTime();\n\n  /* Open the database and the input file */\n  if( zDbName[0] && strcmp(zDbName,\":memory:\")!=0 ){\n    unlink(zDbName);\n  }\n  if( sqlite3_open(zDbName, &db) ){\n    fatal_error(\"Cannot open database file: %s\\n\", zDbName);\n  }\n  if( zFileToRead ){\n    in = fopen(zFileToRead, \"rb\");\n    if( in==0 ){\n      fatal_error(\"Could not open input file \\\"%s\\\"\\n\", zFileToRead);\n    }\n  }else{\n    if( iMode==MODE_ALL ){\n      fatal_error(\"The --all mode cannot be used with stdin\\n\");\n    }\n    in = stdin;\n  }\n\n  /* Set database connection options */\n  if( doTrace ) sqlite3_trace(db, traceCallback, 0);\n  if( pageSize ){\n    zSql = sqlite3_mprintf(\"PRAGMA page_size=%d\", pageSize);\n    sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  if( cacheSize ){\n    zSql = sqlite3_mprintf(\"PRAGMA cache_size=%d\", cacheSize);\n    sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n  if( noSync ) sqlite3_exec(db, \"PRAGMA synchronous=OFF\", 0, 0, 0);\n  if( zJMode ){\n    zSql = sqlite3_mprintf(\"PRAGMA journal_mode=%s\", zJMode);\n    sqlite3_exec(db, zSql, 0, 0, 0);\n    sqlite3_free(zSql);\n  }\n\n  iLoopCnt = 0;\n  while( allLoop(iMode, &iLoopCnt, &iMode2, &useWithoutRowid) ){\n    /* Delete prior content in --all mode */\n    if( iMode==MODE_ALL ){\n      if( sqlite3_exec(db, \"DROP TABLE IF EXISTS wordcount; VACUUM;\",0,0,0) ){\n        fatal_error(\"Could not clean up prior iteration\\n\");\n      }\n      startTime = realTime();\n      rewind(in);\n    }\n \n    /* Construct the \"wordcount\" table into which to put the words */\n    if( sqlite3_exec(db, \"BEGIN IMMEDIATE\", 0, 0, 0) ){\n      fatal_error(\"Could not start a transaction\\n\");\n    }\n    zSql = sqlite3_mprintf(\n       \"CREATE TABLE IF NOT EXISTS wordcount(\\n\"\n       \"  word TEXT PRIMARY KEY COLLATE %s,\\n\"\n       \"  cnt INTEGER\\n\"\n       \")%s\",\n       useNocase ? \"nocase\" : \"binary\",\n       useWithoutRowid ? \" WITHOUT ROWID\" : \"\"\n    );\n    if( zSql==0 ) fatal_error(\"out of memory\\n\");\n    rc = sqlite3_exec(db, zSql, 0, 0, 0);\n    if( rc ) fatal_error(\"Could not create the wordcount table: %s.\\n\",\n                         sqlite3_errmsg(db));\n    sqlite3_free(zSql);\n  \n    /* Prepare SQL statements that will be needed */\n    if( iMode2==MODE_QUERY ){\n      rc = sqlite3_prepare_v2(db,\n            \"SELECT cnt FROM wordcount WHERE word=?1\",\n            -1, &pSelect, 0);\n      if( rc ) fatal_error(\"Could not prepare the SELECT statement: %s\\n\",\n                            sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_SELECT ){\n      rc = sqlite3_prepare_v2(db,\n            \"SELECT 1 FROM wordcount WHERE word=?1\",\n            -1, &pSelect, 0);\n      if( rc ) fatal_error(\"Could not prepare the SELECT statement: %s\\n\",\n                            sqlite3_errmsg(db));\n      rc = sqlite3_prepare_v2(db,\n            \"INSERT INTO wordcount(word,cnt) VALUES(?1,1)\",\n            -1, &pInsert, 0);\n      if( rc ) fatal_error(\"Could not prepare the INSERT statement: %s\\n\",\n                           sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_SELECT || iMode2==MODE_UPDATE || iMode2==MODE_INSERT ){\n      rc = sqlite3_prepare_v2(db,\n            \"UPDATE wordcount SET cnt=cnt+1 WHERE word=?1\",\n            -1, &pUpdate, 0);\n      if( rc ) fatal_error(\"Could not prepare the UPDATE statement: %s\\n\",\n                           sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_INSERT ){\n      rc = sqlite3_prepare_v2(db,\n            \"INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,1)\",\n            -1, &pInsert, 0);\n      if( rc ) fatal_error(\"Could not prepare the INSERT statement: %s\\n\",\n                           sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_UPDATE ){\n      rc = sqlite3_prepare_v2(db,\n            \"INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,0)\",\n            -1, &pInsert, 0);\n      if( rc ) fatal_error(\"Could not prepare the INSERT statement: %s\\n\",\n                           sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_REPLACE ){\n      rc = sqlite3_prepare_v2(db,\n          \"REPLACE INTO wordcount(word,cnt)\"\n          \"VALUES(?1,coalesce((SELECT cnt FROM wordcount WHERE word=?1),0)+1)\",\n          -1, &pInsert, 0);\n      if( rc ) fatal_error(\"Could not prepare the REPLACE statement: %s\\n\",\n                            sqlite3_errmsg(db));\n    }\n    if( iMode2==MODE_DELETE ){\n      rc = sqlite3_prepare_v2(db,\n            \"DELETE FROM wordcount WHERE word=?1\",\n            -1, &pDelete, 0);\n      if( rc ) fatal_error(\"Could not prepare the DELETE statement: %s\\n\",\n                           sqlite3_errmsg(db));\n    }\n  \n    /* Process the input file */\n    while( fgets(zInput, sizeof(zInput), in) ){\n      for(i=0; zInput[i]; i++){\n        if( !ISALPHA(zInput[i]) ) continue;\n        for(j=i+1; ISALPHA(zInput[j]); j++){}\n  \n        /* Found a new word at zInput[i] that is j-i bytes long. \n        ** Process it into the wordcount table.  */\n        if( iMode2==MODE_DELETE ){\n          sqlite3_bind_text(pDelete, 1, zInput+i, j-i, SQLITE_STATIC);\n          if( sqlite3_step(pDelete)!=SQLITE_DONE ){\n            fatal_error(\"DELETE failed: %s\\n\", sqlite3_errmsg(db));\n          }\n          sqlite3_reset(pDelete);\n        }else if( iMode2==MODE_SELECT ){\n          sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);\n          rc = sqlite3_step(pSelect);\n          sqlite3_reset(pSelect);\n          if( rc==SQLITE_ROW ){\n            sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);\n            if( sqlite3_step(pUpdate)!=SQLITE_DONE ){\n              fatal_error(\"UPDATE failed: %s\\n\", sqlite3_errmsg(db));\n            }\n            sqlite3_reset(pUpdate);\n          }else if( rc==SQLITE_DONE ){\n            sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);\n            if( sqlite3_step(pInsert)!=SQLITE_DONE ){\n              fatal_error(\"Insert failed: %s\\n\", sqlite3_errmsg(db));\n            }\n            sqlite3_reset(pInsert);\n          }else{\n            fatal_error(\"SELECT failed: %s\\n\", sqlite3_errmsg(db));\n          }\n        }else if( iMode2==MODE_QUERY ){\n          sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);\n          if( sqlite3_step(pSelect)==SQLITE_ROW ){\n            sumCnt += sqlite3_column_int64(pSelect, 0);\n          }\n          sqlite3_reset(pSelect);\n        }else{\n          sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);\n          if( sqlite3_step(pInsert)!=SQLITE_DONE ){\n            fatal_error(\"INSERT failed: %s\\n\", sqlite3_errmsg(db));\n          }\n          sqlite3_reset(pInsert);\n          if( iMode2==MODE_UPDATE\n           || (iMode2==MODE_INSERT && sqlite3_changes(db)==0)\n          ){\n            sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);\n            if( sqlite3_step(pUpdate)!=SQLITE_DONE ){\n              fatal_error(\"UPDATE failed: %s\\n\", sqlite3_errmsg(db));\n            }\n            sqlite3_reset(pUpdate);\n          }\n        }\n        i = j-1;\n  \n        /* Increment the operation counter.  Do a COMMIT if it is time. */\n        nOp++;\n        if( commitInterval>0 && (nOp%commitInterval)==0 ){\n          sqlite3_exec(db, \"COMMIT; BEGIN IMMEDIATE\", 0, 0, 0);\n        }\n      }\n    }\n    sqlite3_exec(db, \"COMMIT\", 0, 0, 0);\n    sqlite3_finalize(pInsert);  pInsert = 0;\n    sqlite3_finalize(pUpdate);  pUpdate = 0;\n    sqlite3_finalize(pSelect);  pSelect = 0;\n    sqlite3_finalize(pDelete);  pDelete = 0;\n  \n    if( iMode2==MODE_QUERY && iMode!=MODE_ALL ){\n      printf(\"%s sum of cnt: %lld\\n\", zTag, sumCnt);\n      rc = sqlite3_prepare_v2(db,\"SELECT sum(cnt*cnt) FROM wordcount\", -1,\n                              &pSelect, 0);\n      if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){\n        printf(\"%s double-check: %lld\\n\", zTag,sqlite3_column_int64(pSelect,0));\n      }\n      sqlite3_finalize(pSelect);\n    }\n  \n  \n    if( showTimer ){\n      sqlite3_int64 elapseTime = realTime() - startTime;\n      totalTime += elapseTime;\n      fprintf(pTimer, \"%3d.%03d wordcount\", (int)(elapseTime/1000),\n                                   (int)(elapseTime%1000));\n      if( iMode==MODE_ALL ){\n        fprintf(pTimer, \" %s%s\\n\", azMode[iMode2],\n                useWithoutRowid? \" --without-rowid\" : \"\");\n      }else{\n        for(i=1; i<argc; i++) if( i!=showTimer ) fprintf(pTimer,\" %s\",argv[i]);\n        fprintf(pTimer, \"\\n\");\n      }\n    }\n  \n    if( showSummary ){\n      sqlite3_create_function(db, \"checksum\", -1, SQLITE_UTF8, 0,\n                              0, checksumStep, checksumFinalize);\n      sqlite3_exec(db, \n        \"SELECT 'count(*):  ', count(*) FROM wordcount;\\n\"\n        \"SELECT 'sum(cnt):  ', sum(cnt) FROM wordcount;\\n\"\n        \"SELECT 'max(cnt):  ', max(cnt) FROM wordcount;\\n\"\n        \"SELECT 'avg(cnt):  ', avg(cnt) FROM wordcount;\\n\"\n        \"SELECT 'sum(cnt=1):', sum(cnt=1) FROM wordcount;\\n\"\n        \"SELECT 'top 10:    ', group_concat(word, ', ') FROM \"\n           \"(SELECT word FROM wordcount ORDER BY cnt DESC, word LIMIT 10);\\n\"\n        \"SELECT 'checksum:  ', checksum(word, cnt) FROM \"\n           \"(SELECT word, cnt FROM wordcount ORDER BY word);\\n\"\n        \"PRAGMA integrity_check;\\n\",\n        printResult, 0, 0);\n    }\n  } /* End the --all loop */\n\n  /* Close the input file after the last read */\n  if( zFileToRead ) fclose(in);\n\n  /* In --all mode, so the total time */\n  if( iMode==MODE_ALL && showTimer ){\n    fprintf(pTimer, \"%3d.%03d wordcount --all\\n\", (int)(totalTime/1000),\n                                   (int)(totalTime%1000));\n  }\n  \n  /* Database connection statistics printed after both prepared statements\n  ** have been finalized */\n  if( showStats ){\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, 0);\n    printf(\"%s Lookaside Slots Used:        %d (max %d)\\n\", zTag, iCur,iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, 0);\n    printf(\"%s Successful lookasides:       %d\\n\", zTag, iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHiwtr,0);\n    printf(\"%s Lookaside size faults:       %d\\n\", zTag, iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHiwtr,0);\n    printf(\"%s Lookaside OOM faults:        %d\\n\", zTag, iHiwtr);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, 0);\n    printf(\"%s Pager Heap Usage:            %d bytes\\n\", zTag, iCur);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);\n    printf(\"%s Page cache hits:             %d\\n\", zTag, iCur);\n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);\n    printf(\"%s Page cache misses:           %d\\n\", zTag, iCur); \n    sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);\n    printf(\"%s Page cache writes:           %d\\n\", zTag, iCur); \n    sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, 0);\n    printf(\"%s Schema Heap Usage:           %d bytes\\n\", zTag, iCur); \n    sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, 0);\n    printf(\"%s Statement Heap Usage:        %d bytes\\n\", zTag, iCur); \n  }\n\n  sqlite3_close(db);\n\n  /* Global memory usage statistics printed after the database connection\n  ** has closed.  Memory usage should be zero at this point. */\n  if( showStats ){\n    sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, 0);\n    printf(\"%s Memory Used (bytes):         %d (max %d)\\n\", zTag,iCur,iHiwtr);\n    sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, 0);\n    printf(\"%s Outstanding Allocations:     %d (max %d)\\n\",zTag,iCur,iHiwtr);\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, 0);\n    printf(\"%s Pcache Overflow Bytes:       %d (max %d)\\n\",zTag,iCur,iHiwtr);\n    sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, 0);\n    printf(\"%s Largest Allocation:          %d bytes\\n\",zTag,iHiwtr);\n    sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, 0);\n    printf(\"%s Largest Pcache Allocation:   %d bytes\\n\",zTag,iHiwtr);\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/writecrash.test",
    "content": "# 2009 January 8\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n#\n# Test the outcome of a writer crashing within a call to the VFS\n# xWrite function.\n#\n\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix writecrash\n\ndo_not_use_codec\n\n\nif {$tcl_platform(platform)==\"windows\"} {\n  finish_test\n  return\n}\n\ndo_execsql_test 1.0 {\n  CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE);\n  WITH s(i) AS (\n    VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100\n  )\n  INSERT INTO t1 SELECT NULL, randomblob(900) FROM s;\n} {}\n\nset bGo 1\nfor {set tn 1} {$bGo} {incr tn} {\n\ndb close\nsqlite3 db test.db\n\n  do_test 1.$tn.1 {\n    set res [crash_on_write $tn {\n      UPDATE t1 SET b = randomblob(899) WHERE (a%3)==0\n    }]\n    set bGo 0\n    if {[string match {1 {child killed:*}} $res]} {\n      set res {0 {}}\n      set bGo 1\n    }\n    set res\n  } {0 {}}\n\n#db close\n#sqlite3 db test.db\n\n  do_execsql_test 1.$tn.2 { PRAGMA integrity_check } {ok}\n\ndb close\nsqlite3 db test.db\n\n  do_execsql_test 1.$tn.3 { PRAGMA integrity_check } {ok}\n}\n\n\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/zeroblob.test",
    "content": "# 2007 May 02\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# This file implements regression tests for SQLite library.  The\n# focus of this file is testing of the zero-filled blob functionality\n# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),\n# and the built-in zeroblob() SQL function.\n#\n# $Id: zeroblob.test,v 1.14 2009/07/14 02:33:02 drh Exp $\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix zeroblob\n\nifcapable !incrblob {\n  finish_test\n  return\n}\n\ntest_set_config_pagecache 0 0\n\n# When zeroblob() is used for the last field of a column, then the\n# content of the zeroblob is never instantiated on the VDBE stack.\n# But it does get inserted into the database correctly.\n#\ndb eval {PRAGMA cache_size=10}\nsqlite3_memory_highwater 1\nunset -nocomplain memused\nset memused [sqlite3_memory_used]\ndo_test zeroblob-1.1 {\n  execsql {\n    CREATE TABLE t1(a,b,c,d);\n  }\n  set ::sqlite3_max_blobsize 0\n  execsql {\n    INSERT INTO t1 VALUES(2,3,4,zeroblob(1000000));\n  }\n  set ::sqlite3_max_blobsize\n} {10}\n\ndo_test zeroblob-1.1.1 {\n  expr {[sqlite3_memory_highwater]<$::memused+35000}\n} {1}\ndo_test zeroblob-1.2 {\n  execsql {\n    SELECT length(d) FROM t1\n  }\n} {1000000}\n\n# If a non-NULL column follows the zeroblob, then the content of\n# the zeroblob must be instantiated.\n#\ndo_test zeroblob-1.3 {\n  set ::sqlite3_max_blobsize 0\n  execsql {\n    INSERT INTO t1 VALUES(3,4,zeroblob(10000),5);\n  }\n  set ::sqlite3_max_blobsize\n} {10010}\ndo_test zeroblob-1.4 {\n  execsql {\n    SELECT length(c), length(d) FROM t1\n  }\n} {1 1000000 10000 1}\n\n# Multiple zeroblobs can appear at the end of record.  No instantiation\n# of the blob content occurs on the stack.\n#\ndo_test zeroblob-1.5 {\n  set ::sqlite3_max_blobsize 0\n  execsql {\n    INSERT INTO t1 VALUES(4,5,zeroblob(10000),zeroblob(10000));\n  }\n  set ::sqlite3_max_blobsize\n} {11}\ndo_test zeroblob-1.6 {\n  execsql {\n    SELECT length(c), length(d) FROM t1\n  }\n} {1 1000000 10000 1 10000 10000}\n\n# NULLs can follow the zeroblob() or be intermixed with zeroblobs and\n# no instantiation of the zeroblobs occurs on the stack.\n#\ndo_test zeroblob-1.7 {\n  set ::sqlite3_max_blobsize 0\n  execsql {\n    INSERT INTO t1 VALUES(5,zeroblob(10000),NULL,zeroblob(10000));\n  }\n  set ::sqlite3_max_blobsize\n} {10}\ndo_test zeroblob-1.8 {\n  execsql {\n    SELECT length(b), length(d) FROM t1 WHERE a=5\n  }\n} {10000 10000}\n\n# Comparisons against zeroblobs work.\n#\ndo_test zeroblob-2.1 {\n  execsql {\n    SELECT a FROM t1 WHERE b=zeroblob(10000)\n  }\n} {5}\n\n# Comparisons against zeroblobs work even when indexed.\n#\ndo_test zeroblob-2.2 {\n  execsql {\n    CREATE INDEX i1_1 ON t1(b);\n    SELECT a FROM t1 WHERE b=zeroblob(10000);\n  }\n} {5}\n\n# DISTINCT works for zeroblobs\n#\nifcapable bloblit&&subquery&&compound {\n  do_test zeroblob-3.1 {\n    execsql {\n      SELECT count(DISTINCT a) FROM (\n        SELECT x'00000000000000000000' AS a\n        UNION ALL\n        SELECT zeroblob(10) AS a\n      )\n    }\n  } {1}\n}\n\n# Concatentation works with zeroblob\n#\nifcapable bloblit {\n  do_test zeroblob-4.1 {\n    execsql {\n      SELECT hex(zeroblob(2) || x'61')\n    }\n  } {000061}\n}\n\n# Check various CAST(...) operations on zeroblob.\n#\ndo_test zeroblob-5.1 {\n  execsql {\n    SELECT CAST (zeroblob(100) AS REAL);\n  }\n} {0.0}\ndo_test zeroblob-5.2 {\n  execsql {\n    SELECT CAST (zeroblob(100) AS INTEGER);\n  }\n} {0}\ndo_test zeroblob-5.3 {\n  execsql {\n    SELECT CAST (zeroblob(100) AS TEXT);\n  }\n} {{}}\ndo_test zeroblob-5.4 {\n  execsql {\n    SELECT CAST(zeroblob(100) AS BLOB);\n  }\n} [execsql {SELECT zeroblob(100)}]\n  \n\n# Check for malicious use of zeroblob.  Make sure nothing crashes.\n#\ndo_test zeroblob-6.1.1 { \n  execsql {select zeroblob(-1)} \n} {{}} \ndo_test zeroblob-6.1.2 { \n  execsql {select zeroblob(-10)} \n} {{}} \ndo_test zeroblob-6.1.3 { \n  execsql {select zeroblob(-100)} \n} {{}} \ndo_test zeroblob-6.2 { \n  execsql {select length(zeroblob(-1))} \n} {0} \ndo_test zeroblob-6.3 { \n  execsql {select zeroblob(-1)|1} \n} {1} \ndo_test zeroblob-6.4 { \n  catchsql {select length(zeroblob(2147483648))} \n} {1 {string or blob too big}} \ndo_test zeroblob-6.5 { \n  catchsql {select zeroblob(2147483648)} \n} {1 {string or blob too big}}\ndo_test zeroblob-6.6 {\n  execsql {select hex(zeroblob(-1))}\n} {{}}\ndo_test zeroblob-6.7 {\n  execsql {select typeof(zeroblob(-1))}\n} {blob}\n\n# Test bind_zeroblob()\n#\nsqlite3_memory_highwater 1\nunset -nocomplain memused\nset memused [sqlite3_memory_used]\ndo_test zeroblob-7.1 {\n  set ::STMT [sqlite3_prepare $::DB \"SELECT length(?)\" -1 DUMMY]\n  set ::sqlite3_max_blobsize 0\n  sqlite3_bind_zeroblob $::STMT 1 450000\n  sqlite3_step $::STMT\n} {SQLITE_ROW}\ndo_test zeroblob-7.2 {\n  sqlite3_column_int $::STMT 0\n} {450000}\ndo_test zeroblob-7.3 {\n  sqlite3_finalize $::STMT\n} {SQLITE_OK}\ndo_test zeroblob-7.4 {\n  set ::sqlite3_max_blobsize\n} {0}\ndo_test zeroblob-7.5 {\n  expr {[sqlite3_memory_highwater]<$::memused+10000}\n} {1}\n\n# Test that MakeRecord can handle a value with some real content\n# and a zero-blob tail.\n#\ndo_test zeroblob-8.1 {\n  llength [execsql {\n    SELECT 'hello' AS a, zeroblob(10) as b from t1 ORDER BY a, b;\n  }]\n} {8}\n\n\n# Ticket #3965\n# zeroblobs on either size of an IN operator\n#\ndo_test zeroblob-9.1 {\n  db eval {SELECT x'0000' IN (x'000000')}\n} {0}\ndo_test zeroblob-9.2 {\n  db eval {SELECT x'0000' IN (x'0000')}\n} {1}\ndo_test zeroblob-9.3 {\n  db eval {SELECT zeroblob(2) IN (x'000000')}\n} {0}\ndo_test zeroblob-9.4 {\n  db eval {SELECT zeroblob(2) IN (x'0000')}\n} {1}\ndo_test zeroblob-9.5 {\n  db eval {SELECT x'0000' IN (zeroblob(3))}\n} {0}\ndo_test zeroblob-9.6 {\n  db eval {SELECT x'0000' IN (zeroblob(2))}\n} {1}\ndo_test zeroblob-9.7 {\n  db eval {SELECT zeroblob(2) IN (zeroblob(3))}\n} {0}\ndo_test zeroblob-9.8 {\n  db eval {SELECT zeroblob(2) IN (zeroblob(2))}\n} {1}\n\n# Oversized zeroblob records\n#\ndo_test zeroblob-10.1 {\n  db eval {\n    CREATE TABLE t10(a,b,c);\n  }\n  catchsql {INSERT INTO t10 VALUES(zeroblob(1e9),zeroblob(1e9),zeroblob(1e9))}\n} {1 {string or blob too big}}\n\n#-------------------------------------------------------------------------\n# Test the zeroblob() function on its own with negative or oversized \n# arguments.\n#\ndo_execsql_test 11.0 { \n  SELECT length(zeroblob(-1444444444444444));\n} {0}\ndo_catchsql_test 11.1 { \n  SELECT zeroblob(5000 * 1024 * 1024);\n} {1 {string or blob too big}}\ndo_catchsql_test 11.2 { \n  SELECT quote(zeroblob(5000 * 1024 * 1024));\n} {1 {string or blob too big}}\ndo_catchsql_test 11.3 { \n  SELECT quote(zeroblob(-1444444444444444));\n} {0 X''}\ndo_catchsql_test 11.4 {\n  SELECT quote(test_zeroblob(-1));\n} {0 X''}\n\n#-------------------------------------------------------------------------\n# Test the sqlite3_bind_zeroblob64() API.\n#\nproc bind_and_run {stmt nZero} {\n  sqlite3_bind_zeroblob64 $stmt 1 $nZero\n  sqlite3_step $stmt\n  set ret [sqlite3_column_int $stmt 0]\n  sqlite3_reset $stmt\n  set ret\n}\nset stmt [sqlite3_prepare db \"SELECT length(?)\" -1 dummy]\n\ndo_test 12.1 { bind_and_run $stmt 40 } 40\ndo_test 12.2 { bind_and_run $stmt  0 }  0\ndo_test 12.3 { bind_and_run $stmt 1000 } 1000\n\ndo_test 12.4 { \n  list [catch { bind_and_run $stmt [expr 5000 * 1024 * 1024] } msg] $msg \n} {1 SQLITE_TOOBIG}\ndo_test 12.5 {\n  sqlite3_step $stmt\n  set ret [sqlite3_column_int $stmt 0]\n  sqlite3_reset $stmt\n  set ret\n} {1000}\n\nsqlite3_finalize $stmt\n\ntest_restore_config_pagecache\nfinish_test\n"
  },
  {
    "path": "v2/testdata/_sqlite/test/zerodamage.test",
    "content": "# 2011 December 21\n#\n# The author disclaims copyright to this source code.  In place of\n# a legal notice, here is a blessing:\n#\n#    May you do good and not evil.\n#    May you find forgiveness for yourself and forgive others.\n#    May you share freely, never taking more than you give.\n#\n#***********************************************************************\n# \n# This file implements tests of the SQLITE_IOCAP_POWERSAFE_OVERWRITE property\n# and the SQLITE_FCNTL_POWERSAFE_OVERWRITE file-control for manipulating it.\n#\n# The name of this file comes from the fact that we used to call the\n# POWERSAFE_OVERWRITE property ZERO_DAMAGE.\n#\n\nset testdir [file dirname $argv0]\nsource $testdir/tester.tcl\nset testprefix zerodamage\n\nifcapable !vtab {\n  finish_test\n  return\n}\n\n# POWERSAFE_OVERWRITE defaults to true\n#\ndo_test zerodamage-1.0 {\n  file_control_powersafe_overwrite db -1\n} {0 1}\n\n# Check the ability to turn zero-damage on and off.\n#\ndo_test zerodamage-1.1 {\n  file_control_powersafe_overwrite db 0\n  file_control_powersafe_overwrite db -1\n} {0 0}\ndo_test zerodamage-1.2 {\n  file_control_powersafe_overwrite db 1\n  file_control_powersafe_overwrite db -1\n} {0 1}\n\n# Run a transaction with zero-damage on, a small page size and a much larger\n# sectorsize.  Verify that the maximum journal size is small - that the\n# rollback journal is not being padded.\n#\ndo_test zerodamage-2.0 {\n  db close\n  testvfs tv -default 1\n  tv sectorsize 8192\n  sqlite3 db file:test.db?psow=TRUE -uri 1\n  unset -nocomplain ::max_journal_size\n  set ::max_journal_size 0\n  proc xDeleteCallback {method file args} {\n    set sz [file size $file]\n    if {$sz>$::max_journal_size} {set ::max_journal_size $sz}\n  }\n  tv filter xDelete\n  tv script xDeleteCallback\n  load_static_extension db wholenumber\n  db eval {\n    PRAGMA page_size=1024;\n    PRAGMA journal_mode=DELETE;\n    PRAGMA cache_size=5;\n    CREATE VIRTUAL TABLE nums USING wholenumber;\n    CREATE TABLE t1(x, y);\n    INSERT INTO t1 SELECT value, randomblob(100) FROM nums\n                    WHERE value BETWEEN 1 AND 400;\n  }\n  set ::max_journal_size 0\n  db eval {\n    UPDATE t1 SET y=randomblob(50) WHERE x=123;\n  }\n  concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]\n} {0 1 2576}\n\n# Repeat the previous step with zero-damage turned off.  This time the\n# maximum rollback journal size should be much larger.\n#\ndo_test zerodamage-2.1 {\n  set ::max_journal_size 0\n  db close\n  sqlite3 db file:test.db?psow=FALSE -uri 1\n  db eval {\n    UPDATE t1 SET y=randomblob(50) WHERE x=124;\n  }\n  concat [file_control_powersafe_overwrite db -1] [set ::max_journal_size]\n} {0 0 24704}\n\nif {[wal_is_capable]} {\n  # Run a WAL-mode transaction with POWERSAFE_OVERWRITE on to verify that the\n  # WAL file does not get too big.\n  #\n  do_test zerodamage-3.0 {\n    db eval {\n       PRAGMA journal_mode=WAL;\n    }\n    db close\n    sqlite3 db file:test.db?psow=TRUE -uri 1\n    db eval {\n       UPDATE t1 SET y=randomblob(50) WHERE x=124;\n    }\n    file size test.db-wal\n  } {1080}\n\n  # Repeat the previous with POWERSAFE_OVERWRITE off.  Verify that the WAL file\n  # is padded.\n  #\n  do_test zerodamage-3.1 {\n    db close\n    sqlite3 db file:test.db?psow=FALSE -uri 1\n    db eval {\n       PRAGMA synchronous=FULL;\n       UPDATE t1 SET y=randomblob(50) WHERE x=124;\n    }\n    file size test.db-wal\n  } {16800}\n}\n\nfinish_test\n"
  },
  {
    "path": "v2/testdata/bug/1.c",
    "content": "#include <assert.h>\nextern void abort (void);\n\nvoid f1(int *ip) {\n\t*ip = 24;\n}\n\nvoid t1() {\n  \tint i = 42;\n\tassert(i == 42);\n\tf1(&i);\n\tassert(i == 24);\n}\n\nvoid t2() {\n\tint i = 42;\n\tint *ip = &i;\n\tassert(i == 42);\n\tassert(*ip == 42);\n\tassert(ip == &i);\n\tf1(ip);\n\tassert(i == 24);\n}\n\nvoid f3(int **ipp) {\n\t**ipp = 24;\n}\n\nvoid t3() {\n\tint i = 42;\n\tint *ip = &i;\n\tassert(i == 42);\n\tassert(*ip == 42);\n\tassert(ip == &i);\n\tf3(&ip);\n\tassert(i == 24);\n}\n\nvoid f4(int **ipp) {\n}\n\nvoid t4() {\n\tint i = 42;\n\tint *ip = &i;\n\tassert(i == 42);\n\tassert(*ip == 42);\n\tassert(ip == &i);\n\tf4(&ip);\n}\n\nint main (void) {\n\tt1();\n\tt2();\n\tt3();\n\tt4();\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/bug/10.c",
    "content": "#include <assert.h>\n\n#define __mingw_choose_expr __builtin_choose_expr\n\nint main() {\n\tint i = __mingw_choose_expr(0, 2, 3);\n\tint j = __mingw_choose_expr(1, 2, 3);\n\tassert(i == 3);\n\tassert(j == 2);\n}\n"
  },
  {
    "path": "v2/testdata/bug/11.c",
    "content": "int __isnan(double) {}\nint __isnanf(float) {}\nint __isnanl(long double) {}\n\n#define __typeof__ typeof\n#define __dfp_expansion(__call, __fin, x) __fin\n#define __mingw_choose_expr __builtin_choose_expr\n#define __mingw_types_compatible_p(type1, type2) __builtin_types_compatible_p ( type1 , type2 )\n#define isnan(x) __mingw_choose_expr ( __mingw_types_compatible_p ( __typeof__ ( x ) , double ) , __isnan ( x ) , __mingw_choose_expr ( __mingw_types_compatible_p ( __typeof__ ( x ) , float ) , __isnanf ( x ) , __mingw_choose_expr ( __mingw_types_compatible_p ( __typeof__ ( x ) , long double ) , __isnanl ( x ) , __dfp_expansion ( __isnan , ( __builtin_trap ( ) , x ) , x ) ) ) )\n\nint main() {\n\tfloat f;\n\tdouble d;\n\tlong double l;\n\tisnan(f);\n\tisnan(d);\n\tisnan(l);\n}\n"
  },
  {
    "path": "v2/testdata/bug/12.c",
    "content": "#include <assert.h>\n\nvoid foo(int *v[]) {\n\tassert(*v[0] == 42 || *v[0] == 314);\n}\n\nvoid bar(int v[]) {\n\tassert(v[0] == 42 || v[0] == 314);\n}\n\nint a[] = {42};\n\nint main() {\n\tint *p = a;\n\tfoo(&p);\n\tbar(a);\n\tint b[] = {314};\n\tp = b;\n\tfoo(&p);\n\tbar(b);\n}\n"
  },
  {
    "path": "v2/testdata/bug/13.c",
    "content": "#include <assert.h>\n\ntypedef struct _OVERLAPPED {\n\tint Internal;\n\tint InternalHigh;\n\tunion {\n\t\tstruct {\n\t\t\tint Offset;\n\t\t\tint OffsetHigh;\n\t\t};\n\t\tvoid *Pointer;\n\t};\n\tunsigned hEvent;\n} OVERLAPPED;\n\nOVERLAPPED test;\nOVERLAPPED test2;\n\nint main() {\n\tOVERLAPPED test3, test4;\n\tOVERLAPPED *p = &test2, *q = &test4;\n\ttest.Offset = 42;\n\tp->Offset = 43;\n\ttest3.Offset = 44;\n\tq->Offset = 45;\n\tassert(test.Offset == 42);\n\tassert(p->Offset == 43);\n\tassert(test3.Offset == 44);\n\tassert(q->Offset == 45);\n}\n"
  },
  {
    "path": "v2/testdata/bug/14.c",
    "content": "#include <assert.h>\n\ntypedef struct _SYSTEM_INFO {\n\tunion {\n\t\tint dwOemId;\n\t\tstruct {\n\t\t\tint wProcessorArchitecture;\n\t\t\tint wReserved;\n\t\t};\n\t};\n\tint dwPageSize;\n\tint lpMinimumApplicationAddress;\n\tint lpMaximumApplicationAddress;\n\tint dwActiveProcessorMask;\n\tint dwNumberOfProcessors;\n\tint dwProcessorType;\n\tint dwAllocationGranularity;\n\tint wProcessorLevel;\n\tint wProcessorRevision;\n} SYSTEM_INFO;\n\nint main() {\n\tSYSTEM_INFO sysinfo;\n\tsysinfo.dwPageSize = 1;\n}\n"
  },
  {
    "path": "v2/testdata/bug/15.c",
    "content": "#include <assert.h>\n#include <stdarg.h>\n\nva_list a;\n\nvoid g(va_list ap) {\n\tassert(va_arg(ap, int) == 278);\n}\n\nvoid f(int i, ...) {\n\tva_list ap;\n\tva_start(ap, i);\n\tassert(va_arg(ap, int) == 42);\n\tassert(va_arg(ap, double) == 3.14);\n\tg(ap);\n\tassert(va_arg(ap, int) == 123);\n\tva_end(ap);\n}\n\nint main() {\n\tva_list b;\n\t__builtin_printf(\"%i %i\\n\", sizeof(a), sizeof(b));\n\tassert(sizeof(a) == sizeof(void*));\n\tassert(sizeof(b) == sizeof(void*));\n\tf(0, 42, 3.14, 278, 123);\n}\n"
  },
  {
    "path": "v2/testdata/bug/16.c",
    "content": "#include <assert.h>\n#include <errno.h>\n\nint foo() { return 42; }\n\nint main() {\n\tint j = foo();\n\t__errno_location();\n\tint *p = __errno_location();\n\tint i = *__errno_location();\n\tp = &*__errno_location();\n\terrno = 42;\n\tassert(*p == 42);\n\tp = &(*__errno_location());\n\terrno = 421;\n\tassert(*p == 421);\n}\n"
  },
  {
    "path": "v2/testdata/bug/17.c",
    "content": "#include <assert.h>\n\nint main() {\n\tint i = 42;\n\tswitch (i) {\n\t\tint j = 314;\n\tcase 41:\n\t\tassert(0);\n\t\tbreak;\n\tcase 42:\n\t\tassert(i == 42);\n\t\tassert(j == 0); // Not guaranteed in C, only in the Go translation.\n\t\tbreak;\n\tcase 43:\n\t\tassert(0);\n\t\tbreak;\n\tdefault:\n\t\tassert(0);\n\t\tbreak;\n\t}\n\tassert(i == 42);\n}\n"
  },
  {
    "path": "v2/testdata/bug/18.c",
    "content": "#include <assert.h>\n\nint f1() { return 1; }\n\nint f2() { return 2; }\n\nstruct api {\n\tint(*a)();\n\tint(*b)();\n} api, api2;\n\nstruct api *api3, *api4;\n\nint main() {\n\tvoid *p = &api2;\n\tp = &api4;\n\n\tapi.b = f1;\n\tassert(api.b() == 1);\n\tapi2.b = f1;\n\tassert(api2.b() == 1);\n\tapi3 = &api2;\n\tapi3->b = f2;\n\tassert(api3->b() == 2);\n\tapi4 = &api2;\n\tapi4->b = f2;\n\tassert(api4->b() == 2);\n}\n"
  },
  {
    "path": "v2/testdata/bug/2.c",
    "content": "#include <stdlib.h>\n\nvoid foo(char**) {}\n\nint main() {\n\tchar *p = NULL;\n\tfoo(&p);\n\treturn p != NULL;\n}\n"
  },
  {
    "path": "v2/testdata/bug/3.c",
    "content": "static void f(int);\n\nint main() {\n\tf(42);\n\treturn 0;\n}\n\nstatic void f(int i) {\n\tint j = 0;\n\tif (j) {\n\t\tj++;\n\t}\n}\n"
  },
  {
    "path": "v2/testdata/bug/4.c",
    "content": "struct s {\n\tint i;\n} x;\n\nint foo(struct s *p) {\n\treturn p->i;\n}\n\nint foo2(struct s *p) {\n\treturn (*p).i;\n}\n\nint main() {\n\tx.i = 42;\n\tif (foo(&x) != 42) {\n\t\tabort();\n\t}\n\tif (foo2(&x) != 42) {\n\t\tabort();\n\t}\n}\n"
  },
  {
    "path": "v2/testdata/bug/5.c",
    "content": "#include <assert.h>\n#include <stdint.h>\n\n#if defined(__PTRDIFF_TYPE__)\n#define SQLITE_INT_TO_PTR1(X)  ((void*)(__PTRDIFF_TYPE__)(X))\n#define SQLITE_PTR_TO_INT1(X)  ((int)(__PTRDIFF_TYPE__)(X))\n#endif\n\n#define SQLITE_INT_TO_PTR2(X)  ((void*)&((char*)0)[X])\n#define SQLITE_PTR_TO_INT2(X)  ((int)(((char*)X)-(char*)0))\n\n#define SQLITE_INT_TO_PTR3(X)  ((void*)(intptr_t)(X))\n#define SQLITE_PTR_TO_INT3(X)  ((int)(intptr_t)(X))\n\n#define SQLITE_INT_TO_PTR4(X)  ((void*)(X))\n#define SQLITE_PTR_TO_INT4(X)  ((int)(X))\n\nvoid foo(char *p, char *q) {\n\tint i, j = 42;\n\tchar **z = &q;\n\n\tassert(p);\n\tassert(q);\n\tassert(z);\n\tp = 0;\n\tq = 0;\n\tz = 0;\n\tassert(!p);\n\tassert(!q);\n\tassert(!z);\n\n#if defined(SQLITE_INT_TO_PTR1)\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR1(314);\n\ti = SQLITE_PTR_TO_INT1(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR1(j);\n\ti = SQLITE_PTR_TO_INT1(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR1(314);\n\ti = SQLITE_PTR_TO_INT1(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR1(j);\n\ti = SQLITE_PTR_TO_INT1(q);\n\tassert(i == 42);\n#endif\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR2(314);\n\ti = SQLITE_PTR_TO_INT2(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR2(j);\n\ti = SQLITE_PTR_TO_INT2(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR2(314);\n\ti = SQLITE_PTR_TO_INT2(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR2(j);\n\ti = SQLITE_PTR_TO_INT2(q);\n\tassert(i == 42);\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR3(314);\n\ti = SQLITE_PTR_TO_INT3(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR3(j);\n\ti = SQLITE_PTR_TO_INT3(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR3(314);\n\ti = SQLITE_PTR_TO_INT3(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR3(j);\n\ti = SQLITE_PTR_TO_INT3(q);\n\tassert(i == 42);\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR4(314);\n\ti = SQLITE_PTR_TO_INT4(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR4(j);\n\ti = SQLITE_PTR_TO_INT4(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR4(314);\n\ti = SQLITE_PTR_TO_INT4(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR4(j);\n\ti = SQLITE_PTR_TO_INT4(q);\n\tassert(i == 42);\n}\n\nint main() {\n\tint i, j = 42;\n\tchar c;\n\tchar *p = &c, *q = &c;\n\tchar **z = &q;\n\n\tfoo(p, q);\n\n\tassert(p);\n\tassert(q);\n\tassert(z);\n\tp = 0;\n\tq = 0;\n\tz = 0;\n\tassert(!p);\n\tassert(!q);\n\tassert(!z);\n\n#if defined(SQLITE_INT_TO_PTR1)\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR1(314);\n\ti = SQLITE_PTR_TO_INT1(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR1(j);\n\ti = SQLITE_PTR_TO_INT1(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR1(314);\n\ti = SQLITE_PTR_TO_INT1(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR1(j);\n\ti = SQLITE_PTR_TO_INT1(q);\n\tassert(i == 42);\n#endif\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR2(314);\n\ti = SQLITE_PTR_TO_INT2(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR2(j);\n\ti = SQLITE_PTR_TO_INT2(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR2(314);\n\ti = SQLITE_PTR_TO_INT2(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR2(j);\n\ti = SQLITE_PTR_TO_INT2(q);\n\tassert(i == 42);\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR3(314);\n\ti = SQLITE_PTR_TO_INT3(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR3(j);\n\ti = SQLITE_PTR_TO_INT3(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR3(314);\n\ti = SQLITE_PTR_TO_INT3(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR3(j);\n\ti = SQLITE_PTR_TO_INT3(q);\n\tassert(i == 42);\n\n\tp = 0;\n\ti = 0;\n\tp = SQLITE_INT_TO_PTR4(314);\n\ti = SQLITE_PTR_TO_INT4(p);\n\tassert(i == 314);\n\tp = SQLITE_INT_TO_PTR4(j);\n\ti = SQLITE_PTR_TO_INT4(p);\n\tassert(i == 42);\n\tq = 0;\n\ti = 0;\n\tq = SQLITE_INT_TO_PTR4(314);\n\ti = SQLITE_PTR_TO_INT4(q);\n\tassert(i == 314);\n\tq = SQLITE_INT_TO_PTR4(j);\n\ti = SQLITE_PTR_TO_INT4(q);\n\tassert(i == 42);\n}\n"
  },
  {
    "path": "v2/testdata/bug/6.c",
    "content": "#include <assert.h>\n\nchar *tld_p;\nchar *esc_tld_p;\n\nint main() {\n\tassert(!tld_p);\n\tassert(!esc_tld_p);\n\tchar **pp = &esc_tld_p;\n\tassert(pp);\n\n\tstatic char *static_p;\n\tstatic char *esc_static_p;\n\n\tassert(!static_p);\n\tassert(!esc_static_p);\n\tpp = &esc_static_p;\n\tassert(pp);\n}\n"
  },
  {
    "path": "v2/testdata/bug/7.c",
    "content": "#include <assert.h>\n\nint i;\nint *pi = &i;\nint **ppi = &pi;\n\nint main() {\n\tassert(pi == &i);\n\tassert(ppi == &pi);\n\tassert((void*)pi != (void*)ppi);\n\tassert(&pi);\n\tassert(&ppi);\n\n\tint *spi = pi;\n\tint **sppi = ppi;\n\n\tassert(!i);\n\tassert(!*pi);\n\tassert(!**ppi);\n\n\ti = 42;\n\tassert(i == 42);\n\tassert(*pi == 42);\n\tassert(**ppi == 42);\n\n\t*pi = 24;\n\tassert(i == 24);\n\tassert(*pi == 24);\n\tassert(**ppi == 24);\n\tassert(pi == spi);\n\tassert(ppi == sppi);\n\n\t**ppi = 314;\n\tassert(i == 314);\n\tassert(*pi == 314);\n\tassert(**ppi == 314);\n\tassert(pi == spi);\n\tassert(ppi == sppi);\n}\n"
  },
  {
    "path": "v2/testdata/bug/8.c",
    "content": "#include  <stdint.h>\n\nint main() {\n\tint y;\n\tint8_t i8;\n\tuint8_t u8;\n\tint16_t i16;\n\tuint16_t u16;\n\tint32_t i32;\n\tuint32_t u32;\n\tint64_t i64;\n\tuint64_t u64;\n\n\tfor (i8 = -4; i8 <= 4; i8++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) << %i(%x) = %i(%x)\\n\", i8, (uint8_t)i8, y, (unsigned)y, i8 << y, (uint8_t)(i8 << y));\n\t\t}\n\t}\n\tfor (u8 = 0; u8 <= 4; u8++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) << %i(%x) = %u(%x)\\n\", u8, u8, y, (unsigned)y, u8 << y, u8 << y);\n\t\t}\n\t}\n\tfor (i8 = -4; i8 <= 4; i8++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) >> %i(%x) = %i(%x)\\n\", i8, (uint8_t)i8, y, (unsigned)y, i8 >> y, (uint8_t)(i8 >> y));\n\t\t}\n\t}\n\tfor (u8 = 0; u8 <= 4; u8++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) >> %i(%x) = %u(%x)\\n\", u8, u8, y, (unsigned)y, u8 >> y, u8 >> y);\n\t\t}\n\t}\n\n\tfor (i16 = -4; i16 <= 4; i16++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) << %i(%x) = %i(%x)\\n\", i16, (uint16_t)i16, y, (unsigned)y, i16 << y, (uint16_t)(i16 << y));\n\t\t}\n\t}\n\tfor (u16 = 0; u16 <= 4; u16++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) << %i(%x) = %u(%x)\\n\", u16, u16, y, (unsigned)y, u16 << y, u16 << y);\n\t\t}\n\t}\n\tfor (i16 = -4; i16 <= 4; i16++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) >> %i(%x) = %i(%x)\\n\", i16, (uint16_t)i16, y, (unsigned)y, i16 >> y, (uint16_t)(i16 >> y));\n\t\t}\n\t}\n\tfor (u16 = 0; u16 <= 4; u16++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) >> %i(%x) = %u(%x)\\n\", u16, u16, y, (unsigned)y, u16 >> y, u16 >> y);\n\t\t}\n\t}\n\n\tfor (i32 = -4; i32 <= 4; i32++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) << %i(%x) = %i(%x)\\n\", i32, (uint32_t)i32, y, (unsigned)y, i32 << y, (uint32_t)(i32 << y));\n\t\t}\n\t}\n\tfor (u32 = 0; u32 <= 4; u32++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) << %i(%x) = %u(%x)\\n\", u32, u32, y, (unsigned)y, u32 << y, u32 << y);\n\t\t}\n\t}\n\tfor (i32 = -4; i32 <= 4; i32++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) >> %i(%x) = %i(%x)\\n\", i16, (uint32_t)i16, y, (unsigned)y, i16 >> y, (uint32_t)(i16 >> y));\n\t\t}\n\t}\n\tfor (u32 = 0; u32 <= 4; u32++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) >> %i(%x) = %u(%x)\\n\", u32, u32, y, (unsigned)y, u32 >> y, u32 >> y);\n\t\t}\n\t}\n\n\tfor (i64 = -4; i64 <= 4; i64++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) << %i(%x) = %i(%x)\\n\", i64, (uint64_t)i64, y, (unsigned)y, i64 << y, (uint64_t)(i64 << y));\n\t\t}\n\t}\n\tfor (u64 = 0; u64 <= 4; u64++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) << %i(%x) = %u(%x)\\n\", u64, u64, y, (unsigned)y, u64 << y, u64 << y);\n\t\t}\n\t}\n\tfor (i64 = -4; i64 <= 4; i64++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"  signed 8 %i(%x) >> %i(%x) = %i(%x)\\n\", i16, (uint64_t)i16, y, (unsigned)y, i16 >> y, (uint64_t)(i16 >> y));\n\t\t}\n\t}\n\tfor (u64 = 0; u64 <= 4; u64++) {\n\t\tfor (y = -128; y <= 127; y++) {\n\t\t\tprintf(\"unsigned 8 %u(%x) >> %i(%x) = %u(%x)\\n\", u64, u64, y, (unsigned)y, u64 >> y, u64 >> y);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "v2/testdata/bug/8.expect",
    "content": "  signed 8 -4(fc) << -128(ffffff80) = -4(fc)\n  signed 8 -4(fc) << -127(ffffff81) = -8(f8)\n  signed 8 -4(fc) << -126(ffffff82) = -16(f0)\n  signed 8 -4(fc) << -125(ffffff83) = -32(e0)\n  signed 8 -4(fc) << -124(ffffff84) = -64(c0)\n  signed 8 -4(fc) << -123(ffffff85) = -128(80)\n  signed 8 -4(fc) << -122(ffffff86) = -256(0)\n  signed 8 -4(fc) << -121(ffffff87) = -512(0)\n  signed 8 -4(fc) << -120(ffffff88) = -1024(0)\n  signed 8 -4(fc) << -119(ffffff89) = -2048(0)\n  signed 8 -4(fc) << -118(ffffff8a) = -4096(0)\n  signed 8 -4(fc) << -117(ffffff8b) = -8192(0)\n  signed 8 -4(fc) << -116(ffffff8c) = -16384(0)\n  signed 8 -4(fc) << -115(ffffff8d) = -32768(0)\n  signed 8 -4(fc) << -114(ffffff8e) = -65536(0)\n  signed 8 -4(fc) << -113(ffffff8f) = -131072(0)\n  signed 8 -4(fc) << -112(ffffff90) = -262144(0)\n  signed 8 -4(fc) << -111(ffffff91) = -524288(0)\n  signed 8 -4(fc) << -110(ffffff92) = -1048576(0)\n  signed 8 -4(fc) << -109(ffffff93) = -2097152(0)\n  signed 8 -4(fc) << -108(ffffff94) = -4194304(0)\n  signed 8 -4(fc) << -107(ffffff95) = -8388608(0)\n  signed 8 -4(fc) << -106(ffffff96) = -16777216(0)\n  signed 8 -4(fc) << -105(ffffff97) = -33554432(0)\n  signed 8 -4(fc) << -104(ffffff98) = -67108864(0)\n  signed 8 -4(fc) << -103(ffffff99) = -134217728(0)\n  signed 8 -4(fc) << -102(ffffff9a) = -268435456(0)\n  signed 8 -4(fc) << -101(ffffff9b) = -536870912(0)\n  signed 8 -4(fc) << -100(ffffff9c) = -1073741824(0)\n  signed 8 -4(fc) << -99(ffffff9d) = -2147483648(0)\n  signed 8 -4(fc) << -98(ffffff9e) = 0(0)\n  signed 8 -4(fc) << -97(ffffff9f) = 0(0)\n  signed 8 -4(fc) << -96(ffffffa0) = -4(fc)\n  signed 8 -4(fc) << -95(ffffffa1) = -8(f8)\n  signed 8 -4(fc) << -94(ffffffa2) = -16(f0)\n  signed 8 -4(fc) << -93(ffffffa3) = -32(e0)\n  signed 8 -4(fc) << -92(ffffffa4) = -64(c0)\n  signed 8 -4(fc) << -91(ffffffa5) = -128(80)\n  signed 8 -4(fc) << -90(ffffffa6) = -256(0)\n  signed 8 -4(fc) << -89(ffffffa7) = -512(0)\n  signed 8 -4(fc) << -88(ffffffa8) = -1024(0)\n  signed 8 -4(fc) << -87(ffffffa9) = -2048(0)\n  signed 8 -4(fc) << -86(ffffffaa) = -4096(0)\n  signed 8 -4(fc) << -85(ffffffab) = -8192(0)\n  signed 8 -4(fc) << -84(ffffffac) = -16384(0)\n  signed 8 -4(fc) << -83(ffffffad) = -32768(0)\n  signed 8 -4(fc) << -82(ffffffae) = -65536(0)\n  signed 8 -4(fc) << -81(ffffffaf) = -131072(0)\n  signed 8 -4(fc) << -80(ffffffb0) = -262144(0)\n  signed 8 -4(fc) << -79(ffffffb1) = -524288(0)\n  signed 8 -4(fc) << -78(ffffffb2) = -1048576(0)\n  signed 8 -4(fc) << -77(ffffffb3) = -2097152(0)\n  signed 8 -4(fc) << -76(ffffffb4) = -4194304(0)\n  signed 8 -4(fc) << -75(ffffffb5) = -8388608(0)\n  signed 8 -4(fc) << -74(ffffffb6) = -16777216(0)\n  signed 8 -4(fc) << -73(ffffffb7) = -33554432(0)\n  signed 8 -4(fc) << -72(ffffffb8) = -67108864(0)\n  signed 8 -4(fc) << -71(ffffffb9) = -134217728(0)\n  signed 8 -4(fc) << -70(ffffffba) = -268435456(0)\n  signed 8 -4(fc) << -69(ffffffbb) = -536870912(0)\n  signed 8 -4(fc) << -68(ffffffbc) = -1073741824(0)\n  signed 8 -4(fc) << -67(ffffffbd) = -2147483648(0)\n  signed 8 -4(fc) << -66(ffffffbe) = 0(0)\n  signed 8 -4(fc) << -65(ffffffbf) = 0(0)\n  signed 8 -4(fc) << -64(ffffffc0) = -4(fc)\n  signed 8 -4(fc) << -63(ffffffc1) = -8(f8)\n  signed 8 -4(fc) << -62(ffffffc2) = -16(f0)\n  signed 8 -4(fc) << -61(ffffffc3) = -32(e0)\n  signed 8 -4(fc) << -60(ffffffc4) = -64(c0)\n  signed 8 -4(fc) << -59(ffffffc5) = -128(80)\n  signed 8 -4(fc) << -58(ffffffc6) = -256(0)\n  signed 8 -4(fc) << -57(ffffffc7) = -512(0)\n  signed 8 -4(fc) << -56(ffffffc8) = -1024(0)\n  signed 8 -4(fc) << -55(ffffffc9) = -2048(0)\n  signed 8 -4(fc) << -54(ffffffca) = -4096(0)\n  signed 8 -4(fc) << -53(ffffffcb) = -8192(0)\n  signed 8 -4(fc) << -52(ffffffcc) = -16384(0)\n  signed 8 -4(fc) << -51(ffffffcd) = -32768(0)\n  signed 8 -4(fc) << -50(ffffffce) = -65536(0)\n  signed 8 -4(fc) << -49(ffffffcf) = -131072(0)\n  signed 8 -4(fc) << -48(ffffffd0) = -262144(0)\n  signed 8 -4(fc) << -47(ffffffd1) = -524288(0)\n  signed 8 -4(fc) << -46(ffffffd2) = -1048576(0)\n  signed 8 -4(fc) << -45(ffffffd3) = -2097152(0)\n  signed 8 -4(fc) << -44(ffffffd4) = -4194304(0)\n  signed 8 -4(fc) << -43(ffffffd5) = -8388608(0)\n  signed 8 -4(fc) << -42(ffffffd6) = -16777216(0)\n  signed 8 -4(fc) << -41(ffffffd7) = -33554432(0)\n  signed 8 -4(fc) << -40(ffffffd8) = -67108864(0)\n  signed 8 -4(fc) << -39(ffffffd9) = -134217728(0)\n  signed 8 -4(fc) << -38(ffffffda) = -268435456(0)\n  signed 8 -4(fc) << -37(ffffffdb) = -536870912(0)\n  signed 8 -4(fc) << -36(ffffffdc) = -1073741824(0)\n  signed 8 -4(fc) << -35(ffffffdd) = -2147483648(0)\n  signed 8 -4(fc) << -34(ffffffde) = 0(0)\n  signed 8 -4(fc) << -33(ffffffdf) = 0(0)\n  signed 8 -4(fc) << -32(ffffffe0) = -4(fc)\n  signed 8 -4(fc) << -31(ffffffe1) = -8(f8)\n  signed 8 -4(fc) << -30(ffffffe2) = -16(f0)\n  signed 8 -4(fc) << -29(ffffffe3) = -32(e0)\n  signed 8 -4(fc) << -28(ffffffe4) = -64(c0)\n  signed 8 -4(fc) << -27(ffffffe5) = -128(80)\n  signed 8 -4(fc) << -26(ffffffe6) = -256(0)\n  signed 8 -4(fc) << -25(ffffffe7) = -512(0)\n  signed 8 -4(fc) << -24(ffffffe8) = -1024(0)\n  signed 8 -4(fc) << -23(ffffffe9) = -2048(0)\n  signed 8 -4(fc) << -22(ffffffea) = -4096(0)\n  signed 8 -4(fc) << -21(ffffffeb) = -8192(0)\n  signed 8 -4(fc) << -20(ffffffec) = -16384(0)\n  signed 8 -4(fc) << -19(ffffffed) = -32768(0)\n  signed 8 -4(fc) << -18(ffffffee) = -65536(0)\n  signed 8 -4(fc) << -17(ffffffef) = -131072(0)\n  signed 8 -4(fc) << -16(fffffff0) = -262144(0)\n  signed 8 -4(fc) << -15(fffffff1) = -524288(0)\n  signed 8 -4(fc) << -14(fffffff2) = -1048576(0)\n  signed 8 -4(fc) << -13(fffffff3) = -2097152(0)\n  signed 8 -4(fc) << -12(fffffff4) = -4194304(0)\n  signed 8 -4(fc) << -11(fffffff5) = -8388608(0)\n  signed 8 -4(fc) << -10(fffffff6) = -16777216(0)\n  signed 8 -4(fc) << -9(fffffff7) = -33554432(0)\n  signed 8 -4(fc) << -8(fffffff8) = -67108864(0)\n  signed 8 -4(fc) << -7(fffffff9) = -134217728(0)\n  signed 8 -4(fc) << -6(fffffffa) = -268435456(0)\n  signed 8 -4(fc) << -5(fffffffb) = -536870912(0)\n  signed 8 -4(fc) << -4(fffffffc) = -1073741824(0)\n  signed 8 -4(fc) << -3(fffffffd) = -2147483648(0)\n  signed 8 -4(fc) << -2(fffffffe) = 0(0)\n  signed 8 -4(fc) << -1(ffffffff) = 0(0)\n  signed 8 -4(fc) << 0(0) = -4(fc)\n  signed 8 -4(fc) << 1(1) = -8(f8)\n  signed 8 -4(fc) << 2(2) = -16(f0)\n  signed 8 -4(fc) << 3(3) = -32(e0)\n  signed 8 -4(fc) << 4(4) = -64(c0)\n  signed 8 -4(fc) << 5(5) = -128(80)\n  signed 8 -4(fc) << 6(6) = -256(0)\n  signed 8 -4(fc) << 7(7) = -512(0)\n  signed 8 -4(fc) << 8(8) = -1024(0)\n  signed 8 -4(fc) << 9(9) = -2048(0)\n  signed 8 -4(fc) << 10(a) = -4096(0)\n  signed 8 -4(fc) << 11(b) = -8192(0)\n  signed 8 -4(fc) << 12(c) = -16384(0)\n  signed 8 -4(fc) << 13(d) = -32768(0)\n  signed 8 -4(fc) << 14(e) = -65536(0)\n  signed 8 -4(fc) << 15(f) = -131072(0)\n  signed 8 -4(fc) << 16(10) = -262144(0)\n  signed 8 -4(fc) << 17(11) = -524288(0)\n  signed 8 -4(fc) << 18(12) = -1048576(0)\n  signed 8 -4(fc) << 19(13) = -2097152(0)\n  signed 8 -4(fc) << 20(14) = -4194304(0)\n  signed 8 -4(fc) << 21(15) = -8388608(0)\n  signed 8 -4(fc) << 22(16) = -16777216(0)\n  signed 8 -4(fc) << 23(17) = -33554432(0)\n  signed 8 -4(fc) << 24(18) = -67108864(0)\n  signed 8 -4(fc) << 25(19) = -134217728(0)\n  signed 8 -4(fc) << 26(1a) = -268435456(0)\n  signed 8 -4(fc) << 27(1b) = -536870912(0)\n  signed 8 -4(fc) << 28(1c) = -1073741824(0)\n  signed 8 -4(fc) << 29(1d) = -2147483648(0)\n  signed 8 -4(fc) << 30(1e) = 0(0)\n  signed 8 -4(fc) << 31(1f) = 0(0)\n  signed 8 -4(fc) << 32(20) = -4(fc)\n  signed 8 -4(fc) << 33(21) = -8(f8)\n  signed 8 -4(fc) << 34(22) = -16(f0)\n  signed 8 -4(fc) << 35(23) = -32(e0)\n  signed 8 -4(fc) << 36(24) = -64(c0)\n  signed 8 -4(fc) << 37(25) = -128(80)\n  signed 8 -4(fc) << 38(26) = -256(0)\n  signed 8 -4(fc) << 39(27) = -512(0)\n  signed 8 -4(fc) << 40(28) = -1024(0)\n  signed 8 -4(fc) << 41(29) = -2048(0)\n  signed 8 -4(fc) << 42(2a) = -4096(0)\n  signed 8 -4(fc) << 43(2b) = -8192(0)\n  signed 8 -4(fc) << 44(2c) = -16384(0)\n  signed 8 -4(fc) << 45(2d) = -32768(0)\n  signed 8 -4(fc) << 46(2e) = -65536(0)\n  signed 8 -4(fc) << 47(2f) = -131072(0)\n  signed 8 -4(fc) << 48(30) = -262144(0)\n  signed 8 -4(fc) << 49(31) = -524288(0)\n  signed 8 -4(fc) << 50(32) = -1048576(0)\n  signed 8 -4(fc) << 51(33) = -2097152(0)\n  signed 8 -4(fc) << 52(34) = -4194304(0)\n  signed 8 -4(fc) << 53(35) = -8388608(0)\n  signed 8 -4(fc) << 54(36) = -16777216(0)\n  signed 8 -4(fc) << 55(37) = -33554432(0)\n  signed 8 -4(fc) << 56(38) = -67108864(0)\n  signed 8 -4(fc) << 57(39) = -134217728(0)\n  signed 8 -4(fc) << 58(3a) = -268435456(0)\n  signed 8 -4(fc) << 59(3b) = -536870912(0)\n  signed 8 -4(fc) << 60(3c) = -1073741824(0)\n  signed 8 -4(fc) << 61(3d) = -2147483648(0)\n  signed 8 -4(fc) << 62(3e) = 0(0)\n  signed 8 -4(fc) << 63(3f) = 0(0)\n  signed 8 -4(fc) << 64(40) = -4(fc)\n  signed 8 -4(fc) << 65(41) = -8(f8)\n  signed 8 -4(fc) << 66(42) = -16(f0)\n  signed 8 -4(fc) << 67(43) = -32(e0)\n  signed 8 -4(fc) << 68(44) = -64(c0)\n  signed 8 -4(fc) << 69(45) = -128(80)\n  signed 8 -4(fc) << 70(46) = -256(0)\n  signed 8 -4(fc) << 71(47) = -512(0)\n  signed 8 -4(fc) << 72(48) = -1024(0)\n  signed 8 -4(fc) << 73(49) = -2048(0)\n  signed 8 -4(fc) << 74(4a) = -4096(0)\n  signed 8 -4(fc) << 75(4b) = -8192(0)\n  signed 8 -4(fc) << 76(4c) = -16384(0)\n  signed 8 -4(fc) << 77(4d) = -32768(0)\n  signed 8 -4(fc) << 78(4e) = -65536(0)\n  signed 8 -4(fc) << 79(4f) = -131072(0)\n  signed 8 -4(fc) << 80(50) = -262144(0)\n  signed 8 -4(fc) << 81(51) = -524288(0)\n  signed 8 -4(fc) << 82(52) = -1048576(0)\n  signed 8 -4(fc) << 83(53) = -2097152(0)\n  signed 8 -4(fc) << 84(54) = -4194304(0)\n  signed 8 -4(fc) << 85(55) = -8388608(0)\n  signed 8 -4(fc) << 86(56) = -16777216(0)\n  signed 8 -4(fc) << 87(57) = -33554432(0)\n  signed 8 -4(fc) << 88(58) = -67108864(0)\n  signed 8 -4(fc) << 89(59) = -134217728(0)\n  signed 8 -4(fc) << 90(5a) = -268435456(0)\n  signed 8 -4(fc) << 91(5b) = -536870912(0)\n  signed 8 -4(fc) << 92(5c) = -1073741824(0)\n  signed 8 -4(fc) << 93(5d) = -2147483648(0)\n  signed 8 -4(fc) << 94(5e) = 0(0)\n  signed 8 -4(fc) << 95(5f) = 0(0)\n  signed 8 -4(fc) << 96(60) = -4(fc)\n  signed 8 -4(fc) << 97(61) = -8(f8)\n  signed 8 -4(fc) << 98(62) = -16(f0)\n  signed 8 -4(fc) << 99(63) = -32(e0)\n  signed 8 -4(fc) << 100(64) = -64(c0)\n  signed 8 -4(fc) << 101(65) = -128(80)\n  signed 8 -4(fc) << 102(66) = -256(0)\n  signed 8 -4(fc) << 103(67) = -512(0)\n  signed 8 -4(fc) << 104(68) = -1024(0)\n  signed 8 -4(fc) << 105(69) = -2048(0)\n  signed 8 -4(fc) << 106(6a) = -4096(0)\n  signed 8 -4(fc) << 107(6b) = -8192(0)\n  signed 8 -4(fc) << 108(6c) = -16384(0)\n  signed 8 -4(fc) << 109(6d) = -32768(0)\n  signed 8 -4(fc) << 110(6e) = -65536(0)\n  signed 8 -4(fc) << 111(6f) = -131072(0)\n  signed 8 -4(fc) << 112(70) = -262144(0)\n  signed 8 -4(fc) << 113(71) = -524288(0)\n  signed 8 -4(fc) << 114(72) = -1048576(0)\n  signed 8 -4(fc) << 115(73) = -2097152(0)\n  signed 8 -4(fc) << 116(74) = -4194304(0)\n  signed 8 -4(fc) << 117(75) = -8388608(0)\n  signed 8 -4(fc) << 118(76) = -16777216(0)\n  signed 8 -4(fc) << 119(77) = -33554432(0)\n  signed 8 -4(fc) << 120(78) = -67108864(0)\n  signed 8 -4(fc) << 121(79) = -134217728(0)\n  signed 8 -4(fc) << 122(7a) = -268435456(0)\n  signed 8 -4(fc) << 123(7b) = -536870912(0)\n  signed 8 -4(fc) << 124(7c) = -1073741824(0)\n  signed 8 -4(fc) << 125(7d) = -2147483648(0)\n  signed 8 -4(fc) << 126(7e) = 0(0)\n  signed 8 -4(fc) << 127(7f) = 0(0)\n  signed 8 -3(fd) << -128(ffffff80) = -3(fd)\n  signed 8 -3(fd) << -127(ffffff81) = -6(fa)\n  signed 8 -3(fd) << -126(ffffff82) = -12(f4)\n  signed 8 -3(fd) << -125(ffffff83) = -24(e8)\n  signed 8 -3(fd) << -124(ffffff84) = -48(d0)\n  signed 8 -3(fd) << -123(ffffff85) = -96(a0)\n  signed 8 -3(fd) << -122(ffffff86) = -192(40)\n  signed 8 -3(fd) << -121(ffffff87) = -384(80)\n  signed 8 -3(fd) << -120(ffffff88) = -768(0)\n  signed 8 -3(fd) << -119(ffffff89) = -1536(0)\n  signed 8 -3(fd) << -118(ffffff8a) = -3072(0)\n  signed 8 -3(fd) << -117(ffffff8b) = -6144(0)\n  signed 8 -3(fd) << -116(ffffff8c) = -12288(0)\n  signed 8 -3(fd) << -115(ffffff8d) = -24576(0)\n  signed 8 -3(fd) << -114(ffffff8e) = -49152(0)\n  signed 8 -3(fd) << -113(ffffff8f) = -98304(0)\n  signed 8 -3(fd) << -112(ffffff90) = -196608(0)\n  signed 8 -3(fd) << -111(ffffff91) = -393216(0)\n  signed 8 -3(fd) << -110(ffffff92) = -786432(0)\n  signed 8 -3(fd) << -109(ffffff93) = -1572864(0)\n  signed 8 -3(fd) << -108(ffffff94) = -3145728(0)\n  signed 8 -3(fd) << -107(ffffff95) = -6291456(0)\n  signed 8 -3(fd) << -106(ffffff96) = -12582912(0)\n  signed 8 -3(fd) << -105(ffffff97) = -25165824(0)\n  signed 8 -3(fd) << -104(ffffff98) = -50331648(0)\n  signed 8 -3(fd) << -103(ffffff99) = -100663296(0)\n  signed 8 -3(fd) << -102(ffffff9a) = -201326592(0)\n  signed 8 -3(fd) << -101(ffffff9b) = -402653184(0)\n  signed 8 -3(fd) << -100(ffffff9c) = -805306368(0)\n  signed 8 -3(fd) << -99(ffffff9d) = -1610612736(0)\n  signed 8 -3(fd) << -98(ffffff9e) = 1073741824(0)\n  signed 8 -3(fd) << -97(ffffff9f) = -2147483648(0)\n  signed 8 -3(fd) << -96(ffffffa0) = -3(fd)\n  signed 8 -3(fd) << -95(ffffffa1) = -6(fa)\n  signed 8 -3(fd) << -94(ffffffa2) = -12(f4)\n  signed 8 -3(fd) << -93(ffffffa3) = -24(e8)\n  signed 8 -3(fd) << -92(ffffffa4) = -48(d0)\n  signed 8 -3(fd) << -91(ffffffa5) = -96(a0)\n  signed 8 -3(fd) << -90(ffffffa6) = -192(40)\n  signed 8 -3(fd) << -89(ffffffa7) = -384(80)\n  signed 8 -3(fd) << -88(ffffffa8) = -768(0)\n  signed 8 -3(fd) << -87(ffffffa9) = -1536(0)\n  signed 8 -3(fd) << -86(ffffffaa) = -3072(0)\n  signed 8 -3(fd) << -85(ffffffab) = -6144(0)\n  signed 8 -3(fd) << -84(ffffffac) = -12288(0)\n  signed 8 -3(fd) << -83(ffffffad) = -24576(0)\n  signed 8 -3(fd) << -82(ffffffae) = -49152(0)\n  signed 8 -3(fd) << -81(ffffffaf) = -98304(0)\n  signed 8 -3(fd) << -80(ffffffb0) = -196608(0)\n  signed 8 -3(fd) << -79(ffffffb1) = -393216(0)\n  signed 8 -3(fd) << -78(ffffffb2) = -786432(0)\n  signed 8 -3(fd) << -77(ffffffb3) = -1572864(0)\n  signed 8 -3(fd) << -76(ffffffb4) = -3145728(0)\n  signed 8 -3(fd) << -75(ffffffb5) = -6291456(0)\n  signed 8 -3(fd) << -74(ffffffb6) = -12582912(0)\n  signed 8 -3(fd) << -73(ffffffb7) = -25165824(0)\n  signed 8 -3(fd) << -72(ffffffb8) = -50331648(0)\n  signed 8 -3(fd) << -71(ffffffb9) = -100663296(0)\n  signed 8 -3(fd) << -70(ffffffba) = -201326592(0)\n  signed 8 -3(fd) << -69(ffffffbb) = -402653184(0)\n  signed 8 -3(fd) << -68(ffffffbc) = -805306368(0)\n  signed 8 -3(fd) << -67(ffffffbd) = -1610612736(0)\n  signed 8 -3(fd) << -66(ffffffbe) = 1073741824(0)\n  signed 8 -3(fd) << -65(ffffffbf) = -2147483648(0)\n  signed 8 -3(fd) << -64(ffffffc0) = -3(fd)\n  signed 8 -3(fd) << -63(ffffffc1) = -6(fa)\n  signed 8 -3(fd) << -62(ffffffc2) = -12(f4)\n  signed 8 -3(fd) << -61(ffffffc3) = -24(e8)\n  signed 8 -3(fd) << -60(ffffffc4) = -48(d0)\n  signed 8 -3(fd) << -59(ffffffc5) = -96(a0)\n  signed 8 -3(fd) << -58(ffffffc6) = -192(40)\n  signed 8 -3(fd) << -57(ffffffc7) = -384(80)\n  signed 8 -3(fd) << -56(ffffffc8) = -768(0)\n  signed 8 -3(fd) << -55(ffffffc9) = -1536(0)\n  signed 8 -3(fd) << -54(ffffffca) = -3072(0)\n  signed 8 -3(fd) << -53(ffffffcb) = -6144(0)\n  signed 8 -3(fd) << -52(ffffffcc) = -12288(0)\n  signed 8 -3(fd) << -51(ffffffcd) = -24576(0)\n  signed 8 -3(fd) << -50(ffffffce) = -49152(0)\n  signed 8 -3(fd) << -49(ffffffcf) = -98304(0)\n  signed 8 -3(fd) << -48(ffffffd0) = -196608(0)\n  signed 8 -3(fd) << -47(ffffffd1) = -393216(0)\n  signed 8 -3(fd) << -46(ffffffd2) = -786432(0)\n  signed 8 -3(fd) << -45(ffffffd3) = -1572864(0)\n  signed 8 -3(fd) << -44(ffffffd4) = -3145728(0)\n  signed 8 -3(fd) << -43(ffffffd5) = -6291456(0)\n  signed 8 -3(fd) << -42(ffffffd6) = -12582912(0)\n  signed 8 -3(fd) << -41(ffffffd7) = -25165824(0)\n  signed 8 -3(fd) << -40(ffffffd8) = -50331648(0)\n  signed 8 -3(fd) << -39(ffffffd9) = -100663296(0)\n  signed 8 -3(fd) << -38(ffffffda) = -201326592(0)\n  signed 8 -3(fd) << -37(ffffffdb) = -402653184(0)\n  signed 8 -3(fd) << -36(ffffffdc) = -805306368(0)\n  signed 8 -3(fd) << -35(ffffffdd) = -1610612736(0)\n  signed 8 -3(fd) << -34(ffffffde) = 1073741824(0)\n  signed 8 -3(fd) << -33(ffffffdf) = -2147483648(0)\n  signed 8 -3(fd) << -32(ffffffe0) = -3(fd)\n  signed 8 -3(fd) << -31(ffffffe1) = -6(fa)\n  signed 8 -3(fd) << -30(ffffffe2) = -12(f4)\n  signed 8 -3(fd) << -29(ffffffe3) = -24(e8)\n  signed 8 -3(fd) << -28(ffffffe4) = -48(d0)\n  signed 8 -3(fd) << -27(ffffffe5) = -96(a0)\n  signed 8 -3(fd) << -26(ffffffe6) = -192(40)\n  signed 8 -3(fd) << -25(ffffffe7) = -384(80)\n  signed 8 -3(fd) << -24(ffffffe8) = -768(0)\n  signed 8 -3(fd) << -23(ffffffe9) = -1536(0)\n  signed 8 -3(fd) << -22(ffffffea) = -3072(0)\n  signed 8 -3(fd) << -21(ffffffeb) = -6144(0)\n  signed 8 -3(fd) << -20(ffffffec) = -12288(0)\n  signed 8 -3(fd) << -19(ffffffed) = -24576(0)\n  signed 8 -3(fd) << -18(ffffffee) = -49152(0)\n  signed 8 -3(fd) << -17(ffffffef) = -98304(0)\n  signed 8 -3(fd) << -16(fffffff0) = -196608(0)\n  signed 8 -3(fd) << -15(fffffff1) = -393216(0)\n  signed 8 -3(fd) << -14(fffffff2) = -786432(0)\n  signed 8 -3(fd) << -13(fffffff3) = -1572864(0)\n  signed 8 -3(fd) << -12(fffffff4) = -3145728(0)\n  signed 8 -3(fd) << -11(fffffff5) = -6291456(0)\n  signed 8 -3(fd) << -10(fffffff6) = -12582912(0)\n  signed 8 -3(fd) << -9(fffffff7) = -25165824(0)\n  signed 8 -3(fd) << -8(fffffff8) = -50331648(0)\n  signed 8 -3(fd) << -7(fffffff9) = -100663296(0)\n  signed 8 -3(fd) << -6(fffffffa) = -201326592(0)\n  signed 8 -3(fd) << -5(fffffffb) = -402653184(0)\n  signed 8 -3(fd) << -4(fffffffc) = -805306368(0)\n  signed 8 -3(fd) << -3(fffffffd) = -1610612736(0)\n  signed 8 -3(fd) << -2(fffffffe) = 1073741824(0)\n  signed 8 -3(fd) << -1(ffffffff) = -2147483648(0)\n  signed 8 -3(fd) << 0(0) = -3(fd)\n  signed 8 -3(fd) << 1(1) = -6(fa)\n  signed 8 -3(fd) << 2(2) = -12(f4)\n  signed 8 -3(fd) << 3(3) = -24(e8)\n  signed 8 -3(fd) << 4(4) = -48(d0)\n  signed 8 -3(fd) << 5(5) = -96(a0)\n  signed 8 -3(fd) << 6(6) = -192(40)\n  signed 8 -3(fd) << 7(7) = -384(80)\n  signed 8 -3(fd) << 8(8) = -768(0)\n  signed 8 -3(fd) << 9(9) = -1536(0)\n  signed 8 -3(fd) << 10(a) = -3072(0)\n  signed 8 -3(fd) << 11(b) = -6144(0)\n  signed 8 -3(fd) << 12(c) = -12288(0)\n  signed 8 -3(fd) << 13(d) = -24576(0)\n  signed 8 -3(fd) << 14(e) = -49152(0)\n  signed 8 -3(fd) << 15(f) = -98304(0)\n  signed 8 -3(fd) << 16(10) = -196608(0)\n  signed 8 -3(fd) << 17(11) = -393216(0)\n  signed 8 -3(fd) << 18(12) = -786432(0)\n  signed 8 -3(fd) << 19(13) = -1572864(0)\n  signed 8 -3(fd) << 20(14) = -3145728(0)\n  signed 8 -3(fd) << 21(15) = -6291456(0)\n  signed 8 -3(fd) << 22(16) = -12582912(0)\n  signed 8 -3(fd) << 23(17) = -25165824(0)\n  signed 8 -3(fd) << 24(18) = -50331648(0)\n  signed 8 -3(fd) << 25(19) = -100663296(0)\n  signed 8 -3(fd) << 26(1a) = -201326592(0)\n  signed 8 -3(fd) << 27(1b) = -402653184(0)\n  signed 8 -3(fd) << 28(1c) = -805306368(0)\n  signed 8 -3(fd) << 29(1d) = -1610612736(0)\n  signed 8 -3(fd) << 30(1e) = 1073741824(0)\n  signed 8 -3(fd) << 31(1f) = -2147483648(0)\n  signed 8 -3(fd) << 32(20) = -3(fd)\n  signed 8 -3(fd) << 33(21) = -6(fa)\n  signed 8 -3(fd) << 34(22) = -12(f4)\n  signed 8 -3(fd) << 35(23) = -24(e8)\n  signed 8 -3(fd) << 36(24) = -48(d0)\n  signed 8 -3(fd) << 37(25) = -96(a0)\n  signed 8 -3(fd) << 38(26) = -192(40)\n  signed 8 -3(fd) << 39(27) = -384(80)\n  signed 8 -3(fd) << 40(28) = -768(0)\n  signed 8 -3(fd) << 41(29) = -1536(0)\n  signed 8 -3(fd) << 42(2a) = -3072(0)\n  signed 8 -3(fd) << 43(2b) = -6144(0)\n  signed 8 -3(fd) << 44(2c) = -12288(0)\n  signed 8 -3(fd) << 45(2d) = -24576(0)\n  signed 8 -3(fd) << 46(2e) = -49152(0)\n  signed 8 -3(fd) << 47(2f) = -98304(0)\n  signed 8 -3(fd) << 48(30) = -196608(0)\n  signed 8 -3(fd) << 49(31) = -393216(0)\n  signed 8 -3(fd) << 50(32) = -786432(0)\n  signed 8 -3(fd) << 51(33) = -1572864(0)\n  signed 8 -3(fd) << 52(34) = -3145728(0)\n  signed 8 -3(fd) << 53(35) = -6291456(0)\n  signed 8 -3(fd) << 54(36) = -12582912(0)\n  signed 8 -3(fd) << 55(37) = -25165824(0)\n  signed 8 -3(fd) << 56(38) = -50331648(0)\n  signed 8 -3(fd) << 57(39) = -100663296(0)\n  signed 8 -3(fd) << 58(3a) = -201326592(0)\n  signed 8 -3(fd) << 59(3b) = -402653184(0)\n  signed 8 -3(fd) << 60(3c) = -805306368(0)\n  signed 8 -3(fd) << 61(3d) = -1610612736(0)\n  signed 8 -3(fd) << 62(3e) = 1073741824(0)\n  signed 8 -3(fd) << 63(3f) = -2147483648(0)\n  signed 8 -3(fd) << 64(40) = -3(fd)\n  signed 8 -3(fd) << 65(41) = -6(fa)\n  signed 8 -3(fd) << 66(42) = -12(f4)\n  signed 8 -3(fd) << 67(43) = -24(e8)\n  signed 8 -3(fd) << 68(44) = -48(d0)\n  signed 8 -3(fd) << 69(45) = -96(a0)\n  signed 8 -3(fd) << 70(46) = -192(40)\n  signed 8 -3(fd) << 71(47) = -384(80)\n  signed 8 -3(fd) << 72(48) = -768(0)\n  signed 8 -3(fd) << 73(49) = -1536(0)\n  signed 8 -3(fd) << 74(4a) = -3072(0)\n  signed 8 -3(fd) << 75(4b) = -6144(0)\n  signed 8 -3(fd) << 76(4c) = -12288(0)\n  signed 8 -3(fd) << 77(4d) = -24576(0)\n  signed 8 -3(fd) << 78(4e) = -49152(0)\n  signed 8 -3(fd) << 79(4f) = -98304(0)\n  signed 8 -3(fd) << 80(50) = -196608(0)\n  signed 8 -3(fd) << 81(51) = -393216(0)\n  signed 8 -3(fd) << 82(52) = -786432(0)\n  signed 8 -3(fd) << 83(53) = -1572864(0)\n  signed 8 -3(fd) << 84(54) = -3145728(0)\n  signed 8 -3(fd) << 85(55) = -6291456(0)\n  signed 8 -3(fd) << 86(56) = -12582912(0)\n  signed 8 -3(fd) << 87(57) = -25165824(0)\n  signed 8 -3(fd) << 88(58) = -50331648(0)\n  signed 8 -3(fd) << 89(59) = -100663296(0)\n  signed 8 -3(fd) << 90(5a) = -201326592(0)\n  signed 8 -3(fd) << 91(5b) = -402653184(0)\n  signed 8 -3(fd) << 92(5c) = -805306368(0)\n  signed 8 -3(fd) << 93(5d) = -1610612736(0)\n  signed 8 -3(fd) << 94(5e) = 1073741824(0)\n  signed 8 -3(fd) << 95(5f) = -2147483648(0)\n  signed 8 -3(fd) << 96(60) = -3(fd)\n  signed 8 -3(fd) << 97(61) = -6(fa)\n  signed 8 -3(fd) << 98(62) = -12(f4)\n  signed 8 -3(fd) << 99(63) = -24(e8)\n  signed 8 -3(fd) << 100(64) = -48(d0)\n  signed 8 -3(fd) << 101(65) = -96(a0)\n  signed 8 -3(fd) << 102(66) = -192(40)\n  signed 8 -3(fd) << 103(67) = -384(80)\n  signed 8 -3(fd) << 104(68) = -768(0)\n  signed 8 -3(fd) << 105(69) = -1536(0)\n  signed 8 -3(fd) << 106(6a) = -3072(0)\n  signed 8 -3(fd) << 107(6b) = -6144(0)\n  signed 8 -3(fd) << 108(6c) = -12288(0)\n  signed 8 -3(fd) << 109(6d) = -24576(0)\n  signed 8 -3(fd) << 110(6e) = -49152(0)\n  signed 8 -3(fd) << 111(6f) = -98304(0)\n  signed 8 -3(fd) << 112(70) = -196608(0)\n  signed 8 -3(fd) << 113(71) = -393216(0)\n  signed 8 -3(fd) << 114(72) = -786432(0)\n  signed 8 -3(fd) << 115(73) = -1572864(0)\n  signed 8 -3(fd) << 116(74) = -3145728(0)\n  signed 8 -3(fd) << 117(75) = -6291456(0)\n  signed 8 -3(fd) << 118(76) = -12582912(0)\n  signed 8 -3(fd) << 119(77) = -25165824(0)\n  signed 8 -3(fd) << 120(78) = -50331648(0)\n  signed 8 -3(fd) << 121(79) = -100663296(0)\n  signed 8 -3(fd) << 122(7a) = -201326592(0)\n  signed 8 -3(fd) << 123(7b) = -402653184(0)\n  signed 8 -3(fd) << 124(7c) = -805306368(0)\n  signed 8 -3(fd) << 125(7d) = -1610612736(0)\n  signed 8 -3(fd) << 126(7e) = 1073741824(0)\n  signed 8 -3(fd) << 127(7f) = -2147483648(0)\n  signed 8 -2(fe) << -128(ffffff80) = -2(fe)\n  signed 8 -2(fe) << -127(ffffff81) = -4(fc)\n  signed 8 -2(fe) << -126(ffffff82) = -8(f8)\n  signed 8 -2(fe) << -125(ffffff83) = -16(f0)\n  signed 8 -2(fe) << -124(ffffff84) = -32(e0)\n  signed 8 -2(fe) << -123(ffffff85) = -64(c0)\n  signed 8 -2(fe) << -122(ffffff86) = -128(80)\n  signed 8 -2(fe) << -121(ffffff87) = -256(0)\n  signed 8 -2(fe) << -120(ffffff88) = -512(0)\n  signed 8 -2(fe) << -119(ffffff89) = -1024(0)\n  signed 8 -2(fe) << -118(ffffff8a) = -2048(0)\n  signed 8 -2(fe) << -117(ffffff8b) = -4096(0)\n  signed 8 -2(fe) << -116(ffffff8c) = -8192(0)\n  signed 8 -2(fe) << -115(ffffff8d) = -16384(0)\n  signed 8 -2(fe) << -114(ffffff8e) = -32768(0)\n  signed 8 -2(fe) << -113(ffffff8f) = -65536(0)\n  signed 8 -2(fe) << -112(ffffff90) = -131072(0)\n  signed 8 -2(fe) << -111(ffffff91) = -262144(0)\n  signed 8 -2(fe) << -110(ffffff92) = -524288(0)\n  signed 8 -2(fe) << -109(ffffff93) = -1048576(0)\n  signed 8 -2(fe) << -108(ffffff94) = -2097152(0)\n  signed 8 -2(fe) << -107(ffffff95) = -4194304(0)\n  signed 8 -2(fe) << -106(ffffff96) = -8388608(0)\n  signed 8 -2(fe) << -105(ffffff97) = -16777216(0)\n  signed 8 -2(fe) << -104(ffffff98) = -33554432(0)\n  signed 8 -2(fe) << -103(ffffff99) = -67108864(0)\n  signed 8 -2(fe) << -102(ffffff9a) = -134217728(0)\n  signed 8 -2(fe) << -101(ffffff9b) = -268435456(0)\n  signed 8 -2(fe) << -100(ffffff9c) = -536870912(0)\n  signed 8 -2(fe) << -99(ffffff9d) = -1073741824(0)\n  signed 8 -2(fe) << -98(ffffff9e) = -2147483648(0)\n  signed 8 -2(fe) << -97(ffffff9f) = 0(0)\n  signed 8 -2(fe) << -96(ffffffa0) = -2(fe)\n  signed 8 -2(fe) << -95(ffffffa1) = -4(fc)\n  signed 8 -2(fe) << -94(ffffffa2) = -8(f8)\n  signed 8 -2(fe) << -93(ffffffa3) = -16(f0)\n  signed 8 -2(fe) << -92(ffffffa4) = -32(e0)\n  signed 8 -2(fe) << -91(ffffffa5) = -64(c0)\n  signed 8 -2(fe) << -90(ffffffa6) = -128(80)\n  signed 8 -2(fe) << -89(ffffffa7) = -256(0)\n  signed 8 -2(fe) << -88(ffffffa8) = -512(0)\n  signed 8 -2(fe) << -87(ffffffa9) = -1024(0)\n  signed 8 -2(fe) << -86(ffffffaa) = -2048(0)\n  signed 8 -2(fe) << -85(ffffffab) = -4096(0)\n  signed 8 -2(fe) << -84(ffffffac) = -8192(0)\n  signed 8 -2(fe) << -83(ffffffad) = -16384(0)\n  signed 8 -2(fe) << -82(ffffffae) = -32768(0)\n  signed 8 -2(fe) << -81(ffffffaf) = -65536(0)\n  signed 8 -2(fe) << -80(ffffffb0) = -131072(0)\n  signed 8 -2(fe) << -79(ffffffb1) = -262144(0)\n  signed 8 -2(fe) << -78(ffffffb2) = -524288(0)\n  signed 8 -2(fe) << -77(ffffffb3) = -1048576(0)\n  signed 8 -2(fe) << -76(ffffffb4) = -2097152(0)\n  signed 8 -2(fe) << -75(ffffffb5) = -4194304(0)\n  signed 8 -2(fe) << -74(ffffffb6) = -8388608(0)\n  signed 8 -2(fe) << -73(ffffffb7) = -16777216(0)\n  signed 8 -2(fe) << -72(ffffffb8) = -33554432(0)\n  signed 8 -2(fe) << -71(ffffffb9) = -67108864(0)\n  signed 8 -2(fe) << -70(ffffffba) = -134217728(0)\n  signed 8 -2(fe) << -69(ffffffbb) = -268435456(0)\n  signed 8 -2(fe) << -68(ffffffbc) = -536870912(0)\n  signed 8 -2(fe) << -67(ffffffbd) = -1073741824(0)\n  signed 8 -2(fe) << -66(ffffffbe) = -2147483648(0)\n  signed 8 -2(fe) << -65(ffffffbf) = 0(0)\n  signed 8 -2(fe) << -64(ffffffc0) = -2(fe)\n  signed 8 -2(fe) << -63(ffffffc1) = -4(fc)\n  signed 8 -2(fe) << -62(ffffffc2) = -8(f8)\n  signed 8 -2(fe) << -61(ffffffc3) = -16(f0)\n  signed 8 -2(fe) << -60(ffffffc4) = -32(e0)\n  signed 8 -2(fe) << -59(ffffffc5) = -64(c0)\n  signed 8 -2(fe) << -58(ffffffc6) = -128(80)\n  signed 8 -2(fe) << -57(ffffffc7) = -256(0)\n  signed 8 -2(fe) << -56(ffffffc8) = -512(0)\n  signed 8 -2(fe) << -55(ffffffc9) = -1024(0)\n  signed 8 -2(fe) << -54(ffffffca) = -2048(0)\n  signed 8 -2(fe) << -53(ffffffcb) = -4096(0)\n  signed 8 -2(fe) << -52(ffffffcc) = -8192(0)\n  signed 8 -2(fe) << -51(ffffffcd) = -16384(0)\n  signed 8 -2(fe) << -50(ffffffce) = -32768(0)\n  signed 8 -2(fe) << -49(ffffffcf) = -65536(0)\n  signed 8 -2(fe) << -48(ffffffd0) = -131072(0)\n  signed 8 -2(fe) << -47(ffffffd1) = -262144(0)\n  signed 8 -2(fe) << -46(ffffffd2) = -524288(0)\n  signed 8 -2(fe) << -45(ffffffd3) = -1048576(0)\n  signed 8 -2(fe) << -44(ffffffd4) = -2097152(0)\n  signed 8 -2(fe) << -43(ffffffd5) = -4194304(0)\n  signed 8 -2(fe) << -42(ffffffd6) = -8388608(0)\n  signed 8 -2(fe) << -41(ffffffd7) = -16777216(0)\n  signed 8 -2(fe) << -40(ffffffd8) = -33554432(0)\n  signed 8 -2(fe) << -39(ffffffd9) = -67108864(0)\n  signed 8 -2(fe) << -38(ffffffda) = -134217728(0)\n  signed 8 -2(fe) << -37(ffffffdb) = -268435456(0)\n  signed 8 -2(fe) << -36(ffffffdc) = -536870912(0)\n  signed 8 -2(fe) << -35(ffffffdd) = -1073741824(0)\n  signed 8 -2(fe) << -34(ffffffde) = -2147483648(0)\n  signed 8 -2(fe) << -33(ffffffdf) = 0(0)\n  signed 8 -2(fe) << -32(ffffffe0) = -2(fe)\n  signed 8 -2(fe) << -31(ffffffe1) = -4(fc)\n  signed 8 -2(fe) << -30(ffffffe2) = -8(f8)\n  signed 8 -2(fe) << -29(ffffffe3) = -16(f0)\n  signed 8 -2(fe) << -28(ffffffe4) = -32(e0)\n  signed 8 -2(fe) << -27(ffffffe5) = -64(c0)\n  signed 8 -2(fe) << -26(ffffffe6) = -128(80)\n  signed 8 -2(fe) << -25(ffffffe7) = -256(0)\n  signed 8 -2(fe) << -24(ffffffe8) = -512(0)\n  signed 8 -2(fe) << -23(ffffffe9) = -1024(0)\n  signed 8 -2(fe) << -22(ffffffea) = -2048(0)\n  signed 8 -2(fe) << -21(ffffffeb) = -4096(0)\n  signed 8 -2(fe) << -20(ffffffec) = -8192(0)\n  signed 8 -2(fe) << -19(ffffffed) = -16384(0)\n  signed 8 -2(fe) << -18(ffffffee) = -32768(0)\n  signed 8 -2(fe) << -17(ffffffef) = -65536(0)\n  signed 8 -2(fe) << -16(fffffff0) = -131072(0)\n  signed 8 -2(fe) << -15(fffffff1) = -262144(0)\n  signed 8 -2(fe) << -14(fffffff2) = -524288(0)\n  signed 8 -2(fe) << -13(fffffff3) = -1048576(0)\n  signed 8 -2(fe) << -12(fffffff4) = -2097152(0)\n  signed 8 -2(fe) << -11(fffffff5) = -4194304(0)\n  signed 8 -2(fe) << -10(fffffff6) = -8388608(0)\n  signed 8 -2(fe) << -9(fffffff7) = -16777216(0)\n  signed 8 -2(fe) << -8(fffffff8) = -33554432(0)\n  signed 8 -2(fe) << -7(fffffff9) = -67108864(0)\n  signed 8 -2(fe) << -6(fffffffa) = -134217728(0)\n  signed 8 -2(fe) << -5(fffffffb) = -268435456(0)\n  signed 8 -2(fe) << -4(fffffffc) = -536870912(0)\n  signed 8 -2(fe) << -3(fffffffd) = -1073741824(0)\n  signed 8 -2(fe) << -2(fffffffe) = -2147483648(0)\n  signed 8 -2(fe) << -1(ffffffff) = 0(0)\n  signed 8 -2(fe) << 0(0) = -2(fe)\n  signed 8 -2(fe) << 1(1) = -4(fc)\n  signed 8 -2(fe) << 2(2) = -8(f8)\n  signed 8 -2(fe) << 3(3) = -16(f0)\n  signed 8 -2(fe) << 4(4) = -32(e0)\n  signed 8 -2(fe) << 5(5) = -64(c0)\n  signed 8 -2(fe) << 6(6) = -128(80)\n  signed 8 -2(fe) << 7(7) = -256(0)\n  signed 8 -2(fe) << 8(8) = -512(0)\n  signed 8 -2(fe) << 9(9) = -1024(0)\n  signed 8 -2(fe) << 10(a) = -2048(0)\n  signed 8 -2(fe) << 11(b) = -4096(0)\n  signed 8 -2(fe) << 12(c) = -8192(0)\n  signed 8 -2(fe) << 13(d) = -16384(0)\n  signed 8 -2(fe) << 14(e) = -32768(0)\n  signed 8 -2(fe) << 15(f) = -65536(0)\n  signed 8 -2(fe) << 16(10) = -131072(0)\n  signed 8 -2(fe) << 17(11) = -262144(0)\n  signed 8 -2(fe) << 18(12) = -524288(0)\n  signed 8 -2(fe) << 19(13) = -1048576(0)\n  signed 8 -2(fe) << 20(14) = -2097152(0)\n  signed 8 -2(fe) << 21(15) = -4194304(0)\n  signed 8 -2(fe) << 22(16) = -8388608(0)\n  signed 8 -2(fe) << 23(17) = -16777216(0)\n  signed 8 -2(fe) << 24(18) = -33554432(0)\n  signed 8 -2(fe) << 25(19) = -67108864(0)\n  signed 8 -2(fe) << 26(1a) = -134217728(0)\n  signed 8 -2(fe) << 27(1b) = -268435456(0)\n  signed 8 -2(fe) << 28(1c) = -536870912(0)\n  signed 8 -2(fe) << 29(1d) = -1073741824(0)\n  signed 8 -2(fe) << 30(1e) = -2147483648(0)\n  signed 8 -2(fe) << 31(1f) = 0(0)\n  signed 8 -2(fe) << 32(20) = -2(fe)\n  signed 8 -2(fe) << 33(21) = -4(fc)\n  signed 8 -2(fe) << 34(22) = -8(f8)\n  signed 8 -2(fe) << 35(23) = -16(f0)\n  signed 8 -2(fe) << 36(24) = -32(e0)\n  signed 8 -2(fe) << 37(25) = -64(c0)\n  signed 8 -2(fe) << 38(26) = -128(80)\n  signed 8 -2(fe) << 39(27) = -256(0)\n  signed 8 -2(fe) << 40(28) = -512(0)\n  signed 8 -2(fe) << 41(29) = -1024(0)\n  signed 8 -2(fe) << 42(2a) = -2048(0)\n  signed 8 -2(fe) << 43(2b) = -4096(0)\n  signed 8 -2(fe) << 44(2c) = -8192(0)\n  signed 8 -2(fe) << 45(2d) = -16384(0)\n  signed 8 -2(fe) << 46(2e) = -32768(0)\n  signed 8 -2(fe) << 47(2f) = -65536(0)\n  signed 8 -2(fe) << 48(30) = -131072(0)\n  signed 8 -2(fe) << 49(31) = -262144(0)\n  signed 8 -2(fe) << 50(32) = -524288(0)\n  signed 8 -2(fe) << 51(33) = -1048576(0)\n  signed 8 -2(fe) << 52(34) = -2097152(0)\n  signed 8 -2(fe) << 53(35) = -4194304(0)\n  signed 8 -2(fe) << 54(36) = -8388608(0)\n  signed 8 -2(fe) << 55(37) = -16777216(0)\n  signed 8 -2(fe) << 56(38) = -33554432(0)\n  signed 8 -2(fe) << 57(39) = -67108864(0)\n  signed 8 -2(fe) << 58(3a) = -134217728(0)\n  signed 8 -2(fe) << 59(3b) = -268435456(0)\n  signed 8 -2(fe) << 60(3c) = -536870912(0)\n  signed 8 -2(fe) << 61(3d) = -1073741824(0)\n  signed 8 -2(fe) << 62(3e) = -2147483648(0)\n  signed 8 -2(fe) << 63(3f) = 0(0)\n  signed 8 -2(fe) << 64(40) = -2(fe)\n  signed 8 -2(fe) << 65(41) = -4(fc)\n  signed 8 -2(fe) << 66(42) = -8(f8)\n  signed 8 -2(fe) << 67(43) = -16(f0)\n  signed 8 -2(fe) << 68(44) = -32(e0)\n  signed 8 -2(fe) << 69(45) = -64(c0)\n  signed 8 -2(fe) << 70(46) = -128(80)\n  signed 8 -2(fe) << 71(47) = -256(0)\n  signed 8 -2(fe) << 72(48) = -512(0)\n  signed 8 -2(fe) << 73(49) = -1024(0)\n  signed 8 -2(fe) << 74(4a) = -2048(0)\n  signed 8 -2(fe) << 75(4b) = -4096(0)\n  signed 8 -2(fe) << 76(4c) = -8192(0)\n  signed 8 -2(fe) << 77(4d) = -16384(0)\n  signed 8 -2(fe) << 78(4e) = -32768(0)\n  signed 8 -2(fe) << 79(4f) = -65536(0)\n  signed 8 -2(fe) << 80(50) = -131072(0)\n  signed 8 -2(fe) << 81(51) = -262144(0)\n  signed 8 -2(fe) << 82(52) = -524288(0)\n  signed 8 -2(fe) << 83(53) = -1048576(0)\n  signed 8 -2(fe) << 84(54) = -2097152(0)\n  signed 8 -2(fe) << 85(55) = -4194304(0)\n  signed 8 -2(fe) << 86(56) = -8388608(0)\n  signed 8 -2(fe) << 87(57) = -16777216(0)\n  signed 8 -2(fe) << 88(58) = -33554432(0)\n  signed 8 -2(fe) << 89(59) = -67108864(0)\n  signed 8 -2(fe) << 90(5a) = -134217728(0)\n  signed 8 -2(fe) << 91(5b) = -268435456(0)\n  signed 8 -2(fe) << 92(5c) = -536870912(0)\n  signed 8 -2(fe) << 93(5d) = -1073741824(0)\n  signed 8 -2(fe) << 94(5e) = -2147483648(0)\n  signed 8 -2(fe) << 95(5f) = 0(0)\n  signed 8 -2(fe) << 96(60) = -2(fe)\n  signed 8 -2(fe) << 97(61) = -4(fc)\n  signed 8 -2(fe) << 98(62) = -8(f8)\n  signed 8 -2(fe) << 99(63) = -16(f0)\n  signed 8 -2(fe) << 100(64) = -32(e0)\n  signed 8 -2(fe) << 101(65) = -64(c0)\n  signed 8 -2(fe) << 102(66) = -128(80)\n  signed 8 -2(fe) << 103(67) = -256(0)\n  signed 8 -2(fe) << 104(68) = -512(0)\n  signed 8 -2(fe) << 105(69) = -1024(0)\n  signed 8 -2(fe) << 106(6a) = -2048(0)\n  signed 8 -2(fe) << 107(6b) = -4096(0)\n  signed 8 -2(fe) << 108(6c) = -8192(0)\n  signed 8 -2(fe) << 109(6d) = -16384(0)\n  signed 8 -2(fe) << 110(6e) = -32768(0)\n  signed 8 -2(fe) << 111(6f) = -65536(0)\n  signed 8 -2(fe) << 112(70) = -131072(0)\n  signed 8 -2(fe) << 113(71) = -262144(0)\n  signed 8 -2(fe) << 114(72) = -524288(0)\n  signed 8 -2(fe) << 115(73) = -1048576(0)\n  signed 8 -2(fe) << 116(74) = -2097152(0)\n  signed 8 -2(fe) << 117(75) = -4194304(0)\n  signed 8 -2(fe) << 118(76) = -8388608(0)\n  signed 8 -2(fe) << 119(77) = -16777216(0)\n  signed 8 -2(fe) << 120(78) = -33554432(0)\n  signed 8 -2(fe) << 121(79) = -67108864(0)\n  signed 8 -2(fe) << 122(7a) = -134217728(0)\n  signed 8 -2(fe) << 123(7b) = -268435456(0)\n  signed 8 -2(fe) << 124(7c) = -536870912(0)\n  signed 8 -2(fe) << 125(7d) = -1073741824(0)\n  signed 8 -2(fe) << 126(7e) = -2147483648(0)\n  signed 8 -2(fe) << 127(7f) = 0(0)\n  signed 8 -1(ff) << -128(ffffff80) = -1(ff)\n  signed 8 -1(ff) << -127(ffffff81) = -2(fe)\n  signed 8 -1(ff) << -126(ffffff82) = -4(fc)\n  signed 8 -1(ff) << -125(ffffff83) = -8(f8)\n  signed 8 -1(ff) << -124(ffffff84) = -16(f0)\n  signed 8 -1(ff) << -123(ffffff85) = -32(e0)\n  signed 8 -1(ff) << -122(ffffff86) = -64(c0)\n  signed 8 -1(ff) << -121(ffffff87) = -128(80)\n  signed 8 -1(ff) << -120(ffffff88) = -256(0)\n  signed 8 -1(ff) << -119(ffffff89) = -512(0)\n  signed 8 -1(ff) << -118(ffffff8a) = -1024(0)\n  signed 8 -1(ff) << -117(ffffff8b) = -2048(0)\n  signed 8 -1(ff) << -116(ffffff8c) = -4096(0)\n  signed 8 -1(ff) << -115(ffffff8d) = -8192(0)\n  signed 8 -1(ff) << -114(ffffff8e) = -16384(0)\n  signed 8 -1(ff) << -113(ffffff8f) = -32768(0)\n  signed 8 -1(ff) << -112(ffffff90) = -65536(0)\n  signed 8 -1(ff) << -111(ffffff91) = -131072(0)\n  signed 8 -1(ff) << -110(ffffff92) = -262144(0)\n  signed 8 -1(ff) << -109(ffffff93) = -524288(0)\n  signed 8 -1(ff) << -108(ffffff94) = -1048576(0)\n  signed 8 -1(ff) << -107(ffffff95) = -2097152(0)\n  signed 8 -1(ff) << -106(ffffff96) = -4194304(0)\n  signed 8 -1(ff) << -105(ffffff97) = -8388608(0)\n  signed 8 -1(ff) << -104(ffffff98) = -16777216(0)\n  signed 8 -1(ff) << -103(ffffff99) = -33554432(0)\n  signed 8 -1(ff) << -102(ffffff9a) = -67108864(0)\n  signed 8 -1(ff) << -101(ffffff9b) = -134217728(0)\n  signed 8 -1(ff) << -100(ffffff9c) = -268435456(0)\n  signed 8 -1(ff) << -99(ffffff9d) = -536870912(0)\n  signed 8 -1(ff) << -98(ffffff9e) = -1073741824(0)\n  signed 8 -1(ff) << -97(ffffff9f) = -2147483648(0)\n  signed 8 -1(ff) << -96(ffffffa0) = -1(ff)\n  signed 8 -1(ff) << -95(ffffffa1) = -2(fe)\n  signed 8 -1(ff) << -94(ffffffa2) = -4(fc)\n  signed 8 -1(ff) << -93(ffffffa3) = -8(f8)\n  signed 8 -1(ff) << -92(ffffffa4) = -16(f0)\n  signed 8 -1(ff) << -91(ffffffa5) = -32(e0)\n  signed 8 -1(ff) << -90(ffffffa6) = -64(c0)\n  signed 8 -1(ff) << -89(ffffffa7) = -128(80)\n  signed 8 -1(ff) << -88(ffffffa8) = -256(0)\n  signed 8 -1(ff) << -87(ffffffa9) = -512(0)\n  signed 8 -1(ff) << -86(ffffffaa) = -1024(0)\n  signed 8 -1(ff) << -85(ffffffab) = -2048(0)\n  signed 8 -1(ff) << -84(ffffffac) = -4096(0)\n  signed 8 -1(ff) << -83(ffffffad) = -8192(0)\n  signed 8 -1(ff) << -82(ffffffae) = -16384(0)\n  signed 8 -1(ff) << -81(ffffffaf) = -32768(0)\n  signed 8 -1(ff) << -80(ffffffb0) = -65536(0)\n  signed 8 -1(ff) << -79(ffffffb1) = -131072(0)\n  signed 8 -1(ff) << -78(ffffffb2) = -262144(0)\n  signed 8 -1(ff) << -77(ffffffb3) = -524288(0)\n  signed 8 -1(ff) << -76(ffffffb4) = -1048576(0)\n  signed 8 -1(ff) << -75(ffffffb5) = -2097152(0)\n  signed 8 -1(ff) << -74(ffffffb6) = -4194304(0)\n  signed 8 -1(ff) << -73(ffffffb7) = -8388608(0)\n  signed 8 -1(ff) << -72(ffffffb8) = -16777216(0)\n  signed 8 -1(ff) << -71(ffffffb9) = -33554432(0)\n  signed 8 -1(ff) << -70(ffffffba) = -67108864(0)\n  signed 8 -1(ff) << -69(ffffffbb) = -134217728(0)\n  signed 8 -1(ff) << -68(ffffffbc) = -268435456(0)\n  signed 8 -1(ff) << -67(ffffffbd) = -536870912(0)\n  signed 8 -1(ff) << -66(ffffffbe) = -1073741824(0)\n  signed 8 -1(ff) << -65(ffffffbf) = -2147483648(0)\n  signed 8 -1(ff) << -64(ffffffc0) = -1(ff)\n  signed 8 -1(ff) << -63(ffffffc1) = -2(fe)\n  signed 8 -1(ff) << -62(ffffffc2) = -4(fc)\n  signed 8 -1(ff) << -61(ffffffc3) = -8(f8)\n  signed 8 -1(ff) << -60(ffffffc4) = -16(f0)\n  signed 8 -1(ff) << -59(ffffffc5) = -32(e0)\n  signed 8 -1(ff) << -58(ffffffc6) = -64(c0)\n  signed 8 -1(ff) << -57(ffffffc7) = -128(80)\n  signed 8 -1(ff) << -56(ffffffc8) = -256(0)\n  signed 8 -1(ff) << -55(ffffffc9) = -512(0)\n  signed 8 -1(ff) << -54(ffffffca) = -1024(0)\n  signed 8 -1(ff) << -53(ffffffcb) = -2048(0)\n  signed 8 -1(ff) << -52(ffffffcc) = -4096(0)\n  signed 8 -1(ff) << -51(ffffffcd) = -8192(0)\n  signed 8 -1(ff) << -50(ffffffce) = -16384(0)\n  signed 8 -1(ff) << -49(ffffffcf) = -32768(0)\n  signed 8 -1(ff) << -48(ffffffd0) = -65536(0)\n  signed 8 -1(ff) << -47(ffffffd1) = -131072(0)\n  signed 8 -1(ff) << -46(ffffffd2) = -262144(0)\n  signed 8 -1(ff) << -45(ffffffd3) = -524288(0)\n  signed 8 -1(ff) << -44(ffffffd4) = -1048576(0)\n  signed 8 -1(ff) << -43(ffffffd5) = -2097152(0)\n  signed 8 -1(ff) << -42(ffffffd6) = -4194304(0)\n  signed 8 -1(ff) << -41(ffffffd7) = -8388608(0)\n  signed 8 -1(ff) << -40(ffffffd8) = -16777216(0)\n  signed 8 -1(ff) << -39(ffffffd9) = -33554432(0)\n  signed 8 -1(ff) << -38(ffffffda) = -67108864(0)\n  signed 8 -1(ff) << -37(ffffffdb) = -134217728(0)\n  signed 8 -1(ff) << -36(ffffffdc) = -268435456(0)\n  signed 8 -1(ff) << -35(ffffffdd) = -536870912(0)\n  signed 8 -1(ff) << -34(ffffffde) = -1073741824(0)\n  signed 8 -1(ff) << -33(ffffffdf) = -2147483648(0)\n  signed 8 -1(ff) << -32(ffffffe0) = -1(ff)\n  signed 8 -1(ff) << -31(ffffffe1) = -2(fe)\n  signed 8 -1(ff) << -30(ffffffe2) = -4(fc)\n  signed 8 -1(ff) << -29(ffffffe3) = -8(f8)\n  signed 8 -1(ff) << -28(ffffffe4) = -16(f0)\n  signed 8 -1(ff) << -27(ffffffe5) = -32(e0)\n  signed 8 -1(ff) << -26(ffffffe6) = -64(c0)\n  signed 8 -1(ff) << -25(ffffffe7) = -128(80)\n  signed 8 -1(ff) << -24(ffffffe8) = -256(0)\n  signed 8 -1(ff) << -23(ffffffe9) = -512(0)\n  signed 8 -1(ff) << -22(ffffffea) = -1024(0)\n  signed 8 -1(ff) << -21(ffffffeb) = -2048(0)\n  signed 8 -1(ff) << -20(ffffffec) = -4096(0)\n  signed 8 -1(ff) << -19(ffffffed) = -8192(0)\n  signed 8 -1(ff) << -18(ffffffee) = -16384(0)\n  signed 8 -1(ff) << -17(ffffffef) = -32768(0)\n  signed 8 -1(ff) << -16(fffffff0) = -65536(0)\n  signed 8 -1(ff) << -15(fffffff1) = -131072(0)\n  signed 8 -1(ff) << -14(fffffff2) = -262144(0)\n  signed 8 -1(ff) << -13(fffffff3) = -524288(0)\n  signed 8 -1(ff) << -12(fffffff4) = -1048576(0)\n  signed 8 -1(ff) << -11(fffffff5) = -2097152(0)\n  signed 8 -1(ff) << -10(fffffff6) = -4194304(0)\n  signed 8 -1(ff) << -9(fffffff7) = -8388608(0)\n  signed 8 -1(ff) << -8(fffffff8) = -16777216(0)\n  signed 8 -1(ff) << -7(fffffff9) = -33554432(0)\n  signed 8 -1(ff) << -6(fffffffa) = -67108864(0)\n  signed 8 -1(ff) << -5(fffffffb) = -134217728(0)\n  signed 8 -1(ff) << -4(fffffffc) = -268435456(0)\n  signed 8 -1(ff) << -3(fffffffd) = -536870912(0)\n  signed 8 -1(ff) << -2(fffffffe) = -1073741824(0)\n  signed 8 -1(ff) << -1(ffffffff) = -2147483648(0)\n  signed 8 -1(ff) << 0(0) = -1(ff)\n  signed 8 -1(ff) << 1(1) = -2(fe)\n  signed 8 -1(ff) << 2(2) = -4(fc)\n  signed 8 -1(ff) << 3(3) = -8(f8)\n  signed 8 -1(ff) << 4(4) = -16(f0)\n  signed 8 -1(ff) << 5(5) = -32(e0)\n  signed 8 -1(ff) << 6(6) = -64(c0)\n  signed 8 -1(ff) << 7(7) = -128(80)\n  signed 8 -1(ff) << 8(8) = -256(0)\n  signed 8 -1(ff) << 9(9) = -512(0)\n  signed 8 -1(ff) << 10(a) = -1024(0)\n  signed 8 -1(ff) << 11(b) = -2048(0)\n  signed 8 -1(ff) << 12(c) = -4096(0)\n  signed 8 -1(ff) << 13(d) = -8192(0)\n  signed 8 -1(ff) << 14(e) = -16384(0)\n  signed 8 -1(ff) << 15(f) = -32768(0)\n  signed 8 -1(ff) << 16(10) = -65536(0)\n  signed 8 -1(ff) << 17(11) = -131072(0)\n  signed 8 -1(ff) << 18(12) = -262144(0)\n  signed 8 -1(ff) << 19(13) = -524288(0)\n  signed 8 -1(ff) << 20(14) = -1048576(0)\n  signed 8 -1(ff) << 21(15) = -2097152(0)\n  signed 8 -1(ff) << 22(16) = -4194304(0)\n  signed 8 -1(ff) << 23(17) = -8388608(0)\n  signed 8 -1(ff) << 24(18) = -16777216(0)\n  signed 8 -1(ff) << 25(19) = -33554432(0)\n  signed 8 -1(ff) << 26(1a) = -67108864(0)\n  signed 8 -1(ff) << 27(1b) = -134217728(0)\n  signed 8 -1(ff) << 28(1c) = -268435456(0)\n  signed 8 -1(ff) << 29(1d) = -536870912(0)\n  signed 8 -1(ff) << 30(1e) = -1073741824(0)\n  signed 8 -1(ff) << 31(1f) = -2147483648(0)\n  signed 8 -1(ff) << 32(20) = -1(ff)\n  signed 8 -1(ff) << 33(21) = -2(fe)\n  signed 8 -1(ff) << 34(22) = -4(fc)\n  signed 8 -1(ff) << 35(23) = -8(f8)\n  signed 8 -1(ff) << 36(24) = -16(f0)\n  signed 8 -1(ff) << 37(25) = -32(e0)\n  signed 8 -1(ff) << 38(26) = -64(c0)\n  signed 8 -1(ff) << 39(27) = -128(80)\n  signed 8 -1(ff) << 40(28) = -256(0)\n  signed 8 -1(ff) << 41(29) = -512(0)\n  signed 8 -1(ff) << 42(2a) = -1024(0)\n  signed 8 -1(ff) << 43(2b) = -2048(0)\n  signed 8 -1(ff) << 44(2c) = -4096(0)\n  signed 8 -1(ff) << 45(2d) = -8192(0)\n  signed 8 -1(ff) << 46(2e) = -16384(0)\n  signed 8 -1(ff) << 47(2f) = -32768(0)\n  signed 8 -1(ff) << 48(30) = -65536(0)\n  signed 8 -1(ff) << 49(31) = -131072(0)\n  signed 8 -1(ff) << 50(32) = -262144(0)\n  signed 8 -1(ff) << 51(33) = -524288(0)\n  signed 8 -1(ff) << 52(34) = -1048576(0)\n  signed 8 -1(ff) << 53(35) = -2097152(0)\n  signed 8 -1(ff) << 54(36) = -4194304(0)\n  signed 8 -1(ff) << 55(37) = -8388608(0)\n  signed 8 -1(ff) << 56(38) = -16777216(0)\n  signed 8 -1(ff) << 57(39) = -33554432(0)\n  signed 8 -1(ff) << 58(3a) = -67108864(0)\n  signed 8 -1(ff) << 59(3b) = -134217728(0)\n  signed 8 -1(ff) << 60(3c) = -268435456(0)\n  signed 8 -1(ff) << 61(3d) = -536870912(0)\n  signed 8 -1(ff) << 62(3e) = -1073741824(0)\n  signed 8 -1(ff) << 63(3f) = -2147483648(0)\n  signed 8 -1(ff) << 64(40) = -1(ff)\n  signed 8 -1(ff) << 65(41) = -2(fe)\n  signed 8 -1(ff) << 66(42) = -4(fc)\n  signed 8 -1(ff) << 67(43) = -8(f8)\n  signed 8 -1(ff) << 68(44) = -16(f0)\n  signed 8 -1(ff) << 69(45) = -32(e0)\n  signed 8 -1(ff) << 70(46) = -64(c0)\n  signed 8 -1(ff) << 71(47) = -128(80)\n  signed 8 -1(ff) << 72(48) = -256(0)\n  signed 8 -1(ff) << 73(49) = -512(0)\n  signed 8 -1(ff) << 74(4a) = -1024(0)\n  signed 8 -1(ff) << 75(4b) = -2048(0)\n  signed 8 -1(ff) << 76(4c) = -4096(0)\n  signed 8 -1(ff) << 77(4d) = -8192(0)\n  signed 8 -1(ff) << 78(4e) = -16384(0)\n  signed 8 -1(ff) << 79(4f) = -32768(0)\n  signed 8 -1(ff) << 80(50) = -65536(0)\n  signed 8 -1(ff) << 81(51) = -131072(0)\n  signed 8 -1(ff) << 82(52) = -262144(0)\n  signed 8 -1(ff) << 83(53) = -524288(0)\n  signed 8 -1(ff) << 84(54) = -1048576(0)\n  signed 8 -1(ff) << 85(55) = -2097152(0)\n  signed 8 -1(ff) << 86(56) = -4194304(0)\n  signed 8 -1(ff) << 87(57) = -8388608(0)\n  signed 8 -1(ff) << 88(58) = -16777216(0)\n  signed 8 -1(ff) << 89(59) = -33554432(0)\n  signed 8 -1(ff) << 90(5a) = -67108864(0)\n  signed 8 -1(ff) << 91(5b) = -134217728(0)\n  signed 8 -1(ff) << 92(5c) = -268435456(0)\n  signed 8 -1(ff) << 93(5d) = -536870912(0)\n  signed 8 -1(ff) << 94(5e) = -1073741824(0)\n  signed 8 -1(ff) << 95(5f) = -2147483648(0)\n  signed 8 -1(ff) << 96(60) = -1(ff)\n  signed 8 -1(ff) << 97(61) = -2(fe)\n  signed 8 -1(ff) << 98(62) = -4(fc)\n  signed 8 -1(ff) << 99(63) = -8(f8)\n  signed 8 -1(ff) << 100(64) = -16(f0)\n  signed 8 -1(ff) << 101(65) = -32(e0)\n  signed 8 -1(ff) << 102(66) = -64(c0)\n  signed 8 -1(ff) << 103(67) = -128(80)\n  signed 8 -1(ff) << 104(68) = -256(0)\n  signed 8 -1(ff) << 105(69) = -512(0)\n  signed 8 -1(ff) << 106(6a) = -1024(0)\n  signed 8 -1(ff) << 107(6b) = -2048(0)\n  signed 8 -1(ff) << 108(6c) = -4096(0)\n  signed 8 -1(ff) << 109(6d) = -8192(0)\n  signed 8 -1(ff) << 110(6e) = -16384(0)\n  signed 8 -1(ff) << 111(6f) = -32768(0)\n  signed 8 -1(ff) << 112(70) = -65536(0)\n  signed 8 -1(ff) << 113(71) = -131072(0)\n  signed 8 -1(ff) << 114(72) = -262144(0)\n  signed 8 -1(ff) << 115(73) = -524288(0)\n  signed 8 -1(ff) << 116(74) = -1048576(0)\n  signed 8 -1(ff) << 117(75) = -2097152(0)\n  signed 8 -1(ff) << 118(76) = -4194304(0)\n  signed 8 -1(ff) << 119(77) = -8388608(0)\n  signed 8 -1(ff) << 120(78) = -16777216(0)\n  signed 8 -1(ff) << 121(79) = -33554432(0)\n  signed 8 -1(ff) << 122(7a) = -67108864(0)\n  signed 8 -1(ff) << 123(7b) = -134217728(0)\n  signed 8 -1(ff) << 124(7c) = -268435456(0)\n  signed 8 -1(ff) << 125(7d) = -536870912(0)\n  signed 8 -1(ff) << 126(7e) = -1073741824(0)\n  signed 8 -1(ff) << 127(7f) = -2147483648(0)\n  signed 8 0(0) << -128(ffffff80) = 0(0)\n  signed 8 0(0) << -127(ffffff81) = 0(0)\n  signed 8 0(0) << -126(ffffff82) = 0(0)\n  signed 8 0(0) << -125(ffffff83) = 0(0)\n  signed 8 0(0) << -124(ffffff84) = 0(0)\n  signed 8 0(0) << -123(ffffff85) = 0(0)\n  signed 8 0(0) << -122(ffffff86) = 0(0)\n  signed 8 0(0) << -121(ffffff87) = 0(0)\n  signed 8 0(0) << -120(ffffff88) = 0(0)\n  signed 8 0(0) << -119(ffffff89) = 0(0)\n  signed 8 0(0) << -118(ffffff8a) = 0(0)\n  signed 8 0(0) << -117(ffffff8b) = 0(0)\n  signed 8 0(0) << -116(ffffff8c) = 0(0)\n  signed 8 0(0) << -115(ffffff8d) = 0(0)\n  signed 8 0(0) << -114(ffffff8e) = 0(0)\n  signed 8 0(0) << -113(ffffff8f) = 0(0)\n  signed 8 0(0) << -112(ffffff90) = 0(0)\n  signed 8 0(0) << -111(ffffff91) = 0(0)\n  signed 8 0(0) << -110(ffffff92) = 0(0)\n  signed 8 0(0) << -109(ffffff93) = 0(0)\n  signed 8 0(0) << -108(ffffff94) = 0(0)\n  signed 8 0(0) << -107(ffffff95) = 0(0)\n  signed 8 0(0) << -106(ffffff96) = 0(0)\n  signed 8 0(0) << -105(ffffff97) = 0(0)\n  signed 8 0(0) << -104(ffffff98) = 0(0)\n  signed 8 0(0) << -103(ffffff99) = 0(0)\n  signed 8 0(0) << -102(ffffff9a) = 0(0)\n  signed 8 0(0) << -101(ffffff9b) = 0(0)\n  signed 8 0(0) << -100(ffffff9c) = 0(0)\n  signed 8 0(0) << -99(ffffff9d) = 0(0)\n  signed 8 0(0) << -98(ffffff9e) = 0(0)\n  signed 8 0(0) << -97(ffffff9f) = 0(0)\n  signed 8 0(0) << -96(ffffffa0) = 0(0)\n  signed 8 0(0) << -95(ffffffa1) = 0(0)\n  signed 8 0(0) << -94(ffffffa2) = 0(0)\n  signed 8 0(0) << -93(ffffffa3) = 0(0)\n  signed 8 0(0) << -92(ffffffa4) = 0(0)\n  signed 8 0(0) << -91(ffffffa5) = 0(0)\n  signed 8 0(0) << -90(ffffffa6) = 0(0)\n  signed 8 0(0) << -89(ffffffa7) = 0(0)\n  signed 8 0(0) << -88(ffffffa8) = 0(0)\n  signed 8 0(0) << -87(ffffffa9) = 0(0)\n  signed 8 0(0) << -86(ffffffaa) = 0(0)\n  signed 8 0(0) << -85(ffffffab) = 0(0)\n  signed 8 0(0) << -84(ffffffac) = 0(0)\n  signed 8 0(0) << -83(ffffffad) = 0(0)\n  signed 8 0(0) << -82(ffffffae) = 0(0)\n  signed 8 0(0) << -81(ffffffaf) = 0(0)\n  signed 8 0(0) << -80(ffffffb0) = 0(0)\n  signed 8 0(0) << -79(ffffffb1) = 0(0)\n  signed 8 0(0) << -78(ffffffb2) = 0(0)\n  signed 8 0(0) << -77(ffffffb3) = 0(0)\n  signed 8 0(0) << -76(ffffffb4) = 0(0)\n  signed 8 0(0) << -75(ffffffb5) = 0(0)\n  signed 8 0(0) << -74(ffffffb6) = 0(0)\n  signed 8 0(0) << -73(ffffffb7) = 0(0)\n  signed 8 0(0) << -72(ffffffb8) = 0(0)\n  signed 8 0(0) << -71(ffffffb9) = 0(0)\n  signed 8 0(0) << -70(ffffffba) = 0(0)\n  signed 8 0(0) << -69(ffffffbb) = 0(0)\n  signed 8 0(0) << -68(ffffffbc) = 0(0)\n  signed 8 0(0) << -67(ffffffbd) = 0(0)\n  signed 8 0(0) << -66(ffffffbe) = 0(0)\n  signed 8 0(0) << -65(ffffffbf) = 0(0)\n  signed 8 0(0) << -64(ffffffc0) = 0(0)\n  signed 8 0(0) << -63(ffffffc1) = 0(0)\n  signed 8 0(0) << -62(ffffffc2) = 0(0)\n  signed 8 0(0) << -61(ffffffc3) = 0(0)\n  signed 8 0(0) << -60(ffffffc4) = 0(0)\n  signed 8 0(0) << -59(ffffffc5) = 0(0)\n  signed 8 0(0) << -58(ffffffc6) = 0(0)\n  signed 8 0(0) << -57(ffffffc7) = 0(0)\n  signed 8 0(0) << -56(ffffffc8) = 0(0)\n  signed 8 0(0) << -55(ffffffc9) = 0(0)\n  signed 8 0(0) << -54(ffffffca) = 0(0)\n  signed 8 0(0) << -53(ffffffcb) = 0(0)\n  signed 8 0(0) << -52(ffffffcc) = 0(0)\n  signed 8 0(0) << -51(ffffffcd) = 0(0)\n  signed 8 0(0) << -50(ffffffce) = 0(0)\n  signed 8 0(0) << -49(ffffffcf) = 0(0)\n  signed 8 0(0) << -48(ffffffd0) = 0(0)\n  signed 8 0(0) << -47(ffffffd1) = 0(0)\n  signed 8 0(0) << -46(ffffffd2) = 0(0)\n  signed 8 0(0) << -45(ffffffd3) = 0(0)\n  signed 8 0(0) << -44(ffffffd4) = 0(0)\n  signed 8 0(0) << -43(ffffffd5) = 0(0)\n  signed 8 0(0) << -42(ffffffd6) = 0(0)\n  signed 8 0(0) << -41(ffffffd7) = 0(0)\n  signed 8 0(0) << -40(ffffffd8) = 0(0)\n  signed 8 0(0) << -39(ffffffd9) = 0(0)\n  signed 8 0(0) << -38(ffffffda) = 0(0)\n  signed 8 0(0) << -37(ffffffdb) = 0(0)\n  signed 8 0(0) << -36(ffffffdc) = 0(0)\n  signed 8 0(0) << -35(ffffffdd) = 0(0)\n  signed 8 0(0) << -34(ffffffde) = 0(0)\n  signed 8 0(0) << -33(ffffffdf) = 0(0)\n  signed 8 0(0) << -32(ffffffe0) = 0(0)\n  signed 8 0(0) << -31(ffffffe1) = 0(0)\n  signed 8 0(0) << -30(ffffffe2) = 0(0)\n  signed 8 0(0) << -29(ffffffe3) = 0(0)\n  signed 8 0(0) << -28(ffffffe4) = 0(0)\n  signed 8 0(0) << -27(ffffffe5) = 0(0)\n  signed 8 0(0) << -26(ffffffe6) = 0(0)\n  signed 8 0(0) << -25(ffffffe7) = 0(0)\n  signed 8 0(0) << -24(ffffffe8) = 0(0)\n  signed 8 0(0) << -23(ffffffe9) = 0(0)\n  signed 8 0(0) << -22(ffffffea) = 0(0)\n  signed 8 0(0) << -21(ffffffeb) = 0(0)\n  signed 8 0(0) << -20(ffffffec) = 0(0)\n  signed 8 0(0) << -19(ffffffed) = 0(0)\n  signed 8 0(0) << -18(ffffffee) = 0(0)\n  signed 8 0(0) << -17(ffffffef) = 0(0)\n  signed 8 0(0) << -16(fffffff0) = 0(0)\n  signed 8 0(0) << -15(fffffff1) = 0(0)\n  signed 8 0(0) << -14(fffffff2) = 0(0)\n  signed 8 0(0) << -13(fffffff3) = 0(0)\n  signed 8 0(0) << -12(fffffff4) = 0(0)\n  signed 8 0(0) << -11(fffffff5) = 0(0)\n  signed 8 0(0) << -10(fffffff6) = 0(0)\n  signed 8 0(0) << -9(fffffff7) = 0(0)\n  signed 8 0(0) << -8(fffffff8) = 0(0)\n  signed 8 0(0) << -7(fffffff9) = 0(0)\n  signed 8 0(0) << -6(fffffffa) = 0(0)\n  signed 8 0(0) << -5(fffffffb) = 0(0)\n  signed 8 0(0) << -4(fffffffc) = 0(0)\n  signed 8 0(0) << -3(fffffffd) = 0(0)\n  signed 8 0(0) << -2(fffffffe) = 0(0)\n  signed 8 0(0) << -1(ffffffff) = 0(0)\n  signed 8 0(0) << 0(0) = 0(0)\n  signed 8 0(0) << 1(1) = 0(0)\n  signed 8 0(0) << 2(2) = 0(0)\n  signed 8 0(0) << 3(3) = 0(0)\n  signed 8 0(0) << 4(4) = 0(0)\n  signed 8 0(0) << 5(5) = 0(0)\n  signed 8 0(0) << 6(6) = 0(0)\n  signed 8 0(0) << 7(7) = 0(0)\n  signed 8 0(0) << 8(8) = 0(0)\n  signed 8 0(0) << 9(9) = 0(0)\n  signed 8 0(0) << 10(a) = 0(0)\n  signed 8 0(0) << 11(b) = 0(0)\n  signed 8 0(0) << 12(c) = 0(0)\n  signed 8 0(0) << 13(d) = 0(0)\n  signed 8 0(0) << 14(e) = 0(0)\n  signed 8 0(0) << 15(f) = 0(0)\n  signed 8 0(0) << 16(10) = 0(0)\n  signed 8 0(0) << 17(11) = 0(0)\n  signed 8 0(0) << 18(12) = 0(0)\n  signed 8 0(0) << 19(13) = 0(0)\n  signed 8 0(0) << 20(14) = 0(0)\n  signed 8 0(0) << 21(15) = 0(0)\n  signed 8 0(0) << 22(16) = 0(0)\n  signed 8 0(0) << 23(17) = 0(0)\n  signed 8 0(0) << 24(18) = 0(0)\n  signed 8 0(0) << 25(19) = 0(0)\n  signed 8 0(0) << 26(1a) = 0(0)\n  signed 8 0(0) << 27(1b) = 0(0)\n  signed 8 0(0) << 28(1c) = 0(0)\n  signed 8 0(0) << 29(1d) = 0(0)\n  signed 8 0(0) << 30(1e) = 0(0)\n  signed 8 0(0) << 31(1f) = 0(0)\n  signed 8 0(0) << 32(20) = 0(0)\n  signed 8 0(0) << 33(21) = 0(0)\n  signed 8 0(0) << 34(22) = 0(0)\n  signed 8 0(0) << 35(23) = 0(0)\n  signed 8 0(0) << 36(24) = 0(0)\n  signed 8 0(0) << 37(25) = 0(0)\n  signed 8 0(0) << 38(26) = 0(0)\n  signed 8 0(0) << 39(27) = 0(0)\n  signed 8 0(0) << 40(28) = 0(0)\n  signed 8 0(0) << 41(29) = 0(0)\n  signed 8 0(0) << 42(2a) = 0(0)\n  signed 8 0(0) << 43(2b) = 0(0)\n  signed 8 0(0) << 44(2c) = 0(0)\n  signed 8 0(0) << 45(2d) = 0(0)\n  signed 8 0(0) << 46(2e) = 0(0)\n  signed 8 0(0) << 47(2f) = 0(0)\n  signed 8 0(0) << 48(30) = 0(0)\n  signed 8 0(0) << 49(31) = 0(0)\n  signed 8 0(0) << 50(32) = 0(0)\n  signed 8 0(0) << 51(33) = 0(0)\n  signed 8 0(0) << 52(34) = 0(0)\n  signed 8 0(0) << 53(35) = 0(0)\n  signed 8 0(0) << 54(36) = 0(0)\n  signed 8 0(0) << 55(37) = 0(0)\n  signed 8 0(0) << 56(38) = 0(0)\n  signed 8 0(0) << 57(39) = 0(0)\n  signed 8 0(0) << 58(3a) = 0(0)\n  signed 8 0(0) << 59(3b) = 0(0)\n  signed 8 0(0) << 60(3c) = 0(0)\n  signed 8 0(0) << 61(3d) = 0(0)\n  signed 8 0(0) << 62(3e) = 0(0)\n  signed 8 0(0) << 63(3f) = 0(0)\n  signed 8 0(0) << 64(40) = 0(0)\n  signed 8 0(0) << 65(41) = 0(0)\n  signed 8 0(0) << 66(42) = 0(0)\n  signed 8 0(0) << 67(43) = 0(0)\n  signed 8 0(0) << 68(44) = 0(0)\n  signed 8 0(0) << 69(45) = 0(0)\n  signed 8 0(0) << 70(46) = 0(0)\n  signed 8 0(0) << 71(47) = 0(0)\n  signed 8 0(0) << 72(48) = 0(0)\n  signed 8 0(0) << 73(49) = 0(0)\n  signed 8 0(0) << 74(4a) = 0(0)\n  signed 8 0(0) << 75(4b) = 0(0)\n  signed 8 0(0) << 76(4c) = 0(0)\n  signed 8 0(0) << 77(4d) = 0(0)\n  signed 8 0(0) << 78(4e) = 0(0)\n  signed 8 0(0) << 79(4f) = 0(0)\n  signed 8 0(0) << 80(50) = 0(0)\n  signed 8 0(0) << 81(51) = 0(0)\n  signed 8 0(0) << 82(52) = 0(0)\n  signed 8 0(0) << 83(53) = 0(0)\n  signed 8 0(0) << 84(54) = 0(0)\n  signed 8 0(0) << 85(55) = 0(0)\n  signed 8 0(0) << 86(56) = 0(0)\n  signed 8 0(0) << 87(57) = 0(0)\n  signed 8 0(0) << 88(58) = 0(0)\n  signed 8 0(0) << 89(59) = 0(0)\n  signed 8 0(0) << 90(5a) = 0(0)\n  signed 8 0(0) << 91(5b) = 0(0)\n  signed 8 0(0) << 92(5c) = 0(0)\n  signed 8 0(0) << 93(5d) = 0(0)\n  signed 8 0(0) << 94(5e) = 0(0)\n  signed 8 0(0) << 95(5f) = 0(0)\n  signed 8 0(0) << 96(60) = 0(0)\n  signed 8 0(0) << 97(61) = 0(0)\n  signed 8 0(0) << 98(62) = 0(0)\n  signed 8 0(0) << 99(63) = 0(0)\n  signed 8 0(0) << 100(64) = 0(0)\n  signed 8 0(0) << 101(65) = 0(0)\n  signed 8 0(0) << 102(66) = 0(0)\n  signed 8 0(0) << 103(67) = 0(0)\n  signed 8 0(0) << 104(68) = 0(0)\n  signed 8 0(0) << 105(69) = 0(0)\n  signed 8 0(0) << 106(6a) = 0(0)\n  signed 8 0(0) << 107(6b) = 0(0)\n  signed 8 0(0) << 108(6c) = 0(0)\n  signed 8 0(0) << 109(6d) = 0(0)\n  signed 8 0(0) << 110(6e) = 0(0)\n  signed 8 0(0) << 111(6f) = 0(0)\n  signed 8 0(0) << 112(70) = 0(0)\n  signed 8 0(0) << 113(71) = 0(0)\n  signed 8 0(0) << 114(72) = 0(0)\n  signed 8 0(0) << 115(73) = 0(0)\n  signed 8 0(0) << 116(74) = 0(0)\n  signed 8 0(0) << 117(75) = 0(0)\n  signed 8 0(0) << 118(76) = 0(0)\n  signed 8 0(0) << 119(77) = 0(0)\n  signed 8 0(0) << 120(78) = 0(0)\n  signed 8 0(0) << 121(79) = 0(0)\n  signed 8 0(0) << 122(7a) = 0(0)\n  signed 8 0(0) << 123(7b) = 0(0)\n  signed 8 0(0) << 124(7c) = 0(0)\n  signed 8 0(0) << 125(7d) = 0(0)\n  signed 8 0(0) << 126(7e) = 0(0)\n  signed 8 0(0) << 127(7f) = 0(0)\n  signed 8 1(1) << -128(ffffff80) = 1(1)\n  signed 8 1(1) << -127(ffffff81) = 2(2)\n  signed 8 1(1) << -126(ffffff82) = 4(4)\n  signed 8 1(1) << -125(ffffff83) = 8(8)\n  signed 8 1(1) << -124(ffffff84) = 16(10)\n  signed 8 1(1) << -123(ffffff85) = 32(20)\n  signed 8 1(1) << -122(ffffff86) = 64(40)\n  signed 8 1(1) << -121(ffffff87) = 128(80)\n  signed 8 1(1) << -120(ffffff88) = 256(0)\n  signed 8 1(1) << -119(ffffff89) = 512(0)\n  signed 8 1(1) << -118(ffffff8a) = 1024(0)\n  signed 8 1(1) << -117(ffffff8b) = 2048(0)\n  signed 8 1(1) << -116(ffffff8c) = 4096(0)\n  signed 8 1(1) << -115(ffffff8d) = 8192(0)\n  signed 8 1(1) << -114(ffffff8e) = 16384(0)\n  signed 8 1(1) << -113(ffffff8f) = 32768(0)\n  signed 8 1(1) << -112(ffffff90) = 65536(0)\n  signed 8 1(1) << -111(ffffff91) = 131072(0)\n  signed 8 1(1) << -110(ffffff92) = 262144(0)\n  signed 8 1(1) << -109(ffffff93) = 524288(0)\n  signed 8 1(1) << -108(ffffff94) = 1048576(0)\n  signed 8 1(1) << -107(ffffff95) = 2097152(0)\n  signed 8 1(1) << -106(ffffff96) = 4194304(0)\n  signed 8 1(1) << -105(ffffff97) = 8388608(0)\n  signed 8 1(1) << -104(ffffff98) = 16777216(0)\n  signed 8 1(1) << -103(ffffff99) = 33554432(0)\n  signed 8 1(1) << -102(ffffff9a) = 67108864(0)\n  signed 8 1(1) << -101(ffffff9b) = 134217728(0)\n  signed 8 1(1) << -100(ffffff9c) = 268435456(0)\n  signed 8 1(1) << -99(ffffff9d) = 536870912(0)\n  signed 8 1(1) << -98(ffffff9e) = 1073741824(0)\n  signed 8 1(1) << -97(ffffff9f) = -2147483648(0)\n  signed 8 1(1) << -96(ffffffa0) = 1(1)\n  signed 8 1(1) << -95(ffffffa1) = 2(2)\n  signed 8 1(1) << -94(ffffffa2) = 4(4)\n  signed 8 1(1) << -93(ffffffa3) = 8(8)\n  signed 8 1(1) << -92(ffffffa4) = 16(10)\n  signed 8 1(1) << -91(ffffffa5) = 32(20)\n  signed 8 1(1) << -90(ffffffa6) = 64(40)\n  signed 8 1(1) << -89(ffffffa7) = 128(80)\n  signed 8 1(1) << -88(ffffffa8) = 256(0)\n  signed 8 1(1) << -87(ffffffa9) = 512(0)\n  signed 8 1(1) << -86(ffffffaa) = 1024(0)\n  signed 8 1(1) << -85(ffffffab) = 2048(0)\n  signed 8 1(1) << -84(ffffffac) = 4096(0)\n  signed 8 1(1) << -83(ffffffad) = 8192(0)\n  signed 8 1(1) << -82(ffffffae) = 16384(0)\n  signed 8 1(1) << -81(ffffffaf) = 32768(0)\n  signed 8 1(1) << -80(ffffffb0) = 65536(0)\n  signed 8 1(1) << -79(ffffffb1) = 131072(0)\n  signed 8 1(1) << -78(ffffffb2) = 262144(0)\n  signed 8 1(1) << -77(ffffffb3) = 524288(0)\n  signed 8 1(1) << -76(ffffffb4) = 1048576(0)\n  signed 8 1(1) << -75(ffffffb5) = 2097152(0)\n  signed 8 1(1) << -74(ffffffb6) = 4194304(0)\n  signed 8 1(1) << -73(ffffffb7) = 8388608(0)\n  signed 8 1(1) << -72(ffffffb8) = 16777216(0)\n  signed 8 1(1) << -71(ffffffb9) = 33554432(0)\n  signed 8 1(1) << -70(ffffffba) = 67108864(0)\n  signed 8 1(1) << -69(ffffffbb) = 134217728(0)\n  signed 8 1(1) << -68(ffffffbc) = 268435456(0)\n  signed 8 1(1) << -67(ffffffbd) = 536870912(0)\n  signed 8 1(1) << -66(ffffffbe) = 1073741824(0)\n  signed 8 1(1) << -65(ffffffbf) = -2147483648(0)\n  signed 8 1(1) << -64(ffffffc0) = 1(1)\n  signed 8 1(1) << -63(ffffffc1) = 2(2)\n  signed 8 1(1) << -62(ffffffc2) = 4(4)\n  signed 8 1(1) << -61(ffffffc3) = 8(8)\n  signed 8 1(1) << -60(ffffffc4) = 16(10)\n  signed 8 1(1) << -59(ffffffc5) = 32(20)\n  signed 8 1(1) << -58(ffffffc6) = 64(40)\n  signed 8 1(1) << -57(ffffffc7) = 128(80)\n  signed 8 1(1) << -56(ffffffc8) = 256(0)\n  signed 8 1(1) << -55(ffffffc9) = 512(0)\n  signed 8 1(1) << -54(ffffffca) = 1024(0)\n  signed 8 1(1) << -53(ffffffcb) = 2048(0)\n  signed 8 1(1) << -52(ffffffcc) = 4096(0)\n  signed 8 1(1) << -51(ffffffcd) = 8192(0)\n  signed 8 1(1) << -50(ffffffce) = 16384(0)\n  signed 8 1(1) << -49(ffffffcf) = 32768(0)\n  signed 8 1(1) << -48(ffffffd0) = 65536(0)\n  signed 8 1(1) << -47(ffffffd1) = 131072(0)\n  signed 8 1(1) << -46(ffffffd2) = 262144(0)\n  signed 8 1(1) << -45(ffffffd3) = 524288(0)\n  signed 8 1(1) << -44(ffffffd4) = 1048576(0)\n  signed 8 1(1) << -43(ffffffd5) = 2097152(0)\n  signed 8 1(1) << -42(ffffffd6) = 4194304(0)\n  signed 8 1(1) << -41(ffffffd7) = 8388608(0)\n  signed 8 1(1) << -40(ffffffd8) = 16777216(0)\n  signed 8 1(1) << -39(ffffffd9) = 33554432(0)\n  signed 8 1(1) << -38(ffffffda) = 67108864(0)\n  signed 8 1(1) << -37(ffffffdb) = 134217728(0)\n  signed 8 1(1) << -36(ffffffdc) = 268435456(0)\n  signed 8 1(1) << -35(ffffffdd) = 536870912(0)\n  signed 8 1(1) << -34(ffffffde) = 1073741824(0)\n  signed 8 1(1) << -33(ffffffdf) = -2147483648(0)\n  signed 8 1(1) << -32(ffffffe0) = 1(1)\n  signed 8 1(1) << -31(ffffffe1) = 2(2)\n  signed 8 1(1) << -30(ffffffe2) = 4(4)\n  signed 8 1(1) << -29(ffffffe3) = 8(8)\n  signed 8 1(1) << -28(ffffffe4) = 16(10)\n  signed 8 1(1) << -27(ffffffe5) = 32(20)\n  signed 8 1(1) << -26(ffffffe6) = 64(40)\n  signed 8 1(1) << -25(ffffffe7) = 128(80)\n  signed 8 1(1) << -24(ffffffe8) = 256(0)\n  signed 8 1(1) << -23(ffffffe9) = 512(0)\n  signed 8 1(1) << -22(ffffffea) = 1024(0)\n  signed 8 1(1) << -21(ffffffeb) = 2048(0)\n  signed 8 1(1) << -20(ffffffec) = 4096(0)\n  signed 8 1(1) << -19(ffffffed) = 8192(0)\n  signed 8 1(1) << -18(ffffffee) = 16384(0)\n  signed 8 1(1) << -17(ffffffef) = 32768(0)\n  signed 8 1(1) << -16(fffffff0) = 65536(0)\n  signed 8 1(1) << -15(fffffff1) = 131072(0)\n  signed 8 1(1) << -14(fffffff2) = 262144(0)\n  signed 8 1(1) << -13(fffffff3) = 524288(0)\n  signed 8 1(1) << -12(fffffff4) = 1048576(0)\n  signed 8 1(1) << -11(fffffff5) = 2097152(0)\n  signed 8 1(1) << -10(fffffff6) = 4194304(0)\n  signed 8 1(1) << -9(fffffff7) = 8388608(0)\n  signed 8 1(1) << -8(fffffff8) = 16777216(0)\n  signed 8 1(1) << -7(fffffff9) = 33554432(0)\n  signed 8 1(1) << -6(fffffffa) = 67108864(0)\n  signed 8 1(1) << -5(fffffffb) = 134217728(0)\n  signed 8 1(1) << -4(fffffffc) = 268435456(0)\n  signed 8 1(1) << -3(fffffffd) = 536870912(0)\n  signed 8 1(1) << -2(fffffffe) = 1073741824(0)\n  signed 8 1(1) << -1(ffffffff) = -2147483648(0)\n  signed 8 1(1) << 0(0) = 1(1)\n  signed 8 1(1) << 1(1) = 2(2)\n  signed 8 1(1) << 2(2) = 4(4)\n  signed 8 1(1) << 3(3) = 8(8)\n  signed 8 1(1) << 4(4) = 16(10)\n  signed 8 1(1) << 5(5) = 32(20)\n  signed 8 1(1) << 6(6) = 64(40)\n  signed 8 1(1) << 7(7) = 128(80)\n  signed 8 1(1) << 8(8) = 256(0)\n  signed 8 1(1) << 9(9) = 512(0)\n  signed 8 1(1) << 10(a) = 1024(0)\n  signed 8 1(1) << 11(b) = 2048(0)\n  signed 8 1(1) << 12(c) = 4096(0)\n  signed 8 1(1) << 13(d) = 8192(0)\n  signed 8 1(1) << 14(e) = 16384(0)\n  signed 8 1(1) << 15(f) = 32768(0)\n  signed 8 1(1) << 16(10) = 65536(0)\n  signed 8 1(1) << 17(11) = 131072(0)\n  signed 8 1(1) << 18(12) = 262144(0)\n  signed 8 1(1) << 19(13) = 524288(0)\n  signed 8 1(1) << 20(14) = 1048576(0)\n  signed 8 1(1) << 21(15) = 2097152(0)\n  signed 8 1(1) << 22(16) = 4194304(0)\n  signed 8 1(1) << 23(17) = 8388608(0)\n  signed 8 1(1) << 24(18) = 16777216(0)\n  signed 8 1(1) << 25(19) = 33554432(0)\n  signed 8 1(1) << 26(1a) = 67108864(0)\n  signed 8 1(1) << 27(1b) = 134217728(0)\n  signed 8 1(1) << 28(1c) = 268435456(0)\n  signed 8 1(1) << 29(1d) = 536870912(0)\n  signed 8 1(1) << 30(1e) = 1073741824(0)\n  signed 8 1(1) << 31(1f) = -2147483648(0)\n  signed 8 1(1) << 32(20) = 1(1)\n  signed 8 1(1) << 33(21) = 2(2)\n  signed 8 1(1) << 34(22) = 4(4)\n  signed 8 1(1) << 35(23) = 8(8)\n  signed 8 1(1) << 36(24) = 16(10)\n  signed 8 1(1) << 37(25) = 32(20)\n  signed 8 1(1) << 38(26) = 64(40)\n  signed 8 1(1) << 39(27) = 128(80)\n  signed 8 1(1) << 40(28) = 256(0)\n  signed 8 1(1) << 41(29) = 512(0)\n  signed 8 1(1) << 42(2a) = 1024(0)\n  signed 8 1(1) << 43(2b) = 2048(0)\n  signed 8 1(1) << 44(2c) = 4096(0)\n  signed 8 1(1) << 45(2d) = 8192(0)\n  signed 8 1(1) << 46(2e) = 16384(0)\n  signed 8 1(1) << 47(2f) = 32768(0)\n  signed 8 1(1) << 48(30) = 65536(0)\n  signed 8 1(1) << 49(31) = 131072(0)\n  signed 8 1(1) << 50(32) = 262144(0)\n  signed 8 1(1) << 51(33) = 524288(0)\n  signed 8 1(1) << 52(34) = 1048576(0)\n  signed 8 1(1) << 53(35) = 2097152(0)\n  signed 8 1(1) << 54(36) = 4194304(0)\n  signed 8 1(1) << 55(37) = 8388608(0)\n  signed 8 1(1) << 56(38) = 16777216(0)\n  signed 8 1(1) << 57(39) = 33554432(0)\n  signed 8 1(1) << 58(3a) = 67108864(0)\n  signed 8 1(1) << 59(3b) = 134217728(0)\n  signed 8 1(1) << 60(3c) = 268435456(0)\n  signed 8 1(1) << 61(3d) = 536870912(0)\n  signed 8 1(1) << 62(3e) = 1073741824(0)\n  signed 8 1(1) << 63(3f) = -2147483648(0)\n  signed 8 1(1) << 64(40) = 1(1)\n  signed 8 1(1) << 65(41) = 2(2)\n  signed 8 1(1) << 66(42) = 4(4)\n  signed 8 1(1) << 67(43) = 8(8)\n  signed 8 1(1) << 68(44) = 16(10)\n  signed 8 1(1) << 69(45) = 32(20)\n  signed 8 1(1) << 70(46) = 64(40)\n  signed 8 1(1) << 71(47) = 128(80)\n  signed 8 1(1) << 72(48) = 256(0)\n  signed 8 1(1) << 73(49) = 512(0)\n  signed 8 1(1) << 74(4a) = 1024(0)\n  signed 8 1(1) << 75(4b) = 2048(0)\n  signed 8 1(1) << 76(4c) = 4096(0)\n  signed 8 1(1) << 77(4d) = 8192(0)\n  signed 8 1(1) << 78(4e) = 16384(0)\n  signed 8 1(1) << 79(4f) = 32768(0)\n  signed 8 1(1) << 80(50) = 65536(0)\n  signed 8 1(1) << 81(51) = 131072(0)\n  signed 8 1(1) << 82(52) = 262144(0)\n  signed 8 1(1) << 83(53) = 524288(0)\n  signed 8 1(1) << 84(54) = 1048576(0)\n  signed 8 1(1) << 85(55) = 2097152(0)\n  signed 8 1(1) << 86(56) = 4194304(0)\n  signed 8 1(1) << 87(57) = 8388608(0)\n  signed 8 1(1) << 88(58) = 16777216(0)\n  signed 8 1(1) << 89(59) = 33554432(0)\n  signed 8 1(1) << 90(5a) = 67108864(0)\n  signed 8 1(1) << 91(5b) = 134217728(0)\n  signed 8 1(1) << 92(5c) = 268435456(0)\n  signed 8 1(1) << 93(5d) = 536870912(0)\n  signed 8 1(1) << 94(5e) = 1073741824(0)\n  signed 8 1(1) << 95(5f) = -2147483648(0)\n  signed 8 1(1) << 96(60) = 1(1)\n  signed 8 1(1) << 97(61) = 2(2)\n  signed 8 1(1) << 98(62) = 4(4)\n  signed 8 1(1) << 99(63) = 8(8)\n  signed 8 1(1) << 100(64) = 16(10)\n  signed 8 1(1) << 101(65) = 32(20)\n  signed 8 1(1) << 102(66) = 64(40)\n  signed 8 1(1) << 103(67) = 128(80)\n  signed 8 1(1) << 104(68) = 256(0)\n  signed 8 1(1) << 105(69) = 512(0)\n  signed 8 1(1) << 106(6a) = 1024(0)\n  signed 8 1(1) << 107(6b) = 2048(0)\n  signed 8 1(1) << 108(6c) = 4096(0)\n  signed 8 1(1) << 109(6d) = 8192(0)\n  signed 8 1(1) << 110(6e) = 16384(0)\n  signed 8 1(1) << 111(6f) = 32768(0)\n  signed 8 1(1) << 112(70) = 65536(0)\n  signed 8 1(1) << 113(71) = 131072(0)\n  signed 8 1(1) << 114(72) = 262144(0)\n  signed 8 1(1) << 115(73) = 524288(0)\n  signed 8 1(1) << 116(74) = 1048576(0)\n  signed 8 1(1) << 117(75) = 2097152(0)\n  signed 8 1(1) << 118(76) = 4194304(0)\n  signed 8 1(1) << 119(77) = 8388608(0)\n  signed 8 1(1) << 120(78) = 16777216(0)\n  signed 8 1(1) << 121(79) = 33554432(0)\n  signed 8 1(1) << 122(7a) = 67108864(0)\n  signed 8 1(1) << 123(7b) = 134217728(0)\n  signed 8 1(1) << 124(7c) = 268435456(0)\n  signed 8 1(1) << 125(7d) = 536870912(0)\n  signed 8 1(1) << 126(7e) = 1073741824(0)\n  signed 8 1(1) << 127(7f) = -2147483648(0)\n  signed 8 2(2) << -128(ffffff80) = 2(2)\n  signed 8 2(2) << -127(ffffff81) = 4(4)\n  signed 8 2(2) << -126(ffffff82) = 8(8)\n  signed 8 2(2) << -125(ffffff83) = 16(10)\n  signed 8 2(2) << -124(ffffff84) = 32(20)\n  signed 8 2(2) << -123(ffffff85) = 64(40)\n  signed 8 2(2) << -122(ffffff86) = 128(80)\n  signed 8 2(2) << -121(ffffff87) = 256(0)\n  signed 8 2(2) << -120(ffffff88) = 512(0)\n  signed 8 2(2) << -119(ffffff89) = 1024(0)\n  signed 8 2(2) << -118(ffffff8a) = 2048(0)\n  signed 8 2(2) << -117(ffffff8b) = 4096(0)\n  signed 8 2(2) << -116(ffffff8c) = 8192(0)\n  signed 8 2(2) << -115(ffffff8d) = 16384(0)\n  signed 8 2(2) << -114(ffffff8e) = 32768(0)\n  signed 8 2(2) << -113(ffffff8f) = 65536(0)\n  signed 8 2(2) << -112(ffffff90) = 131072(0)\n  signed 8 2(2) << -111(ffffff91) = 262144(0)\n  signed 8 2(2) << -110(ffffff92) = 524288(0)\n  signed 8 2(2) << -109(ffffff93) = 1048576(0)\n  signed 8 2(2) << -108(ffffff94) = 2097152(0)\n  signed 8 2(2) << -107(ffffff95) = 4194304(0)\n  signed 8 2(2) << -106(ffffff96) = 8388608(0)\n  signed 8 2(2) << -105(ffffff97) = 16777216(0)\n  signed 8 2(2) << -104(ffffff98) = 33554432(0)\n  signed 8 2(2) << -103(ffffff99) = 67108864(0)\n  signed 8 2(2) << -102(ffffff9a) = 134217728(0)\n  signed 8 2(2) << -101(ffffff9b) = 268435456(0)\n  signed 8 2(2) << -100(ffffff9c) = 536870912(0)\n  signed 8 2(2) << -99(ffffff9d) = 1073741824(0)\n  signed 8 2(2) << -98(ffffff9e) = -2147483648(0)\n  signed 8 2(2) << -97(ffffff9f) = 0(0)\n  signed 8 2(2) << -96(ffffffa0) = 2(2)\n  signed 8 2(2) << -95(ffffffa1) = 4(4)\n  signed 8 2(2) << -94(ffffffa2) = 8(8)\n  signed 8 2(2) << -93(ffffffa3) = 16(10)\n  signed 8 2(2) << -92(ffffffa4) = 32(20)\n  signed 8 2(2) << -91(ffffffa5) = 64(40)\n  signed 8 2(2) << -90(ffffffa6) = 128(80)\n  signed 8 2(2) << -89(ffffffa7) = 256(0)\n  signed 8 2(2) << -88(ffffffa8) = 512(0)\n  signed 8 2(2) << -87(ffffffa9) = 1024(0)\n  signed 8 2(2) << -86(ffffffaa) = 2048(0)\n  signed 8 2(2) << -85(ffffffab) = 4096(0)\n  signed 8 2(2) << -84(ffffffac) = 8192(0)\n  signed 8 2(2) << -83(ffffffad) = 16384(0)\n  signed 8 2(2) << -82(ffffffae) = 32768(0)\n  signed 8 2(2) << -81(ffffffaf) = 65536(0)\n  signed 8 2(2) << -80(ffffffb0) = 131072(0)\n  signed 8 2(2) << -79(ffffffb1) = 262144(0)\n  signed 8 2(2) << -78(ffffffb2) = 524288(0)\n  signed 8 2(2) << -77(ffffffb3) = 1048576(0)\n  signed 8 2(2) << -76(ffffffb4) = 2097152(0)\n  signed 8 2(2) << -75(ffffffb5) = 4194304(0)\n  signed 8 2(2) << -74(ffffffb6) = 8388608(0)\n  signed 8 2(2) << -73(ffffffb7) = 16777216(0)\n  signed 8 2(2) << -72(ffffffb8) = 33554432(0)\n  signed 8 2(2) << -71(ffffffb9) = 67108864(0)\n  signed 8 2(2) << -70(ffffffba) = 134217728(0)\n  signed 8 2(2) << -69(ffffffbb) = 268435456(0)\n  signed 8 2(2) << -68(ffffffbc) = 536870912(0)\n  signed 8 2(2) << -67(ffffffbd) = 1073741824(0)\n  signed 8 2(2) << -66(ffffffbe) = -2147483648(0)\n  signed 8 2(2) << -65(ffffffbf) = 0(0)\n  signed 8 2(2) << -64(ffffffc0) = 2(2)\n  signed 8 2(2) << -63(ffffffc1) = 4(4)\n  signed 8 2(2) << -62(ffffffc2) = 8(8)\n  signed 8 2(2) << -61(ffffffc3) = 16(10)\n  signed 8 2(2) << -60(ffffffc4) = 32(20)\n  signed 8 2(2) << -59(ffffffc5) = 64(40)\n  signed 8 2(2) << -58(ffffffc6) = 128(80)\n  signed 8 2(2) << -57(ffffffc7) = 256(0)\n  signed 8 2(2) << -56(ffffffc8) = 512(0)\n  signed 8 2(2) << -55(ffffffc9) = 1024(0)\n  signed 8 2(2) << -54(ffffffca) = 2048(0)\n  signed 8 2(2) << -53(ffffffcb) = 4096(0)\n  signed 8 2(2) << -52(ffffffcc) = 8192(0)\n  signed 8 2(2) << -51(ffffffcd) = 16384(0)\n  signed 8 2(2) << -50(ffffffce) = 32768(0)\n  signed 8 2(2) << -49(ffffffcf) = 65536(0)\n  signed 8 2(2) << -48(ffffffd0) = 131072(0)\n  signed 8 2(2) << -47(ffffffd1) = 262144(0)\n  signed 8 2(2) << -46(ffffffd2) = 524288(0)\n  signed 8 2(2) << -45(ffffffd3) = 1048576(0)\n  signed 8 2(2) << -44(ffffffd4) = 2097152(0)\n  signed 8 2(2) << -43(ffffffd5) = 4194304(0)\n  signed 8 2(2) << -42(ffffffd6) = 8388608(0)\n  signed 8 2(2) << -41(ffffffd7) = 16777216(0)\n  signed 8 2(2) << -40(ffffffd8) = 33554432(0)\n  signed 8 2(2) << -39(ffffffd9) = 67108864(0)\n  signed 8 2(2) << -38(ffffffda) = 134217728(0)\n  signed 8 2(2) << -37(ffffffdb) = 268435456(0)\n  signed 8 2(2) << -36(ffffffdc) = 536870912(0)\n  signed 8 2(2) << -35(ffffffdd) = 1073741824(0)\n  signed 8 2(2) << -34(ffffffde) = -2147483648(0)\n  signed 8 2(2) << -33(ffffffdf) = 0(0)\n  signed 8 2(2) << -32(ffffffe0) = 2(2)\n  signed 8 2(2) << -31(ffffffe1) = 4(4)\n  signed 8 2(2) << -30(ffffffe2) = 8(8)\n  signed 8 2(2) << -29(ffffffe3) = 16(10)\n  signed 8 2(2) << -28(ffffffe4) = 32(20)\n  signed 8 2(2) << -27(ffffffe5) = 64(40)\n  signed 8 2(2) << -26(ffffffe6) = 128(80)\n  signed 8 2(2) << -25(ffffffe7) = 256(0)\n  signed 8 2(2) << -24(ffffffe8) = 512(0)\n  signed 8 2(2) << -23(ffffffe9) = 1024(0)\n  signed 8 2(2) << -22(ffffffea) = 2048(0)\n  signed 8 2(2) << -21(ffffffeb) = 4096(0)\n  signed 8 2(2) << -20(ffffffec) = 8192(0)\n  signed 8 2(2) << -19(ffffffed) = 16384(0)\n  signed 8 2(2) << -18(ffffffee) = 32768(0)\n  signed 8 2(2) << -17(ffffffef) = 65536(0)\n  signed 8 2(2) << -16(fffffff0) = 131072(0)\n  signed 8 2(2) << -15(fffffff1) = 262144(0)\n  signed 8 2(2) << -14(fffffff2) = 524288(0)\n  signed 8 2(2) << -13(fffffff3) = 1048576(0)\n  signed 8 2(2) << -12(fffffff4) = 2097152(0)\n  signed 8 2(2) << -11(fffffff5) = 4194304(0)\n  signed 8 2(2) << -10(fffffff6) = 8388608(0)\n  signed 8 2(2) << -9(fffffff7) = 16777216(0)\n  signed 8 2(2) << -8(fffffff8) = 33554432(0)\n  signed 8 2(2) << -7(fffffff9) = 67108864(0)\n  signed 8 2(2) << -6(fffffffa) = 134217728(0)\n  signed 8 2(2) << -5(fffffffb) = 268435456(0)\n  signed 8 2(2) << -4(fffffffc) = 536870912(0)\n  signed 8 2(2) << -3(fffffffd) = 1073741824(0)\n  signed 8 2(2) << -2(fffffffe) = -2147483648(0)\n  signed 8 2(2) << -1(ffffffff) = 0(0)\n  signed 8 2(2) << 0(0) = 2(2)\n  signed 8 2(2) << 1(1) = 4(4)\n  signed 8 2(2) << 2(2) = 8(8)\n  signed 8 2(2) << 3(3) = 16(10)\n  signed 8 2(2) << 4(4) = 32(20)\n  signed 8 2(2) << 5(5) = 64(40)\n  signed 8 2(2) << 6(6) = 128(80)\n  signed 8 2(2) << 7(7) = 256(0)\n  signed 8 2(2) << 8(8) = 512(0)\n  signed 8 2(2) << 9(9) = 1024(0)\n  signed 8 2(2) << 10(a) = 2048(0)\n  signed 8 2(2) << 11(b) = 4096(0)\n  signed 8 2(2) << 12(c) = 8192(0)\n  signed 8 2(2) << 13(d) = 16384(0)\n  signed 8 2(2) << 14(e) = 32768(0)\n  signed 8 2(2) << 15(f) = 65536(0)\n  signed 8 2(2) << 16(10) = 131072(0)\n  signed 8 2(2) << 17(11) = 262144(0)\n  signed 8 2(2) << 18(12) = 524288(0)\n  signed 8 2(2) << 19(13) = 1048576(0)\n  signed 8 2(2) << 20(14) = 2097152(0)\n  signed 8 2(2) << 21(15) = 4194304(0)\n  signed 8 2(2) << 22(16) = 8388608(0)\n  signed 8 2(2) << 23(17) = 16777216(0)\n  signed 8 2(2) << 24(18) = 33554432(0)\n  signed 8 2(2) << 25(19) = 67108864(0)\n  signed 8 2(2) << 26(1a) = 134217728(0)\n  signed 8 2(2) << 27(1b) = 268435456(0)\n  signed 8 2(2) << 28(1c) = 536870912(0)\n  signed 8 2(2) << 29(1d) = 1073741824(0)\n  signed 8 2(2) << 30(1e) = -2147483648(0)\n  signed 8 2(2) << 31(1f) = 0(0)\n  signed 8 2(2) << 32(20) = 2(2)\n  signed 8 2(2) << 33(21) = 4(4)\n  signed 8 2(2) << 34(22) = 8(8)\n  signed 8 2(2) << 35(23) = 16(10)\n  signed 8 2(2) << 36(24) = 32(20)\n  signed 8 2(2) << 37(25) = 64(40)\n  signed 8 2(2) << 38(26) = 128(80)\n  signed 8 2(2) << 39(27) = 256(0)\n  signed 8 2(2) << 40(28) = 512(0)\n  signed 8 2(2) << 41(29) = 1024(0)\n  signed 8 2(2) << 42(2a) = 2048(0)\n  signed 8 2(2) << 43(2b) = 4096(0)\n  signed 8 2(2) << 44(2c) = 8192(0)\n  signed 8 2(2) << 45(2d) = 16384(0)\n  signed 8 2(2) << 46(2e) = 32768(0)\n  signed 8 2(2) << 47(2f) = 65536(0)\n  signed 8 2(2) << 48(30) = 131072(0)\n  signed 8 2(2) << 49(31) = 262144(0)\n  signed 8 2(2) << 50(32) = 524288(0)\n  signed 8 2(2) << 51(33) = 1048576(0)\n  signed 8 2(2) << 52(34) = 2097152(0)\n  signed 8 2(2) << 53(35) = 4194304(0)\n  signed 8 2(2) << 54(36) = 8388608(0)\n  signed 8 2(2) << 55(37) = 16777216(0)\n  signed 8 2(2) << 56(38) = 33554432(0)\n  signed 8 2(2) << 57(39) = 67108864(0)\n  signed 8 2(2) << 58(3a) = 134217728(0)\n  signed 8 2(2) << 59(3b) = 268435456(0)\n  signed 8 2(2) << 60(3c) = 536870912(0)\n  signed 8 2(2) << 61(3d) = 1073741824(0)\n  signed 8 2(2) << 62(3e) = -2147483648(0)\n  signed 8 2(2) << 63(3f) = 0(0)\n  signed 8 2(2) << 64(40) = 2(2)\n  signed 8 2(2) << 65(41) = 4(4)\n  signed 8 2(2) << 66(42) = 8(8)\n  signed 8 2(2) << 67(43) = 16(10)\n  signed 8 2(2) << 68(44) = 32(20)\n  signed 8 2(2) << 69(45) = 64(40)\n  signed 8 2(2) << 70(46) = 128(80)\n  signed 8 2(2) << 71(47) = 256(0)\n  signed 8 2(2) << 72(48) = 512(0)\n  signed 8 2(2) << 73(49) = 1024(0)\n  signed 8 2(2) << 74(4a) = 2048(0)\n  signed 8 2(2) << 75(4b) = 4096(0)\n  signed 8 2(2) << 76(4c) = 8192(0)\n  signed 8 2(2) << 77(4d) = 16384(0)\n  signed 8 2(2) << 78(4e) = 32768(0)\n  signed 8 2(2) << 79(4f) = 65536(0)\n  signed 8 2(2) << 80(50) = 131072(0)\n  signed 8 2(2) << 81(51) = 262144(0)\n  signed 8 2(2) << 82(52) = 524288(0)\n  signed 8 2(2) << 83(53) = 1048576(0)\n  signed 8 2(2) << 84(54) = 2097152(0)\n  signed 8 2(2) << 85(55) = 4194304(0)\n  signed 8 2(2) << 86(56) = 8388608(0)\n  signed 8 2(2) << 87(57) = 16777216(0)\n  signed 8 2(2) << 88(58) = 33554432(0)\n  signed 8 2(2) << 89(59) = 67108864(0)\n  signed 8 2(2) << 90(5a) = 134217728(0)\n  signed 8 2(2) << 91(5b) = 268435456(0)\n  signed 8 2(2) << 92(5c) = 536870912(0)\n  signed 8 2(2) << 93(5d) = 1073741824(0)\n  signed 8 2(2) << 94(5e) = -2147483648(0)\n  signed 8 2(2) << 95(5f) = 0(0)\n  signed 8 2(2) << 96(60) = 2(2)\n  signed 8 2(2) << 97(61) = 4(4)\n  signed 8 2(2) << 98(62) = 8(8)\n  signed 8 2(2) << 99(63) = 16(10)\n  signed 8 2(2) << 100(64) = 32(20)\n  signed 8 2(2) << 101(65) = 64(40)\n  signed 8 2(2) << 102(66) = 128(80)\n  signed 8 2(2) << 103(67) = 256(0)\n  signed 8 2(2) << 104(68) = 512(0)\n  signed 8 2(2) << 105(69) = 1024(0)\n  signed 8 2(2) << 106(6a) = 2048(0)\n  signed 8 2(2) << 107(6b) = 4096(0)\n  signed 8 2(2) << 108(6c) = 8192(0)\n  signed 8 2(2) << 109(6d) = 16384(0)\n  signed 8 2(2) << 110(6e) = 32768(0)\n  signed 8 2(2) << 111(6f) = 65536(0)\n  signed 8 2(2) << 112(70) = 131072(0)\n  signed 8 2(2) << 113(71) = 262144(0)\n  signed 8 2(2) << 114(72) = 524288(0)\n  signed 8 2(2) << 115(73) = 1048576(0)\n  signed 8 2(2) << 116(74) = 2097152(0)\n  signed 8 2(2) << 117(75) = 4194304(0)\n  signed 8 2(2) << 118(76) = 8388608(0)\n  signed 8 2(2) << 119(77) = 16777216(0)\n  signed 8 2(2) << 120(78) = 33554432(0)\n  signed 8 2(2) << 121(79) = 67108864(0)\n  signed 8 2(2) << 122(7a) = 134217728(0)\n  signed 8 2(2) << 123(7b) = 268435456(0)\n  signed 8 2(2) << 124(7c) = 536870912(0)\n  signed 8 2(2) << 125(7d) = 1073741824(0)\n  signed 8 2(2) << 126(7e) = -2147483648(0)\n  signed 8 2(2) << 127(7f) = 0(0)\n  signed 8 3(3) << -128(ffffff80) = 3(3)\n  signed 8 3(3) << -127(ffffff81) = 6(6)\n  signed 8 3(3) << -126(ffffff82) = 12(c)\n  signed 8 3(3) << -125(ffffff83) = 24(18)\n  signed 8 3(3) << -124(ffffff84) = 48(30)\n  signed 8 3(3) << -123(ffffff85) = 96(60)\n  signed 8 3(3) << -122(ffffff86) = 192(c0)\n  signed 8 3(3) << -121(ffffff87) = 384(80)\n  signed 8 3(3) << -120(ffffff88) = 768(0)\n  signed 8 3(3) << -119(ffffff89) = 1536(0)\n  signed 8 3(3) << -118(ffffff8a) = 3072(0)\n  signed 8 3(3) << -117(ffffff8b) = 6144(0)\n  signed 8 3(3) << -116(ffffff8c) = 12288(0)\n  signed 8 3(3) << -115(ffffff8d) = 24576(0)\n  signed 8 3(3) << -114(ffffff8e) = 49152(0)\n  signed 8 3(3) << -113(ffffff8f) = 98304(0)\n  signed 8 3(3) << -112(ffffff90) = 196608(0)\n  signed 8 3(3) << -111(ffffff91) = 393216(0)\n  signed 8 3(3) << -110(ffffff92) = 786432(0)\n  signed 8 3(3) << -109(ffffff93) = 1572864(0)\n  signed 8 3(3) << -108(ffffff94) = 3145728(0)\n  signed 8 3(3) << -107(ffffff95) = 6291456(0)\n  signed 8 3(3) << -106(ffffff96) = 12582912(0)\n  signed 8 3(3) << -105(ffffff97) = 25165824(0)\n  signed 8 3(3) << -104(ffffff98) = 50331648(0)\n  signed 8 3(3) << -103(ffffff99) = 100663296(0)\n  signed 8 3(3) << -102(ffffff9a) = 201326592(0)\n  signed 8 3(3) << -101(ffffff9b) = 402653184(0)\n  signed 8 3(3) << -100(ffffff9c) = 805306368(0)\n  signed 8 3(3) << -99(ffffff9d) = 1610612736(0)\n  signed 8 3(3) << -98(ffffff9e) = -1073741824(0)\n  signed 8 3(3) << -97(ffffff9f) = -2147483648(0)\n  signed 8 3(3) << -96(ffffffa0) = 3(3)\n  signed 8 3(3) << -95(ffffffa1) = 6(6)\n  signed 8 3(3) << -94(ffffffa2) = 12(c)\n  signed 8 3(3) << -93(ffffffa3) = 24(18)\n  signed 8 3(3) << -92(ffffffa4) = 48(30)\n  signed 8 3(3) << -91(ffffffa5) = 96(60)\n  signed 8 3(3) << -90(ffffffa6) = 192(c0)\n  signed 8 3(3) << -89(ffffffa7) = 384(80)\n  signed 8 3(3) << -88(ffffffa8) = 768(0)\n  signed 8 3(3) << -87(ffffffa9) = 1536(0)\n  signed 8 3(3) << -86(ffffffaa) = 3072(0)\n  signed 8 3(3) << -85(ffffffab) = 6144(0)\n  signed 8 3(3) << -84(ffffffac) = 12288(0)\n  signed 8 3(3) << -83(ffffffad) = 24576(0)\n  signed 8 3(3) << -82(ffffffae) = 49152(0)\n  signed 8 3(3) << -81(ffffffaf) = 98304(0)\n  signed 8 3(3) << -80(ffffffb0) = 196608(0)\n  signed 8 3(3) << -79(ffffffb1) = 393216(0)\n  signed 8 3(3) << -78(ffffffb2) = 786432(0)\n  signed 8 3(3) << -77(ffffffb3) = 1572864(0)\n  signed 8 3(3) << -76(ffffffb4) = 3145728(0)\n  signed 8 3(3) << -75(ffffffb5) = 6291456(0)\n  signed 8 3(3) << -74(ffffffb6) = 12582912(0)\n  signed 8 3(3) << -73(ffffffb7) = 25165824(0)\n  signed 8 3(3) << -72(ffffffb8) = 50331648(0)\n  signed 8 3(3) << -71(ffffffb9) = 100663296(0)\n  signed 8 3(3) << -70(ffffffba) = 201326592(0)\n  signed 8 3(3) << -69(ffffffbb) = 402653184(0)\n  signed 8 3(3) << -68(ffffffbc) = 805306368(0)\n  signed 8 3(3) << -67(ffffffbd) = 1610612736(0)\n  signed 8 3(3) << -66(ffffffbe) = -1073741824(0)\n  signed 8 3(3) << -65(ffffffbf) = -2147483648(0)\n  signed 8 3(3) << -64(ffffffc0) = 3(3)\n  signed 8 3(3) << -63(ffffffc1) = 6(6)\n  signed 8 3(3) << -62(ffffffc2) = 12(c)\n  signed 8 3(3) << -61(ffffffc3) = 24(18)\n  signed 8 3(3) << -60(ffffffc4) = 48(30)\n  signed 8 3(3) << -59(ffffffc5) = 96(60)\n  signed 8 3(3) << -58(ffffffc6) = 192(c0)\n  signed 8 3(3) << -57(ffffffc7) = 384(80)\n  signed 8 3(3) << -56(ffffffc8) = 768(0)\n  signed 8 3(3) << -55(ffffffc9) = 1536(0)\n  signed 8 3(3) << -54(ffffffca) = 3072(0)\n  signed 8 3(3) << -53(ffffffcb) = 6144(0)\n  signed 8 3(3) << -52(ffffffcc) = 12288(0)\n  signed 8 3(3) << -51(ffffffcd) = 24576(0)\n  signed 8 3(3) << -50(ffffffce) = 49152(0)\n  signed 8 3(3) << -49(ffffffcf) = 98304(0)\n  signed 8 3(3) << -48(ffffffd0) = 196608(0)\n  signed 8 3(3) << -47(ffffffd1) = 393216(0)\n  signed 8 3(3) << -46(ffffffd2) = 786432(0)\n  signed 8 3(3) << -45(ffffffd3) = 1572864(0)\n  signed 8 3(3) << -44(ffffffd4) = 3145728(0)\n  signed 8 3(3) << -43(ffffffd5) = 6291456(0)\n  signed 8 3(3) << -42(ffffffd6) = 12582912(0)\n  signed 8 3(3) << -41(ffffffd7) = 25165824(0)\n  signed 8 3(3) << -40(ffffffd8) = 50331648(0)\n  signed 8 3(3) << -39(ffffffd9) = 100663296(0)\n  signed 8 3(3) << -38(ffffffda) = 201326592(0)\n  signed 8 3(3) << -37(ffffffdb) = 402653184(0)\n  signed 8 3(3) << -36(ffffffdc) = 805306368(0)\n  signed 8 3(3) << -35(ffffffdd) = 1610612736(0)\n  signed 8 3(3) << -34(ffffffde) = -1073741824(0)\n  signed 8 3(3) << -33(ffffffdf) = -2147483648(0)\n  signed 8 3(3) << -32(ffffffe0) = 3(3)\n  signed 8 3(3) << -31(ffffffe1) = 6(6)\n  signed 8 3(3) << -30(ffffffe2) = 12(c)\n  signed 8 3(3) << -29(ffffffe3) = 24(18)\n  signed 8 3(3) << -28(ffffffe4) = 48(30)\n  signed 8 3(3) << -27(ffffffe5) = 96(60)\n  signed 8 3(3) << -26(ffffffe6) = 192(c0)\n  signed 8 3(3) << -25(ffffffe7) = 384(80)\n  signed 8 3(3) << -24(ffffffe8) = 768(0)\n  signed 8 3(3) << -23(ffffffe9) = 1536(0)\n  signed 8 3(3) << -22(ffffffea) = 3072(0)\n  signed 8 3(3) << -21(ffffffeb) = 6144(0)\n  signed 8 3(3) << -20(ffffffec) = 12288(0)\n  signed 8 3(3) << -19(ffffffed) = 24576(0)\n  signed 8 3(3) << -18(ffffffee) = 49152(0)\n  signed 8 3(3) << -17(ffffffef) = 98304(0)\n  signed 8 3(3) << -16(fffffff0) = 196608(0)\n  signed 8 3(3) << -15(fffffff1) = 393216(0)\n  signed 8 3(3) << -14(fffffff2) = 786432(0)\n  signed 8 3(3) << -13(fffffff3) = 1572864(0)\n  signed 8 3(3) << -12(fffffff4) = 3145728(0)\n  signed 8 3(3) << -11(fffffff5) = 6291456(0)\n  signed 8 3(3) << -10(fffffff6) = 12582912(0)\n  signed 8 3(3) << -9(fffffff7) = 25165824(0)\n  signed 8 3(3) << -8(fffffff8) = 50331648(0)\n  signed 8 3(3) << -7(fffffff9) = 100663296(0)\n  signed 8 3(3) << -6(fffffffa) = 201326592(0)\n  signed 8 3(3) << -5(fffffffb) = 402653184(0)\n  signed 8 3(3) << -4(fffffffc) = 805306368(0)\n  signed 8 3(3) << -3(fffffffd) = 1610612736(0)\n  signed 8 3(3) << -2(fffffffe) = -1073741824(0)\n  signed 8 3(3) << -1(ffffffff) = -2147483648(0)\n  signed 8 3(3) << 0(0) = 3(3)\n  signed 8 3(3) << 1(1) = 6(6)\n  signed 8 3(3) << 2(2) = 12(c)\n  signed 8 3(3) << 3(3) = 24(18)\n  signed 8 3(3) << 4(4) = 48(30)\n  signed 8 3(3) << 5(5) = 96(60)\n  signed 8 3(3) << 6(6) = 192(c0)\n  signed 8 3(3) << 7(7) = 384(80)\n  signed 8 3(3) << 8(8) = 768(0)\n  signed 8 3(3) << 9(9) = 1536(0)\n  signed 8 3(3) << 10(a) = 3072(0)\n  signed 8 3(3) << 11(b) = 6144(0)\n  signed 8 3(3) << 12(c) = 12288(0)\n  signed 8 3(3) << 13(d) = 24576(0)\n  signed 8 3(3) << 14(e) = 49152(0)\n  signed 8 3(3) << 15(f) = 98304(0)\n  signed 8 3(3) << 16(10) = 196608(0)\n  signed 8 3(3) << 17(11) = 393216(0)\n  signed 8 3(3) << 18(12) = 786432(0)\n  signed 8 3(3) << 19(13) = 1572864(0)\n  signed 8 3(3) << 20(14) = 3145728(0)\n  signed 8 3(3) << 21(15) = 6291456(0)\n  signed 8 3(3) << 22(16) = 12582912(0)\n  signed 8 3(3) << 23(17) = 25165824(0)\n  signed 8 3(3) << 24(18) = 50331648(0)\n  signed 8 3(3) << 25(19) = 100663296(0)\n  signed 8 3(3) << 26(1a) = 201326592(0)\n  signed 8 3(3) << 27(1b) = 402653184(0)\n  signed 8 3(3) << 28(1c) = 805306368(0)\n  signed 8 3(3) << 29(1d) = 1610612736(0)\n  signed 8 3(3) << 30(1e) = -1073741824(0)\n  signed 8 3(3) << 31(1f) = -2147483648(0)\n  signed 8 3(3) << 32(20) = 3(3)\n  signed 8 3(3) << 33(21) = 6(6)\n  signed 8 3(3) << 34(22) = 12(c)\n  signed 8 3(3) << 35(23) = 24(18)\n  signed 8 3(3) << 36(24) = 48(30)\n  signed 8 3(3) << 37(25) = 96(60)\n  signed 8 3(3) << 38(26) = 192(c0)\n  signed 8 3(3) << 39(27) = 384(80)\n  signed 8 3(3) << 40(28) = 768(0)\n  signed 8 3(3) << 41(29) = 1536(0)\n  signed 8 3(3) << 42(2a) = 3072(0)\n  signed 8 3(3) << 43(2b) = 6144(0)\n  signed 8 3(3) << 44(2c) = 12288(0)\n  signed 8 3(3) << 45(2d) = 24576(0)\n  signed 8 3(3) << 46(2e) = 49152(0)\n  signed 8 3(3) << 47(2f) = 98304(0)\n  signed 8 3(3) << 48(30) = 196608(0)\n  signed 8 3(3) << 49(31) = 393216(0)\n  signed 8 3(3) << 50(32) = 786432(0)\n  signed 8 3(3) << 51(33) = 1572864(0)\n  signed 8 3(3) << 52(34) = 3145728(0)\n  signed 8 3(3) << 53(35) = 6291456(0)\n  signed 8 3(3) << 54(36) = 12582912(0)\n  signed 8 3(3) << 55(37) = 25165824(0)\n  signed 8 3(3) << 56(38) = 50331648(0)\n  signed 8 3(3) << 57(39) = 100663296(0)\n  signed 8 3(3) << 58(3a) = 201326592(0)\n  signed 8 3(3) << 59(3b) = 402653184(0)\n  signed 8 3(3) << 60(3c) = 805306368(0)\n  signed 8 3(3) << 61(3d) = 1610612736(0)\n  signed 8 3(3) << 62(3e) = -1073741824(0)\n  signed 8 3(3) << 63(3f) = -2147483648(0)\n  signed 8 3(3) << 64(40) = 3(3)\n  signed 8 3(3) << 65(41) = 6(6)\n  signed 8 3(3) << 66(42) = 12(c)\n  signed 8 3(3) << 67(43) = 24(18)\n  signed 8 3(3) << 68(44) = 48(30)\n  signed 8 3(3) << 69(45) = 96(60)\n  signed 8 3(3) << 70(46) = 192(c0)\n  signed 8 3(3) << 71(47) = 384(80)\n  signed 8 3(3) << 72(48) = 768(0)\n  signed 8 3(3) << 73(49) = 1536(0)\n  signed 8 3(3) << 74(4a) = 3072(0)\n  signed 8 3(3) << 75(4b) = 6144(0)\n  signed 8 3(3) << 76(4c) = 12288(0)\n  signed 8 3(3) << 77(4d) = 24576(0)\n  signed 8 3(3) << 78(4e) = 49152(0)\n  signed 8 3(3) << 79(4f) = 98304(0)\n  signed 8 3(3) << 80(50) = 196608(0)\n  signed 8 3(3) << 81(51) = 393216(0)\n  signed 8 3(3) << 82(52) = 786432(0)\n  signed 8 3(3) << 83(53) = 1572864(0)\n  signed 8 3(3) << 84(54) = 3145728(0)\n  signed 8 3(3) << 85(55) = 6291456(0)\n  signed 8 3(3) << 86(56) = 12582912(0)\n  signed 8 3(3) << 87(57) = 25165824(0)\n  signed 8 3(3) << 88(58) = 50331648(0)\n  signed 8 3(3) << 89(59) = 100663296(0)\n  signed 8 3(3) << 90(5a) = 201326592(0)\n  signed 8 3(3) << 91(5b) = 402653184(0)\n  signed 8 3(3) << 92(5c) = 805306368(0)\n  signed 8 3(3) << 93(5d) = 1610612736(0)\n  signed 8 3(3) << 94(5e) = -1073741824(0)\n  signed 8 3(3) << 95(5f) = -2147483648(0)\n  signed 8 3(3) << 96(60) = 3(3)\n  signed 8 3(3) << 97(61) = 6(6)\n  signed 8 3(3) << 98(62) = 12(c)\n  signed 8 3(3) << 99(63) = 24(18)\n  signed 8 3(3) << 100(64) = 48(30)\n  signed 8 3(3) << 101(65) = 96(60)\n  signed 8 3(3) << 102(66) = 192(c0)\n  signed 8 3(3) << 103(67) = 384(80)\n  signed 8 3(3) << 104(68) = 768(0)\n  signed 8 3(3) << 105(69) = 1536(0)\n  signed 8 3(3) << 106(6a) = 3072(0)\n  signed 8 3(3) << 107(6b) = 6144(0)\n  signed 8 3(3) << 108(6c) = 12288(0)\n  signed 8 3(3) << 109(6d) = 24576(0)\n  signed 8 3(3) << 110(6e) = 49152(0)\n  signed 8 3(3) << 111(6f) = 98304(0)\n  signed 8 3(3) << 112(70) = 196608(0)\n  signed 8 3(3) << 113(71) = 393216(0)\n  signed 8 3(3) << 114(72) = 786432(0)\n  signed 8 3(3) << 115(73) = 1572864(0)\n  signed 8 3(3) << 116(74) = 3145728(0)\n  signed 8 3(3) << 117(75) = 6291456(0)\n  signed 8 3(3) << 118(76) = 12582912(0)\n  signed 8 3(3) << 119(77) = 25165824(0)\n  signed 8 3(3) << 120(78) = 50331648(0)\n  signed 8 3(3) << 121(79) = 100663296(0)\n  signed 8 3(3) << 122(7a) = 201326592(0)\n  signed 8 3(3) << 123(7b) = 402653184(0)\n  signed 8 3(3) << 124(7c) = 805306368(0)\n  signed 8 3(3) << 125(7d) = 1610612736(0)\n  signed 8 3(3) << 126(7e) = -1073741824(0)\n  signed 8 3(3) << 127(7f) = -2147483648(0)\n  signed 8 4(4) << -128(ffffff80) = 4(4)\n  signed 8 4(4) << -127(ffffff81) = 8(8)\n  signed 8 4(4) << -126(ffffff82) = 16(10)\n  signed 8 4(4) << -125(ffffff83) = 32(20)\n  signed 8 4(4) << -124(ffffff84) = 64(40)\n  signed 8 4(4) << -123(ffffff85) = 128(80)\n  signed 8 4(4) << -122(ffffff86) = 256(0)\n  signed 8 4(4) << -121(ffffff87) = 512(0)\n  signed 8 4(4) << -120(ffffff88) = 1024(0)\n  signed 8 4(4) << -119(ffffff89) = 2048(0)\n  signed 8 4(4) << -118(ffffff8a) = 4096(0)\n  signed 8 4(4) << -117(ffffff8b) = 8192(0)\n  signed 8 4(4) << -116(ffffff8c) = 16384(0)\n  signed 8 4(4) << -115(ffffff8d) = 32768(0)\n  signed 8 4(4) << -114(ffffff8e) = 65536(0)\n  signed 8 4(4) << -113(ffffff8f) = 131072(0)\n  signed 8 4(4) << -112(ffffff90) = 262144(0)\n  signed 8 4(4) << -111(ffffff91) = 524288(0)\n  signed 8 4(4) << -110(ffffff92) = 1048576(0)\n  signed 8 4(4) << -109(ffffff93) = 2097152(0)\n  signed 8 4(4) << -108(ffffff94) = 4194304(0)\n  signed 8 4(4) << -107(ffffff95) = 8388608(0)\n  signed 8 4(4) << -106(ffffff96) = 16777216(0)\n  signed 8 4(4) << -105(ffffff97) = 33554432(0)\n  signed 8 4(4) << -104(ffffff98) = 67108864(0)\n  signed 8 4(4) << -103(ffffff99) = 134217728(0)\n  signed 8 4(4) << -102(ffffff9a) = 268435456(0)\n  signed 8 4(4) << -101(ffffff9b) = 536870912(0)\n  signed 8 4(4) << -100(ffffff9c) = 1073741824(0)\n  signed 8 4(4) << -99(ffffff9d) = -2147483648(0)\n  signed 8 4(4) << -98(ffffff9e) = 0(0)\n  signed 8 4(4) << -97(ffffff9f) = 0(0)\n  signed 8 4(4) << -96(ffffffa0) = 4(4)\n  signed 8 4(4) << -95(ffffffa1) = 8(8)\n  signed 8 4(4) << -94(ffffffa2) = 16(10)\n  signed 8 4(4) << -93(ffffffa3) = 32(20)\n  signed 8 4(4) << -92(ffffffa4) = 64(40)\n  signed 8 4(4) << -91(ffffffa5) = 128(80)\n  signed 8 4(4) << -90(ffffffa6) = 256(0)\n  signed 8 4(4) << -89(ffffffa7) = 512(0)\n  signed 8 4(4) << -88(ffffffa8) = 1024(0)\n  signed 8 4(4) << -87(ffffffa9) = 2048(0)\n  signed 8 4(4) << -86(ffffffaa) = 4096(0)\n  signed 8 4(4) << -85(ffffffab) = 8192(0)\n  signed 8 4(4) << -84(ffffffac) = 16384(0)\n  signed 8 4(4) << -83(ffffffad) = 32768(0)\n  signed 8 4(4) << -82(ffffffae) = 65536(0)\n  signed 8 4(4) << -81(ffffffaf) = 131072(0)\n  signed 8 4(4) << -80(ffffffb0) = 262144(0)\n  signed 8 4(4) << -79(ffffffb1) = 524288(0)\n  signed 8 4(4) << -78(ffffffb2) = 1048576(0)\n  signed 8 4(4) << -77(ffffffb3) = 2097152(0)\n  signed 8 4(4) << -76(ffffffb4) = 4194304(0)\n  signed 8 4(4) << -75(ffffffb5) = 8388608(0)\n  signed 8 4(4) << -74(ffffffb6) = 16777216(0)\n  signed 8 4(4) << -73(ffffffb7) = 33554432(0)\n  signed 8 4(4) << -72(ffffffb8) = 67108864(0)\n  signed 8 4(4) << -71(ffffffb9) = 134217728(0)\n  signed 8 4(4) << -70(ffffffba) = 268435456(0)\n  signed 8 4(4) << -69(ffffffbb) = 536870912(0)\n  signed 8 4(4) << -68(ffffffbc) = 1073741824(0)\n  signed 8 4(4) << -67(ffffffbd) = -2147483648(0)\n  signed 8 4(4) << -66(ffffffbe) = 0(0)\n  signed 8 4(4) << -65(ffffffbf) = 0(0)\n  signed 8 4(4) << -64(ffffffc0) = 4(4)\n  signed 8 4(4) << -63(ffffffc1) = 8(8)\n  signed 8 4(4) << -62(ffffffc2) = 16(10)\n  signed 8 4(4) << -61(ffffffc3) = 32(20)\n  signed 8 4(4) << -60(ffffffc4) = 64(40)\n  signed 8 4(4) << -59(ffffffc5) = 128(80)\n  signed 8 4(4) << -58(ffffffc6) = 256(0)\n  signed 8 4(4) << -57(ffffffc7) = 512(0)\n  signed 8 4(4) << -56(ffffffc8) = 1024(0)\n  signed 8 4(4) << -55(ffffffc9) = 2048(0)\n  signed 8 4(4) << -54(ffffffca) = 4096(0)\n  signed 8 4(4) << -53(ffffffcb) = 8192(0)\n  signed 8 4(4) << -52(ffffffcc) = 16384(0)\n  signed 8 4(4) << -51(ffffffcd) = 32768(0)\n  signed 8 4(4) << -50(ffffffce) = 65536(0)\n  signed 8 4(4) << -49(ffffffcf) = 131072(0)\n  signed 8 4(4) << -48(ffffffd0) = 262144(0)\n  signed 8 4(4) << -47(ffffffd1) = 524288(0)\n  signed 8 4(4) << -46(ffffffd2) = 1048576(0)\n  signed 8 4(4) << -45(ffffffd3) = 2097152(0)\n  signed 8 4(4) << -44(ffffffd4) = 4194304(0)\n  signed 8 4(4) << -43(ffffffd5) = 8388608(0)\n  signed 8 4(4) << -42(ffffffd6) = 16777216(0)\n  signed 8 4(4) << -41(ffffffd7) = 33554432(0)\n  signed 8 4(4) << -40(ffffffd8) = 67108864(0)\n  signed 8 4(4) << -39(ffffffd9) = 134217728(0)\n  signed 8 4(4) << -38(ffffffda) = 268435456(0)\n  signed 8 4(4) << -37(ffffffdb) = 536870912(0)\n  signed 8 4(4) << -36(ffffffdc) = 1073741824(0)\n  signed 8 4(4) << -35(ffffffdd) = -2147483648(0)\n  signed 8 4(4) << -34(ffffffde) = 0(0)\n  signed 8 4(4) << -33(ffffffdf) = 0(0)\n  signed 8 4(4) << -32(ffffffe0) = 4(4)\n  signed 8 4(4) << -31(ffffffe1) = 8(8)\n  signed 8 4(4) << -30(ffffffe2) = 16(10)\n  signed 8 4(4) << -29(ffffffe3) = 32(20)\n  signed 8 4(4) << -28(ffffffe4) = 64(40)\n  signed 8 4(4) << -27(ffffffe5) = 128(80)\n  signed 8 4(4) << -26(ffffffe6) = 256(0)\n  signed 8 4(4) << -25(ffffffe7) = 512(0)\n  signed 8 4(4) << -24(ffffffe8) = 1024(0)\n  signed 8 4(4) << -23(ffffffe9) = 2048(0)\n  signed 8 4(4) << -22(ffffffea) = 4096(0)\n  signed 8 4(4) << -21(ffffffeb) = 8192(0)\n  signed 8 4(4) << -20(ffffffec) = 16384(0)\n  signed 8 4(4) << -19(ffffffed) = 32768(0)\n  signed 8 4(4) << -18(ffffffee) = 65536(0)\n  signed 8 4(4) << -17(ffffffef) = 131072(0)\n  signed 8 4(4) << -16(fffffff0) = 262144(0)\n  signed 8 4(4) << -15(fffffff1) = 524288(0)\n  signed 8 4(4) << -14(fffffff2) = 1048576(0)\n  signed 8 4(4) << -13(fffffff3) = 2097152(0)\n  signed 8 4(4) << -12(fffffff4) = 4194304(0)\n  signed 8 4(4) << -11(fffffff5) = 8388608(0)\n  signed 8 4(4) << -10(fffffff6) = 16777216(0)\n  signed 8 4(4) << -9(fffffff7) = 33554432(0)\n  signed 8 4(4) << -8(fffffff8) = 67108864(0)\n  signed 8 4(4) << -7(fffffff9) = 134217728(0)\n  signed 8 4(4) << -6(fffffffa) = 268435456(0)\n  signed 8 4(4) << -5(fffffffb) = 536870912(0)\n  signed 8 4(4) << -4(fffffffc) = 1073741824(0)\n  signed 8 4(4) << -3(fffffffd) = -2147483648(0)\n  signed 8 4(4) << -2(fffffffe) = 0(0)\n  signed 8 4(4) << -1(ffffffff) = 0(0)\n  signed 8 4(4) << 0(0) = 4(4)\n  signed 8 4(4) << 1(1) = 8(8)\n  signed 8 4(4) << 2(2) = 16(10)\n  signed 8 4(4) << 3(3) = 32(20)\n  signed 8 4(4) << 4(4) = 64(40)\n  signed 8 4(4) << 5(5) = 128(80)\n  signed 8 4(4) << 6(6) = 256(0)\n  signed 8 4(4) << 7(7) = 512(0)\n  signed 8 4(4) << 8(8) = 1024(0)\n  signed 8 4(4) << 9(9) = 2048(0)\n  signed 8 4(4) << 10(a) = 4096(0)\n  signed 8 4(4) << 11(b) = 8192(0)\n  signed 8 4(4) << 12(c) = 16384(0)\n  signed 8 4(4) << 13(d) = 32768(0)\n  signed 8 4(4) << 14(e) = 65536(0)\n  signed 8 4(4) << 15(f) = 131072(0)\n  signed 8 4(4) << 16(10) = 262144(0)\n  signed 8 4(4) << 17(11) = 524288(0)\n  signed 8 4(4) << 18(12) = 1048576(0)\n  signed 8 4(4) << 19(13) = 2097152(0)\n  signed 8 4(4) << 20(14) = 4194304(0)\n  signed 8 4(4) << 21(15) = 8388608(0)\n  signed 8 4(4) << 22(16) = 16777216(0)\n  signed 8 4(4) << 23(17) = 33554432(0)\n  signed 8 4(4) << 24(18) = 67108864(0)\n  signed 8 4(4) << 25(19) = 134217728(0)\n  signed 8 4(4) << 26(1a) = 268435456(0)\n  signed 8 4(4) << 27(1b) = 536870912(0)\n  signed 8 4(4) << 28(1c) = 1073741824(0)\n  signed 8 4(4) << 29(1d) = -2147483648(0)\n  signed 8 4(4) << 30(1e) = 0(0)\n  signed 8 4(4) << 31(1f) = 0(0)\n  signed 8 4(4) << 32(20) = 4(4)\n  signed 8 4(4) << 33(21) = 8(8)\n  signed 8 4(4) << 34(22) = 16(10)\n  signed 8 4(4) << 35(23) = 32(20)\n  signed 8 4(4) << 36(24) = 64(40)\n  signed 8 4(4) << 37(25) = 128(80)\n  signed 8 4(4) << 38(26) = 256(0)\n  signed 8 4(4) << 39(27) = 512(0)\n  signed 8 4(4) << 40(28) = 1024(0)\n  signed 8 4(4) << 41(29) = 2048(0)\n  signed 8 4(4) << 42(2a) = 4096(0)\n  signed 8 4(4) << 43(2b) = 8192(0)\n  signed 8 4(4) << 44(2c) = 16384(0)\n  signed 8 4(4) << 45(2d) = 32768(0)\n  signed 8 4(4) << 46(2e) = 65536(0)\n  signed 8 4(4) << 47(2f) = 131072(0)\n  signed 8 4(4) << 48(30) = 262144(0)\n  signed 8 4(4) << 49(31) = 524288(0)\n  signed 8 4(4) << 50(32) = 1048576(0)\n  signed 8 4(4) << 51(33) = 2097152(0)\n  signed 8 4(4) << 52(34) = 4194304(0)\n  signed 8 4(4) << 53(35) = 8388608(0)\n  signed 8 4(4) << 54(36) = 16777216(0)\n  signed 8 4(4) << 55(37) = 33554432(0)\n  signed 8 4(4) << 56(38) = 67108864(0)\n  signed 8 4(4) << 57(39) = 134217728(0)\n  signed 8 4(4) << 58(3a) = 268435456(0)\n  signed 8 4(4) << 59(3b) = 536870912(0)\n  signed 8 4(4) << 60(3c) = 1073741824(0)\n  signed 8 4(4) << 61(3d) = -2147483648(0)\n  signed 8 4(4) << 62(3e) = 0(0)\n  signed 8 4(4) << 63(3f) = 0(0)\n  signed 8 4(4) << 64(40) = 4(4)\n  signed 8 4(4) << 65(41) = 8(8)\n  signed 8 4(4) << 66(42) = 16(10)\n  signed 8 4(4) << 67(43) = 32(20)\n  signed 8 4(4) << 68(44) = 64(40)\n  signed 8 4(4) << 69(45) = 128(80)\n  signed 8 4(4) << 70(46) = 256(0)\n  signed 8 4(4) << 71(47) = 512(0)\n  signed 8 4(4) << 72(48) = 1024(0)\n  signed 8 4(4) << 73(49) = 2048(0)\n  signed 8 4(4) << 74(4a) = 4096(0)\n  signed 8 4(4) << 75(4b) = 8192(0)\n  signed 8 4(4) << 76(4c) = 16384(0)\n  signed 8 4(4) << 77(4d) = 32768(0)\n  signed 8 4(4) << 78(4e) = 65536(0)\n  signed 8 4(4) << 79(4f) = 131072(0)\n  signed 8 4(4) << 80(50) = 262144(0)\n  signed 8 4(4) << 81(51) = 524288(0)\n  signed 8 4(4) << 82(52) = 1048576(0)\n  signed 8 4(4) << 83(53) = 2097152(0)\n  signed 8 4(4) << 84(54) = 4194304(0)\n  signed 8 4(4) << 85(55) = 8388608(0)\n  signed 8 4(4) << 86(56) = 16777216(0)\n  signed 8 4(4) << 87(57) = 33554432(0)\n  signed 8 4(4) << 88(58) = 67108864(0)\n  signed 8 4(4) << 89(59) = 134217728(0)\n  signed 8 4(4) << 90(5a) = 268435456(0)\n  signed 8 4(4) << 91(5b) = 536870912(0)\n  signed 8 4(4) << 92(5c) = 1073741824(0)\n  signed 8 4(4) << 93(5d) = -2147483648(0)\n  signed 8 4(4) << 94(5e) = 0(0)\n  signed 8 4(4) << 95(5f) = 0(0)\n  signed 8 4(4) << 96(60) = 4(4)\n  signed 8 4(4) << 97(61) = 8(8)\n  signed 8 4(4) << 98(62) = 16(10)\n  signed 8 4(4) << 99(63) = 32(20)\n  signed 8 4(4) << 100(64) = 64(40)\n  signed 8 4(4) << 101(65) = 128(80)\n  signed 8 4(4) << 102(66) = 256(0)\n  signed 8 4(4) << 103(67) = 512(0)\n  signed 8 4(4) << 104(68) = 1024(0)\n  signed 8 4(4) << 105(69) = 2048(0)\n  signed 8 4(4) << 106(6a) = 4096(0)\n  signed 8 4(4) << 107(6b) = 8192(0)\n  signed 8 4(4) << 108(6c) = 16384(0)\n  signed 8 4(4) << 109(6d) = 32768(0)\n  signed 8 4(4) << 110(6e) = 65536(0)\n  signed 8 4(4) << 111(6f) = 131072(0)\n  signed 8 4(4) << 112(70) = 262144(0)\n  signed 8 4(4) << 113(71) = 524288(0)\n  signed 8 4(4) << 114(72) = 1048576(0)\n  signed 8 4(4) << 115(73) = 2097152(0)\n  signed 8 4(4) << 116(74) = 4194304(0)\n  signed 8 4(4) << 117(75) = 8388608(0)\n  signed 8 4(4) << 118(76) = 16777216(0)\n  signed 8 4(4) << 119(77) = 33554432(0)\n  signed 8 4(4) << 120(78) = 67108864(0)\n  signed 8 4(4) << 121(79) = 134217728(0)\n  signed 8 4(4) << 122(7a) = 268435456(0)\n  signed 8 4(4) << 123(7b) = 536870912(0)\n  signed 8 4(4) << 124(7c) = 1073741824(0)\n  signed 8 4(4) << 125(7d) = -2147483648(0)\n  signed 8 4(4) << 126(7e) = 0(0)\n  signed 8 4(4) << 127(7f) = 0(0)\nunsigned 8 0(0) << -128(ffffff80) = 0(0)\nunsigned 8 0(0) << -127(ffffff81) = 0(0)\nunsigned 8 0(0) << -126(ffffff82) = 0(0)\nunsigned 8 0(0) << -125(ffffff83) = 0(0)\nunsigned 8 0(0) << -124(ffffff84) = 0(0)\nunsigned 8 0(0) << -123(ffffff85) = 0(0)\nunsigned 8 0(0) << -122(ffffff86) = 0(0)\nunsigned 8 0(0) << -121(ffffff87) = 0(0)\nunsigned 8 0(0) << -120(ffffff88) = 0(0)\nunsigned 8 0(0) << -119(ffffff89) = 0(0)\nunsigned 8 0(0) << -118(ffffff8a) = 0(0)\nunsigned 8 0(0) << -117(ffffff8b) = 0(0)\nunsigned 8 0(0) << -116(ffffff8c) = 0(0)\nunsigned 8 0(0) << -115(ffffff8d) = 0(0)\nunsigned 8 0(0) << -114(ffffff8e) = 0(0)\nunsigned 8 0(0) << -113(ffffff8f) = 0(0)\nunsigned 8 0(0) << -112(ffffff90) = 0(0)\nunsigned 8 0(0) << -111(ffffff91) = 0(0)\nunsigned 8 0(0) << -110(ffffff92) = 0(0)\nunsigned 8 0(0) << -109(ffffff93) = 0(0)\nunsigned 8 0(0) << -108(ffffff94) = 0(0)\nunsigned 8 0(0) << -107(ffffff95) = 0(0)\nunsigned 8 0(0) << -106(ffffff96) = 0(0)\nunsigned 8 0(0) << -105(ffffff97) = 0(0)\nunsigned 8 0(0) << -104(ffffff98) = 0(0)\nunsigned 8 0(0) << -103(ffffff99) = 0(0)\nunsigned 8 0(0) << -102(ffffff9a) = 0(0)\nunsigned 8 0(0) << -101(ffffff9b) = 0(0)\nunsigned 8 0(0) << -100(ffffff9c) = 0(0)\nunsigned 8 0(0) << -99(ffffff9d) = 0(0)\nunsigned 8 0(0) << -98(ffffff9e) = 0(0)\nunsigned 8 0(0) << -97(ffffff9f) = 0(0)\nunsigned 8 0(0) << -96(ffffffa0) = 0(0)\nunsigned 8 0(0) << -95(ffffffa1) = 0(0)\nunsigned 8 0(0) << -94(ffffffa2) = 0(0)\nunsigned 8 0(0) << -93(ffffffa3) = 0(0)\nunsigned 8 0(0) << -92(ffffffa4) = 0(0)\nunsigned 8 0(0) << -91(ffffffa5) = 0(0)\nunsigned 8 0(0) << -90(ffffffa6) = 0(0)\nunsigned 8 0(0) << -89(ffffffa7) = 0(0)\nunsigned 8 0(0) << -88(ffffffa8) = 0(0)\nunsigned 8 0(0) << -87(ffffffa9) = 0(0)\nunsigned 8 0(0) << -86(ffffffaa) = 0(0)\nunsigned 8 0(0) << -85(ffffffab) = 0(0)\nunsigned 8 0(0) << -84(ffffffac) = 0(0)\nunsigned 8 0(0) << -83(ffffffad) = 0(0)\nunsigned 8 0(0) << -82(ffffffae) = 0(0)\nunsigned 8 0(0) << -81(ffffffaf) = 0(0)\nunsigned 8 0(0) << -80(ffffffb0) = 0(0)\nunsigned 8 0(0) << -79(ffffffb1) = 0(0)\nunsigned 8 0(0) << -78(ffffffb2) = 0(0)\nunsigned 8 0(0) << -77(ffffffb3) = 0(0)\nunsigned 8 0(0) << -76(ffffffb4) = 0(0)\nunsigned 8 0(0) << -75(ffffffb5) = 0(0)\nunsigned 8 0(0) << -74(ffffffb6) = 0(0)\nunsigned 8 0(0) << -73(ffffffb7) = 0(0)\nunsigned 8 0(0) << -72(ffffffb8) = 0(0)\nunsigned 8 0(0) << -71(ffffffb9) = 0(0)\nunsigned 8 0(0) << -70(ffffffba) = 0(0)\nunsigned 8 0(0) << -69(ffffffbb) = 0(0)\nunsigned 8 0(0) << -68(ffffffbc) = 0(0)\nunsigned 8 0(0) << -67(ffffffbd) = 0(0)\nunsigned 8 0(0) << -66(ffffffbe) = 0(0)\nunsigned 8 0(0) << -65(ffffffbf) = 0(0)\nunsigned 8 0(0) << -64(ffffffc0) = 0(0)\nunsigned 8 0(0) << -63(ffffffc1) = 0(0)\nunsigned 8 0(0) << -62(ffffffc2) = 0(0)\nunsigned 8 0(0) << -61(ffffffc3) = 0(0)\nunsigned 8 0(0) << -60(ffffffc4) = 0(0)\nunsigned 8 0(0) << -59(ffffffc5) = 0(0)\nunsigned 8 0(0) << -58(ffffffc6) = 0(0)\nunsigned 8 0(0) << -57(ffffffc7) = 0(0)\nunsigned 8 0(0) << -56(ffffffc8) = 0(0)\nunsigned 8 0(0) << -55(ffffffc9) = 0(0)\nunsigned 8 0(0) << -54(ffffffca) = 0(0)\nunsigned 8 0(0) << -53(ffffffcb) = 0(0)\nunsigned 8 0(0) << -52(ffffffcc) = 0(0)\nunsigned 8 0(0) << -51(ffffffcd) = 0(0)\nunsigned 8 0(0) << -50(ffffffce) = 0(0)\nunsigned 8 0(0) << -49(ffffffcf) = 0(0)\nunsigned 8 0(0) << -48(ffffffd0) = 0(0)\nunsigned 8 0(0) << -47(ffffffd1) = 0(0)\nunsigned 8 0(0) << -46(ffffffd2) = 0(0)\nunsigned 8 0(0) << -45(ffffffd3) = 0(0)\nunsigned 8 0(0) << -44(ffffffd4) = 0(0)\nunsigned 8 0(0) << -43(ffffffd5) = 0(0)\nunsigned 8 0(0) << -42(ffffffd6) = 0(0)\nunsigned 8 0(0) << -41(ffffffd7) = 0(0)\nunsigned 8 0(0) << -40(ffffffd8) = 0(0)\nunsigned 8 0(0) << -39(ffffffd9) = 0(0)\nunsigned 8 0(0) << -38(ffffffda) = 0(0)\nunsigned 8 0(0) << -37(ffffffdb) = 0(0)\nunsigned 8 0(0) << -36(ffffffdc) = 0(0)\nunsigned 8 0(0) << -35(ffffffdd) = 0(0)\nunsigned 8 0(0) << -34(ffffffde) = 0(0)\nunsigned 8 0(0) << -33(ffffffdf) = 0(0)\nunsigned 8 0(0) << -32(ffffffe0) = 0(0)\nunsigned 8 0(0) << -31(ffffffe1) = 0(0)\nunsigned 8 0(0) << -30(ffffffe2) = 0(0)\nunsigned 8 0(0) << -29(ffffffe3) = 0(0)\nunsigned 8 0(0) << -28(ffffffe4) = 0(0)\nunsigned 8 0(0) << -27(ffffffe5) = 0(0)\nunsigned 8 0(0) << -26(ffffffe6) = 0(0)\nunsigned 8 0(0) << -25(ffffffe7) = 0(0)\nunsigned 8 0(0) << -24(ffffffe8) = 0(0)\nunsigned 8 0(0) << -23(ffffffe9) = 0(0)\nunsigned 8 0(0) << -22(ffffffea) = 0(0)\nunsigned 8 0(0) << -21(ffffffeb) = 0(0)\nunsigned 8 0(0) << -20(ffffffec) = 0(0)\nunsigned 8 0(0) << -19(ffffffed) = 0(0)\nunsigned 8 0(0) << -18(ffffffee) = 0(0)\nunsigned 8 0(0) << -17(ffffffef) = 0(0)\nunsigned 8 0(0) << -16(fffffff0) = 0(0)\nunsigned 8 0(0) << -15(fffffff1) = 0(0)\nunsigned 8 0(0) << -14(fffffff2) = 0(0)\nunsigned 8 0(0) << -13(fffffff3) = 0(0)\nunsigned 8 0(0) << -12(fffffff4) = 0(0)\nunsigned 8 0(0) << -11(fffffff5) = 0(0)\nunsigned 8 0(0) << -10(fffffff6) = 0(0)\nunsigned 8 0(0) << -9(fffffff7) = 0(0)\nunsigned 8 0(0) << -8(fffffff8) = 0(0)\nunsigned 8 0(0) << -7(fffffff9) = 0(0)\nunsigned 8 0(0) << -6(fffffffa) = 0(0)\nunsigned 8 0(0) << -5(fffffffb) = 0(0)\nunsigned 8 0(0) << -4(fffffffc) = 0(0)\nunsigned 8 0(0) << -3(fffffffd) = 0(0)\nunsigned 8 0(0) << -2(fffffffe) = 0(0)\nunsigned 8 0(0) << -1(ffffffff) = 0(0)\nunsigned 8 0(0) << 0(0) = 0(0)\nunsigned 8 0(0) << 1(1) = 0(0)\nunsigned 8 0(0) << 2(2) = 0(0)\nunsigned 8 0(0) << 3(3) = 0(0)\nunsigned 8 0(0) << 4(4) = 0(0)\nunsigned 8 0(0) << 5(5) = 0(0)\nunsigned 8 0(0) << 6(6) = 0(0)\nunsigned 8 0(0) << 7(7) = 0(0)\nunsigned 8 0(0) << 8(8) = 0(0)\nunsigned 8 0(0) << 9(9) = 0(0)\nunsigned 8 0(0) << 10(a) = 0(0)\nunsigned 8 0(0) << 11(b) = 0(0)\nunsigned 8 0(0) << 12(c) = 0(0)\nunsigned 8 0(0) << 13(d) = 0(0)\nunsigned 8 0(0) << 14(e) = 0(0)\nunsigned 8 0(0) << 15(f) = 0(0)\nunsigned 8 0(0) << 16(10) = 0(0)\nunsigned 8 0(0) << 17(11) = 0(0)\nunsigned 8 0(0) << 18(12) = 0(0)\nunsigned 8 0(0) << 19(13) = 0(0)\nunsigned 8 0(0) << 20(14) = 0(0)\nunsigned 8 0(0) << 21(15) = 0(0)\nunsigned 8 0(0) << 22(16) = 0(0)\nunsigned 8 0(0) << 23(17) = 0(0)\nunsigned 8 0(0) << 24(18) = 0(0)\nunsigned 8 0(0) << 25(19) = 0(0)\nunsigned 8 0(0) << 26(1a) = 0(0)\nunsigned 8 0(0) << 27(1b) = 0(0)\nunsigned 8 0(0) << 28(1c) = 0(0)\nunsigned 8 0(0) << 29(1d) = 0(0)\nunsigned 8 0(0) << 30(1e) = 0(0)\nunsigned 8 0(0) << 31(1f) = 0(0)\nunsigned 8 0(0) << 32(20) = 0(0)\nunsigned 8 0(0) << 33(21) = 0(0)\nunsigned 8 0(0) << 34(22) = 0(0)\nunsigned 8 0(0) << 35(23) = 0(0)\nunsigned 8 0(0) << 36(24) = 0(0)\nunsigned 8 0(0) << 37(25) = 0(0)\nunsigned 8 0(0) << 38(26) = 0(0)\nunsigned 8 0(0) << 39(27) = 0(0)\nunsigned 8 0(0) << 40(28) = 0(0)\nunsigned 8 0(0) << 41(29) = 0(0)\nunsigned 8 0(0) << 42(2a) = 0(0)\nunsigned 8 0(0) << 43(2b) = 0(0)\nunsigned 8 0(0) << 44(2c) = 0(0)\nunsigned 8 0(0) << 45(2d) = 0(0)\nunsigned 8 0(0) << 46(2e) = 0(0)\nunsigned 8 0(0) << 47(2f) = 0(0)\nunsigned 8 0(0) << 48(30) = 0(0)\nunsigned 8 0(0) << 49(31) = 0(0)\nunsigned 8 0(0) << 50(32) = 0(0)\nunsigned 8 0(0) << 51(33) = 0(0)\nunsigned 8 0(0) << 52(34) = 0(0)\nunsigned 8 0(0) << 53(35) = 0(0)\nunsigned 8 0(0) << 54(36) = 0(0)\nunsigned 8 0(0) << 55(37) = 0(0)\nunsigned 8 0(0) << 56(38) = 0(0)\nunsigned 8 0(0) << 57(39) = 0(0)\nunsigned 8 0(0) << 58(3a) = 0(0)\nunsigned 8 0(0) << 59(3b) = 0(0)\nunsigned 8 0(0) << 60(3c) = 0(0)\nunsigned 8 0(0) << 61(3d) = 0(0)\nunsigned 8 0(0) << 62(3e) = 0(0)\nunsigned 8 0(0) << 63(3f) = 0(0)\nunsigned 8 0(0) << 64(40) = 0(0)\nunsigned 8 0(0) << 65(41) = 0(0)\nunsigned 8 0(0) << 66(42) = 0(0)\nunsigned 8 0(0) << 67(43) = 0(0)\nunsigned 8 0(0) << 68(44) = 0(0)\nunsigned 8 0(0) << 69(45) = 0(0)\nunsigned 8 0(0) << 70(46) = 0(0)\nunsigned 8 0(0) << 71(47) = 0(0)\nunsigned 8 0(0) << 72(48) = 0(0)\nunsigned 8 0(0) << 73(49) = 0(0)\nunsigned 8 0(0) << 74(4a) = 0(0)\nunsigned 8 0(0) << 75(4b) = 0(0)\nunsigned 8 0(0) << 76(4c) = 0(0)\nunsigned 8 0(0) << 77(4d) = 0(0)\nunsigned 8 0(0) << 78(4e) = 0(0)\nunsigned 8 0(0) << 79(4f) = 0(0)\nunsigned 8 0(0) << 80(50) = 0(0)\nunsigned 8 0(0) << 81(51) = 0(0)\nunsigned 8 0(0) << 82(52) = 0(0)\nunsigned 8 0(0) << 83(53) = 0(0)\nunsigned 8 0(0) << 84(54) = 0(0)\nunsigned 8 0(0) << 85(55) = 0(0)\nunsigned 8 0(0) << 86(56) = 0(0)\nunsigned 8 0(0) << 87(57) = 0(0)\nunsigned 8 0(0) << 88(58) = 0(0)\nunsigned 8 0(0) << 89(59) = 0(0)\nunsigned 8 0(0) << 90(5a) = 0(0)\nunsigned 8 0(0) << 91(5b) = 0(0)\nunsigned 8 0(0) << 92(5c) = 0(0)\nunsigned 8 0(0) << 93(5d) = 0(0)\nunsigned 8 0(0) << 94(5e) = 0(0)\nunsigned 8 0(0) << 95(5f) = 0(0)\nunsigned 8 0(0) << 96(60) = 0(0)\nunsigned 8 0(0) << 97(61) = 0(0)\nunsigned 8 0(0) << 98(62) = 0(0)\nunsigned 8 0(0) << 99(63) = 0(0)\nunsigned 8 0(0) << 100(64) = 0(0)\nunsigned 8 0(0) << 101(65) = 0(0)\nunsigned 8 0(0) << 102(66) = 0(0)\nunsigned 8 0(0) << 103(67) = 0(0)\nunsigned 8 0(0) << 104(68) = 0(0)\nunsigned 8 0(0) << 105(69) = 0(0)\nunsigned 8 0(0) << 106(6a) = 0(0)\nunsigned 8 0(0) << 107(6b) = 0(0)\nunsigned 8 0(0) << 108(6c) = 0(0)\nunsigned 8 0(0) << 109(6d) = 0(0)\nunsigned 8 0(0) << 110(6e) = 0(0)\nunsigned 8 0(0) << 111(6f) = 0(0)\nunsigned 8 0(0) << 112(70) = 0(0)\nunsigned 8 0(0) << 113(71) = 0(0)\nunsigned 8 0(0) << 114(72) = 0(0)\nunsigned 8 0(0) << 115(73) = 0(0)\nunsigned 8 0(0) << 116(74) = 0(0)\nunsigned 8 0(0) << 117(75) = 0(0)\nunsigned 8 0(0) << 118(76) = 0(0)\nunsigned 8 0(0) << 119(77) = 0(0)\nunsigned 8 0(0) << 120(78) = 0(0)\nunsigned 8 0(0) << 121(79) = 0(0)\nunsigned 8 0(0) << 122(7a) = 0(0)\nunsigned 8 0(0) << 123(7b) = 0(0)\nunsigned 8 0(0) << 124(7c) = 0(0)\nunsigned 8 0(0) << 125(7d) = 0(0)\nunsigned 8 0(0) << 126(7e) = 0(0)\nunsigned 8 0(0) << 127(7f) = 0(0)\nunsigned 8 1(1) << -128(ffffff80) = 1(1)\nunsigned 8 1(1) << -127(ffffff81) = 2(2)\nunsigned 8 1(1) << -126(ffffff82) = 4(4)\nunsigned 8 1(1) << -125(ffffff83) = 8(8)\nunsigned 8 1(1) << -124(ffffff84) = 16(10)\nunsigned 8 1(1) << -123(ffffff85) = 32(20)\nunsigned 8 1(1) << -122(ffffff86) = 64(40)\nunsigned 8 1(1) << -121(ffffff87) = 128(80)\nunsigned 8 1(1) << -120(ffffff88) = 256(100)\nunsigned 8 1(1) << -119(ffffff89) = 512(200)\nunsigned 8 1(1) << -118(ffffff8a) = 1024(400)\nunsigned 8 1(1) << -117(ffffff8b) = 2048(800)\nunsigned 8 1(1) << -116(ffffff8c) = 4096(1000)\nunsigned 8 1(1) << -115(ffffff8d) = 8192(2000)\nunsigned 8 1(1) << -114(ffffff8e) = 16384(4000)\nunsigned 8 1(1) << -113(ffffff8f) = 32768(8000)\nunsigned 8 1(1) << -112(ffffff90) = 65536(10000)\nunsigned 8 1(1) << -111(ffffff91) = 131072(20000)\nunsigned 8 1(1) << -110(ffffff92) = 262144(40000)\nunsigned 8 1(1) << -109(ffffff93) = 524288(80000)\nunsigned 8 1(1) << -108(ffffff94) = 1048576(100000)\nunsigned 8 1(1) << -107(ffffff95) = 2097152(200000)\nunsigned 8 1(1) << -106(ffffff96) = 4194304(400000)\nunsigned 8 1(1) << -105(ffffff97) = 8388608(800000)\nunsigned 8 1(1) << -104(ffffff98) = 16777216(1000000)\nunsigned 8 1(1) << -103(ffffff99) = 33554432(2000000)\nunsigned 8 1(1) << -102(ffffff9a) = 67108864(4000000)\nunsigned 8 1(1) << -101(ffffff9b) = 134217728(8000000)\nunsigned 8 1(1) << -100(ffffff9c) = 268435456(10000000)\nunsigned 8 1(1) << -99(ffffff9d) = 536870912(20000000)\nunsigned 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\nunsigned 8 1(1) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 1(1) << -96(ffffffa0) = 1(1)\nunsigned 8 1(1) << -95(ffffffa1) = 2(2)\nunsigned 8 1(1) << -94(ffffffa2) = 4(4)\nunsigned 8 1(1) << -93(ffffffa3) = 8(8)\nunsigned 8 1(1) << -92(ffffffa4) = 16(10)\nunsigned 8 1(1) << -91(ffffffa5) = 32(20)\nunsigned 8 1(1) << -90(ffffffa6) = 64(40)\nunsigned 8 1(1) << -89(ffffffa7) = 128(80)\nunsigned 8 1(1) << -88(ffffffa8) = 256(100)\nunsigned 8 1(1) << -87(ffffffa9) = 512(200)\nunsigned 8 1(1) << -86(ffffffaa) = 1024(400)\nunsigned 8 1(1) << -85(ffffffab) = 2048(800)\nunsigned 8 1(1) << -84(ffffffac) = 4096(1000)\nunsigned 8 1(1) << -83(ffffffad) = 8192(2000)\nunsigned 8 1(1) << -82(ffffffae) = 16384(4000)\nunsigned 8 1(1) << -81(ffffffaf) = 32768(8000)\nunsigned 8 1(1) << -80(ffffffb0) = 65536(10000)\nunsigned 8 1(1) << -79(ffffffb1) = 131072(20000)\nunsigned 8 1(1) << -78(ffffffb2) = 262144(40000)\nunsigned 8 1(1) << -77(ffffffb3) = 524288(80000)\nunsigned 8 1(1) << -76(ffffffb4) = 1048576(100000)\nunsigned 8 1(1) << -75(ffffffb5) = 2097152(200000)\nunsigned 8 1(1) << -74(ffffffb6) = 4194304(400000)\nunsigned 8 1(1) << -73(ffffffb7) = 8388608(800000)\nunsigned 8 1(1) << -72(ffffffb8) = 16777216(1000000)\nunsigned 8 1(1) << -71(ffffffb9) = 33554432(2000000)\nunsigned 8 1(1) << -70(ffffffba) = 67108864(4000000)\nunsigned 8 1(1) << -69(ffffffbb) = 134217728(8000000)\nunsigned 8 1(1) << -68(ffffffbc) = 268435456(10000000)\nunsigned 8 1(1) << -67(ffffffbd) = 536870912(20000000)\nunsigned 8 1(1) << -66(ffffffbe) = 1073741824(40000000)\nunsigned 8 1(1) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 1(1) << -64(ffffffc0) = 1(1)\nunsigned 8 1(1) << -63(ffffffc1) = 2(2)\nunsigned 8 1(1) << -62(ffffffc2) = 4(4)\nunsigned 8 1(1) << -61(ffffffc3) = 8(8)\nunsigned 8 1(1) << -60(ffffffc4) = 16(10)\nunsigned 8 1(1) << -59(ffffffc5) = 32(20)\nunsigned 8 1(1) << -58(ffffffc6) = 64(40)\nunsigned 8 1(1) << -57(ffffffc7) = 128(80)\nunsigned 8 1(1) << -56(ffffffc8) = 256(100)\nunsigned 8 1(1) << -55(ffffffc9) = 512(200)\nunsigned 8 1(1) << -54(ffffffca) = 1024(400)\nunsigned 8 1(1) << -53(ffffffcb) = 2048(800)\nunsigned 8 1(1) << -52(ffffffcc) = 4096(1000)\nunsigned 8 1(1) << -51(ffffffcd) = 8192(2000)\nunsigned 8 1(1) << -50(ffffffce) = 16384(4000)\nunsigned 8 1(1) << -49(ffffffcf) = 32768(8000)\nunsigned 8 1(1) << -48(ffffffd0) = 65536(10000)\nunsigned 8 1(1) << -47(ffffffd1) = 131072(20000)\nunsigned 8 1(1) << -46(ffffffd2) = 262144(40000)\nunsigned 8 1(1) << -45(ffffffd3) = 524288(80000)\nunsigned 8 1(1) << -44(ffffffd4) = 1048576(100000)\nunsigned 8 1(1) << -43(ffffffd5) = 2097152(200000)\nunsigned 8 1(1) << -42(ffffffd6) = 4194304(400000)\nunsigned 8 1(1) << -41(ffffffd7) = 8388608(800000)\nunsigned 8 1(1) << -40(ffffffd8) = 16777216(1000000)\nunsigned 8 1(1) << -39(ffffffd9) = 33554432(2000000)\nunsigned 8 1(1) << -38(ffffffda) = 67108864(4000000)\nunsigned 8 1(1) << -37(ffffffdb) = 134217728(8000000)\nunsigned 8 1(1) << -36(ffffffdc) = 268435456(10000000)\nunsigned 8 1(1) << -35(ffffffdd) = 536870912(20000000)\nunsigned 8 1(1) << -34(ffffffde) = 1073741824(40000000)\nunsigned 8 1(1) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 1(1) << -32(ffffffe0) = 1(1)\nunsigned 8 1(1) << -31(ffffffe1) = 2(2)\nunsigned 8 1(1) << -30(ffffffe2) = 4(4)\nunsigned 8 1(1) << -29(ffffffe3) = 8(8)\nunsigned 8 1(1) << -28(ffffffe4) = 16(10)\nunsigned 8 1(1) << -27(ffffffe5) = 32(20)\nunsigned 8 1(1) << -26(ffffffe6) = 64(40)\nunsigned 8 1(1) << -25(ffffffe7) = 128(80)\nunsigned 8 1(1) << -24(ffffffe8) = 256(100)\nunsigned 8 1(1) << -23(ffffffe9) = 512(200)\nunsigned 8 1(1) << -22(ffffffea) = 1024(400)\nunsigned 8 1(1) << -21(ffffffeb) = 2048(800)\nunsigned 8 1(1) << -20(ffffffec) = 4096(1000)\nunsigned 8 1(1) << -19(ffffffed) = 8192(2000)\nunsigned 8 1(1) << -18(ffffffee) = 16384(4000)\nunsigned 8 1(1) << -17(ffffffef) = 32768(8000)\nunsigned 8 1(1) << -16(fffffff0) = 65536(10000)\nunsigned 8 1(1) << -15(fffffff1) = 131072(20000)\nunsigned 8 1(1) << -14(fffffff2) = 262144(40000)\nunsigned 8 1(1) << -13(fffffff3) = 524288(80000)\nunsigned 8 1(1) << -12(fffffff4) = 1048576(100000)\nunsigned 8 1(1) << -11(fffffff5) = 2097152(200000)\nunsigned 8 1(1) << -10(fffffff6) = 4194304(400000)\nunsigned 8 1(1) << -9(fffffff7) = 8388608(800000)\nunsigned 8 1(1) << -8(fffffff8) = 16777216(1000000)\nunsigned 8 1(1) << -7(fffffff9) = 33554432(2000000)\nunsigned 8 1(1) << -6(fffffffa) = 67108864(4000000)\nunsigned 8 1(1) << -5(fffffffb) = 134217728(8000000)\nunsigned 8 1(1) << -4(fffffffc) = 268435456(10000000)\nunsigned 8 1(1) << -3(fffffffd) = 536870912(20000000)\nunsigned 8 1(1) << -2(fffffffe) = 1073741824(40000000)\nunsigned 8 1(1) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 1(1) << 0(0) = 1(1)\nunsigned 8 1(1) << 1(1) = 2(2)\nunsigned 8 1(1) << 2(2) = 4(4)\nunsigned 8 1(1) << 3(3) = 8(8)\nunsigned 8 1(1) << 4(4) = 16(10)\nunsigned 8 1(1) << 5(5) = 32(20)\nunsigned 8 1(1) << 6(6) = 64(40)\nunsigned 8 1(1) << 7(7) = 128(80)\nunsigned 8 1(1) << 8(8) = 256(100)\nunsigned 8 1(1) << 9(9) = 512(200)\nunsigned 8 1(1) << 10(a) = 1024(400)\nunsigned 8 1(1) << 11(b) = 2048(800)\nunsigned 8 1(1) << 12(c) = 4096(1000)\nunsigned 8 1(1) << 13(d) = 8192(2000)\nunsigned 8 1(1) << 14(e) = 16384(4000)\nunsigned 8 1(1) << 15(f) = 32768(8000)\nunsigned 8 1(1) << 16(10) = 65536(10000)\nunsigned 8 1(1) << 17(11) = 131072(20000)\nunsigned 8 1(1) << 18(12) = 262144(40000)\nunsigned 8 1(1) << 19(13) = 524288(80000)\nunsigned 8 1(1) << 20(14) = 1048576(100000)\nunsigned 8 1(1) << 21(15) = 2097152(200000)\nunsigned 8 1(1) << 22(16) = 4194304(400000)\nunsigned 8 1(1) << 23(17) = 8388608(800000)\nunsigned 8 1(1) << 24(18) = 16777216(1000000)\nunsigned 8 1(1) << 25(19) = 33554432(2000000)\nunsigned 8 1(1) << 26(1a) = 67108864(4000000)\nunsigned 8 1(1) << 27(1b) = 134217728(8000000)\nunsigned 8 1(1) << 28(1c) = 268435456(10000000)\nunsigned 8 1(1) << 29(1d) = 536870912(20000000)\nunsigned 8 1(1) << 30(1e) = 1073741824(40000000)\nunsigned 8 1(1) << 31(1f) = 2147483648(80000000)\nunsigned 8 1(1) << 32(20) = 1(1)\nunsigned 8 1(1) << 33(21) = 2(2)\nunsigned 8 1(1) << 34(22) = 4(4)\nunsigned 8 1(1) << 35(23) = 8(8)\nunsigned 8 1(1) << 36(24) = 16(10)\nunsigned 8 1(1) << 37(25) = 32(20)\nunsigned 8 1(1) << 38(26) = 64(40)\nunsigned 8 1(1) << 39(27) = 128(80)\nunsigned 8 1(1) << 40(28) = 256(100)\nunsigned 8 1(1) << 41(29) = 512(200)\nunsigned 8 1(1) << 42(2a) = 1024(400)\nunsigned 8 1(1) << 43(2b) = 2048(800)\nunsigned 8 1(1) << 44(2c) = 4096(1000)\nunsigned 8 1(1) << 45(2d) = 8192(2000)\nunsigned 8 1(1) << 46(2e) = 16384(4000)\nunsigned 8 1(1) << 47(2f) = 32768(8000)\nunsigned 8 1(1) << 48(30) = 65536(10000)\nunsigned 8 1(1) << 49(31) = 131072(20000)\nunsigned 8 1(1) << 50(32) = 262144(40000)\nunsigned 8 1(1) << 51(33) = 524288(80000)\nunsigned 8 1(1) << 52(34) = 1048576(100000)\nunsigned 8 1(1) << 53(35) = 2097152(200000)\nunsigned 8 1(1) << 54(36) = 4194304(400000)\nunsigned 8 1(1) << 55(37) = 8388608(800000)\nunsigned 8 1(1) << 56(38) = 16777216(1000000)\nunsigned 8 1(1) << 57(39) = 33554432(2000000)\nunsigned 8 1(1) << 58(3a) = 67108864(4000000)\nunsigned 8 1(1) << 59(3b) = 134217728(8000000)\nunsigned 8 1(1) << 60(3c) = 268435456(10000000)\nunsigned 8 1(1) << 61(3d) = 536870912(20000000)\nunsigned 8 1(1) << 62(3e) = 1073741824(40000000)\nunsigned 8 1(1) << 63(3f) = 2147483648(80000000)\nunsigned 8 1(1) << 64(40) = 1(1)\nunsigned 8 1(1) << 65(41) = 2(2)\nunsigned 8 1(1) << 66(42) = 4(4)\nunsigned 8 1(1) << 67(43) = 8(8)\nunsigned 8 1(1) << 68(44) = 16(10)\nunsigned 8 1(1) << 69(45) = 32(20)\nunsigned 8 1(1) << 70(46) = 64(40)\nunsigned 8 1(1) << 71(47) = 128(80)\nunsigned 8 1(1) << 72(48) = 256(100)\nunsigned 8 1(1) << 73(49) = 512(200)\nunsigned 8 1(1) << 74(4a) = 1024(400)\nunsigned 8 1(1) << 75(4b) = 2048(800)\nunsigned 8 1(1) << 76(4c) = 4096(1000)\nunsigned 8 1(1) << 77(4d) = 8192(2000)\nunsigned 8 1(1) << 78(4e) = 16384(4000)\nunsigned 8 1(1) << 79(4f) = 32768(8000)\nunsigned 8 1(1) << 80(50) = 65536(10000)\nunsigned 8 1(1) << 81(51) = 131072(20000)\nunsigned 8 1(1) << 82(52) = 262144(40000)\nunsigned 8 1(1) << 83(53) = 524288(80000)\nunsigned 8 1(1) << 84(54) = 1048576(100000)\nunsigned 8 1(1) << 85(55) = 2097152(200000)\nunsigned 8 1(1) << 86(56) = 4194304(400000)\nunsigned 8 1(1) << 87(57) = 8388608(800000)\nunsigned 8 1(1) << 88(58) = 16777216(1000000)\nunsigned 8 1(1) << 89(59) = 33554432(2000000)\nunsigned 8 1(1) << 90(5a) = 67108864(4000000)\nunsigned 8 1(1) << 91(5b) = 134217728(8000000)\nunsigned 8 1(1) << 92(5c) = 268435456(10000000)\nunsigned 8 1(1) << 93(5d) = 536870912(20000000)\nunsigned 8 1(1) << 94(5e) = 1073741824(40000000)\nunsigned 8 1(1) << 95(5f) = 2147483648(80000000)\nunsigned 8 1(1) << 96(60) = 1(1)\nunsigned 8 1(1) << 97(61) = 2(2)\nunsigned 8 1(1) << 98(62) = 4(4)\nunsigned 8 1(1) << 99(63) = 8(8)\nunsigned 8 1(1) << 100(64) = 16(10)\nunsigned 8 1(1) << 101(65) = 32(20)\nunsigned 8 1(1) << 102(66) = 64(40)\nunsigned 8 1(1) << 103(67) = 128(80)\nunsigned 8 1(1) << 104(68) = 256(100)\nunsigned 8 1(1) << 105(69) = 512(200)\nunsigned 8 1(1) << 106(6a) = 1024(400)\nunsigned 8 1(1) << 107(6b) = 2048(800)\nunsigned 8 1(1) << 108(6c) = 4096(1000)\nunsigned 8 1(1) << 109(6d) = 8192(2000)\nunsigned 8 1(1) << 110(6e) = 16384(4000)\nunsigned 8 1(1) << 111(6f) = 32768(8000)\nunsigned 8 1(1) << 112(70) = 65536(10000)\nunsigned 8 1(1) << 113(71) = 131072(20000)\nunsigned 8 1(1) << 114(72) = 262144(40000)\nunsigned 8 1(1) << 115(73) = 524288(80000)\nunsigned 8 1(1) << 116(74) = 1048576(100000)\nunsigned 8 1(1) << 117(75) = 2097152(200000)\nunsigned 8 1(1) << 118(76) = 4194304(400000)\nunsigned 8 1(1) << 119(77) = 8388608(800000)\nunsigned 8 1(1) << 120(78) = 16777216(1000000)\nunsigned 8 1(1) << 121(79) = 33554432(2000000)\nunsigned 8 1(1) << 122(7a) = 67108864(4000000)\nunsigned 8 1(1) << 123(7b) = 134217728(8000000)\nunsigned 8 1(1) << 124(7c) = 268435456(10000000)\nunsigned 8 1(1) << 125(7d) = 536870912(20000000)\nunsigned 8 1(1) << 126(7e) = 1073741824(40000000)\nunsigned 8 1(1) << 127(7f) = 2147483648(80000000)\nunsigned 8 2(2) << -128(ffffff80) = 2(2)\nunsigned 8 2(2) << -127(ffffff81) = 4(4)\nunsigned 8 2(2) << -126(ffffff82) = 8(8)\nunsigned 8 2(2) << -125(ffffff83) = 16(10)\nunsigned 8 2(2) << -124(ffffff84) = 32(20)\nunsigned 8 2(2) << -123(ffffff85) = 64(40)\nunsigned 8 2(2) << -122(ffffff86) = 128(80)\nunsigned 8 2(2) << -121(ffffff87) = 256(100)\nunsigned 8 2(2) << -120(ffffff88) = 512(200)\nunsigned 8 2(2) << -119(ffffff89) = 1024(400)\nunsigned 8 2(2) << -118(ffffff8a) = 2048(800)\nunsigned 8 2(2) << -117(ffffff8b) = 4096(1000)\nunsigned 8 2(2) << -116(ffffff8c) = 8192(2000)\nunsigned 8 2(2) << -115(ffffff8d) = 16384(4000)\nunsigned 8 2(2) << -114(ffffff8e) = 32768(8000)\nunsigned 8 2(2) << -113(ffffff8f) = 65536(10000)\nunsigned 8 2(2) << -112(ffffff90) = 131072(20000)\nunsigned 8 2(2) << -111(ffffff91) = 262144(40000)\nunsigned 8 2(2) << -110(ffffff92) = 524288(80000)\nunsigned 8 2(2) << -109(ffffff93) = 1048576(100000)\nunsigned 8 2(2) << -108(ffffff94) = 2097152(200000)\nunsigned 8 2(2) << -107(ffffff95) = 4194304(400000)\nunsigned 8 2(2) << -106(ffffff96) = 8388608(800000)\nunsigned 8 2(2) << -105(ffffff97) = 16777216(1000000)\nunsigned 8 2(2) << -104(ffffff98) = 33554432(2000000)\nunsigned 8 2(2) << -103(ffffff99) = 67108864(4000000)\nunsigned 8 2(2) << -102(ffffff9a) = 134217728(8000000)\nunsigned 8 2(2) << -101(ffffff9b) = 268435456(10000000)\nunsigned 8 2(2) << -100(ffffff9c) = 536870912(20000000)\nunsigned 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\nunsigned 8 2(2) << -98(ffffff9e) = 2147483648(80000000)\nunsigned 8 2(2) << -97(ffffff9f) = 0(0)\nunsigned 8 2(2) << -96(ffffffa0) = 2(2)\nunsigned 8 2(2) << -95(ffffffa1) = 4(4)\nunsigned 8 2(2) << -94(ffffffa2) = 8(8)\nunsigned 8 2(2) << -93(ffffffa3) = 16(10)\nunsigned 8 2(2) << -92(ffffffa4) = 32(20)\nunsigned 8 2(2) << -91(ffffffa5) = 64(40)\nunsigned 8 2(2) << -90(ffffffa6) = 128(80)\nunsigned 8 2(2) << -89(ffffffa7) = 256(100)\nunsigned 8 2(2) << -88(ffffffa8) = 512(200)\nunsigned 8 2(2) << -87(ffffffa9) = 1024(400)\nunsigned 8 2(2) << -86(ffffffaa) = 2048(800)\nunsigned 8 2(2) << -85(ffffffab) = 4096(1000)\nunsigned 8 2(2) << -84(ffffffac) = 8192(2000)\nunsigned 8 2(2) << -83(ffffffad) = 16384(4000)\nunsigned 8 2(2) << -82(ffffffae) = 32768(8000)\nunsigned 8 2(2) << -81(ffffffaf) = 65536(10000)\nunsigned 8 2(2) << -80(ffffffb0) = 131072(20000)\nunsigned 8 2(2) << -79(ffffffb1) = 262144(40000)\nunsigned 8 2(2) << -78(ffffffb2) = 524288(80000)\nunsigned 8 2(2) << -77(ffffffb3) = 1048576(100000)\nunsigned 8 2(2) << -76(ffffffb4) = 2097152(200000)\nunsigned 8 2(2) << -75(ffffffb5) = 4194304(400000)\nunsigned 8 2(2) << -74(ffffffb6) = 8388608(800000)\nunsigned 8 2(2) << -73(ffffffb7) = 16777216(1000000)\nunsigned 8 2(2) << -72(ffffffb8) = 33554432(2000000)\nunsigned 8 2(2) << -71(ffffffb9) = 67108864(4000000)\nunsigned 8 2(2) << -70(ffffffba) = 134217728(8000000)\nunsigned 8 2(2) << -69(ffffffbb) = 268435456(10000000)\nunsigned 8 2(2) << -68(ffffffbc) = 536870912(20000000)\nunsigned 8 2(2) << -67(ffffffbd) = 1073741824(40000000)\nunsigned 8 2(2) << -66(ffffffbe) = 2147483648(80000000)\nunsigned 8 2(2) << -65(ffffffbf) = 0(0)\nunsigned 8 2(2) << -64(ffffffc0) = 2(2)\nunsigned 8 2(2) << -63(ffffffc1) = 4(4)\nunsigned 8 2(2) << -62(ffffffc2) = 8(8)\nunsigned 8 2(2) << -61(ffffffc3) = 16(10)\nunsigned 8 2(2) << -60(ffffffc4) = 32(20)\nunsigned 8 2(2) << -59(ffffffc5) = 64(40)\nunsigned 8 2(2) << -58(ffffffc6) = 128(80)\nunsigned 8 2(2) << -57(ffffffc7) = 256(100)\nunsigned 8 2(2) << -56(ffffffc8) = 512(200)\nunsigned 8 2(2) << -55(ffffffc9) = 1024(400)\nunsigned 8 2(2) << -54(ffffffca) = 2048(800)\nunsigned 8 2(2) << -53(ffffffcb) = 4096(1000)\nunsigned 8 2(2) << -52(ffffffcc) = 8192(2000)\nunsigned 8 2(2) << -51(ffffffcd) = 16384(4000)\nunsigned 8 2(2) << -50(ffffffce) = 32768(8000)\nunsigned 8 2(2) << -49(ffffffcf) = 65536(10000)\nunsigned 8 2(2) << -48(ffffffd0) = 131072(20000)\nunsigned 8 2(2) << -47(ffffffd1) = 262144(40000)\nunsigned 8 2(2) << -46(ffffffd2) = 524288(80000)\nunsigned 8 2(2) << -45(ffffffd3) = 1048576(100000)\nunsigned 8 2(2) << -44(ffffffd4) = 2097152(200000)\nunsigned 8 2(2) << -43(ffffffd5) = 4194304(400000)\nunsigned 8 2(2) << -42(ffffffd6) = 8388608(800000)\nunsigned 8 2(2) << -41(ffffffd7) = 16777216(1000000)\nunsigned 8 2(2) << -40(ffffffd8) = 33554432(2000000)\nunsigned 8 2(2) << -39(ffffffd9) = 67108864(4000000)\nunsigned 8 2(2) << -38(ffffffda) = 134217728(8000000)\nunsigned 8 2(2) << -37(ffffffdb) = 268435456(10000000)\nunsigned 8 2(2) << -36(ffffffdc) = 536870912(20000000)\nunsigned 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\nunsigned 8 2(2) << -34(ffffffde) = 2147483648(80000000)\nunsigned 8 2(2) << -33(ffffffdf) = 0(0)\nunsigned 8 2(2) << -32(ffffffe0) = 2(2)\nunsigned 8 2(2) << -31(ffffffe1) = 4(4)\nunsigned 8 2(2) << -30(ffffffe2) = 8(8)\nunsigned 8 2(2) << -29(ffffffe3) = 16(10)\nunsigned 8 2(2) << -28(ffffffe4) = 32(20)\nunsigned 8 2(2) << -27(ffffffe5) = 64(40)\nunsigned 8 2(2) << -26(ffffffe6) = 128(80)\nunsigned 8 2(2) << -25(ffffffe7) = 256(100)\nunsigned 8 2(2) << -24(ffffffe8) = 512(200)\nunsigned 8 2(2) << -23(ffffffe9) = 1024(400)\nunsigned 8 2(2) << -22(ffffffea) = 2048(800)\nunsigned 8 2(2) << -21(ffffffeb) = 4096(1000)\nunsigned 8 2(2) << -20(ffffffec) = 8192(2000)\nunsigned 8 2(2) << -19(ffffffed) = 16384(4000)\nunsigned 8 2(2) << -18(ffffffee) = 32768(8000)\nunsigned 8 2(2) << -17(ffffffef) = 65536(10000)\nunsigned 8 2(2) << -16(fffffff0) = 131072(20000)\nunsigned 8 2(2) << -15(fffffff1) = 262144(40000)\nunsigned 8 2(2) << -14(fffffff2) = 524288(80000)\nunsigned 8 2(2) << -13(fffffff3) = 1048576(100000)\nunsigned 8 2(2) << -12(fffffff4) = 2097152(200000)\nunsigned 8 2(2) << -11(fffffff5) = 4194304(400000)\nunsigned 8 2(2) << -10(fffffff6) = 8388608(800000)\nunsigned 8 2(2) << -9(fffffff7) = 16777216(1000000)\nunsigned 8 2(2) << -8(fffffff8) = 33554432(2000000)\nunsigned 8 2(2) << -7(fffffff9) = 67108864(4000000)\nunsigned 8 2(2) << -6(fffffffa) = 134217728(8000000)\nunsigned 8 2(2) << -5(fffffffb) = 268435456(10000000)\nunsigned 8 2(2) << -4(fffffffc) = 536870912(20000000)\nunsigned 8 2(2) << -3(fffffffd) = 1073741824(40000000)\nunsigned 8 2(2) << -2(fffffffe) = 2147483648(80000000)\nunsigned 8 2(2) << -1(ffffffff) = 0(0)\nunsigned 8 2(2) << 0(0) = 2(2)\nunsigned 8 2(2) << 1(1) = 4(4)\nunsigned 8 2(2) << 2(2) = 8(8)\nunsigned 8 2(2) << 3(3) = 16(10)\nunsigned 8 2(2) << 4(4) = 32(20)\nunsigned 8 2(2) << 5(5) = 64(40)\nunsigned 8 2(2) << 6(6) = 128(80)\nunsigned 8 2(2) << 7(7) = 256(100)\nunsigned 8 2(2) << 8(8) = 512(200)\nunsigned 8 2(2) << 9(9) = 1024(400)\nunsigned 8 2(2) << 10(a) = 2048(800)\nunsigned 8 2(2) << 11(b) = 4096(1000)\nunsigned 8 2(2) << 12(c) = 8192(2000)\nunsigned 8 2(2) << 13(d) = 16384(4000)\nunsigned 8 2(2) << 14(e) = 32768(8000)\nunsigned 8 2(2) << 15(f) = 65536(10000)\nunsigned 8 2(2) << 16(10) = 131072(20000)\nunsigned 8 2(2) << 17(11) = 262144(40000)\nunsigned 8 2(2) << 18(12) = 524288(80000)\nunsigned 8 2(2) << 19(13) = 1048576(100000)\nunsigned 8 2(2) << 20(14) = 2097152(200000)\nunsigned 8 2(2) << 21(15) = 4194304(400000)\nunsigned 8 2(2) << 22(16) = 8388608(800000)\nunsigned 8 2(2) << 23(17) = 16777216(1000000)\nunsigned 8 2(2) << 24(18) = 33554432(2000000)\nunsigned 8 2(2) << 25(19) = 67108864(4000000)\nunsigned 8 2(2) << 26(1a) = 134217728(8000000)\nunsigned 8 2(2) << 27(1b) = 268435456(10000000)\nunsigned 8 2(2) << 28(1c) = 536870912(20000000)\nunsigned 8 2(2) << 29(1d) = 1073741824(40000000)\nunsigned 8 2(2) << 30(1e) = 2147483648(80000000)\nunsigned 8 2(2) << 31(1f) = 0(0)\nunsigned 8 2(2) << 32(20) = 2(2)\nunsigned 8 2(2) << 33(21) = 4(4)\nunsigned 8 2(2) << 34(22) = 8(8)\nunsigned 8 2(2) << 35(23) = 16(10)\nunsigned 8 2(2) << 36(24) = 32(20)\nunsigned 8 2(2) << 37(25) = 64(40)\nunsigned 8 2(2) << 38(26) = 128(80)\nunsigned 8 2(2) << 39(27) = 256(100)\nunsigned 8 2(2) << 40(28) = 512(200)\nunsigned 8 2(2) << 41(29) = 1024(400)\nunsigned 8 2(2) << 42(2a) = 2048(800)\nunsigned 8 2(2) << 43(2b) = 4096(1000)\nunsigned 8 2(2) << 44(2c) = 8192(2000)\nunsigned 8 2(2) << 45(2d) = 16384(4000)\nunsigned 8 2(2) << 46(2e) = 32768(8000)\nunsigned 8 2(2) << 47(2f) = 65536(10000)\nunsigned 8 2(2) << 48(30) = 131072(20000)\nunsigned 8 2(2) << 49(31) = 262144(40000)\nunsigned 8 2(2) << 50(32) = 524288(80000)\nunsigned 8 2(2) << 51(33) = 1048576(100000)\nunsigned 8 2(2) << 52(34) = 2097152(200000)\nunsigned 8 2(2) << 53(35) = 4194304(400000)\nunsigned 8 2(2) << 54(36) = 8388608(800000)\nunsigned 8 2(2) << 55(37) = 16777216(1000000)\nunsigned 8 2(2) << 56(38) = 33554432(2000000)\nunsigned 8 2(2) << 57(39) = 67108864(4000000)\nunsigned 8 2(2) << 58(3a) = 134217728(8000000)\nunsigned 8 2(2) << 59(3b) = 268435456(10000000)\nunsigned 8 2(2) << 60(3c) = 536870912(20000000)\nunsigned 8 2(2) << 61(3d) = 1073741824(40000000)\nunsigned 8 2(2) << 62(3e) = 2147483648(80000000)\nunsigned 8 2(2) << 63(3f) = 0(0)\nunsigned 8 2(2) << 64(40) = 2(2)\nunsigned 8 2(2) << 65(41) = 4(4)\nunsigned 8 2(2) << 66(42) = 8(8)\nunsigned 8 2(2) << 67(43) = 16(10)\nunsigned 8 2(2) << 68(44) = 32(20)\nunsigned 8 2(2) << 69(45) = 64(40)\nunsigned 8 2(2) << 70(46) = 128(80)\nunsigned 8 2(2) << 71(47) = 256(100)\nunsigned 8 2(2) << 72(48) = 512(200)\nunsigned 8 2(2) << 73(49) = 1024(400)\nunsigned 8 2(2) << 74(4a) = 2048(800)\nunsigned 8 2(2) << 75(4b) = 4096(1000)\nunsigned 8 2(2) << 76(4c) = 8192(2000)\nunsigned 8 2(2) << 77(4d) = 16384(4000)\nunsigned 8 2(2) << 78(4e) = 32768(8000)\nunsigned 8 2(2) << 79(4f) = 65536(10000)\nunsigned 8 2(2) << 80(50) = 131072(20000)\nunsigned 8 2(2) << 81(51) = 262144(40000)\nunsigned 8 2(2) << 82(52) = 524288(80000)\nunsigned 8 2(2) << 83(53) = 1048576(100000)\nunsigned 8 2(2) << 84(54) = 2097152(200000)\nunsigned 8 2(2) << 85(55) = 4194304(400000)\nunsigned 8 2(2) << 86(56) = 8388608(800000)\nunsigned 8 2(2) << 87(57) = 16777216(1000000)\nunsigned 8 2(2) << 88(58) = 33554432(2000000)\nunsigned 8 2(2) << 89(59) = 67108864(4000000)\nunsigned 8 2(2) << 90(5a) = 134217728(8000000)\nunsigned 8 2(2) << 91(5b) = 268435456(10000000)\nunsigned 8 2(2) << 92(5c) = 536870912(20000000)\nunsigned 8 2(2) << 93(5d) = 1073741824(40000000)\nunsigned 8 2(2) << 94(5e) = 2147483648(80000000)\nunsigned 8 2(2) << 95(5f) = 0(0)\nunsigned 8 2(2) << 96(60) = 2(2)\nunsigned 8 2(2) << 97(61) = 4(4)\nunsigned 8 2(2) << 98(62) = 8(8)\nunsigned 8 2(2) << 99(63) = 16(10)\nunsigned 8 2(2) << 100(64) = 32(20)\nunsigned 8 2(2) << 101(65) = 64(40)\nunsigned 8 2(2) << 102(66) = 128(80)\nunsigned 8 2(2) << 103(67) = 256(100)\nunsigned 8 2(2) << 104(68) = 512(200)\nunsigned 8 2(2) << 105(69) = 1024(400)\nunsigned 8 2(2) << 106(6a) = 2048(800)\nunsigned 8 2(2) << 107(6b) = 4096(1000)\nunsigned 8 2(2) << 108(6c) = 8192(2000)\nunsigned 8 2(2) << 109(6d) = 16384(4000)\nunsigned 8 2(2) << 110(6e) = 32768(8000)\nunsigned 8 2(2) << 111(6f) = 65536(10000)\nunsigned 8 2(2) << 112(70) = 131072(20000)\nunsigned 8 2(2) << 113(71) = 262144(40000)\nunsigned 8 2(2) << 114(72) = 524288(80000)\nunsigned 8 2(2) << 115(73) = 1048576(100000)\nunsigned 8 2(2) << 116(74) = 2097152(200000)\nunsigned 8 2(2) << 117(75) = 4194304(400000)\nunsigned 8 2(2) << 118(76) = 8388608(800000)\nunsigned 8 2(2) << 119(77) = 16777216(1000000)\nunsigned 8 2(2) << 120(78) = 33554432(2000000)\nunsigned 8 2(2) << 121(79) = 67108864(4000000)\nunsigned 8 2(2) << 122(7a) = 134217728(8000000)\nunsigned 8 2(2) << 123(7b) = 268435456(10000000)\nunsigned 8 2(2) << 124(7c) = 536870912(20000000)\nunsigned 8 2(2) << 125(7d) = 1073741824(40000000)\nunsigned 8 2(2) << 126(7e) = 2147483648(80000000)\nunsigned 8 2(2) << 127(7f) = 0(0)\nunsigned 8 3(3) << -128(ffffff80) = 3(3)\nunsigned 8 3(3) << -127(ffffff81) = 6(6)\nunsigned 8 3(3) << -126(ffffff82) = 12(c)\nunsigned 8 3(3) << -125(ffffff83) = 24(18)\nunsigned 8 3(3) << -124(ffffff84) = 48(30)\nunsigned 8 3(3) << -123(ffffff85) = 96(60)\nunsigned 8 3(3) << -122(ffffff86) = 192(c0)\nunsigned 8 3(3) << -121(ffffff87) = 384(180)\nunsigned 8 3(3) << -120(ffffff88) = 768(300)\nunsigned 8 3(3) << -119(ffffff89) = 1536(600)\nunsigned 8 3(3) << -118(ffffff8a) = 3072(c00)\nunsigned 8 3(3) << -117(ffffff8b) = 6144(1800)\nunsigned 8 3(3) << -116(ffffff8c) = 12288(3000)\nunsigned 8 3(3) << -115(ffffff8d) = 24576(6000)\nunsigned 8 3(3) << -114(ffffff8e) = 49152(c000)\nunsigned 8 3(3) << -113(ffffff8f) = 98304(18000)\nunsigned 8 3(3) << -112(ffffff90) = 196608(30000)\nunsigned 8 3(3) << -111(ffffff91) = 393216(60000)\nunsigned 8 3(3) << -110(ffffff92) = 786432(c0000)\nunsigned 8 3(3) << -109(ffffff93) = 1572864(180000)\nunsigned 8 3(3) << -108(ffffff94) = 3145728(300000)\nunsigned 8 3(3) << -107(ffffff95) = 6291456(600000)\nunsigned 8 3(3) << -106(ffffff96) = 12582912(c00000)\nunsigned 8 3(3) << -105(ffffff97) = 25165824(1800000)\nunsigned 8 3(3) << -104(ffffff98) = 50331648(3000000)\nunsigned 8 3(3) << -103(ffffff99) = 100663296(6000000)\nunsigned 8 3(3) << -102(ffffff9a) = 201326592(c000000)\nunsigned 8 3(3) << -101(ffffff9b) = 402653184(18000000)\nunsigned 8 3(3) << -100(ffffff9c) = 805306368(30000000)\nunsigned 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\nunsigned 8 3(3) << -98(ffffff9e) = 3221225472(c0000000)\nunsigned 8 3(3) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 3(3) << -96(ffffffa0) = 3(3)\nunsigned 8 3(3) << -95(ffffffa1) = 6(6)\nunsigned 8 3(3) << -94(ffffffa2) = 12(c)\nunsigned 8 3(3) << -93(ffffffa3) = 24(18)\nunsigned 8 3(3) << -92(ffffffa4) = 48(30)\nunsigned 8 3(3) << -91(ffffffa5) = 96(60)\nunsigned 8 3(3) << -90(ffffffa6) = 192(c0)\nunsigned 8 3(3) << -89(ffffffa7) = 384(180)\nunsigned 8 3(3) << -88(ffffffa8) = 768(300)\nunsigned 8 3(3) << -87(ffffffa9) = 1536(600)\nunsigned 8 3(3) << -86(ffffffaa) = 3072(c00)\nunsigned 8 3(3) << -85(ffffffab) = 6144(1800)\nunsigned 8 3(3) << -84(ffffffac) = 12288(3000)\nunsigned 8 3(3) << -83(ffffffad) = 24576(6000)\nunsigned 8 3(3) << -82(ffffffae) = 49152(c000)\nunsigned 8 3(3) << -81(ffffffaf) = 98304(18000)\nunsigned 8 3(3) << -80(ffffffb0) = 196608(30000)\nunsigned 8 3(3) << -79(ffffffb1) = 393216(60000)\nunsigned 8 3(3) << -78(ffffffb2) = 786432(c0000)\nunsigned 8 3(3) << -77(ffffffb3) = 1572864(180000)\nunsigned 8 3(3) << -76(ffffffb4) = 3145728(300000)\nunsigned 8 3(3) << -75(ffffffb5) = 6291456(600000)\nunsigned 8 3(3) << -74(ffffffb6) = 12582912(c00000)\nunsigned 8 3(3) << -73(ffffffb7) = 25165824(1800000)\nunsigned 8 3(3) << -72(ffffffb8) = 50331648(3000000)\nunsigned 8 3(3) << -71(ffffffb9) = 100663296(6000000)\nunsigned 8 3(3) << -70(ffffffba) = 201326592(c000000)\nunsigned 8 3(3) << -69(ffffffbb) = 402653184(18000000)\nunsigned 8 3(3) << -68(ffffffbc) = 805306368(30000000)\nunsigned 8 3(3) << -67(ffffffbd) = 1610612736(60000000)\nunsigned 8 3(3) << -66(ffffffbe) = 3221225472(c0000000)\nunsigned 8 3(3) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 3(3) << -64(ffffffc0) = 3(3)\nunsigned 8 3(3) << -63(ffffffc1) = 6(6)\nunsigned 8 3(3) << -62(ffffffc2) = 12(c)\nunsigned 8 3(3) << -61(ffffffc3) = 24(18)\nunsigned 8 3(3) << -60(ffffffc4) = 48(30)\nunsigned 8 3(3) << -59(ffffffc5) = 96(60)\nunsigned 8 3(3) << -58(ffffffc6) = 192(c0)\nunsigned 8 3(3) << -57(ffffffc7) = 384(180)\nunsigned 8 3(3) << -56(ffffffc8) = 768(300)\nunsigned 8 3(3) << -55(ffffffc9) = 1536(600)\nunsigned 8 3(3) << -54(ffffffca) = 3072(c00)\nunsigned 8 3(3) << -53(ffffffcb) = 6144(1800)\nunsigned 8 3(3) << -52(ffffffcc) = 12288(3000)\nunsigned 8 3(3) << -51(ffffffcd) = 24576(6000)\nunsigned 8 3(3) << -50(ffffffce) = 49152(c000)\nunsigned 8 3(3) << -49(ffffffcf) = 98304(18000)\nunsigned 8 3(3) << -48(ffffffd0) = 196608(30000)\nunsigned 8 3(3) << -47(ffffffd1) = 393216(60000)\nunsigned 8 3(3) << -46(ffffffd2) = 786432(c0000)\nunsigned 8 3(3) << -45(ffffffd3) = 1572864(180000)\nunsigned 8 3(3) << -44(ffffffd4) = 3145728(300000)\nunsigned 8 3(3) << -43(ffffffd5) = 6291456(600000)\nunsigned 8 3(3) << -42(ffffffd6) = 12582912(c00000)\nunsigned 8 3(3) << -41(ffffffd7) = 25165824(1800000)\nunsigned 8 3(3) << -40(ffffffd8) = 50331648(3000000)\nunsigned 8 3(3) << -39(ffffffd9) = 100663296(6000000)\nunsigned 8 3(3) << -38(ffffffda) = 201326592(c000000)\nunsigned 8 3(3) << -37(ffffffdb) = 402653184(18000000)\nunsigned 8 3(3) << -36(ffffffdc) = 805306368(30000000)\nunsigned 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\nunsigned 8 3(3) << -34(ffffffde) = 3221225472(c0000000)\nunsigned 8 3(3) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 3(3) << -32(ffffffe0) = 3(3)\nunsigned 8 3(3) << -31(ffffffe1) = 6(6)\nunsigned 8 3(3) << -30(ffffffe2) = 12(c)\nunsigned 8 3(3) << -29(ffffffe3) = 24(18)\nunsigned 8 3(3) << -28(ffffffe4) = 48(30)\nunsigned 8 3(3) << -27(ffffffe5) = 96(60)\nunsigned 8 3(3) << -26(ffffffe6) = 192(c0)\nunsigned 8 3(3) << -25(ffffffe7) = 384(180)\nunsigned 8 3(3) << -24(ffffffe8) = 768(300)\nunsigned 8 3(3) << -23(ffffffe9) = 1536(600)\nunsigned 8 3(3) << -22(ffffffea) = 3072(c00)\nunsigned 8 3(3) << -21(ffffffeb) = 6144(1800)\nunsigned 8 3(3) << -20(ffffffec) = 12288(3000)\nunsigned 8 3(3) << -19(ffffffed) = 24576(6000)\nunsigned 8 3(3) << -18(ffffffee) = 49152(c000)\nunsigned 8 3(3) << -17(ffffffef) = 98304(18000)\nunsigned 8 3(3) << -16(fffffff0) = 196608(30000)\nunsigned 8 3(3) << -15(fffffff1) = 393216(60000)\nunsigned 8 3(3) << -14(fffffff2) = 786432(c0000)\nunsigned 8 3(3) << -13(fffffff3) = 1572864(180000)\nunsigned 8 3(3) << -12(fffffff4) = 3145728(300000)\nunsigned 8 3(3) << -11(fffffff5) = 6291456(600000)\nunsigned 8 3(3) << -10(fffffff6) = 12582912(c00000)\nunsigned 8 3(3) << -9(fffffff7) = 25165824(1800000)\nunsigned 8 3(3) << -8(fffffff8) = 50331648(3000000)\nunsigned 8 3(3) << -7(fffffff9) = 100663296(6000000)\nunsigned 8 3(3) << -6(fffffffa) = 201326592(c000000)\nunsigned 8 3(3) << -5(fffffffb) = 402653184(18000000)\nunsigned 8 3(3) << -4(fffffffc) = 805306368(30000000)\nunsigned 8 3(3) << -3(fffffffd) = 1610612736(60000000)\nunsigned 8 3(3) << -2(fffffffe) = 3221225472(c0000000)\nunsigned 8 3(3) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 3(3) << 0(0) = 3(3)\nunsigned 8 3(3) << 1(1) = 6(6)\nunsigned 8 3(3) << 2(2) = 12(c)\nunsigned 8 3(3) << 3(3) = 24(18)\nunsigned 8 3(3) << 4(4) = 48(30)\nunsigned 8 3(3) << 5(5) = 96(60)\nunsigned 8 3(3) << 6(6) = 192(c0)\nunsigned 8 3(3) << 7(7) = 384(180)\nunsigned 8 3(3) << 8(8) = 768(300)\nunsigned 8 3(3) << 9(9) = 1536(600)\nunsigned 8 3(3) << 10(a) = 3072(c00)\nunsigned 8 3(3) << 11(b) = 6144(1800)\nunsigned 8 3(3) << 12(c) = 12288(3000)\nunsigned 8 3(3) << 13(d) = 24576(6000)\nunsigned 8 3(3) << 14(e) = 49152(c000)\nunsigned 8 3(3) << 15(f) = 98304(18000)\nunsigned 8 3(3) << 16(10) = 196608(30000)\nunsigned 8 3(3) << 17(11) = 393216(60000)\nunsigned 8 3(3) << 18(12) = 786432(c0000)\nunsigned 8 3(3) << 19(13) = 1572864(180000)\nunsigned 8 3(3) << 20(14) = 3145728(300000)\nunsigned 8 3(3) << 21(15) = 6291456(600000)\nunsigned 8 3(3) << 22(16) = 12582912(c00000)\nunsigned 8 3(3) << 23(17) = 25165824(1800000)\nunsigned 8 3(3) << 24(18) = 50331648(3000000)\nunsigned 8 3(3) << 25(19) = 100663296(6000000)\nunsigned 8 3(3) << 26(1a) = 201326592(c000000)\nunsigned 8 3(3) << 27(1b) = 402653184(18000000)\nunsigned 8 3(3) << 28(1c) = 805306368(30000000)\nunsigned 8 3(3) << 29(1d) = 1610612736(60000000)\nunsigned 8 3(3) << 30(1e) = 3221225472(c0000000)\nunsigned 8 3(3) << 31(1f) = 2147483648(80000000)\nunsigned 8 3(3) << 32(20) = 3(3)\nunsigned 8 3(3) << 33(21) = 6(6)\nunsigned 8 3(3) << 34(22) = 12(c)\nunsigned 8 3(3) << 35(23) = 24(18)\nunsigned 8 3(3) << 36(24) = 48(30)\nunsigned 8 3(3) << 37(25) = 96(60)\nunsigned 8 3(3) << 38(26) = 192(c0)\nunsigned 8 3(3) << 39(27) = 384(180)\nunsigned 8 3(3) << 40(28) = 768(300)\nunsigned 8 3(3) << 41(29) = 1536(600)\nunsigned 8 3(3) << 42(2a) = 3072(c00)\nunsigned 8 3(3) << 43(2b) = 6144(1800)\nunsigned 8 3(3) << 44(2c) = 12288(3000)\nunsigned 8 3(3) << 45(2d) = 24576(6000)\nunsigned 8 3(3) << 46(2e) = 49152(c000)\nunsigned 8 3(3) << 47(2f) = 98304(18000)\nunsigned 8 3(3) << 48(30) = 196608(30000)\nunsigned 8 3(3) << 49(31) = 393216(60000)\nunsigned 8 3(3) << 50(32) = 786432(c0000)\nunsigned 8 3(3) << 51(33) = 1572864(180000)\nunsigned 8 3(3) << 52(34) = 3145728(300000)\nunsigned 8 3(3) << 53(35) = 6291456(600000)\nunsigned 8 3(3) << 54(36) = 12582912(c00000)\nunsigned 8 3(3) << 55(37) = 25165824(1800000)\nunsigned 8 3(3) << 56(38) = 50331648(3000000)\nunsigned 8 3(3) << 57(39) = 100663296(6000000)\nunsigned 8 3(3) << 58(3a) = 201326592(c000000)\nunsigned 8 3(3) << 59(3b) = 402653184(18000000)\nunsigned 8 3(3) << 60(3c) = 805306368(30000000)\nunsigned 8 3(3) << 61(3d) = 1610612736(60000000)\nunsigned 8 3(3) << 62(3e) = 3221225472(c0000000)\nunsigned 8 3(3) << 63(3f) = 2147483648(80000000)\nunsigned 8 3(3) << 64(40) = 3(3)\nunsigned 8 3(3) << 65(41) = 6(6)\nunsigned 8 3(3) << 66(42) = 12(c)\nunsigned 8 3(3) << 67(43) = 24(18)\nunsigned 8 3(3) << 68(44) = 48(30)\nunsigned 8 3(3) << 69(45) = 96(60)\nunsigned 8 3(3) << 70(46) = 192(c0)\nunsigned 8 3(3) << 71(47) = 384(180)\nunsigned 8 3(3) << 72(48) = 768(300)\nunsigned 8 3(3) << 73(49) = 1536(600)\nunsigned 8 3(3) << 74(4a) = 3072(c00)\nunsigned 8 3(3) << 75(4b) = 6144(1800)\nunsigned 8 3(3) << 76(4c) = 12288(3000)\nunsigned 8 3(3) << 77(4d) = 24576(6000)\nunsigned 8 3(3) << 78(4e) = 49152(c000)\nunsigned 8 3(3) << 79(4f) = 98304(18000)\nunsigned 8 3(3) << 80(50) = 196608(30000)\nunsigned 8 3(3) << 81(51) = 393216(60000)\nunsigned 8 3(3) << 82(52) = 786432(c0000)\nunsigned 8 3(3) << 83(53) = 1572864(180000)\nunsigned 8 3(3) << 84(54) = 3145728(300000)\nunsigned 8 3(3) << 85(55) = 6291456(600000)\nunsigned 8 3(3) << 86(56) = 12582912(c00000)\nunsigned 8 3(3) << 87(57) = 25165824(1800000)\nunsigned 8 3(3) << 88(58) = 50331648(3000000)\nunsigned 8 3(3) << 89(59) = 100663296(6000000)\nunsigned 8 3(3) << 90(5a) = 201326592(c000000)\nunsigned 8 3(3) << 91(5b) = 402653184(18000000)\nunsigned 8 3(3) << 92(5c) = 805306368(30000000)\nunsigned 8 3(3) << 93(5d) = 1610612736(60000000)\nunsigned 8 3(3) << 94(5e) = 3221225472(c0000000)\nunsigned 8 3(3) << 95(5f) = 2147483648(80000000)\nunsigned 8 3(3) << 96(60) = 3(3)\nunsigned 8 3(3) << 97(61) = 6(6)\nunsigned 8 3(3) << 98(62) = 12(c)\nunsigned 8 3(3) << 99(63) = 24(18)\nunsigned 8 3(3) << 100(64) = 48(30)\nunsigned 8 3(3) << 101(65) = 96(60)\nunsigned 8 3(3) << 102(66) = 192(c0)\nunsigned 8 3(3) << 103(67) = 384(180)\nunsigned 8 3(3) << 104(68) = 768(300)\nunsigned 8 3(3) << 105(69) = 1536(600)\nunsigned 8 3(3) << 106(6a) = 3072(c00)\nunsigned 8 3(3) << 107(6b) = 6144(1800)\nunsigned 8 3(3) << 108(6c) = 12288(3000)\nunsigned 8 3(3) << 109(6d) = 24576(6000)\nunsigned 8 3(3) << 110(6e) = 49152(c000)\nunsigned 8 3(3) << 111(6f) = 98304(18000)\nunsigned 8 3(3) << 112(70) = 196608(30000)\nunsigned 8 3(3) << 113(71) = 393216(60000)\nunsigned 8 3(3) << 114(72) = 786432(c0000)\nunsigned 8 3(3) << 115(73) = 1572864(180000)\nunsigned 8 3(3) << 116(74) = 3145728(300000)\nunsigned 8 3(3) << 117(75) = 6291456(600000)\nunsigned 8 3(3) << 118(76) = 12582912(c00000)\nunsigned 8 3(3) << 119(77) = 25165824(1800000)\nunsigned 8 3(3) << 120(78) = 50331648(3000000)\nunsigned 8 3(3) << 121(79) = 100663296(6000000)\nunsigned 8 3(3) << 122(7a) = 201326592(c000000)\nunsigned 8 3(3) << 123(7b) = 402653184(18000000)\nunsigned 8 3(3) << 124(7c) = 805306368(30000000)\nunsigned 8 3(3) << 125(7d) = 1610612736(60000000)\nunsigned 8 3(3) << 126(7e) = 3221225472(c0000000)\nunsigned 8 3(3) << 127(7f) = 2147483648(80000000)\nunsigned 8 4(4) << -128(ffffff80) = 4(4)\nunsigned 8 4(4) << -127(ffffff81) = 8(8)\nunsigned 8 4(4) << -126(ffffff82) = 16(10)\nunsigned 8 4(4) << -125(ffffff83) = 32(20)\nunsigned 8 4(4) << -124(ffffff84) = 64(40)\nunsigned 8 4(4) << -123(ffffff85) = 128(80)\nunsigned 8 4(4) << -122(ffffff86) = 256(100)\nunsigned 8 4(4) << -121(ffffff87) = 512(200)\nunsigned 8 4(4) << -120(ffffff88) = 1024(400)\nunsigned 8 4(4) << -119(ffffff89) = 2048(800)\nunsigned 8 4(4) << -118(ffffff8a) = 4096(1000)\nunsigned 8 4(4) << -117(ffffff8b) = 8192(2000)\nunsigned 8 4(4) << -116(ffffff8c) = 16384(4000)\nunsigned 8 4(4) << -115(ffffff8d) = 32768(8000)\nunsigned 8 4(4) << -114(ffffff8e) = 65536(10000)\nunsigned 8 4(4) << -113(ffffff8f) = 131072(20000)\nunsigned 8 4(4) << -112(ffffff90) = 262144(40000)\nunsigned 8 4(4) << -111(ffffff91) = 524288(80000)\nunsigned 8 4(4) << -110(ffffff92) = 1048576(100000)\nunsigned 8 4(4) << -109(ffffff93) = 2097152(200000)\nunsigned 8 4(4) << -108(ffffff94) = 4194304(400000)\nunsigned 8 4(4) << -107(ffffff95) = 8388608(800000)\nunsigned 8 4(4) << -106(ffffff96) = 16777216(1000000)\nunsigned 8 4(4) << -105(ffffff97) = 33554432(2000000)\nunsigned 8 4(4) << -104(ffffff98) = 67108864(4000000)\nunsigned 8 4(4) << -103(ffffff99) = 134217728(8000000)\nunsigned 8 4(4) << -102(ffffff9a) = 268435456(10000000)\nunsigned 8 4(4) << -101(ffffff9b) = 536870912(20000000)\nunsigned 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\nunsigned 8 4(4) << -99(ffffff9d) = 2147483648(80000000)\nunsigned 8 4(4) << -98(ffffff9e) = 0(0)\nunsigned 8 4(4) << -97(ffffff9f) = 0(0)\nunsigned 8 4(4) << -96(ffffffa0) = 4(4)\nunsigned 8 4(4) << -95(ffffffa1) = 8(8)\nunsigned 8 4(4) << -94(ffffffa2) = 16(10)\nunsigned 8 4(4) << -93(ffffffa3) = 32(20)\nunsigned 8 4(4) << -92(ffffffa4) = 64(40)\nunsigned 8 4(4) << -91(ffffffa5) = 128(80)\nunsigned 8 4(4) << -90(ffffffa6) = 256(100)\nunsigned 8 4(4) << -89(ffffffa7) = 512(200)\nunsigned 8 4(4) << -88(ffffffa8) = 1024(400)\nunsigned 8 4(4) << -87(ffffffa9) = 2048(800)\nunsigned 8 4(4) << -86(ffffffaa) = 4096(1000)\nunsigned 8 4(4) << -85(ffffffab) = 8192(2000)\nunsigned 8 4(4) << -84(ffffffac) = 16384(4000)\nunsigned 8 4(4) << -83(ffffffad) = 32768(8000)\nunsigned 8 4(4) << -82(ffffffae) = 65536(10000)\nunsigned 8 4(4) << -81(ffffffaf) = 131072(20000)\nunsigned 8 4(4) << -80(ffffffb0) = 262144(40000)\nunsigned 8 4(4) << -79(ffffffb1) = 524288(80000)\nunsigned 8 4(4) << -78(ffffffb2) = 1048576(100000)\nunsigned 8 4(4) << -77(ffffffb3) = 2097152(200000)\nunsigned 8 4(4) << -76(ffffffb4) = 4194304(400000)\nunsigned 8 4(4) << -75(ffffffb5) = 8388608(800000)\nunsigned 8 4(4) << -74(ffffffb6) = 16777216(1000000)\nunsigned 8 4(4) << -73(ffffffb7) = 33554432(2000000)\nunsigned 8 4(4) << -72(ffffffb8) = 67108864(4000000)\nunsigned 8 4(4) << -71(ffffffb9) = 134217728(8000000)\nunsigned 8 4(4) << -70(ffffffba) = 268435456(10000000)\nunsigned 8 4(4) << -69(ffffffbb) = 536870912(20000000)\nunsigned 8 4(4) << -68(ffffffbc) = 1073741824(40000000)\nunsigned 8 4(4) << -67(ffffffbd) = 2147483648(80000000)\nunsigned 8 4(4) << -66(ffffffbe) = 0(0)\nunsigned 8 4(4) << -65(ffffffbf) = 0(0)\nunsigned 8 4(4) << -64(ffffffc0) = 4(4)\nunsigned 8 4(4) << -63(ffffffc1) = 8(8)\nunsigned 8 4(4) << -62(ffffffc2) = 16(10)\nunsigned 8 4(4) << -61(ffffffc3) = 32(20)\nunsigned 8 4(4) << -60(ffffffc4) = 64(40)\nunsigned 8 4(4) << -59(ffffffc5) = 128(80)\nunsigned 8 4(4) << -58(ffffffc6) = 256(100)\nunsigned 8 4(4) << -57(ffffffc7) = 512(200)\nunsigned 8 4(4) << -56(ffffffc8) = 1024(400)\nunsigned 8 4(4) << -55(ffffffc9) = 2048(800)\nunsigned 8 4(4) << -54(ffffffca) = 4096(1000)\nunsigned 8 4(4) << -53(ffffffcb) = 8192(2000)\nunsigned 8 4(4) << -52(ffffffcc) = 16384(4000)\nunsigned 8 4(4) << -51(ffffffcd) = 32768(8000)\nunsigned 8 4(4) << -50(ffffffce) = 65536(10000)\nunsigned 8 4(4) << -49(ffffffcf) = 131072(20000)\nunsigned 8 4(4) << -48(ffffffd0) = 262144(40000)\nunsigned 8 4(4) << -47(ffffffd1) = 524288(80000)\nunsigned 8 4(4) << -46(ffffffd2) = 1048576(100000)\nunsigned 8 4(4) << -45(ffffffd3) = 2097152(200000)\nunsigned 8 4(4) << -44(ffffffd4) = 4194304(400000)\nunsigned 8 4(4) << -43(ffffffd5) = 8388608(800000)\nunsigned 8 4(4) << -42(ffffffd6) = 16777216(1000000)\nunsigned 8 4(4) << -41(ffffffd7) = 33554432(2000000)\nunsigned 8 4(4) << -40(ffffffd8) = 67108864(4000000)\nunsigned 8 4(4) << -39(ffffffd9) = 134217728(8000000)\nunsigned 8 4(4) << -38(ffffffda) = 268435456(10000000)\nunsigned 8 4(4) << -37(ffffffdb) = 536870912(20000000)\nunsigned 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\nunsigned 8 4(4) << -35(ffffffdd) = 2147483648(80000000)\nunsigned 8 4(4) << -34(ffffffde) = 0(0)\nunsigned 8 4(4) << -33(ffffffdf) = 0(0)\nunsigned 8 4(4) << -32(ffffffe0) = 4(4)\nunsigned 8 4(4) << -31(ffffffe1) = 8(8)\nunsigned 8 4(4) << -30(ffffffe2) = 16(10)\nunsigned 8 4(4) << -29(ffffffe3) = 32(20)\nunsigned 8 4(4) << -28(ffffffe4) = 64(40)\nunsigned 8 4(4) << -27(ffffffe5) = 128(80)\nunsigned 8 4(4) << -26(ffffffe6) = 256(100)\nunsigned 8 4(4) << -25(ffffffe7) = 512(200)\nunsigned 8 4(4) << -24(ffffffe8) = 1024(400)\nunsigned 8 4(4) << -23(ffffffe9) = 2048(800)\nunsigned 8 4(4) << -22(ffffffea) = 4096(1000)\nunsigned 8 4(4) << -21(ffffffeb) = 8192(2000)\nunsigned 8 4(4) << -20(ffffffec) = 16384(4000)\nunsigned 8 4(4) << -19(ffffffed) = 32768(8000)\nunsigned 8 4(4) << -18(ffffffee) = 65536(10000)\nunsigned 8 4(4) << -17(ffffffef) = 131072(20000)\nunsigned 8 4(4) << -16(fffffff0) = 262144(40000)\nunsigned 8 4(4) << -15(fffffff1) = 524288(80000)\nunsigned 8 4(4) << -14(fffffff2) = 1048576(100000)\nunsigned 8 4(4) << -13(fffffff3) = 2097152(200000)\nunsigned 8 4(4) << -12(fffffff4) = 4194304(400000)\nunsigned 8 4(4) << -11(fffffff5) = 8388608(800000)\nunsigned 8 4(4) << -10(fffffff6) = 16777216(1000000)\nunsigned 8 4(4) << -9(fffffff7) = 33554432(2000000)\nunsigned 8 4(4) << -8(fffffff8) = 67108864(4000000)\nunsigned 8 4(4) << -7(fffffff9) = 134217728(8000000)\nunsigned 8 4(4) << -6(fffffffa) = 268435456(10000000)\nunsigned 8 4(4) << -5(fffffffb) = 536870912(20000000)\nunsigned 8 4(4) << -4(fffffffc) = 1073741824(40000000)\nunsigned 8 4(4) << -3(fffffffd) = 2147483648(80000000)\nunsigned 8 4(4) << -2(fffffffe) = 0(0)\nunsigned 8 4(4) << -1(ffffffff) = 0(0)\nunsigned 8 4(4) << 0(0) = 4(4)\nunsigned 8 4(4) << 1(1) = 8(8)\nunsigned 8 4(4) << 2(2) = 16(10)\nunsigned 8 4(4) << 3(3) = 32(20)\nunsigned 8 4(4) << 4(4) = 64(40)\nunsigned 8 4(4) << 5(5) = 128(80)\nunsigned 8 4(4) << 6(6) = 256(100)\nunsigned 8 4(4) << 7(7) = 512(200)\nunsigned 8 4(4) << 8(8) = 1024(400)\nunsigned 8 4(4) << 9(9) = 2048(800)\nunsigned 8 4(4) << 10(a) = 4096(1000)\nunsigned 8 4(4) << 11(b) = 8192(2000)\nunsigned 8 4(4) << 12(c) = 16384(4000)\nunsigned 8 4(4) << 13(d) = 32768(8000)\nunsigned 8 4(4) << 14(e) = 65536(10000)\nunsigned 8 4(4) << 15(f) = 131072(20000)\nunsigned 8 4(4) << 16(10) = 262144(40000)\nunsigned 8 4(4) << 17(11) = 524288(80000)\nunsigned 8 4(4) << 18(12) = 1048576(100000)\nunsigned 8 4(4) << 19(13) = 2097152(200000)\nunsigned 8 4(4) << 20(14) = 4194304(400000)\nunsigned 8 4(4) << 21(15) = 8388608(800000)\nunsigned 8 4(4) << 22(16) = 16777216(1000000)\nunsigned 8 4(4) << 23(17) = 33554432(2000000)\nunsigned 8 4(4) << 24(18) = 67108864(4000000)\nunsigned 8 4(4) << 25(19) = 134217728(8000000)\nunsigned 8 4(4) << 26(1a) = 268435456(10000000)\nunsigned 8 4(4) << 27(1b) = 536870912(20000000)\nunsigned 8 4(4) << 28(1c) = 1073741824(40000000)\nunsigned 8 4(4) << 29(1d) = 2147483648(80000000)\nunsigned 8 4(4) << 30(1e) = 0(0)\nunsigned 8 4(4) << 31(1f) = 0(0)\nunsigned 8 4(4) << 32(20) = 4(4)\nunsigned 8 4(4) << 33(21) = 8(8)\nunsigned 8 4(4) << 34(22) = 16(10)\nunsigned 8 4(4) << 35(23) = 32(20)\nunsigned 8 4(4) << 36(24) = 64(40)\nunsigned 8 4(4) << 37(25) = 128(80)\nunsigned 8 4(4) << 38(26) = 256(100)\nunsigned 8 4(4) << 39(27) = 512(200)\nunsigned 8 4(4) << 40(28) = 1024(400)\nunsigned 8 4(4) << 41(29) = 2048(800)\nunsigned 8 4(4) << 42(2a) = 4096(1000)\nunsigned 8 4(4) << 43(2b) = 8192(2000)\nunsigned 8 4(4) << 44(2c) = 16384(4000)\nunsigned 8 4(4) << 45(2d) = 32768(8000)\nunsigned 8 4(4) << 46(2e) = 65536(10000)\nunsigned 8 4(4) << 47(2f) = 131072(20000)\nunsigned 8 4(4) << 48(30) = 262144(40000)\nunsigned 8 4(4) << 49(31) = 524288(80000)\nunsigned 8 4(4) << 50(32) = 1048576(100000)\nunsigned 8 4(4) << 51(33) = 2097152(200000)\nunsigned 8 4(4) << 52(34) = 4194304(400000)\nunsigned 8 4(4) << 53(35) = 8388608(800000)\nunsigned 8 4(4) << 54(36) = 16777216(1000000)\nunsigned 8 4(4) << 55(37) = 33554432(2000000)\nunsigned 8 4(4) << 56(38) = 67108864(4000000)\nunsigned 8 4(4) << 57(39) = 134217728(8000000)\nunsigned 8 4(4) << 58(3a) = 268435456(10000000)\nunsigned 8 4(4) << 59(3b) = 536870912(20000000)\nunsigned 8 4(4) << 60(3c) = 1073741824(40000000)\nunsigned 8 4(4) << 61(3d) = 2147483648(80000000)\nunsigned 8 4(4) << 62(3e) = 0(0)\nunsigned 8 4(4) << 63(3f) = 0(0)\nunsigned 8 4(4) << 64(40) = 4(4)\nunsigned 8 4(4) << 65(41) = 8(8)\nunsigned 8 4(4) << 66(42) = 16(10)\nunsigned 8 4(4) << 67(43) = 32(20)\nunsigned 8 4(4) << 68(44) = 64(40)\nunsigned 8 4(4) << 69(45) = 128(80)\nunsigned 8 4(4) << 70(46) = 256(100)\nunsigned 8 4(4) << 71(47) = 512(200)\nunsigned 8 4(4) << 72(48) = 1024(400)\nunsigned 8 4(4) << 73(49) = 2048(800)\nunsigned 8 4(4) << 74(4a) = 4096(1000)\nunsigned 8 4(4) << 75(4b) = 8192(2000)\nunsigned 8 4(4) << 76(4c) = 16384(4000)\nunsigned 8 4(4) << 77(4d) = 32768(8000)\nunsigned 8 4(4) << 78(4e) = 65536(10000)\nunsigned 8 4(4) << 79(4f) = 131072(20000)\nunsigned 8 4(4) << 80(50) = 262144(40000)\nunsigned 8 4(4) << 81(51) = 524288(80000)\nunsigned 8 4(4) << 82(52) = 1048576(100000)\nunsigned 8 4(4) << 83(53) = 2097152(200000)\nunsigned 8 4(4) << 84(54) = 4194304(400000)\nunsigned 8 4(4) << 85(55) = 8388608(800000)\nunsigned 8 4(4) << 86(56) = 16777216(1000000)\nunsigned 8 4(4) << 87(57) = 33554432(2000000)\nunsigned 8 4(4) << 88(58) = 67108864(4000000)\nunsigned 8 4(4) << 89(59) = 134217728(8000000)\nunsigned 8 4(4) << 90(5a) = 268435456(10000000)\nunsigned 8 4(4) << 91(5b) = 536870912(20000000)\nunsigned 8 4(4) << 92(5c) = 1073741824(40000000)\nunsigned 8 4(4) << 93(5d) = 2147483648(80000000)\nunsigned 8 4(4) << 94(5e) = 0(0)\nunsigned 8 4(4) << 95(5f) = 0(0)\nunsigned 8 4(4) << 96(60) = 4(4)\nunsigned 8 4(4) << 97(61) = 8(8)\nunsigned 8 4(4) << 98(62) = 16(10)\nunsigned 8 4(4) << 99(63) = 32(20)\nunsigned 8 4(4) << 100(64) = 64(40)\nunsigned 8 4(4) << 101(65) = 128(80)\nunsigned 8 4(4) << 102(66) = 256(100)\nunsigned 8 4(4) << 103(67) = 512(200)\nunsigned 8 4(4) << 104(68) = 1024(400)\nunsigned 8 4(4) << 105(69) = 2048(800)\nunsigned 8 4(4) << 106(6a) = 4096(1000)\nunsigned 8 4(4) << 107(6b) = 8192(2000)\nunsigned 8 4(4) << 108(6c) = 16384(4000)\nunsigned 8 4(4) << 109(6d) = 32768(8000)\nunsigned 8 4(4) << 110(6e) = 65536(10000)\nunsigned 8 4(4) << 111(6f) = 131072(20000)\nunsigned 8 4(4) << 112(70) = 262144(40000)\nunsigned 8 4(4) << 113(71) = 524288(80000)\nunsigned 8 4(4) << 114(72) = 1048576(100000)\nunsigned 8 4(4) << 115(73) = 2097152(200000)\nunsigned 8 4(4) << 116(74) = 4194304(400000)\nunsigned 8 4(4) << 117(75) = 8388608(800000)\nunsigned 8 4(4) << 118(76) = 16777216(1000000)\nunsigned 8 4(4) << 119(77) = 33554432(2000000)\nunsigned 8 4(4) << 120(78) = 67108864(4000000)\nunsigned 8 4(4) << 121(79) = 134217728(8000000)\nunsigned 8 4(4) << 122(7a) = 268435456(10000000)\nunsigned 8 4(4) << 123(7b) = 536870912(20000000)\nunsigned 8 4(4) << 124(7c) = 1073741824(40000000)\nunsigned 8 4(4) << 125(7d) = 2147483648(80000000)\nunsigned 8 4(4) << 126(7e) = 0(0)\nunsigned 8 4(4) << 127(7f) = 0(0)\n  signed 8 -4(fc) >> -128(ffffff80) = -4(fc)\n  signed 8 -4(fc) >> -127(ffffff81) = -2(fe)\n  signed 8 -4(fc) >> -126(ffffff82) = -1(ff)\n  signed 8 -4(fc) >> -125(ffffff83) = -1(ff)\n  signed 8 -4(fc) >> -124(ffffff84) = -1(ff)\n  signed 8 -4(fc) >> -123(ffffff85) = -1(ff)\n  signed 8 -4(fc) >> -122(ffffff86) = -1(ff)\n  signed 8 -4(fc) >> -121(ffffff87) = -1(ff)\n  signed 8 -4(fc) >> -120(ffffff88) = -1(ff)\n  signed 8 -4(fc) >> -119(ffffff89) = -1(ff)\n  signed 8 -4(fc) >> -118(ffffff8a) = -1(ff)\n  signed 8 -4(fc) >> -117(ffffff8b) = -1(ff)\n  signed 8 -4(fc) >> -116(ffffff8c) = -1(ff)\n  signed 8 -4(fc) >> -115(ffffff8d) = -1(ff)\n  signed 8 -4(fc) >> -114(ffffff8e) = -1(ff)\n  signed 8 -4(fc) >> -113(ffffff8f) = -1(ff)\n  signed 8 -4(fc) >> -112(ffffff90) = -1(ff)\n  signed 8 -4(fc) >> -111(ffffff91) = -1(ff)\n  signed 8 -4(fc) >> -110(ffffff92) = -1(ff)\n  signed 8 -4(fc) >> -109(ffffff93) = -1(ff)\n  signed 8 -4(fc) >> -108(ffffff94) = -1(ff)\n  signed 8 -4(fc) >> -107(ffffff95) = -1(ff)\n  signed 8 -4(fc) >> -106(ffffff96) = -1(ff)\n  signed 8 -4(fc) >> -105(ffffff97) = -1(ff)\n  signed 8 -4(fc) >> -104(ffffff98) = -1(ff)\n  signed 8 -4(fc) >> -103(ffffff99) = -1(ff)\n  signed 8 -4(fc) >> -102(ffffff9a) = -1(ff)\n  signed 8 -4(fc) >> -101(ffffff9b) = -1(ff)\n  signed 8 -4(fc) >> -100(ffffff9c) = -1(ff)\n  signed 8 -4(fc) >> -99(ffffff9d) = -1(ff)\n  signed 8 -4(fc) >> -98(ffffff9e) = -1(ff)\n  signed 8 -4(fc) >> -97(ffffff9f) = -1(ff)\n  signed 8 -4(fc) >> -96(ffffffa0) = -4(fc)\n  signed 8 -4(fc) >> -95(ffffffa1) = -2(fe)\n  signed 8 -4(fc) >> -94(ffffffa2) = -1(ff)\n  signed 8 -4(fc) >> -93(ffffffa3) = -1(ff)\n  signed 8 -4(fc) >> -92(ffffffa4) = -1(ff)\n  signed 8 -4(fc) >> -91(ffffffa5) = -1(ff)\n  signed 8 -4(fc) >> -90(ffffffa6) = -1(ff)\n  signed 8 -4(fc) >> -89(ffffffa7) = -1(ff)\n  signed 8 -4(fc) >> -88(ffffffa8) = -1(ff)\n  signed 8 -4(fc) >> -87(ffffffa9) = -1(ff)\n  signed 8 -4(fc) >> -86(ffffffaa) = -1(ff)\n  signed 8 -4(fc) >> -85(ffffffab) = -1(ff)\n  signed 8 -4(fc) >> -84(ffffffac) = -1(ff)\n  signed 8 -4(fc) >> -83(ffffffad) = -1(ff)\n  signed 8 -4(fc) >> -82(ffffffae) = -1(ff)\n  signed 8 -4(fc) >> -81(ffffffaf) = -1(ff)\n  signed 8 -4(fc) >> -80(ffffffb0) = -1(ff)\n  signed 8 -4(fc) >> -79(ffffffb1) = -1(ff)\n  signed 8 -4(fc) >> -78(ffffffb2) = -1(ff)\n  signed 8 -4(fc) >> -77(ffffffb3) = -1(ff)\n  signed 8 -4(fc) >> -76(ffffffb4) = -1(ff)\n  signed 8 -4(fc) >> -75(ffffffb5) = -1(ff)\n  signed 8 -4(fc) >> -74(ffffffb6) = -1(ff)\n  signed 8 -4(fc) >> -73(ffffffb7) = -1(ff)\n  signed 8 -4(fc) >> -72(ffffffb8) = -1(ff)\n  signed 8 -4(fc) >> -71(ffffffb9) = -1(ff)\n  signed 8 -4(fc) >> -70(ffffffba) = -1(ff)\n  signed 8 -4(fc) >> -69(ffffffbb) = -1(ff)\n  signed 8 -4(fc) >> -68(ffffffbc) = -1(ff)\n  signed 8 -4(fc) >> -67(ffffffbd) = -1(ff)\n  signed 8 -4(fc) >> -66(ffffffbe) = -1(ff)\n  signed 8 -4(fc) >> -65(ffffffbf) = -1(ff)\n  signed 8 -4(fc) >> -64(ffffffc0) = -4(fc)\n  signed 8 -4(fc) >> -63(ffffffc1) = -2(fe)\n  signed 8 -4(fc) >> -62(ffffffc2) = -1(ff)\n  signed 8 -4(fc) >> -61(ffffffc3) = -1(ff)\n  signed 8 -4(fc) >> -60(ffffffc4) = -1(ff)\n  signed 8 -4(fc) >> -59(ffffffc5) = -1(ff)\n  signed 8 -4(fc) >> -58(ffffffc6) = -1(ff)\n  signed 8 -4(fc) >> -57(ffffffc7) = -1(ff)\n  signed 8 -4(fc) >> -56(ffffffc8) = -1(ff)\n  signed 8 -4(fc) >> -55(ffffffc9) = -1(ff)\n  signed 8 -4(fc) >> -54(ffffffca) = -1(ff)\n  signed 8 -4(fc) >> -53(ffffffcb) = -1(ff)\n  signed 8 -4(fc) >> -52(ffffffcc) = -1(ff)\n  signed 8 -4(fc) >> -51(ffffffcd) = -1(ff)\n  signed 8 -4(fc) >> -50(ffffffce) = -1(ff)\n  signed 8 -4(fc) >> -49(ffffffcf) = -1(ff)\n  signed 8 -4(fc) >> -48(ffffffd0) = -1(ff)\n  signed 8 -4(fc) >> -47(ffffffd1) = -1(ff)\n  signed 8 -4(fc) >> -46(ffffffd2) = -1(ff)\n  signed 8 -4(fc) >> -45(ffffffd3) = -1(ff)\n  signed 8 -4(fc) >> -44(ffffffd4) = -1(ff)\n  signed 8 -4(fc) >> -43(ffffffd5) = -1(ff)\n  signed 8 -4(fc) >> -42(ffffffd6) = -1(ff)\n  signed 8 -4(fc) >> -41(ffffffd7) = -1(ff)\n  signed 8 -4(fc) >> -40(ffffffd8) = -1(ff)\n  signed 8 -4(fc) >> -39(ffffffd9) = -1(ff)\n  signed 8 -4(fc) >> -38(ffffffda) = -1(ff)\n  signed 8 -4(fc) >> -37(ffffffdb) = -1(ff)\n  signed 8 -4(fc) >> -36(ffffffdc) = -1(ff)\n  signed 8 -4(fc) >> -35(ffffffdd) = -1(ff)\n  signed 8 -4(fc) >> -34(ffffffde) = -1(ff)\n  signed 8 -4(fc) >> -33(ffffffdf) = -1(ff)\n  signed 8 -4(fc) >> -32(ffffffe0) = -4(fc)\n  signed 8 -4(fc) >> -31(ffffffe1) = -2(fe)\n  signed 8 -4(fc) >> -30(ffffffe2) = -1(ff)\n  signed 8 -4(fc) >> -29(ffffffe3) = -1(ff)\n  signed 8 -4(fc) >> -28(ffffffe4) = -1(ff)\n  signed 8 -4(fc) >> -27(ffffffe5) = -1(ff)\n  signed 8 -4(fc) >> -26(ffffffe6) = -1(ff)\n  signed 8 -4(fc) >> -25(ffffffe7) = -1(ff)\n  signed 8 -4(fc) >> -24(ffffffe8) = -1(ff)\n  signed 8 -4(fc) >> -23(ffffffe9) = -1(ff)\n  signed 8 -4(fc) >> -22(ffffffea) = -1(ff)\n  signed 8 -4(fc) >> -21(ffffffeb) = -1(ff)\n  signed 8 -4(fc) >> -20(ffffffec) = -1(ff)\n  signed 8 -4(fc) >> -19(ffffffed) = -1(ff)\n  signed 8 -4(fc) >> -18(ffffffee) = -1(ff)\n  signed 8 -4(fc) >> -17(ffffffef) = -1(ff)\n  signed 8 -4(fc) >> -16(fffffff0) = -1(ff)\n  signed 8 -4(fc) >> -15(fffffff1) = -1(ff)\n  signed 8 -4(fc) >> -14(fffffff2) = -1(ff)\n  signed 8 -4(fc) >> -13(fffffff3) = -1(ff)\n  signed 8 -4(fc) >> -12(fffffff4) = -1(ff)\n  signed 8 -4(fc) >> -11(fffffff5) = -1(ff)\n  signed 8 -4(fc) >> -10(fffffff6) = -1(ff)\n  signed 8 -4(fc) >> -9(fffffff7) = -1(ff)\n  signed 8 -4(fc) >> -8(fffffff8) = -1(ff)\n  signed 8 -4(fc) >> -7(fffffff9) = -1(ff)\n  signed 8 -4(fc) >> -6(fffffffa) = -1(ff)\n  signed 8 -4(fc) >> -5(fffffffb) = -1(ff)\n  signed 8 -4(fc) >> -4(fffffffc) = -1(ff)\n  signed 8 -4(fc) >> -3(fffffffd) = -1(ff)\n  signed 8 -4(fc) >> -2(fffffffe) = -1(ff)\n  signed 8 -4(fc) >> -1(ffffffff) = -1(ff)\n  signed 8 -4(fc) >> 0(0) = -4(fc)\n  signed 8 -4(fc) >> 1(1) = -2(fe)\n  signed 8 -4(fc) >> 2(2) = -1(ff)\n  signed 8 -4(fc) >> 3(3) = -1(ff)\n  signed 8 -4(fc) >> 4(4) = -1(ff)\n  signed 8 -4(fc) >> 5(5) = -1(ff)\n  signed 8 -4(fc) >> 6(6) = -1(ff)\n  signed 8 -4(fc) >> 7(7) = -1(ff)\n  signed 8 -4(fc) >> 8(8) = -1(ff)\n  signed 8 -4(fc) >> 9(9) = -1(ff)\n  signed 8 -4(fc) >> 10(a) = -1(ff)\n  signed 8 -4(fc) >> 11(b) = -1(ff)\n  signed 8 -4(fc) >> 12(c) = -1(ff)\n  signed 8 -4(fc) >> 13(d) = -1(ff)\n  signed 8 -4(fc) >> 14(e) = -1(ff)\n  signed 8 -4(fc) >> 15(f) = -1(ff)\n  signed 8 -4(fc) >> 16(10) = -1(ff)\n  signed 8 -4(fc) >> 17(11) = -1(ff)\n  signed 8 -4(fc) >> 18(12) = -1(ff)\n  signed 8 -4(fc) >> 19(13) = -1(ff)\n  signed 8 -4(fc) >> 20(14) = -1(ff)\n  signed 8 -4(fc) >> 21(15) = -1(ff)\n  signed 8 -4(fc) >> 22(16) = -1(ff)\n  signed 8 -4(fc) >> 23(17) = -1(ff)\n  signed 8 -4(fc) >> 24(18) = -1(ff)\n  signed 8 -4(fc) >> 25(19) = -1(ff)\n  signed 8 -4(fc) >> 26(1a) = -1(ff)\n  signed 8 -4(fc) >> 27(1b) = -1(ff)\n  signed 8 -4(fc) >> 28(1c) = -1(ff)\n  signed 8 -4(fc) >> 29(1d) = -1(ff)\n  signed 8 -4(fc) >> 30(1e) = -1(ff)\n  signed 8 -4(fc) >> 31(1f) = -1(ff)\n  signed 8 -4(fc) >> 32(20) = -4(fc)\n  signed 8 -4(fc) >> 33(21) = -2(fe)\n  signed 8 -4(fc) >> 34(22) = -1(ff)\n  signed 8 -4(fc) >> 35(23) = -1(ff)\n  signed 8 -4(fc) >> 36(24) = -1(ff)\n  signed 8 -4(fc) >> 37(25) = -1(ff)\n  signed 8 -4(fc) >> 38(26) = -1(ff)\n  signed 8 -4(fc) >> 39(27) = -1(ff)\n  signed 8 -4(fc) >> 40(28) = -1(ff)\n  signed 8 -4(fc) >> 41(29) = -1(ff)\n  signed 8 -4(fc) >> 42(2a) = -1(ff)\n  signed 8 -4(fc) >> 43(2b) = -1(ff)\n  signed 8 -4(fc) >> 44(2c) = -1(ff)\n  signed 8 -4(fc) >> 45(2d) = -1(ff)\n  signed 8 -4(fc) >> 46(2e) = -1(ff)\n  signed 8 -4(fc) >> 47(2f) = -1(ff)\n  signed 8 -4(fc) >> 48(30) = -1(ff)\n  signed 8 -4(fc) >> 49(31) = -1(ff)\n  signed 8 -4(fc) >> 50(32) = -1(ff)\n  signed 8 -4(fc) >> 51(33) = -1(ff)\n  signed 8 -4(fc) >> 52(34) = -1(ff)\n  signed 8 -4(fc) >> 53(35) = -1(ff)\n  signed 8 -4(fc) >> 54(36) = -1(ff)\n  signed 8 -4(fc) >> 55(37) = -1(ff)\n  signed 8 -4(fc) >> 56(38) = -1(ff)\n  signed 8 -4(fc) >> 57(39) = -1(ff)\n  signed 8 -4(fc) >> 58(3a) = -1(ff)\n  signed 8 -4(fc) >> 59(3b) = -1(ff)\n  signed 8 -4(fc) >> 60(3c) = -1(ff)\n  signed 8 -4(fc) >> 61(3d) = -1(ff)\n  signed 8 -4(fc) >> 62(3e) = -1(ff)\n  signed 8 -4(fc) >> 63(3f) = -1(ff)\n  signed 8 -4(fc) >> 64(40) = -4(fc)\n  signed 8 -4(fc) >> 65(41) = -2(fe)\n  signed 8 -4(fc) >> 66(42) = -1(ff)\n  signed 8 -4(fc) >> 67(43) = -1(ff)\n  signed 8 -4(fc) >> 68(44) = -1(ff)\n  signed 8 -4(fc) >> 69(45) = -1(ff)\n  signed 8 -4(fc) >> 70(46) = -1(ff)\n  signed 8 -4(fc) >> 71(47) = -1(ff)\n  signed 8 -4(fc) >> 72(48) = -1(ff)\n  signed 8 -4(fc) >> 73(49) = -1(ff)\n  signed 8 -4(fc) >> 74(4a) = -1(ff)\n  signed 8 -4(fc) >> 75(4b) = -1(ff)\n  signed 8 -4(fc) >> 76(4c) = -1(ff)\n  signed 8 -4(fc) >> 77(4d) = -1(ff)\n  signed 8 -4(fc) >> 78(4e) = -1(ff)\n  signed 8 -4(fc) >> 79(4f) = -1(ff)\n  signed 8 -4(fc) >> 80(50) = -1(ff)\n  signed 8 -4(fc) >> 81(51) = -1(ff)\n  signed 8 -4(fc) >> 82(52) = -1(ff)\n  signed 8 -4(fc) >> 83(53) = -1(ff)\n  signed 8 -4(fc) >> 84(54) = -1(ff)\n  signed 8 -4(fc) >> 85(55) = -1(ff)\n  signed 8 -4(fc) >> 86(56) = -1(ff)\n  signed 8 -4(fc) >> 87(57) = -1(ff)\n  signed 8 -4(fc) >> 88(58) = -1(ff)\n  signed 8 -4(fc) >> 89(59) = -1(ff)\n  signed 8 -4(fc) >> 90(5a) = -1(ff)\n  signed 8 -4(fc) >> 91(5b) = -1(ff)\n  signed 8 -4(fc) >> 92(5c) = -1(ff)\n  signed 8 -4(fc) >> 93(5d) = -1(ff)\n  signed 8 -4(fc) >> 94(5e) = -1(ff)\n  signed 8 -4(fc) >> 95(5f) = -1(ff)\n  signed 8 -4(fc) >> 96(60) = -4(fc)\n  signed 8 -4(fc) >> 97(61) = -2(fe)\n  signed 8 -4(fc) >> 98(62) = -1(ff)\n  signed 8 -4(fc) >> 99(63) = -1(ff)\n  signed 8 -4(fc) >> 100(64) = -1(ff)\n  signed 8 -4(fc) >> 101(65) = -1(ff)\n  signed 8 -4(fc) >> 102(66) = -1(ff)\n  signed 8 -4(fc) >> 103(67) = -1(ff)\n  signed 8 -4(fc) >> 104(68) = -1(ff)\n  signed 8 -4(fc) >> 105(69) = -1(ff)\n  signed 8 -4(fc) >> 106(6a) = -1(ff)\n  signed 8 -4(fc) >> 107(6b) = -1(ff)\n  signed 8 -4(fc) >> 108(6c) = -1(ff)\n  signed 8 -4(fc) >> 109(6d) = -1(ff)\n  signed 8 -4(fc) >> 110(6e) = -1(ff)\n  signed 8 -4(fc) >> 111(6f) = -1(ff)\n  signed 8 -4(fc) >> 112(70) = -1(ff)\n  signed 8 -4(fc) >> 113(71) = -1(ff)\n  signed 8 -4(fc) >> 114(72) = -1(ff)\n  signed 8 -4(fc) >> 115(73) = -1(ff)\n  signed 8 -4(fc) >> 116(74) = -1(ff)\n  signed 8 -4(fc) >> 117(75) = -1(ff)\n  signed 8 -4(fc) >> 118(76) = -1(ff)\n  signed 8 -4(fc) >> 119(77) = -1(ff)\n  signed 8 -4(fc) >> 120(78) = -1(ff)\n  signed 8 -4(fc) >> 121(79) = -1(ff)\n  signed 8 -4(fc) >> 122(7a) = -1(ff)\n  signed 8 -4(fc) >> 123(7b) = -1(ff)\n  signed 8 -4(fc) >> 124(7c) = -1(ff)\n  signed 8 -4(fc) >> 125(7d) = -1(ff)\n  signed 8 -4(fc) >> 126(7e) = -1(ff)\n  signed 8 -4(fc) >> 127(7f) = -1(ff)\n  signed 8 -3(fd) >> -128(ffffff80) = -3(fd)\n  signed 8 -3(fd) >> -127(ffffff81) = -2(fe)\n  signed 8 -3(fd) >> -126(ffffff82) = -1(ff)\n  signed 8 -3(fd) >> -125(ffffff83) = -1(ff)\n  signed 8 -3(fd) >> -124(ffffff84) = -1(ff)\n  signed 8 -3(fd) >> -123(ffffff85) = -1(ff)\n  signed 8 -3(fd) >> -122(ffffff86) = -1(ff)\n  signed 8 -3(fd) >> -121(ffffff87) = -1(ff)\n  signed 8 -3(fd) >> -120(ffffff88) = -1(ff)\n  signed 8 -3(fd) >> -119(ffffff89) = -1(ff)\n  signed 8 -3(fd) >> -118(ffffff8a) = -1(ff)\n  signed 8 -3(fd) >> -117(ffffff8b) = -1(ff)\n  signed 8 -3(fd) >> -116(ffffff8c) = -1(ff)\n  signed 8 -3(fd) >> -115(ffffff8d) = -1(ff)\n  signed 8 -3(fd) >> -114(ffffff8e) = -1(ff)\n  signed 8 -3(fd) >> -113(ffffff8f) = -1(ff)\n  signed 8 -3(fd) >> -112(ffffff90) = -1(ff)\n  signed 8 -3(fd) >> -111(ffffff91) = -1(ff)\n  signed 8 -3(fd) >> -110(ffffff92) = -1(ff)\n  signed 8 -3(fd) >> -109(ffffff93) = -1(ff)\n  signed 8 -3(fd) >> -108(ffffff94) = -1(ff)\n  signed 8 -3(fd) >> -107(ffffff95) = -1(ff)\n  signed 8 -3(fd) >> -106(ffffff96) = -1(ff)\n  signed 8 -3(fd) >> -105(ffffff97) = -1(ff)\n  signed 8 -3(fd) >> -104(ffffff98) = -1(ff)\n  signed 8 -3(fd) >> -103(ffffff99) = -1(ff)\n  signed 8 -3(fd) >> -102(ffffff9a) = -1(ff)\n  signed 8 -3(fd) >> -101(ffffff9b) = -1(ff)\n  signed 8 -3(fd) >> -100(ffffff9c) = -1(ff)\n  signed 8 -3(fd) >> -99(ffffff9d) = -1(ff)\n  signed 8 -3(fd) >> -98(ffffff9e) = -1(ff)\n  signed 8 -3(fd) >> -97(ffffff9f) = -1(ff)\n  signed 8 -3(fd) >> -96(ffffffa0) = -3(fd)\n  signed 8 -3(fd) >> -95(ffffffa1) = -2(fe)\n  signed 8 -3(fd) >> -94(ffffffa2) = -1(ff)\n  signed 8 -3(fd) >> -93(ffffffa3) = -1(ff)\n  signed 8 -3(fd) >> -92(ffffffa4) = -1(ff)\n  signed 8 -3(fd) >> -91(ffffffa5) = -1(ff)\n  signed 8 -3(fd) >> -90(ffffffa6) = -1(ff)\n  signed 8 -3(fd) >> -89(ffffffa7) = -1(ff)\n  signed 8 -3(fd) >> -88(ffffffa8) = -1(ff)\n  signed 8 -3(fd) >> -87(ffffffa9) = -1(ff)\n  signed 8 -3(fd) >> -86(ffffffaa) = -1(ff)\n  signed 8 -3(fd) >> -85(ffffffab) = -1(ff)\n  signed 8 -3(fd) >> -84(ffffffac) = -1(ff)\n  signed 8 -3(fd) >> -83(ffffffad) = -1(ff)\n  signed 8 -3(fd) >> -82(ffffffae) = -1(ff)\n  signed 8 -3(fd) >> -81(ffffffaf) = -1(ff)\n  signed 8 -3(fd) >> -80(ffffffb0) = -1(ff)\n  signed 8 -3(fd) >> -79(ffffffb1) = -1(ff)\n  signed 8 -3(fd) >> -78(ffffffb2) = -1(ff)\n  signed 8 -3(fd) >> -77(ffffffb3) = -1(ff)\n  signed 8 -3(fd) >> -76(ffffffb4) = -1(ff)\n  signed 8 -3(fd) >> -75(ffffffb5) = -1(ff)\n  signed 8 -3(fd) >> -74(ffffffb6) = -1(ff)\n  signed 8 -3(fd) >> -73(ffffffb7) = -1(ff)\n  signed 8 -3(fd) >> -72(ffffffb8) = -1(ff)\n  signed 8 -3(fd) >> -71(ffffffb9) = -1(ff)\n  signed 8 -3(fd) >> -70(ffffffba) = -1(ff)\n  signed 8 -3(fd) >> -69(ffffffbb) = -1(ff)\n  signed 8 -3(fd) >> -68(ffffffbc) = -1(ff)\n  signed 8 -3(fd) >> -67(ffffffbd) = -1(ff)\n  signed 8 -3(fd) >> -66(ffffffbe) = -1(ff)\n  signed 8 -3(fd) >> -65(ffffffbf) = -1(ff)\n  signed 8 -3(fd) >> -64(ffffffc0) = -3(fd)\n  signed 8 -3(fd) >> -63(ffffffc1) = -2(fe)\n  signed 8 -3(fd) >> -62(ffffffc2) = -1(ff)\n  signed 8 -3(fd) >> -61(ffffffc3) = -1(ff)\n  signed 8 -3(fd) >> -60(ffffffc4) = -1(ff)\n  signed 8 -3(fd) >> -59(ffffffc5) = -1(ff)\n  signed 8 -3(fd) >> -58(ffffffc6) = -1(ff)\n  signed 8 -3(fd) >> -57(ffffffc7) = -1(ff)\n  signed 8 -3(fd) >> -56(ffffffc8) = -1(ff)\n  signed 8 -3(fd) >> -55(ffffffc9) = -1(ff)\n  signed 8 -3(fd) >> -54(ffffffca) = -1(ff)\n  signed 8 -3(fd) >> -53(ffffffcb) = -1(ff)\n  signed 8 -3(fd) >> -52(ffffffcc) = -1(ff)\n  signed 8 -3(fd) >> -51(ffffffcd) = -1(ff)\n  signed 8 -3(fd) >> -50(ffffffce) = -1(ff)\n  signed 8 -3(fd) >> -49(ffffffcf) = -1(ff)\n  signed 8 -3(fd) >> -48(ffffffd0) = -1(ff)\n  signed 8 -3(fd) >> -47(ffffffd1) = -1(ff)\n  signed 8 -3(fd) >> -46(ffffffd2) = -1(ff)\n  signed 8 -3(fd) >> -45(ffffffd3) = -1(ff)\n  signed 8 -3(fd) >> -44(ffffffd4) = -1(ff)\n  signed 8 -3(fd) >> -43(ffffffd5) = -1(ff)\n  signed 8 -3(fd) >> -42(ffffffd6) = -1(ff)\n  signed 8 -3(fd) >> -41(ffffffd7) = -1(ff)\n  signed 8 -3(fd) >> -40(ffffffd8) = -1(ff)\n  signed 8 -3(fd) >> -39(ffffffd9) = -1(ff)\n  signed 8 -3(fd) >> -38(ffffffda) = -1(ff)\n  signed 8 -3(fd) >> -37(ffffffdb) = -1(ff)\n  signed 8 -3(fd) >> -36(ffffffdc) = -1(ff)\n  signed 8 -3(fd) >> -35(ffffffdd) = -1(ff)\n  signed 8 -3(fd) >> -34(ffffffde) = -1(ff)\n  signed 8 -3(fd) >> -33(ffffffdf) = -1(ff)\n  signed 8 -3(fd) >> -32(ffffffe0) = -3(fd)\n  signed 8 -3(fd) >> -31(ffffffe1) = -2(fe)\n  signed 8 -3(fd) >> -30(ffffffe2) = -1(ff)\n  signed 8 -3(fd) >> -29(ffffffe3) = -1(ff)\n  signed 8 -3(fd) >> -28(ffffffe4) = -1(ff)\n  signed 8 -3(fd) >> -27(ffffffe5) = -1(ff)\n  signed 8 -3(fd) >> -26(ffffffe6) = -1(ff)\n  signed 8 -3(fd) >> -25(ffffffe7) = -1(ff)\n  signed 8 -3(fd) >> -24(ffffffe8) = -1(ff)\n  signed 8 -3(fd) >> -23(ffffffe9) = -1(ff)\n  signed 8 -3(fd) >> -22(ffffffea) = -1(ff)\n  signed 8 -3(fd) >> -21(ffffffeb) = -1(ff)\n  signed 8 -3(fd) >> -20(ffffffec) = -1(ff)\n  signed 8 -3(fd) >> -19(ffffffed) = -1(ff)\n  signed 8 -3(fd) >> -18(ffffffee) = -1(ff)\n  signed 8 -3(fd) >> -17(ffffffef) = -1(ff)\n  signed 8 -3(fd) >> -16(fffffff0) = -1(ff)\n  signed 8 -3(fd) >> -15(fffffff1) = -1(ff)\n  signed 8 -3(fd) >> -14(fffffff2) = -1(ff)\n  signed 8 -3(fd) >> -13(fffffff3) = -1(ff)\n  signed 8 -3(fd) >> -12(fffffff4) = -1(ff)\n  signed 8 -3(fd) >> -11(fffffff5) = -1(ff)\n  signed 8 -3(fd) >> -10(fffffff6) = -1(ff)\n  signed 8 -3(fd) >> -9(fffffff7) = -1(ff)\n  signed 8 -3(fd) >> -8(fffffff8) = -1(ff)\n  signed 8 -3(fd) >> -7(fffffff9) = -1(ff)\n  signed 8 -3(fd) >> -6(fffffffa) = -1(ff)\n  signed 8 -3(fd) >> -5(fffffffb) = -1(ff)\n  signed 8 -3(fd) >> -4(fffffffc) = -1(ff)\n  signed 8 -3(fd) >> -3(fffffffd) = -1(ff)\n  signed 8 -3(fd) >> -2(fffffffe) = -1(ff)\n  signed 8 -3(fd) >> -1(ffffffff) = -1(ff)\n  signed 8 -3(fd) >> 0(0) = -3(fd)\n  signed 8 -3(fd) >> 1(1) = -2(fe)\n  signed 8 -3(fd) >> 2(2) = -1(ff)\n  signed 8 -3(fd) >> 3(3) = -1(ff)\n  signed 8 -3(fd) >> 4(4) = -1(ff)\n  signed 8 -3(fd) >> 5(5) = -1(ff)\n  signed 8 -3(fd) >> 6(6) = -1(ff)\n  signed 8 -3(fd) >> 7(7) = -1(ff)\n  signed 8 -3(fd) >> 8(8) = -1(ff)\n  signed 8 -3(fd) >> 9(9) = -1(ff)\n  signed 8 -3(fd) >> 10(a) = -1(ff)\n  signed 8 -3(fd) >> 11(b) = -1(ff)\n  signed 8 -3(fd) >> 12(c) = -1(ff)\n  signed 8 -3(fd) >> 13(d) = -1(ff)\n  signed 8 -3(fd) >> 14(e) = -1(ff)\n  signed 8 -3(fd) >> 15(f) = -1(ff)\n  signed 8 -3(fd) >> 16(10) = -1(ff)\n  signed 8 -3(fd) >> 17(11) = -1(ff)\n  signed 8 -3(fd) >> 18(12) = -1(ff)\n  signed 8 -3(fd) >> 19(13) = -1(ff)\n  signed 8 -3(fd) >> 20(14) = -1(ff)\n  signed 8 -3(fd) >> 21(15) = -1(ff)\n  signed 8 -3(fd) >> 22(16) = -1(ff)\n  signed 8 -3(fd) >> 23(17) = -1(ff)\n  signed 8 -3(fd) >> 24(18) = -1(ff)\n  signed 8 -3(fd) >> 25(19) = -1(ff)\n  signed 8 -3(fd) >> 26(1a) = -1(ff)\n  signed 8 -3(fd) >> 27(1b) = -1(ff)\n  signed 8 -3(fd) >> 28(1c) = -1(ff)\n  signed 8 -3(fd) >> 29(1d) = -1(ff)\n  signed 8 -3(fd) >> 30(1e) = -1(ff)\n  signed 8 -3(fd) >> 31(1f) = -1(ff)\n  signed 8 -3(fd) >> 32(20) = -3(fd)\n  signed 8 -3(fd) >> 33(21) = -2(fe)\n  signed 8 -3(fd) >> 34(22) = -1(ff)\n  signed 8 -3(fd) >> 35(23) = -1(ff)\n  signed 8 -3(fd) >> 36(24) = -1(ff)\n  signed 8 -3(fd) >> 37(25) = -1(ff)\n  signed 8 -3(fd) >> 38(26) = -1(ff)\n  signed 8 -3(fd) >> 39(27) = -1(ff)\n  signed 8 -3(fd) >> 40(28) = -1(ff)\n  signed 8 -3(fd) >> 41(29) = -1(ff)\n  signed 8 -3(fd) >> 42(2a) = -1(ff)\n  signed 8 -3(fd) >> 43(2b) = -1(ff)\n  signed 8 -3(fd) >> 44(2c) = -1(ff)\n  signed 8 -3(fd) >> 45(2d) = -1(ff)\n  signed 8 -3(fd) >> 46(2e) = -1(ff)\n  signed 8 -3(fd) >> 47(2f) = -1(ff)\n  signed 8 -3(fd) >> 48(30) = -1(ff)\n  signed 8 -3(fd) >> 49(31) = -1(ff)\n  signed 8 -3(fd) >> 50(32) = -1(ff)\n  signed 8 -3(fd) >> 51(33) = -1(ff)\n  signed 8 -3(fd) >> 52(34) = -1(ff)\n  signed 8 -3(fd) >> 53(35) = -1(ff)\n  signed 8 -3(fd) >> 54(36) = -1(ff)\n  signed 8 -3(fd) >> 55(37) = -1(ff)\n  signed 8 -3(fd) >> 56(38) = -1(ff)\n  signed 8 -3(fd) >> 57(39) = -1(ff)\n  signed 8 -3(fd) >> 58(3a) = -1(ff)\n  signed 8 -3(fd) >> 59(3b) = -1(ff)\n  signed 8 -3(fd) >> 60(3c) = -1(ff)\n  signed 8 -3(fd) >> 61(3d) = -1(ff)\n  signed 8 -3(fd) >> 62(3e) = -1(ff)\n  signed 8 -3(fd) >> 63(3f) = -1(ff)\n  signed 8 -3(fd) >> 64(40) = -3(fd)\n  signed 8 -3(fd) >> 65(41) = -2(fe)\n  signed 8 -3(fd) >> 66(42) = -1(ff)\n  signed 8 -3(fd) >> 67(43) = -1(ff)\n  signed 8 -3(fd) >> 68(44) = -1(ff)\n  signed 8 -3(fd) >> 69(45) = -1(ff)\n  signed 8 -3(fd) >> 70(46) = -1(ff)\n  signed 8 -3(fd) >> 71(47) = -1(ff)\n  signed 8 -3(fd) >> 72(48) = -1(ff)\n  signed 8 -3(fd) >> 73(49) = -1(ff)\n  signed 8 -3(fd) >> 74(4a) = -1(ff)\n  signed 8 -3(fd) >> 75(4b) = -1(ff)\n  signed 8 -3(fd) >> 76(4c) = -1(ff)\n  signed 8 -3(fd) >> 77(4d) = -1(ff)\n  signed 8 -3(fd) >> 78(4e) = -1(ff)\n  signed 8 -3(fd) >> 79(4f) = -1(ff)\n  signed 8 -3(fd) >> 80(50) = -1(ff)\n  signed 8 -3(fd) >> 81(51) = -1(ff)\n  signed 8 -3(fd) >> 82(52) = -1(ff)\n  signed 8 -3(fd) >> 83(53) = -1(ff)\n  signed 8 -3(fd) >> 84(54) = -1(ff)\n  signed 8 -3(fd) >> 85(55) = -1(ff)\n  signed 8 -3(fd) >> 86(56) = -1(ff)\n  signed 8 -3(fd) >> 87(57) = -1(ff)\n  signed 8 -3(fd) >> 88(58) = -1(ff)\n  signed 8 -3(fd) >> 89(59) = -1(ff)\n  signed 8 -3(fd) >> 90(5a) = -1(ff)\n  signed 8 -3(fd) >> 91(5b) = -1(ff)\n  signed 8 -3(fd) >> 92(5c) = -1(ff)\n  signed 8 -3(fd) >> 93(5d) = -1(ff)\n  signed 8 -3(fd) >> 94(5e) = -1(ff)\n  signed 8 -3(fd) >> 95(5f) = -1(ff)\n  signed 8 -3(fd) >> 96(60) = -3(fd)\n  signed 8 -3(fd) >> 97(61) = -2(fe)\n  signed 8 -3(fd) >> 98(62) = -1(ff)\n  signed 8 -3(fd) >> 99(63) = -1(ff)\n  signed 8 -3(fd) >> 100(64) = -1(ff)\n  signed 8 -3(fd) >> 101(65) = -1(ff)\n  signed 8 -3(fd) >> 102(66) = -1(ff)\n  signed 8 -3(fd) >> 103(67) = -1(ff)\n  signed 8 -3(fd) >> 104(68) = -1(ff)\n  signed 8 -3(fd) >> 105(69) = -1(ff)\n  signed 8 -3(fd) >> 106(6a) = -1(ff)\n  signed 8 -3(fd) >> 107(6b) = -1(ff)\n  signed 8 -3(fd) >> 108(6c) = -1(ff)\n  signed 8 -3(fd) >> 109(6d) = -1(ff)\n  signed 8 -3(fd) >> 110(6e) = -1(ff)\n  signed 8 -3(fd) >> 111(6f) = -1(ff)\n  signed 8 -3(fd) >> 112(70) = -1(ff)\n  signed 8 -3(fd) >> 113(71) = -1(ff)\n  signed 8 -3(fd) >> 114(72) = -1(ff)\n  signed 8 -3(fd) >> 115(73) = -1(ff)\n  signed 8 -3(fd) >> 116(74) = -1(ff)\n  signed 8 -3(fd) >> 117(75) = -1(ff)\n  signed 8 -3(fd) >> 118(76) = -1(ff)\n  signed 8 -3(fd) >> 119(77) = -1(ff)\n  signed 8 -3(fd) >> 120(78) = -1(ff)\n  signed 8 -3(fd) >> 121(79) = -1(ff)\n  signed 8 -3(fd) >> 122(7a) = -1(ff)\n  signed 8 -3(fd) >> 123(7b) = -1(ff)\n  signed 8 -3(fd) >> 124(7c) = -1(ff)\n  signed 8 -3(fd) >> 125(7d) = -1(ff)\n  signed 8 -3(fd) >> 126(7e) = -1(ff)\n  signed 8 -3(fd) >> 127(7f) = -1(ff)\n  signed 8 -2(fe) >> -128(ffffff80) = -2(fe)\n  signed 8 -2(fe) >> -127(ffffff81) = -1(ff)\n  signed 8 -2(fe) >> -126(ffffff82) = -1(ff)\n  signed 8 -2(fe) >> -125(ffffff83) = -1(ff)\n  signed 8 -2(fe) >> -124(ffffff84) = -1(ff)\n  signed 8 -2(fe) >> -123(ffffff85) = -1(ff)\n  signed 8 -2(fe) >> -122(ffffff86) = -1(ff)\n  signed 8 -2(fe) >> -121(ffffff87) = -1(ff)\n  signed 8 -2(fe) >> -120(ffffff88) = -1(ff)\n  signed 8 -2(fe) >> -119(ffffff89) = -1(ff)\n  signed 8 -2(fe) >> -118(ffffff8a) = -1(ff)\n  signed 8 -2(fe) >> -117(ffffff8b) = -1(ff)\n  signed 8 -2(fe) >> -116(ffffff8c) = -1(ff)\n  signed 8 -2(fe) >> -115(ffffff8d) = -1(ff)\n  signed 8 -2(fe) >> -114(ffffff8e) = -1(ff)\n  signed 8 -2(fe) >> -113(ffffff8f) = -1(ff)\n  signed 8 -2(fe) >> -112(ffffff90) = -1(ff)\n  signed 8 -2(fe) >> -111(ffffff91) = -1(ff)\n  signed 8 -2(fe) >> -110(ffffff92) = -1(ff)\n  signed 8 -2(fe) >> -109(ffffff93) = -1(ff)\n  signed 8 -2(fe) >> -108(ffffff94) = -1(ff)\n  signed 8 -2(fe) >> -107(ffffff95) = -1(ff)\n  signed 8 -2(fe) >> -106(ffffff96) = -1(ff)\n  signed 8 -2(fe) >> -105(ffffff97) = -1(ff)\n  signed 8 -2(fe) >> -104(ffffff98) = -1(ff)\n  signed 8 -2(fe) >> -103(ffffff99) = -1(ff)\n  signed 8 -2(fe) >> -102(ffffff9a) = -1(ff)\n  signed 8 -2(fe) >> -101(ffffff9b) = -1(ff)\n  signed 8 -2(fe) >> -100(ffffff9c) = -1(ff)\n  signed 8 -2(fe) >> -99(ffffff9d) = -1(ff)\n  signed 8 -2(fe) >> -98(ffffff9e) = -1(ff)\n  signed 8 -2(fe) >> -97(ffffff9f) = -1(ff)\n  signed 8 -2(fe) >> -96(ffffffa0) = -2(fe)\n  signed 8 -2(fe) >> -95(ffffffa1) = -1(ff)\n  signed 8 -2(fe) >> -94(ffffffa2) = -1(ff)\n  signed 8 -2(fe) >> -93(ffffffa3) = -1(ff)\n  signed 8 -2(fe) >> -92(ffffffa4) = -1(ff)\n  signed 8 -2(fe) >> -91(ffffffa5) = -1(ff)\n  signed 8 -2(fe) >> -90(ffffffa6) = -1(ff)\n  signed 8 -2(fe) >> -89(ffffffa7) = -1(ff)\n  signed 8 -2(fe) >> -88(ffffffa8) = -1(ff)\n  signed 8 -2(fe) >> -87(ffffffa9) = -1(ff)\n  signed 8 -2(fe) >> -86(ffffffaa) = -1(ff)\n  signed 8 -2(fe) >> -85(ffffffab) = -1(ff)\n  signed 8 -2(fe) >> -84(ffffffac) = -1(ff)\n  signed 8 -2(fe) >> -83(ffffffad) = -1(ff)\n  signed 8 -2(fe) >> -82(ffffffae) = -1(ff)\n  signed 8 -2(fe) >> -81(ffffffaf) = -1(ff)\n  signed 8 -2(fe) >> -80(ffffffb0) = -1(ff)\n  signed 8 -2(fe) >> -79(ffffffb1) = -1(ff)\n  signed 8 -2(fe) >> -78(ffffffb2) = -1(ff)\n  signed 8 -2(fe) >> -77(ffffffb3) = -1(ff)\n  signed 8 -2(fe) >> -76(ffffffb4) = -1(ff)\n  signed 8 -2(fe) >> -75(ffffffb5) = -1(ff)\n  signed 8 -2(fe) >> -74(ffffffb6) = -1(ff)\n  signed 8 -2(fe) >> -73(ffffffb7) = -1(ff)\n  signed 8 -2(fe) >> -72(ffffffb8) = -1(ff)\n  signed 8 -2(fe) >> -71(ffffffb9) = -1(ff)\n  signed 8 -2(fe) >> -70(ffffffba) = -1(ff)\n  signed 8 -2(fe) >> -69(ffffffbb) = -1(ff)\n  signed 8 -2(fe) >> -68(ffffffbc) = -1(ff)\n  signed 8 -2(fe) >> -67(ffffffbd) = -1(ff)\n  signed 8 -2(fe) >> -66(ffffffbe) = -1(ff)\n  signed 8 -2(fe) >> -65(ffffffbf) = -1(ff)\n  signed 8 -2(fe) >> -64(ffffffc0) = -2(fe)\n  signed 8 -2(fe) >> -63(ffffffc1) = -1(ff)\n  signed 8 -2(fe) >> -62(ffffffc2) = -1(ff)\n  signed 8 -2(fe) >> -61(ffffffc3) = -1(ff)\n  signed 8 -2(fe) >> -60(ffffffc4) = -1(ff)\n  signed 8 -2(fe) >> -59(ffffffc5) = -1(ff)\n  signed 8 -2(fe) >> -58(ffffffc6) = -1(ff)\n  signed 8 -2(fe) >> -57(ffffffc7) = -1(ff)\n  signed 8 -2(fe) >> -56(ffffffc8) = -1(ff)\n  signed 8 -2(fe) >> -55(ffffffc9) = -1(ff)\n  signed 8 -2(fe) >> -54(ffffffca) = -1(ff)\n  signed 8 -2(fe) >> -53(ffffffcb) = -1(ff)\n  signed 8 -2(fe) >> -52(ffffffcc) = -1(ff)\n  signed 8 -2(fe) >> -51(ffffffcd) = -1(ff)\n  signed 8 -2(fe) >> -50(ffffffce) = -1(ff)\n  signed 8 -2(fe) >> -49(ffffffcf) = -1(ff)\n  signed 8 -2(fe) >> -48(ffffffd0) = -1(ff)\n  signed 8 -2(fe) >> -47(ffffffd1) = -1(ff)\n  signed 8 -2(fe) >> -46(ffffffd2) = -1(ff)\n  signed 8 -2(fe) >> -45(ffffffd3) = -1(ff)\n  signed 8 -2(fe) >> -44(ffffffd4) = -1(ff)\n  signed 8 -2(fe) >> -43(ffffffd5) = -1(ff)\n  signed 8 -2(fe) >> -42(ffffffd6) = -1(ff)\n  signed 8 -2(fe) >> -41(ffffffd7) = -1(ff)\n  signed 8 -2(fe) >> -40(ffffffd8) = -1(ff)\n  signed 8 -2(fe) >> -39(ffffffd9) = -1(ff)\n  signed 8 -2(fe) >> -38(ffffffda) = -1(ff)\n  signed 8 -2(fe) >> -37(ffffffdb) = -1(ff)\n  signed 8 -2(fe) >> -36(ffffffdc) = -1(ff)\n  signed 8 -2(fe) >> -35(ffffffdd) = -1(ff)\n  signed 8 -2(fe) >> -34(ffffffde) = -1(ff)\n  signed 8 -2(fe) >> -33(ffffffdf) = -1(ff)\n  signed 8 -2(fe) >> -32(ffffffe0) = -2(fe)\n  signed 8 -2(fe) >> -31(ffffffe1) = -1(ff)\n  signed 8 -2(fe) >> -30(ffffffe2) = -1(ff)\n  signed 8 -2(fe) >> -29(ffffffe3) = -1(ff)\n  signed 8 -2(fe) >> -28(ffffffe4) = -1(ff)\n  signed 8 -2(fe) >> -27(ffffffe5) = -1(ff)\n  signed 8 -2(fe) >> -26(ffffffe6) = -1(ff)\n  signed 8 -2(fe) >> -25(ffffffe7) = -1(ff)\n  signed 8 -2(fe) >> -24(ffffffe8) = -1(ff)\n  signed 8 -2(fe) >> -23(ffffffe9) = -1(ff)\n  signed 8 -2(fe) >> -22(ffffffea) = -1(ff)\n  signed 8 -2(fe) >> -21(ffffffeb) = -1(ff)\n  signed 8 -2(fe) >> -20(ffffffec) = -1(ff)\n  signed 8 -2(fe) >> -19(ffffffed) = -1(ff)\n  signed 8 -2(fe) >> -18(ffffffee) = -1(ff)\n  signed 8 -2(fe) >> -17(ffffffef) = -1(ff)\n  signed 8 -2(fe) >> -16(fffffff0) = -1(ff)\n  signed 8 -2(fe) >> -15(fffffff1) = -1(ff)\n  signed 8 -2(fe) >> -14(fffffff2) = -1(ff)\n  signed 8 -2(fe) >> -13(fffffff3) = -1(ff)\n  signed 8 -2(fe) >> -12(fffffff4) = -1(ff)\n  signed 8 -2(fe) >> -11(fffffff5) = -1(ff)\n  signed 8 -2(fe) >> -10(fffffff6) = -1(ff)\n  signed 8 -2(fe) >> -9(fffffff7) = -1(ff)\n  signed 8 -2(fe) >> -8(fffffff8) = -1(ff)\n  signed 8 -2(fe) >> -7(fffffff9) = -1(ff)\n  signed 8 -2(fe) >> -6(fffffffa) = -1(ff)\n  signed 8 -2(fe) >> -5(fffffffb) = -1(ff)\n  signed 8 -2(fe) >> -4(fffffffc) = -1(ff)\n  signed 8 -2(fe) >> -3(fffffffd) = -1(ff)\n  signed 8 -2(fe) >> -2(fffffffe) = -1(ff)\n  signed 8 -2(fe) >> -1(ffffffff) = -1(ff)\n  signed 8 -2(fe) >> 0(0) = -2(fe)\n  signed 8 -2(fe) >> 1(1) = -1(ff)\n  signed 8 -2(fe) >> 2(2) = -1(ff)\n  signed 8 -2(fe) >> 3(3) = -1(ff)\n  signed 8 -2(fe) >> 4(4) = -1(ff)\n  signed 8 -2(fe) >> 5(5) = -1(ff)\n  signed 8 -2(fe) >> 6(6) = -1(ff)\n  signed 8 -2(fe) >> 7(7) = -1(ff)\n  signed 8 -2(fe) >> 8(8) = -1(ff)\n  signed 8 -2(fe) >> 9(9) = -1(ff)\n  signed 8 -2(fe) >> 10(a) = -1(ff)\n  signed 8 -2(fe) >> 11(b) = -1(ff)\n  signed 8 -2(fe) >> 12(c) = -1(ff)\n  signed 8 -2(fe) >> 13(d) = -1(ff)\n  signed 8 -2(fe) >> 14(e) = -1(ff)\n  signed 8 -2(fe) >> 15(f) = -1(ff)\n  signed 8 -2(fe) >> 16(10) = -1(ff)\n  signed 8 -2(fe) >> 17(11) = -1(ff)\n  signed 8 -2(fe) >> 18(12) = -1(ff)\n  signed 8 -2(fe) >> 19(13) = -1(ff)\n  signed 8 -2(fe) >> 20(14) = -1(ff)\n  signed 8 -2(fe) >> 21(15) = -1(ff)\n  signed 8 -2(fe) >> 22(16) = -1(ff)\n  signed 8 -2(fe) >> 23(17) = -1(ff)\n  signed 8 -2(fe) >> 24(18) = -1(ff)\n  signed 8 -2(fe) >> 25(19) = -1(ff)\n  signed 8 -2(fe) >> 26(1a) = -1(ff)\n  signed 8 -2(fe) >> 27(1b) = -1(ff)\n  signed 8 -2(fe) >> 28(1c) = -1(ff)\n  signed 8 -2(fe) >> 29(1d) = -1(ff)\n  signed 8 -2(fe) >> 30(1e) = -1(ff)\n  signed 8 -2(fe) >> 31(1f) = -1(ff)\n  signed 8 -2(fe) >> 32(20) = -2(fe)\n  signed 8 -2(fe) >> 33(21) = -1(ff)\n  signed 8 -2(fe) >> 34(22) = -1(ff)\n  signed 8 -2(fe) >> 35(23) = -1(ff)\n  signed 8 -2(fe) >> 36(24) = -1(ff)\n  signed 8 -2(fe) >> 37(25) = -1(ff)\n  signed 8 -2(fe) >> 38(26) = -1(ff)\n  signed 8 -2(fe) >> 39(27) = -1(ff)\n  signed 8 -2(fe) >> 40(28) = -1(ff)\n  signed 8 -2(fe) >> 41(29) = -1(ff)\n  signed 8 -2(fe) >> 42(2a) = -1(ff)\n  signed 8 -2(fe) >> 43(2b) = -1(ff)\n  signed 8 -2(fe) >> 44(2c) = -1(ff)\n  signed 8 -2(fe) >> 45(2d) = -1(ff)\n  signed 8 -2(fe) >> 46(2e) = -1(ff)\n  signed 8 -2(fe) >> 47(2f) = -1(ff)\n  signed 8 -2(fe) >> 48(30) = -1(ff)\n  signed 8 -2(fe) >> 49(31) = -1(ff)\n  signed 8 -2(fe) >> 50(32) = -1(ff)\n  signed 8 -2(fe) >> 51(33) = -1(ff)\n  signed 8 -2(fe) >> 52(34) = -1(ff)\n  signed 8 -2(fe) >> 53(35) = -1(ff)\n  signed 8 -2(fe) >> 54(36) = -1(ff)\n  signed 8 -2(fe) >> 55(37) = -1(ff)\n  signed 8 -2(fe) >> 56(38) = -1(ff)\n  signed 8 -2(fe) >> 57(39) = -1(ff)\n  signed 8 -2(fe) >> 58(3a) = -1(ff)\n  signed 8 -2(fe) >> 59(3b) = -1(ff)\n  signed 8 -2(fe) >> 60(3c) = -1(ff)\n  signed 8 -2(fe) >> 61(3d) = -1(ff)\n  signed 8 -2(fe) >> 62(3e) = -1(ff)\n  signed 8 -2(fe) >> 63(3f) = -1(ff)\n  signed 8 -2(fe) >> 64(40) = -2(fe)\n  signed 8 -2(fe) >> 65(41) = -1(ff)\n  signed 8 -2(fe) >> 66(42) = -1(ff)\n  signed 8 -2(fe) >> 67(43) = -1(ff)\n  signed 8 -2(fe) >> 68(44) = -1(ff)\n  signed 8 -2(fe) >> 69(45) = -1(ff)\n  signed 8 -2(fe) >> 70(46) = -1(ff)\n  signed 8 -2(fe) >> 71(47) = -1(ff)\n  signed 8 -2(fe) >> 72(48) = -1(ff)\n  signed 8 -2(fe) >> 73(49) = -1(ff)\n  signed 8 -2(fe) >> 74(4a) = -1(ff)\n  signed 8 -2(fe) >> 75(4b) = -1(ff)\n  signed 8 -2(fe) >> 76(4c) = -1(ff)\n  signed 8 -2(fe) >> 77(4d) = -1(ff)\n  signed 8 -2(fe) >> 78(4e) = -1(ff)\n  signed 8 -2(fe) >> 79(4f) = -1(ff)\n  signed 8 -2(fe) >> 80(50) = -1(ff)\n  signed 8 -2(fe) >> 81(51) = -1(ff)\n  signed 8 -2(fe) >> 82(52) = -1(ff)\n  signed 8 -2(fe) >> 83(53) = -1(ff)\n  signed 8 -2(fe) >> 84(54) = -1(ff)\n  signed 8 -2(fe) >> 85(55) = -1(ff)\n  signed 8 -2(fe) >> 86(56) = -1(ff)\n  signed 8 -2(fe) >> 87(57) = -1(ff)\n  signed 8 -2(fe) >> 88(58) = -1(ff)\n  signed 8 -2(fe) >> 89(59) = -1(ff)\n  signed 8 -2(fe) >> 90(5a) = -1(ff)\n  signed 8 -2(fe) >> 91(5b) = -1(ff)\n  signed 8 -2(fe) >> 92(5c) = -1(ff)\n  signed 8 -2(fe) >> 93(5d) = -1(ff)\n  signed 8 -2(fe) >> 94(5e) = -1(ff)\n  signed 8 -2(fe) >> 95(5f) = -1(ff)\n  signed 8 -2(fe) >> 96(60) = -2(fe)\n  signed 8 -2(fe) >> 97(61) = -1(ff)\n  signed 8 -2(fe) >> 98(62) = -1(ff)\n  signed 8 -2(fe) >> 99(63) = -1(ff)\n  signed 8 -2(fe) >> 100(64) = -1(ff)\n  signed 8 -2(fe) >> 101(65) = -1(ff)\n  signed 8 -2(fe) >> 102(66) = -1(ff)\n  signed 8 -2(fe) >> 103(67) = -1(ff)\n  signed 8 -2(fe) >> 104(68) = -1(ff)\n  signed 8 -2(fe) >> 105(69) = -1(ff)\n  signed 8 -2(fe) >> 106(6a) = -1(ff)\n  signed 8 -2(fe) >> 107(6b) = -1(ff)\n  signed 8 -2(fe) >> 108(6c) = -1(ff)\n  signed 8 -2(fe) >> 109(6d) = -1(ff)\n  signed 8 -2(fe) >> 110(6e) = -1(ff)\n  signed 8 -2(fe) >> 111(6f) = -1(ff)\n  signed 8 -2(fe) >> 112(70) = -1(ff)\n  signed 8 -2(fe) >> 113(71) = -1(ff)\n  signed 8 -2(fe) >> 114(72) = -1(ff)\n  signed 8 -2(fe) >> 115(73) = -1(ff)\n  signed 8 -2(fe) >> 116(74) = -1(ff)\n  signed 8 -2(fe) >> 117(75) = -1(ff)\n  signed 8 -2(fe) >> 118(76) = -1(ff)\n  signed 8 -2(fe) >> 119(77) = -1(ff)\n  signed 8 -2(fe) >> 120(78) = -1(ff)\n  signed 8 -2(fe) >> 121(79) = -1(ff)\n  signed 8 -2(fe) >> 122(7a) = -1(ff)\n  signed 8 -2(fe) >> 123(7b) = -1(ff)\n  signed 8 -2(fe) >> 124(7c) = -1(ff)\n  signed 8 -2(fe) >> 125(7d) = -1(ff)\n  signed 8 -2(fe) >> 126(7e) = -1(ff)\n  signed 8 -2(fe) >> 127(7f) = -1(ff)\n  signed 8 -1(ff) >> -128(ffffff80) = -1(ff)\n  signed 8 -1(ff) >> -127(ffffff81) = -1(ff)\n  signed 8 -1(ff) >> -126(ffffff82) = -1(ff)\n  signed 8 -1(ff) >> -125(ffffff83) = -1(ff)\n  signed 8 -1(ff) >> -124(ffffff84) = -1(ff)\n  signed 8 -1(ff) >> -123(ffffff85) = -1(ff)\n  signed 8 -1(ff) >> -122(ffffff86) = -1(ff)\n  signed 8 -1(ff) >> -121(ffffff87) = -1(ff)\n  signed 8 -1(ff) >> -120(ffffff88) = -1(ff)\n  signed 8 -1(ff) >> -119(ffffff89) = -1(ff)\n  signed 8 -1(ff) >> -118(ffffff8a) = -1(ff)\n  signed 8 -1(ff) >> -117(ffffff8b) = -1(ff)\n  signed 8 -1(ff) >> -116(ffffff8c) = -1(ff)\n  signed 8 -1(ff) >> -115(ffffff8d) = -1(ff)\n  signed 8 -1(ff) >> -114(ffffff8e) = -1(ff)\n  signed 8 -1(ff) >> -113(ffffff8f) = -1(ff)\n  signed 8 -1(ff) >> -112(ffffff90) = -1(ff)\n  signed 8 -1(ff) >> -111(ffffff91) = -1(ff)\n  signed 8 -1(ff) >> -110(ffffff92) = -1(ff)\n  signed 8 -1(ff) >> -109(ffffff93) = -1(ff)\n  signed 8 -1(ff) >> -108(ffffff94) = -1(ff)\n  signed 8 -1(ff) >> -107(ffffff95) = -1(ff)\n  signed 8 -1(ff) >> -106(ffffff96) = -1(ff)\n  signed 8 -1(ff) >> -105(ffffff97) = -1(ff)\n  signed 8 -1(ff) >> -104(ffffff98) = -1(ff)\n  signed 8 -1(ff) >> -103(ffffff99) = -1(ff)\n  signed 8 -1(ff) >> -102(ffffff9a) = -1(ff)\n  signed 8 -1(ff) >> -101(ffffff9b) = -1(ff)\n  signed 8 -1(ff) >> -100(ffffff9c) = -1(ff)\n  signed 8 -1(ff) >> -99(ffffff9d) = -1(ff)\n  signed 8 -1(ff) >> -98(ffffff9e) = -1(ff)\n  signed 8 -1(ff) >> -97(ffffff9f) = -1(ff)\n  signed 8 -1(ff) >> -96(ffffffa0) = -1(ff)\n  signed 8 -1(ff) >> -95(ffffffa1) = -1(ff)\n  signed 8 -1(ff) >> -94(ffffffa2) = -1(ff)\n  signed 8 -1(ff) >> -93(ffffffa3) = -1(ff)\n  signed 8 -1(ff) >> -92(ffffffa4) = -1(ff)\n  signed 8 -1(ff) >> -91(ffffffa5) = -1(ff)\n  signed 8 -1(ff) >> -90(ffffffa6) = -1(ff)\n  signed 8 -1(ff) >> -89(ffffffa7) = -1(ff)\n  signed 8 -1(ff) >> -88(ffffffa8) = -1(ff)\n  signed 8 -1(ff) >> -87(ffffffa9) = -1(ff)\n  signed 8 -1(ff) >> -86(ffffffaa) = -1(ff)\n  signed 8 -1(ff) >> -85(ffffffab) = -1(ff)\n  signed 8 -1(ff) >> -84(ffffffac) = -1(ff)\n  signed 8 -1(ff) >> -83(ffffffad) = -1(ff)\n  signed 8 -1(ff) >> -82(ffffffae) = -1(ff)\n  signed 8 -1(ff) >> -81(ffffffaf) = -1(ff)\n  signed 8 -1(ff) >> -80(ffffffb0) = -1(ff)\n  signed 8 -1(ff) >> -79(ffffffb1) = -1(ff)\n  signed 8 -1(ff) >> -78(ffffffb2) = -1(ff)\n  signed 8 -1(ff) >> -77(ffffffb3) = -1(ff)\n  signed 8 -1(ff) >> -76(ffffffb4) = -1(ff)\n  signed 8 -1(ff) >> -75(ffffffb5) = -1(ff)\n  signed 8 -1(ff) >> -74(ffffffb6) = -1(ff)\n  signed 8 -1(ff) >> -73(ffffffb7) = -1(ff)\n  signed 8 -1(ff) >> -72(ffffffb8) = -1(ff)\n  signed 8 -1(ff) >> -71(ffffffb9) = -1(ff)\n  signed 8 -1(ff) >> -70(ffffffba) = -1(ff)\n  signed 8 -1(ff) >> -69(ffffffbb) = -1(ff)\n  signed 8 -1(ff) >> -68(ffffffbc) = -1(ff)\n  signed 8 -1(ff) >> -67(ffffffbd) = -1(ff)\n  signed 8 -1(ff) >> -66(ffffffbe) = -1(ff)\n  signed 8 -1(ff) >> -65(ffffffbf) = -1(ff)\n  signed 8 -1(ff) >> -64(ffffffc0) = -1(ff)\n  signed 8 -1(ff) >> -63(ffffffc1) = -1(ff)\n  signed 8 -1(ff) >> -62(ffffffc2) = -1(ff)\n  signed 8 -1(ff) >> -61(ffffffc3) = -1(ff)\n  signed 8 -1(ff) >> -60(ffffffc4) = -1(ff)\n  signed 8 -1(ff) >> -59(ffffffc5) = -1(ff)\n  signed 8 -1(ff) >> -58(ffffffc6) = -1(ff)\n  signed 8 -1(ff) >> -57(ffffffc7) = -1(ff)\n  signed 8 -1(ff) >> -56(ffffffc8) = -1(ff)\n  signed 8 -1(ff) >> -55(ffffffc9) = -1(ff)\n  signed 8 -1(ff) >> -54(ffffffca) = -1(ff)\n  signed 8 -1(ff) >> -53(ffffffcb) = -1(ff)\n  signed 8 -1(ff) >> -52(ffffffcc) = -1(ff)\n  signed 8 -1(ff) >> -51(ffffffcd) = -1(ff)\n  signed 8 -1(ff) >> -50(ffffffce) = -1(ff)\n  signed 8 -1(ff) >> -49(ffffffcf) = -1(ff)\n  signed 8 -1(ff) >> -48(ffffffd0) = -1(ff)\n  signed 8 -1(ff) >> -47(ffffffd1) = -1(ff)\n  signed 8 -1(ff) >> -46(ffffffd2) = -1(ff)\n  signed 8 -1(ff) >> -45(ffffffd3) = -1(ff)\n  signed 8 -1(ff) >> -44(ffffffd4) = -1(ff)\n  signed 8 -1(ff) >> -43(ffffffd5) = -1(ff)\n  signed 8 -1(ff) >> -42(ffffffd6) = -1(ff)\n  signed 8 -1(ff) >> -41(ffffffd7) = -1(ff)\n  signed 8 -1(ff) >> -40(ffffffd8) = -1(ff)\n  signed 8 -1(ff) >> -39(ffffffd9) = -1(ff)\n  signed 8 -1(ff) >> -38(ffffffda) = -1(ff)\n  signed 8 -1(ff) >> -37(ffffffdb) = -1(ff)\n  signed 8 -1(ff) >> -36(ffffffdc) = -1(ff)\n  signed 8 -1(ff) >> -35(ffffffdd) = -1(ff)\n  signed 8 -1(ff) >> -34(ffffffde) = -1(ff)\n  signed 8 -1(ff) >> -33(ffffffdf) = -1(ff)\n  signed 8 -1(ff) >> -32(ffffffe0) = -1(ff)\n  signed 8 -1(ff) >> -31(ffffffe1) = -1(ff)\n  signed 8 -1(ff) >> -30(ffffffe2) = -1(ff)\n  signed 8 -1(ff) >> -29(ffffffe3) = -1(ff)\n  signed 8 -1(ff) >> -28(ffffffe4) = -1(ff)\n  signed 8 -1(ff) >> -27(ffffffe5) = -1(ff)\n  signed 8 -1(ff) >> -26(ffffffe6) = -1(ff)\n  signed 8 -1(ff) >> -25(ffffffe7) = -1(ff)\n  signed 8 -1(ff) >> -24(ffffffe8) = -1(ff)\n  signed 8 -1(ff) >> -23(ffffffe9) = -1(ff)\n  signed 8 -1(ff) >> -22(ffffffea) = -1(ff)\n  signed 8 -1(ff) >> -21(ffffffeb) = -1(ff)\n  signed 8 -1(ff) >> -20(ffffffec) = -1(ff)\n  signed 8 -1(ff) >> -19(ffffffed) = -1(ff)\n  signed 8 -1(ff) >> -18(ffffffee) = -1(ff)\n  signed 8 -1(ff) >> -17(ffffffef) = -1(ff)\n  signed 8 -1(ff) >> -16(fffffff0) = -1(ff)\n  signed 8 -1(ff) >> -15(fffffff1) = -1(ff)\n  signed 8 -1(ff) >> -14(fffffff2) = -1(ff)\n  signed 8 -1(ff) >> -13(fffffff3) = -1(ff)\n  signed 8 -1(ff) >> -12(fffffff4) = -1(ff)\n  signed 8 -1(ff) >> -11(fffffff5) = -1(ff)\n  signed 8 -1(ff) >> -10(fffffff6) = -1(ff)\n  signed 8 -1(ff) >> -9(fffffff7) = -1(ff)\n  signed 8 -1(ff) >> -8(fffffff8) = -1(ff)\n  signed 8 -1(ff) >> -7(fffffff9) = -1(ff)\n  signed 8 -1(ff) >> -6(fffffffa) = -1(ff)\n  signed 8 -1(ff) >> -5(fffffffb) = -1(ff)\n  signed 8 -1(ff) >> -4(fffffffc) = -1(ff)\n  signed 8 -1(ff) >> -3(fffffffd) = -1(ff)\n  signed 8 -1(ff) >> -2(fffffffe) = -1(ff)\n  signed 8 -1(ff) >> -1(ffffffff) = -1(ff)\n  signed 8 -1(ff) >> 0(0) = -1(ff)\n  signed 8 -1(ff) >> 1(1) = -1(ff)\n  signed 8 -1(ff) >> 2(2) = -1(ff)\n  signed 8 -1(ff) >> 3(3) = -1(ff)\n  signed 8 -1(ff) >> 4(4) = -1(ff)\n  signed 8 -1(ff) >> 5(5) = -1(ff)\n  signed 8 -1(ff) >> 6(6) = -1(ff)\n  signed 8 -1(ff) >> 7(7) = -1(ff)\n  signed 8 -1(ff) >> 8(8) = -1(ff)\n  signed 8 -1(ff) >> 9(9) = -1(ff)\n  signed 8 -1(ff) >> 10(a) = -1(ff)\n  signed 8 -1(ff) >> 11(b) = -1(ff)\n  signed 8 -1(ff) >> 12(c) = -1(ff)\n  signed 8 -1(ff) >> 13(d) = -1(ff)\n  signed 8 -1(ff) >> 14(e) = -1(ff)\n  signed 8 -1(ff) >> 15(f) = -1(ff)\n  signed 8 -1(ff) >> 16(10) = -1(ff)\n  signed 8 -1(ff) >> 17(11) = -1(ff)\n  signed 8 -1(ff) >> 18(12) = -1(ff)\n  signed 8 -1(ff) >> 19(13) = -1(ff)\n  signed 8 -1(ff) >> 20(14) = -1(ff)\n  signed 8 -1(ff) >> 21(15) = -1(ff)\n  signed 8 -1(ff) >> 22(16) = -1(ff)\n  signed 8 -1(ff) >> 23(17) = -1(ff)\n  signed 8 -1(ff) >> 24(18) = -1(ff)\n  signed 8 -1(ff) >> 25(19) = -1(ff)\n  signed 8 -1(ff) >> 26(1a) = -1(ff)\n  signed 8 -1(ff) >> 27(1b) = -1(ff)\n  signed 8 -1(ff) >> 28(1c) = -1(ff)\n  signed 8 -1(ff) >> 29(1d) = -1(ff)\n  signed 8 -1(ff) >> 30(1e) = -1(ff)\n  signed 8 -1(ff) >> 31(1f) = -1(ff)\n  signed 8 -1(ff) >> 32(20) = -1(ff)\n  signed 8 -1(ff) >> 33(21) = -1(ff)\n  signed 8 -1(ff) >> 34(22) = -1(ff)\n  signed 8 -1(ff) >> 35(23) = -1(ff)\n  signed 8 -1(ff) >> 36(24) = -1(ff)\n  signed 8 -1(ff) >> 37(25) = -1(ff)\n  signed 8 -1(ff) >> 38(26) = -1(ff)\n  signed 8 -1(ff) >> 39(27) = -1(ff)\n  signed 8 -1(ff) >> 40(28) = -1(ff)\n  signed 8 -1(ff) >> 41(29) = -1(ff)\n  signed 8 -1(ff) >> 42(2a) = -1(ff)\n  signed 8 -1(ff) >> 43(2b) = -1(ff)\n  signed 8 -1(ff) >> 44(2c) = -1(ff)\n  signed 8 -1(ff) >> 45(2d) = -1(ff)\n  signed 8 -1(ff) >> 46(2e) = -1(ff)\n  signed 8 -1(ff) >> 47(2f) = -1(ff)\n  signed 8 -1(ff) >> 48(30) = -1(ff)\n  signed 8 -1(ff) >> 49(31) = -1(ff)\n  signed 8 -1(ff) >> 50(32) = -1(ff)\n  signed 8 -1(ff) >> 51(33) = -1(ff)\n  signed 8 -1(ff) >> 52(34) = -1(ff)\n  signed 8 -1(ff) >> 53(35) = -1(ff)\n  signed 8 -1(ff) >> 54(36) = -1(ff)\n  signed 8 -1(ff) >> 55(37) = -1(ff)\n  signed 8 -1(ff) >> 56(38) = -1(ff)\n  signed 8 -1(ff) >> 57(39) = -1(ff)\n  signed 8 -1(ff) >> 58(3a) = -1(ff)\n  signed 8 -1(ff) >> 59(3b) = -1(ff)\n  signed 8 -1(ff) >> 60(3c) = -1(ff)\n  signed 8 -1(ff) >> 61(3d) = -1(ff)\n  signed 8 -1(ff) >> 62(3e) = -1(ff)\n  signed 8 -1(ff) >> 63(3f) = -1(ff)\n  signed 8 -1(ff) >> 64(40) = -1(ff)\n  signed 8 -1(ff) >> 65(41) = -1(ff)\n  signed 8 -1(ff) >> 66(42) = -1(ff)\n  signed 8 -1(ff) >> 67(43) = -1(ff)\n  signed 8 -1(ff) >> 68(44) = -1(ff)\n  signed 8 -1(ff) >> 69(45) = -1(ff)\n  signed 8 -1(ff) >> 70(46) = -1(ff)\n  signed 8 -1(ff) >> 71(47) = -1(ff)\n  signed 8 -1(ff) >> 72(48) = -1(ff)\n  signed 8 -1(ff) >> 73(49) = -1(ff)\n  signed 8 -1(ff) >> 74(4a) = -1(ff)\n  signed 8 -1(ff) >> 75(4b) = -1(ff)\n  signed 8 -1(ff) >> 76(4c) = -1(ff)\n  signed 8 -1(ff) >> 77(4d) = -1(ff)\n  signed 8 -1(ff) >> 78(4e) = -1(ff)\n  signed 8 -1(ff) >> 79(4f) = -1(ff)\n  signed 8 -1(ff) >> 80(50) = -1(ff)\n  signed 8 -1(ff) >> 81(51) = -1(ff)\n  signed 8 -1(ff) >> 82(52) = -1(ff)\n  signed 8 -1(ff) >> 83(53) = -1(ff)\n  signed 8 -1(ff) >> 84(54) = -1(ff)\n  signed 8 -1(ff) >> 85(55) = -1(ff)\n  signed 8 -1(ff) >> 86(56) = -1(ff)\n  signed 8 -1(ff) >> 87(57) = -1(ff)\n  signed 8 -1(ff) >> 88(58) = -1(ff)\n  signed 8 -1(ff) >> 89(59) = -1(ff)\n  signed 8 -1(ff) >> 90(5a) = -1(ff)\n  signed 8 -1(ff) >> 91(5b) = -1(ff)\n  signed 8 -1(ff) >> 92(5c) = -1(ff)\n  signed 8 -1(ff) >> 93(5d) = -1(ff)\n  signed 8 -1(ff) >> 94(5e) = -1(ff)\n  signed 8 -1(ff) >> 95(5f) = -1(ff)\n  signed 8 -1(ff) >> 96(60) = -1(ff)\n  signed 8 -1(ff) >> 97(61) = -1(ff)\n  signed 8 -1(ff) >> 98(62) = -1(ff)\n  signed 8 -1(ff) >> 99(63) = -1(ff)\n  signed 8 -1(ff) >> 100(64) = -1(ff)\n  signed 8 -1(ff) >> 101(65) = -1(ff)\n  signed 8 -1(ff) >> 102(66) = -1(ff)\n  signed 8 -1(ff) >> 103(67) = -1(ff)\n  signed 8 -1(ff) >> 104(68) = -1(ff)\n  signed 8 -1(ff) >> 105(69) = -1(ff)\n  signed 8 -1(ff) >> 106(6a) = -1(ff)\n  signed 8 -1(ff) >> 107(6b) = -1(ff)\n  signed 8 -1(ff) >> 108(6c) = -1(ff)\n  signed 8 -1(ff) >> 109(6d) = -1(ff)\n  signed 8 -1(ff) >> 110(6e) = -1(ff)\n  signed 8 -1(ff) >> 111(6f) = -1(ff)\n  signed 8 -1(ff) >> 112(70) = -1(ff)\n  signed 8 -1(ff) >> 113(71) = -1(ff)\n  signed 8 -1(ff) >> 114(72) = -1(ff)\n  signed 8 -1(ff) >> 115(73) = -1(ff)\n  signed 8 -1(ff) >> 116(74) = -1(ff)\n  signed 8 -1(ff) >> 117(75) = -1(ff)\n  signed 8 -1(ff) >> 118(76) = -1(ff)\n  signed 8 -1(ff) >> 119(77) = -1(ff)\n  signed 8 -1(ff) >> 120(78) = -1(ff)\n  signed 8 -1(ff) >> 121(79) = -1(ff)\n  signed 8 -1(ff) >> 122(7a) = -1(ff)\n  signed 8 -1(ff) >> 123(7b) = -1(ff)\n  signed 8 -1(ff) >> 124(7c) = -1(ff)\n  signed 8 -1(ff) >> 125(7d) = -1(ff)\n  signed 8 -1(ff) >> 126(7e) = -1(ff)\n  signed 8 -1(ff) >> 127(7f) = -1(ff)\n  signed 8 0(0) >> -128(ffffff80) = 0(0)\n  signed 8 0(0) >> -127(ffffff81) = 0(0)\n  signed 8 0(0) >> -126(ffffff82) = 0(0)\n  signed 8 0(0) >> -125(ffffff83) = 0(0)\n  signed 8 0(0) >> -124(ffffff84) = 0(0)\n  signed 8 0(0) >> -123(ffffff85) = 0(0)\n  signed 8 0(0) >> -122(ffffff86) = 0(0)\n  signed 8 0(0) >> -121(ffffff87) = 0(0)\n  signed 8 0(0) >> -120(ffffff88) = 0(0)\n  signed 8 0(0) >> -119(ffffff89) = 0(0)\n  signed 8 0(0) >> -118(ffffff8a) = 0(0)\n  signed 8 0(0) >> -117(ffffff8b) = 0(0)\n  signed 8 0(0) >> -116(ffffff8c) = 0(0)\n  signed 8 0(0) >> -115(ffffff8d) = 0(0)\n  signed 8 0(0) >> -114(ffffff8e) = 0(0)\n  signed 8 0(0) >> -113(ffffff8f) = 0(0)\n  signed 8 0(0) >> -112(ffffff90) = 0(0)\n  signed 8 0(0) >> -111(ffffff91) = 0(0)\n  signed 8 0(0) >> -110(ffffff92) = 0(0)\n  signed 8 0(0) >> -109(ffffff93) = 0(0)\n  signed 8 0(0) >> -108(ffffff94) = 0(0)\n  signed 8 0(0) >> -107(ffffff95) = 0(0)\n  signed 8 0(0) >> -106(ffffff96) = 0(0)\n  signed 8 0(0) >> -105(ffffff97) = 0(0)\n  signed 8 0(0) >> -104(ffffff98) = 0(0)\n  signed 8 0(0) >> -103(ffffff99) = 0(0)\n  signed 8 0(0) >> -102(ffffff9a) = 0(0)\n  signed 8 0(0) >> -101(ffffff9b) = 0(0)\n  signed 8 0(0) >> -100(ffffff9c) = 0(0)\n  signed 8 0(0) >> -99(ffffff9d) = 0(0)\n  signed 8 0(0) >> -98(ffffff9e) = 0(0)\n  signed 8 0(0) >> -97(ffffff9f) = 0(0)\n  signed 8 0(0) >> -96(ffffffa0) = 0(0)\n  signed 8 0(0) >> -95(ffffffa1) = 0(0)\n  signed 8 0(0) >> -94(ffffffa2) = 0(0)\n  signed 8 0(0) >> -93(ffffffa3) = 0(0)\n  signed 8 0(0) >> -92(ffffffa4) = 0(0)\n  signed 8 0(0) >> -91(ffffffa5) = 0(0)\n  signed 8 0(0) >> -90(ffffffa6) = 0(0)\n  signed 8 0(0) >> -89(ffffffa7) = 0(0)\n  signed 8 0(0) >> -88(ffffffa8) = 0(0)\n  signed 8 0(0) >> -87(ffffffa9) = 0(0)\n  signed 8 0(0) >> -86(ffffffaa) = 0(0)\n  signed 8 0(0) >> -85(ffffffab) = 0(0)\n  signed 8 0(0) >> -84(ffffffac) = 0(0)\n  signed 8 0(0) >> -83(ffffffad) = 0(0)\n  signed 8 0(0) >> -82(ffffffae) = 0(0)\n  signed 8 0(0) >> -81(ffffffaf) = 0(0)\n  signed 8 0(0) >> -80(ffffffb0) = 0(0)\n  signed 8 0(0) >> -79(ffffffb1) = 0(0)\n  signed 8 0(0) >> -78(ffffffb2) = 0(0)\n  signed 8 0(0) >> -77(ffffffb3) = 0(0)\n  signed 8 0(0) >> -76(ffffffb4) = 0(0)\n  signed 8 0(0) >> -75(ffffffb5) = 0(0)\n  signed 8 0(0) >> -74(ffffffb6) = 0(0)\n  signed 8 0(0) >> -73(ffffffb7) = 0(0)\n  signed 8 0(0) >> -72(ffffffb8) = 0(0)\n  signed 8 0(0) >> -71(ffffffb9) = 0(0)\n  signed 8 0(0) >> -70(ffffffba) = 0(0)\n  signed 8 0(0) >> -69(ffffffbb) = 0(0)\n  signed 8 0(0) >> -68(ffffffbc) = 0(0)\n  signed 8 0(0) >> -67(ffffffbd) = 0(0)\n  signed 8 0(0) >> -66(ffffffbe) = 0(0)\n  signed 8 0(0) >> -65(ffffffbf) = 0(0)\n  signed 8 0(0) >> -64(ffffffc0) = 0(0)\n  signed 8 0(0) >> -63(ffffffc1) = 0(0)\n  signed 8 0(0) >> -62(ffffffc2) = 0(0)\n  signed 8 0(0) >> -61(ffffffc3) = 0(0)\n  signed 8 0(0) >> -60(ffffffc4) = 0(0)\n  signed 8 0(0) >> -59(ffffffc5) = 0(0)\n  signed 8 0(0) >> -58(ffffffc6) = 0(0)\n  signed 8 0(0) >> -57(ffffffc7) = 0(0)\n  signed 8 0(0) >> -56(ffffffc8) = 0(0)\n  signed 8 0(0) >> -55(ffffffc9) = 0(0)\n  signed 8 0(0) >> -54(ffffffca) = 0(0)\n  signed 8 0(0) >> -53(ffffffcb) = 0(0)\n  signed 8 0(0) >> -52(ffffffcc) = 0(0)\n  signed 8 0(0) >> -51(ffffffcd) = 0(0)\n  signed 8 0(0) >> -50(ffffffce) = 0(0)\n  signed 8 0(0) >> -49(ffffffcf) = 0(0)\n  signed 8 0(0) >> -48(ffffffd0) = 0(0)\n  signed 8 0(0) >> -47(ffffffd1) = 0(0)\n  signed 8 0(0) >> -46(ffffffd2) = 0(0)\n  signed 8 0(0) >> -45(ffffffd3) = 0(0)\n  signed 8 0(0) >> -44(ffffffd4) = 0(0)\n  signed 8 0(0) >> -43(ffffffd5) = 0(0)\n  signed 8 0(0) >> -42(ffffffd6) = 0(0)\n  signed 8 0(0) >> -41(ffffffd7) = 0(0)\n  signed 8 0(0) >> -40(ffffffd8) = 0(0)\n  signed 8 0(0) >> -39(ffffffd9) = 0(0)\n  signed 8 0(0) >> -38(ffffffda) = 0(0)\n  signed 8 0(0) >> -37(ffffffdb) = 0(0)\n  signed 8 0(0) >> -36(ffffffdc) = 0(0)\n  signed 8 0(0) >> -35(ffffffdd) = 0(0)\n  signed 8 0(0) >> -34(ffffffde) = 0(0)\n  signed 8 0(0) >> -33(ffffffdf) = 0(0)\n  signed 8 0(0) >> -32(ffffffe0) = 0(0)\n  signed 8 0(0) >> -31(ffffffe1) = 0(0)\n  signed 8 0(0) >> -30(ffffffe2) = 0(0)\n  signed 8 0(0) >> -29(ffffffe3) = 0(0)\n  signed 8 0(0) >> -28(ffffffe4) = 0(0)\n  signed 8 0(0) >> -27(ffffffe5) = 0(0)\n  signed 8 0(0) >> -26(ffffffe6) = 0(0)\n  signed 8 0(0) >> -25(ffffffe7) = 0(0)\n  signed 8 0(0) >> -24(ffffffe8) = 0(0)\n  signed 8 0(0) >> -23(ffffffe9) = 0(0)\n  signed 8 0(0) >> -22(ffffffea) = 0(0)\n  signed 8 0(0) >> -21(ffffffeb) = 0(0)\n  signed 8 0(0) >> -20(ffffffec) = 0(0)\n  signed 8 0(0) >> -19(ffffffed) = 0(0)\n  signed 8 0(0) >> -18(ffffffee) = 0(0)\n  signed 8 0(0) >> -17(ffffffef) = 0(0)\n  signed 8 0(0) >> -16(fffffff0) = 0(0)\n  signed 8 0(0) >> -15(fffffff1) = 0(0)\n  signed 8 0(0) >> -14(fffffff2) = 0(0)\n  signed 8 0(0) >> -13(fffffff3) = 0(0)\n  signed 8 0(0) >> -12(fffffff4) = 0(0)\n  signed 8 0(0) >> -11(fffffff5) = 0(0)\n  signed 8 0(0) >> -10(fffffff6) = 0(0)\n  signed 8 0(0) >> -9(fffffff7) = 0(0)\n  signed 8 0(0) >> -8(fffffff8) = 0(0)\n  signed 8 0(0) >> -7(fffffff9) = 0(0)\n  signed 8 0(0) >> -6(fffffffa) = 0(0)\n  signed 8 0(0) >> -5(fffffffb) = 0(0)\n  signed 8 0(0) >> -4(fffffffc) = 0(0)\n  signed 8 0(0) >> -3(fffffffd) = 0(0)\n  signed 8 0(0) >> -2(fffffffe) = 0(0)\n  signed 8 0(0) >> -1(ffffffff) = 0(0)\n  signed 8 0(0) >> 0(0) = 0(0)\n  signed 8 0(0) >> 1(1) = 0(0)\n  signed 8 0(0) >> 2(2) = 0(0)\n  signed 8 0(0) >> 3(3) = 0(0)\n  signed 8 0(0) >> 4(4) = 0(0)\n  signed 8 0(0) >> 5(5) = 0(0)\n  signed 8 0(0) >> 6(6) = 0(0)\n  signed 8 0(0) >> 7(7) = 0(0)\n  signed 8 0(0) >> 8(8) = 0(0)\n  signed 8 0(0) >> 9(9) = 0(0)\n  signed 8 0(0) >> 10(a) = 0(0)\n  signed 8 0(0) >> 11(b) = 0(0)\n  signed 8 0(0) >> 12(c) = 0(0)\n  signed 8 0(0) >> 13(d) = 0(0)\n  signed 8 0(0) >> 14(e) = 0(0)\n  signed 8 0(0) >> 15(f) = 0(0)\n  signed 8 0(0) >> 16(10) = 0(0)\n  signed 8 0(0) >> 17(11) = 0(0)\n  signed 8 0(0) >> 18(12) = 0(0)\n  signed 8 0(0) >> 19(13) = 0(0)\n  signed 8 0(0) >> 20(14) = 0(0)\n  signed 8 0(0) >> 21(15) = 0(0)\n  signed 8 0(0) >> 22(16) = 0(0)\n  signed 8 0(0) >> 23(17) = 0(0)\n  signed 8 0(0) >> 24(18) = 0(0)\n  signed 8 0(0) >> 25(19) = 0(0)\n  signed 8 0(0) >> 26(1a) = 0(0)\n  signed 8 0(0) >> 27(1b) = 0(0)\n  signed 8 0(0) >> 28(1c) = 0(0)\n  signed 8 0(0) >> 29(1d) = 0(0)\n  signed 8 0(0) >> 30(1e) = 0(0)\n  signed 8 0(0) >> 31(1f) = 0(0)\n  signed 8 0(0) >> 32(20) = 0(0)\n  signed 8 0(0) >> 33(21) = 0(0)\n  signed 8 0(0) >> 34(22) = 0(0)\n  signed 8 0(0) >> 35(23) = 0(0)\n  signed 8 0(0) >> 36(24) = 0(0)\n  signed 8 0(0) >> 37(25) = 0(0)\n  signed 8 0(0) >> 38(26) = 0(0)\n  signed 8 0(0) >> 39(27) = 0(0)\n  signed 8 0(0) >> 40(28) = 0(0)\n  signed 8 0(0) >> 41(29) = 0(0)\n  signed 8 0(0) >> 42(2a) = 0(0)\n  signed 8 0(0) >> 43(2b) = 0(0)\n  signed 8 0(0) >> 44(2c) = 0(0)\n  signed 8 0(0) >> 45(2d) = 0(0)\n  signed 8 0(0) >> 46(2e) = 0(0)\n  signed 8 0(0) >> 47(2f) = 0(0)\n  signed 8 0(0) >> 48(30) = 0(0)\n  signed 8 0(0) >> 49(31) = 0(0)\n  signed 8 0(0) >> 50(32) = 0(0)\n  signed 8 0(0) >> 51(33) = 0(0)\n  signed 8 0(0) >> 52(34) = 0(0)\n  signed 8 0(0) >> 53(35) = 0(0)\n  signed 8 0(0) >> 54(36) = 0(0)\n  signed 8 0(0) >> 55(37) = 0(0)\n  signed 8 0(0) >> 56(38) = 0(0)\n  signed 8 0(0) >> 57(39) = 0(0)\n  signed 8 0(0) >> 58(3a) = 0(0)\n  signed 8 0(0) >> 59(3b) = 0(0)\n  signed 8 0(0) >> 60(3c) = 0(0)\n  signed 8 0(0) >> 61(3d) = 0(0)\n  signed 8 0(0) >> 62(3e) = 0(0)\n  signed 8 0(0) >> 63(3f) = 0(0)\n  signed 8 0(0) >> 64(40) = 0(0)\n  signed 8 0(0) >> 65(41) = 0(0)\n  signed 8 0(0) >> 66(42) = 0(0)\n  signed 8 0(0) >> 67(43) = 0(0)\n  signed 8 0(0) >> 68(44) = 0(0)\n  signed 8 0(0) >> 69(45) = 0(0)\n  signed 8 0(0) >> 70(46) = 0(0)\n  signed 8 0(0) >> 71(47) = 0(0)\n  signed 8 0(0) >> 72(48) = 0(0)\n  signed 8 0(0) >> 73(49) = 0(0)\n  signed 8 0(0) >> 74(4a) = 0(0)\n  signed 8 0(0) >> 75(4b) = 0(0)\n  signed 8 0(0) >> 76(4c) = 0(0)\n  signed 8 0(0) >> 77(4d) = 0(0)\n  signed 8 0(0) >> 78(4e) = 0(0)\n  signed 8 0(0) >> 79(4f) = 0(0)\n  signed 8 0(0) >> 80(50) = 0(0)\n  signed 8 0(0) >> 81(51) = 0(0)\n  signed 8 0(0) >> 82(52) = 0(0)\n  signed 8 0(0) >> 83(53) = 0(0)\n  signed 8 0(0) >> 84(54) = 0(0)\n  signed 8 0(0) >> 85(55) = 0(0)\n  signed 8 0(0) >> 86(56) = 0(0)\n  signed 8 0(0) >> 87(57) = 0(0)\n  signed 8 0(0) >> 88(58) = 0(0)\n  signed 8 0(0) >> 89(59) = 0(0)\n  signed 8 0(0) >> 90(5a) = 0(0)\n  signed 8 0(0) >> 91(5b) = 0(0)\n  signed 8 0(0) >> 92(5c) = 0(0)\n  signed 8 0(0) >> 93(5d) = 0(0)\n  signed 8 0(0) >> 94(5e) = 0(0)\n  signed 8 0(0) >> 95(5f) = 0(0)\n  signed 8 0(0) >> 96(60) = 0(0)\n  signed 8 0(0) >> 97(61) = 0(0)\n  signed 8 0(0) >> 98(62) = 0(0)\n  signed 8 0(0) >> 99(63) = 0(0)\n  signed 8 0(0) >> 100(64) = 0(0)\n  signed 8 0(0) >> 101(65) = 0(0)\n  signed 8 0(0) >> 102(66) = 0(0)\n  signed 8 0(0) >> 103(67) = 0(0)\n  signed 8 0(0) >> 104(68) = 0(0)\n  signed 8 0(0) >> 105(69) = 0(0)\n  signed 8 0(0) >> 106(6a) = 0(0)\n  signed 8 0(0) >> 107(6b) = 0(0)\n  signed 8 0(0) >> 108(6c) = 0(0)\n  signed 8 0(0) >> 109(6d) = 0(0)\n  signed 8 0(0) >> 110(6e) = 0(0)\n  signed 8 0(0) >> 111(6f) = 0(0)\n  signed 8 0(0) >> 112(70) = 0(0)\n  signed 8 0(0) >> 113(71) = 0(0)\n  signed 8 0(0) >> 114(72) = 0(0)\n  signed 8 0(0) >> 115(73) = 0(0)\n  signed 8 0(0) >> 116(74) = 0(0)\n  signed 8 0(0) >> 117(75) = 0(0)\n  signed 8 0(0) >> 118(76) = 0(0)\n  signed 8 0(0) >> 119(77) = 0(0)\n  signed 8 0(0) >> 120(78) = 0(0)\n  signed 8 0(0) >> 121(79) = 0(0)\n  signed 8 0(0) >> 122(7a) = 0(0)\n  signed 8 0(0) >> 123(7b) = 0(0)\n  signed 8 0(0) >> 124(7c) = 0(0)\n  signed 8 0(0) >> 125(7d) = 0(0)\n  signed 8 0(0) >> 126(7e) = 0(0)\n  signed 8 0(0) >> 127(7f) = 0(0)\n  signed 8 1(1) >> -128(ffffff80) = 1(1)\n  signed 8 1(1) >> -127(ffffff81) = 0(0)\n  signed 8 1(1) >> -126(ffffff82) = 0(0)\n  signed 8 1(1) >> -125(ffffff83) = 0(0)\n  signed 8 1(1) >> -124(ffffff84) = 0(0)\n  signed 8 1(1) >> -123(ffffff85) = 0(0)\n  signed 8 1(1) >> -122(ffffff86) = 0(0)\n  signed 8 1(1) >> -121(ffffff87) = 0(0)\n  signed 8 1(1) >> -120(ffffff88) = 0(0)\n  signed 8 1(1) >> -119(ffffff89) = 0(0)\n  signed 8 1(1) >> -118(ffffff8a) = 0(0)\n  signed 8 1(1) >> -117(ffffff8b) = 0(0)\n  signed 8 1(1) >> -116(ffffff8c) = 0(0)\n  signed 8 1(1) >> -115(ffffff8d) = 0(0)\n  signed 8 1(1) >> -114(ffffff8e) = 0(0)\n  signed 8 1(1) >> -113(ffffff8f) = 0(0)\n  signed 8 1(1) >> -112(ffffff90) = 0(0)\n  signed 8 1(1) >> -111(ffffff91) = 0(0)\n  signed 8 1(1) >> -110(ffffff92) = 0(0)\n  signed 8 1(1) >> -109(ffffff93) = 0(0)\n  signed 8 1(1) >> -108(ffffff94) = 0(0)\n  signed 8 1(1) >> -107(ffffff95) = 0(0)\n  signed 8 1(1) >> -106(ffffff96) = 0(0)\n  signed 8 1(1) >> -105(ffffff97) = 0(0)\n  signed 8 1(1) >> -104(ffffff98) = 0(0)\n  signed 8 1(1) >> -103(ffffff99) = 0(0)\n  signed 8 1(1) >> -102(ffffff9a) = 0(0)\n  signed 8 1(1) >> -101(ffffff9b) = 0(0)\n  signed 8 1(1) >> -100(ffffff9c) = 0(0)\n  signed 8 1(1) >> -99(ffffff9d) = 0(0)\n  signed 8 1(1) >> -98(ffffff9e) = 0(0)\n  signed 8 1(1) >> -97(ffffff9f) = 0(0)\n  signed 8 1(1) >> -96(ffffffa0) = 1(1)\n  signed 8 1(1) >> -95(ffffffa1) = 0(0)\n  signed 8 1(1) >> -94(ffffffa2) = 0(0)\n  signed 8 1(1) >> -93(ffffffa3) = 0(0)\n  signed 8 1(1) >> -92(ffffffa4) = 0(0)\n  signed 8 1(1) >> -91(ffffffa5) = 0(0)\n  signed 8 1(1) >> -90(ffffffa6) = 0(0)\n  signed 8 1(1) >> -89(ffffffa7) = 0(0)\n  signed 8 1(1) >> -88(ffffffa8) = 0(0)\n  signed 8 1(1) >> -87(ffffffa9) = 0(0)\n  signed 8 1(1) >> -86(ffffffaa) = 0(0)\n  signed 8 1(1) >> -85(ffffffab) = 0(0)\n  signed 8 1(1) >> -84(ffffffac) = 0(0)\n  signed 8 1(1) >> -83(ffffffad) = 0(0)\n  signed 8 1(1) >> -82(ffffffae) = 0(0)\n  signed 8 1(1) >> -81(ffffffaf) = 0(0)\n  signed 8 1(1) >> -80(ffffffb0) = 0(0)\n  signed 8 1(1) >> -79(ffffffb1) = 0(0)\n  signed 8 1(1) >> -78(ffffffb2) = 0(0)\n  signed 8 1(1) >> -77(ffffffb3) = 0(0)\n  signed 8 1(1) >> -76(ffffffb4) = 0(0)\n  signed 8 1(1) >> -75(ffffffb5) = 0(0)\n  signed 8 1(1) >> -74(ffffffb6) = 0(0)\n  signed 8 1(1) >> -73(ffffffb7) = 0(0)\n  signed 8 1(1) >> -72(ffffffb8) = 0(0)\n  signed 8 1(1) >> -71(ffffffb9) = 0(0)\n  signed 8 1(1) >> -70(ffffffba) = 0(0)\n  signed 8 1(1) >> -69(ffffffbb) = 0(0)\n  signed 8 1(1) >> -68(ffffffbc) = 0(0)\n  signed 8 1(1) >> -67(ffffffbd) = 0(0)\n  signed 8 1(1) >> -66(ffffffbe) = 0(0)\n  signed 8 1(1) >> -65(ffffffbf) = 0(0)\n  signed 8 1(1) >> -64(ffffffc0) = 1(1)\n  signed 8 1(1) >> -63(ffffffc1) = 0(0)\n  signed 8 1(1) >> -62(ffffffc2) = 0(0)\n  signed 8 1(1) >> -61(ffffffc3) = 0(0)\n  signed 8 1(1) >> -60(ffffffc4) = 0(0)\n  signed 8 1(1) >> -59(ffffffc5) = 0(0)\n  signed 8 1(1) >> -58(ffffffc6) = 0(0)\n  signed 8 1(1) >> -57(ffffffc7) = 0(0)\n  signed 8 1(1) >> -56(ffffffc8) = 0(0)\n  signed 8 1(1) >> -55(ffffffc9) = 0(0)\n  signed 8 1(1) >> -54(ffffffca) = 0(0)\n  signed 8 1(1) >> -53(ffffffcb) = 0(0)\n  signed 8 1(1) >> -52(ffffffcc) = 0(0)\n  signed 8 1(1) >> -51(ffffffcd) = 0(0)\n  signed 8 1(1) >> -50(ffffffce) = 0(0)\n  signed 8 1(1) >> -49(ffffffcf) = 0(0)\n  signed 8 1(1) >> -48(ffffffd0) = 0(0)\n  signed 8 1(1) >> -47(ffffffd1) = 0(0)\n  signed 8 1(1) >> -46(ffffffd2) = 0(0)\n  signed 8 1(1) >> -45(ffffffd3) = 0(0)\n  signed 8 1(1) >> -44(ffffffd4) = 0(0)\n  signed 8 1(1) >> -43(ffffffd5) = 0(0)\n  signed 8 1(1) >> -42(ffffffd6) = 0(0)\n  signed 8 1(1) >> -41(ffffffd7) = 0(0)\n  signed 8 1(1) >> -40(ffffffd8) = 0(0)\n  signed 8 1(1) >> -39(ffffffd9) = 0(0)\n  signed 8 1(1) >> -38(ffffffda) = 0(0)\n  signed 8 1(1) >> -37(ffffffdb) = 0(0)\n  signed 8 1(1) >> -36(ffffffdc) = 0(0)\n  signed 8 1(1) >> -35(ffffffdd) = 0(0)\n  signed 8 1(1) >> -34(ffffffde) = 0(0)\n  signed 8 1(1) >> -33(ffffffdf) = 0(0)\n  signed 8 1(1) >> -32(ffffffe0) = 1(1)\n  signed 8 1(1) >> -31(ffffffe1) = 0(0)\n  signed 8 1(1) >> -30(ffffffe2) = 0(0)\n  signed 8 1(1) >> -29(ffffffe3) = 0(0)\n  signed 8 1(1) >> -28(ffffffe4) = 0(0)\n  signed 8 1(1) >> -27(ffffffe5) = 0(0)\n  signed 8 1(1) >> -26(ffffffe6) = 0(0)\n  signed 8 1(1) >> -25(ffffffe7) = 0(0)\n  signed 8 1(1) >> -24(ffffffe8) = 0(0)\n  signed 8 1(1) >> -23(ffffffe9) = 0(0)\n  signed 8 1(1) >> -22(ffffffea) = 0(0)\n  signed 8 1(1) >> -21(ffffffeb) = 0(0)\n  signed 8 1(1) >> -20(ffffffec) = 0(0)\n  signed 8 1(1) >> -19(ffffffed) = 0(0)\n  signed 8 1(1) >> -18(ffffffee) = 0(0)\n  signed 8 1(1) >> -17(ffffffef) = 0(0)\n  signed 8 1(1) >> -16(fffffff0) = 0(0)\n  signed 8 1(1) >> -15(fffffff1) = 0(0)\n  signed 8 1(1) >> -14(fffffff2) = 0(0)\n  signed 8 1(1) >> -13(fffffff3) = 0(0)\n  signed 8 1(1) >> -12(fffffff4) = 0(0)\n  signed 8 1(1) >> -11(fffffff5) = 0(0)\n  signed 8 1(1) >> -10(fffffff6) = 0(0)\n  signed 8 1(1) >> -9(fffffff7) = 0(0)\n  signed 8 1(1) >> -8(fffffff8) = 0(0)\n  signed 8 1(1) >> -7(fffffff9) = 0(0)\n  signed 8 1(1) >> -6(fffffffa) = 0(0)\n  signed 8 1(1) >> -5(fffffffb) = 0(0)\n  signed 8 1(1) >> -4(fffffffc) = 0(0)\n  signed 8 1(1) >> -3(fffffffd) = 0(0)\n  signed 8 1(1) >> -2(fffffffe) = 0(0)\n  signed 8 1(1) >> -1(ffffffff) = 0(0)\n  signed 8 1(1) >> 0(0) = 1(1)\n  signed 8 1(1) >> 1(1) = 0(0)\n  signed 8 1(1) >> 2(2) = 0(0)\n  signed 8 1(1) >> 3(3) = 0(0)\n  signed 8 1(1) >> 4(4) = 0(0)\n  signed 8 1(1) >> 5(5) = 0(0)\n  signed 8 1(1) >> 6(6) = 0(0)\n  signed 8 1(1) >> 7(7) = 0(0)\n  signed 8 1(1) >> 8(8) = 0(0)\n  signed 8 1(1) >> 9(9) = 0(0)\n  signed 8 1(1) >> 10(a) = 0(0)\n  signed 8 1(1) >> 11(b) = 0(0)\n  signed 8 1(1) >> 12(c) = 0(0)\n  signed 8 1(1) >> 13(d) = 0(0)\n  signed 8 1(1) >> 14(e) = 0(0)\n  signed 8 1(1) >> 15(f) = 0(0)\n  signed 8 1(1) >> 16(10) = 0(0)\n  signed 8 1(1) >> 17(11) = 0(0)\n  signed 8 1(1) >> 18(12) = 0(0)\n  signed 8 1(1) >> 19(13) = 0(0)\n  signed 8 1(1) >> 20(14) = 0(0)\n  signed 8 1(1) >> 21(15) = 0(0)\n  signed 8 1(1) >> 22(16) = 0(0)\n  signed 8 1(1) >> 23(17) = 0(0)\n  signed 8 1(1) >> 24(18) = 0(0)\n  signed 8 1(1) >> 25(19) = 0(0)\n  signed 8 1(1) >> 26(1a) = 0(0)\n  signed 8 1(1) >> 27(1b) = 0(0)\n  signed 8 1(1) >> 28(1c) = 0(0)\n  signed 8 1(1) >> 29(1d) = 0(0)\n  signed 8 1(1) >> 30(1e) = 0(0)\n  signed 8 1(1) >> 31(1f) = 0(0)\n  signed 8 1(1) >> 32(20) = 1(1)\n  signed 8 1(1) >> 33(21) = 0(0)\n  signed 8 1(1) >> 34(22) = 0(0)\n  signed 8 1(1) >> 35(23) = 0(0)\n  signed 8 1(1) >> 36(24) = 0(0)\n  signed 8 1(1) >> 37(25) = 0(0)\n  signed 8 1(1) >> 38(26) = 0(0)\n  signed 8 1(1) >> 39(27) = 0(0)\n  signed 8 1(1) >> 40(28) = 0(0)\n  signed 8 1(1) >> 41(29) = 0(0)\n  signed 8 1(1) >> 42(2a) = 0(0)\n  signed 8 1(1) >> 43(2b) = 0(0)\n  signed 8 1(1) >> 44(2c) = 0(0)\n  signed 8 1(1) >> 45(2d) = 0(0)\n  signed 8 1(1) >> 46(2e) = 0(0)\n  signed 8 1(1) >> 47(2f) = 0(0)\n  signed 8 1(1) >> 48(30) = 0(0)\n  signed 8 1(1) >> 49(31) = 0(0)\n  signed 8 1(1) >> 50(32) = 0(0)\n  signed 8 1(1) >> 51(33) = 0(0)\n  signed 8 1(1) >> 52(34) = 0(0)\n  signed 8 1(1) >> 53(35) = 0(0)\n  signed 8 1(1) >> 54(36) = 0(0)\n  signed 8 1(1) >> 55(37) = 0(0)\n  signed 8 1(1) >> 56(38) = 0(0)\n  signed 8 1(1) >> 57(39) = 0(0)\n  signed 8 1(1) >> 58(3a) = 0(0)\n  signed 8 1(1) >> 59(3b) = 0(0)\n  signed 8 1(1) >> 60(3c) = 0(0)\n  signed 8 1(1) >> 61(3d) = 0(0)\n  signed 8 1(1) >> 62(3e) = 0(0)\n  signed 8 1(1) >> 63(3f) = 0(0)\n  signed 8 1(1) >> 64(40) = 1(1)\n  signed 8 1(1) >> 65(41) = 0(0)\n  signed 8 1(1) >> 66(42) = 0(0)\n  signed 8 1(1) >> 67(43) = 0(0)\n  signed 8 1(1) >> 68(44) = 0(0)\n  signed 8 1(1) >> 69(45) = 0(0)\n  signed 8 1(1) >> 70(46) = 0(0)\n  signed 8 1(1) >> 71(47) = 0(0)\n  signed 8 1(1) >> 72(48) = 0(0)\n  signed 8 1(1) >> 73(49) = 0(0)\n  signed 8 1(1) >> 74(4a) = 0(0)\n  signed 8 1(1) >> 75(4b) = 0(0)\n  signed 8 1(1) >> 76(4c) = 0(0)\n  signed 8 1(1) >> 77(4d) = 0(0)\n  signed 8 1(1) >> 78(4e) = 0(0)\n  signed 8 1(1) >> 79(4f) = 0(0)\n  signed 8 1(1) >> 80(50) = 0(0)\n  signed 8 1(1) >> 81(51) = 0(0)\n  signed 8 1(1) >> 82(52) = 0(0)\n  signed 8 1(1) >> 83(53) = 0(0)\n  signed 8 1(1) >> 84(54) = 0(0)\n  signed 8 1(1) >> 85(55) = 0(0)\n  signed 8 1(1) >> 86(56) = 0(0)\n  signed 8 1(1) >> 87(57) = 0(0)\n  signed 8 1(1) >> 88(58) = 0(0)\n  signed 8 1(1) >> 89(59) = 0(0)\n  signed 8 1(1) >> 90(5a) = 0(0)\n  signed 8 1(1) >> 91(5b) = 0(0)\n  signed 8 1(1) >> 92(5c) = 0(0)\n  signed 8 1(1) >> 93(5d) = 0(0)\n  signed 8 1(1) >> 94(5e) = 0(0)\n  signed 8 1(1) >> 95(5f) = 0(0)\n  signed 8 1(1) >> 96(60) = 1(1)\n  signed 8 1(1) >> 97(61) = 0(0)\n  signed 8 1(1) >> 98(62) = 0(0)\n  signed 8 1(1) >> 99(63) = 0(0)\n  signed 8 1(1) >> 100(64) = 0(0)\n  signed 8 1(1) >> 101(65) = 0(0)\n  signed 8 1(1) >> 102(66) = 0(0)\n  signed 8 1(1) >> 103(67) = 0(0)\n  signed 8 1(1) >> 104(68) = 0(0)\n  signed 8 1(1) >> 105(69) = 0(0)\n  signed 8 1(1) >> 106(6a) = 0(0)\n  signed 8 1(1) >> 107(6b) = 0(0)\n  signed 8 1(1) >> 108(6c) = 0(0)\n  signed 8 1(1) >> 109(6d) = 0(0)\n  signed 8 1(1) >> 110(6e) = 0(0)\n  signed 8 1(1) >> 111(6f) = 0(0)\n  signed 8 1(1) >> 112(70) = 0(0)\n  signed 8 1(1) >> 113(71) = 0(0)\n  signed 8 1(1) >> 114(72) = 0(0)\n  signed 8 1(1) >> 115(73) = 0(0)\n  signed 8 1(1) >> 116(74) = 0(0)\n  signed 8 1(1) >> 117(75) = 0(0)\n  signed 8 1(1) >> 118(76) = 0(0)\n  signed 8 1(1) >> 119(77) = 0(0)\n  signed 8 1(1) >> 120(78) = 0(0)\n  signed 8 1(1) >> 121(79) = 0(0)\n  signed 8 1(1) >> 122(7a) = 0(0)\n  signed 8 1(1) >> 123(7b) = 0(0)\n  signed 8 1(1) >> 124(7c) = 0(0)\n  signed 8 1(1) >> 125(7d) = 0(0)\n  signed 8 1(1) >> 126(7e) = 0(0)\n  signed 8 1(1) >> 127(7f) = 0(0)\n  signed 8 2(2) >> -128(ffffff80) = 2(2)\n  signed 8 2(2) >> -127(ffffff81) = 1(1)\n  signed 8 2(2) >> -126(ffffff82) = 0(0)\n  signed 8 2(2) >> -125(ffffff83) = 0(0)\n  signed 8 2(2) >> -124(ffffff84) = 0(0)\n  signed 8 2(2) >> -123(ffffff85) = 0(0)\n  signed 8 2(2) >> -122(ffffff86) = 0(0)\n  signed 8 2(2) >> -121(ffffff87) = 0(0)\n  signed 8 2(2) >> -120(ffffff88) = 0(0)\n  signed 8 2(2) >> -119(ffffff89) = 0(0)\n  signed 8 2(2) >> -118(ffffff8a) = 0(0)\n  signed 8 2(2) >> -117(ffffff8b) = 0(0)\n  signed 8 2(2) >> -116(ffffff8c) = 0(0)\n  signed 8 2(2) >> -115(ffffff8d) = 0(0)\n  signed 8 2(2) >> -114(ffffff8e) = 0(0)\n  signed 8 2(2) >> -113(ffffff8f) = 0(0)\n  signed 8 2(2) >> -112(ffffff90) = 0(0)\n  signed 8 2(2) >> -111(ffffff91) = 0(0)\n  signed 8 2(2) >> -110(ffffff92) = 0(0)\n  signed 8 2(2) >> -109(ffffff93) = 0(0)\n  signed 8 2(2) >> -108(ffffff94) = 0(0)\n  signed 8 2(2) >> -107(ffffff95) = 0(0)\n  signed 8 2(2) >> -106(ffffff96) = 0(0)\n  signed 8 2(2) >> -105(ffffff97) = 0(0)\n  signed 8 2(2) >> -104(ffffff98) = 0(0)\n  signed 8 2(2) >> -103(ffffff99) = 0(0)\n  signed 8 2(2) >> -102(ffffff9a) = 0(0)\n  signed 8 2(2) >> -101(ffffff9b) = 0(0)\n  signed 8 2(2) >> -100(ffffff9c) = 0(0)\n  signed 8 2(2) >> -99(ffffff9d) = 0(0)\n  signed 8 2(2) >> -98(ffffff9e) = 0(0)\n  signed 8 2(2) >> -97(ffffff9f) = 0(0)\n  signed 8 2(2) >> -96(ffffffa0) = 2(2)\n  signed 8 2(2) >> -95(ffffffa1) = 1(1)\n  signed 8 2(2) >> -94(ffffffa2) = 0(0)\n  signed 8 2(2) >> -93(ffffffa3) = 0(0)\n  signed 8 2(2) >> -92(ffffffa4) = 0(0)\n  signed 8 2(2) >> -91(ffffffa5) = 0(0)\n  signed 8 2(2) >> -90(ffffffa6) = 0(0)\n  signed 8 2(2) >> -89(ffffffa7) = 0(0)\n  signed 8 2(2) >> -88(ffffffa8) = 0(0)\n  signed 8 2(2) >> -87(ffffffa9) = 0(0)\n  signed 8 2(2) >> -86(ffffffaa) = 0(0)\n  signed 8 2(2) >> -85(ffffffab) = 0(0)\n  signed 8 2(2) >> -84(ffffffac) = 0(0)\n  signed 8 2(2) >> -83(ffffffad) = 0(0)\n  signed 8 2(2) >> -82(ffffffae) = 0(0)\n  signed 8 2(2) >> -81(ffffffaf) = 0(0)\n  signed 8 2(2) >> -80(ffffffb0) = 0(0)\n  signed 8 2(2) >> -79(ffffffb1) = 0(0)\n  signed 8 2(2) >> -78(ffffffb2) = 0(0)\n  signed 8 2(2) >> -77(ffffffb3) = 0(0)\n  signed 8 2(2) >> -76(ffffffb4) = 0(0)\n  signed 8 2(2) >> -75(ffffffb5) = 0(0)\n  signed 8 2(2) >> -74(ffffffb6) = 0(0)\n  signed 8 2(2) >> -73(ffffffb7) = 0(0)\n  signed 8 2(2) >> -72(ffffffb8) = 0(0)\n  signed 8 2(2) >> -71(ffffffb9) = 0(0)\n  signed 8 2(2) >> -70(ffffffba) = 0(0)\n  signed 8 2(2) >> -69(ffffffbb) = 0(0)\n  signed 8 2(2) >> -68(ffffffbc) = 0(0)\n  signed 8 2(2) >> -67(ffffffbd) = 0(0)\n  signed 8 2(2) >> -66(ffffffbe) = 0(0)\n  signed 8 2(2) >> -65(ffffffbf) = 0(0)\n  signed 8 2(2) >> -64(ffffffc0) = 2(2)\n  signed 8 2(2) >> -63(ffffffc1) = 1(1)\n  signed 8 2(2) >> -62(ffffffc2) = 0(0)\n  signed 8 2(2) >> -61(ffffffc3) = 0(0)\n  signed 8 2(2) >> -60(ffffffc4) = 0(0)\n  signed 8 2(2) >> -59(ffffffc5) = 0(0)\n  signed 8 2(2) >> -58(ffffffc6) = 0(0)\n  signed 8 2(2) >> -57(ffffffc7) = 0(0)\n  signed 8 2(2) >> -56(ffffffc8) = 0(0)\n  signed 8 2(2) >> -55(ffffffc9) = 0(0)\n  signed 8 2(2) >> -54(ffffffca) = 0(0)\n  signed 8 2(2) >> -53(ffffffcb) = 0(0)\n  signed 8 2(2) >> -52(ffffffcc) = 0(0)\n  signed 8 2(2) >> -51(ffffffcd) = 0(0)\n  signed 8 2(2) >> -50(ffffffce) = 0(0)\n  signed 8 2(2) >> -49(ffffffcf) = 0(0)\n  signed 8 2(2) >> -48(ffffffd0) = 0(0)\n  signed 8 2(2) >> -47(ffffffd1) = 0(0)\n  signed 8 2(2) >> -46(ffffffd2) = 0(0)\n  signed 8 2(2) >> -45(ffffffd3) = 0(0)\n  signed 8 2(2) >> -44(ffffffd4) = 0(0)\n  signed 8 2(2) >> -43(ffffffd5) = 0(0)\n  signed 8 2(2) >> -42(ffffffd6) = 0(0)\n  signed 8 2(2) >> -41(ffffffd7) = 0(0)\n  signed 8 2(2) >> -40(ffffffd8) = 0(0)\n  signed 8 2(2) >> -39(ffffffd9) = 0(0)\n  signed 8 2(2) >> -38(ffffffda) = 0(0)\n  signed 8 2(2) >> -37(ffffffdb) = 0(0)\n  signed 8 2(2) >> -36(ffffffdc) = 0(0)\n  signed 8 2(2) >> -35(ffffffdd) = 0(0)\n  signed 8 2(2) >> -34(ffffffde) = 0(0)\n  signed 8 2(2) >> -33(ffffffdf) = 0(0)\n  signed 8 2(2) >> -32(ffffffe0) = 2(2)\n  signed 8 2(2) >> -31(ffffffe1) = 1(1)\n  signed 8 2(2) >> -30(ffffffe2) = 0(0)\n  signed 8 2(2) >> -29(ffffffe3) = 0(0)\n  signed 8 2(2) >> -28(ffffffe4) = 0(0)\n  signed 8 2(2) >> -27(ffffffe5) = 0(0)\n  signed 8 2(2) >> -26(ffffffe6) = 0(0)\n  signed 8 2(2) >> -25(ffffffe7) = 0(0)\n  signed 8 2(2) >> -24(ffffffe8) = 0(0)\n  signed 8 2(2) >> -23(ffffffe9) = 0(0)\n  signed 8 2(2) >> -22(ffffffea) = 0(0)\n  signed 8 2(2) >> -21(ffffffeb) = 0(0)\n  signed 8 2(2) >> -20(ffffffec) = 0(0)\n  signed 8 2(2) >> -19(ffffffed) = 0(0)\n  signed 8 2(2) >> -18(ffffffee) = 0(0)\n  signed 8 2(2) >> -17(ffffffef) = 0(0)\n  signed 8 2(2) >> -16(fffffff0) = 0(0)\n  signed 8 2(2) >> -15(fffffff1) = 0(0)\n  signed 8 2(2) >> -14(fffffff2) = 0(0)\n  signed 8 2(2) >> -13(fffffff3) = 0(0)\n  signed 8 2(2) >> -12(fffffff4) = 0(0)\n  signed 8 2(2) >> -11(fffffff5) = 0(0)\n  signed 8 2(2) >> -10(fffffff6) = 0(0)\n  signed 8 2(2) >> -9(fffffff7) = 0(0)\n  signed 8 2(2) >> -8(fffffff8) = 0(0)\n  signed 8 2(2) >> -7(fffffff9) = 0(0)\n  signed 8 2(2) >> -6(fffffffa) = 0(0)\n  signed 8 2(2) >> -5(fffffffb) = 0(0)\n  signed 8 2(2) >> -4(fffffffc) = 0(0)\n  signed 8 2(2) >> -3(fffffffd) = 0(0)\n  signed 8 2(2) >> -2(fffffffe) = 0(0)\n  signed 8 2(2) >> -1(ffffffff) = 0(0)\n  signed 8 2(2) >> 0(0) = 2(2)\n  signed 8 2(2) >> 1(1) = 1(1)\n  signed 8 2(2) >> 2(2) = 0(0)\n  signed 8 2(2) >> 3(3) = 0(0)\n  signed 8 2(2) >> 4(4) = 0(0)\n  signed 8 2(2) >> 5(5) = 0(0)\n  signed 8 2(2) >> 6(6) = 0(0)\n  signed 8 2(2) >> 7(7) = 0(0)\n  signed 8 2(2) >> 8(8) = 0(0)\n  signed 8 2(2) >> 9(9) = 0(0)\n  signed 8 2(2) >> 10(a) = 0(0)\n  signed 8 2(2) >> 11(b) = 0(0)\n  signed 8 2(2) >> 12(c) = 0(0)\n  signed 8 2(2) >> 13(d) = 0(0)\n  signed 8 2(2) >> 14(e) = 0(0)\n  signed 8 2(2) >> 15(f) = 0(0)\n  signed 8 2(2) >> 16(10) = 0(0)\n  signed 8 2(2) >> 17(11) = 0(0)\n  signed 8 2(2) >> 18(12) = 0(0)\n  signed 8 2(2) >> 19(13) = 0(0)\n  signed 8 2(2) >> 20(14) = 0(0)\n  signed 8 2(2) >> 21(15) = 0(0)\n  signed 8 2(2) >> 22(16) = 0(0)\n  signed 8 2(2) >> 23(17) = 0(0)\n  signed 8 2(2) >> 24(18) = 0(0)\n  signed 8 2(2) >> 25(19) = 0(0)\n  signed 8 2(2) >> 26(1a) = 0(0)\n  signed 8 2(2) >> 27(1b) = 0(0)\n  signed 8 2(2) >> 28(1c) = 0(0)\n  signed 8 2(2) >> 29(1d) = 0(0)\n  signed 8 2(2) >> 30(1e) = 0(0)\n  signed 8 2(2) >> 31(1f) = 0(0)\n  signed 8 2(2) >> 32(20) = 2(2)\n  signed 8 2(2) >> 33(21) = 1(1)\n  signed 8 2(2) >> 34(22) = 0(0)\n  signed 8 2(2) >> 35(23) = 0(0)\n  signed 8 2(2) >> 36(24) = 0(0)\n  signed 8 2(2) >> 37(25) = 0(0)\n  signed 8 2(2) >> 38(26) = 0(0)\n  signed 8 2(2) >> 39(27) = 0(0)\n  signed 8 2(2) >> 40(28) = 0(0)\n  signed 8 2(2) >> 41(29) = 0(0)\n  signed 8 2(2) >> 42(2a) = 0(0)\n  signed 8 2(2) >> 43(2b) = 0(0)\n  signed 8 2(2) >> 44(2c) = 0(0)\n  signed 8 2(2) >> 45(2d) = 0(0)\n  signed 8 2(2) >> 46(2e) = 0(0)\n  signed 8 2(2) >> 47(2f) = 0(0)\n  signed 8 2(2) >> 48(30) = 0(0)\n  signed 8 2(2) >> 49(31) = 0(0)\n  signed 8 2(2) >> 50(32) = 0(0)\n  signed 8 2(2) >> 51(33) = 0(0)\n  signed 8 2(2) >> 52(34) = 0(0)\n  signed 8 2(2) >> 53(35) = 0(0)\n  signed 8 2(2) >> 54(36) = 0(0)\n  signed 8 2(2) >> 55(37) = 0(0)\n  signed 8 2(2) >> 56(38) = 0(0)\n  signed 8 2(2) >> 57(39) = 0(0)\n  signed 8 2(2) >> 58(3a) = 0(0)\n  signed 8 2(2) >> 59(3b) = 0(0)\n  signed 8 2(2) >> 60(3c) = 0(0)\n  signed 8 2(2) >> 61(3d) = 0(0)\n  signed 8 2(2) >> 62(3e) = 0(0)\n  signed 8 2(2) >> 63(3f) = 0(0)\n  signed 8 2(2) >> 64(40) = 2(2)\n  signed 8 2(2) >> 65(41) = 1(1)\n  signed 8 2(2) >> 66(42) = 0(0)\n  signed 8 2(2) >> 67(43) = 0(0)\n  signed 8 2(2) >> 68(44) = 0(0)\n  signed 8 2(2) >> 69(45) = 0(0)\n  signed 8 2(2) >> 70(46) = 0(0)\n  signed 8 2(2) >> 71(47) = 0(0)\n  signed 8 2(2) >> 72(48) = 0(0)\n  signed 8 2(2) >> 73(49) = 0(0)\n  signed 8 2(2) >> 74(4a) = 0(0)\n  signed 8 2(2) >> 75(4b) = 0(0)\n  signed 8 2(2) >> 76(4c) = 0(0)\n  signed 8 2(2) >> 77(4d) = 0(0)\n  signed 8 2(2) >> 78(4e) = 0(0)\n  signed 8 2(2) >> 79(4f) = 0(0)\n  signed 8 2(2) >> 80(50) = 0(0)\n  signed 8 2(2) >> 81(51) = 0(0)\n  signed 8 2(2) >> 82(52) = 0(0)\n  signed 8 2(2) >> 83(53) = 0(0)\n  signed 8 2(2) >> 84(54) = 0(0)\n  signed 8 2(2) >> 85(55) = 0(0)\n  signed 8 2(2) >> 86(56) = 0(0)\n  signed 8 2(2) >> 87(57) = 0(0)\n  signed 8 2(2) >> 88(58) = 0(0)\n  signed 8 2(2) >> 89(59) = 0(0)\n  signed 8 2(2) >> 90(5a) = 0(0)\n  signed 8 2(2) >> 91(5b) = 0(0)\n  signed 8 2(2) >> 92(5c) = 0(0)\n  signed 8 2(2) >> 93(5d) = 0(0)\n  signed 8 2(2) >> 94(5e) = 0(0)\n  signed 8 2(2) >> 95(5f) = 0(0)\n  signed 8 2(2) >> 96(60) = 2(2)\n  signed 8 2(2) >> 97(61) = 1(1)\n  signed 8 2(2) >> 98(62) = 0(0)\n  signed 8 2(2) >> 99(63) = 0(0)\n  signed 8 2(2) >> 100(64) = 0(0)\n  signed 8 2(2) >> 101(65) = 0(0)\n  signed 8 2(2) >> 102(66) = 0(0)\n  signed 8 2(2) >> 103(67) = 0(0)\n  signed 8 2(2) >> 104(68) = 0(0)\n  signed 8 2(2) >> 105(69) = 0(0)\n  signed 8 2(2) >> 106(6a) = 0(0)\n  signed 8 2(2) >> 107(6b) = 0(0)\n  signed 8 2(2) >> 108(6c) = 0(0)\n  signed 8 2(2) >> 109(6d) = 0(0)\n  signed 8 2(2) >> 110(6e) = 0(0)\n  signed 8 2(2) >> 111(6f) = 0(0)\n  signed 8 2(2) >> 112(70) = 0(0)\n  signed 8 2(2) >> 113(71) = 0(0)\n  signed 8 2(2) >> 114(72) = 0(0)\n  signed 8 2(2) >> 115(73) = 0(0)\n  signed 8 2(2) >> 116(74) = 0(0)\n  signed 8 2(2) >> 117(75) = 0(0)\n  signed 8 2(2) >> 118(76) = 0(0)\n  signed 8 2(2) >> 119(77) = 0(0)\n  signed 8 2(2) >> 120(78) = 0(0)\n  signed 8 2(2) >> 121(79) = 0(0)\n  signed 8 2(2) >> 122(7a) = 0(0)\n  signed 8 2(2) >> 123(7b) = 0(0)\n  signed 8 2(2) >> 124(7c) = 0(0)\n  signed 8 2(2) >> 125(7d) = 0(0)\n  signed 8 2(2) >> 126(7e) = 0(0)\n  signed 8 2(2) >> 127(7f) = 0(0)\n  signed 8 3(3) >> -128(ffffff80) = 3(3)\n  signed 8 3(3) >> -127(ffffff81) = 1(1)\n  signed 8 3(3) >> -126(ffffff82) = 0(0)\n  signed 8 3(3) >> -125(ffffff83) = 0(0)\n  signed 8 3(3) >> -124(ffffff84) = 0(0)\n  signed 8 3(3) >> -123(ffffff85) = 0(0)\n  signed 8 3(3) >> -122(ffffff86) = 0(0)\n  signed 8 3(3) >> -121(ffffff87) = 0(0)\n  signed 8 3(3) >> -120(ffffff88) = 0(0)\n  signed 8 3(3) >> -119(ffffff89) = 0(0)\n  signed 8 3(3) >> -118(ffffff8a) = 0(0)\n  signed 8 3(3) >> -117(ffffff8b) = 0(0)\n  signed 8 3(3) >> -116(ffffff8c) = 0(0)\n  signed 8 3(3) >> -115(ffffff8d) = 0(0)\n  signed 8 3(3) >> -114(ffffff8e) = 0(0)\n  signed 8 3(3) >> -113(ffffff8f) = 0(0)\n  signed 8 3(3) >> -112(ffffff90) = 0(0)\n  signed 8 3(3) >> -111(ffffff91) = 0(0)\n  signed 8 3(3) >> -110(ffffff92) = 0(0)\n  signed 8 3(3) >> -109(ffffff93) = 0(0)\n  signed 8 3(3) >> -108(ffffff94) = 0(0)\n  signed 8 3(3) >> -107(ffffff95) = 0(0)\n  signed 8 3(3) >> -106(ffffff96) = 0(0)\n  signed 8 3(3) >> -105(ffffff97) = 0(0)\n  signed 8 3(3) >> -104(ffffff98) = 0(0)\n  signed 8 3(3) >> -103(ffffff99) = 0(0)\n  signed 8 3(3) >> -102(ffffff9a) = 0(0)\n  signed 8 3(3) >> -101(ffffff9b) = 0(0)\n  signed 8 3(3) >> -100(ffffff9c) = 0(0)\n  signed 8 3(3) >> -99(ffffff9d) = 0(0)\n  signed 8 3(3) >> -98(ffffff9e) = 0(0)\n  signed 8 3(3) >> -97(ffffff9f) = 0(0)\n  signed 8 3(3) >> -96(ffffffa0) = 3(3)\n  signed 8 3(3) >> -95(ffffffa1) = 1(1)\n  signed 8 3(3) >> -94(ffffffa2) = 0(0)\n  signed 8 3(3) >> -93(ffffffa3) = 0(0)\n  signed 8 3(3) >> -92(ffffffa4) = 0(0)\n  signed 8 3(3) >> -91(ffffffa5) = 0(0)\n  signed 8 3(3) >> -90(ffffffa6) = 0(0)\n  signed 8 3(3) >> -89(ffffffa7) = 0(0)\n  signed 8 3(3) >> -88(ffffffa8) = 0(0)\n  signed 8 3(3) >> -87(ffffffa9) = 0(0)\n  signed 8 3(3) >> -86(ffffffaa) = 0(0)\n  signed 8 3(3) >> -85(ffffffab) = 0(0)\n  signed 8 3(3) >> -84(ffffffac) = 0(0)\n  signed 8 3(3) >> -83(ffffffad) = 0(0)\n  signed 8 3(3) >> -82(ffffffae) = 0(0)\n  signed 8 3(3) >> -81(ffffffaf) = 0(0)\n  signed 8 3(3) >> -80(ffffffb0) = 0(0)\n  signed 8 3(3) >> -79(ffffffb1) = 0(0)\n  signed 8 3(3) >> -78(ffffffb2) = 0(0)\n  signed 8 3(3) >> -77(ffffffb3) = 0(0)\n  signed 8 3(3) >> -76(ffffffb4) = 0(0)\n  signed 8 3(3) >> -75(ffffffb5) = 0(0)\n  signed 8 3(3) >> -74(ffffffb6) = 0(0)\n  signed 8 3(3) >> -73(ffffffb7) = 0(0)\n  signed 8 3(3) >> -72(ffffffb8) = 0(0)\n  signed 8 3(3) >> -71(ffffffb9) = 0(0)\n  signed 8 3(3) >> -70(ffffffba) = 0(0)\n  signed 8 3(3) >> -69(ffffffbb) = 0(0)\n  signed 8 3(3) >> -68(ffffffbc) = 0(0)\n  signed 8 3(3) >> -67(ffffffbd) = 0(0)\n  signed 8 3(3) >> -66(ffffffbe) = 0(0)\n  signed 8 3(3) >> -65(ffffffbf) = 0(0)\n  signed 8 3(3) >> -64(ffffffc0) = 3(3)\n  signed 8 3(3) >> -63(ffffffc1) = 1(1)\n  signed 8 3(3) >> -62(ffffffc2) = 0(0)\n  signed 8 3(3) >> -61(ffffffc3) = 0(0)\n  signed 8 3(3) >> -60(ffffffc4) = 0(0)\n  signed 8 3(3) >> -59(ffffffc5) = 0(0)\n  signed 8 3(3) >> -58(ffffffc6) = 0(0)\n  signed 8 3(3) >> -57(ffffffc7) = 0(0)\n  signed 8 3(3) >> -56(ffffffc8) = 0(0)\n  signed 8 3(3) >> -55(ffffffc9) = 0(0)\n  signed 8 3(3) >> -54(ffffffca) = 0(0)\n  signed 8 3(3) >> -53(ffffffcb) = 0(0)\n  signed 8 3(3) >> -52(ffffffcc) = 0(0)\n  signed 8 3(3) >> -51(ffffffcd) = 0(0)\n  signed 8 3(3) >> -50(ffffffce) = 0(0)\n  signed 8 3(3) >> -49(ffffffcf) = 0(0)\n  signed 8 3(3) >> -48(ffffffd0) = 0(0)\n  signed 8 3(3) >> -47(ffffffd1) = 0(0)\n  signed 8 3(3) >> -46(ffffffd2) = 0(0)\n  signed 8 3(3) >> -45(ffffffd3) = 0(0)\n  signed 8 3(3) >> -44(ffffffd4) = 0(0)\n  signed 8 3(3) >> -43(ffffffd5) = 0(0)\n  signed 8 3(3) >> -42(ffffffd6) = 0(0)\n  signed 8 3(3) >> -41(ffffffd7) = 0(0)\n  signed 8 3(3) >> -40(ffffffd8) = 0(0)\n  signed 8 3(3) >> -39(ffffffd9) = 0(0)\n  signed 8 3(3) >> -38(ffffffda) = 0(0)\n  signed 8 3(3) >> -37(ffffffdb) = 0(0)\n  signed 8 3(3) >> -36(ffffffdc) = 0(0)\n  signed 8 3(3) >> -35(ffffffdd) = 0(0)\n  signed 8 3(3) >> -34(ffffffde) = 0(0)\n  signed 8 3(3) >> -33(ffffffdf) = 0(0)\n  signed 8 3(3) >> -32(ffffffe0) = 3(3)\n  signed 8 3(3) >> -31(ffffffe1) = 1(1)\n  signed 8 3(3) >> -30(ffffffe2) = 0(0)\n  signed 8 3(3) >> -29(ffffffe3) = 0(0)\n  signed 8 3(3) >> -28(ffffffe4) = 0(0)\n  signed 8 3(3) >> -27(ffffffe5) = 0(0)\n  signed 8 3(3) >> -26(ffffffe6) = 0(0)\n  signed 8 3(3) >> -25(ffffffe7) = 0(0)\n  signed 8 3(3) >> -24(ffffffe8) = 0(0)\n  signed 8 3(3) >> -23(ffffffe9) = 0(0)\n  signed 8 3(3) >> -22(ffffffea) = 0(0)\n  signed 8 3(3) >> -21(ffffffeb) = 0(0)\n  signed 8 3(3) >> -20(ffffffec) = 0(0)\n  signed 8 3(3) >> -19(ffffffed) = 0(0)\n  signed 8 3(3) >> -18(ffffffee) = 0(0)\n  signed 8 3(3) >> -17(ffffffef) = 0(0)\n  signed 8 3(3) >> -16(fffffff0) = 0(0)\n  signed 8 3(3) >> -15(fffffff1) = 0(0)\n  signed 8 3(3) >> -14(fffffff2) = 0(0)\n  signed 8 3(3) >> -13(fffffff3) = 0(0)\n  signed 8 3(3) >> -12(fffffff4) = 0(0)\n  signed 8 3(3) >> -11(fffffff5) = 0(0)\n  signed 8 3(3) >> -10(fffffff6) = 0(0)\n  signed 8 3(3) >> -9(fffffff7) = 0(0)\n  signed 8 3(3) >> -8(fffffff8) = 0(0)\n  signed 8 3(3) >> -7(fffffff9) = 0(0)\n  signed 8 3(3) >> -6(fffffffa) = 0(0)\n  signed 8 3(3) >> -5(fffffffb) = 0(0)\n  signed 8 3(3) >> -4(fffffffc) = 0(0)\n  signed 8 3(3) >> -3(fffffffd) = 0(0)\n  signed 8 3(3) >> -2(fffffffe) = 0(0)\n  signed 8 3(3) >> -1(ffffffff) = 0(0)\n  signed 8 3(3) >> 0(0) = 3(3)\n  signed 8 3(3) >> 1(1) = 1(1)\n  signed 8 3(3) >> 2(2) = 0(0)\n  signed 8 3(3) >> 3(3) = 0(0)\n  signed 8 3(3) >> 4(4) = 0(0)\n  signed 8 3(3) >> 5(5) = 0(0)\n  signed 8 3(3) >> 6(6) = 0(0)\n  signed 8 3(3) >> 7(7) = 0(0)\n  signed 8 3(3) >> 8(8) = 0(0)\n  signed 8 3(3) >> 9(9) = 0(0)\n  signed 8 3(3) >> 10(a) = 0(0)\n  signed 8 3(3) >> 11(b) = 0(0)\n  signed 8 3(3) >> 12(c) = 0(0)\n  signed 8 3(3) >> 13(d) = 0(0)\n  signed 8 3(3) >> 14(e) = 0(0)\n  signed 8 3(3) >> 15(f) = 0(0)\n  signed 8 3(3) >> 16(10) = 0(0)\n  signed 8 3(3) >> 17(11) = 0(0)\n  signed 8 3(3) >> 18(12) = 0(0)\n  signed 8 3(3) >> 19(13) = 0(0)\n  signed 8 3(3) >> 20(14) = 0(0)\n  signed 8 3(3) >> 21(15) = 0(0)\n  signed 8 3(3) >> 22(16) = 0(0)\n  signed 8 3(3) >> 23(17) = 0(0)\n  signed 8 3(3) >> 24(18) = 0(0)\n  signed 8 3(3) >> 25(19) = 0(0)\n  signed 8 3(3) >> 26(1a) = 0(0)\n  signed 8 3(3) >> 27(1b) = 0(0)\n  signed 8 3(3) >> 28(1c) = 0(0)\n  signed 8 3(3) >> 29(1d) = 0(0)\n  signed 8 3(3) >> 30(1e) = 0(0)\n  signed 8 3(3) >> 31(1f) = 0(0)\n  signed 8 3(3) >> 32(20) = 3(3)\n  signed 8 3(3) >> 33(21) = 1(1)\n  signed 8 3(3) >> 34(22) = 0(0)\n  signed 8 3(3) >> 35(23) = 0(0)\n  signed 8 3(3) >> 36(24) = 0(0)\n  signed 8 3(3) >> 37(25) = 0(0)\n  signed 8 3(3) >> 38(26) = 0(0)\n  signed 8 3(3) >> 39(27) = 0(0)\n  signed 8 3(3) >> 40(28) = 0(0)\n  signed 8 3(3) >> 41(29) = 0(0)\n  signed 8 3(3) >> 42(2a) = 0(0)\n  signed 8 3(3) >> 43(2b) = 0(0)\n  signed 8 3(3) >> 44(2c) = 0(0)\n  signed 8 3(3) >> 45(2d) = 0(0)\n  signed 8 3(3) >> 46(2e) = 0(0)\n  signed 8 3(3) >> 47(2f) = 0(0)\n  signed 8 3(3) >> 48(30) = 0(0)\n  signed 8 3(3) >> 49(31) = 0(0)\n  signed 8 3(3) >> 50(32) = 0(0)\n  signed 8 3(3) >> 51(33) = 0(0)\n  signed 8 3(3) >> 52(34) = 0(0)\n  signed 8 3(3) >> 53(35) = 0(0)\n  signed 8 3(3) >> 54(36) = 0(0)\n  signed 8 3(3) >> 55(37) = 0(0)\n  signed 8 3(3) >> 56(38) = 0(0)\n  signed 8 3(3) >> 57(39) = 0(0)\n  signed 8 3(3) >> 58(3a) = 0(0)\n  signed 8 3(3) >> 59(3b) = 0(0)\n  signed 8 3(3) >> 60(3c) = 0(0)\n  signed 8 3(3) >> 61(3d) = 0(0)\n  signed 8 3(3) >> 62(3e) = 0(0)\n  signed 8 3(3) >> 63(3f) = 0(0)\n  signed 8 3(3) >> 64(40) = 3(3)\n  signed 8 3(3) >> 65(41) = 1(1)\n  signed 8 3(3) >> 66(42) = 0(0)\n  signed 8 3(3) >> 67(43) = 0(0)\n  signed 8 3(3) >> 68(44) = 0(0)\n  signed 8 3(3) >> 69(45) = 0(0)\n  signed 8 3(3) >> 70(46) = 0(0)\n  signed 8 3(3) >> 71(47) = 0(0)\n  signed 8 3(3) >> 72(48) = 0(0)\n  signed 8 3(3) >> 73(49) = 0(0)\n  signed 8 3(3) >> 74(4a) = 0(0)\n  signed 8 3(3) >> 75(4b) = 0(0)\n  signed 8 3(3) >> 76(4c) = 0(0)\n  signed 8 3(3) >> 77(4d) = 0(0)\n  signed 8 3(3) >> 78(4e) = 0(0)\n  signed 8 3(3) >> 79(4f) = 0(0)\n  signed 8 3(3) >> 80(50) = 0(0)\n  signed 8 3(3) >> 81(51) = 0(0)\n  signed 8 3(3) >> 82(52) = 0(0)\n  signed 8 3(3) >> 83(53) = 0(0)\n  signed 8 3(3) >> 84(54) = 0(0)\n  signed 8 3(3) >> 85(55) = 0(0)\n  signed 8 3(3) >> 86(56) = 0(0)\n  signed 8 3(3) >> 87(57) = 0(0)\n  signed 8 3(3) >> 88(58) = 0(0)\n  signed 8 3(3) >> 89(59) = 0(0)\n  signed 8 3(3) >> 90(5a) = 0(0)\n  signed 8 3(3) >> 91(5b) = 0(0)\n  signed 8 3(3) >> 92(5c) = 0(0)\n  signed 8 3(3) >> 93(5d) = 0(0)\n  signed 8 3(3) >> 94(5e) = 0(0)\n  signed 8 3(3) >> 95(5f) = 0(0)\n  signed 8 3(3) >> 96(60) = 3(3)\n  signed 8 3(3) >> 97(61) = 1(1)\n  signed 8 3(3) >> 98(62) = 0(0)\n  signed 8 3(3) >> 99(63) = 0(0)\n  signed 8 3(3) >> 100(64) = 0(0)\n  signed 8 3(3) >> 101(65) = 0(0)\n  signed 8 3(3) >> 102(66) = 0(0)\n  signed 8 3(3) >> 103(67) = 0(0)\n  signed 8 3(3) >> 104(68) = 0(0)\n  signed 8 3(3) >> 105(69) = 0(0)\n  signed 8 3(3) >> 106(6a) = 0(0)\n  signed 8 3(3) >> 107(6b) = 0(0)\n  signed 8 3(3) >> 108(6c) = 0(0)\n  signed 8 3(3) >> 109(6d) = 0(0)\n  signed 8 3(3) >> 110(6e) = 0(0)\n  signed 8 3(3) >> 111(6f) = 0(0)\n  signed 8 3(3) >> 112(70) = 0(0)\n  signed 8 3(3) >> 113(71) = 0(0)\n  signed 8 3(3) >> 114(72) = 0(0)\n  signed 8 3(3) >> 115(73) = 0(0)\n  signed 8 3(3) >> 116(74) = 0(0)\n  signed 8 3(3) >> 117(75) = 0(0)\n  signed 8 3(3) >> 118(76) = 0(0)\n  signed 8 3(3) >> 119(77) = 0(0)\n  signed 8 3(3) >> 120(78) = 0(0)\n  signed 8 3(3) >> 121(79) = 0(0)\n  signed 8 3(3) >> 122(7a) = 0(0)\n  signed 8 3(3) >> 123(7b) = 0(0)\n  signed 8 3(3) >> 124(7c) = 0(0)\n  signed 8 3(3) >> 125(7d) = 0(0)\n  signed 8 3(3) >> 126(7e) = 0(0)\n  signed 8 3(3) >> 127(7f) = 0(0)\n  signed 8 4(4) >> -128(ffffff80) = 4(4)\n  signed 8 4(4) >> -127(ffffff81) = 2(2)\n  signed 8 4(4) >> -126(ffffff82) = 1(1)\n  signed 8 4(4) >> -125(ffffff83) = 0(0)\n  signed 8 4(4) >> -124(ffffff84) = 0(0)\n  signed 8 4(4) >> -123(ffffff85) = 0(0)\n  signed 8 4(4) >> -122(ffffff86) = 0(0)\n  signed 8 4(4) >> -121(ffffff87) = 0(0)\n  signed 8 4(4) >> -120(ffffff88) = 0(0)\n  signed 8 4(4) >> -119(ffffff89) = 0(0)\n  signed 8 4(4) >> -118(ffffff8a) = 0(0)\n  signed 8 4(4) >> -117(ffffff8b) = 0(0)\n  signed 8 4(4) >> -116(ffffff8c) = 0(0)\n  signed 8 4(4) >> -115(ffffff8d) = 0(0)\n  signed 8 4(4) >> -114(ffffff8e) = 0(0)\n  signed 8 4(4) >> -113(ffffff8f) = 0(0)\n  signed 8 4(4) >> -112(ffffff90) = 0(0)\n  signed 8 4(4) >> -111(ffffff91) = 0(0)\n  signed 8 4(4) >> -110(ffffff92) = 0(0)\n  signed 8 4(4) >> -109(ffffff93) = 0(0)\n  signed 8 4(4) >> -108(ffffff94) = 0(0)\n  signed 8 4(4) >> -107(ffffff95) = 0(0)\n  signed 8 4(4) >> -106(ffffff96) = 0(0)\n  signed 8 4(4) >> -105(ffffff97) = 0(0)\n  signed 8 4(4) >> -104(ffffff98) = 0(0)\n  signed 8 4(4) >> -103(ffffff99) = 0(0)\n  signed 8 4(4) >> -102(ffffff9a) = 0(0)\n  signed 8 4(4) >> -101(ffffff9b) = 0(0)\n  signed 8 4(4) >> -100(ffffff9c) = 0(0)\n  signed 8 4(4) >> -99(ffffff9d) = 0(0)\n  signed 8 4(4) >> -98(ffffff9e) = 0(0)\n  signed 8 4(4) >> -97(ffffff9f) = 0(0)\n  signed 8 4(4) >> -96(ffffffa0) = 4(4)\n  signed 8 4(4) >> -95(ffffffa1) = 2(2)\n  signed 8 4(4) >> -94(ffffffa2) = 1(1)\n  signed 8 4(4) >> -93(ffffffa3) = 0(0)\n  signed 8 4(4) >> -92(ffffffa4) = 0(0)\n  signed 8 4(4) >> -91(ffffffa5) = 0(0)\n  signed 8 4(4) >> -90(ffffffa6) = 0(0)\n  signed 8 4(4) >> -89(ffffffa7) = 0(0)\n  signed 8 4(4) >> -88(ffffffa8) = 0(0)\n  signed 8 4(4) >> -87(ffffffa9) = 0(0)\n  signed 8 4(4) >> -86(ffffffaa) = 0(0)\n  signed 8 4(4) >> -85(ffffffab) = 0(0)\n  signed 8 4(4) >> -84(ffffffac) = 0(0)\n  signed 8 4(4) >> -83(ffffffad) = 0(0)\n  signed 8 4(4) >> -82(ffffffae) = 0(0)\n  signed 8 4(4) >> -81(ffffffaf) = 0(0)\n  signed 8 4(4) >> -80(ffffffb0) = 0(0)\n  signed 8 4(4) >> -79(ffffffb1) = 0(0)\n  signed 8 4(4) >> -78(ffffffb2) = 0(0)\n  signed 8 4(4) >> -77(ffffffb3) = 0(0)\n  signed 8 4(4) >> -76(ffffffb4) = 0(0)\n  signed 8 4(4) >> -75(ffffffb5) = 0(0)\n  signed 8 4(4) >> -74(ffffffb6) = 0(0)\n  signed 8 4(4) >> -73(ffffffb7) = 0(0)\n  signed 8 4(4) >> -72(ffffffb8) = 0(0)\n  signed 8 4(4) >> -71(ffffffb9) = 0(0)\n  signed 8 4(4) >> -70(ffffffba) = 0(0)\n  signed 8 4(4) >> -69(ffffffbb) = 0(0)\n  signed 8 4(4) >> -68(ffffffbc) = 0(0)\n  signed 8 4(4) >> -67(ffffffbd) = 0(0)\n  signed 8 4(4) >> -66(ffffffbe) = 0(0)\n  signed 8 4(4) >> -65(ffffffbf) = 0(0)\n  signed 8 4(4) >> -64(ffffffc0) = 4(4)\n  signed 8 4(4) >> -63(ffffffc1) = 2(2)\n  signed 8 4(4) >> -62(ffffffc2) = 1(1)\n  signed 8 4(4) >> -61(ffffffc3) = 0(0)\n  signed 8 4(4) >> -60(ffffffc4) = 0(0)\n  signed 8 4(4) >> -59(ffffffc5) = 0(0)\n  signed 8 4(4) >> -58(ffffffc6) = 0(0)\n  signed 8 4(4) >> -57(ffffffc7) = 0(0)\n  signed 8 4(4) >> -56(ffffffc8) = 0(0)\n  signed 8 4(4) >> -55(ffffffc9) = 0(0)\n  signed 8 4(4) >> -54(ffffffca) = 0(0)\n  signed 8 4(4) >> -53(ffffffcb) = 0(0)\n  signed 8 4(4) >> -52(ffffffcc) = 0(0)\n  signed 8 4(4) >> -51(ffffffcd) = 0(0)\n  signed 8 4(4) >> -50(ffffffce) = 0(0)\n  signed 8 4(4) >> -49(ffffffcf) = 0(0)\n  signed 8 4(4) >> -48(ffffffd0) = 0(0)\n  signed 8 4(4) >> -47(ffffffd1) = 0(0)\n  signed 8 4(4) >> -46(ffffffd2) = 0(0)\n  signed 8 4(4) >> -45(ffffffd3) = 0(0)\n  signed 8 4(4) >> -44(ffffffd4) = 0(0)\n  signed 8 4(4) >> -43(ffffffd5) = 0(0)\n  signed 8 4(4) >> -42(ffffffd6) = 0(0)\n  signed 8 4(4) >> -41(ffffffd7) = 0(0)\n  signed 8 4(4) >> -40(ffffffd8) = 0(0)\n  signed 8 4(4) >> -39(ffffffd9) = 0(0)\n  signed 8 4(4) >> -38(ffffffda) = 0(0)\n  signed 8 4(4) >> -37(ffffffdb) = 0(0)\n  signed 8 4(4) >> -36(ffffffdc) = 0(0)\n  signed 8 4(4) >> -35(ffffffdd) = 0(0)\n  signed 8 4(4) >> -34(ffffffde) = 0(0)\n  signed 8 4(4) >> -33(ffffffdf) = 0(0)\n  signed 8 4(4) >> -32(ffffffe0) = 4(4)\n  signed 8 4(4) >> -31(ffffffe1) = 2(2)\n  signed 8 4(4) >> -30(ffffffe2) = 1(1)\n  signed 8 4(4) >> -29(ffffffe3) = 0(0)\n  signed 8 4(4) >> -28(ffffffe4) = 0(0)\n  signed 8 4(4) >> -27(ffffffe5) = 0(0)\n  signed 8 4(4) >> -26(ffffffe6) = 0(0)\n  signed 8 4(4) >> -25(ffffffe7) = 0(0)\n  signed 8 4(4) >> -24(ffffffe8) = 0(0)\n  signed 8 4(4) >> -23(ffffffe9) = 0(0)\n  signed 8 4(4) >> -22(ffffffea) = 0(0)\n  signed 8 4(4) >> -21(ffffffeb) = 0(0)\n  signed 8 4(4) >> -20(ffffffec) = 0(0)\n  signed 8 4(4) >> -19(ffffffed) = 0(0)\n  signed 8 4(4) >> -18(ffffffee) = 0(0)\n  signed 8 4(4) >> -17(ffffffef) = 0(0)\n  signed 8 4(4) >> -16(fffffff0) = 0(0)\n  signed 8 4(4) >> -15(fffffff1) = 0(0)\n  signed 8 4(4) >> -14(fffffff2) = 0(0)\n  signed 8 4(4) >> -13(fffffff3) = 0(0)\n  signed 8 4(4) >> -12(fffffff4) = 0(0)\n  signed 8 4(4) >> -11(fffffff5) = 0(0)\n  signed 8 4(4) >> -10(fffffff6) = 0(0)\n  signed 8 4(4) >> -9(fffffff7) = 0(0)\n  signed 8 4(4) >> -8(fffffff8) = 0(0)\n  signed 8 4(4) >> -7(fffffff9) = 0(0)\n  signed 8 4(4) >> -6(fffffffa) = 0(0)\n  signed 8 4(4) >> -5(fffffffb) = 0(0)\n  signed 8 4(4) >> -4(fffffffc) = 0(0)\n  signed 8 4(4) >> -3(fffffffd) = 0(0)\n  signed 8 4(4) >> -2(fffffffe) = 0(0)\n  signed 8 4(4) >> -1(ffffffff) = 0(0)\n  signed 8 4(4) >> 0(0) = 4(4)\n  signed 8 4(4) >> 1(1) = 2(2)\n  signed 8 4(4) >> 2(2) = 1(1)\n  signed 8 4(4) >> 3(3) = 0(0)\n  signed 8 4(4) >> 4(4) = 0(0)\n  signed 8 4(4) >> 5(5) = 0(0)\n  signed 8 4(4) >> 6(6) = 0(0)\n  signed 8 4(4) >> 7(7) = 0(0)\n  signed 8 4(4) >> 8(8) = 0(0)\n  signed 8 4(4) >> 9(9) = 0(0)\n  signed 8 4(4) >> 10(a) = 0(0)\n  signed 8 4(4) >> 11(b) = 0(0)\n  signed 8 4(4) >> 12(c) = 0(0)\n  signed 8 4(4) >> 13(d) = 0(0)\n  signed 8 4(4) >> 14(e) = 0(0)\n  signed 8 4(4) >> 15(f) = 0(0)\n  signed 8 4(4) >> 16(10) = 0(0)\n  signed 8 4(4) >> 17(11) = 0(0)\n  signed 8 4(4) >> 18(12) = 0(0)\n  signed 8 4(4) >> 19(13) = 0(0)\n  signed 8 4(4) >> 20(14) = 0(0)\n  signed 8 4(4) >> 21(15) = 0(0)\n  signed 8 4(4) >> 22(16) = 0(0)\n  signed 8 4(4) >> 23(17) = 0(0)\n  signed 8 4(4) >> 24(18) = 0(0)\n  signed 8 4(4) >> 25(19) = 0(0)\n  signed 8 4(4) >> 26(1a) = 0(0)\n  signed 8 4(4) >> 27(1b) = 0(0)\n  signed 8 4(4) >> 28(1c) = 0(0)\n  signed 8 4(4) >> 29(1d) = 0(0)\n  signed 8 4(4) >> 30(1e) = 0(0)\n  signed 8 4(4) >> 31(1f) = 0(0)\n  signed 8 4(4) >> 32(20) = 4(4)\n  signed 8 4(4) >> 33(21) = 2(2)\n  signed 8 4(4) >> 34(22) = 1(1)\n  signed 8 4(4) >> 35(23) = 0(0)\n  signed 8 4(4) >> 36(24) = 0(0)\n  signed 8 4(4) >> 37(25) = 0(0)\n  signed 8 4(4) >> 38(26) = 0(0)\n  signed 8 4(4) >> 39(27) = 0(0)\n  signed 8 4(4) >> 40(28) = 0(0)\n  signed 8 4(4) >> 41(29) = 0(0)\n  signed 8 4(4) >> 42(2a) = 0(0)\n  signed 8 4(4) >> 43(2b) = 0(0)\n  signed 8 4(4) >> 44(2c) = 0(0)\n  signed 8 4(4) >> 45(2d) = 0(0)\n  signed 8 4(4) >> 46(2e) = 0(0)\n  signed 8 4(4) >> 47(2f) = 0(0)\n  signed 8 4(4) >> 48(30) = 0(0)\n  signed 8 4(4) >> 49(31) = 0(0)\n  signed 8 4(4) >> 50(32) = 0(0)\n  signed 8 4(4) >> 51(33) = 0(0)\n  signed 8 4(4) >> 52(34) = 0(0)\n  signed 8 4(4) >> 53(35) = 0(0)\n  signed 8 4(4) >> 54(36) = 0(0)\n  signed 8 4(4) >> 55(37) = 0(0)\n  signed 8 4(4) >> 56(38) = 0(0)\n  signed 8 4(4) >> 57(39) = 0(0)\n  signed 8 4(4) >> 58(3a) = 0(0)\n  signed 8 4(4) >> 59(3b) = 0(0)\n  signed 8 4(4) >> 60(3c) = 0(0)\n  signed 8 4(4) >> 61(3d) = 0(0)\n  signed 8 4(4) >> 62(3e) = 0(0)\n  signed 8 4(4) >> 63(3f) = 0(0)\n  signed 8 4(4) >> 64(40) = 4(4)\n  signed 8 4(4) >> 65(41) = 2(2)\n  signed 8 4(4) >> 66(42) = 1(1)\n  signed 8 4(4) >> 67(43) = 0(0)\n  signed 8 4(4) >> 68(44) = 0(0)\n  signed 8 4(4) >> 69(45) = 0(0)\n  signed 8 4(4) >> 70(46) = 0(0)\n  signed 8 4(4) >> 71(47) = 0(0)\n  signed 8 4(4) >> 72(48) = 0(0)\n  signed 8 4(4) >> 73(49) = 0(0)\n  signed 8 4(4) >> 74(4a) = 0(0)\n  signed 8 4(4) >> 75(4b) = 0(0)\n  signed 8 4(4) >> 76(4c) = 0(0)\n  signed 8 4(4) >> 77(4d) = 0(0)\n  signed 8 4(4) >> 78(4e) = 0(0)\n  signed 8 4(4) >> 79(4f) = 0(0)\n  signed 8 4(4) >> 80(50) = 0(0)\n  signed 8 4(4) >> 81(51) = 0(0)\n  signed 8 4(4) >> 82(52) = 0(0)\n  signed 8 4(4) >> 83(53) = 0(0)\n  signed 8 4(4) >> 84(54) = 0(0)\n  signed 8 4(4) >> 85(55) = 0(0)\n  signed 8 4(4) >> 86(56) = 0(0)\n  signed 8 4(4) >> 87(57) = 0(0)\n  signed 8 4(4) >> 88(58) = 0(0)\n  signed 8 4(4) >> 89(59) = 0(0)\n  signed 8 4(4) >> 90(5a) = 0(0)\n  signed 8 4(4) >> 91(5b) = 0(0)\n  signed 8 4(4) >> 92(5c) = 0(0)\n  signed 8 4(4) >> 93(5d) = 0(0)\n  signed 8 4(4) >> 94(5e) = 0(0)\n  signed 8 4(4) >> 95(5f) = 0(0)\n  signed 8 4(4) >> 96(60) = 4(4)\n  signed 8 4(4) >> 97(61) = 2(2)\n  signed 8 4(4) >> 98(62) = 1(1)\n  signed 8 4(4) >> 99(63) = 0(0)\n  signed 8 4(4) >> 100(64) = 0(0)\n  signed 8 4(4) >> 101(65) = 0(0)\n  signed 8 4(4) >> 102(66) = 0(0)\n  signed 8 4(4) >> 103(67) = 0(0)\n  signed 8 4(4) >> 104(68) = 0(0)\n  signed 8 4(4) >> 105(69) = 0(0)\n  signed 8 4(4) >> 106(6a) = 0(0)\n  signed 8 4(4) >> 107(6b) = 0(0)\n  signed 8 4(4) >> 108(6c) = 0(0)\n  signed 8 4(4) >> 109(6d) = 0(0)\n  signed 8 4(4) >> 110(6e) = 0(0)\n  signed 8 4(4) >> 111(6f) = 0(0)\n  signed 8 4(4) >> 112(70) = 0(0)\n  signed 8 4(4) >> 113(71) = 0(0)\n  signed 8 4(4) >> 114(72) = 0(0)\n  signed 8 4(4) >> 115(73) = 0(0)\n  signed 8 4(4) >> 116(74) = 0(0)\n  signed 8 4(4) >> 117(75) = 0(0)\n  signed 8 4(4) >> 118(76) = 0(0)\n  signed 8 4(4) >> 119(77) = 0(0)\n  signed 8 4(4) >> 120(78) = 0(0)\n  signed 8 4(4) >> 121(79) = 0(0)\n  signed 8 4(4) >> 122(7a) = 0(0)\n  signed 8 4(4) >> 123(7b) = 0(0)\n  signed 8 4(4) >> 124(7c) = 0(0)\n  signed 8 4(4) >> 125(7d) = 0(0)\n  signed 8 4(4) >> 126(7e) = 0(0)\n  signed 8 4(4) >> 127(7f) = 0(0)\nunsigned 8 0(0) >> -128(ffffff80) = 0(0)\nunsigned 8 0(0) >> -127(ffffff81) = 0(0)\nunsigned 8 0(0) >> -126(ffffff82) = 0(0)\nunsigned 8 0(0) >> -125(ffffff83) = 0(0)\nunsigned 8 0(0) >> -124(ffffff84) = 0(0)\nunsigned 8 0(0) >> -123(ffffff85) = 0(0)\nunsigned 8 0(0) >> -122(ffffff86) = 0(0)\nunsigned 8 0(0) >> -121(ffffff87) = 0(0)\nunsigned 8 0(0) >> -120(ffffff88) = 0(0)\nunsigned 8 0(0) >> -119(ffffff89) = 0(0)\nunsigned 8 0(0) >> -118(ffffff8a) = 0(0)\nunsigned 8 0(0) >> -117(ffffff8b) = 0(0)\nunsigned 8 0(0) >> -116(ffffff8c) = 0(0)\nunsigned 8 0(0) >> -115(ffffff8d) = 0(0)\nunsigned 8 0(0) >> -114(ffffff8e) = 0(0)\nunsigned 8 0(0) >> -113(ffffff8f) = 0(0)\nunsigned 8 0(0) >> -112(ffffff90) = 0(0)\nunsigned 8 0(0) >> -111(ffffff91) = 0(0)\nunsigned 8 0(0) >> -110(ffffff92) = 0(0)\nunsigned 8 0(0) >> -109(ffffff93) = 0(0)\nunsigned 8 0(0) >> -108(ffffff94) = 0(0)\nunsigned 8 0(0) >> -107(ffffff95) = 0(0)\nunsigned 8 0(0) >> -106(ffffff96) = 0(0)\nunsigned 8 0(0) >> -105(ffffff97) = 0(0)\nunsigned 8 0(0) >> -104(ffffff98) = 0(0)\nunsigned 8 0(0) >> -103(ffffff99) = 0(0)\nunsigned 8 0(0) >> -102(ffffff9a) = 0(0)\nunsigned 8 0(0) >> -101(ffffff9b) = 0(0)\nunsigned 8 0(0) >> -100(ffffff9c) = 0(0)\nunsigned 8 0(0) >> -99(ffffff9d) = 0(0)\nunsigned 8 0(0) >> -98(ffffff9e) = 0(0)\nunsigned 8 0(0) >> -97(ffffff9f) = 0(0)\nunsigned 8 0(0) >> -96(ffffffa0) = 0(0)\nunsigned 8 0(0) >> -95(ffffffa1) = 0(0)\nunsigned 8 0(0) >> -94(ffffffa2) = 0(0)\nunsigned 8 0(0) >> -93(ffffffa3) = 0(0)\nunsigned 8 0(0) >> -92(ffffffa4) = 0(0)\nunsigned 8 0(0) >> -91(ffffffa5) = 0(0)\nunsigned 8 0(0) >> -90(ffffffa6) = 0(0)\nunsigned 8 0(0) >> -89(ffffffa7) = 0(0)\nunsigned 8 0(0) >> -88(ffffffa8) = 0(0)\nunsigned 8 0(0) >> -87(ffffffa9) = 0(0)\nunsigned 8 0(0) >> -86(ffffffaa) = 0(0)\nunsigned 8 0(0) >> -85(ffffffab) = 0(0)\nunsigned 8 0(0) >> -84(ffffffac) = 0(0)\nunsigned 8 0(0) >> -83(ffffffad) = 0(0)\nunsigned 8 0(0) >> -82(ffffffae) = 0(0)\nunsigned 8 0(0) >> -81(ffffffaf) = 0(0)\nunsigned 8 0(0) >> -80(ffffffb0) = 0(0)\nunsigned 8 0(0) >> -79(ffffffb1) = 0(0)\nunsigned 8 0(0) >> -78(ffffffb2) = 0(0)\nunsigned 8 0(0) >> -77(ffffffb3) = 0(0)\nunsigned 8 0(0) >> -76(ffffffb4) = 0(0)\nunsigned 8 0(0) >> -75(ffffffb5) = 0(0)\nunsigned 8 0(0) >> -74(ffffffb6) = 0(0)\nunsigned 8 0(0) >> -73(ffffffb7) = 0(0)\nunsigned 8 0(0) >> -72(ffffffb8) = 0(0)\nunsigned 8 0(0) >> -71(ffffffb9) = 0(0)\nunsigned 8 0(0) >> -70(ffffffba) = 0(0)\nunsigned 8 0(0) >> -69(ffffffbb) = 0(0)\nunsigned 8 0(0) >> -68(ffffffbc) = 0(0)\nunsigned 8 0(0) >> -67(ffffffbd) = 0(0)\nunsigned 8 0(0) >> -66(ffffffbe) = 0(0)\nunsigned 8 0(0) >> -65(ffffffbf) = 0(0)\nunsigned 8 0(0) >> -64(ffffffc0) = 0(0)\nunsigned 8 0(0) >> -63(ffffffc1) = 0(0)\nunsigned 8 0(0) >> -62(ffffffc2) = 0(0)\nunsigned 8 0(0) >> -61(ffffffc3) = 0(0)\nunsigned 8 0(0) >> -60(ffffffc4) = 0(0)\nunsigned 8 0(0) >> -59(ffffffc5) = 0(0)\nunsigned 8 0(0) >> -58(ffffffc6) = 0(0)\nunsigned 8 0(0) >> -57(ffffffc7) = 0(0)\nunsigned 8 0(0) >> -56(ffffffc8) = 0(0)\nunsigned 8 0(0) >> -55(ffffffc9) = 0(0)\nunsigned 8 0(0) >> -54(ffffffca) = 0(0)\nunsigned 8 0(0) >> -53(ffffffcb) = 0(0)\nunsigned 8 0(0) >> -52(ffffffcc) = 0(0)\nunsigned 8 0(0) >> -51(ffffffcd) = 0(0)\nunsigned 8 0(0) >> -50(ffffffce) = 0(0)\nunsigned 8 0(0) >> -49(ffffffcf) = 0(0)\nunsigned 8 0(0) >> -48(ffffffd0) = 0(0)\nunsigned 8 0(0) >> -47(ffffffd1) = 0(0)\nunsigned 8 0(0) >> -46(ffffffd2) = 0(0)\nunsigned 8 0(0) >> -45(ffffffd3) = 0(0)\nunsigned 8 0(0) >> -44(ffffffd4) = 0(0)\nunsigned 8 0(0) >> -43(ffffffd5) = 0(0)\nunsigned 8 0(0) >> -42(ffffffd6) = 0(0)\nunsigned 8 0(0) >> -41(ffffffd7) = 0(0)\nunsigned 8 0(0) >> -40(ffffffd8) = 0(0)\nunsigned 8 0(0) >> -39(ffffffd9) = 0(0)\nunsigned 8 0(0) >> -38(ffffffda) = 0(0)\nunsigned 8 0(0) >> -37(ffffffdb) = 0(0)\nunsigned 8 0(0) >> -36(ffffffdc) = 0(0)\nunsigned 8 0(0) >> -35(ffffffdd) = 0(0)\nunsigned 8 0(0) >> -34(ffffffde) = 0(0)\nunsigned 8 0(0) >> -33(ffffffdf) = 0(0)\nunsigned 8 0(0) >> -32(ffffffe0) = 0(0)\nunsigned 8 0(0) >> -31(ffffffe1) = 0(0)\nunsigned 8 0(0) >> -30(ffffffe2) = 0(0)\nunsigned 8 0(0) >> -29(ffffffe3) = 0(0)\nunsigned 8 0(0) >> -28(ffffffe4) = 0(0)\nunsigned 8 0(0) >> -27(ffffffe5) = 0(0)\nunsigned 8 0(0) >> -26(ffffffe6) = 0(0)\nunsigned 8 0(0) >> -25(ffffffe7) = 0(0)\nunsigned 8 0(0) >> -24(ffffffe8) = 0(0)\nunsigned 8 0(0) >> -23(ffffffe9) = 0(0)\nunsigned 8 0(0) >> -22(ffffffea) = 0(0)\nunsigned 8 0(0) >> -21(ffffffeb) = 0(0)\nunsigned 8 0(0) >> -20(ffffffec) = 0(0)\nunsigned 8 0(0) >> -19(ffffffed) = 0(0)\nunsigned 8 0(0) >> -18(ffffffee) = 0(0)\nunsigned 8 0(0) >> -17(ffffffef) = 0(0)\nunsigned 8 0(0) >> -16(fffffff0) = 0(0)\nunsigned 8 0(0) >> -15(fffffff1) = 0(0)\nunsigned 8 0(0) >> -14(fffffff2) = 0(0)\nunsigned 8 0(0) >> -13(fffffff3) = 0(0)\nunsigned 8 0(0) >> -12(fffffff4) = 0(0)\nunsigned 8 0(0) >> -11(fffffff5) = 0(0)\nunsigned 8 0(0) >> -10(fffffff6) = 0(0)\nunsigned 8 0(0) >> -9(fffffff7) = 0(0)\nunsigned 8 0(0) >> -8(fffffff8) = 0(0)\nunsigned 8 0(0) >> -7(fffffff9) = 0(0)\nunsigned 8 0(0) >> -6(fffffffa) = 0(0)\nunsigned 8 0(0) >> -5(fffffffb) = 0(0)\nunsigned 8 0(0) >> -4(fffffffc) = 0(0)\nunsigned 8 0(0) >> -3(fffffffd) = 0(0)\nunsigned 8 0(0) >> -2(fffffffe) = 0(0)\nunsigned 8 0(0) >> -1(ffffffff) = 0(0)\nunsigned 8 0(0) >> 0(0) = 0(0)\nunsigned 8 0(0) >> 1(1) = 0(0)\nunsigned 8 0(0) >> 2(2) = 0(0)\nunsigned 8 0(0) >> 3(3) = 0(0)\nunsigned 8 0(0) >> 4(4) = 0(0)\nunsigned 8 0(0) >> 5(5) = 0(0)\nunsigned 8 0(0) >> 6(6) = 0(0)\nunsigned 8 0(0) >> 7(7) = 0(0)\nunsigned 8 0(0) >> 8(8) = 0(0)\nunsigned 8 0(0) >> 9(9) = 0(0)\nunsigned 8 0(0) >> 10(a) = 0(0)\nunsigned 8 0(0) >> 11(b) = 0(0)\nunsigned 8 0(0) >> 12(c) = 0(0)\nunsigned 8 0(0) >> 13(d) = 0(0)\nunsigned 8 0(0) >> 14(e) = 0(0)\nunsigned 8 0(0) >> 15(f) = 0(0)\nunsigned 8 0(0) >> 16(10) = 0(0)\nunsigned 8 0(0) >> 17(11) = 0(0)\nunsigned 8 0(0) >> 18(12) = 0(0)\nunsigned 8 0(0) >> 19(13) = 0(0)\nunsigned 8 0(0) >> 20(14) = 0(0)\nunsigned 8 0(0) >> 21(15) = 0(0)\nunsigned 8 0(0) >> 22(16) = 0(0)\nunsigned 8 0(0) >> 23(17) = 0(0)\nunsigned 8 0(0) >> 24(18) = 0(0)\nunsigned 8 0(0) >> 25(19) = 0(0)\nunsigned 8 0(0) >> 26(1a) = 0(0)\nunsigned 8 0(0) >> 27(1b) = 0(0)\nunsigned 8 0(0) >> 28(1c) = 0(0)\nunsigned 8 0(0) >> 29(1d) = 0(0)\nunsigned 8 0(0) >> 30(1e) = 0(0)\nunsigned 8 0(0) >> 31(1f) = 0(0)\nunsigned 8 0(0) >> 32(20) = 0(0)\nunsigned 8 0(0) >> 33(21) = 0(0)\nunsigned 8 0(0) >> 34(22) = 0(0)\nunsigned 8 0(0) >> 35(23) = 0(0)\nunsigned 8 0(0) >> 36(24) = 0(0)\nunsigned 8 0(0) >> 37(25) = 0(0)\nunsigned 8 0(0) >> 38(26) = 0(0)\nunsigned 8 0(0) >> 39(27) = 0(0)\nunsigned 8 0(0) >> 40(28) = 0(0)\nunsigned 8 0(0) >> 41(29) = 0(0)\nunsigned 8 0(0) >> 42(2a) = 0(0)\nunsigned 8 0(0) >> 43(2b) = 0(0)\nunsigned 8 0(0) >> 44(2c) = 0(0)\nunsigned 8 0(0) >> 45(2d) = 0(0)\nunsigned 8 0(0) >> 46(2e) = 0(0)\nunsigned 8 0(0) >> 47(2f) = 0(0)\nunsigned 8 0(0) >> 48(30) = 0(0)\nunsigned 8 0(0) >> 49(31) = 0(0)\nunsigned 8 0(0) >> 50(32) = 0(0)\nunsigned 8 0(0) >> 51(33) = 0(0)\nunsigned 8 0(0) >> 52(34) = 0(0)\nunsigned 8 0(0) >> 53(35) = 0(0)\nunsigned 8 0(0) >> 54(36) = 0(0)\nunsigned 8 0(0) >> 55(37) = 0(0)\nunsigned 8 0(0) >> 56(38) = 0(0)\nunsigned 8 0(0) >> 57(39) = 0(0)\nunsigned 8 0(0) >> 58(3a) = 0(0)\nunsigned 8 0(0) >> 59(3b) = 0(0)\nunsigned 8 0(0) >> 60(3c) = 0(0)\nunsigned 8 0(0) >> 61(3d) = 0(0)\nunsigned 8 0(0) >> 62(3e) = 0(0)\nunsigned 8 0(0) >> 63(3f) = 0(0)\nunsigned 8 0(0) >> 64(40) = 0(0)\nunsigned 8 0(0) >> 65(41) = 0(0)\nunsigned 8 0(0) >> 66(42) = 0(0)\nunsigned 8 0(0) >> 67(43) = 0(0)\nunsigned 8 0(0) >> 68(44) = 0(0)\nunsigned 8 0(0) >> 69(45) = 0(0)\nunsigned 8 0(0) >> 70(46) = 0(0)\nunsigned 8 0(0) >> 71(47) = 0(0)\nunsigned 8 0(0) >> 72(48) = 0(0)\nunsigned 8 0(0) >> 73(49) = 0(0)\nunsigned 8 0(0) >> 74(4a) = 0(0)\nunsigned 8 0(0) >> 75(4b) = 0(0)\nunsigned 8 0(0) >> 76(4c) = 0(0)\nunsigned 8 0(0) >> 77(4d) = 0(0)\nunsigned 8 0(0) >> 78(4e) = 0(0)\nunsigned 8 0(0) >> 79(4f) = 0(0)\nunsigned 8 0(0) >> 80(50) = 0(0)\nunsigned 8 0(0) >> 81(51) = 0(0)\nunsigned 8 0(0) >> 82(52) = 0(0)\nunsigned 8 0(0) >> 83(53) = 0(0)\nunsigned 8 0(0) >> 84(54) = 0(0)\nunsigned 8 0(0) >> 85(55) = 0(0)\nunsigned 8 0(0) >> 86(56) = 0(0)\nunsigned 8 0(0) >> 87(57) = 0(0)\nunsigned 8 0(0) >> 88(58) = 0(0)\nunsigned 8 0(0) >> 89(59) = 0(0)\nunsigned 8 0(0) >> 90(5a) = 0(0)\nunsigned 8 0(0) >> 91(5b) = 0(0)\nunsigned 8 0(0) >> 92(5c) = 0(0)\nunsigned 8 0(0) >> 93(5d) = 0(0)\nunsigned 8 0(0) >> 94(5e) = 0(0)\nunsigned 8 0(0) >> 95(5f) = 0(0)\nunsigned 8 0(0) >> 96(60) = 0(0)\nunsigned 8 0(0) >> 97(61) = 0(0)\nunsigned 8 0(0) >> 98(62) = 0(0)\nunsigned 8 0(0) >> 99(63) = 0(0)\nunsigned 8 0(0) >> 100(64) = 0(0)\nunsigned 8 0(0) >> 101(65) = 0(0)\nunsigned 8 0(0) >> 102(66) = 0(0)\nunsigned 8 0(0) >> 103(67) = 0(0)\nunsigned 8 0(0) >> 104(68) = 0(0)\nunsigned 8 0(0) >> 105(69) = 0(0)\nunsigned 8 0(0) >> 106(6a) = 0(0)\nunsigned 8 0(0) >> 107(6b) = 0(0)\nunsigned 8 0(0) >> 108(6c) = 0(0)\nunsigned 8 0(0) >> 109(6d) = 0(0)\nunsigned 8 0(0) >> 110(6e) = 0(0)\nunsigned 8 0(0) >> 111(6f) = 0(0)\nunsigned 8 0(0) >> 112(70) = 0(0)\nunsigned 8 0(0) >> 113(71) = 0(0)\nunsigned 8 0(0) >> 114(72) = 0(0)\nunsigned 8 0(0) >> 115(73) = 0(0)\nunsigned 8 0(0) >> 116(74) = 0(0)\nunsigned 8 0(0) >> 117(75) = 0(0)\nunsigned 8 0(0) >> 118(76) = 0(0)\nunsigned 8 0(0) >> 119(77) = 0(0)\nunsigned 8 0(0) >> 120(78) = 0(0)\nunsigned 8 0(0) >> 121(79) = 0(0)\nunsigned 8 0(0) >> 122(7a) = 0(0)\nunsigned 8 0(0) >> 123(7b) = 0(0)\nunsigned 8 0(0) >> 124(7c) = 0(0)\nunsigned 8 0(0) >> 125(7d) = 0(0)\nunsigned 8 0(0) >> 126(7e) = 0(0)\nunsigned 8 0(0) >> 127(7f) = 0(0)\nunsigned 8 1(1) >> -128(ffffff80) = 1(1)\nunsigned 8 1(1) >> -127(ffffff81) = 0(0)\nunsigned 8 1(1) >> -126(ffffff82) = 0(0)\nunsigned 8 1(1) >> -125(ffffff83) = 0(0)\nunsigned 8 1(1) >> -124(ffffff84) = 0(0)\nunsigned 8 1(1) >> -123(ffffff85) = 0(0)\nunsigned 8 1(1) >> -122(ffffff86) = 0(0)\nunsigned 8 1(1) >> -121(ffffff87) = 0(0)\nunsigned 8 1(1) >> -120(ffffff88) = 0(0)\nunsigned 8 1(1) >> -119(ffffff89) = 0(0)\nunsigned 8 1(1) >> -118(ffffff8a) = 0(0)\nunsigned 8 1(1) >> -117(ffffff8b) = 0(0)\nunsigned 8 1(1) >> -116(ffffff8c) = 0(0)\nunsigned 8 1(1) >> -115(ffffff8d) = 0(0)\nunsigned 8 1(1) >> -114(ffffff8e) = 0(0)\nunsigned 8 1(1) >> -113(ffffff8f) = 0(0)\nunsigned 8 1(1) >> -112(ffffff90) = 0(0)\nunsigned 8 1(1) >> -111(ffffff91) = 0(0)\nunsigned 8 1(1) >> -110(ffffff92) = 0(0)\nunsigned 8 1(1) >> -109(ffffff93) = 0(0)\nunsigned 8 1(1) >> -108(ffffff94) = 0(0)\nunsigned 8 1(1) >> -107(ffffff95) = 0(0)\nunsigned 8 1(1) >> -106(ffffff96) = 0(0)\nunsigned 8 1(1) >> -105(ffffff97) = 0(0)\nunsigned 8 1(1) >> -104(ffffff98) = 0(0)\nunsigned 8 1(1) >> -103(ffffff99) = 0(0)\nunsigned 8 1(1) >> -102(ffffff9a) = 0(0)\nunsigned 8 1(1) >> -101(ffffff9b) = 0(0)\nunsigned 8 1(1) >> -100(ffffff9c) = 0(0)\nunsigned 8 1(1) >> -99(ffffff9d) = 0(0)\nunsigned 8 1(1) >> -98(ffffff9e) = 0(0)\nunsigned 8 1(1) >> -97(ffffff9f) = 0(0)\nunsigned 8 1(1) >> -96(ffffffa0) = 1(1)\nunsigned 8 1(1) >> -95(ffffffa1) = 0(0)\nunsigned 8 1(1) >> -94(ffffffa2) = 0(0)\nunsigned 8 1(1) >> -93(ffffffa3) = 0(0)\nunsigned 8 1(1) >> -92(ffffffa4) = 0(0)\nunsigned 8 1(1) >> -91(ffffffa5) = 0(0)\nunsigned 8 1(1) >> -90(ffffffa6) = 0(0)\nunsigned 8 1(1) >> -89(ffffffa7) = 0(0)\nunsigned 8 1(1) >> -88(ffffffa8) = 0(0)\nunsigned 8 1(1) >> -87(ffffffa9) = 0(0)\nunsigned 8 1(1) >> -86(ffffffaa) = 0(0)\nunsigned 8 1(1) >> -85(ffffffab) = 0(0)\nunsigned 8 1(1) >> -84(ffffffac) = 0(0)\nunsigned 8 1(1) >> -83(ffffffad) = 0(0)\nunsigned 8 1(1) >> -82(ffffffae) = 0(0)\nunsigned 8 1(1) >> -81(ffffffaf) = 0(0)\nunsigned 8 1(1) >> -80(ffffffb0) = 0(0)\nunsigned 8 1(1) >> -79(ffffffb1) = 0(0)\nunsigned 8 1(1) >> -78(ffffffb2) = 0(0)\nunsigned 8 1(1) >> -77(ffffffb3) = 0(0)\nunsigned 8 1(1) >> -76(ffffffb4) = 0(0)\nunsigned 8 1(1) >> -75(ffffffb5) = 0(0)\nunsigned 8 1(1) >> -74(ffffffb6) = 0(0)\nunsigned 8 1(1) >> -73(ffffffb7) = 0(0)\nunsigned 8 1(1) >> -72(ffffffb8) = 0(0)\nunsigned 8 1(1) >> -71(ffffffb9) = 0(0)\nunsigned 8 1(1) >> -70(ffffffba) = 0(0)\nunsigned 8 1(1) >> -69(ffffffbb) = 0(0)\nunsigned 8 1(1) >> -68(ffffffbc) = 0(0)\nunsigned 8 1(1) >> -67(ffffffbd) = 0(0)\nunsigned 8 1(1) >> -66(ffffffbe) = 0(0)\nunsigned 8 1(1) >> -65(ffffffbf) = 0(0)\nunsigned 8 1(1) >> -64(ffffffc0) = 1(1)\nunsigned 8 1(1) >> -63(ffffffc1) = 0(0)\nunsigned 8 1(1) >> -62(ffffffc2) = 0(0)\nunsigned 8 1(1) >> -61(ffffffc3) = 0(0)\nunsigned 8 1(1) >> -60(ffffffc4) = 0(0)\nunsigned 8 1(1) >> -59(ffffffc5) = 0(0)\nunsigned 8 1(1) >> -58(ffffffc6) = 0(0)\nunsigned 8 1(1) >> -57(ffffffc7) = 0(0)\nunsigned 8 1(1) >> -56(ffffffc8) = 0(0)\nunsigned 8 1(1) >> -55(ffffffc9) = 0(0)\nunsigned 8 1(1) >> -54(ffffffca) = 0(0)\nunsigned 8 1(1) >> -53(ffffffcb) = 0(0)\nunsigned 8 1(1) >> -52(ffffffcc) = 0(0)\nunsigned 8 1(1) >> -51(ffffffcd) = 0(0)\nunsigned 8 1(1) >> -50(ffffffce) = 0(0)\nunsigned 8 1(1) >> -49(ffffffcf) = 0(0)\nunsigned 8 1(1) >> -48(ffffffd0) = 0(0)\nunsigned 8 1(1) >> -47(ffffffd1) = 0(0)\nunsigned 8 1(1) >> -46(ffffffd2) = 0(0)\nunsigned 8 1(1) >> -45(ffffffd3) = 0(0)\nunsigned 8 1(1) >> -44(ffffffd4) = 0(0)\nunsigned 8 1(1) >> -43(ffffffd5) = 0(0)\nunsigned 8 1(1) >> -42(ffffffd6) = 0(0)\nunsigned 8 1(1) >> -41(ffffffd7) = 0(0)\nunsigned 8 1(1) >> -40(ffffffd8) = 0(0)\nunsigned 8 1(1) >> -39(ffffffd9) = 0(0)\nunsigned 8 1(1) >> -38(ffffffda) = 0(0)\nunsigned 8 1(1) >> -37(ffffffdb) = 0(0)\nunsigned 8 1(1) >> -36(ffffffdc) = 0(0)\nunsigned 8 1(1) >> -35(ffffffdd) = 0(0)\nunsigned 8 1(1) >> -34(ffffffde) = 0(0)\nunsigned 8 1(1) >> -33(ffffffdf) = 0(0)\nunsigned 8 1(1) >> -32(ffffffe0) = 1(1)\nunsigned 8 1(1) >> -31(ffffffe1) = 0(0)\nunsigned 8 1(1) >> -30(ffffffe2) = 0(0)\nunsigned 8 1(1) >> -29(ffffffe3) = 0(0)\nunsigned 8 1(1) >> -28(ffffffe4) = 0(0)\nunsigned 8 1(1) >> -27(ffffffe5) = 0(0)\nunsigned 8 1(1) >> -26(ffffffe6) = 0(0)\nunsigned 8 1(1) >> -25(ffffffe7) = 0(0)\nunsigned 8 1(1) >> -24(ffffffe8) = 0(0)\nunsigned 8 1(1) >> -23(ffffffe9) = 0(0)\nunsigned 8 1(1) >> -22(ffffffea) = 0(0)\nunsigned 8 1(1) >> -21(ffffffeb) = 0(0)\nunsigned 8 1(1) >> -20(ffffffec) = 0(0)\nunsigned 8 1(1) >> -19(ffffffed) = 0(0)\nunsigned 8 1(1) >> -18(ffffffee) = 0(0)\nunsigned 8 1(1) >> -17(ffffffef) = 0(0)\nunsigned 8 1(1) >> -16(fffffff0) = 0(0)\nunsigned 8 1(1) >> -15(fffffff1) = 0(0)\nunsigned 8 1(1) >> -14(fffffff2) = 0(0)\nunsigned 8 1(1) >> -13(fffffff3) = 0(0)\nunsigned 8 1(1) >> -12(fffffff4) = 0(0)\nunsigned 8 1(1) >> -11(fffffff5) = 0(0)\nunsigned 8 1(1) >> -10(fffffff6) = 0(0)\nunsigned 8 1(1) >> -9(fffffff7) = 0(0)\nunsigned 8 1(1) >> -8(fffffff8) = 0(0)\nunsigned 8 1(1) >> -7(fffffff9) = 0(0)\nunsigned 8 1(1) >> -6(fffffffa) = 0(0)\nunsigned 8 1(1) >> -5(fffffffb) = 0(0)\nunsigned 8 1(1) >> -4(fffffffc) = 0(0)\nunsigned 8 1(1) >> -3(fffffffd) = 0(0)\nunsigned 8 1(1) >> -2(fffffffe) = 0(0)\nunsigned 8 1(1) >> -1(ffffffff) = 0(0)\nunsigned 8 1(1) >> 0(0) = 1(1)\nunsigned 8 1(1) >> 1(1) = 0(0)\nunsigned 8 1(1) >> 2(2) = 0(0)\nunsigned 8 1(1) >> 3(3) = 0(0)\nunsigned 8 1(1) >> 4(4) = 0(0)\nunsigned 8 1(1) >> 5(5) = 0(0)\nunsigned 8 1(1) >> 6(6) = 0(0)\nunsigned 8 1(1) >> 7(7) = 0(0)\nunsigned 8 1(1) >> 8(8) = 0(0)\nunsigned 8 1(1) >> 9(9) = 0(0)\nunsigned 8 1(1) >> 10(a) = 0(0)\nunsigned 8 1(1) >> 11(b) = 0(0)\nunsigned 8 1(1) >> 12(c) = 0(0)\nunsigned 8 1(1) >> 13(d) = 0(0)\nunsigned 8 1(1) >> 14(e) = 0(0)\nunsigned 8 1(1) >> 15(f) = 0(0)\nunsigned 8 1(1) >> 16(10) = 0(0)\nunsigned 8 1(1) >> 17(11) = 0(0)\nunsigned 8 1(1) >> 18(12) = 0(0)\nunsigned 8 1(1) >> 19(13) = 0(0)\nunsigned 8 1(1) >> 20(14) = 0(0)\nunsigned 8 1(1) >> 21(15) = 0(0)\nunsigned 8 1(1) >> 22(16) = 0(0)\nunsigned 8 1(1) >> 23(17) = 0(0)\nunsigned 8 1(1) >> 24(18) = 0(0)\nunsigned 8 1(1) >> 25(19) = 0(0)\nunsigned 8 1(1) >> 26(1a) = 0(0)\nunsigned 8 1(1) >> 27(1b) = 0(0)\nunsigned 8 1(1) >> 28(1c) = 0(0)\nunsigned 8 1(1) >> 29(1d) = 0(0)\nunsigned 8 1(1) >> 30(1e) = 0(0)\nunsigned 8 1(1) >> 31(1f) = 0(0)\nunsigned 8 1(1) >> 32(20) = 1(1)\nunsigned 8 1(1) >> 33(21) = 0(0)\nunsigned 8 1(1) >> 34(22) = 0(0)\nunsigned 8 1(1) >> 35(23) = 0(0)\nunsigned 8 1(1) >> 36(24) = 0(0)\nunsigned 8 1(1) >> 37(25) = 0(0)\nunsigned 8 1(1) >> 38(26) = 0(0)\nunsigned 8 1(1) >> 39(27) = 0(0)\nunsigned 8 1(1) >> 40(28) = 0(0)\nunsigned 8 1(1) >> 41(29) = 0(0)\nunsigned 8 1(1) >> 42(2a) = 0(0)\nunsigned 8 1(1) >> 43(2b) = 0(0)\nunsigned 8 1(1) >> 44(2c) = 0(0)\nunsigned 8 1(1) >> 45(2d) = 0(0)\nunsigned 8 1(1) >> 46(2e) = 0(0)\nunsigned 8 1(1) >> 47(2f) = 0(0)\nunsigned 8 1(1) >> 48(30) = 0(0)\nunsigned 8 1(1) >> 49(31) = 0(0)\nunsigned 8 1(1) >> 50(32) = 0(0)\nunsigned 8 1(1) >> 51(33) = 0(0)\nunsigned 8 1(1) >> 52(34) = 0(0)\nunsigned 8 1(1) >> 53(35) = 0(0)\nunsigned 8 1(1) >> 54(36) = 0(0)\nunsigned 8 1(1) >> 55(37) = 0(0)\nunsigned 8 1(1) >> 56(38) = 0(0)\nunsigned 8 1(1) >> 57(39) = 0(0)\nunsigned 8 1(1) >> 58(3a) = 0(0)\nunsigned 8 1(1) >> 59(3b) = 0(0)\nunsigned 8 1(1) >> 60(3c) = 0(0)\nunsigned 8 1(1) >> 61(3d) = 0(0)\nunsigned 8 1(1) >> 62(3e) = 0(0)\nunsigned 8 1(1) >> 63(3f) = 0(0)\nunsigned 8 1(1) >> 64(40) = 1(1)\nunsigned 8 1(1) >> 65(41) = 0(0)\nunsigned 8 1(1) >> 66(42) = 0(0)\nunsigned 8 1(1) >> 67(43) = 0(0)\nunsigned 8 1(1) >> 68(44) = 0(0)\nunsigned 8 1(1) >> 69(45) = 0(0)\nunsigned 8 1(1) >> 70(46) = 0(0)\nunsigned 8 1(1) >> 71(47) = 0(0)\nunsigned 8 1(1) >> 72(48) = 0(0)\nunsigned 8 1(1) >> 73(49) = 0(0)\nunsigned 8 1(1) >> 74(4a) = 0(0)\nunsigned 8 1(1) >> 75(4b) = 0(0)\nunsigned 8 1(1) >> 76(4c) = 0(0)\nunsigned 8 1(1) >> 77(4d) = 0(0)\nunsigned 8 1(1) >> 78(4e) = 0(0)\nunsigned 8 1(1) >> 79(4f) = 0(0)\nunsigned 8 1(1) >> 80(50) = 0(0)\nunsigned 8 1(1) >> 81(51) = 0(0)\nunsigned 8 1(1) >> 82(52) = 0(0)\nunsigned 8 1(1) >> 83(53) = 0(0)\nunsigned 8 1(1) >> 84(54) = 0(0)\nunsigned 8 1(1) >> 85(55) = 0(0)\nunsigned 8 1(1) >> 86(56) = 0(0)\nunsigned 8 1(1) >> 87(57) = 0(0)\nunsigned 8 1(1) >> 88(58) = 0(0)\nunsigned 8 1(1) >> 89(59) = 0(0)\nunsigned 8 1(1) >> 90(5a) = 0(0)\nunsigned 8 1(1) >> 91(5b) = 0(0)\nunsigned 8 1(1) >> 92(5c) = 0(0)\nunsigned 8 1(1) >> 93(5d) = 0(0)\nunsigned 8 1(1) >> 94(5e) = 0(0)\nunsigned 8 1(1) >> 95(5f) = 0(0)\nunsigned 8 1(1) >> 96(60) = 1(1)\nunsigned 8 1(1) >> 97(61) = 0(0)\nunsigned 8 1(1) >> 98(62) = 0(0)\nunsigned 8 1(1) >> 99(63) = 0(0)\nunsigned 8 1(1) >> 100(64) = 0(0)\nunsigned 8 1(1) >> 101(65) = 0(0)\nunsigned 8 1(1) >> 102(66) = 0(0)\nunsigned 8 1(1) >> 103(67) = 0(0)\nunsigned 8 1(1) >> 104(68) = 0(0)\nunsigned 8 1(1) >> 105(69) = 0(0)\nunsigned 8 1(1) >> 106(6a) = 0(0)\nunsigned 8 1(1) >> 107(6b) = 0(0)\nunsigned 8 1(1) >> 108(6c) = 0(0)\nunsigned 8 1(1) >> 109(6d) = 0(0)\nunsigned 8 1(1) >> 110(6e) = 0(0)\nunsigned 8 1(1) >> 111(6f) = 0(0)\nunsigned 8 1(1) >> 112(70) = 0(0)\nunsigned 8 1(1) >> 113(71) = 0(0)\nunsigned 8 1(1) >> 114(72) = 0(0)\nunsigned 8 1(1) >> 115(73) = 0(0)\nunsigned 8 1(1) >> 116(74) = 0(0)\nunsigned 8 1(1) >> 117(75) = 0(0)\nunsigned 8 1(1) >> 118(76) = 0(0)\nunsigned 8 1(1) >> 119(77) = 0(0)\nunsigned 8 1(1) >> 120(78) = 0(0)\nunsigned 8 1(1) >> 121(79) = 0(0)\nunsigned 8 1(1) >> 122(7a) = 0(0)\nunsigned 8 1(1) >> 123(7b) = 0(0)\nunsigned 8 1(1) >> 124(7c) = 0(0)\nunsigned 8 1(1) >> 125(7d) = 0(0)\nunsigned 8 1(1) >> 126(7e) = 0(0)\nunsigned 8 1(1) >> 127(7f) = 0(0)\nunsigned 8 2(2) >> -128(ffffff80) = 2(2)\nunsigned 8 2(2) >> -127(ffffff81) = 1(1)\nunsigned 8 2(2) >> -126(ffffff82) = 0(0)\nunsigned 8 2(2) >> -125(ffffff83) = 0(0)\nunsigned 8 2(2) >> -124(ffffff84) = 0(0)\nunsigned 8 2(2) >> -123(ffffff85) = 0(0)\nunsigned 8 2(2) >> -122(ffffff86) = 0(0)\nunsigned 8 2(2) >> -121(ffffff87) = 0(0)\nunsigned 8 2(2) >> -120(ffffff88) = 0(0)\nunsigned 8 2(2) >> -119(ffffff89) = 0(0)\nunsigned 8 2(2) >> -118(ffffff8a) = 0(0)\nunsigned 8 2(2) >> -117(ffffff8b) = 0(0)\nunsigned 8 2(2) >> -116(ffffff8c) = 0(0)\nunsigned 8 2(2) >> -115(ffffff8d) = 0(0)\nunsigned 8 2(2) >> -114(ffffff8e) = 0(0)\nunsigned 8 2(2) >> -113(ffffff8f) = 0(0)\nunsigned 8 2(2) >> -112(ffffff90) = 0(0)\nunsigned 8 2(2) >> -111(ffffff91) = 0(0)\nunsigned 8 2(2) >> -110(ffffff92) = 0(0)\nunsigned 8 2(2) >> -109(ffffff93) = 0(0)\nunsigned 8 2(2) >> -108(ffffff94) = 0(0)\nunsigned 8 2(2) >> -107(ffffff95) = 0(0)\nunsigned 8 2(2) >> -106(ffffff96) = 0(0)\nunsigned 8 2(2) >> -105(ffffff97) = 0(0)\nunsigned 8 2(2) >> -104(ffffff98) = 0(0)\nunsigned 8 2(2) >> -103(ffffff99) = 0(0)\nunsigned 8 2(2) >> -102(ffffff9a) = 0(0)\nunsigned 8 2(2) >> -101(ffffff9b) = 0(0)\nunsigned 8 2(2) >> -100(ffffff9c) = 0(0)\nunsigned 8 2(2) >> -99(ffffff9d) = 0(0)\nunsigned 8 2(2) >> -98(ffffff9e) = 0(0)\nunsigned 8 2(2) >> -97(ffffff9f) = 0(0)\nunsigned 8 2(2) >> -96(ffffffa0) = 2(2)\nunsigned 8 2(2) >> -95(ffffffa1) = 1(1)\nunsigned 8 2(2) >> -94(ffffffa2) = 0(0)\nunsigned 8 2(2) >> -93(ffffffa3) = 0(0)\nunsigned 8 2(2) >> -92(ffffffa4) = 0(0)\nunsigned 8 2(2) >> -91(ffffffa5) = 0(0)\nunsigned 8 2(2) >> -90(ffffffa6) = 0(0)\nunsigned 8 2(2) >> -89(ffffffa7) = 0(0)\nunsigned 8 2(2) >> -88(ffffffa8) = 0(0)\nunsigned 8 2(2) >> -87(ffffffa9) = 0(0)\nunsigned 8 2(2) >> -86(ffffffaa) = 0(0)\nunsigned 8 2(2) >> -85(ffffffab) = 0(0)\nunsigned 8 2(2) >> -84(ffffffac) = 0(0)\nunsigned 8 2(2) >> -83(ffffffad) = 0(0)\nunsigned 8 2(2) >> -82(ffffffae) = 0(0)\nunsigned 8 2(2) >> -81(ffffffaf) = 0(0)\nunsigned 8 2(2) >> -80(ffffffb0) = 0(0)\nunsigned 8 2(2) >> -79(ffffffb1) = 0(0)\nunsigned 8 2(2) >> -78(ffffffb2) = 0(0)\nunsigned 8 2(2) >> -77(ffffffb3) = 0(0)\nunsigned 8 2(2) >> -76(ffffffb4) = 0(0)\nunsigned 8 2(2) >> -75(ffffffb5) = 0(0)\nunsigned 8 2(2) >> -74(ffffffb6) = 0(0)\nunsigned 8 2(2) >> -73(ffffffb7) = 0(0)\nunsigned 8 2(2) >> -72(ffffffb8) = 0(0)\nunsigned 8 2(2) >> -71(ffffffb9) = 0(0)\nunsigned 8 2(2) >> -70(ffffffba) = 0(0)\nunsigned 8 2(2) >> -69(ffffffbb) = 0(0)\nunsigned 8 2(2) >> -68(ffffffbc) = 0(0)\nunsigned 8 2(2) >> -67(ffffffbd) = 0(0)\nunsigned 8 2(2) >> -66(ffffffbe) = 0(0)\nunsigned 8 2(2) >> -65(ffffffbf) = 0(0)\nunsigned 8 2(2) >> -64(ffffffc0) = 2(2)\nunsigned 8 2(2) >> -63(ffffffc1) = 1(1)\nunsigned 8 2(2) >> -62(ffffffc2) = 0(0)\nunsigned 8 2(2) >> -61(ffffffc3) = 0(0)\nunsigned 8 2(2) >> -60(ffffffc4) = 0(0)\nunsigned 8 2(2) >> -59(ffffffc5) = 0(0)\nunsigned 8 2(2) >> -58(ffffffc6) = 0(0)\nunsigned 8 2(2) >> -57(ffffffc7) = 0(0)\nunsigned 8 2(2) >> -56(ffffffc8) = 0(0)\nunsigned 8 2(2) >> -55(ffffffc9) = 0(0)\nunsigned 8 2(2) >> -54(ffffffca) = 0(0)\nunsigned 8 2(2) >> -53(ffffffcb) = 0(0)\nunsigned 8 2(2) >> -52(ffffffcc) = 0(0)\nunsigned 8 2(2) >> -51(ffffffcd) = 0(0)\nunsigned 8 2(2) >> -50(ffffffce) = 0(0)\nunsigned 8 2(2) >> -49(ffffffcf) = 0(0)\nunsigned 8 2(2) >> -48(ffffffd0) = 0(0)\nunsigned 8 2(2) >> -47(ffffffd1) = 0(0)\nunsigned 8 2(2) >> -46(ffffffd2) = 0(0)\nunsigned 8 2(2) >> -45(ffffffd3) = 0(0)\nunsigned 8 2(2) >> -44(ffffffd4) = 0(0)\nunsigned 8 2(2) >> -43(ffffffd5) = 0(0)\nunsigned 8 2(2) >> -42(ffffffd6) = 0(0)\nunsigned 8 2(2) >> -41(ffffffd7) = 0(0)\nunsigned 8 2(2) >> -40(ffffffd8) = 0(0)\nunsigned 8 2(2) >> -39(ffffffd9) = 0(0)\nunsigned 8 2(2) >> -38(ffffffda) = 0(0)\nunsigned 8 2(2) >> -37(ffffffdb) = 0(0)\nunsigned 8 2(2) >> -36(ffffffdc) = 0(0)\nunsigned 8 2(2) >> -35(ffffffdd) = 0(0)\nunsigned 8 2(2) >> -34(ffffffde) = 0(0)\nunsigned 8 2(2) >> -33(ffffffdf) = 0(0)\nunsigned 8 2(2) >> -32(ffffffe0) = 2(2)\nunsigned 8 2(2) >> -31(ffffffe1) = 1(1)\nunsigned 8 2(2) >> -30(ffffffe2) = 0(0)\nunsigned 8 2(2) >> -29(ffffffe3) = 0(0)\nunsigned 8 2(2) >> -28(ffffffe4) = 0(0)\nunsigned 8 2(2) >> -27(ffffffe5) = 0(0)\nunsigned 8 2(2) >> -26(ffffffe6) = 0(0)\nunsigned 8 2(2) >> -25(ffffffe7) = 0(0)\nunsigned 8 2(2) >> -24(ffffffe8) = 0(0)\nunsigned 8 2(2) >> -23(ffffffe9) = 0(0)\nunsigned 8 2(2) >> -22(ffffffea) = 0(0)\nunsigned 8 2(2) >> -21(ffffffeb) = 0(0)\nunsigned 8 2(2) >> -20(ffffffec) = 0(0)\nunsigned 8 2(2) >> -19(ffffffed) = 0(0)\nunsigned 8 2(2) >> -18(ffffffee) = 0(0)\nunsigned 8 2(2) >> -17(ffffffef) = 0(0)\nunsigned 8 2(2) >> -16(fffffff0) = 0(0)\nunsigned 8 2(2) >> -15(fffffff1) = 0(0)\nunsigned 8 2(2) >> -14(fffffff2) = 0(0)\nunsigned 8 2(2) >> -13(fffffff3) = 0(0)\nunsigned 8 2(2) >> -12(fffffff4) = 0(0)\nunsigned 8 2(2) >> -11(fffffff5) = 0(0)\nunsigned 8 2(2) >> -10(fffffff6) = 0(0)\nunsigned 8 2(2) >> -9(fffffff7) = 0(0)\nunsigned 8 2(2) >> -8(fffffff8) = 0(0)\nunsigned 8 2(2) >> -7(fffffff9) = 0(0)\nunsigned 8 2(2) >> -6(fffffffa) = 0(0)\nunsigned 8 2(2) >> -5(fffffffb) = 0(0)\nunsigned 8 2(2) >> -4(fffffffc) = 0(0)\nunsigned 8 2(2) >> -3(fffffffd) = 0(0)\nunsigned 8 2(2) >> -2(fffffffe) = 0(0)\nunsigned 8 2(2) >> -1(ffffffff) = 0(0)\nunsigned 8 2(2) >> 0(0) = 2(2)\nunsigned 8 2(2) >> 1(1) = 1(1)\nunsigned 8 2(2) >> 2(2) = 0(0)\nunsigned 8 2(2) >> 3(3) = 0(0)\nunsigned 8 2(2) >> 4(4) = 0(0)\nunsigned 8 2(2) >> 5(5) = 0(0)\nunsigned 8 2(2) >> 6(6) = 0(0)\nunsigned 8 2(2) >> 7(7) = 0(0)\nunsigned 8 2(2) >> 8(8) = 0(0)\nunsigned 8 2(2) >> 9(9) = 0(0)\nunsigned 8 2(2) >> 10(a) = 0(0)\nunsigned 8 2(2) >> 11(b) = 0(0)\nunsigned 8 2(2) >> 12(c) = 0(0)\nunsigned 8 2(2) >> 13(d) = 0(0)\nunsigned 8 2(2) >> 14(e) = 0(0)\nunsigned 8 2(2) >> 15(f) = 0(0)\nunsigned 8 2(2) >> 16(10) = 0(0)\nunsigned 8 2(2) >> 17(11) = 0(0)\nunsigned 8 2(2) >> 18(12) = 0(0)\nunsigned 8 2(2) >> 19(13) = 0(0)\nunsigned 8 2(2) >> 20(14) = 0(0)\nunsigned 8 2(2) >> 21(15) = 0(0)\nunsigned 8 2(2) >> 22(16) = 0(0)\nunsigned 8 2(2) >> 23(17) = 0(0)\nunsigned 8 2(2) >> 24(18) = 0(0)\nunsigned 8 2(2) >> 25(19) = 0(0)\nunsigned 8 2(2) >> 26(1a) = 0(0)\nunsigned 8 2(2) >> 27(1b) = 0(0)\nunsigned 8 2(2) >> 28(1c) = 0(0)\nunsigned 8 2(2) >> 29(1d) = 0(0)\nunsigned 8 2(2) >> 30(1e) = 0(0)\nunsigned 8 2(2) >> 31(1f) = 0(0)\nunsigned 8 2(2) >> 32(20) = 2(2)\nunsigned 8 2(2) >> 33(21) = 1(1)\nunsigned 8 2(2) >> 34(22) = 0(0)\nunsigned 8 2(2) >> 35(23) = 0(0)\nunsigned 8 2(2) >> 36(24) = 0(0)\nunsigned 8 2(2) >> 37(25) = 0(0)\nunsigned 8 2(2) >> 38(26) = 0(0)\nunsigned 8 2(2) >> 39(27) = 0(0)\nunsigned 8 2(2) >> 40(28) = 0(0)\nunsigned 8 2(2) >> 41(29) = 0(0)\nunsigned 8 2(2) >> 42(2a) = 0(0)\nunsigned 8 2(2) >> 43(2b) = 0(0)\nunsigned 8 2(2) >> 44(2c) = 0(0)\nunsigned 8 2(2) >> 45(2d) = 0(0)\nunsigned 8 2(2) >> 46(2e) = 0(0)\nunsigned 8 2(2) >> 47(2f) = 0(0)\nunsigned 8 2(2) >> 48(30) = 0(0)\nunsigned 8 2(2) >> 49(31) = 0(0)\nunsigned 8 2(2) >> 50(32) = 0(0)\nunsigned 8 2(2) >> 51(33) = 0(0)\nunsigned 8 2(2) >> 52(34) = 0(0)\nunsigned 8 2(2) >> 53(35) = 0(0)\nunsigned 8 2(2) >> 54(36) = 0(0)\nunsigned 8 2(2) >> 55(37) = 0(0)\nunsigned 8 2(2) >> 56(38) = 0(0)\nunsigned 8 2(2) >> 57(39) = 0(0)\nunsigned 8 2(2) >> 58(3a) = 0(0)\nunsigned 8 2(2) >> 59(3b) = 0(0)\nunsigned 8 2(2) >> 60(3c) = 0(0)\nunsigned 8 2(2) >> 61(3d) = 0(0)\nunsigned 8 2(2) >> 62(3e) = 0(0)\nunsigned 8 2(2) >> 63(3f) = 0(0)\nunsigned 8 2(2) >> 64(40) = 2(2)\nunsigned 8 2(2) >> 65(41) = 1(1)\nunsigned 8 2(2) >> 66(42) = 0(0)\nunsigned 8 2(2) >> 67(43) = 0(0)\nunsigned 8 2(2) >> 68(44) = 0(0)\nunsigned 8 2(2) >> 69(45) = 0(0)\nunsigned 8 2(2) >> 70(46) = 0(0)\nunsigned 8 2(2) >> 71(47) = 0(0)\nunsigned 8 2(2) >> 72(48) = 0(0)\nunsigned 8 2(2) >> 73(49) = 0(0)\nunsigned 8 2(2) >> 74(4a) = 0(0)\nunsigned 8 2(2) >> 75(4b) = 0(0)\nunsigned 8 2(2) >> 76(4c) = 0(0)\nunsigned 8 2(2) >> 77(4d) = 0(0)\nunsigned 8 2(2) >> 78(4e) = 0(0)\nunsigned 8 2(2) >> 79(4f) = 0(0)\nunsigned 8 2(2) >> 80(50) = 0(0)\nunsigned 8 2(2) >> 81(51) = 0(0)\nunsigned 8 2(2) >> 82(52) = 0(0)\nunsigned 8 2(2) >> 83(53) = 0(0)\nunsigned 8 2(2) >> 84(54) = 0(0)\nunsigned 8 2(2) >> 85(55) = 0(0)\nunsigned 8 2(2) >> 86(56) = 0(0)\nunsigned 8 2(2) >> 87(57) = 0(0)\nunsigned 8 2(2) >> 88(58) = 0(0)\nunsigned 8 2(2) >> 89(59) = 0(0)\nunsigned 8 2(2) >> 90(5a) = 0(0)\nunsigned 8 2(2) >> 91(5b) = 0(0)\nunsigned 8 2(2) >> 92(5c) = 0(0)\nunsigned 8 2(2) >> 93(5d) = 0(0)\nunsigned 8 2(2) >> 94(5e) = 0(0)\nunsigned 8 2(2) >> 95(5f) = 0(0)\nunsigned 8 2(2) >> 96(60) = 2(2)\nunsigned 8 2(2) >> 97(61) = 1(1)\nunsigned 8 2(2) >> 98(62) = 0(0)\nunsigned 8 2(2) >> 99(63) = 0(0)\nunsigned 8 2(2) >> 100(64) = 0(0)\nunsigned 8 2(2) >> 101(65) = 0(0)\nunsigned 8 2(2) >> 102(66) = 0(0)\nunsigned 8 2(2) >> 103(67) = 0(0)\nunsigned 8 2(2) >> 104(68) = 0(0)\nunsigned 8 2(2) >> 105(69) = 0(0)\nunsigned 8 2(2) >> 106(6a) = 0(0)\nunsigned 8 2(2) >> 107(6b) = 0(0)\nunsigned 8 2(2) >> 108(6c) = 0(0)\nunsigned 8 2(2) >> 109(6d) = 0(0)\nunsigned 8 2(2) >> 110(6e) = 0(0)\nunsigned 8 2(2) >> 111(6f) = 0(0)\nunsigned 8 2(2) >> 112(70) = 0(0)\nunsigned 8 2(2) >> 113(71) = 0(0)\nunsigned 8 2(2) >> 114(72) = 0(0)\nunsigned 8 2(2) >> 115(73) = 0(0)\nunsigned 8 2(2) >> 116(74) = 0(0)\nunsigned 8 2(2) >> 117(75) = 0(0)\nunsigned 8 2(2) >> 118(76) = 0(0)\nunsigned 8 2(2) >> 119(77) = 0(0)\nunsigned 8 2(2) >> 120(78) = 0(0)\nunsigned 8 2(2) >> 121(79) = 0(0)\nunsigned 8 2(2) >> 122(7a) = 0(0)\nunsigned 8 2(2) >> 123(7b) = 0(0)\nunsigned 8 2(2) >> 124(7c) = 0(0)\nunsigned 8 2(2) >> 125(7d) = 0(0)\nunsigned 8 2(2) >> 126(7e) = 0(0)\nunsigned 8 2(2) >> 127(7f) = 0(0)\nunsigned 8 3(3) >> -128(ffffff80) = 3(3)\nunsigned 8 3(3) >> -127(ffffff81) = 1(1)\nunsigned 8 3(3) >> -126(ffffff82) = 0(0)\nunsigned 8 3(3) >> -125(ffffff83) = 0(0)\nunsigned 8 3(3) >> -124(ffffff84) = 0(0)\nunsigned 8 3(3) >> -123(ffffff85) = 0(0)\nunsigned 8 3(3) >> -122(ffffff86) = 0(0)\nunsigned 8 3(3) >> -121(ffffff87) = 0(0)\nunsigned 8 3(3) >> -120(ffffff88) = 0(0)\nunsigned 8 3(3) >> -119(ffffff89) = 0(0)\nunsigned 8 3(3) >> -118(ffffff8a) = 0(0)\nunsigned 8 3(3) >> -117(ffffff8b) = 0(0)\nunsigned 8 3(3) >> -116(ffffff8c) = 0(0)\nunsigned 8 3(3) >> -115(ffffff8d) = 0(0)\nunsigned 8 3(3) >> -114(ffffff8e) = 0(0)\nunsigned 8 3(3) >> -113(ffffff8f) = 0(0)\nunsigned 8 3(3) >> -112(ffffff90) = 0(0)\nunsigned 8 3(3) >> -111(ffffff91) = 0(0)\nunsigned 8 3(3) >> -110(ffffff92) = 0(0)\nunsigned 8 3(3) >> -109(ffffff93) = 0(0)\nunsigned 8 3(3) >> -108(ffffff94) = 0(0)\nunsigned 8 3(3) >> -107(ffffff95) = 0(0)\nunsigned 8 3(3) >> -106(ffffff96) = 0(0)\nunsigned 8 3(3) >> -105(ffffff97) = 0(0)\nunsigned 8 3(3) >> -104(ffffff98) = 0(0)\nunsigned 8 3(3) >> -103(ffffff99) = 0(0)\nunsigned 8 3(3) >> -102(ffffff9a) = 0(0)\nunsigned 8 3(3) >> -101(ffffff9b) = 0(0)\nunsigned 8 3(3) >> -100(ffffff9c) = 0(0)\nunsigned 8 3(3) >> -99(ffffff9d) = 0(0)\nunsigned 8 3(3) >> -98(ffffff9e) = 0(0)\nunsigned 8 3(3) >> -97(ffffff9f) = 0(0)\nunsigned 8 3(3) >> -96(ffffffa0) = 3(3)\nunsigned 8 3(3) >> -95(ffffffa1) = 1(1)\nunsigned 8 3(3) >> -94(ffffffa2) = 0(0)\nunsigned 8 3(3) >> -93(ffffffa3) = 0(0)\nunsigned 8 3(3) >> -92(ffffffa4) = 0(0)\nunsigned 8 3(3) >> -91(ffffffa5) = 0(0)\nunsigned 8 3(3) >> -90(ffffffa6) = 0(0)\nunsigned 8 3(3) >> -89(ffffffa7) = 0(0)\nunsigned 8 3(3) >> -88(ffffffa8) = 0(0)\nunsigned 8 3(3) >> -87(ffffffa9) = 0(0)\nunsigned 8 3(3) >> -86(ffffffaa) = 0(0)\nunsigned 8 3(3) >> -85(ffffffab) = 0(0)\nunsigned 8 3(3) >> -84(ffffffac) = 0(0)\nunsigned 8 3(3) >> -83(ffffffad) = 0(0)\nunsigned 8 3(3) >> -82(ffffffae) = 0(0)\nunsigned 8 3(3) >> -81(ffffffaf) = 0(0)\nunsigned 8 3(3) >> -80(ffffffb0) = 0(0)\nunsigned 8 3(3) >> -79(ffffffb1) = 0(0)\nunsigned 8 3(3) >> -78(ffffffb2) = 0(0)\nunsigned 8 3(3) >> -77(ffffffb3) = 0(0)\nunsigned 8 3(3) >> -76(ffffffb4) = 0(0)\nunsigned 8 3(3) >> -75(ffffffb5) = 0(0)\nunsigned 8 3(3) >> -74(ffffffb6) = 0(0)\nunsigned 8 3(3) >> -73(ffffffb7) = 0(0)\nunsigned 8 3(3) >> -72(ffffffb8) = 0(0)\nunsigned 8 3(3) >> -71(ffffffb9) = 0(0)\nunsigned 8 3(3) >> -70(ffffffba) = 0(0)\nunsigned 8 3(3) >> -69(ffffffbb) = 0(0)\nunsigned 8 3(3) >> -68(ffffffbc) = 0(0)\nunsigned 8 3(3) >> -67(ffffffbd) = 0(0)\nunsigned 8 3(3) >> -66(ffffffbe) = 0(0)\nunsigned 8 3(3) >> -65(ffffffbf) = 0(0)\nunsigned 8 3(3) >> -64(ffffffc0) = 3(3)\nunsigned 8 3(3) >> -63(ffffffc1) = 1(1)\nunsigned 8 3(3) >> -62(ffffffc2) = 0(0)\nunsigned 8 3(3) >> -61(ffffffc3) = 0(0)\nunsigned 8 3(3) >> -60(ffffffc4) = 0(0)\nunsigned 8 3(3) >> -59(ffffffc5) = 0(0)\nunsigned 8 3(3) >> -58(ffffffc6) = 0(0)\nunsigned 8 3(3) >> -57(ffffffc7) = 0(0)\nunsigned 8 3(3) >> -56(ffffffc8) = 0(0)\nunsigned 8 3(3) >> -55(ffffffc9) = 0(0)\nunsigned 8 3(3) >> -54(ffffffca) = 0(0)\nunsigned 8 3(3) >> -53(ffffffcb) = 0(0)\nunsigned 8 3(3) >> -52(ffffffcc) = 0(0)\nunsigned 8 3(3) >> -51(ffffffcd) = 0(0)\nunsigned 8 3(3) >> -50(ffffffce) = 0(0)\nunsigned 8 3(3) >> -49(ffffffcf) = 0(0)\nunsigned 8 3(3) >> -48(ffffffd0) = 0(0)\nunsigned 8 3(3) >> -47(ffffffd1) = 0(0)\nunsigned 8 3(3) >> -46(ffffffd2) = 0(0)\nunsigned 8 3(3) >> -45(ffffffd3) = 0(0)\nunsigned 8 3(3) >> -44(ffffffd4) = 0(0)\nunsigned 8 3(3) >> -43(ffffffd5) = 0(0)\nunsigned 8 3(3) >> -42(ffffffd6) = 0(0)\nunsigned 8 3(3) >> -41(ffffffd7) = 0(0)\nunsigned 8 3(3) >> -40(ffffffd8) = 0(0)\nunsigned 8 3(3) >> -39(ffffffd9) = 0(0)\nunsigned 8 3(3) >> -38(ffffffda) = 0(0)\nunsigned 8 3(3) >> -37(ffffffdb) = 0(0)\nunsigned 8 3(3) >> -36(ffffffdc) = 0(0)\nunsigned 8 3(3) >> -35(ffffffdd) = 0(0)\nunsigned 8 3(3) >> -34(ffffffde) = 0(0)\nunsigned 8 3(3) >> -33(ffffffdf) = 0(0)\nunsigned 8 3(3) >> -32(ffffffe0) = 3(3)\nunsigned 8 3(3) >> -31(ffffffe1) = 1(1)\nunsigned 8 3(3) >> -30(ffffffe2) = 0(0)\nunsigned 8 3(3) >> -29(ffffffe3) = 0(0)\nunsigned 8 3(3) >> -28(ffffffe4) = 0(0)\nunsigned 8 3(3) >> -27(ffffffe5) = 0(0)\nunsigned 8 3(3) >> -26(ffffffe6) = 0(0)\nunsigned 8 3(3) >> -25(ffffffe7) = 0(0)\nunsigned 8 3(3) >> -24(ffffffe8) = 0(0)\nunsigned 8 3(3) >> -23(ffffffe9) = 0(0)\nunsigned 8 3(3) >> -22(ffffffea) = 0(0)\nunsigned 8 3(3) >> -21(ffffffeb) = 0(0)\nunsigned 8 3(3) >> -20(ffffffec) = 0(0)\nunsigned 8 3(3) >> -19(ffffffed) = 0(0)\nunsigned 8 3(3) >> -18(ffffffee) = 0(0)\nunsigned 8 3(3) >> -17(ffffffef) = 0(0)\nunsigned 8 3(3) >> -16(fffffff0) = 0(0)\nunsigned 8 3(3) >> -15(fffffff1) = 0(0)\nunsigned 8 3(3) >> -14(fffffff2) = 0(0)\nunsigned 8 3(3) >> -13(fffffff3) = 0(0)\nunsigned 8 3(3) >> -12(fffffff4) = 0(0)\nunsigned 8 3(3) >> -11(fffffff5) = 0(0)\nunsigned 8 3(3) >> -10(fffffff6) = 0(0)\nunsigned 8 3(3) >> -9(fffffff7) = 0(0)\nunsigned 8 3(3) >> -8(fffffff8) = 0(0)\nunsigned 8 3(3) >> -7(fffffff9) = 0(0)\nunsigned 8 3(3) >> -6(fffffffa) = 0(0)\nunsigned 8 3(3) >> -5(fffffffb) = 0(0)\nunsigned 8 3(3) >> -4(fffffffc) = 0(0)\nunsigned 8 3(3) >> -3(fffffffd) = 0(0)\nunsigned 8 3(3) >> -2(fffffffe) = 0(0)\nunsigned 8 3(3) >> -1(ffffffff) = 0(0)\nunsigned 8 3(3) >> 0(0) = 3(3)\nunsigned 8 3(3) >> 1(1) = 1(1)\nunsigned 8 3(3) >> 2(2) = 0(0)\nunsigned 8 3(3) >> 3(3) = 0(0)\nunsigned 8 3(3) >> 4(4) = 0(0)\nunsigned 8 3(3) >> 5(5) = 0(0)\nunsigned 8 3(3) >> 6(6) = 0(0)\nunsigned 8 3(3) >> 7(7) = 0(0)\nunsigned 8 3(3) >> 8(8) = 0(0)\nunsigned 8 3(3) >> 9(9) = 0(0)\nunsigned 8 3(3) >> 10(a) = 0(0)\nunsigned 8 3(3) >> 11(b) = 0(0)\nunsigned 8 3(3) >> 12(c) = 0(0)\nunsigned 8 3(3) >> 13(d) = 0(0)\nunsigned 8 3(3) >> 14(e) = 0(0)\nunsigned 8 3(3) >> 15(f) = 0(0)\nunsigned 8 3(3) >> 16(10) = 0(0)\nunsigned 8 3(3) >> 17(11) = 0(0)\nunsigned 8 3(3) >> 18(12) = 0(0)\nunsigned 8 3(3) >> 19(13) = 0(0)\nunsigned 8 3(3) >> 20(14) = 0(0)\nunsigned 8 3(3) >> 21(15) = 0(0)\nunsigned 8 3(3) >> 22(16) = 0(0)\nunsigned 8 3(3) >> 23(17) = 0(0)\nunsigned 8 3(3) >> 24(18) = 0(0)\nunsigned 8 3(3) >> 25(19) = 0(0)\nunsigned 8 3(3) >> 26(1a) = 0(0)\nunsigned 8 3(3) >> 27(1b) = 0(0)\nunsigned 8 3(3) >> 28(1c) = 0(0)\nunsigned 8 3(3) >> 29(1d) = 0(0)\nunsigned 8 3(3) >> 30(1e) = 0(0)\nunsigned 8 3(3) >> 31(1f) = 0(0)\nunsigned 8 3(3) >> 32(20) = 3(3)\nunsigned 8 3(3) >> 33(21) = 1(1)\nunsigned 8 3(3) >> 34(22) = 0(0)\nunsigned 8 3(3) >> 35(23) = 0(0)\nunsigned 8 3(3) >> 36(24) = 0(0)\nunsigned 8 3(3) >> 37(25) = 0(0)\nunsigned 8 3(3) >> 38(26) = 0(0)\nunsigned 8 3(3) >> 39(27) = 0(0)\nunsigned 8 3(3) >> 40(28) = 0(0)\nunsigned 8 3(3) >> 41(29) = 0(0)\nunsigned 8 3(3) >> 42(2a) = 0(0)\nunsigned 8 3(3) >> 43(2b) = 0(0)\nunsigned 8 3(3) >> 44(2c) = 0(0)\nunsigned 8 3(3) >> 45(2d) = 0(0)\nunsigned 8 3(3) >> 46(2e) = 0(0)\nunsigned 8 3(3) >> 47(2f) = 0(0)\nunsigned 8 3(3) >> 48(30) = 0(0)\nunsigned 8 3(3) >> 49(31) = 0(0)\nunsigned 8 3(3) >> 50(32) = 0(0)\nunsigned 8 3(3) >> 51(33) = 0(0)\nunsigned 8 3(3) >> 52(34) = 0(0)\nunsigned 8 3(3) >> 53(35) = 0(0)\nunsigned 8 3(3) >> 54(36) = 0(0)\nunsigned 8 3(3) >> 55(37) = 0(0)\nunsigned 8 3(3) >> 56(38) = 0(0)\nunsigned 8 3(3) >> 57(39) = 0(0)\nunsigned 8 3(3) >> 58(3a) = 0(0)\nunsigned 8 3(3) >> 59(3b) = 0(0)\nunsigned 8 3(3) >> 60(3c) = 0(0)\nunsigned 8 3(3) >> 61(3d) = 0(0)\nunsigned 8 3(3) >> 62(3e) = 0(0)\nunsigned 8 3(3) >> 63(3f) = 0(0)\nunsigned 8 3(3) >> 64(40) = 3(3)\nunsigned 8 3(3) >> 65(41) = 1(1)\nunsigned 8 3(3) >> 66(42) = 0(0)\nunsigned 8 3(3) >> 67(43) = 0(0)\nunsigned 8 3(3) >> 68(44) = 0(0)\nunsigned 8 3(3) >> 69(45) = 0(0)\nunsigned 8 3(3) >> 70(46) = 0(0)\nunsigned 8 3(3) >> 71(47) = 0(0)\nunsigned 8 3(3) >> 72(48) = 0(0)\nunsigned 8 3(3) >> 73(49) = 0(0)\nunsigned 8 3(3) >> 74(4a) = 0(0)\nunsigned 8 3(3) >> 75(4b) = 0(0)\nunsigned 8 3(3) >> 76(4c) = 0(0)\nunsigned 8 3(3) >> 77(4d) = 0(0)\nunsigned 8 3(3) >> 78(4e) = 0(0)\nunsigned 8 3(3) >> 79(4f) = 0(0)\nunsigned 8 3(3) >> 80(50) = 0(0)\nunsigned 8 3(3) >> 81(51) = 0(0)\nunsigned 8 3(3) >> 82(52) = 0(0)\nunsigned 8 3(3) >> 83(53) = 0(0)\nunsigned 8 3(3) >> 84(54) = 0(0)\nunsigned 8 3(3) >> 85(55) = 0(0)\nunsigned 8 3(3) >> 86(56) = 0(0)\nunsigned 8 3(3) >> 87(57) = 0(0)\nunsigned 8 3(3) >> 88(58) = 0(0)\nunsigned 8 3(3) >> 89(59) = 0(0)\nunsigned 8 3(3) >> 90(5a) = 0(0)\nunsigned 8 3(3) >> 91(5b) = 0(0)\nunsigned 8 3(3) >> 92(5c) = 0(0)\nunsigned 8 3(3) >> 93(5d) = 0(0)\nunsigned 8 3(3) >> 94(5e) = 0(0)\nunsigned 8 3(3) >> 95(5f) = 0(0)\nunsigned 8 3(3) >> 96(60) = 3(3)\nunsigned 8 3(3) >> 97(61) = 1(1)\nunsigned 8 3(3) >> 98(62) = 0(0)\nunsigned 8 3(3) >> 99(63) = 0(0)\nunsigned 8 3(3) >> 100(64) = 0(0)\nunsigned 8 3(3) >> 101(65) = 0(0)\nunsigned 8 3(3) >> 102(66) = 0(0)\nunsigned 8 3(3) >> 103(67) = 0(0)\nunsigned 8 3(3) >> 104(68) = 0(0)\nunsigned 8 3(3) >> 105(69) = 0(0)\nunsigned 8 3(3) >> 106(6a) = 0(0)\nunsigned 8 3(3) >> 107(6b) = 0(0)\nunsigned 8 3(3) >> 108(6c) = 0(0)\nunsigned 8 3(3) >> 109(6d) = 0(0)\nunsigned 8 3(3) >> 110(6e) = 0(0)\nunsigned 8 3(3) >> 111(6f) = 0(0)\nunsigned 8 3(3) >> 112(70) = 0(0)\nunsigned 8 3(3) >> 113(71) = 0(0)\nunsigned 8 3(3) >> 114(72) = 0(0)\nunsigned 8 3(3) >> 115(73) = 0(0)\nunsigned 8 3(3) >> 116(74) = 0(0)\nunsigned 8 3(3) >> 117(75) = 0(0)\nunsigned 8 3(3) >> 118(76) = 0(0)\nunsigned 8 3(3) >> 119(77) = 0(0)\nunsigned 8 3(3) >> 120(78) = 0(0)\nunsigned 8 3(3) >> 121(79) = 0(0)\nunsigned 8 3(3) >> 122(7a) = 0(0)\nunsigned 8 3(3) >> 123(7b) = 0(0)\nunsigned 8 3(3) >> 124(7c) = 0(0)\nunsigned 8 3(3) >> 125(7d) = 0(0)\nunsigned 8 3(3) >> 126(7e) = 0(0)\nunsigned 8 3(3) >> 127(7f) = 0(0)\nunsigned 8 4(4) >> -128(ffffff80) = 4(4)\nunsigned 8 4(4) >> -127(ffffff81) = 2(2)\nunsigned 8 4(4) >> -126(ffffff82) = 1(1)\nunsigned 8 4(4) >> -125(ffffff83) = 0(0)\nunsigned 8 4(4) >> -124(ffffff84) = 0(0)\nunsigned 8 4(4) >> -123(ffffff85) = 0(0)\nunsigned 8 4(4) >> -122(ffffff86) = 0(0)\nunsigned 8 4(4) >> -121(ffffff87) = 0(0)\nunsigned 8 4(4) >> -120(ffffff88) = 0(0)\nunsigned 8 4(4) >> -119(ffffff89) = 0(0)\nunsigned 8 4(4) >> -118(ffffff8a) = 0(0)\nunsigned 8 4(4) >> -117(ffffff8b) = 0(0)\nunsigned 8 4(4) >> -116(ffffff8c) = 0(0)\nunsigned 8 4(4) >> -115(ffffff8d) = 0(0)\nunsigned 8 4(4) >> -114(ffffff8e) = 0(0)\nunsigned 8 4(4) >> -113(ffffff8f) = 0(0)\nunsigned 8 4(4) >> -112(ffffff90) = 0(0)\nunsigned 8 4(4) >> -111(ffffff91) = 0(0)\nunsigned 8 4(4) >> -110(ffffff92) = 0(0)\nunsigned 8 4(4) >> -109(ffffff93) = 0(0)\nunsigned 8 4(4) >> -108(ffffff94) = 0(0)\nunsigned 8 4(4) >> -107(ffffff95) = 0(0)\nunsigned 8 4(4) >> -106(ffffff96) = 0(0)\nunsigned 8 4(4) >> -105(ffffff97) = 0(0)\nunsigned 8 4(4) >> -104(ffffff98) = 0(0)\nunsigned 8 4(4) >> -103(ffffff99) = 0(0)\nunsigned 8 4(4) >> -102(ffffff9a) = 0(0)\nunsigned 8 4(4) >> -101(ffffff9b) = 0(0)\nunsigned 8 4(4) >> -100(ffffff9c) = 0(0)\nunsigned 8 4(4) >> -99(ffffff9d) = 0(0)\nunsigned 8 4(4) >> -98(ffffff9e) = 0(0)\nunsigned 8 4(4) >> -97(ffffff9f) = 0(0)\nunsigned 8 4(4) >> -96(ffffffa0) = 4(4)\nunsigned 8 4(4) >> -95(ffffffa1) = 2(2)\nunsigned 8 4(4) >> -94(ffffffa2) = 1(1)\nunsigned 8 4(4) >> -93(ffffffa3) = 0(0)\nunsigned 8 4(4) >> -92(ffffffa4) = 0(0)\nunsigned 8 4(4) >> -91(ffffffa5) = 0(0)\nunsigned 8 4(4) >> -90(ffffffa6) = 0(0)\nunsigned 8 4(4) >> -89(ffffffa7) = 0(0)\nunsigned 8 4(4) >> -88(ffffffa8) = 0(0)\nunsigned 8 4(4) >> -87(ffffffa9) = 0(0)\nunsigned 8 4(4) >> -86(ffffffaa) = 0(0)\nunsigned 8 4(4) >> -85(ffffffab) = 0(0)\nunsigned 8 4(4) >> -84(ffffffac) = 0(0)\nunsigned 8 4(4) >> -83(ffffffad) = 0(0)\nunsigned 8 4(4) >> -82(ffffffae) = 0(0)\nunsigned 8 4(4) >> -81(ffffffaf) = 0(0)\nunsigned 8 4(4) >> -80(ffffffb0) = 0(0)\nunsigned 8 4(4) >> -79(ffffffb1) = 0(0)\nunsigned 8 4(4) >> -78(ffffffb2) = 0(0)\nunsigned 8 4(4) >> -77(ffffffb3) = 0(0)\nunsigned 8 4(4) >> -76(ffffffb4) = 0(0)\nunsigned 8 4(4) >> -75(ffffffb5) = 0(0)\nunsigned 8 4(4) >> -74(ffffffb6) = 0(0)\nunsigned 8 4(4) >> -73(ffffffb7) = 0(0)\nunsigned 8 4(4) >> -72(ffffffb8) = 0(0)\nunsigned 8 4(4) >> -71(ffffffb9) = 0(0)\nunsigned 8 4(4) >> -70(ffffffba) = 0(0)\nunsigned 8 4(4) >> -69(ffffffbb) = 0(0)\nunsigned 8 4(4) >> -68(ffffffbc) = 0(0)\nunsigned 8 4(4) >> -67(ffffffbd) = 0(0)\nunsigned 8 4(4) >> -66(ffffffbe) = 0(0)\nunsigned 8 4(4) >> -65(ffffffbf) = 0(0)\nunsigned 8 4(4) >> -64(ffffffc0) = 4(4)\nunsigned 8 4(4) >> -63(ffffffc1) = 2(2)\nunsigned 8 4(4) >> -62(ffffffc2) = 1(1)\nunsigned 8 4(4) >> -61(ffffffc3) = 0(0)\nunsigned 8 4(4) >> -60(ffffffc4) = 0(0)\nunsigned 8 4(4) >> -59(ffffffc5) = 0(0)\nunsigned 8 4(4) >> -58(ffffffc6) = 0(0)\nunsigned 8 4(4) >> -57(ffffffc7) = 0(0)\nunsigned 8 4(4) >> -56(ffffffc8) = 0(0)\nunsigned 8 4(4) >> -55(ffffffc9) = 0(0)\nunsigned 8 4(4) >> -54(ffffffca) = 0(0)\nunsigned 8 4(4) >> -53(ffffffcb) = 0(0)\nunsigned 8 4(4) >> -52(ffffffcc) = 0(0)\nunsigned 8 4(4) >> -51(ffffffcd) = 0(0)\nunsigned 8 4(4) >> -50(ffffffce) = 0(0)\nunsigned 8 4(4) >> -49(ffffffcf) = 0(0)\nunsigned 8 4(4) >> -48(ffffffd0) = 0(0)\nunsigned 8 4(4) >> -47(ffffffd1) = 0(0)\nunsigned 8 4(4) >> -46(ffffffd2) = 0(0)\nunsigned 8 4(4) >> -45(ffffffd3) = 0(0)\nunsigned 8 4(4) >> -44(ffffffd4) = 0(0)\nunsigned 8 4(4) >> -43(ffffffd5) = 0(0)\nunsigned 8 4(4) >> -42(ffffffd6) = 0(0)\nunsigned 8 4(4) >> -41(ffffffd7) = 0(0)\nunsigned 8 4(4) >> -40(ffffffd8) = 0(0)\nunsigned 8 4(4) >> -39(ffffffd9) = 0(0)\nunsigned 8 4(4) >> -38(ffffffda) = 0(0)\nunsigned 8 4(4) >> -37(ffffffdb) = 0(0)\nunsigned 8 4(4) >> -36(ffffffdc) = 0(0)\nunsigned 8 4(4) >> -35(ffffffdd) = 0(0)\nunsigned 8 4(4) >> -34(ffffffde) = 0(0)\nunsigned 8 4(4) >> -33(ffffffdf) = 0(0)\nunsigned 8 4(4) >> -32(ffffffe0) = 4(4)\nunsigned 8 4(4) >> -31(ffffffe1) = 2(2)\nunsigned 8 4(4) >> -30(ffffffe2) = 1(1)\nunsigned 8 4(4) >> -29(ffffffe3) = 0(0)\nunsigned 8 4(4) >> -28(ffffffe4) = 0(0)\nunsigned 8 4(4) >> -27(ffffffe5) = 0(0)\nunsigned 8 4(4) >> -26(ffffffe6) = 0(0)\nunsigned 8 4(4) >> -25(ffffffe7) = 0(0)\nunsigned 8 4(4) >> -24(ffffffe8) = 0(0)\nunsigned 8 4(4) >> -23(ffffffe9) = 0(0)\nunsigned 8 4(4) >> -22(ffffffea) = 0(0)\nunsigned 8 4(4) >> -21(ffffffeb) = 0(0)\nunsigned 8 4(4) >> -20(ffffffec) = 0(0)\nunsigned 8 4(4) >> -19(ffffffed) = 0(0)\nunsigned 8 4(4) >> -18(ffffffee) = 0(0)\nunsigned 8 4(4) >> -17(ffffffef) = 0(0)\nunsigned 8 4(4) >> -16(fffffff0) = 0(0)\nunsigned 8 4(4) >> -15(fffffff1) = 0(0)\nunsigned 8 4(4) >> -14(fffffff2) = 0(0)\nunsigned 8 4(4) >> -13(fffffff3) = 0(0)\nunsigned 8 4(4) >> -12(fffffff4) = 0(0)\nunsigned 8 4(4) >> -11(fffffff5) = 0(0)\nunsigned 8 4(4) >> -10(fffffff6) = 0(0)\nunsigned 8 4(4) >> -9(fffffff7) = 0(0)\nunsigned 8 4(4) >> -8(fffffff8) = 0(0)\nunsigned 8 4(4) >> -7(fffffff9) = 0(0)\nunsigned 8 4(4) >> -6(fffffffa) = 0(0)\nunsigned 8 4(4) >> -5(fffffffb) = 0(0)\nunsigned 8 4(4) >> -4(fffffffc) = 0(0)\nunsigned 8 4(4) >> -3(fffffffd) = 0(0)\nunsigned 8 4(4) >> -2(fffffffe) = 0(0)\nunsigned 8 4(4) >> -1(ffffffff) = 0(0)\nunsigned 8 4(4) >> 0(0) = 4(4)\nunsigned 8 4(4) >> 1(1) = 2(2)\nunsigned 8 4(4) >> 2(2) = 1(1)\nunsigned 8 4(4) >> 3(3) = 0(0)\nunsigned 8 4(4) >> 4(4) = 0(0)\nunsigned 8 4(4) >> 5(5) = 0(0)\nunsigned 8 4(4) >> 6(6) = 0(0)\nunsigned 8 4(4) >> 7(7) = 0(0)\nunsigned 8 4(4) >> 8(8) = 0(0)\nunsigned 8 4(4) >> 9(9) = 0(0)\nunsigned 8 4(4) >> 10(a) = 0(0)\nunsigned 8 4(4) >> 11(b) = 0(0)\nunsigned 8 4(4) >> 12(c) = 0(0)\nunsigned 8 4(4) >> 13(d) = 0(0)\nunsigned 8 4(4) >> 14(e) = 0(0)\nunsigned 8 4(4) >> 15(f) = 0(0)\nunsigned 8 4(4) >> 16(10) = 0(0)\nunsigned 8 4(4) >> 17(11) = 0(0)\nunsigned 8 4(4) >> 18(12) = 0(0)\nunsigned 8 4(4) >> 19(13) = 0(0)\nunsigned 8 4(4) >> 20(14) = 0(0)\nunsigned 8 4(4) >> 21(15) = 0(0)\nunsigned 8 4(4) >> 22(16) = 0(0)\nunsigned 8 4(4) >> 23(17) = 0(0)\nunsigned 8 4(4) >> 24(18) = 0(0)\nunsigned 8 4(4) >> 25(19) = 0(0)\nunsigned 8 4(4) >> 26(1a) = 0(0)\nunsigned 8 4(4) >> 27(1b) = 0(0)\nunsigned 8 4(4) >> 28(1c) = 0(0)\nunsigned 8 4(4) >> 29(1d) = 0(0)\nunsigned 8 4(4) >> 30(1e) = 0(0)\nunsigned 8 4(4) >> 31(1f) = 0(0)\nunsigned 8 4(4) >> 32(20) = 4(4)\nunsigned 8 4(4) >> 33(21) = 2(2)\nunsigned 8 4(4) >> 34(22) = 1(1)\nunsigned 8 4(4) >> 35(23) = 0(0)\nunsigned 8 4(4) >> 36(24) = 0(0)\nunsigned 8 4(4) >> 37(25) = 0(0)\nunsigned 8 4(4) >> 38(26) = 0(0)\nunsigned 8 4(4) >> 39(27) = 0(0)\nunsigned 8 4(4) >> 40(28) = 0(0)\nunsigned 8 4(4) >> 41(29) = 0(0)\nunsigned 8 4(4) >> 42(2a) = 0(0)\nunsigned 8 4(4) >> 43(2b) = 0(0)\nunsigned 8 4(4) >> 44(2c) = 0(0)\nunsigned 8 4(4) >> 45(2d) = 0(0)\nunsigned 8 4(4) >> 46(2e) = 0(0)\nunsigned 8 4(4) >> 47(2f) = 0(0)\nunsigned 8 4(4) >> 48(30) = 0(0)\nunsigned 8 4(4) >> 49(31) = 0(0)\nunsigned 8 4(4) >> 50(32) = 0(0)\nunsigned 8 4(4) >> 51(33) = 0(0)\nunsigned 8 4(4) >> 52(34) = 0(0)\nunsigned 8 4(4) >> 53(35) = 0(0)\nunsigned 8 4(4) >> 54(36) = 0(0)\nunsigned 8 4(4) >> 55(37) = 0(0)\nunsigned 8 4(4) >> 56(38) = 0(0)\nunsigned 8 4(4) >> 57(39) = 0(0)\nunsigned 8 4(4) >> 58(3a) = 0(0)\nunsigned 8 4(4) >> 59(3b) = 0(0)\nunsigned 8 4(4) >> 60(3c) = 0(0)\nunsigned 8 4(4) >> 61(3d) = 0(0)\nunsigned 8 4(4) >> 62(3e) = 0(0)\nunsigned 8 4(4) >> 63(3f) = 0(0)\nunsigned 8 4(4) >> 64(40) = 4(4)\nunsigned 8 4(4) >> 65(41) = 2(2)\nunsigned 8 4(4) >> 66(42) = 1(1)\nunsigned 8 4(4) >> 67(43) = 0(0)\nunsigned 8 4(4) >> 68(44) = 0(0)\nunsigned 8 4(4) >> 69(45) = 0(0)\nunsigned 8 4(4) >> 70(46) = 0(0)\nunsigned 8 4(4) >> 71(47) = 0(0)\nunsigned 8 4(4) >> 72(48) = 0(0)\nunsigned 8 4(4) >> 73(49) = 0(0)\nunsigned 8 4(4) >> 74(4a) = 0(0)\nunsigned 8 4(4) >> 75(4b) = 0(0)\nunsigned 8 4(4) >> 76(4c) = 0(0)\nunsigned 8 4(4) >> 77(4d) = 0(0)\nunsigned 8 4(4) >> 78(4e) = 0(0)\nunsigned 8 4(4) >> 79(4f) = 0(0)\nunsigned 8 4(4) >> 80(50) = 0(0)\nunsigned 8 4(4) >> 81(51) = 0(0)\nunsigned 8 4(4) >> 82(52) = 0(0)\nunsigned 8 4(4) >> 83(53) = 0(0)\nunsigned 8 4(4) >> 84(54) = 0(0)\nunsigned 8 4(4) >> 85(55) = 0(0)\nunsigned 8 4(4) >> 86(56) = 0(0)\nunsigned 8 4(4) >> 87(57) = 0(0)\nunsigned 8 4(4) >> 88(58) = 0(0)\nunsigned 8 4(4) >> 89(59) = 0(0)\nunsigned 8 4(4) >> 90(5a) = 0(0)\nunsigned 8 4(4) >> 91(5b) = 0(0)\nunsigned 8 4(4) >> 92(5c) = 0(0)\nunsigned 8 4(4) >> 93(5d) = 0(0)\nunsigned 8 4(4) >> 94(5e) = 0(0)\nunsigned 8 4(4) >> 95(5f) = 0(0)\nunsigned 8 4(4) >> 96(60) = 4(4)\nunsigned 8 4(4) >> 97(61) = 2(2)\nunsigned 8 4(4) >> 98(62) = 1(1)\nunsigned 8 4(4) >> 99(63) = 0(0)\nunsigned 8 4(4) >> 100(64) = 0(0)\nunsigned 8 4(4) >> 101(65) = 0(0)\nunsigned 8 4(4) >> 102(66) = 0(0)\nunsigned 8 4(4) >> 103(67) = 0(0)\nunsigned 8 4(4) >> 104(68) = 0(0)\nunsigned 8 4(4) >> 105(69) = 0(0)\nunsigned 8 4(4) >> 106(6a) = 0(0)\nunsigned 8 4(4) >> 107(6b) = 0(0)\nunsigned 8 4(4) >> 108(6c) = 0(0)\nunsigned 8 4(4) >> 109(6d) = 0(0)\nunsigned 8 4(4) >> 110(6e) = 0(0)\nunsigned 8 4(4) >> 111(6f) = 0(0)\nunsigned 8 4(4) >> 112(70) = 0(0)\nunsigned 8 4(4) >> 113(71) = 0(0)\nunsigned 8 4(4) >> 114(72) = 0(0)\nunsigned 8 4(4) >> 115(73) = 0(0)\nunsigned 8 4(4) >> 116(74) = 0(0)\nunsigned 8 4(4) >> 117(75) = 0(0)\nunsigned 8 4(4) >> 118(76) = 0(0)\nunsigned 8 4(4) >> 119(77) = 0(0)\nunsigned 8 4(4) >> 120(78) = 0(0)\nunsigned 8 4(4) >> 121(79) = 0(0)\nunsigned 8 4(4) >> 122(7a) = 0(0)\nunsigned 8 4(4) >> 123(7b) = 0(0)\nunsigned 8 4(4) >> 124(7c) = 0(0)\nunsigned 8 4(4) >> 125(7d) = 0(0)\nunsigned 8 4(4) >> 126(7e) = 0(0)\nunsigned 8 4(4) >> 127(7f) = 0(0)\n  signed 8 -4(fffc) << -128(ffffff80) = -4(fffc)\n  signed 8 -4(fffc) << -127(ffffff81) = -8(fff8)\n  signed 8 -4(fffc) << -126(ffffff82) = -16(fff0)\n  signed 8 -4(fffc) << -125(ffffff83) = -32(ffe0)\n  signed 8 -4(fffc) << -124(ffffff84) = -64(ffc0)\n  signed 8 -4(fffc) << -123(ffffff85) = -128(ff80)\n  signed 8 -4(fffc) << -122(ffffff86) = -256(ff00)\n  signed 8 -4(fffc) << -121(ffffff87) = -512(fe00)\n  signed 8 -4(fffc) << -120(ffffff88) = -1024(fc00)\n  signed 8 -4(fffc) << -119(ffffff89) = -2048(f800)\n  signed 8 -4(fffc) << -118(ffffff8a) = -4096(f000)\n  signed 8 -4(fffc) << -117(ffffff8b) = -8192(e000)\n  signed 8 -4(fffc) << -116(ffffff8c) = -16384(c000)\n  signed 8 -4(fffc) << -115(ffffff8d) = -32768(8000)\n  signed 8 -4(fffc) << -114(ffffff8e) = -65536(0)\n  signed 8 -4(fffc) << -113(ffffff8f) = -131072(0)\n  signed 8 -4(fffc) << -112(ffffff90) = -262144(0)\n  signed 8 -4(fffc) << -111(ffffff91) = -524288(0)\n  signed 8 -4(fffc) << -110(ffffff92) = -1048576(0)\n  signed 8 -4(fffc) << -109(ffffff93) = -2097152(0)\n  signed 8 -4(fffc) << -108(ffffff94) = -4194304(0)\n  signed 8 -4(fffc) << -107(ffffff95) = -8388608(0)\n  signed 8 -4(fffc) << -106(ffffff96) = -16777216(0)\n  signed 8 -4(fffc) << -105(ffffff97) = -33554432(0)\n  signed 8 -4(fffc) << -104(ffffff98) = -67108864(0)\n  signed 8 -4(fffc) << -103(ffffff99) = -134217728(0)\n  signed 8 -4(fffc) << -102(ffffff9a) = -268435456(0)\n  signed 8 -4(fffc) << -101(ffffff9b) = -536870912(0)\n  signed 8 -4(fffc) << -100(ffffff9c) = -1073741824(0)\n  signed 8 -4(fffc) << -99(ffffff9d) = -2147483648(0)\n  signed 8 -4(fffc) << -98(ffffff9e) = 0(0)\n  signed 8 -4(fffc) << -97(ffffff9f) = 0(0)\n  signed 8 -4(fffc) << -96(ffffffa0) = -4(fffc)\n  signed 8 -4(fffc) << -95(ffffffa1) = -8(fff8)\n  signed 8 -4(fffc) << -94(ffffffa2) = -16(fff0)\n  signed 8 -4(fffc) << -93(ffffffa3) = -32(ffe0)\n  signed 8 -4(fffc) << -92(ffffffa4) = -64(ffc0)\n  signed 8 -4(fffc) << -91(ffffffa5) = -128(ff80)\n  signed 8 -4(fffc) << -90(ffffffa6) = -256(ff00)\n  signed 8 -4(fffc) << -89(ffffffa7) = -512(fe00)\n  signed 8 -4(fffc) << -88(ffffffa8) = -1024(fc00)\n  signed 8 -4(fffc) << -87(ffffffa9) = -2048(f800)\n  signed 8 -4(fffc) << -86(ffffffaa) = -4096(f000)\n  signed 8 -4(fffc) << -85(ffffffab) = -8192(e000)\n  signed 8 -4(fffc) << -84(ffffffac) = -16384(c000)\n  signed 8 -4(fffc) << -83(ffffffad) = -32768(8000)\n  signed 8 -4(fffc) << -82(ffffffae) = -65536(0)\n  signed 8 -4(fffc) << -81(ffffffaf) = -131072(0)\n  signed 8 -4(fffc) << -80(ffffffb0) = -262144(0)\n  signed 8 -4(fffc) << -79(ffffffb1) = -524288(0)\n  signed 8 -4(fffc) << -78(ffffffb2) = -1048576(0)\n  signed 8 -4(fffc) << -77(ffffffb3) = -2097152(0)\n  signed 8 -4(fffc) << -76(ffffffb4) = -4194304(0)\n  signed 8 -4(fffc) << -75(ffffffb5) = -8388608(0)\n  signed 8 -4(fffc) << -74(ffffffb6) = -16777216(0)\n  signed 8 -4(fffc) << -73(ffffffb7) = -33554432(0)\n  signed 8 -4(fffc) << -72(ffffffb8) = -67108864(0)\n  signed 8 -4(fffc) << -71(ffffffb9) = -134217728(0)\n  signed 8 -4(fffc) << -70(ffffffba) = -268435456(0)\n  signed 8 -4(fffc) << -69(ffffffbb) = -536870912(0)\n  signed 8 -4(fffc) << -68(ffffffbc) = -1073741824(0)\n  signed 8 -4(fffc) << -67(ffffffbd) = -2147483648(0)\n  signed 8 -4(fffc) << -66(ffffffbe) = 0(0)\n  signed 8 -4(fffc) << -65(ffffffbf) = 0(0)\n  signed 8 -4(fffc) << -64(ffffffc0) = -4(fffc)\n  signed 8 -4(fffc) << -63(ffffffc1) = -8(fff8)\n  signed 8 -4(fffc) << -62(ffffffc2) = -16(fff0)\n  signed 8 -4(fffc) << -61(ffffffc3) = -32(ffe0)\n  signed 8 -4(fffc) << -60(ffffffc4) = -64(ffc0)\n  signed 8 -4(fffc) << -59(ffffffc5) = -128(ff80)\n  signed 8 -4(fffc) << -58(ffffffc6) = -256(ff00)\n  signed 8 -4(fffc) << -57(ffffffc7) = -512(fe00)\n  signed 8 -4(fffc) << -56(ffffffc8) = -1024(fc00)\n  signed 8 -4(fffc) << -55(ffffffc9) = -2048(f800)\n  signed 8 -4(fffc) << -54(ffffffca) = -4096(f000)\n  signed 8 -4(fffc) << -53(ffffffcb) = -8192(e000)\n  signed 8 -4(fffc) << -52(ffffffcc) = -16384(c000)\n  signed 8 -4(fffc) << -51(ffffffcd) = -32768(8000)\n  signed 8 -4(fffc) << -50(ffffffce) = -65536(0)\n  signed 8 -4(fffc) << -49(ffffffcf) = -131072(0)\n  signed 8 -4(fffc) << -48(ffffffd0) = -262144(0)\n  signed 8 -4(fffc) << -47(ffffffd1) = -524288(0)\n  signed 8 -4(fffc) << -46(ffffffd2) = -1048576(0)\n  signed 8 -4(fffc) << -45(ffffffd3) = -2097152(0)\n  signed 8 -4(fffc) << -44(ffffffd4) = -4194304(0)\n  signed 8 -4(fffc) << -43(ffffffd5) = -8388608(0)\n  signed 8 -4(fffc) << -42(ffffffd6) = -16777216(0)\n  signed 8 -4(fffc) << -41(ffffffd7) = -33554432(0)\n  signed 8 -4(fffc) << -40(ffffffd8) = -67108864(0)\n  signed 8 -4(fffc) << -39(ffffffd9) = -134217728(0)\n  signed 8 -4(fffc) << -38(ffffffda) = -268435456(0)\n  signed 8 -4(fffc) << -37(ffffffdb) = -536870912(0)\n  signed 8 -4(fffc) << -36(ffffffdc) = -1073741824(0)\n  signed 8 -4(fffc) << -35(ffffffdd) = -2147483648(0)\n  signed 8 -4(fffc) << -34(ffffffde) = 0(0)\n  signed 8 -4(fffc) << -33(ffffffdf) = 0(0)\n  signed 8 -4(fffc) << -32(ffffffe0) = -4(fffc)\n  signed 8 -4(fffc) << -31(ffffffe1) = -8(fff8)\n  signed 8 -4(fffc) << -30(ffffffe2) = -16(fff0)\n  signed 8 -4(fffc) << -29(ffffffe3) = -32(ffe0)\n  signed 8 -4(fffc) << -28(ffffffe4) = -64(ffc0)\n  signed 8 -4(fffc) << -27(ffffffe5) = -128(ff80)\n  signed 8 -4(fffc) << -26(ffffffe6) = -256(ff00)\n  signed 8 -4(fffc) << -25(ffffffe7) = -512(fe00)\n  signed 8 -4(fffc) << -24(ffffffe8) = -1024(fc00)\n  signed 8 -4(fffc) << -23(ffffffe9) = -2048(f800)\n  signed 8 -4(fffc) << -22(ffffffea) = -4096(f000)\n  signed 8 -4(fffc) << -21(ffffffeb) = -8192(e000)\n  signed 8 -4(fffc) << -20(ffffffec) = -16384(c000)\n  signed 8 -4(fffc) << -19(ffffffed) = -32768(8000)\n  signed 8 -4(fffc) << -18(ffffffee) = -65536(0)\n  signed 8 -4(fffc) << -17(ffffffef) = -131072(0)\n  signed 8 -4(fffc) << -16(fffffff0) = -262144(0)\n  signed 8 -4(fffc) << -15(fffffff1) = -524288(0)\n  signed 8 -4(fffc) << -14(fffffff2) = -1048576(0)\n  signed 8 -4(fffc) << -13(fffffff3) = -2097152(0)\n  signed 8 -4(fffc) << -12(fffffff4) = -4194304(0)\n  signed 8 -4(fffc) << -11(fffffff5) = -8388608(0)\n  signed 8 -4(fffc) << -10(fffffff6) = -16777216(0)\n  signed 8 -4(fffc) << -9(fffffff7) = -33554432(0)\n  signed 8 -4(fffc) << -8(fffffff8) = -67108864(0)\n  signed 8 -4(fffc) << -7(fffffff9) = -134217728(0)\n  signed 8 -4(fffc) << -6(fffffffa) = -268435456(0)\n  signed 8 -4(fffc) << -5(fffffffb) = -536870912(0)\n  signed 8 -4(fffc) << -4(fffffffc) = -1073741824(0)\n  signed 8 -4(fffc) << -3(fffffffd) = -2147483648(0)\n  signed 8 -4(fffc) << -2(fffffffe) = 0(0)\n  signed 8 -4(fffc) << -1(ffffffff) = 0(0)\n  signed 8 -4(fffc) << 0(0) = -4(fffc)\n  signed 8 -4(fffc) << 1(1) = -8(fff8)\n  signed 8 -4(fffc) << 2(2) = -16(fff0)\n  signed 8 -4(fffc) << 3(3) = -32(ffe0)\n  signed 8 -4(fffc) << 4(4) = -64(ffc0)\n  signed 8 -4(fffc) << 5(5) = -128(ff80)\n  signed 8 -4(fffc) << 6(6) = -256(ff00)\n  signed 8 -4(fffc) << 7(7) = -512(fe00)\n  signed 8 -4(fffc) << 8(8) = -1024(fc00)\n  signed 8 -4(fffc) << 9(9) = -2048(f800)\n  signed 8 -4(fffc) << 10(a) = -4096(f000)\n  signed 8 -4(fffc) << 11(b) = -8192(e000)\n  signed 8 -4(fffc) << 12(c) = -16384(c000)\n  signed 8 -4(fffc) << 13(d) = -32768(8000)\n  signed 8 -4(fffc) << 14(e) = -65536(0)\n  signed 8 -4(fffc) << 15(f) = -131072(0)\n  signed 8 -4(fffc) << 16(10) = -262144(0)\n  signed 8 -4(fffc) << 17(11) = -524288(0)\n  signed 8 -4(fffc) << 18(12) = -1048576(0)\n  signed 8 -4(fffc) << 19(13) = -2097152(0)\n  signed 8 -4(fffc) << 20(14) = -4194304(0)\n  signed 8 -4(fffc) << 21(15) = -8388608(0)\n  signed 8 -4(fffc) << 22(16) = -16777216(0)\n  signed 8 -4(fffc) << 23(17) = -33554432(0)\n  signed 8 -4(fffc) << 24(18) = -67108864(0)\n  signed 8 -4(fffc) << 25(19) = -134217728(0)\n  signed 8 -4(fffc) << 26(1a) = -268435456(0)\n  signed 8 -4(fffc) << 27(1b) = -536870912(0)\n  signed 8 -4(fffc) << 28(1c) = -1073741824(0)\n  signed 8 -4(fffc) << 29(1d) = -2147483648(0)\n  signed 8 -4(fffc) << 30(1e) = 0(0)\n  signed 8 -4(fffc) << 31(1f) = 0(0)\n  signed 8 -4(fffc) << 32(20) = -4(fffc)\n  signed 8 -4(fffc) << 33(21) = -8(fff8)\n  signed 8 -4(fffc) << 34(22) = -16(fff0)\n  signed 8 -4(fffc) << 35(23) = -32(ffe0)\n  signed 8 -4(fffc) << 36(24) = -64(ffc0)\n  signed 8 -4(fffc) << 37(25) = -128(ff80)\n  signed 8 -4(fffc) << 38(26) = -256(ff00)\n  signed 8 -4(fffc) << 39(27) = -512(fe00)\n  signed 8 -4(fffc) << 40(28) = -1024(fc00)\n  signed 8 -4(fffc) << 41(29) = -2048(f800)\n  signed 8 -4(fffc) << 42(2a) = -4096(f000)\n  signed 8 -4(fffc) << 43(2b) = -8192(e000)\n  signed 8 -4(fffc) << 44(2c) = -16384(c000)\n  signed 8 -4(fffc) << 45(2d) = -32768(8000)\n  signed 8 -4(fffc) << 46(2e) = -65536(0)\n  signed 8 -4(fffc) << 47(2f) = -131072(0)\n  signed 8 -4(fffc) << 48(30) = -262144(0)\n  signed 8 -4(fffc) << 49(31) = -524288(0)\n  signed 8 -4(fffc) << 50(32) = -1048576(0)\n  signed 8 -4(fffc) << 51(33) = -2097152(0)\n  signed 8 -4(fffc) << 52(34) = -4194304(0)\n  signed 8 -4(fffc) << 53(35) = -8388608(0)\n  signed 8 -4(fffc) << 54(36) = -16777216(0)\n  signed 8 -4(fffc) << 55(37) = -33554432(0)\n  signed 8 -4(fffc) << 56(38) = -67108864(0)\n  signed 8 -4(fffc) << 57(39) = -134217728(0)\n  signed 8 -4(fffc) << 58(3a) = -268435456(0)\n  signed 8 -4(fffc) << 59(3b) = -536870912(0)\n  signed 8 -4(fffc) << 60(3c) = -1073741824(0)\n  signed 8 -4(fffc) << 61(3d) = -2147483648(0)\n  signed 8 -4(fffc) << 62(3e) = 0(0)\n  signed 8 -4(fffc) << 63(3f) = 0(0)\n  signed 8 -4(fffc) << 64(40) = -4(fffc)\n  signed 8 -4(fffc) << 65(41) = -8(fff8)\n  signed 8 -4(fffc) << 66(42) = -16(fff0)\n  signed 8 -4(fffc) << 67(43) = -32(ffe0)\n  signed 8 -4(fffc) << 68(44) = -64(ffc0)\n  signed 8 -4(fffc) << 69(45) = -128(ff80)\n  signed 8 -4(fffc) << 70(46) = -256(ff00)\n  signed 8 -4(fffc) << 71(47) = -512(fe00)\n  signed 8 -4(fffc) << 72(48) = -1024(fc00)\n  signed 8 -4(fffc) << 73(49) = -2048(f800)\n  signed 8 -4(fffc) << 74(4a) = -4096(f000)\n  signed 8 -4(fffc) << 75(4b) = -8192(e000)\n  signed 8 -4(fffc) << 76(4c) = -16384(c000)\n  signed 8 -4(fffc) << 77(4d) = -32768(8000)\n  signed 8 -4(fffc) << 78(4e) = -65536(0)\n  signed 8 -4(fffc) << 79(4f) = -131072(0)\n  signed 8 -4(fffc) << 80(50) = -262144(0)\n  signed 8 -4(fffc) << 81(51) = -524288(0)\n  signed 8 -4(fffc) << 82(52) = -1048576(0)\n  signed 8 -4(fffc) << 83(53) = -2097152(0)\n  signed 8 -4(fffc) << 84(54) = -4194304(0)\n  signed 8 -4(fffc) << 85(55) = -8388608(0)\n  signed 8 -4(fffc) << 86(56) = -16777216(0)\n  signed 8 -4(fffc) << 87(57) = -33554432(0)\n  signed 8 -4(fffc) << 88(58) = -67108864(0)\n  signed 8 -4(fffc) << 89(59) = -134217728(0)\n  signed 8 -4(fffc) << 90(5a) = -268435456(0)\n  signed 8 -4(fffc) << 91(5b) = -536870912(0)\n  signed 8 -4(fffc) << 92(5c) = -1073741824(0)\n  signed 8 -4(fffc) << 93(5d) = -2147483648(0)\n  signed 8 -4(fffc) << 94(5e) = 0(0)\n  signed 8 -4(fffc) << 95(5f) = 0(0)\n  signed 8 -4(fffc) << 96(60) = -4(fffc)\n  signed 8 -4(fffc) << 97(61) = -8(fff8)\n  signed 8 -4(fffc) << 98(62) = -16(fff0)\n  signed 8 -4(fffc) << 99(63) = -32(ffe0)\n  signed 8 -4(fffc) << 100(64) = -64(ffc0)\n  signed 8 -4(fffc) << 101(65) = -128(ff80)\n  signed 8 -4(fffc) << 102(66) = -256(ff00)\n  signed 8 -4(fffc) << 103(67) = -512(fe00)\n  signed 8 -4(fffc) << 104(68) = -1024(fc00)\n  signed 8 -4(fffc) << 105(69) = -2048(f800)\n  signed 8 -4(fffc) << 106(6a) = -4096(f000)\n  signed 8 -4(fffc) << 107(6b) = -8192(e000)\n  signed 8 -4(fffc) << 108(6c) = -16384(c000)\n  signed 8 -4(fffc) << 109(6d) = -32768(8000)\n  signed 8 -4(fffc) << 110(6e) = -65536(0)\n  signed 8 -4(fffc) << 111(6f) = -131072(0)\n  signed 8 -4(fffc) << 112(70) = -262144(0)\n  signed 8 -4(fffc) << 113(71) = -524288(0)\n  signed 8 -4(fffc) << 114(72) = -1048576(0)\n  signed 8 -4(fffc) << 115(73) = -2097152(0)\n  signed 8 -4(fffc) << 116(74) = -4194304(0)\n  signed 8 -4(fffc) << 117(75) = -8388608(0)\n  signed 8 -4(fffc) << 118(76) = -16777216(0)\n  signed 8 -4(fffc) << 119(77) = -33554432(0)\n  signed 8 -4(fffc) << 120(78) = -67108864(0)\n  signed 8 -4(fffc) << 121(79) = -134217728(0)\n  signed 8 -4(fffc) << 122(7a) = -268435456(0)\n  signed 8 -4(fffc) << 123(7b) = -536870912(0)\n  signed 8 -4(fffc) << 124(7c) = -1073741824(0)\n  signed 8 -4(fffc) << 125(7d) = -2147483648(0)\n  signed 8 -4(fffc) << 126(7e) = 0(0)\n  signed 8 -4(fffc) << 127(7f) = 0(0)\n  signed 8 -3(fffd) << -128(ffffff80) = -3(fffd)\n  signed 8 -3(fffd) << -127(ffffff81) = -6(fffa)\n  signed 8 -3(fffd) << -126(ffffff82) = -12(fff4)\n  signed 8 -3(fffd) << -125(ffffff83) = -24(ffe8)\n  signed 8 -3(fffd) << -124(ffffff84) = -48(ffd0)\n  signed 8 -3(fffd) << -123(ffffff85) = -96(ffa0)\n  signed 8 -3(fffd) << -122(ffffff86) = -192(ff40)\n  signed 8 -3(fffd) << -121(ffffff87) = -384(fe80)\n  signed 8 -3(fffd) << -120(ffffff88) = -768(fd00)\n  signed 8 -3(fffd) << -119(ffffff89) = -1536(fa00)\n  signed 8 -3(fffd) << -118(ffffff8a) = -3072(f400)\n  signed 8 -3(fffd) << -117(ffffff8b) = -6144(e800)\n  signed 8 -3(fffd) << -116(ffffff8c) = -12288(d000)\n  signed 8 -3(fffd) << -115(ffffff8d) = -24576(a000)\n  signed 8 -3(fffd) << -114(ffffff8e) = -49152(4000)\n  signed 8 -3(fffd) << -113(ffffff8f) = -98304(8000)\n  signed 8 -3(fffd) << -112(ffffff90) = -196608(0)\n  signed 8 -3(fffd) << -111(ffffff91) = -393216(0)\n  signed 8 -3(fffd) << -110(ffffff92) = -786432(0)\n  signed 8 -3(fffd) << -109(ffffff93) = -1572864(0)\n  signed 8 -3(fffd) << -108(ffffff94) = -3145728(0)\n  signed 8 -3(fffd) << -107(ffffff95) = -6291456(0)\n  signed 8 -3(fffd) << -106(ffffff96) = -12582912(0)\n  signed 8 -3(fffd) << -105(ffffff97) = -25165824(0)\n  signed 8 -3(fffd) << -104(ffffff98) = -50331648(0)\n  signed 8 -3(fffd) << -103(ffffff99) = -100663296(0)\n  signed 8 -3(fffd) << -102(ffffff9a) = -201326592(0)\n  signed 8 -3(fffd) << -101(ffffff9b) = -402653184(0)\n  signed 8 -3(fffd) << -100(ffffff9c) = -805306368(0)\n  signed 8 -3(fffd) << -99(ffffff9d) = -1610612736(0)\n  signed 8 -3(fffd) << -98(ffffff9e) = 1073741824(0)\n  signed 8 -3(fffd) << -97(ffffff9f) = -2147483648(0)\n  signed 8 -3(fffd) << -96(ffffffa0) = -3(fffd)\n  signed 8 -3(fffd) << -95(ffffffa1) = -6(fffa)\n  signed 8 -3(fffd) << -94(ffffffa2) = -12(fff4)\n  signed 8 -3(fffd) << -93(ffffffa3) = -24(ffe8)\n  signed 8 -3(fffd) << -92(ffffffa4) = -48(ffd0)\n  signed 8 -3(fffd) << -91(ffffffa5) = -96(ffa0)\n  signed 8 -3(fffd) << -90(ffffffa6) = -192(ff40)\n  signed 8 -3(fffd) << -89(ffffffa7) = -384(fe80)\n  signed 8 -3(fffd) << -88(ffffffa8) = -768(fd00)\n  signed 8 -3(fffd) << -87(ffffffa9) = -1536(fa00)\n  signed 8 -3(fffd) << -86(ffffffaa) = -3072(f400)\n  signed 8 -3(fffd) << -85(ffffffab) = -6144(e800)\n  signed 8 -3(fffd) << -84(ffffffac) = -12288(d000)\n  signed 8 -3(fffd) << -83(ffffffad) = -24576(a000)\n  signed 8 -3(fffd) << -82(ffffffae) = -49152(4000)\n  signed 8 -3(fffd) << -81(ffffffaf) = -98304(8000)\n  signed 8 -3(fffd) << -80(ffffffb0) = -196608(0)\n  signed 8 -3(fffd) << -79(ffffffb1) = -393216(0)\n  signed 8 -3(fffd) << -78(ffffffb2) = -786432(0)\n  signed 8 -3(fffd) << -77(ffffffb3) = -1572864(0)\n  signed 8 -3(fffd) << -76(ffffffb4) = -3145728(0)\n  signed 8 -3(fffd) << -75(ffffffb5) = -6291456(0)\n  signed 8 -3(fffd) << -74(ffffffb6) = -12582912(0)\n  signed 8 -3(fffd) << -73(ffffffb7) = -25165824(0)\n  signed 8 -3(fffd) << -72(ffffffb8) = -50331648(0)\n  signed 8 -3(fffd) << -71(ffffffb9) = -100663296(0)\n  signed 8 -3(fffd) << -70(ffffffba) = -201326592(0)\n  signed 8 -3(fffd) << -69(ffffffbb) = -402653184(0)\n  signed 8 -3(fffd) << -68(ffffffbc) = -805306368(0)\n  signed 8 -3(fffd) << -67(ffffffbd) = -1610612736(0)\n  signed 8 -3(fffd) << -66(ffffffbe) = 1073741824(0)\n  signed 8 -3(fffd) << -65(ffffffbf) = -2147483648(0)\n  signed 8 -3(fffd) << -64(ffffffc0) = -3(fffd)\n  signed 8 -3(fffd) << -63(ffffffc1) = -6(fffa)\n  signed 8 -3(fffd) << -62(ffffffc2) = -12(fff4)\n  signed 8 -3(fffd) << -61(ffffffc3) = -24(ffe8)\n  signed 8 -3(fffd) << -60(ffffffc4) = -48(ffd0)\n  signed 8 -3(fffd) << -59(ffffffc5) = -96(ffa0)\n  signed 8 -3(fffd) << -58(ffffffc6) = -192(ff40)\n  signed 8 -3(fffd) << -57(ffffffc7) = -384(fe80)\n  signed 8 -3(fffd) << -56(ffffffc8) = -768(fd00)\n  signed 8 -3(fffd) << -55(ffffffc9) = -1536(fa00)\n  signed 8 -3(fffd) << -54(ffffffca) = -3072(f400)\n  signed 8 -3(fffd) << -53(ffffffcb) = -6144(e800)\n  signed 8 -3(fffd) << -52(ffffffcc) = -12288(d000)\n  signed 8 -3(fffd) << -51(ffffffcd) = -24576(a000)\n  signed 8 -3(fffd) << -50(ffffffce) = -49152(4000)\n  signed 8 -3(fffd) << -49(ffffffcf) = -98304(8000)\n  signed 8 -3(fffd) << -48(ffffffd0) = -196608(0)\n  signed 8 -3(fffd) << -47(ffffffd1) = -393216(0)\n  signed 8 -3(fffd) << -46(ffffffd2) = -786432(0)\n  signed 8 -3(fffd) << -45(ffffffd3) = -1572864(0)\n  signed 8 -3(fffd) << -44(ffffffd4) = -3145728(0)\n  signed 8 -3(fffd) << -43(ffffffd5) = -6291456(0)\n  signed 8 -3(fffd) << -42(ffffffd6) = -12582912(0)\n  signed 8 -3(fffd) << -41(ffffffd7) = -25165824(0)\n  signed 8 -3(fffd) << -40(ffffffd8) = -50331648(0)\n  signed 8 -3(fffd) << -39(ffffffd9) = -100663296(0)\n  signed 8 -3(fffd) << -38(ffffffda) = -201326592(0)\n  signed 8 -3(fffd) << -37(ffffffdb) = -402653184(0)\n  signed 8 -3(fffd) << -36(ffffffdc) = -805306368(0)\n  signed 8 -3(fffd) << -35(ffffffdd) = -1610612736(0)\n  signed 8 -3(fffd) << -34(ffffffde) = 1073741824(0)\n  signed 8 -3(fffd) << -33(ffffffdf) = -2147483648(0)\n  signed 8 -3(fffd) << -32(ffffffe0) = -3(fffd)\n  signed 8 -3(fffd) << -31(ffffffe1) = -6(fffa)\n  signed 8 -3(fffd) << -30(ffffffe2) = -12(fff4)\n  signed 8 -3(fffd) << -29(ffffffe3) = -24(ffe8)\n  signed 8 -3(fffd) << -28(ffffffe4) = -48(ffd0)\n  signed 8 -3(fffd) << -27(ffffffe5) = -96(ffa0)\n  signed 8 -3(fffd) << -26(ffffffe6) = -192(ff40)\n  signed 8 -3(fffd) << -25(ffffffe7) = -384(fe80)\n  signed 8 -3(fffd) << -24(ffffffe8) = -768(fd00)\n  signed 8 -3(fffd) << -23(ffffffe9) = -1536(fa00)\n  signed 8 -3(fffd) << -22(ffffffea) = -3072(f400)\n  signed 8 -3(fffd) << -21(ffffffeb) = -6144(e800)\n  signed 8 -3(fffd) << -20(ffffffec) = -12288(d000)\n  signed 8 -3(fffd) << -19(ffffffed) = -24576(a000)\n  signed 8 -3(fffd) << -18(ffffffee) = -49152(4000)\n  signed 8 -3(fffd) << -17(ffffffef) = -98304(8000)\n  signed 8 -3(fffd) << -16(fffffff0) = -196608(0)\n  signed 8 -3(fffd) << -15(fffffff1) = -393216(0)\n  signed 8 -3(fffd) << -14(fffffff2) = -786432(0)\n  signed 8 -3(fffd) << -13(fffffff3) = -1572864(0)\n  signed 8 -3(fffd) << -12(fffffff4) = -3145728(0)\n  signed 8 -3(fffd) << -11(fffffff5) = -6291456(0)\n  signed 8 -3(fffd) << -10(fffffff6) = -12582912(0)\n  signed 8 -3(fffd) << -9(fffffff7) = -25165824(0)\n  signed 8 -3(fffd) << -8(fffffff8) = -50331648(0)\n  signed 8 -3(fffd) << -7(fffffff9) = -100663296(0)\n  signed 8 -3(fffd) << -6(fffffffa) = -201326592(0)\n  signed 8 -3(fffd) << -5(fffffffb) = -402653184(0)\n  signed 8 -3(fffd) << -4(fffffffc) = -805306368(0)\n  signed 8 -3(fffd) << -3(fffffffd) = -1610612736(0)\n  signed 8 -3(fffd) << -2(fffffffe) = 1073741824(0)\n  signed 8 -3(fffd) << -1(ffffffff) = -2147483648(0)\n  signed 8 -3(fffd) << 0(0) = -3(fffd)\n  signed 8 -3(fffd) << 1(1) = -6(fffa)\n  signed 8 -3(fffd) << 2(2) = -12(fff4)\n  signed 8 -3(fffd) << 3(3) = -24(ffe8)\n  signed 8 -3(fffd) << 4(4) = -48(ffd0)\n  signed 8 -3(fffd) << 5(5) = -96(ffa0)\n  signed 8 -3(fffd) << 6(6) = -192(ff40)\n  signed 8 -3(fffd) << 7(7) = -384(fe80)\n  signed 8 -3(fffd) << 8(8) = -768(fd00)\n  signed 8 -3(fffd) << 9(9) = -1536(fa00)\n  signed 8 -3(fffd) << 10(a) = -3072(f400)\n  signed 8 -3(fffd) << 11(b) = -6144(e800)\n  signed 8 -3(fffd) << 12(c) = -12288(d000)\n  signed 8 -3(fffd) << 13(d) = -24576(a000)\n  signed 8 -3(fffd) << 14(e) = -49152(4000)\n  signed 8 -3(fffd) << 15(f) = -98304(8000)\n  signed 8 -3(fffd) << 16(10) = -196608(0)\n  signed 8 -3(fffd) << 17(11) = -393216(0)\n  signed 8 -3(fffd) << 18(12) = -786432(0)\n  signed 8 -3(fffd) << 19(13) = -1572864(0)\n  signed 8 -3(fffd) << 20(14) = -3145728(0)\n  signed 8 -3(fffd) << 21(15) = -6291456(0)\n  signed 8 -3(fffd) << 22(16) = -12582912(0)\n  signed 8 -3(fffd) << 23(17) = -25165824(0)\n  signed 8 -3(fffd) << 24(18) = -50331648(0)\n  signed 8 -3(fffd) << 25(19) = -100663296(0)\n  signed 8 -3(fffd) << 26(1a) = -201326592(0)\n  signed 8 -3(fffd) << 27(1b) = -402653184(0)\n  signed 8 -3(fffd) << 28(1c) = -805306368(0)\n  signed 8 -3(fffd) << 29(1d) = -1610612736(0)\n  signed 8 -3(fffd) << 30(1e) = 1073741824(0)\n  signed 8 -3(fffd) << 31(1f) = -2147483648(0)\n  signed 8 -3(fffd) << 32(20) = -3(fffd)\n  signed 8 -3(fffd) << 33(21) = -6(fffa)\n  signed 8 -3(fffd) << 34(22) = -12(fff4)\n  signed 8 -3(fffd) << 35(23) = -24(ffe8)\n  signed 8 -3(fffd) << 36(24) = -48(ffd0)\n  signed 8 -3(fffd) << 37(25) = -96(ffa0)\n  signed 8 -3(fffd) << 38(26) = -192(ff40)\n  signed 8 -3(fffd) << 39(27) = -384(fe80)\n  signed 8 -3(fffd) << 40(28) = -768(fd00)\n  signed 8 -3(fffd) << 41(29) = -1536(fa00)\n  signed 8 -3(fffd) << 42(2a) = -3072(f400)\n  signed 8 -3(fffd) << 43(2b) = -6144(e800)\n  signed 8 -3(fffd) << 44(2c) = -12288(d000)\n  signed 8 -3(fffd) << 45(2d) = -24576(a000)\n  signed 8 -3(fffd) << 46(2e) = -49152(4000)\n  signed 8 -3(fffd) << 47(2f) = -98304(8000)\n  signed 8 -3(fffd) << 48(30) = -196608(0)\n  signed 8 -3(fffd) << 49(31) = -393216(0)\n  signed 8 -3(fffd) << 50(32) = -786432(0)\n  signed 8 -3(fffd) << 51(33) = -1572864(0)\n  signed 8 -3(fffd) << 52(34) = -3145728(0)\n  signed 8 -3(fffd) << 53(35) = -6291456(0)\n  signed 8 -3(fffd) << 54(36) = -12582912(0)\n  signed 8 -3(fffd) << 55(37) = -25165824(0)\n  signed 8 -3(fffd) << 56(38) = -50331648(0)\n  signed 8 -3(fffd) << 57(39) = -100663296(0)\n  signed 8 -3(fffd) << 58(3a) = -201326592(0)\n  signed 8 -3(fffd) << 59(3b) = -402653184(0)\n  signed 8 -3(fffd) << 60(3c) = -805306368(0)\n  signed 8 -3(fffd) << 61(3d) = -1610612736(0)\n  signed 8 -3(fffd) << 62(3e) = 1073741824(0)\n  signed 8 -3(fffd) << 63(3f) = -2147483648(0)\n  signed 8 -3(fffd) << 64(40) = -3(fffd)\n  signed 8 -3(fffd) << 65(41) = -6(fffa)\n  signed 8 -3(fffd) << 66(42) = -12(fff4)\n  signed 8 -3(fffd) << 67(43) = -24(ffe8)\n  signed 8 -3(fffd) << 68(44) = -48(ffd0)\n  signed 8 -3(fffd) << 69(45) = -96(ffa0)\n  signed 8 -3(fffd) << 70(46) = -192(ff40)\n  signed 8 -3(fffd) << 71(47) = -384(fe80)\n  signed 8 -3(fffd) << 72(48) = -768(fd00)\n  signed 8 -3(fffd) << 73(49) = -1536(fa00)\n  signed 8 -3(fffd) << 74(4a) = -3072(f400)\n  signed 8 -3(fffd) << 75(4b) = -6144(e800)\n  signed 8 -3(fffd) << 76(4c) = -12288(d000)\n  signed 8 -3(fffd) << 77(4d) = -24576(a000)\n  signed 8 -3(fffd) << 78(4e) = -49152(4000)\n  signed 8 -3(fffd) << 79(4f) = -98304(8000)\n  signed 8 -3(fffd) << 80(50) = -196608(0)\n  signed 8 -3(fffd) << 81(51) = -393216(0)\n  signed 8 -3(fffd) << 82(52) = -786432(0)\n  signed 8 -3(fffd) << 83(53) = -1572864(0)\n  signed 8 -3(fffd) << 84(54) = -3145728(0)\n  signed 8 -3(fffd) << 85(55) = -6291456(0)\n  signed 8 -3(fffd) << 86(56) = -12582912(0)\n  signed 8 -3(fffd) << 87(57) = -25165824(0)\n  signed 8 -3(fffd) << 88(58) = -50331648(0)\n  signed 8 -3(fffd) << 89(59) = -100663296(0)\n  signed 8 -3(fffd) << 90(5a) = -201326592(0)\n  signed 8 -3(fffd) << 91(5b) = -402653184(0)\n  signed 8 -3(fffd) << 92(5c) = -805306368(0)\n  signed 8 -3(fffd) << 93(5d) = -1610612736(0)\n  signed 8 -3(fffd) << 94(5e) = 1073741824(0)\n  signed 8 -3(fffd) << 95(5f) = -2147483648(0)\n  signed 8 -3(fffd) << 96(60) = -3(fffd)\n  signed 8 -3(fffd) << 97(61) = -6(fffa)\n  signed 8 -3(fffd) << 98(62) = -12(fff4)\n  signed 8 -3(fffd) << 99(63) = -24(ffe8)\n  signed 8 -3(fffd) << 100(64) = -48(ffd0)\n  signed 8 -3(fffd) << 101(65) = -96(ffa0)\n  signed 8 -3(fffd) << 102(66) = -192(ff40)\n  signed 8 -3(fffd) << 103(67) = -384(fe80)\n  signed 8 -3(fffd) << 104(68) = -768(fd00)\n  signed 8 -3(fffd) << 105(69) = -1536(fa00)\n  signed 8 -3(fffd) << 106(6a) = -3072(f400)\n  signed 8 -3(fffd) << 107(6b) = -6144(e800)\n  signed 8 -3(fffd) << 108(6c) = -12288(d000)\n  signed 8 -3(fffd) << 109(6d) = -24576(a000)\n  signed 8 -3(fffd) << 110(6e) = -49152(4000)\n  signed 8 -3(fffd) << 111(6f) = -98304(8000)\n  signed 8 -3(fffd) << 112(70) = -196608(0)\n  signed 8 -3(fffd) << 113(71) = -393216(0)\n  signed 8 -3(fffd) << 114(72) = -786432(0)\n  signed 8 -3(fffd) << 115(73) = -1572864(0)\n  signed 8 -3(fffd) << 116(74) = -3145728(0)\n  signed 8 -3(fffd) << 117(75) = -6291456(0)\n  signed 8 -3(fffd) << 118(76) = -12582912(0)\n  signed 8 -3(fffd) << 119(77) = -25165824(0)\n  signed 8 -3(fffd) << 120(78) = -50331648(0)\n  signed 8 -3(fffd) << 121(79) = -100663296(0)\n  signed 8 -3(fffd) << 122(7a) = -201326592(0)\n  signed 8 -3(fffd) << 123(7b) = -402653184(0)\n  signed 8 -3(fffd) << 124(7c) = -805306368(0)\n  signed 8 -3(fffd) << 125(7d) = -1610612736(0)\n  signed 8 -3(fffd) << 126(7e) = 1073741824(0)\n  signed 8 -3(fffd) << 127(7f) = -2147483648(0)\n  signed 8 -2(fffe) << -128(ffffff80) = -2(fffe)\n  signed 8 -2(fffe) << -127(ffffff81) = -4(fffc)\n  signed 8 -2(fffe) << -126(ffffff82) = -8(fff8)\n  signed 8 -2(fffe) << -125(ffffff83) = -16(fff0)\n  signed 8 -2(fffe) << -124(ffffff84) = -32(ffe0)\n  signed 8 -2(fffe) << -123(ffffff85) = -64(ffc0)\n  signed 8 -2(fffe) << -122(ffffff86) = -128(ff80)\n  signed 8 -2(fffe) << -121(ffffff87) = -256(ff00)\n  signed 8 -2(fffe) << -120(ffffff88) = -512(fe00)\n  signed 8 -2(fffe) << -119(ffffff89) = -1024(fc00)\n  signed 8 -2(fffe) << -118(ffffff8a) = -2048(f800)\n  signed 8 -2(fffe) << -117(ffffff8b) = -4096(f000)\n  signed 8 -2(fffe) << -116(ffffff8c) = -8192(e000)\n  signed 8 -2(fffe) << -115(ffffff8d) = -16384(c000)\n  signed 8 -2(fffe) << -114(ffffff8e) = -32768(8000)\n  signed 8 -2(fffe) << -113(ffffff8f) = -65536(0)\n  signed 8 -2(fffe) << -112(ffffff90) = -131072(0)\n  signed 8 -2(fffe) << -111(ffffff91) = -262144(0)\n  signed 8 -2(fffe) << -110(ffffff92) = -524288(0)\n  signed 8 -2(fffe) << -109(ffffff93) = -1048576(0)\n  signed 8 -2(fffe) << -108(ffffff94) = -2097152(0)\n  signed 8 -2(fffe) << -107(ffffff95) = -4194304(0)\n  signed 8 -2(fffe) << -106(ffffff96) = -8388608(0)\n  signed 8 -2(fffe) << -105(ffffff97) = -16777216(0)\n  signed 8 -2(fffe) << -104(ffffff98) = -33554432(0)\n  signed 8 -2(fffe) << -103(ffffff99) = -67108864(0)\n  signed 8 -2(fffe) << -102(ffffff9a) = -134217728(0)\n  signed 8 -2(fffe) << -101(ffffff9b) = -268435456(0)\n  signed 8 -2(fffe) << -100(ffffff9c) = -536870912(0)\n  signed 8 -2(fffe) << -99(ffffff9d) = -1073741824(0)\n  signed 8 -2(fffe) << -98(ffffff9e) = -2147483648(0)\n  signed 8 -2(fffe) << -97(ffffff9f) = 0(0)\n  signed 8 -2(fffe) << -96(ffffffa0) = -2(fffe)\n  signed 8 -2(fffe) << -95(ffffffa1) = -4(fffc)\n  signed 8 -2(fffe) << -94(ffffffa2) = -8(fff8)\n  signed 8 -2(fffe) << -93(ffffffa3) = -16(fff0)\n  signed 8 -2(fffe) << -92(ffffffa4) = -32(ffe0)\n  signed 8 -2(fffe) << -91(ffffffa5) = -64(ffc0)\n  signed 8 -2(fffe) << -90(ffffffa6) = -128(ff80)\n  signed 8 -2(fffe) << -89(ffffffa7) = -256(ff00)\n  signed 8 -2(fffe) << -88(ffffffa8) = -512(fe00)\n  signed 8 -2(fffe) << -87(ffffffa9) = -1024(fc00)\n  signed 8 -2(fffe) << -86(ffffffaa) = -2048(f800)\n  signed 8 -2(fffe) << -85(ffffffab) = -4096(f000)\n  signed 8 -2(fffe) << -84(ffffffac) = -8192(e000)\n  signed 8 -2(fffe) << -83(ffffffad) = -16384(c000)\n  signed 8 -2(fffe) << -82(ffffffae) = -32768(8000)\n  signed 8 -2(fffe) << -81(ffffffaf) = -65536(0)\n  signed 8 -2(fffe) << -80(ffffffb0) = -131072(0)\n  signed 8 -2(fffe) << -79(ffffffb1) = -262144(0)\n  signed 8 -2(fffe) << -78(ffffffb2) = -524288(0)\n  signed 8 -2(fffe) << -77(ffffffb3) = -1048576(0)\n  signed 8 -2(fffe) << -76(ffffffb4) = -2097152(0)\n  signed 8 -2(fffe) << -75(ffffffb5) = -4194304(0)\n  signed 8 -2(fffe) << -74(ffffffb6) = -8388608(0)\n  signed 8 -2(fffe) << -73(ffffffb7) = -16777216(0)\n  signed 8 -2(fffe) << -72(ffffffb8) = -33554432(0)\n  signed 8 -2(fffe) << -71(ffffffb9) = -67108864(0)\n  signed 8 -2(fffe) << -70(ffffffba) = -134217728(0)\n  signed 8 -2(fffe) << -69(ffffffbb) = -268435456(0)\n  signed 8 -2(fffe) << -68(ffffffbc) = -536870912(0)\n  signed 8 -2(fffe) << -67(ffffffbd) = -1073741824(0)\n  signed 8 -2(fffe) << -66(ffffffbe) = -2147483648(0)\n  signed 8 -2(fffe) << -65(ffffffbf) = 0(0)\n  signed 8 -2(fffe) << -64(ffffffc0) = -2(fffe)\n  signed 8 -2(fffe) << -63(ffffffc1) = -4(fffc)\n  signed 8 -2(fffe) << -62(ffffffc2) = -8(fff8)\n  signed 8 -2(fffe) << -61(ffffffc3) = -16(fff0)\n  signed 8 -2(fffe) << -60(ffffffc4) = -32(ffe0)\n  signed 8 -2(fffe) << -59(ffffffc5) = -64(ffc0)\n  signed 8 -2(fffe) << -58(ffffffc6) = -128(ff80)\n  signed 8 -2(fffe) << -57(ffffffc7) = -256(ff00)\n  signed 8 -2(fffe) << -56(ffffffc8) = -512(fe00)\n  signed 8 -2(fffe) << -55(ffffffc9) = -1024(fc00)\n  signed 8 -2(fffe) << -54(ffffffca) = -2048(f800)\n  signed 8 -2(fffe) << -53(ffffffcb) = -4096(f000)\n  signed 8 -2(fffe) << -52(ffffffcc) = -8192(e000)\n  signed 8 -2(fffe) << -51(ffffffcd) = -16384(c000)\n  signed 8 -2(fffe) << -50(ffffffce) = -32768(8000)\n  signed 8 -2(fffe) << -49(ffffffcf) = -65536(0)\n  signed 8 -2(fffe) << -48(ffffffd0) = -131072(0)\n  signed 8 -2(fffe) << -47(ffffffd1) = -262144(0)\n  signed 8 -2(fffe) << -46(ffffffd2) = -524288(0)\n  signed 8 -2(fffe) << -45(ffffffd3) = -1048576(0)\n  signed 8 -2(fffe) << -44(ffffffd4) = -2097152(0)\n  signed 8 -2(fffe) << -43(ffffffd5) = -4194304(0)\n  signed 8 -2(fffe) << -42(ffffffd6) = -8388608(0)\n  signed 8 -2(fffe) << -41(ffffffd7) = -16777216(0)\n  signed 8 -2(fffe) << -40(ffffffd8) = -33554432(0)\n  signed 8 -2(fffe) << -39(ffffffd9) = -67108864(0)\n  signed 8 -2(fffe) << -38(ffffffda) = -134217728(0)\n  signed 8 -2(fffe) << -37(ffffffdb) = -268435456(0)\n  signed 8 -2(fffe) << -36(ffffffdc) = -536870912(0)\n  signed 8 -2(fffe) << -35(ffffffdd) = -1073741824(0)\n  signed 8 -2(fffe) << -34(ffffffde) = -2147483648(0)\n  signed 8 -2(fffe) << -33(ffffffdf) = 0(0)\n  signed 8 -2(fffe) << -32(ffffffe0) = -2(fffe)\n  signed 8 -2(fffe) << -31(ffffffe1) = -4(fffc)\n  signed 8 -2(fffe) << -30(ffffffe2) = -8(fff8)\n  signed 8 -2(fffe) << -29(ffffffe3) = -16(fff0)\n  signed 8 -2(fffe) << -28(ffffffe4) = -32(ffe0)\n  signed 8 -2(fffe) << -27(ffffffe5) = -64(ffc0)\n  signed 8 -2(fffe) << -26(ffffffe6) = -128(ff80)\n  signed 8 -2(fffe) << -25(ffffffe7) = -256(ff00)\n  signed 8 -2(fffe) << -24(ffffffe8) = -512(fe00)\n  signed 8 -2(fffe) << -23(ffffffe9) = -1024(fc00)\n  signed 8 -2(fffe) << -22(ffffffea) = -2048(f800)\n  signed 8 -2(fffe) << -21(ffffffeb) = -4096(f000)\n  signed 8 -2(fffe) << -20(ffffffec) = -8192(e000)\n  signed 8 -2(fffe) << -19(ffffffed) = -16384(c000)\n  signed 8 -2(fffe) << -18(ffffffee) = -32768(8000)\n  signed 8 -2(fffe) << -17(ffffffef) = -65536(0)\n  signed 8 -2(fffe) << -16(fffffff0) = -131072(0)\n  signed 8 -2(fffe) << -15(fffffff1) = -262144(0)\n  signed 8 -2(fffe) << -14(fffffff2) = -524288(0)\n  signed 8 -2(fffe) << -13(fffffff3) = -1048576(0)\n  signed 8 -2(fffe) << -12(fffffff4) = -2097152(0)\n  signed 8 -2(fffe) << -11(fffffff5) = -4194304(0)\n  signed 8 -2(fffe) << -10(fffffff6) = -8388608(0)\n  signed 8 -2(fffe) << -9(fffffff7) = -16777216(0)\n  signed 8 -2(fffe) << -8(fffffff8) = -33554432(0)\n  signed 8 -2(fffe) << -7(fffffff9) = -67108864(0)\n  signed 8 -2(fffe) << -6(fffffffa) = -134217728(0)\n  signed 8 -2(fffe) << -5(fffffffb) = -268435456(0)\n  signed 8 -2(fffe) << -4(fffffffc) = -536870912(0)\n  signed 8 -2(fffe) << -3(fffffffd) = -1073741824(0)\n  signed 8 -2(fffe) << -2(fffffffe) = -2147483648(0)\n  signed 8 -2(fffe) << -1(ffffffff) = 0(0)\n  signed 8 -2(fffe) << 0(0) = -2(fffe)\n  signed 8 -2(fffe) << 1(1) = -4(fffc)\n  signed 8 -2(fffe) << 2(2) = -8(fff8)\n  signed 8 -2(fffe) << 3(3) = -16(fff0)\n  signed 8 -2(fffe) << 4(4) = -32(ffe0)\n  signed 8 -2(fffe) << 5(5) = -64(ffc0)\n  signed 8 -2(fffe) << 6(6) = -128(ff80)\n  signed 8 -2(fffe) << 7(7) = -256(ff00)\n  signed 8 -2(fffe) << 8(8) = -512(fe00)\n  signed 8 -2(fffe) << 9(9) = -1024(fc00)\n  signed 8 -2(fffe) << 10(a) = -2048(f800)\n  signed 8 -2(fffe) << 11(b) = -4096(f000)\n  signed 8 -2(fffe) << 12(c) = -8192(e000)\n  signed 8 -2(fffe) << 13(d) = -16384(c000)\n  signed 8 -2(fffe) << 14(e) = -32768(8000)\n  signed 8 -2(fffe) << 15(f) = -65536(0)\n  signed 8 -2(fffe) << 16(10) = -131072(0)\n  signed 8 -2(fffe) << 17(11) = -262144(0)\n  signed 8 -2(fffe) << 18(12) = -524288(0)\n  signed 8 -2(fffe) << 19(13) = -1048576(0)\n  signed 8 -2(fffe) << 20(14) = -2097152(0)\n  signed 8 -2(fffe) << 21(15) = -4194304(0)\n  signed 8 -2(fffe) << 22(16) = -8388608(0)\n  signed 8 -2(fffe) << 23(17) = -16777216(0)\n  signed 8 -2(fffe) << 24(18) = -33554432(0)\n  signed 8 -2(fffe) << 25(19) = -67108864(0)\n  signed 8 -2(fffe) << 26(1a) = -134217728(0)\n  signed 8 -2(fffe) << 27(1b) = -268435456(0)\n  signed 8 -2(fffe) << 28(1c) = -536870912(0)\n  signed 8 -2(fffe) << 29(1d) = -1073741824(0)\n  signed 8 -2(fffe) << 30(1e) = -2147483648(0)\n  signed 8 -2(fffe) << 31(1f) = 0(0)\n  signed 8 -2(fffe) << 32(20) = -2(fffe)\n  signed 8 -2(fffe) << 33(21) = -4(fffc)\n  signed 8 -2(fffe) << 34(22) = -8(fff8)\n  signed 8 -2(fffe) << 35(23) = -16(fff0)\n  signed 8 -2(fffe) << 36(24) = -32(ffe0)\n  signed 8 -2(fffe) << 37(25) = -64(ffc0)\n  signed 8 -2(fffe) << 38(26) = -128(ff80)\n  signed 8 -2(fffe) << 39(27) = -256(ff00)\n  signed 8 -2(fffe) << 40(28) = -512(fe00)\n  signed 8 -2(fffe) << 41(29) = -1024(fc00)\n  signed 8 -2(fffe) << 42(2a) = -2048(f800)\n  signed 8 -2(fffe) << 43(2b) = -4096(f000)\n  signed 8 -2(fffe) << 44(2c) = -8192(e000)\n  signed 8 -2(fffe) << 45(2d) = -16384(c000)\n  signed 8 -2(fffe) << 46(2e) = -32768(8000)\n  signed 8 -2(fffe) << 47(2f) = -65536(0)\n  signed 8 -2(fffe) << 48(30) = -131072(0)\n  signed 8 -2(fffe) << 49(31) = -262144(0)\n  signed 8 -2(fffe) << 50(32) = -524288(0)\n  signed 8 -2(fffe) << 51(33) = -1048576(0)\n  signed 8 -2(fffe) << 52(34) = -2097152(0)\n  signed 8 -2(fffe) << 53(35) = -4194304(0)\n  signed 8 -2(fffe) << 54(36) = -8388608(0)\n  signed 8 -2(fffe) << 55(37) = -16777216(0)\n  signed 8 -2(fffe) << 56(38) = -33554432(0)\n  signed 8 -2(fffe) << 57(39) = -67108864(0)\n  signed 8 -2(fffe) << 58(3a) = -134217728(0)\n  signed 8 -2(fffe) << 59(3b) = -268435456(0)\n  signed 8 -2(fffe) << 60(3c) = -536870912(0)\n  signed 8 -2(fffe) << 61(3d) = -1073741824(0)\n  signed 8 -2(fffe) << 62(3e) = -2147483648(0)\n  signed 8 -2(fffe) << 63(3f) = 0(0)\n  signed 8 -2(fffe) << 64(40) = -2(fffe)\n  signed 8 -2(fffe) << 65(41) = -4(fffc)\n  signed 8 -2(fffe) << 66(42) = -8(fff8)\n  signed 8 -2(fffe) << 67(43) = -16(fff0)\n  signed 8 -2(fffe) << 68(44) = -32(ffe0)\n  signed 8 -2(fffe) << 69(45) = -64(ffc0)\n  signed 8 -2(fffe) << 70(46) = -128(ff80)\n  signed 8 -2(fffe) << 71(47) = -256(ff00)\n  signed 8 -2(fffe) << 72(48) = -512(fe00)\n  signed 8 -2(fffe) << 73(49) = -1024(fc00)\n  signed 8 -2(fffe) << 74(4a) = -2048(f800)\n  signed 8 -2(fffe) << 75(4b) = -4096(f000)\n  signed 8 -2(fffe) << 76(4c) = -8192(e000)\n  signed 8 -2(fffe) << 77(4d) = -16384(c000)\n  signed 8 -2(fffe) << 78(4e) = -32768(8000)\n  signed 8 -2(fffe) << 79(4f) = -65536(0)\n  signed 8 -2(fffe) << 80(50) = -131072(0)\n  signed 8 -2(fffe) << 81(51) = -262144(0)\n  signed 8 -2(fffe) << 82(52) = -524288(0)\n  signed 8 -2(fffe) << 83(53) = -1048576(0)\n  signed 8 -2(fffe) << 84(54) = -2097152(0)\n  signed 8 -2(fffe) << 85(55) = -4194304(0)\n  signed 8 -2(fffe) << 86(56) = -8388608(0)\n  signed 8 -2(fffe) << 87(57) = -16777216(0)\n  signed 8 -2(fffe) << 88(58) = -33554432(0)\n  signed 8 -2(fffe) << 89(59) = -67108864(0)\n  signed 8 -2(fffe) << 90(5a) = -134217728(0)\n  signed 8 -2(fffe) << 91(5b) = -268435456(0)\n  signed 8 -2(fffe) << 92(5c) = -536870912(0)\n  signed 8 -2(fffe) << 93(5d) = -1073741824(0)\n  signed 8 -2(fffe) << 94(5e) = -2147483648(0)\n  signed 8 -2(fffe) << 95(5f) = 0(0)\n  signed 8 -2(fffe) << 96(60) = -2(fffe)\n  signed 8 -2(fffe) << 97(61) = -4(fffc)\n  signed 8 -2(fffe) << 98(62) = -8(fff8)\n  signed 8 -2(fffe) << 99(63) = -16(fff0)\n  signed 8 -2(fffe) << 100(64) = -32(ffe0)\n  signed 8 -2(fffe) << 101(65) = -64(ffc0)\n  signed 8 -2(fffe) << 102(66) = -128(ff80)\n  signed 8 -2(fffe) << 103(67) = -256(ff00)\n  signed 8 -2(fffe) << 104(68) = -512(fe00)\n  signed 8 -2(fffe) << 105(69) = -1024(fc00)\n  signed 8 -2(fffe) << 106(6a) = -2048(f800)\n  signed 8 -2(fffe) << 107(6b) = -4096(f000)\n  signed 8 -2(fffe) << 108(6c) = -8192(e000)\n  signed 8 -2(fffe) << 109(6d) = -16384(c000)\n  signed 8 -2(fffe) << 110(6e) = -32768(8000)\n  signed 8 -2(fffe) << 111(6f) = -65536(0)\n  signed 8 -2(fffe) << 112(70) = -131072(0)\n  signed 8 -2(fffe) << 113(71) = -262144(0)\n  signed 8 -2(fffe) << 114(72) = -524288(0)\n  signed 8 -2(fffe) << 115(73) = -1048576(0)\n  signed 8 -2(fffe) << 116(74) = -2097152(0)\n  signed 8 -2(fffe) << 117(75) = -4194304(0)\n  signed 8 -2(fffe) << 118(76) = -8388608(0)\n  signed 8 -2(fffe) << 119(77) = -16777216(0)\n  signed 8 -2(fffe) << 120(78) = -33554432(0)\n  signed 8 -2(fffe) << 121(79) = -67108864(0)\n  signed 8 -2(fffe) << 122(7a) = -134217728(0)\n  signed 8 -2(fffe) << 123(7b) = -268435456(0)\n  signed 8 -2(fffe) << 124(7c) = -536870912(0)\n  signed 8 -2(fffe) << 125(7d) = -1073741824(0)\n  signed 8 -2(fffe) << 126(7e) = -2147483648(0)\n  signed 8 -2(fffe) << 127(7f) = 0(0)\n  signed 8 -1(ffff) << -128(ffffff80) = -1(ffff)\n  signed 8 -1(ffff) << -127(ffffff81) = -2(fffe)\n  signed 8 -1(ffff) << -126(ffffff82) = -4(fffc)\n  signed 8 -1(ffff) << -125(ffffff83) = -8(fff8)\n  signed 8 -1(ffff) << -124(ffffff84) = -16(fff0)\n  signed 8 -1(ffff) << -123(ffffff85) = -32(ffe0)\n  signed 8 -1(ffff) << -122(ffffff86) = -64(ffc0)\n  signed 8 -1(ffff) << -121(ffffff87) = -128(ff80)\n  signed 8 -1(ffff) << -120(ffffff88) = -256(ff00)\n  signed 8 -1(ffff) << -119(ffffff89) = -512(fe00)\n  signed 8 -1(ffff) << -118(ffffff8a) = -1024(fc00)\n  signed 8 -1(ffff) << -117(ffffff8b) = -2048(f800)\n  signed 8 -1(ffff) << -116(ffffff8c) = -4096(f000)\n  signed 8 -1(ffff) << -115(ffffff8d) = -8192(e000)\n  signed 8 -1(ffff) << -114(ffffff8e) = -16384(c000)\n  signed 8 -1(ffff) << -113(ffffff8f) = -32768(8000)\n  signed 8 -1(ffff) << -112(ffffff90) = -65536(0)\n  signed 8 -1(ffff) << -111(ffffff91) = -131072(0)\n  signed 8 -1(ffff) << -110(ffffff92) = -262144(0)\n  signed 8 -1(ffff) << -109(ffffff93) = -524288(0)\n  signed 8 -1(ffff) << -108(ffffff94) = -1048576(0)\n  signed 8 -1(ffff) << -107(ffffff95) = -2097152(0)\n  signed 8 -1(ffff) << -106(ffffff96) = -4194304(0)\n  signed 8 -1(ffff) << -105(ffffff97) = -8388608(0)\n  signed 8 -1(ffff) << -104(ffffff98) = -16777216(0)\n  signed 8 -1(ffff) << -103(ffffff99) = -33554432(0)\n  signed 8 -1(ffff) << -102(ffffff9a) = -67108864(0)\n  signed 8 -1(ffff) << -101(ffffff9b) = -134217728(0)\n  signed 8 -1(ffff) << -100(ffffff9c) = -268435456(0)\n  signed 8 -1(ffff) << -99(ffffff9d) = -536870912(0)\n  signed 8 -1(ffff) << -98(ffffff9e) = -1073741824(0)\n  signed 8 -1(ffff) << -97(ffffff9f) = -2147483648(0)\n  signed 8 -1(ffff) << -96(ffffffa0) = -1(ffff)\n  signed 8 -1(ffff) << -95(ffffffa1) = -2(fffe)\n  signed 8 -1(ffff) << -94(ffffffa2) = -4(fffc)\n  signed 8 -1(ffff) << -93(ffffffa3) = -8(fff8)\n  signed 8 -1(ffff) << -92(ffffffa4) = -16(fff0)\n  signed 8 -1(ffff) << -91(ffffffa5) = -32(ffe0)\n  signed 8 -1(ffff) << -90(ffffffa6) = -64(ffc0)\n  signed 8 -1(ffff) << -89(ffffffa7) = -128(ff80)\n  signed 8 -1(ffff) << -88(ffffffa8) = -256(ff00)\n  signed 8 -1(ffff) << -87(ffffffa9) = -512(fe00)\n  signed 8 -1(ffff) << -86(ffffffaa) = -1024(fc00)\n  signed 8 -1(ffff) << -85(ffffffab) = -2048(f800)\n  signed 8 -1(ffff) << -84(ffffffac) = -4096(f000)\n  signed 8 -1(ffff) << -83(ffffffad) = -8192(e000)\n  signed 8 -1(ffff) << -82(ffffffae) = -16384(c000)\n  signed 8 -1(ffff) << -81(ffffffaf) = -32768(8000)\n  signed 8 -1(ffff) << -80(ffffffb0) = -65536(0)\n  signed 8 -1(ffff) << -79(ffffffb1) = -131072(0)\n  signed 8 -1(ffff) << -78(ffffffb2) = -262144(0)\n  signed 8 -1(ffff) << -77(ffffffb3) = -524288(0)\n  signed 8 -1(ffff) << -76(ffffffb4) = -1048576(0)\n  signed 8 -1(ffff) << -75(ffffffb5) = -2097152(0)\n  signed 8 -1(ffff) << -74(ffffffb6) = -4194304(0)\n  signed 8 -1(ffff) << -73(ffffffb7) = -8388608(0)\n  signed 8 -1(ffff) << -72(ffffffb8) = -16777216(0)\n  signed 8 -1(ffff) << -71(ffffffb9) = -33554432(0)\n  signed 8 -1(ffff) << -70(ffffffba) = -67108864(0)\n  signed 8 -1(ffff) << -69(ffffffbb) = -134217728(0)\n  signed 8 -1(ffff) << -68(ffffffbc) = -268435456(0)\n  signed 8 -1(ffff) << -67(ffffffbd) = -536870912(0)\n  signed 8 -1(ffff) << -66(ffffffbe) = -1073741824(0)\n  signed 8 -1(ffff) << -65(ffffffbf) = -2147483648(0)\n  signed 8 -1(ffff) << -64(ffffffc0) = -1(ffff)\n  signed 8 -1(ffff) << -63(ffffffc1) = -2(fffe)\n  signed 8 -1(ffff) << -62(ffffffc2) = -4(fffc)\n  signed 8 -1(ffff) << -61(ffffffc3) = -8(fff8)\n  signed 8 -1(ffff) << -60(ffffffc4) = -16(fff0)\n  signed 8 -1(ffff) << -59(ffffffc5) = -32(ffe0)\n  signed 8 -1(ffff) << -58(ffffffc6) = -64(ffc0)\n  signed 8 -1(ffff) << -57(ffffffc7) = -128(ff80)\n  signed 8 -1(ffff) << -56(ffffffc8) = -256(ff00)\n  signed 8 -1(ffff) << -55(ffffffc9) = -512(fe00)\n  signed 8 -1(ffff) << -54(ffffffca) = -1024(fc00)\n  signed 8 -1(ffff) << -53(ffffffcb) = -2048(f800)\n  signed 8 -1(ffff) << -52(ffffffcc) = -4096(f000)\n  signed 8 -1(ffff) << -51(ffffffcd) = -8192(e000)\n  signed 8 -1(ffff) << -50(ffffffce) = -16384(c000)\n  signed 8 -1(ffff) << -49(ffffffcf) = -32768(8000)\n  signed 8 -1(ffff) << -48(ffffffd0) = -65536(0)\n  signed 8 -1(ffff) << -47(ffffffd1) = -131072(0)\n  signed 8 -1(ffff) << -46(ffffffd2) = -262144(0)\n  signed 8 -1(ffff) << -45(ffffffd3) = -524288(0)\n  signed 8 -1(ffff) << -44(ffffffd4) = -1048576(0)\n  signed 8 -1(ffff) << -43(ffffffd5) = -2097152(0)\n  signed 8 -1(ffff) << -42(ffffffd6) = -4194304(0)\n  signed 8 -1(ffff) << -41(ffffffd7) = -8388608(0)\n  signed 8 -1(ffff) << -40(ffffffd8) = -16777216(0)\n  signed 8 -1(ffff) << -39(ffffffd9) = -33554432(0)\n  signed 8 -1(ffff) << -38(ffffffda) = -67108864(0)\n  signed 8 -1(ffff) << -37(ffffffdb) = -134217728(0)\n  signed 8 -1(ffff) << -36(ffffffdc) = -268435456(0)\n  signed 8 -1(ffff) << -35(ffffffdd) = -536870912(0)\n  signed 8 -1(ffff) << -34(ffffffde) = -1073741824(0)\n  signed 8 -1(ffff) << -33(ffffffdf) = -2147483648(0)\n  signed 8 -1(ffff) << -32(ffffffe0) = -1(ffff)\n  signed 8 -1(ffff) << -31(ffffffe1) = -2(fffe)\n  signed 8 -1(ffff) << -30(ffffffe2) = -4(fffc)\n  signed 8 -1(ffff) << -29(ffffffe3) = -8(fff8)\n  signed 8 -1(ffff) << -28(ffffffe4) = -16(fff0)\n  signed 8 -1(ffff) << -27(ffffffe5) = -32(ffe0)\n  signed 8 -1(ffff) << -26(ffffffe6) = -64(ffc0)\n  signed 8 -1(ffff) << -25(ffffffe7) = -128(ff80)\n  signed 8 -1(ffff) << -24(ffffffe8) = -256(ff00)\n  signed 8 -1(ffff) << -23(ffffffe9) = -512(fe00)\n  signed 8 -1(ffff) << -22(ffffffea) = -1024(fc00)\n  signed 8 -1(ffff) << -21(ffffffeb) = -2048(f800)\n  signed 8 -1(ffff) << -20(ffffffec) = -4096(f000)\n  signed 8 -1(ffff) << -19(ffffffed) = -8192(e000)\n  signed 8 -1(ffff) << -18(ffffffee) = -16384(c000)\n  signed 8 -1(ffff) << -17(ffffffef) = -32768(8000)\n  signed 8 -1(ffff) << -16(fffffff0) = -65536(0)\n  signed 8 -1(ffff) << -15(fffffff1) = -131072(0)\n  signed 8 -1(ffff) << -14(fffffff2) = -262144(0)\n  signed 8 -1(ffff) << -13(fffffff3) = -524288(0)\n  signed 8 -1(ffff) << -12(fffffff4) = -1048576(0)\n  signed 8 -1(ffff) << -11(fffffff5) = -2097152(0)\n  signed 8 -1(ffff) << -10(fffffff6) = -4194304(0)\n  signed 8 -1(ffff) << -9(fffffff7) = -8388608(0)\n  signed 8 -1(ffff) << -8(fffffff8) = -16777216(0)\n  signed 8 -1(ffff) << -7(fffffff9) = -33554432(0)\n  signed 8 -1(ffff) << -6(fffffffa) = -67108864(0)\n  signed 8 -1(ffff) << -5(fffffffb) = -134217728(0)\n  signed 8 -1(ffff) << -4(fffffffc) = -268435456(0)\n  signed 8 -1(ffff) << -3(fffffffd) = -536870912(0)\n  signed 8 -1(ffff) << -2(fffffffe) = -1073741824(0)\n  signed 8 -1(ffff) << -1(ffffffff) = -2147483648(0)\n  signed 8 -1(ffff) << 0(0) = -1(ffff)\n  signed 8 -1(ffff) << 1(1) = -2(fffe)\n  signed 8 -1(ffff) << 2(2) = -4(fffc)\n  signed 8 -1(ffff) << 3(3) = -8(fff8)\n  signed 8 -1(ffff) << 4(4) = -16(fff0)\n  signed 8 -1(ffff) << 5(5) = -32(ffe0)\n  signed 8 -1(ffff) << 6(6) = -64(ffc0)\n  signed 8 -1(ffff) << 7(7) = -128(ff80)\n  signed 8 -1(ffff) << 8(8) = -256(ff00)\n  signed 8 -1(ffff) << 9(9) = -512(fe00)\n  signed 8 -1(ffff) << 10(a) = -1024(fc00)\n  signed 8 -1(ffff) << 11(b) = -2048(f800)\n  signed 8 -1(ffff) << 12(c) = -4096(f000)\n  signed 8 -1(ffff) << 13(d) = -8192(e000)\n  signed 8 -1(ffff) << 14(e) = -16384(c000)\n  signed 8 -1(ffff) << 15(f) = -32768(8000)\n  signed 8 -1(ffff) << 16(10) = -65536(0)\n  signed 8 -1(ffff) << 17(11) = -131072(0)\n  signed 8 -1(ffff) << 18(12) = -262144(0)\n  signed 8 -1(ffff) << 19(13) = -524288(0)\n  signed 8 -1(ffff) << 20(14) = -1048576(0)\n  signed 8 -1(ffff) << 21(15) = -2097152(0)\n  signed 8 -1(ffff) << 22(16) = -4194304(0)\n  signed 8 -1(ffff) << 23(17) = -8388608(0)\n  signed 8 -1(ffff) << 24(18) = -16777216(0)\n  signed 8 -1(ffff) << 25(19) = -33554432(0)\n  signed 8 -1(ffff) << 26(1a) = -67108864(0)\n  signed 8 -1(ffff) << 27(1b) = -134217728(0)\n  signed 8 -1(ffff) << 28(1c) = -268435456(0)\n  signed 8 -1(ffff) << 29(1d) = -536870912(0)\n  signed 8 -1(ffff) << 30(1e) = -1073741824(0)\n  signed 8 -1(ffff) << 31(1f) = -2147483648(0)\n  signed 8 -1(ffff) << 32(20) = -1(ffff)\n  signed 8 -1(ffff) << 33(21) = -2(fffe)\n  signed 8 -1(ffff) << 34(22) = -4(fffc)\n  signed 8 -1(ffff) << 35(23) = -8(fff8)\n  signed 8 -1(ffff) << 36(24) = -16(fff0)\n  signed 8 -1(ffff) << 37(25) = -32(ffe0)\n  signed 8 -1(ffff) << 38(26) = -64(ffc0)\n  signed 8 -1(ffff) << 39(27) = -128(ff80)\n  signed 8 -1(ffff) << 40(28) = -256(ff00)\n  signed 8 -1(ffff) << 41(29) = -512(fe00)\n  signed 8 -1(ffff) << 42(2a) = -1024(fc00)\n  signed 8 -1(ffff) << 43(2b) = -2048(f800)\n  signed 8 -1(ffff) << 44(2c) = -4096(f000)\n  signed 8 -1(ffff) << 45(2d) = -8192(e000)\n  signed 8 -1(ffff) << 46(2e) = -16384(c000)\n  signed 8 -1(ffff) << 47(2f) = -32768(8000)\n  signed 8 -1(ffff) << 48(30) = -65536(0)\n  signed 8 -1(ffff) << 49(31) = -131072(0)\n  signed 8 -1(ffff) << 50(32) = -262144(0)\n  signed 8 -1(ffff) << 51(33) = -524288(0)\n  signed 8 -1(ffff) << 52(34) = -1048576(0)\n  signed 8 -1(ffff) << 53(35) = -2097152(0)\n  signed 8 -1(ffff) << 54(36) = -4194304(0)\n  signed 8 -1(ffff) << 55(37) = -8388608(0)\n  signed 8 -1(ffff) << 56(38) = -16777216(0)\n  signed 8 -1(ffff) << 57(39) = -33554432(0)\n  signed 8 -1(ffff) << 58(3a) = -67108864(0)\n  signed 8 -1(ffff) << 59(3b) = -134217728(0)\n  signed 8 -1(ffff) << 60(3c) = -268435456(0)\n  signed 8 -1(ffff) << 61(3d) = -536870912(0)\n  signed 8 -1(ffff) << 62(3e) = -1073741824(0)\n  signed 8 -1(ffff) << 63(3f) = -2147483648(0)\n  signed 8 -1(ffff) << 64(40) = -1(ffff)\n  signed 8 -1(ffff) << 65(41) = -2(fffe)\n  signed 8 -1(ffff) << 66(42) = -4(fffc)\n  signed 8 -1(ffff) << 67(43) = -8(fff8)\n  signed 8 -1(ffff) << 68(44) = -16(fff0)\n  signed 8 -1(ffff) << 69(45) = -32(ffe0)\n  signed 8 -1(ffff) << 70(46) = -64(ffc0)\n  signed 8 -1(ffff) << 71(47) = -128(ff80)\n  signed 8 -1(ffff) << 72(48) = -256(ff00)\n  signed 8 -1(ffff) << 73(49) = -512(fe00)\n  signed 8 -1(ffff) << 74(4a) = -1024(fc00)\n  signed 8 -1(ffff) << 75(4b) = -2048(f800)\n  signed 8 -1(ffff) << 76(4c) = -4096(f000)\n  signed 8 -1(ffff) << 77(4d) = -8192(e000)\n  signed 8 -1(ffff) << 78(4e) = -16384(c000)\n  signed 8 -1(ffff) << 79(4f) = -32768(8000)\n  signed 8 -1(ffff) << 80(50) = -65536(0)\n  signed 8 -1(ffff) << 81(51) = -131072(0)\n  signed 8 -1(ffff) << 82(52) = -262144(0)\n  signed 8 -1(ffff) << 83(53) = -524288(0)\n  signed 8 -1(ffff) << 84(54) = -1048576(0)\n  signed 8 -1(ffff) << 85(55) = -2097152(0)\n  signed 8 -1(ffff) << 86(56) = -4194304(0)\n  signed 8 -1(ffff) << 87(57) = -8388608(0)\n  signed 8 -1(ffff) << 88(58) = -16777216(0)\n  signed 8 -1(ffff) << 89(59) = -33554432(0)\n  signed 8 -1(ffff) << 90(5a) = -67108864(0)\n  signed 8 -1(ffff) << 91(5b) = -134217728(0)\n  signed 8 -1(ffff) << 92(5c) = -268435456(0)\n  signed 8 -1(ffff) << 93(5d) = -536870912(0)\n  signed 8 -1(ffff) << 94(5e) = -1073741824(0)\n  signed 8 -1(ffff) << 95(5f) = -2147483648(0)\n  signed 8 -1(ffff) << 96(60) = -1(ffff)\n  signed 8 -1(ffff) << 97(61) = -2(fffe)\n  signed 8 -1(ffff) << 98(62) = -4(fffc)\n  signed 8 -1(ffff) << 99(63) = -8(fff8)\n  signed 8 -1(ffff) << 100(64) = -16(fff0)\n  signed 8 -1(ffff) << 101(65) = -32(ffe0)\n  signed 8 -1(ffff) << 102(66) = -64(ffc0)\n  signed 8 -1(ffff) << 103(67) = -128(ff80)\n  signed 8 -1(ffff) << 104(68) = -256(ff00)\n  signed 8 -1(ffff) << 105(69) = -512(fe00)\n  signed 8 -1(ffff) << 106(6a) = -1024(fc00)\n  signed 8 -1(ffff) << 107(6b) = -2048(f800)\n  signed 8 -1(ffff) << 108(6c) = -4096(f000)\n  signed 8 -1(ffff) << 109(6d) = -8192(e000)\n  signed 8 -1(ffff) << 110(6e) = -16384(c000)\n  signed 8 -1(ffff) << 111(6f) = -32768(8000)\n  signed 8 -1(ffff) << 112(70) = -65536(0)\n  signed 8 -1(ffff) << 113(71) = -131072(0)\n  signed 8 -1(ffff) << 114(72) = -262144(0)\n  signed 8 -1(ffff) << 115(73) = -524288(0)\n  signed 8 -1(ffff) << 116(74) = -1048576(0)\n  signed 8 -1(ffff) << 117(75) = -2097152(0)\n  signed 8 -1(ffff) << 118(76) = -4194304(0)\n  signed 8 -1(ffff) << 119(77) = -8388608(0)\n  signed 8 -1(ffff) << 120(78) = -16777216(0)\n  signed 8 -1(ffff) << 121(79) = -33554432(0)\n  signed 8 -1(ffff) << 122(7a) = -67108864(0)\n  signed 8 -1(ffff) << 123(7b) = -134217728(0)\n  signed 8 -1(ffff) << 124(7c) = -268435456(0)\n  signed 8 -1(ffff) << 125(7d) = -536870912(0)\n  signed 8 -1(ffff) << 126(7e) = -1073741824(0)\n  signed 8 -1(ffff) << 127(7f) = -2147483648(0)\n  signed 8 0(0) << -128(ffffff80) = 0(0)\n  signed 8 0(0) << -127(ffffff81) = 0(0)\n  signed 8 0(0) << -126(ffffff82) = 0(0)\n  signed 8 0(0) << -125(ffffff83) = 0(0)\n  signed 8 0(0) << -124(ffffff84) = 0(0)\n  signed 8 0(0) << -123(ffffff85) = 0(0)\n  signed 8 0(0) << -122(ffffff86) = 0(0)\n  signed 8 0(0) << -121(ffffff87) = 0(0)\n  signed 8 0(0) << -120(ffffff88) = 0(0)\n  signed 8 0(0) << -119(ffffff89) = 0(0)\n  signed 8 0(0) << -118(ffffff8a) = 0(0)\n  signed 8 0(0) << -117(ffffff8b) = 0(0)\n  signed 8 0(0) << -116(ffffff8c) = 0(0)\n  signed 8 0(0) << -115(ffffff8d) = 0(0)\n  signed 8 0(0) << -114(ffffff8e) = 0(0)\n  signed 8 0(0) << -113(ffffff8f) = 0(0)\n  signed 8 0(0) << -112(ffffff90) = 0(0)\n  signed 8 0(0) << -111(ffffff91) = 0(0)\n  signed 8 0(0) << -110(ffffff92) = 0(0)\n  signed 8 0(0) << -109(ffffff93) = 0(0)\n  signed 8 0(0) << -108(ffffff94) = 0(0)\n  signed 8 0(0) << -107(ffffff95) = 0(0)\n  signed 8 0(0) << -106(ffffff96) = 0(0)\n  signed 8 0(0) << -105(ffffff97) = 0(0)\n  signed 8 0(0) << -104(ffffff98) = 0(0)\n  signed 8 0(0) << -103(ffffff99) = 0(0)\n  signed 8 0(0) << -102(ffffff9a) = 0(0)\n  signed 8 0(0) << -101(ffffff9b) = 0(0)\n  signed 8 0(0) << -100(ffffff9c) = 0(0)\n  signed 8 0(0) << -99(ffffff9d) = 0(0)\n  signed 8 0(0) << -98(ffffff9e) = 0(0)\n  signed 8 0(0) << -97(ffffff9f) = 0(0)\n  signed 8 0(0) << -96(ffffffa0) = 0(0)\n  signed 8 0(0) << -95(ffffffa1) = 0(0)\n  signed 8 0(0) << -94(ffffffa2) = 0(0)\n  signed 8 0(0) << -93(ffffffa3) = 0(0)\n  signed 8 0(0) << -92(ffffffa4) = 0(0)\n  signed 8 0(0) << -91(ffffffa5) = 0(0)\n  signed 8 0(0) << -90(ffffffa6) = 0(0)\n  signed 8 0(0) << -89(ffffffa7) = 0(0)\n  signed 8 0(0) << -88(ffffffa8) = 0(0)\n  signed 8 0(0) << -87(ffffffa9) = 0(0)\n  signed 8 0(0) << -86(ffffffaa) = 0(0)\n  signed 8 0(0) << -85(ffffffab) = 0(0)\n  signed 8 0(0) << -84(ffffffac) = 0(0)\n  signed 8 0(0) << -83(ffffffad) = 0(0)\n  signed 8 0(0) << -82(ffffffae) = 0(0)\n  signed 8 0(0) << -81(ffffffaf) = 0(0)\n  signed 8 0(0) << -80(ffffffb0) = 0(0)\n  signed 8 0(0) << -79(ffffffb1) = 0(0)\n  signed 8 0(0) << -78(ffffffb2) = 0(0)\n  signed 8 0(0) << -77(ffffffb3) = 0(0)\n  signed 8 0(0) << -76(ffffffb4) = 0(0)\n  signed 8 0(0) << -75(ffffffb5) = 0(0)\n  signed 8 0(0) << -74(ffffffb6) = 0(0)\n  signed 8 0(0) << -73(ffffffb7) = 0(0)\n  signed 8 0(0) << -72(ffffffb8) = 0(0)\n  signed 8 0(0) << -71(ffffffb9) = 0(0)\n  signed 8 0(0) << -70(ffffffba) = 0(0)\n  signed 8 0(0) << -69(ffffffbb) = 0(0)\n  signed 8 0(0) << -68(ffffffbc) = 0(0)\n  signed 8 0(0) << -67(ffffffbd) = 0(0)\n  signed 8 0(0) << -66(ffffffbe) = 0(0)\n  signed 8 0(0) << -65(ffffffbf) = 0(0)\n  signed 8 0(0) << -64(ffffffc0) = 0(0)\n  signed 8 0(0) << -63(ffffffc1) = 0(0)\n  signed 8 0(0) << -62(ffffffc2) = 0(0)\n  signed 8 0(0) << -61(ffffffc3) = 0(0)\n  signed 8 0(0) << -60(ffffffc4) = 0(0)\n  signed 8 0(0) << -59(ffffffc5) = 0(0)\n  signed 8 0(0) << -58(ffffffc6) = 0(0)\n  signed 8 0(0) << -57(ffffffc7) = 0(0)\n  signed 8 0(0) << -56(ffffffc8) = 0(0)\n  signed 8 0(0) << -55(ffffffc9) = 0(0)\n  signed 8 0(0) << -54(ffffffca) = 0(0)\n  signed 8 0(0) << -53(ffffffcb) = 0(0)\n  signed 8 0(0) << -52(ffffffcc) = 0(0)\n  signed 8 0(0) << -51(ffffffcd) = 0(0)\n  signed 8 0(0) << -50(ffffffce) = 0(0)\n  signed 8 0(0) << -49(ffffffcf) = 0(0)\n  signed 8 0(0) << -48(ffffffd0) = 0(0)\n  signed 8 0(0) << -47(ffffffd1) = 0(0)\n  signed 8 0(0) << -46(ffffffd2) = 0(0)\n  signed 8 0(0) << -45(ffffffd3) = 0(0)\n  signed 8 0(0) << -44(ffffffd4) = 0(0)\n  signed 8 0(0) << -43(ffffffd5) = 0(0)\n  signed 8 0(0) << -42(ffffffd6) = 0(0)\n  signed 8 0(0) << -41(ffffffd7) = 0(0)\n  signed 8 0(0) << -40(ffffffd8) = 0(0)\n  signed 8 0(0) << -39(ffffffd9) = 0(0)\n  signed 8 0(0) << -38(ffffffda) = 0(0)\n  signed 8 0(0) << -37(ffffffdb) = 0(0)\n  signed 8 0(0) << -36(ffffffdc) = 0(0)\n  signed 8 0(0) << -35(ffffffdd) = 0(0)\n  signed 8 0(0) << -34(ffffffde) = 0(0)\n  signed 8 0(0) << -33(ffffffdf) = 0(0)\n  signed 8 0(0) << -32(ffffffe0) = 0(0)\n  signed 8 0(0) << -31(ffffffe1) = 0(0)\n  signed 8 0(0) << -30(ffffffe2) = 0(0)\n  signed 8 0(0) << -29(ffffffe3) = 0(0)\n  signed 8 0(0) << -28(ffffffe4) = 0(0)\n  signed 8 0(0) << -27(ffffffe5) = 0(0)\n  signed 8 0(0) << -26(ffffffe6) = 0(0)\n  signed 8 0(0) << -25(ffffffe7) = 0(0)\n  signed 8 0(0) << -24(ffffffe8) = 0(0)\n  signed 8 0(0) << -23(ffffffe9) = 0(0)\n  signed 8 0(0) << -22(ffffffea) = 0(0)\n  signed 8 0(0) << -21(ffffffeb) = 0(0)\n  signed 8 0(0) << -20(ffffffec) = 0(0)\n  signed 8 0(0) << -19(ffffffed) = 0(0)\n  signed 8 0(0) << -18(ffffffee) = 0(0)\n  signed 8 0(0) << -17(ffffffef) = 0(0)\n  signed 8 0(0) << -16(fffffff0) = 0(0)\n  signed 8 0(0) << -15(fffffff1) = 0(0)\n  signed 8 0(0) << -14(fffffff2) = 0(0)\n  signed 8 0(0) << -13(fffffff3) = 0(0)\n  signed 8 0(0) << -12(fffffff4) = 0(0)\n  signed 8 0(0) << -11(fffffff5) = 0(0)\n  signed 8 0(0) << -10(fffffff6) = 0(0)\n  signed 8 0(0) << -9(fffffff7) = 0(0)\n  signed 8 0(0) << -8(fffffff8) = 0(0)\n  signed 8 0(0) << -7(fffffff9) = 0(0)\n  signed 8 0(0) << -6(fffffffa) = 0(0)\n  signed 8 0(0) << -5(fffffffb) = 0(0)\n  signed 8 0(0) << -4(fffffffc) = 0(0)\n  signed 8 0(0) << -3(fffffffd) = 0(0)\n  signed 8 0(0) << -2(fffffffe) = 0(0)\n  signed 8 0(0) << -1(ffffffff) = 0(0)\n  signed 8 0(0) << 0(0) = 0(0)\n  signed 8 0(0) << 1(1) = 0(0)\n  signed 8 0(0) << 2(2) = 0(0)\n  signed 8 0(0) << 3(3) = 0(0)\n  signed 8 0(0) << 4(4) = 0(0)\n  signed 8 0(0) << 5(5) = 0(0)\n  signed 8 0(0) << 6(6) = 0(0)\n  signed 8 0(0) << 7(7) = 0(0)\n  signed 8 0(0) << 8(8) = 0(0)\n  signed 8 0(0) << 9(9) = 0(0)\n  signed 8 0(0) << 10(a) = 0(0)\n  signed 8 0(0) << 11(b) = 0(0)\n  signed 8 0(0) << 12(c) = 0(0)\n  signed 8 0(0) << 13(d) = 0(0)\n  signed 8 0(0) << 14(e) = 0(0)\n  signed 8 0(0) << 15(f) = 0(0)\n  signed 8 0(0) << 16(10) = 0(0)\n  signed 8 0(0) << 17(11) = 0(0)\n  signed 8 0(0) << 18(12) = 0(0)\n  signed 8 0(0) << 19(13) = 0(0)\n  signed 8 0(0) << 20(14) = 0(0)\n  signed 8 0(0) << 21(15) = 0(0)\n  signed 8 0(0) << 22(16) = 0(0)\n  signed 8 0(0) << 23(17) = 0(0)\n  signed 8 0(0) << 24(18) = 0(0)\n  signed 8 0(0) << 25(19) = 0(0)\n  signed 8 0(0) << 26(1a) = 0(0)\n  signed 8 0(0) << 27(1b) = 0(0)\n  signed 8 0(0) << 28(1c) = 0(0)\n  signed 8 0(0) << 29(1d) = 0(0)\n  signed 8 0(0) << 30(1e) = 0(0)\n  signed 8 0(0) << 31(1f) = 0(0)\n  signed 8 0(0) << 32(20) = 0(0)\n  signed 8 0(0) << 33(21) = 0(0)\n  signed 8 0(0) << 34(22) = 0(0)\n  signed 8 0(0) << 35(23) = 0(0)\n  signed 8 0(0) << 36(24) = 0(0)\n  signed 8 0(0) << 37(25) = 0(0)\n  signed 8 0(0) << 38(26) = 0(0)\n  signed 8 0(0) << 39(27) = 0(0)\n  signed 8 0(0) << 40(28) = 0(0)\n  signed 8 0(0) << 41(29) = 0(0)\n  signed 8 0(0) << 42(2a) = 0(0)\n  signed 8 0(0) << 43(2b) = 0(0)\n  signed 8 0(0) << 44(2c) = 0(0)\n  signed 8 0(0) << 45(2d) = 0(0)\n  signed 8 0(0) << 46(2e) = 0(0)\n  signed 8 0(0) << 47(2f) = 0(0)\n  signed 8 0(0) << 48(30) = 0(0)\n  signed 8 0(0) << 49(31) = 0(0)\n  signed 8 0(0) << 50(32) = 0(0)\n  signed 8 0(0) << 51(33) = 0(0)\n  signed 8 0(0) << 52(34) = 0(0)\n  signed 8 0(0) << 53(35) = 0(0)\n  signed 8 0(0) << 54(36) = 0(0)\n  signed 8 0(0) << 55(37) = 0(0)\n  signed 8 0(0) << 56(38) = 0(0)\n  signed 8 0(0) << 57(39) = 0(0)\n  signed 8 0(0) << 58(3a) = 0(0)\n  signed 8 0(0) << 59(3b) = 0(0)\n  signed 8 0(0) << 60(3c) = 0(0)\n  signed 8 0(0) << 61(3d) = 0(0)\n  signed 8 0(0) << 62(3e) = 0(0)\n  signed 8 0(0) << 63(3f) = 0(0)\n  signed 8 0(0) << 64(40) = 0(0)\n  signed 8 0(0) << 65(41) = 0(0)\n  signed 8 0(0) << 66(42) = 0(0)\n  signed 8 0(0) << 67(43) = 0(0)\n  signed 8 0(0) << 68(44) = 0(0)\n  signed 8 0(0) << 69(45) = 0(0)\n  signed 8 0(0) << 70(46) = 0(0)\n  signed 8 0(0) << 71(47) = 0(0)\n  signed 8 0(0) << 72(48) = 0(0)\n  signed 8 0(0) << 73(49) = 0(0)\n  signed 8 0(0) << 74(4a) = 0(0)\n  signed 8 0(0) << 75(4b) = 0(0)\n  signed 8 0(0) << 76(4c) = 0(0)\n  signed 8 0(0) << 77(4d) = 0(0)\n  signed 8 0(0) << 78(4e) = 0(0)\n  signed 8 0(0) << 79(4f) = 0(0)\n  signed 8 0(0) << 80(50) = 0(0)\n  signed 8 0(0) << 81(51) = 0(0)\n  signed 8 0(0) << 82(52) = 0(0)\n  signed 8 0(0) << 83(53) = 0(0)\n  signed 8 0(0) << 84(54) = 0(0)\n  signed 8 0(0) << 85(55) = 0(0)\n  signed 8 0(0) << 86(56) = 0(0)\n  signed 8 0(0) << 87(57) = 0(0)\n  signed 8 0(0) << 88(58) = 0(0)\n  signed 8 0(0) << 89(59) = 0(0)\n  signed 8 0(0) << 90(5a) = 0(0)\n  signed 8 0(0) << 91(5b) = 0(0)\n  signed 8 0(0) << 92(5c) = 0(0)\n  signed 8 0(0) << 93(5d) = 0(0)\n  signed 8 0(0) << 94(5e) = 0(0)\n  signed 8 0(0) << 95(5f) = 0(0)\n  signed 8 0(0) << 96(60) = 0(0)\n  signed 8 0(0) << 97(61) = 0(0)\n  signed 8 0(0) << 98(62) = 0(0)\n  signed 8 0(0) << 99(63) = 0(0)\n  signed 8 0(0) << 100(64) = 0(0)\n  signed 8 0(0) << 101(65) = 0(0)\n  signed 8 0(0) << 102(66) = 0(0)\n  signed 8 0(0) << 103(67) = 0(0)\n  signed 8 0(0) << 104(68) = 0(0)\n  signed 8 0(0) << 105(69) = 0(0)\n  signed 8 0(0) << 106(6a) = 0(0)\n  signed 8 0(0) << 107(6b) = 0(0)\n  signed 8 0(0) << 108(6c) = 0(0)\n  signed 8 0(0) << 109(6d) = 0(0)\n  signed 8 0(0) << 110(6e) = 0(0)\n  signed 8 0(0) << 111(6f) = 0(0)\n  signed 8 0(0) << 112(70) = 0(0)\n  signed 8 0(0) << 113(71) = 0(0)\n  signed 8 0(0) << 114(72) = 0(0)\n  signed 8 0(0) << 115(73) = 0(0)\n  signed 8 0(0) << 116(74) = 0(0)\n  signed 8 0(0) << 117(75) = 0(0)\n  signed 8 0(0) << 118(76) = 0(0)\n  signed 8 0(0) << 119(77) = 0(0)\n  signed 8 0(0) << 120(78) = 0(0)\n  signed 8 0(0) << 121(79) = 0(0)\n  signed 8 0(0) << 122(7a) = 0(0)\n  signed 8 0(0) << 123(7b) = 0(0)\n  signed 8 0(0) << 124(7c) = 0(0)\n  signed 8 0(0) << 125(7d) = 0(0)\n  signed 8 0(0) << 126(7e) = 0(0)\n  signed 8 0(0) << 127(7f) = 0(0)\n  signed 8 1(1) << -128(ffffff80) = 1(1)\n  signed 8 1(1) << -127(ffffff81) = 2(2)\n  signed 8 1(1) << -126(ffffff82) = 4(4)\n  signed 8 1(1) << -125(ffffff83) = 8(8)\n  signed 8 1(1) << -124(ffffff84) = 16(10)\n  signed 8 1(1) << -123(ffffff85) = 32(20)\n  signed 8 1(1) << -122(ffffff86) = 64(40)\n  signed 8 1(1) << -121(ffffff87) = 128(80)\n  signed 8 1(1) << -120(ffffff88) = 256(100)\n  signed 8 1(1) << -119(ffffff89) = 512(200)\n  signed 8 1(1) << -118(ffffff8a) = 1024(400)\n  signed 8 1(1) << -117(ffffff8b) = 2048(800)\n  signed 8 1(1) << -116(ffffff8c) = 4096(1000)\n  signed 8 1(1) << -115(ffffff8d) = 8192(2000)\n  signed 8 1(1) << -114(ffffff8e) = 16384(4000)\n  signed 8 1(1) << -113(ffffff8f) = 32768(8000)\n  signed 8 1(1) << -112(ffffff90) = 65536(0)\n  signed 8 1(1) << -111(ffffff91) = 131072(0)\n  signed 8 1(1) << -110(ffffff92) = 262144(0)\n  signed 8 1(1) << -109(ffffff93) = 524288(0)\n  signed 8 1(1) << -108(ffffff94) = 1048576(0)\n  signed 8 1(1) << -107(ffffff95) = 2097152(0)\n  signed 8 1(1) << -106(ffffff96) = 4194304(0)\n  signed 8 1(1) << -105(ffffff97) = 8388608(0)\n  signed 8 1(1) << -104(ffffff98) = 16777216(0)\n  signed 8 1(1) << -103(ffffff99) = 33554432(0)\n  signed 8 1(1) << -102(ffffff9a) = 67108864(0)\n  signed 8 1(1) << -101(ffffff9b) = 134217728(0)\n  signed 8 1(1) << -100(ffffff9c) = 268435456(0)\n  signed 8 1(1) << -99(ffffff9d) = 536870912(0)\n  signed 8 1(1) << -98(ffffff9e) = 1073741824(0)\n  signed 8 1(1) << -97(ffffff9f) = -2147483648(0)\n  signed 8 1(1) << -96(ffffffa0) = 1(1)\n  signed 8 1(1) << -95(ffffffa1) = 2(2)\n  signed 8 1(1) << -94(ffffffa2) = 4(4)\n  signed 8 1(1) << -93(ffffffa3) = 8(8)\n  signed 8 1(1) << -92(ffffffa4) = 16(10)\n  signed 8 1(1) << -91(ffffffa5) = 32(20)\n  signed 8 1(1) << -90(ffffffa6) = 64(40)\n  signed 8 1(1) << -89(ffffffa7) = 128(80)\n  signed 8 1(1) << -88(ffffffa8) = 256(100)\n  signed 8 1(1) << -87(ffffffa9) = 512(200)\n  signed 8 1(1) << -86(ffffffaa) = 1024(400)\n  signed 8 1(1) << -85(ffffffab) = 2048(800)\n  signed 8 1(1) << -84(ffffffac) = 4096(1000)\n  signed 8 1(1) << -83(ffffffad) = 8192(2000)\n  signed 8 1(1) << -82(ffffffae) = 16384(4000)\n  signed 8 1(1) << -81(ffffffaf) = 32768(8000)\n  signed 8 1(1) << -80(ffffffb0) = 65536(0)\n  signed 8 1(1) << -79(ffffffb1) = 131072(0)\n  signed 8 1(1) << -78(ffffffb2) = 262144(0)\n  signed 8 1(1) << -77(ffffffb3) = 524288(0)\n  signed 8 1(1) << -76(ffffffb4) = 1048576(0)\n  signed 8 1(1) << -75(ffffffb5) = 2097152(0)\n  signed 8 1(1) << -74(ffffffb6) = 4194304(0)\n  signed 8 1(1) << -73(ffffffb7) = 8388608(0)\n  signed 8 1(1) << -72(ffffffb8) = 16777216(0)\n  signed 8 1(1) << -71(ffffffb9) = 33554432(0)\n  signed 8 1(1) << -70(ffffffba) = 67108864(0)\n  signed 8 1(1) << -69(ffffffbb) = 134217728(0)\n  signed 8 1(1) << -68(ffffffbc) = 268435456(0)\n  signed 8 1(1) << -67(ffffffbd) = 536870912(0)\n  signed 8 1(1) << -66(ffffffbe) = 1073741824(0)\n  signed 8 1(1) << -65(ffffffbf) = -2147483648(0)\n  signed 8 1(1) << -64(ffffffc0) = 1(1)\n  signed 8 1(1) << -63(ffffffc1) = 2(2)\n  signed 8 1(1) << -62(ffffffc2) = 4(4)\n  signed 8 1(1) << -61(ffffffc3) = 8(8)\n  signed 8 1(1) << -60(ffffffc4) = 16(10)\n  signed 8 1(1) << -59(ffffffc5) = 32(20)\n  signed 8 1(1) << -58(ffffffc6) = 64(40)\n  signed 8 1(1) << -57(ffffffc7) = 128(80)\n  signed 8 1(1) << -56(ffffffc8) = 256(100)\n  signed 8 1(1) << -55(ffffffc9) = 512(200)\n  signed 8 1(1) << -54(ffffffca) = 1024(400)\n  signed 8 1(1) << -53(ffffffcb) = 2048(800)\n  signed 8 1(1) << -52(ffffffcc) = 4096(1000)\n  signed 8 1(1) << -51(ffffffcd) = 8192(2000)\n  signed 8 1(1) << -50(ffffffce) = 16384(4000)\n  signed 8 1(1) << -49(ffffffcf) = 32768(8000)\n  signed 8 1(1) << -48(ffffffd0) = 65536(0)\n  signed 8 1(1) << -47(ffffffd1) = 131072(0)\n  signed 8 1(1) << -46(ffffffd2) = 262144(0)\n  signed 8 1(1) << -45(ffffffd3) = 524288(0)\n  signed 8 1(1) << -44(ffffffd4) = 1048576(0)\n  signed 8 1(1) << -43(ffffffd5) = 2097152(0)\n  signed 8 1(1) << -42(ffffffd6) = 4194304(0)\n  signed 8 1(1) << -41(ffffffd7) = 8388608(0)\n  signed 8 1(1) << -40(ffffffd8) = 16777216(0)\n  signed 8 1(1) << -39(ffffffd9) = 33554432(0)\n  signed 8 1(1) << -38(ffffffda) = 67108864(0)\n  signed 8 1(1) << -37(ffffffdb) = 134217728(0)\n  signed 8 1(1) << -36(ffffffdc) = 268435456(0)\n  signed 8 1(1) << -35(ffffffdd) = 536870912(0)\n  signed 8 1(1) << -34(ffffffde) = 1073741824(0)\n  signed 8 1(1) << -33(ffffffdf) = -2147483648(0)\n  signed 8 1(1) << -32(ffffffe0) = 1(1)\n  signed 8 1(1) << -31(ffffffe1) = 2(2)\n  signed 8 1(1) << -30(ffffffe2) = 4(4)\n  signed 8 1(1) << -29(ffffffe3) = 8(8)\n  signed 8 1(1) << -28(ffffffe4) = 16(10)\n  signed 8 1(1) << -27(ffffffe5) = 32(20)\n  signed 8 1(1) << -26(ffffffe6) = 64(40)\n  signed 8 1(1) << -25(ffffffe7) = 128(80)\n  signed 8 1(1) << -24(ffffffe8) = 256(100)\n  signed 8 1(1) << -23(ffffffe9) = 512(200)\n  signed 8 1(1) << -22(ffffffea) = 1024(400)\n  signed 8 1(1) << -21(ffffffeb) = 2048(800)\n  signed 8 1(1) << -20(ffffffec) = 4096(1000)\n  signed 8 1(1) << -19(ffffffed) = 8192(2000)\n  signed 8 1(1) << -18(ffffffee) = 16384(4000)\n  signed 8 1(1) << -17(ffffffef) = 32768(8000)\n  signed 8 1(1) << -16(fffffff0) = 65536(0)\n  signed 8 1(1) << -15(fffffff1) = 131072(0)\n  signed 8 1(1) << -14(fffffff2) = 262144(0)\n  signed 8 1(1) << -13(fffffff3) = 524288(0)\n  signed 8 1(1) << -12(fffffff4) = 1048576(0)\n  signed 8 1(1) << -11(fffffff5) = 2097152(0)\n  signed 8 1(1) << -10(fffffff6) = 4194304(0)\n  signed 8 1(1) << -9(fffffff7) = 8388608(0)\n  signed 8 1(1) << -8(fffffff8) = 16777216(0)\n  signed 8 1(1) << -7(fffffff9) = 33554432(0)\n  signed 8 1(1) << -6(fffffffa) = 67108864(0)\n  signed 8 1(1) << -5(fffffffb) = 134217728(0)\n  signed 8 1(1) << -4(fffffffc) = 268435456(0)\n  signed 8 1(1) << -3(fffffffd) = 536870912(0)\n  signed 8 1(1) << -2(fffffffe) = 1073741824(0)\n  signed 8 1(1) << -1(ffffffff) = -2147483648(0)\n  signed 8 1(1) << 0(0) = 1(1)\n  signed 8 1(1) << 1(1) = 2(2)\n  signed 8 1(1) << 2(2) = 4(4)\n  signed 8 1(1) << 3(3) = 8(8)\n  signed 8 1(1) << 4(4) = 16(10)\n  signed 8 1(1) << 5(5) = 32(20)\n  signed 8 1(1) << 6(6) = 64(40)\n  signed 8 1(1) << 7(7) = 128(80)\n  signed 8 1(1) << 8(8) = 256(100)\n  signed 8 1(1) << 9(9) = 512(200)\n  signed 8 1(1) << 10(a) = 1024(400)\n  signed 8 1(1) << 11(b) = 2048(800)\n  signed 8 1(1) << 12(c) = 4096(1000)\n  signed 8 1(1) << 13(d) = 8192(2000)\n  signed 8 1(1) << 14(e) = 16384(4000)\n  signed 8 1(1) << 15(f) = 32768(8000)\n  signed 8 1(1) << 16(10) = 65536(0)\n  signed 8 1(1) << 17(11) = 131072(0)\n  signed 8 1(1) << 18(12) = 262144(0)\n  signed 8 1(1) << 19(13) = 524288(0)\n  signed 8 1(1) << 20(14) = 1048576(0)\n  signed 8 1(1) << 21(15) = 2097152(0)\n  signed 8 1(1) << 22(16) = 4194304(0)\n  signed 8 1(1) << 23(17) = 8388608(0)\n  signed 8 1(1) << 24(18) = 16777216(0)\n  signed 8 1(1) << 25(19) = 33554432(0)\n  signed 8 1(1) << 26(1a) = 67108864(0)\n  signed 8 1(1) << 27(1b) = 134217728(0)\n  signed 8 1(1) << 28(1c) = 268435456(0)\n  signed 8 1(1) << 29(1d) = 536870912(0)\n  signed 8 1(1) << 30(1e) = 1073741824(0)\n  signed 8 1(1) << 31(1f) = -2147483648(0)\n  signed 8 1(1) << 32(20) = 1(1)\n  signed 8 1(1) << 33(21) = 2(2)\n  signed 8 1(1) << 34(22) = 4(4)\n  signed 8 1(1) << 35(23) = 8(8)\n  signed 8 1(1) << 36(24) = 16(10)\n  signed 8 1(1) << 37(25) = 32(20)\n  signed 8 1(1) << 38(26) = 64(40)\n  signed 8 1(1) << 39(27) = 128(80)\n  signed 8 1(1) << 40(28) = 256(100)\n  signed 8 1(1) << 41(29) = 512(200)\n  signed 8 1(1) << 42(2a) = 1024(400)\n  signed 8 1(1) << 43(2b) = 2048(800)\n  signed 8 1(1) << 44(2c) = 4096(1000)\n  signed 8 1(1) << 45(2d) = 8192(2000)\n  signed 8 1(1) << 46(2e) = 16384(4000)\n  signed 8 1(1) << 47(2f) = 32768(8000)\n  signed 8 1(1) << 48(30) = 65536(0)\n  signed 8 1(1) << 49(31) = 131072(0)\n  signed 8 1(1) << 50(32) = 262144(0)\n  signed 8 1(1) << 51(33) = 524288(0)\n  signed 8 1(1) << 52(34) = 1048576(0)\n  signed 8 1(1) << 53(35) = 2097152(0)\n  signed 8 1(1) << 54(36) = 4194304(0)\n  signed 8 1(1) << 55(37) = 8388608(0)\n  signed 8 1(1) << 56(38) = 16777216(0)\n  signed 8 1(1) << 57(39) = 33554432(0)\n  signed 8 1(1) << 58(3a) = 67108864(0)\n  signed 8 1(1) << 59(3b) = 134217728(0)\n  signed 8 1(1) << 60(3c) = 268435456(0)\n  signed 8 1(1) << 61(3d) = 536870912(0)\n  signed 8 1(1) << 62(3e) = 1073741824(0)\n  signed 8 1(1) << 63(3f) = -2147483648(0)\n  signed 8 1(1) << 64(40) = 1(1)\n  signed 8 1(1) << 65(41) = 2(2)\n  signed 8 1(1) << 66(42) = 4(4)\n  signed 8 1(1) << 67(43) = 8(8)\n  signed 8 1(1) << 68(44) = 16(10)\n  signed 8 1(1) << 69(45) = 32(20)\n  signed 8 1(1) << 70(46) = 64(40)\n  signed 8 1(1) << 71(47) = 128(80)\n  signed 8 1(1) << 72(48) = 256(100)\n  signed 8 1(1) << 73(49) = 512(200)\n  signed 8 1(1) << 74(4a) = 1024(400)\n  signed 8 1(1) << 75(4b) = 2048(800)\n  signed 8 1(1) << 76(4c) = 4096(1000)\n  signed 8 1(1) << 77(4d) = 8192(2000)\n  signed 8 1(1) << 78(4e) = 16384(4000)\n  signed 8 1(1) << 79(4f) = 32768(8000)\n  signed 8 1(1) << 80(50) = 65536(0)\n  signed 8 1(1) << 81(51) = 131072(0)\n  signed 8 1(1) << 82(52) = 262144(0)\n  signed 8 1(1) << 83(53) = 524288(0)\n  signed 8 1(1) << 84(54) = 1048576(0)\n  signed 8 1(1) << 85(55) = 2097152(0)\n  signed 8 1(1) << 86(56) = 4194304(0)\n  signed 8 1(1) << 87(57) = 8388608(0)\n  signed 8 1(1) << 88(58) = 16777216(0)\n  signed 8 1(1) << 89(59) = 33554432(0)\n  signed 8 1(1) << 90(5a) = 67108864(0)\n  signed 8 1(1) << 91(5b) = 134217728(0)\n  signed 8 1(1) << 92(5c) = 268435456(0)\n  signed 8 1(1) << 93(5d) = 536870912(0)\n  signed 8 1(1) << 94(5e) = 1073741824(0)\n  signed 8 1(1) << 95(5f) = -2147483648(0)\n  signed 8 1(1) << 96(60) = 1(1)\n  signed 8 1(1) << 97(61) = 2(2)\n  signed 8 1(1) << 98(62) = 4(4)\n  signed 8 1(1) << 99(63) = 8(8)\n  signed 8 1(1) << 100(64) = 16(10)\n  signed 8 1(1) << 101(65) = 32(20)\n  signed 8 1(1) << 102(66) = 64(40)\n  signed 8 1(1) << 103(67) = 128(80)\n  signed 8 1(1) << 104(68) = 256(100)\n  signed 8 1(1) << 105(69) = 512(200)\n  signed 8 1(1) << 106(6a) = 1024(400)\n  signed 8 1(1) << 107(6b) = 2048(800)\n  signed 8 1(1) << 108(6c) = 4096(1000)\n  signed 8 1(1) << 109(6d) = 8192(2000)\n  signed 8 1(1) << 110(6e) = 16384(4000)\n  signed 8 1(1) << 111(6f) = 32768(8000)\n  signed 8 1(1) << 112(70) = 65536(0)\n  signed 8 1(1) << 113(71) = 131072(0)\n  signed 8 1(1) << 114(72) = 262144(0)\n  signed 8 1(1) << 115(73) = 524288(0)\n  signed 8 1(1) << 116(74) = 1048576(0)\n  signed 8 1(1) << 117(75) = 2097152(0)\n  signed 8 1(1) << 118(76) = 4194304(0)\n  signed 8 1(1) << 119(77) = 8388608(0)\n  signed 8 1(1) << 120(78) = 16777216(0)\n  signed 8 1(1) << 121(79) = 33554432(0)\n  signed 8 1(1) << 122(7a) = 67108864(0)\n  signed 8 1(1) << 123(7b) = 134217728(0)\n  signed 8 1(1) << 124(7c) = 268435456(0)\n  signed 8 1(1) << 125(7d) = 536870912(0)\n  signed 8 1(1) << 126(7e) = 1073741824(0)\n  signed 8 1(1) << 127(7f) = -2147483648(0)\n  signed 8 2(2) << -128(ffffff80) = 2(2)\n  signed 8 2(2) << -127(ffffff81) = 4(4)\n  signed 8 2(2) << -126(ffffff82) = 8(8)\n  signed 8 2(2) << -125(ffffff83) = 16(10)\n  signed 8 2(2) << -124(ffffff84) = 32(20)\n  signed 8 2(2) << -123(ffffff85) = 64(40)\n  signed 8 2(2) << -122(ffffff86) = 128(80)\n  signed 8 2(2) << -121(ffffff87) = 256(100)\n  signed 8 2(2) << -120(ffffff88) = 512(200)\n  signed 8 2(2) << -119(ffffff89) = 1024(400)\n  signed 8 2(2) << -118(ffffff8a) = 2048(800)\n  signed 8 2(2) << -117(ffffff8b) = 4096(1000)\n  signed 8 2(2) << -116(ffffff8c) = 8192(2000)\n  signed 8 2(2) << -115(ffffff8d) = 16384(4000)\n  signed 8 2(2) << -114(ffffff8e) = 32768(8000)\n  signed 8 2(2) << -113(ffffff8f) = 65536(0)\n  signed 8 2(2) << -112(ffffff90) = 131072(0)\n  signed 8 2(2) << -111(ffffff91) = 262144(0)\n  signed 8 2(2) << -110(ffffff92) = 524288(0)\n  signed 8 2(2) << -109(ffffff93) = 1048576(0)\n  signed 8 2(2) << -108(ffffff94) = 2097152(0)\n  signed 8 2(2) << -107(ffffff95) = 4194304(0)\n  signed 8 2(2) << -106(ffffff96) = 8388608(0)\n  signed 8 2(2) << -105(ffffff97) = 16777216(0)\n  signed 8 2(2) << -104(ffffff98) = 33554432(0)\n  signed 8 2(2) << -103(ffffff99) = 67108864(0)\n  signed 8 2(2) << -102(ffffff9a) = 134217728(0)\n  signed 8 2(2) << -101(ffffff9b) = 268435456(0)\n  signed 8 2(2) << -100(ffffff9c) = 536870912(0)\n  signed 8 2(2) << -99(ffffff9d) = 1073741824(0)\n  signed 8 2(2) << -98(ffffff9e) = -2147483648(0)\n  signed 8 2(2) << -97(ffffff9f) = 0(0)\n  signed 8 2(2) << -96(ffffffa0) = 2(2)\n  signed 8 2(2) << -95(ffffffa1) = 4(4)\n  signed 8 2(2) << -94(ffffffa2) = 8(8)\n  signed 8 2(2) << -93(ffffffa3) = 16(10)\n  signed 8 2(2) << -92(ffffffa4) = 32(20)\n  signed 8 2(2) << -91(ffffffa5) = 64(40)\n  signed 8 2(2) << -90(ffffffa6) = 128(80)\n  signed 8 2(2) << -89(ffffffa7) = 256(100)\n  signed 8 2(2) << -88(ffffffa8) = 512(200)\n  signed 8 2(2) << -87(ffffffa9) = 1024(400)\n  signed 8 2(2) << -86(ffffffaa) = 2048(800)\n  signed 8 2(2) << -85(ffffffab) = 4096(1000)\n  signed 8 2(2) << -84(ffffffac) = 8192(2000)\n  signed 8 2(2) << -83(ffffffad) = 16384(4000)\n  signed 8 2(2) << -82(ffffffae) = 32768(8000)\n  signed 8 2(2) << -81(ffffffaf) = 65536(0)\n  signed 8 2(2) << -80(ffffffb0) = 131072(0)\n  signed 8 2(2) << -79(ffffffb1) = 262144(0)\n  signed 8 2(2) << -78(ffffffb2) = 524288(0)\n  signed 8 2(2) << -77(ffffffb3) = 1048576(0)\n  signed 8 2(2) << -76(ffffffb4) = 2097152(0)\n  signed 8 2(2) << -75(ffffffb5) = 4194304(0)\n  signed 8 2(2) << -74(ffffffb6) = 8388608(0)\n  signed 8 2(2) << -73(ffffffb7) = 16777216(0)\n  signed 8 2(2) << -72(ffffffb8) = 33554432(0)\n  signed 8 2(2) << -71(ffffffb9) = 67108864(0)\n  signed 8 2(2) << -70(ffffffba) = 134217728(0)\n  signed 8 2(2) << -69(ffffffbb) = 268435456(0)\n  signed 8 2(2) << -68(ffffffbc) = 536870912(0)\n  signed 8 2(2) << -67(ffffffbd) = 1073741824(0)\n  signed 8 2(2) << -66(ffffffbe) = -2147483648(0)\n  signed 8 2(2) << -65(ffffffbf) = 0(0)\n  signed 8 2(2) << -64(ffffffc0) = 2(2)\n  signed 8 2(2) << -63(ffffffc1) = 4(4)\n  signed 8 2(2) << -62(ffffffc2) = 8(8)\n  signed 8 2(2) << -61(ffffffc3) = 16(10)\n  signed 8 2(2) << -60(ffffffc4) = 32(20)\n  signed 8 2(2) << -59(ffffffc5) = 64(40)\n  signed 8 2(2) << -58(ffffffc6) = 128(80)\n  signed 8 2(2) << -57(ffffffc7) = 256(100)\n  signed 8 2(2) << -56(ffffffc8) = 512(200)\n  signed 8 2(2) << -55(ffffffc9) = 1024(400)\n  signed 8 2(2) << -54(ffffffca) = 2048(800)\n  signed 8 2(2) << -53(ffffffcb) = 4096(1000)\n  signed 8 2(2) << -52(ffffffcc) = 8192(2000)\n  signed 8 2(2) << -51(ffffffcd) = 16384(4000)\n  signed 8 2(2) << -50(ffffffce) = 32768(8000)\n  signed 8 2(2) << -49(ffffffcf) = 65536(0)\n  signed 8 2(2) << -48(ffffffd0) = 131072(0)\n  signed 8 2(2) << -47(ffffffd1) = 262144(0)\n  signed 8 2(2) << -46(ffffffd2) = 524288(0)\n  signed 8 2(2) << -45(ffffffd3) = 1048576(0)\n  signed 8 2(2) << -44(ffffffd4) = 2097152(0)\n  signed 8 2(2) << -43(ffffffd5) = 4194304(0)\n  signed 8 2(2) << -42(ffffffd6) = 8388608(0)\n  signed 8 2(2) << -41(ffffffd7) = 16777216(0)\n  signed 8 2(2) << -40(ffffffd8) = 33554432(0)\n  signed 8 2(2) << -39(ffffffd9) = 67108864(0)\n  signed 8 2(2) << -38(ffffffda) = 134217728(0)\n  signed 8 2(2) << -37(ffffffdb) = 268435456(0)\n  signed 8 2(2) << -36(ffffffdc) = 536870912(0)\n  signed 8 2(2) << -35(ffffffdd) = 1073741824(0)\n  signed 8 2(2) << -34(ffffffde) = -2147483648(0)\n  signed 8 2(2) << -33(ffffffdf) = 0(0)\n  signed 8 2(2) << -32(ffffffe0) = 2(2)\n  signed 8 2(2) << -31(ffffffe1) = 4(4)\n  signed 8 2(2) << -30(ffffffe2) = 8(8)\n  signed 8 2(2) << -29(ffffffe3) = 16(10)\n  signed 8 2(2) << -28(ffffffe4) = 32(20)\n  signed 8 2(2) << -27(ffffffe5) = 64(40)\n  signed 8 2(2) << -26(ffffffe6) = 128(80)\n  signed 8 2(2) << -25(ffffffe7) = 256(100)\n  signed 8 2(2) << -24(ffffffe8) = 512(200)\n  signed 8 2(2) << -23(ffffffe9) = 1024(400)\n  signed 8 2(2) << -22(ffffffea) = 2048(800)\n  signed 8 2(2) << -21(ffffffeb) = 4096(1000)\n  signed 8 2(2) << -20(ffffffec) = 8192(2000)\n  signed 8 2(2) << -19(ffffffed) = 16384(4000)\n  signed 8 2(2) << -18(ffffffee) = 32768(8000)\n  signed 8 2(2) << -17(ffffffef) = 65536(0)\n  signed 8 2(2) << -16(fffffff0) = 131072(0)\n  signed 8 2(2) << -15(fffffff1) = 262144(0)\n  signed 8 2(2) << -14(fffffff2) = 524288(0)\n  signed 8 2(2) << -13(fffffff3) = 1048576(0)\n  signed 8 2(2) << -12(fffffff4) = 2097152(0)\n  signed 8 2(2) << -11(fffffff5) = 4194304(0)\n  signed 8 2(2) << -10(fffffff6) = 8388608(0)\n  signed 8 2(2) << -9(fffffff7) = 16777216(0)\n  signed 8 2(2) << -8(fffffff8) = 33554432(0)\n  signed 8 2(2) << -7(fffffff9) = 67108864(0)\n  signed 8 2(2) << -6(fffffffa) = 134217728(0)\n  signed 8 2(2) << -5(fffffffb) = 268435456(0)\n  signed 8 2(2) << -4(fffffffc) = 536870912(0)\n  signed 8 2(2) << -3(fffffffd) = 1073741824(0)\n  signed 8 2(2) << -2(fffffffe) = -2147483648(0)\n  signed 8 2(2) << -1(ffffffff) = 0(0)\n  signed 8 2(2) << 0(0) = 2(2)\n  signed 8 2(2) << 1(1) = 4(4)\n  signed 8 2(2) << 2(2) = 8(8)\n  signed 8 2(2) << 3(3) = 16(10)\n  signed 8 2(2) << 4(4) = 32(20)\n  signed 8 2(2) << 5(5) = 64(40)\n  signed 8 2(2) << 6(6) = 128(80)\n  signed 8 2(2) << 7(7) = 256(100)\n  signed 8 2(2) << 8(8) = 512(200)\n  signed 8 2(2) << 9(9) = 1024(400)\n  signed 8 2(2) << 10(a) = 2048(800)\n  signed 8 2(2) << 11(b) = 4096(1000)\n  signed 8 2(2) << 12(c) = 8192(2000)\n  signed 8 2(2) << 13(d) = 16384(4000)\n  signed 8 2(2) << 14(e) = 32768(8000)\n  signed 8 2(2) << 15(f) = 65536(0)\n  signed 8 2(2) << 16(10) = 131072(0)\n  signed 8 2(2) << 17(11) = 262144(0)\n  signed 8 2(2) << 18(12) = 524288(0)\n  signed 8 2(2) << 19(13) = 1048576(0)\n  signed 8 2(2) << 20(14) = 2097152(0)\n  signed 8 2(2) << 21(15) = 4194304(0)\n  signed 8 2(2) << 22(16) = 8388608(0)\n  signed 8 2(2) << 23(17) = 16777216(0)\n  signed 8 2(2) << 24(18) = 33554432(0)\n  signed 8 2(2) << 25(19) = 67108864(0)\n  signed 8 2(2) << 26(1a) = 134217728(0)\n  signed 8 2(2) << 27(1b) = 268435456(0)\n  signed 8 2(2) << 28(1c) = 536870912(0)\n  signed 8 2(2) << 29(1d) = 1073741824(0)\n  signed 8 2(2) << 30(1e) = -2147483648(0)\n  signed 8 2(2) << 31(1f) = 0(0)\n  signed 8 2(2) << 32(20) = 2(2)\n  signed 8 2(2) << 33(21) = 4(4)\n  signed 8 2(2) << 34(22) = 8(8)\n  signed 8 2(2) << 35(23) = 16(10)\n  signed 8 2(2) << 36(24) = 32(20)\n  signed 8 2(2) << 37(25) = 64(40)\n  signed 8 2(2) << 38(26) = 128(80)\n  signed 8 2(2) << 39(27) = 256(100)\n  signed 8 2(2) << 40(28) = 512(200)\n  signed 8 2(2) << 41(29) = 1024(400)\n  signed 8 2(2) << 42(2a) = 2048(800)\n  signed 8 2(2) << 43(2b) = 4096(1000)\n  signed 8 2(2) << 44(2c) = 8192(2000)\n  signed 8 2(2) << 45(2d) = 16384(4000)\n  signed 8 2(2) << 46(2e) = 32768(8000)\n  signed 8 2(2) << 47(2f) = 65536(0)\n  signed 8 2(2) << 48(30) = 131072(0)\n  signed 8 2(2) << 49(31) = 262144(0)\n  signed 8 2(2) << 50(32) = 524288(0)\n  signed 8 2(2) << 51(33) = 1048576(0)\n  signed 8 2(2) << 52(34) = 2097152(0)\n  signed 8 2(2) << 53(35) = 4194304(0)\n  signed 8 2(2) << 54(36) = 8388608(0)\n  signed 8 2(2) << 55(37) = 16777216(0)\n  signed 8 2(2) << 56(38) = 33554432(0)\n  signed 8 2(2) << 57(39) = 67108864(0)\n  signed 8 2(2) << 58(3a) = 134217728(0)\n  signed 8 2(2) << 59(3b) = 268435456(0)\n  signed 8 2(2) << 60(3c) = 536870912(0)\n  signed 8 2(2) << 61(3d) = 1073741824(0)\n  signed 8 2(2) << 62(3e) = -2147483648(0)\n  signed 8 2(2) << 63(3f) = 0(0)\n  signed 8 2(2) << 64(40) = 2(2)\n  signed 8 2(2) << 65(41) = 4(4)\n  signed 8 2(2) << 66(42) = 8(8)\n  signed 8 2(2) << 67(43) = 16(10)\n  signed 8 2(2) << 68(44) = 32(20)\n  signed 8 2(2) << 69(45) = 64(40)\n  signed 8 2(2) << 70(46) = 128(80)\n  signed 8 2(2) << 71(47) = 256(100)\n  signed 8 2(2) << 72(48) = 512(200)\n  signed 8 2(2) << 73(49) = 1024(400)\n  signed 8 2(2) << 74(4a) = 2048(800)\n  signed 8 2(2) << 75(4b) = 4096(1000)\n  signed 8 2(2) << 76(4c) = 8192(2000)\n  signed 8 2(2) << 77(4d) = 16384(4000)\n  signed 8 2(2) << 78(4e) = 32768(8000)\n  signed 8 2(2) << 79(4f) = 65536(0)\n  signed 8 2(2) << 80(50) = 131072(0)\n  signed 8 2(2) << 81(51) = 262144(0)\n  signed 8 2(2) << 82(52) = 524288(0)\n  signed 8 2(2) << 83(53) = 1048576(0)\n  signed 8 2(2) << 84(54) = 2097152(0)\n  signed 8 2(2) << 85(55) = 4194304(0)\n  signed 8 2(2) << 86(56) = 8388608(0)\n  signed 8 2(2) << 87(57) = 16777216(0)\n  signed 8 2(2) << 88(58) = 33554432(0)\n  signed 8 2(2) << 89(59) = 67108864(0)\n  signed 8 2(2) << 90(5a) = 134217728(0)\n  signed 8 2(2) << 91(5b) = 268435456(0)\n  signed 8 2(2) << 92(5c) = 536870912(0)\n  signed 8 2(2) << 93(5d) = 1073741824(0)\n  signed 8 2(2) << 94(5e) = -2147483648(0)\n  signed 8 2(2) << 95(5f) = 0(0)\n  signed 8 2(2) << 96(60) = 2(2)\n  signed 8 2(2) << 97(61) = 4(4)\n  signed 8 2(2) << 98(62) = 8(8)\n  signed 8 2(2) << 99(63) = 16(10)\n  signed 8 2(2) << 100(64) = 32(20)\n  signed 8 2(2) << 101(65) = 64(40)\n  signed 8 2(2) << 102(66) = 128(80)\n  signed 8 2(2) << 103(67) = 256(100)\n  signed 8 2(2) << 104(68) = 512(200)\n  signed 8 2(2) << 105(69) = 1024(400)\n  signed 8 2(2) << 106(6a) = 2048(800)\n  signed 8 2(2) << 107(6b) = 4096(1000)\n  signed 8 2(2) << 108(6c) = 8192(2000)\n  signed 8 2(2) << 109(6d) = 16384(4000)\n  signed 8 2(2) << 110(6e) = 32768(8000)\n  signed 8 2(2) << 111(6f) = 65536(0)\n  signed 8 2(2) << 112(70) = 131072(0)\n  signed 8 2(2) << 113(71) = 262144(0)\n  signed 8 2(2) << 114(72) = 524288(0)\n  signed 8 2(2) << 115(73) = 1048576(0)\n  signed 8 2(2) << 116(74) = 2097152(0)\n  signed 8 2(2) << 117(75) = 4194304(0)\n  signed 8 2(2) << 118(76) = 8388608(0)\n  signed 8 2(2) << 119(77) = 16777216(0)\n  signed 8 2(2) << 120(78) = 33554432(0)\n  signed 8 2(2) << 121(79) = 67108864(0)\n  signed 8 2(2) << 122(7a) = 134217728(0)\n  signed 8 2(2) << 123(7b) = 268435456(0)\n  signed 8 2(2) << 124(7c) = 536870912(0)\n  signed 8 2(2) << 125(7d) = 1073741824(0)\n  signed 8 2(2) << 126(7e) = -2147483648(0)\n  signed 8 2(2) << 127(7f) = 0(0)\n  signed 8 3(3) << -128(ffffff80) = 3(3)\n  signed 8 3(3) << -127(ffffff81) = 6(6)\n  signed 8 3(3) << -126(ffffff82) = 12(c)\n  signed 8 3(3) << -125(ffffff83) = 24(18)\n  signed 8 3(3) << -124(ffffff84) = 48(30)\n  signed 8 3(3) << -123(ffffff85) = 96(60)\n  signed 8 3(3) << -122(ffffff86) = 192(c0)\n  signed 8 3(3) << -121(ffffff87) = 384(180)\n  signed 8 3(3) << -120(ffffff88) = 768(300)\n  signed 8 3(3) << -119(ffffff89) = 1536(600)\n  signed 8 3(3) << -118(ffffff8a) = 3072(c00)\n  signed 8 3(3) << -117(ffffff8b) = 6144(1800)\n  signed 8 3(3) << -116(ffffff8c) = 12288(3000)\n  signed 8 3(3) << -115(ffffff8d) = 24576(6000)\n  signed 8 3(3) << -114(ffffff8e) = 49152(c000)\n  signed 8 3(3) << -113(ffffff8f) = 98304(8000)\n  signed 8 3(3) << -112(ffffff90) = 196608(0)\n  signed 8 3(3) << -111(ffffff91) = 393216(0)\n  signed 8 3(3) << -110(ffffff92) = 786432(0)\n  signed 8 3(3) << -109(ffffff93) = 1572864(0)\n  signed 8 3(3) << -108(ffffff94) = 3145728(0)\n  signed 8 3(3) << -107(ffffff95) = 6291456(0)\n  signed 8 3(3) << -106(ffffff96) = 12582912(0)\n  signed 8 3(3) << -105(ffffff97) = 25165824(0)\n  signed 8 3(3) << -104(ffffff98) = 50331648(0)\n  signed 8 3(3) << -103(ffffff99) = 100663296(0)\n  signed 8 3(3) << -102(ffffff9a) = 201326592(0)\n  signed 8 3(3) << -101(ffffff9b) = 402653184(0)\n  signed 8 3(3) << -100(ffffff9c) = 805306368(0)\n  signed 8 3(3) << -99(ffffff9d) = 1610612736(0)\n  signed 8 3(3) << -98(ffffff9e) = -1073741824(0)\n  signed 8 3(3) << -97(ffffff9f) = -2147483648(0)\n  signed 8 3(3) << -96(ffffffa0) = 3(3)\n  signed 8 3(3) << -95(ffffffa1) = 6(6)\n  signed 8 3(3) << -94(ffffffa2) = 12(c)\n  signed 8 3(3) << -93(ffffffa3) = 24(18)\n  signed 8 3(3) << -92(ffffffa4) = 48(30)\n  signed 8 3(3) << -91(ffffffa5) = 96(60)\n  signed 8 3(3) << -90(ffffffa6) = 192(c0)\n  signed 8 3(3) << -89(ffffffa7) = 384(180)\n  signed 8 3(3) << -88(ffffffa8) = 768(300)\n  signed 8 3(3) << -87(ffffffa9) = 1536(600)\n  signed 8 3(3) << -86(ffffffaa) = 3072(c00)\n  signed 8 3(3) << -85(ffffffab) = 6144(1800)\n  signed 8 3(3) << -84(ffffffac) = 12288(3000)\n  signed 8 3(3) << -83(ffffffad) = 24576(6000)\n  signed 8 3(3) << -82(ffffffae) = 49152(c000)\n  signed 8 3(3) << -81(ffffffaf) = 98304(8000)\n  signed 8 3(3) << -80(ffffffb0) = 196608(0)\n  signed 8 3(3) << -79(ffffffb1) = 393216(0)\n  signed 8 3(3) << -78(ffffffb2) = 786432(0)\n  signed 8 3(3) << -77(ffffffb3) = 1572864(0)\n  signed 8 3(3) << -76(ffffffb4) = 3145728(0)\n  signed 8 3(3) << -75(ffffffb5) = 6291456(0)\n  signed 8 3(3) << -74(ffffffb6) = 12582912(0)\n  signed 8 3(3) << -73(ffffffb7) = 25165824(0)\n  signed 8 3(3) << -72(ffffffb8) = 50331648(0)\n  signed 8 3(3) << -71(ffffffb9) = 100663296(0)\n  signed 8 3(3) << -70(ffffffba) = 201326592(0)\n  signed 8 3(3) << -69(ffffffbb) = 402653184(0)\n  signed 8 3(3) << -68(ffffffbc) = 805306368(0)\n  signed 8 3(3) << -67(ffffffbd) = 1610612736(0)\n  signed 8 3(3) << -66(ffffffbe) = -1073741824(0)\n  signed 8 3(3) << -65(ffffffbf) = -2147483648(0)\n  signed 8 3(3) << -64(ffffffc0) = 3(3)\n  signed 8 3(3) << -63(ffffffc1) = 6(6)\n  signed 8 3(3) << -62(ffffffc2) = 12(c)\n  signed 8 3(3) << -61(ffffffc3) = 24(18)\n  signed 8 3(3) << -60(ffffffc4) = 48(30)\n  signed 8 3(3) << -59(ffffffc5) = 96(60)\n  signed 8 3(3) << -58(ffffffc6) = 192(c0)\n  signed 8 3(3) << -57(ffffffc7) = 384(180)\n  signed 8 3(3) << -56(ffffffc8) = 768(300)\n  signed 8 3(3) << -55(ffffffc9) = 1536(600)\n  signed 8 3(3) << -54(ffffffca) = 3072(c00)\n  signed 8 3(3) << -53(ffffffcb) = 6144(1800)\n  signed 8 3(3) << -52(ffffffcc) = 12288(3000)\n  signed 8 3(3) << -51(ffffffcd) = 24576(6000)\n  signed 8 3(3) << -50(ffffffce) = 49152(c000)\n  signed 8 3(3) << -49(ffffffcf) = 98304(8000)\n  signed 8 3(3) << -48(ffffffd0) = 196608(0)\n  signed 8 3(3) << -47(ffffffd1) = 393216(0)\n  signed 8 3(3) << -46(ffffffd2) = 786432(0)\n  signed 8 3(3) << -45(ffffffd3) = 1572864(0)\n  signed 8 3(3) << -44(ffffffd4) = 3145728(0)\n  signed 8 3(3) << -43(ffffffd5) = 6291456(0)\n  signed 8 3(3) << -42(ffffffd6) = 12582912(0)\n  signed 8 3(3) << -41(ffffffd7) = 25165824(0)\n  signed 8 3(3) << -40(ffffffd8) = 50331648(0)\n  signed 8 3(3) << -39(ffffffd9) = 100663296(0)\n  signed 8 3(3) << -38(ffffffda) = 201326592(0)\n  signed 8 3(3) << -37(ffffffdb) = 402653184(0)\n  signed 8 3(3) << -36(ffffffdc) = 805306368(0)\n  signed 8 3(3) << -35(ffffffdd) = 1610612736(0)\n  signed 8 3(3) << -34(ffffffde) = -1073741824(0)\n  signed 8 3(3) << -33(ffffffdf) = -2147483648(0)\n  signed 8 3(3) << -32(ffffffe0) = 3(3)\n  signed 8 3(3) << -31(ffffffe1) = 6(6)\n  signed 8 3(3) << -30(ffffffe2) = 12(c)\n  signed 8 3(3) << -29(ffffffe3) = 24(18)\n  signed 8 3(3) << -28(ffffffe4) = 48(30)\n  signed 8 3(3) << -27(ffffffe5) = 96(60)\n  signed 8 3(3) << -26(ffffffe6) = 192(c0)\n  signed 8 3(3) << -25(ffffffe7) = 384(180)\n  signed 8 3(3) << -24(ffffffe8) = 768(300)\n  signed 8 3(3) << -23(ffffffe9) = 1536(600)\n  signed 8 3(3) << -22(ffffffea) = 3072(c00)\n  signed 8 3(3) << -21(ffffffeb) = 6144(1800)\n  signed 8 3(3) << -20(ffffffec) = 12288(3000)\n  signed 8 3(3) << -19(ffffffed) = 24576(6000)\n  signed 8 3(3) << -18(ffffffee) = 49152(c000)\n  signed 8 3(3) << -17(ffffffef) = 98304(8000)\n  signed 8 3(3) << -16(fffffff0) = 196608(0)\n  signed 8 3(3) << -15(fffffff1) = 393216(0)\n  signed 8 3(3) << -14(fffffff2) = 786432(0)\n  signed 8 3(3) << -13(fffffff3) = 1572864(0)\n  signed 8 3(3) << -12(fffffff4) = 3145728(0)\n  signed 8 3(3) << -11(fffffff5) = 6291456(0)\n  signed 8 3(3) << -10(fffffff6) = 12582912(0)\n  signed 8 3(3) << -9(fffffff7) = 25165824(0)\n  signed 8 3(3) << -8(fffffff8) = 50331648(0)\n  signed 8 3(3) << -7(fffffff9) = 100663296(0)\n  signed 8 3(3) << -6(fffffffa) = 201326592(0)\n  signed 8 3(3) << -5(fffffffb) = 402653184(0)\n  signed 8 3(3) << -4(fffffffc) = 805306368(0)\n  signed 8 3(3) << -3(fffffffd) = 1610612736(0)\n  signed 8 3(3) << -2(fffffffe) = -1073741824(0)\n  signed 8 3(3) << -1(ffffffff) = -2147483648(0)\n  signed 8 3(3) << 0(0) = 3(3)\n  signed 8 3(3) << 1(1) = 6(6)\n  signed 8 3(3) << 2(2) = 12(c)\n  signed 8 3(3) << 3(3) = 24(18)\n  signed 8 3(3) << 4(4) = 48(30)\n  signed 8 3(3) << 5(5) = 96(60)\n  signed 8 3(3) << 6(6) = 192(c0)\n  signed 8 3(3) << 7(7) = 384(180)\n  signed 8 3(3) << 8(8) = 768(300)\n  signed 8 3(3) << 9(9) = 1536(600)\n  signed 8 3(3) << 10(a) = 3072(c00)\n  signed 8 3(3) << 11(b) = 6144(1800)\n  signed 8 3(3) << 12(c) = 12288(3000)\n  signed 8 3(3) << 13(d) = 24576(6000)\n  signed 8 3(3) << 14(e) = 49152(c000)\n  signed 8 3(3) << 15(f) = 98304(8000)\n  signed 8 3(3) << 16(10) = 196608(0)\n  signed 8 3(3) << 17(11) = 393216(0)\n  signed 8 3(3) << 18(12) = 786432(0)\n  signed 8 3(3) << 19(13) = 1572864(0)\n  signed 8 3(3) << 20(14) = 3145728(0)\n  signed 8 3(3) << 21(15) = 6291456(0)\n  signed 8 3(3) << 22(16) = 12582912(0)\n  signed 8 3(3) << 23(17) = 25165824(0)\n  signed 8 3(3) << 24(18) = 50331648(0)\n  signed 8 3(3) << 25(19) = 100663296(0)\n  signed 8 3(3) << 26(1a) = 201326592(0)\n  signed 8 3(3) << 27(1b) = 402653184(0)\n  signed 8 3(3) << 28(1c) = 805306368(0)\n  signed 8 3(3) << 29(1d) = 1610612736(0)\n  signed 8 3(3) << 30(1e) = -1073741824(0)\n  signed 8 3(3) << 31(1f) = -2147483648(0)\n  signed 8 3(3) << 32(20) = 3(3)\n  signed 8 3(3) << 33(21) = 6(6)\n  signed 8 3(3) << 34(22) = 12(c)\n  signed 8 3(3) << 35(23) = 24(18)\n  signed 8 3(3) << 36(24) = 48(30)\n  signed 8 3(3) << 37(25) = 96(60)\n  signed 8 3(3) << 38(26) = 192(c0)\n  signed 8 3(3) << 39(27) = 384(180)\n  signed 8 3(3) << 40(28) = 768(300)\n  signed 8 3(3) << 41(29) = 1536(600)\n  signed 8 3(3) << 42(2a) = 3072(c00)\n  signed 8 3(3) << 43(2b) = 6144(1800)\n  signed 8 3(3) << 44(2c) = 12288(3000)\n  signed 8 3(3) << 45(2d) = 24576(6000)\n  signed 8 3(3) << 46(2e) = 49152(c000)\n  signed 8 3(3) << 47(2f) = 98304(8000)\n  signed 8 3(3) << 48(30) = 196608(0)\n  signed 8 3(3) << 49(31) = 393216(0)\n  signed 8 3(3) << 50(32) = 786432(0)\n  signed 8 3(3) << 51(33) = 1572864(0)\n  signed 8 3(3) << 52(34) = 3145728(0)\n  signed 8 3(3) << 53(35) = 6291456(0)\n  signed 8 3(3) << 54(36) = 12582912(0)\n  signed 8 3(3) << 55(37) = 25165824(0)\n  signed 8 3(3) << 56(38) = 50331648(0)\n  signed 8 3(3) << 57(39) = 100663296(0)\n  signed 8 3(3) << 58(3a) = 201326592(0)\n  signed 8 3(3) << 59(3b) = 402653184(0)\n  signed 8 3(3) << 60(3c) = 805306368(0)\n  signed 8 3(3) << 61(3d) = 1610612736(0)\n  signed 8 3(3) << 62(3e) = -1073741824(0)\n  signed 8 3(3) << 63(3f) = -2147483648(0)\n  signed 8 3(3) << 64(40) = 3(3)\n  signed 8 3(3) << 65(41) = 6(6)\n  signed 8 3(3) << 66(42) = 12(c)\n  signed 8 3(3) << 67(43) = 24(18)\n  signed 8 3(3) << 68(44) = 48(30)\n  signed 8 3(3) << 69(45) = 96(60)\n  signed 8 3(3) << 70(46) = 192(c0)\n  signed 8 3(3) << 71(47) = 384(180)\n  signed 8 3(3) << 72(48) = 768(300)\n  signed 8 3(3) << 73(49) = 1536(600)\n  signed 8 3(3) << 74(4a) = 3072(c00)\n  signed 8 3(3) << 75(4b) = 6144(1800)\n  signed 8 3(3) << 76(4c) = 12288(3000)\n  signed 8 3(3) << 77(4d) = 24576(6000)\n  signed 8 3(3) << 78(4e) = 49152(c000)\n  signed 8 3(3) << 79(4f) = 98304(8000)\n  signed 8 3(3) << 80(50) = 196608(0)\n  signed 8 3(3) << 81(51) = 393216(0)\n  signed 8 3(3) << 82(52) = 786432(0)\n  signed 8 3(3) << 83(53) = 1572864(0)\n  signed 8 3(3) << 84(54) = 3145728(0)\n  signed 8 3(3) << 85(55) = 6291456(0)\n  signed 8 3(3) << 86(56) = 12582912(0)\n  signed 8 3(3) << 87(57) = 25165824(0)\n  signed 8 3(3) << 88(58) = 50331648(0)\n  signed 8 3(3) << 89(59) = 100663296(0)\n  signed 8 3(3) << 90(5a) = 201326592(0)\n  signed 8 3(3) << 91(5b) = 402653184(0)\n  signed 8 3(3) << 92(5c) = 805306368(0)\n  signed 8 3(3) << 93(5d) = 1610612736(0)\n  signed 8 3(3) << 94(5e) = -1073741824(0)\n  signed 8 3(3) << 95(5f) = -2147483648(0)\n  signed 8 3(3) << 96(60) = 3(3)\n  signed 8 3(3) << 97(61) = 6(6)\n  signed 8 3(3) << 98(62) = 12(c)\n  signed 8 3(3) << 99(63) = 24(18)\n  signed 8 3(3) << 100(64) = 48(30)\n  signed 8 3(3) << 101(65) = 96(60)\n  signed 8 3(3) << 102(66) = 192(c0)\n  signed 8 3(3) << 103(67) = 384(180)\n  signed 8 3(3) << 104(68) = 768(300)\n  signed 8 3(3) << 105(69) = 1536(600)\n  signed 8 3(3) << 106(6a) = 3072(c00)\n  signed 8 3(3) << 107(6b) = 6144(1800)\n  signed 8 3(3) << 108(6c) = 12288(3000)\n  signed 8 3(3) << 109(6d) = 24576(6000)\n  signed 8 3(3) << 110(6e) = 49152(c000)\n  signed 8 3(3) << 111(6f) = 98304(8000)\n  signed 8 3(3) << 112(70) = 196608(0)\n  signed 8 3(3) << 113(71) = 393216(0)\n  signed 8 3(3) << 114(72) = 786432(0)\n  signed 8 3(3) << 115(73) = 1572864(0)\n  signed 8 3(3) << 116(74) = 3145728(0)\n  signed 8 3(3) << 117(75) = 6291456(0)\n  signed 8 3(3) << 118(76) = 12582912(0)\n  signed 8 3(3) << 119(77) = 25165824(0)\n  signed 8 3(3) << 120(78) = 50331648(0)\n  signed 8 3(3) << 121(79) = 100663296(0)\n  signed 8 3(3) << 122(7a) = 201326592(0)\n  signed 8 3(3) << 123(7b) = 402653184(0)\n  signed 8 3(3) << 124(7c) = 805306368(0)\n  signed 8 3(3) << 125(7d) = 1610612736(0)\n  signed 8 3(3) << 126(7e) = -1073741824(0)\n  signed 8 3(3) << 127(7f) = -2147483648(0)\n  signed 8 4(4) << -128(ffffff80) = 4(4)\n  signed 8 4(4) << -127(ffffff81) = 8(8)\n  signed 8 4(4) << -126(ffffff82) = 16(10)\n  signed 8 4(4) << -125(ffffff83) = 32(20)\n  signed 8 4(4) << -124(ffffff84) = 64(40)\n  signed 8 4(4) << -123(ffffff85) = 128(80)\n  signed 8 4(4) << -122(ffffff86) = 256(100)\n  signed 8 4(4) << -121(ffffff87) = 512(200)\n  signed 8 4(4) << -120(ffffff88) = 1024(400)\n  signed 8 4(4) << -119(ffffff89) = 2048(800)\n  signed 8 4(4) << -118(ffffff8a) = 4096(1000)\n  signed 8 4(4) << -117(ffffff8b) = 8192(2000)\n  signed 8 4(4) << -116(ffffff8c) = 16384(4000)\n  signed 8 4(4) << -115(ffffff8d) = 32768(8000)\n  signed 8 4(4) << -114(ffffff8e) = 65536(0)\n  signed 8 4(4) << -113(ffffff8f) = 131072(0)\n  signed 8 4(4) << -112(ffffff90) = 262144(0)\n  signed 8 4(4) << -111(ffffff91) = 524288(0)\n  signed 8 4(4) << -110(ffffff92) = 1048576(0)\n  signed 8 4(4) << -109(ffffff93) = 2097152(0)\n  signed 8 4(4) << -108(ffffff94) = 4194304(0)\n  signed 8 4(4) << -107(ffffff95) = 8388608(0)\n  signed 8 4(4) << -106(ffffff96) = 16777216(0)\n  signed 8 4(4) << -105(ffffff97) = 33554432(0)\n  signed 8 4(4) << -104(ffffff98) = 67108864(0)\n  signed 8 4(4) << -103(ffffff99) = 134217728(0)\n  signed 8 4(4) << -102(ffffff9a) = 268435456(0)\n  signed 8 4(4) << -101(ffffff9b) = 536870912(0)\n  signed 8 4(4) << -100(ffffff9c) = 1073741824(0)\n  signed 8 4(4) << -99(ffffff9d) = -2147483648(0)\n  signed 8 4(4) << -98(ffffff9e) = 0(0)\n  signed 8 4(4) << -97(ffffff9f) = 0(0)\n  signed 8 4(4) << -96(ffffffa0) = 4(4)\n  signed 8 4(4) << -95(ffffffa1) = 8(8)\n  signed 8 4(4) << -94(ffffffa2) = 16(10)\n  signed 8 4(4) << -93(ffffffa3) = 32(20)\n  signed 8 4(4) << -92(ffffffa4) = 64(40)\n  signed 8 4(4) << -91(ffffffa5) = 128(80)\n  signed 8 4(4) << -90(ffffffa6) = 256(100)\n  signed 8 4(4) << -89(ffffffa7) = 512(200)\n  signed 8 4(4) << -88(ffffffa8) = 1024(400)\n  signed 8 4(4) << -87(ffffffa9) = 2048(800)\n  signed 8 4(4) << -86(ffffffaa) = 4096(1000)\n  signed 8 4(4) << -85(ffffffab) = 8192(2000)\n  signed 8 4(4) << -84(ffffffac) = 16384(4000)\n  signed 8 4(4) << -83(ffffffad) = 32768(8000)\n  signed 8 4(4) << -82(ffffffae) = 65536(0)\n  signed 8 4(4) << -81(ffffffaf) = 131072(0)\n  signed 8 4(4) << -80(ffffffb0) = 262144(0)\n  signed 8 4(4) << -79(ffffffb1) = 524288(0)\n  signed 8 4(4) << -78(ffffffb2) = 1048576(0)\n  signed 8 4(4) << -77(ffffffb3) = 2097152(0)\n  signed 8 4(4) << -76(ffffffb4) = 4194304(0)\n  signed 8 4(4) << -75(ffffffb5) = 8388608(0)\n  signed 8 4(4) << -74(ffffffb6) = 16777216(0)\n  signed 8 4(4) << -73(ffffffb7) = 33554432(0)\n  signed 8 4(4) << -72(ffffffb8) = 67108864(0)\n  signed 8 4(4) << -71(ffffffb9) = 134217728(0)\n  signed 8 4(4) << -70(ffffffba) = 268435456(0)\n  signed 8 4(4) << -69(ffffffbb) = 536870912(0)\n  signed 8 4(4) << -68(ffffffbc) = 1073741824(0)\n  signed 8 4(4) << -67(ffffffbd) = -2147483648(0)\n  signed 8 4(4) << -66(ffffffbe) = 0(0)\n  signed 8 4(4) << -65(ffffffbf) = 0(0)\n  signed 8 4(4) << -64(ffffffc0) = 4(4)\n  signed 8 4(4) << -63(ffffffc1) = 8(8)\n  signed 8 4(4) << -62(ffffffc2) = 16(10)\n  signed 8 4(4) << -61(ffffffc3) = 32(20)\n  signed 8 4(4) << -60(ffffffc4) = 64(40)\n  signed 8 4(4) << -59(ffffffc5) = 128(80)\n  signed 8 4(4) << -58(ffffffc6) = 256(100)\n  signed 8 4(4) << -57(ffffffc7) = 512(200)\n  signed 8 4(4) << -56(ffffffc8) = 1024(400)\n  signed 8 4(4) << -55(ffffffc9) = 2048(800)\n  signed 8 4(4) << -54(ffffffca) = 4096(1000)\n  signed 8 4(4) << -53(ffffffcb) = 8192(2000)\n  signed 8 4(4) << -52(ffffffcc) = 16384(4000)\n  signed 8 4(4) << -51(ffffffcd) = 32768(8000)\n  signed 8 4(4) << -50(ffffffce) = 65536(0)\n  signed 8 4(4) << -49(ffffffcf) = 131072(0)\n  signed 8 4(4) << -48(ffffffd0) = 262144(0)\n  signed 8 4(4) << -47(ffffffd1) = 524288(0)\n  signed 8 4(4) << -46(ffffffd2) = 1048576(0)\n  signed 8 4(4) << -45(ffffffd3) = 2097152(0)\n  signed 8 4(4) << -44(ffffffd4) = 4194304(0)\n  signed 8 4(4) << -43(ffffffd5) = 8388608(0)\n  signed 8 4(4) << -42(ffffffd6) = 16777216(0)\n  signed 8 4(4) << -41(ffffffd7) = 33554432(0)\n  signed 8 4(4) << -40(ffffffd8) = 67108864(0)\n  signed 8 4(4) << -39(ffffffd9) = 134217728(0)\n  signed 8 4(4) << -38(ffffffda) = 268435456(0)\n  signed 8 4(4) << -37(ffffffdb) = 536870912(0)\n  signed 8 4(4) << -36(ffffffdc) = 1073741824(0)\n  signed 8 4(4) << -35(ffffffdd) = -2147483648(0)\n  signed 8 4(4) << -34(ffffffde) = 0(0)\n  signed 8 4(4) << -33(ffffffdf) = 0(0)\n  signed 8 4(4) << -32(ffffffe0) = 4(4)\n  signed 8 4(4) << -31(ffffffe1) = 8(8)\n  signed 8 4(4) << -30(ffffffe2) = 16(10)\n  signed 8 4(4) << -29(ffffffe3) = 32(20)\n  signed 8 4(4) << -28(ffffffe4) = 64(40)\n  signed 8 4(4) << -27(ffffffe5) = 128(80)\n  signed 8 4(4) << -26(ffffffe6) = 256(100)\n  signed 8 4(4) << -25(ffffffe7) = 512(200)\n  signed 8 4(4) << -24(ffffffe8) = 1024(400)\n  signed 8 4(4) << -23(ffffffe9) = 2048(800)\n  signed 8 4(4) << -22(ffffffea) = 4096(1000)\n  signed 8 4(4) << -21(ffffffeb) = 8192(2000)\n  signed 8 4(4) << -20(ffffffec) = 16384(4000)\n  signed 8 4(4) << -19(ffffffed) = 32768(8000)\n  signed 8 4(4) << -18(ffffffee) = 65536(0)\n  signed 8 4(4) << -17(ffffffef) = 131072(0)\n  signed 8 4(4) << -16(fffffff0) = 262144(0)\n  signed 8 4(4) << -15(fffffff1) = 524288(0)\n  signed 8 4(4) << -14(fffffff2) = 1048576(0)\n  signed 8 4(4) << -13(fffffff3) = 2097152(0)\n  signed 8 4(4) << -12(fffffff4) = 4194304(0)\n  signed 8 4(4) << -11(fffffff5) = 8388608(0)\n  signed 8 4(4) << -10(fffffff6) = 16777216(0)\n  signed 8 4(4) << -9(fffffff7) = 33554432(0)\n  signed 8 4(4) << -8(fffffff8) = 67108864(0)\n  signed 8 4(4) << -7(fffffff9) = 134217728(0)\n  signed 8 4(4) << -6(fffffffa) = 268435456(0)\n  signed 8 4(4) << -5(fffffffb) = 536870912(0)\n  signed 8 4(4) << -4(fffffffc) = 1073741824(0)\n  signed 8 4(4) << -3(fffffffd) = -2147483648(0)\n  signed 8 4(4) << -2(fffffffe) = 0(0)\n  signed 8 4(4) << -1(ffffffff) = 0(0)\n  signed 8 4(4) << 0(0) = 4(4)\n  signed 8 4(4) << 1(1) = 8(8)\n  signed 8 4(4) << 2(2) = 16(10)\n  signed 8 4(4) << 3(3) = 32(20)\n  signed 8 4(4) << 4(4) = 64(40)\n  signed 8 4(4) << 5(5) = 128(80)\n  signed 8 4(4) << 6(6) = 256(100)\n  signed 8 4(4) << 7(7) = 512(200)\n  signed 8 4(4) << 8(8) = 1024(400)\n  signed 8 4(4) << 9(9) = 2048(800)\n  signed 8 4(4) << 10(a) = 4096(1000)\n  signed 8 4(4) << 11(b) = 8192(2000)\n  signed 8 4(4) << 12(c) = 16384(4000)\n  signed 8 4(4) << 13(d) = 32768(8000)\n  signed 8 4(4) << 14(e) = 65536(0)\n  signed 8 4(4) << 15(f) = 131072(0)\n  signed 8 4(4) << 16(10) = 262144(0)\n  signed 8 4(4) << 17(11) = 524288(0)\n  signed 8 4(4) << 18(12) = 1048576(0)\n  signed 8 4(4) << 19(13) = 2097152(0)\n  signed 8 4(4) << 20(14) = 4194304(0)\n  signed 8 4(4) << 21(15) = 8388608(0)\n  signed 8 4(4) << 22(16) = 16777216(0)\n  signed 8 4(4) << 23(17) = 33554432(0)\n  signed 8 4(4) << 24(18) = 67108864(0)\n  signed 8 4(4) << 25(19) = 134217728(0)\n  signed 8 4(4) << 26(1a) = 268435456(0)\n  signed 8 4(4) << 27(1b) = 536870912(0)\n  signed 8 4(4) << 28(1c) = 1073741824(0)\n  signed 8 4(4) << 29(1d) = -2147483648(0)\n  signed 8 4(4) << 30(1e) = 0(0)\n  signed 8 4(4) << 31(1f) = 0(0)\n  signed 8 4(4) << 32(20) = 4(4)\n  signed 8 4(4) << 33(21) = 8(8)\n  signed 8 4(4) << 34(22) = 16(10)\n  signed 8 4(4) << 35(23) = 32(20)\n  signed 8 4(4) << 36(24) = 64(40)\n  signed 8 4(4) << 37(25) = 128(80)\n  signed 8 4(4) << 38(26) = 256(100)\n  signed 8 4(4) << 39(27) = 512(200)\n  signed 8 4(4) << 40(28) = 1024(400)\n  signed 8 4(4) << 41(29) = 2048(800)\n  signed 8 4(4) << 42(2a) = 4096(1000)\n  signed 8 4(4) << 43(2b) = 8192(2000)\n  signed 8 4(4) << 44(2c) = 16384(4000)\n  signed 8 4(4) << 45(2d) = 32768(8000)\n  signed 8 4(4) << 46(2e) = 65536(0)\n  signed 8 4(4) << 47(2f) = 131072(0)\n  signed 8 4(4) << 48(30) = 262144(0)\n  signed 8 4(4) << 49(31) = 524288(0)\n  signed 8 4(4) << 50(32) = 1048576(0)\n  signed 8 4(4) << 51(33) = 2097152(0)\n  signed 8 4(4) << 52(34) = 4194304(0)\n  signed 8 4(4) << 53(35) = 8388608(0)\n  signed 8 4(4) << 54(36) = 16777216(0)\n  signed 8 4(4) << 55(37) = 33554432(0)\n  signed 8 4(4) << 56(38) = 67108864(0)\n  signed 8 4(4) << 57(39) = 134217728(0)\n  signed 8 4(4) << 58(3a) = 268435456(0)\n  signed 8 4(4) << 59(3b) = 536870912(0)\n  signed 8 4(4) << 60(3c) = 1073741824(0)\n  signed 8 4(4) << 61(3d) = -2147483648(0)\n  signed 8 4(4) << 62(3e) = 0(0)\n  signed 8 4(4) << 63(3f) = 0(0)\n  signed 8 4(4) << 64(40) = 4(4)\n  signed 8 4(4) << 65(41) = 8(8)\n  signed 8 4(4) << 66(42) = 16(10)\n  signed 8 4(4) << 67(43) = 32(20)\n  signed 8 4(4) << 68(44) = 64(40)\n  signed 8 4(4) << 69(45) = 128(80)\n  signed 8 4(4) << 70(46) = 256(100)\n  signed 8 4(4) << 71(47) = 512(200)\n  signed 8 4(4) << 72(48) = 1024(400)\n  signed 8 4(4) << 73(49) = 2048(800)\n  signed 8 4(4) << 74(4a) = 4096(1000)\n  signed 8 4(4) << 75(4b) = 8192(2000)\n  signed 8 4(4) << 76(4c) = 16384(4000)\n  signed 8 4(4) << 77(4d) = 32768(8000)\n  signed 8 4(4) << 78(4e) = 65536(0)\n  signed 8 4(4) << 79(4f) = 131072(0)\n  signed 8 4(4) << 80(50) = 262144(0)\n  signed 8 4(4) << 81(51) = 524288(0)\n  signed 8 4(4) << 82(52) = 1048576(0)\n  signed 8 4(4) << 83(53) = 2097152(0)\n  signed 8 4(4) << 84(54) = 4194304(0)\n  signed 8 4(4) << 85(55) = 8388608(0)\n  signed 8 4(4) << 86(56) = 16777216(0)\n  signed 8 4(4) << 87(57) = 33554432(0)\n  signed 8 4(4) << 88(58) = 67108864(0)\n  signed 8 4(4) << 89(59) = 134217728(0)\n  signed 8 4(4) << 90(5a) = 268435456(0)\n  signed 8 4(4) << 91(5b) = 536870912(0)\n  signed 8 4(4) << 92(5c) = 1073741824(0)\n  signed 8 4(4) << 93(5d) = -2147483648(0)\n  signed 8 4(4) << 94(5e) = 0(0)\n  signed 8 4(4) << 95(5f) = 0(0)\n  signed 8 4(4) << 96(60) = 4(4)\n  signed 8 4(4) << 97(61) = 8(8)\n  signed 8 4(4) << 98(62) = 16(10)\n  signed 8 4(4) << 99(63) = 32(20)\n  signed 8 4(4) << 100(64) = 64(40)\n  signed 8 4(4) << 101(65) = 128(80)\n  signed 8 4(4) << 102(66) = 256(100)\n  signed 8 4(4) << 103(67) = 512(200)\n  signed 8 4(4) << 104(68) = 1024(400)\n  signed 8 4(4) << 105(69) = 2048(800)\n  signed 8 4(4) << 106(6a) = 4096(1000)\n  signed 8 4(4) << 107(6b) = 8192(2000)\n  signed 8 4(4) << 108(6c) = 16384(4000)\n  signed 8 4(4) << 109(6d) = 32768(8000)\n  signed 8 4(4) << 110(6e) = 65536(0)\n  signed 8 4(4) << 111(6f) = 131072(0)\n  signed 8 4(4) << 112(70) = 262144(0)\n  signed 8 4(4) << 113(71) = 524288(0)\n  signed 8 4(4) << 114(72) = 1048576(0)\n  signed 8 4(4) << 115(73) = 2097152(0)\n  signed 8 4(4) << 116(74) = 4194304(0)\n  signed 8 4(4) << 117(75) = 8388608(0)\n  signed 8 4(4) << 118(76) = 16777216(0)\n  signed 8 4(4) << 119(77) = 33554432(0)\n  signed 8 4(4) << 120(78) = 67108864(0)\n  signed 8 4(4) << 121(79) = 134217728(0)\n  signed 8 4(4) << 122(7a) = 268435456(0)\n  signed 8 4(4) << 123(7b) = 536870912(0)\n  signed 8 4(4) << 124(7c) = 1073741824(0)\n  signed 8 4(4) << 125(7d) = -2147483648(0)\n  signed 8 4(4) << 126(7e) = 0(0)\n  signed 8 4(4) << 127(7f) = 0(0)\nunsigned 8 0(0) << -128(ffffff80) = 0(0)\nunsigned 8 0(0) << -127(ffffff81) = 0(0)\nunsigned 8 0(0) << -126(ffffff82) = 0(0)\nunsigned 8 0(0) << -125(ffffff83) = 0(0)\nunsigned 8 0(0) << -124(ffffff84) = 0(0)\nunsigned 8 0(0) << -123(ffffff85) = 0(0)\nunsigned 8 0(0) << -122(ffffff86) = 0(0)\nunsigned 8 0(0) << -121(ffffff87) = 0(0)\nunsigned 8 0(0) << -120(ffffff88) = 0(0)\nunsigned 8 0(0) << -119(ffffff89) = 0(0)\nunsigned 8 0(0) << -118(ffffff8a) = 0(0)\nunsigned 8 0(0) << -117(ffffff8b) = 0(0)\nunsigned 8 0(0) << -116(ffffff8c) = 0(0)\nunsigned 8 0(0) << -115(ffffff8d) = 0(0)\nunsigned 8 0(0) << -114(ffffff8e) = 0(0)\nunsigned 8 0(0) << -113(ffffff8f) = 0(0)\nunsigned 8 0(0) << -112(ffffff90) = 0(0)\nunsigned 8 0(0) << -111(ffffff91) = 0(0)\nunsigned 8 0(0) << -110(ffffff92) = 0(0)\nunsigned 8 0(0) << -109(ffffff93) = 0(0)\nunsigned 8 0(0) << -108(ffffff94) = 0(0)\nunsigned 8 0(0) << -107(ffffff95) = 0(0)\nunsigned 8 0(0) << -106(ffffff96) = 0(0)\nunsigned 8 0(0) << -105(ffffff97) = 0(0)\nunsigned 8 0(0) << -104(ffffff98) = 0(0)\nunsigned 8 0(0) << -103(ffffff99) = 0(0)\nunsigned 8 0(0) << -102(ffffff9a) = 0(0)\nunsigned 8 0(0) << -101(ffffff9b) = 0(0)\nunsigned 8 0(0) << -100(ffffff9c) = 0(0)\nunsigned 8 0(0) << -99(ffffff9d) = 0(0)\nunsigned 8 0(0) << -98(ffffff9e) = 0(0)\nunsigned 8 0(0) << -97(ffffff9f) = 0(0)\nunsigned 8 0(0) << -96(ffffffa0) = 0(0)\nunsigned 8 0(0) << -95(ffffffa1) = 0(0)\nunsigned 8 0(0) << -94(ffffffa2) = 0(0)\nunsigned 8 0(0) << -93(ffffffa3) = 0(0)\nunsigned 8 0(0) << -92(ffffffa4) = 0(0)\nunsigned 8 0(0) << -91(ffffffa5) = 0(0)\nunsigned 8 0(0) << -90(ffffffa6) = 0(0)\nunsigned 8 0(0) << -89(ffffffa7) = 0(0)\nunsigned 8 0(0) << -88(ffffffa8) = 0(0)\nunsigned 8 0(0) << -87(ffffffa9) = 0(0)\nunsigned 8 0(0) << -86(ffffffaa) = 0(0)\nunsigned 8 0(0) << -85(ffffffab) = 0(0)\nunsigned 8 0(0) << -84(ffffffac) = 0(0)\nunsigned 8 0(0) << -83(ffffffad) = 0(0)\nunsigned 8 0(0) << -82(ffffffae) = 0(0)\nunsigned 8 0(0) << -81(ffffffaf) = 0(0)\nunsigned 8 0(0) << -80(ffffffb0) = 0(0)\nunsigned 8 0(0) << -79(ffffffb1) = 0(0)\nunsigned 8 0(0) << -78(ffffffb2) = 0(0)\nunsigned 8 0(0) << -77(ffffffb3) = 0(0)\nunsigned 8 0(0) << -76(ffffffb4) = 0(0)\nunsigned 8 0(0) << -75(ffffffb5) = 0(0)\nunsigned 8 0(0) << -74(ffffffb6) = 0(0)\nunsigned 8 0(0) << -73(ffffffb7) = 0(0)\nunsigned 8 0(0) << -72(ffffffb8) = 0(0)\nunsigned 8 0(0) << -71(ffffffb9) = 0(0)\nunsigned 8 0(0) << -70(ffffffba) = 0(0)\nunsigned 8 0(0) << -69(ffffffbb) = 0(0)\nunsigned 8 0(0) << -68(ffffffbc) = 0(0)\nunsigned 8 0(0) << -67(ffffffbd) = 0(0)\nunsigned 8 0(0) << -66(ffffffbe) = 0(0)\nunsigned 8 0(0) << -65(ffffffbf) = 0(0)\nunsigned 8 0(0) << -64(ffffffc0) = 0(0)\nunsigned 8 0(0) << -63(ffffffc1) = 0(0)\nunsigned 8 0(0) << -62(ffffffc2) = 0(0)\nunsigned 8 0(0) << -61(ffffffc3) = 0(0)\nunsigned 8 0(0) << -60(ffffffc4) = 0(0)\nunsigned 8 0(0) << -59(ffffffc5) = 0(0)\nunsigned 8 0(0) << -58(ffffffc6) = 0(0)\nunsigned 8 0(0) << -57(ffffffc7) = 0(0)\nunsigned 8 0(0) << -56(ffffffc8) = 0(0)\nunsigned 8 0(0) << -55(ffffffc9) = 0(0)\nunsigned 8 0(0) << -54(ffffffca) = 0(0)\nunsigned 8 0(0) << -53(ffffffcb) = 0(0)\nunsigned 8 0(0) << -52(ffffffcc) = 0(0)\nunsigned 8 0(0) << -51(ffffffcd) = 0(0)\nunsigned 8 0(0) << -50(ffffffce) = 0(0)\nunsigned 8 0(0) << -49(ffffffcf) = 0(0)\nunsigned 8 0(0) << -48(ffffffd0) = 0(0)\nunsigned 8 0(0) << -47(ffffffd1) = 0(0)\nunsigned 8 0(0) << -46(ffffffd2) = 0(0)\nunsigned 8 0(0) << -45(ffffffd3) = 0(0)\nunsigned 8 0(0) << -44(ffffffd4) = 0(0)\nunsigned 8 0(0) << -43(ffffffd5) = 0(0)\nunsigned 8 0(0) << -42(ffffffd6) = 0(0)\nunsigned 8 0(0) << -41(ffffffd7) = 0(0)\nunsigned 8 0(0) << -40(ffffffd8) = 0(0)\nunsigned 8 0(0) << -39(ffffffd9) = 0(0)\nunsigned 8 0(0) << -38(ffffffda) = 0(0)\nunsigned 8 0(0) << -37(ffffffdb) = 0(0)\nunsigned 8 0(0) << -36(ffffffdc) = 0(0)\nunsigned 8 0(0) << -35(ffffffdd) = 0(0)\nunsigned 8 0(0) << -34(ffffffde) = 0(0)\nunsigned 8 0(0) << -33(ffffffdf) = 0(0)\nunsigned 8 0(0) << -32(ffffffe0) = 0(0)\nunsigned 8 0(0) << -31(ffffffe1) = 0(0)\nunsigned 8 0(0) << -30(ffffffe2) = 0(0)\nunsigned 8 0(0) << -29(ffffffe3) = 0(0)\nunsigned 8 0(0) << -28(ffffffe4) = 0(0)\nunsigned 8 0(0) << -27(ffffffe5) = 0(0)\nunsigned 8 0(0) << -26(ffffffe6) = 0(0)\nunsigned 8 0(0) << -25(ffffffe7) = 0(0)\nunsigned 8 0(0) << -24(ffffffe8) = 0(0)\nunsigned 8 0(0) << -23(ffffffe9) = 0(0)\nunsigned 8 0(0) << -22(ffffffea) = 0(0)\nunsigned 8 0(0) << -21(ffffffeb) = 0(0)\nunsigned 8 0(0) << -20(ffffffec) = 0(0)\nunsigned 8 0(0) << -19(ffffffed) = 0(0)\nunsigned 8 0(0) << -18(ffffffee) = 0(0)\nunsigned 8 0(0) << -17(ffffffef) = 0(0)\nunsigned 8 0(0) << -16(fffffff0) = 0(0)\nunsigned 8 0(0) << -15(fffffff1) = 0(0)\nunsigned 8 0(0) << -14(fffffff2) = 0(0)\nunsigned 8 0(0) << -13(fffffff3) = 0(0)\nunsigned 8 0(0) << -12(fffffff4) = 0(0)\nunsigned 8 0(0) << -11(fffffff5) = 0(0)\nunsigned 8 0(0) << -10(fffffff6) = 0(0)\nunsigned 8 0(0) << -9(fffffff7) = 0(0)\nunsigned 8 0(0) << -8(fffffff8) = 0(0)\nunsigned 8 0(0) << -7(fffffff9) = 0(0)\nunsigned 8 0(0) << -6(fffffffa) = 0(0)\nunsigned 8 0(0) << -5(fffffffb) = 0(0)\nunsigned 8 0(0) << -4(fffffffc) = 0(0)\nunsigned 8 0(0) << -3(fffffffd) = 0(0)\nunsigned 8 0(0) << -2(fffffffe) = 0(0)\nunsigned 8 0(0) << -1(ffffffff) = 0(0)\nunsigned 8 0(0) << 0(0) = 0(0)\nunsigned 8 0(0) << 1(1) = 0(0)\nunsigned 8 0(0) << 2(2) = 0(0)\nunsigned 8 0(0) << 3(3) = 0(0)\nunsigned 8 0(0) << 4(4) = 0(0)\nunsigned 8 0(0) << 5(5) = 0(0)\nunsigned 8 0(0) << 6(6) = 0(0)\nunsigned 8 0(0) << 7(7) = 0(0)\nunsigned 8 0(0) << 8(8) = 0(0)\nunsigned 8 0(0) << 9(9) = 0(0)\nunsigned 8 0(0) << 10(a) = 0(0)\nunsigned 8 0(0) << 11(b) = 0(0)\nunsigned 8 0(0) << 12(c) = 0(0)\nunsigned 8 0(0) << 13(d) = 0(0)\nunsigned 8 0(0) << 14(e) = 0(0)\nunsigned 8 0(0) << 15(f) = 0(0)\nunsigned 8 0(0) << 16(10) = 0(0)\nunsigned 8 0(0) << 17(11) = 0(0)\nunsigned 8 0(0) << 18(12) = 0(0)\nunsigned 8 0(0) << 19(13) = 0(0)\nunsigned 8 0(0) << 20(14) = 0(0)\nunsigned 8 0(0) << 21(15) = 0(0)\nunsigned 8 0(0) << 22(16) = 0(0)\nunsigned 8 0(0) << 23(17) = 0(0)\nunsigned 8 0(0) << 24(18) = 0(0)\nunsigned 8 0(0) << 25(19) = 0(0)\nunsigned 8 0(0) << 26(1a) = 0(0)\nunsigned 8 0(0) << 27(1b) = 0(0)\nunsigned 8 0(0) << 28(1c) = 0(0)\nunsigned 8 0(0) << 29(1d) = 0(0)\nunsigned 8 0(0) << 30(1e) = 0(0)\nunsigned 8 0(0) << 31(1f) = 0(0)\nunsigned 8 0(0) << 32(20) = 0(0)\nunsigned 8 0(0) << 33(21) = 0(0)\nunsigned 8 0(0) << 34(22) = 0(0)\nunsigned 8 0(0) << 35(23) = 0(0)\nunsigned 8 0(0) << 36(24) = 0(0)\nunsigned 8 0(0) << 37(25) = 0(0)\nunsigned 8 0(0) << 38(26) = 0(0)\nunsigned 8 0(0) << 39(27) = 0(0)\nunsigned 8 0(0) << 40(28) = 0(0)\nunsigned 8 0(0) << 41(29) = 0(0)\nunsigned 8 0(0) << 42(2a) = 0(0)\nunsigned 8 0(0) << 43(2b) = 0(0)\nunsigned 8 0(0) << 44(2c) = 0(0)\nunsigned 8 0(0) << 45(2d) = 0(0)\nunsigned 8 0(0) << 46(2e) = 0(0)\nunsigned 8 0(0) << 47(2f) = 0(0)\nunsigned 8 0(0) << 48(30) = 0(0)\nunsigned 8 0(0) << 49(31) = 0(0)\nunsigned 8 0(0) << 50(32) = 0(0)\nunsigned 8 0(0) << 51(33) = 0(0)\nunsigned 8 0(0) << 52(34) = 0(0)\nunsigned 8 0(0) << 53(35) = 0(0)\nunsigned 8 0(0) << 54(36) = 0(0)\nunsigned 8 0(0) << 55(37) = 0(0)\nunsigned 8 0(0) << 56(38) = 0(0)\nunsigned 8 0(0) << 57(39) = 0(0)\nunsigned 8 0(0) << 58(3a) = 0(0)\nunsigned 8 0(0) << 59(3b) = 0(0)\nunsigned 8 0(0) << 60(3c) = 0(0)\nunsigned 8 0(0) << 61(3d) = 0(0)\nunsigned 8 0(0) << 62(3e) = 0(0)\nunsigned 8 0(0) << 63(3f) = 0(0)\nunsigned 8 0(0) << 64(40) = 0(0)\nunsigned 8 0(0) << 65(41) = 0(0)\nunsigned 8 0(0) << 66(42) = 0(0)\nunsigned 8 0(0) << 67(43) = 0(0)\nunsigned 8 0(0) << 68(44) = 0(0)\nunsigned 8 0(0) << 69(45) = 0(0)\nunsigned 8 0(0) << 70(46) = 0(0)\nunsigned 8 0(0) << 71(47) = 0(0)\nunsigned 8 0(0) << 72(48) = 0(0)\nunsigned 8 0(0) << 73(49) = 0(0)\nunsigned 8 0(0) << 74(4a) = 0(0)\nunsigned 8 0(0) << 75(4b) = 0(0)\nunsigned 8 0(0) << 76(4c) = 0(0)\nunsigned 8 0(0) << 77(4d) = 0(0)\nunsigned 8 0(0) << 78(4e) = 0(0)\nunsigned 8 0(0) << 79(4f) = 0(0)\nunsigned 8 0(0) << 80(50) = 0(0)\nunsigned 8 0(0) << 81(51) = 0(0)\nunsigned 8 0(0) << 82(52) = 0(0)\nunsigned 8 0(0) << 83(53) = 0(0)\nunsigned 8 0(0) << 84(54) = 0(0)\nunsigned 8 0(0) << 85(55) = 0(0)\nunsigned 8 0(0) << 86(56) = 0(0)\nunsigned 8 0(0) << 87(57) = 0(0)\nunsigned 8 0(0) << 88(58) = 0(0)\nunsigned 8 0(0) << 89(59) = 0(0)\nunsigned 8 0(0) << 90(5a) = 0(0)\nunsigned 8 0(0) << 91(5b) = 0(0)\nunsigned 8 0(0) << 92(5c) = 0(0)\nunsigned 8 0(0) << 93(5d) = 0(0)\nunsigned 8 0(0) << 94(5e) = 0(0)\nunsigned 8 0(0) << 95(5f) = 0(0)\nunsigned 8 0(0) << 96(60) = 0(0)\nunsigned 8 0(0) << 97(61) = 0(0)\nunsigned 8 0(0) << 98(62) = 0(0)\nunsigned 8 0(0) << 99(63) = 0(0)\nunsigned 8 0(0) << 100(64) = 0(0)\nunsigned 8 0(0) << 101(65) = 0(0)\nunsigned 8 0(0) << 102(66) = 0(0)\nunsigned 8 0(0) << 103(67) = 0(0)\nunsigned 8 0(0) << 104(68) = 0(0)\nunsigned 8 0(0) << 105(69) = 0(0)\nunsigned 8 0(0) << 106(6a) = 0(0)\nunsigned 8 0(0) << 107(6b) = 0(0)\nunsigned 8 0(0) << 108(6c) = 0(0)\nunsigned 8 0(0) << 109(6d) = 0(0)\nunsigned 8 0(0) << 110(6e) = 0(0)\nunsigned 8 0(0) << 111(6f) = 0(0)\nunsigned 8 0(0) << 112(70) = 0(0)\nunsigned 8 0(0) << 113(71) = 0(0)\nunsigned 8 0(0) << 114(72) = 0(0)\nunsigned 8 0(0) << 115(73) = 0(0)\nunsigned 8 0(0) << 116(74) = 0(0)\nunsigned 8 0(0) << 117(75) = 0(0)\nunsigned 8 0(0) << 118(76) = 0(0)\nunsigned 8 0(0) << 119(77) = 0(0)\nunsigned 8 0(0) << 120(78) = 0(0)\nunsigned 8 0(0) << 121(79) = 0(0)\nunsigned 8 0(0) << 122(7a) = 0(0)\nunsigned 8 0(0) << 123(7b) = 0(0)\nunsigned 8 0(0) << 124(7c) = 0(0)\nunsigned 8 0(0) << 125(7d) = 0(0)\nunsigned 8 0(0) << 126(7e) = 0(0)\nunsigned 8 0(0) << 127(7f) = 0(0)\nunsigned 8 1(1) << -128(ffffff80) = 1(1)\nunsigned 8 1(1) << -127(ffffff81) = 2(2)\nunsigned 8 1(1) << -126(ffffff82) = 4(4)\nunsigned 8 1(1) << -125(ffffff83) = 8(8)\nunsigned 8 1(1) << -124(ffffff84) = 16(10)\nunsigned 8 1(1) << -123(ffffff85) = 32(20)\nunsigned 8 1(1) << -122(ffffff86) = 64(40)\nunsigned 8 1(1) << -121(ffffff87) = 128(80)\nunsigned 8 1(1) << -120(ffffff88) = 256(100)\nunsigned 8 1(1) << -119(ffffff89) = 512(200)\nunsigned 8 1(1) << -118(ffffff8a) = 1024(400)\nunsigned 8 1(1) << -117(ffffff8b) = 2048(800)\nunsigned 8 1(1) << -116(ffffff8c) = 4096(1000)\nunsigned 8 1(1) << -115(ffffff8d) = 8192(2000)\nunsigned 8 1(1) << -114(ffffff8e) = 16384(4000)\nunsigned 8 1(1) << -113(ffffff8f) = 32768(8000)\nunsigned 8 1(1) << -112(ffffff90) = 65536(10000)\nunsigned 8 1(1) << -111(ffffff91) = 131072(20000)\nunsigned 8 1(1) << -110(ffffff92) = 262144(40000)\nunsigned 8 1(1) << -109(ffffff93) = 524288(80000)\nunsigned 8 1(1) << -108(ffffff94) = 1048576(100000)\nunsigned 8 1(1) << -107(ffffff95) = 2097152(200000)\nunsigned 8 1(1) << -106(ffffff96) = 4194304(400000)\nunsigned 8 1(1) << -105(ffffff97) = 8388608(800000)\nunsigned 8 1(1) << -104(ffffff98) = 16777216(1000000)\nunsigned 8 1(1) << -103(ffffff99) = 33554432(2000000)\nunsigned 8 1(1) << -102(ffffff9a) = 67108864(4000000)\nunsigned 8 1(1) << -101(ffffff9b) = 134217728(8000000)\nunsigned 8 1(1) << -100(ffffff9c) = 268435456(10000000)\nunsigned 8 1(1) << -99(ffffff9d) = 536870912(20000000)\nunsigned 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\nunsigned 8 1(1) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 1(1) << -96(ffffffa0) = 1(1)\nunsigned 8 1(1) << -95(ffffffa1) = 2(2)\nunsigned 8 1(1) << -94(ffffffa2) = 4(4)\nunsigned 8 1(1) << -93(ffffffa3) = 8(8)\nunsigned 8 1(1) << -92(ffffffa4) = 16(10)\nunsigned 8 1(1) << -91(ffffffa5) = 32(20)\nunsigned 8 1(1) << -90(ffffffa6) = 64(40)\nunsigned 8 1(1) << -89(ffffffa7) = 128(80)\nunsigned 8 1(1) << -88(ffffffa8) = 256(100)\nunsigned 8 1(1) << -87(ffffffa9) = 512(200)\nunsigned 8 1(1) << -86(ffffffaa) = 1024(400)\nunsigned 8 1(1) << -85(ffffffab) = 2048(800)\nunsigned 8 1(1) << -84(ffffffac) = 4096(1000)\nunsigned 8 1(1) << -83(ffffffad) = 8192(2000)\nunsigned 8 1(1) << -82(ffffffae) = 16384(4000)\nunsigned 8 1(1) << -81(ffffffaf) = 32768(8000)\nunsigned 8 1(1) << -80(ffffffb0) = 65536(10000)\nunsigned 8 1(1) << -79(ffffffb1) = 131072(20000)\nunsigned 8 1(1) << -78(ffffffb2) = 262144(40000)\nunsigned 8 1(1) << -77(ffffffb3) = 524288(80000)\nunsigned 8 1(1) << -76(ffffffb4) = 1048576(100000)\nunsigned 8 1(1) << -75(ffffffb5) = 2097152(200000)\nunsigned 8 1(1) << -74(ffffffb6) = 4194304(400000)\nunsigned 8 1(1) << -73(ffffffb7) = 8388608(800000)\nunsigned 8 1(1) << -72(ffffffb8) = 16777216(1000000)\nunsigned 8 1(1) << -71(ffffffb9) = 33554432(2000000)\nunsigned 8 1(1) << -70(ffffffba) = 67108864(4000000)\nunsigned 8 1(1) << -69(ffffffbb) = 134217728(8000000)\nunsigned 8 1(1) << -68(ffffffbc) = 268435456(10000000)\nunsigned 8 1(1) << -67(ffffffbd) = 536870912(20000000)\nunsigned 8 1(1) << -66(ffffffbe) = 1073741824(40000000)\nunsigned 8 1(1) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 1(1) << -64(ffffffc0) = 1(1)\nunsigned 8 1(1) << -63(ffffffc1) = 2(2)\nunsigned 8 1(1) << -62(ffffffc2) = 4(4)\nunsigned 8 1(1) << -61(ffffffc3) = 8(8)\nunsigned 8 1(1) << -60(ffffffc4) = 16(10)\nunsigned 8 1(1) << -59(ffffffc5) = 32(20)\nunsigned 8 1(1) << -58(ffffffc6) = 64(40)\nunsigned 8 1(1) << -57(ffffffc7) = 128(80)\nunsigned 8 1(1) << -56(ffffffc8) = 256(100)\nunsigned 8 1(1) << -55(ffffffc9) = 512(200)\nunsigned 8 1(1) << -54(ffffffca) = 1024(400)\nunsigned 8 1(1) << -53(ffffffcb) = 2048(800)\nunsigned 8 1(1) << -52(ffffffcc) = 4096(1000)\nunsigned 8 1(1) << -51(ffffffcd) = 8192(2000)\nunsigned 8 1(1) << -50(ffffffce) = 16384(4000)\nunsigned 8 1(1) << -49(ffffffcf) = 32768(8000)\nunsigned 8 1(1) << -48(ffffffd0) = 65536(10000)\nunsigned 8 1(1) << -47(ffffffd1) = 131072(20000)\nunsigned 8 1(1) << -46(ffffffd2) = 262144(40000)\nunsigned 8 1(1) << -45(ffffffd3) = 524288(80000)\nunsigned 8 1(1) << -44(ffffffd4) = 1048576(100000)\nunsigned 8 1(1) << -43(ffffffd5) = 2097152(200000)\nunsigned 8 1(1) << -42(ffffffd6) = 4194304(400000)\nunsigned 8 1(1) << -41(ffffffd7) = 8388608(800000)\nunsigned 8 1(1) << -40(ffffffd8) = 16777216(1000000)\nunsigned 8 1(1) << -39(ffffffd9) = 33554432(2000000)\nunsigned 8 1(1) << -38(ffffffda) = 67108864(4000000)\nunsigned 8 1(1) << -37(ffffffdb) = 134217728(8000000)\nunsigned 8 1(1) << -36(ffffffdc) = 268435456(10000000)\nunsigned 8 1(1) << -35(ffffffdd) = 536870912(20000000)\nunsigned 8 1(1) << -34(ffffffde) = 1073741824(40000000)\nunsigned 8 1(1) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 1(1) << -32(ffffffe0) = 1(1)\nunsigned 8 1(1) << -31(ffffffe1) = 2(2)\nunsigned 8 1(1) << -30(ffffffe2) = 4(4)\nunsigned 8 1(1) << -29(ffffffe3) = 8(8)\nunsigned 8 1(1) << -28(ffffffe4) = 16(10)\nunsigned 8 1(1) << -27(ffffffe5) = 32(20)\nunsigned 8 1(1) << -26(ffffffe6) = 64(40)\nunsigned 8 1(1) << -25(ffffffe7) = 128(80)\nunsigned 8 1(1) << -24(ffffffe8) = 256(100)\nunsigned 8 1(1) << -23(ffffffe9) = 512(200)\nunsigned 8 1(1) << -22(ffffffea) = 1024(400)\nunsigned 8 1(1) << -21(ffffffeb) = 2048(800)\nunsigned 8 1(1) << -20(ffffffec) = 4096(1000)\nunsigned 8 1(1) << -19(ffffffed) = 8192(2000)\nunsigned 8 1(1) << -18(ffffffee) = 16384(4000)\nunsigned 8 1(1) << -17(ffffffef) = 32768(8000)\nunsigned 8 1(1) << -16(fffffff0) = 65536(10000)\nunsigned 8 1(1) << -15(fffffff1) = 131072(20000)\nunsigned 8 1(1) << -14(fffffff2) = 262144(40000)\nunsigned 8 1(1) << -13(fffffff3) = 524288(80000)\nunsigned 8 1(1) << -12(fffffff4) = 1048576(100000)\nunsigned 8 1(1) << -11(fffffff5) = 2097152(200000)\nunsigned 8 1(1) << -10(fffffff6) = 4194304(400000)\nunsigned 8 1(1) << -9(fffffff7) = 8388608(800000)\nunsigned 8 1(1) << -8(fffffff8) = 16777216(1000000)\nunsigned 8 1(1) << -7(fffffff9) = 33554432(2000000)\nunsigned 8 1(1) << -6(fffffffa) = 67108864(4000000)\nunsigned 8 1(1) << -5(fffffffb) = 134217728(8000000)\nunsigned 8 1(1) << -4(fffffffc) = 268435456(10000000)\nunsigned 8 1(1) << -3(fffffffd) = 536870912(20000000)\nunsigned 8 1(1) << -2(fffffffe) = 1073741824(40000000)\nunsigned 8 1(1) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 1(1) << 0(0) = 1(1)\nunsigned 8 1(1) << 1(1) = 2(2)\nunsigned 8 1(1) << 2(2) = 4(4)\nunsigned 8 1(1) << 3(3) = 8(8)\nunsigned 8 1(1) << 4(4) = 16(10)\nunsigned 8 1(1) << 5(5) = 32(20)\nunsigned 8 1(1) << 6(6) = 64(40)\nunsigned 8 1(1) << 7(7) = 128(80)\nunsigned 8 1(1) << 8(8) = 256(100)\nunsigned 8 1(1) << 9(9) = 512(200)\nunsigned 8 1(1) << 10(a) = 1024(400)\nunsigned 8 1(1) << 11(b) = 2048(800)\nunsigned 8 1(1) << 12(c) = 4096(1000)\nunsigned 8 1(1) << 13(d) = 8192(2000)\nunsigned 8 1(1) << 14(e) = 16384(4000)\nunsigned 8 1(1) << 15(f) = 32768(8000)\nunsigned 8 1(1) << 16(10) = 65536(10000)\nunsigned 8 1(1) << 17(11) = 131072(20000)\nunsigned 8 1(1) << 18(12) = 262144(40000)\nunsigned 8 1(1) << 19(13) = 524288(80000)\nunsigned 8 1(1) << 20(14) = 1048576(100000)\nunsigned 8 1(1) << 21(15) = 2097152(200000)\nunsigned 8 1(1) << 22(16) = 4194304(400000)\nunsigned 8 1(1) << 23(17) = 8388608(800000)\nunsigned 8 1(1) << 24(18) = 16777216(1000000)\nunsigned 8 1(1) << 25(19) = 33554432(2000000)\nunsigned 8 1(1) << 26(1a) = 67108864(4000000)\nunsigned 8 1(1) << 27(1b) = 134217728(8000000)\nunsigned 8 1(1) << 28(1c) = 268435456(10000000)\nunsigned 8 1(1) << 29(1d) = 536870912(20000000)\nunsigned 8 1(1) << 30(1e) = 1073741824(40000000)\nunsigned 8 1(1) << 31(1f) = 2147483648(80000000)\nunsigned 8 1(1) << 32(20) = 1(1)\nunsigned 8 1(1) << 33(21) = 2(2)\nunsigned 8 1(1) << 34(22) = 4(4)\nunsigned 8 1(1) << 35(23) = 8(8)\nunsigned 8 1(1) << 36(24) = 16(10)\nunsigned 8 1(1) << 37(25) = 32(20)\nunsigned 8 1(1) << 38(26) = 64(40)\nunsigned 8 1(1) << 39(27) = 128(80)\nunsigned 8 1(1) << 40(28) = 256(100)\nunsigned 8 1(1) << 41(29) = 512(200)\nunsigned 8 1(1) << 42(2a) = 1024(400)\nunsigned 8 1(1) << 43(2b) = 2048(800)\nunsigned 8 1(1) << 44(2c) = 4096(1000)\nunsigned 8 1(1) << 45(2d) = 8192(2000)\nunsigned 8 1(1) << 46(2e) = 16384(4000)\nunsigned 8 1(1) << 47(2f) = 32768(8000)\nunsigned 8 1(1) << 48(30) = 65536(10000)\nunsigned 8 1(1) << 49(31) = 131072(20000)\nunsigned 8 1(1) << 50(32) = 262144(40000)\nunsigned 8 1(1) << 51(33) = 524288(80000)\nunsigned 8 1(1) << 52(34) = 1048576(100000)\nunsigned 8 1(1) << 53(35) = 2097152(200000)\nunsigned 8 1(1) << 54(36) = 4194304(400000)\nunsigned 8 1(1) << 55(37) = 8388608(800000)\nunsigned 8 1(1) << 56(38) = 16777216(1000000)\nunsigned 8 1(1) << 57(39) = 33554432(2000000)\nunsigned 8 1(1) << 58(3a) = 67108864(4000000)\nunsigned 8 1(1) << 59(3b) = 134217728(8000000)\nunsigned 8 1(1) << 60(3c) = 268435456(10000000)\nunsigned 8 1(1) << 61(3d) = 536870912(20000000)\nunsigned 8 1(1) << 62(3e) = 1073741824(40000000)\nunsigned 8 1(1) << 63(3f) = 2147483648(80000000)\nunsigned 8 1(1) << 64(40) = 1(1)\nunsigned 8 1(1) << 65(41) = 2(2)\nunsigned 8 1(1) << 66(42) = 4(4)\nunsigned 8 1(1) << 67(43) = 8(8)\nunsigned 8 1(1) << 68(44) = 16(10)\nunsigned 8 1(1) << 69(45) = 32(20)\nunsigned 8 1(1) << 70(46) = 64(40)\nunsigned 8 1(1) << 71(47) = 128(80)\nunsigned 8 1(1) << 72(48) = 256(100)\nunsigned 8 1(1) << 73(49) = 512(200)\nunsigned 8 1(1) << 74(4a) = 1024(400)\nunsigned 8 1(1) << 75(4b) = 2048(800)\nunsigned 8 1(1) << 76(4c) = 4096(1000)\nunsigned 8 1(1) << 77(4d) = 8192(2000)\nunsigned 8 1(1) << 78(4e) = 16384(4000)\nunsigned 8 1(1) << 79(4f) = 32768(8000)\nunsigned 8 1(1) << 80(50) = 65536(10000)\nunsigned 8 1(1) << 81(51) = 131072(20000)\nunsigned 8 1(1) << 82(52) = 262144(40000)\nunsigned 8 1(1) << 83(53) = 524288(80000)\nunsigned 8 1(1) << 84(54) = 1048576(100000)\nunsigned 8 1(1) << 85(55) = 2097152(200000)\nunsigned 8 1(1) << 86(56) = 4194304(400000)\nunsigned 8 1(1) << 87(57) = 8388608(800000)\nunsigned 8 1(1) << 88(58) = 16777216(1000000)\nunsigned 8 1(1) << 89(59) = 33554432(2000000)\nunsigned 8 1(1) << 90(5a) = 67108864(4000000)\nunsigned 8 1(1) << 91(5b) = 134217728(8000000)\nunsigned 8 1(1) << 92(5c) = 268435456(10000000)\nunsigned 8 1(1) << 93(5d) = 536870912(20000000)\nunsigned 8 1(1) << 94(5e) = 1073741824(40000000)\nunsigned 8 1(1) << 95(5f) = 2147483648(80000000)\nunsigned 8 1(1) << 96(60) = 1(1)\nunsigned 8 1(1) << 97(61) = 2(2)\nunsigned 8 1(1) << 98(62) = 4(4)\nunsigned 8 1(1) << 99(63) = 8(8)\nunsigned 8 1(1) << 100(64) = 16(10)\nunsigned 8 1(1) << 101(65) = 32(20)\nunsigned 8 1(1) << 102(66) = 64(40)\nunsigned 8 1(1) << 103(67) = 128(80)\nunsigned 8 1(1) << 104(68) = 256(100)\nunsigned 8 1(1) << 105(69) = 512(200)\nunsigned 8 1(1) << 106(6a) = 1024(400)\nunsigned 8 1(1) << 107(6b) = 2048(800)\nunsigned 8 1(1) << 108(6c) = 4096(1000)\nunsigned 8 1(1) << 109(6d) = 8192(2000)\nunsigned 8 1(1) << 110(6e) = 16384(4000)\nunsigned 8 1(1) << 111(6f) = 32768(8000)\nunsigned 8 1(1) << 112(70) = 65536(10000)\nunsigned 8 1(1) << 113(71) = 131072(20000)\nunsigned 8 1(1) << 114(72) = 262144(40000)\nunsigned 8 1(1) << 115(73) = 524288(80000)\nunsigned 8 1(1) << 116(74) = 1048576(100000)\nunsigned 8 1(1) << 117(75) = 2097152(200000)\nunsigned 8 1(1) << 118(76) = 4194304(400000)\nunsigned 8 1(1) << 119(77) = 8388608(800000)\nunsigned 8 1(1) << 120(78) = 16777216(1000000)\nunsigned 8 1(1) << 121(79) = 33554432(2000000)\nunsigned 8 1(1) << 122(7a) = 67108864(4000000)\nunsigned 8 1(1) << 123(7b) = 134217728(8000000)\nunsigned 8 1(1) << 124(7c) = 268435456(10000000)\nunsigned 8 1(1) << 125(7d) = 536870912(20000000)\nunsigned 8 1(1) << 126(7e) = 1073741824(40000000)\nunsigned 8 1(1) << 127(7f) = 2147483648(80000000)\nunsigned 8 2(2) << -128(ffffff80) = 2(2)\nunsigned 8 2(2) << -127(ffffff81) = 4(4)\nunsigned 8 2(2) << -126(ffffff82) = 8(8)\nunsigned 8 2(2) << -125(ffffff83) = 16(10)\nunsigned 8 2(2) << -124(ffffff84) = 32(20)\nunsigned 8 2(2) << -123(ffffff85) = 64(40)\nunsigned 8 2(2) << -122(ffffff86) = 128(80)\nunsigned 8 2(2) << -121(ffffff87) = 256(100)\nunsigned 8 2(2) << -120(ffffff88) = 512(200)\nunsigned 8 2(2) << -119(ffffff89) = 1024(400)\nunsigned 8 2(2) << -118(ffffff8a) = 2048(800)\nunsigned 8 2(2) << -117(ffffff8b) = 4096(1000)\nunsigned 8 2(2) << -116(ffffff8c) = 8192(2000)\nunsigned 8 2(2) << -115(ffffff8d) = 16384(4000)\nunsigned 8 2(2) << -114(ffffff8e) = 32768(8000)\nunsigned 8 2(2) << -113(ffffff8f) = 65536(10000)\nunsigned 8 2(2) << -112(ffffff90) = 131072(20000)\nunsigned 8 2(2) << -111(ffffff91) = 262144(40000)\nunsigned 8 2(2) << -110(ffffff92) = 524288(80000)\nunsigned 8 2(2) << -109(ffffff93) = 1048576(100000)\nunsigned 8 2(2) << -108(ffffff94) = 2097152(200000)\nunsigned 8 2(2) << -107(ffffff95) = 4194304(400000)\nunsigned 8 2(2) << -106(ffffff96) = 8388608(800000)\nunsigned 8 2(2) << -105(ffffff97) = 16777216(1000000)\nunsigned 8 2(2) << -104(ffffff98) = 33554432(2000000)\nunsigned 8 2(2) << -103(ffffff99) = 67108864(4000000)\nunsigned 8 2(2) << -102(ffffff9a) = 134217728(8000000)\nunsigned 8 2(2) << -101(ffffff9b) = 268435456(10000000)\nunsigned 8 2(2) << -100(ffffff9c) = 536870912(20000000)\nunsigned 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\nunsigned 8 2(2) << -98(ffffff9e) = 2147483648(80000000)\nunsigned 8 2(2) << -97(ffffff9f) = 0(0)\nunsigned 8 2(2) << -96(ffffffa0) = 2(2)\nunsigned 8 2(2) << -95(ffffffa1) = 4(4)\nunsigned 8 2(2) << -94(ffffffa2) = 8(8)\nunsigned 8 2(2) << -93(ffffffa3) = 16(10)\nunsigned 8 2(2) << -92(ffffffa4) = 32(20)\nunsigned 8 2(2) << -91(ffffffa5) = 64(40)\nunsigned 8 2(2) << -90(ffffffa6) = 128(80)\nunsigned 8 2(2) << -89(ffffffa7) = 256(100)\nunsigned 8 2(2) << -88(ffffffa8) = 512(200)\nunsigned 8 2(2) << -87(ffffffa9) = 1024(400)\nunsigned 8 2(2) << -86(ffffffaa) = 2048(800)\nunsigned 8 2(2) << -85(ffffffab) = 4096(1000)\nunsigned 8 2(2) << -84(ffffffac) = 8192(2000)\nunsigned 8 2(2) << -83(ffffffad) = 16384(4000)\nunsigned 8 2(2) << -82(ffffffae) = 32768(8000)\nunsigned 8 2(2) << -81(ffffffaf) = 65536(10000)\nunsigned 8 2(2) << -80(ffffffb0) = 131072(20000)\nunsigned 8 2(2) << -79(ffffffb1) = 262144(40000)\nunsigned 8 2(2) << -78(ffffffb2) = 524288(80000)\nunsigned 8 2(2) << -77(ffffffb3) = 1048576(100000)\nunsigned 8 2(2) << -76(ffffffb4) = 2097152(200000)\nunsigned 8 2(2) << -75(ffffffb5) = 4194304(400000)\nunsigned 8 2(2) << -74(ffffffb6) = 8388608(800000)\nunsigned 8 2(2) << -73(ffffffb7) = 16777216(1000000)\nunsigned 8 2(2) << -72(ffffffb8) = 33554432(2000000)\nunsigned 8 2(2) << -71(ffffffb9) = 67108864(4000000)\nunsigned 8 2(2) << -70(ffffffba) = 134217728(8000000)\nunsigned 8 2(2) << -69(ffffffbb) = 268435456(10000000)\nunsigned 8 2(2) << -68(ffffffbc) = 536870912(20000000)\nunsigned 8 2(2) << -67(ffffffbd) = 1073741824(40000000)\nunsigned 8 2(2) << -66(ffffffbe) = 2147483648(80000000)\nunsigned 8 2(2) << -65(ffffffbf) = 0(0)\nunsigned 8 2(2) << -64(ffffffc0) = 2(2)\nunsigned 8 2(2) << -63(ffffffc1) = 4(4)\nunsigned 8 2(2) << -62(ffffffc2) = 8(8)\nunsigned 8 2(2) << -61(ffffffc3) = 16(10)\nunsigned 8 2(2) << -60(ffffffc4) = 32(20)\nunsigned 8 2(2) << -59(ffffffc5) = 64(40)\nunsigned 8 2(2) << -58(ffffffc6) = 128(80)\nunsigned 8 2(2) << -57(ffffffc7) = 256(100)\nunsigned 8 2(2) << -56(ffffffc8) = 512(200)\nunsigned 8 2(2) << -55(ffffffc9) = 1024(400)\nunsigned 8 2(2) << -54(ffffffca) = 2048(800)\nunsigned 8 2(2) << -53(ffffffcb) = 4096(1000)\nunsigned 8 2(2) << -52(ffffffcc) = 8192(2000)\nunsigned 8 2(2) << -51(ffffffcd) = 16384(4000)\nunsigned 8 2(2) << -50(ffffffce) = 32768(8000)\nunsigned 8 2(2) << -49(ffffffcf) = 65536(10000)\nunsigned 8 2(2) << -48(ffffffd0) = 131072(20000)\nunsigned 8 2(2) << -47(ffffffd1) = 262144(40000)\nunsigned 8 2(2) << -46(ffffffd2) = 524288(80000)\nunsigned 8 2(2) << -45(ffffffd3) = 1048576(100000)\nunsigned 8 2(2) << -44(ffffffd4) = 2097152(200000)\nunsigned 8 2(2) << -43(ffffffd5) = 4194304(400000)\nunsigned 8 2(2) << -42(ffffffd6) = 8388608(800000)\nunsigned 8 2(2) << -41(ffffffd7) = 16777216(1000000)\nunsigned 8 2(2) << -40(ffffffd8) = 33554432(2000000)\nunsigned 8 2(2) << -39(ffffffd9) = 67108864(4000000)\nunsigned 8 2(2) << -38(ffffffda) = 134217728(8000000)\nunsigned 8 2(2) << -37(ffffffdb) = 268435456(10000000)\nunsigned 8 2(2) << -36(ffffffdc) = 536870912(20000000)\nunsigned 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\nunsigned 8 2(2) << -34(ffffffde) = 2147483648(80000000)\nunsigned 8 2(2) << -33(ffffffdf) = 0(0)\nunsigned 8 2(2) << -32(ffffffe0) = 2(2)\nunsigned 8 2(2) << -31(ffffffe1) = 4(4)\nunsigned 8 2(2) << -30(ffffffe2) = 8(8)\nunsigned 8 2(2) << -29(ffffffe3) = 16(10)\nunsigned 8 2(2) << -28(ffffffe4) = 32(20)\nunsigned 8 2(2) << -27(ffffffe5) = 64(40)\nunsigned 8 2(2) << -26(ffffffe6) = 128(80)\nunsigned 8 2(2) << -25(ffffffe7) = 256(100)\nunsigned 8 2(2) << -24(ffffffe8) = 512(200)\nunsigned 8 2(2) << -23(ffffffe9) = 1024(400)\nunsigned 8 2(2) << -22(ffffffea) = 2048(800)\nunsigned 8 2(2) << -21(ffffffeb) = 4096(1000)\nunsigned 8 2(2) << -20(ffffffec) = 8192(2000)\nunsigned 8 2(2) << -19(ffffffed) = 16384(4000)\nunsigned 8 2(2) << -18(ffffffee) = 32768(8000)\nunsigned 8 2(2) << -17(ffffffef) = 65536(10000)\nunsigned 8 2(2) << -16(fffffff0) = 131072(20000)\nunsigned 8 2(2) << -15(fffffff1) = 262144(40000)\nunsigned 8 2(2) << -14(fffffff2) = 524288(80000)\nunsigned 8 2(2) << -13(fffffff3) = 1048576(100000)\nunsigned 8 2(2) << -12(fffffff4) = 2097152(200000)\nunsigned 8 2(2) << -11(fffffff5) = 4194304(400000)\nunsigned 8 2(2) << -10(fffffff6) = 8388608(800000)\nunsigned 8 2(2) << -9(fffffff7) = 16777216(1000000)\nunsigned 8 2(2) << -8(fffffff8) = 33554432(2000000)\nunsigned 8 2(2) << -7(fffffff9) = 67108864(4000000)\nunsigned 8 2(2) << -6(fffffffa) = 134217728(8000000)\nunsigned 8 2(2) << -5(fffffffb) = 268435456(10000000)\nunsigned 8 2(2) << -4(fffffffc) = 536870912(20000000)\nunsigned 8 2(2) << -3(fffffffd) = 1073741824(40000000)\nunsigned 8 2(2) << -2(fffffffe) = 2147483648(80000000)\nunsigned 8 2(2) << -1(ffffffff) = 0(0)\nunsigned 8 2(2) << 0(0) = 2(2)\nunsigned 8 2(2) << 1(1) = 4(4)\nunsigned 8 2(2) << 2(2) = 8(8)\nunsigned 8 2(2) << 3(3) = 16(10)\nunsigned 8 2(2) << 4(4) = 32(20)\nunsigned 8 2(2) << 5(5) = 64(40)\nunsigned 8 2(2) << 6(6) = 128(80)\nunsigned 8 2(2) << 7(7) = 256(100)\nunsigned 8 2(2) << 8(8) = 512(200)\nunsigned 8 2(2) << 9(9) = 1024(400)\nunsigned 8 2(2) << 10(a) = 2048(800)\nunsigned 8 2(2) << 11(b) = 4096(1000)\nunsigned 8 2(2) << 12(c) = 8192(2000)\nunsigned 8 2(2) << 13(d) = 16384(4000)\nunsigned 8 2(2) << 14(e) = 32768(8000)\nunsigned 8 2(2) << 15(f) = 65536(10000)\nunsigned 8 2(2) << 16(10) = 131072(20000)\nunsigned 8 2(2) << 17(11) = 262144(40000)\nunsigned 8 2(2) << 18(12) = 524288(80000)\nunsigned 8 2(2) << 19(13) = 1048576(100000)\nunsigned 8 2(2) << 20(14) = 2097152(200000)\nunsigned 8 2(2) << 21(15) = 4194304(400000)\nunsigned 8 2(2) << 22(16) = 8388608(800000)\nunsigned 8 2(2) << 23(17) = 16777216(1000000)\nunsigned 8 2(2) << 24(18) = 33554432(2000000)\nunsigned 8 2(2) << 25(19) = 67108864(4000000)\nunsigned 8 2(2) << 26(1a) = 134217728(8000000)\nunsigned 8 2(2) << 27(1b) = 268435456(10000000)\nunsigned 8 2(2) << 28(1c) = 536870912(20000000)\nunsigned 8 2(2) << 29(1d) = 1073741824(40000000)\nunsigned 8 2(2) << 30(1e) = 2147483648(80000000)\nunsigned 8 2(2) << 31(1f) = 0(0)\nunsigned 8 2(2) << 32(20) = 2(2)\nunsigned 8 2(2) << 33(21) = 4(4)\nunsigned 8 2(2) << 34(22) = 8(8)\nunsigned 8 2(2) << 35(23) = 16(10)\nunsigned 8 2(2) << 36(24) = 32(20)\nunsigned 8 2(2) << 37(25) = 64(40)\nunsigned 8 2(2) << 38(26) = 128(80)\nunsigned 8 2(2) << 39(27) = 256(100)\nunsigned 8 2(2) << 40(28) = 512(200)\nunsigned 8 2(2) << 41(29) = 1024(400)\nunsigned 8 2(2) << 42(2a) = 2048(800)\nunsigned 8 2(2) << 43(2b) = 4096(1000)\nunsigned 8 2(2) << 44(2c) = 8192(2000)\nunsigned 8 2(2) << 45(2d) = 16384(4000)\nunsigned 8 2(2) << 46(2e) = 32768(8000)\nunsigned 8 2(2) << 47(2f) = 65536(10000)\nunsigned 8 2(2) << 48(30) = 131072(20000)\nunsigned 8 2(2) << 49(31) = 262144(40000)\nunsigned 8 2(2) << 50(32) = 524288(80000)\nunsigned 8 2(2) << 51(33) = 1048576(100000)\nunsigned 8 2(2) << 52(34) = 2097152(200000)\nunsigned 8 2(2) << 53(35) = 4194304(400000)\nunsigned 8 2(2) << 54(36) = 8388608(800000)\nunsigned 8 2(2) << 55(37) = 16777216(1000000)\nunsigned 8 2(2) << 56(38) = 33554432(2000000)\nunsigned 8 2(2) << 57(39) = 67108864(4000000)\nunsigned 8 2(2) << 58(3a) = 134217728(8000000)\nunsigned 8 2(2) << 59(3b) = 268435456(10000000)\nunsigned 8 2(2) << 60(3c) = 536870912(20000000)\nunsigned 8 2(2) << 61(3d) = 1073741824(40000000)\nunsigned 8 2(2) << 62(3e) = 2147483648(80000000)\nunsigned 8 2(2) << 63(3f) = 0(0)\nunsigned 8 2(2) << 64(40) = 2(2)\nunsigned 8 2(2) << 65(41) = 4(4)\nunsigned 8 2(2) << 66(42) = 8(8)\nunsigned 8 2(2) << 67(43) = 16(10)\nunsigned 8 2(2) << 68(44) = 32(20)\nunsigned 8 2(2) << 69(45) = 64(40)\nunsigned 8 2(2) << 70(46) = 128(80)\nunsigned 8 2(2) << 71(47) = 256(100)\nunsigned 8 2(2) << 72(48) = 512(200)\nunsigned 8 2(2) << 73(49) = 1024(400)\nunsigned 8 2(2) << 74(4a) = 2048(800)\nunsigned 8 2(2) << 75(4b) = 4096(1000)\nunsigned 8 2(2) << 76(4c) = 8192(2000)\nunsigned 8 2(2) << 77(4d) = 16384(4000)\nunsigned 8 2(2) << 78(4e) = 32768(8000)\nunsigned 8 2(2) << 79(4f) = 65536(10000)\nunsigned 8 2(2) << 80(50) = 131072(20000)\nunsigned 8 2(2) << 81(51) = 262144(40000)\nunsigned 8 2(2) << 82(52) = 524288(80000)\nunsigned 8 2(2) << 83(53) = 1048576(100000)\nunsigned 8 2(2) << 84(54) = 2097152(200000)\nunsigned 8 2(2) << 85(55) = 4194304(400000)\nunsigned 8 2(2) << 86(56) = 8388608(800000)\nunsigned 8 2(2) << 87(57) = 16777216(1000000)\nunsigned 8 2(2) << 88(58) = 33554432(2000000)\nunsigned 8 2(2) << 89(59) = 67108864(4000000)\nunsigned 8 2(2) << 90(5a) = 134217728(8000000)\nunsigned 8 2(2) << 91(5b) = 268435456(10000000)\nunsigned 8 2(2) << 92(5c) = 536870912(20000000)\nunsigned 8 2(2) << 93(5d) = 1073741824(40000000)\nunsigned 8 2(2) << 94(5e) = 2147483648(80000000)\nunsigned 8 2(2) << 95(5f) = 0(0)\nunsigned 8 2(2) << 96(60) = 2(2)\nunsigned 8 2(2) << 97(61) = 4(4)\nunsigned 8 2(2) << 98(62) = 8(8)\nunsigned 8 2(2) << 99(63) = 16(10)\nunsigned 8 2(2) << 100(64) = 32(20)\nunsigned 8 2(2) << 101(65) = 64(40)\nunsigned 8 2(2) << 102(66) = 128(80)\nunsigned 8 2(2) << 103(67) = 256(100)\nunsigned 8 2(2) << 104(68) = 512(200)\nunsigned 8 2(2) << 105(69) = 1024(400)\nunsigned 8 2(2) << 106(6a) = 2048(800)\nunsigned 8 2(2) << 107(6b) = 4096(1000)\nunsigned 8 2(2) << 108(6c) = 8192(2000)\nunsigned 8 2(2) << 109(6d) = 16384(4000)\nunsigned 8 2(2) << 110(6e) = 32768(8000)\nunsigned 8 2(2) << 111(6f) = 65536(10000)\nunsigned 8 2(2) << 112(70) = 131072(20000)\nunsigned 8 2(2) << 113(71) = 262144(40000)\nunsigned 8 2(2) << 114(72) = 524288(80000)\nunsigned 8 2(2) << 115(73) = 1048576(100000)\nunsigned 8 2(2) << 116(74) = 2097152(200000)\nunsigned 8 2(2) << 117(75) = 4194304(400000)\nunsigned 8 2(2) << 118(76) = 8388608(800000)\nunsigned 8 2(2) << 119(77) = 16777216(1000000)\nunsigned 8 2(2) << 120(78) = 33554432(2000000)\nunsigned 8 2(2) << 121(79) = 67108864(4000000)\nunsigned 8 2(2) << 122(7a) = 134217728(8000000)\nunsigned 8 2(2) << 123(7b) = 268435456(10000000)\nunsigned 8 2(2) << 124(7c) = 536870912(20000000)\nunsigned 8 2(2) << 125(7d) = 1073741824(40000000)\nunsigned 8 2(2) << 126(7e) = 2147483648(80000000)\nunsigned 8 2(2) << 127(7f) = 0(0)\nunsigned 8 3(3) << -128(ffffff80) = 3(3)\nunsigned 8 3(3) << -127(ffffff81) = 6(6)\nunsigned 8 3(3) << -126(ffffff82) = 12(c)\nunsigned 8 3(3) << -125(ffffff83) = 24(18)\nunsigned 8 3(3) << -124(ffffff84) = 48(30)\nunsigned 8 3(3) << -123(ffffff85) = 96(60)\nunsigned 8 3(3) << -122(ffffff86) = 192(c0)\nunsigned 8 3(3) << -121(ffffff87) = 384(180)\nunsigned 8 3(3) << -120(ffffff88) = 768(300)\nunsigned 8 3(3) << -119(ffffff89) = 1536(600)\nunsigned 8 3(3) << -118(ffffff8a) = 3072(c00)\nunsigned 8 3(3) << -117(ffffff8b) = 6144(1800)\nunsigned 8 3(3) << -116(ffffff8c) = 12288(3000)\nunsigned 8 3(3) << -115(ffffff8d) = 24576(6000)\nunsigned 8 3(3) << -114(ffffff8e) = 49152(c000)\nunsigned 8 3(3) << -113(ffffff8f) = 98304(18000)\nunsigned 8 3(3) << -112(ffffff90) = 196608(30000)\nunsigned 8 3(3) << -111(ffffff91) = 393216(60000)\nunsigned 8 3(3) << -110(ffffff92) = 786432(c0000)\nunsigned 8 3(3) << -109(ffffff93) = 1572864(180000)\nunsigned 8 3(3) << -108(ffffff94) = 3145728(300000)\nunsigned 8 3(3) << -107(ffffff95) = 6291456(600000)\nunsigned 8 3(3) << -106(ffffff96) = 12582912(c00000)\nunsigned 8 3(3) << -105(ffffff97) = 25165824(1800000)\nunsigned 8 3(3) << -104(ffffff98) = 50331648(3000000)\nunsigned 8 3(3) << -103(ffffff99) = 100663296(6000000)\nunsigned 8 3(3) << -102(ffffff9a) = 201326592(c000000)\nunsigned 8 3(3) << -101(ffffff9b) = 402653184(18000000)\nunsigned 8 3(3) << -100(ffffff9c) = 805306368(30000000)\nunsigned 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\nunsigned 8 3(3) << -98(ffffff9e) = 3221225472(c0000000)\nunsigned 8 3(3) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 3(3) << -96(ffffffa0) = 3(3)\nunsigned 8 3(3) << -95(ffffffa1) = 6(6)\nunsigned 8 3(3) << -94(ffffffa2) = 12(c)\nunsigned 8 3(3) << -93(ffffffa3) = 24(18)\nunsigned 8 3(3) << -92(ffffffa4) = 48(30)\nunsigned 8 3(3) << -91(ffffffa5) = 96(60)\nunsigned 8 3(3) << -90(ffffffa6) = 192(c0)\nunsigned 8 3(3) << -89(ffffffa7) = 384(180)\nunsigned 8 3(3) << -88(ffffffa8) = 768(300)\nunsigned 8 3(3) << -87(ffffffa9) = 1536(600)\nunsigned 8 3(3) << -86(ffffffaa) = 3072(c00)\nunsigned 8 3(3) << -85(ffffffab) = 6144(1800)\nunsigned 8 3(3) << -84(ffffffac) = 12288(3000)\nunsigned 8 3(3) << -83(ffffffad) = 24576(6000)\nunsigned 8 3(3) << -82(ffffffae) = 49152(c000)\nunsigned 8 3(3) << -81(ffffffaf) = 98304(18000)\nunsigned 8 3(3) << -80(ffffffb0) = 196608(30000)\nunsigned 8 3(3) << -79(ffffffb1) = 393216(60000)\nunsigned 8 3(3) << -78(ffffffb2) = 786432(c0000)\nunsigned 8 3(3) << -77(ffffffb3) = 1572864(180000)\nunsigned 8 3(3) << -76(ffffffb4) = 3145728(300000)\nunsigned 8 3(3) << -75(ffffffb5) = 6291456(600000)\nunsigned 8 3(3) << -74(ffffffb6) = 12582912(c00000)\nunsigned 8 3(3) << -73(ffffffb7) = 25165824(1800000)\nunsigned 8 3(3) << -72(ffffffb8) = 50331648(3000000)\nunsigned 8 3(3) << -71(ffffffb9) = 100663296(6000000)\nunsigned 8 3(3) << -70(ffffffba) = 201326592(c000000)\nunsigned 8 3(3) << -69(ffffffbb) = 402653184(18000000)\nunsigned 8 3(3) << -68(ffffffbc) = 805306368(30000000)\nunsigned 8 3(3) << -67(ffffffbd) = 1610612736(60000000)\nunsigned 8 3(3) << -66(ffffffbe) = 3221225472(c0000000)\nunsigned 8 3(3) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 3(3) << -64(ffffffc0) = 3(3)\nunsigned 8 3(3) << -63(ffffffc1) = 6(6)\nunsigned 8 3(3) << -62(ffffffc2) = 12(c)\nunsigned 8 3(3) << -61(ffffffc3) = 24(18)\nunsigned 8 3(3) << -60(ffffffc4) = 48(30)\nunsigned 8 3(3) << -59(ffffffc5) = 96(60)\nunsigned 8 3(3) << -58(ffffffc6) = 192(c0)\nunsigned 8 3(3) << -57(ffffffc7) = 384(180)\nunsigned 8 3(3) << -56(ffffffc8) = 768(300)\nunsigned 8 3(3) << -55(ffffffc9) = 1536(600)\nunsigned 8 3(3) << -54(ffffffca) = 3072(c00)\nunsigned 8 3(3) << -53(ffffffcb) = 6144(1800)\nunsigned 8 3(3) << -52(ffffffcc) = 12288(3000)\nunsigned 8 3(3) << -51(ffffffcd) = 24576(6000)\nunsigned 8 3(3) << -50(ffffffce) = 49152(c000)\nunsigned 8 3(3) << -49(ffffffcf) = 98304(18000)\nunsigned 8 3(3) << -48(ffffffd0) = 196608(30000)\nunsigned 8 3(3) << -47(ffffffd1) = 393216(60000)\nunsigned 8 3(3) << -46(ffffffd2) = 786432(c0000)\nunsigned 8 3(3) << -45(ffffffd3) = 1572864(180000)\nunsigned 8 3(3) << -44(ffffffd4) = 3145728(300000)\nunsigned 8 3(3) << -43(ffffffd5) = 6291456(600000)\nunsigned 8 3(3) << -42(ffffffd6) = 12582912(c00000)\nunsigned 8 3(3) << -41(ffffffd7) = 25165824(1800000)\nunsigned 8 3(3) << -40(ffffffd8) = 50331648(3000000)\nunsigned 8 3(3) << -39(ffffffd9) = 100663296(6000000)\nunsigned 8 3(3) << -38(ffffffda) = 201326592(c000000)\nunsigned 8 3(3) << -37(ffffffdb) = 402653184(18000000)\nunsigned 8 3(3) << -36(ffffffdc) = 805306368(30000000)\nunsigned 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\nunsigned 8 3(3) << -34(ffffffde) = 3221225472(c0000000)\nunsigned 8 3(3) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 3(3) << -32(ffffffe0) = 3(3)\nunsigned 8 3(3) << -31(ffffffe1) = 6(6)\nunsigned 8 3(3) << -30(ffffffe2) = 12(c)\nunsigned 8 3(3) << -29(ffffffe3) = 24(18)\nunsigned 8 3(3) << -28(ffffffe4) = 48(30)\nunsigned 8 3(3) << -27(ffffffe5) = 96(60)\nunsigned 8 3(3) << -26(ffffffe6) = 192(c0)\nunsigned 8 3(3) << -25(ffffffe7) = 384(180)\nunsigned 8 3(3) << -24(ffffffe8) = 768(300)\nunsigned 8 3(3) << -23(ffffffe9) = 1536(600)\nunsigned 8 3(3) << -22(ffffffea) = 3072(c00)\nunsigned 8 3(3) << -21(ffffffeb) = 6144(1800)\nunsigned 8 3(3) << -20(ffffffec) = 12288(3000)\nunsigned 8 3(3) << -19(ffffffed) = 24576(6000)\nunsigned 8 3(3) << -18(ffffffee) = 49152(c000)\nunsigned 8 3(3) << -17(ffffffef) = 98304(18000)\nunsigned 8 3(3) << -16(fffffff0) = 196608(30000)\nunsigned 8 3(3) << -15(fffffff1) = 393216(60000)\nunsigned 8 3(3) << -14(fffffff2) = 786432(c0000)\nunsigned 8 3(3) << -13(fffffff3) = 1572864(180000)\nunsigned 8 3(3) << -12(fffffff4) = 3145728(300000)\nunsigned 8 3(3) << -11(fffffff5) = 6291456(600000)\nunsigned 8 3(3) << -10(fffffff6) = 12582912(c00000)\nunsigned 8 3(3) << -9(fffffff7) = 25165824(1800000)\nunsigned 8 3(3) << -8(fffffff8) = 50331648(3000000)\nunsigned 8 3(3) << -7(fffffff9) = 100663296(6000000)\nunsigned 8 3(3) << -6(fffffffa) = 201326592(c000000)\nunsigned 8 3(3) << -5(fffffffb) = 402653184(18000000)\nunsigned 8 3(3) << -4(fffffffc) = 805306368(30000000)\nunsigned 8 3(3) << -3(fffffffd) = 1610612736(60000000)\nunsigned 8 3(3) << -2(fffffffe) = 3221225472(c0000000)\nunsigned 8 3(3) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 3(3) << 0(0) = 3(3)\nunsigned 8 3(3) << 1(1) = 6(6)\nunsigned 8 3(3) << 2(2) = 12(c)\nunsigned 8 3(3) << 3(3) = 24(18)\nunsigned 8 3(3) << 4(4) = 48(30)\nunsigned 8 3(3) << 5(5) = 96(60)\nunsigned 8 3(3) << 6(6) = 192(c0)\nunsigned 8 3(3) << 7(7) = 384(180)\nunsigned 8 3(3) << 8(8) = 768(300)\nunsigned 8 3(3) << 9(9) = 1536(600)\nunsigned 8 3(3) << 10(a) = 3072(c00)\nunsigned 8 3(3) << 11(b) = 6144(1800)\nunsigned 8 3(3) << 12(c) = 12288(3000)\nunsigned 8 3(3) << 13(d) = 24576(6000)\nunsigned 8 3(3) << 14(e) = 49152(c000)\nunsigned 8 3(3) << 15(f) = 98304(18000)\nunsigned 8 3(3) << 16(10) = 196608(30000)\nunsigned 8 3(3) << 17(11) = 393216(60000)\nunsigned 8 3(3) << 18(12) = 786432(c0000)\nunsigned 8 3(3) << 19(13) = 1572864(180000)\nunsigned 8 3(3) << 20(14) = 3145728(300000)\nunsigned 8 3(3) << 21(15) = 6291456(600000)\nunsigned 8 3(3) << 22(16) = 12582912(c00000)\nunsigned 8 3(3) << 23(17) = 25165824(1800000)\nunsigned 8 3(3) << 24(18) = 50331648(3000000)\nunsigned 8 3(3) << 25(19) = 100663296(6000000)\nunsigned 8 3(3) << 26(1a) = 201326592(c000000)\nunsigned 8 3(3) << 27(1b) = 402653184(18000000)\nunsigned 8 3(3) << 28(1c) = 805306368(30000000)\nunsigned 8 3(3) << 29(1d) = 1610612736(60000000)\nunsigned 8 3(3) << 30(1e) = 3221225472(c0000000)\nunsigned 8 3(3) << 31(1f) = 2147483648(80000000)\nunsigned 8 3(3) << 32(20) = 3(3)\nunsigned 8 3(3) << 33(21) = 6(6)\nunsigned 8 3(3) << 34(22) = 12(c)\nunsigned 8 3(3) << 35(23) = 24(18)\nunsigned 8 3(3) << 36(24) = 48(30)\nunsigned 8 3(3) << 37(25) = 96(60)\nunsigned 8 3(3) << 38(26) = 192(c0)\nunsigned 8 3(3) << 39(27) = 384(180)\nunsigned 8 3(3) << 40(28) = 768(300)\nunsigned 8 3(3) << 41(29) = 1536(600)\nunsigned 8 3(3) << 42(2a) = 3072(c00)\nunsigned 8 3(3) << 43(2b) = 6144(1800)\nunsigned 8 3(3) << 44(2c) = 12288(3000)\nunsigned 8 3(3) << 45(2d) = 24576(6000)\nunsigned 8 3(3) << 46(2e) = 49152(c000)\nunsigned 8 3(3) << 47(2f) = 98304(18000)\nunsigned 8 3(3) << 48(30) = 196608(30000)\nunsigned 8 3(3) << 49(31) = 393216(60000)\nunsigned 8 3(3) << 50(32) = 786432(c0000)\nunsigned 8 3(3) << 51(33) = 1572864(180000)\nunsigned 8 3(3) << 52(34) = 3145728(300000)\nunsigned 8 3(3) << 53(35) = 6291456(600000)\nunsigned 8 3(3) << 54(36) = 12582912(c00000)\nunsigned 8 3(3) << 55(37) = 25165824(1800000)\nunsigned 8 3(3) << 56(38) = 50331648(3000000)\nunsigned 8 3(3) << 57(39) = 100663296(6000000)\nunsigned 8 3(3) << 58(3a) = 201326592(c000000)\nunsigned 8 3(3) << 59(3b) = 402653184(18000000)\nunsigned 8 3(3) << 60(3c) = 805306368(30000000)\nunsigned 8 3(3) << 61(3d) = 1610612736(60000000)\nunsigned 8 3(3) << 62(3e) = 3221225472(c0000000)\nunsigned 8 3(3) << 63(3f) = 2147483648(80000000)\nunsigned 8 3(3) << 64(40) = 3(3)\nunsigned 8 3(3) << 65(41) = 6(6)\nunsigned 8 3(3) << 66(42) = 12(c)\nunsigned 8 3(3) << 67(43) = 24(18)\nunsigned 8 3(3) << 68(44) = 48(30)\nunsigned 8 3(3) << 69(45) = 96(60)\nunsigned 8 3(3) << 70(46) = 192(c0)\nunsigned 8 3(3) << 71(47) = 384(180)\nunsigned 8 3(3) << 72(48) = 768(300)\nunsigned 8 3(3) << 73(49) = 1536(600)\nunsigned 8 3(3) << 74(4a) = 3072(c00)\nunsigned 8 3(3) << 75(4b) = 6144(1800)\nunsigned 8 3(3) << 76(4c) = 12288(3000)\nunsigned 8 3(3) << 77(4d) = 24576(6000)\nunsigned 8 3(3) << 78(4e) = 49152(c000)\nunsigned 8 3(3) << 79(4f) = 98304(18000)\nunsigned 8 3(3) << 80(50) = 196608(30000)\nunsigned 8 3(3) << 81(51) = 393216(60000)\nunsigned 8 3(3) << 82(52) = 786432(c0000)\nunsigned 8 3(3) << 83(53) = 1572864(180000)\nunsigned 8 3(3) << 84(54) = 3145728(300000)\nunsigned 8 3(3) << 85(55) = 6291456(600000)\nunsigned 8 3(3) << 86(56) = 12582912(c00000)\nunsigned 8 3(3) << 87(57) = 25165824(1800000)\nunsigned 8 3(3) << 88(58) = 50331648(3000000)\nunsigned 8 3(3) << 89(59) = 100663296(6000000)\nunsigned 8 3(3) << 90(5a) = 201326592(c000000)\nunsigned 8 3(3) << 91(5b) = 402653184(18000000)\nunsigned 8 3(3) << 92(5c) = 805306368(30000000)\nunsigned 8 3(3) << 93(5d) = 1610612736(60000000)\nunsigned 8 3(3) << 94(5e) = 3221225472(c0000000)\nunsigned 8 3(3) << 95(5f) = 2147483648(80000000)\nunsigned 8 3(3) << 96(60) = 3(3)\nunsigned 8 3(3) << 97(61) = 6(6)\nunsigned 8 3(3) << 98(62) = 12(c)\nunsigned 8 3(3) << 99(63) = 24(18)\nunsigned 8 3(3) << 100(64) = 48(30)\nunsigned 8 3(3) << 101(65) = 96(60)\nunsigned 8 3(3) << 102(66) = 192(c0)\nunsigned 8 3(3) << 103(67) = 384(180)\nunsigned 8 3(3) << 104(68) = 768(300)\nunsigned 8 3(3) << 105(69) = 1536(600)\nunsigned 8 3(3) << 106(6a) = 3072(c00)\nunsigned 8 3(3) << 107(6b) = 6144(1800)\nunsigned 8 3(3) << 108(6c) = 12288(3000)\nunsigned 8 3(3) << 109(6d) = 24576(6000)\nunsigned 8 3(3) << 110(6e) = 49152(c000)\nunsigned 8 3(3) << 111(6f) = 98304(18000)\nunsigned 8 3(3) << 112(70) = 196608(30000)\nunsigned 8 3(3) << 113(71) = 393216(60000)\nunsigned 8 3(3) << 114(72) = 786432(c0000)\nunsigned 8 3(3) << 115(73) = 1572864(180000)\nunsigned 8 3(3) << 116(74) = 3145728(300000)\nunsigned 8 3(3) << 117(75) = 6291456(600000)\nunsigned 8 3(3) << 118(76) = 12582912(c00000)\nunsigned 8 3(3) << 119(77) = 25165824(1800000)\nunsigned 8 3(3) << 120(78) = 50331648(3000000)\nunsigned 8 3(3) << 121(79) = 100663296(6000000)\nunsigned 8 3(3) << 122(7a) = 201326592(c000000)\nunsigned 8 3(3) << 123(7b) = 402653184(18000000)\nunsigned 8 3(3) << 124(7c) = 805306368(30000000)\nunsigned 8 3(3) << 125(7d) = 1610612736(60000000)\nunsigned 8 3(3) << 126(7e) = 3221225472(c0000000)\nunsigned 8 3(3) << 127(7f) = 2147483648(80000000)\nunsigned 8 4(4) << -128(ffffff80) = 4(4)\nunsigned 8 4(4) << -127(ffffff81) = 8(8)\nunsigned 8 4(4) << -126(ffffff82) = 16(10)\nunsigned 8 4(4) << -125(ffffff83) = 32(20)\nunsigned 8 4(4) << -124(ffffff84) = 64(40)\nunsigned 8 4(4) << -123(ffffff85) = 128(80)\nunsigned 8 4(4) << -122(ffffff86) = 256(100)\nunsigned 8 4(4) << -121(ffffff87) = 512(200)\nunsigned 8 4(4) << -120(ffffff88) = 1024(400)\nunsigned 8 4(4) << -119(ffffff89) = 2048(800)\nunsigned 8 4(4) << -118(ffffff8a) = 4096(1000)\nunsigned 8 4(4) << -117(ffffff8b) = 8192(2000)\nunsigned 8 4(4) << -116(ffffff8c) = 16384(4000)\nunsigned 8 4(4) << -115(ffffff8d) = 32768(8000)\nunsigned 8 4(4) << -114(ffffff8e) = 65536(10000)\nunsigned 8 4(4) << -113(ffffff8f) = 131072(20000)\nunsigned 8 4(4) << -112(ffffff90) = 262144(40000)\nunsigned 8 4(4) << -111(ffffff91) = 524288(80000)\nunsigned 8 4(4) << -110(ffffff92) = 1048576(100000)\nunsigned 8 4(4) << -109(ffffff93) = 2097152(200000)\nunsigned 8 4(4) << -108(ffffff94) = 4194304(400000)\nunsigned 8 4(4) << -107(ffffff95) = 8388608(800000)\nunsigned 8 4(4) << -106(ffffff96) = 16777216(1000000)\nunsigned 8 4(4) << -105(ffffff97) = 33554432(2000000)\nunsigned 8 4(4) << -104(ffffff98) = 67108864(4000000)\nunsigned 8 4(4) << -103(ffffff99) = 134217728(8000000)\nunsigned 8 4(4) << -102(ffffff9a) = 268435456(10000000)\nunsigned 8 4(4) << -101(ffffff9b) = 536870912(20000000)\nunsigned 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\nunsigned 8 4(4) << -99(ffffff9d) = 2147483648(80000000)\nunsigned 8 4(4) << -98(ffffff9e) = 0(0)\nunsigned 8 4(4) << -97(ffffff9f) = 0(0)\nunsigned 8 4(4) << -96(ffffffa0) = 4(4)\nunsigned 8 4(4) << -95(ffffffa1) = 8(8)\nunsigned 8 4(4) << -94(ffffffa2) = 16(10)\nunsigned 8 4(4) << -93(ffffffa3) = 32(20)\nunsigned 8 4(4) << -92(ffffffa4) = 64(40)\nunsigned 8 4(4) << -91(ffffffa5) = 128(80)\nunsigned 8 4(4) << -90(ffffffa6) = 256(100)\nunsigned 8 4(4) << -89(ffffffa7) = 512(200)\nunsigned 8 4(4) << -88(ffffffa8) = 1024(400)\nunsigned 8 4(4) << -87(ffffffa9) = 2048(800)\nunsigned 8 4(4) << -86(ffffffaa) = 4096(1000)\nunsigned 8 4(4) << -85(ffffffab) = 8192(2000)\nunsigned 8 4(4) << -84(ffffffac) = 16384(4000)\nunsigned 8 4(4) << -83(ffffffad) = 32768(8000)\nunsigned 8 4(4) << -82(ffffffae) = 65536(10000)\nunsigned 8 4(4) << -81(ffffffaf) = 131072(20000)\nunsigned 8 4(4) << -80(ffffffb0) = 262144(40000)\nunsigned 8 4(4) << -79(ffffffb1) = 524288(80000)\nunsigned 8 4(4) << -78(ffffffb2) = 1048576(100000)\nunsigned 8 4(4) << -77(ffffffb3) = 2097152(200000)\nunsigned 8 4(4) << -76(ffffffb4) = 4194304(400000)\nunsigned 8 4(4) << -75(ffffffb5) = 8388608(800000)\nunsigned 8 4(4) << -74(ffffffb6) = 16777216(1000000)\nunsigned 8 4(4) << -73(ffffffb7) = 33554432(2000000)\nunsigned 8 4(4) << -72(ffffffb8) = 67108864(4000000)\nunsigned 8 4(4) << -71(ffffffb9) = 134217728(8000000)\nunsigned 8 4(4) << -70(ffffffba) = 268435456(10000000)\nunsigned 8 4(4) << -69(ffffffbb) = 536870912(20000000)\nunsigned 8 4(4) << -68(ffffffbc) = 1073741824(40000000)\nunsigned 8 4(4) << -67(ffffffbd) = 2147483648(80000000)\nunsigned 8 4(4) << -66(ffffffbe) = 0(0)\nunsigned 8 4(4) << -65(ffffffbf) = 0(0)\nunsigned 8 4(4) << -64(ffffffc0) = 4(4)\nunsigned 8 4(4) << -63(ffffffc1) = 8(8)\nunsigned 8 4(4) << -62(ffffffc2) = 16(10)\nunsigned 8 4(4) << -61(ffffffc3) = 32(20)\nunsigned 8 4(4) << -60(ffffffc4) = 64(40)\nunsigned 8 4(4) << -59(ffffffc5) = 128(80)\nunsigned 8 4(4) << -58(ffffffc6) = 256(100)\nunsigned 8 4(4) << -57(ffffffc7) = 512(200)\nunsigned 8 4(4) << -56(ffffffc8) = 1024(400)\nunsigned 8 4(4) << -55(ffffffc9) = 2048(800)\nunsigned 8 4(4) << -54(ffffffca) = 4096(1000)\nunsigned 8 4(4) << -53(ffffffcb) = 8192(2000)\nunsigned 8 4(4) << -52(ffffffcc) = 16384(4000)\nunsigned 8 4(4) << -51(ffffffcd) = 32768(8000)\nunsigned 8 4(4) << -50(ffffffce) = 65536(10000)\nunsigned 8 4(4) << -49(ffffffcf) = 131072(20000)\nunsigned 8 4(4) << -48(ffffffd0) = 262144(40000)\nunsigned 8 4(4) << -47(ffffffd1) = 524288(80000)\nunsigned 8 4(4) << -46(ffffffd2) = 1048576(100000)\nunsigned 8 4(4) << -45(ffffffd3) = 2097152(200000)\nunsigned 8 4(4) << -44(ffffffd4) = 4194304(400000)\nunsigned 8 4(4) << -43(ffffffd5) = 8388608(800000)\nunsigned 8 4(4) << -42(ffffffd6) = 16777216(1000000)\nunsigned 8 4(4) << -41(ffffffd7) = 33554432(2000000)\nunsigned 8 4(4) << -40(ffffffd8) = 67108864(4000000)\nunsigned 8 4(4) << -39(ffffffd9) = 134217728(8000000)\nunsigned 8 4(4) << -38(ffffffda) = 268435456(10000000)\nunsigned 8 4(4) << -37(ffffffdb) = 536870912(20000000)\nunsigned 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\nunsigned 8 4(4) << -35(ffffffdd) = 2147483648(80000000)\nunsigned 8 4(4) << -34(ffffffde) = 0(0)\nunsigned 8 4(4) << -33(ffffffdf) = 0(0)\nunsigned 8 4(4) << -32(ffffffe0) = 4(4)\nunsigned 8 4(4) << -31(ffffffe1) = 8(8)\nunsigned 8 4(4) << -30(ffffffe2) = 16(10)\nunsigned 8 4(4) << -29(ffffffe3) = 32(20)\nunsigned 8 4(4) << -28(ffffffe4) = 64(40)\nunsigned 8 4(4) << -27(ffffffe5) = 128(80)\nunsigned 8 4(4) << -26(ffffffe6) = 256(100)\nunsigned 8 4(4) << -25(ffffffe7) = 512(200)\nunsigned 8 4(4) << -24(ffffffe8) = 1024(400)\nunsigned 8 4(4) << -23(ffffffe9) = 2048(800)\nunsigned 8 4(4) << -22(ffffffea) = 4096(1000)\nunsigned 8 4(4) << -21(ffffffeb) = 8192(2000)\nunsigned 8 4(4) << -20(ffffffec) = 16384(4000)\nunsigned 8 4(4) << -19(ffffffed) = 32768(8000)\nunsigned 8 4(4) << -18(ffffffee) = 65536(10000)\nunsigned 8 4(4) << -17(ffffffef) = 131072(20000)\nunsigned 8 4(4) << -16(fffffff0) = 262144(40000)\nunsigned 8 4(4) << -15(fffffff1) = 524288(80000)\nunsigned 8 4(4) << -14(fffffff2) = 1048576(100000)\nunsigned 8 4(4) << -13(fffffff3) = 2097152(200000)\nunsigned 8 4(4) << -12(fffffff4) = 4194304(400000)\nunsigned 8 4(4) << -11(fffffff5) = 8388608(800000)\nunsigned 8 4(4) << -10(fffffff6) = 16777216(1000000)\nunsigned 8 4(4) << -9(fffffff7) = 33554432(2000000)\nunsigned 8 4(4) << -8(fffffff8) = 67108864(4000000)\nunsigned 8 4(4) << -7(fffffff9) = 134217728(8000000)\nunsigned 8 4(4) << -6(fffffffa) = 268435456(10000000)\nunsigned 8 4(4) << -5(fffffffb) = 536870912(20000000)\nunsigned 8 4(4) << -4(fffffffc) = 1073741824(40000000)\nunsigned 8 4(4) << -3(fffffffd) = 2147483648(80000000)\nunsigned 8 4(4) << -2(fffffffe) = 0(0)\nunsigned 8 4(4) << -1(ffffffff) = 0(0)\nunsigned 8 4(4) << 0(0) = 4(4)\nunsigned 8 4(4) << 1(1) = 8(8)\nunsigned 8 4(4) << 2(2) = 16(10)\nunsigned 8 4(4) << 3(3) = 32(20)\nunsigned 8 4(4) << 4(4) = 64(40)\nunsigned 8 4(4) << 5(5) = 128(80)\nunsigned 8 4(4) << 6(6) = 256(100)\nunsigned 8 4(4) << 7(7) = 512(200)\nunsigned 8 4(4) << 8(8) = 1024(400)\nunsigned 8 4(4) << 9(9) = 2048(800)\nunsigned 8 4(4) << 10(a) = 4096(1000)\nunsigned 8 4(4) << 11(b) = 8192(2000)\nunsigned 8 4(4) << 12(c) = 16384(4000)\nunsigned 8 4(4) << 13(d) = 32768(8000)\nunsigned 8 4(4) << 14(e) = 65536(10000)\nunsigned 8 4(4) << 15(f) = 131072(20000)\nunsigned 8 4(4) << 16(10) = 262144(40000)\nunsigned 8 4(4) << 17(11) = 524288(80000)\nunsigned 8 4(4) << 18(12) = 1048576(100000)\nunsigned 8 4(4) << 19(13) = 2097152(200000)\nunsigned 8 4(4) << 20(14) = 4194304(400000)\nunsigned 8 4(4) << 21(15) = 8388608(800000)\nunsigned 8 4(4) << 22(16) = 16777216(1000000)\nunsigned 8 4(4) << 23(17) = 33554432(2000000)\nunsigned 8 4(4) << 24(18) = 67108864(4000000)\nunsigned 8 4(4) << 25(19) = 134217728(8000000)\nunsigned 8 4(4) << 26(1a) = 268435456(10000000)\nunsigned 8 4(4) << 27(1b) = 536870912(20000000)\nunsigned 8 4(4) << 28(1c) = 1073741824(40000000)\nunsigned 8 4(4) << 29(1d) = 2147483648(80000000)\nunsigned 8 4(4) << 30(1e) = 0(0)\nunsigned 8 4(4) << 31(1f) = 0(0)\nunsigned 8 4(4) << 32(20) = 4(4)\nunsigned 8 4(4) << 33(21) = 8(8)\nunsigned 8 4(4) << 34(22) = 16(10)\nunsigned 8 4(4) << 35(23) = 32(20)\nunsigned 8 4(4) << 36(24) = 64(40)\nunsigned 8 4(4) << 37(25) = 128(80)\nunsigned 8 4(4) << 38(26) = 256(100)\nunsigned 8 4(4) << 39(27) = 512(200)\nunsigned 8 4(4) << 40(28) = 1024(400)\nunsigned 8 4(4) << 41(29) = 2048(800)\nunsigned 8 4(4) << 42(2a) = 4096(1000)\nunsigned 8 4(4) << 43(2b) = 8192(2000)\nunsigned 8 4(4) << 44(2c) = 16384(4000)\nunsigned 8 4(4) << 45(2d) = 32768(8000)\nunsigned 8 4(4) << 46(2e) = 65536(10000)\nunsigned 8 4(4) << 47(2f) = 131072(20000)\nunsigned 8 4(4) << 48(30) = 262144(40000)\nunsigned 8 4(4) << 49(31) = 524288(80000)\nunsigned 8 4(4) << 50(32) = 1048576(100000)\nunsigned 8 4(4) << 51(33) = 2097152(200000)\nunsigned 8 4(4) << 52(34) = 4194304(400000)\nunsigned 8 4(4) << 53(35) = 8388608(800000)\nunsigned 8 4(4) << 54(36) = 16777216(1000000)\nunsigned 8 4(4) << 55(37) = 33554432(2000000)\nunsigned 8 4(4) << 56(38) = 67108864(4000000)\nunsigned 8 4(4) << 57(39) = 134217728(8000000)\nunsigned 8 4(4) << 58(3a) = 268435456(10000000)\nunsigned 8 4(4) << 59(3b) = 536870912(20000000)\nunsigned 8 4(4) << 60(3c) = 1073741824(40000000)\nunsigned 8 4(4) << 61(3d) = 2147483648(80000000)\nunsigned 8 4(4) << 62(3e) = 0(0)\nunsigned 8 4(4) << 63(3f) = 0(0)\nunsigned 8 4(4) << 64(40) = 4(4)\nunsigned 8 4(4) << 65(41) = 8(8)\nunsigned 8 4(4) << 66(42) = 16(10)\nunsigned 8 4(4) << 67(43) = 32(20)\nunsigned 8 4(4) << 68(44) = 64(40)\nunsigned 8 4(4) << 69(45) = 128(80)\nunsigned 8 4(4) << 70(46) = 256(100)\nunsigned 8 4(4) << 71(47) = 512(200)\nunsigned 8 4(4) << 72(48) = 1024(400)\nunsigned 8 4(4) << 73(49) = 2048(800)\nunsigned 8 4(4) << 74(4a) = 4096(1000)\nunsigned 8 4(4) << 75(4b) = 8192(2000)\nunsigned 8 4(4) << 76(4c) = 16384(4000)\nunsigned 8 4(4) << 77(4d) = 32768(8000)\nunsigned 8 4(4) << 78(4e) = 65536(10000)\nunsigned 8 4(4) << 79(4f) = 131072(20000)\nunsigned 8 4(4) << 80(50) = 262144(40000)\nunsigned 8 4(4) << 81(51) = 524288(80000)\nunsigned 8 4(4) << 82(52) = 1048576(100000)\nunsigned 8 4(4) << 83(53) = 2097152(200000)\nunsigned 8 4(4) << 84(54) = 4194304(400000)\nunsigned 8 4(4) << 85(55) = 8388608(800000)\nunsigned 8 4(4) << 86(56) = 16777216(1000000)\nunsigned 8 4(4) << 87(57) = 33554432(2000000)\nunsigned 8 4(4) << 88(58) = 67108864(4000000)\nunsigned 8 4(4) << 89(59) = 134217728(8000000)\nunsigned 8 4(4) << 90(5a) = 268435456(10000000)\nunsigned 8 4(4) << 91(5b) = 536870912(20000000)\nunsigned 8 4(4) << 92(5c) = 1073741824(40000000)\nunsigned 8 4(4) << 93(5d) = 2147483648(80000000)\nunsigned 8 4(4) << 94(5e) = 0(0)\nunsigned 8 4(4) << 95(5f) = 0(0)\nunsigned 8 4(4) << 96(60) = 4(4)\nunsigned 8 4(4) << 97(61) = 8(8)\nunsigned 8 4(4) << 98(62) = 16(10)\nunsigned 8 4(4) << 99(63) = 32(20)\nunsigned 8 4(4) << 100(64) = 64(40)\nunsigned 8 4(4) << 101(65) = 128(80)\nunsigned 8 4(4) << 102(66) = 256(100)\nunsigned 8 4(4) << 103(67) = 512(200)\nunsigned 8 4(4) << 104(68) = 1024(400)\nunsigned 8 4(4) << 105(69) = 2048(800)\nunsigned 8 4(4) << 106(6a) = 4096(1000)\nunsigned 8 4(4) << 107(6b) = 8192(2000)\nunsigned 8 4(4) << 108(6c) = 16384(4000)\nunsigned 8 4(4) << 109(6d) = 32768(8000)\nunsigned 8 4(4) << 110(6e) = 65536(10000)\nunsigned 8 4(4) << 111(6f) = 131072(20000)\nunsigned 8 4(4) << 112(70) = 262144(40000)\nunsigned 8 4(4) << 113(71) = 524288(80000)\nunsigned 8 4(4) << 114(72) = 1048576(100000)\nunsigned 8 4(4) << 115(73) = 2097152(200000)\nunsigned 8 4(4) << 116(74) = 4194304(400000)\nunsigned 8 4(4) << 117(75) = 8388608(800000)\nunsigned 8 4(4) << 118(76) = 16777216(1000000)\nunsigned 8 4(4) << 119(77) = 33554432(2000000)\nunsigned 8 4(4) << 120(78) = 67108864(4000000)\nunsigned 8 4(4) << 121(79) = 134217728(8000000)\nunsigned 8 4(4) << 122(7a) = 268435456(10000000)\nunsigned 8 4(4) << 123(7b) = 536870912(20000000)\nunsigned 8 4(4) << 124(7c) = 1073741824(40000000)\nunsigned 8 4(4) << 125(7d) = 2147483648(80000000)\nunsigned 8 4(4) << 126(7e) = 0(0)\nunsigned 8 4(4) << 127(7f) = 0(0)\n  signed 8 -4(fffc) >> -128(ffffff80) = -4(fffc)\n  signed 8 -4(fffc) >> -127(ffffff81) = -2(fffe)\n  signed 8 -4(fffc) >> -126(ffffff82) = -1(ffff)\n  signed 8 -4(fffc) >> -125(ffffff83) = -1(ffff)\n  signed 8 -4(fffc) >> -124(ffffff84) = -1(ffff)\n  signed 8 -4(fffc) >> -123(ffffff85) = -1(ffff)\n  signed 8 -4(fffc) >> -122(ffffff86) = -1(ffff)\n  signed 8 -4(fffc) >> -121(ffffff87) = -1(ffff)\n  signed 8 -4(fffc) >> -120(ffffff88) = -1(ffff)\n  signed 8 -4(fffc) >> -119(ffffff89) = -1(ffff)\n  signed 8 -4(fffc) >> -118(ffffff8a) = -1(ffff)\n  signed 8 -4(fffc) >> -117(ffffff8b) = -1(ffff)\n  signed 8 -4(fffc) >> -116(ffffff8c) = -1(ffff)\n  signed 8 -4(fffc) >> -115(ffffff8d) = -1(ffff)\n  signed 8 -4(fffc) >> -114(ffffff8e) = -1(ffff)\n  signed 8 -4(fffc) >> -113(ffffff8f) = -1(ffff)\n  signed 8 -4(fffc) >> -112(ffffff90) = -1(ffff)\n  signed 8 -4(fffc) >> -111(ffffff91) = -1(ffff)\n  signed 8 -4(fffc) >> -110(ffffff92) = -1(ffff)\n  signed 8 -4(fffc) >> -109(ffffff93) = -1(ffff)\n  signed 8 -4(fffc) >> -108(ffffff94) = -1(ffff)\n  signed 8 -4(fffc) >> -107(ffffff95) = -1(ffff)\n  signed 8 -4(fffc) >> -106(ffffff96) = -1(ffff)\n  signed 8 -4(fffc) >> -105(ffffff97) = -1(ffff)\n  signed 8 -4(fffc) >> -104(ffffff98) = -1(ffff)\n  signed 8 -4(fffc) >> -103(ffffff99) = -1(ffff)\n  signed 8 -4(fffc) >> -102(ffffff9a) = -1(ffff)\n  signed 8 -4(fffc) >> -101(ffffff9b) = -1(ffff)\n  signed 8 -4(fffc) >> -100(ffffff9c) = -1(ffff)\n  signed 8 -4(fffc) >> -99(ffffff9d) = -1(ffff)\n  signed 8 -4(fffc) >> -98(ffffff9e) = -1(ffff)\n  signed 8 -4(fffc) >> -97(ffffff9f) = -1(ffff)\n  signed 8 -4(fffc) >> -96(ffffffa0) = -4(fffc)\n  signed 8 -4(fffc) >> -95(ffffffa1) = -2(fffe)\n  signed 8 -4(fffc) >> -94(ffffffa2) = -1(ffff)\n  signed 8 -4(fffc) >> -93(ffffffa3) = -1(ffff)\n  signed 8 -4(fffc) >> -92(ffffffa4) = -1(ffff)\n  signed 8 -4(fffc) >> -91(ffffffa5) = -1(ffff)\n  signed 8 -4(fffc) >> -90(ffffffa6) = -1(ffff)\n  signed 8 -4(fffc) >> -89(ffffffa7) = -1(ffff)\n  signed 8 -4(fffc) >> -88(ffffffa8) = -1(ffff)\n  signed 8 -4(fffc) >> -87(ffffffa9) = -1(ffff)\n  signed 8 -4(fffc) >> -86(ffffffaa) = -1(ffff)\n  signed 8 -4(fffc) >> -85(ffffffab) = -1(ffff)\n  signed 8 -4(fffc) >> -84(ffffffac) = -1(ffff)\n  signed 8 -4(fffc) >> -83(ffffffad) = -1(ffff)\n  signed 8 -4(fffc) >> -82(ffffffae) = -1(ffff)\n  signed 8 -4(fffc) >> -81(ffffffaf) = -1(ffff)\n  signed 8 -4(fffc) >> -80(ffffffb0) = -1(ffff)\n  signed 8 -4(fffc) >> -79(ffffffb1) = -1(ffff)\n  signed 8 -4(fffc) >> -78(ffffffb2) = -1(ffff)\n  signed 8 -4(fffc) >> -77(ffffffb3) = -1(ffff)\n  signed 8 -4(fffc) >> -76(ffffffb4) = -1(ffff)\n  signed 8 -4(fffc) >> -75(ffffffb5) = -1(ffff)\n  signed 8 -4(fffc) >> -74(ffffffb6) = -1(ffff)\n  signed 8 -4(fffc) >> -73(ffffffb7) = -1(ffff)\n  signed 8 -4(fffc) >> -72(ffffffb8) = -1(ffff)\n  signed 8 -4(fffc) >> -71(ffffffb9) = -1(ffff)\n  signed 8 -4(fffc) >> -70(ffffffba) = -1(ffff)\n  signed 8 -4(fffc) >> -69(ffffffbb) = -1(ffff)\n  signed 8 -4(fffc) >> -68(ffffffbc) = -1(ffff)\n  signed 8 -4(fffc) >> -67(ffffffbd) = -1(ffff)\n  signed 8 -4(fffc) >> -66(ffffffbe) = -1(ffff)\n  signed 8 -4(fffc) >> -65(ffffffbf) = -1(ffff)\n  signed 8 -4(fffc) >> -64(ffffffc0) = -4(fffc)\n  signed 8 -4(fffc) >> -63(ffffffc1) = -2(fffe)\n  signed 8 -4(fffc) >> -62(ffffffc2) = -1(ffff)\n  signed 8 -4(fffc) >> -61(ffffffc3) = -1(ffff)\n  signed 8 -4(fffc) >> -60(ffffffc4) = -1(ffff)\n  signed 8 -4(fffc) >> -59(ffffffc5) = -1(ffff)\n  signed 8 -4(fffc) >> -58(ffffffc6) = -1(ffff)\n  signed 8 -4(fffc) >> -57(ffffffc7) = -1(ffff)\n  signed 8 -4(fffc) >> -56(ffffffc8) = -1(ffff)\n  signed 8 -4(fffc) >> -55(ffffffc9) = -1(ffff)\n  signed 8 -4(fffc) >> -54(ffffffca) = -1(ffff)\n  signed 8 -4(fffc) >> -53(ffffffcb) = -1(ffff)\n  signed 8 -4(fffc) >> -52(ffffffcc) = -1(ffff)\n  signed 8 -4(fffc) >> -51(ffffffcd) = -1(ffff)\n  signed 8 -4(fffc) >> -50(ffffffce) = -1(ffff)\n  signed 8 -4(fffc) >> -49(ffffffcf) = -1(ffff)\n  signed 8 -4(fffc) >> -48(ffffffd0) = -1(ffff)\n  signed 8 -4(fffc) >> -47(ffffffd1) = -1(ffff)\n  signed 8 -4(fffc) >> -46(ffffffd2) = -1(ffff)\n  signed 8 -4(fffc) >> -45(ffffffd3) = -1(ffff)\n  signed 8 -4(fffc) >> -44(ffffffd4) = -1(ffff)\n  signed 8 -4(fffc) >> -43(ffffffd5) = -1(ffff)\n  signed 8 -4(fffc) >> -42(ffffffd6) = -1(ffff)\n  signed 8 -4(fffc) >> -41(ffffffd7) = -1(ffff)\n  signed 8 -4(fffc) >> -40(ffffffd8) = -1(ffff)\n  signed 8 -4(fffc) >> -39(ffffffd9) = -1(ffff)\n  signed 8 -4(fffc) >> -38(ffffffda) = -1(ffff)\n  signed 8 -4(fffc) >> -37(ffffffdb) = -1(ffff)\n  signed 8 -4(fffc) >> -36(ffffffdc) = -1(ffff)\n  signed 8 -4(fffc) >> -35(ffffffdd) = -1(ffff)\n  signed 8 -4(fffc) >> -34(ffffffde) = -1(ffff)\n  signed 8 -4(fffc) >> -33(ffffffdf) = -1(ffff)\n  signed 8 -4(fffc) >> -32(ffffffe0) = -4(fffc)\n  signed 8 -4(fffc) >> -31(ffffffe1) = -2(fffe)\n  signed 8 -4(fffc) >> -30(ffffffe2) = -1(ffff)\n  signed 8 -4(fffc) >> -29(ffffffe3) = -1(ffff)\n  signed 8 -4(fffc) >> -28(ffffffe4) = -1(ffff)\n  signed 8 -4(fffc) >> -27(ffffffe5) = -1(ffff)\n  signed 8 -4(fffc) >> -26(ffffffe6) = -1(ffff)\n  signed 8 -4(fffc) >> -25(ffffffe7) = -1(ffff)\n  signed 8 -4(fffc) >> -24(ffffffe8) = -1(ffff)\n  signed 8 -4(fffc) >> -23(ffffffe9) = -1(ffff)\n  signed 8 -4(fffc) >> -22(ffffffea) = -1(ffff)\n  signed 8 -4(fffc) >> -21(ffffffeb) = -1(ffff)\n  signed 8 -4(fffc) >> -20(ffffffec) = -1(ffff)\n  signed 8 -4(fffc) >> -19(ffffffed) = -1(ffff)\n  signed 8 -4(fffc) >> -18(ffffffee) = -1(ffff)\n  signed 8 -4(fffc) >> -17(ffffffef) = -1(ffff)\n  signed 8 -4(fffc) >> -16(fffffff0) = -1(ffff)\n  signed 8 -4(fffc) >> -15(fffffff1) = -1(ffff)\n  signed 8 -4(fffc) >> -14(fffffff2) = -1(ffff)\n  signed 8 -4(fffc) >> -13(fffffff3) = -1(ffff)\n  signed 8 -4(fffc) >> -12(fffffff4) = -1(ffff)\n  signed 8 -4(fffc) >> -11(fffffff5) = -1(ffff)\n  signed 8 -4(fffc) >> -10(fffffff6) = -1(ffff)\n  signed 8 -4(fffc) >> -9(fffffff7) = -1(ffff)\n  signed 8 -4(fffc) >> -8(fffffff8) = -1(ffff)\n  signed 8 -4(fffc) >> -7(fffffff9) = -1(ffff)\n  signed 8 -4(fffc) >> -6(fffffffa) = -1(ffff)\n  signed 8 -4(fffc) >> -5(fffffffb) = -1(ffff)\n  signed 8 -4(fffc) >> -4(fffffffc) = -1(ffff)\n  signed 8 -4(fffc) >> -3(fffffffd) = -1(ffff)\n  signed 8 -4(fffc) >> -2(fffffffe) = -1(ffff)\n  signed 8 -4(fffc) >> -1(ffffffff) = -1(ffff)\n  signed 8 -4(fffc) >> 0(0) = -4(fffc)\n  signed 8 -4(fffc) >> 1(1) = -2(fffe)\n  signed 8 -4(fffc) >> 2(2) = -1(ffff)\n  signed 8 -4(fffc) >> 3(3) = -1(ffff)\n  signed 8 -4(fffc) >> 4(4) = -1(ffff)\n  signed 8 -4(fffc) >> 5(5) = -1(ffff)\n  signed 8 -4(fffc) >> 6(6) = -1(ffff)\n  signed 8 -4(fffc) >> 7(7) = -1(ffff)\n  signed 8 -4(fffc) >> 8(8) = -1(ffff)\n  signed 8 -4(fffc) >> 9(9) = -1(ffff)\n  signed 8 -4(fffc) >> 10(a) = -1(ffff)\n  signed 8 -4(fffc) >> 11(b) = -1(ffff)\n  signed 8 -4(fffc) >> 12(c) = -1(ffff)\n  signed 8 -4(fffc) >> 13(d) = -1(ffff)\n  signed 8 -4(fffc) >> 14(e) = -1(ffff)\n  signed 8 -4(fffc) >> 15(f) = -1(ffff)\n  signed 8 -4(fffc) >> 16(10) = -1(ffff)\n  signed 8 -4(fffc) >> 17(11) = -1(ffff)\n  signed 8 -4(fffc) >> 18(12) = -1(ffff)\n  signed 8 -4(fffc) >> 19(13) = -1(ffff)\n  signed 8 -4(fffc) >> 20(14) = -1(ffff)\n  signed 8 -4(fffc) >> 21(15) = -1(ffff)\n  signed 8 -4(fffc) >> 22(16) = -1(ffff)\n  signed 8 -4(fffc) >> 23(17) = -1(ffff)\n  signed 8 -4(fffc) >> 24(18) = -1(ffff)\n  signed 8 -4(fffc) >> 25(19) = -1(ffff)\n  signed 8 -4(fffc) >> 26(1a) = -1(ffff)\n  signed 8 -4(fffc) >> 27(1b) = -1(ffff)\n  signed 8 -4(fffc) >> 28(1c) = -1(ffff)\n  signed 8 -4(fffc) >> 29(1d) = -1(ffff)\n  signed 8 -4(fffc) >> 30(1e) = -1(ffff)\n  signed 8 -4(fffc) >> 31(1f) = -1(ffff)\n  signed 8 -4(fffc) >> 32(20) = -4(fffc)\n  signed 8 -4(fffc) >> 33(21) = -2(fffe)\n  signed 8 -4(fffc) >> 34(22) = -1(ffff)\n  signed 8 -4(fffc) >> 35(23) = -1(ffff)\n  signed 8 -4(fffc) >> 36(24) = -1(ffff)\n  signed 8 -4(fffc) >> 37(25) = -1(ffff)\n  signed 8 -4(fffc) >> 38(26) = -1(ffff)\n  signed 8 -4(fffc) >> 39(27) = -1(ffff)\n  signed 8 -4(fffc) >> 40(28) = -1(ffff)\n  signed 8 -4(fffc) >> 41(29) = -1(ffff)\n  signed 8 -4(fffc) >> 42(2a) = -1(ffff)\n  signed 8 -4(fffc) >> 43(2b) = -1(ffff)\n  signed 8 -4(fffc) >> 44(2c) = -1(ffff)\n  signed 8 -4(fffc) >> 45(2d) = -1(ffff)\n  signed 8 -4(fffc) >> 46(2e) = -1(ffff)\n  signed 8 -4(fffc) >> 47(2f) = -1(ffff)\n  signed 8 -4(fffc) >> 48(30) = -1(ffff)\n  signed 8 -4(fffc) >> 49(31) = -1(ffff)\n  signed 8 -4(fffc) >> 50(32) = -1(ffff)\n  signed 8 -4(fffc) >> 51(33) = -1(ffff)\n  signed 8 -4(fffc) >> 52(34) = -1(ffff)\n  signed 8 -4(fffc) >> 53(35) = -1(ffff)\n  signed 8 -4(fffc) >> 54(36) = -1(ffff)\n  signed 8 -4(fffc) >> 55(37) = -1(ffff)\n  signed 8 -4(fffc) >> 56(38) = -1(ffff)\n  signed 8 -4(fffc) >> 57(39) = -1(ffff)\n  signed 8 -4(fffc) >> 58(3a) = -1(ffff)\n  signed 8 -4(fffc) >> 59(3b) = -1(ffff)\n  signed 8 -4(fffc) >> 60(3c) = -1(ffff)\n  signed 8 -4(fffc) >> 61(3d) = -1(ffff)\n  signed 8 -4(fffc) >> 62(3e) = -1(ffff)\n  signed 8 -4(fffc) >> 63(3f) = -1(ffff)\n  signed 8 -4(fffc) >> 64(40) = -4(fffc)\n  signed 8 -4(fffc) >> 65(41) = -2(fffe)\n  signed 8 -4(fffc) >> 66(42) = -1(ffff)\n  signed 8 -4(fffc) >> 67(43) = -1(ffff)\n  signed 8 -4(fffc) >> 68(44) = -1(ffff)\n  signed 8 -4(fffc) >> 69(45) = -1(ffff)\n  signed 8 -4(fffc) >> 70(46) = -1(ffff)\n  signed 8 -4(fffc) >> 71(47) = -1(ffff)\n  signed 8 -4(fffc) >> 72(48) = -1(ffff)\n  signed 8 -4(fffc) >> 73(49) = -1(ffff)\n  signed 8 -4(fffc) >> 74(4a) = -1(ffff)\n  signed 8 -4(fffc) >> 75(4b) = -1(ffff)\n  signed 8 -4(fffc) >> 76(4c) = -1(ffff)\n  signed 8 -4(fffc) >> 77(4d) = -1(ffff)\n  signed 8 -4(fffc) >> 78(4e) = -1(ffff)\n  signed 8 -4(fffc) >> 79(4f) = -1(ffff)\n  signed 8 -4(fffc) >> 80(50) = -1(ffff)\n  signed 8 -4(fffc) >> 81(51) = -1(ffff)\n  signed 8 -4(fffc) >> 82(52) = -1(ffff)\n  signed 8 -4(fffc) >> 83(53) = -1(ffff)\n  signed 8 -4(fffc) >> 84(54) = -1(ffff)\n  signed 8 -4(fffc) >> 85(55) = -1(ffff)\n  signed 8 -4(fffc) >> 86(56) = -1(ffff)\n  signed 8 -4(fffc) >> 87(57) = -1(ffff)\n  signed 8 -4(fffc) >> 88(58) = -1(ffff)\n  signed 8 -4(fffc) >> 89(59) = -1(ffff)\n  signed 8 -4(fffc) >> 90(5a) = -1(ffff)\n  signed 8 -4(fffc) >> 91(5b) = -1(ffff)\n  signed 8 -4(fffc) >> 92(5c) = -1(ffff)\n  signed 8 -4(fffc) >> 93(5d) = -1(ffff)\n  signed 8 -4(fffc) >> 94(5e) = -1(ffff)\n  signed 8 -4(fffc) >> 95(5f) = -1(ffff)\n  signed 8 -4(fffc) >> 96(60) = -4(fffc)\n  signed 8 -4(fffc) >> 97(61) = -2(fffe)\n  signed 8 -4(fffc) >> 98(62) = -1(ffff)\n  signed 8 -4(fffc) >> 99(63) = -1(ffff)\n  signed 8 -4(fffc) >> 100(64) = -1(ffff)\n  signed 8 -4(fffc) >> 101(65) = -1(ffff)\n  signed 8 -4(fffc) >> 102(66) = -1(ffff)\n  signed 8 -4(fffc) >> 103(67) = -1(ffff)\n  signed 8 -4(fffc) >> 104(68) = -1(ffff)\n  signed 8 -4(fffc) >> 105(69) = -1(ffff)\n  signed 8 -4(fffc) >> 106(6a) = -1(ffff)\n  signed 8 -4(fffc) >> 107(6b) = -1(ffff)\n  signed 8 -4(fffc) >> 108(6c) = -1(ffff)\n  signed 8 -4(fffc) >> 109(6d) = -1(ffff)\n  signed 8 -4(fffc) >> 110(6e) = -1(ffff)\n  signed 8 -4(fffc) >> 111(6f) = -1(ffff)\n  signed 8 -4(fffc) >> 112(70) = -1(ffff)\n  signed 8 -4(fffc) >> 113(71) = -1(ffff)\n  signed 8 -4(fffc) >> 114(72) = -1(ffff)\n  signed 8 -4(fffc) >> 115(73) = -1(ffff)\n  signed 8 -4(fffc) >> 116(74) = -1(ffff)\n  signed 8 -4(fffc) >> 117(75) = -1(ffff)\n  signed 8 -4(fffc) >> 118(76) = -1(ffff)\n  signed 8 -4(fffc) >> 119(77) = -1(ffff)\n  signed 8 -4(fffc) >> 120(78) = -1(ffff)\n  signed 8 -4(fffc) >> 121(79) = -1(ffff)\n  signed 8 -4(fffc) >> 122(7a) = -1(ffff)\n  signed 8 -4(fffc) >> 123(7b) = -1(ffff)\n  signed 8 -4(fffc) >> 124(7c) = -1(ffff)\n  signed 8 -4(fffc) >> 125(7d) = -1(ffff)\n  signed 8 -4(fffc) >> 126(7e) = -1(ffff)\n  signed 8 -4(fffc) >> 127(7f) = -1(ffff)\n  signed 8 -3(fffd) >> -128(ffffff80) = -3(fffd)\n  signed 8 -3(fffd) >> -127(ffffff81) = -2(fffe)\n  signed 8 -3(fffd) >> -126(ffffff82) = -1(ffff)\n  signed 8 -3(fffd) >> -125(ffffff83) = -1(ffff)\n  signed 8 -3(fffd) >> -124(ffffff84) = -1(ffff)\n  signed 8 -3(fffd) >> -123(ffffff85) = -1(ffff)\n  signed 8 -3(fffd) >> -122(ffffff86) = -1(ffff)\n  signed 8 -3(fffd) >> -121(ffffff87) = -1(ffff)\n  signed 8 -3(fffd) >> -120(ffffff88) = -1(ffff)\n  signed 8 -3(fffd) >> -119(ffffff89) = -1(ffff)\n  signed 8 -3(fffd) >> -118(ffffff8a) = -1(ffff)\n  signed 8 -3(fffd) >> -117(ffffff8b) = -1(ffff)\n  signed 8 -3(fffd) >> -116(ffffff8c) = -1(ffff)\n  signed 8 -3(fffd) >> -115(ffffff8d) = -1(ffff)\n  signed 8 -3(fffd) >> -114(ffffff8e) = -1(ffff)\n  signed 8 -3(fffd) >> -113(ffffff8f) = -1(ffff)\n  signed 8 -3(fffd) >> -112(ffffff90) = -1(ffff)\n  signed 8 -3(fffd) >> -111(ffffff91) = -1(ffff)\n  signed 8 -3(fffd) >> -110(ffffff92) = -1(ffff)\n  signed 8 -3(fffd) >> -109(ffffff93) = -1(ffff)\n  signed 8 -3(fffd) >> -108(ffffff94) = -1(ffff)\n  signed 8 -3(fffd) >> -107(ffffff95) = -1(ffff)\n  signed 8 -3(fffd) >> -106(ffffff96) = -1(ffff)\n  signed 8 -3(fffd) >> -105(ffffff97) = -1(ffff)\n  signed 8 -3(fffd) >> -104(ffffff98) = -1(ffff)\n  signed 8 -3(fffd) >> -103(ffffff99) = -1(ffff)\n  signed 8 -3(fffd) >> -102(ffffff9a) = -1(ffff)\n  signed 8 -3(fffd) >> -101(ffffff9b) = -1(ffff)\n  signed 8 -3(fffd) >> -100(ffffff9c) = -1(ffff)\n  signed 8 -3(fffd) >> -99(ffffff9d) = -1(ffff)\n  signed 8 -3(fffd) >> -98(ffffff9e) = -1(ffff)\n  signed 8 -3(fffd) >> -97(ffffff9f) = -1(ffff)\n  signed 8 -3(fffd) >> -96(ffffffa0) = -3(fffd)\n  signed 8 -3(fffd) >> -95(ffffffa1) = -2(fffe)\n  signed 8 -3(fffd) >> -94(ffffffa2) = -1(ffff)\n  signed 8 -3(fffd) >> -93(ffffffa3) = -1(ffff)\n  signed 8 -3(fffd) >> -92(ffffffa4) = -1(ffff)\n  signed 8 -3(fffd) >> -91(ffffffa5) = -1(ffff)\n  signed 8 -3(fffd) >> -90(ffffffa6) = -1(ffff)\n  signed 8 -3(fffd) >> -89(ffffffa7) = -1(ffff)\n  signed 8 -3(fffd) >> -88(ffffffa8) = -1(ffff)\n  signed 8 -3(fffd) >> -87(ffffffa9) = -1(ffff)\n  signed 8 -3(fffd) >> -86(ffffffaa) = -1(ffff)\n  signed 8 -3(fffd) >> -85(ffffffab) = -1(ffff)\n  signed 8 -3(fffd) >> -84(ffffffac) = -1(ffff)\n  signed 8 -3(fffd) >> -83(ffffffad) = -1(ffff)\n  signed 8 -3(fffd) >> -82(ffffffae) = -1(ffff)\n  signed 8 -3(fffd) >> -81(ffffffaf) = -1(ffff)\n  signed 8 -3(fffd) >> -80(ffffffb0) = -1(ffff)\n  signed 8 -3(fffd) >> -79(ffffffb1) = -1(ffff)\n  signed 8 -3(fffd) >> -78(ffffffb2) = -1(ffff)\n  signed 8 -3(fffd) >> -77(ffffffb3) = -1(ffff)\n  signed 8 -3(fffd) >> -76(ffffffb4) = -1(ffff)\n  signed 8 -3(fffd) >> -75(ffffffb5) = -1(ffff)\n  signed 8 -3(fffd) >> -74(ffffffb6) = -1(ffff)\n  signed 8 -3(fffd) >> -73(ffffffb7) = -1(ffff)\n  signed 8 -3(fffd) >> -72(ffffffb8) = -1(ffff)\n  signed 8 -3(fffd) >> -71(ffffffb9) = -1(ffff)\n  signed 8 -3(fffd) >> -70(ffffffba) = -1(ffff)\n  signed 8 -3(fffd) >> -69(ffffffbb) = -1(ffff)\n  signed 8 -3(fffd) >> -68(ffffffbc) = -1(ffff)\n  signed 8 -3(fffd) >> -67(ffffffbd) = -1(ffff)\n  signed 8 -3(fffd) >> -66(ffffffbe) = -1(ffff)\n  signed 8 -3(fffd) >> -65(ffffffbf) = -1(ffff)\n  signed 8 -3(fffd) >> -64(ffffffc0) = -3(fffd)\n  signed 8 -3(fffd) >> -63(ffffffc1) = -2(fffe)\n  signed 8 -3(fffd) >> -62(ffffffc2) = -1(ffff)\n  signed 8 -3(fffd) >> -61(ffffffc3) = -1(ffff)\n  signed 8 -3(fffd) >> -60(ffffffc4) = -1(ffff)\n  signed 8 -3(fffd) >> -59(ffffffc5) = -1(ffff)\n  signed 8 -3(fffd) >> -58(ffffffc6) = -1(ffff)\n  signed 8 -3(fffd) >> -57(ffffffc7) = -1(ffff)\n  signed 8 -3(fffd) >> -56(ffffffc8) = -1(ffff)\n  signed 8 -3(fffd) >> -55(ffffffc9) = -1(ffff)\n  signed 8 -3(fffd) >> -54(ffffffca) = -1(ffff)\n  signed 8 -3(fffd) >> -53(ffffffcb) = -1(ffff)\n  signed 8 -3(fffd) >> -52(ffffffcc) = -1(ffff)\n  signed 8 -3(fffd) >> -51(ffffffcd) = -1(ffff)\n  signed 8 -3(fffd) >> -50(ffffffce) = -1(ffff)\n  signed 8 -3(fffd) >> -49(ffffffcf) = -1(ffff)\n  signed 8 -3(fffd) >> -48(ffffffd0) = -1(ffff)\n  signed 8 -3(fffd) >> -47(ffffffd1) = -1(ffff)\n  signed 8 -3(fffd) >> -46(ffffffd2) = -1(ffff)\n  signed 8 -3(fffd) >> -45(ffffffd3) = -1(ffff)\n  signed 8 -3(fffd) >> -44(ffffffd4) = -1(ffff)\n  signed 8 -3(fffd) >> -43(ffffffd5) = -1(ffff)\n  signed 8 -3(fffd) >> -42(ffffffd6) = -1(ffff)\n  signed 8 -3(fffd) >> -41(ffffffd7) = -1(ffff)\n  signed 8 -3(fffd) >> -40(ffffffd8) = -1(ffff)\n  signed 8 -3(fffd) >> -39(ffffffd9) = -1(ffff)\n  signed 8 -3(fffd) >> -38(ffffffda) = -1(ffff)\n  signed 8 -3(fffd) >> -37(ffffffdb) = -1(ffff)\n  signed 8 -3(fffd) >> -36(ffffffdc) = -1(ffff)\n  signed 8 -3(fffd) >> -35(ffffffdd) = -1(ffff)\n  signed 8 -3(fffd) >> -34(ffffffde) = -1(ffff)\n  signed 8 -3(fffd) >> -33(ffffffdf) = -1(ffff)\n  signed 8 -3(fffd) >> -32(ffffffe0) = -3(fffd)\n  signed 8 -3(fffd) >> -31(ffffffe1) = -2(fffe)\n  signed 8 -3(fffd) >> -30(ffffffe2) = -1(ffff)\n  signed 8 -3(fffd) >> -29(ffffffe3) = -1(ffff)\n  signed 8 -3(fffd) >> -28(ffffffe4) = -1(ffff)\n  signed 8 -3(fffd) >> -27(ffffffe5) = -1(ffff)\n  signed 8 -3(fffd) >> -26(ffffffe6) = -1(ffff)\n  signed 8 -3(fffd) >> -25(ffffffe7) = -1(ffff)\n  signed 8 -3(fffd) >> -24(ffffffe8) = -1(ffff)\n  signed 8 -3(fffd) >> -23(ffffffe9) = -1(ffff)\n  signed 8 -3(fffd) >> -22(ffffffea) = -1(ffff)\n  signed 8 -3(fffd) >> -21(ffffffeb) = -1(ffff)\n  signed 8 -3(fffd) >> -20(ffffffec) = -1(ffff)\n  signed 8 -3(fffd) >> -19(ffffffed) = -1(ffff)\n  signed 8 -3(fffd) >> -18(ffffffee) = -1(ffff)\n  signed 8 -3(fffd) >> -17(ffffffef) = -1(ffff)\n  signed 8 -3(fffd) >> -16(fffffff0) = -1(ffff)\n  signed 8 -3(fffd) >> -15(fffffff1) = -1(ffff)\n  signed 8 -3(fffd) >> -14(fffffff2) = -1(ffff)\n  signed 8 -3(fffd) >> -13(fffffff3) = -1(ffff)\n  signed 8 -3(fffd) >> -12(fffffff4) = -1(ffff)\n  signed 8 -3(fffd) >> -11(fffffff5) = -1(ffff)\n  signed 8 -3(fffd) >> -10(fffffff6) = -1(ffff)\n  signed 8 -3(fffd) >> -9(fffffff7) = -1(ffff)\n  signed 8 -3(fffd) >> -8(fffffff8) = -1(ffff)\n  signed 8 -3(fffd) >> -7(fffffff9) = -1(ffff)\n  signed 8 -3(fffd) >> -6(fffffffa) = -1(ffff)\n  signed 8 -3(fffd) >> -5(fffffffb) = -1(ffff)\n  signed 8 -3(fffd) >> -4(fffffffc) = -1(ffff)\n  signed 8 -3(fffd) >> -3(fffffffd) = -1(ffff)\n  signed 8 -3(fffd) >> -2(fffffffe) = -1(ffff)\n  signed 8 -3(fffd) >> -1(ffffffff) = -1(ffff)\n  signed 8 -3(fffd) >> 0(0) = -3(fffd)\n  signed 8 -3(fffd) >> 1(1) = -2(fffe)\n  signed 8 -3(fffd) >> 2(2) = -1(ffff)\n  signed 8 -3(fffd) >> 3(3) = -1(ffff)\n  signed 8 -3(fffd) >> 4(4) = -1(ffff)\n  signed 8 -3(fffd) >> 5(5) = -1(ffff)\n  signed 8 -3(fffd) >> 6(6) = -1(ffff)\n  signed 8 -3(fffd) >> 7(7) = -1(ffff)\n  signed 8 -3(fffd) >> 8(8) = -1(ffff)\n  signed 8 -3(fffd) >> 9(9) = -1(ffff)\n  signed 8 -3(fffd) >> 10(a) = -1(ffff)\n  signed 8 -3(fffd) >> 11(b) = -1(ffff)\n  signed 8 -3(fffd) >> 12(c) = -1(ffff)\n  signed 8 -3(fffd) >> 13(d) = -1(ffff)\n  signed 8 -3(fffd) >> 14(e) = -1(ffff)\n  signed 8 -3(fffd) >> 15(f) = -1(ffff)\n  signed 8 -3(fffd) >> 16(10) = -1(ffff)\n  signed 8 -3(fffd) >> 17(11) = -1(ffff)\n  signed 8 -3(fffd) >> 18(12) = -1(ffff)\n  signed 8 -3(fffd) >> 19(13) = -1(ffff)\n  signed 8 -3(fffd) >> 20(14) = -1(ffff)\n  signed 8 -3(fffd) >> 21(15) = -1(ffff)\n  signed 8 -3(fffd) >> 22(16) = -1(ffff)\n  signed 8 -3(fffd) >> 23(17) = -1(ffff)\n  signed 8 -3(fffd) >> 24(18) = -1(ffff)\n  signed 8 -3(fffd) >> 25(19) = -1(ffff)\n  signed 8 -3(fffd) >> 26(1a) = -1(ffff)\n  signed 8 -3(fffd) >> 27(1b) = -1(ffff)\n  signed 8 -3(fffd) >> 28(1c) = -1(ffff)\n  signed 8 -3(fffd) >> 29(1d) = -1(ffff)\n  signed 8 -3(fffd) >> 30(1e) = -1(ffff)\n  signed 8 -3(fffd) >> 31(1f) = -1(ffff)\n  signed 8 -3(fffd) >> 32(20) = -3(fffd)\n  signed 8 -3(fffd) >> 33(21) = -2(fffe)\n  signed 8 -3(fffd) >> 34(22) = -1(ffff)\n  signed 8 -3(fffd) >> 35(23) = -1(ffff)\n  signed 8 -3(fffd) >> 36(24) = -1(ffff)\n  signed 8 -3(fffd) >> 37(25) = -1(ffff)\n  signed 8 -3(fffd) >> 38(26) = -1(ffff)\n  signed 8 -3(fffd) >> 39(27) = -1(ffff)\n  signed 8 -3(fffd) >> 40(28) = -1(ffff)\n  signed 8 -3(fffd) >> 41(29) = -1(ffff)\n  signed 8 -3(fffd) >> 42(2a) = -1(ffff)\n  signed 8 -3(fffd) >> 43(2b) = -1(ffff)\n  signed 8 -3(fffd) >> 44(2c) = -1(ffff)\n  signed 8 -3(fffd) >> 45(2d) = -1(ffff)\n  signed 8 -3(fffd) >> 46(2e) = -1(ffff)\n  signed 8 -3(fffd) >> 47(2f) = -1(ffff)\n  signed 8 -3(fffd) >> 48(30) = -1(ffff)\n  signed 8 -3(fffd) >> 49(31) = -1(ffff)\n  signed 8 -3(fffd) >> 50(32) = -1(ffff)\n  signed 8 -3(fffd) >> 51(33) = -1(ffff)\n  signed 8 -3(fffd) >> 52(34) = -1(ffff)\n  signed 8 -3(fffd) >> 53(35) = -1(ffff)\n  signed 8 -3(fffd) >> 54(36) = -1(ffff)\n  signed 8 -3(fffd) >> 55(37) = -1(ffff)\n  signed 8 -3(fffd) >> 56(38) = -1(ffff)\n  signed 8 -3(fffd) >> 57(39) = -1(ffff)\n  signed 8 -3(fffd) >> 58(3a) = -1(ffff)\n  signed 8 -3(fffd) >> 59(3b) = -1(ffff)\n  signed 8 -3(fffd) >> 60(3c) = -1(ffff)\n  signed 8 -3(fffd) >> 61(3d) = -1(ffff)\n  signed 8 -3(fffd) >> 62(3e) = -1(ffff)\n  signed 8 -3(fffd) >> 63(3f) = -1(ffff)\n  signed 8 -3(fffd) >> 64(40) = -3(fffd)\n  signed 8 -3(fffd) >> 65(41) = -2(fffe)\n  signed 8 -3(fffd) >> 66(42) = -1(ffff)\n  signed 8 -3(fffd) >> 67(43) = -1(ffff)\n  signed 8 -3(fffd) >> 68(44) = -1(ffff)\n  signed 8 -3(fffd) >> 69(45) = -1(ffff)\n  signed 8 -3(fffd) >> 70(46) = -1(ffff)\n  signed 8 -3(fffd) >> 71(47) = -1(ffff)\n  signed 8 -3(fffd) >> 72(48) = -1(ffff)\n  signed 8 -3(fffd) >> 73(49) = -1(ffff)\n  signed 8 -3(fffd) >> 74(4a) = -1(ffff)\n  signed 8 -3(fffd) >> 75(4b) = -1(ffff)\n  signed 8 -3(fffd) >> 76(4c) = -1(ffff)\n  signed 8 -3(fffd) >> 77(4d) = -1(ffff)\n  signed 8 -3(fffd) >> 78(4e) = -1(ffff)\n  signed 8 -3(fffd) >> 79(4f) = -1(ffff)\n  signed 8 -3(fffd) >> 80(50) = -1(ffff)\n  signed 8 -3(fffd) >> 81(51) = -1(ffff)\n  signed 8 -3(fffd) >> 82(52) = -1(ffff)\n  signed 8 -3(fffd) >> 83(53) = -1(ffff)\n  signed 8 -3(fffd) >> 84(54) = -1(ffff)\n  signed 8 -3(fffd) >> 85(55) = -1(ffff)\n  signed 8 -3(fffd) >> 86(56) = -1(ffff)\n  signed 8 -3(fffd) >> 87(57) = -1(ffff)\n  signed 8 -3(fffd) >> 88(58) = -1(ffff)\n  signed 8 -3(fffd) >> 89(59) = -1(ffff)\n  signed 8 -3(fffd) >> 90(5a) = -1(ffff)\n  signed 8 -3(fffd) >> 91(5b) = -1(ffff)\n  signed 8 -3(fffd) >> 92(5c) = -1(ffff)\n  signed 8 -3(fffd) >> 93(5d) = -1(ffff)\n  signed 8 -3(fffd) >> 94(5e) = -1(ffff)\n  signed 8 -3(fffd) >> 95(5f) = -1(ffff)\n  signed 8 -3(fffd) >> 96(60) = -3(fffd)\n  signed 8 -3(fffd) >> 97(61) = -2(fffe)\n  signed 8 -3(fffd) >> 98(62) = -1(ffff)\n  signed 8 -3(fffd) >> 99(63) = -1(ffff)\n  signed 8 -3(fffd) >> 100(64) = -1(ffff)\n  signed 8 -3(fffd) >> 101(65) = -1(ffff)\n  signed 8 -3(fffd) >> 102(66) = -1(ffff)\n  signed 8 -3(fffd) >> 103(67) = -1(ffff)\n  signed 8 -3(fffd) >> 104(68) = -1(ffff)\n  signed 8 -3(fffd) >> 105(69) = -1(ffff)\n  signed 8 -3(fffd) >> 106(6a) = -1(ffff)\n  signed 8 -3(fffd) >> 107(6b) = -1(ffff)\n  signed 8 -3(fffd) >> 108(6c) = -1(ffff)\n  signed 8 -3(fffd) >> 109(6d) = -1(ffff)\n  signed 8 -3(fffd) >> 110(6e) = -1(ffff)\n  signed 8 -3(fffd) >> 111(6f) = -1(ffff)\n  signed 8 -3(fffd) >> 112(70) = -1(ffff)\n  signed 8 -3(fffd) >> 113(71) = -1(ffff)\n  signed 8 -3(fffd) >> 114(72) = -1(ffff)\n  signed 8 -3(fffd) >> 115(73) = -1(ffff)\n  signed 8 -3(fffd) >> 116(74) = -1(ffff)\n  signed 8 -3(fffd) >> 117(75) = -1(ffff)\n  signed 8 -3(fffd) >> 118(76) = -1(ffff)\n  signed 8 -3(fffd) >> 119(77) = -1(ffff)\n  signed 8 -3(fffd) >> 120(78) = -1(ffff)\n  signed 8 -3(fffd) >> 121(79) = -1(ffff)\n  signed 8 -3(fffd) >> 122(7a) = -1(ffff)\n  signed 8 -3(fffd) >> 123(7b) = -1(ffff)\n  signed 8 -3(fffd) >> 124(7c) = -1(ffff)\n  signed 8 -3(fffd) >> 125(7d) = -1(ffff)\n  signed 8 -3(fffd) >> 126(7e) = -1(ffff)\n  signed 8 -3(fffd) >> 127(7f) = -1(ffff)\n  signed 8 -2(fffe) >> -128(ffffff80) = -2(fffe)\n  signed 8 -2(fffe) >> -127(ffffff81) = -1(ffff)\n  signed 8 -2(fffe) >> -126(ffffff82) = -1(ffff)\n  signed 8 -2(fffe) >> -125(ffffff83) = -1(ffff)\n  signed 8 -2(fffe) >> -124(ffffff84) = -1(ffff)\n  signed 8 -2(fffe) >> -123(ffffff85) = -1(ffff)\n  signed 8 -2(fffe) >> -122(ffffff86) = -1(ffff)\n  signed 8 -2(fffe) >> -121(ffffff87) = -1(ffff)\n  signed 8 -2(fffe) >> -120(ffffff88) = -1(ffff)\n  signed 8 -2(fffe) >> -119(ffffff89) = -1(ffff)\n  signed 8 -2(fffe) >> -118(ffffff8a) = -1(ffff)\n  signed 8 -2(fffe) >> -117(ffffff8b) = -1(ffff)\n  signed 8 -2(fffe) >> -116(ffffff8c) = -1(ffff)\n  signed 8 -2(fffe) >> -115(ffffff8d) = -1(ffff)\n  signed 8 -2(fffe) >> -114(ffffff8e) = -1(ffff)\n  signed 8 -2(fffe) >> -113(ffffff8f) = -1(ffff)\n  signed 8 -2(fffe) >> -112(ffffff90) = -1(ffff)\n  signed 8 -2(fffe) >> -111(ffffff91) = -1(ffff)\n  signed 8 -2(fffe) >> -110(ffffff92) = -1(ffff)\n  signed 8 -2(fffe) >> -109(ffffff93) = -1(ffff)\n  signed 8 -2(fffe) >> -108(ffffff94) = -1(ffff)\n  signed 8 -2(fffe) >> -107(ffffff95) = -1(ffff)\n  signed 8 -2(fffe) >> -106(ffffff96) = -1(ffff)\n  signed 8 -2(fffe) >> -105(ffffff97) = -1(ffff)\n  signed 8 -2(fffe) >> -104(ffffff98) = -1(ffff)\n  signed 8 -2(fffe) >> -103(ffffff99) = -1(ffff)\n  signed 8 -2(fffe) >> -102(ffffff9a) = -1(ffff)\n  signed 8 -2(fffe) >> -101(ffffff9b) = -1(ffff)\n  signed 8 -2(fffe) >> -100(ffffff9c) = -1(ffff)\n  signed 8 -2(fffe) >> -99(ffffff9d) = -1(ffff)\n  signed 8 -2(fffe) >> -98(ffffff9e) = -1(ffff)\n  signed 8 -2(fffe) >> -97(ffffff9f) = -1(ffff)\n  signed 8 -2(fffe) >> -96(ffffffa0) = -2(fffe)\n  signed 8 -2(fffe) >> -95(ffffffa1) = -1(ffff)\n  signed 8 -2(fffe) >> -94(ffffffa2) = -1(ffff)\n  signed 8 -2(fffe) >> -93(ffffffa3) = -1(ffff)\n  signed 8 -2(fffe) >> -92(ffffffa4) = -1(ffff)\n  signed 8 -2(fffe) >> -91(ffffffa5) = -1(ffff)\n  signed 8 -2(fffe) >> -90(ffffffa6) = -1(ffff)\n  signed 8 -2(fffe) >> -89(ffffffa7) = -1(ffff)\n  signed 8 -2(fffe) >> -88(ffffffa8) = -1(ffff)\n  signed 8 -2(fffe) >> -87(ffffffa9) = -1(ffff)\n  signed 8 -2(fffe) >> -86(ffffffaa) = -1(ffff)\n  signed 8 -2(fffe) >> -85(ffffffab) = -1(ffff)\n  signed 8 -2(fffe) >> -84(ffffffac) = -1(ffff)\n  signed 8 -2(fffe) >> -83(ffffffad) = -1(ffff)\n  signed 8 -2(fffe) >> -82(ffffffae) = -1(ffff)\n  signed 8 -2(fffe) >> -81(ffffffaf) = -1(ffff)\n  signed 8 -2(fffe) >> -80(ffffffb0) = -1(ffff)\n  signed 8 -2(fffe) >> -79(ffffffb1) = -1(ffff)\n  signed 8 -2(fffe) >> -78(ffffffb2) = -1(ffff)\n  signed 8 -2(fffe) >> -77(ffffffb3) = -1(ffff)\n  signed 8 -2(fffe) >> -76(ffffffb4) = -1(ffff)\n  signed 8 -2(fffe) >> -75(ffffffb5) = -1(ffff)\n  signed 8 -2(fffe) >> -74(ffffffb6) = -1(ffff)\n  signed 8 -2(fffe) >> -73(ffffffb7) = -1(ffff)\n  signed 8 -2(fffe) >> -72(ffffffb8) = -1(ffff)\n  signed 8 -2(fffe) >> -71(ffffffb9) = -1(ffff)\n  signed 8 -2(fffe) >> -70(ffffffba) = -1(ffff)\n  signed 8 -2(fffe) >> -69(ffffffbb) = -1(ffff)\n  signed 8 -2(fffe) >> -68(ffffffbc) = -1(ffff)\n  signed 8 -2(fffe) >> -67(ffffffbd) = -1(ffff)\n  signed 8 -2(fffe) >> -66(ffffffbe) = -1(ffff)\n  signed 8 -2(fffe) >> -65(ffffffbf) = -1(ffff)\n  signed 8 -2(fffe) >> -64(ffffffc0) = -2(fffe)\n  signed 8 -2(fffe) >> -63(ffffffc1) = -1(ffff)\n  signed 8 -2(fffe) >> -62(ffffffc2) = -1(ffff)\n  signed 8 -2(fffe) >> -61(ffffffc3) = -1(ffff)\n  signed 8 -2(fffe) >> -60(ffffffc4) = -1(ffff)\n  signed 8 -2(fffe) >> -59(ffffffc5) = -1(ffff)\n  signed 8 -2(fffe) >> -58(ffffffc6) = -1(ffff)\n  signed 8 -2(fffe) >> -57(ffffffc7) = -1(ffff)\n  signed 8 -2(fffe) >> -56(ffffffc8) = -1(ffff)\n  signed 8 -2(fffe) >> -55(ffffffc9) = -1(ffff)\n  signed 8 -2(fffe) >> -54(ffffffca) = -1(ffff)\n  signed 8 -2(fffe) >> -53(ffffffcb) = -1(ffff)\n  signed 8 -2(fffe) >> -52(ffffffcc) = -1(ffff)\n  signed 8 -2(fffe) >> -51(ffffffcd) = -1(ffff)\n  signed 8 -2(fffe) >> -50(ffffffce) = -1(ffff)\n  signed 8 -2(fffe) >> -49(ffffffcf) = -1(ffff)\n  signed 8 -2(fffe) >> -48(ffffffd0) = -1(ffff)\n  signed 8 -2(fffe) >> -47(ffffffd1) = -1(ffff)\n  signed 8 -2(fffe) >> -46(ffffffd2) = -1(ffff)\n  signed 8 -2(fffe) >> -45(ffffffd3) = -1(ffff)\n  signed 8 -2(fffe) >> -44(ffffffd4) = -1(ffff)\n  signed 8 -2(fffe) >> -43(ffffffd5) = -1(ffff)\n  signed 8 -2(fffe) >> -42(ffffffd6) = -1(ffff)\n  signed 8 -2(fffe) >> -41(ffffffd7) = -1(ffff)\n  signed 8 -2(fffe) >> -40(ffffffd8) = -1(ffff)\n  signed 8 -2(fffe) >> -39(ffffffd9) = -1(ffff)\n  signed 8 -2(fffe) >> -38(ffffffda) = -1(ffff)\n  signed 8 -2(fffe) >> -37(ffffffdb) = -1(ffff)\n  signed 8 -2(fffe) >> -36(ffffffdc) = -1(ffff)\n  signed 8 -2(fffe) >> -35(ffffffdd) = -1(ffff)\n  signed 8 -2(fffe) >> -34(ffffffde) = -1(ffff)\n  signed 8 -2(fffe) >> -33(ffffffdf) = -1(ffff)\n  signed 8 -2(fffe) >> -32(ffffffe0) = -2(fffe)\n  signed 8 -2(fffe) >> -31(ffffffe1) = -1(ffff)\n  signed 8 -2(fffe) >> -30(ffffffe2) = -1(ffff)\n  signed 8 -2(fffe) >> -29(ffffffe3) = -1(ffff)\n  signed 8 -2(fffe) >> -28(ffffffe4) = -1(ffff)\n  signed 8 -2(fffe) >> -27(ffffffe5) = -1(ffff)\n  signed 8 -2(fffe) >> -26(ffffffe6) = -1(ffff)\n  signed 8 -2(fffe) >> -25(ffffffe7) = -1(ffff)\n  signed 8 -2(fffe) >> -24(ffffffe8) = -1(ffff)\n  signed 8 -2(fffe) >> -23(ffffffe9) = -1(ffff)\n  signed 8 -2(fffe) >> -22(ffffffea) = -1(ffff)\n  signed 8 -2(fffe) >> -21(ffffffeb) = -1(ffff)\n  signed 8 -2(fffe) >> -20(ffffffec) = -1(ffff)\n  signed 8 -2(fffe) >> -19(ffffffed) = -1(ffff)\n  signed 8 -2(fffe) >> -18(ffffffee) = -1(ffff)\n  signed 8 -2(fffe) >> -17(ffffffef) = -1(ffff)\n  signed 8 -2(fffe) >> -16(fffffff0) = -1(ffff)\n  signed 8 -2(fffe) >> -15(fffffff1) = -1(ffff)\n  signed 8 -2(fffe) >> -14(fffffff2) = -1(ffff)\n  signed 8 -2(fffe) >> -13(fffffff3) = -1(ffff)\n  signed 8 -2(fffe) >> -12(fffffff4) = -1(ffff)\n  signed 8 -2(fffe) >> -11(fffffff5) = -1(ffff)\n  signed 8 -2(fffe) >> -10(fffffff6) = -1(ffff)\n  signed 8 -2(fffe) >> -9(fffffff7) = -1(ffff)\n  signed 8 -2(fffe) >> -8(fffffff8) = -1(ffff)\n  signed 8 -2(fffe) >> -7(fffffff9) = -1(ffff)\n  signed 8 -2(fffe) >> -6(fffffffa) = -1(ffff)\n  signed 8 -2(fffe) >> -5(fffffffb) = -1(ffff)\n  signed 8 -2(fffe) >> -4(fffffffc) = -1(ffff)\n  signed 8 -2(fffe) >> -3(fffffffd) = -1(ffff)\n  signed 8 -2(fffe) >> -2(fffffffe) = -1(ffff)\n  signed 8 -2(fffe) >> -1(ffffffff) = -1(ffff)\n  signed 8 -2(fffe) >> 0(0) = -2(fffe)\n  signed 8 -2(fffe) >> 1(1) = -1(ffff)\n  signed 8 -2(fffe) >> 2(2) = -1(ffff)\n  signed 8 -2(fffe) >> 3(3) = -1(ffff)\n  signed 8 -2(fffe) >> 4(4) = -1(ffff)\n  signed 8 -2(fffe) >> 5(5) = -1(ffff)\n  signed 8 -2(fffe) >> 6(6) = -1(ffff)\n  signed 8 -2(fffe) >> 7(7) = -1(ffff)\n  signed 8 -2(fffe) >> 8(8) = -1(ffff)\n  signed 8 -2(fffe) >> 9(9) = -1(ffff)\n  signed 8 -2(fffe) >> 10(a) = -1(ffff)\n  signed 8 -2(fffe) >> 11(b) = -1(ffff)\n  signed 8 -2(fffe) >> 12(c) = -1(ffff)\n  signed 8 -2(fffe) >> 13(d) = -1(ffff)\n  signed 8 -2(fffe) >> 14(e) = -1(ffff)\n  signed 8 -2(fffe) >> 15(f) = -1(ffff)\n  signed 8 -2(fffe) >> 16(10) = -1(ffff)\n  signed 8 -2(fffe) >> 17(11) = -1(ffff)\n  signed 8 -2(fffe) >> 18(12) = -1(ffff)\n  signed 8 -2(fffe) >> 19(13) = -1(ffff)\n  signed 8 -2(fffe) >> 20(14) = -1(ffff)\n  signed 8 -2(fffe) >> 21(15) = -1(ffff)\n  signed 8 -2(fffe) >> 22(16) = -1(ffff)\n  signed 8 -2(fffe) >> 23(17) = -1(ffff)\n  signed 8 -2(fffe) >> 24(18) = -1(ffff)\n  signed 8 -2(fffe) >> 25(19) = -1(ffff)\n  signed 8 -2(fffe) >> 26(1a) = -1(ffff)\n  signed 8 -2(fffe) >> 27(1b) = -1(ffff)\n  signed 8 -2(fffe) >> 28(1c) = -1(ffff)\n  signed 8 -2(fffe) >> 29(1d) = -1(ffff)\n  signed 8 -2(fffe) >> 30(1e) = -1(ffff)\n  signed 8 -2(fffe) >> 31(1f) = -1(ffff)\n  signed 8 -2(fffe) >> 32(20) = -2(fffe)\n  signed 8 -2(fffe) >> 33(21) = -1(ffff)\n  signed 8 -2(fffe) >> 34(22) = -1(ffff)\n  signed 8 -2(fffe) >> 35(23) = -1(ffff)\n  signed 8 -2(fffe) >> 36(24) = -1(ffff)\n  signed 8 -2(fffe) >> 37(25) = -1(ffff)\n  signed 8 -2(fffe) >> 38(26) = -1(ffff)\n  signed 8 -2(fffe) >> 39(27) = -1(ffff)\n  signed 8 -2(fffe) >> 40(28) = -1(ffff)\n  signed 8 -2(fffe) >> 41(29) = -1(ffff)\n  signed 8 -2(fffe) >> 42(2a) = -1(ffff)\n  signed 8 -2(fffe) >> 43(2b) = -1(ffff)\n  signed 8 -2(fffe) >> 44(2c) = -1(ffff)\n  signed 8 -2(fffe) >> 45(2d) = -1(ffff)\n  signed 8 -2(fffe) >> 46(2e) = -1(ffff)\n  signed 8 -2(fffe) >> 47(2f) = -1(ffff)\n  signed 8 -2(fffe) >> 48(30) = -1(ffff)\n  signed 8 -2(fffe) >> 49(31) = -1(ffff)\n  signed 8 -2(fffe) >> 50(32) = -1(ffff)\n  signed 8 -2(fffe) >> 51(33) = -1(ffff)\n  signed 8 -2(fffe) >> 52(34) = -1(ffff)\n  signed 8 -2(fffe) >> 53(35) = -1(ffff)\n  signed 8 -2(fffe) >> 54(36) = -1(ffff)\n  signed 8 -2(fffe) >> 55(37) = -1(ffff)\n  signed 8 -2(fffe) >> 56(38) = -1(ffff)\n  signed 8 -2(fffe) >> 57(39) = -1(ffff)\n  signed 8 -2(fffe) >> 58(3a) = -1(ffff)\n  signed 8 -2(fffe) >> 59(3b) = -1(ffff)\n  signed 8 -2(fffe) >> 60(3c) = -1(ffff)\n  signed 8 -2(fffe) >> 61(3d) = -1(ffff)\n  signed 8 -2(fffe) >> 62(3e) = -1(ffff)\n  signed 8 -2(fffe) >> 63(3f) = -1(ffff)\n  signed 8 -2(fffe) >> 64(40) = -2(fffe)\n  signed 8 -2(fffe) >> 65(41) = -1(ffff)\n  signed 8 -2(fffe) >> 66(42) = -1(ffff)\n  signed 8 -2(fffe) >> 67(43) = -1(ffff)\n  signed 8 -2(fffe) >> 68(44) = -1(ffff)\n  signed 8 -2(fffe) >> 69(45) = -1(ffff)\n  signed 8 -2(fffe) >> 70(46) = -1(ffff)\n  signed 8 -2(fffe) >> 71(47) = -1(ffff)\n  signed 8 -2(fffe) >> 72(48) = -1(ffff)\n  signed 8 -2(fffe) >> 73(49) = -1(ffff)\n  signed 8 -2(fffe) >> 74(4a) = -1(ffff)\n  signed 8 -2(fffe) >> 75(4b) = -1(ffff)\n  signed 8 -2(fffe) >> 76(4c) = -1(ffff)\n  signed 8 -2(fffe) >> 77(4d) = -1(ffff)\n  signed 8 -2(fffe) >> 78(4e) = -1(ffff)\n  signed 8 -2(fffe) >> 79(4f) = -1(ffff)\n  signed 8 -2(fffe) >> 80(50) = -1(ffff)\n  signed 8 -2(fffe) >> 81(51) = -1(ffff)\n  signed 8 -2(fffe) >> 82(52) = -1(ffff)\n  signed 8 -2(fffe) >> 83(53) = -1(ffff)\n  signed 8 -2(fffe) >> 84(54) = -1(ffff)\n  signed 8 -2(fffe) >> 85(55) = -1(ffff)\n  signed 8 -2(fffe) >> 86(56) = -1(ffff)\n  signed 8 -2(fffe) >> 87(57) = -1(ffff)\n  signed 8 -2(fffe) >> 88(58) = -1(ffff)\n  signed 8 -2(fffe) >> 89(59) = -1(ffff)\n  signed 8 -2(fffe) >> 90(5a) = -1(ffff)\n  signed 8 -2(fffe) >> 91(5b) = -1(ffff)\n  signed 8 -2(fffe) >> 92(5c) = -1(ffff)\n  signed 8 -2(fffe) >> 93(5d) = -1(ffff)\n  signed 8 -2(fffe) >> 94(5e) = -1(ffff)\n  signed 8 -2(fffe) >> 95(5f) = -1(ffff)\n  signed 8 -2(fffe) >> 96(60) = -2(fffe)\n  signed 8 -2(fffe) >> 97(61) = -1(ffff)\n  signed 8 -2(fffe) >> 98(62) = -1(ffff)\n  signed 8 -2(fffe) >> 99(63) = -1(ffff)\n  signed 8 -2(fffe) >> 100(64) = -1(ffff)\n  signed 8 -2(fffe) >> 101(65) = -1(ffff)\n  signed 8 -2(fffe) >> 102(66) = -1(ffff)\n  signed 8 -2(fffe) >> 103(67) = -1(ffff)\n  signed 8 -2(fffe) >> 104(68) = -1(ffff)\n  signed 8 -2(fffe) >> 105(69) = -1(ffff)\n  signed 8 -2(fffe) >> 106(6a) = -1(ffff)\n  signed 8 -2(fffe) >> 107(6b) = -1(ffff)\n  signed 8 -2(fffe) >> 108(6c) = -1(ffff)\n  signed 8 -2(fffe) >> 109(6d) = -1(ffff)\n  signed 8 -2(fffe) >> 110(6e) = -1(ffff)\n  signed 8 -2(fffe) >> 111(6f) = -1(ffff)\n  signed 8 -2(fffe) >> 112(70) = -1(ffff)\n  signed 8 -2(fffe) >> 113(71) = -1(ffff)\n  signed 8 -2(fffe) >> 114(72) = -1(ffff)\n  signed 8 -2(fffe) >> 115(73) = -1(ffff)\n  signed 8 -2(fffe) >> 116(74) = -1(ffff)\n  signed 8 -2(fffe) >> 117(75) = -1(ffff)\n  signed 8 -2(fffe) >> 118(76) = -1(ffff)\n  signed 8 -2(fffe) >> 119(77) = -1(ffff)\n  signed 8 -2(fffe) >> 120(78) = -1(ffff)\n  signed 8 -2(fffe) >> 121(79) = -1(ffff)\n  signed 8 -2(fffe) >> 122(7a) = -1(ffff)\n  signed 8 -2(fffe) >> 123(7b) = -1(ffff)\n  signed 8 -2(fffe) >> 124(7c) = -1(ffff)\n  signed 8 -2(fffe) >> 125(7d) = -1(ffff)\n  signed 8 -2(fffe) >> 126(7e) = -1(ffff)\n  signed 8 -2(fffe) >> 127(7f) = -1(ffff)\n  signed 8 -1(ffff) >> -128(ffffff80) = -1(ffff)\n  signed 8 -1(ffff) >> -127(ffffff81) = -1(ffff)\n  signed 8 -1(ffff) >> -126(ffffff82) = -1(ffff)\n  signed 8 -1(ffff) >> -125(ffffff83) = -1(ffff)\n  signed 8 -1(ffff) >> -124(ffffff84) = -1(ffff)\n  signed 8 -1(ffff) >> -123(ffffff85) = -1(ffff)\n  signed 8 -1(ffff) >> -122(ffffff86) = -1(ffff)\n  signed 8 -1(ffff) >> -121(ffffff87) = -1(ffff)\n  signed 8 -1(ffff) >> -120(ffffff88) = -1(ffff)\n  signed 8 -1(ffff) >> -119(ffffff89) = -1(ffff)\n  signed 8 -1(ffff) >> -118(ffffff8a) = -1(ffff)\n  signed 8 -1(ffff) >> -117(ffffff8b) = -1(ffff)\n  signed 8 -1(ffff) >> -116(ffffff8c) = -1(ffff)\n  signed 8 -1(ffff) >> -115(ffffff8d) = -1(ffff)\n  signed 8 -1(ffff) >> -114(ffffff8e) = -1(ffff)\n  signed 8 -1(ffff) >> -113(ffffff8f) = -1(ffff)\n  signed 8 -1(ffff) >> -112(ffffff90) = -1(ffff)\n  signed 8 -1(ffff) >> -111(ffffff91) = -1(ffff)\n  signed 8 -1(ffff) >> -110(ffffff92) = -1(ffff)\n  signed 8 -1(ffff) >> -109(ffffff93) = -1(ffff)\n  signed 8 -1(ffff) >> -108(ffffff94) = -1(ffff)\n  signed 8 -1(ffff) >> -107(ffffff95) = -1(ffff)\n  signed 8 -1(ffff) >> -106(ffffff96) = -1(ffff)\n  signed 8 -1(ffff) >> -105(ffffff97) = -1(ffff)\n  signed 8 -1(ffff) >> -104(ffffff98) = -1(ffff)\n  signed 8 -1(ffff) >> -103(ffffff99) = -1(ffff)\n  signed 8 -1(ffff) >> -102(ffffff9a) = -1(ffff)\n  signed 8 -1(ffff) >> -101(ffffff9b) = -1(ffff)\n  signed 8 -1(ffff) >> -100(ffffff9c) = -1(ffff)\n  signed 8 -1(ffff) >> -99(ffffff9d) = -1(ffff)\n  signed 8 -1(ffff) >> -98(ffffff9e) = -1(ffff)\n  signed 8 -1(ffff) >> -97(ffffff9f) = -1(ffff)\n  signed 8 -1(ffff) >> -96(ffffffa0) = -1(ffff)\n  signed 8 -1(ffff) >> -95(ffffffa1) = -1(ffff)\n  signed 8 -1(ffff) >> -94(ffffffa2) = -1(ffff)\n  signed 8 -1(ffff) >> -93(ffffffa3) = -1(ffff)\n  signed 8 -1(ffff) >> -92(ffffffa4) = -1(ffff)\n  signed 8 -1(ffff) >> -91(ffffffa5) = -1(ffff)\n  signed 8 -1(ffff) >> -90(ffffffa6) = -1(ffff)\n  signed 8 -1(ffff) >> -89(ffffffa7) = -1(ffff)\n  signed 8 -1(ffff) >> -88(ffffffa8) = -1(ffff)\n  signed 8 -1(ffff) >> -87(ffffffa9) = -1(ffff)\n  signed 8 -1(ffff) >> -86(ffffffaa) = -1(ffff)\n  signed 8 -1(ffff) >> -85(ffffffab) = -1(ffff)\n  signed 8 -1(ffff) >> -84(ffffffac) = -1(ffff)\n  signed 8 -1(ffff) >> -83(ffffffad) = -1(ffff)\n  signed 8 -1(ffff) >> -82(ffffffae) = -1(ffff)\n  signed 8 -1(ffff) >> -81(ffffffaf) = -1(ffff)\n  signed 8 -1(ffff) >> -80(ffffffb0) = -1(ffff)\n  signed 8 -1(ffff) >> -79(ffffffb1) = -1(ffff)\n  signed 8 -1(ffff) >> -78(ffffffb2) = -1(ffff)\n  signed 8 -1(ffff) >> -77(ffffffb3) = -1(ffff)\n  signed 8 -1(ffff) >> -76(ffffffb4) = -1(ffff)\n  signed 8 -1(ffff) >> -75(ffffffb5) = -1(ffff)\n  signed 8 -1(ffff) >> -74(ffffffb6) = -1(ffff)\n  signed 8 -1(ffff) >> -73(ffffffb7) = -1(ffff)\n  signed 8 -1(ffff) >> -72(ffffffb8) = -1(ffff)\n  signed 8 -1(ffff) >> -71(ffffffb9) = -1(ffff)\n  signed 8 -1(ffff) >> -70(ffffffba) = -1(ffff)\n  signed 8 -1(ffff) >> -69(ffffffbb) = -1(ffff)\n  signed 8 -1(ffff) >> -68(ffffffbc) = -1(ffff)\n  signed 8 -1(ffff) >> -67(ffffffbd) = -1(ffff)\n  signed 8 -1(ffff) >> -66(ffffffbe) = -1(ffff)\n  signed 8 -1(ffff) >> -65(ffffffbf) = -1(ffff)\n  signed 8 -1(ffff) >> -64(ffffffc0) = -1(ffff)\n  signed 8 -1(ffff) >> -63(ffffffc1) = -1(ffff)\n  signed 8 -1(ffff) >> -62(ffffffc2) = -1(ffff)\n  signed 8 -1(ffff) >> -61(ffffffc3) = -1(ffff)\n  signed 8 -1(ffff) >> -60(ffffffc4) = -1(ffff)\n  signed 8 -1(ffff) >> -59(ffffffc5) = -1(ffff)\n  signed 8 -1(ffff) >> -58(ffffffc6) = -1(ffff)\n  signed 8 -1(ffff) >> -57(ffffffc7) = -1(ffff)\n  signed 8 -1(ffff) >> -56(ffffffc8) = -1(ffff)\n  signed 8 -1(ffff) >> -55(ffffffc9) = -1(ffff)\n  signed 8 -1(ffff) >> -54(ffffffca) = -1(ffff)\n  signed 8 -1(ffff) >> -53(ffffffcb) = -1(ffff)\n  signed 8 -1(ffff) >> -52(ffffffcc) = -1(ffff)\n  signed 8 -1(ffff) >> -51(ffffffcd) = -1(ffff)\n  signed 8 -1(ffff) >> -50(ffffffce) = -1(ffff)\n  signed 8 -1(ffff) >> -49(ffffffcf) = -1(ffff)\n  signed 8 -1(ffff) >> -48(ffffffd0) = -1(ffff)\n  signed 8 -1(ffff) >> -47(ffffffd1) = -1(ffff)\n  signed 8 -1(ffff) >> -46(ffffffd2) = -1(ffff)\n  signed 8 -1(ffff) >> -45(ffffffd3) = -1(ffff)\n  signed 8 -1(ffff) >> -44(ffffffd4) = -1(ffff)\n  signed 8 -1(ffff) >> -43(ffffffd5) = -1(ffff)\n  signed 8 -1(ffff) >> -42(ffffffd6) = -1(ffff)\n  signed 8 -1(ffff) >> -41(ffffffd7) = -1(ffff)\n  signed 8 -1(ffff) >> -40(ffffffd8) = -1(ffff)\n  signed 8 -1(ffff) >> -39(ffffffd9) = -1(ffff)\n  signed 8 -1(ffff) >> -38(ffffffda) = -1(ffff)\n  signed 8 -1(ffff) >> -37(ffffffdb) = -1(ffff)\n  signed 8 -1(ffff) >> -36(ffffffdc) = -1(ffff)\n  signed 8 -1(ffff) >> -35(ffffffdd) = -1(ffff)\n  signed 8 -1(ffff) >> -34(ffffffde) = -1(ffff)\n  signed 8 -1(ffff) >> -33(ffffffdf) = -1(ffff)\n  signed 8 -1(ffff) >> -32(ffffffe0) = -1(ffff)\n  signed 8 -1(ffff) >> -31(ffffffe1) = -1(ffff)\n  signed 8 -1(ffff) >> -30(ffffffe2) = -1(ffff)\n  signed 8 -1(ffff) >> -29(ffffffe3) = -1(ffff)\n  signed 8 -1(ffff) >> -28(ffffffe4) = -1(ffff)\n  signed 8 -1(ffff) >> -27(ffffffe5) = -1(ffff)\n  signed 8 -1(ffff) >> -26(ffffffe6) = -1(ffff)\n  signed 8 -1(ffff) >> -25(ffffffe7) = -1(ffff)\n  signed 8 -1(ffff) >> -24(ffffffe8) = -1(ffff)\n  signed 8 -1(ffff) >> -23(ffffffe9) = -1(ffff)\n  signed 8 -1(ffff) >> -22(ffffffea) = -1(ffff)\n  signed 8 -1(ffff) >> -21(ffffffeb) = -1(ffff)\n  signed 8 -1(ffff) >> -20(ffffffec) = -1(ffff)\n  signed 8 -1(ffff) >> -19(ffffffed) = -1(ffff)\n  signed 8 -1(ffff) >> -18(ffffffee) = -1(ffff)\n  signed 8 -1(ffff) >> -17(ffffffef) = -1(ffff)\n  signed 8 -1(ffff) >> -16(fffffff0) = -1(ffff)\n  signed 8 -1(ffff) >> -15(fffffff1) = -1(ffff)\n  signed 8 -1(ffff) >> -14(fffffff2) = -1(ffff)\n  signed 8 -1(ffff) >> -13(fffffff3) = -1(ffff)\n  signed 8 -1(ffff) >> -12(fffffff4) = -1(ffff)\n  signed 8 -1(ffff) >> -11(fffffff5) = -1(ffff)\n  signed 8 -1(ffff) >> -10(fffffff6) = -1(ffff)\n  signed 8 -1(ffff) >> -9(fffffff7) = -1(ffff)\n  signed 8 -1(ffff) >> -8(fffffff8) = -1(ffff)\n  signed 8 -1(ffff) >> -7(fffffff9) = -1(ffff)\n  signed 8 -1(ffff) >> -6(fffffffa) = -1(ffff)\n  signed 8 -1(ffff) >> -5(fffffffb) = -1(ffff)\n  signed 8 -1(ffff) >> -4(fffffffc) = -1(ffff)\n  signed 8 -1(ffff) >> -3(fffffffd) = -1(ffff)\n  signed 8 -1(ffff) >> -2(fffffffe) = -1(ffff)\n  signed 8 -1(ffff) >> -1(ffffffff) = -1(ffff)\n  signed 8 -1(ffff) >> 0(0) = -1(ffff)\n  signed 8 -1(ffff) >> 1(1) = -1(ffff)\n  signed 8 -1(ffff) >> 2(2) = -1(ffff)\n  signed 8 -1(ffff) >> 3(3) = -1(ffff)\n  signed 8 -1(ffff) >> 4(4) = -1(ffff)\n  signed 8 -1(ffff) >> 5(5) = -1(ffff)\n  signed 8 -1(ffff) >> 6(6) = -1(ffff)\n  signed 8 -1(ffff) >> 7(7) = -1(ffff)\n  signed 8 -1(ffff) >> 8(8) = -1(ffff)\n  signed 8 -1(ffff) >> 9(9) = -1(ffff)\n  signed 8 -1(ffff) >> 10(a) = -1(ffff)\n  signed 8 -1(ffff) >> 11(b) = -1(ffff)\n  signed 8 -1(ffff) >> 12(c) = -1(ffff)\n  signed 8 -1(ffff) >> 13(d) = -1(ffff)\n  signed 8 -1(ffff) >> 14(e) = -1(ffff)\n  signed 8 -1(ffff) >> 15(f) = -1(ffff)\n  signed 8 -1(ffff) >> 16(10) = -1(ffff)\n  signed 8 -1(ffff) >> 17(11) = -1(ffff)\n  signed 8 -1(ffff) >> 18(12) = -1(ffff)\n  signed 8 -1(ffff) >> 19(13) = -1(ffff)\n  signed 8 -1(ffff) >> 20(14) = -1(ffff)\n  signed 8 -1(ffff) >> 21(15) = -1(ffff)\n  signed 8 -1(ffff) >> 22(16) = -1(ffff)\n  signed 8 -1(ffff) >> 23(17) = -1(ffff)\n  signed 8 -1(ffff) >> 24(18) = -1(ffff)\n  signed 8 -1(ffff) >> 25(19) = -1(ffff)\n  signed 8 -1(ffff) >> 26(1a) = -1(ffff)\n  signed 8 -1(ffff) >> 27(1b) = -1(ffff)\n  signed 8 -1(ffff) >> 28(1c) = -1(ffff)\n  signed 8 -1(ffff) >> 29(1d) = -1(ffff)\n  signed 8 -1(ffff) >> 30(1e) = -1(ffff)\n  signed 8 -1(ffff) >> 31(1f) = -1(ffff)\n  signed 8 -1(ffff) >> 32(20) = -1(ffff)\n  signed 8 -1(ffff) >> 33(21) = -1(ffff)\n  signed 8 -1(ffff) >> 34(22) = -1(ffff)\n  signed 8 -1(ffff) >> 35(23) = -1(ffff)\n  signed 8 -1(ffff) >> 36(24) = -1(ffff)\n  signed 8 -1(ffff) >> 37(25) = -1(ffff)\n  signed 8 -1(ffff) >> 38(26) = -1(ffff)\n  signed 8 -1(ffff) >> 39(27) = -1(ffff)\n  signed 8 -1(ffff) >> 40(28) = -1(ffff)\n  signed 8 -1(ffff) >> 41(29) = -1(ffff)\n  signed 8 -1(ffff) >> 42(2a) = -1(ffff)\n  signed 8 -1(ffff) >> 43(2b) = -1(ffff)\n  signed 8 -1(ffff) >> 44(2c) = -1(ffff)\n  signed 8 -1(ffff) >> 45(2d) = -1(ffff)\n  signed 8 -1(ffff) >> 46(2e) = -1(ffff)\n  signed 8 -1(ffff) >> 47(2f) = -1(ffff)\n  signed 8 -1(ffff) >> 48(30) = -1(ffff)\n  signed 8 -1(ffff) >> 49(31) = -1(ffff)\n  signed 8 -1(ffff) >> 50(32) = -1(ffff)\n  signed 8 -1(ffff) >> 51(33) = -1(ffff)\n  signed 8 -1(ffff) >> 52(34) = -1(ffff)\n  signed 8 -1(ffff) >> 53(35) = -1(ffff)\n  signed 8 -1(ffff) >> 54(36) = -1(ffff)\n  signed 8 -1(ffff) >> 55(37) = -1(ffff)\n  signed 8 -1(ffff) >> 56(38) = -1(ffff)\n  signed 8 -1(ffff) >> 57(39) = -1(ffff)\n  signed 8 -1(ffff) >> 58(3a) = -1(ffff)\n  signed 8 -1(ffff) >> 59(3b) = -1(ffff)\n  signed 8 -1(ffff) >> 60(3c) = -1(ffff)\n  signed 8 -1(ffff) >> 61(3d) = -1(ffff)\n  signed 8 -1(ffff) >> 62(3e) = -1(ffff)\n  signed 8 -1(ffff) >> 63(3f) = -1(ffff)\n  signed 8 -1(ffff) >> 64(40) = -1(ffff)\n  signed 8 -1(ffff) >> 65(41) = -1(ffff)\n  signed 8 -1(ffff) >> 66(42) = -1(ffff)\n  signed 8 -1(ffff) >> 67(43) = -1(ffff)\n  signed 8 -1(ffff) >> 68(44) = -1(ffff)\n  signed 8 -1(ffff) >> 69(45) = -1(ffff)\n  signed 8 -1(ffff) >> 70(46) = -1(ffff)\n  signed 8 -1(ffff) >> 71(47) = -1(ffff)\n  signed 8 -1(ffff) >> 72(48) = -1(ffff)\n  signed 8 -1(ffff) >> 73(49) = -1(ffff)\n  signed 8 -1(ffff) >> 74(4a) = -1(ffff)\n  signed 8 -1(ffff) >> 75(4b) = -1(ffff)\n  signed 8 -1(ffff) >> 76(4c) = -1(ffff)\n  signed 8 -1(ffff) >> 77(4d) = -1(ffff)\n  signed 8 -1(ffff) >> 78(4e) = -1(ffff)\n  signed 8 -1(ffff) >> 79(4f) = -1(ffff)\n  signed 8 -1(ffff) >> 80(50) = -1(ffff)\n  signed 8 -1(ffff) >> 81(51) = -1(ffff)\n  signed 8 -1(ffff) >> 82(52) = -1(ffff)\n  signed 8 -1(ffff) >> 83(53) = -1(ffff)\n  signed 8 -1(ffff) >> 84(54) = -1(ffff)\n  signed 8 -1(ffff) >> 85(55) = -1(ffff)\n  signed 8 -1(ffff) >> 86(56) = -1(ffff)\n  signed 8 -1(ffff) >> 87(57) = -1(ffff)\n  signed 8 -1(ffff) >> 88(58) = -1(ffff)\n  signed 8 -1(ffff) >> 89(59) = -1(ffff)\n  signed 8 -1(ffff) >> 90(5a) = -1(ffff)\n  signed 8 -1(ffff) >> 91(5b) = -1(ffff)\n  signed 8 -1(ffff) >> 92(5c) = -1(ffff)\n  signed 8 -1(ffff) >> 93(5d) = -1(ffff)\n  signed 8 -1(ffff) >> 94(5e) = -1(ffff)\n  signed 8 -1(ffff) >> 95(5f) = -1(ffff)\n  signed 8 -1(ffff) >> 96(60) = -1(ffff)\n  signed 8 -1(ffff) >> 97(61) = -1(ffff)\n  signed 8 -1(ffff) >> 98(62) = -1(ffff)\n  signed 8 -1(ffff) >> 99(63) = -1(ffff)\n  signed 8 -1(ffff) >> 100(64) = -1(ffff)\n  signed 8 -1(ffff) >> 101(65) = -1(ffff)\n  signed 8 -1(ffff) >> 102(66) = -1(ffff)\n  signed 8 -1(ffff) >> 103(67) = -1(ffff)\n  signed 8 -1(ffff) >> 104(68) = -1(ffff)\n  signed 8 -1(ffff) >> 105(69) = -1(ffff)\n  signed 8 -1(ffff) >> 106(6a) = -1(ffff)\n  signed 8 -1(ffff) >> 107(6b) = -1(ffff)\n  signed 8 -1(ffff) >> 108(6c) = -1(ffff)\n  signed 8 -1(ffff) >> 109(6d) = -1(ffff)\n  signed 8 -1(ffff) >> 110(6e) = -1(ffff)\n  signed 8 -1(ffff) >> 111(6f) = -1(ffff)\n  signed 8 -1(ffff) >> 112(70) = -1(ffff)\n  signed 8 -1(ffff) >> 113(71) = -1(ffff)\n  signed 8 -1(ffff) >> 114(72) = -1(ffff)\n  signed 8 -1(ffff) >> 115(73) = -1(ffff)\n  signed 8 -1(ffff) >> 116(74) = -1(ffff)\n  signed 8 -1(ffff) >> 117(75) = -1(ffff)\n  signed 8 -1(ffff) >> 118(76) = -1(ffff)\n  signed 8 -1(ffff) >> 119(77) = -1(ffff)\n  signed 8 -1(ffff) >> 120(78) = -1(ffff)\n  signed 8 -1(ffff) >> 121(79) = -1(ffff)\n  signed 8 -1(ffff) >> 122(7a) = -1(ffff)\n  signed 8 -1(ffff) >> 123(7b) = -1(ffff)\n  signed 8 -1(ffff) >> 124(7c) = -1(ffff)\n  signed 8 -1(ffff) >> 125(7d) = -1(ffff)\n  signed 8 -1(ffff) >> 126(7e) = -1(ffff)\n  signed 8 -1(ffff) >> 127(7f) = -1(ffff)\n  signed 8 0(0) >> -128(ffffff80) = 0(0)\n  signed 8 0(0) >> -127(ffffff81) = 0(0)\n  signed 8 0(0) >> -126(ffffff82) = 0(0)\n  signed 8 0(0) >> -125(ffffff83) = 0(0)\n  signed 8 0(0) >> -124(ffffff84) = 0(0)\n  signed 8 0(0) >> -123(ffffff85) = 0(0)\n  signed 8 0(0) >> -122(ffffff86) = 0(0)\n  signed 8 0(0) >> -121(ffffff87) = 0(0)\n  signed 8 0(0) >> -120(ffffff88) = 0(0)\n  signed 8 0(0) >> -119(ffffff89) = 0(0)\n  signed 8 0(0) >> -118(ffffff8a) = 0(0)\n  signed 8 0(0) >> -117(ffffff8b) = 0(0)\n  signed 8 0(0) >> -116(ffffff8c) = 0(0)\n  signed 8 0(0) >> -115(ffffff8d) = 0(0)\n  signed 8 0(0) >> -114(ffffff8e) = 0(0)\n  signed 8 0(0) >> -113(ffffff8f) = 0(0)\n  signed 8 0(0) >> -112(ffffff90) = 0(0)\n  signed 8 0(0) >> -111(ffffff91) = 0(0)\n  signed 8 0(0) >> -110(ffffff92) = 0(0)\n  signed 8 0(0) >> -109(ffffff93) = 0(0)\n  signed 8 0(0) >> -108(ffffff94) = 0(0)\n  signed 8 0(0) >> -107(ffffff95) = 0(0)\n  signed 8 0(0) >> -106(ffffff96) = 0(0)\n  signed 8 0(0) >> -105(ffffff97) = 0(0)\n  signed 8 0(0) >> -104(ffffff98) = 0(0)\n  signed 8 0(0) >> -103(ffffff99) = 0(0)\n  signed 8 0(0) >> -102(ffffff9a) = 0(0)\n  signed 8 0(0) >> -101(ffffff9b) = 0(0)\n  signed 8 0(0) >> -100(ffffff9c) = 0(0)\n  signed 8 0(0) >> -99(ffffff9d) = 0(0)\n  signed 8 0(0) >> -98(ffffff9e) = 0(0)\n  signed 8 0(0) >> -97(ffffff9f) = 0(0)\n  signed 8 0(0) >> -96(ffffffa0) = 0(0)\n  signed 8 0(0) >> -95(ffffffa1) = 0(0)\n  signed 8 0(0) >> -94(ffffffa2) = 0(0)\n  signed 8 0(0) >> -93(ffffffa3) = 0(0)\n  signed 8 0(0) >> -92(ffffffa4) = 0(0)\n  signed 8 0(0) >> -91(ffffffa5) = 0(0)\n  signed 8 0(0) >> -90(ffffffa6) = 0(0)\n  signed 8 0(0) >> -89(ffffffa7) = 0(0)\n  signed 8 0(0) >> -88(ffffffa8) = 0(0)\n  signed 8 0(0) >> -87(ffffffa9) = 0(0)\n  signed 8 0(0) >> -86(ffffffaa) = 0(0)\n  signed 8 0(0) >> -85(ffffffab) = 0(0)\n  signed 8 0(0) >> -84(ffffffac) = 0(0)\n  signed 8 0(0) >> -83(ffffffad) = 0(0)\n  signed 8 0(0) >> -82(ffffffae) = 0(0)\n  signed 8 0(0) >> -81(ffffffaf) = 0(0)\n  signed 8 0(0) >> -80(ffffffb0) = 0(0)\n  signed 8 0(0) >> -79(ffffffb1) = 0(0)\n  signed 8 0(0) >> -78(ffffffb2) = 0(0)\n  signed 8 0(0) >> -77(ffffffb3) = 0(0)\n  signed 8 0(0) >> -76(ffffffb4) = 0(0)\n  signed 8 0(0) >> -75(ffffffb5) = 0(0)\n  signed 8 0(0) >> -74(ffffffb6) = 0(0)\n  signed 8 0(0) >> -73(ffffffb7) = 0(0)\n  signed 8 0(0) >> -72(ffffffb8) = 0(0)\n  signed 8 0(0) >> -71(ffffffb9) = 0(0)\n  signed 8 0(0) >> -70(ffffffba) = 0(0)\n  signed 8 0(0) >> -69(ffffffbb) = 0(0)\n  signed 8 0(0) >> -68(ffffffbc) = 0(0)\n  signed 8 0(0) >> -67(ffffffbd) = 0(0)\n  signed 8 0(0) >> -66(ffffffbe) = 0(0)\n  signed 8 0(0) >> -65(ffffffbf) = 0(0)\n  signed 8 0(0) >> -64(ffffffc0) = 0(0)\n  signed 8 0(0) >> -63(ffffffc1) = 0(0)\n  signed 8 0(0) >> -62(ffffffc2) = 0(0)\n  signed 8 0(0) >> -61(ffffffc3) = 0(0)\n  signed 8 0(0) >> -60(ffffffc4) = 0(0)\n  signed 8 0(0) >> -59(ffffffc5) = 0(0)\n  signed 8 0(0) >> -58(ffffffc6) = 0(0)\n  signed 8 0(0) >> -57(ffffffc7) = 0(0)\n  signed 8 0(0) >> -56(ffffffc8) = 0(0)\n  signed 8 0(0) >> -55(ffffffc9) = 0(0)\n  signed 8 0(0) >> -54(ffffffca) = 0(0)\n  signed 8 0(0) >> -53(ffffffcb) = 0(0)\n  signed 8 0(0) >> -52(ffffffcc) = 0(0)\n  signed 8 0(0) >> -51(ffffffcd) = 0(0)\n  signed 8 0(0) >> -50(ffffffce) = 0(0)\n  signed 8 0(0) >> -49(ffffffcf) = 0(0)\n  signed 8 0(0) >> -48(ffffffd0) = 0(0)\n  signed 8 0(0) >> -47(ffffffd1) = 0(0)\n  signed 8 0(0) >> -46(ffffffd2) = 0(0)\n  signed 8 0(0) >> -45(ffffffd3) = 0(0)\n  signed 8 0(0) >> -44(ffffffd4) = 0(0)\n  signed 8 0(0) >> -43(ffffffd5) = 0(0)\n  signed 8 0(0) >> -42(ffffffd6) = 0(0)\n  signed 8 0(0) >> -41(ffffffd7) = 0(0)\n  signed 8 0(0) >> -40(ffffffd8) = 0(0)\n  signed 8 0(0) >> -39(ffffffd9) = 0(0)\n  signed 8 0(0) >> -38(ffffffda) = 0(0)\n  signed 8 0(0) >> -37(ffffffdb) = 0(0)\n  signed 8 0(0) >> -36(ffffffdc) = 0(0)\n  signed 8 0(0) >> -35(ffffffdd) = 0(0)\n  signed 8 0(0) >> -34(ffffffde) = 0(0)\n  signed 8 0(0) >> -33(ffffffdf) = 0(0)\n  signed 8 0(0) >> -32(ffffffe0) = 0(0)\n  signed 8 0(0) >> -31(ffffffe1) = 0(0)\n  signed 8 0(0) >> -30(ffffffe2) = 0(0)\n  signed 8 0(0) >> -29(ffffffe3) = 0(0)\n  signed 8 0(0) >> -28(ffffffe4) = 0(0)\n  signed 8 0(0) >> -27(ffffffe5) = 0(0)\n  signed 8 0(0) >> -26(ffffffe6) = 0(0)\n  signed 8 0(0) >> -25(ffffffe7) = 0(0)\n  signed 8 0(0) >> -24(ffffffe8) = 0(0)\n  signed 8 0(0) >> -23(ffffffe9) = 0(0)\n  signed 8 0(0) >> -22(ffffffea) = 0(0)\n  signed 8 0(0) >> -21(ffffffeb) = 0(0)\n  signed 8 0(0) >> -20(ffffffec) = 0(0)\n  signed 8 0(0) >> -19(ffffffed) = 0(0)\n  signed 8 0(0) >> -18(ffffffee) = 0(0)\n  signed 8 0(0) >> -17(ffffffef) = 0(0)\n  signed 8 0(0) >> -16(fffffff0) = 0(0)\n  signed 8 0(0) >> -15(fffffff1) = 0(0)\n  signed 8 0(0) >> -14(fffffff2) = 0(0)\n  signed 8 0(0) >> -13(fffffff3) = 0(0)\n  signed 8 0(0) >> -12(fffffff4) = 0(0)\n  signed 8 0(0) >> -11(fffffff5) = 0(0)\n  signed 8 0(0) >> -10(fffffff6) = 0(0)\n  signed 8 0(0) >> -9(fffffff7) = 0(0)\n  signed 8 0(0) >> -8(fffffff8) = 0(0)\n  signed 8 0(0) >> -7(fffffff9) = 0(0)\n  signed 8 0(0) >> -6(fffffffa) = 0(0)\n  signed 8 0(0) >> -5(fffffffb) = 0(0)\n  signed 8 0(0) >> -4(fffffffc) = 0(0)\n  signed 8 0(0) >> -3(fffffffd) = 0(0)\n  signed 8 0(0) >> -2(fffffffe) = 0(0)\n  signed 8 0(0) >> -1(ffffffff) = 0(0)\n  signed 8 0(0) >> 0(0) = 0(0)\n  signed 8 0(0) >> 1(1) = 0(0)\n  signed 8 0(0) >> 2(2) = 0(0)\n  signed 8 0(0) >> 3(3) = 0(0)\n  signed 8 0(0) >> 4(4) = 0(0)\n  signed 8 0(0) >> 5(5) = 0(0)\n  signed 8 0(0) >> 6(6) = 0(0)\n  signed 8 0(0) >> 7(7) = 0(0)\n  signed 8 0(0) >> 8(8) = 0(0)\n  signed 8 0(0) >> 9(9) = 0(0)\n  signed 8 0(0) >> 10(a) = 0(0)\n  signed 8 0(0) >> 11(b) = 0(0)\n  signed 8 0(0) >> 12(c) = 0(0)\n  signed 8 0(0) >> 13(d) = 0(0)\n  signed 8 0(0) >> 14(e) = 0(0)\n  signed 8 0(0) >> 15(f) = 0(0)\n  signed 8 0(0) >> 16(10) = 0(0)\n  signed 8 0(0) >> 17(11) = 0(0)\n  signed 8 0(0) >> 18(12) = 0(0)\n  signed 8 0(0) >> 19(13) = 0(0)\n  signed 8 0(0) >> 20(14) = 0(0)\n  signed 8 0(0) >> 21(15) = 0(0)\n  signed 8 0(0) >> 22(16) = 0(0)\n  signed 8 0(0) >> 23(17) = 0(0)\n  signed 8 0(0) >> 24(18) = 0(0)\n  signed 8 0(0) >> 25(19) = 0(0)\n  signed 8 0(0) >> 26(1a) = 0(0)\n  signed 8 0(0) >> 27(1b) = 0(0)\n  signed 8 0(0) >> 28(1c) = 0(0)\n  signed 8 0(0) >> 29(1d) = 0(0)\n  signed 8 0(0) >> 30(1e) = 0(0)\n  signed 8 0(0) >> 31(1f) = 0(0)\n  signed 8 0(0) >> 32(20) = 0(0)\n  signed 8 0(0) >> 33(21) = 0(0)\n  signed 8 0(0) >> 34(22) = 0(0)\n  signed 8 0(0) >> 35(23) = 0(0)\n  signed 8 0(0) >> 36(24) = 0(0)\n  signed 8 0(0) >> 37(25) = 0(0)\n  signed 8 0(0) >> 38(26) = 0(0)\n  signed 8 0(0) >> 39(27) = 0(0)\n  signed 8 0(0) >> 40(28) = 0(0)\n  signed 8 0(0) >> 41(29) = 0(0)\n  signed 8 0(0) >> 42(2a) = 0(0)\n  signed 8 0(0) >> 43(2b) = 0(0)\n  signed 8 0(0) >> 44(2c) = 0(0)\n  signed 8 0(0) >> 45(2d) = 0(0)\n  signed 8 0(0) >> 46(2e) = 0(0)\n  signed 8 0(0) >> 47(2f) = 0(0)\n  signed 8 0(0) >> 48(30) = 0(0)\n  signed 8 0(0) >> 49(31) = 0(0)\n  signed 8 0(0) >> 50(32) = 0(0)\n  signed 8 0(0) >> 51(33) = 0(0)\n  signed 8 0(0) >> 52(34) = 0(0)\n  signed 8 0(0) >> 53(35) = 0(0)\n  signed 8 0(0) >> 54(36) = 0(0)\n  signed 8 0(0) >> 55(37) = 0(0)\n  signed 8 0(0) >> 56(38) = 0(0)\n  signed 8 0(0) >> 57(39) = 0(0)\n  signed 8 0(0) >> 58(3a) = 0(0)\n  signed 8 0(0) >> 59(3b) = 0(0)\n  signed 8 0(0) >> 60(3c) = 0(0)\n  signed 8 0(0) >> 61(3d) = 0(0)\n  signed 8 0(0) >> 62(3e) = 0(0)\n  signed 8 0(0) >> 63(3f) = 0(0)\n  signed 8 0(0) >> 64(40) = 0(0)\n  signed 8 0(0) >> 65(41) = 0(0)\n  signed 8 0(0) >> 66(42) = 0(0)\n  signed 8 0(0) >> 67(43) = 0(0)\n  signed 8 0(0) >> 68(44) = 0(0)\n  signed 8 0(0) >> 69(45) = 0(0)\n  signed 8 0(0) >> 70(46) = 0(0)\n  signed 8 0(0) >> 71(47) = 0(0)\n  signed 8 0(0) >> 72(48) = 0(0)\n  signed 8 0(0) >> 73(49) = 0(0)\n  signed 8 0(0) >> 74(4a) = 0(0)\n  signed 8 0(0) >> 75(4b) = 0(0)\n  signed 8 0(0) >> 76(4c) = 0(0)\n  signed 8 0(0) >> 77(4d) = 0(0)\n  signed 8 0(0) >> 78(4e) = 0(0)\n  signed 8 0(0) >> 79(4f) = 0(0)\n  signed 8 0(0) >> 80(50) = 0(0)\n  signed 8 0(0) >> 81(51) = 0(0)\n  signed 8 0(0) >> 82(52) = 0(0)\n  signed 8 0(0) >> 83(53) = 0(0)\n  signed 8 0(0) >> 84(54) = 0(0)\n  signed 8 0(0) >> 85(55) = 0(0)\n  signed 8 0(0) >> 86(56) = 0(0)\n  signed 8 0(0) >> 87(57) = 0(0)\n  signed 8 0(0) >> 88(58) = 0(0)\n  signed 8 0(0) >> 89(59) = 0(0)\n  signed 8 0(0) >> 90(5a) = 0(0)\n  signed 8 0(0) >> 91(5b) = 0(0)\n  signed 8 0(0) >> 92(5c) = 0(0)\n  signed 8 0(0) >> 93(5d) = 0(0)\n  signed 8 0(0) >> 94(5e) = 0(0)\n  signed 8 0(0) >> 95(5f) = 0(0)\n  signed 8 0(0) >> 96(60) = 0(0)\n  signed 8 0(0) >> 97(61) = 0(0)\n  signed 8 0(0) >> 98(62) = 0(0)\n  signed 8 0(0) >> 99(63) = 0(0)\n  signed 8 0(0) >> 100(64) = 0(0)\n  signed 8 0(0) >> 101(65) = 0(0)\n  signed 8 0(0) >> 102(66) = 0(0)\n  signed 8 0(0) >> 103(67) = 0(0)\n  signed 8 0(0) >> 104(68) = 0(0)\n  signed 8 0(0) >> 105(69) = 0(0)\n  signed 8 0(0) >> 106(6a) = 0(0)\n  signed 8 0(0) >> 107(6b) = 0(0)\n  signed 8 0(0) >> 108(6c) = 0(0)\n  signed 8 0(0) >> 109(6d) = 0(0)\n  signed 8 0(0) >> 110(6e) = 0(0)\n  signed 8 0(0) >> 111(6f) = 0(0)\n  signed 8 0(0) >> 112(70) = 0(0)\n  signed 8 0(0) >> 113(71) = 0(0)\n  signed 8 0(0) >> 114(72) = 0(0)\n  signed 8 0(0) >> 115(73) = 0(0)\n  signed 8 0(0) >> 116(74) = 0(0)\n  signed 8 0(0) >> 117(75) = 0(0)\n  signed 8 0(0) >> 118(76) = 0(0)\n  signed 8 0(0) >> 119(77) = 0(0)\n  signed 8 0(0) >> 120(78) = 0(0)\n  signed 8 0(0) >> 121(79) = 0(0)\n  signed 8 0(0) >> 122(7a) = 0(0)\n  signed 8 0(0) >> 123(7b) = 0(0)\n  signed 8 0(0) >> 124(7c) = 0(0)\n  signed 8 0(0) >> 125(7d) = 0(0)\n  signed 8 0(0) >> 126(7e) = 0(0)\n  signed 8 0(0) >> 127(7f) = 0(0)\n  signed 8 1(1) >> -128(ffffff80) = 1(1)\n  signed 8 1(1) >> -127(ffffff81) = 0(0)\n  signed 8 1(1) >> -126(ffffff82) = 0(0)\n  signed 8 1(1) >> -125(ffffff83) = 0(0)\n  signed 8 1(1) >> -124(ffffff84) = 0(0)\n  signed 8 1(1) >> -123(ffffff85) = 0(0)\n  signed 8 1(1) >> -122(ffffff86) = 0(0)\n  signed 8 1(1) >> -121(ffffff87) = 0(0)\n  signed 8 1(1) >> -120(ffffff88) = 0(0)\n  signed 8 1(1) >> -119(ffffff89) = 0(0)\n  signed 8 1(1) >> -118(ffffff8a) = 0(0)\n  signed 8 1(1) >> -117(ffffff8b) = 0(0)\n  signed 8 1(1) >> -116(ffffff8c) = 0(0)\n  signed 8 1(1) >> -115(ffffff8d) = 0(0)\n  signed 8 1(1) >> -114(ffffff8e) = 0(0)\n  signed 8 1(1) >> -113(ffffff8f) = 0(0)\n  signed 8 1(1) >> -112(ffffff90) = 0(0)\n  signed 8 1(1) >> -111(ffffff91) = 0(0)\n  signed 8 1(1) >> -110(ffffff92) = 0(0)\n  signed 8 1(1) >> -109(ffffff93) = 0(0)\n  signed 8 1(1) >> -108(ffffff94) = 0(0)\n  signed 8 1(1) >> -107(ffffff95) = 0(0)\n  signed 8 1(1) >> -106(ffffff96) = 0(0)\n  signed 8 1(1) >> -105(ffffff97) = 0(0)\n  signed 8 1(1) >> -104(ffffff98) = 0(0)\n  signed 8 1(1) >> -103(ffffff99) = 0(0)\n  signed 8 1(1) >> -102(ffffff9a) = 0(0)\n  signed 8 1(1) >> -101(ffffff9b) = 0(0)\n  signed 8 1(1) >> -100(ffffff9c) = 0(0)\n  signed 8 1(1) >> -99(ffffff9d) = 0(0)\n  signed 8 1(1) >> -98(ffffff9e) = 0(0)\n  signed 8 1(1) >> -97(ffffff9f) = 0(0)\n  signed 8 1(1) >> -96(ffffffa0) = 1(1)\n  signed 8 1(1) >> -95(ffffffa1) = 0(0)\n  signed 8 1(1) >> -94(ffffffa2) = 0(0)\n  signed 8 1(1) >> -93(ffffffa3) = 0(0)\n  signed 8 1(1) >> -92(ffffffa4) = 0(0)\n  signed 8 1(1) >> -91(ffffffa5) = 0(0)\n  signed 8 1(1) >> -90(ffffffa6) = 0(0)\n  signed 8 1(1) >> -89(ffffffa7) = 0(0)\n  signed 8 1(1) >> -88(ffffffa8) = 0(0)\n  signed 8 1(1) >> -87(ffffffa9) = 0(0)\n  signed 8 1(1) >> -86(ffffffaa) = 0(0)\n  signed 8 1(1) >> -85(ffffffab) = 0(0)\n  signed 8 1(1) >> -84(ffffffac) = 0(0)\n  signed 8 1(1) >> -83(ffffffad) = 0(0)\n  signed 8 1(1) >> -82(ffffffae) = 0(0)\n  signed 8 1(1) >> -81(ffffffaf) = 0(0)\n  signed 8 1(1) >> -80(ffffffb0) = 0(0)\n  signed 8 1(1) >> -79(ffffffb1) = 0(0)\n  signed 8 1(1) >> -78(ffffffb2) = 0(0)\n  signed 8 1(1) >> -77(ffffffb3) = 0(0)\n  signed 8 1(1) >> -76(ffffffb4) = 0(0)\n  signed 8 1(1) >> -75(ffffffb5) = 0(0)\n  signed 8 1(1) >> -74(ffffffb6) = 0(0)\n  signed 8 1(1) >> -73(ffffffb7) = 0(0)\n  signed 8 1(1) >> -72(ffffffb8) = 0(0)\n  signed 8 1(1) >> -71(ffffffb9) = 0(0)\n  signed 8 1(1) >> -70(ffffffba) = 0(0)\n  signed 8 1(1) >> -69(ffffffbb) = 0(0)\n  signed 8 1(1) >> -68(ffffffbc) = 0(0)\n  signed 8 1(1) >> -67(ffffffbd) = 0(0)\n  signed 8 1(1) >> -66(ffffffbe) = 0(0)\n  signed 8 1(1) >> -65(ffffffbf) = 0(0)\n  signed 8 1(1) >> -64(ffffffc0) = 1(1)\n  signed 8 1(1) >> -63(ffffffc1) = 0(0)\n  signed 8 1(1) >> -62(ffffffc2) = 0(0)\n  signed 8 1(1) >> -61(ffffffc3) = 0(0)\n  signed 8 1(1) >> -60(ffffffc4) = 0(0)\n  signed 8 1(1) >> -59(ffffffc5) = 0(0)\n  signed 8 1(1) >> -58(ffffffc6) = 0(0)\n  signed 8 1(1) >> -57(ffffffc7) = 0(0)\n  signed 8 1(1) >> -56(ffffffc8) = 0(0)\n  signed 8 1(1) >> -55(ffffffc9) = 0(0)\n  signed 8 1(1) >> -54(ffffffca) = 0(0)\n  signed 8 1(1) >> -53(ffffffcb) = 0(0)\n  signed 8 1(1) >> -52(ffffffcc) = 0(0)\n  signed 8 1(1) >> -51(ffffffcd) = 0(0)\n  signed 8 1(1) >> -50(ffffffce) = 0(0)\n  signed 8 1(1) >> -49(ffffffcf) = 0(0)\n  signed 8 1(1) >> -48(ffffffd0) = 0(0)\n  signed 8 1(1) >> -47(ffffffd1) = 0(0)\n  signed 8 1(1) >> -46(ffffffd2) = 0(0)\n  signed 8 1(1) >> -45(ffffffd3) = 0(0)\n  signed 8 1(1) >> -44(ffffffd4) = 0(0)\n  signed 8 1(1) >> -43(ffffffd5) = 0(0)\n  signed 8 1(1) >> -42(ffffffd6) = 0(0)\n  signed 8 1(1) >> -41(ffffffd7) = 0(0)\n  signed 8 1(1) >> -40(ffffffd8) = 0(0)\n  signed 8 1(1) >> -39(ffffffd9) = 0(0)\n  signed 8 1(1) >> -38(ffffffda) = 0(0)\n  signed 8 1(1) >> -37(ffffffdb) = 0(0)\n  signed 8 1(1) >> -36(ffffffdc) = 0(0)\n  signed 8 1(1) >> -35(ffffffdd) = 0(0)\n  signed 8 1(1) >> -34(ffffffde) = 0(0)\n  signed 8 1(1) >> -33(ffffffdf) = 0(0)\n  signed 8 1(1) >> -32(ffffffe0) = 1(1)\n  signed 8 1(1) >> -31(ffffffe1) = 0(0)\n  signed 8 1(1) >> -30(ffffffe2) = 0(0)\n  signed 8 1(1) >> -29(ffffffe3) = 0(0)\n  signed 8 1(1) >> -28(ffffffe4) = 0(0)\n  signed 8 1(1) >> -27(ffffffe5) = 0(0)\n  signed 8 1(1) >> -26(ffffffe6) = 0(0)\n  signed 8 1(1) >> -25(ffffffe7) = 0(0)\n  signed 8 1(1) >> -24(ffffffe8) = 0(0)\n  signed 8 1(1) >> -23(ffffffe9) = 0(0)\n  signed 8 1(1) >> -22(ffffffea) = 0(0)\n  signed 8 1(1) >> -21(ffffffeb) = 0(0)\n  signed 8 1(1) >> -20(ffffffec) = 0(0)\n  signed 8 1(1) >> -19(ffffffed) = 0(0)\n  signed 8 1(1) >> -18(ffffffee) = 0(0)\n  signed 8 1(1) >> -17(ffffffef) = 0(0)\n  signed 8 1(1) >> -16(fffffff0) = 0(0)\n  signed 8 1(1) >> -15(fffffff1) = 0(0)\n  signed 8 1(1) >> -14(fffffff2) = 0(0)\n  signed 8 1(1) >> -13(fffffff3) = 0(0)\n  signed 8 1(1) >> -12(fffffff4) = 0(0)\n  signed 8 1(1) >> -11(fffffff5) = 0(0)\n  signed 8 1(1) >> -10(fffffff6) = 0(0)\n  signed 8 1(1) >> -9(fffffff7) = 0(0)\n  signed 8 1(1) >> -8(fffffff8) = 0(0)\n  signed 8 1(1) >> -7(fffffff9) = 0(0)\n  signed 8 1(1) >> -6(fffffffa) = 0(0)\n  signed 8 1(1) >> -5(fffffffb) = 0(0)\n  signed 8 1(1) >> -4(fffffffc) = 0(0)\n  signed 8 1(1) >> -3(fffffffd) = 0(0)\n  signed 8 1(1) >> -2(fffffffe) = 0(0)\n  signed 8 1(1) >> -1(ffffffff) = 0(0)\n  signed 8 1(1) >> 0(0) = 1(1)\n  signed 8 1(1) >> 1(1) = 0(0)\n  signed 8 1(1) >> 2(2) = 0(0)\n  signed 8 1(1) >> 3(3) = 0(0)\n  signed 8 1(1) >> 4(4) = 0(0)\n  signed 8 1(1) >> 5(5) = 0(0)\n  signed 8 1(1) >> 6(6) = 0(0)\n  signed 8 1(1) >> 7(7) = 0(0)\n  signed 8 1(1) >> 8(8) = 0(0)\n  signed 8 1(1) >> 9(9) = 0(0)\n  signed 8 1(1) >> 10(a) = 0(0)\n  signed 8 1(1) >> 11(b) = 0(0)\n  signed 8 1(1) >> 12(c) = 0(0)\n  signed 8 1(1) >> 13(d) = 0(0)\n  signed 8 1(1) >> 14(e) = 0(0)\n  signed 8 1(1) >> 15(f) = 0(0)\n  signed 8 1(1) >> 16(10) = 0(0)\n  signed 8 1(1) >> 17(11) = 0(0)\n  signed 8 1(1) >> 18(12) = 0(0)\n  signed 8 1(1) >> 19(13) = 0(0)\n  signed 8 1(1) >> 20(14) = 0(0)\n  signed 8 1(1) >> 21(15) = 0(0)\n  signed 8 1(1) >> 22(16) = 0(0)\n  signed 8 1(1) >> 23(17) = 0(0)\n  signed 8 1(1) >> 24(18) = 0(0)\n  signed 8 1(1) >> 25(19) = 0(0)\n  signed 8 1(1) >> 26(1a) = 0(0)\n  signed 8 1(1) >> 27(1b) = 0(0)\n  signed 8 1(1) >> 28(1c) = 0(0)\n  signed 8 1(1) >> 29(1d) = 0(0)\n  signed 8 1(1) >> 30(1e) = 0(0)\n  signed 8 1(1) >> 31(1f) = 0(0)\n  signed 8 1(1) >> 32(20) = 1(1)\n  signed 8 1(1) >> 33(21) = 0(0)\n  signed 8 1(1) >> 34(22) = 0(0)\n  signed 8 1(1) >> 35(23) = 0(0)\n  signed 8 1(1) >> 36(24) = 0(0)\n  signed 8 1(1) >> 37(25) = 0(0)\n  signed 8 1(1) >> 38(26) = 0(0)\n  signed 8 1(1) >> 39(27) = 0(0)\n  signed 8 1(1) >> 40(28) = 0(0)\n  signed 8 1(1) >> 41(29) = 0(0)\n  signed 8 1(1) >> 42(2a) = 0(0)\n  signed 8 1(1) >> 43(2b) = 0(0)\n  signed 8 1(1) >> 44(2c) = 0(0)\n  signed 8 1(1) >> 45(2d) = 0(0)\n  signed 8 1(1) >> 46(2e) = 0(0)\n  signed 8 1(1) >> 47(2f) = 0(0)\n  signed 8 1(1) >> 48(30) = 0(0)\n  signed 8 1(1) >> 49(31) = 0(0)\n  signed 8 1(1) >> 50(32) = 0(0)\n  signed 8 1(1) >> 51(33) = 0(0)\n  signed 8 1(1) >> 52(34) = 0(0)\n  signed 8 1(1) >> 53(35) = 0(0)\n  signed 8 1(1) >> 54(36) = 0(0)\n  signed 8 1(1) >> 55(37) = 0(0)\n  signed 8 1(1) >> 56(38) = 0(0)\n  signed 8 1(1) >> 57(39) = 0(0)\n  signed 8 1(1) >> 58(3a) = 0(0)\n  signed 8 1(1) >> 59(3b) = 0(0)\n  signed 8 1(1) >> 60(3c) = 0(0)\n  signed 8 1(1) >> 61(3d) = 0(0)\n  signed 8 1(1) >> 62(3e) = 0(0)\n  signed 8 1(1) >> 63(3f) = 0(0)\n  signed 8 1(1) >> 64(40) = 1(1)\n  signed 8 1(1) >> 65(41) = 0(0)\n  signed 8 1(1) >> 66(42) = 0(0)\n  signed 8 1(1) >> 67(43) = 0(0)\n  signed 8 1(1) >> 68(44) = 0(0)\n  signed 8 1(1) >> 69(45) = 0(0)\n  signed 8 1(1) >> 70(46) = 0(0)\n  signed 8 1(1) >> 71(47) = 0(0)\n  signed 8 1(1) >> 72(48) = 0(0)\n  signed 8 1(1) >> 73(49) = 0(0)\n  signed 8 1(1) >> 74(4a) = 0(0)\n  signed 8 1(1) >> 75(4b) = 0(0)\n  signed 8 1(1) >> 76(4c) = 0(0)\n  signed 8 1(1) >> 77(4d) = 0(0)\n  signed 8 1(1) >> 78(4e) = 0(0)\n  signed 8 1(1) >> 79(4f) = 0(0)\n  signed 8 1(1) >> 80(50) = 0(0)\n  signed 8 1(1) >> 81(51) = 0(0)\n  signed 8 1(1) >> 82(52) = 0(0)\n  signed 8 1(1) >> 83(53) = 0(0)\n  signed 8 1(1) >> 84(54) = 0(0)\n  signed 8 1(1) >> 85(55) = 0(0)\n  signed 8 1(1) >> 86(56) = 0(0)\n  signed 8 1(1) >> 87(57) = 0(0)\n  signed 8 1(1) >> 88(58) = 0(0)\n  signed 8 1(1) >> 89(59) = 0(0)\n  signed 8 1(1) >> 90(5a) = 0(0)\n  signed 8 1(1) >> 91(5b) = 0(0)\n  signed 8 1(1) >> 92(5c) = 0(0)\n  signed 8 1(1) >> 93(5d) = 0(0)\n  signed 8 1(1) >> 94(5e) = 0(0)\n  signed 8 1(1) >> 95(5f) = 0(0)\n  signed 8 1(1) >> 96(60) = 1(1)\n  signed 8 1(1) >> 97(61) = 0(0)\n  signed 8 1(1) >> 98(62) = 0(0)\n  signed 8 1(1) >> 99(63) = 0(0)\n  signed 8 1(1) >> 100(64) = 0(0)\n  signed 8 1(1) >> 101(65) = 0(0)\n  signed 8 1(1) >> 102(66) = 0(0)\n  signed 8 1(1) >> 103(67) = 0(0)\n  signed 8 1(1) >> 104(68) = 0(0)\n  signed 8 1(1) >> 105(69) = 0(0)\n  signed 8 1(1) >> 106(6a) = 0(0)\n  signed 8 1(1) >> 107(6b) = 0(0)\n  signed 8 1(1) >> 108(6c) = 0(0)\n  signed 8 1(1) >> 109(6d) = 0(0)\n  signed 8 1(1) >> 110(6e) = 0(0)\n  signed 8 1(1) >> 111(6f) = 0(0)\n  signed 8 1(1) >> 112(70) = 0(0)\n  signed 8 1(1) >> 113(71) = 0(0)\n  signed 8 1(1) >> 114(72) = 0(0)\n  signed 8 1(1) >> 115(73) = 0(0)\n  signed 8 1(1) >> 116(74) = 0(0)\n  signed 8 1(1) >> 117(75) = 0(0)\n  signed 8 1(1) >> 118(76) = 0(0)\n  signed 8 1(1) >> 119(77) = 0(0)\n  signed 8 1(1) >> 120(78) = 0(0)\n  signed 8 1(1) >> 121(79) = 0(0)\n  signed 8 1(1) >> 122(7a) = 0(0)\n  signed 8 1(1) >> 123(7b) = 0(0)\n  signed 8 1(1) >> 124(7c) = 0(0)\n  signed 8 1(1) >> 125(7d) = 0(0)\n  signed 8 1(1) >> 126(7e) = 0(0)\n  signed 8 1(1) >> 127(7f) = 0(0)\n  signed 8 2(2) >> -128(ffffff80) = 2(2)\n  signed 8 2(2) >> -127(ffffff81) = 1(1)\n  signed 8 2(2) >> -126(ffffff82) = 0(0)\n  signed 8 2(2) >> -125(ffffff83) = 0(0)\n  signed 8 2(2) >> -124(ffffff84) = 0(0)\n  signed 8 2(2) >> -123(ffffff85) = 0(0)\n  signed 8 2(2) >> -122(ffffff86) = 0(0)\n  signed 8 2(2) >> -121(ffffff87) = 0(0)\n  signed 8 2(2) >> -120(ffffff88) = 0(0)\n  signed 8 2(2) >> -119(ffffff89) = 0(0)\n  signed 8 2(2) >> -118(ffffff8a) = 0(0)\n  signed 8 2(2) >> -117(ffffff8b) = 0(0)\n  signed 8 2(2) >> -116(ffffff8c) = 0(0)\n  signed 8 2(2) >> -115(ffffff8d) = 0(0)\n  signed 8 2(2) >> -114(ffffff8e) = 0(0)\n  signed 8 2(2) >> -113(ffffff8f) = 0(0)\n  signed 8 2(2) >> -112(ffffff90) = 0(0)\n  signed 8 2(2) >> -111(ffffff91) = 0(0)\n  signed 8 2(2) >> -110(ffffff92) = 0(0)\n  signed 8 2(2) >> -109(ffffff93) = 0(0)\n  signed 8 2(2) >> -108(ffffff94) = 0(0)\n  signed 8 2(2) >> -107(ffffff95) = 0(0)\n  signed 8 2(2) >> -106(ffffff96) = 0(0)\n  signed 8 2(2) >> -105(ffffff97) = 0(0)\n  signed 8 2(2) >> -104(ffffff98) = 0(0)\n  signed 8 2(2) >> -103(ffffff99) = 0(0)\n  signed 8 2(2) >> -102(ffffff9a) = 0(0)\n  signed 8 2(2) >> -101(ffffff9b) = 0(0)\n  signed 8 2(2) >> -100(ffffff9c) = 0(0)\n  signed 8 2(2) >> -99(ffffff9d) = 0(0)\n  signed 8 2(2) >> -98(ffffff9e) = 0(0)\n  signed 8 2(2) >> -97(ffffff9f) = 0(0)\n  signed 8 2(2) >> -96(ffffffa0) = 2(2)\n  signed 8 2(2) >> -95(ffffffa1) = 1(1)\n  signed 8 2(2) >> -94(ffffffa2) = 0(0)\n  signed 8 2(2) >> -93(ffffffa3) = 0(0)\n  signed 8 2(2) >> -92(ffffffa4) = 0(0)\n  signed 8 2(2) >> -91(ffffffa5) = 0(0)\n  signed 8 2(2) >> -90(ffffffa6) = 0(0)\n  signed 8 2(2) >> -89(ffffffa7) = 0(0)\n  signed 8 2(2) >> -88(ffffffa8) = 0(0)\n  signed 8 2(2) >> -87(ffffffa9) = 0(0)\n  signed 8 2(2) >> -86(ffffffaa) = 0(0)\n  signed 8 2(2) >> -85(ffffffab) = 0(0)\n  signed 8 2(2) >> -84(ffffffac) = 0(0)\n  signed 8 2(2) >> -83(ffffffad) = 0(0)\n  signed 8 2(2) >> -82(ffffffae) = 0(0)\n  signed 8 2(2) >> -81(ffffffaf) = 0(0)\n  signed 8 2(2) >> -80(ffffffb0) = 0(0)\n  signed 8 2(2) >> -79(ffffffb1) = 0(0)\n  signed 8 2(2) >> -78(ffffffb2) = 0(0)\n  signed 8 2(2) >> -77(ffffffb3) = 0(0)\n  signed 8 2(2) >> -76(ffffffb4) = 0(0)\n  signed 8 2(2) >> -75(ffffffb5) = 0(0)\n  signed 8 2(2) >> -74(ffffffb6) = 0(0)\n  signed 8 2(2) >> -73(ffffffb7) = 0(0)\n  signed 8 2(2) >> -72(ffffffb8) = 0(0)\n  signed 8 2(2) >> -71(ffffffb9) = 0(0)\n  signed 8 2(2) >> -70(ffffffba) = 0(0)\n  signed 8 2(2) >> -69(ffffffbb) = 0(0)\n  signed 8 2(2) >> -68(ffffffbc) = 0(0)\n  signed 8 2(2) >> -67(ffffffbd) = 0(0)\n  signed 8 2(2) >> -66(ffffffbe) = 0(0)\n  signed 8 2(2) >> -65(ffffffbf) = 0(0)\n  signed 8 2(2) >> -64(ffffffc0) = 2(2)\n  signed 8 2(2) >> -63(ffffffc1) = 1(1)\n  signed 8 2(2) >> -62(ffffffc2) = 0(0)\n  signed 8 2(2) >> -61(ffffffc3) = 0(0)\n  signed 8 2(2) >> -60(ffffffc4) = 0(0)\n  signed 8 2(2) >> -59(ffffffc5) = 0(0)\n  signed 8 2(2) >> -58(ffffffc6) = 0(0)\n  signed 8 2(2) >> -57(ffffffc7) = 0(0)\n  signed 8 2(2) >> -56(ffffffc8) = 0(0)\n  signed 8 2(2) >> -55(ffffffc9) = 0(0)\n  signed 8 2(2) >> -54(ffffffca) = 0(0)\n  signed 8 2(2) >> -53(ffffffcb) = 0(0)\n  signed 8 2(2) >> -52(ffffffcc) = 0(0)\n  signed 8 2(2) >> -51(ffffffcd) = 0(0)\n  signed 8 2(2) >> -50(ffffffce) = 0(0)\n  signed 8 2(2) >> -49(ffffffcf) = 0(0)\n  signed 8 2(2) >> -48(ffffffd0) = 0(0)\n  signed 8 2(2) >> -47(ffffffd1) = 0(0)\n  signed 8 2(2) >> -46(ffffffd2) = 0(0)\n  signed 8 2(2) >> -45(ffffffd3) = 0(0)\n  signed 8 2(2) >> -44(ffffffd4) = 0(0)\n  signed 8 2(2) >> -43(ffffffd5) = 0(0)\n  signed 8 2(2) >> -42(ffffffd6) = 0(0)\n  signed 8 2(2) >> -41(ffffffd7) = 0(0)\n  signed 8 2(2) >> -40(ffffffd8) = 0(0)\n  signed 8 2(2) >> -39(ffffffd9) = 0(0)\n  signed 8 2(2) >> -38(ffffffda) = 0(0)\n  signed 8 2(2) >> -37(ffffffdb) = 0(0)\n  signed 8 2(2) >> -36(ffffffdc) = 0(0)\n  signed 8 2(2) >> -35(ffffffdd) = 0(0)\n  signed 8 2(2) >> -34(ffffffde) = 0(0)\n  signed 8 2(2) >> -33(ffffffdf) = 0(0)\n  signed 8 2(2) >> -32(ffffffe0) = 2(2)\n  signed 8 2(2) >> -31(ffffffe1) = 1(1)\n  signed 8 2(2) >> -30(ffffffe2) = 0(0)\n  signed 8 2(2) >> -29(ffffffe3) = 0(0)\n  signed 8 2(2) >> -28(ffffffe4) = 0(0)\n  signed 8 2(2) >> -27(ffffffe5) = 0(0)\n  signed 8 2(2) >> -26(ffffffe6) = 0(0)\n  signed 8 2(2) >> -25(ffffffe7) = 0(0)\n  signed 8 2(2) >> -24(ffffffe8) = 0(0)\n  signed 8 2(2) >> -23(ffffffe9) = 0(0)\n  signed 8 2(2) >> -22(ffffffea) = 0(0)\n  signed 8 2(2) >> -21(ffffffeb) = 0(0)\n  signed 8 2(2) >> -20(ffffffec) = 0(0)\n  signed 8 2(2) >> -19(ffffffed) = 0(0)\n  signed 8 2(2) >> -18(ffffffee) = 0(0)\n  signed 8 2(2) >> -17(ffffffef) = 0(0)\n  signed 8 2(2) >> -16(fffffff0) = 0(0)\n  signed 8 2(2) >> -15(fffffff1) = 0(0)\n  signed 8 2(2) >> -14(fffffff2) = 0(0)\n  signed 8 2(2) >> -13(fffffff3) = 0(0)\n  signed 8 2(2) >> -12(fffffff4) = 0(0)\n  signed 8 2(2) >> -11(fffffff5) = 0(0)\n  signed 8 2(2) >> -10(fffffff6) = 0(0)\n  signed 8 2(2) >> -9(fffffff7) = 0(0)\n  signed 8 2(2) >> -8(fffffff8) = 0(0)\n  signed 8 2(2) >> -7(fffffff9) = 0(0)\n  signed 8 2(2) >> -6(fffffffa) = 0(0)\n  signed 8 2(2) >> -5(fffffffb) = 0(0)\n  signed 8 2(2) >> -4(fffffffc) = 0(0)\n  signed 8 2(2) >> -3(fffffffd) = 0(0)\n  signed 8 2(2) >> -2(fffffffe) = 0(0)\n  signed 8 2(2) >> -1(ffffffff) = 0(0)\n  signed 8 2(2) >> 0(0) = 2(2)\n  signed 8 2(2) >> 1(1) = 1(1)\n  signed 8 2(2) >> 2(2) = 0(0)\n  signed 8 2(2) >> 3(3) = 0(0)\n  signed 8 2(2) >> 4(4) = 0(0)\n  signed 8 2(2) >> 5(5) = 0(0)\n  signed 8 2(2) >> 6(6) = 0(0)\n  signed 8 2(2) >> 7(7) = 0(0)\n  signed 8 2(2) >> 8(8) = 0(0)\n  signed 8 2(2) >> 9(9) = 0(0)\n  signed 8 2(2) >> 10(a) = 0(0)\n  signed 8 2(2) >> 11(b) = 0(0)\n  signed 8 2(2) >> 12(c) = 0(0)\n  signed 8 2(2) >> 13(d) = 0(0)\n  signed 8 2(2) >> 14(e) = 0(0)\n  signed 8 2(2) >> 15(f) = 0(0)\n  signed 8 2(2) >> 16(10) = 0(0)\n  signed 8 2(2) >> 17(11) = 0(0)\n  signed 8 2(2) >> 18(12) = 0(0)\n  signed 8 2(2) >> 19(13) = 0(0)\n  signed 8 2(2) >> 20(14) = 0(0)\n  signed 8 2(2) >> 21(15) = 0(0)\n  signed 8 2(2) >> 22(16) = 0(0)\n  signed 8 2(2) >> 23(17) = 0(0)\n  signed 8 2(2) >> 24(18) = 0(0)\n  signed 8 2(2) >> 25(19) = 0(0)\n  signed 8 2(2) >> 26(1a) = 0(0)\n  signed 8 2(2) >> 27(1b) = 0(0)\n  signed 8 2(2) >> 28(1c) = 0(0)\n  signed 8 2(2) >> 29(1d) = 0(0)\n  signed 8 2(2) >> 30(1e) = 0(0)\n  signed 8 2(2) >> 31(1f) = 0(0)\n  signed 8 2(2) >> 32(20) = 2(2)\n  signed 8 2(2) >> 33(21) = 1(1)\n  signed 8 2(2) >> 34(22) = 0(0)\n  signed 8 2(2) >> 35(23) = 0(0)\n  signed 8 2(2) >> 36(24) = 0(0)\n  signed 8 2(2) >> 37(25) = 0(0)\n  signed 8 2(2) >> 38(26) = 0(0)\n  signed 8 2(2) >> 39(27) = 0(0)\n  signed 8 2(2) >> 40(28) = 0(0)\n  signed 8 2(2) >> 41(29) = 0(0)\n  signed 8 2(2) >> 42(2a) = 0(0)\n  signed 8 2(2) >> 43(2b) = 0(0)\n  signed 8 2(2) >> 44(2c) = 0(0)\n  signed 8 2(2) >> 45(2d) = 0(0)\n  signed 8 2(2) >> 46(2e) = 0(0)\n  signed 8 2(2) >> 47(2f) = 0(0)\n  signed 8 2(2) >> 48(30) = 0(0)\n  signed 8 2(2) >> 49(31) = 0(0)\n  signed 8 2(2) >> 50(32) = 0(0)\n  signed 8 2(2) >> 51(33) = 0(0)\n  signed 8 2(2) >> 52(34) = 0(0)\n  signed 8 2(2) >> 53(35) = 0(0)\n  signed 8 2(2) >> 54(36) = 0(0)\n  signed 8 2(2) >> 55(37) = 0(0)\n  signed 8 2(2) >> 56(38) = 0(0)\n  signed 8 2(2) >> 57(39) = 0(0)\n  signed 8 2(2) >> 58(3a) = 0(0)\n  signed 8 2(2) >> 59(3b) = 0(0)\n  signed 8 2(2) >> 60(3c) = 0(0)\n  signed 8 2(2) >> 61(3d) = 0(0)\n  signed 8 2(2) >> 62(3e) = 0(0)\n  signed 8 2(2) >> 63(3f) = 0(0)\n  signed 8 2(2) >> 64(40) = 2(2)\n  signed 8 2(2) >> 65(41) = 1(1)\n  signed 8 2(2) >> 66(42) = 0(0)\n  signed 8 2(2) >> 67(43) = 0(0)\n  signed 8 2(2) >> 68(44) = 0(0)\n  signed 8 2(2) >> 69(45) = 0(0)\n  signed 8 2(2) >> 70(46) = 0(0)\n  signed 8 2(2) >> 71(47) = 0(0)\n  signed 8 2(2) >> 72(48) = 0(0)\n  signed 8 2(2) >> 73(49) = 0(0)\n  signed 8 2(2) >> 74(4a) = 0(0)\n  signed 8 2(2) >> 75(4b) = 0(0)\n  signed 8 2(2) >> 76(4c) = 0(0)\n  signed 8 2(2) >> 77(4d) = 0(0)\n  signed 8 2(2) >> 78(4e) = 0(0)\n  signed 8 2(2) >> 79(4f) = 0(0)\n  signed 8 2(2) >> 80(50) = 0(0)\n  signed 8 2(2) >> 81(51) = 0(0)\n  signed 8 2(2) >> 82(52) = 0(0)\n  signed 8 2(2) >> 83(53) = 0(0)\n  signed 8 2(2) >> 84(54) = 0(0)\n  signed 8 2(2) >> 85(55) = 0(0)\n  signed 8 2(2) >> 86(56) = 0(0)\n  signed 8 2(2) >> 87(57) = 0(0)\n  signed 8 2(2) >> 88(58) = 0(0)\n  signed 8 2(2) >> 89(59) = 0(0)\n  signed 8 2(2) >> 90(5a) = 0(0)\n  signed 8 2(2) >> 91(5b) = 0(0)\n  signed 8 2(2) >> 92(5c) = 0(0)\n  signed 8 2(2) >> 93(5d) = 0(0)\n  signed 8 2(2) >> 94(5e) = 0(0)\n  signed 8 2(2) >> 95(5f) = 0(0)\n  signed 8 2(2) >> 96(60) = 2(2)\n  signed 8 2(2) >> 97(61) = 1(1)\n  signed 8 2(2) >> 98(62) = 0(0)\n  signed 8 2(2) >> 99(63) = 0(0)\n  signed 8 2(2) >> 100(64) = 0(0)\n  signed 8 2(2) >> 101(65) = 0(0)\n  signed 8 2(2) >> 102(66) = 0(0)\n  signed 8 2(2) >> 103(67) = 0(0)\n  signed 8 2(2) >> 104(68) = 0(0)\n  signed 8 2(2) >> 105(69) = 0(0)\n  signed 8 2(2) >> 106(6a) = 0(0)\n  signed 8 2(2) >> 107(6b) = 0(0)\n  signed 8 2(2) >> 108(6c) = 0(0)\n  signed 8 2(2) >> 109(6d) = 0(0)\n  signed 8 2(2) >> 110(6e) = 0(0)\n  signed 8 2(2) >> 111(6f) = 0(0)\n  signed 8 2(2) >> 112(70) = 0(0)\n  signed 8 2(2) >> 113(71) = 0(0)\n  signed 8 2(2) >> 114(72) = 0(0)\n  signed 8 2(2) >> 115(73) = 0(0)\n  signed 8 2(2) >> 116(74) = 0(0)\n  signed 8 2(2) >> 117(75) = 0(0)\n  signed 8 2(2) >> 118(76) = 0(0)\n  signed 8 2(2) >> 119(77) = 0(0)\n  signed 8 2(2) >> 120(78) = 0(0)\n  signed 8 2(2) >> 121(79) = 0(0)\n  signed 8 2(2) >> 122(7a) = 0(0)\n  signed 8 2(2) >> 123(7b) = 0(0)\n  signed 8 2(2) >> 124(7c) = 0(0)\n  signed 8 2(2) >> 125(7d) = 0(0)\n  signed 8 2(2) >> 126(7e) = 0(0)\n  signed 8 2(2) >> 127(7f) = 0(0)\n  signed 8 3(3) >> -128(ffffff80) = 3(3)\n  signed 8 3(3) >> -127(ffffff81) = 1(1)\n  signed 8 3(3) >> -126(ffffff82) = 0(0)\n  signed 8 3(3) >> -125(ffffff83) = 0(0)\n  signed 8 3(3) >> -124(ffffff84) = 0(0)\n  signed 8 3(3) >> -123(ffffff85) = 0(0)\n  signed 8 3(3) >> -122(ffffff86) = 0(0)\n  signed 8 3(3) >> -121(ffffff87) = 0(0)\n  signed 8 3(3) >> -120(ffffff88) = 0(0)\n  signed 8 3(3) >> -119(ffffff89) = 0(0)\n  signed 8 3(3) >> -118(ffffff8a) = 0(0)\n  signed 8 3(3) >> -117(ffffff8b) = 0(0)\n  signed 8 3(3) >> -116(ffffff8c) = 0(0)\n  signed 8 3(3) >> -115(ffffff8d) = 0(0)\n  signed 8 3(3) >> -114(ffffff8e) = 0(0)\n  signed 8 3(3) >> -113(ffffff8f) = 0(0)\n  signed 8 3(3) >> -112(ffffff90) = 0(0)\n  signed 8 3(3) >> -111(ffffff91) = 0(0)\n  signed 8 3(3) >> -110(ffffff92) = 0(0)\n  signed 8 3(3) >> -109(ffffff93) = 0(0)\n  signed 8 3(3) >> -108(ffffff94) = 0(0)\n  signed 8 3(3) >> -107(ffffff95) = 0(0)\n  signed 8 3(3) >> -106(ffffff96) = 0(0)\n  signed 8 3(3) >> -105(ffffff97) = 0(0)\n  signed 8 3(3) >> -104(ffffff98) = 0(0)\n  signed 8 3(3) >> -103(ffffff99) = 0(0)\n  signed 8 3(3) >> -102(ffffff9a) = 0(0)\n  signed 8 3(3) >> -101(ffffff9b) = 0(0)\n  signed 8 3(3) >> -100(ffffff9c) = 0(0)\n  signed 8 3(3) >> -99(ffffff9d) = 0(0)\n  signed 8 3(3) >> -98(ffffff9e) = 0(0)\n  signed 8 3(3) >> -97(ffffff9f) = 0(0)\n  signed 8 3(3) >> -96(ffffffa0) = 3(3)\n  signed 8 3(3) >> -95(ffffffa1) = 1(1)\n  signed 8 3(3) >> -94(ffffffa2) = 0(0)\n  signed 8 3(3) >> -93(ffffffa3) = 0(0)\n  signed 8 3(3) >> -92(ffffffa4) = 0(0)\n  signed 8 3(3) >> -91(ffffffa5) = 0(0)\n  signed 8 3(3) >> -90(ffffffa6) = 0(0)\n  signed 8 3(3) >> -89(ffffffa7) = 0(0)\n  signed 8 3(3) >> -88(ffffffa8) = 0(0)\n  signed 8 3(3) >> -87(ffffffa9) = 0(0)\n  signed 8 3(3) >> -86(ffffffaa) = 0(0)\n  signed 8 3(3) >> -85(ffffffab) = 0(0)\n  signed 8 3(3) >> -84(ffffffac) = 0(0)\n  signed 8 3(3) >> -83(ffffffad) = 0(0)\n  signed 8 3(3) >> -82(ffffffae) = 0(0)\n  signed 8 3(3) >> -81(ffffffaf) = 0(0)\n  signed 8 3(3) >> -80(ffffffb0) = 0(0)\n  signed 8 3(3) >> -79(ffffffb1) = 0(0)\n  signed 8 3(3) >> -78(ffffffb2) = 0(0)\n  signed 8 3(3) >> -77(ffffffb3) = 0(0)\n  signed 8 3(3) >> -76(ffffffb4) = 0(0)\n  signed 8 3(3) >> -75(ffffffb5) = 0(0)\n  signed 8 3(3) >> -74(ffffffb6) = 0(0)\n  signed 8 3(3) >> -73(ffffffb7) = 0(0)\n  signed 8 3(3) >> -72(ffffffb8) = 0(0)\n  signed 8 3(3) >> -71(ffffffb9) = 0(0)\n  signed 8 3(3) >> -70(ffffffba) = 0(0)\n  signed 8 3(3) >> -69(ffffffbb) = 0(0)\n  signed 8 3(3) >> -68(ffffffbc) = 0(0)\n  signed 8 3(3) >> -67(ffffffbd) = 0(0)\n  signed 8 3(3) >> -66(ffffffbe) = 0(0)\n  signed 8 3(3) >> -65(ffffffbf) = 0(0)\n  signed 8 3(3) >> -64(ffffffc0) = 3(3)\n  signed 8 3(3) >> -63(ffffffc1) = 1(1)\n  signed 8 3(3) >> -62(ffffffc2) = 0(0)\n  signed 8 3(3) >> -61(ffffffc3) = 0(0)\n  signed 8 3(3) >> -60(ffffffc4) = 0(0)\n  signed 8 3(3) >> -59(ffffffc5) = 0(0)\n  signed 8 3(3) >> -58(ffffffc6) = 0(0)\n  signed 8 3(3) >> -57(ffffffc7) = 0(0)\n  signed 8 3(3) >> -56(ffffffc8) = 0(0)\n  signed 8 3(3) >> -55(ffffffc9) = 0(0)\n  signed 8 3(3) >> -54(ffffffca) = 0(0)\n  signed 8 3(3) >> -53(ffffffcb) = 0(0)\n  signed 8 3(3) >> -52(ffffffcc) = 0(0)\n  signed 8 3(3) >> -51(ffffffcd) = 0(0)\n  signed 8 3(3) >> -50(ffffffce) = 0(0)\n  signed 8 3(3) >> -49(ffffffcf) = 0(0)\n  signed 8 3(3) >> -48(ffffffd0) = 0(0)\n  signed 8 3(3) >> -47(ffffffd1) = 0(0)\n  signed 8 3(3) >> -46(ffffffd2) = 0(0)\n  signed 8 3(3) >> -45(ffffffd3) = 0(0)\n  signed 8 3(3) >> -44(ffffffd4) = 0(0)\n  signed 8 3(3) >> -43(ffffffd5) = 0(0)\n  signed 8 3(3) >> -42(ffffffd6) = 0(0)\n  signed 8 3(3) >> -41(ffffffd7) = 0(0)\n  signed 8 3(3) >> -40(ffffffd8) = 0(0)\n  signed 8 3(3) >> -39(ffffffd9) = 0(0)\n  signed 8 3(3) >> -38(ffffffda) = 0(0)\n  signed 8 3(3) >> -37(ffffffdb) = 0(0)\n  signed 8 3(3) >> -36(ffffffdc) = 0(0)\n  signed 8 3(3) >> -35(ffffffdd) = 0(0)\n  signed 8 3(3) >> -34(ffffffde) = 0(0)\n  signed 8 3(3) >> -33(ffffffdf) = 0(0)\n  signed 8 3(3) >> -32(ffffffe0) = 3(3)\n  signed 8 3(3) >> -31(ffffffe1) = 1(1)\n  signed 8 3(3) >> -30(ffffffe2) = 0(0)\n  signed 8 3(3) >> -29(ffffffe3) = 0(0)\n  signed 8 3(3) >> -28(ffffffe4) = 0(0)\n  signed 8 3(3) >> -27(ffffffe5) = 0(0)\n  signed 8 3(3) >> -26(ffffffe6) = 0(0)\n  signed 8 3(3) >> -25(ffffffe7) = 0(0)\n  signed 8 3(3) >> -24(ffffffe8) = 0(0)\n  signed 8 3(3) >> -23(ffffffe9) = 0(0)\n  signed 8 3(3) >> -22(ffffffea) = 0(0)\n  signed 8 3(3) >> -21(ffffffeb) = 0(0)\n  signed 8 3(3) >> -20(ffffffec) = 0(0)\n  signed 8 3(3) >> -19(ffffffed) = 0(0)\n  signed 8 3(3) >> -18(ffffffee) = 0(0)\n  signed 8 3(3) >> -17(ffffffef) = 0(0)\n  signed 8 3(3) >> -16(fffffff0) = 0(0)\n  signed 8 3(3) >> -15(fffffff1) = 0(0)\n  signed 8 3(3) >> -14(fffffff2) = 0(0)\n  signed 8 3(3) >> -13(fffffff3) = 0(0)\n  signed 8 3(3) >> -12(fffffff4) = 0(0)\n  signed 8 3(3) >> -11(fffffff5) = 0(0)\n  signed 8 3(3) >> -10(fffffff6) = 0(0)\n  signed 8 3(3) >> -9(fffffff7) = 0(0)\n  signed 8 3(3) >> -8(fffffff8) = 0(0)\n  signed 8 3(3) >> -7(fffffff9) = 0(0)\n  signed 8 3(3) >> -6(fffffffa) = 0(0)\n  signed 8 3(3) >> -5(fffffffb) = 0(0)\n  signed 8 3(3) >> -4(fffffffc) = 0(0)\n  signed 8 3(3) >> -3(fffffffd) = 0(0)\n  signed 8 3(3) >> -2(fffffffe) = 0(0)\n  signed 8 3(3) >> -1(ffffffff) = 0(0)\n  signed 8 3(3) >> 0(0) = 3(3)\n  signed 8 3(3) >> 1(1) = 1(1)\n  signed 8 3(3) >> 2(2) = 0(0)\n  signed 8 3(3) >> 3(3) = 0(0)\n  signed 8 3(3) >> 4(4) = 0(0)\n  signed 8 3(3) >> 5(5) = 0(0)\n  signed 8 3(3) >> 6(6) = 0(0)\n  signed 8 3(3) >> 7(7) = 0(0)\n  signed 8 3(3) >> 8(8) = 0(0)\n  signed 8 3(3) >> 9(9) = 0(0)\n  signed 8 3(3) >> 10(a) = 0(0)\n  signed 8 3(3) >> 11(b) = 0(0)\n  signed 8 3(3) >> 12(c) = 0(0)\n  signed 8 3(3) >> 13(d) = 0(0)\n  signed 8 3(3) >> 14(e) = 0(0)\n  signed 8 3(3) >> 15(f) = 0(0)\n  signed 8 3(3) >> 16(10) = 0(0)\n  signed 8 3(3) >> 17(11) = 0(0)\n  signed 8 3(3) >> 18(12) = 0(0)\n  signed 8 3(3) >> 19(13) = 0(0)\n  signed 8 3(3) >> 20(14) = 0(0)\n  signed 8 3(3) >> 21(15) = 0(0)\n  signed 8 3(3) >> 22(16) = 0(0)\n  signed 8 3(3) >> 23(17) = 0(0)\n  signed 8 3(3) >> 24(18) = 0(0)\n  signed 8 3(3) >> 25(19) = 0(0)\n  signed 8 3(3) >> 26(1a) = 0(0)\n  signed 8 3(3) >> 27(1b) = 0(0)\n  signed 8 3(3) >> 28(1c) = 0(0)\n  signed 8 3(3) >> 29(1d) = 0(0)\n  signed 8 3(3) >> 30(1e) = 0(0)\n  signed 8 3(3) >> 31(1f) = 0(0)\n  signed 8 3(3) >> 32(20) = 3(3)\n  signed 8 3(3) >> 33(21) = 1(1)\n  signed 8 3(3) >> 34(22) = 0(0)\n  signed 8 3(3) >> 35(23) = 0(0)\n  signed 8 3(3) >> 36(24) = 0(0)\n  signed 8 3(3) >> 37(25) = 0(0)\n  signed 8 3(3) >> 38(26) = 0(0)\n  signed 8 3(3) >> 39(27) = 0(0)\n  signed 8 3(3) >> 40(28) = 0(0)\n  signed 8 3(3) >> 41(29) = 0(0)\n  signed 8 3(3) >> 42(2a) = 0(0)\n  signed 8 3(3) >> 43(2b) = 0(0)\n  signed 8 3(3) >> 44(2c) = 0(0)\n  signed 8 3(3) >> 45(2d) = 0(0)\n  signed 8 3(3) >> 46(2e) = 0(0)\n  signed 8 3(3) >> 47(2f) = 0(0)\n  signed 8 3(3) >> 48(30) = 0(0)\n  signed 8 3(3) >> 49(31) = 0(0)\n  signed 8 3(3) >> 50(32) = 0(0)\n  signed 8 3(3) >> 51(33) = 0(0)\n  signed 8 3(3) >> 52(34) = 0(0)\n  signed 8 3(3) >> 53(35) = 0(0)\n  signed 8 3(3) >> 54(36) = 0(0)\n  signed 8 3(3) >> 55(37) = 0(0)\n  signed 8 3(3) >> 56(38) = 0(0)\n  signed 8 3(3) >> 57(39) = 0(0)\n  signed 8 3(3) >> 58(3a) = 0(0)\n  signed 8 3(3) >> 59(3b) = 0(0)\n  signed 8 3(3) >> 60(3c) = 0(0)\n  signed 8 3(3) >> 61(3d) = 0(0)\n  signed 8 3(3) >> 62(3e) = 0(0)\n  signed 8 3(3) >> 63(3f) = 0(0)\n  signed 8 3(3) >> 64(40) = 3(3)\n  signed 8 3(3) >> 65(41) = 1(1)\n  signed 8 3(3) >> 66(42) = 0(0)\n  signed 8 3(3) >> 67(43) = 0(0)\n  signed 8 3(3) >> 68(44) = 0(0)\n  signed 8 3(3) >> 69(45) = 0(0)\n  signed 8 3(3) >> 70(46) = 0(0)\n  signed 8 3(3) >> 71(47) = 0(0)\n  signed 8 3(3) >> 72(48) = 0(0)\n  signed 8 3(3) >> 73(49) = 0(0)\n  signed 8 3(3) >> 74(4a) = 0(0)\n  signed 8 3(3) >> 75(4b) = 0(0)\n  signed 8 3(3) >> 76(4c) = 0(0)\n  signed 8 3(3) >> 77(4d) = 0(0)\n  signed 8 3(3) >> 78(4e) = 0(0)\n  signed 8 3(3) >> 79(4f) = 0(0)\n  signed 8 3(3) >> 80(50) = 0(0)\n  signed 8 3(3) >> 81(51) = 0(0)\n  signed 8 3(3) >> 82(52) = 0(0)\n  signed 8 3(3) >> 83(53) = 0(0)\n  signed 8 3(3) >> 84(54) = 0(0)\n  signed 8 3(3) >> 85(55) = 0(0)\n  signed 8 3(3) >> 86(56) = 0(0)\n  signed 8 3(3) >> 87(57) = 0(0)\n  signed 8 3(3) >> 88(58) = 0(0)\n  signed 8 3(3) >> 89(59) = 0(0)\n  signed 8 3(3) >> 90(5a) = 0(0)\n  signed 8 3(3) >> 91(5b) = 0(0)\n  signed 8 3(3) >> 92(5c) = 0(0)\n  signed 8 3(3) >> 93(5d) = 0(0)\n  signed 8 3(3) >> 94(5e) = 0(0)\n  signed 8 3(3) >> 95(5f) = 0(0)\n  signed 8 3(3) >> 96(60) = 3(3)\n  signed 8 3(3) >> 97(61) = 1(1)\n  signed 8 3(3) >> 98(62) = 0(0)\n  signed 8 3(3) >> 99(63) = 0(0)\n  signed 8 3(3) >> 100(64) = 0(0)\n  signed 8 3(3) >> 101(65) = 0(0)\n  signed 8 3(3) >> 102(66) = 0(0)\n  signed 8 3(3) >> 103(67) = 0(0)\n  signed 8 3(3) >> 104(68) = 0(0)\n  signed 8 3(3) >> 105(69) = 0(0)\n  signed 8 3(3) >> 106(6a) = 0(0)\n  signed 8 3(3) >> 107(6b) = 0(0)\n  signed 8 3(3) >> 108(6c) = 0(0)\n  signed 8 3(3) >> 109(6d) = 0(0)\n  signed 8 3(3) >> 110(6e) = 0(0)\n  signed 8 3(3) >> 111(6f) = 0(0)\n  signed 8 3(3) >> 112(70) = 0(0)\n  signed 8 3(3) >> 113(71) = 0(0)\n  signed 8 3(3) >> 114(72) = 0(0)\n  signed 8 3(3) >> 115(73) = 0(0)\n  signed 8 3(3) >> 116(74) = 0(0)\n  signed 8 3(3) >> 117(75) = 0(0)\n  signed 8 3(3) >> 118(76) = 0(0)\n  signed 8 3(3) >> 119(77) = 0(0)\n  signed 8 3(3) >> 120(78) = 0(0)\n  signed 8 3(3) >> 121(79) = 0(0)\n  signed 8 3(3) >> 122(7a) = 0(0)\n  signed 8 3(3) >> 123(7b) = 0(0)\n  signed 8 3(3) >> 124(7c) = 0(0)\n  signed 8 3(3) >> 125(7d) = 0(0)\n  signed 8 3(3) >> 126(7e) = 0(0)\n  signed 8 3(3) >> 127(7f) = 0(0)\n  signed 8 4(4) >> -128(ffffff80) = 4(4)\n  signed 8 4(4) >> -127(ffffff81) = 2(2)\n  signed 8 4(4) >> -126(ffffff82) = 1(1)\n  signed 8 4(4) >> -125(ffffff83) = 0(0)\n  signed 8 4(4) >> -124(ffffff84) = 0(0)\n  signed 8 4(4) >> -123(ffffff85) = 0(0)\n  signed 8 4(4) >> -122(ffffff86) = 0(0)\n  signed 8 4(4) >> -121(ffffff87) = 0(0)\n  signed 8 4(4) >> -120(ffffff88) = 0(0)\n  signed 8 4(4) >> -119(ffffff89) = 0(0)\n  signed 8 4(4) >> -118(ffffff8a) = 0(0)\n  signed 8 4(4) >> -117(ffffff8b) = 0(0)\n  signed 8 4(4) >> -116(ffffff8c) = 0(0)\n  signed 8 4(4) >> -115(ffffff8d) = 0(0)\n  signed 8 4(4) >> -114(ffffff8e) = 0(0)\n  signed 8 4(4) >> -113(ffffff8f) = 0(0)\n  signed 8 4(4) >> -112(ffffff90) = 0(0)\n  signed 8 4(4) >> -111(ffffff91) = 0(0)\n  signed 8 4(4) >> -110(ffffff92) = 0(0)\n  signed 8 4(4) >> -109(ffffff93) = 0(0)\n  signed 8 4(4) >> -108(ffffff94) = 0(0)\n  signed 8 4(4) >> -107(ffffff95) = 0(0)\n  signed 8 4(4) >> -106(ffffff96) = 0(0)\n  signed 8 4(4) >> -105(ffffff97) = 0(0)\n  signed 8 4(4) >> -104(ffffff98) = 0(0)\n  signed 8 4(4) >> -103(ffffff99) = 0(0)\n  signed 8 4(4) >> -102(ffffff9a) = 0(0)\n  signed 8 4(4) >> -101(ffffff9b) = 0(0)\n  signed 8 4(4) >> -100(ffffff9c) = 0(0)\n  signed 8 4(4) >> -99(ffffff9d) = 0(0)\n  signed 8 4(4) >> -98(ffffff9e) = 0(0)\n  signed 8 4(4) >> -97(ffffff9f) = 0(0)\n  signed 8 4(4) >> -96(ffffffa0) = 4(4)\n  signed 8 4(4) >> -95(ffffffa1) = 2(2)\n  signed 8 4(4) >> -94(ffffffa2) = 1(1)\n  signed 8 4(4) >> -93(ffffffa3) = 0(0)\n  signed 8 4(4) >> -92(ffffffa4) = 0(0)\n  signed 8 4(4) >> -91(ffffffa5) = 0(0)\n  signed 8 4(4) >> -90(ffffffa6) = 0(0)\n  signed 8 4(4) >> -89(ffffffa7) = 0(0)\n  signed 8 4(4) >> -88(ffffffa8) = 0(0)\n  signed 8 4(4) >> -87(ffffffa9) = 0(0)\n  signed 8 4(4) >> -86(ffffffaa) = 0(0)\n  signed 8 4(4) >> -85(ffffffab) = 0(0)\n  signed 8 4(4) >> -84(ffffffac) = 0(0)\n  signed 8 4(4) >> -83(ffffffad) = 0(0)\n  signed 8 4(4) >> -82(ffffffae) = 0(0)\n  signed 8 4(4) >> -81(ffffffaf) = 0(0)\n  signed 8 4(4) >> -80(ffffffb0) = 0(0)\n  signed 8 4(4) >> -79(ffffffb1) = 0(0)\n  signed 8 4(4) >> -78(ffffffb2) = 0(0)\n  signed 8 4(4) >> -77(ffffffb3) = 0(0)\n  signed 8 4(4) >> -76(ffffffb4) = 0(0)\n  signed 8 4(4) >> -75(ffffffb5) = 0(0)\n  signed 8 4(4) >> -74(ffffffb6) = 0(0)\n  signed 8 4(4) >> -73(ffffffb7) = 0(0)\n  signed 8 4(4) >> -72(ffffffb8) = 0(0)\n  signed 8 4(4) >> -71(ffffffb9) = 0(0)\n  signed 8 4(4) >> -70(ffffffba) = 0(0)\n  signed 8 4(4) >> -69(ffffffbb) = 0(0)\n  signed 8 4(4) >> -68(ffffffbc) = 0(0)\n  signed 8 4(4) >> -67(ffffffbd) = 0(0)\n  signed 8 4(4) >> -66(ffffffbe) = 0(0)\n  signed 8 4(4) >> -65(ffffffbf) = 0(0)\n  signed 8 4(4) >> -64(ffffffc0) = 4(4)\n  signed 8 4(4) >> -63(ffffffc1) = 2(2)\n  signed 8 4(4) >> -62(ffffffc2) = 1(1)\n  signed 8 4(4) >> -61(ffffffc3) = 0(0)\n  signed 8 4(4) >> -60(ffffffc4) = 0(0)\n  signed 8 4(4) >> -59(ffffffc5) = 0(0)\n  signed 8 4(4) >> -58(ffffffc6) = 0(0)\n  signed 8 4(4) >> -57(ffffffc7) = 0(0)\n  signed 8 4(4) >> -56(ffffffc8) = 0(0)\n  signed 8 4(4) >> -55(ffffffc9) = 0(0)\n  signed 8 4(4) >> -54(ffffffca) = 0(0)\n  signed 8 4(4) >> -53(ffffffcb) = 0(0)\n  signed 8 4(4) >> -52(ffffffcc) = 0(0)\n  signed 8 4(4) >> -51(ffffffcd) = 0(0)\n  signed 8 4(4) >> -50(ffffffce) = 0(0)\n  signed 8 4(4) >> -49(ffffffcf) = 0(0)\n  signed 8 4(4) >> -48(ffffffd0) = 0(0)\n  signed 8 4(4) >> -47(ffffffd1) = 0(0)\n  signed 8 4(4) >> -46(ffffffd2) = 0(0)\n  signed 8 4(4) >> -45(ffffffd3) = 0(0)\n  signed 8 4(4) >> -44(ffffffd4) = 0(0)\n  signed 8 4(4) >> -43(ffffffd5) = 0(0)\n  signed 8 4(4) >> -42(ffffffd6) = 0(0)\n  signed 8 4(4) >> -41(ffffffd7) = 0(0)\n  signed 8 4(4) >> -40(ffffffd8) = 0(0)\n  signed 8 4(4) >> -39(ffffffd9) = 0(0)\n  signed 8 4(4) >> -38(ffffffda) = 0(0)\n  signed 8 4(4) >> -37(ffffffdb) = 0(0)\n  signed 8 4(4) >> -36(ffffffdc) = 0(0)\n  signed 8 4(4) >> -35(ffffffdd) = 0(0)\n  signed 8 4(4) >> -34(ffffffde) = 0(0)\n  signed 8 4(4) >> -33(ffffffdf) = 0(0)\n  signed 8 4(4) >> -32(ffffffe0) = 4(4)\n  signed 8 4(4) >> -31(ffffffe1) = 2(2)\n  signed 8 4(4) >> -30(ffffffe2) = 1(1)\n  signed 8 4(4) >> -29(ffffffe3) = 0(0)\n  signed 8 4(4) >> -28(ffffffe4) = 0(0)\n  signed 8 4(4) >> -27(ffffffe5) = 0(0)\n  signed 8 4(4) >> -26(ffffffe6) = 0(0)\n  signed 8 4(4) >> -25(ffffffe7) = 0(0)\n  signed 8 4(4) >> -24(ffffffe8) = 0(0)\n  signed 8 4(4) >> -23(ffffffe9) = 0(0)\n  signed 8 4(4) >> -22(ffffffea) = 0(0)\n  signed 8 4(4) >> -21(ffffffeb) = 0(0)\n  signed 8 4(4) >> -20(ffffffec) = 0(0)\n  signed 8 4(4) >> -19(ffffffed) = 0(0)\n  signed 8 4(4) >> -18(ffffffee) = 0(0)\n  signed 8 4(4) >> -17(ffffffef) = 0(0)\n  signed 8 4(4) >> -16(fffffff0) = 0(0)\n  signed 8 4(4) >> -15(fffffff1) = 0(0)\n  signed 8 4(4) >> -14(fffffff2) = 0(0)\n  signed 8 4(4) >> -13(fffffff3) = 0(0)\n  signed 8 4(4) >> -12(fffffff4) = 0(0)\n  signed 8 4(4) >> -11(fffffff5) = 0(0)\n  signed 8 4(4) >> -10(fffffff6) = 0(0)\n  signed 8 4(4) >> -9(fffffff7) = 0(0)\n  signed 8 4(4) >> -8(fffffff8) = 0(0)\n  signed 8 4(4) >> -7(fffffff9) = 0(0)\n  signed 8 4(4) >> -6(fffffffa) = 0(0)\n  signed 8 4(4) >> -5(fffffffb) = 0(0)\n  signed 8 4(4) >> -4(fffffffc) = 0(0)\n  signed 8 4(4) >> -3(fffffffd) = 0(0)\n  signed 8 4(4) >> -2(fffffffe) = 0(0)\n  signed 8 4(4) >> -1(ffffffff) = 0(0)\n  signed 8 4(4) >> 0(0) = 4(4)\n  signed 8 4(4) >> 1(1) = 2(2)\n  signed 8 4(4) >> 2(2) = 1(1)\n  signed 8 4(4) >> 3(3) = 0(0)\n  signed 8 4(4) >> 4(4) = 0(0)\n  signed 8 4(4) >> 5(5) = 0(0)\n  signed 8 4(4) >> 6(6) = 0(0)\n  signed 8 4(4) >> 7(7) = 0(0)\n  signed 8 4(4) >> 8(8) = 0(0)\n  signed 8 4(4) >> 9(9) = 0(0)\n  signed 8 4(4) >> 10(a) = 0(0)\n  signed 8 4(4) >> 11(b) = 0(0)\n  signed 8 4(4) >> 12(c) = 0(0)\n  signed 8 4(4) >> 13(d) = 0(0)\n  signed 8 4(4) >> 14(e) = 0(0)\n  signed 8 4(4) >> 15(f) = 0(0)\n  signed 8 4(4) >> 16(10) = 0(0)\n  signed 8 4(4) >> 17(11) = 0(0)\n  signed 8 4(4) >> 18(12) = 0(0)\n  signed 8 4(4) >> 19(13) = 0(0)\n  signed 8 4(4) >> 20(14) = 0(0)\n  signed 8 4(4) >> 21(15) = 0(0)\n  signed 8 4(4) >> 22(16) = 0(0)\n  signed 8 4(4) >> 23(17) = 0(0)\n  signed 8 4(4) >> 24(18) = 0(0)\n  signed 8 4(4) >> 25(19) = 0(0)\n  signed 8 4(4) >> 26(1a) = 0(0)\n  signed 8 4(4) >> 27(1b) = 0(0)\n  signed 8 4(4) >> 28(1c) = 0(0)\n  signed 8 4(4) >> 29(1d) = 0(0)\n  signed 8 4(4) >> 30(1e) = 0(0)\n  signed 8 4(4) >> 31(1f) = 0(0)\n  signed 8 4(4) >> 32(20) = 4(4)\n  signed 8 4(4) >> 33(21) = 2(2)\n  signed 8 4(4) >> 34(22) = 1(1)\n  signed 8 4(4) >> 35(23) = 0(0)\n  signed 8 4(4) >> 36(24) = 0(0)\n  signed 8 4(4) >> 37(25) = 0(0)\n  signed 8 4(4) >> 38(26) = 0(0)\n  signed 8 4(4) >> 39(27) = 0(0)\n  signed 8 4(4) >> 40(28) = 0(0)\n  signed 8 4(4) >> 41(29) = 0(0)\n  signed 8 4(4) >> 42(2a) = 0(0)\n  signed 8 4(4) >> 43(2b) = 0(0)\n  signed 8 4(4) >> 44(2c) = 0(0)\n  signed 8 4(4) >> 45(2d) = 0(0)\n  signed 8 4(4) >> 46(2e) = 0(0)\n  signed 8 4(4) >> 47(2f) = 0(0)\n  signed 8 4(4) >> 48(30) = 0(0)\n  signed 8 4(4) >> 49(31) = 0(0)\n  signed 8 4(4) >> 50(32) = 0(0)\n  signed 8 4(4) >> 51(33) = 0(0)\n  signed 8 4(4) >> 52(34) = 0(0)\n  signed 8 4(4) >> 53(35) = 0(0)\n  signed 8 4(4) >> 54(36) = 0(0)\n  signed 8 4(4) >> 55(37) = 0(0)\n  signed 8 4(4) >> 56(38) = 0(0)\n  signed 8 4(4) >> 57(39) = 0(0)\n  signed 8 4(4) >> 58(3a) = 0(0)\n  signed 8 4(4) >> 59(3b) = 0(0)\n  signed 8 4(4) >> 60(3c) = 0(0)\n  signed 8 4(4) >> 61(3d) = 0(0)\n  signed 8 4(4) >> 62(3e) = 0(0)\n  signed 8 4(4) >> 63(3f) = 0(0)\n  signed 8 4(4) >> 64(40) = 4(4)\n  signed 8 4(4) >> 65(41) = 2(2)\n  signed 8 4(4) >> 66(42) = 1(1)\n  signed 8 4(4) >> 67(43) = 0(0)\n  signed 8 4(4) >> 68(44) = 0(0)\n  signed 8 4(4) >> 69(45) = 0(0)\n  signed 8 4(4) >> 70(46) = 0(0)\n  signed 8 4(4) >> 71(47) = 0(0)\n  signed 8 4(4) >> 72(48) = 0(0)\n  signed 8 4(4) >> 73(49) = 0(0)\n  signed 8 4(4) >> 74(4a) = 0(0)\n  signed 8 4(4) >> 75(4b) = 0(0)\n  signed 8 4(4) >> 76(4c) = 0(0)\n  signed 8 4(4) >> 77(4d) = 0(0)\n  signed 8 4(4) >> 78(4e) = 0(0)\n  signed 8 4(4) >> 79(4f) = 0(0)\n  signed 8 4(4) >> 80(50) = 0(0)\n  signed 8 4(4) >> 81(51) = 0(0)\n  signed 8 4(4) >> 82(52) = 0(0)\n  signed 8 4(4) >> 83(53) = 0(0)\n  signed 8 4(4) >> 84(54) = 0(0)\n  signed 8 4(4) >> 85(55) = 0(0)\n  signed 8 4(4) >> 86(56) = 0(0)\n  signed 8 4(4) >> 87(57) = 0(0)\n  signed 8 4(4) >> 88(58) = 0(0)\n  signed 8 4(4) >> 89(59) = 0(0)\n  signed 8 4(4) >> 90(5a) = 0(0)\n  signed 8 4(4) >> 91(5b) = 0(0)\n  signed 8 4(4) >> 92(5c) = 0(0)\n  signed 8 4(4) >> 93(5d) = 0(0)\n  signed 8 4(4) >> 94(5e) = 0(0)\n  signed 8 4(4) >> 95(5f) = 0(0)\n  signed 8 4(4) >> 96(60) = 4(4)\n  signed 8 4(4) >> 97(61) = 2(2)\n  signed 8 4(4) >> 98(62) = 1(1)\n  signed 8 4(4) >> 99(63) = 0(0)\n  signed 8 4(4) >> 100(64) = 0(0)\n  signed 8 4(4) >> 101(65) = 0(0)\n  signed 8 4(4) >> 102(66) = 0(0)\n  signed 8 4(4) >> 103(67) = 0(0)\n  signed 8 4(4) >> 104(68) = 0(0)\n  signed 8 4(4) >> 105(69) = 0(0)\n  signed 8 4(4) >> 106(6a) = 0(0)\n  signed 8 4(4) >> 107(6b) = 0(0)\n  signed 8 4(4) >> 108(6c) = 0(0)\n  signed 8 4(4) >> 109(6d) = 0(0)\n  signed 8 4(4) >> 110(6e) = 0(0)\n  signed 8 4(4) >> 111(6f) = 0(0)\n  signed 8 4(4) >> 112(70) = 0(0)\n  signed 8 4(4) >> 113(71) = 0(0)\n  signed 8 4(4) >> 114(72) = 0(0)\n  signed 8 4(4) >> 115(73) = 0(0)\n  signed 8 4(4) >> 116(74) = 0(0)\n  signed 8 4(4) >> 117(75) = 0(0)\n  signed 8 4(4) >> 118(76) = 0(0)\n  signed 8 4(4) >> 119(77) = 0(0)\n  signed 8 4(4) >> 120(78) = 0(0)\n  signed 8 4(4) >> 121(79) = 0(0)\n  signed 8 4(4) >> 122(7a) = 0(0)\n  signed 8 4(4) >> 123(7b) = 0(0)\n  signed 8 4(4) >> 124(7c) = 0(0)\n  signed 8 4(4) >> 125(7d) = 0(0)\n  signed 8 4(4) >> 126(7e) = 0(0)\n  signed 8 4(4) >> 127(7f) = 0(0)\nunsigned 8 0(0) >> -128(ffffff80) = 0(0)\nunsigned 8 0(0) >> -127(ffffff81) = 0(0)\nunsigned 8 0(0) >> -126(ffffff82) = 0(0)\nunsigned 8 0(0) >> -125(ffffff83) = 0(0)\nunsigned 8 0(0) >> -124(ffffff84) = 0(0)\nunsigned 8 0(0) >> -123(ffffff85) = 0(0)\nunsigned 8 0(0) >> -122(ffffff86) = 0(0)\nunsigned 8 0(0) >> -121(ffffff87) = 0(0)\nunsigned 8 0(0) >> -120(ffffff88) = 0(0)\nunsigned 8 0(0) >> -119(ffffff89) = 0(0)\nunsigned 8 0(0) >> -118(ffffff8a) = 0(0)\nunsigned 8 0(0) >> -117(ffffff8b) = 0(0)\nunsigned 8 0(0) >> -116(ffffff8c) = 0(0)\nunsigned 8 0(0) >> -115(ffffff8d) = 0(0)\nunsigned 8 0(0) >> -114(ffffff8e) = 0(0)\nunsigned 8 0(0) >> -113(ffffff8f) = 0(0)\nunsigned 8 0(0) >> -112(ffffff90) = 0(0)\nunsigned 8 0(0) >> -111(ffffff91) = 0(0)\nunsigned 8 0(0) >> -110(ffffff92) = 0(0)\nunsigned 8 0(0) >> -109(ffffff93) = 0(0)\nunsigned 8 0(0) >> -108(ffffff94) = 0(0)\nunsigned 8 0(0) >> -107(ffffff95) = 0(0)\nunsigned 8 0(0) >> -106(ffffff96) = 0(0)\nunsigned 8 0(0) >> -105(ffffff97) = 0(0)\nunsigned 8 0(0) >> -104(ffffff98) = 0(0)\nunsigned 8 0(0) >> -103(ffffff99) = 0(0)\nunsigned 8 0(0) >> -102(ffffff9a) = 0(0)\nunsigned 8 0(0) >> -101(ffffff9b) = 0(0)\nunsigned 8 0(0) >> -100(ffffff9c) = 0(0)\nunsigned 8 0(0) >> -99(ffffff9d) = 0(0)\nunsigned 8 0(0) >> -98(ffffff9e) = 0(0)\nunsigned 8 0(0) >> -97(ffffff9f) = 0(0)\nunsigned 8 0(0) >> -96(ffffffa0) = 0(0)\nunsigned 8 0(0) >> -95(ffffffa1) = 0(0)\nunsigned 8 0(0) >> -94(ffffffa2) = 0(0)\nunsigned 8 0(0) >> -93(ffffffa3) = 0(0)\nunsigned 8 0(0) >> -92(ffffffa4) = 0(0)\nunsigned 8 0(0) >> -91(ffffffa5) = 0(0)\nunsigned 8 0(0) >> -90(ffffffa6) = 0(0)\nunsigned 8 0(0) >> -89(ffffffa7) = 0(0)\nunsigned 8 0(0) >> -88(ffffffa8) = 0(0)\nunsigned 8 0(0) >> -87(ffffffa9) = 0(0)\nunsigned 8 0(0) >> -86(ffffffaa) = 0(0)\nunsigned 8 0(0) >> -85(ffffffab) = 0(0)\nunsigned 8 0(0) >> -84(ffffffac) = 0(0)\nunsigned 8 0(0) >> -83(ffffffad) = 0(0)\nunsigned 8 0(0) >> -82(ffffffae) = 0(0)\nunsigned 8 0(0) >> -81(ffffffaf) = 0(0)\nunsigned 8 0(0) >> -80(ffffffb0) = 0(0)\nunsigned 8 0(0) >> -79(ffffffb1) = 0(0)\nunsigned 8 0(0) >> -78(ffffffb2) = 0(0)\nunsigned 8 0(0) >> -77(ffffffb3) = 0(0)\nunsigned 8 0(0) >> -76(ffffffb4) = 0(0)\nunsigned 8 0(0) >> -75(ffffffb5) = 0(0)\nunsigned 8 0(0) >> -74(ffffffb6) = 0(0)\nunsigned 8 0(0) >> -73(ffffffb7) = 0(0)\nunsigned 8 0(0) >> -72(ffffffb8) = 0(0)\nunsigned 8 0(0) >> -71(ffffffb9) = 0(0)\nunsigned 8 0(0) >> -70(ffffffba) = 0(0)\nunsigned 8 0(0) >> -69(ffffffbb) = 0(0)\nunsigned 8 0(0) >> -68(ffffffbc) = 0(0)\nunsigned 8 0(0) >> -67(ffffffbd) = 0(0)\nunsigned 8 0(0) >> -66(ffffffbe) = 0(0)\nunsigned 8 0(0) >> -65(ffffffbf) = 0(0)\nunsigned 8 0(0) >> -64(ffffffc0) = 0(0)\nunsigned 8 0(0) >> -63(ffffffc1) = 0(0)\nunsigned 8 0(0) >> -62(ffffffc2) = 0(0)\nunsigned 8 0(0) >> -61(ffffffc3) = 0(0)\nunsigned 8 0(0) >> -60(ffffffc4) = 0(0)\nunsigned 8 0(0) >> -59(ffffffc5) = 0(0)\nunsigned 8 0(0) >> -58(ffffffc6) = 0(0)\nunsigned 8 0(0) >> -57(ffffffc7) = 0(0)\nunsigned 8 0(0) >> -56(ffffffc8) = 0(0)\nunsigned 8 0(0) >> -55(ffffffc9) = 0(0)\nunsigned 8 0(0) >> -54(ffffffca) = 0(0)\nunsigned 8 0(0) >> -53(ffffffcb) = 0(0)\nunsigned 8 0(0) >> -52(ffffffcc) = 0(0)\nunsigned 8 0(0) >> -51(ffffffcd) = 0(0)\nunsigned 8 0(0) >> -50(ffffffce) = 0(0)\nunsigned 8 0(0) >> -49(ffffffcf) = 0(0)\nunsigned 8 0(0) >> -48(ffffffd0) = 0(0)\nunsigned 8 0(0) >> -47(ffffffd1) = 0(0)\nunsigned 8 0(0) >> -46(ffffffd2) = 0(0)\nunsigned 8 0(0) >> -45(ffffffd3) = 0(0)\nunsigned 8 0(0) >> -44(ffffffd4) = 0(0)\nunsigned 8 0(0) >> -43(ffffffd5) = 0(0)\nunsigned 8 0(0) >> -42(ffffffd6) = 0(0)\nunsigned 8 0(0) >> -41(ffffffd7) = 0(0)\nunsigned 8 0(0) >> -40(ffffffd8) = 0(0)\nunsigned 8 0(0) >> -39(ffffffd9) = 0(0)\nunsigned 8 0(0) >> -38(ffffffda) = 0(0)\nunsigned 8 0(0) >> -37(ffffffdb) = 0(0)\nunsigned 8 0(0) >> -36(ffffffdc) = 0(0)\nunsigned 8 0(0) >> -35(ffffffdd) = 0(0)\nunsigned 8 0(0) >> -34(ffffffde) = 0(0)\nunsigned 8 0(0) >> -33(ffffffdf) = 0(0)\nunsigned 8 0(0) >> -32(ffffffe0) = 0(0)\nunsigned 8 0(0) >> -31(ffffffe1) = 0(0)\nunsigned 8 0(0) >> -30(ffffffe2) = 0(0)\nunsigned 8 0(0) >> -29(ffffffe3) = 0(0)\nunsigned 8 0(0) >> -28(ffffffe4) = 0(0)\nunsigned 8 0(0) >> -27(ffffffe5) = 0(0)\nunsigned 8 0(0) >> -26(ffffffe6) = 0(0)\nunsigned 8 0(0) >> -25(ffffffe7) = 0(0)\nunsigned 8 0(0) >> -24(ffffffe8) = 0(0)\nunsigned 8 0(0) >> -23(ffffffe9) = 0(0)\nunsigned 8 0(0) >> -22(ffffffea) = 0(0)\nunsigned 8 0(0) >> -21(ffffffeb) = 0(0)\nunsigned 8 0(0) >> -20(ffffffec) = 0(0)\nunsigned 8 0(0) >> -19(ffffffed) = 0(0)\nunsigned 8 0(0) >> -18(ffffffee) = 0(0)\nunsigned 8 0(0) >> -17(ffffffef) = 0(0)\nunsigned 8 0(0) >> -16(fffffff0) = 0(0)\nunsigned 8 0(0) >> -15(fffffff1) = 0(0)\nunsigned 8 0(0) >> -14(fffffff2) = 0(0)\nunsigned 8 0(0) >> -13(fffffff3) = 0(0)\nunsigned 8 0(0) >> -12(fffffff4) = 0(0)\nunsigned 8 0(0) >> -11(fffffff5) = 0(0)\nunsigned 8 0(0) >> -10(fffffff6) = 0(0)\nunsigned 8 0(0) >> -9(fffffff7) = 0(0)\nunsigned 8 0(0) >> -8(fffffff8) = 0(0)\nunsigned 8 0(0) >> -7(fffffff9) = 0(0)\nunsigned 8 0(0) >> -6(fffffffa) = 0(0)\nunsigned 8 0(0) >> -5(fffffffb) = 0(0)\nunsigned 8 0(0) >> -4(fffffffc) = 0(0)\nunsigned 8 0(0) >> -3(fffffffd) = 0(0)\nunsigned 8 0(0) >> -2(fffffffe) = 0(0)\nunsigned 8 0(0) >> -1(ffffffff) = 0(0)\nunsigned 8 0(0) >> 0(0) = 0(0)\nunsigned 8 0(0) >> 1(1) = 0(0)\nunsigned 8 0(0) >> 2(2) = 0(0)\nunsigned 8 0(0) >> 3(3) = 0(0)\nunsigned 8 0(0) >> 4(4) = 0(0)\nunsigned 8 0(0) >> 5(5) = 0(0)\nunsigned 8 0(0) >> 6(6) = 0(0)\nunsigned 8 0(0) >> 7(7) = 0(0)\nunsigned 8 0(0) >> 8(8) = 0(0)\nunsigned 8 0(0) >> 9(9) = 0(0)\nunsigned 8 0(0) >> 10(a) = 0(0)\nunsigned 8 0(0) >> 11(b) = 0(0)\nunsigned 8 0(0) >> 12(c) = 0(0)\nunsigned 8 0(0) >> 13(d) = 0(0)\nunsigned 8 0(0) >> 14(e) = 0(0)\nunsigned 8 0(0) >> 15(f) = 0(0)\nunsigned 8 0(0) >> 16(10) = 0(0)\nunsigned 8 0(0) >> 17(11) = 0(0)\nunsigned 8 0(0) >> 18(12) = 0(0)\nunsigned 8 0(0) >> 19(13) = 0(0)\nunsigned 8 0(0) >> 20(14) = 0(0)\nunsigned 8 0(0) >> 21(15) = 0(0)\nunsigned 8 0(0) >> 22(16) = 0(0)\nunsigned 8 0(0) >> 23(17) = 0(0)\nunsigned 8 0(0) >> 24(18) = 0(0)\nunsigned 8 0(0) >> 25(19) = 0(0)\nunsigned 8 0(0) >> 26(1a) = 0(0)\nunsigned 8 0(0) >> 27(1b) = 0(0)\nunsigned 8 0(0) >> 28(1c) = 0(0)\nunsigned 8 0(0) >> 29(1d) = 0(0)\nunsigned 8 0(0) >> 30(1e) = 0(0)\nunsigned 8 0(0) >> 31(1f) = 0(0)\nunsigned 8 0(0) >> 32(20) = 0(0)\nunsigned 8 0(0) >> 33(21) = 0(0)\nunsigned 8 0(0) >> 34(22) = 0(0)\nunsigned 8 0(0) >> 35(23) = 0(0)\nunsigned 8 0(0) >> 36(24) = 0(0)\nunsigned 8 0(0) >> 37(25) = 0(0)\nunsigned 8 0(0) >> 38(26) = 0(0)\nunsigned 8 0(0) >> 39(27) = 0(0)\nunsigned 8 0(0) >> 40(28) = 0(0)\nunsigned 8 0(0) >> 41(29) = 0(0)\nunsigned 8 0(0) >> 42(2a) = 0(0)\nunsigned 8 0(0) >> 43(2b) = 0(0)\nunsigned 8 0(0) >> 44(2c) = 0(0)\nunsigned 8 0(0) >> 45(2d) = 0(0)\nunsigned 8 0(0) >> 46(2e) = 0(0)\nunsigned 8 0(0) >> 47(2f) = 0(0)\nunsigned 8 0(0) >> 48(30) = 0(0)\nunsigned 8 0(0) >> 49(31) = 0(0)\nunsigned 8 0(0) >> 50(32) = 0(0)\nunsigned 8 0(0) >> 51(33) = 0(0)\nunsigned 8 0(0) >> 52(34) = 0(0)\nunsigned 8 0(0) >> 53(35) = 0(0)\nunsigned 8 0(0) >> 54(36) = 0(0)\nunsigned 8 0(0) >> 55(37) = 0(0)\nunsigned 8 0(0) >> 56(38) = 0(0)\nunsigned 8 0(0) >> 57(39) = 0(0)\nunsigned 8 0(0) >> 58(3a) = 0(0)\nunsigned 8 0(0) >> 59(3b) = 0(0)\nunsigned 8 0(0) >> 60(3c) = 0(0)\nunsigned 8 0(0) >> 61(3d) = 0(0)\nunsigned 8 0(0) >> 62(3e) = 0(0)\nunsigned 8 0(0) >> 63(3f) = 0(0)\nunsigned 8 0(0) >> 64(40) = 0(0)\nunsigned 8 0(0) >> 65(41) = 0(0)\nunsigned 8 0(0) >> 66(42) = 0(0)\nunsigned 8 0(0) >> 67(43) = 0(0)\nunsigned 8 0(0) >> 68(44) = 0(0)\nunsigned 8 0(0) >> 69(45) = 0(0)\nunsigned 8 0(0) >> 70(46) = 0(0)\nunsigned 8 0(0) >> 71(47) = 0(0)\nunsigned 8 0(0) >> 72(48) = 0(0)\nunsigned 8 0(0) >> 73(49) = 0(0)\nunsigned 8 0(0) >> 74(4a) = 0(0)\nunsigned 8 0(0) >> 75(4b) = 0(0)\nunsigned 8 0(0) >> 76(4c) = 0(0)\nunsigned 8 0(0) >> 77(4d) = 0(0)\nunsigned 8 0(0) >> 78(4e) = 0(0)\nunsigned 8 0(0) >> 79(4f) = 0(0)\nunsigned 8 0(0) >> 80(50) = 0(0)\nunsigned 8 0(0) >> 81(51) = 0(0)\nunsigned 8 0(0) >> 82(52) = 0(0)\nunsigned 8 0(0) >> 83(53) = 0(0)\nunsigned 8 0(0) >> 84(54) = 0(0)\nunsigned 8 0(0) >> 85(55) = 0(0)\nunsigned 8 0(0) >> 86(56) = 0(0)\nunsigned 8 0(0) >> 87(57) = 0(0)\nunsigned 8 0(0) >> 88(58) = 0(0)\nunsigned 8 0(0) >> 89(59) = 0(0)\nunsigned 8 0(0) >> 90(5a) = 0(0)\nunsigned 8 0(0) >> 91(5b) = 0(0)\nunsigned 8 0(0) >> 92(5c) = 0(0)\nunsigned 8 0(0) >> 93(5d) = 0(0)\nunsigned 8 0(0) >> 94(5e) = 0(0)\nunsigned 8 0(0) >> 95(5f) = 0(0)\nunsigned 8 0(0) >> 96(60) = 0(0)\nunsigned 8 0(0) >> 97(61) = 0(0)\nunsigned 8 0(0) >> 98(62) = 0(0)\nunsigned 8 0(0) >> 99(63) = 0(0)\nunsigned 8 0(0) >> 100(64) = 0(0)\nunsigned 8 0(0) >> 101(65) = 0(0)\nunsigned 8 0(0) >> 102(66) = 0(0)\nunsigned 8 0(0) >> 103(67) = 0(0)\nunsigned 8 0(0) >> 104(68) = 0(0)\nunsigned 8 0(0) >> 105(69) = 0(0)\nunsigned 8 0(0) >> 106(6a) = 0(0)\nunsigned 8 0(0) >> 107(6b) = 0(0)\nunsigned 8 0(0) >> 108(6c) = 0(0)\nunsigned 8 0(0) >> 109(6d) = 0(0)\nunsigned 8 0(0) >> 110(6e) = 0(0)\nunsigned 8 0(0) >> 111(6f) = 0(0)\nunsigned 8 0(0) >> 112(70) = 0(0)\nunsigned 8 0(0) >> 113(71) = 0(0)\nunsigned 8 0(0) >> 114(72) = 0(0)\nunsigned 8 0(0) >> 115(73) = 0(0)\nunsigned 8 0(0) >> 116(74) = 0(0)\nunsigned 8 0(0) >> 117(75) = 0(0)\nunsigned 8 0(0) >> 118(76) = 0(0)\nunsigned 8 0(0) >> 119(77) = 0(0)\nunsigned 8 0(0) >> 120(78) = 0(0)\nunsigned 8 0(0) >> 121(79) = 0(0)\nunsigned 8 0(0) >> 122(7a) = 0(0)\nunsigned 8 0(0) >> 123(7b) = 0(0)\nunsigned 8 0(0) >> 124(7c) = 0(0)\nunsigned 8 0(0) >> 125(7d) = 0(0)\nunsigned 8 0(0) >> 126(7e) = 0(0)\nunsigned 8 0(0) >> 127(7f) = 0(0)\nunsigned 8 1(1) >> -128(ffffff80) = 1(1)\nunsigned 8 1(1) >> -127(ffffff81) = 0(0)\nunsigned 8 1(1) >> -126(ffffff82) = 0(0)\nunsigned 8 1(1) >> -125(ffffff83) = 0(0)\nunsigned 8 1(1) >> -124(ffffff84) = 0(0)\nunsigned 8 1(1) >> -123(ffffff85) = 0(0)\nunsigned 8 1(1) >> -122(ffffff86) = 0(0)\nunsigned 8 1(1) >> -121(ffffff87) = 0(0)\nunsigned 8 1(1) >> -120(ffffff88) = 0(0)\nunsigned 8 1(1) >> -119(ffffff89) = 0(0)\nunsigned 8 1(1) >> -118(ffffff8a) = 0(0)\nunsigned 8 1(1) >> -117(ffffff8b) = 0(0)\nunsigned 8 1(1) >> -116(ffffff8c) = 0(0)\nunsigned 8 1(1) >> -115(ffffff8d) = 0(0)\nunsigned 8 1(1) >> -114(ffffff8e) = 0(0)\nunsigned 8 1(1) >> -113(ffffff8f) = 0(0)\nunsigned 8 1(1) >> -112(ffffff90) = 0(0)\nunsigned 8 1(1) >> -111(ffffff91) = 0(0)\nunsigned 8 1(1) >> -110(ffffff92) = 0(0)\nunsigned 8 1(1) >> -109(ffffff93) = 0(0)\nunsigned 8 1(1) >> -108(ffffff94) = 0(0)\nunsigned 8 1(1) >> -107(ffffff95) = 0(0)\nunsigned 8 1(1) >> -106(ffffff96) = 0(0)\nunsigned 8 1(1) >> -105(ffffff97) = 0(0)\nunsigned 8 1(1) >> -104(ffffff98) = 0(0)\nunsigned 8 1(1) >> -103(ffffff99) = 0(0)\nunsigned 8 1(1) >> -102(ffffff9a) = 0(0)\nunsigned 8 1(1) >> -101(ffffff9b) = 0(0)\nunsigned 8 1(1) >> -100(ffffff9c) = 0(0)\nunsigned 8 1(1) >> -99(ffffff9d) = 0(0)\nunsigned 8 1(1) >> -98(ffffff9e) = 0(0)\nunsigned 8 1(1) >> -97(ffffff9f) = 0(0)\nunsigned 8 1(1) >> -96(ffffffa0) = 1(1)\nunsigned 8 1(1) >> -95(ffffffa1) = 0(0)\nunsigned 8 1(1) >> -94(ffffffa2) = 0(0)\nunsigned 8 1(1) >> -93(ffffffa3) = 0(0)\nunsigned 8 1(1) >> -92(ffffffa4) = 0(0)\nunsigned 8 1(1) >> -91(ffffffa5) = 0(0)\nunsigned 8 1(1) >> -90(ffffffa6) = 0(0)\nunsigned 8 1(1) >> -89(ffffffa7) = 0(0)\nunsigned 8 1(1) >> -88(ffffffa8) = 0(0)\nunsigned 8 1(1) >> -87(ffffffa9) = 0(0)\nunsigned 8 1(1) >> -86(ffffffaa) = 0(0)\nunsigned 8 1(1) >> -85(ffffffab) = 0(0)\nunsigned 8 1(1) >> -84(ffffffac) = 0(0)\nunsigned 8 1(1) >> -83(ffffffad) = 0(0)\nunsigned 8 1(1) >> -82(ffffffae) = 0(0)\nunsigned 8 1(1) >> -81(ffffffaf) = 0(0)\nunsigned 8 1(1) >> -80(ffffffb0) = 0(0)\nunsigned 8 1(1) >> -79(ffffffb1) = 0(0)\nunsigned 8 1(1) >> -78(ffffffb2) = 0(0)\nunsigned 8 1(1) >> -77(ffffffb3) = 0(0)\nunsigned 8 1(1) >> -76(ffffffb4) = 0(0)\nunsigned 8 1(1) >> -75(ffffffb5) = 0(0)\nunsigned 8 1(1) >> -74(ffffffb6) = 0(0)\nunsigned 8 1(1) >> -73(ffffffb7) = 0(0)\nunsigned 8 1(1) >> -72(ffffffb8) = 0(0)\nunsigned 8 1(1) >> -71(ffffffb9) = 0(0)\nunsigned 8 1(1) >> -70(ffffffba) = 0(0)\nunsigned 8 1(1) >> -69(ffffffbb) = 0(0)\nunsigned 8 1(1) >> -68(ffffffbc) = 0(0)\nunsigned 8 1(1) >> -67(ffffffbd) = 0(0)\nunsigned 8 1(1) >> -66(ffffffbe) = 0(0)\nunsigned 8 1(1) >> -65(ffffffbf) = 0(0)\nunsigned 8 1(1) >> -64(ffffffc0) = 1(1)\nunsigned 8 1(1) >> -63(ffffffc1) = 0(0)\nunsigned 8 1(1) >> -62(ffffffc2) = 0(0)\nunsigned 8 1(1) >> -61(ffffffc3) = 0(0)\nunsigned 8 1(1) >> -60(ffffffc4) = 0(0)\nunsigned 8 1(1) >> -59(ffffffc5) = 0(0)\nunsigned 8 1(1) >> -58(ffffffc6) = 0(0)\nunsigned 8 1(1) >> -57(ffffffc7) = 0(0)\nunsigned 8 1(1) >> -56(ffffffc8) = 0(0)\nunsigned 8 1(1) >> -55(ffffffc9) = 0(0)\nunsigned 8 1(1) >> -54(ffffffca) = 0(0)\nunsigned 8 1(1) >> -53(ffffffcb) = 0(0)\nunsigned 8 1(1) >> -52(ffffffcc) = 0(0)\nunsigned 8 1(1) >> -51(ffffffcd) = 0(0)\nunsigned 8 1(1) >> -50(ffffffce) = 0(0)\nunsigned 8 1(1) >> -49(ffffffcf) = 0(0)\nunsigned 8 1(1) >> -48(ffffffd0) = 0(0)\nunsigned 8 1(1) >> -47(ffffffd1) = 0(0)\nunsigned 8 1(1) >> -46(ffffffd2) = 0(0)\nunsigned 8 1(1) >> -45(ffffffd3) = 0(0)\nunsigned 8 1(1) >> -44(ffffffd4) = 0(0)\nunsigned 8 1(1) >> -43(ffffffd5) = 0(0)\nunsigned 8 1(1) >> -42(ffffffd6) = 0(0)\nunsigned 8 1(1) >> -41(ffffffd7) = 0(0)\nunsigned 8 1(1) >> -40(ffffffd8) = 0(0)\nunsigned 8 1(1) >> -39(ffffffd9) = 0(0)\nunsigned 8 1(1) >> -38(ffffffda) = 0(0)\nunsigned 8 1(1) >> -37(ffffffdb) = 0(0)\nunsigned 8 1(1) >> -36(ffffffdc) = 0(0)\nunsigned 8 1(1) >> -35(ffffffdd) = 0(0)\nunsigned 8 1(1) >> -34(ffffffde) = 0(0)\nunsigned 8 1(1) >> -33(ffffffdf) = 0(0)\nunsigned 8 1(1) >> -32(ffffffe0) = 1(1)\nunsigned 8 1(1) >> -31(ffffffe1) = 0(0)\nunsigned 8 1(1) >> -30(ffffffe2) = 0(0)\nunsigned 8 1(1) >> -29(ffffffe3) = 0(0)\nunsigned 8 1(1) >> -28(ffffffe4) = 0(0)\nunsigned 8 1(1) >> -27(ffffffe5) = 0(0)\nunsigned 8 1(1) >> -26(ffffffe6) = 0(0)\nunsigned 8 1(1) >> -25(ffffffe7) = 0(0)\nunsigned 8 1(1) >> -24(ffffffe8) = 0(0)\nunsigned 8 1(1) >> -23(ffffffe9) = 0(0)\nunsigned 8 1(1) >> -22(ffffffea) = 0(0)\nunsigned 8 1(1) >> -21(ffffffeb) = 0(0)\nunsigned 8 1(1) >> -20(ffffffec) = 0(0)\nunsigned 8 1(1) >> -19(ffffffed) = 0(0)\nunsigned 8 1(1) >> -18(ffffffee) = 0(0)\nunsigned 8 1(1) >> -17(ffffffef) = 0(0)\nunsigned 8 1(1) >> -16(fffffff0) = 0(0)\nunsigned 8 1(1) >> -15(fffffff1) = 0(0)\nunsigned 8 1(1) >> -14(fffffff2) = 0(0)\nunsigned 8 1(1) >> -13(fffffff3) = 0(0)\nunsigned 8 1(1) >> -12(fffffff4) = 0(0)\nunsigned 8 1(1) >> -11(fffffff5) = 0(0)\nunsigned 8 1(1) >> -10(fffffff6) = 0(0)\nunsigned 8 1(1) >> -9(fffffff7) = 0(0)\nunsigned 8 1(1) >> -8(fffffff8) = 0(0)\nunsigned 8 1(1) >> -7(fffffff9) = 0(0)\nunsigned 8 1(1) >> -6(fffffffa) = 0(0)\nunsigned 8 1(1) >> -5(fffffffb) = 0(0)\nunsigned 8 1(1) >> -4(fffffffc) = 0(0)\nunsigned 8 1(1) >> -3(fffffffd) = 0(0)\nunsigned 8 1(1) >> -2(fffffffe) = 0(0)\nunsigned 8 1(1) >> -1(ffffffff) = 0(0)\nunsigned 8 1(1) >> 0(0) = 1(1)\nunsigned 8 1(1) >> 1(1) = 0(0)\nunsigned 8 1(1) >> 2(2) = 0(0)\nunsigned 8 1(1) >> 3(3) = 0(0)\nunsigned 8 1(1) >> 4(4) = 0(0)\nunsigned 8 1(1) >> 5(5) = 0(0)\nunsigned 8 1(1) >> 6(6) = 0(0)\nunsigned 8 1(1) >> 7(7) = 0(0)\nunsigned 8 1(1) >> 8(8) = 0(0)\nunsigned 8 1(1) >> 9(9) = 0(0)\nunsigned 8 1(1) >> 10(a) = 0(0)\nunsigned 8 1(1) >> 11(b) = 0(0)\nunsigned 8 1(1) >> 12(c) = 0(0)\nunsigned 8 1(1) >> 13(d) = 0(0)\nunsigned 8 1(1) >> 14(e) = 0(0)\nunsigned 8 1(1) >> 15(f) = 0(0)\nunsigned 8 1(1) >> 16(10) = 0(0)\nunsigned 8 1(1) >> 17(11) = 0(0)\nunsigned 8 1(1) >> 18(12) = 0(0)\nunsigned 8 1(1) >> 19(13) = 0(0)\nunsigned 8 1(1) >> 20(14) = 0(0)\nunsigned 8 1(1) >> 21(15) = 0(0)\nunsigned 8 1(1) >> 22(16) = 0(0)\nunsigned 8 1(1) >> 23(17) = 0(0)\nunsigned 8 1(1) >> 24(18) = 0(0)\nunsigned 8 1(1) >> 25(19) = 0(0)\nunsigned 8 1(1) >> 26(1a) = 0(0)\nunsigned 8 1(1) >> 27(1b) = 0(0)\nunsigned 8 1(1) >> 28(1c) = 0(0)\nunsigned 8 1(1) >> 29(1d) = 0(0)\nunsigned 8 1(1) >> 30(1e) = 0(0)\nunsigned 8 1(1) >> 31(1f) = 0(0)\nunsigned 8 1(1) >> 32(20) = 1(1)\nunsigned 8 1(1) >> 33(21) = 0(0)\nunsigned 8 1(1) >> 34(22) = 0(0)\nunsigned 8 1(1) >> 35(23) = 0(0)\nunsigned 8 1(1) >> 36(24) = 0(0)\nunsigned 8 1(1) >> 37(25) = 0(0)\nunsigned 8 1(1) >> 38(26) = 0(0)\nunsigned 8 1(1) >> 39(27) = 0(0)\nunsigned 8 1(1) >> 40(28) = 0(0)\nunsigned 8 1(1) >> 41(29) = 0(0)\nunsigned 8 1(1) >> 42(2a) = 0(0)\nunsigned 8 1(1) >> 43(2b) = 0(0)\nunsigned 8 1(1) >> 44(2c) = 0(0)\nunsigned 8 1(1) >> 45(2d) = 0(0)\nunsigned 8 1(1) >> 46(2e) = 0(0)\nunsigned 8 1(1) >> 47(2f) = 0(0)\nunsigned 8 1(1) >> 48(30) = 0(0)\nunsigned 8 1(1) >> 49(31) = 0(0)\nunsigned 8 1(1) >> 50(32) = 0(0)\nunsigned 8 1(1) >> 51(33) = 0(0)\nunsigned 8 1(1) >> 52(34) = 0(0)\nunsigned 8 1(1) >> 53(35) = 0(0)\nunsigned 8 1(1) >> 54(36) = 0(0)\nunsigned 8 1(1) >> 55(37) = 0(0)\nunsigned 8 1(1) >> 56(38) = 0(0)\nunsigned 8 1(1) >> 57(39) = 0(0)\nunsigned 8 1(1) >> 58(3a) = 0(0)\nunsigned 8 1(1) >> 59(3b) = 0(0)\nunsigned 8 1(1) >> 60(3c) = 0(0)\nunsigned 8 1(1) >> 61(3d) = 0(0)\nunsigned 8 1(1) >> 62(3e) = 0(0)\nunsigned 8 1(1) >> 63(3f) = 0(0)\nunsigned 8 1(1) >> 64(40) = 1(1)\nunsigned 8 1(1) >> 65(41) = 0(0)\nunsigned 8 1(1) >> 66(42) = 0(0)\nunsigned 8 1(1) >> 67(43) = 0(0)\nunsigned 8 1(1) >> 68(44) = 0(0)\nunsigned 8 1(1) >> 69(45) = 0(0)\nunsigned 8 1(1) >> 70(46) = 0(0)\nunsigned 8 1(1) >> 71(47) = 0(0)\nunsigned 8 1(1) >> 72(48) = 0(0)\nunsigned 8 1(1) >> 73(49) = 0(0)\nunsigned 8 1(1) >> 74(4a) = 0(0)\nunsigned 8 1(1) >> 75(4b) = 0(0)\nunsigned 8 1(1) >> 76(4c) = 0(0)\nunsigned 8 1(1) >> 77(4d) = 0(0)\nunsigned 8 1(1) >> 78(4e) = 0(0)\nunsigned 8 1(1) >> 79(4f) = 0(0)\nunsigned 8 1(1) >> 80(50) = 0(0)\nunsigned 8 1(1) >> 81(51) = 0(0)\nunsigned 8 1(1) >> 82(52) = 0(0)\nunsigned 8 1(1) >> 83(53) = 0(0)\nunsigned 8 1(1) >> 84(54) = 0(0)\nunsigned 8 1(1) >> 85(55) = 0(0)\nunsigned 8 1(1) >> 86(56) = 0(0)\nunsigned 8 1(1) >> 87(57) = 0(0)\nunsigned 8 1(1) >> 88(58) = 0(0)\nunsigned 8 1(1) >> 89(59) = 0(0)\nunsigned 8 1(1) >> 90(5a) = 0(0)\nunsigned 8 1(1) >> 91(5b) = 0(0)\nunsigned 8 1(1) >> 92(5c) = 0(0)\nunsigned 8 1(1) >> 93(5d) = 0(0)\nunsigned 8 1(1) >> 94(5e) = 0(0)\nunsigned 8 1(1) >> 95(5f) = 0(0)\nunsigned 8 1(1) >> 96(60) = 1(1)\nunsigned 8 1(1) >> 97(61) = 0(0)\nunsigned 8 1(1) >> 98(62) = 0(0)\nunsigned 8 1(1) >> 99(63) = 0(0)\nunsigned 8 1(1) >> 100(64) = 0(0)\nunsigned 8 1(1) >> 101(65) = 0(0)\nunsigned 8 1(1) >> 102(66) = 0(0)\nunsigned 8 1(1) >> 103(67) = 0(0)\nunsigned 8 1(1) >> 104(68) = 0(0)\nunsigned 8 1(1) >> 105(69) = 0(0)\nunsigned 8 1(1) >> 106(6a) = 0(0)\nunsigned 8 1(1) >> 107(6b) = 0(0)\nunsigned 8 1(1) >> 108(6c) = 0(0)\nunsigned 8 1(1) >> 109(6d) = 0(0)\nunsigned 8 1(1) >> 110(6e) = 0(0)\nunsigned 8 1(1) >> 111(6f) = 0(0)\nunsigned 8 1(1) >> 112(70) = 0(0)\nunsigned 8 1(1) >> 113(71) = 0(0)\nunsigned 8 1(1) >> 114(72) = 0(0)\nunsigned 8 1(1) >> 115(73) = 0(0)\nunsigned 8 1(1) >> 116(74) = 0(0)\nunsigned 8 1(1) >> 117(75) = 0(0)\nunsigned 8 1(1) >> 118(76) = 0(0)\nunsigned 8 1(1) >> 119(77) = 0(0)\nunsigned 8 1(1) >> 120(78) = 0(0)\nunsigned 8 1(1) >> 121(79) = 0(0)\nunsigned 8 1(1) >> 122(7a) = 0(0)\nunsigned 8 1(1) >> 123(7b) = 0(0)\nunsigned 8 1(1) >> 124(7c) = 0(0)\nunsigned 8 1(1) >> 125(7d) = 0(0)\nunsigned 8 1(1) >> 126(7e) = 0(0)\nunsigned 8 1(1) >> 127(7f) = 0(0)\nunsigned 8 2(2) >> -128(ffffff80) = 2(2)\nunsigned 8 2(2) >> -127(ffffff81) = 1(1)\nunsigned 8 2(2) >> -126(ffffff82) = 0(0)\nunsigned 8 2(2) >> -125(ffffff83) = 0(0)\nunsigned 8 2(2) >> -124(ffffff84) = 0(0)\nunsigned 8 2(2) >> -123(ffffff85) = 0(0)\nunsigned 8 2(2) >> -122(ffffff86) = 0(0)\nunsigned 8 2(2) >> -121(ffffff87) = 0(0)\nunsigned 8 2(2) >> -120(ffffff88) = 0(0)\nunsigned 8 2(2) >> -119(ffffff89) = 0(0)\nunsigned 8 2(2) >> -118(ffffff8a) = 0(0)\nunsigned 8 2(2) >> -117(ffffff8b) = 0(0)\nunsigned 8 2(2) >> -116(ffffff8c) = 0(0)\nunsigned 8 2(2) >> -115(ffffff8d) = 0(0)\nunsigned 8 2(2) >> -114(ffffff8e) = 0(0)\nunsigned 8 2(2) >> -113(ffffff8f) = 0(0)\nunsigned 8 2(2) >> -112(ffffff90) = 0(0)\nunsigned 8 2(2) >> -111(ffffff91) = 0(0)\nunsigned 8 2(2) >> -110(ffffff92) = 0(0)\nunsigned 8 2(2) >> -109(ffffff93) = 0(0)\nunsigned 8 2(2) >> -108(ffffff94) = 0(0)\nunsigned 8 2(2) >> -107(ffffff95) = 0(0)\nunsigned 8 2(2) >> -106(ffffff96) = 0(0)\nunsigned 8 2(2) >> -105(ffffff97) = 0(0)\nunsigned 8 2(2) >> -104(ffffff98) = 0(0)\nunsigned 8 2(2) >> -103(ffffff99) = 0(0)\nunsigned 8 2(2) >> -102(ffffff9a) = 0(0)\nunsigned 8 2(2) >> -101(ffffff9b) = 0(0)\nunsigned 8 2(2) >> -100(ffffff9c) = 0(0)\nunsigned 8 2(2) >> -99(ffffff9d) = 0(0)\nunsigned 8 2(2) >> -98(ffffff9e) = 0(0)\nunsigned 8 2(2) >> -97(ffffff9f) = 0(0)\nunsigned 8 2(2) >> -96(ffffffa0) = 2(2)\nunsigned 8 2(2) >> -95(ffffffa1) = 1(1)\nunsigned 8 2(2) >> -94(ffffffa2) = 0(0)\nunsigned 8 2(2) >> -93(ffffffa3) = 0(0)\nunsigned 8 2(2) >> -92(ffffffa4) = 0(0)\nunsigned 8 2(2) >> -91(ffffffa5) = 0(0)\nunsigned 8 2(2) >> -90(ffffffa6) = 0(0)\nunsigned 8 2(2) >> -89(ffffffa7) = 0(0)\nunsigned 8 2(2) >> -88(ffffffa8) = 0(0)\nunsigned 8 2(2) >> -87(ffffffa9) = 0(0)\nunsigned 8 2(2) >> -86(ffffffaa) = 0(0)\nunsigned 8 2(2) >> -85(ffffffab) = 0(0)\nunsigned 8 2(2) >> -84(ffffffac) = 0(0)\nunsigned 8 2(2) >> -83(ffffffad) = 0(0)\nunsigned 8 2(2) >> -82(ffffffae) = 0(0)\nunsigned 8 2(2) >> -81(ffffffaf) = 0(0)\nunsigned 8 2(2) >> -80(ffffffb0) = 0(0)\nunsigned 8 2(2) >> -79(ffffffb1) = 0(0)\nunsigned 8 2(2) >> -78(ffffffb2) = 0(0)\nunsigned 8 2(2) >> -77(ffffffb3) = 0(0)\nunsigned 8 2(2) >> -76(ffffffb4) = 0(0)\nunsigned 8 2(2) >> -75(ffffffb5) = 0(0)\nunsigned 8 2(2) >> -74(ffffffb6) = 0(0)\nunsigned 8 2(2) >> -73(ffffffb7) = 0(0)\nunsigned 8 2(2) >> -72(ffffffb8) = 0(0)\nunsigned 8 2(2) >> -71(ffffffb9) = 0(0)\nunsigned 8 2(2) >> -70(ffffffba) = 0(0)\nunsigned 8 2(2) >> -69(ffffffbb) = 0(0)\nunsigned 8 2(2) >> -68(ffffffbc) = 0(0)\nunsigned 8 2(2) >> -67(ffffffbd) = 0(0)\nunsigned 8 2(2) >> -66(ffffffbe) = 0(0)\nunsigned 8 2(2) >> -65(ffffffbf) = 0(0)\nunsigned 8 2(2) >> -64(ffffffc0) = 2(2)\nunsigned 8 2(2) >> -63(ffffffc1) = 1(1)\nunsigned 8 2(2) >> -62(ffffffc2) = 0(0)\nunsigned 8 2(2) >> -61(ffffffc3) = 0(0)\nunsigned 8 2(2) >> -60(ffffffc4) = 0(0)\nunsigned 8 2(2) >> -59(ffffffc5) = 0(0)\nunsigned 8 2(2) >> -58(ffffffc6) = 0(0)\nunsigned 8 2(2) >> -57(ffffffc7) = 0(0)\nunsigned 8 2(2) >> -56(ffffffc8) = 0(0)\nunsigned 8 2(2) >> -55(ffffffc9) = 0(0)\nunsigned 8 2(2) >> -54(ffffffca) = 0(0)\nunsigned 8 2(2) >> -53(ffffffcb) = 0(0)\nunsigned 8 2(2) >> -52(ffffffcc) = 0(0)\nunsigned 8 2(2) >> -51(ffffffcd) = 0(0)\nunsigned 8 2(2) >> -50(ffffffce) = 0(0)\nunsigned 8 2(2) >> -49(ffffffcf) = 0(0)\nunsigned 8 2(2) >> -48(ffffffd0) = 0(0)\nunsigned 8 2(2) >> -47(ffffffd1) = 0(0)\nunsigned 8 2(2) >> -46(ffffffd2) = 0(0)\nunsigned 8 2(2) >> -45(ffffffd3) = 0(0)\nunsigned 8 2(2) >> -44(ffffffd4) = 0(0)\nunsigned 8 2(2) >> -43(ffffffd5) = 0(0)\nunsigned 8 2(2) >> -42(ffffffd6) = 0(0)\nunsigned 8 2(2) >> -41(ffffffd7) = 0(0)\nunsigned 8 2(2) >> -40(ffffffd8) = 0(0)\nunsigned 8 2(2) >> -39(ffffffd9) = 0(0)\nunsigned 8 2(2) >> -38(ffffffda) = 0(0)\nunsigned 8 2(2) >> -37(ffffffdb) = 0(0)\nunsigned 8 2(2) >> -36(ffffffdc) = 0(0)\nunsigned 8 2(2) >> -35(ffffffdd) = 0(0)\nunsigned 8 2(2) >> -34(ffffffde) = 0(0)\nunsigned 8 2(2) >> -33(ffffffdf) = 0(0)\nunsigned 8 2(2) >> -32(ffffffe0) = 2(2)\nunsigned 8 2(2) >> -31(ffffffe1) = 1(1)\nunsigned 8 2(2) >> -30(ffffffe2) = 0(0)\nunsigned 8 2(2) >> -29(ffffffe3) = 0(0)\nunsigned 8 2(2) >> -28(ffffffe4) = 0(0)\nunsigned 8 2(2) >> -27(ffffffe5) = 0(0)\nunsigned 8 2(2) >> -26(ffffffe6) = 0(0)\nunsigned 8 2(2) >> -25(ffffffe7) = 0(0)\nunsigned 8 2(2) >> -24(ffffffe8) = 0(0)\nunsigned 8 2(2) >> -23(ffffffe9) = 0(0)\nunsigned 8 2(2) >> -22(ffffffea) = 0(0)\nunsigned 8 2(2) >> -21(ffffffeb) = 0(0)\nunsigned 8 2(2) >> -20(ffffffec) = 0(0)\nunsigned 8 2(2) >> -19(ffffffed) = 0(0)\nunsigned 8 2(2) >> -18(ffffffee) = 0(0)\nunsigned 8 2(2) >> -17(ffffffef) = 0(0)\nunsigned 8 2(2) >> -16(fffffff0) = 0(0)\nunsigned 8 2(2) >> -15(fffffff1) = 0(0)\nunsigned 8 2(2) >> -14(fffffff2) = 0(0)\nunsigned 8 2(2) >> -13(fffffff3) = 0(0)\nunsigned 8 2(2) >> -12(fffffff4) = 0(0)\nunsigned 8 2(2) >> -11(fffffff5) = 0(0)\nunsigned 8 2(2) >> -10(fffffff6) = 0(0)\nunsigned 8 2(2) >> -9(fffffff7) = 0(0)\nunsigned 8 2(2) >> -8(fffffff8) = 0(0)\nunsigned 8 2(2) >> -7(fffffff9) = 0(0)\nunsigned 8 2(2) >> -6(fffffffa) = 0(0)\nunsigned 8 2(2) >> -5(fffffffb) = 0(0)\nunsigned 8 2(2) >> -4(fffffffc) = 0(0)\nunsigned 8 2(2) >> -3(fffffffd) = 0(0)\nunsigned 8 2(2) >> -2(fffffffe) = 0(0)\nunsigned 8 2(2) >> -1(ffffffff) = 0(0)\nunsigned 8 2(2) >> 0(0) = 2(2)\nunsigned 8 2(2) >> 1(1) = 1(1)\nunsigned 8 2(2) >> 2(2) = 0(0)\nunsigned 8 2(2) >> 3(3) = 0(0)\nunsigned 8 2(2) >> 4(4) = 0(0)\nunsigned 8 2(2) >> 5(5) = 0(0)\nunsigned 8 2(2) >> 6(6) = 0(0)\nunsigned 8 2(2) >> 7(7) = 0(0)\nunsigned 8 2(2) >> 8(8) = 0(0)\nunsigned 8 2(2) >> 9(9) = 0(0)\nunsigned 8 2(2) >> 10(a) = 0(0)\nunsigned 8 2(2) >> 11(b) = 0(0)\nunsigned 8 2(2) >> 12(c) = 0(0)\nunsigned 8 2(2) >> 13(d) = 0(0)\nunsigned 8 2(2) >> 14(e) = 0(0)\nunsigned 8 2(2) >> 15(f) = 0(0)\nunsigned 8 2(2) >> 16(10) = 0(0)\nunsigned 8 2(2) >> 17(11) = 0(0)\nunsigned 8 2(2) >> 18(12) = 0(0)\nunsigned 8 2(2) >> 19(13) = 0(0)\nunsigned 8 2(2) >> 20(14) = 0(0)\nunsigned 8 2(2) >> 21(15) = 0(0)\nunsigned 8 2(2) >> 22(16) = 0(0)\nunsigned 8 2(2) >> 23(17) = 0(0)\nunsigned 8 2(2) >> 24(18) = 0(0)\nunsigned 8 2(2) >> 25(19) = 0(0)\nunsigned 8 2(2) >> 26(1a) = 0(0)\nunsigned 8 2(2) >> 27(1b) = 0(0)\nunsigned 8 2(2) >> 28(1c) = 0(0)\nunsigned 8 2(2) >> 29(1d) = 0(0)\nunsigned 8 2(2) >> 30(1e) = 0(0)\nunsigned 8 2(2) >> 31(1f) = 0(0)\nunsigned 8 2(2) >> 32(20) = 2(2)\nunsigned 8 2(2) >> 33(21) = 1(1)\nunsigned 8 2(2) >> 34(22) = 0(0)\nunsigned 8 2(2) >> 35(23) = 0(0)\nunsigned 8 2(2) >> 36(24) = 0(0)\nunsigned 8 2(2) >> 37(25) = 0(0)\nunsigned 8 2(2) >> 38(26) = 0(0)\nunsigned 8 2(2) >> 39(27) = 0(0)\nunsigned 8 2(2) >> 40(28) = 0(0)\nunsigned 8 2(2) >> 41(29) = 0(0)\nunsigned 8 2(2) >> 42(2a) = 0(0)\nunsigned 8 2(2) >> 43(2b) = 0(0)\nunsigned 8 2(2) >> 44(2c) = 0(0)\nunsigned 8 2(2) >> 45(2d) = 0(0)\nunsigned 8 2(2) >> 46(2e) = 0(0)\nunsigned 8 2(2) >> 47(2f) = 0(0)\nunsigned 8 2(2) >> 48(30) = 0(0)\nunsigned 8 2(2) >> 49(31) = 0(0)\nunsigned 8 2(2) >> 50(32) = 0(0)\nunsigned 8 2(2) >> 51(33) = 0(0)\nunsigned 8 2(2) >> 52(34) = 0(0)\nunsigned 8 2(2) >> 53(35) = 0(0)\nunsigned 8 2(2) >> 54(36) = 0(0)\nunsigned 8 2(2) >> 55(37) = 0(0)\nunsigned 8 2(2) >> 56(38) = 0(0)\nunsigned 8 2(2) >> 57(39) = 0(0)\nunsigned 8 2(2) >> 58(3a) = 0(0)\nunsigned 8 2(2) >> 59(3b) = 0(0)\nunsigned 8 2(2) >> 60(3c) = 0(0)\nunsigned 8 2(2) >> 61(3d) = 0(0)\nunsigned 8 2(2) >> 62(3e) = 0(0)\nunsigned 8 2(2) >> 63(3f) = 0(0)\nunsigned 8 2(2) >> 64(40) = 2(2)\nunsigned 8 2(2) >> 65(41) = 1(1)\nunsigned 8 2(2) >> 66(42) = 0(0)\nunsigned 8 2(2) >> 67(43) = 0(0)\nunsigned 8 2(2) >> 68(44) = 0(0)\nunsigned 8 2(2) >> 69(45) = 0(0)\nunsigned 8 2(2) >> 70(46) = 0(0)\nunsigned 8 2(2) >> 71(47) = 0(0)\nunsigned 8 2(2) >> 72(48) = 0(0)\nunsigned 8 2(2) >> 73(49) = 0(0)\nunsigned 8 2(2) >> 74(4a) = 0(0)\nunsigned 8 2(2) >> 75(4b) = 0(0)\nunsigned 8 2(2) >> 76(4c) = 0(0)\nunsigned 8 2(2) >> 77(4d) = 0(0)\nunsigned 8 2(2) >> 78(4e) = 0(0)\nunsigned 8 2(2) >> 79(4f) = 0(0)\nunsigned 8 2(2) >> 80(50) = 0(0)\nunsigned 8 2(2) >> 81(51) = 0(0)\nunsigned 8 2(2) >> 82(52) = 0(0)\nunsigned 8 2(2) >> 83(53) = 0(0)\nunsigned 8 2(2) >> 84(54) = 0(0)\nunsigned 8 2(2) >> 85(55) = 0(0)\nunsigned 8 2(2) >> 86(56) = 0(0)\nunsigned 8 2(2) >> 87(57) = 0(0)\nunsigned 8 2(2) >> 88(58) = 0(0)\nunsigned 8 2(2) >> 89(59) = 0(0)\nunsigned 8 2(2) >> 90(5a) = 0(0)\nunsigned 8 2(2) >> 91(5b) = 0(0)\nunsigned 8 2(2) >> 92(5c) = 0(0)\nunsigned 8 2(2) >> 93(5d) = 0(0)\nunsigned 8 2(2) >> 94(5e) = 0(0)\nunsigned 8 2(2) >> 95(5f) = 0(0)\nunsigned 8 2(2) >> 96(60) = 2(2)\nunsigned 8 2(2) >> 97(61) = 1(1)\nunsigned 8 2(2) >> 98(62) = 0(0)\nunsigned 8 2(2) >> 99(63) = 0(0)\nunsigned 8 2(2) >> 100(64) = 0(0)\nunsigned 8 2(2) >> 101(65) = 0(0)\nunsigned 8 2(2) >> 102(66) = 0(0)\nunsigned 8 2(2) >> 103(67) = 0(0)\nunsigned 8 2(2) >> 104(68) = 0(0)\nunsigned 8 2(2) >> 105(69) = 0(0)\nunsigned 8 2(2) >> 106(6a) = 0(0)\nunsigned 8 2(2) >> 107(6b) = 0(0)\nunsigned 8 2(2) >> 108(6c) = 0(0)\nunsigned 8 2(2) >> 109(6d) = 0(0)\nunsigned 8 2(2) >> 110(6e) = 0(0)\nunsigned 8 2(2) >> 111(6f) = 0(0)\nunsigned 8 2(2) >> 112(70) = 0(0)\nunsigned 8 2(2) >> 113(71) = 0(0)\nunsigned 8 2(2) >> 114(72) = 0(0)\nunsigned 8 2(2) >> 115(73) = 0(0)\nunsigned 8 2(2) >> 116(74) = 0(0)\nunsigned 8 2(2) >> 117(75) = 0(0)\nunsigned 8 2(2) >> 118(76) = 0(0)\nunsigned 8 2(2) >> 119(77) = 0(0)\nunsigned 8 2(2) >> 120(78) = 0(0)\nunsigned 8 2(2) >> 121(79) = 0(0)\nunsigned 8 2(2) >> 122(7a) = 0(0)\nunsigned 8 2(2) >> 123(7b) = 0(0)\nunsigned 8 2(2) >> 124(7c) = 0(0)\nunsigned 8 2(2) >> 125(7d) = 0(0)\nunsigned 8 2(2) >> 126(7e) = 0(0)\nunsigned 8 2(2) >> 127(7f) = 0(0)\nunsigned 8 3(3) >> -128(ffffff80) = 3(3)\nunsigned 8 3(3) >> -127(ffffff81) = 1(1)\nunsigned 8 3(3) >> -126(ffffff82) = 0(0)\nunsigned 8 3(3) >> -125(ffffff83) = 0(0)\nunsigned 8 3(3) >> -124(ffffff84) = 0(0)\nunsigned 8 3(3) >> -123(ffffff85) = 0(0)\nunsigned 8 3(3) >> -122(ffffff86) = 0(0)\nunsigned 8 3(3) >> -121(ffffff87) = 0(0)\nunsigned 8 3(3) >> -120(ffffff88) = 0(0)\nunsigned 8 3(3) >> -119(ffffff89) = 0(0)\nunsigned 8 3(3) >> -118(ffffff8a) = 0(0)\nunsigned 8 3(3) >> -117(ffffff8b) = 0(0)\nunsigned 8 3(3) >> -116(ffffff8c) = 0(0)\nunsigned 8 3(3) >> -115(ffffff8d) = 0(0)\nunsigned 8 3(3) >> -114(ffffff8e) = 0(0)\nunsigned 8 3(3) >> -113(ffffff8f) = 0(0)\nunsigned 8 3(3) >> -112(ffffff90) = 0(0)\nunsigned 8 3(3) >> -111(ffffff91) = 0(0)\nunsigned 8 3(3) >> -110(ffffff92) = 0(0)\nunsigned 8 3(3) >> -109(ffffff93) = 0(0)\nunsigned 8 3(3) >> -108(ffffff94) = 0(0)\nunsigned 8 3(3) >> -107(ffffff95) = 0(0)\nunsigned 8 3(3) >> -106(ffffff96) = 0(0)\nunsigned 8 3(3) >> -105(ffffff97) = 0(0)\nunsigned 8 3(3) >> -104(ffffff98) = 0(0)\nunsigned 8 3(3) >> -103(ffffff99) = 0(0)\nunsigned 8 3(3) >> -102(ffffff9a) = 0(0)\nunsigned 8 3(3) >> -101(ffffff9b) = 0(0)\nunsigned 8 3(3) >> -100(ffffff9c) = 0(0)\nunsigned 8 3(3) >> -99(ffffff9d) = 0(0)\nunsigned 8 3(3) >> -98(ffffff9e) = 0(0)\nunsigned 8 3(3) >> -97(ffffff9f) = 0(0)\nunsigned 8 3(3) >> -96(ffffffa0) = 3(3)\nunsigned 8 3(3) >> -95(ffffffa1) = 1(1)\nunsigned 8 3(3) >> -94(ffffffa2) = 0(0)\nunsigned 8 3(3) >> -93(ffffffa3) = 0(0)\nunsigned 8 3(3) >> -92(ffffffa4) = 0(0)\nunsigned 8 3(3) >> -91(ffffffa5) = 0(0)\nunsigned 8 3(3) >> -90(ffffffa6) = 0(0)\nunsigned 8 3(3) >> -89(ffffffa7) = 0(0)\nunsigned 8 3(3) >> -88(ffffffa8) = 0(0)\nunsigned 8 3(3) >> -87(ffffffa9) = 0(0)\nunsigned 8 3(3) >> -86(ffffffaa) = 0(0)\nunsigned 8 3(3) >> -85(ffffffab) = 0(0)\nunsigned 8 3(3) >> -84(ffffffac) = 0(0)\nunsigned 8 3(3) >> -83(ffffffad) = 0(0)\nunsigned 8 3(3) >> -82(ffffffae) = 0(0)\nunsigned 8 3(3) >> -81(ffffffaf) = 0(0)\nunsigned 8 3(3) >> -80(ffffffb0) = 0(0)\nunsigned 8 3(3) >> -79(ffffffb1) = 0(0)\nunsigned 8 3(3) >> -78(ffffffb2) = 0(0)\nunsigned 8 3(3) >> -77(ffffffb3) = 0(0)\nunsigned 8 3(3) >> -76(ffffffb4) = 0(0)\nunsigned 8 3(3) >> -75(ffffffb5) = 0(0)\nunsigned 8 3(3) >> -74(ffffffb6) = 0(0)\nunsigned 8 3(3) >> -73(ffffffb7) = 0(0)\nunsigned 8 3(3) >> -72(ffffffb8) = 0(0)\nunsigned 8 3(3) >> -71(ffffffb9) = 0(0)\nunsigned 8 3(3) >> -70(ffffffba) = 0(0)\nunsigned 8 3(3) >> -69(ffffffbb) = 0(0)\nunsigned 8 3(3) >> -68(ffffffbc) = 0(0)\nunsigned 8 3(3) >> -67(ffffffbd) = 0(0)\nunsigned 8 3(3) >> -66(ffffffbe) = 0(0)\nunsigned 8 3(3) >> -65(ffffffbf) = 0(0)\nunsigned 8 3(3) >> -64(ffffffc0) = 3(3)\nunsigned 8 3(3) >> -63(ffffffc1) = 1(1)\nunsigned 8 3(3) >> -62(ffffffc2) = 0(0)\nunsigned 8 3(3) >> -61(ffffffc3) = 0(0)\nunsigned 8 3(3) >> -60(ffffffc4) = 0(0)\nunsigned 8 3(3) >> -59(ffffffc5) = 0(0)\nunsigned 8 3(3) >> -58(ffffffc6) = 0(0)\nunsigned 8 3(3) >> -57(ffffffc7) = 0(0)\nunsigned 8 3(3) >> -56(ffffffc8) = 0(0)\nunsigned 8 3(3) >> -55(ffffffc9) = 0(0)\nunsigned 8 3(3) >> -54(ffffffca) = 0(0)\nunsigned 8 3(3) >> -53(ffffffcb) = 0(0)\nunsigned 8 3(3) >> -52(ffffffcc) = 0(0)\nunsigned 8 3(3) >> -51(ffffffcd) = 0(0)\nunsigned 8 3(3) >> -50(ffffffce) = 0(0)\nunsigned 8 3(3) >> -49(ffffffcf) = 0(0)\nunsigned 8 3(3) >> -48(ffffffd0) = 0(0)\nunsigned 8 3(3) >> -47(ffffffd1) = 0(0)\nunsigned 8 3(3) >> -46(ffffffd2) = 0(0)\nunsigned 8 3(3) >> -45(ffffffd3) = 0(0)\nunsigned 8 3(3) >> -44(ffffffd4) = 0(0)\nunsigned 8 3(3) >> -43(ffffffd5) = 0(0)\nunsigned 8 3(3) >> -42(ffffffd6) = 0(0)\nunsigned 8 3(3) >> -41(ffffffd7) = 0(0)\nunsigned 8 3(3) >> -40(ffffffd8) = 0(0)\nunsigned 8 3(3) >> -39(ffffffd9) = 0(0)\nunsigned 8 3(3) >> -38(ffffffda) = 0(0)\nunsigned 8 3(3) >> -37(ffffffdb) = 0(0)\nunsigned 8 3(3) >> -36(ffffffdc) = 0(0)\nunsigned 8 3(3) >> -35(ffffffdd) = 0(0)\nunsigned 8 3(3) >> -34(ffffffde) = 0(0)\nunsigned 8 3(3) >> -33(ffffffdf) = 0(0)\nunsigned 8 3(3) >> -32(ffffffe0) = 3(3)\nunsigned 8 3(3) >> -31(ffffffe1) = 1(1)\nunsigned 8 3(3) >> -30(ffffffe2) = 0(0)\nunsigned 8 3(3) >> -29(ffffffe3) = 0(0)\nunsigned 8 3(3) >> -28(ffffffe4) = 0(0)\nunsigned 8 3(3) >> -27(ffffffe5) = 0(0)\nunsigned 8 3(3) >> -26(ffffffe6) = 0(0)\nunsigned 8 3(3) >> -25(ffffffe7) = 0(0)\nunsigned 8 3(3) >> -24(ffffffe8) = 0(0)\nunsigned 8 3(3) >> -23(ffffffe9) = 0(0)\nunsigned 8 3(3) >> -22(ffffffea) = 0(0)\nunsigned 8 3(3) >> -21(ffffffeb) = 0(0)\nunsigned 8 3(3) >> -20(ffffffec) = 0(0)\nunsigned 8 3(3) >> -19(ffffffed) = 0(0)\nunsigned 8 3(3) >> -18(ffffffee) = 0(0)\nunsigned 8 3(3) >> -17(ffffffef) = 0(0)\nunsigned 8 3(3) >> -16(fffffff0) = 0(0)\nunsigned 8 3(3) >> -15(fffffff1) = 0(0)\nunsigned 8 3(3) >> -14(fffffff2) = 0(0)\nunsigned 8 3(3) >> -13(fffffff3) = 0(0)\nunsigned 8 3(3) >> -12(fffffff4) = 0(0)\nunsigned 8 3(3) >> -11(fffffff5) = 0(0)\nunsigned 8 3(3) >> -10(fffffff6) = 0(0)\nunsigned 8 3(3) >> -9(fffffff7) = 0(0)\nunsigned 8 3(3) >> -8(fffffff8) = 0(0)\nunsigned 8 3(3) >> -7(fffffff9) = 0(0)\nunsigned 8 3(3) >> -6(fffffffa) = 0(0)\nunsigned 8 3(3) >> -5(fffffffb) = 0(0)\nunsigned 8 3(3) >> -4(fffffffc) = 0(0)\nunsigned 8 3(3) >> -3(fffffffd) = 0(0)\nunsigned 8 3(3) >> -2(fffffffe) = 0(0)\nunsigned 8 3(3) >> -1(ffffffff) = 0(0)\nunsigned 8 3(3) >> 0(0) = 3(3)\nunsigned 8 3(3) >> 1(1) = 1(1)\nunsigned 8 3(3) >> 2(2) = 0(0)\nunsigned 8 3(3) >> 3(3) = 0(0)\nunsigned 8 3(3) >> 4(4) = 0(0)\nunsigned 8 3(3) >> 5(5) = 0(0)\nunsigned 8 3(3) >> 6(6) = 0(0)\nunsigned 8 3(3) >> 7(7) = 0(0)\nunsigned 8 3(3) >> 8(8) = 0(0)\nunsigned 8 3(3) >> 9(9) = 0(0)\nunsigned 8 3(3) >> 10(a) = 0(0)\nunsigned 8 3(3) >> 11(b) = 0(0)\nunsigned 8 3(3) >> 12(c) = 0(0)\nunsigned 8 3(3) >> 13(d) = 0(0)\nunsigned 8 3(3) >> 14(e) = 0(0)\nunsigned 8 3(3) >> 15(f) = 0(0)\nunsigned 8 3(3) >> 16(10) = 0(0)\nunsigned 8 3(3) >> 17(11) = 0(0)\nunsigned 8 3(3) >> 18(12) = 0(0)\nunsigned 8 3(3) >> 19(13) = 0(0)\nunsigned 8 3(3) >> 20(14) = 0(0)\nunsigned 8 3(3) >> 21(15) = 0(0)\nunsigned 8 3(3) >> 22(16) = 0(0)\nunsigned 8 3(3) >> 23(17) = 0(0)\nunsigned 8 3(3) >> 24(18) = 0(0)\nunsigned 8 3(3) >> 25(19) = 0(0)\nunsigned 8 3(3) >> 26(1a) = 0(0)\nunsigned 8 3(3) >> 27(1b) = 0(0)\nunsigned 8 3(3) >> 28(1c) = 0(0)\nunsigned 8 3(3) >> 29(1d) = 0(0)\nunsigned 8 3(3) >> 30(1e) = 0(0)\nunsigned 8 3(3) >> 31(1f) = 0(0)\nunsigned 8 3(3) >> 32(20) = 3(3)\nunsigned 8 3(3) >> 33(21) = 1(1)\nunsigned 8 3(3) >> 34(22) = 0(0)\nunsigned 8 3(3) >> 35(23) = 0(0)\nunsigned 8 3(3) >> 36(24) = 0(0)\nunsigned 8 3(3) >> 37(25) = 0(0)\nunsigned 8 3(3) >> 38(26) = 0(0)\nunsigned 8 3(3) >> 39(27) = 0(0)\nunsigned 8 3(3) >> 40(28) = 0(0)\nunsigned 8 3(3) >> 41(29) = 0(0)\nunsigned 8 3(3) >> 42(2a) = 0(0)\nunsigned 8 3(3) >> 43(2b) = 0(0)\nunsigned 8 3(3) >> 44(2c) = 0(0)\nunsigned 8 3(3) >> 45(2d) = 0(0)\nunsigned 8 3(3) >> 46(2e) = 0(0)\nunsigned 8 3(3) >> 47(2f) = 0(0)\nunsigned 8 3(3) >> 48(30) = 0(0)\nunsigned 8 3(3) >> 49(31) = 0(0)\nunsigned 8 3(3) >> 50(32) = 0(0)\nunsigned 8 3(3) >> 51(33) = 0(0)\nunsigned 8 3(3) >> 52(34) = 0(0)\nunsigned 8 3(3) >> 53(35) = 0(0)\nunsigned 8 3(3) >> 54(36) = 0(0)\nunsigned 8 3(3) >> 55(37) = 0(0)\nunsigned 8 3(3) >> 56(38) = 0(0)\nunsigned 8 3(3) >> 57(39) = 0(0)\nunsigned 8 3(3) >> 58(3a) = 0(0)\nunsigned 8 3(3) >> 59(3b) = 0(0)\nunsigned 8 3(3) >> 60(3c) = 0(0)\nunsigned 8 3(3) >> 61(3d) = 0(0)\nunsigned 8 3(3) >> 62(3e) = 0(0)\nunsigned 8 3(3) >> 63(3f) = 0(0)\nunsigned 8 3(3) >> 64(40) = 3(3)\nunsigned 8 3(3) >> 65(41) = 1(1)\nunsigned 8 3(3) >> 66(42) = 0(0)\nunsigned 8 3(3) >> 67(43) = 0(0)\nunsigned 8 3(3) >> 68(44) = 0(0)\nunsigned 8 3(3) >> 69(45) = 0(0)\nunsigned 8 3(3) >> 70(46) = 0(0)\nunsigned 8 3(3) >> 71(47) = 0(0)\nunsigned 8 3(3) >> 72(48) = 0(0)\nunsigned 8 3(3) >> 73(49) = 0(0)\nunsigned 8 3(3) >> 74(4a) = 0(0)\nunsigned 8 3(3) >> 75(4b) = 0(0)\nunsigned 8 3(3) >> 76(4c) = 0(0)\nunsigned 8 3(3) >> 77(4d) = 0(0)\nunsigned 8 3(3) >> 78(4e) = 0(0)\nunsigned 8 3(3) >> 79(4f) = 0(0)\nunsigned 8 3(3) >> 80(50) = 0(0)\nunsigned 8 3(3) >> 81(51) = 0(0)\nunsigned 8 3(3) >> 82(52) = 0(0)\nunsigned 8 3(3) >> 83(53) = 0(0)\nunsigned 8 3(3) >> 84(54) = 0(0)\nunsigned 8 3(3) >> 85(55) = 0(0)\nunsigned 8 3(3) >> 86(56) = 0(0)\nunsigned 8 3(3) >> 87(57) = 0(0)\nunsigned 8 3(3) >> 88(58) = 0(0)\nunsigned 8 3(3) >> 89(59) = 0(0)\nunsigned 8 3(3) >> 90(5a) = 0(0)\nunsigned 8 3(3) >> 91(5b) = 0(0)\nunsigned 8 3(3) >> 92(5c) = 0(0)\nunsigned 8 3(3) >> 93(5d) = 0(0)\nunsigned 8 3(3) >> 94(5e) = 0(0)\nunsigned 8 3(3) >> 95(5f) = 0(0)\nunsigned 8 3(3) >> 96(60) = 3(3)\nunsigned 8 3(3) >> 97(61) = 1(1)\nunsigned 8 3(3) >> 98(62) = 0(0)\nunsigned 8 3(3) >> 99(63) = 0(0)\nunsigned 8 3(3) >> 100(64) = 0(0)\nunsigned 8 3(3) >> 101(65) = 0(0)\nunsigned 8 3(3) >> 102(66) = 0(0)\nunsigned 8 3(3) >> 103(67) = 0(0)\nunsigned 8 3(3) >> 104(68) = 0(0)\nunsigned 8 3(3) >> 105(69) = 0(0)\nunsigned 8 3(3) >> 106(6a) = 0(0)\nunsigned 8 3(3) >> 107(6b) = 0(0)\nunsigned 8 3(3) >> 108(6c) = 0(0)\nunsigned 8 3(3) >> 109(6d) = 0(0)\nunsigned 8 3(3) >> 110(6e) = 0(0)\nunsigned 8 3(3) >> 111(6f) = 0(0)\nunsigned 8 3(3) >> 112(70) = 0(0)\nunsigned 8 3(3) >> 113(71) = 0(0)\nunsigned 8 3(3) >> 114(72) = 0(0)\nunsigned 8 3(3) >> 115(73) = 0(0)\nunsigned 8 3(3) >> 116(74) = 0(0)\nunsigned 8 3(3) >> 117(75) = 0(0)\nunsigned 8 3(3) >> 118(76) = 0(0)\nunsigned 8 3(3) >> 119(77) = 0(0)\nunsigned 8 3(3) >> 120(78) = 0(0)\nunsigned 8 3(3) >> 121(79) = 0(0)\nunsigned 8 3(3) >> 122(7a) = 0(0)\nunsigned 8 3(3) >> 123(7b) = 0(0)\nunsigned 8 3(3) >> 124(7c) = 0(0)\nunsigned 8 3(3) >> 125(7d) = 0(0)\nunsigned 8 3(3) >> 126(7e) = 0(0)\nunsigned 8 3(3) >> 127(7f) = 0(0)\nunsigned 8 4(4) >> -128(ffffff80) = 4(4)\nunsigned 8 4(4) >> -127(ffffff81) = 2(2)\nunsigned 8 4(4) >> -126(ffffff82) = 1(1)\nunsigned 8 4(4) >> -125(ffffff83) = 0(0)\nunsigned 8 4(4) >> -124(ffffff84) = 0(0)\nunsigned 8 4(4) >> -123(ffffff85) = 0(0)\nunsigned 8 4(4) >> -122(ffffff86) = 0(0)\nunsigned 8 4(4) >> -121(ffffff87) = 0(0)\nunsigned 8 4(4) >> -120(ffffff88) = 0(0)\nunsigned 8 4(4) >> -119(ffffff89) = 0(0)\nunsigned 8 4(4) >> -118(ffffff8a) = 0(0)\nunsigned 8 4(4) >> -117(ffffff8b) = 0(0)\nunsigned 8 4(4) >> -116(ffffff8c) = 0(0)\nunsigned 8 4(4) >> -115(ffffff8d) = 0(0)\nunsigned 8 4(4) >> -114(ffffff8e) = 0(0)\nunsigned 8 4(4) >> -113(ffffff8f) = 0(0)\nunsigned 8 4(4) >> -112(ffffff90) = 0(0)\nunsigned 8 4(4) >> -111(ffffff91) = 0(0)\nunsigned 8 4(4) >> -110(ffffff92) = 0(0)\nunsigned 8 4(4) >> -109(ffffff93) = 0(0)\nunsigned 8 4(4) >> -108(ffffff94) = 0(0)\nunsigned 8 4(4) >> -107(ffffff95) = 0(0)\nunsigned 8 4(4) >> -106(ffffff96) = 0(0)\nunsigned 8 4(4) >> -105(ffffff97) = 0(0)\nunsigned 8 4(4) >> -104(ffffff98) = 0(0)\nunsigned 8 4(4) >> -103(ffffff99) = 0(0)\nunsigned 8 4(4) >> -102(ffffff9a) = 0(0)\nunsigned 8 4(4) >> -101(ffffff9b) = 0(0)\nunsigned 8 4(4) >> -100(ffffff9c) = 0(0)\nunsigned 8 4(4) >> -99(ffffff9d) = 0(0)\nunsigned 8 4(4) >> -98(ffffff9e) = 0(0)\nunsigned 8 4(4) >> -97(ffffff9f) = 0(0)\nunsigned 8 4(4) >> -96(ffffffa0) = 4(4)\nunsigned 8 4(4) >> -95(ffffffa1) = 2(2)\nunsigned 8 4(4) >> -94(ffffffa2) = 1(1)\nunsigned 8 4(4) >> -93(ffffffa3) = 0(0)\nunsigned 8 4(4) >> -92(ffffffa4) = 0(0)\nunsigned 8 4(4) >> -91(ffffffa5) = 0(0)\nunsigned 8 4(4) >> -90(ffffffa6) = 0(0)\nunsigned 8 4(4) >> -89(ffffffa7) = 0(0)\nunsigned 8 4(4) >> -88(ffffffa8) = 0(0)\nunsigned 8 4(4) >> -87(ffffffa9) = 0(0)\nunsigned 8 4(4) >> -86(ffffffaa) = 0(0)\nunsigned 8 4(4) >> -85(ffffffab) = 0(0)\nunsigned 8 4(4) >> -84(ffffffac) = 0(0)\nunsigned 8 4(4) >> -83(ffffffad) = 0(0)\nunsigned 8 4(4) >> -82(ffffffae) = 0(0)\nunsigned 8 4(4) >> -81(ffffffaf) = 0(0)\nunsigned 8 4(4) >> -80(ffffffb0) = 0(0)\nunsigned 8 4(4) >> -79(ffffffb1) = 0(0)\nunsigned 8 4(4) >> -78(ffffffb2) = 0(0)\nunsigned 8 4(4) >> -77(ffffffb3) = 0(0)\nunsigned 8 4(4) >> -76(ffffffb4) = 0(0)\nunsigned 8 4(4) >> -75(ffffffb5) = 0(0)\nunsigned 8 4(4) >> -74(ffffffb6) = 0(0)\nunsigned 8 4(4) >> -73(ffffffb7) = 0(0)\nunsigned 8 4(4) >> -72(ffffffb8) = 0(0)\nunsigned 8 4(4) >> -71(ffffffb9) = 0(0)\nunsigned 8 4(4) >> -70(ffffffba) = 0(0)\nunsigned 8 4(4) >> -69(ffffffbb) = 0(0)\nunsigned 8 4(4) >> -68(ffffffbc) = 0(0)\nunsigned 8 4(4) >> -67(ffffffbd) = 0(0)\nunsigned 8 4(4) >> -66(ffffffbe) = 0(0)\nunsigned 8 4(4) >> -65(ffffffbf) = 0(0)\nunsigned 8 4(4) >> -64(ffffffc0) = 4(4)\nunsigned 8 4(4) >> -63(ffffffc1) = 2(2)\nunsigned 8 4(4) >> -62(ffffffc2) = 1(1)\nunsigned 8 4(4) >> -61(ffffffc3) = 0(0)\nunsigned 8 4(4) >> -60(ffffffc4) = 0(0)\nunsigned 8 4(4) >> -59(ffffffc5) = 0(0)\nunsigned 8 4(4) >> -58(ffffffc6) = 0(0)\nunsigned 8 4(4) >> -57(ffffffc7) = 0(0)\nunsigned 8 4(4) >> -56(ffffffc8) = 0(0)\nunsigned 8 4(4) >> -55(ffffffc9) = 0(0)\nunsigned 8 4(4) >> -54(ffffffca) = 0(0)\nunsigned 8 4(4) >> -53(ffffffcb) = 0(0)\nunsigned 8 4(4) >> -52(ffffffcc) = 0(0)\nunsigned 8 4(4) >> -51(ffffffcd) = 0(0)\nunsigned 8 4(4) >> -50(ffffffce) = 0(0)\nunsigned 8 4(4) >> -49(ffffffcf) = 0(0)\nunsigned 8 4(4) >> -48(ffffffd0) = 0(0)\nunsigned 8 4(4) >> -47(ffffffd1) = 0(0)\nunsigned 8 4(4) >> -46(ffffffd2) = 0(0)\nunsigned 8 4(4) >> -45(ffffffd3) = 0(0)\nunsigned 8 4(4) >> -44(ffffffd4) = 0(0)\nunsigned 8 4(4) >> -43(ffffffd5) = 0(0)\nunsigned 8 4(4) >> -42(ffffffd6) = 0(0)\nunsigned 8 4(4) >> -41(ffffffd7) = 0(0)\nunsigned 8 4(4) >> -40(ffffffd8) = 0(0)\nunsigned 8 4(4) >> -39(ffffffd9) = 0(0)\nunsigned 8 4(4) >> -38(ffffffda) = 0(0)\nunsigned 8 4(4) >> -37(ffffffdb) = 0(0)\nunsigned 8 4(4) >> -36(ffffffdc) = 0(0)\nunsigned 8 4(4) >> -35(ffffffdd) = 0(0)\nunsigned 8 4(4) >> -34(ffffffde) = 0(0)\nunsigned 8 4(4) >> -33(ffffffdf) = 0(0)\nunsigned 8 4(4) >> -32(ffffffe0) = 4(4)\nunsigned 8 4(4) >> -31(ffffffe1) = 2(2)\nunsigned 8 4(4) >> -30(ffffffe2) = 1(1)\nunsigned 8 4(4) >> -29(ffffffe3) = 0(0)\nunsigned 8 4(4) >> -28(ffffffe4) = 0(0)\nunsigned 8 4(4) >> -27(ffffffe5) = 0(0)\nunsigned 8 4(4) >> -26(ffffffe6) = 0(0)\nunsigned 8 4(4) >> -25(ffffffe7) = 0(0)\nunsigned 8 4(4) >> -24(ffffffe8) = 0(0)\nunsigned 8 4(4) >> -23(ffffffe9) = 0(0)\nunsigned 8 4(4) >> -22(ffffffea) = 0(0)\nunsigned 8 4(4) >> -21(ffffffeb) = 0(0)\nunsigned 8 4(4) >> -20(ffffffec) = 0(0)\nunsigned 8 4(4) >> -19(ffffffed) = 0(0)\nunsigned 8 4(4) >> -18(ffffffee) = 0(0)\nunsigned 8 4(4) >> -17(ffffffef) = 0(0)\nunsigned 8 4(4) >> -16(fffffff0) = 0(0)\nunsigned 8 4(4) >> -15(fffffff1) = 0(0)\nunsigned 8 4(4) >> -14(fffffff2) = 0(0)\nunsigned 8 4(4) >> -13(fffffff3) = 0(0)\nunsigned 8 4(4) >> -12(fffffff4) = 0(0)\nunsigned 8 4(4) >> -11(fffffff5) = 0(0)\nunsigned 8 4(4) >> -10(fffffff6) = 0(0)\nunsigned 8 4(4) >> -9(fffffff7) = 0(0)\nunsigned 8 4(4) >> -8(fffffff8) = 0(0)\nunsigned 8 4(4) >> -7(fffffff9) = 0(0)\nunsigned 8 4(4) >> -6(fffffffa) = 0(0)\nunsigned 8 4(4) >> -5(fffffffb) = 0(0)\nunsigned 8 4(4) >> -4(fffffffc) = 0(0)\nunsigned 8 4(4) >> -3(fffffffd) = 0(0)\nunsigned 8 4(4) >> -2(fffffffe) = 0(0)\nunsigned 8 4(4) >> -1(ffffffff) = 0(0)\nunsigned 8 4(4) >> 0(0) = 4(4)\nunsigned 8 4(4) >> 1(1) = 2(2)\nunsigned 8 4(4) >> 2(2) = 1(1)\nunsigned 8 4(4) >> 3(3) = 0(0)\nunsigned 8 4(4) >> 4(4) = 0(0)\nunsigned 8 4(4) >> 5(5) = 0(0)\nunsigned 8 4(4) >> 6(6) = 0(0)\nunsigned 8 4(4) >> 7(7) = 0(0)\nunsigned 8 4(4) >> 8(8) = 0(0)\nunsigned 8 4(4) >> 9(9) = 0(0)\nunsigned 8 4(4) >> 10(a) = 0(0)\nunsigned 8 4(4) >> 11(b) = 0(0)\nunsigned 8 4(4) >> 12(c) = 0(0)\nunsigned 8 4(4) >> 13(d) = 0(0)\nunsigned 8 4(4) >> 14(e) = 0(0)\nunsigned 8 4(4) >> 15(f) = 0(0)\nunsigned 8 4(4) >> 16(10) = 0(0)\nunsigned 8 4(4) >> 17(11) = 0(0)\nunsigned 8 4(4) >> 18(12) = 0(0)\nunsigned 8 4(4) >> 19(13) = 0(0)\nunsigned 8 4(4) >> 20(14) = 0(0)\nunsigned 8 4(4) >> 21(15) = 0(0)\nunsigned 8 4(4) >> 22(16) = 0(0)\nunsigned 8 4(4) >> 23(17) = 0(0)\nunsigned 8 4(4) >> 24(18) = 0(0)\nunsigned 8 4(4) >> 25(19) = 0(0)\nunsigned 8 4(4) >> 26(1a) = 0(0)\nunsigned 8 4(4) >> 27(1b) = 0(0)\nunsigned 8 4(4) >> 28(1c) = 0(0)\nunsigned 8 4(4) >> 29(1d) = 0(0)\nunsigned 8 4(4) >> 30(1e) = 0(0)\nunsigned 8 4(4) >> 31(1f) = 0(0)\nunsigned 8 4(4) >> 32(20) = 4(4)\nunsigned 8 4(4) >> 33(21) = 2(2)\nunsigned 8 4(4) >> 34(22) = 1(1)\nunsigned 8 4(4) >> 35(23) = 0(0)\nunsigned 8 4(4) >> 36(24) = 0(0)\nunsigned 8 4(4) >> 37(25) = 0(0)\nunsigned 8 4(4) >> 38(26) = 0(0)\nunsigned 8 4(4) >> 39(27) = 0(0)\nunsigned 8 4(4) >> 40(28) = 0(0)\nunsigned 8 4(4) >> 41(29) = 0(0)\nunsigned 8 4(4) >> 42(2a) = 0(0)\nunsigned 8 4(4) >> 43(2b) = 0(0)\nunsigned 8 4(4) >> 44(2c) = 0(0)\nunsigned 8 4(4) >> 45(2d) = 0(0)\nunsigned 8 4(4) >> 46(2e) = 0(0)\nunsigned 8 4(4) >> 47(2f) = 0(0)\nunsigned 8 4(4) >> 48(30) = 0(0)\nunsigned 8 4(4) >> 49(31) = 0(0)\nunsigned 8 4(4) >> 50(32) = 0(0)\nunsigned 8 4(4) >> 51(33) = 0(0)\nunsigned 8 4(4) >> 52(34) = 0(0)\nunsigned 8 4(4) >> 53(35) = 0(0)\nunsigned 8 4(4) >> 54(36) = 0(0)\nunsigned 8 4(4) >> 55(37) = 0(0)\nunsigned 8 4(4) >> 56(38) = 0(0)\nunsigned 8 4(4) >> 57(39) = 0(0)\nunsigned 8 4(4) >> 58(3a) = 0(0)\nunsigned 8 4(4) >> 59(3b) = 0(0)\nunsigned 8 4(4) >> 60(3c) = 0(0)\nunsigned 8 4(4) >> 61(3d) = 0(0)\nunsigned 8 4(4) >> 62(3e) = 0(0)\nunsigned 8 4(4) >> 63(3f) = 0(0)\nunsigned 8 4(4) >> 64(40) = 4(4)\nunsigned 8 4(4) >> 65(41) = 2(2)\nunsigned 8 4(4) >> 66(42) = 1(1)\nunsigned 8 4(4) >> 67(43) = 0(0)\nunsigned 8 4(4) >> 68(44) = 0(0)\nunsigned 8 4(4) >> 69(45) = 0(0)\nunsigned 8 4(4) >> 70(46) = 0(0)\nunsigned 8 4(4) >> 71(47) = 0(0)\nunsigned 8 4(4) >> 72(48) = 0(0)\nunsigned 8 4(4) >> 73(49) = 0(0)\nunsigned 8 4(4) >> 74(4a) = 0(0)\nunsigned 8 4(4) >> 75(4b) = 0(0)\nunsigned 8 4(4) >> 76(4c) = 0(0)\nunsigned 8 4(4) >> 77(4d) = 0(0)\nunsigned 8 4(4) >> 78(4e) = 0(0)\nunsigned 8 4(4) >> 79(4f) = 0(0)\nunsigned 8 4(4) >> 80(50) = 0(0)\nunsigned 8 4(4) >> 81(51) = 0(0)\nunsigned 8 4(4) >> 82(52) = 0(0)\nunsigned 8 4(4) >> 83(53) = 0(0)\nunsigned 8 4(4) >> 84(54) = 0(0)\nunsigned 8 4(4) >> 85(55) = 0(0)\nunsigned 8 4(4) >> 86(56) = 0(0)\nunsigned 8 4(4) >> 87(57) = 0(0)\nunsigned 8 4(4) >> 88(58) = 0(0)\nunsigned 8 4(4) >> 89(59) = 0(0)\nunsigned 8 4(4) >> 90(5a) = 0(0)\nunsigned 8 4(4) >> 91(5b) = 0(0)\nunsigned 8 4(4) >> 92(5c) = 0(0)\nunsigned 8 4(4) >> 93(5d) = 0(0)\nunsigned 8 4(4) >> 94(5e) = 0(0)\nunsigned 8 4(4) >> 95(5f) = 0(0)\nunsigned 8 4(4) >> 96(60) = 4(4)\nunsigned 8 4(4) >> 97(61) = 2(2)\nunsigned 8 4(4) >> 98(62) = 1(1)\nunsigned 8 4(4) >> 99(63) = 0(0)\nunsigned 8 4(4) >> 100(64) = 0(0)\nunsigned 8 4(4) >> 101(65) = 0(0)\nunsigned 8 4(4) >> 102(66) = 0(0)\nunsigned 8 4(4) >> 103(67) = 0(0)\nunsigned 8 4(4) >> 104(68) = 0(0)\nunsigned 8 4(4) >> 105(69) = 0(0)\nunsigned 8 4(4) >> 106(6a) = 0(0)\nunsigned 8 4(4) >> 107(6b) = 0(0)\nunsigned 8 4(4) >> 108(6c) = 0(0)\nunsigned 8 4(4) >> 109(6d) = 0(0)\nunsigned 8 4(4) >> 110(6e) = 0(0)\nunsigned 8 4(4) >> 111(6f) = 0(0)\nunsigned 8 4(4) >> 112(70) = 0(0)\nunsigned 8 4(4) >> 113(71) = 0(0)\nunsigned 8 4(4) >> 114(72) = 0(0)\nunsigned 8 4(4) >> 115(73) = 0(0)\nunsigned 8 4(4) >> 116(74) = 0(0)\nunsigned 8 4(4) >> 117(75) = 0(0)\nunsigned 8 4(4) >> 118(76) = 0(0)\nunsigned 8 4(4) >> 119(77) = 0(0)\nunsigned 8 4(4) >> 120(78) = 0(0)\nunsigned 8 4(4) >> 121(79) = 0(0)\nunsigned 8 4(4) >> 122(7a) = 0(0)\nunsigned 8 4(4) >> 123(7b) = 0(0)\nunsigned 8 4(4) >> 124(7c) = 0(0)\nunsigned 8 4(4) >> 125(7d) = 0(0)\nunsigned 8 4(4) >> 126(7e) = 0(0)\nunsigned 8 4(4) >> 127(7f) = 0(0)\n  signed 8 -4(fffffffc) << -128(ffffff80) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -127(ffffff81) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -126(ffffff82) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -125(ffffff83) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -124(ffffff84) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -123(ffffff85) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -122(ffffff86) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -121(ffffff87) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -120(ffffff88) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -119(ffffff89) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -118(ffffff8a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -117(ffffff8b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -116(ffffff8c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -115(ffffff8d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -114(ffffff8e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -113(ffffff8f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -112(ffffff90) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -111(ffffff91) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -110(ffffff92) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -109(ffffff93) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -108(ffffff94) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -107(ffffff95) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -106(ffffff96) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -105(ffffff97) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -104(ffffff98) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -103(ffffff99) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -102(ffffff9a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -101(ffffff9b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -100(ffffff9c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -99(ffffff9d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -98(ffffff9e) = 0(0)\n  signed 8 -4(fffffffc) << -97(ffffff9f) = 0(0)\n  signed 8 -4(fffffffc) << -96(ffffffa0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -95(ffffffa1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -94(ffffffa2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -93(ffffffa3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -92(ffffffa4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -91(ffffffa5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -90(ffffffa6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -89(ffffffa7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -88(ffffffa8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -87(ffffffa9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -86(ffffffaa) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -85(ffffffab) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -84(ffffffac) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -83(ffffffad) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -82(ffffffae) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -81(ffffffaf) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -80(ffffffb0) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -79(ffffffb1) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -78(ffffffb2) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -77(ffffffb3) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -76(ffffffb4) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -75(ffffffb5) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -74(ffffffb6) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -73(ffffffb7) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -72(ffffffb8) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -71(ffffffb9) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -70(ffffffba) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -69(ffffffbb) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -68(ffffffbc) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -67(ffffffbd) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -66(ffffffbe) = 0(0)\n  signed 8 -4(fffffffc) << -65(ffffffbf) = 0(0)\n  signed 8 -4(fffffffc) << -64(ffffffc0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -63(ffffffc1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -62(ffffffc2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -61(ffffffc3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -60(ffffffc4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -59(ffffffc5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -58(ffffffc6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -57(ffffffc7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -56(ffffffc8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -55(ffffffc9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -54(ffffffca) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -53(ffffffcb) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -52(ffffffcc) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -51(ffffffcd) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -50(ffffffce) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -49(ffffffcf) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -48(ffffffd0) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -47(ffffffd1) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -46(ffffffd2) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -45(ffffffd3) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -44(ffffffd4) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -43(ffffffd5) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -42(ffffffd6) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -41(ffffffd7) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -40(ffffffd8) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -39(ffffffd9) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -38(ffffffda) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -37(ffffffdb) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -36(ffffffdc) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -35(ffffffdd) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -34(ffffffde) = 0(0)\n  signed 8 -4(fffffffc) << -33(ffffffdf) = 0(0)\n  signed 8 -4(fffffffc) << -32(ffffffe0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -31(ffffffe1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -30(ffffffe2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -29(ffffffe3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -28(ffffffe4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -27(ffffffe5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -26(ffffffe6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -25(ffffffe7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -24(ffffffe8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -23(ffffffe9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -22(ffffffea) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -21(ffffffeb) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -20(ffffffec) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -19(ffffffed) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -18(ffffffee) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -17(ffffffef) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -16(fffffff0) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -15(fffffff1) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -14(fffffff2) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -13(fffffff3) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -12(fffffff4) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -11(fffffff5) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -10(fffffff6) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -9(fffffff7) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -8(fffffff8) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -7(fffffff9) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -6(fffffffa) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -5(fffffffb) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -4(fffffffc) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -3(fffffffd) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -2(fffffffe) = 0(0)\n  signed 8 -4(fffffffc) << -1(ffffffff) = 0(0)\n  signed 8 -4(fffffffc) << 0(0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 1(1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 2(2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 3(3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 4(4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 5(5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 6(6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 7(7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 8(8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 9(9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 10(a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 11(b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 12(c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 13(d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 14(e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 15(f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 16(10) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 17(11) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 18(12) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 19(13) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 20(14) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 21(15) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 22(16) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 23(17) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 24(18) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 25(19) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 26(1a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 27(1b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 28(1c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 29(1d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 30(1e) = 0(0)\n  signed 8 -4(fffffffc) << 31(1f) = 0(0)\n  signed 8 -4(fffffffc) << 32(20) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 33(21) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 34(22) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 35(23) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 36(24) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 37(25) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 38(26) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 39(27) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 40(28) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 41(29) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 42(2a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 43(2b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 44(2c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 45(2d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 46(2e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 47(2f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 48(30) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 49(31) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 50(32) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 51(33) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 52(34) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 53(35) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 54(36) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 55(37) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 56(38) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 57(39) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 58(3a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 59(3b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 60(3c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 61(3d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 62(3e) = 0(0)\n  signed 8 -4(fffffffc) << 63(3f) = 0(0)\n  signed 8 -4(fffffffc) << 64(40) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 65(41) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 66(42) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 67(43) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 68(44) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 69(45) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 70(46) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 71(47) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 72(48) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 73(49) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 74(4a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 75(4b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 76(4c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 77(4d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 78(4e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 79(4f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 80(50) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 81(51) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 82(52) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 83(53) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 84(54) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 85(55) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 86(56) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 87(57) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 88(58) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 89(59) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 90(5a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 91(5b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 92(5c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 93(5d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 94(5e) = 0(0)\n  signed 8 -4(fffffffc) << 95(5f) = 0(0)\n  signed 8 -4(fffffffc) << 96(60) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 97(61) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 98(62) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 99(63) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 100(64) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 101(65) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 102(66) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 103(67) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 104(68) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 105(69) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 106(6a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 107(6b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 108(6c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 109(6d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 110(6e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 111(6f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 112(70) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 113(71) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 114(72) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 115(73) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 116(74) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 117(75) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 118(76) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 119(77) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 120(78) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 121(79) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 122(7a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 123(7b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 124(7c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 125(7d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 126(7e) = 0(0)\n  signed 8 -4(fffffffc) << 127(7f) = 0(0)\n  signed 8 -3(fffffffd) << -128(ffffff80) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -127(ffffff81) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -126(ffffff82) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -125(ffffff83) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -124(ffffff84) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -123(ffffff85) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -122(ffffff86) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -121(ffffff87) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -120(ffffff88) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -119(ffffff89) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -118(ffffff8a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -117(ffffff8b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -116(ffffff8c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -115(ffffff8d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -114(ffffff8e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -113(ffffff8f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -112(ffffff90) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -111(ffffff91) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -110(ffffff92) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -109(ffffff93) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -108(ffffff94) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -107(ffffff95) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -106(ffffff96) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -105(ffffff97) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -104(ffffff98) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -103(ffffff99) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -102(ffffff9a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -101(ffffff9b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -100(ffffff9c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -99(ffffff9d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -98(ffffff9e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << -96(ffffffa0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -95(ffffffa1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -94(ffffffa2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -93(ffffffa3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -92(ffffffa4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -91(ffffffa5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -90(ffffffa6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -89(ffffffa7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -88(ffffffa8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -87(ffffffa9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -86(ffffffaa) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -85(ffffffab) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -84(ffffffac) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -83(ffffffad) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -82(ffffffae) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -81(ffffffaf) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -80(ffffffb0) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -79(ffffffb1) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -78(ffffffb2) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -77(ffffffb3) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -76(ffffffb4) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -75(ffffffb5) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -74(ffffffb6) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -73(ffffffb7) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -72(ffffffb8) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -71(ffffffb9) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -70(ffffffba) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -69(ffffffbb) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -68(ffffffbc) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -67(ffffffbd) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -66(ffffffbe) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -65(ffffffbf) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << -64(ffffffc0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -63(ffffffc1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -62(ffffffc2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -61(ffffffc3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -60(ffffffc4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -59(ffffffc5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -58(ffffffc6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -57(ffffffc7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -56(ffffffc8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -55(ffffffc9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -54(ffffffca) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -53(ffffffcb) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -52(ffffffcc) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -51(ffffffcd) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -50(ffffffce) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -49(ffffffcf) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -48(ffffffd0) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -47(ffffffd1) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -46(ffffffd2) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -45(ffffffd3) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -44(ffffffd4) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -43(ffffffd5) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -42(ffffffd6) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -41(ffffffd7) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -40(ffffffd8) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -39(ffffffd9) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -38(ffffffda) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -37(ffffffdb) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -36(ffffffdc) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -35(ffffffdd) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -34(ffffffde) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << -32(ffffffe0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -31(ffffffe1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -30(ffffffe2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -29(ffffffe3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -28(ffffffe4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -27(ffffffe5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -26(ffffffe6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -25(ffffffe7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -24(ffffffe8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -23(ffffffe9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -22(ffffffea) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -21(ffffffeb) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -20(ffffffec) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -19(ffffffed) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -18(ffffffee) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -17(ffffffef) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -16(fffffff0) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -15(fffffff1) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -14(fffffff2) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -13(fffffff3) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -12(fffffff4) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -11(fffffff5) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -10(fffffff6) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -9(fffffff7) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -8(fffffff8) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -7(fffffff9) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -6(fffffffa) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -5(fffffffb) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -4(fffffffc) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -3(fffffffd) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -2(fffffffe) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -1(ffffffff) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 0(0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 1(1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 2(2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 3(3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 4(4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 5(5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 6(6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 7(7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 8(8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 9(9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 10(a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 11(b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 12(c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 13(d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 14(e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 15(f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 16(10) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 17(11) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 18(12) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 19(13) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 20(14) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 21(15) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 22(16) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 23(17) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 24(18) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 25(19) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 26(1a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 27(1b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 28(1c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 29(1d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 30(1e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 31(1f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 32(20) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 33(21) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 34(22) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 35(23) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 36(24) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 37(25) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 38(26) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 39(27) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 40(28) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 41(29) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 42(2a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 43(2b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 44(2c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 45(2d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 46(2e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 47(2f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 48(30) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 49(31) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 50(32) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 51(33) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 52(34) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 53(35) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 54(36) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 55(37) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 56(38) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 57(39) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 58(3a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 59(3b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 60(3c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 61(3d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 62(3e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 63(3f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 64(40) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 65(41) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 66(42) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 67(43) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 68(44) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 69(45) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 70(46) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 71(47) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 72(48) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 73(49) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 74(4a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 75(4b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 76(4c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 77(4d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 78(4e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 79(4f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 80(50) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 81(51) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 82(52) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 83(53) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 84(54) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 85(55) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 86(56) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 87(57) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 88(58) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 89(59) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 90(5a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 91(5b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 92(5c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 93(5d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 94(5e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 95(5f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 96(60) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 97(61) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 98(62) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 99(63) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 100(64) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 101(65) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 102(66) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 103(67) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 104(68) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 105(69) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 106(6a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 107(6b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 108(6c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 109(6d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 110(6e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 111(6f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 112(70) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 113(71) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 114(72) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 115(73) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 116(74) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 117(75) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 118(76) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 119(77) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 120(78) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 121(79) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 122(7a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 123(7b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 124(7c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 125(7d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 126(7e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 127(7f) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -128(ffffff80) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -127(ffffff81) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -126(ffffff82) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -125(ffffff83) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -124(ffffff84) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -123(ffffff85) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -122(ffffff86) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -121(ffffff87) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -120(ffffff88) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -119(ffffff89) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -118(ffffff8a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -117(ffffff8b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -116(ffffff8c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -115(ffffff8d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -114(ffffff8e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -113(ffffff8f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -112(ffffff90) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -111(ffffff91) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -110(ffffff92) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -109(ffffff93) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -108(ffffff94) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -107(ffffff95) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -106(ffffff96) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -105(ffffff97) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -104(ffffff98) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -103(ffffff99) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -102(ffffff9a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -101(ffffff9b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -100(ffffff9c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -99(ffffff9d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -98(ffffff9e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -97(ffffff9f) = 0(0)\n  signed 8 -2(fffffffe) << -96(ffffffa0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -95(ffffffa1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -94(ffffffa2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -93(ffffffa3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -92(ffffffa4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -91(ffffffa5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -90(ffffffa6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -89(ffffffa7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -88(ffffffa8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -87(ffffffa9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -86(ffffffaa) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -85(ffffffab) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -84(ffffffac) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -83(ffffffad) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -82(ffffffae) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -81(ffffffaf) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -80(ffffffb0) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -79(ffffffb1) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -78(ffffffb2) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -77(ffffffb3) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -76(ffffffb4) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -75(ffffffb5) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -74(ffffffb6) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -73(ffffffb7) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -72(ffffffb8) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -71(ffffffb9) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -70(ffffffba) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -69(ffffffbb) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -68(ffffffbc) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -67(ffffffbd) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -66(ffffffbe) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -65(ffffffbf) = 0(0)\n  signed 8 -2(fffffffe) << -64(ffffffc0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -63(ffffffc1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -62(ffffffc2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -61(ffffffc3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -60(ffffffc4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -59(ffffffc5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -58(ffffffc6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -57(ffffffc7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -56(ffffffc8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -55(ffffffc9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -54(ffffffca) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -53(ffffffcb) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -52(ffffffcc) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -51(ffffffcd) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -50(ffffffce) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -49(ffffffcf) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -48(ffffffd0) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -47(ffffffd1) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -46(ffffffd2) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -45(ffffffd3) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -44(ffffffd4) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -43(ffffffd5) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -42(ffffffd6) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -41(ffffffd7) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -40(ffffffd8) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -39(ffffffd9) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -38(ffffffda) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -37(ffffffdb) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -36(ffffffdc) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -35(ffffffdd) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -34(ffffffde) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -33(ffffffdf) = 0(0)\n  signed 8 -2(fffffffe) << -32(ffffffe0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -31(ffffffe1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -30(ffffffe2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -29(ffffffe3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -28(ffffffe4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -27(ffffffe5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -26(ffffffe6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -25(ffffffe7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -24(ffffffe8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -23(ffffffe9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -22(ffffffea) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -21(ffffffeb) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -20(ffffffec) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -19(ffffffed) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -18(ffffffee) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -17(ffffffef) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -16(fffffff0) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -15(fffffff1) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -14(fffffff2) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -13(fffffff3) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -12(fffffff4) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -11(fffffff5) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -10(fffffff6) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -9(fffffff7) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -8(fffffff8) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -7(fffffff9) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -6(fffffffa) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -5(fffffffb) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -4(fffffffc) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -3(fffffffd) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -2(fffffffe) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -1(ffffffff) = 0(0)\n  signed 8 -2(fffffffe) << 0(0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 1(1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 2(2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 3(3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 4(4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 5(5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 6(6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 7(7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 8(8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 9(9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 10(a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 11(b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 12(c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 13(d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 14(e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 15(f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 16(10) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 17(11) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 18(12) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 19(13) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 20(14) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 21(15) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 22(16) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 23(17) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 24(18) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 25(19) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 26(1a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 27(1b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 28(1c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 29(1d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 30(1e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 31(1f) = 0(0)\n  signed 8 -2(fffffffe) << 32(20) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 33(21) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 34(22) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 35(23) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 36(24) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 37(25) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 38(26) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 39(27) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 40(28) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 41(29) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 42(2a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 43(2b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 44(2c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 45(2d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 46(2e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 47(2f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 48(30) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 49(31) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 50(32) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 51(33) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 52(34) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 53(35) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 54(36) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 55(37) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 56(38) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 57(39) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 58(3a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 59(3b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 60(3c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 61(3d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 62(3e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 63(3f) = 0(0)\n  signed 8 -2(fffffffe) << 64(40) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 65(41) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 66(42) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 67(43) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 68(44) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 69(45) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 70(46) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 71(47) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 72(48) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 73(49) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 74(4a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 75(4b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 76(4c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 77(4d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 78(4e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 79(4f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 80(50) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 81(51) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 82(52) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 83(53) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 84(54) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 85(55) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 86(56) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 87(57) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 88(58) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 89(59) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 90(5a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 91(5b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 92(5c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 93(5d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 94(5e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 95(5f) = 0(0)\n  signed 8 -2(fffffffe) << 96(60) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 97(61) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 98(62) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 99(63) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 100(64) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 101(65) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 102(66) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 103(67) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 104(68) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 105(69) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 106(6a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 107(6b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 108(6c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 109(6d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 110(6e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 111(6f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 112(70) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 113(71) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 114(72) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 115(73) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 116(74) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 117(75) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 118(76) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 119(77) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 120(78) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 121(79) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 122(7a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 123(7b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 124(7c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 125(7d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 126(7e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 127(7f) = 0(0)\n  signed 8 -1(ffffffff) << -128(ffffff80) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -127(ffffff81) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -126(ffffff82) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -125(ffffff83) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -124(ffffff84) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -123(ffffff85) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -122(ffffff86) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -121(ffffff87) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -120(ffffff88) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -119(ffffff89) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -118(ffffff8a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -117(ffffff8b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -116(ffffff8c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -115(ffffff8d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -114(ffffff8e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -113(ffffff8f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -112(ffffff90) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -111(ffffff91) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -110(ffffff92) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -109(ffffff93) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -108(ffffff94) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -107(ffffff95) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -106(ffffff96) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -105(ffffff97) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -104(ffffff98) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -103(ffffff99) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -102(ffffff9a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -101(ffffff9b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -100(ffffff9c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -99(ffffff9d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -98(ffffff9e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << -96(ffffffa0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -95(ffffffa1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -94(ffffffa2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -93(ffffffa3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -92(ffffffa4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -91(ffffffa5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -90(ffffffa6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -89(ffffffa7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -88(ffffffa8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -87(ffffffa9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -86(ffffffaa) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -85(ffffffab) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -84(ffffffac) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -83(ffffffad) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -82(ffffffae) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -81(ffffffaf) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -80(ffffffb0) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -79(ffffffb1) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -78(ffffffb2) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -77(ffffffb3) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -76(ffffffb4) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -75(ffffffb5) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -74(ffffffb6) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -73(ffffffb7) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -72(ffffffb8) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -71(ffffffb9) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -70(ffffffba) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -69(ffffffbb) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -68(ffffffbc) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -67(ffffffbd) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -66(ffffffbe) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -65(ffffffbf) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << -64(ffffffc0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -63(ffffffc1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -62(ffffffc2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -61(ffffffc3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -60(ffffffc4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -59(ffffffc5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -58(ffffffc6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -57(ffffffc7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -56(ffffffc8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -55(ffffffc9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -54(ffffffca) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -53(ffffffcb) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -52(ffffffcc) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -51(ffffffcd) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -50(ffffffce) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -49(ffffffcf) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -48(ffffffd0) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -47(ffffffd1) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -46(ffffffd2) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -45(ffffffd3) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -44(ffffffd4) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -43(ffffffd5) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -42(ffffffd6) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -41(ffffffd7) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -40(ffffffd8) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -39(ffffffd9) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -38(ffffffda) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -37(ffffffdb) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -36(ffffffdc) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -35(ffffffdd) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -34(ffffffde) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << -32(ffffffe0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -31(ffffffe1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -30(ffffffe2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -29(ffffffe3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -28(ffffffe4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -27(ffffffe5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -26(ffffffe6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -25(ffffffe7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -24(ffffffe8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -23(ffffffe9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -22(ffffffea) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -21(ffffffeb) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -20(ffffffec) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -19(ffffffed) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -18(ffffffee) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -17(ffffffef) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -16(fffffff0) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -15(fffffff1) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -14(fffffff2) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -13(fffffff3) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -12(fffffff4) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -11(fffffff5) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -10(fffffff6) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -9(fffffff7) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -8(fffffff8) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -7(fffffff9) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -6(fffffffa) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -5(fffffffb) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -4(fffffffc) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -3(fffffffd) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -2(fffffffe) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -1(ffffffff) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 0(0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 1(1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 2(2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 3(3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 4(4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 5(5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 6(6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 7(7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 8(8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 9(9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 10(a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 11(b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 12(c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 13(d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 14(e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 15(f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 16(10) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 17(11) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 18(12) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 19(13) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 20(14) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 21(15) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 22(16) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 23(17) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 24(18) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 25(19) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 26(1a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 27(1b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 28(1c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 29(1d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 30(1e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 31(1f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 32(20) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 33(21) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 34(22) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 35(23) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 36(24) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 37(25) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 38(26) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 39(27) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 40(28) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 41(29) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 42(2a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 43(2b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 44(2c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 45(2d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 46(2e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 47(2f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 48(30) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 49(31) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 50(32) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 51(33) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 52(34) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 53(35) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 54(36) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 55(37) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 56(38) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 57(39) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 58(3a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 59(3b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 60(3c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 61(3d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 62(3e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 63(3f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 64(40) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 65(41) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 66(42) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 67(43) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 68(44) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 69(45) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 70(46) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 71(47) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 72(48) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 73(49) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 74(4a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 75(4b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 76(4c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 77(4d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 78(4e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 79(4f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 80(50) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 81(51) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 82(52) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 83(53) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 84(54) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 85(55) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 86(56) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 87(57) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 88(58) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 89(59) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 90(5a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 91(5b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 92(5c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 93(5d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 94(5e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 95(5f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 96(60) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 97(61) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 98(62) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 99(63) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 100(64) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 101(65) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 102(66) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 103(67) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 104(68) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 105(69) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 106(6a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 107(6b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 108(6c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 109(6d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 110(6e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 111(6f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 112(70) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 113(71) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 114(72) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 115(73) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 116(74) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 117(75) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 118(76) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 119(77) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 120(78) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 121(79) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 122(7a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 123(7b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 124(7c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 125(7d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 126(7e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 127(7f) = -2147483648(80000000)\n  signed 8 0(0) << -128(ffffff80) = 0(0)\n  signed 8 0(0) << -127(ffffff81) = 0(0)\n  signed 8 0(0) << -126(ffffff82) = 0(0)\n  signed 8 0(0) << -125(ffffff83) = 0(0)\n  signed 8 0(0) << -124(ffffff84) = 0(0)\n  signed 8 0(0) << -123(ffffff85) = 0(0)\n  signed 8 0(0) << -122(ffffff86) = 0(0)\n  signed 8 0(0) << -121(ffffff87) = 0(0)\n  signed 8 0(0) << -120(ffffff88) = 0(0)\n  signed 8 0(0) << -119(ffffff89) = 0(0)\n  signed 8 0(0) << -118(ffffff8a) = 0(0)\n  signed 8 0(0) << -117(ffffff8b) = 0(0)\n  signed 8 0(0) << -116(ffffff8c) = 0(0)\n  signed 8 0(0) << -115(ffffff8d) = 0(0)\n  signed 8 0(0) << -114(ffffff8e) = 0(0)\n  signed 8 0(0) << -113(ffffff8f) = 0(0)\n  signed 8 0(0) << -112(ffffff90) = 0(0)\n  signed 8 0(0) << -111(ffffff91) = 0(0)\n  signed 8 0(0) << -110(ffffff92) = 0(0)\n  signed 8 0(0) << -109(ffffff93) = 0(0)\n  signed 8 0(0) << -108(ffffff94) = 0(0)\n  signed 8 0(0) << -107(ffffff95) = 0(0)\n  signed 8 0(0) << -106(ffffff96) = 0(0)\n  signed 8 0(0) << -105(ffffff97) = 0(0)\n  signed 8 0(0) << -104(ffffff98) = 0(0)\n  signed 8 0(0) << -103(ffffff99) = 0(0)\n  signed 8 0(0) << -102(ffffff9a) = 0(0)\n  signed 8 0(0) << -101(ffffff9b) = 0(0)\n  signed 8 0(0) << -100(ffffff9c) = 0(0)\n  signed 8 0(0) << -99(ffffff9d) = 0(0)\n  signed 8 0(0) << -98(ffffff9e) = 0(0)\n  signed 8 0(0) << -97(ffffff9f) = 0(0)\n  signed 8 0(0) << -96(ffffffa0) = 0(0)\n  signed 8 0(0) << -95(ffffffa1) = 0(0)\n  signed 8 0(0) << -94(ffffffa2) = 0(0)\n  signed 8 0(0) << -93(ffffffa3) = 0(0)\n  signed 8 0(0) << -92(ffffffa4) = 0(0)\n  signed 8 0(0) << -91(ffffffa5) = 0(0)\n  signed 8 0(0) << -90(ffffffa6) = 0(0)\n  signed 8 0(0) << -89(ffffffa7) = 0(0)\n  signed 8 0(0) << -88(ffffffa8) = 0(0)\n  signed 8 0(0) << -87(ffffffa9) = 0(0)\n  signed 8 0(0) << -86(ffffffaa) = 0(0)\n  signed 8 0(0) << -85(ffffffab) = 0(0)\n  signed 8 0(0) << -84(ffffffac) = 0(0)\n  signed 8 0(0) << -83(ffffffad) = 0(0)\n  signed 8 0(0) << -82(ffffffae) = 0(0)\n  signed 8 0(0) << -81(ffffffaf) = 0(0)\n  signed 8 0(0) << -80(ffffffb0) = 0(0)\n  signed 8 0(0) << -79(ffffffb1) = 0(0)\n  signed 8 0(0) << -78(ffffffb2) = 0(0)\n  signed 8 0(0) << -77(ffffffb3) = 0(0)\n  signed 8 0(0) << -76(ffffffb4) = 0(0)\n  signed 8 0(0) << -75(ffffffb5) = 0(0)\n  signed 8 0(0) << -74(ffffffb6) = 0(0)\n  signed 8 0(0) << -73(ffffffb7) = 0(0)\n  signed 8 0(0) << -72(ffffffb8) = 0(0)\n  signed 8 0(0) << -71(ffffffb9) = 0(0)\n  signed 8 0(0) << -70(ffffffba) = 0(0)\n  signed 8 0(0) << -69(ffffffbb) = 0(0)\n  signed 8 0(0) << -68(ffffffbc) = 0(0)\n  signed 8 0(0) << -67(ffffffbd) = 0(0)\n  signed 8 0(0) << -66(ffffffbe) = 0(0)\n  signed 8 0(0) << -65(ffffffbf) = 0(0)\n  signed 8 0(0) << -64(ffffffc0) = 0(0)\n  signed 8 0(0) << -63(ffffffc1) = 0(0)\n  signed 8 0(0) << -62(ffffffc2) = 0(0)\n  signed 8 0(0) << -61(ffffffc3) = 0(0)\n  signed 8 0(0) << -60(ffffffc4) = 0(0)\n  signed 8 0(0) << -59(ffffffc5) = 0(0)\n  signed 8 0(0) << -58(ffffffc6) = 0(0)\n  signed 8 0(0) << -57(ffffffc7) = 0(0)\n  signed 8 0(0) << -56(ffffffc8) = 0(0)\n  signed 8 0(0) << -55(ffffffc9) = 0(0)\n  signed 8 0(0) << -54(ffffffca) = 0(0)\n  signed 8 0(0) << -53(ffffffcb) = 0(0)\n  signed 8 0(0) << -52(ffffffcc) = 0(0)\n  signed 8 0(0) << -51(ffffffcd) = 0(0)\n  signed 8 0(0) << -50(ffffffce) = 0(0)\n  signed 8 0(0) << -49(ffffffcf) = 0(0)\n  signed 8 0(0) << -48(ffffffd0) = 0(0)\n  signed 8 0(0) << -47(ffffffd1) = 0(0)\n  signed 8 0(0) << -46(ffffffd2) = 0(0)\n  signed 8 0(0) << -45(ffffffd3) = 0(0)\n  signed 8 0(0) << -44(ffffffd4) = 0(0)\n  signed 8 0(0) << -43(ffffffd5) = 0(0)\n  signed 8 0(0) << -42(ffffffd6) = 0(0)\n  signed 8 0(0) << -41(ffffffd7) = 0(0)\n  signed 8 0(0) << -40(ffffffd8) = 0(0)\n  signed 8 0(0) << -39(ffffffd9) = 0(0)\n  signed 8 0(0) << -38(ffffffda) = 0(0)\n  signed 8 0(0) << -37(ffffffdb) = 0(0)\n  signed 8 0(0) << -36(ffffffdc) = 0(0)\n  signed 8 0(0) << -35(ffffffdd) = 0(0)\n  signed 8 0(0) << -34(ffffffde) = 0(0)\n  signed 8 0(0) << -33(ffffffdf) = 0(0)\n  signed 8 0(0) << -32(ffffffe0) = 0(0)\n  signed 8 0(0) << -31(ffffffe1) = 0(0)\n  signed 8 0(0) << -30(ffffffe2) = 0(0)\n  signed 8 0(0) << -29(ffffffe3) = 0(0)\n  signed 8 0(0) << -28(ffffffe4) = 0(0)\n  signed 8 0(0) << -27(ffffffe5) = 0(0)\n  signed 8 0(0) << -26(ffffffe6) = 0(0)\n  signed 8 0(0) << -25(ffffffe7) = 0(0)\n  signed 8 0(0) << -24(ffffffe8) = 0(0)\n  signed 8 0(0) << -23(ffffffe9) = 0(0)\n  signed 8 0(0) << -22(ffffffea) = 0(0)\n  signed 8 0(0) << -21(ffffffeb) = 0(0)\n  signed 8 0(0) << -20(ffffffec) = 0(0)\n  signed 8 0(0) << -19(ffffffed) = 0(0)\n  signed 8 0(0) << -18(ffffffee) = 0(0)\n  signed 8 0(0) << -17(ffffffef) = 0(0)\n  signed 8 0(0) << -16(fffffff0) = 0(0)\n  signed 8 0(0) << -15(fffffff1) = 0(0)\n  signed 8 0(0) << -14(fffffff2) = 0(0)\n  signed 8 0(0) << -13(fffffff3) = 0(0)\n  signed 8 0(0) << -12(fffffff4) = 0(0)\n  signed 8 0(0) << -11(fffffff5) = 0(0)\n  signed 8 0(0) << -10(fffffff6) = 0(0)\n  signed 8 0(0) << -9(fffffff7) = 0(0)\n  signed 8 0(0) << -8(fffffff8) = 0(0)\n  signed 8 0(0) << -7(fffffff9) = 0(0)\n  signed 8 0(0) << -6(fffffffa) = 0(0)\n  signed 8 0(0) << -5(fffffffb) = 0(0)\n  signed 8 0(0) << -4(fffffffc) = 0(0)\n  signed 8 0(0) << -3(fffffffd) = 0(0)\n  signed 8 0(0) << -2(fffffffe) = 0(0)\n  signed 8 0(0) << -1(ffffffff) = 0(0)\n  signed 8 0(0) << 0(0) = 0(0)\n  signed 8 0(0) << 1(1) = 0(0)\n  signed 8 0(0) << 2(2) = 0(0)\n  signed 8 0(0) << 3(3) = 0(0)\n  signed 8 0(0) << 4(4) = 0(0)\n  signed 8 0(0) << 5(5) = 0(0)\n  signed 8 0(0) << 6(6) = 0(0)\n  signed 8 0(0) << 7(7) = 0(0)\n  signed 8 0(0) << 8(8) = 0(0)\n  signed 8 0(0) << 9(9) = 0(0)\n  signed 8 0(0) << 10(a) = 0(0)\n  signed 8 0(0) << 11(b) = 0(0)\n  signed 8 0(0) << 12(c) = 0(0)\n  signed 8 0(0) << 13(d) = 0(0)\n  signed 8 0(0) << 14(e) = 0(0)\n  signed 8 0(0) << 15(f) = 0(0)\n  signed 8 0(0) << 16(10) = 0(0)\n  signed 8 0(0) << 17(11) = 0(0)\n  signed 8 0(0) << 18(12) = 0(0)\n  signed 8 0(0) << 19(13) = 0(0)\n  signed 8 0(0) << 20(14) = 0(0)\n  signed 8 0(0) << 21(15) = 0(0)\n  signed 8 0(0) << 22(16) = 0(0)\n  signed 8 0(0) << 23(17) = 0(0)\n  signed 8 0(0) << 24(18) = 0(0)\n  signed 8 0(0) << 25(19) = 0(0)\n  signed 8 0(0) << 26(1a) = 0(0)\n  signed 8 0(0) << 27(1b) = 0(0)\n  signed 8 0(0) << 28(1c) = 0(0)\n  signed 8 0(0) << 29(1d) = 0(0)\n  signed 8 0(0) << 30(1e) = 0(0)\n  signed 8 0(0) << 31(1f) = 0(0)\n  signed 8 0(0) << 32(20) = 0(0)\n  signed 8 0(0) << 33(21) = 0(0)\n  signed 8 0(0) << 34(22) = 0(0)\n  signed 8 0(0) << 35(23) = 0(0)\n  signed 8 0(0) << 36(24) = 0(0)\n  signed 8 0(0) << 37(25) = 0(0)\n  signed 8 0(0) << 38(26) = 0(0)\n  signed 8 0(0) << 39(27) = 0(0)\n  signed 8 0(0) << 40(28) = 0(0)\n  signed 8 0(0) << 41(29) = 0(0)\n  signed 8 0(0) << 42(2a) = 0(0)\n  signed 8 0(0) << 43(2b) = 0(0)\n  signed 8 0(0) << 44(2c) = 0(0)\n  signed 8 0(0) << 45(2d) = 0(0)\n  signed 8 0(0) << 46(2e) = 0(0)\n  signed 8 0(0) << 47(2f) = 0(0)\n  signed 8 0(0) << 48(30) = 0(0)\n  signed 8 0(0) << 49(31) = 0(0)\n  signed 8 0(0) << 50(32) = 0(0)\n  signed 8 0(0) << 51(33) = 0(0)\n  signed 8 0(0) << 52(34) = 0(0)\n  signed 8 0(0) << 53(35) = 0(0)\n  signed 8 0(0) << 54(36) = 0(0)\n  signed 8 0(0) << 55(37) = 0(0)\n  signed 8 0(0) << 56(38) = 0(0)\n  signed 8 0(0) << 57(39) = 0(0)\n  signed 8 0(0) << 58(3a) = 0(0)\n  signed 8 0(0) << 59(3b) = 0(0)\n  signed 8 0(0) << 60(3c) = 0(0)\n  signed 8 0(0) << 61(3d) = 0(0)\n  signed 8 0(0) << 62(3e) = 0(0)\n  signed 8 0(0) << 63(3f) = 0(0)\n  signed 8 0(0) << 64(40) = 0(0)\n  signed 8 0(0) << 65(41) = 0(0)\n  signed 8 0(0) << 66(42) = 0(0)\n  signed 8 0(0) << 67(43) = 0(0)\n  signed 8 0(0) << 68(44) = 0(0)\n  signed 8 0(0) << 69(45) = 0(0)\n  signed 8 0(0) << 70(46) = 0(0)\n  signed 8 0(0) << 71(47) = 0(0)\n  signed 8 0(0) << 72(48) = 0(0)\n  signed 8 0(0) << 73(49) = 0(0)\n  signed 8 0(0) << 74(4a) = 0(0)\n  signed 8 0(0) << 75(4b) = 0(0)\n  signed 8 0(0) << 76(4c) = 0(0)\n  signed 8 0(0) << 77(4d) = 0(0)\n  signed 8 0(0) << 78(4e) = 0(0)\n  signed 8 0(0) << 79(4f) = 0(0)\n  signed 8 0(0) << 80(50) = 0(0)\n  signed 8 0(0) << 81(51) = 0(0)\n  signed 8 0(0) << 82(52) = 0(0)\n  signed 8 0(0) << 83(53) = 0(0)\n  signed 8 0(0) << 84(54) = 0(0)\n  signed 8 0(0) << 85(55) = 0(0)\n  signed 8 0(0) << 86(56) = 0(0)\n  signed 8 0(0) << 87(57) = 0(0)\n  signed 8 0(0) << 88(58) = 0(0)\n  signed 8 0(0) << 89(59) = 0(0)\n  signed 8 0(0) << 90(5a) = 0(0)\n  signed 8 0(0) << 91(5b) = 0(0)\n  signed 8 0(0) << 92(5c) = 0(0)\n  signed 8 0(0) << 93(5d) = 0(0)\n  signed 8 0(0) << 94(5e) = 0(0)\n  signed 8 0(0) << 95(5f) = 0(0)\n  signed 8 0(0) << 96(60) = 0(0)\n  signed 8 0(0) << 97(61) = 0(0)\n  signed 8 0(0) << 98(62) = 0(0)\n  signed 8 0(0) << 99(63) = 0(0)\n  signed 8 0(0) << 100(64) = 0(0)\n  signed 8 0(0) << 101(65) = 0(0)\n  signed 8 0(0) << 102(66) = 0(0)\n  signed 8 0(0) << 103(67) = 0(0)\n  signed 8 0(0) << 104(68) = 0(0)\n  signed 8 0(0) << 105(69) = 0(0)\n  signed 8 0(0) << 106(6a) = 0(0)\n  signed 8 0(0) << 107(6b) = 0(0)\n  signed 8 0(0) << 108(6c) = 0(0)\n  signed 8 0(0) << 109(6d) = 0(0)\n  signed 8 0(0) << 110(6e) = 0(0)\n  signed 8 0(0) << 111(6f) = 0(0)\n  signed 8 0(0) << 112(70) = 0(0)\n  signed 8 0(0) << 113(71) = 0(0)\n  signed 8 0(0) << 114(72) = 0(0)\n  signed 8 0(0) << 115(73) = 0(0)\n  signed 8 0(0) << 116(74) = 0(0)\n  signed 8 0(0) << 117(75) = 0(0)\n  signed 8 0(0) << 118(76) = 0(0)\n  signed 8 0(0) << 119(77) = 0(0)\n  signed 8 0(0) << 120(78) = 0(0)\n  signed 8 0(0) << 121(79) = 0(0)\n  signed 8 0(0) << 122(7a) = 0(0)\n  signed 8 0(0) << 123(7b) = 0(0)\n  signed 8 0(0) << 124(7c) = 0(0)\n  signed 8 0(0) << 125(7d) = 0(0)\n  signed 8 0(0) << 126(7e) = 0(0)\n  signed 8 0(0) << 127(7f) = 0(0)\n  signed 8 1(1) << -128(ffffff80) = 1(1)\n  signed 8 1(1) << -127(ffffff81) = 2(2)\n  signed 8 1(1) << -126(ffffff82) = 4(4)\n  signed 8 1(1) << -125(ffffff83) = 8(8)\n  signed 8 1(1) << -124(ffffff84) = 16(10)\n  signed 8 1(1) << -123(ffffff85) = 32(20)\n  signed 8 1(1) << -122(ffffff86) = 64(40)\n  signed 8 1(1) << -121(ffffff87) = 128(80)\n  signed 8 1(1) << -120(ffffff88) = 256(100)\n  signed 8 1(1) << -119(ffffff89) = 512(200)\n  signed 8 1(1) << -118(ffffff8a) = 1024(400)\n  signed 8 1(1) << -117(ffffff8b) = 2048(800)\n  signed 8 1(1) << -116(ffffff8c) = 4096(1000)\n  signed 8 1(1) << -115(ffffff8d) = 8192(2000)\n  signed 8 1(1) << -114(ffffff8e) = 16384(4000)\n  signed 8 1(1) << -113(ffffff8f) = 32768(8000)\n  signed 8 1(1) << -112(ffffff90) = 65536(10000)\n  signed 8 1(1) << -111(ffffff91) = 131072(20000)\n  signed 8 1(1) << -110(ffffff92) = 262144(40000)\n  signed 8 1(1) << -109(ffffff93) = 524288(80000)\n  signed 8 1(1) << -108(ffffff94) = 1048576(100000)\n  signed 8 1(1) << -107(ffffff95) = 2097152(200000)\n  signed 8 1(1) << -106(ffffff96) = 4194304(400000)\n  signed 8 1(1) << -105(ffffff97) = 8388608(800000)\n  signed 8 1(1) << -104(ffffff98) = 16777216(1000000)\n  signed 8 1(1) << -103(ffffff99) = 33554432(2000000)\n  signed 8 1(1) << -102(ffffff9a) = 67108864(4000000)\n  signed 8 1(1) << -101(ffffff9b) = 134217728(8000000)\n  signed 8 1(1) << -100(ffffff9c) = 268435456(10000000)\n  signed 8 1(1) << -99(ffffff9d) = 536870912(20000000)\n  signed 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\n  signed 8 1(1) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 1(1) << -96(ffffffa0) = 1(1)\n  signed 8 1(1) << -95(ffffffa1) = 2(2)\n  signed 8 1(1) << -94(ffffffa2) = 4(4)\n  signed 8 1(1) << -93(ffffffa3) = 8(8)\n  signed 8 1(1) << -92(ffffffa4) = 16(10)\n  signed 8 1(1) << -91(ffffffa5) = 32(20)\n  signed 8 1(1) << -90(ffffffa6) = 64(40)\n  signed 8 1(1) << -89(ffffffa7) = 128(80)\n  signed 8 1(1) << -88(ffffffa8) = 256(100)\n  signed 8 1(1) << -87(ffffffa9) = 512(200)\n  signed 8 1(1) << -86(ffffffaa) = 1024(400)\n  signed 8 1(1) << -85(ffffffab) = 2048(800)\n  signed 8 1(1) << -84(ffffffac) = 4096(1000)\n  signed 8 1(1) << -83(ffffffad) = 8192(2000)\n  signed 8 1(1) << -82(ffffffae) = 16384(4000)\n  signed 8 1(1) << -81(ffffffaf) = 32768(8000)\n  signed 8 1(1) << -80(ffffffb0) = 65536(10000)\n  signed 8 1(1) << -79(ffffffb1) = 131072(20000)\n  signed 8 1(1) << -78(ffffffb2) = 262144(40000)\n  signed 8 1(1) << -77(ffffffb3) = 524288(80000)\n  signed 8 1(1) << -76(ffffffb4) = 1048576(100000)\n  signed 8 1(1) << -75(ffffffb5) = 2097152(200000)\n  signed 8 1(1) << -74(ffffffb6) = 4194304(400000)\n  signed 8 1(1) << -73(ffffffb7) = 8388608(800000)\n  signed 8 1(1) << -72(ffffffb8) = 16777216(1000000)\n  signed 8 1(1) << -71(ffffffb9) = 33554432(2000000)\n  signed 8 1(1) << -70(ffffffba) = 67108864(4000000)\n  signed 8 1(1) << -69(ffffffbb) = 134217728(8000000)\n  signed 8 1(1) << -68(ffffffbc) = 268435456(10000000)\n  signed 8 1(1) << -67(ffffffbd) = 536870912(20000000)\n  signed 8 1(1) << -66(ffffffbe) = 1073741824(40000000)\n  signed 8 1(1) << -65(ffffffbf) = -2147483648(80000000)\n  signed 8 1(1) << -64(ffffffc0) = 1(1)\n  signed 8 1(1) << -63(ffffffc1) = 2(2)\n  signed 8 1(1) << -62(ffffffc2) = 4(4)\n  signed 8 1(1) << -61(ffffffc3) = 8(8)\n  signed 8 1(1) << -60(ffffffc4) = 16(10)\n  signed 8 1(1) << -59(ffffffc5) = 32(20)\n  signed 8 1(1) << -58(ffffffc6) = 64(40)\n  signed 8 1(1) << -57(ffffffc7) = 128(80)\n  signed 8 1(1) << -56(ffffffc8) = 256(100)\n  signed 8 1(1) << -55(ffffffc9) = 512(200)\n  signed 8 1(1) << -54(ffffffca) = 1024(400)\n  signed 8 1(1) << -53(ffffffcb) = 2048(800)\n  signed 8 1(1) << -52(ffffffcc) = 4096(1000)\n  signed 8 1(1) << -51(ffffffcd) = 8192(2000)\n  signed 8 1(1) << -50(ffffffce) = 16384(4000)\n  signed 8 1(1) << -49(ffffffcf) = 32768(8000)\n  signed 8 1(1) << -48(ffffffd0) = 65536(10000)\n  signed 8 1(1) << -47(ffffffd1) = 131072(20000)\n  signed 8 1(1) << -46(ffffffd2) = 262144(40000)\n  signed 8 1(1) << -45(ffffffd3) = 524288(80000)\n  signed 8 1(1) << -44(ffffffd4) = 1048576(100000)\n  signed 8 1(1) << -43(ffffffd5) = 2097152(200000)\n  signed 8 1(1) << -42(ffffffd6) = 4194304(400000)\n  signed 8 1(1) << -41(ffffffd7) = 8388608(800000)\n  signed 8 1(1) << -40(ffffffd8) = 16777216(1000000)\n  signed 8 1(1) << -39(ffffffd9) = 33554432(2000000)\n  signed 8 1(1) << -38(ffffffda) = 67108864(4000000)\n  signed 8 1(1) << -37(ffffffdb) = 134217728(8000000)\n  signed 8 1(1) << -36(ffffffdc) = 268435456(10000000)\n  signed 8 1(1) << -35(ffffffdd) = 536870912(20000000)\n  signed 8 1(1) << -34(ffffffde) = 1073741824(40000000)\n  signed 8 1(1) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 1(1) << -32(ffffffe0) = 1(1)\n  signed 8 1(1) << -31(ffffffe1) = 2(2)\n  signed 8 1(1) << -30(ffffffe2) = 4(4)\n  signed 8 1(1) << -29(ffffffe3) = 8(8)\n  signed 8 1(1) << -28(ffffffe4) = 16(10)\n  signed 8 1(1) << -27(ffffffe5) = 32(20)\n  signed 8 1(1) << -26(ffffffe6) = 64(40)\n  signed 8 1(1) << -25(ffffffe7) = 128(80)\n  signed 8 1(1) << -24(ffffffe8) = 256(100)\n  signed 8 1(1) << -23(ffffffe9) = 512(200)\n  signed 8 1(1) << -22(ffffffea) = 1024(400)\n  signed 8 1(1) << -21(ffffffeb) = 2048(800)\n  signed 8 1(1) << -20(ffffffec) = 4096(1000)\n  signed 8 1(1) << -19(ffffffed) = 8192(2000)\n  signed 8 1(1) << -18(ffffffee) = 16384(4000)\n  signed 8 1(1) << -17(ffffffef) = 32768(8000)\n  signed 8 1(1) << -16(fffffff0) = 65536(10000)\n  signed 8 1(1) << -15(fffffff1) = 131072(20000)\n  signed 8 1(1) << -14(fffffff2) = 262144(40000)\n  signed 8 1(1) << -13(fffffff3) = 524288(80000)\n  signed 8 1(1) << -12(fffffff4) = 1048576(100000)\n  signed 8 1(1) << -11(fffffff5) = 2097152(200000)\n  signed 8 1(1) << -10(fffffff6) = 4194304(400000)\n  signed 8 1(1) << -9(fffffff7) = 8388608(800000)\n  signed 8 1(1) << -8(fffffff8) = 16777216(1000000)\n  signed 8 1(1) << -7(fffffff9) = 33554432(2000000)\n  signed 8 1(1) << -6(fffffffa) = 67108864(4000000)\n  signed 8 1(1) << -5(fffffffb) = 134217728(8000000)\n  signed 8 1(1) << -4(fffffffc) = 268435456(10000000)\n  signed 8 1(1) << -3(fffffffd) = 536870912(20000000)\n  signed 8 1(1) << -2(fffffffe) = 1073741824(40000000)\n  signed 8 1(1) << -1(ffffffff) = -2147483648(80000000)\n  signed 8 1(1) << 0(0) = 1(1)\n  signed 8 1(1) << 1(1) = 2(2)\n  signed 8 1(1) << 2(2) = 4(4)\n  signed 8 1(1) << 3(3) = 8(8)\n  signed 8 1(1) << 4(4) = 16(10)\n  signed 8 1(1) << 5(5) = 32(20)\n  signed 8 1(1) << 6(6) = 64(40)\n  signed 8 1(1) << 7(7) = 128(80)\n  signed 8 1(1) << 8(8) = 256(100)\n  signed 8 1(1) << 9(9) = 512(200)\n  signed 8 1(1) << 10(a) = 1024(400)\n  signed 8 1(1) << 11(b) = 2048(800)\n  signed 8 1(1) << 12(c) = 4096(1000)\n  signed 8 1(1) << 13(d) = 8192(2000)\n  signed 8 1(1) << 14(e) = 16384(4000)\n  signed 8 1(1) << 15(f) = 32768(8000)\n  signed 8 1(1) << 16(10) = 65536(10000)\n  signed 8 1(1) << 17(11) = 131072(20000)\n  signed 8 1(1) << 18(12) = 262144(40000)\n  signed 8 1(1) << 19(13) = 524288(80000)\n  signed 8 1(1) << 20(14) = 1048576(100000)\n  signed 8 1(1) << 21(15) = 2097152(200000)\n  signed 8 1(1) << 22(16) = 4194304(400000)\n  signed 8 1(1) << 23(17) = 8388608(800000)\n  signed 8 1(1) << 24(18) = 16777216(1000000)\n  signed 8 1(1) << 25(19) = 33554432(2000000)\n  signed 8 1(1) << 26(1a) = 67108864(4000000)\n  signed 8 1(1) << 27(1b) = 134217728(8000000)\n  signed 8 1(1) << 28(1c) = 268435456(10000000)\n  signed 8 1(1) << 29(1d) = 536870912(20000000)\n  signed 8 1(1) << 30(1e) = 1073741824(40000000)\n  signed 8 1(1) << 31(1f) = -2147483648(80000000)\n  signed 8 1(1) << 32(20) = 1(1)\n  signed 8 1(1) << 33(21) = 2(2)\n  signed 8 1(1) << 34(22) = 4(4)\n  signed 8 1(1) << 35(23) = 8(8)\n  signed 8 1(1) << 36(24) = 16(10)\n  signed 8 1(1) << 37(25) = 32(20)\n  signed 8 1(1) << 38(26) = 64(40)\n  signed 8 1(1) << 39(27) = 128(80)\n  signed 8 1(1) << 40(28) = 256(100)\n  signed 8 1(1) << 41(29) = 512(200)\n  signed 8 1(1) << 42(2a) = 1024(400)\n  signed 8 1(1) << 43(2b) = 2048(800)\n  signed 8 1(1) << 44(2c) = 4096(1000)\n  signed 8 1(1) << 45(2d) = 8192(2000)\n  signed 8 1(1) << 46(2e) = 16384(4000)\n  signed 8 1(1) << 47(2f) = 32768(8000)\n  signed 8 1(1) << 48(30) = 65536(10000)\n  signed 8 1(1) << 49(31) = 131072(20000)\n  signed 8 1(1) << 50(32) = 262144(40000)\n  signed 8 1(1) << 51(33) = 524288(80000)\n  signed 8 1(1) << 52(34) = 1048576(100000)\n  signed 8 1(1) << 53(35) = 2097152(200000)\n  signed 8 1(1) << 54(36) = 4194304(400000)\n  signed 8 1(1) << 55(37) = 8388608(800000)\n  signed 8 1(1) << 56(38) = 16777216(1000000)\n  signed 8 1(1) << 57(39) = 33554432(2000000)\n  signed 8 1(1) << 58(3a) = 67108864(4000000)\n  signed 8 1(1) << 59(3b) = 134217728(8000000)\n  signed 8 1(1) << 60(3c) = 268435456(10000000)\n  signed 8 1(1) << 61(3d) = 536870912(20000000)\n  signed 8 1(1) << 62(3e) = 1073741824(40000000)\n  signed 8 1(1) << 63(3f) = -2147483648(80000000)\n  signed 8 1(1) << 64(40) = 1(1)\n  signed 8 1(1) << 65(41) = 2(2)\n  signed 8 1(1) << 66(42) = 4(4)\n  signed 8 1(1) << 67(43) = 8(8)\n  signed 8 1(1) << 68(44) = 16(10)\n  signed 8 1(1) << 69(45) = 32(20)\n  signed 8 1(1) << 70(46) = 64(40)\n  signed 8 1(1) << 71(47) = 128(80)\n  signed 8 1(1) << 72(48) = 256(100)\n  signed 8 1(1) << 73(49) = 512(200)\n  signed 8 1(1) << 74(4a) = 1024(400)\n  signed 8 1(1) << 75(4b) = 2048(800)\n  signed 8 1(1) << 76(4c) = 4096(1000)\n  signed 8 1(1) << 77(4d) = 8192(2000)\n  signed 8 1(1) << 78(4e) = 16384(4000)\n  signed 8 1(1) << 79(4f) = 32768(8000)\n  signed 8 1(1) << 80(50) = 65536(10000)\n  signed 8 1(1) << 81(51) = 131072(20000)\n  signed 8 1(1) << 82(52) = 262144(40000)\n  signed 8 1(1) << 83(53) = 524288(80000)\n  signed 8 1(1) << 84(54) = 1048576(100000)\n  signed 8 1(1) << 85(55) = 2097152(200000)\n  signed 8 1(1) << 86(56) = 4194304(400000)\n  signed 8 1(1) << 87(57) = 8388608(800000)\n  signed 8 1(1) << 88(58) = 16777216(1000000)\n  signed 8 1(1) << 89(59) = 33554432(2000000)\n  signed 8 1(1) << 90(5a) = 67108864(4000000)\n  signed 8 1(1) << 91(5b) = 134217728(8000000)\n  signed 8 1(1) << 92(5c) = 268435456(10000000)\n  signed 8 1(1) << 93(5d) = 536870912(20000000)\n  signed 8 1(1) << 94(5e) = 1073741824(40000000)\n  signed 8 1(1) << 95(5f) = -2147483648(80000000)\n  signed 8 1(1) << 96(60) = 1(1)\n  signed 8 1(1) << 97(61) = 2(2)\n  signed 8 1(1) << 98(62) = 4(4)\n  signed 8 1(1) << 99(63) = 8(8)\n  signed 8 1(1) << 100(64) = 16(10)\n  signed 8 1(1) << 101(65) = 32(20)\n  signed 8 1(1) << 102(66) = 64(40)\n  signed 8 1(1) << 103(67) = 128(80)\n  signed 8 1(1) << 104(68) = 256(100)\n  signed 8 1(1) << 105(69) = 512(200)\n  signed 8 1(1) << 106(6a) = 1024(400)\n  signed 8 1(1) << 107(6b) = 2048(800)\n  signed 8 1(1) << 108(6c) = 4096(1000)\n  signed 8 1(1) << 109(6d) = 8192(2000)\n  signed 8 1(1) << 110(6e) = 16384(4000)\n  signed 8 1(1) << 111(6f) = 32768(8000)\n  signed 8 1(1) << 112(70) = 65536(10000)\n  signed 8 1(1) << 113(71) = 131072(20000)\n  signed 8 1(1) << 114(72) = 262144(40000)\n  signed 8 1(1) << 115(73) = 524288(80000)\n  signed 8 1(1) << 116(74) = 1048576(100000)\n  signed 8 1(1) << 117(75) = 2097152(200000)\n  signed 8 1(1) << 118(76) = 4194304(400000)\n  signed 8 1(1) << 119(77) = 8388608(800000)\n  signed 8 1(1) << 120(78) = 16777216(1000000)\n  signed 8 1(1) << 121(79) = 33554432(2000000)\n  signed 8 1(1) << 122(7a) = 67108864(4000000)\n  signed 8 1(1) << 123(7b) = 134217728(8000000)\n  signed 8 1(1) << 124(7c) = 268435456(10000000)\n  signed 8 1(1) << 125(7d) = 536870912(20000000)\n  signed 8 1(1) << 126(7e) = 1073741824(40000000)\n  signed 8 1(1) << 127(7f) = -2147483648(80000000)\n  signed 8 2(2) << -128(ffffff80) = 2(2)\n  signed 8 2(2) << -127(ffffff81) = 4(4)\n  signed 8 2(2) << -126(ffffff82) = 8(8)\n  signed 8 2(2) << -125(ffffff83) = 16(10)\n  signed 8 2(2) << -124(ffffff84) = 32(20)\n  signed 8 2(2) << -123(ffffff85) = 64(40)\n  signed 8 2(2) << -122(ffffff86) = 128(80)\n  signed 8 2(2) << -121(ffffff87) = 256(100)\n  signed 8 2(2) << -120(ffffff88) = 512(200)\n  signed 8 2(2) << -119(ffffff89) = 1024(400)\n  signed 8 2(2) << -118(ffffff8a) = 2048(800)\n  signed 8 2(2) << -117(ffffff8b) = 4096(1000)\n  signed 8 2(2) << -116(ffffff8c) = 8192(2000)\n  signed 8 2(2) << -115(ffffff8d) = 16384(4000)\n  signed 8 2(2) << -114(ffffff8e) = 32768(8000)\n  signed 8 2(2) << -113(ffffff8f) = 65536(10000)\n  signed 8 2(2) << -112(ffffff90) = 131072(20000)\n  signed 8 2(2) << -111(ffffff91) = 262144(40000)\n  signed 8 2(2) << -110(ffffff92) = 524288(80000)\n  signed 8 2(2) << -109(ffffff93) = 1048576(100000)\n  signed 8 2(2) << -108(ffffff94) = 2097152(200000)\n  signed 8 2(2) << -107(ffffff95) = 4194304(400000)\n  signed 8 2(2) << -106(ffffff96) = 8388608(800000)\n  signed 8 2(2) << -105(ffffff97) = 16777216(1000000)\n  signed 8 2(2) << -104(ffffff98) = 33554432(2000000)\n  signed 8 2(2) << -103(ffffff99) = 67108864(4000000)\n  signed 8 2(2) << -102(ffffff9a) = 134217728(8000000)\n  signed 8 2(2) << -101(ffffff9b) = 268435456(10000000)\n  signed 8 2(2) << -100(ffffff9c) = 536870912(20000000)\n  signed 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\n  signed 8 2(2) << -98(ffffff9e) = -2147483648(80000000)\n  signed 8 2(2) << -97(ffffff9f) = 0(0)\n  signed 8 2(2) << -96(ffffffa0) = 2(2)\n  signed 8 2(2) << -95(ffffffa1) = 4(4)\n  signed 8 2(2) << -94(ffffffa2) = 8(8)\n  signed 8 2(2) << -93(ffffffa3) = 16(10)\n  signed 8 2(2) << -92(ffffffa4) = 32(20)\n  signed 8 2(2) << -91(ffffffa5) = 64(40)\n  signed 8 2(2) << -90(ffffffa6) = 128(80)\n  signed 8 2(2) << -89(ffffffa7) = 256(100)\n  signed 8 2(2) << -88(ffffffa8) = 512(200)\n  signed 8 2(2) << -87(ffffffa9) = 1024(400)\n  signed 8 2(2) << -86(ffffffaa) = 2048(800)\n  signed 8 2(2) << -85(ffffffab) = 4096(1000)\n  signed 8 2(2) << -84(ffffffac) = 8192(2000)\n  signed 8 2(2) << -83(ffffffad) = 16384(4000)\n  signed 8 2(2) << -82(ffffffae) = 32768(8000)\n  signed 8 2(2) << -81(ffffffaf) = 65536(10000)\n  signed 8 2(2) << -80(ffffffb0) = 131072(20000)\n  signed 8 2(2) << -79(ffffffb1) = 262144(40000)\n  signed 8 2(2) << -78(ffffffb2) = 524288(80000)\n  signed 8 2(2) << -77(ffffffb3) = 1048576(100000)\n  signed 8 2(2) << -76(ffffffb4) = 2097152(200000)\n  signed 8 2(2) << -75(ffffffb5) = 4194304(400000)\n  signed 8 2(2) << -74(ffffffb6) = 8388608(800000)\n  signed 8 2(2) << -73(ffffffb7) = 16777216(1000000)\n  signed 8 2(2) << -72(ffffffb8) = 33554432(2000000)\n  signed 8 2(2) << -71(ffffffb9) = 67108864(4000000)\n  signed 8 2(2) << -70(ffffffba) = 134217728(8000000)\n  signed 8 2(2) << -69(ffffffbb) = 268435456(10000000)\n  signed 8 2(2) << -68(ffffffbc) = 536870912(20000000)\n  signed 8 2(2) << -67(ffffffbd) = 1073741824(40000000)\n  signed 8 2(2) << -66(ffffffbe) = -2147483648(80000000)\n  signed 8 2(2) << -65(ffffffbf) = 0(0)\n  signed 8 2(2) << -64(ffffffc0) = 2(2)\n  signed 8 2(2) << -63(ffffffc1) = 4(4)\n  signed 8 2(2) << -62(ffffffc2) = 8(8)\n  signed 8 2(2) << -61(ffffffc3) = 16(10)\n  signed 8 2(2) << -60(ffffffc4) = 32(20)\n  signed 8 2(2) << -59(ffffffc5) = 64(40)\n  signed 8 2(2) << -58(ffffffc6) = 128(80)\n  signed 8 2(2) << -57(ffffffc7) = 256(100)\n  signed 8 2(2) << -56(ffffffc8) = 512(200)\n  signed 8 2(2) << -55(ffffffc9) = 1024(400)\n  signed 8 2(2) << -54(ffffffca) = 2048(800)\n  signed 8 2(2) << -53(ffffffcb) = 4096(1000)\n  signed 8 2(2) << -52(ffffffcc) = 8192(2000)\n  signed 8 2(2) << -51(ffffffcd) = 16384(4000)\n  signed 8 2(2) << -50(ffffffce) = 32768(8000)\n  signed 8 2(2) << -49(ffffffcf) = 65536(10000)\n  signed 8 2(2) << -48(ffffffd0) = 131072(20000)\n  signed 8 2(2) << -47(ffffffd1) = 262144(40000)\n  signed 8 2(2) << -46(ffffffd2) = 524288(80000)\n  signed 8 2(2) << -45(ffffffd3) = 1048576(100000)\n  signed 8 2(2) << -44(ffffffd4) = 2097152(200000)\n  signed 8 2(2) << -43(ffffffd5) = 4194304(400000)\n  signed 8 2(2) << -42(ffffffd6) = 8388608(800000)\n  signed 8 2(2) << -41(ffffffd7) = 16777216(1000000)\n  signed 8 2(2) << -40(ffffffd8) = 33554432(2000000)\n  signed 8 2(2) << -39(ffffffd9) = 67108864(4000000)\n  signed 8 2(2) << -38(ffffffda) = 134217728(8000000)\n  signed 8 2(2) << -37(ffffffdb) = 268435456(10000000)\n  signed 8 2(2) << -36(ffffffdc) = 536870912(20000000)\n  signed 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\n  signed 8 2(2) << -34(ffffffde) = -2147483648(80000000)\n  signed 8 2(2) << -33(ffffffdf) = 0(0)\n  signed 8 2(2) << -32(ffffffe0) = 2(2)\n  signed 8 2(2) << -31(ffffffe1) = 4(4)\n  signed 8 2(2) << -30(ffffffe2) = 8(8)\n  signed 8 2(2) << -29(ffffffe3) = 16(10)\n  signed 8 2(2) << -28(ffffffe4) = 32(20)\n  signed 8 2(2) << -27(ffffffe5) = 64(40)\n  signed 8 2(2) << -26(ffffffe6) = 128(80)\n  signed 8 2(2) << -25(ffffffe7) = 256(100)\n  signed 8 2(2) << -24(ffffffe8) = 512(200)\n  signed 8 2(2) << -23(ffffffe9) = 1024(400)\n  signed 8 2(2) << -22(ffffffea) = 2048(800)\n  signed 8 2(2) << -21(ffffffeb) = 4096(1000)\n  signed 8 2(2) << -20(ffffffec) = 8192(2000)\n  signed 8 2(2) << -19(ffffffed) = 16384(4000)\n  signed 8 2(2) << -18(ffffffee) = 32768(8000)\n  signed 8 2(2) << -17(ffffffef) = 65536(10000)\n  signed 8 2(2) << -16(fffffff0) = 131072(20000)\n  signed 8 2(2) << -15(fffffff1) = 262144(40000)\n  signed 8 2(2) << -14(fffffff2) = 524288(80000)\n  signed 8 2(2) << -13(fffffff3) = 1048576(100000)\n  signed 8 2(2) << -12(fffffff4) = 2097152(200000)\n  signed 8 2(2) << -11(fffffff5) = 4194304(400000)\n  signed 8 2(2) << -10(fffffff6) = 8388608(800000)\n  signed 8 2(2) << -9(fffffff7) = 16777216(1000000)\n  signed 8 2(2) << -8(fffffff8) = 33554432(2000000)\n  signed 8 2(2) << -7(fffffff9) = 67108864(4000000)\n  signed 8 2(2) << -6(fffffffa) = 134217728(8000000)\n  signed 8 2(2) << -5(fffffffb) = 268435456(10000000)\n  signed 8 2(2) << -4(fffffffc) = 536870912(20000000)\n  signed 8 2(2) << -3(fffffffd) = 1073741824(40000000)\n  signed 8 2(2) << -2(fffffffe) = -2147483648(80000000)\n  signed 8 2(2) << -1(ffffffff) = 0(0)\n  signed 8 2(2) << 0(0) = 2(2)\n  signed 8 2(2) << 1(1) = 4(4)\n  signed 8 2(2) << 2(2) = 8(8)\n  signed 8 2(2) << 3(3) = 16(10)\n  signed 8 2(2) << 4(4) = 32(20)\n  signed 8 2(2) << 5(5) = 64(40)\n  signed 8 2(2) << 6(6) = 128(80)\n  signed 8 2(2) << 7(7) = 256(100)\n  signed 8 2(2) << 8(8) = 512(200)\n  signed 8 2(2) << 9(9) = 1024(400)\n  signed 8 2(2) << 10(a) = 2048(800)\n  signed 8 2(2) << 11(b) = 4096(1000)\n  signed 8 2(2) << 12(c) = 8192(2000)\n  signed 8 2(2) << 13(d) = 16384(4000)\n  signed 8 2(2) << 14(e) = 32768(8000)\n  signed 8 2(2) << 15(f) = 65536(10000)\n  signed 8 2(2) << 16(10) = 131072(20000)\n  signed 8 2(2) << 17(11) = 262144(40000)\n  signed 8 2(2) << 18(12) = 524288(80000)\n  signed 8 2(2) << 19(13) = 1048576(100000)\n  signed 8 2(2) << 20(14) = 2097152(200000)\n  signed 8 2(2) << 21(15) = 4194304(400000)\n  signed 8 2(2) << 22(16) = 8388608(800000)\n  signed 8 2(2) << 23(17) = 16777216(1000000)\n  signed 8 2(2) << 24(18) = 33554432(2000000)\n  signed 8 2(2) << 25(19) = 67108864(4000000)\n  signed 8 2(2) << 26(1a) = 134217728(8000000)\n  signed 8 2(2) << 27(1b) = 268435456(10000000)\n  signed 8 2(2) << 28(1c) = 536870912(20000000)\n  signed 8 2(2) << 29(1d) = 1073741824(40000000)\n  signed 8 2(2) << 30(1e) = -2147483648(80000000)\n  signed 8 2(2) << 31(1f) = 0(0)\n  signed 8 2(2) << 32(20) = 2(2)\n  signed 8 2(2) << 33(21) = 4(4)\n  signed 8 2(2) << 34(22) = 8(8)\n  signed 8 2(2) << 35(23) = 16(10)\n  signed 8 2(2) << 36(24) = 32(20)\n  signed 8 2(2) << 37(25) = 64(40)\n  signed 8 2(2) << 38(26) = 128(80)\n  signed 8 2(2) << 39(27) = 256(100)\n  signed 8 2(2) << 40(28) = 512(200)\n  signed 8 2(2) << 41(29) = 1024(400)\n  signed 8 2(2) << 42(2a) = 2048(800)\n  signed 8 2(2) << 43(2b) = 4096(1000)\n  signed 8 2(2) << 44(2c) = 8192(2000)\n  signed 8 2(2) << 45(2d) = 16384(4000)\n  signed 8 2(2) << 46(2e) = 32768(8000)\n  signed 8 2(2) << 47(2f) = 65536(10000)\n  signed 8 2(2) << 48(30) = 131072(20000)\n  signed 8 2(2) << 49(31) = 262144(40000)\n  signed 8 2(2) << 50(32) = 524288(80000)\n  signed 8 2(2) << 51(33) = 1048576(100000)\n  signed 8 2(2) << 52(34) = 2097152(200000)\n  signed 8 2(2) << 53(35) = 4194304(400000)\n  signed 8 2(2) << 54(36) = 8388608(800000)\n  signed 8 2(2) << 55(37) = 16777216(1000000)\n  signed 8 2(2) << 56(38) = 33554432(2000000)\n  signed 8 2(2) << 57(39) = 67108864(4000000)\n  signed 8 2(2) << 58(3a) = 134217728(8000000)\n  signed 8 2(2) << 59(3b) = 268435456(10000000)\n  signed 8 2(2) << 60(3c) = 536870912(20000000)\n  signed 8 2(2) << 61(3d) = 1073741824(40000000)\n  signed 8 2(2) << 62(3e) = -2147483648(80000000)\n  signed 8 2(2) << 63(3f) = 0(0)\n  signed 8 2(2) << 64(40) = 2(2)\n  signed 8 2(2) << 65(41) = 4(4)\n  signed 8 2(2) << 66(42) = 8(8)\n  signed 8 2(2) << 67(43) = 16(10)\n  signed 8 2(2) << 68(44) = 32(20)\n  signed 8 2(2) << 69(45) = 64(40)\n  signed 8 2(2) << 70(46) = 128(80)\n  signed 8 2(2) << 71(47) = 256(100)\n  signed 8 2(2) << 72(48) = 512(200)\n  signed 8 2(2) << 73(49) = 1024(400)\n  signed 8 2(2) << 74(4a) = 2048(800)\n  signed 8 2(2) << 75(4b) = 4096(1000)\n  signed 8 2(2) << 76(4c) = 8192(2000)\n  signed 8 2(2) << 77(4d) = 16384(4000)\n  signed 8 2(2) << 78(4e) = 32768(8000)\n  signed 8 2(2) << 79(4f) = 65536(10000)\n  signed 8 2(2) << 80(50) = 131072(20000)\n  signed 8 2(2) << 81(51) = 262144(40000)\n  signed 8 2(2) << 82(52) = 524288(80000)\n  signed 8 2(2) << 83(53) = 1048576(100000)\n  signed 8 2(2) << 84(54) = 2097152(200000)\n  signed 8 2(2) << 85(55) = 4194304(400000)\n  signed 8 2(2) << 86(56) = 8388608(800000)\n  signed 8 2(2) << 87(57) = 16777216(1000000)\n  signed 8 2(2) << 88(58) = 33554432(2000000)\n  signed 8 2(2) << 89(59) = 67108864(4000000)\n  signed 8 2(2) << 90(5a) = 134217728(8000000)\n  signed 8 2(2) << 91(5b) = 268435456(10000000)\n  signed 8 2(2) << 92(5c) = 536870912(20000000)\n  signed 8 2(2) << 93(5d) = 1073741824(40000000)\n  signed 8 2(2) << 94(5e) = -2147483648(80000000)\n  signed 8 2(2) << 95(5f) = 0(0)\n  signed 8 2(2) << 96(60) = 2(2)\n  signed 8 2(2) << 97(61) = 4(4)\n  signed 8 2(2) << 98(62) = 8(8)\n  signed 8 2(2) << 99(63) = 16(10)\n  signed 8 2(2) << 100(64) = 32(20)\n  signed 8 2(2) << 101(65) = 64(40)\n  signed 8 2(2) << 102(66) = 128(80)\n  signed 8 2(2) << 103(67) = 256(100)\n  signed 8 2(2) << 104(68) = 512(200)\n  signed 8 2(2) << 105(69) = 1024(400)\n  signed 8 2(2) << 106(6a) = 2048(800)\n  signed 8 2(2) << 107(6b) = 4096(1000)\n  signed 8 2(2) << 108(6c) = 8192(2000)\n  signed 8 2(2) << 109(6d) = 16384(4000)\n  signed 8 2(2) << 110(6e) = 32768(8000)\n  signed 8 2(2) << 111(6f) = 65536(10000)\n  signed 8 2(2) << 112(70) = 131072(20000)\n  signed 8 2(2) << 113(71) = 262144(40000)\n  signed 8 2(2) << 114(72) = 524288(80000)\n  signed 8 2(2) << 115(73) = 1048576(100000)\n  signed 8 2(2) << 116(74) = 2097152(200000)\n  signed 8 2(2) << 117(75) = 4194304(400000)\n  signed 8 2(2) << 118(76) = 8388608(800000)\n  signed 8 2(2) << 119(77) = 16777216(1000000)\n  signed 8 2(2) << 120(78) = 33554432(2000000)\n  signed 8 2(2) << 121(79) = 67108864(4000000)\n  signed 8 2(2) << 122(7a) = 134217728(8000000)\n  signed 8 2(2) << 123(7b) = 268435456(10000000)\n  signed 8 2(2) << 124(7c) = 536870912(20000000)\n  signed 8 2(2) << 125(7d) = 1073741824(40000000)\n  signed 8 2(2) << 126(7e) = -2147483648(80000000)\n  signed 8 2(2) << 127(7f) = 0(0)\n  signed 8 3(3) << -128(ffffff80) = 3(3)\n  signed 8 3(3) << -127(ffffff81) = 6(6)\n  signed 8 3(3) << -126(ffffff82) = 12(c)\n  signed 8 3(3) << -125(ffffff83) = 24(18)\n  signed 8 3(3) << -124(ffffff84) = 48(30)\n  signed 8 3(3) << -123(ffffff85) = 96(60)\n  signed 8 3(3) << -122(ffffff86) = 192(c0)\n  signed 8 3(3) << -121(ffffff87) = 384(180)\n  signed 8 3(3) << -120(ffffff88) = 768(300)\n  signed 8 3(3) << -119(ffffff89) = 1536(600)\n  signed 8 3(3) << -118(ffffff8a) = 3072(c00)\n  signed 8 3(3) << -117(ffffff8b) = 6144(1800)\n  signed 8 3(3) << -116(ffffff8c) = 12288(3000)\n  signed 8 3(3) << -115(ffffff8d) = 24576(6000)\n  signed 8 3(3) << -114(ffffff8e) = 49152(c000)\n  signed 8 3(3) << -113(ffffff8f) = 98304(18000)\n  signed 8 3(3) << -112(ffffff90) = 196608(30000)\n  signed 8 3(3) << -111(ffffff91) = 393216(60000)\n  signed 8 3(3) << -110(ffffff92) = 786432(c0000)\n  signed 8 3(3) << -109(ffffff93) = 1572864(180000)\n  signed 8 3(3) << -108(ffffff94) = 3145728(300000)\n  signed 8 3(3) << -107(ffffff95) = 6291456(600000)\n  signed 8 3(3) << -106(ffffff96) = 12582912(c00000)\n  signed 8 3(3) << -105(ffffff97) = 25165824(1800000)\n  signed 8 3(3) << -104(ffffff98) = 50331648(3000000)\n  signed 8 3(3) << -103(ffffff99) = 100663296(6000000)\n  signed 8 3(3) << -102(ffffff9a) = 201326592(c000000)\n  signed 8 3(3) << -101(ffffff9b) = 402653184(18000000)\n  signed 8 3(3) << -100(ffffff9c) = 805306368(30000000)\n  signed 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\n  signed 8 3(3) << -98(ffffff9e) = -1073741824(c0000000)\n  signed 8 3(3) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 3(3) << -96(ffffffa0) = 3(3)\n  signed 8 3(3) << -95(ffffffa1) = 6(6)\n  signed 8 3(3) << -94(ffffffa2) = 12(c)\n  signed 8 3(3) << -93(ffffffa3) = 24(18)\n  signed 8 3(3) << -92(ffffffa4) = 48(30)\n  signed 8 3(3) << -91(ffffffa5) = 96(60)\n  signed 8 3(3) << -90(ffffffa6) = 192(c0)\n  signed 8 3(3) << -89(ffffffa7) = 384(180)\n  signed 8 3(3) << -88(ffffffa8) = 768(300)\n  signed 8 3(3) << -87(ffffffa9) = 1536(600)\n  signed 8 3(3) << -86(ffffffaa) = 3072(c00)\n  signed 8 3(3) << -85(ffffffab) = 6144(1800)\n  signed 8 3(3) << -84(ffffffac) = 12288(3000)\n  signed 8 3(3) << -83(ffffffad) = 24576(6000)\n  signed 8 3(3) << -82(ffffffae) = 49152(c000)\n  signed 8 3(3) << -81(ffffffaf) = 98304(18000)\n  signed 8 3(3) << -80(ffffffb0) = 196608(30000)\n  signed 8 3(3) << -79(ffffffb1) = 393216(60000)\n  signed 8 3(3) << -78(ffffffb2) = 786432(c0000)\n  signed 8 3(3) << -77(ffffffb3) = 1572864(180000)\n  signed 8 3(3) << -76(ffffffb4) = 3145728(300000)\n  signed 8 3(3) << -75(ffffffb5) = 6291456(600000)\n  signed 8 3(3) << -74(ffffffb6) = 12582912(c00000)\n  signed 8 3(3) << -73(ffffffb7) = 25165824(1800000)\n  signed 8 3(3) << -72(ffffffb8) = 50331648(3000000)\n  signed 8 3(3) << -71(ffffffb9) = 100663296(6000000)\n  signed 8 3(3) << -70(ffffffba) = 201326592(c000000)\n  signed 8 3(3) << -69(ffffffbb) = 402653184(18000000)\n  signed 8 3(3) << -68(ffffffbc) = 805306368(30000000)\n  signed 8 3(3) << -67(ffffffbd) = 1610612736(60000000)\n  signed 8 3(3) << -66(ffffffbe) = -1073741824(c0000000)\n  signed 8 3(3) << -65(ffffffbf) = -2147483648(80000000)\n  signed 8 3(3) << -64(ffffffc0) = 3(3)\n  signed 8 3(3) << -63(ffffffc1) = 6(6)\n  signed 8 3(3) << -62(ffffffc2) = 12(c)\n  signed 8 3(3) << -61(ffffffc3) = 24(18)\n  signed 8 3(3) << -60(ffffffc4) = 48(30)\n  signed 8 3(3) << -59(ffffffc5) = 96(60)\n  signed 8 3(3) << -58(ffffffc6) = 192(c0)\n  signed 8 3(3) << -57(ffffffc7) = 384(180)\n  signed 8 3(3) << -56(ffffffc8) = 768(300)\n  signed 8 3(3) << -55(ffffffc9) = 1536(600)\n  signed 8 3(3) << -54(ffffffca) = 3072(c00)\n  signed 8 3(3) << -53(ffffffcb) = 6144(1800)\n  signed 8 3(3) << -52(ffffffcc) = 12288(3000)\n  signed 8 3(3) << -51(ffffffcd) = 24576(6000)\n  signed 8 3(3) << -50(ffffffce) = 49152(c000)\n  signed 8 3(3) << -49(ffffffcf) = 98304(18000)\n  signed 8 3(3) << -48(ffffffd0) = 196608(30000)\n  signed 8 3(3) << -47(ffffffd1) = 393216(60000)\n  signed 8 3(3) << -46(ffffffd2) = 786432(c0000)\n  signed 8 3(3) << -45(ffffffd3) = 1572864(180000)\n  signed 8 3(3) << -44(ffffffd4) = 3145728(300000)\n  signed 8 3(3) << -43(ffffffd5) = 6291456(600000)\n  signed 8 3(3) << -42(ffffffd6) = 12582912(c00000)\n  signed 8 3(3) << -41(ffffffd7) = 25165824(1800000)\n  signed 8 3(3) << -40(ffffffd8) = 50331648(3000000)\n  signed 8 3(3) << -39(ffffffd9) = 100663296(6000000)\n  signed 8 3(3) << -38(ffffffda) = 201326592(c000000)\n  signed 8 3(3) << -37(ffffffdb) = 402653184(18000000)\n  signed 8 3(3) << -36(ffffffdc) = 805306368(30000000)\n  signed 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\n  signed 8 3(3) << -34(ffffffde) = -1073741824(c0000000)\n  signed 8 3(3) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 3(3) << -32(ffffffe0) = 3(3)\n  signed 8 3(3) << -31(ffffffe1) = 6(6)\n  signed 8 3(3) << -30(ffffffe2) = 12(c)\n  signed 8 3(3) << -29(ffffffe3) = 24(18)\n  signed 8 3(3) << -28(ffffffe4) = 48(30)\n  signed 8 3(3) << -27(ffffffe5) = 96(60)\n  signed 8 3(3) << -26(ffffffe6) = 192(c0)\n  signed 8 3(3) << -25(ffffffe7) = 384(180)\n  signed 8 3(3) << -24(ffffffe8) = 768(300)\n  signed 8 3(3) << -23(ffffffe9) = 1536(600)\n  signed 8 3(3) << -22(ffffffea) = 3072(c00)\n  signed 8 3(3) << -21(ffffffeb) = 6144(1800)\n  signed 8 3(3) << -20(ffffffec) = 12288(3000)\n  signed 8 3(3) << -19(ffffffed) = 24576(6000)\n  signed 8 3(3) << -18(ffffffee) = 49152(c000)\n  signed 8 3(3) << -17(ffffffef) = 98304(18000)\n  signed 8 3(3) << -16(fffffff0) = 196608(30000)\n  signed 8 3(3) << -15(fffffff1) = 393216(60000)\n  signed 8 3(3) << -14(fffffff2) = 786432(c0000)\n  signed 8 3(3) << -13(fffffff3) = 1572864(180000)\n  signed 8 3(3) << -12(fffffff4) = 3145728(300000)\n  signed 8 3(3) << -11(fffffff5) = 6291456(600000)\n  signed 8 3(3) << -10(fffffff6) = 12582912(c00000)\n  signed 8 3(3) << -9(fffffff7) = 25165824(1800000)\n  signed 8 3(3) << -8(fffffff8) = 50331648(3000000)\n  signed 8 3(3) << -7(fffffff9) = 100663296(6000000)\n  signed 8 3(3) << -6(fffffffa) = 201326592(c000000)\n  signed 8 3(3) << -5(fffffffb) = 402653184(18000000)\n  signed 8 3(3) << -4(fffffffc) = 805306368(30000000)\n  signed 8 3(3) << -3(fffffffd) = 1610612736(60000000)\n  signed 8 3(3) << -2(fffffffe) = -1073741824(c0000000)\n  signed 8 3(3) << -1(ffffffff) = -2147483648(80000000)\n  signed 8 3(3) << 0(0) = 3(3)\n  signed 8 3(3) << 1(1) = 6(6)\n  signed 8 3(3) << 2(2) = 12(c)\n  signed 8 3(3) << 3(3) = 24(18)\n  signed 8 3(3) << 4(4) = 48(30)\n  signed 8 3(3) << 5(5) = 96(60)\n  signed 8 3(3) << 6(6) = 192(c0)\n  signed 8 3(3) << 7(7) = 384(180)\n  signed 8 3(3) << 8(8) = 768(300)\n  signed 8 3(3) << 9(9) = 1536(600)\n  signed 8 3(3) << 10(a) = 3072(c00)\n  signed 8 3(3) << 11(b) = 6144(1800)\n  signed 8 3(3) << 12(c) = 12288(3000)\n  signed 8 3(3) << 13(d) = 24576(6000)\n  signed 8 3(3) << 14(e) = 49152(c000)\n  signed 8 3(3) << 15(f) = 98304(18000)\n  signed 8 3(3) << 16(10) = 196608(30000)\n  signed 8 3(3) << 17(11) = 393216(60000)\n  signed 8 3(3) << 18(12) = 786432(c0000)\n  signed 8 3(3) << 19(13) = 1572864(180000)\n  signed 8 3(3) << 20(14) = 3145728(300000)\n  signed 8 3(3) << 21(15) = 6291456(600000)\n  signed 8 3(3) << 22(16) = 12582912(c00000)\n  signed 8 3(3) << 23(17) = 25165824(1800000)\n  signed 8 3(3) << 24(18) = 50331648(3000000)\n  signed 8 3(3) << 25(19) = 100663296(6000000)\n  signed 8 3(3) << 26(1a) = 201326592(c000000)\n  signed 8 3(3) << 27(1b) = 402653184(18000000)\n  signed 8 3(3) << 28(1c) = 805306368(30000000)\n  signed 8 3(3) << 29(1d) = 1610612736(60000000)\n  signed 8 3(3) << 30(1e) = -1073741824(c0000000)\n  signed 8 3(3) << 31(1f) = -2147483648(80000000)\n  signed 8 3(3) << 32(20) = 3(3)\n  signed 8 3(3) << 33(21) = 6(6)\n  signed 8 3(3) << 34(22) = 12(c)\n  signed 8 3(3) << 35(23) = 24(18)\n  signed 8 3(3) << 36(24) = 48(30)\n  signed 8 3(3) << 37(25) = 96(60)\n  signed 8 3(3) << 38(26) = 192(c0)\n  signed 8 3(3) << 39(27) = 384(180)\n  signed 8 3(3) << 40(28) = 768(300)\n  signed 8 3(3) << 41(29) = 1536(600)\n  signed 8 3(3) << 42(2a) = 3072(c00)\n  signed 8 3(3) << 43(2b) = 6144(1800)\n  signed 8 3(3) << 44(2c) = 12288(3000)\n  signed 8 3(3) << 45(2d) = 24576(6000)\n  signed 8 3(3) << 46(2e) = 49152(c000)\n  signed 8 3(3) << 47(2f) = 98304(18000)\n  signed 8 3(3) << 48(30) = 196608(30000)\n  signed 8 3(3) << 49(31) = 393216(60000)\n  signed 8 3(3) << 50(32) = 786432(c0000)\n  signed 8 3(3) << 51(33) = 1572864(180000)\n  signed 8 3(3) << 52(34) = 3145728(300000)\n  signed 8 3(3) << 53(35) = 6291456(600000)\n  signed 8 3(3) << 54(36) = 12582912(c00000)\n  signed 8 3(3) << 55(37) = 25165824(1800000)\n  signed 8 3(3) << 56(38) = 50331648(3000000)\n  signed 8 3(3) << 57(39) = 100663296(6000000)\n  signed 8 3(3) << 58(3a) = 201326592(c000000)\n  signed 8 3(3) << 59(3b) = 402653184(18000000)\n  signed 8 3(3) << 60(3c) = 805306368(30000000)\n  signed 8 3(3) << 61(3d) = 1610612736(60000000)\n  signed 8 3(3) << 62(3e) = -1073741824(c0000000)\n  signed 8 3(3) << 63(3f) = -2147483648(80000000)\n  signed 8 3(3) << 64(40) = 3(3)\n  signed 8 3(3) << 65(41) = 6(6)\n  signed 8 3(3) << 66(42) = 12(c)\n  signed 8 3(3) << 67(43) = 24(18)\n  signed 8 3(3) << 68(44) = 48(30)\n  signed 8 3(3) << 69(45) = 96(60)\n  signed 8 3(3) << 70(46) = 192(c0)\n  signed 8 3(3) << 71(47) = 384(180)\n  signed 8 3(3) << 72(48) = 768(300)\n  signed 8 3(3) << 73(49) = 1536(600)\n  signed 8 3(3) << 74(4a) = 3072(c00)\n  signed 8 3(3) << 75(4b) = 6144(1800)\n  signed 8 3(3) << 76(4c) = 12288(3000)\n  signed 8 3(3) << 77(4d) = 24576(6000)\n  signed 8 3(3) << 78(4e) = 49152(c000)\n  signed 8 3(3) << 79(4f) = 98304(18000)\n  signed 8 3(3) << 80(50) = 196608(30000)\n  signed 8 3(3) << 81(51) = 393216(60000)\n  signed 8 3(3) << 82(52) = 786432(c0000)\n  signed 8 3(3) << 83(53) = 1572864(180000)\n  signed 8 3(3) << 84(54) = 3145728(300000)\n  signed 8 3(3) << 85(55) = 6291456(600000)\n  signed 8 3(3) << 86(56) = 12582912(c00000)\n  signed 8 3(3) << 87(57) = 25165824(1800000)\n  signed 8 3(3) << 88(58) = 50331648(3000000)\n  signed 8 3(3) << 89(59) = 100663296(6000000)\n  signed 8 3(3) << 90(5a) = 201326592(c000000)\n  signed 8 3(3) << 91(5b) = 402653184(18000000)\n  signed 8 3(3) << 92(5c) = 805306368(30000000)\n  signed 8 3(3) << 93(5d) = 1610612736(60000000)\n  signed 8 3(3) << 94(5e) = -1073741824(c0000000)\n  signed 8 3(3) << 95(5f) = -2147483648(80000000)\n  signed 8 3(3) << 96(60) = 3(3)\n  signed 8 3(3) << 97(61) = 6(6)\n  signed 8 3(3) << 98(62) = 12(c)\n  signed 8 3(3) << 99(63) = 24(18)\n  signed 8 3(3) << 100(64) = 48(30)\n  signed 8 3(3) << 101(65) = 96(60)\n  signed 8 3(3) << 102(66) = 192(c0)\n  signed 8 3(3) << 103(67) = 384(180)\n  signed 8 3(3) << 104(68) = 768(300)\n  signed 8 3(3) << 105(69) = 1536(600)\n  signed 8 3(3) << 106(6a) = 3072(c00)\n  signed 8 3(3) << 107(6b) = 6144(1800)\n  signed 8 3(3) << 108(6c) = 12288(3000)\n  signed 8 3(3) << 109(6d) = 24576(6000)\n  signed 8 3(3) << 110(6e) = 49152(c000)\n  signed 8 3(3) << 111(6f) = 98304(18000)\n  signed 8 3(3) << 112(70) = 196608(30000)\n  signed 8 3(3) << 113(71) = 393216(60000)\n  signed 8 3(3) << 114(72) = 786432(c0000)\n  signed 8 3(3) << 115(73) = 1572864(180000)\n  signed 8 3(3) << 116(74) = 3145728(300000)\n  signed 8 3(3) << 117(75) = 6291456(600000)\n  signed 8 3(3) << 118(76) = 12582912(c00000)\n  signed 8 3(3) << 119(77) = 25165824(1800000)\n  signed 8 3(3) << 120(78) = 50331648(3000000)\n  signed 8 3(3) << 121(79) = 100663296(6000000)\n  signed 8 3(3) << 122(7a) = 201326592(c000000)\n  signed 8 3(3) << 123(7b) = 402653184(18000000)\n  signed 8 3(3) << 124(7c) = 805306368(30000000)\n  signed 8 3(3) << 125(7d) = 1610612736(60000000)\n  signed 8 3(3) << 126(7e) = -1073741824(c0000000)\n  signed 8 3(3) << 127(7f) = -2147483648(80000000)\n  signed 8 4(4) << -128(ffffff80) = 4(4)\n  signed 8 4(4) << -127(ffffff81) = 8(8)\n  signed 8 4(4) << -126(ffffff82) = 16(10)\n  signed 8 4(4) << -125(ffffff83) = 32(20)\n  signed 8 4(4) << -124(ffffff84) = 64(40)\n  signed 8 4(4) << -123(ffffff85) = 128(80)\n  signed 8 4(4) << -122(ffffff86) = 256(100)\n  signed 8 4(4) << -121(ffffff87) = 512(200)\n  signed 8 4(4) << -120(ffffff88) = 1024(400)\n  signed 8 4(4) << -119(ffffff89) = 2048(800)\n  signed 8 4(4) << -118(ffffff8a) = 4096(1000)\n  signed 8 4(4) << -117(ffffff8b) = 8192(2000)\n  signed 8 4(4) << -116(ffffff8c) = 16384(4000)\n  signed 8 4(4) << -115(ffffff8d) = 32768(8000)\n  signed 8 4(4) << -114(ffffff8e) = 65536(10000)\n  signed 8 4(4) << -113(ffffff8f) = 131072(20000)\n  signed 8 4(4) << -112(ffffff90) = 262144(40000)\n  signed 8 4(4) << -111(ffffff91) = 524288(80000)\n  signed 8 4(4) << -110(ffffff92) = 1048576(100000)\n  signed 8 4(4) << -109(ffffff93) = 2097152(200000)\n  signed 8 4(4) << -108(ffffff94) = 4194304(400000)\n  signed 8 4(4) << -107(ffffff95) = 8388608(800000)\n  signed 8 4(4) << -106(ffffff96) = 16777216(1000000)\n  signed 8 4(4) << -105(ffffff97) = 33554432(2000000)\n  signed 8 4(4) << -104(ffffff98) = 67108864(4000000)\n  signed 8 4(4) << -103(ffffff99) = 134217728(8000000)\n  signed 8 4(4) << -102(ffffff9a) = 268435456(10000000)\n  signed 8 4(4) << -101(ffffff9b) = 536870912(20000000)\n  signed 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\n  signed 8 4(4) << -99(ffffff9d) = -2147483648(80000000)\n  signed 8 4(4) << -98(ffffff9e) = 0(0)\n  signed 8 4(4) << -97(ffffff9f) = 0(0)\n  signed 8 4(4) << -96(ffffffa0) = 4(4)\n  signed 8 4(4) << -95(ffffffa1) = 8(8)\n  signed 8 4(4) << -94(ffffffa2) = 16(10)\n  signed 8 4(4) << -93(ffffffa3) = 32(20)\n  signed 8 4(4) << -92(ffffffa4) = 64(40)\n  signed 8 4(4) << -91(ffffffa5) = 128(80)\n  signed 8 4(4) << -90(ffffffa6) = 256(100)\n  signed 8 4(4) << -89(ffffffa7) = 512(200)\n  signed 8 4(4) << -88(ffffffa8) = 1024(400)\n  signed 8 4(4) << -87(ffffffa9) = 2048(800)\n  signed 8 4(4) << -86(ffffffaa) = 4096(1000)\n  signed 8 4(4) << -85(ffffffab) = 8192(2000)\n  signed 8 4(4) << -84(ffffffac) = 16384(4000)\n  signed 8 4(4) << -83(ffffffad) = 32768(8000)\n  signed 8 4(4) << -82(ffffffae) = 65536(10000)\n  signed 8 4(4) << -81(ffffffaf) = 131072(20000)\n  signed 8 4(4) << -80(ffffffb0) = 262144(40000)\n  signed 8 4(4) << -79(ffffffb1) = 524288(80000)\n  signed 8 4(4) << -78(ffffffb2) = 1048576(100000)\n  signed 8 4(4) << -77(ffffffb3) = 2097152(200000)\n  signed 8 4(4) << -76(ffffffb4) = 4194304(400000)\n  signed 8 4(4) << -75(ffffffb5) = 8388608(800000)\n  signed 8 4(4) << -74(ffffffb6) = 16777216(1000000)\n  signed 8 4(4) << -73(ffffffb7) = 33554432(2000000)\n  signed 8 4(4) << -72(ffffffb8) = 67108864(4000000)\n  signed 8 4(4) << -71(ffffffb9) = 134217728(8000000)\n  signed 8 4(4) << -70(ffffffba) = 268435456(10000000)\n  signed 8 4(4) << -69(ffffffbb) = 536870912(20000000)\n  signed 8 4(4) << -68(ffffffbc) = 1073741824(40000000)\n  signed 8 4(4) << -67(ffffffbd) = -2147483648(80000000)\n  signed 8 4(4) << -66(ffffffbe) = 0(0)\n  signed 8 4(4) << -65(ffffffbf) = 0(0)\n  signed 8 4(4) << -64(ffffffc0) = 4(4)\n  signed 8 4(4) << -63(ffffffc1) = 8(8)\n  signed 8 4(4) << -62(ffffffc2) = 16(10)\n  signed 8 4(4) << -61(ffffffc3) = 32(20)\n  signed 8 4(4) << -60(ffffffc4) = 64(40)\n  signed 8 4(4) << -59(ffffffc5) = 128(80)\n  signed 8 4(4) << -58(ffffffc6) = 256(100)\n  signed 8 4(4) << -57(ffffffc7) = 512(200)\n  signed 8 4(4) << -56(ffffffc8) = 1024(400)\n  signed 8 4(4) << -55(ffffffc9) = 2048(800)\n  signed 8 4(4) << -54(ffffffca) = 4096(1000)\n  signed 8 4(4) << -53(ffffffcb) = 8192(2000)\n  signed 8 4(4) << -52(ffffffcc) = 16384(4000)\n  signed 8 4(4) << -51(ffffffcd) = 32768(8000)\n  signed 8 4(4) << -50(ffffffce) = 65536(10000)\n  signed 8 4(4) << -49(ffffffcf) = 131072(20000)\n  signed 8 4(4) << -48(ffffffd0) = 262144(40000)\n  signed 8 4(4) << -47(ffffffd1) = 524288(80000)\n  signed 8 4(4) << -46(ffffffd2) = 1048576(100000)\n  signed 8 4(4) << -45(ffffffd3) = 2097152(200000)\n  signed 8 4(4) << -44(ffffffd4) = 4194304(400000)\n  signed 8 4(4) << -43(ffffffd5) = 8388608(800000)\n  signed 8 4(4) << -42(ffffffd6) = 16777216(1000000)\n  signed 8 4(4) << -41(ffffffd7) = 33554432(2000000)\n  signed 8 4(4) << -40(ffffffd8) = 67108864(4000000)\n  signed 8 4(4) << -39(ffffffd9) = 134217728(8000000)\n  signed 8 4(4) << -38(ffffffda) = 268435456(10000000)\n  signed 8 4(4) << -37(ffffffdb) = 536870912(20000000)\n  signed 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\n  signed 8 4(4) << -35(ffffffdd) = -2147483648(80000000)\n  signed 8 4(4) << -34(ffffffde) = 0(0)\n  signed 8 4(4) << -33(ffffffdf) = 0(0)\n  signed 8 4(4) << -32(ffffffe0) = 4(4)\n  signed 8 4(4) << -31(ffffffe1) = 8(8)\n  signed 8 4(4) << -30(ffffffe2) = 16(10)\n  signed 8 4(4) << -29(ffffffe3) = 32(20)\n  signed 8 4(4) << -28(ffffffe4) = 64(40)\n  signed 8 4(4) << -27(ffffffe5) = 128(80)\n  signed 8 4(4) << -26(ffffffe6) = 256(100)\n  signed 8 4(4) << -25(ffffffe7) = 512(200)\n  signed 8 4(4) << -24(ffffffe8) = 1024(400)\n  signed 8 4(4) << -23(ffffffe9) = 2048(800)\n  signed 8 4(4) << -22(ffffffea) = 4096(1000)\n  signed 8 4(4) << -21(ffffffeb) = 8192(2000)\n  signed 8 4(4) << -20(ffffffec) = 16384(4000)\n  signed 8 4(4) << -19(ffffffed) = 32768(8000)\n  signed 8 4(4) << -18(ffffffee) = 65536(10000)\n  signed 8 4(4) << -17(ffffffef) = 131072(20000)\n  signed 8 4(4) << -16(fffffff0) = 262144(40000)\n  signed 8 4(4) << -15(fffffff1) = 524288(80000)\n  signed 8 4(4) << -14(fffffff2) = 1048576(100000)\n  signed 8 4(4) << -13(fffffff3) = 2097152(200000)\n  signed 8 4(4) << -12(fffffff4) = 4194304(400000)\n  signed 8 4(4) << -11(fffffff5) = 8388608(800000)\n  signed 8 4(4) << -10(fffffff6) = 16777216(1000000)\n  signed 8 4(4) << -9(fffffff7) = 33554432(2000000)\n  signed 8 4(4) << -8(fffffff8) = 67108864(4000000)\n  signed 8 4(4) << -7(fffffff9) = 134217728(8000000)\n  signed 8 4(4) << -6(fffffffa) = 268435456(10000000)\n  signed 8 4(4) << -5(fffffffb) = 536870912(20000000)\n  signed 8 4(4) << -4(fffffffc) = 1073741824(40000000)\n  signed 8 4(4) << -3(fffffffd) = -2147483648(80000000)\n  signed 8 4(4) << -2(fffffffe) = 0(0)\n  signed 8 4(4) << -1(ffffffff) = 0(0)\n  signed 8 4(4) << 0(0) = 4(4)\n  signed 8 4(4) << 1(1) = 8(8)\n  signed 8 4(4) << 2(2) = 16(10)\n  signed 8 4(4) << 3(3) = 32(20)\n  signed 8 4(4) << 4(4) = 64(40)\n  signed 8 4(4) << 5(5) = 128(80)\n  signed 8 4(4) << 6(6) = 256(100)\n  signed 8 4(4) << 7(7) = 512(200)\n  signed 8 4(4) << 8(8) = 1024(400)\n  signed 8 4(4) << 9(9) = 2048(800)\n  signed 8 4(4) << 10(a) = 4096(1000)\n  signed 8 4(4) << 11(b) = 8192(2000)\n  signed 8 4(4) << 12(c) = 16384(4000)\n  signed 8 4(4) << 13(d) = 32768(8000)\n  signed 8 4(4) << 14(e) = 65536(10000)\n  signed 8 4(4) << 15(f) = 131072(20000)\n  signed 8 4(4) << 16(10) = 262144(40000)\n  signed 8 4(4) << 17(11) = 524288(80000)\n  signed 8 4(4) << 18(12) = 1048576(100000)\n  signed 8 4(4) << 19(13) = 2097152(200000)\n  signed 8 4(4) << 20(14) = 4194304(400000)\n  signed 8 4(4) << 21(15) = 8388608(800000)\n  signed 8 4(4) << 22(16) = 16777216(1000000)\n  signed 8 4(4) << 23(17) = 33554432(2000000)\n  signed 8 4(4) << 24(18) = 67108864(4000000)\n  signed 8 4(4) << 25(19) = 134217728(8000000)\n  signed 8 4(4) << 26(1a) = 268435456(10000000)\n  signed 8 4(4) << 27(1b) = 536870912(20000000)\n  signed 8 4(4) << 28(1c) = 1073741824(40000000)\n  signed 8 4(4) << 29(1d) = -2147483648(80000000)\n  signed 8 4(4) << 30(1e) = 0(0)\n  signed 8 4(4) << 31(1f) = 0(0)\n  signed 8 4(4) << 32(20) = 4(4)\n  signed 8 4(4) << 33(21) = 8(8)\n  signed 8 4(4) << 34(22) = 16(10)\n  signed 8 4(4) << 35(23) = 32(20)\n  signed 8 4(4) << 36(24) = 64(40)\n  signed 8 4(4) << 37(25) = 128(80)\n  signed 8 4(4) << 38(26) = 256(100)\n  signed 8 4(4) << 39(27) = 512(200)\n  signed 8 4(4) << 40(28) = 1024(400)\n  signed 8 4(4) << 41(29) = 2048(800)\n  signed 8 4(4) << 42(2a) = 4096(1000)\n  signed 8 4(4) << 43(2b) = 8192(2000)\n  signed 8 4(4) << 44(2c) = 16384(4000)\n  signed 8 4(4) << 45(2d) = 32768(8000)\n  signed 8 4(4) << 46(2e) = 65536(10000)\n  signed 8 4(4) << 47(2f) = 131072(20000)\n  signed 8 4(4) << 48(30) = 262144(40000)\n  signed 8 4(4) << 49(31) = 524288(80000)\n  signed 8 4(4) << 50(32) = 1048576(100000)\n  signed 8 4(4) << 51(33) = 2097152(200000)\n  signed 8 4(4) << 52(34) = 4194304(400000)\n  signed 8 4(4) << 53(35) = 8388608(800000)\n  signed 8 4(4) << 54(36) = 16777216(1000000)\n  signed 8 4(4) << 55(37) = 33554432(2000000)\n  signed 8 4(4) << 56(38) = 67108864(4000000)\n  signed 8 4(4) << 57(39) = 134217728(8000000)\n  signed 8 4(4) << 58(3a) = 268435456(10000000)\n  signed 8 4(4) << 59(3b) = 536870912(20000000)\n  signed 8 4(4) << 60(3c) = 1073741824(40000000)\n  signed 8 4(4) << 61(3d) = -2147483648(80000000)\n  signed 8 4(4) << 62(3e) = 0(0)\n  signed 8 4(4) << 63(3f) = 0(0)\n  signed 8 4(4) << 64(40) = 4(4)\n  signed 8 4(4) << 65(41) = 8(8)\n  signed 8 4(4) << 66(42) = 16(10)\n  signed 8 4(4) << 67(43) = 32(20)\n  signed 8 4(4) << 68(44) = 64(40)\n  signed 8 4(4) << 69(45) = 128(80)\n  signed 8 4(4) << 70(46) = 256(100)\n  signed 8 4(4) << 71(47) = 512(200)\n  signed 8 4(4) << 72(48) = 1024(400)\n  signed 8 4(4) << 73(49) = 2048(800)\n  signed 8 4(4) << 74(4a) = 4096(1000)\n  signed 8 4(4) << 75(4b) = 8192(2000)\n  signed 8 4(4) << 76(4c) = 16384(4000)\n  signed 8 4(4) << 77(4d) = 32768(8000)\n  signed 8 4(4) << 78(4e) = 65536(10000)\n  signed 8 4(4) << 79(4f) = 131072(20000)\n  signed 8 4(4) << 80(50) = 262144(40000)\n  signed 8 4(4) << 81(51) = 524288(80000)\n  signed 8 4(4) << 82(52) = 1048576(100000)\n  signed 8 4(4) << 83(53) = 2097152(200000)\n  signed 8 4(4) << 84(54) = 4194304(400000)\n  signed 8 4(4) << 85(55) = 8388608(800000)\n  signed 8 4(4) << 86(56) = 16777216(1000000)\n  signed 8 4(4) << 87(57) = 33554432(2000000)\n  signed 8 4(4) << 88(58) = 67108864(4000000)\n  signed 8 4(4) << 89(59) = 134217728(8000000)\n  signed 8 4(4) << 90(5a) = 268435456(10000000)\n  signed 8 4(4) << 91(5b) = 536870912(20000000)\n  signed 8 4(4) << 92(5c) = 1073741824(40000000)\n  signed 8 4(4) << 93(5d) = -2147483648(80000000)\n  signed 8 4(4) << 94(5e) = 0(0)\n  signed 8 4(4) << 95(5f) = 0(0)\n  signed 8 4(4) << 96(60) = 4(4)\n  signed 8 4(4) << 97(61) = 8(8)\n  signed 8 4(4) << 98(62) = 16(10)\n  signed 8 4(4) << 99(63) = 32(20)\n  signed 8 4(4) << 100(64) = 64(40)\n  signed 8 4(4) << 101(65) = 128(80)\n  signed 8 4(4) << 102(66) = 256(100)\n  signed 8 4(4) << 103(67) = 512(200)\n  signed 8 4(4) << 104(68) = 1024(400)\n  signed 8 4(4) << 105(69) = 2048(800)\n  signed 8 4(4) << 106(6a) = 4096(1000)\n  signed 8 4(4) << 107(6b) = 8192(2000)\n  signed 8 4(4) << 108(6c) = 16384(4000)\n  signed 8 4(4) << 109(6d) = 32768(8000)\n  signed 8 4(4) << 110(6e) = 65536(10000)\n  signed 8 4(4) << 111(6f) = 131072(20000)\n  signed 8 4(4) << 112(70) = 262144(40000)\n  signed 8 4(4) << 113(71) = 524288(80000)\n  signed 8 4(4) << 114(72) = 1048576(100000)\n  signed 8 4(4) << 115(73) = 2097152(200000)\n  signed 8 4(4) << 116(74) = 4194304(400000)\n  signed 8 4(4) << 117(75) = 8388608(800000)\n  signed 8 4(4) << 118(76) = 16777216(1000000)\n  signed 8 4(4) << 119(77) = 33554432(2000000)\n  signed 8 4(4) << 120(78) = 67108864(4000000)\n  signed 8 4(4) << 121(79) = 134217728(8000000)\n  signed 8 4(4) << 122(7a) = 268435456(10000000)\n  signed 8 4(4) << 123(7b) = 536870912(20000000)\n  signed 8 4(4) << 124(7c) = 1073741824(40000000)\n  signed 8 4(4) << 125(7d) = -2147483648(80000000)\n  signed 8 4(4) << 126(7e) = 0(0)\n  signed 8 4(4) << 127(7f) = 0(0)\nunsigned 8 0(0) << -128(ffffff80) = 0(0)\nunsigned 8 0(0) << -127(ffffff81) = 0(0)\nunsigned 8 0(0) << -126(ffffff82) = 0(0)\nunsigned 8 0(0) << -125(ffffff83) = 0(0)\nunsigned 8 0(0) << -124(ffffff84) = 0(0)\nunsigned 8 0(0) << -123(ffffff85) = 0(0)\nunsigned 8 0(0) << -122(ffffff86) = 0(0)\nunsigned 8 0(0) << -121(ffffff87) = 0(0)\nunsigned 8 0(0) << -120(ffffff88) = 0(0)\nunsigned 8 0(0) << -119(ffffff89) = 0(0)\nunsigned 8 0(0) << -118(ffffff8a) = 0(0)\nunsigned 8 0(0) << -117(ffffff8b) = 0(0)\nunsigned 8 0(0) << -116(ffffff8c) = 0(0)\nunsigned 8 0(0) << -115(ffffff8d) = 0(0)\nunsigned 8 0(0) << -114(ffffff8e) = 0(0)\nunsigned 8 0(0) << -113(ffffff8f) = 0(0)\nunsigned 8 0(0) << -112(ffffff90) = 0(0)\nunsigned 8 0(0) << -111(ffffff91) = 0(0)\nunsigned 8 0(0) << -110(ffffff92) = 0(0)\nunsigned 8 0(0) << -109(ffffff93) = 0(0)\nunsigned 8 0(0) << -108(ffffff94) = 0(0)\nunsigned 8 0(0) << -107(ffffff95) = 0(0)\nunsigned 8 0(0) << -106(ffffff96) = 0(0)\nunsigned 8 0(0) << -105(ffffff97) = 0(0)\nunsigned 8 0(0) << -104(ffffff98) = 0(0)\nunsigned 8 0(0) << -103(ffffff99) = 0(0)\nunsigned 8 0(0) << -102(ffffff9a) = 0(0)\nunsigned 8 0(0) << -101(ffffff9b) = 0(0)\nunsigned 8 0(0) << -100(ffffff9c) = 0(0)\nunsigned 8 0(0) << -99(ffffff9d) = 0(0)\nunsigned 8 0(0) << -98(ffffff9e) = 0(0)\nunsigned 8 0(0) << -97(ffffff9f) = 0(0)\nunsigned 8 0(0) << -96(ffffffa0) = 0(0)\nunsigned 8 0(0) << -95(ffffffa1) = 0(0)\nunsigned 8 0(0) << -94(ffffffa2) = 0(0)\nunsigned 8 0(0) << -93(ffffffa3) = 0(0)\nunsigned 8 0(0) << -92(ffffffa4) = 0(0)\nunsigned 8 0(0) << -91(ffffffa5) = 0(0)\nunsigned 8 0(0) << -90(ffffffa6) = 0(0)\nunsigned 8 0(0) << -89(ffffffa7) = 0(0)\nunsigned 8 0(0) << -88(ffffffa8) = 0(0)\nunsigned 8 0(0) << -87(ffffffa9) = 0(0)\nunsigned 8 0(0) << -86(ffffffaa) = 0(0)\nunsigned 8 0(0) << -85(ffffffab) = 0(0)\nunsigned 8 0(0) << -84(ffffffac) = 0(0)\nunsigned 8 0(0) << -83(ffffffad) = 0(0)\nunsigned 8 0(0) << -82(ffffffae) = 0(0)\nunsigned 8 0(0) << -81(ffffffaf) = 0(0)\nunsigned 8 0(0) << -80(ffffffb0) = 0(0)\nunsigned 8 0(0) << -79(ffffffb1) = 0(0)\nunsigned 8 0(0) << -78(ffffffb2) = 0(0)\nunsigned 8 0(0) << -77(ffffffb3) = 0(0)\nunsigned 8 0(0) << -76(ffffffb4) = 0(0)\nunsigned 8 0(0) << -75(ffffffb5) = 0(0)\nunsigned 8 0(0) << -74(ffffffb6) = 0(0)\nunsigned 8 0(0) << -73(ffffffb7) = 0(0)\nunsigned 8 0(0) << -72(ffffffb8) = 0(0)\nunsigned 8 0(0) << -71(ffffffb9) = 0(0)\nunsigned 8 0(0) << -70(ffffffba) = 0(0)\nunsigned 8 0(0) << -69(ffffffbb) = 0(0)\nunsigned 8 0(0) << -68(ffffffbc) = 0(0)\nunsigned 8 0(0) << -67(ffffffbd) = 0(0)\nunsigned 8 0(0) << -66(ffffffbe) = 0(0)\nunsigned 8 0(0) << -65(ffffffbf) = 0(0)\nunsigned 8 0(0) << -64(ffffffc0) = 0(0)\nunsigned 8 0(0) << -63(ffffffc1) = 0(0)\nunsigned 8 0(0) << -62(ffffffc2) = 0(0)\nunsigned 8 0(0) << -61(ffffffc3) = 0(0)\nunsigned 8 0(0) << -60(ffffffc4) = 0(0)\nunsigned 8 0(0) << -59(ffffffc5) = 0(0)\nunsigned 8 0(0) << -58(ffffffc6) = 0(0)\nunsigned 8 0(0) << -57(ffffffc7) = 0(0)\nunsigned 8 0(0) << -56(ffffffc8) = 0(0)\nunsigned 8 0(0) << -55(ffffffc9) = 0(0)\nunsigned 8 0(0) << -54(ffffffca) = 0(0)\nunsigned 8 0(0) << -53(ffffffcb) = 0(0)\nunsigned 8 0(0) << -52(ffffffcc) = 0(0)\nunsigned 8 0(0) << -51(ffffffcd) = 0(0)\nunsigned 8 0(0) << -50(ffffffce) = 0(0)\nunsigned 8 0(0) << -49(ffffffcf) = 0(0)\nunsigned 8 0(0) << -48(ffffffd0) = 0(0)\nunsigned 8 0(0) << -47(ffffffd1) = 0(0)\nunsigned 8 0(0) << -46(ffffffd2) = 0(0)\nunsigned 8 0(0) << -45(ffffffd3) = 0(0)\nunsigned 8 0(0) << -44(ffffffd4) = 0(0)\nunsigned 8 0(0) << -43(ffffffd5) = 0(0)\nunsigned 8 0(0) << -42(ffffffd6) = 0(0)\nunsigned 8 0(0) << -41(ffffffd7) = 0(0)\nunsigned 8 0(0) << -40(ffffffd8) = 0(0)\nunsigned 8 0(0) << -39(ffffffd9) = 0(0)\nunsigned 8 0(0) << -38(ffffffda) = 0(0)\nunsigned 8 0(0) << -37(ffffffdb) = 0(0)\nunsigned 8 0(0) << -36(ffffffdc) = 0(0)\nunsigned 8 0(0) << -35(ffffffdd) = 0(0)\nunsigned 8 0(0) << -34(ffffffde) = 0(0)\nunsigned 8 0(0) << -33(ffffffdf) = 0(0)\nunsigned 8 0(0) << -32(ffffffe0) = 0(0)\nunsigned 8 0(0) << -31(ffffffe1) = 0(0)\nunsigned 8 0(0) << -30(ffffffe2) = 0(0)\nunsigned 8 0(0) << -29(ffffffe3) = 0(0)\nunsigned 8 0(0) << -28(ffffffe4) = 0(0)\nunsigned 8 0(0) << -27(ffffffe5) = 0(0)\nunsigned 8 0(0) << -26(ffffffe6) = 0(0)\nunsigned 8 0(0) << -25(ffffffe7) = 0(0)\nunsigned 8 0(0) << -24(ffffffe8) = 0(0)\nunsigned 8 0(0) << -23(ffffffe9) = 0(0)\nunsigned 8 0(0) << -22(ffffffea) = 0(0)\nunsigned 8 0(0) << -21(ffffffeb) = 0(0)\nunsigned 8 0(0) << -20(ffffffec) = 0(0)\nunsigned 8 0(0) << -19(ffffffed) = 0(0)\nunsigned 8 0(0) << -18(ffffffee) = 0(0)\nunsigned 8 0(0) << -17(ffffffef) = 0(0)\nunsigned 8 0(0) << -16(fffffff0) = 0(0)\nunsigned 8 0(0) << -15(fffffff1) = 0(0)\nunsigned 8 0(0) << -14(fffffff2) = 0(0)\nunsigned 8 0(0) << -13(fffffff3) = 0(0)\nunsigned 8 0(0) << -12(fffffff4) = 0(0)\nunsigned 8 0(0) << -11(fffffff5) = 0(0)\nunsigned 8 0(0) << -10(fffffff6) = 0(0)\nunsigned 8 0(0) << -9(fffffff7) = 0(0)\nunsigned 8 0(0) << -8(fffffff8) = 0(0)\nunsigned 8 0(0) << -7(fffffff9) = 0(0)\nunsigned 8 0(0) << -6(fffffffa) = 0(0)\nunsigned 8 0(0) << -5(fffffffb) = 0(0)\nunsigned 8 0(0) << -4(fffffffc) = 0(0)\nunsigned 8 0(0) << -3(fffffffd) = 0(0)\nunsigned 8 0(0) << -2(fffffffe) = 0(0)\nunsigned 8 0(0) << -1(ffffffff) = 0(0)\nunsigned 8 0(0) << 0(0) = 0(0)\nunsigned 8 0(0) << 1(1) = 0(0)\nunsigned 8 0(0) << 2(2) = 0(0)\nunsigned 8 0(0) << 3(3) = 0(0)\nunsigned 8 0(0) << 4(4) = 0(0)\nunsigned 8 0(0) << 5(5) = 0(0)\nunsigned 8 0(0) << 6(6) = 0(0)\nunsigned 8 0(0) << 7(7) = 0(0)\nunsigned 8 0(0) << 8(8) = 0(0)\nunsigned 8 0(0) << 9(9) = 0(0)\nunsigned 8 0(0) << 10(a) = 0(0)\nunsigned 8 0(0) << 11(b) = 0(0)\nunsigned 8 0(0) << 12(c) = 0(0)\nunsigned 8 0(0) << 13(d) = 0(0)\nunsigned 8 0(0) << 14(e) = 0(0)\nunsigned 8 0(0) << 15(f) = 0(0)\nunsigned 8 0(0) << 16(10) = 0(0)\nunsigned 8 0(0) << 17(11) = 0(0)\nunsigned 8 0(0) << 18(12) = 0(0)\nunsigned 8 0(0) << 19(13) = 0(0)\nunsigned 8 0(0) << 20(14) = 0(0)\nunsigned 8 0(0) << 21(15) = 0(0)\nunsigned 8 0(0) << 22(16) = 0(0)\nunsigned 8 0(0) << 23(17) = 0(0)\nunsigned 8 0(0) << 24(18) = 0(0)\nunsigned 8 0(0) << 25(19) = 0(0)\nunsigned 8 0(0) << 26(1a) = 0(0)\nunsigned 8 0(0) << 27(1b) = 0(0)\nunsigned 8 0(0) << 28(1c) = 0(0)\nunsigned 8 0(0) << 29(1d) = 0(0)\nunsigned 8 0(0) << 30(1e) = 0(0)\nunsigned 8 0(0) << 31(1f) = 0(0)\nunsigned 8 0(0) << 32(20) = 0(0)\nunsigned 8 0(0) << 33(21) = 0(0)\nunsigned 8 0(0) << 34(22) = 0(0)\nunsigned 8 0(0) << 35(23) = 0(0)\nunsigned 8 0(0) << 36(24) = 0(0)\nunsigned 8 0(0) << 37(25) = 0(0)\nunsigned 8 0(0) << 38(26) = 0(0)\nunsigned 8 0(0) << 39(27) = 0(0)\nunsigned 8 0(0) << 40(28) = 0(0)\nunsigned 8 0(0) << 41(29) = 0(0)\nunsigned 8 0(0) << 42(2a) = 0(0)\nunsigned 8 0(0) << 43(2b) = 0(0)\nunsigned 8 0(0) << 44(2c) = 0(0)\nunsigned 8 0(0) << 45(2d) = 0(0)\nunsigned 8 0(0) << 46(2e) = 0(0)\nunsigned 8 0(0) << 47(2f) = 0(0)\nunsigned 8 0(0) << 48(30) = 0(0)\nunsigned 8 0(0) << 49(31) = 0(0)\nunsigned 8 0(0) << 50(32) = 0(0)\nunsigned 8 0(0) << 51(33) = 0(0)\nunsigned 8 0(0) << 52(34) = 0(0)\nunsigned 8 0(0) << 53(35) = 0(0)\nunsigned 8 0(0) << 54(36) = 0(0)\nunsigned 8 0(0) << 55(37) = 0(0)\nunsigned 8 0(0) << 56(38) = 0(0)\nunsigned 8 0(0) << 57(39) = 0(0)\nunsigned 8 0(0) << 58(3a) = 0(0)\nunsigned 8 0(0) << 59(3b) = 0(0)\nunsigned 8 0(0) << 60(3c) = 0(0)\nunsigned 8 0(0) << 61(3d) = 0(0)\nunsigned 8 0(0) << 62(3e) = 0(0)\nunsigned 8 0(0) << 63(3f) = 0(0)\nunsigned 8 0(0) << 64(40) = 0(0)\nunsigned 8 0(0) << 65(41) = 0(0)\nunsigned 8 0(0) << 66(42) = 0(0)\nunsigned 8 0(0) << 67(43) = 0(0)\nunsigned 8 0(0) << 68(44) = 0(0)\nunsigned 8 0(0) << 69(45) = 0(0)\nunsigned 8 0(0) << 70(46) = 0(0)\nunsigned 8 0(0) << 71(47) = 0(0)\nunsigned 8 0(0) << 72(48) = 0(0)\nunsigned 8 0(0) << 73(49) = 0(0)\nunsigned 8 0(0) << 74(4a) = 0(0)\nunsigned 8 0(0) << 75(4b) = 0(0)\nunsigned 8 0(0) << 76(4c) = 0(0)\nunsigned 8 0(0) << 77(4d) = 0(0)\nunsigned 8 0(0) << 78(4e) = 0(0)\nunsigned 8 0(0) << 79(4f) = 0(0)\nunsigned 8 0(0) << 80(50) = 0(0)\nunsigned 8 0(0) << 81(51) = 0(0)\nunsigned 8 0(0) << 82(52) = 0(0)\nunsigned 8 0(0) << 83(53) = 0(0)\nunsigned 8 0(0) << 84(54) = 0(0)\nunsigned 8 0(0) << 85(55) = 0(0)\nunsigned 8 0(0) << 86(56) = 0(0)\nunsigned 8 0(0) << 87(57) = 0(0)\nunsigned 8 0(0) << 88(58) = 0(0)\nunsigned 8 0(0) << 89(59) = 0(0)\nunsigned 8 0(0) << 90(5a) = 0(0)\nunsigned 8 0(0) << 91(5b) = 0(0)\nunsigned 8 0(0) << 92(5c) = 0(0)\nunsigned 8 0(0) << 93(5d) = 0(0)\nunsigned 8 0(0) << 94(5e) = 0(0)\nunsigned 8 0(0) << 95(5f) = 0(0)\nunsigned 8 0(0) << 96(60) = 0(0)\nunsigned 8 0(0) << 97(61) = 0(0)\nunsigned 8 0(0) << 98(62) = 0(0)\nunsigned 8 0(0) << 99(63) = 0(0)\nunsigned 8 0(0) << 100(64) = 0(0)\nunsigned 8 0(0) << 101(65) = 0(0)\nunsigned 8 0(0) << 102(66) = 0(0)\nunsigned 8 0(0) << 103(67) = 0(0)\nunsigned 8 0(0) << 104(68) = 0(0)\nunsigned 8 0(0) << 105(69) = 0(0)\nunsigned 8 0(0) << 106(6a) = 0(0)\nunsigned 8 0(0) << 107(6b) = 0(0)\nunsigned 8 0(0) << 108(6c) = 0(0)\nunsigned 8 0(0) << 109(6d) = 0(0)\nunsigned 8 0(0) << 110(6e) = 0(0)\nunsigned 8 0(0) << 111(6f) = 0(0)\nunsigned 8 0(0) << 112(70) = 0(0)\nunsigned 8 0(0) << 113(71) = 0(0)\nunsigned 8 0(0) << 114(72) = 0(0)\nunsigned 8 0(0) << 115(73) = 0(0)\nunsigned 8 0(0) << 116(74) = 0(0)\nunsigned 8 0(0) << 117(75) = 0(0)\nunsigned 8 0(0) << 118(76) = 0(0)\nunsigned 8 0(0) << 119(77) = 0(0)\nunsigned 8 0(0) << 120(78) = 0(0)\nunsigned 8 0(0) << 121(79) = 0(0)\nunsigned 8 0(0) << 122(7a) = 0(0)\nunsigned 8 0(0) << 123(7b) = 0(0)\nunsigned 8 0(0) << 124(7c) = 0(0)\nunsigned 8 0(0) << 125(7d) = 0(0)\nunsigned 8 0(0) << 126(7e) = 0(0)\nunsigned 8 0(0) << 127(7f) = 0(0)\nunsigned 8 1(1) << -128(ffffff80) = 1(1)\nunsigned 8 1(1) << -127(ffffff81) = 2(2)\nunsigned 8 1(1) << -126(ffffff82) = 4(4)\nunsigned 8 1(1) << -125(ffffff83) = 8(8)\nunsigned 8 1(1) << -124(ffffff84) = 16(10)\nunsigned 8 1(1) << -123(ffffff85) = 32(20)\nunsigned 8 1(1) << -122(ffffff86) = 64(40)\nunsigned 8 1(1) << -121(ffffff87) = 128(80)\nunsigned 8 1(1) << -120(ffffff88) = 256(100)\nunsigned 8 1(1) << -119(ffffff89) = 512(200)\nunsigned 8 1(1) << -118(ffffff8a) = 1024(400)\nunsigned 8 1(1) << -117(ffffff8b) = 2048(800)\nunsigned 8 1(1) << -116(ffffff8c) = 4096(1000)\nunsigned 8 1(1) << -115(ffffff8d) = 8192(2000)\nunsigned 8 1(1) << -114(ffffff8e) = 16384(4000)\nunsigned 8 1(1) << -113(ffffff8f) = 32768(8000)\nunsigned 8 1(1) << -112(ffffff90) = 65536(10000)\nunsigned 8 1(1) << -111(ffffff91) = 131072(20000)\nunsigned 8 1(1) << -110(ffffff92) = 262144(40000)\nunsigned 8 1(1) << -109(ffffff93) = 524288(80000)\nunsigned 8 1(1) << -108(ffffff94) = 1048576(100000)\nunsigned 8 1(1) << -107(ffffff95) = 2097152(200000)\nunsigned 8 1(1) << -106(ffffff96) = 4194304(400000)\nunsigned 8 1(1) << -105(ffffff97) = 8388608(800000)\nunsigned 8 1(1) << -104(ffffff98) = 16777216(1000000)\nunsigned 8 1(1) << -103(ffffff99) = 33554432(2000000)\nunsigned 8 1(1) << -102(ffffff9a) = 67108864(4000000)\nunsigned 8 1(1) << -101(ffffff9b) = 134217728(8000000)\nunsigned 8 1(1) << -100(ffffff9c) = 268435456(10000000)\nunsigned 8 1(1) << -99(ffffff9d) = 536870912(20000000)\nunsigned 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\nunsigned 8 1(1) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 1(1) << -96(ffffffa0) = 1(1)\nunsigned 8 1(1) << -95(ffffffa1) = 2(2)\nunsigned 8 1(1) << -94(ffffffa2) = 4(4)\nunsigned 8 1(1) << -93(ffffffa3) = 8(8)\nunsigned 8 1(1) << -92(ffffffa4) = 16(10)\nunsigned 8 1(1) << -91(ffffffa5) = 32(20)\nunsigned 8 1(1) << -90(ffffffa6) = 64(40)\nunsigned 8 1(1) << -89(ffffffa7) = 128(80)\nunsigned 8 1(1) << -88(ffffffa8) = 256(100)\nunsigned 8 1(1) << -87(ffffffa9) = 512(200)\nunsigned 8 1(1) << -86(ffffffaa) = 1024(400)\nunsigned 8 1(1) << -85(ffffffab) = 2048(800)\nunsigned 8 1(1) << -84(ffffffac) = 4096(1000)\nunsigned 8 1(1) << -83(ffffffad) = 8192(2000)\nunsigned 8 1(1) << -82(ffffffae) = 16384(4000)\nunsigned 8 1(1) << -81(ffffffaf) = 32768(8000)\nunsigned 8 1(1) << -80(ffffffb0) = 65536(10000)\nunsigned 8 1(1) << -79(ffffffb1) = 131072(20000)\nunsigned 8 1(1) << -78(ffffffb2) = 262144(40000)\nunsigned 8 1(1) << -77(ffffffb3) = 524288(80000)\nunsigned 8 1(1) << -76(ffffffb4) = 1048576(100000)\nunsigned 8 1(1) << -75(ffffffb5) = 2097152(200000)\nunsigned 8 1(1) << -74(ffffffb6) = 4194304(400000)\nunsigned 8 1(1) << -73(ffffffb7) = 8388608(800000)\nunsigned 8 1(1) << -72(ffffffb8) = 16777216(1000000)\nunsigned 8 1(1) << -71(ffffffb9) = 33554432(2000000)\nunsigned 8 1(1) << -70(ffffffba) = 67108864(4000000)\nunsigned 8 1(1) << -69(ffffffbb) = 134217728(8000000)\nunsigned 8 1(1) << -68(ffffffbc) = 268435456(10000000)\nunsigned 8 1(1) << -67(ffffffbd) = 536870912(20000000)\nunsigned 8 1(1) << -66(ffffffbe) = 1073741824(40000000)\nunsigned 8 1(1) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 1(1) << -64(ffffffc0) = 1(1)\nunsigned 8 1(1) << -63(ffffffc1) = 2(2)\nunsigned 8 1(1) << -62(ffffffc2) = 4(4)\nunsigned 8 1(1) << -61(ffffffc3) = 8(8)\nunsigned 8 1(1) << -60(ffffffc4) = 16(10)\nunsigned 8 1(1) << -59(ffffffc5) = 32(20)\nunsigned 8 1(1) << -58(ffffffc6) = 64(40)\nunsigned 8 1(1) << -57(ffffffc7) = 128(80)\nunsigned 8 1(1) << -56(ffffffc8) = 256(100)\nunsigned 8 1(1) << -55(ffffffc9) = 512(200)\nunsigned 8 1(1) << -54(ffffffca) = 1024(400)\nunsigned 8 1(1) << -53(ffffffcb) = 2048(800)\nunsigned 8 1(1) << -52(ffffffcc) = 4096(1000)\nunsigned 8 1(1) << -51(ffffffcd) = 8192(2000)\nunsigned 8 1(1) << -50(ffffffce) = 16384(4000)\nunsigned 8 1(1) << -49(ffffffcf) = 32768(8000)\nunsigned 8 1(1) << -48(ffffffd0) = 65536(10000)\nunsigned 8 1(1) << -47(ffffffd1) = 131072(20000)\nunsigned 8 1(1) << -46(ffffffd2) = 262144(40000)\nunsigned 8 1(1) << -45(ffffffd3) = 524288(80000)\nunsigned 8 1(1) << -44(ffffffd4) = 1048576(100000)\nunsigned 8 1(1) << -43(ffffffd5) = 2097152(200000)\nunsigned 8 1(1) << -42(ffffffd6) = 4194304(400000)\nunsigned 8 1(1) << -41(ffffffd7) = 8388608(800000)\nunsigned 8 1(1) << -40(ffffffd8) = 16777216(1000000)\nunsigned 8 1(1) << -39(ffffffd9) = 33554432(2000000)\nunsigned 8 1(1) << -38(ffffffda) = 67108864(4000000)\nunsigned 8 1(1) << -37(ffffffdb) = 134217728(8000000)\nunsigned 8 1(1) << -36(ffffffdc) = 268435456(10000000)\nunsigned 8 1(1) << -35(ffffffdd) = 536870912(20000000)\nunsigned 8 1(1) << -34(ffffffde) = 1073741824(40000000)\nunsigned 8 1(1) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 1(1) << -32(ffffffe0) = 1(1)\nunsigned 8 1(1) << -31(ffffffe1) = 2(2)\nunsigned 8 1(1) << -30(ffffffe2) = 4(4)\nunsigned 8 1(1) << -29(ffffffe3) = 8(8)\nunsigned 8 1(1) << -28(ffffffe4) = 16(10)\nunsigned 8 1(1) << -27(ffffffe5) = 32(20)\nunsigned 8 1(1) << -26(ffffffe6) = 64(40)\nunsigned 8 1(1) << -25(ffffffe7) = 128(80)\nunsigned 8 1(1) << -24(ffffffe8) = 256(100)\nunsigned 8 1(1) << -23(ffffffe9) = 512(200)\nunsigned 8 1(1) << -22(ffffffea) = 1024(400)\nunsigned 8 1(1) << -21(ffffffeb) = 2048(800)\nunsigned 8 1(1) << -20(ffffffec) = 4096(1000)\nunsigned 8 1(1) << -19(ffffffed) = 8192(2000)\nunsigned 8 1(1) << -18(ffffffee) = 16384(4000)\nunsigned 8 1(1) << -17(ffffffef) = 32768(8000)\nunsigned 8 1(1) << -16(fffffff0) = 65536(10000)\nunsigned 8 1(1) << -15(fffffff1) = 131072(20000)\nunsigned 8 1(1) << -14(fffffff2) = 262144(40000)\nunsigned 8 1(1) << -13(fffffff3) = 524288(80000)\nunsigned 8 1(1) << -12(fffffff4) = 1048576(100000)\nunsigned 8 1(1) << -11(fffffff5) = 2097152(200000)\nunsigned 8 1(1) << -10(fffffff6) = 4194304(400000)\nunsigned 8 1(1) << -9(fffffff7) = 8388608(800000)\nunsigned 8 1(1) << -8(fffffff8) = 16777216(1000000)\nunsigned 8 1(1) << -7(fffffff9) = 33554432(2000000)\nunsigned 8 1(1) << -6(fffffffa) = 67108864(4000000)\nunsigned 8 1(1) << -5(fffffffb) = 134217728(8000000)\nunsigned 8 1(1) << -4(fffffffc) = 268435456(10000000)\nunsigned 8 1(1) << -3(fffffffd) = 536870912(20000000)\nunsigned 8 1(1) << -2(fffffffe) = 1073741824(40000000)\nunsigned 8 1(1) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 1(1) << 0(0) = 1(1)\nunsigned 8 1(1) << 1(1) = 2(2)\nunsigned 8 1(1) << 2(2) = 4(4)\nunsigned 8 1(1) << 3(3) = 8(8)\nunsigned 8 1(1) << 4(4) = 16(10)\nunsigned 8 1(1) << 5(5) = 32(20)\nunsigned 8 1(1) << 6(6) = 64(40)\nunsigned 8 1(1) << 7(7) = 128(80)\nunsigned 8 1(1) << 8(8) = 256(100)\nunsigned 8 1(1) << 9(9) = 512(200)\nunsigned 8 1(1) << 10(a) = 1024(400)\nunsigned 8 1(1) << 11(b) = 2048(800)\nunsigned 8 1(1) << 12(c) = 4096(1000)\nunsigned 8 1(1) << 13(d) = 8192(2000)\nunsigned 8 1(1) << 14(e) = 16384(4000)\nunsigned 8 1(1) << 15(f) = 32768(8000)\nunsigned 8 1(1) << 16(10) = 65536(10000)\nunsigned 8 1(1) << 17(11) = 131072(20000)\nunsigned 8 1(1) << 18(12) = 262144(40000)\nunsigned 8 1(1) << 19(13) = 524288(80000)\nunsigned 8 1(1) << 20(14) = 1048576(100000)\nunsigned 8 1(1) << 21(15) = 2097152(200000)\nunsigned 8 1(1) << 22(16) = 4194304(400000)\nunsigned 8 1(1) << 23(17) = 8388608(800000)\nunsigned 8 1(1) << 24(18) = 16777216(1000000)\nunsigned 8 1(1) << 25(19) = 33554432(2000000)\nunsigned 8 1(1) << 26(1a) = 67108864(4000000)\nunsigned 8 1(1) << 27(1b) = 134217728(8000000)\nunsigned 8 1(1) << 28(1c) = 268435456(10000000)\nunsigned 8 1(1) << 29(1d) = 536870912(20000000)\nunsigned 8 1(1) << 30(1e) = 1073741824(40000000)\nunsigned 8 1(1) << 31(1f) = 2147483648(80000000)\nunsigned 8 1(1) << 32(20) = 1(1)\nunsigned 8 1(1) << 33(21) = 2(2)\nunsigned 8 1(1) << 34(22) = 4(4)\nunsigned 8 1(1) << 35(23) = 8(8)\nunsigned 8 1(1) << 36(24) = 16(10)\nunsigned 8 1(1) << 37(25) = 32(20)\nunsigned 8 1(1) << 38(26) = 64(40)\nunsigned 8 1(1) << 39(27) = 128(80)\nunsigned 8 1(1) << 40(28) = 256(100)\nunsigned 8 1(1) << 41(29) = 512(200)\nunsigned 8 1(1) << 42(2a) = 1024(400)\nunsigned 8 1(1) << 43(2b) = 2048(800)\nunsigned 8 1(1) << 44(2c) = 4096(1000)\nunsigned 8 1(1) << 45(2d) = 8192(2000)\nunsigned 8 1(1) << 46(2e) = 16384(4000)\nunsigned 8 1(1) << 47(2f) = 32768(8000)\nunsigned 8 1(1) << 48(30) = 65536(10000)\nunsigned 8 1(1) << 49(31) = 131072(20000)\nunsigned 8 1(1) << 50(32) = 262144(40000)\nunsigned 8 1(1) << 51(33) = 524288(80000)\nunsigned 8 1(1) << 52(34) = 1048576(100000)\nunsigned 8 1(1) << 53(35) = 2097152(200000)\nunsigned 8 1(1) << 54(36) = 4194304(400000)\nunsigned 8 1(1) << 55(37) = 8388608(800000)\nunsigned 8 1(1) << 56(38) = 16777216(1000000)\nunsigned 8 1(1) << 57(39) = 33554432(2000000)\nunsigned 8 1(1) << 58(3a) = 67108864(4000000)\nunsigned 8 1(1) << 59(3b) = 134217728(8000000)\nunsigned 8 1(1) << 60(3c) = 268435456(10000000)\nunsigned 8 1(1) << 61(3d) = 536870912(20000000)\nunsigned 8 1(1) << 62(3e) = 1073741824(40000000)\nunsigned 8 1(1) << 63(3f) = 2147483648(80000000)\nunsigned 8 1(1) << 64(40) = 1(1)\nunsigned 8 1(1) << 65(41) = 2(2)\nunsigned 8 1(1) << 66(42) = 4(4)\nunsigned 8 1(1) << 67(43) = 8(8)\nunsigned 8 1(1) << 68(44) = 16(10)\nunsigned 8 1(1) << 69(45) = 32(20)\nunsigned 8 1(1) << 70(46) = 64(40)\nunsigned 8 1(1) << 71(47) = 128(80)\nunsigned 8 1(1) << 72(48) = 256(100)\nunsigned 8 1(1) << 73(49) = 512(200)\nunsigned 8 1(1) << 74(4a) = 1024(400)\nunsigned 8 1(1) << 75(4b) = 2048(800)\nunsigned 8 1(1) << 76(4c) = 4096(1000)\nunsigned 8 1(1) << 77(4d) = 8192(2000)\nunsigned 8 1(1) << 78(4e) = 16384(4000)\nunsigned 8 1(1) << 79(4f) = 32768(8000)\nunsigned 8 1(1) << 80(50) = 65536(10000)\nunsigned 8 1(1) << 81(51) = 131072(20000)\nunsigned 8 1(1) << 82(52) = 262144(40000)\nunsigned 8 1(1) << 83(53) = 524288(80000)\nunsigned 8 1(1) << 84(54) = 1048576(100000)\nunsigned 8 1(1) << 85(55) = 2097152(200000)\nunsigned 8 1(1) << 86(56) = 4194304(400000)\nunsigned 8 1(1) << 87(57) = 8388608(800000)\nunsigned 8 1(1) << 88(58) = 16777216(1000000)\nunsigned 8 1(1) << 89(59) = 33554432(2000000)\nunsigned 8 1(1) << 90(5a) = 67108864(4000000)\nunsigned 8 1(1) << 91(5b) = 134217728(8000000)\nunsigned 8 1(1) << 92(5c) = 268435456(10000000)\nunsigned 8 1(1) << 93(5d) = 536870912(20000000)\nunsigned 8 1(1) << 94(5e) = 1073741824(40000000)\nunsigned 8 1(1) << 95(5f) = 2147483648(80000000)\nunsigned 8 1(1) << 96(60) = 1(1)\nunsigned 8 1(1) << 97(61) = 2(2)\nunsigned 8 1(1) << 98(62) = 4(4)\nunsigned 8 1(1) << 99(63) = 8(8)\nunsigned 8 1(1) << 100(64) = 16(10)\nunsigned 8 1(1) << 101(65) = 32(20)\nunsigned 8 1(1) << 102(66) = 64(40)\nunsigned 8 1(1) << 103(67) = 128(80)\nunsigned 8 1(1) << 104(68) = 256(100)\nunsigned 8 1(1) << 105(69) = 512(200)\nunsigned 8 1(1) << 106(6a) = 1024(400)\nunsigned 8 1(1) << 107(6b) = 2048(800)\nunsigned 8 1(1) << 108(6c) = 4096(1000)\nunsigned 8 1(1) << 109(6d) = 8192(2000)\nunsigned 8 1(1) << 110(6e) = 16384(4000)\nunsigned 8 1(1) << 111(6f) = 32768(8000)\nunsigned 8 1(1) << 112(70) = 65536(10000)\nunsigned 8 1(1) << 113(71) = 131072(20000)\nunsigned 8 1(1) << 114(72) = 262144(40000)\nunsigned 8 1(1) << 115(73) = 524288(80000)\nunsigned 8 1(1) << 116(74) = 1048576(100000)\nunsigned 8 1(1) << 117(75) = 2097152(200000)\nunsigned 8 1(1) << 118(76) = 4194304(400000)\nunsigned 8 1(1) << 119(77) = 8388608(800000)\nunsigned 8 1(1) << 120(78) = 16777216(1000000)\nunsigned 8 1(1) << 121(79) = 33554432(2000000)\nunsigned 8 1(1) << 122(7a) = 67108864(4000000)\nunsigned 8 1(1) << 123(7b) = 134217728(8000000)\nunsigned 8 1(1) << 124(7c) = 268435456(10000000)\nunsigned 8 1(1) << 125(7d) = 536870912(20000000)\nunsigned 8 1(1) << 126(7e) = 1073741824(40000000)\nunsigned 8 1(1) << 127(7f) = 2147483648(80000000)\nunsigned 8 2(2) << -128(ffffff80) = 2(2)\nunsigned 8 2(2) << -127(ffffff81) = 4(4)\nunsigned 8 2(2) << -126(ffffff82) = 8(8)\nunsigned 8 2(2) << -125(ffffff83) = 16(10)\nunsigned 8 2(2) << -124(ffffff84) = 32(20)\nunsigned 8 2(2) << -123(ffffff85) = 64(40)\nunsigned 8 2(2) << -122(ffffff86) = 128(80)\nunsigned 8 2(2) << -121(ffffff87) = 256(100)\nunsigned 8 2(2) << -120(ffffff88) = 512(200)\nunsigned 8 2(2) << -119(ffffff89) = 1024(400)\nunsigned 8 2(2) << -118(ffffff8a) = 2048(800)\nunsigned 8 2(2) << -117(ffffff8b) = 4096(1000)\nunsigned 8 2(2) << -116(ffffff8c) = 8192(2000)\nunsigned 8 2(2) << -115(ffffff8d) = 16384(4000)\nunsigned 8 2(2) << -114(ffffff8e) = 32768(8000)\nunsigned 8 2(2) << -113(ffffff8f) = 65536(10000)\nunsigned 8 2(2) << -112(ffffff90) = 131072(20000)\nunsigned 8 2(2) << -111(ffffff91) = 262144(40000)\nunsigned 8 2(2) << -110(ffffff92) = 524288(80000)\nunsigned 8 2(2) << -109(ffffff93) = 1048576(100000)\nunsigned 8 2(2) << -108(ffffff94) = 2097152(200000)\nunsigned 8 2(2) << -107(ffffff95) = 4194304(400000)\nunsigned 8 2(2) << -106(ffffff96) = 8388608(800000)\nunsigned 8 2(2) << -105(ffffff97) = 16777216(1000000)\nunsigned 8 2(2) << -104(ffffff98) = 33554432(2000000)\nunsigned 8 2(2) << -103(ffffff99) = 67108864(4000000)\nunsigned 8 2(2) << -102(ffffff9a) = 134217728(8000000)\nunsigned 8 2(2) << -101(ffffff9b) = 268435456(10000000)\nunsigned 8 2(2) << -100(ffffff9c) = 536870912(20000000)\nunsigned 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\nunsigned 8 2(2) << -98(ffffff9e) = 2147483648(80000000)\nunsigned 8 2(2) << -97(ffffff9f) = 0(0)\nunsigned 8 2(2) << -96(ffffffa0) = 2(2)\nunsigned 8 2(2) << -95(ffffffa1) = 4(4)\nunsigned 8 2(2) << -94(ffffffa2) = 8(8)\nunsigned 8 2(2) << -93(ffffffa3) = 16(10)\nunsigned 8 2(2) << -92(ffffffa4) = 32(20)\nunsigned 8 2(2) << -91(ffffffa5) = 64(40)\nunsigned 8 2(2) << -90(ffffffa6) = 128(80)\nunsigned 8 2(2) << -89(ffffffa7) = 256(100)\nunsigned 8 2(2) << -88(ffffffa8) = 512(200)\nunsigned 8 2(2) << -87(ffffffa9) = 1024(400)\nunsigned 8 2(2) << -86(ffffffaa) = 2048(800)\nunsigned 8 2(2) << -85(ffffffab) = 4096(1000)\nunsigned 8 2(2) << -84(ffffffac) = 8192(2000)\nunsigned 8 2(2) << -83(ffffffad) = 16384(4000)\nunsigned 8 2(2) << -82(ffffffae) = 32768(8000)\nunsigned 8 2(2) << -81(ffffffaf) = 65536(10000)\nunsigned 8 2(2) << -80(ffffffb0) = 131072(20000)\nunsigned 8 2(2) << -79(ffffffb1) = 262144(40000)\nunsigned 8 2(2) << -78(ffffffb2) = 524288(80000)\nunsigned 8 2(2) << -77(ffffffb3) = 1048576(100000)\nunsigned 8 2(2) << -76(ffffffb4) = 2097152(200000)\nunsigned 8 2(2) << -75(ffffffb5) = 4194304(400000)\nunsigned 8 2(2) << -74(ffffffb6) = 8388608(800000)\nunsigned 8 2(2) << -73(ffffffb7) = 16777216(1000000)\nunsigned 8 2(2) << -72(ffffffb8) = 33554432(2000000)\nunsigned 8 2(2) << -71(ffffffb9) = 67108864(4000000)\nunsigned 8 2(2) << -70(ffffffba) = 134217728(8000000)\nunsigned 8 2(2) << -69(ffffffbb) = 268435456(10000000)\nunsigned 8 2(2) << -68(ffffffbc) = 536870912(20000000)\nunsigned 8 2(2) << -67(ffffffbd) = 1073741824(40000000)\nunsigned 8 2(2) << -66(ffffffbe) = 2147483648(80000000)\nunsigned 8 2(2) << -65(ffffffbf) = 0(0)\nunsigned 8 2(2) << -64(ffffffc0) = 2(2)\nunsigned 8 2(2) << -63(ffffffc1) = 4(4)\nunsigned 8 2(2) << -62(ffffffc2) = 8(8)\nunsigned 8 2(2) << -61(ffffffc3) = 16(10)\nunsigned 8 2(2) << -60(ffffffc4) = 32(20)\nunsigned 8 2(2) << -59(ffffffc5) = 64(40)\nunsigned 8 2(2) << -58(ffffffc6) = 128(80)\nunsigned 8 2(2) << -57(ffffffc7) = 256(100)\nunsigned 8 2(2) << -56(ffffffc8) = 512(200)\nunsigned 8 2(2) << -55(ffffffc9) = 1024(400)\nunsigned 8 2(2) << -54(ffffffca) = 2048(800)\nunsigned 8 2(2) << -53(ffffffcb) = 4096(1000)\nunsigned 8 2(2) << -52(ffffffcc) = 8192(2000)\nunsigned 8 2(2) << -51(ffffffcd) = 16384(4000)\nunsigned 8 2(2) << -50(ffffffce) = 32768(8000)\nunsigned 8 2(2) << -49(ffffffcf) = 65536(10000)\nunsigned 8 2(2) << -48(ffffffd0) = 131072(20000)\nunsigned 8 2(2) << -47(ffffffd1) = 262144(40000)\nunsigned 8 2(2) << -46(ffffffd2) = 524288(80000)\nunsigned 8 2(2) << -45(ffffffd3) = 1048576(100000)\nunsigned 8 2(2) << -44(ffffffd4) = 2097152(200000)\nunsigned 8 2(2) << -43(ffffffd5) = 4194304(400000)\nunsigned 8 2(2) << -42(ffffffd6) = 8388608(800000)\nunsigned 8 2(2) << -41(ffffffd7) = 16777216(1000000)\nunsigned 8 2(2) << -40(ffffffd8) = 33554432(2000000)\nunsigned 8 2(2) << -39(ffffffd9) = 67108864(4000000)\nunsigned 8 2(2) << -38(ffffffda) = 134217728(8000000)\nunsigned 8 2(2) << -37(ffffffdb) = 268435456(10000000)\nunsigned 8 2(2) << -36(ffffffdc) = 536870912(20000000)\nunsigned 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\nunsigned 8 2(2) << -34(ffffffde) = 2147483648(80000000)\nunsigned 8 2(2) << -33(ffffffdf) = 0(0)\nunsigned 8 2(2) << -32(ffffffe0) = 2(2)\nunsigned 8 2(2) << -31(ffffffe1) = 4(4)\nunsigned 8 2(2) << -30(ffffffe2) = 8(8)\nunsigned 8 2(2) << -29(ffffffe3) = 16(10)\nunsigned 8 2(2) << -28(ffffffe4) = 32(20)\nunsigned 8 2(2) << -27(ffffffe5) = 64(40)\nunsigned 8 2(2) << -26(ffffffe6) = 128(80)\nunsigned 8 2(2) << -25(ffffffe7) = 256(100)\nunsigned 8 2(2) << -24(ffffffe8) = 512(200)\nunsigned 8 2(2) << -23(ffffffe9) = 1024(400)\nunsigned 8 2(2) << -22(ffffffea) = 2048(800)\nunsigned 8 2(2) << -21(ffffffeb) = 4096(1000)\nunsigned 8 2(2) << -20(ffffffec) = 8192(2000)\nunsigned 8 2(2) << -19(ffffffed) = 16384(4000)\nunsigned 8 2(2) << -18(ffffffee) = 32768(8000)\nunsigned 8 2(2) << -17(ffffffef) = 65536(10000)\nunsigned 8 2(2) << -16(fffffff0) = 131072(20000)\nunsigned 8 2(2) << -15(fffffff1) = 262144(40000)\nunsigned 8 2(2) << -14(fffffff2) = 524288(80000)\nunsigned 8 2(2) << -13(fffffff3) = 1048576(100000)\nunsigned 8 2(2) << -12(fffffff4) = 2097152(200000)\nunsigned 8 2(2) << -11(fffffff5) = 4194304(400000)\nunsigned 8 2(2) << -10(fffffff6) = 8388608(800000)\nunsigned 8 2(2) << -9(fffffff7) = 16777216(1000000)\nunsigned 8 2(2) << -8(fffffff8) = 33554432(2000000)\nunsigned 8 2(2) << -7(fffffff9) = 67108864(4000000)\nunsigned 8 2(2) << -6(fffffffa) = 134217728(8000000)\nunsigned 8 2(2) << -5(fffffffb) = 268435456(10000000)\nunsigned 8 2(2) << -4(fffffffc) = 536870912(20000000)\nunsigned 8 2(2) << -3(fffffffd) = 1073741824(40000000)\nunsigned 8 2(2) << -2(fffffffe) = 2147483648(80000000)\nunsigned 8 2(2) << -1(ffffffff) = 0(0)\nunsigned 8 2(2) << 0(0) = 2(2)\nunsigned 8 2(2) << 1(1) = 4(4)\nunsigned 8 2(2) << 2(2) = 8(8)\nunsigned 8 2(2) << 3(3) = 16(10)\nunsigned 8 2(2) << 4(4) = 32(20)\nunsigned 8 2(2) << 5(5) = 64(40)\nunsigned 8 2(2) << 6(6) = 128(80)\nunsigned 8 2(2) << 7(7) = 256(100)\nunsigned 8 2(2) << 8(8) = 512(200)\nunsigned 8 2(2) << 9(9) = 1024(400)\nunsigned 8 2(2) << 10(a) = 2048(800)\nunsigned 8 2(2) << 11(b) = 4096(1000)\nunsigned 8 2(2) << 12(c) = 8192(2000)\nunsigned 8 2(2) << 13(d) = 16384(4000)\nunsigned 8 2(2) << 14(e) = 32768(8000)\nunsigned 8 2(2) << 15(f) = 65536(10000)\nunsigned 8 2(2) << 16(10) = 131072(20000)\nunsigned 8 2(2) << 17(11) = 262144(40000)\nunsigned 8 2(2) << 18(12) = 524288(80000)\nunsigned 8 2(2) << 19(13) = 1048576(100000)\nunsigned 8 2(2) << 20(14) = 2097152(200000)\nunsigned 8 2(2) << 21(15) = 4194304(400000)\nunsigned 8 2(2) << 22(16) = 8388608(800000)\nunsigned 8 2(2) << 23(17) = 16777216(1000000)\nunsigned 8 2(2) << 24(18) = 33554432(2000000)\nunsigned 8 2(2) << 25(19) = 67108864(4000000)\nunsigned 8 2(2) << 26(1a) = 134217728(8000000)\nunsigned 8 2(2) << 27(1b) = 268435456(10000000)\nunsigned 8 2(2) << 28(1c) = 536870912(20000000)\nunsigned 8 2(2) << 29(1d) = 1073741824(40000000)\nunsigned 8 2(2) << 30(1e) = 2147483648(80000000)\nunsigned 8 2(2) << 31(1f) = 0(0)\nunsigned 8 2(2) << 32(20) = 2(2)\nunsigned 8 2(2) << 33(21) = 4(4)\nunsigned 8 2(2) << 34(22) = 8(8)\nunsigned 8 2(2) << 35(23) = 16(10)\nunsigned 8 2(2) << 36(24) = 32(20)\nunsigned 8 2(2) << 37(25) = 64(40)\nunsigned 8 2(2) << 38(26) = 128(80)\nunsigned 8 2(2) << 39(27) = 256(100)\nunsigned 8 2(2) << 40(28) = 512(200)\nunsigned 8 2(2) << 41(29) = 1024(400)\nunsigned 8 2(2) << 42(2a) = 2048(800)\nunsigned 8 2(2) << 43(2b) = 4096(1000)\nunsigned 8 2(2) << 44(2c) = 8192(2000)\nunsigned 8 2(2) << 45(2d) = 16384(4000)\nunsigned 8 2(2) << 46(2e) = 32768(8000)\nunsigned 8 2(2) << 47(2f) = 65536(10000)\nunsigned 8 2(2) << 48(30) = 131072(20000)\nunsigned 8 2(2) << 49(31) = 262144(40000)\nunsigned 8 2(2) << 50(32) = 524288(80000)\nunsigned 8 2(2) << 51(33) = 1048576(100000)\nunsigned 8 2(2) << 52(34) = 2097152(200000)\nunsigned 8 2(2) << 53(35) = 4194304(400000)\nunsigned 8 2(2) << 54(36) = 8388608(800000)\nunsigned 8 2(2) << 55(37) = 16777216(1000000)\nunsigned 8 2(2) << 56(38) = 33554432(2000000)\nunsigned 8 2(2) << 57(39) = 67108864(4000000)\nunsigned 8 2(2) << 58(3a) = 134217728(8000000)\nunsigned 8 2(2) << 59(3b) = 268435456(10000000)\nunsigned 8 2(2) << 60(3c) = 536870912(20000000)\nunsigned 8 2(2) << 61(3d) = 1073741824(40000000)\nunsigned 8 2(2) << 62(3e) = 2147483648(80000000)\nunsigned 8 2(2) << 63(3f) = 0(0)\nunsigned 8 2(2) << 64(40) = 2(2)\nunsigned 8 2(2) << 65(41) = 4(4)\nunsigned 8 2(2) << 66(42) = 8(8)\nunsigned 8 2(2) << 67(43) = 16(10)\nunsigned 8 2(2) << 68(44) = 32(20)\nunsigned 8 2(2) << 69(45) = 64(40)\nunsigned 8 2(2) << 70(46) = 128(80)\nunsigned 8 2(2) << 71(47) = 256(100)\nunsigned 8 2(2) << 72(48) = 512(200)\nunsigned 8 2(2) << 73(49) = 1024(400)\nunsigned 8 2(2) << 74(4a) = 2048(800)\nunsigned 8 2(2) << 75(4b) = 4096(1000)\nunsigned 8 2(2) << 76(4c) = 8192(2000)\nunsigned 8 2(2) << 77(4d) = 16384(4000)\nunsigned 8 2(2) << 78(4e) = 32768(8000)\nunsigned 8 2(2) << 79(4f) = 65536(10000)\nunsigned 8 2(2) << 80(50) = 131072(20000)\nunsigned 8 2(2) << 81(51) = 262144(40000)\nunsigned 8 2(2) << 82(52) = 524288(80000)\nunsigned 8 2(2) << 83(53) = 1048576(100000)\nunsigned 8 2(2) << 84(54) = 2097152(200000)\nunsigned 8 2(2) << 85(55) = 4194304(400000)\nunsigned 8 2(2) << 86(56) = 8388608(800000)\nunsigned 8 2(2) << 87(57) = 16777216(1000000)\nunsigned 8 2(2) << 88(58) = 33554432(2000000)\nunsigned 8 2(2) << 89(59) = 67108864(4000000)\nunsigned 8 2(2) << 90(5a) = 134217728(8000000)\nunsigned 8 2(2) << 91(5b) = 268435456(10000000)\nunsigned 8 2(2) << 92(5c) = 536870912(20000000)\nunsigned 8 2(2) << 93(5d) = 1073741824(40000000)\nunsigned 8 2(2) << 94(5e) = 2147483648(80000000)\nunsigned 8 2(2) << 95(5f) = 0(0)\nunsigned 8 2(2) << 96(60) = 2(2)\nunsigned 8 2(2) << 97(61) = 4(4)\nunsigned 8 2(2) << 98(62) = 8(8)\nunsigned 8 2(2) << 99(63) = 16(10)\nunsigned 8 2(2) << 100(64) = 32(20)\nunsigned 8 2(2) << 101(65) = 64(40)\nunsigned 8 2(2) << 102(66) = 128(80)\nunsigned 8 2(2) << 103(67) = 256(100)\nunsigned 8 2(2) << 104(68) = 512(200)\nunsigned 8 2(2) << 105(69) = 1024(400)\nunsigned 8 2(2) << 106(6a) = 2048(800)\nunsigned 8 2(2) << 107(6b) = 4096(1000)\nunsigned 8 2(2) << 108(6c) = 8192(2000)\nunsigned 8 2(2) << 109(6d) = 16384(4000)\nunsigned 8 2(2) << 110(6e) = 32768(8000)\nunsigned 8 2(2) << 111(6f) = 65536(10000)\nunsigned 8 2(2) << 112(70) = 131072(20000)\nunsigned 8 2(2) << 113(71) = 262144(40000)\nunsigned 8 2(2) << 114(72) = 524288(80000)\nunsigned 8 2(2) << 115(73) = 1048576(100000)\nunsigned 8 2(2) << 116(74) = 2097152(200000)\nunsigned 8 2(2) << 117(75) = 4194304(400000)\nunsigned 8 2(2) << 118(76) = 8388608(800000)\nunsigned 8 2(2) << 119(77) = 16777216(1000000)\nunsigned 8 2(2) << 120(78) = 33554432(2000000)\nunsigned 8 2(2) << 121(79) = 67108864(4000000)\nunsigned 8 2(2) << 122(7a) = 134217728(8000000)\nunsigned 8 2(2) << 123(7b) = 268435456(10000000)\nunsigned 8 2(2) << 124(7c) = 536870912(20000000)\nunsigned 8 2(2) << 125(7d) = 1073741824(40000000)\nunsigned 8 2(2) << 126(7e) = 2147483648(80000000)\nunsigned 8 2(2) << 127(7f) = 0(0)\nunsigned 8 3(3) << -128(ffffff80) = 3(3)\nunsigned 8 3(3) << -127(ffffff81) = 6(6)\nunsigned 8 3(3) << -126(ffffff82) = 12(c)\nunsigned 8 3(3) << -125(ffffff83) = 24(18)\nunsigned 8 3(3) << -124(ffffff84) = 48(30)\nunsigned 8 3(3) << -123(ffffff85) = 96(60)\nunsigned 8 3(3) << -122(ffffff86) = 192(c0)\nunsigned 8 3(3) << -121(ffffff87) = 384(180)\nunsigned 8 3(3) << -120(ffffff88) = 768(300)\nunsigned 8 3(3) << -119(ffffff89) = 1536(600)\nunsigned 8 3(3) << -118(ffffff8a) = 3072(c00)\nunsigned 8 3(3) << -117(ffffff8b) = 6144(1800)\nunsigned 8 3(3) << -116(ffffff8c) = 12288(3000)\nunsigned 8 3(3) << -115(ffffff8d) = 24576(6000)\nunsigned 8 3(3) << -114(ffffff8e) = 49152(c000)\nunsigned 8 3(3) << -113(ffffff8f) = 98304(18000)\nunsigned 8 3(3) << -112(ffffff90) = 196608(30000)\nunsigned 8 3(3) << -111(ffffff91) = 393216(60000)\nunsigned 8 3(3) << -110(ffffff92) = 786432(c0000)\nunsigned 8 3(3) << -109(ffffff93) = 1572864(180000)\nunsigned 8 3(3) << -108(ffffff94) = 3145728(300000)\nunsigned 8 3(3) << -107(ffffff95) = 6291456(600000)\nunsigned 8 3(3) << -106(ffffff96) = 12582912(c00000)\nunsigned 8 3(3) << -105(ffffff97) = 25165824(1800000)\nunsigned 8 3(3) << -104(ffffff98) = 50331648(3000000)\nunsigned 8 3(3) << -103(ffffff99) = 100663296(6000000)\nunsigned 8 3(3) << -102(ffffff9a) = 201326592(c000000)\nunsigned 8 3(3) << -101(ffffff9b) = 402653184(18000000)\nunsigned 8 3(3) << -100(ffffff9c) = 805306368(30000000)\nunsigned 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\nunsigned 8 3(3) << -98(ffffff9e) = 3221225472(c0000000)\nunsigned 8 3(3) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 3(3) << -96(ffffffa0) = 3(3)\nunsigned 8 3(3) << -95(ffffffa1) = 6(6)\nunsigned 8 3(3) << -94(ffffffa2) = 12(c)\nunsigned 8 3(3) << -93(ffffffa3) = 24(18)\nunsigned 8 3(3) << -92(ffffffa4) = 48(30)\nunsigned 8 3(3) << -91(ffffffa5) = 96(60)\nunsigned 8 3(3) << -90(ffffffa6) = 192(c0)\nunsigned 8 3(3) << -89(ffffffa7) = 384(180)\nunsigned 8 3(3) << -88(ffffffa8) = 768(300)\nunsigned 8 3(3) << -87(ffffffa9) = 1536(600)\nunsigned 8 3(3) << -86(ffffffaa) = 3072(c00)\nunsigned 8 3(3) << -85(ffffffab) = 6144(1800)\nunsigned 8 3(3) << -84(ffffffac) = 12288(3000)\nunsigned 8 3(3) << -83(ffffffad) = 24576(6000)\nunsigned 8 3(3) << -82(ffffffae) = 49152(c000)\nunsigned 8 3(3) << -81(ffffffaf) = 98304(18000)\nunsigned 8 3(3) << -80(ffffffb0) = 196608(30000)\nunsigned 8 3(3) << -79(ffffffb1) = 393216(60000)\nunsigned 8 3(3) << -78(ffffffb2) = 786432(c0000)\nunsigned 8 3(3) << -77(ffffffb3) = 1572864(180000)\nunsigned 8 3(3) << -76(ffffffb4) = 3145728(300000)\nunsigned 8 3(3) << -75(ffffffb5) = 6291456(600000)\nunsigned 8 3(3) << -74(ffffffb6) = 12582912(c00000)\nunsigned 8 3(3) << -73(ffffffb7) = 25165824(1800000)\nunsigned 8 3(3) << -72(ffffffb8) = 50331648(3000000)\nunsigned 8 3(3) << -71(ffffffb9) = 100663296(6000000)\nunsigned 8 3(3) << -70(ffffffba) = 201326592(c000000)\nunsigned 8 3(3) << -69(ffffffbb) = 402653184(18000000)\nunsigned 8 3(3) << -68(ffffffbc) = 805306368(30000000)\nunsigned 8 3(3) << -67(ffffffbd) = 1610612736(60000000)\nunsigned 8 3(3) << -66(ffffffbe) = 3221225472(c0000000)\nunsigned 8 3(3) << -65(ffffffbf) = 2147483648(80000000)\nunsigned 8 3(3) << -64(ffffffc0) = 3(3)\nunsigned 8 3(3) << -63(ffffffc1) = 6(6)\nunsigned 8 3(3) << -62(ffffffc2) = 12(c)\nunsigned 8 3(3) << -61(ffffffc3) = 24(18)\nunsigned 8 3(3) << -60(ffffffc4) = 48(30)\nunsigned 8 3(3) << -59(ffffffc5) = 96(60)\nunsigned 8 3(3) << -58(ffffffc6) = 192(c0)\nunsigned 8 3(3) << -57(ffffffc7) = 384(180)\nunsigned 8 3(3) << -56(ffffffc8) = 768(300)\nunsigned 8 3(3) << -55(ffffffc9) = 1536(600)\nunsigned 8 3(3) << -54(ffffffca) = 3072(c00)\nunsigned 8 3(3) << -53(ffffffcb) = 6144(1800)\nunsigned 8 3(3) << -52(ffffffcc) = 12288(3000)\nunsigned 8 3(3) << -51(ffffffcd) = 24576(6000)\nunsigned 8 3(3) << -50(ffffffce) = 49152(c000)\nunsigned 8 3(3) << -49(ffffffcf) = 98304(18000)\nunsigned 8 3(3) << -48(ffffffd0) = 196608(30000)\nunsigned 8 3(3) << -47(ffffffd1) = 393216(60000)\nunsigned 8 3(3) << -46(ffffffd2) = 786432(c0000)\nunsigned 8 3(3) << -45(ffffffd3) = 1572864(180000)\nunsigned 8 3(3) << -44(ffffffd4) = 3145728(300000)\nunsigned 8 3(3) << -43(ffffffd5) = 6291456(600000)\nunsigned 8 3(3) << -42(ffffffd6) = 12582912(c00000)\nunsigned 8 3(3) << -41(ffffffd7) = 25165824(1800000)\nunsigned 8 3(3) << -40(ffffffd8) = 50331648(3000000)\nunsigned 8 3(3) << -39(ffffffd9) = 100663296(6000000)\nunsigned 8 3(3) << -38(ffffffda) = 201326592(c000000)\nunsigned 8 3(3) << -37(ffffffdb) = 402653184(18000000)\nunsigned 8 3(3) << -36(ffffffdc) = 805306368(30000000)\nunsigned 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\nunsigned 8 3(3) << -34(ffffffde) = 3221225472(c0000000)\nunsigned 8 3(3) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 3(3) << -32(ffffffe0) = 3(3)\nunsigned 8 3(3) << -31(ffffffe1) = 6(6)\nunsigned 8 3(3) << -30(ffffffe2) = 12(c)\nunsigned 8 3(3) << -29(ffffffe3) = 24(18)\nunsigned 8 3(3) << -28(ffffffe4) = 48(30)\nunsigned 8 3(3) << -27(ffffffe5) = 96(60)\nunsigned 8 3(3) << -26(ffffffe6) = 192(c0)\nunsigned 8 3(3) << -25(ffffffe7) = 384(180)\nunsigned 8 3(3) << -24(ffffffe8) = 768(300)\nunsigned 8 3(3) << -23(ffffffe9) = 1536(600)\nunsigned 8 3(3) << -22(ffffffea) = 3072(c00)\nunsigned 8 3(3) << -21(ffffffeb) = 6144(1800)\nunsigned 8 3(3) << -20(ffffffec) = 12288(3000)\nunsigned 8 3(3) << -19(ffffffed) = 24576(6000)\nunsigned 8 3(3) << -18(ffffffee) = 49152(c000)\nunsigned 8 3(3) << -17(ffffffef) = 98304(18000)\nunsigned 8 3(3) << -16(fffffff0) = 196608(30000)\nunsigned 8 3(3) << -15(fffffff1) = 393216(60000)\nunsigned 8 3(3) << -14(fffffff2) = 786432(c0000)\nunsigned 8 3(3) << -13(fffffff3) = 1572864(180000)\nunsigned 8 3(3) << -12(fffffff4) = 3145728(300000)\nunsigned 8 3(3) << -11(fffffff5) = 6291456(600000)\nunsigned 8 3(3) << -10(fffffff6) = 12582912(c00000)\nunsigned 8 3(3) << -9(fffffff7) = 25165824(1800000)\nunsigned 8 3(3) << -8(fffffff8) = 50331648(3000000)\nunsigned 8 3(3) << -7(fffffff9) = 100663296(6000000)\nunsigned 8 3(3) << -6(fffffffa) = 201326592(c000000)\nunsigned 8 3(3) << -5(fffffffb) = 402653184(18000000)\nunsigned 8 3(3) << -4(fffffffc) = 805306368(30000000)\nunsigned 8 3(3) << -3(fffffffd) = 1610612736(60000000)\nunsigned 8 3(3) << -2(fffffffe) = 3221225472(c0000000)\nunsigned 8 3(3) << -1(ffffffff) = 2147483648(80000000)\nunsigned 8 3(3) << 0(0) = 3(3)\nunsigned 8 3(3) << 1(1) = 6(6)\nunsigned 8 3(3) << 2(2) = 12(c)\nunsigned 8 3(3) << 3(3) = 24(18)\nunsigned 8 3(3) << 4(4) = 48(30)\nunsigned 8 3(3) << 5(5) = 96(60)\nunsigned 8 3(3) << 6(6) = 192(c0)\nunsigned 8 3(3) << 7(7) = 384(180)\nunsigned 8 3(3) << 8(8) = 768(300)\nunsigned 8 3(3) << 9(9) = 1536(600)\nunsigned 8 3(3) << 10(a) = 3072(c00)\nunsigned 8 3(3) << 11(b) = 6144(1800)\nunsigned 8 3(3) << 12(c) = 12288(3000)\nunsigned 8 3(3) << 13(d) = 24576(6000)\nunsigned 8 3(3) << 14(e) = 49152(c000)\nunsigned 8 3(3) << 15(f) = 98304(18000)\nunsigned 8 3(3) << 16(10) = 196608(30000)\nunsigned 8 3(3) << 17(11) = 393216(60000)\nunsigned 8 3(3) << 18(12) = 786432(c0000)\nunsigned 8 3(3) << 19(13) = 1572864(180000)\nunsigned 8 3(3) << 20(14) = 3145728(300000)\nunsigned 8 3(3) << 21(15) = 6291456(600000)\nunsigned 8 3(3) << 22(16) = 12582912(c00000)\nunsigned 8 3(3) << 23(17) = 25165824(1800000)\nunsigned 8 3(3) << 24(18) = 50331648(3000000)\nunsigned 8 3(3) << 25(19) = 100663296(6000000)\nunsigned 8 3(3) << 26(1a) = 201326592(c000000)\nunsigned 8 3(3) << 27(1b) = 402653184(18000000)\nunsigned 8 3(3) << 28(1c) = 805306368(30000000)\nunsigned 8 3(3) << 29(1d) = 1610612736(60000000)\nunsigned 8 3(3) << 30(1e) = 3221225472(c0000000)\nunsigned 8 3(3) << 31(1f) = 2147483648(80000000)\nunsigned 8 3(3) << 32(20) = 3(3)\nunsigned 8 3(3) << 33(21) = 6(6)\nunsigned 8 3(3) << 34(22) = 12(c)\nunsigned 8 3(3) << 35(23) = 24(18)\nunsigned 8 3(3) << 36(24) = 48(30)\nunsigned 8 3(3) << 37(25) = 96(60)\nunsigned 8 3(3) << 38(26) = 192(c0)\nunsigned 8 3(3) << 39(27) = 384(180)\nunsigned 8 3(3) << 40(28) = 768(300)\nunsigned 8 3(3) << 41(29) = 1536(600)\nunsigned 8 3(3) << 42(2a) = 3072(c00)\nunsigned 8 3(3) << 43(2b) = 6144(1800)\nunsigned 8 3(3) << 44(2c) = 12288(3000)\nunsigned 8 3(3) << 45(2d) = 24576(6000)\nunsigned 8 3(3) << 46(2e) = 49152(c000)\nunsigned 8 3(3) << 47(2f) = 98304(18000)\nunsigned 8 3(3) << 48(30) = 196608(30000)\nunsigned 8 3(3) << 49(31) = 393216(60000)\nunsigned 8 3(3) << 50(32) = 786432(c0000)\nunsigned 8 3(3) << 51(33) = 1572864(180000)\nunsigned 8 3(3) << 52(34) = 3145728(300000)\nunsigned 8 3(3) << 53(35) = 6291456(600000)\nunsigned 8 3(3) << 54(36) = 12582912(c00000)\nunsigned 8 3(3) << 55(37) = 25165824(1800000)\nunsigned 8 3(3) << 56(38) = 50331648(3000000)\nunsigned 8 3(3) << 57(39) = 100663296(6000000)\nunsigned 8 3(3) << 58(3a) = 201326592(c000000)\nunsigned 8 3(3) << 59(3b) = 402653184(18000000)\nunsigned 8 3(3) << 60(3c) = 805306368(30000000)\nunsigned 8 3(3) << 61(3d) = 1610612736(60000000)\nunsigned 8 3(3) << 62(3e) = 3221225472(c0000000)\nunsigned 8 3(3) << 63(3f) = 2147483648(80000000)\nunsigned 8 3(3) << 64(40) = 3(3)\nunsigned 8 3(3) << 65(41) = 6(6)\nunsigned 8 3(3) << 66(42) = 12(c)\nunsigned 8 3(3) << 67(43) = 24(18)\nunsigned 8 3(3) << 68(44) = 48(30)\nunsigned 8 3(3) << 69(45) = 96(60)\nunsigned 8 3(3) << 70(46) = 192(c0)\nunsigned 8 3(3) << 71(47) = 384(180)\nunsigned 8 3(3) << 72(48) = 768(300)\nunsigned 8 3(3) << 73(49) = 1536(600)\nunsigned 8 3(3) << 74(4a) = 3072(c00)\nunsigned 8 3(3) << 75(4b) = 6144(1800)\nunsigned 8 3(3) << 76(4c) = 12288(3000)\nunsigned 8 3(3) << 77(4d) = 24576(6000)\nunsigned 8 3(3) << 78(4e) = 49152(c000)\nunsigned 8 3(3) << 79(4f) = 98304(18000)\nunsigned 8 3(3) << 80(50) = 196608(30000)\nunsigned 8 3(3) << 81(51) = 393216(60000)\nunsigned 8 3(3) << 82(52) = 786432(c0000)\nunsigned 8 3(3) << 83(53) = 1572864(180000)\nunsigned 8 3(3) << 84(54) = 3145728(300000)\nunsigned 8 3(3) << 85(55) = 6291456(600000)\nunsigned 8 3(3) << 86(56) = 12582912(c00000)\nunsigned 8 3(3) << 87(57) = 25165824(1800000)\nunsigned 8 3(3) << 88(58) = 50331648(3000000)\nunsigned 8 3(3) << 89(59) = 100663296(6000000)\nunsigned 8 3(3) << 90(5a) = 201326592(c000000)\nunsigned 8 3(3) << 91(5b) = 402653184(18000000)\nunsigned 8 3(3) << 92(5c) = 805306368(30000000)\nunsigned 8 3(3) << 93(5d) = 1610612736(60000000)\nunsigned 8 3(3) << 94(5e) = 3221225472(c0000000)\nunsigned 8 3(3) << 95(5f) = 2147483648(80000000)\nunsigned 8 3(3) << 96(60) = 3(3)\nunsigned 8 3(3) << 97(61) = 6(6)\nunsigned 8 3(3) << 98(62) = 12(c)\nunsigned 8 3(3) << 99(63) = 24(18)\nunsigned 8 3(3) << 100(64) = 48(30)\nunsigned 8 3(3) << 101(65) = 96(60)\nunsigned 8 3(3) << 102(66) = 192(c0)\nunsigned 8 3(3) << 103(67) = 384(180)\nunsigned 8 3(3) << 104(68) = 768(300)\nunsigned 8 3(3) << 105(69) = 1536(600)\nunsigned 8 3(3) << 106(6a) = 3072(c00)\nunsigned 8 3(3) << 107(6b) = 6144(1800)\nunsigned 8 3(3) << 108(6c) = 12288(3000)\nunsigned 8 3(3) << 109(6d) = 24576(6000)\nunsigned 8 3(3) << 110(6e) = 49152(c000)\nunsigned 8 3(3) << 111(6f) = 98304(18000)\nunsigned 8 3(3) << 112(70) = 196608(30000)\nunsigned 8 3(3) << 113(71) = 393216(60000)\nunsigned 8 3(3) << 114(72) = 786432(c0000)\nunsigned 8 3(3) << 115(73) = 1572864(180000)\nunsigned 8 3(3) << 116(74) = 3145728(300000)\nunsigned 8 3(3) << 117(75) = 6291456(600000)\nunsigned 8 3(3) << 118(76) = 12582912(c00000)\nunsigned 8 3(3) << 119(77) = 25165824(1800000)\nunsigned 8 3(3) << 120(78) = 50331648(3000000)\nunsigned 8 3(3) << 121(79) = 100663296(6000000)\nunsigned 8 3(3) << 122(7a) = 201326592(c000000)\nunsigned 8 3(3) << 123(7b) = 402653184(18000000)\nunsigned 8 3(3) << 124(7c) = 805306368(30000000)\nunsigned 8 3(3) << 125(7d) = 1610612736(60000000)\nunsigned 8 3(3) << 126(7e) = 3221225472(c0000000)\nunsigned 8 3(3) << 127(7f) = 2147483648(80000000)\nunsigned 8 4(4) << -128(ffffff80) = 4(4)\nunsigned 8 4(4) << -127(ffffff81) = 8(8)\nunsigned 8 4(4) << -126(ffffff82) = 16(10)\nunsigned 8 4(4) << -125(ffffff83) = 32(20)\nunsigned 8 4(4) << -124(ffffff84) = 64(40)\nunsigned 8 4(4) << -123(ffffff85) = 128(80)\nunsigned 8 4(4) << -122(ffffff86) = 256(100)\nunsigned 8 4(4) << -121(ffffff87) = 512(200)\nunsigned 8 4(4) << -120(ffffff88) = 1024(400)\nunsigned 8 4(4) << -119(ffffff89) = 2048(800)\nunsigned 8 4(4) << -118(ffffff8a) = 4096(1000)\nunsigned 8 4(4) << -117(ffffff8b) = 8192(2000)\nunsigned 8 4(4) << -116(ffffff8c) = 16384(4000)\nunsigned 8 4(4) << -115(ffffff8d) = 32768(8000)\nunsigned 8 4(4) << -114(ffffff8e) = 65536(10000)\nunsigned 8 4(4) << -113(ffffff8f) = 131072(20000)\nunsigned 8 4(4) << -112(ffffff90) = 262144(40000)\nunsigned 8 4(4) << -111(ffffff91) = 524288(80000)\nunsigned 8 4(4) << -110(ffffff92) = 1048576(100000)\nunsigned 8 4(4) << -109(ffffff93) = 2097152(200000)\nunsigned 8 4(4) << -108(ffffff94) = 4194304(400000)\nunsigned 8 4(4) << -107(ffffff95) = 8388608(800000)\nunsigned 8 4(4) << -106(ffffff96) = 16777216(1000000)\nunsigned 8 4(4) << -105(ffffff97) = 33554432(2000000)\nunsigned 8 4(4) << -104(ffffff98) = 67108864(4000000)\nunsigned 8 4(4) << -103(ffffff99) = 134217728(8000000)\nunsigned 8 4(4) << -102(ffffff9a) = 268435456(10000000)\nunsigned 8 4(4) << -101(ffffff9b) = 536870912(20000000)\nunsigned 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\nunsigned 8 4(4) << -99(ffffff9d) = 2147483648(80000000)\nunsigned 8 4(4) << -98(ffffff9e) = 0(0)\nunsigned 8 4(4) << -97(ffffff9f) = 0(0)\nunsigned 8 4(4) << -96(ffffffa0) = 4(4)\nunsigned 8 4(4) << -95(ffffffa1) = 8(8)\nunsigned 8 4(4) << -94(ffffffa2) = 16(10)\nunsigned 8 4(4) << -93(ffffffa3) = 32(20)\nunsigned 8 4(4) << -92(ffffffa4) = 64(40)\nunsigned 8 4(4) << -91(ffffffa5) = 128(80)\nunsigned 8 4(4) << -90(ffffffa6) = 256(100)\nunsigned 8 4(4) << -89(ffffffa7) = 512(200)\nunsigned 8 4(4) << -88(ffffffa8) = 1024(400)\nunsigned 8 4(4) << -87(ffffffa9) = 2048(800)\nunsigned 8 4(4) << -86(ffffffaa) = 4096(1000)\nunsigned 8 4(4) << -85(ffffffab) = 8192(2000)\nunsigned 8 4(4) << -84(ffffffac) = 16384(4000)\nunsigned 8 4(4) << -83(ffffffad) = 32768(8000)\nunsigned 8 4(4) << -82(ffffffae) = 65536(10000)\nunsigned 8 4(4) << -81(ffffffaf) = 131072(20000)\nunsigned 8 4(4) << -80(ffffffb0) = 262144(40000)\nunsigned 8 4(4) << -79(ffffffb1) = 524288(80000)\nunsigned 8 4(4) << -78(ffffffb2) = 1048576(100000)\nunsigned 8 4(4) << -77(ffffffb3) = 2097152(200000)\nunsigned 8 4(4) << -76(ffffffb4) = 4194304(400000)\nunsigned 8 4(4) << -75(ffffffb5) = 8388608(800000)\nunsigned 8 4(4) << -74(ffffffb6) = 16777216(1000000)\nunsigned 8 4(4) << -73(ffffffb7) = 33554432(2000000)\nunsigned 8 4(4) << -72(ffffffb8) = 67108864(4000000)\nunsigned 8 4(4) << -71(ffffffb9) = 134217728(8000000)\nunsigned 8 4(4) << -70(ffffffba) = 268435456(10000000)\nunsigned 8 4(4) << -69(ffffffbb) = 536870912(20000000)\nunsigned 8 4(4) << -68(ffffffbc) = 1073741824(40000000)\nunsigned 8 4(4) << -67(ffffffbd) = 2147483648(80000000)\nunsigned 8 4(4) << -66(ffffffbe) = 0(0)\nunsigned 8 4(4) << -65(ffffffbf) = 0(0)\nunsigned 8 4(4) << -64(ffffffc0) = 4(4)\nunsigned 8 4(4) << -63(ffffffc1) = 8(8)\nunsigned 8 4(4) << -62(ffffffc2) = 16(10)\nunsigned 8 4(4) << -61(ffffffc3) = 32(20)\nunsigned 8 4(4) << -60(ffffffc4) = 64(40)\nunsigned 8 4(4) << -59(ffffffc5) = 128(80)\nunsigned 8 4(4) << -58(ffffffc6) = 256(100)\nunsigned 8 4(4) << -57(ffffffc7) = 512(200)\nunsigned 8 4(4) << -56(ffffffc8) = 1024(400)\nunsigned 8 4(4) << -55(ffffffc9) = 2048(800)\nunsigned 8 4(4) << -54(ffffffca) = 4096(1000)\nunsigned 8 4(4) << -53(ffffffcb) = 8192(2000)\nunsigned 8 4(4) << -52(ffffffcc) = 16384(4000)\nunsigned 8 4(4) << -51(ffffffcd) = 32768(8000)\nunsigned 8 4(4) << -50(ffffffce) = 65536(10000)\nunsigned 8 4(4) << -49(ffffffcf) = 131072(20000)\nunsigned 8 4(4) << -48(ffffffd0) = 262144(40000)\nunsigned 8 4(4) << -47(ffffffd1) = 524288(80000)\nunsigned 8 4(4) << -46(ffffffd2) = 1048576(100000)\nunsigned 8 4(4) << -45(ffffffd3) = 2097152(200000)\nunsigned 8 4(4) << -44(ffffffd4) = 4194304(400000)\nunsigned 8 4(4) << -43(ffffffd5) = 8388608(800000)\nunsigned 8 4(4) << -42(ffffffd6) = 16777216(1000000)\nunsigned 8 4(4) << -41(ffffffd7) = 33554432(2000000)\nunsigned 8 4(4) << -40(ffffffd8) = 67108864(4000000)\nunsigned 8 4(4) << -39(ffffffd9) = 134217728(8000000)\nunsigned 8 4(4) << -38(ffffffda) = 268435456(10000000)\nunsigned 8 4(4) << -37(ffffffdb) = 536870912(20000000)\nunsigned 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\nunsigned 8 4(4) << -35(ffffffdd) = 2147483648(80000000)\nunsigned 8 4(4) << -34(ffffffde) = 0(0)\nunsigned 8 4(4) << -33(ffffffdf) = 0(0)\nunsigned 8 4(4) << -32(ffffffe0) = 4(4)\nunsigned 8 4(4) << -31(ffffffe1) = 8(8)\nunsigned 8 4(4) << -30(ffffffe2) = 16(10)\nunsigned 8 4(4) << -29(ffffffe3) = 32(20)\nunsigned 8 4(4) << -28(ffffffe4) = 64(40)\nunsigned 8 4(4) << -27(ffffffe5) = 128(80)\nunsigned 8 4(4) << -26(ffffffe6) = 256(100)\nunsigned 8 4(4) << -25(ffffffe7) = 512(200)\nunsigned 8 4(4) << -24(ffffffe8) = 1024(400)\nunsigned 8 4(4) << -23(ffffffe9) = 2048(800)\nunsigned 8 4(4) << -22(ffffffea) = 4096(1000)\nunsigned 8 4(4) << -21(ffffffeb) = 8192(2000)\nunsigned 8 4(4) << -20(ffffffec) = 16384(4000)\nunsigned 8 4(4) << -19(ffffffed) = 32768(8000)\nunsigned 8 4(4) << -18(ffffffee) = 65536(10000)\nunsigned 8 4(4) << -17(ffffffef) = 131072(20000)\nunsigned 8 4(4) << -16(fffffff0) = 262144(40000)\nunsigned 8 4(4) << -15(fffffff1) = 524288(80000)\nunsigned 8 4(4) << -14(fffffff2) = 1048576(100000)\nunsigned 8 4(4) << -13(fffffff3) = 2097152(200000)\nunsigned 8 4(4) << -12(fffffff4) = 4194304(400000)\nunsigned 8 4(4) << -11(fffffff5) = 8388608(800000)\nunsigned 8 4(4) << -10(fffffff6) = 16777216(1000000)\nunsigned 8 4(4) << -9(fffffff7) = 33554432(2000000)\nunsigned 8 4(4) << -8(fffffff8) = 67108864(4000000)\nunsigned 8 4(4) << -7(fffffff9) = 134217728(8000000)\nunsigned 8 4(4) << -6(fffffffa) = 268435456(10000000)\nunsigned 8 4(4) << -5(fffffffb) = 536870912(20000000)\nunsigned 8 4(4) << -4(fffffffc) = 1073741824(40000000)\nunsigned 8 4(4) << -3(fffffffd) = 2147483648(80000000)\nunsigned 8 4(4) << -2(fffffffe) = 0(0)\nunsigned 8 4(4) << -1(ffffffff) = 0(0)\nunsigned 8 4(4) << 0(0) = 4(4)\nunsigned 8 4(4) << 1(1) = 8(8)\nunsigned 8 4(4) << 2(2) = 16(10)\nunsigned 8 4(4) << 3(3) = 32(20)\nunsigned 8 4(4) << 4(4) = 64(40)\nunsigned 8 4(4) << 5(5) = 128(80)\nunsigned 8 4(4) << 6(6) = 256(100)\nunsigned 8 4(4) << 7(7) = 512(200)\nunsigned 8 4(4) << 8(8) = 1024(400)\nunsigned 8 4(4) << 9(9) = 2048(800)\nunsigned 8 4(4) << 10(a) = 4096(1000)\nunsigned 8 4(4) << 11(b) = 8192(2000)\nunsigned 8 4(4) << 12(c) = 16384(4000)\nunsigned 8 4(4) << 13(d) = 32768(8000)\nunsigned 8 4(4) << 14(e) = 65536(10000)\nunsigned 8 4(4) << 15(f) = 131072(20000)\nunsigned 8 4(4) << 16(10) = 262144(40000)\nunsigned 8 4(4) << 17(11) = 524288(80000)\nunsigned 8 4(4) << 18(12) = 1048576(100000)\nunsigned 8 4(4) << 19(13) = 2097152(200000)\nunsigned 8 4(4) << 20(14) = 4194304(400000)\nunsigned 8 4(4) << 21(15) = 8388608(800000)\nunsigned 8 4(4) << 22(16) = 16777216(1000000)\nunsigned 8 4(4) << 23(17) = 33554432(2000000)\nunsigned 8 4(4) << 24(18) = 67108864(4000000)\nunsigned 8 4(4) << 25(19) = 134217728(8000000)\nunsigned 8 4(4) << 26(1a) = 268435456(10000000)\nunsigned 8 4(4) << 27(1b) = 536870912(20000000)\nunsigned 8 4(4) << 28(1c) = 1073741824(40000000)\nunsigned 8 4(4) << 29(1d) = 2147483648(80000000)\nunsigned 8 4(4) << 30(1e) = 0(0)\nunsigned 8 4(4) << 31(1f) = 0(0)\nunsigned 8 4(4) << 32(20) = 4(4)\nunsigned 8 4(4) << 33(21) = 8(8)\nunsigned 8 4(4) << 34(22) = 16(10)\nunsigned 8 4(4) << 35(23) = 32(20)\nunsigned 8 4(4) << 36(24) = 64(40)\nunsigned 8 4(4) << 37(25) = 128(80)\nunsigned 8 4(4) << 38(26) = 256(100)\nunsigned 8 4(4) << 39(27) = 512(200)\nunsigned 8 4(4) << 40(28) = 1024(400)\nunsigned 8 4(4) << 41(29) = 2048(800)\nunsigned 8 4(4) << 42(2a) = 4096(1000)\nunsigned 8 4(4) << 43(2b) = 8192(2000)\nunsigned 8 4(4) << 44(2c) = 16384(4000)\nunsigned 8 4(4) << 45(2d) = 32768(8000)\nunsigned 8 4(4) << 46(2e) = 65536(10000)\nunsigned 8 4(4) << 47(2f) = 131072(20000)\nunsigned 8 4(4) << 48(30) = 262144(40000)\nunsigned 8 4(4) << 49(31) = 524288(80000)\nunsigned 8 4(4) << 50(32) = 1048576(100000)\nunsigned 8 4(4) << 51(33) = 2097152(200000)\nunsigned 8 4(4) << 52(34) = 4194304(400000)\nunsigned 8 4(4) << 53(35) = 8388608(800000)\nunsigned 8 4(4) << 54(36) = 16777216(1000000)\nunsigned 8 4(4) << 55(37) = 33554432(2000000)\nunsigned 8 4(4) << 56(38) = 67108864(4000000)\nunsigned 8 4(4) << 57(39) = 134217728(8000000)\nunsigned 8 4(4) << 58(3a) = 268435456(10000000)\nunsigned 8 4(4) << 59(3b) = 536870912(20000000)\nunsigned 8 4(4) << 60(3c) = 1073741824(40000000)\nunsigned 8 4(4) << 61(3d) = 2147483648(80000000)\nunsigned 8 4(4) << 62(3e) = 0(0)\nunsigned 8 4(4) << 63(3f) = 0(0)\nunsigned 8 4(4) << 64(40) = 4(4)\nunsigned 8 4(4) << 65(41) = 8(8)\nunsigned 8 4(4) << 66(42) = 16(10)\nunsigned 8 4(4) << 67(43) = 32(20)\nunsigned 8 4(4) << 68(44) = 64(40)\nunsigned 8 4(4) << 69(45) = 128(80)\nunsigned 8 4(4) << 70(46) = 256(100)\nunsigned 8 4(4) << 71(47) = 512(200)\nunsigned 8 4(4) << 72(48) = 1024(400)\nunsigned 8 4(4) << 73(49) = 2048(800)\nunsigned 8 4(4) << 74(4a) = 4096(1000)\nunsigned 8 4(4) << 75(4b) = 8192(2000)\nunsigned 8 4(4) << 76(4c) = 16384(4000)\nunsigned 8 4(4) << 77(4d) = 32768(8000)\nunsigned 8 4(4) << 78(4e) = 65536(10000)\nunsigned 8 4(4) << 79(4f) = 131072(20000)\nunsigned 8 4(4) << 80(50) = 262144(40000)\nunsigned 8 4(4) << 81(51) = 524288(80000)\nunsigned 8 4(4) << 82(52) = 1048576(100000)\nunsigned 8 4(4) << 83(53) = 2097152(200000)\nunsigned 8 4(4) << 84(54) = 4194304(400000)\nunsigned 8 4(4) << 85(55) = 8388608(800000)\nunsigned 8 4(4) << 86(56) = 16777216(1000000)\nunsigned 8 4(4) << 87(57) = 33554432(2000000)\nunsigned 8 4(4) << 88(58) = 67108864(4000000)\nunsigned 8 4(4) << 89(59) = 134217728(8000000)\nunsigned 8 4(4) << 90(5a) = 268435456(10000000)\nunsigned 8 4(4) << 91(5b) = 536870912(20000000)\nunsigned 8 4(4) << 92(5c) = 1073741824(40000000)\nunsigned 8 4(4) << 93(5d) = 2147483648(80000000)\nunsigned 8 4(4) << 94(5e) = 0(0)\nunsigned 8 4(4) << 95(5f) = 0(0)\nunsigned 8 4(4) << 96(60) = 4(4)\nunsigned 8 4(4) << 97(61) = 8(8)\nunsigned 8 4(4) << 98(62) = 16(10)\nunsigned 8 4(4) << 99(63) = 32(20)\nunsigned 8 4(4) << 100(64) = 64(40)\nunsigned 8 4(4) << 101(65) = 128(80)\nunsigned 8 4(4) << 102(66) = 256(100)\nunsigned 8 4(4) << 103(67) = 512(200)\nunsigned 8 4(4) << 104(68) = 1024(400)\nunsigned 8 4(4) << 105(69) = 2048(800)\nunsigned 8 4(4) << 106(6a) = 4096(1000)\nunsigned 8 4(4) << 107(6b) = 8192(2000)\nunsigned 8 4(4) << 108(6c) = 16384(4000)\nunsigned 8 4(4) << 109(6d) = 32768(8000)\nunsigned 8 4(4) << 110(6e) = 65536(10000)\nunsigned 8 4(4) << 111(6f) = 131072(20000)\nunsigned 8 4(4) << 112(70) = 262144(40000)\nunsigned 8 4(4) << 113(71) = 524288(80000)\nunsigned 8 4(4) << 114(72) = 1048576(100000)\nunsigned 8 4(4) << 115(73) = 2097152(200000)\nunsigned 8 4(4) << 116(74) = 4194304(400000)\nunsigned 8 4(4) << 117(75) = 8388608(800000)\nunsigned 8 4(4) << 118(76) = 16777216(1000000)\nunsigned 8 4(4) << 119(77) = 33554432(2000000)\nunsigned 8 4(4) << 120(78) = 67108864(4000000)\nunsigned 8 4(4) << 121(79) = 134217728(8000000)\nunsigned 8 4(4) << 122(7a) = 268435456(10000000)\nunsigned 8 4(4) << 123(7b) = 536870912(20000000)\nunsigned 8 4(4) << 124(7c) = 1073741824(40000000)\nunsigned 8 4(4) << 125(7d) = 2147483648(80000000)\nunsigned 8 4(4) << 126(7e) = 0(0)\nunsigned 8 4(4) << 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\nunsigned 8 0(0) >> -128(ffffff80) = 0(0)\nunsigned 8 0(0) >> -127(ffffff81) = 0(0)\nunsigned 8 0(0) >> -126(ffffff82) = 0(0)\nunsigned 8 0(0) >> -125(ffffff83) = 0(0)\nunsigned 8 0(0) >> -124(ffffff84) = 0(0)\nunsigned 8 0(0) >> -123(ffffff85) = 0(0)\nunsigned 8 0(0) >> -122(ffffff86) = 0(0)\nunsigned 8 0(0) >> -121(ffffff87) = 0(0)\nunsigned 8 0(0) >> -120(ffffff88) = 0(0)\nunsigned 8 0(0) >> -119(ffffff89) = 0(0)\nunsigned 8 0(0) >> -118(ffffff8a) = 0(0)\nunsigned 8 0(0) >> -117(ffffff8b) = 0(0)\nunsigned 8 0(0) >> -116(ffffff8c) = 0(0)\nunsigned 8 0(0) >> -115(ffffff8d) = 0(0)\nunsigned 8 0(0) >> -114(ffffff8e) = 0(0)\nunsigned 8 0(0) >> -113(ffffff8f) = 0(0)\nunsigned 8 0(0) >> -112(ffffff90) = 0(0)\nunsigned 8 0(0) >> -111(ffffff91) = 0(0)\nunsigned 8 0(0) >> -110(ffffff92) = 0(0)\nunsigned 8 0(0) >> -109(ffffff93) = 0(0)\nunsigned 8 0(0) >> -108(ffffff94) = 0(0)\nunsigned 8 0(0) >> -107(ffffff95) = 0(0)\nunsigned 8 0(0) >> -106(ffffff96) = 0(0)\nunsigned 8 0(0) >> -105(ffffff97) = 0(0)\nunsigned 8 0(0) >> -104(ffffff98) = 0(0)\nunsigned 8 0(0) >> -103(ffffff99) = 0(0)\nunsigned 8 0(0) >> -102(ffffff9a) = 0(0)\nunsigned 8 0(0) >> -101(ffffff9b) = 0(0)\nunsigned 8 0(0) >> -100(ffffff9c) = 0(0)\nunsigned 8 0(0) >> -99(ffffff9d) = 0(0)\nunsigned 8 0(0) >> -98(ffffff9e) = 0(0)\nunsigned 8 0(0) >> -97(ffffff9f) = 0(0)\nunsigned 8 0(0) >> -96(ffffffa0) = 0(0)\nunsigned 8 0(0) >> -95(ffffffa1) = 0(0)\nunsigned 8 0(0) >> -94(ffffffa2) = 0(0)\nunsigned 8 0(0) >> -93(ffffffa3) = 0(0)\nunsigned 8 0(0) >> -92(ffffffa4) = 0(0)\nunsigned 8 0(0) >> -91(ffffffa5) = 0(0)\nunsigned 8 0(0) >> -90(ffffffa6) = 0(0)\nunsigned 8 0(0) >> -89(ffffffa7) = 0(0)\nunsigned 8 0(0) >> -88(ffffffa8) = 0(0)\nunsigned 8 0(0) >> -87(ffffffa9) = 0(0)\nunsigned 8 0(0) >> -86(ffffffaa) = 0(0)\nunsigned 8 0(0) >> -85(ffffffab) = 0(0)\nunsigned 8 0(0) >> -84(ffffffac) = 0(0)\nunsigned 8 0(0) >> -83(ffffffad) = 0(0)\nunsigned 8 0(0) >> -82(ffffffae) = 0(0)\nunsigned 8 0(0) >> -81(ffffffaf) = 0(0)\nunsigned 8 0(0) >> -80(ffffffb0) = 0(0)\nunsigned 8 0(0) >> -79(ffffffb1) = 0(0)\nunsigned 8 0(0) >> -78(ffffffb2) = 0(0)\nunsigned 8 0(0) >> -77(ffffffb3) = 0(0)\nunsigned 8 0(0) >> -76(ffffffb4) = 0(0)\nunsigned 8 0(0) >> -75(ffffffb5) = 0(0)\nunsigned 8 0(0) >> -74(ffffffb6) = 0(0)\nunsigned 8 0(0) >> -73(ffffffb7) = 0(0)\nunsigned 8 0(0) >> -72(ffffffb8) = 0(0)\nunsigned 8 0(0) >> -71(ffffffb9) = 0(0)\nunsigned 8 0(0) >> -70(ffffffba) = 0(0)\nunsigned 8 0(0) >> -69(ffffffbb) = 0(0)\nunsigned 8 0(0) >> -68(ffffffbc) = 0(0)\nunsigned 8 0(0) >> -67(ffffffbd) = 0(0)\nunsigned 8 0(0) >> -66(ffffffbe) = 0(0)\nunsigned 8 0(0) >> -65(ffffffbf) = 0(0)\nunsigned 8 0(0) >> -64(ffffffc0) = 0(0)\nunsigned 8 0(0) >> -63(ffffffc1) = 0(0)\nunsigned 8 0(0) >> -62(ffffffc2) = 0(0)\nunsigned 8 0(0) >> -61(ffffffc3) = 0(0)\nunsigned 8 0(0) >> -60(ffffffc4) = 0(0)\nunsigned 8 0(0) >> -59(ffffffc5) = 0(0)\nunsigned 8 0(0) >> -58(ffffffc6) = 0(0)\nunsigned 8 0(0) >> -57(ffffffc7) = 0(0)\nunsigned 8 0(0) >> -56(ffffffc8) = 0(0)\nunsigned 8 0(0) >> -55(ffffffc9) = 0(0)\nunsigned 8 0(0) >> -54(ffffffca) = 0(0)\nunsigned 8 0(0) >> -53(ffffffcb) = 0(0)\nunsigned 8 0(0) >> -52(ffffffcc) = 0(0)\nunsigned 8 0(0) >> -51(ffffffcd) = 0(0)\nunsigned 8 0(0) >> -50(ffffffce) = 0(0)\nunsigned 8 0(0) >> -49(ffffffcf) = 0(0)\nunsigned 8 0(0) >> -48(ffffffd0) = 0(0)\nunsigned 8 0(0) >> -47(ffffffd1) = 0(0)\nunsigned 8 0(0) >> -46(ffffffd2) = 0(0)\nunsigned 8 0(0) >> -45(ffffffd3) = 0(0)\nunsigned 8 0(0) >> -44(ffffffd4) = 0(0)\nunsigned 8 0(0) >> -43(ffffffd5) = 0(0)\nunsigned 8 0(0) >> -42(ffffffd6) = 0(0)\nunsigned 8 0(0) >> -41(ffffffd7) = 0(0)\nunsigned 8 0(0) >> -40(ffffffd8) = 0(0)\nunsigned 8 0(0) >> -39(ffffffd9) = 0(0)\nunsigned 8 0(0) >> -38(ffffffda) = 0(0)\nunsigned 8 0(0) >> -37(ffffffdb) = 0(0)\nunsigned 8 0(0) >> -36(ffffffdc) = 0(0)\nunsigned 8 0(0) >> -35(ffffffdd) = 0(0)\nunsigned 8 0(0) >> -34(ffffffde) = 0(0)\nunsigned 8 0(0) >> -33(ffffffdf) = 0(0)\nunsigned 8 0(0) >> -32(ffffffe0) = 0(0)\nunsigned 8 0(0) >> -31(ffffffe1) = 0(0)\nunsigned 8 0(0) >> -30(ffffffe2) = 0(0)\nunsigned 8 0(0) >> -29(ffffffe3) = 0(0)\nunsigned 8 0(0) >> -28(ffffffe4) = 0(0)\nunsigned 8 0(0) >> -27(ffffffe5) = 0(0)\nunsigned 8 0(0) >> -26(ffffffe6) = 0(0)\nunsigned 8 0(0) >> -25(ffffffe7) = 0(0)\nunsigned 8 0(0) >> -24(ffffffe8) = 0(0)\nunsigned 8 0(0) >> -23(ffffffe9) = 0(0)\nunsigned 8 0(0) >> -22(ffffffea) = 0(0)\nunsigned 8 0(0) >> -21(ffffffeb) = 0(0)\nunsigned 8 0(0) >> -20(ffffffec) = 0(0)\nunsigned 8 0(0) >> -19(ffffffed) = 0(0)\nunsigned 8 0(0) >> -18(ffffffee) = 0(0)\nunsigned 8 0(0) >> -17(ffffffef) = 0(0)\nunsigned 8 0(0) >> -16(fffffff0) = 0(0)\nunsigned 8 0(0) >> -15(fffffff1) = 0(0)\nunsigned 8 0(0) >> -14(fffffff2) = 0(0)\nunsigned 8 0(0) >> -13(fffffff3) = 0(0)\nunsigned 8 0(0) >> -12(fffffff4) = 0(0)\nunsigned 8 0(0) >> -11(fffffff5) = 0(0)\nunsigned 8 0(0) >> -10(fffffff6) = 0(0)\nunsigned 8 0(0) >> -9(fffffff7) = 0(0)\nunsigned 8 0(0) >> -8(fffffff8) = 0(0)\nunsigned 8 0(0) >> -7(fffffff9) = 0(0)\nunsigned 8 0(0) >> -6(fffffffa) = 0(0)\nunsigned 8 0(0) >> -5(fffffffb) = 0(0)\nunsigned 8 0(0) >> -4(fffffffc) = 0(0)\nunsigned 8 0(0) >> -3(fffffffd) = 0(0)\nunsigned 8 0(0) >> -2(fffffffe) = 0(0)\nunsigned 8 0(0) >> -1(ffffffff) = 0(0)\nunsigned 8 0(0) >> 0(0) = 0(0)\nunsigned 8 0(0) >> 1(1) = 0(0)\nunsigned 8 0(0) >> 2(2) = 0(0)\nunsigned 8 0(0) >> 3(3) = 0(0)\nunsigned 8 0(0) >> 4(4) = 0(0)\nunsigned 8 0(0) >> 5(5) = 0(0)\nunsigned 8 0(0) >> 6(6) = 0(0)\nunsigned 8 0(0) >> 7(7) = 0(0)\nunsigned 8 0(0) >> 8(8) = 0(0)\nunsigned 8 0(0) >> 9(9) = 0(0)\nunsigned 8 0(0) >> 10(a) = 0(0)\nunsigned 8 0(0) >> 11(b) = 0(0)\nunsigned 8 0(0) >> 12(c) = 0(0)\nunsigned 8 0(0) >> 13(d) = 0(0)\nunsigned 8 0(0) >> 14(e) = 0(0)\nunsigned 8 0(0) >> 15(f) = 0(0)\nunsigned 8 0(0) >> 16(10) = 0(0)\nunsigned 8 0(0) >> 17(11) = 0(0)\nunsigned 8 0(0) >> 18(12) = 0(0)\nunsigned 8 0(0) >> 19(13) = 0(0)\nunsigned 8 0(0) >> 20(14) = 0(0)\nunsigned 8 0(0) >> 21(15) = 0(0)\nunsigned 8 0(0) >> 22(16) = 0(0)\nunsigned 8 0(0) >> 23(17) = 0(0)\nunsigned 8 0(0) >> 24(18) = 0(0)\nunsigned 8 0(0) >> 25(19) = 0(0)\nunsigned 8 0(0) >> 26(1a) = 0(0)\nunsigned 8 0(0) >> 27(1b) = 0(0)\nunsigned 8 0(0) >> 28(1c) = 0(0)\nunsigned 8 0(0) >> 29(1d) = 0(0)\nunsigned 8 0(0) >> 30(1e) = 0(0)\nunsigned 8 0(0) >> 31(1f) = 0(0)\nunsigned 8 0(0) >> 32(20) = 0(0)\nunsigned 8 0(0) >> 33(21) = 0(0)\nunsigned 8 0(0) >> 34(22) = 0(0)\nunsigned 8 0(0) >> 35(23) = 0(0)\nunsigned 8 0(0) >> 36(24) = 0(0)\nunsigned 8 0(0) >> 37(25) = 0(0)\nunsigned 8 0(0) >> 38(26) = 0(0)\nunsigned 8 0(0) >> 39(27) = 0(0)\nunsigned 8 0(0) >> 40(28) = 0(0)\nunsigned 8 0(0) >> 41(29) = 0(0)\nunsigned 8 0(0) >> 42(2a) = 0(0)\nunsigned 8 0(0) >> 43(2b) = 0(0)\nunsigned 8 0(0) >> 44(2c) = 0(0)\nunsigned 8 0(0) >> 45(2d) = 0(0)\nunsigned 8 0(0) >> 46(2e) = 0(0)\nunsigned 8 0(0) >> 47(2f) = 0(0)\nunsigned 8 0(0) >> 48(30) = 0(0)\nunsigned 8 0(0) >> 49(31) = 0(0)\nunsigned 8 0(0) >> 50(32) = 0(0)\nunsigned 8 0(0) >> 51(33) = 0(0)\nunsigned 8 0(0) >> 52(34) = 0(0)\nunsigned 8 0(0) >> 53(35) = 0(0)\nunsigned 8 0(0) >> 54(36) = 0(0)\nunsigned 8 0(0) >> 55(37) = 0(0)\nunsigned 8 0(0) >> 56(38) = 0(0)\nunsigned 8 0(0) >> 57(39) = 0(0)\nunsigned 8 0(0) >> 58(3a) = 0(0)\nunsigned 8 0(0) >> 59(3b) = 0(0)\nunsigned 8 0(0) >> 60(3c) = 0(0)\nunsigned 8 0(0) >> 61(3d) = 0(0)\nunsigned 8 0(0) >> 62(3e) = 0(0)\nunsigned 8 0(0) >> 63(3f) = 0(0)\nunsigned 8 0(0) >> 64(40) = 0(0)\nunsigned 8 0(0) >> 65(41) = 0(0)\nunsigned 8 0(0) >> 66(42) = 0(0)\nunsigned 8 0(0) >> 67(43) = 0(0)\nunsigned 8 0(0) >> 68(44) = 0(0)\nunsigned 8 0(0) >> 69(45) = 0(0)\nunsigned 8 0(0) >> 70(46) = 0(0)\nunsigned 8 0(0) >> 71(47) = 0(0)\nunsigned 8 0(0) >> 72(48) = 0(0)\nunsigned 8 0(0) >> 73(49) = 0(0)\nunsigned 8 0(0) >> 74(4a) = 0(0)\nunsigned 8 0(0) >> 75(4b) = 0(0)\nunsigned 8 0(0) >> 76(4c) = 0(0)\nunsigned 8 0(0) >> 77(4d) = 0(0)\nunsigned 8 0(0) >> 78(4e) = 0(0)\nunsigned 8 0(0) >> 79(4f) = 0(0)\nunsigned 8 0(0) >> 80(50) = 0(0)\nunsigned 8 0(0) >> 81(51) = 0(0)\nunsigned 8 0(0) >> 82(52) = 0(0)\nunsigned 8 0(0) >> 83(53) = 0(0)\nunsigned 8 0(0) >> 84(54) = 0(0)\nunsigned 8 0(0) >> 85(55) = 0(0)\nunsigned 8 0(0) >> 86(56) = 0(0)\nunsigned 8 0(0) >> 87(57) = 0(0)\nunsigned 8 0(0) >> 88(58) = 0(0)\nunsigned 8 0(0) >> 89(59) = 0(0)\nunsigned 8 0(0) >> 90(5a) = 0(0)\nunsigned 8 0(0) >> 91(5b) = 0(0)\nunsigned 8 0(0) >> 92(5c) = 0(0)\nunsigned 8 0(0) >> 93(5d) = 0(0)\nunsigned 8 0(0) >> 94(5e) = 0(0)\nunsigned 8 0(0) >> 95(5f) = 0(0)\nunsigned 8 0(0) >> 96(60) = 0(0)\nunsigned 8 0(0) >> 97(61) = 0(0)\nunsigned 8 0(0) >> 98(62) = 0(0)\nunsigned 8 0(0) >> 99(63) = 0(0)\nunsigned 8 0(0) >> 100(64) = 0(0)\nunsigned 8 0(0) >> 101(65) = 0(0)\nunsigned 8 0(0) >> 102(66) = 0(0)\nunsigned 8 0(0) >> 103(67) = 0(0)\nunsigned 8 0(0) >> 104(68) = 0(0)\nunsigned 8 0(0) >> 105(69) = 0(0)\nunsigned 8 0(0) >> 106(6a) = 0(0)\nunsigned 8 0(0) >> 107(6b) = 0(0)\nunsigned 8 0(0) >> 108(6c) = 0(0)\nunsigned 8 0(0) >> 109(6d) = 0(0)\nunsigned 8 0(0) >> 110(6e) = 0(0)\nunsigned 8 0(0) >> 111(6f) = 0(0)\nunsigned 8 0(0) >> 112(70) = 0(0)\nunsigned 8 0(0) >> 113(71) = 0(0)\nunsigned 8 0(0) >> 114(72) = 0(0)\nunsigned 8 0(0) >> 115(73) = 0(0)\nunsigned 8 0(0) >> 116(74) = 0(0)\nunsigned 8 0(0) >> 117(75) = 0(0)\nunsigned 8 0(0) >> 118(76) = 0(0)\nunsigned 8 0(0) >> 119(77) = 0(0)\nunsigned 8 0(0) >> 120(78) = 0(0)\nunsigned 8 0(0) >> 121(79) = 0(0)\nunsigned 8 0(0) >> 122(7a) = 0(0)\nunsigned 8 0(0) >> 123(7b) = 0(0)\nunsigned 8 0(0) >> 124(7c) = 0(0)\nunsigned 8 0(0) >> 125(7d) = 0(0)\nunsigned 8 0(0) >> 126(7e) = 0(0)\nunsigned 8 0(0) >> 127(7f) = 0(0)\nunsigned 8 1(1) >> -128(ffffff80) = 1(1)\nunsigned 8 1(1) >> -127(ffffff81) = 0(0)\nunsigned 8 1(1) >> -126(ffffff82) = 0(0)\nunsigned 8 1(1) >> -125(ffffff83) = 0(0)\nunsigned 8 1(1) >> -124(ffffff84) = 0(0)\nunsigned 8 1(1) >> -123(ffffff85) = 0(0)\nunsigned 8 1(1) >> -122(ffffff86) = 0(0)\nunsigned 8 1(1) >> -121(ffffff87) = 0(0)\nunsigned 8 1(1) >> -120(ffffff88) = 0(0)\nunsigned 8 1(1) >> -119(ffffff89) = 0(0)\nunsigned 8 1(1) >> -118(ffffff8a) = 0(0)\nunsigned 8 1(1) >> -117(ffffff8b) = 0(0)\nunsigned 8 1(1) >> -116(ffffff8c) = 0(0)\nunsigned 8 1(1) >> -115(ffffff8d) = 0(0)\nunsigned 8 1(1) >> -114(ffffff8e) = 0(0)\nunsigned 8 1(1) >> -113(ffffff8f) = 0(0)\nunsigned 8 1(1) >> -112(ffffff90) = 0(0)\nunsigned 8 1(1) >> -111(ffffff91) = 0(0)\nunsigned 8 1(1) >> -110(ffffff92) = 0(0)\nunsigned 8 1(1) >> -109(ffffff93) = 0(0)\nunsigned 8 1(1) >> -108(ffffff94) = 0(0)\nunsigned 8 1(1) >> -107(ffffff95) = 0(0)\nunsigned 8 1(1) >> -106(ffffff96) = 0(0)\nunsigned 8 1(1) >> -105(ffffff97) = 0(0)\nunsigned 8 1(1) >> -104(ffffff98) = 0(0)\nunsigned 8 1(1) >> -103(ffffff99) = 0(0)\nunsigned 8 1(1) >> -102(ffffff9a) = 0(0)\nunsigned 8 1(1) >> -101(ffffff9b) = 0(0)\nunsigned 8 1(1) >> -100(ffffff9c) = 0(0)\nunsigned 8 1(1) >> -99(ffffff9d) = 0(0)\nunsigned 8 1(1) >> -98(ffffff9e) = 0(0)\nunsigned 8 1(1) >> -97(ffffff9f) = 0(0)\nunsigned 8 1(1) >> -96(ffffffa0) = 1(1)\nunsigned 8 1(1) >> -95(ffffffa1) = 0(0)\nunsigned 8 1(1) >> -94(ffffffa2) = 0(0)\nunsigned 8 1(1) >> -93(ffffffa3) = 0(0)\nunsigned 8 1(1) >> -92(ffffffa4) = 0(0)\nunsigned 8 1(1) >> -91(ffffffa5) = 0(0)\nunsigned 8 1(1) >> -90(ffffffa6) = 0(0)\nunsigned 8 1(1) >> -89(ffffffa7) = 0(0)\nunsigned 8 1(1) >> -88(ffffffa8) = 0(0)\nunsigned 8 1(1) >> -87(ffffffa9) = 0(0)\nunsigned 8 1(1) >> -86(ffffffaa) = 0(0)\nunsigned 8 1(1) >> -85(ffffffab) = 0(0)\nunsigned 8 1(1) >> -84(ffffffac) = 0(0)\nunsigned 8 1(1) >> -83(ffffffad) = 0(0)\nunsigned 8 1(1) >> -82(ffffffae) = 0(0)\nunsigned 8 1(1) >> -81(ffffffaf) = 0(0)\nunsigned 8 1(1) >> -80(ffffffb0) = 0(0)\nunsigned 8 1(1) >> -79(ffffffb1) = 0(0)\nunsigned 8 1(1) >> -78(ffffffb2) = 0(0)\nunsigned 8 1(1) >> -77(ffffffb3) = 0(0)\nunsigned 8 1(1) >> -76(ffffffb4) = 0(0)\nunsigned 8 1(1) >> -75(ffffffb5) = 0(0)\nunsigned 8 1(1) >> -74(ffffffb6) = 0(0)\nunsigned 8 1(1) >> -73(ffffffb7) = 0(0)\nunsigned 8 1(1) >> -72(ffffffb8) = 0(0)\nunsigned 8 1(1) >> -71(ffffffb9) = 0(0)\nunsigned 8 1(1) >> -70(ffffffba) = 0(0)\nunsigned 8 1(1) >> -69(ffffffbb) = 0(0)\nunsigned 8 1(1) >> -68(ffffffbc) = 0(0)\nunsigned 8 1(1) >> -67(ffffffbd) = 0(0)\nunsigned 8 1(1) >> -66(ffffffbe) = 0(0)\nunsigned 8 1(1) >> -65(ffffffbf) = 0(0)\nunsigned 8 1(1) >> -64(ffffffc0) = 1(1)\nunsigned 8 1(1) >> -63(ffffffc1) = 0(0)\nunsigned 8 1(1) >> -62(ffffffc2) = 0(0)\nunsigned 8 1(1) >> -61(ffffffc3) = 0(0)\nunsigned 8 1(1) >> -60(ffffffc4) = 0(0)\nunsigned 8 1(1) >> -59(ffffffc5) = 0(0)\nunsigned 8 1(1) >> -58(ffffffc6) = 0(0)\nunsigned 8 1(1) >> -57(ffffffc7) = 0(0)\nunsigned 8 1(1) >> -56(ffffffc8) = 0(0)\nunsigned 8 1(1) >> -55(ffffffc9) = 0(0)\nunsigned 8 1(1) >> -54(ffffffca) = 0(0)\nunsigned 8 1(1) >> -53(ffffffcb) = 0(0)\nunsigned 8 1(1) >> -52(ffffffcc) = 0(0)\nunsigned 8 1(1) >> -51(ffffffcd) = 0(0)\nunsigned 8 1(1) >> -50(ffffffce) = 0(0)\nunsigned 8 1(1) >> -49(ffffffcf) = 0(0)\nunsigned 8 1(1) >> -48(ffffffd0) = 0(0)\nunsigned 8 1(1) >> -47(ffffffd1) = 0(0)\nunsigned 8 1(1) >> -46(ffffffd2) = 0(0)\nunsigned 8 1(1) >> -45(ffffffd3) = 0(0)\nunsigned 8 1(1) >> -44(ffffffd4) = 0(0)\nunsigned 8 1(1) >> -43(ffffffd5) = 0(0)\nunsigned 8 1(1) >> -42(ffffffd6) = 0(0)\nunsigned 8 1(1) >> -41(ffffffd7) = 0(0)\nunsigned 8 1(1) >> -40(ffffffd8) = 0(0)\nunsigned 8 1(1) >> -39(ffffffd9) = 0(0)\nunsigned 8 1(1) >> -38(ffffffda) = 0(0)\nunsigned 8 1(1) >> -37(ffffffdb) = 0(0)\nunsigned 8 1(1) >> -36(ffffffdc) = 0(0)\nunsigned 8 1(1) >> -35(ffffffdd) = 0(0)\nunsigned 8 1(1) >> -34(ffffffde) = 0(0)\nunsigned 8 1(1) >> -33(ffffffdf) = 0(0)\nunsigned 8 1(1) >> -32(ffffffe0) = 1(1)\nunsigned 8 1(1) >> -31(ffffffe1) = 0(0)\nunsigned 8 1(1) >> -30(ffffffe2) = 0(0)\nunsigned 8 1(1) >> -29(ffffffe3) = 0(0)\nunsigned 8 1(1) >> -28(ffffffe4) = 0(0)\nunsigned 8 1(1) >> -27(ffffffe5) = 0(0)\nunsigned 8 1(1) >> -26(ffffffe6) = 0(0)\nunsigned 8 1(1) >> -25(ffffffe7) = 0(0)\nunsigned 8 1(1) >> -24(ffffffe8) = 0(0)\nunsigned 8 1(1) >> -23(ffffffe9) = 0(0)\nunsigned 8 1(1) >> -22(ffffffea) = 0(0)\nunsigned 8 1(1) >> -21(ffffffeb) = 0(0)\nunsigned 8 1(1) >> -20(ffffffec) = 0(0)\nunsigned 8 1(1) >> -19(ffffffed) = 0(0)\nunsigned 8 1(1) >> -18(ffffffee) = 0(0)\nunsigned 8 1(1) >> -17(ffffffef) = 0(0)\nunsigned 8 1(1) >> -16(fffffff0) = 0(0)\nunsigned 8 1(1) >> -15(fffffff1) = 0(0)\nunsigned 8 1(1) >> -14(fffffff2) = 0(0)\nunsigned 8 1(1) >> -13(fffffff3) = 0(0)\nunsigned 8 1(1) >> -12(fffffff4) = 0(0)\nunsigned 8 1(1) >> -11(fffffff5) = 0(0)\nunsigned 8 1(1) >> -10(fffffff6) = 0(0)\nunsigned 8 1(1) >> -9(fffffff7) = 0(0)\nunsigned 8 1(1) >> -8(fffffff8) = 0(0)\nunsigned 8 1(1) >> -7(fffffff9) = 0(0)\nunsigned 8 1(1) >> -6(fffffffa) = 0(0)\nunsigned 8 1(1) >> -5(fffffffb) = 0(0)\nunsigned 8 1(1) >> -4(fffffffc) = 0(0)\nunsigned 8 1(1) >> -3(fffffffd) = 0(0)\nunsigned 8 1(1) >> -2(fffffffe) = 0(0)\nunsigned 8 1(1) >> -1(ffffffff) = 0(0)\nunsigned 8 1(1) >> 0(0) = 1(1)\nunsigned 8 1(1) >> 1(1) = 0(0)\nunsigned 8 1(1) >> 2(2) = 0(0)\nunsigned 8 1(1) >> 3(3) = 0(0)\nunsigned 8 1(1) >> 4(4) = 0(0)\nunsigned 8 1(1) >> 5(5) = 0(0)\nunsigned 8 1(1) >> 6(6) = 0(0)\nunsigned 8 1(1) >> 7(7) = 0(0)\nunsigned 8 1(1) >> 8(8) = 0(0)\nunsigned 8 1(1) >> 9(9) = 0(0)\nunsigned 8 1(1) >> 10(a) = 0(0)\nunsigned 8 1(1) >> 11(b) = 0(0)\nunsigned 8 1(1) >> 12(c) = 0(0)\nunsigned 8 1(1) >> 13(d) = 0(0)\nunsigned 8 1(1) >> 14(e) = 0(0)\nunsigned 8 1(1) >> 15(f) = 0(0)\nunsigned 8 1(1) >> 16(10) = 0(0)\nunsigned 8 1(1) >> 17(11) = 0(0)\nunsigned 8 1(1) >> 18(12) = 0(0)\nunsigned 8 1(1) >> 19(13) = 0(0)\nunsigned 8 1(1) >> 20(14) = 0(0)\nunsigned 8 1(1) >> 21(15) = 0(0)\nunsigned 8 1(1) >> 22(16) = 0(0)\nunsigned 8 1(1) >> 23(17) = 0(0)\nunsigned 8 1(1) >> 24(18) = 0(0)\nunsigned 8 1(1) >> 25(19) = 0(0)\nunsigned 8 1(1) >> 26(1a) = 0(0)\nunsigned 8 1(1) >> 27(1b) = 0(0)\nunsigned 8 1(1) >> 28(1c) = 0(0)\nunsigned 8 1(1) >> 29(1d) = 0(0)\nunsigned 8 1(1) >> 30(1e) = 0(0)\nunsigned 8 1(1) >> 31(1f) = 0(0)\nunsigned 8 1(1) >> 32(20) = 1(1)\nunsigned 8 1(1) >> 33(21) = 0(0)\nunsigned 8 1(1) >> 34(22) = 0(0)\nunsigned 8 1(1) >> 35(23) = 0(0)\nunsigned 8 1(1) >> 36(24) = 0(0)\nunsigned 8 1(1) >> 37(25) = 0(0)\nunsigned 8 1(1) >> 38(26) = 0(0)\nunsigned 8 1(1) >> 39(27) = 0(0)\nunsigned 8 1(1) >> 40(28) = 0(0)\nunsigned 8 1(1) >> 41(29) = 0(0)\nunsigned 8 1(1) >> 42(2a) = 0(0)\nunsigned 8 1(1) >> 43(2b) = 0(0)\nunsigned 8 1(1) >> 44(2c) = 0(0)\nunsigned 8 1(1) >> 45(2d) = 0(0)\nunsigned 8 1(1) >> 46(2e) = 0(0)\nunsigned 8 1(1) >> 47(2f) = 0(0)\nunsigned 8 1(1) >> 48(30) = 0(0)\nunsigned 8 1(1) >> 49(31) = 0(0)\nunsigned 8 1(1) >> 50(32) = 0(0)\nunsigned 8 1(1) >> 51(33) = 0(0)\nunsigned 8 1(1) >> 52(34) = 0(0)\nunsigned 8 1(1) >> 53(35) = 0(0)\nunsigned 8 1(1) >> 54(36) = 0(0)\nunsigned 8 1(1) >> 55(37) = 0(0)\nunsigned 8 1(1) >> 56(38) = 0(0)\nunsigned 8 1(1) >> 57(39) = 0(0)\nunsigned 8 1(1) >> 58(3a) = 0(0)\nunsigned 8 1(1) >> 59(3b) = 0(0)\nunsigned 8 1(1) >> 60(3c) = 0(0)\nunsigned 8 1(1) >> 61(3d) = 0(0)\nunsigned 8 1(1) >> 62(3e) = 0(0)\nunsigned 8 1(1) >> 63(3f) = 0(0)\nunsigned 8 1(1) >> 64(40) = 1(1)\nunsigned 8 1(1) >> 65(41) = 0(0)\nunsigned 8 1(1) >> 66(42) = 0(0)\nunsigned 8 1(1) >> 67(43) = 0(0)\nunsigned 8 1(1) >> 68(44) = 0(0)\nunsigned 8 1(1) >> 69(45) = 0(0)\nunsigned 8 1(1) >> 70(46) = 0(0)\nunsigned 8 1(1) >> 71(47) = 0(0)\nunsigned 8 1(1) >> 72(48) = 0(0)\nunsigned 8 1(1) >> 73(49) = 0(0)\nunsigned 8 1(1) >> 74(4a) = 0(0)\nunsigned 8 1(1) >> 75(4b) = 0(0)\nunsigned 8 1(1) >> 76(4c) = 0(0)\nunsigned 8 1(1) >> 77(4d) = 0(0)\nunsigned 8 1(1) >> 78(4e) = 0(0)\nunsigned 8 1(1) >> 79(4f) = 0(0)\nunsigned 8 1(1) >> 80(50) = 0(0)\nunsigned 8 1(1) >> 81(51) = 0(0)\nunsigned 8 1(1) >> 82(52) = 0(0)\nunsigned 8 1(1) >> 83(53) = 0(0)\nunsigned 8 1(1) >> 84(54) = 0(0)\nunsigned 8 1(1) >> 85(55) = 0(0)\nunsigned 8 1(1) >> 86(56) = 0(0)\nunsigned 8 1(1) >> 87(57) = 0(0)\nunsigned 8 1(1) >> 88(58) = 0(0)\nunsigned 8 1(1) >> 89(59) = 0(0)\nunsigned 8 1(1) >> 90(5a) = 0(0)\nunsigned 8 1(1) >> 91(5b) = 0(0)\nunsigned 8 1(1) >> 92(5c) = 0(0)\nunsigned 8 1(1) >> 93(5d) = 0(0)\nunsigned 8 1(1) >> 94(5e) = 0(0)\nunsigned 8 1(1) >> 95(5f) = 0(0)\nunsigned 8 1(1) >> 96(60) = 1(1)\nunsigned 8 1(1) >> 97(61) = 0(0)\nunsigned 8 1(1) >> 98(62) = 0(0)\nunsigned 8 1(1) >> 99(63) = 0(0)\nunsigned 8 1(1) >> 100(64) = 0(0)\nunsigned 8 1(1) >> 101(65) = 0(0)\nunsigned 8 1(1) >> 102(66) = 0(0)\nunsigned 8 1(1) >> 103(67) = 0(0)\nunsigned 8 1(1) >> 104(68) = 0(0)\nunsigned 8 1(1) >> 105(69) = 0(0)\nunsigned 8 1(1) >> 106(6a) = 0(0)\nunsigned 8 1(1) >> 107(6b) = 0(0)\nunsigned 8 1(1) >> 108(6c) = 0(0)\nunsigned 8 1(1) >> 109(6d) = 0(0)\nunsigned 8 1(1) >> 110(6e) = 0(0)\nunsigned 8 1(1) >> 111(6f) = 0(0)\nunsigned 8 1(1) >> 112(70) = 0(0)\nunsigned 8 1(1) >> 113(71) = 0(0)\nunsigned 8 1(1) >> 114(72) = 0(0)\nunsigned 8 1(1) >> 115(73) = 0(0)\nunsigned 8 1(1) >> 116(74) = 0(0)\nunsigned 8 1(1) >> 117(75) = 0(0)\nunsigned 8 1(1) >> 118(76) = 0(0)\nunsigned 8 1(1) >> 119(77) = 0(0)\nunsigned 8 1(1) >> 120(78) = 0(0)\nunsigned 8 1(1) >> 121(79) = 0(0)\nunsigned 8 1(1) >> 122(7a) = 0(0)\nunsigned 8 1(1) >> 123(7b) = 0(0)\nunsigned 8 1(1) >> 124(7c) = 0(0)\nunsigned 8 1(1) >> 125(7d) = 0(0)\nunsigned 8 1(1) >> 126(7e) = 0(0)\nunsigned 8 1(1) >> 127(7f) = 0(0)\nunsigned 8 2(2) >> -128(ffffff80) = 2(2)\nunsigned 8 2(2) >> -127(ffffff81) = 1(1)\nunsigned 8 2(2) >> -126(ffffff82) = 0(0)\nunsigned 8 2(2) >> -125(ffffff83) = 0(0)\nunsigned 8 2(2) >> -124(ffffff84) = 0(0)\nunsigned 8 2(2) >> -123(ffffff85) = 0(0)\nunsigned 8 2(2) >> -122(ffffff86) = 0(0)\nunsigned 8 2(2) >> -121(ffffff87) = 0(0)\nunsigned 8 2(2) >> -120(ffffff88) = 0(0)\nunsigned 8 2(2) >> -119(ffffff89) = 0(0)\nunsigned 8 2(2) >> -118(ffffff8a) = 0(0)\nunsigned 8 2(2) >> -117(ffffff8b) = 0(0)\nunsigned 8 2(2) >> -116(ffffff8c) = 0(0)\nunsigned 8 2(2) >> -115(ffffff8d) = 0(0)\nunsigned 8 2(2) >> -114(ffffff8e) = 0(0)\nunsigned 8 2(2) >> -113(ffffff8f) = 0(0)\nunsigned 8 2(2) >> -112(ffffff90) = 0(0)\nunsigned 8 2(2) >> -111(ffffff91) = 0(0)\nunsigned 8 2(2) >> -110(ffffff92) = 0(0)\nunsigned 8 2(2) >> -109(ffffff93) = 0(0)\nunsigned 8 2(2) >> -108(ffffff94) = 0(0)\nunsigned 8 2(2) >> -107(ffffff95) = 0(0)\nunsigned 8 2(2) >> -106(ffffff96) = 0(0)\nunsigned 8 2(2) >> -105(ffffff97) = 0(0)\nunsigned 8 2(2) >> -104(ffffff98) = 0(0)\nunsigned 8 2(2) >> -103(ffffff99) = 0(0)\nunsigned 8 2(2) >> -102(ffffff9a) = 0(0)\nunsigned 8 2(2) >> -101(ffffff9b) = 0(0)\nunsigned 8 2(2) >> -100(ffffff9c) = 0(0)\nunsigned 8 2(2) >> -99(ffffff9d) = 0(0)\nunsigned 8 2(2) >> -98(ffffff9e) = 0(0)\nunsigned 8 2(2) >> -97(ffffff9f) = 0(0)\nunsigned 8 2(2) >> -96(ffffffa0) = 2(2)\nunsigned 8 2(2) >> -95(ffffffa1) = 1(1)\nunsigned 8 2(2) >> -94(ffffffa2) = 0(0)\nunsigned 8 2(2) >> -93(ffffffa3) = 0(0)\nunsigned 8 2(2) >> -92(ffffffa4) = 0(0)\nunsigned 8 2(2) >> -91(ffffffa5) = 0(0)\nunsigned 8 2(2) >> -90(ffffffa6) = 0(0)\nunsigned 8 2(2) >> -89(ffffffa7) = 0(0)\nunsigned 8 2(2) >> -88(ffffffa8) = 0(0)\nunsigned 8 2(2) >> -87(ffffffa9) = 0(0)\nunsigned 8 2(2) >> -86(ffffffaa) = 0(0)\nunsigned 8 2(2) >> -85(ffffffab) = 0(0)\nunsigned 8 2(2) >> -84(ffffffac) = 0(0)\nunsigned 8 2(2) >> -83(ffffffad) = 0(0)\nunsigned 8 2(2) >> -82(ffffffae) = 0(0)\nunsigned 8 2(2) >> -81(ffffffaf) = 0(0)\nunsigned 8 2(2) >> -80(ffffffb0) = 0(0)\nunsigned 8 2(2) >> -79(ffffffb1) = 0(0)\nunsigned 8 2(2) >> -78(ffffffb2) = 0(0)\nunsigned 8 2(2) >> -77(ffffffb3) = 0(0)\nunsigned 8 2(2) >> -76(ffffffb4) = 0(0)\nunsigned 8 2(2) >> -75(ffffffb5) = 0(0)\nunsigned 8 2(2) >> -74(ffffffb6) = 0(0)\nunsigned 8 2(2) >> -73(ffffffb7) = 0(0)\nunsigned 8 2(2) >> -72(ffffffb8) = 0(0)\nunsigned 8 2(2) >> -71(ffffffb9) = 0(0)\nunsigned 8 2(2) >> -70(ffffffba) = 0(0)\nunsigned 8 2(2) >> -69(ffffffbb) = 0(0)\nunsigned 8 2(2) >> -68(ffffffbc) = 0(0)\nunsigned 8 2(2) >> -67(ffffffbd) = 0(0)\nunsigned 8 2(2) >> -66(ffffffbe) = 0(0)\nunsigned 8 2(2) >> -65(ffffffbf) = 0(0)\nunsigned 8 2(2) >> -64(ffffffc0) = 2(2)\nunsigned 8 2(2) >> -63(ffffffc1) = 1(1)\nunsigned 8 2(2) >> -62(ffffffc2) = 0(0)\nunsigned 8 2(2) >> -61(ffffffc3) = 0(0)\nunsigned 8 2(2) >> -60(ffffffc4) = 0(0)\nunsigned 8 2(2) >> -59(ffffffc5) = 0(0)\nunsigned 8 2(2) >> -58(ffffffc6) = 0(0)\nunsigned 8 2(2) >> -57(ffffffc7) = 0(0)\nunsigned 8 2(2) >> -56(ffffffc8) = 0(0)\nunsigned 8 2(2) >> -55(ffffffc9) = 0(0)\nunsigned 8 2(2) >> -54(ffffffca) = 0(0)\nunsigned 8 2(2) >> -53(ffffffcb) = 0(0)\nunsigned 8 2(2) >> -52(ffffffcc) = 0(0)\nunsigned 8 2(2) >> -51(ffffffcd) = 0(0)\nunsigned 8 2(2) >> -50(ffffffce) = 0(0)\nunsigned 8 2(2) >> -49(ffffffcf) = 0(0)\nunsigned 8 2(2) >> -48(ffffffd0) = 0(0)\nunsigned 8 2(2) >> -47(ffffffd1) = 0(0)\nunsigned 8 2(2) >> -46(ffffffd2) = 0(0)\nunsigned 8 2(2) >> -45(ffffffd3) = 0(0)\nunsigned 8 2(2) >> -44(ffffffd4) = 0(0)\nunsigned 8 2(2) >> -43(ffffffd5) = 0(0)\nunsigned 8 2(2) >> -42(ffffffd6) = 0(0)\nunsigned 8 2(2) >> -41(ffffffd7) = 0(0)\nunsigned 8 2(2) >> -40(ffffffd8) = 0(0)\nunsigned 8 2(2) >> -39(ffffffd9) = 0(0)\nunsigned 8 2(2) >> -38(ffffffda) = 0(0)\nunsigned 8 2(2) >> -37(ffffffdb) = 0(0)\nunsigned 8 2(2) >> -36(ffffffdc) = 0(0)\nunsigned 8 2(2) >> -35(ffffffdd) = 0(0)\nunsigned 8 2(2) >> -34(ffffffde) = 0(0)\nunsigned 8 2(2) >> -33(ffffffdf) = 0(0)\nunsigned 8 2(2) >> -32(ffffffe0) = 2(2)\nunsigned 8 2(2) >> -31(ffffffe1) = 1(1)\nunsigned 8 2(2) >> -30(ffffffe2) = 0(0)\nunsigned 8 2(2) >> -29(ffffffe3) = 0(0)\nunsigned 8 2(2) >> -28(ffffffe4) = 0(0)\nunsigned 8 2(2) >> -27(ffffffe5) = 0(0)\nunsigned 8 2(2) >> -26(ffffffe6) = 0(0)\nunsigned 8 2(2) >> -25(ffffffe7) = 0(0)\nunsigned 8 2(2) >> -24(ffffffe8) = 0(0)\nunsigned 8 2(2) >> -23(ffffffe9) = 0(0)\nunsigned 8 2(2) >> -22(ffffffea) = 0(0)\nunsigned 8 2(2) >> -21(ffffffeb) = 0(0)\nunsigned 8 2(2) >> -20(ffffffec) = 0(0)\nunsigned 8 2(2) >> -19(ffffffed) = 0(0)\nunsigned 8 2(2) >> -18(ffffffee) = 0(0)\nunsigned 8 2(2) >> -17(ffffffef) = 0(0)\nunsigned 8 2(2) >> -16(fffffff0) = 0(0)\nunsigned 8 2(2) >> -15(fffffff1) = 0(0)\nunsigned 8 2(2) >> -14(fffffff2) = 0(0)\nunsigned 8 2(2) >> -13(fffffff3) = 0(0)\nunsigned 8 2(2) >> -12(fffffff4) = 0(0)\nunsigned 8 2(2) >> -11(fffffff5) = 0(0)\nunsigned 8 2(2) >> -10(fffffff6) = 0(0)\nunsigned 8 2(2) >> -9(fffffff7) = 0(0)\nunsigned 8 2(2) >> -8(fffffff8) = 0(0)\nunsigned 8 2(2) >> -7(fffffff9) = 0(0)\nunsigned 8 2(2) >> -6(fffffffa) = 0(0)\nunsigned 8 2(2) >> -5(fffffffb) = 0(0)\nunsigned 8 2(2) >> -4(fffffffc) = 0(0)\nunsigned 8 2(2) >> -3(fffffffd) = 0(0)\nunsigned 8 2(2) >> -2(fffffffe) = 0(0)\nunsigned 8 2(2) >> -1(ffffffff) = 0(0)\nunsigned 8 2(2) >> 0(0) = 2(2)\nunsigned 8 2(2) >> 1(1) = 1(1)\nunsigned 8 2(2) >> 2(2) = 0(0)\nunsigned 8 2(2) >> 3(3) = 0(0)\nunsigned 8 2(2) >> 4(4) = 0(0)\nunsigned 8 2(2) >> 5(5) = 0(0)\nunsigned 8 2(2) >> 6(6) = 0(0)\nunsigned 8 2(2) >> 7(7) = 0(0)\nunsigned 8 2(2) >> 8(8) = 0(0)\nunsigned 8 2(2) >> 9(9) = 0(0)\nunsigned 8 2(2) >> 10(a) = 0(0)\nunsigned 8 2(2) >> 11(b) = 0(0)\nunsigned 8 2(2) >> 12(c) = 0(0)\nunsigned 8 2(2) >> 13(d) = 0(0)\nunsigned 8 2(2) >> 14(e) = 0(0)\nunsigned 8 2(2) >> 15(f) = 0(0)\nunsigned 8 2(2) >> 16(10) = 0(0)\nunsigned 8 2(2) >> 17(11) = 0(0)\nunsigned 8 2(2) >> 18(12) = 0(0)\nunsigned 8 2(2) >> 19(13) = 0(0)\nunsigned 8 2(2) >> 20(14) = 0(0)\nunsigned 8 2(2) >> 21(15) = 0(0)\nunsigned 8 2(2) >> 22(16) = 0(0)\nunsigned 8 2(2) >> 23(17) = 0(0)\nunsigned 8 2(2) >> 24(18) = 0(0)\nunsigned 8 2(2) >> 25(19) = 0(0)\nunsigned 8 2(2) >> 26(1a) = 0(0)\nunsigned 8 2(2) >> 27(1b) = 0(0)\nunsigned 8 2(2) >> 28(1c) = 0(0)\nunsigned 8 2(2) >> 29(1d) = 0(0)\nunsigned 8 2(2) >> 30(1e) = 0(0)\nunsigned 8 2(2) >> 31(1f) = 0(0)\nunsigned 8 2(2) >> 32(20) = 2(2)\nunsigned 8 2(2) >> 33(21) = 1(1)\nunsigned 8 2(2) >> 34(22) = 0(0)\nunsigned 8 2(2) >> 35(23) = 0(0)\nunsigned 8 2(2) >> 36(24) = 0(0)\nunsigned 8 2(2) >> 37(25) = 0(0)\nunsigned 8 2(2) >> 38(26) = 0(0)\nunsigned 8 2(2) >> 39(27) = 0(0)\nunsigned 8 2(2) >> 40(28) = 0(0)\nunsigned 8 2(2) >> 41(29) = 0(0)\nunsigned 8 2(2) >> 42(2a) = 0(0)\nunsigned 8 2(2) >> 43(2b) = 0(0)\nunsigned 8 2(2) >> 44(2c) = 0(0)\nunsigned 8 2(2) >> 45(2d) = 0(0)\nunsigned 8 2(2) >> 46(2e) = 0(0)\nunsigned 8 2(2) >> 47(2f) = 0(0)\nunsigned 8 2(2) >> 48(30) = 0(0)\nunsigned 8 2(2) >> 49(31) = 0(0)\nunsigned 8 2(2) >> 50(32) = 0(0)\nunsigned 8 2(2) >> 51(33) = 0(0)\nunsigned 8 2(2) >> 52(34) = 0(0)\nunsigned 8 2(2) >> 53(35) = 0(0)\nunsigned 8 2(2) >> 54(36) = 0(0)\nunsigned 8 2(2) >> 55(37) = 0(0)\nunsigned 8 2(2) >> 56(38) = 0(0)\nunsigned 8 2(2) >> 57(39) = 0(0)\nunsigned 8 2(2) >> 58(3a) = 0(0)\nunsigned 8 2(2) >> 59(3b) = 0(0)\nunsigned 8 2(2) >> 60(3c) = 0(0)\nunsigned 8 2(2) >> 61(3d) = 0(0)\nunsigned 8 2(2) >> 62(3e) = 0(0)\nunsigned 8 2(2) >> 63(3f) = 0(0)\nunsigned 8 2(2) >> 64(40) = 2(2)\nunsigned 8 2(2) >> 65(41) = 1(1)\nunsigned 8 2(2) >> 66(42) = 0(0)\nunsigned 8 2(2) >> 67(43) = 0(0)\nunsigned 8 2(2) >> 68(44) = 0(0)\nunsigned 8 2(2) >> 69(45) = 0(0)\nunsigned 8 2(2) >> 70(46) = 0(0)\nunsigned 8 2(2) >> 71(47) = 0(0)\nunsigned 8 2(2) >> 72(48) = 0(0)\nunsigned 8 2(2) >> 73(49) = 0(0)\nunsigned 8 2(2) >> 74(4a) = 0(0)\nunsigned 8 2(2) >> 75(4b) = 0(0)\nunsigned 8 2(2) >> 76(4c) = 0(0)\nunsigned 8 2(2) >> 77(4d) = 0(0)\nunsigned 8 2(2) >> 78(4e) = 0(0)\nunsigned 8 2(2) >> 79(4f) = 0(0)\nunsigned 8 2(2) >> 80(50) = 0(0)\nunsigned 8 2(2) >> 81(51) = 0(0)\nunsigned 8 2(2) >> 82(52) = 0(0)\nunsigned 8 2(2) >> 83(53) = 0(0)\nunsigned 8 2(2) >> 84(54) = 0(0)\nunsigned 8 2(2) >> 85(55) = 0(0)\nunsigned 8 2(2) >> 86(56) = 0(0)\nunsigned 8 2(2) >> 87(57) = 0(0)\nunsigned 8 2(2) >> 88(58) = 0(0)\nunsigned 8 2(2) >> 89(59) = 0(0)\nunsigned 8 2(2) >> 90(5a) = 0(0)\nunsigned 8 2(2) >> 91(5b) = 0(0)\nunsigned 8 2(2) >> 92(5c) = 0(0)\nunsigned 8 2(2) >> 93(5d) = 0(0)\nunsigned 8 2(2) >> 94(5e) = 0(0)\nunsigned 8 2(2) >> 95(5f) = 0(0)\nunsigned 8 2(2) >> 96(60) = 2(2)\nunsigned 8 2(2) >> 97(61) = 1(1)\nunsigned 8 2(2) >> 98(62) = 0(0)\nunsigned 8 2(2) >> 99(63) = 0(0)\nunsigned 8 2(2) >> 100(64) = 0(0)\nunsigned 8 2(2) >> 101(65) = 0(0)\nunsigned 8 2(2) >> 102(66) = 0(0)\nunsigned 8 2(2) >> 103(67) = 0(0)\nunsigned 8 2(2) >> 104(68) = 0(0)\nunsigned 8 2(2) >> 105(69) = 0(0)\nunsigned 8 2(2) >> 106(6a) = 0(0)\nunsigned 8 2(2) >> 107(6b) = 0(0)\nunsigned 8 2(2) >> 108(6c) = 0(0)\nunsigned 8 2(2) >> 109(6d) = 0(0)\nunsigned 8 2(2) >> 110(6e) = 0(0)\nunsigned 8 2(2) >> 111(6f) = 0(0)\nunsigned 8 2(2) >> 112(70) = 0(0)\nunsigned 8 2(2) >> 113(71) = 0(0)\nunsigned 8 2(2) >> 114(72) = 0(0)\nunsigned 8 2(2) >> 115(73) = 0(0)\nunsigned 8 2(2) >> 116(74) = 0(0)\nunsigned 8 2(2) >> 117(75) = 0(0)\nunsigned 8 2(2) >> 118(76) = 0(0)\nunsigned 8 2(2) >> 119(77) = 0(0)\nunsigned 8 2(2) >> 120(78) = 0(0)\nunsigned 8 2(2) >> 121(79) = 0(0)\nunsigned 8 2(2) >> 122(7a) = 0(0)\nunsigned 8 2(2) >> 123(7b) = 0(0)\nunsigned 8 2(2) >> 124(7c) = 0(0)\nunsigned 8 2(2) >> 125(7d) = 0(0)\nunsigned 8 2(2) >> 126(7e) = 0(0)\nunsigned 8 2(2) >> 127(7f) = 0(0)\nunsigned 8 3(3) >> -128(ffffff80) = 3(3)\nunsigned 8 3(3) >> -127(ffffff81) = 1(1)\nunsigned 8 3(3) >> -126(ffffff82) = 0(0)\nunsigned 8 3(3) >> -125(ffffff83) = 0(0)\nunsigned 8 3(3) >> -124(ffffff84) = 0(0)\nunsigned 8 3(3) >> -123(ffffff85) = 0(0)\nunsigned 8 3(3) >> -122(ffffff86) = 0(0)\nunsigned 8 3(3) >> -121(ffffff87) = 0(0)\nunsigned 8 3(3) >> -120(ffffff88) = 0(0)\nunsigned 8 3(3) >> -119(ffffff89) = 0(0)\nunsigned 8 3(3) >> -118(ffffff8a) = 0(0)\nunsigned 8 3(3) >> -117(ffffff8b) = 0(0)\nunsigned 8 3(3) >> -116(ffffff8c) = 0(0)\nunsigned 8 3(3) >> -115(ffffff8d) = 0(0)\nunsigned 8 3(3) >> -114(ffffff8e) = 0(0)\nunsigned 8 3(3) >> -113(ffffff8f) = 0(0)\nunsigned 8 3(3) >> -112(ffffff90) = 0(0)\nunsigned 8 3(3) >> -111(ffffff91) = 0(0)\nunsigned 8 3(3) >> -110(ffffff92) = 0(0)\nunsigned 8 3(3) >> -109(ffffff93) = 0(0)\nunsigned 8 3(3) >> -108(ffffff94) = 0(0)\nunsigned 8 3(3) >> -107(ffffff95) = 0(0)\nunsigned 8 3(3) >> -106(ffffff96) = 0(0)\nunsigned 8 3(3) >> -105(ffffff97) = 0(0)\nunsigned 8 3(3) >> -104(ffffff98) = 0(0)\nunsigned 8 3(3) >> -103(ffffff99) = 0(0)\nunsigned 8 3(3) >> -102(ffffff9a) = 0(0)\nunsigned 8 3(3) >> -101(ffffff9b) = 0(0)\nunsigned 8 3(3) >> -100(ffffff9c) = 0(0)\nunsigned 8 3(3) >> -99(ffffff9d) = 0(0)\nunsigned 8 3(3) >> -98(ffffff9e) = 0(0)\nunsigned 8 3(3) >> -97(ffffff9f) = 0(0)\nunsigned 8 3(3) >> -96(ffffffa0) = 3(3)\nunsigned 8 3(3) >> -95(ffffffa1) = 1(1)\nunsigned 8 3(3) >> -94(ffffffa2) = 0(0)\nunsigned 8 3(3) >> -93(ffffffa3) = 0(0)\nunsigned 8 3(3) >> -92(ffffffa4) = 0(0)\nunsigned 8 3(3) >> -91(ffffffa5) = 0(0)\nunsigned 8 3(3) >> -90(ffffffa6) = 0(0)\nunsigned 8 3(3) >> -89(ffffffa7) = 0(0)\nunsigned 8 3(3) >> -88(ffffffa8) = 0(0)\nunsigned 8 3(3) >> -87(ffffffa9) = 0(0)\nunsigned 8 3(3) >> -86(ffffffaa) = 0(0)\nunsigned 8 3(3) >> -85(ffffffab) = 0(0)\nunsigned 8 3(3) >> -84(ffffffac) = 0(0)\nunsigned 8 3(3) >> -83(ffffffad) = 0(0)\nunsigned 8 3(3) >> -82(ffffffae) = 0(0)\nunsigned 8 3(3) >> -81(ffffffaf) = 0(0)\nunsigned 8 3(3) >> -80(ffffffb0) = 0(0)\nunsigned 8 3(3) >> -79(ffffffb1) = 0(0)\nunsigned 8 3(3) >> -78(ffffffb2) = 0(0)\nunsigned 8 3(3) >> -77(ffffffb3) = 0(0)\nunsigned 8 3(3) >> -76(ffffffb4) = 0(0)\nunsigned 8 3(3) >> -75(ffffffb5) = 0(0)\nunsigned 8 3(3) >> -74(ffffffb6) = 0(0)\nunsigned 8 3(3) >> -73(ffffffb7) = 0(0)\nunsigned 8 3(3) >> -72(ffffffb8) = 0(0)\nunsigned 8 3(3) >> -71(ffffffb9) = 0(0)\nunsigned 8 3(3) >> -70(ffffffba) = 0(0)\nunsigned 8 3(3) >> -69(ffffffbb) = 0(0)\nunsigned 8 3(3) >> -68(ffffffbc) = 0(0)\nunsigned 8 3(3) >> -67(ffffffbd) = 0(0)\nunsigned 8 3(3) >> -66(ffffffbe) = 0(0)\nunsigned 8 3(3) >> -65(ffffffbf) = 0(0)\nunsigned 8 3(3) >> -64(ffffffc0) = 3(3)\nunsigned 8 3(3) >> -63(ffffffc1) = 1(1)\nunsigned 8 3(3) >> -62(ffffffc2) = 0(0)\nunsigned 8 3(3) >> -61(ffffffc3) = 0(0)\nunsigned 8 3(3) >> -60(ffffffc4) = 0(0)\nunsigned 8 3(3) >> -59(ffffffc5) = 0(0)\nunsigned 8 3(3) >> -58(ffffffc6) = 0(0)\nunsigned 8 3(3) >> -57(ffffffc7) = 0(0)\nunsigned 8 3(3) >> -56(ffffffc8) = 0(0)\nunsigned 8 3(3) >> -55(ffffffc9) = 0(0)\nunsigned 8 3(3) >> -54(ffffffca) = 0(0)\nunsigned 8 3(3) >> -53(ffffffcb) = 0(0)\nunsigned 8 3(3) >> -52(ffffffcc) = 0(0)\nunsigned 8 3(3) >> -51(ffffffcd) = 0(0)\nunsigned 8 3(3) >> -50(ffffffce) = 0(0)\nunsigned 8 3(3) >> -49(ffffffcf) = 0(0)\nunsigned 8 3(3) >> -48(ffffffd0) = 0(0)\nunsigned 8 3(3) >> -47(ffffffd1) = 0(0)\nunsigned 8 3(3) >> -46(ffffffd2) = 0(0)\nunsigned 8 3(3) >> -45(ffffffd3) = 0(0)\nunsigned 8 3(3) >> -44(ffffffd4) = 0(0)\nunsigned 8 3(3) >> -43(ffffffd5) = 0(0)\nunsigned 8 3(3) >> -42(ffffffd6) = 0(0)\nunsigned 8 3(3) >> -41(ffffffd7) = 0(0)\nunsigned 8 3(3) >> -40(ffffffd8) = 0(0)\nunsigned 8 3(3) >> -39(ffffffd9) = 0(0)\nunsigned 8 3(3) >> -38(ffffffda) = 0(0)\nunsigned 8 3(3) >> -37(ffffffdb) = 0(0)\nunsigned 8 3(3) >> -36(ffffffdc) = 0(0)\nunsigned 8 3(3) >> -35(ffffffdd) = 0(0)\nunsigned 8 3(3) >> -34(ffffffde) = 0(0)\nunsigned 8 3(3) >> -33(ffffffdf) = 0(0)\nunsigned 8 3(3) >> -32(ffffffe0) = 3(3)\nunsigned 8 3(3) >> -31(ffffffe1) = 1(1)\nunsigned 8 3(3) >> -30(ffffffe2) = 0(0)\nunsigned 8 3(3) >> -29(ffffffe3) = 0(0)\nunsigned 8 3(3) >> -28(ffffffe4) = 0(0)\nunsigned 8 3(3) >> -27(ffffffe5) = 0(0)\nunsigned 8 3(3) >> -26(ffffffe6) = 0(0)\nunsigned 8 3(3) >> -25(ffffffe7) = 0(0)\nunsigned 8 3(3) >> -24(ffffffe8) = 0(0)\nunsigned 8 3(3) >> -23(ffffffe9) = 0(0)\nunsigned 8 3(3) >> -22(ffffffea) = 0(0)\nunsigned 8 3(3) >> -21(ffffffeb) = 0(0)\nunsigned 8 3(3) >> -20(ffffffec) = 0(0)\nunsigned 8 3(3) >> -19(ffffffed) = 0(0)\nunsigned 8 3(3) >> -18(ffffffee) = 0(0)\nunsigned 8 3(3) >> -17(ffffffef) = 0(0)\nunsigned 8 3(3) >> -16(fffffff0) = 0(0)\nunsigned 8 3(3) >> -15(fffffff1) = 0(0)\nunsigned 8 3(3) >> -14(fffffff2) = 0(0)\nunsigned 8 3(3) >> -13(fffffff3) = 0(0)\nunsigned 8 3(3) >> -12(fffffff4) = 0(0)\nunsigned 8 3(3) >> -11(fffffff5) = 0(0)\nunsigned 8 3(3) >> -10(fffffff6) = 0(0)\nunsigned 8 3(3) >> -9(fffffff7) = 0(0)\nunsigned 8 3(3) >> -8(fffffff8) = 0(0)\nunsigned 8 3(3) >> -7(fffffff9) = 0(0)\nunsigned 8 3(3) >> -6(fffffffa) = 0(0)\nunsigned 8 3(3) >> -5(fffffffb) = 0(0)\nunsigned 8 3(3) >> -4(fffffffc) = 0(0)\nunsigned 8 3(3) >> -3(fffffffd) = 0(0)\nunsigned 8 3(3) >> -2(fffffffe) = 0(0)\nunsigned 8 3(3) >> -1(ffffffff) = 0(0)\nunsigned 8 3(3) >> 0(0) = 3(3)\nunsigned 8 3(3) >> 1(1) = 1(1)\nunsigned 8 3(3) >> 2(2) = 0(0)\nunsigned 8 3(3) >> 3(3) = 0(0)\nunsigned 8 3(3) >> 4(4) = 0(0)\nunsigned 8 3(3) >> 5(5) = 0(0)\nunsigned 8 3(3) >> 6(6) = 0(0)\nunsigned 8 3(3) >> 7(7) = 0(0)\nunsigned 8 3(3) >> 8(8) = 0(0)\nunsigned 8 3(3) >> 9(9) = 0(0)\nunsigned 8 3(3) >> 10(a) = 0(0)\nunsigned 8 3(3) >> 11(b) = 0(0)\nunsigned 8 3(3) >> 12(c) = 0(0)\nunsigned 8 3(3) >> 13(d) = 0(0)\nunsigned 8 3(3) >> 14(e) = 0(0)\nunsigned 8 3(3) >> 15(f) = 0(0)\nunsigned 8 3(3) >> 16(10) = 0(0)\nunsigned 8 3(3) >> 17(11) = 0(0)\nunsigned 8 3(3) >> 18(12) = 0(0)\nunsigned 8 3(3) >> 19(13) = 0(0)\nunsigned 8 3(3) >> 20(14) = 0(0)\nunsigned 8 3(3) >> 21(15) = 0(0)\nunsigned 8 3(3) >> 22(16) = 0(0)\nunsigned 8 3(3) >> 23(17) = 0(0)\nunsigned 8 3(3) >> 24(18) = 0(0)\nunsigned 8 3(3) >> 25(19) = 0(0)\nunsigned 8 3(3) >> 26(1a) = 0(0)\nunsigned 8 3(3) >> 27(1b) = 0(0)\nunsigned 8 3(3) >> 28(1c) = 0(0)\nunsigned 8 3(3) >> 29(1d) = 0(0)\nunsigned 8 3(3) >> 30(1e) = 0(0)\nunsigned 8 3(3) >> 31(1f) = 0(0)\nunsigned 8 3(3) >> 32(20) = 3(3)\nunsigned 8 3(3) >> 33(21) = 1(1)\nunsigned 8 3(3) >> 34(22) = 0(0)\nunsigned 8 3(3) >> 35(23) = 0(0)\nunsigned 8 3(3) >> 36(24) = 0(0)\nunsigned 8 3(3) >> 37(25) = 0(0)\nunsigned 8 3(3) >> 38(26) = 0(0)\nunsigned 8 3(3) >> 39(27) = 0(0)\nunsigned 8 3(3) >> 40(28) = 0(0)\nunsigned 8 3(3) >> 41(29) = 0(0)\nunsigned 8 3(3) >> 42(2a) = 0(0)\nunsigned 8 3(3) >> 43(2b) = 0(0)\nunsigned 8 3(3) >> 44(2c) = 0(0)\nunsigned 8 3(3) >> 45(2d) = 0(0)\nunsigned 8 3(3) >> 46(2e) = 0(0)\nunsigned 8 3(3) >> 47(2f) = 0(0)\nunsigned 8 3(3) >> 48(30) = 0(0)\nunsigned 8 3(3) >> 49(31) = 0(0)\nunsigned 8 3(3) >> 50(32) = 0(0)\nunsigned 8 3(3) >> 51(33) = 0(0)\nunsigned 8 3(3) >> 52(34) = 0(0)\nunsigned 8 3(3) >> 53(35) = 0(0)\nunsigned 8 3(3) >> 54(36) = 0(0)\nunsigned 8 3(3) >> 55(37) = 0(0)\nunsigned 8 3(3) >> 56(38) = 0(0)\nunsigned 8 3(3) >> 57(39) = 0(0)\nunsigned 8 3(3) >> 58(3a) = 0(0)\nunsigned 8 3(3) >> 59(3b) = 0(0)\nunsigned 8 3(3) >> 60(3c) = 0(0)\nunsigned 8 3(3) >> 61(3d) = 0(0)\nunsigned 8 3(3) >> 62(3e) = 0(0)\nunsigned 8 3(3) >> 63(3f) = 0(0)\nunsigned 8 3(3) >> 64(40) = 3(3)\nunsigned 8 3(3) >> 65(41) = 1(1)\nunsigned 8 3(3) >> 66(42) = 0(0)\nunsigned 8 3(3) >> 67(43) = 0(0)\nunsigned 8 3(3) >> 68(44) = 0(0)\nunsigned 8 3(3) >> 69(45) = 0(0)\nunsigned 8 3(3) >> 70(46) = 0(0)\nunsigned 8 3(3) >> 71(47) = 0(0)\nunsigned 8 3(3) >> 72(48) = 0(0)\nunsigned 8 3(3) >> 73(49) = 0(0)\nunsigned 8 3(3) >> 74(4a) = 0(0)\nunsigned 8 3(3) >> 75(4b) = 0(0)\nunsigned 8 3(3) >> 76(4c) = 0(0)\nunsigned 8 3(3) >> 77(4d) = 0(0)\nunsigned 8 3(3) >> 78(4e) = 0(0)\nunsigned 8 3(3) >> 79(4f) = 0(0)\nunsigned 8 3(3) >> 80(50) = 0(0)\nunsigned 8 3(3) >> 81(51) = 0(0)\nunsigned 8 3(3) >> 82(52) = 0(0)\nunsigned 8 3(3) >> 83(53) = 0(0)\nunsigned 8 3(3) >> 84(54) = 0(0)\nunsigned 8 3(3) >> 85(55) = 0(0)\nunsigned 8 3(3) >> 86(56) = 0(0)\nunsigned 8 3(3) >> 87(57) = 0(0)\nunsigned 8 3(3) >> 88(58) = 0(0)\nunsigned 8 3(3) >> 89(59) = 0(0)\nunsigned 8 3(3) >> 90(5a) = 0(0)\nunsigned 8 3(3) >> 91(5b) = 0(0)\nunsigned 8 3(3) >> 92(5c) = 0(0)\nunsigned 8 3(3) >> 93(5d) = 0(0)\nunsigned 8 3(3) >> 94(5e) = 0(0)\nunsigned 8 3(3) >> 95(5f) = 0(0)\nunsigned 8 3(3) >> 96(60) = 3(3)\nunsigned 8 3(3) >> 97(61) = 1(1)\nunsigned 8 3(3) >> 98(62) = 0(0)\nunsigned 8 3(3) >> 99(63) = 0(0)\nunsigned 8 3(3) >> 100(64) = 0(0)\nunsigned 8 3(3) >> 101(65) = 0(0)\nunsigned 8 3(3) >> 102(66) = 0(0)\nunsigned 8 3(3) >> 103(67) = 0(0)\nunsigned 8 3(3) >> 104(68) = 0(0)\nunsigned 8 3(3) >> 105(69) = 0(0)\nunsigned 8 3(3) >> 106(6a) = 0(0)\nunsigned 8 3(3) >> 107(6b) = 0(0)\nunsigned 8 3(3) >> 108(6c) = 0(0)\nunsigned 8 3(3) >> 109(6d) = 0(0)\nunsigned 8 3(3) >> 110(6e) = 0(0)\nunsigned 8 3(3) >> 111(6f) = 0(0)\nunsigned 8 3(3) >> 112(70) = 0(0)\nunsigned 8 3(3) >> 113(71) = 0(0)\nunsigned 8 3(3) >> 114(72) = 0(0)\nunsigned 8 3(3) >> 115(73) = 0(0)\nunsigned 8 3(3) >> 116(74) = 0(0)\nunsigned 8 3(3) >> 117(75) = 0(0)\nunsigned 8 3(3) >> 118(76) = 0(0)\nunsigned 8 3(3) >> 119(77) = 0(0)\nunsigned 8 3(3) >> 120(78) = 0(0)\nunsigned 8 3(3) >> 121(79) = 0(0)\nunsigned 8 3(3) >> 122(7a) = 0(0)\nunsigned 8 3(3) >> 123(7b) = 0(0)\nunsigned 8 3(3) >> 124(7c) = 0(0)\nunsigned 8 3(3) >> 125(7d) = 0(0)\nunsigned 8 3(3) >> 126(7e) = 0(0)\nunsigned 8 3(3) >> 127(7f) = 0(0)\nunsigned 8 4(4) >> -128(ffffff80) = 4(4)\nunsigned 8 4(4) >> -127(ffffff81) = 2(2)\nunsigned 8 4(4) >> -126(ffffff82) = 1(1)\nunsigned 8 4(4) >> -125(ffffff83) = 0(0)\nunsigned 8 4(4) >> -124(ffffff84) = 0(0)\nunsigned 8 4(4) >> -123(ffffff85) = 0(0)\nunsigned 8 4(4) >> -122(ffffff86) = 0(0)\nunsigned 8 4(4) >> -121(ffffff87) = 0(0)\nunsigned 8 4(4) >> -120(ffffff88) = 0(0)\nunsigned 8 4(4) >> -119(ffffff89) = 0(0)\nunsigned 8 4(4) >> -118(ffffff8a) = 0(0)\nunsigned 8 4(4) >> -117(ffffff8b) = 0(0)\nunsigned 8 4(4) >> -116(ffffff8c) = 0(0)\nunsigned 8 4(4) >> -115(ffffff8d) = 0(0)\nunsigned 8 4(4) >> -114(ffffff8e) = 0(0)\nunsigned 8 4(4) >> -113(ffffff8f) = 0(0)\nunsigned 8 4(4) >> -112(ffffff90) = 0(0)\nunsigned 8 4(4) >> -111(ffffff91) = 0(0)\nunsigned 8 4(4) >> -110(ffffff92) = 0(0)\nunsigned 8 4(4) >> -109(ffffff93) = 0(0)\nunsigned 8 4(4) >> -108(ffffff94) = 0(0)\nunsigned 8 4(4) >> -107(ffffff95) = 0(0)\nunsigned 8 4(4) >> -106(ffffff96) = 0(0)\nunsigned 8 4(4) >> -105(ffffff97) = 0(0)\nunsigned 8 4(4) >> -104(ffffff98) = 0(0)\nunsigned 8 4(4) >> -103(ffffff99) = 0(0)\nunsigned 8 4(4) >> -102(ffffff9a) = 0(0)\nunsigned 8 4(4) >> -101(ffffff9b) = 0(0)\nunsigned 8 4(4) >> -100(ffffff9c) = 0(0)\nunsigned 8 4(4) >> -99(ffffff9d) = 0(0)\nunsigned 8 4(4) >> -98(ffffff9e) = 0(0)\nunsigned 8 4(4) >> -97(ffffff9f) = 0(0)\nunsigned 8 4(4) >> -96(ffffffa0) = 4(4)\nunsigned 8 4(4) >> -95(ffffffa1) = 2(2)\nunsigned 8 4(4) >> -94(ffffffa2) = 1(1)\nunsigned 8 4(4) >> -93(ffffffa3) = 0(0)\nunsigned 8 4(4) >> -92(ffffffa4) = 0(0)\nunsigned 8 4(4) >> -91(ffffffa5) = 0(0)\nunsigned 8 4(4) >> -90(ffffffa6) = 0(0)\nunsigned 8 4(4) >> -89(ffffffa7) = 0(0)\nunsigned 8 4(4) >> -88(ffffffa8) = 0(0)\nunsigned 8 4(4) >> -87(ffffffa9) = 0(0)\nunsigned 8 4(4) >> -86(ffffffaa) = 0(0)\nunsigned 8 4(4) >> -85(ffffffab) = 0(0)\nunsigned 8 4(4) >> -84(ffffffac) = 0(0)\nunsigned 8 4(4) >> -83(ffffffad) = 0(0)\nunsigned 8 4(4) >> -82(ffffffae) = 0(0)\nunsigned 8 4(4) >> -81(ffffffaf) = 0(0)\nunsigned 8 4(4) >> -80(ffffffb0) = 0(0)\nunsigned 8 4(4) >> -79(ffffffb1) = 0(0)\nunsigned 8 4(4) >> -78(ffffffb2) = 0(0)\nunsigned 8 4(4) >> -77(ffffffb3) = 0(0)\nunsigned 8 4(4) >> -76(ffffffb4) = 0(0)\nunsigned 8 4(4) >> -75(ffffffb5) = 0(0)\nunsigned 8 4(4) >> -74(ffffffb6) = 0(0)\nunsigned 8 4(4) >> -73(ffffffb7) = 0(0)\nunsigned 8 4(4) >> -72(ffffffb8) = 0(0)\nunsigned 8 4(4) >> -71(ffffffb9) = 0(0)\nunsigned 8 4(4) >> -70(ffffffba) = 0(0)\nunsigned 8 4(4) >> -69(ffffffbb) = 0(0)\nunsigned 8 4(4) >> -68(ffffffbc) = 0(0)\nunsigned 8 4(4) >> -67(ffffffbd) = 0(0)\nunsigned 8 4(4) >> -66(ffffffbe) = 0(0)\nunsigned 8 4(4) >> -65(ffffffbf) = 0(0)\nunsigned 8 4(4) >> -64(ffffffc0) = 4(4)\nunsigned 8 4(4) >> -63(ffffffc1) = 2(2)\nunsigned 8 4(4) >> -62(ffffffc2) = 1(1)\nunsigned 8 4(4) >> -61(ffffffc3) = 0(0)\nunsigned 8 4(4) >> -60(ffffffc4) = 0(0)\nunsigned 8 4(4) >> -59(ffffffc5) = 0(0)\nunsigned 8 4(4) >> -58(ffffffc6) = 0(0)\nunsigned 8 4(4) >> -57(ffffffc7) = 0(0)\nunsigned 8 4(4) >> -56(ffffffc8) = 0(0)\nunsigned 8 4(4) >> -55(ffffffc9) = 0(0)\nunsigned 8 4(4) >> -54(ffffffca) = 0(0)\nunsigned 8 4(4) >> -53(ffffffcb) = 0(0)\nunsigned 8 4(4) >> -52(ffffffcc) = 0(0)\nunsigned 8 4(4) >> -51(ffffffcd) = 0(0)\nunsigned 8 4(4) >> -50(ffffffce) = 0(0)\nunsigned 8 4(4) >> -49(ffffffcf) = 0(0)\nunsigned 8 4(4) >> -48(ffffffd0) = 0(0)\nunsigned 8 4(4) >> -47(ffffffd1) = 0(0)\nunsigned 8 4(4) >> -46(ffffffd2) = 0(0)\nunsigned 8 4(4) >> -45(ffffffd3) = 0(0)\nunsigned 8 4(4) >> -44(ffffffd4) = 0(0)\nunsigned 8 4(4) >> -43(ffffffd5) = 0(0)\nunsigned 8 4(4) >> -42(ffffffd6) = 0(0)\nunsigned 8 4(4) >> -41(ffffffd7) = 0(0)\nunsigned 8 4(4) >> -40(ffffffd8) = 0(0)\nunsigned 8 4(4) >> -39(ffffffd9) = 0(0)\nunsigned 8 4(4) >> -38(ffffffda) = 0(0)\nunsigned 8 4(4) >> -37(ffffffdb) = 0(0)\nunsigned 8 4(4) >> -36(ffffffdc) = 0(0)\nunsigned 8 4(4) >> -35(ffffffdd) = 0(0)\nunsigned 8 4(4) >> -34(ffffffde) = 0(0)\nunsigned 8 4(4) >> -33(ffffffdf) = 0(0)\nunsigned 8 4(4) >> -32(ffffffe0) = 4(4)\nunsigned 8 4(4) >> -31(ffffffe1) = 2(2)\nunsigned 8 4(4) >> -30(ffffffe2) = 1(1)\nunsigned 8 4(4) >> -29(ffffffe3) = 0(0)\nunsigned 8 4(4) >> -28(ffffffe4) = 0(0)\nunsigned 8 4(4) >> -27(ffffffe5) = 0(0)\nunsigned 8 4(4) >> -26(ffffffe6) = 0(0)\nunsigned 8 4(4) >> -25(ffffffe7) = 0(0)\nunsigned 8 4(4) >> -24(ffffffe8) = 0(0)\nunsigned 8 4(4) >> -23(ffffffe9) = 0(0)\nunsigned 8 4(4) >> -22(ffffffea) = 0(0)\nunsigned 8 4(4) >> -21(ffffffeb) = 0(0)\nunsigned 8 4(4) >> -20(ffffffec) = 0(0)\nunsigned 8 4(4) >> -19(ffffffed) = 0(0)\nunsigned 8 4(4) >> -18(ffffffee) = 0(0)\nunsigned 8 4(4) >> -17(ffffffef) = 0(0)\nunsigned 8 4(4) >> -16(fffffff0) = 0(0)\nunsigned 8 4(4) >> -15(fffffff1) = 0(0)\nunsigned 8 4(4) >> -14(fffffff2) = 0(0)\nunsigned 8 4(4) >> -13(fffffff3) = 0(0)\nunsigned 8 4(4) >> -12(fffffff4) = 0(0)\nunsigned 8 4(4) >> -11(fffffff5) = 0(0)\nunsigned 8 4(4) >> -10(fffffff6) = 0(0)\nunsigned 8 4(4) >> -9(fffffff7) = 0(0)\nunsigned 8 4(4) >> -8(fffffff8) = 0(0)\nunsigned 8 4(4) >> -7(fffffff9) = 0(0)\nunsigned 8 4(4) >> -6(fffffffa) = 0(0)\nunsigned 8 4(4) >> -5(fffffffb) = 0(0)\nunsigned 8 4(4) >> -4(fffffffc) = 0(0)\nunsigned 8 4(4) >> -3(fffffffd) = 0(0)\nunsigned 8 4(4) >> -2(fffffffe) = 0(0)\nunsigned 8 4(4) >> -1(ffffffff) = 0(0)\nunsigned 8 4(4) >> 0(0) = 4(4)\nunsigned 8 4(4) >> 1(1) = 2(2)\nunsigned 8 4(4) >> 2(2) = 1(1)\nunsigned 8 4(4) >> 3(3) = 0(0)\nunsigned 8 4(4) >> 4(4) = 0(0)\nunsigned 8 4(4) >> 5(5) = 0(0)\nunsigned 8 4(4) >> 6(6) = 0(0)\nunsigned 8 4(4) >> 7(7) = 0(0)\nunsigned 8 4(4) >> 8(8) = 0(0)\nunsigned 8 4(4) >> 9(9) = 0(0)\nunsigned 8 4(4) >> 10(a) = 0(0)\nunsigned 8 4(4) >> 11(b) = 0(0)\nunsigned 8 4(4) >> 12(c) = 0(0)\nunsigned 8 4(4) >> 13(d) = 0(0)\nunsigned 8 4(4) >> 14(e) = 0(0)\nunsigned 8 4(4) >> 15(f) = 0(0)\nunsigned 8 4(4) >> 16(10) = 0(0)\nunsigned 8 4(4) >> 17(11) = 0(0)\nunsigned 8 4(4) >> 18(12) = 0(0)\nunsigned 8 4(4) >> 19(13) = 0(0)\nunsigned 8 4(4) >> 20(14) = 0(0)\nunsigned 8 4(4) >> 21(15) = 0(0)\nunsigned 8 4(4) >> 22(16) = 0(0)\nunsigned 8 4(4) >> 23(17) = 0(0)\nunsigned 8 4(4) >> 24(18) = 0(0)\nunsigned 8 4(4) >> 25(19) = 0(0)\nunsigned 8 4(4) >> 26(1a) = 0(0)\nunsigned 8 4(4) >> 27(1b) = 0(0)\nunsigned 8 4(4) >> 28(1c) = 0(0)\nunsigned 8 4(4) >> 29(1d) = 0(0)\nunsigned 8 4(4) >> 30(1e) = 0(0)\nunsigned 8 4(4) >> 31(1f) = 0(0)\nunsigned 8 4(4) >> 32(20) = 4(4)\nunsigned 8 4(4) >> 33(21) = 2(2)\nunsigned 8 4(4) >> 34(22) = 1(1)\nunsigned 8 4(4) >> 35(23) = 0(0)\nunsigned 8 4(4) >> 36(24) = 0(0)\nunsigned 8 4(4) >> 37(25) = 0(0)\nunsigned 8 4(4) >> 38(26) = 0(0)\nunsigned 8 4(4) >> 39(27) = 0(0)\nunsigned 8 4(4) >> 40(28) = 0(0)\nunsigned 8 4(4) >> 41(29) = 0(0)\nunsigned 8 4(4) >> 42(2a) = 0(0)\nunsigned 8 4(4) >> 43(2b) = 0(0)\nunsigned 8 4(4) >> 44(2c) = 0(0)\nunsigned 8 4(4) >> 45(2d) = 0(0)\nunsigned 8 4(4) >> 46(2e) = 0(0)\nunsigned 8 4(4) >> 47(2f) = 0(0)\nunsigned 8 4(4) >> 48(30) = 0(0)\nunsigned 8 4(4) >> 49(31) = 0(0)\nunsigned 8 4(4) >> 50(32) = 0(0)\nunsigned 8 4(4) >> 51(33) = 0(0)\nunsigned 8 4(4) >> 52(34) = 0(0)\nunsigned 8 4(4) >> 53(35) = 0(0)\nunsigned 8 4(4) >> 54(36) = 0(0)\nunsigned 8 4(4) >> 55(37) = 0(0)\nunsigned 8 4(4) >> 56(38) = 0(0)\nunsigned 8 4(4) >> 57(39) = 0(0)\nunsigned 8 4(4) >> 58(3a) = 0(0)\nunsigned 8 4(4) >> 59(3b) = 0(0)\nunsigned 8 4(4) >> 60(3c) = 0(0)\nunsigned 8 4(4) >> 61(3d) = 0(0)\nunsigned 8 4(4) >> 62(3e) = 0(0)\nunsigned 8 4(4) >> 63(3f) = 0(0)\nunsigned 8 4(4) >> 64(40) = 4(4)\nunsigned 8 4(4) >> 65(41) = 2(2)\nunsigned 8 4(4) >> 66(42) = 1(1)\nunsigned 8 4(4) >> 67(43) = 0(0)\nunsigned 8 4(4) >> 68(44) = 0(0)\nunsigned 8 4(4) >> 69(45) = 0(0)\nunsigned 8 4(4) >> 70(46) = 0(0)\nunsigned 8 4(4) >> 71(47) = 0(0)\nunsigned 8 4(4) >> 72(48) = 0(0)\nunsigned 8 4(4) >> 73(49) = 0(0)\nunsigned 8 4(4) >> 74(4a) = 0(0)\nunsigned 8 4(4) >> 75(4b) = 0(0)\nunsigned 8 4(4) >> 76(4c) = 0(0)\nunsigned 8 4(4) >> 77(4d) = 0(0)\nunsigned 8 4(4) >> 78(4e) = 0(0)\nunsigned 8 4(4) >> 79(4f) = 0(0)\nunsigned 8 4(4) >> 80(50) = 0(0)\nunsigned 8 4(4) >> 81(51) = 0(0)\nunsigned 8 4(4) >> 82(52) = 0(0)\nunsigned 8 4(4) >> 83(53) = 0(0)\nunsigned 8 4(4) >> 84(54) = 0(0)\nunsigned 8 4(4) >> 85(55) = 0(0)\nunsigned 8 4(4) >> 86(56) = 0(0)\nunsigned 8 4(4) >> 87(57) = 0(0)\nunsigned 8 4(4) >> 88(58) = 0(0)\nunsigned 8 4(4) >> 89(59) = 0(0)\nunsigned 8 4(4) >> 90(5a) = 0(0)\nunsigned 8 4(4) >> 91(5b) = 0(0)\nunsigned 8 4(4) >> 92(5c) = 0(0)\nunsigned 8 4(4) >> 93(5d) = 0(0)\nunsigned 8 4(4) >> 94(5e) = 0(0)\nunsigned 8 4(4) >> 95(5f) = 0(0)\nunsigned 8 4(4) >> 96(60) = 4(4)\nunsigned 8 4(4) >> 97(61) = 2(2)\nunsigned 8 4(4) >> 98(62) = 1(1)\nunsigned 8 4(4) >> 99(63) = 0(0)\nunsigned 8 4(4) >> 100(64) = 0(0)\nunsigned 8 4(4) >> 101(65) = 0(0)\nunsigned 8 4(4) >> 102(66) = 0(0)\nunsigned 8 4(4) >> 103(67) = 0(0)\nunsigned 8 4(4) >> 104(68) = 0(0)\nunsigned 8 4(4) >> 105(69) = 0(0)\nunsigned 8 4(4) >> 106(6a) = 0(0)\nunsigned 8 4(4) >> 107(6b) = 0(0)\nunsigned 8 4(4) >> 108(6c) = 0(0)\nunsigned 8 4(4) >> 109(6d) = 0(0)\nunsigned 8 4(4) >> 110(6e) = 0(0)\nunsigned 8 4(4) >> 111(6f) = 0(0)\nunsigned 8 4(4) >> 112(70) = 0(0)\nunsigned 8 4(4) >> 113(71) = 0(0)\nunsigned 8 4(4) >> 114(72) = 0(0)\nunsigned 8 4(4) >> 115(73) = 0(0)\nunsigned 8 4(4) >> 116(74) = 0(0)\nunsigned 8 4(4) >> 117(75) = 0(0)\nunsigned 8 4(4) >> 118(76) = 0(0)\nunsigned 8 4(4) >> 119(77) = 0(0)\nunsigned 8 4(4) >> 120(78) = 0(0)\nunsigned 8 4(4) >> 121(79) = 0(0)\nunsigned 8 4(4) >> 122(7a) = 0(0)\nunsigned 8 4(4) >> 123(7b) = 0(0)\nunsigned 8 4(4) >> 124(7c) = 0(0)\nunsigned 8 4(4) >> 125(7d) = 0(0)\nunsigned 8 4(4) >> 126(7e) = 0(0)\nunsigned 8 4(4) >> 127(7f) = 0(0)\n  signed 8 -4(fffffffc) << -128(ffffff80) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -127(ffffff81) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -126(ffffff82) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -125(ffffff83) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -124(ffffff84) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -123(ffffff85) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -122(ffffff86) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -121(ffffff87) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -120(ffffff88) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -119(ffffff89) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -118(ffffff8a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -117(ffffff8b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -116(ffffff8c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -115(ffffff8d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -114(ffffff8e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -113(ffffff8f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -112(ffffff90) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -111(ffffff91) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -110(ffffff92) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -109(ffffff93) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -108(ffffff94) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -107(ffffff95) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -106(ffffff96) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -105(ffffff97) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -104(ffffff98) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -103(ffffff99) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -102(ffffff9a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -101(ffffff9b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -100(ffffff9c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -99(ffffff9d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -98(ffffff9e) = 0(0)\n  signed 8 -4(fffffffc) << -97(ffffff9f) = 0(0)\n  signed 8 -4(fffffffc) << -96(ffffffa0) = 0(0)\n  signed 8 -4(fffffffc) << -95(ffffffa1) = 0(0)\n  signed 8 -4(fffffffc) << -94(ffffffa2) = 0(0)\n  signed 8 -4(fffffffc) << -93(ffffffa3) = 0(0)\n  signed 8 -4(fffffffc) << -92(ffffffa4) = 0(0)\n  signed 8 -4(fffffffc) << -91(ffffffa5) = 0(0)\n  signed 8 -4(fffffffc) << -90(ffffffa6) = 0(0)\n  signed 8 -4(fffffffc) << -89(ffffffa7) = 0(0)\n  signed 8 -4(fffffffc) << -88(ffffffa8) = 0(0)\n  signed 8 -4(fffffffc) << -87(ffffffa9) = 0(0)\n  signed 8 -4(fffffffc) << -86(ffffffaa) = 0(0)\n  signed 8 -4(fffffffc) << -85(ffffffab) = 0(0)\n  signed 8 -4(fffffffc) << -84(ffffffac) = 0(0)\n  signed 8 -4(fffffffc) << -83(ffffffad) = 0(0)\n  signed 8 -4(fffffffc) << -82(ffffffae) = 0(0)\n  signed 8 -4(fffffffc) << -81(ffffffaf) = 0(0)\n  signed 8 -4(fffffffc) << -80(ffffffb0) = 0(0)\n  signed 8 -4(fffffffc) << -79(ffffffb1) = 0(0)\n  signed 8 -4(fffffffc) << -78(ffffffb2) = 0(0)\n  signed 8 -4(fffffffc) << -77(ffffffb3) = 0(0)\n  signed 8 -4(fffffffc) << -76(ffffffb4) = 0(0)\n  signed 8 -4(fffffffc) << -75(ffffffb5) = 0(0)\n  signed 8 -4(fffffffc) << -74(ffffffb6) = 0(0)\n  signed 8 -4(fffffffc) << -73(ffffffb7) = 0(0)\n  signed 8 -4(fffffffc) << -72(ffffffb8) = 0(0)\n  signed 8 -4(fffffffc) << -71(ffffffb9) = 0(0)\n  signed 8 -4(fffffffc) << -70(ffffffba) = 0(0)\n  signed 8 -4(fffffffc) << -69(ffffffbb) = 0(0)\n  signed 8 -4(fffffffc) << -68(ffffffbc) = 0(0)\n  signed 8 -4(fffffffc) << -67(ffffffbd) = 0(0)\n  signed 8 -4(fffffffc) << -66(ffffffbe) = 0(0)\n  signed 8 -4(fffffffc) << -65(ffffffbf) = 0(0)\n  signed 8 -4(fffffffc) << -64(ffffffc0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << -63(ffffffc1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << -62(ffffffc2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << -61(ffffffc3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << -60(ffffffc4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << -59(ffffffc5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << -58(ffffffc6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << -57(ffffffc7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << -56(ffffffc8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << -55(ffffffc9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << -54(ffffffca) = -4096(fffff000)\n  signed 8 -4(fffffffc) << -53(ffffffcb) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << -52(ffffffcc) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << -51(ffffffcd) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << -50(ffffffce) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << -49(ffffffcf) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << -48(ffffffd0) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << -47(ffffffd1) = -524288(fff80000)\n  signed 8 -4(fffffffc) << -46(ffffffd2) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << -45(ffffffd3) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << -44(ffffffd4) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << -43(ffffffd5) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << -42(ffffffd6) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << -41(ffffffd7) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << -40(ffffffd8) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << -39(ffffffd9) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << -38(ffffffda) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << -37(ffffffdb) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << -36(ffffffdc) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << -35(ffffffdd) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << -34(ffffffde) = 0(0)\n  signed 8 -4(fffffffc) << -33(ffffffdf) = 0(0)\n  signed 8 -4(fffffffc) << -32(ffffffe0) = 0(0)\n  signed 8 -4(fffffffc) << -31(ffffffe1) = 0(0)\n  signed 8 -4(fffffffc) << -30(ffffffe2) = 0(0)\n  signed 8 -4(fffffffc) << -29(ffffffe3) = 0(0)\n  signed 8 -4(fffffffc) << -28(ffffffe4) = 0(0)\n  signed 8 -4(fffffffc) << -27(ffffffe5) = 0(0)\n  signed 8 -4(fffffffc) << -26(ffffffe6) = 0(0)\n  signed 8 -4(fffffffc) << -25(ffffffe7) = 0(0)\n  signed 8 -4(fffffffc) << -24(ffffffe8) = 0(0)\n  signed 8 -4(fffffffc) << -23(ffffffe9) = 0(0)\n  signed 8 -4(fffffffc) << -22(ffffffea) = 0(0)\n  signed 8 -4(fffffffc) << -21(ffffffeb) = 0(0)\n  signed 8 -4(fffffffc) << -20(ffffffec) = 0(0)\n  signed 8 -4(fffffffc) << -19(ffffffed) = 0(0)\n  signed 8 -4(fffffffc) << -18(ffffffee) = 0(0)\n  signed 8 -4(fffffffc) << -17(ffffffef) = 0(0)\n  signed 8 -4(fffffffc) << -16(fffffff0) = 0(0)\n  signed 8 -4(fffffffc) << -15(fffffff1) = 0(0)\n  signed 8 -4(fffffffc) << -14(fffffff2) = 0(0)\n  signed 8 -4(fffffffc) << -13(fffffff3) = 0(0)\n  signed 8 -4(fffffffc) << -12(fffffff4) = 0(0)\n  signed 8 -4(fffffffc) << -11(fffffff5) = 0(0)\n  signed 8 -4(fffffffc) << -10(fffffff6) = 0(0)\n  signed 8 -4(fffffffc) << -9(fffffff7) = 0(0)\n  signed 8 -4(fffffffc) << -8(fffffff8) = 0(0)\n  signed 8 -4(fffffffc) << -7(fffffff9) = 0(0)\n  signed 8 -4(fffffffc) << -6(fffffffa) = 0(0)\n  signed 8 -4(fffffffc) << -5(fffffffb) = 0(0)\n  signed 8 -4(fffffffc) << -4(fffffffc) = 0(0)\n  signed 8 -4(fffffffc) << -3(fffffffd) = 0(0)\n  signed 8 -4(fffffffc) << -2(fffffffe) = 0(0)\n  signed 8 -4(fffffffc) << -1(ffffffff) = 0(0)\n  signed 8 -4(fffffffc) << 0(0) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 1(1) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 2(2) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 3(3) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 4(4) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 5(5) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 6(6) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 7(7) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 8(8) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 9(9) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 10(a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 11(b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 12(c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 13(d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 14(e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 15(f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 16(10) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 17(11) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 18(12) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 19(13) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 20(14) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 21(15) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 22(16) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 23(17) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 24(18) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 25(19) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 26(1a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 27(1b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 28(1c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 29(1d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 30(1e) = 0(0)\n  signed 8 -4(fffffffc) << 31(1f) = 0(0)\n  signed 8 -4(fffffffc) << 32(20) = 0(0)\n  signed 8 -4(fffffffc) << 33(21) = 0(0)\n  signed 8 -4(fffffffc) << 34(22) = 0(0)\n  signed 8 -4(fffffffc) << 35(23) = 0(0)\n  signed 8 -4(fffffffc) << 36(24) = 0(0)\n  signed 8 -4(fffffffc) << 37(25) = 0(0)\n  signed 8 -4(fffffffc) << 38(26) = 0(0)\n  signed 8 -4(fffffffc) << 39(27) = 0(0)\n  signed 8 -4(fffffffc) << 40(28) = 0(0)\n  signed 8 -4(fffffffc) << 41(29) = 0(0)\n  signed 8 -4(fffffffc) << 42(2a) = 0(0)\n  signed 8 -4(fffffffc) << 43(2b) = 0(0)\n  signed 8 -4(fffffffc) << 44(2c) = 0(0)\n  signed 8 -4(fffffffc) << 45(2d) = 0(0)\n  signed 8 -4(fffffffc) << 46(2e) = 0(0)\n  signed 8 -4(fffffffc) << 47(2f) = 0(0)\n  signed 8 -4(fffffffc) << 48(30) = 0(0)\n  signed 8 -4(fffffffc) << 49(31) = 0(0)\n  signed 8 -4(fffffffc) << 50(32) = 0(0)\n  signed 8 -4(fffffffc) << 51(33) = 0(0)\n  signed 8 -4(fffffffc) << 52(34) = 0(0)\n  signed 8 -4(fffffffc) << 53(35) = 0(0)\n  signed 8 -4(fffffffc) << 54(36) = 0(0)\n  signed 8 -4(fffffffc) << 55(37) = 0(0)\n  signed 8 -4(fffffffc) << 56(38) = 0(0)\n  signed 8 -4(fffffffc) << 57(39) = 0(0)\n  signed 8 -4(fffffffc) << 58(3a) = 0(0)\n  signed 8 -4(fffffffc) << 59(3b) = 0(0)\n  signed 8 -4(fffffffc) << 60(3c) = 0(0)\n  signed 8 -4(fffffffc) << 61(3d) = 0(0)\n  signed 8 -4(fffffffc) << 62(3e) = 0(0)\n  signed 8 -4(fffffffc) << 63(3f) = 0(0)\n  signed 8 -4(fffffffc) << 64(40) = -4(fffffffc)\n  signed 8 -4(fffffffc) << 65(41) = -8(fffffff8)\n  signed 8 -4(fffffffc) << 66(42) = -16(fffffff0)\n  signed 8 -4(fffffffc) << 67(43) = -32(ffffffe0)\n  signed 8 -4(fffffffc) << 68(44) = -64(ffffffc0)\n  signed 8 -4(fffffffc) << 69(45) = -128(ffffff80)\n  signed 8 -4(fffffffc) << 70(46) = -256(ffffff00)\n  signed 8 -4(fffffffc) << 71(47) = -512(fffffe00)\n  signed 8 -4(fffffffc) << 72(48) = -1024(fffffc00)\n  signed 8 -4(fffffffc) << 73(49) = -2048(fffff800)\n  signed 8 -4(fffffffc) << 74(4a) = -4096(fffff000)\n  signed 8 -4(fffffffc) << 75(4b) = -8192(ffffe000)\n  signed 8 -4(fffffffc) << 76(4c) = -16384(ffffc000)\n  signed 8 -4(fffffffc) << 77(4d) = -32768(ffff8000)\n  signed 8 -4(fffffffc) << 78(4e) = -65536(ffff0000)\n  signed 8 -4(fffffffc) << 79(4f) = -131072(fffe0000)\n  signed 8 -4(fffffffc) << 80(50) = -262144(fffc0000)\n  signed 8 -4(fffffffc) << 81(51) = -524288(fff80000)\n  signed 8 -4(fffffffc) << 82(52) = -1048576(fff00000)\n  signed 8 -4(fffffffc) << 83(53) = -2097152(ffe00000)\n  signed 8 -4(fffffffc) << 84(54) = -4194304(ffc00000)\n  signed 8 -4(fffffffc) << 85(55) = -8388608(ff800000)\n  signed 8 -4(fffffffc) << 86(56) = -16777216(ff000000)\n  signed 8 -4(fffffffc) << 87(57) = -33554432(fe000000)\n  signed 8 -4(fffffffc) << 88(58) = -67108864(fc000000)\n  signed 8 -4(fffffffc) << 89(59) = -134217728(f8000000)\n  signed 8 -4(fffffffc) << 90(5a) = -268435456(f0000000)\n  signed 8 -4(fffffffc) << 91(5b) = -536870912(e0000000)\n  signed 8 -4(fffffffc) << 92(5c) = -1073741824(c0000000)\n  signed 8 -4(fffffffc) << 93(5d) = -2147483648(80000000)\n  signed 8 -4(fffffffc) << 94(5e) = 0(0)\n  signed 8 -4(fffffffc) << 95(5f) = 0(0)\n  signed 8 -4(fffffffc) << 96(60) = 0(0)\n  signed 8 -4(fffffffc) << 97(61) = 0(0)\n  signed 8 -4(fffffffc) << 98(62) = 0(0)\n  signed 8 -4(fffffffc) << 99(63) = 0(0)\n  signed 8 -4(fffffffc) << 100(64) = 0(0)\n  signed 8 -4(fffffffc) << 101(65) = 0(0)\n  signed 8 -4(fffffffc) << 102(66) = 0(0)\n  signed 8 -4(fffffffc) << 103(67) = 0(0)\n  signed 8 -4(fffffffc) << 104(68) = 0(0)\n  signed 8 -4(fffffffc) << 105(69) = 0(0)\n  signed 8 -4(fffffffc) << 106(6a) = 0(0)\n  signed 8 -4(fffffffc) << 107(6b) = 0(0)\n  signed 8 -4(fffffffc) << 108(6c) = 0(0)\n  signed 8 -4(fffffffc) << 109(6d) = 0(0)\n  signed 8 -4(fffffffc) << 110(6e) = 0(0)\n  signed 8 -4(fffffffc) << 111(6f) = 0(0)\n  signed 8 -4(fffffffc) << 112(70) = 0(0)\n  signed 8 -4(fffffffc) << 113(71) = 0(0)\n  signed 8 -4(fffffffc) << 114(72) = 0(0)\n  signed 8 -4(fffffffc) << 115(73) = 0(0)\n  signed 8 -4(fffffffc) << 116(74) = 0(0)\n  signed 8 -4(fffffffc) << 117(75) = 0(0)\n  signed 8 -4(fffffffc) << 118(76) = 0(0)\n  signed 8 -4(fffffffc) << 119(77) = 0(0)\n  signed 8 -4(fffffffc) << 120(78) = 0(0)\n  signed 8 -4(fffffffc) << 121(79) = 0(0)\n  signed 8 -4(fffffffc) << 122(7a) = 0(0)\n  signed 8 -4(fffffffc) << 123(7b) = 0(0)\n  signed 8 -4(fffffffc) << 124(7c) = 0(0)\n  signed 8 -4(fffffffc) << 125(7d) = 0(0)\n  signed 8 -4(fffffffc) << 126(7e) = 0(0)\n  signed 8 -4(fffffffc) << 127(7f) = 0(0)\n  signed 8 -3(fffffffd) << -128(ffffff80) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -127(ffffff81) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -126(ffffff82) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -125(ffffff83) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -124(ffffff84) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -123(ffffff85) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -122(ffffff86) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -121(ffffff87) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -120(ffffff88) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -119(ffffff89) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -118(ffffff8a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -117(ffffff8b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -116(ffffff8c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -115(ffffff8d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -114(ffffff8e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -113(ffffff8f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -112(ffffff90) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -111(ffffff91) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -110(ffffff92) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -109(ffffff93) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -108(ffffff94) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -107(ffffff95) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -106(ffffff96) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -105(ffffff97) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -104(ffffff98) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -103(ffffff99) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -102(ffffff9a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -101(ffffff9b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -100(ffffff9c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -99(ffffff9d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -98(ffffff9e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << -96(ffffffa0) = 0(0)\n  signed 8 -3(fffffffd) << -95(ffffffa1) = 0(0)\n  signed 8 -3(fffffffd) << -94(ffffffa2) = 0(0)\n  signed 8 -3(fffffffd) << -93(ffffffa3) = 0(0)\n  signed 8 -3(fffffffd) << -92(ffffffa4) = 0(0)\n  signed 8 -3(fffffffd) << -91(ffffffa5) = 0(0)\n  signed 8 -3(fffffffd) << -90(ffffffa6) = 0(0)\n  signed 8 -3(fffffffd) << -89(ffffffa7) = 0(0)\n  signed 8 -3(fffffffd) << -88(ffffffa8) = 0(0)\n  signed 8 -3(fffffffd) << -87(ffffffa9) = 0(0)\n  signed 8 -3(fffffffd) << -86(ffffffaa) = 0(0)\n  signed 8 -3(fffffffd) << -85(ffffffab) = 0(0)\n  signed 8 -3(fffffffd) << -84(ffffffac) = 0(0)\n  signed 8 -3(fffffffd) << -83(ffffffad) = 0(0)\n  signed 8 -3(fffffffd) << -82(ffffffae) = 0(0)\n  signed 8 -3(fffffffd) << -81(ffffffaf) = 0(0)\n  signed 8 -3(fffffffd) << -80(ffffffb0) = 0(0)\n  signed 8 -3(fffffffd) << -79(ffffffb1) = 0(0)\n  signed 8 -3(fffffffd) << -78(ffffffb2) = 0(0)\n  signed 8 -3(fffffffd) << -77(ffffffb3) = 0(0)\n  signed 8 -3(fffffffd) << -76(ffffffb4) = 0(0)\n  signed 8 -3(fffffffd) << -75(ffffffb5) = 0(0)\n  signed 8 -3(fffffffd) << -74(ffffffb6) = 0(0)\n  signed 8 -3(fffffffd) << -73(ffffffb7) = 0(0)\n  signed 8 -3(fffffffd) << -72(ffffffb8) = 0(0)\n  signed 8 -3(fffffffd) << -71(ffffffb9) = 0(0)\n  signed 8 -3(fffffffd) << -70(ffffffba) = 0(0)\n  signed 8 -3(fffffffd) << -69(ffffffbb) = 0(0)\n  signed 8 -3(fffffffd) << -68(ffffffbc) = 0(0)\n  signed 8 -3(fffffffd) << -67(ffffffbd) = 0(0)\n  signed 8 -3(fffffffd) << -66(ffffffbe) = 0(0)\n  signed 8 -3(fffffffd) << -65(ffffffbf) = 0(0)\n  signed 8 -3(fffffffd) << -64(ffffffc0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << -63(ffffffc1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << -62(ffffffc2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << -61(ffffffc3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << -60(ffffffc4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << -59(ffffffc5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << -58(ffffffc6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << -57(ffffffc7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << -56(ffffffc8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << -55(ffffffc9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << -54(ffffffca) = -3072(fffff400)\n  signed 8 -3(fffffffd) << -53(ffffffcb) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << -52(ffffffcc) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << -51(ffffffcd) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << -50(ffffffce) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << -49(ffffffcf) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << -48(ffffffd0) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << -47(ffffffd1) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << -46(ffffffd2) = -786432(fff40000)\n  signed 8 -3(fffffffd) << -45(ffffffd3) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << -44(ffffffd4) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << -43(ffffffd5) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << -42(ffffffd6) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << -41(ffffffd7) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << -40(ffffffd8) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << -39(ffffffd9) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << -38(ffffffda) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << -37(ffffffdb) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << -36(ffffffdc) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << -35(ffffffdd) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << -34(ffffffde) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << -32(ffffffe0) = 0(0)\n  signed 8 -3(fffffffd) << -31(ffffffe1) = 0(0)\n  signed 8 -3(fffffffd) << -30(ffffffe2) = 0(0)\n  signed 8 -3(fffffffd) << -29(ffffffe3) = 0(0)\n  signed 8 -3(fffffffd) << -28(ffffffe4) = 0(0)\n  signed 8 -3(fffffffd) << -27(ffffffe5) = 0(0)\n  signed 8 -3(fffffffd) << -26(ffffffe6) = 0(0)\n  signed 8 -3(fffffffd) << -25(ffffffe7) = 0(0)\n  signed 8 -3(fffffffd) << -24(ffffffe8) = 0(0)\n  signed 8 -3(fffffffd) << -23(ffffffe9) = 0(0)\n  signed 8 -3(fffffffd) << -22(ffffffea) = 0(0)\n  signed 8 -3(fffffffd) << -21(ffffffeb) = 0(0)\n  signed 8 -3(fffffffd) << -20(ffffffec) = 0(0)\n  signed 8 -3(fffffffd) << -19(ffffffed) = 0(0)\n  signed 8 -3(fffffffd) << -18(ffffffee) = 0(0)\n  signed 8 -3(fffffffd) << -17(ffffffef) = 0(0)\n  signed 8 -3(fffffffd) << -16(fffffff0) = 0(0)\n  signed 8 -3(fffffffd) << -15(fffffff1) = 0(0)\n  signed 8 -3(fffffffd) << -14(fffffff2) = 0(0)\n  signed 8 -3(fffffffd) << -13(fffffff3) = 0(0)\n  signed 8 -3(fffffffd) << -12(fffffff4) = 0(0)\n  signed 8 -3(fffffffd) << -11(fffffff5) = 0(0)\n  signed 8 -3(fffffffd) << -10(fffffff6) = 0(0)\n  signed 8 -3(fffffffd) << -9(fffffff7) = 0(0)\n  signed 8 -3(fffffffd) << -8(fffffff8) = 0(0)\n  signed 8 -3(fffffffd) << -7(fffffff9) = 0(0)\n  signed 8 -3(fffffffd) << -6(fffffffa) = 0(0)\n  signed 8 -3(fffffffd) << -5(fffffffb) = 0(0)\n  signed 8 -3(fffffffd) << -4(fffffffc) = 0(0)\n  signed 8 -3(fffffffd) << -3(fffffffd) = 0(0)\n  signed 8 -3(fffffffd) << -2(fffffffe) = 0(0)\n  signed 8 -3(fffffffd) << -1(ffffffff) = 0(0)\n  signed 8 -3(fffffffd) << 0(0) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 1(1) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 2(2) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 3(3) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 4(4) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 5(5) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 6(6) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 7(7) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 8(8) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 9(9) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 10(a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 11(b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 12(c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 13(d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 14(e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 15(f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 16(10) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 17(11) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 18(12) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 19(13) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 20(14) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 21(15) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 22(16) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 23(17) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 24(18) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 25(19) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 26(1a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 27(1b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 28(1c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 29(1d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 30(1e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 31(1f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 32(20) = 0(0)\n  signed 8 -3(fffffffd) << 33(21) = 0(0)\n  signed 8 -3(fffffffd) << 34(22) = 0(0)\n  signed 8 -3(fffffffd) << 35(23) = 0(0)\n  signed 8 -3(fffffffd) << 36(24) = 0(0)\n  signed 8 -3(fffffffd) << 37(25) = 0(0)\n  signed 8 -3(fffffffd) << 38(26) = 0(0)\n  signed 8 -3(fffffffd) << 39(27) = 0(0)\n  signed 8 -3(fffffffd) << 40(28) = 0(0)\n  signed 8 -3(fffffffd) << 41(29) = 0(0)\n  signed 8 -3(fffffffd) << 42(2a) = 0(0)\n  signed 8 -3(fffffffd) << 43(2b) = 0(0)\n  signed 8 -3(fffffffd) << 44(2c) = 0(0)\n  signed 8 -3(fffffffd) << 45(2d) = 0(0)\n  signed 8 -3(fffffffd) << 46(2e) = 0(0)\n  signed 8 -3(fffffffd) << 47(2f) = 0(0)\n  signed 8 -3(fffffffd) << 48(30) = 0(0)\n  signed 8 -3(fffffffd) << 49(31) = 0(0)\n  signed 8 -3(fffffffd) << 50(32) = 0(0)\n  signed 8 -3(fffffffd) << 51(33) = 0(0)\n  signed 8 -3(fffffffd) << 52(34) = 0(0)\n  signed 8 -3(fffffffd) << 53(35) = 0(0)\n  signed 8 -3(fffffffd) << 54(36) = 0(0)\n  signed 8 -3(fffffffd) << 55(37) = 0(0)\n  signed 8 -3(fffffffd) << 56(38) = 0(0)\n  signed 8 -3(fffffffd) << 57(39) = 0(0)\n  signed 8 -3(fffffffd) << 58(3a) = 0(0)\n  signed 8 -3(fffffffd) << 59(3b) = 0(0)\n  signed 8 -3(fffffffd) << 60(3c) = 0(0)\n  signed 8 -3(fffffffd) << 61(3d) = 0(0)\n  signed 8 -3(fffffffd) << 62(3e) = 0(0)\n  signed 8 -3(fffffffd) << 63(3f) = 0(0)\n  signed 8 -3(fffffffd) << 64(40) = -3(fffffffd)\n  signed 8 -3(fffffffd) << 65(41) = -6(fffffffa)\n  signed 8 -3(fffffffd) << 66(42) = -12(fffffff4)\n  signed 8 -3(fffffffd) << 67(43) = -24(ffffffe8)\n  signed 8 -3(fffffffd) << 68(44) = -48(ffffffd0)\n  signed 8 -3(fffffffd) << 69(45) = -96(ffffffa0)\n  signed 8 -3(fffffffd) << 70(46) = -192(ffffff40)\n  signed 8 -3(fffffffd) << 71(47) = -384(fffffe80)\n  signed 8 -3(fffffffd) << 72(48) = -768(fffffd00)\n  signed 8 -3(fffffffd) << 73(49) = -1536(fffffa00)\n  signed 8 -3(fffffffd) << 74(4a) = -3072(fffff400)\n  signed 8 -3(fffffffd) << 75(4b) = -6144(ffffe800)\n  signed 8 -3(fffffffd) << 76(4c) = -12288(ffffd000)\n  signed 8 -3(fffffffd) << 77(4d) = -24576(ffffa000)\n  signed 8 -3(fffffffd) << 78(4e) = -49152(ffff4000)\n  signed 8 -3(fffffffd) << 79(4f) = -98304(fffe8000)\n  signed 8 -3(fffffffd) << 80(50) = -196608(fffd0000)\n  signed 8 -3(fffffffd) << 81(51) = -393216(fffa0000)\n  signed 8 -3(fffffffd) << 82(52) = -786432(fff40000)\n  signed 8 -3(fffffffd) << 83(53) = -1572864(ffe80000)\n  signed 8 -3(fffffffd) << 84(54) = -3145728(ffd00000)\n  signed 8 -3(fffffffd) << 85(55) = -6291456(ffa00000)\n  signed 8 -3(fffffffd) << 86(56) = -12582912(ff400000)\n  signed 8 -3(fffffffd) << 87(57) = -25165824(fe800000)\n  signed 8 -3(fffffffd) << 88(58) = -50331648(fd000000)\n  signed 8 -3(fffffffd) << 89(59) = -100663296(fa000000)\n  signed 8 -3(fffffffd) << 90(5a) = -201326592(f4000000)\n  signed 8 -3(fffffffd) << 91(5b) = -402653184(e8000000)\n  signed 8 -3(fffffffd) << 92(5c) = -805306368(d0000000)\n  signed 8 -3(fffffffd) << 93(5d) = -1610612736(a0000000)\n  signed 8 -3(fffffffd) << 94(5e) = 1073741824(40000000)\n  signed 8 -3(fffffffd) << 95(5f) = -2147483648(80000000)\n  signed 8 -3(fffffffd) << 96(60) = 0(0)\n  signed 8 -3(fffffffd) << 97(61) = 0(0)\n  signed 8 -3(fffffffd) << 98(62) = 0(0)\n  signed 8 -3(fffffffd) << 99(63) = 0(0)\n  signed 8 -3(fffffffd) << 100(64) = 0(0)\n  signed 8 -3(fffffffd) << 101(65) = 0(0)\n  signed 8 -3(fffffffd) << 102(66) = 0(0)\n  signed 8 -3(fffffffd) << 103(67) = 0(0)\n  signed 8 -3(fffffffd) << 104(68) = 0(0)\n  signed 8 -3(fffffffd) << 105(69) = 0(0)\n  signed 8 -3(fffffffd) << 106(6a) = 0(0)\n  signed 8 -3(fffffffd) << 107(6b) = 0(0)\n  signed 8 -3(fffffffd) << 108(6c) = 0(0)\n  signed 8 -3(fffffffd) << 109(6d) = 0(0)\n  signed 8 -3(fffffffd) << 110(6e) = 0(0)\n  signed 8 -3(fffffffd) << 111(6f) = 0(0)\n  signed 8 -3(fffffffd) << 112(70) = 0(0)\n  signed 8 -3(fffffffd) << 113(71) = 0(0)\n  signed 8 -3(fffffffd) << 114(72) = 0(0)\n  signed 8 -3(fffffffd) << 115(73) = 0(0)\n  signed 8 -3(fffffffd) << 116(74) = 0(0)\n  signed 8 -3(fffffffd) << 117(75) = 0(0)\n  signed 8 -3(fffffffd) << 118(76) = 0(0)\n  signed 8 -3(fffffffd) << 119(77) = 0(0)\n  signed 8 -3(fffffffd) << 120(78) = 0(0)\n  signed 8 -3(fffffffd) << 121(79) = 0(0)\n  signed 8 -3(fffffffd) << 122(7a) = 0(0)\n  signed 8 -3(fffffffd) << 123(7b) = 0(0)\n  signed 8 -3(fffffffd) << 124(7c) = 0(0)\n  signed 8 -3(fffffffd) << 125(7d) = 0(0)\n  signed 8 -3(fffffffd) << 126(7e) = 0(0)\n  signed 8 -3(fffffffd) << 127(7f) = 0(0)\n  signed 8 -2(fffffffe) << -128(ffffff80) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -127(ffffff81) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -126(ffffff82) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -125(ffffff83) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -124(ffffff84) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -123(ffffff85) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -122(ffffff86) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -121(ffffff87) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -120(ffffff88) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -119(ffffff89) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -118(ffffff8a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -117(ffffff8b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -116(ffffff8c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -115(ffffff8d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -114(ffffff8e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -113(ffffff8f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -112(ffffff90) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -111(ffffff91) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -110(ffffff92) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -109(ffffff93) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -108(ffffff94) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -107(ffffff95) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -106(ffffff96) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -105(ffffff97) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -104(ffffff98) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -103(ffffff99) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -102(ffffff9a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -101(ffffff9b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -100(ffffff9c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -99(ffffff9d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -98(ffffff9e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -97(ffffff9f) = 0(0)\n  signed 8 -2(fffffffe) << -96(ffffffa0) = 0(0)\n  signed 8 -2(fffffffe) << -95(ffffffa1) = 0(0)\n  signed 8 -2(fffffffe) << -94(ffffffa2) = 0(0)\n  signed 8 -2(fffffffe) << -93(ffffffa3) = 0(0)\n  signed 8 -2(fffffffe) << -92(ffffffa4) = 0(0)\n  signed 8 -2(fffffffe) << -91(ffffffa5) = 0(0)\n  signed 8 -2(fffffffe) << -90(ffffffa6) = 0(0)\n  signed 8 -2(fffffffe) << -89(ffffffa7) = 0(0)\n  signed 8 -2(fffffffe) << -88(ffffffa8) = 0(0)\n  signed 8 -2(fffffffe) << -87(ffffffa9) = 0(0)\n  signed 8 -2(fffffffe) << -86(ffffffaa) = 0(0)\n  signed 8 -2(fffffffe) << -85(ffffffab) = 0(0)\n  signed 8 -2(fffffffe) << -84(ffffffac) = 0(0)\n  signed 8 -2(fffffffe) << -83(ffffffad) = 0(0)\n  signed 8 -2(fffffffe) << -82(ffffffae) = 0(0)\n  signed 8 -2(fffffffe) << -81(ffffffaf) = 0(0)\n  signed 8 -2(fffffffe) << -80(ffffffb0) = 0(0)\n  signed 8 -2(fffffffe) << -79(ffffffb1) = 0(0)\n  signed 8 -2(fffffffe) << -78(ffffffb2) = 0(0)\n  signed 8 -2(fffffffe) << -77(ffffffb3) = 0(0)\n  signed 8 -2(fffffffe) << -76(ffffffb4) = 0(0)\n  signed 8 -2(fffffffe) << -75(ffffffb5) = 0(0)\n  signed 8 -2(fffffffe) << -74(ffffffb6) = 0(0)\n  signed 8 -2(fffffffe) << -73(ffffffb7) = 0(0)\n  signed 8 -2(fffffffe) << -72(ffffffb8) = 0(0)\n  signed 8 -2(fffffffe) << -71(ffffffb9) = 0(0)\n  signed 8 -2(fffffffe) << -70(ffffffba) = 0(0)\n  signed 8 -2(fffffffe) << -69(ffffffbb) = 0(0)\n  signed 8 -2(fffffffe) << -68(ffffffbc) = 0(0)\n  signed 8 -2(fffffffe) << -67(ffffffbd) = 0(0)\n  signed 8 -2(fffffffe) << -66(ffffffbe) = 0(0)\n  signed 8 -2(fffffffe) << -65(ffffffbf) = 0(0)\n  signed 8 -2(fffffffe) << -64(ffffffc0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << -63(ffffffc1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << -62(ffffffc2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << -61(ffffffc3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << -60(ffffffc4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << -59(ffffffc5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << -58(ffffffc6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << -57(ffffffc7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << -56(ffffffc8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << -55(ffffffc9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << -54(ffffffca) = -2048(fffff800)\n  signed 8 -2(fffffffe) << -53(ffffffcb) = -4096(fffff000)\n  signed 8 -2(fffffffe) << -52(ffffffcc) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << -51(ffffffcd) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << -50(ffffffce) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << -49(ffffffcf) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << -48(ffffffd0) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << -47(ffffffd1) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << -46(ffffffd2) = -524288(fff80000)\n  signed 8 -2(fffffffe) << -45(ffffffd3) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << -44(ffffffd4) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << -43(ffffffd5) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << -42(ffffffd6) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << -41(ffffffd7) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << -40(ffffffd8) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << -39(ffffffd9) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << -38(ffffffda) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << -37(ffffffdb) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << -36(ffffffdc) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << -35(ffffffdd) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << -34(ffffffde) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << -33(ffffffdf) = 0(0)\n  signed 8 -2(fffffffe) << -32(ffffffe0) = 0(0)\n  signed 8 -2(fffffffe) << -31(ffffffe1) = 0(0)\n  signed 8 -2(fffffffe) << -30(ffffffe2) = 0(0)\n  signed 8 -2(fffffffe) << -29(ffffffe3) = 0(0)\n  signed 8 -2(fffffffe) << -28(ffffffe4) = 0(0)\n  signed 8 -2(fffffffe) << -27(ffffffe5) = 0(0)\n  signed 8 -2(fffffffe) << -26(ffffffe6) = 0(0)\n  signed 8 -2(fffffffe) << -25(ffffffe7) = 0(0)\n  signed 8 -2(fffffffe) << -24(ffffffe8) = 0(0)\n  signed 8 -2(fffffffe) << -23(ffffffe9) = 0(0)\n  signed 8 -2(fffffffe) << -22(ffffffea) = 0(0)\n  signed 8 -2(fffffffe) << -21(ffffffeb) = 0(0)\n  signed 8 -2(fffffffe) << -20(ffffffec) = 0(0)\n  signed 8 -2(fffffffe) << -19(ffffffed) = 0(0)\n  signed 8 -2(fffffffe) << -18(ffffffee) = 0(0)\n  signed 8 -2(fffffffe) << -17(ffffffef) = 0(0)\n  signed 8 -2(fffffffe) << -16(fffffff0) = 0(0)\n  signed 8 -2(fffffffe) << -15(fffffff1) = 0(0)\n  signed 8 -2(fffffffe) << -14(fffffff2) = 0(0)\n  signed 8 -2(fffffffe) << -13(fffffff3) = 0(0)\n  signed 8 -2(fffffffe) << -12(fffffff4) = 0(0)\n  signed 8 -2(fffffffe) << -11(fffffff5) = 0(0)\n  signed 8 -2(fffffffe) << -10(fffffff6) = 0(0)\n  signed 8 -2(fffffffe) << -9(fffffff7) = 0(0)\n  signed 8 -2(fffffffe) << -8(fffffff8) = 0(0)\n  signed 8 -2(fffffffe) << -7(fffffff9) = 0(0)\n  signed 8 -2(fffffffe) << -6(fffffffa) = 0(0)\n  signed 8 -2(fffffffe) << -5(fffffffb) = 0(0)\n  signed 8 -2(fffffffe) << -4(fffffffc) = 0(0)\n  signed 8 -2(fffffffe) << -3(fffffffd) = 0(0)\n  signed 8 -2(fffffffe) << -2(fffffffe) = 0(0)\n  signed 8 -2(fffffffe) << -1(ffffffff) = 0(0)\n  signed 8 -2(fffffffe) << 0(0) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 1(1) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 2(2) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 3(3) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 4(4) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 5(5) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 6(6) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 7(7) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 8(8) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 9(9) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 10(a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 11(b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 12(c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 13(d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 14(e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 15(f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 16(10) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 17(11) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 18(12) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 19(13) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 20(14) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 21(15) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 22(16) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 23(17) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 24(18) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 25(19) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 26(1a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 27(1b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 28(1c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 29(1d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 30(1e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 31(1f) = 0(0)\n  signed 8 -2(fffffffe) << 32(20) = 0(0)\n  signed 8 -2(fffffffe) << 33(21) = 0(0)\n  signed 8 -2(fffffffe) << 34(22) = 0(0)\n  signed 8 -2(fffffffe) << 35(23) = 0(0)\n  signed 8 -2(fffffffe) << 36(24) = 0(0)\n  signed 8 -2(fffffffe) << 37(25) = 0(0)\n  signed 8 -2(fffffffe) << 38(26) = 0(0)\n  signed 8 -2(fffffffe) << 39(27) = 0(0)\n  signed 8 -2(fffffffe) << 40(28) = 0(0)\n  signed 8 -2(fffffffe) << 41(29) = 0(0)\n  signed 8 -2(fffffffe) << 42(2a) = 0(0)\n  signed 8 -2(fffffffe) << 43(2b) = 0(0)\n  signed 8 -2(fffffffe) << 44(2c) = 0(0)\n  signed 8 -2(fffffffe) << 45(2d) = 0(0)\n  signed 8 -2(fffffffe) << 46(2e) = 0(0)\n  signed 8 -2(fffffffe) << 47(2f) = 0(0)\n  signed 8 -2(fffffffe) << 48(30) = 0(0)\n  signed 8 -2(fffffffe) << 49(31) = 0(0)\n  signed 8 -2(fffffffe) << 50(32) = 0(0)\n  signed 8 -2(fffffffe) << 51(33) = 0(0)\n  signed 8 -2(fffffffe) << 52(34) = 0(0)\n  signed 8 -2(fffffffe) << 53(35) = 0(0)\n  signed 8 -2(fffffffe) << 54(36) = 0(0)\n  signed 8 -2(fffffffe) << 55(37) = 0(0)\n  signed 8 -2(fffffffe) << 56(38) = 0(0)\n  signed 8 -2(fffffffe) << 57(39) = 0(0)\n  signed 8 -2(fffffffe) << 58(3a) = 0(0)\n  signed 8 -2(fffffffe) << 59(3b) = 0(0)\n  signed 8 -2(fffffffe) << 60(3c) = 0(0)\n  signed 8 -2(fffffffe) << 61(3d) = 0(0)\n  signed 8 -2(fffffffe) << 62(3e) = 0(0)\n  signed 8 -2(fffffffe) << 63(3f) = 0(0)\n  signed 8 -2(fffffffe) << 64(40) = -2(fffffffe)\n  signed 8 -2(fffffffe) << 65(41) = -4(fffffffc)\n  signed 8 -2(fffffffe) << 66(42) = -8(fffffff8)\n  signed 8 -2(fffffffe) << 67(43) = -16(fffffff0)\n  signed 8 -2(fffffffe) << 68(44) = -32(ffffffe0)\n  signed 8 -2(fffffffe) << 69(45) = -64(ffffffc0)\n  signed 8 -2(fffffffe) << 70(46) = -128(ffffff80)\n  signed 8 -2(fffffffe) << 71(47) = -256(ffffff00)\n  signed 8 -2(fffffffe) << 72(48) = -512(fffffe00)\n  signed 8 -2(fffffffe) << 73(49) = -1024(fffffc00)\n  signed 8 -2(fffffffe) << 74(4a) = -2048(fffff800)\n  signed 8 -2(fffffffe) << 75(4b) = -4096(fffff000)\n  signed 8 -2(fffffffe) << 76(4c) = -8192(ffffe000)\n  signed 8 -2(fffffffe) << 77(4d) = -16384(ffffc000)\n  signed 8 -2(fffffffe) << 78(4e) = -32768(ffff8000)\n  signed 8 -2(fffffffe) << 79(4f) = -65536(ffff0000)\n  signed 8 -2(fffffffe) << 80(50) = -131072(fffe0000)\n  signed 8 -2(fffffffe) << 81(51) = -262144(fffc0000)\n  signed 8 -2(fffffffe) << 82(52) = -524288(fff80000)\n  signed 8 -2(fffffffe) << 83(53) = -1048576(fff00000)\n  signed 8 -2(fffffffe) << 84(54) = -2097152(ffe00000)\n  signed 8 -2(fffffffe) << 85(55) = -4194304(ffc00000)\n  signed 8 -2(fffffffe) << 86(56) = -8388608(ff800000)\n  signed 8 -2(fffffffe) << 87(57) = -16777216(ff000000)\n  signed 8 -2(fffffffe) << 88(58) = -33554432(fe000000)\n  signed 8 -2(fffffffe) << 89(59) = -67108864(fc000000)\n  signed 8 -2(fffffffe) << 90(5a) = -134217728(f8000000)\n  signed 8 -2(fffffffe) << 91(5b) = -268435456(f0000000)\n  signed 8 -2(fffffffe) << 92(5c) = -536870912(e0000000)\n  signed 8 -2(fffffffe) << 93(5d) = -1073741824(c0000000)\n  signed 8 -2(fffffffe) << 94(5e) = -2147483648(80000000)\n  signed 8 -2(fffffffe) << 95(5f) = 0(0)\n  signed 8 -2(fffffffe) << 96(60) = 0(0)\n  signed 8 -2(fffffffe) << 97(61) = 0(0)\n  signed 8 -2(fffffffe) << 98(62) = 0(0)\n  signed 8 -2(fffffffe) << 99(63) = 0(0)\n  signed 8 -2(fffffffe) << 100(64) = 0(0)\n  signed 8 -2(fffffffe) << 101(65) = 0(0)\n  signed 8 -2(fffffffe) << 102(66) = 0(0)\n  signed 8 -2(fffffffe) << 103(67) = 0(0)\n  signed 8 -2(fffffffe) << 104(68) = 0(0)\n  signed 8 -2(fffffffe) << 105(69) = 0(0)\n  signed 8 -2(fffffffe) << 106(6a) = 0(0)\n  signed 8 -2(fffffffe) << 107(6b) = 0(0)\n  signed 8 -2(fffffffe) << 108(6c) = 0(0)\n  signed 8 -2(fffffffe) << 109(6d) = 0(0)\n  signed 8 -2(fffffffe) << 110(6e) = 0(0)\n  signed 8 -2(fffffffe) << 111(6f) = 0(0)\n  signed 8 -2(fffffffe) << 112(70) = 0(0)\n  signed 8 -2(fffffffe) << 113(71) = 0(0)\n  signed 8 -2(fffffffe) << 114(72) = 0(0)\n  signed 8 -2(fffffffe) << 115(73) = 0(0)\n  signed 8 -2(fffffffe) << 116(74) = 0(0)\n  signed 8 -2(fffffffe) << 117(75) = 0(0)\n  signed 8 -2(fffffffe) << 118(76) = 0(0)\n  signed 8 -2(fffffffe) << 119(77) = 0(0)\n  signed 8 -2(fffffffe) << 120(78) = 0(0)\n  signed 8 -2(fffffffe) << 121(79) = 0(0)\n  signed 8 -2(fffffffe) << 122(7a) = 0(0)\n  signed 8 -2(fffffffe) << 123(7b) = 0(0)\n  signed 8 -2(fffffffe) << 124(7c) = 0(0)\n  signed 8 -2(fffffffe) << 125(7d) = 0(0)\n  signed 8 -2(fffffffe) << 126(7e) = 0(0)\n  signed 8 -2(fffffffe) << 127(7f) = 0(0)\n  signed 8 -1(ffffffff) << -128(ffffff80) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -127(ffffff81) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -126(ffffff82) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -125(ffffff83) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -124(ffffff84) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -123(ffffff85) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -122(ffffff86) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -121(ffffff87) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -120(ffffff88) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -119(ffffff89) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -118(ffffff8a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -117(ffffff8b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -116(ffffff8c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -115(ffffff8d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -114(ffffff8e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -113(ffffff8f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -112(ffffff90) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -111(ffffff91) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -110(ffffff92) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -109(ffffff93) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -108(ffffff94) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -107(ffffff95) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -106(ffffff96) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -105(ffffff97) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -104(ffffff98) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -103(ffffff99) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -102(ffffff9a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -101(ffffff9b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -100(ffffff9c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -99(ffffff9d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -98(ffffff9e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << -96(ffffffa0) = 0(0)\n  signed 8 -1(ffffffff) << -95(ffffffa1) = 0(0)\n  signed 8 -1(ffffffff) << -94(ffffffa2) = 0(0)\n  signed 8 -1(ffffffff) << -93(ffffffa3) = 0(0)\n  signed 8 -1(ffffffff) << -92(ffffffa4) = 0(0)\n  signed 8 -1(ffffffff) << -91(ffffffa5) = 0(0)\n  signed 8 -1(ffffffff) << -90(ffffffa6) = 0(0)\n  signed 8 -1(ffffffff) << -89(ffffffa7) = 0(0)\n  signed 8 -1(ffffffff) << -88(ffffffa8) = 0(0)\n  signed 8 -1(ffffffff) << -87(ffffffa9) = 0(0)\n  signed 8 -1(ffffffff) << -86(ffffffaa) = 0(0)\n  signed 8 -1(ffffffff) << -85(ffffffab) = 0(0)\n  signed 8 -1(ffffffff) << -84(ffffffac) = 0(0)\n  signed 8 -1(ffffffff) << -83(ffffffad) = 0(0)\n  signed 8 -1(ffffffff) << -82(ffffffae) = 0(0)\n  signed 8 -1(ffffffff) << -81(ffffffaf) = 0(0)\n  signed 8 -1(ffffffff) << -80(ffffffb0) = 0(0)\n  signed 8 -1(ffffffff) << -79(ffffffb1) = 0(0)\n  signed 8 -1(ffffffff) << -78(ffffffb2) = 0(0)\n  signed 8 -1(ffffffff) << -77(ffffffb3) = 0(0)\n  signed 8 -1(ffffffff) << -76(ffffffb4) = 0(0)\n  signed 8 -1(ffffffff) << -75(ffffffb5) = 0(0)\n  signed 8 -1(ffffffff) << -74(ffffffb6) = 0(0)\n  signed 8 -1(ffffffff) << -73(ffffffb7) = 0(0)\n  signed 8 -1(ffffffff) << -72(ffffffb8) = 0(0)\n  signed 8 -1(ffffffff) << -71(ffffffb9) = 0(0)\n  signed 8 -1(ffffffff) << -70(ffffffba) = 0(0)\n  signed 8 -1(ffffffff) << -69(ffffffbb) = 0(0)\n  signed 8 -1(ffffffff) << -68(ffffffbc) = 0(0)\n  signed 8 -1(ffffffff) << -67(ffffffbd) = 0(0)\n  signed 8 -1(ffffffff) << -66(ffffffbe) = 0(0)\n  signed 8 -1(ffffffff) << -65(ffffffbf) = 0(0)\n  signed 8 -1(ffffffff) << -64(ffffffc0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << -63(ffffffc1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << -62(ffffffc2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << -61(ffffffc3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << -60(ffffffc4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << -59(ffffffc5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << -58(ffffffc6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << -57(ffffffc7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << -56(ffffffc8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << -55(ffffffc9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << -54(ffffffca) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << -53(ffffffcb) = -2048(fffff800)\n  signed 8 -1(ffffffff) << -52(ffffffcc) = -4096(fffff000)\n  signed 8 -1(ffffffff) << -51(ffffffcd) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << -50(ffffffce) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << -49(ffffffcf) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << -48(ffffffd0) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << -47(ffffffd1) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << -46(ffffffd2) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << -45(ffffffd3) = -524288(fff80000)\n  signed 8 -1(ffffffff) << -44(ffffffd4) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << -43(ffffffd5) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << -42(ffffffd6) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << -41(ffffffd7) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << -40(ffffffd8) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << -39(ffffffd9) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << -38(ffffffda) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << -37(ffffffdb) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << -36(ffffffdc) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << -35(ffffffdd) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << -34(ffffffde) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << -32(ffffffe0) = 0(0)\n  signed 8 -1(ffffffff) << -31(ffffffe1) = 0(0)\n  signed 8 -1(ffffffff) << -30(ffffffe2) = 0(0)\n  signed 8 -1(ffffffff) << -29(ffffffe3) = 0(0)\n  signed 8 -1(ffffffff) << -28(ffffffe4) = 0(0)\n  signed 8 -1(ffffffff) << -27(ffffffe5) = 0(0)\n  signed 8 -1(ffffffff) << -26(ffffffe6) = 0(0)\n  signed 8 -1(ffffffff) << -25(ffffffe7) = 0(0)\n  signed 8 -1(ffffffff) << -24(ffffffe8) = 0(0)\n  signed 8 -1(ffffffff) << -23(ffffffe9) = 0(0)\n  signed 8 -1(ffffffff) << -22(ffffffea) = 0(0)\n  signed 8 -1(ffffffff) << -21(ffffffeb) = 0(0)\n  signed 8 -1(ffffffff) << -20(ffffffec) = 0(0)\n  signed 8 -1(ffffffff) << -19(ffffffed) = 0(0)\n  signed 8 -1(ffffffff) << -18(ffffffee) = 0(0)\n  signed 8 -1(ffffffff) << -17(ffffffef) = 0(0)\n  signed 8 -1(ffffffff) << -16(fffffff0) = 0(0)\n  signed 8 -1(ffffffff) << -15(fffffff1) = 0(0)\n  signed 8 -1(ffffffff) << -14(fffffff2) = 0(0)\n  signed 8 -1(ffffffff) << -13(fffffff3) = 0(0)\n  signed 8 -1(ffffffff) << -12(fffffff4) = 0(0)\n  signed 8 -1(ffffffff) << -11(fffffff5) = 0(0)\n  signed 8 -1(ffffffff) << -10(fffffff6) = 0(0)\n  signed 8 -1(ffffffff) << -9(fffffff7) = 0(0)\n  signed 8 -1(ffffffff) << -8(fffffff8) = 0(0)\n  signed 8 -1(ffffffff) << -7(fffffff9) = 0(0)\n  signed 8 -1(ffffffff) << -6(fffffffa) = 0(0)\n  signed 8 -1(ffffffff) << -5(fffffffb) = 0(0)\n  signed 8 -1(ffffffff) << -4(fffffffc) = 0(0)\n  signed 8 -1(ffffffff) << -3(fffffffd) = 0(0)\n  signed 8 -1(ffffffff) << -2(fffffffe) = 0(0)\n  signed 8 -1(ffffffff) << -1(ffffffff) = 0(0)\n  signed 8 -1(ffffffff) << 0(0) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 1(1) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 2(2) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 3(3) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 4(4) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 5(5) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 6(6) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 7(7) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 8(8) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 9(9) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 10(a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 11(b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 12(c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 13(d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 14(e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 15(f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 16(10) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 17(11) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 18(12) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 19(13) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 20(14) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 21(15) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 22(16) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 23(17) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 24(18) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 25(19) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 26(1a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 27(1b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 28(1c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 29(1d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 30(1e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 31(1f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 32(20) = 0(0)\n  signed 8 -1(ffffffff) << 33(21) = 0(0)\n  signed 8 -1(ffffffff) << 34(22) = 0(0)\n  signed 8 -1(ffffffff) << 35(23) = 0(0)\n  signed 8 -1(ffffffff) << 36(24) = 0(0)\n  signed 8 -1(ffffffff) << 37(25) = 0(0)\n  signed 8 -1(ffffffff) << 38(26) = 0(0)\n  signed 8 -1(ffffffff) << 39(27) = 0(0)\n  signed 8 -1(ffffffff) << 40(28) = 0(0)\n  signed 8 -1(ffffffff) << 41(29) = 0(0)\n  signed 8 -1(ffffffff) << 42(2a) = 0(0)\n  signed 8 -1(ffffffff) << 43(2b) = 0(0)\n  signed 8 -1(ffffffff) << 44(2c) = 0(0)\n  signed 8 -1(ffffffff) << 45(2d) = 0(0)\n  signed 8 -1(ffffffff) << 46(2e) = 0(0)\n  signed 8 -1(ffffffff) << 47(2f) = 0(0)\n  signed 8 -1(ffffffff) << 48(30) = 0(0)\n  signed 8 -1(ffffffff) << 49(31) = 0(0)\n  signed 8 -1(ffffffff) << 50(32) = 0(0)\n  signed 8 -1(ffffffff) << 51(33) = 0(0)\n  signed 8 -1(ffffffff) << 52(34) = 0(0)\n  signed 8 -1(ffffffff) << 53(35) = 0(0)\n  signed 8 -1(ffffffff) << 54(36) = 0(0)\n  signed 8 -1(ffffffff) << 55(37) = 0(0)\n  signed 8 -1(ffffffff) << 56(38) = 0(0)\n  signed 8 -1(ffffffff) << 57(39) = 0(0)\n  signed 8 -1(ffffffff) << 58(3a) = 0(0)\n  signed 8 -1(ffffffff) << 59(3b) = 0(0)\n  signed 8 -1(ffffffff) << 60(3c) = 0(0)\n  signed 8 -1(ffffffff) << 61(3d) = 0(0)\n  signed 8 -1(ffffffff) << 62(3e) = 0(0)\n  signed 8 -1(ffffffff) << 63(3f) = 0(0)\n  signed 8 -1(ffffffff) << 64(40) = -1(ffffffff)\n  signed 8 -1(ffffffff) << 65(41) = -2(fffffffe)\n  signed 8 -1(ffffffff) << 66(42) = -4(fffffffc)\n  signed 8 -1(ffffffff) << 67(43) = -8(fffffff8)\n  signed 8 -1(ffffffff) << 68(44) = -16(fffffff0)\n  signed 8 -1(ffffffff) << 69(45) = -32(ffffffe0)\n  signed 8 -1(ffffffff) << 70(46) = -64(ffffffc0)\n  signed 8 -1(ffffffff) << 71(47) = -128(ffffff80)\n  signed 8 -1(ffffffff) << 72(48) = -256(ffffff00)\n  signed 8 -1(ffffffff) << 73(49) = -512(fffffe00)\n  signed 8 -1(ffffffff) << 74(4a) = -1024(fffffc00)\n  signed 8 -1(ffffffff) << 75(4b) = -2048(fffff800)\n  signed 8 -1(ffffffff) << 76(4c) = -4096(fffff000)\n  signed 8 -1(ffffffff) << 77(4d) = -8192(ffffe000)\n  signed 8 -1(ffffffff) << 78(4e) = -16384(ffffc000)\n  signed 8 -1(ffffffff) << 79(4f) = -32768(ffff8000)\n  signed 8 -1(ffffffff) << 80(50) = -65536(ffff0000)\n  signed 8 -1(ffffffff) << 81(51) = -131072(fffe0000)\n  signed 8 -1(ffffffff) << 82(52) = -262144(fffc0000)\n  signed 8 -1(ffffffff) << 83(53) = -524288(fff80000)\n  signed 8 -1(ffffffff) << 84(54) = -1048576(fff00000)\n  signed 8 -1(ffffffff) << 85(55) = -2097152(ffe00000)\n  signed 8 -1(ffffffff) << 86(56) = -4194304(ffc00000)\n  signed 8 -1(ffffffff) << 87(57) = -8388608(ff800000)\n  signed 8 -1(ffffffff) << 88(58) = -16777216(ff000000)\n  signed 8 -1(ffffffff) << 89(59) = -33554432(fe000000)\n  signed 8 -1(ffffffff) << 90(5a) = -67108864(fc000000)\n  signed 8 -1(ffffffff) << 91(5b) = -134217728(f8000000)\n  signed 8 -1(ffffffff) << 92(5c) = -268435456(f0000000)\n  signed 8 -1(ffffffff) << 93(5d) = -536870912(e0000000)\n  signed 8 -1(ffffffff) << 94(5e) = -1073741824(c0000000)\n  signed 8 -1(ffffffff) << 95(5f) = -2147483648(80000000)\n  signed 8 -1(ffffffff) << 96(60) = 0(0)\n  signed 8 -1(ffffffff) << 97(61) = 0(0)\n  signed 8 -1(ffffffff) << 98(62) = 0(0)\n  signed 8 -1(ffffffff) << 99(63) = 0(0)\n  signed 8 -1(ffffffff) << 100(64) = 0(0)\n  signed 8 -1(ffffffff) << 101(65) = 0(0)\n  signed 8 -1(ffffffff) << 102(66) = 0(0)\n  signed 8 -1(ffffffff) << 103(67) = 0(0)\n  signed 8 -1(ffffffff) << 104(68) = 0(0)\n  signed 8 -1(ffffffff) << 105(69) = 0(0)\n  signed 8 -1(ffffffff) << 106(6a) = 0(0)\n  signed 8 -1(ffffffff) << 107(6b) = 0(0)\n  signed 8 -1(ffffffff) << 108(6c) = 0(0)\n  signed 8 -1(ffffffff) << 109(6d) = 0(0)\n  signed 8 -1(ffffffff) << 110(6e) = 0(0)\n  signed 8 -1(ffffffff) << 111(6f) = 0(0)\n  signed 8 -1(ffffffff) << 112(70) = 0(0)\n  signed 8 -1(ffffffff) << 113(71) = 0(0)\n  signed 8 -1(ffffffff) << 114(72) = 0(0)\n  signed 8 -1(ffffffff) << 115(73) = 0(0)\n  signed 8 -1(ffffffff) << 116(74) = 0(0)\n  signed 8 -1(ffffffff) << 117(75) = 0(0)\n  signed 8 -1(ffffffff) << 118(76) = 0(0)\n  signed 8 -1(ffffffff) << 119(77) = 0(0)\n  signed 8 -1(ffffffff) << 120(78) = 0(0)\n  signed 8 -1(ffffffff) << 121(79) = 0(0)\n  signed 8 -1(ffffffff) << 122(7a) = 0(0)\n  signed 8 -1(ffffffff) << 123(7b) = 0(0)\n  signed 8 -1(ffffffff) << 124(7c) = 0(0)\n  signed 8 -1(ffffffff) << 125(7d) = 0(0)\n  signed 8 -1(ffffffff) << 126(7e) = 0(0)\n  signed 8 -1(ffffffff) << 127(7f) = 0(0)\n  signed 8 0(0) << -128(ffffff80) = 0(0)\n  signed 8 0(0) << -127(ffffff81) = 0(0)\n  signed 8 0(0) << -126(ffffff82) = 0(0)\n  signed 8 0(0) << -125(ffffff83) = 0(0)\n  signed 8 0(0) << -124(ffffff84) = 0(0)\n  signed 8 0(0) << -123(ffffff85) = 0(0)\n  signed 8 0(0) << -122(ffffff86) = 0(0)\n  signed 8 0(0) << -121(ffffff87) = 0(0)\n  signed 8 0(0) << -120(ffffff88) = 0(0)\n  signed 8 0(0) << -119(ffffff89) = 0(0)\n  signed 8 0(0) << -118(ffffff8a) = 0(0)\n  signed 8 0(0) << -117(ffffff8b) = 0(0)\n  signed 8 0(0) << -116(ffffff8c) = 0(0)\n  signed 8 0(0) << -115(ffffff8d) = 0(0)\n  signed 8 0(0) << -114(ffffff8e) = 0(0)\n  signed 8 0(0) << -113(ffffff8f) = 0(0)\n  signed 8 0(0) << -112(ffffff90) = 0(0)\n  signed 8 0(0) << -111(ffffff91) = 0(0)\n  signed 8 0(0) << -110(ffffff92) = 0(0)\n  signed 8 0(0) << -109(ffffff93) = 0(0)\n  signed 8 0(0) << -108(ffffff94) = 0(0)\n  signed 8 0(0) << -107(ffffff95) = 0(0)\n  signed 8 0(0) << -106(ffffff96) = 0(0)\n  signed 8 0(0) << -105(ffffff97) = 0(0)\n  signed 8 0(0) << -104(ffffff98) = 0(0)\n  signed 8 0(0) << -103(ffffff99) = 0(0)\n  signed 8 0(0) << -102(ffffff9a) = 0(0)\n  signed 8 0(0) << -101(ffffff9b) = 0(0)\n  signed 8 0(0) << -100(ffffff9c) = 0(0)\n  signed 8 0(0) << -99(ffffff9d) = 0(0)\n  signed 8 0(0) << -98(ffffff9e) = 0(0)\n  signed 8 0(0) << -97(ffffff9f) = 0(0)\n  signed 8 0(0) << -96(ffffffa0) = 0(0)\n  signed 8 0(0) << -95(ffffffa1) = 0(0)\n  signed 8 0(0) << -94(ffffffa2) = 0(0)\n  signed 8 0(0) << -93(ffffffa3) = 0(0)\n  signed 8 0(0) << -92(ffffffa4) = 0(0)\n  signed 8 0(0) << -91(ffffffa5) = 0(0)\n  signed 8 0(0) << -90(ffffffa6) = 0(0)\n  signed 8 0(0) << -89(ffffffa7) = 0(0)\n  signed 8 0(0) << -88(ffffffa8) = 0(0)\n  signed 8 0(0) << -87(ffffffa9) = 0(0)\n  signed 8 0(0) << -86(ffffffaa) = 0(0)\n  signed 8 0(0) << -85(ffffffab) = 0(0)\n  signed 8 0(0) << -84(ffffffac) = 0(0)\n  signed 8 0(0) << -83(ffffffad) = 0(0)\n  signed 8 0(0) << -82(ffffffae) = 0(0)\n  signed 8 0(0) << -81(ffffffaf) = 0(0)\n  signed 8 0(0) << -80(ffffffb0) = 0(0)\n  signed 8 0(0) << -79(ffffffb1) = 0(0)\n  signed 8 0(0) << -78(ffffffb2) = 0(0)\n  signed 8 0(0) << -77(ffffffb3) = 0(0)\n  signed 8 0(0) << -76(ffffffb4) = 0(0)\n  signed 8 0(0) << -75(ffffffb5) = 0(0)\n  signed 8 0(0) << -74(ffffffb6) = 0(0)\n  signed 8 0(0) << -73(ffffffb7) = 0(0)\n  signed 8 0(0) << -72(ffffffb8) = 0(0)\n  signed 8 0(0) << -71(ffffffb9) = 0(0)\n  signed 8 0(0) << -70(ffffffba) = 0(0)\n  signed 8 0(0) << -69(ffffffbb) = 0(0)\n  signed 8 0(0) << -68(ffffffbc) = 0(0)\n  signed 8 0(0) << -67(ffffffbd) = 0(0)\n  signed 8 0(0) << -66(ffffffbe) = 0(0)\n  signed 8 0(0) << -65(ffffffbf) = 0(0)\n  signed 8 0(0) << -64(ffffffc0) = 0(0)\n  signed 8 0(0) << -63(ffffffc1) = 0(0)\n  signed 8 0(0) << -62(ffffffc2) = 0(0)\n  signed 8 0(0) << -61(ffffffc3) = 0(0)\n  signed 8 0(0) << -60(ffffffc4) = 0(0)\n  signed 8 0(0) << -59(ffffffc5) = 0(0)\n  signed 8 0(0) << -58(ffffffc6) = 0(0)\n  signed 8 0(0) << -57(ffffffc7) = 0(0)\n  signed 8 0(0) << -56(ffffffc8) = 0(0)\n  signed 8 0(0) << -55(ffffffc9) = 0(0)\n  signed 8 0(0) << -54(ffffffca) = 0(0)\n  signed 8 0(0) << -53(ffffffcb) = 0(0)\n  signed 8 0(0) << -52(ffffffcc) = 0(0)\n  signed 8 0(0) << -51(ffffffcd) = 0(0)\n  signed 8 0(0) << -50(ffffffce) = 0(0)\n  signed 8 0(0) << -49(ffffffcf) = 0(0)\n  signed 8 0(0) << -48(ffffffd0) = 0(0)\n  signed 8 0(0) << -47(ffffffd1) = 0(0)\n  signed 8 0(0) << -46(ffffffd2) = 0(0)\n  signed 8 0(0) << -45(ffffffd3) = 0(0)\n  signed 8 0(0) << -44(ffffffd4) = 0(0)\n  signed 8 0(0) << -43(ffffffd5) = 0(0)\n  signed 8 0(0) << -42(ffffffd6) = 0(0)\n  signed 8 0(0) << -41(ffffffd7) = 0(0)\n  signed 8 0(0) << -40(ffffffd8) = 0(0)\n  signed 8 0(0) << -39(ffffffd9) = 0(0)\n  signed 8 0(0) << -38(ffffffda) = 0(0)\n  signed 8 0(0) << -37(ffffffdb) = 0(0)\n  signed 8 0(0) << -36(ffffffdc) = 0(0)\n  signed 8 0(0) << -35(ffffffdd) = 0(0)\n  signed 8 0(0) << -34(ffffffde) = 0(0)\n  signed 8 0(0) << -33(ffffffdf) = 0(0)\n  signed 8 0(0) << -32(ffffffe0) = 0(0)\n  signed 8 0(0) << -31(ffffffe1) = 0(0)\n  signed 8 0(0) << -30(ffffffe2) = 0(0)\n  signed 8 0(0) << -29(ffffffe3) = 0(0)\n  signed 8 0(0) << -28(ffffffe4) = 0(0)\n  signed 8 0(0) << -27(ffffffe5) = 0(0)\n  signed 8 0(0) << -26(ffffffe6) = 0(0)\n  signed 8 0(0) << -25(ffffffe7) = 0(0)\n  signed 8 0(0) << -24(ffffffe8) = 0(0)\n  signed 8 0(0) << -23(ffffffe9) = 0(0)\n  signed 8 0(0) << -22(ffffffea) = 0(0)\n  signed 8 0(0) << -21(ffffffeb) = 0(0)\n  signed 8 0(0) << -20(ffffffec) = 0(0)\n  signed 8 0(0) << -19(ffffffed) = 0(0)\n  signed 8 0(0) << -18(ffffffee) = 0(0)\n  signed 8 0(0) << -17(ffffffef) = 0(0)\n  signed 8 0(0) << -16(fffffff0) = 0(0)\n  signed 8 0(0) << -15(fffffff1) = 0(0)\n  signed 8 0(0) << -14(fffffff2) = 0(0)\n  signed 8 0(0) << -13(fffffff3) = 0(0)\n  signed 8 0(0) << -12(fffffff4) = 0(0)\n  signed 8 0(0) << -11(fffffff5) = 0(0)\n  signed 8 0(0) << -10(fffffff6) = 0(0)\n  signed 8 0(0) << -9(fffffff7) = 0(0)\n  signed 8 0(0) << -8(fffffff8) = 0(0)\n  signed 8 0(0) << -7(fffffff9) = 0(0)\n  signed 8 0(0) << -6(fffffffa) = 0(0)\n  signed 8 0(0) << -5(fffffffb) = 0(0)\n  signed 8 0(0) << -4(fffffffc) = 0(0)\n  signed 8 0(0) << -3(fffffffd) = 0(0)\n  signed 8 0(0) << -2(fffffffe) = 0(0)\n  signed 8 0(0) << -1(ffffffff) = 0(0)\n  signed 8 0(0) << 0(0) = 0(0)\n  signed 8 0(0) << 1(1) = 0(0)\n  signed 8 0(0) << 2(2) = 0(0)\n  signed 8 0(0) << 3(3) = 0(0)\n  signed 8 0(0) << 4(4) = 0(0)\n  signed 8 0(0) << 5(5) = 0(0)\n  signed 8 0(0) << 6(6) = 0(0)\n  signed 8 0(0) << 7(7) = 0(0)\n  signed 8 0(0) << 8(8) = 0(0)\n  signed 8 0(0) << 9(9) = 0(0)\n  signed 8 0(0) << 10(a) = 0(0)\n  signed 8 0(0) << 11(b) = 0(0)\n  signed 8 0(0) << 12(c) = 0(0)\n  signed 8 0(0) << 13(d) = 0(0)\n  signed 8 0(0) << 14(e) = 0(0)\n  signed 8 0(0) << 15(f) = 0(0)\n  signed 8 0(0) << 16(10) = 0(0)\n  signed 8 0(0) << 17(11) = 0(0)\n  signed 8 0(0) << 18(12) = 0(0)\n  signed 8 0(0) << 19(13) = 0(0)\n  signed 8 0(0) << 20(14) = 0(0)\n  signed 8 0(0) << 21(15) = 0(0)\n  signed 8 0(0) << 22(16) = 0(0)\n  signed 8 0(0) << 23(17) = 0(0)\n  signed 8 0(0) << 24(18) = 0(0)\n  signed 8 0(0) << 25(19) = 0(0)\n  signed 8 0(0) << 26(1a) = 0(0)\n  signed 8 0(0) << 27(1b) = 0(0)\n  signed 8 0(0) << 28(1c) = 0(0)\n  signed 8 0(0) << 29(1d) = 0(0)\n  signed 8 0(0) << 30(1e) = 0(0)\n  signed 8 0(0) << 31(1f) = 0(0)\n  signed 8 0(0) << 32(20) = 0(0)\n  signed 8 0(0) << 33(21) = 0(0)\n  signed 8 0(0) << 34(22) = 0(0)\n  signed 8 0(0) << 35(23) = 0(0)\n  signed 8 0(0) << 36(24) = 0(0)\n  signed 8 0(0) << 37(25) = 0(0)\n  signed 8 0(0) << 38(26) = 0(0)\n  signed 8 0(0) << 39(27) = 0(0)\n  signed 8 0(0) << 40(28) = 0(0)\n  signed 8 0(0) << 41(29) = 0(0)\n  signed 8 0(0) << 42(2a) = 0(0)\n  signed 8 0(0) << 43(2b) = 0(0)\n  signed 8 0(0) << 44(2c) = 0(0)\n  signed 8 0(0) << 45(2d) = 0(0)\n  signed 8 0(0) << 46(2e) = 0(0)\n  signed 8 0(0) << 47(2f) = 0(0)\n  signed 8 0(0) << 48(30) = 0(0)\n  signed 8 0(0) << 49(31) = 0(0)\n  signed 8 0(0) << 50(32) = 0(0)\n  signed 8 0(0) << 51(33) = 0(0)\n  signed 8 0(0) << 52(34) = 0(0)\n  signed 8 0(0) << 53(35) = 0(0)\n  signed 8 0(0) << 54(36) = 0(0)\n  signed 8 0(0) << 55(37) = 0(0)\n  signed 8 0(0) << 56(38) = 0(0)\n  signed 8 0(0) << 57(39) = 0(0)\n  signed 8 0(0) << 58(3a) = 0(0)\n  signed 8 0(0) << 59(3b) = 0(0)\n  signed 8 0(0) << 60(3c) = 0(0)\n  signed 8 0(0) << 61(3d) = 0(0)\n  signed 8 0(0) << 62(3e) = 0(0)\n  signed 8 0(0) << 63(3f) = 0(0)\n  signed 8 0(0) << 64(40) = 0(0)\n  signed 8 0(0) << 65(41) = 0(0)\n  signed 8 0(0) << 66(42) = 0(0)\n  signed 8 0(0) << 67(43) = 0(0)\n  signed 8 0(0) << 68(44) = 0(0)\n  signed 8 0(0) << 69(45) = 0(0)\n  signed 8 0(0) << 70(46) = 0(0)\n  signed 8 0(0) << 71(47) = 0(0)\n  signed 8 0(0) << 72(48) = 0(0)\n  signed 8 0(0) << 73(49) = 0(0)\n  signed 8 0(0) << 74(4a) = 0(0)\n  signed 8 0(0) << 75(4b) = 0(0)\n  signed 8 0(0) << 76(4c) = 0(0)\n  signed 8 0(0) << 77(4d) = 0(0)\n  signed 8 0(0) << 78(4e) = 0(0)\n  signed 8 0(0) << 79(4f) = 0(0)\n  signed 8 0(0) << 80(50) = 0(0)\n  signed 8 0(0) << 81(51) = 0(0)\n  signed 8 0(0) << 82(52) = 0(0)\n  signed 8 0(0) << 83(53) = 0(0)\n  signed 8 0(0) << 84(54) = 0(0)\n  signed 8 0(0) << 85(55) = 0(0)\n  signed 8 0(0) << 86(56) = 0(0)\n  signed 8 0(0) << 87(57) = 0(0)\n  signed 8 0(0) << 88(58) = 0(0)\n  signed 8 0(0) << 89(59) = 0(0)\n  signed 8 0(0) << 90(5a) = 0(0)\n  signed 8 0(0) << 91(5b) = 0(0)\n  signed 8 0(0) << 92(5c) = 0(0)\n  signed 8 0(0) << 93(5d) = 0(0)\n  signed 8 0(0) << 94(5e) = 0(0)\n  signed 8 0(0) << 95(5f) = 0(0)\n  signed 8 0(0) << 96(60) = 0(0)\n  signed 8 0(0) << 97(61) = 0(0)\n  signed 8 0(0) << 98(62) = 0(0)\n  signed 8 0(0) << 99(63) = 0(0)\n  signed 8 0(0) << 100(64) = 0(0)\n  signed 8 0(0) << 101(65) = 0(0)\n  signed 8 0(0) << 102(66) = 0(0)\n  signed 8 0(0) << 103(67) = 0(0)\n  signed 8 0(0) << 104(68) = 0(0)\n  signed 8 0(0) << 105(69) = 0(0)\n  signed 8 0(0) << 106(6a) = 0(0)\n  signed 8 0(0) << 107(6b) = 0(0)\n  signed 8 0(0) << 108(6c) = 0(0)\n  signed 8 0(0) << 109(6d) = 0(0)\n  signed 8 0(0) << 110(6e) = 0(0)\n  signed 8 0(0) << 111(6f) = 0(0)\n  signed 8 0(0) << 112(70) = 0(0)\n  signed 8 0(0) << 113(71) = 0(0)\n  signed 8 0(0) << 114(72) = 0(0)\n  signed 8 0(0) << 115(73) = 0(0)\n  signed 8 0(0) << 116(74) = 0(0)\n  signed 8 0(0) << 117(75) = 0(0)\n  signed 8 0(0) << 118(76) = 0(0)\n  signed 8 0(0) << 119(77) = 0(0)\n  signed 8 0(0) << 120(78) = 0(0)\n  signed 8 0(0) << 121(79) = 0(0)\n  signed 8 0(0) << 122(7a) = 0(0)\n  signed 8 0(0) << 123(7b) = 0(0)\n  signed 8 0(0) << 124(7c) = 0(0)\n  signed 8 0(0) << 125(7d) = 0(0)\n  signed 8 0(0) << 126(7e) = 0(0)\n  signed 8 0(0) << 127(7f) = 0(0)\n  signed 8 1(1) << -128(ffffff80) = 1(1)\n  signed 8 1(1) << -127(ffffff81) = 2(2)\n  signed 8 1(1) << -126(ffffff82) = 4(4)\n  signed 8 1(1) << -125(ffffff83) = 8(8)\n  signed 8 1(1) << -124(ffffff84) = 16(10)\n  signed 8 1(1) << -123(ffffff85) = 32(20)\n  signed 8 1(1) << -122(ffffff86) = 64(40)\n  signed 8 1(1) << -121(ffffff87) = 128(80)\n  signed 8 1(1) << -120(ffffff88) = 256(100)\n  signed 8 1(1) << -119(ffffff89) = 512(200)\n  signed 8 1(1) << -118(ffffff8a) = 1024(400)\n  signed 8 1(1) << -117(ffffff8b) = 2048(800)\n  signed 8 1(1) << -116(ffffff8c) = 4096(1000)\n  signed 8 1(1) << -115(ffffff8d) = 8192(2000)\n  signed 8 1(1) << -114(ffffff8e) = 16384(4000)\n  signed 8 1(1) << -113(ffffff8f) = 32768(8000)\n  signed 8 1(1) << -112(ffffff90) = 65536(10000)\n  signed 8 1(1) << -111(ffffff91) = 131072(20000)\n  signed 8 1(1) << -110(ffffff92) = 262144(40000)\n  signed 8 1(1) << -109(ffffff93) = 524288(80000)\n  signed 8 1(1) << -108(ffffff94) = 1048576(100000)\n  signed 8 1(1) << -107(ffffff95) = 2097152(200000)\n  signed 8 1(1) << -106(ffffff96) = 4194304(400000)\n  signed 8 1(1) << -105(ffffff97) = 8388608(800000)\n  signed 8 1(1) << -104(ffffff98) = 16777216(1000000)\n  signed 8 1(1) << -103(ffffff99) = 33554432(2000000)\n  signed 8 1(1) << -102(ffffff9a) = 67108864(4000000)\n  signed 8 1(1) << -101(ffffff9b) = 134217728(8000000)\n  signed 8 1(1) << -100(ffffff9c) = 268435456(10000000)\n  signed 8 1(1) << -99(ffffff9d) = 536870912(20000000)\n  signed 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\n  signed 8 1(1) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 1(1) << -96(ffffffa0) = 0(0)\n  signed 8 1(1) << -95(ffffffa1) = 0(0)\n  signed 8 1(1) << -94(ffffffa2) = 0(0)\n  signed 8 1(1) << -93(ffffffa3) = 0(0)\n  signed 8 1(1) << -92(ffffffa4) = 0(0)\n  signed 8 1(1) << -91(ffffffa5) = 0(0)\n  signed 8 1(1) << -90(ffffffa6) = 0(0)\n  signed 8 1(1) << -89(ffffffa7) = 0(0)\n  signed 8 1(1) << -88(ffffffa8) = 0(0)\n  signed 8 1(1) << -87(ffffffa9) = 0(0)\n  signed 8 1(1) << -86(ffffffaa) = 0(0)\n  signed 8 1(1) << -85(ffffffab) = 0(0)\n  signed 8 1(1) << -84(ffffffac) = 0(0)\n  signed 8 1(1) << -83(ffffffad) = 0(0)\n  signed 8 1(1) << -82(ffffffae) = 0(0)\n  signed 8 1(1) << -81(ffffffaf) = 0(0)\n  signed 8 1(1) << -80(ffffffb0) = 0(0)\n  signed 8 1(1) << -79(ffffffb1) = 0(0)\n  signed 8 1(1) << -78(ffffffb2) = 0(0)\n  signed 8 1(1) << -77(ffffffb3) = 0(0)\n  signed 8 1(1) << -76(ffffffb4) = 0(0)\n  signed 8 1(1) << -75(ffffffb5) = 0(0)\n  signed 8 1(1) << -74(ffffffb6) = 0(0)\n  signed 8 1(1) << -73(ffffffb7) = 0(0)\n  signed 8 1(1) << -72(ffffffb8) = 0(0)\n  signed 8 1(1) << -71(ffffffb9) = 0(0)\n  signed 8 1(1) << -70(ffffffba) = 0(0)\n  signed 8 1(1) << -69(ffffffbb) = 0(0)\n  signed 8 1(1) << -68(ffffffbc) = 0(0)\n  signed 8 1(1) << -67(ffffffbd) = 0(0)\n  signed 8 1(1) << -66(ffffffbe) = 0(0)\n  signed 8 1(1) << -65(ffffffbf) = 0(0)\n  signed 8 1(1) << -64(ffffffc0) = 1(1)\n  signed 8 1(1) << -63(ffffffc1) = 2(2)\n  signed 8 1(1) << -62(ffffffc2) = 4(4)\n  signed 8 1(1) << -61(ffffffc3) = 8(8)\n  signed 8 1(1) << -60(ffffffc4) = 16(10)\n  signed 8 1(1) << -59(ffffffc5) = 32(20)\n  signed 8 1(1) << -58(ffffffc6) = 64(40)\n  signed 8 1(1) << -57(ffffffc7) = 128(80)\n  signed 8 1(1) << -56(ffffffc8) = 256(100)\n  signed 8 1(1) << -55(ffffffc9) = 512(200)\n  signed 8 1(1) << -54(ffffffca) = 1024(400)\n  signed 8 1(1) << -53(ffffffcb) = 2048(800)\n  signed 8 1(1) << -52(ffffffcc) = 4096(1000)\n  signed 8 1(1) << -51(ffffffcd) = 8192(2000)\n  signed 8 1(1) << -50(ffffffce) = 16384(4000)\n  signed 8 1(1) << -49(ffffffcf) = 32768(8000)\n  signed 8 1(1) << -48(ffffffd0) = 65536(10000)\n  signed 8 1(1) << -47(ffffffd1) = 131072(20000)\n  signed 8 1(1) << -46(ffffffd2) = 262144(40000)\n  signed 8 1(1) << -45(ffffffd3) = 524288(80000)\n  signed 8 1(1) << -44(ffffffd4) = 1048576(100000)\n  signed 8 1(1) << -43(ffffffd5) = 2097152(200000)\n  signed 8 1(1) << -42(ffffffd6) = 4194304(400000)\n  signed 8 1(1) << -41(ffffffd7) = 8388608(800000)\n  signed 8 1(1) << -40(ffffffd8) = 16777216(1000000)\n  signed 8 1(1) << -39(ffffffd9) = 33554432(2000000)\n  signed 8 1(1) << -38(ffffffda) = 67108864(4000000)\n  signed 8 1(1) << -37(ffffffdb) = 134217728(8000000)\n  signed 8 1(1) << -36(ffffffdc) = 268435456(10000000)\n  signed 8 1(1) << -35(ffffffdd) = 536870912(20000000)\n  signed 8 1(1) << -34(ffffffde) = 1073741824(40000000)\n  signed 8 1(1) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 1(1) << -32(ffffffe0) = 0(0)\n  signed 8 1(1) << -31(ffffffe1) = 0(0)\n  signed 8 1(1) << -30(ffffffe2) = 0(0)\n  signed 8 1(1) << -29(ffffffe3) = 0(0)\n  signed 8 1(1) << -28(ffffffe4) = 0(0)\n  signed 8 1(1) << -27(ffffffe5) = 0(0)\n  signed 8 1(1) << -26(ffffffe6) = 0(0)\n  signed 8 1(1) << -25(ffffffe7) = 0(0)\n  signed 8 1(1) << -24(ffffffe8) = 0(0)\n  signed 8 1(1) << -23(ffffffe9) = 0(0)\n  signed 8 1(1) << -22(ffffffea) = 0(0)\n  signed 8 1(1) << -21(ffffffeb) = 0(0)\n  signed 8 1(1) << -20(ffffffec) = 0(0)\n  signed 8 1(1) << -19(ffffffed) = 0(0)\n  signed 8 1(1) << -18(ffffffee) = 0(0)\n  signed 8 1(1) << -17(ffffffef) = 0(0)\n  signed 8 1(1) << -16(fffffff0) = 0(0)\n  signed 8 1(1) << -15(fffffff1) = 0(0)\n  signed 8 1(1) << -14(fffffff2) = 0(0)\n  signed 8 1(1) << -13(fffffff3) = 0(0)\n  signed 8 1(1) << -12(fffffff4) = 0(0)\n  signed 8 1(1) << -11(fffffff5) = 0(0)\n  signed 8 1(1) << -10(fffffff6) = 0(0)\n  signed 8 1(1) << -9(fffffff7) = 0(0)\n  signed 8 1(1) << -8(fffffff8) = 0(0)\n  signed 8 1(1) << -7(fffffff9) = 0(0)\n  signed 8 1(1) << -6(fffffffa) = 0(0)\n  signed 8 1(1) << -5(fffffffb) = 0(0)\n  signed 8 1(1) << -4(fffffffc) = 0(0)\n  signed 8 1(1) << -3(fffffffd) = 0(0)\n  signed 8 1(1) << -2(fffffffe) = 0(0)\n  signed 8 1(1) << -1(ffffffff) = 0(0)\n  signed 8 1(1) << 0(0) = 1(1)\n  signed 8 1(1) << 1(1) = 2(2)\n  signed 8 1(1) << 2(2) = 4(4)\n  signed 8 1(1) << 3(3) = 8(8)\n  signed 8 1(1) << 4(4) = 16(10)\n  signed 8 1(1) << 5(5) = 32(20)\n  signed 8 1(1) << 6(6) = 64(40)\n  signed 8 1(1) << 7(7) = 128(80)\n  signed 8 1(1) << 8(8) = 256(100)\n  signed 8 1(1) << 9(9) = 512(200)\n  signed 8 1(1) << 10(a) = 1024(400)\n  signed 8 1(1) << 11(b) = 2048(800)\n  signed 8 1(1) << 12(c) = 4096(1000)\n  signed 8 1(1) << 13(d) = 8192(2000)\n  signed 8 1(1) << 14(e) = 16384(4000)\n  signed 8 1(1) << 15(f) = 32768(8000)\n  signed 8 1(1) << 16(10) = 65536(10000)\n  signed 8 1(1) << 17(11) = 131072(20000)\n  signed 8 1(1) << 18(12) = 262144(40000)\n  signed 8 1(1) << 19(13) = 524288(80000)\n  signed 8 1(1) << 20(14) = 1048576(100000)\n  signed 8 1(1) << 21(15) = 2097152(200000)\n  signed 8 1(1) << 22(16) = 4194304(400000)\n  signed 8 1(1) << 23(17) = 8388608(800000)\n  signed 8 1(1) << 24(18) = 16777216(1000000)\n  signed 8 1(1) << 25(19) = 33554432(2000000)\n  signed 8 1(1) << 26(1a) = 67108864(4000000)\n  signed 8 1(1) << 27(1b) = 134217728(8000000)\n  signed 8 1(1) << 28(1c) = 268435456(10000000)\n  signed 8 1(1) << 29(1d) = 536870912(20000000)\n  signed 8 1(1) << 30(1e) = 1073741824(40000000)\n  signed 8 1(1) << 31(1f) = -2147483648(80000000)\n  signed 8 1(1) << 32(20) = 0(0)\n  signed 8 1(1) << 33(21) = 0(0)\n  signed 8 1(1) << 34(22) = 0(0)\n  signed 8 1(1) << 35(23) = 0(0)\n  signed 8 1(1) << 36(24) = 0(0)\n  signed 8 1(1) << 37(25) = 0(0)\n  signed 8 1(1) << 38(26) = 0(0)\n  signed 8 1(1) << 39(27) = 0(0)\n  signed 8 1(1) << 40(28) = 0(0)\n  signed 8 1(1) << 41(29) = 0(0)\n  signed 8 1(1) << 42(2a) = 0(0)\n  signed 8 1(1) << 43(2b) = 0(0)\n  signed 8 1(1) << 44(2c) = 0(0)\n  signed 8 1(1) << 45(2d) = 0(0)\n  signed 8 1(1) << 46(2e) = 0(0)\n  signed 8 1(1) << 47(2f) = 0(0)\n  signed 8 1(1) << 48(30) = 0(0)\n  signed 8 1(1) << 49(31) = 0(0)\n  signed 8 1(1) << 50(32) = 0(0)\n  signed 8 1(1) << 51(33) = 0(0)\n  signed 8 1(1) << 52(34) = 0(0)\n  signed 8 1(1) << 53(35) = 0(0)\n  signed 8 1(1) << 54(36) = 0(0)\n  signed 8 1(1) << 55(37) = 0(0)\n  signed 8 1(1) << 56(38) = 0(0)\n  signed 8 1(1) << 57(39) = 0(0)\n  signed 8 1(1) << 58(3a) = 0(0)\n  signed 8 1(1) << 59(3b) = 0(0)\n  signed 8 1(1) << 60(3c) = 0(0)\n  signed 8 1(1) << 61(3d) = 0(0)\n  signed 8 1(1) << 62(3e) = 0(0)\n  signed 8 1(1) << 63(3f) = 0(0)\n  signed 8 1(1) << 64(40) = 1(1)\n  signed 8 1(1) << 65(41) = 2(2)\n  signed 8 1(1) << 66(42) = 4(4)\n  signed 8 1(1) << 67(43) = 8(8)\n  signed 8 1(1) << 68(44) = 16(10)\n  signed 8 1(1) << 69(45) = 32(20)\n  signed 8 1(1) << 70(46) = 64(40)\n  signed 8 1(1) << 71(47) = 128(80)\n  signed 8 1(1) << 72(48) = 256(100)\n  signed 8 1(1) << 73(49) = 512(200)\n  signed 8 1(1) << 74(4a) = 1024(400)\n  signed 8 1(1) << 75(4b) = 2048(800)\n  signed 8 1(1) << 76(4c) = 4096(1000)\n  signed 8 1(1) << 77(4d) = 8192(2000)\n  signed 8 1(1) << 78(4e) = 16384(4000)\n  signed 8 1(1) << 79(4f) = 32768(8000)\n  signed 8 1(1) << 80(50) = 65536(10000)\n  signed 8 1(1) << 81(51) = 131072(20000)\n  signed 8 1(1) << 82(52) = 262144(40000)\n  signed 8 1(1) << 83(53) = 524288(80000)\n  signed 8 1(1) << 84(54) = 1048576(100000)\n  signed 8 1(1) << 85(55) = 2097152(200000)\n  signed 8 1(1) << 86(56) = 4194304(400000)\n  signed 8 1(1) << 87(57) = 8388608(800000)\n  signed 8 1(1) << 88(58) = 16777216(1000000)\n  signed 8 1(1) << 89(59) = 33554432(2000000)\n  signed 8 1(1) << 90(5a) = 67108864(4000000)\n  signed 8 1(1) << 91(5b) = 134217728(8000000)\n  signed 8 1(1) << 92(5c) = 268435456(10000000)\n  signed 8 1(1) << 93(5d) = 536870912(20000000)\n  signed 8 1(1) << 94(5e) = 1073741824(40000000)\n  signed 8 1(1) << 95(5f) = -2147483648(80000000)\n  signed 8 1(1) << 96(60) = 0(0)\n  signed 8 1(1) << 97(61) = 0(0)\n  signed 8 1(1) << 98(62) = 0(0)\n  signed 8 1(1) << 99(63) = 0(0)\n  signed 8 1(1) << 100(64) = 0(0)\n  signed 8 1(1) << 101(65) = 0(0)\n  signed 8 1(1) << 102(66) = 0(0)\n  signed 8 1(1) << 103(67) = 0(0)\n  signed 8 1(1) << 104(68) = 0(0)\n  signed 8 1(1) << 105(69) = 0(0)\n  signed 8 1(1) << 106(6a) = 0(0)\n  signed 8 1(1) << 107(6b) = 0(0)\n  signed 8 1(1) << 108(6c) = 0(0)\n  signed 8 1(1) << 109(6d) = 0(0)\n  signed 8 1(1) << 110(6e) = 0(0)\n  signed 8 1(1) << 111(6f) = 0(0)\n  signed 8 1(1) << 112(70) = 0(0)\n  signed 8 1(1) << 113(71) = 0(0)\n  signed 8 1(1) << 114(72) = 0(0)\n  signed 8 1(1) << 115(73) = 0(0)\n  signed 8 1(1) << 116(74) = 0(0)\n  signed 8 1(1) << 117(75) = 0(0)\n  signed 8 1(1) << 118(76) = 0(0)\n  signed 8 1(1) << 119(77) = 0(0)\n  signed 8 1(1) << 120(78) = 0(0)\n  signed 8 1(1) << 121(79) = 0(0)\n  signed 8 1(1) << 122(7a) = 0(0)\n  signed 8 1(1) << 123(7b) = 0(0)\n  signed 8 1(1) << 124(7c) = 0(0)\n  signed 8 1(1) << 125(7d) = 0(0)\n  signed 8 1(1) << 126(7e) = 0(0)\n  signed 8 1(1) << 127(7f) = 0(0)\n  signed 8 2(2) << -128(ffffff80) = 2(2)\n  signed 8 2(2) << -127(ffffff81) = 4(4)\n  signed 8 2(2) << -126(ffffff82) = 8(8)\n  signed 8 2(2) << -125(ffffff83) = 16(10)\n  signed 8 2(2) << -124(ffffff84) = 32(20)\n  signed 8 2(2) << -123(ffffff85) = 64(40)\n  signed 8 2(2) << -122(ffffff86) = 128(80)\n  signed 8 2(2) << -121(ffffff87) = 256(100)\n  signed 8 2(2) << -120(ffffff88) = 512(200)\n  signed 8 2(2) << -119(ffffff89) = 1024(400)\n  signed 8 2(2) << -118(ffffff8a) = 2048(800)\n  signed 8 2(2) << -117(ffffff8b) = 4096(1000)\n  signed 8 2(2) << -116(ffffff8c) = 8192(2000)\n  signed 8 2(2) << -115(ffffff8d) = 16384(4000)\n  signed 8 2(2) << -114(ffffff8e) = 32768(8000)\n  signed 8 2(2) << -113(ffffff8f) = 65536(10000)\n  signed 8 2(2) << -112(ffffff90) = 131072(20000)\n  signed 8 2(2) << -111(ffffff91) = 262144(40000)\n  signed 8 2(2) << -110(ffffff92) = 524288(80000)\n  signed 8 2(2) << -109(ffffff93) = 1048576(100000)\n  signed 8 2(2) << -108(ffffff94) = 2097152(200000)\n  signed 8 2(2) << -107(ffffff95) = 4194304(400000)\n  signed 8 2(2) << -106(ffffff96) = 8388608(800000)\n  signed 8 2(2) << -105(ffffff97) = 16777216(1000000)\n  signed 8 2(2) << -104(ffffff98) = 33554432(2000000)\n  signed 8 2(2) << -103(ffffff99) = 67108864(4000000)\n  signed 8 2(2) << -102(ffffff9a) = 134217728(8000000)\n  signed 8 2(2) << -101(ffffff9b) = 268435456(10000000)\n  signed 8 2(2) << -100(ffffff9c) = 536870912(20000000)\n  signed 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\n  signed 8 2(2) << -98(ffffff9e) = -2147483648(80000000)\n  signed 8 2(2) << -97(ffffff9f) = 0(0)\n  signed 8 2(2) << -96(ffffffa0) = 0(0)\n  signed 8 2(2) << -95(ffffffa1) = 0(0)\n  signed 8 2(2) << -94(ffffffa2) = 0(0)\n  signed 8 2(2) << -93(ffffffa3) = 0(0)\n  signed 8 2(2) << -92(ffffffa4) = 0(0)\n  signed 8 2(2) << -91(ffffffa5) = 0(0)\n  signed 8 2(2) << -90(ffffffa6) = 0(0)\n  signed 8 2(2) << -89(ffffffa7) = 0(0)\n  signed 8 2(2) << -88(ffffffa8) = 0(0)\n  signed 8 2(2) << -87(ffffffa9) = 0(0)\n  signed 8 2(2) << -86(ffffffaa) = 0(0)\n  signed 8 2(2) << -85(ffffffab) = 0(0)\n  signed 8 2(2) << -84(ffffffac) = 0(0)\n  signed 8 2(2) << -83(ffffffad) = 0(0)\n  signed 8 2(2) << -82(ffffffae) = 0(0)\n  signed 8 2(2) << -81(ffffffaf) = 0(0)\n  signed 8 2(2) << -80(ffffffb0) = 0(0)\n  signed 8 2(2) << -79(ffffffb1) = 0(0)\n  signed 8 2(2) << -78(ffffffb2) = 0(0)\n  signed 8 2(2) << -77(ffffffb3) = 0(0)\n  signed 8 2(2) << -76(ffffffb4) = 0(0)\n  signed 8 2(2) << -75(ffffffb5) = 0(0)\n  signed 8 2(2) << -74(ffffffb6) = 0(0)\n  signed 8 2(2) << -73(ffffffb7) = 0(0)\n  signed 8 2(2) << -72(ffffffb8) = 0(0)\n  signed 8 2(2) << -71(ffffffb9) = 0(0)\n  signed 8 2(2) << -70(ffffffba) = 0(0)\n  signed 8 2(2) << -69(ffffffbb) = 0(0)\n  signed 8 2(2) << -68(ffffffbc) = 0(0)\n  signed 8 2(2) << -67(ffffffbd) = 0(0)\n  signed 8 2(2) << -66(ffffffbe) = 0(0)\n  signed 8 2(2) << -65(ffffffbf) = 0(0)\n  signed 8 2(2) << -64(ffffffc0) = 2(2)\n  signed 8 2(2) << -63(ffffffc1) = 4(4)\n  signed 8 2(2) << -62(ffffffc2) = 8(8)\n  signed 8 2(2) << -61(ffffffc3) = 16(10)\n  signed 8 2(2) << -60(ffffffc4) = 32(20)\n  signed 8 2(2) << -59(ffffffc5) = 64(40)\n  signed 8 2(2) << -58(ffffffc6) = 128(80)\n  signed 8 2(2) << -57(ffffffc7) = 256(100)\n  signed 8 2(2) << -56(ffffffc8) = 512(200)\n  signed 8 2(2) << -55(ffffffc9) = 1024(400)\n  signed 8 2(2) << -54(ffffffca) = 2048(800)\n  signed 8 2(2) << -53(ffffffcb) = 4096(1000)\n  signed 8 2(2) << -52(ffffffcc) = 8192(2000)\n  signed 8 2(2) << -51(ffffffcd) = 16384(4000)\n  signed 8 2(2) << -50(ffffffce) = 32768(8000)\n  signed 8 2(2) << -49(ffffffcf) = 65536(10000)\n  signed 8 2(2) << -48(ffffffd0) = 131072(20000)\n  signed 8 2(2) << -47(ffffffd1) = 262144(40000)\n  signed 8 2(2) << -46(ffffffd2) = 524288(80000)\n  signed 8 2(2) << -45(ffffffd3) = 1048576(100000)\n  signed 8 2(2) << -44(ffffffd4) = 2097152(200000)\n  signed 8 2(2) << -43(ffffffd5) = 4194304(400000)\n  signed 8 2(2) << -42(ffffffd6) = 8388608(800000)\n  signed 8 2(2) << -41(ffffffd7) = 16777216(1000000)\n  signed 8 2(2) << -40(ffffffd8) = 33554432(2000000)\n  signed 8 2(2) << -39(ffffffd9) = 67108864(4000000)\n  signed 8 2(2) << -38(ffffffda) = 134217728(8000000)\n  signed 8 2(2) << -37(ffffffdb) = 268435456(10000000)\n  signed 8 2(2) << -36(ffffffdc) = 536870912(20000000)\n  signed 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\n  signed 8 2(2) << -34(ffffffde) = -2147483648(80000000)\n  signed 8 2(2) << -33(ffffffdf) = 0(0)\n  signed 8 2(2) << -32(ffffffe0) = 0(0)\n  signed 8 2(2) << -31(ffffffe1) = 0(0)\n  signed 8 2(2) << -30(ffffffe2) = 0(0)\n  signed 8 2(2) << -29(ffffffe3) = 0(0)\n  signed 8 2(2) << -28(ffffffe4) = 0(0)\n  signed 8 2(2) << -27(ffffffe5) = 0(0)\n  signed 8 2(2) << -26(ffffffe6) = 0(0)\n  signed 8 2(2) << -25(ffffffe7) = 0(0)\n  signed 8 2(2) << -24(ffffffe8) = 0(0)\n  signed 8 2(2) << -23(ffffffe9) = 0(0)\n  signed 8 2(2) << -22(ffffffea) = 0(0)\n  signed 8 2(2) << -21(ffffffeb) = 0(0)\n  signed 8 2(2) << -20(ffffffec) = 0(0)\n  signed 8 2(2) << -19(ffffffed) = 0(0)\n  signed 8 2(2) << -18(ffffffee) = 0(0)\n  signed 8 2(2) << -17(ffffffef) = 0(0)\n  signed 8 2(2) << -16(fffffff0) = 0(0)\n  signed 8 2(2) << -15(fffffff1) = 0(0)\n  signed 8 2(2) << -14(fffffff2) = 0(0)\n  signed 8 2(2) << -13(fffffff3) = 0(0)\n  signed 8 2(2) << -12(fffffff4) = 0(0)\n  signed 8 2(2) << -11(fffffff5) = 0(0)\n  signed 8 2(2) << -10(fffffff6) = 0(0)\n  signed 8 2(2) << -9(fffffff7) = 0(0)\n  signed 8 2(2) << -8(fffffff8) = 0(0)\n  signed 8 2(2) << -7(fffffff9) = 0(0)\n  signed 8 2(2) << -6(fffffffa) = 0(0)\n  signed 8 2(2) << -5(fffffffb) = 0(0)\n  signed 8 2(2) << -4(fffffffc) = 0(0)\n  signed 8 2(2) << -3(fffffffd) = 0(0)\n  signed 8 2(2) << -2(fffffffe) = 0(0)\n  signed 8 2(2) << -1(ffffffff) = 0(0)\n  signed 8 2(2) << 0(0) = 2(2)\n  signed 8 2(2) << 1(1) = 4(4)\n  signed 8 2(2) << 2(2) = 8(8)\n  signed 8 2(2) << 3(3) = 16(10)\n  signed 8 2(2) << 4(4) = 32(20)\n  signed 8 2(2) << 5(5) = 64(40)\n  signed 8 2(2) << 6(6) = 128(80)\n  signed 8 2(2) << 7(7) = 256(100)\n  signed 8 2(2) << 8(8) = 512(200)\n  signed 8 2(2) << 9(9) = 1024(400)\n  signed 8 2(2) << 10(a) = 2048(800)\n  signed 8 2(2) << 11(b) = 4096(1000)\n  signed 8 2(2) << 12(c) = 8192(2000)\n  signed 8 2(2) << 13(d) = 16384(4000)\n  signed 8 2(2) << 14(e) = 32768(8000)\n  signed 8 2(2) << 15(f) = 65536(10000)\n  signed 8 2(2) << 16(10) = 131072(20000)\n  signed 8 2(2) << 17(11) = 262144(40000)\n  signed 8 2(2) << 18(12) = 524288(80000)\n  signed 8 2(2) << 19(13) = 1048576(100000)\n  signed 8 2(2) << 20(14) = 2097152(200000)\n  signed 8 2(2) << 21(15) = 4194304(400000)\n  signed 8 2(2) << 22(16) = 8388608(800000)\n  signed 8 2(2) << 23(17) = 16777216(1000000)\n  signed 8 2(2) << 24(18) = 33554432(2000000)\n  signed 8 2(2) << 25(19) = 67108864(4000000)\n  signed 8 2(2) << 26(1a) = 134217728(8000000)\n  signed 8 2(2) << 27(1b) = 268435456(10000000)\n  signed 8 2(2) << 28(1c) = 536870912(20000000)\n  signed 8 2(2) << 29(1d) = 1073741824(40000000)\n  signed 8 2(2) << 30(1e) = -2147483648(80000000)\n  signed 8 2(2) << 31(1f) = 0(0)\n  signed 8 2(2) << 32(20) = 0(0)\n  signed 8 2(2) << 33(21) = 0(0)\n  signed 8 2(2) << 34(22) = 0(0)\n  signed 8 2(2) << 35(23) = 0(0)\n  signed 8 2(2) << 36(24) = 0(0)\n  signed 8 2(2) << 37(25) = 0(0)\n  signed 8 2(2) << 38(26) = 0(0)\n  signed 8 2(2) << 39(27) = 0(0)\n  signed 8 2(2) << 40(28) = 0(0)\n  signed 8 2(2) << 41(29) = 0(0)\n  signed 8 2(2) << 42(2a) = 0(0)\n  signed 8 2(2) << 43(2b) = 0(0)\n  signed 8 2(2) << 44(2c) = 0(0)\n  signed 8 2(2) << 45(2d) = 0(0)\n  signed 8 2(2) << 46(2e) = 0(0)\n  signed 8 2(2) << 47(2f) = 0(0)\n  signed 8 2(2) << 48(30) = 0(0)\n  signed 8 2(2) << 49(31) = 0(0)\n  signed 8 2(2) << 50(32) = 0(0)\n  signed 8 2(2) << 51(33) = 0(0)\n  signed 8 2(2) << 52(34) = 0(0)\n  signed 8 2(2) << 53(35) = 0(0)\n  signed 8 2(2) << 54(36) = 0(0)\n  signed 8 2(2) << 55(37) = 0(0)\n  signed 8 2(2) << 56(38) = 0(0)\n  signed 8 2(2) << 57(39) = 0(0)\n  signed 8 2(2) << 58(3a) = 0(0)\n  signed 8 2(2) << 59(3b) = 0(0)\n  signed 8 2(2) << 60(3c) = 0(0)\n  signed 8 2(2) << 61(3d) = 0(0)\n  signed 8 2(2) << 62(3e) = 0(0)\n  signed 8 2(2) << 63(3f) = 0(0)\n  signed 8 2(2) << 64(40) = 2(2)\n  signed 8 2(2) << 65(41) = 4(4)\n  signed 8 2(2) << 66(42) = 8(8)\n  signed 8 2(2) << 67(43) = 16(10)\n  signed 8 2(2) << 68(44) = 32(20)\n  signed 8 2(2) << 69(45) = 64(40)\n  signed 8 2(2) << 70(46) = 128(80)\n  signed 8 2(2) << 71(47) = 256(100)\n  signed 8 2(2) << 72(48) = 512(200)\n  signed 8 2(2) << 73(49) = 1024(400)\n  signed 8 2(2) << 74(4a) = 2048(800)\n  signed 8 2(2) << 75(4b) = 4096(1000)\n  signed 8 2(2) << 76(4c) = 8192(2000)\n  signed 8 2(2) << 77(4d) = 16384(4000)\n  signed 8 2(2) << 78(4e) = 32768(8000)\n  signed 8 2(2) << 79(4f) = 65536(10000)\n  signed 8 2(2) << 80(50) = 131072(20000)\n  signed 8 2(2) << 81(51) = 262144(40000)\n  signed 8 2(2) << 82(52) = 524288(80000)\n  signed 8 2(2) << 83(53) = 1048576(100000)\n  signed 8 2(2) << 84(54) = 2097152(200000)\n  signed 8 2(2) << 85(55) = 4194304(400000)\n  signed 8 2(2) << 86(56) = 8388608(800000)\n  signed 8 2(2) << 87(57) = 16777216(1000000)\n  signed 8 2(2) << 88(58) = 33554432(2000000)\n  signed 8 2(2) << 89(59) = 67108864(4000000)\n  signed 8 2(2) << 90(5a) = 134217728(8000000)\n  signed 8 2(2) << 91(5b) = 268435456(10000000)\n  signed 8 2(2) << 92(5c) = 536870912(20000000)\n  signed 8 2(2) << 93(5d) = 1073741824(40000000)\n  signed 8 2(2) << 94(5e) = -2147483648(80000000)\n  signed 8 2(2) << 95(5f) = 0(0)\n  signed 8 2(2) << 96(60) = 0(0)\n  signed 8 2(2) << 97(61) = 0(0)\n  signed 8 2(2) << 98(62) = 0(0)\n  signed 8 2(2) << 99(63) = 0(0)\n  signed 8 2(2) << 100(64) = 0(0)\n  signed 8 2(2) << 101(65) = 0(0)\n  signed 8 2(2) << 102(66) = 0(0)\n  signed 8 2(2) << 103(67) = 0(0)\n  signed 8 2(2) << 104(68) = 0(0)\n  signed 8 2(2) << 105(69) = 0(0)\n  signed 8 2(2) << 106(6a) = 0(0)\n  signed 8 2(2) << 107(6b) = 0(0)\n  signed 8 2(2) << 108(6c) = 0(0)\n  signed 8 2(2) << 109(6d) = 0(0)\n  signed 8 2(2) << 110(6e) = 0(0)\n  signed 8 2(2) << 111(6f) = 0(0)\n  signed 8 2(2) << 112(70) = 0(0)\n  signed 8 2(2) << 113(71) = 0(0)\n  signed 8 2(2) << 114(72) = 0(0)\n  signed 8 2(2) << 115(73) = 0(0)\n  signed 8 2(2) << 116(74) = 0(0)\n  signed 8 2(2) << 117(75) = 0(0)\n  signed 8 2(2) << 118(76) = 0(0)\n  signed 8 2(2) << 119(77) = 0(0)\n  signed 8 2(2) << 120(78) = 0(0)\n  signed 8 2(2) << 121(79) = 0(0)\n  signed 8 2(2) << 122(7a) = 0(0)\n  signed 8 2(2) << 123(7b) = 0(0)\n  signed 8 2(2) << 124(7c) = 0(0)\n  signed 8 2(2) << 125(7d) = 0(0)\n  signed 8 2(2) << 126(7e) = 0(0)\n  signed 8 2(2) << 127(7f) = 0(0)\n  signed 8 3(3) << -128(ffffff80) = 3(3)\n  signed 8 3(3) << -127(ffffff81) = 6(6)\n  signed 8 3(3) << -126(ffffff82) = 12(c)\n  signed 8 3(3) << -125(ffffff83) = 24(18)\n  signed 8 3(3) << -124(ffffff84) = 48(30)\n  signed 8 3(3) << -123(ffffff85) = 96(60)\n  signed 8 3(3) << -122(ffffff86) = 192(c0)\n  signed 8 3(3) << -121(ffffff87) = 384(180)\n  signed 8 3(3) << -120(ffffff88) = 768(300)\n  signed 8 3(3) << -119(ffffff89) = 1536(600)\n  signed 8 3(3) << -118(ffffff8a) = 3072(c00)\n  signed 8 3(3) << -117(ffffff8b) = 6144(1800)\n  signed 8 3(3) << -116(ffffff8c) = 12288(3000)\n  signed 8 3(3) << -115(ffffff8d) = 24576(6000)\n  signed 8 3(3) << -114(ffffff8e) = 49152(c000)\n  signed 8 3(3) << -113(ffffff8f) = 98304(18000)\n  signed 8 3(3) << -112(ffffff90) = 196608(30000)\n  signed 8 3(3) << -111(ffffff91) = 393216(60000)\n  signed 8 3(3) << -110(ffffff92) = 786432(c0000)\n  signed 8 3(3) << -109(ffffff93) = 1572864(180000)\n  signed 8 3(3) << -108(ffffff94) = 3145728(300000)\n  signed 8 3(3) << -107(ffffff95) = 6291456(600000)\n  signed 8 3(3) << -106(ffffff96) = 12582912(c00000)\n  signed 8 3(3) << -105(ffffff97) = 25165824(1800000)\n  signed 8 3(3) << -104(ffffff98) = 50331648(3000000)\n  signed 8 3(3) << -103(ffffff99) = 100663296(6000000)\n  signed 8 3(3) << -102(ffffff9a) = 201326592(c000000)\n  signed 8 3(3) << -101(ffffff9b) = 402653184(18000000)\n  signed 8 3(3) << -100(ffffff9c) = 805306368(30000000)\n  signed 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\n  signed 8 3(3) << -98(ffffff9e) = -1073741824(c0000000)\n  signed 8 3(3) << -97(ffffff9f) = -2147483648(80000000)\n  signed 8 3(3) << -96(ffffffa0) = 0(0)\n  signed 8 3(3) << -95(ffffffa1) = 0(0)\n  signed 8 3(3) << -94(ffffffa2) = 0(0)\n  signed 8 3(3) << -93(ffffffa3) = 0(0)\n  signed 8 3(3) << -92(ffffffa4) = 0(0)\n  signed 8 3(3) << -91(ffffffa5) = 0(0)\n  signed 8 3(3) << -90(ffffffa6) = 0(0)\n  signed 8 3(3) << -89(ffffffa7) = 0(0)\n  signed 8 3(3) << -88(ffffffa8) = 0(0)\n  signed 8 3(3) << -87(ffffffa9) = 0(0)\n  signed 8 3(3) << -86(ffffffaa) = 0(0)\n  signed 8 3(3) << -85(ffffffab) = 0(0)\n  signed 8 3(3) << -84(ffffffac) = 0(0)\n  signed 8 3(3) << -83(ffffffad) = 0(0)\n  signed 8 3(3) << -82(ffffffae) = 0(0)\n  signed 8 3(3) << -81(ffffffaf) = 0(0)\n  signed 8 3(3) << -80(ffffffb0) = 0(0)\n  signed 8 3(3) << -79(ffffffb1) = 0(0)\n  signed 8 3(3) << -78(ffffffb2) = 0(0)\n  signed 8 3(3) << -77(ffffffb3) = 0(0)\n  signed 8 3(3) << -76(ffffffb4) = 0(0)\n  signed 8 3(3) << -75(ffffffb5) = 0(0)\n  signed 8 3(3) << -74(ffffffb6) = 0(0)\n  signed 8 3(3) << -73(ffffffb7) = 0(0)\n  signed 8 3(3) << -72(ffffffb8) = 0(0)\n  signed 8 3(3) << -71(ffffffb9) = 0(0)\n  signed 8 3(3) << -70(ffffffba) = 0(0)\n  signed 8 3(3) << -69(ffffffbb) = 0(0)\n  signed 8 3(3) << -68(ffffffbc) = 0(0)\n  signed 8 3(3) << -67(ffffffbd) = 0(0)\n  signed 8 3(3) << -66(ffffffbe) = 0(0)\n  signed 8 3(3) << -65(ffffffbf) = 0(0)\n  signed 8 3(3) << -64(ffffffc0) = 3(3)\n  signed 8 3(3) << -63(ffffffc1) = 6(6)\n  signed 8 3(3) << -62(ffffffc2) = 12(c)\n  signed 8 3(3) << -61(ffffffc3) = 24(18)\n  signed 8 3(3) << -60(ffffffc4) = 48(30)\n  signed 8 3(3) << -59(ffffffc5) = 96(60)\n  signed 8 3(3) << -58(ffffffc6) = 192(c0)\n  signed 8 3(3) << -57(ffffffc7) = 384(180)\n  signed 8 3(3) << -56(ffffffc8) = 768(300)\n  signed 8 3(3) << -55(ffffffc9) = 1536(600)\n  signed 8 3(3) << -54(ffffffca) = 3072(c00)\n  signed 8 3(3) << -53(ffffffcb) = 6144(1800)\n  signed 8 3(3) << -52(ffffffcc) = 12288(3000)\n  signed 8 3(3) << -51(ffffffcd) = 24576(6000)\n  signed 8 3(3) << -50(ffffffce) = 49152(c000)\n  signed 8 3(3) << -49(ffffffcf) = 98304(18000)\n  signed 8 3(3) << -48(ffffffd0) = 196608(30000)\n  signed 8 3(3) << -47(ffffffd1) = 393216(60000)\n  signed 8 3(3) << -46(ffffffd2) = 786432(c0000)\n  signed 8 3(3) << -45(ffffffd3) = 1572864(180000)\n  signed 8 3(3) << -44(ffffffd4) = 3145728(300000)\n  signed 8 3(3) << -43(ffffffd5) = 6291456(600000)\n  signed 8 3(3) << -42(ffffffd6) = 12582912(c00000)\n  signed 8 3(3) << -41(ffffffd7) = 25165824(1800000)\n  signed 8 3(3) << -40(ffffffd8) = 50331648(3000000)\n  signed 8 3(3) << -39(ffffffd9) = 100663296(6000000)\n  signed 8 3(3) << -38(ffffffda) = 201326592(c000000)\n  signed 8 3(3) << -37(ffffffdb) = 402653184(18000000)\n  signed 8 3(3) << -36(ffffffdc) = 805306368(30000000)\n  signed 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\n  signed 8 3(3) << -34(ffffffde) = -1073741824(c0000000)\n  signed 8 3(3) << -33(ffffffdf) = -2147483648(80000000)\n  signed 8 3(3) << -32(ffffffe0) = 0(0)\n  signed 8 3(3) << -31(ffffffe1) = 0(0)\n  signed 8 3(3) << -30(ffffffe2) = 0(0)\n  signed 8 3(3) << -29(ffffffe3) = 0(0)\n  signed 8 3(3) << -28(ffffffe4) = 0(0)\n  signed 8 3(3) << -27(ffffffe5) = 0(0)\n  signed 8 3(3) << -26(ffffffe6) = 0(0)\n  signed 8 3(3) << -25(ffffffe7) = 0(0)\n  signed 8 3(3) << -24(ffffffe8) = 0(0)\n  signed 8 3(3) << -23(ffffffe9) = 0(0)\n  signed 8 3(3) << -22(ffffffea) = 0(0)\n  signed 8 3(3) << -21(ffffffeb) = 0(0)\n  signed 8 3(3) << -20(ffffffec) = 0(0)\n  signed 8 3(3) << -19(ffffffed) = 0(0)\n  signed 8 3(3) << -18(ffffffee) = 0(0)\n  signed 8 3(3) << -17(ffffffef) = 0(0)\n  signed 8 3(3) << -16(fffffff0) = 0(0)\n  signed 8 3(3) << -15(fffffff1) = 0(0)\n  signed 8 3(3) << -14(fffffff2) = 0(0)\n  signed 8 3(3) << -13(fffffff3) = 0(0)\n  signed 8 3(3) << -12(fffffff4) = 0(0)\n  signed 8 3(3) << -11(fffffff5) = 0(0)\n  signed 8 3(3) << -10(fffffff6) = 0(0)\n  signed 8 3(3) << -9(fffffff7) = 0(0)\n  signed 8 3(3) << -8(fffffff8) = 0(0)\n  signed 8 3(3) << -7(fffffff9) = 0(0)\n  signed 8 3(3) << -6(fffffffa) = 0(0)\n  signed 8 3(3) << -5(fffffffb) = 0(0)\n  signed 8 3(3) << -4(fffffffc) = 0(0)\n  signed 8 3(3) << -3(fffffffd) = 0(0)\n  signed 8 3(3) << -2(fffffffe) = 0(0)\n  signed 8 3(3) << -1(ffffffff) = 0(0)\n  signed 8 3(3) << 0(0) = 3(3)\n  signed 8 3(3) << 1(1) = 6(6)\n  signed 8 3(3) << 2(2) = 12(c)\n  signed 8 3(3) << 3(3) = 24(18)\n  signed 8 3(3) << 4(4) = 48(30)\n  signed 8 3(3) << 5(5) = 96(60)\n  signed 8 3(3) << 6(6) = 192(c0)\n  signed 8 3(3) << 7(7) = 384(180)\n  signed 8 3(3) << 8(8) = 768(300)\n  signed 8 3(3) << 9(9) = 1536(600)\n  signed 8 3(3) << 10(a) = 3072(c00)\n  signed 8 3(3) << 11(b) = 6144(1800)\n  signed 8 3(3) << 12(c) = 12288(3000)\n  signed 8 3(3) << 13(d) = 24576(6000)\n  signed 8 3(3) << 14(e) = 49152(c000)\n  signed 8 3(3) << 15(f) = 98304(18000)\n  signed 8 3(3) << 16(10) = 196608(30000)\n  signed 8 3(3) << 17(11) = 393216(60000)\n  signed 8 3(3) << 18(12) = 786432(c0000)\n  signed 8 3(3) << 19(13) = 1572864(180000)\n  signed 8 3(3) << 20(14) = 3145728(300000)\n  signed 8 3(3) << 21(15) = 6291456(600000)\n  signed 8 3(3) << 22(16) = 12582912(c00000)\n  signed 8 3(3) << 23(17) = 25165824(1800000)\n  signed 8 3(3) << 24(18) = 50331648(3000000)\n  signed 8 3(3) << 25(19) = 100663296(6000000)\n  signed 8 3(3) << 26(1a) = 201326592(c000000)\n  signed 8 3(3) << 27(1b) = 402653184(18000000)\n  signed 8 3(3) << 28(1c) = 805306368(30000000)\n  signed 8 3(3) << 29(1d) = 1610612736(60000000)\n  signed 8 3(3) << 30(1e) = -1073741824(c0000000)\n  signed 8 3(3) << 31(1f) = -2147483648(80000000)\n  signed 8 3(3) << 32(20) = 0(0)\n  signed 8 3(3) << 33(21) = 0(0)\n  signed 8 3(3) << 34(22) = 0(0)\n  signed 8 3(3) << 35(23) = 0(0)\n  signed 8 3(3) << 36(24) = 0(0)\n  signed 8 3(3) << 37(25) = 0(0)\n  signed 8 3(3) << 38(26) = 0(0)\n  signed 8 3(3) << 39(27) = 0(0)\n  signed 8 3(3) << 40(28) = 0(0)\n  signed 8 3(3) << 41(29) = 0(0)\n  signed 8 3(3) << 42(2a) = 0(0)\n  signed 8 3(3) << 43(2b) = 0(0)\n  signed 8 3(3) << 44(2c) = 0(0)\n  signed 8 3(3) << 45(2d) = 0(0)\n  signed 8 3(3) << 46(2e) = 0(0)\n  signed 8 3(3) << 47(2f) = 0(0)\n  signed 8 3(3) << 48(30) = 0(0)\n  signed 8 3(3) << 49(31) = 0(0)\n  signed 8 3(3) << 50(32) = 0(0)\n  signed 8 3(3) << 51(33) = 0(0)\n  signed 8 3(3) << 52(34) = 0(0)\n  signed 8 3(3) << 53(35) = 0(0)\n  signed 8 3(3) << 54(36) = 0(0)\n  signed 8 3(3) << 55(37) = 0(0)\n  signed 8 3(3) << 56(38) = 0(0)\n  signed 8 3(3) << 57(39) = 0(0)\n  signed 8 3(3) << 58(3a) = 0(0)\n  signed 8 3(3) << 59(3b) = 0(0)\n  signed 8 3(3) << 60(3c) = 0(0)\n  signed 8 3(3) << 61(3d) = 0(0)\n  signed 8 3(3) << 62(3e) = 0(0)\n  signed 8 3(3) << 63(3f) = 0(0)\n  signed 8 3(3) << 64(40) = 3(3)\n  signed 8 3(3) << 65(41) = 6(6)\n  signed 8 3(3) << 66(42) = 12(c)\n  signed 8 3(3) << 67(43) = 24(18)\n  signed 8 3(3) << 68(44) = 48(30)\n  signed 8 3(3) << 69(45) = 96(60)\n  signed 8 3(3) << 70(46) = 192(c0)\n  signed 8 3(3) << 71(47) = 384(180)\n  signed 8 3(3) << 72(48) = 768(300)\n  signed 8 3(3) << 73(49) = 1536(600)\n  signed 8 3(3) << 74(4a) = 3072(c00)\n  signed 8 3(3) << 75(4b) = 6144(1800)\n  signed 8 3(3) << 76(4c) = 12288(3000)\n  signed 8 3(3) << 77(4d) = 24576(6000)\n  signed 8 3(3) << 78(4e) = 49152(c000)\n  signed 8 3(3) << 79(4f) = 98304(18000)\n  signed 8 3(3) << 80(50) = 196608(30000)\n  signed 8 3(3) << 81(51) = 393216(60000)\n  signed 8 3(3) << 82(52) = 786432(c0000)\n  signed 8 3(3) << 83(53) = 1572864(180000)\n  signed 8 3(3) << 84(54) = 3145728(300000)\n  signed 8 3(3) << 85(55) = 6291456(600000)\n  signed 8 3(3) << 86(56) = 12582912(c00000)\n  signed 8 3(3) << 87(57) = 25165824(1800000)\n  signed 8 3(3) << 88(58) = 50331648(3000000)\n  signed 8 3(3) << 89(59) = 100663296(6000000)\n  signed 8 3(3) << 90(5a) = 201326592(c000000)\n  signed 8 3(3) << 91(5b) = 402653184(18000000)\n  signed 8 3(3) << 92(5c) = 805306368(30000000)\n  signed 8 3(3) << 93(5d) = 1610612736(60000000)\n  signed 8 3(3) << 94(5e) = -1073741824(c0000000)\n  signed 8 3(3) << 95(5f) = -2147483648(80000000)\n  signed 8 3(3) << 96(60) = 0(0)\n  signed 8 3(3) << 97(61) = 0(0)\n  signed 8 3(3) << 98(62) = 0(0)\n  signed 8 3(3) << 99(63) = 0(0)\n  signed 8 3(3) << 100(64) = 0(0)\n  signed 8 3(3) << 101(65) = 0(0)\n  signed 8 3(3) << 102(66) = 0(0)\n  signed 8 3(3) << 103(67) = 0(0)\n  signed 8 3(3) << 104(68) = 0(0)\n  signed 8 3(3) << 105(69) = 0(0)\n  signed 8 3(3) << 106(6a) = 0(0)\n  signed 8 3(3) << 107(6b) = 0(0)\n  signed 8 3(3) << 108(6c) = 0(0)\n  signed 8 3(3) << 109(6d) = 0(0)\n  signed 8 3(3) << 110(6e) = 0(0)\n  signed 8 3(3) << 111(6f) = 0(0)\n  signed 8 3(3) << 112(70) = 0(0)\n  signed 8 3(3) << 113(71) = 0(0)\n  signed 8 3(3) << 114(72) = 0(0)\n  signed 8 3(3) << 115(73) = 0(0)\n  signed 8 3(3) << 116(74) = 0(0)\n  signed 8 3(3) << 117(75) = 0(0)\n  signed 8 3(3) << 118(76) = 0(0)\n  signed 8 3(3) << 119(77) = 0(0)\n  signed 8 3(3) << 120(78) = 0(0)\n  signed 8 3(3) << 121(79) = 0(0)\n  signed 8 3(3) << 122(7a) = 0(0)\n  signed 8 3(3) << 123(7b) = 0(0)\n  signed 8 3(3) << 124(7c) = 0(0)\n  signed 8 3(3) << 125(7d) = 0(0)\n  signed 8 3(3) << 126(7e) = 0(0)\n  signed 8 3(3) << 127(7f) = 0(0)\n  signed 8 4(4) << -128(ffffff80) = 4(4)\n  signed 8 4(4) << -127(ffffff81) = 8(8)\n  signed 8 4(4) << -126(ffffff82) = 16(10)\n  signed 8 4(4) << -125(ffffff83) = 32(20)\n  signed 8 4(4) << -124(ffffff84) = 64(40)\n  signed 8 4(4) << -123(ffffff85) = 128(80)\n  signed 8 4(4) << -122(ffffff86) = 256(100)\n  signed 8 4(4) << -121(ffffff87) = 512(200)\n  signed 8 4(4) << -120(ffffff88) = 1024(400)\n  signed 8 4(4) << -119(ffffff89) = 2048(800)\n  signed 8 4(4) << -118(ffffff8a) = 4096(1000)\n  signed 8 4(4) << -117(ffffff8b) = 8192(2000)\n  signed 8 4(4) << -116(ffffff8c) = 16384(4000)\n  signed 8 4(4) << -115(ffffff8d) = 32768(8000)\n  signed 8 4(4) << -114(ffffff8e) = 65536(10000)\n  signed 8 4(4) << -113(ffffff8f) = 131072(20000)\n  signed 8 4(4) << -112(ffffff90) = 262144(40000)\n  signed 8 4(4) << -111(ffffff91) = 524288(80000)\n  signed 8 4(4) << -110(ffffff92) = 1048576(100000)\n  signed 8 4(4) << -109(ffffff93) = 2097152(200000)\n  signed 8 4(4) << -108(ffffff94) = 4194304(400000)\n  signed 8 4(4) << -107(ffffff95) = 8388608(800000)\n  signed 8 4(4) << -106(ffffff96) = 16777216(1000000)\n  signed 8 4(4) << -105(ffffff97) = 33554432(2000000)\n  signed 8 4(4) << -104(ffffff98) = 67108864(4000000)\n  signed 8 4(4) << -103(ffffff99) = 134217728(8000000)\n  signed 8 4(4) << -102(ffffff9a) = 268435456(10000000)\n  signed 8 4(4) << -101(ffffff9b) = 536870912(20000000)\n  signed 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\n  signed 8 4(4) << -99(ffffff9d) = -2147483648(80000000)\n  signed 8 4(4) << -98(ffffff9e) = 0(0)\n  signed 8 4(4) << -97(ffffff9f) = 0(0)\n  signed 8 4(4) << -96(ffffffa0) = 0(0)\n  signed 8 4(4) << -95(ffffffa1) = 0(0)\n  signed 8 4(4) << -94(ffffffa2) = 0(0)\n  signed 8 4(4) << -93(ffffffa3) = 0(0)\n  signed 8 4(4) << -92(ffffffa4) = 0(0)\n  signed 8 4(4) << -91(ffffffa5) = 0(0)\n  signed 8 4(4) << -90(ffffffa6) = 0(0)\n  signed 8 4(4) << -89(ffffffa7) = 0(0)\n  signed 8 4(4) << -88(ffffffa8) = 0(0)\n  signed 8 4(4) << -87(ffffffa9) = 0(0)\n  signed 8 4(4) << -86(ffffffaa) = 0(0)\n  signed 8 4(4) << -85(ffffffab) = 0(0)\n  signed 8 4(4) << -84(ffffffac) = 0(0)\n  signed 8 4(4) << -83(ffffffad) = 0(0)\n  signed 8 4(4) << -82(ffffffae) = 0(0)\n  signed 8 4(4) << -81(ffffffaf) = 0(0)\n  signed 8 4(4) << -80(ffffffb0) = 0(0)\n  signed 8 4(4) << -79(ffffffb1) = 0(0)\n  signed 8 4(4) << -78(ffffffb2) = 0(0)\n  signed 8 4(4) << -77(ffffffb3) = 0(0)\n  signed 8 4(4) << -76(ffffffb4) = 0(0)\n  signed 8 4(4) << -75(ffffffb5) = 0(0)\n  signed 8 4(4) << -74(ffffffb6) = 0(0)\n  signed 8 4(4) << -73(ffffffb7) = 0(0)\n  signed 8 4(4) << -72(ffffffb8) = 0(0)\n  signed 8 4(4) << -71(ffffffb9) = 0(0)\n  signed 8 4(4) << -70(ffffffba) = 0(0)\n  signed 8 4(4) << -69(ffffffbb) = 0(0)\n  signed 8 4(4) << -68(ffffffbc) = 0(0)\n  signed 8 4(4) << -67(ffffffbd) = 0(0)\n  signed 8 4(4) << -66(ffffffbe) = 0(0)\n  signed 8 4(4) << -65(ffffffbf) = 0(0)\n  signed 8 4(4) << -64(ffffffc0) = 4(4)\n  signed 8 4(4) << -63(ffffffc1) = 8(8)\n  signed 8 4(4) << -62(ffffffc2) = 16(10)\n  signed 8 4(4) << -61(ffffffc3) = 32(20)\n  signed 8 4(4) << -60(ffffffc4) = 64(40)\n  signed 8 4(4) << -59(ffffffc5) = 128(80)\n  signed 8 4(4) << -58(ffffffc6) = 256(100)\n  signed 8 4(4) << -57(ffffffc7) = 512(200)\n  signed 8 4(4) << -56(ffffffc8) = 1024(400)\n  signed 8 4(4) << -55(ffffffc9) = 2048(800)\n  signed 8 4(4) << -54(ffffffca) = 4096(1000)\n  signed 8 4(4) << -53(ffffffcb) = 8192(2000)\n  signed 8 4(4) << -52(ffffffcc) = 16384(4000)\n  signed 8 4(4) << -51(ffffffcd) = 32768(8000)\n  signed 8 4(4) << -50(ffffffce) = 65536(10000)\n  signed 8 4(4) << -49(ffffffcf) = 131072(20000)\n  signed 8 4(4) << -48(ffffffd0) = 262144(40000)\n  signed 8 4(4) << -47(ffffffd1) = 524288(80000)\n  signed 8 4(4) << -46(ffffffd2) = 1048576(100000)\n  signed 8 4(4) << -45(ffffffd3) = 2097152(200000)\n  signed 8 4(4) << -44(ffffffd4) = 4194304(400000)\n  signed 8 4(4) << -43(ffffffd5) = 8388608(800000)\n  signed 8 4(4) << -42(ffffffd6) = 16777216(1000000)\n  signed 8 4(4) << -41(ffffffd7) = 33554432(2000000)\n  signed 8 4(4) << -40(ffffffd8) = 67108864(4000000)\n  signed 8 4(4) << -39(ffffffd9) = 134217728(8000000)\n  signed 8 4(4) << -38(ffffffda) = 268435456(10000000)\n  signed 8 4(4) << -37(ffffffdb) = 536870912(20000000)\n  signed 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\n  signed 8 4(4) << -35(ffffffdd) = -2147483648(80000000)\n  signed 8 4(4) << -34(ffffffde) = 0(0)\n  signed 8 4(4) << -33(ffffffdf) = 0(0)\n  signed 8 4(4) << -32(ffffffe0) = 0(0)\n  signed 8 4(4) << -31(ffffffe1) = 0(0)\n  signed 8 4(4) << -30(ffffffe2) = 0(0)\n  signed 8 4(4) << -29(ffffffe3) = 0(0)\n  signed 8 4(4) << -28(ffffffe4) = 0(0)\n  signed 8 4(4) << -27(ffffffe5) = 0(0)\n  signed 8 4(4) << -26(ffffffe6) = 0(0)\n  signed 8 4(4) << -25(ffffffe7) = 0(0)\n  signed 8 4(4) << -24(ffffffe8) = 0(0)\n  signed 8 4(4) << -23(ffffffe9) = 0(0)\n  signed 8 4(4) << -22(ffffffea) = 0(0)\n  signed 8 4(4) << -21(ffffffeb) = 0(0)\n  signed 8 4(4) << -20(ffffffec) = 0(0)\n  signed 8 4(4) << -19(ffffffed) = 0(0)\n  signed 8 4(4) << -18(ffffffee) = 0(0)\n  signed 8 4(4) << -17(ffffffef) = 0(0)\n  signed 8 4(4) << -16(fffffff0) = 0(0)\n  signed 8 4(4) << -15(fffffff1) = 0(0)\n  signed 8 4(4) << -14(fffffff2) = 0(0)\n  signed 8 4(4) << -13(fffffff3) = 0(0)\n  signed 8 4(4) << -12(fffffff4) = 0(0)\n  signed 8 4(4) << -11(fffffff5) = 0(0)\n  signed 8 4(4) << -10(fffffff6) = 0(0)\n  signed 8 4(4) << -9(fffffff7) = 0(0)\n  signed 8 4(4) << -8(fffffff8) = 0(0)\n  signed 8 4(4) << -7(fffffff9) = 0(0)\n  signed 8 4(4) << -6(fffffffa) = 0(0)\n  signed 8 4(4) << -5(fffffffb) = 0(0)\n  signed 8 4(4) << -4(fffffffc) = 0(0)\n  signed 8 4(4) << -3(fffffffd) = 0(0)\n  signed 8 4(4) << -2(fffffffe) = 0(0)\n  signed 8 4(4) << -1(ffffffff) = 0(0)\n  signed 8 4(4) << 0(0) = 4(4)\n  signed 8 4(4) << 1(1) = 8(8)\n  signed 8 4(4) << 2(2) = 16(10)\n  signed 8 4(4) << 3(3) = 32(20)\n  signed 8 4(4) << 4(4) = 64(40)\n  signed 8 4(4) << 5(5) = 128(80)\n  signed 8 4(4) << 6(6) = 256(100)\n  signed 8 4(4) << 7(7) = 512(200)\n  signed 8 4(4) << 8(8) = 1024(400)\n  signed 8 4(4) << 9(9) = 2048(800)\n  signed 8 4(4) << 10(a) = 4096(1000)\n  signed 8 4(4) << 11(b) = 8192(2000)\n  signed 8 4(4) << 12(c) = 16384(4000)\n  signed 8 4(4) << 13(d) = 32768(8000)\n  signed 8 4(4) << 14(e) = 65536(10000)\n  signed 8 4(4) << 15(f) = 131072(20000)\n  signed 8 4(4) << 16(10) = 262144(40000)\n  signed 8 4(4) << 17(11) = 524288(80000)\n  signed 8 4(4) << 18(12) = 1048576(100000)\n  signed 8 4(4) << 19(13) = 2097152(200000)\n  signed 8 4(4) << 20(14) = 4194304(400000)\n  signed 8 4(4) << 21(15) = 8388608(800000)\n  signed 8 4(4) << 22(16) = 16777216(1000000)\n  signed 8 4(4) << 23(17) = 33554432(2000000)\n  signed 8 4(4) << 24(18) = 67108864(4000000)\n  signed 8 4(4) << 25(19) = 134217728(8000000)\n  signed 8 4(4) << 26(1a) = 268435456(10000000)\n  signed 8 4(4) << 27(1b) = 536870912(20000000)\n  signed 8 4(4) << 28(1c) = 1073741824(40000000)\n  signed 8 4(4) << 29(1d) = -2147483648(80000000)\n  signed 8 4(4) << 30(1e) = 0(0)\n  signed 8 4(4) << 31(1f) = 0(0)\n  signed 8 4(4) << 32(20) = 0(0)\n  signed 8 4(4) << 33(21) = 0(0)\n  signed 8 4(4) << 34(22) = 0(0)\n  signed 8 4(4) << 35(23) = 0(0)\n  signed 8 4(4) << 36(24) = 0(0)\n  signed 8 4(4) << 37(25) = 0(0)\n  signed 8 4(4) << 38(26) = 0(0)\n  signed 8 4(4) << 39(27) = 0(0)\n  signed 8 4(4) << 40(28) = 0(0)\n  signed 8 4(4) << 41(29) = 0(0)\n  signed 8 4(4) << 42(2a) = 0(0)\n  signed 8 4(4) << 43(2b) = 0(0)\n  signed 8 4(4) << 44(2c) = 0(0)\n  signed 8 4(4) << 45(2d) = 0(0)\n  signed 8 4(4) << 46(2e) = 0(0)\n  signed 8 4(4) << 47(2f) = 0(0)\n  signed 8 4(4) << 48(30) = 0(0)\n  signed 8 4(4) << 49(31) = 0(0)\n  signed 8 4(4) << 50(32) = 0(0)\n  signed 8 4(4) << 51(33) = 0(0)\n  signed 8 4(4) << 52(34) = 0(0)\n  signed 8 4(4) << 53(35) = 0(0)\n  signed 8 4(4) << 54(36) = 0(0)\n  signed 8 4(4) << 55(37) = 0(0)\n  signed 8 4(4) << 56(38) = 0(0)\n  signed 8 4(4) << 57(39) = 0(0)\n  signed 8 4(4) << 58(3a) = 0(0)\n  signed 8 4(4) << 59(3b) = 0(0)\n  signed 8 4(4) << 60(3c) = 0(0)\n  signed 8 4(4) << 61(3d) = 0(0)\n  signed 8 4(4) << 62(3e) = 0(0)\n  signed 8 4(4) << 63(3f) = 0(0)\n  signed 8 4(4) << 64(40) = 4(4)\n  signed 8 4(4) << 65(41) = 8(8)\n  signed 8 4(4) << 66(42) = 16(10)\n  signed 8 4(4) << 67(43) = 32(20)\n  signed 8 4(4) << 68(44) = 64(40)\n  signed 8 4(4) << 69(45) = 128(80)\n  signed 8 4(4) << 70(46) = 256(100)\n  signed 8 4(4) << 71(47) = 512(200)\n  signed 8 4(4) << 72(48) = 1024(400)\n  signed 8 4(4) << 73(49) = 2048(800)\n  signed 8 4(4) << 74(4a) = 4096(1000)\n  signed 8 4(4) << 75(4b) = 8192(2000)\n  signed 8 4(4) << 76(4c) = 16384(4000)\n  signed 8 4(4) << 77(4d) = 32768(8000)\n  signed 8 4(4) << 78(4e) = 65536(10000)\n  signed 8 4(4) << 79(4f) = 131072(20000)\n  signed 8 4(4) << 80(50) = 262144(40000)\n  signed 8 4(4) << 81(51) = 524288(80000)\n  signed 8 4(4) << 82(52) = 1048576(100000)\n  signed 8 4(4) << 83(53) = 2097152(200000)\n  signed 8 4(4) << 84(54) = 4194304(400000)\n  signed 8 4(4) << 85(55) = 8388608(800000)\n  signed 8 4(4) << 86(56) = 16777216(1000000)\n  signed 8 4(4) << 87(57) = 33554432(2000000)\n  signed 8 4(4) << 88(58) = 67108864(4000000)\n  signed 8 4(4) << 89(59) = 134217728(8000000)\n  signed 8 4(4) << 90(5a) = 268435456(10000000)\n  signed 8 4(4) << 91(5b) = 536870912(20000000)\n  signed 8 4(4) << 92(5c) = 1073741824(40000000)\n  signed 8 4(4) << 93(5d) = -2147483648(80000000)\n  signed 8 4(4) << 94(5e) = 0(0)\n  signed 8 4(4) << 95(5f) = 0(0)\n  signed 8 4(4) << 96(60) = 0(0)\n  signed 8 4(4) << 97(61) = 0(0)\n  signed 8 4(4) << 98(62) = 0(0)\n  signed 8 4(4) << 99(63) = 0(0)\n  signed 8 4(4) << 100(64) = 0(0)\n  signed 8 4(4) << 101(65) = 0(0)\n  signed 8 4(4) << 102(66) = 0(0)\n  signed 8 4(4) << 103(67) = 0(0)\n  signed 8 4(4) << 104(68) = 0(0)\n  signed 8 4(4) << 105(69) = 0(0)\n  signed 8 4(4) << 106(6a) = 0(0)\n  signed 8 4(4) << 107(6b) = 0(0)\n  signed 8 4(4) << 108(6c) = 0(0)\n  signed 8 4(4) << 109(6d) = 0(0)\n  signed 8 4(4) << 110(6e) = 0(0)\n  signed 8 4(4) << 111(6f) = 0(0)\n  signed 8 4(4) << 112(70) = 0(0)\n  signed 8 4(4) << 113(71) = 0(0)\n  signed 8 4(4) << 114(72) = 0(0)\n  signed 8 4(4) << 115(73) = 0(0)\n  signed 8 4(4) << 116(74) = 0(0)\n  signed 8 4(4) << 117(75) = 0(0)\n  signed 8 4(4) << 118(76) = 0(0)\n  signed 8 4(4) << 119(77) = 0(0)\n  signed 8 4(4) << 120(78) = 0(0)\n  signed 8 4(4) << 121(79) = 0(0)\n  signed 8 4(4) << 122(7a) = 0(0)\n  signed 8 4(4) << 123(7b) = 0(0)\n  signed 8 4(4) << 124(7c) = 0(0)\n  signed 8 4(4) << 125(7d) = 0(0)\n  signed 8 4(4) << 126(7e) = 0(0)\n  signed 8 4(4) << 127(7f) = 0(0)\nunsigned 8 0(0) << -128(ffffff80) = 0(0)\nunsigned 8 0(0) << -127(ffffff81) = 0(0)\nunsigned 8 0(0) << -126(ffffff82) = 0(0)\nunsigned 8 0(0) << -125(ffffff83) = 0(0)\nunsigned 8 0(0) << -124(ffffff84) = 0(0)\nunsigned 8 0(0) << -123(ffffff85) = 0(0)\nunsigned 8 0(0) << -122(ffffff86) = 0(0)\nunsigned 8 0(0) << -121(ffffff87) = 0(0)\nunsigned 8 0(0) << -120(ffffff88) = 0(0)\nunsigned 8 0(0) << -119(ffffff89) = 0(0)\nunsigned 8 0(0) << -118(ffffff8a) = 0(0)\nunsigned 8 0(0) << -117(ffffff8b) = 0(0)\nunsigned 8 0(0) << -116(ffffff8c) = 0(0)\nunsigned 8 0(0) << -115(ffffff8d) = 0(0)\nunsigned 8 0(0) << -114(ffffff8e) = 0(0)\nunsigned 8 0(0) << -113(ffffff8f) = 0(0)\nunsigned 8 0(0) << -112(ffffff90) = 0(0)\nunsigned 8 0(0) << -111(ffffff91) = 0(0)\nunsigned 8 0(0) << -110(ffffff92) = 0(0)\nunsigned 8 0(0) << -109(ffffff93) = 0(0)\nunsigned 8 0(0) << -108(ffffff94) = 0(0)\nunsigned 8 0(0) << -107(ffffff95) = 0(0)\nunsigned 8 0(0) << -106(ffffff96) = 0(0)\nunsigned 8 0(0) << -105(ffffff97) = 0(0)\nunsigned 8 0(0) << -104(ffffff98) = 0(0)\nunsigned 8 0(0) << -103(ffffff99) = 0(0)\nunsigned 8 0(0) << -102(ffffff9a) = 0(0)\nunsigned 8 0(0) << -101(ffffff9b) = 0(0)\nunsigned 8 0(0) << -100(ffffff9c) = 0(0)\nunsigned 8 0(0) << -99(ffffff9d) = 0(0)\nunsigned 8 0(0) << -98(ffffff9e) = 0(0)\nunsigned 8 0(0) << -97(ffffff9f) = 0(0)\nunsigned 8 0(0) << -96(ffffffa0) = 0(0)\nunsigned 8 0(0) << -95(ffffffa1) = 0(0)\nunsigned 8 0(0) << -94(ffffffa2) = 0(0)\nunsigned 8 0(0) << -93(ffffffa3) = 0(0)\nunsigned 8 0(0) << -92(ffffffa4) = 0(0)\nunsigned 8 0(0) << -91(ffffffa5) = 0(0)\nunsigned 8 0(0) << -90(ffffffa6) = 0(0)\nunsigned 8 0(0) << -89(ffffffa7) = 0(0)\nunsigned 8 0(0) << -88(ffffffa8) = 0(0)\nunsigned 8 0(0) << -87(ffffffa9) = 0(0)\nunsigned 8 0(0) << -86(ffffffaa) = 0(0)\nunsigned 8 0(0) << -85(ffffffab) = 0(0)\nunsigned 8 0(0) << -84(ffffffac) = 0(0)\nunsigned 8 0(0) << -83(ffffffad) = 0(0)\nunsigned 8 0(0) << -82(ffffffae) = 0(0)\nunsigned 8 0(0) << -81(ffffffaf) = 0(0)\nunsigned 8 0(0) << -80(ffffffb0) = 0(0)\nunsigned 8 0(0) << -79(ffffffb1) = 0(0)\nunsigned 8 0(0) << -78(ffffffb2) = 0(0)\nunsigned 8 0(0) << -77(ffffffb3) = 0(0)\nunsigned 8 0(0) << -76(ffffffb4) = 0(0)\nunsigned 8 0(0) << -75(ffffffb5) = 0(0)\nunsigned 8 0(0) << -74(ffffffb6) = 0(0)\nunsigned 8 0(0) << -73(ffffffb7) = 0(0)\nunsigned 8 0(0) << -72(ffffffb8) = 0(0)\nunsigned 8 0(0) << -71(ffffffb9) = 0(0)\nunsigned 8 0(0) << -70(ffffffba) = 0(0)\nunsigned 8 0(0) << -69(ffffffbb) = 0(0)\nunsigned 8 0(0) << -68(ffffffbc) = 0(0)\nunsigned 8 0(0) << -67(ffffffbd) = 0(0)\nunsigned 8 0(0) << -66(ffffffbe) = 0(0)\nunsigned 8 0(0) << -65(ffffffbf) = 0(0)\nunsigned 8 0(0) << -64(ffffffc0) = 0(0)\nunsigned 8 0(0) << -63(ffffffc1) = 0(0)\nunsigned 8 0(0) << -62(ffffffc2) = 0(0)\nunsigned 8 0(0) << -61(ffffffc3) = 0(0)\nunsigned 8 0(0) << -60(ffffffc4) = 0(0)\nunsigned 8 0(0) << -59(ffffffc5) = 0(0)\nunsigned 8 0(0) << -58(ffffffc6) = 0(0)\nunsigned 8 0(0) << -57(ffffffc7) = 0(0)\nunsigned 8 0(0) << -56(ffffffc8) = 0(0)\nunsigned 8 0(0) << -55(ffffffc9) = 0(0)\nunsigned 8 0(0) << -54(ffffffca) = 0(0)\nunsigned 8 0(0) << -53(ffffffcb) = 0(0)\nunsigned 8 0(0) << -52(ffffffcc) = 0(0)\nunsigned 8 0(0) << -51(ffffffcd) = 0(0)\nunsigned 8 0(0) << -50(ffffffce) = 0(0)\nunsigned 8 0(0) << -49(ffffffcf) = 0(0)\nunsigned 8 0(0) << -48(ffffffd0) = 0(0)\nunsigned 8 0(0) << -47(ffffffd1) = 0(0)\nunsigned 8 0(0) << -46(ffffffd2) = 0(0)\nunsigned 8 0(0) << -45(ffffffd3) = 0(0)\nunsigned 8 0(0) << -44(ffffffd4) = 0(0)\nunsigned 8 0(0) << -43(ffffffd5) = 0(0)\nunsigned 8 0(0) << -42(ffffffd6) = 0(0)\nunsigned 8 0(0) << -41(ffffffd7) = 0(0)\nunsigned 8 0(0) << -40(ffffffd8) = 0(0)\nunsigned 8 0(0) << -39(ffffffd9) = 0(0)\nunsigned 8 0(0) << -38(ffffffda) = 0(0)\nunsigned 8 0(0) << -37(ffffffdb) = 0(0)\nunsigned 8 0(0) << -36(ffffffdc) = 0(0)\nunsigned 8 0(0) << -35(ffffffdd) = 0(0)\nunsigned 8 0(0) << -34(ffffffde) = 0(0)\nunsigned 8 0(0) << -33(ffffffdf) = 0(0)\nunsigned 8 0(0) << -32(ffffffe0) = 0(0)\nunsigned 8 0(0) << -31(ffffffe1) = 0(0)\nunsigned 8 0(0) << -30(ffffffe2) = 0(0)\nunsigned 8 0(0) << -29(ffffffe3) = 0(0)\nunsigned 8 0(0) << -28(ffffffe4) = 0(0)\nunsigned 8 0(0) << -27(ffffffe5) = 0(0)\nunsigned 8 0(0) << -26(ffffffe6) = 0(0)\nunsigned 8 0(0) << -25(ffffffe7) = 0(0)\nunsigned 8 0(0) << -24(ffffffe8) = 0(0)\nunsigned 8 0(0) << -23(ffffffe9) = 0(0)\nunsigned 8 0(0) << -22(ffffffea) = 0(0)\nunsigned 8 0(0) << -21(ffffffeb) = 0(0)\nunsigned 8 0(0) << -20(ffffffec) = 0(0)\nunsigned 8 0(0) << -19(ffffffed) = 0(0)\nunsigned 8 0(0) << -18(ffffffee) = 0(0)\nunsigned 8 0(0) << -17(ffffffef) = 0(0)\nunsigned 8 0(0) << -16(fffffff0) = 0(0)\nunsigned 8 0(0) << -15(fffffff1) = 0(0)\nunsigned 8 0(0) << -14(fffffff2) = 0(0)\nunsigned 8 0(0) << -13(fffffff3) = 0(0)\nunsigned 8 0(0) << -12(fffffff4) = 0(0)\nunsigned 8 0(0) << -11(fffffff5) = 0(0)\nunsigned 8 0(0) << -10(fffffff6) = 0(0)\nunsigned 8 0(0) << -9(fffffff7) = 0(0)\nunsigned 8 0(0) << -8(fffffff8) = 0(0)\nunsigned 8 0(0) << -7(fffffff9) = 0(0)\nunsigned 8 0(0) << -6(fffffffa) = 0(0)\nunsigned 8 0(0) << -5(fffffffb) = 0(0)\nunsigned 8 0(0) << -4(fffffffc) = 0(0)\nunsigned 8 0(0) << -3(fffffffd) = 0(0)\nunsigned 8 0(0) << -2(fffffffe) = 0(0)\nunsigned 8 0(0) << -1(ffffffff) = 0(0)\nunsigned 8 0(0) << 0(0) = 0(0)\nunsigned 8 0(0) << 1(1) = 0(0)\nunsigned 8 0(0) << 2(2) = 0(0)\nunsigned 8 0(0) << 3(3) = 0(0)\nunsigned 8 0(0) << 4(4) = 0(0)\nunsigned 8 0(0) << 5(5) = 0(0)\nunsigned 8 0(0) << 6(6) = 0(0)\nunsigned 8 0(0) << 7(7) = 0(0)\nunsigned 8 0(0) << 8(8) = 0(0)\nunsigned 8 0(0) << 9(9) = 0(0)\nunsigned 8 0(0) << 10(a) = 0(0)\nunsigned 8 0(0) << 11(b) = 0(0)\nunsigned 8 0(0) << 12(c) = 0(0)\nunsigned 8 0(0) << 13(d) = 0(0)\nunsigned 8 0(0) << 14(e) = 0(0)\nunsigned 8 0(0) << 15(f) = 0(0)\nunsigned 8 0(0) << 16(10) = 0(0)\nunsigned 8 0(0) << 17(11) = 0(0)\nunsigned 8 0(0) << 18(12) = 0(0)\nunsigned 8 0(0) << 19(13) = 0(0)\nunsigned 8 0(0) << 20(14) = 0(0)\nunsigned 8 0(0) << 21(15) = 0(0)\nunsigned 8 0(0) << 22(16) = 0(0)\nunsigned 8 0(0) << 23(17) = 0(0)\nunsigned 8 0(0) << 24(18) = 0(0)\nunsigned 8 0(0) << 25(19) = 0(0)\nunsigned 8 0(0) << 26(1a) = 0(0)\nunsigned 8 0(0) << 27(1b) = 0(0)\nunsigned 8 0(0) << 28(1c) = 0(0)\nunsigned 8 0(0) << 29(1d) = 0(0)\nunsigned 8 0(0) << 30(1e) = 0(0)\nunsigned 8 0(0) << 31(1f) = 0(0)\nunsigned 8 0(0) << 32(20) = 0(0)\nunsigned 8 0(0) << 33(21) = 0(0)\nunsigned 8 0(0) << 34(22) = 0(0)\nunsigned 8 0(0) << 35(23) = 0(0)\nunsigned 8 0(0) << 36(24) = 0(0)\nunsigned 8 0(0) << 37(25) = 0(0)\nunsigned 8 0(0) << 38(26) = 0(0)\nunsigned 8 0(0) << 39(27) = 0(0)\nunsigned 8 0(0) << 40(28) = 0(0)\nunsigned 8 0(0) << 41(29) = 0(0)\nunsigned 8 0(0) << 42(2a) = 0(0)\nunsigned 8 0(0) << 43(2b) = 0(0)\nunsigned 8 0(0) << 44(2c) = 0(0)\nunsigned 8 0(0) << 45(2d) = 0(0)\nunsigned 8 0(0) << 46(2e) = 0(0)\nunsigned 8 0(0) << 47(2f) = 0(0)\nunsigned 8 0(0) << 48(30) = 0(0)\nunsigned 8 0(0) << 49(31) = 0(0)\nunsigned 8 0(0) << 50(32) = 0(0)\nunsigned 8 0(0) << 51(33) = 0(0)\nunsigned 8 0(0) << 52(34) = 0(0)\nunsigned 8 0(0) << 53(35) = 0(0)\nunsigned 8 0(0) << 54(36) = 0(0)\nunsigned 8 0(0) << 55(37) = 0(0)\nunsigned 8 0(0) << 56(38) = 0(0)\nunsigned 8 0(0) << 57(39) = 0(0)\nunsigned 8 0(0) << 58(3a) = 0(0)\nunsigned 8 0(0) << 59(3b) = 0(0)\nunsigned 8 0(0) << 60(3c) = 0(0)\nunsigned 8 0(0) << 61(3d) = 0(0)\nunsigned 8 0(0) << 62(3e) = 0(0)\nunsigned 8 0(0) << 63(3f) = 0(0)\nunsigned 8 0(0) << 64(40) = 0(0)\nunsigned 8 0(0) << 65(41) = 0(0)\nunsigned 8 0(0) << 66(42) = 0(0)\nunsigned 8 0(0) << 67(43) = 0(0)\nunsigned 8 0(0) << 68(44) = 0(0)\nunsigned 8 0(0) << 69(45) = 0(0)\nunsigned 8 0(0) << 70(46) = 0(0)\nunsigned 8 0(0) << 71(47) = 0(0)\nunsigned 8 0(0) << 72(48) = 0(0)\nunsigned 8 0(0) << 73(49) = 0(0)\nunsigned 8 0(0) << 74(4a) = 0(0)\nunsigned 8 0(0) << 75(4b) = 0(0)\nunsigned 8 0(0) << 76(4c) = 0(0)\nunsigned 8 0(0) << 77(4d) = 0(0)\nunsigned 8 0(0) << 78(4e) = 0(0)\nunsigned 8 0(0) << 79(4f) = 0(0)\nunsigned 8 0(0) << 80(50) = 0(0)\nunsigned 8 0(0) << 81(51) = 0(0)\nunsigned 8 0(0) << 82(52) = 0(0)\nunsigned 8 0(0) << 83(53) = 0(0)\nunsigned 8 0(0) << 84(54) = 0(0)\nunsigned 8 0(0) << 85(55) = 0(0)\nunsigned 8 0(0) << 86(56) = 0(0)\nunsigned 8 0(0) << 87(57) = 0(0)\nunsigned 8 0(0) << 88(58) = 0(0)\nunsigned 8 0(0) << 89(59) = 0(0)\nunsigned 8 0(0) << 90(5a) = 0(0)\nunsigned 8 0(0) << 91(5b) = 0(0)\nunsigned 8 0(0) << 92(5c) = 0(0)\nunsigned 8 0(0) << 93(5d) = 0(0)\nunsigned 8 0(0) << 94(5e) = 0(0)\nunsigned 8 0(0) << 95(5f) = 0(0)\nunsigned 8 0(0) << 96(60) = 0(0)\nunsigned 8 0(0) << 97(61) = 0(0)\nunsigned 8 0(0) << 98(62) = 0(0)\nunsigned 8 0(0) << 99(63) = 0(0)\nunsigned 8 0(0) << 100(64) = 0(0)\nunsigned 8 0(0) << 101(65) = 0(0)\nunsigned 8 0(0) << 102(66) = 0(0)\nunsigned 8 0(0) << 103(67) = 0(0)\nunsigned 8 0(0) << 104(68) = 0(0)\nunsigned 8 0(0) << 105(69) = 0(0)\nunsigned 8 0(0) << 106(6a) = 0(0)\nunsigned 8 0(0) << 107(6b) = 0(0)\nunsigned 8 0(0) << 108(6c) = 0(0)\nunsigned 8 0(0) << 109(6d) = 0(0)\nunsigned 8 0(0) << 110(6e) = 0(0)\nunsigned 8 0(0) << 111(6f) = 0(0)\nunsigned 8 0(0) << 112(70) = 0(0)\nunsigned 8 0(0) << 113(71) = 0(0)\nunsigned 8 0(0) << 114(72) = 0(0)\nunsigned 8 0(0) << 115(73) = 0(0)\nunsigned 8 0(0) << 116(74) = 0(0)\nunsigned 8 0(0) << 117(75) = 0(0)\nunsigned 8 0(0) << 118(76) = 0(0)\nunsigned 8 0(0) << 119(77) = 0(0)\nunsigned 8 0(0) << 120(78) = 0(0)\nunsigned 8 0(0) << 121(79) = 0(0)\nunsigned 8 0(0) << 122(7a) = 0(0)\nunsigned 8 0(0) << 123(7b) = 0(0)\nunsigned 8 0(0) << 124(7c) = 0(0)\nunsigned 8 0(0) << 125(7d) = 0(0)\nunsigned 8 0(0) << 126(7e) = 0(0)\nunsigned 8 0(0) << 127(7f) = 0(0)\nunsigned 8 1(1) << -128(ffffff80) = 1(1)\nunsigned 8 1(1) << -127(ffffff81) = 2(2)\nunsigned 8 1(1) << -126(ffffff82) = 4(4)\nunsigned 8 1(1) << -125(ffffff83) = 8(8)\nunsigned 8 1(1) << -124(ffffff84) = 16(10)\nunsigned 8 1(1) << -123(ffffff85) = 32(20)\nunsigned 8 1(1) << -122(ffffff86) = 64(40)\nunsigned 8 1(1) << -121(ffffff87) = 128(80)\nunsigned 8 1(1) << -120(ffffff88) = 256(100)\nunsigned 8 1(1) << -119(ffffff89) = 512(200)\nunsigned 8 1(1) << -118(ffffff8a) = 1024(400)\nunsigned 8 1(1) << -117(ffffff8b) = 2048(800)\nunsigned 8 1(1) << -116(ffffff8c) = 4096(1000)\nunsigned 8 1(1) << -115(ffffff8d) = 8192(2000)\nunsigned 8 1(1) << -114(ffffff8e) = 16384(4000)\nunsigned 8 1(1) << -113(ffffff8f) = 32768(8000)\nunsigned 8 1(1) << -112(ffffff90) = 65536(10000)\nunsigned 8 1(1) << -111(ffffff91) = 131072(20000)\nunsigned 8 1(1) << -110(ffffff92) = 262144(40000)\nunsigned 8 1(1) << -109(ffffff93) = 524288(80000)\nunsigned 8 1(1) << -108(ffffff94) = 1048576(100000)\nunsigned 8 1(1) << -107(ffffff95) = 2097152(200000)\nunsigned 8 1(1) << -106(ffffff96) = 4194304(400000)\nunsigned 8 1(1) << -105(ffffff97) = 8388608(800000)\nunsigned 8 1(1) << -104(ffffff98) = 16777216(1000000)\nunsigned 8 1(1) << -103(ffffff99) = 33554432(2000000)\nunsigned 8 1(1) << -102(ffffff9a) = 67108864(4000000)\nunsigned 8 1(1) << -101(ffffff9b) = 134217728(8000000)\nunsigned 8 1(1) << -100(ffffff9c) = 268435456(10000000)\nunsigned 8 1(1) << -99(ffffff9d) = 536870912(20000000)\nunsigned 8 1(1) << -98(ffffff9e) = 1073741824(40000000)\nunsigned 8 1(1) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 1(1) << -96(ffffffa0) = 0(0)\nunsigned 8 1(1) << -95(ffffffa1) = 0(0)\nunsigned 8 1(1) << -94(ffffffa2) = 0(0)\nunsigned 8 1(1) << -93(ffffffa3) = 0(0)\nunsigned 8 1(1) << -92(ffffffa4) = 0(0)\nunsigned 8 1(1) << -91(ffffffa5) = 0(0)\nunsigned 8 1(1) << -90(ffffffa6) = 0(0)\nunsigned 8 1(1) << -89(ffffffa7) = 0(0)\nunsigned 8 1(1) << -88(ffffffa8) = 0(0)\nunsigned 8 1(1) << -87(ffffffa9) = 0(0)\nunsigned 8 1(1) << -86(ffffffaa) = 0(0)\nunsigned 8 1(1) << -85(ffffffab) = 0(0)\nunsigned 8 1(1) << -84(ffffffac) = 0(0)\nunsigned 8 1(1) << -83(ffffffad) = 0(0)\nunsigned 8 1(1) << -82(ffffffae) = 0(0)\nunsigned 8 1(1) << -81(ffffffaf) = 0(0)\nunsigned 8 1(1) << -80(ffffffb0) = 0(0)\nunsigned 8 1(1) << -79(ffffffb1) = 0(0)\nunsigned 8 1(1) << -78(ffffffb2) = 0(0)\nunsigned 8 1(1) << -77(ffffffb3) = 0(0)\nunsigned 8 1(1) << -76(ffffffb4) = 0(0)\nunsigned 8 1(1) << -75(ffffffb5) = 0(0)\nunsigned 8 1(1) << -74(ffffffb6) = 0(0)\nunsigned 8 1(1) << -73(ffffffb7) = 0(0)\nunsigned 8 1(1) << -72(ffffffb8) = 0(0)\nunsigned 8 1(1) << -71(ffffffb9) = 0(0)\nunsigned 8 1(1) << -70(ffffffba) = 0(0)\nunsigned 8 1(1) << -69(ffffffbb) = 0(0)\nunsigned 8 1(1) << -68(ffffffbc) = 0(0)\nunsigned 8 1(1) << -67(ffffffbd) = 0(0)\nunsigned 8 1(1) << -66(ffffffbe) = 0(0)\nunsigned 8 1(1) << -65(ffffffbf) = 0(0)\nunsigned 8 1(1) << -64(ffffffc0) = 1(1)\nunsigned 8 1(1) << -63(ffffffc1) = 2(2)\nunsigned 8 1(1) << -62(ffffffc2) = 4(4)\nunsigned 8 1(1) << -61(ffffffc3) = 8(8)\nunsigned 8 1(1) << -60(ffffffc4) = 16(10)\nunsigned 8 1(1) << -59(ffffffc5) = 32(20)\nunsigned 8 1(1) << -58(ffffffc6) = 64(40)\nunsigned 8 1(1) << -57(ffffffc7) = 128(80)\nunsigned 8 1(1) << -56(ffffffc8) = 256(100)\nunsigned 8 1(1) << -55(ffffffc9) = 512(200)\nunsigned 8 1(1) << -54(ffffffca) = 1024(400)\nunsigned 8 1(1) << -53(ffffffcb) = 2048(800)\nunsigned 8 1(1) << -52(ffffffcc) = 4096(1000)\nunsigned 8 1(1) << -51(ffffffcd) = 8192(2000)\nunsigned 8 1(1) << -50(ffffffce) = 16384(4000)\nunsigned 8 1(1) << -49(ffffffcf) = 32768(8000)\nunsigned 8 1(1) << -48(ffffffd0) = 65536(10000)\nunsigned 8 1(1) << -47(ffffffd1) = 131072(20000)\nunsigned 8 1(1) << -46(ffffffd2) = 262144(40000)\nunsigned 8 1(1) << -45(ffffffd3) = 524288(80000)\nunsigned 8 1(1) << -44(ffffffd4) = 1048576(100000)\nunsigned 8 1(1) << -43(ffffffd5) = 2097152(200000)\nunsigned 8 1(1) << -42(ffffffd6) = 4194304(400000)\nunsigned 8 1(1) << -41(ffffffd7) = 8388608(800000)\nunsigned 8 1(1) << -40(ffffffd8) = 16777216(1000000)\nunsigned 8 1(1) << -39(ffffffd9) = 33554432(2000000)\nunsigned 8 1(1) << -38(ffffffda) = 67108864(4000000)\nunsigned 8 1(1) << -37(ffffffdb) = 134217728(8000000)\nunsigned 8 1(1) << -36(ffffffdc) = 268435456(10000000)\nunsigned 8 1(1) << -35(ffffffdd) = 536870912(20000000)\nunsigned 8 1(1) << -34(ffffffde) = 1073741824(40000000)\nunsigned 8 1(1) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 1(1) << -32(ffffffe0) = 0(0)\nunsigned 8 1(1) << -31(ffffffe1) = 0(0)\nunsigned 8 1(1) << -30(ffffffe2) = 0(0)\nunsigned 8 1(1) << -29(ffffffe3) = 0(0)\nunsigned 8 1(1) << -28(ffffffe4) = 0(0)\nunsigned 8 1(1) << -27(ffffffe5) = 0(0)\nunsigned 8 1(1) << -26(ffffffe6) = 0(0)\nunsigned 8 1(1) << -25(ffffffe7) = 0(0)\nunsigned 8 1(1) << -24(ffffffe8) = 0(0)\nunsigned 8 1(1) << -23(ffffffe9) = 0(0)\nunsigned 8 1(1) << -22(ffffffea) = 0(0)\nunsigned 8 1(1) << -21(ffffffeb) = 0(0)\nunsigned 8 1(1) << -20(ffffffec) = 0(0)\nunsigned 8 1(1) << -19(ffffffed) = 0(0)\nunsigned 8 1(1) << -18(ffffffee) = 0(0)\nunsigned 8 1(1) << -17(ffffffef) = 0(0)\nunsigned 8 1(1) << -16(fffffff0) = 0(0)\nunsigned 8 1(1) << -15(fffffff1) = 0(0)\nunsigned 8 1(1) << -14(fffffff2) = 0(0)\nunsigned 8 1(1) << -13(fffffff3) = 0(0)\nunsigned 8 1(1) << -12(fffffff4) = 0(0)\nunsigned 8 1(1) << -11(fffffff5) = 0(0)\nunsigned 8 1(1) << -10(fffffff6) = 0(0)\nunsigned 8 1(1) << -9(fffffff7) = 0(0)\nunsigned 8 1(1) << -8(fffffff8) = 0(0)\nunsigned 8 1(1) << -7(fffffff9) = 0(0)\nunsigned 8 1(1) << -6(fffffffa) = 0(0)\nunsigned 8 1(1) << -5(fffffffb) = 0(0)\nunsigned 8 1(1) << -4(fffffffc) = 0(0)\nunsigned 8 1(1) << -3(fffffffd) = 0(0)\nunsigned 8 1(1) << -2(fffffffe) = 0(0)\nunsigned 8 1(1) << -1(ffffffff) = 0(0)\nunsigned 8 1(1) << 0(0) = 1(1)\nunsigned 8 1(1) << 1(1) = 2(2)\nunsigned 8 1(1) << 2(2) = 4(4)\nunsigned 8 1(1) << 3(3) = 8(8)\nunsigned 8 1(1) << 4(4) = 16(10)\nunsigned 8 1(1) << 5(5) = 32(20)\nunsigned 8 1(1) << 6(6) = 64(40)\nunsigned 8 1(1) << 7(7) = 128(80)\nunsigned 8 1(1) << 8(8) = 256(100)\nunsigned 8 1(1) << 9(9) = 512(200)\nunsigned 8 1(1) << 10(a) = 1024(400)\nunsigned 8 1(1) << 11(b) = 2048(800)\nunsigned 8 1(1) << 12(c) = 4096(1000)\nunsigned 8 1(1) << 13(d) = 8192(2000)\nunsigned 8 1(1) << 14(e) = 16384(4000)\nunsigned 8 1(1) << 15(f) = 32768(8000)\nunsigned 8 1(1) << 16(10) = 65536(10000)\nunsigned 8 1(1) << 17(11) = 131072(20000)\nunsigned 8 1(1) << 18(12) = 262144(40000)\nunsigned 8 1(1) << 19(13) = 524288(80000)\nunsigned 8 1(1) << 20(14) = 1048576(100000)\nunsigned 8 1(1) << 21(15) = 2097152(200000)\nunsigned 8 1(1) << 22(16) = 4194304(400000)\nunsigned 8 1(1) << 23(17) = 8388608(800000)\nunsigned 8 1(1) << 24(18) = 16777216(1000000)\nunsigned 8 1(1) << 25(19) = 33554432(2000000)\nunsigned 8 1(1) << 26(1a) = 67108864(4000000)\nunsigned 8 1(1) << 27(1b) = 134217728(8000000)\nunsigned 8 1(1) << 28(1c) = 268435456(10000000)\nunsigned 8 1(1) << 29(1d) = 536870912(20000000)\nunsigned 8 1(1) << 30(1e) = 1073741824(40000000)\nunsigned 8 1(1) << 31(1f) = 2147483648(80000000)\nunsigned 8 1(1) << 32(20) = 0(0)\nunsigned 8 1(1) << 33(21) = 0(0)\nunsigned 8 1(1) << 34(22) = 0(0)\nunsigned 8 1(1) << 35(23) = 0(0)\nunsigned 8 1(1) << 36(24) = 0(0)\nunsigned 8 1(1) << 37(25) = 0(0)\nunsigned 8 1(1) << 38(26) = 0(0)\nunsigned 8 1(1) << 39(27) = 0(0)\nunsigned 8 1(1) << 40(28) = 0(0)\nunsigned 8 1(1) << 41(29) = 0(0)\nunsigned 8 1(1) << 42(2a) = 0(0)\nunsigned 8 1(1) << 43(2b) = 0(0)\nunsigned 8 1(1) << 44(2c) = 0(0)\nunsigned 8 1(1) << 45(2d) = 0(0)\nunsigned 8 1(1) << 46(2e) = 0(0)\nunsigned 8 1(1) << 47(2f) = 0(0)\nunsigned 8 1(1) << 48(30) = 0(0)\nunsigned 8 1(1) << 49(31) = 0(0)\nunsigned 8 1(1) << 50(32) = 0(0)\nunsigned 8 1(1) << 51(33) = 0(0)\nunsigned 8 1(1) << 52(34) = 0(0)\nunsigned 8 1(1) << 53(35) = 0(0)\nunsigned 8 1(1) << 54(36) = 0(0)\nunsigned 8 1(1) << 55(37) = 0(0)\nunsigned 8 1(1) << 56(38) = 0(0)\nunsigned 8 1(1) << 57(39) = 0(0)\nunsigned 8 1(1) << 58(3a) = 0(0)\nunsigned 8 1(1) << 59(3b) = 0(0)\nunsigned 8 1(1) << 60(3c) = 0(0)\nunsigned 8 1(1) << 61(3d) = 0(0)\nunsigned 8 1(1) << 62(3e) = 0(0)\nunsigned 8 1(1) << 63(3f) = 0(0)\nunsigned 8 1(1) << 64(40) = 1(1)\nunsigned 8 1(1) << 65(41) = 2(2)\nunsigned 8 1(1) << 66(42) = 4(4)\nunsigned 8 1(1) << 67(43) = 8(8)\nunsigned 8 1(1) << 68(44) = 16(10)\nunsigned 8 1(1) << 69(45) = 32(20)\nunsigned 8 1(1) << 70(46) = 64(40)\nunsigned 8 1(1) << 71(47) = 128(80)\nunsigned 8 1(1) << 72(48) = 256(100)\nunsigned 8 1(1) << 73(49) = 512(200)\nunsigned 8 1(1) << 74(4a) = 1024(400)\nunsigned 8 1(1) << 75(4b) = 2048(800)\nunsigned 8 1(1) << 76(4c) = 4096(1000)\nunsigned 8 1(1) << 77(4d) = 8192(2000)\nunsigned 8 1(1) << 78(4e) = 16384(4000)\nunsigned 8 1(1) << 79(4f) = 32768(8000)\nunsigned 8 1(1) << 80(50) = 65536(10000)\nunsigned 8 1(1) << 81(51) = 131072(20000)\nunsigned 8 1(1) << 82(52) = 262144(40000)\nunsigned 8 1(1) << 83(53) = 524288(80000)\nunsigned 8 1(1) << 84(54) = 1048576(100000)\nunsigned 8 1(1) << 85(55) = 2097152(200000)\nunsigned 8 1(1) << 86(56) = 4194304(400000)\nunsigned 8 1(1) << 87(57) = 8388608(800000)\nunsigned 8 1(1) << 88(58) = 16777216(1000000)\nunsigned 8 1(1) << 89(59) = 33554432(2000000)\nunsigned 8 1(1) << 90(5a) = 67108864(4000000)\nunsigned 8 1(1) << 91(5b) = 134217728(8000000)\nunsigned 8 1(1) << 92(5c) = 268435456(10000000)\nunsigned 8 1(1) << 93(5d) = 536870912(20000000)\nunsigned 8 1(1) << 94(5e) = 1073741824(40000000)\nunsigned 8 1(1) << 95(5f) = 2147483648(80000000)\nunsigned 8 1(1) << 96(60) = 0(0)\nunsigned 8 1(1) << 97(61) = 0(0)\nunsigned 8 1(1) << 98(62) = 0(0)\nunsigned 8 1(1) << 99(63) = 0(0)\nunsigned 8 1(1) << 100(64) = 0(0)\nunsigned 8 1(1) << 101(65) = 0(0)\nunsigned 8 1(1) << 102(66) = 0(0)\nunsigned 8 1(1) << 103(67) = 0(0)\nunsigned 8 1(1) << 104(68) = 0(0)\nunsigned 8 1(1) << 105(69) = 0(0)\nunsigned 8 1(1) << 106(6a) = 0(0)\nunsigned 8 1(1) << 107(6b) = 0(0)\nunsigned 8 1(1) << 108(6c) = 0(0)\nunsigned 8 1(1) << 109(6d) = 0(0)\nunsigned 8 1(1) << 110(6e) = 0(0)\nunsigned 8 1(1) << 111(6f) = 0(0)\nunsigned 8 1(1) << 112(70) = 0(0)\nunsigned 8 1(1) << 113(71) = 0(0)\nunsigned 8 1(1) << 114(72) = 0(0)\nunsigned 8 1(1) << 115(73) = 0(0)\nunsigned 8 1(1) << 116(74) = 0(0)\nunsigned 8 1(1) << 117(75) = 0(0)\nunsigned 8 1(1) << 118(76) = 0(0)\nunsigned 8 1(1) << 119(77) = 0(0)\nunsigned 8 1(1) << 120(78) = 0(0)\nunsigned 8 1(1) << 121(79) = 0(0)\nunsigned 8 1(1) << 122(7a) = 0(0)\nunsigned 8 1(1) << 123(7b) = 0(0)\nunsigned 8 1(1) << 124(7c) = 0(0)\nunsigned 8 1(1) << 125(7d) = 0(0)\nunsigned 8 1(1) << 126(7e) = 0(0)\nunsigned 8 1(1) << 127(7f) = 0(0)\nunsigned 8 2(2) << -128(ffffff80) = 2(2)\nunsigned 8 2(2) << -127(ffffff81) = 4(4)\nunsigned 8 2(2) << -126(ffffff82) = 8(8)\nunsigned 8 2(2) << -125(ffffff83) = 16(10)\nunsigned 8 2(2) << -124(ffffff84) = 32(20)\nunsigned 8 2(2) << -123(ffffff85) = 64(40)\nunsigned 8 2(2) << -122(ffffff86) = 128(80)\nunsigned 8 2(2) << -121(ffffff87) = 256(100)\nunsigned 8 2(2) << -120(ffffff88) = 512(200)\nunsigned 8 2(2) << -119(ffffff89) = 1024(400)\nunsigned 8 2(2) << -118(ffffff8a) = 2048(800)\nunsigned 8 2(2) << -117(ffffff8b) = 4096(1000)\nunsigned 8 2(2) << -116(ffffff8c) = 8192(2000)\nunsigned 8 2(2) << -115(ffffff8d) = 16384(4000)\nunsigned 8 2(2) << -114(ffffff8e) = 32768(8000)\nunsigned 8 2(2) << -113(ffffff8f) = 65536(10000)\nunsigned 8 2(2) << -112(ffffff90) = 131072(20000)\nunsigned 8 2(2) << -111(ffffff91) = 262144(40000)\nunsigned 8 2(2) << -110(ffffff92) = 524288(80000)\nunsigned 8 2(2) << -109(ffffff93) = 1048576(100000)\nunsigned 8 2(2) << -108(ffffff94) = 2097152(200000)\nunsigned 8 2(2) << -107(ffffff95) = 4194304(400000)\nunsigned 8 2(2) << -106(ffffff96) = 8388608(800000)\nunsigned 8 2(2) << -105(ffffff97) = 16777216(1000000)\nunsigned 8 2(2) << -104(ffffff98) = 33554432(2000000)\nunsigned 8 2(2) << -103(ffffff99) = 67108864(4000000)\nunsigned 8 2(2) << -102(ffffff9a) = 134217728(8000000)\nunsigned 8 2(2) << -101(ffffff9b) = 268435456(10000000)\nunsigned 8 2(2) << -100(ffffff9c) = 536870912(20000000)\nunsigned 8 2(2) << -99(ffffff9d) = 1073741824(40000000)\nunsigned 8 2(2) << -98(ffffff9e) = 2147483648(80000000)\nunsigned 8 2(2) << -97(ffffff9f) = 0(0)\nunsigned 8 2(2) << -96(ffffffa0) = 0(0)\nunsigned 8 2(2) << -95(ffffffa1) = 0(0)\nunsigned 8 2(2) << -94(ffffffa2) = 0(0)\nunsigned 8 2(2) << -93(ffffffa3) = 0(0)\nunsigned 8 2(2) << -92(ffffffa4) = 0(0)\nunsigned 8 2(2) << -91(ffffffa5) = 0(0)\nunsigned 8 2(2) << -90(ffffffa6) = 0(0)\nunsigned 8 2(2) << -89(ffffffa7) = 0(0)\nunsigned 8 2(2) << -88(ffffffa8) = 0(0)\nunsigned 8 2(2) << -87(ffffffa9) = 0(0)\nunsigned 8 2(2) << -86(ffffffaa) = 0(0)\nunsigned 8 2(2) << -85(ffffffab) = 0(0)\nunsigned 8 2(2) << -84(ffffffac) = 0(0)\nunsigned 8 2(2) << -83(ffffffad) = 0(0)\nunsigned 8 2(2) << -82(ffffffae) = 0(0)\nunsigned 8 2(2) << -81(ffffffaf) = 0(0)\nunsigned 8 2(2) << -80(ffffffb0) = 0(0)\nunsigned 8 2(2) << -79(ffffffb1) = 0(0)\nunsigned 8 2(2) << -78(ffffffb2) = 0(0)\nunsigned 8 2(2) << -77(ffffffb3) = 0(0)\nunsigned 8 2(2) << -76(ffffffb4) = 0(0)\nunsigned 8 2(2) << -75(ffffffb5) = 0(0)\nunsigned 8 2(2) << -74(ffffffb6) = 0(0)\nunsigned 8 2(2) << -73(ffffffb7) = 0(0)\nunsigned 8 2(2) << -72(ffffffb8) = 0(0)\nunsigned 8 2(2) << -71(ffffffb9) = 0(0)\nunsigned 8 2(2) << -70(ffffffba) = 0(0)\nunsigned 8 2(2) << -69(ffffffbb) = 0(0)\nunsigned 8 2(2) << -68(ffffffbc) = 0(0)\nunsigned 8 2(2) << -67(ffffffbd) = 0(0)\nunsigned 8 2(2) << -66(ffffffbe) = 0(0)\nunsigned 8 2(2) << -65(ffffffbf) = 0(0)\nunsigned 8 2(2) << -64(ffffffc0) = 2(2)\nunsigned 8 2(2) << -63(ffffffc1) = 4(4)\nunsigned 8 2(2) << -62(ffffffc2) = 8(8)\nunsigned 8 2(2) << -61(ffffffc3) = 16(10)\nunsigned 8 2(2) << -60(ffffffc4) = 32(20)\nunsigned 8 2(2) << -59(ffffffc5) = 64(40)\nunsigned 8 2(2) << -58(ffffffc6) = 128(80)\nunsigned 8 2(2) << -57(ffffffc7) = 256(100)\nunsigned 8 2(2) << -56(ffffffc8) = 512(200)\nunsigned 8 2(2) << -55(ffffffc9) = 1024(400)\nunsigned 8 2(2) << -54(ffffffca) = 2048(800)\nunsigned 8 2(2) << -53(ffffffcb) = 4096(1000)\nunsigned 8 2(2) << -52(ffffffcc) = 8192(2000)\nunsigned 8 2(2) << -51(ffffffcd) = 16384(4000)\nunsigned 8 2(2) << -50(ffffffce) = 32768(8000)\nunsigned 8 2(2) << -49(ffffffcf) = 65536(10000)\nunsigned 8 2(2) << -48(ffffffd0) = 131072(20000)\nunsigned 8 2(2) << -47(ffffffd1) = 262144(40000)\nunsigned 8 2(2) << -46(ffffffd2) = 524288(80000)\nunsigned 8 2(2) << -45(ffffffd3) = 1048576(100000)\nunsigned 8 2(2) << -44(ffffffd4) = 2097152(200000)\nunsigned 8 2(2) << -43(ffffffd5) = 4194304(400000)\nunsigned 8 2(2) << -42(ffffffd6) = 8388608(800000)\nunsigned 8 2(2) << -41(ffffffd7) = 16777216(1000000)\nunsigned 8 2(2) << -40(ffffffd8) = 33554432(2000000)\nunsigned 8 2(2) << -39(ffffffd9) = 67108864(4000000)\nunsigned 8 2(2) << -38(ffffffda) = 134217728(8000000)\nunsigned 8 2(2) << -37(ffffffdb) = 268435456(10000000)\nunsigned 8 2(2) << -36(ffffffdc) = 536870912(20000000)\nunsigned 8 2(2) << -35(ffffffdd) = 1073741824(40000000)\nunsigned 8 2(2) << -34(ffffffde) = 2147483648(80000000)\nunsigned 8 2(2) << -33(ffffffdf) = 0(0)\nunsigned 8 2(2) << -32(ffffffe0) = 0(0)\nunsigned 8 2(2) << -31(ffffffe1) = 0(0)\nunsigned 8 2(2) << -30(ffffffe2) = 0(0)\nunsigned 8 2(2) << -29(ffffffe3) = 0(0)\nunsigned 8 2(2) << -28(ffffffe4) = 0(0)\nunsigned 8 2(2) << -27(ffffffe5) = 0(0)\nunsigned 8 2(2) << -26(ffffffe6) = 0(0)\nunsigned 8 2(2) << -25(ffffffe7) = 0(0)\nunsigned 8 2(2) << -24(ffffffe8) = 0(0)\nunsigned 8 2(2) << -23(ffffffe9) = 0(0)\nunsigned 8 2(2) << -22(ffffffea) = 0(0)\nunsigned 8 2(2) << -21(ffffffeb) = 0(0)\nunsigned 8 2(2) << -20(ffffffec) = 0(0)\nunsigned 8 2(2) << -19(ffffffed) = 0(0)\nunsigned 8 2(2) << -18(ffffffee) = 0(0)\nunsigned 8 2(2) << -17(ffffffef) = 0(0)\nunsigned 8 2(2) << -16(fffffff0) = 0(0)\nunsigned 8 2(2) << -15(fffffff1) = 0(0)\nunsigned 8 2(2) << -14(fffffff2) = 0(0)\nunsigned 8 2(2) << -13(fffffff3) = 0(0)\nunsigned 8 2(2) << -12(fffffff4) = 0(0)\nunsigned 8 2(2) << -11(fffffff5) = 0(0)\nunsigned 8 2(2) << -10(fffffff6) = 0(0)\nunsigned 8 2(2) << -9(fffffff7) = 0(0)\nunsigned 8 2(2) << -8(fffffff8) = 0(0)\nunsigned 8 2(2) << -7(fffffff9) = 0(0)\nunsigned 8 2(2) << -6(fffffffa) = 0(0)\nunsigned 8 2(2) << -5(fffffffb) = 0(0)\nunsigned 8 2(2) << -4(fffffffc) = 0(0)\nunsigned 8 2(2) << -3(fffffffd) = 0(0)\nunsigned 8 2(2) << -2(fffffffe) = 0(0)\nunsigned 8 2(2) << -1(ffffffff) = 0(0)\nunsigned 8 2(2) << 0(0) = 2(2)\nunsigned 8 2(2) << 1(1) = 4(4)\nunsigned 8 2(2) << 2(2) = 8(8)\nunsigned 8 2(2) << 3(3) = 16(10)\nunsigned 8 2(2) << 4(4) = 32(20)\nunsigned 8 2(2) << 5(5) = 64(40)\nunsigned 8 2(2) << 6(6) = 128(80)\nunsigned 8 2(2) << 7(7) = 256(100)\nunsigned 8 2(2) << 8(8) = 512(200)\nunsigned 8 2(2) << 9(9) = 1024(400)\nunsigned 8 2(2) << 10(a) = 2048(800)\nunsigned 8 2(2) << 11(b) = 4096(1000)\nunsigned 8 2(2) << 12(c) = 8192(2000)\nunsigned 8 2(2) << 13(d) = 16384(4000)\nunsigned 8 2(2) << 14(e) = 32768(8000)\nunsigned 8 2(2) << 15(f) = 65536(10000)\nunsigned 8 2(2) << 16(10) = 131072(20000)\nunsigned 8 2(2) << 17(11) = 262144(40000)\nunsigned 8 2(2) << 18(12) = 524288(80000)\nunsigned 8 2(2) << 19(13) = 1048576(100000)\nunsigned 8 2(2) << 20(14) = 2097152(200000)\nunsigned 8 2(2) << 21(15) = 4194304(400000)\nunsigned 8 2(2) << 22(16) = 8388608(800000)\nunsigned 8 2(2) << 23(17) = 16777216(1000000)\nunsigned 8 2(2) << 24(18) = 33554432(2000000)\nunsigned 8 2(2) << 25(19) = 67108864(4000000)\nunsigned 8 2(2) << 26(1a) = 134217728(8000000)\nunsigned 8 2(2) << 27(1b) = 268435456(10000000)\nunsigned 8 2(2) << 28(1c) = 536870912(20000000)\nunsigned 8 2(2) << 29(1d) = 1073741824(40000000)\nunsigned 8 2(2) << 30(1e) = 2147483648(80000000)\nunsigned 8 2(2) << 31(1f) = 0(0)\nunsigned 8 2(2) << 32(20) = 0(0)\nunsigned 8 2(2) << 33(21) = 0(0)\nunsigned 8 2(2) << 34(22) = 0(0)\nunsigned 8 2(2) << 35(23) = 0(0)\nunsigned 8 2(2) << 36(24) = 0(0)\nunsigned 8 2(2) << 37(25) = 0(0)\nunsigned 8 2(2) << 38(26) = 0(0)\nunsigned 8 2(2) << 39(27) = 0(0)\nunsigned 8 2(2) << 40(28) = 0(0)\nunsigned 8 2(2) << 41(29) = 0(0)\nunsigned 8 2(2) << 42(2a) = 0(0)\nunsigned 8 2(2) << 43(2b) = 0(0)\nunsigned 8 2(2) << 44(2c) = 0(0)\nunsigned 8 2(2) << 45(2d) = 0(0)\nunsigned 8 2(2) << 46(2e) = 0(0)\nunsigned 8 2(2) << 47(2f) = 0(0)\nunsigned 8 2(2) << 48(30) = 0(0)\nunsigned 8 2(2) << 49(31) = 0(0)\nunsigned 8 2(2) << 50(32) = 0(0)\nunsigned 8 2(2) << 51(33) = 0(0)\nunsigned 8 2(2) << 52(34) = 0(0)\nunsigned 8 2(2) << 53(35) = 0(0)\nunsigned 8 2(2) << 54(36) = 0(0)\nunsigned 8 2(2) << 55(37) = 0(0)\nunsigned 8 2(2) << 56(38) = 0(0)\nunsigned 8 2(2) << 57(39) = 0(0)\nunsigned 8 2(2) << 58(3a) = 0(0)\nunsigned 8 2(2) << 59(3b) = 0(0)\nunsigned 8 2(2) << 60(3c) = 0(0)\nunsigned 8 2(2) << 61(3d) = 0(0)\nunsigned 8 2(2) << 62(3e) = 0(0)\nunsigned 8 2(2) << 63(3f) = 0(0)\nunsigned 8 2(2) << 64(40) = 2(2)\nunsigned 8 2(2) << 65(41) = 4(4)\nunsigned 8 2(2) << 66(42) = 8(8)\nunsigned 8 2(2) << 67(43) = 16(10)\nunsigned 8 2(2) << 68(44) = 32(20)\nunsigned 8 2(2) << 69(45) = 64(40)\nunsigned 8 2(2) << 70(46) = 128(80)\nunsigned 8 2(2) << 71(47) = 256(100)\nunsigned 8 2(2) << 72(48) = 512(200)\nunsigned 8 2(2) << 73(49) = 1024(400)\nunsigned 8 2(2) << 74(4a) = 2048(800)\nunsigned 8 2(2) << 75(4b) = 4096(1000)\nunsigned 8 2(2) << 76(4c) = 8192(2000)\nunsigned 8 2(2) << 77(4d) = 16384(4000)\nunsigned 8 2(2) << 78(4e) = 32768(8000)\nunsigned 8 2(2) << 79(4f) = 65536(10000)\nunsigned 8 2(2) << 80(50) = 131072(20000)\nunsigned 8 2(2) << 81(51) = 262144(40000)\nunsigned 8 2(2) << 82(52) = 524288(80000)\nunsigned 8 2(2) << 83(53) = 1048576(100000)\nunsigned 8 2(2) << 84(54) = 2097152(200000)\nunsigned 8 2(2) << 85(55) = 4194304(400000)\nunsigned 8 2(2) << 86(56) = 8388608(800000)\nunsigned 8 2(2) << 87(57) = 16777216(1000000)\nunsigned 8 2(2) << 88(58) = 33554432(2000000)\nunsigned 8 2(2) << 89(59) = 67108864(4000000)\nunsigned 8 2(2) << 90(5a) = 134217728(8000000)\nunsigned 8 2(2) << 91(5b) = 268435456(10000000)\nunsigned 8 2(2) << 92(5c) = 536870912(20000000)\nunsigned 8 2(2) << 93(5d) = 1073741824(40000000)\nunsigned 8 2(2) << 94(5e) = 2147483648(80000000)\nunsigned 8 2(2) << 95(5f) = 0(0)\nunsigned 8 2(2) << 96(60) = 0(0)\nunsigned 8 2(2) << 97(61) = 0(0)\nunsigned 8 2(2) << 98(62) = 0(0)\nunsigned 8 2(2) << 99(63) = 0(0)\nunsigned 8 2(2) << 100(64) = 0(0)\nunsigned 8 2(2) << 101(65) = 0(0)\nunsigned 8 2(2) << 102(66) = 0(0)\nunsigned 8 2(2) << 103(67) = 0(0)\nunsigned 8 2(2) << 104(68) = 0(0)\nunsigned 8 2(2) << 105(69) = 0(0)\nunsigned 8 2(2) << 106(6a) = 0(0)\nunsigned 8 2(2) << 107(6b) = 0(0)\nunsigned 8 2(2) << 108(6c) = 0(0)\nunsigned 8 2(2) << 109(6d) = 0(0)\nunsigned 8 2(2) << 110(6e) = 0(0)\nunsigned 8 2(2) << 111(6f) = 0(0)\nunsigned 8 2(2) << 112(70) = 0(0)\nunsigned 8 2(2) << 113(71) = 0(0)\nunsigned 8 2(2) << 114(72) = 0(0)\nunsigned 8 2(2) << 115(73) = 0(0)\nunsigned 8 2(2) << 116(74) = 0(0)\nunsigned 8 2(2) << 117(75) = 0(0)\nunsigned 8 2(2) << 118(76) = 0(0)\nunsigned 8 2(2) << 119(77) = 0(0)\nunsigned 8 2(2) << 120(78) = 0(0)\nunsigned 8 2(2) << 121(79) = 0(0)\nunsigned 8 2(2) << 122(7a) = 0(0)\nunsigned 8 2(2) << 123(7b) = 0(0)\nunsigned 8 2(2) << 124(7c) = 0(0)\nunsigned 8 2(2) << 125(7d) = 0(0)\nunsigned 8 2(2) << 126(7e) = 0(0)\nunsigned 8 2(2) << 127(7f) = 0(0)\nunsigned 8 3(3) << -128(ffffff80) = 3(3)\nunsigned 8 3(3) << -127(ffffff81) = 6(6)\nunsigned 8 3(3) << -126(ffffff82) = 12(c)\nunsigned 8 3(3) << -125(ffffff83) = 24(18)\nunsigned 8 3(3) << -124(ffffff84) = 48(30)\nunsigned 8 3(3) << -123(ffffff85) = 96(60)\nunsigned 8 3(3) << -122(ffffff86) = 192(c0)\nunsigned 8 3(3) << -121(ffffff87) = 384(180)\nunsigned 8 3(3) << -120(ffffff88) = 768(300)\nunsigned 8 3(3) << -119(ffffff89) = 1536(600)\nunsigned 8 3(3) << -118(ffffff8a) = 3072(c00)\nunsigned 8 3(3) << -117(ffffff8b) = 6144(1800)\nunsigned 8 3(3) << -116(ffffff8c) = 12288(3000)\nunsigned 8 3(3) << -115(ffffff8d) = 24576(6000)\nunsigned 8 3(3) << -114(ffffff8e) = 49152(c000)\nunsigned 8 3(3) << -113(ffffff8f) = 98304(18000)\nunsigned 8 3(3) << -112(ffffff90) = 196608(30000)\nunsigned 8 3(3) << -111(ffffff91) = 393216(60000)\nunsigned 8 3(3) << -110(ffffff92) = 786432(c0000)\nunsigned 8 3(3) << -109(ffffff93) = 1572864(180000)\nunsigned 8 3(3) << -108(ffffff94) = 3145728(300000)\nunsigned 8 3(3) << -107(ffffff95) = 6291456(600000)\nunsigned 8 3(3) << -106(ffffff96) = 12582912(c00000)\nunsigned 8 3(3) << -105(ffffff97) = 25165824(1800000)\nunsigned 8 3(3) << -104(ffffff98) = 50331648(3000000)\nunsigned 8 3(3) << -103(ffffff99) = 100663296(6000000)\nunsigned 8 3(3) << -102(ffffff9a) = 201326592(c000000)\nunsigned 8 3(3) << -101(ffffff9b) = 402653184(18000000)\nunsigned 8 3(3) << -100(ffffff9c) = 805306368(30000000)\nunsigned 8 3(3) << -99(ffffff9d) = 1610612736(60000000)\nunsigned 8 3(3) << -98(ffffff9e) = 3221225472(c0000000)\nunsigned 8 3(3) << -97(ffffff9f) = 2147483648(80000000)\nunsigned 8 3(3) << -96(ffffffa0) = 0(0)\nunsigned 8 3(3) << -95(ffffffa1) = 0(0)\nunsigned 8 3(3) << -94(ffffffa2) = 0(0)\nunsigned 8 3(3) << -93(ffffffa3) = 0(0)\nunsigned 8 3(3) << -92(ffffffa4) = 0(0)\nunsigned 8 3(3) << -91(ffffffa5) = 0(0)\nunsigned 8 3(3) << -90(ffffffa6) = 0(0)\nunsigned 8 3(3) << -89(ffffffa7) = 0(0)\nunsigned 8 3(3) << -88(ffffffa8) = 0(0)\nunsigned 8 3(3) << -87(ffffffa9) = 0(0)\nunsigned 8 3(3) << -86(ffffffaa) = 0(0)\nunsigned 8 3(3) << -85(ffffffab) = 0(0)\nunsigned 8 3(3) << -84(ffffffac) = 0(0)\nunsigned 8 3(3) << -83(ffffffad) = 0(0)\nunsigned 8 3(3) << -82(ffffffae) = 0(0)\nunsigned 8 3(3) << -81(ffffffaf) = 0(0)\nunsigned 8 3(3) << -80(ffffffb0) = 0(0)\nunsigned 8 3(3) << -79(ffffffb1) = 0(0)\nunsigned 8 3(3) << -78(ffffffb2) = 0(0)\nunsigned 8 3(3) << -77(ffffffb3) = 0(0)\nunsigned 8 3(3) << -76(ffffffb4) = 0(0)\nunsigned 8 3(3) << -75(ffffffb5) = 0(0)\nunsigned 8 3(3) << -74(ffffffb6) = 0(0)\nunsigned 8 3(3) << -73(ffffffb7) = 0(0)\nunsigned 8 3(3) << -72(ffffffb8) = 0(0)\nunsigned 8 3(3) << -71(ffffffb9) = 0(0)\nunsigned 8 3(3) << -70(ffffffba) = 0(0)\nunsigned 8 3(3) << -69(ffffffbb) = 0(0)\nunsigned 8 3(3) << -68(ffffffbc) = 0(0)\nunsigned 8 3(3) << -67(ffffffbd) = 0(0)\nunsigned 8 3(3) << -66(ffffffbe) = 0(0)\nunsigned 8 3(3) << -65(ffffffbf) = 0(0)\nunsigned 8 3(3) << -64(ffffffc0) = 3(3)\nunsigned 8 3(3) << -63(ffffffc1) = 6(6)\nunsigned 8 3(3) << -62(ffffffc2) = 12(c)\nunsigned 8 3(3) << -61(ffffffc3) = 24(18)\nunsigned 8 3(3) << -60(ffffffc4) = 48(30)\nunsigned 8 3(3) << -59(ffffffc5) = 96(60)\nunsigned 8 3(3) << -58(ffffffc6) = 192(c0)\nunsigned 8 3(3) << -57(ffffffc7) = 384(180)\nunsigned 8 3(3) << -56(ffffffc8) = 768(300)\nunsigned 8 3(3) << -55(ffffffc9) = 1536(600)\nunsigned 8 3(3) << -54(ffffffca) = 3072(c00)\nunsigned 8 3(3) << -53(ffffffcb) = 6144(1800)\nunsigned 8 3(3) << -52(ffffffcc) = 12288(3000)\nunsigned 8 3(3) << -51(ffffffcd) = 24576(6000)\nunsigned 8 3(3) << -50(ffffffce) = 49152(c000)\nunsigned 8 3(3) << -49(ffffffcf) = 98304(18000)\nunsigned 8 3(3) << -48(ffffffd0) = 196608(30000)\nunsigned 8 3(3) << -47(ffffffd1) = 393216(60000)\nunsigned 8 3(3) << -46(ffffffd2) = 786432(c0000)\nunsigned 8 3(3) << -45(ffffffd3) = 1572864(180000)\nunsigned 8 3(3) << -44(ffffffd4) = 3145728(300000)\nunsigned 8 3(3) << -43(ffffffd5) = 6291456(600000)\nunsigned 8 3(3) << -42(ffffffd6) = 12582912(c00000)\nunsigned 8 3(3) << -41(ffffffd7) = 25165824(1800000)\nunsigned 8 3(3) << -40(ffffffd8) = 50331648(3000000)\nunsigned 8 3(3) << -39(ffffffd9) = 100663296(6000000)\nunsigned 8 3(3) << -38(ffffffda) = 201326592(c000000)\nunsigned 8 3(3) << -37(ffffffdb) = 402653184(18000000)\nunsigned 8 3(3) << -36(ffffffdc) = 805306368(30000000)\nunsigned 8 3(3) << -35(ffffffdd) = 1610612736(60000000)\nunsigned 8 3(3) << -34(ffffffde) = 3221225472(c0000000)\nunsigned 8 3(3) << -33(ffffffdf) = 2147483648(80000000)\nunsigned 8 3(3) << -32(ffffffe0) = 0(0)\nunsigned 8 3(3) << -31(ffffffe1) = 0(0)\nunsigned 8 3(3) << -30(ffffffe2) = 0(0)\nunsigned 8 3(3) << -29(ffffffe3) = 0(0)\nunsigned 8 3(3) << -28(ffffffe4) = 0(0)\nunsigned 8 3(3) << -27(ffffffe5) = 0(0)\nunsigned 8 3(3) << -26(ffffffe6) = 0(0)\nunsigned 8 3(3) << -25(ffffffe7) = 0(0)\nunsigned 8 3(3) << -24(ffffffe8) = 0(0)\nunsigned 8 3(3) << -23(ffffffe9) = 0(0)\nunsigned 8 3(3) << -22(ffffffea) = 0(0)\nunsigned 8 3(3) << -21(ffffffeb) = 0(0)\nunsigned 8 3(3) << -20(ffffffec) = 0(0)\nunsigned 8 3(3) << -19(ffffffed) = 0(0)\nunsigned 8 3(3) << -18(ffffffee) = 0(0)\nunsigned 8 3(3) << -17(ffffffef) = 0(0)\nunsigned 8 3(3) << -16(fffffff0) = 0(0)\nunsigned 8 3(3) << -15(fffffff1) = 0(0)\nunsigned 8 3(3) << -14(fffffff2) = 0(0)\nunsigned 8 3(3) << -13(fffffff3) = 0(0)\nunsigned 8 3(3) << -12(fffffff4) = 0(0)\nunsigned 8 3(3) << -11(fffffff5) = 0(0)\nunsigned 8 3(3) << -10(fffffff6) = 0(0)\nunsigned 8 3(3) << -9(fffffff7) = 0(0)\nunsigned 8 3(3) << -8(fffffff8) = 0(0)\nunsigned 8 3(3) << -7(fffffff9) = 0(0)\nunsigned 8 3(3) << -6(fffffffa) = 0(0)\nunsigned 8 3(3) << -5(fffffffb) = 0(0)\nunsigned 8 3(3) << -4(fffffffc) = 0(0)\nunsigned 8 3(3) << -3(fffffffd) = 0(0)\nunsigned 8 3(3) << -2(fffffffe) = 0(0)\nunsigned 8 3(3) << -1(ffffffff) = 0(0)\nunsigned 8 3(3) << 0(0) = 3(3)\nunsigned 8 3(3) << 1(1) = 6(6)\nunsigned 8 3(3) << 2(2) = 12(c)\nunsigned 8 3(3) << 3(3) = 24(18)\nunsigned 8 3(3) << 4(4) = 48(30)\nunsigned 8 3(3) << 5(5) = 96(60)\nunsigned 8 3(3) << 6(6) = 192(c0)\nunsigned 8 3(3) << 7(7) = 384(180)\nunsigned 8 3(3) << 8(8) = 768(300)\nunsigned 8 3(3) << 9(9) = 1536(600)\nunsigned 8 3(3) << 10(a) = 3072(c00)\nunsigned 8 3(3) << 11(b) = 6144(1800)\nunsigned 8 3(3) << 12(c) = 12288(3000)\nunsigned 8 3(3) << 13(d) = 24576(6000)\nunsigned 8 3(3) << 14(e) = 49152(c000)\nunsigned 8 3(3) << 15(f) = 98304(18000)\nunsigned 8 3(3) << 16(10) = 196608(30000)\nunsigned 8 3(3) << 17(11) = 393216(60000)\nunsigned 8 3(3) << 18(12) = 786432(c0000)\nunsigned 8 3(3) << 19(13) = 1572864(180000)\nunsigned 8 3(3) << 20(14) = 3145728(300000)\nunsigned 8 3(3) << 21(15) = 6291456(600000)\nunsigned 8 3(3) << 22(16) = 12582912(c00000)\nunsigned 8 3(3) << 23(17) = 25165824(1800000)\nunsigned 8 3(3) << 24(18) = 50331648(3000000)\nunsigned 8 3(3) << 25(19) = 100663296(6000000)\nunsigned 8 3(3) << 26(1a) = 201326592(c000000)\nunsigned 8 3(3) << 27(1b) = 402653184(18000000)\nunsigned 8 3(3) << 28(1c) = 805306368(30000000)\nunsigned 8 3(3) << 29(1d) = 1610612736(60000000)\nunsigned 8 3(3) << 30(1e) = 3221225472(c0000000)\nunsigned 8 3(3) << 31(1f) = 2147483648(80000000)\nunsigned 8 3(3) << 32(20) = 0(0)\nunsigned 8 3(3) << 33(21) = 0(0)\nunsigned 8 3(3) << 34(22) = 0(0)\nunsigned 8 3(3) << 35(23) = 0(0)\nunsigned 8 3(3) << 36(24) = 0(0)\nunsigned 8 3(3) << 37(25) = 0(0)\nunsigned 8 3(3) << 38(26) = 0(0)\nunsigned 8 3(3) << 39(27) = 0(0)\nunsigned 8 3(3) << 40(28) = 0(0)\nunsigned 8 3(3) << 41(29) = 0(0)\nunsigned 8 3(3) << 42(2a) = 0(0)\nunsigned 8 3(3) << 43(2b) = 0(0)\nunsigned 8 3(3) << 44(2c) = 0(0)\nunsigned 8 3(3) << 45(2d) = 0(0)\nunsigned 8 3(3) << 46(2e) = 0(0)\nunsigned 8 3(3) << 47(2f) = 0(0)\nunsigned 8 3(3) << 48(30) = 0(0)\nunsigned 8 3(3) << 49(31) = 0(0)\nunsigned 8 3(3) << 50(32) = 0(0)\nunsigned 8 3(3) << 51(33) = 0(0)\nunsigned 8 3(3) << 52(34) = 0(0)\nunsigned 8 3(3) << 53(35) = 0(0)\nunsigned 8 3(3) << 54(36) = 0(0)\nunsigned 8 3(3) << 55(37) = 0(0)\nunsigned 8 3(3) << 56(38) = 0(0)\nunsigned 8 3(3) << 57(39) = 0(0)\nunsigned 8 3(3) << 58(3a) = 0(0)\nunsigned 8 3(3) << 59(3b) = 0(0)\nunsigned 8 3(3) << 60(3c) = 0(0)\nunsigned 8 3(3) << 61(3d) = 0(0)\nunsigned 8 3(3) << 62(3e) = 0(0)\nunsigned 8 3(3) << 63(3f) = 0(0)\nunsigned 8 3(3) << 64(40) = 3(3)\nunsigned 8 3(3) << 65(41) = 6(6)\nunsigned 8 3(3) << 66(42) = 12(c)\nunsigned 8 3(3) << 67(43) = 24(18)\nunsigned 8 3(3) << 68(44) = 48(30)\nunsigned 8 3(3) << 69(45) = 96(60)\nunsigned 8 3(3) << 70(46) = 192(c0)\nunsigned 8 3(3) << 71(47) = 384(180)\nunsigned 8 3(3) << 72(48) = 768(300)\nunsigned 8 3(3) << 73(49) = 1536(600)\nunsigned 8 3(3) << 74(4a) = 3072(c00)\nunsigned 8 3(3) << 75(4b) = 6144(1800)\nunsigned 8 3(3) << 76(4c) = 12288(3000)\nunsigned 8 3(3) << 77(4d) = 24576(6000)\nunsigned 8 3(3) << 78(4e) = 49152(c000)\nunsigned 8 3(3) << 79(4f) = 98304(18000)\nunsigned 8 3(3) << 80(50) = 196608(30000)\nunsigned 8 3(3) << 81(51) = 393216(60000)\nunsigned 8 3(3) << 82(52) = 786432(c0000)\nunsigned 8 3(3) << 83(53) = 1572864(180000)\nunsigned 8 3(3) << 84(54) = 3145728(300000)\nunsigned 8 3(3) << 85(55) = 6291456(600000)\nunsigned 8 3(3) << 86(56) = 12582912(c00000)\nunsigned 8 3(3) << 87(57) = 25165824(1800000)\nunsigned 8 3(3) << 88(58) = 50331648(3000000)\nunsigned 8 3(3) << 89(59) = 100663296(6000000)\nunsigned 8 3(3) << 90(5a) = 201326592(c000000)\nunsigned 8 3(3) << 91(5b) = 402653184(18000000)\nunsigned 8 3(3) << 92(5c) = 805306368(30000000)\nunsigned 8 3(3) << 93(5d) = 1610612736(60000000)\nunsigned 8 3(3) << 94(5e) = 3221225472(c0000000)\nunsigned 8 3(3) << 95(5f) = 2147483648(80000000)\nunsigned 8 3(3) << 96(60) = 0(0)\nunsigned 8 3(3) << 97(61) = 0(0)\nunsigned 8 3(3) << 98(62) = 0(0)\nunsigned 8 3(3) << 99(63) = 0(0)\nunsigned 8 3(3) << 100(64) = 0(0)\nunsigned 8 3(3) << 101(65) = 0(0)\nunsigned 8 3(3) << 102(66) = 0(0)\nunsigned 8 3(3) << 103(67) = 0(0)\nunsigned 8 3(3) << 104(68) = 0(0)\nunsigned 8 3(3) << 105(69) = 0(0)\nunsigned 8 3(3) << 106(6a) = 0(0)\nunsigned 8 3(3) << 107(6b) = 0(0)\nunsigned 8 3(3) << 108(6c) = 0(0)\nunsigned 8 3(3) << 109(6d) = 0(0)\nunsigned 8 3(3) << 110(6e) = 0(0)\nunsigned 8 3(3) << 111(6f) = 0(0)\nunsigned 8 3(3) << 112(70) = 0(0)\nunsigned 8 3(3) << 113(71) = 0(0)\nunsigned 8 3(3) << 114(72) = 0(0)\nunsigned 8 3(3) << 115(73) = 0(0)\nunsigned 8 3(3) << 116(74) = 0(0)\nunsigned 8 3(3) << 117(75) = 0(0)\nunsigned 8 3(3) << 118(76) = 0(0)\nunsigned 8 3(3) << 119(77) = 0(0)\nunsigned 8 3(3) << 120(78) = 0(0)\nunsigned 8 3(3) << 121(79) = 0(0)\nunsigned 8 3(3) << 122(7a) = 0(0)\nunsigned 8 3(3) << 123(7b) = 0(0)\nunsigned 8 3(3) << 124(7c) = 0(0)\nunsigned 8 3(3) << 125(7d) = 0(0)\nunsigned 8 3(3) << 126(7e) = 0(0)\nunsigned 8 3(3) << 127(7f) = 0(0)\nunsigned 8 4(4) << -128(ffffff80) = 4(4)\nunsigned 8 4(4) << -127(ffffff81) = 8(8)\nunsigned 8 4(4) << -126(ffffff82) = 16(10)\nunsigned 8 4(4) << -125(ffffff83) = 32(20)\nunsigned 8 4(4) << -124(ffffff84) = 64(40)\nunsigned 8 4(4) << -123(ffffff85) = 128(80)\nunsigned 8 4(4) << -122(ffffff86) = 256(100)\nunsigned 8 4(4) << -121(ffffff87) = 512(200)\nunsigned 8 4(4) << -120(ffffff88) = 1024(400)\nunsigned 8 4(4) << -119(ffffff89) = 2048(800)\nunsigned 8 4(4) << -118(ffffff8a) = 4096(1000)\nunsigned 8 4(4) << -117(ffffff8b) = 8192(2000)\nunsigned 8 4(4) << -116(ffffff8c) = 16384(4000)\nunsigned 8 4(4) << -115(ffffff8d) = 32768(8000)\nunsigned 8 4(4) << -114(ffffff8e) = 65536(10000)\nunsigned 8 4(4) << -113(ffffff8f) = 131072(20000)\nunsigned 8 4(4) << -112(ffffff90) = 262144(40000)\nunsigned 8 4(4) << -111(ffffff91) = 524288(80000)\nunsigned 8 4(4) << -110(ffffff92) = 1048576(100000)\nunsigned 8 4(4) << -109(ffffff93) = 2097152(200000)\nunsigned 8 4(4) << -108(ffffff94) = 4194304(400000)\nunsigned 8 4(4) << -107(ffffff95) = 8388608(800000)\nunsigned 8 4(4) << -106(ffffff96) = 16777216(1000000)\nunsigned 8 4(4) << -105(ffffff97) = 33554432(2000000)\nunsigned 8 4(4) << -104(ffffff98) = 67108864(4000000)\nunsigned 8 4(4) << -103(ffffff99) = 134217728(8000000)\nunsigned 8 4(4) << -102(ffffff9a) = 268435456(10000000)\nunsigned 8 4(4) << -101(ffffff9b) = 536870912(20000000)\nunsigned 8 4(4) << -100(ffffff9c) = 1073741824(40000000)\nunsigned 8 4(4) << -99(ffffff9d) = 2147483648(80000000)\nunsigned 8 4(4) << -98(ffffff9e) = 0(0)\nunsigned 8 4(4) << -97(ffffff9f) = 0(0)\nunsigned 8 4(4) << -96(ffffffa0) = 0(0)\nunsigned 8 4(4) << -95(ffffffa1) = 0(0)\nunsigned 8 4(4) << -94(ffffffa2) = 0(0)\nunsigned 8 4(4) << -93(ffffffa3) = 0(0)\nunsigned 8 4(4) << -92(ffffffa4) = 0(0)\nunsigned 8 4(4) << -91(ffffffa5) = 0(0)\nunsigned 8 4(4) << -90(ffffffa6) = 0(0)\nunsigned 8 4(4) << -89(ffffffa7) = 0(0)\nunsigned 8 4(4) << -88(ffffffa8) = 0(0)\nunsigned 8 4(4) << -87(ffffffa9) = 0(0)\nunsigned 8 4(4) << -86(ffffffaa) = 0(0)\nunsigned 8 4(4) << -85(ffffffab) = 0(0)\nunsigned 8 4(4) << -84(ffffffac) = 0(0)\nunsigned 8 4(4) << -83(ffffffad) = 0(0)\nunsigned 8 4(4) << -82(ffffffae) = 0(0)\nunsigned 8 4(4) << -81(ffffffaf) = 0(0)\nunsigned 8 4(4) << -80(ffffffb0) = 0(0)\nunsigned 8 4(4) << -79(ffffffb1) = 0(0)\nunsigned 8 4(4) << -78(ffffffb2) = 0(0)\nunsigned 8 4(4) << -77(ffffffb3) = 0(0)\nunsigned 8 4(4) << -76(ffffffb4) = 0(0)\nunsigned 8 4(4) << -75(ffffffb5) = 0(0)\nunsigned 8 4(4) << -74(ffffffb6) = 0(0)\nunsigned 8 4(4) << -73(ffffffb7) = 0(0)\nunsigned 8 4(4) << -72(ffffffb8) = 0(0)\nunsigned 8 4(4) << -71(ffffffb9) = 0(0)\nunsigned 8 4(4) << -70(ffffffba) = 0(0)\nunsigned 8 4(4) << -69(ffffffbb) = 0(0)\nunsigned 8 4(4) << -68(ffffffbc) = 0(0)\nunsigned 8 4(4) << -67(ffffffbd) = 0(0)\nunsigned 8 4(4) << -66(ffffffbe) = 0(0)\nunsigned 8 4(4) << -65(ffffffbf) = 0(0)\nunsigned 8 4(4) << -64(ffffffc0) = 4(4)\nunsigned 8 4(4) << -63(ffffffc1) = 8(8)\nunsigned 8 4(4) << -62(ffffffc2) = 16(10)\nunsigned 8 4(4) << -61(ffffffc3) = 32(20)\nunsigned 8 4(4) << -60(ffffffc4) = 64(40)\nunsigned 8 4(4) << -59(ffffffc5) = 128(80)\nunsigned 8 4(4) << -58(ffffffc6) = 256(100)\nunsigned 8 4(4) << -57(ffffffc7) = 512(200)\nunsigned 8 4(4) << -56(ffffffc8) = 1024(400)\nunsigned 8 4(4) << -55(ffffffc9) = 2048(800)\nunsigned 8 4(4) << -54(ffffffca) = 4096(1000)\nunsigned 8 4(4) << -53(ffffffcb) = 8192(2000)\nunsigned 8 4(4) << -52(ffffffcc) = 16384(4000)\nunsigned 8 4(4) << -51(ffffffcd) = 32768(8000)\nunsigned 8 4(4) << -50(ffffffce) = 65536(10000)\nunsigned 8 4(4) << -49(ffffffcf) = 131072(20000)\nunsigned 8 4(4) << -48(ffffffd0) = 262144(40000)\nunsigned 8 4(4) << -47(ffffffd1) = 524288(80000)\nunsigned 8 4(4) << -46(ffffffd2) = 1048576(100000)\nunsigned 8 4(4) << -45(ffffffd3) = 2097152(200000)\nunsigned 8 4(4) << -44(ffffffd4) = 4194304(400000)\nunsigned 8 4(4) << -43(ffffffd5) = 8388608(800000)\nunsigned 8 4(4) << -42(ffffffd6) = 16777216(1000000)\nunsigned 8 4(4) << -41(ffffffd7) = 33554432(2000000)\nunsigned 8 4(4) << -40(ffffffd8) = 67108864(4000000)\nunsigned 8 4(4) << -39(ffffffd9) = 134217728(8000000)\nunsigned 8 4(4) << -38(ffffffda) = 268435456(10000000)\nunsigned 8 4(4) << -37(ffffffdb) = 536870912(20000000)\nunsigned 8 4(4) << -36(ffffffdc) = 1073741824(40000000)\nunsigned 8 4(4) << -35(ffffffdd) = 2147483648(80000000)\nunsigned 8 4(4) << -34(ffffffde) = 0(0)\nunsigned 8 4(4) << -33(ffffffdf) = 0(0)\nunsigned 8 4(4) << -32(ffffffe0) = 0(0)\nunsigned 8 4(4) << -31(ffffffe1) = 0(0)\nunsigned 8 4(4) << -30(ffffffe2) = 0(0)\nunsigned 8 4(4) << -29(ffffffe3) = 0(0)\nunsigned 8 4(4) << -28(ffffffe4) = 0(0)\nunsigned 8 4(4) << -27(ffffffe5) = 0(0)\nunsigned 8 4(4) << -26(ffffffe6) = 0(0)\nunsigned 8 4(4) << -25(ffffffe7) = 0(0)\nunsigned 8 4(4) << -24(ffffffe8) = 0(0)\nunsigned 8 4(4) << -23(ffffffe9) = 0(0)\nunsigned 8 4(4) << -22(ffffffea) = 0(0)\nunsigned 8 4(4) << -21(ffffffeb) = 0(0)\nunsigned 8 4(4) << -20(ffffffec) = 0(0)\nunsigned 8 4(4) << -19(ffffffed) = 0(0)\nunsigned 8 4(4) << -18(ffffffee) = 0(0)\nunsigned 8 4(4) << -17(ffffffef) = 0(0)\nunsigned 8 4(4) << -16(fffffff0) = 0(0)\nunsigned 8 4(4) << -15(fffffff1) = 0(0)\nunsigned 8 4(4) << -14(fffffff2) = 0(0)\nunsigned 8 4(4) << -13(fffffff3) = 0(0)\nunsigned 8 4(4) << -12(fffffff4) = 0(0)\nunsigned 8 4(4) << -11(fffffff5) = 0(0)\nunsigned 8 4(4) << -10(fffffff6) = 0(0)\nunsigned 8 4(4) << -9(fffffff7) = 0(0)\nunsigned 8 4(4) << -8(fffffff8) = 0(0)\nunsigned 8 4(4) << -7(fffffff9) = 0(0)\nunsigned 8 4(4) << -6(fffffffa) = 0(0)\nunsigned 8 4(4) << -5(fffffffb) = 0(0)\nunsigned 8 4(4) << -4(fffffffc) = 0(0)\nunsigned 8 4(4) << -3(fffffffd) = 0(0)\nunsigned 8 4(4) << -2(fffffffe) = 0(0)\nunsigned 8 4(4) << -1(ffffffff) = 0(0)\nunsigned 8 4(4) << 0(0) = 4(4)\nunsigned 8 4(4) << 1(1) = 8(8)\nunsigned 8 4(4) << 2(2) = 16(10)\nunsigned 8 4(4) << 3(3) = 32(20)\nunsigned 8 4(4) << 4(4) = 64(40)\nunsigned 8 4(4) << 5(5) = 128(80)\nunsigned 8 4(4) << 6(6) = 256(100)\nunsigned 8 4(4) << 7(7) = 512(200)\nunsigned 8 4(4) << 8(8) = 1024(400)\nunsigned 8 4(4) << 9(9) = 2048(800)\nunsigned 8 4(4) << 10(a) = 4096(1000)\nunsigned 8 4(4) << 11(b) = 8192(2000)\nunsigned 8 4(4) << 12(c) = 16384(4000)\nunsigned 8 4(4) << 13(d) = 32768(8000)\nunsigned 8 4(4) << 14(e) = 65536(10000)\nunsigned 8 4(4) << 15(f) = 131072(20000)\nunsigned 8 4(4) << 16(10) = 262144(40000)\nunsigned 8 4(4) << 17(11) = 524288(80000)\nunsigned 8 4(4) << 18(12) = 1048576(100000)\nunsigned 8 4(4) << 19(13) = 2097152(200000)\nunsigned 8 4(4) << 20(14) = 4194304(400000)\nunsigned 8 4(4) << 21(15) = 8388608(800000)\nunsigned 8 4(4) << 22(16) = 16777216(1000000)\nunsigned 8 4(4) << 23(17) = 33554432(2000000)\nunsigned 8 4(4) << 24(18) = 67108864(4000000)\nunsigned 8 4(4) << 25(19) = 134217728(8000000)\nunsigned 8 4(4) << 26(1a) = 268435456(10000000)\nunsigned 8 4(4) << 27(1b) = 536870912(20000000)\nunsigned 8 4(4) << 28(1c) = 1073741824(40000000)\nunsigned 8 4(4) << 29(1d) = 2147483648(80000000)\nunsigned 8 4(4) << 30(1e) = 0(0)\nunsigned 8 4(4) << 31(1f) = 0(0)\nunsigned 8 4(4) << 32(20) = 0(0)\nunsigned 8 4(4) << 33(21) = 0(0)\nunsigned 8 4(4) << 34(22) = 0(0)\nunsigned 8 4(4) << 35(23) = 0(0)\nunsigned 8 4(4) << 36(24) = 0(0)\nunsigned 8 4(4) << 37(25) = 0(0)\nunsigned 8 4(4) << 38(26) = 0(0)\nunsigned 8 4(4) << 39(27) = 0(0)\nunsigned 8 4(4) << 40(28) = 0(0)\nunsigned 8 4(4) << 41(29) = 0(0)\nunsigned 8 4(4) << 42(2a) = 0(0)\nunsigned 8 4(4) << 43(2b) = 0(0)\nunsigned 8 4(4) << 44(2c) = 0(0)\nunsigned 8 4(4) << 45(2d) = 0(0)\nunsigned 8 4(4) << 46(2e) = 0(0)\nunsigned 8 4(4) << 47(2f) = 0(0)\nunsigned 8 4(4) << 48(30) = 0(0)\nunsigned 8 4(4) << 49(31) = 0(0)\nunsigned 8 4(4) << 50(32) = 0(0)\nunsigned 8 4(4) << 51(33) = 0(0)\nunsigned 8 4(4) << 52(34) = 0(0)\nunsigned 8 4(4) << 53(35) = 0(0)\nunsigned 8 4(4) << 54(36) = 0(0)\nunsigned 8 4(4) << 55(37) = 0(0)\nunsigned 8 4(4) << 56(38) = 0(0)\nunsigned 8 4(4) << 57(39) = 0(0)\nunsigned 8 4(4) << 58(3a) = 0(0)\nunsigned 8 4(4) << 59(3b) = 0(0)\nunsigned 8 4(4) << 60(3c) = 0(0)\nunsigned 8 4(4) << 61(3d) = 0(0)\nunsigned 8 4(4) << 62(3e) = 0(0)\nunsigned 8 4(4) << 63(3f) = 0(0)\nunsigned 8 4(4) << 64(40) = 4(4)\nunsigned 8 4(4) << 65(41) = 8(8)\nunsigned 8 4(4) << 66(42) = 16(10)\nunsigned 8 4(4) << 67(43) = 32(20)\nunsigned 8 4(4) << 68(44) = 64(40)\nunsigned 8 4(4) << 69(45) = 128(80)\nunsigned 8 4(4) << 70(46) = 256(100)\nunsigned 8 4(4) << 71(47) = 512(200)\nunsigned 8 4(4) << 72(48) = 1024(400)\nunsigned 8 4(4) << 73(49) = 2048(800)\nunsigned 8 4(4) << 74(4a) = 4096(1000)\nunsigned 8 4(4) << 75(4b) = 8192(2000)\nunsigned 8 4(4) << 76(4c) = 16384(4000)\nunsigned 8 4(4) << 77(4d) = 32768(8000)\nunsigned 8 4(4) << 78(4e) = 65536(10000)\nunsigned 8 4(4) << 79(4f) = 131072(20000)\nunsigned 8 4(4) << 80(50) = 262144(40000)\nunsigned 8 4(4) << 81(51) = 524288(80000)\nunsigned 8 4(4) << 82(52) = 1048576(100000)\nunsigned 8 4(4) << 83(53) = 2097152(200000)\nunsigned 8 4(4) << 84(54) = 4194304(400000)\nunsigned 8 4(4) << 85(55) = 8388608(800000)\nunsigned 8 4(4) << 86(56) = 16777216(1000000)\nunsigned 8 4(4) << 87(57) = 33554432(2000000)\nunsigned 8 4(4) << 88(58) = 67108864(4000000)\nunsigned 8 4(4) << 89(59) = 134217728(8000000)\nunsigned 8 4(4) << 90(5a) = 268435456(10000000)\nunsigned 8 4(4) << 91(5b) = 536870912(20000000)\nunsigned 8 4(4) << 92(5c) = 1073741824(40000000)\nunsigned 8 4(4) << 93(5d) = 2147483648(80000000)\nunsigned 8 4(4) << 94(5e) = 0(0)\nunsigned 8 4(4) << 95(5f) = 0(0)\nunsigned 8 4(4) << 96(60) = 0(0)\nunsigned 8 4(4) << 97(61) = 0(0)\nunsigned 8 4(4) << 98(62) = 0(0)\nunsigned 8 4(4) << 99(63) = 0(0)\nunsigned 8 4(4) << 100(64) = 0(0)\nunsigned 8 4(4) << 101(65) = 0(0)\nunsigned 8 4(4) << 102(66) = 0(0)\nunsigned 8 4(4) << 103(67) = 0(0)\nunsigned 8 4(4) << 104(68) = 0(0)\nunsigned 8 4(4) << 105(69) = 0(0)\nunsigned 8 4(4) << 106(6a) = 0(0)\nunsigned 8 4(4) << 107(6b) = 0(0)\nunsigned 8 4(4) << 108(6c) = 0(0)\nunsigned 8 4(4) << 109(6d) = 0(0)\nunsigned 8 4(4) << 110(6e) = 0(0)\nunsigned 8 4(4) << 111(6f) = 0(0)\nunsigned 8 4(4) << 112(70) = 0(0)\nunsigned 8 4(4) << 113(71) = 0(0)\nunsigned 8 4(4) << 114(72) = 0(0)\nunsigned 8 4(4) << 115(73) = 0(0)\nunsigned 8 4(4) << 116(74) = 0(0)\nunsigned 8 4(4) << 117(75) = 0(0)\nunsigned 8 4(4) << 118(76) = 0(0)\nunsigned 8 4(4) << 119(77) = 0(0)\nunsigned 8 4(4) << 120(78) = 0(0)\nunsigned 8 4(4) << 121(79) = 0(0)\nunsigned 8 4(4) << 122(7a) = 0(0)\nunsigned 8 4(4) << 123(7b) = 0(0)\nunsigned 8 4(4) << 124(7c) = 0(0)\nunsigned 8 4(4) << 125(7d) = 0(0)\nunsigned 8 4(4) << 126(7e) = 0(0)\nunsigned 8 4(4) << 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\n  signed 8 5(5) >> -128(ffffff80) = 5(5)\n  signed 8 5(5) >> -127(ffffff81) = 2(2)\n  signed 8 5(5) >> -126(ffffff82) = 1(1)\n  signed 8 5(5) >> -125(ffffff83) = 0(0)\n  signed 8 5(5) >> -124(ffffff84) = 0(0)\n  signed 8 5(5) >> -123(ffffff85) = 0(0)\n  signed 8 5(5) >> -122(ffffff86) = 0(0)\n  signed 8 5(5) >> -121(ffffff87) = 0(0)\n  signed 8 5(5) >> -120(ffffff88) = 0(0)\n  signed 8 5(5) >> -119(ffffff89) = 0(0)\n  signed 8 5(5) >> -118(ffffff8a) = 0(0)\n  signed 8 5(5) >> -117(ffffff8b) = 0(0)\n  signed 8 5(5) >> -116(ffffff8c) = 0(0)\n  signed 8 5(5) >> -115(ffffff8d) = 0(0)\n  signed 8 5(5) >> -114(ffffff8e) = 0(0)\n  signed 8 5(5) >> -113(ffffff8f) = 0(0)\n  signed 8 5(5) >> -112(ffffff90) = 0(0)\n  signed 8 5(5) >> -111(ffffff91) = 0(0)\n  signed 8 5(5) >> -110(ffffff92) = 0(0)\n  signed 8 5(5) >> -109(ffffff93) = 0(0)\n  signed 8 5(5) >> -108(ffffff94) = 0(0)\n  signed 8 5(5) >> -107(ffffff95) = 0(0)\n  signed 8 5(5) >> -106(ffffff96) = 0(0)\n  signed 8 5(5) >> -105(ffffff97) = 0(0)\n  signed 8 5(5) >> -104(ffffff98) = 0(0)\n  signed 8 5(5) >> -103(ffffff99) = 0(0)\n  signed 8 5(5) >> -102(ffffff9a) = 0(0)\n  signed 8 5(5) >> -101(ffffff9b) = 0(0)\n  signed 8 5(5) >> -100(ffffff9c) = 0(0)\n  signed 8 5(5) >> -99(ffffff9d) = 0(0)\n  signed 8 5(5) >> -98(ffffff9e) = 0(0)\n  signed 8 5(5) >> -97(ffffff9f) = 0(0)\n  signed 8 5(5) >> -96(ffffffa0) = 5(5)\n  signed 8 5(5) >> -95(ffffffa1) = 2(2)\n  signed 8 5(5) >> -94(ffffffa2) = 1(1)\n  signed 8 5(5) >> -93(ffffffa3) = 0(0)\n  signed 8 5(5) >> -92(ffffffa4) = 0(0)\n  signed 8 5(5) >> -91(ffffffa5) = 0(0)\n  signed 8 5(5) >> -90(ffffffa6) = 0(0)\n  signed 8 5(5) >> -89(ffffffa7) = 0(0)\n  signed 8 5(5) >> -88(ffffffa8) = 0(0)\n  signed 8 5(5) >> -87(ffffffa9) = 0(0)\n  signed 8 5(5) >> -86(ffffffaa) = 0(0)\n  signed 8 5(5) >> -85(ffffffab) = 0(0)\n  signed 8 5(5) >> -84(ffffffac) = 0(0)\n  signed 8 5(5) >> -83(ffffffad) = 0(0)\n  signed 8 5(5) >> -82(ffffffae) = 0(0)\n  signed 8 5(5) >> -81(ffffffaf) = 0(0)\n  signed 8 5(5) >> -80(ffffffb0) = 0(0)\n  signed 8 5(5) >> -79(ffffffb1) = 0(0)\n  signed 8 5(5) >> -78(ffffffb2) = 0(0)\n  signed 8 5(5) >> -77(ffffffb3) = 0(0)\n  signed 8 5(5) >> -76(ffffffb4) = 0(0)\n  signed 8 5(5) >> -75(ffffffb5) = 0(0)\n  signed 8 5(5) >> -74(ffffffb6) = 0(0)\n  signed 8 5(5) >> -73(ffffffb7) = 0(0)\n  signed 8 5(5) >> -72(ffffffb8) = 0(0)\n  signed 8 5(5) >> -71(ffffffb9) = 0(0)\n  signed 8 5(5) >> -70(ffffffba) = 0(0)\n  signed 8 5(5) >> -69(ffffffbb) = 0(0)\n  signed 8 5(5) >> -68(ffffffbc) = 0(0)\n  signed 8 5(5) >> -67(ffffffbd) = 0(0)\n  signed 8 5(5) >> -66(ffffffbe) = 0(0)\n  signed 8 5(5) >> -65(ffffffbf) = 0(0)\n  signed 8 5(5) >> -64(ffffffc0) = 5(5)\n  signed 8 5(5) >> -63(ffffffc1) = 2(2)\n  signed 8 5(5) >> -62(ffffffc2) = 1(1)\n  signed 8 5(5) >> -61(ffffffc3) = 0(0)\n  signed 8 5(5) >> -60(ffffffc4) = 0(0)\n  signed 8 5(5) >> -59(ffffffc5) = 0(0)\n  signed 8 5(5) >> -58(ffffffc6) = 0(0)\n  signed 8 5(5) >> -57(ffffffc7) = 0(0)\n  signed 8 5(5) >> -56(ffffffc8) = 0(0)\n  signed 8 5(5) >> -55(ffffffc9) = 0(0)\n  signed 8 5(5) >> -54(ffffffca) = 0(0)\n  signed 8 5(5) >> -53(ffffffcb) = 0(0)\n  signed 8 5(5) >> -52(ffffffcc) = 0(0)\n  signed 8 5(5) >> -51(ffffffcd) = 0(0)\n  signed 8 5(5) >> -50(ffffffce) = 0(0)\n  signed 8 5(5) >> -49(ffffffcf) = 0(0)\n  signed 8 5(5) >> -48(ffffffd0) = 0(0)\n  signed 8 5(5) >> -47(ffffffd1) = 0(0)\n  signed 8 5(5) >> -46(ffffffd2) = 0(0)\n  signed 8 5(5) >> -45(ffffffd3) = 0(0)\n  signed 8 5(5) >> -44(ffffffd4) = 0(0)\n  signed 8 5(5) >> -43(ffffffd5) = 0(0)\n  signed 8 5(5) >> -42(ffffffd6) = 0(0)\n  signed 8 5(5) >> -41(ffffffd7) = 0(0)\n  signed 8 5(5) >> -40(ffffffd8) = 0(0)\n  signed 8 5(5) >> -39(ffffffd9) = 0(0)\n  signed 8 5(5) >> -38(ffffffda) = 0(0)\n  signed 8 5(5) >> -37(ffffffdb) = 0(0)\n  signed 8 5(5) >> -36(ffffffdc) = 0(0)\n  signed 8 5(5) >> -35(ffffffdd) = 0(0)\n  signed 8 5(5) >> -34(ffffffde) = 0(0)\n  signed 8 5(5) >> -33(ffffffdf) = 0(0)\n  signed 8 5(5) >> -32(ffffffe0) = 5(5)\n  signed 8 5(5) >> -31(ffffffe1) = 2(2)\n  signed 8 5(5) >> -30(ffffffe2) = 1(1)\n  signed 8 5(5) >> -29(ffffffe3) = 0(0)\n  signed 8 5(5) >> -28(ffffffe4) = 0(0)\n  signed 8 5(5) >> -27(ffffffe5) = 0(0)\n  signed 8 5(5) >> -26(ffffffe6) = 0(0)\n  signed 8 5(5) >> -25(ffffffe7) = 0(0)\n  signed 8 5(5) >> -24(ffffffe8) = 0(0)\n  signed 8 5(5) >> -23(ffffffe9) = 0(0)\n  signed 8 5(5) >> -22(ffffffea) = 0(0)\n  signed 8 5(5) >> -21(ffffffeb) = 0(0)\n  signed 8 5(5) >> -20(ffffffec) = 0(0)\n  signed 8 5(5) >> -19(ffffffed) = 0(0)\n  signed 8 5(5) >> -18(ffffffee) = 0(0)\n  signed 8 5(5) >> -17(ffffffef) = 0(0)\n  signed 8 5(5) >> -16(fffffff0) = 0(0)\n  signed 8 5(5) >> -15(fffffff1) = 0(0)\n  signed 8 5(5) >> -14(fffffff2) = 0(0)\n  signed 8 5(5) >> -13(fffffff3) = 0(0)\n  signed 8 5(5) >> -12(fffffff4) = 0(0)\n  signed 8 5(5) >> -11(fffffff5) = 0(0)\n  signed 8 5(5) >> -10(fffffff6) = 0(0)\n  signed 8 5(5) >> -9(fffffff7) = 0(0)\n  signed 8 5(5) >> -8(fffffff8) = 0(0)\n  signed 8 5(5) >> -7(fffffff9) = 0(0)\n  signed 8 5(5) >> -6(fffffffa) = 0(0)\n  signed 8 5(5) >> -5(fffffffb) = 0(0)\n  signed 8 5(5) >> -4(fffffffc) = 0(0)\n  signed 8 5(5) >> -3(fffffffd) = 0(0)\n  signed 8 5(5) >> -2(fffffffe) = 0(0)\n  signed 8 5(5) >> -1(ffffffff) = 0(0)\n  signed 8 5(5) >> 0(0) = 5(5)\n  signed 8 5(5) >> 1(1) = 2(2)\n  signed 8 5(5) >> 2(2) = 1(1)\n  signed 8 5(5) >> 3(3) = 0(0)\n  signed 8 5(5) >> 4(4) = 0(0)\n  signed 8 5(5) >> 5(5) = 0(0)\n  signed 8 5(5) >> 6(6) = 0(0)\n  signed 8 5(5) >> 7(7) = 0(0)\n  signed 8 5(5) >> 8(8) = 0(0)\n  signed 8 5(5) >> 9(9) = 0(0)\n  signed 8 5(5) >> 10(a) = 0(0)\n  signed 8 5(5) >> 11(b) = 0(0)\n  signed 8 5(5) >> 12(c) = 0(0)\n  signed 8 5(5) >> 13(d) = 0(0)\n  signed 8 5(5) >> 14(e) = 0(0)\n  signed 8 5(5) >> 15(f) = 0(0)\n  signed 8 5(5) >> 16(10) = 0(0)\n  signed 8 5(5) >> 17(11) = 0(0)\n  signed 8 5(5) >> 18(12) = 0(0)\n  signed 8 5(5) >> 19(13) = 0(0)\n  signed 8 5(5) >> 20(14) = 0(0)\n  signed 8 5(5) >> 21(15) = 0(0)\n  signed 8 5(5) >> 22(16) = 0(0)\n  signed 8 5(5) >> 23(17) = 0(0)\n  signed 8 5(5) >> 24(18) = 0(0)\n  signed 8 5(5) >> 25(19) = 0(0)\n  signed 8 5(5) >> 26(1a) = 0(0)\n  signed 8 5(5) >> 27(1b) = 0(0)\n  signed 8 5(5) >> 28(1c) = 0(0)\n  signed 8 5(5) >> 29(1d) = 0(0)\n  signed 8 5(5) >> 30(1e) = 0(0)\n  signed 8 5(5) >> 31(1f) = 0(0)\n  signed 8 5(5) >> 32(20) = 5(5)\n  signed 8 5(5) >> 33(21) = 2(2)\n  signed 8 5(5) >> 34(22) = 1(1)\n  signed 8 5(5) >> 35(23) = 0(0)\n  signed 8 5(5) >> 36(24) = 0(0)\n  signed 8 5(5) >> 37(25) = 0(0)\n  signed 8 5(5) >> 38(26) = 0(0)\n  signed 8 5(5) >> 39(27) = 0(0)\n  signed 8 5(5) >> 40(28) = 0(0)\n  signed 8 5(5) >> 41(29) = 0(0)\n  signed 8 5(5) >> 42(2a) = 0(0)\n  signed 8 5(5) >> 43(2b) = 0(0)\n  signed 8 5(5) >> 44(2c) = 0(0)\n  signed 8 5(5) >> 45(2d) = 0(0)\n  signed 8 5(5) >> 46(2e) = 0(0)\n  signed 8 5(5) >> 47(2f) = 0(0)\n  signed 8 5(5) >> 48(30) = 0(0)\n  signed 8 5(5) >> 49(31) = 0(0)\n  signed 8 5(5) >> 50(32) = 0(0)\n  signed 8 5(5) >> 51(33) = 0(0)\n  signed 8 5(5) >> 52(34) = 0(0)\n  signed 8 5(5) >> 53(35) = 0(0)\n  signed 8 5(5) >> 54(36) = 0(0)\n  signed 8 5(5) >> 55(37) = 0(0)\n  signed 8 5(5) >> 56(38) = 0(0)\n  signed 8 5(5) >> 57(39) = 0(0)\n  signed 8 5(5) >> 58(3a) = 0(0)\n  signed 8 5(5) >> 59(3b) = 0(0)\n  signed 8 5(5) >> 60(3c) = 0(0)\n  signed 8 5(5) >> 61(3d) = 0(0)\n  signed 8 5(5) >> 62(3e) = 0(0)\n  signed 8 5(5) >> 63(3f) = 0(0)\n  signed 8 5(5) >> 64(40) = 5(5)\n  signed 8 5(5) >> 65(41) = 2(2)\n  signed 8 5(5) >> 66(42) = 1(1)\n  signed 8 5(5) >> 67(43) = 0(0)\n  signed 8 5(5) >> 68(44) = 0(0)\n  signed 8 5(5) >> 69(45) = 0(0)\n  signed 8 5(5) >> 70(46) = 0(0)\n  signed 8 5(5) >> 71(47) = 0(0)\n  signed 8 5(5) >> 72(48) = 0(0)\n  signed 8 5(5) >> 73(49) = 0(0)\n  signed 8 5(5) >> 74(4a) = 0(0)\n  signed 8 5(5) >> 75(4b) = 0(0)\n  signed 8 5(5) >> 76(4c) = 0(0)\n  signed 8 5(5) >> 77(4d) = 0(0)\n  signed 8 5(5) >> 78(4e) = 0(0)\n  signed 8 5(5) >> 79(4f) = 0(0)\n  signed 8 5(5) >> 80(50) = 0(0)\n  signed 8 5(5) >> 81(51) = 0(0)\n  signed 8 5(5) >> 82(52) = 0(0)\n  signed 8 5(5) >> 83(53) = 0(0)\n  signed 8 5(5) >> 84(54) = 0(0)\n  signed 8 5(5) >> 85(55) = 0(0)\n  signed 8 5(5) >> 86(56) = 0(0)\n  signed 8 5(5) >> 87(57) = 0(0)\n  signed 8 5(5) >> 88(58) = 0(0)\n  signed 8 5(5) >> 89(59) = 0(0)\n  signed 8 5(5) >> 90(5a) = 0(0)\n  signed 8 5(5) >> 91(5b) = 0(0)\n  signed 8 5(5) >> 92(5c) = 0(0)\n  signed 8 5(5) >> 93(5d) = 0(0)\n  signed 8 5(5) >> 94(5e) = 0(0)\n  signed 8 5(5) >> 95(5f) = 0(0)\n  signed 8 5(5) >> 96(60) = 5(5)\n  signed 8 5(5) >> 97(61) = 2(2)\n  signed 8 5(5) >> 98(62) = 1(1)\n  signed 8 5(5) >> 99(63) = 0(0)\n  signed 8 5(5) >> 100(64) = 0(0)\n  signed 8 5(5) >> 101(65) = 0(0)\n  signed 8 5(5) >> 102(66) = 0(0)\n  signed 8 5(5) >> 103(67) = 0(0)\n  signed 8 5(5) >> 104(68) = 0(0)\n  signed 8 5(5) >> 105(69) = 0(0)\n  signed 8 5(5) >> 106(6a) = 0(0)\n  signed 8 5(5) >> 107(6b) = 0(0)\n  signed 8 5(5) >> 108(6c) = 0(0)\n  signed 8 5(5) >> 109(6d) = 0(0)\n  signed 8 5(5) >> 110(6e) = 0(0)\n  signed 8 5(5) >> 111(6f) = 0(0)\n  signed 8 5(5) >> 112(70) = 0(0)\n  signed 8 5(5) >> 113(71) = 0(0)\n  signed 8 5(5) >> 114(72) = 0(0)\n  signed 8 5(5) >> 115(73) = 0(0)\n  signed 8 5(5) >> 116(74) = 0(0)\n  signed 8 5(5) >> 117(75) = 0(0)\n  signed 8 5(5) >> 118(76) = 0(0)\n  signed 8 5(5) >> 119(77) = 0(0)\n  signed 8 5(5) >> 120(78) = 0(0)\n  signed 8 5(5) >> 121(79) = 0(0)\n  signed 8 5(5) >> 122(7a) = 0(0)\n  signed 8 5(5) >> 123(7b) = 0(0)\n  signed 8 5(5) >> 124(7c) = 0(0)\n  signed 8 5(5) >> 125(7d) = 0(0)\n  signed 8 5(5) >> 126(7e) = 0(0)\n  signed 8 5(5) >> 127(7f) = 0(0)\nunsigned 8 0(0) >> -128(ffffff80) = 0(0)\nunsigned 8 0(0) >> -127(ffffff81) = 0(0)\nunsigned 8 0(0) >> -126(ffffff82) = 0(0)\nunsigned 8 0(0) >> -125(ffffff83) = 0(0)\nunsigned 8 0(0) >> -124(ffffff84) = 0(0)\nunsigned 8 0(0) >> -123(ffffff85) = 0(0)\nunsigned 8 0(0) >> -122(ffffff86) = 0(0)\nunsigned 8 0(0) >> -121(ffffff87) = 0(0)\nunsigned 8 0(0) >> -120(ffffff88) = 0(0)\nunsigned 8 0(0) >> -119(ffffff89) = 0(0)\nunsigned 8 0(0) >> -118(ffffff8a) = 0(0)\nunsigned 8 0(0) >> -117(ffffff8b) = 0(0)\nunsigned 8 0(0) >> -116(ffffff8c) = 0(0)\nunsigned 8 0(0) >> -115(ffffff8d) = 0(0)\nunsigned 8 0(0) >> -114(ffffff8e) = 0(0)\nunsigned 8 0(0) >> -113(ffffff8f) = 0(0)\nunsigned 8 0(0) >> -112(ffffff90) = 0(0)\nunsigned 8 0(0) >> -111(ffffff91) = 0(0)\nunsigned 8 0(0) >> -110(ffffff92) = 0(0)\nunsigned 8 0(0) >> -109(ffffff93) = 0(0)\nunsigned 8 0(0) >> -108(ffffff94) = 0(0)\nunsigned 8 0(0) >> -107(ffffff95) = 0(0)\nunsigned 8 0(0) >> -106(ffffff96) = 0(0)\nunsigned 8 0(0) >> -105(ffffff97) = 0(0)\nunsigned 8 0(0) >> -104(ffffff98) = 0(0)\nunsigned 8 0(0) >> -103(ffffff99) = 0(0)\nunsigned 8 0(0) >> -102(ffffff9a) = 0(0)\nunsigned 8 0(0) >> -101(ffffff9b) = 0(0)\nunsigned 8 0(0) >> -100(ffffff9c) = 0(0)\nunsigned 8 0(0) >> -99(ffffff9d) = 0(0)\nunsigned 8 0(0) >> -98(ffffff9e) = 0(0)\nunsigned 8 0(0) >> -97(ffffff9f) = 0(0)\nunsigned 8 0(0) >> -96(ffffffa0) = 0(0)\nunsigned 8 0(0) >> -95(ffffffa1) = 0(0)\nunsigned 8 0(0) >> -94(ffffffa2) = 0(0)\nunsigned 8 0(0) >> -93(ffffffa3) = 0(0)\nunsigned 8 0(0) >> -92(ffffffa4) = 0(0)\nunsigned 8 0(0) >> -91(ffffffa5) = 0(0)\nunsigned 8 0(0) >> -90(ffffffa6) = 0(0)\nunsigned 8 0(0) >> -89(ffffffa7) = 0(0)\nunsigned 8 0(0) >> -88(ffffffa8) = 0(0)\nunsigned 8 0(0) >> -87(ffffffa9) = 0(0)\nunsigned 8 0(0) >> -86(ffffffaa) = 0(0)\nunsigned 8 0(0) >> -85(ffffffab) = 0(0)\nunsigned 8 0(0) >> -84(ffffffac) = 0(0)\nunsigned 8 0(0) >> -83(ffffffad) = 0(0)\nunsigned 8 0(0) >> -82(ffffffae) = 0(0)\nunsigned 8 0(0) >> -81(ffffffaf) = 0(0)\nunsigned 8 0(0) >> -80(ffffffb0) = 0(0)\nunsigned 8 0(0) >> -79(ffffffb1) = 0(0)\nunsigned 8 0(0) >> -78(ffffffb2) = 0(0)\nunsigned 8 0(0) >> -77(ffffffb3) = 0(0)\nunsigned 8 0(0) >> -76(ffffffb4) = 0(0)\nunsigned 8 0(0) >> -75(ffffffb5) = 0(0)\nunsigned 8 0(0) >> -74(ffffffb6) = 0(0)\nunsigned 8 0(0) >> -73(ffffffb7) = 0(0)\nunsigned 8 0(0) >> -72(ffffffb8) = 0(0)\nunsigned 8 0(0) >> -71(ffffffb9) = 0(0)\nunsigned 8 0(0) >> -70(ffffffba) = 0(0)\nunsigned 8 0(0) >> -69(ffffffbb) = 0(0)\nunsigned 8 0(0) >> -68(ffffffbc) = 0(0)\nunsigned 8 0(0) >> -67(ffffffbd) = 0(0)\nunsigned 8 0(0) >> -66(ffffffbe) = 0(0)\nunsigned 8 0(0) >> -65(ffffffbf) = 0(0)\nunsigned 8 0(0) >> -64(ffffffc0) = 0(0)\nunsigned 8 0(0) >> -63(ffffffc1) = 0(0)\nunsigned 8 0(0) >> -62(ffffffc2) = 0(0)\nunsigned 8 0(0) >> -61(ffffffc3) = 0(0)\nunsigned 8 0(0) >> -60(ffffffc4) = 0(0)\nunsigned 8 0(0) >> -59(ffffffc5) = 0(0)\nunsigned 8 0(0) >> -58(ffffffc6) = 0(0)\nunsigned 8 0(0) >> -57(ffffffc7) = 0(0)\nunsigned 8 0(0) >> -56(ffffffc8) = 0(0)\nunsigned 8 0(0) >> -55(ffffffc9) = 0(0)\nunsigned 8 0(0) >> -54(ffffffca) = 0(0)\nunsigned 8 0(0) >> -53(ffffffcb) = 0(0)\nunsigned 8 0(0) >> -52(ffffffcc) = 0(0)\nunsigned 8 0(0) >> -51(ffffffcd) = 0(0)\nunsigned 8 0(0) >> -50(ffffffce) = 0(0)\nunsigned 8 0(0) >> -49(ffffffcf) = 0(0)\nunsigned 8 0(0) >> -48(ffffffd0) = 0(0)\nunsigned 8 0(0) >> -47(ffffffd1) = 0(0)\nunsigned 8 0(0) >> -46(ffffffd2) = 0(0)\nunsigned 8 0(0) >> -45(ffffffd3) = 0(0)\nunsigned 8 0(0) >> -44(ffffffd4) = 0(0)\nunsigned 8 0(0) >> -43(ffffffd5) = 0(0)\nunsigned 8 0(0) >> -42(ffffffd6) = 0(0)\nunsigned 8 0(0) >> -41(ffffffd7) = 0(0)\nunsigned 8 0(0) >> -40(ffffffd8) = 0(0)\nunsigned 8 0(0) >> -39(ffffffd9) = 0(0)\nunsigned 8 0(0) >> -38(ffffffda) = 0(0)\nunsigned 8 0(0) >> -37(ffffffdb) = 0(0)\nunsigned 8 0(0) >> -36(ffffffdc) = 0(0)\nunsigned 8 0(0) >> -35(ffffffdd) = 0(0)\nunsigned 8 0(0) >> -34(ffffffde) = 0(0)\nunsigned 8 0(0) >> -33(ffffffdf) = 0(0)\nunsigned 8 0(0) >> -32(ffffffe0) = 0(0)\nunsigned 8 0(0) >> -31(ffffffe1) = 0(0)\nunsigned 8 0(0) >> -30(ffffffe2) = 0(0)\nunsigned 8 0(0) >> -29(ffffffe3) = 0(0)\nunsigned 8 0(0) >> -28(ffffffe4) = 0(0)\nunsigned 8 0(0) >> -27(ffffffe5) = 0(0)\nunsigned 8 0(0) >> -26(ffffffe6) = 0(0)\nunsigned 8 0(0) >> -25(ffffffe7) = 0(0)\nunsigned 8 0(0) >> -24(ffffffe8) = 0(0)\nunsigned 8 0(0) >> -23(ffffffe9) = 0(0)\nunsigned 8 0(0) >> -22(ffffffea) = 0(0)\nunsigned 8 0(0) >> -21(ffffffeb) = 0(0)\nunsigned 8 0(0) >> -20(ffffffec) = 0(0)\nunsigned 8 0(0) >> -19(ffffffed) = 0(0)\nunsigned 8 0(0) >> -18(ffffffee) = 0(0)\nunsigned 8 0(0) >> -17(ffffffef) = 0(0)\nunsigned 8 0(0) >> -16(fffffff0) = 0(0)\nunsigned 8 0(0) >> -15(fffffff1) = 0(0)\nunsigned 8 0(0) >> -14(fffffff2) = 0(0)\nunsigned 8 0(0) >> -13(fffffff3) = 0(0)\nunsigned 8 0(0) >> -12(fffffff4) = 0(0)\nunsigned 8 0(0) >> -11(fffffff5) = 0(0)\nunsigned 8 0(0) >> -10(fffffff6) = 0(0)\nunsigned 8 0(0) >> -9(fffffff7) = 0(0)\nunsigned 8 0(0) >> -8(fffffff8) = 0(0)\nunsigned 8 0(0) >> -7(fffffff9) = 0(0)\nunsigned 8 0(0) >> -6(fffffffa) = 0(0)\nunsigned 8 0(0) >> -5(fffffffb) = 0(0)\nunsigned 8 0(0) >> -4(fffffffc) = 0(0)\nunsigned 8 0(0) >> -3(fffffffd) = 0(0)\nunsigned 8 0(0) >> -2(fffffffe) = 0(0)\nunsigned 8 0(0) >> -1(ffffffff) = 0(0)\nunsigned 8 0(0) >> 0(0) = 0(0)\nunsigned 8 0(0) >> 1(1) = 0(0)\nunsigned 8 0(0) >> 2(2) = 0(0)\nunsigned 8 0(0) >> 3(3) = 0(0)\nunsigned 8 0(0) >> 4(4) = 0(0)\nunsigned 8 0(0) >> 5(5) = 0(0)\nunsigned 8 0(0) >> 6(6) = 0(0)\nunsigned 8 0(0) >> 7(7) = 0(0)\nunsigned 8 0(0) >> 8(8) = 0(0)\nunsigned 8 0(0) >> 9(9) = 0(0)\nunsigned 8 0(0) >> 10(a) = 0(0)\nunsigned 8 0(0) >> 11(b) = 0(0)\nunsigned 8 0(0) >> 12(c) = 0(0)\nunsigned 8 0(0) >> 13(d) = 0(0)\nunsigned 8 0(0) >> 14(e) = 0(0)\nunsigned 8 0(0) >> 15(f) = 0(0)\nunsigned 8 0(0) >> 16(10) = 0(0)\nunsigned 8 0(0) >> 17(11) = 0(0)\nunsigned 8 0(0) >> 18(12) = 0(0)\nunsigned 8 0(0) >> 19(13) = 0(0)\nunsigned 8 0(0) >> 20(14) = 0(0)\nunsigned 8 0(0) >> 21(15) = 0(0)\nunsigned 8 0(0) >> 22(16) = 0(0)\nunsigned 8 0(0) >> 23(17) = 0(0)\nunsigned 8 0(0) >> 24(18) = 0(0)\nunsigned 8 0(0) >> 25(19) = 0(0)\nunsigned 8 0(0) >> 26(1a) = 0(0)\nunsigned 8 0(0) >> 27(1b) = 0(0)\nunsigned 8 0(0) >> 28(1c) = 0(0)\nunsigned 8 0(0) >> 29(1d) = 0(0)\nunsigned 8 0(0) >> 30(1e) = 0(0)\nunsigned 8 0(0) >> 31(1f) = 0(0)\nunsigned 8 0(0) >> 32(20) = 0(0)\nunsigned 8 0(0) >> 33(21) = 0(0)\nunsigned 8 0(0) >> 34(22) = 0(0)\nunsigned 8 0(0) >> 35(23) = 0(0)\nunsigned 8 0(0) >> 36(24) = 0(0)\nunsigned 8 0(0) >> 37(25) = 0(0)\nunsigned 8 0(0) >> 38(26) = 0(0)\nunsigned 8 0(0) >> 39(27) = 0(0)\nunsigned 8 0(0) >> 40(28) = 0(0)\nunsigned 8 0(0) >> 41(29) = 0(0)\nunsigned 8 0(0) >> 42(2a) = 0(0)\nunsigned 8 0(0) >> 43(2b) = 0(0)\nunsigned 8 0(0) >> 44(2c) = 0(0)\nunsigned 8 0(0) >> 45(2d) = 0(0)\nunsigned 8 0(0) >> 46(2e) = 0(0)\nunsigned 8 0(0) >> 47(2f) = 0(0)\nunsigned 8 0(0) >> 48(30) = 0(0)\nunsigned 8 0(0) >> 49(31) = 0(0)\nunsigned 8 0(0) >> 50(32) = 0(0)\nunsigned 8 0(0) >> 51(33) = 0(0)\nunsigned 8 0(0) >> 52(34) = 0(0)\nunsigned 8 0(0) >> 53(35) = 0(0)\nunsigned 8 0(0) >> 54(36) = 0(0)\nunsigned 8 0(0) >> 55(37) = 0(0)\nunsigned 8 0(0) >> 56(38) = 0(0)\nunsigned 8 0(0) >> 57(39) = 0(0)\nunsigned 8 0(0) >> 58(3a) = 0(0)\nunsigned 8 0(0) >> 59(3b) = 0(0)\nunsigned 8 0(0) >> 60(3c) = 0(0)\nunsigned 8 0(0) >> 61(3d) = 0(0)\nunsigned 8 0(0) >> 62(3e) = 0(0)\nunsigned 8 0(0) >> 63(3f) = 0(0)\nunsigned 8 0(0) >> 64(40) = 0(0)\nunsigned 8 0(0) >> 65(41) = 0(0)\nunsigned 8 0(0) >> 66(42) = 0(0)\nunsigned 8 0(0) >> 67(43) = 0(0)\nunsigned 8 0(0) >> 68(44) = 0(0)\nunsigned 8 0(0) >> 69(45) = 0(0)\nunsigned 8 0(0) >> 70(46) = 0(0)\nunsigned 8 0(0) >> 71(47) = 0(0)\nunsigned 8 0(0) >> 72(48) = 0(0)\nunsigned 8 0(0) >> 73(49) = 0(0)\nunsigned 8 0(0) >> 74(4a) = 0(0)\nunsigned 8 0(0) >> 75(4b) = 0(0)\nunsigned 8 0(0) >> 76(4c) = 0(0)\nunsigned 8 0(0) >> 77(4d) = 0(0)\nunsigned 8 0(0) >> 78(4e) = 0(0)\nunsigned 8 0(0) >> 79(4f) = 0(0)\nunsigned 8 0(0) >> 80(50) = 0(0)\nunsigned 8 0(0) >> 81(51) = 0(0)\nunsigned 8 0(0) >> 82(52) = 0(0)\nunsigned 8 0(0) >> 83(53) = 0(0)\nunsigned 8 0(0) >> 84(54) = 0(0)\nunsigned 8 0(0) >> 85(55) = 0(0)\nunsigned 8 0(0) >> 86(56) = 0(0)\nunsigned 8 0(0) >> 87(57) = 0(0)\nunsigned 8 0(0) >> 88(58) = 0(0)\nunsigned 8 0(0) >> 89(59) = 0(0)\nunsigned 8 0(0) >> 90(5a) = 0(0)\nunsigned 8 0(0) >> 91(5b) = 0(0)\nunsigned 8 0(0) >> 92(5c) = 0(0)\nunsigned 8 0(0) >> 93(5d) = 0(0)\nunsigned 8 0(0) >> 94(5e) = 0(0)\nunsigned 8 0(0) >> 95(5f) = 0(0)\nunsigned 8 0(0) >> 96(60) = 0(0)\nunsigned 8 0(0) >> 97(61) = 0(0)\nunsigned 8 0(0) >> 98(62) = 0(0)\nunsigned 8 0(0) >> 99(63) = 0(0)\nunsigned 8 0(0) >> 100(64) = 0(0)\nunsigned 8 0(0) >> 101(65) = 0(0)\nunsigned 8 0(0) >> 102(66) = 0(0)\nunsigned 8 0(0) >> 103(67) = 0(0)\nunsigned 8 0(0) >> 104(68) = 0(0)\nunsigned 8 0(0) >> 105(69) = 0(0)\nunsigned 8 0(0) >> 106(6a) = 0(0)\nunsigned 8 0(0) >> 107(6b) = 0(0)\nunsigned 8 0(0) >> 108(6c) = 0(0)\nunsigned 8 0(0) >> 109(6d) = 0(0)\nunsigned 8 0(0) >> 110(6e) = 0(0)\nunsigned 8 0(0) >> 111(6f) = 0(0)\nunsigned 8 0(0) >> 112(70) = 0(0)\nunsigned 8 0(0) >> 113(71) = 0(0)\nunsigned 8 0(0) >> 114(72) = 0(0)\nunsigned 8 0(0) >> 115(73) = 0(0)\nunsigned 8 0(0) >> 116(74) = 0(0)\nunsigned 8 0(0) >> 117(75) = 0(0)\nunsigned 8 0(0) >> 118(76) = 0(0)\nunsigned 8 0(0) >> 119(77) = 0(0)\nunsigned 8 0(0) >> 120(78) = 0(0)\nunsigned 8 0(0) >> 121(79) = 0(0)\nunsigned 8 0(0) >> 122(7a) = 0(0)\nunsigned 8 0(0) >> 123(7b) = 0(0)\nunsigned 8 0(0) >> 124(7c) = 0(0)\nunsigned 8 0(0) >> 125(7d) = 0(0)\nunsigned 8 0(0) >> 126(7e) = 0(0)\nunsigned 8 0(0) >> 127(7f) = 0(0)\nunsigned 8 1(1) >> -128(ffffff80) = 1(1)\nunsigned 8 1(1) >> -127(ffffff81) = 0(0)\nunsigned 8 1(1) >> -126(ffffff82) = 0(0)\nunsigned 8 1(1) >> -125(ffffff83) = 0(0)\nunsigned 8 1(1) >> -124(ffffff84) = 0(0)\nunsigned 8 1(1) >> -123(ffffff85) = 0(0)\nunsigned 8 1(1) >> -122(ffffff86) = 0(0)\nunsigned 8 1(1) >> -121(ffffff87) = 0(0)\nunsigned 8 1(1) >> -120(ffffff88) = 0(0)\nunsigned 8 1(1) >> -119(ffffff89) = 0(0)\nunsigned 8 1(1) >> -118(ffffff8a) = 0(0)\nunsigned 8 1(1) >> -117(ffffff8b) = 0(0)\nunsigned 8 1(1) >> -116(ffffff8c) = 0(0)\nunsigned 8 1(1) >> -115(ffffff8d) = 0(0)\nunsigned 8 1(1) >> -114(ffffff8e) = 0(0)\nunsigned 8 1(1) >> -113(ffffff8f) = 0(0)\nunsigned 8 1(1) >> -112(ffffff90) = 0(0)\nunsigned 8 1(1) >> -111(ffffff91) = 0(0)\nunsigned 8 1(1) >> -110(ffffff92) = 0(0)\nunsigned 8 1(1) >> -109(ffffff93) = 0(0)\nunsigned 8 1(1) >> -108(ffffff94) = 0(0)\nunsigned 8 1(1) >> -107(ffffff95) = 0(0)\nunsigned 8 1(1) >> -106(ffffff96) = 0(0)\nunsigned 8 1(1) >> -105(ffffff97) = 0(0)\nunsigned 8 1(1) >> -104(ffffff98) = 0(0)\nunsigned 8 1(1) >> -103(ffffff99) = 0(0)\nunsigned 8 1(1) >> -102(ffffff9a) = 0(0)\nunsigned 8 1(1) >> -101(ffffff9b) = 0(0)\nunsigned 8 1(1) >> -100(ffffff9c) = 0(0)\nunsigned 8 1(1) >> -99(ffffff9d) = 0(0)\nunsigned 8 1(1) >> -98(ffffff9e) = 0(0)\nunsigned 8 1(1) >> -97(ffffff9f) = 0(0)\nunsigned 8 1(1) >> -96(ffffffa0) = 0(0)\nunsigned 8 1(1) >> -95(ffffffa1) = 0(0)\nunsigned 8 1(1) >> -94(ffffffa2) = 0(0)\nunsigned 8 1(1) >> -93(ffffffa3) = 0(0)\nunsigned 8 1(1) >> -92(ffffffa4) = 0(0)\nunsigned 8 1(1) >> -91(ffffffa5) = 0(0)\nunsigned 8 1(1) >> -90(ffffffa6) = 0(0)\nunsigned 8 1(1) >> -89(ffffffa7) = 0(0)\nunsigned 8 1(1) >> -88(ffffffa8) = 0(0)\nunsigned 8 1(1) >> -87(ffffffa9) = 0(0)\nunsigned 8 1(1) >> -86(ffffffaa) = 0(0)\nunsigned 8 1(1) >> -85(ffffffab) = 0(0)\nunsigned 8 1(1) >> -84(ffffffac) = 0(0)\nunsigned 8 1(1) >> -83(ffffffad) = 0(0)\nunsigned 8 1(1) >> -82(ffffffae) = 0(0)\nunsigned 8 1(1) >> -81(ffffffaf) = 0(0)\nunsigned 8 1(1) >> -80(ffffffb0) = 0(0)\nunsigned 8 1(1) >> -79(ffffffb1) = 0(0)\nunsigned 8 1(1) >> -78(ffffffb2) = 0(0)\nunsigned 8 1(1) >> -77(ffffffb3) = 0(0)\nunsigned 8 1(1) >> -76(ffffffb4) = 0(0)\nunsigned 8 1(1) >> -75(ffffffb5) = 0(0)\nunsigned 8 1(1) >> -74(ffffffb6) = 0(0)\nunsigned 8 1(1) >> -73(ffffffb7) = 0(0)\nunsigned 8 1(1) >> -72(ffffffb8) = 0(0)\nunsigned 8 1(1) >> -71(ffffffb9) = 0(0)\nunsigned 8 1(1) >> -70(ffffffba) = 0(0)\nunsigned 8 1(1) >> -69(ffffffbb) = 0(0)\nunsigned 8 1(1) >> -68(ffffffbc) = 0(0)\nunsigned 8 1(1) >> -67(ffffffbd) = 0(0)\nunsigned 8 1(1) >> -66(ffffffbe) = 0(0)\nunsigned 8 1(1) >> -65(ffffffbf) = 0(0)\nunsigned 8 1(1) >> -64(ffffffc0) = 1(1)\nunsigned 8 1(1) >> -63(ffffffc1) = 0(0)\nunsigned 8 1(1) >> -62(ffffffc2) = 0(0)\nunsigned 8 1(1) >> -61(ffffffc3) = 0(0)\nunsigned 8 1(1) >> -60(ffffffc4) = 0(0)\nunsigned 8 1(1) >> -59(ffffffc5) = 0(0)\nunsigned 8 1(1) >> -58(ffffffc6) = 0(0)\nunsigned 8 1(1) >> -57(ffffffc7) = 0(0)\nunsigned 8 1(1) >> -56(ffffffc8) = 0(0)\nunsigned 8 1(1) >> -55(ffffffc9) = 0(0)\nunsigned 8 1(1) >> -54(ffffffca) = 0(0)\nunsigned 8 1(1) >> -53(ffffffcb) = 0(0)\nunsigned 8 1(1) >> -52(ffffffcc) = 0(0)\nunsigned 8 1(1) >> -51(ffffffcd) = 0(0)\nunsigned 8 1(1) >> -50(ffffffce) = 0(0)\nunsigned 8 1(1) >> -49(ffffffcf) = 0(0)\nunsigned 8 1(1) >> -48(ffffffd0) = 0(0)\nunsigned 8 1(1) >> -47(ffffffd1) = 0(0)\nunsigned 8 1(1) >> -46(ffffffd2) = 0(0)\nunsigned 8 1(1) >> -45(ffffffd3) = 0(0)\nunsigned 8 1(1) >> -44(ffffffd4) = 0(0)\nunsigned 8 1(1) >> -43(ffffffd5) = 0(0)\nunsigned 8 1(1) >> -42(ffffffd6) = 0(0)\nunsigned 8 1(1) >> -41(ffffffd7) = 0(0)\nunsigned 8 1(1) >> -40(ffffffd8) = 0(0)\nunsigned 8 1(1) >> -39(ffffffd9) = 0(0)\nunsigned 8 1(1) >> -38(ffffffda) = 0(0)\nunsigned 8 1(1) >> -37(ffffffdb) = 0(0)\nunsigned 8 1(1) >> -36(ffffffdc) = 0(0)\nunsigned 8 1(1) >> -35(ffffffdd) = 0(0)\nunsigned 8 1(1) >> -34(ffffffde) = 0(0)\nunsigned 8 1(1) >> -33(ffffffdf) = 0(0)\nunsigned 8 1(1) >> -32(ffffffe0) = 0(0)\nunsigned 8 1(1) >> -31(ffffffe1) = 0(0)\nunsigned 8 1(1) >> -30(ffffffe2) = 0(0)\nunsigned 8 1(1) >> -29(ffffffe3) = 0(0)\nunsigned 8 1(1) >> -28(ffffffe4) = 0(0)\nunsigned 8 1(1) >> -27(ffffffe5) = 0(0)\nunsigned 8 1(1) >> -26(ffffffe6) = 0(0)\nunsigned 8 1(1) >> -25(ffffffe7) = 0(0)\nunsigned 8 1(1) >> -24(ffffffe8) = 0(0)\nunsigned 8 1(1) >> -23(ffffffe9) = 0(0)\nunsigned 8 1(1) >> -22(ffffffea) = 0(0)\nunsigned 8 1(1) >> -21(ffffffeb) = 0(0)\nunsigned 8 1(1) >> -20(ffffffec) = 0(0)\nunsigned 8 1(1) >> -19(ffffffed) = 0(0)\nunsigned 8 1(1) >> -18(ffffffee) = 0(0)\nunsigned 8 1(1) >> -17(ffffffef) = 0(0)\nunsigned 8 1(1) >> -16(fffffff0) = 0(0)\nunsigned 8 1(1) >> -15(fffffff1) = 0(0)\nunsigned 8 1(1) >> -14(fffffff2) = 0(0)\nunsigned 8 1(1) >> -13(fffffff3) = 0(0)\nunsigned 8 1(1) >> -12(fffffff4) = 0(0)\nunsigned 8 1(1) >> -11(fffffff5) = 0(0)\nunsigned 8 1(1) >> -10(fffffff6) = 0(0)\nunsigned 8 1(1) >> -9(fffffff7) = 0(0)\nunsigned 8 1(1) >> -8(fffffff8) = 0(0)\nunsigned 8 1(1) >> -7(fffffff9) = 0(0)\nunsigned 8 1(1) >> -6(fffffffa) = 0(0)\nunsigned 8 1(1) >> -5(fffffffb) = 0(0)\nunsigned 8 1(1) >> -4(fffffffc) = 0(0)\nunsigned 8 1(1) >> -3(fffffffd) = 0(0)\nunsigned 8 1(1) >> -2(fffffffe) = 0(0)\nunsigned 8 1(1) >> -1(ffffffff) = 0(0)\nunsigned 8 1(1) >> 0(0) = 1(1)\nunsigned 8 1(1) >> 1(1) = 0(0)\nunsigned 8 1(1) >> 2(2) = 0(0)\nunsigned 8 1(1) >> 3(3) = 0(0)\nunsigned 8 1(1) >> 4(4) = 0(0)\nunsigned 8 1(1) >> 5(5) = 0(0)\nunsigned 8 1(1) >> 6(6) = 0(0)\nunsigned 8 1(1) >> 7(7) = 0(0)\nunsigned 8 1(1) >> 8(8) = 0(0)\nunsigned 8 1(1) >> 9(9) = 0(0)\nunsigned 8 1(1) >> 10(a) = 0(0)\nunsigned 8 1(1) >> 11(b) = 0(0)\nunsigned 8 1(1) >> 12(c) = 0(0)\nunsigned 8 1(1) >> 13(d) = 0(0)\nunsigned 8 1(1) >> 14(e) = 0(0)\nunsigned 8 1(1) >> 15(f) = 0(0)\nunsigned 8 1(1) >> 16(10) = 0(0)\nunsigned 8 1(1) >> 17(11) = 0(0)\nunsigned 8 1(1) >> 18(12) = 0(0)\nunsigned 8 1(1) >> 19(13) = 0(0)\nunsigned 8 1(1) >> 20(14) = 0(0)\nunsigned 8 1(1) >> 21(15) = 0(0)\nunsigned 8 1(1) >> 22(16) = 0(0)\nunsigned 8 1(1) >> 23(17) = 0(0)\nunsigned 8 1(1) >> 24(18) = 0(0)\nunsigned 8 1(1) >> 25(19) = 0(0)\nunsigned 8 1(1) >> 26(1a) = 0(0)\nunsigned 8 1(1) >> 27(1b) = 0(0)\nunsigned 8 1(1) >> 28(1c) = 0(0)\nunsigned 8 1(1) >> 29(1d) = 0(0)\nunsigned 8 1(1) >> 30(1e) = 0(0)\nunsigned 8 1(1) >> 31(1f) = 0(0)\nunsigned 8 1(1) >> 32(20) = 0(0)\nunsigned 8 1(1) >> 33(21) = 0(0)\nunsigned 8 1(1) >> 34(22) = 0(0)\nunsigned 8 1(1) >> 35(23) = 0(0)\nunsigned 8 1(1) >> 36(24) = 0(0)\nunsigned 8 1(1) >> 37(25) = 0(0)\nunsigned 8 1(1) >> 38(26) = 0(0)\nunsigned 8 1(1) >> 39(27) = 0(0)\nunsigned 8 1(1) >> 40(28) = 0(0)\nunsigned 8 1(1) >> 41(29) = 0(0)\nunsigned 8 1(1) >> 42(2a) = 0(0)\nunsigned 8 1(1) >> 43(2b) = 0(0)\nunsigned 8 1(1) >> 44(2c) = 0(0)\nunsigned 8 1(1) >> 45(2d) = 0(0)\nunsigned 8 1(1) >> 46(2e) = 0(0)\nunsigned 8 1(1) >> 47(2f) = 0(0)\nunsigned 8 1(1) >> 48(30) = 0(0)\nunsigned 8 1(1) >> 49(31) = 0(0)\nunsigned 8 1(1) >> 50(32) = 0(0)\nunsigned 8 1(1) >> 51(33) = 0(0)\nunsigned 8 1(1) >> 52(34) = 0(0)\nunsigned 8 1(1) >> 53(35) = 0(0)\nunsigned 8 1(1) >> 54(36) = 0(0)\nunsigned 8 1(1) >> 55(37) = 0(0)\nunsigned 8 1(1) >> 56(38) = 0(0)\nunsigned 8 1(1) >> 57(39) = 0(0)\nunsigned 8 1(1) >> 58(3a) = 0(0)\nunsigned 8 1(1) >> 59(3b) = 0(0)\nunsigned 8 1(1) >> 60(3c) = 0(0)\nunsigned 8 1(1) >> 61(3d) = 0(0)\nunsigned 8 1(1) >> 62(3e) = 0(0)\nunsigned 8 1(1) >> 63(3f) = 0(0)\nunsigned 8 1(1) >> 64(40) = 1(1)\nunsigned 8 1(1) >> 65(41) = 0(0)\nunsigned 8 1(1) >> 66(42) = 0(0)\nunsigned 8 1(1) >> 67(43) = 0(0)\nunsigned 8 1(1) >> 68(44) = 0(0)\nunsigned 8 1(1) >> 69(45) = 0(0)\nunsigned 8 1(1) >> 70(46) = 0(0)\nunsigned 8 1(1) >> 71(47) = 0(0)\nunsigned 8 1(1) >> 72(48) = 0(0)\nunsigned 8 1(1) >> 73(49) = 0(0)\nunsigned 8 1(1) >> 74(4a) = 0(0)\nunsigned 8 1(1) >> 75(4b) = 0(0)\nunsigned 8 1(1) >> 76(4c) = 0(0)\nunsigned 8 1(1) >> 77(4d) = 0(0)\nunsigned 8 1(1) >> 78(4e) = 0(0)\nunsigned 8 1(1) >> 79(4f) = 0(0)\nunsigned 8 1(1) >> 80(50) = 0(0)\nunsigned 8 1(1) >> 81(51) = 0(0)\nunsigned 8 1(1) >> 82(52) = 0(0)\nunsigned 8 1(1) >> 83(53) = 0(0)\nunsigned 8 1(1) >> 84(54) = 0(0)\nunsigned 8 1(1) >> 85(55) = 0(0)\nunsigned 8 1(1) >> 86(56) = 0(0)\nunsigned 8 1(1) >> 87(57) = 0(0)\nunsigned 8 1(1) >> 88(58) = 0(0)\nunsigned 8 1(1) >> 89(59) = 0(0)\nunsigned 8 1(1) >> 90(5a) = 0(0)\nunsigned 8 1(1) >> 91(5b) = 0(0)\nunsigned 8 1(1) >> 92(5c) = 0(0)\nunsigned 8 1(1) >> 93(5d) = 0(0)\nunsigned 8 1(1) >> 94(5e) = 0(0)\nunsigned 8 1(1) >> 95(5f) = 0(0)\nunsigned 8 1(1) >> 96(60) = 0(0)\nunsigned 8 1(1) >> 97(61) = 0(0)\nunsigned 8 1(1) >> 98(62) = 0(0)\nunsigned 8 1(1) >> 99(63) = 0(0)\nunsigned 8 1(1) >> 100(64) = 0(0)\nunsigned 8 1(1) >> 101(65) = 0(0)\nunsigned 8 1(1) >> 102(66) = 0(0)\nunsigned 8 1(1) >> 103(67) = 0(0)\nunsigned 8 1(1) >> 104(68) = 0(0)\nunsigned 8 1(1) >> 105(69) = 0(0)\nunsigned 8 1(1) >> 106(6a) = 0(0)\nunsigned 8 1(1) >> 107(6b) = 0(0)\nunsigned 8 1(1) >> 108(6c) = 0(0)\nunsigned 8 1(1) >> 109(6d) = 0(0)\nunsigned 8 1(1) >> 110(6e) = 0(0)\nunsigned 8 1(1) >> 111(6f) = 0(0)\nunsigned 8 1(1) >> 112(70) = 0(0)\nunsigned 8 1(1) >> 113(71) = 0(0)\nunsigned 8 1(1) >> 114(72) = 0(0)\nunsigned 8 1(1) >> 115(73) = 0(0)\nunsigned 8 1(1) >> 116(74) = 0(0)\nunsigned 8 1(1) >> 117(75) = 0(0)\nunsigned 8 1(1) >> 118(76) = 0(0)\nunsigned 8 1(1) >> 119(77) = 0(0)\nunsigned 8 1(1) >> 120(78) = 0(0)\nunsigned 8 1(1) >> 121(79) = 0(0)\nunsigned 8 1(1) >> 122(7a) = 0(0)\nunsigned 8 1(1) >> 123(7b) = 0(0)\nunsigned 8 1(1) >> 124(7c) = 0(0)\nunsigned 8 1(1) >> 125(7d) = 0(0)\nunsigned 8 1(1) >> 126(7e) = 0(0)\nunsigned 8 1(1) >> 127(7f) = 0(0)\nunsigned 8 2(2) >> -128(ffffff80) = 2(2)\nunsigned 8 2(2) >> -127(ffffff81) = 1(1)\nunsigned 8 2(2) >> -126(ffffff82) = 0(0)\nunsigned 8 2(2) >> -125(ffffff83) = 0(0)\nunsigned 8 2(2) >> -124(ffffff84) = 0(0)\nunsigned 8 2(2) >> -123(ffffff85) = 0(0)\nunsigned 8 2(2) >> -122(ffffff86) = 0(0)\nunsigned 8 2(2) >> -121(ffffff87) = 0(0)\nunsigned 8 2(2) >> -120(ffffff88) = 0(0)\nunsigned 8 2(2) >> -119(ffffff89) = 0(0)\nunsigned 8 2(2) >> -118(ffffff8a) = 0(0)\nunsigned 8 2(2) >> -117(ffffff8b) = 0(0)\nunsigned 8 2(2) >> -116(ffffff8c) = 0(0)\nunsigned 8 2(2) >> -115(ffffff8d) = 0(0)\nunsigned 8 2(2) >> -114(ffffff8e) = 0(0)\nunsigned 8 2(2) >> -113(ffffff8f) = 0(0)\nunsigned 8 2(2) >> -112(ffffff90) = 0(0)\nunsigned 8 2(2) >> -111(ffffff91) = 0(0)\nunsigned 8 2(2) >> -110(ffffff92) = 0(0)\nunsigned 8 2(2) >> -109(ffffff93) = 0(0)\nunsigned 8 2(2) >> -108(ffffff94) = 0(0)\nunsigned 8 2(2) >> -107(ffffff95) = 0(0)\nunsigned 8 2(2) >> -106(ffffff96) = 0(0)\nunsigned 8 2(2) >> -105(ffffff97) = 0(0)\nunsigned 8 2(2) >> -104(ffffff98) = 0(0)\nunsigned 8 2(2) >> -103(ffffff99) = 0(0)\nunsigned 8 2(2) >> -102(ffffff9a) = 0(0)\nunsigned 8 2(2) >> -101(ffffff9b) = 0(0)\nunsigned 8 2(2) >> -100(ffffff9c) = 0(0)\nunsigned 8 2(2) >> -99(ffffff9d) = 0(0)\nunsigned 8 2(2) >> -98(ffffff9e) = 0(0)\nunsigned 8 2(2) >> -97(ffffff9f) = 0(0)\nunsigned 8 2(2) >> -96(ffffffa0) = 0(0)\nunsigned 8 2(2) >> -95(ffffffa1) = 0(0)\nunsigned 8 2(2) >> -94(ffffffa2) = 0(0)\nunsigned 8 2(2) >> -93(ffffffa3) = 0(0)\nunsigned 8 2(2) >> -92(ffffffa4) = 0(0)\nunsigned 8 2(2) >> -91(ffffffa5) = 0(0)\nunsigned 8 2(2) >> -90(ffffffa6) = 0(0)\nunsigned 8 2(2) >> -89(ffffffa7) = 0(0)\nunsigned 8 2(2) >> -88(ffffffa8) = 0(0)\nunsigned 8 2(2) >> -87(ffffffa9) = 0(0)\nunsigned 8 2(2) >> -86(ffffffaa) = 0(0)\nunsigned 8 2(2) >> -85(ffffffab) = 0(0)\nunsigned 8 2(2) >> -84(ffffffac) = 0(0)\nunsigned 8 2(2) >> -83(ffffffad) = 0(0)\nunsigned 8 2(2) >> -82(ffffffae) = 0(0)\nunsigned 8 2(2) >> -81(ffffffaf) = 0(0)\nunsigned 8 2(2) >> -80(ffffffb0) = 0(0)\nunsigned 8 2(2) >> -79(ffffffb1) = 0(0)\nunsigned 8 2(2) >> -78(ffffffb2) = 0(0)\nunsigned 8 2(2) >> -77(ffffffb3) = 0(0)\nunsigned 8 2(2) >> -76(ffffffb4) = 0(0)\nunsigned 8 2(2) >> -75(ffffffb5) = 0(0)\nunsigned 8 2(2) >> -74(ffffffb6) = 0(0)\nunsigned 8 2(2) >> -73(ffffffb7) = 0(0)\nunsigned 8 2(2) >> -72(ffffffb8) = 0(0)\nunsigned 8 2(2) >> -71(ffffffb9) = 0(0)\nunsigned 8 2(2) >> -70(ffffffba) = 0(0)\nunsigned 8 2(2) >> -69(ffffffbb) = 0(0)\nunsigned 8 2(2) >> -68(ffffffbc) = 0(0)\nunsigned 8 2(2) >> -67(ffffffbd) = 0(0)\nunsigned 8 2(2) >> -66(ffffffbe) = 0(0)\nunsigned 8 2(2) >> -65(ffffffbf) = 0(0)\nunsigned 8 2(2) >> -64(ffffffc0) = 2(2)\nunsigned 8 2(2) >> -63(ffffffc1) = 1(1)\nunsigned 8 2(2) >> -62(ffffffc2) = 0(0)\nunsigned 8 2(2) >> -61(ffffffc3) = 0(0)\nunsigned 8 2(2) >> -60(ffffffc4) = 0(0)\nunsigned 8 2(2) >> -59(ffffffc5) = 0(0)\nunsigned 8 2(2) >> -58(ffffffc6) = 0(0)\nunsigned 8 2(2) >> -57(ffffffc7) = 0(0)\nunsigned 8 2(2) >> -56(ffffffc8) = 0(0)\nunsigned 8 2(2) >> -55(ffffffc9) = 0(0)\nunsigned 8 2(2) >> -54(ffffffca) = 0(0)\nunsigned 8 2(2) >> -53(ffffffcb) = 0(0)\nunsigned 8 2(2) >> -52(ffffffcc) = 0(0)\nunsigned 8 2(2) >> -51(ffffffcd) = 0(0)\nunsigned 8 2(2) >> -50(ffffffce) = 0(0)\nunsigned 8 2(2) >> -49(ffffffcf) = 0(0)\nunsigned 8 2(2) >> -48(ffffffd0) = 0(0)\nunsigned 8 2(2) >> -47(ffffffd1) = 0(0)\nunsigned 8 2(2) >> -46(ffffffd2) = 0(0)\nunsigned 8 2(2) >> -45(ffffffd3) = 0(0)\nunsigned 8 2(2) >> -44(ffffffd4) = 0(0)\nunsigned 8 2(2) >> -43(ffffffd5) = 0(0)\nunsigned 8 2(2) >> -42(ffffffd6) = 0(0)\nunsigned 8 2(2) >> -41(ffffffd7) = 0(0)\nunsigned 8 2(2) >> -40(ffffffd8) = 0(0)\nunsigned 8 2(2) >> -39(ffffffd9) = 0(0)\nunsigned 8 2(2) >> -38(ffffffda) = 0(0)\nunsigned 8 2(2) >> -37(ffffffdb) = 0(0)\nunsigned 8 2(2) >> -36(ffffffdc) = 0(0)\nunsigned 8 2(2) >> -35(ffffffdd) = 0(0)\nunsigned 8 2(2) >> -34(ffffffde) = 0(0)\nunsigned 8 2(2) >> -33(ffffffdf) = 0(0)\nunsigned 8 2(2) >> -32(ffffffe0) = 0(0)\nunsigned 8 2(2) >> -31(ffffffe1) = 0(0)\nunsigned 8 2(2) >> -30(ffffffe2) = 0(0)\nunsigned 8 2(2) >> -29(ffffffe3) = 0(0)\nunsigned 8 2(2) >> -28(ffffffe4) = 0(0)\nunsigned 8 2(2) >> -27(ffffffe5) = 0(0)\nunsigned 8 2(2) >> -26(ffffffe6) = 0(0)\nunsigned 8 2(2) >> -25(ffffffe7) = 0(0)\nunsigned 8 2(2) >> -24(ffffffe8) = 0(0)\nunsigned 8 2(2) >> -23(ffffffe9) = 0(0)\nunsigned 8 2(2) >> -22(ffffffea) = 0(0)\nunsigned 8 2(2) >> -21(ffffffeb) = 0(0)\nunsigned 8 2(2) >> -20(ffffffec) = 0(0)\nunsigned 8 2(2) >> -19(ffffffed) = 0(0)\nunsigned 8 2(2) >> -18(ffffffee) = 0(0)\nunsigned 8 2(2) >> -17(ffffffef) = 0(0)\nunsigned 8 2(2) >> -16(fffffff0) = 0(0)\nunsigned 8 2(2) >> -15(fffffff1) = 0(0)\nunsigned 8 2(2) >> -14(fffffff2) = 0(0)\nunsigned 8 2(2) >> -13(fffffff3) = 0(0)\nunsigned 8 2(2) >> -12(fffffff4) = 0(0)\nunsigned 8 2(2) >> -11(fffffff5) = 0(0)\nunsigned 8 2(2) >> -10(fffffff6) = 0(0)\nunsigned 8 2(2) >> -9(fffffff7) = 0(0)\nunsigned 8 2(2) >> -8(fffffff8) = 0(0)\nunsigned 8 2(2) >> -7(fffffff9) = 0(0)\nunsigned 8 2(2) >> -6(fffffffa) = 0(0)\nunsigned 8 2(2) >> -5(fffffffb) = 0(0)\nunsigned 8 2(2) >> -4(fffffffc) = 0(0)\nunsigned 8 2(2) >> -3(fffffffd) = 0(0)\nunsigned 8 2(2) >> -2(fffffffe) = 0(0)\nunsigned 8 2(2) >> -1(ffffffff) = 0(0)\nunsigned 8 2(2) >> 0(0) = 2(2)\nunsigned 8 2(2) >> 1(1) = 1(1)\nunsigned 8 2(2) >> 2(2) = 0(0)\nunsigned 8 2(2) >> 3(3) = 0(0)\nunsigned 8 2(2) >> 4(4) = 0(0)\nunsigned 8 2(2) >> 5(5) = 0(0)\nunsigned 8 2(2) >> 6(6) = 0(0)\nunsigned 8 2(2) >> 7(7) = 0(0)\nunsigned 8 2(2) >> 8(8) = 0(0)\nunsigned 8 2(2) >> 9(9) = 0(0)\nunsigned 8 2(2) >> 10(a) = 0(0)\nunsigned 8 2(2) >> 11(b) = 0(0)\nunsigned 8 2(2) >> 12(c) = 0(0)\nunsigned 8 2(2) >> 13(d) = 0(0)\nunsigned 8 2(2) >> 14(e) = 0(0)\nunsigned 8 2(2) >> 15(f) = 0(0)\nunsigned 8 2(2) >> 16(10) = 0(0)\nunsigned 8 2(2) >> 17(11) = 0(0)\nunsigned 8 2(2) >> 18(12) = 0(0)\nunsigned 8 2(2) >> 19(13) = 0(0)\nunsigned 8 2(2) >> 20(14) = 0(0)\nunsigned 8 2(2) >> 21(15) = 0(0)\nunsigned 8 2(2) >> 22(16) = 0(0)\nunsigned 8 2(2) >> 23(17) = 0(0)\nunsigned 8 2(2) >> 24(18) = 0(0)\nunsigned 8 2(2) >> 25(19) = 0(0)\nunsigned 8 2(2) >> 26(1a) = 0(0)\nunsigned 8 2(2) >> 27(1b) = 0(0)\nunsigned 8 2(2) >> 28(1c) = 0(0)\nunsigned 8 2(2) >> 29(1d) = 0(0)\nunsigned 8 2(2) >> 30(1e) = 0(0)\nunsigned 8 2(2) >> 31(1f) = 0(0)\nunsigned 8 2(2) >> 32(20) = 0(0)\nunsigned 8 2(2) >> 33(21) = 0(0)\nunsigned 8 2(2) >> 34(22) = 0(0)\nunsigned 8 2(2) >> 35(23) = 0(0)\nunsigned 8 2(2) >> 36(24) = 0(0)\nunsigned 8 2(2) >> 37(25) = 0(0)\nunsigned 8 2(2) >> 38(26) = 0(0)\nunsigned 8 2(2) >> 39(27) = 0(0)\nunsigned 8 2(2) >> 40(28) = 0(0)\nunsigned 8 2(2) >> 41(29) = 0(0)\nunsigned 8 2(2) >> 42(2a) = 0(0)\nunsigned 8 2(2) >> 43(2b) = 0(0)\nunsigned 8 2(2) >> 44(2c) = 0(0)\nunsigned 8 2(2) >> 45(2d) = 0(0)\nunsigned 8 2(2) >> 46(2e) = 0(0)\nunsigned 8 2(2) >> 47(2f) = 0(0)\nunsigned 8 2(2) >> 48(30) = 0(0)\nunsigned 8 2(2) >> 49(31) = 0(0)\nunsigned 8 2(2) >> 50(32) = 0(0)\nunsigned 8 2(2) >> 51(33) = 0(0)\nunsigned 8 2(2) >> 52(34) = 0(0)\nunsigned 8 2(2) >> 53(35) = 0(0)\nunsigned 8 2(2) >> 54(36) = 0(0)\nunsigned 8 2(2) >> 55(37) = 0(0)\nunsigned 8 2(2) >> 56(38) = 0(0)\nunsigned 8 2(2) >> 57(39) = 0(0)\nunsigned 8 2(2) >> 58(3a) = 0(0)\nunsigned 8 2(2) >> 59(3b) = 0(0)\nunsigned 8 2(2) >> 60(3c) = 0(0)\nunsigned 8 2(2) >> 61(3d) = 0(0)\nunsigned 8 2(2) >> 62(3e) = 0(0)\nunsigned 8 2(2) >> 63(3f) = 0(0)\nunsigned 8 2(2) >> 64(40) = 2(2)\nunsigned 8 2(2) >> 65(41) = 1(1)\nunsigned 8 2(2) >> 66(42) = 0(0)\nunsigned 8 2(2) >> 67(43) = 0(0)\nunsigned 8 2(2) >> 68(44) = 0(0)\nunsigned 8 2(2) >> 69(45) = 0(0)\nunsigned 8 2(2) >> 70(46) = 0(0)\nunsigned 8 2(2) >> 71(47) = 0(0)\nunsigned 8 2(2) >> 72(48) = 0(0)\nunsigned 8 2(2) >> 73(49) = 0(0)\nunsigned 8 2(2) >> 74(4a) = 0(0)\nunsigned 8 2(2) >> 75(4b) = 0(0)\nunsigned 8 2(2) >> 76(4c) = 0(0)\nunsigned 8 2(2) >> 77(4d) = 0(0)\nunsigned 8 2(2) >> 78(4e) = 0(0)\nunsigned 8 2(2) >> 79(4f) = 0(0)\nunsigned 8 2(2) >> 80(50) = 0(0)\nunsigned 8 2(2) >> 81(51) = 0(0)\nunsigned 8 2(2) >> 82(52) = 0(0)\nunsigned 8 2(2) >> 83(53) = 0(0)\nunsigned 8 2(2) >> 84(54) = 0(0)\nunsigned 8 2(2) >> 85(55) = 0(0)\nunsigned 8 2(2) >> 86(56) = 0(0)\nunsigned 8 2(2) >> 87(57) = 0(0)\nunsigned 8 2(2) >> 88(58) = 0(0)\nunsigned 8 2(2) >> 89(59) = 0(0)\nunsigned 8 2(2) >> 90(5a) = 0(0)\nunsigned 8 2(2) >> 91(5b) = 0(0)\nunsigned 8 2(2) >> 92(5c) = 0(0)\nunsigned 8 2(2) >> 93(5d) = 0(0)\nunsigned 8 2(2) >> 94(5e) = 0(0)\nunsigned 8 2(2) >> 95(5f) = 0(0)\nunsigned 8 2(2) >> 96(60) = 0(0)\nunsigned 8 2(2) >> 97(61) = 0(0)\nunsigned 8 2(2) >> 98(62) = 0(0)\nunsigned 8 2(2) >> 99(63) = 0(0)\nunsigned 8 2(2) >> 100(64) = 0(0)\nunsigned 8 2(2) >> 101(65) = 0(0)\nunsigned 8 2(2) >> 102(66) = 0(0)\nunsigned 8 2(2) >> 103(67) = 0(0)\nunsigned 8 2(2) >> 104(68) = 0(0)\nunsigned 8 2(2) >> 105(69) = 0(0)\nunsigned 8 2(2) >> 106(6a) = 0(0)\nunsigned 8 2(2) >> 107(6b) = 0(0)\nunsigned 8 2(2) >> 108(6c) = 0(0)\nunsigned 8 2(2) >> 109(6d) = 0(0)\nunsigned 8 2(2) >> 110(6e) = 0(0)\nunsigned 8 2(2) >> 111(6f) = 0(0)\nunsigned 8 2(2) >> 112(70) = 0(0)\nunsigned 8 2(2) >> 113(71) = 0(0)\nunsigned 8 2(2) >> 114(72) = 0(0)\nunsigned 8 2(2) >> 115(73) = 0(0)\nunsigned 8 2(2) >> 116(74) = 0(0)\nunsigned 8 2(2) >> 117(75) = 0(0)\nunsigned 8 2(2) >> 118(76) = 0(0)\nunsigned 8 2(2) >> 119(77) = 0(0)\nunsigned 8 2(2) >> 120(78) = 0(0)\nunsigned 8 2(2) >> 121(79) = 0(0)\nunsigned 8 2(2) >> 122(7a) = 0(0)\nunsigned 8 2(2) >> 123(7b) = 0(0)\nunsigned 8 2(2) >> 124(7c) = 0(0)\nunsigned 8 2(2) >> 125(7d) = 0(0)\nunsigned 8 2(2) >> 126(7e) = 0(0)\nunsigned 8 2(2) >> 127(7f) = 0(0)\nunsigned 8 3(3) >> -128(ffffff80) = 3(3)\nunsigned 8 3(3) >> -127(ffffff81) = 1(1)\nunsigned 8 3(3) >> -126(ffffff82) = 0(0)\nunsigned 8 3(3) >> -125(ffffff83) = 0(0)\nunsigned 8 3(3) >> -124(ffffff84) = 0(0)\nunsigned 8 3(3) >> -123(ffffff85) = 0(0)\nunsigned 8 3(3) >> -122(ffffff86) = 0(0)\nunsigned 8 3(3) >> -121(ffffff87) = 0(0)\nunsigned 8 3(3) >> -120(ffffff88) = 0(0)\nunsigned 8 3(3) >> -119(ffffff89) = 0(0)\nunsigned 8 3(3) >> -118(ffffff8a) = 0(0)\nunsigned 8 3(3) >> -117(ffffff8b) = 0(0)\nunsigned 8 3(3) >> -116(ffffff8c) = 0(0)\nunsigned 8 3(3) >> -115(ffffff8d) = 0(0)\nunsigned 8 3(3) >> -114(ffffff8e) = 0(0)\nunsigned 8 3(3) >> -113(ffffff8f) = 0(0)\nunsigned 8 3(3) >> -112(ffffff90) = 0(0)\nunsigned 8 3(3) >> -111(ffffff91) = 0(0)\nunsigned 8 3(3) >> -110(ffffff92) = 0(0)\nunsigned 8 3(3) >> -109(ffffff93) = 0(0)\nunsigned 8 3(3) >> -108(ffffff94) = 0(0)\nunsigned 8 3(3) >> -107(ffffff95) = 0(0)\nunsigned 8 3(3) >> -106(ffffff96) = 0(0)\nunsigned 8 3(3) >> -105(ffffff97) = 0(0)\nunsigned 8 3(3) >> -104(ffffff98) = 0(0)\nunsigned 8 3(3) >> -103(ffffff99) = 0(0)\nunsigned 8 3(3) >> -102(ffffff9a) = 0(0)\nunsigned 8 3(3) >> -101(ffffff9b) = 0(0)\nunsigned 8 3(3) >> -100(ffffff9c) = 0(0)\nunsigned 8 3(3) >> -99(ffffff9d) = 0(0)\nunsigned 8 3(3) >> -98(ffffff9e) = 0(0)\nunsigned 8 3(3) >> -97(ffffff9f) = 0(0)\nunsigned 8 3(3) >> -96(ffffffa0) = 0(0)\nunsigned 8 3(3) >> -95(ffffffa1) = 0(0)\nunsigned 8 3(3) >> -94(ffffffa2) = 0(0)\nunsigned 8 3(3) >> -93(ffffffa3) = 0(0)\nunsigned 8 3(3) >> -92(ffffffa4) = 0(0)\nunsigned 8 3(3) >> -91(ffffffa5) = 0(0)\nunsigned 8 3(3) >> -90(ffffffa6) = 0(0)\nunsigned 8 3(3) >> -89(ffffffa7) = 0(0)\nunsigned 8 3(3) >> -88(ffffffa8) = 0(0)\nunsigned 8 3(3) >> -87(ffffffa9) = 0(0)\nunsigned 8 3(3) >> -86(ffffffaa) = 0(0)\nunsigned 8 3(3) >> -85(ffffffab) = 0(0)\nunsigned 8 3(3) >> -84(ffffffac) = 0(0)\nunsigned 8 3(3) >> -83(ffffffad) = 0(0)\nunsigned 8 3(3) >> -82(ffffffae) = 0(0)\nunsigned 8 3(3) >> -81(ffffffaf) = 0(0)\nunsigned 8 3(3) >> -80(ffffffb0) = 0(0)\nunsigned 8 3(3) >> -79(ffffffb1) = 0(0)\nunsigned 8 3(3) >> -78(ffffffb2) = 0(0)\nunsigned 8 3(3) >> -77(ffffffb3) = 0(0)\nunsigned 8 3(3) >> -76(ffffffb4) = 0(0)\nunsigned 8 3(3) >> -75(ffffffb5) = 0(0)\nunsigned 8 3(3) >> -74(ffffffb6) = 0(0)\nunsigned 8 3(3) >> -73(ffffffb7) = 0(0)\nunsigned 8 3(3) >> -72(ffffffb8) = 0(0)\nunsigned 8 3(3) >> -71(ffffffb9) = 0(0)\nunsigned 8 3(3) >> -70(ffffffba) = 0(0)\nunsigned 8 3(3) >> -69(ffffffbb) = 0(0)\nunsigned 8 3(3) >> -68(ffffffbc) = 0(0)\nunsigned 8 3(3) >> -67(ffffffbd) = 0(0)\nunsigned 8 3(3) >> -66(ffffffbe) = 0(0)\nunsigned 8 3(3) >> -65(ffffffbf) = 0(0)\nunsigned 8 3(3) >> -64(ffffffc0) = 3(3)\nunsigned 8 3(3) >> -63(ffffffc1) = 1(1)\nunsigned 8 3(3) >> -62(ffffffc2) = 0(0)\nunsigned 8 3(3) >> -61(ffffffc3) = 0(0)\nunsigned 8 3(3) >> -60(ffffffc4) = 0(0)\nunsigned 8 3(3) >> -59(ffffffc5) = 0(0)\nunsigned 8 3(3) >> -58(ffffffc6) = 0(0)\nunsigned 8 3(3) >> -57(ffffffc7) = 0(0)\nunsigned 8 3(3) >> -56(ffffffc8) = 0(0)\nunsigned 8 3(3) >> -55(ffffffc9) = 0(0)\nunsigned 8 3(3) >> -54(ffffffca) = 0(0)\nunsigned 8 3(3) >> -53(ffffffcb) = 0(0)\nunsigned 8 3(3) >> -52(ffffffcc) = 0(0)\nunsigned 8 3(3) >> -51(ffffffcd) = 0(0)\nunsigned 8 3(3) >> -50(ffffffce) = 0(0)\nunsigned 8 3(3) >> -49(ffffffcf) = 0(0)\nunsigned 8 3(3) >> -48(ffffffd0) = 0(0)\nunsigned 8 3(3) >> -47(ffffffd1) = 0(0)\nunsigned 8 3(3) >> -46(ffffffd2) = 0(0)\nunsigned 8 3(3) >> -45(ffffffd3) = 0(0)\nunsigned 8 3(3) >> -44(ffffffd4) = 0(0)\nunsigned 8 3(3) >> -43(ffffffd5) = 0(0)\nunsigned 8 3(3) >> -42(ffffffd6) = 0(0)\nunsigned 8 3(3) >> -41(ffffffd7) = 0(0)\nunsigned 8 3(3) >> -40(ffffffd8) = 0(0)\nunsigned 8 3(3) >> -39(ffffffd9) = 0(0)\nunsigned 8 3(3) >> -38(ffffffda) = 0(0)\nunsigned 8 3(3) >> -37(ffffffdb) = 0(0)\nunsigned 8 3(3) >> -36(ffffffdc) = 0(0)\nunsigned 8 3(3) >> -35(ffffffdd) = 0(0)\nunsigned 8 3(3) >> -34(ffffffde) = 0(0)\nunsigned 8 3(3) >> -33(ffffffdf) = 0(0)\nunsigned 8 3(3) >> -32(ffffffe0) = 0(0)\nunsigned 8 3(3) >> -31(ffffffe1) = 0(0)\nunsigned 8 3(3) >> -30(ffffffe2) = 0(0)\nunsigned 8 3(3) >> -29(ffffffe3) = 0(0)\nunsigned 8 3(3) >> -28(ffffffe4) = 0(0)\nunsigned 8 3(3) >> -27(ffffffe5) = 0(0)\nunsigned 8 3(3) >> -26(ffffffe6) = 0(0)\nunsigned 8 3(3) >> -25(ffffffe7) = 0(0)\nunsigned 8 3(3) >> -24(ffffffe8) = 0(0)\nunsigned 8 3(3) >> -23(ffffffe9) = 0(0)\nunsigned 8 3(3) >> -22(ffffffea) = 0(0)\nunsigned 8 3(3) >> -21(ffffffeb) = 0(0)\nunsigned 8 3(3) >> -20(ffffffec) = 0(0)\nunsigned 8 3(3) >> -19(ffffffed) = 0(0)\nunsigned 8 3(3) >> -18(ffffffee) = 0(0)\nunsigned 8 3(3) >> -17(ffffffef) = 0(0)\nunsigned 8 3(3) >> -16(fffffff0) = 0(0)\nunsigned 8 3(3) >> -15(fffffff1) = 0(0)\nunsigned 8 3(3) >> -14(fffffff2) = 0(0)\nunsigned 8 3(3) >> -13(fffffff3) = 0(0)\nunsigned 8 3(3) >> -12(fffffff4) = 0(0)\nunsigned 8 3(3) >> -11(fffffff5) = 0(0)\nunsigned 8 3(3) >> -10(fffffff6) = 0(0)\nunsigned 8 3(3) >> -9(fffffff7) = 0(0)\nunsigned 8 3(3) >> -8(fffffff8) = 0(0)\nunsigned 8 3(3) >> -7(fffffff9) = 0(0)\nunsigned 8 3(3) >> -6(fffffffa) = 0(0)\nunsigned 8 3(3) >> -5(fffffffb) = 0(0)\nunsigned 8 3(3) >> -4(fffffffc) = 0(0)\nunsigned 8 3(3) >> -3(fffffffd) = 0(0)\nunsigned 8 3(3) >> -2(fffffffe) = 0(0)\nunsigned 8 3(3) >> -1(ffffffff) = 0(0)\nunsigned 8 3(3) >> 0(0) = 3(3)\nunsigned 8 3(3) >> 1(1) = 1(1)\nunsigned 8 3(3) >> 2(2) = 0(0)\nunsigned 8 3(3) >> 3(3) = 0(0)\nunsigned 8 3(3) >> 4(4) = 0(0)\nunsigned 8 3(3) >> 5(5) = 0(0)\nunsigned 8 3(3) >> 6(6) = 0(0)\nunsigned 8 3(3) >> 7(7) = 0(0)\nunsigned 8 3(3) >> 8(8) = 0(0)\nunsigned 8 3(3) >> 9(9) = 0(0)\nunsigned 8 3(3) >> 10(a) = 0(0)\nunsigned 8 3(3) >> 11(b) = 0(0)\nunsigned 8 3(3) >> 12(c) = 0(0)\nunsigned 8 3(3) >> 13(d) = 0(0)\nunsigned 8 3(3) >> 14(e) = 0(0)\nunsigned 8 3(3) >> 15(f) = 0(0)\nunsigned 8 3(3) >> 16(10) = 0(0)\nunsigned 8 3(3) >> 17(11) = 0(0)\nunsigned 8 3(3) >> 18(12) = 0(0)\nunsigned 8 3(3) >> 19(13) = 0(0)\nunsigned 8 3(3) >> 20(14) = 0(0)\nunsigned 8 3(3) >> 21(15) = 0(0)\nunsigned 8 3(3) >> 22(16) = 0(0)\nunsigned 8 3(3) >> 23(17) = 0(0)\nunsigned 8 3(3) >> 24(18) = 0(0)\nunsigned 8 3(3) >> 25(19) = 0(0)\nunsigned 8 3(3) >> 26(1a) = 0(0)\nunsigned 8 3(3) >> 27(1b) = 0(0)\nunsigned 8 3(3) >> 28(1c) = 0(0)\nunsigned 8 3(3) >> 29(1d) = 0(0)\nunsigned 8 3(3) >> 30(1e) = 0(0)\nunsigned 8 3(3) >> 31(1f) = 0(0)\nunsigned 8 3(3) >> 32(20) = 0(0)\nunsigned 8 3(3) >> 33(21) = 0(0)\nunsigned 8 3(3) >> 34(22) = 0(0)\nunsigned 8 3(3) >> 35(23) = 0(0)\nunsigned 8 3(3) >> 36(24) = 0(0)\nunsigned 8 3(3) >> 37(25) = 0(0)\nunsigned 8 3(3) >> 38(26) = 0(0)\nunsigned 8 3(3) >> 39(27) = 0(0)\nunsigned 8 3(3) >> 40(28) = 0(0)\nunsigned 8 3(3) >> 41(29) = 0(0)\nunsigned 8 3(3) >> 42(2a) = 0(0)\nunsigned 8 3(3) >> 43(2b) = 0(0)\nunsigned 8 3(3) >> 44(2c) = 0(0)\nunsigned 8 3(3) >> 45(2d) = 0(0)\nunsigned 8 3(3) >> 46(2e) = 0(0)\nunsigned 8 3(3) >> 47(2f) = 0(0)\nunsigned 8 3(3) >> 48(30) = 0(0)\nunsigned 8 3(3) >> 49(31) = 0(0)\nunsigned 8 3(3) >> 50(32) = 0(0)\nunsigned 8 3(3) >> 51(33) = 0(0)\nunsigned 8 3(3) >> 52(34) = 0(0)\nunsigned 8 3(3) >> 53(35) = 0(0)\nunsigned 8 3(3) >> 54(36) = 0(0)\nunsigned 8 3(3) >> 55(37) = 0(0)\nunsigned 8 3(3) >> 56(38) = 0(0)\nunsigned 8 3(3) >> 57(39) = 0(0)\nunsigned 8 3(3) >> 58(3a) = 0(0)\nunsigned 8 3(3) >> 59(3b) = 0(0)\nunsigned 8 3(3) >> 60(3c) = 0(0)\nunsigned 8 3(3) >> 61(3d) = 0(0)\nunsigned 8 3(3) >> 62(3e) = 0(0)\nunsigned 8 3(3) >> 63(3f) = 0(0)\nunsigned 8 3(3) >> 64(40) = 3(3)\nunsigned 8 3(3) >> 65(41) = 1(1)\nunsigned 8 3(3) >> 66(42) = 0(0)\nunsigned 8 3(3) >> 67(43) = 0(0)\nunsigned 8 3(3) >> 68(44) = 0(0)\nunsigned 8 3(3) >> 69(45) = 0(0)\nunsigned 8 3(3) >> 70(46) = 0(0)\nunsigned 8 3(3) >> 71(47) = 0(0)\nunsigned 8 3(3) >> 72(48) = 0(0)\nunsigned 8 3(3) >> 73(49) = 0(0)\nunsigned 8 3(3) >> 74(4a) = 0(0)\nunsigned 8 3(3) >> 75(4b) = 0(0)\nunsigned 8 3(3) >> 76(4c) = 0(0)\nunsigned 8 3(3) >> 77(4d) = 0(0)\nunsigned 8 3(3) >> 78(4e) = 0(0)\nunsigned 8 3(3) >> 79(4f) = 0(0)\nunsigned 8 3(3) >> 80(50) = 0(0)\nunsigned 8 3(3) >> 81(51) = 0(0)\nunsigned 8 3(3) >> 82(52) = 0(0)\nunsigned 8 3(3) >> 83(53) = 0(0)\nunsigned 8 3(3) >> 84(54) = 0(0)\nunsigned 8 3(3) >> 85(55) = 0(0)\nunsigned 8 3(3) >> 86(56) = 0(0)\nunsigned 8 3(3) >> 87(57) = 0(0)\nunsigned 8 3(3) >> 88(58) = 0(0)\nunsigned 8 3(3) >> 89(59) = 0(0)\nunsigned 8 3(3) >> 90(5a) = 0(0)\nunsigned 8 3(3) >> 91(5b) = 0(0)\nunsigned 8 3(3) >> 92(5c) = 0(0)\nunsigned 8 3(3) >> 93(5d) = 0(0)\nunsigned 8 3(3) >> 94(5e) = 0(0)\nunsigned 8 3(3) >> 95(5f) = 0(0)\nunsigned 8 3(3) >> 96(60) = 0(0)\nunsigned 8 3(3) >> 97(61) = 0(0)\nunsigned 8 3(3) >> 98(62) = 0(0)\nunsigned 8 3(3) >> 99(63) = 0(0)\nunsigned 8 3(3) >> 100(64) = 0(0)\nunsigned 8 3(3) >> 101(65) = 0(0)\nunsigned 8 3(3) >> 102(66) = 0(0)\nunsigned 8 3(3) >> 103(67) = 0(0)\nunsigned 8 3(3) >> 104(68) = 0(0)\nunsigned 8 3(3) >> 105(69) = 0(0)\nunsigned 8 3(3) >> 106(6a) = 0(0)\nunsigned 8 3(3) >> 107(6b) = 0(0)\nunsigned 8 3(3) >> 108(6c) = 0(0)\nunsigned 8 3(3) >> 109(6d) = 0(0)\nunsigned 8 3(3) >> 110(6e) = 0(0)\nunsigned 8 3(3) >> 111(6f) = 0(0)\nunsigned 8 3(3) >> 112(70) = 0(0)\nunsigned 8 3(3) >> 113(71) = 0(0)\nunsigned 8 3(3) >> 114(72) = 0(0)\nunsigned 8 3(3) >> 115(73) = 0(0)\nunsigned 8 3(3) >> 116(74) = 0(0)\nunsigned 8 3(3) >> 117(75) = 0(0)\nunsigned 8 3(3) >> 118(76) = 0(0)\nunsigned 8 3(3) >> 119(77) = 0(0)\nunsigned 8 3(3) >> 120(78) = 0(0)\nunsigned 8 3(3) >> 121(79) = 0(0)\nunsigned 8 3(3) >> 122(7a) = 0(0)\nunsigned 8 3(3) >> 123(7b) = 0(0)\nunsigned 8 3(3) >> 124(7c) = 0(0)\nunsigned 8 3(3) >> 125(7d) = 0(0)\nunsigned 8 3(3) >> 126(7e) = 0(0)\nunsigned 8 3(3) >> 127(7f) = 0(0)\nunsigned 8 4(4) >> -128(ffffff80) = 4(4)\nunsigned 8 4(4) >> -127(ffffff81) = 2(2)\nunsigned 8 4(4) >> -126(ffffff82) = 1(1)\nunsigned 8 4(4) >> -125(ffffff83) = 0(0)\nunsigned 8 4(4) >> -124(ffffff84) = 0(0)\nunsigned 8 4(4) >> -123(ffffff85) = 0(0)\nunsigned 8 4(4) >> -122(ffffff86) = 0(0)\nunsigned 8 4(4) >> -121(ffffff87) = 0(0)\nunsigned 8 4(4) >> -120(ffffff88) = 0(0)\nunsigned 8 4(4) >> -119(ffffff89) = 0(0)\nunsigned 8 4(4) >> -118(ffffff8a) = 0(0)\nunsigned 8 4(4) >> -117(ffffff8b) = 0(0)\nunsigned 8 4(4) >> -116(ffffff8c) = 0(0)\nunsigned 8 4(4) >> -115(ffffff8d) = 0(0)\nunsigned 8 4(4) >> -114(ffffff8e) = 0(0)\nunsigned 8 4(4) >> -113(ffffff8f) = 0(0)\nunsigned 8 4(4) >> -112(ffffff90) = 0(0)\nunsigned 8 4(4) >> -111(ffffff91) = 0(0)\nunsigned 8 4(4) >> -110(ffffff92) = 0(0)\nunsigned 8 4(4) >> -109(ffffff93) = 0(0)\nunsigned 8 4(4) >> -108(ffffff94) = 0(0)\nunsigned 8 4(4) >> -107(ffffff95) = 0(0)\nunsigned 8 4(4) >> -106(ffffff96) = 0(0)\nunsigned 8 4(4) >> -105(ffffff97) = 0(0)\nunsigned 8 4(4) >> -104(ffffff98) = 0(0)\nunsigned 8 4(4) >> -103(ffffff99) = 0(0)\nunsigned 8 4(4) >> -102(ffffff9a) = 0(0)\nunsigned 8 4(4) >> -101(ffffff9b) = 0(0)\nunsigned 8 4(4) >> -100(ffffff9c) = 0(0)\nunsigned 8 4(4) >> -99(ffffff9d) = 0(0)\nunsigned 8 4(4) >> -98(ffffff9e) = 0(0)\nunsigned 8 4(4) >> -97(ffffff9f) = 0(0)\nunsigned 8 4(4) >> -96(ffffffa0) = 0(0)\nunsigned 8 4(4) >> -95(ffffffa1) = 0(0)\nunsigned 8 4(4) >> -94(ffffffa2) = 0(0)\nunsigned 8 4(4) >> -93(ffffffa3) = 0(0)\nunsigned 8 4(4) >> -92(ffffffa4) = 0(0)\nunsigned 8 4(4) >> -91(ffffffa5) = 0(0)\nunsigned 8 4(4) >> -90(ffffffa6) = 0(0)\nunsigned 8 4(4) >> -89(ffffffa7) = 0(0)\nunsigned 8 4(4) >> -88(ffffffa8) = 0(0)\nunsigned 8 4(4) >> -87(ffffffa9) = 0(0)\nunsigned 8 4(4) >> -86(ffffffaa) = 0(0)\nunsigned 8 4(4) >> -85(ffffffab) = 0(0)\nunsigned 8 4(4) >> -84(ffffffac) = 0(0)\nunsigned 8 4(4) >> -83(ffffffad) = 0(0)\nunsigned 8 4(4) >> -82(ffffffae) = 0(0)\nunsigned 8 4(4) >> -81(ffffffaf) = 0(0)\nunsigned 8 4(4) >> -80(ffffffb0) = 0(0)\nunsigned 8 4(4) >> -79(ffffffb1) = 0(0)\nunsigned 8 4(4) >> -78(ffffffb2) = 0(0)\nunsigned 8 4(4) >> -77(ffffffb3) = 0(0)\nunsigned 8 4(4) >> -76(ffffffb4) = 0(0)\nunsigned 8 4(4) >> -75(ffffffb5) = 0(0)\nunsigned 8 4(4) >> -74(ffffffb6) = 0(0)\nunsigned 8 4(4) >> -73(ffffffb7) = 0(0)\nunsigned 8 4(4) >> -72(ffffffb8) = 0(0)\nunsigned 8 4(4) >> -71(ffffffb9) = 0(0)\nunsigned 8 4(4) >> -70(ffffffba) = 0(0)\nunsigned 8 4(4) >> -69(ffffffbb) = 0(0)\nunsigned 8 4(4) >> -68(ffffffbc) = 0(0)\nunsigned 8 4(4) >> -67(ffffffbd) = 0(0)\nunsigned 8 4(4) >> -66(ffffffbe) = 0(0)\nunsigned 8 4(4) >> -65(ffffffbf) = 0(0)\nunsigned 8 4(4) >> -64(ffffffc0) = 4(4)\nunsigned 8 4(4) >> -63(ffffffc1) = 2(2)\nunsigned 8 4(4) >> -62(ffffffc2) = 1(1)\nunsigned 8 4(4) >> -61(ffffffc3) = 0(0)\nunsigned 8 4(4) >> -60(ffffffc4) = 0(0)\nunsigned 8 4(4) >> -59(ffffffc5) = 0(0)\nunsigned 8 4(4) >> -58(ffffffc6) = 0(0)\nunsigned 8 4(4) >> -57(ffffffc7) = 0(0)\nunsigned 8 4(4) >> -56(ffffffc8) = 0(0)\nunsigned 8 4(4) >> -55(ffffffc9) = 0(0)\nunsigned 8 4(4) >> -54(ffffffca) = 0(0)\nunsigned 8 4(4) >> -53(ffffffcb) = 0(0)\nunsigned 8 4(4) >> -52(ffffffcc) = 0(0)\nunsigned 8 4(4) >> -51(ffffffcd) = 0(0)\nunsigned 8 4(4) >> -50(ffffffce) = 0(0)\nunsigned 8 4(4) >> -49(ffffffcf) = 0(0)\nunsigned 8 4(4) >> -48(ffffffd0) = 0(0)\nunsigned 8 4(4) >> -47(ffffffd1) = 0(0)\nunsigned 8 4(4) >> -46(ffffffd2) = 0(0)\nunsigned 8 4(4) >> -45(ffffffd3) = 0(0)\nunsigned 8 4(4) >> -44(ffffffd4) = 0(0)\nunsigned 8 4(4) >> -43(ffffffd5) = 0(0)\nunsigned 8 4(4) >> -42(ffffffd6) = 0(0)\nunsigned 8 4(4) >> -41(ffffffd7) = 0(0)\nunsigned 8 4(4) >> -40(ffffffd8) = 0(0)\nunsigned 8 4(4) >> -39(ffffffd9) = 0(0)\nunsigned 8 4(4) >> -38(ffffffda) = 0(0)\nunsigned 8 4(4) >> -37(ffffffdb) = 0(0)\nunsigned 8 4(4) >> -36(ffffffdc) = 0(0)\nunsigned 8 4(4) >> -35(ffffffdd) = 0(0)\nunsigned 8 4(4) >> -34(ffffffde) = 0(0)\nunsigned 8 4(4) >> -33(ffffffdf) = 0(0)\nunsigned 8 4(4) >> -32(ffffffe0) = 0(0)\nunsigned 8 4(4) >> -31(ffffffe1) = 0(0)\nunsigned 8 4(4) >> -30(ffffffe2) = 0(0)\nunsigned 8 4(4) >> -29(ffffffe3) = 0(0)\nunsigned 8 4(4) >> -28(ffffffe4) = 0(0)\nunsigned 8 4(4) >> -27(ffffffe5) = 0(0)\nunsigned 8 4(4) >> -26(ffffffe6) = 0(0)\nunsigned 8 4(4) >> -25(ffffffe7) = 0(0)\nunsigned 8 4(4) >> -24(ffffffe8) = 0(0)\nunsigned 8 4(4) >> -23(ffffffe9) = 0(0)\nunsigned 8 4(4) >> -22(ffffffea) = 0(0)\nunsigned 8 4(4) >> -21(ffffffeb) = 0(0)\nunsigned 8 4(4) >> -20(ffffffec) = 0(0)\nunsigned 8 4(4) >> -19(ffffffed) = 0(0)\nunsigned 8 4(4) >> -18(ffffffee) = 0(0)\nunsigned 8 4(4) >> -17(ffffffef) = 0(0)\nunsigned 8 4(4) >> -16(fffffff0) = 0(0)\nunsigned 8 4(4) >> -15(fffffff1) = 0(0)\nunsigned 8 4(4) >> -14(fffffff2) = 0(0)\nunsigned 8 4(4) >> -13(fffffff3) = 0(0)\nunsigned 8 4(4) >> -12(fffffff4) = 0(0)\nunsigned 8 4(4) >> -11(fffffff5) = 0(0)\nunsigned 8 4(4) >> -10(fffffff6) = 0(0)\nunsigned 8 4(4) >> -9(fffffff7) = 0(0)\nunsigned 8 4(4) >> -8(fffffff8) = 0(0)\nunsigned 8 4(4) >> -7(fffffff9) = 0(0)\nunsigned 8 4(4) >> -6(fffffffa) = 0(0)\nunsigned 8 4(4) >> -5(fffffffb) = 0(0)\nunsigned 8 4(4) >> -4(fffffffc) = 0(0)\nunsigned 8 4(4) >> -3(fffffffd) = 0(0)\nunsigned 8 4(4) >> -2(fffffffe) = 0(0)\nunsigned 8 4(4) >> -1(ffffffff) = 0(0)\nunsigned 8 4(4) >> 0(0) = 4(4)\nunsigned 8 4(4) >> 1(1) = 2(2)\nunsigned 8 4(4) >> 2(2) = 1(1)\nunsigned 8 4(4) >> 3(3) = 0(0)\nunsigned 8 4(4) >> 4(4) = 0(0)\nunsigned 8 4(4) >> 5(5) = 0(0)\nunsigned 8 4(4) >> 6(6) = 0(0)\nunsigned 8 4(4) >> 7(7) = 0(0)\nunsigned 8 4(4) >> 8(8) = 0(0)\nunsigned 8 4(4) >> 9(9) = 0(0)\nunsigned 8 4(4) >> 10(a) = 0(0)\nunsigned 8 4(4) >> 11(b) = 0(0)\nunsigned 8 4(4) >> 12(c) = 0(0)\nunsigned 8 4(4) >> 13(d) = 0(0)\nunsigned 8 4(4) >> 14(e) = 0(0)\nunsigned 8 4(4) >> 15(f) = 0(0)\nunsigned 8 4(4) >> 16(10) = 0(0)\nunsigned 8 4(4) >> 17(11) = 0(0)\nunsigned 8 4(4) >> 18(12) = 0(0)\nunsigned 8 4(4) >> 19(13) = 0(0)\nunsigned 8 4(4) >> 20(14) = 0(0)\nunsigned 8 4(4) >> 21(15) = 0(0)\nunsigned 8 4(4) >> 22(16) = 0(0)\nunsigned 8 4(4) >> 23(17) = 0(0)\nunsigned 8 4(4) >> 24(18) = 0(0)\nunsigned 8 4(4) >> 25(19) = 0(0)\nunsigned 8 4(4) >> 26(1a) = 0(0)\nunsigned 8 4(4) >> 27(1b) = 0(0)\nunsigned 8 4(4) >> 28(1c) = 0(0)\nunsigned 8 4(4) >> 29(1d) = 0(0)\nunsigned 8 4(4) >> 30(1e) = 0(0)\nunsigned 8 4(4) >> 31(1f) = 0(0)\nunsigned 8 4(4) >> 32(20) = 0(0)\nunsigned 8 4(4) >> 33(21) = 0(0)\nunsigned 8 4(4) >> 34(22) = 0(0)\nunsigned 8 4(4) >> 35(23) = 0(0)\nunsigned 8 4(4) >> 36(24) = 0(0)\nunsigned 8 4(4) >> 37(25) = 0(0)\nunsigned 8 4(4) >> 38(26) = 0(0)\nunsigned 8 4(4) >> 39(27) = 0(0)\nunsigned 8 4(4) >> 40(28) = 0(0)\nunsigned 8 4(4) >> 41(29) = 0(0)\nunsigned 8 4(4) >> 42(2a) = 0(0)\nunsigned 8 4(4) >> 43(2b) = 0(0)\nunsigned 8 4(4) >> 44(2c) = 0(0)\nunsigned 8 4(4) >> 45(2d) = 0(0)\nunsigned 8 4(4) >> 46(2e) = 0(0)\nunsigned 8 4(4) >> 47(2f) = 0(0)\nunsigned 8 4(4) >> 48(30) = 0(0)\nunsigned 8 4(4) >> 49(31) = 0(0)\nunsigned 8 4(4) >> 50(32) = 0(0)\nunsigned 8 4(4) >> 51(33) = 0(0)\nunsigned 8 4(4) >> 52(34) = 0(0)\nunsigned 8 4(4) >> 53(35) = 0(0)\nunsigned 8 4(4) >> 54(36) = 0(0)\nunsigned 8 4(4) >> 55(37) = 0(0)\nunsigned 8 4(4) >> 56(38) = 0(0)\nunsigned 8 4(4) >> 57(39) = 0(0)\nunsigned 8 4(4) >> 58(3a) = 0(0)\nunsigned 8 4(4) >> 59(3b) = 0(0)\nunsigned 8 4(4) >> 60(3c) = 0(0)\nunsigned 8 4(4) >> 61(3d) = 0(0)\nunsigned 8 4(4) >> 62(3e) = 0(0)\nunsigned 8 4(4) >> 63(3f) = 0(0)\nunsigned 8 4(4) >> 64(40) = 4(4)\nunsigned 8 4(4) >> 65(41) = 2(2)\nunsigned 8 4(4) >> 66(42) = 1(1)\nunsigned 8 4(4) >> 67(43) = 0(0)\nunsigned 8 4(4) >> 68(44) = 0(0)\nunsigned 8 4(4) >> 69(45) = 0(0)\nunsigned 8 4(4) >> 70(46) = 0(0)\nunsigned 8 4(4) >> 71(47) = 0(0)\nunsigned 8 4(4) >> 72(48) = 0(0)\nunsigned 8 4(4) >> 73(49) = 0(0)\nunsigned 8 4(4) >> 74(4a) = 0(0)\nunsigned 8 4(4) >> 75(4b) = 0(0)\nunsigned 8 4(4) >> 76(4c) = 0(0)\nunsigned 8 4(4) >> 77(4d) = 0(0)\nunsigned 8 4(4) >> 78(4e) = 0(0)\nunsigned 8 4(4) >> 79(4f) = 0(0)\nunsigned 8 4(4) >> 80(50) = 0(0)\nunsigned 8 4(4) >> 81(51) = 0(0)\nunsigned 8 4(4) >> 82(52) = 0(0)\nunsigned 8 4(4) >> 83(53) = 0(0)\nunsigned 8 4(4) >> 84(54) = 0(0)\nunsigned 8 4(4) >> 85(55) = 0(0)\nunsigned 8 4(4) >> 86(56) = 0(0)\nunsigned 8 4(4) >> 87(57) = 0(0)\nunsigned 8 4(4) >> 88(58) = 0(0)\nunsigned 8 4(4) >> 89(59) = 0(0)\nunsigned 8 4(4) >> 90(5a) = 0(0)\nunsigned 8 4(4) >> 91(5b) = 0(0)\nunsigned 8 4(4) >> 92(5c) = 0(0)\nunsigned 8 4(4) >> 93(5d) = 0(0)\nunsigned 8 4(4) >> 94(5e) = 0(0)\nunsigned 8 4(4) >> 95(5f) = 0(0)\nunsigned 8 4(4) >> 96(60) = 0(0)\nunsigned 8 4(4) >> 97(61) = 0(0)\nunsigned 8 4(4) >> 98(62) = 0(0)\nunsigned 8 4(4) >> 99(63) = 0(0)\nunsigned 8 4(4) >> 100(64) = 0(0)\nunsigned 8 4(4) >> 101(65) = 0(0)\nunsigned 8 4(4) >> 102(66) = 0(0)\nunsigned 8 4(4) >> 103(67) = 0(0)\nunsigned 8 4(4) >> 104(68) = 0(0)\nunsigned 8 4(4) >> 105(69) = 0(0)\nunsigned 8 4(4) >> 106(6a) = 0(0)\nunsigned 8 4(4) >> 107(6b) = 0(0)\nunsigned 8 4(4) >> 108(6c) = 0(0)\nunsigned 8 4(4) >> 109(6d) = 0(0)\nunsigned 8 4(4) >> 110(6e) = 0(0)\nunsigned 8 4(4) >> 111(6f) = 0(0)\nunsigned 8 4(4) >> 112(70) = 0(0)\nunsigned 8 4(4) >> 113(71) = 0(0)\nunsigned 8 4(4) >> 114(72) = 0(0)\nunsigned 8 4(4) >> 115(73) = 0(0)\nunsigned 8 4(4) >> 116(74) = 0(0)\nunsigned 8 4(4) >> 117(75) = 0(0)\nunsigned 8 4(4) >> 118(76) = 0(0)\nunsigned 8 4(4) >> 119(77) = 0(0)\nunsigned 8 4(4) >> 120(78) = 0(0)\nunsigned 8 4(4) >> 121(79) = 0(0)\nunsigned 8 4(4) >> 122(7a) = 0(0)\nunsigned 8 4(4) >> 123(7b) = 0(0)\nunsigned 8 4(4) >> 124(7c) = 0(0)\nunsigned 8 4(4) >> 125(7d) = 0(0)\nunsigned 8 4(4) >> 126(7e) = 0(0)\nunsigned 8 4(4) >> 127(7f) = 0(0)\n"
  },
  {
    "path": "v2/testdata/bug/9.c",
    "content": "#include <stdio.h>\n\nint main() {\n\tfloat f32;\n\tunsigned long long u64;\n\tf32 = __FLT_MAX__;\n\tu64 = f32;\n\tprintf(\"%f %llu\\n\", f32, u64);\n\tint i32;\n\tint *pi32;\n\tpi32 = &i32;\n\t*pi32 = 0x9.A70A99p+87;\n\tprintf(\"%f %i\\n\", 0x9.A70A99p+87, i32);\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/bug/9.expect",
    "content": "340282346638528859811704183484516925440.000000 0\n1493652873142210332356247552.000000 2147483647\n"
  },
  {
    "path": "v2/testdata/cpp-expand/000.h",
    "content": "#define a b\na\n#define a2  b2\na2\n#define a3 b3//\na3\n#define a4 b4 //\na4\n#define a5 b5 c5\na5\n#define a6 b6  c6\na6\n#define a7 b7/**/c7\na7\n#define a8 b8 /**/c8\na8\n#define a9 b9/**/ c9\na9\n#define a10 b10 /**/ c10\na10\n"
  },
  {
    "path": "v2/testdata/cpp-expand/000.h.expect",
    "content": "\nb\n\nb2\n\nb3\n\nb4\n\nb5 c5\n\nb6 c6\n\nb7 c7\n\nb8 c8\n\nb9 c9\n\nb10 c10\n"
  },
  {
    "path": "v2/testdata/cpp-expand/001.h",
    "content": "#define f(x) f(2*x)\n#define m(a) a(24)\nf(f(42))\nm(f)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/001.h.expect",
    "content": "\n\nf(2*f(2*42))\nf(2*24)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/002.h",
    "content": "#define x      3\n#define f(a)   f(x * (a))\n#undef  x      \n#define x      2\n#define g      f\n#define w      0,1\n\ng(x+(3,4)-w)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/002.h.expect",
    "content": "\n\n\n\n\n\n\nf(2 * (2+(3,4)-0,1))\n"
  },
  {
    "path": "v2/testdata/cpp-expand/003.h",
    "content": "#define str(s) # s\n\nstr(: @\\n)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/003.h.expect",
    "content": "\n\n\": @\\n\"\n"
  },
  {
    "path": "v2/testdata/cpp-expand/004.h",
    "content": "#define __str(x) # x\n#define ____header(name, os, arch) __str(name ## _ ## os ## _ ## arch.h)\n#define ___header(name, os, arch) ____header(name, os, arch)\n#define __header(name) ___header(name, __os__, __arch__)\n\n#define bug1(name) __str(name ## _ ## os)\nbug1(a);\n\n#define __os__ linux\n#define __arch__ amd64\n\n____header(a, b, c);\n___header(a, b, c);\n__header(a);\n\n#define __str2(x) #x\n#define ____header2(name, os, arch) __str2(name##_##os##_##arch.h)\n#define ___header2(name, os, arch) ____header2(name, os, arch)\n#define __header2(name) ___header2(name, __os__, __arch__)\n\n#define bug2(name) __str2(name##_##os)\nbug2(a);\n\n____header2(a, b, c);\n___header2(a, b, c);\n__header2(a);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/004.h.expect",
    "content": "\n\n\n\n\n\n\"a_os\";\n\n\n\n\n\"a_b_c.h\";\n\"a_b_c.h\";\n\"a_linux_amd64.h\";\n\n\n\n\n\n\n\n\"a_os\";\n\n\"a_b_c.h\";\n\"a_b_c.h\";\n\"a_linux_amd64.h\";\n"
  },
  {
    "path": "v2/testdata/cpp-expand/005.c",
    "content": "#define foo(a, ...) bar(a, __VA_ARGS__)\nfoo(1, 2, 3);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/005.c.expect",
    "content": "\nbar(1, 2, 3);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/006.c",
    "content": "#define foo2(a, b...) bar2(a, b)\nfoo2(1, 2, 3);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/006.c.expect",
    "content": "\nbar2(1, 2, 3);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/007.c",
    "content": "#define a(b) b\n#define c a\nc(42)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/007.c.expect",
    "content": "\n\n42\n"
  },
  {
    "path": "v2/testdata/cpp-expand/008.c",
    "content": "#define QUOTE_(s) #s\n#define QUOTE(s) QUOTE_(s)\n#define check(t) check(QUOTE(t), __alignof__(t))\n \ncheck (void);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/008.c.expect",
    "content": "\n\n\n\ncheck(\"void\", __alignof__(void));\n"
  },
  {
    "path": "v2/testdata/cpp-expand/009.c",
    "content": "long __syscall(syscall_arg_t, ...);\n\n#ifndef __scc\n#define __scc(X) ((long) (X))\ntypedef long syscall_arg_t;\n#endif\n\n\n#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)\n#define __SYSCALL_CONCAT_X(a,b) a##b\n#define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)\n#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)\n#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n\n#define __sys_open(...) __SYSCALL_DISP(__sys_open,,__VA_ARGS__)\n#define __sys_open3(x,pn,fl,mo) __syscall4(SYS_openat, AT_FDCWD, pn, (fl)|O_LARGEFILE, mo)\n#define __syscall4(n,a,b,c,d) (__syscall)(n,__scc(a),__scc(b),__scc(c),__scc(d))\n#define sys_open(...) __syscall_ret(__sys_open(__VA_ARGS__))\n\nint fd = sys_open(filename, flags, 0666);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/009.c.expect",
    "content": "long __syscall(syscall_arg_t, ...);\n\n\n\ntypedef long syscall_arg_t;\n\n\n\n\n\n\n\n\n\n\n\n\n\nint fd = __syscall_ret((__syscall)(SYS_openat,((long) (AT_FDCWD)),((long) (filename)),((long) ((flags)|O_LARGEFILE)),((long) (0666))));\n"
  },
  {
    "path": "v2/testdata/cpp-expand/010.c",
    "content": "#define TEST42 0x0502\n#define TESTBASE 1\n#define TEST3 (TEST42 >= 0x0502 || !defined (TESTBASE))\n#define TEST4\n\n#if TEST3 && defined (TEST4)\n\tint test = 4;\n#endif\n\n\nint main (void) {\n\treturn test;\n}\n"
  },
  {
    "path": "v2/testdata/cpp-expand/010.c.expect",
    "content": "\n\n\n\n\n\nint test = 4;\n\n\n\nint main (void) {\nreturn test;\n}\n"
  },
  {
    "path": "v2/testdata/cpp-expand/011.c",
    "content": "#if 0 != (0 && (0/0))\n   FAIL\n#endif\n\n#if 1 != (-1 || (0/0))\n   FAIL\n#endif\n\n#if 3 != (-1 ? 3 : (0/0))\n   FAIL\n#endif\n\nint\nmain()\n{\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/cpp-expand/011.c.expect",
    "content": "\n\n\n\n\n\n\n\n\nint\nmain()\n{\nreturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10-8.h",
    "content": "#define EMPTY\nEMPTY # include <file.h>\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10-8.h.expect",
    "content": "\n # include <file.h>\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.2-7.h",
    "content": "#include <stdio.h>\n#include \"myprog.h\"\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.2-7.h.expect",
    "content": "<stdio.h>\n\"myprog.h\"\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.2-8.h",
    "content": "#if VERSION == 1\n\t#define INCFILE \"vers1.h\"\n#elif VERSION == 2\n\t#define INCFILE \"vers2.h\" // and so on\n#else\n\t#define INCFILE \"versN.h\"\n#endif\n#include INCFILE\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.2-8.h.expect",
    "content": "\n\n\n\n\n\n\n\"versN.h\"\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.3-4.h",
    "content": "#define hash_hash # ## #\n#define mkstr(a) # a\n#define in_between(a) mkstr(a)\n#define join(c, d) in_between(c hash_hash d)\nchar p[] = join(x, y); // equivalent to\n                       // char p[] = \"x ## y\";\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.3-4.h.expect",
    "content": "\n\n\n\nchar p[] = \"x ## y\";\n\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-3.h",
    "content": "#define TABSIZE 100\nint table[TABSIZE];\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-3.h.expect",
    "content": "\nint table[100];\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-4.h",
    "content": "#define max(a, b) ((a) > (b) ? (a) : (b))\nmax(x, y);\nmax((x), y);\nmax(x, (y));\nmax((x), (y));\nmax((x, 1), y);\nmax((x, (1, 3)), ((y, 4), 2));\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-4.h.expect",
    "content": "\n((x) > (y) ? (x) : (y));\n(((x)) > (y) ? ((x)) : (y));\n((x) > ((y)) ? (x) : ((y)));\n(((x)) > ((y)) ? ((x)) : ((y)));\n(((x, 1)) > (y) ? ((x, 1)) : (y));\n(((x, (1, 3))) > (((y, 4), 2)) ? ((x, (1, 3))) : (((y, 4), 2)));\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-5.h",
    "content": "#define x      3\n#define f(a)   f(x * (a))\n#undef  x      \n#define x      2\n#define g      f\n#define z      z[0]\n#define h      g(~\n#define m(a)   a(w)\n#define w      0,1\n#define t(a)   a\n#define p()    int\n#define q(x)   x\n#define r(x,y) x ## y\n#define str(x) # x\n\nf(y+1) + f(f(z)) % t(t(g)(0) + t)(1);\ng(x+(3,4)-w) | h 5) & m\n\t(f)^m(m);\np() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };\nchar c[2][6] = { str(hello), str() };\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-5.h.expect",
    "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nf(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);\nf(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);\nint i[] = { 1, 23, 4, 5,  };\nchar c[2][6] = { \"hello\", \"\" };\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-6.h",
    "content": "#define str(s) # s\n#define xstr(s) str(s)\n#define debug(s, t) printf(\"x\" # s \"= %d, x\" # t \"= %s\", \\\n\t\tx ## s, x ## t)\n#define INCFILE(n) vers ## n\n#define glue(a, b) a ## b\n#define xglue(a, b) glue(a, b)\n#define HIGHLOW \"hello\"\n#define LOW LOW \", world\"\n\ndebug(1, 2);\nfputs(str(strncmp(\"abc\\0d\", \"abc\", '\\4') // this goes away\n\t\t\t== 0) str(: @\\n), s);\n#include xstr(INCFILE(2).h)\nglue(HIGH, LOW);\nxglue(HIGH, LOW)\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-6.h.expect",
    "content": "\n\n\n\n\n\n\n\n\nprintf(\"x\" \"1\" \"= %d, x\" \"2\" \"= %s\", x1, x2);\nfputs(\"strncmp(\\\"abc\\\\0d\\\", \\\"abc\\\", '\\\\4') == 0\" \": @\\n\", s);\n\"vers2.h\"\n\"hello\";\n\"hello\" \", world\"\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-7.h",
    "content": "#define t(x,y,z) x ## y ## z\nint j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n\tt(10,,), t(,11,), t(,,12), t(,,) };\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-7.h.expect",
    "content": "\nint j[] = { 123, 45, 67, 89,\n10, 11, 12,  };\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-8.h",
    "content": "#define OBJ_LIKE (1-1)\n#define OBJ_LIKE /* white space */ (1-1) /* other */\n#define FUNC_LIKE(a) ( a )\n#define FUNC_LIKE( a ) ( /* note the white space */ \\\n\t\ta /* other stuff on this line\n\t\t*/ )\nok\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-8.h.expect",
    "content": "\n\n\n\nok\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-9.h",
    "content": "#define debug(...) fprintf(stderr, __VA_ARGS__)\n#define showlist(...) puts(#__VA_ARGS__)\n#define report(test, ...) ((test)?puts(#test):\\\n\t\tprintf(__VA_ARGS__))\ndebug(\"Flag\");\ndebug(\"X = %d\\n\", x);\nshowlist(The first, second, and third items.);\nreport(x>y, \"x is %d but y is %d\", x, y);\n"
  },
  {
    "path": "v2/testdata/cpp-expand/example-6.10.3.5-9.h.expect",
    "content": "\n\n\nfprintf(stderr, \"Flag\");\nfprintf(stderr, \"X = %d\\n\", x);\nputs(\"The first, second, and third items.\");\n((x>y)?puts(\"x>y\"): printf(\"x is %d but y is %d\", x, y));\n"
  },
  {
    "path": "v2/testdata/cpp-expand/mustfail/example-6.10.3.5-9a.h",
    "content": "#define OBJ_LIKE (1-1)\n#define OBJ_LIKE (0) // different token sequence\n"
  },
  {
    "path": "v2/testdata/cpp-expand/mustfail/example-6.10.3.5-9b.h",
    "content": "#define OBJ_LIKE (1-1)\n#define OBJ_LIKE (1 - 1) // different white space\n"
  },
  {
    "path": "v2/testdata/cpp-expand/mustfail/example-6.10.3.5-9c.h",
    "content": "#define FUNC_LIKE(a) ( a )\n#define FUNC_LIKE(b) ( a ) // different parameter usage\n"
  },
  {
    "path": "v2/testdata/cpp-expand/mustfail/example-6.10.3.5-9d.h",
    "content": "#define FUNC_LIKE(a) ( a )\n#define FUNC_LIKE(b) ( b ) // different parameter spelling\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/COPYING.LIB",
    "content": "\n                  GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n\t51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations\nbelow.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\f\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it\nbecomes a de-facto standard.  To achieve this, non-free programs must\nbe allowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\f\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control\ncompilation and installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\f\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\f\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at least\n    three years, to give the same user the materials specified in\n    Subsection 6a, above, for a charge no more than the cost of\n    performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\f\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\f\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply, and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License\nmay add an explicit geographical distribution limitation excluding those\ncountries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\f\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\f\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms\nof the ordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.\nIt is safest to attach them to the start of each source file to most\neffectively convey the exclusion of warranty; and each file should\nhave at least the \"copyright\" line and a pointer to where the full\nnotice is found.\n\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or\nyour school, if any, to sign a \"copyright disclaimer\" for the library,\nif necessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James\n  Random Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/COPYING.RUNTIME",
    "content": "GCC RUNTIME LIBRARY EXCEPTION\n\nVersion 3.1, 31 March 2009\n\nCopyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>\n\nEveryone is permitted to copy and distribute verbatim copies of this\nlicense document, but changing it is not allowed.\n\nThis GCC Runtime Library Exception (\"Exception\") is an additional\npermission under section 7 of the GNU General Public License, version\n3 (\"GPLv3\"). It applies to a given file (the \"Runtime Library\") that\nbears a notice placed by the copyright holder of the file stating that\nthe file is governed by GPLv3 along with this Exception.\n\nWhen you use GCC to compile a program, GCC may combine portions of\ncertain GCC header files and runtime libraries with the compiled\nprogram. The purpose of this Exception is to allow compilation of\nnon-GPL (including proprietary) programs to use, in this way, the\nheader files and runtime libraries covered by this Exception.\n\n0. Definitions.\n\nA file is an \"Independent Module\" if it either requires the Runtime\nLibrary for execution after a Compilation Process, or makes use of an\ninterface provided by the Runtime Library, but is not otherwise based\non the Runtime Library.\n\n\"GCC\" means a version of the GNU Compiler Collection, with or without\nmodifications, governed by version 3 (or a specified later version) of\nthe GNU General Public License (GPL) with the option of using any\nsubsequent versions published by the FSF.\n\n\"GPL-compatible Software\" is software whose conditions of propagation,\nmodification and use would permit combination with GCC in accord with\nthe license of GCC.\n\n\"Target Code\" refers to output from any compiler for a real or virtual\ntarget processor architecture, in executable form or suitable for\ninput to an assembler, loader, linker and/or execution\nphase. Notwithstanding that, Target Code does not include data in any\nformat that is used as a compiler intermediate representation, or used\nfor producing a compiler intermediate representation.\n\nThe \"Compilation Process\" transforms code entirely represented in\nnon-intermediate languages designed for human-written code, and/or in\nJava Virtual Machine byte code, into Target Code. Thus, for example,\nuse of source code generators and preprocessors need not be considered\npart of the Compilation Process, since the Compilation Process can be\nunderstood as starting with the output of the generators or\npreprocessors.\n\nA Compilation Process is \"Eligible\" if it is done using GCC, alone or\nwith other GPL-compatible software, or if it is done without using any\nwork based on GCC. For example, using non-GPL-compatible Software to\noptimize any GCC intermediate representations would not qualify as an\nEligible Compilation Process.\n\n1. Grant of Additional Permission.\n\nYou have permission to propagate a work of Target Code formed by\ncombining the Runtime Library with Independent Modules, even if such\npropagation would otherwise violate the terms of GPLv3, provided that\nall Target Code was generated by Eligible Compilation Processes. You\nmay then convey such a combination under terms of your choice,\nconsistent with the licensing of the Independent Modules.\n\n2. No Weakening of GCC Copyleft.\n\nThe availability of this Exception does not imply any general\npresumption that third-party software is unaffected by the copyleft\nrequirements of the license of GCC.\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/COPYING3",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/COPYING3.LIB",
    "content": "\t\t   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions. \n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version. \n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/README",
    "content": "This directory contains the GNU Compiler Collection (GCC).\n\nThe GNU Compiler Collection is free software.  See the files whose\nnames start with COPYING for copying permission.  The manuals, and\nsome of the runtime libraries, are under different terms; see the\nindividual source files for details.\n\nThe directory INSTALL contains copies of the installation information\nas HTML and plain text.  The source of this information is\ngcc/doc/install.texi.  The installation information includes details\nof what is included in the GCC sources and what files GCC installs.\n\nSee the file gcc/doc/gcc.texi (together with other files that it\nincludes) for usage and porting information.  An online readable\nversion of the manual is in the files gcc/doc/gcc.info*.\n\nSee http://gcc.gnu.org/bugs/ for how to report bugs usefully.\n\nCopyright years on GCC source files may be listed using range\nnotation, e.g., 1987-2012, indicating that every year in the range,\ninclusive, is a copyrightable year that could otherwise be listed\nindividually.\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000112-1.c",
    "content": "#include <string.h>\n\nstatic int\nspecial_format (fmt)\n     const char *fmt;\n{\n  return (strchr (fmt, '*') != 0\n          || strchr (fmt, 'V') != 0\n          || strchr (fmt, 'S') != 0\n          || strchr (fmt, 'n') != 0);\n}\n\nmain()\n{\n  if (special_format (\"ee\"))\n    abort ();\n  if (!special_format (\"*e\"))\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000113-1.c",
    "content": "struct x { \n  unsigned x1:1;\n  unsigned x2:2;\n  unsigned x3:3;\n};\n   \nfoobar (int x, int y, int z)\n{\n  struct x a = {x, y, z};\n  struct x b = {x, y, z};\n  struct x *c = &b;\n\n  c->x3 += (a.x2 - a.x1) * c->x2;\n  if (a.x1 != 1 || c->x3 != 5)\n    abort ();\n  exit (0);\n}\n\nmain()\n{\n  foobar (1, 2, 3);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000121-1.c",
    "content": "void big(long long u) { }\n\nvoid doit(unsigned int a,unsigned int b,char *id)\n{\n  big(*id);\n  big(a);\n  big(b);\n}\n\nint main(void)\n{\n  doit(1,1,\"\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000205-1.c",
    "content": "static int f (int a)\n{\n  if (a == 0)\n    return 0;\n  do\n    if (a & 128)\n      return 1;\n  while (f (0));\n  return 0;\n}\n\nint main(void)\n{\n  if (f (~128))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000217-1.c",
    "content": "unsigned short int showbug(unsigned short int *a, unsigned short int *b)\n{\n        *a += *b -8;\n        return (*a >= 8);\n}\n\nint main()\n{\n        unsigned short int x = 0;\n        unsigned short int y = 10;\n\n        if (showbug(&x, &y) != 0)\n\t  abort ();\n\n\texit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000223-1.c",
    "content": "/* Copyright (C) 2000 Free Software Foundation, Inc.\n   Contributed by Nathan Sidwell 23 Feb 2000 <nathan@codesourcery.com> */\n\n/* __alignof__ should never return a non-power of 2\n   eg, sizeof(long double) might be 12, but that means it must be alignable\n   on a 4 byte boundary. */\n\nvoid check (char const *type, int align)\n{\n  if ((align & -align) != align)\n    {\n      abort ();\n    }\n}\n\n#define QUOTE_(s) #s\n#define QUOTE(s) QUOTE_(s)\n\n#define check(t) check(QUOTE(t), __alignof__(t))\n\n// This struct should have an alignment of the lcm of all the types. If one of\n// the base alignments is not a power of two, then A cannot be power of two\n// aligned.\nstruct A\n{\n  char c;\n  signed short ss;\n  unsigned short us;\n  signed int si;\n  unsigned int ui;\n  signed long sl;\n  unsigned long ul;\n  signed long long sll;\n  unsigned long long ull;\n  float f;\n  double d;\n  long double ld;\n  void *dp;\n  void (*fp)();\n};\n\nint main ()\n{\n  check (void);\n  check (char);\n  check (signed short);\n  check (unsigned short);\n  check (signed int);\n  check (unsigned int);\n  check (signed long);\n  check (unsigned long);\n  check (signed long long);\n  check (unsigned long long);\n  check (float);\n  check (double);\n  check (long double);\n  check (void *);\n  check (void (*)());\n  check (struct A);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000224-1.c",
    "content": "int loop_1 = 100;\nint loop_2 = 7;\nint flag = 0;\n\nint test (void)\n{\n    int i;\n    int counter  = 0;\n\n    while (loop_1 > counter) {\n        if (flag & 1) {\n            for (i = 0; i < loop_2; i++) {\n                counter++;\n            }\n        }\n        flag++;\n    }\n    return 1;\n}\n\nint main()\n{\n    if (test () != 1)\n      abort ();\n    \n    exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000225-1.c",
    "content": "int main ()\n{\n    int nResult;\n    int b=0;\n    int i = -1;\n\n    do\n    {\n     if (b!=0) {\n       abort ();\n       nResult=1;\n     } else {\n      nResult=0;\n     }\n     i++;\n     b=(i+2)*4;\n    } while (i < 0);\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000227-1.c",
    "content": "static const unsigned char f[] = \"\\0\\377\";\nstatic const unsigned char g[] = \"\\0\";\n\nint main(void)\n{\n  if (sizeof f != 3 || sizeof g != 3)\n    abort ();\n  if (f[0] != g[0])\n    abort ();\n  if (f[1] != g[1])\n    abort ();\n  if (f[2] != g[2])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000313-1.c",
    "content": "unsigned int buggy (unsigned int *param)\n{\n  unsigned int accu, zero = 0, borrow;\n  accu    = - *param;\n  borrow  = - (accu > zero);\n  *param += accu;\n  return borrow;\n}\n\nint main (void)\n{\n  unsigned int param  = 1;\n  unsigned int borrow = buggy (&param);\n\n  if (param != 0)\n    abort ();\n  if (borrow + 1 != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000314-1.c",
    "content": "int main ()\n{\n  long winds = 0;\n\n  while (winds != 0)\n    {\n      if (*(char *) winds)\n\tbreak;\n    }\n\n  if (winds == 0 || winds != 0 || *(char *) winds)\n    exit (0);\n\n  abort ();\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000314-2.c",
    "content": "typedef unsigned long long uint64;\nconst uint64 bigconst = 1ULL << 34;\n\nint a = 1;\n\nstatic\nuint64 getmask(void)\n{\n    if (a)\n      return bigconst;\n    else\n      return 0;\n}\n\nmain()\n{\n    uint64 f = getmask();\n    if (sizeof (long long) == 8\n\t&& f != bigconst) abort ();\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000314-3.c",
    "content": "extern void abort (void);\n\nstatic char arg0[] = \"arg0\";\nstatic char arg1[] = \"arg1\";\n\nstatic void attr_rtx\t\t(char *, char *);\nstatic char *attr_string        (char *);\nstatic void attr_eq\t\t(char *, char *);\n\nstatic void \nattr_rtx (char *varg0, char *varg1)\n{\n  if (varg0 != arg0)\n    abort ();\n\n  if (varg1 != arg1)\n    abort ();\n\n  return;\n}\n\nstatic void \nattr_eq (name, value)\n     char *name, *value;\n{\n  return attr_rtx (attr_string (name),\n\t\t   attr_string (value));\n}\n\nstatic char *\nattr_string (str)\n     char *str;\n{\n  return str;\n}\n\nint main()\n{\n  attr_eq (arg0, arg1);\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000402-1.c",
    "content": "#include <limits.h>\n\n#if ULONG_LONG_MAX != 18446744073709551615ull && ULONG_MAX != 18446744073709551615ull\nint main(void) { exit (0); }\n#else\n#if ULONG_MAX != 18446744073709551615ull\ntypedef unsigned long long ull;\n#else\ntypedef unsigned long ull;\n#endif\n\n#include <stdio.h>\n\nvoid checkit(int);\n\nmain () {\n    const ull a = 0x1400000000ULL;\n    const ull b = 0x80000000ULL;\n    const ull c = a/b;\n    const ull d = 0x1400000000ULL / 0x80000000ULL;\n\n    checkit ((int) c);\n    checkit ((int) d);\n\n    exit(0);\n}\n\nvoid checkit (int a)\n{\n  if (a != 40)\n    abort();\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000403-1.c",
    "content": "extern unsigned long aa[], bb[];\n\nint seqgt (unsigned long a, unsigned short win, unsigned long b);\n\nint seqgt2 (unsigned long a, unsigned short win, unsigned long b);\n\nmain()\n{\n  if (! seqgt (*aa, 0x1000, *bb) || ! seqgt2 (*aa, 0x1000, *bb))\n    abort ();\n\n  exit (0);\n}\n\nint\nseqgt (unsigned long a, unsigned short win, unsigned long b)\n{\n  return (long) ((a + win) - b) > 0;\n}\n\nint\nseqgt2 (unsigned long a, unsigned short win, unsigned long b)\n{\n  long l = ((a + win) - b);\n  return l > 0;\n}\n\nunsigned long aa[] = { (1UL << (sizeof (long) * 8 - 1)) - 0xfff };\nunsigned long bb[] = { (1UL << (sizeof (long) * 8 - 1)) - 0xfff };\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-1.c",
    "content": "short int i = -1;\nconst char * const wordlist[207];\n\nconst char * const *\nfoo(void)\n{\n  register const char * const *wordptr = &wordlist[207u + i];\n  return wordptr;\n}\n\nint\nmain()\n{\n  if (foo() != &wordlist[206])\n    abort ();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-2.c",
    "content": "int f(int a,int *y)\n{\n  int x = a;\n\n  if (a==0)\n    return *y;\n\n  return f(a-1,&x);\n}\n\nint main(int argc,char **argv)\n{\n  if (f (100, (int *) 0) != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-3.c",
    "content": "typedef struct {\n  char y;\n  char x[32];\n} X;\n\nint z (void)\n{\n  X xxx;\n  xxx.x[0] =\n  xxx.x[31] = '0';\n  xxx.y = 0xf;\n  return f (xxx, xxx);\n}\n\nint main (void)\n{\n  int val;\n\n  val = z ();\n  if (val != 0x60)\n    abort ();\n  exit (0);\n}\n\nint f(X x, X y)\n{\n  if (x.y != y.y)\n    return 'F';\n\n  return x.x[0] + y.x[0];\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-4.c",
    "content": "  void f(int i, int j, int radius, int width, int N)\n  {\n    const int diff   = i-radius;\n    const int lowk   = (diff>0 ? diff : 0 );\n    int k;\n  \n    for(k=lowk; k<= 2; k++){\n      int idx = ((k-i+radius)*width-j+radius);\n      if (idx < 0)\n\tabort ();\n    }\n  \n    for(k=lowk; k<= 2; k++);\n  }\n  \n  \n  int main(int argc, char **argv)\n  {\n    int exc_rad=2;\n    int N=8;\n    int i;\n    for(i=1; i<4; i++)\n      f(i,1,exc_rad,2*exc_rad + 1, N);\n    exit (0);\n  } \n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-5.c",
    "content": "int main( void ) {\n    struct {\n\tint node;\n\tint type;\n    } lastglob[1] = { { 0   , 1  } };\n\n    if (lastglob[0].node != 0 || lastglob[0].type != 1)\n      abort ();\n    exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000412-6.c",
    "content": "unsigned bug (unsigned short value, unsigned short *buffer,\n              unsigned short *bufend);\n\nunsigned short buf[] = {1, 4, 16, 64, 256};\nint main()\n{\n  if (bug (512, buf, buf + 3) != 491)\n    abort ();\n\n  exit (0);\n}\n\nunsigned\nbug (unsigned short value, unsigned short *buffer, unsigned short *bufend)\n{\n  unsigned short *tmp;\n\n  for (tmp = buffer; tmp < bufend; tmp++)\n    value -= *tmp;\n\n  return value;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000419-1.c",
    "content": "struct foo { int a, b, c; };\n\nvoid\nbrother (int a, int b, int c)\n{\n  if (a)\n    abort ();\n}\n\nvoid\nsister (struct foo f, int b, int c)\n{\n  brother ((f.b == b), b, c);\n}\n\nint\nmain ()\n{\n  struct foo f = { 7, 8, 9 };\n  sister (f, 1, 2);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000422-1.c",
    "content": "int ops[13] =\n{\n  11, 12, 46, 3, 2, 2, 3, 2, 1, 3, 2, 1, 2\n};\n\nint correct[13] = \n{\n  46, 12, 11, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1\n};\n\nint num = 13;\n\nint main()\n{\n  int i;\n\n  for (i = 0; i < num; i++)\n    {\n      int j;\n\n      for (j = num - 1; j > i; j--)\n        {\n          if (ops[j-1] < ops[j])\n            {\n              int op = ops[j];\n              ops[j] = ops[j-1];\n              ops[j-1] = op;\n            }\n        }\n    }\n\n\n  for (i = 0; i < num; i++)\n    if (ops[i] != correct[i])\n      abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000503-1.c",
    "content": "unsigned long\nsub (int a)\n{\n  return ((0 > a - 2) ? 0 : a - 2) * sizeof (long);\n}\n\nmain ()\n{\n  if (sub (0) != 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000511-1.c",
    "content": "void f (int value, int expect)\n{\n  if (value != expect)\n    abort ();\n}\n\nint main()\n{\n  int a = 7, b = 6, c = 4, d = 7, e = 2;\n\t\n  f (a||b%c,   1);\n  f (a?b%c:0,  2);\n  f (a=b%c,    2);\n  f (a*=b%c,   4);\n  f (a/=b%c,   2);\n  f (a%=b%c,   0);\n  f (a+=b%c,   2);\n  f (d||c&&e,  1);\n  f (d?c&&e:0, 1);\n  f (d=c&&e,   1);\n  f (d*=c&&e,  1);\n  f (d%=c&&e,  0);\n  f (d+=c&&e,  1);\n  f (d-=c&&e,  0);\n  f (d||c||e,  1);\n  f (d?c||e:0, 0);\n  f (d=c||e,   1);\n  f (d*=c||e,  1);\n  f (d%=c||e,  0);\n  f (d+=c||e,  1);\n  f (d-=c||e,  0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000519-1.c",
    "content": "#include <stdarg.h>\n\nint\nbar (int a, va_list ap)\n{\n  int b;\n\n  do\n    b = va_arg (ap, int);\n  while (b > 10);\n\n  return a + b;\n}\n\nint\nfoo (int a, ...)\n{\n  va_list ap;\n\n  va_start (ap, a);\n  return bar (a, ap);\n}\n\nint\nmain ()\n{\n  if (foo (1, 2, 3) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000519-2.c",
    "content": "long x = -1L;\n\nint main()\n{\n  long b = (x != -1L);\n\n  if (b)\n    abort();\n\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000523-1.c",
    "content": "int\nmain (void)\n{\n  long long   x;\n  int         n;\n\n  if (sizeof (long long) < 8)\n    exit (0);\n  \n  n = 9;\n  x = (((long long) n) << 55) / 0xff; \n\n  if (x == 0)\n    abort ();\n\n  x = (((long long) 9) << 55) / 0xff;\n\n  if (x == 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000528-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* Contributed by Alexandre Oliva <aoliva@cygnus.com> */\n\nunsigned long l = (unsigned long)-2;\nunsigned short s;\n\nint main () {\n  long t = l;\n  s = t;\n  if (s != (unsigned short)-2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000603-1.c",
    "content": "/* It is not clear whether this test is conforming.  See DR#236\n   http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_236.htm.  However,\n   there seems to be consensus that the presence of a union to aggregate\n   struct s1 and struct s2 should make it conforming.  */\nstruct s1 { double d; };\nstruct s2 { double d; };\nunion u { struct s1 x; struct s2 y; };\n\ndouble f(struct s1 *a, struct s2 *b)\n{\n  a->d = 1.0;\n  return b->d + 1.0;\n}\n\nint main()\n{\n  union u a;\n  a.x.d = 0.0;\n  if (f (&a.x, &a.y) != 2.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000605-1.c",
    "content": "typedef struct _RenderInfo RenderInfo;\nstruct _RenderInfo\n{\n    int y;\n    float scaley;\n    int src_y;\n};\n\nstatic void bar(void) { }\n\nstatic int\nrender_image_rgb_a (RenderInfo * info)\n{\n  int y, ye;\n  float error;\n  float step;\n\n  y = info->y;\n  ye = 256;\n\n  step = 1.0 / info->scaley;\n\n  error = y * step;\n  error -= ((int) error) - step;\n\n  for (; y < ye; y++) {\n      if (error >= 1.0) {\n\t  info->src_y += (int) error;\n\t  error -= (int) error;\n\t  bar();\n      }\n      error += step;\n  }\n  return info->src_y;\n}\n\nint main (void)\n{\n    RenderInfo info;\n\n    info.y = 0;\n    info.src_y = 0;\n    info.scaley = 1.0;\n\n    if (render_image_rgb_a(&info) != 256)\n       abort ();\n    exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000605-2.c",
    "content": "struct F { int i; };\n\nvoid f1(struct F *x, struct F *y)\n{\n  int timeout = 0;\n  for (; ((const struct F*)x)->i < y->i ; x->i++)\n    if (++timeout > 5)\n      abort ();\n}\n\nmain()\n{\n  struct F x, y;\n  x.i = 0;\n  y.i = 1;\n  f1 (&x, &y);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000605-3.c",
    "content": "struct F { int x; int y; };\n\nint main()\n{\n  int timeout = 0;\n  int x = 0;\n  while (1)\n    {\n      const struct F i = { x++, };\n      if (i.x > 0)\n\tbreak;\n      if (++timeout > 5)\n\tgoto die;\n    }\n  return 0;\n die:\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000622-1.c",
    "content": "long foo(long a, long b, long c)\n{\n  if (a != 12 || b != 1 || c != 11)\n    abort();\n  return 0;\n}\nlong bar (long a, long b)\n{\n  return b;\n}\nvoid baz (long a, long b, void *c)\n{\n  long d;\n  d = (long)c;\n  foo(d, bar (a, 1), b);\n}\nint main()\n{\n  baz (10, 11, (void *)12);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000703-1.c",
    "content": "void abort(void);\nvoid exit(int);\nstruct baz \n{\n  char a[17];\n  char b[3];\n  unsigned int c;\n  unsigned int d;\n};\n\nvoid foo(struct baz *p, unsigned int c, unsigned int d)\n{\n  __builtin_memcpy (p->b, \"abc\", 3);\n  p->c = c;\n  p->d = d;\n}\n\nvoid bar(struct baz *p, unsigned int c, unsigned int d)\n{\n  ({ void *s = (p);\n     __builtin_memset (s, '\\0', sizeof (struct baz));\n     s; });\n  __builtin_memcpy (p->a, \"01234567890123456\", 17);\n  __builtin_memcpy (p->b, \"abc\", 3);\n  p->c = c;\n  p->d = d;\n}\n\nint main()\n{\n  struct baz p;\n  foo(&p, 71, 18);\n  if (p.c != 71 || p.d != 18)\n    abort();\n  bar(&p, 59, 26);\n  if (p.c != 59 || p.d != 26)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000706-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c, d, e;\n};\n\nvoid bar(struct baz *x, int f, int g, int h, int i, int j)\n{\n  if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||\n      f != 6 || g != 7 || h != 8 || i != 9 || j != 10)\n    abort();\n}\n\nvoid foo(struct baz x, char **y)\n{\n  bar(&x,6,7,8,9,10);\n}\n\nint main()\n{\n  struct baz x;\n\n  x.a = 1;\n  x.b = 2;\n  x.c = 3;\n  x.d = 4;\n  x.e = 5;\n  foo(x,(char **)0);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000706-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c, d, e;\n};\n\nvoid bar(struct baz *x, int f, int g, int h, int i, int j)\n{\n  if (x->a != 1 || x->b != 2 || x->c != 3 || x->d != 4 || x->e != 5 ||\n      f != 6 || g != 7 || h != 8 || i != 9 || j != 10)\n    abort();\n}\n\nvoid foo(char *z, struct baz x, char *y)\n{\n  bar(&x,6,7,8,9,10);\n}\n\nint main()\n{\n  struct baz x;\n\n  x.a = 1;\n  x.b = 2;\n  x.c = 3;\n  x.d = 4;\n  x.e = 5;\n  foo((char *)0,x,(char *)0);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000706-3.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nint c;\n\nvoid baz(int *p)\n{\n  c = *p;\n}\n\nvoid bar(int b)\n{\n  if (c != 1 || b != 2)\n    abort();\n}\n\nvoid foo(int a, int b)\n{\n  baz(&a);\n  bar(b);\n}\n\nint main()\n{\n  foo(1, 2);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000706-4.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nint *c;\n\nvoid bar(int b)\n{\n  if (*c != 1 || b != 2)\n    abort();\n}\n\nvoid foo(int a, int b)\n{\n  c = &a;\n  bar(b);\n}\n\nint main()\n{\n  foo(1, 2);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000706-5.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz { int a, b, c; };\n\nstruct baz *c;\n\nvoid bar(int b)\n{\n  if (c->a != 1 || c->b != 2 || c->c != 3 || b != 4)\n    abort();\n}\n\nvoid foo(struct baz a, int b)\n{\n  c = &a;\n  bar(b);\n}\n\nint main()\n{\n  struct baz a;\n  a.a = 1;\n  a.b = 2;\n  a.c = 3;\n  foo(a, 4);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000707-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nstruct baz {\n  int a, b, c;\n};\n\nvoid\nfoo (int a, int b, int c)\n{\n  if (a != 4)\n    abort ();\n}\n\nvoid\nbar (struct baz x, int b, int c)\n{\n  foo (x.b, b, c);\n}\n\nint\nmain ()\n{\n  struct baz x = { 3, 4, 5 };\n  bar (x, 1, 2);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000715-1.c",
    "content": "void abort(void);\nvoid exit(int);\n\nvoid\ntest1(void)\n{\n  int x = 3, y = 2;\n\n  if ((x < y ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest2(void)\n{\n  int x = 3, y = 2, z;\n\n  z = (x < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest3(void)\n{\n  int x = 3, y = 2;\n  int xx = 3, yy = 2;\n\n  if ((xx < yy ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nint x, y;\n\nstatic void\ninit_xy(void)\n{\n  x = 3;\n  y = 2;\n}\n\nvoid\ntest4(void)\n{\n  init_xy();\n  if ((x < y ? x++ : y++) != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest5(void)\n{\n  int z;\n\n  init_xy();\n  z = (x < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nvoid\ntest6(void)\n{\n  int xx = 3, yy = 2;\n  int z;\n\n  init_xy();\n  z = (xx < y) ? x++ : y++;\n  if (z != 2)\n    abort ();\n\n  if (x != 3)\n    abort ();\n\n  if (y != 3)\n    abort ();\n}\n\nint\nmain(){\n  test1 ();\n  test2 ();\n  test3 ();\n  test4 ();\n  test5 ();\n  test6 ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000715-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nunsigned int foo(unsigned int a)\n{\n  return ((unsigned char)(a + 1)) * 4;\n}\n\nint main(void)\n{\n  if (foo((unsigned char)~0))\n    abort ();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000717-1.c",
    "content": "typedef struct trio { int a, b, c; } trio;\n\nint\nbar (int i, trio t)\n{\n  if (t.a == t.b || t.a == t.c)\n    abort ();\n}\n\nint\nfoo (trio t, int i)\n{\n  return bar (i, t);\n}\n\nmain ()\n{\n  trio t = { 1, 2, 3 };\n\n  foo (t, 4);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000717-2.c",
    "content": "static void\ncompare (long long foo)\n{\n  if (foo < 4294967297LL)\n    abort();\n}\nint main(void)\n{\n  compare (8589934591LL);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000717-3.c",
    "content": "int c = -1;\n\nfoo (p)\n     int *p;\n{\n  int x;\n  int a;\n\n  a = p[0];\n  x = a + 5;\n  a = c;\n  p[0] = x - 15;\n  return a;\n}\n\nint main()\n{\n   int b = 1;\n   int a = foo(&b);\n\n   if (a != -1 || b != (1 + 5 - 15))\n     abort ();\n\n   exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000717-4.c",
    "content": "/* Extracted from gas.  Incorrectly generated non-pic code at -O0 for\n   IA-64, which produces linker errors on some operating systems.  */\n\nstruct\n{\n  int offset;\n  struct slot\n  {\n    int field[6];\n  }\n  slot[4];\n} s;\n\nint\nx ()\n{\n  int toggle = 0;\n  int r = s.slot[0].field[!toggle];\n  return r;\n}\n\nint\nmain ()\n{\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000717-5.c",
    "content": "typedef struct trio { int a, b, c; } trio;\n\nint\nbar (int i, int j, int k, trio t)\n{\n  if (t.a != 1 || t.b != 2 || t.c != 3 ||\n      i != 4 || j != 5 || k != 6)\n    abort ();\n}\n\nint\nfoo (trio t, int i, int j, int k)\n{\n  return bar (i, j, k, t);\n}\n\nmain ()\n{\n  trio t = { 1, 2, 3 };\n\n  foo (t, 4, 5, 6);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000722-1.c",
    "content": "struct s { char *p; int t; };\n\nextern void bar (void);\nextern void foo (struct s *);\n\nint main(void)\n{\n  bar ();\n  bar ();\n  exit (0);\n}\n\nvoid \nbar (void)\n{\n  foo (& (struct s) { \"hi\", 1 });\n}\n\nvoid foo (struct s *p)\n{\n  if (p->t != 1)\n    abort();\n  p->t = 2;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000726-1.c",
    "content": "void adjust_xy (short *, short *);\n\nstruct adjust_template\n{\n  short kx_x;\n  short kx_y;\n  short kx;\n  short kz;\n};\n\nstatic struct adjust_template adjust = {0, 0, 1, 1};\n\nmain ()\n{\n  short x = 1, y = 1;\n\n  adjust_xy (&x, &y);\n\n  if (x != 1)\n    abort ();\n\n  exit (0);\n}\n\nvoid\nadjust_xy (x, y)\n     short  *x;\n     short  *y;\n{\n  *x = adjust.kx_x * *x + adjust.kx_y * *y + adjust.kx;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000731-1.c",
    "content": "double\nfoo (void)\n{\n  return 0.0;\n}\n\nvoid\ndo_sibcall (void)\n{\n  (void) foo ();\n}\n\nint\nmain (void)\n{\n   double x;\n\n   for (x = 0; x < 20; x++)\n      do_sibcall ();\n   if (!(x >= 10))\n      abort ();\n   exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000731-2.c",
    "content": "int\nmain()\n{\n    int i = 1;\n    int j = 0;\n\n    while (i != 1024 || j <= 0) {\n        i *= 2;\n        ++ j;\n    }\n\n    if (j != 10)\n      abort ();\n\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000801-1.c",
    "content": "extern void abort(void);\nextern void exit(int);\n\nvoid\nfoo (char *bp, unsigned n)\n{\n  register char c;\n  register char *ep = bp + n;\n  register char *sp;\n\n  while (bp < ep)\n    {\n      sp = bp + 3;\n      c = *sp;\n      *sp = *bp;\n      *bp++ = c;\n      sp = bp + 1;\n      c = *sp;\n      *sp = *bp;\n      *bp++ = c;\n      bp += 2;\n    }\n}\n\nint main(void)\n{\n  int one = 1;\n\n  if (sizeof(int) != 4 * sizeof(char))\n    exit(0);\n\n  foo((char *)&one, sizeof(one));\n  foo((char *)&one, sizeof(one));\n\n  if (one != 1)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000801-2.c",
    "content": "extern void abort(void);\nextern void exit(int);\nint bar(void);\nint baz(void);\n\nstruct foo {\n  struct foo *next;\n};\n\nstruct foo *test(struct foo *node)\n{\n  while (node) {\n    if (bar() && !baz())\n      break;\n    node = node->next;\n  }\n  return node;\n}\n\nint bar (void)\n{\n  return 0;\n}\n\nint baz (void)\n{\n  return 0;\n}\n\nint main(void)\n{\n  struct foo a, b, *c;\n\n  a.next = &b;\n  b.next = (struct foo *)0;\n  c = test(&a);\n  if (c)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000801-3.c",
    "content": "/* Origin: PR c/92 from Simon Marlow <t-simonm@microsoft.com>, adapted\n   to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n\ntypedef struct { } empty;\n\ntypedef struct {\n  int i;\n  empty e;\n  int i2;\n} st;\n\nst s = { .i = 0, .i2 = 1 };\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (s.i2 == 1)\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000801-4.c",
    "content": "/* Origin: PR c/128 from Martin Sebor <sebor@roguewave.com>, adapted\n   as a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n/* Character arrays initialized by a string literal must have\n   uninitialized elements zeroed.  This isn't clear in the 1990\n   standard, but was fixed in TC2 and C99; see DRs #060, #092.\n*/\nextern void abort (void);\n\nint\nfoo (void)\n{\n  char s[2] = \"\";\n  return 0 == s[1];\n}\n\nchar *t;\n\nint\nmain (void)\n{\n  {\n    char s[] = \"x\";\n    t = s;\n  }\n  if (foo ())\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000808-1.c",
    "content": "typedef struct {\n  long int p_x, p_y;\n} Point;\n\nvoid\nbar ()\n{\n}\n\nvoid\nf (p0, p1, p2, p3, p4, p5)\n     Point p0, p1, p2, p3, p4, p5;\n{\n  if (p0.p_x != 0 || p0.p_y != 1\n      || p1.p_x != -1 || p1.p_y != 0\n      || p2.p_x != 1 || p2.p_y != -1\n      || p3.p_x != -1 || p3.p_y != 1\n      || p4.p_x != 0 || p4.p_y != -1\n      || p5.p_x != 1 || p5.p_y != 0)\n    abort ();\n}\n\nvoid\nfoo ()\n{\n  Point p0, p1, p2, p3, p4, p5;\n\n  bar();\n  \n  p0.p_x = 0;\n  p0.p_y = 1;\n\n  p1.p_x = -1;\n  p1.p_y = 0;\n\n  p2.p_x = 1;\n  p2.p_y = -1;\n\n  p3.p_x = -1;\n  p3.p_y = 1;\n\n  p4.p_x = 0;\n  p4.p_y = -1;\n\n  p5.p_x = 1;\n  p5.p_y = 0;\n\n  f (p0, p1, p2, p3, p4, p5);\n}\n\nint\nmain()\n{\n  foo();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000815-1.c",
    "content": "struct table_elt\n{\n  void *exp;\n  struct table_elt *next_same_hash;\n  struct table_elt *prev_same_hash;\n  struct table_elt *next_same_value;\n  struct table_elt *prev_same_value;\n  struct table_elt *first_same_value;\n  struct table_elt *related_value;\n  int cost;\n  int mode;\n  char in_memory;\n  char in_struct;\n  char is_const;\n  char flag;\n};\n\nstruct write_data\n{\n  int sp : 1;\t\t\t \n  int var : 1;\t\t\t \n  int nonscalar : 1;\t\t \n  int all : 1;\t\t\t \n};\n\nint cse_rtx_addr_varies_p(void *);\nvoid remove_from_table(struct table_elt *, int);\nstatic struct table_elt *table[32];\n\nvoid\ninvalidate_memory (writes)\n     struct write_data *writes;\n{\n  register int i;\n  register struct table_elt *p, *next;\n  int all = writes->all;\n  int nonscalar = writes->nonscalar;\n\n  for (i = 0; i < 31; i++)\n    for (p = table[i]; p; p = next)\n      {\n\tnext = p->next_same_hash;\n\tif (p->in_memory\n\t    && (all\n\t\t|| (nonscalar && p->in_struct)\n\t\t|| cse_rtx_addr_varies_p (p->exp)))\n\t  remove_from_table (p, i);\n      }\n}\n\nint cse_rtx_addr_varies_p(void *x) { return 0; }\nvoid remove_from_table(struct table_elt *x, int y) { abort (); }\n\nint\nmain()\n{\n  struct write_data writes;\n  struct table_elt elt;\n\n  __builtin_memset(&elt, 0, sizeof(elt));\n  elt.in_memory = 1;\n  table[0] = &elt;\n\n  __builtin_memset(&writes, 0, sizeof(writes));\n  writes.var = 1;\n  writes.nonscalar = 1;\n\n  invalidate_memory(&writes);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000818-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   by Manfred Hollstein <manfredh@redhat.com>  */\n\nvoid *temporary_obstack;\n\nstatic int input (void);\nstatic int ISALNUM (int ch);\nstatic void obstack_1grow (void **ptr, int ch);\n\nint yylex (void);\nint main (void);\n\nint main (void)\n{\n  int ch = yylex ();\n\n  exit (0);\n}\n\nint yylex (void)\n{\n  int ch;\n\n#ifndef WORK_AROUND\n  for (;;)\n    {\n      ch = input ();\n      if (ISALNUM (ch))\n        obstack_1grow (&temporary_obstack, ch);\n      else if (ch != '_')\n        break;\n    }\n#else\n  do\n    {\n      ch = input ();\n      if (ISALNUM (ch))\n        obstack_1grow (&temporary_obstack, ch);\n    } while (ch == '_');\n#endif\n\n  return ch;\n}\n\nstatic int input (void)\n{\n  return 0;\n}\n\nstatic int ISALNUM (int ch)\n{\n  return ((ch >= 'A' && ch <= 'Z')\n\t  || (ch >= 'a' && ch <= 'z')\n\t  || (ch >= '0' && ch <= '0'));\n}\n\nstatic void obstack_1grow (void **ptr, int ch)\n{\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000819-1.c",
    "content": "int a[2] = { 2, 0 };\n\nvoid foo(int *sp, int cnt)\n{\n  int *p, *top;\n\n  top = sp; sp -= cnt;\n\n  for(p = sp; p <= top; p++)\n    if (*p < 2) exit(0);\n}\n\nint main()\n{\n  foo(a + 1, 1);\n  abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000822-1.c",
    "content": "#ifndef NO_TRAMPOLINES\nint f0(int (*fn)(int *), int *p)\n{\n  return (*fn) (p);\n}\n\nint f1(void)\n{\n  int i = 0;\n\n  int f2(int *p)\n  {\n    i = 1;\n    return *p + 1;\n  }\n\n  return f0(f2, &i);\n}\n#endif\n\nint main()\n{\n#ifndef NO_TRAMPOLINES\n  if (f1() != 2)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000910-1.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* by Alexandre Oliva <aoliva@redhat.com> */\n\n#include <stdlib.h>\n\nvoid bar (int);\nvoid foo (int *);\n\nint main () {\n  static int a[] = { 0, 1, 2 };\n  int *i = &a[sizeof(a)/sizeof(*a)];\n  \n  while (i-- > a)\n    foo (i);\n\n  exit (0);\n}\n\nvoid baz (int, int);\n\nvoid bar (int i) { baz (i, i); }\nvoid foo (int *i) { bar (*i); }\n\nvoid baz (int i, int j) {\n  if (i != j)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000910-2.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation  */\n/* by Alexandre Oliva <aoliva@redhat.com> */\n\n#include <stdlib.h>\n#include <string.h>\n\nchar *list[] = { \"*\", \"e\" };\n\nstatic int bar (const char *fmt) {\n  return (strchr (fmt, '*') != 0);\n}\n\nstatic void foo () {\n  int i;\n  for (i = 0; i < sizeof (list) / sizeof (*list); i++) {\n    const char *fmt = list[i];\n    if (bar (fmt))\n      continue;\n    if (i == 0)\n      abort ();\n    else\n      exit (0);\n  }\n}\n\nint main () {\n  foo ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000914-1.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\n\nenum tree_code {\nERROR_MARK,\nIDENTIFIER_NODE,\nOP_IDENTIFIER,\nTREE_LIST,\nTREE_VEC,\nBLOCK,\nVOID_TYPE,\nINTEGER_TYPE,\nREAL_TYPE,\nCOMPLEX_TYPE,\nVECTOR_TYPE,\nENUMERAL_TYPE,\nBOOLEAN_TYPE,\nCHAR_TYPE,\nPOINTER_TYPE,\nOFFSET_TYPE,\nREFERENCE_TYPE,\nMETHOD_TYPE,\nFILE_TYPE,\nARRAY_TYPE,\nSET_TYPE,\nRECORD_TYPE,\nUNION_TYPE,\nQUAL_UNION_TYPE,\nFUNCTION_TYPE,\nLANG_TYPE,\nINTEGER_CST,\nREAL_CST,\nCOMPLEX_CST,\nSTRING_CST,\nFUNCTION_DECL,\nLABEL_DECL,\nCONST_DECL,\nTYPE_DECL,\nVAR_DECL,\nPARM_DECL,\nRESULT_DECL,\nFIELD_DECL,\nNAMESPACE_DECL,\nCOMPONENT_REF,\nBIT_FIELD_REF,\nINDIRECT_REF,\nBUFFER_REF,\nARRAY_REF,\nCONSTRUCTOR,\nCOMPOUND_EXPR,\nMODIFY_EXPR,\nINIT_EXPR,\nTARGET_EXPR,\nCOND_EXPR,\nBIND_EXPR,\nCALL_EXPR,\nMETHOD_CALL_EXPR,\nWITH_CLEANUP_EXPR,\nCLEANUP_POINT_EXPR,\nPLACEHOLDER_EXPR,\nWITH_RECORD_EXPR,\nPLUS_EXPR,\nMINUS_EXPR,\nMULT_EXPR,\nTRUNC_DIV_EXPR,\nCEIL_DIV_EXPR,\nFLOOR_DIV_EXPR,\nROUND_DIV_EXPR,\nTRUNC_MOD_EXPR,\nCEIL_MOD_EXPR,\nFLOOR_MOD_EXPR,\nROUND_MOD_EXPR,\nRDIV_EXPR,\nEXACT_DIV_EXPR,\nFIX_TRUNC_EXPR,\nFIX_CEIL_EXPR,\nFIX_FLOOR_EXPR,\nFIX_ROUND_EXPR,\nFLOAT_EXPR,\nEXPON_EXPR,\nNEGATE_EXPR,\nMIN_EXPR,\nMAX_EXPR,\nABS_EXPR,\nFFS_EXPR,\nLSHIFT_EXPR,\nRSHIFT_EXPR,\nLROTATE_EXPR,\nRROTATE_EXPR,\nBIT_IOR_EXPR,\nBIT_XOR_EXPR,\nBIT_AND_EXPR,\nBIT_ANDTC_EXPR,\nBIT_NOT_EXPR,\nTRUTH_ANDIF_EXPR,\nTRUTH_ORIF_EXPR,\nTRUTH_AND_EXPR,\nTRUTH_OR_EXPR,\nTRUTH_XOR_EXPR,\nTRUTH_NOT_EXPR,\nLT_EXPR,\nLE_EXPR,\nGT_EXPR,\nGE_EXPR,\nEQ_EXPR,\nNE_EXPR,\nUNORDERED_EXPR,\nORDERED_EXPR,\nUNLT_EXPR,\nUNLE_EXPR,\nUNGT_EXPR,\nUNGE_EXPR,\nUNEQ_EXPR,\nIN_EXPR,\nSET_LE_EXPR,\nCARD_EXPR,\nRANGE_EXPR,\nCONVERT_EXPR,\nNOP_EXPR,\nNON_LVALUE_EXPR,\nSAVE_EXPR,\nUNSAVE_EXPR,\nRTL_EXPR,\nADDR_EXPR,\nREFERENCE_EXPR,\nENTRY_VALUE_EXPR,\nCOMPLEX_EXPR,\nCONJ_EXPR,\nREALPART_EXPR,\nIMAGPART_EXPR,\nPREDECREMENT_EXPR,\nPREINCREMENT_EXPR,\nPOSTDECREMENT_EXPR,\nPOSTINCREMENT_EXPR,\nVA_ARG_EXPR,\nTRY_CATCH_EXPR,\nTRY_FINALLY_EXPR,\nGOTO_SUBROUTINE_EXPR,\nPOPDHC_EXPR,\nPOPDCC_EXPR,\nLABEL_EXPR,\nGOTO_EXPR,\nRETURN_EXPR,\nEXIT_EXPR,\nLOOP_EXPR,\nLABELED_BLOCK_EXPR,\nEXIT_BLOCK_EXPR,\nEXPR_WITH_FILE_LOCATION,\nSWITCH_EXPR,\n  LAST_AND_UNUSED_TREE_CODE\n};\ntypedef union tree_node *tree;\nstruct tree_common\n{\n  union tree_node *chain;\n  union tree_node *type;\n  enum tree_code code : 8;\n  unsigned side_effects_flag : 1;\n  unsigned constant_flag : 1;\n  unsigned permanent_flag : 1;\n  unsigned addressable_flag : 1;\n  unsigned volatile_flag : 1;\n  unsigned readonly_flag : 1;\n  unsigned unsigned_flag : 1;\n  unsigned asm_written_flag: 1;\n  unsigned used_flag : 1;\n  unsigned nothrow_flag : 1;\n  unsigned static_flag : 1;\n  unsigned public_flag : 1;\n  unsigned private_flag : 1;\n  unsigned protected_flag : 1;\n  unsigned bounded_flag : 1;\n  unsigned lang_flag_0 : 1;\n  unsigned lang_flag_1 : 1;\n  unsigned lang_flag_2 : 1;\n  unsigned lang_flag_3 : 1;\n  unsigned lang_flag_4 : 1;\n  unsigned lang_flag_5 : 1;\n  unsigned lang_flag_6 : 1;\n};\nunion tree_node\n{\n  struct tree_common common;\n };\nenum c_tree_code {\n  C_DUMMY_TREE_CODE = LAST_AND_UNUSED_TREE_CODE,\nSRCLOC,\nSIZEOF_EXPR,\nARROW_EXPR,\nALIGNOF_EXPR,\nEXPR_STMT,\nCOMPOUND_STMT,\nDECL_STMT,\nIF_STMT,\nFOR_STMT,\nWHILE_STMT,\nDO_STMT,\nRETURN_STMT,\nBREAK_STMT,\nCONTINUE_STMT,\nSWITCH_STMT,\nGOTO_STMT,\nLABEL_STMT,\nASM_STMT,\nSCOPE_STMT,\nCASE_LABEL,\nSTMT_EXPR,\n  LAST_C_TREE_CODE\n};\nenum cplus_tree_code {\n  CP_DUMMY_TREE_CODE = LAST_C_TREE_CODE,\nOFFSET_REF,\nPTRMEM_CST,\nNEW_EXPR,\nVEC_NEW_EXPR,\nDELETE_EXPR,\nVEC_DELETE_EXPR,\nSCOPE_REF,\nMEMBER_REF,\nTYPE_EXPR,\nAGGR_INIT_EXPR,\nTHROW_EXPR,\nEMPTY_CLASS_EXPR,\nTEMPLATE_DECL,\nTEMPLATE_PARM_INDEX,\nTEMPLATE_TYPE_PARM,\nTEMPLATE_TEMPLATE_PARM,\nBOUND_TEMPLATE_TEMPLATE_PARM,\nTYPENAME_TYPE,\nTYPEOF_TYPE,\nUSING_DECL,\nDEFAULT_ARG,\nTEMPLATE_ID_EXPR,\nCPLUS_BINDING,\nOVERLOAD,\nWRAPPER,\nLOOKUP_EXPR,\nFUNCTION_NAME,\nMODOP_EXPR,\nCAST_EXPR,\nREINTERPRET_CAST_EXPR,\nCONST_CAST_EXPR,\nSTATIC_CAST_EXPR,\nDYNAMIC_CAST_EXPR,\nDOTSTAR_EXPR,\nTYPEID_EXPR,\nPSEUDO_DTOR_EXPR,\nSUBOBJECT,\nCTOR_STMT,\nCLEANUP_STMT,\nSTART_CATCH_STMT,\nCTOR_INITIALIZER,\nRETURN_INIT,\nTRY_BLOCK,\nHANDLER,\nTAG_DEFN,\nIDENTITY_CONV,\nLVALUE_CONV,\nQUAL_CONV,\nSTD_CONV,\nPTR_CONV,\nPMEM_CONV,\nBASE_CONV,\nREF_BIND,\nUSER_CONV,\nAMBIG_CONV,\nRVALUE_CONV,\n  LAST_CPLUS_TREE_CODE\n};\n\nblah(){}\n\nconvert_like_real (convs)\n     tree convs;\n{\n  switch (((enum tree_code) (convs)->common.code))\n    {\n    case AMBIG_CONV:\n      return blah();\n    default:\n      break;\n    };\n   abort ();\n}\n\nmain()\n{\n  tree convs = (void *)malloc (sizeof (struct tree_common));;\n\n  convs->common.code = AMBIG_CONV;\n  convert_like_real (convs);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20000917-1.c",
    "content": "/* This bug exists in gcc-2.95, egcs-1.1.2, gcc-2.7.2 and probably\n   every other version as well.  */\n\ntypedef struct int3 { int a, b, c; } int3;\n\nint3\none (void)\n{\n  return (int3) { 1, 1, 1 };\n}\n\nint3\nzero (void)\n{\n  return (int3) { 0, 0, 0 };\n}\n\nint\nmain (void)\n{\n  int3 a;\n\n  /* gcc allocates a temporary for the inner expression statement\n     to store the return value of `one'.\n\n     gcc frees the temporaries for the inner expression statement.\n\n     gcc realloates the same temporary slot to store the return\n     value of `zero'.\n\n     gcc expands the call to zero ahead of the expansion of the\n     statement expressions.  The temporary gets the value of `zero'.\n\n     gcc expands statement expressions and the stale temporary is\n     clobbered with the value of `one'.  The bad value is copied from\n     the temporary into *&a.  */\n\n  *({ ({ one (); &a; }); }) = zero ();\n  if (a.a && a.b && a.c)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001009-1.c",
    "content": "int a,b;\nmain()\n{\n  int c=-2;\n  int d=0xfe;\n  int e=a&1;\n  int f=b&2;\n  if ((char)(c|(e&f)) == (char)d)\n    return 0;\n  else\n    abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001009-2.c",
    "content": "int b=1;\nint foo()\n{\n  int a;\n  int c;\n  a=0xff;\n  for (;b;b--)\n  {\n    c=1;\n    asm(\"\"::\"r\"(c));\n    c=(signed char)a;\n  }\n  if (c!=-1)\n    abort();\n  return c;\n}\nint main()\n{\n  foo();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001011-1.c",
    "content": "extern void abort(void);\nextern int strcmp(const char *, const char *);\n\nint foo(const char *a)\n{\n    return strcmp(a, \"main\");\n}\n\nint main(void)\n{\n    if(foo(__FUNCTION__))\n        abort();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001013-1.c",
    "content": "struct x {\n\tint a, b;\n} z = { -4028, 4096 };\n\nint foo(struct x *p, int y)\n{\n  if ((y & 0xff) != y || -p->b >= p->a)\n    return 1;\n  return 0;\n}\n\nmain()\n{\n  if (foo (&z, 10))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001017-1.c",
    "content": " \nvoid bug (double *Cref, char transb, int m, int n, int k,\n\t  double a, double *A, int fdA, double *B, int fdB,\n\t  double b, double *C, int fdC)\n{\n  if (C != Cref) abort ();\n}\n \nint main (void)\n{\n  double A[1], B[1], C[1];\n   \n  bug (C, 'B', 1, 2, 3, 4.0, A, 5, B, 6, 7.0, C, 8);\n   \n  return 0;\n}\n                                                                                                                                       \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001017-2.c",
    "content": "void\nfn_4parms (unsigned char a, long *b, long *c, unsigned int *d)\n{\n  if (*b != 1 || *c != 2 || *d != 3)\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned char a = 0;\n  unsigned long b = 1, c = 2;\n  unsigned int d = 3;\n\n  fn_4parms (a, &b, &c, &d);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001024-1.c",
    "content": "struct a;\n\nextern int baz (struct a *__restrict x);\n\nstruct a {\n  long v;\n  long w;\n};\n\nstruct b {\n  struct a c;\n  struct a d;\n};\n\nint bar (int x, const struct b *__restrict y, struct b *__restrict z)\n{\n  if (y->c.v || y->c.w != 250000 || y->d.v || y->d.w != 250000)\n    abort();\n}\n\nvoid foo(void)\n{\n  struct b x;\n  x.c.v = 0;\n  x.c.w = 250000;\n  x.d = x.c;\n  bar(0, &x, ((void *)0));\n}\n\nint main()\n{\n  foo();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001026-1.c",
    "content": "extern void abort (void);\n\ntypedef struct {\n  long r[(19 + sizeof (long))/(sizeof (long))];\n} realvaluetype;\n\ntypedef void *tree;\n\nstatic realvaluetype\nreal_value_from_int_cst (tree x, tree y)\n{\n  realvaluetype r;\n  int i;\n  for (i = 0; i < sizeof(r.r)/sizeof(long); ++i)\n    r.r[i] = -1;\n  return r;\n}\n\nstruct brfic_args\n{\n  tree type;\n  tree i;\n  realvaluetype d;\n};\n\nstatic void\nbuild_real_from_int_cst_1 (data)\n     void * data;\n{\n  struct brfic_args *args = (struct brfic_args *) data;\n  args->d = real_value_from_int_cst (args->type, args->i);\n}\n\nint main()\n{\n  struct brfic_args args;\n\n  __builtin_memset (&args, 0, sizeof(args));\n  build_real_from_int_cst_1 (&args);\n\n  if (args.d.r[0] == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001027-1.c",
    "content": "int x,*p=&x;\n\nint main()\n{\n  int i=0;\n  x=1;\n  p[i]=2;\n  if (x != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001031-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid t1 (int x)\n{\n  if (x != 4100)\n    abort ();\n}\n\nint t2 (void)\n{\n  int i;\n  t1 ((i = 4096) + 4);\n  return i;\n}\n\nvoid t3 (long long x)\n{\n  if (x != 0x80000fffULL)\n    abort ();\n}\n\nlong long t4 (void)\n{\n  long long i;\n  t3 ((i = 4096) + 0x7fffffffULL);\n  return i;\n}\n\nmain ()\n{\n  if (t2 () != 4096)\n    abort ();\n  if (t4 () != 4096)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001101.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nextern void abort(void);\n\t\t\t \ntypedef struct\n{\n  unsigned int unchanging : 1;\n} struc, *rtx;\n\nrtx dummy ( int *a, rtx *b)\n{\n  *a = 1;\n  *b = (rtx)7;\n  return (rtx)1;\n}\n\nvoid bogus (insn, thread, delay_list)\n     rtx insn;\n     rtx thread;\n     rtx delay_list;\n{\n  rtx new_thread;\n  int must_annul;\n\n  delay_list = dummy ( &must_annul, &new_thread);\n  if (delay_list == 0 &&  new_thread )\n    {\n      thread = new_thread;\n    }\n  if (delay_list && must_annul)\n    insn->unchanging = 1;\n  if (new_thread != thread )\n    abort();\n}\n\nint main()\n{\n  struc baz;\n  bogus (&baz, (rtx)7, 0);\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001108-1.c",
    "content": "long long\nsigned_poly (long long sum, long x)\n{\n  sum += (long long) (long) sum * (long long) x;\n  return sum;\n}\n\nunsigned long long\nunsigned_poly (unsigned long long sum, unsigned long x)\n{\n  sum += (unsigned long long) (unsigned long) sum * (unsigned long long) x;\n  return sum;\n}\n\nint\nmain (void)\n{\n  if (signed_poly (2LL, -3) != -4LL)\n    abort ();\n  \n  if (unsigned_poly (2ULL, 3) != 8ULL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001111-1.c",
    "content": "\nstatic int next_buffer = 0;\nvoid bar (void);\n\nstatic int t = 1, u = 0;\n\nlong\nfoo (unsigned int offset)\n{\n  unsigned i, buffer;\n  int x;\n  char *data;\n\n  i = u;\n  if (i)\n    return i * 0xce2f;\n\n  buffer = next_buffer;\n  data = buffer * 0xce2f;\n  for (i = 0; i < 2; i++)\n    bar ();\n  buffer = next_buffer;\n  return buffer * 0xce2f + offset;\n\n}\n\nvoid\nbar (void)\n{\n}\n\nint\nmain ()\n{\n  if (foo (3) != 3)\n    abort ();\n  next_buffer = 1;\n  if (foo (2) != 0xce2f + 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001112-1.c",
    "content": "int main ()\n{\n  long long i = 1;\n\n  i = i * 2 + 1;\n  \n  if (i != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001121-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\ndouble d;\n\n__inline__ double foo (void)\n{\n  return d;\n}\n\n__inline__ int bar (void)\n{\n  foo();\n  return 0;\n}\n\nint main (void)\n{\n  if (bar ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001124-1.c",
    "content": "\nstruct inode {\n\tlong long\t\ti_size;\n\tstruct super_block\t*i_sb;\n};\n\nstruct file {\n\tlong long\t\tf_pos;\n};\n\nstruct super_block {\n\tint\t\t\ts_blocksize;\n\tunsigned char\t\ts_blocksize_bits;\n\tint\t\t\ts_hs;\n};\n\nstatic char *\nisofs_bread(unsigned int block)\n{\n\tif (block)\n\t  abort ();\n\texit(0);\n}\n\nstatic int\ndo_isofs_readdir(struct inode *inode, struct file *filp)\n{\n\tint bufsize = inode->i_sb->s_blocksize;\n\tunsigned char bufbits = inode->i_sb->s_blocksize_bits;\n\tunsigned int block, offset;\n\tchar *bh = 0;\n\tint hs;\n\n \tif (filp->f_pos >= inode->i_size)\n\t\treturn 0;\n \n\toffset = filp->f_pos & (bufsize - 1);\n\tblock = filp->f_pos >> bufbits;\n\ths = inode->i_sb->s_hs;\n\n\twhile (filp->f_pos < inode->i_size) {\n\t\tif (!bh)\n\t\t\tbh = isofs_bread(block);\n\n\t\ths += block << bufbits;\n\n\t\tif (hs == 0)\n\t\t\tfilp->f_pos++;\n\n\t\tif (offset >= bufsize)\n\t\t\toffset &= bufsize - 1;\n\n\t\tif (*bh)\n\t\t\tfilp->f_pos++;\n\n\t\tfilp->f_pos++;\n\t}\n\treturn 0;\n}\n\nstruct super_block s;\nstruct inode i;\nstruct file f;\n\nint\nmain(int argc, char **argv)\n{\n\ts.s_blocksize = 512;\n\ts.s_blocksize_bits = 9;\n\ti.i_size = 2048;\n\ti.i_sb = &s;\n\tf.f_pos = 0;\n\n\tdo_isofs_readdir(&i,&f);\n\tabort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001130-1.c",
    "content": "static inline int bar(void) { return 1; }\nstatic int mem[3];\n\nstatic int foo(int x)\n{\n  if (x != 0)\n    return x;\n\n  mem[x++] = foo(bar());\n\n  if (x != 1)\n    abort();\n\n  return 0;\n}\n\nint main()\n{\n  foo(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001130-2.c",
    "content": "static int which_alternative = 3;\n\nstatic const char *i960_output_ldconst (void);\n\nstatic const char *\noutput_25 (void)\n{\n  switch (which_alternative)\n    {\n    case 0:\n      return \"mov\t%1,%0\";\n    case 1:\n      return i960_output_ldconst ();\n    case 2:\n      return \"ld\t%1,%0\";\n    case 3:\n      return \"st\t%1,%0\";      \n    }\n}\n\nstatic const char *i960_output_ldconst (void)\n{\n  return \"foo\";\n}\nint main(void)\n{\n  const char *s = output_25 () ;\n  if (s[0] != 's')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001203-1.c",
    "content": "/* Origin: PR c/410 from Jan Echternach\n   <jan.echternach@informatik.uni-rostock.de>,\n   adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n*/\n\nextern void exit (int);\n\nstatic void\nfoo (void)\n{\n  struct {\n    long a;\n    char b[1];\n  } x = { 2, { 0 } };\n}\n\nint\nmain (void)\n{\n  int tmp;\n  foo ();\n  tmp = 1;\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001203-2.c",
    "content": "struct obstack\n{\n  long chunk_size;\n  struct _obstack_chunk *chunk;\n  char *object_base;\n  char *next_free;\n  char *chunk_limit;\n  int alignment_mask;\n  unsigned maybe_empty_object;\n};\n\nstruct objfile\n  {\n    struct objfile *next;\n    struct obstack type_obstack;\n  };\n\nstruct type\n  {\n    unsigned length;\n    struct objfile *objfile;\n    short nfields;\n    struct field\n      {\n        union field_location\n          {\n            int bitpos;\n            unsigned long physaddr;\n            char *physname;\n          }\n        loc;\n        int bitsize;\n        struct type *type;\n        char *name;\n      }\n     *fields;\n  };\n\nstruct type *alloc_type (void);\nvoid * xmalloc (unsigned int z);\nvoid _obstack_newchunk (struct obstack *o, int i);\nvoid get_discrete_bounds (long long *lowp, long long *highp);\n\nextern void *memset(void *, int, __SIZE_TYPE__);\n\nstruct type *\ncreate_array_type (struct type *result_type, struct type *element_type)\n{\n  long long low_bound, high_bound;\n  if (result_type == ((void *)0))\n    {\n      result_type = alloc_type ();\n    }\n  get_discrete_bounds (&low_bound, &high_bound);\n  (result_type)->length =\n    (element_type)->length * (high_bound - low_bound + 1);\n  (result_type)->nfields = 1;\n  (result_type)->fields =\n    (struct field *) ((result_type)->objfile != ((void *)0) \n\t\t      ? (\n\t\t      {\n\t\t\tstruct obstack *__h = \n\t\t\t  (&(result_type)->objfile -> type_obstack);\n\t\t\t{\n\t\t\t  struct obstack *__o = (__h);\n\t\t\t  int __len = ((sizeof (struct field)));\n\t\t\t  if (__o->chunk_limit - __o->next_free < __len)\n\t\t\t    _obstack_newchunk (__o, __len); \n\t\t\t  __o->next_free += __len; (void) 0;\n\t\t\t};\n\t\t\t({\n\t\t\t  struct obstack *__o1 = (__h); \n\t\t\t  void *value; \n\t\t\t  value = (void *) __o1->object_base;\n\t\t\t  if (__o1->next_free == value)\n\t\t\t    __o1->maybe_empty_object = 1;\n\t\t\t  __o1->next_free = (((((__o1->next_free) - (char *) 0)\n\t\t\t\t\t       +__o1->alignment_mask) \n\t\t\t\t\t      & ~ (__o1->alignment_mask)) \n\t\t\t\t\t     + (char *) 0);\n\t\t\t  if (__o1->next_free - (char *)__o1->chunk \n\t\t\t      > __o1->chunk_limit - (char *)__o1->chunk)\n\t\t\t    __o1->next_free = __o1->chunk_limit;\n\t\t\t  __o1->object_base = __o1->next_free; \n\t\t\t  value;\n\t\t\t});\n\t\t      }) : xmalloc (sizeof (struct field)));\n  return (result_type);\n}\n\nstruct type *\nalloc_type (void)\n{\n  abort ();\n}\nvoid * xmalloc (unsigned int z)\n{\n  return 0;\n}\nvoid _obstack_newchunk (struct obstack *o, int i)\n{\n  abort ();\n}\nvoid\nget_discrete_bounds (long long *lowp, long long *highp)\n{\n  *lowp = 0;\n  *highp = 2;\n}\n\nint main(void)\n{\n  struct type element_type;\n  struct type result_type;\n  \n  memset (&element_type, 0, sizeof (struct type));\n  memset (&result_type, 0, sizeof (struct type));\n  element_type.length = 4;\n  create_array_type (&result_type, &element_type);\n  if (result_type.length != 12)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001221-1.c",
    "content": "int main ()\n{\n  unsigned long long a;\n  if (! (a = 0xfedcba9876543210ULL))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001228-1.c",
    "content": "int foo1(void)\n{\n  union {\n    char a[sizeof (unsigned)];\n    unsigned b;\n  } u;\n  \n  u.b = 0x01;\n  return u.a[0];\n}\n\nint foo2(void)\n{\n  volatile union {\n    char a[sizeof (unsigned)];\n    unsigned b;\n  } u;\n  \n  u.b = 0x01;\n  return u.a[0];\n}\n\nint main(void)\n{\n  if (foo1() != foo2())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20001229-1.c",
    "content": "/* This testcase originally provoked an unaligned access fault on Alpha.\n\n   Since Digital Unix and Linux (and probably others) by default fix\n   these up in the kernel, the failure was not visible unless one \n   is sitting at the console examining logs.\n\n   So: If we know how, ask the kernel to deliver SIGBUS instead so\n   that the test case visibly fails.  */\n   \n#if defined(__alpha__) && defined(__linux__)\n#include <asm/sysinfo.h>\n#include <asm/unistd.h>\n\nstatic inline int\nsetsysinfo(unsigned long op, void *buffer, unsigned long size,\n           int *start, void *arg, unsigned long flag)\n{\n  syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);\n}\n\nstatic void __attribute__((constructor))\ntrap_unaligned(void)\n{\n  unsigned int buf[2];\n  buf[0] = SSIN_UACPROC;\n  buf[1] = UAC_SIGBUS | UAC_NOPRINT;\n  setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);\n}\n#endif /* alpha */\n\nvoid foo(char *a, char *b) { }\n\nvoid showinfo()\n{\n    char uname[33] = \"\", tty[38] = \"/dev/\";\n    foo(uname, tty);\n}\n\nint main()\n{\n  showinfo ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010106-1.c",
    "content": "/* Copyright 2001 Free Software Foundation\n   Contributed by Alexandre Oliva <aoliva@redhat.com> */\n\nint f(int i) {\n  switch (i)\n  {\n    case -2:\n      return 33;\n    case -1:\n      return 0;\n    case 0:\n      return 7;\n    case 1:\n      return 4;\n    case 2:\n      return 3;\n    case 3:\n      return 15;\n    case 4:\n     return 9;\n    default:\n      abort ();\n  }\n}\n\nint main() {\n  if (f(-1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010114-1.c",
    "content": "/* Origin: PR c/1540 from Mattias Lampe <lampe@tu-harburg.de>,\n   adapted to a testcase by Joseph Myers <jsm28@cam.ac.uk>.\n   GCC 2.95.2 fails, CVS GCC of 2001-01-13 passes.  */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  int array1[1] = { 1 };\n  int array2[2][1]= { { 1 }, { 0 } };\n  if (array1[0] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010116-1.c",
    "content": "/* Distilled from optimization/863.  */\n\nextern void abort (void);\nextern void exit (int);\nextern void ok (int);\n\ntypedef struct\n{\n  int x, y, z;\n} Data;\n\nvoid find (Data *first, Data *last)\n{\n  int i;\n  for (i = (last - first) >> 2; i > 0; --i)\n    ok(i);\n  abort ();\n}\n\nvoid ok(int i)\n{\n  if (i != 1)\n    abort ();\n  exit (0);\n}\n\nint\nmain ()\n{\n  Data DataList[4];\n  find (DataList + 0, DataList + 4);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010118-1.c",
    "content": "typedef struct {\n  int a, b, c, d, e, f;\n} A;\n\nvoid foo (A *v, int w, int x, int *y, int *z)\n{\n}\n\nvoid\nbar (A *v, int x, int y, int w, int h)\n{\n  if (v->a != x || v->b != y) {\n    int oldw = w;\n    int oldh = h;\n    int e = v->e;\n    int f = v->f;\n    int dx, dy;\n    foo(v, 0, 0, &w, &h);\n    dx = (oldw - w) * (double) e/2.0;\n    dy = (oldh - h) * (double) f/2.0;\n    x += dx;\n    y += dy;\n    v->a = x;\n    v->b = y;\n    v->c = w;\n    v->d = h;\n  }\n}\n\nint main ()\n{\n  A w = { 100, 110, 20, 30, -1, -1 };\n  bar (&w,400,420,50,70);\n  if (w.d != 70)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010119-1.c",
    "content": "#ifdef __OPTIMIZE__\nextern void undef (void);\n\nvoid bar (unsigned x) { }\nvoid baz (unsigned x) { }\n\nextern inline void foo (int a, int b)\n{\n  int c = 0;\n  while (c++ < b)\n    (__builtin_constant_p (a) ? ((a) > 20000 ? undef () : bar (a)) : baz (a));\n}\n#else\nvoid foo (int a, int b)\n{\n}\n#endif\n\nint main (void)\n{\n  foo(10, 100);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010122-1.c",
    "content": "/* { dg-skip-if \"requires frame pointers\" { *-*-* } \"-fomit-frame-pointer\" \"\" } */\n/* { dg-require-effective-target return_address } */\n\nextern void exit (int);\nextern void abort (void);\nextern void *alloca (__SIZE_TYPE__);\nchar *dummy (void);\n\n#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))\n\nvoid *save_ret1[6];\nvoid *test4a (char *);\nvoid *test5a (char *);\nvoid *test6a (char *);\n\nvoid NOINLINE *test1 (void)\n{\n  void * temp;\n  temp = __builtin_return_address (0);\n  return temp;\n}\n\nvoid NOINLINE *test2 (void)\n{\n  void * temp;\n  dummy ();\n  temp = __builtin_return_address (0);\n  return temp;\n}\n\nvoid NOINLINE *test3 (void)\n{\n  void * temp;\n  temp = __builtin_return_address (0);\n  dummy ();\n  return temp;\n}\n\nvoid NOINLINE *test4 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test4a (save);\n}\n\nvoid *NOINLINE test4a (char * p)\n{\n  void * temp;\n  temp = __builtin_return_address (1);\n  return temp;\n}\n\nvoid NOINLINE *test5 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test5a (save);\n}\n\nvoid NOINLINE *test5a (char * p)\n{\n  void * temp;\n  dummy ();\n  temp = __builtin_return_address (1);\n  return temp;\n}\n\nvoid NOINLINE *test6 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return test6a (save);\n}\n\nvoid NOINLINE *test6a (char * p)\n{\n  void * temp;\n  temp = __builtin_return_address (1);\n  dummy ();\n  return temp;\n}\n\nvoid *(*func1[6])(void) = { test1, test2, test3, test4, test5, test6 };\n\nchar * NOINLINE call_func1 (int i)\n{\n  save_ret1[i] = func1[i] ();\n}\n\nstatic void *ret_addr;\nvoid *save_ret2[6];\nvoid test10a (char *);\nvoid test11a (char *);\nvoid test12a (char *);\n\nvoid NOINLINE test7 (void)\n{\n  ret_addr = __builtin_return_address (0);\n  return;\n}\n\nvoid NOINLINE test8 (void)\n{\n  dummy ();\n  ret_addr = __builtin_return_address (0);\n  return;\n}\n\nvoid NOINLINE test9 (void)\n{\n  ret_addr = __builtin_return_address (0);\n  dummy ();\n  return;\n}\n\nvoid NOINLINE test10 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test10a (save);\n}\n\nvoid NOINLINE test10a (char * p)\n{\n  ret_addr = __builtin_return_address (1);\n  return;\n}\n\nvoid NOINLINE test11 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test11a (save);\n}\n\nvoid NOINLINE test11a (char * p)\n{\n  dummy ();\n  ret_addr = __builtin_return_address (1);\n  return;\n}\n\nvoid NOINLINE test12 (void)\n{\n  char * save = (char*) alloca (4);\n  \n  test12a (save);\n}\n\nvoid NOINLINE test12a (char * p)\n{\n  ret_addr = __builtin_return_address (1);\n  dummy ();\n  return;\n}\n\nchar * dummy (void)\n{\n  char * save = (char*) alloca (4);\n  \n  return save;\n}\n\nvoid (*func2[6])(void) = { test7, test8, test9, test10, test11, test12 };\n\nvoid NOINLINE call_func2 (int i)\n{\n  func2[i] ();\n  save_ret2[i] = ret_addr;\n}\n\nint main (void)\n{\n  int i;\n\n  for (i = 0; i < 6; i++) {\n    call_func1(i);\n  }\n\n  if (save_ret1[0] != save_ret1[1]\n      || save_ret1[1] != save_ret1[2])\n    abort ();\n  if (save_ret1[3] != save_ret1[4]\n      || save_ret1[4] != save_ret1[5])\n    abort ();\n  if (save_ret1[3] && save_ret1[0] != save_ret1[3])\n    abort ();\n\n\n  for (i = 0; i < 6; i++) {\n    call_func2(i);\n  }\n\n  if (save_ret2[0] != save_ret2[1]\n      || save_ret2[1] != save_ret2[2])\n    abort ();\n  if (save_ret2[3] != save_ret2[4]\n      || save_ret2[4] != save_ret2[5])\n    abort ();\n  if (save_ret2[3] && save_ret2[0] != save_ret2[3])\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010123-1.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nstruct s\n{\n    int value;\n    char *string;\n};\n\nint main (void)\n{\n  int i;\n  for (i = 0; i < 4; i++)\n    {\n      struct s *t = & (struct s) { 3, \"hey there\" };\n      if (t->value != 3)\n\tabort();\n      t->value = 4;\n      if (t->value != 4)\n\tabort();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010129-1.c",
    "content": "/* { dg-options \"-mtune=i686\" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */\n\nextern void abort (void);\nextern void exit (int);\n\nlong baz1 (void *a)\n{\n  static long l;\n  return l++;\n}\n\nint baz2 (const char *a)\n{\n  return 0;\n}\n\nint baz3 (int i)\n{\n  if (!i)\n    abort ();\n  return 1;\n}\n\nvoid **bar;\n\nint foo (void *a, long b, int c)\n{\n  int d = 0, e, f = 0, i;\n  char g[256];\n  void **h;\n\n  g[0] = '\\n';\n  g[1] = 0;\n\n  while (baz1 (a) < b) {\n    if (g[0] != ' ' && g[0] != '\\t') {\n      f = 1;\n      e = 0;\n      if (!d && baz2 (g) == 0) {\n\tif ((c & 0x10) == 0)\n\t  continue;\n\te = d = 1;\n      }\n      if (!((c & 0x10) && (c & 0x4000) && e) && (c & 2))\n\tcontinue;\n      if ((c & 0x2000) && baz2 (g) == 0)\n\tcontinue;\n      if ((c & 0x1408) && baz2 (g) == 0)\n\tcontinue;\n      if ((c & 0x200) && baz2 (g) == 0)\n\tcontinue;\n      if (c & 0x80) {\n\tfor (h = bar, i = 0; h; h = (void **)*h, i++)\n\t  if (baz3 (i))\n\t    break;\n      }\n      f = 0;\n    }\n  }\n  return 0;\n}\n\nint main ()\n{\n  void *n = 0;\n  bar = &n;\n  foo (&n, 1, 0xc811);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010206-1.c",
    "content": "int foo (void)\n{\n  int i;\n#line 1 \"20010206-1.c\"\n  if (0) i = 1; else i\n#line 1 \"20010206-1.c\"\n    = 26;\n  return i;\n}\n\nint main ()\n{\n  if (foo () != 26)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010209-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nint b;\nint foo (void)\n{\n  int x[b];\n  int bar (int t[b])\n  {\n    int i;\n    for (i = 0; i < b; i++)\n      t[i] = i + (i > 0 ? t[i-1] : 0);\n    return t[b-1];\n  }\n  return bar (x);\n}\n\nint main ()\n{\n  b = 6;\n  if (foo () != 15)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010221-1.c",
    "content": "\nint n = 2;\n\nmain ()\n{\n  int i, x = 45;\n\n  for (i = 0; i < n; i++)\n    {\n      if (i != 0)\n\tx = ( i > 0 ) ? i : 0;\n    }\n\n  if (x != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010222-1.c",
    "content": "int a[2] = { 18, 6 };\n\nint main ()\n{\n  int b = (-3 * a[0] -3 * a[1]) / 12;\n  if (b != -6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010224-1.c",
    "content": "extern void abort (void);\n\ntypedef signed short int16_t;\ntypedef unsigned short uint16_t;\n\nint16_t logadd (int16_t *a, int16_t *b);\nvoid ba_compute_psd (int16_t start);\n\nint16_t masktab[6] = { 1, 2, 3, 4, 5};\nint16_t psd[6] = { 50, 40, 30, 20, 10};\nint16_t bndpsd[6] = { 1, 2, 3, 4, 5};\n\nvoid ba_compute_psd (int16_t start)\n{\n  int i,j,k;\n  int16_t lastbin = 4;\n\n  j = start; \n  k = masktab[start]; \n\n  bndpsd[k] = psd[j]; \n  j++; \n\n  for (i = j; i < lastbin; i++) { \n    bndpsd[k] = logadd(&bndpsd[k], &psd[j]);\n    j++; \n  } \n}\n\nint16_t logadd (int16_t *a, int16_t *b)\n{\n  return *a + *b;\n}\n\nint main (void)\n{\n  int i;\n\n  ba_compute_psd (0);\n\n  if (bndpsd[1] != 140) abort ();\n  return 0;\n}\n  \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010325-1.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.\n\n   This tests for inconsistency in whether wide STRING_CSTs use the host\n   or the target endianness.  */\n\nextern void exit (int);\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (L\"a\" \"b\"[1] != L'b')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010329-1.c",
    "content": "#include <limits.h>\n\nint main (void)\n{\n  void *x = ((void *)((unsigned int)INT_MAX + 2));\n  void *y = ((void *)((unsigned long)LONG_MAX + 2));\n  if (x >= ((void *)((unsigned int)INT_MAX + 1))\n      && x <= ((void *)((unsigned int)INT_MAX + 6))\n      && y >= ((void *)((unsigned long)LONG_MAX + 1))\n      && y <= ((void *)((unsigned long)LONG_MAX + 6)))\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010403-1.c",
    "content": "void b (int *);\nvoid c (int, int);\nvoid d (int);\n\nint e;\n\nvoid a (int x, int y)\n{\n  int f = x ? e : 0;\n  int z = y;\n\n  b (&y);\n  c (z, y);\n  d (f);\n}\n\nvoid b (int *y)\n{\n  (*y)++;\n}\n\nvoid c (int x, int y)\n{\n  if (x == y)\n    abort ();\n}\n\nvoid d (int x)\n{\n}\n\nint main (void)\n{\n  a (0, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010409-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *s);\n\ntypedef struct A {\n  int a, b;\n} A;\n\ntypedef struct B {\n  struct A **a;\n  int b;\n} B;\n\nA *a;\nint b = 1, c;\nB d[1];\n\nvoid foo (A *x, const char *y, int z)\n{\n  c = y[4] + z * 25;\n}\n\nA *bar (const char *v, int w, int x, const char *y, int z)\n{\n  if (w)\n    abort ();\n  exit (0);\n}\n\nvoid test (const char *x, int *y)\n{\n  foo (d->a[d->b], \"test\", 200);\n  d->a[d->b] = bar (x, b ? 0 : 65536, strlen (x), \"test\", 201);\n  d->a[d->b]->a++;\n  if (y)\n    d->a[d->b]->b = *y;\n}\n\nint main ()\n{\n  d->b = 0;\n  d->a = &a;\n  test (\"\", 0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010422-1.c",
    "content": "unsigned int foo(unsigned int x)\n{\n  if (x < 5)\n    x = 4;\n  else\n    x = 8;\n  return x;\n}\n\nint main(void)\n{\n  if (foo (8) != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010518-1.c",
    "content": "/* Leaf functions with many arguments.  */\n\nint\nadd (int a,\n    int b,\n    int c,\n    int d,\n    int e,\n    int f,\n    int g,\n    int h,\n    int i,\n    int j,\n    int k,\n    int l,\n    int m)\n{\n  return a+b+c+d+e+f+g+h+i+j+k+l+m;\n}\n\nint\nmain(void)\n{\n  if (add (1,2,3,4,5,6,7,8,9,10,11,12,13) != 91)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010518-2.c",
    "content": "/* Mis-aligned packed structures.  */\n\ntypedef struct\n{\n  char b0;\n  char b1;\n  char b2;\n  char b3;\n  char b4;\n  char b5;\n} __attribute__ ((packed)) b_struct;\n\n\ntypedef struct\n{\n  short a;\n  long b;\n  short c;\n  short d;\n  b_struct e;\n} __attribute__ ((packed)) a_struct;\n\n\nint\nmain(void)\n{\n  volatile a_struct *a;\n  volatile a_struct b;\n\n  a = &b;\n  *a = (a_struct){1,2,3,4};\n  a->e.b4 = 'c';\n\n  if (a->a != 1 || a->b != 2 || a->c != 3 || a->d != 4 || a->e.b4 != 'c')\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010520-1.c",
    "content": "static unsigned int expr_hash_table_size = 1;\n\nint\nmain ()\n{\n  int del = 1;\n  unsigned int i = 0;\n\n  if (i < expr_hash_table_size && del)\n    exit (0);\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010604-1.c",
    "content": "#include <stdbool.h>\n\nint f (int a, int b, int c, _Bool d, _Bool e, _Bool f, char g)\n{\n  if (g != 1 || d != true || e != true || f != true) abort ();\n  return a + b + c;\n}\n\nint main (void)\n{\n  if (f (1, 2, -3, true, true, true, '\\001'))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010605-1.c",
    "content": "int main ()\n{\n  int v = 42;\n\n  inline int fff (int x)\n    {\n      return x*10;\n    }\n\n  return (fff (v) != 420);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010605-2.c",
    "content": "void foo (), bar (), baz ();\nint main ()\n{\n  __complex__ double x;\n  __complex__ float y;\n  __complex__ long double z;\n  __real__ x = 1.0;\n  __imag__ x = 2.0;\n  foo (x);\n  __real__ y = 3.0f;\n  __imag__ y = 4.0f;\n  bar (y);\n  __real__ z = 5.0L;\n  __imag__ z = 6.0L;\n  baz (z);\n  exit (0);\n}\n\nvoid foo (__complex__ double x)\n{\n  if (__real__ x != 1.0 || __imag__ x != 2.0)\n    abort ();\n}\n\nvoid bar (__complex__ float x)\n{\n  if (__real__ x != 3.0f || __imag__ x != 4.0f)\n    abort ();\n}\n\nvoid baz (__complex__ long double x)\n{\n  if (__real__ x != 5.0L || __imag__ x != 6.0L)\n    abort ();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010711-1.c",
    "content": "void foo (int *a) {}\n\nint main ()\n{\n  int a;\n  if (&a == 0)\n    abort ();\n  else\n    {\n      foo (&a);\n      exit (0);\n    }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010717-1.c",
    "content": "extern void abort (void);\n\nint\nmain ()\n{\n  int i, j;\n  unsigned long u, r1, r2;\n\n  i = -16;\n  j = 1;\n  u = i + j;\n\n  /* no sign extension upon shift */\n  r1 = u >> 1;\n  /* sign extension upon shift, but there shouldn't be */\n  r2 = ((unsigned long) (i + j)) >> 1;\n\n  if (r1 != r2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010723-1.c",
    "content": "int\ntest ()\n{\n  int biv,giv;\n  for (biv = 0, giv = 0; giv != 8; biv++)\n      giv = biv*8;\n  return giv;\n}\n\n\nmain()\n{\n  if (test () != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010904-1.c",
    "content": "typedef struct x { int a; int b; } __attribute__((aligned(32))) X;\ntypedef struct y { X x[32]; int c; } Y;\n\nY y[2];\n\nint main(void)\n{\n  if (((char *)&y[1] - (char *)&y[0]) & 31)\n    abort ();\n  exit (0);\n}                \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010904-2.c",
    "content": "typedef struct x { int a; int b; } __attribute__((aligned(32))) X;\ntypedef struct y { X x; X y[31]; int c; } Y;\n\nY y[2];\n\nint main(void)\n{\n  if (((char *)&y[1] - (char *)&y[0]) & 31)\n    abort ();\n  exit (0);\n}                \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010910-1.c",
    "content": "/* Test case contributed by Ingo Rohloff <rohloff@in.tum.de>.\n   Code distilled from Linux kernel.  */\n\n/* Compile this program with a gcc-2.95.2 using\n   \"gcc -O2\" and run it. The result will be that\n   rx_ring[1].next == 0   (it should be == 14)\n   and\n   ep.skbuff[4] == 5      (it should be 0)\n*/\n\nextern void abort(void);\n\nstruct epic_rx_desc \n{\n  unsigned int next;\n};\n\nstruct epic_private \n{\n  struct epic_rx_desc *rx_ring;\n  unsigned int rx_skbuff[5];\n};\n\nstatic void epic_init_ring(struct epic_private *ep)\n{\n  int i;\n\n  for (i = 0; i < 5; i++) \n  {\n    ep->rx_ring[i].next = 10 + (i+1)*2;\n    ep->rx_skbuff[i] = 0;\n  }\n  ep->rx_ring[i-1].next = 10;\n}\n\nstatic int check_rx_ring[5] = { 12,14,16,18,10 };\n\nint main(void)\n{\n  struct epic_private ep;\n  struct epic_rx_desc rx_ring[5];\n  int i;\n\n  for (i=0;i<5;i++)\n  {\n    rx_ring[i].next=0;\n    ep.rx_skbuff[i]=5;\n  }\n  \n  ep.rx_ring=rx_ring;\n  epic_init_ring(&ep);\n  \n  for (i=0;i<5;i++)\n  {\n    if ( rx_ring[i].next != check_rx_ring[i] ) abort();\n    if ( ep.rx_skbuff[i] != 0 ) abort();\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010915-1.c",
    "content": "/* Bug in reorg.c, deleting the \"++\" in the last loop in main.\n   Origin: <hp@axis.com>.  */\n\nextern void f (void);\nextern int x (int, char **);\nextern int r (const char *);\nextern char *s (char *, char **);\nextern char *m (char *);\nchar *u;\nchar *h;\nint check = 0;\nint o = 0;\n\nint main (int argc, char **argv)\n{\n  char *args[] = {\"a\", \"b\", \"c\", \"d\", \"e\"};\n  if (x (5, args) != 0 || check != 2 || o != 5)\n    abort ();\n  exit (0);\n}\n\nint x (int argc, char **argv)\n{\n  int opt = 0;\n  char *g = 0;\n  char *p = 0;\n\n  if (argc > o && argc > 2 && argv[o])\n    {\n      g = s (argv[o], &p);\n      if (g)\n\t{\n\t  *g++ = '\\0';\n\t  h = s (g, &p);\n\t  if (g == p)\n\t    h = m (g);\n\t}\n      u = s (argv[o], &p);\n      if (argv[o] == p)\n\tu = m (argv[o]);\n    }\n  else\n    abort ();\n\n  while (++o < argc)\n    if (r (argv[o]) == 0)\n      return 1;\n\n  return 0;\n}\n\nchar *m (char *x) { abort (); }\nchar *s (char *v, char **pp)\n{\n  if (strcmp (v, \"a\") != 0 || check++ > 1)\n    abort ();\n  *pp = v+1;\n  return 0;\n}\n\nint r (const char *f)\n{\n  static char c[2] = \"b\";\n  static int cnt = 0;\n\n  if (*f != *c || f[1] != c[1] || cnt > 3)\n    abort ();\n  c[0]++;\n  cnt++;\n  return 1;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010924-1.c",
    "content": "/* Verify that flexible arrays can be initialized from STRING_CST\n   constructors. */\n\n/* Baselines.  */\nstruct {\n  char a1c;\n  char *a1p;\n} a1 = {\n  '4',\n  \"62\"\n};\n\nstruct {\n  char a2c;\n  char a2p[2];\n} a2 = {\n  'v',\n  \"cq\"\n};\n\n/* The tests.  */\nstruct {\n  char a3c;\n  char a3p[];\n} a3 = {\n  'o',\n  \"wx\"\n};\n\nstruct {\n  char a4c;\n  char a4p[];\n} a4 = {\n  '9',\n  { 'e', 'b' }\n};\n\nmain()\n{\n  if (a1.a1c != '4')\n    abort();\n  if (a1.a1p[0] != '6')\n    abort();\n  if (a1.a1p[1] != '2')\n    abort();\n  if (a1.a1p[2] != '\\0')\n    abort();\n\n  if (a2.a2c != 'v')\n    abort();\n  if (a2.a2p[0] != 'c')\n    abort();\n  if (a2.a2p[1] != 'q')\n    abort();\n\n  if (a3.a3c != 'o')\n    abort();\n  if (a3.a3p[0] != 'w')\n    abort();\n  if (a3.a3p[1] != 'x')\n    abort();\n\n  if (a4.a4c != '9')\n    abort();\n  if (a4.a4p[0] != 'e')\n    abort();\n  if (a4.a4p[1] != 'b')\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20010925-1.c",
    "content": "extern void exit(int);\nextern void abort (void);\n\nextern void * memcpy (void *, const void *, __SIZE_TYPE__);\nint foo (void *, void *, unsigned int c);\n\nint src[10];\nint dst[10];\n\nint main()\n{\n   if (foo (dst, src, 10) != 0)\n     abort();\n   exit(0);\n}\n\nint foo (void *a, void *b, unsigned int c)\n{\n  if (c == 0)\n    return 1;\n\n  memcpy (a, b, c);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011008-3.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\ntypedef unsigned int u_int32_t;\ntypedef unsigned char u_int8_t;\ntypedef int int32_t;\n\ntypedef enum {\n        TXNLIST_DELETE,\n        TXNLIST_LSN,\n        TXNLIST_TXNID,\n        TXNLIST_PGNO\n} db_txnlist_type;\n\nstruct __db_lsn; typedef struct __db_lsn DB_LSN;\nstruct __db_lsn {\n        u_int32_t file;\n        u_int32_t offset;\n};\nstruct __db_txnlist; typedef struct __db_txnlist DB_TXNLIST;\n\nstruct __db_txnlist {\n        db_txnlist_type type;\n        struct { struct __db_txnlist *le_next; struct __db_txnlist **le_prev; } links;\n        union {\n                struct {\n                        u_int32_t txnid;\n                        int32_t generation;\n                        int32_t aborted;\n                } t;\n                struct {\n\n\n                        u_int32_t flags;\n                        int32_t fileid;\n                        u_int32_t count;\n                        char *fname;\n                } d;\n                struct {\n                        int32_t ntxns;\n                        int32_t maxn;\n                        DB_LSN *lsn_array;\n                } l;\n                struct {\n                        int32_t nentries;\n                        int32_t maxentry;\n                        char *fname;\n                        int32_t fileid;\n                        void *pgno_array;\n                        u_int8_t uid[20];\n                } p;\n        } u;\n};\n\nint log_compare (const DB_LSN *a, const DB_LSN *b)\n{\n  return 1;\n}\n\n\nint\n__db_txnlist_lsnadd(int val, DB_TXNLIST *elp, DB_LSN *lsnp, u_int32_t flags)\n{\n   int i;\n \n   for (i = 0; i < (!(flags & (0x1)) ? 1 : elp->u.l.ntxns); i++)\n     {\n\tint __j;\n\tDB_LSN __tmp;\n\tval++; \n\tfor (__j = 0; __j < elp->u.l.ntxns - 1; __j++)\n\t  if (log_compare(&elp->u.l.lsn_array[__j], &elp->u.l.lsn_array[__j + 1]) < 0)\n\t  {\n\t     __tmp = elp->u.l.lsn_array[__j];\n\t     elp->u.l.lsn_array[__j] = elp->u.l.lsn_array[__j + 1];\n\t     elp->u.l.lsn_array[__j + 1] = __tmp;\n\t  }\n     }\n\n   *lsnp = elp->u.l.lsn_array[0];\n   return val;\n}\n\n#if defined (STACK_SIZE) && STACK_SIZE < 12350\n#define VLEN (STACK_SIZE/10)\n#else\n#define VLEN 1235\n#endif\n\nint main (void)\n{\n  DB_TXNLIST el;\n  DB_LSN lsn, lsn_a[VLEN];\n  \n  el.u.l.ntxns = VLEN-1;\n  el.u.l.lsn_array = lsn_a;\n  \n  if (__db_txnlist_lsnadd (0, &el, &lsn, 0) != 1)\n    abort ();\n  \n  if (__db_txnlist_lsnadd (0, &el, &lsn, 1) != VLEN-1)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011019-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nstruct { int a; int b[5]; } x;\nint *y;\n\nint foo (void)\n{\n  return y - x.b;\n}\n\nint main (void)\n{\n  y = x.b;\n  if (foo ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011024-1.c",
    "content": "/* Test whether store motion recognizes pure functions as potentially reading\n   any memory.  */\n\ntypedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *dest, const void *src, size_t n);\nextern size_t strlen (const char *s);\nextern int strcmp (const char *s1, const char *s2) __attribute__((pure));\n\nchar buf[50];\n\nstatic void foo (void)\n{\n  if (memcpy (buf, \"abc\", 4) != buf) abort ();\n  if (strcmp (buf, \"abc\")) abort ();\n  memcpy (buf, \"abcdefgh\", strlen (\"abcdefgh\") + 1);\n}\n\nint main (void)\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011109-1.c",
    "content": "void fail1(void)\n{\n  abort ();\n}\nvoid fail2(void)\n{\n  abort ();\n}\nvoid fail3(void)\n{\n  abort ();\n}\nvoid fail4(void)\n{\n  abort ();\n}\n\n\nvoid foo(long x)\n{\n  switch (x)\n    {\n    case -6: \n      fail1 (); break;\n    case 0: \n      fail2 (); break;\n    case 1: case 2: \n      break;\n    case 3: case 4: case 5: \n      fail3 ();\n      break;\n    default:\n      fail4 ();\n      break;\n    }\n  switch (x)\n    {\n      \n    case -3: \n      fail1 (); break;\n    case 0: case 4: \n      fail2 (); break;\n    case 1: case 3: \n      break;\n    case 2: case 8: \n      abort ();\n      break;\n    default:\n      fail4 ();\n      break;\n    }\n}\n\nint main(void)\n{\n  foo (1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011109-2.c",
    "content": "int main(void)\n{\n  char *c1 = \"foo\";\n  char *c2 = \"foo\";\n  int i;\n  for (i = 0; i < 3; i++)\n    if (c1[i] != c2[i])\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011113-1.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nextern void *memcpy (void *__restrict, const void *__restrict, size_t);\nextern void abort (void);\nextern void exit (int);\n\ntypedef struct t\n{\n  unsigned a : 16;\n  unsigned b : 8;\n  unsigned c : 8;\n  long d[4];\n} *T;\n\ntypedef struct {\n  long r[3];\n} U;\n\nT bar (U, unsigned int);\n\nT foo (T x)\n{\n  U d, u;\n\n  memcpy (&u, &x->d[1], sizeof u);\n  d = u;\n  return bar (d, x->b);\n}\n\nT baz (T x)\n{\n  U d, u;\n\n  d.r[0] = 0x123456789;\n  d.r[1] = 0xfedcba987;\n  d.r[2] = 0xabcdef123;\n  memcpy (&u, &x->d[1], sizeof u);\n  d = u;\n  return bar (d, x->b);\n}\n\nT bar (U d, unsigned int m)\n{\n  if (d.r[0] != 21 || d.r[1] != 22 || d.r[2] != 23)\n    abort ();\n  return 0;\n}\n\nstruct t t = { 26, 0, 0, { 0, 21, 22, 23 }};\n\nint main (void)\n{\n  baz (&t);\n  foo (&t);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011114-1.c",
    "content": "char foo(char bar[])\n{\n  return bar[1];\n}\nextern char foo(char *);\nint main(void)\n{\n  if (foo(\"xy\") != 'y')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011115-1.c",
    "content": "extern void exit (int);\n\nstatic inline int\nfoo (void)\n{\n#ifdef __OPTIMIZE__\n  extern int undefined_reference;\n  return undefined_reference;\n#else\n  return 0;\n#endif\n}\n\nstatic inline int\nbar (void)\n{\n  if (foo == foo)\n    return 1;\n  else\n    return foo ();\n}\n\nint main (void)\n{\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011121-1.c",
    "content": "struct s\n{\n  int i[18];\n  char f;\n  char b[2];\n};\n\nstruct s s1;\n\nint\nmain()\n{\n  struct s s2;\n  s2.b[0] = 100;\n  __builtin_memcpy(&s2, &s1, ((unsigned int) &((struct s *)0)->b));\n  if (s2.b[0] != 100)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011126-1.c",
    "content": "/* Produced a overflow in ifcvt.c, causing S to contain 0xffffffff7fffffff.  */\n\nint a = 1;\n\nint main ()\n{\n  long long s;\n\n  s = a;\n  if (s < 0)\n    s = -2147483648LL;\n  else\n    s = 2147483647LL;\n\n  if (s < 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011126-2.c",
    "content": "/* Problem originally visible on ia64.\n\n   There is a partial redundancy of \"in + 1\" that makes GCSE want to\n   transform the final while loop to \n\n     p = in + 1;\n     tmp = p;\n     ...\n     goto start;\n   top:\n     tmp = tmp + 1;\n   start:\n     in = tmp;\n     if (in < p) goto top;\n\n   We miscalculate the number of loop iterations as (p - tmp) = 0\n   instead of (p - in) = 1, which results in overflow in the doloop\n   optimization.  */\n\nstatic const char *\ntest (const char *in, char *out)\n{\n  while (1)\n    {\n      if (*in == 'a')\n\t{\n\t  const char *p = in + 1;\n\t  while (*p == 'x')\n\t    ++p;\n\t  if (*p == 'b')\n\t    return p;\n\t  while (in < p)\n\t    *out++ = *in++;\n\t}\n    }\n}\n\nint main ()\n{\n  char out[4];\n  test (\"aab\", out);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011128-1.c",
    "content": "main()\n{\n  char blah[33] = \"01234567890123456789\";\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011217-1.c",
    "content": "int\nmain()\n{\n  double x = 1.0;\n  double y = 2.0;\n\n  if ((y > x--) != 1)\n    abort ();\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011219-1.c",
    "content": "/* This testcase failed on IA-32 at -O and above, because combine attached\n   a REG_LABEL note to jump instruction already using JUMP_LABEL.  */\n\nextern void abort (void);\nextern void exit (int);\n\nenum X { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q };\n\nvoid\nbar (const char *x, int y, const char *z)\n{\n}\n\nlong\nfoo (enum X x, const void *y)\n{\n  long a;\n\n  switch (x)\n    {\n    case K:\n      a = *(long *)y;\n      break;\n    case L:\n      a = *(long *)y;\n      break;\n    case M:\n      a = *(long *)y;\n      break;\n    case N:\n      a = *(long *)y;\n      break;\n    case O:\n      a = *(long *)y;\n      break;\n    default:\n      bar (\"foo\", 1, \"bar\");\n    }\n  return a;\n}\n\nint\nmain ()\n{\n  long i = 24;\n  if (foo (N, &i) != 24)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20011223-1.c",
    "content": "/* Origin: Joseph Myers <jsm28@cam.ac.uk>.  */\n/* Case labels in a switch statement are converted to the promoted\n   type of the controlling expression, not an unpromoted version.\n   Reported as PR c/2454 by\n   Andreas Krakowczyk <Andreas.Krakowczyk@fujitsu-siemens.com>.  */\n\nextern void exit (int);\nextern void abort (void);\n\nstatic int i;\n\nint\nmain (void)\n{\n  i = -1;\n  switch ((signed char) i) {\n  case 255:\n    abort ();\n  default:\n    exit (0);\n  }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020103-1.c",
    "content": "/* On h8300 port, the following used to be broken with -mh or -ms.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long\nfoo (unsigned long a)\n{\n  return a ^ 0x0000ffff;\n}\n\nunsigned long\nbar (unsigned long a)\n{\n  return a ^ 0xffff0000;\n}\n\nint\nmain ()\n{\n  if (foo (0) != 0x0000ffff)\n    abort ();\n\n  if (bar (0) != 0xffff0000)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020107-1.c",
    "content": "/* This testcase failed because - 1 - buf was simplified into ~buf and when\n   later expanding it back into - buf + -1, -1 got lost.  */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nstatic void\nbar (int x)\n{\n  if (!x)\n    abort ();\n}\n\nchar buf[10];\n\ninline char *\nfoo (char *tmp)\n{\n  asm (\"\" : \"=r\" (tmp) : \"0\" (tmp));\n  return tmp + 2;\n}\n\nint\nmain (void)\n{\n  bar ((foo (buf) - 1 - buf) == 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020108-1.c",
    "content": "/* This file tests shifts in various integral modes.  */\n\n#include <limits.h>\n\n#define CAT(A, B) A ## B\n\n#define REPEAT_8\t\\\nREPEAT_FN ( 0)\t\t\\\nREPEAT_FN ( 1)\t\t\\\nREPEAT_FN ( 2)\t\t\\\nREPEAT_FN ( 3)\t\t\\\nREPEAT_FN ( 4)\t\t\\\nREPEAT_FN ( 5)\t\t\\\nREPEAT_FN ( 6)\t\t\\\nREPEAT_FN ( 7)\n\n#define REPEAT_16\t\\\nREPEAT_8\t\t\\\nREPEAT_FN ( 8)\t\t\\\nREPEAT_FN ( 9)\t\t\\\nREPEAT_FN (10)\t\t\\\nREPEAT_FN (11)\t\t\\\nREPEAT_FN (12)\t\t\\\nREPEAT_FN (13)\t\t\\\nREPEAT_FN (14)\t\t\\\nREPEAT_FN (15)\n\n#define REPEAT_32\t\\\nREPEAT_16\t\t\\\nREPEAT_FN (16)\t\t\\\nREPEAT_FN (17)\t\t\\\nREPEAT_FN (18)\t\t\\\nREPEAT_FN (19)\t\t\\\nREPEAT_FN (20)\t\t\\\nREPEAT_FN (21)\t\t\\\nREPEAT_FN (22)\t\t\\\nREPEAT_FN (23)\t\t\\\nREPEAT_FN (24)\t\t\\\nREPEAT_FN (25)\t\t\\\nREPEAT_FN (26)\t\t\\\nREPEAT_FN (27)\t\t\\\nREPEAT_FN (28)\t\t\\\nREPEAT_FN (29)\t\t\\\nREPEAT_FN (30)\t\t\\\nREPEAT_FN (31)\n\n/* Define 8-bit shifts.  */\n#if CHAR_BIT == 8\ntypedef unsigned int u8 __attribute__((mode(QI)));\ntypedef signed int s8 __attribute__((mode(QI)));\n\n#define REPEAT_FN(COUNT) \\\nu8 CAT (ashift_qi_, COUNT) (u8 n) { return n << COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu8 CAT (lshiftrt_qi_, COUNT) (u8 n) { return n >> COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns8 CAT (ashiftrt_qi_, COUNT) (s8 n) { return n >> COUNT; }\nREPEAT_8\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 */\n\n/* Define 16-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16\n#if CHAR_BIT == 8\ntypedef unsigned int u16 __attribute__((mode(HI)));\ntypedef signed int s16 __attribute__((mode(HI)));\n#elif CHAR_BIT == 16\ntypedef unsigned int u16 __attribute__((mode(QI)));\ntypedef signed int s16 __attribute__((mode(QI)));\n#endif\n\n#define REPEAT_FN(COUNT) \\\nu16 CAT (ashift_hi_, COUNT) (u16 n) { return n << COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu16 CAT (lshiftrt_hi_, COUNT) (u16 n) { return n >> COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns16 CAT (ashiftrt_hi_, COUNT) (s16 n) { return n >> COUNT; }\nREPEAT_16\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */\n\n/* Define 32-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32\n#if CHAR_BIT == 8\ntypedef unsigned int u32 __attribute__((mode(SI)));\ntypedef signed int s32 __attribute__((mode(SI)));\n#elif CHAR_BIT == 16\ntypedef unsigned int u32 __attribute__((mode(HI)));\ntypedef signed int s32 __attribute__((mode(HI)));\n#elif CHAR_BIT == 32\ntypedef unsigned int u32 __attribute__((mode(QI)));\ntypedef signed int s32 __attribute__((mode(QI)));\n#endif\n\n#define REPEAT_FN(COUNT) \\\nu32 CAT (ashift_si_, COUNT) (u32 n) { return n << COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\nu32 CAT (lshiftrt_si_, COUNT) (u32 n) { return n >> COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n\n#define REPEAT_FN(COUNT) \\\ns32 CAT (ashiftrt_si_, COUNT) (s32 n) { return n >> COUNT; }\nREPEAT_32\n#undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain ()\n{\n  /* Test 8-bit shifts.  */\n#if CHAR_BIT == 8\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashift_qi_, COUNT) (0xff) != (u8) ((u8)0xff << COUNT)) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (lshiftrt_qi_, COUNT) (0xff) != (u8) ((u8)0xff >> COUNT)) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_qi_, COUNT) (-1) != -1) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_qi_, COUNT) (0) != 0) abort ();\n  REPEAT_8;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 */\n\n  /* Test 16-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16\n# define REPEAT_FN(COUNT)\t\t\t\\\n  if (CAT (ashift_hi_, COUNT) (0xffff)\t\t\\\n      != (u16) ((u16) 0xffff << COUNT)) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT)\t\t\t\\\n  if (CAT (lshiftrt_hi_, COUNT) (0xffff)\t\\\n      != (u16) ((u16) 0xffff >> COUNT)) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_hi_, COUNT) (-1) != -1) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_hi_, COUNT) (0) != 0) abort ();\n  REPEAT_16;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 */\n\n  /* Test 32-bit shifts.  */\n#if CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32\n# define REPEAT_FN(COUNT)\t\t\t\t\\\n  if (CAT (ashift_si_, COUNT) (0xffffffff)\t\t\\\n      != (u32) ((u32) 0xffffffff << COUNT)) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT)\t\t\t\t\\\n  if (CAT (lshiftrt_si_, COUNT) (0xffffffff)\t\t\\\n      != (u32) ((u32) 0xffffffff >> COUNT)) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_si_, COUNT) (-1) != -1) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n\n# define REPEAT_FN(COUNT) \\\n  if (CAT (ashiftrt_si_, COUNT) (0) != 0) abort ();\n  REPEAT_32;\n# undef REPEAT_FN\n#endif /* CHAR_BIT == 8 || CHAR_BIT == 16 || CHAR_BIT == 32 */\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020118-1.c",
    "content": "/* This tests an insn length of sign extension on h8300 port.  */\n\nextern void exit (int);\n\nvolatile signed char *q;\nvolatile signed int n;\n\nvoid\nfoo (void)\n{\n  signed char *p;\n\n  for (;;)\n    {\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n      p = (signed char *) q; n = p[2];\n    }\n}\n\nint\nmain ()\n{\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020127-1.c",
    "content": "/* This used to fail on h8300.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long\nfoo (unsigned long n)\n{\n  return (~n >> 3) & 1;\n}\n\nint\nmain ()\n{\n  if (foo (1 << 3) != 0)\n    abort ();\n\n  if (foo (0) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020129-1.c",
    "content": "/* This testcase failed at -O2 on IA-64, because scheduling did not take\n   into account conditional execution when using cselib for alias\n   analysis.  */\n\nstruct D { int d1; struct D *d2; };\nstruct C { struct D c1; long c2, c3, c4, c5, c6; };\nstruct A { struct A *a1; struct C *a2; };\nstruct B { struct C b1; struct A *b2; };\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (struct B *x, struct B *y)\n{\n  if (x->b2 == 0)\n    {\n      struct A *a;\n\n      x->b2 = a = y->b2;\n      y->b2 = 0;\n      for (; a; a = a->a1)\n\ta->a2 = &x->b1;\n    }\n\n  if (y->b2 != 0)\n    abort ();\n\n  if (x->b1.c3 == -1)\n    {\n      x->b1.c3 = y->b1.c3;\n      x->b1.c4 = y->b1.c4;\n      y->b1.c3 = -1;\n      y->b1.c4 = 0;\n    }\n\n  if (y->b1.c3 != -1)\n    abort ();\n}\n\nstruct B x, y;\n\nint main ()\n{\n  y.b1.c1.d1 = 6;\n  y.b1.c3 = 145;\n  y.b1.c4 = 2448;\n  x.b1.c3 = -1;\n  foo (&x, &y);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020201-1.c",
    "content": "/* Test whether division by constant works properly.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned char cx = 7;\nunsigned short sx = 14;\nunsigned int ix = 21;\nunsigned long lx = 28;\nunsigned long long Lx = 35;\n\nint\nmain ()\n{\n  unsigned char cy;\n  unsigned short sy;\n  unsigned int iy;\n  unsigned long ly;\n  unsigned long long Ly;\n  \n  cy = cx / 6; if (cy != 1) abort ();\n  cy = cx % 6; if (cy != 1) abort ();\n\n  sy = sx / 6; if (sy != 2) abort ();\n  sy = sx % 6; if (sy != 2) abort ();\n\n  iy = ix / 6; if (iy != 3) abort ();\n  iy = ix % 6; if (iy != 3) abort ();\n\n  ly = lx / 6; if (ly != 4) abort ();\n  ly = lx % 6; if (ly != 4) abort ();\n\n  Ly = Lx / 6; if (Ly != 5) abort ();\n  Ly = Lx % 6; if (Ly != 5) abort ();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020206-1.c",
    "content": "struct A {\n  unsigned int a, b, c;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nstruct A bar (void)\n{\n  return (struct A) { 176, 52, 31 };\n}\n\nvoid baz (struct A *a)\n{\n  if (a->a != 176 || a->b != 52 || a->c != 31)\n    abort ();\n}\n\nint main ()\n{\n  struct A d;\n\n  d = ({ ({ bar (); }); });\n  baz (&d);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020206-2.c",
    "content": "/* Origin: PR c/5420 from David Mosberger <davidm@hpl.hp.com>.\n   This testcase was miscompiled when tail call optimizing, because a\n   compound literal initialization was emitted only in the tail call insn\n   chain, not in the normal call insn chain.  */\n\ntypedef struct { unsigned short a; } A;\n\nextern void abort (void);\nextern void exit (int);\n\nvoid foo (unsigned int x)\n{\n  if (x != 0x800 && x != 0x810)\n    abort ();\n}\n\nint\nmain (int argc, char **argv)\n{\n  int i;\n  for (i = 0; i < 2; ++i)\n    foo (((A) { ((!(i >> 4) ? 8 : 64 + (i >> 4)) << 8) + (i << 4) } ).a);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020213-1.c",
    "content": "/* PR c/5681\n   This testcase failed on IA-32 at -O0, because safe_from_p\n   incorrectly assumed it is safe to first write into a.a2 b-1\n   and then read the original value from it.  */\n\nint bar (float);\n\nstruct A {\n  float a1;\n  int a2;\n} a;\n\nint b;\n\nvoid foo (void)\n{\n  a.a2 = bar (a.a1);\n  a.a2 = a.a2 < b - 1 ? a.a2 : b - 1;\n  if (a.a2 >= b - 1)\n    abort ();\n}\n\nint bar (float x)\n{\n  return 2241;\n}\n\nint main()\n{\n  a.a1 = 1.0f;\n  b = 3384;\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020215-1.c",
    "content": "/* Test failed on an architecture that:\n\n   - had 16-bit registers,\n   - passed 64-bit structures in registers,\n   - only allowed SImode values in even numbered registers.\n\n   Before reload, s.i2 in foo() was represented as:\n\n\t(subreg:SI (reg:DI 0) 2)\n\n   find_dummy_reload would return (reg:SI 1) for the subreg reload,\n   despite that not being a valid register.  */\n\nstruct s\n{\n  short i1;\n  long i2;\n  short i3;\n};\n\nstruct s foo (struct s s)\n{\n  s.i2++;\n  return s;\n}\n\nint main ()\n{\n  struct s s = foo ((struct s) { 1000, 2000L, 3000 });\n  if (s.i1 != 1000 || s.i2 != 2001L || s.i3 != 3000)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020216-1.c",
    "content": "/* PR c/3444\n   This used to fail because bitwise xor was improperly computed in char type\n   and sign extended to int type.  */\n\nextern void abort ();\nextern void exit (int);\n\nsigned char c = (signed char) 0xffffffff;\n\nint foo (void)\n{\n  return (unsigned short) c ^ (signed char) 0x99999999;\n}\n\nint main (void)\n{\n  if ((unsigned char) -1 != 0xff\n      || sizeof (short) != 2\n      || sizeof (int) != 4)\n    exit (0);\n  if (foo () != (int) 0xffff0066)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020219-1.c",
    "content": "/* PR c/4308\n   This testcase failed because 0x8000000000000000 >> 0\n   was incorrectly folded into 0xffffffff00000000.  */\n\nextern void abort (void);\nextern void exit (int);\n\nlong long foo (void)\n{\n  long long C = 1ULL << 63, X;\n  int Y = 32;\n  X = C >> (Y & 31);\n  return X;\n}\n\nint main (void)\n{\n  if (foo () != 1ULL << 63)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020225-1.c",
    "content": "/* This testcase failed at -O2 on powerpc64 due to andsi3 writing\n   nonzero bits to the high 32 bits of a 64 bit register.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned long foo (unsigned long base, unsigned int val)\n{\n  return base + (val & 0x80000001);\n}\n\nint main (void)\n{\n  if (foo (0L, 0x0ffffff0) != 0L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020225-2.c",
    "content": "static int \ntest(int x)\n{\n  union \n    {\n      int i;\n      double d;\n  } a;\n  a.d = 0;\n  a.i = 1;\n  return x >> a.i;\n}\n\nint main(void)\n{\n  if (test (5) != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020226-1.c",
    "content": "/* This tests the rotate patterns that some machines support.  */\n\n#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((unsigned char)0x1234U)\n#define SHORT_VALUE ((unsigned short)0x1234U)\n#define INT_VALUE 0x1234U\n#define LONG_VALUE 0x12345678LU\n#define LL_VALUE 0x12345678abcdef0LLU\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nunsigned char uc = CHAR_VALUE;\nunsigned short us = SHORT_VALUE;\nunsigned int ui = INT_VALUE;\nunsigned long ul = LONG_VALUE;\nunsigned long long ull = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020227-1.c",
    "content": "/* This testcase failed on mmix-knuth-mmixware.  Problem was with storing\n   to an unaligned mem:SC, gcc tried doing it by parts from a (concat:SC\n   (reg:SF 293) (reg:SF 294)).  */\n\ntypedef __complex__ float cf;\nstruct x { char c; cf f; } __attribute__ ((__packed__));\nextern void f2 (struct x*);\nextern void f1 (void);\nint\nmain (void)\n{\n  f1 ();\n  exit (0);\n}\n\nvoid\nf1 (void)\n{\n  struct x s;\n  s.f = 1;\n  s.c = 42;\n  f2 (&s);\n}\n\nvoid\nf2 (struct x *y)\n{\n  if (y->f != 1 || y->c != 42)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020307-1.c",
    "content": "#define MASK(N) ((1UL << (N)) - 1)\n#define BITS(N) ((1UL << ((N) - 1)) + 2)\n\n#define FUNC(N) void f##N(long j) { if ((j & MASK(N)) >= BITS(N)) abort();}\n\nFUNC(3)\nFUNC(4)\nFUNC(5)\nFUNC(6)\nFUNC(7)\nFUNC(8)\nFUNC(9)\nFUNC(10)\nFUNC(11)\nFUNC(12)\nFUNC(13)\nFUNC(14)\nFUNC(15)\nFUNC(16)\nFUNC(17)\nFUNC(18)\nFUNC(19)\nFUNC(20)\nFUNC(21)\nFUNC(22)\nFUNC(23)\nFUNC(24)\nFUNC(25)\nFUNC(26)\nFUNC(27)\nFUNC(28)\nFUNC(29)\nFUNC(30)\nFUNC(31)\n\nint main ()\n{\n  f3(0);\n  f4(0);\n  f5(0);\n  f6(0);\n  f7(0);\n  f8(0);\n  f9(0);\n  f10(0);\n  f11(0);\n  f12(0);\n  f13(0);\n  f14(0);\n  f15(0);\n  f16(0);\n  f17(0);\n  f18(0);\n  f19(0);\n  f20(0);\n  f21(0);\n  f22(0);\n  f23(0);\n  f24(0);\n  f25(0);\n  f26(0);\n  f27(0);\n  f28(0);\n  f29(0);\n  f30(0);\n  f31(0);\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020314-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nvoid f(void * a, double y)\n{\n}\n\ndouble g (double a, double b, double c, double d)\n{\n  double x, y, z;\n  void *p;\n\n  x = a + b;\n  y = c * d;\n\n  p = alloca (16);\n\n  f(p, y);\n  z = x * y * a;\n\n  return z + b;\n}\n\nmain ()\n{\n  double a, b, c, d;\n  a = 1.0;\n  b = 0.0;\n  c = 10.0;\n  d = 0.0;\n\n  if (g (a, b, c, d) != 0.0)\n    abort ();\n\n  if (a != 1.0 || b != 0.0 || c != 10.0 || d != 0.0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020320-1.c",
    "content": "/* PR c/5354 */\n/* Verify that GCC preserves relevant stack slots.  */\n\nextern void abort(void);\nextern void exit(int);\n\nstruct large { int x, y[9]; };\n\nint main()\n{\n  int fixed;\n\n  fixed = ({ int temp1 = 2; temp1; }) - ({ int temp2 = 1; temp2; });\n  if (fixed != 1)\n    abort();\n\n  fixed = ({ struct large temp3; temp3.x = 2; temp3; }).x\n\t  - ({ struct large temp4; temp4.x = 1; temp4; }).x;\n  if (fixed != 1)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020321-1.c",
    "content": "/* PR 3177 */\n/* Produced a SIGILL on ia64 with sibcall from F to G.  We hadn't\n   widened the register window to allow for the fourth outgoing\n   argument as an \"in\" register.  */\n\nfloat g (void *a, void *b, int e, int c, float d)\n{\n  return d;\n}\n\nfloat f (void *a, void *b, int c, float d)\n{\n  return g (a, b, 0, c, d);\n}\n\nint main ()\n{\n  f (0, 0, 1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020328-1.c",
    "content": "int b = 0;\n\nfunc () { }\n\nvoid\ntestit(int x)\n{\n  if (x != 20)\n    abort ();\n}\n\nint\nmain()\n\n{\n  int a = 0;\n\n  if (b)\n    func();\n\n  /* simplify_and_const_int would incorrectly omit the mask in\n     the line below.  */\n  testit ((a + 23) & 0xfffffffc);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020402-1.c",
    "content": "/* derived from PR c/2100 */\n\nextern void abort ();\nextern void exit (int);\n\n#define SMALL_N  2\n#define NUM_ELEM 4\n\nint main(void)\n{\n  int listElem[NUM_ELEM]={30,2,10,5};\n  int listSmall[SMALL_N];\n  int i, j;\n  int posGreatest=-1, greatest=-1;\n\n  for (i=0; i<SMALL_N; i++) { \n    listSmall[i] = listElem[i];\n    if (listElem[i] > greatest) {\n      posGreatest = i;\n      greatest = listElem[i];\n    }\n  }\n  \n  for (i=SMALL_N; i<NUM_ELEM; i++) { \n    if (listElem[i] < greatest) {\n      listSmall[posGreatest] = listElem[i];\n      posGreatest = 0;\n      greatest = listSmall[0];\n      for (j=1; j<SMALL_N; j++) \n\tif (listSmall[j] > greatest) {\n\t  posGreatest = j;\n\t  greatest = listSmall[j];\n\t}\n    }\n  }\n\n  if (listSmall[0] != 5 || listSmall[1] != 2)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020402-2.c",
    "content": "/* PR 3967\n\n   local-alloc screwed up consideration of high+lo_sum and created\n   reg_equivs that it shouldn't have, resulting in lo_sum with\n   uninitialized data, resulting in segv.  The test has to remain\n   relatively large, since register spilling is required to twig\n   the bug.  */\n\nunsigned long *Local1;\nunsigned long *Local2;\nunsigned long *Local3;\nunsigned long *RDbf1;\nunsigned long *RDbf2;\nunsigned long *RDbf3;\nunsigned long *IntVc1;\nunsigned long *IntVc2;\nunsigned long *IntCode3;\nunsigned long *IntCode4;\nunsigned long *IntCode5;\nunsigned long *IntCode6;\nunsigned long *Lom1;\nunsigned long *Lom2;\nunsigned long *Lom3;\nunsigned long *Lom4;\nunsigned long *Lom5;\nunsigned long *Lom6;\nunsigned long *Lom7;\nunsigned long *Lom8;\nunsigned long *Lom9;\nunsigned long *Lom10;\nunsigned long *RDbf11;\nunsigned long *RDbf12;\n\ntypedef struct\n  {\n    long a1;\n    unsigned long n1;\n    unsigned long local1;\n    unsigned long local2;\n    unsigned long local3;\n    unsigned long rdbf1;\n    unsigned long rdbf2;\n    unsigned long milli;\n    unsigned long frames1;\n    unsigned long frames2;\n    unsigned long nonShared;\n    long newPrivate;\n    long freeLimit;\n    unsigned long cache1;\n    unsigned long cache2;\n    unsigned long cache3;\n    unsigned long cache4;\n    unsigned long cache5;\n    unsigned long time6;\n    unsigned long frames7;\n    unsigned long page8;\n    unsigned long ot9;\n    unsigned long data10;\n    unsigned long bm11;\n    unsigned long misc12;\n  }\nShrPcCommonStatSType;\n\n\ntypedef struct\n  {\n    unsigned long sharedAttached;\n    unsigned long totalAttached;\n    long avgPercentShared;\n    unsigned long numberOfFreeFrames;\n    unsigned long localDirtyPageCount;\n    unsigned long globalDirtyPageCount;\n    long wakeupInterval;\n    unsigned long numActiveProcesses;\n    unsigned long numRecentActiveProcesses;\n    unsigned long gemDirtyPageKinds[10];\n    unsigned long stoneDirtyPageKinds[10];\n    unsigned long gemsInCacheCount;\n    long targetFreeFrameCount;\n  }\nShrPcMonStatSType;\n\ntypedef struct\n  {\n    unsigned long c1;\n    unsigned long c2;\n    unsigned long c3;\n    unsigned long c4;\n    unsigned long c5;\n    unsigned long c6;\n    unsigned long c7;\n    unsigned long c8;\n    unsigned long c9;\n    unsigned long c10;\n    unsigned long c11;\n    unsigned long c12;\n    unsigned long a1;\n    unsigned long a2;\n    unsigned long a3;\n    unsigned long a4;\n    unsigned long a5;\n    unsigned long a6;\n    unsigned long a7;\n    unsigned long a8;\n    unsigned long a9;\n    unsigned long a10;\n    unsigned long a11;\n    unsigned long a12;\n    unsigned long a13;\n    unsigned long a14;\n    unsigned long a15;\n    unsigned long a16;\n    unsigned long a17;\n    unsigned long a18;\n    unsigned long a19;\n    unsigned long sessionStats[40];\n  }\nShrPcGemStatSType;\n\nunion ShrPcStatUnion\n  {\n    ShrPcMonStatSType monitor;\n    ShrPcGemStatSType gem;\n  };\n\ntypedef struct\n  {\n    int processId;\n    int sessionId;\n    ShrPcCommonStatSType cmn;\n    union ShrPcStatUnion u;\n  } ShrPcStatsSType;\n\ntypedef struct\n  {\n    unsigned long *p1;\n    unsigned long *p2;\n    unsigned long *p3;\n    unsigned long *p4;\n    unsigned long *p5;\n    unsigned long *p6;\n    unsigned long *p7;\n    unsigned long *p8;\n    unsigned long *p9;\n    unsigned long *p10;\n    unsigned long *p11;\n  }\nWorkEntrySType;\n\nWorkEntrySType Workspace;\n\nstatic void \nsetStatPointers (ShrPcStatsSType * statsPtr, long sessionId)\n{\n  statsPtr->sessionId = sessionId;\n  statsPtr->cmn.a1 = 0;\n  statsPtr->cmn.n1 = 5;\n\n  Local1 = &statsPtr->cmn.local1;\n  Local2 = &statsPtr->cmn.local2;\n  Local3 = &statsPtr->cmn.local3;\n  RDbf1 = &statsPtr->cmn.rdbf1;\n  RDbf2 = &statsPtr->cmn.rdbf2;\n  RDbf3 = &statsPtr->cmn.milli;\n  *RDbf3 = 1;\n\n  IntVc1 = &statsPtr->u.gem.a1;\n  IntVc2 = &statsPtr->u.gem.a2;\n  IntCode3 = &statsPtr->u.gem.a3;\n  IntCode4 = &statsPtr->u.gem.a4;\n  IntCode5 = &statsPtr->u.gem.a5;\n  IntCode6 = &statsPtr->u.gem.a6;\n\n  {\n    WorkEntrySType *workSpPtr;\n    workSpPtr = &Workspace;\n    workSpPtr->p1 = &statsPtr->u.gem.a7;\n    workSpPtr->p2 = &statsPtr->u.gem.a8;\n    workSpPtr->p3 = &statsPtr->u.gem.a9;\n    workSpPtr->p4 = &statsPtr->u.gem.a10;\n    workSpPtr->p5 = &statsPtr->u.gem.a11;\n    workSpPtr->p6 = &statsPtr->u.gem.a12;\n    workSpPtr->p7 = &statsPtr->u.gem.a13;\n    workSpPtr->p8 = &statsPtr->u.gem.a14;\n    workSpPtr->p9 = &statsPtr->u.gem.a15;\n    workSpPtr->p10 = &statsPtr->u.gem.a16;\n    workSpPtr->p11 = &statsPtr->u.gem.a17;\n  }\n  Lom1 = &statsPtr->u.gem.c1;\n  Lom2 = &statsPtr->u.gem.c2;\n  Lom3 = &statsPtr->u.gem.c3;\n  Lom4 = &statsPtr->u.gem.c4;\n  Lom5 = &statsPtr->u.gem.c5;\n  Lom6 = &statsPtr->u.gem.c6;\n  Lom7 = &statsPtr->u.gem.c7;\n  Lom8 = &statsPtr->u.gem.c8;\n  Lom9 = &statsPtr->u.gem.c9;\n  Lom10 = &statsPtr->u.gem.c10;\n  RDbf11 = &statsPtr->u.gem.c11;\n  RDbf12 = &statsPtr->u.gem.c12;\n}\n\ntypedef struct\n{\n  ShrPcStatsSType stats;\n} ShrPcPteSType;\n\nShrPcPteSType MyPte;\n\nstatic void \ninitPte (void *shrpcPtr, long sessionId)\n{\n  ShrPcPteSType *ptePtr;\n\n  ptePtr = &MyPte;\n  setStatPointers (&ptePtr->stats, sessionId);\n}\n\nvoid \nInitCache (int sessionId)\n{\n  initPte (0, sessionId);\n}\n\nint \nmain (int argc, char *argv[])\n{\n  InitCache (5);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020402-3.c",
    "content": "/* extracted from gdb sources */\n\ntypedef unsigned long long CORE_ADDR;\n\nstruct blockvector;\n\nstruct symtab {\n  struct blockvector *blockvector;\n};\n\nstruct sec {\n  void *unused;\n};\n\nstruct symbol {\n  int len;\n  char *name;\n};\n\nstruct block {\n\tCORE_ADDR startaddr, endaddr;\n\tstruct symbol *function;\n\tstruct block *superblock;\n\tunsigned char gcc_compile_flag;\n\tint nsyms;\n\tstruct symbol syms[1];\n};\n\nstruct blockvector {\n\tint nblocks;\n\tstruct block *block[2];\n};\n\nstruct blockvector *blockvector_for_pc_sect(register CORE_ADDR pc,\n\t\t\t\t\t    struct symtab *symtab)\n{\n  register struct block *b;\n  register int bot, top, half;\n  struct blockvector *bl;\n\n  bl = symtab->blockvector;\n  b = bl->block[0];\n\n  bot = 0;\n  top = bl->nblocks;\n\n  while (top - bot > 1)\n    {\n      half = (top - bot + 1) >> 1;\n      b = bl->block[bot + half];\n      if (b->startaddr <= pc)\n\tbot += half;\n      else\n\ttop = bot + half;\n    }\n\n  while (bot >= 0)\n    {\n      b = bl->block[bot];\n      if (b->endaddr > pc)\n\t{\n\t  return bl;\n\t}\n      bot--;\n    }\n  return 0;\n}\n\nint main(void)\n{\n  struct block a = { 0, 0x10000, 0, 0, 1, 20 };\n  struct block b = { 0x10000, 0x20000, 0, 0, 1, 20 };\n  struct blockvector bv = { 2, { &a, &b } };\n  struct symtab s = { &bv };\n\n  struct blockvector *ret;\n\n  ret = blockvector_for_pc_sect(0x500, &s);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020404-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-skip-if \"pointers can be truncated\" { m32c-*-* } \"*\" \"\" } */\n/* Extracted from GDB sources. */\n\ntypedef long long bfd_signed_vma;\ntypedef bfd_signed_vma file_ptr;\n\ntypedef enum bfd_boolean {false, true} boolean;\n\ntypedef unsigned long long bfd_size_type;\n\ntypedef unsigned int flagword;\n\ntypedef unsigned long long CORE_ADDR;\ntypedef unsigned long long bfd_vma;\n\nstruct bfd_struct {\n\tint x;\n};\n\nstruct asection_struct {\n  unsigned int user_set_vma : 1;\n  bfd_vma vma;\n  bfd_vma lma;\n  unsigned int alignment_power;\n  unsigned int entsize;\n};\n\ntypedef struct bfd_struct bfd;\ntypedef struct asection_struct asection;\n\nstatic bfd *\nbfd_openw_with_cleanup (char *filename, const char *target, char *mode);\n\nstatic asection *\nbfd_make_section_anyway (bfd *abfd, const char *name);\n\nstatic boolean\nbfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val);\n\nstatic boolean\nbfd_set_section_flags (bfd *abfd, asection *sec, flagword flags);\n\nstatic boolean\nbfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count);\n\nstatic void\ndump_bfd_file (char *filename, char *mode,\n               char *target, CORE_ADDR vaddr,\n               char *buf, int len)\n{\n  bfd *obfd;\n  asection *osection;\n\n  obfd = bfd_openw_with_cleanup (filename, target, mode);\n  osection = bfd_make_section_anyway (obfd, \".newsec\");\n  bfd_set_section_size (obfd, osection, len);\n  (((osection)->vma = (osection)->lma= (vaddr)), ((osection)->user_set_vma = (boolean)true), true);\n  (((osection)->alignment_power = (0)),true);\n  bfd_set_section_flags (obfd, osection, 0x203);\n  osection->entsize = 0;\n  bfd_set_section_contents (obfd, osection, buf, 0, len);\n}\n\nstatic bfd *\nbfd_openw_with_cleanup (char *filename, const char *target, char *mode)\n{\n\tstatic bfd foo_bfd = { 0 };\n\treturn &foo_bfd;\n}\n\nstatic asection *\nbfd_make_section_anyway (bfd *abfd, const char *name)\n{\n\tstatic asection foo_section = { false, 0x0, 0x0, 0 };\n\n\treturn &foo_section;\n}\n\nstatic boolean\nbfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val)\n{\n\treturn true;\n}\n\nstatic boolean\nbfd_set_section_flags (bfd *abfd, asection *sec, flagword flags)\n{\n}\n\nstatic boolean\nbfd_set_section_contents (bfd *abfd, asection *section, void * data, file_ptr offset, bfd_size_type count)\n{\n\tif (count != (bfd_size_type)0x1eadbeef)\n\t\tabort();\n}\n\nstatic char hello[] = \"hello\";\n\nint main(void)\n{\n\tdump_bfd_file(0, 0, 0, (CORE_ADDR)0xdeadbeef, hello, (int)0x1eadbeef);\n\texit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020406-1.c",
    "content": "// Origin: abbott@dima.unige.it\n// PR c/5120\n\nextern void * malloc (__SIZE_TYPE__);\nextern void * calloc (__SIZE_TYPE__, __SIZE_TYPE__);\n\ntypedef unsigned int FFelem;\n\nFFelem FFmul(const FFelem x, const FFelem y)\n{\n  return x;\n}\n\n\nstruct DUPFFstruct\n{\n  int maxdeg;\n  int deg;\n  FFelem *coeffs;\n};\n\ntypedef struct DUPFFstruct *DUPFF;\n\n\nint DUPFFdeg(const DUPFF f)\n{\n  return f->deg;\n}\n\n\nDUPFF DUPFFnew(const int maxdeg)\n{\n  DUPFF ans = (DUPFF)malloc(sizeof(struct DUPFFstruct));\n  ans->coeffs = 0;\n  if (maxdeg >= 0) ans->coeffs = (FFelem*)calloc(maxdeg+1,sizeof(FFelem));\n  ans->maxdeg = maxdeg;\n  ans->deg = -1;\n  return ans;\n}\n\nvoid DUPFFfree(DUPFF x)\n{\n}\n\nvoid DUPFFswap(DUPFF x, DUPFF y)\n{\n}\n\n\nDUPFF DUPFFcopy(const DUPFF x)\n{\n  return x;\n}\n\n\nvoid DUPFFshift_add(DUPFF f, const DUPFF g, int deg, const FFelem coeff)\n{\n}\n\n\nDUPFF DUPFFexgcd(DUPFF *fcofac, DUPFF *gcofac, const DUPFF f, const DUPFF g)\n{\n  DUPFF u, v, uf, ug, vf, vg;\n  FFelem q, lcu, lcvrecip, p;\n  int df, dg, du, dv;\n\n  printf(\"DUPFFexgcd called on degrees %d and %d\\n\", DUPFFdeg(f), DUPFFdeg(g));\n  if (DUPFFdeg(f) < DUPFFdeg(g)) return DUPFFexgcd(gcofac, fcofac, g, f);  /*** BUG IN THIS LINE ***/\n  if (DUPFFdeg(f) != 2 || DUPFFdeg(g) != 1) abort();\n  if (f->coeffs[0] == 0) return f;\n  /****** NEVER REACH HERE IN THE EXAMPLE ******/\n  p = 2;\n\n  df = DUPFFdeg(f);  if (df < 0) df = 0; /* both inputs are zero */\n  dg = DUPFFdeg(g);  if (dg < 0) dg = 0; /* one input is zero */\n  u = DUPFFcopy(f);\n  v = DUPFFcopy(g);\n\n  uf = DUPFFnew(dg); uf->coeffs[0] = 1; uf->deg = 0;\n  ug = DUPFFnew(df);\n  vf = DUPFFnew(dg);\n  vg = DUPFFnew(df); vg->coeffs[0] = 1; vg->deg = 0;\n\n  while (DUPFFdeg(v) > 0)\n  {\n    dv = DUPFFdeg(v);\n    lcvrecip = FFmul(1, v->coeffs[dv]);\n    while (DUPFFdeg(u) >= dv)\n    {\n      du = DUPFFdeg(u);\n      lcu = u->coeffs[du];\n      q = FFmul(lcu, lcvrecip);\n      DUPFFshift_add(u, v, du-dv, p-q);\n      DUPFFshift_add(uf, vf, du-dv, p-q);\n      DUPFFshift_add(ug, vg, du-dv, p-q);\n    }\n    DUPFFswap(u, v);\n    DUPFFswap(uf, vf);\n    DUPFFswap(ug, vg);\n  }\n  if (DUPFFdeg(v) == 0)\n  {\n    DUPFFswap(u, v);\n    DUPFFswap(uf, vf);\n    DUPFFswap(ug, vg);\n  }\n  DUPFFfree(vf);\n  DUPFFfree(vg);\n  DUPFFfree(v);\n  *fcofac = uf;\n  *gcofac = ug;\n  return u;\n}\n\n\n\nint main()\n{\n  DUPFF f, g, cf, cg, h;\n  f = DUPFFnew(1); f->coeffs[1] = 1; f->deg = 1;\n  g = DUPFFnew(2); g->coeffs[2] = 1; g->deg = 2;\n\n  printf(\"calling DUPFFexgcd on degrees %d and %d\\n\", DUPFFdeg(f), DUPFFdeg(g)) ;\n  h = DUPFFexgcd(&cf, &cg, f, g);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020411-1.c",
    "content": "/* PR optimization/6177\n   This testcase ICEd because expr.c did not expect to see a CONCAT\n   as array rtl.  */\n\nextern void abort (void);\nextern void exit (int);\n\n__complex__ float foo (void)\n{\n  __complex__ float f[1];\n  __real__ f[0] = 1.0;\n  __imag__ f[0] = 1.0;\n  f[0] = __builtin_conjf (f[0]);\n  return f[0];\n}\n\nint main (void)\n{\n  __complex__ double d[1];\n  d[0] = foo ();\n  if (__real__ d[0] != 1.0\n      || __imag__ d[0] != -1.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020412-1.c",
    "content": "/* PR c/3711\n   This testcase ICEd on IA-32 at -O0 and was miscompiled otherwise,\n   because std_expand_builtin_va_arg didn't handle variable size types.  */\n/* { dg-require-effective-target alloca } */\n\n#include <stdarg.h>\n\nextern void abort (void);\nextern void exit (int);\n\nvoid bar (int c)\n{\n  static int d = '0';\n\n  if (c != d++)\n    abort ();\n  if (c < '0' || c > '9')\n    abort ();\n}\n\nvoid foo (int size, ...)\n{\n  struct\n  {\n    char x[size];\n  } d;\n  va_list ap;\n  int i;\n\n  va_start (ap, size);\n  d = va_arg (ap, typeof (d));\n  for (i = 0; i < size; i++)\n    bar (d.x[i]);\n  d = va_arg (ap, typeof (d));\n  for (i = 0; i < size; i++)\n    bar (d.x[i]);\n  va_end (ap);\n}\n\nint main (void)\n{\n  int z = 5;\n  struct { char a[z]; } x, y;\n          \n  x.a[0] = '0';\n  x.a[1] = '1';\n  x.a[2] = '2';\n  x.a[3] = '3';\n  x.a[4] = '4';\n  y.a[0] = '5';\n  y.a[1] = '6';\n  y.a[2] = '7';\n  y.a[3] = '8';\n  y.a[4] = '9';\n  foo (z, x, y);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020413-1.c",
    "content": "void test(long double val, int *eval)\n{\n  long double tmp = 1.0l;\n  int i = 0;\n\n  if (val < 0.0l)\n    val = -val;\n\n  if (val >= tmp)\n    while (tmp < val)\n      {\n\ttmp *= 2.0l;\n\tif (i++ >= 10)\n\t  abort ();\n      }\n  else if (val != 0.0l)\n    while (val < tmp)\n      {\n\ttmp /= 2.0l;\n\tif (i++ >= 10)\n\t  abort ();\n      }\n\n  *eval = i;\n}\n\nint main(void)\n{\n  int eval;\n\n  test(3.0, &eval);\n  test(3.5, &eval);\n  test(4.0, &eval);\n  test(5.0, &eval);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020418-1.c",
    "content": "/* ifcvt accidentally deletes a referenced label while generating\n   conditional traps on machines having such patterns */\n\nstruct foo { int a; };\n\nvoid gcc_crash(struct foo *p)\n{\n\tif (__builtin_expect(p->a < 52, 0))\n\t\t__builtin_trap();\n top:\n\tp->a++;\n\tif (p->a >= 62)\n\t\tgoto top;\n}\n\nint main(void)\n{\n\tstruct foo x;\n\n\tx.a = 53;\n\tgcc_crash(&x);\n\n\texit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020423-1.c",
    "content": "/* PR c/5430 */\n/* Verify that the multiplicative folding code is not fooled\n   by the mix between signed variables and unsigned constants. */\n\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  int my_int = 924;\n  unsigned int result;\n\n  result = ((my_int*2 + 4) - 8U) / 2;\n  if (result != 922U)\n    abort();\n         \n  result = ((my_int*2 - 4U) + 2) / 2;\n  if (result != 923U)\n    abort();\n\n  result = (((my_int + 2) * 2) - 8U - 4) / 2;\n  if (result != 920U)\n    abort();\n  result = (((my_int + 2) * 2) - (8U + 4)) / 2;\n  if (result != 920U)\n    abort();\n\n  result = ((my_int*4 + 2U) - 4U) / 2;\n  if (result != 1847U)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020503-1.c",
    "content": "/* PR 6534 */\n/* GCSE unified the two i<0 tests, but if-conversion to ui=abs(i) \n   insertted the code at the wrong place corrupting the i<0 test.  */\n\nvoid abort (void);\nstatic char *\ninttostr (long i, char buf[128])\n{\n  unsigned long ui = i;\n  char *p = buf + 127;\n  *p = '\\0';\n  if (i < 0)\n    ui = -ui;\n  do\n    *--p = '0' + ui % 10;\n  while ((ui /= 10) != 0);\n  if (i < 0)\n    *--p = '-';\n  return p;\n}\n\nint\nmain ()\n{\n  char buf[128], *p;\n\n  p = inttostr (-1, buf);\n  if (*p != '-')\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020506-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test that (A & C1) op C2 optimizations behave correctly where C1 is\n   a constant power of 2, op is == or !=, and C2 is C1 or zero.\n\n   Written by Roger Sayle, 5th May 2002.  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid test1 (signed char c, int set);\nvoid test2 (unsigned char c, int set);\nvoid test3 (short s, int set);\nvoid test4 (unsigned short s, int set);\nvoid test5 (int i, int set);\nvoid test6 (unsigned int i, int set);\nvoid test7 (long long l, int set);\nvoid test8 (unsigned long long l, int set);\n\n#ifndef LONG_LONG_MAX\n#define LONG_LONG_MAX __LONG_LONG_MAX__\n#endif\n#ifndef LONG_LONG_MIN\n#define LONG_LONG_MIN (-LONG_LONG_MAX-1)\n#endif\n#ifndef ULONG_LONG_MAX\n#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)\n#endif\n\n\nvoid\ntest1 (signed char c, int set)\n{\n  if ((c & (SCHAR_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) == (SCHAR_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != (SCHAR_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest2 (unsigned char c, int set)\n{\n  if ((c & (SCHAR_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) == (SCHAR_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((c & (SCHAR_MAX+1)) != (SCHAR_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest3 (short s, int set)\n{\n  if ((s & (SHRT_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) == (SHRT_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != (SHRT_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest4 (unsigned short s, int set)\n{\n  if ((s & (SHRT_MAX+1)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) == (SHRT_MAX+1))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((s & (SHRT_MAX+1)) != (SHRT_MAX+1))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest5 (int i, int set)\n{\n  if ((i & (INT_MAX+1U)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((i & (INT_MAX+1U)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) == (INT_MAX+1U))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) != (INT_MAX+1U))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest6 (unsigned int i, int set)\n{\n  if ((i & (INT_MAX+1U)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((i & (INT_MAX+1U)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) == (INT_MAX+1U))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((i & (INT_MAX+1U)) != (INT_MAX+1U))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest7 (long long l, int set)\n{\n  if ((l & (LONG_LONG_MAX+1ULL)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) == (LONG_LONG_MAX+1ULL))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != (LONG_LONG_MAX+1ULL))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nvoid\ntest8 (unsigned long long l, int set)\n{\n  if ((l & (LONG_LONG_MAX+1ULL)) == 0)\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != 0)\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) == (LONG_LONG_MAX+1ULL))\n    {\n      if (!set) abort ();\n    }\n  else\n    if (set) abort ();\n\n  if ((l & (LONG_LONG_MAX+1ULL)) != (LONG_LONG_MAX+1ULL))\n    {\n      if (set) abort ();\n    }\n  else\n    if (!set) abort ();\n}\n\nint\nmain ()\n{\n  test1 (0, 0);\n  test1 (SCHAR_MAX, 0);\n  test1 (SCHAR_MIN, 1);\n  test1 (UCHAR_MAX, 1);\n\n  test2 (0, 0);\n  test2 (SCHAR_MAX, 0);\n  test2 (SCHAR_MIN, 1);\n  test2 (UCHAR_MAX, 1);\n\n  test3 (0, 0);\n  test3 (SHRT_MAX, 0);\n  test3 (SHRT_MIN, 1);\n  test3 (USHRT_MAX, 1);\n\n  test4 (0, 0);\n  test4 (SHRT_MAX, 0);\n  test4 (SHRT_MIN, 1);\n  test4 (USHRT_MAX, 1);\n\n  test5 (0, 0);\n  test5 (INT_MAX, 0);\n  test5 (INT_MIN, 1);\n  test5 (UINT_MAX, 1);\n\n  test6 (0, 0);\n  test6 (INT_MAX, 0);\n  test6 (INT_MIN, 1);\n  test6 (UINT_MAX, 1);\n\n  test7 (0, 0);\n  test7 (LONG_LONG_MAX, 0);\n  test7 (LONG_LONG_MIN, 1);\n  test7 (ULONG_LONG_MAX, 1);\n\n  test8 (0, 0);\n  test8 (LONG_LONG_MAX, 0);\n  test8 (LONG_LONG_MIN, 1);\n  test8 (ULONG_LONG_MAX, 1);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020508-1.c",
    "content": "/* This tests the rotate patterns that some machines support.  */\n\n#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((unsigned char)0xf234U)\n#define SHORT_VALUE ((unsigned short)0xf234U)\n#define INT_VALUE 0xf234U\n#define LONG_VALUE 0xf2345678LU\n#define LL_VALUE 0xf2345678abcdef0LLU\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nunsigned char uc = CHAR_VALUE;\nunsigned short us = SHORT_VALUE;\nunsigned int ui = INT_VALUE;\nunsigned long ul = LONG_VALUE;\nunsigned long long ull = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020508-2.c",
    "content": "#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0x1234)\n#define SHORT_VALUE ((short)0x1234)\n#define INT_VALUE ((int)0x1234)\n#define LONG_VALUE ((long)0x12345678L)\n#define LL_VALUE ((long long)0x12345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020508-3.c",
    "content": "#include <limits.h>\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0xf234)\n#define SHORT_VALUE ((short)0xf234)\n#define INT_VALUE ((int)0xf234)\n#define LONG_VALUE ((long)0xf2345678L)\n#define LL_VALUE ((long long)0xf2345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020510-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test that optimizing ((c>=1) && (c<=127)) into (signed char)c < 0\n   doesn't cause any problems for the compiler and behaves correctly.\n\n   Written by Roger Sayle, 8th May 2002.  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid\ntestc (unsigned char c, int ok)\n{\n  if ((c>=1) && (c<=SCHAR_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntests (unsigned short s, int ok)\n{\n  if ((s>=1) && (s<=SHRT_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntesti (unsigned int i, int ok)\n{\n  if ((i>=1) && (i<=INT_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nvoid\ntestl (unsigned long l, int ok)\n{\n  if ((l>=1) && (l<=LONG_MAX))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint\nmain ()\n{\n  testc (0, 0);\n  testc (1, 1);\n  testc (SCHAR_MAX, 1);\n  testc (SCHAR_MAX+1, 0);\n  testc (UCHAR_MAX, 0);\n\n  tests (0, 0);\n  tests (1, 1);\n  tests (SHRT_MAX, 1);\n  tests (SHRT_MAX+1, 0);\n  tests (USHRT_MAX, 0);\n\n  testi (0, 0);\n  testi (1, 1);\n  testi (INT_MAX, 1);\n  testi (INT_MAX+1U, 0);\n  testi (UINT_MAX, 0);\n\n  testl (0, 0);\n  testl (1, 1);\n  testl (LONG_MAX, 1);\n  testl (LONG_MAX+1UL, 0);\n  testl (ULONG_MAX, 0);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020529-1.c",
    "content": "/* PR target/6838 from cato@df.lth.se.\n   cris-elf got an ICE with -O2: the insn matching\n      (insn 49 48 52 (parallel[ \n\t\t  (set (mem/s:HI (plus:SI (reg/v/f:SI 0 r0 [24])\n\t\t\t      (const_int 8 [0x8])) [5 <variable>.c+0 S2 A8])\n\t\t      (reg:HI 2 r2 [27]))\n\t\t  (set (reg/f:SI 2 r2 [31])\n\t\t      (plus:SI (reg/v/f:SI 0 r0 [24])\n\t\t\t  (const_int 8 [0x8])))\n\t      ] ) 24 {*mov_sidehi_mem} (nil)\n\t  (nil))\n   forced a splitter through the output pattern \"#\", but there was no\n   matching splitter.  */\n\n/* The ptx assembler appears to clobber 'b' inside foo during the f1 call.\n   Reported to nvidia 2016-05-18.  */\n/* { dg-skip-if \"PTX assembler bug\" { nvptx-*-* } { \"-O0\" } { \"\" } } */\n\nstruct xx\n {\n   int a;\n   struct xx *b;\n   short c;\n };\n\nint f1 (struct xx *);\nvoid f2 (void);\n\nint\nfoo (struct xx *p, int b, int c, int d)\n{\n  int a;\n\n  for (;;)\n    {\n      a = f1(p);\n      if (a)\n\treturn (0);\n      if (b)\n\tcontinue;\n      p->c = d;\n      if (p->a)\n\tf2 ();\n      if (c)\n\tf2 ();\n      d = p->c;\n      switch (a)\n\t{\n\tcase 1:\n\t  if (p->b)\n\t    f2 ();\n\t  if (c)\n\t    f2 ();\n\tdefault:\n\t  break;\n\t}\n    }\n  return d;\n}\n\nint main (void)\n{\n  struct xx s = {0, &s, 23};\n  if (foo (&s, 0, 0, 0) != 0 || s.a != 0 || s.b != &s || s.c != 0)\n    abort ();\n  exit (0);\n}\n\nint\nf1 (struct xx *p)\n{\n  static int beenhere = 0;\n  if (beenhere++ > 1)\n    abort ();\n  return beenhere > 1;\n}\n\nvoid\nf2 (void)\n{\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020611-1.c",
    "content": "/* PR target/6997.  Missing (set_attr \"cc\" \"none\") in sleu pattern in\n   cris.md.  Testcase from hp@axis.com.  */\n\nint p;\nint k;\nunsigned int n;\n\nvoid x ()\n{\n  unsigned int h;\n\n  h = n <= 30;\n  if (h)\n    p = 1;\n  else\n    p = 0;\n\n  if (h)\n    k = 1;\n  else\n    k = 0;\n}\n\nunsigned int n = 30;\n\nmain ()\n{\n  x ();\n  if (p != 1 || k != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020614-1.c",
    "content": "/* PR c/6677 */\n/* Verify that GCC doesn't perform illegal simplifications\n   when folding constants.  */\n\n#include <limits.h>\n\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  int i;\n  signed char j;\n  unsigned char k;\n\n  i = SCHAR_MAX;\n\n  j = ((signed char) (i << 1)) / 2;\n\n  if (j != -1)\n    abort();\n\n  j = ((signed char) (i * 2)) / 2;\n\n  if (j != -1)\n    abort();\n\n  i = UCHAR_MAX;\n\n  k = ((unsigned char) (i << 1)) / 2;\n\n  if (k != UCHAR_MAX/2)\n    abort();\n\n  k = ((unsigned char) (i * 2)) / 2;\n\n  if (k != UCHAR_MAX/2)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020615-1.c",
    "content": "/* PR target/7042.  When reorg.c changed branches into return insns, it\n   completely forgot about any current_function_epilogue_delay_list and\n   dropped those insns.  Uncovered on cris-axis-elf, where an insn in an\n   epilogue delay-slot set the return-value register with the testcase\n   below.  Derived from ghostscript-6.52 (GPL) by hp@axis.com.  */\n\ntypedef struct font_hints_s {\n  int axes_swapped;\n  int x_inverted, y_inverted;\n} font_hints;\ntypedef struct gs_fixed_point_s {\n  long x, y;\n} gs_fixed_point;\n\nint\nline_hints(const font_hints *fh, const gs_fixed_point *p0,\n\t   const gs_fixed_point *p1)\n{\n  long dx = p1->x - p0->x;\n  long dy = p1->y - p0->y;\n  long adx, ady;\n  int xi = fh->x_inverted, yi = fh->y_inverted;\n  int hints;\n  if (xi)\n    dx = -dx;\n  if (yi)\n    dy = -dy;\n  if (fh->axes_swapped) {\n    long t = dx;\n    int ti = xi;\n    dx = dy, xi = yi;\n    dy = t, yi = ti;\n  }\n  adx = dx < 0 ? -dx : dx;\n  ady = dy < 0 ? -dy : dy;\n  if (dy != 0 && (adx <= ady >> 4)) {\n    hints = dy > 0 ? 2 : 1;\n    if (xi)\n      hints ^= 3;\n  } else if (dx != 0 && (ady <= adx >> 4)) {\n    hints = dx < 0 ? 8 : 4;\n    if (yi)\n      hints ^= 12;\n  } else\n    hints = 0;\n  return hints;\n}\nint main ()\n{\n  static font_hints fh[] = {{0, 1, 0}, {0, 0, 1}, {0, 0, 0}};\n  static gs_fixed_point gsf[]\n    = {{0x30000, 0x13958}, {0x30000, 0x18189},\n       {0x13958, 0x30000}, {0x18189, 0x30000}};\n  if (line_hints (fh, gsf, gsf + 1) != 1\n      || line_hints (fh + 1, gsf + 2, gsf + 3) != 8\n      || line_hints (fh + 2, gsf + 2, gsf + 3) != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020619-1.c",
    "content": "#if (__SIZEOF_INT__ == 4)\ntypedef int int32;\n#elif (__SIZEOF_LONG__ == 4)\ntypedef long int32;\n#else\n#error Add target support for int32\n#endif\nstatic int32 ref(void)\n{\n  union {\n    char c[5];\n    int32 i;\n  } u;\n\n  __builtin_memset (&u, 0, sizeof(u));\n  u.c[0] = 1;\n  u.c[1] = 2;\n  u.c[2] = 3;\n  u.c[3] = 4;\n\n  return u.i;\n}\n\nint main()\n{\n  int32 b = ref();\n  if (b != 0x01020304\n      && b != 0x04030201)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020716-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint sub1 (int val)\n{\n  return val;\n}\n\nint testcond (int val)\n{\n  int flag1;\n\n    {\n      int t1 = val;\n        {\n          int t2 = t1;\n            {\n              flag1 = sub1 (t2) ==0;\n              goto lab1;\n            };\n        }\n      lab1: ;\n    }\n\n  if (flag1 != 0)\n    return 0x4d0000;\n  else\n    return 0;\n}\n\nint main (void)\n{\n  if (testcond (1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020720-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Ensure that fabs(x) < 0.0 optimization is working.\n\n   Written by Roger Sayle, 20th July 2002.  */\n\nextern void abort (void);\nextern double fabs (double);\nextern void link_error (void);\n\nvoid\nfoo (double x)\n{\n  double p, q;\n\n  p = fabs (x);\n  q = 0.0;\n  if (p < q)\n    link_error ();\n}\n\nint\nmain()\n{\n  foo (1.0);\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_error ()\n{\n  abort ();\n}\n#endif\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020805-1.c",
    "content": "/* This testcase was miscompiled on IA-32, because fold-const\n   assumed associate_trees is always done on PLUS_EXPR.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid check (unsigned int m)\n{\n  if (m != (unsigned int) -1)\n    abort ();\n}\n\nunsigned int n = 1;\n\nint main (void)\n{\n  unsigned int m;\n  m = (1 | (2 - n)) | (-n);\n  check (m);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020810-1.c",
    "content": "/* PR target/7559\n   This testcase was miscompiled on x86-64, because classify_argument\n   wrongly computed the offset of nested structure fields.  */\n\nextern void abort (void);\n\nstruct A\n{\n  long x;\n};\n\nstruct R\n{\n  struct A a, b;\n};\n\nstruct R R = { 100, 200 };\n\nvoid f (struct R r)\n{\n  if (r.a.x != R.a.x || r.b.x != R.b.x)\n    abort ();\n}\n\nstruct R g (void)\n{\n  return R;\n}\n\nint main (void)\n{\n  struct R r;\n  f(R);\n  r = g();\n  if (r.a.x != R.a.x || r.b.x != R.b.x)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020819-1.c",
    "content": "foo ()\n{\n  return 0;\n}\n\nmain()\n{\n  int i, j, k, ccp_bad = 0;\n\n  for (i = 0; i < 10; i++)\n    {\n      for (j = 0; j < 10; j++)\n\tif (foo ())\n\t  ccp_bad = 1;\n    \n      k = ccp_bad != 0;\n      if (k)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020904-1.c",
    "content": "/* PR c/7102 */\n\n/* Verify that GCC zero-extends integer constants\n   in unsigned binary operations. */\n\ntypedef unsigned char u8;\n\nu8 fun(u8 y)\n{\n  u8 x=((u8)255)/y;\n  return x;\n}\n\nint main(void)\n{\n  if (fun((u8)2) != 127)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020911-1.c",
    "content": "extern void abort (void);\nunsigned short c = 0x8000;\nint main()\n{\n  if ((c-0x8000) < 0 || (c-0x8000) > 0x7fff)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020916-1.c",
    "content": "/* Distilled from try_pre_increment in flow.c.  If-conversion inserted\n   new instructions at the wrong place on ppc.  */\n\nint foo(int a)\n{\n  int x;\n  x = 0;\n  if (a > 0) x = 1;\n  if (a < 0) x = 1;\n  return x;\n}\n\nint main()\n{\n  if (foo(1) != 1)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20020920-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nstruct B\n{\n  int x;\n  int y;\n};\n\nstruct A\n{\n  int z;\n  struct B b;\n};\n\nstruct A\nf ()\n{\n  struct B b = { 0, 1 };\n  struct A a = { 2, b };\n  return a;\n}\n\nint\nmain (void)\n{\n  struct A a = f ();\n  if (a.z != 2 || a.b.x != 0 || a.b.y != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021010-1.c",
    "content": "#include <limits.h>\n\nint\nsub ()\n{\n  int dummy = 0, a = 16;\n\n  if (a / INT_MAX / 16 == 0)\n    return 0;\n  else\n    return a / INT_MAX / 16;\n}\n\nint\nmain ()\n{\n  if (sub () != 0)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021010-2.c",
    "content": "/* cse.c failure on x86 target.\n   Contributed by Stuart Hastings 10 Oct 2002 <stuart@apple.com> */\n#include <stdlib.h>\n\ntypedef signed short SInt16;\n\ntypedef struct {\n    SInt16 minx;\n    SInt16 maxx;\n    SInt16 miny;\n    SInt16 maxy;\n} IOGBounds;\n\nint expectedwidth = 50;\n\nunsigned int *global_vramPtr = (unsigned int *)0xa000;\n\nIOGBounds global_bounds = { 100, 150, 100, 150 };\nIOGBounds global_saveRect = { 75, 175, 75, 175 };\n\nmain()\n{\n  unsigned int *vramPtr;\n  int width;\n  IOGBounds saveRect = global_saveRect;\n  IOGBounds bounds = global_bounds;\n\n  if (saveRect.minx < bounds.minx) saveRect.minx = bounds.minx;\n  if (saveRect.maxx > bounds.maxx) saveRect.maxx = bounds.maxx;\n\n  vramPtr = global_vramPtr + (saveRect.miny - bounds.miny) ;\n  width = saveRect.maxx - saveRect.minx;\n\n  if (width != expectedwidth)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021011-1.c",
    "content": "/* PR opt/8165.  */\n\nextern void abort (void);\n\nchar buf[64];\n\nint\nmain (void)\n{\n  int i;\n\n  __builtin_strcpy (buf, \"mystring\");\n  if (__builtin_strcmp (buf, \"mystring\") != 0)\n    abort ();\n\n  for (i = 0; i < 16; ++i)\n    {\n      __builtin_strcpy (buf + i, \"mystring\");\n      if (__builtin_strcmp (buf + i, \"mystring\") != 0)\n\tabort ();\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021015-1.c",
    "content": "/* PR opt/7409.  */\n\nextern void abort (void);\n\nchar g_list[] = { '1' };\n\nvoid g (void *p, char *list, int length, char **elementPtr, char **nextPtr)\n{\n  if (*nextPtr != g_list)\n    abort ();\n\n  **nextPtr = 0;\n}\n\nint main (void)\n{\n  char *list = g_list;\n  char *element;\n  int i, length = 100;\n\n  for (i = 0; *list != 0; i++) \n    {\n      char *prevList = list;\n      g (0, list, length, &element, &list);\n      length -= (list - prevList);\n    }\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021024-1.c",
    "content": "/* Origin: PR target/6981 from Mattias Engdegaard <mattias@virtutech.se>.  */\n/* { dg-require-effective-target int32plus } */\n\nvoid exit (int);\nvoid abort (void);\n\nunsigned long long *cp, m;\n\nvoid foo (void)\n{\n}\n\nvoid bar (unsigned rop, unsigned long long *r)\n{\n  unsigned rs1, rs2, rd;\n\ntop:\n  rs2 = (rop >> 23) & 0x1ff;\n  rs1 = (rop >> 9) & 0x1ff;\n  rd = rop & 0x1ff;\n\n  *cp = 1;\n  m = r[rs1] + r[rs2];\n  *cp = 2;\n  foo();\n  if (!rd)\n    goto top;\n  r[rd] = 1;\n}\n\nint main(void)\n{\n  static unsigned long long r[64];\n  unsigned long long cr;\n  cp = &cr;\n\n  r[4] = 47;\n  r[8] = 11;\n  bar((8 << 23) | (4 << 9) | 15, r);\n\n  if (m != 47 + 11)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021111-1.c",
    "content": "/* Origin: PR c/8467 */\n\nextern void abort (void);\nextern void exit (int);\n\nint aim_callhandler(int sess, int conn, unsigned short family, unsigned short type);\n\nint aim_callhandler(int sess, int conn, unsigned short family, unsigned short type)\n{\n  static int i = 0;\n\n  if (!conn)\n    return 0;\n\n  if (type == 0xffff)\n    {\n      return 0;\n    }\n\n  if (i >= 1)\n    abort ();\n\n  i++;\n  return aim_callhandler(sess, conn, family, (unsigned short) 0xffff);\n}\n\nint main (void)\n{\n  aim_callhandler (0, 1, 0, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021113-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n\n/* This program tests a data flow bug that would cause constant propagation\n   to propagate constants through function calls.  */\n\nfoo (int *p)\n{\n  *p = 10;\n}\n\nmain()\n{\n  int *ptr = alloca (sizeof (int));\n  *ptr = 5;\n  foo (ptr);\n  if (*ptr == 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021118-1.c",
    "content": "struct s { int f[4]; };\n\nint foo (struct s s, int x1, int x2, int x3, int x4, int x5, int x6, int x7)\n{\n  return s.f[3] + x7;\n}\n\nint main ()\n{\n  struct s s = { 1, 2, 3, 4 };\n\n  if (foo (s, 100, 200, 300, 400, 500, 600, 700) != 704)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021118-2.c",
    "content": "/* Originally added to test SH constant pool layout.  t1() failed for\n   non-PIC and t2() failed for PIC.  */\n\nint t1 (float *f, int i,\n\tvoid (*f1) (double),\n\tvoid (*f2) (float, float))\n{\n  f1 (3.0);\n  f[i] = f[i + 1];\n  f2 (2.5f, 3.5f);\n}\n\nint t2 (float *f, int i,\n\tvoid (*f1) (double),\n\tvoid (*f2) (float, float),\n\tvoid (*f3) (float))\n{\n  f3 (6.0f);\n  f1 (3.0);\n  f[i] = f[i + 1];\n  f2 (2.5f, 3.5f);\n}\n\nvoid f1 (double d)\n{\n  if (d != 3.0)\n    abort ();\n}\n\nvoid f2 (float f1, float f2)\n{\n  if (f1 != 2.5f || f2 != 3.5f)\n    abort ();\n}\n\nvoid f3 (float f)\n{\n  if (f != 6.0f)\n    abort ();\n}\n\nint main ()\n{\n  float f[3] = { 2.0f, 3.0f, 4.0f };\n  t1 (f, 0, f1, f2);\n  t2 (f, 1, f1, f2, f3);\n  if (f[0] != 3.0f && f[1] != 4.0f)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021118-3.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint\nfoo (int x)\n{\n  if (x == -2 || -x - 100 >= 0)\n    abort ();\n  return 0;\n}\n           \nint\nmain ()\n{\n  foo (-3);\n  foo (-99);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021119-1.c",
    "content": "/* PR 8639.  */\n\nextern void abort(void);\n\nint foo (int i)\n{\n  int r;\n  r = (80 - 4 * i) / 20;\n  return r;\n}\n    \nint main ()\n{\n  if (foo (1) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021120-1.c",
    "content": "/* Macros to emit \"L Nxx R\" for each octal number xx between 000 and 037.  */\n#define OP1(L, N, R, I, J) L N##I##J R\n#define OP2(L, N, R, I) \\\n    OP1(L, N, R, 0, I), OP1(L, N, R, 1, I), \\\n    OP1(L, N, R, 2, I), OP1(L, N, R, 3, I)\n#define OP(L, N, R) \\\n    OP2(L, N, R, 0), OP2(L, N, R, 1), OP2(L, N, R, 2), OP2(L, N, R, 3), \\\n    OP2(L, N, R, 4), OP2(L, N, R, 5), OP2(L, N, R, 6), OP2(L, N, R, 7)\n\n/* Declare 32 unique variables with prefix N.  */\n#define DECLARE(N) OP (, N,)\n\n/* Copy 32 variables with prefix N from the array at ADDR.\n   Leave ADDR pointing to the end of the array.  */\n#define COPYIN(N, ADDR) OP (, N, = *(ADDR++))\n\n/* Likewise, but copy the other way.  */\n#define COPYOUT(N, ADDR) OP (*(ADDR++) =, N,)\n\n/* Add the contents of the array at ADDR to 32 variables with prefix N.\n   Leave ADDR pointing to the end of the array.  */\n#define ADD(N, ADDR) OP (, N, += *(ADDR++))\n\nvolatile double gd[32];\nvolatile float gf[32];\n\nvoid foo (int n)\n{\n  double DECLARE(d);\n  float DECLARE(f);\n  volatile double *pd;\n  volatile float *pf;\n  int i;\n\n  pd = gd; COPYIN (d, pd);\n  for (i = 0; i < n; i++)\n    {\n      pf = gf; COPYIN (f, pf);\n      pd = gd; ADD (d, pd);\n      pd = gd; ADD (d, pd);\n      pd = gd; ADD (d, pd);\n      pf = gf; COPYOUT (f, pf);\n    }\n  pd = gd; COPYOUT (d, pd);\n}\n\nint main ()\n{\n  int i;\n\n  for (i = 0; i < 32; i++)\n    gd[i] = i, gf[i] = i;\n  foo (1);\n  for (i = 0; i < 32; i++)\n    if (gd[i] != i * 4 || gf[i] != i)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021120-2.c",
    "content": "int g1, g2;\n\nvoid foo (int x)\n{\n  int y;\n\n  if (x)\n    y = 793;\n  else\n    y = 793;\n  g1 = 7930 / y;\n  g2 = 7930 / x;\n}\n\nint main ()\n{\n  foo (793);\n  if (g1 != 10 || g2 != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021120-3.c",
    "content": "/* Test whether a partly call-clobbered register will be moved over a call.\n   Although the original test case didn't use any GNUisms, it proved\n   difficult to reduce without the named register extension.  */\n#if __SH64__ == 32\n#define LOC asm (\"r10\")\n#else\n#define LOC\n#endif\n\nunsigned int foo (char *c, unsigned int x, unsigned int y)\n{\n  register unsigned int z LOC;\n\n  sprintf (c, \"%d\", x / y);\n  z = x + 1;\n  return z / (y + 1);\n}\n\nint main ()\n{\n  char c[16];\n\n  if (foo (c, ~1U, 4) != (~0U / 5))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021127-1.c",
    "content": "/* { dg-options \"-std=c99\" } */\n\nlong long a = -1;\nlong long llabs (long long);\nvoid abort (void);\nint\nmain()\n{\n  if (llabs (a) != 1)\n    abort ();\n  return 0;\n}\nlong long llabs (long long b)\n{\n\tabort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021204-1.c",
    "content": "/* This test was miscompiled when using sibling call optimization,\n   because X ? Y : Y - 1 optimization changed X into !X in place\n   and haven't reverted it if do_store_flag was successful, so\n   when expanding the expression the second time it was\n   !X ? Y : Y - 1.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid foo (int x)\n{\n  if (x != 1)\n    abort ();\n}\n\nint z;\n\nint main (int argc, char **argv)\n{\n  char *a = \"test\";\n  char *b = a + 2;\n\n  foo (z > 0 ? b - a : b - a - 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20021219-1.c",
    "content": "/* PR optimization/8988 */\n/* Contributed by Kevin Easton */\n\nvoid foo(char *p1, char **p2)\n{}\n \nint main(void)\n{\n  char str[] = \"foo { xx }\";\n  char *ptr = str + 5;\n\n  foo(ptr, &ptr);\n\n  while (*ptr && (*ptr == 13 || *ptr == 32))\n    ptr++;\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030105-1.c",
    "content": "int __attribute__ ((noinline))\nfoo ()\n{\n  const int a[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };\n  int i, sum;\n\n  sum = 0;\n  for (i = 0; i < sizeof (a) / sizeof (*a); i++)\n    sum += a[i];\n\n  return sum;\n}\n\nint\nmain ()\n{\n  if (foo () != 28)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030109-1.c",
    "content": "/* PR c/8032 */\n/* Verify that an empty initializer inside a partial\n   parent initializer doesn't confuse GCC.  */\n\nstruct X\n{\n  int a;\n  int b;\n  int z[];\n};\n\nstruct X x = { .b = 40, .z = {} };\n\nint main ()\n{\n  if (x.b != 40)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030117-1.c",
    "content": "int foo (int, int, int);\nint bar (int, int, int);\n\nint main (void)\n{\n  if (foo (5, 10, 21) != 12)\n    abort ();\n\n  if (bar (9, 12, 15) != 150)\n    abort ();\n\n  exit (0);\n}\n\nint foo (int x, int y, int z)\n{\n  return (x + y + z) / 3;\n}\n\nint bar (int x, int y, int z)\n{\n  return foo (x * x, y * y, z * z);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030120-1.c",
    "content": "/* On H8/300 port, NOTICE_UPDATE_CC had a bug that causes the final\n   pass to remove test insns that should be kept.  */\n\nunsigned short\ntest1 (unsigned short w)\n{\n  if ((w & 0xff00) == 0)\n    {\n      if (w == 0)\n\tw = 2;\n    }\n  return w;\n}\n\nunsigned long\ntest2 (unsigned long w)\n{\n  if ((w & 0xffff0000) == 0)\n    {\n      if (w == 0)\n\tw = 2;\n    }\n  return w;\n}\n\nint\ntest3 (unsigned short a)\n{\n  if (a & 1)\n    return 1;\n  else if (a)\n    return 1;\n  else\n    return 0;\n}\n\nint\nmain ()\n{\n  if (test1 (1) != 1)\n    abort ();\n\n  if (test2 (1) != 1)\n    abort ();\n\n  if (test3 (2) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030120-2.c",
    "content": "/* PR 8848 */\n\nextern void abort ();\n\nint foo(int status)\n{\n  int s = 0;\n  if (status == 1) s=1;\n  if (status == 3) s=3;\n  if (status == 4) s=4;\n  return s;\n}\n\nint main()\n{\n  if (foo (3) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030125-1.c",
    "content": "/* Verify whether math functions are simplified.  */\n/* { dg-require-effective-target c99_runtime } */\n/* { dg-require-weak } */\ndouble sin(double);\ndouble floor(double);\nfloat \nt(float a)\n{\n\treturn sin(a);\n}\nfloat \nq(float a)\n{\n\treturn floor(a);\n}\ndouble\nq1(float a)\n{\n\treturn floor(a);\n}\nmain()\n{\n#ifdef __OPTIMIZE__\n\tif (t(0)!=0)\n\t\tabort ();\n\tif (q(0)!=0)\n\t\tabort ();\n\tif (q1(0)!=0)\n\t\tabort ();\n#endif\n\treturn 0;\n}\n__attribute__ ((weak))\ndouble\nfloor(double a)\n{\n\tabort ();\n}\n__attribute__ ((weak))\nfloat\nfloorf(float a)\n{\n\treturn a;\n}\n__attribute__ ((weak))\ndouble\nsin(double a)\n{\n\treturn a;\n}\n__attribute__ ((weak))\nfloat\nsinf(float a)\n{\n\tabort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030128-1.c",
    "content": "unsigned char x = 50;\nvolatile short y = -5;\n\nint main ()\n{\n  x /= y;\n  if (x != (unsigned char) -10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030203-1.c",
    "content": "void f(int);\nint do_layer3(int single)\n{\n  int stereo1;\n\n  if(single >= 0) /* stream is stereo, but force to mono */\n    stereo1 = 1;\n  else\n    stereo1 = 2;\n  f(single);\n\n  return stereo1;\n}\n\nextern void abort ();\nint main()\n{\n  if (do_layer3(-1) != 2)\n    abort ();\n  return 0;\n}\n\nvoid f(int i) {}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030209-1.c",
    "content": "#ifdef STACK_SIZE\n#if STACK_SIZE < 8*100*100\n#define SKIP\n#endif\n#endif\n\n#ifndef SKIP\ndouble x[100][100];\nint main ()\n{\n  int i;\n\n  i = 99;\n  x[i][0] = 42;\n  if (x[99][0] != 42)\n    abort ();\n  exit (0);\n}\n#else\nint\nmain ()\n{\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030216-1.c",
    "content": "/* This test requires constant propagation of loads and stores to be\n   enabled.  This is only guaranteed at -O2 and higher.  Do not run\n   at -O1.  */\n/* { dg-skip-if \"requires higher optimization\" { *-*-* } \"-O1\" \"\" } */\n\nvoid link_error (void);\nconst double one=1.0;\nmain ()\n{\n#ifdef __OPTIMIZE__\n  if ((int) one != 1)\n    link_error ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030218-1.c",
    "content": "/*  On H8, the predicate general_operand_src(op,mode) used to ignore\n    mode when op is a (mem (post_inc ...)).  As a result, the pattern\n    for extendhisi2 was recognized as extendqisi2.  */\n\nextern void abort ();\nextern void exit (int);\n\nshort *q;\n\nlong\nfoo (short *p)\n{\n  long b = *p;\n  q = p + 1;\n  return b;\n}\n\nint\nmain ()\n{\n  short a = 0xff00;\n  if (foo (&a) != (long) (short) 0xff00)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030221-1.c",
    "content": "/* PR optimization/8613 */\n/* Contributed by Glen Nakamura */\n\nextern void abort (void);\n \nint main (void)\n{\n  char buf[16] = \"1234567890\";\n  char *p = buf;\n\n  *p++ = (char) __builtin_strlen (buf);\n\n  if ((buf[0] != 10) || (p - buf != 1))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030222-1.c",
    "content": "/* Verify that we get the low part of the long long as an int.  We\n   used to get it wrong on big-endian machines, if register allocation\n   succeeded at all.  We use volatile to make sure the long long is\n   actually truncated to int, in case a single register is wide enough\n   for a long long.  */\n/* { dg-skip-if \"asm would require extra shift-left-4-byte\" { spu-*-* } \"*\" \"\" } */\n/* { dg-skip-if \"asm requires register allocation\" { nvptx-*-* } \"*\" \"\" } */\n#include <limits.h>\n\nvoid\nll_to_int (long long x, volatile int *p)\n{\n  int i;\n  asm (\"\" : \"=r\" (i) : \"0\" (x));\n  *p = i;\n}\n\nint val = INT_MIN + 1;\n\nint main() {\n  volatile int i;\n\n  ll_to_int ((long long)val, &i);\n  if (i != val)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030224-2.c",
    "content": "/* Make sure that we don't free any temp stack slots associated with\n   initializing marker before we're finished with them.  */\n\nextern void abort();\n\ntypedef struct { short v16; } __attribute__((packed)) jint16_t;\n\nstruct node {\n  jint16_t magic;\n  jint16_t nodetype;\n  int totlen;\n} __attribute__((packed));\n\nstruct node node, *node_p = &node;\n\nint main()\n{\n  struct node marker = {\n    .magic = (jint16_t) {0x1985},\n    .nodetype = (jint16_t) {0x2003},\n    .totlen = node_p->totlen\n  };\n  if (marker.magic.v16 != 0x1985)\n    abort();\n  if (marker.nodetype.v16 != 0x2003)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030307-1.c",
    "content": "/* PR optimization/8726 */\n/* Originator: Paul Eggert <eggert@twinsun.com> */\n\n/* Verify that GCC doesn't miscompile tail calls on Sparc. */\n\nextern void abort(void);\n\nint fcntl_lock(int fd, int op, long long offset, long long count, int type);\n\nint vfswrap_lock(char *fsp, int fd, int op, long long offset, long long count, int type)\n{\n  return fcntl_lock(fd, op, offset, count, type);\n}\n\nint fcntl_lock(int fd, int op, long long offset, long long count, int type)\n{\n  return type;\n}\n\nint main(void)\n{\n  if (vfswrap_lock (0, 1, 2, 3, 4, 5) != 5)\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030313-1.c",
    "content": "struct A\n{\n  unsigned long p, q, r, s;\n} x = { 13, 14, 15, 16 };\n\nextern void abort (void);\nextern void exit (int);\n\nstatic inline struct A *\nbar (void)\n{\n  struct A *r;\n\n  switch (8)\n    {\n    case 2:\n      abort ();\n      break;\n    case 8:\n      r = &x;\n      break;\n    default:\n      abort ();\n      break;\n    }\n  return r;\n}\n\nvoid\nfoo (unsigned long *x, int y)\n{\n  if (y != 12)\n    abort ();\n  if (x[0] != 1 || x[1] != 11)\n    abort ();\n  if (x[2] != 2 || x[3] != 12)\n    abort ();\n  if (x[4] != 3 || x[5] != 13)\n    abort ();\n  if (x[6] != 4 || x[7] != 14)\n    abort ();\n  if (x[8] != 5 || x[9] != 15)\n    abort ();\n  if (x[10] != 6 || x[11] != 16)\n    abort ();\n}\n\nint\nmain (void)\n{\n  unsigned long a[40];\n  int b = 0;\n\n  a[b++] = 1;\n  a[b++] = 11;\n  a[b++] = 2;\n  a[b++] = 12;\n  a[b++] = 3;\n  a[b++] = bar()->p;\n  a[b++] = 4;\n  a[b++] = bar()->q;\n  a[b++] = 5;\n  a[b++] = bar()->r;\n  a[b++] = 6;\n  a[b++] = bar()->s;\n  foo (a, b);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030316-1.c",
    "content": "/* PR target/9164 */\n/* The comparison operand was sign extended erraneously.  */\n\nint\nmain (void)\n{\n    long j = 0x40000000;\n    if ((unsigned int) (0x40000000 + j) < 0L)\n \tabort ();\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030323-1.c",
    "content": "/* PR opt/10116 */\n/* { dg-require-effective-target return_address } */\n/* Removed tablejump while label still in use; this is really a link test.  */\n\nvoid *NSReturnAddress(int offset)\n{\n\tswitch (offset) {\n\tcase 0:  return __builtin_return_address(0 + 1);\n\tcase 1:  return __builtin_return_address(1 + 1);\n\tcase 2:  return __builtin_return_address(2 + 1);\n\tcase 3:  return __builtin_return_address(3 + 1);\n\tcase 4:  return __builtin_return_address(4 + 1);\n\tcase 5:  return __builtin_return_address(5 + 1);\n\tcase 6:  return __builtin_return_address(6 + 1);\n\tcase 7:  return __builtin_return_address(7 + 1);\n\tcase 8:  return __builtin_return_address(8 + 1);\n\tcase 9:  return __builtin_return_address(9 + 1);\n\tcase 10: return __builtin_return_address(10 + 1);\n\tcase 11: return __builtin_return_address(11 + 1);\n\tcase 12: return __builtin_return_address(12 + 1);\n\tcase 13: return __builtin_return_address(13 + 1);\n\tcase 14: return __builtin_return_address(14 + 1);\n\tcase 15: return __builtin_return_address(15 + 1);\n\tcase 16: return __builtin_return_address(16 + 1);\n\tcase 17: return __builtin_return_address(17 + 1);\n\tcase 18: return __builtin_return_address(18 + 1);\n\tcase 19: return __builtin_return_address(19 + 1);\n\tcase 20: return __builtin_return_address(20 + 1);\n\tcase 21: return __builtin_return_address(21 + 1);\n\tcase 22: return __builtin_return_address(22 + 1);\n\tcase 23: return __builtin_return_address(23 + 1);\n\tcase 24: return __builtin_return_address(24 + 1);\n\tcase 25: return __builtin_return_address(25 + 1);\n\tcase 26: return __builtin_return_address(26 + 1);\n\tcase 27: return __builtin_return_address(27 + 1);\n\tcase 28: return __builtin_return_address(28 + 1);\n\tcase 29: return __builtin_return_address(29 + 1);\n\tcase 30: return __builtin_return_address(30 + 1);\n\tcase 31: return __builtin_return_address(31 + 1);\n\tcase 32: return __builtin_return_address(32 + 1);\n\tcase 33: return __builtin_return_address(33 + 1);\n\tcase 34: return __builtin_return_address(34 + 1);\n\tcase 35: return __builtin_return_address(35 + 1);\n\tcase 36: return __builtin_return_address(36 + 1);\n\tcase 37: return __builtin_return_address(37 + 1);\n\tcase 38: return __builtin_return_address(38 + 1);\n\tcase 39: return __builtin_return_address(39 + 1);\n\tcase 40: return __builtin_return_address(40 + 1);\n\tcase 41: return __builtin_return_address(41 + 1);\n\tcase 42: return __builtin_return_address(42 + 1);\n\tcase 43: return __builtin_return_address(43 + 1);\n\tcase 44: return __builtin_return_address(44 + 1);\n\tcase 45: return __builtin_return_address(45 + 1);\n\tcase 46: return __builtin_return_address(46 + 1);\n\tcase 47: return __builtin_return_address(47 + 1);\n\tcase 48: return __builtin_return_address(48 + 1);\n\tcase 49: return __builtin_return_address(49 + 1);\n\tcase 50: return __builtin_return_address(50 + 1);\n\tcase 51: return __builtin_return_address(51 + 1);\n\tcase 52: return __builtin_return_address(52 + 1);\n\tcase 53: return __builtin_return_address(53 + 1);\n\tcase 54: return __builtin_return_address(54 + 1);\n\tcase 55: return __builtin_return_address(55 + 1);\n\tcase 56: return __builtin_return_address(56 + 1);\n\tcase 57: return __builtin_return_address(57 + 1);\n\tcase 58: return __builtin_return_address(58 + 1);\n\tcase 59: return __builtin_return_address(59 + 1);\n\tcase 60: return __builtin_return_address(60 + 1);\n\tcase 61: return __builtin_return_address(61 + 1);\n\tcase 62: return __builtin_return_address(62 + 1);\n\tcase 63: return __builtin_return_address(63 + 1);\n\tcase 64: return __builtin_return_address(64 + 1);\n\tcase 65: return __builtin_return_address(65 + 1);\n\tcase 66: return __builtin_return_address(66 + 1);\n\tcase 67: return __builtin_return_address(67 + 1);\n\tcase 68: return __builtin_return_address(68 + 1);\n\tcase 69: return __builtin_return_address(69 + 1);\n\tcase 70: return __builtin_return_address(70 + 1);\n\tcase 71: return __builtin_return_address(71 + 1);\n\tcase 72: return __builtin_return_address(72 + 1);\n\tcase 73: return __builtin_return_address(73 + 1);\n\tcase 74: return __builtin_return_address(74 + 1);\n\tcase 75: return __builtin_return_address(75 + 1);\n\tcase 76: return __builtin_return_address(76 + 1);\n\tcase 77: return __builtin_return_address(77 + 1);\n\tcase 78: return __builtin_return_address(78 + 1);\n\tcase 79: return __builtin_return_address(79 + 1);\n\tcase 80: return __builtin_return_address(80 + 1);\n\tcase 81: return __builtin_return_address(81 + 1);\n\tcase 82: return __builtin_return_address(82 + 1);\n\tcase 83: return __builtin_return_address(83 + 1);\n\tcase 84: return __builtin_return_address(84 + 1);\n\tcase 85: return __builtin_return_address(85 + 1);\n\tcase 86: return __builtin_return_address(86 + 1);\n\tcase 87: return __builtin_return_address(87 + 1);\n\tcase 88: return __builtin_return_address(88 + 1);\n\tcase 89: return __builtin_return_address(89 + 1);\n\tcase 90: return __builtin_return_address(90 + 1);\n\tcase 91: return __builtin_return_address(91 + 1);\n\tcase 92: return __builtin_return_address(92 + 1);\n\tcase 93: return __builtin_return_address(93 + 1);\n\tcase 94: return __builtin_return_address(94 + 1);\n\tcase 95: return __builtin_return_address(95 + 1);\n\tcase 96: return __builtin_return_address(96 + 1);\n\tcase 97: return __builtin_return_address(97 + 1);\n\tcase 98: return __builtin_return_address(98 + 1);\n\tcase 99: return __builtin_return_address(99 + 1);\n\t}\n\treturn 0;\n}\n\nint main()\n{\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030330-1.c",
    "content": "/* PR opt/10011 */\n/* This is link test for builtin_constant_p simplification + DCE.  */\n\nextern void link_error(void);\nstatic void usb_hub_port_wait_reset(unsigned int delay)\n{\n        int delay_time;\n        for (delay_time = 0; delay_time < 500; delay_time += delay) {\n                if (__builtin_constant_p(delay))\n                        link_error();\n        }\n}\n\nint main() { return 0; }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030401-1.c",
    "content": "/* Testcase for PR fortran/9974.  This was a miscompilation of the g77\n   front-end caused by the jump bypassing optimizations not handling\n   instructions inserted on CFG edges.  */\n\nextern void abort ();\n\nint bar ()\n{\n  return 1;\n}\n\nvoid foo (int x)\n{\n  unsigned char error = 0;\n\n  if (! (error = ((x == 0) || bar ())))\n    bar ();\n  if (! error)\n    abort ();\n}\n\nint main()\n{\n  foo (1);\n  return 0;\n}\n  \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030403-1.c",
    "content": "/* The non-destructive folder was always emitting >= when folding\n   comparisons to signed_max+1.  */\n\n#include <limits.h>\n\nint\nmain ()\n{\n  unsigned long count = 8;\n\n  if (count > INT_MAX)\n    abort ();\n\n  return (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030404-1.c",
    "content": "/* This exposed a bug in tree-ssa-ccp.c.  Since 'j' and 'i' are never\n   defined, CCP was not traversing the edges out of the if(), which caused\n   the PHI node for 'k' at the top of the while to only be visited once.\n   This ended up causing CCP to think that 'k' was the constant '1'.  */\nmain()\n{\n  int i, j, k;\n\n  k = 0;\n  while (k < 10)\n    {\n      k++;\n      if (j > i)\n\tj = 5;\n      else\n\tj =3;\n    }\n\n  if (k != 10)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030408-1.c",
    "content": "/* PR optimization/8634 */\n/* Contributed by Glen Nakamura <glen at imodulo dot com> */\n\nextern void abort (void);\n\nstruct foo {\n  char a, b, c, d, e, f, g, h, i, j;\n};\n\nint test1 ()\n{\n  const char X[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };\n  char buffer[8];\n  __builtin_memcpy (buffer, X, 8);\n  if (buffer[0] != 'A' || buffer[1] != 'B'\n      || buffer[2] != 'C' || buffer[3] != 'D'\n      || buffer[4] != 'E' || buffer[5] != 'F'\n      || buffer[6] != 'G' || buffer[7] != 'H')\n    abort ();\n  return 0;\n}\n\nint test2 ()\n{\n  const char X[10] = { 'A', 'B', 'C', 'D', 'E' };\n  char buffer[10];\n  __builtin_memcpy (buffer, X, 10);\n  if (buffer[0] != 'A' || buffer[1] != 'B'\n      || buffer[2] != 'C' || buffer[3] != 'D'\n      || buffer[4] != 'E' || buffer[5] != '\\0'\n      || buffer[6] != '\\0' || buffer[7] != '\\0'\n      || buffer[8] != '\\0' || buffer[9] != '\\0')\n    abort ();\n  return 0;\n}\n\nint test3 ()\n{\n  const struct foo X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };\n  char buffer[10];\n  __builtin_memcpy (buffer, &X, 10);\n  if (buffer[0] != 'A' || buffer[1] != '\\0'\n      || buffer[2] != 'C' || buffer[3] != '\\0'\n      || buffer[4] != 'E' || buffer[5] != '\\0'\n      || buffer[6] != 'G' || buffer[7] != '\\0'\n      || buffer[8] != 'I' || buffer[9] != '\\0')\n    abort ();\n  return 0;\n}\n\nint test4 ()\n{\n  const struct foo X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };\n  char buffer[10];\n  __builtin_memcpy (buffer, &X, 10);\n  if (buffer[0] != '\\0' || buffer[1] != 'B'\n      || buffer[2] != '\\0' || buffer[3] != 'D'\n      || buffer[4] != '\\0' || buffer[5] != 'F'\n      || buffer[6] != '\\0' || buffer[7] != 'H'\n      || buffer[8] != '\\0' || buffer[9] != 'J')\n    abort ();\n  return 0;\n}\n\nint main ()\n{\n  test1 (); test2 (); test3 (); test4 ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030501-1.c",
    "content": "int\nmain (int argc, char **argv)\n{\n  int size = 10;\n\n  {\n    int retframe_block()\n      {\n        return size + 5;\n      }\n\n  if (retframe_block() != 15)\n      abort ();\n  exit (0);\n\n  }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030606-1.c",
    "content": "\nint * foo (int *x, int b)\n{\n\n  *(x++) = 55;\n  if (b)\n    *(x++) = b;\n\n  return x;\n}\n\nmain()\n{\n  int a[5];\n\n  memset (a, 1, sizeof (a));\n\n  if (foo(a, 0) - a != 1 || a[0] != 55 || a[1] != a[4])\n    abort();\n\n  memset (a, 1, sizeof (a));\n\n  if (foo(a, 2) - a != 2 || a[0] != 55 || a[1] != 2)\n    abort();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030613-1.c",
    "content": "/* PR optimization/10955 */\n/* Originator: <heinrich.brand@fujitsu-siemens.com> */\n\n/* This used to fail on SPARC32 at -O3 because the loop unroller\n   wrongly thought it could eliminate a pseudo in a loop, while\n   the pseudo was used outside the loop.  */\n\nextern void abort(void);\n\n#define COMPLEX struct CS\n\nCOMPLEX {\n  long x;\n  long y;\n};\n\n\nstatic COMPLEX CCID (COMPLEX x)\n{\n  COMPLEX a;\n\n  a.x = x.x;\n  a.y = x.y;\n\n  return a;\n}\n\n\nstatic COMPLEX CPOW (COMPLEX x, int y)\n{\n  COMPLEX a;\n  a = x;\n\n  while (--y > 0)\n    a=CCID(a);\n\n  return a;\n}\n\n\nstatic int c5p (COMPLEX x)\n{\n  COMPLEX a,b;\n  a = CPOW (x, 2);\n  b = CCID( CPOW(a,2) );\n    \n  return (b.x == b.y); \n}\n\n\nint main (void)\n{\n  COMPLEX  x;  \n\n  x.x = -7;\n  x.y = -7;\n\n  if (!c5p(x))\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030626-1.c",
    "content": "char buf[10];\n\nextern void abort (void);\nextern int sprintf (char*, const char*, ...);\n\nint main()\n{\n  int l = sprintf (buf, \"foo\\0bar\");\n  if (l != 3)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030626-2.c",
    "content": "char buf[40];\n\nextern int sprintf (char*, const char*, ...);\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  int l = sprintf (buf, \"%s\", i++ ? \"string\" : \"other string\");\n  if (l != sizeof (\"other string\") - 1 || i != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030714-1.c",
    "content": "/* derived from PR optimization/11440  */\n\nextern void abort (void);\nextern void exit (int);\n\ntypedef _Bool bool;\nconst bool false = 0;\nconst bool true = 1;\n\nenum EPosition \n{\n  STATIC, RELATIVE, ABSOLUTE, FIXED\n};\ntypedef enum EPosition EPosition;\n\nenum EFloat \n{\n  FNONE = 0, FLEFT, FRIGHT\n};\ntypedef enum EFloat EFloat;\n\nstruct RenderBox\n{\n  int unused[6];\n  short m_verticalPosition;\n  \n  bool m_layouted : 1;\n  bool m_unused : 1;\n  bool m_minMaxKnown : 1;\n  bool m_floating : 1;\n  \n  bool m_positioned : 1;\n  bool m_overhangingContents : 1;\n  bool m_relPositioned : 1;\n  bool m_paintSpecial : 1;\n  \n  bool m_isAnonymous : 1;\n  bool m_recalcMinMax : 1;\n  bool m_isText : 1;\n  bool m_inline : 1;\n  \n  bool m_replaced : 1;\n  bool m_mouseInside : 1;\n  bool m_hasFirstLine : 1;\n  bool m_isSelectionBorder : 1;\n  \n  bool (*isTableCell) (struct RenderBox *this);\n};\n\ntypedef struct RenderBox RenderBox;\n\nstruct RenderStyle\n{\n  struct NonInheritedFlags \n    {\n      union \n\t{\n\t  struct \n\t    {\n\t      unsigned int _display : 4;\n\t      unsigned int _bg_repeat : 2;\n\t      bool _bg_attachment : 1;\n\t      unsigned int _overflow : 4 ;\n\t      unsigned int _vertical_align : 4;\n\t      unsigned int _clear : 2;\n\t      EPosition _position : 2;\n\t      EFloat _floating : 2;\n\t      unsigned int _table_layout : 1;\n\t      bool _flowAroundFloats :1;\n\n\t      unsigned int _styleType : 3;\n\t      bool _hasHover : 1;\n\t      bool _hasActive : 1;\n\t      bool _clipSpecified : 1;\n\t      unsigned int _unicodeBidi : 2;\n\t      int _unused : 1;\n\t    } f;\n\t  int _niflags;\n\t};\n    } noninherited_flags;\n};\n\ntypedef struct RenderStyle RenderStyle;\n\nextern void RenderObject_setStyle(RenderBox *this, RenderStyle *_style);\nextern void removeFromSpecialObjects(RenderBox *this);\n\n\n\nvoid RenderBox_setStyle(RenderBox *thisin, RenderStyle *_style)\n{\n  RenderBox *this = thisin;\n  bool oldpos, tmp;\n  EPosition tmppo;\n  \n  tmp = this->m_positioned;\n\n  oldpos = tmp;\n\n  RenderObject_setStyle(this, _style);\n  \n  tmppo = _style->noninherited_flags.f._position;\n\n  switch(tmppo)\n    {\n    case ABSOLUTE:\n    case FIXED:\n\t{\n\t  bool ltrue = true;\n\t  this->m_positioned = ltrue;\n\t  break;\n\t}\n\n    default:\n\t{\n\t  EFloat tmpf;\n\t  EPosition tmpp;\n\t  if (oldpos)\n\t    {\n\t      bool ltrue = true;\n\t      this->m_positioned = ltrue;\n\t      removeFromSpecialObjects(this);\n\t    }\n\t    {\n\t      bool lfalse = false;\n\t      this->m_positioned = lfalse;\n\t    }\n\n\t  tmpf = _style->noninherited_flags.f._floating;\n\n\t  if(!this->isTableCell (this) && !(tmpf == FNONE)) \n\t    {\n\t      bool ltrue = true;\n\t      this->m_floating = ltrue;\n\t    }\n\t  else \n\t    {\n\t      tmpp = _style->noninherited_flags.f._position;\n\t      if (tmpp == RELATIVE)\n\t\t{\n\t\t  bool ltrue = true;\n\t\t  this->m_relPositioned = ltrue;\n\t\t}\n\t    }\n\t}\n    }\n}\n\n\n\n\nRenderBox g_this;\nRenderStyle g__style;\n\nvoid RenderObject_setStyle(RenderBox *this, RenderStyle *_style)\n{\n  (void) this;\n  (void) _style;\n}\n\nvoid removeFromSpecialObjects(RenderBox *this)\n{\n  (void) this;\n}\n\nbool RenderBox_isTableCell (RenderBox *this)\n{\n  (void) this;\n  return false;\n}\n\nint main (void)\n{\n\n  g_this.m_relPositioned = false;\n  g_this.m_positioned = false;\n  g_this.m_floating = false;\n  g_this.isTableCell = RenderBox_isTableCell;\n\n  g__style.noninherited_flags.f._position = FIXED;\n  g__style.noninherited_flags.f._floating = FNONE;\n\n  RenderBox_setStyle (&g_this, &g__style);\n  \n  if (g_this.m_positioned != true)\n    abort ();\n  if (g_this.m_relPositioned != false)\n    abort ();\n  if (g_this.m_floating != false)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030715-1.c",
    "content": "/* PR optimization/11320 */\n/* Origin: Andreas Schwab <schwab@suse.de> */\n\n/* Verify that the scheduler correctly computes the dependencies\n   in the presence of conditional instructions.  */\n\nint strcmp (const char *, const char *);\nint ap_standalone;\n\nconst char *ap_check_cmd_context (void *a, int b)\n{\n  return 0;\n}\n\nconst char *server_type (void *a, void *b, char *arg)\n{\n  const char *err = ap_check_cmd_context (a, 0x01|0x02|0x04|0x08|0x10);\n  if (err)\n    return err;\n\n  if (!strcmp (arg, \"inetd\"))\n    ap_standalone = 0;\n  else if (!strcmp (arg, \"standalone\"))\n      ap_standalone = 1;\n  else\n    return \"ServerType must be either 'inetd' or 'standalone'\";\n\n  return 0;\n}\n\nint main ()\n{\n  server_type (0, 0, \"standalone\");\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030717-1.c",
    "content": "/* PR target/11087\n   This testcase was miscompiled on ppc64, because basic_induction_var called\n   convert_modes, yet did not expect it to emit any new instructions.\n   Those were emitted at the end of the function and destroyed during life\n   analysis, while the program used uninitialized pseudos created by\n   convert_modes.  */\n\nstruct A\n{\n  unsigned short a1;\n  unsigned long a2;\n};\n\nstruct B\n{\n  int b1, b2, b3, b4, b5;\n};\n\nstruct C\n{\n  struct B c1[1];\n  int c2, c3;\n};\n\nstatic\nint foo (int x)\n{\n  return  x < 0 ? -x : x;\n}\n\nint bar (struct C *x, struct A *y)\n{\n  int a = x->c3;\n  const int b = y->a1 >> 9;\n  const unsigned long c = y->a2;\n  int d = a;\n  unsigned long e, f;\n\n  f = foo (c - x->c1[d].b4);\n  do\n    {\n      if (d <= 0)\n\td = x->c2;\n      d--;\n\n      e = foo (c-x->c1[d].b4);\n      if (e < f)\n\ta = d;\n    }\n  while (d != x->c3);\n  x->c1[a].b4 = c + b;\n  return a;\n}\n\nint\nmain ()\n{\n  struct A a;\n  struct C b;\n  int c;\n\n  a.a1 = 512;\n  a.a2 = 4242;\n  __builtin_memset (&b, 0, sizeof (b));\n  b.c1[0].b3 = 424242;\n  b.c2 = 1;\n  c = bar (&b, &a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030718-1.c",
    "content": "/* PR c/10320\n   The function temp was not being emitted in a prerelease of 3.4 20030406. \n   Contributed by pinskia@physics.uc.edu */\n\nstatic inline void temp();\nint main()\n{\n        temp();\n        return 0;\n}\nstatic void temp(){}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030811-1.c",
    "content": "/* Origin: PR target/11535 from H. J. Lu <hjl@lucon.org> */\n/* { dg-require-effective-target return_address } */\n\nvoid vararg (int i, ...)\n{\n  (void) i;\n}\n\nint i0[0], i1;\n\nvoid test1 (void)\n{\n  int a = (int) (long long) __builtin_return_address (0);\n  vararg (0, a);\n}\n\nvoid test2 (void)\n{\n  i0[0] = (int) (long long) __builtin_return_address (0);\n}\n\nvoid test3 (void)\n{\n  i1 = (int) (long long) __builtin_return_address (0);\n}\n\nvoid test4 (void)\n{\n  volatile long long a = (long long) __builtin_return_address (0);\n  i0[0] = (int) a;\n}\n\nint main (void)\n{\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030821-1.c",
    "content": "extern void abort (void);\n\nint\nfoo (int x)\n{\n  if ((int) (x & 0x80ffffff) != (int) (0x8000fffe))\n    abort ();\n\n  return 0;\n}\n\nint\nmain ()\n{\n  return foo (0x8000fffe);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030828-1.c",
    "content": "const int *p;\n\nint bar (void)\n{\n  return *p + 1;\n}\n\nmain ()\n{\n  /* Variable 'i' is never used but it's aliased to a global pointer.  The\n     alias analyzer was not considering that 'i' may be used in the call to\n     bar().  */\n  const int i = 5;\n  p = &i;\n  if (bar() != 6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030828-2.c",
    "content": "struct rtx_def\n{\n  int code;\n};\n\nmain()\n{\n  int tmp[2];\n  struct rtx_def *r, s;\n  int *p, *q;\n\n  /* The alias analyzer was creating the same memory tag for r, p and q\n     because 'struct rtx_def *' is type-compatible with 'int *'.  However,\n     the alias set of 'int[2]' is not the same as 'int *', so variable\n     'tmp' was deemed not aliased with anything.  */\n  r = &s;\n  r->code = 39;\n\n  /* If 'r' wasn't declared, then q and tmp would have had the same memory\n     tag.  */\n  p = tmp;\n  q = p + 1;\n  *q = 0;\n  tmp[1] = 39;\n  if (*q != 39)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030903-1.c",
    "content": "/* Test that we don't let stmt.c think that the enumeration's values are\n   the entire set of possibilities.  Such an assumption is false for C,\n   but true for other languages.  */\n\nenum X { X1 = 1, X2, X3, X4 };\nstatic volatile enum X test = 0;\nstatic void y(int);\n\nint main()\n{\n  switch (test)\n    {\n    case X1: y(1); break;\n    case X2: y(2); break;\n    case X3: y(3); break;\n    case X4: y(4); break;\n    }\n  return 0;\n}\n\nstatic void y(int x) { abort (); }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030909-1.c",
    "content": "void abort ();\nvoid exit (int);\n\nvoid test(int x, int y)\n{\n  if (x == y)\n    abort ();\n}\n\nvoid foo(int x, int y)\n{\n  if (x == y)\n    goto a;\n  else\n    {\na:;\n      if (x == y)\n\tgoto b;\n      else\n\t{\nb:;\n\t  if (x != y)\n\t    test (x, y);\n\t}\n    }\n}\n\nint main(void)\n{\n  foo (0, 0);\n\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030910-1.c",
    "content": "/* The gimplifier was inserting unwanted temporaries for REALPART_EXPR\n   nodes.  These need to be treated like a COMPONENT_REF so their address can\n   be taken.  */\n\nint main()\n{\n  __complex double dc;\n  double *dp = &(__real dc);\n  *dp = 3.14;\n  if ((__real dc) != 3.14) abort();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030913-1.c",
    "content": "/* Assignments via pointers pointing to global variables were being killed\n   by SSA-DCE.  Test contributed by Paul Brook <paul@nowt.org>  */\n\nint glob; \n \nvoid \nfn2(int ** q) \n{ \n  *q = &glob; \n} \n \nvoid test() \n{ \n  int *p; \n \n  fn2(&p); \n \n  *p=42; \n} \n \nint main() \n{ \n  test(); \n  if (glob != 42) abort(); \n  exit (0); \n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030914-1.c",
    "content": "/* On IRIX 6, PB is passed partially in registers and partially on the\n   stack, with an odd number of words in the register part.  Check that\n   the long double stack argument (PC) is still accessed properly.  */\n\nstruct s { int val[16]; };\n\nlong double f (int pa, struct s pb, long double pc)\n{\n  int i;\n\n  for (i = 0; i < 16; i++)\n    pc += pb.val[i];\n  return pc;\n}\n\nint main ()\n{\n  struct s x;\n  int i;\n\n  for (i = 0; i < 16; i++)\n    x.val[i] = i + 1;\n  if (f (1, x, 10000.0L) != 10136.0L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030914-2.c",
    "content": "/* On IRIX 6, PA is passed partially in registers and partially on the\n   stack.  We therefore have two potential uses of pretend_args_size:\n   one for the partial argument and one for the varargs save area.\n   Make sure that these uses don't conflict.  */\n\nstruct s { int i[18]; };\n\nint f (struct s pa, int pb, ...)\n{\n  return pb;\n}\n\nstruct s gs;\n\nint main ()\n{\n  if (f (gs, 0x1234) != 0x1234)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030916-1.c",
    "content": "/* \"i\" overflows in f().  Check that x[i] is not treated as a giv.  */\n#include <limits.h>\n\n#if CHAR_BIT == 8\n\nvoid f (unsigned int *x)\n{\n  unsigned char i;\n  int j;\n\n  i = 0x10;\n  for (j = 0; j < 0x10; j++)\n    {\n      i += 0xe8;\n      x[i] = 0;\n      i -= 0xe7;\n    }\n}\n\nint main ()\n{\n  unsigned int x[256];\n  int i;\n\n  for (i = 0; i < 256; i++)\n    x[i] = 1;\n  f (x);\n  for (i = 0; i < 256; i++)\n    if (x[i] != (i >= 0x08 && i < 0xf8))\n      abort ();\n  exit (0);\n}\n#else\nint main () { exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030920-1.c",
    "content": "extern void abort (void);\n\nint main()\n{\n  int hicount = 0;\n  unsigned char *c;\n  char *str = \"\\x7f\\xff\";\n  for (c = (unsigned char *)str; *c ; c++) {\n    if (!(((unsigned int)(*c)) < 0x80)) hicount++;\n  }\n  if (hicount != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20030928-1.c",
    "content": "#include <limits.h>\n\n#if INT_MAX <= 32767\nint main () { exit (0); }\n#else\nvoid get_addrs (const char**x, int *y)\n{\n  x[0] = \"a1111\" + (y[0] - 0x10000) * 2;\n  x[1] = \"a1112\" + (y[1] - 0x20000) * 2;\n  x[2] = \"a1113\" + (y[2] - 0x30000) * 2;\n  x[3] = \"a1114\" + (y[3] - 0x40000) * 2;\n  x[4] = \"a1115\" + (y[4] - 0x50000) * 2;\n  x[5] = \"a1116\" + (y[5] - 0x60000) * 2;\n  x[6] = \"a1117\" + (y[6] - 0x70000) * 2;\n  x[7] = \"a1118\" + (y[7] - 0x80000) * 2;\n}\n\nint main ()\n{\n  const char *x[8];\n  int y[8];\n  int i;\n\n  for (i = 0; i < 8; i++)\n    y[i] = 0x10000 * (i + 1);\n  get_addrs (x, y);\n  for (i = 0; i < 8; i++)\n    if (*x[i] != 'a')\n      abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031003-1.c",
    "content": "/* PR optimization/9325  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nint f1()\n{\n  return (int)2147483648.0f;\n}\n\nint f2()\n{\n  return (int)(float)(2147483647);\n}\n\nint main()\n{\n#if INT_MAX == 2147483647\n  if (f1() != 2147483647)\n    abort ();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2() != 0x7fffff80)\n    abort ();\n#else\n  if (f2() != 2147483647)\n    abort ();\n#endif\n#endif\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031010-1.c",
    "content": "/* A reminder to process ops in generate_expr_as_of_bb exactly once.  */\n\nlong __attribute__((noinline))\nfoo (long ct, long cf, _Bool p1, _Bool p2, _Bool p3)\n{\n  long diff;\n\n  diff = ct - cf;\n\n  if (p1)\n    {\n      if (p2)\n\t{\n\t  if (p3)\n\t    {\n\t      long tmp = ct;\n\t      ct = cf;\n\t      cf = tmp;\n\t    }\n\t  diff = ct - cf;\n\t}\n\n      return diff;\n    }\n\n  abort ();\n}\n\nint main ()\n{\n  if (foo(2, 3, 1, 1, 1) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031011-1.c",
    "content": "/* Check that MAX_EXPR and MIN_EXPR are working properly.  */\n\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n\nextern void abort (void);\n\nint main()\n{\n  int ll_bitsize, ll_bitpos;\n  int rl_bitsize, rl_bitpos;\n  int end_bit;\n\n  ll_bitpos = 32;  ll_bitsize = 32;\n  rl_bitpos = 0;   rl_bitsize = 32;\n\n  end_bit = MAX (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);\n  if (end_bit != 64)\n    abort ();\n  end_bit = MAX (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);\n  if (end_bit != 64)\n    abort ();\n  end_bit = MIN (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);\n  if (end_bit != 32)\n    abort ();\n  end_bit = MIN (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);\n  if (end_bit != 32)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031012-1.c",
    "content": "/* PR optimization/8750\n   Used to fail under Cygwin with \n   -O2 -fomit-frame-pointer        \n   Testcase by David B. Trout     */\n\n#if defined(STACK_SIZE) && STACK_SIZE < 16000\n#define ARRAY_SIZE (STACK_SIZE / 2)\n#define STRLEN\t   (ARRAY_SIZE - 9)\n#else\n#define ARRAY_SIZE 15000\n#define STRLEN     13371\n#endif\n\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern void abort (void);\n\nstatic void foo ()\n{\n    char a[ARRAY_SIZE];\n\n    a[0]=0;\n    memset( &a[0], 0xCD, STRLEN );\n    a[STRLEN]=0;\n    if (strlen(a) != STRLEN)\n      abort ();\n}\n\nint main ( int argc, char* argv[] )\n{\n    foo();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031020-1.c",
    "content": "/* PR target/12654\n   The Alpha backend tried to do a >= 1024 as (a - 1024) >= 0, which fails\n   for very large negative values.  */\n/* Origin: tg@swox.com  */\n\n#include <limits.h>\n\nextern void abort (void);\n\nvoid __attribute__((noinline))\nfoo (long x)\n{\n  if (x >= 1024)\n    abort ();\n}\n\nint\nmain ()\n{\n  foo (LONG_MIN);\n  foo (LONG_MIN + 10000);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031201-1.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n   PR target/13256\n   STRICT_LOW_PART was handled incorrectly in delay slots.\n   Origin: Hans-Peter Nilsson.  */\n\ntypedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s1;\ntypedef struct { unsigned int e0 : 16; unsigned int e1 : 16; } s2;\ntypedef struct { s1 i12; s2 i16; } io;\nstatic int test_length = 2;\nstatic io *i;\nstatic int m = 1;\nstatic int d = 1;\nstatic unsigned long test_t0;\nstatic unsigned long test_t1;\nvoid test(void) __attribute__ ((__noinline__));\nextern int f1 (void *port) __attribute__ ((__noinline__));\nextern void f0 (void) __attribute__ ((__noinline__));\nint\nf1 (void *port)\n{\n  int fail_count = 0;\n  unsigned long tlen;\n  s1 x0 = {0};\n  s2 x1 = {0};\n\n  i = port;\n  x0.e0 = x1.e0 = 32;\n  i->i12 = x0;\n  i->i16 = x1;\n  do f0(); while (test_t1);\n  x0.e0 = x1.e0 = 8;\n  i->i12 = x0;\n  i->i16 = x1;\n  test ();\n  if (m)\n    {\n      unsigned long e = 1000000000 / 460800 * test_length;\n      tlen = test_t1 - test_t0;\n      if (((tlen-e) & 0x7FFFFFFF) > 1000)\n\tf0();\n    }\n  if (d)\n    {\n      unsigned long e = 1000000000 / 460800 * test_length;\n      tlen = test_t1 - test_t0;\n      if (((tlen - e) & 0x7FFFFFFF) > 1000)\n\tf0();\n    }\n  return fail_count != 0 ? 1 : 0;\n}\n\nint\nmain ()\n{\n  io io0;\n  f1 (&io0);\n  abort ();\n}\n\nvoid\ntest (void)\n{\n  io *iop = i;\n  if (iop->i12.e0 != 8 || iop->i16.e0 != 8)\n    abort ();\n  exit (0);\n}\n\nvoid\nf0 (void)\n{\n  static int washere = 0;\n  io *iop = i;\n  if (washere++ || iop->i12.e0 != 32 || iop->i16.e0 != 32)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031204-1.c",
    "content": "/* PR optimization/13260 */\n\n#include <string.h>\n\ntypedef unsigned long u32;\n\nu32 in_aton(const char* x)\n{\n  return 0x0a0b0c0d;\n}\n\nu32 root_nfs_parse_addr(char *name)\n{\n u32 addr;\n int octets = 0;\n char *cp, *cq;\n\n cp = cq = name;\n while (octets < 4) {\n  while (*cp >= '0' && *cp <= '9')\n   cp++;\n  if (cp == cq || cp - cq > 3)\n   break;\n  if (*cp == '.' || octets == 3)\n   octets++;\n  if (octets < 4)\n   cp++;\n  cq = cp;\n }\n\n if (octets == 4 && (*cp == ':' || *cp == '\\0')) {\n  if (*cp == ':')\n   *cp++ = '\\0';\n  addr = in_aton(name);\n  strcpy(name, cp);\n } else\n  addr = (-1);\n\n return addr;\n}\n\nint\nmain()\n{\n  static char addr[] = \"10.11.12.13:/hello\";\n  u32 result = root_nfs_parse_addr(addr);\n  if (result != 0x0a0b0c0d) { abort(); }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031211-1.c",
    "content": "struct a { unsigned int bitfield : 1; };\n\nunsigned int x;\n\nmain()\n{\n  struct a a = {0};\n  x = 0xbeef;\n  a.bitfield |= x;\n  if (a.bitfield != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031211-2.c",
    "content": "struct a\n{\n  unsigned int bitfield : 3;\n};\n\nint main()\n{\n  struct a a;\n\n  a.bitfield = 131;\n  foo (a.bitfield);\n  exit (0);\n}\n\nfoo(unsigned int z)\n{\n  if (z != 3)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031214-1.c",
    "content": "/* PR optimization/10312 */\n/* Originator: Peter van Hoof <p dot van-hoof at qub dot ac dot uk> */\n\n/* Verify that the strength reduction pass doesn't find\n   illegitimate givs.  */\n\nstruct\n{\n  double a;\n  int n[2];\n} g = { 0., { 1, 2}};\n\nint k = 0;\n\nvoid\nb (int *j)\n{\n}\n\nint\nmain ()\n{\n  int j;\n\n  for (j = 0; j < 2; j++)\n    k = (k > g.n[j]) ? k : g.n[j];\n\n  k++;\n  b (&j);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031215-1.c",
    "content": "/* PR middle-end/13400 */\n/* The following test used to fail at run-time with a write to read-only\n   memory, caused by if-conversion converting a conditional write into an\n   unconditional write.  */\n\ntypedef struct {int c, l; char ch[3];} pstr;\nconst pstr ao = {2, 2, \"OK\"};\nconst pstr * const a = &ao;\n\nvoid test1(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = 0;\n    }\n}\n\nvoid test2(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = -1;\n    }\n}\n\nvoid test3(void)\n{\n    if (a->ch[a->l]) {\n        ((char *)a->ch)[a->l] = 1;\n    }\n}\n\nint main(void)\n{\n    test1();\n    test2();\n    test3();\n    return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20031216-1.c",
    "content": "/* PR optimization/13313 */\n/* Origin: Mike Lerwill <mike@ml-solutions.co.uk> */\n\nextern void abort(void);\n\nvoid DisplayNumber (unsigned long v)\n{\n  if (v != 0x9aL)\n    abort();\n}\n\nunsigned long ReadNumber (void)\n{\n  return 0x009a0000L;\n}\n\nint main (void)\n{\n  unsigned long tmp;\n  tmp = (ReadNumber() & 0x00ff0000L) >> 16;\n  DisplayNumber (tmp);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040208-1.c",
    "content": "int main ()\n{\n  long double x;\n\n  x = 0x1.0p-500L;\n  x *= 0x1.0p-522L;\n  if (x != 0x1.0p-1022L)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040218-1.c",
    "content": "/* PR target/14209.  Bug in cris.md, shrinking access size of\n   postincrement.\n   Origin: <hp@axis.com>.  */\n\nlong int xb (long int *y) __attribute__ ((__noinline__));\nlong int xw (long int *y) __attribute__ ((__noinline__));\nshort int yb (short int *y) __attribute__ ((__noinline__));\n\nlong int xb (long int *y)\n{\n  long int xx = *y & 255;\n  return xx + y[1];\n}\n\nlong int xw (long int *y)\n{\n  long int xx = *y & 65535;\n  return xx + y[1];\n}\n\nshort int yb (short int *y)\n{\n  short int xx = *y & 255;\n  return xx + y[1];\n}\n\nint main (void)\n{\n  long int y[] = {-1, 16000};\n  short int yw[] = {-1, 16000};\n\n  if (xb (y) != 16255\n      || xw (y) != 81535\n      || yb (yw) != 16255)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040223-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n#include <string.h>\n#include <stdio.h>\n\nvoid\na(void *x,int y)\n{\n  if (y != 1234)\n    abort ();\n}\n\nint\nmain()\n{\n  a(strcpy(alloca(100),\"abc\"),1234);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040302-1.c",
    "content": "/* { dg-require-effective-target label_values } */\nint code[]={0,0,0,0,1};\n\nvoid foo(int x) {\n  volatile int b;\n  b = 0xffffffff;\n}\n\nvoid bar(int *pc) {\n  static const void *l[] = {&&lab0, &&end};\n\n  foo(0);\n  goto *l[*pc];\n lab0:\n  foo(0);\n  pc++;\n  goto *l[*pc];\n end:\n  return;\n}\n\nint main() {\n  bar(code);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040307-1.c",
    "content": "int main()\n{\n  int b = 0;\n\n  struct {\n    unsigned int bit0:1;\n    unsigned int bit1:1;\n    unsigned int bit2:1;\n    unsigned int bit3:1;\n    unsigned int bit4:1;\n    unsigned int bit5:1;\n    unsigned int bit6:1;\n    unsigned int bit7:1;\n  } sdata = {0x01};\n\n  while ( sdata.bit0-- > 0 ) {\n    b++ ;\n    if ( b > 100 ) break;\n  }\n\n  if (b != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040308-1.c",
    "content": "/* { dg-require-effective-target alloca } */\n/* This used to fail on SPARC with an unaligned memory access.  */\n\nvoid foo(int n)\n{\n  struct S {\n    int i[n];\n    unsigned int b:1;\n    int i2;\n  } __attribute__ ((packed)) __attribute__ ((aligned (4)));\n\n  struct S s;\n\n  s.i2 = 0;\n}\n\nint main(void)\n{\n  foo(4);\n  \n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040309-1.c",
    "content": "extern void abort ();\n\nint foo(unsigned short x)\n{\n  unsigned short y;\n  y = x > 32767 ? x - 32768 : 0;\n  return y;\n}\n\nint main()\n{\n  if (foo (0) != 0)\n    abort ();\n  if (foo (32767) != 0)\n    abort ();\n  if (foo (32768) != 0)\n    abort ();\n  if (foo (32769) != 1)\n    abort ();\n  if (foo (65535) != 32767)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040311-1.c",
    "content": "/* Copyright (C) 2004 Free Software Foundation.\n\n   Check that constant folding and RTL simplification of -(x >> y) doesn't\n   break anything and produces the expected results.\n\n   Written by Roger Sayle, 11th March 2004.  */\n\nextern void abort (void);\n\n#define INT_BITS  (sizeof(int)*8)\n\nint test1(int x)\n{\n  return -(x >> (INT_BITS-1));\n}\n\nint test2(unsigned int x)\n{\n  return -((int)(x >> (INT_BITS-1)));\n}\n\nint test3(int x)\n{\n  int y;\n  y = INT_BITS-1;\n  return -(x >> y);\n}\n\nint test4(unsigned int x)\n{\n  int y;\n  y = INT_BITS-1;\n  return -((int)(x >> y));\n}\n\nint main()\n{\n  if (test1(0) != 0)\n    abort ();\n  if (test1(1) != 0)\n    abort ();\n  if (test1(-1) != 1)\n    abort ();\n\n  if (test2(0) != 0)\n    abort ();\n  if (test2(1) != 0)\n    abort ();\n  if (test2((unsigned int)-1) != -1)\n    abort ();\n\n  if (test3(0) != 0)\n    abort ();\n  if (test3(1) != 0)\n    abort ();\n  if (test3(-1) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(1) != 0)\n    abort ();\n  if (test4((unsigned int)-1) != -1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040313-1.c",
    "content": "/* PR middle-end/14470 */\n/* Origin: Lodewijk Voge <lvoge@cs.vu.nl> */\n\nextern void abort(void);\n\nint main()\n{\n  int t[1025] = { 1024 }, d;\n\n  d = 0;\n  d = t[d]++;\n  if (t[0] != 1025)\n    abort();\n  if (d != 1024)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040319-1.c",
    "content": "int\nblah (int zzz)\n{\n  int foo;\n  if (zzz >= 0)\n    return 1;\n  foo = (zzz >= 0 ? (zzz) : -(zzz));\n  return foo;\n}\n\nmain()\n{\n  if (blah (-1) != 1)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040331-1.c",
    "content": "/* PR c++/14755 */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n#if __INT_MAX__ >= 2147483647\n  struct { int count: 31; } s = { 0 };\n  while (s.count--)\n    abort ();\n#elif __INT_MAX__ >= 32767\n  struct { int count: 15; } s = { 0 };\n  while (s.count--)\n    abort ();\n#else\n  /* Don't bother because __INT_MAX__ is too small.  */\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040409-1.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return x ^ INT_MIN;\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return x ^ (unsigned int)INT_MIN;\n}\n\nint test2(int x)\n{\n  return x + INT_MIN;\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return x + (unsigned int)INT_MIN;\n}\n\nint test3(int x)\n{\n  return x - INT_MIN;\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return x - (unsigned int)INT_MIN;\n}\n\nint test4(int x)\n{\n  int y = INT_MIN;\n  return x ^ y;\n}\n\nunsigned int test4u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x ^ y;\n}\n\nint test5(int x)\n{\n  int y = INT_MIN;\n  return x + y;\n}\n\nunsigned int test5u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x + y;\n}\n\nint test6(int x)\n{\n  int y = INT_MIN;\n  return x - y;\n}\n\nunsigned int test6u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return x - y;\n}\n\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x80000000);\n  test(0x80000000,0x00000000);\n  test(0x12345678,0x92345678);\n  test(0x92345678,0x12345678);\n  test(0x7fffffff,0xffffffff);\n  test(0xffffffff,0x7fffffff);\n\n  testu(0x00000000,0x80000000);\n  testu(0x80000000,0x00000000);\n  testu(0x12345678,0x92345678);\n  testu(0x92345678,0x12345678);\n  testu(0x7fffffff,0xffffffff);\n  testu(0xffffffff,0x7fffffff);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x8000);\n  test(0x8000,0x0000);\n  test(0x1234,0x9234);\n  test(0x9234,0x1234);\n  test(0x7fff,0xffff);\n  test(0xffff,0x7fff);\n\n  testu(0x0000,0x8000);\n  testu(0x8000,0x0000);\n  testu(0x1234,0x9234);\n  testu(0x9234,0x1234);\n  testu(0x7fff,0xffff);\n  testu(0xffff,0x7fff);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040409-2.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return (x ^ INT_MIN) ^ 0x1234;\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return (x ^ (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test2(int x)\n{\n  return (x ^ 0x1234) ^ INT_MIN;\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return (x ^ 0x1234) ^ (unsigned int)INT_MIN;\n}\n\nint test3(int x)\n{\n  return (x + INT_MIN) ^ 0x1234;\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return (x + (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test4(int x)\n{\n  return (x ^ 0x1234) + INT_MIN;\n}\n\nunsigned int test4u(unsigned int x)\n{\n  return (x ^ 0x1234) + (unsigned int)INT_MIN;\n}\n\nint test5(int x)\n{\n  return (x - INT_MIN) ^ 0x1234;\n}\n\nunsigned int test5u(unsigned int x)\n{\n  return (x - (unsigned int)INT_MIN) ^ 0x1234;\n}\n\nint test6(int x)\n{\n  return (x ^ 0x1234) - INT_MIN;\n}\n\nunsigned int test6u(unsigned int x)\n{\n  return (x ^ 0x1234) - (unsigned int)INT_MIN;\n}\n\nint test7(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x ^ y) ^ z;\n}\n\nunsigned int test7u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x ^ y) ^ z;\n}\n\nint test8(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) ^ z;\n}\n\nunsigned int test8u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) ^ z;\n}\n\nint test9(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x + y) ^ z;\n}\n\nunsigned int test9u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x + y) ^ z;\n}\n\nint test10(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) + z;\n}\n\nunsigned int test10u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) + z;\n}\n\nint test11(int x)\n{\n  int y = INT_MIN;\n  int z = 0x1234;\n  return (x - y) ^ z;\n}\n\nunsigned int test11u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  unsigned int z = 0x1234;\n  return (x - y) ^ z;\n}\n\nint test12(int x)\n{\n  int y = 0x1234;\n  int z = INT_MIN;\n  return (x ^ y) - z;\n}\n\nunsigned int test12u(unsigned int x)\n{\n  unsigned int y = 0x1234;\n  unsigned int z = (unsigned int)INT_MIN;\n  return (x ^ y) - z;\n}\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n  if (test7(a) != b)\n    abort();\n  if (test8(a) != b)\n    abort();\n  if (test9(a) != b)\n    abort();\n  if (test10(a) != b)\n    abort();\n  if (test11(a) != b)\n    abort();\n  if (test12(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n  if (test7u(a) != b)\n    abort();\n  if (test8u(a) != b)\n    abort();\n  if (test9u(a) != b)\n    abort();\n  if (test10u(a) != b)\n    abort();\n  if (test11u(a) != b)\n    abort();\n  if (test12u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x80001234);\n  test(0x00001234,0x80000000);\n  test(0x80000000,0x00001234);\n  test(0x80001234,0x00000000);\n  test(0x7fffffff,0xffffedcb);\n  test(0xffffffff,0x7fffedcb);\n\n  testu(0x00000000,0x80001234);\n  testu(0x00001234,0x80000000);\n  testu(0x80000000,0x00001234);\n  testu(0x80001234,0x00000000);\n  testu(0x7fffffff,0xffffedcb);\n  testu(0xffffffff,0x7fffedcb);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x9234);\n  test(0x1234,0x8000);\n  test(0x8000,0x1234);\n  test(0x9234,0x0000);\n  test(0x7fff,0xedcb);\n  test(0xffff,0x6dcb);\n\n  testu(0x0000,0x9234);\n  testu(0x8000,0x1234);\n  testu(0x1234,0x8000);\n  testu(0x9234,0x0000);\n  testu(0x7fff,0xedcb);\n  testu(0xffff,0x6dcb);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040409-3.c",
    "content": "#include <limits.h>\n\nextern void abort ();\n\nint test1(int x)\n{\n  return ~(x ^ INT_MIN);\n}\n\nunsigned int test1u(unsigned int x)\n{\n  return ~(x ^ (unsigned int)INT_MIN);\n}\n\nint test2(int x)\n{\n  return ~(x + INT_MIN);\n}\n\nunsigned int test2u(unsigned int x)\n{\n  return ~(x + (unsigned int)INT_MIN);\n}\n\nint test3(int x)\n{\n  return ~(x - INT_MIN);\n}\n\nunsigned int test3u(unsigned int x)\n{\n  return ~(x - (unsigned int)INT_MIN);\n}\n\nint test4(int x)\n{\n  int y = INT_MIN;\n  return ~(x ^ y);\n}\n\nunsigned int test4u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x ^ y);\n}\n\nint test5(int x)\n{\n  int y = INT_MIN;\n  return ~(x + y);\n}\n\nunsigned int test5u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x + y);\n}\n\nint test6(int x)\n{\n  int y = INT_MIN;\n  return ~(x - y);\n}\n\nunsigned int test6u(unsigned int x)\n{\n  unsigned int y = (unsigned int)INT_MIN;\n  return ~(x - y);\n}\n\n\n\nvoid test(int a, int b)\n{\n  if (test1(a) != b)\n    abort();\n  if (test2(a) != b)\n    abort();\n  if (test3(a) != b)\n    abort();\n  if (test4(a) != b)\n    abort();\n  if (test5(a) != b)\n    abort();\n  if (test6(a) != b)\n    abort();\n}\n\nvoid testu(unsigned int a, unsigned int b)\n{\n  if (test1u(a) != b)\n    abort();\n  if (test2u(a) != b)\n    abort();\n  if (test3u(a) != b)\n    abort();\n  if (test4u(a) != b)\n    abort();\n  if (test5u(a) != b)\n    abort();\n  if (test6u(a) != b)\n    abort();\n}\n\n\nint main()\n{\n#if INT_MAX == 2147483647\n  test(0x00000000,0x7fffffff);\n  test(0x80000000,0xffffffff);\n  test(0x12345678,0x6dcba987);\n  test(0x92345678,0xedcba987);\n  test(0x7fffffff,0x00000000);\n  test(0xffffffff,0x80000000);\n\n  testu(0x00000000,0x7fffffff);\n  testu(0x80000000,0xffffffff);\n  testu(0x12345678,0x6dcba987);\n  testu(0x92345678,0xedcba987);\n  testu(0x7fffffff,0x00000000);\n  testu(0xffffffff,0x80000000);\n#endif\n\n#if INT_MAX == 32767\n  test(0x0000,0x7fff);\n  test(0x8000,0xffff);\n  test(0x1234,0x6dcb);\n  test(0x9234,0xedcb);\n  test(0x7fff,0x0000);\n  test(0xffff,0x8000);\n\n  testu(0x0000,0x7fff);\n  testu(0x8000,0xffff);\n  testu(0x1234,0x6dcb);\n  testu(0x9234,0xedcb);\n  testu(0x7fff,0x0000);\n  testu(0xffff,0x8000);\n#endif\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040411-1.c",
    "content": "int\nsub1 (int i, int j)\n{\n  typedef int c[i+2];\n  int x[10], y[10];\n\n  if (j == 2)\n    {\n      memcpy (x, y, 10 * sizeof (int));\n      return sizeof (c);\n    }\n  else\n    return sizeof (c) * 3;\n}\n\nint\nmain ()\n{\n  if (sub1 (20, 3) != 66 * sizeof (int))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040423-1.c",
    "content": "int\nsub1 (int i, int j)\n{\n  typedef struct\n  {\n   int  c[i+2];\n  }c;\n  int x[10], y[10];\n\n  if (j == 2)\n    {\n      memcpy (x, y, 10 * sizeof (int));\n      return sizeof (c);\n    }\n  else\n    return sizeof (c) * 3;\n}\n\nint\nmain ()\n{\n  typedef struct\n  {\n   int  c[22];\n  }c;\n  if (sub1 (20, 3) != sizeof (c)*3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040520-1.c",
    "content": "/* PR 15454 */\n\nvoid abort ();\nint main () {\n        int foo;\n        int bar (void)\n        {\n                int baz = 0;\n                if (foo!=45)\n                        baz = foo;\n                return baz;\n        }\n        foo = 1;\n        if (!bar ())\n                abort ();\n        return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040625-1.c",
    "content": "/* From PR target/16176 */\nstruct __attribute__ ((packed)) s { struct s *next; };\n\nstruct s * __attribute__ ((noinline))\nmaybe_next (struct s *s, int t)\n{\n  if (t)\n    s = s->next;\n  return s;\n}\n\nint main ()\n{\n  struct s s1, s2;\n\n  s1.next = &s2;\n  if (maybe_next (&s1, 1) != &s2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040629-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Test arithmetics on bitfields.  */\n#ifndef T\n\nextern void abort (void);\nextern void exit (int);\n\n#ifndef FIELDS1\n#define FIELDS1\n#endif\n#ifndef FIELDS2\n#define FIELDS2\n#endif\n\nstruct { FIELDS1 unsigned int i : 6, j : 11, k : 15; FIELDS2 } b;\nstruct { FIELDS1 unsigned int i : 5, j : 1, k : 26; FIELDS2 } c;\nstruct { FIELDS1 unsigned int i : 16, j : 8, k : 8; FIELDS2 } d;\n\nunsigned int ret1 (void) { return b.i; }\nunsigned int ret2 (void) { return b.j; }\nunsigned int ret3 (void) { return b.k; }\nunsigned int ret4 (void) { return c.i; }\nunsigned int ret5 (void) { return c.j; }\nunsigned int ret6 (void) { return c.k; }\nunsigned int ret7 (void) { return d.i; }\nunsigned int ret8 (void) { return d.j; }\nunsigned int ret9 (void) { return d.k; }\n\n#define T(n, pre, post, op) \t\t\t\t\t\\\nvoid fn1_##n (unsigned int x) { pre b.i post; }\t\t\t\\\nvoid fn2_##n (unsigned int x) { pre b.j post; }\t\t\t\\\nvoid fn3_##n (unsigned int x) { pre b.k post; }\t\t\t\\\nvoid fn4_##n (unsigned int x) { pre c.i post; }\t\t\t\\\nvoid fn5_##n (unsigned int x) { pre c.j post; }\t\t\t\\\nvoid fn6_##n (unsigned int x) { pre c.k post; }\t\t\t\\\nvoid fn7_##n (unsigned int x) { pre d.i post; }\t\t\t\\\nvoid fn8_##n (unsigned int x) { pre d.j post; }\t\t\t\\\nvoid fn9_##n (unsigned int x) { pre d.k post; }\n\n#include \"20040629-1.c\"\n#undef T\n\n#define FAIL(n, i) abort ()\n\nint\nmain (void)\n{\n#define T(n, pre, post, op)\t\t\t\t\t\\\n  b.i = 51;\t\t\t\t\t\t\t\\\n  b.j = 636;\t\t\t\t\t\t\t\\\n  b.k = 31278;\t\t\t\t\t\t\t\\\n  c.i = 21;\t\t\t\t\t\t\t\\\n  c.j = 1;\t\t\t\t\t\t\t\\\n  c.k = 33554432;\t\t\t\t\t\t\\\n  d.i = 26812;\t\t\t\t\t\t\t\\\n  d.j = 156;\t\t\t\t\t\t\t\\\n  d.k = 187;\t\t\t\t\t\t\t\\\n  fn1_##n (3);\t\t\t\t\t\t\t\\\n  if (ret1 () != (op (51, 3) & ((1 << 6) - 1)))\t\t\t\\\n    FAIL (n, 1);\t\t\t\t\t\t\\\n  b.i = 51;\t\t\t\t\t\t\t\\\n  fn2_##n (251);\t\t\t\t\t\t\\\n  if (ret2 () != (op (636, 251) & ((1 << 11) - 1)))\t\t\\\n    FAIL (n, 2);\t\t\t\t\t\t\\\n  b.j = 636;\t\t\t\t\t\t\t\\\n  fn3_##n (13279);\t\t\t\t\t\t\\\n  if (ret3 () != (op (31278, 13279) & ((1 << 15) - 1)))\t\t\\\n    FAIL (n, 3);\t\t\t\t\t\t\\\n  b.j = 31278;\t\t\t\t\t\t\t\\\n  fn4_##n (24);\t\t\t\t\t\t\t\\\n  if (ret4 () != (op (21, 24) & ((1 << 5) - 1)))\t\t\\\n    FAIL (n, 4);\t\t\t\t\t\t\\\n  c.i = 21;\t\t\t\t\t\t\t\\\n  fn5_##n (1);\t\t\t\t\t\t\t\\\n  if (ret5 () != (op (1, 1) & ((1 << 1) - 1)))\t\t\t\\\n    FAIL (n, 5);\t\t\t\t\t\t\\\n  c.j = 1;\t\t\t\t\t\t\t\\\n  fn6_##n (264151);\t\t\t\t\t\t\\\n  if (ret6 () != (op (33554432, 264151) & ((1 << 26) - 1)))\t\\\n    FAIL (n, 6);\t\t\t\t\t\t\\\n  c.k = 33554432;\t\t\t\t\t\t\\\n  fn7_##n (713);\t\t\t\t\t\t\\\n  if (ret7 () != (op (26812, 713) & ((1 << 16) - 1)))\t\t\\\n    FAIL (n, 7);\t\t\t\t\t\t\\\n  d.i = 26812;\t\t\t\t\t\t\t\\\n  fn8_##n (17);\t\t\t\t\t\t\t\\\n  if (ret8 () != (op (156, 17) & ((1 << 8) - 1)))\t\t\\\n    FAIL (n, 8);\t\t\t\t\t\t\\\n  d.j = 156;\t\t\t\t\t\t\t\\\n  fn9_##n (199);\t\t\t\t\t\t\\\n  if (ret9 () != (op (187, 199) & ((1 << 8) - 1)))\t\t\\\n    FAIL (n, 9);\t\t\t\t\t\t\\\n  d.k = 187;\n\n#include \"20040629-1.c\"\n#undef T\n  return 0;\n}\n\n#else\n\n#ifndef opadd\n#define opadd(x, y) (x + y)\n#define opsub(x, y) (x - y)\n#define opinc(x, y) (x + 1)\n#define opdec(x, y) (x - 1)\n#define opand(x, y) (x & y)\n#define opior(x, y) (x | y)\n#define opxor(x, y) (x ^ y)\n#define opdiv(x, y) (x / y)\n#define oprem(x, y) (x % y)\n#define opadd3(x, y) (x + 3)\n#define opsub7(x, y) (x - 7)\n#define opand21(x, y) (x & 21)\n#define opior19(x, y) (x | 19)\n#define opxor37(x, y) (x ^ 37)\n#define opdiv17(x, y) (x / 17)\n#define oprem19(x, y) (x % 19)\n#endif\n\nT(1, , += x, opadd)\nT(2, ++, , opinc)\nT(3, , ++, opinc)\nT(4, , -= x, opsub)\nT(5, --, , opdec)\nT(6, , --, opdec)\nT(7, , &= x, opand)\nT(8, , |= x, opior)\nT(9, , ^= x, opxor)\nT(a, , /= x, opdiv)\nT(b, , %= x, oprem)\nT(c, , += 3, opadd3)\nT(d, , -= 7, opsub7)\nT(e, , &= 21, opand21)\nT(f, , |= 19, opior19)\nT(g, , ^= 37, opxor37)\nT(h, , /= 17, opdiv17)\nT(i, , %= 19, oprem19)\n\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040703-1.c",
    "content": "/* PR 16341 */\n/* { dg-require-effective-target int32plus } */\n\n#define PART_PRECISION (sizeof (cpp_num_part) * 8)\n\ntypedef unsigned int cpp_num_part;\ntypedef struct cpp_num cpp_num;\nstruct cpp_num\n{\n   cpp_num_part high;\n   cpp_num_part low;\n   int unsignedp;  /* True if value should be treated as unsigned.  */\n   int overflow;   /* True if the most recent calculation overflowed.  */\n};\n\nstatic  int\nnum_positive (cpp_num num, unsigned int precision)\n{\n   if (precision > PART_PRECISION)\n     {\n       precision -= PART_PRECISION;\n       return (num.high & (cpp_num_part) 1 << (precision - 1)) == 0;\n     }\n\n   return (num.low & (cpp_num_part) 1 << (precision - 1)) == 0;\n}\n\nstatic cpp_num\nnum_trim (cpp_num num, unsigned int precision)\n{\n   if (precision > PART_PRECISION)\n     {\n       precision -= PART_PRECISION;\n       if (precision < PART_PRECISION)\n         num.high &= ((cpp_num_part) 1 << precision) - 1;\n     }\n   else\n     {\n       if (precision < PART_PRECISION)\n         num.low &= ((cpp_num_part) 1 << precision) - 1;\n       num.high = 0;\n     }\n\n   return num;\n}\n\n/* Shift NUM, of width PRECISION, right by N bits.  */\nstatic cpp_num\nnum_rshift (cpp_num num, unsigned int precision, unsigned int n)\n{\n   cpp_num_part sign_mask;\n   int x = num_positive (num, precision);\n\n   if (num.unsignedp || x)\n     sign_mask = 0;\n   else\n     sign_mask = ~(cpp_num_part) 0;\n\n   if (n >= precision)\n     num.high = num.low = sign_mask;\n   else\n     {\n       /* Sign-extend.  */\n       if (precision < PART_PRECISION)\n         num.high = sign_mask, num.low |= sign_mask << precision;\n       else if (precision < 2 * PART_PRECISION)\n         num.high |= sign_mask << (precision - PART_PRECISION);\n\n       if (n >= PART_PRECISION)\n         {\n           n -= PART_PRECISION;\n           num.low = num.high;\n           num.high = sign_mask;\n         }\n\n       if (n)\n         {\n           num.low = (num.low >> n) | (num.high << (PART_PRECISION - n));\n           num.high = (num.high >> n) | (sign_mask << (PART_PRECISION - n));\n         }\n     }\n\n   num = num_trim (num, precision);\n   num.overflow = 0;\n   return num;\n}\n                              #define num_zerop(num) ((num.low | num.high) == 0)\n#define num_eq(num1, num2) (num1.low == num2.low && num1.high == num2.high)\n\ncpp_num\nnum_lshift (cpp_num num, unsigned int precision, unsigned int n)\n{\n   if (n >= precision)\n     {\n       num.overflow = !num.unsignedp && !num_zerop (num);\n       num.high = num.low = 0;\n     }\n   else\n     {\n       cpp_num orig;\n       unsigned int m = n;\n\n       orig = num;\n       if (m >= PART_PRECISION)\n         {\n           m -= PART_PRECISION;\n           num.high = num.low;\n           num.low = 0;\n         }\n       if (m)\n         {\n           num.high = (num.high << m) | (num.low >> (PART_PRECISION - m));\n           num.low <<= m;\n         }\n       num = num_trim (num, precision);\n\n       if (num.unsignedp)\n         num.overflow = 0;\n       else\n         {\n           cpp_num maybe_orig = num_rshift (num, precision, n);\n           num.overflow = !num_eq (orig, maybe_orig);\n         }\n     }\n\n   return num;\n}\n\nunsigned int precision = 64;\nunsigned int n = 16;\n\ncpp_num num = { 0, 3, 0, 0 };\n\nint main()\n{\n   cpp_num res = num_lshift (num, 64, n);\n\n   if (res.low != 0x30000)\n     abort ();\n\n   if (res.high != 0)\n     abort ();\n\n   if (res.overflow != 0)\n     abort ();\n\n   exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040704-1.c",
    "content": "/* PR 16348: Make sure that condition-first false loops DTRT.  */\n\nextern void abort ();\n\nint main()\n{\n  for (; 0 ;)\n    {\n      abort ();\n    label:\n      return 0;\n    }\n  goto label;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040705-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#define FIELDS1 long long l;\n#include \"20040629-1.c\"\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040705-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#define FIELDS2 long long l;\n#include \"20040629-1.c\"\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040706-1.c",
    "content": "int main ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    continue;\n  if (i < 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040707-1.c",
    "content": "struct s { char c1, c2; };\nvoid foo (struct s s)\n{\n  static struct s s1;\n  s1 = s;\n}\nint main ()\n{\n  static struct s s2;\n  foo (s2);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040709-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Test arithmetics on bitfields.  */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned int\nmyrnd (void)\n{\n  static unsigned int s = 1388815473;\n  s *= 1103515245;\n  s += 12345;\n  return (s / 65536) % 2048;\n}\n\n#define T(S)\t\t\t\t\t\\\nstruct S s##S;\t\t\t\t\t\\\nstruct S retme##S (struct S x)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return x;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn1##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y = retme##S (y);\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn2##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y.k %= 15;\t\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int retit##S (void)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return s##S.k;\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn3##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  s##S.k += x;\t\t\t\t\t\\\n  return retit##S ();\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid test##S (void)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n  unsigned int mask, v, a, r;\t\t\t\\\n  struct S x;\t\t\t\t\t\\\n  char *p = (char *) &s##S;\t\t\t\\\n  for (i = 0; i < sizeof (s##S); ++i)\t\t\\\n    *p++ = myrnd ();\t\t\t\t\\\n  if (__builtin_classify_type (s##S.l) == 8)\t\\\n    s##S.l = 5.25;\t\t\t\t\\\n  s##S.k = -1;\t\t\t\t\t\\\n  mask = s##S.k;\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn1##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn2##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((((v + a) & mask) % 15) & mask) != r)\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn3##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || s##S.k != r || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n}\n\nstruct A { unsigned int i : 6, l : 1, j : 10, k : 15; }; T(A)\nstruct B { unsigned int i : 6, j : 11, k : 15; unsigned int l; }; T(B)\nstruct C { unsigned int l; unsigned int i : 6, j : 11, k : 15; }; T(C)\nstruct D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)\nstruct E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)\nstruct F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)\nstruct G { unsigned int i : 12, j : 13, k : 7; unsigned long long l; }; T(G)\nstruct H { unsigned int i : 12, j : 11, k : 9; unsigned long long l; }; T(H)\nstruct I { unsigned short i : 1, j : 6, k : 9; unsigned long long l; }; T(I)\nstruct J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)\nstruct K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)\nstruct L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)\nstruct M { unsigned int l; unsigned int k : 6, j : 11, i : 15; }; T(M)\nstruct N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)\nstruct O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)\nstruct P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)\nstruct Q { unsigned int k : 12, j : 13, i : 7; unsigned long long l; }; T(Q)\nstruct R { unsigned int k : 12, j : 11, i : 9; unsigned long long l; }; T(R)\nstruct S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)\nstruct T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)\nstruct U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)\nstruct V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)\nstruct W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)\nstruct X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)\nstruct Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)\nstruct Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)\n\nint\nmain (void)\n{\n  testA ();\n  testB ();\n  testC ();\n  testD ();\n  testE ();\n  testF ();\n  testG ();\n  testH ();\n  testI ();\n  testJ ();\n  testK ();\n  testL ();\n  testM ();\n  testN ();\n  testO ();\n  testP ();\n  testQ ();\n  testR ();\n  testS ();\n  testT ();\n  testU ();\n  testV ();\n  testW ();\n  testX ();\n  testY ();\n  testZ ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040709-2.c",
    "content": "/* Test arithmetics on bitfields.  */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nextern void exit (int);\n\nunsigned int\nmyrnd (void)\n{\n  static unsigned int s = 1388815473;\n  s *= 1103515245;\n  s += 12345;\n  return (s / 65536) % 2048;\n}\n\n#define T(S)\t\t\t\t\t\\\nstruct S s##S;\t\t\t\t\t\\\nstruct S retme##S (struct S x)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return x;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn1##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y = retme##S (y);\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn2##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  struct S y = s##S;\t\t\t\t\\\n  y.k += x;\t\t\t\t\t\\\n  y.k %= 15;\t\t\t\t\t\\\n  return y.k;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int retit##S (void)\t\t\t\\\n{\t\t\t\t\t\t\\\n  return s##S.k;\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nunsigned int fn3##S (unsigned int x)\t\t\\\n{\t\t\t\t\t\t\\\n  s##S.k += x;\t\t\t\t\t\\\n  return retit##S ();\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid test##S (void)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n  unsigned int mask, v, a, r;\t\t\t\\\n  struct S x;\t\t\t\t\t\\\n  char *p = (char *) &s##S;\t\t\t\\\n  for (i = 0; i < sizeof (s##S); ++i)\t\t\\\n    *p++ = myrnd ();\t\t\t\t\\\n  if (__builtin_classify_type (s##S.l) == 8)\t\\\n    s##S.l = 5.25;\t\t\t\t\\\n  s##S.k = -1;\t\t\t\t\t\\\n  mask = s##S.k;\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn1##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn2##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || x.k != s##S.k || x.l != s##S.l\t\t\\\n      || ((((v + a) & mask) % 15) & mask) != r)\t\\\n    abort ();\t\t\t\t\t\\\n  v = myrnd ();\t\t\t\t\t\\\n  a = myrnd ();\t\t\t\t\t\\\n  s##S.k = v;\t\t\t\t\t\\\n  x = s##S;\t\t\t\t\t\\\n  r = fn3##S (a);\t\t\t\t\\\n  if (x.i != s##S.i || x.j != s##S.j\t\t\\\n      || s##S.k != r || x.l != s##S.l\t\t\\\n      || ((v + a) & mask) != r)\t\t\t\\\n    abort ();\t\t\t\t\t\\\n}\n\n#define pck __attribute__((packed))\nstruct pck A { unsigned short i : 1, l : 1, j : 3, k : 11; }; T(A)\nstruct pck B { unsigned short i : 4, j : 1, k : 11; unsigned int l; }; T(B)\nstruct pck C { unsigned int l; unsigned short i : 4, j : 1, k : 11; }; T(C)\nstruct pck D { unsigned long long l : 6, i : 6, j : 23, k : 29; }; T(D)\nstruct pck E { unsigned long long l, i : 12, j : 23, k : 29; }; T(E)\nstruct pck F { unsigned long long i : 12, j : 23, k : 29, l; }; T(F)\nstruct pck G { unsigned short i : 1, j : 1, k : 6; unsigned long long l; }; T(G)\nstruct pck H { unsigned short i : 6, j : 2, k : 8; unsigned long long l; }; T(H)\nstruct pck I { unsigned short i : 1, j : 6, k : 1; unsigned long long l; }; T(I)\nstruct pck J { unsigned short i : 1, j : 8, k : 7; unsigned short l; }; T(J)\nstruct pck K { unsigned int k : 6, l : 1, j : 10, i : 15; }; T(K)\nstruct pck L { unsigned int k : 6, j : 11, i : 15; unsigned int l; }; T(L)\nstruct pck M { unsigned int l; unsigned short k : 6, j : 11, i : 15; }; T(M)\nstruct pck N { unsigned long long l : 6, k : 6, j : 23, i : 29; }; T(N)\nstruct pck O { unsigned long long l, k : 12, j : 23, i : 29; }; T(O)\nstruct pck P { unsigned long long k : 12, j : 23, i : 29, l; }; T(P)\nstruct pck Q { unsigned short k : 12, j : 1, i : 3; unsigned long long l; }; T(Q)\nstruct pck R { unsigned short k : 2, j : 11, i : 3; unsigned long long l; }; T(R)\nstruct pck S { unsigned short k : 1, j : 6, i : 9; unsigned long long l; }; T(S)\nstruct pck T { unsigned short k : 1, j : 8, i : 7; unsigned short l; }; T(T)\nstruct pck U { unsigned short j : 6, k : 1, i : 9; unsigned long long l; }; T(U)\nstruct pck V { unsigned short j : 8, k : 1, i : 7; unsigned short l; }; T(V)\nstruct pck W { long double l; unsigned int k : 12, j : 13, i : 7; }; T(W)\nstruct pck X { unsigned int k : 12, j : 13, i : 7; long double l; }; T(X)\nstruct pck Y { unsigned int k : 12, j : 11, i : 9; long double l; }; T(Y)\nstruct pck Z { long double l; unsigned int j : 13, i : 7, k : 12; }; T(Z)\n\nint\nmain (void)\n{\n  testA ();\n  testB ();\n  testC ();\n  testD ();\n  testE ();\n  testF ();\n  testG ();\n  testH ();\n  testI ();\n  testJ ();\n  testK ();\n  testL ();\n  testM ();\n  testN ();\n  testO ();\n  testP ();\n  testQ ();\n  testR ();\n  testS ();\n  testT ();\n  testU ();\n  testV ();\n  testW ();\n  testX ();\n  testY ();\n  testZ ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040805-1.c",
    "content": "#if __INT_MAX__ < 32768 || (defined(STACK_SIZE) && STACK_SIZE < 0x12000)\nint main () { exit (0); }\n#else\nint a[2] = { 2, 3 };\n\nstatic int __attribute__((noinline))\nbar (int x, void *b)\n{\n  a[0]++;\n  return x;\n}\n\nstatic int __attribute__((noinline))\nfoo (int x)\n{\n  char buf[0x10000];\n  int y = a[0];\n  a[1] = y;\n  x = bar (x, buf);\n  y = bar (y, buf);\n  return x + y;\n}\n\nint\nmain ()\n{\n  if (foo (100) != 102)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040811-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target alloca } */\n\n/* Ensure that we deallocate X when branching back before its\n   declaration.  */\n\nvoid *volatile p;\n                                                                                \nint\nmain (void)\n{\n  int n = 0;\n lab:;\n  int x[n % 1000 + 1];\n  x[0] = 1;\n  x[n % 1000] = 2;\n  p = x;\n  n++;\n  if (n < 1000000)\n    goto lab;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040820-1.c",
    "content": "/* PR rtl-optimization/17099 */\n\nextern void exit (int);\nextern void abort (void);\n\nvoid\ncheck (int a)\n{\n  if (a != 1)\n    abort ();\n}\n\nvoid\ntest (int a, int b)\n{\n  check ((a ? 1 : 0) | (b ? 2 : 0));\n}\n\nint\nmain (void)\n{\n  test (1, 0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040823-1.c",
    "content": "/* Ensure that we create VUSE operands also for noreturn functions.  */\n\n#include <stdlib.h>\n#include <string.h>\n\nint *pwarn;\n\nvoid bla (void) __attribute__ ((noreturn));\n\nvoid bla (void)\n{\n  if (!*pwarn)\n    abort ();\n    \n  exit (0);\n}\n\nint main (void)\n{\n  int warn;\n\n  memset (&warn, 0, sizeof (warn));\n\n  pwarn = &warn;\n\n  warn = 1;\n\n  bla ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040831-1.c",
    "content": "/* This testcase was being miscompiled, because operand_equal_p\n   returned that (unsigned long) d and (long) d are equal.  */\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  double d = -12.0;\n  long l = (d > 10000) ? (unsigned long) d : (long) d;\n  if (l != -12)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20040917-1.c",
    "content": "/* submitted by kenneth zadeck */\n\nstatic int test_var;\n\n/* the idea here is that not only is inlinable, inlinable but since it\n   is static, the cgraph node will not be marked as output.  The\n   current version of the code ignores these cgraph nodes.  */\n\nvoid not_inlinable()  __attribute__((noinline));\n\nstatic void  \ninlinable ()\n{\n  test_var = -10;\n}\n\nvoid \nnot_inlinable ()\n{\n  inlinable();\n}\n\nmain ()\n{\n  test_var = 10;\n  /* Variable test_var should be considered call-clobbered by the call\n     to not_inlinable().  */\n  not_inlinable ();\n  if (test_var == 10)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041011-1.c",
    "content": "typedef unsigned long long ull;\nvolatile int gvol[32];\null gull;\n\n#define MULTI(X) \\\n\tX( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), X(10), \\\n\tX(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19), X(20), \\\n\tX(21), X(22), X(23), X(24), X(25), X(26), X(27), X(28), X(29), X(30)\n\n#define DECLARE(INDEX) x##INDEX\n#define COPYIN(INDEX) x##INDEX = gvol[INDEX]\n#define COPYOUT(INDEX) gvol[INDEX] = x##INDEX\n\n#define BUILD_TEST(NAME, N)\t\t\\\n  ull __attribute__((noinline))\t\t\\\n  NAME (int n, ull x)\t\t\t\\\n  {\t\t\t\t\t\\\n    while (n--)\t\t\t\t\\\n      {\t\t\t\t\t\\\n\tint MULTI (DECLARE);\t\t\\\n\tMULTI (COPYIN);\t\t\t\\\n\tMULTI (COPYOUT);\t\t\\\n\tx += N;\t\t\t\t\\\n      }\t\t\t\t\t\\\n    return x;\t\t\t\t\\\n  }\n\n#define RUN_TEST(NAME, N)\t\t\\\n  if (NAME (3, ~0ULL) != N * 3 - 1)\t\\\n    abort ();\t\t\t\t\\\n  if (NAME (3, 0xffffffffULL)\t\t\\\n      != N * 3 + 0xffffffffULL)\t\t\\\n    abort ();\n\n#define DO_TESTS(DO_TEST)\t\\\n  DO_TEST (t1, -2048)\t\t\\\n  DO_TEST (t2, -513)\t\t\\\n  DO_TEST (t3, -512)\t\t\\\n  DO_TEST (t4, -511)\t\t\\\n  DO_TEST (t5, -1)\t\t\\\n  DO_TEST (t6, 1)\t\t\\\n  DO_TEST (t7, 511)\t\t\\\n  DO_TEST (t8, 512)\t\t\\\n  DO_TEST (t9, 513)\t\t\\\n  DO_TEST (t10, gull)\t\t\\\n  DO_TEST (t11, -gull)\n\nDO_TESTS (BUILD_TEST)\n\null neg (ull x) { return -x; }\n\nint\nmain ()\n{\n  gull = 100;\n  DO_TESTS (RUN_TEST)\n  if (neg (gull) != -100ULL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041019-1.c",
    "content": "test_store_ccp (int i)\n{\n  int *p, a, b, c;\n\n  if (i < 5)\n    p = &a;\n  else if (i > 8)\n    p = &b;\n  else\n    p = &c;\n\n  *p = 10;\n  b = 3;\n\n  /* STORE-CCP was wrongfully propagating 10 into *p.  */\n  return *p + 2;\n}\n\n\ntest_store_copy_prop (int i)\n{\n  int *p, a, b, c;\n\n  if (i < 5)\n    p = &a;\n  else if (i > 8)\n    p = &b;\n  else\n    p = &c;\n\n  *p = i;\n  b = i + 1;\n\n  /* STORE-COPY-PROP was wrongfully propagating i into *p.  */\n  return *p;\n}\n\n\nmain()\n{\n  int x;\n  \n  x = test_store_ccp (10);\n  if (x == 12)\n    abort ();\n  \n  x = test_store_copy_prop (9);\n  if (x == 9)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041112-1.c",
    "content": "/* This was failing on Alpha because the comparison (p != -1) was rewritten\n   as (p+1 != 0) and p+1 isn't allowed to wrap for pointers.  */\n\nextern void abort(void);\n\ntypedef __SIZE_TYPE__ size_t;\n\nint global;\n\nstatic void *foo(int p)\n{\n  if (p == 0)\n   {\n      global++;\n      return &global;\n   }\n\n  return (void *)(size_t)-1;\n}\n\nint bar(void)\n{\n  void *p;\n\n  p = foo(global);\n  if (p != (void *)(size_t)-1)\n    return 1;\n\n  global++;\n  return 0;\n}\n\nint main(void)\n{\n  global = 1;\n  if (bar () != 0)\n    abort();\n  \n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041113-1.c",
    "content": "#include <stdarg.h>\n\nvoid test (int x, ...)\n{\n    va_list ap;\n    int i;\n    va_start (ap, x);\n    if (va_arg (ap, int) != 1)\n\tabort ();\n    if (va_arg (ap, int) != 2)\n\tabort ();\n    if (va_arg (ap, int) != 3)\n\tabort ();\n    if (va_arg (ap, int) != 4)\n\tabort ();\n}\n\ndouble a = 40.0;\n\nint main(int argc, char *argv[])\n{\n    test(0, 1, 2, 3, (int)(a / 10.0));\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041114-1.c",
    "content": "/* Verify that\n   \n   var <= 0 || ((long unsigned) (unsigned) (var - 1) < MAX_UNSIGNED_INT)\n\n   gets folded to 1.  */\n\n#include <limits.h>\n\nvoid abort (void);\nvoid link_failure (void);\n\nvolatile int v;\n\nvoid \nfoo (int var)\n{\n  if (!(var <= 0\n        || ((long unsigned) (unsigned) (var - 1) < UINT_MAX)))\n    link_failure ();\n}\n\nint\nmain (int argc, char **argv)\n{\n  foo (v);\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_failure (void)\n{\n  abort ();\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041124-1.c",
    "content": "struct s { _Complex unsigned short x; };\nstruct s gs = { 100 + 200i };\nstruct s __attribute__((noinline)) foo (void) { return gs; }\n\nint main ()\n{\n  if (foo ().x != gs.x)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041126-1.c",
    "content": "extern int abs (int);\nextern void abort (void);\n\nvoid\ncheck (int *p)\n{\n  int i;\n  for (i = 0; i < 5; ++i)\n    if (p[i])\n      abort ();\n  for (; i < 10; ++i)\n    if (p[i] != i + 1)\n      abort ();\n}\n\nint\nmain (void)\n{\n  int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n  int i;\n\n  for (i = -5; i < 0; i++)\n    a[abs (i - 10) - 11] = 0;\n  check (a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041201-1.c",
    "content": "/* PR rtl-opt/15289 */\n\ntypedef struct { _Complex char a; _Complex char b; } Scc2;\n\nScc2 s = { 1+2i, 3+4i };\n\nint checkScc2 (Scc2 s)\n{\n  return s.a != 1+2i || s.b != 3+4i;\n}\n\nint main (void)\n{\n  return checkScc2 (s);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041210-1.c",
    "content": "/* The FR-V port used to fail this test because the andcc patterns\n   wrongly claimed to set the C and V flags.  */\n#include <limits.h>\n\nint x[4] = { INT_MIN / 2, INT_MAX, 2, 4 };\n\nint\nmain ()\n{\n  if (x[0] < x[1])\n    if ((x[2] & x[3]) < 0)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041212-1.c",
    "content": "/* A function pointer compared with a void pointer should not be canonicalized.\n   See PR middle-end/17564.  */\nvoid *f (void) __attribute__ ((__noinline__));\nvoid *\nf (void)\n{\n  return f;\n}\nint\nmain (void)\n{\n  if (f () != f)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041213-2.c",
    "content": "/* PR tree-optimization/18694\n\n   The dominator optimization didn't take the PHI evaluation order\n   into account when threading an edge.  */\n\nextern void abort (void) __attribute__((noreturn));\nextern void exit (int) __attribute__((noreturn));\n\nvoid __attribute__((noinline))\nfoo (int i)\n{\n  int next_n = 1;\n  int j = 0;\n\n  for (; i != 0; i--)\n    {\n      int n;\n\n      for (n = next_n; j < n; j++)\n\tnext_n++;\n\n      if (j != n)\n\tabort ();\n    }\n}\n\nint\nmain (void)\n{\n  foo (2);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041214-1.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n\ntypedef long unsigned int size_t;\nextern void abort (void);\nextern char *strcpy (char *, const char *);\nextern int strcmp (const char *, const char *);\ntypedef __builtin_va_list va_list;\nstatic const char null[] = \"(null)\";\nint g (char *s, const char *format, va_list ap)\n{\n  const char *f;\n  const char *string;\n  char spec;\n  static const void *step0_jumps[] = {\n    &&do_precision,\n    &&do_form_integer,\n    &&do_form_string,\n  };\n  f = format;\n  if (*f == '\\0')\n    goto all_done;\n  do\n    {\n      spec = (*++f);\n      goto *(step0_jumps[2]);\n      \n    /* begin switch table. */\n    do_precision:\n      ++f;\n      __builtin_va_arg (ap, int);\n      spec = *f;\n      goto *(step0_jumps[2]);\n      \n      do_form_integer:\n\t__builtin_va_arg (ap, unsigned long int);\n\tgoto end;\n\t\n      do_form_string:\n\tstring = __builtin_va_arg (ap, const char *);\n\tstrcpy (s, string);\n      \n      /* End of switch table. */\n      end:\n      ++f;\n    }\n  while (*f != '\\0');\n\nall_done:\n  return 0;\n}\n\nvoid\nf (char *s, const char *f, ...)\n{\n  va_list ap;\n  __builtin_va_start (ap, f);\n  g (s, f, ap);\n  __builtin_va_end (ap);\n}\n\nint\nmain (void)\n{\n  char buf[10];\n  f (buf, \"%s\", \"asdf\", 0);\n  if (strcmp (buf, \"asdf\"))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041218-1.c",
    "content": "/* PR rtl-optimization/16968 */\n/* Testcase by Jakub Jelinek  <jakub@redhat.com> */\n\nstruct T\n{\n  unsigned int b, c, *d;\n  unsigned char e;\n};\nstruct S\n{\n  unsigned int a;\n  struct T f;\n};\nstruct U\n{\n  struct S g, h;\n};\nstruct V\n{\n  unsigned int i;\n  struct U j;\n};\n\nextern void exit (int);\nextern void abort (void);\n\nvoid *\ndummy1 (void *x)\n{\n  return \"\";\n}\n\nvoid *\ndummy2 (void *x, void *y)\n{\n  exit (0);\n}\n\nstruct V *\nbaz (unsigned int x)\n{\n  static struct V v;\n  __builtin_memset (&v, 0x55, sizeof (v));\n  return &v;\n}\n\nint\ncheck (void *x, struct S *y)\n{\n  if (y->a || y->f.b || y->f.c || y->f.d || y->f.e)\n    abort ();\n  return 1;\n}\n\nstatic struct V *\nbar (unsigned int x, void *y)\n{\n  const struct T t = { 0, 0, (void *) 0, 0 };\n  struct V *u;\n  void *v;\n  v = dummy1 (y);\n  if (!v)\n    return (void *) 0;\n\n  u = baz (sizeof (struct V));\n  u->i = x;\n  u->j.g.a = 0;\n  u->j.g.f = t;\n  u->j.h.a = 0;\n  u->j.h.f = t;\n\n  if (!check (v, &u->j.g) || !check (v, &u->j.h))\n    return (void *) 0;\n  return u;\n}\n\nint\nfoo (unsigned int *x, unsigned int y, void **z)\n{\n  void *v;\n  unsigned int i, j;\n\n  *z = v = (void *) 0;\n\n  for (i = 0; i < y; i++)\n    {\n      struct V *c;\n\n      j = *x;\n\n      switch (j)\n\t{\n\tcase 1:\n\t  c = bar (j, x);\n\t  break;\n\tdefault:\n\t  c = 0;\n\t  break;\n\t}\n      if (c)\n\tv = dummy2 (v, c);\n      else\n        return 1;\n    }\n\n  *z = v;\n  return 0;\n}\n\nint\nmain (void)\n{\n  unsigned int one = 1;\n  void *p;\n  foo (&one, 1, &p);\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20041218-2.c",
    "content": "extern void abort (void);\n\nint test(int n)\n{\n  struct s { char b[n]; } __attribute__((packed));\n  n++;\n  return sizeof(struct s);\n}\n\nint main()\n{\n  if (test(123) != 123)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050104-1.c",
    "content": "/* PR tree-optimization/19060 */\n\nvoid abort (void);\n\nstatic\nlong long min ()\n{\n  return -__LONG_LONG_MAX__ - 1;\n}\n\nvoid\nfoo (long long j)\n{\n  if (j > 10 || j < min ())\n    abort ();\n}\n\nint\nmain (void)\n{\n  foo (10);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050106-1.c",
    "content": "/* PR tree-optimization/19283 */\n\nvoid abort (void);\n\nstatic inline unsigned short\nfoo (unsigned int *p)\n{\n  return *p;\n};\n\nunsigned int u;\n\nint\nmain ()\n{\n  if ((foo (&u) & 0x8000) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050107-1.c",
    "content": "typedef enum { C = 1, D = 2 } B;\nextern void abort (void);\n\nstruct S\n{\n  B __attribute__ ((mode (byte))) a;\n  B __attribute__ ((mode (byte))) b;\n};\n\nvoid\nfoo (struct S *x)\n{\n  if (x->a != C || x->b != D)\n    abort ();\n}\n\nint\nmain (void)\n{\n  struct S s;\n  s.a = C;\n  s.b = D;\n  foo (&s);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050111-1.c",
    "content": "/* PR middle-end/19084, rtl-optimization/19348 */\n\nunsigned int\nfoo (unsigned long long x)\n{\n  unsigned int u;\n\n  if (x == 0)\n    return 0;\n  u = (unsigned int) (x >> 32);\n  return u;\n}\n\nunsigned long long\nbar (unsigned short x)\n{\n  return (unsigned long long) x << 32;\n}\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  if (sizeof (long long) != 8)\n    return 0;\n\n  if (foo (0) != 0)\n    abort ();\n  if (foo (0xffffffffULL) != 0)\n    abort ();\n  if (foo (0x25ff00ff00ULL) != 0x25)\n    abort ();\n  if (bar (0) != 0)\n    abort ();\n  if (bar (0x25) != 0x2500000000ULL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050119-1.c",
    "content": "/* PR c/19342 */\ntypedef enum { A, B, C, D } E;\n\nstruct S {\n  E __attribute__ ((mode (__byte__))) a;\n  E __attribute__ ((mode (__byte__))) b;\n  E __attribute__ ((mode (__byte__))) c;\n  E __attribute__ ((mode (__byte__))) d;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (struct S *s)\n{\n  if (s->a != s->b)\n    abort ();\n  if (s->c != C)\n    abort ();\n}\n\nint\nmain (void)\n{\n  struct S s[2];\n  s[0].a = B;\n  s[0].b = B;\n  s[0].c = C;\n  s[0].d = D;\n  s[1].a = D;\n  s[1].b = C;\n  s[1].c = B;\n  s[1].d = A;\n  foo (s);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050119-2.c",
    "content": "/* PR middle-end/19874 */\ntypedef enum { A, B, C, D } E;\n\nstruct S {\n  E __attribute__ ((mode (__byte__))) a;\n  E __attribute__ ((mode (__byte__))) b;\n  E __attribute__ ((mode (__byte__))) c;\n  E __attribute__ ((mode (__byte__))) d;\n};\n\nextern void abort (void);\nextern void exit (int);\n\nE\nfoo (struct S *s)\n{\n  if (s->a != s->b)\n    abort ();\n  if (s->c != C)\n    abort ();\n  return s->d;\n}\n\nint\nmain (void)\n{\n  struct S s[2];\n  s[0].a = B;\n  s[0].b = B;\n  s[0].c = C;\n  s[0].d = D;\n  s[1].a = D;\n  s[1].b = C;\n  s[1].c = B;\n  s[1].d = A;\n  if (foo (s) != D)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050121-1.c",
    "content": "/* PR middle-end/19551 */\n\nextern void abort ();\n\n#define T(type, name) \\\n__attribute__((pure)) _Complex type\t\t\\\nfoo_##name (int x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  _Complex type r;\t\t\t\t\\\n  __real r = x + 1;\t\t\t\t\\\n  __imag r = x - 1;\t\t\t\t\\\n  return r;\t\t\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\\\nbar_##name (type *x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  *x = __real foo_##name (5);\t\t\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\\\nbaz_##name (type *x)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  *x = __imag foo_##name (5);\t\t\t\\\n}\n\ntypedef long double ldouble_t;\ntypedef long long llong;\n\nT (float, float)\nT (double, double)\nT (long double, ldouble_t)\nT (char, char)\nT (short, short)\nT (int, int)\nT (long, long)\nT (long long, llong)\n#undef T\n\nint\nmain (void)\n{\n#define T(type, name) \\\n  {\t\t\t\t\t\t\\\n    type var = 0;\t\t\t\t\\\n    bar_##name (&var);\t\t\t\t\\\n    if (var != 6)\t\t\t\t\\\n      abort ();\t\t\t\t\t\\\n    var = 0;\t\t\t\t\t\\\n    baz_##name (&var);\t\t\t\t\\\n    if (var != 4)\t\t\t\t\\\n      abort ();\t\t\t\t\t\\\n  }\n  T (float, float)\n  T (double, double)\n  T (long double, ldouble_t)\n  T (char, char)\n  T (short, short)\n  T (int, int)\n  T (long, long)\n  T (long long, llong)\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050124-1.c",
    "content": "/* PR rtl-optimization/19579 */\n\nextern void abort (void);\n\nint\nfoo (int i, int j)\n{\n  int k = i + 1;\n\n  if (j)\n    {\n      if (k > 0)\n\tk++;\n      else if (k < 0)\n\tk--;\n    }\n\n  return k;\n}\n\nint\nmain (void)\n{\n  if (foo (-2, 0) != -1)\n    abort ();\n  if (foo (-1, 0) != 0)\n    abort ();\n  if (foo (0, 0) != 1)\n    abort ();\n  if (foo (1, 0) != 2)\n    abort ();\n  if (foo (-2, 1) != -2)\n    abort ();\n  if (foo (-1, 1) != 0)\n    abort ();\n  if (foo (0, 1) != 2)\n    abort ();\n  if (foo (1, 1) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050125-1.c",
    "content": "/* Verify that the CALL sideeffect isn't optimized away.  */\n/* Contributed by Greg Parker  25 Jan 2005  <gparker@apple.com> */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nstruct parse {\n  char *next;\n  char *end;\n  int error;\n};\n\nint seterr(struct parse *p, int err)\n{\n  p->error = err;\n  return 0;\n}\n\nvoid bracket_empty(struct parse *p)\n{\n  if (((p->next < p->end) && (*p->next++) == ']')  ||  seterr(p, 7)) { }\n}\n\nint main(int argc __attribute__((unused)), char **argv __attribute__((unused)))\n{\n  struct parse p;\n  p.next = p.end = (char *)0x12345;\n\n  p.error = 0;\n  bracket_empty(&p);\n  if (p.error != 7)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050131-1.c",
    "content": "/* Verify that we do not lose side effects on a MOD expression.  */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nint\nfoo (int a)\n{\n  int x = 0 % a++;\n  return a;\n}\n\nmain()\n{\n  if (foo (9) != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050203-1.c",
    "content": "/* Reduced testcase extracted from Samba source code.  */\n\n#include <stdlib.h>\n\nstatic void __attribute__((__noinline__))\n     foo (unsigned char *p) {\n  *p = 0x81;\n}\n\nstatic void __attribute__((__noinline__))\n     bar (int x) {\n  asm (\"\");\n}\n\nint main() {\n  unsigned char b;\n\n  foo(&b);\n  if (b & 0x80)\n    {\n      bar (b & 0x7f);\n      exit (0);\n    }\n  else\n    {\n      bar (b & 1);\n      abort ();\n    }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050215-1.c",
    "content": "/* PR middle-end/19857 */\n\ntypedef struct { char c[8]; } V\n#ifdef __ELF__\n  __attribute__ ((aligned (8)))\n#endif\n  ;\ntypedef __SIZE_TYPE__ size_t;\nV v;\nvoid abort (void);\n\nint\nmain (void)\n{\n  V *w = &v;\n  if (((size_t) ((float *) ((size_t) w & ~(size_t) 3)) % 8) != 0\n      || ((size_t) w & 1))\n    {\n#ifndef __ELF__\n      if (((size_t) &v & 7) == 0)\n#endif\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050218-1.c",
    "content": "/* PR tree-optimization/19828 */\ntypedef __SIZE_TYPE__ size_t;\nextern size_t strlen (const char *s);\nextern int strncmp (const char *s1, const char *s2, size_t n);\nextern void abort (void);\n\nconst char *a[16] = { \"a\", \"bc\", \"de\", \"fgh\" };\n\nint\nfoo (char *x, const char *y, size_t n)\n{\n  size_t i, j = 0;\n  for (i = 0; i < n; i++)\n    {\n      if (strncmp (x + j, a[i], strlen (a[i])) != 0)\n        return 2;\n      j += strlen (a[i]);\n      if (y)\n        j += strlen (y);\n    }\n  return 0;\n}\n\nint\nmain (void)\n{\n  if (foo (\"abcde\", (const char *) 0, 3) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050224-1.c",
    "content": "/* Origin: Mikael Pettersson <mikpe@csd.uu.se> and the Linux kernel.  */\n\nextern void abort (void);\nunsigned long a = 0xc0000000, b = 0xd0000000;\nunsigned long c = 0xc01bb958, d = 0xc0264000;\nunsigned long e = 0xc0288000, f = 0xc02d4378;\n\nvoid\nfoo (int x, int y, int z)\n{\n  if (x != 245 || y != 36 || z != 444)\n    abort ();\n}\n\nint\nmain (void)\n{\n  unsigned long g;\n  int h = 0, i = 0, j = 0;\n\n  if (sizeof (unsigned long) < 4)\n    return 0;\n\n  for (g = a; g < b; g += 0x1000)\n    if (g < c)\n      h++;\n    else if (g >= d && g < e)\n      j++;\n    else if (g < f)\n      i++;\n  foo (i, j, h);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050316-1.c",
    "content": "/* PR rtl-optimization/16104 */\n/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-Wno-psabi\" } */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nint\ntest1 (void)\n{\n  return (long long) (V2SI) 0LL;\n}\n\nint\ntest2 (V2SI x)\n{\n  return (long long) x;\n}\n\nV2SI\ntest3 (void)\n{\n  return (V2SI) (long long) (int) (V2HI) 0;\n}\n\nV2SI\ntest4 (V2HI x)\n{\n  return (V2SI) (long long) (int) x;\n}\n\nV2SI\ntest5 (V2USI x)\n{\n  return (V2SI) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  if (test1 () != 0)\n    abort ();\n\n  V2SI x = { 2, 2 };\n  if (test2 (x) != 2)\n    abort ();\n\n  union { V2SI x; int y[2]; V2USI z; long long l; } u;\n  u.x = test3 ();\n  if (u.y[0] != 0 || u.y[1] != 0)\n    abort ();\n\n  V2HI y = { 4, 4 };\n  union { V2SI x; long long y; } v;\n  v.x = test4 (y);\n  if (v.y != 0x40004)\n    abort ();\n\n  V2USI z = { 6, 6 };\n  u.x = test5 (z);\n  if (u.y[0] != 6 || u.y[1] != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050316-2.c",
    "content": "/* This testcase generates MMX instructions together with x87 instructions.\n   Currently, there is no \"emms\" generated to switch between register sets,\n   so the testcase fails for targets where MMX insns are enabled.  */\n/* { dg-options \"-mno-mmx -Wno-psabi\" { target { x86_64-*-* i?86-*-* } } } */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef float V2SF __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nlong long\ntest1 (V2SF x)\n{\n  return (long long) (V2SI) x;\n}\n\nlong long\ntest2 (V2SF x)\n{\n  return (long long) x;\n}\n\nlong long\ntest3 (V2SI x)\n{\n  return (long long) (V2SF) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  V2SF x = { 2.0, 2.0 };\n  union { long long l; float f[2]; int i[2]; } u;\n  u.l = test1 (x);\n  if (u.f[0] != 2.0 || u.f[1] != 2.0)\n    abort ();\n\n  V2SF y = { 6.0, 6.0 };\n  u.l = test2 (y);\n  if (u.f[0] != 6.0 || u.f[1] != 6.0)\n    abort ();\n\n  V2SI z = { 4, 4 };\n  u.l = test3 (z);\n  if (u.i[0] != 4 || u.i[1] != 4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050316-3.c",
    "content": "/* { dg-options \"-Wno-psabi\" } */\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\ntypedef unsigned int V2USI __attribute__ ((vector_size (8)));\ntypedef short V2HI __attribute__ ((vector_size (4)));\ntypedef unsigned int V2UHI __attribute__ ((vector_size (4)));\n\nV2USI\ntest1 (V2SI x)\n{\n  return (V2USI) (V2SI) (long long) x;\n}\n\nlong long\ntest2 (V2SI x)\n{\n  return (long long) (V2USI) (V2SI) (long long) x;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) != 2 || sizeof (int) != 4 || sizeof (long long) != 8)\n    return 0;\n\n  union { V2SI x; int y[2]; V2USI z; long long l; } u;\n  V2SI a = { -3, -3 };\n  u.z = test1 (a);\n  if (u.y[0] != -3 || u.y[1] != -3)\n    abort ();\n\n  u.l = test2 (a);\n  if (u.y[0] != -3 || u.y[1] != -3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050410-1.c",
    "content": "int s = 200;\nint __attribute__((noinline))\nfoo (void)\n{\n  return (signed char) (s - 100) - 5;\n}\nint\nmain (void)\n{\n  if (foo () != 95)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050502-1.c",
    "content": "/* PR rtl-optimization/21330 */\n\nextern void abort (void);\nextern int strcmp (const char *, const char *);\n\nint\n__attribute__((noinline))\nbar (const char **x)\n{\n  return *(*x)++;\n}\n\nint\n__attribute__((noinline))\nbaz (int c)\n{\n  return c != '@';\n}\n\nvoid\n__attribute__((noinline))\nfoo (const char **w, char *x, _Bool y, _Bool z)\n{\n  char c = bar (w);\n  int i = 0;\n\n  while (1)\n    {\n      x[i++] = c;\n      c = bar (w);\n      if (y && c == '\\'')\n        break;\n      if (z && c == '\\\"')\n        break;\n      if (!y && !z && !baz (c))\n        break;\n    }\n   x[i] = 0;\n}\n\nint\nmain (void)\n{\n  char buf[64];\n  const char *p;\n  p = \"abcde'fgh\";\n  foo (&p, buf, 1, 0);\n  if (strcmp (p, \"fgh\") != 0 || strcmp (buf, \"abcde\") != 0)\n    abort ();\n  p = \"ABCDEFG\\\"HI\";\n  foo (&p, buf, 0, 1);\n  if (strcmp (p, \"HI\") != 0 || strcmp (buf, \"ABCDEFG\") != 0)\n    abort ();\n  p = \"abcd\\\"e'fgh\";\n  foo (&p, buf, 1, 1);\n  if (strcmp (p, \"e'fgh\") != 0 || strcmp (buf, \"abcd\") != 0)\n    abort ();\n  p = \"ABCDEF'G\\\"HI\";\n  foo (&p, buf, 1, 1);\n  if (strcmp (p, \"G\\\"HI\") != 0 || strcmp (buf, \"ABCDEF\") != 0)\n    abort ();\n  p = \"abcdef@gh\";\n  foo (&p, buf, 0, 0);\n  if (strcmp (p, \"gh\") != 0 || strcmp (buf, \"abcdef\") != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050502-2.c",
    "content": "/* PR target/21297 */\ntypedef __SIZE_TYPE__ size_t;\nextern int memcmp (const char *, const char *, size_t);\nextern void abort ();\n\nvoid\nfoo (char *x)\n{\n  int i;\n  for (i = 0; i < 2; i++);\n  x[i + i] = '\\0';\n}\n\nvoid\nbar (char *x)\n{\n  int i;\n  for (i = 0; i < 2; i++);\n  x[i + i + i + i] = '\\0';\n}\n\nint\nmain (void)\n{\n  char x[] = \"IJKLMNOPQR\";\n  foo (x);\n  if (memcmp (x, \"IJKL\\0NOPQR\", sizeof x) != 0)\n    abort ();\n  x[4] = 'M';\n  bar (x);\n  if (memcmp (x, \"IJKLMNOP\\0R\", sizeof x) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050604-1.c",
    "content": "/* PR regression/21897 */\n/* This testcase generates MMX instructions together with x87 instructions.\n   Currently, there is no \"emms\" generated to switch between register sets,\n   so the testcase fails for targets where MMX insns are enabled.  */\n/* { dg-options \"-mno-mmx\" { target { x86_64-*-* i?86-*-* } } } */\n\nextern void abort (void);\n\ntypedef short v4hi __attribute__ ((vector_size (8)));\ntypedef float v4sf __attribute__ ((vector_size (16)));\n\nunion\n{\n  v4hi v;\n  short s[4];\n} u;\n\nunion\n{\n  v4sf v;\n  float f[4];\n} v;\n\nvoid\nfoo (void)\n{\n  unsigned int i;\n  for (i = 0; i < 2; i++)\n    u.v += (v4hi) { 12, 14 };\n  for (i = 0; i < 2; i++)\n    v.v += (v4sf) { 18.0, 20.0, 22 };\n}\n\nint\nmain (void)\n{\n  foo ();\n  if (u.s[0] != 24 || u.s[1] != 28 || u.s[2] || u.s[3])\n    abort ();\n  if (v.f[0] != 36.0 || v.f[1] != 40.0 || v.f[2] != 44.0 || v.f[3] != 0.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050607-1.c",
    "content": "/* PR middle-end/21850 */\n\nextern void abort (void);\n\ntypedef int V2SI __attribute__ ((vector_size (8)));\n\nint\nmain (void)\n{\n#if (__INT_MAX__ == 2147483647) \\\n    && (__LONG_LONG_MAX__ == 9223372036854775807LL)\n  if (((int)(long long)(V2SI){ 2, 2 }) != 2)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050613-1.c",
    "content": "/* PR tree-optimization/22043 */\n\nextern void abort (void);\n\nstruct A { int i; int j; int k; int l; };\nstruct B { struct A a; int r[1]; };\nstruct C { struct A a; int r[0]; };\nstruct D { struct A a; int r[]; };\n\nvoid\nfoo (struct A *x)\n{\n  if (x->i != 0 || x->j != 5 || x->k != 0 || x->l != 0)\n    abort ();\n}\n\nint\nmain ()\n{\n  struct B b = { .a.j = 5 };\n  struct C c = { .a.j = 5 };\n  struct D d = { .a.j = 5 };\n  foo (&b.a);\n  foo (&c.a);\n  foo (&d.a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050713-1.c",
    "content": "/* Test that sibling call is not used if there is an argument overlap.  */\n\nextern void abort (void);\n\nstruct S\n{\n  int a, b, c;\n};\n\nint\nfoo2 (struct S x, struct S y)\n{\n  if (x.a != 3 || x.b != 4 || x.c != 5)\n    abort ();\n  if (y.a != 6 || y.b != 7 || y.c != 8)\n    abort ();\n  return 0;\n}\n\nint\nfoo3 (struct S x, struct S y, struct S z)\n{\n  foo2 (x, y);\n  if (z.a != 9 || z.b != 10 || z.c != 11)\n    abort ();\n  return 0;\n}\n\nint\nbar2 (struct S x, struct S y)\n{\n  return foo2 (y, x);\n}\n\nint\nbar3 (struct S x, struct S y, struct S z)\n{\n  return foo3 (y, x, z);\n}\n\nint\nbaz3 (struct S x, struct S y, struct S z)\n{\n  return foo3 (y, z, x);\n}\n\nint\nmain (void)\n{\n  struct S a = { 3, 4, 5 }, b = { 6, 7, 8 }, c = { 9, 10, 11 };\n\n  bar2 (b, a);\n  bar3 (b, a, c);\n  baz3 (c, a, b);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050826-1.c",
    "content": "/* PR rtl-optimization/23561 */\n\nstruct A\n{\n  char a1[1];\n  char a2[5];\n  char a3[1];\n  char a4[2048 - 7];\n} a;\n\ntypedef __SIZE_TYPE__ size_t;\nextern void *memset (void *, int, size_t);\nextern void *memcpy (void *, const void *, size_t);\nextern int memcmp (const void *, const void *, size_t);\nextern void abort (void);\n\nvoid\nbar (struct A *x)\n{\n  size_t i;\n  if (memcmp (x, \"\\1HELLO\\1\", sizeof \"\\1HELLO\\1\"))\n    abort ();\n  for (i = 0; i < sizeof (x->a4); i++)\n    if (x->a4[i])\n      abort ();\n}\n\nint\nfoo (void)\n{\n  memset (&a, 0, sizeof (a));\n  a.a1[0] = 1;\n  memcpy (a.a2, \"HELLO\", sizeof \"HELLO\");\n  a.a3[0] = 1;\n  bar (&a);\n  return 0;\n}\n\nint\nmain (void)\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050826-2.c",
    "content": "/* PR rtl-optimization/23560 */\n\nstruct rtattr\n{\n  unsigned short rta_len;\n  unsigned short rta_type;\n};\n\n__attribute__ ((noinline))\nint inet_check_attr (void *r, struct rtattr **rta)\n{\n  int i;\n\n  for (i = 1; i <= 14; i++)\n    {\n      struct rtattr *attr = rta[i - 1];\n      if (attr)\n\t{\n\t  if (attr->rta_len - sizeof (struct rtattr) < 4)\n\t    return -22;\n\t  if (i != 9 && i != 8)\n\t    rta[i - 1] = attr + 1;\n\t}\n    }\n  return 0;\n}\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  struct rtattr rt[2];\n  struct rtattr *rta[14];\n  int i;\n\n  rt[0].rta_len = sizeof (struct rtattr) + 8;\n  rt[0].rta_type = 0;\n  rt[1] = rt[0];\n  for (i = 0; i < 14; i++)\n    rta[i] = &rt[0];\n  if (inet_check_attr (0, rta) != 0)\n    abort ();\n  for (i = 0; i < 14; i++)\n    if (rta[i] != &rt[i != 7 && i != 8])\n      abort ();\n  for (i = 0; i < 14; i++)\n    rta[i] = &rt[0];\n  rta[1] = 0;\n  rt[1].rta_len -= 8;\n  rta[5] = &rt[1];\n  if (inet_check_attr (0, rta) != -22)\n    abort ();\n  for (i = 0; i < 14; i++)\n    if (i == 1 && rta[i] != 0)\n      abort ();\n    else if (i != 1 && i <= 5 && rta[i] != &rt[1])\n      abort ();\n    else if (i > 5 && rta[i] != &rt[0])\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20050929-1.c",
    "content": "/* PR middle-end/24109 */\n\nextern void abort (void);\n\nstruct A { int i; int j; };\nstruct B { struct A *a; struct A *b; };\nstruct C { struct B *c; struct A *d; };\nstruct C e = { &(struct B) { &(struct A) { 1, 2 }, &(struct A) { 3, 4 } }, &(struct A) { 5, 6 } };\n\nint\nmain (void)\n{\n  if (e.c->a->i != 1 || e.c->a->j != 2)\n    abort ();\n  if (e.c->b->i != 3 || e.c->b->j != 4)\n    abort ();\n  if (e.d->i != 5 || e.d->j != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051012-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nextern void abort (void);\n\nstruct type \n{\n  int *a;\n  \n  int b:16;\n  unsigned int p:9;\n} t;\n\nunsigned int \nfoo ()\n{\n  return t.p;\n}\n\nint \nmain (void)\n{\n  t.p = 8;\n  if (foo (t) != 8)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051021-1.c",
    "content": "/* Verify that TRUTH_AND_EXPR is not wrongly changed to TRUTH_ANDIF_EXPR.  */\n\nextern void abort (void);\n\nint count = 0;\n\nint foo1(void)\n{\n  count++;\n  return 0;\n}\n\nint foo2(void)\n{\n  count++;\n  return 0;\n}\n\nint main(void)\n{\n  if ((foo1() == 1) & (foo2() == 1))\n    abort ();\n\n  if (count != 2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051104-1.c",
    "content": "/* PR rtl-optimization/23567 */\n\nstruct\n{\n  int len;\n  char *name;\n} s;\n\nint\nmain (void)\n{\n  s.len = 0;\n  s.name = \"\";\n  if (s.name [s.len] != 0)\n    s.name [s.len] = 0;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051110-1.c",
    "content": "void add_unwind_adjustsp (long);\nvoid abort (void);\n\nunsigned char bytes[5];\n\nvoid\nadd_unwind_adjustsp (long offset)\n{\n  int n;\n  unsigned long o;\n\n  o = (long) ((offset - 0x204) >> 2);\n\n  n = 0;\n  while (o)\n    {\n      bytes[n] = o & 0x7f;\n      o >>= 7;\n      if (o)\n\tbytes[n] |= 0x80;\n      n++;\n    }\n}\n\nint main(void)\n{\n  add_unwind_adjustsp (4132);\n  if (bytes[0] != 0x88 || bytes[1] != 0x07)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051110-2.c",
    "content": "void add_unwind_adjustsp (long);\nvoid abort (void);\n\nunsigned char bytes[5];\n\nint flag;\n\nvoid\nadd_unwind_adjustsp (long offset)\n{\n  int n;\n  unsigned long o;\n\n  o = (long) ((offset - 0x204) >> 2);\n\n  n = 0;\n  do\n    {\na:\n      bytes[n] = o & 0x7f;\n      o >>= 7;\n      if (o)\n        {\n\t  bytes[n] |= 0x80;\n\t  if (flag)\n\t    goto a;\n\t}\n      n++;\n    }\n  while (o);\n}\n\nint main(void)\n{\n  add_unwind_adjustsp (4132);\n  if (bytes[0] != 0x88 || bytes[1] != 0x07)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051113-1.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\nextern void *memset(void *, int, __SIZE_TYPE__);\ntypedef struct\n{\n  short a;  \n  unsigned short b;\n  unsigned short c;\n  unsigned long long Count;\n  long long Count2;\n} __attribute__((packed)) Struct1;\n\ntypedef struct\n{\n  short a;\n  unsigned short b;\n  unsigned short c;\n  unsigned long long d;\n  long long e;\n  long long f;\n} __attribute__((packed)) Struct2;\n\ntypedef union\n{\n  Struct1 a;\n  Struct2 b;\n} Union;\n\ntypedef struct\n{\n  int Count;\n  Union List[0];\n} __attribute__((packed)) Struct3;\n\nunsigned long long Sum (Struct3 *instrs) __attribute__((noinline));\nunsigned long long Sum (Struct3 *instrs)\n{\n    unsigned long long  count = 0;\n    int     i;\n    \n    for (i = 0; i < instrs->Count; i++) {\n        count += instrs->List[i].a.Count;\n    }\n    return count;\n}\nlong long Sum2 (Struct3 *instrs) __attribute__((noinline));\nlong long Sum2 (Struct3 *instrs)\n{\n    long long  count = 0;\n    int     i;\n    \n    for (i = 0; i < instrs->Count; i++) {\n        count += instrs->List[i].a.Count2;\n    }\n    return count;\n}\nmain() {\n  Struct3 *p = malloc (sizeof (int) + 3 * sizeof(Union));\n  memset(p, 0, sizeof(int) + 3*sizeof(Union));\n  p->Count = 3;\n  p->List[0].a.Count = 555;\n  p->List[1].a.Count = 999;\n  p->List[2].a.Count = 0x101010101ULL;\n  p->List[0].a.Count2 = 555;\n  p->List[1].a.Count2 = 999;\n  p->List[2].a.Count2 = 0x101010101LL;\n  if (Sum(p) != 555 + 999 + 0x101010101ULL)\n    abort();\n  if (Sum2(p) != 555 + 999 + 0x101010101LL)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20051215-1.c",
    "content": "/* PR rtl-optimization/24899 */\n\nextern void abort (void);\n\n__attribute__ ((noinline)) int\nfoo (int x, int y, int *z)\n{\n  int a, b, c, d;\n\n  a = b = 0;\n  for (d = 0; d < y; d++)\n    {\n      if (z)\n\tb = d * *z;\n      for (c = 0; c < x; c++)\n\ta += b;\n    }\n\n  return a;\n}\n\nint\nmain (void)\n{\n  if (foo (3, 2, 0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060102-1.c",
    "content": "extern void abort ();\n\nint f(int x)\n{\n  return (x >> (sizeof (x) * __CHAR_BIT__ - 1)) ? -1 : 1;\n}\n\nvolatile int one = 1;\nint main (void)\n{\n  /* Test that the function above returns different values for\n     different signs.  */\n  if (f(one) == f(-one))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060110-1.c",
    "content": "extern void abort (void);\n\nlong long \nf (long long a) \n{ \n  return (a << 32) >> 32; \n} \nlong long a = 0x1234567876543210LL;\nlong long b = (0x1234567876543210LL << 32) >> 32;\nint\nmain ()\n{\n  if (f (a) != b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060110-2.c",
    "content": "extern void abort (void);\n\nlong long \nf (long long a, long long b) \n{ \n  return ((a + b) << 32) >> 32; \n} \n\nlong long a = 0x1234567876543210LL;\nlong long b = 0x2345678765432101LL;\nlong long c = ((0x1234567876543210LL + 0x2345678765432101LL) << 32) >> 32;\n\nint\nmain ()\n{\n  if (f (a, b) != c)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060127-1.c",
    "content": "void abort ();\n\nvoid\nf (long long a)\n{\n  if ((a & 0xffffffffLL) != 0)\n    abort ();\n}\n\nlong long a = 0x1234567800000000LL;\n\nint\nmain ()\n{\n  f (a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060412-1.c",
    "content": "extern void abort (void);\n\nstruct S\n{\n  long o;\n};\n\nstruct T\n{\n  long o;\n  struct S m[82];\n};\n\nstruct T t;\n\nint\nmain ()\n{\n  struct S *p, *q;\n\n  p = (struct S *) &t;\n  p = &((struct T *) p)->m[0];\n  q = p + 82;\n  while (--q > p)\n    q->o = -1;\n  q->o = 0;\n\n  if (q > p)\n    abort ();\n  if (q - p > 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060420-1.c",
    "content": "extern void abort (void);\n\ntypedef float v4flt __attribute__ ((vector_size (16)));\n\nvoid __attribute__ ((noinline)) foo (float *dst, float **src, int a, int n)\n{\n  int i, j;\n  int z = sizeof (v4flt) / sizeof (float);\n  unsigned m = sizeof (v4flt) - 1;\n\n  for (j = 0; j < n && (((unsigned long) dst + j) & m); ++j)\n    {\n      float t = src[0][j];\n      for (i = 1; i < a; ++i)\n\tt += src[i][j];\n      dst[j] = t;\n    }\n\n  for (; j < (n - (4 * z - 1)); j += 4 * z)\n    {\n      v4flt t0 = *(v4flt *) (src[0] + j + 0 * z);\n      v4flt t1 = *(v4flt *) (src[0] + j + 1 * z);\n      v4flt t2 = *(v4flt *) (src[0] + j + 2 * z);\n      v4flt t3 = *(v4flt *) (src[0] + j + 3 * z);\n      for (i = 1; i < a; ++i)\n\t{\n\t  t0 += *(v4flt *) (src[i] + j + 0 * z);\n\t  t1 += *(v4flt *) (src[i] + j + 1 * z);\n\t  t2 += *(v4flt *) (src[i] + j + 2 * z);\n\t  t3 += *(v4flt *) (src[i] + j + 3 * z);\n\t}\n      *(v4flt *) (dst + j + 0 * z) = t0;\n      *(v4flt *) (dst + j + 1 * z) = t1;\n      *(v4flt *) (dst + j + 2 * z) = t2;\n      *(v4flt *) (dst + j + 3 * z) = t3;\n    }\n  for (; j < n; ++j)\n    {\n      float t = src[0][j];\n      for (i = 1; i < a; ++i)\n\tt += src[i][j];\n      dst[j] = t;\n    }\n}\n\nfloat buffer[64];\n\nint\nmain (void)\n{\n  int i;\n  float *dst, *src[2];\n  char *cptr;\n\n  cptr = (char *)buffer;\n  cptr += (-(long int) buffer & (16 * sizeof (float) - 1));\n  dst = (float *)cptr;\n  src[0] = dst + 16;\n  src[1] = dst + 32;\n  for (i = 0; i < 16; ++i)\n    {\n      src[0][i] = (float) i + 11 * (float) i;\n      src[1][i] = (float) i + 12 * (float) i;\n    }\n  foo (dst, src, 2, 16);\n  for (i = 0; i < 16; ++i)\n    {\n      float e = (float) i + 11 * (float) i + (float) i + 12 * (float) i;\n      if (dst[i] != e)\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060905-1.c",
    "content": "/* PR rtl-optimization/28386 */\n/* Origin: Volker Reichelt <reichelt@gcc.gnu.org> */\n\nextern void abort(void);\n\nvolatile char s[256][3];\n\nchar g;\n\nstatic void dummy(char a)\n{\n  g = a;\n}\n\nstatic int foo(void)\n{\n  int i, j=0;\n\n  for (i = 0; i < 256; i++)\n    if (i >= 128 && i < 256)\n      {\n\tdummy (s[i - 128][0]);\n\t++j;\n      }\n\n  return j;\n}\n\nint main(void)\n{\n  if (foo () != 128)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060910-1.c",
    "content": "/* PR rtl-optimization/28636 */\n/* Origin: Andreas Schwab <schwab@suse.de> */\n\nextern void abort(void);\n\nstruct input_ty\n{\n  unsigned char *buffer_position;\n  unsigned char *buffer_end;\n};\n\nint input_getc_complicated (struct input_ty *x) { return 0; }\n\nint check_header (struct input_ty *deeper)\n{\n  unsigned len;\n  for (len = 0; len < 6; len++)\n    if (((deeper)->buffer_position < (deeper)->buffer_end\n         ? *((deeper)->buffer_position)++\n         : input_getc_complicated((deeper))) < 0)\n      return 0;\n  return 1;\n}\n\nstruct input_ty s;\nunsigned char b[6];\n\nint main (void)\n{\n  s.buffer_position = b;\n  s.buffer_end = b + sizeof b;\n  if (!check_header(&s))\n    abort();\n  if (s.buffer_position != s.buffer_end)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060929-1.c",
    "content": "/* PR c/29154 */\n\nextern void abort (void);\n\nvoid\nfoo (int **p, int *q)\n{\n  *(*p++)++ = *q++;\n}\n\nvoid\nbar (int **p, int *q)\n{\n  **p = *q++;\n  *(*p++)++;\n}\n\nvoid\nbaz (int **p, int *q)\n{\n  **p = *q++;\n  (*p++)++;\n}\n\nint\nmain (void)\n{\n  int i = 42, j = 0;\n  int *p = &i;\n  foo (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  i = 43;\n  p = &i;\n  bar (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  i = 44;\n  p = &i;\n  baz (&p, &j);\n  if (p - 1 != &i || j != 0 || i != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060930-1.c",
    "content": "/* PR rtl-optimization/28096 */\n/* Origin: Jan Stein <jan@gatespacetelematics.com> */\n\nextern void abort (void);\n\nint bar (int, int) __attribute__((noinline));\nint bar (int a, int b)\n{\n  if (b != 1)\n    abort ();\n}\n\nvoid foo(int, int) __attribute__((noinline));\nvoid foo (int e, int n)\n{\n  int i, bb2, bb5;\n\n  if (e > 0)\n    e = -e;\n\n  for (i = 0; i < n; i++)\n    {\n      if (e >= 0)\n\t{\n\t  bb2 = 0;\n\t  bb5 = 0;\n\t}\n      else\n\t{\n\t  bb5 = -e;\n\t  bb2 = bb5;\n\t}\n\n      bar (bb5, bb2);\n    }\n}\n\nint main(void)\n{\n  foo (1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20060930-2.c",
    "content": "/* PR middle-end/29272 */\n\nextern void abort (void);\n\nstruct S { struct S *s; } s;\nstruct T { struct T *t; } t;\n\nstatic inline void\nfoo (void *s)\n{\n  struct T *p = s;\n  __builtin_memcpy (&p->t, &t.t, sizeof (t.t));\n}\n\nvoid *\n__attribute__((noinline))\nbar (void *p, struct S *q)\n{\n  q->s = &s;\n  foo (p);\n  return q->s;\n}\n\nint\nmain (void)\n{\n  t.t = &t;\n  if (bar (&s, &s) != (void *) &t)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20061031-1.c",
    "content": "/* PR rtl-optimization/29631 */\n/* Origin: Falk Hueffner <falk@debian.org> */\n\nconst signed char nunmap[] = { 17, -1, 1 };\n\n__attribute__((noinline))\nvoid ff(int i) {\n    asm volatile(\"\");\n}\n\n__attribute__((noinline))\nvoid f(short delta)\n{\n    short p0 = 2, s;\n    for (s = 0; s < 2; s++)\n    {\n        p0 += delta;\n        ff(s);\n        if (nunmap[p0] == 17)\n            asm volatile(\"\");\n    }\n}\n\nint main(void)\n{\n    f(-1);\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20061101-1.c",
    "content": "/* PR rtl-optimization/28970 */\n/* Origin: Peter Bergner <bergner@vnet.ibm.com> */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nint tar (int i)\n{\n  if (i != 36863)\n    abort ();\n\n  return -1;\n}\n\nvoid bug(int q, int bcount)\n{\n  int j = 0;\n  int outgo = 0;\n\n  while(j != -1)\n    {\n      outgo++;\n      if (outgo > q-1)\n        outgo = q-1;\n      j = tar (outgo*bcount);\n    }\n}\n\nint main(void)\n{\n  bug(5, 36863);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20061101-2.c",
    "content": "/* PR rtl-optimization/28970 */\n/* Origin: Peter Bergner <bergner@vnet.ibm.com> */\n\nextern void abort (void);\n\nint tar (long i)\n{\n  if (i != 36863)\n    abort ();\n\n  return -1;\n}\n\nvoid bug(int q, long bcount)\n{\n  int j = 0;\n  int outgo = 0;\n\n  while(j != -1)\n    {\n      outgo++;\n      if (outgo > q-1)\n        outgo = q-1;\n      j = tar (outgo*bcount);\n    }\n}\n\nint main(void)\n{\n  bug(5, 36863);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20061220-1.c",
    "content": "/* PR middle-end/30262 */\n/* { dg-skip-if \"asm statements do not work as expected\" { rl78-*-* } \"*\" \"\" } */\nextern void abort (void);\n\nint\nfoo (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    x = 254;\n  }\n\n  nested ();\n  asm volatile (\"\" :: \"r\" (x));\n  asm volatile (\"\" :: \"m\" (x));\n  asm volatile (\"\" :: \"mr\" (x));\n  asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n  asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n  return x;\n}\n\nint\nbar (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    asm volatile (\"\" :: \"r\" (x));\n    asm volatile (\"\" :: \"m\" (x));\n    asm volatile (\"\" :: \"mr\" (x));\n    x += 4;\n    asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n    asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n  }\n\n  nested ();\n  return x;\n}\n\nint\nbaz (void)\n{\n  unsigned int x = 0;\n\n  void nested (void)\n  {\n    void nested2 (void)\n    {\n      asm volatile (\"\" :: \"r\" (x));\n      asm volatile (\"\" :: \"m\" (x));\n      asm volatile (\"\" :: \"mr\" (x));\n      x += 4;\n      asm volatile (\"\" : \"=r\" (x) : \"0\" (x));\n      asm volatile (\"\" : \"=m\" (x) : \"m\" (x));\n    }\n    nested2 ();\n    nested2 ();\n  }\n\n  nested ();\n  return x;\n}\n\nint\nmain (void)\n{\n  if (foo () != 254 || bar () != 4 || baz () != 8)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070201-1.c",
    "content": "/* PR middle-end/30473 */\n\nextern int sprintf (char *, const char *, ...);\nextern void abort (void);\n\nchar *\nfoo (char *buf, char *p)\n{\n  sprintf (buf, \"abcde\", p++);\n  return p;\n}\n\nint\nmain (void)\n{\n  char buf[6];\n  if (foo (buf, &buf[2]) != &buf[3])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070212-1.c",
    "content": "struct f\n{\n  int i;\n};\n\nint g(int i, int c, struct f *ff, int *p)\n{\n  int *t;\n  if (c)\n   t = &i;\n  else\n   t = &ff->i;\n  *p = 0;\n  return *t;\n}\n\nextern void abort(void);\n\nint main()\n{\n  struct f f;\n  f.i = 1;\n  if (g(5, 0, &f, &f.i) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070212-2.c",
    "content": "int f(int k, int i1, int j1)\n{\n  int *f1;\n  if(k)\n   f1 = &i1;\n  else\n   f1 = &j1;\n  i1 = 0;\n  return *f1;\n}\n\nextern void abort (void);\n\nint main()\n{\n  if (f(1, 1, 2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070212-3.c",
    "content": "struct foo { int i; int j; };\n\nint bar (struct foo *k, int k2, int f, int f2)\n{\n  int *p, *q;\n  int res;\n  if (f)\n    p = &k->i;\n  else\n    p = &k->j;\n  res = *p;\n  k->i = 1;\n  if (f2)\n    q = p;\n  else\n    q = &k2;\n  return res + *q;\n}\n\nextern void abort (void);\n\nint main()\n{\n  struct foo k;\n  k.i = 0;\n  k.j = 1;\n  if (bar (&k, 1, 1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070424-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid do_exit (void) { exit (0); }\nvoid do_abort (void) { abort (); }\n\nvoid foo (int x, int a)\n{\n  if (x < a)\n    goto doit;\n  do_exit ();\n  if (x != a)\n    goto doit;\n\n  /* else */\n  do_abort ();\n  return;\n\ndoit:\n  do_abort ();\n}\n\nint main()\n{\n  foo (1, 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070517-1.c",
    "content": "/* PR rtl-optimization/31691 */\n/* Origin: Chi-Hua Chen <stephaniechc-gccbug@yahoo.com> */\n\nextern void abort (void);\n\nstatic int get_kind(int) __attribute__ ((noinline));\n\nstatic int get_kind(int v)\n{\n  volatile int k = v;\n  return k;\n}\n\nstatic int some_call(void) __attribute__ ((noinline));\n\nstatic int some_call(void)\n{\n  return 0;\n}\n\nstatic void example (int arg)\n{\n  int tmp, kind = get_kind (arg);\n\n  if (kind == 9 || kind == 10 || kind == 5)\n    {\n      if (some_call() == 0)\n        {\n          if (kind == 9 || kind == 10)\n            tmp = arg;\n          else\n            abort();\n        }\n    }\n} \n\nint main(void)\n{\n  example(10);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070614-1.c",
    "content": "extern void abort (void);\n\n_Complex v = 3.0 + 1.0iF;\n\nvoid\nfoo (_Complex z, int *x)\n{\n  if (z != v)\n    abort ();\n}\n\n_Complex bar (_Complex z) __attribute__ ((pure));\n_Complex\nbar (_Complex z)\n{\n  return v;\n}\n\nint\nbaz (void)\n{\n  int a, i;\n  for (i = 0; i < 6; i++)\n    foo (bar (1.0iF * i), &a);\n  return 0;\n}\n\nint\nmain ()\n{\n  baz ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070623-1.c",
    "content": "#include <limits.h>\n\nint __attribute__((noinline)) nge(int a, int b) {return -(a >= b);}\nint __attribute__((noinline)) ngt(int a, int b) {return -(a > b);}\nint __attribute__((noinline)) nle(int a, int b) {return -(a <= b);}\nint __attribute__((noinline)) nlt(int a, int b) {return -(a < b);}\nint __attribute__((noinline)) neq(int a, int b) {return -(a == b);}\nint __attribute__((noinline)) nne(int a, int b) {return -(a != b);}\nint __attribute__((noinline)) ngeu(unsigned a, unsigned b) {return -(a >= b);}\nint __attribute__((noinline)) ngtu(unsigned a, unsigned b) {return -(a > b);}\nint __attribute__((noinline)) nleu(unsigned a, unsigned b) {return -(a <= b);}\nint __attribute__((noinline)) nltu(unsigned a, unsigned b) {return -(a < b);}\n\n\nint main()\n{\n  if (nge(INT_MIN, INT_MAX) !=  0) abort();\n  if (nge(INT_MAX, INT_MIN) != -1) abort();\n  if (ngt(INT_MIN, INT_MAX) !=  0) abort();\n  if (ngt(INT_MAX, INT_MIN) != -1) abort();\n  if (nle(INT_MIN, INT_MAX) != -1) abort();\n  if (nle(INT_MAX, INT_MIN) !=  0) abort();\n  if (nlt(INT_MIN, INT_MAX) != -1) abort();\n  if (nlt(INT_MAX, INT_MIN) !=  0) abort();\n\n  if (neq(INT_MIN, INT_MAX) !=  0) abort();\n  if (neq(INT_MAX, INT_MIN) !=  0) abort();\n  if (nne(INT_MIN, INT_MAX) != -1) abort();\n  if (nne(INT_MAX, INT_MIN) != -1) abort();\n\n  if (ngeu(0, ~0U) !=  0) abort();\n  if (ngeu(~0U, 0) != -1) abort();\n  if (ngtu(0, ~0U) !=  0) abort();\n  if (ngtu(~0U, 0) != -1) abort();\n  if (nleu(0, ~0U) != -1) abort();\n  if (nleu(~0U, 0) !=  0) abort();\n  if (nltu(0, ~0U) != -1) abort();\n  if (nltu(~0U, 0) !=  0) abort();\n  \n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070724-1.c",
    "content": "void abort (void);\n\nstatic unsigned char magic[] = \"\\235\";\nstatic unsigned char value = '\\235';\n\nint main()\n{\n  if (value != magic[0])\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070824-1.c",
    "content": "/* PR tree-optimization/33136 */\n/* { dg-require-effective-target alloca } */\n\nextern void abort (void);\n\nstruct S\n{\n  struct S *a;\n  int b;\n};\n\nint\nmain (void)\n{\n  struct S *s = (struct S *) 0, **p, *n;\n  for (p = &s; *p; p = &(*p)->a);\n  n = (struct S *) __builtin_alloca (sizeof (*n));\n  n->a = *p;\n  n->b = 1;\n  *p = n;\n\n  if (!s)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20070919-1.c",
    "content": "/* PR c/33238 */\n/* { dg-require-effective-target alloca } */\n\ntypedef __SIZE_TYPE__ size_t;\nint memcmp (const void *, const void *, size_t);\nvoid abort (void);\n\nvoid\n__attribute__((noinline))\nbar (void *x, void *y)\n{\n  struct S { char w[8]; } *p = x, *q = y;\n  if (memcmp (p->w, \"zyxwvut\", 8) != 0)\n    abort ();\n  if (memcmp (q[0].w, \"abcdefg\", 8) != 0)\n    abort ();\n  if (memcmp (q[1].w, \"ABCDEFG\", 8) != 0)\n    abort ();\n  if (memcmp (q[2].w, \"zyxwvut\", 8) != 0)\n    abort ();\n  if (memcmp (q[3].w, \"zyxwvut\", 8) != 0)\n    abort ();\n}\n\nvoid\n__attribute__((noinline))\nfoo (void *x, int y)\n{\n  struct S { char w[y]; } *p = x, a;\n  int i;\n  a = ({ struct S b; b = p[2]; p[3] = b; });\n  bar (&a, x);\n}\n\nint\nmain (void)\n{\n  struct S { char w[8]; } p[4]\n    = { \"abcdefg\", \"ABCDEFG\", \"zyxwvut\", \"ZYXWVUT\" };\n  foo (p, 8);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071011-1.c",
    "content": "extern void abort(void);\nvoid foo(int *p)\n{\n  int x;\n  int y;\n  x = *p;\n  *p = 0;\n  y = *p;\n  if (x != y)\n    return;\n  abort ();\n}\n\nint main()\n{\n  int a = 1;\n  foo(&a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071018-1.c",
    "content": "extern void abort(void);\n\nstruct foo {\n  int rank;\n  char *name;\n};\n\nstruct mem {\n  struct foo *x[4];\n};\n\nvoid __attribute__((noinline)) bar(struct foo **f)\n{\n  *f = __builtin_malloc(sizeof(struct foo));\n}\nstruct foo * __attribute__((noinline, noclone)) foo(int rank)\n{\n  void *x = __builtin_malloc(sizeof(struct mem));\n  struct mem *as = x;\n  struct foo **upper = &as->x[rank * 8 - 5];\n  *upper = 0;\n  bar(upper);\n  return *upper;\n}\n\nint main()\n{\n  if (foo(1) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071029-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\ntypedef union\n{\n  struct\n  {\n    int f1, f2, f3, f4, f5, f6, f7, f8;\n    long int f9, f10;\n    int f11;\n  } f;\n  char s[56];\n  long int a;\n} T;\n\n__attribute__((noinline))\nvoid\ntest (T *t)\n{\n  static int i = 11;\n  if (t->f.f1 != i++)\n    abort ();\n  if (t->f.f2 || t->f.f3 || t->f.f4 || t->f.f5 || t->f.f6\n      || t->f.f7 || t->f.f8 || t->f.f9 || t->f.f10 || t->f.f11)\n    abort ();\n  if (i == 20)\n    exit (0);\n}\n\n__attribute__((noinline))\nvoid\nfoo (int i)\n{\n  T t;\nagain:\n  t = (T) { { ++i, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };\n  test (&t);\n  goto again;\n}\n\nint\nmain (void)\n{\n  T *t1, *t2;\n  int cnt = 0;\n  t1 = (T *) 0;\nloop:\n  t2 = t1;\n  t1 = & (T) { .f.f9 = cnt++ };\n  if (cnt < 3)\n    goto loop;\n  if (t1 != t2 || t1->f.f9 != 2)\n    abort ();\n  foo (10);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071030-1.c",
    "content": "/* PR target/11044 */\n/* Originator: Tim McGrath <misty-@charter.net> */\n/* Testcase contributed by Eric Botcazou <ebotcazou@libertysurf.fr> */\n\n/* Testcase copied from gcc.target/i386/loop-3.c */\n\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern void abort (void);\n\ntypedef struct\n{\n        unsigned char colormod;\n} entity_state_t;\n\ntypedef struct\n{\n        int num_entities;\n        entity_state_t *entities;\n} packet_entities_t;\n\ntypedef struct\n{\n        double senttime;\n        float ping_time;\n        packet_entities_t entities;\n} client_frame_t;\n\ntypedef enum\n{\n        cs_free,\n        cs_server,\n        cs_zombie,\n        cs_connected,\n        cs_spawned\n} sv_client_state_t;\n\ntypedef struct client_s\n{\n        sv_client_state_t state;\n        int ping;\n        client_frame_t frames[64];\n} client_t;\n\nint CalcPing (client_t *cl)\n{\n        float ping;\n        int count, i;\n        register client_frame_t *frame;\n\n        if (cl->state == cs_server)\n                return cl->ping;\n        ping = 0;\n        count = 0;\n        for (frame = cl->frames, i = 0; i < 64; i++, frame++) {\n                if (frame->ping_time > 0) {\n                        ping += frame->ping_time;\n                        count++;\n                }\n        }\n        if (!count)\n                return 9999;\n        ping /= count;\n\n        return ping * 1000;\n}\n\nint main(void)\n{\n   client_t cl;\n\n   memset(&cl, 0, sizeof(cl));\n\n   cl.frames[0].ping_time = 1.0f;\n\n   if (CalcPing(&cl) != 1000)\n     abort();\n\n   return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071108-1.c",
    "content": "/* PR tree-optimization/32575 */\n\nextern void abort (void);\n\nstruct S\n{\n  void *s1, *s2;\n  unsigned char s3, s4, s5;\n};\n\n__attribute__ ((noinline))\nvoid *\nfoo (void)\n{\n  static struct S s;\n  return &s;\n}\n\n__attribute__ ((noinline))\nvoid *\nbar ()\n{\n  return (void *) 0;\n}\n\n__attribute__ ((noinline))\nstruct S *\ntest (void *a, void *b)\n{\n  struct S *p, q;\n  p = foo ();\n  if (p == 0)\n    {\n      p = &q;\n      __builtin_memset (p, 0, sizeof (*p));\n    }\n  p->s1 = a;\n  p->s2 = b;\n  if (p == &q)\n    p = 0;\n  return p;\n}\n\nint\nmain (void)\n{\n  int a;\n  int b;\n  struct S *z = test ((void *) &a, (void *) &b);\n  if (z == 0 || z->s1 != (void *) &a || z->s2 != (void *) &b || z->s3 || z->s4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071120-1.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline,noreturn))\nvec_assert_fail (void)\n{\n    abort ();\n}\n\nstruct ggc_root_tab {\n    void *base;\n};\n\ntypedef struct deferred_access_check {} VEC_deferred_access_check_gc;\n\ntypedef struct deferred_access {\n    VEC_deferred_access_check_gc* deferred_access_checks;\n    int deferring_access_checks_kind;\n} deferred_access;\n\ntypedef struct VEC_deferred_access_base {\n    unsigned num;\n    deferred_access vec[1];\n} VEC_deferred_access_base;\n\nstatic __inline__ deferred_access *\nVEC_deferred_access_base_last (VEC_deferred_access_base *vec_)\n{\n    (void)((vec_ && vec_->num) ? 0 : (vec_assert_fail (), 0));\n    return &vec_->vec[vec_->num - 1];\n}\n\nstatic __inline__  void\nVEC_deferred_access_base_pop (VEC_deferred_access_base *vec_)\n{\n    (void)((vec_->num) ? 0 : (vec_assert_fail (), 0));\n    --vec_->num;\n}\n\nvoid __attribute__((noinline))\nperform_access_checks (VEC_deferred_access_check_gc* p)\n{\n    abort ();\n}\n\ntypedef struct VEC_deferred_access_gc {\n    VEC_deferred_access_base base;\n} VEC_deferred_access_gc;\n\nstatic VEC_deferred_access_gc *deferred_access_stack;\nstatic unsigned deferred_access_no_check;\n\nconst struct ggc_root_tab gt_pch_rs_gt_cp_semantics_h[] = {\n    {\n\t&deferred_access_no_check\n    }\n};\n\nvoid __attribute__((noinline)) pop_to_parent_deferring_access_checks (void)\n{\n    if (deferred_access_no_check)\n\tdeferred_access_no_check--;\n    else\n    {\n        VEC_deferred_access_check_gc *checks;\n        deferred_access *ptr;\n\tchecks = (VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0))->deferred_access_checks;\n        VEC_deferred_access_base_pop(deferred_access_stack ? &deferred_access_stack->base : 0);\n        ptr = VEC_deferred_access_base_last(deferred_access_stack ? &deferred_access_stack->base : 0);\n        if (ptr->deferring_access_checks_kind == 0)\n\t    perform_access_checks (checks);\n    }\n}\n\nint main()\n{\n    deferred_access_stack = __builtin_malloc (sizeof(VEC_deferred_access_gc) + sizeof(deferred_access) * 8);\n    deferred_access_stack->base.num = 2;\n    deferred_access_stack->base.vec[0].deferring_access_checks_kind = 1;\n    pop_to_parent_deferring_access_checks ();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071202-1.c",
    "content": "extern void abort (void);\nstruct T { int t; int r[8]; };\nstruct S { int a; int b; int c[6]; struct T d; };\n\n__attribute__((noinline)) void\nfoo (struct S *s)\n{\n  *s = (struct S) { s->b, s->a, { 0, 0, 0, 0, 0, 0 }, s->d };\n}\n\nint\nmain (void)\n{\n  struct S s = { 6, 12, { 1, 2, 3, 4, 5, 6 },\n\t\t { 7, { 8, 9, 10, 11, 12, 13, 14, 15 } } };\n  foo (&s);\n  if (s.a != 12 || s.b != 6\n      || s.c[0] || s.c[1] || s.c[2] || s.c[3] || s.c[4] || s.c[5])\n    abort ();\n  if (s.d.t != 7 || s.d.r[0] != 8 || s.d.r[1] != 9 || s.d.r[2] != 10\n      || s.d.r[3] != 11 || s.d.r[4] != 12 || s.d.r[5] != 13\n      || s.d.r[6] != 14 || s.d.r[7] != 15)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071205-1.c",
    "content": "/* PR middle-end/34337 */\n\nextern void abort (void);\n\nint\nfoo (int x)\n{\n  return ((x << 8) & 65535) | 255;\n}\n\nint\nmain (void)\n{\n  if (foo (0x32) != 0x32ff || foo (0x174) != 0x74ff)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071210-1.c",
    "content": "/* PR rtl-optimization/34302 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nstruct S\n{\n  int n1, n2, n3, n4;\n};\n\n__attribute__((noinline)) struct S\nfoo (int x, int y, int z)\n{\n  if (x != 10 || y != 9 || z != 8)\n    abort ();\n  struct S s = { 1, 2, 3, 4 };\n  return s;\n}\n\n__attribute__((noinline)) void **\nbar (void **u, int *v)\n{\n  void **w = u;\n  int *s = v, x, y, z;\n  void **p, **q;\n  static void *l[] = { &&lab1, &&lab1, &&lab2, &&lab3, &&lab4 };\n\n  if (!u)\n    return l;\n\n  q = *w++;\n  goto *q;\nlab2:\n  p = q;\n  q = *w++;\n  x = s[2];\n  y = s[1];\n  z = s[0];\n  s -= 1;\n  struct S r = foo (x, y, z);\n  s[3] = r.n1;\n  s[2] = r.n2;\n  s[1] = r.n3;\n  s[0] = r.n4;\n  goto *q;\nlab3:\n  p = q;\n  q = *w++;\n  s += 1;\n  s[0] = 23;\nlab1:\n  goto *q;\nlab4:\n  return 0;\n}\n\nint\nmain (void)\n{\n  void **u = bar ((void **) 0, (int *) 0);\n  void *t[] = { u[2], u[4] };\n  int s[] = { 7, 8, 9, 10, 11, 12 };\n  if (bar (t, &s[1]) != (void **) 0\n      || s[0] != 4 || s[1] != 3 || s[2] != 2 || s[3] != 1\n      || s[4] != 11 || s[5] != 12)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071211-1.c",
    "content": "extern void abort() __attribute__ ((noreturn));\n\nstruct s\n{\n  unsigned long long f1 : 40;\n#if(__SIZEOF_INT__ >= 4)\n  unsigned int f2 : 24;\n#else\n  unsigned long int f2 : 24;\n#endif\n} sv;\n\nint main()\n{\n  int f2;\n  sv.f2 = (1 << 24) - 1;\n  __asm__ volatile (\"\" : : : \"memory\");\n  ++sv.f2;\n  f2 = sv.f2;\n  if (f2 != 0)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071213-1.c",
    "content": "/* PR target/34281 */\n\n#include <stdarg.h>\n\nextern void abort (void);\n\nvoid\nh (int x, va_list ap)\n{\n  switch (x)\n    {\n    case 1:\n      if (va_arg (ap, int) != 3 || va_arg (ap, int) != 4)\n\tabort ();\n      return;\n    case 5:\n      if (va_arg (ap, int) != 9 || va_arg (ap, int) != 10)\n\tabort ();\n      return;\n    default:\n      abort ();\n    }\n}\n\nvoid\nf1 (int i, long long int j, ...)\n{\n  va_list ap;\n  va_start (ap, j);\n  h (i, ap);\n  if (i != 1 || j != 2)\n    abort ();\n  va_end (ap);\n}\n\nvoid\nf2 (int i, int j, int k, long long int l, ...)\n{\n  va_list ap;\n  va_start (ap, l);\n  h (i, ap);\n  if (i != 5 || j != 6 || k != 7 || l != 8)\n    abort ();\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  f1 (1, 2, 3, 4);\n  f2 (5, 6, 7, 8, 9, 10);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071216-1.c",
    "content": "/* PR rtl-optimization/34490 */\n\nextern void abort (void);\n\nstatic int x;\n\nint\n__attribute__((noinline))\nbar (void)\n{\n  return x;\n}\n\nint\nfoo (void)\n{\n  long int b = bar ();\n  if ((unsigned long) b < -4095L)\n    return b;\n  if (-b != 38)\n    b = -2;\n  return b + 1;\n}\n\nint\nmain (void)\n{\n  x = 26;\n  if (foo () != 26)\n    abort ();\n  x = -39;\n  if (foo () != -1)\n    abort ();\n  x = -38;\n  if (foo () != -37)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071219-1.c",
    "content": "/* PR c++/34459 */\n\nextern void abort (void);\nextern void *memset (void *s, int c, __SIZE_TYPE__ n);\n\nstruct S\n{\n  char s[25];\n};\n\nstruct S *p;\n\nvoid __attribute__((noinline,noclone))\nfoo (struct S *x, int set)\n{\n  int i;\n  for (i = 0; i < sizeof (x->s); ++i)\n    if (x->s[i] != 0)\n      abort ();\n    else if (set)\n      x->s[i] = set;\n  p = x;\n}\n\nvoid __attribute__((noinline,noclone))\ntest1 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  b = a;\n  b = b;\n  foo (&b, 0);\n}\n\nvoid __attribute__((noinline,noclone))\ntest2 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  b = a;\n  b = *p;\n  foo (&b, 0);\n}\n\nvoid __attribute__((noinline,noclone))\ntest3 (void)\n{\n  struct S a;\n  memset (&a.s, '\\0', sizeof (a.s));\n  foo (&a, 0);\n  struct S b = a;\n  foo (&b, 1);\n  *p = a;\n  *p = b;\n  foo (&b, 0);\n}\n\nint\nmain (void)\n{\n  test1 ();\n  test2 ();\n  test3 ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071220-1.c",
    "content": "/* PR tree-optimization/29484 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nvoid *__attribute__((noinline))\nbaz (void **lab)\n{\n  asm volatile (\"\" : \"+r\" (lab));\n  return *lab;\n}\n\nstatic inline\nint bar (void)\n{\n  static void *b[] = { &&addr };\n  void *p = baz (b);\n  goto *p;\naddr:\n  return 17;\n}\n\nint __attribute__((noinline))\nf1 (void)\n{\n  return bar ();\n}\n\nint __attribute__((noinline))\nf2 (void)\n{\n  return bar ();\n}\n\nint\nmain (void)\n{\n  if (f1 () != 17 || f1 () != 17 || f2 () != 17 || f2 () != 17)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20071220-2.c",
    "content": "/* PR tree-optimization/29484 */\n/* { dg-require-effective-target label_values } */\n\nextern void abort (void);\n\nvoid *__attribute__((noinline))\nbaz (void **lab)\n{\n  asm volatile (\"\" : \"+r\" (lab));\n  return *lab;\n}\n\nstatic inline\nint bar (void)\n{\n  static void *b[] = { &&addr };\n  baz (b);\naddr:\n  return 17;\n}\n\nint __attribute__((noinline))\nf1 (void)\n{\n  return bar ();\n}\n\nint __attribute__((noinline))\nf2 (void)\n{\n  return bar ();\n}\n\nint\nmain (void)\n{\n  if (f1 () != 17 || f1 () != 17 || f2 () != 17 || f2 () != 17)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080117-1.c",
    "content": "typedef struct gs_imager_state_s {\n  struct {\n    int half_width;\n    int cap;\n    float miter_limit;\n  } line_params;\n} gs_imager_state;\nstatic const gs_imager_state gstate_initial = { { 1 } };\nvoid gstate_path_memory(gs_imager_state *pgs) {\n  *pgs = gstate_initial;\n}\nint gs_state_update_overprint(void)\n{\n  return gstate_initial.line_params.half_width;\n}\n\nextern void abort (void);\nint main()\n{\n  if (gs_state_update_overprint() != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080122-1.c",
    "content": "/* PR rtl-optimization/34628 */\n/* Origin: Martin Michlmayr <tbm@cyrius.com> */\n\ntypedef unsigned short u16;\ntypedef unsigned char u8;\n\nstatic void\ndo_segfault(u8 in_buf[], const u8 out_buf[], const int len)\n{\n  int i;\n\n  for (i = 0; i < len; i++) {\n    asm(\"\");\n\n    in_buf[2*i] = (   out_buf[2*i] | out_buf[(2*i)+1]<<8  ) & 0xFF;\n\n    asm(\"\");\n\n    in_buf[(2*i)+1] =  ( out_buf[2*i] | out_buf[(2*i)+1]<<8 ) >> 8;\n\n    asm(\"\");\n  }\n}\n\nint main(int argc, char *argv[])\n{\n  u8 outbuf[32] = \"buffer     \";\n  u8 inbuf[32] = \"\\f\";\n\n  asm(\"\");\n  do_segfault(inbuf, outbuf, 12);\n  asm(\"\");\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080222-1.c",
    "content": "extern void abort (void);\n\nstruct container\n{\n  unsigned char data[1];\n};\n\nunsigned char space[6] = {1, 2, 3, 4, 5, 6};\n\nint\nfoo (struct container *p)\n{\n  return p->data[4];\n}\n\nint\nmain ()\n{\n  if (foo ((struct container *) space) != 5)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080408-1.c",
    "content": "extern void abort (void);\nint main ()\n{\n  short ssi = 126;\n  unsigned short usi = 65280;\n  int fail = !(ssi < usi);\n  if (fail)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080424-1.c",
    "content": "/* PR tree-optimization/36008 */\n\nextern void abort (void);\n\nint g[48][3][3];\n\nvoid __attribute__ ((noinline))\nbar (int x[3][3], int y[3][3])\n{\n  static int i;\n  if (x != g[i + 8] || y != g[i++])\n    abort ();\n}\n\nstatic inline void __attribute__ ((always_inline))\nfoo (int x[][3][3])\n{\n  int i;\n  for (i = 0; i < 8; i++)\n    {\n      int k = i + 8;\n      bar (x[k], x[k - 8]);\n    }\n}\n\nint\nmain ()\n{\n  foo (g);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080502-1.c",
    "content": "/* PR target/36090 */\n\nextern void abort (void);\n\nlong double __attribute__ ((noinline)) foo (long double x)\n{\n  return __builtin_signbit (x) ? 3.1415926535897932384626433832795029L : 0.0;\n}\n\nint\nmain (void)\n{\n  if (foo (-1.0L) != 3.1415926535897932384626433832795029L)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080506-1.c",
    "content": "/* PR middle-end/36137 */\nextern void abort (void);\n\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n\nint\nmain ()\n{\n  unsigned int u;\n  int i = -1;\n\n  u = MAX ((unsigned int) MAX (i, 0), 1);\n  if (u != 1)\n    abort ();\n\n  u = MIN ((unsigned int) MAX (i, 0), (unsigned int) i);\n  if (u != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080506-2.c",
    "content": "/* PR middle-end/36013 */\n\nextern void abort (void);\n\nvoid __attribute__((noinline))\nfoo (int **__restrict p, int **__restrict q)\n{\n  *p[0] = 1;\n  *q[0] = 2;\n  if (*p[0] != 2)\n    abort ();\n}\n\nint\nmain (void)\n{\n  int a;\n  int *p1 = &a, *p2 = &a;\n  foo (&p1, &p2);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080519-1.c",
    "content": "extern void abort (void);\n\ntypedef unsigned long HARD_REG_SET[2];\nHARD_REG_SET reg_class_contents[2];\n\nstruct du_chain\n{\n  struct du_chain *next_use;\n  int cl;\n};\n\nvoid __attribute__((noinline))\nmerge_overlapping_regs (HARD_REG_SET *p)\n{\n  if ((*p)[0] != -1 || (*p)[1] != -1)\n    abort ();\n}\n\nvoid __attribute__((noinline))\nregrename_optimize (struct du_chain *this)\n{\n  HARD_REG_SET this_unavailable;\n  unsigned long *scan_fp_;\n  int n_uses;\n  struct du_chain *last;\n\n  this_unavailable[0] = 0;\n  this_unavailable[1] = 0;\n\n  n_uses = 0;\n  for (last = this; last->next_use; last = last->next_use)\n    {\n      scan_fp_ = reg_class_contents[last->cl];\n      n_uses++;\n      this_unavailable[0] |= ~ scan_fp_[0];\n      this_unavailable[1] |= ~ scan_fp_[1];\n    }\n  if (n_uses < 1)\n    return;\n\n  scan_fp_ = reg_class_contents[last->cl];\n  this_unavailable[0] |= ~ scan_fp_[0];\n  this_unavailable[1] |= ~ scan_fp_[1];\n\n  merge_overlapping_regs (&this_unavailable);\n}\n\nint main()\n{\n  struct du_chain du1 = { 0, 0 };\n  struct du_chain du0 = { &du1, 1 };\n  reg_class_contents[0][0] = -1;\n  reg_class_contents[0][1] = -1;\n  reg_class_contents[1][0] = 0;\n  reg_class_contents[1][1] = 0;\n  regrename_optimize (&du0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080522-1.c",
    "content": "/* This testcase is to make sure we have i in referenced vars and that we\n   properly compute aliasing for the loads and stores.  */\n\nextern void abort (void);\n\nstatic int i;\nstatic int *p = &i;\n\nint __attribute__((noinline))\nfoo(int *q)\n{\n  *p = 1;\n  *q = 2;\n  return *p;\n}\n\nint __attribute__((noinline))\nbar(int *q)\n{\n  *q = 2;\n  *p = 1;\n  return *q;\n}\n\nint main()\n{\n  int j = 0;\n\n  if (foo(&i) != 2)\n    abort ();\n  if (bar(&i) != 1)\n    abort ();\n  if (foo(&j) != 1)\n    abort ();\n  if (j != 2)\n    abort ();\n  if (bar(&j) != 2)\n    abort ();\n  if (j != 2)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080529-1.c",
    "content": "/* PR target/36362 */\n\nextern void abort (void);\n\nint\ntest (float c)\n{\n  return !!c * 7LL == 0;\n}\n\nint\nmain (void)\n{\n  if (test (1.0f) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080604-1.c",
    "content": "struct barstruct { char const* some_string; } x;\nextern void abort (void);\nvoid __attribute__((noinline))\nfoo(void)\n{\n  if (!x.some_string)\n    abort ();\n}\nvoid baz(int b)\n{\n  struct barstruct bar;\n  struct barstruct* barptr;\n  if (b)\n    barptr = &bar;\n  else\n    {\n      barptr = &x + 1;\n      barptr = barptr - 1;\n    }\n  barptr->some_string = \"Everything OK\";\n  foo();\n  barptr->some_string = \"Everything OK\";\n}\nint main()\n{\n  x.some_string = (void *)0;\n  baz(0);\n  if (!x.some_string)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080719-1.c",
    "content": "typedef unsigned int u32;\n\nstatic const u32 deadfish = 0xdeadf155;\n\nstatic const u32 cfb_tab8_be[] = {\n    0x00000000,0x000000ff,0x0000ff00,0x0000ffff,\n    0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,\n    0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,\n    0xffff0000,0xffff00ff,0xffffff00,0xffffffff\n};\n\nstatic const u32 cfb_tab8_le[] = {\n    0x00000000,0xff000000,0x00ff0000,0xffff0000,\n    0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,\n    0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,\n    0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff\n};\n\nstatic const u32 cfb_tab16_be[] = {\n    0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff\n};\n\nstatic const u32 cfb_tab16_le[] = {\n    0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff\n};\n\nstatic const u32 cfb_tab32[] = {\n 0x00000000, 0xffffffff\n};\n\n\n\n\n\n\nconst u32 *xxx(int bpp)\n{\n const u32 *tab;\n\nif (0) return &deadfish;\n\n switch (bpp) {\n case 8:\n  tab = cfb_tab8_be;\n  break;\n case 16:\n  tab = cfb_tab16_be;\n  break;\n case 32:\n default:\n  tab = cfb_tab32;\n  break;\n }\n\n return tab;\n}\n\nint main(void)\n{\n  const u32 *a = xxx(8);\n  int b = a[0];\n  if (b != cfb_tab8_be[0])\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20080813-1.c",
    "content": "/* PR middle-end/37103 */\n\nextern void abort (void);\n\nvoid\nfoo (unsigned short x)\n{\n  signed char y = -1;\n  if (x == y)\n    abort ();\n}\n\nvoid\nbar (unsigned short x)\n{\n  unsigned char y = -1;\n  if (x == y)\n    abort ();\n}\n\nint\nmain (void)\n{\n  if (sizeof (int) == sizeof (short))\n    return 0;\n  foo (-1);\n  if (sizeof (short) > 1)\n    bar (-1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20081103-1.c",
    "content": "struct S { char c; char arr[4]; float f; };\n\nchar A[4] = { '1', '2', '3', '4' };\n\nvoid foo (struct S s)\n{\n  if (__builtin_memcmp (s.arr, A, 4))\n    __builtin_abort ();\n}\n\nint main (void)\n{\n  struct S s;\n  __builtin_memcpy (s.arr, A, 4);\n  foo (s);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20081112-1.c",
    "content": "#include <limits.h>\n\nextern void abort (void);\n\nstatic __attribute__((noinline)) void foo (int a)\n{\n  int b = (a - 1) + INT_MIN;\n\n  if (b != INT_MIN)\n    abort ();\n}\n\nint main (void)\n{\n  foo (1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20081117-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort (void);\n\nstruct s\n{\n  unsigned long long a:16;\n  unsigned long long b:32;\n  unsigned long long c:16;\n};\n\n__attribute__ ((noinline)) unsigned\nf (struct s s, unsigned i)\n{\n  return s.b == i;\n}\n\nstruct s s = { 1, 0x87654321u, 2};\n\nint\nmain ()\n{\n  if (!f (s, 0x87654321u))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20081218-1.c",
    "content": "struct A { int i, j; char pad[512]; } a;\n\nint __attribute__((noinline))\nfoo (void)\n{\n  __builtin_memset (&a, 0x26, sizeof a);\n  return a.i;\n}\n\nvoid __attribute__((noinline))\nbar (void)\n{\n  __builtin_memset (&a, 0x36, sizeof a);\n  a.i = 0x36363636;\n  a.j = 0x36373636;\n}\n\nint\nmain (void)\n{\n  int i;\n  if (sizeof (int) != 4 || __CHAR_BIT__ != 8)\n    return 0;\n\n  if (foo () != 0x26262626)\n    __builtin_abort ();\n  for (i = 0; i < sizeof a; i++)\n    if (((char *)&a)[i] != 0x26)\n      __builtin_abort ();\n\n  bar ();\n  if (a.j != 0x36373636)\n    __builtin_abort ();\n  a.j = 0x36363636;\n  for (i = 0; i < sizeof a; i++)\n    if (((char *)&a)[i] != 0x36)\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090113-1.c",
    "content": "typedef struct descriptor_dimension\n{\n  int stride;\n  int lbound;\n  int ubound;\n} descriptor_dimension;\ntypedef struct {\n    int *data;\n    int dtype;\n    descriptor_dimension dim[7];\n} gfc_array_i4;\n\nvoid\nmsum_i4 (gfc_array_i4 * const retarray,\n\t gfc_array_i4 * const array,\n\t const int * const pdim)\n{\n  int count[7];\n  int extent[7];\n  int * dest;\n  const int * base;\n  int dim;\n  int n;\n  int len;\n\n  dim = (*pdim) - 1;\n  len = array->dim[dim].ubound + 1 - array->dim[dim].lbound;\n\n  for (n = 0; n < dim; n++)\n    {\n      extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound;\n      count[n] = 0;\n    }\n\n  dest = retarray->data;\n  base = array->data;\n\n  do\n    {\n      int result = 0;\n\n      for (n = 0; n < len; n++, base++)\n\tresult += *base;\n      *dest = result;\n\n      count[0]++;\n      dest += 1;\n    }\n  while (count[0] != extent[0]);\n}\n\nint main()\n{\n  int rdata[3];\n  int adata[9];\n  gfc_array_i4 retarray = { rdata, 265, { { 1, 1, 3 } } };\n  gfc_array_i4 array = { adata, 266, { { 1, 1, 3 }, { 3, 1, 3 } } };\n  int dim = 2;\n  msum_i4 (&retarray, &array, &dim);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090113-2.c",
    "content": "struct obstack {};\nstruct bitmap_head_def;\ntypedef struct bitmap_head_def *bitmap;\ntypedef const struct bitmap_head_def *const_bitmap;\ntypedef unsigned long BITMAP_WORD;\ntypedef struct bitmap_obstack\n{\n  struct bitmap_element_def *elements;\n  struct bitmap_head_def *heads;\n  struct obstack obstack;\n} bitmap_obstack;\ntypedef struct bitmap_element_def\n{\n  struct bitmap_element_def *next;\n  struct bitmap_element_def *prev;\n  unsigned int indx;\n  BITMAP_WORD bits[((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u))];\n} bitmap_element;\n\nstruct bitmap_descriptor;\n\ntypedef struct bitmap_head_def {\n    bitmap_element *first;\n    bitmap_element *current;\n    unsigned int indx;\n    bitmap_obstack *obstack;\n} bitmap_head;\n\nbitmap_element bitmap_zero_bits;\n\ntypedef struct\n{\n  bitmap_element *elt1;\n  bitmap_element *elt2;\n  unsigned word_no;\n  BITMAP_WORD bits;\n} bitmap_iterator;\n\nstatic void __attribute__((noinline))\nbmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,\n\t\t   unsigned start_bit, unsigned *bit_no)\n{\n  bi->elt1 = map->first;\n  bi->elt2 = ((void *)0);\n\n  while (1)\n    {\n      if (!bi->elt1)\n\t{\n\t  bi->elt1 = &bitmap_zero_bits;\n\t  break;\n\t}\n\n      if (bi->elt1->indx >= start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))\n\tbreak;\n      bi->elt1 = bi->elt1->next;\n    }\n\n  if (bi->elt1->indx != start_bit / (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u)))\n    start_bit = bi->elt1->indx * (((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u)) * (8 * 8 * 1u));\n\n  bi->word_no = start_bit / (8 * 8 * 1u) % ((128 + (8 * 8 * 1u) - 1) / (8 * 8 * 1u));\n  bi->bits = bi->elt1->bits[bi->word_no];\n  bi->bits >>= start_bit % (8 * 8 * 1u);\n\n  start_bit += !bi->bits;\n\n  *bit_no = start_bit;\n}\n\nstatic void __attribute__((noinline))\nbmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)\n{\n  bi->bits >>= 1;\n  *bit_no += 1;\n}\n\nstatic unsigned char __attribute__((noinline))\nbmp_iter_set_tail (bitmap_iterator *bi, unsigned *bit_no)\n{\n  while (!(bi->bits & 1))\n    {\n      bi->bits >>= 1;\n      *bit_no += 1;\n    }\n  return 1;\n}\n\nstatic __inline__ unsigned char\nbmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)\n{\n  unsigned bno = *bit_no;\n  BITMAP_WORD bits = bi->bits;\n  bitmap_element *elt1;\n\n  if (bits)\n    {\n      while (!(bits & 1))\n\t{\n\t  bits >>= 1;\n\t  bno += 1;\n\t}\n      *bit_no = bno;\n      return 1;\n    }\n\n  *bit_no = ((bno + 64 - 1) / 64 * 64);\n  bi->word_no++;\n\n  elt1 = bi->elt1;\n  while (1)\n    {\n      while (bi->word_no != 2)\n\t{\n\t  bi->bits = elt1->bits[bi->word_no];\n\t  if (bi->bits)\n\t    {\n\t      bi->elt1 = elt1;\n\t      return bmp_iter_set_tail (bi, bit_no);\n\t    }\n\t  *bit_no += 64;\n\t  bi->word_no++;\n\t}\n\n      elt1 = elt1->next;\n      if (!elt1)\n\t{\n\t  bi->elt1 = elt1;\n\t  return 0;\n\t}\n      *bit_no = elt1->indx * (2 * 64);\n      bi->word_no = 0;\n    }\n}\n\nextern void abort (void);\n\nstatic void __attribute__((noinline)) catchme(int i)\n{\n  if (i != 0 && i != 64)\n    abort ();\n}\nstatic void __attribute__((noinline)) foobar (bitmap_head *chain)\n{\n  bitmap_iterator rsi;\n  unsigned int regno;\n  for (bmp_iter_set_init (&(rsi), (chain), (0), &(regno));\n       bmp_iter_set (&(rsi), &(regno));\n       bmp_iter_next (&(rsi), &(regno)))\n    catchme(regno);\n}\n\nint main()\n{\n  bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };\n  bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };\n  foobar (&live_throughout);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090113-3.c",
    "content": "struct obstack {};\nstruct bitmap_head_def;\ntypedef struct bitmap_head_def *bitmap;\ntypedef const struct bitmap_head_def *const_bitmap;\ntypedef unsigned long BITMAP_WORD;\n\ntypedef struct bitmap_obstack\n{\n  struct bitmap_element_def *elements;\n  struct bitmap_head_def *heads;\n  struct obstack obstack;\n} bitmap_obstack;\ntypedef struct bitmap_element_def\n{\n  struct bitmap_element_def *next;\n  struct bitmap_element_def *prev;\n  unsigned int indx;\n  BITMAP_WORD bits[(2)];\n} bitmap_element;\n\nstruct bitmap_descriptor;\n\ntypedef struct bitmap_head_def {\n    bitmap_element *first;\n    bitmap_element *current;\n    unsigned int indx;\n    bitmap_obstack *obstack;\n} bitmap_head;\n\nbitmap_element bitmap_zero_bits;\n\ntypedef struct\n{\n  bitmap_element *elt1;\n  bitmap_element *elt2;\n  unsigned word_no;\n  BITMAP_WORD bits;\n} bitmap_iterator;\n\nstatic __attribute__((noinline)) void\nbmp_iter_set_init (bitmap_iterator *bi, const_bitmap map,\n\t\t   unsigned start_bit, unsigned *bit_no)\n{\n  bi->elt1 = map->first;\n  bi->elt2 = ((void *)0);\n\n  while (1)\n    {\n      if (!bi->elt1)\n\t{\n\t  bi->elt1 = &bitmap_zero_bits;\n\t  break;\n\t}\n\n      if (bi->elt1->indx >= start_bit / (128u))\n\tbreak;\n      bi->elt1 = bi->elt1->next;\n    }\n\n  if (bi->elt1->indx != start_bit / (128u))\n    start_bit = bi->elt1->indx * (128u);\n\n  bi->word_no = start_bit / 64u % (2);\n  bi->bits = bi->elt1->bits[bi->word_no];\n  bi->bits >>= start_bit % 64u;\n\n  start_bit += !bi->bits;\n\n  *bit_no = start_bit;\n}\n\nstatic __inline__ __attribute__((always_inline)) void\nbmp_iter_next (bitmap_iterator *bi, unsigned *bit_no)\n{\n  bi->bits >>= 1;\n  *bit_no += 1;\n}\n\nstatic __inline__ __attribute__((always_inline)) unsigned char\nbmp_iter_set (bitmap_iterator *bi, unsigned *bit_no)\n{\n  if (bi->bits)\n    {\n      while (!(bi->bits & 1))\n\t{\n\t  bi->bits >>= 1;\n\t  *bit_no += 1;\n\t}\n      return 1;\n    }\n\n  *bit_no = ((*bit_no + 64u - 1) / 64u * 64u);\n  bi->word_no++;\n\n  while (1)\n    {\n      while (bi->word_no != (2))\n\t{\n\t  bi->bits = bi->elt1->bits[bi->word_no];\n\t  if (bi->bits)\n\t    {\n\t      while (!(bi->bits & 1))\n\t\t{\n\t\t  bi->bits >>= 1;\n\t\t  *bit_no += 1;\n\t\t}\n\t      return 1;\n\t    }\n\t  *bit_no += 64u;\n\t  bi->word_no++;\n\t}\n\n      bi->elt1 = bi->elt1->next;\n      if (!bi->elt1)\n\treturn 0;\n      *bit_no = bi->elt1->indx * (128u);\n      bi->word_no = 0;\n    }\n}\n\nstatic void __attribute__((noinline))\nfoobar (bitmap_head *live_throughout)\n{\n  bitmap_iterator rsi;\n  unsigned int regno;\n  for (bmp_iter_set_init (&(rsi), (live_throughout), (0), &(regno));\n       bmp_iter_set (&(rsi), &(regno));\n       bmp_iter_next (&(rsi), &(regno)))\n    ;\n}\nint main()\n{\n  bitmap_element elem = { (void *)0, (void *)0, 0, { 1, 1 } };\n  bitmap_head live_throughout = { &elem, &elem, 0, (void *)0 };\n  foobar (&live_throughout);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090207-1.c",
    "content": "int foo(int i)\n{\n  int a[32];\n  a[1] = 3;\n  a[0] = 1;\n  a[i] = 2;\n  return a[0];\n}\nextern void abort (void);\nint main()\n{\n  if (foo (0) != 2\n      || foo (1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090219-1.c",
    "content": "/* On ARM, BAR used to get a bogus number in E due to stack\n   misalignment.  */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfoo (void)\n{\n  int f = 0;\n\n  void bar (int a, int b, int c, int d, int e)\n    {\n      if (e != 0)\n\t{\n\t  f = 1;\n\t  abort ();\n\t}\n    }\n\n  bar (0, 0, 0, 0, 0);\n}\n\nint\nmain (void)\n{\n  foo ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090527-1.c",
    "content": "typedef enum { POSITION_ASIS, POSITION_UNSPECIFIED } unit_position;\n\ntypedef enum { STATUS_UNKNOWN, STATUS_UNSPECIFIED } unit_status;\n\ntypedef struct\n{\n  unit_position position;\n  unit_status status;\n} unit_flags;\n\nextern void abort (void);\n\nvoid\nnew_unit (unit_flags * flags)\n{\n  if (flags->status == STATUS_UNSPECIFIED)\n    flags->status = STATUS_UNKNOWN;\n\n  if (flags->position == POSITION_UNSPECIFIED)\n    flags->position = POSITION_ASIS;\n\n  switch (flags->status)\n    {\n    case STATUS_UNKNOWN:\n      break;\n\n    default:\n      abort ();\n    }\n}\n\nint main()\n{\n  unit_flags f;\n  f.status = STATUS_UNSPECIFIED;\n  new_unit (&f);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090623-1.c",
    "content": "int * __restrict__ x;\n\nint foo (int y)\n{\n  *x = y;\n  return *x;\n}\n\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  x = &i;\n  if (foo(1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090711-1.c",
    "content": "/* Used to be miscompiled at -O0 due to incorrect choice of sign extension\n   vs. zero extension.  __attribute__ ((noinline)) added to try to make it\n   fail at higher optimization levels too.  */\n\nextern void abort (void);\n\nlong long __attribute__ ((noinline))\ndiv (long long val)\n{\n  return val / 32768;\n}\n\nint main (void)\n{\n  long long d1 = -990000000;\n  long long d2 = div(d1);\n  if (d2 != -30212)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20090814-1.c",
    "content": "int __attribute__((noinline))\nbar (int *a)\n{\n  return *a;\n}\nint i;\nint __attribute__((noinline))\nfoo (int (*a)[2])\n{\n  return bar (&(*a)[i]);\n}\n\nextern void abort (void);\nint a[2];\nint main()\n{\n  a[0] = -1;\n  a[1] = 42;\n  i = 1;\n  if (foo (&a) != 42)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20091229-1.c",
    "content": "long long foo(long long v) { return v / -0x080000000LL; }\nint main(int argc, char **argv) { if (foo(0x080000000LL) != -1) abort(); exit (0); }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100209-1.c",
    "content": "int bar(int foo)\n{\n  return (int)(((unsigned long long)(long long)foo) / 8);\n}\nextern void abort (void);\nint main()\n{\n  if (sizeof (long long) > sizeof (int)\n      && bar(-1) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100316-1.c",
    "content": "struct Foo {\n  int i;\n  unsigned precision : 10;\n  unsigned blah : 3;\n} f;\n\nint __attribute__((noinline,noclone))\nfoo (struct Foo *p)\n{\n  struct Foo *q = p;\n  return (*q).precision;\n}\n\nextern void abort (void);\n\nint main()\n{\n  f.i = -1;\n  f.precision = 0;\n  f.blah = -1;\n  if (foo (&f) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100416-1.c",
    "content": "void abort(void);\n\nint\nmovegt(int x, int y, long long a)\n{\n  int i;\n  int ret = 0;\n  for (i = 0; i < y; i++)\n    {\n      if (a >= (long long) 0xf000000000000000LL)\n\tret = x;\n      else\n\tret = y;\n    }\n  return ret;\n}\n\nstruct test\n{\n  long long val;\n  int ret;\n} tests[] = {\n  { 0xf000000000000000LL, -1 },\n  { 0xefffffffffffffffLL, 1 },\n  { 0xf000000000000001LL, -1 },\n  { 0x0000000000000000LL, -1 },\n  { 0x8000000000000000LL, 1 },\n};\n\nint\nmain()\n{\n  int i;\n  for (i = 0; i < sizeof (tests) / sizeof (tests[0]); i++)\n    {\n      if (movegt (-1, 1, tests[i].val) != tests[i].ret)\n\tabort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100430-1.c",
    "content": "/* This used to generate unaligned accesses at -O2 because of IVOPTS.  */\n\nstruct packed_struct\n{\n  struct packed_struct1\n  {\n    unsigned char cc11;\n    unsigned char cc12;\n  } __attribute__ ((packed)) pst1;\n  struct packed_struct2\n  {\n    unsigned char cc21;\n    unsigned char cc22;\n    unsigned short ss[104];\n    unsigned char cc23[13];\n  } __attribute__ ((packed)) pst2[4];\n} __attribute__ ((packed));\n\ntypedef struct\n{\n  int ii;\n  struct packed_struct buf;\n} info_t;\n\nstatic unsigned short g;\n\nstatic void __attribute__((noinline))\ndummy (unsigned short s)\n{\n  g = s;\n}\n\nstatic int\nfoo (info_t *info)\n{\n  int i, j;\n\n  for (i = 0; i < info->buf.pst1.cc11; i++)\n    for (j = 0; j < info->buf.pst2[i].cc22; j++)\n      dummy (info->buf.pst2[i].ss[j]);\n\n  return 0;\n}\n\nint main(void)\n{\n  info_t info;\n  info.buf.pst1.cc11 = 2;\n  info.buf.pst2[0].cc22 = info.buf.pst2[1].cc22 = 8;\n  return foo (&info);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100708-1.c",
    "content": "/* PR middle-end/44843 */\n/* Verify that we don't use the alignment of struct S for inner accesses.  */\n\nstruct S\n{\n  double for_alignment;\n  struct { int x, y, z; } a[16];\n};\n\nvoid f(struct S *s) __attribute__((noinline));\n\nvoid f(struct S *s)\n{\n  unsigned int i;\n\n  for (i = 0; i < 16; ++i)\n    {\n      s->a[i].x = 0;\n      s->a[i].y = 0;\n      s->a[i].z = 0;\n    }\n}\n\nint main (void)\n{\n  struct S s;\n  f (&s);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100805-1.c",
    "content": "unsigned int foo (unsigned int a, unsigned int b)\n{\n  unsigned i;\n  a = a & 1;\n  for (i = 0; i < b; ++i)\n    a = a << 1 | a >> (sizeof (unsigned int) * 8 - 1);\n  return a;\n}\nextern void abort (void);\nint main()\n{\n  if (foo (1, sizeof (unsigned int) * 8 + 1) != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20100827-1.c",
    "content": "extern void abort (void);\nint __attribute__((noinline,noclone))\nfoo (char *p)\n{\n  int h = 0;\n  do\n    {\n      if (*p == '\\0')\n\tbreak;\n      ++h;\n      if (p == 0)\n\tabort ();\n      ++p;\n    }\n  while (1);\n  return h;\n}\nint main()\n{\n  if (foo(\"a\") != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20101011-1.c",
    "content": "/* { dg-options \"-fnon-call-exceptions\" } */\n/* With -fnon-call-exceptions 0 / 0 should not be eliminated.  */\n\n#ifdef SIGNAL_SUPPRESS\n# define DO_TEST 0\n#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)\n  /* On PPC division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__riscv)\n  /* On RISC-V division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__SPU__)\n  /* On SPU division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__sh__)\n  /* On SH division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__v850__)\n  /* On V850 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__MSP430__)\n  /* On MSP430 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__RL78__)\n  /* On RL78 division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__RX__)\n  /* On RX division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__aarch64__)\n  /* On AArch64 integer division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__TMS320C6X__)\n  /* On TI C6X division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__VISIUM__)\n  /* On Visium division by zero does not trap.  */\n# define DO_TEST 0\n#elif defined (__mips__) && !defined(__linux__)\n  /* MIPS divisions do trap by default, but libgloss targets do not\n     intercept the trap and raise a SIGFPE.  The same is probably\n     true of other bare-metal environments, so restrict the test to\n     systems that use the Linux kernel.  */\n# define DO_TEST 0\n#elif defined (__mips16) && defined(__linux__)\n  /* Not all Linux kernels deal correctly the breakpoints generated by\n     MIPS16 divisions by zero.  They show up as a SIGTRAP instead.  */\n# define DO_TEST 0\n#elif defined (__MICROBLAZE__)\n/* We cannot rely on division by zero generating a trap. */\n# define DO_TEST 0\n#elif defined (__epiphany__)\n  /* Epiphany does not have hardware division, and the software implementation\n     has truly undefined behavior for division by 0.  */\n# define DO_TEST 0\n#elif defined (__m68k__) && !defined(__linux__)\n  /* Attempting to trap division-by-zero in this way isn't likely to work on \n     bare-metal m68k systems.  */\n# define DO_TEST 0\n#elif defined (__CRIS__)\n  /* No SIGFPE for CRIS integer division.  */\n# define DO_TEST 0\n#elif defined (__MMIX__)\n/* By default we emit a sequence with DIVU, which \"never signals an\n   exceptional condition, even when dividing by zero\".  */\n# define DO_TEST 0\n#elif defined (__arc__)\n  /* No SIGFPE for ARC integer division.  */\n# define DO_TEST 0\n#elif defined (__arm__) && defined (__ARM_EABI__)\n# ifdef __ARM_ARCH_EXT_IDIV__\n  /* Hardware division instructions may not trap, and handle trapping\n     differently anyway.  Skip the test if we have those instructions.  */\n#  define DO_TEST 0\n# else\n#  include <signal.h>\n  /* ARM division-by-zero behavior is to call a helper function, which\n     can do several different things, depending on requirements.  Emulate\n     the behavior of other targets here by raising SIGFPE.  */\nint __attribute__((used))\n__aeabi_idiv0 (int return_value)\n{\n  raise (SIGFPE);\n  return return_value;\n}\n#  define DO_TEST 1\n# endif\n#elif defined (__nios2__)\n  /* Nios II requires both hardware support and user configuration to\n     raise an exception on divide by zero.  */\n# define DO_TEST 0\n#elif defined (__nvptx__)\n/* There isn't even a signal function.  */\n# define DO_TEST 0\n#else\n# define DO_TEST 1\n#endif\n\nextern void abort (void);\nextern void exit (int);\n\n#if DO_TEST\n\n#include <signal.h>\n\nvoid\nsigfpe (int signum __attribute__ ((unused)))\n{\n  exit (0);\n}\n\n#endif\n\n/* When optimizing, the compiler is smart enough to constant fold the\n   static unset variables i and j to produce 0 / 0, but it can't\n   eliminate the assignment to the global k.  */\nstatic int i;\nstatic int j;\nint k __attribute__ ((used));\n\nint\nmain ()\n{\n#if DO_TEST\n  signal (SIGFPE, sigfpe);\n  k = i / j;\n  abort ();\n#else\n  exit (0);\n#endif\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20101013-1.c",
    "content": "/* PR rtl-optimization/45912 */\n\nextern void abort (void);\n\nstatic void* __attribute__((noinline,noclone))\nget_addr_base_and_unit_offset (void *base, long long *i)\n{\n  *i = 0;\n  return base;\n}\n\nstatic void* __attribute__((noinline,noclone))\nbuild_int_cst (void *base, long long offset)\n{\n  if (offset != 4)\n    abort ();\n\n  return base;\n}\n\nstatic void* __attribute__((noinline,noclone))\nbuild_ref_for_offset (void *base, long long offset)\n{\n  long long base_offset;\n  base = get_addr_base_and_unit_offset (base, &base_offset);\n  return build_int_cst (base, base_offset + offset / 8);\n}\n\nint\nmain (void)\n{\n  void *ret = build_ref_for_offset ((void *)0, 32);\n  if (ret != (void *)0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20101025-1.c",
    "content": "static int g_7;\nstatic int *volatile g_6 = &g_7;\nint g_3;\n\nstatic int f1 (int *p_58)\n{\n    return *p_58;\n}\n\nvoid f2 (int i) __attribute__ ((noinline));\nvoid f2 (int i)\n{\n  g_3 = i;\n}\n\nint f3 (void) __attribute__ ((noinline));\nint f3 (void)\n{\n    *g_6 = 1;\n    f2 (f1 (&g_7));\n    return 0;\n}\n\nint main ()\n{\n  f3 ();\n  if (g_3 != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20110418-1.c",
    "content": "typedef unsigned long long uint64_t;\nvoid f(uint64_t *a, uint64_t aa) __attribute__((noinline));\nvoid f(uint64_t *a, uint64_t aa)\n{\n  uint64_t new_value = aa;\n  uint64_t old_value = *a;\n  int bit_size = 32;\n    uint64_t mask = (uint64_t)(unsigned)(-1);\n    uint64_t tmp = old_value & mask;\n    new_value &= mask;\n    /* On overflow we need to add 1 in the upper bits */\n    if (tmp > new_value)\n        new_value += 1ull<<bit_size;\n    /* Add in the upper bits from the old value */\n    new_value += old_value & ~mask;\n    *a = new_value;\n}\nint main(void)\n{\n  uint64_t value, new_value, old_value;\n  value = 0x100000001;\n  old_value = value;\n  new_value = (value+1)&(uint64_t)(unsigned)(-1);\n  f(&value, new_value);\n  if (value != old_value+1)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20111208-1.c",
    "content": "/* PR tree-optimization/51315 */\n/* Reported by Jurij Smakov <jurij@wooyd.org> */\n\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memcpy (void *__restrict __dest,\n       __const void *__restrict __src, size_t __n)\n     __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));\n\nextern size_t strlen (__const char *__s)\n     __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\n\ntypedef __INT16_TYPE__ int16_t;\ntypedef __INT32_TYPE__ int32_t;\n\nextern void abort (void);\n\nint a;\n\nstatic void __attribute__ ((noinline,noclone))\ndo_something (int item)\n{\n  a = item;\n}\n\nint\npack_unpack (char *s, char *p)\n{\n  char *send, *pend;\n  char type;\n  int integer_size;\n\n  send = s + strlen (s);\n  pend = p + strlen (p);\n\n  while (p < pend)\n    {\n      type = *p++;\n\n      switch (type)\n {\n case 's':\n   integer_size = 2;\n   goto unpack_integer;\n\n case 'l':\n   integer_size = 4;\n   goto unpack_integer;\n\n unpack_integer:\n   switch (integer_size)\n     {\n     case 2:\n       {\n  union\n  {\n    int16_t i;\n    char a[sizeof (int16_t)];\n  }\n  v;\n  memcpy (v.a, s, sizeof (int16_t));\n  s += sizeof (int16_t);\n  do_something (v.i);\n       }\n       break;\n\n     case 4:\n       {\n  union\n  {\n    int32_t i;\n    char a[sizeof (int32_t)];\n  }\n  v;\n  memcpy (v.a, s, sizeof (int32_t));\n  s += sizeof (int32_t);\n  do_something (v.i);\n       }\n       break;\n     }\n   break;\n }\n    }\n  return (int) *s;\n}\n\nint\nmain (void)\n{\n  int n = pack_unpack (\"\\200\\001\\377\\376\\035\\300\", \"sl\");\n  if (n != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20111212-1.c",
    "content": "/* PR tree-optimization/50569 */\n/* Reported by Paul Koning <pkoning@gcc.gnu.org> */\n/* Reduced testcase by Mikael Pettersson <mikpe@it.uu.se> */\n\nstruct event {\n    struct {\n\tunsigned int sec;\n    } sent __attribute__((packed));\n};\n\nvoid __attribute__((noinline,noclone)) frob_entry(char *buf)\n{\n    struct event event;\n\n    __builtin_memcpy(&event, buf, sizeof(event));\n    if (event.sent.sec < 64) {\n\tevent.sent.sec = -1U;\n\t__builtin_memcpy(buf, &event, sizeof(event));\n    }\n}\n\nint main(void)\n{\n    union {\n\tchar buf[1 + sizeof(struct event)];\n\tint align;\n    } u;\n\n    __builtin_memset(&u, 0, sizeof u);\n\n    frob_entry(&u.buf[1]);\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20111227-1.c",
    "content": "/* PR rtl-optimization/51667 */\n/* Testcase by Uros Bizjak <ubizjak@gmail.com> */\n\nextern void abort (void);\n\nvoid __attribute__((noinline,noclone))\nbar (int a)\n{\n  if (a != -1)\n    abort ();\n}\n\nvoid __attribute__((noinline,noclone))\nfoo (short *a, int t)\n{\n  short r = *a;\n\n  if (t)\n    bar ((unsigned short) r);\n  else\n    bar ((signed short) r);\n}\n\nshort v = -1;\n\nint main(void)\n{\n  foo (&v, 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120105-1.c",
    "content": "struct __attribute__((packed)) S\n{\n  int a, b, c;\n};\n\nstatic int __attribute__ ((noinline,noclone))\nextract(const char *p)\n{\n  struct S s;\n  __builtin_memcpy (&s, p, sizeof(struct S));\n  return s.a;\n}\n\nvolatile int i;\n\nint main (void)\n{\n  char p[sizeof(struct S) + 1];\n\n  __builtin_memset (p, 0, sizeof(struct S) + 1);\n  i = extract (p + 1);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120111-1.c",
    "content": "#include <stdlib.h>\n#include <stdint.h>\n\nuint32_t f0a (uint64_t arg2) __attribute__((noinline));\n\nuint32_t\nf0a (uint64_t arg)\n{\n  return ~((unsigned) (arg > -3));\n}\n\nint main() {\n  uint32_t r1;\n  r1 = f0a (12094370573988097329ULL);\n  if (r1 != ~0U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120207-1.c",
    "content": "/* PR middle-end/51994 */\n/* Testcase by Uros Bizjak <ubizjak@gmail.com> */\n\nextern char *strcpy (char *, const char *);\nextern void abort (void);\n\nchar __attribute__((noinline))\ntest (int a)\n{\n  char buf[16];\n  char *output = buf;\n\n  strcpy (&buf[0], \"0123456789\");\n\n  output += a;\n  output -= 1;\n\n  return output[0];\n}\n\nint main ()\n{\n  if (test (2) != '1')\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120427-1.c",
    "content": "typedef struct sreal\n{\n  unsigned sig;\t\t/* Significant.  */\n  int exp;\t\t/* Exponent.  */\n} sreal;\n\nsreal_compare (sreal *a, sreal *b)\n{\n  if (a->exp > b->exp)\n    return 1;\n  if (a->exp < b->exp)\n    return -1;\n  if (a->sig > b->sig)\n    return 1;\n  return -(a->sig < b->sig);\n}\n\nsreal a[] = {\n   { 0, 0 },\n   { 1, 0 },\n   { 0, 1 },\n   { 1, 1 }\n};\n\nint main()\n{\n  int i, j;\n  for (i = 0; i <= 3; i++) {\n    for (j = 0; j < 3; j++) {\n      if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();\n      if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();\n      if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120427-2.c",
    "content": "typedef struct sreal\n{\n  unsigned sig;\t\t/* Significant.  */\n  int exp;\t\t/* Exponent.  */\n} sreal;\n\nsreal_compare (sreal *a, sreal *b)\n{\n  if (a->exp > b->exp)\n    return 1;\n  if (a->exp < b->exp)\n    return -1;\n  if (a->sig > b->sig)\n    return 1;\n  if (a->sig < b->sig)\n    return -1;\n  return 0;\n}\n\nsreal a[] = {\n   { 0, 0 },\n   { 1, 0 },\n   { 0, 1 },\n   { 1, 1 }\n};\n\nint main()\n{\n  int i, j;\n  for (i = 0; i <= 3; i++) {\n    for (j = 0; j < 3; j++) {\n      if (i < j && sreal_compare(&a[i], &a[j]) != -1) abort();\n      if (i == j && sreal_compare(&a[i], &a[j]) != 0) abort();\n      if (i > j && sreal_compare(&a[i], &a[j]) != 1) abort();\n    }\n  }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120615-1.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline,noclone))\n     test1(int i)\n{\n  if (i == 12)\n    return;\n  if (i != 17)\n    {\n      if (i == 15)\n\treturn;\n      abort ();\n    }\n}\n\nint main() { test1 (15); return 0; }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120808-1.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nvolatile int i;\nunsigned char *volatile cp;\nunsigned char d[32] = { 0 };\n\nint\nmain (void)\n{\n  unsigned char c[32] = { 0 };\n  unsigned char *p = d + i;\n  int j;\n  for (j = 0; j < 30; j++)\n    {\n      int x = 0xff;\n      int y = *++p;\n      switch (j)\n\t{\n\tcase 1: x ^= 2; break;\n\tcase 2: x ^= 4; break;\n\tcase 25: x ^= 1; break;\n\tdefault: break;\n\t}\n      c[j] = y | x;\n      cp = p;\n    }\n  if (c[0] != 0xff\n      || c[1] != 0xfd\n      || c[2] != 0xfb\n      || c[3] != 0xff\n      || c[4] != 0xff\n      || c[25] != 0xfe\n      || cp != d + 30)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120817-1.c",
    "content": "typedef unsigned long long u64;\nunsigned long foo = 0;\nu64 f() __attribute__((noinline));\n\nu64 f() {\n  return ((u64)40) + ((u64) 24) * (int)(foo - 1);\n}\n\nint main ()\n{\n  if (f () != 16)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20120919-1.c",
    "content": "/* PR rtl-optimization/54290 */\n/* Testcase by Eric Volk <eriksnga@gmail.com> */\n/* { dg-require-effective-target int32plus } */\n\ndouble vd[2] = {1., 0.};\nint vi[2] = {1234567890, 0};\ndouble *pd = vd;\nint *pi = vi;\n\nextern void abort(void);\n\nvoid init (int *n, int *dummy) __attribute__ ((noinline,noclone));\n\nvoid init (int *n, int *dummy)\n{\n  if(0 == n) dummy[0] = 0;\n}\n\nint main (void)\n{\n  int dummy[1532];\n  int i = -1, n = 1, s = 0;\n  init (&n, dummy);\n  while (i < n) {\n    if (i == 0) {\n      if (pd[i] > 0) {\n        if (pi[i] > 0) {\n          s += pi[i];\n        }\n      }\n      pd[i] = pi[i];\n    }\n    ++i;\n  }\n  if (s != 1234567890)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20121108-1.c",
    "content": "char temp[] = \"192.168.190.160\";\nunsigned result = (((((192u<<8)|168u)<<8)|190u)<<8)|160u;\n\nint strtoul1(const char *a, char **b, int c) __attribute__((noinline, noclone));\nint strtoul1(const char *a, char **b, int c)\n{\n  *b = a+3;\n  if (a == temp)\n    return 192;\n  else if (a == temp+4)\n    return 168;\n  else if (a == temp+8)\n    return 190;\n  else if (a == temp+12)\n    return 160;\n  __builtin_abort();\n}\n\nint string_to_ip(const char *s) __attribute__((noinline,noclone));\nint string_to_ip(const char *s)\n{\n        int addr;\n        char *e;\n        int i;\n\n        if (s == 0)\n                return(0);\n\n        for (addr=0, i=0; i<4; ++i) {\n                int val = s ? strtoul1(s, &e, 10) : 0;\n                addr <<= 8;\n                addr |= (val & 0xFF);\n                if (s) {\n                        s = (*e) ? e+1 : e;\n                }\n        }\n\n        return addr;\n}\n\nint main(void)\n{\n  int t = string_to_ip (temp);\n  printf (\"%x\\n\", t);\n  printf (\"%x\\n\", result);\n  if (t != result)\n    __builtin_abort ();\n  printf (\"WORKS.\\n\");\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20131127-1.c",
    "content": "/* PR middle-end/59138 */\n/* Testcase by John Regehr <regehr@cs.utah.edu> */\n\nextern void abort (void);\n\n#pragma pack(1)\n\nstruct S0 {\n  int f0;\n  int f1;\n  int f2;\n  short f3;\n};\n\nshort a = 1;\n\nstruct S0 b = { 1 }, c, d, e;\n\nstruct S0 fn1() { return c; }\n\nvoid fn2 (void)\n{\n  b = fn1 ();\n  a = 0;\n  d = e;\n}\n\nint main (void)\n{\n  fn2 ();\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140212-1.c",
    "content": "/* PR rtl-optimization/60116 */\n/* Reported by Zhendong Su <su@cs.ucdavis.edu> */\n\nextern void abort (void);\n\nint a, b, c, d = 1, e, f = 1, h, i, k;\nchar g, j;\n\nvoid\nfn1 (void)\n{\n  int l;\n  e = 0;\n  c = 0;\n  for (;;)\n    {\n      k = a && b;\n      j = k * 54;\n      g = j * 147;\n      l = ~g + (long long) e && 1;\n      if (d)\n\tc = l;\n      else\n\th = i = l * 9UL;\n      if (f)\n\treturn;\n    }\n}\n\nint\nmain (void)\n{\n  fn1 ();\n  if (c != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140212-2.c",
    "content": "/* This used to fail as we would convert f into just return (unsigned int)usVlanID\n   which is wrong. */\n\nint f(unsigned short usVlanID) __attribute__((noinline,noclone));\nint f(unsigned short usVlanID)\n{\n  unsigned int uiVlanID = 0xffffffff;\n  int i;\n  if ((unsigned short)0xffff != usVlanID)\n    uiVlanID = (unsigned int)usVlanID;\n  return uiVlanID;\n}\n\nint main(void)\n{\n  if (f(1) != 1)\n    __builtin_abort ();\n  if (f(0xffff) != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140326-1.c",
    "content": "int a;\n\nint\nmain (void)\n{\n  char e[2] = { 0, 0 }, f = 0;\n  if (a == 131072)\n    f = e[a];\n  return f;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140425-1.c",
    "content": "/* PR target/60941 */\n/* Reported by Martin Husemann <martin@netbsd.org> */\n\nextern void abort (void);\n\nstatic void __attribute__((noinline))\nset (unsigned long *l)\n{\n  *l = 31;\n}\n\nint main (void)\n{\n  unsigned long l;\n  int i;\n\n  set (&l);\n  i = (int) l;\n  l = (unsigned long)(2U << i);\n  if (l != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140622-1.c",
    "content": "unsigned p;\n\nlong __attribute__((noinline, noclone))\ntest (unsigned a)\n{\n  return (long)(p + a) - (long)p;\n}\n\nint\nmain ()\n{\n  p = (unsigned) -2;\n  if (test (0) != 0)\n    __builtin_abort ();\n  if (test (1) != 1)\n    __builtin_abort ();\n  if (test (2) != -(long)(unsigned)-2)\n    __builtin_abort ();\n  p = (unsigned) -1;\n  if (test (0) != 0)\n    __builtin_abort ();\n  if (test (1) != -(long)(unsigned)-1)\n    __builtin_abort ();\n  if (test (2) != -(long)(unsigned)-2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20140828-1.c",
    "content": "short *f(short *a, int b, int *d) __attribute__((noinline,noclone));\n\nshort *f(short *a, int b, int *d)\n{\n  short c = *a;\n  a++;\n  c = b << c;\n  *d = c;\n  return a;\n}\n\nint main(void)\n{\n  int d;\n  short a[2];\n  a[0] = 0;\n  if (f(a, 1, &d) != &a[1])\n    __builtin_abort ();\n  if (d != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20141022-1.c",
    "content": "#define ABORT() do { __builtin_printf(\"assert.\\n\");  __builtin_abort (); }while(0)\nint f(int a) __attribute__((noinline));\nint f(int a)\n{\n  int fem_key_src;\n  int D2930 = a & 4294967291;\n  fem_key_src = a == 6 ? 0 : 15;\n  fem_key_src = D2930 != 1 ? fem_key_src : 0;\n  return fem_key_src;\n}\n\nint main(void)\n{\n  if (f(0) != 15)\n    ABORT ();\n  if (f(1) != 0)\n    ABORT ();\n  if (f(6) != 0)\n    ABORT ();\n  if (f(5) != 0)\n    ABORT ();\n  if (f(15) != 15)\n    ABORT ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20141107-1.c",
    "content": "#define bool _Bool\n\nbool f(int a, bool c) __attribute__((noinline));\nbool f(int a, bool c)\n{\n  if (!a)\n    c = !c;\n  return c;\n}\n\nvoid checkf(int a, bool b)\n{\n  bool c = f(a, b);\n  char d;\n  __builtin_memcpy (&d, &c, 1);\n  if ( d != (a==0)^b)\n    __builtin_abort();\n}\n\nint main(void)\n{\n  checkf(0, 0);\n  checkf(0, 1);\n  checkf(1, 1);\n  checkf(1, 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20141125-1.c",
    "content": "int f(long long a) __attribute__((noinline,noclone));\nint f(long long a)\n{\n  if (a & 0x3ffffffffffffffull)\n    return 1;\n  return 1024;\n}\n\nint main(void)\n{\n  if(f(0x48375d8000000000ull) != 1)\n    __builtin_abort ();\n  if (f(0xfc00000000000000ull) != 1024)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20150611-1.c",
    "content": "int a, c, d;\nshort b;\n\nint\nmain ()\n{\n  int e[1];\n  for (; b < 2; b++)\n    {\n      a = 0;\n      if (b == 28378)\n        a = e[b];\n      if (!(d || b))\n        for (; c;)\n          ;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20170111-1.c",
    "content": "/* PR rtl-optimization/79032 */\n/* Reported by Daniel Cederman <cederman@gaisler.com> */\n\nextern void abort (void);\n\nstruct S {\n  short a;\n  long long b;\n  short c;\n  char d;\n  unsigned short e;\n  long *f;\n};\n\nstatic long foo (struct S *s) __attribute__((noclone, noinline));\n\nstatic long foo (struct S *s)\n{\n  long a = 1;\n  a /= s->e;\n  s->f[a]--;\n  return a;\n}\n\nint main (void)\n{\n  long val = 1;\n  struct S s = { 0, 0, 0, 0, 2, &val };\n  val = foo (&s);\n  if (val != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20170401-1.c",
    "content": "/* PR45070 */\nextern void abort(void);\n\nstruct packed_ushort {\n    unsigned short ucs;\n} __attribute__((packed));\n\nstruct source {\n    int pos, length;\n};\n\nstatic int flag;\n\nstatic void __attribute__((noinline)) fetch(struct source *p)\n{\n    p->length = 128;\n}\n    \nstatic struct packed_ushort __attribute__((noinline)) next(struct source *p)\n{\n    struct packed_ushort rv;\n\n    if (p->pos >= p->length) {\n\tif (flag) {\n\t    flag = 0;\n\t    fetch(p);\n\t    return next(p);\n\t}\n\tflag = 1;\n\trv.ucs = 0xffff;\n\treturn rv;\n    }\n    rv.ucs = 0;\n    return rv;\n}\n\nint main(void)\n{\n    struct source s;\n    int i;\n\n    s.pos = 0;\n    s.length = 0;\n    flag = 0;\n\n    for (i = 0; i < 16; i++) {\n\tstruct packed_ushort rv = next(&s);\n\tif ((i == 0 && rv.ucs != 0xffff)\n\t    || (i > 0 && rv.ucs != 0))\n\t    abort();\n    }\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20170401-2.c",
    "content": "void adjust_xy (short *, short *);\n\nstruct adjust_template\n{\n  short kx_x;\n  short kx_y;\n};\n\nstatic struct adjust_template adjust = {1, 1};\n\nmain ()\n{\n  short x = 1, y = 1;\n\n  adjust_xy (&x, &y);\n\n  if (x != 2)\n    abort ();\n\n  exit (0);\n}\n\nvoid\nadjust_xy (x, y)\n     short  *x;\n     short  *y;\n{\n  *x = adjust.kx_x * *x + adjust.kx_y * *y;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/20170419-1.c",
    "content": "/* PR tree-optimization/80426 */\n/* Testcase by <ishiura-compiler@ml.kwansei.ac.jp> */\n\n#define INT_MAX 0x7fffffff\n#define INT_MIN (-INT_MAX-1)\n\nint x;\n\nint main (void)\n{\n  volatile int a = 0;\n  volatile int b = -INT_MAX;\n  int j;\n\n  for(j = 0; j < 18; j += 1) {\n    x = ( (a == 0) != (b - (int)(INT_MIN) ) );\n  }\n\n  if (x != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/900409-1.c",
    "content": "long f1(long a){return a&0xff000000L;}\nlong f2 (long a){return a&~0xff000000L;}\nlong f3(long a){return a&0x000000ffL;}\nlong f4(long a){return a&~0x000000ffL;}\nlong f5(long a){return a&0x0000ffffL;}\nlong f6(long a){return a&~0x0000ffffL;}\n\nmain ()\n{\n  long a = 0x89ABCDEF;\n\n  if (f1(a)!=0x89000000L||\n      f2(a)!=0x00ABCDEFL||\n      f3(a)!=0x000000EFL||\n      f4(a)!=0x89ABCD00L||\n      f5(a)!=0x0000CDEFL||\n      f6(a)!=0x89AB0000L)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920202-1.c",
    "content": "static int rule_text_needs_stack_pop = 0;\nstatic int input_stack_pos = 1;\n\nf (void)\n{\n  rule_text_needs_stack_pop = 1;\n\n  if (input_stack_pos <= 0)\n    return 1;\n  else\n    return 0;\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920302-1.c",
    "content": "short optab[5];\nchar buf[10];\nexecute (ip)\n     register short *ip;\n{\n#ifndef NO_LABEL_VALUES\n  register void *base = &&x;\n  char *bp = buf;\n  static void *tab[] = {&&x, &&y, &&z};\n  if (ip == 0)\n    {\n      int i;\n      for (i = 0; i < 3; ++i)\n\toptab[i] = (short)(tab[i] - base);\n      return;\n    }\nx:  *bp++='x';\n    goto *(base + *ip++);\ny:  *bp++='y';\n    goto *(base + *ip++);\nz:  *bp++='z';\n    *bp=0;\n    return;\n#else\n    strcpy (buf, \"xyxyz\");\n#endif\n}\n\nshort p[5];\n\nmain ()\n{\n  execute ((short *) 0);\n  p[0] = optab[1];\n  p[1] = optab[0];\n  p[2] = optab[1];\n  p[3] = optab[2];\n  execute (&p);\n  if (strcmp (buf, \"xyxyz\"))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920409-1.c",
    "content": "x(){signed char c=-1;return c<0;}main(){if(x()!=1)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920410-1.c",
    "content": "#define STACK_REQUIREMENT (40000 * 4 + 256)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\nmain(){int d[40000];d[0]=0;exit(0);}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920411-1.c",
    "content": "long f (w)\n     char *w;\n{\n  long k, i, c = 0, x;\n  char *p = (char*) &x;\n  for (i = 0; i < 1; i++)\n    {\n      for (k = 0; k < sizeof (long); k++)\n\tp[k] = w[k];\n      c += x;\n    }\n  return c;\n}\n\nmain ()\n{\n  int i;\n  char a[sizeof (long)];\n\n  for (i = sizeof (long); --i >= 0;) a[i] = ' ';\n  if (f (a) != ~0UL / (unsigned char) ~0 * ' ')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920415-1.c",
    "content": "#ifndef NO_LABEL_VALUES\nmain(){__label__ l;void*x(){return&&l;}goto*x();abort();return;l:exit(0);}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920428-1.c",
    "content": "x(const char*s){char a[1];const char*ss=s;a[*s++]|=1;return(int)ss+1==(int)s;}\nmain(){if(x(\"\")!=1)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920428-2.c",
    "content": "#if !defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\ns(i){if(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return f(i);l1:;}return 1;}\nx(){return s(0)==1&&s(1)==0&&s(2)==1;}\nmain(){if(x()!=1)abort();exit(0);}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920429-1.c",
    "content": "typedef unsigned char t;int i,j;\nt*f(t*p){t c;c=*p++;i=((c&2)?1:0);j=(c&7)+1;return p;}\nmain(){t*p0=\"ab\",*p1;p1=f(p0);if(p0+1!=p1)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\nint s[2];\nx(){if(!s[0]){s[1+s[1]]=s[1];return 1;}}\nmain(){s[0]=s[1]=0;if(x(0)!=1)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-2.c",
    "content": "unsigned long\ngcd_ll (unsigned long long x, unsigned long long y)\n{\n  for (;;)\n    {\n      if (y == 0)\n\treturn (unsigned long) x;\n      x = x % y;\n      if (x == 0)\n\treturn (unsigned long) y;\n      y = y % x;\n    }\n}\n\nunsigned long long\npowmod_ll (unsigned long long b, unsigned e, unsigned long long m)\n{\n  unsigned t;\n  unsigned long long pow;\n  int i;\n\n  if (e == 0)\n    return 1;\n\n  /* Find the most significant bit in E.  */\n  t = e;\n  for (i = 0; t != 0; i++)\n    t >>= 1;\n\n  /* The most sign bit in E is handled outside of the loop, by beginning\n     with B in POW, and decrementing I.  */\n  pow = b;\n  i -= 2;\n\n  for (; i >= 0; i--)\n    {\n      pow = pow * pow % m;\n      if ((1 << i) & e)\n\tpow = pow * b % m;\n    }\n\n  return pow;\n}\n\nunsigned long factab[10];\n\nvoid\nfacts (t, a_int, x0, p)\n     unsigned long long t;\n     int a_int;\n     int x0;\n     unsigned p;\n{\n  unsigned long *xp = factab;\n  unsigned long long x, y;\n  unsigned long q = 1;\n  unsigned long long a = a_int;\n  int i;\n  unsigned long d;\n  int j = 1;\n  unsigned long tmp;\n  int jj = 0;\n\n  x = x0;\n  y = x0;\n\n  for (i = 1; i < 10000; i++)\n    {\n      x = powmod_ll (x, p, t) + a;\n      y = powmod_ll (y, p, t) + a;\n      y = powmod_ll (y, p, t) + a;\n\n      if (x > y)\n\ttmp = x - y;\n      else\n\ttmp = y - x;\n      q = (unsigned long long) q * tmp % t;\n\n      if (i == j)\n\t{\n\t  jj += 1;\n\t  j += jj;\n\t  d = gcd_ll (q, t);\n\t  if (d != 1)\n\t    {\n\t      *xp++ = d;\n\t      t /= d;\n\t      if (t == 1)\n\t\t{\n\t\t  return;\n\t\t  *xp = 0;\n\t\t}\n\t    }\n\t}\n    }\n}\n\nmain ()\n{\n  unsigned long long t;\n  unsigned x0, a;\n  unsigned p;\n\n  p = 27;\n  t = (1ULL << p) - 1;\n\n  a = -1;\n  x0 = 3;\n\n  facts (t, a, x0, p);\n  if (factab[0] != 7 || factab[1] != 73 || factab[2] != 262657)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-3.c",
    "content": "int tab[9];\nexecute(oip, ip)\n     unsigned short *oip, *ip;\n{\n#ifndef NO_LABEL_VALUES\n  int x = 0;\n  int *xp = tab;\nbase:\n  x++;\n  if (x == 4)\n    {\n      *xp = 0;\n      return;\n    }\n  *xp++ = ip - oip;\n  goto *(&&base + *ip++);\n#else\n  tab[0] = 0;\n  tab[1] = 1;\n  tab[2] = 2;\n  tab[3] = 0;\n#endif\n}\n\nmain()\n{\n  unsigned short ip[10];\n  int i;\n  for (i = 0; i < 10; i++)\n    ip[i] = 0;\n  execute(ip, ip);\n  if (tab[0] != 0 || tab[1] != 1 || tab[2] != 2 || tab[3] != 0)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-4.c",
    "content": "#ifndef NO_LABEL_VALUES\nint\nx (int i)\n{\n  static const void *j[] = {&& x, && y, && z};\n  \n  goto *j[i];\n  \n x: return 2;\n y: return 3;\n z: return 5;\n}\n\nint\nmain (void)\n{\n  if (   x (0) != 2\n      || x (1) != 3\n      || x (2) != 5)\n    abort ();\n\n  exit (0);\n}\n#else\nint\nmain (void) { exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-5.c",
    "content": "#ifndef NO_LABEL_VALUES\nx (int i)\n{\n  void *j[] = {&&x, &&y, &&z};\n  goto *j[i];\n x:return 2;\n y:return 3;\n z:return 5;\n\n}\nmain ()\n{\n  if (x (0) != 2 || x (1) != 3 || x (2) != 5)\n    abort();\n  exit(0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-6.c",
    "content": "#include <stdio.h>\n\n/* Convert a decimal string to a long long unsigned.  No error check is\n   performed.  */\n\nlong long unsigned\nstr2llu (str)\n     char *str;\n{\n  long long unsigned acc;\n  int d;\n  acc =  *str++ - '0';\n  for (;;)\n    {\n      d = *str++;\n      if (d == '\\0')\n\tbreak;\n      d -= '0';\n      acc = acc * 10 + d;\n    }\n\n  return acc;\n}\n\n/* isqrt(t) - computes the square root of t. (tege 86-10-27) */\n\nlong unsigned\nsqrtllu (long long unsigned t)\n{\n  long long unsigned s;\n  long long unsigned b;\n\n  for (b = 0, s = t;  b++, (s >>= 1) != 0; )\n    ;\n\n  s = 1LL << (b >> 1);\n\n  if (b & 1)\n    s += s >> 1;\n\n  do\n    {\n      b = t / s;\n      s = (s + b) >> 1;\n    }\n  while (b < s);\n\n  return s;\n}\n\n\nint plist (p0, p1, tab)\n     long long unsigned p0, p1;\n     long long unsigned *tab;\n{\n  long long unsigned p;\n  long unsigned d;\n  long unsigned s;\n  long long unsigned *xp = tab;\n\n  for (p = p0;  p <= p1;  p += 2)\n    {\n      s = sqrtllu (p);\n\n      for (d = 3;  d <= s;  d += 2)\n\t{\n\t  long long unsigned q = p % d;\n\t  if (q == 0)\n\t    goto not_prime;\n\t}\n\n      *xp++ = p;\n    not_prime:;\n    }\n  *xp = 0;\n  return xp - tab;\n}\n\nmain (argc, argv)\n     int argc;\n     char *argv[];\n{\n  long long tab[10];\n  int nprimes;\n  nprimes = plist (str2llu (\"1234111111\"), str2llu (\"1234111127\"), tab);\n\n  if(tab[0]!=1234111117LL||tab[1]!=1234111121LL||tab[2]!=1234111127LL||tab[3]!=0)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-7.c",
    "content": "#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 1000\n#endif\n\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\nx(a)\n{\n  __label__ xlab;\n  void y(a)\n    {\n      if (a==0)\n\tgoto xlab;\n      y (a-1);\n    }\n  y (a);\n xlab:;\n  return a;\n}\n#endif\n\nmain ()\n{\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\n  if (x (DEPTH) != DEPTH)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-8.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\n\nchar buf[50];\nint\nva (int a, double b, int c, ...)\n{\n  va_list ap;\n  int d, e, f, g, h, i, j, k, l, m, n, o, p;\n  va_start (ap, c);\n\n  d = va_arg (ap, int);\n  e = va_arg (ap, int);\n  f = va_arg (ap, int);\n  g = va_arg (ap, int);\n  h = va_arg (ap, int);\n  i = va_arg (ap, int);\n  j = va_arg (ap, int);\n  k = va_arg (ap, int);\n  l = va_arg (ap, int);\n  m = va_arg (ap, int);\n  n = va_arg (ap, int);\n  o = va_arg (ap, int);\n  p = va_arg (ap, int);\n\n  sprintf (buf,\n\t   \"%d,%f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\",\n\t   a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);\n  va_end (ap);\n}\n\nmain()\n{\n  va (1, 1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  if (strcmp (\"1,1.000000,2,3,4,5,6,7,8,9,10,11,12,13,14,15\", buf))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920501-9.c",
    "content": "#include <stdio.h>\n\nlong long proc1(){return 1LL;}\nlong long proc2(){return 0x12345678LL;}\nlong long proc3(){return 0xaabbccdd12345678LL;}\nlong long proc4(){return -1LL;}\nlong long proc5(){return 0xaabbccddLL;}\n\nprint_longlong(x,buf)\n     long long x;\n     char *buf;\n{\n  unsigned long l;\n  l= (x >> 32) & 0xffffffff;\n  if (l != 0)\n    sprintf(buf,\"%lx%08.lx\",l,((unsigned long)x & 0xffffffff));\n  else\n    sprintf(buf,\"%lx\",((unsigned long)x & 0xffffffff));\n}\n\nmain(){char buf[100];\nprint_longlong(proc1(),buf);if(strcmp(\"1\",buf))abort();\nprint_longlong(proc2(),buf);if(strcmp(\"12345678\",buf))abort();\nprint_longlong(proc3(),buf);if(strcmp(\"aabbccdd12345678\",buf))abort();\nprint_longlong(proc4(),buf);if(strcmp(\"ffffffffffffffff\",buf))abort();\nprint_longlong(proc5(),buf);if(strcmp(\"aabbccdd\",buf))abort();\nexit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920506-1.c",
    "content": "int l[]={0,1};\nmain(){int*p=l;switch(*p++){case 0:exit(0);case 1:break;case 2:break;case 3:case 4:break;}abort();}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920520-1.c",
    "content": "foo(int *bar)\n{\n  *bar = 8;\n}\n\nbugger()\n{\n  int oldDepth, newDepth;\n\n  foo(&oldDepth);\n\n  switch (oldDepth)\n    {\n    case 8:\n    case 500:\n      newDepth = 8;\n      break;\n\n    case 5000:\n      newDepth = 500;\n      break;\n\n    default:\n      newDepth = 17;\n      break;\n    }\n\n  return newDepth - oldDepth;\n}\n\nmain()\n{\n  if (bugger() != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920603-1.c",
    "content": "f(got){if(got!=0xffff)abort();}\nmain(){signed char c=-1;unsigned u=(unsigned short)c;f(u);exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920604-1.c",
    "content": "long long\nmod (a, b)\n     long long a, b;\n{\n  return a % b;\n}\n\nint\nmain ()\n{\n  mod (1LL, 2LL);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920612-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint f(j)int j;{return++j>0;}\nint main(){if(f((~0U)>>1))abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920612-2.c",
    "content": "main ()\n{\n  int i = 0;\n  int a (int x)\n    {\n      while (x)\n\ti++, x--;\n      return x;\n    }\n#ifndef NO_TRAMPOLINES\n  if (a (2) != 0)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920618-1.c",
    "content": "main(){if(1.17549435e-38F<=1.1)exit(0);abort();}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920625-1.c",
    "content": "#include <stdarg.h>\n\ntypedef struct{double x,y;}point;\npoint pts[]={{1.0,2.0},{3.0,4.0},{5.0,6.0},{7.0,8.0}};\nstatic int va1(int nargs,...)\n{\n  va_list args;\n  int i;\n  point pi;\n  va_start(args,nargs);\n  for(i=0;i<nargs;i++){\n    pi=va_arg(args,point);\n    if(pts[i].x!=pi.x||pts[i].y!=pi.y)abort();\n  }\n  va_end(args);\n}\n\ntypedef struct{int x,y;}ipoint;\nipoint ipts[]={{1,2},{3,4},{5,6},{7,8}};\nstatic int va2(int nargs,...)\n{\n  va_list args;\n  int i;\n  ipoint pi;\n  va_start(args,nargs);\n  for(i=0;i<nargs;i++){\n    pi=va_arg(args,ipoint);\n    if(ipts[i].x!=pi.x||ipts[i].y!=pi.y)abort();\n  }\n  va_end(args);\n}\n\nmain()\n{\nva1(4,pts[0],pts[1],pts[2],pts[3]);\nva2(4,ipts[0],ipts[1],ipts[2],ipts[3]);\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920710-1.c",
    "content": "main()\n{\n  if ((double) 18446744073709551615ULL < 1.84467440737095e+19 ||\n      (double) 18446744073709551615ULL > 1.84467440737096e+19)\n    abort();\n\n  if (16777217L != (float)16777217e0)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920711-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint f(long a){return (--a > 0);}\nint main(){if(f(0x80000000L)==0)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920721-1.c",
    "content": "long f(short a,short b){return (long)a/b;}\nmain(){if(f(-32768,-1)!=32768L)abort();else exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920721-2.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nf(){}\nmain(){int n=2;double x[n];f();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920721-3.c",
    "content": "static inline fu (unsigned short data)\n{\n  return data;\n}\nru(i)\n{\n   if(fu(i++)!=5)abort();\n   if(fu(++i)!=7)abort();\n}\nstatic inline fs (signed short data)\n{\n  return data;\n}\nrs(i)\n{\n   if(fs(i++)!=5)abort();\n   if(fs(++i)!=7)abort();\n}\n\n\nmain()\n{\n  ru(5);\n  rs(5);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920721-4.c",
    "content": "#ifndef NO_LABEL_VALUES\nint try (int num) {\n  __label__ lab1, lab2, lab3, lab4, lab5, lab6, default_lab;\n\n  void *do_switch (int num) {\n    switch(num) {\n    case 1:\n      return &&lab1;\n    case 2:\n      return &&lab2;\n    case 3:\n      return &&lab3;\n    case 4:\n      return &&lab4;\n    case 5:\n      return &&lab5;\n    case 6:\n      return &&lab6;\n    default:\n      return &&default_lab;\n    }\n  }\n\n  goto *do_switch (num);\n\n lab1:\n  return 1;\n\n lab2:\n  return 2;\n\n lab3:\n  return 3;\n\n lab4:\n  return 4;\n\n lab5:\n  return 5;\n\n lab6:\n  return 6;\n\n default_lab:\n  return -1;\n}\n\nmain()\n{\n  int i;\n  for (i = 1; i <= 6; i++)\n    {\n      if (try (i) != i)\n\tabort();\n    }\n  exit(0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920726-1.c",
    "content": "#include <stdio.h>\n#include <stdarg.h>\n\nstruct spurious\n{\n    int anumber;\n};\n\nint first(char *buf, char *fmt, ...)\n{\n  int pos, number;\n  va_list args;\n  int dummy;\n  char *bp = buf;\n\n  va_start(args, fmt);\n  for (pos = 0; fmt[pos]; pos++)\n    if (fmt[pos] == 'i')\n      {\n\tnumber = va_arg(args, int);\n\tsprintf(bp, \"%d\", number);\n\tbp += strlen(bp);\n      }\n    else\n      *bp++ = fmt[pos];\n\n  va_end(args);\n  *bp = 0;\n  return dummy;\n}\n\nstruct spurious second(char *buf,char *fmt, ...)\n{\n  int pos, number;\n  va_list args;\n  struct spurious dummy;\n  char *bp = buf;\n\n  va_start(args, fmt);\n  for (pos = 0; fmt[pos]; pos++)\n    if (fmt[pos] == 'i')\n      {\n\tnumber = va_arg(args, int);\n\tsprintf(bp, \"%d\", number);\n\tbp += strlen(bp);\n      }\n    else\n      *bp++ = fmt[pos];\n\n  va_end(args);\n  *bp = 0;\n  return dummy;\n}\n\nmain()\n{\n  char buf1[100], buf2[100];\n  first(buf1, \"i i \", 5, 20);\n  second(buf2, \"i i \", 5, 20);\n  if (strcmp (\"5 20 \", buf1) || strcmp (\"5 20 \", buf2))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920728-1.c",
    "content": "typedef struct {int dims[0]; } *A;\n\nf(unsigned long obj)\n{\n  unsigned char y = obj >> 24;\n  y &= ~4;\n\n  if ((y==0)||(y!=251  ))\n    abort();\n\n  if(((int)obj&7)!=7)return;\n\n  REST_OF_CODE_JUST_HERE_TO_TRIGGER_THE_BUG:\n\n  {\n    unsigned char t = obj >> 24;\n    if (!(t==0)&&(t<=0x03))\n      return 0;\n    return ((A)(obj&0x00FFFFFFL))->dims[1];\n  }\n}\n\nlong g(){return 0xff000000L;}\nmain (){int x;f(g());exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920730-1.c",
    "content": "/* 920730-1.c */\n#include <limits.h>\nf1()\n{\n\tint b=INT_MIN;\n\treturn b>=INT_MIN;\n}\n\nf2()\n{\n\tint b=INT_MIN+1;\n\treturn b>= (unsigned)(INT_MAX+2);\n}\n\nf3()\n{\n\tint b=INT_MAX;\n\treturn b>=INT_MAX;\n}\n\nf4()\n{\n\tint b=-1;\n\treturn b>=UINT_MAX;\n}\n\nmain ()\n{\n\tif((f1()&f2()&f3()&f4())!=1)\n\t\tabort();\n\t\texit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920731-1.c",
    "content": "f(x){int i;for(i=0;i<8&&(x&1)==0;x>>=1,i++);return i;}\nmain(){if(f(4)!=2)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920810-1.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include <stdlib.h>\n\ntypedef struct{void*super;int name;int size;}t;\nt*f(t*clas,int size)\n{\n  t*child=(t*)malloc(size);\n  memcpy(child,clas,clas->size);\n  child->super=clas;\n  child->name=0;\n  child->size=size;\n  return child;\n}\nmain()\n{\n  t foo,*bar;\n  memset(&foo,37,sizeof(t));\n  foo.size=sizeof(t);\n  bar=f(&foo,sizeof(t));\n  if(bar->super!=&foo||bar->name!=0||bar->size!=sizeof(t))abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920812-1.c",
    "content": "typedef int t;\nf(t y){switch(y){case 1:return 1;}return 0;}\nmain(){if(f((t)1)!=1)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920829-1.c",
    "content": "long long c=2863311530LL,c3=2863311530LL*3;\nmain(){if(c*3!=c3)abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920908-1.c",
    "content": "/* REPRODUCED:RUN:SIGNAL MACHINE:mips OPTIONS: */\n\n#include <stdarg.h>\n\ntypedef struct{int A;}T;\n\nT f(int x,...)\n{\nva_list ap;\nT X;\nva_start(ap,x);\nX=va_arg(ap,T);\nif(X.A!=10)abort();\nX=va_arg(ap,T);\nif(X.A!=20)abort();\nva_end(ap);\nreturn X;\n}\n\nmain()\n{\nT X,Y;\nint i;\nX.A=10;\nY.A=20;\nf(2,X,Y);\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920908-2.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\n/*\nCONF:m68k-sun-sunos4.1.1\nOPTIONS:-O\n*/\nstruct T\n{\nunsigned i:8;\nunsigned c:24;\n};\nf(struct T t)\n{\nstruct T s[1];\ns[0]=t;\nreturn(char)s->c;\n}\nmain()\n{\nstruct T t;\nt.i=0xff;\nt.c=0xffff11;\nif(f(t)!=0x11)abort();\nexit(0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920909-1.c",
    "content": "f(a){switch(a){case 0x402:return a+1;case 0x403:return a+2;case 0x404:return a+3;case 0x405:return a+4;case 0x406:return 1;case 0x407:return 4;}return 0;}\nmain(){if(f(1))abort();exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920922-1.c",
    "content": "unsigned long*\nf(p)unsigned long*p;\n{\n  unsigned long a = (*p++) >> 24;\n  return p + a;\n}\n\nmain ()\n{\n  unsigned long x = 0x80000000UL;\n  if (f(&x) != &x + 0x81)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/920929-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n/* REPRODUCED:RUN:SIGNAL MACHINE:sparc OPTIONS: */\nf(int n)\n{\nint i;\ndouble v[n];\nfor(i=0;i<n;i++)\nv[i]=0;\n}\nmain()\n{\nf(100);\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921006-1.c",
    "content": "/* REPRODUCED:RUN:SIGNAL MACHINE:i386 OPTIONS:-O */\nmain()\n{\nif(strcmp(\"X\",\"\")<0)abort();\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921007-1.c",
    "content": "static int strcmp(){return-1;}\n#define strcmp __builtin_strcmp\nmain()\n{\nif(strcmp(\"X\",\"X\\376\")>=0)abort();\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921013-1.c",
    "content": "f(d,x,y,n)\nint*d;\nfloat*x,*y;\nint n;\n{\n  while(n--){*d++=*x++==*y++;}\n}\n\nmain()\n{\n  int r[4];\n  float a[]={5,1,3,5};\n  float b[]={2,4,3,0};\n  int i;\n  f(r,a,b,4);\n  for(i=0;i<4;i++)\n    if((a[i]==b[i])!=r[i])\n      abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921016-1.c",
    "content": "main()\n{\nint j=1081;\nstruct\n{\nsigned int m:11;\n}l;\nif((l.m=j)==j)abort();\nexit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921017-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nf(n)\n{\n  int a[n];\n  int g(i)\n    {\n      return a[i];\n    }\n  a[1]=4711;\n  return g(1);\n}\nmain()\n{\n#ifndef NO_TRAMPOLINES\n  if(f(2)!=4711)abort();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921019-1.c",
    "content": "void *foo[]={(void *)&(\"X\"[0])};\n\nmain ()\n{\n  if (((char*)foo[0])[0] != 'X')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921019-2.c",
    "content": "main()\n{\n  double x,y=0.5;\n  x=y/0.2;\n  if(x!=x)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921029-1.c",
    "content": "typedef unsigned long long ULL;\nULL back;\nULL hpart, lpart;\nULL\nbuild(long h, long l)\n{\n  hpart = h;\n  hpart <<= 32;\n  lpart = l;\n  lpart &= 0xFFFFFFFFLL;\n  back = hpart | lpart;\n  return back;\n}\n\nmain()\n{\n  if (build(0, 1) != 0x0000000000000001LL)\n    abort();\n  if (build(0, 0) != 0x0000000000000000LL)\n    abort();\n  if (build(0, 0xFFFFFFFF) != 0x00000000FFFFFFFFLL)\n    abort();\n  if (build(0, 0xFFFFFFFE) != 0x00000000FFFFFFFELL)\n    abort();\n  if (build(1, 1) != 0x0000000100000001LL)\n    abort();\n  if (build(1, 0) != 0x0000000100000000LL)\n    abort();\n  if (build(1, 0xFFFFFFFF) != 0x00000001FFFFFFFFLL)\n    abort();\n  if (build(1, 0xFFFFFFFE) != 0x00000001FFFFFFFELL)\n    abort();\n  if (build(0xFFFFFFFF, 1) != 0xFFFFFFFF00000001LL)\n    abort();\n  if (build(0xFFFFFFFF, 0) != 0xFFFFFFFF00000000LL)\n    abort();\n  if (build(0xFFFFFFFF, 0xFFFFFFFF) != 0xFFFFFFFFFFFFFFFFLL)\n    abort();\n  if (build(0xFFFFFFFF, 0xFFFFFFFE) != 0xFFFFFFFFFFFFFFFELL)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921104-1.c",
    "content": "main ()\n{\n  unsigned long val = 1;\n\n  if (val > (unsigned long) ~0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921110-1.c",
    "content": "extern void abort(void);\ntypedef void (*frob)();\nfrob f[] = {abort};\n\nint main(void)\n{\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921112-1.c",
    "content": "union u {\n  struct { int i1, i2; } t;\n  double d;\n} x[2], v;\n\nf (x, v)\n     union u *x, v;\n{\n  *++x = v;\n}\n\nmain()\n{\n  x[1].t.i1 = x[1].t.i2 = 0;\n  v.t.i1 = 1;\n  v.t.i2 = 2;\n  f (x, v);\n  if (x[1].t.i1 != 1 || x[1].t.i2 != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921113-1.c",
    "content": "#define STACK_REQUIREMENT (128 * 128 * 4 + 1024)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\n\ntypedef struct {\n  float wsx;\n} struct_list;\n\ntypedef struct_list *list_t;\n\ntypedef struct {\n  float x, y;\n} vector_t;\n\nw(float x, float y) {}\n\nf1(float x, float y)\n{\n  if (x != 0 || y != 0)\n    abort();\n}\nf2(float x, float y)\n{\n  if (x != 1 || y != 1)\n    abort();\n}\n\ngitter(int count, vector_t pos[], list_t list, int *nww, vector_t limit[2], float r)\n{\n  float d;\n  int gitt[128][128];\n\n  f1(limit[0].x, limit[0].y);\n  f2(limit[1].x, limit[1].y);\n\n  *nww = 0;\n\n  d = pos[0].x;\n  if (d <= 0.)\n    {\n      w(d, r);\n      if (d <= r * 0.5)\n\t{\n\t  w(d, r);\n\t  list[0].wsx = 1;\n\t}\n    }\n}\n\nvector_t pos[1] = {{0., 0.}};\nvector_t limit[2] = {{0.,0.},{1.,1.}};\n\nmain()\n{\n  int nww;\n  struct_list list;\n\n  gitter(1, pos, &list, &nww, limit, 1.);\n  exit(0);\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921117-1.c",
    "content": "struct s {\n  char text[11];\n  int flag;\n} cell;\n\nint\ncheck (struct s p)\n{\n  if (p.flag != 99)\n    return 1;\n  return strcmp (p.text, \"0123456789\");\n}\n\nmain ()\n{\n  cell.flag = 99;\n  strcpy (cell.text, \"0123456789\");\n\n  if (check (cell))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921123-1.c",
    "content": "f(short *p)\n{\n  short x = *p;\n  return (--x < 0);\n}\n\nmain()\n{\n  short x = -10;\n  if (!f(&x))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921123-2.c",
    "content": "typedef struct\n{\n  unsigned short b0, b1, b2, b3;\n} four_quarters;\n\nfour_quarters x;\nint a, b;\n\nvoid f (four_quarters j)\n{\n  b = j.b2;\n  a = j.b3;\n}\n\nmain ()\n{\n  four_quarters x;\n  x.b0 = x.b1 = x.b2 = 0;\n  x.b3 = 38;\n  f(x);\n  if (a != 38)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921124-1.c",
    "content": "f(x, d1, d2, d3)\n   double d1, d2, d3;\n{\n   return x;\n}\n\ng(b,s,x,y,i,j)\n     char *b,*s;\n     double x,y;\n{\n  if (x != 1.0 || y != 2.0 || i != 3 || j != 4)\n    abort();\n}\n\nmain()\n{\n  g(\"\",\"\", 1.0, 2.0, f(3, 0.0, 0.0, 0.0), f(4, 0.0, 0.0, 0.0));\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921202-1.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n#ifndef STACK_SIZE\n#define\tVLEN\t2055\n#else\n#define VLEN ((STACK_SIZE/16) - 1)\n#endif\nmain ()\n{\n  long dx[VLEN+1];\n  long dy[VLEN+1];\n  long s1[VLEN];\n  int cyx, cyy;\n  int i;\n  long size;\n\n  for (;;)\n    {\n      size = VLEN;\n      mpn_random2 (s1, size);\n\n      for (i = 0; i < 1; i++)\n\t;\n\n      dy[size] = 0x12345678;\n\n      for (i = 0; i < 1; i++)\n\tcyy = mpn_mul_1 (dy, s1, size);\n\n      if (cyx != cyy || mpn_cmp (dx, dy, size + 1) != 0 || dx[size] != 0x12345678)\n\t{\n\t  foo (\"\", 8, cyy); mpn_print (dy, size);\n\t}\n      exxit();\n    }\n}\n\nfoo (){}\nmpn_mul_1(){}\nmpn_print (){}\nmpn_random2(){}\nmpn_cmp(){}\nexxit(){exit(0);}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921202-2.c",
    "content": "int\nf(long long x)\n{\n  x >>= 8;\n  return x & 0xff;\n}\n\nmain()\n{\n  if (f(0x0123456789ABCDEFLL) != 0xCD)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921204-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\ntypedef struct {\n  unsigned b0:1, f1:17, b18:1, b19:1, b20:1, f2:11;\n} bf;\n\ntypedef union {\n  bf b;\n  unsigned w;\n} bu;\n\nbu\nf(bu i)\n{\n  bu o = i;\n\n  if (o.b.b0)\n    o.b.b18 = 1,\n    o.b.b20 = 1;\n  else\n    o.b.b18 = 0,\n    o.b.b20 = 0;\n\n  return o;\n}\n\nmain()\n{\n  bu a;\n  bu r;\n\n  a.w = 0x4000000;\n  a.b.b0 = 0;\n  r = f(a);\n  if (a.w != r.w)\n    abort();\n  exit(0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921207-1.c",
    "content": "f()\n{\n  unsigned b = 0;\n\n  if (b > ~0U)\n    b = ~0U;\n\n  return b;\n}\nmain()\n{\n  if (f()!=0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921208-1.c",
    "content": "double\nf(double x)\n{\n  return x*x;\n}\n\ndouble\nInt(double (*f)(double), double a)\n{\n  return (*f)(a);\n}\n\nmain()\n{\n  if (Int(&f,2.0) != 4.0)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921208-2.c",
    "content": "/* { dg-require-effective-target untyped_assembly } */\n#define STACK_REQUIREMENT (100000 * 4 + 1024)\n#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT\nmain () { exit (0); }\n#else\n\ng(){}\n\nf()\n{\n  int i;\n  float a[100000];\n\n  for (i = 0; i < 1; i++)\n    {\n      g(1.0, 1.0 + i / 2.0 * 3.0);\n      g(2.0, 1.0 + i / 2.0 * 3.0);\n    }\n}\n\nmain ()\n{\n  f();\n  exit(0);\n}\n\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921215-1.c",
    "content": "main()\n{\n#ifndef NO_TRAMPOLINES\n  void p(void ((*f) (void ())))\n    {\n      void r()\n\t{\n\t  foo ();\n\t}\n\n      f(r);\n    }\n\n  void q(void ((*f)()))\n    {\n      f();\n    }\n\n  p(q);\n#endif\n  exit(0);\n}\n\nfoo(){}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921218-1.c",
    "content": "f()\n{\n  return (unsigned char)(\"\\377\"[0]);\n}\n\nmain()\n{\n  if (f() != (unsigned char)(0377))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/921218-2.c",
    "content": "f()\n{\n  long l2;\n  unsigned short us;\n  unsigned long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nmain()\n{\n  if (f()!=(unsigned short)-1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930106-1.c",
    "content": "#if defined (STACK_SIZE)\n#define DUMMY_SIZE 9\n#else\n#define DUMMY_SIZE 399999\n#endif\n\ndouble g()\n{\n  return 1.0;\n}\n\nf()\n{\n  char dummy[DUMMY_SIZE];\n  double f1, f2, f3;\n  f1 = g();\n  f2 = g();\n  f3 = g();\n  return f1 + f2 + f3;\n}\n\nmain()\n{\n  if (f() != 3.0)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930111-1.c",
    "content": "main()\n{\n  if (wwrite((long long) 0) != 123)\n    abort();\n  exit(0);\n}\n\nint\nwwrite(long long i)\n{\n  switch(i)\n    {\n    case 3:\n    case 10:\n    case 23:\n    case 28:\n    case 47:\n      return 0;\n    default:\n      return 123;\n    }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930123-1.c",
    "content": "f(int *x)\n{\n  *x = 0;\n}\n\nmain()\n{\n  int s, c, x;\n  char a[] = \"c\";\n\n  f(&s);\n  a[c = 0] = s == 0 ? (x=1, 'a') : (x=2, 'b');\n  if (a[c] != 'a')\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930126-1.c",
    "content": "struct s {\n  unsigned long long a:8, b:32;\n};\n\nstruct s\nf(struct s x)\n{\n  x.b = 0xcdef1234;\n  return x;\n}\n\nmain()\n{\n  static struct s i;\n  i.a = 12;\n  i = f(i);\n  if (i.a != 12 || i.b != 0xcdef1234)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930208-1.c",
    "content": "typedef union {\n  long l;\n  struct { char b3, b2, b1, b0; } c;\n} T;\n\nf (T u)\n{\n  ++u.c.b0;\n  ++u.c.b3;\n  return (u.c.b1 != 2 || u.c.b2 != 2);\n}\n\nmain ()\n{\n  T u;\n  u.c.b1 = 2;\n  u.c.b2 = 2;\n  u.c.b0 = ~0;\n  u.c.b3 = ~0;\n  if (f (u))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930406-1.c",
    "content": "f()\n{\n  int x = 1;\n#if defined(STACK_SIZE)\n  char big[STACK_SIZE/2];\n#else\n  char big[0x1000];\n#endif\n\n  ({\n    __label__ mylabel;\n  mylabel:\n    x++;\n    if (x != 3)\n      goto mylabel;\n  });\n  exit(0);\n}\n\nmain()\n{\n  f();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930408-1.c",
    "content": "typedef enum foo E;\nenum foo { e0, e1 };\n\nstruct {\n  E eval;\n} s;\n\np()\n{\n  abort();\n}\n\nf()\n{\n  switch (s.eval)\n    {\n    case e0:\n      p();\n    }\n}\n\nmain()\n{\n  s.eval = e1;\n  f();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930429-1.c",
    "content": "char *\nf (char *p)\n{\n  short x = *p++ << 16;\n  return p;\n}\n\nmain ()\n{\n  char *p = \"\";\n  if (f (p) != p + 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930429-2.c",
    "content": "int\nf (b)\n{\n  return (b >> 1) > 0;\n}\n\nmain ()\n{\n  if (!f (9))\n    abort ();\n  if (f (-9))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930513-1.c",
    "content": "#include <stdio.h>\nchar buf[2];\n\nf (fp)\n     int (*fp)(char *, const char *, ...);\n{\n  (*fp)(buf, \"%.0f\", 5.0);\n}\n\nmain ()\n{\n  f (&sprintf);\n  if (buf[0] != '5' || buf[1] != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930513-2.c",
    "content": "sub3 (i)\n     const int *i;\n{\n}\n\neq (a, b)\n{\n  static int i = 0;\n  if (a != i)\n    abort ();\n  i++;\n}\n\nmain ()\n{\n  int i;\n\n  for (i = 0; i < 4; i++)\n    {\n      const int j = i;\n      int k;\n      sub3 (&j);\n      k = j;\n      eq (k, k);\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930518-1.c",
    "content": "int bar = 0;\n\nf (p)\n     int *p;\n{\n  int foo = 2;\n\n  while (foo > bar)\n    {\n      foo -=  bar;\n      *p++ = foo;\n      bar = 1;\n    }\n}\n\nmain ()\n{\n  int tab[2];\n  tab[0] = tab[1] = 0;\n  f (tab);\n  if (tab[0] != 2 || tab[1] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930526-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void exit (int);\n\ninline void\nf (int x)\n{\n  int *(p[25]);\n  int m[25*7];\n  int i;\n\n  for (i = 0; i < 25; i++)\n    p[i] = m + x*i;\n\n  p[1][0] = 0;\n}\n\nint\nmain ()\n{\n  f (7);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930527-1.c",
    "content": "f (unsigned char x)\n{\n  return (0x50 | (x >> 4)) ^ 0xff;\n}\n\nmain ()\n{\n  if (f (0) != 0xaf)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930529-1.c",
    "content": "/* { dg-options { \"-fwrapv\" } } */\n\nextern void abort (void);\nextern void exit (int);\n\nint dd (int x, int d) { return x / d; }\n\nint\nmain ()\n{\n  int i;\n  for (i = -3; i <= 3; i++)\n    {\n      if (dd (i, 1) != i / 1)\n\tabort ();\n      if (dd (i, 2) != i / 2)\n\tabort ();\n      if (dd (i, 3) != i / 3)\n\tabort ();\n      if (dd (i, 4) != i / 4)\n\tabort ();\n      if (dd (i, 5) != i / 5)\n\tabort ();\n      if (dd (i, 6) != i / 6)\n\tabort ();\n      if (dd (i, 7) != i / 7)\n\tabort ();\n      if (dd (i, 8) != i / 8)\n\tabort ();\n    }\n  for (i = ((unsigned) ~0 >> 1) - 3; i <= ((unsigned) ~0 >> 1) + 3; i++)\n    {\n      if (dd (i, 1) != i / 1)\n\tabort ();\n      if (dd (i, 2) != i / 2)\n\tabort ();\n      if (dd (i, 3) != i / 3)\n\tabort ();\n      if (dd (i, 4) != i / 4)\n\tabort ();\n      if (dd (i, 5) != i / 5)\n\tabort ();\n      if (dd (i, 6) != i / 6)\n\tabort ();\n      if (dd (i, 7) != i / 7)\n\tabort ();\n      if (dd (i, 8) != i / 8)\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930603-1.c",
    "content": "float fx (x)\n     float x;\n{\n  return 1.0 + 3.0 / (2.302585093 * x);\n}\n\nmain ()\n{\n  float fx (), inita (), initc (), a, b, c;\n  a = inita ();\n  c = initc ();\n  f ();\n  b = fx (c) + a;\n  f ();\n  if (a != 3.0 || b < 4.3257 || b > 4.3258 || c != 4.0)\n    abort ();\n  exit (0);\n}\n\nfloat inita () { return 3.0; }\nfloat initc () { return 4.0; }\nf () {}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930603-2.c",
    "content": "int w[2][2];\n\nf ()\n{\n  int i, j;\n\n  for (i = 0; i < 2; i++)\n    for (j = 0; j < 2; j++)\n      if (i == j)\n\tw[i][j] = 1;\n}\n\nmain ()\n{\n  f ();\n  if (w[0][0] != 1 || w[1][1] != 1 || w[1][0] != 0 || w[0][1] != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930603-3.c",
    "content": "f (b, c)\n     unsigned char *b;\n     int c;\n{\n  unsigned long v = 0;\n  switch (c)\n    {\n    case 'd':\n      v = ((unsigned long)b[0] << 8) + b[1];\n      v >>= 9;\n      break;\n\n    case 'k':\n      v = b[3] >> 4;\n      break;\n\n    default:\n      abort ();\n    }\n\n  return v;\n}\nmain ()\n{\n  char buf[4];\n  buf[0] = 170; buf[1] = 5;\n  if (f (buf, 'd') != 85)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930608-1.c",
    "content": "double f (double a) {}\ndouble (* const a[]) (double) = {&f};\n\nmain ()\n{\n  double (*p) ();\n  p = &f;\n  if (p != a[0])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930614-1.c",
    "content": "f (double *ty)\n{\n  *ty = -1.0;\n}\n\nmain ()\n{\n  double foo[6];\n  double tx = 0.0, ty, d;\n\n  f (&ty);\n\n  if (ty < 0)\n    ty = -ty;\n  d = (tx > ty) ? tx : ty;\n  if (ty != d)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930614-2.c",
    "content": "main ()\n{\n  int i, j, k, l;\n  float x[8][2][8][2];\n\n  for (i = 0; i < 8; i++)\n    for (j = i; j < 8; j++)\n      for (k = 0; k < 2; k++)\n\tfor (l = 0; l < 2; l++)\n\t  {\n\t    if ((i == j) && (k == l))\n\t      x[i][k][j][l] = 0.8;\n\t    else\n\t      x[i][k][j][l] = 0.8;\n\t    if (x[i][k][j][l] < 0.0)\n\t      abort ();\n\t  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930621-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nf ()\n{\n  struct {\n    int x : 18;\n    int y : 14;\n  } foo;\n\n  foo.x = 10;\n  foo.y = 20;\n\n  return foo.y;\n}\n\nmain ()\n{\n  if (f () != 20)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930622-1.c",
    "content": "int a = 1, b;\n\ng () { return 0; }\nh (x) {}\n\nf ()\n{\n  if (g () == -1)\n    return 0;\n  a = g ();\n  if (b >= 1)\n    h (a);\n  return 0;\n}\n\nmain ()\n{\n  f ();\n  if (a != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930622-2.c",
    "content": "long double\nll_to_ld (long long n)\n{\n  return n;\n}\n\nlong long\nld_to_ll (long double n)\n{\n  return n;\n}\n\nmain ()\n{\n  long long n;\n\n  if (ll_to_ld (10LL) != 10.0)\n    abort ();\n\n  if (ld_to_ll (10.0) != 10)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930628-1.c",
    "content": "f (double x[2], double y[2])\n{\n  if (x == y)\n    abort ();\n}\n\nmain ()\n{\n  struct { int f[3]; double x[1][2]; } tp[4][2];\n  int i, j, ki, kj, mi, mj;\n  float bdm[4][2][4][2];\n\n  for (i = 0; i < 4; i++)\n    for (j = i; j < 4; j++)\n      for (ki = 0; ki < 2; ki++)\n\tfor (kj = 0; kj < 2; kj++)\n\t  if ((j == i) && (ki == kj))\n\t    bdm[i][ki][j][kj] = 1000.0;\n\t  else\n\t    {\n\t      for (mi = 0; mi < 1; mi++)\n\t\tfor (mj = 0; mj < 1; mj++)\n\t\t  f (tp[i][ki].x[mi], tp[j][kj].x[mj]);\n\t      bdm[i][ki][j][kj] = 1000.0;\n\t    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930630-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nmain ()\n{\n  struct\n    {\n      signed int bf0:17;\n      signed int bf1:7;\n    } bf;\n\n  bf.bf1 = 7;\n  f (bf.bf1);\n  exit (0);\n}\n\nf (x)\n     int x;\n{\n  if (x != 7)\n    abort ();\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930702-1.c",
    "content": "fp (double a, int b)\n{\n  if (a != 33 || b != 11)\n    abort ();\n}\n\nmain ()\n{\n  int (*f) (double, int) = fp;\n\n  fp (33, 11);\n  f (33, 11);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930713-1.c",
    "content": "typedef struct\n{\n  char x;\n} T;\n\nT\nf (s1)\n     T s1;\n{\n  T s1a;\n  s1a.x = 17;\n  return s1a;\n}\n\nmain ()\n{\n  T s1a, s1b;\n  s1a.x = 13;\n  s1b = f (s1a);\n  if (s1a.x != 13 || s1b.x != 17)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930718-1.c",
    "content": "typedef struct rtx_def\n{\n  int f1 :1;\n  int f2 :1;\n} *rtx;\n\nstatic rtx\nf (orig)\n     register rtx orig;\n{\n  if (orig->f1 || orig->f2)\n    return orig;\n  orig->f2 = 1;\n  return orig;\n}\n\nvoid\nf2 ()\n{\n  abort ();\n}\n\nmain ()\n{\n  struct rtx_def foo;\n  rtx bar;\n\n  foo.f1 = 1;\n  foo.f2 = 0;\n  bar = f (&foo);\n  if (bar != &foo || bar->f2 != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930719-1.c",
    "content": "int\nf (foo, bar, com)\n{\n  unsigned align;\n  if (foo)\n    return 0;\n  while (1)\n    {\n      switch (bar)\n\t{\n\tcase 1:\n\t  if (com != 0)\n \t    return align;\n\t  *(char *) 0 = 0;\n\t}\n    }\n}\n\nmain ()\n{\n  f (0, 1, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930725-1.c",
    "content": "int v;\n\nchar *\ng ()\n{\n  return \"\";\n}\n\nchar *\nf ()\n{\n  return (v == 0 ? g () : \"abc\");\n}\n\nmain ()\n{\n  v = 1;\n  if (!strcmp (f (), \"abc\"))\n    exit (0);\n  abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930818-1.c",
    "content": "static double one = 1.0;\n\nf()\n{\n  int colinear;\n  colinear = (one == 0.0);\n  if (colinear)\n    abort ();\n  return colinear;\n}\nmain()\n{\n  if (f()) abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930916-1.c",
    "content": "f (n)\n     unsigned n;\n{\n  if ((int) n >= 0)\n    abort ();\n}\n\nmain ()\n{\n  unsigned x = ~0;\n  f (x);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930921-1.c",
    "content": "f (x)\n     unsigned x;\n{\n  return (unsigned) (((unsigned long long) x * 0xAAAAAAAB) >> 32) >> 1;\n}\n\nmain ()\n{\n  unsigned i;\n\n  for (i = 0; i < 10000; i++)\n    if (f (i) != i / 3)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930929-1.c",
    "content": "sub1 (i)\n     int i;\n{\n  return i - (5 - i);\n}\n\nsub2 (i)\n     int i;\n{\n  return i + (5 + i);\n}\n\nsub3 (i)\n     int i;\n{\n  return i - (5 + i);\n}\n\nsub4 (i)\n     int i;\n{\n  return i + (5 - i);\n}\n\nmain()\n{\n  if (sub1 (20) != 35)\n    abort ();\n  if (sub2 (20) != 45)\n    abort ();\n  if (sub3 (20) != -5)\n    abort ();\n  if (sub4 (20) != 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930930-1.c",
    "content": "__extension__ typedef __PTRDIFF_TYPE__ ptr_t;\nptr_t *wm_TR;\nptr_t *wm_HB;\nptr_t *wm_SPB;\n\nptr_t mem[100];\n\nf (mr_TR, mr_SPB, mr_HB, reg1, reg2)\n     ptr_t *mr_TR;\n     ptr_t *mr_SPB;\n     ptr_t *mr_HB;\n     ptr_t *reg1;\n     ptr_t *reg2;\n{\n  ptr_t *x = mr_TR;\n\n  for (;;)\n    {\n      if (reg1 < reg2)\n\tgoto out;\n      if ((ptr_t *) *reg1 < mr_HB && (ptr_t *) *reg1 >= mr_SPB)\n\t*--mr_TR = *reg1;\n      reg1--;\n    }\n out:\n\n  if (x != mr_TR)\n    abort ();\n}\n\nmain ()\n{\n  mem[99] = (ptr_t) mem;\n  f (mem + 100, mem + 6, mem + 8, mem + 99, mem + 99);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/930930-2.c",
    "content": "int\ntest_endianness()\n{\n  union doubleword\n    {\n      double d;\n      unsigned long u[2];\n    } dw;\n  dw.d = 10;\n  return dw.u[0] != 0 ? 1 : 0;\n}\n\nint\ntest_endianness_vol()\n{\n  union doubleword\n    {\n      volatile double d;\n      volatile long u[2];\n    } dw;\n  dw.d = 10;\n  return dw.u[0] != 0 ? 1 : 0;\n}\n\nmain ()\n{\n  if (test_endianness () != test_endianness_vol ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931002-1.c",
    "content": "f (void (*func) ())\n{\n  func ();\n}\n\nmain ()\n{\n#ifndef NO_TRAMPOLINES\n  void t0 ()\n    {\n    }\n\n  void t1 ()\n    {\n      f (t0);\n    }\n\n  void t2 ()\n    {\n      t1 ();\n    }\n\n  t1 ();\n  t1 ();\n  t2 ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-1.c",
    "content": "struct tiny\n{\n  int c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-10.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-11.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n  char e;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n  if (x.e != 30)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n  if (y.e != 31)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n  if (z.e != 32)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-12.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-13.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n  if (x.e != 30)\n    abort();\n  if (x.f != 40)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n  if (y.e != 31)\n    abort();\n  if (y.f != 41)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n  if (z.e != 32)\n    abort();\n  if (z.f != 42)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-14.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n      if (x.f != i + 40)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-2.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  int c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-3.c",
    "content": "struct tiny\n{\n  short c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-4.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  short c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-5.c",
    "content": "struct tiny\n{\n  short c;\n  short d;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-6.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  short c;\n  short d;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-7.c",
    "content": "struct tiny\n{\n  char c;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n\n  if (y.c != 11)\n    abort();\n\n  if (z.c != 12)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-8.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931004-9.c",
    "content": "struct tiny\n{\n  char c;\n  char d;\n};\n\nf (int n, struct tiny x, struct tiny y, struct tiny z, long l)\n{\n  if (x.c != 10)\n    abort();\n  if (x.d != 20)\n    abort();\n\n  if (y.c != 11)\n    abort();\n  if (y.d != 21)\n    abort();\n\n  if (z.c != 12)\n    abort();\n  if (z.d != 22)\n    abort();\n\n  if (l != 123)\n    abort ();\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931005-1.c",
    "content": "typedef struct\n{\n  char x;\n} T;\n\nT\nf (s1)\n     T s1;\n{\n  T s1a;\n  s1a.x = s1.x;\n  return s1a;\n}\n\nmain ()\n{\n  T s1a, s1b;\n  s1a.x = 100;\n  s1b = f (s1a);\n  if (s1b.x != 100)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931009-1.c",
    "content": "main ()\n{\n  f ();\n  exit (0);\n}\n\nstatic\ng (out, size, lo, hi)\n     int *out, size, lo, hi;\n{\n  int j;\n\n  for (j = 0; j < size; j++)\n    out[j] = j * (hi - lo);\n}\n\n\nf ()\n{\n  int a[2];\n\n  g (a, 2, 0, 1);\n\n  if (a[0] != 0 || a[1] != 1)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931012-1.c",
    "content": "f (int b, int c)\n{\n  if (b != 0 && b != 1 && c != 0)\n    b = 0;\n  return b;\n}\n\nmain ()\n{\n  if (!f (1, 2))\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931017-1.c",
    "content": "int v;\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n\nh1 ()\n{\n  return 0;\n}\n\nh2 (e)\n     int *e;\n{\n  if (e != &v)\n    abort ();\n  return 0;\n}\n\ng (c)\n     char *c;\n{\n  int i;\n  int b;\n\n  do\n    {\n      i = h1 ();\n      if (i == -1)\n\treturn 0;\n      else if (i == 1)\n\th1 ();\n    }\n  while (i == 1);\n\n  do\n    b = h2 (&v);\n  while (i == 5);\n\n  if (i != 2)\n    return b;\n  *c = 'a';\n\n  return 0;\n}\n\n\nf ()\n{\n  char c;\n  g (&c);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931018-1.c",
    "content": "unsigned int a[0x1000];\nextern const unsigned long v;\n\nmain ()\n{\n  f (v);\n  f (v);\n  exit (0);\n}\n\nf (a)\n     unsigned long a;\n{\n  if (a != 0xdeadbeefL)\n    abort();\n}\n\nconst unsigned long v = 0xdeadbeefL;\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931031-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct foo\n{\n  unsigned y:1;\n  unsigned x:32;\n};\n\nint\nf (x)\n     struct foo x;\n{\n  int t = x.x;\n  if (t < 0)\n    return 1;\n  return t+1;\n}\n\nmain ()\n{\n  struct foo x;\n  x.x = -1;\n  if (f (x) == 0)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931102-1.c",
    "content": "typedef union\n{\n  struct\n    {\n      char h, l;\n    } b;\n} T;\n\nf (x)\n     int x;\n{\n  int num = 0;\n  T reg;\n\n  reg.b.l = x;\n  while ((reg.b.l & 1) == 0)\n    {\n      num++;\n      reg.b.l >>= 1;\n    }\n  return num;\n}\n\nmain ()\n{\n  if (f (2) != 1)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931102-2.c",
    "content": "typedef union\n{\n  long align;\n  struct\n    {\n      short h, l;\n    } b;\n} T;\n\nf (x)\n     int x;\n{\n  int num = 0;\n  T reg;\n\n  reg.b.l = x;\n  while ((reg.b.l & 1) == 0)\n    {\n      num++;\n      reg.b.l >>= 1;\n    }\n  return num;\n}\n\nmain ()\n{\n  if (f (2) != 1)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931110-1.c",
    "content": "typedef struct\n{\n  short f:3, g:3, h:10;\n} small;\n\nstruct\n{\n  int i;\n  small s[10];\n} x;\n\nmain ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    x.s[i].f = 0;\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931110-2.c",
    "content": "main ()\n{\n  static int a[] = {3, 4};\n  register int *b;\n  int c;\n\n  b = a;\n  c = *b++ % 8;\n  if (c != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931208-1.c",
    "content": "f ()\n{\n  unsigned long x, y = 1;\n\n  x = ((y * 8192) - 216) / 16;\n  return x;\n}\n\nmain ()\n{\n  if (f () != 498)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/931228-1.c",
    "content": "f (x)\n{\n  x &= 010000;\n  x &= 007777;\n  x ^= 017777;\n  x &= 017770;\n  return x;\n}\n\nmain ()\n{\n  if (f (-1) != 017770)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/940115-1.c",
    "content": "f (cp, end)\n     char *cp;\n     char *end;\n{\n  return (cp < end);\n}\n\nmain ()\n{\n  if (! f ((char *) 0, (char *) 1))\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/940122-1.c",
    "content": "char *a = 0;\nchar *b = 0;\n\ng (x)\n     int x;\n{\n  if ((!!a) != (!!b))\n    abort ();\n}\n\nf (x)\n     int x;\n{\n  g (x * x);\n}\n\nmain ()\n{\n  f (100);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941014-1.c",
    "content": "int f (int a, int b) { }\n\nmain ()\n{\n  unsigned long addr1;\n  unsigned long addr2;\n\n  addr1 = (unsigned long) &f;\n  addr1 += 5;\n  addr2 = 5 + (unsigned long) &f;\n\n  if (addr1 != addr2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941014-2.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n\ntypedef struct {\n  unsigned short a;\n  unsigned short b;\n} foo_t;\n\nvoid a1 (unsigned long offset) {}\n\nvolatile foo_t *\nf ()\n{\n  volatile foo_t *foo_p = (volatile foo_t *)malloc (sizeof (foo_t));\n\n  a1((unsigned long)foo_p-30);\n  if (foo_p->a & 0xf000)\n    printf(\"%d\\n\", foo_p->a);\n  foo_p->b = 0x0100;\n  a1 ((unsigned long)foo_p + 2);\n  a1 ((unsigned long)foo_p - 30);\n  return foo_p;\n}\n\nmain ()\n{\n  volatile foo_t *foo_p;\n\n  foo_p = f ();\n  if (foo_p->b != 0x0100)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941015-1.c",
    "content": "int\nfoo1 (value)\n     long long value;\n{\n  register const long long constant = 0xc000000080000000LL;\n\n  if (value < constant)\n    return 1;\n  else\n    return 2;\n}\n\nint\nfoo2 (value)\n     unsigned long long value;\n{\n  register const unsigned long long constant = 0xc000000080000000LL;\n\n  if (value < constant)\n    return 1;\n  else\n    return 2;\n}\n\nmain ()\n{\n  unsigned long long value = 0xc000000000000001LL;\n  int x, y;\n\n  x = foo1 (value);\n  y = foo2 (value);\n  if (x != y || x != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941021-1.c",
    "content": "double glob_dbl;\n\nf (pdbl, value)\n     double *pdbl;\n     double value;\n{\n  if (pdbl == 0)\n    pdbl = &glob_dbl;\n\n  *pdbl = value;\n}\n\nmain ()\n{\n  f ((void *) 0, 55.1);\n\n  if (glob_dbl != 55.1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941025-1.c",
    "content": "long f (x, y)\n     long x,y;\n{\n  return (x > 1) ? y : (y & 1);\n}\n\nmain ()\n{\n  if (f (2L, 0xdecadeL) != 0xdecadeL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941031-1.c",
    "content": "typedef long mpt;\n\nint\nf (mpt us, mpt vs)\n{\n  long aus;\n  long avs;\n\n  aus = us >= 0 ? us : -us;\n  avs = vs >= 0 ? vs : -vs;\n\n  if (aus < avs)\n    {\n      long t = aus;\n      aus = avs;\n      avs = aus;\n    }\n\n  return avs;\n}\n\nmain ()\n{\n  if (f ((mpt) 3, (mpt) 17) != 17)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941101-1.c",
    "content": "f ()\n{\n  int var = 7;\n\n  if ((var/7) == 1)\n    return var/7;\n  return 0;\n}\n\nmain ()\n{\n  if (f () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941110-1.c",
    "content": "f (const int x)\n{\n  int y = 0;\n  y = x ? y : -y;\n  {\n    const int *p = &x;\n  }\n  return y;\n}\n\nmain ()\n{\n  if (f (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/941202-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\ng (x, y)\n{\n  if (x != 3)\n    abort ();\n}\n\nstatic inline\nf (int i)\n{\n  int *tmp;\n\n  tmp = (int *) alloca (sizeof (i));\n  *tmp = i;\n  g (*tmp, 0);\n}\n\nmain ()\n{\n  f (3);\n  exit (0);\n};\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950221-1.c",
    "content": "struct parsefile\n{\n  long fd;\n  char *buf;\n};\nstruct parsefile basepf;\nstruct parsefile *parsefile = &basepf;\n#ifdef STACK_SIZE\nint filler[STACK_SIZE / (2*sizeof(int))];\n#else\nint filler[0x3000];\n#endif\nint el;\n\nchar *\ng1 (a, b)\n     int a;\n     int *b;\n{\n}\n\ng2 (a)\n     long a;\n{\n  if (a != 0xdeadbeefL)\n    abort ();\n  exit (0);\n}\n\nf ()\n{\n  register char *p, *q;\n  register int i;\n  register int something;\n\n  if (parsefile->fd == 0L && el)\n    {\n      const char *rl_cp;\n      int len;\n      rl_cp = g1 (el, &len);\n      strcpy (p, rl_cp);\n    }\n  else\n    {\n    alabel:\n      i = g2 (parsefile->fd);\n    }\n}\n\nmain ()\n{\n  el = 0;\n  parsefile->fd = 0xdeadbeefL;\n  f ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950322-1.c",
    "content": "f (unsigned char *a)\n{\n  int i, j;\n  int x, y;\n\n  j = a[1];\n  i = a[0] - j;\n  if (i < 0)\n    {\n      x = 1;\n      y = -i;\n    }\n  else\n    {\n      x = 0;\n      y =  i;\n    }\n  return x + y;\n}\n\n\nmain ()\n{\n  unsigned char a[2];\n  a[0] = 8;\n  a[1] = 9;\n  if (f (a) != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950426-1.c",
    "content": "\nstruct tag {\n  int m1;\n  char *m2[5];\n} s1, *p1;\n\nint i;\n\nmain()\n{\n  s1.m1 = -1;\n  p1 = &s1;\n\n  if ( func1( &p1->m1 ) == -1 )\n    foo (\"ok\");\n  else\n    abort ();\n\n  i = 3;\n  s1.m2[3]= \"123\";\n\n  if ( strlen( (p1->m2[i])++ ) == 3 )\n    foo (\"ok\");\n  else\n    abort ();\n\n  exit (0);\n}\n\nfunc1(int *p) { return(*p); }\n\nfoo (char *s) {}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950426-2.c",
    "content": "main()\n{\n  long int i = -2147483647L - 1L; /* 0x80000000 */\n  char ca = 1;\n\n  if (i >> ca != -1073741824L)\n    abort ();\n\n  if (i >> i / -2000000000L != -1073741824L)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950503-1.c",
    "content": "main ()\n{\n  int tmp;\n  unsigned long long utmp1, utmp2;\n\n  tmp = 16;\n\n  utmp1 = (~((unsigned long long) 0)) >> tmp;\n  utmp2 = (~((unsigned long long) 0)) >> 16;\n\n  if (utmp1 != utmp2)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950511-1.c",
    "content": "main ()\n{\n  unsigned long long xx;\n  unsigned long long *x = (unsigned long long *) &xx;\n\n  *x = -3;\n  *x = *x * *x;\n  if (*x != 9)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950512-1.c",
    "content": "unsigned\nf1 (x)\n{\n  return ((unsigned) (x != 0) - 3) / 2;\n}\n\nunsigned long long\nf2 (x)\n{\n  return ((unsigned long long) (x != 0) - 3) / 2;\n}\n\nmain ()\n{\n  if (f1 (1) != (~(unsigned) 0) >> 1)\n    abort ();\n  if (f1 (0) != ((~(unsigned) 0) >> 1) - 1)\n    abort ();\n  if (f2 (1) != (~(unsigned long long) 0) >> 1)\n    abort ();\n  if (f2 (0) != ((~(unsigned long long) 0) >> 1) - 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950605-1.c",
    "content": "f (c)\n    unsigned char c;\n{\n  if (c != 0xFF)\n    abort ();\n}\n\nmain ()\n{\n  f (-1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950607-1.c",
    "content": "main ()\n{\n  struct { long status; } h;\n\n  h.status = 0;\n  if (((h.status & 128) == 1) && ((h.status & 32) == 0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950607-2.c",
    "content": "typedef struct {\n  long int p_x, p_y;\n} Point;\n\nint\nf (Point basePt, Point pt1, Point pt2)\n{\n  long long vector;\n\n  vector =\n    (long long) (pt1.p_x - basePt.p_x) * (long long) (pt2.p_y - basePt.p_y) -\n      (long long) (pt1.p_y - basePt.p_y) * (long long) (pt2.p_x - basePt.p_x);\n\n  if (vector > (long long) 0)\n    return 0;\n  else if (vector < (long long) 0)\n    return 1;\n  else\n    return 2;\n}\n\nmain ()\n{\n  Point b, p1, p2;\n  int answer;\n\n  b.p_x = -23250;\n  b.p_y = 23250;\n\n  p1.p_x = 23250;\n  p1.p_y = -23250;\n\n  p2.p_x = -23250;\n  p2.p_y = -23250;\n\n  answer = f (b, p1, p2);\n\n  if (answer != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950612-1.c",
    "content": "unsigned int\nf1 (int diff)\n{\n  return ((unsigned int) (diff < 0 ? -diff : diff));\n}\n\nunsigned int\nf2 (unsigned int diff)\n{\n  return ((unsigned int) ((signed int) diff < 0 ? -diff : diff));\n}\n\nunsigned long long\nf3 (long long diff)\n{\n  return ((unsigned long long) (diff < 0 ? -diff : diff));\n}\n\nunsigned long long\nf4 (unsigned long long diff)\n{\n  return ((unsigned long long) ((signed long long) diff < 0 ? -diff : diff));\n}\n\nmain ()\n{\n  int i;\n  for (i = 0; i <= 10; i++)\n    {\n      if (f1 (i) != i)\n\tabort ();\n      if (f1 (-i) != i)\n\tabort ();\n      if (f2 (i) != i)\n\tabort ();\n      if (f2 (-i) != i)\n\tabort ();\n      if (f3 ((long long) i) != i)\n\tabort ();\n      if (f3 ((long long) -i) != i)\n\tabort ();\n      if (f4 ((long long) i) != i)\n\tabort ();\n      if (f4 ((long long) -i) != i)\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950621-1.c",
    "content": "struct s\n{\n  int a;\n  int b;\n  struct s *dummy;\n};\n\nf (struct s *sp)\n{\n  return sp && sp->a == -1 && sp->b == -1;\n}\n\nmain ()\n{\n  struct s x;\n  x.a = x.b = -1;\n  if (f (&x) == 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950628-1.c",
    "content": "typedef struct\n{\n  char hours, day, month;\n  short year;\n} T;\n\nT g (void)\n{\n  T now;\n\n  now.hours = 1;\n  now.day = 2;\n  now.month = 3;\n  now.year = 4;\n  return now;\n}\n\nT f (void)\n{\n  T virk;\n\n  virk = g ();\n  return virk;\n}\n\nmain ()\n{\n  if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950704-1.c",
    "content": "int errflag;\n\nlong long\nf (long long x, long long y)\n{\n  long long r;\n\n  errflag = 0;\n  r = x + y;\n  if (x >= 0)\n    {\n      if ((y < 0) || (r >= 0))\n\treturn r;\n    }\n  else\n    {\n      if ((y > 0) || (r < 0))\n\treturn r;\n    }\n  errflag = 1;\n  return 0;\n}\n\nmain ()\n{\n  f (0, 0);\n  if (errflag)\n    abort ();\n\n  f (1, -1);\n  if (errflag)\n    abort ();\n\n  f (-1, 1);\n  if (errflag)\n    abort ();\n\n  f (0x8000000000000000LL, 0x8000000000000000LL);\n  if (!errflag)\n    abort ();\n\n  f (0x8000000000000000LL, -1LL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 0x7fffffffffffffffLL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 1LL);\n  if (!errflag)\n    abort ();\n\n  f (0x7fffffffffffffffLL, 0x8000000000000000LL);\n  if (errflag)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950706-1.c",
    "content": "int\nf (int n)\n{\n  return (n > 0) - (n < 0);\n}\n\nmain ()\n{\n  if (f (-1) != -1)\n    abort ();\n  if (f (1) != 1)\n    abort ();\n  if (f (0) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950710-1.c",
    "content": "struct twelve\n{\n  int a;\n  int b;\n  int c;\n};\n\nstruct pair\n{\n  int first;\n  int second;\n};\n\nstruct pair\ng ()\n{\n  struct pair p;\n  return p;\n}\n\nstatic void\nf ()\n{\n  int i;\n  for (i = 0; i < 1; i++)\n    {\n      int j;\n      for (j = 0; j < 1; j++)\n\t{\n\t  if (0)\n\t    {\n\t      int k;\n\t      for (k = 0; k < 1; k++)\n\t\t{\n\t\t  struct pair e = g ();\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      struct twelve a, b;\n\t      if ((((char *) &b - (char *) &a) < 0\n\t\t   ? (-((char *) &b - (char *) &a))\n\t\t   : ((char *) &b - (char *) &a))  < sizeof (a))\n\t\tabort ();\n\t    }\n\t}\n    }\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950714-1.c",
    "content": "int array[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};\n\nmain ()\n{\n  int i, j;\n  int *p;\n\n  for (i = 0; i < 10; i++)\n    for (p = &array[0]; p != &array[9]; p++)\n      if (*p == i)\n\tgoto label;\n\n label:\n  if (i != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950809-1.c",
    "content": "struct S\n{\n  int *sp, fc, *sc, a[2];\n};\n\nf (struct S *x)\n{\n  int *t = x->sc;\n  int t1 = t[0];\n  int t2 = t[1];\n  int t3 = t[2];\n  int a0 = x->a[0];\n  int a1 = x->a[1];\n  t[2] = t1;\n  t[0] = a1;\n  x->a[1] = a0;\n  x->a[0] = t3;\n  x->fc = t2;\n  x->sp = t;\n}\n\nmain ()\n{\n  struct S s;\n  static int sc[3] = {2, 3, 4};\n  s.sc = sc;\n  s.a[0] = 10;\n  s.a[1] = 11;\n  f (&s);\n  if (s.sp[2] != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950906-1.c",
    "content": "g (int i)\n{\n}\n\nf (int i)\n{\n  g (0);\n  while ( ({ i--; }) )\n    g (0);\n}\n\nmain ()\n{\n  f (10);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950915-1.c",
    "content": "long int a = 100000;\nlong int b = 21475;\n\nlong\nf ()\n{\n  return ((long long) a * (long long) b) >> 16;\n}\n\nmain ()\n{\n  if (f () < 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/950929-1.c",
    "content": "int f (char *p) { }\n\nmain ()\n{\n  char c;\n  char c2;\n  int i = 0;\n  char *pc = &c;\n  char *pc2 = &c2;\n  int *pi = &i;\n\n  *pc2 = 1;\n  *pi = 1;\n  *pc2 &= *pi;\n  f (pc2);\n  *pc2 = 1;\n  *pc2 &= *pi;\n  if (*pc2 != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/951003-1.c",
    "content": "int f (i) { return 12; }\nint g () { return 0; }\n\nmain ()\n{\n  int i, s;\n\n  for (i = 0; i < 32; i++)\n    {\n      s = f (i);\n\n      if (i == g ())\n\ts = 42;\n      if (i == 0 || s == 12)\n\t;\n      else\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/951115-1.c",
    "content": "int var = 0;\n\ng ()\n{\n  var = 1;\n}\n\nf ()\n{\n  int f2 = 0;\n\n  if (f2 == 0)\n    ;\n\n  g ();\n}\n\nmain ()\n{\n  f ();\n  if (var != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/951204-1.c",
    "content": "f (char *x)\n{\n  *x = 'x';\n}\n\nmain ()\n{\n  int i;\n  char x = '\\0';\n\n  for (i = 0; i < 100; ++i)\n    {\n      f (&x);\n      if (*(const char *) &x != 'x')\n\tabort ();\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960116-1.c",
    "content": "static inline\np (int *p)\n{\n  return !((long) p & 1);\n}\n\nint\nf (int *q)\n{\n  if (p (q) && *q)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  if (f ((int*) 0xffffffff) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960117-1.c",
    "content": "static char id_space[2] [32 +1];\ntypedef short COUNT;\n\ntypedef char TEXT;\n\nunion T_VALS\n{\n  TEXT   *id __attribute__ ((aligned (2), packed)) ;\n};\ntypedef union T_VALS VALS;\n\nstruct T_VAL\n{\n  COUNT    pos __attribute__ ((aligned (2), packed)) ;\n  VALS    vals __attribute__ ((aligned (2), packed)) ;\n};\ntypedef struct T_VAL VAL;\n\nVAL curval = {0};\n\nstatic short idc = 0;\nstatic int cur_line;\nstatic int char_pos;\n\ntypedef unsigned short WORD;\n\nWORD\nget_id (char c)\n{\n  curval.vals.id[0] = c;\n}\n\nWORD\nget_tok ()\n{\n  char c = 'c';\n  curval.vals.id = id_space[idc];\n  curval.pos = (cur_line << 10) | char_pos;\n  return get_id (c);\n}\n\nmain ()\n{\n  get_tok ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960209-1.c",
    "content": "struct a_struct\n{\n  unsigned char a_character;\n};\n\nstruct a_struct an_array[5];\nstruct a_struct *a_ptr;\nint yabba = 1;\n\nint\nf (a, b)\n     unsigned char a;\n     unsigned long b;\n{\n  long i, j, p, q, r, s;\n\n  if (b != (unsigned long) 0)\n    {\n      if (yabba)\n\treturn -1;\n      s = 4000000 / b;\n      for (i = 0; i < 11; i++)\n\t{\n\t  for (j = 0; j < 256; j++)\n\t    {\n\t      if (((p - s < 0) ? -s : 0) < (( q - s < 0) ? -s : q))\n\t\tr = i;\n\t    }\n\t}\n    }\n\n  if (yabba)\n    return 0;\n  a_ptr = &an_array[a];\n  a_ptr->a_character = (unsigned char) r;\n}\n\nmain ()\n{\n  if (f (1, 0UL) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960215-1.c",
    "content": "long double C = 2;\nlong double U = 1;\nlong double Y2 = 3;\nlong double Y1 = 1;\nlong double X, Y, Z, T, R, S;\nmain ()\n{\n  X = (C + U) * Y2;\n  Y = C - U - U;\n  Z = C + U + U;\n  T = (C - U) * Y1;\n  X = X - (Z + U);\n  R = Y * Y1;\n  S = Z * Y2;\n  T = T - Y;\n  Y = (U - Y) + R;\n  Z = S - (Z + U + U);\n  R = (Y2 + U) * Y1;\n  Y1 = Y2 * Y1;\n  R = R - Y2;\n  Y1 = Y1 - 0.5L;\n  if (Z != 6)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960218-1.c",
    "content": "int glob;\n\ng (x)\n{\n  glob = x;\n  return 0;\n}\n\nf (x)\n{\n  int a = ~x;\n  while (a)\n    a = g (a);\n}\n\nmain ()\n{\n  f (3);\n  if (glob != -4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960219-1.c",
    "content": "f (int i)\n{\n  if (((1 << i) & 1) == 0)\n    abort ();\n}\n\nmain ()\n{\n  f (0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960301-1.c",
    "content": "struct foo {\n  unsigned : 12;\n  unsigned field : 4;\n} foo;\nunsigned oldfoo;\n\nint\nbar (unsigned k)\n{\n  oldfoo = foo.field;\n  foo.field = k;\n  if (k)\n    return 1;\n  return 2;\n}\n\nmain ()\n{\n  if (bar (1U) != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960302-1.c",
    "content": "long a = 1;\n\nfoo ()\n{\n  switch (a % 2 % 2 % 2 % 2 % 2 % 2 % 2 % 2)\n    {\n    case 0:\n      return 0;\n    case 1:\n      return 1;\n    default:\n      return -1;\n    }\n}\n\nmain ()\n{\n  if (foo () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960311-1.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned char data)\n{\n  if (data & 0x80) a1();\n  data <<= 1;\n\n  if (data & 0x80) a1();\n  data <<= 1;\n\n  if (data & 0x80) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x80);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x40);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x20);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc0);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa0);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x60);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe0);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960311-2.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned short data)\n{\n  if (data & 0x8000) a1();\n  data <<= 1;\n\n  if (data & 0x8000) a1();\n  data <<= 1;\n\n  if (data & 0x8000) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x8000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x4000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x2000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x6000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe000);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960311-3.c",
    "content": "#include <stdio.h>\n\n#ifdef DEBUG\n#define abort() printf (\"error, line %d\\n\", __LINE__)\n#endif\n\nint count;\n\nvoid a1() { ++count; }\n\nvoid\nb (unsigned long data)\n{\n  if (data & 0x80000000) a1();\n  data <<= 1;\n\n  if (data & 0x80000000) a1();\n  data <<= 1;\n\n  if (data & 0x80000000) a1();\n}\n\nmain ()\n{\n  count = 0;\n  b (0);\n  if (count != 0)\n    abort ();\n\n  count = 0;\n  b (0x80000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x40000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0x20000000);\n  if (count != 1)\n    abort ();\n\n  count = 0;\n  b (0xc0000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xa0000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0x60000000);\n  if (count != 2)\n    abort ();\n\n  count = 0;\n  b (0xe0000000);\n  if (count != 3)\n    abort ();\n\n#ifdef DEBUG\n  printf (\"Done.\\n\");\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960312-1.c",
    "content": "struct S\n{\n  int *sp, fc, *sc, a[2];\n};\n\nf (struct S *x)\n{\n  int *t = x->sc;\n  int t1 = t[0];\n  int t2 = t[1];\n  int t3 = t[2];\n  int a0 = x->a[0];\n  int a1 = x->a[1];\n  asm(\"\": :\"r\" (t2), \"r\" (t3));\n  t[2] = t1;\n  t[0] = a1;\n  x->a[1] = a0;\n  x->a[0] = t3;\n  x->fc = t2;\n  x->sp = t;\n}\n\nmain ()\n{\n  struct S s;\n  static int sc[3] = {2, 3, 4};\n  s.sc = sc;\n  s.a[0] = 10;\n  s.a[1] = 11;\n  f (&s);\n  if (s.sp[2] != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960317-1.c",
    "content": "int\nf (unsigned bitcount, int mant)\n{\n  int mask = -1 << bitcount;\n  {\n    if (! (mant & -mask))\n      goto ab;\n    if (mant & ~mask)\n      goto auf;\n  }\nab:\n  return 0;\nauf:\n  return 1;\n}\n\nmain ()\n{\n  if (f (0, -1))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960321-1.c",
    "content": "char a[10] = \"deadbeef\";\n\nchar\nacc_a (long i)\n{\n  return a[i-2000000000L];\n}\n\nmain ()\n{\n  if (acc_a (2000000000L) != 'd')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960326-1.c",
    "content": "struct s\n{\n  int a;\n  int b;\n  short c;\n  int d[3];\n};\n\nstruct s s = { .b = 3, .d = {2,0,0} };\n\nmain ()\n{\n  if (s.b != 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960327-1.c",
    "content": "#include <stdio.h>\ng ()\n{\n  return '\\n';\n}\n\nf ()\n{\n  char s[] = \"abcedfg012345\";\n  char *sp = s + 12;\n\n  switch (g ())\n    {\n      case '\\n':\n        break;\n    }\n\n  while (*--sp == '0')\n    ;\n  sprintf (sp + 1, \"X\");\n\n  if (s[12] != 'X')\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960402-1.c",
    "content": "f (signed long long int x)\n{\n  return x > 0xFFFFFFFFLL || x < -0x80000000LL;\n}\n\nmain ()\n{\n  if (f (0) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960405-1.c",
    "content": "#define X  5.9486574767861588254287966331400356538172e4931L\n\nlong double x = X + X;\nlong double y = 2.0L * X;\n\nmain ()\n{\n#if ! defined (__vax__) && ! defined (_CRAY)\n  if (x != y)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960416-1.c",
    "content": "typedef unsigned long int st;\ntypedef unsigned long long dt;\ntypedef union\n{\n  dt d;\n  struct\n  {\n    st h, l;\n  }\n  s;\n} t_be;\n\ntypedef union\n{\n  dt d;\n  struct\n  {\n    st l, h;\n  }\n  s;\n} t_le;\n\n#define df(f, t) \\\nint \\\nf (t afh, t bfh) \\\n{ \\\n  t hh; \\\n  t hp, lp, dp, m; \\\n  st ad, bd; \\\n  int s; \\\n  s = 0; \\\n  ad = afh.s.h - afh.s.l; \\\n  bd = bfh.s.l - bfh.s.h; \\\n  if (bd > bfh.s.l) \\\n    { \\\n      bd = -bd; \\\n      s = ~s; \\\n    } \\\n  lp.d = (dt) afh.s.l * bfh.s.l; \\\n  hp.d = (dt) afh.s.h * bfh.s.h; \\\n  dp.d = (dt) ad *bd; \\\n  dp.d ^= s; \\\n  hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \\\n  m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \\\n  return hh.s.l + m.s.l; \\\n}\n\ndf(f_le, t_le)\ndf(f_be, t_be)\n\nmain ()\n{\n  t_be x;\n  x.s.h = 0x10000000U;\n  x.s.l = 0xe0000000U;\n  if (x.d == 0x10000000e0000000ULL\n      && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1)\n    abort ();\n  if (x.d == 0xe000000010000000ULL\n      && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960419-1.c",
    "content": "static int i;\n\nvoid\ncheck(x)\n     int x;\n{\n  if (!x)\n    abort();\n}\n\nmain()\n{\n  int *p = &i;\n\n  check(p != (void *)0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960419-2.c",
    "content": "#define SIZE 8\n\nmain()\n{\n  int a[SIZE] = {1};\n  int i;\n\n  for (i = 1; i < SIZE; i++)\n    if (a[i] != 0)\n      abort();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960512-1.c",
    "content": "__complex__\ndouble f ()\n{\n  int a[40];\n  __complex__ double c;\n\n  a[9] = 0;\n  c = a[9];\n  return c;\n}\n\nmain ()\n{\n  __complex__ double c;\n\n  if (c = f ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960513-1.c",
    "content": "long double\nf (d, i)\n     long double d;\n     int i;\n{\n  long double e;\n\n  d = -d;\n  e = d;\n  if (i == 1)\n    d *= 2;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  d -= e * d;\n  return d;\n}\n\nmain ()\n{\n  if (! (int) (f (2.0L, 1)))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960521-1.c",
    "content": "#include <stdlib.h>\n\nint *a, *b;\nint n;\n\n#ifdef STACK_SIZE\n#define BLOCK_SIZE (STACK_SIZE / (sizeof (*a) + sizeof (*b)))\n#else\n#define BLOCK_SIZE 32768\n#endif\nfoo ()\n{\n  int i;\n  for (i = 0; i < n; i++)\n    a[i] = -1;\n  for (i = 0; i < BLOCK_SIZE - 1; i++)\n    b[i] = -1;\n}\n\nmain ()\n{\n  n = BLOCK_SIZE;\n  a = malloc (n * sizeof(*a));\n  b = malloc (n * sizeof(*b));\n  *b++ = 0;\n  foo ();\n  if (b[-1])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960608-1.c",
    "content": "typedef struct\n{\n  unsigned char a  : 2;\n  unsigned char b  : 3;\n  unsigned char c  : 1;\n  unsigned char d  : 1;\n  unsigned char e  : 1;\n} a_struct;\n\nfoo (flags)\n     a_struct *flags;\n{\n  return (flags->c != 0\n\t  || flags->d != 1\n\t  || flags->e != 1\n\t  || flags->a != 2\n\t  || flags->b != 3);\n}\n\nmain ()\n{\n  a_struct flags;\n\n  flags.c  = 0;\n  flags.d  = 1;\n  flags.e  = 1;\n  flags.a  = 2;\n  flags.b  = 3;\n\n  if (foo (&flags) != 0)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960801-1.c",
    "content": "unsigned\nf ()\n{\n  long long l2;\n  unsigned short us;\n  unsigned long long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nunsigned long long\ng ()\n{\n  long long l2;\n  unsigned short us;\n  unsigned long long ul;\n  short s2;\n\n  ul = us = l2 = s2 = -1;\n  return ul;\n}\n\nmain ()\n{\n  if (f () != (unsigned short) -1)\n    abort ();\n  if (g () != (unsigned short) -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960802-1.c",
    "content": "long val = 0x5e000000;\n\nlong\nf1 (void)\n{\n  return 0x132;\n}\n\nlong\nf2 (void)\n{\n  return 0x5e000000;\n}\n\nvoid\nf3 (long b)\n{\n  val = b;\n}\n\nvoid\nf4 ()\n{\n  long v = f1 ();\n  long o = f2 ();\n  v = (v & 0x00ffffff) | (o & 0xff000000);\n  f3 (v);\n}\n\nmain ()\n{\n  f4 ();\n  if (val != 0x5e000132)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960830-1.c",
    "content": "#ifdef __i386__\nf (rp)\n     unsigned int *rp;\n{\n  __asm__ (\"mull %3\" : \"=a\" (rp[0]), \"=d\" (rp[1]) : \"%0\" (7), \"rm\" (7));\n}\n\nmain ()\n{\n  unsigned int s[2];\n\n  f (s);\n  if (s[1] != 0 || s[0] != 49)\n    abort ();\n exit (0);\n}\n#else\nmain ()\n{\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/960909-1.c",
    "content": "int\nffs (x)\n     int x;\n{\n  int bit, mask;\n\n  if (x == 0)\n    return 0;\n\n  for (bit = 1, mask = 1; !(x & mask); bit++, mask <<= 1)\n    ;\n\n  return bit;\n}\n\nf (x)\n     int x;\n{\n  int y;\n  y = ffs (x) - 1;\n  if (y < 0) \n    abort ();\n}\n\nmain ()\n{\n  f (1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961004-1.c",
    "content": "int k = 0;\n\nmain()\n{\n  int i;\n  int j;\n\n  for (i = 0; i < 2; i++)\n    {\n      if (k)\n\t{\n\t  if (j != 2)\n\t    abort ();\n\t}\n      else\n\t{\n\t  j = 2;\n\t  k++;\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961017-1.c",
    "content": "main ()\n{\n  unsigned char z = 0;\n\n  do ;\n  while (--z > 0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961017-2.c",
    "content": "main ()\n{\n  int i = 0;\n\n\n  if (sizeof (unsigned long int) == 4)\n    {\n      unsigned long int z = 0;\n\n      do {\n\tz -= 0x00004000;\n\ti++;\n\tif (i > 0x00040000)\n\t  abort ();\n      } while (z > 0);\n      exit (0);\n    }\n  else if (sizeof (unsigned int) == 4)\n    {\n      unsigned int z = 0;\n\n      do {\n\tz -= 0x00004000;\n\ti++;\n\tif (i > 0x00040000)\n\t  abort ();\n      } while (z > 0);\n      exit (0);\n    }\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961026-1.c",
    "content": "int\ntest (arg)\n     int arg;\n{\n  if (arg > 0 || arg == 0)\n    return 0;\n  return -1;\n}\n\nmain ()\n{\n  if (test (0) != 0)\n    abort ();\n  if (test (-1) != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961112-1.c",
    "content": "f (x)\n{\n  if (x != 0 || x == 0)\n    return 0;\n  return 1;\n}\n\nmain ()\n{\n  if (f (3))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961122-1.c",
    "content": "long long acc;\n\naddhi (short a)\n{\n  acc += (long long) a << 32;\n}\n\nsubhi (short a)\n{\n  acc -= (long long) a << 32;\n}\n\nmain ()\n{\n  acc = 0xffff00000000ll;\n  addhi (1);\n  if (acc != 0x1000000000000ll)\n    abort ();\n  subhi (1);\n  if (acc != 0xffff00000000ll)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961122-2.c",
    "content": "int\nf (int a)\n{\n  return ((a >= 0 && a <= 10) && ! (a >= 0));\n}\n\nmain ()\n{\n  if (f (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961125-1.c",
    "content": "static char *\nbegfield (int tab, char *ptr, char *lim, int sword, int schar)\n{\n  if (tab)\n    {\n      while (ptr < lim && sword--)\n\t{\n\t  while (ptr < lim && *ptr != tab)\n\t    ++ptr;\n\t  if (ptr < lim)\n\t    ++ptr;\n\t}\n    }\n  else\n    {\n      while (1)\n\t;\n    }\n\n  if (ptr + schar <= lim)\n    ptr += schar;\n\n  return ptr;\n}\n\nmain ()\n{\n  char *s = \":ab\";\n  char *lim = s + 3;\n  if (begfield (':', s, lim, 1, 1) != s + 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961206-1.c",
    "content": "int\nsub1 (unsigned long long i)\n{\n  if (i < 0x80000000)\n    return 1;\n  else\n    return 0;\n}\n\nint\nsub2 (unsigned long long i)\n{\n  if (i <= 0x7FFFFFFF)\n    return 1;\n  else\n    return 0;\n}\n\nint\nsub3 (unsigned long long i)\n{\n  if (i >= 0x80000000)\n    return 0;\n  else\n    return 1;\n}\n\nint\nsub4 (unsigned long long i)\n{\n  if (i > 0x7FFFFFFF)\n    return 0;\n  else\n    return 1;\n}\n\nmain()\n{\n  if (sub1 (0x80000000ULL))\n    abort ();\n\n  if (sub2 (0x80000000ULL))\n    abort ();\n\n  if (sub3 (0x80000000ULL))\n    abort ();\n\n  if (sub4 (0x80000000ULL))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961213-1.c",
    "content": "int\ng (unsigned long long int *v, int n, unsigned int a[], int b)\n{\n  int cnt;\n  *v = 0;\n  for (cnt = 0; cnt < n; ++cnt)\n    *v = *v * b + a[cnt];\n  return n;\n}\n\nmain ()\n{\n  int res;\n  unsigned int ar[] = { 10, 11, 12, 13, 14 };\n  unsigned long long int v;\n\n  res = g (&v, sizeof(ar)/sizeof(ar[0]), ar, 16);\n  if (v != 0xabcdeUL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/961223-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void exit (int);\nextern void abort (void);\n\nstruct s {\n  double d;\n};\n\ninline struct s\nsub (struct s s)\n{\n  s.d += 1.0;\n  return s;\n}\n\nint\nmain ()\n{\n  struct s t = { 2.0 };\n  t = sub (t);\n  if (t.d != 3.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/970214-1.c",
    "content": "#define L 1\nmain ()\n{\n  exit (L'1' != L'1');\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/970214-2.c",
    "content": "#define m(L) (L'1' + (L))\nmain ()\n{\n  exit (m (0) != L'1');\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/970217-1.c",
    "content": "sub (int i, int array[i++])\n{\n  return i;\n}\n\nmain()\n{\n  int array[10];\n  exit (sub (10, array) != 11);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/970923-1.c",
    "content": "int\nts(a)\n     int a;\n{\n  if (a < 1000 && a > 2000)\n    return 1;\n  else\n    return 0;\n}\n\nint\ntu(a)\n     unsigned int a;\n{\n  if (a < 1000 && a > 2000)\n    return 1;\n  else\n    return 0;\n}\n\n\nmain()\n{\n  if (ts (0) || tu (0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980205.c",
    "content": "#include <stdarg.h>\n\nvoid fdouble (double one, ...)\n{\n  double value;\n  va_list ap;\n\n  va_start (ap, one);\n  value = va_arg (ap, double);\n  va_end (ap);\n\n  if (one != 1.0 || value != 2.0)\n    abort ();\n}\n\nint main ()\n{\n  fdouble (1.0, 2.0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980223.c",
    "content": "typedef struct { char *addr; long type; } object;\n\nobject bar (object blah)\n{\n  abort();\n}\n\nobject foo (object x, object y)\n{\n  object z = *(object*)(x.addr);\n  if (z.type & 64)\n    {\n      y = *(object*)(z.addr+sizeof(object));\n      z = *(object*)(z.addr);\n      if (z.type & 64)\n        y = bar(y);\n    }\n  return y;\n}\n\nint nil;\nobject cons1[2] = { {(char *) &nil, 0}, {(char *) &nil, 0} };\nobject cons2[2] = { {(char *) &cons1, 64}, {(char *) &nil, 0} };\n\nmain()\n{\n  object x = {(char *) &cons2, 64};\n  object y = {(char *) &nil, 0};\n  object three = foo(x,y);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980424-1.c",
    "content": "int i, a[99];\n\nvoid f (int one)\n{\n  if (one != 1)\n    abort ();\n}\n\nvoid\ng ()\n{\n  f (a[i & 0x3f]);\n}\n\nint\nmain ()\n{\n  a[0] = 1;\n  i = 0x40;\n  g ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980505-1.c",
    "content": "static int f(int) __attribute__((const));\nint main()\n{\n   int f1, f2, x;\n   x = 1; f1 = f(x);\n   x = 2; f2 = f(x);\n   if (f1 != 1 || f2 != 2)\n     abort ();\n   exit (0);\n}\nstatic int f(int x) { return x; }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980505-2.c",
    "content": "typedef unsigned short Uint16;\ntypedef unsigned int Uint;\n\nUint f ()\n{\n        Uint16 token;\n        Uint count;\n        static Uint16 values[1] = {0x9300};\n\n        token = values[0];\n        count = token >> 8;\n\n        return count;\n}\n\nint\nmain ()\n{\n  if (f () != 0x93)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980506-1.c",
    "content": "struct decision\n{\n  char enforce_mode;             \n  struct decision *next;         \n};\n\n\nstatic void\nclear_modes (p)\n     register struct decision *p;\n{\n  goto blah;\n\nfoo:\n  p->enforce_mode = 0;\nblah:\n  if (p)\n    goto foo;\n}\n\nmain()\n{\n  struct decision *p = 0;\n  clear_modes (p);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980506-2.c",
    "content": "static void *self(void *p){ return p; }\n\nint\nf()\n{\n  struct { int i; } s, *sp;\n  int *ip = &s.i;\n\n  s.i = 1;\n  sp = self(&s);\n  \n  *ip = 0;\n  return sp->i+1;\n}\n\nmain()\n{\n  if (f () != 1)\n    abort ();\n  else\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980506-3.c",
    "content": "unsigned char lookup_table [257];\n\nstatic int \nbuild_lookup (pattern)\n     unsigned char *pattern;\n{\n  int m;\n\n  m = strlen (pattern) - 1;\n  \n  memset (lookup_table, ++m, 257);\n  return m;\n}\n\nint main(argc, argv)\n     int argc;\n     char **argv;\n{\n  if (build_lookup (\"bind\") != 4)\n    abort ();\n  else\n    exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980526-1.c",
    "content": "/* { dg-skip-if \"requires indirect jumps\" { ! indirect_jumps } { \"-O0\" } { \"\" } } */\n/* { dg-skip-if \"requires label values\" { ! label_values } { \"-O0\" } { \"\" } } */\nint expect_do1 = 1, expect_do2 = 2;\n \nstatic int doit(int x){\n  __label__ lbl1;\n  __label__ lbl2;\n  static int jtab_init = 0;\n  static void *jtab[2];\n \n  if(!jtab_init) {\n    jtab[0] = &&lbl1;\n    jtab[1] = &&lbl2;\n    jtab_init = 1;\n  }\n  goto *jtab[x];\nlbl1:\n  return 1;\nlbl2:\n  return 2;\n}\n \nstatic void do1(void) {\n  if (doit(0) != expect_do1)\n    abort ();\n}\n \nstatic void do2(void){\n  if (doit(1) != expect_do2)\n    abort ();\n}\n \nint main(void){\n#ifndef NO_LABEL_VALUES\n  do1();\n  do2();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980526-2.c",
    "content": "typedef unsigned int dev_t;\ntypedef unsigned int kdev_t;\n\nstatic inline kdev_t to_kdev_t(int dev)\n{\n\tint major, minor;\n\t\n\tif (sizeof(kdev_t) == 16)\n\t\treturn (kdev_t)dev;\n\tmajor = (dev >> 8);\n\tminor = (dev & 0xff);\n\treturn ((( major ) << 22 ) | (  minor )) ;\n\n}\n\nvoid do_mknod(const char * filename, int mode, kdev_t dev)\n{\n\tif (dev==0x15800078)\n\t\texit(0);\n\telse\n\t\tabort();\n}\n\n\nchar * getname(const char * filename)\n{\n\tregister unsigned int a1,a2,a3,a4,a5,a6,a7,a8,a9;\n\ta1 = (unsigned int)(filename) *5 + 1;\n\ta2 = (unsigned int)(filename) *6 + 2;\n\ta3 = (unsigned int)(filename) *7 + 3;\n\ta4 = (unsigned int)(filename) *8 + 4;\n\ta5 = (unsigned int)(filename) *9 + 5;\n\ta6 = (unsigned int)(filename) *10 + 5;\n\ta7 = (unsigned int)(filename) *11 + 5;\n\ta8 = (unsigned int)(filename) *12 + 5;\n\ta9 = (unsigned int)(filename) *13 + 5;\n\treturn (char *)(a1*a2+a3*a4+a5*a6+a7*a8+a9);\n}\n\nint sys_mknod(const char * filename, int mode, dev_t dev)\n{\n\tint error;\n\tchar * tmp;\n\n\ttmp = getname(filename);\n\terror = ((long)( tmp )) ;\n\tdo_mknod(tmp,mode,to_kdev_t(dev));\n\treturn error;\n}\n\nint main(void)\n{\n\tif (sizeof (int) != 4)\n\t  exit (0);\n\n\treturn sys_mknod(\"test\",1,0x12345678);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980526-3.c",
    "content": "int compare(x, y)\nunsigned int x;\nunsigned int y;\n{\n   if (x==y)\n     return 0;\n   else\n     return 1;\n}\n \nmain()\n{\n unsigned int i, j, k, l;\n i = 5; j = 2; k=0; l=2;\n if (compare(5%(~(unsigned) 2), i%~j) \n     || compare(0, k%~l))\n    abort();\n else\n    exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980602-1.c",
    "content": "main()\n{\n  int i;\n  for (i = 1; i < 100; i++)\n    ;\n  if (i == 100) \n    exit (0);\n  abort ();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980602-2.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct {\n    unsigned bit : 30;\n} t;\n\nint main()\n{\n    if (!(t.bit++))\n\texit (0);\n    else\n\tabort ();\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980604-1.c",
    "content": "int a = 1;\nint b = -1;\n\nint c = 1;\nint d = 0;\n\nmain ()\n{\n  double e;\n  double f;\n  double g;\n\n  f = c;\n  g = d;\n  e = (a < b) ? f : g;\n  if (e)\n    abort ();\n  exit(0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980605-1.c",
    "content": "#include <stdio.h>\n\n#ifndef STACK_SIZE\n#define STACK_SIZE 200000\n#endif\n\n__inline__ static int\ndummy (x)\n{\n  int y;\n  y = (long) (x * 4711.3);\n  return y;\n}\n\nint getval (void);\n\nint\nf2 (double x)\n{\n  unsigned short s;\n  int a, b, c, d, e, f, g, h, i, j;\n\n  a = getval ();\n  b = getval ();\n  c = getval ();\n  d = getval ();\n  e = getval ();\n  f = getval ();\n  g = getval ();\n  h = getval ();\n  i = getval ();\n  j = getval ();\n\n\n  s = x;\n\n  return a + b + c + d + e + f + g + h + i + j + s;\n}\n\nint x = 1;\n\nint\ngetval (void)\n{\n  return x++;\n}\n\nchar buf[10];\n\nvoid\nf ()\n{\n  char ar[STACK_SIZE/2];\n  int a, b, c, d, e, f, g, h, i, j, k;\n\n  a = getval ();\n  b = getval ();\n  c = getval ();\n  d = getval ();\n  e = getval ();\n  f = getval ();\n  g = getval ();\n  h = getval ();\n  i = getval ();\n  j = getval ();\n\n  k = f2 (17.0);\n\n  sprintf (buf, \"%d\\n\", a + b + c + d + e + f + g + h + i + j + k);\n  if (a + b + c + d + e + f + g + h + i + j + k != 227)\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980608-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\n#include <stdarg.h>\n\nextern void abort(void);\nextern void exit (int);\n\nvoid f1(int a,int b,int c,int d,int e, int f,int g,int h,int i,int j, int k,int\nl,int m,int n,int o)\n{\n    return;\n}\n\ninline void debug(const char *msg,...)\n{\n    va_list ap;\n    va_start( ap, msg );\n\n    f1(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);\n\n    if ( va_arg(ap,int) != 101)\n        abort();\n    if ( va_arg(ap,int) != 102)\n        abort();\n    if ( va_arg(ap,int) != 103)\n        abort();\n    if ( va_arg(ap,int) != 104)\n        abort();\n    if ( va_arg(ap,int) != 105)\n        abort();\n    if ( va_arg(ap,int) != 106)\n        abort();\n\n    va_end( ap );\n}\n\nint main(void)\n{\n  debug(\"%d %d %d  %d %d %d\\n\", 101, 102, 103, 104, 105, 106);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980612-1.c",
    "content": "struct fd\n{\n\tunsigned char a;\n\tunsigned char b;\n} f = { 5 };\n\nstruct fd *g() { return &f; }\nint h() { return -1; }\n\nint main()\n{\n\tstruct fd *f = g();\n\tf->b = h();\n\tif (((f->a & 0x7f) & ~0x10) <= 2)\n\t\tabort ();\n\texit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980617-1.c",
    "content": "void foo (unsigned int * p)\n{\n  if ((signed char)(*p & 0xFF) == 17 || (signed char)(*p & 0xFF) == 18)\n    return;\n  else\n    abort ();\n}\n\nint main ()\n{\n  int i = 0x30011;\n  foo(&i);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980618-1.c",
    "content": "void func(int, int);\n\nint main()\n{\n        int x = 7;\n        func(!x, !7);\n\texit (0);\n}\n\nvoid func(int x, int y)\n{\n        if (x == y)\n                return;\n        else\n                abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980701-1.c",
    "content": "ns_name_skip (unsigned char **x, unsigned char *y)\n{\n  *x = 0;\n  return 0;\n}\n\nunsigned char a[2];\n\nint dn_skipname(unsigned char *ptr, unsigned char *eom) {\n    unsigned char *saveptr = ptr;\n\n    if (ns_name_skip(&ptr, eom) == -1)\n\t        return (-1);\n    return (ptr - saveptr);\n}\n\nmain()\n{\n  if (dn_skipname (&a[0], &a[1]) == 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980707-1.c",
    "content": "#include <stdlib.h>\n#include <string.h>\n\nchar **\nbuildargv (char *input)\n{\n  static char *arglist[256];\n  int numargs = 0;\n\n  while (1)\n    {\n      while (*input == ' ')\n\tinput++;\n      if (*input == 0)\n\tbreak;\n      arglist [numargs++] = input;\n      while (*input != ' ' && *input != 0)\n\tinput++;\n      if (*input == 0)\n\tbreak;\n      *(input++) = 0;\n    }\n  arglist [numargs] = NULL;\n  return arglist;\n}\n\n\nint main()\n{\n  char **args;\n  char input[256];\n  int i;\n\n  strcpy(input, \" a b\");\n  args = buildargv(input);\n\n  if (strcmp (args[0], \"a\"))\n    abort ();\n  if (strcmp (args[1], \"b\"))\n    abort ();\n  if (args[2] != NULL)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980709-1.c",
    "content": "/* { dg-xfail-if \"Can not call system libm.a with -msoft-float\" { powerpc-*-aix* rs6000-*-aix* } { \"-msoft-float\" } { \"\" } } */\n#include <math.h>\n\nmain()\n{\n  volatile double a;\n  double c;\n  a = 32.0;\n  c = pow(a, 1.0/3.0);\n  if (c + 0.1 > 3.174802\n      && c - 0.1 < 3.174802)\n    exit (0);\n  else\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980716-1.c",
    "content": "#include <stdarg.h>\n\nvoid\nstub(int num, ...)\n{\n    va_list ap;\n    char *end;\n    int i;\n\n    for (i = 0; i < 2; i++) {\n        va_start(ap, num);\n        while ( 1 ) {\n            end = va_arg(ap, char *);\n            if (!end) break;\n        }\n        va_end(ap);\n    }\n}\n\nint\nmain()\n{\n    stub(1, \"ab\", \"bc\", \"cx\", (char *)0);\n    exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/980929-1.c",
    "content": "void f(int i)\n{\n  if (i != 1000)\n    abort ();\n}\n\n\nint main()\n{\n  int n=1000;\n  int i;\n\n  f(n);\n  for(i=0; i<1; ++i) {\n    f(n);\n    n=666;\n    &n;\n  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/981001-1.c",
    "content": "#define NG   0x100L\n\nunsigned long flg = 0;\n\nlong sub (int n)\n{\n  int a, b ;\n\n  if (n >= 2)\n    {\n      if (n % 2 == 0)\n\t{\n\t  a = sub (n / 2);\n\t  \n\t  return (a + 2 * sub (n / 2 - 1)) * a;\n\t}\n      else\n\t{\n\t  a = sub (n / 2 + 1);\n\t  b = sub (n / 2);\n\t  \n\t  return a * a + b * b;\n\t}\n    }\n  else \n    return (long) n;\n}\n\nint main (void)\n{\n  if (sub (30) != 832040L)\n    flg |= NG;\n\n  if (flg)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/981019-1.c",
    "content": "/* { dg-skip-if \"ptxas seg faults\" { nvptx-*-* } { \"-O3*\" } { \"\" } } */\n\nextern int f2(void);\nextern int f3(void);\nextern void f1(void);\n\nvoid\nff(int fname, int part, int nparts)\n{\n  if (fname)  /* bb 0 */\n    {\n      if (nparts)  /* bb 1 */\n\tf1();  /* bb 2 */\n    }\n  else\n    fname = 2; /* bb 3  */\n\n  /* bb 4 is the branch to bb 10\n     (bb 10 is physically at the end of the loop) */\n  while (f3() /* bb 10 */)\n    {\n      if (nparts /* bb 5 */ && f2() /* bb 6 */)\n\t{\n\t  f1();  /* bb 7 ... */\n\t  nparts = part;\n\t  if (f3())  /* ... bb 7 */\n\t    f1();  /* bb 8 */\n\t  f1(); /* bb 9 */\n\t  break;\n\t}\n    }\n\n  if (nparts)  /* bb 11 */\n    f1(); /* bb 12 */\n  return; /* bb 13 */\n}\n\nint main(void)\n{\n  ff(0, 1, 0);\n  return 0;\n}\n\nint f3(void) { static int x = 0; x = !x; return x; }\nvoid f1(void) { abort(); }\nint f2(void) { abort(); }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/981130-1.c",
    "content": "/* { dg-xfail-if \"alias analysis conflicts with instruction scheduling\" { m32r-*-* } { \"-O2\" \"-O1\" \"-O0\" \"-Os\"} { \"\" } } */\nstruct s { int a; int b;};\nstruct s s1;\nstruct s s2 = { 1, 2, };\n\nvoid\ncheck (a, b)\n     int a;\n     int b;\n{\n  if (a == b)\n    exit (0);\n  else\n    abort ();\n}\n\nint\nmain ()\n{\n  int * p;\n  int x;\n  \n  s1.a = 9;\n  p    = & s1.a;\n  s1   = s2;\n  x    = * p;\n  \n  check (x, 1);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/981206-1.c",
    "content": "/* Verify unaligned address aliasing on Alpha EV[45].  */\n\nstatic unsigned short x, y;\n\nvoid foo()\n{\n  x = 0x345;\n  y = 0x567;\n}\n\nint main()\n{\n  foo ();\n  if (x != 0x345 || y != 0x567)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990106-1.c",
    "content": "foo(bufp)\nchar *bufp;\n{\n    int x = 80;\n    return (*bufp++ = x ? 'a' : 'b');\n}\n\nmain()\n{\n  char x;\n\n  if (foo (&x) != 'a')\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990106-2.c",
    "content": "unsigned calc_mp(unsigned mod)\n{\n      unsigned a,b,c;\n      c=-1;\n      a=c/mod;\n      b=0-a*mod;\n      if (b > mod) { a += 1; b-=mod; }\n      return b;\n}\n\nint main(int argc, char *argv[])\n{\n      unsigned x = 1234;\n      unsigned y = calc_mp(x);\n\n      if ((sizeof (y) == 4 && y != 680)\n\t  || (sizeof (y) == 2 && y != 134))\n\tabort ();\n      exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990117-1.c",
    "content": "int\nfoo (int x, int y, int i, int j)\n{\n  double tmp1 = ((double) x / y);\n  double tmp2 = ((double) i / j);\n\n  return tmp1 < tmp2;\n}\n\nmain ()\n{\n  if (foo (2, 24, 3, 4) == 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990127-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nmain()\n{\n    int a,b,c;\n    int *pa, *pb, *pc;\n    int **ppa, **ppb, **ppc;\n    int i,j,k,x,y,z;\n\n    a = 10;\n    b = 20;\n    c = 30;\n    pa = &a; pb = &b; pc = &c;\n    ppa = &pa; ppb = &pb; ppc = &pc;\n    x = 0; y = 0; z = 0;\n\n    for(i=0;i<10;i++){\n        if( pa == &a ) pa = &b;\n        else pa = &a;\n        while( (*pa)-- ){\n            x++;\n            if( (*pa) < 3 ) break;\n            else pa = &b;\n        }\n        x++;\n        pa = &b;\n    }\n\n    if ((*pa) != -5 || (*pb) != -5 || x != 43)\n      abort ();\n\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990127-2.c",
    "content": "/* { dg-options \"-mpc64\"  { target { i?86-*-* x86_64-*-* } } } */\n\nextern void abort (void);\nextern void exit (int);\n\nvoid\nfpEq (double x, double y)\n{\n  if (x != y)\n    abort ();\n}\n\nvoid\nfpTest (double x, double y)\n{\n  double result1 = (35.7 * 100.0) / 45.0;\n  double result2 = (x * 100.0) / y;\n  fpEq (result1, result2);\n}\n\nint\nmain ()\n{\n  fpTest (35.7, 45.0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990128-1.c",
    "content": "extern int printf (const char *,...);\n\nstruct s { struct s *n; } *p;\nstruct s ss;\n#define MAX     10\nstruct s sss[MAX];\nint count = 0;\n\nvoid sub( struct s *p, struct s **pp );\nint look( struct s *p, struct s **pp );\n\nmain()\n{\n    struct s *pp;\n    struct s *next;\n    int i;\n\n    p = &ss;\n    next = p;\n    for ( i = 0; i < MAX; i++ ) {\n        next->n = &sss[i];\n        next = next->n;\n    }\n    next->n = 0;\n\n    sub( p, &pp );\n    if (count != MAX+2)\n      abort ();\n\n    exit( 0 );\n}\n\nvoid sub( struct s *p, struct s **pp )\n{\n   for ( ; look( p, pp ); ) {\n        if ( p )\n            p = p->n;\n        else\n            break;\n   }\n}\n\nint look( struct s *p, struct s **pp )\n{\n    for ( ; p; p = p->n )\n        ;\n    *pp = p;\n    count++;\n    return( 1 );\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990130-1.c",
    "content": "int count = 0;\nint dummy;\n\nstatic int *\nbar(void)\n{\n  ++count;\n  return &dummy;\n}\n\nstatic void\nfoo(void)\n{\n  asm(\"\" : \"+r\"(*bar()));\n}\n\nmain()\n{\n  foo();\n  if (count != 1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990208-1.c",
    "content": "/* As a quality of implementation issue, we should not prevent inlining\n   of function explicitly marked inline just because a label therein had\n   its address taken.  */\n\n#ifndef NO_LABEL_VALUES\nstatic void *ptr1, *ptr2;\nstatic int i = 1;\n\nstatic __inline__ void doit(void **pptr, int cond)\n{\n  if (cond) {\n  here:\n    *pptr = &&here;\n  }\n}\n\n__attribute__ ((noinline))\nstatic void f(int cond)\n{\n  doit (&ptr1, cond);\n}\n\n__attribute__ ((noinline))\nstatic void g(int cond)\n{\n  doit (&ptr2, cond);\n}\n\n__attribute__ ((noinline))\nstatic void bar(void);\n\nint main()\n{\n  f (i);\n  bar();\n  g (i);\n\n#ifdef  __OPTIMIZE__\n  if (ptr1 == ptr2)\n    abort ();\n#endif\n\n  exit (0);\n}\n\nvoid bar(void) { }\n\n#else /* NO_LABEL_VALUES */\nint main() { exit(0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990211-1.c",
    "content": "/* Copyright (C) 1999 Free Software Foundation, Inc.\n  Contributed by Nathan Sidwell 20 Jan 1999 <nathan@acm.org> */\n\n/* check range combining boolean operations work */\n\nextern void abort();\n\n#define N 77\n\nvoid func(int i)\n{\n  /* fold-const does some clever things with range tests. Make sure\n     we get (some of) them right */\n  \n  /* these must fail, regardless of the value of i */\n  if ((i < 0) && (i >= 0))\n    abort();\n  if ((i > 0) && (i <= 0))\n    abort();\n  if ((i >= 0) && (i < 0))\n    abort();\n  if ((i <= 0) && (i > 0))\n    abort();\n\n  if ((i < N) && (i >= N))\n    abort();\n  if ((i > N) && (i <= N))\n    abort();\n  if ((i >= N) && (i < N))\n    abort();\n  if ((i <= N) && (i > N))\n    abort();\n    \n  /* these must pass, regardless of the value of i */\n  if (! ((i < 0) || (i >= 0)))\n    abort();\n  if (! ((i > 0) || (i <= 0)))\n    abort();\n  if (! ((i >= 0) || (i < 0)))\n    abort();\n  if (! ((i <= 0) || (i > 0)))\n    abort();\n\n  if (! ((i < N) || (i >= N)))\n    abort();\n  if (! ((i > N) || (i <= N)))\n    abort();\n  if (! ((i >= N) || (i < N)))\n    abort();\n  if (! ((i <= N) || (i > N)))\n    abort();\n  \n  return;\n}\n\nint main()\n{\n  func(0);\n  func(1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990222-1.c",
    "content": "char line[4] = { '1', '9', '9', '\\0' };\n\nint main()\n{\n  char *ptr = line + 3;\n\n  while ((*--ptr += 1) > '9') *ptr = '0';\n  if (line[0] != '2' || line[1] != '0' || line[2] != '0')\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990324-1.c",
    "content": "void f(long i)\n{\n  if ((signed char)i < 0 || (signed char)i == 0) \n    abort ();\n  else\n    exit (0);\n}\n\nmain()\n{\n  f(0xffffff01);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990326-1.c",
    "content": "struct a {\n\tchar a, b;\n\tshort c;\n};\n\nint\na1()\n{\n\tstatic struct a x = { 1, 2, ~1 }, y = { 65, 2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\na2()\n{\n\tstatic struct a x = { 1, 66, ~1 }, y = { 1, 2, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\na3()\n{\n\tstatic struct a x = { 9, 66, ~1 }, y = { 33, 18, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct b {\n\tint c;\n\tshort b, a;\n};\n\nint\nb1()\n{\n\tstatic struct b x = { ~1, 2, 1 }, y = { ~2, 2, 65 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nb2()\n{\n\tstatic struct b x = { ~1, 66, 1 }, y = { ~2, 2, 1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nb3()\n{\n\tstatic struct b x = { ~1, 66, 9 }, y = { ~2, 18, 33 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct c {\n\tunsigned int c:4, b:14, a:14;\n} __attribute__ ((aligned));\n\nint\nc1()\n{\n\tstatic struct c x = { ~1, 2, 1 }, y = { ~2, 2, 65 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nc2()\n{\n\tstatic struct c x = { ~1, 66, 1 }, y = { ~2, 2, 1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nc3()\n{\n\tstatic struct c x = { ~1, 66, 9 }, y = { ~2, 18, 33 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct d {\n\tunsigned int a:14, b:14, c:4;\n} __attribute__ ((aligned));\n\nint\nd1()\n{\n\tstatic struct d x = { 1, 2, ~1 }, y = { 65, 2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nd2()\n{\n\tstatic struct d x = { 1, 66, ~1 }, y = { 1, 2, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nd3()\n{\n\tstatic struct d x = { 9, 66, ~1 }, y = { 33, 18, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nstruct e {\n\tint c:4, b:14, a:14;\n} __attribute__ ((aligned));\n\nint\ne1()\n{\n\tstatic struct e x = { ~1, -2, -65 }, y = { ~2, -2, -1 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\ne2()\n{\n\tstatic struct e x = { ~1, -2, -1 }, y = { ~2, -66, -1 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\ne3()\n{\n\tstatic struct e x = { ~1, -18, -33 }, y = { ~2, -66, -9 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\ne4()\n{\n\tstatic struct e x = { -1, -1, 0 };\n\n\treturn x.a == 0 && x.b & 0x2000;\n}\n\nstruct f {\n\tint a:14, b:14, c:4;\n} __attribute__ ((aligned));\n\nint\nf1()\n{\n\tstatic struct f x = { -65, -2, ~1 }, y = { -1, -2, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nf2()\n{\n\tstatic struct f x = { -1, -2, ~1 }, y = { -1, -66, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nf3()\n{\n\tstatic struct f x = { -33, -18, ~1 }, y = { -9, -66, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\nf4()\n{\n\tstatic struct f x = { 0, -1, -1 };\n\n\treturn x.a == 0 && x.b & 0x2000;\n}\n\nstruct gx {\n\tint c:4, b:14, a:14;\n} __attribute__ ((aligned));\nstruct gy {\n\tint b:14, a:14, c:4;\n} __attribute__ ((aligned));\n\nint\ng1()\n{\n\tstatic struct gx x = { ~1, -2, -65 };\n\tstatic struct gy y = { -2, -1, ~2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\ng2()\n{\n\tstatic struct gx x = { ~1, -2, -1 };\n\tstatic struct gy y = { -66, -1, ~2 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\ng3()\n{\n\tstatic struct gx x = { ~1, -18, -33 };\n\tstatic struct gy y = { -66, -9, ~2 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\ng4()\n{\n\tstatic struct gx x = { ~1, 0x0020, 0x0010 };\n\tstatic struct gy y = { 0x0200, 0x0100, ~2 };\n\n\treturn ((x.a & 0x00f0) == (y.a & 0x0f00) &&\n\t\t(x.b & 0x00f0) == (y.b & 0x0f00));\n}\n\nint\ng5()\n{\n\tstatic struct gx x = { ~1, 0x0200, 0x0100 };\n\tstatic struct gy y = { 0x0020, 0x0010, ~2 };\n\n\treturn ((x.a & 0x0f00) == (y.a & 0x00f0) &&\n\t\t(x.b & 0x0f00) == (y.b & 0x00f0));\n}\n\nint\ng6()\n{\n\tstatic struct gx x = { ~1, 0xfe20, 0xfd10 };\n\tstatic struct gy y = { 0xc22f, 0xc11f, ~2 };\n\n\treturn ((x.a & 0x03ff) == (y.a & 0x3ff0) &&\n\t\t(x.b & 0x03ff) == (y.b & 0x3ff0));\n}\n\nint\ng7()\n{\n\tstatic struct gx x = { ~1, 0xc22f, 0xc11f };\n\tstatic struct gy y = { 0xfe20, 0xfd10, ~2 };\n\n\treturn ((x.a & 0x3ff0) == (y.a & 0x03ff) &&\n\t\t(x.b & 0x3ff0) == (y.b & 0x03ff));\n}\n\nstruct hx {\n\tint a:14, b:14, c:4;\n} __attribute__ ((aligned));\nstruct hy {\n\tint c:4, a:14, b:14;\n} __attribute__ ((aligned));\n\nint\nh1()\n{\n\tstatic struct hx x = { -65, -2, ~1 };\n\tstatic struct hy y = { ~2, -1, -2 };\n\n\treturn (x.a == (y.a & ~64) && x.b == y.b);\n}\n\nint\nh2()\n{\n\tstatic struct hx x = { -1, -2, ~1 };\n\tstatic struct hy y = { ~2, -1, -66 };\n\n\treturn (x.a == y.a && (x.b & ~64) == y.b);\n}\n\nint\nh3()\n{\n\tstatic struct hx x = { -33, -18, ~1 };\n\tstatic struct hy y = { ~2, -9, -66 };\n\n\treturn ((x.a & ~8) == (y.a & ~32) && (x.b & ~64) == (y.b & ~16));\n}\n\nint\nh4()\n{\n\tstatic struct hx x = { 0x0010, 0x0020, ~1 };\n\tstatic struct hy y = { ~2, 0x0100, 0x0200 };\n\n\treturn ((x.a & 0x00f0) == (y.a & 0x0f00) &&\n\t\t(x.b & 0x00f0) == (y.b & 0x0f00));\n}\n\nint\nh5()\n{\n\tstatic struct hx x = { 0x0100, 0x0200, ~1 };\n\tstatic struct hy y = { ~2, 0x0010, 0x0020 };\n\n\treturn ((x.a & 0x0f00) == (y.a & 0x00f0) &&\n\t\t(x.b & 0x0f00) == (y.b & 0x00f0));\n}\n\nint\nh6()\n{\n\tstatic struct hx x = { 0xfd10, 0xfe20, ~1 };\n\tstatic struct hy y = { ~2, 0xc11f, 0xc22f };\n\n\treturn ((x.a & 0x03ff) == (y.a & 0x3ff0) &&\n\t\t(x.b & 0x03ff) == (y.b & 0x3ff0));\n}\n\nint\nh7()\n{\n\tstatic struct hx x = { 0xc11f, 0xc22f, ~1 };\n\tstatic struct hy y = { ~2, 0xfd10, 0xfe20 };\n\n\treturn ((x.a & 0x3ff0) == (y.a & 0x03ff) &&\n\t\t(x.b & 0x3ff0) == (y.b & 0x03ff));\n}\n\nint\nmain()\n{\n  if (!a1 ())\n    abort ();\n  if (!a2 ())\n    abort ();\n  if (!a3 ())\n    abort ();\n  if (!b1 ())\n    abort ();\n  if (!b2 ())\n    abort ();\n  if (!b3 ())\n    abort ();\n  if (!c1 ())\n    abort ();\n  if (!c2 ())\n    abort ();\n  if (!c3 ())\n    abort ();\n  if (!d1 ())\n    abort ();\n  if (!d2 ())\n    abort ();\n  if (!d3 ())\n    abort ();\n  if (!e1 ())\n    abort ();\n  if (!e2 ())\n    abort ();\n  if (!e3 ())\n    abort ();\n  if (!e4 ())\n    abort ();\n  if (!f1 ())\n    abort ();\n  if (!f2 ())\n    abort ();\n  if (!f3 ())\n    abort ();\n  if (!f4 ())\n    abort ();\n  if (!g1 ())\n    abort ();\n  if (!g2 ())\n    abort ();\n  if (!g3 ())\n    abort ();\n  if (g4 ())\n    abort ();\n  if (g5 ())\n    abort ();\n  if (!g6 ())\n    abort ();\n  if (!g7 ())\n    abort ();\n  if (!h1 ())\n    abort ();\n  if (!h2 ())\n    abort ();\n  if (!h3 ())\n    abort ();\n  if (h4 ())\n    abort ();\n  if (h5 ())\n    abort ();\n  if (!h6 ())\n    abort ();\n  if (!h7 ())\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990404-1.c",
    "content": "\nint x[10] = { 0,1,2,3,4,5,6,7,8,9};\n\nint\nmain()\n{\n  int niterations = 0, i;\n\n  for (;;) {\n    int i, mi, max;\n    max = 0;\n    for (i = 0; i < 10 ; i++) {\n      if (x[i] > max) {\n\tmax = x[i];\n\tmi = i;\n      }\n    }\n    if (max == 0)\n      break;\n    x[mi] = 0;\n    niterations++;\n    if (niterations > 10)\n      abort ();\n  }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990413-2.c",
    "content": "/* This tests for a bug in regstack that was breaking glibc's math library. */\n/* { dg-skip-if \"\" { ! { i?86-*-* x86_64-*-* } } { \"*\" } { \"\" } } */\n\nextern void abort (void);\n\nstatic __inline double\nminus_zero (void)\n{\n  union { double __d; int __i[2]; } __x;\n  __x.__i[0] = 0x0;\n  __x.__i[1] = 0x80000000;\n  return __x.__d;\n}\n\nstatic __inline long double\n__atan2l (long double __y, long double __x)\n{\n  register long double __value;\n  __asm __volatile__ (\"fpatan\\n\\t\"\n\t\t      : \"=t\" (__value)\n\t\t      : \"0\" (__x), \"u\" (__y)\n\t\t      : \"st(1)\");\n  return __value;\n}\n\nstatic __inline long double\n__sqrtl (long double __x)\n{\n  register long double __result;\n  __asm __volatile__ (\"fsqrt\" : \"=t\" (__result) : \"0\" (__x));\n  return __result;\n}\n\nstatic __inline double\nasin (double __x)\n{\n  return __atan2l (__x, __sqrtl (1.0 - __x * __x));\n}\n\nint\nmain (void)\n{\n  double x;\n\n  x = minus_zero();\n  x = asin (x);\n\n  if (x != 0.0) /* actually -0.0, but 0.0 == -0.0 */\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990513-1.c",
    "content": "#include <string.h>\n\nvoid foo (int *BM_tab, int j)\n{\n  int *BM_tab_base;\n\n  BM_tab_base = BM_tab;\n  BM_tab += 0400;\n  while (BM_tab_base != BM_tab)\n    {\n      *--BM_tab = j;\n      *--BM_tab = j;\n      *--BM_tab = j;\n      *--BM_tab = j;\n    }\n}\n\nint main ()\n{\n  int BM_tab[0400];\n  memset (BM_tab, 0, sizeof (BM_tab));\n  foo (BM_tab, 6);\n  if (BM_tab[0] != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990524-1.c",
    "content": "char a[] = \"12345\";\nchar b[] = \"12345\";\n\nvoid loop (char * pz, char * pzDta)\n{\n    for (;;) {\n        switch (*(pz++) = *(pzDta++)) {\n        case 0:\n  \t    goto loopDone2;\n\n\tcase '\"':\n\tcase '\\\\':\n\t    pz[-1]  = '\\\\';\n            *(pz++) = pzDta[-1];\n\t}\n    } loopDone2:;\n\n  if (a - pz != b - pzDta)\n    abort ();\n}\n\nmain()\n{\n  loop (a, b);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990525-1.c",
    "content": "struct blah {\n    int m1, m2;\n};\n\nvoid die(struct blah arg)\n{\n    int i ;\n    struct blah buf[1];\n\n    for (i = 0; i < 1 ; buf[i++] = arg)\n        ;\n    if (buf[0].m1 != 1) {\n        abort ();\n    }\n}\n\nint main()\n{\n    struct blah s = { 1, 2 };\n\n    die(s);\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990525-2.c",
    "content": "typedef struct {\n    int v[4];\n} Test1;\n\nTest1 func2();\n\nint func1()\n{\n    Test1 test;\n    test = func2();\n\n    if (test.v[0] != 10)\n      abort ();\n    if (test.v[1] != 20)\n      abort ();\n    if (test.v[2] != 30)\n      abort ();\n    if (test.v[3] != 40)\n      abort ();\n}\n\nTest1 func2()\n{\n    Test1 tmp;\n    tmp.v[0] = 10;\n    tmp.v[1] = 20;\n    tmp.v[2] = 30;\n    tmp.v[3] = 40;\n    return tmp;\n}\n\n\nint main()\n{\n    func1();\n    exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990527-1.c",
    "content": "int sum;\n\nvoid\ng (int i)\n{\n  sum += i;\n}\n\nvoid\nf(int j)\n{\n  int i;\n\n  for (i = 0; i < 9; i++)\n    {\n      j++;\n      g (j);\n      j = 9;\n    }\n}\n\nint\nmain ()\n{\n  f (0);\n  if (sum != 81)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990531-1.c",
    "content": "   unsigned long bad(int reg, unsigned long inWord)\n   {\n       union {\n           unsigned long word;\n           unsigned char byte[4];\n       } data;\n\n       data.word = inWord;\n       data.byte[reg] = 0;\n\n       return data.word;\n   }\n\nmain()\n{\n  /* XXX This test could be generalized.  */\n  if (sizeof (long) != 4)\n    exit (0);\n\n  if (bad (0, 0xdeadbeef) == 0xdeadbeef)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990604-1.c",
    "content": "int b;\nvoid f ()\n{\n  int i = 0;\n  if (b == 0)\n    do {\n      b = i;\n      i++;\n    } while (i < 10);\n}\n\nint main ()\n{\n  f ();\n  if (b != 9)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990628-1.c",
    "content": "#include <stdlib.h>\n\nstruct {\n    long sqlcode;\n} sqlca;\n\n\nstruct data_record {\n    int dummy;\n    int a[100];\n} *data_ptr, data_tmp;\n\n\nint\nnum_records()\n{\n    return 1;\n}\n\n\nvoid\nfetch()\n{\n    static int fetch_count;\n\n    memset(&data_tmp, 0x55, sizeof(data_tmp));\n    sqlca.sqlcode = (++fetch_count > 1 ? 100 : 0);\n}\n\n\nvoid\nload_data() {\n    struct data_record *p;\n    int num = num_records();\n\n    data_ptr = malloc(num * sizeof(struct data_record));\n    memset(data_ptr, 0xaa, num * sizeof(struct data_record));\n\n    fetch();\n    p = data_ptr;\n    while (sqlca.sqlcode == 0) {\n        *p++ = data_tmp;\n        fetch();\n    }\n}\n\n\nmain()\n{\n    load_data();\n    if (sizeof (int) == 2 && data_ptr[0].dummy != 0x5555)\n      abort ();\n    else if (sizeof (int) > 2 && data_ptr[0].dummy != 0x55555555)\n      abort ();\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990804-1.c",
    "content": "int gfbyte ( void ) \n{\n return 0;\n} \n\nint main( void ) \n{\n int i,j,k ;\n\n i = gfbyte();\n\n i = i + 1 ;\n\n if ( i == 0 ) \n     k = -0 ;\n else\n     k = i + 0 ;\n\n if (i != 1)\n   abort ();\n\n k = 1 ;\n if ( k <= i)\n     do \n\t j = gfbyte () ;\n     while ( k++ < i ) ;\n\n exit (0);\n} \n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990811-1.c",
    "content": "struct s {long a; int b;};\n\nint foo(int x, void *y)\n{\n  switch(x) {\n    case 0: return ((struct s*)y)->a;\n    case 1: return *(signed char*)y;\n    case 2: return *(short*)y;\n  }\n  abort();\n}\n\nint main ()\n{\n  struct s s;\n  short sh[10];\n  signed char c[10];\n  int i;\n\n  s.a = 1;\n  s.b = 2;\n  for (i = 0; i < 10; i++) {\n    sh[i] = i;\n    c[i] = i;\n  }\n\n  if (foo(0, &s) != 1) abort();\n  if (foo(1, c+3) != 3) abort();\n  if (foo(2, sh+3) != 3) abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990826-0.c",
    "content": "/*\nFrom: niles@fan745.gsfc.nasa.gov\nTo: fortran@gnu.org\nSubject: Re: Scary problems in g77 for RedHat 6.0. (glibc-2.1) \nDate: Sun, 06 Jun 1999 23:37:23 -0400\nX-UIDL: 9c1e40c572e3b306464f703461764cd5\n*/\n\n/* { dg-xfail-if \"Can not call system libm.a with -msoft-float\" { powerpc-*-aix* rs6000-*-aix* } { \"-msoft-float\" } { \"\" } } */\n\n#include <stdio.h>\n#include <math.h>\n\nint\nmain()\n{\n  if (floor (0.1) != 0.)\n    abort ();\n  return 0;\n}\n\n/*\nIt will result in 36028797018963968.000000 on Alpha RedHat Linux 6.0\nusing glibc-2.1 at least on my 21064.  This may result in g77 bug\nreports concerning the INT() function, just so you know.\n\n\tThanks,\t\n\tRick Niles.\n*/\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990827-1.c",
    "content": "unsigned test(unsigned one , unsigned  bit)\n{\n    unsigned val=  bit & 1;\n    unsigned zero= one >> 1;\n\n    val++;\n    return zero + ( val>> 1 );\n}\n\nint main()\n{\n  if (test (1,0) != 0)\n    abort ();\n  if (test (1,1) != 1)\n    abort ();\n  if (test (1,65535) != 1)\n    abort ();\n  exit (0);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990829-1.c",
    "content": "double test (const double le, const double ri)\n{\n\tdouble val = ( ri - le ) / ( ri * ( le + 1.0 ) );\n\treturn val;\n}\n\nint main ()\n{\n        double retval;\n\n\tretval = test(1.0,2.0);\n        if (retval < 0.24 || retval > 0.26)\n\t  abort ();\n\texit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/990923-1.c",
    "content": "#define mask  0xffff0000L\n#define value 0xabcd0000L\n\nlong\nfoo (long x)\n{\n  if ((x & mask) == value)\n    return x & 0xffffL;\n  return 1;\n}\n\nint \nmain (void)\n{\n  if (foo (value) != 0 || foo (0) != 1)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991014-1.c",
    "content": "\ntypedef __SIZE_TYPE__ Size_t;\n\n#if __SIZEOF_LONG__ < __SIZEOF_POINTER__\n#define bufsize ((1LL << (8 * sizeof(Size_t) - 2))-256)\n#else\n#define bufsize ((1L << (8 * sizeof(Size_t) - 2))-256)\n#endif\n\nstruct huge_struct\n{\n  short buf[bufsize];\n  int a;\n  int b;\n  int c;\n  int d;\n};\n\nunion huge_union\n{\n  int a;\n  char buf[bufsize];\n};\n\nSize_t union_size()\n{\n  return sizeof(union huge_union);\n}\n\nSize_t struct_size()\n{\n  return sizeof(struct huge_struct);\n}\n\nSize_t struct_a_offset()\n{\n  return (Size_t)(&((struct huge_struct *) 0)->a);\n}\n\nint main()\n{\n  /* Check the exact sizeof value. bufsize is aligned on 256b. */\n  if (union_size() != sizeof(char) * bufsize)\n    abort();\n\n  if (struct_size() != sizeof(short) * bufsize + 4*sizeof(int))\n    abort();\n\n  if (struct_a_offset() < sizeof(short) * bufsize)\n    abort();  \n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991016-1.c",
    "content": "/* Two of these types will, on current gcc targets, have the same\n   mode but have different alias sets.  DOIT tries to get gcse to\n   invalidly hoist one of the values out of the loop.  */\n\ntypedef int T0;\ntypedef long T1;\ntypedef long long T2;\n\nint\ndoit(int sel, int n, void *p)\n{\n  T0 * const p0 = p;\n  T1 * const p1 = p;\n  T2 * const p2 = p;\n\n  switch (sel)\n    {\n    case 0:\n      do \n\t*p0 += *p0;\n      while (--n);\n      return *p0 == 0;\n\n    case 1:\n      do \n\t*p1 += *p1;\n      while (--n);\n      return *p1 == 0;\n\n    case 2:\n      do \n\t*p2 += *p2;\n      while (--n);\n      return *p2 == 0;\n\n    default:\n      abort ();\n    }\n}\n\nint\nmain()\n{\n  T0 v0; T1 v1; T2 v2;\n\n  v0 = 1; doit(0, 5, &v0);\n  v1 = 1; doit(1, 5, &v1);\n  v2 = 1; doit(2, 5, &v2);\n\n  if (v0 != 32) abort ();\n  if (v1 != 32) abort ();\n  if (v2 != 32) abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991019-1.c",
    "content": "typedef struct {\n     double epsilon;\n} material_type;\n\nmaterial_type foo(double x)\n{\n     material_type m;\n\n     m.epsilon = 1.0 + x;\n     return m;\n}\n\nmain()\n{\n  int i;\n  material_type x;\n\n  /* We must iterate enough times to overflow the FP stack on the\n     x86.  */\n  for (i = 0; i < 10; i++)\n    {\n      x = foo (1.0);\n      if (x.epsilon != 1.0 + 1.0)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991023-1.c",
    "content": "\n\nint blah;\nfoo()\n{\n  int i;\n\n  for (i=0 ; i< 7 ; i++)\n    {\n      if (i == 7 - 1)\n\tblah = 0xfcc;\n      else\n\tblah = 0xfee;\n    }\n  return blah;\n}\n\n\nmain()\n{\n  if (foo () != 0xfcc)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991030-1.c",
    "content": "double x = 0x1.fp1;\nint main()\n{\n  if (x !=  3.875)\n    abort ();\n  exit (0);\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991112-1.c",
    "content": "/* This code was miscompiled at -O3 on x86.\n   Reported by Jim Meyering; distilled from bash.  */\n\nint rl_show_char (int c) { return 0; }\n\nint rl_character_len (int c, int pos)\n{\n  return isprint (c) ? 1 : 2;\n}\n\nint main(void)\n{\n  int (*x)(int, int) = rl_character_len;\n  if (x('a', 1) != 1)\n    abort();\n  if (x('\\002', 1) != 2)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991118-1.c",
    "content": "struct tmp\n{\n  long long int pad : 12;\n  long long int field : 52;\n};\n\nstruct tmp2\n{\n  long long int field : 52;\n  long long int pad : 12;\n};\n\nstruct tmp3\n{\n  long long int pad : 11;\n  long long int field : 53;\n};\n\nstruct tmp4\n{\n  long long int field : 53;\n  long long int pad : 11;\n};\n\nstruct tmp\nsub (struct tmp tmp)\n{\n  tmp.field ^= 0x0008765412345678LL;\n  return tmp;\n}\n\nstruct tmp2\nsub2 (struct tmp2 tmp2)\n{\n  tmp2.field ^= 0x0008765412345678LL;\n  return tmp2;\n}\n\nstruct tmp3\nsub3 (struct tmp3 tmp3)\n{\n  tmp3.field ^= 0x0018765412345678LL;\n  return tmp3;\n}\n\nstruct tmp4\nsub4 (struct tmp4 tmp4)\n{\n  tmp4.field ^= 0x0018765412345678LL;\n  return tmp4;\n}\n\nstruct tmp tmp = {0x123, 0x123456789ABCDLL};\nstruct tmp2 tmp2 = {0x123456789ABCDLL, 0x123};\nstruct tmp3 tmp3 = {0x123, 0x1FFFF00000000LL};\nstruct tmp4 tmp4 = {0x1FFFF00000000LL, 0x123};\n\nmain()\n{\n\n  if (sizeof (long long) != 8)\n    exit (0);\n\n  tmp = sub (tmp);\n  tmp2 = sub2 (tmp2);\n\n  if (tmp.pad != 0x123 || tmp.field != 0xFFF9551175BDFDB5LL)\n    abort ();\n  if (tmp2.pad != 0x123 || tmp2.field != 0xFFF9551175BDFDB5LL)\n    abort ();\n\n  tmp3 = sub3 (tmp3);\n  tmp4 = sub4 (tmp4);\n  if (tmp3.pad != 0x123 || tmp3.field != 0xFFF989AB12345678LL)\n    abort ();\n  if (tmp4.pad != 0x123 || tmp4.field != 0xFFF989AB12345678LL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991201-1.c",
    "content": "struct vc_data {\n\tunsigned long\tspace;\n\tunsigned char   vc_palette[16*3];        \n};\n\nstruct vc {\n\tstruct vc_data *d;\n};\n\nstruct vc_data a_con;\nstruct vc vc_cons[63] = { &a_con };\nint default_red[16];\nint default_grn[16];\nint default_blu[16];\n\nextern void bar(int);\n\nvoid reset_palette(int currcons)\n{\n\tint j, k;\n\tfor (j=k=0; j<16; j++) {\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_red[j];\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_grn[j];\n\t\t(vc_cons[currcons].d->vc_palette) [k++] = default_blu[j];\n\t}\n\tbar(k);\n}\n\nvoid bar(int k)\n{\n\tif (k != 16*3)\n\t\tabort();\n}\n\nint main()\n{\n\treset_palette(0);\n\texit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991202-1.c",
    "content": "int x, y;\n\nint\nmain()\n{\n  x = 2;\n  y = x;\n  do\n    {\n      x = y;\n      y = 2 * y;\n    }\n  while ( ! ((y - x) >= 20));\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991202-2.c",
    "content": "\nint\nf1 ()\n{\n  unsigned long x, y = 1;\n\n  x = ((y * 8192) - 216) % 16;\n  return x;\n}\n\nint\nmain ()\n{\n  if (f1 () != 8)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991202-3.c",
    "content": "\nunsigned int f (unsigned int a)\n{\n  return a * 65536 / 8;\n}\n\nunsigned int g (unsigned int a)\n{\n  return a * 65536;\n}\n\nunsigned int h (unsigned int a)\n{\n  return a / 8;\n}\n\nint main ()\n{\n  if (f (65536) != h (g (65536)))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991216-1.c",
    "content": "#define VALUE 0x123456789abcdefLL\n#define AFTER 0x55\n\nvoid\ntest1 (int a, long long value, int after)\n{\n  if (a != 1\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest2 (int a, int b, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest3 (int a, int b, int c, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest4 (int a, int b, int c, int d, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest5 (int a, int b, int c, int d, int e, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest6 (int a, int b, int c, int d, int e, int f, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest7 (int a, int b, int c, int d, int e, int f, int g, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || g != 7\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nvoid\ntest8 (int a, int b, int c, int d, int e, int f, int g, int h, long long value, int after)\n{\n  if (a != 1\n      || b != 2\n      || c != 3\n      || d != 4\n      || e != 5\n      || f != 6\n      || g != 7\n      || h != 8\n      || value != VALUE\n      || after != AFTER)\n    abort ();\n}\n\nint\nmain ()\n{\n  test1 (1, VALUE, AFTER);\n  test2 (1, 2, VALUE, AFTER);\n  test3 (1, 2, 3, VALUE, AFTER);\n  test4 (1, 2, 3, 4, VALUE, AFTER);\n  test5 (1, 2, 3, 4, 5, VALUE, AFTER);\n  test6 (1, 2, 3, 4, 5, 6, VALUE, AFTER);\n  test7 (1, 2, 3, 4, 5, 6, 7, VALUE, AFTER);\n  test8 (1, 2, 3, 4, 5, 6, 7, 8, VALUE, AFTER);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991216-2.c",
    "content": "#include <stdarg.h>\n\n#define VALUE 0x123456789abcdefLL\n#define AFTER 0x55\n\nvoid\ntest (int n, ...)\n{\n  va_list ap;\n  int i;\n\n  va_start (ap, n);\n  for (i = 2; i <= n; i++)\n    {\n      if (va_arg (ap, int) != i)\n\tabort ();\n    }\n\n  if (va_arg (ap, long long) != VALUE)\n    abort ();\n\n  if (va_arg (ap, int) != AFTER)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  test (1, VALUE, AFTER);\n  test (2, 2, VALUE, AFTER);\n  test (3, 2, 3, VALUE, AFTER);\n  test (4, 2, 3, 4, VALUE, AFTER);\n  test (5, 2, 3, 4, 5, VALUE, AFTER);\n  test (6, 2, 3, 4, 5, 6, VALUE, AFTER);\n  test (7, 2, 3, 4, 5, 6, 7, VALUE, AFTER);\n  test (8, 2, 3, 4, 5, 6, 7, 8, VALUE, AFTER);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991216-4.c",
    "content": "/* Test against a problem with loop reversal.  */\nstatic void bug(int size, int tries)\n{\n    int i;\n    int num = 0;\n    while (num < size)\n    {\n        for (i = 1; i < tries; i++) num++;\n    }\n}\n\nint main()\n{\n    bug(5, 10);\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991221-1.c",
    "content": "int main( void )\n{\n   unsigned long totalsize = 80;\n   unsigned long msize = 64;\n\n   if (sizeof(long) != 4)\n     exit(0);\n   \n   if ( totalsize > (2147483647L   * 2UL + 1)  \n        || (msize != 0 && ((msize - 1) > (2147483647L   * 2UL + 1) )))\n      abort();\n   exit( 0 );\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991227-1.c",
    "content": "char* doit(int flag)\n{\n  return 1 + (flag ? \"\\0wrong\\n\" : \"\\0right\\n\");\n}\nint main()\n{\n  char *result = doit(0);\n  if (*result == 'r' && result[1] == 'i')\n    exit(0);\n  abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/991228-1.c",
    "content": "__extension__ union { double d; int i[2]; } u = { d: -0.25 };\n\n/* This assumes the endianness of words in a long long is the same as\n   that for doubles, which doesn't hold for a few platforms, but we\n   can probably special case them here, as appropriate.  */\nlong long endianness_test = 1;\n#define MSW (*(int*)&endianness_test)\n\nint\nsignbit(double x)\n{\n  __extension__ union { double d; int i[2]; } u = { d: x };\n  return u.i[MSW] < 0;\n}\n    \nint main(void)\n{\n  if (2*sizeof(int) != sizeof(double) || u.i[MSW] >= 0)\n    exit(0);\n\n  if (!signbit(-0.25))\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/alias-1.c",
    "content": "int val;\n\nint *ptr = &val;\nfloat *ptr2 = &val;\n\n__attribute__((optimize (\"-fno-strict-aliasing\")))\ntypepun ()\n{\n  *ptr2=0;\n}\n\nmain()\n{\n  *ptr=1;\n  typepun ();\n  if (*ptr)\n    __builtin_abort ();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/alias-2.c",
    "content": "/* { dg-require-alias \"\" } */\nint a[10]={};\nextern int b[10] __attribute__ ((alias(\"a\")));\nint off;\nmain()\n{\n  b[off]=1;\n  a[off]=2;\n  if (b[off]!=2)\n   __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/alias-3.c",
    "content": "/* { dg-require-alias \"\" } */\nstatic int a=0;\nextern int b __attribute__ ((alias(\"a\")));\n__attribute__ ((noinline))\nstatic inc()\n{\n  b++;\n}\nint\nmain()\n{\n  a=0;\n  inc ();\n  if (a!=1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/alias-4.c",
    "content": "/* { dg-require-alias \"\" } */\nint a = 1;\nextern int b __attribute__ ((alias (\"a\")));\nint c = 1;\nextern int d __attribute__ ((alias (\"c\")));\nmain (int argc)\n{\n  int *p;\n  int *q;\n  if (argc)\n    p = &a, q = &b;\n  else\n    p = &c, q = &d;\n  *p = 1;\n  *q = 2;\n  if (*p == 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/align-1.c",
    "content": "typedef int new_int __attribute__ ((aligned(16)));\nstruct S { int x; };\n \nint main()\n{\n  if (sizeof(struct S) != sizeof(int))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/align-2.c",
    "content": "/* Simple alignment checks;\n   looking for compiler/assembler alignment disagreements,\n   agreement between struct initialization and access.  */\nstruct a_short { char c; short s; } s_c_s = { 'a', 13 };\nstruct a_int { char c ; int i; } s_c_i = { 'b', 14 };\nstruct b_int { short s; int i; } s_s_i  = { 15, 16 };\nstruct a_float { char c; float f; } s_c_f = { 'c', 17.0 };\nstruct b_float { short s; float f; } s_s_f = { 18, 19.0 };\nstruct a_double { char c; double d; } s_c_d = { 'd', 20.0 };\nstruct b_double { short s; double d; } s_s_d = { 21, 22.0 };\nstruct c_double { int i; double d; } s_i_d = { 23, 24.0 };\nstruct d_double { float f; double d; } s_f_d = { 25.0, 26.0 };\nstruct a_ldouble { char c; long double ld; } s_c_ld = { 'e', 27.0 };\nstruct b_ldouble { short s; long double ld; } s_s_ld = { 28, 29.0 };\nstruct c_ldouble { int i; long double ld; } s_i_ld = { 30, 31.0 };\nstruct d_ldouble { float f; long double ld; } s_f_ld = { 32.0, 33.0 };\nstruct e_ldouble { double d; long double ld; } s_d_ld = { 34.0, 35.0 };\n\nint main ()\n{\n  if (s_c_s.c != 'a') abort ();\n  if (s_c_s.s != 13) abort ();\n  if (s_c_i.c != 'b') abort ();\n  if (s_c_i.i != 14) abort ();\n  if (s_s_i.s != 15) abort ();\n  if (s_s_i.i != 16) abort ();\n  if (s_c_f.c != 'c') abort ();\n  if (s_c_f.f != 17.0) abort ();\n  if (s_s_f.s != 18) abort ();\n  if (s_s_f.f != 19.0) abort ();\n  if (s_c_d.c != 'd') abort ();\n  if (s_c_d.d != 20.0) abort ();\n  if (s_s_d.s != 21) abort ();\n  if (s_s_d.d != 22.0) abort ();\n  if (s_i_d.i != 23) abort ();\n  if (s_i_d.d != 24.0) abort ();\n  if (s_f_d.f != 25.0) abort ();\n  if (s_f_d.d != 26.0) abort ();\n  if (s_c_ld.c != 'e') abort ();\n  if (s_c_ld.ld != 27.0) abort ();\n  if (s_s_ld.s != 28) abort ();\n  if (s_s_ld.ld != 29.0) abort ();\n  if (s_i_ld.i != 30) abort ();\n  if (s_i_ld.ld != 31.0) abort ();\n  if (s_f_ld.f != 32.0) abort ();\n  if (s_f_ld.ld != 33.0) abort ();\n  if (s_d_ld.d != 34.0) abort ();\n  if (s_d_ld.ld != 35.0) abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/align-3.c",
    "content": "void func(void) __attribute__((aligned(256)));\n\nvoid func(void) \n{\n}\n\nint main()\n{\n  if (__alignof__(func) != 256)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/align-nest.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n\nvoid foo(int n)\n{\n  typedef struct\n  {\n    int value;\n  } myint;\n  \n  struct S\n  {\n    int i[n];\n    unsigned int b:1;\n    myint mi;\n  } __attribute__ ((packed)) __attribute__ ((aligned (4)));\n\n  struct S s[2];\n  int k;\n  \n  for (k = 0; k < 2; k ++)\n    s[k].mi.value = 0;\n}\n\nint main ()\n{\n  foo (2);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/alloca-1.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\n/* Verify that alloca storage is sufficiently aligned.  */\n/* ??? May fail if BIGGEST_ALIGNMENT > STACK_BOUNDARY.  Which, I guess\n   can only happen on !STRICT_ALIGNMENT targets.  */\n\ntypedef __SIZE_TYPE__ size_t;\n\nstruct dummy { int x __attribute__((aligned)); };\n#define BIGGEST_ALIGNMENT __alignof__(struct dummy)\n\n_Bool foo(void)\n{\n  char *p = __builtin_alloca(32);\n  return ((size_t)p & (BIGGEST_ALIGNMENT - 1)) == 0;\n}\n\nint main()\n{\n  if (!foo())\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/anon-1.c",
    "content": "/* Copyright (C) 2001 Free Software Foundation, Inc.  */\n\n/* Source: Neil Booth, 4 Nov 2001, derived from PR 2820 - field lookup in\n   nested anonymous entities was broken.  */\n\nstruct\n{\n  int x;\n  struct\n  {\n    int a;\n    union\n    {\n      int b;\n    };\n  };\n} foo;\n\nint\nmain(int argc, char *argv[])\n{\n  foo.b = 6;\n  foo.a = 5;\n\n  if (foo.b != 6)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/arith-1.c",
    "content": "unsigned\nsat_add (unsigned i)\n{\n  unsigned ret = i + 1;\n  if (ret < i)\n    ret = i;\n  return ret;\n}\n\nunsigned\nsat_add2 (unsigned i)\n{\n  unsigned ret = i + 1;\n  if (ret > i)\n    return ret;\n  return i;\n}\n\nunsigned\nsat_add3 (unsigned i)\n{\n  unsigned ret = i - 1;\n  if (ret > i)\n    ret = i;\n  return ret;\n}\n\nunsigned\nsat_add4 (unsigned i)\n{\n  unsigned ret = i - 1;\n  if (ret < i)\n    return ret;\n  return i;\n}\nmain ()\n{\n  if (sat_add (~0U) != ~0U)\n    abort ();\n  if (sat_add2 (~0U) != ~0U)\n    abort ();\n  if (sat_add3 (0U) != 0U)\n    abort ();\n  if (sat_add4 (0U) != 0U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/arith-rand-ll.c",
    "content": "long long\nsimple_rand ()\n{\n  static unsigned long long seed = 47114711;\n  unsigned long long this = seed * 1103515245 + 12345;\n  seed = this;\n  return this >> 8;\n}\n\nunsigned long long int\nrandom_bitstring ()\n{\n  unsigned long long int x;\n  int n_bits;\n  long long ran;\n  int tot_bits = 0;\n\n  x = 0;\n  for (;;)\n    {\n      ran = simple_rand ();\n      n_bits = (ran >> 1) % 16;\n      tot_bits += n_bits;\n\n      if (n_bits == 0)\n\treturn x;\n      else\n\t{\n\t  x <<= n_bits;\n\t  if (ran & 1)\n\t    x |= (1 << n_bits) - 1;\n\n\t  if (tot_bits > 8 * sizeof (long long) + 6)\n\t    return x;\n\t}\n    }\n}\n\n#define ABS(x) ((x) >= 0 ? (x) : -(x))\n\nmain ()\n{\n  long long int i;\n\n  for (i = 0; i < 10000; i++)\n    {\n      unsigned long long x, y;\n      x = random_bitstring ();\n      y = random_bitstring ();\n\n      if (sizeof (int) == sizeof (long long))\n\tgoto save_time;\n\n      { unsigned long long xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed long long xx = x, yy = y, r1, r2;\n\tif ((unsigned long long) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned long long) ABS (yy) || (signed long long) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    save_time:\n      { unsigned int xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed int xx = x, yy = y, r1, r2;\n\tif ((unsigned int) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) != xx || ((xx < 0) != (r2 < 0) && r2))\n\t  abort ();\n      }\n      { unsigned short xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed short xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned short) ABS (yy) || (signed short) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned char xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed char xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned char) ABS (yy) || (signed char) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/arith-rand.c",
    "content": "long\nsimple_rand ()\n{\n  static unsigned long seed = 47114711;\n  unsigned long this = seed * 1103515245 + 12345;\n  seed = this;\n  return this >> 8;\n}\n\nunsigned long int\nrandom_bitstring ()\n{\n  unsigned long int x;\n  int n_bits;\n  long ran;\n  int tot_bits = 0;\n\n  x = 0;\n  for (;;)\n    {\n      ran = simple_rand ();\n      n_bits = (ran >> 1) % 16;\n      tot_bits += n_bits;\n\n      if (n_bits == 0)\n\treturn x;\n      else\n\t{\n\t  x <<= n_bits;\n\t  if (ran & 1)\n\t    x |= (1 << n_bits) - 1;\n\n\t  if (tot_bits > 8 * sizeof (long) + 6)\n\t    return x;\n\t}\n    }\n}\n\n#define ABS(x) ((x) >= 0 ? (x) : -(x))\n\nmain ()\n{\n  long int i;\n\n  for (i = 0; i < 1000; i++)\n    {\n      unsigned long x, y;\n      x = random_bitstring ();\n      y = random_bitstring ();\n\n      if (sizeof (int) == sizeof (long))\n\tgoto save_time;\n\n      { unsigned long xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed long xx = x, yy = y, r1, r2;\n\tif ((unsigned long) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned long) ABS (yy) || (signed long) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    save_time:\n      { unsigned int xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed int xx = x, yy = y, r1, r2;\n\tif ((unsigned int) xx << 1 == 0 && yy == -1)\n\t  continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned short xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed short xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned short) ABS (yy) || (signed short) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n      { unsigned char xx = x, yy = y, r1, r2;\n\tif (yy == 0) continue;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (r2 >= yy || r1 * yy + r2 != xx)\n\t  abort ();\n      }\n      { signed char xx = x, yy = y, r1, r2;\n\tr1 = xx / yy;\n\tr2 = xx % yy;\n\tif (ABS (r2) >= (unsigned char) ABS (yy) || (signed char) (r1 * yy + r2) != xx)\n\t  abort ();\n      }\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ashldi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic unsigned long long const data[64] = {\n  0x123456789abcdefULL,\n  0x2468acf13579bdeULL,\n  0x48d159e26af37bcULL,\n  0x91a2b3c4d5e6f78ULL,\n  0x123456789abcdef0ULL,\n  0x2468acf13579bde0ULL,\n  0x48d159e26af37bc0ULL,\n  0x91a2b3c4d5e6f780ULL,\n  0x23456789abcdef00ULL,\n  0x468acf13579bde00ULL,\n  0x8d159e26af37bc00ULL,\n  0x1a2b3c4d5e6f7800ULL,\n  0x3456789abcdef000ULL,\n  0x68acf13579bde000ULL,\n  0xd159e26af37bc000ULL,\n  0xa2b3c4d5e6f78000ULL,\n  0x456789abcdef0000ULL,\n  0x8acf13579bde0000ULL,\n  0x159e26af37bc0000ULL,\n  0x2b3c4d5e6f780000ULL,\n  0x56789abcdef00000ULL,\n  0xacf13579bde00000ULL,\n  0x59e26af37bc00000ULL,\n  0xb3c4d5e6f7800000ULL,\n  0x6789abcdef000000ULL,\n  0xcf13579bde000000ULL,\n  0x9e26af37bc000000ULL,\n  0x3c4d5e6f78000000ULL,\n  0x789abcdef0000000ULL,\n  0xf13579bde0000000ULL,\n  0xe26af37bc0000000ULL,\n  0xc4d5e6f780000000ULL,\n  0x89abcdef00000000ULL,\n  0x13579bde00000000ULL,\n  0x26af37bc00000000ULL,\n  0x4d5e6f7800000000ULL,\n  0x9abcdef000000000ULL,\n  0x3579bde000000000ULL,\n  0x6af37bc000000000ULL,\n  0xd5e6f78000000000ULL,\n  0xabcdef0000000000ULL,\n  0x579bde0000000000ULL,\n  0xaf37bc0000000000ULL,\n  0x5e6f780000000000ULL,\n  0xbcdef00000000000ULL,\n  0x79bde00000000000ULL,\n  0xf37bc00000000000ULL,\n  0xe6f7800000000000ULL,\n  0xcdef000000000000ULL,\n  0x9bde000000000000ULL,\n  0x37bc000000000000ULL,\n  0x6f78000000000000ULL,\n  0xdef0000000000000ULL,\n  0xbde0000000000000ULL,\n  0x7bc0000000000000ULL,\n  0xf780000000000000ULL,\n  0xef00000000000000ULL,\n  0xde00000000000000ULL,\n  0xbc00000000000000ULL,\n  0x7800000000000000ULL,\n  0xf000000000000000ULL,\n  0xe000000000000000ULL,\n  0xc000000000000000ULL,\n  0x8000000000000000ULL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic unsigned long long const data[32] = {\n  0x1234567fULL,\n  0x2468acfeULL,\n  0x48d159fcULL,\n  0x91a2b3f8ULL,\n  0x234567f0ULL,\n  0x468acfe0ULL,\n  0x8d159fc0ULL,\n  0x1a2b3f80ULL,\n  0x34567f00ULL,\n  0x68acfe00ULL,\n  0xd159fc00ULL,\n  0xa2b3f800ULL,\n  0x4567f000ULL,\n  0x8acfe000ULL,\n  0x159fc000ULL,\n  0x2b3f8000ULL,\n  0x567f0000ULL,\n  0xacfe0000ULL,\n  0x59fc0000ULL,\n  0xb3f80000ULL,\n  0x67f00000ULL,\n  0xcfe00000ULL,\n  0x9fc00000ULL,\n  0x3f800000ULL,\n  0x7f000000ULL,\n  0xfe000000ULL,\n  0xfc000000ULL,\n  0xf8000000ULL,\n  0xf0000000ULL,\n  0xe0000000ULL,\n  0xc0000000ULL,\n  0x80000000ULL\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic unsigned long long\nvariable_shift(unsigned long long x, int i)\n{\n  return x << i;\n}\n\nstatic unsigned long long\nconstant_shift(unsigned long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x << 0; break;\n    case 1: x = x << 1; break;\n    case 2: x = x << 2; break;\n    case 3: x = x << 3; break;\n    case 4: x = x << 4; break;\n    case 5: x = x << 5; break;\n    case 6: x = x << 6; break;\n    case 7: x = x << 7; break;\n    case 8: x = x << 8; break;\n    case 9: x = x << 9; break;\n    case 10: x = x << 10; break;\n    case 11: x = x << 11; break;\n    case 12: x = x << 12; break;\n    case 13: x = x << 13; break;\n    case 14: x = x << 14; break;\n    case 15: x = x << 15; break;\n    case 16: x = x << 16; break;\n    case 17: x = x << 17; break;\n    case 18: x = x << 18; break;\n    case 19: x = x << 19; break;\n    case 20: x = x << 20; break;\n    case 21: x = x << 21; break;\n    case 22: x = x << 22; break;\n    case 23: x = x << 23; break;\n    case 24: x = x << 24; break;\n    case 25: x = x << 25; break;\n    case 26: x = x << 26; break;\n    case 27: x = x << 27; break;\n    case 28: x = x << 28; break;\n    case 29: x = x << 29; break;\n    case 30: x = x << 30; break;\n    case 31: x = x << 31; break;\n#if BITS > 32\n    case 32: x = x << 32; break;\n    case 33: x = x << 33; break;\n    case 34: x = x << 34; break;\n    case 35: x = x << 35; break;\n    case 36: x = x << 36; break;\n    case 37: x = x << 37; break;\n    case 38: x = x << 38; break;\n    case 39: x = x << 39; break;\n    case 40: x = x << 40; break;\n    case 41: x = x << 41; break;\n    case 42: x = x << 42; break;\n    case 43: x = x << 43; break;\n    case 44: x = x << 44; break;\n    case 45: x = x << 45; break;\n    case 46: x = x << 46; break;\n    case 47: x = x << 47; break;\n    case 48: x = x << 48; break;\n    case 49: x = x << 49; break;\n    case 50: x = x << 50; break;\n    case 51: x = x << 51; break;\n    case 52: x = x << 52; break;\n    case 53: x = x << 53; break;\n    case 54: x = x << 54; break;\n    case 55: x = x << 55; break;\n    case 56: x = x << 56; break;\n    case 57: x = x << 57; break;\n    case 58: x = x << 58; break;\n    case 59: x = x << 59; break;\n    case 60: x = x << 60; break;\n    case 61: x = x << 61; break;\n    case 62: x = x << 62; break;\n    case 63: x = x << 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = variable_shift (data[0], i);\n      if (y != data[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = constant_shift (data[0], i);\n      if (y != data[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ashrdi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic long long const zext[64] = {\n  0x7654321fedcba980LL,\n  0x3b2a190ff6e5d4c0LL,\n  0x1d950c87fb72ea60LL,\n  0xeca8643fdb97530LL,\n  0x7654321fedcba98LL,\n  0x3b2a190ff6e5d4cLL,\n  0x1d950c87fb72ea6LL,\n  0xeca8643fdb9753LL,\n  0x7654321fedcba9LL,\n  0x3b2a190ff6e5d4LL,\n  0x1d950c87fb72eaLL,\n  0xeca8643fdb975LL,\n  0x7654321fedcbaLL,\n  0x3b2a190ff6e5dLL,\n  0x1d950c87fb72eLL,\n  0xeca8643fdb97LL,\n  0x7654321fedcbLL,\n  0x3b2a190ff6e5LL,\n  0x1d950c87fb72LL,\n  0xeca8643fdb9LL,\n  0x7654321fedcLL,\n  0x3b2a190ff6eLL,\n  0x1d950c87fb7LL,\n  0xeca8643fdbLL,\n  0x7654321fedLL,\n  0x3b2a190ff6LL,\n  0x1d950c87fbLL,\n  0xeca8643fdLL,\n  0x7654321feLL,\n  0x3b2a190ffLL,\n  0x1d950c87fLL,\n  0xeca8643fLL,\n  0x7654321fLL,\n  0x3b2a190fLL,\n  0x1d950c87LL,\n  0xeca8643LL,\n  0x7654321LL,\n  0x3b2a190LL,\n  0x1d950c8LL,\n  0xeca864LL,\n  0x765432LL,\n  0x3b2a19LL,\n  0x1d950cLL,\n  0xeca86LL,\n  0x76543LL,\n  0x3b2a1LL,\n  0x1d950LL,\n  0xeca8LL,\n  0x7654LL,\n  0x3b2aLL,\n  0x1d95LL,\n  0xecaLL,\n  0x765LL,\n  0x3b2LL,\n  0x1d9LL,\n  0xecLL,\n  0x76LL,\n  0x3bLL,\n  0x1dLL,\n  0xeLL,\n  0x7LL,\n  0x3LL,\n  0x1LL,\n  0LL\n};\n\nstatic long long const sext[64] = {\n  0x8edcba9f76543210LL,\n  0xc76e5d4fbb2a1908LL,\n  0xe3b72ea7dd950c84LL,\n  0xf1db9753eeca8642LL,\n  0xf8edcba9f7654321LL,\n  0xfc76e5d4fbb2a190LL,\n  0xfe3b72ea7dd950c8LL,\n  0xff1db9753eeca864LL,\n  0xff8edcba9f765432LL,\n  0xffc76e5d4fbb2a19LL,\n  0xffe3b72ea7dd950cLL,\n  0xfff1db9753eeca86LL,\n  0xfff8edcba9f76543LL,\n  0xfffc76e5d4fbb2a1LL,\n  0xfffe3b72ea7dd950LL,\n  0xffff1db9753eeca8LL,\n  0xffff8edcba9f7654LL,\n  0xffffc76e5d4fbb2aLL,\n  0xffffe3b72ea7dd95LL,\n  0xfffff1db9753eecaLL,\n  0xfffff8edcba9f765LL,\n  0xfffffc76e5d4fbb2LL,\n  0xfffffe3b72ea7dd9LL,\n  0xffffff1db9753eecLL,\n  0xffffff8edcba9f76LL,\n  0xffffffc76e5d4fbbLL,\n  0xffffffe3b72ea7ddLL,\n  0xfffffff1db9753eeLL,\n  0xfffffff8edcba9f7LL,\n  0xfffffffc76e5d4fbLL,\n  0xfffffffe3b72ea7dLL,\n  0xffffffff1db9753eLL,\n  0xffffffff8edcba9fLL,\n  0xffffffffc76e5d4fLL,\n  0xffffffffe3b72ea7LL,\n  0xfffffffff1db9753LL,\n  0xfffffffff8edcba9LL,\n  0xfffffffffc76e5d4LL,\n  0xfffffffffe3b72eaLL,\n  0xffffffffff1db975LL,\n  0xffffffffff8edcbaLL,\n  0xffffffffffc76e5dLL,\n  0xffffffffffe3b72eLL,\n  0xfffffffffff1db97LL,\n  0xfffffffffff8edcbLL,\n  0xfffffffffffc76e5LL,\n  0xfffffffffffe3b72LL,\n  0xffffffffffff1db9LL,\n  0xffffffffffff8edcLL,\n  0xffffffffffffc76eLL,\n  0xffffffffffffe3b7LL,\n  0xfffffffffffff1dbLL,\n  0xfffffffffffff8edLL,\n  0xfffffffffffffc76LL,\n  0xfffffffffffffe3bLL,\n  0xffffffffffffff1dLL,\n  0xffffffffffffff8eLL,\n  0xffffffffffffffc7LL,\n  0xffffffffffffffe3LL,\n  0xfffffffffffffff1LL,\n  0xfffffffffffffff8LL,\n  0xfffffffffffffffcLL,\n  0xfffffffffffffffeLL,\n  0xffffffffffffffffLL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic long long const zext[32] = {\n  0x76543218LL,\n  0x3b2a190cLL,\n  0x1d950c86LL,\n  0xeca8643LL,\n  0x7654321LL,\n  0x3b2a190LL,\n  0x1d950c8LL,\n  0xeca864LL,\n  0x765432LL,\n  0x3b2a19LL,\n  0x1d950cLL,\n  0xeca86LL,\n  0x76543LL,\n  0x3b2a1LL,\n  0x1d950LL,\n  0xeca8LL,\n  0x7654LL,\n  0x3b2aLL,\n  0x1d95LL,\n  0xecaLL,\n  0x765LL,\n  0x3b2LL,\n  0x1d9LL,\n  0xecLL,\n  0x76LL,\n  0x3bLL,\n  0x1dLL,\n  0xeLL,\n  0x7LL,\n  0x3LL,\n  0x1LL,\n  0LL\n};\n\nstatic long long const sext[64] = {\n  0x87654321LL,\n  0xc3b2a190LL,\n  0xe1d950c8LL,\n  0xf0eca864LL,\n  0xf8765432LL,\n  0xfc3b2a19LL,\n  0xfe1d950cLL,\n  0xff0eca86LL,\n  0xff876543LL,\n  0xffc3b2a1LL,\n  0xffe1d950LL,\n  0xfff0eca8LL,\n  0xfff87654LL,\n  0xfffc3b2aLL,\n  0xfffe1d95LL,\n  0xffff0ecaLL,\n  0xffff8765LL,\n  0xffffc3b2LL,\n  0xffffe1d9LL,\n  0xfffff0ecLL,\n  0xfffff876LL,\n  0xfffffc3bLL,\n  0xfffffe1dLL,\n  0xffffff0eLL,\n  0xffffff87LL,\n  0xffffffc3LL,\n  0xffffffe1LL,\n  0xfffffff0LL,\n  0xfffffff8LL,\n  0xfffffffcLL,\n  0xfffffffeLL,\n  0xffffffffLL\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic long long\nvariable_shift(long long x, int i)\n{\n  return x >> i;\n}\n\nstatic long long\nconstant_shift(long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x >> 0; break;\n    case 1: x = x >> 1; break;\n    case 2: x = x >> 2; break;\n    case 3: x = x >> 3; break;\n    case 4: x = x >> 4; break;\n    case 5: x = x >> 5; break;\n    case 6: x = x >> 6; break;\n    case 7: x = x >> 7; break;\n    case 8: x = x >> 8; break;\n    case 9: x = x >> 9; break;\n    case 10: x = x >> 10; break;\n    case 11: x = x >> 11; break;\n    case 12: x = x >> 12; break;\n    case 13: x = x >> 13; break;\n    case 14: x = x >> 14; break;\n    case 15: x = x >> 15; break;\n    case 16: x = x >> 16; break;\n    case 17: x = x >> 17; break;\n    case 18: x = x >> 18; break;\n    case 19: x = x >> 19; break;\n    case 20: x = x >> 20; break;\n    case 21: x = x >> 21; break;\n    case 22: x = x >> 22; break;\n    case 23: x = x >> 23; break;\n    case 24: x = x >> 24; break;\n    case 25: x = x >> 25; break;\n    case 26: x = x >> 26; break;\n    case 27: x = x >> 27; break;\n    case 28: x = x >> 28; break;\n    case 29: x = x >> 29; break;\n    case 30: x = x >> 30; break;\n    case 31: x = x >> 31; break;\n#if BITS > 32\n    case 32: x = x >> 32; break;\n    case 33: x = x >> 33; break;\n    case 34: x = x >> 34; break;\n    case 35: x = x >> 35; break;\n    case 36: x = x >> 36; break;\n    case 37: x = x >> 37; break;\n    case 38: x = x >> 38; break;\n    case 39: x = x >> 39; break;\n    case 40: x = x >> 40; break;\n    case 41: x = x >> 41; break;\n    case 42: x = x >> 42; break;\n    case 43: x = x >> 43; break;\n    case 44: x = x >> 44; break;\n    case 45: x = x >> 45; break;\n    case 46: x = x >> 46; break;\n    case 47: x = x >> 47; break;\n    case 48: x = x >> 48; break;\n    case 49: x = x >> 49; break;\n    case 50: x = x >> 50; break;\n    case 51: x = x >> 51; break;\n    case 52: x = x >> 52; break;\n    case 53: x = x >> 53; break;\n    case 54: x = x >> 54; break;\n    case 55: x = x >> 55; break;\n    case 56: x = x >> 56; break;\n    case 57: x = x >> 57; break;\n    case 58: x = x >> 58; break;\n    case 59: x = x >> 59; break;\n    case 60: x = x >> 60; break;\n    case 61: x = x >> 61; break;\n    case 62: x = x >> 62; break;\n    case 63: x = x >> 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = variable_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = variable_shift (sext[0], i);\n      if (y != sext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = constant_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      long long y = constant_shift (sext[0], i);\n      if (y != sext[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bcp-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__ ((externally_visible)) int global;\nint func(void);\n\n/* These must fail.  */\nint bad0(void) { return __builtin_constant_p(global); }\nint bad1(void) { return __builtin_constant_p(global++); }\ninline int bad2(int x) { return __builtin_constant_p(x++); }\ninline int bad3(int x) { return __builtin_constant_p(x); }\ninline int bad4(const char *x) { return __builtin_constant_p(x); }\nint bad5(void) { return bad2(1); }\ninline int bad6(int x) { return __builtin_constant_p(x+1); }\nint bad7(void) { return __builtin_constant_p(func()); }\nint bad8(void) { char buf[10]; return __builtin_constant_p(buf); }\nint bad9(const char *x) { return __builtin_constant_p(x[123456]); }\nint bad10(void) { return __builtin_constant_p(&global); }\n\n/* These must pass, or we've broken gcc2 functionality.  */\nint good0(void) { return __builtin_constant_p(1); }\nint good1(void) { return __builtin_constant_p(\"hi\"); }\nint good2(void) { return __builtin_constant_p((1234 + 45) & ~7); }\n\n/* These are extensions to gcc2.  Failure indicates an optimization\n   regression.  */\nint opt0(void) { return bad3(1); }\nint opt1(void) { return bad6(1); }\nint opt2(void) { return __builtin_constant_p(\"hi\"[0]); }\n\n/* \n * Opt3 is known to fail.  It is one of the important cases that glibc\n * was interested in though, so keep this around as a reminder.\n *\n * The solution is to add bits to recover bytes from constant pool\n * elements given nothing but a constant pool label and an offset.\n * When we can do that, and we can simplify strlen after the fact,\n * then we can enable recognition of constant pool labels as constants.\n */\n\n/* int opt3(void) { return bad4(\"hi\"); } */\n\n\n/* Call through tables so -finline-functions can't screw with us.  */\nint (* volatile bad_t0[])(void) = {\n\tbad0, bad1, bad5, bad7, bad8, bad10\n};\n\nint (* volatile bad_t1[])(int x) = {\n\tbad2, bad3, bad6\n};\n\nint (* volatile bad_t2[])(const char *x) = {\n\tbad4, bad9\n};\n\nint (* volatile good_t0[])(void) = {\n\tgood0, good1, good2\n};\n\nint (* volatile opt_t0[])(void) = {\n\topt0, opt1, opt2 /* , opt3 */\n};\n\n#define N(arr) (sizeof(arr)/sizeof(*arr))\n\nint main()\n{\n  int i;\n\n  for (i = 0; i < N(bad_t0); ++i)\n    if ((*bad_t0[i])())\n      abort();\n\n  for (i = 0; i < N(bad_t1); ++i)\n    if ((*bad_t1[i])(1))\n      abort();\n\n  for (i = 0; i < N(bad_t2); ++i)\n    if ((*bad_t2[i])(\"hi\"))\n      abort();\n\n  for (i = 0; i < N(good_t0); ++i)\n    if (! (*good_t0[i])())\n      abort();\n\n#ifdef __OPTIMIZE__\n  for (i = 0; i < N(opt_t0); ++i)\n    if (! (*opt_t0[i])())\n      abort();\n#endif\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf-layout-1.c",
    "content": "struct { long f8:8; long f24:24; } a;\nstruct { long f32:32; } b;\n\nmain ()\n{\n  if (sizeof (a) != sizeof (b))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf-pack-1.c",
    "content": "struct foo\n{\n  unsigned half:16;\n  unsigned long whole:32 __attribute__ ((packed));\n};\n\nf (struct foo *q)\n{\n  if (q->half != 0x1234)\n    abort ();\n  if (q->whole != 0x56789abcL)\n    abort ();\n}\n\nmain ()\n{\n  struct foo bar;\n\n  bar.half = 0x1234;\n  bar.whole = 0x56789abcL;\n  f (&bar);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf-sign-1.c",
    "content": "main ()\n{\n  struct  {\n    signed int s:3;\n    unsigned int u:3;\n    int i:3;\n  } x = {-1, -1, -1};\n\n  if (x.u != 7)\n    abort ();\n  if (x.s != - 1)\n    abort ();\n\n  if (x.i != -1 && x.i != 7)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c",
    "content": "/* \n This test checks promotion of bitfields.  Bitfields should be promoted\n very much like chars and shorts: \n\n Bitfields (signed or unsigned) should be promoted to signed int if their\n value will fit in a signed int, otherwise to an unsigned int if their \n value will fit in an unsigned int, otherwise we don't promote them (ANSI/ISO\n does not specify the behavior of bitfields larger than an unsigned int).\n\n We test the behavior by subtracting two from the promoted value: this will\n result in a negitive value for signed types, a positive value for unsigned\n types.  This test (of course) assumes that the compiler is correctly \n implementing signed and unsigned arithmetic.\n */\n\nstruct X {\n  unsigned int\t     u3:3;\n    signed long int  s31:31;\n    signed long int  s32:32;\n  unsigned long int  u31:31;\n  unsigned long int  u32:32;\n  unsigned long long ull3 :3;\n  unsigned long long ull35:35;\n  unsigned u15:15;\n};\n\nstruct X x;\n\nmain ()\n{\n  if ((x.u3 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.s31 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.s32 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.u15 - 2) >= 0)\t\t/* promoted value should be signed */\n    abort ();\n\n  /* Conditionalize check on whether integers are 4 bytes or larger, i.e.\n     larger than a 31 bit bitfield.  */\n  if (sizeof (int) >= 4)\n    {\n      if ((x.u31 - 2) >= 0)\t/* promoted value should be signed */\n\tabort ();\n    }\n  else\n    {\n      if ((x.u31 - 2) < 0)\t/* promoted value should be UNsigned */\n\tabort ();\n    }\n\n  if ((x.u32 - 2) < 0)\t\t/* promoted value should be UNsigned */\n    abort ();\n\n  if ((x.ull3 - 2) >= 0)\t/* promoted value should be signed */\n    abort ();\n\n  if ((x.ull35 - 2) < 0)\t/* promoted value should be UNsigned */\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bf64-1.c",
    "content": "/* { dg-xfail-if \"ABI specifies bitfields cannot exceed 32 bits\" { mcore-*-* } \"*\" \"\" } */\nstruct tmp\n{\n  long long int pad : 12;\n  long long int field : 52;\n};\n\nstruct tmp2\n{\n  long long int field : 52;\n  long long int pad : 12;\n};\n\nstruct tmp\nsub (struct tmp tmp)\n{\n  tmp.field |= 0x0008765412345678LL;\n  return tmp;\n}\n\nstruct tmp2\nsub2 (struct tmp2 tmp2)\n{\n  tmp2.field |= 0x0008765412345678LL;\n  return tmp2;\n}\n\nmain()\n{\n  struct tmp tmp = {0x123, 0xFFF000FFF000FLL};\n  struct tmp2 tmp2 = {0xFFF000FFF000FLL, 0x123};\n\n  tmp = sub (tmp);\n  tmp2 = sub2 (tmp2);\n\n  if (tmp.pad != 0x123 || tmp.field != 0xFFFFFF541FFF567FLL)\n    abort ();\n  if (tmp2.pad != 0x123 || tmp2.field != 0xFFFFFF541FFF567FLL)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-1.c",
    "content": "/* Copyright 2002 Free Software Foundation, Inc.\n\n   Tests correct signedness of operations on bitfields; in particular\n   that integer promotions are done correctly, including the case when\n   casts are present.\n\n   The C front end was eliding the cast of an unsigned bitfield to\n   unsigned as a no-op, when in fact it forces a conversion to a\n   full-width unsigned int. (At the time of writing, the C++ front end\n   has a different bug; it erroneously promotes the uncast unsigned\n   bitfield to an unsigned int).\n\n   Source: Neil Booth, 25 Jan 2002, based on PR 3325 (and 3326, which\n   is a different manifestation of the same bug).\n*/\n\nextern void abort ();\n\nint\nmain(int argc, char *argv[])\n{\n  struct x { signed int i : 7; unsigned int u : 7; } bit;\n\n  unsigned int u;\n  int i;\n  unsigned int unsigned_result = -13U % 61;\n  int signed_result = -13 % 61;\n\n  bit.u = 61, u = 61; \n  bit.i = -13, i = -13;\n\n  if (i % u != unsigned_result)\n    abort ();\n  if (i % (unsigned int) u != unsigned_result)\n    abort ();\n\n  /* Somewhat counter-intuitively, bit.u is promoted to an int, making\n     the operands and result an int.  */\n  if (i % bit.u != signed_result)\n    abort ();\n\n  if (bit.i % bit.u != signed_result)\n    abort ();\n\n  /* But with a cast to unsigned int, the unsigned int is promoted to\n     itself as a no-op, and the operands and result are unsigned.  */\n  if (i % (unsigned int) bit.u != unsigned_result)\n    abort ();\n\n  if (bit.i % (unsigned int) bit.u != unsigned_result)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-2.c",
    "content": "/* Test whether bit field boundaries aren't advanced if bit field type\n   has alignment large enough.  */\nextern void abort (void);\nextern void exit (int);\n\nstruct A {\n  unsigned short a : 5;\n  unsigned short b : 5;\n  unsigned short c : 6;\n};\n\nstruct B {\n  unsigned short a : 5;\n  unsigned short b : 3;\n  unsigned short c : 8;\n};\n\nint main ()\n{\n  /* If short is not at least 16 bits wide, don't test anything.  */\n  if ((unsigned short) 65521 != 65521)\n    exit (0);\n\n  if (sizeof (struct A) != sizeof (struct B))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-3.c",
    "content": "/* Test that operations on bit-fields yield results reduced to bit-field\n   type.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\nextern void exit (int);\nextern void abort (void);\n\nstruct s {\n  unsigned long long u33: 33;\n  unsigned long long u40: 40;\n  unsigned long long u41: 41;\n};\n\nstruct s a = { 0x100000, 0x100000, 0x100000 };\nstruct s b = { 0x100000000ULL, 0x100000000ULL, 0x100000000ULL };\nstruct s c = { 0x1FFFFFFFFULL, 0, 0 };\n\nint \nmain (void)\n{\n  if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0\n      || a.u40 * a.u40 != 0)\n    abort ();\n  if (a.u33 * a.u41 != 0x10000000000ULL\n      || a.u40 * a.u41 != 0x10000000000ULL\n      || a.u41 * a.u33 != 0x10000000000ULL\n      || a.u41 * a.u40 != 0x10000000000ULL\n      || a.u41 * a.u41 != 0x10000000000ULL)\n    abort ();\n  if (b.u33 + b.u33 != 0)\n    abort ();\n  if (b.u33 + b.u40 != 0x200000000ULL\n      || b.u33 + b.u41 != 0x200000000ULL\n      || b.u40 + b.u33 != 0x200000000ULL\n      || b.u40 + b.u40 != 0x200000000ULL\n      || b.u40 + b.u41 != 0x200000000ULL\n      || b.u41 + b.u33 != 0x200000000ULL\n      || b.u41 + b.u40 != 0x200000000ULL\n      || b.u41 + b.u41 != 0x200000000ULL)\n    abort ();\n  if (a.u33 - b.u33 != 0x100100000ULL\n      || a.u33 - b.u40 != 0xFF00100000ULL\n      || a.u33 - b.u41 != 0x1FF00100000ULL\n      || a.u40 - b.u33 != 0xFF00100000ULL\n      || a.u40 - b.u40 != 0xFF00100000ULL\n      || a.u40 - b.u41 != 0x1FF00100000ULL\n      || a.u41 - b.u33 != 0x1FF00100000ULL\n      || a.u41 - b.u40 != 0x1FF00100000ULL\n      || a.u41 - b.u41 != 0x1FF00100000ULL)\n    abort ();\n  if (++c.u33 != 0 || --c.u40 != 0xFFFFFFFFFFULL || c.u41-- != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-4.c",
    "content": "/* When comparisons of bit-fields to unsigned constants got shortened,\n   the shortened signed constant was wrongly marked as overflowing,\n   leading to a later integer_zerop failure and misoptimization.\n\n   Related to bug tree-optimization/16437 but shows the problem on\n   32-bit systems.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nstruct s { int a:12, b:20; };\n\nstruct s x = { -123, -456 };\n\nint\nmain (void)\n{\n  if (x.a != -123U || x.b != -456U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-5.c",
    "content": "/* See http://gcc.gnu.org/ml/gcc/2009-06/msg00072.html.  */\n\nextern void abort (void);\n\nstruct s\n{\n  unsigned long long a:2;\n  unsigned long long b:40;\n  unsigned long long c:22;\n};\n\n__attribute__ ((noinline)) void\ng (unsigned long long a, unsigned long long b)\n{\n  asm (\"\");\n  if (a != b)\n    abort ();\n}\n\n__attribute__ ((noinline)) void\nf (struct s s, unsigned long long b)\n{\n  asm (\"\");\n  g (((unsigned long long) (s.b-8)) + 8, b);\n}\n\nint\nmain ()\n{\n  struct s s = {1, 10, 3};\n  struct s t = {1, 2, 3};\n  f (s, 10);\n  f (t, 0x10000000002);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-6.c",
    "content": "/* { dg-require-effective-target int32plus } */\nunion U\n{\n  const int a;\n  unsigned b : 20;\n};\n\nstatic union U u = { 0x12345678 };\n\n/* Constant folding used to fail to account for endianness when folding a\n   union.  */\n\nint\nmain (void)\n{\n#ifdef __BYTE_ORDER__\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  return u.b - 0x45678;\n#else\n  return u.b - 0x12345;\n#endif\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bitfld-7.c",
    "content": "/* { dg-require-effective-target int32plus } */\nunion U\n{\n  const int a;\n  unsigned b : 24;\n};\n\nstatic union U u = { 0x12345678 };\n\n/* Constant folding used to fail to account for endianness when folding a\n   union.  */\n\nint\nmain (void)\n{\n#ifdef __BYTE_ORDER__\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  return u.b - 0x345678;\n#else\n  return u.b - 0x123456;\n#endif\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bswap-1.c",
    "content": "/* Test __builtin_bswap64 . */\n\nunsigned long long g(unsigned long long a) __attribute__((noinline));\nunsigned long long g(unsigned long long a)\n{\n  return __builtin_bswap64(a);\n}\n\n\nunsigned long long f(unsigned long long c)\n{\n  union {\n    unsigned long long a;\n    unsigned char b[8];\n  } a, b;\n  a.a = c;\n  b.b[0] = a.b[7];\n  b.b[1] = a.b[6];\n  b.b[2] = a.b[5];\n  b.b[3] = a.b[4];\n  b.b[4] = a.b[3];\n  b.b[5] = a.b[2];\n  b.b[6] = a.b[1];\n  b.b[7] = a.b[0];\n  return b.a;\n}\n\nint main(void)\n{\n  unsigned long long i;\n  /* The rest of the testcase assumes 8 byte long long. */\n  if (sizeof(i) != sizeof(char)*8)\n    return 0;\n  if (f(0x12) != g(0x12))\n    __builtin_abort();\n  if (f(0x1234) != g(0x1234))\n    __builtin_abort();\n  if (f(0x123456) != g(0x123456))\n    __builtin_abort();\n  if (f(0x12345678ull) != g(0x12345678ull))\n    __builtin_abort();\n  if (f(0x1234567890ull) != g(0x1234567890ull))\n    __builtin_abort();\n  if (f(0x123456789012ull) != g(0x123456789012ull))\n    __builtin_abort();\n  if (f(0x12345678901234ull) != g(0x12345678901234ull))\n    __builtin_abort();\n  if (f(0x1234567890123456ull) != g(0x1234567890123456ull))\n    __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/bswap-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef __UINT32_TYPE__ unsigned;\n#endif\n\nstruct bitfield {\n  unsigned char f0:7;\n  unsigned char   :1;\n  unsigned char f1:7;\n  unsigned char   :1;\n  unsigned char f2:7;\n  unsigned char   :1;\n  unsigned char f3:7;\n};\n\nstruct ok {\n  unsigned char f0;\n  unsigned char f1;\n  unsigned char f2;\n  unsigned char f3;\n};\n\nunion bf_or_uint32 {\n  struct ok inval;\n  struct bitfield bfval;\n};\n\n__attribute__ ((noinline, noclone)) uint32_t\npartial_read_le32 (union bf_or_uint32 in)\n{\n  return in.bfval.f0 | (in.bfval.f1 << 8)\n\t | (in.bfval.f2 << 16) | (in.bfval.f3 << 24);\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\npartial_read_be32 (union bf_or_uint32 in)\n{\n  return in.bfval.f3 | (in.bfval.f2 << 8)\n\t | (in.bfval.f1 << 16) | (in.bfval.f0 << 24);\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_read_le32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  *y = 1;\n  c2 = x[2];\n  c3 = x[3];\n  return c0 | c1 << 8 | c2 << 16 | c3 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_read_be32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  *y = 1;\n  c2 = x[2];\n  c3 = x[3];\n  return c3 | c2 << 8 | c1 << 16 | c0 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nincorrect_read_le32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  c2 = x[2];\n  c3 = x[3];\n  *y = 1;\n  return c0 | c1 << 8 | c2 << 16 | c3 << 24;\n}\n\n__attribute__ ((noinline, noclone)) uint32_t\nincorrect_read_be32 (char *x, char *y)\n{\n  unsigned char c0, c1, c2, c3;\n\n  c0 = x[0];\n  c1 = x[1];\n  c2 = x[2];\n  c3 = x[3];\n  *y = 1;\n  return c3 | c2 << 8 | c1 << 16 | c0 << 24;\n}\n\nint\nmain ()\n{\n  union bf_or_uint32 bfin;\n  uint32_t out;\n  char cin[] = { 0x83, 0x85, 0x87, 0x89 };\n\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };\n  out = partial_read_le32 (bfin);\n  /* Test what bswap would do if its check are not strict enough instead of\n     what is the expected result as there is too many possible results with\n     bitfields.  */\n  if (out == 0x89878583)\n    __builtin_abort ();\n  bfin.inval = (struct ok) { 0x83, 0x85, 0x87, 0x89 };\n  out = partial_read_be32 (bfin);\n  /* Test what bswap would do if its check are not strict enough instead of\n     what is the expected result as there is too many possible results with\n     bitfields.  */\n  if (out == 0x83858789)\n    __builtin_abort ();\n  out = fake_read_le32 (cin, &cin[2]);\n  if (out != 0x89018583)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = fake_read_be32 (cin, &cin[2]);\n  if (out != 0x83850189)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = incorrect_read_le32 (cin, &cin[2]);\n  if (out != 0x89878583)\n    __builtin_abort ();\n  cin[2] = 0x87;\n  out = incorrect_read_be32 (cin, &cin[2]);\n  if (out != 0x83858789)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/built-in-setjmp.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target alloca } */\n\nextern int strcmp(const char *, const char *);\nextern char *strcpy(char *, const char *);\nextern void abort(void);\nextern void exit(int);\n\nvoid *buf[20];\n\nvoid __attribute__((noinline))\nsub2 (void)\n{\n  __builtin_longjmp (buf, 1);\n}\n\nint\nmain ()\n{\n  char *p = (char *) __builtin_alloca (20);\n\n  strcpy (p, \"test\");\n\n  if (__builtin_setjmp (buf))\n    {\n      if (strcmp (p, \"test\") != 0)\n\tabort ();\n\n      exit (0);\n    }\n\n  {\n    int *q = (int *) __builtin_alloca (p[2] * sizeof (int));\n    int i;\n    \n    for (i = 0; i < p[2]; i++)\n      q[i] = 0;\n\n    while (1)\n      sub2 ();\n  }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-bitops-1.c",
    "content": "#include <limits.h>\n#include <assert.h>\n\n#if __INT_MAX__ > 2147483647L\n# if __INT_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_INT 64\n# else\n#  define BITSIZEOF_INT 32\n# endif\n#else\n# if __INT_MAX__ >= 2147483647L\n#  define BITSIZEOF_INT 32\n# else\n#  define BITSIZEOF_INT 16\n# endif\n#endif\n\n#if __LONG_MAX__ > 2147483647L\n# if __LONG_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_LONG 64\n# else\n#  define BITSIZEOF_LONG 32\n# endif\n#else\n# define BITSIZEOF_LONG 32\n#endif\n\n#if __LONG_LONG_MAX__ > 2147483647L\n# if __LONG_LONG_MAX__ >= 9223372036854775807L\n#  define BITSIZEOF_LONG_LONG 64\n# else\n#  define BITSIZEOF_LONG_LONG 32\n# endif\n#else\n# define BITSIZEOF_LONG_LONG 32\n#endif\n\n#define MAKE_FUNS(suffix, type)\t\t\t\t\t\t\\\nint my_ffs##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    if (x == 0)\t\t\t\t\t\t\t\t\\\n\t return 0; \t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1  << i))\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i + 1;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_ctz##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1  << i))\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i;\t\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_clz##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << ((CHAR_BIT * sizeof (type)) - i - 1)))\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i;\t\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_clrsb##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int leading = (x >> CHAR_BIT * sizeof (type) - 1) & 1;\t\t\\\n    for (i = 1; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (((x >> ((CHAR_BIT * sizeof (type)) - i - 1)) & 1)\t\t\\\n\t    != leading)\t\t\t\t\t\t\t\\\n\t    break;\t\t\t\t\t\t\t\\\n    return i - 1;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_popcount##suffix(type x) {\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int count = 0;\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << i))\t\t\t\t\t\\\n\t    count++;\t\t\t\t\t\t\t\\\n    return count;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\nint my_parity##suffix(type x) {\t\t\t\t\t\t\\\n    int i;\t\t\t\t\t\t\t\t\\\n    int count = 0;\t\t\t\t\t\t\t\\\n    for (i = 0; i < CHAR_BIT * sizeof (type); i++)\t\t\t\\\n\tif (x & ((type) 1 << i))\t\t\t\t\t\\\n\t    count++;\t\t\t\t\t\t\t\\\n    return count & 1;\t\t\t\t\t\t\t\\\n}\n\nMAKE_FUNS (, unsigned);\nMAKE_FUNS (l, unsigned long);\nMAKE_FUNS (ll, unsigned long long);\n\nextern void abort (void);\nextern void exit (int);\n\n#define NUMS16\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x0000U,\t\t\t\t\t\\\n    0x0001U,\t\t\t\t\t\\\n    0x8000U,\t\t\t\t\t\\\n    0x0002U,\t\t\t\t\t\\\n    0x4000U,\t\t\t\t\t\\\n    0x0100U,\t\t\t\t\t\\\n    0x0080U,\t\t\t\t\t\\\n    0xa5a5U,\t\t\t\t\t\\\n    0x5a5aU,\t\t\t\t\t\\\n    0xcafeU,\t\t\t\t\t\\\n    0xffffU\t\t\t\t\t\\\n  }\n\n#define NUMS32\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x00000000UL,\t\t\t\t\\\n    0x00000001UL,\t\t\t\t\\\n    0x80000000UL,\t\t\t\t\\\n    0x00000002UL,\t\t\t\t\\\n    0x40000000UL,\t\t\t\t\\\n    0x00010000UL,\t\t\t\t\\\n    0x00008000UL,\t\t\t\t\\\n    0xa5a5a5a5UL,\t\t\t\t\\\n    0x5a5a5a5aUL,\t\t\t\t\\\n    0xcafe0000UL,\t\t\t\t\\\n    0x00cafe00UL,\t\t\t\t\\\n    0x0000cafeUL,\t\t\t\t\\\n    0xffffffffUL\t\t\t\t\\\n  }\n\n#define NUMS64\t\t\t\t\t\\\n  {\t\t\t\t\t\t\\\n    0x0000000000000000ULL,\t\t\t\\\n    0x0000000000000001ULL,\t\t\t\\\n    0x8000000000000000ULL,\t\t\t\\\n    0x0000000000000002ULL,\t\t\t\\\n    0x4000000000000000ULL,\t\t\t\\\n    0x0000000100000000ULL,\t\t\t\\\n    0x0000000080000000ULL,\t\t\t\\\n    0xa5a5a5a5a5a5a5a5ULL,\t\t\t\\\n    0x5a5a5a5a5a5a5a5aULL,\t\t\t\\\n    0xcafecafe00000000ULL,\t\t\t\\\n    0x0000cafecafe0000ULL,\t\t\t\\\n    0x00000000cafecafeULL,\t\t\t\\\n    0xffffffffffffffffULL\t\t\t\\\n  }\n\nunsigned int ints[] =\n#if BITSIZEOF_INT == 64\nNUMS64;\n#elif BITSIZEOF_INT == 32\nNUMS32;\n#else\nNUMS16;\n#endif\n\nunsigned long longs[] =\n#if BITSIZEOF_LONG == 64\nNUMS64;\n#else\nNUMS32;\n#endif\n\nunsigned long long longlongs[] =\n#if BITSIZEOF_LONG_LONG == 64\nNUMS64;\n#else\nNUMS32;\n#endif\n\n#define N(table) (sizeof (table) / sizeof (table[0]))\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < N(ints); i++)\n    {\n      if (__builtin_ffs (ints[i]) != my_ffs (ints[i]))\n\tabort ();\n      if (ints[i] != 0\n\t  && __builtin_clz (ints[i]) != my_clz (ints[i]))\n\tabort ();\n      if (ints[i] != 0\n\t  && __builtin_ctz (ints[i]) != my_ctz (ints[i]))\n\tabort ();\n      if (__builtin_clrsb (ints[i]) != my_clrsb (ints[i]))\n\tabort ();\n      if (__builtin_popcount (ints[i]) != my_popcount (ints[i]))\n\tabort ();\n      if (__builtin_parity (ints[i]) != my_parity (ints[i]))\n\tabort ();\n    }\n\n  for (i = 0; i < N(longs); i++)\n    {\n      if (__builtin_ffsl (longs[i]) != my_ffsl (longs[i]))\n\tabort ();\n      if (longs[i] != 0\n\t  && __builtin_clzl (longs[i]) != my_clzl (longs[i]))\n\tabort ();\n      if (longs[i] != 0\n\t  && __builtin_ctzl (longs[i]) != my_ctzl (longs[i]))\n\tabort ();\n      if (__builtin_clrsbl (longs[i]) != my_clrsbl (longs[i]))\n\tabort ();\n      if (__builtin_popcountl (longs[i]) != my_popcountl (longs[i]))\n\tabort ();\n      if (__builtin_parityl (longs[i]) != my_parityl (longs[i]))\n\tabort ();\n    }\n\n  for (i = 0; i < N(longlongs); i++)\n    {\n      if (__builtin_ffsll (longlongs[i]) != my_ffsll (longlongs[i]))\n\tabort ();\n      if (longlongs[i] != 0\n\t  && __builtin_clzll (longlongs[i]) != my_clzll (longlongs[i]))\n\tabort ();\n      if (longlongs[i] != 0\n\t  && __builtin_ctzll (longlongs[i]) != my_ctzll (longlongs[i]))\n\tabort ();\n      if (__builtin_clrsbll (longlongs[i]) != my_clrsbll (longlongs[i]))\n\tabort ();\n      if (__builtin_popcountll (longlongs[i]) != my_popcountll (longlongs[i]))\n\tabort ();\n      if (__builtin_parityll (longlongs[i]) != my_parityll (longlongs[i]))\n\tabort ();\n    }\n\n  /* Test constant folding.  */\n\n#define TEST(x, suffix)\t\t\t\t\t\t\t\\\n  if (__builtin_ffs##suffix (x) != my_ffs##suffix (x))\t\t\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (x != 0 && __builtin_clz##suffix (x) != my_clz##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (x != 0 && __builtin_ctz##suffix (x) != my_ctz##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_clrsb##suffix (x) != my_clrsb##suffix (x))\t\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_popcount##suffix (x) != my_popcount##suffix (x))\t\\\n    abort ();\t\t\t\t\t\t\t\t\\\n  if (__builtin_parity##suffix (x) != my_parity##suffix (x))\t\t\\\n    abort ();\n\n#if BITSIZEOF_INT == 32\n  TEST(0x00000000UL,);\n  TEST(0x00000001UL,);\n  TEST(0x80000000UL,);\n  TEST(0x40000000UL,);\n  TEST(0x00010000UL,);\n  TEST(0x00008000UL,);\n  TEST(0xa5a5a5a5UL,);\n  TEST(0x5a5a5a5aUL,);\n  TEST(0xcafe0000UL,);\n  TEST(0x00cafe00UL,);\n  TEST(0x0000cafeUL,);\n  TEST(0xffffffffUL,);\n#endif\n\n#if BITSIZEOF_LONG_LONG == 64\n  TEST(0x0000000000000000ULL, ll);\n  TEST(0x0000000000000001ULL, ll);\n  TEST(0x8000000000000000ULL, ll);\n  TEST(0x0000000000000002ULL, ll);\n  TEST(0x4000000000000000ULL, ll);\n  TEST(0x0000000100000000ULL, ll);\n  TEST(0x0000000080000000ULL, ll);\n  TEST(0xa5a5a5a5a5a5a5a5ULL, ll);\n  TEST(0x5a5a5a5a5a5a5a5aULL, ll);\n  TEST(0xcafecafe00000000ULL, ll);\n  TEST(0x0000cafecafe0000ULL, ll);\n  TEST(0x00000000cafecafeULL, ll);\n  TEST(0xffffffffffffffffULL, ll);\n#endif\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-constant.c",
    "content": "/* PR optimization/8423.  */\n\n#define btest(x) __builtin_constant_p(x) ? \"1\" : \"0\"\n\n#ifdef __OPTIMIZE__\nvoid\nfoo (char *i)\n{\n  if (*i == '0')\n    abort ();\n}\n#else\nvoid\nfoo (char *i)\n{\n}\n#endif\n\nint\nmain (void)\n{\n  int size = sizeof (int);\n  foo (btest (size));\n  foo (btest (size));\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-1.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch using all valid combinations of rw and locality values.\n   These must be compile-time constants.  */\n\n#define NO_TEMPORAL_LOCALITY 0\n#define LOW_TEMPORAL_LOCALITY 1\n#define MODERATE_TEMPORAL_LOCALITY 1\n#define HIGH_TEMPORAL_LOCALITY 3\n\n#define WRITE_ACCESS 1\n#define READ_ACCESS 0\n\nenum locality { none, low, moderate, high };\nenum rw { read, write };\n\nint arr[10];\n\nvoid\ngood_const (const int *p)\n{\n  __builtin_prefetch (p, 0, 0);\n  __builtin_prefetch (p, 0, 1);\n  __builtin_prefetch (p, 0, 2);\n  __builtin_prefetch (p, READ_ACCESS, 3);\n  __builtin_prefetch (p, 1, NO_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, 1, LOW_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, 1, MODERATE_TEMPORAL_LOCALITY);\n  __builtin_prefetch (p, WRITE_ACCESS, HIGH_TEMPORAL_LOCALITY);\n}\n\nvoid\ngood_enum (const int *p)\n{\n    __builtin_prefetch (p, read, none);\n    __builtin_prefetch (p, read, low);\n    __builtin_prefetch (p, read, moderate);\n    __builtin_prefetch (p, read, high);\n    __builtin_prefetch (p, write, none);\n    __builtin_prefetch (p, write, low);\n    __builtin_prefetch (p, write, moderate);\n    __builtin_prefetch (p, write, high);\n}\n\nvoid\ngood_expr (const int *p)\n{\n  __builtin_prefetch (p, 1 - 1, 6 - (2 * 3));\n  __builtin_prefetch (p, 1 + 0, 1 + 2);\n}\n\nvoid\ngood_vararg (const int *p)\n{\n  __builtin_prefetch (p, 0, 3);\n  __builtin_prefetch (p, 0);\n  __builtin_prefetch (p, 1);\n  __builtin_prefetch (p);\n}\n\nint\nmain ()\n{\n  good_const (arr);\n  good_enum (arr);\n  good_expr (arr);\n  good_vararg (arr);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-2.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch data using a variety of storage classes and address\n   expressions.  */\n\nint glob_int_arr[100];\nint *glob_ptr_int = glob_int_arr;\nint glob_int = 4;\n\nstatic stat_int_arr[100];\nstatic int *stat_ptr_int = stat_int_arr;\nstatic int stat_int;\n\nstruct S {\n  int a;\n  short b, c;\n  char d[8];\n  struct S *next;\n};\n\nstruct S str;\nstruct S *ptr_str = &str;\n\n/* Prefetch global variables using the address of the variable.  */\n\nvoid\nsimple_global ()\n{\n  __builtin_prefetch (glob_int_arr, 0, 0);\n  __builtin_prefetch (glob_ptr_int, 0, 0);\n  __builtin_prefetch (&glob_int, 0, 0);\n}\n\n/* Prefetch file-level static variables using the address of the variable.  */\n\nvoid\nsimple_file ()\n{\n  __builtin_prefetch (stat_int_arr, 0, 0);\n  __builtin_prefetch (stat_ptr_int, 0, 0);\n  __builtin_prefetch (&stat_int, 0, 0);\n}\n\n/* Prefetch local static variables using the address of the variable.  */\n\nvoid\nsimple_static_local ()\n{\n  static int gx[100];\n  static int *hx = gx;\n  static int ix;\n  __builtin_prefetch (gx, 0, 0);\n  __builtin_prefetch (hx, 0, 0);\n  __builtin_prefetch (&ix, 0, 0);\n}\n\n/* Prefetch local stack variables using the address of the variable.  */\n\nvoid\nsimple_local ()\n{\n  int gx[100];\n  int *hx = gx;\n  int ix;\n  __builtin_prefetch (gx, 0, 0);\n  __builtin_prefetch (hx, 0, 0);\n  __builtin_prefetch (&ix, 0, 0);\n}\n\n/* Prefetch arguments using the address of the variable.  */\n\nvoid\nsimple_arg (int g[100], int *h, int i)\n{\n  __builtin_prefetch (g, 0, 0);\n  __builtin_prefetch (h, 0, 0);\n  __builtin_prefetch (&i, 0, 0);\n}\n\n/* Prefetch using address expressions involving global variables.  */\n\nvoid\nexpr_global (void)\n{\n  __builtin_prefetch (&str, 0, 0);\n  __builtin_prefetch (ptr_str, 0, 0);\n  __builtin_prefetch (&str.b, 0, 0);\n  __builtin_prefetch (&ptr_str->b, 0, 0);\n  __builtin_prefetch (&str.d, 0, 0);\n  __builtin_prefetch (&ptr_str->d, 0, 0);\n  __builtin_prefetch (str.next, 0, 0);\n  __builtin_prefetch (ptr_str->next, 0, 0);\n  __builtin_prefetch (str.next->d, 0, 0);\n  __builtin_prefetch (ptr_str->next->d, 0, 0);\n\n  __builtin_prefetch (&glob_int_arr, 0, 0);\n  __builtin_prefetch (glob_ptr_int, 0, 0);\n  __builtin_prefetch (&glob_int_arr[2], 0, 0);\n  __builtin_prefetch (&glob_ptr_int[3], 0, 0);\n  __builtin_prefetch (glob_int_arr+3, 0, 0);\n  __builtin_prefetch (glob_int_arr+glob_int, 0, 0);\n  __builtin_prefetch (glob_ptr_int+5, 0, 0);\n  __builtin_prefetch (glob_ptr_int+glob_int, 0, 0);\n}\n\n/* Prefetch using address expressions involving local variables.  */\n\nvoid\nexpr_local (void)\n{\n  int b[10];\n  int *pb = b;\n  struct S t;\n  struct S *pt = &t;\n  int j = 4;\n\n  __builtin_prefetch (&t, 0, 0);\n  __builtin_prefetch (pt, 0, 0);\n  __builtin_prefetch (&t.b, 0, 0);\n  __builtin_prefetch (&pt->b, 0, 0);\n  __builtin_prefetch (&t.d, 0, 0);\n  __builtin_prefetch (&pt->d, 0, 0);\n  __builtin_prefetch (t.next, 0, 0);\n  __builtin_prefetch (pt->next, 0, 0);\n  __builtin_prefetch (t.next->d, 0, 0);\n  __builtin_prefetch (pt->next->d, 0, 0);\n\n  __builtin_prefetch (&b, 0, 0);\n  __builtin_prefetch (pb, 0, 0);\n  __builtin_prefetch (&b[2], 0, 0);\n  __builtin_prefetch (&pb[3], 0, 0);\n  __builtin_prefetch (b+3, 0, 0);\n  __builtin_prefetch (b+j, 0, 0);\n  __builtin_prefetch (pb+5, 0, 0);\n  __builtin_prefetch (pb+j, 0, 0);\n}\n\nint\nmain ()\n{\n  simple_global ();\n  simple_file ();\n  simple_static_local ();\n  simple_local ();\n  simple_arg (glob_int_arr, glob_ptr_int, glob_int);\n\n  str.next = &str;\n  expr_global ();\n  expr_local ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-3.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Prefetch data using a variety of storage classes and address\n   expressions with volatile variables and pointers.  */\n\nint glob_int_arr[100];\nint glob_int = 4;\nvolatile int glob_vol_int_arr[100];\nint * volatile glob_vol_ptr_int = glob_int_arr;\nvolatile int *glob_ptr_vol_int = glob_vol_int_arr;\nvolatile int * volatile glob_vol_ptr_vol_int = glob_vol_int_arr;\nvolatile int glob_vol_int;\n\nstatic stat_int_arr[100];\nstatic volatile int stat_vol_int_arr[100];\nstatic int * volatile stat_vol_ptr_int = stat_int_arr;\nstatic volatile int *stat_ptr_vol_int = stat_vol_int_arr;\nstatic volatile int * volatile stat_vol_ptr_vol_int = stat_vol_int_arr;\nstatic volatile int stat_vol_int;\n\nstruct S {\n  int a;\n  short b, c;\n  char d[8];\n  struct S *next;\n};\n\nstruct S str;\nvolatile struct S vol_str;\nstruct S * volatile vol_ptr_str = &str;\nvolatile struct S *ptr_vol_str = &vol_str;\nvolatile struct S * volatile vol_ptr_vol_str = &vol_str;\n\n/* Prefetch volatile global variables using the address of the variable.  */\n\nvoid\nsimple_vol_global ()\n{\n  __builtin_prefetch (glob_vol_int_arr, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&glob_vol_int, 0, 0);\n}\n\n/* Prefetch volatile static variables using the address of the variable.  */\n\nvoid\nsimple_vol_file ()\n{\n  __builtin_prefetch (stat_vol_int_arr, 0, 0);\n  __builtin_prefetch (stat_vol_ptr_int, 0, 0);\n  __builtin_prefetch (stat_ptr_vol_int, 0, 0);\n  __builtin_prefetch (stat_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&stat_vol_int, 0, 0);\n}\n\n/* Prefetch using address expressions involving volatile global variables.  */\n\nvoid\nexpr_vol_global (void)\n{\n  __builtin_prefetch (&vol_str, 0, 0);\n  __builtin_prefetch (ptr_vol_str, 0, 0);\n  __builtin_prefetch (vol_ptr_str, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str, 0, 0);\n  __builtin_prefetch (&vol_str.b, 0, 0);\n  __builtin_prefetch (&ptr_vol_str->b, 0, 0);\n  __builtin_prefetch (&vol_ptr_str->b, 0, 0);\n  __builtin_prefetch (&vol_ptr_vol_str->b, 0, 0);\n  __builtin_prefetch (&vol_str.d, 0, 0);\n  __builtin_prefetch (&vol_ptr_str->d, 0, 0);\n  __builtin_prefetch (&ptr_vol_str->d, 0, 0);\n  __builtin_prefetch (&vol_ptr_vol_str->d, 0, 0);\n  __builtin_prefetch (vol_str.next, 0, 0);\n  __builtin_prefetch (vol_ptr_str->next, 0, 0);\n  __builtin_prefetch (ptr_vol_str->next, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str->next, 0, 0);\n  __builtin_prefetch (vol_str.next->d, 0, 0);\n  __builtin_prefetch (vol_ptr_str->next->d, 0, 0);\n  __builtin_prefetch (ptr_vol_str->next->d, 0, 0);\n  __builtin_prefetch (vol_ptr_vol_str->next->d, 0, 0);\n\n  __builtin_prefetch (&glob_vol_int_arr, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int, 0, 0);\n  __builtin_prefetch (&glob_vol_int_arr[2], 0, 0);\n  __builtin_prefetch (&glob_vol_ptr_int[3], 0, 0);\n  __builtin_prefetch (&glob_ptr_vol_int[3], 0, 0);\n  __builtin_prefetch (&glob_vol_ptr_vol_int[3], 0, 0);\n  __builtin_prefetch (glob_vol_int_arr+3, 0, 0);\n  __builtin_prefetch (glob_vol_int_arr+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int+5, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int+5, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int+5, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_int+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_ptr_vol_int+glob_vol_int, 0, 0);\n  __builtin_prefetch (glob_vol_ptr_vol_int+glob_vol_int, 0, 0);\n}\n\nint\nmain ()\n{\n  simple_vol_global ();\n  simple_vol_file ();\n\n  str.next = &str;\n  vol_str.next = &str;\n  expr_vol_global ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-4.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Check that the expression containing the address to prefetch is\n   evaluated if it has side effects, even if the target does not support\n   data prefetch.  Check changes to pointers and to array indices that are\n   either global variables or arguments.  */\n\n#define ARRSIZE 100\n\nint arr[ARRSIZE];\nint *ptr = &arr[20]; \nint arrindex = 4;\n\n/* Check that assignment within a prefetch argument is evaluated.  */\n\nint\nassign_arg_ptr (int *p)\n{\n  int *q;\n  __builtin_prefetch ((q = p), 0, 0);\n  return q == p;\n}\n\nint\nassign_glob_ptr (void)\n{\n  int *q;\n  __builtin_prefetch ((q = ptr), 0, 0);\n  return q == ptr;\n}\n\nint\nassign_arg_idx (int *p, int i)\n{\n  int j;\n  __builtin_prefetch (&p[j = i], 0, 0);\n  return j == i;\n}\n\nint\nassign_glob_idx (void)\n{\n  int j;\n  __builtin_prefetch (&ptr[j = arrindex], 0, 0);\n  return j == arrindex;\n}\n\n/* Check that pre/post increment/decrement within a prefetch argument are\n   evaluated.  */\n\nint\npreinc_arg_ptr (int *p)\n{\n  int *q;\n  q = p + 1;\n  __builtin_prefetch (++p, 0, 0);\n  return p == q;\n}\n\nint\npreinc_glob_ptr (void)\n{\n  int *q;\n  q = ptr + 1;\n  __builtin_prefetch (++ptr, 0, 0);\n  return ptr == q;\n}\n\nint\npostinc_arg_ptr (int *p)\n{\n  int *q;\n  q = p + 1;\n  __builtin_prefetch (p++, 0, 0);\n  return p == q;\n}\n\nint\npostinc_glob_ptr (void)\n{\n  int *q;\n  q = ptr + 1;\n  __builtin_prefetch (ptr++, 0, 0);\n  return ptr == q;\n}\n\nint\npredec_arg_ptr (int *p)\n{\n  int *q;\n  q = p - 1;\n  __builtin_prefetch (--p, 0, 0);\n  return p == q;\n}\n\nint\npredec_glob_ptr (void)\n{\n  int *q;\n  q = ptr - 1;\n  __builtin_prefetch (--ptr, 0, 0);\n  return ptr == q;\n}\n\nint\npostdec_arg_ptr (int *p)\n{\n  int *q;\n  q = p - 1;\n  __builtin_prefetch (p--, 0, 0);\n  return p == q;\n}\n\nint\npostdec_glob_ptr (void)\n{\n  int *q;\n  q = ptr - 1;\n  __builtin_prefetch (ptr--, 0, 0);\n  return ptr == q;\n}\n\nint\npreinc_arg_idx (int *p, int i)\n{\n  int j = i + 1;\n  __builtin_prefetch (&p[++i], 0, 0);\n  return i == j;\n}\n\n\nint\npreinc_glob_idx (void)\n{\n  int j = arrindex + 1;\n  __builtin_prefetch (&ptr[++arrindex], 0, 0);\n  return arrindex == j;\n}\n\nint\npostinc_arg_idx (int *p, int i)\n{\n  int j = i + 1;\n  __builtin_prefetch (&p[i++], 0, 0);\n  return i == j;\n}\n\nint\npostinc_glob_idx (void)\n{\n  int j = arrindex + 1;\n  __builtin_prefetch (&ptr[arrindex++], 0, 0);\n  return arrindex == j;\n}\n\nint\npredec_arg_idx (int *p, int i)\n{\n  int j = i - 1;\n  __builtin_prefetch (&p[--i], 0, 0);\n  return i == j;\n}\n\nint\npredec_glob_idx (void)\n{\n  int j = arrindex - 1;\n  __builtin_prefetch (&ptr[--arrindex], 0, 0);\n  return arrindex == j;\n}\n\nint\npostdec_arg_idx (int *p, int i)\n{\n  int j = i - 1;\n  __builtin_prefetch (&p[i--], 0, 0);\n  return i == j;\n}\n\nint\npostdec_glob_idx (void)\n{\n  int j = arrindex - 1;\n  __builtin_prefetch (&ptr[arrindex--], 0, 0);\n  return arrindex == j;\n}\n\n/* Check that function calls within the first prefetch argument are\n   evaluated.  */\n\nint getptrcnt = 0;\n\nint *\ngetptr (int *p)\n{\n  getptrcnt++;\n  return p + 1;\n}\n\nint\nfunccall_arg_ptr (int *p)\n{\n  __builtin_prefetch (getptr (p), 0, 0);\n  return getptrcnt == 1;\n}\n\nint getintcnt = 0;\n\nint\ngetint (int i)\n{\n  getintcnt++;\n  return i + 1;\n}\n\nint\nfunccall_arg_idx (int *p, int i)\n{\n  __builtin_prefetch (&p[getint (i)], 0, 0);\n  return getintcnt == 1;\n}\n\nint\nmain ()\n{\n  if (!assign_arg_ptr (ptr))\n    abort ();\n  if (!assign_glob_ptr ())\n    abort ();\n  if (!assign_arg_idx (ptr, 4))\n    abort ();\n  if (!assign_glob_idx ())\n    abort ();\n  if (!preinc_arg_ptr (ptr))\n    abort ();\n  if (!preinc_glob_ptr ())\n    abort ();\n  if (!postinc_arg_ptr (ptr))\n    abort ();\n  if (!postinc_glob_ptr ())\n    abort ();\n  if (!predec_arg_ptr (ptr))\n    abort ();\n  if (!predec_glob_ptr ())\n    abort ();\n  if (!postdec_arg_ptr (ptr))\n    abort ();\n  if (!postdec_glob_ptr ())\n    abort ();\n  if (!preinc_arg_idx (ptr, 3))\n    abort ();\n  if (!preinc_glob_idx ())\n    abort ();\n  if (!postinc_arg_idx (ptr, 3))\n    abort ();\n  if (!postinc_glob_idx ())\n    abort ();\n  if (!predec_arg_idx (ptr, 3))\n    abort ();\n  if (!predec_glob_idx ())\n    abort ();\n  if (!postdec_arg_idx (ptr, 3))\n    abort ();\n  if (!postdec_glob_idx ())\n    abort ();\n  if (!funccall_arg_ptr (ptr))\n    abort ();\n  if (!funccall_arg_idx (ptr, 3))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-5.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Use addresses that are unlikely to be word-aligned.  Some targets\n   have alignment requirements for prefetch addresses, so make sure the\n   compiler takes care of that.  This fails if it aborts, anything else\n   is OK.  */\n\nstruct S {\n  short a;\n  short b;\n  char c[8];\n} s;\n\nchar arr[100];\nchar *ptr = arr;\nint idx = 3;\n\nvoid\narg_ptr (char *p)\n{\n  __builtin_prefetch (p, 0, 0);\n}\n\nvoid\narg_idx (char *p, int i)\n{\n  __builtin_prefetch (&p[i], 0, 0);\n}\n\nvoid\nglob_ptr (void)\n{\n  __builtin_prefetch (ptr, 0, 0);\n}\n\nvoid\nglob_idx (void)\n{\n  __builtin_prefetch (&ptr[idx], 0, 0);\n}\n\nint\nmain ()\n{\n  __builtin_prefetch (&s.b, 0, 0);\n  __builtin_prefetch (&s.c[1], 0, 0);\n\n  arg_ptr (&s.c[1]);\n  arg_ptr (ptr+3);\n  arg_idx (ptr, 3);\n  arg_idx (ptr+1, 2);\n  idx = 3;\n  glob_ptr ();\n  glob_idx ();\n  ptr++;\n  idx = 2;\n  glob_ptr ();\n  glob_idx ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-6.c",
    "content": "/* Test that __builtin_prefetch does no harm.\n\n   Data prefetch should not fault if used with an invalid address.  */\n\n#include <limits.h>\n\n#define ARRSIZE 65\nint *bad_addr[ARRSIZE];\nint arr_used;\n\n/* Fill bad_addr with a range of values in the hopes that on any target\n   some will be invalid addresses.  */\nvoid\ninit_addrs (void)\n{\n  int i;\n  int bits_per_ptr = sizeof (void *) * 8;\n  for (i = 0; i < bits_per_ptr; i++)\n    bad_addr[i] = (void *)(1UL << i);\n  arr_used = bits_per_ptr + 1;  /* The last element used is zero.  */\n}\n\nvoid\nprefetch_for_read (void)\n{\n  int i;\n  for (i = 0; i < ARRSIZE; i++)\n    __builtin_prefetch (bad_addr[i], 0, 0);\n}\n\nvoid\nprefetch_for_write (void)\n{\n  int i;\n  for (i = 0; i < ARRSIZE; i++)\n    __builtin_prefetch (bad_addr[i], 1, 0);\n}\n\nint\nmain ()\n{\n  init_addrs ();\n  prefetch_for_read ();\n  prefetch_for_write ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/builtin-types-compatible-p.c",
    "content": "int i;\ndouble d;\n\n/* Make sure we return a constant.  */\nfloat rootbeer[__builtin_types_compatible_p (int, typeof(i))];\n\ntypedef enum { hot, dog, poo, bear } dingos;\ntypedef enum { janette, laura, amanda } cranberry;\n\ntypedef float same1;\ntypedef float same2;\n\nint main (void);\n\nint main (void)\n{\n  /* Compatible types.  */\n  if (!(__builtin_types_compatible_p (int, const int)\n\t&& __builtin_types_compatible_p (typeof (hot), int)\n\t&& __builtin_types_compatible_p (typeof (hot), typeof (laura))\n\t&& __builtin_types_compatible_p (int[5], int[])\n\t&& __builtin_types_compatible_p (same1, same2)))\n    abort ();\n\n  /* Incompatible types.  */\n  if (__builtin_types_compatible_p (char *, int)\n      || __builtin_types_compatible_p (char *, const char *)\n      || __builtin_types_compatible_p (long double, double)\n      || __builtin_types_compatible_p (typeof (i), typeof (d))\n      || __builtin_types_compatible_p (typeof (dingos), typeof (cranberry))\n      || __builtin_types_compatible_p (char, int)\n      || __builtin_types_compatible_p (char *, char **))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/call-trap-1.c",
    "content": "/* Undefined behavior from a call to a function cast to a different\n   type does not appear until after the function designator and\n   arguments have been evaluated.  PR 38483.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n/* { dg-require-effective-target untyped_assembly } */\n\nextern void exit (int);\nextern void abort (void);\n\nint\nfoo (void)\n{\n  exit (0);\n  return 0;\n}\n\nvoid\nbar (void)\n{\n}\n\nint\nmain (void)\n{\n  ((long (*)(int))bar) (foo ());\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cbrt.c",
    "content": "/*\n * ====================================================\n * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n *\n * Developed at SunPro, a Sun Microsystems, Inc. business.\n * Permission to use, copy, modify, and distribute this\n * software is freely granted, provided that this notice\n * is preserved.\n * ====================================================\n*/\n\n#ifndef __vax__\nstatic const unsigned long\n\tB1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */\n\tB2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */\n\nstatic const double\n\tC =  5.42857142857142815906e-01, /* 19/35     = 0x3FE15F15, 0xF15F15F1 */\n\tD = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */\n\tE =  1.41428571428571436819e+00, /* 99/70     = 0x3FF6A0EA, 0x0EA0EA0F */\n\tF =  1.60714285714285720630e+00, /* 45/28     = 0x3FF9B6DB, 0x6DB6DB6E */\n\tG =  3.57142857142857150787e-01; /* 5/14      = 0x3FD6DB6D, 0xB6DB6DB7 */\n\ndouble\ncbrtl (double x)\n{\n  long hx;\n  double r,s,w;\n  double lt;\n  unsigned sign;\n  typedef unsigned unsigned32 __attribute__((mode(SI)));\n  union {\n    double t;\n    unsigned32 pt[2];\n  } ut, ux;\n  int n0;\n\n  ut.t = 1.0;\n  n0 = (ut.pt[0] == 0);\n\n  ut.t = 0.0;\n  ux.t = x;\n\n  hx = ux.pt[n0];\t\t\t/* high word of x */\n  sign=hx&0x80000000;\t\t\t/* sign= sign(x) */\n  hx  ^=sign;\n  if(hx>=0x7ff00000) return(x+x);\t/* cbrt(NaN,INF) is itself */\n  if((hx| ux.pt[1-n0])==0)\n    return(ux.t);\t\t\t/* cbrt(0) is itself */\n\n  ux.pt[n0] = hx;\n  /* rough cbrt to 5 bits */\n  if(hx<0x00100000)\t\t\t/* subnormal number */\n    {ut.pt[n0]=0x43500000;\t\t/* set t= 2**54 */\n     ut.t*=x; ut.pt[n0]=ut.pt[n0]/3+B2;\n   }\n  else\n    ut.pt[n0]=hx/3+B1;\n\n  /* new cbrt to 23 bits, may be implemented in single precision */\n  r=ut.t*ut.t/ux.t;\n  s=C+r*ut.t;\n  ut.t*=G+F/(s+E+D/s);\n\n  /* chopped to 20 bits and make it larger than cbrt(x) */\n  ut.pt[1-n0]=0; ut.pt[n0]+=0x00000001;\n\n  /* one step newton iteration to 53 bits with error less than 0.667 ulps */\n  s=ut.t*ut.t;\t\t\t\t/* t*t is exact */\n  r=ux.t/s;\n  w=ut.t+ut.t;\n  r=(r-ut.t)/(w+r);\t\t\t/* r-s is exact */\n  ut.t=ut.t+ut.t*r;\n\n  /* restore the sign bit */\n  ut.pt[n0] |= sign;\n\n  lt = ut.t;\n  lt -= (lt - (x/(lt*lt))) * 0.333333333333333333333;\n  return lt;\n}\n\nmain ()\n{\n  if ((int) (cbrtl (27.0) + 0.5) != 3)\n    abort ();\n\n  exit (0);\n}\n#else\nmain () { exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c",
    "content": "#define F 140\n#define T 13\n\nfeq (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (x, y)\n     long long int x;\n     long long int y;\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfltu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfgeu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgtu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfleu (x, y)\n     unsigned long long int x;\n     unsigned long long int y;\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nlong long args[] =\n{\n  0LL,\n  1LL,\n  -1LL,\n  0x7fffffffffffffffLL,\n  0x8000000000000000LL,\n  0x8000000000000001LL,\n  0x1A3F237394D36C58LL,\n  0x93850E92CAAC1B04LL\n};\n\nint correct_results[] =\n{\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T\n};\n\nmain ()\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      long long arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  long long arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fltu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgeu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgtu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fleu (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cmpsf-1.c",
    "content": "#include <limits.h>\n\n#define F 140\n#define T 13\n\nfeq (float x, float y)\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (float x, float y)\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (float x, float y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (float x, float y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (float x, float y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (float x, float y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfloat args[] =\n{\n  0.0F,\n  1.0F,\n  -1.0F, \n  __FLT_MAX__,\n  __FLT_MIN__,\n  0.0000000000001F,\n  123456789.0F,\n  -987654321.0F\n};\n\nint correct_results[] =\n{\n T, F, F, T, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n T, F, F, T, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n T, F, F, T, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, T, F, F, T,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,                                             \n F, T, F, T, T, F,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n T, F, F, T, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, F, T, T, F,\n F, T, F, T, T, F,\n T, F, F, T, F, T,\n F, T, F, T, T, F,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n F, T, T, F, F, T,\n T, F, F, T, F, T,\n};\n\nint\nmain (void)\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      float arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  float arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cmpsi-1.c",
    "content": "f1 (unsigned int x, unsigned int y)\n{\n  if (x == 0)\n    dummy ();\n  x -= y;\n  /* 0xfffffff2 < 0x80000000? */\n  if (x < ~(~(unsigned int) 0 >> 1))\n    abort ();\n  return x;\n}\n\nf2 (unsigned long int x, unsigned long int y)\n{\n  if (x == 0)\n    dummy ();\n  x -= y;\n  /* 0xfffffff2 < 0x80000000? */\n  if (x < ~(~(unsigned long int) 0 >> 1))\n    abort ();\n  return x;\n}\n\n\ndummy () {}\n\nmain ()\n{\n  /*      0x7ffffff3\t\t\t0x80000001 */\n  f1 ((~(unsigned int) 0 >> 1) - 12, ~(~(unsigned int) 0 >> 1) + 1);\n  f2 ((~(unsigned long int) 0 >> 1) - 12, ~(~(unsigned long int) 0 >> 1) + 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cmpsi-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#define F 140\n#define T 13\n\nfeq (int x, int y)\n{\n  if (x == y)\n    return T;\n  else\n    return F;\n}\n\nfne (int x, int y)\n{\n  if (x != y)\n    return T;\n  else\n    return F;\n}\n\nflt (int x, int y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfge (int x, int y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgt (int x, int y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfle (int x, int y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nfltu (unsigned int x, unsigned int y)\n{\n  if (x < y)\n    return T;\n  else\n    return F;\n}\n\nfgeu (unsigned int x, unsigned int y)\n{\n  if (x >= y)\n    return T;\n  else\n    return F;\n}\n\nfgtu (unsigned int x, unsigned int y)\n{\n  if (x > y)\n    return T;\n  else\n    return F;\n}\n\nfleu (unsigned int x, unsigned int y)\n{\n  if (x <= y)\n    return T;\n  else\n    return F;\n}\n\nunsigned int args[] =\n{\n  0L,\n  1L,\n  -1L,\n  0x7fffffffL,\n  0x80000000L,\n  0x80000001L,\n  0x1A3F2373L,\n  0x93850E92L\n};\n\nint correct_results[] =\n{\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  T, F, F, T, F, T, F, T, F, T,\n  F, T, F, T, T, F, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, T, F, F, T, T, F, F, T,\n  F, T, T, F, F, T, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, F, T, T, F, F, T, T, F,\n  F, T, T, F, F, T, F, T, T, F,\n  T, F, F, T, F, T, F, T, F, T\n};\n\nint\nmain (void)\n{\n  int i, j, *res = correct_results;\n\n  for (i = 0; i < 8; i++)\n    {\n      unsigned int arg0 = args[i];\n      for (j = 0; j < 8; j++)\n\t{\n\t  unsigned int arg1 = args[j];\n\n\t  if (feq (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fne (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (flt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fge (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgt (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fle (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fltu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgeu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fgtu (arg0, arg1) != *res++)\n\t    abort ();\n\t  if (fleu (arg0, arg1) != *res++)\n\t    abort ();\n\t}\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c",
    "content": "#include <stdlib.h>\n\n#if !defined(NO_LABEL_VALUES) && (!defined(STACK_SIZE) || STACK_SIZE >= 4000) && __INT_MAX__ >= 2147483647\ntypedef unsigned int uint32;\ntypedef signed int sint32;\n\ntypedef uint32 reg_t;\n\ntypedef unsigned long int host_addr_t;\ntypedef uint32 target_addr_t;\ntypedef sint32 target_saddr_t;\n\ntypedef union\n{\n  struct\n    {\n      signed int\toffset:18;\n      unsigned int\tignore:4;\n      unsigned int\ts1:8;\n      int\t\t:2;\n      signed int\tsimm:14;\n      unsigned int\ts3:8;\n      unsigned int\ts2:8;\n      int\t\tpad2:2;\n    } f1;\n  long long ll;\n  double d;\n} insn_t;\n\ntypedef struct\n{\n  target_addr_t vaddr_tag;\n  unsigned long int rigged_paddr;\n} tlb_entry_t;\n\ntypedef struct\n{\n  insn_t *pc;\n  reg_t registers[256];\n  insn_t *program;\n  tlb_entry_t tlb_tab[0x100];\n} environment_t;\n\nenum operations\n{\n  LOAD32_RR,\n  METAOP_DONE\n};\n\nhost_addr_t\nf ()\n{\n  abort ();\n}\n\nreg_t\nsimulator_kernel (int what, environment_t *env)\n{\n  register insn_t *pc = env->pc;\n  register reg_t *regs = env->registers;\n  register insn_t insn;\n  register int s1;\n  register reg_t r2;\n  register void *base_addr = &&sim_base_addr;\n  register tlb_entry_t *tlb = env->tlb_tab;\n\n  if (what != 0)\n    {\n      int i;\n      static void *op_map[] =\n\t{\n\t  &&L_LOAD32_RR,\n\t  &&L_METAOP_DONE,\n\t};\n      insn_t *program = env->program;\n      for (i = 0; i < what; i++)\n\tprogram[i].f1.offset = op_map[program[i].f1.offset] - base_addr;\n    }\n\n sim_base_addr:;\n\n  insn = *pc++;\n  r2 = (*(reg_t *) (((char *) regs) + (insn.f1.s2 << 2)));\n  s1 = (insn.f1.s1 << 2);\n  goto *(base_addr + insn.f1.offset);\n\n L_LOAD32_RR:\n  {\n    target_addr_t vaddr_page = r2 / 4096;\n    unsigned int x = vaddr_page % 0x100;\n    insn = *pc++;\n\n    for (;;)\n      {\n\ttarget_addr_t tag = tlb[x].vaddr_tag;\n\thost_addr_t rigged_paddr = tlb[x].rigged_paddr;\n\n\tif (tag == vaddr_page)\n\t  {\n\t    *(reg_t *) (((char *) regs) + s1) = *(uint32 *) (rigged_paddr + r2);\n\t    r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));\n\t    s1 = insn.f1.s1 << 2;\n\t    goto *(base_addr + insn.f1.offset);\n\t  }\n\n\tif (((target_saddr_t) tag < 0))\n\t  {\n\t    *(reg_t *) (((char *) regs) + s1) = *(uint32 *) f ();\n\t    r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2));\n\t    s1 = insn.f1.s1 << 2;\n\t    goto *(base_addr + insn.f1.offset);\n\t  }\n\n\tx = (x - 1) % 0x100;\n      }\n\n    L_METAOP_DONE:\n      return (*(reg_t *) (((char *) regs) + s1));\n  }\n}\n\ninsn_t program[2 + 1];\n\nvoid *malloc ();\n\nint\nmain ()\n{\n  environment_t env;\n  insn_t insn;\n  int i, res;\n  host_addr_t a_page = (host_addr_t) malloc (2 * 4096);\n  target_addr_t a_vaddr = 0x123450;\n  target_addr_t vaddr_page = a_vaddr / 4096;\n  a_page = (a_page + 4096 - 1) & -4096;\n\n  env.tlb_tab[((vaddr_page) % 0x100)].vaddr_tag = vaddr_page;\n  env.tlb_tab[((vaddr_page) % 0x100)].rigged_paddr = a_page - vaddr_page * 4096;\n  insn.f1.offset = LOAD32_RR;\n  env.registers[0] = 0;\n  env.registers[2] = a_vaddr;\n  *(sint32 *) (a_page + a_vaddr % 4096) = 88;\n  insn.f1.s1 = 0;\n  insn.f1.s2 = 2;\n\n  for (i = 0; i < 2; i++)\n    program[i] = insn;\n\n  insn.f1.offset = METAOP_DONE;\n  insn.f1.s1 = 0;\n  program[2] = insn;\n\n  env.pc = program;\n  env.program = program;\n\n  res = simulator_kernel (2 + 1, &env);\n\n  if (res != 88)\n    abort ();\n  exit (0);\n}\n#else\nmain(){ exit (0); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/comp-goto-2.c",
    "content": "/* A slight variation of 920501-7.c.  */\n\n#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 1000\n#endif\n\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\nx(a)\n{\n  __label__ xlab;\n  void y(a)\n    {\n      void *x = &&llab;\n      if (a==-1)\n\tgoto *x;\n      if (a==0)\n\tgoto xlab;\n    llab:\n      y (a-1);\n    }\n  y (a);\n xlab:;\n  return a;\n}\n#endif\n\nmain ()\n{\n#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)\n  if (x (DEPTH) != DEPTH)\n    abort ();\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/compare-1.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Test for correctness of composite comparisons.\n\n   Written by Roger Sayle, 3rd June 2002.  */\n\nextern void abort (void);\n\nint ieq (int x, int y, int ok)\n{\n  if ((x<=y) && (x>=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((x<=y) && (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((x<=y) && (y<=x))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n\n  if ((y==x) && (x<=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ine (int x, int y, int ok)\n{\n  if ((x<y) || (x>y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ilt (int x, int y, int ok)\n{\n  if ((x<y) && (x!=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ile (int x, int y, int ok)\n{\n  if ((x<y) || (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint igt (int x, int y, int ok)\n{\n  if ((x>y) && (x!=y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint ige (int x, int y, int ok)\n{\n  if ((x>y) || (x==y))\n    {\n      if (!ok) abort ();\n    }\n  else\n    if (ok) abort ();\n}\n\nint\nmain ()\n{\n  ieq (1, 4, 0);\n  ieq (3, 3, 1);\n  ieq (5, 2, 0);\n\n  ine (1, 4, 1);\n  ine (3, 3, 0);\n  ine (5, 2, 1);\n\n  ilt (1, 4, 1);\n  ilt (3, 3, 0);\n  ilt (5, 2, 0);\n\n  ile (1, 4, 1);\n  ile (3, 3, 1);\n  ile (5, 2, 0);\n\n  igt (1, 4, 0);\n  igt (3, 3, 0);\n  igt (5, 2, 1);\n\n  ige (1, 4, 0);\n  ige (3, 3, 1);\n  ige (5, 2, 1);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/compare-2.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Ensure that the composite comparison optimization doesn't misfire\n   and attempt to combine a signed comparison with an unsigned one.\n\n   Written by Roger Sayle, 3rd June 2002.  */\n\nextern void abort (void);\n\nint\nfoo (int x, int y)\n{\n  /* If miscompiled the following may become \"x == y\".  */\n  return (x<=y) && ((unsigned int)x >= (unsigned int)y);\n}\n\nint\nmain ()\n{\n  if (! foo (-1,0))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/compare-3.c",
    "content": "/* Copyright (C) 2002 Free Software Foundation.\n\n   Test for composite comparison always true/false optimization.\n\n   Written by Roger Sayle, 7th June 2002.  */\n\nextern void link_error0 ();\nextern void link_error1 ();\n\nvoid\ntest1 (int x, int y)\n{\n  if ((x==y) && (x!=y))\n    link_error0();\n}\n\nvoid\ntest2 (int x, int y)\n{\n  if ((x<y) && (x>y))\n    link_error0();\n}\n\nvoid\ntest3 (int x, int y)\n{\n  if ((x<y) && (y<x))\n    link_error0();\n}\n\nvoid \ntest4 (int x, int y)\n{\n  if ((x==y) || (x!=y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest5 (int x, int y)\n{\n  if ((x>=y) || (x<y))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\ntest6 (int x, int y)\n{\n  if ((x<=y) || (y<x))\n    {\n    }\n  else\n    link_error1 ();\n}\n\nvoid\nall_tests (int x, int y)\n{\n  test1 (x, y);\n  test2 (x, y);\n  test3 (x, y);\n  test4 (x, y);\n  test5 (x, y);\n  test6 (x, y);\n}\n\nint\nmain ()\n{\n  all_tests (0, 0);\n  all_tests (1, 2);\n  all_tests (4, 3);\n\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid link_error0() {}\nvoid link_error1() {}\n#endif /* ! __OPTIMIZE__ */\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-1.c",
    "content": "double\ng0 (double x)\n{\n  return 1.0;\n}\n\ndouble\ng1 (double x)\n{\n  return -1.0;\n}\n\ndouble\ng2 (double x)\n{\n  return 0.0;\n}\n\n__complex__ double\nxcexp (__complex__ double x)\n{\n  double r;\n\n  r = g0 (__real__ x);\n  __real__ x = r * g1 (__imag__ x);\n  __imag__ x = r * g2 (__imag__ x);\n  return x;\n}\n\nmain ()\n{\n  __complex__ double x;\n\n  x = xcexp (1.0i);\n  if (__real__ x != -1.0)\n    abort ();\n  if (__imag__ x != 0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-2.c",
    "content": "__complex__ double\nf (__complex__ double x, __complex__ double y)\n{\n  x += y;\n  return x;\n}\n\n__complex__ double ag = 1.0 + 1.0i;\n__complex__ double bg = -2.0 + 2.0i;\n\nmain ()\n{\n  __complex__ double a, b, c;\n\n  a = ag;\n  b = -2.0 + 2.0i;\n  c = f (a, b);\n\n  if (a != 1.0 + 1.0i)\n    abort ();\n  if (b != -2.0 + 2.0i)\n    abort ();\n  if (c != -1.0 + 3.0i)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-3.c",
    "content": "struct complex\n{\n  float r;\n  float i;\n};\n\nstruct complex cmplx (float, float);\n\nstruct complex\nf (float a, float b)\n{\n  struct complex c;\n  c.r = a;\n  c.i = b;\n  return c;\n}\n\nmain ()\n{\n  struct complex z = f (1.0, 0.0);\n\n  if (z.r != 1.0 || z.i != 0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-4.c",
    "content": "main ()\n{\n  if ((__complex__ double) 0.0 != (__complex__ double) (-0.0))\n    abort ();\n\n  if (0.0 != -0.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-5.c",
    "content": "float __complex__\np (float __complex__  a, float __complex__  b)\n{\n  return a + b;\n}\n\nfloat __complex__  x = 1.0 + 14.0 * (1.0fi);\nfloat __complex__  y = 7.0 + 5.0 * (1.0fi);\nfloat __complex__  w = 8.0 + 19.0 * (1.0fi);\nfloat __complex__  z;\n\nmain ()\n{\n\n  z = p (x,y);\n  y = p (x, 1.0f / z);\n  if (z != w)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-6.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n/* This test tests complex conjugate and passing/returning of\n   complex parameter.  */\n\n#include <stdlib.h>\n#include <stdio.h>\n\nint err;\n\n#define TEST(TYPE, FUNC)\t\t\t\t\t\\\n__complex__ TYPE\t\t\t\t\t\t\\\nctest_ ## FUNC (__complex__ TYPE x)\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  __complex__ TYPE res;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  res = ~x;\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  return res;\t\t\t\t\t\t\t\\\n}\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\nvoid\t\t\t\t\t\t\t\t\\\ntest_ ## FUNC (void)\t\t\t\t\t\t\\\n{\t\t\t\t\t\t\t\t\\\n  __complex__ TYPE res, x;\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  x = 1.0 + 2.0i;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  res = ctest_ ## FUNC (x);\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n  if (res != 1.0 - 2.0i)\t\t\t\t\t\\\n    {\t\t\t\t\t\t\t\t\\\n      printf (\"test_\" #FUNC \" failed\\n\");\t\t\t\\\n      ++err;\t\t\t\t\t\t\t\\\n    }\t\t\t\t\t\t\t\t\\\n}\n\n\nTEST(float, float)\nTEST(double, double)\nTEST(long double, long_double)\nTEST(int, int)\nTEST(long int, long_int)\n\nint\nmain (void)\n{\n\n  err = 0;\n\n  test_float ();\n  test_double ();\n  test_long_double ();\n  test_int ();\n  test_long_int ();\n\n  if (err != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/complex-7.c",
    "content": "/* Test argument passing of complex values.  The MIPS64 compiler had a\n   bug when they were split between registers and the stack.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\nvolatile _Complex float f1 = 1.1f + 2.2if;\nvolatile _Complex float f2 = 3.3f + 4.4if;\nvolatile _Complex float f3 = 5.5f + 6.6if;\nvolatile _Complex float f4 = 7.7f + 8.8if;\nvolatile _Complex float f5 = 9.9f + 10.1if;\nvolatile _Complex double d1 = 1.1 + 2.2i;\nvolatile _Complex double d2 = 3.3 + 4.4i;\nvolatile _Complex double d3 = 5.5 + 6.6i;\nvolatile _Complex double d4 = 7.7 + 8.8i;\nvolatile _Complex double d5 = 9.9 + 10.1i;\nvolatile _Complex long double ld1 = 1.1L + 2.2iL;\nvolatile _Complex long double ld2 = 3.3L + 4.4iL;\nvolatile _Complex long double ld3 = 5.5L + 6.6iL;\nvolatile _Complex long double ld4 = 7.7L + 8.8iL;\nvolatile _Complex long double ld5 = 9.9L + 10.1iL;\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__((noinline)) void\ncheck_float (int a, _Complex float a1, _Complex float a2,\n\t     _Complex float a3, _Complex float a4, _Complex float a5)\n{\n  if (a1 != f1 || a2 != f2 || a3 != f3 || a4 != f4 || a5 != f5)\n    abort ();\n}\n\n__attribute__((noinline)) void\ncheck_double (int a, _Complex double a1, _Complex double a2,\n\t     _Complex double a3, _Complex double a4, _Complex double a5)\n{\n  if (a1 != d1 || a2 != d2 || a3 != d3 || a4 != d4 || a5 != d5)\n    abort ();\n}\n\n__attribute__((noinline)) void\ncheck_long_double (int a, _Complex long double a1, _Complex long double a2,\n\t     _Complex long double a3, _Complex long double a4,\n\t\t   _Complex long double a5)\n{\n  if (a1 != ld1 || a2 != ld2 || a3 != ld3 || a4 != ld4 || a5 != ld5)\n    abort ();\n}\n\nint\nmain (void)\n{\n  check_float (0, f1, f2, f3, f4, f5);\n  check_double (0, d1, d2, d3, d4, d5);\n  check_long_double (0, ld1, ld2, ld3, ld4, ld5);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/compndlit-1.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\nstruct S\n{\n  int a:3;\n  unsigned b:1, c:28;\n};\n\nstruct S x = {1, 1, 1};\n\nmain ()\n{\n  x = (struct S) {b:0, a:0, c:({ struct S o = x; o.a == 1 ? 10 : 20;})};\n  if (x.c != 10)\n    abort ();\n  exit (0);\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/const-addr-expr-1.c",
    "content": "#include        <stdio.h>\n#include        <stdlib.h>\nextern void abort();\n\ntypedef struct foo\n{\n        int     uaattrid;\n        char    *name;\n} FOO;\n\nFOO     Upgrade_items[] =\n{\n        {1, \"1\"},\n        {2, \"2\"},\n        {0, NULL}\n};\n\nint     *Upgd_minor_ID = \n        (int *) &((Upgrade_items + 1)->uaattrid);\n\nint     *Upgd_minor_ID1 = \n        (int *) &((Upgrade_items)->uaattrid);\n\nint\nmain(int argc, char **argv)\n{\n\tif (*Upgd_minor_ID != 2)\n\t  abort();\n\n\tif (*Upgd_minor_ID1 != 1)\n\t  abort();\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/conversion.c",
    "content": "/* Test front-end conversions, optimizer conversions, and run-time\n   conversions between different arithmetic types.\n\n   Constants are specified in a non-obvious way to make them work for\n   any word size.  Their value on a 32-bit machine is indicated in the\n   comments.\n\n   Note that this code is NOT intended for testing of accuracy of fp\n   conversions.  */\n\nfloat\nu2f(u)\n     unsigned int u;\n{\n  return u;\n}\n\ndouble\nu2d(u)\n     unsigned int u;\n{\n  return u;\n}\n\nlong double\nu2ld(u)\n     unsigned int u;\n{\n  return u;\n}\n\nfloat\ns2f(s)\n     int s;\n{\n  return s;\n}\n\ndouble\ns2d(s)\n     int s;\n{\n  return s;\n}\n\nlong double\ns2ld(s)\n     int s;\n{\n  return s;\n}\n\nint\nfnear (float x, float y)\n{\n  float t = x - y;\n  return t == 0 || x / t > 1000000.0;\n}\n\nint\ndnear (double x, double y)\n{\n  double t = x - y;\n  return t == 0 || x / t > 100000000000000.0;\n}\n\nint\nldnear (long double x, long double y)\n{\n  long double t = x - y;\n  return t == 0 || x / t > 100000000000000000000000000000000.0;\n}\n\ntest_integer_to_float()\n{\n  if (u2f(0U) != (float) 0U)\t\t\t\t/* 0 */\n    abort();\n  if (!fnear (u2f(~0U), (float) ~0U))\t\t\t/* 0xffffffff */\n    abort();\n  if (!fnear (u2f((~0U) >> 1), (float) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2f(~((~0U) >> 1)) != (float) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (u2d(0U) != (double) 0U)\t\t\t\t/* 0 */\n    abort();\n  if (!dnear (u2d(~0U), (double) ~0U))\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (u2d((~0U) >> 1),(double) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2d(~((~0U) >> 1)) != (double) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (u2ld(0U) != (long double) 0U)\t\t\t/* 0 */\n    abort();\n  if (!ldnear (u2ld(~0U), (long double) ~0U))\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (u2ld((~0U) >> 1),(long double) ((~0U) >> 1)))\t/* 0x7fffffff */\n    abort();\n  if (u2ld(~((~0U) >> 1)) != (long double) ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n  if (s2f(0) != (float) 0)\t\t\t\t/* 0 */\n    abort();\n  if (!fnear (s2f(~0), (float) ~0))\t\t\t/* 0xffffffff */\n    abort();\n  if (!fnear (s2f((int)((~0U) >> 1)), (float)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2f((int)(~((~0U) >> 1))) != (float)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (s2d(0) != (double) 0)\t\t\t\t/* 0 */\n    abort();\n  if (!dnear (s2d(~0), (double) ~0))\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (s2d((int)((~0U) >> 1)), (double)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (s2ld(0) != (long double) 0)\t\t\t/* 0 */\n    abort();\n  if (!ldnear (s2ld(~0), (long double) ~0))\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (s2ld((int)((~0U) >> 1)), (long double)(int)((~0U) >> 1))) /* 0x7fffffff */\n    abort();\n  if (s2ld((int)~((~0U) >> 1)) != (long double)(int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n}\n\n#if __GNUC__\nfloat\null2f(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\ndouble\null2d(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\nlong double\null2ld(u)\n     unsigned long long int u;\n{\n  return u;\n}\n\nfloat\nsll2f(s)\n     long long int s;\n{\n  return s;\n}\n\ndouble\nsll2d(s)\n     long long int s;\n{\n  return s;\n}\n\nlong double\nsll2ld(s)\n     long long int s;\n{\n  return s;\n}\n\ntest_longlong_integer_to_float()\n{\n  if (ull2f(0ULL) != (float) 0ULL)\t\t\t/* 0 */\n    abort();\n  if (ull2f(~0ULL) != (float) ~0ULL)\t\t\t/* 0xffffffff */\n    abort();\n  if (ull2f((~0ULL) >> 1) != (float) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n  if (ull2f(~((~0ULL) >> 1)) != (float) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ull2d(0ULL) != (double) 0ULL)\t\t\t/* 0 */\n    abort();\n#if __HAVE_68881__\n  /* Some 68881 targets return values in fp0, with excess precision.\n     But the compile-time conversion to double works correctly.  */\n  if (! dnear (ull2d(~0ULL), (double) ~0ULL))\t\t/* 0xffffffff */\n    abort();\n  if (! dnear (ull2d((~0ULL) >> 1), (double) ((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n#else\n  if (ull2d(~0ULL) != (double) ~0ULL)\t\t\t/* 0xffffffff */\n    abort();\n  if (ull2d((~0ULL) >> 1) != (double) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n#endif\n  if (ull2d(~((~0ULL) >> 1)) != (double) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ull2ld(0ULL) != (long double) 0ULL)\t\t/* 0 */\n    abort();\n  if (ull2ld(~0ULL) != (long double) ~0ULL)\t\t/* 0xffffffff */\n    abort();\n  if (ull2ld((~0ULL) >> 1) != (long double) ((~0ULL) >> 1))\t/* 0x7fffffff */\n    abort();\n  if (ull2ld(~((~0ULL) >> 1)) != (long double) ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (sll2f(0LL) != (float) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2f(~0LL) != (float) ~0LL)\t\t\t/* 0xffffffff */\n    abort();\n  if (! fnear (sll2f((long long int)((~0ULL) >> 1)), (float)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (sll2f((long long int)(~((~0ULL) >> 1))) != (float)(long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (sll2d(0LL) != (double) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2d(~0LL) != (double) ~0LL)\t\t\t/* 0xffffffff */\n    abort();\n  if (!dnear (sll2d((long long int)((~0ULL) >> 1)), (double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (! dnear (sll2d((long long int)~((~0ULL) >> 1)), (double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */\n    abort();\n\n  if (sll2ld(0LL) != (long double) 0LL)\t\t\t/* 0 */\n    abort();\n  if (sll2ld(~0LL) != (long double) ~0LL)\t\t/* 0xffffffff */\n    abort();\n  if (!ldnear (sll2ld((long long int)((~0ULL) >> 1)), (long double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */\n    abort();\n  if (! ldnear (sll2ld((long long int)~((~0ULL) >> 1)), (long double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */\n    abort();\n}\n#endif\n\nunsigned int\nf2u(float f)\n{\n  return (unsigned) f;\n}\n\nunsigned int\nd2u(double d)\n{\n  return (unsigned) d;\n}\n\nunsigned int\nld2u(long double d)\n{\n  return (unsigned) d;\n}\n\nint\nf2s(float f)\n{\n  return (int) f;\n}\n\nint\nd2s(double d)\n{\n  return (int) d;\n}\n\nint\nld2s(long double d)\n{\n  return (int) d;\n}\n\ntest_float_to_integer()\n{\n  if (f2u(0.0) != 0)\n    abort();\n  if (f2u(0.999) != 0)\n    abort();\n  if (f2u(1.0) != 1)\n    abort();\n  if (f2u(1.99) != 1)\n    abort();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2u((float) ((~0U) >> 1)) != 0x7fffff80)\n    abort();\n#else\n  if (f2u((float) ((~0U) >> 1)) != (~0U) >> 1 &&\t/* 0x7fffffff */\n      f2u((float) ((~0U) >> 1)) != ((~0U) >> 1) + 1)\n    abort();\n#endif\n  if (f2u((float) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n\n /* These tests require double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (double) >= 8) {\n  if (d2u(0.0) != 0)\n    abort();\n  if (d2u(0.999) != 0)\n    abort();\n  if (d2u(1.0) != 1)\n    abort();\n  if (d2u(1.99) != 1)\n    abort();\n  if (d2u((double) (~0U)) != ~0U)\t\t\t/* 0xffffffff */\n    abort();\n  if (d2u((double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (d2u((double) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n }\n\n /* These tests require long double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (long double) >= 8) {\n  if (ld2u(0.0) != 0)\n    abort();\n  if (ld2u(0.999) != 0)\n    abort();\n  if (ld2u(1.0) != 1)\n    abort();\n  if (ld2u(1.99) != 1)\n    abort();\n  if (ld2u((long double) (~0U)) != ~0U)\t\t\t/* 0xffffffff */\n    abort();\n  if (ld2u((long double) ((~0U) >> 1)) != (~0U) >> 1)\t/* 0x7fffffff */\n    abort();\n  if (ld2u((long double) ~((~0U) >> 1)) != ~((~0U) >> 1))\t/* 0x80000000 */\n    abort();\n }\n\n  if (f2s(0.0) != 0)\n    abort();\n  if (f2s(0.999) != 0)\n    abort();\n  if (f2s(1.0) != 1)\n    abort();\n  if (f2s(1.99) != 1)\n    abort();\n  if (f2s(-0.999) != 0)\n    abort();\n  if (f2s(-1.0) != -1)\n    abort();\n  if (f2s(-1.99) != -1)\n    abort();\n  if (f2s((float)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n\n /* These tests require double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (double) >= 8) {\n  if (d2s(0.0) != 0)\n    abort();\n  if (d2s(0.999) != 0)\n    abort();\n  if (d2s(1.0) != 1)\n    abort();\n  if (d2s(1.99) != 1)\n    abort();\n  if (d2s(-0.999) != 0)\n    abort();\n  if (d2s(-1.0) != -1)\n    abort();\n  if (d2s(-1.99) != -1)\n    abort();\n  if (d2s((double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (d2s((double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n }\n\n /* These tests require long double precision, so for hosts that don't offer\n    that much precision, just ignore these test.  */\n if (sizeof (long double) >= 8) {\n  if (ld2s(0.0) != 0)\n    abort();\n  if (ld2s(0.999) != 0)\n    abort();\n  if (ld2s(1.0) != 1)\n    abort();\n  if (ld2s(1.99) != 1)\n    abort();\n  if (ld2s(-0.999) != 0)\n    abort();\n  if (ld2s(-1.0) != -1)\n    abort();\n  if (ld2s(-1.99) != -1)\n    abort();\n  if (ld2s((long double) ((~0U) >> 1)) != (~0U) >> 1)\t\t/* 0x7fffffff */\n    abort();\n  if (ld2s((long double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */\n    abort();\n }\n}\n\n#if __GNUC__\nunsigned long long int\nf2ull(float f)\n{\n  return (unsigned long long int) f;\n}\n\nunsigned long long int\nd2ull(double d)\n{\n  return (unsigned long long int) d;\n}\n\nunsigned long long int\nld2ull(long double d)\n{\n  return (unsigned long long int) d;\n}\n\nlong long int\nf2sll(float f)\n{\n  return (long long int) f;\n}\n\nlong long int\nd2sll(double d)\n{\n  return (long long int) d;\n}\n\nlong long int\nld2sll(long double d)\n{\n  return (long long int) d;\n}\n\ntest_float_to_longlong_integer()\n{\n  if (f2ull(0.0) != 0LL)\n    abort();\n  if (f2ull(0.999) != 0LL)\n    abort();\n  if (f2ull(1.0) != 1LL)\n    abort();\n  if (f2ull(1.99) != 1LL)\n    abort();\n#ifdef __SPU__\n  /* SPU float rounds towards zero.  */\n  if (f2ull((float) ((~0ULL) >> 1)) != 0x7fffff8000000000ULL)\n    abort();\n#else\n  if (f2ull((float) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      f2ull((float) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n#endif\n  if (f2ull((float) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (d2ull(0.0) != 0LL)\n    abort();\n  if (d2ull(0.999) != 0LL)\n    abort();\n  if (d2ull(1.0) != 1LL)\n    abort();\n  if (d2ull(1.99) != 1LL)\n    abort();\n  if (d2ull((double) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      d2ull((double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n  if (d2ull((double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ld2ull(0.0) != 0LL)\n    abort();\n  if (ld2ull(0.999) != 0LL)\n    abort();\n  if (ld2ull(1.0) != 1LL)\n    abort();\n  if (ld2ull(1.99) != 1LL)\n    abort();\n  if (ld2ull((long double) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&\t/* 0x7fffffff */\n      ld2ull((long double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)\n    abort();\n  if (ld2ull((long double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n\n  if (f2sll(0.0) != 0LL)\n    abort();\n  if (f2sll(0.999) != 0LL)\n    abort();\n  if (f2sll(1.0) != 1LL)\n    abort();\n  if (f2sll(1.99) != 1LL)\n    abort();\n  if (f2sll(-0.999) != 0LL)\n    abort();\n  if (f2sll(-1.0) != -1LL)\n    abort();\n  if (f2sll(-1.99) != -1LL)\n    abort();\n  if (f2sll((float)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (d2sll(0.0) != 0LL)\n    abort();\n  if (d2sll(0.999) != 0LL)\n    abort();\n  if (d2sll(1.0) != 1LL)\n    abort();\n  if (d2sll(1.99) != 1LL)\n    abort();\n  if (d2sll(-0.999) != 0LL)\n    abort();\n  if (d2sll(-1.0) != -1LL)\n    abort();\n  if (d2sll(-1.99) != -1LL)\n    abort();\n  if (d2sll((double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n\n  if (ld2sll(0.0) != 0LL)\n    abort();\n  if (ld2sll(0.999) != 0LL)\n    abort();\n  if (ld2sll(1.0) != 1LL)\n    abort();\n  if (ld2sll(1.99) != 1LL)\n    abort();\n  if (ld2sll(-0.999) != 0LL)\n    abort();\n  if (ld2sll(-1.0) != -1LL)\n    abort();\n  if (ld2sll(-1.99) != -1LL)\n    abort();\n  if (ld2sll((long double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */\n    abort();\n}\n#endif\n\nmain()\n{\n  test_integer_to_float();\n  test_float_to_integer();\n#if __GNUC__\n  test_longlong_integer_to_float();\n  test_float_to_longlong_integer();\n#endif\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/cvt-1.c",
    "content": "static inline long\ng1 (double x)\n{\n  return (double) (long) x;\n}\n\nlong\ng2 (double f)\n{\n  return f;\n}\n\ndouble\nf (long i)\n{\n  if (g1 (i) != g2 (i))\n    abort ();\n  return g2 (i);\n}\n\nmain ()\n{\n  if (f (123456789L) != 123456789L)\n    abort ();\n  if (f (123456789L) != g2 (123456789L))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/dbra-1.c",
    "content": "f1 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a == -1)\n\treturn i;\n    }\n  return -1;\n}\n\nf2 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a != -1)\n\treturn i;\n    }\n  return -1;\n}\n\nf3 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a == 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf4 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (--a != 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf5 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (++a == 0)\n\treturn i;\n    }\n  return -1;\n}\n\nf6 (a)\n     long a;\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    {\n      if (++a != 0)\n\treturn i;\n    }\n  return -1;\n}\n\n\nmain()\n{\n  if (f1 (5L) != 5)\n    abort ();\n  if (f2 (1L) != 0)\n    abort ();\n  if (f2 (0L) != 1)\n    abort ();\n  if (f3 (5L) != 4)\n    abort ();\n  if (f4 (1L) != 1)\n    abort ();\n  if (f4 (0L) != 0)\n    abort ();\n  if (f5 (-5L) != 4)\n    abort ();\n  if (f6 (-1L) != 1)\n    abort ();\n  if (f6 (0L) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divcmp-1.c",
    "content": "extern void abort(void);\n\nint test1(int x)\n{\n  return x/10 == 2;\n}\n\nint test1u(unsigned int x)\n{\n  return x/10U == 2;\n}\n\nint test2(int x)\n{\n  return x/10 == 0;\n}\n\nint test2u(unsigned int x)\n{\n  return x/10U == 0;\n}\n\nint test3(int x)\n{\n  return x/10 != 2;\n}\n\nint test3u(unsigned int x)\n{\n  return x/10U != 2;\n}\n\nint test4(int x)\n{\n  return x/10 != 0;\n}\n\nint test4u(unsigned int x)\n{\n  return x/10U != 0;\n}\n\nint test5(int x)\n{\n  return x/10 < 2;\n}\n\nint test5u(unsigned int x)\n{\n  return x/10U < 2;\n}\n\nint test6(int x)\n{\n  return x/10 < 0;\n}\n\nint test7(int x)\n{\n  return x/10  <= 2;\n}\n\nint test7u(unsigned int x)\n{\n  return x/10U <= 2;\n}\n\nint test8(int x)\n{\n  return x/10 <= 0;\n}\n\nint test8u(unsigned int x)\n{\n  return x/10U <= 0;\n}\n\nint test9(int x)\n{\n  return x/10 > 2;\n}\n\nint test9u(unsigned int x)\n{\n  return x/10U > 2;\n}\n\nint test10(int x)\n{\n  return x/10 > 0;\n}\n\nint test10u(unsigned int x)\n{\n  return x/10U > 0;\n}\n\nint test11(int x)\n{\n  return x/10 >= 2;\n}\n\nint test11u(unsigned int x)\n{\n  return x/10U >= 2;\n}\n\nint test12(int x)\n{\n  return x/10 >= 0;\n}\n\n\nint main()\n{\n  if (test1(19) != 0)\n    abort ();\n  if (test1(20) != 1)\n    abort ();\n  if (test1(29) != 1)\n    abort ();\n  if (test1(30) != 0)\n    abort ();\n\n  if (test1u(19) != 0)\n    abort ();\n  if (test1u(20) != 1)\n    abort ();\n  if (test1u(29) != 1)\n    abort ();\n  if (test1u(30) != 0)\n    abort ();\n\n  if (test2(0) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n  if (test2(-1) != 1)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(-10) != 0)\n    abort ();\n\n  if (test2u(0) != 1)\n    abort ();\n  if (test2u(9) != 1)\n    abort ();\n  if (test2u(10) != 0)\n    abort ();\n  if (test2u(-1) != 0)\n    abort ();\n  if (test2u(-9) != 0)\n    abort ();\n  if (test2u(-10) != 0)\n    abort ();\n\n  if (test3(19) != 1)\n    abort ();\n  if (test3(20) != 0)\n    abort ();\n  if (test3(29) != 0)\n    abort ();\n  if (test3(30) != 1)\n    abort ();\n\n  if (test3u(19) != 1)\n    abort ();\n  if (test3u(20) != 0)\n    abort ();\n  if (test3u(29) != 0)\n    abort ();\n  if (test3u(30) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(9) != 0)\n    abort ();\n  if (test4(10) != 1)\n    abort ();\n  if (test4(-1) != 0)\n    abort ();\n  if (test4(-9) != 0)\n    abort ();\n  if (test4(-10) != 1)\n    abort ();\n\n  if (test4u(0) != 0)\n    abort ();\n  if (test4u(9) != 0)\n    abort ();\n  if (test4u(10) != 1)\n    abort ();\n  if (test4u(-1) != 1)\n    abort ();\n  if (test4u(-9) != 1)\n    abort ();\n  if (test4u(-10) != 1)\n    abort ();\n\n  if (test5(19) != 1)\n    abort ();\n  if (test5(20) != 0)\n    abort ();\n  if (test5(29) != 0)\n    abort ();\n  if (test5(30) != 0)\n    abort ();\n\n  if (test5u(19) != 1)\n    abort ();\n  if (test5u(20) != 0)\n    abort ();\n  if (test5u(29) != 0)\n    abort ();\n  if (test5u(30) != 0)\n    abort ();\n\n  if (test6(0) != 0)\n    abort ();\n  if (test6(9) != 0)\n    abort ();\n  if (test6(10) != 0)\n    abort ();\n  if (test6(-1) != 0)\n    abort ();\n  if (test6(-9) != 0)\n    abort ();\n  if (test6(-10) != 1)\n    abort ();\n\n  if (test7(19) != 1)\n    abort ();\n  if (test7(20) != 1)\n    abort ();\n  if (test7(29) != 1)\n    abort ();\n  if (test7(30) != 0)\n    abort ();\n\n  if (test7u(19) != 1)\n    abort ();\n  if (test7u(20) != 1)\n    abort ();\n  if (test7u(29) != 1)\n    abort ();\n  if (test7u(30) != 0)\n    abort ();\n\n  if (test8(0) != 1)\n    abort ();\n  if (test8(9) != 1)\n    abort ();\n  if (test8(10) != 0)\n    abort ();\n  if (test8(-1) != 1)\n    abort ();\n  if (test8(-9) != 1)\n    abort ();\n  if (test8(-10) != 1)\n    abort ();\n\n  if (test8u(0) != 1)\n    abort ();\n  if (test8u(9) != 1)\n    abort ();\n  if (test8u(10) != 0)\n    abort ();\n  if (test8u(-1) != 0)\n    abort ();\n  if (test8u(-9) != 0)\n    abort ();\n  if (test8u(-10) != 0)\n    abort ();\n\n  if (test9(19) != 0)\n    abort ();\n  if (test9(20) != 0)\n    abort ();\n  if (test9(29) != 0)\n    abort ();\n  if (test9(30) != 1)\n    abort ();\n\n  if (test9u(19) != 0)\n    abort ();\n  if (test9u(20) != 0)\n    abort ();\n  if (test9u(29) != 0)\n    abort ();\n  if (test9u(30) != 1)\n    abort ();\n\n  if (test10(0) != 0)\n    abort ();\n  if (test10(9) != 0)\n    abort ();\n  if (test10(10) != 1)\n    abort ();\n  if (test10(-1) != 0)\n    abort ();\n  if (test10(-9) != 0)\n    abort ();\n  if (test10(-10) != 0)\n    abort ();\n\n  if (test10u(0) != 0)\n    abort ();\n  if (test10u(9) != 0)\n    abort ();\n  if (test10u(10) != 1)\n    abort ();\n  if (test10u(-1) != 1)\n    abort ();\n  if (test10u(-9) != 1)\n    abort ();\n  if (test10u(-10) != 1)\n    abort ();\n\n  if (test11(19) != 0)\n    abort ();\n  if (test11(20) != 1)\n    abort ();\n  if (test11(29) != 1)\n    abort ();\n  if (test11(30) != 1)\n    abort ();\n\n  if (test11u(19) != 0)\n    abort ();\n  if (test11u(20) != 1)\n    abort ();\n  if (test11u(29) != 1)\n    abort ();\n  if (test11u(30) != 1)\n    abort ();\n\n  if (test12(0) != 1)\n    abort ();\n  if (test12(9) != 1)\n    abort ();\n  if (test12(10) != 1)\n    abort ();\n  if (test12(-1) != 1)\n    abort ();\n  if (test12(-9) != 1)\n    abort ();\n  if (test12(-10) != 0)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divcmp-2.c",
    "content": "extern void abort (void);\n\nint test1(int x)\n{\n  return x/10 == 2;\n}\n\nint test2(int x)\n{\n  return x/10 == 0;\n}\n\nint test3(int x)\n{\n  return x/10 == -2;\n}\n\nint test4(int x)\n{\n  return x/-10 == 2;\n}\n\nint test5(int x)\n{\n  return x/-10 == 0;\n}\n\nint test6(int x)\n{\n  return x/-10 == -2;\n}\n\n\nint main()\n{\n  if (test1(19) != 0)\n    abort ();\n  if (test1(20) != 1)\n    abort ();\n  if (test1(29) != 1)\n    abort ();\n  if (test1(30) != 0)\n    abort ();\n\n  if (test2(-10) != 0)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n\n  if (test3(-30) != 0)\n    abort ();\n  if (test3(-29) != 1)\n    abort ();\n  if (test3(-20) != 1)\n    abort ();\n  if (test3(-19) != 0)\n    abort ();\n\n  if (test4(-30) != 0)\n    abort ();\n  if (test4(-29) != 1)\n    abort ();\n  if (test4(-20) != 1)\n    abort ();\n  if (test4(-19) != 0)\n    abort ();\n\n  if (test5(-10) != 0)\n    abort ();\n  if (test5(-9) != 1)\n    abort ();\n  if (test5(9) != 1)\n    abort ();\n  if (test5(10) != 0)\n    abort ();\n\n  if (test6(19) != 0)\n    abort ();\n  if (test6(20) != 1)\n    abort ();\n  if (test6(29) != 1)\n    abort ();\n  if (test6(30) != 0)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divcmp-3.c",
    "content": "extern void abort(void);\n\nint test1(char x)\n{\n  return x/100 == 3;\n}\n\nint test1u(unsigned char x)\n{\n  return x/100 == 3;\n}\n\nint test2(char x)\n{\n  return x/100 != 3;\n}\n\nint test2u(unsigned char x)\n{\n  return x/100 != 3;\n}\n\nint test3(char x)\n{\n  return x/100 < 3;\n}\n\nint test3u(unsigned char x)\n{\n  return x/100 < 3;\n}\n\nint test4(char x)\n{\n  return x/100 <= 3;\n}\n\nint test4u(unsigned char x)\n{\n  return x/100 <= 3;\n}\n\nint test5(char x)\n{\n  return x/100 > 3;\n}\n\nint test5u(unsigned char x)\n{\n  return x/100 > 3;\n}\n\nint test6(char x)\n{\n  return x/100 >= 3;\n}\n\nint test6u(unsigned char x)\n{\n  return x/100 >= 3;\n}\n\n\nint main()\n{\n  int c;\n\n  for (c=-128; c<256; c++)\n  {\n    if (test1(c) != 0)\n      abort ();\n    if (test1u(c) != 0)\n      abort ();\n    if (test2(c) != 1)\n      abort ();\n    if (test2u(c) != 1)\n      abort ();\n    if (test3(c) != 1)\n      abort ();\n    if (test3u(c) != 1)\n      abort ();\n    if (test4(c) != 1)\n      abort ();\n    if (test4u(c) != 1)\n      abort ();\n    if (test5(c) != 0)\n      abort ();\n    if (test5u(c) != 0)\n      abort ();\n    if (test6(c) != 0)\n      abort ();\n    if (test6u(c) != 0)\n      abort ();\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divcmp-4.c",
    "content": "/* PR middle-end/17894 */\n\nextern void abort(void);\n\nint test1(int x)\n{\n  return x/-10 == 2;\n}\n\nint test2(int x)\n{\n  return x/-10 == 0;\n}\n\nint test3(int x)\n{\n  return x/-10 != 2;\n}\n\nint test4(int x)\n{\n  return x/-10 != 0;\n}\n\nint test5(int x)\n{\n  return x/-10 < 2;\n}\n\nint test6(int x)\n{\n  return x/-10 < 0;\n}\n\nint test7(int x)\n{\n  return x/-10  <= 2;\n}\n\nint test8(int x)\n{\n  return x/-10 <= 0;\n}\n\nint test9(int x)\n{\n  return x/-10 > 2;\n}\n\nint test10(int x)\n{\n  return x/-10 > 0;\n}\n\nint test11(int x)\n{\n  return x/-10 >= 2;\n}\n\nint test12(int x)\n{\n  return x/-10 >= 0;\n}\n\n\nint main()\n{\n  if (test1(-30) != 0)\n    abort ();\n  if (test1(-29) != 1)\n    abort ();\n  if (test1(-20) != 1)\n    abort ();\n  if (test1(-19) != 0)\n    abort ();\n\n  if (test2(0) != 1)\n    abort ();\n  if (test2(9) != 1)\n    abort ();\n  if (test2(10) != 0)\n    abort ();\n  if (test2(-1) != 1)\n    abort ();\n  if (test2(-9) != 1)\n    abort ();\n  if (test2(-10) != 0)\n    abort ();\n\n  if (test3(-30) != 1)\n    abort ();\n  if (test3(-29) != 0)\n    abort ();\n  if (test3(-20) != 0)\n    abort ();\n  if (test3(-19) != 1)\n    abort ();\n\n  if (test4(0) != 0)\n    abort ();\n  if (test4(9) != 0)\n    abort ();\n  if (test4(10) != 1)\n    abort ();\n  if (test4(-1) != 0)\n    abort ();\n  if (test4(-9) != 0)\n    abort ();\n  if (test4(-10) != 1)\n    abort ();\n\n  if (test5(-30) != 0)\n    abort ();\n  if (test5(-29) != 0)\n    abort ();\n  if (test5(-20) != 0)\n    abort ();\n  if (test5(-19) != 1)\n    abort ();\n\n  if (test6(0) != 0)\n    abort ();\n  if (test6(9) != 0)\n    abort ();\n  if (test6(10) != 1)\n    abort ();\n  if (test6(-1) != 0)\n    abort ();\n  if (test6(-9) != 0)\n    abort ();\n  if (test6(-10) != 0)\n    abort ();\n\n  if (test7(-30) != 0)\n    abort ();\n  if (test7(-29) != 1)\n    abort ();\n  if (test7(-20) != 1)\n    abort ();\n  if (test7(-19) != 1)\n    abort ();\n\n  if (test8(0) != 1)\n    abort ();\n  if (test8(9) != 1)\n    abort ();\n  if (test8(10) != 1)\n    abort ();\n  if (test8(-1) != 1)\n    abort ();\n  if (test8(-9) != 1)\n    abort ();\n  if (test8(-10) != 0)\n    abort ();\n\n  if (test9(-30) != 1)\n    abort ();\n  if (test9(-29) != 0)\n    abort ();\n  if (test9(-20) != 0)\n    abort ();\n  if (test9(-19) != 0)\n    abort ();\n\n  if (test10(0) != 0)\n    abort ();\n  if (test10(9) != 0)\n    abort ();\n  if (test10(10) != 0)\n    abort ();\n  if (test10(-1) != 0)\n    abort ();\n  if (test10(-9) != 0)\n    abort ();\n  if (test10(-10) != 1)\n    abort ();\n\n  if (test11(-30) != 1)\n    abort ();\n  if (test11(-29) != 1)\n    abort ();\n  if (test11(-20) != 1)\n    abort ();\n  if (test11(-19) != 0)\n    abort ();\n\n  if (test12(0) != 1)\n    abort ();\n  if (test12(9) != 1)\n    abort ();\n  if (test12(10) != 0)\n    abort ();\n  if (test12(-1) != 1)\n    abort ();\n  if (test12(-9) != 1)\n    abort ();\n  if (test12(-10) != 1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divcmp-5.c",
    "content": "/* PR middle-end/26561 */\n\nextern void abort(void);\n\nint always_one_1 (int a)\n{\n  if (a/100 >= -999999999)\n    return 1;\n  else\n    return 0;\n}\n\nint always_one_2 (int a)\n{\n  if (a/100 < -999999999)\n    return 0;\n  else\n    return 1;\n}\n\nint main(void)\n{\n  if (always_one_1 (0) != 1)\n    abort ();\n\n  if (always_one_2 (0) != 1)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divconst-1.c",
    "content": "typedef struct\n{\n  unsigned a, b, c, d;\n} t1;\n\nf (t1 *ps)\n{\n    ps->a = 10000;\n    ps->b = ps->a / 3;\n    ps->c = 10000;\n    ps->d = ps->c / 3;\n}\n\nmain ()\n{\n  t1 s;\n  f (&s);\n  if (s.a != 10000 || s.b != 3333 || s.c != 10000 || s.d != 3333)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divconst-2.c",
    "content": "long\nf (long x)\n{\n  return x / (-0x7fffffffL - 1L);\n}\n\nlong\nr (long x)\n{\n  return x % (-0x7fffffffL - 1L);\n}\n\n/* Since we have a negative divisor, this equation must hold for the\n   results of / and %; no specific results are guaranteed.  */\nlong\nstd_eqn (long num, long denom, long quot, long rem)\n{\n  /* For completeness, a check for \"ABS (rem) < ABS (denom)\" belongs here,\n     but causes trouble on 32-bit machines and isn't worthwhile.  */\n  return quot * (-0x7fffffffL - 1L) + rem == num;\n}\n\nlong nums[] =\n{\n  -1L, 0x7fffffffL, -0x7fffffffL - 1L\n};\n\nmain ()\n{\n  int i;\n\n  for (i = 0;\n       i < sizeof (nums) / sizeof (nums[0]);\n       i++)\n    if (std_eqn (nums[i], -0x7fffffffL - 1L, f (nums[i]), r (nums[i])) == 0)\n      abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divconst-3.c",
    "content": "long long\nf (long long x)\n{\n  return x / 10000000000LL;\n}\n\nmain ()\n{\n  if (f (10000000000LL) != 1 || f (100000000000LL) != 10)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/divmod-1.c",
    "content": "div1 (signed char x)\n{\n  return x / -1;\n}\n\ndiv2 (signed short x)\n{\n  return x / -1;\n}\n\ndiv3 (signed char x, signed char y)\n{\n  return x / y;\n}\n\ndiv4 (signed short x, signed short y)\n{\n  return x / y;\n}\n\nmod1 (signed char x)\n{\n  return x % -1;\n}\n\nmod2 (signed short x)\n{\n  return x % -1;\n}\n\nmod3 (signed char x, signed char y)\n{\n  return x % y;\n}\n\nmod4 (signed short x, signed short y)\n{\n  return x % y;\n}\n\nsigned long\nmod5 (signed long x, signed long y)\n{\n  return x % y;\n}\n     \nunsigned long\nmod6 (unsigned long x, unsigned long y)\n{\n  return x % y;\n}\n     \nmain ()\n{\n  if (div1 (-(1 << 7)) != 1 << 7)\n    abort ();\n  if (div2 (-(1 << 15)) != 1 << 15)\n    abort ();\n  if (div3 (-(1 << 7), -1) != 1 << 7)\n    abort ();\n  if (div4 (-(1 << 15), -1) != 1 << 15)\n    abort ();\n  if (mod1 (-(1 << 7)) != 0)\n    abort ();\n  if (mod2 (-(1 << 15)) != 0)\n    abort ();\n  if (mod3 (-(1 << 7), -1) != 0)\n    abort ();\n  if (mod4 (-(1 << 15), -1) != 0)\n    abort ();\n  if (mod5 (0x50000000, 2) != 0)\n    abort ();\n  if (mod6 (0x50000000, 2) != 0)\n    abort ();\n  \n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/doloop-1.c",
    "content": "#include <limits.h>\n\nextern void exit (int);\nextern void abort (void);\n\nvolatile unsigned int i;\n\nint\nmain (void)\n{\n  unsigned char z = 0;\n\n  do ++i;\n  while (--z > 0);\n  if (i != UCHAR_MAX + 1U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/doloop-2.c",
    "content": "#include <limits.h>\n\nextern void exit (int);\nextern void abort (void);\n\nvolatile unsigned int i;\n\nint\nmain (void)\n{\n  unsigned short z = 0;\n\n  do ++i;\n  while (--z > 0);\n  if (i != USHRT_MAX + 1U)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/eeprof-1.c",
    "content": "/* { dg-require-effective-target return_address } */\n/* { dg-options \"-finstrument-functions\" } */\n/* { dg-xfail-run-if \"\" { powerpc-ibm-aix* } \"*\" \"\" } */\n\nextern void abort (void);\n\n#define ASSERT(X)\tif (!(X)) abort ();\n#define NOCHK __attribute__ ((no_instrument_function))\n\nint entry_calls, exit_calls;\nvoid (*last_fn_entered)();\nvoid (*last_fn_exited)();\n\n__attribute__ ((noinline))\nint main () NOCHK;\n\n__attribute__ ((noinline))\nvoid foo ()\n{\n  ASSERT (last_fn_entered == foo);\n}\n\n__attribute__ ((noinline))\nstatic void foo2 ()\n{\n  ASSERT (entry_calls == 1 && exit_calls == 0);\n  ASSERT (last_fn_entered == foo2);\n  foo ();\n  ASSERT (entry_calls == 2 && exit_calls == 1);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo);\n}\n\n__attribute__ ((noinline))\nvoid nfoo (void) NOCHK;\nvoid nfoo ()\n{\n  ASSERT (entry_calls == 2 && exit_calls == 2);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo2);\n  foo ();\n  ASSERT (entry_calls == 3 && exit_calls == 3);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo);\n}\n\nint main ()\n{\n  ASSERT (entry_calls == 0 && exit_calls == 0);\n\n  foo2 ();\n\n  ASSERT (entry_calls == 2 && exit_calls == 2);\n  ASSERT (last_fn_entered == foo);\n  ASSERT (last_fn_exited == foo2);\n\n  nfoo ();\n\n  ASSERT (entry_calls == 3 && exit_calls == 3);\n  ASSERT (last_fn_entered == foo);\n\n  return 0;\n}\n\nvoid __cyg_profile_func_enter (void (*fn)(), void (*parent)()) NOCHK;\nvoid __cyg_profile_func_exit (void (*fn)(), void (*parent)()) NOCHK;\n\n__attribute__ ((noinline))\nvoid __cyg_profile_func_enter (void (*fn)(), void (*parent)())\n{\n  entry_calls++;\n  last_fn_entered = fn;\n}\n__attribute__ ((noinline))\nvoid __cyg_profile_func_exit (void (*fn)(), void (*parent)())\n{\n  exit_calls++;\n  last_fn_exited = fn;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/enum-1.c",
    "content": "typedef enum\n{\n  END = -1,\n  EMPTY = (1 << 8 ) ,\n  BACKREF,\n  BEGLINE,\n  ENDLINE,\n  BEGWORD,\n  ENDWORD,\n  LIMWORD,\n  NOTLIMWORD,\n  QMARK,\n  STAR,\n  PLUS,\n  REPMN,\n  CAT,\n  OR,\n  ORTOP,\n  LPAREN,\n  RPAREN,\n  CSET\n} token;\n\nstatic token tok;\n\nstatic int\natom ()\n{\n  if ((tok >= 0 && tok < (1 << 8 ) ) || tok >= CSET || tok == BACKREF\n      || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD\n      || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)\n    return 1;\n  else\n    return 0;\n}\n\nmain ()\n{\n  tok = 0;\n  if (atom () != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/enum-2.c",
    "content": "/* Copyright (C) 2000 Free Software Foundation */\n/* by Alexandre Oliva  <aoliva@redhat.com> */\n\nenum foo { FOO, BAR };\n\n/* Even though the underlying type of an enum is unspecified, the type\n   of enumeration constants is explicitly defined as int (6.4.4.3/2 in\n   the C99 Standard).  Therefore, `i' must not be promoted to\n   `unsigned' in the comparison below; we must exit the loop when it\n   becomes negative. */\n\nint\nmain ()\n{\n  int i;\n  for (i = BAR; i >= FOO; --i)\n    if (i == -1)\n      abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/enum-3.c",
    "content": "/* The composite type of int and an enum compatible with int might be\n   either of the two types, but it isn't an unsigned type.  */\n/* Origin: Joseph Myers <jsm@polyomino.org.uk> */\n\n#include <limits.h>\n\n#include <stdio.h>\n\nextern void abort (void);\nextern void exit (int);\n\nenum e { a = INT_MIN };\n\nint *p;\nenum e *q;\nint\nmain (void)\n{\n  enum e x = a;\n  q = &x;\n  if (*(1 ? q : p) > 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/execute.exp",
    "content": "# Copyright (C) 1991-2017 Free Software Foundation, Inc.\n\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n# \n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n# \n# You should have received a copy of the GNU General Public License\n# along with GCC; see the file COPYING3.  If not see\n# <http://www.gnu.org/licenses/>.\n\n# This file was written by Rob Savoye. (rob@cygnus.com)\n# Modified and maintained by Jeffrey Wheat (cassidy@cygnus.com)\n\n#\n# These tests come from Torbjorn Granlund (tege@cygnus.com)\n# C torture test suite.\n#\n\n# Load support procs.\nload_lib gcc-dg.exp\n\n# Initialize `dg'.\ndg-init\n\n# Main loop.\nset saved-dg-do-what-default ${dg-do-what-default}\nset dg-do-what-default \"run\"\ngcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\\[cS\\]]] \"\" \"-w\"\nset dg-do-what-default ${saved-dg-do-what-default}\n\n# All done.\ndg-finish\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/extzvsi.c",
    "content": "/* The bit-field below would have a problem if __INT_MAX__ is too\n   small.  */\n#if __INT_MAX__ < 2147483647\nint\nmain (void)\n{\n  exit (0);\n}\n#else\n/* Failed on powerpc due to bad extzvsi pattern.  */\n\nstruct ieee\n{\n  unsigned int negative:1;\n  unsigned int exponent:11;\n  unsigned int mantissa0:20;\n  unsigned int mantissa1:32;\n} x;\n\nunsigned int\nfoo (void)\n{\n  unsigned int exponent;\n\n  exponent = x.exponent;\n  if (exponent == 0)\n    return 1;\n  else if (exponent > 1)\n    return 2;\n  return 0;\n}\n\nint\nmain (void)\n{\n  x.exponent = 1;\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ffs-1.c",
    "content": "__volatile int a = 0;\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  if (__builtin_ffs (a) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ffs-2.c",
    "content": "struct\n  {\n    int input;\n    int output;\n  }\nffstesttab[] =\n  {\n#if __INT_MAX__ >= 2147483647\n    /* at least 32-bit integers */\n    { 0x80000000, 32 },\n    { 0xa5a5a5a5, 1 },\n    { 0x5a5a5a5a, 2 },\n    { 0xcafe0000, 18 },\n#endif\n#if __INT_MAX__ >= 32767\n    /* at least 16-bit integers */\n    { 0x8000, 16 },\n    { 0xa5a5, 1 },\n    { 0x5a5a, 2 },\n    { 0x0ca0, 6 },\n#endif\n#if __INT_MAX__ < 32767\n#error integers are too small\n#endif\n  };\n\n#define NFFSTESTS (sizeof (ffstesttab) / sizeof (ffstesttab[0]))\n\nextern void abort (void);\nextern void exit (int);\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NFFSTESTS; i++)\n    {\n      if (__builtin_ffs (ffstesttab[i].input) != ffstesttab[i].output)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/float-floor.c",
    "content": "\n#if(__SIZEOF_DOUBLE__==8)\ndouble d = 1024.0 - 1.0 / 32768.0;\n#else\ndouble d = 1024.0 - 1.0 / 16384.0;\n#endif\n\nextern double floor(double);\nextern float floorf(float);\nextern void abort();\n\nint main() {\n\n    double df = floor(d);\n    float f1 = (float)floor(d);\n\n    if ((int)df != 1023 || (int)f1 != 1023)\n      abort ();\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/floatunsisf-1.c",
    "content": "/* The fp-bit.c function __floatunsisf had a latent bug where guard bits\n   could be lost leading to incorrect rounding.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\nextern void abort (void);\nextern void exit (int);\n#if __INT_MAX__ >= 0x7fffffff\nvolatile unsigned u = 0x80000081;\n#else\nvolatile unsigned long u = 0x80000081;\n#endif\nvolatile float f1, f2;\nint\nmain (void)\n{\n  f1 = (float) u;\n  f2 = (float) 0x80000081;\n  if (f1 != f2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/fprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain (void)\n{\n#define test(ret, args...) \\\n  fprintf (stdout, args); \t\t\\\n  if (fprintf (stdout, args) != ret)\t\\\n    abort ();\n  test (5, \"hello\");\n  test (6, \"hello\\n\");\n  test (1, \"a\");\n  test (0, \"\");\n  test (5, \"%s\", \"hello\");\n  test (6, \"%s\", \"hello\\n\");\n  test (1, \"%s\", \"a\");\n  test (0, \"%s\", \"\");\n  test (1, \"%c\", 'x');\n  test (7, \"%s\\n\", \"hello\\n\");\n  test (2, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/fprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__fprintf_chk (FILE *f, int flag, const char *fmt, ...)\n{\n  va_list ap;\n  int ret;\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  va_start (ap, fmt);\n  ret = vfprintf (f, fmt, ap);\n  va_end (ap);\n  return ret;\n}\n\nint\nmain (void)\n{\n#define test(ret, opt, args...) \\\n  should_optimize = opt;\t\t\t\\\n  __fprintf_chk (stdout, 1, args); \t\t\\\n  if (!should_optimize)\t\t\t\t\\\n    abort ();\t\t\t\t\t\\\n  should_optimize = 0;\t\t\t\t\\\n  if (__fprintf_chk (stdout, 1, args) != ret)\t\\\n    abort ();\t\t\t\t\t\\\n  if (!should_optimize)\t\t\t\t\\\n    abort ();\n  test (5, 1, \"hello\");\n  test (6, 1, \"hello\\n\");\n  test (1, 1, \"a\");\n  test (0, 1, \"\");\n  test (5, 1, \"%s\", \"hello\");\n  test (6, 1, \"%s\", \"hello\\n\");\n  test (1, 1, \"%s\", \"a\");\n  test (0, 1, \"%s\", \"\");\n  test (1, 1, \"%c\", 'x');\n  test (7, 0, \"%s\\n\", \"hello\\n\");\n  test (2, 0, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/frame-address.c",
    "content": "/* { dg-require-effective-target return_address } */\nint check_fa_work (const char *, const char *) __attribute__((noinline));\nint check_fa_mid (const char *) __attribute__((noinline));\nint check_fa (char *) __attribute__((noinline));\nint how_much (void) __attribute__((noinline));\n\nint check_fa_work (const char *c, const char *f)\n{\n  const char d = 0;\n\n  if (c >= &d)\n    return c >= f && f >= &d;\n  else\n    return c <= f && f <= &d;\n}\n\nint check_fa_mid (const char *c)\n{\n  const char *f = __builtin_frame_address (0);\n\n  /* Prevent a tail call to check_fa_work, eliding the current stack frame.  */\n  return check_fa_work (c, f) != 0;\n}\n\nint check_fa (char *unused)\n{\n  const char c = 0;\n\n  /* Prevent a tail call to check_fa_mid, eliding the current stack frame.  */\n  return check_fa_mid (&c) != 0;\n}\n\nint how_much (void)\n{\n\treturn 8;\n}\n\nint main (void)\n{\n  char *unused = __builtin_alloca (how_much ());\n\n  if (!check_fa(unused))\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/func-ptr-1.c",
    "content": "static double f (float a);\nstatic double (*fp) (float a);\n\nmain ()\n{\n  fp = f;\n  if (fp ((float) 1) != 1.0)\n    abort ();\n  exit (0);\n}\n\nstatic double\nf (float a)\n{\n  return a;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/gofast.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n/* Program to test gcc's usage of the gofast library.  */\n\n/* The main guiding themes are to make it trivial to add test cases over time\n   and to make it easy for a program to parse the output to see if the right\n   libcalls are being made.  */\n\n#include <stdio.h>\n\nfloat fp_add (float a, float b) { return a + b; }\nfloat fp_sub (float a, float b) { return a - b; }\nfloat fp_mul (float a, float b) { return a * b; }\nfloat fp_div (float a, float b) { return a / b; }\nfloat fp_neg (float a) { return -a; }\n\ndouble dp_add (double a, double b) { return a + b; }\ndouble dp_sub (double a, double b) { return a - b; }\ndouble dp_mul (double a, double b) { return a * b; }\ndouble dp_div (double a, double b) { return a / b; }\ndouble dp_neg (double a) { return -a; }\n\ndouble fp_to_dp (float f) { return f; }\nfloat dp_to_fp (double d) { return d; }\n\nint eqsf2 (float a, float b) { return a == b; }\nint nesf2 (float a, float b) { return a != b; }\nint gtsf2 (float a, float b) { return a > b; }\nint gesf2 (float a, float b) { return a >= b; }\nint ltsf2 (float a, float b) { return a < b; }\nint lesf2 (float a, float b) { return a <= b; }\n\nint eqdf2 (double a, double b) { return a == b; }\nint nedf2 (double a, double b) { return a != b; }\nint gtdf2 (double a, double b) { return a > b; }\nint gedf2 (double a, double b) { return a >= b; }\nint ltdf2 (double a, double b) { return a < b; }\nint ledf2 (double a, double b) { return a <= b; }\n\nfloat floatsisf (int i) { return i; }\ndouble floatsidf (int i) { return i; }\nint fixsfsi (float f) { return f; }\nint fixdfsi (double d) { return d; }\nunsigned int fixunssfsi (float f) { return f; }\nunsigned int fixunsdfsi (double d) { return d; }\n\nint fail_count = 0;\n\nint\nfail (char *msg)\n{\n  fail_count++;\n  fprintf (stderr, \"Test failed: %s\\n\", msg);\n}\n\nint\nmain()\n{\n  if (fp_add (1, 1) != 2) fail (\"fp_add 1+1\");\n  if (fp_sub (3, 2) != 1) fail (\"fp_sub 3-2\");\n  if (fp_mul (2, 3) != 6) fail (\"fp_mul 2*3\");\n  if (fp_div (3, 2) != 1.5) fail (\"fp_div 3/2\");\n  if (fp_neg (1) != -1) fail (\"fp_neg 1\");\n\n  if (dp_add (1, 1) != 2) fail (\"dp_add 1+1\");\n  if (dp_sub (3, 2) != 1) fail (\"dp_sub 3-2\");\n  if (dp_mul (2, 3) != 6) fail (\"dp_mul 2*3\");\n  if (dp_div (3, 2) != 1.5) fail (\"dp_div 3/2\");\n  if (dp_neg (1) != -1) fail (\"dp_neg 1\");\n\n  if (fp_to_dp (1.5) != 1.5) fail (\"fp_to_dp 1.5\");\n  if (dp_to_fp (1.5) != 1.5) fail (\"dp_to_fp 1.5\");\n\n  if (floatsisf (1) != 1) fail (\"floatsisf 1\");\n  if (floatsidf (1) != 1) fail (\"floatsidf 1\");\n  if (fixsfsi (1.42) != 1) fail (\"fixsfsi 1.42\");\n  if (fixunssfsi (1.42) != 1) fail (\"fixunssfsi 1.42\");\n  if (fixdfsi (1.42) != 1) fail (\"fixdfsi 1.42\");\n  if (fixunsdfsi (1.42) != 1) fail (\"fixunsdfsi 1.42\");\n\n  if (eqsf2 (1, 1) == 0) fail (\"eqsf2 1==1\");\n  if (eqsf2 (1, 2) != 0) fail (\"eqsf2 1==2\");\n  if (nesf2 (1, 2) == 0) fail (\"nesf2 1!=1\");\n  if (nesf2 (1, 1) != 0) fail (\"nesf2 1!=1\");\n  if (gtsf2 (2, 1) == 0) fail (\"gtsf2 2>1\");\n  if (gtsf2 (1, 1) != 0) fail (\"gtsf2 1>1\");\n  if (gtsf2 (0, 1) != 0) fail (\"gtsf2 0>1\");\n  if (gesf2 (2, 1) == 0) fail (\"gesf2 2>=1\");\n  if (gesf2 (1, 1) == 0) fail (\"gesf2 1>=1\");\n  if (gesf2 (0, 1) != 0) fail (\"gesf2 0>=1\");\n  if (ltsf2 (1, 2) == 0) fail (\"ltsf2 1<2\");\n  if (ltsf2 (1, 1) != 0) fail (\"ltsf2 1<1\");\n  if (ltsf2 (1, 0) != 0) fail (\"ltsf2 1<0\");\n  if (lesf2 (1, 2) == 0) fail (\"lesf2 1<=2\");\n  if (lesf2 (1, 1) == 0) fail (\"lesf2 1<=1\");\n  if (lesf2 (1, 0) != 0) fail (\"lesf2 1<=0\");\n\n  if (fail_count != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ifcvt-onecmpl-abs-1.c",
    "content": "\nextern void abort(void);\n\n__attribute__ ((noinline))\nint foo(int n)\n{\n  if (n < 0)\n    n = ~n;\n\n  return n;\n}\n\nint main(void)\n{\n  if (foo (-1) != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/index-1.c",
    "content": "int a[] =\n{\n  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,\n  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,\n  30, 31, 32, 33, 34, 35, 36, 37, 38, 39\n};\n\nint\nf (long n)\n{\n  return a[n - 100000];\n}\n\nmain ()\n{\n  if (f (100030L) != 30)\n    abort();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/inst-check.c",
    "content": "#include <stdarg.h>\n\nf(m)\n{\n  int i,s=0;\n  for(i=0;i<m;i++)\n    s+=i;\n  return s;\n}\n\nmain()\n{\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/int-compare.c",
    "content": "#include <limits.h>\n\ngt (a, b)\n{\n  return a > b;\n}\n\nge (a, b)\n{\n  return a >= b;\n}\n\nlt (a, b)\n{\n  return a < b;\n}\n\nle (a, b)\n{\n  return a <= b;\n}\n\nvoid\ntrue (c)\n{\n  if (!c)\n    abort();\n}\n\nvoid\nfalse (c)\n{\n  if (c)\n    abort();\n}\n\nf ()\n{\n  true (gt (2, 1));\n  false (gt (1, 2));\n\n  true (gt (INT_MAX, 0));\n  false (gt (0, INT_MAX));\n  true (gt (INT_MAX, 1));\n  false (gt (1, INT_MAX));\n\n  false (gt (INT_MIN, 0));\n  true (gt (0, INT_MIN));\n  false (gt (INT_MIN, 1));\n  true (gt (1, INT_MIN));\n\n  true (gt (INT_MAX, INT_MIN));\n  false (gt (INT_MIN, INT_MAX));\n\n  true (ge (2, 1));\n  false (ge (1, 2));\n\n  true (ge (INT_MAX, 0));\n  false (ge (0, INT_MAX));\n  true (ge (INT_MAX, 1));\n  false (ge (1, INT_MAX));\n\n  false (ge (INT_MIN, 0));\n  true (ge (0, INT_MIN));\n  false (ge (INT_MIN, 1));\n  true (ge (1, INT_MIN));\n\n  true (ge (INT_MAX, INT_MIN));\n  false (ge (INT_MIN, INT_MAX));\n\n  false (lt (2, 1));\n  true (lt (1, 2));\n\n  false (lt (INT_MAX, 0));\n  true (lt (0, INT_MAX));\n  false (lt (INT_MAX, 1));\n  true (lt (1, INT_MAX));\n\n  true (lt (INT_MIN, 0));\n  false (lt (0, INT_MIN));\n  true (lt (INT_MIN, 1));\n  false (lt (1, INT_MIN));\n\n  false (lt (INT_MAX, INT_MIN));\n  true (lt (INT_MIN, INT_MAX));\n\n  false (le (2, 1));\n  true (le (1, 2));\n\n  false (le (INT_MAX, 0));\n  true (le (0, INT_MAX));\n  false (le (INT_MAX, 1));\n  true (le (1, INT_MAX));\n\n  true (le (INT_MIN, 0));\n  false (le (0, INT_MIN));\n  true (le (INT_MIN, 1));\n  false (le (1, INT_MIN));\n\n  false (le (INT_MAX, INT_MIN));\n  true (le (INT_MIN, INT_MAX));\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ipa-sra-1.c",
    "content": "/* Trivially making sure IPA-SRA does not introduce segfaults where they should\n   not be.  */\n\nstruct bovid\n{\n  float red;\n  int green;\n  void *blue;\n};\n\nstatic int\n__attribute__((noinline))\nox (int fail, struct bovid *cow)\n{\n  int r;\n  if (fail)\n    r = cow->red;\n  else\n    r = 0;\n  return r;\n}\n\nint main (int argc, char *argv[])\n{\n  int r;\n\n  r = ox ((argc > 2000), (void *) 0);\n  return r;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ipa-sra-2.c",
    "content": "/* { dg-require-effective-target int32plus } */\nstruct big\n{\n  int data[1000000];\n};\n\nstruct small\n{\n  int data[10];\n};\n\nunion both\n{\n  struct big big;\n  struct small small;\n};\n\nextern void *calloc (__SIZE_TYPE__, __SIZE_TYPE__);\nextern void free (void *);\n\nstatic int __attribute__((noinline))\nfoo (int fail, union both *agg)\n{\n  int r;\n  if (fail)\n    r = agg->big.data[999999];\n  else\n    r = agg->small.data[0];\n  return r;\n}\n\nint main (int argc, char *argv[])\n{\n  union both *agg = calloc (1, sizeof (struct small));\n  int r;\n\n  r = foo ((argc > 2000), agg);\n\n  free (agg);\n  return r;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/longlong.c",
    "content": "/* Source: PR 321 modified for test suite by Neil Booth 14 Jan 2001.  */\n\ntypedef unsigned long long uint64;\nunsigned long pars;\n\nuint64 b[32];\nuint64 *r = b;\n\nvoid alpha_ep_extbl_i_eq_0()\n{\n  unsigned int rb, ra, rc;\n\n  rb  = (((unsigned long)(pars) >> 27)) & 0x1fUL;\n  ra  = (((unsigned int)(pars) >> 5)) & 0x1fUL;\n  rc  = (((unsigned int)(pars) >> 0)) & 0x1fUL;\n  {\n    uint64 temp = ((r[ra] >> ((r[rb] & 0x7) << 3)) & 0x00000000000000FFLL); \n    if (rc != 31) \n      r[rc] = temp;  \n  }\n}\n\nint \nmain(void)\n{\n  if (sizeof (uint64) == 8)\n    {\n      b[17] = 0x0000000000303882ULL; /* rb */\n      b[2] = 0x534f4f4c494d000aULL; /* ra & rc */\n\n      pars = 0x88000042;\t/* 17, 2, 2 coded */\n      alpha_ep_extbl_i_eq_0();\n\n      if (b[2] != 0x4d)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-1.c",
    "content": "main ()\n{\n  int i, j, k[3];\n\n  j = 0;\n  for (i=0; i < 3; i++)\n    {\n      k[i] = j++;\n    }\n\n  for (i=2; i >= 0; i--)\n    {\n      if (k[i] != i)\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-10.c",
    "content": "/* Reduced from PR optimization/5076, PR optimization/2847 */\n\nstatic int count = 0;\n\nstatic void\ninc (void)\n{\n  count++;\n}\n\nint\nmain (void)\n{\n  int iNbr = 1;\n  int test = 0;\n  while (test == 0)\n    {\n      inc ();\n      if (iNbr == 0)\n        break;\n      else\n        {\n          inc ();\n          iNbr--;\n        }\n      test = 1;\n    }\n  if (count != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-11.c",
    "content": "static int a[199];\n\nstatic void\nfoo ()\n{\n  int i;\n  for (i = 198; i >= 0; i--)\n    a[i] = i;\n}\n\nint\nmain ()\n{\n  int i;\n  foo ();\n  for (i = 0; i < 199; i++)\n    if (a[i] != i)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-12.c",
    "content": "/* Checks that pure functions are not treated as const.  */\n\nchar *p;\n\nstatic int __attribute__ ((pure))\nis_end_of_statement (void)\n{\n  return *p == '\\n' || *p == ';' || *p == '!';\n}\n\nvoid foo (void)\n{\n  /* The is_end_of_statement call was moved out of the loop at one stage,\n     resulting in an endless loop.  */\n  while (!is_end_of_statement ())\n    p++;\n}\n\nint\nmain (void)\n{\n  p = \"abc\\n\";\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-13.c",
    "content": "/* PR opt/7130 */\n#define TYPE long\n\nvoid\nscale (TYPE *alpha, TYPE *x, int n)\n{\n  int i, ix;\n\n  if (*alpha != 1)\n    for (i = 0, ix = 0; i < n; i++, ix += 2)\n      {\n\tTYPE tmpr, tmpi;\n\ttmpr = *alpha * x[ix];\n\ttmpi = *alpha * x[ix + 1];\n\tx[ix] = tmpr;\n\tx[ix + 1] = tmpi;\n      }\n}\n\nint\nmain (void)\n{\n  int i;\n  TYPE x[10];\n  TYPE alpha = 2;\n\n  for (i = 0; i < 10; i++)\n    x[i] = i;\n\n  scale (&alpha, x, 5);\n\n  if (x[9] != 18)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-14.c",
    "content": "int a3[3];\n\nvoid f(int *a)\n{\n  int i;\n\n  for (i=3; --i;)\n    a[i] = 42 / i;\n}\n\nint\nmain ()\n{\n  f(a3);\n\n  if (a3[1] != 42 || a3[2] != 21)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-15.c",
    "content": "/* Bombed with a segfault on powerpc-linux.  doloop.c generated wrong\n   loop count.  */\nvoid\nfoo (unsigned long *start, unsigned long *end)\n{\n  unsigned long *temp = end - 1;\n\n  while (end > start)\n    *end-- = *temp--;\n}\n\nint\nmain (void)\n{\n  unsigned long a[5];\n  int start, end, k;\n\n  for (start = 0; start < 5; start++)\n    for (end = 0; end < 5; end++)\n      {\n\tfor (k = 0; k < 5; k++)\n\t  a[k] = k;\n\n\tfoo (a + start, a + end);\n\n\tfor (k = 0; k <= start; k++)\n\t  if (a[k] != k)\n\t    abort ();\n\n\tfor (k = start + 1; k <= end; k++)\n\t  if (a[k] != k - 1)\n\t    abort ();\n\n\tfor (k = end + 1; k < 5; k++)\n\t  if (a[k] != k)\n\t    abort ();\n      }\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2.c",
    "content": "int a[2];\n\nf (b)\n{\n  unsigned int i;\n  for (i = 0; i < b; i++)\n    a[i] = i - 2;\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (2);\n  if (a[0] != -2 || a[1] != -1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2b.c",
    "content": "#include <limits.h>\n\nint a[2];\n\nf (int i)\n{\n  for (; i < INT_MAX; i++)\n    {\n      a[i] = -2;\n      if (&a[i] == &a[1])\n\tbreak;\n    }\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (0);\n  if (a[0] != -2 || a[1] != -2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2c.c",
    "content": "/* { dg-options \"-fgnu89-inline -Wno-pointer-to-int-cast\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint a[2];\n\n__inline__ void f (int b, int o)\n{\n  unsigned int i;\n  int *p;\n  for (p = &a[b], i = b; --i < ~0; )\n    *--p = i * 3 + o;\n}\n\nvoid\ng(int b)\n{\n  f (b, (int)a);\n}\n\nint\nmain ()\n{\n  a[0] = a[1] = 0;\n  g (2);\n  if (a[0] != (int)a || a[1] != (int)a + 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2d.c",
    "content": "int a[2];\n\nf (b)\n{\n  unsigned int i;\n  int *p;\n  for (p = &a[b], i = b; --i < ~0; )\n    *--p = i * 3 + (int)a;\n}\n\nmain ()\n{\n  a[0] = a[1] = 0;\n  f (2);\n  if (a[0] != (int)a || a[1] != (int)a + 3)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2e.c",
    "content": "void f (int *p, int **q)\n{\n  int i;\n  for (i = 0; i < 40; i++)\n    {\n      *q++ = &p[i];\n    }\n}\n\nint main ()\n{\n  void *p;\n  int *q[40];\n  __SIZE_TYPE__ start;\n\n  /* Find the signed middle of the address space.  */\n  if (sizeof(start) == sizeof(int))\n    start = (__SIZE_TYPE__) __INT_MAX__;\n  else if (sizeof(start) == sizeof(long))\n    start = (__SIZE_TYPE__) __LONG_MAX__;\n  else if (sizeof(start) == sizeof(long long))\n    start = (__SIZE_TYPE__) __LONG_LONG_MAX__;\n  else\n    return 0;\n\n  /* Arbitrarily align the pointer.  */\n  start &= -32;\n\n  /* Pretend that's good enough to start address arithmetic.  */\n  p = (void *)start;\n\n  /* Verify that GIV replacement computes the correct results.  */\n  q[39] = 0;\n  f (p, q);\n  if (q[39] != (int *)p + 39)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2f.c",
    "content": "/* { dg-require-effective-target mmap } */\n/* { dg-skip-if \"the executable is at the same position the test tries to remap\" { m68k-*-linux* } { \"*\" } { \"\" } } */\n\n#include <limits.h>\n\n#include <sys/types.h>\n#include <sys/mman.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifndef MAP_ANON\n#ifdef MAP_ANONYMOUS\n#define MAP_ANON MAP_ANONYMOUS\n#else\n#define MAP_ANON MAP_FILE\n#endif\n#endif\n#ifndef MAP_FILE\n#define MAP_FILE 0\n#endif\n#ifndef MAP_FIXED\n#define MAP_FIXED 0\n#endif\n\n#define MAP_START (void *)0x7fff8000\n#define MAP_LEN 0x10000\n\n#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));\n\nf (int s, char *p)\n{\n  int i;\n  for (i = s; i >= 0 && &p[i] < &p[40]; i++)\n    {\n      p[i] = -2;\n    }\n}\n\nmain ()\n{\n#ifdef MAP_ANON\n  char *p;\n  int dev_zero;\n\n  dev_zero = open (\"/dev/zero\", O_RDONLY);\n  /* -1 is OK when we have MAP_ANON; else mmap will flag an error.  */\n  if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))\n    exit (0);\n  p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,\n\t    MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);\n  if (p != (char *)-1)\n    {\n      p += OFFSET;\n      p[39] = 0;\n      f (0, p);\n      if (p[39] != (char)-2)\n\tabort ();\n      p[39] = 0;\n      f (-1, p);\n      if (p[39] != 0)\n\tabort ();\n    }\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-2g.c",
    "content": "/* { dg-require-effective-target mmap } */\n/* { dg-skip-if \"the executable is at the same position the test tries to remap\" { m68k-*-linux* } { \"*\" } { \"\" } } */\n\n#include <limits.h>\n\n#include <sys/types.h>\n#include <sys/mman.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifndef MAP_ANON\n#ifdef MAP_ANONYMOUS\n#define MAP_ANON MAP_ANONYMOUS\n#else\n#define MAP_ANON MAP_FILE\n#endif\n#endif\n#ifndef MAP_FILE\n#define MAP_FILE 0\n#endif\n#ifndef MAP_FIXED\n#define MAP_FIXED 0\n#endif\n\n#define MAP_START (void *)0x7fff8000\n#define MAP_LEN 0x10000\n\n#define OFFSET (MAP_LEN/2 - 2 * sizeof (char));\n\nf (int s, char *p)\n{\n  int i;\n  for (i = s; &p[i] < &p[40] && i >= 0; i++)\n    {\n      p[i] = -2;\n    }\n}\n\nmain ()\n{\n#ifdef MAP_ANON\n  char *p;\n  int dev_zero;\n\n  dev_zero = open (\"/dev/zero\", O_RDONLY);\n  /* -1 is OK when we have MAP_ANON; else mmap will flag an error.  */\n  if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int))\n    exit (0);\n  p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE,\n\t    MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0);\n  if (p != (char *)-1)\n    {\n      p += OFFSET;\n      p[39] = 0;\n      f (0, p);\n      if (p[39] != (char)-2)\n\tabort ();\n      p[39] = 0;\n      f (-1, p);\n      if (p[39] != 0)\n\tabort ();\n    }\n#endif\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-3.c",
    "content": "#include <limits.h>\n\nint n = 0;\n\ng (i)\n{\n  n++;\n}\n\nf (m)\n{\n  int i;\n  i = m;\n  do\n    {\n      g (i * INT_MAX / 2);\n    }\n  while (--i > 0);\n}\n\nmain ()\n{\n  f (4);\n  if (n != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-3b.c",
    "content": "#include <limits.h>\n\nint n = 0;\n\ng (i)\n{\n  n++;\n}\n\nf (m)\n{\n  int i;\n  i = m;\n  do\n    {\n      g (i * 4);\n      i -= INT_MAX / 8;\n    }\n  while (i > 0);\n}\n\nmain ()\n{\n  f (INT_MAX/8*4);\n  if (n != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-3c.c",
    "content": "#include <limits.h>\n\nvoid * a[255];\n\nf (m)\n{\n  int i;\n  int sh = 0x100;\n  i = m;\n  do\n    {\n      a[sh >>= 1] = ((unsigned)i << 3)  + (char*)a;\n      i += 4;\n    }\n  while (i < INT_MAX/2 + 1 + 4 * 4);\n}\n\nmain ()\n{\n  a[0x10] = 0;\n  a[0x08] = 0;\n  f (INT_MAX/2 + INT_MAX/4 + 2);\n  if (a[0x10] || a[0x08])\n    abort ();\n  a[0x10] = 0;\n  a[0x08] = 0;\n  f (INT_MAX/2 + 1);\n  if (! a[0x10] || a[0x08])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-4.c",
    "content": "int\nf()\n{\n  int j = 1;\n  long i;\n  for (i = -0x70000000L; i < 0x60000000L; i += 0x10000000L) j <<= 1;\n  return j;\n}\n\nint\nmain ()\n{\n  if (f () != 8192)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-4b.c",
    "content": "int\nf()\n{\n  int j = 1;\n  long i;\n  i = 0x60000000L;\n  do\n    {\n      j <<= 1;\n      i += 0x10000000L;\n    } while (i < -0x60000000L);\n  return j;\n}\n\nint\nmain ()\n{\n  if (f () != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-5.c",
    "content": "static int ap(int i);\nstatic void testit(void){\n  int ir[4] = {0,1,2,3};\n  int ix,n,m;\n  n=1; m=3;\n  for (ix=1;ix<=4;ix++) {\n    if (n == 1) m = 4;\n    else        m = n-1;\n    ap(ir[n-1]);\n    n = m;\n  }\n}\n\nstatic int t = 0;\nstatic int a[4];\n\nstatic int ap(int i){\n  if (t > 3)\n    abort();\n  a[t++] = i;\n  return 1;\n}\n\nint main(void)\n{\n  testit();\n  if (a[0] != 0)\n    abort();\n  if (a[1] != 3)\n    abort();\n  if (a[2] != 2)\n    abort();\n  if (a[3] != 1)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-6.c",
    "content": "main()\n{\n  char c;\n  char d;\n  int nbits;\n  c = -1;\n  for (nbits = 1 ; nbits < 100; nbits++) {\n    d = (1 << nbits) - 1;\n    if (d == c)\n      break;\n  }\n  if (nbits == 100)\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-7.c",
    "content": "void foo (unsigned int n)\n{\n  int i, j = -1;\n\n  for (i = 0; i < 10 && j < 0; i++)\n    {\n      if ((1UL << i) == n)\n\tj = i;\n    }\n\n  if (j < 0)\n    abort ();\n}\n\nmain()\n{\n  foo (64);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-8.c",
    "content": "double a[3] = { 0.0, 1.0, 2.0 };\n\nvoid bar (int x, double *y)\n{\n  if (x || *y != 1.0)\n    abort ();\n}\n\nint main ()\n{\n  double c;\n  int d;\n  for (d = 0; d < 3; d++)\n  {\n    c = a[d];\n    if (c > 0.0) goto e;\n  }\n  bar(1, &c);\n  exit (1);\ne:\n  bar(0, &c);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-9.c",
    "content": "/* Source: Neil Booth, from PR # 115.  */\n\nint false()\n{\n  return 0;\n}\n\nextern void abort (void);\n\nint main (int argc,char *argv[])\n{\n  int count = 0;\n\n  while (false() || count < -123)\n    ++count;\n\n  if (count)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-ivopts-1.c",
    "content": "/* From PR 18977.  */\nvoid foo(float * x);\n\nint main()\n{\n  float x[4];\n  foo (x);\n  return 0;\n}\n\nvoid foo (float *x)\n{\n    int i,j,k;\n    float temp;\n    static float t16[16]={1.,2.,3.,4.,5.,6.,7.,8.,9.,\n\t\t\t  10.,11.,12.,13.,14.,15.,16.};\n    static float tmp[4]={0.,0.,0.,0.};\n\n    for (i=0; i<4; i++) {\n\tk = 3 - i;\n\ttemp = t16[5*k];\n\tfor(j=k+1; j<4; j++) {\n\t    tmp[k] = t16[k+  j*4] * temp;\n\t}\n    }\n    x[0] = tmp[0];\n    x[1] = tmp[1];\n    x[2] = tmp[2];\n    x[3] = tmp[3];\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/loop-ivopts-2.c",
    "content": "/* PR rtl-optimization/20290  */\n   \n/* We used to mis-optimize the second loop in main on at least ppc and\n   arm, because tree loop would change the loop to something like:\n\n  ivtmp.65 = &l[i];\n  ivtmp.16 = 113;\n  goto <bb 4> (<L4>);\n\n<L3>:;\n  *(ivtmp.65 + 4294967292B) = 9;\n  i = i + 1;\n\n<L4>:;\n  ivtmp.16 = ivtmp.16 - 1;\n  ivtmp.65 = ivtmp.65 + 4B;\n  if (ivtmp.16 != 0) goto <L3>; \n\n  We used to consider the increment of i as executed in every\n  iteration, so we'd miscompute the final value.  */\n\nextern void abort (void);\n\nvoid\ncheck (unsigned int *l)\n{\n  int i;\n  for (i = 0; i < 288; i++)\n    if (l[i] != 7 + (i < 256 || i >= 280) + (i >= 144 && i < 256))\n      abort ();\n}\n\nint\nmain (void)\n{\n  int i;\n  unsigned int l[288];\n\n  for (i = 0; i < 144; i++)\n    l[i] = 8;\n  for (; i < 256; i++)\n    l[i] = 9;\n  for (; i < 280; i++)\n    l[i] = 7;\n  for (; i < 288; i++)\n    l[i] = 8;\n  check (l);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/lshrdi-1.c",
    "content": "#include <limits.h>\n\nextern void abort(void);\nextern void exit(int);\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n#define BITS 64\n\nstatic unsigned long long const zext[64] = {\n  0x87654321fedcba90ULL,\n  0x43b2a190ff6e5d48ULL,\n  0x21d950c87fb72ea4ULL,\n  0x10eca8643fdb9752ULL,\n  0x87654321fedcba9ULL,\n  0x43b2a190ff6e5d4ULL,\n  0x21d950c87fb72eaULL,\n  0x10eca8643fdb975ULL,\n  0x87654321fedcbaULL,\n  0x43b2a190ff6e5dULL,\n  0x21d950c87fb72eULL,\n  0x10eca8643fdb97ULL,\n  0x87654321fedcbULL,\n  0x43b2a190ff6e5ULL,\n  0x21d950c87fb72ULL,\n  0x10eca8643fdb9ULL,\n  0x87654321fedcULL,\n  0x43b2a190ff6eULL,\n  0x21d950c87fb7ULL,\n  0x10eca8643fdbULL,\n  0x87654321fedULL,\n  0x43b2a190ff6ULL,\n  0x21d950c87fbULL,\n  0x10eca8643fdULL,\n  0x87654321feULL,\n  0x43b2a190ffULL,\n  0x21d950c87fULL,\n  0x10eca8643fULL,\n  0x87654321fULL,\n  0x43b2a190fULL,\n  0x21d950c87ULL,\n  0x10eca8643ULL,\n  0x87654321ULL,\n  0x43b2a190ULL,\n  0x21d950c8ULL,\n  0x10eca864ULL,\n  0x8765432ULL,\n  0x43b2a19ULL,\n  0x21d950cULL,\n  0x10eca86ULL,\n  0x876543ULL,\n  0x43b2a1ULL,\n  0x21d950ULL,\n  0x10eca8ULL,\n  0x87654ULL,\n  0x43b2aULL,\n  0x21d95ULL,\n  0x10ecaULL,\n  0x8765ULL,\n  0x43b2ULL,\n  0x21d9ULL,\n  0x10ecULL,\n  0x876ULL,\n  0x43bULL,\n  0x21dULL,\n  0x10eULL,\n  0x87ULL,\n  0x43ULL,\n  0x21ULL,\n  0x10ULL,\n  0x8ULL,\n  0x4ULL,\n  0x2ULL,\n  0x1ULL\n};\n\n#elif __LONG_LONG_MAX__ == 2147483647LL\n#define BITS 32\n\nstatic unsigned long long const zext[32] = {\n  0x87654321ULL,\n  0x43b2a190ULL,\n  0x21d950c8ULL,\n  0x10eca864ULL,\n  0x8765432ULL,\n  0x43b2a19ULL,\n  0x21d950cULL,\n  0x10eca86ULL,\n  0x876543ULL,\n  0x43b2a1ULL,\n  0x21d950ULL,\n  0x10eca8ULL,\n  0x87654ULL,\n  0x43b2aULL,\n  0x21d95ULL,\n  0x10ecaULL,\n  0x8765ULL,\n  0x43b2ULL,\n  0x21d9ULL,\n  0x10ecULL,\n  0x876ULL,\n  0x43bULL,\n  0x21dULL,\n  0x10eULL,\n  0x87ULL,\n  0x43ULL,\n  0x21ULL,\n  0x10ULL,\n  0x8ULL,\n  0x4ULL,\n  0x2ULL,\n  0x1ULL,\n};\n\n#else\n#error \"Update the test case.\"\n#endif\n\nstatic unsigned long long\nvariable_shift(unsigned long long x, int i)\n{\n  return x >> i;\n}\n\nstatic unsigned long long\nconstant_shift(unsigned long long x, int i)\n{\n  switch (i)\n    {\n    case 0: x = x >> 0; break;\n    case 1: x = x >> 1; break;\n    case 2: x = x >> 2; break;\n    case 3: x = x >> 3; break;\n    case 4: x = x >> 4; break;\n    case 5: x = x >> 5; break;\n    case 6: x = x >> 6; break;\n    case 7: x = x >> 7; break;\n    case 8: x = x >> 8; break;\n    case 9: x = x >> 9; break;\n    case 10: x = x >> 10; break;\n    case 11: x = x >> 11; break;\n    case 12: x = x >> 12; break;\n    case 13: x = x >> 13; break;\n    case 14: x = x >> 14; break;\n    case 15: x = x >> 15; break;\n    case 16: x = x >> 16; break;\n    case 17: x = x >> 17; break;\n    case 18: x = x >> 18; break;\n    case 19: x = x >> 19; break;\n    case 20: x = x >> 20; break;\n    case 21: x = x >> 21; break;\n    case 22: x = x >> 22; break;\n    case 23: x = x >> 23; break;\n    case 24: x = x >> 24; break;\n    case 25: x = x >> 25; break;\n    case 26: x = x >> 26; break;\n    case 27: x = x >> 27; break;\n    case 28: x = x >> 28; break;\n    case 29: x = x >> 29; break;\n    case 30: x = x >> 30; break;\n    case 31: x = x >> 31; break;\n#if BITS > 32\n    case 32: x = x >> 32; break;\n    case 33: x = x >> 33; break;\n    case 34: x = x >> 34; break;\n    case 35: x = x >> 35; break;\n    case 36: x = x >> 36; break;\n    case 37: x = x >> 37; break;\n    case 38: x = x >> 38; break;\n    case 39: x = x >> 39; break;\n    case 40: x = x >> 40; break;\n    case 41: x = x >> 41; break;\n    case 42: x = x >> 42; break;\n    case 43: x = x >> 43; break;\n    case 44: x = x >> 44; break;\n    case 45: x = x >> 45; break;\n    case 46: x = x >> 46; break;\n    case 47: x = x >> 47; break;\n    case 48: x = x >> 48; break;\n    case 49: x = x >> 49; break;\n    case 50: x = x >> 50; break;\n    case 51: x = x >> 51; break;\n    case 52: x = x >> 52; break;\n    case 53: x = x >> 53; break;\n    case 54: x = x >> 54; break;\n    case 55: x = x >> 55; break;\n    case 56: x = x >> 56; break;\n    case 57: x = x >> 57; break;\n    case 58: x = x >> 58; break;\n    case 59: x = x >> 59; break;\n    case 60: x = x >> 60; break;\n    case 61: x = x >> 61; break;\n    case 62: x = x >> 62; break;\n    case 63: x = x >> 63; break;\n#endif\n\n    default:\n      abort ();\n    }\n  return x;\n}\n\nint\nmain()\n{\n  int i;\n\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = variable_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n  for (i = 0; i < BITS; ++i)\n    {\n      unsigned long long y = constant_shift (zext[0], i);\n      if (y != zext[i])\n\tabort ();\n    }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/lto-tbaa-1.c",
    "content": "/* { dg-additional-options \"-fno-early-inlining -fno-ipa-cp\" }  */\nstruct a {\n  float *b;\n} *a;\nstruct b {\n  int *b;\n} b;\nstruct c {\n  float *b;\n} *c;\nint d;\nuse_a (struct a *a)\n{\n}\nset_b (int **a)\n{\n  *a=&d;\n}\nuse_c (struct c *a)\n{\n}\n__attribute__ ((noinline)) int **retme(int **val)\n{\n  return val;\n}\nint e;\nstruct b b= {&e};\nstruct b b2;\nstruct b b3;\nint **ptr = &b2.b;\nmain ()\n{\n  a= (void *)0;\n  b.b=&e;\n  ptr =retme ( &b.b);\n  set_b (ptr);\n  b3=b;\n  if (b3.b != &d)\n  __builtin_abort ();\n  c= (void *)0;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/mayalias-1.c",
    "content": "/* Tests that the may_alias attribute works as expected.\n   Author: Osku Salerma <osku@iki.fi> Apr 2002.  */\n \nextern void abort(void);\nextern void exit(int);\n\ntypedef short __attribute__((__may_alias__)) short_a;\n\nint\nmain (void)\n{\n  int a = 0x12345678;\n  short_a *b = (short_a*) &a;\n\n  b[1] = 0;\n\n  if (a == 0x12345678)\n    abort();\n\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/mayalias-2.c",
    "content": "typedef struct __attribute__((__may_alias__)) { short x; } test;\n\nint f() {\n  int a=10;\n  test *p=(test *)&a;\n  p->x = 1;\n  return a;\n}\n\nint main() {\n  if (f() == 10)\n    __builtin_abort();\n  return 0;\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c",
    "content": "typedef struct __attribute__((__may_alias__)) { short x; } test;\n\ntest *p;\n\nint g(int *a)\n{\n p = (test*)a;\n}\n\nint f()\n{\n  int a;\n  g(&a);\n  a = 10;\n  test s={1};\n  *p=s;\n  return a;\n}\n\nint main() {\n  if (f() == 10)\n    __builtin_abort();\n  return 0;\n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/medce-1.c",
    "content": "\nextern void abort (void);\nextern void link_error (void);\n\nstatic int ok = 0;\n\nvoid bar (void)\n{\n  ok = 1;\n}\n\nvoid foo(int x)\n{\n  switch (x)\n  {\n  case 0:\n    if (0)\n    {\n      link_error();\n  case 1:\n      bar();\n    }\n  }\n}\n\nint main()\n{\n  foo (1);\n  if (!ok)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c",
    "content": "#include <string.h>\n\n#if defined (STACK_SIZE)\n#define MEMCPY_SIZE (STACK_SIZE / 3)\n#else\n#define MEMCPY_SIZE (1 << 17)\n#endif\n\n\nvoid *copy (void *o, const void *i, unsigned l)\n{\n  return memcpy (o, i, l);\n}\n\nmain ()\n{\n  unsigned i;\n  unsigned char src[MEMCPY_SIZE];\n  unsigned char dst[MEMCPY_SIZE];\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    src[i] = (unsigned char) i,  dst[i] = 0;\n\n  (void) memcpy (dst, src, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 1, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != 1)\n      abort ();\n\n  (void) memcpy (dst, src, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 0, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != 0)\n      abort ();\n\n  (void) copy (dst, src, MEMCPY_SIZE / 128);\n\n  for (i = 0; i < MEMCPY_SIZE / 128; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  (void) memset (dst, 0, MEMCPY_SIZE);\n\n  (void) copy (dst, src, MEMCPY_SIZE);\n\n  for (i = 0; i < MEMCPY_SIZE; i++)\n    if (dst[i] != (unsigned char) i)\n      abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memcpy-2.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memcpy with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nmain ()\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\n\t  p = memcpy (u1.buf + off1, u2.buf + off2, len);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memcpy-bi.c",
    "content": "/* Test builtin-memcpy (which may emit different code for different N).  */\n#include <string.h>\n\n#define TESTSIZE 80\n\nchar src[TESTSIZE] __attribute__ ((aligned));\nchar dst[TESTSIZE] __attribute__ ((aligned));\n\nvoid\ncheck (char *test, char *match, int n)\n{\n  if (memcmp (test, match, n))\n    abort ();\n}\n\n#define TN(n) \\\n{ memset (dst, 0, n); memcpy (dst, src, n); check (dst, src, n); }\n#define T(n) \\\nTN (n) \\\nTN ((n) + 1) \\\nTN ((n) + 2) \\\nTN ((n) + 3)\n\nmain ()\n{\n  int i,j;\n\n  for (i = 0; i < sizeof (src); ++i)\n      src[i] = 'a' + i % 26;\n\n  T (0);\n  T (4);\n  T (8);\n  T (12);\n  T (16);\n  T (20);\n  T (24);\n  T (28);\n  T (32);\n  T (36);\n  T (40);\n  T (44);\n  T (48);\n  T (52);\n  T (56);\n  T (60);\n  T (64);\n  T (68);\n  T (72);\n  T (76);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memset-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nmain ()\n{\n  int off, len, i;\n  char *p, *q;\n\n  for (off = 0; off < MAX_OFFSET; off++)\n    for (len = 1; len < MAX_COPY; len++)\n      {\n\tfor (i = 0; i < MAX_LENGTH; i++)\n\t  u.buf[i] = 'a';\n\n\tp = memset (u.buf + off, '\\0', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != '\\0')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, A, len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'A')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tp = memset (u.buf + off, 'B', len);\n\tif (p != u.buf + off)\n\t  abort ();\n\n\tq = u.buf;\n\tfor (i = 0; i < off; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n\n\tfor (i = 0; i < len; i++, q++)\n\t  if (*q != 'B')\n\t    abort ();\n\n\tfor (i = 0; i < MAX_EXTRA; i++, q++)\n\t  if (*q != 'a')\n\t    abort ();\n      }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memset-2.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of pointer alignments and constant\n   lengths to make sure any optimizations in the compiler are correct.\n\n   Written by Roger Sayle, April 22, 2002.  */\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY 15\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nvoid reset ()\n{\n  int i;\n\n  for (i = 0; i < MAX_LENGTH; i++)\n    u.buf[i] = 'a';\n}\n\nvoid check (int off, int len, int ch)\n{\n  char *q;\n  int i;\n\n  q = u.buf;\n  for (i = 0; i < off; i++, q++)\n    if (*q != 'a')\n      abort ();\n\n  for (i = 0; i < len; i++, q++)\n    if (*q != ch)\n      abort ();\n\n  for (i = 0; i < MAX_EXTRA; i++, q++)\n    if (*q != 'a')\n      abort ();\n}\n\nint main ()\n{\n  int off;\n  char *p;\n\n  /* len == 1 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, '\\0');\n\n      p = memset (u.buf + off, A, 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, 'A');\n\n      p = memset (u.buf + off, 'B', 1);\n      if (p != u.buf + off) abort ();\n      check (off, 1, 'B');\n    }\n\n  /* len == 2 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, '\\0');\n\n      p = memset (u.buf + off, A, 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, 'A');\n\n      p = memset (u.buf + off, 'B', 2);\n      if (p != u.buf + off) abort ();\n      check (off, 2, 'B');\n    }\n\n  /* len == 3 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, '\\0');\n\n      p = memset (u.buf + off, A, 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, 'A');\n\n      p = memset (u.buf + off, 'B', 3);\n      if (p != u.buf + off) abort ();\n      check (off, 3, 'B');\n    }\n\n  /* len == 4 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, '\\0');\n\n      p = memset (u.buf + off, A, 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, 'A');\n\n      p = memset (u.buf + off, 'B', 4);\n      if (p != u.buf + off) abort ();\n      check (off, 4, 'B');\n    }\n\n  /* len == 5 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, '\\0');\n\n      p = memset (u.buf + off, A, 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, 'A');\n\n      p = memset (u.buf + off, 'B', 5);\n      if (p != u.buf + off) abort ();\n      check (off, 5, 'B');\n    }\n\n  /* len == 6 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, '\\0');\n\n      p = memset (u.buf + off, A, 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, 'A');\n\n      p = memset (u.buf + off, 'B', 6);\n      if (p != u.buf + off) abort ();\n      check (off, 6, 'B');\n    }\n\n  /* len == 7 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, '\\0');\n\n      p = memset (u.buf + off, A, 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, 'A');\n\n      p = memset (u.buf + off, 'B', 7);\n      if (p != u.buf + off) abort ();\n      check (off, 7, 'B');\n    }\n\n  /* len == 8 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, '\\0');\n\n      p = memset (u.buf + off, A, 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, 'A');\n\n      p = memset (u.buf + off, 'B', 8);\n      if (p != u.buf + off) abort ();\n      check (off, 8, 'B');\n    }\n\n  /* len == 9 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, '\\0');\n\n      p = memset (u.buf + off, A, 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, 'A');\n\n      p = memset (u.buf + off, 'B', 9);\n      if (p != u.buf + off) abort ();\n      check (off, 9, 'B');\n    }\n\n  /* len == 10 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, '\\0');\n\n      p = memset (u.buf + off, A, 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, 'A');\n\n      p = memset (u.buf + off, 'B', 10);\n      if (p != u.buf + off) abort ();\n      check (off, 10, 'B');\n    }\n\n  /* len == 11 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, '\\0');\n\n      p = memset (u.buf + off, A, 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, 'A');\n\n      p = memset (u.buf + off, 'B', 11);\n      if (p != u.buf + off) abort ();\n      check (off, 11, 'B');\n    }\n\n  /* len == 12 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, '\\0');\n\n      p = memset (u.buf + off, A, 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, 'A');\n\n      p = memset (u.buf + off, 'B', 12);\n      if (p != u.buf + off) abort ();\n      check (off, 12, 'B');\n    }\n\n  /* len == 13 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, '\\0');\n\n      p = memset (u.buf + off, A, 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, 'A');\n\n      p = memset (u.buf + off, 'B', 13);\n      if (p != u.buf + off) abort ();\n      check (off, 13, 'B');\n    }\n\n  /* len == 14 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, '\\0');\n\n      p = memset (u.buf + off, A, 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, 'A');\n\n      p = memset (u.buf + off, 'B', 14);\n      if (p != u.buf + off) abort ();\n      check (off, 14, 'B');\n    }\n\n  /* len == 15 */\n  for (off = 0; off < MAX_OFFSET; off++)\n    {\n      reset ();\n\n      p = memset (u.buf + off, '\\0', 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, '\\0');\n\n      p = memset (u.buf + off, A, 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, 'A');\n\n      p = memset (u.buf + off, 'B', 15);\n      if (p != u.buf + off) abort ();\n      check (off, 15, 'B');\n    }\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memset-3.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test memset with various combinations of constant pointer alignments and\n   lengths to make sure any optimizations in the compiler are correct.\n\n   Written by Roger Sayle, July 22, 2002.  */\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY 15\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + MAX_EXTRA)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nchar A = 'A';\n\nvoid reset ()\n{\n  int i;\n\n  for (i = 0; i < MAX_LENGTH; i++)\n    u.buf[i] = 'a';\n}\n\nvoid check (int off, int len, int ch)\n{\n  char *q;\n  int i;\n\n  q = u.buf;\n  for (i = 0; i < off; i++, q++)\n    if (*q != 'a')\n      abort ();\n\n  for (i = 0; i < len; i++, q++)\n    if (*q != ch)\n      abort ();\n\n  for (i = 0; i < MAX_EXTRA; i++, q++)\n    if (*q != 'a')\n      abort ();\n}\n\nint main ()\n{\n  int len;\n  char *p;\n\n  /* off == 0 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf, '\\0', len);\n      if (p != u.buf) abort ();\n      check (0, len, '\\0');\n\n      p = memset (u.buf, A, len);\n      if (p != u.buf) abort ();\n      check (0, len, 'A');\n\n      p = memset (u.buf, 'B', len);\n      if (p != u.buf) abort ();\n      check (0, len, 'B');\n    }\n\n  /* off == 1 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+1, '\\0', len);\n      if (p != u.buf+1) abort ();\n      check (1, len, '\\0');\n\n      p = memset (u.buf+1, A, len);\n      if (p != u.buf+1) abort ();\n      check (1, len, 'A');\n\n      p = memset (u.buf+1, 'B', len);\n      if (p != u.buf+1) abort ();\n      check (1, len, 'B');\n    }\n\n  /* off == 2 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+2, '\\0', len);\n      if (p != u.buf+2) abort ();\n      check (2, len, '\\0');\n\n      p = memset (u.buf+2, A, len);\n      if (p != u.buf+2) abort ();\n      check (2, len, 'A');\n\n      p = memset (u.buf+2, 'B', len);\n      if (p != u.buf+2) abort ();\n      check (2, len, 'B');\n    }\n\n  /* off == 3 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+3, '\\0', len);\n      if (p != u.buf+3) abort ();\n      check (3, len, '\\0');\n\n      p = memset (u.buf+3, A, len);\n      if (p != u.buf+3) abort ();\n      check (3, len, 'A');\n\n      p = memset (u.buf+3, 'B', len);\n      if (p != u.buf+3) abort ();\n      check (3, len, 'B');\n    }\n\n  /* off == 4 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+4, '\\0', len);\n      if (p != u.buf+4) abort ();\n      check (4, len, '\\0');\n\n      p = memset (u.buf+4, A, len);\n      if (p != u.buf+4) abort ();\n      check (4, len, 'A');\n\n      p = memset (u.buf+4, 'B', len);\n      if (p != u.buf+4) abort ();\n      check (4, len, 'B');\n    }\n\n  /* off == 5 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+5, '\\0', len);\n      if (p != u.buf+5) abort ();\n      check (5, len, '\\0');\n\n      p = memset (u.buf+5, A, len);\n      if (p != u.buf+5) abort ();\n      check (5, len, 'A');\n\n      p = memset (u.buf+5, 'B', len);\n      if (p != u.buf+5) abort ();\n      check (5, len, 'B');\n    }\n\n  /* off == 6 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+6, '\\0', len);\n      if (p != u.buf+6) abort ();\n      check (6, len, '\\0');\n\n      p = memset (u.buf+6, A, len);\n      if (p != u.buf+6) abort ();\n      check (6, len, 'A');\n\n      p = memset (u.buf+6, 'B', len);\n      if (p != u.buf+6) abort ();\n      check (6, len, 'B');\n    }\n\n  /* off == 7 */\n  for (len = 0; len < MAX_COPY; len++)\n    {\n      reset ();\n\n      p = memset (u.buf+7, '\\0', len);\n      if (p != u.buf+7) abort ();\n      check (7, len, '\\0');\n\n      p = memset (u.buf+7, A, len);\n      if (p != u.buf+7) abort ();\n      check (7, len, 'A');\n\n      p = memset (u.buf+7, 'B', len);\n      if (p != u.buf+7) abort ();\n      check (7, len, 'B');\n    }\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/memset-4.c",
    "content": "/* Test to make sure memset of small old size works\n   correctly. */\n#define SIZE 15\n\nvoid f(char *a) __attribute__((noinline));\nvoid f(char *a)\n{\n  __builtin_memset (a, 0, SIZE);\n}\n\n\nint main(void)\n{\n  int i;\n  char b[SIZE];\n  for(i = 0; i < sizeof(b); i++)\n    {\n      b[i] = i;\n    }\n  f(b);\n  for(i = 0; i < sizeof(b); i++)\n    {\n      if (0 != b[i])\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/mod-1.c",
    "content": "f (x, y)\n{\n  if (x % y != 0)\n    abort ();\n}\n\nmain ()\n{\n  f (-5, 5);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/mode-dependent-address.c",
    "content": "/* { dg-require-effective-target stdint_types } */\n\n#include <stdint.h>\n#include <string.h>\n#include <stdlib.h>\n\nvoid f883b (int8_t * result,\n    int16_t * __restrict arg1,\n    uint32_t * __restrict arg2,\n    uint64_t * __restrict arg3,\n    uint8_t * __restrict arg4)\n{\n    int idx;\n    for (idx=0;idx<96;idx += 1) {\n\tresult[idx] = (((((((((((-27 + 2+1)>>1) || arg4[idx]) < arg1[idx])\n\t\t\t\t? (((-27 + 2+1)>>1) || arg4[idx])\n\t\t\t\t: arg1[idx])\n\t\t\t       >> (arg2[idx] & 31)) ^ 1) - -32)>>7) | -5) & arg3[idx]);\n    }\n}\n\nint8_t result[96];\nint16_t arg1[96];\nuint32_t arg2[96];\nuint64_t arg3[96];\nuint8_t arg4[96];\n\nint main (void) \n{\n  int i;\n  int correct[] = {0x0,0x1,0x2,0x3,0x0,0x1,0x2,0x3,0x8,0x9,0xa,0xb,0x8,0x9,\n                   0xa,0xb,0x10,0x11,0x12,0x13,0x10,0x11,0x12,0x13,\n                   0x18,0x19,0x1a,0x1b,0x18,0x19,0x1a,0x1b,0x20,0x21,0x22,\n                   0x23,0x20,0x21,0x22,0x23,0x28,0x29,0x2a,\n                   0x2b,0x28,0x29,0x2a,0x2b,0x30,0x31,0x32,0x33,\n                   0x30,0x31,0x32,0x33,0x38,0x39,0x3a,0x3b,0x38,0x39,0x3a,\n                   0x3b,0x40,0x41,0x42,0x43,0x40,0x41,0x42,0x43,0x48,0x49,\n                   0x4a,0x4b,0x48,0x49,0x4a,0x4b,0x50,0x51,\n                   0x52,0x53,0x50,0x51,0x52,0x53,0x58,0x59,0x5a,0x5b,\n                   0x58,0x59,0x5a,0x5b};\n\n  for (i=0; i < 96; i++)\n    arg3[i] = arg2[i] = arg1[i] = arg4[i] = i;\n\n  f883b(result, arg1, arg2, arg3, arg4);\n\n  for (i=0; i < 96; i++)\n    if (result[i] != correct[i]) abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/multdi-1.c",
    "content": "/* PR target/9348 */\n\n#define u_l_l unsigned long long\n#define l_l long long\n\nl_l mpy_res;\n\nu_l_l mpy (long a, long b)\n{\n  return (u_l_l) a * (u_l_l) b;\n}\n \nint main(void)\n{\n  mpy_res = mpy(1,-1);\n  if (mpy_res != -1LL)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/multi-ix.c",
    "content": "/* Test for a reload bug:\n   if you have a memory reference using the indexed addressing\n   mode, and the base address is a pseudo containing an address in the frame\n   and this pseudo fails to get a hard register, we end up with a double PLUS,\n   so the frame address gets reloaded.  Now, when the index got a hard register,\n   and it dies in this insn, push_reload will consider that hard register as\n   a reload register, and disregrad overlaps with rld[n_reloads].in .  That is\n   fine as long as the add can be done with a single insn, but when the\n   constant is so large that it has to be reloaded into a register first,\n   that clobbers the index.  */\n\n#include <stdarg.h>\n\n#ifdef STACK_SIZE\n/* We need to be careful that we don't blow our stack.  Function f, in the\n   worst case, needs to fit on the stack:\n\n   * 40 int[CHUNK] arrays;\n   * ~40 ints;\n   * ~40 pointers for stdarg passing.\n\n   Subtract the last two off STACK_SIZE and figure out what the maximum\n   chunk size can be.  We make the last bit conservative to account for\n   register saves and other processor-dependent saving.  Limit the\n   chunk size to some sane values.  */\n\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))\n\n#define CHUNK\t\t\t\t\t\t\t\t\\\n  MIN (500, (MAX (1, (signed)(STACK_SIZE-40*sizeof(int)-256*sizeof(void *)) \\\n\t\t      / (signed)(40*sizeof(int)))))\n#else\n#define CHUNK 500\n#endif\n\nvoid s(int, ...);\nvoid z(int, ...);\nvoid c(int, ...);\n\ntypedef int l[CHUNK];\n\nvoid\nf (int n)\n{\n  int i;\n  l a0, a1, a2, a3, a4, a5, a6, a7, a8, a9;\n  l a10, a11, a12, a13, a14, a15, a16, a17, a18, a19;\n  l a20, a21, a22, a23, a24, a25, a26, a27, a28, a29;\n  l a30, a31, a32, a33, a34, a35, a36, a37, a38, a39;\n  int i0, i1, i2, i3, i4, i5, i6, i7, i8, i9;\n  int i10, i11, i12, i13, i14, i15, i16, i17, i18, i19;\n  int i20, i21, i22, i23, i24, i25, i26, i27, i28, i29;\n  int i30, i31, i32, i33, i34, i35, i36, i37, i38, i39;\n\n  for (i = 0; i < n; i++)\n    {\n      s (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n      i0 = a0[0];\n      i1 = a1[0];\n      i2 = a2[0];\n      i3 = a3[0];\n      i4 = a4[0];\n      i5 = a5[0];\n      i6 = a6[0];\n      i7 = a7[0];\n      i8 = a8[0];\n      i9 = a9[0];\n      i10 = a10[0];\n      i11 = a11[0];\n      i12 = a12[0];\n      i13 = a13[0];\n      i14 = a14[0];\n      i15 = a15[0];\n      i16 = a16[0];\n      i17 = a17[0];\n      i18 = a18[0];\n      i19 = a19[0];\n      i20 = a20[0];\n      i21 = a21[0];\n      i22 = a22[0];\n      i23 = a23[0];\n      i24 = a24[0];\n      i25 = a25[0];\n      i26 = a26[0];\n      i27 = a27[0];\n      i28 = a28[0];\n      i29 = a29[0];\n      i30 = a30[0];\n      i31 = a31[0];\n      i32 = a32[0];\n      i33 = a33[0];\n      i34 = a34[0];\n      i35 = a35[0];\n      i36 = a36[0];\n      i37 = a37[0];\n      i38 = a38[0];\n      i39 = a39[0];\n      z (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n      a0[i0] = i0;\n      a1[i1] = i1;\n      a2[i2] = i2;\n      a3[i3] = i3;\n      a4[i4] = i4;\n      a5[i5] = i5;\n      a6[i6] = i6;\n      a7[i7] = i7;\n      a8[i8] = i8;\n      a9[i9] = i9;\n      a10[i10] = i10;\n      a11[i11] = i11;\n      a12[i12] = i12;\n      a13[i13] = i13;\n      a14[i14] = i14;\n      a15[i15] = i15;\n      a16[i16] = i16;\n      a17[i17] = i17;\n      a18[i18] = i18;\n      a19[i19] = i19;\n      a20[i20] = i20;\n      a21[i21] = i21;\n      a22[i22] = i22;\n      a23[i23] = i23;\n      a24[i24] = i24;\n      a25[i25] = i25;\n      a26[i26] = i26;\n      a27[i27] = i27;\n      a28[i28] = i28;\n      a29[i29] = i29;\n      a30[i30] = i30;\n      a31[i31] = i31;\n      a32[i32] = i32;\n      a33[i33] = i33;\n      a34[i34] = i34;\n      a35[i35] = i35;\n      a36[i36] = i36;\n      a37[i37] = i37;\n      a38[i38] = i38;\n      a39[i39] = i39;\n      c (40, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,\n\t a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,\n         a20, a21, a22, a23, a24, a25, a26, a27, a28, a29,\n         a30, a31, a32, a33, a34, a35, a36, a37, a38, a39);\n    }\n}\n\nint\nmain ()\n{\n  /* CHUNK needs to be at least 40 to avoid stack corruption,\n     since index variable i0 in \"a[i0] = i0\" equals 39.  */\n  if (CHUNK < 40)\n    exit (0);\n\n  f (1);\n  exit (0);\n}\n\nvoid s(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      a[0] = n;\n    }\n  va_end (list);\n}\n\nvoid z(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      __builtin_memset (a, 0, sizeof (l));\n    }\n  va_end (list);\n}\n\nvoid c(int n, ...)\n{\n  va_list list;\n\n  va_start (list, n);\n  while (n--)\n    {\n      int *a = va_arg (list, int *);\n      if (a[n] != n)\n\tabort ();\n    }\n  va_end (list);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nest-align-1.c",
    "content": "/* Test for alignment handling when a variable is accessed by nested\n   function.  */\n/* Origin: Joey Ye <joey.ye@intel.com> */\n\n/* Force bigger stack alignment for PowerPC EABI targets.  */\n/* { dg-options \"-mno-eabi\" { target powerpc-*-eabi* } } */\n\n#include <stddef.h>\n\ntypedef int aligned __attribute__((aligned));\nextern void abort (void);\n\nvoid\ncheck (int *i)\n{\n  *i = 20;\n  if ((((ptrdiff_t) i) & (__alignof__(aligned) - 1)) != 0)\n    abort ();\n}\n\nvoid\nfoo (void)\n{\n  aligned jj;\n  void bar ()\n    {\n      jj = -20;\n    }\n  jj = 0;\n  bar ();\n  if (jj != -20)\n    abort ();\n  check (&jj);\n  if (jj != 20)\n    abort ();\n}\n\nint\nmain()\n{\n  foo ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c",
    "content": "#include <stdarg.h>\n\nmain ()\n{\n  double f (int x, ...)\n    {\n      va_list args;\n      double a;\n\n      va_start (args, x);\n      a = va_arg (args, double);\n      va_end (args);\n      return a;\n    }\n\n  if (f (1, (double)1) != 1.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-1.c",
    "content": "int\ng (int a, int b, int (*gi) (int, int))\n{\n  if ((*gi) (a, b))\n    return a;\n  else\n    return b;\n}\n\nf ()\n{\n#ifndef NO_TRAMPOLINES\n  int i, j;\n  int f2 (int a, int b)\n    {\n      return a > b;\n    }\n\n  if (g (1, 2, f2) != 2)\n    abort ();\n#endif\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-2.c",
    "content": "extern int foo (int, int, int (*) (int, int, int, int, int, int, int));\n\nint z;\n\nint\nmain (void)\n{\n#ifndef NO_TRAMPOLINES\n  int sum = 0;\n  int i;\n\n  int nested (int a, int b, int c, int d, int e, int f, int g)\n    {\n      z = c + d + e + f + g;\n      \n      if (a > 2 * b)\n        return a - b;\n      else\n        return b - a;\n    }\n\n  for (i = 0; i < 10; ++i)\n    {\n      int j;\n\n      for (j = 0; j < 10; ++j)\n        {\n          int k;\n\n          for (k = 0; k < 10; ++k)\n            sum += foo (i, j > k ? j - k : k - j, nested);\n        }\n    }\n\n  if (sum != 2300)\n    abort ();\n\n  if (z != 0x1b)\n    abort ();\n#endif\n  \n  exit (0);\n}\n\nint\nfoo (int a, int b, int (* fp) (int, int, int, int, int, int, int))\n{\n  return fp (a, b, a, b, a, b, a);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-3.c",
    "content": "\nextern long foo (long, long, long (*) (long, long));\nextern long use (long (*) (long, long), long, long);\n\nint\nmain (void)\n{\n#ifndef NO_TRAMPOLINES\n  long sum = 0;\n  long i;\n\n  long nested_0 (long a, long b)\n    {\n      if (a > 2 * b)\n        return a - b;\n      else\n        return b - a;\n    }\n\n  long nested_1 (long a, long b)\n    {\n      return use (nested_0, b, a) + sum;\n    }\n\n  long nested_2 (long a, long b)\n    {\n      return nested_1 (b, a);\n    }\n\n  for (i = 0; i < 10; ++i)\n    {\n      long j;\n\n      for (j = 0; j < 10; ++j)\n        {\n          long k;\n\n          for (k = 0; k < 10; ++k)\n            sum += foo (i, j > k ? j - k : k - j, nested_2);\n        }\n    }\n\n  if ((sum & 0xffffffff) != 0xbecfcbf5)\n    abort ();\n#endif\n\n  exit (0);\n}\n\nlong\nuse (long (* func)(long, long), long a, long b)\n{\n  return func (b, a);\n}\n\nlong\nfoo (long a, long b, long (* func) (long, long))\n{\n  return func (a, b);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-4.c",
    "content": "/* Origin: hp@bitrange.com\n   Test that return values come out right from a 1000-level call chain to\n   functions without parameters that each need at least one \"long\"\n   preserved.  Exposed problems related to the MMIX port.  */\n\nlong level = 0;\nextern long foo (void);\nextern long bar (void);\n\n#ifdef STACK_SIZE\n#define DEPTH ((STACK_SIZE) / 512 + 1)\n#else\n#define DEPTH 500\n#endif\n\nint\nmain (void)\n{\n  if (foo () == -42)\n    exit (0);\n\n  abort ();\n}\n\nlong\nfoo (void)\n{\n  long tmp = ++level;\n  return bar () + tmp;\n}\n\nlong\nbar (void)\n{\n  long tmp = level;\n  return tmp > DEPTH - 1 ? -42 - tmp : foo () - tmp;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-5.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\n#ifndef NO_TRAMPOLINES\nstatic void recursive (int n, void (*proc) (void))\n{\n  __label__ l1;\n\n  void do_goto (void)\n  {\n    goto l1;\n  }\n\n  if (n == 3)\n      recursive (n - 1, do_goto);\n  else if (n > 0)\n    recursive (n - 1, proc);\n  else\n    (*proc) ();\n  return;\n\nl1:\n  if (n == 3)\n    exit (0);\n  else\n    abort ();\n}\n\nint main ()\n{\n  recursive (10, abort);\n  abort ();\n}\n#else\nint main () { return 0; }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-6.c",
    "content": "/* Test that the GP gets properly restored, either by the nonlocal\n   receiver or the nested function.  */\n\n#ifndef NO_TRAMPOLINES\n\ntypedef __SIZE_TYPE__ size_t;\nextern void abort (void);\nextern void exit (int);\nextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));\n\nint main ()\n{\n  __label__ nonlocal;\n  int compare (const void *a, const void *b)\n  {\n    goto nonlocal;\n  }\n\n  char array[3];\n  qsort (array, 3, 1, compare);\n  abort ();\n\n nonlocal:\n  exit (0);\n}\n\n#else\nint main() { return 0; }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/nestfunc-7.c",
    "content": "struct A\n{\n  int one;\n  int two;\n  int three;\n  int four;\n  int five;\n  int six;\n};\n\nstatic int test (void)\n{\n  int base;\n\n  struct A Foo (void)\n    {\n      struct A a;\n\n      a.one = base + 1;\n      a.two = base + 2;\n      a.three = base + 3;\n      a.four = base + 4;\n      a.five = base + 5;\n      a.six = base + 6;\n\n      return a;\n    }\n\n  base = 10;\n  struct A a = Foo ();\n\n  return (a.one == 11\n\t  && a.two == 12\n\t  && a.three == 13\n\t  && a.four == 14\n\t  && a.five == 15\n\t  && a.six == 16);\n}\n\nint main (void)\n{\n  return !test ();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/p18298.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\n#include <stdbool.h>\n#include <stdlib.h>\nextern void abort (void);\nint strcmp (const char*, const char*);\nchar s[2048] = \"a\";\ninline bool foo(const char *str) {\n  return !strcmp(s,str);\n}\nint main() {\nint i = 0;\n  while(!(foo(\"\"))) {\n    i ++;\n    s[0] = '\\0';\n    if (i>2)\n     abort ();\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/packed-1.c",
    "content": "short x1 = 17;\n\nstruct\n{\n  short i __attribute__ ((packed));\n} t;\n\nf ()\n{\n  t.i = x1;\n  if (t.i != 17)\n    abort ();\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/packed-2.c",
    "content": "typedef struct s {\n\tunsigned short a;\n\tunsigned long b __attribute__ ((packed));\n} s;\n\ns t;\n\nint main()\n{\n        t.b = 0;\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pending-4.c",
    "content": "\nvoid dummy (x, y)\n     int *x;\n     int y;\n{}\n\nint\nmain (argc, argv)\n     int argc;\n     char **argv;\n{\n  int number_columns=9;\n  int cnt0 = 0;\n  int cnt1 = 0;\n  int i,A1;\n\n  for (i = number_columns-1; i != 0; i--)\n    {         \n      if (i == 1)\n\t{\n\t  dummy(&A1, i);\n\t  cnt0++;\n\t}\n      else\n\t{\n          dummy(&A1, i-1);\n          cnt1++;\n\t}\n    }\n  if (cnt0 != 1 || cnt1 != 7)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/postmod-1.c",
    "content": "#define DECLARE_ARRAY(A) array##A[0x10]\n#define DECLARE_COUNTER(A) counter##A = 0\n#define DECLARE_POINTER(A) *pointer##A = array##A + x\n/* Create a loop that allows post-modification of pointerA, followed by\n   a use of the post-modified address.  */\n#define BEFORE(A) counter##A += *pointer##A, pointer##A += 3\n#define AFTER(A) counter##A += pointer##A[x]\n\n/* Set up the arrays so that one iteration of the loop sets the counter\n   to 3.0f.  */\n#define INIT_ARRAY(A) array##A[1] = 1.0f, array##A[5] = 2.0f\n\n/* Check that the loop worked correctly for all values.  */\n#define CHECK_ARRAY(A) exit_code |= (counter##A != 3.0f)\n\n/* Having 6 copies triggered the bug for ARM and Thumb.  */\n#define MANY(A) A (0), A (1), A (2), A (3), A (4), A (5)\n\n/* Each addendA should be allocated a register.  */\n#define INIT_VOLATILE(A) addend##A = vol\n#define ADD_VOLATILE(A) vol += addend##A\n\n/* Having 5 copies triggered the bug for ARM and Thumb.  */\n#define MANY2(A) A (0), A (1), A (2), A (3), A (4)\n\nfloat MANY (DECLARE_ARRAY);\nfloat MANY (DECLARE_COUNTER);\n\nvolatile int stop = 1;\nvolatile int vol;\n\nvoid __attribute__((noinline))\nfoo (int x)\n{\n  float MANY (DECLARE_POINTER);\n  int i;\n\n  do\n    {\n      MANY (BEFORE);\n      MANY (AFTER);\n      /* Create an inner loop that should ensure the code above\n\t has registers free for reload inheritance.  */\n      {\n\tint MANY2 (INIT_VOLATILE);\n\tfor (i = 0; i < 10; i++)\n\t  MANY2 (ADD_VOLATILE);\n      }\n    }\n  while (!stop);\n}\n\nint\nmain (void)\n{\n  int exit_code = 0;\n\n  MANY (INIT_ARRAY);\n  foo (1);\n  MANY (CHECK_ARRAY);\n  return exit_code;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr15262-1.c",
    "content": "/* PR 15262.\n   The alias analyzer only considers relations between pointers and\n   symbols.  If two pointers P and Q point to the same symbol S, then\n   their respective memory tags will either be the same or they will\n   have S in their alias set.\n   \n   However, if there are no common symbols between P and Q, TBAA will\n   currently miss their alias relationship altogether.  */\nstruct A\n{\n  int t;\n  int i;\n};\n\nint foo () { return 3; }\n\nmain ()\n{\n  struct A loc, *locp;\n  float f, g, *p;\n  int T355, *T356;\n\n  /* Avoid the partial hack in TBAA that would consider memory tags if\n     the program had no addressable symbols.  */\n  f = 3;\n  g = 2;\n  p = foo () ? &g : &f;\n  if (*p > 0.0)\n    g = 1;\n\n  /* Store into *locp and cache its current value.  */\n  locp = malloc (sizeof (*locp));\n  locp->i = 10;\n  T355 = locp->i;\n\n  /* Take the address of one of locp's fields and write to it.  */\n  T356 = &locp->i;\n  *T356 = 1;\n\n  /* Read the recently stored value.  If TBAA fails, this will appear\n     as a redundant load that will be replaced with '10'.  */\n  T355 = locp->i;\n  if (T355 != 1)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr15262-2.c",
    "content": "/* PR 15262.  Similar to pr15262-1.c but with no obvious addresses\n   being taken in function foo().  Without IPA, by only looking inside\n   foo() we cannot tell for certain whether 'q' and 'b' alias each\n   other.  */\nstruct A\n{\n  int t;\n  int i;\n};\n\nstruct B\n{\n  int *p;\n  float b;\n};\n\nfloat X;\n\nfoo (struct B b, struct A *q, float *h)\n{\n  X += *h;\n  *(b.p) = 3;\n  q->t = 2;\n  return *(b.p);\n}\n\nmain()\n{\n  struct A a;\n  struct B b;\n\n  b.p = &a.t;\n  if (foo (b, &a, &X) == 3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr15262.c",
    "content": "/* We used to mis-compile this testcase as we did not know that\n   &a+offsetof(b,a) was the same as &a.b */\nstruct A\n{\n  int t;\n  int i;\n};\n\nvoid\nbar (float *p)\n{\n  *p = 5.2;\n}\n\nint\nfoo(struct A *locp, int i, int str)\n{\n  float f, g, *p;\n  int T355;\n  int *T356;\n  /* Currently, the alias analyzer has limited support for handling\n     aliases of structure fields when no other variables are aliased.\n     Introduce additional aliases to confuse it.  */\n  p =  i ? &g : &f;\n  bar (p);\n  if (*p > 0.0)\n    str = 1;\n\n  T355 = locp->i;\n  T356 = &locp->i;\n  *T356 = str;\n  T355 = locp->i;\n\n  return T355;\n}\n\nmain ()\n{\n  struct A loc;\n  int str;\n\n  loc.i = 2;\n  str = foo (&loc, 10, 3);\n  if (str!=1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr15296.c",
    "content": "/* PR optimization/15296.  The delayed-branch scheduler caused code that\n   SEGV:d for CRIS; a register was set to -1 in a delay-slot for the\n   fall-through code, while that register held a pointer used in code at\n   the branch target.  */\n\ntypedef __INTPTR_TYPE__ intptr_t;\ntypedef intptr_t W;\nunion u0\n{\n  union u0 *r;\n  W i;\n};\nstruct s1\n{\n  union u0 **m0;\n  union u0 m1[4];\n};\n\nvoid f (void *, struct s1 *, const union u0 *, W, W, W)\n     __attribute__ ((__noinline__));\nvoid g (void *, char *) __attribute__ ((__noinline__));\n\nvoid\nf (void *a, struct s1 *b, const union u0 *h, W v0, W v1, W v4)\n{\n  union u0 *e = 0;\n  union u0 *k = 0;\n  union u0 **v5 = b->m0;\n  union u0 *c = b->m1;\n  union u0 **d = &v5[0];\nl0:;\n  if (v0 < v1)\n    goto l0;\n  if (v0 == 0)\n    goto l3;\n  v0 = v4;\n  if (v0 != 0)\n    goto l3;\n  c[0].r = *d;\n  v1 = -1;\n  e = c[0].r;\n  if (e != 0)\n    g (a, \"\");\n  k = e + 3;\n  k->i = v1;\n  goto l4;\nl3:;\n  c[0].i = v0;\n  e = c[1].r;\n  if (e != 0)\n    g (a, \"\");\n  e = c[0].r;\n  if (e == 0)\n    g (a, \"\");\n  k = e + 2;\n  k->r = c[1].r;\nl4:;\n}\n\nvoid g (void *a, char *b) { abort (); }\n\nint\nmain ()\n{\n  union u0 uv[] = {{ .i = 111 }, { .i = 222 }, { .i = 333 }, { .i = 444 }};\n  struct s1 s = { 0, {{ .i = 555 }, { .i = 0 }, { .i = 999 }, { .i = 777 }}};\n  f (0, &s, 0, 20000, 10000, (W) uv);\n  if (s.m1[0].i != (W) uv || s.m1[1].i != 0 || s.m1[2].i != 999\n      || s.m1[3].i != 777 || uv[0].i != 111 || uv[1].i != 222\n      || uv[2].i != 0 || uv[3].i != 444)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr16790-1.c",
    "content": "/* PR middle-end/16790.  */\n\nextern void abort ();\n\nstatic void test1(unsigned int u1)\n{\n  unsigned int y_final_1;\n  signed short y_middle;\n  unsigned int y_final_2;\n\n  y_final_1 = (unsigned int)( (signed short)(u1 * 2) * 3 );\n  y_middle  =                 (signed short)(u1 * 2);\n  y_final_2 = (unsigned int)( y_middle * 3 );\n\n  if (y_final_1 != y_final_2)\n    abort ();\n}\n\n\nstatic void test2(unsigned int u1)\n{\n  unsigned int y_final_1;\n  signed short y_middle;\n  unsigned int y_final_2;\n\n  y_final_1 = (unsigned int)( (signed short)(u1 << 1) * 3 );\n  y_middle  =                 (signed short)(u1 << 1);\n  y_final_2 = (unsigned int)( y_middle * 3 );\n\n  if (y_final_1 != y_final_2)\n    abort ();\n}\n\n\nint main()\n{\n  test1(0x4000U);\n  test2(0x4000U);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr17078-1.c",
    "content": "extern void abort(void);\n\nvoid test(int *ptr)\n{\n  int i = 1;\n  goto useless;\n  if (0)\n    {\n      useless:\n      i = 0;\n    }\n  else\n    i = 1;\n  *ptr = i;\n}\n\nint main()\n{\n  int i = 1;\n  test(&i);\n  if (i)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr17133.c",
    "content": "extern void abort (void);\n\nint foo = 0;\nvoid *bar = 0;\nunsigned int baz = 100;\n\nvoid *pure_alloc ()\n{\n  void *res;\n  \n  while (1)\n    {\n      res = (void *) ((((unsigned int) (foo + bar))) & ~1);\n      foo += 2;\n      if (foo < baz)\n        return res;\n      foo = 0;\n    }\n}\n\nint main ()\n{\n  pure_alloc ();\n  if (!foo)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr17252.c",
    "content": "/* PR 17252.  When a char * pointer P takes its own address, storing\n   into *P changes P itself.  */\n\nchar *a;\n\nmain ()\n{\n  /* Make 'a' point to itself.  */\n  a = (char *)&a;\n\n  /* Change what 'a' is pointing to.  */\n  a[0]++;\n\n  /* If a's memory tag does not contain 'a' in its alias set, we will\n     think that this predicate is superfluous and change it to\n     'if (1)'.  */\n  if (a == (char *)&a)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr17377.c",
    "content": "/* PR target/17377\n   Bug in code emitted by \"return\" pattern on CRIS: missing pop of\n   forced return address on stack.  */\n/* { dg-require-effective-target return_address } */\nint calls = 0;\n\nvoid *f (int) __attribute__ ((__noinline__));\nvoid *\nf (int i)\n{\n  /* The code does a little brittle song and dance to trig the \"return\"\n     pattern instead of the function epilogue.  This must still be a\n     leaf function for the bug to be exposed.  */\n\n  if (calls++ == 0)\n    return __builtin_return_address (0);\n\n  switch (i)\n    {\n    case 1:\n      return f;\n    case 0:\n      return __builtin_return_address (0);\n    }\n  return 0;\n}\n\nint x;\n\nvoid *y (int i) __attribute__ ((__noinline__,__noclone__));\nvoid *\ny (int i)\n{\n  x = 0;\n\n  /* This must not be a sibling call: the return address must appear\n     constant for different calls to this function.  Postincrementing x\n     catches otherwise unidentified multiple returns (e.g. through the\n     return-address register and then this epilogue popping the address\n     stored on stack in \"f\").  */\n  return (char *) f (i) + x++;\n}\n\nint\nmain (void)\n{\n  void *v = y (4);\n  if (y (1) != f\n      /* Can't reasonably check the validity of the return address\n\t above, but it's not that important: the test-case will probably\n\t crash on the first call to f with the bug present, or it will\n\t run wild including returning early (in y or here), so we also\n\t try and check the number of calls.  */\n      || y (0) != v\n      || y (3) != 0\n      || y (-1) != 0\n      || calls != 5)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19005.c",
    "content": "/* PR target/19005 */\nextern void abort (void);\n\nint v, s;\n\nvoid\nbar (int a, int b)\n{\n  unsigned char x = v;\n\n  if (!s)\n    {\n      if (a != x || b != (unsigned char) (x + 1))\n        abort ();\n    }\n  else if (a != (unsigned char) (x + 1) || b != x)\n    abort ();\n  s ^= 1;\n}\n\nint\nfoo (int x)\n{\n  unsigned char a = x, b = x + 1;\n\n  bar (a, b);\n  a ^= b; b ^= a; a ^= b;\n  bar (a, b);\n  return 0;\n}\n\nint\nmain (void)\n{\n  for (v = -10; v < 266; v++)\n    foo (v);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19449.c",
    "content": "/* PR c/19449 */\n\nextern void abort (void);\n\nint y;\nint z = __builtin_choose_expr (!__builtin_constant_p (y), 3, 4);\n\nint\nfoo (int x)\n{\n  return __builtin_choose_expr (!__builtin_constant_p (x), 3, y++);\n}\n\nint\nmain ()\n{\n  if (y || z != 3 || foo (4) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19515.c",
    "content": "/* PR 19515 */\n\ntypedef union {\n      char a2[8];\n}aun;\n\nvoid abort (void);\n\nint main(void)\n{\n  aun a = {{0}};\n\n  if (a.a2[2] != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19606.c",
    "content": "/* PR c/19606\n   The C front end used to shorten the type of a division to a type\n   that does not preserve the semantics of the original computation.\n   Make sure that won't happen.  */\n\nsigned char a = -4;\n\nint\nfoo (void)\n{\n  return ((unsigned int) (signed int) a) / 2LL;\n}\n\nint\nbar (void)\n{\n  return ((unsigned int) (signed int) a) % 5LL;\n}\n\nint\nmain (void)\n{\n  int r;\n\n  r = foo ();\n  if (r != ((unsigned int) (signed int) (signed char) -4) / 2LL)\n    abort ();\n\n  r = bar ();\n  if (r != ((unsigned int) (signed int) (signed char) -4) % 5LL)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19687.c",
    "content": "extern void abort (void);\n\nunion U\n{\n  int i, j[4];\n};\n\nint main ()\n{\n  union U t = {};\n  int i;\n\n  for (i = 0; i < 4; ++i)\n    if (t.j[i] != 0)\n      abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr19689.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort (void);\n\nstruct\n{\n  int b : 29;\n} f;\n\nvoid foo (short j)\n{\n  f.b = j;\n}\n\nint main()\n{\n  foo (-55);\n  if (f.b != -55)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20100-1.c",
    "content": "/* PR tree-optimization/20100\n   Pure function being treated as const.\n   Author: Hans-Peter Nilsson.  */\n\nstatic unsigned short g = 0;\nstatic unsigned short p = 0;\nunsigned char e;\n\nstatic unsigned short\nnext_g (void)\n{\n  return g == e - 1 ? 0 : g + 1;\n}\n\nstatic unsigned short\ncurr_p (void)\n{\n  return p;\n}\n\nstatic unsigned short\ninc_g (void)\n{\n  return g = next_g ();\n}\n\nstatic unsigned short\ncurr_g (void)\n{\n  return g;\n}\n\nstatic char\nring_empty (void)\n{\n  if (curr_p () == curr_g ())\n    return 1;\n  else\n    return 0;\n}\n\nchar\nfrob (unsigned short a, unsigned short b)\n{\n  g = a;\n  p = b;\n  inc_g ();\n  return ring_empty ();\n}\n\nunsigned short\nget_n (void)\n{\n  unsigned short n = 0;\n  unsigned short org_g;\n  org_g = curr_g ();\n  while (!ring_empty () && n < 5)\n    {\n      inc_g ();\n      n++;\n    }\n\n  return n;\n}\n\nvoid abort (void);\nvoid exit (int);\nint main (void)\n{\n  e = 3;\n  if (frob (0, 2) != 0 || g != 1 || p != 2 || e != 3\n      || get_n () != 1\n      || g != 2 || p != 2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20187-1.c",
    "content": "int a = 0x101;\nint b = 0x100;\n\nint\ntest (void)\n{\n  return (((unsigned char) (unsigned long long) ((a ? a : 1) & (a * b)))\n\t  ? 0 : 1);\n}\n\nint\nmain (void)\n{\n  return 1 - test ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20466-1.c",
    "content": "int f (int **, int *, int *, int **, int **) __attribute__ ((__noinline__));\nint\nf (int **ipp, int *i1p, int *i2p, int **i3, int **i4)\n{\n  **ipp = *i1p;\n  *ipp = i2p;\n  *i3 = *i4;\n  **ipp = 99;\n  return 3;\n}\n\nextern void exit (int);\nextern void abort (void);\n\nint main (void)\n{\n  int i = 42, i1 = 66, i2 = 1, i3 = -1, i4 = 55;\n  int *ip = &i;\n  int *i3p = &i3;\n  int *i4p = &i4;\n\n  f (&ip, &i1, &i2, &i3p, &i4p);\n  if (i != 66 || ip != &i2 || i2 != 99 || i3 != -1 || i3p != i4p || i4 != 55)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20527-1.c",
    "content": "/* PR rtl-optimization/20527\n   Mishandled postincrement.  This test-case is derived from the\n   function BZ2_hbCreateDecodeTables in the file huffman.c from\n   bzip2-1.0.2, hence requiring the following disclaimer copied here:  */\n\n/*--\n  This file is a part of bzip2 and/or libbzip2, a program and\n  library for lossless, block-sorting data compression.\n\n  Copyright (C) 1996-2002 Julian R Seward.  All rights reserved.\n\n  Redistribution and use in source and binary forms, with or without\n  modification, are permitted provided that the following conditions\n  are met:\n\n  1. Redistributions of source code must retain the above copyright\n     notice, this list of conditions and the following disclaimer.\n\n  2. The origin of this software must not be misrepresented; you must \n     not claim that you wrote the original software.  If you use this \n     software in a product, an acknowledgment in the product \n     documentation would be appreciated but is not required.\n\n  3. Altered source versions must be plainly marked as such, and must\n     not be misrepresented as being the original software.\n\n  4. The name of the author may not be used to endorse or promote \n     products derived from this software without specific prior written \n     permission.\n\n  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\n  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\n  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n  Julian Seward, Cambridge, UK.\n  jseward@acm.org\n  bzip2/libbzip2 version 1.0 of 21 March 2000\n\n  This program is based on (at least) the work of:\n     Mike Burrows\n     David Wheeler\n     Peter Fenwick\n     Alistair Moffat\n     Radford Neal\n     Ian H. Witten\n     Robert Sedgewick\n     Jon L. Bentley\n\n  For more information on these sources, see the manual.\n--*/\n\nvoid f (long *limit, long *base, long minLen, long maxLen) __attribute__ ((__noinline__));\nvoid f (long *limit, long *base, long minLen, long maxLen)\n{\n  long i;\n  long vec;\n  vec = 0;\n  for (i = minLen; i <= maxLen; i++) {\n    vec += (base[i+1] - base[i]);\n    limit[i] = vec-1;\n  }\n}\nextern void abort (void);\nextern void exit (int);\nlong b[] = {1, 5, 11, 23};\nint main (void)\n{\n  long l[3];\n  f (l, b, 0, 2);\n  if (l[0] != 3 || l[1] != 9 || l[2] != 21)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c",
    "content": "/* PR tree-optimization/20601 */\n/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\nextern void abort (void);\nextern void exit (int);\n\nstruct T\n{\n  char *t1;\n  char t2[4096];\n  char **t3;\n};\n\nint a[5];\nint b;\nchar **c;\nint d;\nchar **e;\nstruct T t;\nchar *f[16];\nchar *g[] = { \"a\", \"-u\", \"b\", \"c\" };\n\n__attribute__ ((__noreturn__)) void\nfoo (void)\n{\n  while (1);\n}\n\n__attribute__ ((noinline)) char *\nbar (char *x, unsigned int y)\n{\n  return 0;\n}\n\nstatic inline char *\nbaz (char *x, unsigned int y)\n{\n  if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2))\n    foo ();\n  return bar (x, y);\n}\n\nstatic inline int\nsetup1 (int x)\n{\n  char *p;\n  int rval;\n\n  if (!baz (t.t2, sizeof (t.t2)))\n    baz (t.t2, sizeof (t.t2));\n\n  if (x & 0x200)\n    {\n      char **h, **i = e;\n\n      ++d;\n      e = f;\n      if (t.t1 && *t.t1)\n        e[0] = t.t1;\n      else\n        abort ();\n\n      for (h = e + 1; (*h = *i); ++i, ++h)\n        ;\n    }\n  return 1;\n}\n\nstatic inline int\nsetup2 (void)\n{\n  int j = 1;\n\n  e = c + 1;\n  d = b - 1;\n  while (d > 0 && e[0][0] == '-')\n    {\n      if (e[0][1] != '\\0' && e[0][2] != '\\0')\n        abort ();\n\n      switch (e[0][1])\n        {\n        case 'u':\n          if (!e[1])\n            abort ();\n\n          t.t3 = &e[1];\n          d--;\n          e++;\n          break;\n        case 'P':\n          j |= 0x1000;\n          break;\n        case '-':\n          d--;\n          e++;\n          if (j == 1)\n            j |= 0x600;\n          return j;\n        }\n      d--;\n      e++;\n    }\n\n  if (d > 0 && !(j & 1))\n    abort ();\n\n  return j;\n}\n\nint\nmain (void)\n{\n  int x;\n  c = g;\n  b = 4;\n  x = setup2 ();\n  t.t1 = \"/bin/sh\";\n  setup1 (x);\n  /* PRE shouldn't transform x into the constant 0x601 here, it's not legal.  */\n  if ((x & 0x400) && !a[4])\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr20621-1.c",
    "content": "/* When generating o32 MIPS PIC, main's $gp save slot was out of range\n   of a single load instruction.  */\nstruct big { int i[sizeof (int) >= 4 && sizeof (void *) >= 4 ? 0x4000 : 4]; };\nstruct big gb;\nint foo (struct big b, int x) { return b.i[x]; }\n#if defined(STACK_SIZE) && STACK_SIZE <= 0x10000\nint main (void) { return 0; }\n#else\nint main (void) { return foo (gb, 0) + foo (gb, 1); }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr21173.c",
    "content": "void abort (void);\n\nchar q;\nvoid *a[2];\n\nvoid foo (char *p)\n{\n  int i;\n  for (i = 0; i < 2; i++)\n    a[i] += p - &q;\n}\n\nint main (void)\n{\n  int i;\n  foo (&q);\n  for (i = 0; i < 2; i ++)\n    if (a[i])\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr21331.c",
    "content": "void abort (void);\n\nint bar (void) {  return -1;  }\n\nunsigned long\nfoo ()\n{ unsigned long retval;\n  retval = bar ();\n  if (retval == -1)  return 0;\n  return 3;  }\n\nmain ()\n{ if (foo () != 0)  abort ();\n  return 0;  }\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr21964-1.c",
    "content": "void\nfoo (int n, int m)\n{\n  if (m == 0)\n    exit (0);\n  else if (n != 0)\n    abort ();\n  else\n    foo (n++, m - 1);\n}\n \nint\nmain (void)\n{\n  foo (0, 4);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22061-1.c",
    "content": "/* { dg-require-effective-target alloca } */\nint N = 1;\nvoid foo() {} /* Necessary to trigger the original ICE.  */\nvoid bar (char a[2][N]) { a[1][0] = N; }\nint\nmain (void)\n{\n  void *x;\n\n  N = 4;\n  x = alloca (2 * N);\n  memset (x, 0, 2 * N);\n  bar (x);\n  if (N[(char *) x] != N)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22061-2.c",
    "content": "int *x;\nstatic void bar (char a[2][(*x)++]) {}\nint\nmain (void)\n{\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22061-3.c",
    "content": "void\nbar (int N)\n{\n  int foo (char a[2][++N]) { N += 4; return sizeof (a[0]); }\n  if (foo (0) != 2)\n    abort ();\n  if (foo (0) != 7)\n    abort ();\n  if (N != 11)\n    abort ();\n}\n\nint\nmain()\n{\n  bar (1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22061-4.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nvoid\nbar (int N)\n{\n  void foo (int a[2][N++]) {}\n  int a[2][N];\n  foo (a);\n  int b[2][N];\n  foo (b);\n  if (sizeof (a) != sizeof (int) * 2 * 1)\n    abort ();\n  if (sizeof (b) != sizeof (int) * 2 * 2)\n    abort ();\n  if (N != 3)\n    abort ();\n}\n\nint\nmain (void)\n{\n  bar (1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, 1, 2}[++a]);\n  if (a != 1 || *p != 1 || *(int *)b != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-2.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, 1, 2}[1]);\n  if (*p != 1 || *(int *)b != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22098-3.c",
    "content": "extern void abort (void);\nextern void exit (int);\ntypedef __UINTPTR_TYPE__ uintptr_t;\nint n = 0;\nint f (void) { return ++n; }\nint\nmain (void)\n{\n  int a = 0;\n  int *p;\n  uintptr_t b;\n  b = (uintptr_t)(p = &(int []){0, f(), 2}[1]);\n  if (*p != 1 || *(int *)b != 1 || n != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22141-1.c",
    "content": "/* PR middle-end/22141 */\n\nextern void abort (void);\n\nstruct S\n{\n  struct T\n    {\n      char a;\n      char b;\n      char c;\n      char d;\n    } t;\n} u;\n\nstruct U\n{\n  struct S s[4];\n};\n\nvoid __attribute__((noinline))\nc1 (struct T *p)\n{\n  if (p->a != 1 || p->b != 2 || p->c != 3 || p->d != 4)\n    abort ();\n  __builtin_memset (p, 0xaa, sizeof (*p));\n}\n\nvoid __attribute__((noinline))\nc2 (struct S *p)\n{\n  c1 (&p->t);\n}\n\nvoid __attribute__((noinline))\nc3 (struct U *p)\n{\n  c2 (&p->s[2]);\n}\n\nvoid __attribute__((noinline))\nf1 (void)\n{\n  u = (struct S) { { 1, 2, 3, 4 } };\n}\n\nvoid __attribute__((noinline))\nf2 (void)\n{\n  u.t.a = 1;\n  u.t.b = 2;\n  u.t.c = 3;\n  u.t.d = 4;\n}\n\nvoid __attribute__((noinline))\nf3 (void)\n{\n  u.t.d = 4;\n  u.t.b = 2;\n  u.t.a = 1;\n  u.t.c = 3;\n}\n\nvoid __attribute__((noinline))\nf4 (void)\n{\n  struct S v;\n  v.t.a = 1;\n  v.t.b = 2;\n  v.t.c = 3;\n  v.t.d = 4;\n  c2 (&v);\n}\n\nvoid __attribute__((noinline))\nf5 (struct S *p)\n{\n  p->t.a = 1;\n  p->t.c = 3;\n  p->t.d = 4;\n  p->t.b = 2;\n}\n\nvoid __attribute__((noinline))\nf6 (void)\n{\n  struct U v;\n  v.s[2].t.a = 1;\n  v.s[2].t.b = 2;\n  v.s[2].t.c = 3;\n  v.s[2].t.d = 4;\n  c3 (&v);\n}\n\nvoid __attribute__((noinline))\nf7 (struct U *p)\n{\n  p->s[2].t.a = 1;\n  p->s[2].t.c = 3;\n  p->s[2].t.d = 4;\n  p->s[2].t.b = 2;\n}\n\nint\nmain (void)\n{\n  struct U w;\n  f1 ();\n  c2 (&u);\n  f2 ();\n  c1 (&u.t);\n  f3 ();\n  c2 (&u);\n  f4 ();\n  f5 (&u);\n  c2 (&u);\n  f6 ();\n  f7 (&w);\n  c3 (&w);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22141-2.c",
    "content": "/* PR middle-end/22141 */\n\nextern void abort (void);\n\nstruct S\n{\n  struct T\n    {\n      char a;\n      char b;\n      char c;\n      char d;\n    } t;\n} u __attribute__((aligned));\n\nstruct U\n{\n  struct S s[4];\n};\n\nvoid __attribute__((noinline))\nc1 (struct T *p)\n{\n  if (p->a != 1 || p->b != 2 || p->c != 3 || p->d != 4)\n    abort ();\n  __builtin_memset (p, 0xaa, sizeof (*p));\n}\n\nvoid __attribute__((noinline))\nc2 (struct S *p)\n{\n  c1 (&p->t);\n}\n\nvoid __attribute__((noinline))\nc3 (struct U *p)\n{\n  c2 (&p->s[2]);\n}\n\nvoid __attribute__((noinline))\nf1 (void)\n{\n  u = (struct S) { { 1, 2, 3, 4 } };\n}\n\nvoid __attribute__((noinline))\nf2 (void)\n{\n  u.t.a = 1;\n  u.t.b = 2;\n  u.t.c = 3;\n  u.t.d = 4;\n}\n\nvoid __attribute__((noinline))\nf3 (void)\n{\n  u.t.d = 4;\n  u.t.b = 2;\n  u.t.a = 1;\n  u.t.c = 3;\n}\n\nvoid __attribute__((noinline))\nf4 (void)\n{\n  struct S v __attribute__((aligned));\n  v.t.a = 1;\n  v.t.b = 2;\n  v.t.c = 3;\n  v.t.d = 4;\n  c2 (&v);\n}\n\nvoid __attribute__((noinline))\nf5 (struct S *p)\n{\n  p->t.a = 1;\n  p->t.c = 3;\n  p->t.d = 4;\n  p->t.b = 2;\n}\n\nvoid __attribute__((noinline))\nf6 (void)\n{\n  struct U v __attribute__((aligned));\n  v.s[2].t.a = 1;\n  v.s[2].t.b = 2;\n  v.s[2].t.c = 3;\n  v.s[2].t.d = 4;\n  c3 (&v);\n}\n\nvoid __attribute__((noinline))\nf7 (struct U *p)\n{\n  p->s[2].t.a = 1;\n  p->s[2].t.c = 3;\n  p->s[2].t.d = 4;\n  p->s[2].t.b = 2;\n}\n\nint\nmain (void)\n{\n  struct U w __attribute__((aligned));\n  f1 ();\n  c2 (&u);\n  f2 ();\n  c1 (&u.t);\n  f3 ();\n  c2 (&u);\n  f4 ();\n  f5 (&u);\n  c2 (&u);\n  f6 ();\n  f7 (&w);\n  c3 (&w);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22348.c",
    "content": "void abort (void);\nvoid f(int i)\n{\n  if (i>4 + 3 * 16)\n    abort();\n}\n\nint main()\n{\n  unsigned int buflen, i;\n  buflen = 4 + 3 * 16;\n  for (i = 4; i < buflen; i+= 3)\n    f(i);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22429.c",
    "content": "extern void abort (void);\n\n#define N\t(1 << (sizeof(int) * __CHAR_BIT__ - 2))\n\nint f(int n)\n{\n  if (-N <= n && n <= N-1)\n    return 1;\n  return 0;\n}\n\nint main ()\n{\n  if (f (N))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22493-1.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n\n#include <limits.h>\nextern void abort ();\nextern void exit (int);\nvoid f(int i)\n{\n  if (i>0)\n    abort();\n  i = -i;\n  if (i<0)\n    return;\n  abort ();\n}\n\nint main(int argc, char *argv[])\n{\n  f(INT_MIN);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr22630.c",
    "content": "void abort (void);\n\nint j;\n\nvoid bla (int *r)\n{\n  int *p, *q;\n\n  p = q = r;\n  if (!p)\n    p = &j;\n  \n  if (p != q)\n    j = 1;\n}\n\nint main (void)\n{\n  bla (0);\n  if (!j)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23047.c",
    "content": "/* { dg-options \"-fwrapv\" } */\n#include <limits.h>\nextern void abort ();\nextern void exit (int);\nvoid f(int i)\n{\n  i = i > 0 ? i : -i;\n  if (i<0)\n    return;\n  abort ();\n}\n\nint main(int argc, char *argv[])\n{\n  f(INT_MIN);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23135.c",
    "content": "/* Based on execute/simd-1.c, modified by joern.rennecke@st.com to\n   trigger a reload bug.  Verified for gcc mainline from 20050722 13:00 UTC\n   for sh-elf -m4 -O2.  */\n/* { dg-options \"-Wno-psabi\" } */\n\n#ifndef STACK_SIZE\n#define STACK_SIZE (256*1024)\n#endif\n\nextern void abort (void);\nextern void exit (int);\n\ntypedef struct { char c[STACK_SIZE/2]; } big_t;\n\ntypedef int __attribute__((mode(SI))) __attribute__((vector_size (8))) vecint;\ntypedef int __attribute__((mode(SI))) siint;\n\nvecint i = { 150, 100 };\nvecint j = { 10, 13 };\nvecint k;\n\nunion {\n  vecint v;\n  siint i[2];\n} res;\n\nvoid\nverify (siint a1, siint a2, siint b1, siint b2, big_t big)\n{\n  if (a1 != b1\n      || a2 != b2)\n    abort ();\n}\n\nint\nmain ()\n{\n  big_t big;\n  vecint k0, k1, k2, k3, k4, k5, k6, k7;\n\n  k0 = i + j;\n  res.v = k0;\n\n  verify (res.i[0], res.i[1], 160, 113, big);\n\n  k1 = i * j;\n  res.v = k1;\n\n  verify (res.i[0], res.i[1], 1500, 1300, big);\n\n  k2 = i / j;\n/* This is the observed failure - reload 0 has the wrong type and thus the\n   conflict with reload 1 is missed:\n\n(insn:HI 94 92 96 1 pr23135.c:46 (parallel [\n            (set (subreg:SI (reg:DI 253) 0)\n                (div:SI (reg:SI 4 r4)\n                    (reg:SI 5 r5)))\n            (clobber (reg:SI 146 pr))\n            (clobber (reg:DF 64 fr0))\n            (clobber (reg:DF 66 fr2))\n            (use (reg:PSI 151 ))\n            (use (reg/f:SI 256))\n        ]) 60 {divsi3_i4} (insn_list:REG_DEP_TRUE 90 (insn_list:REG_DEP_TRUE 89\n(insn_list:REG_DEP_TRUE 42 (insn_list:REG_DEP_TRUE 83 (insn_list:REG_DEP_TRUE 92\n (insn_list:REG_DEP_TRUE 91 (nil)))))))\n    (expr_list:REG_DEAD (reg:SI 4 r4)\n        (expr_list:REG_DEAD (reg:SI 5 r5)\n            (expr_list:REG_UNUSED (reg:DF 66 fr2)\n                (expr_list:REG_UNUSED (reg:DF 64 fr0)\n                    (expr_list:REG_UNUSED (reg:SI 146 pr)\n                        (insn_list:REG_RETVAL 91 (nil))))))))\n\nReloads for insn # 94\nReload 0: reload_in (SI) = (plus:SI (reg/f:SI 14 r14)\n                                                    (const_int 64 [0x40]))\n        GENERAL_REGS, RELOAD_FOR_OUTADDR_ADDRESS (opnum = 0)\n        reload_in_reg: (plus:SI (reg/f:SI 14 r14)\n                                                    (const_int 64 [0x40]))\n        reload_reg_rtx: (reg:SI 3 r3)\nReload 1: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, se\ncondary_reload_p\n        reload_reg_rtx: (reg:SI 3 r3)\nReload 2: reload_out (SI) = (mem:SI (plus:SI (plus:SI (reg/f:SI 14 r14)\n                                                            (const_int 64 [0x40]))\n                                                        (const_int 28 [0x1c])) [ 16 S8 A32])\n        FPUL_REGS, RELOAD_FOR_OUTPUT (opnum = 0)\n        reload_out_reg: (subreg:SI (reg:DI 253) 0)\n        reload_reg_rtx: (reg:SI 150 fpul)\n        secondary_out_reload = 1\n\nReload 3: reload_in (SI) = (symbol_ref:SI (\"__sdivsi3_i4\") [flags 0x1])\n        GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine\n        reload_in_reg: (reg/f:SI 256)\n        reload_reg_rtx: (reg:SI 3 r3)\n  */\n\n\n  res.v = k2;\n\n  verify (res.i[0], res.i[1], 15, 7, big);\n\n  k3 = i & j;\n  res.v = k3;\n\n  verify (res.i[0], res.i[1], 2, 4, big);\n\n  k4 = i | j;\n  res.v = k4;\n\n  verify (res.i[0], res.i[1], 158, 109, big);\n\n  k5 = i ^ j;\n  res.v = k5;\n\n  verify (res.i[0], res.i[1], 156, 105, big);\n\n  k6 = -i;\n  res.v = k6;\n  verify (res.i[0], res.i[1], -150, -100, big);\n\n  k7 = ~i;\n  res.v = k7;\n  verify (res.i[0], res.i[1], -151, -101, big);\n\n  k = k0 + k1 + k3 + k4 + k5 + k6 + k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 1675, 1430, big);\n\n  k = k0 * k1 * k3 * k4 * k5 * k6 * k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 1456467968, -1579586240, big);\n\n  k = k0 / k1 / k2 / k3 / k4 / k5 / k6 / k7;\n  res.v = k;\n  verify (res.i[0], res.i[1], 0, 0, big);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23324.c",
    "content": "extern void abort (void);\n#define A(x) if (!(x)) abort ()\n\nstatic union at6 {} vv6 = {};\nstatic struct et6\n{\n  struct bt6\n  {\n    signed av6:6;\n    signed bv6:7;\n    signed cv6:6;\n    signed dv6:5;\n    unsigned char ev6;\n    unsigned int fv6;\n    long int gv6;\n  } mv6;\n  unsigned long int nv6;\n  signed ov6:12;\n  signed pv6:3;\n  signed qv6:2;\n  signed rv6:10;\n  union ct6 { long int hv6; float iv6; float jv6; } sv6;\n  int *tv6;\n  union dt6 { double kv6; float lv6; } uv6;\n} wv6 = {\n  { 8, 9, 2, 4, '\\x10', 67426805U, 1047191860L },\n  1366022414UL, 858, 1, 1, 305,\n  { 1069379046L }, (int *) 358273621U,\n  { 3318.041978 }\n};\nstatic double xv6 = 19239.101269;\nstatic long long int yv6 = 1207859169L;\nstatic int zv6 = 660195606;\n\nstatic union at6\ncallee_af6 (struct et6 ap6, double bp6, long long int cp6, int dp6)\n{\n  A (wv6.mv6.av6 == ap6.mv6.av6);\n  A (wv6.mv6.bv6 == ap6.mv6.bv6);\n  A (wv6.mv6.cv6 == ap6.mv6.cv6);\n  A (wv6.mv6.dv6 == ap6.mv6.dv6);\n  A (wv6.mv6.ev6 == ap6.mv6.ev6);\n  A (wv6.mv6.fv6 == ap6.mv6.fv6);\n  A (wv6.mv6.gv6 == ap6.mv6.gv6);\n  A (wv6.nv6 == ap6.nv6);\n  A (wv6.ov6 == ap6.ov6);\n  A (wv6.pv6 == ap6.pv6);\n  A (wv6.qv6 == ap6.qv6);\n  A (wv6.rv6 == ap6.rv6);\n  A (wv6.sv6.hv6 == ap6.sv6.hv6);\n  A (wv6.tv6 == ap6.tv6);\n  A (wv6.uv6.kv6 == ap6.uv6.kv6);\n  A (xv6 == bp6);\n  A (yv6 == cp6);\n  A (zv6 == dp6);\n  return vv6;\n}\n\nstatic void\ncaller_bf6 (void)\n{\n  union at6 bav6;\n  bav6 = callee_af6 (wv6, xv6, yv6, zv6);\n}\n\nstatic unsigned char uv7 = '\\x46';\nstatic float vv7 = 96636.982442;\nstatic double wv7 = 28450.711801;\nstatic union ct7 {} xv7 = {};\nstatic struct et7\n{\n  struct dt7\n  {\n    float iv7;\n    unsigned short int jv7;\n  } kv7;\n  float lv7[0];\n  signed mv7:9;\n  short int nv7;\n  double ov7;\n  float pv7;\n} yv7 = {\n  { 30135.996213, 42435 },\n  {}, 170, 22116, 26479.628148, 4082.960685\n};\nstatic union ft7\n{\n  float qv7;\n  float *rv7;\n  unsigned int *sv7;\n} zv7 = { 5042.227886 };\nstatic int bav7 = 1345451862;\nstatic struct gt7 { double tv7; } bbv7 = { 47875.491954 };\nstatic long int bcv7[1] = { 1732133482L };\nstatic long long int bdv7 = 381678602L;\n\nstatic unsigned char\ncallee_af7 (float ap7, double bp7, union ct7 cp7, struct et7 dp7,\n            union ft7 ep7, int fp7, struct gt7 gp7, long int hp7[1],\n            long long int ip7)\n{\n  A (vv7 == ap7);\n  A (wv7 == bp7);\n  A (yv7.kv7.iv7 == dp7.kv7.iv7);\n  A (yv7.kv7.jv7 == dp7.kv7.jv7);\n  A (yv7.mv7 == dp7.mv7);\n  A (yv7.nv7 == dp7.nv7);\n  A (yv7.ov7 == dp7.ov7);\n  A (yv7.pv7 == dp7.pv7);\n  A (zv7.qv7 == ep7.qv7);\n  A (bav7 == fp7);\n  A (bbv7.tv7 == gp7.tv7);\n  A (bcv7[0] == hp7[0]);\n  A (bdv7 == ip7);\n  return uv7;\n}\n\nstatic void\ncaller_bf7 (void)\n{\n  unsigned char bev7;\n\n  bev7 = callee_af7 (vv7, wv7, xv7, yv7, zv7, bav7, bbv7, bcv7, bdv7);\n  A (uv7 == bev7);\n}\n\nint\nmain ()\n{\n  caller_bf6 ();\n  caller_bf7 ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23467.c",
    "content": "struct s1\n{\n  int __attribute__ ((aligned (8))) a;\n};\n\nstruct\n{\n  char c;\n  struct s1 m;\n} v;\n\nint\nmain (void)\n{\n  if ((int)&v.m & 7)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23604.c",
    "content": "extern void abort (void);\n\nint g(int i, int j)\n{\n  if (i>-1)\n    if (i<2)\n     {\n        if (i != j)\n          {\n            if (j != 0)\n                return 0;\n          }\n     }\n  return 1;\n}\n\nint main(void)\n{\n  if (!g(1, 0))\n   abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr23941.c",
    "content": "extern void abort (void);\ndouble d = __FLT_MIN__ / 2.0;\nint main()\n{\n  double x = __FLT_MIN__ / 2.0;\n  if (x != d)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr24135.c",
    "content": "#ifndef NO_TRAMPOLINES\nextern void abort (void);\n\nint x(int a, int b)\n{\n  __label__ xlab;\n  __label__ xlab2;\n\n  void y(int b)\n    {\n       switch (b)\n        {\n          case 1: goto xlab;\n          case 2: goto xlab;\n        }\n    }\n\n  a = a + 2;\n  y (b);\n\n xlab:\n  return a;\n\n xlab2:\n  a++;\n  return a;\n\n}\n\nint main ()\n{\n  int i, j;\n\n  for (j = 1; j <= 2; ++j)\n    for (i = 1; i <= 2; ++i)\n      {\n\tint a = x (j, i);\n\tif (a != 2 + j)\n\t  abort ();\n      }\n\n  return 0;\n}\n#else\nint main() { return 0; }\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr24141.c",
    "content": "// reduced testcase, compile with -O2. Also, with --disable-checking\n// gcc produces wrong code.\n\nvoid abort (void);\nint i;\n\nvoid g (void)\n{\n  i = 1;\n}\n\nvoid f (int a, int b)\n{\n  int c = 0;\n  if (a == 0)\n    c = 1;\n  if (c)\n    return;\n  if (c == 1)\n    c = 0;\n  if (b == 0)\n    c = 1;\n  if (c)\n    g ();\n}\n\nint main (void)\n{\n  f (1, 0);\n  if (i != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr24142.c",
    "content": "void abort (void);\n\nint f (int a, int b)\n{\n  if (a == 1)\n    a = 0;\n  if (b == 0)\n    a = 1;\n  if (a != 0)\n    return 0;\n  return 1;\n}\n\nint main (void)\n{\n  if (f (1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr24716.c",
    "content": "/* PR24716, scalar evolution returning the wrong result\n   for pdest.  */\n\nint Link[] = { -1 };\nint W[] = { 2 };\n\nextern void abort (void);\n\nint f (int k, int p)\n{\n  int pdest, j, D1361;\n  j = 0;\n  pdest = 0;\n  for (;;) {\n    if (pdest > 2)\n      do\n        j--, pdest++;\n      while (j > 2);\n\n    if (j == 1)\n      break;\n\n    while (pdest > p)\n      if (j == p)\n        pdest++;\n\n    do\n      {\n        D1361 = W[k];\n        do\n          if (D1361 != 0)\n            pdest = 1, W[k] = D1361 = 0;\n        while (p < 1);\n    } while (k > 0);\n\n    do\n      {\n        p = 0;\n        k = Link[k];\n        while (p < j)\n          if (k != -1)\n            pdest++, p++;\n      }\n    while (k != -1);\n    j = 1;\n  }\n\n  /* The correct return value should be pdest (1 in the call from main).\n     DOM3 is mistaken and propagates a 0 here.  */\n  return pdest;\n}\n\nint main ()\n{\n  if (!f (0, 2))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr24851.c",
    "content": "/* We used to handle pointer addition wrongly\n   at the time of recombining to an ARRAY_REF\n   in the case of\n     p + -4B\n   where -4B is represented as unsigned.  */\n\nvoid abort(void);\nint main()\n{\n  int a[10], *p, *q;\n  q = &a[1];\n  p = &q[-1];\n  if (p >= &a[9])\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr25125.c",
    "content": "extern void exit (int);\nextern void abort (void);\nextern unsigned short f (short a) __attribute__((__noinline__));\n\nunsigned short\nf (short a)\n{\n  short b;\n\n  if (a > 0)\n    return 0;\n  b = ((int) a) + - (int) 32768;\n  return b;\n}\n\nint\nmain (void)\n{\n  if (sizeof (short) < 2\n      || sizeof (short) >= sizeof (int))\n    exit (0);\n\n  if (f (-32767) != 1)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr25737.c",
    "content": "extern void abort (void);\n\nstruct delay_block {\n  struct delay_block *succ;\n};\n\nstatic struct delay_block Timer_Queue;\n\nstruct delay_block* time_enqueue (struct delay_block *d)\n{\n  struct delay_block *q = Timer_Queue.succ; \n  d->succ =  (void *)0;\n  return Timer_Queue.succ;\n}\n\nint main(void)\n{\n  Timer_Queue.succ = &Timer_Queue;\n  if (time_enqueue (&Timer_Queue) != (void*)0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr27073.c",
    "content": "void __attribute__((noinline))\nfoo (int *p, int d1, int d2, int d3,\n     short count, int s1, int s2, int s3, int s4, int s5)\n{\n  int n = count;\n  while (n--)\n    {\n      *p++ = s1;\n      *p++ = s2;\n      *p++ = s3;\n      *p++ = s4;\n      *p++ = s5;\n    }\n}\n\nint main()\n{\n  int x[10], i;\n\n  foo (x, 0, 0, 0, 2, 100, 200, 300, 400, 500);\n  for (i = 0; i < 10; i++)\n    if (x[i] != (i % 5 + 1) * 100)\n      abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr27260.c",
    "content": "/* PR middle-end/27260 */\n\nextern void abort (void);\nextern void *memset (void *, int, __SIZE_TYPE__);\n\nchar buf[65];\n\nvoid\nfoo (int x)\n{\n  memset (buf, x != 2 ? 1 : 0, 64);\n}\n\nint\nmain (void)\n{\n  int i;\n  buf[64] = 2;\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 0)\n      abort ();\n  foo (0);\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 1)\n      abort ();\n  foo (2);\n  for (i = 0; i < 64; i++)\n    if (buf[i] != 0)\n      abort ();\n  if (buf[64] != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr27285.c",
    "content": "/* PR tree-optimization/27285 */\n\nextern void abort (void);\n\nstruct S { unsigned char a, b, c, d[16]; };\n\nvoid __attribute__ ((noinline))\nfoo (struct S *x, struct S *y)\n{\n  int a, b;\n  unsigned char c, *d, *e;\n\n  b = x->b;\n  d = x->d;\n  e = y->d;\n  a = 0;\n  while (b)\n    {\n      if (b >= 8)\n\t{\n\t  c = 0xff;\n\t  b -= 8;\n\t}\n      else\n\t{\n\t  c = 0xff << (8 - b);\n\t  b = 0;\n\t}\n\n      e[a] = d[a] & c;\n      a++;\n    }\n}\n\nint\nmain (void)\n{\n  struct S x = { 0, 25, 0, { 0xaa, 0xbb, 0xcc, 0xdd }};\n  struct S y = { 0, 0, 0, { 0 }};\n\n  foo (&x, &y);\n  if (x.d[0] != y.d[0] || x.d[1] != y.d[1]\n      || x.d[2] != y.d[2] || (x.d[3] & 0x80) != y.d[3])\n    abort ();\n   return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr27364.c",
    "content": "int f(unsigned number_of_digits_to_use)\n{\n  if (number_of_digits_to_use >1294)\n    return 0;\n  return (number_of_digits_to_use * 3321928 / 1000000 + 1) /16;\n}\n\nint main(void)\n{\n  if (f(11) != 2)\n    __builtin_abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c",
    "content": "/* PR rtl-optimization/27671.\n   The combiner used to simplify \"a ^ b == a\" to \"a\" via\n   simplify_relational_operation_1 in simplify-rtx.c.  */\n\nextern void abort (void) __attribute__ ((noreturn));\nextern void exit (int) __attribute__ ((noreturn));\n\nstatic int __attribute__((noinline))\nfoo (int a, int b)\n{\n  int c = a ^ b;\n  if (c == a)\n    abort ();\n}\n\nint\nmain (void)\n{\n  foo (0, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28289.c",
    "content": "extern int ok (int);\nextern void exit ();\nstatic int gen_x86_64_shrd (int);\nstatic int\ngen_x86_64_shrd(int a __attribute__ ((__unused__)))\n{\n  return 0;\n}\n\nextern int gen_x86_shrd_1 (int);\nextern void ix86_split_ashr (int);\n\nvoid\nix86_split_ashr (int mode)\n{\n          (mode != 0\n                      ? ok\n                      : gen_x86_64_shrd) (0);\n}\n\nvolatile int one = 1;\nint\nmain (void)\n{\n  ix86_split_ashr (one);\n  return 1;\n}\n\nint\nok (int i)\n{\n  exit (i);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28403.c",
    "content": "typedef unsigned long long ull;\nint global;\n\nint __attribute__((noinline))\nfoo (int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8)\n{\n  global = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8;\n}\n\null __attribute__((noinline))\nbar (ull x)\n{\n  foo (1, 2, 1, 3, 1, 4, 1, 5);\n  return x >> global;\n}\n\nint\nmain (void)\n{\n  if (bar (0x123456789abcdefULL) != (0x123456789abcdefULL >> 18))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28651.c",
    "content": "#include <limits.h>\n\nextern void abort (void);\nint __attribute__((noinline))\nfoo (unsigned int u)\n{\n  return (int)(u + 4) < (int)u;\n}\n\nint\nmain (int argc, char *argv[])\n{\n  unsigned int u = INT_MAX;\n\n  if (foo (u) == 0)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28778.c",
    "content": "extern void abort(void);\ntypedef long GLint;\nvoid aglChoosePixelFormat (const GLint *);\n\nvoid\nfind (const int *alistp)\n{\n  const int *blist;\n  int list[32];\n  if (alistp)\n    blist = alistp;\n  else\n    {\n      list[3] = 42;\n      blist = list;\n    }\n  aglChoosePixelFormat ((GLint *) blist);\n}\n\nvoid\naglChoosePixelFormat (const GLint * a)\n{\n  int *b = (int *) a;\n  if (b[3] != 42)\n    abort ();\n}\n\nint\nmain (void)\n{\n  find (0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28865.c",
    "content": "struct A { int a; char b[]; };\nunion B { struct A a; char b[sizeof (struct A) + 31]; };\nunion B b = { { 1, \"123456789012345678901234567890\" } };\nunion B c = { { 2, \"123456789012345678901234567890\" } };\n\n__attribute__((noinline, noclone)) void\nfoo (int *x[2])\n{\n  x[0] = &b.a.a;\n  x[1] = &c.a.a;\n}\n\nint\nmain ()\n{\n  int *x[2];\n  foo (x);\n  if (*x[0] != 1 || *x[1] != 2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28982a.c",
    "content": "/* PR rtl-optimization/28982.  Function foo() does the equivalent of:\n\n     float tmp_results[NVARS];\n     for (int i = 0; i < NVARS; i++)\n       {\n\t int inc = incs[i];\n\t float *ptr = ptrs[i], result = 0;\n\t for (int j = 0; j < n; j++)\n\t   result += *ptr, ptr += inc;\n\t tmp_results[i] = result;\n       }\n     memcpy (results, tmp_results, sizeof (results));\n\n   but without the outermost loop.  The idea is to create high register\n   pressure and ensure that some INC and PTR variables are spilled.\n\n   On ARM targets, sequences like \"result += *ptr, ptr += inc\" can\n   usually be implemented using (mem (post_modify ...)), and we do\n   indeed create such MEMs before reload for this testcase.  However,\n   (post_modify ...) is not a valid address for coprocessor loads, so\n   for -mfloat-abi=softfp, reload reloads the POST_MODIFY into a base\n   register.  GCC did not deal correctly with cases where the base and\n   index of the POST_MODIFY are themselves reloaded.  */\n#define NITER 4\n#define NVARS 20\n#define MULTI(X) \\\n  X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \\\n  X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)\n\n#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]\n#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0\n#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX\n#define COPYOUT(INDEX) results[INDEX] = result##INDEX\n\nfloat *ptrs[NVARS];\nfloat results[NVARS];\nint incs[NVARS];\n\nvoid __attribute__((noinline))\nfoo (int n)\n{\n  int MULTI (DECLAREI);\n  float MULTI (DECLAREF);\n  while (n--)\n    MULTI (LOOP);\n  MULTI (COPYOUT);\n}\n\nfloat input[NITER * NVARS];\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NVARS; i++)\n    ptrs[i] = input + i, incs[i] = i;\n  for (i = 0; i < NITER * NVARS; i++)\n    input[i] = i;\n  foo (NITER);\n  for (i = 0; i < NVARS; i++)\n    if (results[i] != i * NITER * (NITER + 1) / 2)\n      return 1;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr28982b.c",
    "content": "/* Like pr28982a.c, but with the spill slots outside the range of\n   a single sp-based load on ARM.  This test tests for cases where\n   the addresses in the base and index reloads require further reloads.  */\n#if defined(STACK_SIZE) && STACK_SIZE <= 0x80100\nint main (void) { return 0; }\n#else\n#define NITER 4\n#define NVARS 20\n#define MULTI(X) \\\n  X( 0), X( 1), X( 2), X( 3), X( 4), X( 5), X( 6), X( 7), X( 8), X( 9), \\\n  X(10), X(11), X(12), X(13), X(14), X(15), X(16), X(17), X(18), X(19)\n\n#define DECLAREI(INDEX) inc##INDEX = incs[INDEX]\n#define DECLAREF(INDEX) *ptr##INDEX = ptrs[INDEX], result##INDEX = 0\n#define LOOP(INDEX) result##INDEX += *ptr##INDEX, ptr##INDEX += inc##INDEX\n#define COPYOUT(INDEX) results[INDEX] = result##INDEX\n\nfloat *ptrs[NVARS];\nfloat results[NVARS];\nint incs[NVARS];\n\nstruct big { int i[0x10000]; };\nvoid __attribute__((noinline))\nbar (struct big b)\n{\n  incs[0] += b.i[0];\n}\n\nvoid __attribute__((noinline))\nfoo (int n)\n{\n  struct big b = {};\n  int MULTI (DECLAREI);\n  float MULTI (DECLAREF);\n  while (n--)\n    MULTI (LOOP);\n  MULTI (COPYOUT);\n  bar (b);\n}\n\nfloat input[NITER * NVARS];\n\nint\nmain (void)\n{\n  int i;\n\n  for (i = 0; i < NVARS; i++)\n    ptrs[i] = input + i, incs[i] = i;\n  for (i = 0; i < NITER * NVARS; i++)\n    input[i] = i;\n  foo (NITER);\n  for (i = 0; i < NVARS; i++)\n    if (results[i] != i * NITER * (NITER + 1) / 2)\n      return 1;\n  return 0;\n}\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29006.c",
    "content": "struct __attribute__((__packed__)) s { char c; unsigned long long x; };\nvoid __attribute__((__noinline__)) foo (struct s *s) { s->x = 0; }\nint main (void) { struct s s = { 1, ~0ULL }; foo (&s); return s.x != 0; }\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29156.c",
    "content": "extern void abort(void);\nstruct test1\n{\n  int a;\n  int b;\n};\nstruct test2\n{\n  float d;\n  struct test1 sub;\n};\n\nint global;\n\nint bla(struct test1 *xa, struct test2 *xb)\n{\n  global = 1;\n  xb->sub.a = 1;\n  xa->a = 8;\n  return xb->sub.a;\n}\n\nint main(void)\n{\n  struct test2 pom;\n\n  if (bla (&pom.sub, &pom) != 8)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29695-1.c",
    "content": "/* PR middle-end/29695 */\n\nextern void abort (void);\n\nint\nf1 (void)\n{\n  int a = 128;\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf2 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf3 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? 0x380 : 0;\n}\n\nint\nf4 (void)\n{\n  unsigned char a = 128;\n  return (a & 0x80) ? -128 : 0;\n}\n\nlong long\nf5 (void)\n{\n  long long a = 0x80000000LL;\n  return (a & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf6 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf7 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? 0x380000000LL : 0LL;\n}\n\nlong long\nf8 (void)\n{\n  unsigned int a = 0x80000000;\n  return (a & 0x80000000) ? -2147483648LL : 0LL;\n}\n\nint\nmain (void)\n{\n  if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)\n    return 0;\n  if (f1 () != 128)\n    abort ();\n  if (f2 () != 128)\n    abort ();\n  if (f3 () != 896)\n    abort ();\n  if (f4 () != -128)\n    abort ();\n  if (f5 () != 0x80000000LL)\n    abort ();\n  if (f6 () != 0x80000000LL)\n    abort ();\n  if (f7 () != 0x380000000LL)\n    abort ();\n  if (f8 () != -2147483648LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29695-2.c",
    "content": "/* PR middle-end/29695 */\n\nextern void abort (void);\n\nint a = 128;\nunsigned char b = 128;\nlong long c = 0x80000000LL;\nunsigned int d = 0x80000000;\n\nint\nf1 (void)\n{\n  return (a & 0x80) ? 0x80 : 0;\n}\n\nint\nf2 (void)\n{\n  return (b & 0x80) ? 0x80 : 0;\n}\n\nint\nf3 (void)\n{\n  return (b & 0x80) ? 0x380 : 0;\n}\n\nint\nf4 (void)\n{\n  return (b & 0x80) ? -128 : 0;\n}\n\nlong long\nf5 (void)\n{\n  return (c & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf6 (void)\n{\n  return (d & 0x80000000) ? 0x80000000LL : 0LL;\n}\n\nlong long\nf7 (void)\n{\n  return (d & 0x80000000) ? 0x380000000LL : 0LL;\n}\n\nlong long\nf8 (void)\n{\n  return (d & 0x80000000) ? -2147483648LL : 0LL;\n}\n\nint\nmain (void)\n{\n  if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)\n    return 0;\n  if (f1 () != 128)\n    abort ();\n  if (f2 () != 128)\n    abort ();\n  if (f3 () != 896)\n    abort ();\n  if (f4 () != -128)\n    abort ();\n  if (f5 () != 0x80000000LL)\n    abort ();\n  if (f6 () != 0x80000000LL)\n    abort ();\n  if (f7 () != 0x380000000LL)\n    abort ();\n  if (f8 () != -2147483648LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29797-1.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void abort(void);\n\nunsigned int bar(void) { return 32768; }\n\nint main()\n{\n  unsigned int nStyle = bar ();\n  if (nStyle & 32768)\n    nStyle |= 65536;\n  if (nStyle != (32768 | 65536))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29797-2.c",
    "content": "extern void abort(void);\n\nunsigned long bar(void) { return 32768; }\n\nint main()\n{\n  unsigned long nStyle = bar ();\n  if (nStyle & 32768)\n    nStyle |= 65536;\n  if (nStyle != (32768 | 65536))\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr29798.c",
    "content": "extern void abort ();\n\nint\nmain ()\n{\n  int i;\n  double oldrho;\n  double beta = 0.0;\n  double work = 1.0;\n  for (i = 1; i <= 2; i++)\n    {\n      double rho = work * work;\n      if (i != 1)\n        beta = rho / oldrho;\n      if (beta == 1.0)\n        abort ();\n\n      /* All targets even remotely likely to ever get supported\n\t use at least an even base, so there will never be any\n\t floating-point rounding. All computation in this test\n\t case is exact for even bases.  */\n      work /= 2.0;\n      oldrho = rho;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr30185.c",
    "content": "/* PR target/30185 */\n\nextern void abort (void);\n\ntypedef struct S { char a; long long b; } S;\n\nS\nfoo (S x, S y)\n{\n  S z;\n  z.b = x.b / y.b;\n  return z;\n}\n\nint\nmain (void)\n{\n  S a, b;\n  a.b = 32LL;\n  b.b = 4LL;\n  if (foo (a, b).b != 8LL)\n    abort ();\n  a.b = -8LL;\n  b.b = -2LL;\n  if (foo (a, b).b != 4LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr30778.c",
    "content": "extern void *memset (void *, int, __SIZE_TYPE__);\nextern void abort (void);\n\nstruct reg_stat {\n  void *last_death;\n  void *last_set;\n  void *last_set_value;\n  int   last_set_label;\n  char  last_set_sign_bit_copies;\n  int   last_set_mode : 8;\n  char  last_set_invalid;\n  char sign_bit_copies;\n  long nonzero_bits;\n};\n\nstatic struct reg_stat *reg_stat;\n\nvoid __attribute__((noinline))\ninit_reg_last (void)\n{\n  memset (reg_stat, 0, __builtin_offsetof (struct reg_stat, sign_bit_copies));\n}\n\nint main (void)\n{\n  struct reg_stat r;\n\n  reg_stat = &r;\n  r.nonzero_bits = -1;\n  init_reg_last ();\n  if (r.nonzero_bits != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31072.c",
    "content": "extern volatile int ReadyFlag_NotProperlyInitialized;\n\nvolatile int ReadyFlag_NotProperlyInitialized=1;\n\nint main(void)\n{\n  if (ReadyFlag_NotProperlyInitialized != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31136.c",
    "content": "extern void abort (void);\n\nstruct S {\n  unsigned b4:4;\n  unsigned b6:6;\n} s;\n\nint main()\n{\n  s.b6 = 31;\n  s.b4 = s.b6;\n  s.b6 = s.b4;\n  if (s.b6 != 15)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31169.c",
    "content": "extern void abort();\n\n#define HOST_WIDE_INT long\n#define HOST_BITS_PER_WIDE_INT (sizeof(long)*8)\n\nstruct tree_type\n{\n  unsigned int precision : 9;\n};\n\nint\nsign_bit_p (struct tree_type *t, HOST_WIDE_INT val_hi, unsigned HOST_WIDE_INT val_lo)\n{\n  unsigned HOST_WIDE_INT mask_lo, lo;\n  HOST_WIDE_INT mask_hi, hi;\n  int width = t->precision;\n\n  if (width > HOST_BITS_PER_WIDE_INT)\n    {\n      hi = (unsigned HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT - 1);\n      lo = 0;\n\n      mask_hi = ((unsigned HOST_WIDE_INT) -1\n                 >> (2 * HOST_BITS_PER_WIDE_INT - width));\n      mask_lo = -1;\n    }\n  else\n    {\n      hi = 0;\n      lo = (unsigned HOST_WIDE_INT) 1 << (width - 1);\n    \n      mask_hi = 0;\n      mask_lo = ((unsigned HOST_WIDE_INT) -1\n                 >> (HOST_BITS_PER_WIDE_INT - width));\n    }\n\n  if ((val_hi & mask_hi) == hi\n      && (val_lo & mask_lo) == lo)\n    return 1;\n\n  return 0;\n}\n\nint main()\n{\n  struct tree_type t;\n  t.precision = 1;\n  if (!sign_bit_p (&t, 0, -1))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31448-2.c",
    "content": "/* PR middle-end/31448, this used to ICE during expand because\n   reduce_to_bit_field_precision was not ready to handle constants. */\n\ntypedef struct _st {\n    long int iIndex : 24;\n    long int iIndex1 : 24;\n} st;\nst *next;\nvoid g(void)\n{\n    st *next = 0;\n    int nIndx;\n    const static int constreg[] = { 0,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n}\nvoid f(void)\n{\n    int nIndx;\n    const static long int constreg[] = { 0xFEFEFEFE,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n    next->iIndex1 = constreg[nIndx];\n}\nint main(void)\n{\n  st a;\n  next = &a;\n  f();\n  if (next->iIndex != 0xFFFEFEFE)\n    __builtin_abort ();\n  if (next->iIndex1 != 0xFFFEFEFE)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31448.c",
    "content": "/* PR middle-end/31448, this used to ICE during expand because\n   reduce_to_bit_field_precision was not ready to handle constants. */\n/* { dg-require-effective-target int32plus } */\n\ntypedef struct _st {\n    int iIndex : 24;\n    int iIndex1 : 24;\n} st;\nst *next;\nvoid g(void)\n{\n    st *next = 0;\n    int nIndx;\n    const static int constreg[] = { 0,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n}\nvoid f(void)\n{\n    int nIndx;\n    const static int constreg[] = { 0xFEFEFEFE,};\n    nIndx = 0;\n    next->iIndex = constreg[nIndx];\n    next->iIndex1 = constreg[nIndx];\n}\nint main(void)\n{\n  st a;\n  next = &a;\n  f();\n  if (next->iIndex != 0xFFFEFEFE)\n    __builtin_abort ();\n  if (next->iIndex1 != 0xFFFEFEFE)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr31605.c",
    "content": "void put_field (unsigned int start, unsigned int len)\n{\n  int cur_bitshift = ((start + len) % 8) - 8;\n  if (cur_bitshift > -8)\n    exit (0);\n}\n\nint\nmain ()\n{\n  put_field (0, 1);\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr32244-1.c",
    "content": "struct foo\n{\n  unsigned long long b:40;\n} x;\n\nextern void abort (void);\n\nvoid test1(unsigned long long res)\n{\n  /* The shift is carried out in 40 bit precision.  */\n  if (x.b<<32 != res)\n    abort ();\n}\n\nint main()\n{\n  x.b = 0x0100;\n  test1(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr32500.c",
    "content": "extern void abort(void);\nextern void exit(int);\nvoid foo(int) __attribute__((noinline));\nvoid bar(void) __attribute__((noinline));\n\n/* Make sure foo is not inlined or considered pure/const.  */\nint x;\nvoid foo(int i) { x = i; }\nvoid bar(void) { exit(0); }\n\nint\nmain(int argc, char *argv[])\n{\n\tint i;\n\tint numbers[4] = { 0xdead, 0xbeef, 0x1337, 0x4242 };\n\n\tfor (i = 1; i <= 12; i++) {\n\t\tif (i <= 4)\n\t\t\tfoo(numbers[i-1]);\n\t\telse if (i >= 7 && i <= 9)\n\t\t\tbar();\n\t}\n\n\tabort();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33142.c",
    "content": "int abs(int j);\nextern void abort(void);\n\n__attribute__((noinline)) int lisp_atan2(long dy, long dx) {\n    if (dx <= 0)\n        if (dy > 0)\n            return abs(dx) <= abs(dy);\n    return 0;\n}\n\nint main() {   \n    volatile long dy = 63, dx = -77;\n    if (lisp_atan2(dy, dx))\n        abort();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33382.c",
    "content": "struct Foo {\n  int i;\n  int j[];\n};\n\nstruct Foo x = { 1, { 2, 0, 2, 3 } };\n\nint foo(void)\n{\n  x.j[0] = 1;\n  return x.j[1];\n}\n\nextern void abort(void);\n\nint main()\n{\n  if (foo() != 0)\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33631.c",
    "content": "typedef union\n{\n  int __lock;\n} pthread_mutex_t;\n\nextern void abort (void);\n\nint main()\n{\n    struct { int c; pthread_mutex_t m; } r = { .m = 0 };\n    if (r.c != 0)\n      abort ();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33669.c",
    "content": "extern void abort (void);\n\ntypedef struct foo_t\n{ \n  unsigned int blksz;\n  unsigned int bf_cnt; \n} foo_t;\n\n#define _RNDUP(x, unit)  ((((x) + (unit) - 1) / (unit)) * (unit))\n#define _RNDDOWN(x, unit)  ((x) - ((x)%(unit)))\n\nlong long\nfoo (foo_t *const pxp,  long long offset, unsigned int extent)\n{\n  long long blkoffset = _RNDDOWN(offset, (long long )pxp->blksz);\n  unsigned int diff = (unsigned int)(offset - blkoffset);\n  unsigned int blkextent = _RNDUP(diff + extent, pxp->blksz);\n\n  if (pxp->blksz < blkextent)\n    return -1LL;\n\n  if (pxp->bf_cnt > pxp->blksz)\n    pxp->bf_cnt = pxp->blksz;\n\n  return blkoffset;\n}\n\nint\nmain ()\n{\n  foo_t x;\n  long long xx;\n\n  x.blksz = 8192;\n  x.bf_cnt = 0;\n  xx = foo (&x, 0, 4096);\n  if (xx != 0LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33779-1.c",
    "content": "int foo(int i)\n{\n  if (((unsigned)(i + 1)) * 4 == 0)\n    return 1;\n  return 0;\n}\n\nextern void abort(void);\nint main()\n{\n  if (foo(0x3fffffff) == 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33779-2.c",
    "content": "int foo(int i)\n{\n  return ((int)((unsigned)(i + 1) * 4)) / 4;\n}\n\nextern void abort(void);\nint main()\n{\n  if (foo(0x3fffffff) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33870-1.c",
    "content": "extern void abort (void);\n\ntypedef struct PgHdr PgHdr;\ntypedef unsigned char u8;\nstruct PgHdr {\nint y;\nstruct {\n unsigned int pgno;\n PgHdr *pNextHash, *pPrevHash;\n PgHdr *pNextFree, *pPrevFree;\n PgHdr *pNextAll;\n u8 inJournal;\n short int nRef;\n PgHdr *pDirty, *pPrevDirty;\n unsigned int notUsed;\n} x;\n};\nPgHdr **xx;\nvolatile int vx;\nstatic inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)\n{\n PgHdr result;\n PgHdr *pTail;\n xx = &result.x.pDirty;\n pTail = &result;\n while( pA && pB ){\n   if( pA->x.pgno<pB->x.pgno ){\n     pTail->x.pDirty = pA;\n     pTail = pA;\n     pA = pA->x.pDirty;\n   }else{\n     pTail->x.pDirty = pB;\n     pTail = pB;\n     pB = pB->x.pDirty;\n   }\n   vx = (*xx)->y;\n }\n if( pA ){\n   pTail->x.pDirty = pA;\n }else if( pB ){\n   pTail->x.pDirty = pB;\n }else{\n   pTail->x.pDirty = 0;\n }\n return result.x.pDirty;\n}\n\nPgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)\n{\n PgHdr *a[25], *p;\n int i;\n __builtin_memset (a, 0, sizeof (a));\n while( pIn ){\n   p = pIn;\n   pIn = p->x.pDirty;\n   p->x.pDirty = 0;\n   for(i=0; i<25 -1; i++){\n     if( a[i]==0 ){\n       a[i] = p;\n       break;\n     }else{\n       p = merge_pagelist(a[i], p);\n       a[i] = 0;\n       a[i] = 0;\n     }\n   }\n   if( i==25 -1 ){\n     a[i] = merge_pagelist(a[i], p);\n   }\n }\n p = a[0];\n for(i=1; i<25; i++){\n   p = merge_pagelist (p, a[i]);\n }\n return p;\n}\n\nint main()\n{\n PgHdr a[5];\n PgHdr *p;\n a[0].x.pgno = 5;\n a[0].x.pDirty = &a[1];\n a[1].x.pgno = 4;\n a[1].x.pDirty = &a[2];\n a[2].x.pgno = 1;\n a[2].x.pDirty = &a[3];\n a[3].x.pgno = 3;\n a[3].x.pDirty = 0;\n p = sort_pagelist (&a[0]);\n if (p->x.pDirty == p)\n   abort ();\n return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33870.c",
    "content": "extern void abort (void);\n\ntypedef struct PgHdr PgHdr;\ntypedef unsigned char u8;\nstruct PgHdr {\n  unsigned int pgno;\n  PgHdr *pNextHash, *pPrevHash;\n  PgHdr *pNextFree, *pPrevFree;\n  PgHdr *pNextAll;\n  u8 inJournal;\n  short int nRef;\n  PgHdr *pDirty, *pPrevDirty;\n  unsigned int notUsed;\n};\n\nstatic inline PgHdr *merge_pagelist(PgHdr *pA, PgHdr *pB)\n{\n  PgHdr result;\n  PgHdr *pTail;\n  pTail = &result;\n  while( pA && pB ){\n    if( pA->pgno<pB->pgno ){\n      pTail->pDirty = pA;\n      pTail = pA;\n      pA = pA->pDirty;\n    }else{\n      pTail->pDirty = pB;\n      pTail = pB;\n      pB = pB->pDirty;\n    }\n  }\n  if( pA ){\n    pTail->pDirty = pA;\n  }else if( pB ){\n    pTail->pDirty = pB;\n  }else{\n    pTail->pDirty = 0;\n  }\n  return result.pDirty;\n}\n\nPgHdr * __attribute__((noinline)) sort_pagelist(PgHdr *pIn)\n{\n  PgHdr *a[25], *p;\n  int i;\n  __builtin_memset (a, 0, sizeof (a));\n  while( pIn ){\n    p = pIn;\n    pIn = p->pDirty;\n    p->pDirty = 0;\n    for(i=0; i<25 -1; i++){\n      if( a[i]==0 ){\n        a[i] = p;\n        break;\n      }else{\n        p = merge_pagelist(a[i], p);\n        a[i] = 0;\n      }\n    }\n    if( i==25 -1 ){\n      a[i] = merge_pagelist(a[i], p);\n    }\n  }\n  p = a[0];\n  for(i=1; i<25; i++){\n    p = merge_pagelist (p, a[i]);\n  }\n  return p;\n}\n\nint main()\n{\n  PgHdr a[5];\n  PgHdr *p;\n  a[0].pgno = 5;\n  a[0].pDirty = &a[1];\n  a[1].pgno = 4;\n  a[1].pDirty = &a[2];\n  a[2].pgno = 1;\n  a[2].pDirty = &a[3];\n  a[3].pgno = 3;\n  a[3].pDirty = 0;\n  p = sort_pagelist (&a[0]);\n  if (p->pDirty == p)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr33992.c",
    "content": "extern void abort ();\n\nvoid __attribute__((noinline))\nbar (unsigned long long i)\n{\n  if (i)\n    abort ();\n}\n\nstatic void __attribute__((always_inline))\nfoo (unsigned long long *r)\n{\n  int i;\n\n  for (i = 0; ; i++)\n    if (*r & ((unsigned long long)1 << (63 - i)))\n      break;\n\n  bar (i);\n}\n\nvoid __attribute__((noinline))\ndo_test (unsigned long long *r)\n{\n  int i;\n\n  for (i = 0; i < 2; ++i)\n    foo (r);\n}\n\nint main()\n{\n  unsigned long long r = 0x8000000000000001ull;\n\n  do_test (&r);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34070-1.c",
    "content": "extern void abort (void);\n\nint f(unsigned int x)\n{\n    return ((int)x) % 4;\n}\n\nint main()\n{\n  if (f(-1) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34070-2.c",
    "content": "extern void abort (void);\n\nint f(unsigned int x, int n)\n{\n    return ((int)x) / (1 << n);\n}\n\nint main()\n{\n  if (f(-1, 1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34099-2.c",
    "content": "int test1 (int b, int c)\n{\n  char x;\n  if (b)\n    return x / c;\n  else\n    return 1;\n}\nint test2 (int b, int c)\n{\n  int x;\n  if (b)\n    return x * c;\n  else\n    return 1;\n}\nint test3 (int b, int c)\n{\n  int x;\n  if (b)\n    return x % c;\n  else\n    return 1;\n}\nint test4 (int b, int c)\n{\n  char x;\n  if (b)\n    return x == c;\n  else\n    return 1;\n}\n\nextern void abort (void);\nint main()\n{\n  if (test1(1, 1000) != 0)\n    abort ();\n  if (test2(1, 0) != 0)\n    abort ();\n  if (test3(1, 1) != 0)\n    abort ();\n  if (test4(1, 1000) != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34099.c",
    "content": "int foo (int b, int c)\n{\n  int x;\n  if (b)\n    return x & c;\n  else\n    return 1;\n}\nextern void abort (void);\nint main()\n{\n  if (foo(1, 0) != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34130.c",
    "content": "extern void abort (void);\nint foo (int i)\n{\n  return -2 * __builtin_abs(i - 2);\n}\nint main()\n{\n  if (foo(1) != -2\n      || foo(3) != -2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34154.c",
    "content": "int foo( unsigned long long aLL )\n{\n    switch( aLL )\n    {\n        case 1000000000000000000ULL ... 9999999999999999999ULL : return 19 ; \n        default                                 : return 20 ;\n    };\n};\nextern void abort (void);\nint main()\n{\n    unsigned long long aLL = 1000000000000000000ULL;\n    if (foo (aLL) != 19)\n\tabort ();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34176.c",
    "content": "\ntypedef __SIZE_TYPE__ size_t;\ntypedef unsigned int index_ty;\ntypedef index_ty *index_list_ty;\n\nstruct mult_index\n{\n  index_ty index;\n  unsigned int count;\n};\n\nstruct mult_index_list\n{\n  struct mult_index *item;\n  size_t nitems;\n  size_t nitems_max;\n\n  struct mult_index *item2;\n  size_t nitems2_max;\n};\n\nint __attribute__((noinline))\nhash_find_entry (size_t *result)\n{\n    *result = 2;\n    return 0;\n}\n\nextern void abort (void);\nstruct mult_index * __attribute__((noinline))\nfoo (size_t n)\n{\n  static count = 0;\n  if (count++ > 0)\n    abort ();\n  return 0;\n}\n\nint\nmain (void)\n{\n    size_t nitems = 0;\n\n    for (;;)\n    {\n        size_t list;\n\n        hash_find_entry (&list);\n        {\n            size_t len2 = list;\n            struct mult_index *destptr;\n            struct mult_index *dest;\n            size_t new_max  = nitems + len2;\n\n            if (new_max != len2)\n                break;\n            dest = foo (new_max);\n\n            destptr = dest;\n            while (len2--)\n                destptr++;\n\n            nitems = destptr - dest;\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34415.c",
    "content": "const char *__attribute__((noinline))\nfoo (const char *p)\n{\n  const char *end;\n  int len = 1;\n  for (;;)\n    {\n      int c = *p;\n      c = (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);\n      if (c == 'B')\n\tend = p;\n      else if (c == 'A')\n\t{\n\t  end = p;\n\t  do\n\t    p++;\n\t  while (*p == '+');\n\t}\n      else\n\tbreak;\n      p++;\n      len++;\n    }\n  if (len > 2 && *p == ':')\n    p = end;\n  return p;\n}\n\nint\nmain (void)\n{\n  const char *input = \"Bbb:\";\n  return foo (input) != input + 2;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34456.c",
    "content": "/* { dg-skip-if \"requires qsort\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdlib.h>\n\nint __attribute__ ((noinline)) debug (void) { return 1; }\nint errors;\n\nstruct s { int elt; int (*compare) (int); };\n\nstatic int\ncompare (const void *x, const void *y)\n{\n  const struct s *s1 = x, *s2 = y;\n  int (*compare1) (int);\n  int elt2;\n\n  compare1 = s1->compare;\n  elt2 = s2->elt;\n  if (elt2 != 0 && debug () && compare1 (s1->elt) != 0)\n    errors++;\n  return compare1 (elt2);\n}\n\nint bad_compare (int x) { return -x; }\nstruct s array[2] = { { 1, bad_compare }, { -1, bad_compare } };\n\nint\nmain (void)\n{\n  qsort (array, 2, sizeof (struct s), compare);\n  return errors == 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34768-1.c",
    "content": "int x;\n\nvoid __attribute__((noinline)) foo (void)\n{\n  x = -x;\n}\nvoid __attribute__((const,noinline)) bar (void)\n{\n}\n\nint __attribute__((noinline))\ntest (int c)\n{\n  int tmp = x;\n  (c ? foo : bar) ();\n  return tmp + x;\n}\n\nextern void abort (void);\nint main()\n{\n  x = 1;\n  if (test (1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34768-2.c",
    "content": "int x;\n\nint __attribute__((noinline)) foo (void)\n{\n  x = -x;\n  return 0;\n}\nint __attribute__((const,noinline)) bar (void)\n{\n  return 0;\n}\n\nint __attribute__((noinline))\ntest (int c)\n{\n  int tmp = x;\n  int res = (c ? foo : bar) ();\n  return tmp + x + res;\n}\n\nextern void abort (void);\nint main()\n{\n  x = 1;\n  if (test (1) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34971.c",
    "content": "struct foo\n{\n  unsigned long long b:40;\n} x;\n\nextern void abort (void);\n\nvoid test1(unsigned long long res)\n{\n  /* Build a rotate expression on a 40 bit argument.  */\n  if ((x.b<<8) + (x.b>>32) != res)\n    abort ();\n}\n\nint main()\n{\n  x.b = 0x0100000001;\n  test1(0x0000000101);\n  x.b = 0x0100000000;\n  test1(0x0000000001);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr34982.c",
    "content": "extern void abort (void);\n\nstatic void something();\n\nint main()\n{\n  something(-1);\n  return 0;\n}\n\nstatic void something(int i)\n{\n  if (i != -1)\n    abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35163.c",
    "content": "extern void abort(void);\n\nint main()\n{\n  signed char a = -30;\n  signed char b = -31;\n  #if(__SIZEOF_INT__ >= 4)\n  if (a > (unsigned short)b)\n#else\n  if ((long) a > (unsigned short)b)\n#endif\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35231.c",
    "content": "extern void abort(void);\n\nint __attribute__((noinline))\nfoo(int bits_per_pixel, int depth)\n{\n  if ((bits_per_pixel | depth) == 1)\n    abort ();\n  return bits_per_pixel;\n}\n\nint main()\n{\n  if (foo(2, 0) != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35390.c",
    "content": "extern void abort (void);\n\nunsigned int foo (int n)\n{\n  return ~((unsigned int)~n);\n}\n\nint main()\n{\n  if (foo(0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35456.c",
    "content": "/* { dg-skip-if \"signed zero not supported\" { \"vax-*-*\" } { \"*\" } { \"\" } } */\nextern void abort (void);\n\ndouble\n__attribute__ ((noinline))\nnot_fabs (double x)\n{\n  return x >= 0.0 ? x : -x;\n}\n\nint main()\n{\n  double x = -0.0;\n  double y;\n\n  y = not_fabs (x);\n\n  if (!__builtin_signbit (y))\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35472.c",
    "content": "extern void abort (void);\nextern void *memset (void *s, int c, __SIZE_TYPE__ n);\nstruct S { int i[16]; };\nstruct S *p;\nvoid __attribute__((noinline,noclone))\nfoo(struct S *a, struct S *b) { a->i[0] = -1; p = b; }\nvoid test (void)\n{\n  struct S a, b;\n  memset (&a.i[0], '\\0', sizeof (a.i));\n  memset (&b.i[0], '\\0', sizeof (b.i));\n  foo (&a, &b);\n  *p = a;\n  *p = b;\n  if (b.i[0] != -1)\n    abort ();\n}\nint main()\n{\n  test();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr35800.c",
    "content": "extern void abort (void);\n\nint stab_xcoff_builtin_type (int typenum)\n{\n  const char *name;\n  if (typenum >= 0 || typenum < -34)\n    {\n      return 0;\n    }\n  switch (-typenum)\n    {\n    case 1:\n      name = \"int\";\n      break;\n    case 2:\n      name = \"char\";\n    case 3:\n      name = \"short\";\n      break;\n    case 4:\n      name = \"long\";\n    case 5:\n      name = \"unsigned char\";\n    case 6:\n      name = \"signed char\";\n    case 7:\n      name = \"unsigned short\";\n    case 8:\n      name = \"unsigned int\";\n    case 9:\n      name = \"unsigned\";\n    case 10:\n      name = \"unsigned long\";\n    case 11:\n      name = \"void\";\n    case 12:\n      name = \"float\";\n    case 13:\n      name = \"double\";\n    case 14:\n      name = \"long double\";\n    case 15:\n      name = \"integer\";\n    case 16:\n      name = \"boolean\";\n    case 17:\n      name = \"short real\";\n    case 18:\n      name = \"real\";\n    case 19:\n      name = \"stringptr\";\n    case 20:\n      name = \"character\";\n    case 21:\n      name = \"logical*1\";\n    case 22:\n      name = \"logical*2\";\n    case 23:\n      name = \"logical*4\";\n    case 24:\n      name = \"logical\";\n    case 25:\n      name = \"complex\";\n    case 26:\n      name = \"double complex\";\n    case 27:\n      name = \"integer*1\";\n    case 28:\n      name = \"integer*2\";\n    case 29:\n      name = \"integer*4\";\n    case 30:\n      name = \"wchar\";\n    case 31:\n      name = \"long long\";\n    case 32:\n      name = \"unsigned long long\";\n    case 33:\n      name = \"logical*8\";\n    case 34:\n      name = \"integer*8\";\n    }\n  return name[0];\n}\n\nint main()\n{\n  int i;\n  if (stab_xcoff_builtin_type(0) != 0)\n    abort ();\n  if (stab_xcoff_builtin_type(-1) != 'i')\n    abort ();\n  if (stab_xcoff_builtin_type(-2) != 's')\n    abort ();\n  if (stab_xcoff_builtin_type(-3) != 's')\n    abort ();\n  for (i = -4; i >= -34; --i)\n    if (stab_xcoff_builtin_type(i) != 'i')\n      abort ();\n  if (stab_xcoff_builtin_type(-35) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36034-1.c",
    "content": "double x[5][10] = { { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1 },\n                    { 21, 22, 23, 24, 25, 26, -1, -1, -1, -1 },\n                    { 32, 33, 34, 35, 36, 37, -1, -1, -1, -1 },\n                    { 43, 44, 45, 46, 47, 48, -1, -1, -1, -1 },\n                    { 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 } };\ndouble tmp[5][6];\n\nvoid __attribute__((noinline))\ntest (void)\n{ \n  int i, j;\n  for (i = 0; i < 5; ++i)\n    {\n      tmp[i][0] = x[i][0];\n      tmp[i][1] = x[i][1];\n      tmp[i][2] = x[i][2];\n      tmp[i][3] = x[i][3];\n      tmp[i][4] = x[i][4];\n      tmp[i][5] = x[i][5];\n    }\n}\nextern void abort (void);\nint main()\n{\n  int i, j;\n  test();\n  for (i = 0; i < 5; ++i)\n    for (j = 0; j < 6; ++j)\n      if (tmp[i][j] == -1)\n        abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36034-2.c",
    "content": "double x[50] = { 10, 11, 12, 13, 14, 15, -1, -1, -1, -1,\n                 21, 22, 23, 24, 25, 26, -1, -1, -1, -1,\n                 32, 33, 34, 35, 36, 37, -1, -1, -1, -1,\n                 43, 44, 45, 46, 47, 48, -1, -1, -1, -1,\n                 54, 55, 56, 57, 58, 59, -1, -1, -1, -1 };\ndouble tmp[30];\n\nvoid __attribute__((noinline))\ntest (void)\n{\n  int i, j;\n  for (i = 0; i < 5; ++i)\n    {\n      tmp[i*6] = x[i*10];\n      tmp[i*6+1] = x[i*10+1];\n      tmp[i*6+2] = x[i*10+2];\n      tmp[i*6+3] = x[i*10+3];\n      tmp[i*6+4] = x[i*10+4];\n      tmp[i*6+5] = x[i*10+5];\n    }\n}\nextern void abort (void);\nint main()\n{\n  int i, j;\n  test();\n  for (i = 0; i < 5; ++i)\n    for (j = 0; j < 6; ++j)\n      if (tmp[i*6+j] == -1)\n        abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36038.c",
    "content": "/* PR tree-optimization/36038 */\n\nlong long list[10];\nlong long expect[10] = { 0, 1, 2, 3, 4, 4, 5, 6, 7, 9 };\nlong long *stack_base;\nint indices[10];\nint *markstack_ptr;\n\nvoid\ndoit (void)\n{\n  long long *src;\n  long long *dst;\n  long long *sp = stack_base + 5;\n  int diff = 2;\n  int shift;\n  int count;\n\n  shift = diff - (markstack_ptr[-1] - markstack_ptr[-2]);\n  count = (sp - stack_base) - markstack_ptr[-1] + 2;\n  src = sp;\n  dst = (sp += shift);\n  while (--count)\n    *dst-- = *src--;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 10; i++)\n    list[i] = i;\n\n  markstack_ptr = indices + 9;\n  markstack_ptr[-1] = 2;\n  markstack_ptr[-2] = 1;\n\n  stack_base = list + 2;\n  doit ();\n  if (__builtin_memcmp (expect, list, sizeof (list)))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36077.c",
    "content": "extern void abort (void);\n\nunsigned int test (unsigned int x)\n{\n  return x / 0x80000001U / 0x00000002U;\n}\n\nint main()\n{\n  if (test(2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36093.c",
    "content": "extern void abort (void);\n\ntypedef struct Bar {\n      char c[129];\n} Bar __attribute__((__aligned__(128)));\n\ntypedef struct Foo {\n      Bar bar[4];\n} Foo;\n\nFoo foo[4];\n\nint main()\n{\n   int i, j;\n   Foo *foop = &foo[0];\n\n   for (i=0; i < 4; i++) {\n      Bar *bar = &foop->bar[i];\n      for (j=0; j < 129; j++) {\n         bar->c[j] = 'a' + i;\n      }\n   }\n\n   if (foo[0].bar[3].c[128] != 'd')\n     abort ();\n   return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36321.c",
    "content": "/* { dg-skip-if \"requires alloca\" { ! alloca } { \"-O0\" } { \"\" } } */\nextern void abort (void);\n\nextern __SIZE_TYPE__ strlen (const char *);\nvoid foo(char *str)\n{\n  int len2 = strlen (str);\n  char *a = (char *) __builtin_alloca (0);\n  char *b = (char *) __builtin_alloca (len2*3);\n\n  if ((int) (a-b) < (len2*3))\n    {\n#ifdef _WIN32\n      abort ();\n#endif\n      return;\n    }\n}\n\nstatic char * volatile argp = \"pr36321.x\";\n\nint main(int argc, char **argv)\n{\n  foo (argp);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36339.c",
    "content": "extern void abort (void);\n\ntypedef unsigned long my_uintptr_t;\n\nint check_a(my_uintptr_t tagged_ptr);\n\nint __attribute__((noinline)) try_a(my_uintptr_t x)\n{\n  my_uintptr_t heap[2];\n  my_uintptr_t *hp = heap;\n\n  hp[0] = x;\n  hp[1] = 0;\n  return check_a((my_uintptr_t)(void*)((char*)hp + 1));\n}\n\nint __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr)\n{\n  my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1);\n\n  if (hp[0] == 42 && hp[1] == 0)\n    return 0;\n  return -1;\n}\n\nint main(void)\n{\n  if (try_a(42) < 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36343.c",
    "content": "extern void abort (void);\n\nvoid __attribute__((noinline))\nbar (int **p)\n{\n  float *q = (float *)p;\n  *q = 0.0;\n}\n\nfloat __attribute__((noinline))\nfoo (int b)\n{\n  int *i = 0;\n  float f = 1.0;\n  int **p;\n  if (b)\n    p = &i;\n  else\n    p = (int **)&f;\n  bar (p);\n  if (b)\n    return **p;\n  return f;\n}\n\nint main()\n{\n  if (foo(0) != 0.0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36691.c",
    "content": "unsigned char g_5;\n\nvoid func_1 (void)\n{\n  for (g_5 = 9; g_5 >= 4; g_5 -= 5)\n    ;\n}\n\nextern void abort (void);\nint main (void)\n{\n  func_1 ();\n  if (g_5 != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr36765.c",
    "content": "int __attribute__((noinline))\nfoo(int i)\n{\n  int *p = __builtin_malloc (4 * sizeof(int));\n  *p = 0;\n  p[i] = 1;\n  return *p;\n}\nextern void abort (void);\nint main()\n{\n  if (foo(0) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37102.c",
    "content": "extern void abort (void);\n\nunsigned int a, b = 1, c;\n\nvoid __attribute__ ((noinline))\nfoo (int x)\n{\n  if (x != 5)\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned int d, e;\n  for (d = 1; d < 5; d++)\n    if (c)\n      a = b;\n  a = b;\n  e = a << 1;\n  if (e)\n    e = (e << 1) ^ 1;\n  foo (e);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37125.c",
    "content": "extern void abort (void);\n\nstatic inline unsigned int\nmod_rhs(int rhs)\n{\n  if (rhs == 0) return 1;\n  return rhs;\n}\n\nvoid func_44 (unsigned int p_45);\nvoid func_44 (unsigned int p_45)\n{\n  if (!((p_45 * -9) % mod_rhs (-9))) {\n      abort();\n  }\n}\n\nint main (void)\n{\n  func_44 (2);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37573.c",
    "content": "/* PR tree-optimization/37573 */\n/* { dg-require-effective-target int32plus } */\n\nstruct S\n{\n  unsigned int *a;\n  unsigned int b;\n  unsigned int c[624];\n};\n\nstatic unsigned char __attribute__((noinline))\nfoo (struct S *s)\n{\n  unsigned int r;\n  if (!--s->b)\n    {\n      unsigned int *c = s->c;\n      unsigned int i;\n      s->a = c;\n      for (i = 0; i < 227; i++)\n\tc[i] = ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1)\n\t    ^ ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397];\n    }\n  r = *(s->a++);\n  r ^= (r >> 11);\n  r ^= ((r & 0xff3a58ad) << 7);\n  r ^= ((r & 0xffffdf8c) << 15);\n  r ^= (r >> 18);\n  return (unsigned char) (r >> 1);\n}\n\nstatic void __attribute__((noinline))\nbar (unsigned char *p, unsigned int q, unsigned int r)\n{\n  struct S s;\n  unsigned int i;\n  unsigned int *c = s.c;\n  *c = r;\n  for (i = 1; i < 624; i++)\n    c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]);\n  s.b = 1;\n  while (q--)\n    *p++ ^= foo (&s);\n};\n\nstatic unsigned char p[23] = {\n  0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49,\n  0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38\n};\n\nstatic unsigned char q[23] = {\n  0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43,\n  0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c\n};\n\nint\nmain (void)\n{\n  unsigned int s;\n  s = 23;\n  bar (p, s, s + 0xa25e);\n  if (__builtin_memcmp (p, q, s) != 0)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37780.c",
    "content": "/* PR middle-end/37780.  */\n\n#define VAL (8 * sizeof (int))\n\nint __attribute__ ((noinline, noclone))\nfooctz (int i)\n{\n  return (i == 0) ? VAL : __builtin_ctz (i);\n}\n\nint __attribute__ ((noinline, noclone))\nfooctz2 (int i)\n{\n  return (i != 0) ? __builtin_ctz (i) : VAL;\n}\n\nunsigned int __attribute__ ((noinline, noclone))\nfooctz3 (unsigned int i)\n{\n  return (i > 0) ?  __builtin_ctz (i) : VAL;\n}\n\nint __attribute__ ((noinline, noclone))\nfooclz (int i)\n{\n  return (i == 0) ? VAL : __builtin_clz (i);\n}\n\nint __attribute__ ((noinline, noclone))\nfooclz2 (int i)\n{\n  return (i != 0) ? __builtin_clz (i) : VAL;\n}\n\nunsigned int __attribute__ ((noinline, noclone))\nfooclz3 (unsigned int i)\n{\n  return (i > 0) ? __builtin_clz (i) : VAL;\n}\n\nint\nmain (void)\n{\n  if (fooctz (0) != VAL || fooctz2 (0) != VAL || fooctz3 (0) != VAL\n      || fooclz (0) != VAL || fooclz2 (0) != VAL || fooclz3 (0) != VAL)\n    __builtin_abort ();\n\n  return 0;\n}"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37882.c",
    "content": "/* PR middle-end/37882 */\n\nstruct S\n{\n  unsigned char b : 3;\n} s;\n\nint\nmain ()\n{\n  s.b = 4;\n  if (s.b > 0 && s.b < 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37924.c",
    "content": "/* PR c/37924 */\n\nextern void abort (void);\n\nsigned char a;\nunsigned char b;\n\nint\ntest1 (void)\n{\n  int c = -1;\n  return ((unsigned int) (a ^ c)) >> 9;\n}\n\nint\ntest2 (void)\n{\n  int c = -1;\n  return ((unsigned int) (b ^ c)) >> 9;\n}\n\nint\nmain (void)\n{\n  a = 0;\n  if (test1 () != (-1U >> 9))\n    abort ();\n  a = 0x40;\n  if (test1 () != (-1U >> 9))\n    abort ();\n  a = 0x80;\n  if (test1 () != (a < 0) ? 0 : (-1U >> 9))\n    abort ();\n  a = 0xff;\n  if (test1 () != (a < 0) ? 0 : (-1U >> 9))\n    abort ();\n  b = 0;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0x40;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0x80;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  b = 0xff;\n  if (test2 () != (-1U >> 9))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr37931.c",
    "content": "/* PR middle-end/37931 */\n\nextern void abort (void);\n\nint\nfoo (int a, unsigned int b)\n{\n  return (a | 1) & (b | 1);\n}\n\nint\nmain (void)\n{\n  if (foo (6, 0xc6) != 7)\n    abort ();\n  if (foo (0x80, 0xc1) != 0x81)\n    abort ();\n  if (foo (4, 4) != 5)\n    abort ();\n  if (foo (5, 4) != 5)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38048-1.c",
    "content": "extern void abort(void);\n\nint foo ()\n{\n  int mat[2][1];\n  int (*a)[1] = mat;\n  int det = 0;\n  int i;\n  mat[0][0] = 1;\n  mat[1][0] = 2;\n  for (i = 0; i < 2; ++i)\n    det += a[i][0];\n  return det;\n}\n\nint main()\n{\n  if (foo () != 3)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38048-2.c",
    "content": "extern void abort (void);\n\nstatic int inv_J(int a[][2])\n{\n  int i, j;\n  int det = 0.0;\n   for (j=0; j<2; ++j)\n     det += a[j][0] + a[j][1];\n  return det;\n}\n\nint foo()\n{\n  int mat[2][2];\n  mat[0][0] = 1;\n  mat[0][1] = 2;\n  mat[1][0] = 4;\n  mat[1][1] = 8;\n  return inv_J(mat);\n}\n\nint main()\n{\n  if (foo () != 15)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38051.c",
    "content": "typedef __SIZE_TYPE__ size_t;\nstatic int mymemcmp1 (unsigned long int, unsigned long int)\n  __attribute__ ((__nothrow__));\n\n__inline static int\nmymemcmp1 (unsigned long int a, unsigned long int b)\n{\n  long int srcp1 = (long int) &a;\n  long int srcp2 = (long int) &b;\n  unsigned long int a0, b0;\n  do\n    {\n      a0 = ((unsigned char *) srcp1)[0];\n      b0 = ((unsigned char *) srcp2)[0];\n      srcp1 += 1;\n      srcp2 += 1;\n    }\n  while (a0 == b0);\n  return a0 - b0;\n}\n\nstatic int mymemcmp2 (long, long, size_t) __attribute__ ((__nothrow__));\n\nstatic int\nmymemcmp2 (long int srcp1, long int srcp2, size_t len)\n{\n  unsigned long int a0, a1;\n  unsigned long int b0, b1;\n  switch (len % 4)\n    {\n    default:\n    case 2:\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= 2 * (sizeof (unsigned long int));\n      srcp2 -= 2 * (sizeof (unsigned long int));\n      len += 2;\n      goto do1;\n    case 3:\n      a1 = ((unsigned long int *) srcp1)[0];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= (sizeof (unsigned long int));\n      srcp2 -= (sizeof (unsigned long int));\n      len += 1;\n      goto do2;\n    case 0:\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        return 0;\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      goto do3;\n    case 1:\n      a1 = ((unsigned long int *) srcp1)[0];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp1 += (sizeof (unsigned long int));\n      srcp2 += (sizeof (unsigned long int));\n      len -= 1;\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        goto do0;\n    }\n  do\n    {\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      if (a1 != b1)\n        return mymemcmp1 ((a1), (b1));\n    do3:\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[1];\n      if (a0 != b0)\n        return mymemcmp1 ((a0), (b0));\n    do2:\n      a0 = ((unsigned long int *) srcp1)[2];\n      b0 = ((unsigned long int *) srcp2)[2];\n      if (a1 != b1)\n        return mymemcmp1 ((a1), (b1));\n    do1:\n      a1 = ((unsigned long int *) srcp1)[3];\n      b1 = ((unsigned long int *) srcp2)[3];\n      if (a0 != b0)\n        return mymemcmp1 ((a0), (b0));\n      srcp1 += 4 * (sizeof (unsigned long int));\n      srcp2 += 4 * (sizeof (unsigned long int));\n      len -= 4;\n    }\n  while (len != 0);\ndo0:\n  if (a1 != b1)\n    return mymemcmp1 ((a1), (b1));\n  return 0;\n}\n\nstatic int mymemcmp3 (long, long, size_t) __attribute__ ((__nothrow__));\n\nstatic int\nmymemcmp3 (long int srcp1, long int srcp2, size_t len)\n{\n  unsigned long int a0, a1, a2, a3;\n  unsigned long int b0, b1, b2, b3;\n  unsigned long int x;\n  int shl, shr;\n  shl = 8 * (srcp1 % (sizeof (unsigned long int)));\n  shr = 8 * (sizeof (unsigned long int)) - shl;\n  srcp1 &= -(sizeof (unsigned long int));\n  switch (len % 4)\n    {\n    default:\n    case 2:\n      a1 = ((unsigned long int *) srcp1)[0];\n      a2 = ((unsigned long int *) srcp1)[1];\n      b2 = ((unsigned long int *) srcp2)[0];\n      srcp1 -= 1 * (sizeof (unsigned long int));\n      srcp2 -= 2 * (sizeof (unsigned long int));\n      len += 2;\n      goto do1;\n    case 3:\n      a0 = ((unsigned long int *) srcp1)[0];\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[0];\n      srcp2 -= 1 * (sizeof (unsigned long int));\n      len += 1;\n      goto do2;\n    case 0:\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        return 0;\n      a3 = ((unsigned long int *) srcp1)[0];\n      a0 = ((unsigned long int *) srcp1)[1];\n      b0 = ((unsigned long int *) srcp2)[0];\n      srcp1 += 1 * (sizeof (unsigned long int));\n      goto do3;\n    case 1:\n      a2 = ((unsigned long int *) srcp1)[0];\n      a3 = ((unsigned long int *) srcp1)[1];\n      b3 = ((unsigned long int *) srcp2)[0];\n      srcp1 += 2 * (sizeof (unsigned long int));\n      srcp2 += 1 * (sizeof (unsigned long int));\n      len -= 1;\n      if (16 <= 3 * (sizeof (unsigned long int)) && len == 0)\n        goto do0;\n    }\n  do\n    {\n      a0 = ((unsigned long int *) srcp1)[0];\n      b0 = ((unsigned long int *) srcp2)[0];\n      x = (((a2) >> (shl)) | ((a3) << (shr)));\n      if (x != b3)\n        return mymemcmp1 ((x), (b3));\n    do3:\n      a1 = ((unsigned long int *) srcp1)[1];\n      b1 = ((unsigned long int *) srcp2)[1];\n      x = (((a3) >> (shl)) | ((a0) << (shr)));\n      if (x != b0)\n        return mymemcmp1 ((x), (b0));\n    do2:\n      a2 = ((unsigned long int *) srcp1)[2];\n      b2 = ((unsigned long int *) srcp2)[2];\n      x = (((a0) >> (shl)) | ((a1) << (shr)));\n      if (x != b1)\n        return mymemcmp1 ((x), (b1));\n    do1:\n      a3 = ((unsigned long int *) srcp1)[3];\n      b3 = ((unsigned long int *) srcp2)[3];\n      x = (((a1) >> (shl)) | ((a2) << (shr)));\n      if (x != b2)\n        return mymemcmp1 ((x), (b2));\n      srcp1 += 4 * (sizeof (unsigned long int));\n      srcp2 += 4 * (sizeof (unsigned long int));\n      len -= 4;\n    }\n  while (len != 0);\ndo0:\n  x = (((a2) >> (shl)) | ((a3) << (shr)));\n  if (x != b3)\n    return mymemcmp1 ((x), (b3));\n  return 0;\n}\n\n__attribute__ ((noinline))\nint mymemcmp (const void *s1, const void *s2, size_t len)\n{\n  unsigned long int a0;\n  unsigned long int b0;\n  long int srcp1 = (long int) s1;\n  long int srcp2 = (long int) s2;\n  if (srcp1 % (sizeof (unsigned long int)) == 0)\n    return mymemcmp2 (srcp1, srcp2, len / (sizeof (unsigned long int)));\n  else\n    return mymemcmp3 (srcp1, srcp2, len / (sizeof (unsigned long int)));\n}\n\nchar buf[256];\n\nint\nmain (void)\n{\n  char *p;\n  union { long int l; char c[sizeof (long int)]; } u;\n\n  /* The test above assumes little endian and long being the same size\n     as pointer.  */\n  if (sizeof (long int) != sizeof (void *) || sizeof (long int) < 4)\n    return 0;\n  u.l = 0x12345678L;\n  if (u.c[0] != 0x78 || u.c[1] != 0x56 || u.c[2] != 0x34 || u.c[3] != 0x12)\n    return 0;\n\n  p = buf + 16 - (((long int) buf) & 15);\n  __builtin_memcpy (p + 9,\n\"\\x1\\x37\\x82\\xa7\\x55\\x49\\x9d\\xbf\\xf8\\x44\\xb6\\x55\\x17\\x8e\\xf9\", 15);\n  __builtin_memcpy (p + 128 + 24,\n\"\\x1\\x37\\x82\\xa7\\x55\\x49\\xd0\\xf3\\xb7\\x2a\\x6d\\x23\\x71\\x49\\x6a\", 15);\n  if (mymemcmp (p + 9, p + 128 + 24, 33) != -51)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38151.c",
    "content": "/* { dg-options \"-Wno-psabi\" } */\n/* { dg-require-effective-target int32plus } */\nvoid abort (void);\n\nstruct S2848\n{\n  unsigned int a;\n  _Complex int b;\n  struct\n  {\n  } __attribute__ ((aligned)) c;\n};\n\nstruct S2848 s2848;\n\nint fails;\n\nvoid  __attribute__((noinline))\ncheck2848va (int z, ...)\n{\n  struct S2848 arg;\n  __builtin_va_list ap;\n\n  __builtin_va_start (ap, z);\n\n  arg = __builtin_va_arg (ap, struct S2848);\n\n  if (s2848.a != arg.a)\n    ++fails;\n  if (s2848.b != arg.b)\n    ++fails;\n\n  __builtin_va_end (ap);\n}\n\nint main (void)\n{\n  s2848.a = 4027477739U;\n  s2848.b = (723419448 + -218144346 * __extension__ 1i);\n\n  check2848va (1, s2848);\n\n  if (fails)\n    abort ();\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38212.c",
    "content": "int __attribute__((noinline))\nfoo (int *__restrict p, int i)\n{\n  int *__restrict q;\n  int *__restrict r;\n  int v, w;\n  q = p + 1;\n  r = q - i;\n  v = *r;\n  *p = 1;\n  w = *r;\n  return v + w;\n}\nextern void abort (void);\nint main()\n{\n  int i = 0;\n  if (foo (&i, 1) != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38236.c",
    "content": "struct X { int i; };\n\nint __attribute__((noinline))\nfoo (struct X *p, int *q, int a, int b)\n{\n  struct X x, y;\n  if (a)\n    p = &x;\n  if (b)\n    q = &x.i;\n  else\n    q = &y.i;\n  *q = 1;\n  return p->i; \n}\nextern void abort (void);\nint main()\n{\n  if (foo((void *)0, (void *)0, 1, 1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38422.c",
    "content": "/* PR middle-end/38422 */\n\nextern void abort (void);\n\nstruct S\n{\n  int s : (sizeof (int) * __CHAR_BIT__ - 2);\n} s;\n\nvoid\nfoo (void)\n{\n  s.s *= 2;\n}\n\nint\nmain ()\n{\n  s.s = 24;\n  foo ();\n  if (s.s != 48)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38533.c",
    "content": "/* PR middle-end/38533 */\n\n#define A asm volatile (\"\" : \"=r\" (f) : \"0\" (0)); e |= f;\n#define B A A A A A A A A A A A\n#define C B B B B B B B B B B B\n\nint\nfoo (void)\n{\n  int e = 0, f;\n  C C B B B B B A A A A A A\n  return e;\n}\n\nint\nmain (void)\n{\n  if (foo ())\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38819.c",
    "content": "extern void exit (int);\nextern void abort (void);\n\nvolatile int a = 1;\nvolatile int b = 0;\nvolatile int x = 2;\nvolatile signed int r = 8;\n\nvoid __attribute__((noinline))\nfoo (void)\n{\n  exit (0);\n}\n\nint\nmain (void)\n{\n  int si1 = a;\n  int si2 = b;\n  int i;\n\n  for (i = 0; i < 100; ++i) {\n      foo ();\n      if (x == 8)\n\ti++;\n      r += i + si1 % si2;\n  }\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr38969.c",
    "content": "__complex__ float\n__attribute__ ((noinline)) foo (__complex__ float x)\n{\n  return x;\n}\n\n__complex__ float\n__attribute__ ((noinline)) bar (__complex__ float x)\n{\n  return foo (x);\n}\n\nint main()\n{\n  __complex__ float a, b;\n  __real__ a = 9;\n  __imag__ a = 42;\n\n  b = bar (a);\n\n  if (a != b)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39100.c",
    "content": "/* Bad PTA results (incorrect store handling) was causing us to delete\n   *na = 0 store.  */\n\ntypedef struct E\n{\n  int p;\n  struct E *n;\n} *EP;   \n\ntypedef struct C\n{\n  EP x;\n  short cn, cp; \n} *CP;\n\n__attribute__((noinline)) CP\nfoo (CP h, EP x)\n{\n  EP pl = 0, *pa = &pl;\n  EP nl = 0, *na = &nl;\n  EP n;\n\n  while (x)\n    {\n      n = x->n;   \n      if ((x->p & 1) == 1) \n        {\n          h->cp++;\n          *pa = x;\n          pa = &((*pa)->n);\n        }\n      else\n        {\n          h->cn++;\n          *na = x;\n          na = &((*na)->n);\n        }    \n      x = n;\n    }\n  *pa = nl;\n  *na = 0;\n  h->x = pl;\n  return h;\n}\n\nint\nmain (void)\n{  \n  struct C c = { 0, 0, 0 };\n  struct E e[2] = { { 0, &e[1] }, { 1, 0 } };\n  EP p;\n\n  foo (&c, &e[0]);\n  if (c.cn != 1 || c.cp != 1)\n    __builtin_abort ();\n  if (c.x != &e[1])\n    __builtin_abort ();\n  if (e[1].n != &e[0])\n    __builtin_abort ();\n  if (e[0].n)\n    __builtin_abort ();\n  return 0;  \n}\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39120.c",
    "content": "struct X { int *p; } x;\n\nstruct X __attribute__((noinline))\nfoo(int *p) { struct X x; x.p = p; return x; }\n\nvoid __attribute((noinline))\nbar() { *x.p = 1; }\n\nextern void abort (void);\nint main()\n{\n  int i = 0;\n  x = foo(&i);\n  bar();\n  if (i != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39228.c",
    "content": "/* { dg-add-options ieee } */\n/* { dg-skip-if \"No Inf/NaN support\" { spu-*-* } \"*\" \"\" } */\n\nextern void abort (void);\n\nstatic inline int __attribute__((always_inline)) testf (float b)\n{\n  float c = 1.01f * b;\n\n  return __builtin_isinff (c);\n}\n\nstatic inline int __attribute__((always_inline)) test (double b)\n{\n  double c = 1.01 * b;\n\n  return __builtin_isinf (c);\n}\n\nstatic inline int __attribute__((always_inline)) testl (long double b)\n{\n  long double c = 1.01L * b;\n\n  return __builtin_isinfl (c);\n}\n\nint main()\n{\n  if (testf (__FLT_MAX__) < 1)\n    abort ();\n\n  if (test (__DBL_MAX__) < 1)\n    abort ();\n\n  if (testl (__LDBL_MAX__) < 1)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39233.c",
    "content": "extern void abort (void);\n\n__attribute__((noinline)) void\nfoo (void *p)\n{\n  long l = (long) p;\n  if (l < 0 || l > 6)\n    abort ();\n}\n\nint\nmain ()\n{\n  short i;\n  for (i = 6; i >= 0; i--)\n    foo ((void *) (long) i);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39240.c",
    "content": "/* PR target/39240 */\n\nextern void abort (void);\n\n__attribute__ ((noinline))\nstatic int foo1 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned int bar1 (int x)\n{\n  return foo1 (x + 6);\n}\n\nvolatile unsigned long l1 = (unsigned int) -4;\n\n__attribute__ ((noinline))\nstatic short int foo2 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned short int bar2 (int x)\n{\n  return foo2 (x + 6);\n}\n\nvolatile unsigned long l2 = (unsigned short int) -4;\n\n__attribute__ ((noinline))\nstatic signed char foo3 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nunsigned char bar3 (int x)\n{\n  return foo3 (x + 6);\n}\n\nvolatile unsigned long l3 = (unsigned char) -4;\n\n__attribute__ ((noinline))\nstatic unsigned int foo4 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nint bar4 (int x)\n{\n  return foo4 (x + 6);\n}\n\nvolatile unsigned long l4 = (int) -4;\n\n__attribute__ ((noinline))\nstatic unsigned short int foo5 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nshort int bar5 (int x)\n{\n  return foo5 (x + 6);\n}\n\nvolatile unsigned long l5 = (short int) -4;\n\n__attribute__ ((noinline))\nstatic unsigned char foo6 (int x)\n{\n  return x;\n}\n\n__attribute__ ((noinline))\nsigned char bar6 (int x)\n{\n  return foo6 (x + 6);\n}\n\nvolatile unsigned long l6 = (signed char) -4;\n\nint\nmain (void)\n{\n  if (bar1 (-10) != l1)\n    abort ();\n  if (bar2 (-10) != l2)\n    abort ();\n  if (bar3 (-10) != l3)\n    abort ();\n  if (bar4 (-10) != l4)\n    abort ();\n  if (bar5 (-10) != l5)\n    abort ();\n  if (bar6 (-10) != l6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39339.c",
    "content": "struct C\n{\n  unsigned int c;\n  struct D\n  {\n    unsigned int columns : 4;\n    unsigned int fore : 12;\n    unsigned int back : 6;\n    unsigned int fragment : 1;\n    unsigned int standout : 1;\n    unsigned int underline : 1;\n    unsigned int strikethrough : 1;\n    unsigned int reverse : 1;\n    unsigned int blink : 1;\n    unsigned int half : 1;\n    unsigned int bold : 1;\n    unsigned int invisible : 1;\n    unsigned int pad : 1;\n  } attr;\n};\n\nstruct A\n{\n  struct C *data;\n  unsigned int len;\n};\n\nstruct B\n{\n  struct A *cells;\n  unsigned char soft_wrapped : 1;\n};\n\nstruct E\n{\n  long row, col;\n  struct C defaults;\n};\n\n__attribute__ ((noinline))\nvoid foo (struct E *screen, unsigned int c, int columns, struct B *row)\n{\n  struct D attr;\n  long col;\n  int i;\n  col = screen->col;\n  attr = screen->defaults.attr;\n  attr.columns = columns;\n  row->cells->data[col].c = c;\n  row->cells->data[col].attr = attr;\n  col++;\n  attr.fragment = 1;\n  for (i = 1; i < columns; i++)\n    {\n      row->cells->data[col].c = c;\n      row->cells->data[col].attr = attr;\n      col++;\n    }\n}\n\nint\nmain (void)\n{\n  struct E e = {.row = 5,.col = 0,.defaults =\n      {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} };\n  struct C c[4];\n  struct A a = { c, 4 };\n  struct B b = { &a, 1 };\n  struct D d;\n  __builtin_memset (&c, 0, sizeof c);\n  foo (&e, 65, 2, &b);\n  d = e.defaults.attr;\n  d.columns = 2;\n  if (__builtin_memcmp (&d, &c[0].attr, sizeof d))\n    __builtin_abort ();\n  d.fragment = 1;\n  if (__builtin_memcmp (&d, &c[1].attr, sizeof d))\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr39501.c",
    "content": "/* { dg-options \"-ffast-math\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#define min1(a,b) ((a) < (b) ? (a) : (b))\n#define max1(a,b) ((a) > (b) ? (a) : (b))\n\n#define min2(a,b) ((a) <= (b) ? (a) : (b))\n#define max2(a,b) ((a) >= (b) ? (a) : (b))\n\n#define F(type,n)\t\t\t\t\t\t\\\n  type __attribute__((noinline)) type##_##n(type a, type b)\t\\\n  {\t\t\t\t\t\t\t\t\\\n    return n(a, b);\t\t\t\t\t\t\\\n  }\n\nF(float,min1)\nF(float,min2)\nF(float,max1)\nF(float,max2)\n\nF(double,min1)\nF(double,min2)\nF(double,max1)\nF(double,max2)\n\nint main()\n{\n  if (float_min1(0.f, -1.f) != -1.f) abort();\n  if (float_min1(-1.f, 0.f) != -1.f) abort();\n  if (float_min1(0.f, 1.f)  != 0.f)  abort();\n  if (float_min1(1.f, 0.f)  != 0.f)  abort();\n  if (float_min1(-1.f, 1.f) != -1.f) abort();\n  if (float_min1(1.f, -1.f) != -1.f) abort();\n  \n  if (float_max1(0.f, -1.f) != 0.f)  abort();\n  if (float_max1(-1.f, 0.f) != 0.f)  abort();\n  if (float_max1(0.f, 1.f)  != 1.f)  abort();\n  if (float_max1(1.f, 0.f)  != 1.f)  abort();\n  if (float_max1(-1.f, 1.f) != 1.f)  abort();\n  if (float_max1(1.f, -1.f) != 1.f)  abort();\n  \n  if (float_min2(0.f, -1.f) != -1.f) abort();\n  if (float_min2(-1.f, 0.f) != -1.f) abort();\n  if (float_min2(0.f, 1.f)  != 0.f)  abort();\n  if (float_min2(1.f, 0.f)  != 0.f)  abort();\n  if (float_min2(-1.f, 1.f) != -1.f) abort();\n  if (float_min2(1.f, -1.f) != -1.f) abort();\n  \n  if (float_max2(0.f, -1.f) != 0.f)  abort();\n  if (float_max2(-1.f, 0.f) != 0.f)  abort();\n  if (float_max2(0.f, 1.f)  != 1.f)  abort();\n  if (float_max2(1.f, 0.f)  != 1.f)  abort();\n  if (float_max2(-1.f, 1.f) != 1.f)  abort();\n  if (float_max2(1.f, -1.f) != 1.f)  abort();\n  \n  if (double_min1(0., -1.) != -1.) abort();\n  if (double_min1(-1., 0.) != -1.) abort();\n  if (double_min1(0., 1.)  != 0.)  abort();\n  if (double_min1(1., 0.)  != 0.)  abort();\n  if (double_min1(-1., 1.) != -1.) abort();\n  if (double_min1(1., -1.) != -1.) abort();\n  \n  if (double_max1(0., -1.) != 0.)  abort();\n  if (double_max1(-1., 0.) != 0.)  abort();\n  if (double_max1(0., 1.)  != 1.)  abort();\n  if (double_max1(1., 0.)  != 1.)  abort();\n  if (double_max1(-1., 1.) != 1.)  abort();\n  if (double_max1(1., -1.) != 1.)  abort();\n  \n  if (double_min2(0., -1.) != -1.) abort();\n  if (double_min2(-1., 0.) != -1.) abort();\n  if (double_min2(0., 1.)  != 0.)  abort();\n  if (double_min2(1., 0.)  != 0.)  abort();\n  if (double_min2(-1., 1.) != -1.) abort();\n  if (double_min2(1., -1.) != -1.) abort();\n  \n  if (double_max2(0., -1.) != 0.)  abort();\n  if (double_max2(-1., 0.) != 0.)  abort();\n  if (double_max2(0., 1.)  != 1.)  abort();\n  if (double_max2(1., 0.)  != 1.)  abort();\n  if (double_max2(-1., 1.) != 1.)  abort();\n  if (double_max2(1., -1.) != 1.)  abort();\n  \n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40022.c",
    "content": "extern void abort (void);\n\nstruct A\n{\n  struct A *a;\n};\n\nstruct B\n{\n  struct A *b;\n};\n\n__attribute__((noinline))\nstruct A *\nfoo (struct A *x)\n{\n  asm volatile (\"\" : : \"g\" (x) : \"memory\");\n  return x;\n}\n\n__attribute__((noinline))\nvoid\nbar (struct B *w, struct A *x, struct A *y, struct A *z)\n{\n  struct A **c;\n  c = &w->b;\n  *c = foo (x);\n  while (*c)\n    c = &(*c)->a;\n  *c = foo (y);\n  while (*c)\n    c = &(*c)->a;\n  *c = foo (z);\n}\n\nstruct B d;\nstruct A e, f, g;\n\nint\nmain (void)\n{\n  f.a = &g;\n  bar (&d, &e, &f, 0);\n  if (d.b == 0\n      || d.b->a == 0\n      || d.b->a->a == 0\n      || d.b->a->a->a != 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40057.c",
    "content": "/* PR middle-end/40057 */\n\nextern void abort (void);\n\n__attribute__((noinline)) int\nfoo (unsigned long long x)\n{\n  unsigned long long y = (x >> 31ULL) & 1ULL;\n  if (y == 0ULL)\n    return 0;\n  return -1;\n}\n\n__attribute__((noinline)) int\nbar (long long x)\n{\n  long long y = (x >> 31LL) & 1LL;\n  if (y == 0LL)\n    return 0;\n  return -1;\n}\n\nint\nmain (void)\n{\n  if (sizeof (long long) != 8)\n    return 0;\n  if (foo (0x1682a9aaaULL))\n    abort ();\n  if (!foo (0x1882a9aaaULL))\n    abort ();\n  if (bar (0x1682a9aaaLL))\n    abort ();\n  if (!bar (0x1882a9aaaLL))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40386.c",
    "content": "/* { dg-options \"-fno-ira-share-spill-slots -Wno-shift-overflow\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#define CHAR_BIT 8\n\n#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))\n#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))\n\n#define CHAR_VALUE ((char)0xf234)\n#define SHORT_VALUE ((short)0xf234)\n#define INT_VALUE ((int)0xf234)\n#define LONG_VALUE ((long)0xf2345678L)\n#define LL_VALUE ((long long)0xf2345678abcdef0LL)\n\n#define SHIFT1 4\n#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)\n\nchar c = CHAR_VALUE;\nshort s = SHORT_VALUE;\nint i = INT_VALUE;\nlong l = LONG_VALUE;\nlong long ll = LL_VALUE;\nint shift1 = SHIFT1;\nint shift2 = SHIFT2;\n\nint\nmain ()\n{\n  if (ROR (c, shift1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (c, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, shift1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (s, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, shift1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (i, SHIFT1) != ROR (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, shift1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (l, SHIFT1) != ROR (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, SHIFT1) != ROR (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROR (ll, shift2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROR (ll, SHIFT2) != ROR (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (c, shift1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (c, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, shift1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (s, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, shift1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (i, SHIFT1) != ROL (INT_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, shift1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (l, SHIFT1) != ROL (LONG_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, SHIFT1) != ROL (LL_VALUE, SHIFT1))\n    abort ();\n\n  if (ROL (ll, shift2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  if (ROL (ll, SHIFT2) != ROL (LL_VALUE, SHIFT2))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40404.c",
    "content": "extern void abort (void);\n\n#if (__SIZEOF_INT__ <= 2)\nstruct S {\n  unsigned long ui17 : 17;\n} s;\n#else\nstruct S {\n  unsigned int ui17 : 17;\n} s;\n#endif\nint main()\n{\n  s.ui17 = 0x1ffff;\n  if (s.ui17 >= 0xfffffffeu)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40493.c",
    "content": "extern void abort (void);\n\ntypedef union i386_operand_type\n{\n  struct\n    {\n      unsigned int reg8:1;\n      unsigned int reg16:1;\n      unsigned int reg32:1;\n      unsigned int reg64:1;\n      unsigned int floatreg:1;\n      unsigned int regmmx:1;\n      unsigned int regxmm:1;\n      unsigned int regymm:1;\n      unsigned int control:1;\n      unsigned int debug:1;\n      unsigned int test:1;\n      unsigned int sreg2:1;\n      unsigned int sreg3:1;\n      unsigned int imm1:1;\n      unsigned int imm8:1;\n      unsigned int imm8s:1;\n      unsigned int imm16:1;\n      unsigned int imm32:1;\n      unsigned int imm32s:1;\n      unsigned int imm64:1;\n      unsigned int disp8:1;\n      unsigned int disp16:1;\n      unsigned int disp32:1;\n      unsigned int disp32s:1;\n      unsigned int disp64:1;\n      unsigned int acc:1;\n      unsigned int floatacc:1;\n      unsigned int baseindex:1;\n      unsigned int inoutportreg:1;\n      unsigned int shiftcount:1;\n      unsigned int jumpabsolute:1;\n      unsigned int esseg:1;\n      unsigned int regmem:1;\n      unsigned int mem:1;\n      unsigned int byte:1;\n      unsigned int word:1;\n      unsigned int dword:1;\n      unsigned int fword:1;\n      unsigned int qword:1;\n      unsigned int tbyte:1;\n      unsigned int xmmword:1;\n      unsigned int ymmword:1;\n      unsigned int unspecified:1;\n      unsigned int anysize:1;\n    } bitfield;\n  unsigned int array[2];\n} i386_operand_type;\n\nunsigned int x00, x01, y00, y01;\n\nint main (int argc, char *argv[])\n{\n  i386_operand_type a,b,c,d;\n\n  a.bitfield.reg16 = 1;\n  a.bitfield.imm16 = 0;\n  a.array[1] = 22;\n\n  b = a;\n  x00 = b.array[0];\n  x01 = b.array[1];\n\n  c = b;\n  y00 = c.array[0];\n  y01 = c.array[1];\n\n  d = c;\n  if (d.bitfield.reg16 != 1)\n    abort();\n  if (d.bitfield.imm16 != 0)\n    abort();\n  if (d.array[1] != 22)\n    abort();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40579.c",
    "content": "extern void abort (void);\nstatic char * __attribute__((noinline))\nitos(int num)\n{\n  return (char *)0;\n}\nstatic void __attribute__((noinline))\nfoo(int i, const char *x)\n{\n  if (i >= 4)\n    abort ();\n}\nint main()\n{\n  int x = -__INT_MAX__ + 3;\n  int i;\n\n  for (i = 0; i < 4; ++i)\n    {\n      char *p;\n      --x;\n      p = itos(x);\n      foo(i, p);\n    }\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40657.c",
    "content": "/* Verify that that Thumb-1 epilogue size optimization does not clobber the\n   return value.  */\n\nlong long v = 0x123456789abc;\n\n__attribute__((noinline)) void bar (int *x)\n{\n  asm volatile (\"\" : \"=m\" (x) ::);\n}\n\n__attribute__((noinline)) long long foo()\n{\n  int x;\n  bar(&x);\n  return v;\n}\n\nint main ()\n{\n  if (foo () != v)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40668.c",
    "content": "#if (__SIZEOF_INT__ == 2)\n#define TESTVALUE 0x1234\n#else\n#define TESTVALUE 0x12345678\n#endif\nstatic void\nfoo (unsigned int x, void *p)\n{\n  __builtin_memcpy (p, &x, sizeof x);\n}\n\nvoid\nbar (int type, void *number)\n{\n  switch (type)\n    {\n    case 1:\n      foo (TESTVALUE, number);\n      break;\n    case 7:\n      foo (0, number);\n      break;\n    case 8:\n      foo (0, number);\n      break;\n    case 9:\n      foo (0, number);\n      break;\n    }\n}\n\nint\nmain (void)\n{\n  unsigned int x;\n  bar (1, &x);\n  if (x != TESTVALUE)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr40747.c",
    "content": "/* PR middle-end/40747 */\n\nextern void abort (void);\n\nint\nfoo (int i)\n{\n  return (i < 4 && i >= 0) ? i : 4;\n}\n\nint\nmain ()\n{\n  if (foo (-1) != 4) abort ();\n  if (foo (0) != 0) abort ();\n  if (foo (1) != 1) abort ();\n  if (foo (2) != 2) abort ();\n  if (foo (3) != 3) abort ();\n  if (foo (4) != 4) abort ();\n  if (foo (5) != 4) abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41239.c",
    "content": "/* PR rtl-optimization/41239 */\n\nstruct S\n{\n  short nargs;\n  unsigned long arg[2];\n};\n\nextern void abort (void);\nextern void exit (int);\nextern char fn1 (int, const char *, int, const char *, const char *);\nextern void fn2 (int, ...);\nextern int fn3 (int);\nextern int fn4 (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));\n\nunsigned long\ntest (struct S *x)\n{\n  signed int arg1 = x->arg[0];\n  long int arg2 = x->arg[1];\n\n  if (arg2 == 0)\n    (fn1 (20, \"foo\", 924, __func__, ((void *) 0))\n     ? (fn2 (fn3 (0x2040082), fn4 (\"division by zero\")))\n     : (void) 0);\n\n  return (long int) arg1 / arg2;\n}\n\nint\nmain (void)\n{\n  struct S s = { 2, { 5, 0 } };\n  test (&s);\n  abort ();\n}\n\n__attribute__((noinline)) char\nfn1 (int x, const char *y, int z, const char *w, const char *v)\n{\n  asm volatile (\"\" : : \"r\" (w), \"r\" (v) : \"memory\");\n  asm volatile (\"\" : \"+r\" (x) : \"r\" (y), \"r\" (z) : \"memory\");\n  return x;\n}\n\n__attribute__((noinline)) int\nfn3 (int x)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  return x;\n}\n\n__attribute__((noinline)) int\nfn4 (const char *x, ...)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  return *x;\n}\n\n__attribute__((noinline)) void\nfn2 (int x, ...)\n{\n  asm volatile (\"\" : \"+r\" (x) : : \"memory\");\n  if (x)\n    /* Could be a longjmp or throw too.  */\n    exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41317.c",
    "content": "extern void abort (void);\n\nstruct A\n{\n  int i;\n};\nstruct B\n{\n  struct A a;\n  int j;\n};\n\nstatic void\nfoo (struct B *p)\n{\n  ((struct A *)p)->i = 1;\n}\n\nint main()\n{\n  struct A a;\n  a.i = 0;\n  foo ((struct B *)&a);\n  if (a.i != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41395-1.c",
    "content": "struct VEC_char_base\n{\n  unsigned num;\n  unsigned alloc;\n  short vec[1];\n};\n\nshort __attribute__((noinline))\nfoo (struct VEC_char_base *p, int i)\n{\n  short *q;\n  p->vec[i] = 0;\n  q = &p->vec[8];\n  *q = 1;\n  return p->vec[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);\n  if (foo (p, 8) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41395-2.c",
    "content": "struct VEC_char_base\n{\n  unsigned num;\n  unsigned alloc;\n  union {\n      short vec[1];\n      struct {\n\t  int i;\n\t  int j;\n\t  int k;\n      } a;\n  } u;\n};\n\nshort __attribute__((noinline))\nfoo (struct VEC_char_base *p, int i)\n{\n  short *q;\n  p->u.vec[i] = 0;\n  q = &p->u.vec[16];\n  *q = 1;\n  return p->u.vec[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);\n  if (foo (p, 16) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41463.c",
    "content": "#include <stdlib.h>\n\nunion tree_node;\n\nstruct tree_common \n{\n  int a;\n  long b;\n  long c;\n  void *p;\n  int d;\n};\n\nstruct other_tree\n{\n  struct tree_common common;\n  int arr[14];\n};\n\nstruct tree_vec\n{\n  struct tree_common common;\n  int length;\n  union tree_node *a[1];\n};\n\nunion tree_node\n{\n  struct other_tree othr;\n  struct tree_vec vec;\n};\n\nunion tree_node global;\n\nunion tree_node * __attribute__((noinline))\nfoo (union tree_node *p, int i)\n{\n  union tree_node **q;\n  p->vec.a[i] = (union tree_node *) 0;\n  q = &p->vec.a[1];\n  *q = &global;\n  return p->vec.a[i];\n}\n\nextern void abort (void);\nextern void *malloc (__SIZE_TYPE__);\n\nint\nmain()\n{\n  union tree_node *p = malloc (sizeof (union tree_node));\n  if (foo (p, 1) != &global)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41750.c",
    "content": "/* PR 41750 - IPA-SRA used to pass hash->sgot by value rather than by\n   reference.  */\n\nstruct bfd_link_hash_table\n{\n  int hash;\n};\n\nstruct foo_link_hash_table\n{\n  struct bfd_link_hash_table root;\n  int *dynobj;\n  int *sgot;\n};\n\nstruct foo_link_info\n{\n  struct foo_link_hash_table *hash;\n};\n\nextern void abort (void);\n\nint __attribute__((noinline))\nfoo_create_got_section (int *abfd, struct foo_link_info *info)\n{\n  info->hash->sgot = abfd;\n  return 1;\n}\n\nstatic int *\nget_got (int *abfd, struct foo_link_info *info,\n\t struct foo_link_hash_table *hash)\n{\n  int *got;\n  int *dynobj;\n\n  got = hash->sgot;\n  if (!got)\n    {\n      dynobj = hash->dynobj;\n      if (!dynobj)\n\thash->dynobj = dynobj = abfd;\n      if (!foo_create_got_section (dynobj, info))\n\treturn 0;\n      got = hash->sgot;\n    }\n  return got;\n}\n\nint * __attribute__((noinline,noclone))\nelf64_ia64_check_relocs (int *abfd, struct foo_link_info *info)\n{\n  return get_got (abfd, info, info->hash);\n}\n\nstruct foo_link_info link_info;\nstruct foo_link_hash_table hash;\nint abfd;\n\nint\nmain ()\n{\n  link_info.hash = &hash;\n  if (elf64_ia64_check_relocs (&abfd, &link_info) != &abfd)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41917.c",
    "content": "/* PR rtl-optimization/41917 */\n\nextern void abort (void);\nunsigned int a = 1;\n\nint\nmain (void)\n{\n  unsigned int b, c, d;\n\n  if (sizeof (int) != 4 || (int) 0xc7d24b5e > 0)\n    return 0;\n\n  c = 0xc7d24b5e;\n  d = a | -2;\n  b = (d == 0) ? c : (c % d);\n  if (b != c)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41919.c",
    "content": "extern void abort (void);\n\n#define assert(x) if(!(x)) abort()\n\nstruct S1\n{\n  signed char f0;\n};\n\nint g_23 = 0;\n\nstatic struct S1\nfoo (void)\n{\n  int *l_100 = &g_23;\n  int **l_110 = &l_100;\n  struct S1 l_128 = { 1 };\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  assert (l_100 == &g_23);\n  return l_128;\n}\n\nstatic signed char bar(signed char si1, signed char si2)\n{\n  return (si1 <= 0) ? si1 : (si2 * 2);\n}\nint main (void)\n{\n  struct S1 s = foo();\n  if (bar(0x99 ^ (s.f0 && 1), 1) != -104)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr41935.c",
    "content": "/* PR middle-end/41935 */\n\nextern void abort (void);\n\nlong int\nfoo (int n, int i, int j)\n{\n  typedef int T[n];\n  struct S { int a; T b[n]; };\n  return __builtin_offsetof (struct S, b[i][j]);\n}\n\nint\nmain (void)\n{\n  typedef int T[5];\n  struct S { int a; T b[5]; };\n  if (foo (5, 2, 3)\n      != __builtin_offsetof (struct S, b) + (5 * 2 + 3) * sizeof (int))\n    abort ();\n  if (foo (5, 5, 5)\n      != __builtin_offsetof (struct S, b) + (5 * 5 + 5) * sizeof (int))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42006.c",
    "content": "extern void abort (void);\n\nstatic unsigned int\nmy_add(unsigned int si1, unsigned int si2)\n{\n  return (si1 > (50-si2)) ? si1 : (si1 + si2);\n}\n\nstatic unsigned int\nmy_shift(unsigned int left, unsigned int right)\n{\n  return  (right > 100) ? left : (left >> right);\n}\n\nstatic int func_4(unsigned int p_6)\n{\n  int count = 0;\n  for (p_6 = 1; p_6 < 3; p_6 = my_add(p_6, 1))\n    {\n      if (count++ > 1)\n\tabort ();\n\n      if (my_shift(p_6, p_6))\n\treturn 0;\n    }\n  return 0;\n}\n\nint main(void)\n{\n  func_4(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42142.c",
    "content": "int __attribute__((noinline,noclone))\nsort(int L)\n{\n  int end[2] = { 10, 10, }, i=0, R;\n  while (i<2)\n    {\n      R = end[i];\n      if (L<R)\n        {\n          end[i+1] = 1;\n          end[i] = 10;\n          ++i;\n        }\n      else\n        break;\n    }\n  return i;\n}\nextern void abort (void);\nint main()\n{\n  if (sort (5) != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42154.c",
    "content": "struct A { char x[1]; };\nextern void abort (void);\nvoid __attribute__((noinline,noclone))\nfoo (struct A a)\n{\n  if (a.x[0] != 'a')\n    abort ();\n}\nint main ()\n{\n  struct A a;\n  int i;\n  for (i = 0; i < 1; ++i)\n    a.x[i] = 'a';\n  foo (a);\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42231.c",
    "content": "extern void abort (void);\n\nstatic max;\n\nstatic void __attribute__((noinline)) storemax (int i)\n{\n  if (i > max)\n    max = i;\n}\n\nstatic int CallFunctionRec(int (*fun)(int depth), int depth) {\n  if (!fun(depth)) {\n    return 0;\n  }\n  if (depth < 10) {\n    CallFunctionRec(fun, depth + 1);\n  }\n  return 1;\n}\n\nstatic int CallFunction(int (*fun)(int depth)) {\n  return CallFunctionRec(fun, 1) && !fun(0);\n}\n\nstatic int callback(int depth) {\n  storemax (depth);\n  return depth != 0;\n}\n\nint main() {\n  CallFunction(callback);\n  if (max != 10)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42248.c",
    "content": "typedef struct {\n  _Complex double a;\n  _Complex double b;\n} Scf10;\n\nScf10 g1s;\n\nvoid\ncheck (Scf10 x, _Complex double y)\n{\n  if (x.a != y) __builtin_abort ();\n}\n\nvoid\ninit (Scf10 *p, _Complex double y)\n{\n  p->a = y;\n}\n\nint\nmain ()\n{\n  init (&g1s, (_Complex double)1);\n  check (g1s, (_Complex double)1);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42269-2.c",
    "content": "/* Make sure that language + abi extensions in passing S interoperate.  */\n\nstatic long long __attribute__((noinline))\nfoo (unsigned short s)\n{\n  return (short) s;\n}\n\nunsigned short s = 0xFFFF;\n\nint\nmain (void)\n{\n  return foo (s) + 1 != 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42512.c",
    "content": "extern void abort (void);\n\nshort g_3;\n\nint main (void)\n{\n    int l_2;\n    for (l_2 = -1; l_2 != 0; l_2 = (unsigned char)(l_2 - 1))\n      g_3 |= l_2;\n    if (g_3 != -1)\n      abort ();\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42544.c",
    "content": "/* PR c/42544 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  signed short s = -1;\n  if (sizeof (long long) == sizeof (unsigned int))\n    return 0;\n  if ((unsigned int) s >= 0x100000000ULL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42570.c",
    "content": "typedef unsigned char uint8_t;\nuint8_t foo[1][0];\nextern void abort (void);\nint main()\n{\n  if (sizeof (foo) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42614.c",
    "content": "extern void *malloc(__SIZE_TYPE__);\nextern void abort(void);\nextern void free(void *);\n\ntypedef struct SEntry\n{\n  unsigned char num;\n} TEntry;\n\ntypedef struct STable\n{\n  TEntry data[2];\n} TTable;\n\nTTable *init ()\n{\n  return malloc(sizeof(TTable));\n}\n\nvoid\nexpect_func (int a, unsigned char *b) __attribute__ ((noinline));\n\nstatic inline void\ninlined_wrong (TEntry *entry_p, int flag);\n\nvoid\ninlined_wrong (TEntry *entry_p, int flag)\n{\n  unsigned char index;\n  entry_p->num = 0;\n\n  if (flag == 0)\n    abort();\n\n  for (index = 0; index < 1; index++)\n    entry_p->num++;\n\n  if (!entry_p->num)\n    {\n      abort();\n    }\n}\n\nvoid\nexpect_func (int a, unsigned char *b)\n{\n  if (abs ((a == 0)))\n    abort ();\n  if (abs ((b == 0)))\n    abort ();\n}\n\nint\nmain ()\n{\n  unsigned char index = 0;\n  TTable *table_p = init();\n  TEntry work;\n\n  inlined_wrong (&(table_p->data[1]), 1);\n  expect_func (1, &index);\n  inlined_wrong (&work, 1);\n\n  free (table_p);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42691.c",
    "content": "extern void abort (void);\n\nunion _D_rep\n{\n  unsigned short rep[4];\n  double val;\n};\n\nint add(double* key, double* table)\n{\n  unsigned i = 0;\n  double* deletedEntry = 0;\n  while (1) {\n    double* entry = table + i;\n\n    if (*entry == *key)\n      break;\n\n    union _D_rep _D_inf = {{ 0, 0, 0, 0x7ff0 }};\n    if (*entry != _D_inf.val)\n      abort ();\n\n    union _D_rep _D_inf2 = {{ 0, 0, 0, 0x7ff0 }};\n    if (!_D_inf2.val)\n      deletedEntry = entry;\n\n    i++;\n  }\n  if (deletedEntry)\n    *deletedEntry = 0.0;\n  return 0;\n}\n\nint main ()\n{\n  union _D_rep infinit = {{ 0, 0, 0, 0x7ff0 }};\n  double table[2] = { infinit.val, 23 };\n  double key = 23;\n  int ret = add (&key, table);\n  return ret;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42721.c",
    "content": "/* PR c/42721 */\n\nextern void abort (void);\n\nstatic unsigned long long\nfoo (unsigned long long x, unsigned long long y)\n{\n  return x / y;\n}\n\nstatic int a, b;\n\nint\nmain (void)\n{\n  unsigned long long c = 1;\n  b ^= c && (foo (a, -1ULL) != 1L);\n  if (b != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr42833.c",
    "content": "typedef __INT_LEAST8_TYPE__ int8_t;\ntypedef __UINT_LEAST32_TYPE__ uint32_t;\ntypedef int ssize_t;\ntypedef struct { int8_t v1; int8_t v2; int8_t v3; int8_t v4; } neon_s8;\n\nuint32_t helper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2);\n\nuint32_t\nhelper_neon_rshl_s8 (uint32_t arg1, uint32_t arg2)\n{\n  uint32_t res;\n  neon_s8 vsrc1;\n  neon_s8 vsrc2;\n  neon_s8 vdest;\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.i = (arg1);\n      vsrc1 = conv_u.v;\n    }\n  while (0);\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.i = (arg2);\n      vsrc2 = conv_u.v;\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v1;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = vsrc1.v1 >> (sizeof (vsrc1.v1) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v1) * 8)\n\t{\n\t  vdest.v1 = vsrc1.v1 >> (tmp - 1);\n\t  vdest.v1++;\n\t  vdest.v1 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v1 = (vsrc1.v1 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v1 = vsrc1.v1 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v2;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = vsrc1.v2 >> (sizeof (vsrc1.v2) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v2) * 8)\n\t{\n\t  vdest.v2 = vsrc1.v2 >> (tmp - 1);\n\t  vdest.v2++;\n\t  vdest.v2 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v2 = (vsrc1.v2 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v2 = vsrc1.v2 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v3;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = vsrc1.v3 >> (sizeof (vsrc1.v3) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v3) * 8)\n\t{\n\t  vdest.v3 = vsrc1.v3 >> (tmp - 1);\n\t  vdest.v3++;\n\t  vdest.v3 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v3 = (vsrc1.v3 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v3 = vsrc1.v3 << tmp;\n\t}\n    }\n  while (0);\n  do\n    {\n      int8_t tmp;\n      tmp = (int8_t) vsrc2.v4;\n      if (tmp >= (ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = 0;\n\t}\n      else if (tmp < -(ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = vsrc1.v4 >> (sizeof (vsrc1.v4) * 8 - 1);\n\t}\n      else if (tmp == -(ssize_t) sizeof (vsrc1.v4) * 8)\n\t{\n\t  vdest.v4 = vsrc1.v4 >> (tmp - 1);\n\t  vdest.v4++;\n\t  vdest.v4 >>= 1;\n\t}\n      else if (tmp < 0)\n\t{\n\t  vdest.v4 = (vsrc1.v4 + (1 << (-1 - tmp))) >> -tmp;\n\t}\n      else\n\t{\n\t  vdest.v4 = vsrc1.v4 << tmp;\n\t}\n    }\n  while (0);;\n  do\n    {\n      union\n      {\n\tneon_s8 v;\n\tuint32_t i;\n      } conv_u;\n      conv_u.v = (vdest);\n      res = conv_u.i;\n    }\n  while (0);\n  return res;\n}\n\nextern void abort(void);\n\nint main()\n{\n  uint32_t r = helper_neon_rshl_s8 (0x05050505, 0x01010101);\n  if (r != 0x0a0a0a0a)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43008.c",
    "content": "int i;\nstruct X {\n  int *p;\n};\nstruct X * __attribute__((malloc))\nmy_alloc (void)\n{\n  struct X *p = __builtin_malloc (sizeof (struct X));\n  p->p = &i;\n  return p;\n}\nextern void abort (void);\nint main()\n{\n  struct X *p, *q;\n  p = my_alloc ();\n  q = my_alloc ();\n  *(p->p) = 1;\n  *(q->p) = 0;\n  if (*(p->p) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43220.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-require-effective-target alloca } */\n\nvoid *volatile p;\n\nint\nmain (void)\n{\n  int n = 0;\nlab:;\n    {\n      int x[n % 1000 + 1];\n      x[0] = 1;\n      x[n % 1000] = 2;\n      p = x;\n      n++;\n    }\n\n    {\n      int x[n % 1000 + 1];\n      x[0] = 1;\n      x[n % 1000] = 2;\n      p = x;\n      n++;\n    }\n\n  if (n < 1000000)\n    goto lab;\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43236.c",
    "content": "/* { dg-options \"-ftree-loop-distribution\" } */\nextern void abort(void);\nextern void *memset(void *s, int c, __SIZE_TYPE__ n);\nextern int memcmp(const void *s1, const void *s2, __SIZE_TYPE__ n);\n/*extern int printf(const char *format, ...);*/\n\nint main()\n{\n  char A[30], B[30], C[30];\n  int i;\n\n  /* prepare arrays */\n  memset(A, 1, 30);\n  memset(B, 1, 30);\n\n  for (i = 20; i-- > 10;) {\n    A[i] = 0;\n    B[i] = 0;\n  }\n\n  /* expected result */\n  memset(C, 1, 30);\n  memset(C + 10, 0, 10);\n\n  /* show result */\n/*  for (i = 0; i < 30; i++)\n    printf(\"%d %d %d\\n\", A[i], B[i], C[i]); */\n\n  /* compare results */\n  if (memcmp(A, C, 30) || memcmp(B, C, 30)) abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43269.c",
    "content": "int g_21;\nint g_211;\nint g_261;\n\nstatic void __attribute__((noinline,noclone))\nfunc_32 (int b)\n{\n  if (b) {\nlbl_370:\n      g_21 = 1;\n  }\n\n  for (g_261 = -1; g_261 > -2; g_261--) {\n      if (g_211 + 1) {\n\t  return;\n      } else {\n\t  g_21 = 1;\n\t  goto lbl_370;\n      }\n  }\n}\n\nextern void abort (void);\n\nint main(void)\n{\n  func_32(0);\n  if (g_261 != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43385.c",
    "content": "/* PR c/43385 */\n\nextern void abort (void);\n\nint e;\n\n__attribute__((noinline)) void\nfoo (int x, int y)\n{\n  if (__builtin_expect (x, 0) && y != 0)\n    e++;\n}\n\n__attribute__((noinline)) int\nbar (int x, int y)\n{\n  if (__builtin_expect (x, 0) && y != 0)\n    return 1;\n  else\n    return 0;\n}\n\nint\nmain (void)\n{\n  int z = 0;\n  asm (\"\" : \"+r\" (z));\n  foo (z + 2, z + 1);\n  if (e != 1)\n    abort ();\n  foo (z + 2, z);\n  if (e != 1)\n    abort ();\n  foo (z + 1, z + 1);\n  if (e != 2)\n    abort ();\n  foo (z + 1, z);\n  if (e != 2)\n    abort ();\n  foo (z, z + 1);\n  if (e != 2)\n    abort ();\n  foo (z, z);\n  if (e != 2)\n    abort ();\n  if (bar (z + 2, z + 1) != 1)\n    abort ();\n  if (bar (z + 2, z) != 0)\n    abort ();\n  if (bar (z + 1, z + 1) != 1)\n    abort ();\n  if (bar (z + 1, z) != 0)\n    abort ();\n  if (bar (z, z + 1) != 0)\n    abort ();\n  if (bar (z, z) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43438.c",
    "content": "extern void abort (void);\n\nstatic unsigned char g_2 = 1;\nstatic int g_9;\nstatic int *l_8 = &g_9;\n\nstatic void func_12(int p_13)\n{\n  int * l_17 = &g_9;\n  *l_17 &= 0 < p_13;\n}\n\nint main(void)\n{\n  unsigned char l_11 = 254;\n  *l_8 |= g_2;\n  l_11 |= *l_8;\n  func_12(l_11);\n  if (g_9 != 1)\n    abort ();\n  return 0;\n} \n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43560.c",
    "content": "/* PR tree-optimization/43560 */\n\nstruct S\n{\n  int a, b;\n  char c[10];\n};\n\n__attribute__ ((noinline)) void\ntest (struct S *x)\n{\n  while (x->b > 1 && x->c[x->b - 1] == '/')\n    {\n      x->b--;\n      x->c[x->b] = '\\0';\n    }\n}\n\nconst struct S s = { 0, 0, \"\" };\n\nint\nmain ()\n{\n  struct S *p;\n  asm (\"\" : \"=r\" (p) : \"0\" (&s));\n  test (p);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43629.c",
    "content": "int flag;\nextern void abort (void);\nint main()\n{\n  int x;\n  if (flag)\n    x = -1;\n  else \n    x &= 0xff;\n  if (x & ~0xff)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43783.c",
    "content": "typedef __attribute__((aligned(16)))\nstruct {\n  unsigned long long w[3];\n} UINT192;\n\nUINT192 bid_Kx192[32];\n\nextern void abort (void);\n\nint main()\n{\n  int i = 0;\n  unsigned long x = 0;\n  for (i = 0; i < 32; ++i)\n    bid_Kx192[i].w[1] = i == 1;\n  for (i = 0; i < 32; ++i)\n    x += bid_Kx192[1].w[1];\n  if (x != 32)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43784.c",
    "content": "struct s {\n  unsigned char a[256];\n};\nunion u {\n  struct { struct s b; int c; } d;\n  struct { int c; struct s b; } e;\n};\n\nstatic union u v;\nstatic struct s *p = &v.d.b;\nstatic struct s *q = &v.e.b;\n\nstatic struct s __attribute__((noinline)) rp(void)\n{\n  return *p;\n}\n\nstatic void qp(void)\n{\n  *q = rp();\n}\n\nint main()\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    p->a[i] = i;\n  qp();\n  for (i = 0; i < 256; i++)\n    if (q->a[i] != i)\n      __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43835.c",
    "content": "struct PMC {\n    unsigned flags;\n};\n\ntypedef struct Pcc_cell\n{\n    struct PMC *p;\n    long bla;\n    long type;\n} Pcc_cell;\n\nextern void abort ();\nextern void Parrot_gc_mark_PMC_alive_fun(int * interp, struct PMC *pmc)\n     __attribute__((noinline));\n\nvoid Parrot_gc_mark_PMC_alive_fun (int * interp, struct PMC *pmc)\n{\n  abort ();\n}\n\nstatic void mark_cell(int * interp, Pcc_cell *c)\n        __attribute__((__nonnull__(1)))\n        __attribute__((__nonnull__(2)))\n        __attribute__((noinline));\n\nstatic void\nmark_cell(int * interp, Pcc_cell *c)\n{\n            if (c->type == 4 && c->p\n\t\t&& !(c->p->flags & (1<<18)))\n\t      Parrot_gc_mark_PMC_alive_fun(interp, c->p);\n}\n\nvoid foo(int * interp, Pcc_cell *c);\n\nvoid\nfoo(int * interp, Pcc_cell *c)\n{\n  mark_cell(interp, c);\n}\n\nint main()\n{\n  int i;\n  Pcc_cell c;\n  c.p = 0;\n  c.bla = 42;\n  c.type = 4;\n  foo (&i, &c);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr43987.c",
    "content": "char B[256 * sizeof(void *)];\ntypedef void *FILE;\ntypedef struct globals {\n    int c;\n    FILE *l;\n} __attribute__((may_alias)) T;\nvoid add_input_file(FILE *file)\n{\n  (*(T*)&B).l[0] = file;\n}\nextern void abort (void);\nint main()\n{\n  FILE x;\n  (*(T*)&B).l = &x;\n  add_input_file ((void *)-1);\n  if ((*(T*)&B).l[0] != (void *)-1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44164.c",
    "content": "struct X {\n    struct Y {\n\tstruct YY {\n\t    struct Z {\n\t\tint i;\n\t    } c;\n\t} bb;\n    } b;\n} a;\nint __attribute__((noinline, noclone))\nfoo (struct Z *p)\n{\n  int i = p->i;\n  a.b = (struct Y){};\n  return p->i + i;\n}\nextern void abort (void);\nint main()\n{\n  a.b.bb.c.i = 1;\n  if (foo (&a.b.bb.c) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44202-1.c",
    "content": "extern __attribute__ ((__noreturn__)) void exit(int);\nextern __attribute__ ((__noreturn__)) void abort(void);\n__attribute__ ((__noinline__))\nint\nadd512(int a, int *b)\n{\n  int c = a + 512;\n  if (c != 0)\n    *b = a;\n  return c;\n}\n\n__attribute__ ((__noinline__))\nint\nadd513(int a, int *b)\n{\n  int c = a + 513;\n  if (c == 0)\n    *b = a;\n  return c;\n}\n\nint main(void)\n{\n  int b0 = -1;\n  int b1 = -1;\n  if (add512(-512, &b0) != 0 || b0 != -1 || add513(-513, &b1) != 0 || b1 != -513)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44468.c",
    "content": "#include <stddef.h>\n\nstruct S {\n  int i;\n  int j;\n};\nstruct R {\n  int k;\n  struct S a;\n};\nstruct Q {\n  float k;\n  struct S a;\n};\nstruct Q s;\nint __attribute__((noinline,noclone))\ntest1 (void *q)\n{\n  struct S *b = (struct S *)((char *)q + sizeof (int));\n  s.a.i = 0;\n  b->i = 3;\n  return s.a.i;\n}\nint __attribute__((noinline,noclone))\ntest2 (void *q)\n{\n  struct S *b = &((struct R *)q)->a;\n  s.a.i = 0;\n  b->i = 3;\n  return s.a.i;\n}\nint __attribute__((noinline,noclone))\ntest3 (void *q)\n{\n  s.a.i = 0;\n  ((struct S *)((char *)q + sizeof (int)))->i = 3;\n  return s.a.i;\n}\nextern void abort (void);\nint\nmain()\n{\n  if (sizeof (float) != sizeof (int)\n      || offsetof (struct R, a) != sizeof (int)\n      || offsetof (struct Q, a) != sizeof (int))\n    return 0;\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test1 ((void *)&s) != 3)\n    abort ();\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test2 ((void *)&s) != 3)\n    abort ();\n  s.a.i = 1;\n  s.a.j = 2;\n  if (test3 ((void *)&s) != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44555.c",
    "content": "struct a {\n    char b[100];\n};\nint foo(struct a *a)\n{\n  if (&a->b)\n    return 1;\n  return 0;\n}\nextern void abort (void);\nint main()\n{\n  if (foo((struct a *)0) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44575.c",
    "content": "/* PR target/44575 */\n\n#include <stdarg.h>\n\nint fails = 0;\nstruct S { float a[3]; };\nstruct S a[5];\n\nvoid\ncheck (int z, ...)\n{\n  struct S arg, *p;\n  va_list ap;\n  int j = 0, k = 0;\n  int i;\n  va_start (ap, z);\n  for (i = 2; i < 4; ++i)\n    {\n      p = 0;\n      j++;\n      k += 2;\n      switch ((z << 4) | i)\n\t{\n\tcase 0x12:\n\tcase 0x13:\n\t  p = &a[2];\n\t  arg = va_arg (ap, struct S);\n\t  break;\n\tdefault:\n\t  ++fails;\n\t  break;\n\t}\n      if (p && p->a[2] != arg.a[2])\n\t++fails;\n      if (fails)\n\tbreak;\n    }\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  a[2].a[2] = -49026;\n  check (1, a[2], a[2]);\n  if (fails)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44683.c",
    "content": "int __attribute__((noinline,noclone))\ncopysign_bug (double x)\n{\n  if (x != 0.0 && (x * 0.5 == x))\n    return 1;\n  if (__builtin_copysign(1.0, x) < 0.0)\n    return 2;\n  else\n    return 3;\n}\nint main(void)\n{\n  double x = -0.0;\n  if (copysign_bug (x) != 2)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44828.c",
    "content": "extern void abort (void);\n\nstatic signed char\nfoo (signed char si1, signed char si2)\n{\n  return si1 * si2;\n}\n\nint a = 0x105F61CA;\n\nint\nmain (void)\n{\n  int b = 0x0332F5C8;\n  if (foo (b, a) > 0)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44852.c",
    "content": "__attribute__ ((__noinline__))\nchar *sf(char *s, char *s0)\n{\n  asm (\"\");\n  while (*--s == '9')\n    if (s == s0)\n      {\n\t*s = '0';\n\tbreak;\n      }\n  ++*s++;\n  return s;\n}\n\nint main()\n{\n  char s[] = \"999999\";\n  char *x = sf (s+2, s);\n  if (x != s+1 || __builtin_strcmp (s, \"199999\") != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44858.c",
    "content": "/* PR rtl-optimization/44858 */\n\nextern void abort (void);\nint a = 3;\nint b = 1;\n\n__attribute__((noinline)) long long\nfoo (int x, int y)\n{\n  return x / y;\n}\n\n__attribute__((noinline)) int\nbar (void)\n{\n  int c = 2;\n  c &= foo (1, b) > b;\n  b = (a != 0) | c;\n  return c;\n}\n\nint\nmain (void)\n{\n  if (bar () != 0 || b != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr44942.c",
    "content": "/* PR target/44942 */\n\n#include <stdarg.h>\n\nvoid\ntest1 (int a, int b, int c, int d, int e, int f, int g, long double h, ...)\n{\n  int i;\n  va_list ap;\n\n  va_start (ap, h);\n  i = va_arg (ap, int);\n  if (i != 1234)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest2 (int a, int b, int c, int d, int e, int f, int g, long double h, int i,\n       long double j, int k, long double l, int m, long double n, ...)\n{\n  int o;\n  va_list ap;\n\n  va_start (ap, n);\n  o = va_arg (ap, int);\n  if (o != 1234)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest3 (double a, double b, double c, double d, double e, double f,\n       double g, long double h, ...)\n{\n  double i;\n  va_list ap;\n\n  va_start (ap, h);\n  i = va_arg (ap, double);\n  if (i != 1234.0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nvoid\ntest4 (double a, double b, double c, double d, double e, double f, double g,\n       long double h, double i, long double j, double k, long double l,\n       double m, long double n, ...)\n{\n  double o;\n  va_list ap;\n\n  va_start (ap, n);\n  o = va_arg (ap, double);\n  if (o != 1234.0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  test1 (0, 0, 0, 0, 0, 0, 0, 0.0L, 1234);\n  test2 (0, 0, 0, 0, 0, 0, 0, 0.0L, 0, 0.0L, 0, 0.0L, 0, 0.0L, 1234);\n  test3 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 1234.0);\n  test4 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0L, 0.0, 0.0L,\n\t 0.0, 0.0L, 0.0, 0.0L, 1234.0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr45034.c",
    "content": "extern void abort (void);\nstatic void fixnum_neg(signed char x, signed char *py, int *pv)\n{\n  unsigned char ux, uy;\n\n  ux = (unsigned char)x;\n  uy = -ux;\n  *py = (uy <= 127) ? (signed char)uy : (-(signed char)(255 - uy) - 1);\n  *pv = (x == -128) ? 1 : 0;\n}\n\nvoid __attribute__((noinline)) foo(int x, int y, int v)\n{\n  if (y < -128 || y > 127)\n    abort();\n}\n\nint test_neg(void)\n{\n  signed char x, y;\n  int v, err;\n\n  err = 0;\n  x = -128;\n  for (;;) {\n      fixnum_neg(x, &y, &v);\n      foo((int)x, (int)y, v);\n      if ((v && x != -128) || (!v && x == -128))\n\t++err;\n      if (x == 127)\n\tbreak;\n      ++x;\n  }\n  return err;\n}\n\nint main(void)\n{\n  if (sizeof (char) != 1)\n    return 0;\n  if (test_neg() != 0)\n    abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr45070.c",
    "content": "/* PR45070 */\nextern void abort(void);\n\nstruct packed_ushort {\n    unsigned short ucs;\n} __attribute__((packed));\n\nstruct source {\n    int pos, length;\n    int flag;\n};\n\nstatic void __attribute__((noinline)) fetch(struct source *p)\n{\n    p->length = 128;\n}\n    \nstatic struct packed_ushort __attribute__((noinline)) next(struct source *p)\n{\n    struct packed_ushort rv;\n\n    if (p->pos >= p->length) {\n\tif (p->flag) {\n\t    p->flag = 0;\n\t    fetch(p);\n\t    return next(p);\n\t}\n\tp->flag = 1;\n\trv.ucs = 0xffff;\n\treturn rv;\n    }\n    rv.ucs = 0;\n    return rv;\n}\n\nint main(void)\n{\n    struct source s;\n    int i;\n\n    s.pos = 0;\n    s.length = 0;\n    s.flag = 0;\n\n    for (i = 0; i < 16; i++) {\n\tstruct packed_ushort rv = next(&s);\n\tif ((i == 0 && rv.ucs != 0xffff)\n\t    || (i > 0 && rv.ucs != 0))\n\t    abort();\n    }\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr45262.c",
    "content": "/* PR middle-end/45262 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nint\nfoo (unsigned int x)\n{\n  return ((int) x < 0) || ((int) (-x) < 0);\n}\n\nint\nbar (unsigned int x)\n{\n  return x >> 31 || (-x) >> 31;\n}\n\nint\nmain (void)\n{\n  if (foo (1) != 1)\n    abort ();\n  if (foo (0) != 0)\n    abort ();\n  if (foo (-1) != 1)\n    abort ();\n  if (bar (1) != 1)\n    abort ();\n  if (bar (0) != 0)\n    abort ();\n  if (bar (-1) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr45695.c",
    "content": "/* PR rtl-optimization/45695 */\n\nextern void abort (void);\n\n__attribute__((noinline)) void\ng (int x)\n{\n  asm volatile (\"\" : \"+r\" (x));\n}\n\n__attribute__((noinline)) int\nf (int a, int b, int d)\n{\n  int r = -1;\n  b += d;\n  if (d == a)\n    r = b - d;\n  g (b);\n  return r;\n}\n\nint\nmain (void)\n{\n  int l;\n  asm (\"\" : \"=r\" (l) : \"0\" (0));\n  if (f (l + 0, l + 1, l + 4) != -1)\n    abort ();\n  if (f (l + 4, l + 1, l + 4) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr46019.c",
    "content": "/* PR middle-end/46019 */\n\nextern void abort (void);\n\nint\nmain (void)\n{\n  unsigned long long l = 0x40000000000ULL;\n  int n;\n  for (n = 0; n < 8; n++)\n    if (l / (0x200000000ULL << n) != (0x200 >> n))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr46309.c",
    "content": "/* PR tree-optimization/46309 */\n\nextern void abort (void);\n\nunsigned int *q;\n\n__attribute__((noinline, noclone)) void\nbar (unsigned int *p)\n{\n  if (*p != 2 && *p != 3)\n    (!(!(*q & 263) || *p != 1)) ? abort () : 0;\n}\n\nint\nmain ()\n{\n  unsigned int x, y;\n  asm volatile (\"\" : : : \"memory\");\n  x = 2;\n  bar (&x);\n  x = 3;\n  bar (&x);\n  y = 1;\n  x = 0;\n  q = &y;\n  bar (&x);\n  y = 0;\n  x = 1;\n  bar (&x);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr46316.c",
    "content": "extern void abort (void);\n\nlong long __attribute__((noinline,noclone))\nfoo (long long t)\n{\n  while (t > -4)\n    t -= 2;\n\n  return t;\n}\n\nint main(void)\n{\n  if (foo (0) != -4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr46909-1.c",
    "content": "/* PR tree-optimization/46909 */\n\nextern void abort ();\n\nint\n__attribute__ ((__noinline__))\nfoo (unsigned int x)\n{\n  if (! (x == 4 || x == 6) || (x == 2 || x == 6))\n    return 1;\n  return -1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = -10; i < 10; i++)\n    if (foo (i) != 1 - 2 * (i == 4))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr46909-2.c",
    "content": "/* PR tree-optimization/46909 */\n\nextern void abort (void);\n\nint\n__attribute__((noinline))\nfoo (int x)\n{\n  if ((x != 0 && x != 13) || x == 5 || x == 20)\n    return 1;\n  return -1;\n}\n\nint\nmain (void)\n{\n  int i;\n  for (i = -10; i < 30; i++)\n    if (foo (i) != 1 - 2 * (i == 0) - 2 * (i == 13))\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47148.c",
    "content": "/* PR tree-optimization/47148 */\n\nstatic inline unsigned\nbar (unsigned x, unsigned y)\n{\n  if (y >= 32)\n    return x;\n  else\n    return x >> y;\n}\n\nstatic unsigned a = 1, b = 1;\n\nstatic inline void\nfoo (unsigned char x, unsigned y)\n{\n  if (!y)\n    return;\n  unsigned c = (0x7000U / (x - 2)) ^ a;\n  unsigned d = bar (a, a);\n  b &= ((a - d) && (a - 1)) + c;\n}\n\nint\nmain (void)\n{\n  foo (1, 1);\n  foo (-1, 1);\n  if (b && ((unsigned char) -1) == 255)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47155.c",
    "content": "/* PR tree-optimization/47155 */\n\nunsigned int a;\nstatic signed char b = -127;\nint c = 1;\n\nint\nmain (void)\n{\n  a = b <= (unsigned char) (-6 * c);\n  if (!a)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47237.c",
    "content": "/* { dg-xfail-if \"can cause stack underflow\" { nios2-*-* } \"*\" \"\" } */\n/* { dg-require-effective-target untyped_assembly } */\n#define INTEGER_ARG  5\n\nextern void abort(void);\n\nstatic void foo(int arg)\n{\n  if (arg != INTEGER_ARG)\n    abort();\n}\n\nstatic void bar(int arg)\n{\n  foo(arg);\n  __builtin_apply(foo, __builtin_apply_args(), 16);\n}\n\nint main(void)\n{\n  bar(INTEGER_ARG);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47299.c",
    "content": "/* PR rtl-optimization/47299 */\n\nextern void abort (void);\n\n__attribute__ ((noinline, noclone)) unsigned short\nfoo (unsigned char x)\n{\n  return x * 255;\n}\n\nint\nmain ()\n{\n  if (foo (0x40) != 0x3fc0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47337.c",
    "content": "/* PR rtl-optimization/47337 */\n\nstatic unsigned int a[256], b = 0;\nstatic char c = 0;\nstatic int d = 0, *f = &d;\nstatic long long e = 0;\n\nstatic short\nfoo (long long x, long long y)\n{\n  return x / y;\n}\n\nstatic char\nbar (char x, char y)\n{\n  return x - y;\n}\n\nstatic int\nbaz (int x, int y)\n{\n  *f = (y != (short) (y * 3));\n  for (c = 0; c < 2; c++)\n    {\n    lab:\n      if (d)\n\t{\n\t  if (e)\n\t    e = 1;\n\t  else\n\t    return x;\n\t}\n      else\n\t{\n\t  d = 1;\n\t  goto lab;\n\t}\n      f = &d;\n    }\n  return x;\n}\n\nstatic void\nfnx (unsigned long long x, int y)\n{\n  if (!y)\n    {\n      b = a[b & 1];\n      b = a[b & 1];\n      b = a[(b ^ (x & 1)) & 1];\n      b = a[(b ^ (x & 1)) & 1];\n    }\n}\n\nchar *volatile w = \"2\";\n\nint\nmain ()\n{\n  int h = 0;\n  unsigned int k = 0;\n  int l[8];\n  int i, j;\n\n  if (__builtin_strcmp (w, \"1\") == 0)\n    h = 1;\n\n  for (i = 0; i < 256; i++)\n    {\n      for (j = 8; j > 0; j--)\n\tk = 1;\n      a[i] = k;\n    }\n  for (i = 0; i < 8; i++)\n    l[i] = 0;\n\n  d = bar (c, c);\n  d = baz (c, 1 | foo (l[0], 10));\n  fnx (d, h);\n  fnx (e, h);\n\n  if (d != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47538.c",
    "content": "/* PR tree-optimization/47538 */\n\nstruct S\n{\n  double a, b, *c;\n  unsigned long d;\n};\n\n__attribute__((noinline, noclone)) void\nfoo (struct S *x, const struct S *y)\n{\n  const unsigned long n = y->d + 1;\n  const double m = 0.25 * (y->b - y->a);\n  x->a = y->a;\n  x->b = y->b;\n  if (n == 1)\n    {\n      x->c[0] = 0.;\n    }\n  else if (n == 2)\n    {\n      x->c[1] = m * y->c[0];\n      x->c[0] = 2.0 * x->c[1];\n    }\n  else\n    {\n      double o = 0.0, p = 1.0;\n      unsigned long i;\n\n      for (i = 1; i <= n - 2; i++)\n\t{\n\t  x->c[i] = m * (y->c[i - 1] - y->c[i + 1]) / (double) i;\n\t  o += p * x->c[i];\n\t  p = -p;\n\t}\n      x->c[n - 1] = m * y->c[n - 2] / (n - 1.0);\n      o += p * x->c[n - 1];\n      x->c[0] = 2.0 * o;\n    }\n}\n\nint\nmain (void)\n{\n  struct S x, y;\n  double c[4] = { 10, 20, 30, 40 }, d[4], e[4] = { 118, 118, 118, 118 };\n\n  y.a = 10;\n  y.b = 6;\n  y.c = c;\n  x.c = d;\n  y.d = 3;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 0 || d[1] != 20 || d[2] != 10 || d[3] != -10)\n    __builtin_abort ();\n  y.d = 2;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 60 || d[1] != 20 || d[2] != -10 || d[3] != 118)\n    __builtin_abort ();\n  y.d = 1;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != -20 || d[1] != -10 || d[2] != 118 || d[3] != 118)\n    __builtin_abort ();\n  y.d = 0;\n  __builtin_memcpy (d, e, sizeof d);\n  foo (&x, &y);\n  if (d[0] != 0 || d[1] != 118 || d[2] != 118 || d[3] != 118)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr47925.c",
    "content": "struct s { volatile struct s *next; };\n\nvoid __attribute__((noinline))\nbar (int ignored, int n)\n{\n  asm volatile (\"\");\n}\n\nint __attribute__((noinline))\nfoo (volatile struct s *ptr, int n)\n{\n  int i;\n\n  bar (0, n);\n  for (i = 0; i < n; i++)\n    ptr = ptr->next;\n}\n\nint main (void)\n{\n  volatile struct s rec = { &rec };\n  foo (&rec, 10);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48197.c",
    "content": "/* PR c/48197 */\n\nextern void abort (void);\nstatic int y = 0x8000;\n\nint\nmain ()\n{\n  unsigned int x = (short)y;\n  if (sizeof (0LL) == sizeof (0U))\n    return 0;\n  if (0LL > (0U ^ (short)-0x8000))\n    abort ();\n  if (0LL > (0U ^ x))\n    abort ();\n  if (0LL > (0U ^ (short)y))\n    abort ();\n  if ((0U ^ (short)-0x8000) < 0LL)\n    abort ();\n  if ((0U ^ x) < 0LL)\n    abort ();\n  if ((0U ^ (short)y) < 0LL)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48571-1.c",
    "content": "#define S (sizeof (int))\n\nunsigned int c[624];\nvoid __attribute__((noinline))\nbar (void)\n{\n  unsigned int i;\n  /* Obfuscated c[i] = c[i-1] * 2.  */\n  for (i = 1; i < 624; ++i)\n    *(unsigned int *)((void *)c + (__SIZE_TYPE__)i * S)\n\t= 2 * *(unsigned int *)((void *)c + ((__SIZE_TYPE__)i +\n\t\t\t\t\t     ((__SIZE_TYPE__)-S)/S) * S);\n}\nextern void abort (void);\nint\nmain()\n{\n  unsigned int i, j;\n  for (i = 0; i < 624; ++i)\n    c[i] = 1;\n  bar();\n  j = 1;\n  for (i = 0; i < 624; ++i)\n    {\n      if (c[i] != j)\n\tabort ();\n      j = j * 2;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48717.c",
    "content": "/* PR tree-optimization/48717 */\n\nextern void abort (void);\n\nint v = 1, w;\n\nunsigned short\nfoo (unsigned short x, unsigned short y)\n{\n  return x + y;\n}\n\nvoid\nbar (void)\n{\n  v = foo (~w, w);\n}\n\nint\nmain ()\n{\n  bar ();\n  if (v != (unsigned short) -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48809.c",
    "content": "/* PR tree-optimization/48809 */\n\nextern void abort (void);\n\nint\nfoo (signed char x)\n{\n  int y = 0;\n  switch (x)\n    {\n    case 0: y = 1; break;\n    case 1: y = 7; break;\n    case 2: y = 2; break;\n    case 3: y = 19; break;\n    case 4: y = 5; break;\n    case 5: y = 17; break;\n    case 6: y = 31; break;\n    case 7: y = 8; break;\n    case 8: y = 28; break;\n    case 9: y = 16; break;\n    case 10: y = 31; break;\n    case 11: y = 12; break;\n    case 12: y = 15; break;\n    case 13: y = 111; break;\n    case 14: y = 17; break;\n    case 15: y = 10; break;\n    case 16: y = 31; break;\n    case 17: y = 7; break;\n    case 18: y = 2; break;\n    case 19: y = 19; break;\n    case 20: y = 5; break;\n    case 21: y = 107; break;\n    case 22: y = 31; break;\n    case 23: y = 8; break;\n    case 24: y = 28; break;\n    case 25: y = 106; break;\n    case 26: y = 31; break;\n    case 27: y = 102; break;\n    case 28: y = 105; break;\n    case 29: y = 111; break;\n    case 30: y = 17; break;\n    case 31: y = 10; break;\n    case 32: y = 31; break;\n    case 98: y = 18; break;\n    case -62: y = 19; break;\n    }\n  return y;\n}\n\nint\nmain ()\n{\n  if (foo (98) != 18 || foo (97) != 0 || foo (99) != 0)\n    abort ();\n  if (foo (-62) != 19 || foo (-63) != 0 || foo (-61) != 0)\n    abort ();\n  if (foo (28) != 105 || foo (27) != 102 || foo (29) != 111)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48814-1.c",
    "content": "extern void abort (void);\n\nint arr[] = {1,2,3,4};\nint count = 0;\n\nint __attribute__((noinline))\nincr (void)\n{\n  return ++count;\n}\n\nint main()\n{\n  arr[count++] = incr ();\n  if (count != 2 || arr[count] != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48814-2.c",
    "content": "extern void abort (void);\n\nint arr[] = {1,2,3,4};\nint count = 0;\n\nint\nincr (void)\n{\n  return ++count;\n}\n\nint main()\n{\n  arr[count++] = incr ();\n  if (count != 2 || arr[count] != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c",
    "content": "/* PR middle-end/48973 */\n\nextern void abort (void);\nstruct S { int f : 1; } s;\nint v = -1;\n\nvoid\nfoo (unsigned int x)\n{\n  if (x != -1U)\n    abort ();\n}\n\nint\nmain ()\n{\n  s.f = (v & 1) > 0;\n  foo (s.f);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c",
    "content": "/* PR middle-end/48973 */\n\nextern void abort (void);\nstruct S { int f : 1; } s;\nint v = -1;\n\nint\nmain ()\n{\n  s.f = v < 0;\n  if ((unsigned int) s.f != -1U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49039.c",
    "content": "/* PR tree-optimization/49039 */\nextern void abort (void);\nint cnt;\n\n__attribute__((noinline, noclone)) void\nfoo (unsigned int x, unsigned int y)\n{\n  unsigned int minv, maxv;\n  if (x == 1 || y == -2U)\n    return;\n  minv = x < y ? x : y;\n  maxv = x > y ? x : y;\n  if (minv == 1)\n    ++cnt;\n  if (maxv == -2U)\n    ++cnt;\n}\n\nint\nmain ()\n{\n  foo (-2U, 1);\n  if (cnt != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49073.c",
    "content": "/* PR tree-optimization/49073 */\n\nextern void abort (void);\nint a[] = { 1, 2, 3, 4, 5, 6, 7 }, c;\n\nint\nmain ()\n{\n  int d = 1, i = 1;\n  _Bool f = 0;\n  do\n    {\n      d = a[i];\n      if (f && d == 4)\n\t{\n\t  ++c;\n\t  break;\n\t}\n      i++;\n      f = (d == 3);\n    }\n  while (d < 7);\n  if (c != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49123.c",
    "content": "/* PR lto/49123 */\n\nextern void abort (void);\nstatic struct S { int f : 1; } s;\nstatic int v = -1;\n\nint\nmain ()\n{\n  s.f = v < 0;\n  if ((unsigned int) s.f != -1U)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49161.c",
    "content": "/* PR tree-optimization/49161 */\n\nextern void abort (void);\n\nint c;\n\n__attribute__((noinline, noclone)) void\nbar (int x)\n{\n  if (x != c++)\n    abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  switch (x)\n    {\n    case 3: goto l1;\n    case 4: goto l2;\n    case 6: goto l3;\n    default: return;\n    }\nl1:\n  goto l4;\nl2:\n  goto l4;\nl3:\n  bar (-1);\nl4:\n  bar (0);\n  if (x != 4)\n    bar (1);\n  if (x != 3)\n    bar (-1);\n  bar (2);\n}\n\nint\nmain ()\n{\n  foo (3);\n  if (c != 3)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49186.c",
    "content": "/* PR target/49186 */\nextern void abort (void);\n\nint\nmain ()\n{\n  int x;\n  unsigned long long uv = 0x1000000001ULL;\n\n  x = (uv < 0x80) ? 1 : ((uv < 0x800) ? 2 : 3);\n  if (x != 3)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49218.c",
    "content": "#ifdef __SIZEOF_INT128__\ntypedef __int128 L;\n#else\ntypedef long long L;\n#endif\nfloat f;\n\nint\nmain ()\n{\n  L i = f;\n  if (i <= 10)\n    do\n      {\n\t++i;\n\tasm (\"\");\n      }\n    while (i != 11);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49279.c",
    "content": "/* PR tree-optimization/49279 */\nextern void abort (void);\n\nstruct S { int a; int *__restrict p; };\n\n__attribute__((noinline, noclone))\nstruct S *bar (struct S *p)\n{\n  struct S *r;\n  asm volatile (\"\" : \"=r\" (r) : \"0\" (p) : \"memory\");\n  return r;\n}\n\n__attribute__((noinline, noclone))\nint\nfoo (int *p, int *q)\n{\n  struct S s, *t;\n  s.a = 1;\n  s.p = p;\n  t = bar (&s);\n  t->p = q;\n  s.p[0] = 0;\n  t->p[0] = 1;\n  return s.p[0];\n}\n\nint\nmain ()\n{\n  int a, b;\n  if (foo (&a, &b) != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49281.c",
    "content": "/* PR target/49281 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  return (x << 2) | 4;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int x)\n{\n  return (x << 2) | 3;\n}\n\nint\nmain ()\n{\n  if (foo (43) != 172 || foo (1) != 4 || foo (2) != 12)\n    abort ();\n  if (bar (43) != 175 || bar (1) != 7 || bar (2) != 11)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49390.c",
    "content": "/* PR rtl-optimization/49390 */\n\nstruct S { unsigned int s1; unsigned int s2; };\nstruct T { unsigned int t1; struct S t2; };\nstruct U { unsigned short u1; unsigned short u2; };\nstruct V { struct U v1; struct T v2; };\nstruct S a;\nchar *b;\nunion { char b[64]; struct V v; } u;\nvolatile int v;\nextern void abort (void);\n\n__attribute__((noinline, noclone)) void\nfoo (int x, void *y, unsigned int z, unsigned int w)\n{\n  if (x != 4 || y != (void *) &u.v.v2)\n    abort ();\n  v = z + w;\n  v = 16384;\n}\n\n__attribute__((noinline, noclone)) void\nbar (struct S x)\n{\n  v = x.s1;\n  v = x.s2;\n}\n\n__attribute__((noinline, noclone)) int\nbaz (struct S *x)\n{\n  v = x->s1;\n  v = x->s2;\n  v = 0;\n  return v + 1;\n}\n\n__attribute__((noinline, noclone)) void\ntest (struct S *c)\n{\n  struct T *d;\n  struct S e = a;\n  unsigned int f, g;\n  if (c == 0)\n    c = &e;\n  else\n    {\n      if (c->s2 % 8192 <= 15 || (8192 - c->s2 % 8192) <= 31)\n\tfoo (1, 0, c->s1, c->s2);\n    }\n  if (!baz (c))\n    return;\n  g = (((struct U *) b)->u2 & 2) ? 32 : __builtin_offsetof (struct V, v2);\n  f = c->s2 % 8192;\n  if (f == 0)\n    {\n      e.s2 += g;\n      f = g;\n    }\n  else if (f < g)\n    {\n      foo (2, 0, c->s1, c->s2);\n      return;\n    }\n  if ((((struct U *) b)->u2 & 1) && f == g)\n    {\n      bar (*c);\n      foo (3, 0, c->s1, c->s2);\n      return;\n    }\n  d = (struct T *) (b + c->s2 % 8192);\n  if (d->t2.s1 >= c->s1 && (d->t2.s1 != c->s1 || d->t2.s2 >= c->s2))\n    foo (4, d, c->s1, c->s2);\n  return;\n}\n\nint\nmain ()\n{\n  struct S *c = 0;\n  asm (\"\" : \"+r\" (c) : \"r\" (&a));\n  u.v.v2.t2.s1 = 8192;\n  b = u.b;\n  test (c);\n  if (v != 16384)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49419.c",
    "content": "/* PR tree-optimization/49419 */\n\nextern void abort (void);\n\nstruct S { int w, x, y; } *t;\n\nint\nfoo (int n, int f, int *s, int m)\n{\n  int x, i, a;\n  if (n == -1)\n    return 0;\n  for (x = n, i = 0; t[x].w == f && i < m; i++)\n    x = t[x].x;\n  if (i == m)\n    abort ();\n  a = i + 1;\n  for (x = n; i > 0; i--)\n    {\n      s[i] = t[x].y;\n      x = t[x].x;\n    }\n  s[0] = x;\n  return a;\n}\n\nint\nmain (void)\n{\n  int s[3], i;\n  struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } };\n  t = buf;\n  if (foo (0, 1, s, 3) != 2)\n    abort ();\n  if (s[0] != 1 || s[1] != 2)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49644.c",
    "content": "/* PR c/49644 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  _Complex double a[12], *c = a, s = 3.0 + 1.0i;\n  double b[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, *d = b;\n  int i;\n  for (i = 0; i < 6; i++)\n    *c++ = *d++ * s;\n  if (c != a + 6 || d != b + 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49712.c",
    "content": "/* PR tree-optimization/49712 */\n\nint a[2], b, c, d, e;\n\nvoid\nfoo (int x, int y)\n{\n}\n\nint\nbar (void)\n{\n  int i;\n  for (; d <= 0; d = 1)\n    for (i = 0; i < 4; i++)\n      for (e = 0; e; e = 1)\n\t;\n  return 0;\n}\n\nint\nmain ()\n{\n  for (b = 0; b < 2; b++)\n    while (c)\n      foo (a[b] = 0, bar ());\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49768.c",
    "content": "/* PR tree-optimization/49768 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  static struct { unsigned int : 1; unsigned int s : 1; } s = { .s = 1 };\n  if (s.s != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr49886.c",
    "content": "struct PMC {\n    unsigned flags;\n};\n\ntypedef struct Pcc_cell\n{\n    struct PMC *p;\n    long bla;\n    long type;\n} Pcc_cell;\n\nint gi;\nint cond;\n\nextern void abort ();\nextern void never_ever(int interp, struct PMC *pmc)\n  __attribute__((noinline,noclone));\n\nvoid never_ever (int interp, struct PMC *pmc)\n{\n  abort ();\n}\n\nstatic void mark_cell(int * interp, Pcc_cell *c)\n  __attribute__((__nonnull__(1)));\n\nstatic void\nmark_cell(int * interp, Pcc_cell *c)\n{\n  if (!cond)\n    return;\n\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<18)))\n    never_ever(gi + 1, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<17)))\n    never_ever(gi + 2, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<16)))\n    never_ever(gi + 3, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<15)))\n    never_ever(gi + 4, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<14)))\n    never_ever(gi + 5, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<13)))\n    never_ever(gi + 6, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<12)))\n    never_ever(gi + 7, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<11)))\n    never_ever(gi + 8, c->p);\n  if (c && c->type == 4 && c->p\n      && !(c->p->flags & (1<<10)))\n    never_ever(gi + 9, c->p);\n}\n\nstatic void\nfoo(int * interp, Pcc_cell *c)\n{\n  mark_cell(interp, c);\n}\n\nstatic struct Pcc_cell *\n__attribute__((noinline,noclone))\ngetnull(void)\n{\n  return (struct Pcc_cell *) 0;\n}\n\n\nint main()\n{\n  int i;\n\n  cond = 1;\n  for (i = 0; i < 100; i++)\n    foo (&gi, getnull ());\n  return 0;\n}\n\n\nvoid\nbar_1 (int * interp, Pcc_cell *c)\n{\n  c->bla += 1;\n  mark_cell(interp, c);\n}\n\nvoid\nbar_2 (int * interp, Pcc_cell *c)\n{\n  c->bla += 2;\n  mark_cell(interp, c);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr50865.c",
    "content": "/* PR middle-end/50865 */\n\n#define INT64_MIN (-__LONG_LONG_MAX__ - 1)\n\nint\nmain ()\n{\n  volatile long long l1 = 1;\n  volatile long long l2 = -1;\n  volatile long long l3 = -1;\n\n  if ((INT64_MIN % 1LL) != 0)\n    __builtin_abort ();\n  if ((INT64_MIN % l1) != 0)\n    __builtin_abort ();\n  if (l2 == -1)\n    {\n      if ((INT64_MIN % 1LL) != 0)\n\t__builtin_abort ();\n    }\n  else if ((INT64_MIN % -l2) != 0)\n    __builtin_abort ();\n  if ((INT64_MIN % -l3) != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51023.c",
    "content": "/* PR rtl-optimization/51023 */\n\nextern void abort (void);\n\nshort int\nfoo (long int x)\n{\n  return x;\n}\n\nint\nmain ()\n{\n  long int a = 0x4272AL;\n  if (foo (a) == a)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51323.c",
    "content": "/* PR middle-end/51323 */\n\nextern void abort (void);\nstruct S { int a, b, c; };\nint v;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int y, int z)\n{\n  if (x != v || y != 0 || z != 9)\n    abort ();\n}\n\nstatic inline int\nbaz (const struct S *p)\n{\n  return p->b;\n}\n\n__attribute__((noinline, noclone)) void\nbar (int x, struct S y)\n{\n  foo (baz (&y), 0, x);\n}\n\nint\nmain ()\n{\n  struct S s;\n  v = 3; s.a = v - 1; s.b = v; s.c = v + 1;\n  bar (9, s);\n  v = 17; s.a = v - 1; s.b = v; s.c = v + 1;\n  bar (9, s);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51447.c",
    "content": "/* PR rtl-optimization/51447 */\n/* { dg-require-effective-target label_values } */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\n#ifdef __x86_64__\nregister void *ptr asm (\"rbx\");\n#else\nvoid *ptr;\n#endif\n\nint\nmain (void)\n{\n  __label__ nonlocal_lab;\n  __attribute__((noinline, noclone)) void\n    bar (void *func)\n      {\n\tptr = func;\n\tgoto nonlocal_lab;\n      }\n  bar (&&nonlocal_lab);\n  return 1;\nnonlocal_lab:\n  if (ptr != &&nonlocal_lab)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51466.c",
    "content": "/* PR tree-optimization/51466 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nfoo (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[i];\n  return *p;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[i];\n  *p = 8;\n  return v[i];\n}\n\n__attribute__((noinline, noclone)) int\nbaz (int i)\n{\n  volatile int v[4];\n  int *p;\n  v[i] = 6;\n  p = (int *) &v[0];\n  *p = 8;\n  return v[i];\n}\n\nint\nmain ()\n{\n  if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51581-1.c",
    "content": "/* PR tree-optimization/51581 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\n#define N 4096\nint a[N], c[N];\nunsigned int b[N], d[N];\n\n__attribute__((noinline, noclone)) void\nf1 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 3;\n}\n\n__attribute__((noinline, noclone)) void\nf2 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 3;\n}\n\n__attribute__((noinline, noclone)) void\nf3 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 18;\n}\n\n__attribute__((noinline, noclone)) void\nf4 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 18;\n}\n\n__attribute__((noinline, noclone)) void\nf5 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] / 19;\n}\n\n__attribute__((noinline, noclone)) void\nf6 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] / 19;\n}\n\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) void\nf7 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf8 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);\n}\n\n__attribute__((noinline, noclone)) void\nf9 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf10 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;\n}\n\n__attribute__((noinline, noclone)) void\nf11 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);\n}\n\n__attribute__((noinline, noclone)) void\nf12 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;\n      d[i] = (((b[i] - tmp) >> 1) + tmp) >> 4;\n    }\n}\n#endif\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      asm (\"\");\n      a[i] = i - N / 2;\n      b[i] = i;\n    }\n  a[0] = -__INT_MAX__ - 1;\n  a[1] = -__INT_MAX__;\n  a[N - 1] = __INT_MAX__;\n  b[N - 1] = ~0;\n  f1 ();\n  f2 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 3 || d[i] != b[i] / 3)\n      abort ();\n  f3 ();\n  f4 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 18 || d[i] != b[i] / 18)\n      abort ();\n  f5 ();\n  f6 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 19 || d[i] != b[i] / 19)\n      abort ();\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  f7 ();\n  f8 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 3 || d[i] != b[i] / 3)\n      abort ();\n  f9 ();\n  f10 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 18 || d[i] != b[i] / 18)\n      abort ();\n  f11 ();\n  f12 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] / 19 || d[i] != b[i] / 19)\n      abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51581-2.c",
    "content": "/* PR tree-optimization/51581 */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\n#define N 4096\nint a[N], c[N];\nunsigned int b[N], d[N];\n\n__attribute__((noinline, noclone)) void\nf1 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 3;\n}\n\n__attribute__((noinline, noclone)) void\nf2 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 3;\n}\n\n__attribute__((noinline, noclone)) void\nf3 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 18;\n}\n\n__attribute__((noinline, noclone)) void\nf4 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 18;\n}\n\n__attribute__((noinline, noclone)) void\nf5 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    c[i] = a[i] % 19;\n}\n\n__attribute__((noinline, noclone)) void\nf6 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    d[i] = b[i] % 19;\n}\n\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) void\nf7 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (int) ((unsigned long long) (a[i] * 0x55555556LL) >> 32) - (a[i] >> 31);\n      c[i] = a[i] - x * 3;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf8 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int x = ((unsigned int) ((b[i] * 0xaaaaaaabULL) >> 32) >> 1);\n      d[i] = b[i] - x * 3;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf9 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (((int) ((unsigned long long) (a[i] * 0x38e38e39LL) >> 32)) >> 2) - (a[i] >> 31);\n      c[i] = a[i] - x * 18;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf10 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int x = (unsigned int) ((b[i] * 0x38e38e39ULL) >> 32) >> 2;\n      d[i] = b[i] - x * 18;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf11 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      int x = (((int) ((unsigned long long) (a[i] * 0x6bca1af3LL) >> 32)) >> 3) - (a[i] >> 31);\n      c[i] = a[i] - x * 19;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nf12 (void)\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      unsigned int tmp = (b[i] * 0xaf286bcbULL) >> 32;\n      unsigned int x = (((b[i] - tmp) >> 1) + tmp) >> 4;\n      d[i] = b[i] - x * 19;\n    }\n}\n#endif\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < N; i++)\n    {\n      asm (\"\");\n      a[i] = i - N / 2;\n      b[i] = i;\n    }\n  a[0] = -__INT_MAX__ - 1;\n  a[1] = -__INT_MAX__;\n  a[N - 1] = __INT_MAX__;\n  b[N - 1] = ~0;\n  f1 ();\n  f2 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 3 || d[i] != b[i] % 3)\n      abort ();\n  f3 ();\n  f4 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 18 || d[i] != b[i] % 18)\n      abort ();\n  f5 ();\n  f6 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 19 || d[i] != b[i] % 19)\n      abort ();\n#if __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  f7 ();\n  f8 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 3 || d[i] != b[i] % 3)\n      abort ();\n  f9 ();\n  f10 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 18 || d[i] != b[i] % 18)\n      abort ();\n  f11 ();\n  f12 ();\n  for (i = 0; i < N; i++)\n    if (c[i] != a[i] % 19 || d[i] != b[i] % 19)\n      abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51877.c",
    "content": "/* PR tree-optimization/51877 */\n\nextern void abort (void);\nstruct A { int a; char b[32]; } a, b;\n\n__attribute__((noinline, noclone))\nstruct A\nbar (int x)\n{\n  struct A r;\n  static int n;\n  r.a = ++n;\n  __builtin_memset (r.b, 0, sizeof (r.b));\n  r.b[0] = x;\n  return r;\n}\n\n__attribute__((noinline, noclone))\nvoid\nbaz (void)\n{\n  asm volatile (\"\" : : : \"memory\");\n}\n\n__attribute__((noinline, noclone))\nvoid\nfoo (struct A *x, int y)\n{\n  if (y == 6)\n    a = bar (7);\n  else\n    *x = bar (7);\n  baz ();\n}\n\nint\nmain ()\n{\n  a = bar (3);\n  b = bar (4);\n  if (a.a != 1 || a.b[0] != 3 || b.a != 2 || b.b[0] != 4)\n    abort ();\n  foo (&b, 0);\n  if (a.a != 1 || a.b[0] != 3 || b.a != 3 || b.b[0] != 7)\n    abort ();\n  foo (&b, 6);\n  if (a.a != 4 || a.b[0] != 7 || b.a != 3 || b.b[0] != 7)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr51933.c",
    "content": "/* PR rtl-optimization/51933 */\n\nstatic signed char v1;\nstatic unsigned char v2[256], v3[256];\n\n__attribute__((noclone, noinline)) void\nfoo (void)\n{\n#if defined(__s390__) && !defined(__zarch__)\n  /* S/390 31 bit cannot deal with more than one literal pool\n     reference per insn.  */\n  asm volatile (\"\" : : \"g\" (&v1) : \"memory\");\n  asm volatile (\"\" : : \"g\" (&v2[0]));\n  asm volatile (\"\" : : \"g\" (&v3[0]));\n#else\n  asm volatile (\"\" : : \"g\" (&v1), \"g\" (&v2[0]), \"g\" (&v3[0]) : \"memory\");\n#endif\n}\n\n__attribute__((noclone, noinline)) int\nbar (const int x, const unsigned short *y, char *z)\n{\n  int i;\n  unsigned short u;\n  if (!v1)\n    foo ();\n  for (i = 0; i < x; i++)\n    {\n      u = y[i];\n      z[i] = u < 0x0100 ? v2[u] : v3[u & 0xff];\n    }\n  z[x] = '\\0';\n  return x;\n}\n\nint\nmain (void)\n{\n  char buf[18];\n  unsigned short s[18];\n  unsigned char c[18] = \"abcdefghijklmnopq\";\n  int i;\n  for (i = 0; i < 256; i++)\n    {\n      v2[i] = i;\n      v3[i] = i + 1;\n    }\n  for (i = 0; i < 18; i++)\n    s[i] = c[i];\n  s[5] |= 0x600;\n  s[6] |= 0x500;\n  s[11] |= 0x2000;\n  s[15] |= 0x500;\n  foo ();\n  if (bar (17, s, buf) != 17\n      || __builtin_memcmp (buf, \"abcdeghhijkmmnoqq\", 18) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52129.c",
    "content": "/* PR target/52129 */\n/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"-O1\" } { \"\" } } */\n\nextern void abort (void);\nstruct S { void *p; unsigned int q; };\nstruct T { char a[64]; char b[64]; } t;\n\n__attribute__((noinline, noclone)) int\nfoo (void *x, struct S s, void *y, void *z)\n{\n  if (x != &t.a[2] || s.p != &t.b[5] || s.q != 27 || y != &t.a[17] || z != &t.b[17])\n    abort ();\n  return 29;\n}\n\n__attribute__((noinline, noclone)) int\nbar (void *x, void *y, void *z, struct S s, int t, struct T *u)\n{\n  return foo (x, s, &u->a[t], &u->b[t]);\n}\n\nint\nmain ()\n{\n  struct S s = { &t.b[5], 27 };\n  if (bar (&t.a[2], (void *) 0, (void *) 0, s, 17, &t) != 29)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52209.c",
    "content": "/* PR middle-end/52209 */\n\nextern void abort (void);\nstruct S0 { int f2 : 1; } c;\nint b;\n\nint\nmain ()\n{\n  b = -1 ^ c.f2;\n  if (b != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52286.c",
    "content": "/* PR tree-optimization/52286 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n#if __SIZEOF_INT__ > 2\n  int a, b;\n  asm (\"\" : \"=r\" (a) : \"0\" (0));\n  b = (~a | 1) & -2038094497;\n#else\n  long a, b;\n  asm (\"\" : \"=r\" (a) : \"0\" (0));\n  b = (~a | 1) & -2038094497L;\n#endif\n  if (b >= 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52760.c",
    "content": "/* PR tree-optimization/52760 */\n\nstruct T { unsigned short a, b, c, d; };\n\n__attribute__((noinline, noclone)) void\nfoo (int x, struct T *y)\n{\n  int i;\n\n  for (i = 0; i < x; i++)\n    {\n      y[i].a = ((0x00ff & y[i].a >> 8) | (0xff00 & y[i].a << 8));\n      y[i].b = ((0x00ff & y[i].b >> 8) | (0xff00 & y[i].b << 8));\n      y[i].c = ((0x00ff & y[i].c >> 8) | (0xff00 & y[i].c << 8));\n      y[i].d = ((0x00ff & y[i].d >> 8) | (0xff00 & y[i].d << 8));\n    }\n}\n\nint\nmain ()\n{\n  struct T t = { 0x0001, 0x0203, 0x0405, 0x0607 };\n  foo (1, &t);\n  if (t.a != 0x0100 || t.b != 0x0302 || t.c != 0x0504 || t.d != 0x0706)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52979-1.c",
    "content": "/* PR middle-end/52979 */\n\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nint c, d, e;\n\nvoid\nfoo (void)\n{\n}\n\nstruct __attribute__((packed)) S { int g : 31; int h : 6; };\nstruct S a = { 1 };\nstatic struct S b = { 1 };\n\nvoid\nbar (void)\n{\n  a.h = 1;\n  struct S f = { };\n  b = f;\n  e = 0;\n  if (d)\n    c = a.g;\n}\n\nvoid\nbaz (void)\n{\n  bar ();\n  a = b;\n}\n\nint\nmain ()\n{\n  baz ();\n  if (a.g)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr52979-2.c",
    "content": "/* PR middle-end/52979 */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\nint c, d, e;\n\nvoid\nfoo (void)\n{\n}\n\nstruct __attribute__((packed)) S { int g : 31; int h : 6; };\nstatic struct S b = { 1 };\nstruct S a = { 1 };\n\nvoid\nbar (void)\n{\n  a.h = 1;\n  struct S f = { };\n  b = f;\n  e = 0;\n  if (d)\n    c = a.g;\n}\n\nvoid\nbaz (void)\n{\n  bar ();\n  a = b;\n}\n\nint\nmain ()\n{\n  baz ();\n  if (a.g)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53084.c",
    "content": "/* PR middle-end/53084 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) void\nbar (const char *p)\n{\n  if (p[0] != 'o' || p[1] != 'o' || p[2])\n    abort ();\n}\n\nint\nmain ()\n{\n  static const char *const foo[] = {\"foo\" + 1};\n  bar (foo[0]);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53160.c",
    "content": "/* PR rtl-optimization/53160 */\n\nextern void abort (void);\n\nint a, c = 1, d, e, g;\nvolatile int b;\nvolatile char f;\nlong h;\nshort i;\n\nvoid\nfoo (void)\n{\n  for (e = 0; e; ++e)\n    ;\n}\n\nint\nmain ()\n{\n  if (g)\n    (void) b;\n  foo ();\n  for (d = 0; d >= 0; d--)\n    {\n      short j = f;\n      int k = 0;\n      i = j ? j : j << k;\n    }\n  h = c == 0 ? 0 : i;\n  a = h;\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53465.c",
    "content": "/* PR tree-optimization/53465 */\n\nextern void abort ();\n\nstatic const int a[] = { 1, 2 };\n\nvoid\nfoo (const int *x, int y)\n{\n  int i;\n  int b = 0;\n  int c;\n  for (i = 0; i < y; i++)\n    {\n      int d = x[i];\n      if (d == 0)\n\tbreak;\n      if (b && d <= c)\n\tabort ();\n      c = d;\n      b = 1;\n    }\n}\n\nint\nmain ()\n{\n  foo (a, 2);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53645-2.c",
    "content": "/* PR tree-optimization/53645 */\n/* { dg-options \"-std=gnu89\" } */\n\ntypedef unsigned short int UV __attribute__((vector_size (16)));\ntypedef short int SV __attribute__((vector_size (16)));\nextern void abort (void);\n\n#define TEST(a, b, c, d, e, f, g, h) \\\n__attribute__((noinline)) void\t\t\t\\\nuq##a##b##c##d##e##f##g##h (UV *x, UV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y / ((UV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nur##a##b##c##d##e##f##g##h (UV *x, UV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y % ((UV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nsq##a##b##c##d##e##f##g##h (SV *x, SV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y / ((SV) { a, b, c, d, e, f, g, h });\t\\\n}\t\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\t\\\nsr##a##b##c##d##e##f##g##h (SV *x, SV *y) \t\\\n{\t\t\t\t\t\t\\\n  *x = *y % ((SV) { a, b, c, d, e, f, g, h });\t\\\n}\n\n#define TESTS \\\nTEST (4, 4, 4, 4, 4, 4, 4, 4)\t\t\\\nTEST (1, 4, 2, 8, 16, 64, 32, 128)\t\\\nTEST (3, 3, 3, 3, 3, 3, 3, 3)\t\t\\\nTEST (6, 5, 6, 5, 6, 5, 6, 5)\t\t\\\nTEST (14, 14, 14, 6, 14, 6, 14, 14)\t\\\nTEST (7, 7, 7, 7, 7, 7, 7, 7)\t\t\\\n\nTESTS\n\nUV u[] =\n  { ((UV) { 73U, 65531U, 0U, 174U, 921U, 65535U, 17U, 178U }),\n    ((UV) { 1U, 8173U, 65535U, 65472U, 12U, 29612U, 128U, 8912U }) };\nSV s[] =\n  { ((SV) { 73, -9123, 32761, 8191, 16371, 1201, 12701, 9999 }),\n    ((SV) { 9903, -1, -7323, 0, -7, -323, 9124, -9199 }) };\n\nint\nmain ()\n{\n  UV ur, ur2;\n  SV sr, sr2;\n  int i;\n#undef TEST\n#define TEST(a, b, c, d, e, f, g, h)\t\t\t\\\n    uq##a##b##c##d##e##f##g##h (&ur, u + i);\t\t\\\n    if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[4] != u[i][4] / e || ur[7] != u[i][7] / h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[6] != u[i][6] / g || ur[5] != u[i][5] / f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    ur##a##b##c##d##e##f##g##h (&ur, u + i);\t\t\\\n    if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[4] != u[i][4] % e || ur[7] != u[i][7] % h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[6] != u[i][6] % g || ur[5] != u[i][5] % f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\n  for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)\n    {\n      TESTS\n    }\n#undef TEST\n#define TEST(a, b, c, d, e, f, g, h)\t\t\t\\\n    sq##a##b##c##d##e##f##g##h (&sr, s + i);\t\t\\\n    if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[4] != s[i][4] / e || sr[7] != s[i][7] / h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[6] != s[i][6] / g || sr[5] != s[i][5] / f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    sr##a##b##c##d##e##f##g##h (&sr, s + i);\t\t\\\n    if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[4] != s[i][4] % e || sr[7] != s[i][7] % h)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[6] != s[i][6] % g || sr[5] != s[i][5] % f)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\n  for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)\n    {\n      TESTS\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53645.c",
    "content": "/* PR tree-optimization/53645 */\n/* { dg-options \"-std=gnu89\" } */\n\ntypedef unsigned int UV __attribute__((vector_size (16)));\ntypedef int SV __attribute__((vector_size (16)));\nextern void abort (void);\n\n#define TEST(a, b, c, d) \\\n__attribute__((noinline)) void\t\t\\\nuq##a##b##c##d (UV *x, UV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y / ((UV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nur##a##b##c##d (UV *x, UV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y % ((UV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nsq##a##b##c##d (SV *x, SV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y / ((SV) { a, b, c, d });\t\\\n}\t\t\t\t\t\\\n\t\t\t\t\t\\\n__attribute__((noinline)) void\t\t\\\nsr##a##b##c##d (SV *x, SV *y) \t\t\\\n{\t\t\t\t\t\\\n  *x = *y % ((SV) { a, b, c, d });\t\\\n}\n\n#define TESTS \\\nTEST (4, 4, 4, 4)\t\t\t\\\nTEST (1, 4, 2, 8)\t\t\t\\\nTEST (3, 3, 3, 3)\t\t\t\\\nTEST (6, 5, 6, 5)\t\t\t\\\nTEST (14, 14, 14, 6)\t\t\t\\\nTEST (7, 7, 7, 7)\t\t\t\\\n\nTESTS\n\nUV u[] =\n  { ((UV) { 73U, 65531U, 0U, 174U }),\n    ((UV) { 1U, 8173U, ~0U, ~0U - 63 }) };\nSV s[] =\n  { ((SV) { 73, -9123, 32761, 8191 }),\n    ((SV) { 9903, -1, -7323, 0 }) };\n\nint\nmain ()\n{\n  UV ur, ur2;\n  SV sr, sr2;\n  int i;\n#undef TEST\n#define TEST(a, b, c, d)\t\t\t\t\\\n    uq##a##b##c##d (&ur, u + i);\t\t\t\\\n    if (ur[0] != u[i][0] / a || ur[3] != u[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] / c || ur[1] != u[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    ur##a##b##c##d (&ur, u + i);\t\t\t\\\n    if (ur[0] != u[i][0] % a || ur[3] != u[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\t\t\\\n    if (ur[2] != u[i][2] % c || ur[1] != u[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&ur) : \"memory\");\n  for (i = 0; i < sizeof (u) / sizeof (u[0]); i++)\n    {\n      TESTS\n    }\n#undef TEST\n#define TEST(a, b, c, d)\t\t\t\t\\\n    sq##a##b##c##d (&sr, s + i);\t\t\t\\\n    if (sr[0] != s[i][0] / a || sr[3] != s[i][3] / d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] / c || sr[1] != s[i][1] / b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    sr##a##b##c##d (&sr, s + i);\t\t\t\\\n    if (sr[0] != s[i][0] % a || sr[3] != s[i][3] % d)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\t\t\\\n    if (sr[2] != s[i][2] % c || sr[1] != s[i][1] % b)\t\\\n     abort ();\t\t\t\t\t\t\\\n    asm volatile (\"\" : : \"r\" (&sr) : \"memory\");\n  for (i = 0; i < sizeof (s) / sizeof (s[0]); i++)\n    {\n      TESTS\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr53688.c",
    "content": "char headline[256];\nstruct hdr {\n  char part1[9];\n  char part2[8];\n} p;\n\nvoid __attribute__((noinline,noclone))\ninit()\n{\n  __builtin_memcpy (p.part1, \"FOOBARFOO\", sizeof (p.part1));\n  __builtin_memcpy (p.part2, \"SPEC CPU\", sizeof (p.part2));\n}\n\nint main()\n{\n  char *x;\n  int c;\n  init();\n  __builtin_memcpy (&headline[0], p.part1, 9);\n  c = 9;\n  x = &headline[0];\n  x = x + c;\n  __builtin_memset (x, ' ', 245);\n  __builtin_memcpy (&headline[10], p.part2, 8);\n  c = 18;\n  x = &headline[0];\n  x = x + c;\n  __builtin_memset (x, ' ', 238);\n  if (headline[10] != 'S')\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr54471.c",
    "content": "/* PR tree-optimization/54471 */\n\n#ifdef __SIZEOF_INT128__\n#define T __int128\n#else\n#define T long long\n#endif\n\nextern void abort (void);\n\n__attribute__ ((noinline))\nunsigned T\nfoo (T ixi, unsigned ctr)\n{\n  unsigned T irslt = 1;\n  T ix = ixi;\n\n  for (; ctr; ctr--)\n    {\n      irslt *= ix;\n      ix *= ix;\n    }\n\n  if (irslt != 14348907)\n    abort ();\n  return irslt;\n}\n\nint\nmain ()\n{\n  unsigned T res;\n\n  res = foo (3, 4);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr54937.c",
    "content": "\nvoid exit (int);\nvoid abort (void);\nint a[1];\nvoid (*terminate_me)(int);\n\n__attribute__((noinline,noclone))\nt(int c)\n{ int i;\n  for (i=0;i<c;i++)\n    {\n      if (i)\n       terminate_me(0);\n      a[i]=0;\n    }\n}\nmain()\n{\n  terminate_me = exit;\n  t(100);\n  abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr54985.c",
    "content": "\ntypedef struct st {\n    int a;\n} ST;\n\nint __attribute__((noinline,noclone))\nfoo(ST *s, int c)\n{\n  int first = 1;\n  int count = c;\n  ST *item = s;\n  int a = s->a;\n  int x;\n\n  while (count--)\n    {\n      x = item->a;\n      if (first)\n        first = 0;\n      else if (x >= a)\n        return 1;\n      a = x;\n      item++;\n    }\n  return 0;\n}\n\nextern void abort (void);\n\nint main ()\n{\n  ST _1[2] = {{2}, {1}};\n  if (foo(_1, 2) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr55137.c",
    "content": "/* PR c++/55137 */\n\nextern void abort (void);\n\nint\nfoo (unsigned int x)\n{\n  return ((int) (x + 1U) + 1) < (int) x;\n}\n\nint\nbar (unsigned int x)\n{\n  return (int) (x + 1U) + 1;\n}\n\nint\nbaz (unsigned int x)\n{\n  return x + 1U;\n}\n\nint\nmain ()\n{\n  if (foo (__INT_MAX__) != (bar (__INT_MAX__) < __INT_MAX__)\n      || foo (__INT_MAX__) != ((int) baz (__INT_MAX__) + 1 < __INT_MAX__))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr55750.c",
    "content": "/* PR middle-end/55750 */\n\nextern void abort (void);\n\nstruct S\n{\n  int m : 1;\n  int n : 7;\n} arr[2];\n\n__attribute__((noinline, noclone)) void\nfoo (unsigned i)\n{\n  arr[i].n++;\n}\n\nint\nmain ()\n{\n  arr[0].m = -1;\n  arr[0].n = (1 << 6) - 1;\n  arr[1].m = 0;\n  arr[1].n = -1;\n  foo (0);\n  foo (1);\n  if (arr[0].m != -1 || arr[0].n != -(1 << 6) || arr[1].m != 0 || arr[1].n != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr55875.c",
    "content": "int a[251];\n__attribute__ ((noinline))\nt(int i)\n{\n  if (i==0)\n    exit(0);\n  if (i>255)\n    abort ();\n}\nmain()\n{\n  unsigned int i;\n  for (i=0;;i++)\n    {\n      a[i]=t((unsigned char)(i+5));\n    }\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56051.c",
    "content": "/* PR tree-optimization/56051 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  unsigned char x1[1] = { 0 };\n  unsigned int s1 = __CHAR_BIT__;\n  int a1 = x1[0] < (unsigned char) (1 << s1);\n  unsigned char y1 = (unsigned char) (1 << s1);\n  int b1 = x1[0] < y1;\n  if (a1 != b1)\n    abort ();\n#if __SIZEOF_LONG_LONG__ > __SIZEOF_INT__\n  unsigned long long x2[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };\n  unsigned int s2 = sizeof (int) * __CHAR_BIT__ - 1;\n  int a2 = x2[0] >= (unsigned long long) (1 << s2);\n  unsigned long long y2 = 1 << s2;\n  int b2 = x2[0] >= y2;\n  if (a2 != b2)\n    abort ();\n  unsigned long long x3[1] = { 2ULL << (sizeof (int) * __CHAR_BIT__) };\n  unsigned int s3 = sizeof (int) * __CHAR_BIT__ - 1;\n  int a3 = x3[0] >= (unsigned long long) (1U << s3);\n  unsigned long long y3 = 1U << s3;\n  int b3 = x3[0] >= y3;\n  if (a3 != b3)\n    abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56205.c",
    "content": "/* PR tree-optimization/56205 */\n\n#include <stdarg.h>\n\nint a, b;\nchar c[128];\n\n__attribute__((noinline, noclone)) static void\nf1 (const char *fmt, ...)\n{\n  va_list ap;\n  asm volatile (\"\" : : : \"memory\");\n  if (__builtin_strcmp (fmt, \"%s %d %s\") != 0)\n    __builtin_abort ();\n  va_start (ap, fmt);\n  if (__builtin_strcmp (va_arg (ap, const char *), \"foo\") != 0\n      || va_arg (ap, int) != 1\n      || __builtin_strcmp (va_arg (ap, const char *), \"bar\") != 0)\n    __builtin_abort ();\n  va_end (ap);\n}\n\n__attribute__((noinline, noclone)) static void\nf2 (const char *fmt, va_list ap)\n{\n  asm volatile (\"\" : : : \"memory\");\n  if (__builtin_strcmp (fmt, \"baz\") != 0\n      || __builtin_strcmp (va_arg (ap, const char *), \"foo\") != 0\n      || va_arg (ap, double) != 12.0\n      || va_arg (ap, int) != 26)\n    __builtin_abort ();\n}\n\nstatic void\nf3 (int x, char const *y, va_list z)\n{\n  f1 (\"%s %d %s\", x ? \"\" : \"foo\", ++a, (y && *y) ? \"bar\" : \"\");\n  if (y && *y)\n    f2 (y, z);\n}\n\n__attribute__((noinline, noclone)) void\nf4 (int x, char const *y, ...)\n{\n  va_list z;\n  va_start (z, y);\n  if (!x && *c == '\\0')\n    ++b;\n  f3 (x, y, z);\n  va_end (z);\n}\n\nint\nmain ()\n{\n  asm volatile (\"\" : : : \"memory\");\n  f4 (0, \"baz\", \"foo\", 12.0, 26);\n  if (a != 1 || b != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56250.c",
    "content": "/* PR tree-optimization/56250 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  unsigned int x = 2;\n  unsigned int y = (0U - x / 2) / 2;\n  if (-1U / x != y)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56799.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n#include <stdio.h>\ntypedef struct { int x; int y;} S;\nextern int foo(S*);\nint hi = 0, lo = 0;\n\nint main()\n{\n  S a;\n  int r;\n  a.x = (int) 0x00010000;\n  a.y = 1;\n  r = foo (&a);\n  if (r == 2 && lo==0 && hi==1)\n    {\n      exit (0);\n    }\n  abort ();\n}\n\ntypedef unsigned short u16;\n\n__attribute__ ((noinline)) int foo (S* ptr)\n{\n  int a = ptr->x;\n  int c = 0;\n  u16 b = (u16) a;\n  if (b != 0)\n  {\n    lo = 1;\n    c += ptr->y;\n  }\n  b = a >> 16;\n  if (b != 0)\n  {\n    hi = 1;\n    c+= ptr->y;\n  }\n  c += ptr->y;\n  return c;\n}\n\n     \n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56837.c",
    "content": "extern void abort (void);\n_Complex int a[1024];\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  int i;\n  for (i = 0; i < 1024; i++)\n    a[i] = -1;\n}\n\nint\nmain ()\n{\n  int i;\n  foo ();\n  for (i = 0; i < 1024; i++)\n    if (a[i] != -1)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56866.c",
    "content": "/* PR target/56866 */\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_SHORT__ == 2\n  unsigned long long wq[256], rq[256];\n  unsigned int wi[256], ri[256];\n  unsigned short ws[256], rs[256];\n  unsigned char wc[256], rc[256];\n  int t;\n\n  __builtin_memset (wq, 0, sizeof wq);\n  __builtin_memset (wi, 0, sizeof wi);\n  __builtin_memset (ws, 0, sizeof ws);\n  __builtin_memset (wc, 0, sizeof wc);\n  wq[0] = 0x0123456789abcdefULL;\n  wi[0] = 0x01234567;\n  ws[0] = 0x4567;\n  wc[0] = 0x73;\n\n  asm volatile (\"\" : : \"g\" (wq), \"g\" (wi), \"g\" (ws), \"g\" (wc) : \"memory\");\n\n  for (t = 0; t < 256; ++t)\n    rq[t] = (wq[t] >> 8) | (wq[t] << (sizeof (wq[0]) * __CHAR_BIT__ - 8));\n  for (t = 0; t < 256; ++t)\n    ri[t] = (wi[t] >> 8) | (wi[t] << (sizeof (wi[0]) * __CHAR_BIT__ - 8));\n  for (t = 0; t < 256; ++t)\n    rs[t] = (ws[t] >> 9) | (ws[t] << (sizeof (ws[0]) * __CHAR_BIT__ - 9));\n  for (t = 0; t < 256; ++t)\n    rc[t] = (wc[t] >> 5) | (wc[t] << (sizeof (wc[0]) * __CHAR_BIT__ - 5));\n\n  asm volatile (\"\" : : \"g\" (rq), \"g\" (ri), \"g\" (rs), \"g\" (rc) : \"memory\");\n\n  if (rq[0] != 0xef0123456789abcdULL || rq[1])\n    __builtin_abort ();\n  if (ri[0] != 0x67012345 || ri[1])\n    __builtin_abort ();\n  if (rs[0] != 0xb3a2 || rs[1])\n    __builtin_abort ();\n  if (rc[0] != 0x9b || rc[1])\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56899.c",
    "content": "/* PR tree-optimization/56899 */\n\n#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8\n__attribute__((noinline, noclone)) void\nf1 (int v)\n{\n  int x = -214748365 * (v - 1);\n  if (x != -1932735285)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf2 (int v)\n{\n  int x = 214748365 * (v + 1);\n  if (x != -1932735285)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf3 (unsigned int v)\n{\n  unsigned int x = -214748365U * (v - 1);\n  if (x != -1932735285U)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nf4 (unsigned int v)\n{\n  unsigned int x = 214748365U * (v + 1);\n  if (x != -1932735285U)\n    __builtin_abort ();\n}\n#endif\n\nint\nmain ()\n{\n#if __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8\n  f1 (10);\n  f2 (-10);\n  f3 (10);\n  f4 (-10U);\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56962.c",
    "content": "/* PR tree-optimization/56962 */\n\nextern void abort (void);\nlong long v[144];\n\n__attribute__((noinline, noclone)) void\nbar (long long *x)\n{\n  if (x != &v[29])\n    abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (long long *x, long y, long z)\n{\n  long long a, b, c;\n  a = x[z * 4 + y * 3];\n  b = x[z * 5 + y * 3];\n  c = x[z * 5 + y * 4];\n  x[y * 4] = a;\n  bar (&x[z * 5 + y]);\n  x[z * 5 + y * 5] = b + c;\n}\n\nint\nmain ()\n{\n  foo (v, 24, 1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr56982.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n#include <setjmp.h>\n\nextern void abort (void);\nextern void exit (int);\n\nstatic jmp_buf env;\n\nvoid baz (void)\n{\n  __asm__ volatile (\"\" : : : \"memory\");\n}\n\nstatic inline int g(int x)\n{\n    if (x)\n    {\n        baz();\n        return 0;\n    }\n    else\n    {\n        baz();\n        return 1;\n    }\n}\n\nint f(int *e)\n{\n    if (*e)\n      return 1;\n\n    int x = setjmp(env);\n    int n = g(x);\n    if (n == 0)\n      exit(0);\n    if (x)\n      abort();\n    longjmp(env, 42);\n}\n\nint main(int argc, char** argv)\n{\n    int v = 0;\n    return f(&v);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57124.c",
    "content": "/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-fno-strict-overflow\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n__attribute__ ((noinline)) void\nfoo(short unsigned int *p1, short unsigned int *p2)\n{\n  short unsigned int x1, x4;\n  int x2, x3, x5, x6;\n  unsigned int x7;\n  \n  x1 = *p1;\n  x2 = (int) x1;\n  x3 = x2 * 65536;\n  x4 = *p2;\n  x5 = (int) x4;\n  x6 = x3 + x4;\n  x7 = (unsigned int) x6;\n  if (x7 <= 268435455U)\n    abort ();\n  exit (0);\n}\n\nint\nmain()\n{\n  short unsigned int x, y;\n  x = -5;\n  y = -10;\n  foo (&x, &y);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57130.c",
    "content": "/* PR rtl-optimization/57130 */\n\nstruct S { int a, b, c, d; } s[2] = { { 6, 8, -8, -5 }, { 0, 2, -1, 2 } };\n\n__attribute__((noinline, noclone)) void\nfoo (struct S r)\n{\n  static int cnt;\n  if (__builtin_memcmp (&r, &s[cnt++], sizeof r) != 0)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  struct S r = { 6, 8, -8, -5 };\n  foo (r);\n  r = (struct S) { 0, 2, -1, 2 };\n  foo (r);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57131.c",
    "content": "/* PR rtl-optimization/57131 */\n\nextern void abort (void);\n\nint\nmain ()\n{\n  volatile int x1 = 0;\n  volatile long long x2 = 0;\n  volatile int x3 = 0;\n  volatile int x4 = 1;\n  volatile int x5 = 1;\n  volatile long long x6 = 1;\n  long long t = ((x1 * (x2 << x3)) / (x4 * x5)) + x6;\n\n  if (t != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57144.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nvoid __attribute__ ((noinline))\nfoo(int a)\n{\n  int z = a > 0 ? a : -a;\n  long long x = z;\n  if (x > 0x100000000LL)\n    abort ();\n  else\n    exit (0);\n}\n\nint\nmain()\n{\n  foo (1);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57281.c",
    "content": "/* PR rtl-optimization/57281 */\n\nint a = 1, b, d, *e = &d;\nlong long c, *g = &c;\nvolatile long long f;\n\nint\nfoo (int h)\n{\n  int j = *g = b;\n  return h == 0 ? j : 0;\n}\n\nint\nmain ()\n{\n  int h = a;\n  for (; b != -20; b--)\n    {\n      (int) f;\n      *e = 0;\n      *e = foo (h);\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57321.c",
    "content": "/* PR tree-optimization/57321 */\n\nint a = 1, *b, **c;\n\nstatic int\nfoo (int *p)\n{\n  if (*p == a)\n    {\n      int *i[7][5] = { { 0 } };\n      int **j[1][1];\n      j[0][0] = &i[0][0];\n      *b = &p != c;\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  int i = 0;\n  foo (&i);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57344-1.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  int a : 11;\n#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32\n  int b : 22;\n#else\n  int b : 13;\n#endif\n  char c;\n  int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != -3161)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161L };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57344-2.c",
    "content": "/* PR middle-end/57344 */\n/* { dg-require-effective-target int32plus } */\n\nstruct __attribute__((packed)) S\n{\n  int a : 27;\n#if __SIZEOF_INT__ * __CHAR_BIT__ >= 32\n  int b : 22;\n#else\n  int b : 13;\n#endif\n  char c;\n  int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != -3161)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161L };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57344-3.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  long long int a : 43;\n  long long int b : 22;\n  char c;\n  long long int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (long long int x)\n{\n  if (x != -3161LL)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -3161LL };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57344-4.c",
    "content": "/* PR middle-end/57344 */\n\nstruct __attribute__((packed)) S\n{\n  long long int a : 59;\n  long long int b : 54;\n  char c;\n  long long int : 0;\n} s[2];\nint i;\n\n__attribute__((noinline, noclone)) void\nfoo (long long int x)\n{\n  if (x != -1220975898975746LL)\n    __builtin_abort ();\n  asm volatile (\"\" : : : \"memory\");\n}\n\nint\nmain ()\n{\n  struct S t = { 0, -1220975898975746LL };\n  s[1] = t;\n  for (; i < 1; i++)\n    foo (s[1].b);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57568.c",
    "content": "/* PR target/57568 */\n\nextern void abort (void);\nint a[6][9] = { }, b = 1, *c = &a[3][5];\n\nint\nmain ()\n{\n  if (b && (*c = *c + *c))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57829.c",
    "content": "/* PR rtl-optimization/57829 */\n\n__attribute__((noinline, noclone))\nint\nf1 (int k)\n{\n  return 2 | ((k - 1) >> ((int) sizeof (int) * __CHAR_BIT__ - 1));\n}\n\n__attribute__((noinline, noclone))\nlong int\nf2 (long int k)\n{\n  return 2L | ((k - 1L) >> ((int) sizeof (long int) * __CHAR_BIT__ - 1));\n}\n\n__attribute__((noinline, noclone))\nint\nf3 (int k)\n{\n  k &= 63;\n  return 4 | ((k + 2) >> 5);\n}\n\nint\nmain ()\n{\n  if (f1 (1) != 2 || f2 (1L) != 2L || f3 (63) != 6 || f3 (1) != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57860.c",
    "content": "/* PR rtl-optimization/57860 */\n\nextern void abort (void);\nint a, *b = &a, c, d, e, *f = &e, g, *h = &d, k[1] = { 1 };\n\nint\nfoo (int p)\n{\n  for (;; g++)\n    {\n      for (; c; c--);\n      *f = *h = p > ((0x1FFFFFFFFLL ^ a) & *b);\n      if (k[g])\n\treturn 0;\n    }\n}\n\nint\nmain ()\n{\n  foo (1);\n  if (d != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57861.c",
    "content": "/* PR rtl-optimization/57861 */\n\nextern void abort (void);\nshort a = 1, f;\nint b, c, d, *g = &b, h, i, j;\nunsigned int e;\n\nstatic int\nfoo (char p)\n{\n  int k;\n  for (c = 0; c < 2; c++)\n    {\n      i = (j = 0) || p;\n      k = i * p;\n      if (e < k)\n\t{\n\t  short *l = &f;\n\t  a = d && h;\n\t  *l = 0;\n\t}\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  *g = foo (a);\n  if (a != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57875.c",
    "content": "/* PR rtl-optimization/57875 */\n\nextern void abort (void);\nint a[1], b, c, d, f, i;\nchar e[1];\n\nint\nmain ()\n{\n  for (; i < 1; i++)\n    if (!d)\n      {\n\tif (!c)\n\t  f = 2;\n\te[0] &= f ^= 0;\n      }\n  b = a[e[0] >> 1 & 1];\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57876.c",
    "content": "/* PR rtl-optimization/57876 */\n\nextern void abort (void);\nint a, b = 1, c, *d = &c, f, *g, h, j;\nstatic int e;\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 2; i++)\n    {\n      long long k = b;\n      int l;\n      for (f = 0; f < 8; f++)\n\t{\n\t  int *m = &e;\n\t  j = *d;\n\t  h = a * j - 1;\n\t  *m = (h == 0) < k;\n\t  g = &l;\n\t}\n    }\n  if (e != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr57877.c",
    "content": "/* PR rtl-optimization/57877 */\n\nextern void abort (void);\nint a, b, *c = &b, e, f = 6, g, h;\nshort d;\n\nstatic unsigned char\nfoo (unsigned long long p1, int *p2)\n{\n  for (; g <= 0; g++)\n    {\n      short *i = &d;\n      int *j = &e;\n      h = *c;\n      *i = h;\n      *j = (*i == *p2) < p1;\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  foo (f, &a);\n  if (e != 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58209.c",
    "content": "/* PR tree-optimization/58209 */\n\nextern void abort (void);\ntypedef __INTPTR_TYPE__ T;\nT buf[1024];\n\nT *\nfoo (T n)\n{\n  if (n == 0)\n    return (T *) buf;\n  T s = (T) foo (n - 1);\n  return (T *) (s + sizeof (T));\n}\n\nT *\nbar (T n)\n{\n  if (n == 0)\n    return buf;\n  return foo (n - 1) + 1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 27; i++)\n    if (foo (i) != buf + i || bar (i) != buf + i)\n      abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c",
    "content": "/* PR tree-optimization/58277 */\n\nextern void abort (void);\nstatic int a[2];\nint b, c, d, *e, f, g, h, **i = &e, k, l = 1, n, o, p;\nstatic int **volatile j = &e;\nconst int m;\nchar u;\n\nint\nbar ()\n{\n  u = 0;\n  return m;\n}\n\n__attribute__((noinline, noclone)) void\nbaz ()\n{\n  asm (\"\");\n}\n\nstatic int\nfoo ()\n{\n  int t1;\n  g = bar ();\n  if (l)\n    ;\n  else\n    for (;; h++)\n      {\n\t*i = 0;\n\to = *e = 0;\n\tif (p)\n\t  {\n\t    f = 0;\n\t    return 0;\n\t  }\n\tfor (;; k++)\n\t  {\n\t    int *t2 = 0;\n\t    int *const *t3[] = {\n\t      0, 0, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, &t2, &t2, &t2,\n\t      &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0,\n\t      0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, &t2,\n\t      &t2, &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0,\n\t      &t2, 0, 0, 0, &t2, 0, &t2, 0, 0, &t2, 0, 0, 0, 0,\n\t      0, &t2, 0, 0, 0, 0, &t2, &t2, 0, 0, 0, 0, &t2, 0,\n\t      0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, &t2, 0, 0, 0,\n\t      &t2, &t2\n\t    };\n\t    int *const **t4[] = {&t3[0]};\n\t    **i = 0;\n\t    if (**j)\n\t      break;\n\t    u = 0;\n\t  }\n\t*i = *j;\n\tt1 = 0;\n\tfor (; t1 < 5; t1++)\n\t  *i = *j;\n      }\n  *j = 0;\n  return 1;\n}\n\nint\nmain ()\n{\n  int t5;\n  a[0] = 1;\n  {\n    int *t6[6] = {&d, &d};\n    for (n = 1; n; n--)\n      if (foo())\n\t{\n\t  int *t7[] = {0};\n\t  d = 0;\n\t  for (; u < 1; u++)\n\t    *i = *j;\n\t  *i = 0;\n\t  *i = 0;\n\t  int t8[5] = {0};\n\t  *i = &t8[0];\n\t  int *const *t9 = &t6[0];\n\t  int *const **t10 = &t9;\n\t  *t10 = &t7[0];\n\t}\n  }\n  u = 0;\n  for (; b; b++)\n    for (t5 = 0; t5 < 10; t5++)\n      c = a[a[a[a[a[a[a[a[c]]]]]]]];\n\n  baz ();\n\n  if (!a[a[a[a[a[a[a[a[a[a[a[a[a[a[a[u]]]]]]]]]]]]]]])\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c",
    "content": "/* PR tree-optimization/58277 */\n\nextern void abort (void);\nstatic int a[1], b, c, e, i, j, k, m, q[] = { 1, 1 }, t;\nint volatile d;\nint **r;\nstatic int ***volatile s = &r;\nint f, g, o, x;\nstatic int *volatile h = &f, *p;\nchar n;\n\nstatic void\nfn1 ()\n{\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[b]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n  b = a[a[a[a[a[a[a[a[b]]]]]]]];\n}\n\nstatic int\nfn2 ()\n{\n  n = 0;\n  for (; g; t++)\n    {\n      for (;; m++)\n\t{\n\t  d;\n\t  int *u;\n\t  int **v[] = {\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t    0, 0, 0, 0, 0, &u, 0, 0, 0, 0, &u, &u, &u, &u, &u, &u, &u, 0,\n\t    &u, 0, &u, &u, &u, 0, &u, &u, 0, &u, &u, &u, &u, 0, &u, &u, &u,\n\t    &u, &u, 0, &u, &u, 0, &u, 0, &u, &u, 0, &u, &u, &u, &u, &u, 0,\n\t    &u, 0, 0, 0, &u, &u, &u, 0, 0, &u, &u, &u, 0, &u, 0, &u, &u\n\t  };\n\t  int ***w[] = { &v[0] };\n\t  if (*p)\n\t    break;\n\t  return 0;\n\t}\n      *h = 0;\n    }\n  return 1;\n}\n\nstatic void\nfn3 ()\n{\n  int *y[] = { 0, 0, 0, 0, 0, 0, 0, 0 };\n  for (; i; i++)\n    x = 0;\n  if (fn2 ())\n    {\n      int *z[6] = { };\n      for (; n < 1; n++)\n\t*h = 0;\n      int t1[7];\n      for (; c; c++)\n\to = t1[0];\n      for (; e; e--)\n\t{\n\t  int **t2 = &y[0];\n\t  int ***t3 = &t2;\n\t  *t3 = &z[0];\n\t}\n    }\n  *s = 0;\n  for (n = 0;; n = 0)\n    {\n      int t4 = 0;\n      if (q[n])\n\tbreak;\n      *r = &t4;\n    }\n}\n\nint\nmain ()\n{\n  for (; j; j--)\n    a[0] = 0;\n  fn3 ();\n  for (; k; k++)\n    fn1 ();\n  fn1 ();\n \n  if (n)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58364.c",
    "content": "/* PR tree-optimization/58364 */\n\nint a = 1, b, c;\n\nint\nfoo (int x)\n{\n  return x < 0 ? 1 : x;\n}\n\nint\nmain ()\n{\n  if (foo (a > c == (b = 0)))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58365.c",
    "content": "/* PR rtl-optimization/58365 */\n\nextern void abort (void);\n\nstruct S\n{\n  volatile int a;\n  int b, c, d, e;\n} f;\nstatic struct S g, h;\nint i = 1;\n\nchar\nfoo (void)\n{\n  return i;\n}\n\nstatic struct S\nbar (void)\n{\n  if (foo ())\n    return f;\n  return g;\n}\n\nint\nmain ()\n{\n  h = bar ();\n  f.b = 1;\n  if (h.b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58385.c",
    "content": "/* PR tree-optimization/58385 */\n\nextern void abort (void);\n\nint a, b = 1;\n\nint\nfoo ()\n{\n  b = 0;\n  return 0;\n}\n\nint\nmain ()\n{\n  ((0 || a) & foo () >= 0) <= 1 && 1;\n  if (b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58387.c",
    "content": "extern void abort(void);\n\nint a = -1; \n\nint main ()\n{\n  int b = a == 0 ? 0 : -a;\n  if (b < 1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58419.c",
    "content": "__attribute__((__noinline__))\nvoid\ndummy ()\n{\n  asm volatile(\"\");\n}\n\nint a, g, i, k, *p;\nsigned char b;\nchar e;\nshort c, h;\nstatic short *d = &c;\n\nchar\nfoo (int p1, int p2)\n{\n  return p1 - p2;\n}\n\nint\nbar ()\n{\n  short *q = &c;\n  *q = 1;\n  *p = 0;\n  return 0;\n}\n\nint\nmain ()\n{\n  for (b = -22; b >= -29; b--)\n    {\n      short *l = &h;\n      char *m = &e;\n      *l = a;\n      g = foo (*m = k && *d, 1 > i) || bar (); \n    }\n  dummy();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58431.c",
    "content": "char a, h;\nint b, d, e, g, j, k;\nvolatile int c;\nshort i;\n\nint\nmain ()\n{\n  int m;\n\n  m = i ^= 1;\n  for (b = 0; b < 1; b++)\n    {\n      char o = m;\n      g = k;\n      j = j || c;\n      if (a != o)\n\tfor (; d < 1; d++)\n\t  ;\n      else\n\t{\n\t  char *p = &h;\n\t  *p = 1;\n\t  for (; e; e++)\n\t    ;\n\t}\n    }\n\n  if (h != 0)\n    __builtin_abort(); \n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58564.c",
    "content": "/* PR middle-end/58564 */\n\nextern void abort (void);\nint a, b;\nshort *c, **d = &c;\n\nint\nmain ()\n{\n  b = (0, 0 > ((&c == d) & (1 && (a ^ 1)))) | 0U;\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58570.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#pragma pack(1)\nstruct S\n{\n  int f0:15;\n  int f1:29;\n};\n\nint e = 1, i;\nstatic struct S d[6];\n\nint\nmain (void)\n{\n  if (e)\n    {\n      d[i].f0 = 1;\n      d[i].f1 = 1;\n    }\n  if (d[0].f1 != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58574.c",
    "content": "/* PR target/58574 */\n\n__attribute__((noinline, noclone)) double\nfoo (double x)\n{\n  double t;\n  switch ((int) x)\n    {\n    case 0:\n      t = 2 * x - 1;\n      return 0.70878e-3 + (0.71234e-3 + (0.35779e-5 + (0.17403e-7 + (0.81710e-10 + (0.36885e-12 + 0.15917e-14 * t) * t) * t) * t) * t) * t;\n    case 1:\n      t = 2 * x - 3;\n      return 0.21479e-2 + (0.72686e-3 + (0.36843e-5 + (0.18071e-7 + (0.85496e-10 + (0.38852e-12 + 0.16868e-14 * t) * t) * t) * t) * t) * t;\n    case 2:\n      t = 2 * x - 5;\n      return 0.36165e-2 + (0.74182e-3 + (0.37948e-5 + (0.18771e-7 + (0.89484e-10 + (0.40935e-12 + 0.17872e-14 * t) * t) * t) * t) * t) * t;\n    case 3:\n      t = 2 * x - 7;\n      return 0.51154e-2 + (0.75722e-3 + (0.39096e-5 + (0.19504e-7 + (0.93687e-10 + (0.43143e-12 + 0.18939e-14 * t) * t) * t) * t) * t) * t;\n    case 4:\n      t = 2 * x - 9;\n      return 0.66457e-2 + (0.77310e-3 + (0.40289e-5 + (0.20271e-7 + (0.98117e-10 + (0.45484e-12 + 0.20076e-14 * t) * t) * t) * t) * t) * t;\n    case 5:\n      t = 2 * x - 11;\n      return 0.82082e-2 + (0.78946e-3 + (0.41529e-5 + (0.21074e-7 + (0.10278e-9 + (0.47965e-12 + 0.21285e-14 * t) * t) * t) * t) * t) * t;\n    case 6:\n      t = 2 * x - 13;\n      return 0.98039e-2 + (0.80633e-3 + (0.42819e-5 + (0.21916e-7 + (0.10771e-9 + (0.50595e-12 + 0.22573e-14 * t) * t) * t) * t) * t) * t;\n    case 7:\n      t = 2 * x - 15;\n      return 0.11433e-1 + (0.82372e-3 + (0.44160e-5 + (0.22798e-7 + (0.11291e-9 + (0.53386e-12 + 0.23944e-14 * t) * t) * t) * t) * t) * t;\n    case 8:\n      t = 2 * x - 17;\n      return 0.13099e-1 + (0.84167e-3 + (0.45555e-5 + (0.23723e-7 + (0.11839e-9 + (0.56346e-12 + 0.25403e-14 * t) * t) * t) * t) * t) * t;\n    case 9:\n      t = 2 * x - 19;\n      return 0.14800e-1 + (0.86018e-3 + (0.47008e-5 + (0.24694e-7 + (0.12418e-9 + (0.59486e-12 + 0.26957e-14 * t) * t) * t) * t) * t) * t;\n    case 10:\n      t = 2 * x - 21;\n      return 0.16540e-1 + (0.87928e-3 + (0.48520e-5 + (0.25711e-7 + (0.13030e-9 + (0.62820e-12 + 0.28612e-14 * t) * t) * t) * t) * t) * t;\n    case 11:\n      t = 2 * x - 23;\n      return 0.18318e-1 + (0.89900e-3 + (0.50094e-5 + (0.26779e-7 + (0.13675e-9 + (0.66358e-12 + 0.30375e-14 * t) * t) * t) * t) * t) * t;\n    case 12:\n      t = 2 * x - 25;\n      return 0.20136e-1 + (0.91936e-3 + (0.51734e-5 + (0.27900e-7 + (0.14357e-9 + (0.70114e-12 + 0.32252e-14 * t) * t) * t) * t) * t) * t;\n    case 13:\n      t = 2 * x - 27;\n      return 0.21996e-1 + (0.94040e-3 + (0.53443e-5 + (0.29078e-7 + (0.15078e-9 + (0.74103e-12 + 0.34251e-14 * t) * t) * t) * t) * t) * t;\n    case 14:\n      t = 2 * x - 29;\n      return 0.23898e-1 + (0.96213e-3 + (0.55225e-5 + (0.30314e-7 + (0.15840e-9 + (0.78340e-12 + 0.36381e-14 * t) * t) * t) * t) * t) * t;\n    case 15:\n      t = 2 * x - 31;\n      return 0.25845e-1 + (0.98459e-3 + (0.57082e-5 + (0.31613e-7 + (0.16646e-9 + (0.82840e-12 + 0.38649e-14 * t) * t) * t) * t) * t) * t;\n    case 16:\n      t = 2 * x - 33;\n      return 0.27837e-1 + (0.10078e-2 + (0.59020e-5 + (0.32979e-7 + (0.17498e-9 + (0.87622e-12 + 0.41066e-14 * t) * t) * t) * t) * t) * t;\n    case 17:\n      t = 2 * x - 35;\n      return 0.29877e-1 + (0.10318e-2 + (0.61041e-5 + (0.34414e-7 + (0.18399e-9 + (0.92703e-12 + 0.43639e-14 * t) * t) * t) * t) * t) * t;\n    case 18:\n      t = 2 * x - 37;\n      return 0.31965e-1 + (0.10566e-2 + (0.63151e-5 + (0.35924e-7 + (0.19353e-9 + (0.98102e-12 + 0.46381e-14 * t) * t) * t) * t) * t) * t;\n    case 19:\n      t = 2 * x - 39;\n      return 0.34104e-1 + (0.10823e-2 + (0.65354e-5 + (0.37512e-7 + (0.20362e-9 + (0.10384e-11 + 0.49300e-14 * t) * t) * t) * t) * t) * t;\n    case 20:\n      t = 2 * x - 41;\n      return 0.36295e-1 + (0.11089e-2 + (0.67654e-5 + (0.39184e-7 + (0.21431e-9 + (0.10994e-11 + 0.52409e-14 * t) * t) * t) * t) * t) * t;\n    case 21:\n      t = 2 * x - 43;\n      return 0.38540e-1 + (0.11364e-2 + (0.70058e-5 + (0.40943e-7 + (0.22563e-9 + (0.11642e-11 + 0.55721e-14 * t) * t) * t) * t) * t) * t;\n    case 22:\n      t = 2 * x - 45;\n      return 0.40842e-1 + (0.11650e-2 + (0.72569e-5 + (0.42796e-7 + (0.23761e-9 + (0.12332e-11 + 0.59246e-14 * t) * t) * t) * t) * t) * t;\n    case 23:\n      t = 2 * x - 47;\n      return 0.43201e-1 + (0.11945e-2 + (0.75195e-5 + (0.44747e-7 + (0.25030e-9 + (0.13065e-11 + 0.63000e-14 * t) * t) * t) * t) * t) * t;\n    case 24:\n      t = 2 * x - 49;\n      return 0.45621e-1 + (0.12251e-2 + (0.77941e-5 + (0.46803e-7 + (0.26375e-9 + (0.13845e-11 + 0.66996e-14 * t) * t) * t) * t) * t) * t;\n    case 25:\n      t = 2 * x - 51;\n      return 0.48103e-1 + (0.12569e-2 + (0.80814e-5 + (0.48969e-7 + (0.27801e-9 + (0.14674e-11 + 0.71249e-14 * t) * t) * t) * t) * t) * t;\n    case 26:\n      t = 2 * x - 59;\n      return 0.58702e-1 + (0.13962e-2 + (0.93714e-5 + (0.58882e-7 + (0.34414e-9 + (0.18552e-11 + 0.91160e-14 * t) * t) * t) * t) * t) * t;\n    case 30:\n      t = 2 * x - 79;\n      return 0.90908e-1 + (0.18544e-2 + (0.13903e-4 + (0.95549e-7 + (0.59752e-9 + (0.33656e-11 + 0.16815e-13 * t) * t) * t) * t) * t) * t;\n    case 40:\n      t = 2 * x - 99;\n      return 0.13443e0 + (0.25474e-2 + (0.21385e-4 + (0.15996e-6 + (0.10585e-8 + (0.61258e-11 + 0.30412e-13 * t) * t) * t) * t) * t) * t;\n    case 50:\n      t = 2 * x - 119;\n      return 0.19540e0 + (0.36342e-2 + (0.34096e-4 + (0.27479e-6 + (0.18934e-8 + (0.11021e-10 + 0.52931e-13 * t) * t) * t) * t) * t) * t;\n    case 60:\n      t = 2 * x - 121;\n      return 0.20281e0 + (0.37739e-2 + (0.35791e-4 + (0.29038e-6 + (0.20068e-8 + (0.11673e-10 + 0.55790e-13 * t) * t) * t) * t) * t) * t;\n    case 61:\n      t = 2 * x - 123;\n      return 0.21050e0 + (0.39206e-2 + (0.37582e-4 + (0.30691e-6 + (0.21270e-8 + (0.12361e-10 + 0.58770e-13 * t) * t) * t) * t) * t) * t;\n    case 62:\n      t = 2 * x - 125;\n      return 0.21849e0 + (0.40747e-2 + (0.39476e-4 + (0.32443e-6 + (0.22542e-8 + (0.13084e-10 + 0.61873e-13 * t) * t) * t) * t) * t) * t;\n    case 63:\n      t = 2 * x - 127;\n      return 0.22680e0 + (0.42366e-2 + (0.41477e-4 + (0.34300e-6 + (0.23888e-8 + (0.13846e-10 + 0.65100e-13 * t) * t) * t) * t) * t) * t;\n    case 64:\n      t = 2 * x - 129;\n      return 0.23545e0 + (0.44067e-2 + (0.43594e-4 + (0.36268e-6 + (0.25312e-8 + (0.14647e-10 + 0.68453e-13 * t) * t) * t) * t) * t) * t;\n    case 65:\n      t = 2 * x - 131;\n      return 0.24444e0 + (0.45855e-2 + (0.45832e-4 + (0.38352e-6 + (0.26819e-8 + (0.15489e-10 + 0.71933e-13 * t) * t) * t) * t) * t) * t;\n    case 66:\n      t = 2 * x - 133;\n      return 0.25379e0 + (0.47735e-2 + (0.48199e-4 + (0.40561e-6 + (0.28411e-8 + (0.16374e-10 + 0.75541e-13 * t) * t) * t) * t) * t) * t;\n    case 67:\n      t = 2 * x - 135;\n      return 0.26354e0 + (0.49713e-2 + (0.50702e-4 + (0.42901e-6 + (0.30095e-8 + (0.17303e-10 + 0.79278e-13 * t) * t) * t) * t) * t) * t;\n    case 68:\n      t = 2 * x - 137;\n      return 0.27369e0 + (0.51793e-2 + (0.53350e-4 + (0.45379e-6 + (0.31874e-8 + (0.18277e-10 + 0.83144e-13 * t) * t) * t) * t) * t) * t;\n    case 69:\n      t = 2 * x - 139;\n      return 0.28426e0 + (0.53983e-2 + (0.56150e-4 + (0.48003e-6 + (0.33752e-8 + (0.19299e-10 + 0.87139e-13 * t) * t) * t) * t) * t) * t;\n    case 70:\n      t = 2 * x - 141;\n      return 0.29529e0 + (0.56288e-2 + (0.59113e-4 + (0.50782e-6 + (0.35735e-8 + (0.20369e-10 + 0.91262e-13 * t) * t) * t) * t) * t) * t;\n    case 71:\n      t = 2 * x - 143;\n      return 0.30679e0 + (0.58714e-2 + (0.62248e-4 + (0.53724e-6 + (0.37827e-8 + (0.21490e-10 + 0.95513e-13 * t) * t) * t) * t) * t) * t;\n    case 72:\n      t = 2 * x - 145;\n      return 0.31878e0 + (0.61270e-2 + (0.65564e-4 + (0.56837e-6 + (0.40035e-8 + (0.22662e-10 + 0.99891e-13 * t) * t) * t) * t) * t) * t;\n    case 73:\n      t = 2 * x - 147;\n      return 0.33130e0 + (0.63962e-2 + (0.69072e-4 + (0.60133e-6 + (0.42362e-8 + (0.23888e-10 + 0.10439e-12 * t) * t) * t) * t) * t) * t;\n    case 74:\n      t = 2 * x - 149;\n      return 0.34438e0 + (0.66798e-2 + (0.72783e-4 + (0.63619e-6 + (0.44814e-8 + (0.25168e-10 + 0.10901e-12 * t) * t) * t) * t) * t) * t;\n    case 75:\n      t = 2 * x - 151;\n      return 0.35803e0 + (0.69787e-2 + (0.76710e-4 + (0.67306e-6 + (0.47397e-8 + (0.26505e-10 + 0.11376e-12 * t) * t) * t) * t) * t) * t;\n    case 76:\n      t = 2 * x - 153;\n      return 0.37230e0 + (0.72938e-2 + (0.80864e-4 + (0.71206e-6 + (0.50117e-8 + (0.27899e-10 + 0.11862e-12 * t) * t) * t) * t) * t) * t;\n    case 77:\n      t = 2 * x - 155;\n      return 0.38722e0 + (0.76260e-2 + (0.85259e-4 + (0.75329e-6 + (0.52979e-8 + (0.29352e-10 + 0.12360e-12 * t) * t) * t) * t) * t) * t;\n    case 78:\n      t = 2 * x - 157;\n      return 0.40282e0 + (0.79762e-2 + (0.89909e-4 + (0.79687e-6 + (0.55989e-8 + (0.30866e-10 + 0.12868e-12 * t) * t) * t) * t) * t) * t;\n    case 79:\n      t = 2 * x - 159;\n      return 0.41914e0 + (0.83456e-2 + (0.94827e-4 + (0.84291e-6 + (0.59154e-8 + (0.32441e-10 + 0.13387e-12 * t) * t) * t) * t) * t) * t;\n    case 80:\n      t = 2 * x - 161;\n      return 0.43621e0 + (0.87352e-2 + (0.10002e-3 + (0.89156e-6 + (0.62480e-8 + (0.34079e-10 + 0.13917e-12 * t) * t) * t) * t) * t) * t;\n    case 81:\n      t = 2 * x - 163;\n      return 0.45409e0 + (0.91463e-2 + (0.10553e-3 + (0.94293e-6 + (0.65972e-8 + (0.35782e-10 + 0.14455e-12 * t) * t) * t) * t) * t) * t;\n    case 82:\n      t = 2 * x - 165;\n      return 0.47282e0 + (0.95799e-2 + (0.11135e-3 + (0.99716e-6 + (0.69638e-8 + (0.37549e-10 + 0.15003e-12 * t) * t) * t) * t) * t) * t;\n    case 83:\n      t = 2 * x - 167;\n      return 0.49243e0 + (0.10037e-1 + (0.11750e-3 + (0.10544e-5 + (0.73484e-8 + (0.39383e-10 + 0.15559e-12 * t) * t) * t) * t) * t) * t;\n    case 84:\n      t = 2 * x - 169;\n      return 0.51298e0 + (0.10520e-1 + (0.12400e-3 + (0.11147e-5 + (0.77517e-8 + (0.41283e-10 + 0.16122e-12 * t) * t) * t) * t) * t) * t;\n    case 85:\n      t = 2 * x - 171;\n      return 0.53453e0 + (0.11030e-1 + (0.13088e-3 + (0.11784e-5 + (0.81743e-8 + (0.43252e-10 + 0.16692e-12 * t) * t) * t) * t) * t) * t;\n    case 86:\n      t = 2 * x - 173;\n      return 0.55712e0 + (0.11568e-1 + (0.13815e-3 + (0.12456e-5 + (0.86169e-8 + (0.45290e-10 + 0.17268e-12 * t) * t) * t) * t) * t) * t;\n    case 87:\n      t = 2 * x - 175;\n      return 0.58082e0 + (0.12135e-1 + (0.14584e-3 + (0.13164e-5 + (0.90803e-8 + (0.47397e-10 + 0.17850e-12 * t) * t) * t) * t) * t) * t;\n    case 88:\n      t = 2 * x - 177;\n      return 0.60569e0 + (0.12735e-1 + (0.15396e-3 + (0.13909e-5 + (0.95651e-8 + (0.49574e-10 + 0.18435e-12 * t) * t) * t) * t) * t) * t;\n    case 89:\n      t = 2 * x - 179;\n      return 0.63178e0 + (0.13368e-1 + (0.16254e-3 + (0.14695e-5 + (0.10072e-7 + (0.51822e-10 + 0.19025e-12 * t) * t) * t) * t) * t) * t;\n    case 90:\n      t = 2 * x - 181;\n      return 0.65918e0 + (0.14036e-1 + (0.17160e-3 + (0.15521e-5 + (0.10601e-7 + (0.54140e-10 + 0.19616e-12 * t) * t) * t) * t) * t) * t;\n    case 91:\n      t = 2 * x - 183;\n      return 0.68795e0 + (0.14741e-1 + (0.18117e-3 + (0.16392e-5 + (0.11155e-7 + (0.56530e-10 + 0.20209e-12 * t) * t) * t) * t) * t) * t;\n    case 92:\n      t = 2 * x - 185;\n      return 0.71818e0 + (0.15486e-1 + (0.19128e-3 + (0.17307e-5 + (0.11732e-7 + (0.58991e-10 + 0.20803e-12 * t) * t) * t) * t) * t) * t;\n    case 93:\n      t = 2 * x - 187;\n      return 0.74993e0 + (0.16272e-1 + (0.20195e-3 + (0.18269e-5 + (0.12335e-7 + (0.61523e-10 + 0.21395e-12 * t) * t) * t) * t) * t) * t;\n    }\n  return 1.0;\n}\n\nint\nmain ()\n{\n#ifdef __s390x__\n  {\n    register unsigned long r5 __asm (\"r5\");\n    r5 = 0xdeadbeefUL;\n    asm volatile (\"\":\"+r\" (r5));\n  }\n#endif\n  double d = foo (78.4);\n  if (d < 0.38 || d > 0.42)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58640-2.c",
    "content": "extern void abort (void);\n\nint a[20], b, c; \n\nint\nfn1 ()\n{\n  int d, e, f, g = 0; \n\n  a[12] = 1;\n  for (e = 0; e < 3; e++)\n    for (d = 0; d < 2; d++)\n      {\n\tfor (f = 0; f < 2; f++)\n\t  {\n\t    g ^= a[12] > 1;\n\t    if (g)\n\t      return 0;\n\t    if (b)\n\t      break;\n\t  }\n\tfor (c = 0; c < 1; c++)\n\t  a[d] = a[e * 3 + 9]; \n      }\n  return 0;\n}\n\nint\nmain ()\n{\n  fn1 ();\n  if (a[0] != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58640.c",
    "content": "int a, b, c, d = 1, e;\n\nstatic signed char\nfoo ()\n{\n  int f, g = a;\n\n  for (f = 1; f < 3; f++)\n    for (; b < 1; b++)\n      {\n        if (d)\n          for (c = 0; c < 4; c++)\n            for (f = 0; f < 3; f++)\n              {\n                for (e = 0; e < 1; e++)\n                  a = g;\n                if (f)\n                  break;\n              }\n        else if (f)\n          continue;\n        return 0;\n      }\n  return 0;\n}\n\nint\nmain ()\n{\n  foo ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58662.c",
    "content": "extern void abort (void);\n\nint a, c, d;\nvolatile int b;\n\nstatic int\nfoo (int p1, short p2)\n{\n  return p1 / p2;\n}\n\nint\nmain ()\n{\n  char e;\n  d = foo (a == 0, (0, 35536)); \n  e = d % 14;\n  b = e && c;\n  if (b != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58726.c",
    "content": "/* PR rtl-optimization/58726 */\n\nint a, c;\nunion { int f1; int f2 : 1; } b;\n\nshort\nfoo (short p)\n{\n  return p < 0 ? p : a;\n}\n\nint\nmain ()\n{\n  if (sizeof (short) * __CHAR_BIT__ != 16\n      || sizeof (int) * __CHAR_BIT__ != 32)\n    return 0;\n  b.f1 = 56374;\n  unsigned short d;\n  int e = b.f2;\n  d = e == 0 ? b.f1 : 0;\n  c = foo (d);\n  if (c != (short) 56374)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58831.c",
    "content": "#include <assert.h>\n\nint a, *b, c, d, f, **i, p, q, *r;\nshort o, j;\n\nstatic int __attribute__((noinline, noclone))\nfn1 (int *p1, int **p2)\n{\n  int **e = &b;\n  for (; p; p++)\n    *p1 = 1;\n  *e = *p2 = &d;\n\n  assert (r);\n\n  return c;\n}\n\nstatic int ** __attribute__((noinline, noclone))\nfn2 (void)\n{\n  for (f = 0; f != 42; f++)\n    {\n      int *g[3] = {0, 0, 0};\n      for (o = 0; o; o--)\n        for (; a > 1;)\n          {\n            int **h[1] = { &g[2] };\n          }\n    }\n  return &r;\n}\n\nint\nmain (void)\n{\n  i = fn2 ();\n  fn1 (b, i);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58943.c",
    "content": "/* PR c/58943 */\n\nunsigned int x[1] = { 2 };\n\nunsigned int\nfoo (void)\n{\n  x[0] |= 128;\n  return 1;\n}\n\nint\nmain ()\n{\n  x[0] |= foo ();\n  if (x[0] != 131)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr58984.c",
    "content": "/* PR tree-optimization/58984 */\n\nstruct S { int f0 : 8; int : 6; int f1 : 5; };\nstruct T { char f0; int : 6; int f1 : 5; };\n\nint a, *c = &a, e, n, b, m;\n\nstatic int\nfoo (struct S p)\n{\n  const unsigned short *f[36];\n  for (; e < 2; e++)\n    {\n      const unsigned short **i = &f[0];\n      *c ^= 1;\n      if (p.f1)\n\t{\n\t  *i = 0;\n\t  return b;\n\t}\n    }\n  return 0;\n}\n\nstatic int\nbar (struct T p)\n{\n  const unsigned short *f[36];\n  for (; e < 2; e++)\n    {\n      const unsigned short **i = &f[0];\n      *c ^= 1;\n      if (p.f1)\n\t{\n\t  *i = 0;\n\t  return b;\n\t}\n    }\n  return 0;\n}\n\nint\nmain ()\n{\n  struct S o = { 1, 1 };\n  foo (o);\n  m = n || o.f0;\n  if (a != 1)\n    __builtin_abort ();\n  e = 0;\n  struct T p = { 1, 1 };\n  bar (p);\n  m |= n || p.f0;\n  if (a != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c",
    "content": "/* PR tree-optimization/59014 */\n\n__attribute__((noinline, noclone)) long long int\nfoo (long long int x, long long int y)\n{\n  if (((int) x | (int) y) != 0)\n    return 6;\n  return x + y;\n}\n\nint\nmain ()\n{\n  if (sizeof (long long) == sizeof (int))\n    return 0;\n  int shift_half = sizeof (int) * __CHAR_BIT__ / 2;\n  long long int x = (3LL << shift_half) << shift_half;\n  long long int y = (5LL << shift_half) << shift_half;\n  long long int z = foo (x, y);\n  if (z != ((8LL << shift_half) << shift_half))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59014.c",
    "content": "/* PR tree-optimization/59014 */\n\nint a = 2, b, c, d;\n\nint\nfoo ()\n{\n  for (;; c++)\n    if ((b > 0) | (a & 1))\n      ;\n    else\n      {\n\td = a;\n\treturn 0;\n      }\n}\n\nint\nmain ()\n{\n  foo ();\n  if (d != 2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59101.c",
    "content": "/* PR target/59101 */\n\n__attribute__((noinline, noclone)) int\nfoo (int a)\n{\n  return (~a & 4102790424LL) > 0 | 6;\n}\n\nint\nmain ()\n{\n  if (foo (0) != 7)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59221.c",
    "content": "/* { dg-xfail-if \"ptxas crashes\" { nvptx-*-* } { \"*\" } { \"-O0\" \"-Os\" } } */\n\n\nint a = 1, b, d;\nshort e;\n\nint\nmain ()\n{\n  for (; b; b++)\n    ;\n  short f = a;\n  int g = 15;\n  e = f ? f : 1 << g;\n  int h = e;\n  d = h == 83647 ? 0 : h;\n  if (d != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59229.c",
    "content": "int i;\n\n__attribute__((noinline, noclone)) void\nbar (char *p)\n{\n  if (i < 1 || i > 6)\n    __builtin_abort ();\n  if (__builtin_memcmp (p, \"abcdefg\", i + 1) != 0)\n    __builtin_abort ();\n  __builtin_memset (p, ' ', 7);\n}\n\n__attribute__((noinline, noclone)) void\nfoo (char *p, unsigned long l)\n{\n  if (l < 1 || l > 6)\n    return;\n  char buf[7];\n  __builtin_memcpy (buf, p, l + 1);\n  bar (buf);\n}\n\nint\nmain ()\n{\n  for (i = 0; i < 16; i++)\n    foo (\"abcdefghijklmnop\", i);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59358.c",
    "content": "/* PR tree-optimization/59358 */\n\n__attribute__((noinline, noclone)) int\nfoo (int *x, int y)\n{\n  int z = *x;\n  if (y > z && y <= 16)\n    while (y > z)\n      z *= 2;\n  return z;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 1; i < 17; i++)\n    {\n      int j = foo (&i, 16);\n      int k;\n      if (i >= 8 && i <= 15)\n\tk = 16 + (i - 8) * 2;\n      else if (i >= 4 && i <= 7)\n\tk = 16 + (i - 4) * 4;\n      else if (i == 3)\n\tk = 24;\n      else\n\tk = 16;\n      if (j != k)\n\t__builtin_abort ();\n      j = foo (&i, 7);\n      if (i >= 7)\n\tk = i;\n      else if (i >= 4)\n\tk = 8 + (i - 4) * 2;\n      else if (i == 3)\n\tk = 12;\n      else\n\tk = 8;\n      if (j != k)\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59387.c",
    "content": "/* PR tree-optimization/59387 */\n\nint a, *d, **e = &d, f;\nchar c;\nstruct S { int f1; } b;\n\nint\nmain ()\n{\n  for (a = -19; a; a++)\n    {\n      for (b.f1 = 0; b.f1 < 24; b.f1++)\n\tc--;\n      *e = &f;\n      if (!d)\n\treturn 0;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59388.c",
    "content": "/* PR tree-optimization/59388 */\n\nint a;\nstruct S { unsigned int f:1; } b;\n\nint\nmain ()\n{\n  a = (0 < b.f) | b.f;\n  return a;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59413.c",
    "content": "/* PR tree-optimization/59413 */\n\ntypedef unsigned int uint32_t;\n\nuint32_t a;\nint b;\n\nint\nmain ()\n{\n  uint32_t c;\n  for (a = 7; a <= 1; a++)\n    {\n      char d = a;\n      c = d;\n      b = a == c;\n    }\n  if (a != 7)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59643.c",
    "content": "/* PR tree-optimization/59643 */\n\n#define N 32\n\n__attribute__((noinline, noclone)) void\nfoo (double *a, double *b, double *c, double d, double e, int n)\n{\n  int i;\n  for (i = 1; i < n - 1; i++)\n    a[i] = d * (b[i] + c[i] + a[i - 1] + a[i + 1]) + e * a[i];\n}\n\ndouble expected[] = {\n  0.0, 10.0, 44.0, 110.0, 232.0, 490.0, 1020.0, 2078.0, 4152.0, 8314.0,\n  16652.0, 33326.0, 66664.0, 133354.0, 266748.0, 533534.0, 1067064.0,\n  2134138.0, 4268300.0, 8536622.0, 17073256.0, 34146538.0, 68293116.0,\n  136586270.0, 273172536.0, 546345082.0, 1092690188.0, 2185380398.0,\n  4370760808.0, 8741521642.0, 17483043324.0, 6.0\n};\n\nint\nmain ()\n{\n  int i;\n  double a[N], b[N], c[N];\n  if (__DBL_MANT_DIG__ <= 35)\n    return 0;\n  for (i = 0; i < N; i++)\n    {\n      a[i] = (i & 3) * 2.0;\n      b[i] = (i & 7) - 4;\n      c[i] = i & 7;\n    }\n  foo (a, b, c, 2.0, 3.0, N);\n  for (i = 0; i < N; i++)\n    if (a[i] != expected[i])\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr59747.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nint a[6], c = 1, d;\nshort e;\n\nint __attribute__ ((noinline))\nfn1 (int p)\n{\n  return a[p];\n}\n\nint\nmain ()\n{\n  if (sizeof (long long) != 8)\n    exit (0);\n\n  a[0] = 1;\n  if (c)\n    e--;\n  d = e;\n  long long f = e;\n  if (fn1 ((f >> 56) & 1) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60003.c",
    "content": "/* PR tree-optimization/60003 */\n/* { dg-require-effective-target indirect_jumps } */\n\nextern void abort (void);\n\nunsigned long long jmp_buf[5];\n\n__attribute__((noinline, noclone)) void\nbaz (void)\n{\n  __builtin_longjmp (&jmp_buf, 1);\n}\n\nvoid\nbar (void)\n{\n  baz ();\n}\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  int a = 0;\n\n  if (__builtin_setjmp (&jmp_buf) == 0)\n    {\n      while (1)\n\t{\n\t  a = 1;\n\t  bar ();  /* OK if baz () instead */\n\t}\n    }\n  else\n    {\n      if (a == 0)\n\treturn 0;\n      else\n\treturn x;\n    }\n}\n\nint\nmain ()\n{\n  if (foo (1) == 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60017.c",
    "content": "/* PR target/60017 */\n\nextern void abort (void);\n\nstruct S0\n{\n  short m0;\n  short m1;\n};\n\nstruct S1\n{\n  unsigned m0:1;\n  char m1[2][2];\n  struct S0 m2[2];\n};\n\nstruct S1 x = { 1, {{2, 3}, {4, 5}}, {{6, 7}, {8, 9}} };\n\nstruct S1 func (void)\n{\n  return x;\n}\n\nint main (void)\n{\n  struct S1 ret = func ();\n\n  if (ret.m2[1].m1 != 9)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60062.c",
    "content": "/* PR target/60062 */\n\nint a;\n\nstatic void\nfoo (const char *p1, int p2)\n{\n  if (__builtin_strcmp (p1, \"hello\") != 0)\n    __builtin_abort ();\n}\n\nstatic void\nbar (const char *p1)\n{\n  if (__builtin_strcmp (p1, \"hello\") != 0)\n    __builtin_abort ();\n}\n\n__attribute__((optimize (0))) int\nmain ()\n{\n  foo (\"hello\", a);\n  bar (\"hello\");\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60072.c",
    "content": "/* PR target/60072 */\n\nint c = 1;\n\n__attribute__ ((optimize (1)))\nstatic int *foo (int *p)\n{\n  return p;\n}\n\nint\nmain ()\n{\n  *foo (&c) = 2;\n  return c - 2;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60454.c",
    "content": "#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t\t      \\\n        (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |            \\\n        (((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |            \\\n        (((uint32_t)(x) & (uint32_t)0x000000ffUL) <<  8) |            \\\n        (((uint32_t)(x) & (uint32_t)0x0000ff00UL)      ) |            \\\n        (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))\n\n/* Previous version of bswap optimization would detect byte swap when none\n   happen. This test aims at catching such wrong detection to avoid\n   regressions.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_swap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint main(void)\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (fake_swap32 (0x12345678UL) != 0x78567E12UL)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60822.c",
    "content": "/* { dg-require-effective-target int32plus } */\nstruct X {\n    char fill0[800000];\n    int a;\n    char fill1[900000];\n    int b;\n};\n\nint __attribute__((noinline,noclone))\nAvg(struct X *p, int s)\n{\n    return (s * (long long)(p->a + p->b)) >> 17;\n}\n\nstruct X x;\n\nint main()\n{\n    x.a = 1 << 17;\n    x.b = 2 << 17;\n    if (Avg(&x, 1) != 3)\n\t__builtin_abort();\n    return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr60960.c",
    "content": "/* PR tree-optimization/60960 */\n\ntypedef unsigned char v4qi __attribute__ ((vector_size (4)));\n\n__attribute__((noinline, noclone)) v4qi\nf1 (v4qi v)\n{\n  return v / 2;\n}\n\n__attribute__((noinline, noclone)) v4qi\nf2 (v4qi v)\n{\n  return v / (v4qi) { 2, 2, 2, 2 };\n}\n\n__attribute__((noinline, noclone)) v4qi\nf3 (v4qi x, v4qi y)\n{\n  return x / y;\n}\n\nint\nmain ()\n{\n  v4qi x = { 5, 5, 5, 5 };\n  v4qi y = { 2, 2, 2, 2 };\n  v4qi z = f1 (x);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  z = f2 (x);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  z = f3 (x, y);\n  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61306-1.c",
    "content": "#ifdef __INT32_TYPE__\ntypedef __INT32_TYPE__ int32_t;\n#else\ntypedef int int32_t;\n#endif\n\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t      \\\n\t(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |    \\\n\t(((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |    \\\n\t(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |    \\\n\t(( (int32_t)(x) &  (int32_t)0xff000000UL) >> 24)))\n\n/* Previous version of bswap optimization failed to consider sign extension\n   and as a result would replace an expression *not* doing a bswap by a\n   bswap.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_bswap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint\nmain(void)\n{\n  if (sizeof (int32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (fake_bswap32 (0x87654321) != 0xffffff87)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61306-2.c",
    "content": "#ifdef __INT16_TYPE__\ntypedef __INT16_TYPE__ int16_t;\n#else\ntypedef short int16_t;\n#endif\n\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#define __fake_const_swab32(x) ((uint32_t)(\t\t\t      \\\n\t(((uint32_t)         (x) & (uint32_t)0x000000ffUL) << 24) |   \\\n\t(((uint32_t)(int16_t)(x) & (uint32_t)0x00ffff00UL) <<  8) |   \\\n\t(((uint32_t)         (x) & (uint32_t)0x00ff0000UL) >>  8) |   \\\n\t(((uint32_t)         (x) & (uint32_t)0xff000000UL) >> 24)))\n\n\n/* Previous version of bswap optimization failed to consider sign extension\n   and as a result would replace an expression *not* doing a bswap by a\n   bswap.  */\n\n__attribute__ ((noinline, noclone)) uint32_t\nfake_bswap32 (uint32_t in)\n{\n  return __fake_const_swab32 (in);\n}\n\nint\nmain(void)\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n  if (sizeof (int16_t) * __CHAR_BIT__ != 16)\n    return 0;\n  if (fake_bswap32 (0x81828384) != 0xff838281)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61306-3.c",
    "content": "short a = -1;\nint b;\nchar c;\n\nint\nmain ()\n{\n  c = a;\n  b = a | c;\n  if (b != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61375.c",
    "content": "#ifdef __UINT64_TYPE__\ntypedef __UINT64_TYPE__ uint64_t;\n#else\ntypedef unsigned long long uint64_t;\n#endif\n\n#ifndef __SIZEOF_INT128__\n#define __int128 long long\n#endif\n\n/* Some version of bswap optimization would ICE when analyzing a mask constant\n   too big for an uint64_t variable (PR210931).  */\n\n__attribute__ ((noinline, noclone)) uint64_t\nuint128_central_bitsi_ior (unsigned __int128 in1, uint64_t in2)\n{\n  __int128 mask = (__int128)0xffff << 56;\n  return ((in1 & mask) >> 56) | in2;\n}\n\nint\nmain(int argc, char **argv)\n{\n  __int128 in = 1;\n#ifdef __SIZEOF_INT128__\n  in <<= 64;\n#endif\n  if (sizeof (uint64_t) * __CHAR_BIT__ != 64)\n    return 0;\n  if (sizeof (unsigned __int128) * __CHAR_BIT__ != 128)\n    return 0;\n  if (uint128_central_bitsi_ior (in, 2) != 0x102)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61517.c",
    "content": "int a, b, *c = &a;\nunsigned short d;\n\nint\nmain ()\n{\n  unsigned int e = a;\n  *c = 1;\n  if (!b)\n    {\n      d = e;\n      *c = d | e;\n    }\n\n  if (a != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61673.c",
    "content": "/* PR rtl-optimization/61673 */\n\nchar e;\n\n__attribute__((noinline, noclone)) void\nbar (char x)\n{\n  if (x != 0x54 && x != (char) 0x87)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (const char *x)\n{\n  char d = x[0];\n  int c = d;\n  if ((c >= 0 && c <= 0x7f) == 0)\n    e = d;\n  bar (d);\n}\n\n__attribute__((noinline, noclone)) void\nbaz (const char *x)\n{\n  char d = x[0];\n  int c = d;\n  if ((c >= 0 && c <= 0x7f) == 0)\n    e = d;\n}\n\nint\nmain ()\n{\n  const char c[] = { 0x54, 0x87 };\n  e = 0x21;\n  foo (c);\n  if (e != 0x21)\n    __builtin_abort ();\n  foo (c + 1);\n  if (e != (char) 0x87)\n    __builtin_abort ();\n  e = 0x21;\n  baz (c);\n  if (e != 0x21)\n    __builtin_abort ();\n  baz (c + 1);\n  if (e != (char) 0x87)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61682.c",
    "content": "/* PR tree-optimization/61682 */\n\nint a, b;\nstatic int *c = &b;\n\nint\nmain ()\n{\n  int *d = &a;\n  for (a = 0; a < 12; a++)\n    *c |= *d / 9;\n\n  if (b != 1)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr61725.c",
    "content": "/* PR tree-optimization/61725 */\n\nint\nmain ()\n{\n  int x;\n  for (x = -128; x <= 128; x++)\n    {\n      int a = __builtin_ffs (x);\n      if (x == 0 && a != 0)\n        __builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr62151.c",
    "content": "/* PR rtl-optimization/62151 */\n\nint a, c, d, e, f, g, h, i;\nshort b;\n\nint\nfn1 ()\n{\n  b = 0;\n  for (;;)\n    {\n      int j[2];\n      j[f] = 0;\n      if (h)\n\td = 0;\n      else\n\t{\n\t  for (; f; f++)\n\t    ;\n\t  for (a = 0; a < 1; a++)\n\t    for (;;)\n\t      {\n\t\ti = b & ((b ^ 1) & 83647) ? b : b - 1;\n\t\tg = 1 ? i : 0;\n\t\te = j[0];\n\t\tif (c)\n\t\t  break;\n\t\treturn 0;\n\t      }\n\t}\n    }\n}\n\nint\nmain ()\n{\n  fn1 ();\n  if (g != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr63209.c",
    "content": "static int Sub(int a, int b) {\n  return  b -a;\n}\n\nstatic unsigned Select(unsigned a, unsigned b, unsigned c) {\n  const int pa_minus_pb =\n      Sub((a >>  8) & 0xff, (b >>  8) & 0xff) + \n      Sub((a >>  0) & 0xff, (b >>  0) & 0xff); \n  return (pa_minus_pb <= 0) ? a : b;\n}\n\n__attribute__((noinline)) unsigned Predictor(unsigned left, const unsigned* const top) {\n  const unsigned pred = Select(top[1], left, top[0]);\n  return pred;\n}\n\nint main(void) {\n  const unsigned top[2] = {0xff7a7a7a, 0xff7a7a7a};\n  const unsigned left = 0xff7b7b7b;\n  const unsigned pred = Predictor(left, top /*+ 1*/);\n  if (pred == left)\n    return 0;\n  return 1;\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr63302.c",
    "content": "/* PR tree-optimization/63302 */\n\n#ifdef __SIZEOF_INT128__\n#if __SIZEOF_INT128__ * __CHAR_BIT__ == 128\n#define USE_INT128\n#endif\n#endif\n#if __SIZEOF_LONG_LONG__ * __CHAR_BIT__ == 64\n#define USE_LLONG\n#endif\n\n#ifdef USE_INT128\n__attribute__((noinline, noclone)) int\nfoo (__int128 x)\n{\n  __int128 v = x & (((__int128) -1 << 63) | 0x7ff);\n \n  return v == 0 || v == ((__int128) -1 << 63);\n}\n#endif\n\n#ifdef USE_LLONG\n__attribute__((noinline, noclone)) int\nbar (long long x)\n{\n  long long v = x & (((long long) -1 << 31) | 0x7ff);\n \n  return v == 0 || v == ((long long) -1 << 31);\n}\n#endif\n\nint\nmain ()\n{\n#ifdef USE_INT128\n  if (foo (0) != 1\n      || foo (1) != 0\n      || foo (0x800) != 1\n      || foo (0x801) != 0\n      || foo ((__int128) 1 << 63) != 0\n      || foo ((__int128) -1 << 63) != 1\n      || foo (((__int128) -1 << 63) | 1) != 0\n      || foo (((__int128) -1 << 63) | 0x800) != 1\n      || foo (((__int128) -1 << 63) | 0x801) != 0)\n    __builtin_abort ();\n#endif\n#ifdef USE_LLONG\n  if (bar (0) != 1\n      || bar (1) != 0\n      || bar (0x800) != 1\n      || bar (0x801) != 0\n      || bar (1LL << 31) != 0\n      || bar (-1LL << 31) != 1\n      || bar ((-1LL << 31) | 1) != 0\n      || bar ((-1LL << 31) | 0x800) != 1\n      || bar ((-1LL << 31) | 0x801) != 0)\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr63641.c",
    "content": "/* PR tree-optimization/63641 */\n\n__attribute__ ((noinline, noclone)) int\nfoo (unsigned char b)\n{\n  if (0x0 <= b && b <= 0x8)\n    goto lab;\n  if (b == 0x0b)\n    goto lab;\n  if (0x0e <= b && b <= 0x1a)\n    goto lab;\n  if (0x1c <= b && b <= 0x1f)\n    goto lab;\n  return 0;\nlab:\n  return 1;\n}\n\n__attribute__ ((noinline, noclone)) int\nbar (unsigned char b)\n{\n  if (0x0 <= b && b <= 0x8)\n    goto lab;\n  if (b == 0x0b)\n    goto lab;\n  if (0x0e <= b && b <= 0x1a)\n    goto lab;\n  if (0x3c <= b && b <= 0x3f)\n    goto lab;\n  return 0;\nlab:\n  return 1;\n}\n\nchar tab1[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,\n\t\t1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1 };\nchar tab2[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1,\n\t\t1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,\n\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n\t\t0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 };\n\nint\nmain ()\n{\n  int i;\n  asm volatile (\"\" : : : \"memory\");\n  for (i = 0; i < 256; i++)\n    if (foo (i) != (i < 32 ? tab1[i] : 0))\n      __builtin_abort ();\n  for (i = 0; i < 256; i++)\n    if (bar (i) != (i < 64 ? tab2[i] : 0))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr63659.c",
    "content": "/* PR rtl-optimization/63659 */\n\nint a, b, c, *d = &b, g, h, i;\nunsigned char e;\nchar f;\n\nint\nmain ()\n{\n  while (a)\n    {\n      for (a = 0; a; a++)\n\tfor (; c; c++)\n\t  ;\n      if (i)\n\tbreak;\n    }\n\n  char j = c, k = -1, l;\n  l = g = j >> h;\n  f = l == 0 ? k : k % l;\n  e = 0 ? 0 : f;\n  *d = e;\n\n  if (b != 255)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr63843.c",
    "content": "/* PR rtl-optimization/63843 */\n\nstatic inline __attribute__ ((always_inline))\nunsigned short foo (unsigned short v)\n{\n  return (v << 8) | (v >> 8);\n}\n\nunsigned short __attribute__ ((noinline, noclone, hot))\nbar (unsigned char *x)\n{\n  unsigned int a;\n  unsigned short b;\n  __builtin_memcpy (&a, &x[0], sizeof (a));\n  a ^= 0x80808080U;\n  __builtin_memcpy (&x[0], &a, sizeof (a));\n  __builtin_memcpy (&b, &x[2], sizeof (b));\n  return foo (b);\n}\n\nint\nmain ()\n{\n  unsigned char x[8] = { 0x01, 0x01, 0x01, 0x01 };\n  if (__CHAR_BIT__ == 8\n      && sizeof (short) == 2\n      && sizeof (int) == 4\n      && bar (x) != 0x8181U)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64006.c",
    "content": "/* PR tree-optimization/64006 */\n\nint v;\n\nlong __attribute__ ((noinline, noclone))\ntest (long *x, int y)\n{\n  int i;\n  long s = 1;\n  for (i = 0; i < y; i++)\n    if (__builtin_mul_overflow (s, x[i], &s))\n      v++;\n  return s;\n}\n\nint\nmain ()\n{\n  long d[7] = { 975, 975, 975, 975, 975, 975, 975 };\n  long r = test (d, 7);\n  if (sizeof (long) * __CHAR_BIT__ == 64 && v != 1)\n    __builtin_abort ();\n  else if (sizeof (long) * __CHAR_BIT__ == 32 && v != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64255.c",
    "content": "/* PR rtl-optimization/64255 */\n\n__attribute__((noinline, noclone)) void\nbar (long i, unsigned long j)\n{\n  if (i != 1 || j != 1)\n    __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) void\nfoo (long i)\n{\n  unsigned long j;\n\n  if (!i)\n    return;\n  j = i >= 0 ? (unsigned long) i : - (unsigned long) i;\n  if ((i >= 0 ? (unsigned long) i : - (unsigned long) i) != j)\n    __builtin_abort ();\n  bar (i, j);\n}\n\nint\nmain ()\n{\n  foo (1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64260.c",
    "content": "/* PR rtl-optimization/64260 */\n\nint a = 1, b;\n\nvoid\nfoo (char p)\n{\n  int t = 0;\n  for (; b < 1; b++)\n    {\n      int *s = &a;\n      if (--t)\n\t*s &= p;\n      *s &= 1;\n    }\n}\n\nint\nmain ()\n{\n  foo (0);\n  if (a != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64682.c",
    "content": "/* PR rtl-optimization/64682 */\n\nint a, b = 1;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != 5)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 56; i++)\n    for (; a; a--)\n      ;\n  int *c = &b;\n  if (*c)\n    *c = 1 % (unsigned int) *c | 5;\n\n  foo (b);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64718.c",
    "content": "static int __attribute__ ((noinline, noclone))\nswap (int x)\n{\n  return (unsigned short) ((unsigned short) x << 8 | (unsigned short) x >> 8);\n}\n\nstatic int a = 0x1234;\n\nint\nmain (void)\n{\n  int b = 0x1234;\n  if (swap (a) != 0x3412)\n    __builtin_abort ();\n  if (swap (b) != 0x3412)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64756.c",
    "content": "/* PR rtl-optimization/64756 */\n\nint a, *tmp, **c = &tmp;\nvolatile int d;\nstatic int *volatile *e = &tmp;\nunsigned int f;\n\nstatic void\nfn1 (int *p)\n{\n  int g;\n  for (; f < 1; f++)\n    for (g = 1; g >= 0; g--)\n      {\n\td || d;\n\t*c = p;\n\n\tif (tmp != &a)\n\t  __builtin_abort ();\n\n\t*e = 0;\n      }\n}\n\nint\nmain ()\n{\n  fn1 (&a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64957.c",
    "content": "/* PR rtl-optimization/64957 */\n\n__attribute__((noinline, noclone)) int\nfoo (int b)\n{\n  return (((b ^ 5) | 1) ^ 5) | 1;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int b)\n{\n  return (((b ^ ~5) & ~1) ^ ~5) & ~1;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 16; i++)\n    if (foo (i) != (i | 1) || bar (i) != (i & ~1))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr64979.c",
    "content": "/* PR target/64979 */\n\n#include <stdarg.h>\n\nvoid __attribute__((noinline, noclone))\nbar (int x, va_list *ap)\n{\n  if (ap)\n    {\n      int i;\n      for (i = 0; i < 10; i++)\n\tif (i != va_arg (*ap, int))\n\t  __builtin_abort ();\n      if (va_arg (*ap, double) != 0.5)\n\t__builtin_abort ();\n    }\n}\n\nvoid __attribute__((noinline, noclone))\nfoo (int x, ...)\n{\n  va_list ap;\n  int n;\n\n  va_start (ap, x);\n  n = va_arg (ap, int);\n  bar (x, (va_list *) ((n == 0) ? ((void *) 0) : &ap));\n  va_end (ap);\n}\n\nint\nmain ()\n{\n  foo (100, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0.5);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65053-1.c",
    "content": "/* PR tree-optimization/65053 */\n\nint i;\n\n__attribute__ ((noinline, noclone))\nunsigned int foo (void)\n{\n  return 0;\n}\n\nint\nmain ()\n{\n  unsigned int u = -1;\n  if (u == -1)\n    {\n      unsigned int n = foo ();\n      if (n > 0)\n\tu = n - 1;\n    }\n\n  while (u != -1)\n    {\n      asm (\"\" : \"+g\" (u));\n      u = -1;\n      i = 1;\n    }\n\n  if (i)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65053-2.c",
    "content": "/* PR tree-optimization/65053 */\n\nint i;\nunsigned int x;\n\nint\nmain ()\n{\n  asm volatile (\"\" : \"+g\" (x));\n  unsigned int n = x;\n  unsigned int u = 32;\n  if (n >= 32)\n    __builtin_abort ();\n  if (n != 0)\n    u = n + 32;\n\n  while (u != 32)\n    {\n      asm (\"\" : : \"g\" (u));\n      u = 32;\n      i = 1;\n    }\n\n  if (i)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65170.c",
    "content": "/* PR tree-optimization/65170 */\n\n#ifdef __SIZEOF_INT128__\ntypedef unsigned __int128 V;\ntypedef unsigned long long int H;\n#else\ntypedef unsigned long long int V;\ntypedef unsigned int H;\n#endif\n\n__attribute__((noinline, noclone)) void\nfoo (V b, V c)\n{\n  V a;\n  b &= (H) -1;\n  c &= (H) -1;\n  a = b * c;\n  if (a != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  foo (1, 1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65215-1.c",
    "content": "/* PR tree-optimization/65215 */\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (unsigned long long *x)\n{\n  return foo (*x);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  unsigned long long l = foo (0xdeadbeefU) | 0xfeedbea800000000ULL;\n  if (bar (&l) != 0xdeadbeefU)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65215-2.c",
    "content": "/* PR tree-optimization/65215 */\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned long long\nbar (unsigned long long *x)\n{\n  return ((unsigned long long) foo (*x) << 32) | foo (*x >> 32);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  unsigned long long l = foo (0xfeedbea8U) | ((unsigned long long) foo (0xdeadbeefU) << 32);\n  if (bar (&l) != 0xfeedbea8deadbeefULL)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65215-3.c",
    "content": "/* PR tree-optimization/65215 */\n\nstruct S { unsigned long long l1 : 24, l2 : 8, l3 : 32; };\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned long long\nbar (struct S *x)\n{\n  unsigned long long x1 = foo (((unsigned int) x->l1 << 8) | x->l2);\n  unsigned long long x2 = foo (x->l3);\n  return (x2 << 32) | x1;\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  struct S s = { 0xdeadbeU, 0xefU, 0xfeedbea8U };\n  unsigned long long l = bar (&s);\n  if (foo (l >> 32) != s.l3\n      || (foo (l) >> 8) != s.l1\n      || (foo (l) & 0xff) != s.l2)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65215-4.c",
    "content": "/* PR tree-optimization/65215 */\n\nstruct S { unsigned long long l1 : 48; };\n\nstatic inline unsigned int\nfoo (unsigned int x)\n{\n  return (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24);\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (struct S *x)\n{\n  return foo (x->l1);\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4 || sizeof (unsigned long long) != 8)\n    return 0;\n  struct S s;\n  s.l1 = foo (0xdeadbeefU) | (0xfeedULL << 32);\n  if (bar (&s) != 0xdeadbeefU)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65215-5.c",
    "content": "/* PR tree-optimization/65215 */\n\n__attribute__((noinline, noclone)) unsigned int\nfoo (unsigned char *p)\n{\n  return ((unsigned int) p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];\n}\n\n__attribute__((noinline, noclone)) unsigned int\nbar (unsigned char *p)\n{\n  return ((unsigned int) p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];\n}\n\nstruct S { unsigned int a; unsigned char b[5]; };\n\nint\nmain ()\n{\n  struct S s = { 1, { 2, 3, 4, 5, 6 } };\n  if (__CHAR_BIT__ != 8 || sizeof (unsigned int) != 4)\n    return 0;\n  if (foo (&s.b[1]) != 0x03040506U\n      || bar (&s.b[1]) != 0x06050403U)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65216.c",
    "content": "/* PR tree-optimization/65216 */\n\nint a, b = 62, e;\nvolatile int c, d;\n\nint\nmain ()\n{\n  int f = 0;\n  for (a = 0; a < 2; a++)\n    {\n      b &= (8 ^ f) & 1;\n      for (e = 0; e < 6; e++)\n\tif (c)\n\t  f = d;\n    }\n  if (b != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65369.c",
    "content": "/* PR tree-optimization/65369 */\n#include <stdint.h>\n\nstatic const char data[] =\n  \"12345678901234567890123456789012345678901234567890\"\n  \"123456789012345678901234567890\";\n\n__attribute__ ((noinline))\nstatic void foo (const unsigned int *buf)\n{\n  if (__builtin_memcmp (buf, data, 64))\n    __builtin_abort ();\n}\n\n__attribute__ ((noinline))\nstatic void bar (const unsigned char *block)\n{\n  uint32_t buf[16];\n  __builtin_memcpy (buf +  0, block +  0, 4);\n  __builtin_memcpy (buf +  1, block +  4, 4);\n  __builtin_memcpy (buf +  2, block +  8, 4);\n  __builtin_memcpy (buf +  3, block + 12, 4);\n  __builtin_memcpy (buf +  4, block + 16, 4);\n  __builtin_memcpy (buf +  5, block + 20, 4);\n  __builtin_memcpy (buf +  6, block + 24, 4);\n  __builtin_memcpy (buf +  7, block + 28, 4);\n  __builtin_memcpy (buf +  8, block + 32, 4);\n  __builtin_memcpy (buf +  9, block + 36, 4);\n  __builtin_memcpy (buf + 10, block + 40, 4);\n  __builtin_memcpy (buf + 11, block + 44, 4);\n  __builtin_memcpy (buf + 12, block + 48, 4);\n  __builtin_memcpy (buf + 13, block + 52, 4);\n  __builtin_memcpy (buf + 14, block + 56, 4);\n  __builtin_memcpy (buf + 15, block + 60, 4);\n  foo (buf);\n}\n\nint\nmain ()\n{\n  unsigned char input[sizeof data + 16] __attribute__((aligned (16)));\n  __builtin_memset (input, 0, sizeof input);\n  __builtin_memcpy (input + 1, data, sizeof data);\n  bar (input + 1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65401.c",
    "content": "/* PR rtl-optimization/65401 */\n\nstruct S { unsigned short s[64]; };\n\n__attribute__((noinline, noclone)) void\nfoo (struct S *x)\n{\n  unsigned int i;\n  unsigned char *s;\n\n  s = (unsigned char *) x->s;\n  for (i = 0; i < 64; i++)\n    x->s[i] = s[i * 2] | (s[i * 2 + 1] << 8);\n}  \n\n__attribute__((noinline, noclone)) void\nbar (struct S *x)\n{\n  unsigned int i;\n  unsigned char *s;\n\n  s = (unsigned char *) x->s;\n  for (i = 0; i < 64; i++)\n    x->s[i] = (s[i * 2] << 8) | s[i * 2 + 1];\n}  \n\nint\nmain ()\n{\n  unsigned int i;\n  struct S s;\n  if (sizeof (unsigned short) != 2)\n    return 0;\n  for (i = 0; i < 64; i++)\n    s.s[i] = i + ((64 - i) << 8);\n  foo (&s);\n#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != (64 - i) + (i << 8))\n      __builtin_abort ();\n#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != i + ((64 - i) << 8))\n      __builtin_abort ();\n#endif\n  for (i = 0; i < 64; i++)\n    s.s[i] = i + ((64 - i) << 8);\n  bar (&s);\n#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != (64 - i) + (i << 8))\n      __builtin_abort ();\n#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n  for (i = 0; i < 64; i++)\n    if (s.s[i] != i + ((64 - i) << 8))\n      __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65418-1.c",
    "content": "/* PR tree-optimization/65418 */\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  if (x == -216 || x == -132 || x == -218 || x == -146)\n     return 1;\n  return 0;\n}\n\nint\nmain ()\n{\n  volatile int i;\n  for (i = -230; i < -120; i++)\n    if (foo (i) != (i == -216 || i == -132 || i == -218 || i == -146))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65418-2.c",
    "content": "/* PR tree-optimization/65418 */\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  if (x == -216 || x == -211 || x == -218 || x == -205 || x == -223)\n     return 1;\n  return 0;\n}\n\nint\nmain ()\n{\n  volatile int i;\n  for (i = -230; i < -200; i++)\n    if (foo (i) != (i == -216 || i == -211 || i == -218 || i == -205 || i == -223))\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65427.c",
    "content": "/* PR tree-optimization/65427 */\n\ntypedef int V __attribute__ ((vector_size (8 * sizeof (int))));\nV a, b, c, d, e, f;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int y)\n{\n  do\n    {\n      if (x)\n\td = a ^ c;\n      else\n\td = a ^ b;\n    }\n  while (y);\n}\n\nint\nmain ()\n{\n  a = (V) { 1, 2, 3, 4, 5, 6, 7, 8 };\n  b = (V) { 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80 };\n  e = (V) { 0x41, 0x82, 0x43, 0x84, 0x45, 0x86, 0x47, 0x88 };\n  foo (0, 0);\n  if (__builtin_memcmp (&d, &e, sizeof (V)) != 0)\n    __builtin_abort ();\n  c = (V) { 0x80, 0x40, 0x80, 0x40, 0x80, 0x40, 0x80, 0x40 };\n  f = (V) { 0x81, 0x42, 0x83, 0x44, 0x85, 0x46, 0x87, 0x48 };\n  foo (1, 0);\n  if (__builtin_memcmp (&d, &f, sizeof (V)) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65648.c",
    "content": "/* PR target/65648 */\n\nint a = 0, *b = 0, c = 0;\nstatic int d = 0;\nshort e = 1;\nstatic long long f = 0;\nlong long *i = &f;\nunsigned char j = 0;\n\n__attribute__((noinline, noclone)) void\nfoo (int x, int *y)\n{\n  asm volatile (\"\" : : \"r\" (x), \"r\" (y) : \"memory\");\n}\n\n__attribute__((noinline, noclone)) void\nbar (const char *x, long long y)\n{\n  asm volatile (\"\" : : \"r\" (x), \"r\" (&y) : \"memory\");\n  if (y != 0)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  int k = 0;\n  b = &k;\n  j = (!a) - (c <= e);\n  *i = j;\n  foo (a, &k);\n  bar (\"\", f);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr65956.c",
    "content": "/* PR target/65956 */\n\nstruct A { char *a; int b; long long c; };\nchar v[3];\n\n__attribute__((noinline, noclone)) void\nfn1 (char *x, char *y)\n{\n  if (x != &v[1] || y != &v[2])\n    __builtin_abort ();\n  v[1]++;\n}\n\n__attribute__((noinline, noclone)) int\nfn2 (char *x)\n{\n  asm volatile (\"\" : \"+g\" (x) : : \"memory\");\n  return x == &v[0];\n}\n\n__attribute__((noinline, noclone)) void\nfn3 (const char *x)\n{\n  if (x[0] != 0)\n    __builtin_abort ();\n}\n\nstatic struct A\nfoo (const char *x, struct A y, struct A z)\n{\n  struct A r = { 0, 0, 0 };\n  if (y.b && z.b)\n    {\n      if (fn2 (y.a) && fn2 (z.a))\n\tswitch (x[0])\n\t  {\n\t  case '|':\n\t    break;\n\t  default:\n\t    fn3 (x);\n\t  }\n      fn1 (y.a, z.a);\n    }\n  return r;\n}\n\n__attribute__((noinline, noclone)) int\nbar (int x, struct A *y)\n{\n  switch (x)\n    {\n    case 219:\n      foo (\"+\", y[-2], y[0]);\n    case 220:\n      foo (\"-\", y[-2], y[0]);\n    }\n}\n\nint\nmain ()\n{\n  struct A a[3] = { { &v[1], 1, 1LL }, { &v[0], 0, 0LL }, { &v[2], 2, 2LL } };\n  bar (220, a + 2);\n  if (v[1] != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr66187.c",
    "content": "/* PR tree-optimization/66187 */\n\nint a = 1, e = -1;\nshort b, f;\n\nint\nmain ()\n{\n  f = e;\n  int g = b < 0 ? 0 : f + b;\n  if ((g & -4) < 0)\n    a = 0;\n  if (a)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr66233.c",
    "content": "/* PR tree-optimization/66233 */\n\nunsigned int v[8];\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  int i;\n  for (i = 0; i < 8; i++)\n    v[i] = (float) i;\n}\n\nint\nmain ()\n{\n  unsigned int i;\n  foo ();\n  for (i = 0; i < 8; i++)\n    if (v[i] != i)\n      __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr66556.c",
    "content": "/* { dg-do run } */\n/* { dg-require-effective-target int32plus } */\n\nextern void abort (void);\n\nstruct {\n  unsigned f2;\n  unsigned f3 : 15;\n  unsigned f5 : 3;\n  short f6;\n} b = {0x7f8000, 6, 5, 0}, g = {8, 0, 5, 0};\n\nshort d, l;\nint a, c, h = 8;\nvolatile char e[237] = {4};\nshort *f = &d;\nshort i[5] = {3};\nchar j;\nint *k = &c;\n\nint\nfn1 (unsigned p1) { return -p1; }\n\nvoid\nfn2 (char p1)\n{\n  a = p1;\n  e[0];\n}\n\nshort\nfn3 ()\n{\n  *k = 4;\n  return *f;\n}\n\nint\nmain ()\n{\n\n  unsigned m;\n  short *n = &i[4];\n\n  m = fn1 ((h && j) <= b.f5);\n  l = m > g.f3;\n  *n = 3;\n  fn2 (b.f2 >> 15);\n  if ((a & 0xff) != 0xff)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr66757.c",
    "content": "/* PR tree-optimization/66757 */\n/* Testcase by Zhendong Su <su@cs.ucdavis.edu> */\n\nint a, b;\n\nint\nmain (void)\n{\n  unsigned int t = (unsigned char) (~b); \n\n  if ((t ^ 1) / 255)\n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr66940.c",
    "content": "long long __attribute__ ((noinline, noclone))\nfoo (long long ival)\n{\n if (ival <= 0)\n    return -0x7fffffffffffffffL - 1;\n\n return 0x7fffffffffffffffL;\n}\n\nint\nmain (void)\n{\n  if (foo (-1) != (-0x7fffffffffffffffL - 1))\n    __builtin_abort ();\n\n  if (foo (1) != 0x7fffffffffffffffL)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr67037.c",
    "content": "long (*extfunc)();\n\nstatic inline void lstrcpynW( short *d, const short *s, int n )\n{\n    unsigned int count = n;\n\n    while ((count > 1) && *s)\n    {\n        count--;\n        *d++ = *s++;\n    }\n    if (count) *d = 0;\n}\n\nint __attribute__((noinline,noclone))\nbadfunc(int u0, int u1, int u2, int u3,\n  short *fsname, unsigned int fsname_len)\n{\n    static const short ntfsW[] = {'N','T','F','S',0};\n    char superblock[2048+3300];\n    int ret = 0;\n    short *p;\n\n    if (extfunc())\n        return 0;\n    p = (void *)extfunc();\n    if (p != 0)\n        goto done;\n\n    extfunc(superblock);\n\n    lstrcpynW(fsname, ntfsW, fsname_len);\n\n    ret = 1;\ndone:\n    return ret;\n}\n\nstatic long f()\n{\n    return 0;\n}\n\nint main()\n{\n    short buf[6];\n    extfunc = f;\n    return !badfunc(0, 0, 0, 0, buf, 6);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr67226.c",
    "content": "struct assembly_operand\n{\n  int type, value, symtype, symflags, marker;\n};\n\nstruct assembly_operand to_input, from_input;\n\nvoid __attribute__ ((__noinline__, __noclone__))\nassemblez_1 (int internal_number, struct assembly_operand o1)\n{\n  if (o1.type != from_input.type)\n    __builtin_abort ();\n}\n\nvoid __attribute__ ((__noinline__, __noclone__))\nt0 (struct assembly_operand to, struct assembly_operand from)\n{\n  if (to.value == 0)\n    assemblez_1 (32, from);\n  else\n    __builtin_abort ();\n}\n\nint\nmain (void)\n{\n  to_input.value = 0;\n  to_input.type = 1;\n  to_input.symtype = 2;\n  to_input.symflags = 3;\n  to_input.marker = 4;\n\n  from_input.value = 5;\n  from_input.type = 6;\n  from_input.symtype = 7;\n  from_input.symflags = 8;\n  from_input.marker = 9;\n\n  t0 (to_input, from_input);\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr67714.c",
    "content": "unsigned int b;\nint c;\n\nsigned char\nfn1 ()\n{\n  signed char d;\n  for (int i = 0; i < 1; i++)\n    d = -15;\n  return d;\n}\n\nint\nmain (void)\n{\n  for (c = 0; c < 1; c++)\n    b = 0;\n  char e = fn1 ();\n  signed char f = e ^ b;\n  volatile int g = (int) f;\n\n  if (g != -15)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr67781.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#ifdef __UINT32_TYPE__\ntypedef __UINT32_TYPE__ uint32_t;\n#else\ntypedef unsigned uint32_t;\n#endif\n\n#ifdef __UINT8_TYPE__\ntypedef __UINT8_TYPE__ uint8_t;\n#else\ntypedef unsigned char uint8_t;\n#endif\n\nstruct\n{\n  uint32_t a;\n  uint8_t b;\n} s = { 0x123456, 0x78 };\n\nint pr67781()\n{\n  uint32_t c = (s.a << 8) | s.b;\n  return c;\n}\n\nint\nmain ()\n{\n  if (sizeof (uint32_t) * __CHAR_BIT__ != 32)\n    return 0;\n\n  if (pr67781 () != 0x12345678)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr67929_1.c",
    "content": "int __attribute__ ((noinline, noclone))\nfoo (float a)\n{\n  return a * 4.9f;\n}\n\n\nint\nmain (void)\n{\n  if (foo (10.0f) != 49)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68143_1.c",
    "content": "#define NULL 0\n\nstruct stuff\n{\n    int a;\n    int b;\n    int c;\n    int d;\n    int e;\n    char *f;\n    int g;\n};\n\nvoid __attribute__ ((noinline))\nbar (struct stuff *x)\n{\n  if (x->g != 2)\n    __builtin_abort ();\n}\n\nint\nmain (int argc, char** argv)\n{\n  struct stuff x = {0, 0, 0, 0, 0, NULL, 0};\n  x.a = 100;\n  x.d = 100;\n  x.g = 2;\n  /* Struct should now look like {100, 0, 0, 100, 0, 0, 0, 2}.  */\n  bar (&x);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68185.c",
    "content": "/* { dg-skip-if \"ptxas crashes or executes incorrectly\" { nvptx-*-* } { \"-O0\" \"-Os\" } { \"\" } } Reported 2015-11-20  */\n\nint a, b, d = 1, e, f, o, u, w = 1, z;\nshort c, q, t;\n\nint\nmain ()\n{\n  char g;\n  for (; d; d--)\n    {\n      while (o)\n\tfor (; e;)\n\t  {\n\t    c = b;\n\t    int h = o = z;\n\t    for (; u;)\n\t      for (; a;)\n\t\t;\n\t  }\n      if (t < 1)\n\tg = w;\n      f = g;\n      g && (q = 1);\n    }\n\n  if (q != 1)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68249.c",
    "content": "/* PR rtl-optimization/68249 */\n\nint a, b, c, g, k, l, m, n;\nchar h;\n\nvoid\nfn1 ()\n{\n  for (; k; k++)\n    {\n      m = b || c < 0 || c > 1 ? : c;\n      g = l = n || m < 0 || (m > 1) > 1 >> m ? : 1 << m;\n    }\n  l = b + 1;\n  for (; b < 1; b++)\n    h = a + 1;\n}\n\nint\nmain ()\n{\n  char j; \n  for (; a < 1; a++)\n    {\n      fn1 ();\n      if (h)\n\tj = h;\n      if (j > c)\n\tg = 0;\n    }\n\n  if (h != 1) \n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68250.c",
    "content": "/* PR rtl-optimization/68250 */\n\nsigned char a, b, h, k, l, m, o;\nshort c, d, n;\nint e, f, g, j, q;\n\nvoid\nfn1 (void)\n{\n  int p = b || a;\n  n = o > 0 || d > 1 >> o ? d : d << o;\n  for (; j; j++)\n    m = c < 0 || m || c << p;\n  l = f + 1;\n  for (; f < 1; f = 1)\n    k = h + 1;\n}\n\n__attribute__((noinline, noclone)) void\nfn2 (int k)\n{\n  if (k != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  signed char i;\n  for (; e < 1; e++)\n    {\n      fn1 ();\n      if (k)\n\ti = k;\n      if (i > q)\n\tg = 0;\n    }\n  fn2 (k);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68321.c",
    "content": "/* PR rtl-optimization/68321 */\n\nint e = 1, u = 5, t2, t5, i, k;\nint a[1], b, m;\nchar n, t;\n\nint\nfn1 (int p1)\n{\n  int g[1];\n  for (;;)\n    {\n      if (p1 / 3)\n\tfor (; t5;)\n\t  u || n;\n      t2 = p1 & 4;\n      if (b + 1)\n\treturn 0;\n      u = g[0];\n    }\n}\n\nint\nmain ()\n{\n  for (; e >= 0; e--)\n    {\n      char c;\n      if (!m)\n\tc = t;\n      fn1 (c);\n    }\n  \n  if (a[t2] != 0) \n    __builtin_abort (); \n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c",
    "content": "int a, b, c = 1, d = 1, e;\n\n__attribute__ ((noinline, noclone))\n     int foo (void)\n{\n  asm volatile (\"\":::\"memory\");\n  return 4195552;\n}\n\n__attribute__ ((noinline, noclone))\n     void bar (int x, int y)\n{\n  asm volatile (\"\"::\"g\" (x), \"g\" (y):\"memory\");\n  if (y == 0)\n    __builtin_abort ();\n}\n\nint\nbaz (int x)\n{\n  char g, h;\n  int i, j;\n\n  foo ();\n  for (;;)\n    {\n      if (c)\n\th = d;\n      g = h < x ? h : 0;\n      i = (signed char) ((unsigned char) (g - 120) ^ 1);\n      j = i > 97;\n      if (a - j)\n\tbar (0x123456, 0);\n      if (!b)\n\treturn e;\n    }\n}\n\nint\nmain ()\n{\n  baz (2);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68376-1.c",
    "content": "/* PR rtl-optimization/68376 */\n\nint a, b, c = 1;\nsigned char d;\n\nint\nmain ()\n{\n  for (; a < 1; a++)\n    for (; b < 1; b++)\n      {\n\tsigned char e = ~d;\n\tif (d < 1)\n\t  e = d;\n\td = e;\n\tif (!c)\n\t  __builtin_abort ();\n      }\n\n  if (d != 0)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68376-2.c",
    "content": "/* PR rtl-optimization/68376 */\n\nextern void abort (void);\n\n__attribute__((noinline, noclone)) int\nf1 (int x)\n{\n  return x < 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf2 (int x)\n{\n  return x < 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf3 (int x)\n{\n  return x <= 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf4 (int x)\n{\n  return x <= 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf5 (int x)\n{\n  return x >= 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf6 (int x)\n{\n  return x >= 0 ? x : ~x;\n}\n\n__attribute__((noinline, noclone)) int\nf7 (int x)\n{\n  return x > 0 ? ~x : x;\n}\n\n__attribute__((noinline, noclone)) int\nf8 (int x)\n{\n  return x > 0 ? x : ~x;\n}\n\nint\nmain ()\n{\n  if (f1 (5) != 5 || f1 (-5) != 4 || f1 (0) != 0)\n    abort ();\n  if (f2 (5) != -6 || f2 (-5) != -5 || f2 (0) != -1)\n    abort ();\n  if (f3 (5) != 5 || f3 (-5) != 4 || f3 (0) != -1)\n    abort ();\n  if (f4 (5) != -6 || f4 (-5) != -5 || f4 (0) != 0)\n    abort ();\n  if (f5 (5) != -6 || f5 (-5) != -5 || f5 (0) != -1)\n    abort ();\n  if (f6 (5) != 5 || f6 (-5) != 4 || f6 (0) != 0)\n    abort ();\n  if (f7 (5) != -6 || f7 (-5) != -5 || f7 (0) != 0)\n    abort ();\n  if (f8 (5) != 5 || f8 (-5) != 4 || f8 (0) != -1)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68381.c",
    "content": "/* { dg-options \"-O -fexpensive-optimizations -fno-tree-bit-ccp\" } */\n\n__attribute__ ((noinline, noclone))\nint\nfoo (unsigned short x, unsigned short y)\n{\n  int r;\n  if (__builtin_mul_overflow (x, y, &r))\n    __builtin_abort ();\n  return r;\n}\n\nint\nmain (void)\n{\n  int x = 1;\n  int y = 2;\n  if (foo (x, y) != x * y)\n    __builtin_abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68390.c",
    "content": "/* { dg-do run }  */\n/* { dg-options \"-O2\" } */\n\n__attribute__ ((noinline))\ndouble direct(int x, ...)\n{\n  return x*x;\n}\n\n__attribute__ ((noinline))\ndouble broken(double (*indirect)(int x, ...), int v)\n{\n  return indirect(v);\n}\n\nint main ()\n{\n  double d1, d2;\n  int i = 2;\n  d1 = broken (direct, i);\n  if (d1 != i*i)\n    {\n      __builtin_abort ();\n    }\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68506.c",
    "content": "/* { dg-options \"-fno-builtin-abort\" } */\n\nint a, b, m, n, o, p, s, u, i;\nchar c, q, y;\nshort d;\nunsigned char e;\nstatic int f, h;\nstatic short g, r, v;\nunsigned t;\n\nextern void abort ();\n\nint\nfn1 (int p1)\n{\n  return a ? p1 : p1 + a;\n}\n\nunsigned char\nfn2 (unsigned char p1, int p2)\n{\n  return p2 >= 2 ? p1 : p1 >> p2;\n}\n\nstatic short\nfn3 ()\n{\n  int w, x = 0;\n  for (; p < 31; p++)\n    {\n      s = fn1 (c | ((1 && c) == c));\n      t = fn2 (s, x);\n      c = (unsigned) c > -(unsigned) ((o = (m = d = t) == p) <= 4UL) && n;\n      v = -c;\n      y = 1;\n      for (; y; y++)\n\te = v == 1;\n      d = 0;\n      for (; h != 2;)\n\t{\n\t  for (;;)\n\t    {\n\t      if (!m)\n\t\tabort ();\n\t      r = 7 - f;\n\t      x = e = i | r;\n\t      q = u * g;\n\t      w = b == q;\n\t      if (w)\n\t\tbreak;\n\t    }\n\t  break;\n\t}\n    }\n  return x;\n}\n\nint\nmain ()\n{\n  fn3 ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68532.c",
    "content": "/* { dg-options \"-O2 -ftree-vectorize -fno-vect-cost-model\" } */\n/* { dg-additional-options \"-fno-common\" { target hppa*-*-hpux* } } */\n\n#define SIZE 128\nunsigned short _Alignas (16) in[SIZE];\n\n__attribute__ ((noinline)) int\ntest (unsigned short sum, unsigned short *in, int x)\n{\n  for (int j = 0; j < SIZE; j += 8)\n    sum += in[j] * x;\n  return sum;\n}\n\nint\nmain ()\n{\n  for (int i = 0; i < SIZE; i++)\n    in[i] = i;\n  if (test (0, in, 1) != 960)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68624.c",
    "content": "int b, c, d, e = 1, f, g, h, j;\n\nstatic int\nfn1 ()\n{\n  int a = c;\n  if (h)\n    return 9;\n  g = (c || b) % e;\n  if ((g || f) && b)\n    return 9;\n  e = d;\n  for (c = 0; c > -4; c--)\n    ;\n  if (d)\n    c--;\n  j = c;\n  return d;\n}\n\nint\nmain ()\n{\n  fn1 ();\n\n  if (c != -4)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68648.c",
    "content": "/* { dg-require-effective-target int32plus } */\nint __attribute__ ((noinline))\nfoo (void)\n{\n  return 123;\n}\n\nint __attribute__ ((noinline))\nbar (void)\n{\n  int c = 1;\n  c |= 4294967295 ^ (foo () | 4073709551608);\n  return c;\n}\n\nint\nmain ()\n{\n  if (bar () != 0x83fd4005)\n    __builtin_abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68841.c",
    "content": "static inline int\nfoo (int *x, int y)\n{\n  int z = *x;\n  while (y > z)\n    z *= 2;\n  return z;\n}\n\nint\nmain ()\n{\n  int i;\n  for (i = 1; i < 17; i++)\n    {\n      int j;\n      int k;\n      j = foo (&i, 7);\n      if (i >= 7)\n\tk = i;\n      else if (i >= 4)\n\tk = 8 + (i - 4) * 2;\n      else if (i == 3)\n\tk = 12;\n      else\n\tk = 8;\n      if (j != k)\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr68911.c",
    "content": "extern void abort (void);\n\nchar a;\nint b, c;\nshort d;\n\nint main ()\n{\n  unsigned e = 2;\n  unsigned timeout = 0;\n\n  for (; c < 2; c++)\n    {\n      int f = ~e / 7;\n      if (f)\n\ta = e = ~(b && d);\n      while (e < 94)\n\t{\n\t  e++;\n\t  if (++timeout > 100)\n\t    goto die;\n\t}\n    }\n  return 0;\ndie:\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69097-1.c",
    "content": "/* PR tree-optimization/69097 */\n\nint a, b;\nunsigned int c;\n\nint\nmain ()\n{\n  int d = b;\n  b = ~(~a + (~d | b));\n  a = ~(~c >> b);\n  c = a % b;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69097-2.c",
    "content": "/* PR tree-optimization/69097 */\n\n__attribute__((noinline, noclone)) int\nf1 (int x, int y)\n{\n  return x % y;\n}\n\n__attribute__((noinline, noclone)) int\nf2 (int x, int y)\n{\n  return x % -y;\n}\n\n__attribute__((noinline, noclone)) int\nf3 (int x, int y)\n{\n  int z = -y;\n  return x % z;\n}\n\nint\nmain ()\n{\n  if (f1 (-__INT_MAX__ - 1, 1) != 0\n      || f2 (-__INT_MAX__ - 1, -1) != 0\n      || f3 (-__INT_MAX__ - 1, -1) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69320-1.c",
    "content": "#include <stdlib.h>\nint a, b, d, f;\nchar c;\nstatic int *e = &d;\nint main() {\n  int g = -1L;\n  *e = g;\n  c = 4;\n  for (; c >= 14; c++)\n    *e = 1;\n  f = a == 0;\n  *e ^= f;\n  int h = ~d;\n  if (d)\n    b = h;\n  if (h)\n    exit (0);\n  abort ();\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69320-2.c",
    "content": "\n#include <stdlib.h>\n\nint a, *c, d, e, g, f;\nshort b;\n\nint \nfn1 ()\n{\n  int h = d != 10;\n  if (h > g)\n     asm volatile (\"\" : : : \"memory\");\n  if (h == 10)\n    {\n      int *i = 0;\n      a = 0;\n      for (; a < 7; a++)\n\tfor (; *i;)\n\t  ;\n    }\n  else\n    {\n      b = e / h;\n      return f;\n    }\n  c = &h;\n  abort ();\n}\n\nint\nmain ()\n{\n  fn1 ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69320-3.c",
    "content": "#include <stdlib.h>\n\nstatic int a[40] = {7, 5, 3, 3, 0, 0, 3};\nshort b;\nint c = 5;\nint main() {\n  b = 0;\n  for (; b <= 3; b++)\n    if (a[b + 6] ^ (0 || c))\n      ;\n    else\n      break;\n  if (b != 4)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69320-4.c",
    "content": "#include <stdlib.h>\n\nint a;\nchar b, d;\nshort c;\nshort fn1(int p1, int p2) { return p2 >= 2 ? p1 : p1 > p2; }\n\nint main() {\n  int *e = &a, *f = &a;\n  b = 1;\n  for (; b <= 9; b++) {\n    c = *e != 5 || d;\n    *f = fn1(c || b, a);\n  }\n  if ((long long) a != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69403.c",
    "content": "/* PR target/69403.  */\n\nint a, b, c;\n\n__attribute__ ((__noinline__)) int\nfn1 ()\n{\n  if ((b | (a != (a & c))) == 1)\n    __builtin_abort ();\n  return 0;\n}\n\nint\nmain (void)\n{\n  a = 5;\n  c = 1;\n  b = 6;\n  return fn1 ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69447.c",
    "content": "typedef unsigned char u8;\ntypedef unsigned short u16;\ntypedef unsigned int u32;\ntypedef unsigned long long u64;\n\nu64 __attribute__((noinline, noclone))\nfoo(u8 u8_0, u16 u16_0, u64 u64_0, u8 u8_1, u16 u16_1, u64 u64_1, u64 u64_2, u8 u8_3, u64 u64_3)\n{\n\tu64_1 *= 0x7730;\n\tu64_3 *= u64_3;\n\tu16_1 |= u64_3;\n\tu64_3 -= 2;\n\tu8_3 /= u64_2;\n\tu8_0 |= 3;\n\tu64_3 %= u8_0;\n\tu8_0 -= 1;\n\treturn u8_0 + u16_0 + u64_0 + u8_1 + u16_1 + u64_1 + u8_3 + u64_3;\n}\n\nint main()\n{\n\tunsigned x = foo(1, 1, 1, 1, 1, 1, 1, 1, 1);\n\tif (x != 0x7737)\n\t\t__builtin_abort();\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr69691.c",
    "content": "/* PR rtl-optimization/69691 */\n\nchar u[] = { 46, 97, 99, 104, 52, 0 };\nchar *v[] = { u, 0 };\nstruct S { char a[10]; struct S *b[31]; };\nstruct S r[7], *r2 = r;\nstatic struct S *w = 0;\n\n__attribute__((noinline, noclone)) int\nfn (int x)\n{\n  if (__builtin_strchr (u, x) || x == 96)\n    return x;\n  __builtin_abort ();\n}\n\n__attribute__((noinline, noclone)) int\nfoo (char x)\n{\n  if (x == 0)\n    __builtin_abort ();\n  if (fn (x) >= 96 && fn (x) <= 122)\n    return (fn (x) - 96);\n  else if (x == 46)\n    return 0;\n  else\n    {\n      __builtin_printf (\"foo %d\\n\", x);\n      return -1;\n    }\n}\n\n__attribute__((noinline, noclone)) void\nbar (char **x)\n{\n  char **b, c, *d, e[500], *f, g[10];\n  int z, l, h, i;\n  struct S *s;\n\n  w = r2++;\n  for (b = x; *b; b++)\n    {\n      __builtin_strcpy (e, *b);\n      f = e;\n      do\n\t{\n\t  d = __builtin_strchr (f, 32);\n\t  if (d)\n\t    *d = 0;\n\t  l = __builtin_strlen (f);\n\t  h = 0;\n\t  s = w;\n\t  __builtin_memset (g, 0, sizeof (g));\n\t  for (z = 0; z < l; z++)\n\t    {\n\t      c = f[z];\n\t      if (c >= 48 && c <= 57)\n\t\tg[h] = c - 48;\n\t      else\n\t\t{\n\t\t  i = foo (c);\n\t\t  if (!s->b[i])\n\t\t    {\n\t\t      s->b[i] = r2++;\n\t\t      if (r2 == &r[7])\n\t\t\t__builtin_abort ();\n\t\t    }\n\t\t  s = s->b[i];\n\t\t  h++;\n\t\t}\n\t    }\n\t  __builtin_memcpy (s->a, g, 10);\n\t  if (d)\n\t    f = d + 1;\n\t}\n      while (d);\n    }\n}\n\n__attribute__((noinline, noclone)) void\nbaz (char *x)\n{\n  char a[300], b[300];\n  int z, y, t, l;\n  struct S *s;\n\n  l = __builtin_strlen (x);\n  *a = 96;\n  for (z = 0; z < l; z++)\n    {\n      a[z + 1] = fn ((unsigned int) x[z]);\n      if (foo (a[z + 1]) <= 0)\n\treturn;\n    }\n  a[l + 1] = 96;\n  l += 2;\n  __builtin_memset (b, 0, l + 2);\n\n  if (!w)\n    return;\n\n  for (z = 0; z < l; z++)\n    {\n      s = w;\n      for (y = z; y < l; y++)\n\t{\n\t  s = s->b[foo (a[y])];\n\t  if (!s)\n\t    break;\n\t  for (t = 0; t <= y - z + 2; t++)\n\t    if (s->a[t] > b[z + t])\n\t      b[z + t] = s->a[t];\n\t}\n    }\n  for (z = 3; z < l - 2; z++)\n    if ((b[z] & 1) == 1)\n     asm (\"\");\n}\n\nint\nmain ()\n{\n  bar (v);\n  char c[] = { 97, 97, 97, 97, 97, 0 };\n  baz (c);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70005.c",
    "content": "\nunsigned char a = 6;\nint b, c;\n\nstatic void\nfn1 ()\n{\n  int i = a > 1 ? 1 : a, j = 6 & (c = a && (b = a));\n  int d = 0, e = a, f = ~c, g = b || a;\n  unsigned char h = ~a;\n  if (a)\n    f = j;\n  if (h && g)\n    d = a;\n  i = -~(f * d * h) + c && (e || i) ^ f;\n  if (i != 1) \n    __builtin_abort (); \n}\n\nint\nmain ()\n{\n  fn1 ();\n  return 0; \n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70127.c",
    "content": "/* PR tree-optimization/70127 */\n\nstruct S { int f; signed int g : 2; } a[1], c = {5, 1}, d;\nshort b;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  if (x != 1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  while (b++ <= 0)\n    {\n      struct S e = {1, 1};\n      d = e = a[0] = c;\n    }\n  foo (a[0].g);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70222-1.c",
    "content": "/* PR rtl-optimization/70222 */\n\nint a = 1;\nunsigned int b = 2;\nint c = 0;\nint d = 0;\n\nvoid\nfoo ()\n{\n  int e = ((-(c >= c)) < b) > ((int) (-1ULL >> ((a / a) * 15)));\n  d = -e;\n}\n\n__attribute__((noinline, noclone)) void\nbar (int x)\n{\n  if (x != -1)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  foo ();\n  bar (d);\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70222-2.c",
    "content": "/* PR rtl-optimization/70222 */\n\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n__attribute__((noinline, noclone)) unsigned int\nfoo (int x)\n{\n  unsigned long long y = -1ULL >> x;\n  return (unsigned int) y >> 31;\n}\n#endif\n\nint\nmain ()\n{\n#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8\n  if (foo (15) != 1 || foo (32) != 1 || foo (33) != 0)\n    __builtin_abort ();\n#endif\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70429.c",
    "content": "/* PR rtl-optimization/70429 */\n\n__attribute__((noinline, noclone)) int\nfoo (int a)\n{\n  return (int) (0x14ff6e2207db5d1fLL >> a) >> 4;\n}\n\nint\nmain ()\n{\n  if (sizeof (int) != 4 || sizeof (long long) != 8 || __CHAR_BIT__ != 8)\n    return 0;\n  if (foo (1) != 0x3edae8 || foo (2) != -132158092)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70460.c",
    "content": "/* { dg-require-effective-target indirect_jumps } */\n/* { dg-require-effective-target label_values } */\n\n/* PR rtl-optimization/70460 */\n\nint c;\n\n__attribute__((noinline, noclone)) void\nfoo (int x)\n{\n  static int b[] = { &&lab1 - &&lab0, &&lab2 - &&lab0 };\n  void *a = &&lab0 + b[x];\n  goto *a;\nlab1:\n  c += 2;\nlab2:\n  c++;\nlab0:\n  ;\n}\n\nint\nmain ()\n{\n  foo (0);\n  if (c != 3)\n    __builtin_abort ();\n  foo (1);\n  if (c != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70566.c",
    "content": "/* PR target/70566.  */\n\n#define NULL 0\n\nstruct mystruct\n{\n  unsigned int f1 : 1;\n  unsigned int f2 : 1;\n  unsigned int f3 : 1;\n};\n\n__attribute__ ((noinline)) void\nmyfunc (int a, void *b)\n{\n}\n__attribute__ ((noinline)) int\nmyfunc2 (void *a)\n{\n  return 0;\n}\n\nstatic void\nset_f2 (struct mystruct *user, int f2)\n{\n  if (user->f2 != f2)\n    myfunc (myfunc2 (NULL), NULL);\n  else\n    __builtin_abort ();\n}\n\n__attribute__ ((noinline)) void\nfoo (void *data)\n{\n  struct mystruct *user = data;\n  if (!user->f2)\n    set_f2 (user, 1);\n}\n\nint\nmain (void)\n{\n  struct mystruct a;\n  a.f1 = 1;\n  a.f2 = 0;\n  foo (&a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70586.c",
    "content": "/* PR tree-optimization/70586 */\n\nint a, e, f;\nshort b, c, d;\n\nint\nfoo (int x, int y)\n{\n  return (y == 0 || (x && y == 1)) ? x : x % y;\n}\n\nstatic short\nbar (void)\n{\n  int i = foo (c, f);\n  f = foo (d, 2);\n  int g = foo (b, c);\n  int h = foo (g > 0, c);\n  c = (3 >= h ^ 7) <= foo (i, c);\n  if (foo (e, 1))\n    return a;\n  return 0;\n}\n\nint\nmain ()\n{\n  bar ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70602.c",
    "content": "/* PR tree-optimization/70602 */\n/* { dg-require-effective-target int32plus } */\n\nstruct __attribute__((packed)) S\n{\n  int s : 1;\n  int t : 20;\n};\n\nint a, b, c;\n\nint\nmain ()\n{\n  for (; a < 1; a++)\n    {\n      struct S e[] = { {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, \n\t\t       {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9}, {0, 9}, \n\t\t       {0, 9}, {0, 0}, {0, 9}, {0, 9}, {0, 9}, {0, 0}, {0, 9} };\n      b = b || e[0].s;\n      c = e[0].t;\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr70903.c",
    "content": "typedef unsigned char V8 __attribute__ ((vector_size (32)));\ntypedef unsigned int V32 __attribute__ ((vector_size (32)));\ntypedef unsigned long long V64 __attribute__ ((vector_size (32)));\n\nstatic V32 __attribute__ ((noinline, noclone))\nfoo (V64 x)\n{\n  V64 y = (V64)(V8){((V8)(V64){65535, x[0]})[1]};\n  return (V32){y[0], 255};\n}\n\nint main ()\n{\n  V32 x = foo ((V64){});\n//  __builtin_printf (\"%08x %08x %08x %08x %08x %08x %08x %08x\\n\", x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]);\n  if (x[1] != 255)\n    __builtin_abort();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71083.c",
    "content": "__extension__ typedef __UINT32_TYPE__ uint32_t;\n\nstruct lock_chain {\n  uint32_t irq_context: 2,\n    depth: 6,\n    base: 24;\n};\n\n__attribute__((noinline, noclone))\nstruct lock_chain * foo (struct lock_chain *chain)\n{\n  int i;\n  for (i = 0; i < 100; i++)\n    {\n      chain[i+1].base = chain[i].base;\n    }\n  return chain;\n}\n\nstruct lock_chain1 {\n  char x;\n  unsigned short base;\n} __attribute__((packed));\n\n__attribute__((noinline, noclone))\nstruct lock_chain1 * bar (struct lock_chain1 *chain)\n{\n  int i;\n  for (i = 0; i < 100; i++)\n    {\n      chain[i+1].base = chain[i].base;\n    }\n  return chain;\n}\n\nstruct lock_chain test [101];\nstruct lock_chain1 test1 [101];\n\nint\nmain ()\n{\n  foo (test);\n  bar (test1);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71335.c",
    "content": "int a;\nint\nmain ()\n{\n  int b = 0;\n  while (a < 0 || b)\n    {\n      b = 0;\n      for (; b < 9; b++)\n\t;\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71494.c",
    "content": "/* PR middle-end/71494 */\n/* { dg-require-effective-target label_values } */\n\nint\nmain ()\n{\n  void *label = &&out;\n  int i = 0;\n  void test (void)\n  {\n    label = &&out2;\n    goto *label;\n   out2:;\n    i++;\n  }\n  goto *label;\n out:\n  i += 2;\n  test ();\n  if (i != 3)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71550.c",
    "content": "\nextern void exit (int);\n\nint a = 3, b, c, f, g, h;\nunsigned d;\nchar *e;\n\nint\nmain ()\n{\n  for (; a; a--)\n    {\n      int i;\n      if (h && i)\n\t__builtin_printf (\"%d%d\", c, f);\n      i = 0;\n      for (; i < 2; i++)\n\tif (g)\n\t  for (; d < 10; d++)\n\t    b = *e;\n      i = 0;\n      for (; i < 1; i++)\n\t;\n    }\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71554.c",
    "content": "/* PR target/71554 */\n\nint v;\n\n__attribute__ ((noinline, noclone)) void\nbar (void)\n{\n  v++;\n}\n\n__attribute__ ((noinline, noclone))\nvoid\nfoo (unsigned int x)\n{\n  signed int y = ((-__INT_MAX__ - 1) / 2);\n  signed int r;\n  if (__builtin_mul_overflow (x, y, &r))\n    bar ();\n}\n\nint\nmain ()\n{\n  foo (2);\n  if (v)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71626-1.c",
    "content": "/* PR middle-end/71626 */\n\ntypedef __INTPTR_TYPE__ V __attribute__((__vector_size__(sizeof (__INTPTR_TYPE__))));\n\n__attribute__((noinline, noclone)) V\nfoo ()\n{\n  V v = { (__INTPTR_TYPE__) foo };\n  return v;\n}\n\nint\nmain ()\n{\n  V v = foo ();\n  if (v[0] != (__INTPTR_TYPE__) foo)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71626-2.c",
    "content": "/* PR middle-end/71626 */\n/* { dg-additional-options \"-fpic\" { target fpic } } */\n\n#include \"pr71626-1.c\"\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71631.c",
    "content": "/* PR tree-optimization/71631 */\n\nvolatile char v;\nint a = 1, b = 1, c = 1;\n\nvoid\nfoo (const char *s)\n{\n  while (*s++)\n    v = *s;\n}\n\nint\nmain ()\n{\n  volatile int d = 1;\n  volatile int e = 1;\n  int f = 1 / a;\n  int g = 1U < f;\n  int h = 2 + g;\n  int i = 3 % h;\n  int j = e && b;\n  int k = 1 == c;\n  int l = d != 0;\n  short m = (short) (-1 * i * l);\n  short x = j * (k * m);\n  if (i == 1)\n    foo (\"AB\");\n  if (x != -1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr71700.c",
    "content": "struct S\n{\n  signed f0 : 16;\n  unsigned f1 : 1;\n};\n\nint b;\nstatic struct S c[] = {{-1, 0}, {-1, 0}};\nstruct S d;\n\nint\nmain ()\n{\n  struct S e = c[0];\n  d = e;\n  if (d.f1 != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr7284-1.c",
    "content": "/* Signed left-shift is implementation-defined in C89 (and see\n   DR#081), not undefined.  Bug 7284 from Al Grant (AlGrant at\n   myrealbox.com).  */\n\n/* { dg-require-effective-target int32plus } */\n/* { dg-options \"-std=c89\" } */\n\nextern void abort (void);\nextern void exit (int);\n\nint\nf (int n)\n{\n  return (n << 24) / (1 << 23);\n}\n\nvolatile int x = 128;\n\nint\nmain (void)\n{\n  if (f(x) != -256)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr77718.c",
    "content": "/* PR middle-end/77718 */\n\nchar a[64] __attribute__((aligned (8)));\n\n__attribute__((noinline, noclone)) int\nfoo (void)\n{\n  return __builtin_memcmp (\"bbbbbb\", a, 6);\n}\n\n__attribute__((noinline, noclone)) int\nbar (void)\n{\n  return __builtin_memcmp (a, \"bbbbbb\", 6);\n}\n\nint\nmain ()\n{\n  __builtin_memset (a, 'a', sizeof (a));\n  if (((foo () < 0) ^ ('a' > 'b'))\n      || ((bar () < 0) ^ ('a' < 'b')))\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr77766.c",
    "content": "char a;\nshort b, d = 5, h;\nchar c[1];\nint e, f = 4, g, j;\nint main() {\n  int i;\n  for (; f; f = a) {\n    g = 0;\n    for (; g <= 32; ++g) {\n      i = 0;\n      for (; i < 3; i++)\n        while (1 > d)\n          if (c[b])\n            break;\n    L:\n      if (j)\n        break;\n    }\n  }\n  e = 0;\n  for (; e; e = 0) {\n    d++;\n    for (; h;)\n      goto L;\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr77767.c",
    "content": "/* PR c/77767 */\n\nvoid\nfoo (int a, int b[a++], int c, int d[c++])\n{\n  if (a != 2 || c != 2)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  int e[10];\n  foo (1, e, 1, e);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78170.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* PR tree-optimization/78170.\n   Check that sign-extended store to a bitfield\n   doesn't overwrite other fields.  */\n\nint a, b, d;\n\nstruct S0\n{\n  int f0;\n  int f1;\n  int f2;\n  int f3;\n  int f4;\n  int f5:15;\n  int f6:17;\n  int f7:2;\n  int f8:30;\n} c;\n\nvoid fn1 ()\n{\n  d = b = 1;\n  for (; b; b = a)\n    {\n      struct S0 e = { 0, 0, 0, 0, 0, 0, 1, 0, 1 };\n      c = e;\n      c.f6 = -1;\n    }\n}\n\nint main ()\n{\n  fn1 ();\n  if (c.f7 != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78378.c",
    "content": "/* PR rtl-optimization/78378 */\n\nunsigned long long __attribute__ ((noinline, noclone))\nfoo (unsigned long long x)\n{\n  x <<= 41;\n  x /= 232;\n  return 1 + (unsigned short) x;\n}\n\nint\nmain ()\n{\n  unsigned long long x = foo (1);\n  if (x != 0x2c24)\n    __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78436.c",
    "content": "/* PR tree-optimization/78436 */\n\nstruct S\n{\n  long int a : 24;\n  signed char b : 8;\n} s;\n\n__attribute__((noinline, noclone)) void\nfoo ()\n{\n  s.b = 0;\n  s.a = -1193165L;\n}\n\nint\nmain ()\n{\n  foo ();\n  if (s.b != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78438.c",
    "content": "/* PR target/78438 */\n\nchar a = 0;\nint b = 197412621;\n\n__attribute__ ((noinline, noclone))\nvoid foo ()\n{\n  a = 0 > (short) (b >> 11);\n}\n\nint\nmain ()\n{\n  asm volatile (\"\" : : : \"memory\");\n  if (__CHAR_BIT__ != 8 || sizeof (short) != 2 || sizeof (int) < 4)\n    return 0;\n  foo ();\n  if (a != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78477.c",
    "content": "/* PR rtl-optimization/78477 */\n\nunsigned a;\nunsigned short b;\n\nunsigned\nfoo (unsigned x)\n{\n  b = x;\n  a >>= (b & 1);\n  b = 1 | (b << 5);\n  b >>= 15;\n  x = (unsigned char) b > ((2 - (unsigned char) b) & 1);\n  b = 0;\n  return x;\n}\n\nint\nmain ()\n{\n  if (__CHAR_BIT__ != 8 || sizeof (short) != 2 || sizeof (int) < 4)\n    return 0;\n  unsigned x = foo (12345);\n  if (x != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78559.c",
    "content": "/* PR rtl-optimization/78559 */\n\nint g = 20;\nint d = 0;\n\nshort\nfn2 (int p1, int p2)\n{\n  return p2 >= 2 || 5 >> p2 ? p1 : p1 << p2;\n}\n\nint\nmain ()\n{\n  int result = 0;\nlbl_2582:\n  if (g)\n    {\n      for (int c = -3; c; c++)\n        result = fn2 (1, g);\n    }\n  else\n    {\n      for (int i = 0; i < 2; i += 2)\n        if (d)\n          goto lbl_2582;\n    }\n  if (result != 1)\n    __builtin_abort ();\n  return 0;\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78586.c",
    "content": "/* PR tree-optimization/78586 */\n\nvoid\nfoo (unsigned long x)\n{\n  char a[30];\n  unsigned long b = __builtin_sprintf (a, \"%lu\", x);\n  if (b != 4)\n    __builtin_abort ();\n}\n\nint\nmain ()\n{\n  foo (1000);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78617.c",
    "content": "int a = 0;\nint d = 1;\nint f = 1;\n\nint fn1() {\n  return a || 1 >> a;\n}\n\nint fn2(int p1, int p2) {\n  return p2 >= 2 ? p1 : p1 >> 1;\n}\n\nint fn3(int p1) {\n  return d ^ p1;\n}\n\nint fn4(int p1, int p2) {\n  return fn3(!d > fn2((f = fn1() - 1000) || p2, p1));\n}\n\nint main() {\n  if (fn4(0, 0) != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78622.c",
    "content": "/* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value\n   incorrect with overflow/wrapping\n   { dg-skip-if \"Requires %hhd format\" { hppa*-*-hpux* } { \"*\" } { \"\" } }\n   { dg-additional-options \"-Wformat-overflow=2\" } */\n\n__attribute__((noinline, noclone)) int\nfoo (int x)\n{\n  if (x < 4096 + 8 || x >= 4096 + 256 + 8)\n    return -1;\n\n  char buf[5];\n  int n = __builtin_snprintf (buf, sizeof buf, \"%hhd\", x + 1);\n  __builtin_printf (\"\\\"%hhd\\\" => %i\\n\", x + 1, n);\n  return n;\n}\n\nint\nmain (void)\n{\n  if (__SCHAR_MAX__ != 127 || __CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4)\n    return 0;\n\n  if (foo (4095 + 9) != 1\n      || foo (4095 + 32) != 2\n      || foo (4095 + 127) != 3\n      || foo (4095 + 128) != 4\n      || foo (4095 + 240) != 3\n      || foo (4095 + 248) != 2\n      || foo (4095 + 255) != 2\n      || foo (4095 + 256) != 1)\n    __builtin_abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78675.c",
    "content": "/* PR tree-optimization/78675 */\n\nlong int a;\n\n__attribute__((noinline, noclone)) long int\nfoo (long int x)\n{\n  long int b;\n  while (a < 1)\n    {\n      b = a && x;\n      ++a;\n    }\n  return b;\n}\n\nint\nmain ()\n{\n  if (foo (0) != 0)\n    __builtin_abort ();\n  a = 0;\n  if (foo (1) != 0)\n    __builtin_abort ();\n  a = 0;\n  if (foo (25) != 0)\n    __builtin_abort ();\n  a = -64;\n  if (foo (0) != 0)\n    __builtin_abort ();\n  a = -64;\n  if (foo (1) != 0)\n    __builtin_abort ();\n  a = -64;\n  if (foo (25) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78720.c",
    "content": "/* PR tree-optimization/78720 */\n\n__attribute__((noinline, noclone)) long int\nfoo (signed char x)\n{\n  return x < 0 ? 0x80000L : 0L;\n}\n\n__attribute__((noinline, noclone)) long int\nbar (signed char x)\n{\n  return x < 0 ? 0x80L : 0L;\n}\n\n__attribute__((noinline, noclone)) long int\nbaz (signed char x)\n{\n  return x < 0 ? 0x20L : 0L;\n}\n\nint\nmain ()\n{\n  if (foo (-1) != 0x80000L || bar (-1) != 0x80L || baz (-1) != 0x20L\n      || foo (0) != 0L || bar (0) != 0L || baz (0) != 0L\n      || foo (31) != 0L || bar (31) != 0L || baz (31) != 0L)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78726.c",
    "content": "/* PR tree-optimization/78726 */\n\nunsigned char b = 36, c = 173;\nunsigned int d;\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  unsigned a = ~b;\n  d = a * c * c + 1023094746U * a;\n}\n\nint\nmain ()\n{\n  if (__SIZEOF_INT__ != 4 || __CHAR_BIT__ != 8)\n    return 0;\n  asm volatile (\"\" : : \"g\" (&b), \"g\" (&c) : \"memory\");\n  foo ();\n  if (d != 799092689U)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78791.c",
    "content": "/* PR target/78791 */\n\n__attribute__((used, noinline, noclone)) unsigned long long\nfoo (unsigned long long x, unsigned long long y, unsigned long long z)\n{\n  unsigned long long a = x / y;\n  unsigned long long b = x % y;\n  a |= z;\n  b ^= z;\n  return a + b;\n}\n\nint\nmain ()\n{\n  if (foo (64, 7, 0) != 10 || foo (28, 3, 2) != 14)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr78856.c",
    "content": "extern void exit (int);\n\nint a, b, c, d, e, f[3]; \n\nint main() \n{\n  while (d)\n    while (1)\n      ;\n  int g = 0, h, i = 0;\n  for (; g < 21; g += 9) \n    {\n      int j = 1;\n      for (h = 0; h < 3; h++)\n\tf[h] = 1;\n      for (; j < 10; j++) {\n\td = i && (b ? 0 : c); \n\ti = 1;\n\tif (g)\n\t  a = e;\n      }\n  }\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79043.c",
    "content": "/* PR ipa/78791 */\n\nint val;\n\nint *ptr = &val;\nfloat *ptr2 = &val;\n\nstatic\n__attribute__((always_inline, optimize (\"-fno-strict-aliasing\")))\ntypepun ()\n{\n  *ptr2=0;\n}\n\nmain()\n{\n  *ptr=1;\n  typepun ();\n  if (*ptr)\n    __builtin_abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79121.c",
    "content": "#if __SIZEOF_INT__ < 4\n  __extension__ typedef __UINT32_TYPE__ uint32_t;\n  __extension__ typedef __INT32_TYPE__ int32_t;\n#else\n  typedef unsigned uint32_t;\n  typedef int int32_t;\n#endif\n\nextern void abort (void);\n\n__attribute__ ((noinline, noclone)) unsigned long long f1 (int32_t x)\n{\n  return ((unsigned long long) x) << 4;\n}\n\n__attribute__ ((noinline, noclone)) long long f2 (uint32_t x)\n{\n  return ((long long) x) << 4;\n}\n\n__attribute__ ((noinline, noclone)) unsigned long long f3 (uint32_t x)\n{\n  return ((unsigned long long) x) << 4;\n}\n\n__attribute__ ((noinline, noclone)) long long f4 (int32_t x)\n{\n  return ((long long) x) << 4;\n}\n\nint main ()\n{\n  if (f1 (0xf0000000) != 0xffffffff00000000)\n    abort ();\n  if (f2 (0xf0000000) != 0xf00000000)\n    abort ();\n  if (f3 (0xf0000000) != 0xf00000000)\n    abort ();\n  if (f4 (0xf0000000) != 0xffffffff00000000)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79286.c",
    "content": "int a = 0, c = 0;\nstatic int d[][8] = {};\n\nint main ()\n{\n  int e;\n  for (int b = 0; b < 4; b++)\n    {\n      __builtin_printf (\"%d\\n\", b, e);\n      while (a && c++)\n\te = d[300000000000000000][0];\n    }\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79327.c",
    "content": "/* PR tree-optimization/79327 */\n/* { dg-require-effective-target c99_runtime } */\n\nvolatile int a;\n\nint\nmain (void)\n{\n  int i;\n  char buf[64];\n  if (__builtin_sprintf (buf, \"%#hho\", a) != 1)\n    __builtin_abort ();\n  if (__builtin_sprintf (buf, \"%#hhx\", a) != 1)\n    __builtin_abort ();\n  a = 1;\n  if (__builtin_sprintf (buf, \"%#hho\", a) != 2)\n    __builtin_abort ();\n  if (__builtin_sprintf (buf, \"%#hhx\", a) != 3)\n    __builtin_abort ();\n  a = 127;\n  if (__builtin_sprintf (buf, \"%#hho\", a) != 4)\n    __builtin_abort ();\n  if (__builtin_sprintf (buf, \"%#hhx\", a) != 4)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79354.c",
    "content": "/* PR target/79354 */\n\nint b, f, g;\nfloat e;\nunsigned long d;\n\n__attribute__((noinline, noclone)) void\nfoo (int *a)\n{\n  for (g = 0; g < 32; g++)\n    if (f)\n      {\n        e = d;\n        __builtin_memcpy (&b, &e, sizeof (float));\n        b = *a;\n      }\n}\n\nint\nmain ()\n{\n  int h = 5;\n  f = 1;\n  asm volatile (\"\" : : : \"memory\");\n  foo (&h);\n  asm volatile (\"\" : : : \"memory\");\n  foo (&b);\n  asm volatile (\"\" : : : \"memory\");\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79388.c",
    "content": "/* PR rtl-optimization/79388 */\n/* { dg-additional-options \"-fno-tree-coalesce-vars\" } */\n\nunsigned int a, c;\n\n__attribute__ ((noinline, noclone)) unsigned int\nfoo (unsigned int p)\n{\n  p |= 1;\n  p &= 0xfffe;\n  p %= 0xffff;\n  c = p;\n  return a + p;\n}\n\nint\nmain (void)\n{\n  int x = foo (6);\n  if (x != 6)\n    __builtin_abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79450.c",
    "content": "/* PR rtl-optimization/79450 */\n\nunsigned int\nfoo (unsigned char x, unsigned long long y)\n{\n  do\n    {\n      x &= !y;\n      x %= 24;\n    }\n  while (x < y);\n  return x + y;\n}\n\nint\nmain (void)\n{\n  unsigned int x = foo (1, 0);\n  if (x != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79737-1.c",
    "content": "/* PR tree-optimization/79737 */\n\n#if __SIZEOF_INT__ < 4\n  __extension__ typedef __INT32_TYPE__ int32_t;\n#else\n  typedef int int32_t;\n#endif\n\n#pragma pack(1)\nstruct S\n{\n  int32_t b:18;\n  int32_t c:1;\n  int32_t d:24;\n  int32_t e:15;\n  int32_t f:14;\n} i;\nint g, j, k;\nstatic struct S h;\n\nvoid\nfoo ()\n{\n  for (j = 0; j < 6; j++)\n    k = 0;\n  for (; k < 3; k++)\n    {\n      struct S m = { 5, 0, -5, 9, 5 };\n      h = m;\n      if (g)\n\ti = m;\n      h.e = 0;\n    }\n}\n\nint\nmain ()\n{\n  foo ();\n  if (h.e != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr79737-2.c",
    "content": "/* PR tree-optimization/79737 */\n\n#if __SIZEOF_INT__ < 4\n  __extension__ typedef __INT32_TYPE__ int32_t;\n#else\n  typedef int int32_t;\n#endif\n\n#pragma pack(1)\nstruct S\n{\n  int32_t b:18;\n  int32_t c:1;\n  int32_t d:24;\n  int32_t e:15;\n  int32_t f:14;\n} i, j;\n\nvoid\nfoo ()\n{\n  i.e = 0;\n  i.b = 5;\n  i.c = 0;\n  i.d = -5;\n  i.f = 5;\n}\n\nvoid\nbar ()\n{\n  j.b = 5;\n  j.c = 0;\n  j.d = -5;\n  j.e = 0;\n  j.f = 5;\n}\n\nint\nmain ()\n{\n  foo ();\n  bar ();\n  asm volatile (\"\" : : : \"memory\");\n  if (i.b != j.b || i.c != j.c || i.d != j.d || i.e != j.e || i.f != j.f)\n    __builtin_abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr80153.c",
    "content": "/* PR tree-optimization/80153 */\n\nvoid check (int, int, int) __attribute__((noinline));\nvoid check (int c, int c2, int val)\n{\n  if (!val) {\n    __builtin_abort();\n  }\n}\n\nstatic const char *buf;\nstatic int l, i;\n\nvoid _fputs(const char *str)  __attribute__((noinline));\nvoid _fputs(const char *str)\n{\n  buf = str;\n  i = 0;\n  l = __builtin_strlen(buf);\n}\n\nchar _fgetc() __attribute__((noinline));\nchar _fgetc()\n{\n  char val = buf[i];\n  i++;\n  if (i > l)\n    return -1;\n  else\n    return val;\n}\n\nstatic const char *string = \"oops!\\n\";\n\nint main(void)\n{\n  int i;\n  int c;\n\n  _fputs(string);\n\n  for (i = 0; i < __builtin_strlen(string); i++) {\n    c = _fgetc();\n    check(c, string[i], c == string[i]);\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr80501.c",
    "content": "/* PR rtl-optimization/80501 */\n\nsigned char v = 0;\n\nstatic signed char\nfoo (int x, int y)\n{\n  return x << y;\n}\n\n__attribute__((noinline, noclone)) int\nbar (void)\n{\n  return foo (v >= 0, __CHAR_BIT__ - 1) >= 1;\n}\n\nint\nmain ()\n{\n  if (sizeof (int) > sizeof (char) && bar () != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr80692.c",
    "content": "/* { dg-require-effective-target dfp } */\n\nint main () {\n\t_Decimal64 d64 = -0.DD;\n\n\tif (d64 != 0.DD)\n\t\t__builtin_abort ();\n\n\tif (d64 != -0.DD)\n\t\t__builtin_abort ();\n\n\treturn 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr81555.c",
    "content": "/* PR tree-optimization/81555 */\n\nunsigned int a = 1, d = 0xfaeU, e = 0xe376U;\n_Bool b = 0, f = 1;\nunsigned char g = 1;\n\nvoid\nfoo (void)\n{\n  _Bool c = a != b;\n  if (c)\n    f = 0;\n  if (e & c & (unsigned char)d & c)\n    g = 0;\n}\n\nint\nmain ()\n{\n  foo ();\n  if (f || g != 1)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr81556.c",
    "content": "/* PR tree-optimization/81556 */\n\nunsigned long long int b = 0xb82ff73c5c020599ULL;\nunsigned long long int c = 0xd4e8188733a29d8eULL;\nunsigned long long int d = 2, f = 1, g = 0, h = 0;\nunsigned long long int e = 0xf27771784749f32bULL;\n\n__attribute__((noinline, noclone)) void\nfoo (void)\n{\n  _Bool a = d > 1;\n  g = f % ((d > 1) << 9);\n  h = a & (e & (a & b & c));\n}\n\nint\nmain ()\n{\n  foo ();\n  if (g != 1 || h != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pr81588.c",
    "content": "/* PR tree-optimization/81588 */\n\n__attribute__((noinline, noclone)) int\nbar (int x)\n{\n  __asm volatile (\"\" : : \"g\" (x) : \"memory\");\n}\n\n__attribute__((noinline, noclone)) int\nfoo (unsigned x, long long y)\n{\n  if (y < 0)\n    return 0;\n  if (y < (long long) (4 * x))\n    {\n      bar (y);\n      return 1;\n    }\n  return 0;\n}     \n\nint\nmain ()\n{\n  volatile unsigned x = 10;\n  volatile long long y = -10000;\n  if (foo (x, y) != 0)\n    __builtin_abort ();\n  y = -1;\n  if (foo (x, y) != 0)\n    __builtin_abort ();\n  y = 0;\n  if (foo (x, y) != 1)\n    __builtin_abort ();\n  y = 39;\n  if (foo (x, y) != 1)\n    __builtin_abort ();\n  y = 40;\n  if (foo (x, y) != 0)\n    __builtin_abort ();\n  y = 10000;\n  if (foo (x, y) != 0)\n    __builtin_abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/printf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n\nint\nmain (void)\n{\n#define test(ret, args...) \\\n  printf (args); \t\t\\\n  if (printf (args) != ret)\t\\\n    abort ();\n  test (5, \"hello\");\n  test (6, \"hello\\n\");\n  test (1, \"a\");\n  test (0, \"\");\n  test (5, \"%s\", \"hello\");\n  test (6, \"%s\", \"hello\\n\");\n  test (1, \"%s\", \"a\");\n  test (0, \"%s\", \"\");\n  test (1, \"%c\", 'x');\n  test (7, \"%s\\n\", \"hello\\n\");\n  test (2, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__printf_chk (int flag, const char *fmt, ...)\n{\n  va_list ap;\n  int ret;\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  va_start (ap, fmt);\n  ret = vprintf (fmt, ap);\n  va_end (ap);\n  return ret;\n}\n\nint\nmain (void)\n{\n#define test(ret, opt, args...) \\\n  should_optimize = opt;\t\t\\\n  __printf_chk (1, args); \t\t\\\n  if (!should_optimize)\t\t\t\\\n    abort ();\t\t\t\t\\\n  should_optimize = 0;\t\t\t\\\n  if (__printf_chk (1, args) != ret)\t\\\n    abort ();\t\t\t\t\\\n  if (!should_optimize)\t\t\t\\\n    abort ();\n  test (5, 0, \"hello\");\n  test (6, 1, \"hello\\n\");\n  test (1, 1, \"a\");\n  test (0, 1, \"\");\n  test (5, 0, \"%s\", \"hello\");\n  test (6, 1, \"%s\", \"hello\\n\");\n  test (1, 1, \"%s\", \"a\");\n  test (0, 1, \"%s\", \"\");\n  test (1, 1, \"%c\", 'x');\n  test (7, 1, \"%s\\n\", \"hello\\n\");\n  test (2, 0, \"%d\\n\", 0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pta-field-1.c",
    "content": "struct Foo {\n  int *p;\n  int *q;\n};\n\nvoid __attribute__((noinline))\nbar (int **x)\n{\n  struct Foo *f = (struct Foo *)x;\n  *(f->q) = 0;\n}\n\nint foo(void)\n{\n  struct Foo f;\n  int i = 1, j = 2;\n  f.p = &i;\n  f.q = &j;\n  bar(&f.p);\n  return j;\n}\n\nextern void abort (void);\nint main()\n{\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pta-field-2.c",
    "content": "struct Foo {\n  int *p;\n  int *q;\n};\n\nvoid __attribute__((noinline))\nbar (int **x)\n{\n  struct Foo *f = (struct Foo *)(x - 1);\n  *(f->p) = 0;\n}\n\nint foo(void)\n{\n  struct Foo f;\n  int i = 1, j = 2;\n  f.p = &i;\n  f.q = &j;\n  bar(&f.q);\n  return i;\n}\n\nextern void abort (void);\nint main()\n{\n  if (foo () != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/ptr-arith-1.c",
    "content": "char *\nf (char *s, unsigned int i)\n{\n  return &s[i + 3 - 1];\n}\n\nmain ()\n{\n  char *str = \"abcdefghijkl\";\n  char *x2 = f (str, 12);\n  if (str + 14 != x2)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pure-1.c",
    "content": "\n/* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> 2002-05-27.  */\n\n/* Use a different function for each test so the link failures\n   indicate which one is broken.  */\nextern void link_error0 (void);\nextern void link_error1 (void);\nextern void link_error2 (void);\nextern void link_error3 (void);\nextern void link_error4 (void);\nextern void link_error5 (void);\nextern void link_error6 (void);\nextern void link_error7 (void);\n\nextern int i;\n\nextern int func0 (int) __attribute__ ((__pure__));\nextern int func1 (int) __attribute__ ((__const__));\n\n/* GCC should automatically detect attributes for these functions.\n   At -O3 They'll be inlined, but that's ok.  */\nstatic int func2 (int a) { return i + a; } /* pure */\nstatic int func3 (int a) { return a * 3; } /* const */\nstatic int func4 (int a) { return func0(a) + a; } /* pure */\nstatic int func5 (int a) { return a + func1(a); } /* const */\nstatic int func6 (int a) { return func2(a) + a; } /* pure */\nstatic int func7 (int a) { return a + func3(a); } /* const */\n\nint main ()\n{\n  int i[10], r;\n\n  i[0] = 0;\n  r = func0(0);\n  if (i[0])\n    link_error0();\n\n  i[1] = 0;\n  r = func1(0);\n  if (i[1])\n    link_error1();\n\n  i[2] = 0;\n  r = func2(0);\n  if (i[2])\n    link_error2();\n\n  i[3] = 0;\n  r = func3(0);\n  if (i[3])\n    link_error3();\n\n  i[4] = 0;\n  r = func4(0);\n  if (i[4])\n    link_error4();\n\n  i[5] = 0;\n  r = func5(0);\n  if (i[5])\n    link_error5();\n\n  i[6] = 0;\n  r = func6(0);\n  if (i[6])\n    link_error6();\n\n  i[7] = 0;\n  r = func7(0);\n  if (i[7])\n    link_error7();\n\n  return r;\n}\n\nint func0 (int a) { return a - i; } /* pure */\nint func1 (int a) { return a - a; } /* const */\n\nint i = 2;\n\n#ifndef __OPTIMIZE__\n/* Avoid link failures when not optimizing. */\nvoid link_error0() {}\nvoid link_error1() {}\nvoid link_error2() {}\nvoid link_error3() {}\nvoid link_error4() {}\nvoid link_error5() {}\nvoid link_error6() {}\nvoid link_error7() {}\n#endif /* ! __OPTIMIZE__ */\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/pushpop_macro.c",
    "content": "extern void abort ();\n\n#define _ 2\n#pragma push_macro(\"_\")\n#undef _\n#define _ 1\n#pragma pop_macro(\"_\")\n\nint main ()\n{\n  if (_ != 2)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/regstack-1.c",
    "content": "long double C = 5;\nlong double U = 1;\nlong double Y2 = 11;\nlong double Y1 = 17;\nlong double X, Y, Z, T, R, S;\nmain ()\n{\n  X = (C + U) * Y2;\n  Y = C - U - U;\n  Z = C + U + U;\n  T = (C - U) * Y1;\n  X = X - (Z + U);\n  R = Y * Y1;\n  S = Z * Y2;\n  T = T - Y;\n  Y = (U - Y) + R;\n  Z = S - (Z + U + U);\n  R = (Y2 + U) * Y1;\n  Y1 = Y2 * Y1;\n  R = R - Y2;\n  Y1 = Y1 - 0.5L;\n  if (Z != 68. || Y != 49. || X != 58. || Y1 != 186.5 || R != 193. || S != 77.\n      || T != 65. || Y2 != 11.)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/restrict-1.c",
    "content": "/*  PR rtl-optimization/16536\n    Origin:  Jeremy Denise      <jeremy.denise@libertysurf.fr>\n    Reduced: Wolfgang Bangerth  <bangerth@dealii.org>\n             Volker Reichelt    <reichelt@igpm.rwth-aachen.de>  */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort ();\n\ntypedef struct\n{\n  int i, dummy;\n} A;\n\ninline A foo (const A* p, const A* q)\n{\n  return (A){p->i+q->i};\n}\n\nvoid bar (A* __restrict__ p)\n{\n  *p=foo(p,p);\n  if (p->i!=2)\n    abort();\n}\n\nint main ()\n{\n  A a={1};\n  bar(&a);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define operl(a, b, op) (a op b)\n#define operr(a, b, op) (b op a)\n\n#define check(type, count, vec0, vec1, num, op, lr) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) {\\\n        if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \\\n            __builtin_abort (); \\\n    }\\\n} while (0)\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\nvolatile int one = 1;\n\nint main (int argc, char *argv[]) {\n#define fvec_2 (vector(4, float)){2., 2., 2., 2.}\n#define dvec_2 (vector(2, double)){2., 2.}\n\n\n    vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};\n    vector(8, short) v1;\n\n    vector(4, float) f0 = {1., 2., 3., 4.};\n    vector(4, float) f1, f2;\n\n    vector(2, double) d0 = {1., 2.};\n    vector(2, double) d1, d2;\n\n\n\n    v1 = 2 + v0;   check (short, 8, v0, v1, 2, +, l);\n    v1 = 2 - v0;   check (short, 8, v0, v1, 2, -, l);\n    v1 = 2 * v0;   check (short, 8, v0, v1, 2, *, l);\n    v1 = 2 / v0;   check (short, 8, v0, v1, 2, /, l);\n    v1 = 2 % v0;   check (short, 8, v0, v1, 2, %, l);\n    v1 = 2 ^ v0;   check (short, 8, v0, v1, 2, ^, l);\n    v1 = 2 & v0;   check (short, 8, v0, v1, 2, &, l);\n    v1 = 2 | v0;   check (short, 8, v0, v1, 2, |, l);\n    v1 = 2 << v0;   check (short, 8, v0, v1, 2, <<, l);\n    v1 = 2 >> v0;   check (short, 8, v0, v1, 2, >>, l);\n\n    v1 = v0 + 2;   check (short, 8, v0, v1, 2, +, r);\n    v1 = v0 - 2;   check (short, 8, v0, v1, 2, -, r);\n    v1 = v0 * 2;   check (short, 8, v0, v1, 2, *, r);\n    v1 = v0 / 2;   check (short, 8, v0, v1, 2, /, r);\n    v1 = v0 % 2;   check (short, 8, v0, v1, 2, %, r);\n    v1 = v0 ^ 2;   check (short, 8, v0, v1, 2, ^, r);\n    v1 = v0 & 2;   check (short, 8, v0, v1, 2, &, r);\n    v1 = v0 | 2;   check (short, 8, v0, v1, 2, |, r);\n\n    f1 = 2. + f0;  f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);\n    f1 = 2. - f0;  f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);\n    f1 = 2. * f0;  f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);\n    f1 = 2. / f0;  f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);\n\n    f1 = f0 + 2.;  f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 - 2.;  f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 * 2.;  f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 / 2.;  f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);\n\n    d1 = 2. + d0;  d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);\n    d1 = 2. - d0;  d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);\n    d1 = 2. * d0;  d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);\n    d1 = 2. / d0;  d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);\n\n    d1 = d0 + 2.;  d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 - 2.;  d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 * 2.;  d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 / 2.;  d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/scal-to-vec2.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define operl(a, b, op) (a op b)\n#define operr(a, b, op) (b op a)\n\n#define check(type, count, vec0, vec1, num, op, lr) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) {\\\n        if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \\\n            __builtin_abort (); \\\n    }\\\n} while (0)\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\n\nlong __attribute__ ((noinline)) vlng () {   return (long)42; }\nint  __attribute__ ((noinline)) vint () {   return (int) 43; }\nshort __attribute__ ((noinline)) vsrt () {   return (short)42; }\nchar __attribute__ ((noinline)) vchr () {    return (char)42; }\n\n\nint main (int argc, char *argv[]) {\n    vector(16, char) c0 = {argc, 1,2,3,4,5,6,7, argc, 1,2,3,4,5,6,7};\n    vector(16, char) c1;\n    \n    vector(8, short) s0 = {argc, 1,2,3,4,5,6,7};\n    vector(8, short) s1;\n\n    vector(4, int) i0 = {argc, 1, 2, 3};\n    vector(4, int) i1;\n\n    vector(2, long) l0 = {argc, 1};\n    vector(2, long) l1;\n\n    c1 = vchr() + c0; check (char, 16, c0, c1, vchr(), +, l);\n    \n    s1 = vsrt() + s0; check (short, 8, s0, s1, vsrt(), +, l);\n    s1 = vchr() + s0; check (short, 8, s0, s1, vchr(), +, l);\n\n    i1 = vint() * i0; check (int, 4, i0, i1, vint(), *, l);\n    i1 = vsrt() * i0; check (int, 4, i0, i1, vsrt(), *, l);\n    i1 = vchr() * i0; check (int, 4, i0, i1, vchr(), *, l);\n\n    l1 = vlng() * l0; check (long, 2, l0, l1, vlng(), *, l);\n    l1 = vint() * l0; check (long, 2, l0, l1, vint(), *, l);\n    l1 = vsrt() * l0; check (long, 2, l0, l1, vsrt(), *, l);\n    l1 = vchr() * l0; check (long, 2, l0, l1, vchr(), *, l);\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/scal-to-vec3.c",
    "content": "#define vector(elcount, type)  \\\n__attribute__((vector_size((elcount)*sizeof(type)))) type\n\n#define vidx(type, vec, idx) (*((type *) &(vec) + idx))\n\n#define veccompare(type, count, v0, v1) \\\ndo {\\\n    int __i; \\\n    for (__i = 0; __i < count; __i++) { \\\n        if (vidx (type, v0, __i) != vidx (type, v1, __i)) \\\n            __builtin_abort (); \\\n    } \\\n} while (0)\n\n\nint main (int argc, char *argv[]) {\n#define fvec_2 (vector(4, float)){2., 2., 2., 2.}\n#define dvec_2 (vector(2, double)){2., 2.}\n\n    vector(4, float) f0 = {1., 2., 3., 4.};\n    vector(4, float) f1, f2;\n\n    vector(2, double) d0 = {1., 2.};\n    vector(2, double) d1, d2;\n\n\n    f1 = 2 + f0;  f2 = fvec_2 + f0; veccompare (float, 4, f1, f2);\n    f1 = 2 - f0;  f2 = fvec_2 - f0; veccompare (float, 4, f1, f2);\n    f1 = 2 * f0;  f2 = fvec_2 * f0; veccompare (float, 4, f1, f2);\n    f1 = 2 / f0;  f2 = fvec_2 / f0; veccompare (float, 4, f1, f2);\n\n    f1 = f0 + 2;  f2 = f0 + fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 - 2;  f2 = f0 - fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 * 2;  f2 = f0 * fvec_2; veccompare (float, 4, f1, f2);\n    f1 = f0 / 2;  f2 = f0 / fvec_2; veccompare (float, 4, f1, f2);\n\n    d1 = 2 + d0;  d2 = dvec_2 + d0; veccompare (double, 2, d1, d2);\n    d1 = 2 - d0;  d2 = dvec_2 - d0; veccompare (double, 2, d1, d2);\n    d1 = 2 * d0;  d2 = dvec_2 * d0; veccompare (double, 2, d1, d2);\n    d1 = 2 / d0;  d2 = dvec_2 / d0; veccompare (double, 2, d1, d2);\n\n    d1 = d0 + 2;  d2 = d0 + dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 - 2;  d2 = d0 - dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 * 2;  d2 = d0 * dvec_2; veccompare (double, 2, d1, d2);\n    d1 = d0 / 2;  d2 = d0 / dvec_2; veccompare (double, 2, d1, d2);\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/scope-1.c",
    "content": "int v = 3;\n\nf ()\n{\n  int v = 4;\n  {\n    extern int v;\n    if (v != 3)\n      abort ();\n  }\n}\n\nmain ()\n{\n  f ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/shiftdi.c",
    "content": "/* { dg-require-effective-target int32plus } */\n\n/* Failed on sparc with -mv8plus because sparc.c:set_extends() thought\n   erroneously that SImode ASHIFT chops the upper bits, it does not.  */\n\ntypedef unsigned long long uint64;\n\nvoid g(uint64 x, int y, int z, uint64 *p)\n{\n\tunsigned w = ((x >> y) & 0xffffffffULL) << (z & 0x1f);\n\t*p |= (w & 0xffffffffULL) << z;\n}\n\nint main(void)\n{\n\tuint64 a = 0;\n\tg(0xdeadbeef01234567ULL, 0, 0, &a);\n\treturn (a == 0x01234567) ? 0 : 1;\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation\n\n   Check that constant folding of shift operations is working.\n\n   Roger Sayle, 10th October 2002.  */\n\nextern void abort (void);\nextern void link_error (void);\n\nvoid\nutest (unsigned int x)\n{\n  if (x >> 0 != x)\n    link_error ();\n\n  if (x << 0 != x)\n    link_error ();\n\n  if (0 << x != 0)\n    link_error ();\n\n  if (0 >> x != 0)\n    link_error ();\n\n  if (-1 >> x != -1)\n    link_error ();\n\n  if (~0 >> x != ~0)\n    link_error ();\n}\n\nvoid\nstest (int x)\n{\n  if (x >> 0 != x)\n    link_error ();\n\n  if (x << 0 != x)\n    link_error ();\n\n  if (0 << x != 0)\n    link_error ();\n\n  if (0 >> x != 0)\n    link_error ();\n}\n\nint\nmain ()\n{\n  utest(9);\n  utest(0);\n\n  stest(9);\n  stest(0);\n\n  return 0;\n}\n\n#ifndef __OPTIMIZE__\nvoid\nlink_error ()\n{\n  abort ();\n}\n#endif\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/simd-1.c",
    "content": "/* Origin: Aldy Hernandez <aldyh@redhat.com>\n\n   Purpose: Test generic SIMD support.  This test should work\n   regardless of if the target has SIMD instructions.\n*/\n\ntypedef int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint;\ntypedef int __attribute__((mode(SI))) siint;\n\nvecint i = { 150, 100, 150, 200 };\nvecint j = { 10, 13, 20, 30 };\nvecint k;\n\nunion {\n  vecint v;\n  siint i[4];\n} res;\n\n/* This should go away once we can use == and != on vector types.  */\nvoid\nverify (siint a1, siint a2, siint a3, siint a4,\n\tsiint b1, siint b2, siint b3, siint b4)\n{\n  if (a1 != b1\n      || a2 != b2\n      || a3 != b3\n      || a4 != b4)\n    abort ();\n}\n\nint\nmain ()\n{\n  k = i + j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);\n\n  k = i * j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);\n\n  k = i / j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);\n\n  k = i & j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);\n\n  k = i | j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);\n\n  k = i ^ j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);\n\n  k = -i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3],\n\t  -150, -100, -150, -200);\n\n  k = ~i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/simd-2.c",
    "content": "/* \n   Purpose: Test generic SIMD support, V8HImode.  This test should work\n   regardless of if the target has SIMD instructions.\n*/\n\ntypedef short __attribute__((vector_size (16))) vecint;\n\nvecint i = { 150, 100, 150, 200, 0, 0, 0, 0 };\nvecint j = { 10, 13, 20, 30, 1, 1, 1, 1 };\nvecint k;\n\nunion {\n  vecint v;\n  short i[8];\n} res;\n\n/* This should go away once we can use == and != on vector types.  */\nvoid\nverify (int a1, int a2, int a3, int a4,\n\tint b1, int b2, int b3, int b4)\n{\n  if (a1 != b1\n      || a2 != b2\n      || a3 != b3\n      || a4 != b4)\n    abort ();\n}\n\nint\nmain ()\n{\n  k = i + j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);\n\n  k = i * j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);\n\n  k = i / j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);\n\n  k = i & j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);\n\n  k = i | j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);\n\n  k = i ^ j;\n  res.v = k;\n\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);\n\n  k = -i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3],\n\t  -150, -100, -150, -200);\n\n  k = ~i;\n  res.v = k;\n  verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/simd-4.c",
    "content": "/* { dg-require-effective-target stdint_types } */\n#include <stdint.h>\ntypedef int32_t __attribute__((vector_size(8))) v2si;\nint64_t s64;\n\nstatic inline int64_t\n__ev_convert_s64 (v2si a)\n{\n  return (int64_t) a;\n}\n\nint main()\n{\n  union { int64_t ll; int32_t i[2]; } endianness_test;\n  endianness_test.ll = 1;\n  int32_t little_endian = endianness_test.i[0];\n  s64 = __ev_convert_s64 ((v2si){1,0xffffffff});\n  if (s64 != (little_endian ? 0xffffffff00000001LL : 0x1ffffffffLL))\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/simd-5.c",
    "content": "/* Test saving and restoring of SIMD registers.  */\n\ntypedef short Q __attribute__((vector_size(8)));\n\nQ q1 = {1, 2}, q2 = {3, 4}, q3 = {5, 6}, q4 = {7, 8};\n\nQ w1, w2, w3, w4;\nQ z1, z2, z3, z4;\n\nvolatile int dummy;\n\nvoid  __attribute__((__noinline__))\nfunc0 (void)\n{\n  dummy = 1;\n}\n\nvoid __attribute__((__noinline__))\nfunc1 (void)\n{\n  Q a, b;\n  a = q1 * q2;\n  b = q3 * q4;\n  w1 = a;\n  w2 = b;\n  func0 ();\n  w3 = a;\n  w4 = b;\n}\n\nvoid __attribute__((__noinline__))\nfunc2 (void)\n{\n  Q a, b;\n  a = q1 + q2;\n  b = q3 - q4;\n  z1 = a;\n  z2 = b;\n  func1 ();\n  z3 = a;\n  z4 = b;\n}\n\nint\nmain (void)\n{\n  func2 ();\n\n  if (memcmp (&w1, &w3, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&w2, &w4, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&z1, &z3, sizeof (Q)) != 0)\n    abort ();\n  if (memcmp (&z2, &z4, sizeof (Q)) != 0)\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/simd-6.c",
    "content": "extern void abort (void);\nextern int memcmp (const void *, const void *, __SIZE_TYPE__);\n\ntypedef unsigned char v8qi __attribute__((vector_size(8)));\n\nv8qi foo(v8qi x, v8qi y)\n{\n  return x * y;\n}\n\nint main()\n{\n  v8qi a = { 1, 2, 3, 4, 5, 6, 7, 8 };\n  v8qi b = { 3, 3, 3, 3, 3, 3, 3, 3 };\n  v8qi c = { 3, 6, 9, 12, 15, 18, 21, 24 };\n  v8qi r;\n\n  r = foo (a, b);\n  if (memcmp (&r, &c, 8) != 0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/stdarg-1.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\nva_list *pap;\n\nvoid\nfoo (int v, va_list ap)\n{\n  switch (v)\n    {\n    case 5: foo_arg = va_arg (ap, int); break;\n    default: abort ();\n    }\n}\n\nvoid\nbar (int v)\n{\n  if (v == 0x4006)\n    {\n      if (va_arg (gap, double) != 17.0\n\t  || va_arg (gap, long) != 129L)\n\tabort ();\n    }\n  else if (v == 0x4008)\n    {\n      if (va_arg (*pap, long long) != 14LL\n\t  || va_arg (*pap, long double) != 131.0L\n\t  || va_arg (*pap, int) != 17)\n\tabort ();\n    }\n  bar_arg = v;\n}\n\nvoid\nf0 (int i, ...)\n{\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  va_end (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  bar (d);\n  x = va_arg (ap, long);\n  bar (x);\n  va_end (ap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  d = va_arg (ap, double);\n  va_end (ap);\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  x = va_arg (ap, double);\n  foo (i, ap);\n  va_end (ap);\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  va_copy (gap, ap);\n  bar (i);\n  va_end (ap);\n  va_end (gap);\n}\n\nvoid\nf6 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  bar (d);\n  va_arg (ap, long);\n  va_arg (ap, long);\n  x = va_arg (ap, long);\n  bar (x);\n  va_end (ap);\n}\n\nvoid\nf7 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  pap = &ap;\n  bar (i);\n  va_end (ap);\n}\n\nvoid\nf8 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  pap = &ap;\n  bar (i);\n  d = va_arg (ap, double);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  f0 (1);\n  f1 (2);\n  d = 31.0;\n  f2 (3, 28L);\n  if (bar_arg != 28 || x != 28)\n    abort ();\n  f3 (4, 131.0);\n  if (d != 131.0)\n    abort ();\n  f4 (5, 16.0, 128);\n  if (x != 16 || foo_arg != 128)\n    abort ();\n  f5 (0x4006, 17.0, 129L);\n  if (bar_arg != 0x4006)\n    abort ();\n  f6 (7, 12L, 14L, -31L);\n  if (bar_arg != -31)\n    abort ();\n  f7 (0x4008, 14LL, 131.0L, 17, 26.0);\n  if (bar_arg != 0x4008)\n    abort ();\n  f8 (0x4008, 14LL, 131.0L, 17, 27.0);\n  if (bar_arg != 0x4008 || d != 27.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/stdarg-2.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\n\nvoid\nfoo (int v, va_list ap)\n{\n  switch (v)\n    {\n    case 5:\n      foo_arg = va_arg (ap, int);\n      foo_arg += va_arg (ap, double);\n      foo_arg += va_arg (ap, long long);\n      break;\n    case 8:\n      foo_arg = va_arg (ap, long long);\n      foo_arg += va_arg (ap, double);\n      break;\n    case 11:\n      foo_arg = va_arg (ap, int);\n      foo_arg += va_arg (ap, long double);\n      break;\n    default:\n      abort ();\n    }\n}\n\nvoid\nbar (int v)\n{\n  if (v == 0x4002)\n    {\n      if (va_arg (gap, int) != 13 || va_arg (gap, double) != -14.0)\n\tabort ();\n    }\n  bar_arg = v;\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_start (gap, i);\n  x = va_arg (gap, long);\n  va_end (gap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_start (gap, i);\n  bar (i);\n  va_end (gap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  x = va_arg (aps[4], long);\n  va_end (aps[4]);\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  bar (i);\n  va_end (aps[4]);\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list aps[10];\n  va_start (aps[4], i);\n  foo (i, aps[4]);\n  va_end (aps[4]);\n}\n\nstruct A { int i; va_list g; va_list h[2]; };\n\nvoid\nf6 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  x = va_arg (a.g, long);\n  va_end (a.g);\n}\n\nvoid\nf7 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  bar (i);\n  va_end (a.g);\n}\n\nvoid\nf8 (int i, ...)\n{\n  struct A a;\n  va_start (a.g, i);\n  foo (i, a.g);\n  va_end (a.g);\n}\n\nvoid\nf10 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  x = va_arg (a.h[1], long);\n  va_end (a.h[1]);\n}\n\nvoid\nf11 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  bar (i);\n  va_end (a.h[1]);\n}\n\nvoid\nf12 (int i, ...)\n{\n  struct A a;\n  va_start (a.h[1], i);\n  foo (i, a.h[1]);\n  va_end (a.h[1]);\n}\n\nint\nmain (void)\n{\n  f1 (1, 79L);\n  if (x != 79L)\n    abort ();\n  f2 (0x4002, 13, -14.0);\n  if (bar_arg != 0x4002)\n    abort ();\n  f3 (3, 2031L);\n  if (x != 2031)\n    abort ();\n  f4 (4, 18);\n  if (bar_arg != 4)\n    abort ();\n  f5 (5, 1, 19.0, 18LL);\n  if (foo_arg != 38)\n    abort ();\n  f6 (6, 18L);\n  if (x != 18L)\n    abort ();\n  f7 (7);\n  if (bar_arg != 7)\n    abort ();\n  f8 (8, 2031LL, 13.0);\n  if (foo_arg != 2044)\n    abort ();\n  f10 (9, 180L);\n  if (x != 180L)\n    abort ();\n  f11 (10);\n  if (bar_arg != 10)\n    abort ();\n  f12 (11, 2030, 12.0L);\n  if (foo_arg != 2042)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/stdarg-3.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\n\nint foo_arg, bar_arg;\nlong x;\ndouble d;\nva_list gap;\nstruct S1 { int i; double d; int j; double e; } s1;\nstruct S2 { double d; long i; } s2;\nint y;\n\nvoid\nbar (int v)\n{\n  bar_arg = v;\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    x = va_arg (ap, long);\n  va_end (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    d = va_arg (ap, double);\n  va_end (ap);\n}\n\nvoid\nf3 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      x = va_arg (ap, long);\n      va_end (ap);\n      bar (x);\n    }\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      d = va_arg (ap, double);\n      va_end (ap);\n      bar (d + 4.0);\n    }\n}\n\nvoid\nf5 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    s1 = va_arg (ap, struct S1);\n  va_end (ap);\n}\n\nvoid\nf6 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  while (i-- > 0)\n    s2 = va_arg (ap, struct S2);\n  va_end (ap);\n}\n\nvoid\nf7 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      s1 = va_arg (ap, struct S1);\n      va_end (ap);\n      bar (s1.i);\n    }\n}\n\nvoid\nf8 (int i, ...)\n{\n  va_list ap;\n  int j = i;\n  while (j-- > 0)\n    {\n      va_start (ap, i);\n      s2 = va_arg (ap, struct S2);\n      y = va_arg (ap, int);\n      va_end (ap);\n      bar (s2.i);\n    }\n}\n\nint\nmain (void)\n{\n  struct S1 a1, a3;\n  struct S2 a2, a4;\n\n  f1 (7, 1L, 2L, 3L, 5L, 7L, 9L, 11L, 13L);\n  if (x != 11L)\n    abort ();\n  f2 (6, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0);\n  if (d != 32.0)\n    abort ();\n  f3 (2, 1L, 3L);\n  if (bar_arg != 1L || x != 1L)\n    abort ();\n  f4 (2, 17.0, 19.0);\n  if (bar_arg != 21 || d != 17.0)\n    abort ();\n  a1.i = 131;\n  a1.j = 251;\n  a1.d = 15.0;\n  a1.e = 191.0;\n  a3 = a1;\n  a3.j = 254;\n  a3.e = 178.0;\n  f5 (2, a1, a3, a1);\n  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)\n    abort ();\n  f5 (3, a1, a3, a1);\n  if (s1.i != 131 || s1.j != 251 || s1.d != 15.0 || s1.e != 191.0)\n    abort ();\n  a2.i = 138;\n  a2.d = 16.0;\n  a4.i = 257;\n  a4.d = 176.0;\n  f6 (2, a2, a4, a2);\n  if (s2.i != 257 || s2.d != 176.0)\n    abort ();\n  f6 (3, a2, a4, a2);\n  if (s2.i != 138 || s2.d != 16.0)\n    abort ();\n  f7 (2, a3, a1, a1);\n  if (s1.i != 131 || s1.j != 254 || s1.d != 15.0 || s1.e != 178.0)\n    abort ();\n  if (bar_arg != 131)\n    abort ();\n  f8 (3, a4, a2, a2);\n  if (s2.i != 257 || s2.d != 176.0)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/stdarg-4.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\nlong x, y;\n\ninline void __attribute__((always_inline))\nf1i (va_list ap)\n{\n  x = va_arg (ap, double);\n  x += va_arg (ap, long);\n  x += va_arg (ap, double);\n}\n\nvoid\nf1 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  f1i (ap);\n  va_end (ap);\n}\n\ninline void __attribute__((always_inline))\nf2i (va_list ap)\n{\n  y = va_arg (ap, int);\n  y += va_arg (ap, long);\n  y += va_arg (ap, double);\n  f1i (ap);\n}\n\nvoid\nf2 (int i, ...)\n{\n  va_list ap;\n  va_start (ap, i);\n  f2i (ap);\n  va_end (ap);\n}\n\nlong\nf3h (int i, long arg0, long arg1, long arg2, long arg3)\n{\n  return i + arg0 + arg1 + arg2 + arg3;\n}\n\nlong\nf3 (int i, ...)\n{\n  long t, arg0, arg1, arg2, arg3;\n  va_list ap;\n\n  va_start (ap, i);\n  switch (i)\n    {\n    case 0:\n      t = f3h (i, 0, 0, 0, 0);\n      break;\n    case 1:\n      arg0 = va_arg (ap, long);\n      t = f3h (i, arg0, 0, 0, 0);\n      break;\n    case 2:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, 0, 0);\n      break;\n    case 3:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      arg2 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, arg2, 0);\n      break;\n    case 4:\n      arg0 = va_arg (ap, long);\n      arg1 = va_arg (ap, long);\n      arg2 = va_arg (ap, long);\n      arg3 = va_arg (ap, long);\n      t = f3h (i, arg0, arg1, arg2, arg3);\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n\n  return t;\n}\n\nvoid\nf4 (int i, ...)\n{\n  va_list ap;\n\n  va_start (ap, i);\n  switch (i)\n    {\n    case 4:\n      y = va_arg (ap, double);\n      break;\n    case 5:\n      y = va_arg (ap, double);\n      y += va_arg (ap, double);\n      break;\n    default:\n      abort ();\n    }\n  f1i (ap);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  f1 (3, 16.0, 128L, 32.0);\n  if (x != 176L)\n    abort ();\n  f2 (6, 5, 7L, 18.0, 19.0, 17L, 64.0);\n  if (x != 100L || y != 30L)\n    abort ();\n  if (f3 (0) != 0)\n    abort ();\n  if (f3 (1, 18L) != 19L)\n    abort ();\n  if (f3 (2, 18L, 100L) != 120L)\n    abort ();\n  if (f3 (3, 18L, 100L, 300L) != 421L)\n    abort ();\n  if (f3 (4, 18L, 71L, 64L, 86L) != 243L)\n    abort ();\n  f4 (4, 6.0, 9.0, 16L, 18.0);\n  if (x != 43L || y != 6L)\n    abort ();\n  f4 (5, 7.0, 21.0, 1.0, 17L, 126.0);\n  if (x != 144L || y != 28L)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/stkalign.c",
    "content": "/* { dg-options \"-fno-inline\" } */\n/* Check that stack alignment is not affected by variables not placed\n   on the stack.  */\n\n#include <assert.h>\n\n#define ALIGNMENT 64\n\nunsigned test(unsigned n, unsigned p)\n{\n  static struct { char __attribute__((__aligned__(ALIGNMENT))) c; } s;\n  unsigned x;\n\n  assert(__alignof__(s) == ALIGNMENT);\n  asm (\"\" : \"=g\" (x), \"+m\" (s) : \"0\" (&x));\n\n  return n ? test(n - 1, x) : (x ^ p);\n}\n\nunsigned test2(unsigned n, unsigned p)\n{\n  static struct { char c; } s;\n  unsigned x;\n\n  assert(__alignof__(s) != ALIGNMENT);\n  asm (\"\" : \"=g\" (x), \"+m\" (s) : \"0\" (&x));\n\n  return n ? test2(n - 1, x) : (x ^ p);\n}\n\nint main (int argc, char *argv[] __attribute__((unused)))\n{\n  unsigned int x, y;\n\n  x = test(argc, 0);\n  x |= test(argc + 1, 0);\n  x |= test(argc + 2, 0);\n\n  y = test2(argc, 0);\n  y |= test2(argc + 1, 0);\n  y |= test2(argc + 2, 0);\n\n  return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strcmp-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strcmp with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 2)\n\nstatic union {\n  unsigned char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\ntest (const unsigned char *s1, const unsigned char *s2, int expected)\n{\n  int value = strcmp ((char *) s1, (char *) s2);\n\n  if (expected < 0 && value >= 0)\n    abort ();\n  else if (expected == 0 && value != 0)\n    abort ();\n  else if (expected > 0 && value <= 0)\n    abort ();\n}\n\nmain ()\n{\n  size_t off1, off2, len, i;\n  unsigned char *buf1, *buf2;\n  unsigned char *mod1, *mod2;\n  unsigned char *p1, *p2;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 0; len < MAX_TEST; len++)\n\t{\n\t  p1 = u1.buf;\n\t  for (i = 0; i < off1; i++)\n\t    *p1++ = '\\0';\n\n\t  buf1 = p1;\n\t  for (i = 0; i < len; i++)\n\t    *p1++ = 'a';\n\n\t  mod1 = p1;\n\t  for (i = 0; i < MAX_EXTRA+2; i++)\n\t    *p1++ = 'x';\n\n\t  p2 = u2.buf;\n\t  for (i = 0; i < off2; i++)\n\t    *p2++ = '\\0';\n\n\t  buf2 = p2;\n\t  for (i = 0; i < len; i++)\n\t    *p2++ = 'a';\n\n\t  mod2 = p2;\n\t  for (i = 0; i < MAX_EXTRA+2; i++)\n\t    *p2++ = 'x';\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, 0);\n\n\t  mod1[0] = 'a';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = 'a';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'c';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = 'c';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\252';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, -1);\n\n\t  mod1[0] = (unsigned char)'\\252';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, +1);\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strcpy-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strcpy with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.  */\n\n#include <string.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_COPY\n#define MAX_COPY (10 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_COPY + 1 + MAX_EXTRA)\n\n/* Use a sequence length that is not divisible by two, to make it more\n   likely to detect when words are mixed up.  */\n#define SEQUENCE_LENGTH 31\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nmain ()\n{\n  int off1, off2, len, i;\n  char *p, *q, c;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 1; len < MAX_COPY; len++)\n\t{\n\t  for (i = 0, c = 'A'; i < MAX_LENGTH; i++, c++)\n\t    {\n\t      u1.buf[i] = 'a';\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      u2.buf[i] = c;\n\t    }\n\t  u2.buf[off2 + len] = '\\0';\n\n\t  p = strcpy (u1.buf + off1, u2.buf + off2);\n\t  if (p != u1.buf + off1)\n\t    abort ();\n\n\t  q = u1.buf;\n\t  for (i = 0; i < off1; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\n\t  for (i = 0, c = 'A' + off2; i < len; i++, q++, c++)\n\t    {\n\t      if (c >= 'A' + SEQUENCE_LENGTH)\n\t\tc = 'A';\n\t      if (*q != c)\n\t\tabort ();\n\t    }\n\n\t  if (*q++ != '\\0')\n\t    abort ();\n\t  for (i = 0; i < MAX_EXTRA; i++, q++)\n\t    if (*q != 'a')\n\t      abort ();\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strcpy-2.c",
    "content": "/* Test to make sure strcpy works correctly. */\n#define STRING \"Hi!THE\"\n\nconst char a[] = STRING;\n\nvoid f(char *a) __attribute__((noinline));\nvoid f(char *a)\n{\n  __builtin_strcpy (a, STRING);\n}\n\n\nint main(void)\n{\n  int i;\n  char b[sizeof(a)] = {};\n  f(b);\n  for(i = 0; i < sizeof(b); i++)\n    {\n      if (a[i] != b[i])\n\t__builtin_abort ();\n    }\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-pack-1.c",
    "content": "typedef struct\n{\n  short s __attribute__ ((aligned(2), packed));\n  double d __attribute__ ((aligned(2), packed));\n} TRIAL;\n\nint\ncheck (TRIAL *t)\n{\n  if (t->s != 1 || t->d != 16.0)\n    return 1;\n  return 0;\n}\n\nmain ()\n{\n  TRIAL trial;\n\n  trial.s = 1;\n  trial.d = 16.0;\n\n  if (check (&trial) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-pack-2.c",
    "content": "typedef struct\n{\n  short a __attribute__ ((aligned (2),packed));\n  short *ap[2]  __attribute__ ((aligned (2),packed));\n} A;\n\nmain ()\n{\n  short i, j = 1;\n  A a, *ap = &a;\n  ap->ap[j] = &i;\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c",
    "content": "typedef struct\n{\n  short i __attribute__ ((aligned (2),packed));\n  int f[2] __attribute__ ((aligned (2),packed));\n} A;\n\nf (ap)\n  A *ap;\n{\n  short i, j = 1;\n\n  i = ap->f[1];\n  i += ap->f[j];\n  for (j = 0; j < 2; j++)\n    i += ap->f[j];\n\n  return i;\n}\n\nmain ()\n{\n  A a;\n  a.f[0] = 100;\n  a.f[1] = 13;\n  if (f (&a) != 139)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-pack-4.c",
    "content": "typedef struct\n{\n  unsigned char a __attribute__((packed));\n  unsigned short b __attribute__((packed));\n} three_char_t;\n\nunsigned char\nmy_set_a (void)\n{\n  return 0xab;\n}\n\nunsigned short\nmy_set_b (void)\n{\n  return 0x1234;\n}\n\nmain ()\n{\n  three_char_t three_char;\n\n  three_char.a = my_set_a ();\n  three_char.b = my_set_b ();\n  if (three_char.a != 0xab || three_char.b != 0x1234)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-stdarg-1.c",
    "content": "#include <stdarg.h>\n\nstruct tiny\n{\n  char c;\n  char d;\n  char e;\n  char f;\n  char g;\n};\n\nf (int n, ...)\n{\n  struct tiny x;\n  int i;\n\n  va_list ap;\n  va_start (ap,n);\n  for (i = 0; i < n; i++)\n    {\n      x = va_arg (ap,struct tiny);\n      if (x.c != i + 10)\n\tabort();\n      if (x.d != i + 20)\n\tabort();\n      if (x.e != i + 30)\n\tabort();\n      if (x.f != i + 40)\n\tabort();\n      if (x.g != i + 50)\n\tabort();\n    }\n  {\n    long x = va_arg (ap, long);\n    if (x != 123)\n      abort();\n  }\n  va_end (ap);\n}\n\nmain ()\n{\n  struct tiny x[3];\n  x[0].c = 10;\n  x[1].c = 11;\n  x[2].c = 12;\n  x[0].d = 20;\n  x[1].d = 21;\n  x[2].d = 22;\n  x[0].e = 30;\n  x[1].e = 31;\n  x[2].e = 32;\n  x[0].f = 40;\n  x[1].f = 41;\n  x[2].f = 42;\n  x[0].g = 50;\n  x[1].g = 51;\n  x[2].g = 52;\n  f (3, x[0], x[1], x[2], (long) 123);\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.c",
    "content": "#include <stdarg.h>\n\nstruct s { int x, y; };\n\nf (int attr, ...)\n{\n  struct s va_values;\n  va_list va;\n  int i;\n\n  va_start (va, attr);\n\n  if (attr != 2)\n    abort ();\n\n  va_values = va_arg (va, struct s);\n  if (va_values.x != 0xaaaa || va_values.y != 0x5555)\n    abort ();\n\n  attr = va_arg (va, int);\n  if (attr != 3)\n    abort ();\n\n  va_values = va_arg (va, struct s);\n  if (va_values.x != 0xffff || va_values.y != 0x1111)\n    abort ();\n\n  va_end (va);\n}\n\nmain ()\n{\n  struct s a, b;\n\n  a.x = 0xaaaa;\n  a.y = 0x5555;\n  b.x = 0xffff;\n  b.y = 0x1111;\n\n  f (2, a, 3, b);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/string-opt-17.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test strcpy optimizations don't evaluate side-effects twice.\n      \n   Written by Jakub Jelinek, June 23, 2003.  */\n\ntypedef __SIZE_TYPE__ size_t;\nextern char *strcpy (char *, const char *);\nextern int memcmp (const void *, const void *, size_t);\nextern void abort (void);\nextern void exit (int);\n\nsize_t\ntest1 (char *s, size_t i)\n{\n  strcpy (s, \"foobarbaz\" + i++);\n  return i;\n}\n\nsize_t\ncheck2 (void)\n{\n  static size_t r = 5;\n  if (r != 5)\n    abort ();\n  return ++r;\n}\n\nvoid\ntest2 (char *s)\n{\n  strcpy (s, \"foobarbaz\" + check2 ());\n}\n\nint\nmain (void)\n{\n  char buf[10];\n  if (test1 (buf, 7) != 8 || memcmp (buf, \"az\", 3))\n    abort ();\n  test2 (buf);\n  if (memcmp (buf, \"baz\", 4))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/string-opt-18.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test equal pointer optimizations don't break anything.\n\n   Written by Roger Sayle, July 14, 2003.  */\n\nextern void abort ();\ntypedef __SIZE_TYPE__ size_t;\n\nextern void *memcpy(void*, const void*, size_t);\nextern void *mempcpy(void*, const void*, size_t);\nextern void *memmove(void*, const void*, size_t);\nextern char *strcpy(char*, const char*);\nextern int memcmp(const void*, const void*, size_t);\nextern int strcmp(const char*, const char*);\nextern int strncmp(const char*, const char*, size_t);\n\n\nvoid test1 (void *ptr)\n{\n  if (memcpy(ptr,ptr,8) != ptr)\n    abort ();\n}\n\nvoid test2 (char *ptr)\n{\n  if (mempcpy(ptr,ptr,8) != ptr+8)\n    abort ();\n}\n\nvoid test3 (void *ptr)\n{\n  if (memmove(ptr,ptr,8) != ptr)\n    abort ();\n}\n\nvoid test4 (char *ptr)\n{\n  if (strcpy(ptr,ptr) != ptr)\n    abort ();\n}\n\nvoid test5 (void *ptr)\n{\n  if (memcmp(ptr,ptr,8) != 0)\n    abort ();\n}\n\nvoid test6 (const char *ptr)\n{\n  if (strcmp(ptr,ptr) != 0)\n    abort ();\n}\n\nvoid test7 (const char *ptr)\n{\n  if (strncmp(ptr,ptr,8) != 0)\n    abort ();\n}\n\n\nint main ()\n{\n  char buf[10];\n\n  test1 (buf);\n  test2 (buf);\n  test3 (buf);\n  test4 (buf);\n  test5 (buf);\n  test6 (buf);\n  test7 (buf);\n\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/string-opt-5.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   Ensure builtin strlen, strcmp, strchr, strrchr and strncpy\n   perform correctly.\n\n   Written by Jakub Jelinek, 11/7/2000.  */\n\nextern void abort (void);\nextern __SIZE_TYPE__ strlen (const char *);\nextern int strcmp (const char *, const char *);\nextern char *strchr (const char *, int);\nextern char *strrchr (const char *, int);\nextern char *strncpy (char *, const char *, __SIZE_TYPE__);\nextern void *memset (void *, int, __SIZE_TYPE__);\nextern int memcmp (const void *, const void *, __SIZE_TYPE__);\n\nint x = 6;\nint y = 1;\nchar *bar = \"hi world\";\nchar buf [64];\n\nint main()\n{\n  const char *const foo = \"hello world\";\n  char dst [64];\n\n  if (strlen (bar) != 8)\n    abort ();\n  if (strlen (bar + (++x & 2)) != 6)\n    abort ();\n  if (x != 7)\n    abort ();\n  if (strlen (foo + (x++, 6)) != 5)\n    abort ();\n  if (x != 8)\n    abort ();\n  if (strlen (foo + (++x & 1)) != 10)\n    abort ();\n  if (x != 9)\n    abort ();\n  if (strcmp (foo + (x -= 6), \"lo world\"))\n    abort ();\n  if (x != 3)\n    abort ();\n  if (strcmp (foo, bar) >= 0)\n    abort ();\n  if (strcmp (foo, bar + (x++ & 1)) >= 0)\n    abort ();\n  if (x != 4)\n    abort ();\n  if (strchr (foo + (x++ & 7), 'l') != foo + 9)\n    abort ();\n  if (x != 5)\n    abort ();\n  if (strchr (bar, 'o') != bar + 4)\n    abort ();\n  if (strchr (bar, '\\0')  != bar + 8)\n    abort ();\n  if (strrchr (bar, 'x'))\n    abort ();\n  if (strrchr (bar, 'o') != bar + 4)\n    abort ();\n  if (strcmp (foo + (x++ & 1), \"ello world\" + (--y & 1)))\n    abort ();\n  if (x != 6 || y != 0)\n    abort ();\n  dst[5] = ' ';\n  dst[6] = '\\0';\n  x = 5;\n  y = 1;\n  if (strncpy (dst + 1, foo + (x++ & 3), 4) != dst + 1\n      || x != 6\n      || strcmp (dst + 1, \"ello \"))\n    abort ();\n  memset (dst, ' ', sizeof dst);\n  if (strncpy (dst + (++x & 1), (y++ & 3) + \"foo\", 10) != dst + 1\n      || x != 7\n      || y != 2\n      || memcmp (dst, \" oo\\0\\0\\0\\0\\0\\0\\0\\0 \", 12))\n    abort ();\n  memset (dst, ' ', sizeof dst);\n  if (strncpy (dst, \"hello\", 8) != dst || memcmp (dst, \"hello\\0\\0\\0 \", 9))\n    abort ();\n  x = '!';\n  memset (buf, ' ', sizeof buf);\n  if (memset (buf, x++, ++y) != buf\n      || x != '!' + 1\n      || y != 3\n      || memcmp (buf, \"!!!\", 3))\n    abort ();\n  if (memset (buf + y++, '-', 8) != buf + 3\n      || y != 4\n      || memcmp (buf, \"!!!--------\", 11))\n    abort ();\n  x = 10;\n  if (memset (buf + ++x, 0, y++) != buf + 11\n      || x != 11\n      || y != 5\n      || memcmp (buf + 8, \"---\\0\\0\\0\", 7))\n    abort ();\n  if (memset (buf + (x += 4), 0, 6) != buf + 15\n      || x != 15\n      || memcmp (buf + 10, \"-\\0\\0\\0\\0\\0\\0\\0\\0\\0\", 11))\n    abort ();\n\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strlen-1.c",
    "content": "/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strlen with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA + 1)\n\nstatic union {\n  char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u;\n\nmain ()\n{\n  size_t off, len, len2, i;\n  char *p;\n\n  for (off = 0; off < MAX_OFFSET; off++)\n    for (len = 0; len < MAX_TEST; len++)\n      {\n\tp = u.buf;\n\tfor (i = 0; i < off; i++)\n\t  *p++ = '\\0';\n\n\tfor (i = 0; i < len; i++)\n\t  *p++ = 'a';\n\n\t*p++ = '\\0';\n\tfor (i = 0; i < MAX_EXTRA; i++)\n\t  *p++ = 'b';\n\n\tp = u.buf + off;\n\tlen2 = strlen (p);\n\tif (len != len2)\n\t  abort ();\n      }\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/strncmp-1.c",
    "content": "/* { dg-xfail-if \"kernel strncmp does not perform unsigned comparisons\" { vxworks_kernel } \"*\" \"\" } */\n/* Copyright (C) 2002  Free Software Foundation.\n\n   Test strncmp with various combinations of pointer alignments and lengths to\n   make sure any optimizations in the library are correct.\n\n   Written by Michael Meissner, March 9, 2002.  */\n\n#include <string.h>\n#include <stddef.h>\n\n#ifndef MAX_OFFSET\n#define MAX_OFFSET (sizeof (long long))\n#endif\n\n#ifndef MAX_TEST\n#define MAX_TEST (8 * sizeof (long long))\n#endif\n\n#ifndef MAX_EXTRA\n#define MAX_EXTRA (sizeof (long long))\n#endif\n\n#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA)\n\nstatic union {\n  unsigned char buf[MAX_LENGTH];\n  long long align_int;\n  long double align_fp;\n} u1, u2;\n\nvoid\ntest (const unsigned char *s1, const unsigned char *s2, size_t len, int expected)\n{\n  int value = strncmp ((char *) s1, (char *) s2, len);\n\n  if (expected < 0 && value >= 0)\n    abort ();\n  else if (expected == 0 && value != 0)\n    abort ();\n  else if (expected > 0 && value <= 0)\n    abort ();\n}\n\nmain ()\n{\n  size_t off1, off2, len, i;\n  unsigned char *buf1, *buf2;\n  unsigned char *mod1, *mod2;\n  unsigned char *p1, *p2;\n\n  for (off1 = 0; off1 < MAX_OFFSET; off1++)\n    for (off2 = 0; off2 < MAX_OFFSET; off2++)\n      for (len = 0; len < MAX_TEST; len++)\n\t{\n\t  p1 = u1.buf;\n\t  for (i = 0; i < off1; i++)\n\t    *p1++ = '\\0';\n\n\t  buf1 = p1;\n\t  for (i = 0; i < len; i++)\n\t    *p1++ = 'a';\n\n\t  mod1 = p1;\n\t  for (i = 0; i < MAX_EXTRA; i++)\n\t    *p1++ = 'x';\n\n\t  p2 = u2.buf;\n\t  for (i = 0; i < off2; i++)\n\t    *p2++ = '\\0';\n\n\t  buf2 = p2;\n\t  for (i = 0; i < len; i++)\n\t    *p2++ = 'a';\n\n\t  mod2 = p2;\n\t  for (i = 0; i < MAX_EXTRA; i++)\n\t    *p2++ = 'x';\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, 0);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'a';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = '\\0';\n\t  mod2[0] = 'a';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'c';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'c';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = 'b';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = 'b';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\251';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\252';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, -1);\n\t  test (buf1, buf2, len, 0);\n\n\t  mod1[0] = (unsigned char)'\\252';\n\t  mod1[1] = '\\0';\n\t  mod2[0] = (unsigned char)'\\251';\n\t  mod2[1] = '\\0';\n\t  test (buf1, buf2, MAX_LENGTH, +1);\n\t  test (buf1, buf2, len, 0);\n\t}\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-aliasing-1.c",
    "content": "struct S { float f; };\nint __attribute__((noinline))\nfoo (int *r, struct S *p)\n{\n  int *q = (int *)&p->f;\n  int i = *q;\n  *r = 0;\n  return i + *q;\n}\nextern void abort (void);\nint main()\n{\n  int i = 1;\n  if (foo (&i, (struct S *)&i) != 1)\n    abort ();\n  return (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-cpy-1.c",
    "content": "/* powerpc64-linux gcc miscompiled this due to rs6000.c:expand_block_move\n   not setting mem aliasing info correctly for the code implementing the\n   structure assignment.  */\n\nstruct termios\n{\n  unsigned int a;\n  unsigned int b;\n  unsigned int c;\n  unsigned int d;\n  unsigned char pad[28];\n};\n\nstruct tty_driver\n{\n  unsigned char pad1[38];\n  struct termios t __attribute__ ((aligned (8)));\n};\n\nstatic struct termios zero_t;\nstatic struct tty_driver pty;\n\nvoid ini (void)\n{\n  pty.t = zero_t;\n  pty.t.a = 1;\n  pty.t.b = 2;\n  pty.t.c = 3;\n  pty.t.d = 4;\n}\n\nint main (void)\n{\n  extern void abort (void);\n\n  ini ();\n  if (pty.t.a != 1\n      || pty.t.b != 2\n      || pty.t.c != 3\n      || pty.t.d != 4)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ini-1.c",
    "content": "struct S\n{\n  char f1;\n  int f2[2];\n};\n\nstruct S object = {'X', 8, 9};\n\nmain ()\n{\n  if (object.f1 != 'X' || object.f2[0] != 8 || object.f2[1] != 9)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ini-2.c",
    "content": "struct {\n  int a:4;\n  int :4;\n  int b:4;\n  int c:4;\n} x = { 2,3,4 };\n\nmain ()\n{\n  if (x.a != 2)\n    abort ();\n  if (x.b != 3)\n    abort ();\n  if (x.c != 4)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ini-3.c",
    "content": "struct\n{\n  unsigned int f1:1, f2:1, f3:3, f4:3, f5:2, f6:1, f7:1;\n} result = {1, 1, 7, 7, 3, 1, 1};\n\nmain ()\n{\n  if ((result.f3 & ~7) != 0 || (result.f4 & ~7) != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ini-4.c",
    "content": "struct s {\n  int a[3];\n  int c[3];\n};\n\nstruct s s = {\n  c: {1, 2, 3}\n};\n\nmain()\n{\n  if (s.c[0] != 1)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c",
    "content": "#include <stdio.h>\n#include <string.h>\n\nchar out[100];\n\ntypedef struct { double d; int i[3]; } B;\ntypedef struct { char c[33],c1; } X;\n\nchar c1 = 'a';\nchar c2 = 127;\nchar c3 = (char)128;\nchar c4 = (char)255;\nchar c5 = -1;\n\ndouble d1 = 0.1;\ndouble d2 = 0.2;\ndouble d3 = 0.3;\ndouble d4 = 0.4;\ndouble d5 = 0.5;\ndouble d6 = 0.6;\ndouble d7 = 0.7;\ndouble d8 = 0.8;\ndouble d9 = 0.9;\n\nB B1 = {0.1,{1,2,3}};\nB B2 = {0.2,{5,4,3}};\nX X1 = {\"abcdefghijklmnopqrstuvwxyzABCDEF\", 'G'};\nX X2 = {\"123\",'9'};\nX X3 = {\"return-return-return\",'R'};\n\nX f (B a, char b, double c, B d)\n{\n  static X xr = {\"return val\", 'R'};\n  X r;\n  r = xr;\n  r.c1 = b;\n  sprintf (out, \"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})\",\n\t   a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]);\n  return r;\n}\n\nX (*fp) (B, char, double, B) = &f;\n\nmain ()\n{\n  X Xr;\n  char tmp[100];\n\n  Xr = f (B1, c2, d3, B2);\n  strcpy (tmp, out);\n  Xr.c[0] = Xr.c1 = '\\0';\n  Xr = (*fp) (B1, c2, d3, B2);\n  if (strcmp (tmp, out))\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/struct-ret-2.c",
    "content": "typedef struct\n{\n  unsigned char a __attribute__ ((packed));\n  unsigned short b __attribute__ ((packed));\n} three_byte_t;\n\nunsigned char\nf (void)\n{\n  return 0xab;\n}\n\nunsigned short\ng (void)\n{\n  return 0x1234;\n}\n\nmain ()\n{\n  three_byte_t three_byte;\n\n  three_byte.a = f ();\n  three_byte.b = g ();\n  if (three_byte.a != 0xab || three_byte.b != 0x1234)\n    abort ();\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/switch-1.c",
    "content": "/* Copyright (C) 2003  Free Software Foundation.\n\n   Test that switch statements suitable using case bit tests are\n   implemented correctly.\n\n   Written by Roger Sayle, 01/25/2001.  */\n\nextern void abort (void);\n\nint\nfoo (int x)\n{\n  switch (x)\n    {\n    case 4:\n    case 6:\n    case 9:\n    case 11:\n      return 30;\n    }\n  return 31;\n}\n\nint\nmain ()\n{\n  int i, r;\n\n  for (i=-1; i<66; i++)\n    {\n      r = foo (i);\n      if (i == 4)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 6)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 9)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (i == 11)\n\t{\n\t  if (r != 30)\n\t    abort ();\n\t}\n      else if (r != 31)\n\tabort ();\n    }\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/tstdi-1.c",
    "content": "#define FALSE 140\n#define TRUE 13\n\nfeq (x)\n     long long int x;\n{\n  if (x == 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfne (x)\n     long long int x;\n{\n  if (x != 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nflt (x)\n     long long int x;\n{\n  if (x < 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfge (x)\n     long long int x;\n{\n  if (x >= 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfgt (x)\n     long long int x;\n{\n  if (x > 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nfle (x)\n     long long int x;\n{\n  if (x <= 0)\n    return TRUE;\n  else\n    return FALSE;\n}\n\nmain ()\n{\n  if (feq (0LL) != TRUE)\n    abort ();\n  if (feq (-1LL) != FALSE)\n    abort ();\n  if (feq (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (feq (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (feq (1LL) != FALSE)\n    abort ();\n  if (feq (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  if (fne (0LL) != FALSE)\n    abort ();\n  if (fne (-1LL) != TRUE)\n    abort ();\n  if (fne (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (fne (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (fne (1LL) != TRUE)\n    abort ();\n  if (fne (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (flt (0LL) != FALSE)\n    abort ();\n  if (flt (-1LL) != TRUE)\n    abort ();\n  if (flt (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (flt (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (flt (1LL) != FALSE)\n    abort ();\n  if (flt (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  if (fge (0LL) != TRUE)\n    abort ();\n  if (fge (-1LL) != FALSE)\n    abort ();\n  if (fge (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (fge (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (fge (1LL) != TRUE)\n    abort ();\n  if (fge (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (fgt (0LL) != FALSE)\n    abort ();\n  if (fgt (-1LL) != FALSE)\n    abort ();\n  if (fgt (0x8000000000000000LL) != FALSE)\n    abort ();\n  if (fgt (0x8000000000000001LL) != FALSE)\n    abort ();\n  if (fgt (1LL) != TRUE)\n    abort ();\n  if (fgt (0x7fffffffffffffffLL) != TRUE)\n    abort ();\n\n  if (fle (0LL) != TRUE)\n    abort ();\n  if (fle (-1LL) != TRUE)\n    abort ();\n  if (fle (0x8000000000000000LL) != TRUE)\n    abort ();\n  if (fle (0x8000000000000001LL) != TRUE)\n    abort ();\n  if (fle (1LL) != FALSE)\n    abort ();\n  if (fle (0x7fffffffffffffffLL) != FALSE)\n    abort ();\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/unroll-1.c",
    "content": "/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\ninline int\nf (int x)\n{\n  return (x + 1);\n}\n \nint\nmain (void)\n{\n  int a = 0 ;\n \n  while ( (f(f(f(f(f(f(f(f(f(f(1))))))))))) + a < 12 )\n    {\n      a++;\n      exit (0);\n    }\n  if (a != 1)\n    abort();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/usmul.c",
    "content": "/* { dg-require-effective-target int32plus } */\nint __attribute__ ((noinline)) foo (short x, unsigned short y)\n{\n  return x * y;\n}\n\nint __attribute__ ((noinline)) bar (unsigned short x, short y)\n{\n  return x * y;\n}\n\nint main ()\n{\n  if (foo (-2, 0xffff) != -131070)\n    abort ();\n  if (foo (2, 0xffff) != 131070)\n    abort ();\n  if (foo (-32768, 0x8000) != -1073741824)\n    abort ();\n  if (foo (32767, 0x8000) != 1073709056)\n    abort ();\n\n  if (bar (0xffff, -2) != -131070)\n    abort ();\n  if (bar (0xffff, 2) != 131070)\n    abort ();\n  if (bar (0x8000, -32768) != -1073741824)\n    abort ();\n  if (bar (0x8000, 32767) != 1073709056)\n    abort ();\n\n  exit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-1.c",
    "content": "#include <stdarg.h>\n\ntypedef unsigned long L;\nf (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, L) != 10)\n    abort ();\n  if (va_arg (select, L) != 11)\n    abort ();\n  if (va_arg (select, L) != 0)\n    abort ();\n\n  va_end (select);\n}\n\nmain ()\n{\n  f (1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 0L);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-10.c",
    "content": "/* This is a modfied version of va-arg-9.c to test va_copy.  */\n\n#include <stdarg.h>\n\n#ifndef va_copy\n#define va_copy __va_copy\n#endif\n\nextern __SIZE_TYPE__ strlen (const char *);\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nfap (int i, char* format, va_list ap)\n{\n  va_list apc;\n  char *formatc;\n\n  va_copy (apc, ap);\n  formatc = format;\n\n  if (strlen (format) != 16 - i)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  while (*formatc)\n    if (*formatc++ != to_hex (va_arg (apc, int)))\n      abort ();\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  fap(0, format, ap);\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(1, format, ap);\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(2, format, ap);\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(3, format, ap);\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(4, format, ap);\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(5, format, ap);\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(6, format, ap);\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(7, format, ap);\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(8, format, ap);\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8, int a9,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(9, format, ap);\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(10, format, ap);\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(11, format, ap);\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(12, format, ap);\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(13, format, ap);\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(14, format, ap);\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(15, format, ap);\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-11.c",
    "content": "/* Test va_arg when the result is ignored and only the pointer increment\n   side effect is used.  */\n#include <stdarg.h>\n\nstatic int\nfoo (int a, ...)\n{\n  va_list va;\n  int i, res;\n\n  va_start (va, a);\n\n  for (i = 0; i < 4; ++i)\n    (void) va_arg (va, int);\n\n  res = va_arg (va, int);\n\n  va_end (va);\n\n  return res;\n}\n\nint\nmain (void)\n{\n  if (foo (5, 4, 3, 2, 1, 0))\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-12.c",
    "content": "#include <stdarg.h>\n\n/*typedef unsigned long L;*/\ntypedef double L;\nvoid f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, L) != 10.)\n    abort ();\n  if (va_arg (select, L) != 11.)\n    abort ();\n  if (va_arg (select, L) != 0.)\n    abort ();\n\n  va_end (select);\n}\n\nint main ()\n{\n  f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 0.);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-13.c",
    "content": "/* derived from mozilla source code */\n\n#include <stdarg.h>\n\ntypedef struct {\n  void *stream;\n  va_list ap;\n  int nChar;  \n} ScanfState;\n\nvoid dummy (va_list vap)\n{\n  if (va_arg (vap, int) != 1234) abort();\n  return;\n}\n\nvoid test (int fmt, ...)\n{\n  ScanfState state, *statep;\n\n  statep = &state;\n\n  va_start (statep->ap, fmt);\n  dummy (statep->ap);\n  va_end (statep->ap);\n  \n  va_start (state.ap, fmt);\n  dummy (state.ap);\n  va_end (state.ap);\n  \n  return;\n}\n\nint main (void)\n{\n  test (456, 1234);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-14.c",
    "content": "#include <stdarg.h>\n\nva_list global;\n\nvoid vat(va_list param, ...)\n{\n  va_list local;\n\n  va_start (local, param);\n  va_copy (global, local);\n  va_copy (param, local);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  if (va_arg (global, int) != 1)\n    abort();\n  va_end (global);\n  if (va_arg (param, int) != 1)\n    abort();\n  va_end (param);\n\n  va_start (param, param);\n  va_start (global, param);\n  va_copy (local, param);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  va_copy (local, global);\n  if (va_arg (local, int) != 1)\n    abort();\n  va_end (local);\n  if (va_arg (global, int) != 1)\n    abort();\n  va_end (global);\n  if (va_arg (param, int) != 1)\n    abort();\n  va_end (param);\n}\n\nint main(void) \n{\n  va_list t;\n  vat (t, 1);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-15.c",
    "content": "#include <stdarg.h>\n\nvoid vafunction (char *dummy, ...)\n{\n  double darg;\n  int iarg;\n  int flag = 0;\n  int i;\n  va_list ap;\n\n  va_start(ap, dummy);\n  for (i = 1; i <= 18; i++, flag++) \n    {\n      if (flag & 1)\n\t{\n\t  darg = va_arg (ap, double);\t\n\t  if (darg != (double)i)\n\t    abort();\n\t}\n      else\n\t{\n\t  iarg = va_arg (ap, int);\n\t  if (iarg != i)\n\t    abort();\n\t}\n    }\n    va_end(ap);\n}\n\nint main (void)\n{\n  vafunction( \"\", \n\t1, 2., \n\t3, 4., \n\t5, 6., \n\t7, 8., \n\t9, 10.,\n\t11, 12.,\n\t13, 14.,\n\t15, 16.,\n\t17, 18. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-16.c",
    "content": "#include <stdarg.h>\n\ntypedef double TYPE;\n\nvoid vafunction (TYPE dummy1, TYPE dummy2, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy2);\n  if (dummy1 != 888.)\n    abort();\n  if (dummy2 != 999.)\n    abort();\n  if (va_arg (ap, TYPE) != 1.)\n    abort();\n  if (va_arg (ap, TYPE) != 2.)\n    abort();\n  if (va_arg (ap, TYPE) != 3.)\n    abort();\n  if (va_arg (ap, TYPE) != 4.)\n    abort();\n  if (va_arg (ap, TYPE) != 5.)\n    abort();\n  if (va_arg (ap, TYPE) != 6.)\n    abort();\n  if (va_arg (ap, TYPE) != 7.)\n    abort();\n  if (va_arg (ap, TYPE) != 8.)\n    abort();\n  if (va_arg (ap, TYPE) != 9.)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( 888., 999., 1., 2., 3., 4., 5., 6., 7., 8., 9. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-17.c",
    "content": "#include <stdarg.h>\n\ntypedef double TYPE;\n\nvoid vafunction (char *dummy, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy);\n  if (va_arg (ap, TYPE) != 1.)\n    abort();\n  if (va_arg (ap, TYPE) != 2.)\n    abort();\n  if (va_arg (ap, TYPE) != 3.)\n    abort();\n  if (va_arg (ap, TYPE) != 4.)\n    abort();\n  if (va_arg (ap, TYPE) != 5.)\n    abort();\n  if (va_arg (ap, TYPE) != 6.)\n    abort();\n  if (va_arg (ap, TYPE) != 7.)\n    abort();\n  if (va_arg (ap, TYPE) != 8.)\n    abort();\n  if (va_arg (ap, TYPE) != 9.)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( \"\", 1., 2., 3., 4., 5., 6., 7., 8., 9. );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-18.c",
    "content": "#include <stdarg.h>\n\ntypedef double L;\nvoid f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...)\n{\n  va_list select;\n\n  va_start (select, p8);\n\n  if (va_arg (select, int) != 10)\n    abort ();\n  if (va_arg (select, int) != 11)\n    abort ();\n  if (va_arg (select, int) != 12)\n    abort ();\n\n  va_end (select);\n}\n\nint main ()\n{\n  f (1., 2., 3., 4., 5., 6., 7., 8., 9., 10, 11, 12);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-19.c",
    "content": "#include <stdarg.h>\n\ntypedef int TYPE;\n\nvoid vafunction (char *dummy, ...)\n{\n  va_list ap;\n\n  va_start(ap, dummy);\n  if (va_arg (ap, TYPE) != 1)\n    abort();\n  if (va_arg (ap, TYPE) != 2)\n    abort();\n  if (va_arg (ap, TYPE) != 3)\n    abort();\n  if (va_arg (ap, TYPE) != 4)\n    abort();\n  if (va_arg (ap, TYPE) != 5)\n    abort();\n  if (va_arg (ap, TYPE) != 6)\n    abort();\n  if (va_arg (ap, TYPE) != 7)\n    abort();\n  if (va_arg (ap, TYPE) != 8)\n    abort();\n  if (va_arg (ap, TYPE) != 9)\n    abort();\n  va_end(ap);\n}\n\n\nint main (void)\n{\n  vafunction( \"\", 1, 2, 3, 4, 5, 6, 7, 8, 9 );\n  exit(0);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-2.c",
    "content": "/* The purpose of this test is to catch edge cases when arguments are passed\n   in regs and on the stack.  We test 16 cases, trying to catch multiple\n   targets (some use 3 regs for argument passing, some use 12, etc.).\n   We test both the arguments and the `lastarg' (the argument to va_start).  */\n\n#include <stdarg.h>\n\nextern __SIZE_TYPE__ strlen ();\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  if (strlen (format) != 16 - 0)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 1)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 2)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 3)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 4)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 5)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 6)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 7)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 8)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 9)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 10)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 11)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 12)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 13)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 14)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  if (strlen (format) != 16 - 15)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-20.c",
    "content": "#include <stdarg.h>\n\nvoid foo(va_list v)\n{\n    unsigned long long x = va_arg (v, unsigned long long);\n    if (x != 16LL)\n\tabort();\n}\n\nvoid bar(char c, char d, ...)\n{\n    va_list v;\n    va_start(v, d);\n    foo(v);\n    va_end(v);\n}\n\nint main(void)\n{\n    bar(0, 0, 16LL);\n    exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-21.c",
    "content": "/* Copyright (C) 2000  Free Software Foundation.\n\n   If the argument to va_end() has side effects, test whether side\n   effects from that argument are honored.\n\n   Written by Kaveh R. Ghazi, 10/31/2000.  */\n\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#ifndef __GNUC__\n#define __attribute__(x)\n#endif\n\nstatic void __attribute__ ((__format__ (__printf__, 1, 2)))\ndoit (const char *s, ...) \n{\n  va_list *ap_array[3], **ap_ptr = ap_array;\n\n  ap_array[0] = malloc (sizeof(va_list));\n  ap_array[1] = NULL;\n  ap_array[2] = malloc (sizeof(va_list));\n  \n  va_start (*ap_array[0], s);\n  vprintf (s, **ap_ptr);\n  /* Increment the va_list pointer once.  */\n  va_end (**ap_ptr++);\n\n  /* Increment the va_list pointer a second time.  */\n  ap_ptr++;\n  \n  va_start (*ap_array[2], s);\n  /* If we failed to increment ap_ptr twice, then the parameter passed\n     in here will dereference NULL and should cause a crash.  */\n  vprintf (s, **ap_ptr);\n  va_end (**ap_ptr);\n\n  /* Just in case, If *ap_ptr is NULL abort anyway.  */\n  if (*ap_ptr == 0)\n    abort();\n}\n\nint main()\n{\n  doit (\"%s\", \"hello world\\n\");\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-22.c",
    "content": "#include <stdarg.h>\n\nextern void abort (void);\nextern void exit (int);\n\nvoid bar (int n, int c)\n{\n  static int lastn = -1, lastc = -1;\n\n  if (lastn != n)\n    {\n      if (lastc != lastn)\n\tabort ();\n      lastc = 0;\n      lastn = n;\n    }\n\n  if (c != (char) (lastc ^ (n << 3)))\n    abort ();\n  lastc++;\n}\n\n#define D(N) typedef struct { char x[N]; } A##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n\nvoid foo (int size, ...)\n{\n#define D(N) A##N a##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  va_list ap;\n  int i;\n\n  if (size != 21)\n    abort ();\n  va_start (ap, size);\n#define D(N)\t\t\t\t\t\\\n  a##N = va_arg (ap, typeof (a##N));\t\t\\\n  for (i = 0; i < N; i++)\t\t\t\\\n    bar (N, a##N.x[i]);\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  va_end (ap);\n}\n\nint main (void)\n{\n#define D(N) A##N a##N;\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n  int i;\n\n#define D(N)\t\t\t\t\t\\\n  for (i = 0; i < N; i++)\t\t\t\\\n    a##N.x[i] = i ^ (N << 3);\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n\n  foo (21\n#define D(N) , a##N\nD(0) D(1) D(2) D(3) D(4) D(5) D(6) D(7)\nD(8) D(9) D(10) D(11) D(12) D(13) D(14) D(15)\nD(16) D(31) D(32) D(35) D(72)\n#undef D\n      );\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-23.c",
    "content": "/* PR 9700 */\n/* Alpha got the base address for the va_list incorrect when there was\n   a structure that was passed partially in registers and partially on\n   the stack.  */\n\n#include <stdarg.h>\n\nstruct two { long x, y; };\n\nvoid foo(int a, int b, int c, int d, int e, struct two f, int g, ...)\n{\n  va_list args;\n  int h;\n\n  va_start(args, g);\n  h = va_arg(args, int);\n  if (g != 1 || h != 2)\n    abort ();\n}\n\nint main()\n{\n  struct two t = { 0, 0 };\n  foo(0, 0, 0, 0, 0, t, 1, 2);\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-24.c",
    "content": "/* The purpose of this code is to test argument passing of a tuple of\n   11 integers, with the break point between named and unnamed arguments\n   at every possible position.\t*/\n\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic int errors = 0;\n\nstatic void\nverify (const char *tcase, int n[11])\n{\n  int i;\n  for (i = 0; i <= 10; i++)\n    if (n[i] != i)\n      {\n\tprintf (\" %s: n[%d] = %d expected %d\\n\", tcase, i, n[i], i);\n\terrors++;\n      }\n}\n\n#define STR(x) #x\n\n#define p(i) int q##i,\n#define P(i) n[i] = q##i;\n\n#define p0 p(0)\n#define p1 p(1)\n#define p2 p(2)\n#define p3 p(3)\n#define p4 p(4)\n#define p5 p(5)\n#define p6 p(6)\n#define p7 p(7)\n#define p8 p(8)\n#define p9 p(9)\n\n#define P0 P(0)\n#define P1 P(1)\n#define P2 P(2)\n#define P3 P(3)\n#define P4 P(4)\n#define P5 P(5)\n#define P6 P(6)\n#define P7 P(7)\n#define P8 P(8)\n#define P9 P(9)\n\n#define TCASE(x, params, vecinit)\t\t\\\nstatic void\t\t\t\t\t\\\nvarargs##x (params ...)\t\t\t\t\\\n{\t\t\t\t\t\t\\\n  va_list ap;\t\t\t\t\t\\\n  int n[11];\t\t\t\t\t\\\n  int i;\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n  va_start (ap, q##x);\t\t\t\t\\\n  vecinit\t\t\t\t\t\\\n  for (i = x + 1; i <= 10; i++)\t\t\t\\\n    n[i] = va_arg (ap, int);\t\t\t\\\n  va_end (ap);\t\t\t\t\t\\\n\t\t\t\t\t\t\\\n  verify (STR(varargs##x), n);\t\t\t\\\n}\n\n#define TEST(x) varargs##x (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n\nTCASE(0, p0\t\t\t      , P0\t\t\t     )\nTCASE(1, p0 p1\t\t\t      , P0 P1\t\t\t     )\nTCASE(2, p0 p1 p2\t\t      , P0 P1 P2\t\t     )\nTCASE(3, p0 p1 p2 p3\t\t      , P0 P1 P2 P3\t\t     )\nTCASE(4, p0 p1 p2 p3 p4\t\t      , P0 P1 P2 P3 P4\t\t     )\nTCASE(5, p0 p1 p2 p3 p4 p5\t      , P0 P1 P2 P3 P4 P5\t     )\nTCASE(6, p0 p1 p2 p3 p4 p5 p6\t      , P0 P1 P2 P3 P4 P5 P6\t     )\nTCASE(7, p0 p1 p2 p3 p4 p5 p6 p7      , P0 P1 P2 P3 P4 P5 P6 P7\t     )\nTCASE(8, p0 p1 p2 p3 p4 p5 p6 p7 p8   , P0 P1 P2 P3 P4 P5 P6 P7 P8   )\nTCASE(9, p0 p1 p2 p3 p4 p5 p6 p7 p8 p9, P0 P1 P2 P3 P4 P5 P6 P7 P8 P9)\n\nint main(void)\n{\n  TEST(0);\n  TEST(1);\n  TEST(2);\n  TEST(3);\n  TEST(4);\n  TEST(5);\n  TEST(6);\n  TEST(7);\n  TEST(8);\n  TEST(9);\n\n  if (errors)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-26.c",
    "content": "#include <stdarg.h>\n\ndouble f (float f1, float f2, float f3, float f4,\n\t  float f5, float f6, ...)\n{\n  va_list ap;\n  double d;\n\n  va_start (ap, f6);\n  d = va_arg (ap, double);\n  va_end (ap);\n  return d;\n}\n\nint main ()\n{\n  if (f (1, 2, 3, 4, 5, 6, 7.0) != 7.0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-4.c",
    "content": "/* On the i960 any arg bigger than 16 bytes causes all subsequent args\n   to be passed on the stack.  We test this.  */\n\n#include <stdarg.h>\n\ntypedef struct {\n  char a[32];\n} big;\n\nvoid\nf (big x, char *s, ...)\n{\n  va_list ap;\n\n  if (x.a[0] != 'a' || x.a[1] != 'b' || x.a[2] != 'c')\n    abort ();\n  va_start (ap, s);\n  if (va_arg (ap, int) != 42)\n    abort ();\n  if (va_arg (ap, int) != 'x')\n    abort ();\n  if (va_arg (ap, int) != 0)\n    abort ();\n  va_end (ap);\n}\n\nmain ()\n{\n  static big x = { \"abc\" };\n\n  f (x, \"\", 42, 'x', 0);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-5.c",
    "content": "#include <stdarg.h>\n\nva_double (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, double) != 3.141592)\n    abort ();\n  if (va_arg (args, double) != 2.71827)\n    abort ();\n  if (va_arg (args, double) != 2.2360679)\n    abort ();\n  if (va_arg (args, double) != 2.1474836)\n    abort ();\n\n  va_end (args);\n}\n\nva_long_double (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, long double) != 3.141592L)\n    abort ();\n  if (va_arg (args, long double) != 2.71827L)\n    abort ();\n  if (va_arg (args, long double) != 2.2360679L)\n    abort ();\n  if (va_arg (args, long double) != 2.1474836L)\n    abort ();\n\n  va_end (args);\n}\n\nmain ()\n{\n  va_double (4, 3.141592, 2.71827, 2.2360679, 2.1474836);\n  va_long_double (4, 3.141592L, 2.71827L, 2.2360679L, 2.1474836L);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-6.c",
    "content": "#include <stdarg.h>\n\nf (int n, ...)\n{\n  va_list args;\n\n  va_start (args, n);\n\n  if (va_arg (args, int) != 10)\n    abort ();\n  if (va_arg (args, long long) != 10000000000LL)\n    abort ();\n  if (va_arg (args, int) != 11)\n    abort ();\n  if (va_arg (args, long double) != 3.14L)\n    abort ();\n  if (va_arg (args, int) != 12)\n    abort ();\n  if (va_arg (args, int) != 13)\n    abort ();\n  if (va_arg (args, long long) != 20000000000LL)\n    abort ();\n  if (va_arg (args, int) != 14)\n    abort ();\n  if (va_arg (args, double) != 2.72)\n    abort ();\n\n  va_end(args);\n}\n\nmain ()\n{\n  f (4, 10, 10000000000LL, 11, 3.14L, 12, 13, 20000000000LL, 14, 2.72);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-7.c",
    "content": "/* Origin: Franz Sirl <Franz.Sirl-kernel@lauterbach.com> */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#include <stdarg.h>\n\ninline void\ndebug(int i1, int i2, int i3, int i4, int i5, int i6, int i7,\n      double f1, double f2, double f3, double f4, double f5,\n      double f6, double f7, double f8, double f9, ...)\n{\n  va_list ap;\n\n  va_start (ap, f9);\n\n  if (va_arg (ap,int) != 8)\n    abort ();\n  if (va_arg (ap,int) != 9)\n    abort ();\n  if (va_arg (ap,int) != 10)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain(void)\n{\n  debug (1, 2, 3, 4, 5, 6, 7,\n\t 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0,\n\t 8, 9, 10);\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-8.c",
    "content": "/* Origin: Franz Sirl <Franz.Sirl-kernel@lauterbach.com> */\n/* { dg-options \"-fgnu89-inline\" } */\n\nextern void abort (void);\nextern void exit (int);\n\n#include <stdarg.h>\n#include <limits.h>\n\n#if __LONG_LONG_MAX__ == 9223372036854775807LL\n\ntypedef long long int INT64;\n\ninline void\ndebug(int i1, int i2, int i3, int i4, int i5,\n      int i6, int i7, int i8, int i9, ...)\n{\n  va_list ap;\n\n  va_start (ap, i9);\n\n  if (va_arg (ap,int) != 10)\n    abort ();\n  if (va_arg (ap,INT64) != 0x123400005678LL)\n    abort ();\n\n  va_end (ap);\n}\n\nint\nmain(void)\n{\n  debug(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0x123400005678LL);\n  exit(0);\n}\n\n#else\n\nint\nmain(void)\n{\n  exit(0);\n}\n\n#endif /* long long 64 bits */\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-9.c",
    "content": "/* This is a modfied version of va-arg-2.c to test passing a va_list as\n   a parameter to another function.  */\n\n#include <stdarg.h>\n\nextern __SIZE_TYPE__ strlen (const char *);\n\nint\nto_hex (unsigned int a)\n{\n  static char hex[] = \"0123456789abcdef\";\n\n  if (a > 15)\n    abort ();\n  return hex[a];\n}\n\nvoid\nfap (int i, char* format, va_list ap)\n{\n  if (strlen (format) != 16 - i)\n    abort ();\n  while (*format)\n    if (*format++ != to_hex (va_arg (ap, int)))\n      abort ();\n}\n\nvoid\nf0 (char* format, ...)\n{\n  va_list ap;\n\n  va_start (ap, format);\n  fap(0, format, ap);\n  va_end(ap);\n}\n\nvoid\nf1 (int a1, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(1, format, ap);\n  va_end(ap);\n}\n\nvoid\nf2 (int a1, int a2, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(2, format, ap);\n  va_end(ap);\n}\n\nvoid\nf3 (int a1, int a2, int a3, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(3, format, ap);\n  va_end(ap);\n}\n\nvoid\nf4 (int a1, int a2, int a3, int a4, char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(4, format, ap);\n  va_end(ap);\n}\n\nvoid\nf5 (int a1, int a2, int a3, int a4, int a5,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(5, format, ap);\n  va_end(ap);\n}\n\nvoid\nf6 (int a1, int a2, int a3, int a4, int a5,\n    int a6,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(6, format, ap);\n  va_end(ap);\n}\n\nvoid\nf7 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(7, format, ap);\n  va_end(ap);\n}\n\nvoid\nf8 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(8, format, ap);\n  va_end(ap);\n}\n\nvoid\nf9 (int a1, int a2, int a3, int a4, int a5,\n    int a6, int a7, int a8, int a9,\n    char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(9, format, ap);\n  va_end(ap);\n}\n\nvoid\nf10 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(10, format, ap);\n  va_end(ap);\n}\n\nvoid\nf11 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(11, format, ap);\n  va_end(ap);\n}\n\nvoid\nf12 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(12, format, ap);\n  va_end(ap);\n}\n\nvoid\nf13 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(13, format, ap);\n  va_end(ap);\n}\n\nvoid\nf14 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(14, format, ap);\n  va_end(ap);\n}\n\nvoid\nf15 (int a1, int a2, int a3, int a4, int a5,\n     int a6, int a7, int a8, int a9, int a10,\n     int a11, int a12, int a13, int a14, int a15,\n     char* format, ...)\n{\n  va_list ap;\n\n  va_start(ap, format);\n  fap(15, format, ap);\n  va_end(ap);\n}\n\nmain ()\n{\n  char *f = \"0123456789abcdef\";\n\n  f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15);\n  f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15);\n  f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15);\n  f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15);\n  f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15);\n  f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15);\n  f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15);\n  f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15);\n  f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15);\n\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-pack-1.c",
    "content": "/* __builtin_va_arg_pack () builtin tests.  */\n\n#include <stdarg.h>\n\nextern void abort (void);\n\nint v1 = 8;\nlong int v2 = 3;\nvoid *v3 = (void *) &v2;\nstruct A { char c[16]; } v4 = { \"foo\" };\nlong double v5 = 40;\nchar seen[20];\nint cnt;\n\n__attribute__ ((noinline)) int\nfoo1 (int x, int y, ...)\n{\n  int i;\n  long int l;\n  void *v;\n  struct A a;\n  long double ld;\n  va_list ap;\n\n  va_start (ap, y);\n  if (x < 0 || x >= 20 || seen[x])\n    abort ();\n  seen[x] = ++cnt;\n  if (y != 6)\n    abort ();\n  i = va_arg (ap, int);\n  if (i != 5)\n    abort ();\n  switch (x)\n    {\n    case 0:\n      i = va_arg (ap, int);\n      if (i != 9 || v1 != 9)\n\tabort ();\n      a = va_arg (ap, struct A);\n      if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)\n\tabort ();\n      v = (void *) va_arg (ap, struct A *);\n      if (v != (void *) &v4)\n\tabort ();\n      l = va_arg (ap, long int);\n      if (l != 3 || v2 != 4)\n\tabort ();\n      break;\n    case 1:\n      ld = va_arg (ap, long double);\n      if (ld != 41 || v5 != ld)\n\tabort ();\n      i = va_arg (ap, int);\n      if (i != 8)\n\tabort ();\n      v = va_arg (ap, void *);\n      if (v != &v2)\n\tabort ();\n      break;\n    case 2:\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n  return x;\n}\n\n__attribute__ ((noinline)) int\nfoo2 (int x, int y, ...)\n{\n  long long int ll;\n  void *v;\n  struct A a, b;\n  long double ld;\n  va_list ap;\n\n  va_start (ap, y);\n  if (x < 0 || x >= 20 || seen[x])\n    abort ();\n  seen[x] = ++cnt | 64;\n  if (y != 10)\n    abort ();\n  switch (x)\n    {\n    case 11:\n      break;\n    case 12:\n      ld = va_arg (ap, long double);\n      if (ld != 41 || v5 != 40)\n\tabort ();\n      a = va_arg (ap, struct A);\n      if (__builtin_memcmp (a.c, v4.c, sizeof (a.c)) != 0)\n\tabort ();\n      b = va_arg (ap, struct A);\n      if (__builtin_memcmp (b.c, v4.c, sizeof (b.c)) != 0)\n\tabort ();\n      v = va_arg (ap, void *);\n      if (v != &v2)\n\tabort ();\n      ll = va_arg (ap, long long int);\n      if (ll != 16LL)\n\tabort ();\n      break;\n    case 2:\n      break;\n    default:\n      abort ();\n    }\n  va_end (ap);\n  return x + 8;\n}\n\n__attribute__ ((noinline)) int\nfoo3 (void)\n{\n  return 6;\n}\n\nextern inline __attribute__ ((always_inline, gnu_inline)) int\nbar (int x, ...)\n{\n  if (x < 10)\n    return foo1 (x, foo3 (), 5, __builtin_va_arg_pack ());\n  return foo2 (x, foo3 () + 4, __builtin_va_arg_pack ());\n}\n\nint\nmain (void)\n{\n  if (bar (0, ++v1, v4, &v4, v2++) != 0)\n    abort ();\n  if (bar (1, ++v5, 8, v3) != 1)\n    abort ();\n  if (bar (2) != 2)\n    abort ();\n  if (bar (v1 + 2) != 19)\n    abort ();\n  if (bar (v1 + 3, v5--, v4, v4, v3, 16LL) != 20)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/va-arg-trap-1.c",
    "content": "/* Undefined behavior from a call to va_arg with a type other than\n   that of the argument passed (in particular, with a type such as\n   \"float\" that can never be the type of an argument passed through\n   \"...\") does not appear until after the va_list expression is\n   evaluated.  PR 38483.  */\n/* Origin: Joseph Myers <joseph@codesourcery.com> */\n\n#include <stdarg.h>\n\nextern void exit (int);\nextern void abort (void);\n\nva_list ap;\nfloat f;\n\nva_list *\nfoo (void)\n{\n  exit (0);\n  return &ap;\n}\n\nvoid\nbar (int i, ...)\n{\n  va_start (ap, i);\n  f = va_arg (*foo (), float);\n  va_end (ap);\n}\n\nint\nmain (void)\n{\n  bar (1, 0);\n  abort ();\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vfprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, fmt, args) \\\n    case n:\t\t\t\t\t\\\n      vfprintf (stdout, fmt, ap);\t\t\\\n      if (vfprintf (stdout, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\\\n      break;\n#include \"vfprintf-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, fmt, args) \\\n  inner args;\n#include \"vfprintf-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, \"hello\", (0));\n  test (1, 6, \"hello\\n\", (1));\n  test (2, 1, \"a\", (2));\n  test (3, 0, \"\", (3));\n  test (4, 5, \"%s\", (4, \"hello\"));\n  test (5, 6, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, \"%s\", (6, \"a\"));\n  test (7, 0, \"%s\", (7, \"\"));\n  test (8, 1, \"%c\", (8, 'x'));\n  test (9, 7, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__vfprintf_chk (FILE *f, int flag, const char *fmt, va_list ap)\n{\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  return vfprintf (f, fmt, ap);\n}\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, opt, fmt, args) \\\n    case n:\t\t\t\t\t\t\\\n      should_optimize = opt;\t\t\t\t\\\n      __vfprintf_chk (stdout, 1, fmt, ap);\t\t\\\n      if (! should_optimize)\t\t\t\t\\\n\tabort ();\t\t\t\t\t\\\n      should_optimize = 0;\t\t\t\t\\\n      if (__vfprintf_chk (stdout, 1, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\t\\\n      if (! should_optimize)\t\t\t\t\\\n\tabort ();\t\t\t\t\t\\\n      break;\n#include \"vfprintf-chk-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, opt, fmt, args) \\\n  inner args;\n#include \"vfprintf-chk-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, 1, \"hello\", (0));\n  test (1, 6, 1, \"hello\\n\", (1));\n  test (2, 1, 1, \"a\", (2));\n  test (3, 0, 1, \"\", (3));\n  test (4, 5, 0, \"%s\", (4, \"hello\"));\n  test (5, 6, 0, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, 0, \"%s\", (6, \"a\"));\n  test (7, 0, 0, \"%s\", (7, \"\"));\n  test (8, 1, 0, \"%c\", (8, 'x'));\n  test (9, 7, 0, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, 0, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vla-dealloc-1.c",
    "content": "/* VLAs should be deallocated on a jump to before their definition,\n   including a jump to a label in an inner scope.  PR 19771.  */\n/* { dg-require-effective-target alloca } */\n\n#if (__SIZEOF_INT__ <= 2)\n#define LIMIT 10000\n#else\n#define LIMIT 1000000\n#endif\n\nvoid *volatile p;\n\nint\nmain (void)\n{\n  int n = 0;\n  if (0)\n    {\n    lab:;\n    }\n  int x[n % 1000 + 1];\n  x[0] = 1;\n  x[n % 1000] = 2;\n  p = x;\n  n++;\n  if (n < LIMIT)\n    goto lab;\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, fmt, args) \\\n    case n:\t\t\t\t\\\n      vprintf (fmt, ap);\t\t\\\n      if (vprintf (fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\\\n      break;\n#include \"vprintf-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, fmt, args) \\\n  inner args;\n#include \"vprintf-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, \"hello\", (0));\n  test (1, 6, \"hello\\n\", (1));\n  test (2, 1, \"a\", (2));\n  test (3, 0, \"\", (3));\n  test (4, 5, \"%s\", (4, \"hello\"));\n  test (5, 6, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, \"%s\", (6, \"a\"));\n  test (7, 0, \"%s\", (7, \"\"));\n  test (8, 1, \"%c\", (8, 'x'));\n  test (9, 7, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c",
    "content": "/* { dg-skip-if \"requires io\" { freestanding } { \"*\" } { \"\" } }  */\n\n#ifndef test\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\nvolatile int should_optimize;\n\nint\n__attribute__((noinline))\n__vprintf_chk (int flag, const char *fmt, va_list ap)\n{\n#ifdef __OPTIMIZE__\n  if (should_optimize)\n    abort ();\n#endif\n  should_optimize = 1;\n  return vprintf (fmt, ap);\n}\n\nvoid\ninner (int x, ...)\n{\n  va_list ap, ap2;\n  va_start (ap, x);\n  va_start (ap2, x);\n\n  switch (x)\n    {\n#define test(n, ret, opt, fmt, args) \\\n    case n:\t\t\t\t\t\\\n      should_optimize = opt;\t\t\t\\\n      __vprintf_chk (1, fmt, ap);\t\t\\\n      if (! should_optimize)\t\t\t\\\n\tabort ();\t\t\t\t\\\n      should_optimize = 0;\t\t\t\\\n      if (__vprintf_chk (1, fmt, ap2) != ret)\t\\\n\tabort ();\t\t\t\t\\\n      if (! should_optimize)\t\t\t\\\n\tabort ();\t\t\t\t\\\n      break;\n#include \"vprintf-chk-1.c\"\n#undef test\n    default:\n      abort ();\n    }\n\n  va_end (ap);\n  va_end (ap2);\n}\n\nint\nmain (void)\n{\n#define test(n, ret, opt, fmt, args) \\\n  inner args;\n#include \"vprintf-chk-1.c\"\n#undef test\n  return 0;\n}\n\n#else\n  test (0, 5, 0, \"hello\", (0));\n  test (1, 6, 1, \"hello\\n\", (1));\n  test (2, 1, 1, \"a\", (2));\n  test (3, 0, 1, \"\", (3));\n  test (4, 5, 0, \"%s\", (4, \"hello\"));\n  test (5, 6, 0, \"%s\", (5, \"hello\\n\"));\n  test (6, 1, 0, \"%s\", (6, \"a\"));\n  test (7, 0, 0, \"%s\", (7, \"\"));\n  test (8, 1, 0, \"%c\", (8, 'x'));\n  test (9, 7, 0, \"%s\\n\", (9, \"hello\\n\"));\n  test (10, 2, 0, \"%d\\n\", (10, 0));\n#endif\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-1.c",
    "content": "\nextern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a != 2) {\n\t\ta = -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-2.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a != 2) {\n\t\ta = a > 0 ? a : -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-3.c",
    "content": "extern void abort ();\nextern void exit (int);\n\nint f (int a) {\n\tif (a < 12) {\n\t  if (a > -15) {\n\t\ta = a > 0 ? a : -a;\n\t\tif (a == 2)\n\t\t  return 0;\n\t\treturn 1;\n\t  }\n\t}\n\treturn 1;\n}\n\nint main (int argc, char *argv[]) {\n\tif (f (-2))\n\t\tabort ();\n\texit (0);\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-4.c",
    "content": "extern void exit (int);\nextern void abort ();\n\nvoid test(int x, int y)\n{\n\tint c;\n\n\tif (x == 1) abort();\n\tif (y == 1) abort();\n\n\tc = x / y;\n\n\tif (c != 1) abort();\n}\n\nint main()\n{\n\ttest(2, 2);\n\texit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-5.c",
    "content": "/* { dg-require-effective-target int32plus } */\nextern void exit (int);\nextern void abort ();\n\nvoid test(unsigned int a, unsigned int b)\n{\n  if (a < 5)\n    abort();\n  if (b < 5)\n    abort();\n  if (a + b != 0U)\n    abort();\n}\n\nint main(int argc, char *argv[])\n{\n  unsigned int x = 0x80000000;\n  test(x, x);\n  exit (0);\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-6.c",
    "content": "/* { dg-require-effective-target int32plus } */\n#include <limits.h>\n\nextern void exit (int);\nextern void abort ();\n\nvoid test01(unsigned int a, unsigned int b)\n{\n  if (a < 5)\n    abort();\n  if (b < 5)\n    abort();\n  if (a - b != 5)\n    abort();\n}\n\nvoid test02(unsigned int a, unsigned int b)\n{\n  if (a >= 12)\n    if (b > 15)\n      if (a - b < UINT_MAX - 15U)\n\tabort ();\n}\n\nint main(int argc, char *argv[])\n{\n  unsigned x = 0x80000000;\n  test01(x + 5, x);\n  test02(14, 16);\n  exit (0);\n}\n\n\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/vrp-7.c",
    "content": "\nvoid abort (void);\n\nstruct T\n{\n  int b : 1;\n} t;\n\nvoid __attribute__((noinline)) foo (int f)\n{\n  t.b = (f & 0x10) ? 1 : 0;\n}\n\nint main (void)\n{\n  foo (0x10);\n  if (!t.b)\n    abort ();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c",
    "content": "/* { dg-options \"-finput-charset=utf-8\" } */\ntypedef __WCHAR_TYPE__ wchar_t;\nwchar_t x[] = L\"Ä\";\nwchar_t y = L'Ä';\nextern void abort (void);\nextern void exit (int);\n\nint main (void)\n{\n  if (sizeof (x) / sizeof (wchar_t) != 2)\n    abort ();\n  if (x[0] != L'Ä' || x[1] != L'\\0')\n    abort ();\n  if (y != L'Ä')\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/widechar-1.c",
    "content": "#define C L'\\400'\n\n#if C\n#define zero (!C)\n#else\n#define zero C\n#endif\n\nmain()\n{\n  if (zero != 0)\n    abort ();\n  exit (0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/widechar-2.c",
    "content": "#include <stddef.h>\n\nconst wchar_t ws[] = L\"foo\";\n\nint\nmain (void)\n{\n  if (ws[0] != L'f' || ws[1] != L'o' || ws[2] != L'o' || ws[3] != L'\\0')\n    abort();\n  exit(0);\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/zero-struct-1.c",
    "content": "struct g{};\nchar y[3];\nchar *f = &y[0];\nchar *ff = &y[0];\nvoid h(void)\n{\n  struct g t;\n  *((struct g*)(f++)) = *((struct g*)(ff++));\n  *((struct g*)(f++)) = (struct g){};\n  t = *((struct g*)(ff++));\n}\n\nvoid abort (void);\n\nint main(void)\n{\n  h();\n  if (f != &y[2])\n    abort();\n  if (ff != &y[2])\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/zero-struct-2.c",
    "content": "void abort (void);\nint ii;\ntypedef struct {} raw_spinlock_t;\ntypedef struct {\n  raw_spinlock_t raw_lock;\n} spinlock_t;\nraw_spinlock_t one_raw_spinlock (void)\n{\n  raw_spinlock_t raw_lock;\n  ii++;\n  return raw_lock;\n}\nint main(void)\n{\n  spinlock_t lock = (spinlock_t) { .raw_lock = one_raw_spinlock() };\n  if (ii != 1)\n    abort ();\n  return 0;\n}\n\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/zerolen-1.c",
    "content": "extern void abort (void);\nextern void exit (int);\n\nunion iso_directory_record {\n   char carr[4];\n   struct {\n           unsigned char name_len [1];\n           char name [0];\n   } u;\n} entry;\n\nvoid set(union iso_directory_record *);\n\nint main (void)\n{\n   union iso_directory_record *de;\n\n   de = &entry;\n   set(de);\n\n   if (de->u.name_len[0] == 1 && de->u.name[0] == 0)\n     exit (0);\n   else\n     abort ();\n}\n\nvoid set (union iso_directory_record *p)\n{\n   p->carr[0] = 1;\n   p->carr[1] = 0;\n   return;\n}\n"
  },
  {
    "path": "v2/testdata/github.com/gcc-mirror/gcc/gcc/testsuite/gcc.c-torture/execute/zerolen-2.c",
    "content": "/* { dg-skip-if \"assumes absence of larger-than-word padding\" { epiphany-*-* } \"*\" \"\" } */\nextern void abort(void);\n\ntypedef int word __attribute__((mode(word)));\n\nstruct foo\n{\n  word x;\n  word y[0];\n};\n\nint main()\n{\n  if (sizeof(word) != sizeof(struct foo))\n    abort();\n  if (__alignof__(word) != __alignof__(struct foo))\n    abort();\n  return 0;\n}\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/COPYING",
    "content": "\t\t  GNU LESSER GENERAL PUBLIC LICENSE\n\t\t       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n[This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.]\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\f\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\f\n\t\t  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n  \n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\f\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\f\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\f\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\f\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\f\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\f\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the library's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random Hacker.\n\n  <signature of Ty Coon>, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n\n\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/README",
    "content": "Tiny C Compiler - C Scripting Everywhere - The Smallest ANSI C compiler\n-----------------------------------------------------------------------\n\nFeatures:\n--------\n\n- SMALL! You can compile and execute C code everywhere, for example on\n  rescue disks.\n\n- FAST! tcc generates optimized x86 code. No byte code\n  overhead. Compile, assemble and link about 7 times faster than 'gcc\n  -O0'.\n\n- UNLIMITED! Any C dynamic library can be used directly. TCC is\n  heading torward full ISOC99 compliance. TCC can of course compile\n  itself.\n\n- SAFE! tcc includes an optional memory and bound checker. Bound\n  checked code can be mixed freely with standard code.\n\n- Compile and execute C source directly. No linking or assembly\n  necessary. Full C preprocessor included. \n\n- C script supported : just add '#!/usr/local/bin/tcc -run' at the first\n  line of your C source, and execute it directly from the command\n  line.\n\nDocumentation:\n-------------\n\n1) Installation on a i386 Linux host (for Windows read tcc-win32.txt)\n\n   ./configure\n   make\n   make test\n   make install\n\nAlternatively, out-of-tree builds are supported: you may use different\ndirectories to hold build objects, kept separate from your source tree:\n\n   mkdir _build\n   cd _build\n   ../configure\n   make\n   make test\n   make install\n\nBy default, tcc is installed in /usr/local/bin.\n./configure --help  shows configuration options.\n\n\n2) Introduction\n\nWe assume here that you know ANSI C. Look at the example ex1.c to know\nwhat the programs look like.\n\nThe include file <tcclib.h> can be used if you want a small basic libc\ninclude support (especially useful for floppy disks). Of course, you\ncan also use standard headers, although they are slower to compile.\n\nYou can begin your C script with '#!/usr/local/bin/tcc -run' on the first\nline and set its execute bits (chmod a+x your_script). Then, you can\nlaunch the C code as a shell or perl script :-) The command line\narguments are put in 'argc' and 'argv' of the main functions, as in\nANSI C.\n\n3) Examples\n\nex1.c: simplest example (hello world). Can also be launched directly\nas a script: './ex1.c'.\n\nex2.c: more complicated example: find a number with the four\noperations given a list of numbers (benchmark).\n\nex3.c: compute fibonacci numbers (benchmark).\n\nex4.c: more complicated: X11 program. Very complicated test in fact\nbecause standard headers are being used ! As for ex1.c, can also be launched\ndirectly as a script: './ex4.c'.\n\nex5.c: 'hello world' with standard glibc headers.\n\ntcc.c: TCC can of course compile itself. Used to check the code\ngenerator.\n\ntcctest.c: auto test for TCC which tests many subtle possible bugs. Used\nwhen doing 'make test'.\n\n4) Full Documentation\n\nPlease read tcc-doc.html to have all the features of TCC.\n\nAdditional information is available for the Windows port in tcc-win32.txt.\n\nLicense:\n-------\n\nTCC is distributed under the GNU Lesser General Public License (see\nCOPYING file).\n\nFabrice Bellard.\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/VERSION",
    "content": "0.9.26\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/Makefile",
    "content": "#\n# Tiny C Compiler Makefile - tests\n#\n\nTOP = ..\ninclude $(TOP)/Makefile\nVPATH = $(top_srcdir)/tests\n\n# what tests to run\nTESTS = \\\n hello-exe \\\n hello-run \\\n libtest \\\n test3 \\\n moretests\n\n# test4 -- problem with -static\n# asmtest -- minor differences with gcc\n# btest -- works on i386 (including win32)\n# test3 -- win32 does not know how to printf long doubles\n\n# bounds-checking is supported only on i386\nifneq ($(ARCH),i386)\n TESTS := $(filter-out btest,$(TESTS))\nendif\nifdef CONFIG_WIN32\n TESTS := $(filter-out test3,$(TESTS))\nendif\nifeq ($(TARGETOS),Darwin)\n TESTS := $(filter-out hello-exe test3 btest,$(TESTS))\nendif\n\nifdef DISABLE_STATIC\n export LD_LIBRARY_PATH:=$(CURDIR)/..\nendif\n\nifeq ($(TARGETOS),Darwin)\n CFLAGS+=-Wl,-flat_namespace,-undefined,warning\n export MACOSX_DEPLOYMENT_TARGET:=10.2\n NATIVE_DEFINES+=-D_ANSI_SOURCE\nendif\n\n# run local version of tcc with local libraries and includes\nTCCFLAGS = -B$(TOP)\nifdef CONFIG_WIN32\n TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)\nendif\n\nTCC = $(TOP)/tcc $(TCCFLAGS)\nRUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS)\n\nDISAS = objdump -d\n\n# libtcc test\nifdef LIBTCC1\n LIBTCC1:=$(TOP)/$(LIBTCC1)\nendif\n\nall test : $(TESTS)\n\nhello-exe: ../examples/ex1.c\n\t@echo ------------ $@ ------------\n\t$(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)\n\nhello-run: ../examples/ex1.c\n\t@echo ------------ $@ ------------\n\t$(TCC) -run $<\n\nlibtest: libtcc_test$(EXESUF) $(LIBTCC1)\n\t@echo ------------ $@ ------------\n\t./libtcc_test$(EXESUF) lib_path=..\n\nlibtcc_test$(EXESUF): libtcc_test.c $(top_builddir)/$(LIBTCC)\n\t$(CC) -o $@ $^ $(CPPFLAGS) $(CFLAGS) $(NATIVE_DEFINES) $(LIBS) $(LINK_LIBTCC) $(LDFLAGS)\n\nmoretests:\n\t@echo ------------ $@ ------------\n\t$(MAKE) -C tests2\n\n# test.ref - generate using gcc\n# copy only tcclib.h so GCC's stddef and stdarg will be used\ntest.ref: tcctest.c\n\tcp ../include/tcclib.h .\n\tgcc -o tcctest.gcc $< -I. $(CPPFLAGS) -w $(CFLAGS) $(NATIVE_DEFINES) -std=gnu99 -O0 -fno-omit-frame-pointer $(LDFLAGS)\n\t./tcctest.gcc > $@\n\n# auto test\ntest1: test.ref\n\t@echo ------------ $@ ------------\n\t$(TCC) -run tcctest.c > test.out1\n\t@if diff -u test.ref test.out1 ; then echo \"Auto Test OK\"; fi\n\n# iterated test2 (compile tcc then compile tcctest.c !)\ntest2: test.ref\n\t@echo ------------ $@ ------------\n\t$(TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out2\n\t@if diff -u test.ref test.out2 ; then echo \"Auto Test2 OK\"; fi\n\n# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)\ntest3: test.ref\n\t@echo ------------ $@ ------------\n\t$(TCC) $(RUN_TCC) $(RUN_TCC) $(RUN_TCC) -run tcctest.c > test.out3\n\t@if diff -u test.ref test.out3 ; then echo \"Auto Test3 OK\"; fi\n\n# binary output test\ntest4: test.ref\n\t@echo ------------ $@ ------------\n# object + link output\n\t$(TCC) -c -o tcctest3.o tcctest.c\n\t$(TCC) -o tcctest3 tcctest3.o\n\t./tcctest3 > test3.out\n\t@if diff -u test.ref test3.out ; then echo \"Object Auto Test OK\"; fi\n# dynamic output\n\t$(TCC) -o tcctest1 tcctest.c\n\t./tcctest1 > test1.out\n\t@if diff -u test.ref test1.out ; then echo \"Dynamic Auto Test OK\"; fi\n# dynamic output + bound check\n\t$(TCC) -b -o tcctest4 tcctest.c\n\t./tcctest4 > test4.out\n\t@if diff -u test.ref test4.out ; then echo \"BCheck Auto Test OK\"; fi\n# static output\n\t$(TCC) -static -o tcctest2 tcctest.c\n\t./tcctest2 > test2.out\n\t@if diff -u test.ref test2.out ; then echo \"Static Auto Test OK\"; fi\n\n# memory and bound check auto test\nBOUNDS_OK  = 1 4 8 10 14\nBOUNDS_FAIL= 2 5 7 9 11 12 13 15\n\nbtest: boundtest.c\n\t@echo ------------ $@ ------------\n\t@for i in $(BOUNDS_OK); do \\\n\t   echo ; echo --- boundtest $$i ---; \\\n\t   if $(TCC) -b -run boundtest.c $$i ; then \\\n\t       echo succeded as expected; \\\n\t   else\\\n\t       echo Failed positive test $$i ; exit 1 ; \\\n\t   fi ;\\\n\tdone ;\\\n\tfor i in $(BOUNDS_FAIL); do \\\n\t   echo ; echo --- boundtest $$i ---; \\\n\t   if $(TCC) -b -run boundtest.c $$i ; then \\\n\t       echo Failed negative test $$i ; exit 1 ;\\\n\t   else\\\n\t       echo failed as expected; \\\n\t   fi ;\\\n\tdone ;\\\n\techo; echo Bound test OK\n\n# speed test\nspeedtest: ex2 ex3\n\t@echo ------------ $@ ------------\n\ttime ./ex2 1238 2 3 4 10 13 4\n\ttime $(TCC) -run $(top_srcdir)/examples/ex2.c 1238 2 3 4 10 13 4\n\ttime ./ex3 35\n\ttime $(TCC) -run $(top_srcdir)/examples/ex3.c 35\n\nweaktest: test.ref\n\t$(TCC) -c tcctest.c -o weaktest.tcc.o $(CPPFLAGS) $(CFLAGS)\n\t $(CC) -c tcctest.c -o weaktest.gcc.o -I. $(CPPFLAGS) -w $(CFLAGS)\n\tobjdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \\([a-zA-Z0-9_]*\\)$$/\\1/' | LC_ALL=C sort > weaktest.tcc.o.txt\n\tobjdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \\([a-zA-Z0-9_]*\\)$$/\\1/' | LC_ALL=C sort > weaktest.gcc.o.txt\n\tdiff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo \"Weak Auto Test OK\"\n\nex%: $(top_srcdir)/examples/ex%.c\n\t$(CC) -o $@ $< $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)\n\n# tiny assembler testing\nasmtest.ref: asmtest.S\n\t$(CC) -Wa,-W -o asmtest.ref.o -c asmtest.S\n\tobjdump -D asmtest.ref.o > asmtest.ref\n\nasmtest: asmtest.ref\n\t@echo ------------ $@ ------------\n\t$(TCC) -c asmtest.S\n\tobjdump -D asmtest.o > asmtest.out\n\t@if diff -u --ignore-matching-lines=\"file format\" asmtest.ref asmtest.out ; then echo \"ASM Auto Test OK\"; fi\n\n# targets for development\n%.bin: %.c tcc\n\t$(TCC) -g -o $@ $<\n\t$(DISAS) $@\n\ninstr: instr.o\n\tobjdump -d instr.o\n\ninstr.o: instr.S\n\t$(CC) -o $@ -c $< -O2 -Wall -g\n\ncache: tcc_g\n\tcachegrind ./tcc_g -o /tmp/linpack -lm bench/linpack.c\n\tvg_annotate tcc.c > /tmp/linpack.cache.log\n\n# clean\nclean:\n\t$(MAKE) -C tests2 $@\n\trm -vf *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.gcc *.exe \\\n\t   hello libtcc_test tcctest[1234] ex? tcc_g tcclib.h\n\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/asmtest.S",
    "content": "# gas comment with ``gnu'' style quotes\n\n/* some directive tests */\n\n   .byte 0xff\n   .byte 1, 2, 3\n   .short 1, 2, 3\n   .word 1, 2, 3\n   .long 1, 2, 3\n   .int 1, 2, 3\n   .align 8\n   .byte 1\n/* .align 16, 0x90 gas is too clever for us with 0x90 fill */\n   .align 16, 0x91 /* 0x91 tests the non-clever behaviour */\n   .skip 3\n   .skip 15, 0x90\n   .string \"hello\\0world\"\n\n/* some label tests */\n\n        movl %eax, %ebx\nL1:\n        movl %eax, %ebx\n        mov 0x10000, %eax\nL2:\n        movl $L2 - L1, %ecx\nvar1:\n        nop ; nop ; nop ; nop\n\n        mov var1, %eax\n\n/* instruction tests */\nmovl %eax, %ebx\nmov 0x10000, %eax\nmov 0x10000, %ax\nmov 0x10000, %al\nmov %al, 0x10000\n                \nmov $1, %edx\nmov $1, %dx\nmov $1, %dl\nmovb $2, 0x100(%ebx,%edx,2)\nmovw $2, 0x100(%ebx,%edx,2)\nmovl $2, 0x100(%ebx,%edx,2)\nmovl %eax, 0x100(%ebx,%edx,2)\nmovl 0x100(%ebx,%edx,2), %edx\nmovw %ax, 0x100(%ebx,%edx,2)\n\nmov %eax, 0x12(,%edx,2)\n        \nmov %cr3, %edx\nmov %ecx, %cr3\nmovl %cr3, %eax\nmovl %tr3, %eax\nmovl %db3, %ebx\nmovl %dr6, %eax\nmovl %fs, %ecx\nmovl %ebx, %fs\n\n     movsbl 0x1000, %eax\n     movsbw 0x1000, %ax\n     movswl 0x1000, %eax\n\n     movzbl 0x1000, %eax\n     movzbw 0x1000, %ax\n     movzwl 0x1000, %eax\n            \n     movzb 0x1000, %eax\n     movzb 0x1000, %ax\n                \n        \n  pushl %eax\n  pushw %ax\n  push %eax\n  push %cs\n  push %gs\n  push $1\n  push $100\n                                                \n  popl %eax\n  popw %ax\n  pop %eax\n  pop %ds\n  pop %fs\n          \n  xchg %eax, %ecx\n  xchg %edx, %eax\n  xchg %bx, 0x10000\n  xchg 0x10000, %ebx\n  xchg 0x10000, %dl\n\n  in $100, %al               \n  in $100, %ax               \n  in $100, %eax\n  in %dx, %al\n  in %dx, %ax               \n  in %dx, %eax\n  inb %dx\n  inw %dx               \n  inl %dx\n\n  out %al, $100                       \n  out %ax, $100                       \n  out %eax, $100                       \n\n  /* NOTE: gas is bugged here, so size must be added */\n  outb %al, %dx                       \n  outw %ax, %dx                       \n  outl %eax, %dx                       \n\n  leal 0x1000(%ebx), %ecx\n  lea 0x1000(%ebx), %ecx\n\n  les 0x2000, %eax\n  lds 0x2000, %ebx\n  lfs 0x2000, %ecx\n  lgs 0x2000, %edx\n  lss 0x2000, %edx\n\naddl $0x123, %eax\nadd $0x123, %ebx\naddl $0x123, 0x100\naddl $0x123, 0x100(%ebx)\naddl $0x123, 0x100(%ebx,%edx,2)\naddl $0x123, 0x100(%esp)\naddl $0x123, (3*8)(%esp)\naddl $0x123, (%ebp)\naddl $0x123, (%esp)\ncmpl $0x123, (%esp)\n\nadd %eax, (%ebx)\nadd (%ebx), %eax\n                \nor %dx, (%ebx)\nor (%ebx), %si\n        \nadd %cl, (%ebx)\nadd (%ebx), %dl\n\n    inc %edx\n    incl 0x10000\n    incb 0x10000\n    dec %dx\n  \n  test $1, %al\n  test $1, %cl\n\n  testl $1, 0x1000\n  testb $1, 0x1000\n  testw $1, 0x1000\n  test %eax, %ebx\n  test %eax, 0x1000\n  test 0x1000, %edx\n\n    not %edx\n    notw 0x10000\n    notl 0x10000\n    notb 0x10000\n\n    neg %edx\n    negw 0x10000\n    negl 0x10000\n    negb 0x10000\n\n    imul %ecx\n    mul %edx\n    mulb %cl\n\n    imul %eax, %ecx\n    imul 0x1000, %cx\n    imul $10, %eax, %ecx\n    imul $10, %ax, %cx\n    imul $10, %eax\n    imul $0x1100000, %eax\n    imul $1, %eax\n    \n    idivw 0x1000\n    div %ecx\n    div %bl\n    div %ecx, %eax\n\n\nshl %edx\nshl $10, %edx\nshl %cl, %edx\n\nshld $1, %eax, %edx\nshld %cl, %eax, %edx\nshld %eax, %edx\n\nshrd $1, %eax, %edx\nshrd %cl, %eax, %edx\nshrd %eax, %edx\n\nL4:\ncall 0x1000\ncall L4\ncall *%eax\ncall *0x1000\ncall func1\n\n.global L5,L6\n\nL5:\nL6:\n\nlcall $0x100, $0x1000\n\njmp 0x1000\njmp *%eax\njmp *0x1000\n\nljmp $0x100, $0x1000\n\nret\nretl\n\nret $10\nretl $10\n\nlret\n\nlret $10\n\nenter $1234, $10\n\nL3:\n jo 0x1000\n jnp 0x1001\n jne 0x1002\n jg 0x1003\n\n jo L3\n jnp L3\n jne L3\n jg L3\n\n loopne L3\n loopnz L3\n loope L3\n loopz L3\n loop L3\n jecxz L3\n\n        \n seto %al\n setnp 0x1000\n setl 0xaaaa\n setg %dl\n\n fadd\n fadd %st(1), %st\n fadd %st(0), %st(1)\n fadd %st(3)\n\n fmul %st(0),%st(0)\n fmul %st(0),%st(1)\n\n faddp %st(5)\n faddp\n faddp %st(1), %st\n\n fadds 0x1000\n fiadds 0x1002\n faddl 0x1004\n fiaddl 0x1006\n\n fmul\n fmul %st(1), %st\n fmul %st(3)\n\n fmulp %st(5)\n fmulp\n fmulp %st(1), %st\n\n fmuls 0x1000\n fimuls 0x1002\n fmull 0x1004\n fimull 0x1006\n\n fsub\n fsub %st(1), %st\n fsub %st(3)\n\n fsubp %st(5)\n fsubp\n fsubp %st(1), %st\n\n fsubs 0x1000\n fisubs 0x1002\n fsubl 0x1004\n fisubl 0x1006\n\n fsubr\n fsubr %st(1), %st\n fsubr %st(3)\n\n fsubrp %st(5)\n fsubrp\n fsubrp %st(1), %st\n\n fsubrs 0x1000\n fisubrs 0x1002\n fsubrl 0x1004\n fisubrl 0x1006\n\n fdiv\n fdiv %st(1), %st\n fdiv %st(3)\n\n fdivp %st(5)\n fdivp\n fdivp %st(1), %st\n\n fdivs 0x1000\n fidivs 0x1002\n fdivl 0x1004\n fidivl 0x1006\n\n fcom %st(3)\n\n fcoms 0x1000\n ficoms 0x1002\n fcoml 0x1004\n ficoml 0x1006\n\n fcomp %st(5)\n fcomp\n fcompp\n\n fcomps 0x1000\n ficomps 0x1002\n fcompl 0x1004\n ficompl 0x1006\n\n fld %st(5)\n fldl 0x1000\n flds 0x1002\n fildl 0x1004\n fst %st(4)\n fstp %st(6)\n fstpt 0x1006\n fbstp 0x1008\n\n fxch\n fxch %st(4)\n\n fucom %st(6)\n fucomp %st(3)\n fucompp\n\n finit\n fninit\n fldcw 0x1000\n fnstcw 0x1002\n fstcw 0x1002\n fnstsw 0x1004\n fnstsw (%eax)\n fstsw 0x1004\n fstsw (%eax)\n fnclex\n fclex\n fnstenv 0x1000\n fstenv 0x1000\n fldenv 0x1000\n fnsave 0x1002\n fsave 0x1000\n frstor 0x1000\n ffree %st(7)\n ffreep %st(6)\n \n    ftst\n    fxam\n    fld1\n    fldl2t\n    fldl2e\n    fldpi\n    fldlg2\n    fldln2\n    fldz\n\n    f2xm1\n    fyl2x\n    fptan\n    fpatan\n    fxtract\n    fprem1\n    fdecstp\n    fincstp\n    fprem\n    fyl2xp1\n    fsqrt\n    fsincos\n    frndint\n    fscale\n    fsin\n    fcos\n    fchs\n    fabs\n    fnop\n    fwait\n\nbswap %edx\nxadd %ecx, %edx\nxaddb %dl, 0x1000\nxaddw %ax, 0x1000\nxaddl %eax, 0x1000\ncmpxchg %ecx, %edx\ncmpxchgb %dl, 0x1000\ncmpxchgw %ax, 0x1000\ncmpxchgl %eax, 0x1000\ninvlpg 0x1000\ncmpxchg8b 0x1002\n\nfcmovb %st(5), %st\nfcmove %st(5), %st\nfcmovbe %st(5), %st\nfcmovu %st(5), %st\nfcmovnb %st(5), %st\nfcmovne %st(5), %st\nfcmovnbe %st(5), %st\nfcmovnu %st(5), %st\nfcomi %st(5), %st\nfucomi %st(5), %st\nfcomip %st(5), %st\nfucomip %st(5), %st\n\n\n\n cmovo 0x1000, %eax\n cmovs 0x1000, %eax\n cmovns %edx, %edi\n\nint $3\nint $0x10\n\n    pusha\n    popa\n    clc\n    cld\n    cli\n    clts\n    cmc\n    lahf\n    sahf\n    pushfl\n    popfl\n    pushf\n    popf\n    stc\n    std\n    sti\n    aaa\n    aas\n    daa\n    das\n    aad\n    aam\n    cbw\n    cwd\n    cwde\n    cdq\n    cbtw\n    cwtd\n    cwtl\n    cltd\n    leave\n    int3\n    into\n    iret\n    rsm\n    hlt\n    wait\n    nop\n\n    /* XXX: handle prefixes */\n#if 0\n    aword\n    addr16\n#endif\n    lock\n    rep\n    repe\n    repz\n    repne\n    repnz\n    nop\n\n    lock ;negl (%eax)\n    wait ;pushf\n    rep  ;stosb\n    repe ;lodsb\n    repz ;cmpsb\n    repne;movsb\n    repnz;outsb\n\n    /* handle one-line prefix + ops */\n    lock  negl (%eax)\n    wait  pushf\n    rep   stosb\n    repe  lodsb\n    repz  cmpsb\n    repne movsb\n    repnz outsb\n    \n    invd\n    wbinvd\n    cpuid\n    wrmsr\n    rdtsc\n    rdmsr\n    rdpmc\n    ud2\n\n    emms\n    movd %edx, %mm3\n    movd 0x1000, %mm2\n    movd %mm4, %ecx\n    movd %mm5, 0x1000\n                    \n    movq 0x1000, %mm2\n    movq %mm4, 0x1000\n    \n    pand 0x1000, %mm3\n    pand %mm4, %mm5\n    \n    psllw $1, %mm6\n    psllw 0x1000, %mm7\n    psllw %mm2, %mm7\n\n    xlat\n    cmpsb\n    scmpw\n    insl\n    outsw\n    lodsb\n    slodl\n    movsb\n    movsl\n    smovb\n    scasb\n    sscaw\n    stosw\n    sstol\n\n    bsf 0x1000, %ebx\n    bsr 0x1000, %ebx\n    bt %edx, 0x1000\n    btl $2, 0x1000\n    btc %edx, 0x1000\n    btcl $2, 0x1000\n    btr %edx, 0x1000\n    btrl $2, 0x1000\n    bts %edx, 0x1000\n    btsl $2, 0x1000\n\n        \n        \n    boundl %edx, 0x10000\n    boundw %bx, 0x1000\n    \n    arpl %bx, 0x1000\n    lar 0x1000, %eax\n    lgdt 0x1000\n    lidt 0x1000\n    lldt 0x1000\n    lmsw 0x1000\n    lsl 0x1000, %ecx\n    ltr 0x1000\n    \n    sgdt 0x1000\n    sidt 0x1000\n    sldt 0x1000\n    smsw 0x1000\n    str 0x1000\n    \n    verr 0x1000\n    verw 0x1000\n  \n    push %ds\n    pushw %ds\n    pushl %ds\n    pop %ds\n    popw %ds\n    popl %ds\n    fxsave 1(%ebx)\n    fxrstor 1(%ecx)\n    pushl $1\n    pushw $1\n    push $1\n\n#ifdef __ASSEMBLER__ // should be defined, for S files\n    inc %eax\n#endif\n\nft1: ft2: ft3: ft4: ft5: ft6: ft7: ft8: ft9:\n    xor %eax, %eax\n    ret\n\n.type ft1,STT_FUNC\n.type ft2,@STT_FUNC\n.type ft3,%STT_FUNC\n.type ft4,\"STT_FUNC\"\n.type ft5,function\n.type ft6,@function\n.type ft7,%function\n.type ft8,\"function\"\n\n    pause\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/boundtest.c",
    "content": "#include <stdlib.h>\n#include <stdio.h>\n\n#define NB_ITS 1000000\n//#define NB_ITS 1\n#define TAB_SIZE 100\n\nint tab[TAB_SIZE];\nint ret_sum;\nchar tab3[256];\n\nint test1(void)\n{\n    int i, sum = 0;\n    for(i=0;i<TAB_SIZE;i++) {\n        sum += tab[i];\n    }\n    return sum;\n}\n\n/* error */\nint test2(void)\n{\n    int i, sum = 0;\n    for(i=0;i<TAB_SIZE + 1;i++) {\n        sum += tab[i];\n    }\n    return sum;\n}\n\n/* actually, profiling test */\nint test3(void)\n{\n    int sum;\n    int i, it;\n\n    sum = 0;\n    for(it=0;it<NB_ITS;it++) {\n        for(i=0;i<TAB_SIZE;i++) {\n            sum += tab[i];\n        }\n    }\n    return sum;\n}\n\n/* ok */\nint test4(void)\n{\n    int i, sum = 0;\n    int *tab4;\n\n    tab4 = malloc(20 * sizeof(int));\n    for(i=0;i<20;i++) {\n        sum += tab4[i];\n    }\n    free(tab4);\n\n    return sum;\n}\n\n/* error */\nint test5(void)\n{\n    int i, sum = 0;\n    int *tab4;\n\n    tab4 = malloc(20 * sizeof(int));\n    for(i=0;i<21;i++) {\n        sum += tab4[i];\n    }\n    free(tab4);\n\n    return sum;\n}\n\n/* error */\n/* XXX: currently: bug */\nint test6(void)\n{\n    int i, sum = 0;\n    int *tab4;\n    \n    tab4 = malloc(20 * sizeof(int));\n    free(tab4);\n    for(i=0;i<21;i++) {\n        sum += tab4[i];\n    }\n\n    return sum;\n}\n\n/* error */\nint test7(void)\n{\n    int i, sum = 0;\n    int *p;\n\n    for(i=0;i<TAB_SIZE + 1;i++) {\n        p = &tab[i];\n        if (i == TAB_SIZE)\n            printf(\"i=%d %x\\n\", i, p);\n        sum += *p;\n    }\n    return sum;\n}\n\n/* ok */\nint test8(void)\n{\n    int i, sum = 0;\n    int tab[10];\n\n    for(i=0;i<10;i++) {\n        sum += tab[i];\n    }\n    return sum;\n}\n\n/* error */\nint test9(void)\n{\n    int i, sum = 0;\n    char tab[10];\n\n    for(i=0;i<11;i++) {\n        sum += tab[i];\n    }\n    return sum;\n}\n\n/* ok */\nint test10(void)\n{\n    char tab[10];\n    char tab1[10];\n\n    memset(tab, 0, 10);\n    memcpy(tab, tab1, 10);\n    memmove(tab, tab1, 10);\n    return 0;\n}\n\n/* error */\nint test11(void)\n{\n    char tab[10];\n\n    memset(tab, 0, 11);\n    return 0;\n}\n\n/* error */\nint test12(void)\n{\n    void *ptr;\n    ptr = malloc(10);\n    free(ptr);\n    free(ptr);\n    return 0;\n}\n\n/* error */\nint test13(void)\n{\n    char pad1 = 0;\n    char tab[10];\n    char pad2 = 0;\n    memset(tab, 'a', sizeof(tab));\n    return strlen(tab);\n}\n\nint test14(void)\n{\n    char *p = alloca(TAB_SIZE);\n    memset(p, 'a', TAB_SIZE);\n    p[TAB_SIZE-1] = 0;\n    return strlen(p);\n}\n\n/* error */\nint test15(void)\n{\n    char *p = alloca(TAB_SIZE-1);\n    memset(p, 'a', TAB_SIZE);\n    p[TAB_SIZE-1] = 0;\n    return strlen(p);\n}\n\nint (*table_test[])(void) = {\n    test1,\n    test1,\n    test2,\n    test3,\n    test4,\n    test5,\n    test6,\n    test7,\n    test8,\n    test9,\n    test10,\n    test11,\n    test12,\n    test13,\n    test14,\n    test15,\n};\n\nint main(int argc, char **argv)\n{\n    int index;\n    int (*ftest)(void);\n\n    if (argc < 2) {\n        printf(\"usage: boundtest n\\n\"\n               \"test TCC bound checking system\\n\"\n               );\n        exit(1);\n    }\n\n    index = 0;\n    if (argc >= 2)\n        index = atoi(argv[1]);\n    /* well, we also use bounds on this ! */\n    ftest = table_test[index];\n    ftest();\n\n    return 0;\n}\n\n/*\n * without bound   0.77 s\n * with bounds    4.73\n */  \n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/gcctestsuite.sh",
    "content": "#!/bin/sh\n\nTESTSUITE_PATH=$HOME/gcc/gcc-3.2/gcc/testsuite/gcc.c-torture\nTCC=\"./tcc -B. -I. -DNO_TRAMPOLINES\" \nrm -f tcc.sum tcc.log\nnb_failed=\"0\"\n\nfor src in $TESTSUITE_PATH/compile/*.c ; do\n  echo $TCC -o /tmp/test.o -c $src \n  $TCC -o /tmp/test.o -c $src >> tcc.log 2>&1\n  if [ \"$?\" = \"0\" ] ; then\n     result=\"PASS\"\n  else\n     result=\"FAIL\"\n     nb_failed=$(( $nb_failed + 1 ))\n  fi\n  echo \"$result: $src\"  >> tcc.sum\ndone\n\nfor src in $TESTSUITE_PATH/execute/*.c ; do\n  echo $TCC $src \n  $TCC $src >> tcc.log 2>&1\n  if [ \"$?\" = \"0\" ] ; then\n     result=\"PASS\"\n  else\n     result=\"FAIL\"\n     nb_failed=$(( $nb_failed + 1 ))\n  fi\n  echo \"$result: $src\"  >> tcc.sum\ndone\n\necho \"$nb_failed test(s) failed.\" >> tcc.sum\necho \"$nb_failed test(s) failed.\"\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/libtcc_test.c",
    "content": "/*\n * Simple Test program for libtcc\n *\n * libtcc can be useful to use tcc as a \"backend\" for a code generator.\n */\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#include \"libtcc.h\"\n\n/* this function is called by the generated code */\nint add(int a, int b)\n{\n    return a + b;\n}\n\nchar my_program[] =\n\"int fib(int n)\\n\"\n\"{\\n\"\n\"    if (n <= 2)\\n\"\n\"        return 1;\\n\"\n\"    else\\n\"\n\"        return fib(n-1) + fib(n-2);\\n\"\n\"}\\n\"\n\"\\n\"\n\"int foo(int n)\\n\"\n\"{\\n\"\n\"    printf(\\\"Hello World!\\\\n\\\");\\n\"\n\"    printf(\\\"fib(%d) = %d\\\\n\\\", n, fib(n));\\n\"\n\"    printf(\\\"add(%d, %d) = %d\\\\n\\\", n, 2 * n, add(n, 2 * n));\\n\"\n\"    return 0;\\n\"\n\"}\\n\";\n\nint main(int argc, char **argv)\n{\n    TCCState *s;\n    int (*func)(int);\n\n    s = tcc_new();\n    if (!s) {\n        fprintf(stderr, \"Could not create tcc state\\n\");\n        exit(1);\n    }\n\n    /* if tcclib.h and libtcc1.a are not installed, where can we find them */\n    if (argc == 2 && !memcmp(argv[1], \"lib_path=\",9))\n        tcc_set_lib_path(s, argv[1]+9);\n\n    /* MUST BE CALLED before any compilation */\n    tcc_set_output_type(s, TCC_OUTPUT_MEMORY);\n\n    if (tcc_compile_string(s, my_program) == -1)\n        return 1;\n\n    /* as a test, we add a symbol that the compiled program can use.\n       You may also open a dll with tcc_add_dll() and use symbols from that */\n    tcc_add_symbol(s, \"add\", add);\n\n    /* relocate the code */\n    if (tcc_relocate(s, TCC_RELOCATE_AUTO) < 0)\n        return 1;\n\n    /* get entry symbol */\n    func = tcc_get_symbol(s, \"foo\");\n    if (!func)\n        return 1;\n\n    /* run the code */\n    func(32);\n\n    /* delete the state */\n    tcc_delete(s);\n\n    return 0;\n}\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tcclib.h",
    "content": "/* Simple libc header for TCC \n * \n * Add any function you want from the libc there. This file is here\n * only for your convenience so that you do not need to put the whole\n * glibc include files on your floppy disk \n */\n#ifndef _TCCLIB_H\n#define _TCCLIB_H\n\n#include <stddef.h>\n#include <stdarg.h>\n\n/* stdlib.h */\nvoid *calloc(size_t nmemb, size_t size);\nvoid *malloc(size_t size);\nvoid free(void *ptr);\nvoid *realloc(void *ptr, size_t size);\nint atoi(const char *nptr);\nlong int strtol(const char *nptr, char **endptr, int base);\nunsigned long int strtoul(const char *nptr, char **endptr, int base);\nvoid exit(int);\n\n/* stdio.h */\ntypedef struct __FILE FILE;\n#define EOF (-1)\nextern FILE *stdin;\nextern FILE *stdout;\nextern FILE *stderr;\nFILE *fopen(const char *path, const char *mode);\nFILE *fdopen(int fildes, const char *mode);\nFILE *freopen(const  char *path, const char *mode, FILE *stream);\nint fclose(FILE *stream);\nsize_t  fread(void *ptr, size_t size, size_t nmemb, FILE *stream);\nsize_t  fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream);\nint fgetc(FILE *stream);\nchar *fgets(char *s, int size, FILE *stream);\nint getc(FILE *stream);\nint getchar(void);\nchar *gets(char *s);\nint ungetc(int c, FILE *stream);\nint fflush(FILE *stream);\n\nint printf(const char *format, ...);\nint fprintf(FILE *stream, const char *format, ...);\nint sprintf(char *str, const char *format, ...);\nint snprintf(char *str, size_t size, const  char  *format, ...);\nint asprintf(char **strp, const char *format, ...);\nint dprintf(int fd, const char *format, ...);\nint vprintf(const char *format, va_list ap);\nint vfprintf(FILE  *stream,  const  char *format, va_list ap);\nint vsprintf(char *str, const char *format, va_list ap);\nint vsnprintf(char *str, size_t size, const char  *format, va_list ap);\nint vasprintf(char  **strp,  const  char *format, va_list ap);\nint vdprintf(int fd, const char *format, va_list ap);\n\nvoid perror(const char *s);\n\n/* string.h */\nchar *strcat(char *dest, const char *src);\nchar *strchr(const char *s, int c);\nchar *strrchr(const char *s, int c);\nchar *strcpy(char *dest, const char *src);\nvoid *memcpy(void *dest, const void *src, size_t n);\nvoid *memmove(void *dest, const void *src, size_t n);\nvoid *memset(void *s, int c, size_t n);\nchar *strdup(const char *s);\n\n/* dlfcn.h */\n#define RTLD_LAZY       0x001\n#define RTLD_NOW        0x002\n#define RTLD_GLOBAL     0x100\n\nvoid *dlopen(const char *filename, int flag);\nconst char *dlerror(void);\nvoid *dlsym(void *handle, char *symbol);\nint dlclose(void *handle);\n\n#endif /* _TCCLIB_H */\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tcctest.c",
    "content": "/*\n * TCC auto test program\n */\n#include \"../config.h\"\n\n#if GCC_MAJOR >= 3\n\n/* Unfortunately, gcc version < 3 does not handle that! */\n#define ALL_ISOC99\n\n/* only gcc 3 handles _Bool correctly */\n#define BOOL_ISOC99\n\n/* gcc 2.95.3 does not handle correctly CR in strings or after strays */\n#define CORRECT_CR_HANDLING\n\n#endif\n\n/* deprecated and no longer supported in gcc 3.3 */\n//#define ACCEPT_CR_IN_STRINGS\n\n/* __VA_ARGS__ and __func__ support */\n#define C99_MACROS\n\n/* test various include syntaxes */\n\n#define TCCLIB_INC <tcclib.h>\n#define TCCLIB_INC1 <tcclib\n#define TCCLIB_INC2 h>\n#define TCCLIB_INC3 \"tcclib\"\n\n#include TCCLIB_INC\n\n#include TCCLIB_INC1.TCCLIB_INC2\n\n#include TCCLIB_INC1.h>\n\n/* gcc 3.2 does not accept that (bug ?) */\n//#include TCCLIB_INC3 \".h\"\n\n#include <tcclib.h>\n\n#include \"tcclib.h\"\n\nvoid string_test();\nvoid expr_test();\nvoid macro_test();\nvoid recursive_macro_test();\nvoid scope_test();\nvoid forward_test();\nvoid funcptr_test();\nvoid loop_test();\nvoid switch_test();\nvoid goto_test();\nvoid enum_test();\nvoid typedef_test();\nvoid struct_test();\nvoid array_test();\nvoid expr_ptr_test();\nvoid bool_test();\nvoid expr2_test();\nvoid constant_expr_test();\nvoid expr_cmp_test();\nvoid char_short_test();\nvoid init_test(void);\nvoid compound_literal_test(void);\nint kr_test();\nvoid struct_assign_test(void);\nvoid cast_test(void);\nvoid bitfield_test(void);\nvoid c99_bool_test(void);\nvoid float_test(void);\nvoid longlong_test(void);\nvoid manyarg_test(void);\nvoid stdarg_test(void);\nvoid whitespace_test(void);\nvoid relocation_test(void);\nvoid old_style_function(void);\nvoid alloca_test(void);\nvoid c99_vla_test(int size1, int size2);\nvoid sizeof_test(void);\nvoid typeof_test(void);\nvoid local_label_test(void);\nvoid statement_expr_test(void);\nvoid asm_test(void);\nvoid builtin_test(void);\nvoid weak_test(void);\nvoid global_data_test(void);\nvoid cmp_comparison_test(void);\nvoid math_cmp_test(void);\nvoid callsave_test(void);\nvoid builtin_frame_address_test(void);\n\nint fib(int n);\nvoid num(int n);\nvoid forward_ref(void);\nint isid(int c);\n\n#define A 2\n#define N 1234 + A\n#define pf printf\n#define M1(a, b)  (a) + (b)\n\n#define str\\\n(s) # s\n#define glue(a, b) a ## b\n#define xglue(a, b) glue(a, b)\n#define HIGHLOW \"hello\"\n#define LOW LOW \", world\"\n\nstatic int onetwothree = 123;\n#define onetwothree4 onetwothree\n#define onetwothree xglue(onetwothree,4)\n\n#define min(a, b) ((a) < (b) ? (a) : (b))\n\n#ifdef C99_MACROS\n#define dprintf(level,...) printf(__VA_ARGS__)\n#endif\n\n/* gcc vararg macros */\n#define dprintf1(level, fmt, args...) printf(fmt, ## args)\n\n#define MACRO_NOARGS()\n\n#define AAA 3\n#undef AAA\n#define AAA 4\n\n#if 1\n#define B3 1\n#elif 1\n#define B3 2\n#elif 0\n#define B3 3\n#else\n#define B3 4\n#endif\n\n#define __INT64_C(c)\tc ## LL\n#define INT64_MIN\t(-__INT64_C(9223372036854775807)-1)\n\nint qq(int x)\n{\n    return x + 40;\n}\n#define qq(x) x\n\n#define spin_lock(lock) do { } while (0)\n#define wq_spin_lock spin_lock\n#define TEST2() wq_spin_lock(a)\n\nvoid macro_test(void)\n{\n    printf(\"macro:\\n\");\f\u000b\r\n    pf(\"N=%d\\n\", N);\n    printf(\"aaa=%d\\n\", AAA);\n\n    printf(\"min=%d\\n\", min(1, min(2, -1)));\n\n    printf(\"s1=%s\\n\", glue(HIGH, LOW));\n    printf(\"s2=%s\\n\", xglue(HIGH, LOW));\n    printf(\"s3=%s\\n\", str(\"c\"));\n    printf(\"s4=%s\\n\", str(a1));\n    printf(\"B3=%d\\n\", B3);\n\n    printf(\"onetwothree=%d\\n\", onetwothree);\n\n#ifdef A\n    printf(\"A defined\\n\");\n#endif\n#ifdef B\n    printf(\"B defined\\n\");\n#endif\n#ifdef A\n    printf(\"A defined\\n\");\n#else\n    printf(\"A not defined\\n\");\n#endif\n#ifdef B\n    printf(\"B defined\\n\");\n#else\n    printf(\"B not defined\\n\");\n#endif\n\n#ifdef A\n    printf(\"A defined\\n\");\n#ifdef B\n    printf(\"B1 defined\\n\");\n#else\n    printf(\"B1 not defined\\n\");\n#endif\n#else\n    printf(\"A not defined\\n\");\n#ifdef B\n    printf(\"B2 defined\\n\");\n#else\n    printf(\"B2 not defined\\n\");\n#endif\n#endif\n\n#if 1+1\n    printf(\"test true1\\n\");\n#endif\n#if 0\n    printf(\"test true2\\n\");\n#endif\n#if 1-1\n    printf(\"test true3\\n\");\n#endif\n#if defined(A)\n    printf(\"test trueA\\n\");\n#endif\n#if defined(B)\n    printf(\"test trueB\\n\");\n#endif\n\n#if 0\n    printf(\"test 0\\n\");\n#elif 0\n    printf(\"test 1\\n\");\n#elif 2\n    printf(\"test 2\\n\");\n#else\n    printf(\"test 3\\n\");\n#endif\n\n    MACRO_NOARGS();\n\n#ifdef __LINE__\n    printf(\"__LINE__ defined\\n\");\n#endif\n\n    printf(\"__LINE__=%d __FILE__=%s\\n\",\n           __LINE__, __FILE__);\n#line 200\n    printf(\"__LINE__=%d __FILE__=%s\\n\",\n           __LINE__, __FILE__);\n#line 203 \"test\" \n    printf(\"__LINE__=%d __FILE__=%s\\n\",\n           __LINE__, __FILE__);\n#line 227 \"tcctest.c\"\n\n    /* not strictly preprocessor, but we test it there */\n#ifdef C99_MACROS\n    printf(\"__func__ = %s\\n\", __func__);\n    dprintf(1, \"vaarg=%d\\n\", 1);\n#endif\n    dprintf1(1, \"vaarg1\\n\");\n    dprintf1(1, \"vaarg1=%d\\n\", 2);\n    dprintf1(1, \"vaarg1=%d %d\\n\", 1, 2);\n\n    /* gcc extension */\n    printf(\"func='%s'\\n\", __FUNCTION__);\n\n    /* complicated macros in glibc */\n    printf(\"INT64_MIN=%Ld\\n\", INT64_MIN);\n    {\n        int a;\n        a = 1;\n        glue(a+, +);\n        printf(\"a=%d\\n\", a);\n        glue(a <, <= 2);\n        printf(\"a=%d\\n\", a);\n    }\n    \n    /* macro function with argument outside the macro string */\n#define MF_s MF_hello\n#define MF_hello(msg) printf(\"%s\\n\",msg)\n\n#define MF_t printf(\"tralala\\n\"); MF_hello\n\n    MF_s(\"hi\");\n    MF_t(\"hi\");\n    \n    /* test macro substituion inside args (should not eat stream) */\n    printf(\"qq=%d\\n\", qq(qq)(2));\n\n    /* test zero argument case. NOTE: gcc 2.95.x does not accept a\n       null argument without a space. gcc 3.2 fixes that. */\n\n#define qq1(x) 1\n    printf(\"qq1=%d\\n\", qq1( ));\n\n    /* comment with stray handling *\\\n/\n       /* this is a valid *\\/ comment */\n       /* this is a valid comment *\\*/\n    //  this is a valid\\\ncomment\n\n    /* test function macro substitution when the function name is\n       substituted */\n    TEST2();\n\n    /* And again when the name and parenthes are separated by a\n       comment.  */\n    TEST2 /* the comment */ ();\n}\n\n\nstatic void print_num(char *fn, int line, int num) {\n    printf(\"fn %s, line %d, num %d\\n\", fn, line, num);\n}\n\nvoid recursive_macro_test(void)\n{\n\n#define ELF32_ST_TYPE(val)              ((val) & 0xf)\n#define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))\n#define STB_WEAK        2               /* Weak symbol */\n#define ELFW(type) ELF##32##_##type\n    printf(\"%d\\n\", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));\n\n#define WRAP(x) x\n    \n#define print_num(x) print_num(__FILE__,__LINE__,x)\n    print_num(123);\n    WRAP(print_num(123));\n    WRAP(WRAP(print_num(123)));\n\nstatic struct recursive_macro { int rm_field; } G;\n#define rm_field (G.rm_field)\n    printf(\"rm_field = %d\\n\", rm_field);\n    printf(\"rm_field = %d\\n\", WRAP(rm_field));\n    WRAP((printf(\"rm_field = %d %d\\n\", rm_field, WRAP(rm_field))));\n}\n\nint op(a,b)\n{\n    return a / b;\n}\n\nint ret(a)\n{\n    if (a == 2)\n        return 1;\n    if (a == 3)\n        return 2;\n    return 0;\n}\n\nvoid ps(const char *s)\n{\n    int c;\n    while (1) {\n        c = *s;\n        if (c == 0)\n            break;\n        printf(\"%c\", c);\n        s++;\n    }\n}\n\nconst char foo1_string[] = \"\\\nbar\\n\\\ntest\\14\\\n1\";\n\nvoid string_test()\n{\n    unsigned int b;\n    printf(\"string:\\n\");\n    printf(\"\\141\\1423\\143\\n\");/* dezdez test */\n    printf(\"\\x41\\x42\\x43\\x3a\\n\");\n    printf(\"c=%c\\n\", 'r');\n    printf(\"wc=%C 0x%lx %C\\n\", L'a', L'\\x1234', L'c');\n    printf(\"foo1_string='%s'\\n\", foo1_string);\n#if 0\n    printf(\"wstring=%S\\n\", L\"abc\");\n    printf(\"wstring=%S\\n\", L\"abc\" L\"def\" \"ghi\");\n    printf(\"'\\\\377'=%d '\\\\xff'=%d\\n\", '\\377', '\\xff');\n    printf(\"L'\\\\377'=%d L'\\\\xff'=%d\\n\", L'\\377', L'\\xff');\n#endif\n    ps(\"test\\n\");\n    b = 32;\n    while ((b = b + 1) < 96) {\n        printf(\"%c\", b);\n    }\n    printf(\"\\n\");\n    printf(\"fib=%d\\n\", fib(33));\n    b = 262144;\n    while (b != 0x80000000) {\n        num(b);\n        b = b * 2;\n    }\n}\n\nvoid loop_test()\n{\n    int i;\n    i = 0;\n    while (i < 10)\n        printf(\"%d\", i++);\n    printf(\"\\n\");\n    for(i = 0; i < 10;i++)\n        printf(\"%d\", i);\n    printf(\"\\n\");\n    i = 0;\n    do {\n        printf(\"%d\", i++);\n    } while (i < 10);\n    printf(\"\\n\");\n\n    char count = 123;\n    /* c99 for loop init test */\n    for (size_t count = 1; count < 3; count++)\n        printf(\"count=%d\\n\", count);\n    printf(\"count = %d\\n\", count);\n\n    /* break/continue tests */\n    i = 0;\n    while (1) {\n        if (i == 6)\n            break;\n        i++;\n        if (i == 3)\n            continue;\n        printf(\"%d\", i);\n    }\n    printf(\"\\n\");\n\n    /* break/continue tests */\n    i = 0;\n    do {\n        if (i == 6)\n            break;\n        i++;\n        if (i == 3)\n            continue;\n        printf(\"%d\", i);\n    } while(1);\n    printf(\"\\n\");\n\n    for(i = 0;i < 10;i++) {\n        if (i == 3)\n            continue;\n        printf(\"%d\", i);\n    }\n    printf(\"\\n\");\n}\n\ntypedef int typedef_and_label;\n\nvoid goto_test()\n{\n    int i;\n    static void *label_table[3] = { &&label1, &&label2, &&label3 };\n\n    printf(\"goto:\\n\");\n    i = 0;\n    /* This needs to parse as label, not as start of decl.  */\n typedef_and_label:\n s_loop:\n    if (i >= 10) \n        goto s_end;\n    printf(\"%d\", i);\n    i++;\n    goto s_loop;\n s_end:\n    printf(\"\\n\");\n\n    /* we also test computed gotos (GCC extension) */\n    for(i=0;i<3;i++) {\n        goto *label_table[i];\n    label1:\n        printf(\"label1\\n\");\n        goto next;\n    label2:\n        printf(\"label2\\n\");\n        goto next;\n    label3:\n        printf(\"label3\\n\");\n    next: ;\n    }\n}\n\nenum {\n    E0,\n    E1 = 2,\n    E2 = 4,\n    E3,\n    E4,\n};\n\nenum test {\n    E5 = 1000,\n};\n\nvoid enum_test()\n{\n    enum test b1;\n    printf(\"enum:\\n%d %d %d %d %d %d\\n\",\n           E0, E1, E2, E3, E4, E5);\n    b1 = 1;\n    printf(\"b1=%d\\n\", b1);\n}\n\ntypedef int *my_ptr;\n\ntypedef int mytype1;\ntypedef int mytype2;\n\nvoid typedef_test()\n{\n    my_ptr a;\n    mytype1 mytype2;\n    int b;\n\n    a = &b;\n    *a = 1234;\n    printf(\"typedef:\\n\");\n    printf(\"a=%d\\n\", *a);\n    mytype2 = 2;\n    printf(\"mytype2=%d\\n\", mytype2);\n}\n\nvoid forward_test()\n{\n    printf(\"forward:\\n\");\n    forward_ref();\n    forward_ref();\n}\n\n\nvoid forward_ref(void)\n{\n    printf(\"forward ok\\n\");\n}\n\ntypedef struct struct1 {\n    int f1;\n    int f2, f3;\n    union union1 {\n        int v1;\n        int v2;\n    } u;\n    char str[3];\n} struct1;\n\nstruct struct2 {\n    int a;\n    char b;\n};\n\nunion union2 {\n    int w1;\n    int w2;\n};\n\nstruct struct1 st1, st2;\n\nint main(int argc, char **argv)\n{\n    string_test();\n    expr_test();\n    macro_test();\n    recursive_macro_test();\n    scope_test();\n    forward_test();\n    funcptr_test();\n    loop_test();\n    switch_test();\n    goto_test();\n    enum_test();\n    typedef_test();\n    struct_test();\n    array_test();\n    expr_ptr_test();\n    bool_test();\n    expr2_test();\n    constant_expr_test();\n    expr_cmp_test();\n    char_short_test();\n    init_test();\n    compound_literal_test();\n    kr_test();\n    struct_assign_test();\n    cast_test();\n    bitfield_test();\n    c99_bool_test();\n    float_test();\n    longlong_test();\n    manyarg_test();\n    stdarg_test();\n    whitespace_test();\n    relocation_test();\n    old_style_function();\n    alloca_test();\n    c99_vla_test(5, 2);\n    sizeof_test();\n    typeof_test();\n    statement_expr_test();\n    local_label_test();\n    asm_test();\n    builtin_test();\n#ifndef _WIN32\n    weak_test();\n#endif\n    global_data_test();\n    cmp_comparison_test();\n    math_cmp_test();\n    callsave_test();\n    builtin_frame_address_test();\n    return 0; \n}\n\nint tab[3];\nint tab2[3][2];\n\nint g;\n\nvoid f1(g)\n{\n    printf(\"g1=%d\\n\", g);\n}\n\nvoid scope_test()\n{\n    printf(\"scope:\\n\");\n    g = 2;\n    f1(1);\n    printf(\"g2=%d\\n\", g);\n    {\n        int g;\n        g = 3;\n        printf(\"g3=%d\\n\", g);\n        {\n            int g;\n            g = 4;\n            printf(\"g4=%d\\n\", g);\n        }\n    }\n    printf(\"g5=%d\\n\", g);\n}\n\nvoid array_test()\n{\n    int i, j, a[4];\n\n    printf(\"array:\\n\");\n    printf(\"sizeof(a) = %d\\n\", sizeof(a));\n    printf(\"sizeof(\\\"a\\\") = %d\\n\", sizeof(\"a\"));\n#ifdef C99_MACROS\n    printf(\"sizeof(__func__) = %d\\n\", sizeof(__func__));\n#endif\n    printf(\"sizeof tab %d\\n\", sizeof(tab));\n    printf(\"sizeof tab2 %d\\n\", sizeof tab2);\n    tab[0] = 1;\n    tab[1] = 2;\n    tab[2] = 3;\n    printf(\"%d %d %d\\n\", tab[0], tab[1], tab[2]);\n    for(i=0;i<3;i++)\n        for(j=0;j<2;j++)\n            tab2[i][j] = 10 * i + j;\n    for(i=0;i<3*2;i++) {\n        printf(\" %3d\", ((int *)tab2)[i]);\n    }\n    printf(\"\\n\");\n    printf(\"sizeof(size_t)=%d\\n\", sizeof(size_t));\n    printf(\"sizeof(ptrdiff_t)=%d\\n\", sizeof(ptrdiff_t));\n}\n\nvoid expr_test()\n{\n    int a, b;\n    a = 0;\n    printf(\"%d\\n\", a += 1);\n    printf(\"%d\\n\", a -= 2);\n    printf(\"%d\\n\", a *= 31232132);\n    printf(\"%d\\n\", a /= 4);\n    printf(\"%d\\n\", a %= 20);\n    printf(\"%d\\n\", a &= 6);\n    printf(\"%d\\n\", a ^= 7);\n    printf(\"%d\\n\", a |= 8);\n    printf(\"%d\\n\", a >>= 3);\n    printf(\"%d\\n\", a <<= 4);\n\n    a = 22321;\n    b = -22321;\n    printf(\"%d\\n\", a + 1);\n    printf(\"%d\\n\", a - 2);\n    printf(\"%d\\n\", a * 312);\n    printf(\"%d\\n\", a / 4);\n    printf(\"%d\\n\", b / 4);\n    printf(\"%d\\n\", (unsigned)b / 4);\n    printf(\"%d\\n\", a % 20);\n    printf(\"%d\\n\", b % 20);\n    printf(\"%d\\n\", (unsigned)b % 20);\n    printf(\"%d\\n\", a & 6);\n    printf(\"%d\\n\", a ^ 7);\n    printf(\"%d\\n\", a | 8);\n    printf(\"%d\\n\", a >> 3);\n    printf(\"%d\\n\", b >> 3);\n    printf(\"%d\\n\", (unsigned)b >> 3);\n    printf(\"%d\\n\", a << 4);\n    printf(\"%d\\n\", ~a);\n    printf(\"%d\\n\", -a);\n    printf(\"%d\\n\", +a);\n\n    printf(\"%d\\n\", 12 + 1);\n    printf(\"%d\\n\", 12 - 2);\n    printf(\"%d\\n\", 12 * 312);\n    printf(\"%d\\n\", 12 / 4);\n    printf(\"%d\\n\", 12 % 20);\n    printf(\"%d\\n\", 12 & 6);\n    printf(\"%d\\n\", 12 ^ 7);\n    printf(\"%d\\n\", 12 | 8);\n    printf(\"%d\\n\", 12 >> 2);\n    printf(\"%d\\n\", 12 << 4);\n    printf(\"%d\\n\", ~12);\n    printf(\"%d\\n\", -12);\n    printf(\"%d\\n\", +12);\n    printf(\"%d %d %d %d\\n\", \n           isid('a'), \n           isid('g'), \n           isid('T'), \n           isid('('));\n}\n\nint isid(int c)\n{\n    return (c >= 'a' & c <= 'z') | (c >= 'A' & c <= 'Z') | c == '_';\n}\n\n/**********************/\n\nint vstack[10], *vstack_ptr;\n\nvoid vpush(int vt, int vc)\n{\n    *vstack_ptr++ = vt;\n    *vstack_ptr++ = vc;\n}\n\nvoid vpop(int *ft, int *fc)\n{\n    *fc = *--vstack_ptr;\n    *ft = *--vstack_ptr;\n}\n\nvoid expr2_test()\n{\n    int a, b;\n\n    printf(\"expr2:\\n\");\n    vstack_ptr = vstack;\n    vpush(1432432, 2);\n    vstack_ptr[-2] &= ~0xffffff80;\n    vpop(&a, &b);\n    printf(\"res= %d %d\\n\", a, b);\n}\n\nvoid constant_expr_test()\n{\n    int a;\n    printf(\"constant_expr:\\n\");\n    a = 3;\n    printf(\"%d\\n\", a * 16);\n    printf(\"%d\\n\", a * 1);\n    printf(\"%d\\n\", a + 0);\n}\n\nint tab4[10];\n\nvoid expr_ptr_test()\n{\n    int *p, *q;\n    int i = -1;\n\n    printf(\"expr_ptr:\\n\");\n    p = tab4;\n    q = tab4 + 10;\n    printf(\"diff=%d\\n\", q - p);\n    p++;\n    printf(\"inc=%d\\n\", p - tab4);\n    p--;\n    printf(\"dec=%d\\n\", p - tab4);\n    ++p;\n    printf(\"inc=%d\\n\", p - tab4);\n    --p;\n    printf(\"dec=%d\\n\", p - tab4);\n    printf(\"add=%d\\n\", p + 3 - tab4);\n    printf(\"add=%d\\n\", 3 + p - tab4);\n\n    /* check if 64bit support is ok */\n    q = p = 0;\n    q += i;\n    printf(\"%p %p %ld\\n\", q, p, p-q);\n    printf(\"%d %d %d %d %d %d\\n\",\n           p == q, p != q, p < q, p <= q, p >= q, p > q);\n    i = 0xf0000000;\n    p += i;\n    printf(\"%p %p %ld\\n\", q, p, p-q);\n    printf(\"%d %d %d %d %d %d\\n\",\n           p == q, p != q, p < q, p <= q, p >= q, p > q);\n    p = (int *)((char *)p + 0xf0000000);\n    printf(\"%p %p %ld\\n\", q, p, p-q);\n    printf(\"%d %d %d %d %d %d\\n\",\n           p == q, p != q, p < q, p <= q, p >= q, p > q);\n    p += 0xf0000000;\n    printf(\"%p %p %ld\\n\", q, p, p-q);\n    printf(\"%d %d %d %d %d %d\\n\",\n           p == q, p != q, p < q, p <= q, p >= q, p > q);\n    {\n        struct size12 {\n            int i, j, k;\n        };\n        struct size12 s[2], *sp = s;\n        int i, j;\n        sp->i = 42;\n        sp++;\n        j = -1;\n        printf(\"%d\\n\", sp[j].i);\n    }\n}\n\nvoid expr_cmp_test()\n{\n    int a, b;\n    printf(\"constant_expr:\\n\");\n    a = -1;\n    b = 1;\n    printf(\"%d\\n\", a == a);\n    printf(\"%d\\n\", a != a);\n\n    printf(\"%d\\n\", a < b);\n    printf(\"%d\\n\", a <= b);\n    printf(\"%d\\n\", a <= a);\n    printf(\"%d\\n\", b >= a);\n    printf(\"%d\\n\", a >= a);\n    printf(\"%d\\n\", b > a);\n\n    printf(\"%d\\n\", (unsigned)a < b);\n    printf(\"%d\\n\", (unsigned)a <= b);\n    printf(\"%d\\n\", (unsigned)a <= a);\n    printf(\"%d\\n\", (unsigned)b >= a);\n    printf(\"%d\\n\", (unsigned)a >= a);\n    printf(\"%d\\n\", (unsigned)b > a);\n}\n\nstruct empty {\n};\n\nstruct aligntest1 {\n    char a[10];\n};\n\nstruct aligntest2 {\n    int a;\n    char b[10];\n};\n\nstruct aligntest3 {\n    double a, b;\n};\n\nstruct aligntest4 {\n    double a[0];\n};\n\nvoid struct_test()\n{\n    struct1 *s;\n    union union2 u;\n\n    printf(\"struct:\\n\");\n    printf(\"sizes: %d %d %d %d\\n\",\n           sizeof(struct struct1),\n           sizeof(struct struct2),\n           sizeof(union union1),\n           sizeof(union union2));\n    st1.f1 = 1;\n    st1.f2 = 2;\n    st1.f3 = 3;\n    printf(\"st1: %d %d %d\\n\",\n           st1.f1, st1.f2, st1.f3);\n    st1.u.v1 = 1;\n    st1.u.v2 = 2;\n    printf(\"union1: %d\\n\", st1.u.v1);\n    u.w1 = 1;\n    u.w2 = 2;\n    printf(\"union2: %d\\n\", u.w1);\n    s = &st2;\n    s->f1 = 3;\n    s->f2 = 2;\n    s->f3 = 1;\n    printf(\"st2: %d %d %d\\n\",\n           s->f1, s->f2, s->f3);\n    printf(\"str_addr=%x\\n\", (int)st1.str - (int)&st1.f1);\n\n    /* align / size tests */\n    printf(\"aligntest1 sizeof=%d alignof=%d\\n\",\n           sizeof(struct aligntest1), __alignof__(struct aligntest1));\n    printf(\"aligntest2 sizeof=%d alignof=%d\\n\",\n           sizeof(struct aligntest2), __alignof__(struct aligntest2));\n    printf(\"aligntest3 sizeof=%d alignof=%d\\n\",\n           sizeof(struct aligntest3), __alignof__(struct aligntest3));\n    printf(\"aligntest4 sizeof=%d alignof=%d\\n\",\n           sizeof(struct aligntest4), __alignof__(struct aligntest4));\n           \n    /* empty structures (GCC extension) */\n    printf(\"sizeof(struct empty) = %d\\n\", sizeof(struct empty));\n    printf(\"alignof(struct empty) = %d\\n\", __alignof__(struct empty));\n}\n\n/* XXX: depend on endianness */\nvoid char_short_test()\n{\n    int var1, var2;\n\n    printf(\"char_short:\\n\");\n\n    var1 = 0x01020304;\n    var2 = 0xfffefdfc;\n    printf(\"s8=%d %d\\n\", \n           *(char *)&var1, *(char *)&var2);\n    printf(\"u8=%d %d\\n\", \n           *(unsigned char *)&var1, *(unsigned char *)&var2);\n    printf(\"s16=%d %d\\n\", \n           *(short *)&var1, *(short *)&var2);\n    printf(\"u16=%d %d\\n\", \n           *(unsigned short *)&var1, *(unsigned short *)&var2);\n    printf(\"s32=%d %d\\n\", \n           *(int *)&var1, *(int *)&var2);\n    printf(\"u32=%d %d\\n\", \n           *(unsigned int *)&var1, *(unsigned int *)&var2);\n    *(char *)&var1 = 0x08;\n    printf(\"var1=%x\\n\", var1);\n    *(short *)&var1 = 0x0809;\n    printf(\"var1=%x\\n\", var1);\n    *(int *)&var1 = 0x08090a0b;\n    printf(\"var1=%x\\n\", var1);\n}\n\n/******************/\n\ntypedef struct Sym {\n    int v;\n    int t;\n    int c;\n    struct Sym *next;\n    struct Sym *prev;\n} Sym;\n\n#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')\n#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))\n\nstatic int toupper1(int a)\n{\n    return TOUPPER(a);\n}\n\nvoid bool_test()\n{\n    int *s, a, b, t, f, i;\n\n    a = 0;\n    s = (void*)0;\n    printf(\"!s=%d\\n\", !s);\n\n    if (!s || !s[0])\n        a = 1;\n    printf(\"a=%d\\n\", a);\n\n    printf(\"a=%d %d %d\\n\", 0 || 0, 0 || 1, 1 || 1);\n    printf(\"a=%d %d %d\\n\", 0 && 0, 0 && 1, 1 && 1);\n    printf(\"a=%d %d\\n\", 1 ? 1 : 0, 0 ? 1 : 0);\n#if 1 && 1\n    printf(\"a1\\n\");\n#endif\n#if 1 || 0\n    printf(\"a2\\n\");\n#endif\n#if 1 ? 0 : 1\n    printf(\"a3\\n\");\n#endif\n#if 0 ? 0 : 1\n    printf(\"a4\\n\");\n#endif\n\n    a = 4;\n    printf(\"b=%d\\n\", a + (0 ? 1 : a / 2));\n\n    /* test register spilling */\n    a = 10;\n    b = 10;\n    a = (a + b) * ((a < b) ?\n                   ((b - a) * (a - b)): a + b);\n    printf(\"a=%d\\n\", a);\n\n    /* test complex || or && expressions */\n    t = 1;\n    f = 0;\n    a = 32;\n    printf(\"exp=%d\\n\", f == (32 <= a && a <= 3));\n    printf(\"r=%d\\n\", (t || f) + (t && f));\n\n    /* test ? : cast */\n    {\n        int aspect_on;\n        int aspect_native = 65536;\n        double bfu_aspect = 1.0;\n        int aspect;\n        for(aspect_on = 0; aspect_on < 2; aspect_on++) {\n            aspect=aspect_on?(aspect_native*bfu_aspect+0.5):65535UL;\n            printf(\"aspect=%d\\n\", aspect);\n        }\n    }\n\n    /* test ? : GCC extension */\n    {\n        static int v1 = 34 ? : -1; /* constant case */\n        static int v2 = 0 ? : -1; /* constant case */\n        int a = 30;\n        \n        printf(\"%d %d\\n\", v1, v2);\n        printf(\"%d %d\\n\", a - 30 ? : a * 2, a + 1 ? : a * 2);\n    }\n\n    /* again complex expression */\n    for(i=0;i<256;i++) {\n        if (toupper1 (i) != TOUPPER (i))\n            printf(\"error %d\\n\", i);\n    }\n}\n\n/* GCC accepts that */\nstatic int tab_reinit[];\nstatic int tab_reinit[10];\n\n//int cinit1; /* a global variable can be defined several times without error ! */\nint cinit1; \nint cinit1; \nint cinit1 = 0;\nint *cinit2 = (int []){3, 2, 1};\n\nvoid compound_literal_test(void)\n{\n    int *p, i;\n    char *q, *q3;\n\n    printf(\"compound_test:\\n\");\n\n    p = (int []){1, 2, 3};\n    for(i=0;i<3;i++)\n        printf(\" %d\", p[i]);\n    printf(\"\\n\");\n\n    for(i=0;i<3;i++)\n        printf(\"%d\", cinit2[i]);\n    printf(\"\\n\");\n\n    q = \"tralala1\";\n    printf(\"q1=%s\\n\", q);\n\n    q = (char *){ \"tralala2\" };\n    printf(\"q2=%s\\n\", q);\n\n    q3 = (char *){ q };\n    printf(\"q3=%s\\n\", q3);\n\n    q = (char []){ \"tralala3\" };\n    printf(\"q4=%s\\n\", q);\n\n#ifdef ALL_ISOC99\n    p = (int []){1, 2, cinit1 + 3};\n    for(i=0;i<3;i++)\n        printf(\" %d\", p[i]);\n    printf(\"\\n\");\n\n    for(i=0;i<3;i++) {\n        p = (int []){1, 2, 4 + i};\n        printf(\"%d %d %d\\n\", \n               p[0],\n               p[1],\n               p[2]);\n    }\n#endif\n}\n\n/* K & R protos */\n\nkr_func1(a, b)\n{\n    return a + b;\n}\n\nint kr_func2(a, b)\n{\n    return a + b;\n}\n\nkr_test()\n{\n    printf(\"kr_test:\\n\");\n    printf(\"func1=%d\\n\", kr_func1(3, 4));\n    printf(\"func2=%d\\n\", kr_func2(3, 4));\n    return 0;\n}\n\nvoid num(int n)\n{\n    char *tab, *p;\n    tab = (char*)malloc(20); \n    p = tab;\n    while (1) {\n        *p = 48 + (n % 10);\n        p++;\n        n = n / 10;\n        if (n == 0)\n            break;\n    }\n    while (p != tab) {\n        p--;\n        printf(\"%c\", *p);\n    }\n    printf(\"\\n\");\n    free(tab);\n}\n\n/* structure assignment tests */\nstruct structa1 {\n    int f1;\n    char f2;\n};\n\nstruct structa1 ssta1;\n\nvoid struct_assign_test1(struct structa1 s1, int t, float f)\n{\n    printf(\"%d %d %d %f\\n\", s1.f1, s1.f2, t, f);\n}\n\nstruct structa1 struct_assign_test2(struct structa1 s1, int t)\n{\n    s1.f1 += t;\n    s1.f2 -= t;\n    return s1;\n}\n\nvoid struct_assign_test(void)\n{\n    struct S {\n      struct structa1 lsta1, lsta2;\n      int i;\n    } s, *ps;\n    \n    ps = &s;\n    ps->i = 4;\n#if 0\n    printf(\"struct_assign_test:\\n\");\n\n    s.lsta1.f1 = 1;\n    s.lsta1.f2 = 2;\n    printf(\"%d %d\\n\", s.lsta1.f1, s.lsta1.f2);\n    s.lsta2 = s.lsta1;\n    printf(\"%d %d\\n\", s.lsta2.f1, s.lsta2.f2);\n#else\n    s.lsta2.f1 = 1;\n    s.lsta2.f2 = 2;\n#endif\n    struct_assign_test1(ps->lsta2, 3, 4.5);\n    \n    printf(\"before call: %d %d\\n\", s.lsta2.f1, s.lsta2.f2);\n    ps->lsta2 = struct_assign_test2(ps->lsta2, ps->i);\n    printf(\"after call: %d %d\\n\", ps->lsta2.f1, ps->lsta2.f2);\n\n    static struct {\n        void (*elem)();\n    } t[] = {\n        /* XXX: we should allow this even without braces */\n        { struct_assign_test }\n    };\n    printf(\"%d\\n\", struct_assign_test == t[0].elem);\n}\n\n/* casts to short/char */\n\nvoid cast1(char a, short b, unsigned char c, unsigned short d)\n{\n    printf(\"%d %d %d %d\\n\", a, b, c, d);\n}\n\nchar bcast;\nshort scast;\n\nvoid cast_test()\n{\n    int a;\n    char c;\n    char tab[10];\n    unsigned b,d;\n    short s;\n    char *p = NULL;\n    p -= 0x700000000042;\n\n    printf(\"cast_test:\\n\");\n    a = 0xfffff;\n    cast1(a, a, a, a);\n    a = 0xffffe;\n    printf(\"%d %d %d %d\\n\",\n           (char)(a + 1),\n           (short)(a + 1),\n           (unsigned char)(a + 1),\n           (unsigned short)(a + 1));\n    printf(\"%d %d %d %d\\n\",\n           (char)0xfffff,\n           (short)0xfffff,\n           (unsigned char)0xfffff,\n           (unsigned short)0xfffff);\n\n    a = (bcast = 128) + 1;\n    printf(\"%d\\n\", a);\n    a = (scast = 65536) + 1;\n    printf(\"%d\\n\", a);\n    \n    printf(\"sizeof(c) = %d, sizeof((int)c) = %d\\n\", sizeof(c), sizeof((int)c));\n    \n    /* test cast from unsigned to signed short to int */\n    b = 0xf000;\n    d = (short)b;\n    printf(\"((unsigned)(short)0x%08x) = 0x%08x\\n\", b, d);\n    b = 0xf0f0;\n    d = (char)b;\n    printf(\"((unsigned)(char)0x%08x) = 0x%08x\\n\", b, d);\n    \n    /* test implicit int casting for array accesses */\n    c = 0;\n    tab[1] = 2;\n    tab[c] = 1;\n    printf(\"%d %d\\n\", tab[0], tab[1]);\n\n    /* test implicit casting on some operators */\n    printf(\"sizeof(+(char)'a') = %d\\n\", sizeof(+(char)'a'));\n    printf(\"sizeof(-(char)'a') = %d\\n\", sizeof(-(char)'a'));\n    printf(\"sizeof(~(char)'a') = %d\\n\", sizeof(-(char)'a'));\n\n    /* from pointer to integer types */\n    printf(\"%d %d %ld %ld %lld %lld\\n\",\n           (int)p, (unsigned int)p,\n           (long)p, (unsigned long)p,\n           (long long)p, (unsigned long long)p);\n\n    /* from integers to pointers */\n    printf(\"%p %p %p %p\\n\",\n           (void *)a, (void *)b, (void *)c, (void *)d);\n}\n\n/* initializers tests */\nstruct structinit1 {\n    int f1;\n    char f2;\n    short f3;\n    int farray[3];\n};\n\nint sinit1 = 2;\nint sinit2 = { 3 };\nint sinit3[3] = { 1, 2, {{3}}, };\nint sinit4[3][2] = { {1, 2}, {3, 4}, {5, 6} };\nint sinit5[3][2] = { 1, 2, 3, 4, 5, 6 };\nint sinit6[] = { 1, 2, 3 };\nint sinit7[] = { [2] = 3, [0] = 1, 2 };\nchar sinit8[] = \"hello\" \"trala\";\n\nstruct structinit1 sinit9 = { 1, 2, 3 };\nstruct structinit1 sinit10 = { .f2 = 2, 3, .f1 = 1 };\nstruct structinit1 sinit11 = { .f2 = 2, 3, .f1 = 1, \n#ifdef ALL_ISOC99\n                               .farray[0] = 10,\n                               .farray[1] = 11,\n                               .farray[2] = 12,\n#endif\n};\n\nchar *sinit12 = \"hello world\";\nchar *sinit13[] = {\n    \"test1\",\n    \"test2\",\n    \"test3\",\n};\nchar sinit14[10] = { \"abc\" };\nint sinit15[3] = { sizeof(sinit15), 1, 2 };\n\nstruct { int a[3], b; } sinit16[] = { { 1 }, 2 };\n\nstruct bar {\n        char *s;\n        int len;\n} sinit17[] = {\n        \"a1\", 4,\n        \"a2\", 1\n};\n\nint sinit18[10] = {\n    [2 ... 5] = 20,\n    2,\n    [8] = 10,\n};\n\nstruct complexinit0 {\n    int a;\n    int b;\n};\n\nstruct complexinit {\n    int a;\n    const struct complexinit0 *b;\n};\n\nconst static struct complexinit cix[] = {\n    [0] = {\n\t.a = 2000,\n\t.b = (const struct complexinit0[]) {\n\t\t{ 2001, 2002 },\n\t\t{ 2003, 2003 },\n\t\t{}\n\t}\n    }\n};\n\nstruct complexinit2 {\n\tint a;\n\tint b[];\n};\n\nstruct complexinit2 cix20;\n\nstruct complexinit2 cix21 = {\n\t.a = 3000,\n\t.b = { 3001, 3002, 3003 }\n};\n\nstruct complexinit2 cix22 = {\n\t.a = 4000,\n\t.b = { 4001, 4002, 4003, 4004, 4005, 4006 }\n};\n\nvoid init_test(void)\n{\n    int linit1 = 2;\n    int linit2 = { 3 };\n    int linit4[3][2] = { {1, 2}, {3, 4}, {5, 6} };\n    int linit6[] = { 1, 2, 3 };\n    int i, j;\n    char linit8[] = \"hello\" \"trala\";\n    int linit12[10] = { 1, 2 };\n    int linit13[10] = { 1, 2, [7] = 3, [3] = 4, };\n    char linit14[10] = \"abc\";\n    int linit15[10] = { linit1, linit1 + 1, [6] = linit1 + 2, };\n    struct linit16 { int a1, a2, a3, a4; } linit16 = { 1, .a3 = 2 };\n    int linit17 = sizeof(linit17);\n    \n    printf(\"init_test:\\n\");\n\n    printf(\"sinit1=%d\\n\", sinit1);\n    printf(\"sinit2=%d\\n\", sinit2);\n    printf(\"sinit3=%d %d %d %d\\n\", \n           sizeof(sinit3),\n           sinit3[0],\n           sinit3[1],\n           sinit3[2]\n           );\n    printf(\"sinit6=%d\\n\", sizeof(sinit6));\n    printf(\"sinit7=%d %d %d %d\\n\", \n           sizeof(sinit7),\n           sinit7[0],\n           sinit7[1],\n           sinit7[2]\n           );\n    printf(\"sinit8=%s\\n\", sinit8);\n    printf(\"sinit9=%d %d %d\\n\", \n           sinit9.f1,\n           sinit9.f2,\n           sinit9.f3\n           );\n    printf(\"sinit10=%d %d %d\\n\", \n           sinit10.f1,\n           sinit10.f2,\n           sinit10.f3\n           );\n    printf(\"sinit11=%d %d %d %d %d %d\\n\", \n           sinit11.f1,\n           sinit11.f2,\n           sinit11.f3,\n           sinit11.farray[0],\n           sinit11.farray[1],\n           sinit11.farray[2]\n           );\n\n    for(i=0;i<3;i++)\n        for(j=0;j<2;j++)\n            printf(\"[%d][%d] = %d %d %d\\n\", \n                   i, j, sinit4[i][j], sinit5[i][j], linit4[i][j]);\n    printf(\"linit1=%d\\n\", linit1);\n    printf(\"linit2=%d\\n\", linit2);\n    printf(\"linit6=%d\\n\", sizeof(linit6));\n    printf(\"linit8=%d %s\\n\", sizeof(linit8), linit8);\n\n    printf(\"sinit12=%s\\n\", sinit12);\n    printf(\"sinit13=%d %s %s %s\\n\",\n           sizeof(sinit13), \n           sinit13[0],\n           sinit13[1],\n           sinit13[2]);\n    printf(\"sinit14=%s\\n\", sinit14);\n\n    for(i=0;i<10;i++) printf(\" %d\", linit12[i]);\n    printf(\"\\n\");\n    for(i=0;i<10;i++) printf(\" %d\", linit13[i]);\n    printf(\"\\n\");\n    for(i=0;i<10;i++) printf(\" %d\", linit14[i]);\n    printf(\"\\n\");\n    for(i=0;i<10;i++) printf(\" %d\", linit15[i]);\n    printf(\"\\n\");\n    printf(\"%d %d %d %d\\n\", \n           linit16.a1,\n           linit16.a2,\n           linit16.a3,\n           linit16.a4);\n    /* test that initialisation is done after variable declare */\n    printf(\"linit17=%d\\n\", linit17);\n    printf(\"sinit15=%d\\n\", sinit15[0]);\n    printf(\"sinit16=%d %d\\n\", sinit16[0].a[0], sinit16[1].a[0]);\n    printf(\"sinit17=%s %d %s %d\\n\",\n           sinit17[0].s, sinit17[0].len,\n           sinit17[1].s, sinit17[1].len);\n    for(i=0;i<10;i++)\n        printf(\"%x \", sinit18[i]);\n    printf(\"\\n\");\n    /* complex init check */\n    printf(\"cix: %d %d %d %d %d %d %d\\n\",\n\tcix[0].a,\n\tcix[0].b[0].a, cix[0].b[0].b,\n\tcix[0].b[1].a, cix[0].b[1].b,\n\tcix[0].b[2].a, cix[0].b[2].b);\n    printf(\"cix2: %d %d\\n\", cix21.b[2], cix22.b[5]);\n    printf(\"sizeof cix20 %d, cix21 %d, sizeof cix22 %d\\n\", sizeof cix20, sizeof cix21, sizeof cix22);\n}\n\n\nvoid switch_test()\n{\n    int i;\n\n    for(i=0;i<15;i++) {\n        switch(i) {\n        case 0:\n        case 1:\n            printf(\"a\");\n            break;\n        default:\n            printf(\"%d\", i);\n            break;\n        case 8 ... 12:\n            printf(\"c\");\n            break;\n        case 3:\n            printf(\"b\");\n            break;\n        }\n    }\n    printf(\"\\n\");\n}\n\n/* ISOC99 _Bool type */\nvoid c99_bool_test(void)\n{\n#ifdef BOOL_ISOC99\n    int a;\n    _Bool b;\n\n    printf(\"bool_test:\\n\");\n    printf(\"sizeof(_Bool) = %d\\n\", sizeof(_Bool));\n    a = 3;\n    printf(\"cast: %d %d %d\\n\", (_Bool)10, (_Bool)0, (_Bool)a);\n    b = 3;\n    printf(\"b = %d\\n\", b);\n    b++;\n    printf(\"b = %d\\n\", b);\n#endif\n}\n\nvoid bitfield_test(void)\n{\n    int a;\n    short sa;\n    unsigned char ca;\n    struct sbf1 {\n        int f1 : 3;\n        int : 2;\n        int f2 : 1;\n        int : 0;\n        int f3 : 5;\n        int f4 : 7;\n        unsigned int f5 : 7;\n    } st1;\n    printf(\"bitfield_test:\");\n    printf(\"sizeof(st1) = %d\\n\", sizeof(st1));\n\n    st1.f1 = 3;\n    st1.f2 = 1;\n    st1.f3 = 15;\n    a = 120;\n    st1.f4 = a;\n    st1.f5 = a;\n    st1.f5++;\n    printf(\"%d %d %d %d %d\\n\",\n           st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);\n    sa = st1.f5;\n    ca = st1.f5;\n    printf(\"%d %d\\n\", sa, ca);\n\n    st1.f1 = 7;\n    if (st1.f1 == -1) \n        printf(\"st1.f1 == -1\\n\");\n    else \n        printf(\"st1.f1 != -1\\n\");\n    if (st1.f2 == -1) \n        printf(\"st1.f2 == -1\\n\");\n    else \n        printf(\"st1.f2 != -1\\n\");\n\n    /* bit sizes below must be bigger than 32 since GCC doesn't allow\n       long-long bitfields whose size is not bigger than int */\n    struct sbf2 {\n        long long f1 : 45;\n        long long : 2;\n        long long f2 : 35;\n        unsigned long long f3 : 38;\n    } st2;\n    st2.f1 = 0x123456789ULL;\n    a = 120;\n    st2.f2 = (long long)a << 25;\n    st2.f3 = a;\n    st2.f2++;\n    printf(\"%lld %lld %lld\\n\", st2.f1, st2.f2, st2.f3);\n}\n\n#ifdef __x86_64__\n#define FLOAT_FMT \"%f\\n\"\n#else\n/* x86's float isn't compatible with GCC */\n#define FLOAT_FMT \"%.5f\\n\"\n#endif\n\n/* declare strto* functions as they are C99 */\ndouble strtod(const char *nptr, char **endptr);\nfloat strtof(const char *nptr, char **endptr);\nlong double strtold(const char *nptr, char **endptr);\n\n#define FTEST(prefix, type, fmt)\\\nvoid prefix ## cmp(type a, type b)\\\n{\\\n    printf(\"%d %d %d %d %d %d\\n\",\\\n           a == b,\\\n           a != b,\\\n           a < b,\\\n           a > b,\\\n           a >= b,\\\n           a <= b);\\\n    printf(fmt \" \" fmt \" \" fmt \" \" fmt \" \" fmt \" \" fmt \" \" fmt \"\\n\",\\\n           a,\\\n           b,\\\n           a + b,\\\n           a - b,\\\n           a * b,\\\n           a / b,\\\n           -a);\\\n    printf(fmt \"\\n\", ++a);\\\n    printf(fmt \"\\n\", a++);\\\n    printf(fmt \"\\n\", a);\\\n    b = 0;\\\n    printf(\"%d %d\\n\", !a, !b);\\\n}\\\nvoid prefix ## fcast(type a)\\\n{\\\n    float fa;\\\n    double da;\\\n    long double la;\\\n    int ia;\\\n    unsigned int ua;\\\n    type b;\\\n    fa = a;\\\n    da = a;\\\n    la = a;\\\n    printf(\"ftof: %f %f %Lf\\n\", fa, da, la);\\\n    ia = (int)a;\\\n    ua = (unsigned int)a;\\\n    printf(\"ftoi: %d %u\\n\", ia, ua);\\\n    ia = -1234;\\\n    ua = 0x81234500;\\\n    b = ia;\\\n    printf(\"itof: \" fmt \"\\n\", b);\\\n    b = ua;\\\n    printf(\"utof: \" fmt \"\\n\", b);\\\n}\\\n\\\nfloat prefix ## retf(type a) { return a; }\\\ndouble prefix ## retd(type a) { return a; }\\\nlong double prefix ## retld(type a) { return a; }\\\n\\\nvoid prefix ## call(void)\\\n{\\\n    printf(\"float: \" FLOAT_FMT, prefix ## retf(42.123456789));\\\n    printf(\"double: %f\\n\", prefix ## retd(42.123456789));\\\n    printf(\"long double: %Lf\\n\", prefix ## retld(42.123456789));\\\n    printf(\"strto%s: %f\\n\", #prefix, (double)strto ## prefix(\"1.2\", NULL));\\\n}\\\n\\\nvoid prefix ## test(void)\\\n{\\\n    printf(\"testing '%s'\\n\", #type);\\\n    prefix ## cmp(1, 2.5);\\\n    prefix ## cmp(2, 1.5);\\\n    prefix ## cmp(1, 1);\\\n    prefix ## fcast(234.6);\\\n    prefix ## fcast(-2334.6);\\\n    prefix ## call();\\\n}\n\nFTEST(f, float, \"%f\")\nFTEST(d, double, \"%f\")\nFTEST(ld, long double, \"%Lf\")\n\ndouble ftab1[3] = { 1.2, 3.4, -5.6 };\n\n\nvoid float_test(void)\n{\n    float fa, fb;\n    double da, db;\n    int a;\n    unsigned int b;\n\n    printf(\"float_test:\\n\");\n    printf(\"sizeof(float) = %d\\n\", sizeof(float));\n    printf(\"sizeof(double) = %d\\n\", sizeof(double));\n    printf(\"sizeof(long double) = %d\\n\", sizeof(long double));\n    ftest();\n    dtest();\n    ldtest();\n    printf(\"%f %f %f\\n\", ftab1[0], ftab1[1], ftab1[2]);\n    printf(\"%f %f %f\\n\", 2.12, .5, 2.3e10);\n    //    printf(\"%f %f %f\\n\", 0x1234p12, 0x1e23.23p10, 0x12dp-10);\n    da = 123;\n    printf(\"da=%f\\n\", da);\n    fa = 123;\n    printf(\"fa=%f\\n\", fa);\n    a = 4000000000;\n    da = a;\n    printf(\"da = %f\\n\", da);\n    b = 4000000000;\n    db = b;\n    printf(\"db = %f\\n\", db);\n}\n\nint fib(int n)\n{\n    if (n <= 2)\n        return 1;\n    else\n        return fib(n-1) + fib(n-2);\n}\n\nvoid funcptr_test()\n{\n    void (*func)(int);\n    int a;\n    struct {\n        int dummy;\n        void (*func)(int);\n    } st1;\n\n    printf(\"funcptr:\\n\");\n    func = &num;\n    (*func)(12345);\n    func = num;\n    a = 1;\n    a = 1;\n    func(12345);\n    /* more complicated pointer computation */\n    st1.func = num;\n    st1.func(12346);\n    printf(\"sizeof1 = %d\\n\", sizeof(funcptr_test));\n    printf(\"sizeof2 = %d\\n\", sizeof funcptr_test);\n    printf(\"sizeof3 = %d\\n\", sizeof(&funcptr_test));\n    printf(\"sizeof4 = %d\\n\", sizeof &funcptr_test);\n}\n\nvoid lloptest(long long a, long long b)\n{\n    unsigned long long ua, ub;\n\n    ua = a;\n    ub = b;\n    /* arith */\n    printf(\"arith: %Ld %Ld %Ld\\n\",\n           a + b,\n           a - b,\n           a * b);\n    \n    if (b != 0) {\n        printf(\"arith1: %Ld %Ld\\n\",\n           a / b,\n           a % b);\n    }\n\n    /* binary */\n    printf(\"bin: %Ld %Ld %Ld\\n\",\n           a & b,\n           a | b,\n           a ^ b);\n\n    /* tests */\n    printf(\"test: %d %d %d %d %d %d\\n\",\n           a == b,\n           a != b,\n           a < b,\n           a > b,\n           a >= b,\n           a <= b);\n    \n    printf(\"utest: %d %d %d %d %d %d\\n\",\n           ua == ub,\n           ua != ub,\n           ua < ub,\n           ua > ub,\n           ua >= ub,\n           ua <= ub);\n\n    /* arith2 */\n    a++;\n    b++;\n    printf(\"arith2: %Ld %Ld\\n\", a, b);\n    printf(\"arith2: %Ld %Ld\\n\", a++, b++);\n    printf(\"arith2: %Ld %Ld\\n\", --a, --b);\n    printf(\"arith2: %Ld %Ld\\n\", a, b);\n    b = ub = 0;\n    printf(\"not: %d %d %d %d\\n\", !a, !ua, !b, !ub);\n}\n\nvoid llshift(long long a, int b)\n{\n    printf(\"shift: %Ld %Ld %Ld\\n\",\n           (unsigned long long)a >> b,\n           a >> b,\n           a << b);\n    printf(\"shiftc: %Ld %Ld %Ld\\n\",\n           (unsigned long long)a >> 3,\n           a >> 3,\n           a << 3);\n    printf(\"shiftc: %Ld %Ld %Ld\\n\",\n           (unsigned long long)a >> 35,\n           a >> 35,\n           a << 35);\n}\n\nvoid llfloat(void)\n{\n    float fa;\n    double da;\n    long double lda;\n    long long la, lb, lc;\n    unsigned long long ula, ulb, ulc;\n    la = 0x12345678;\n    ula = 0x72345678;\n    la = (la << 20) | 0x12345;\n    ula = ula << 33;\n    printf(\"la=%Ld ula=%Lu\\n\", la, ula);\n\n    fa = la;\n    da = la;\n    lda = la;\n    printf(\"lltof: %f %f %Lf\\n\", fa, da, lda);\n\n    la = fa;\n    lb = da;\n    lc = lda;\n    printf(\"ftoll: %Ld %Ld %Ld\\n\", la, lb, lc);\n\n    fa = ula;\n    da = ula;\n    lda = ula;\n    printf(\"ulltof: %f %f %Lf\\n\", fa, da, lda);\n\n    ula = fa;\n    ulb = da;\n    ulc = lda;\n    printf(\"ftoull: %Lu %Lu %Lu\\n\", ula, ulb, ulc);\n}\n\nlong long llfunc1(int a)\n{\n    return a * 2;\n}\n\nstruct S {\n    int id; \n    char item;\n};\n\nlong long int value(struct S *v)\n{\n    return ((long long int)v->item);\n}\n\nvoid longlong_test(void)\n{\n    long long a, b, c;\n    int ia;\n    unsigned int ua;\n    printf(\"longlong_test:\\n\");\n    printf(\"sizeof(long long) = %d\\n\", sizeof(long long));\n    ia = -1;\n    ua = -2;\n    a = ia;\n    b = ua;\n    printf(\"%Ld %Ld\\n\", a, b);\n    printf(\"%Ld %Ld %Ld %Lx\\n\", \n           (long long)1, \n           (long long)-2,\n           1LL,\n           0x1234567812345679);\n    a = llfunc1(-3);\n    printf(\"%Ld\\n\", a);\n\n    lloptest(1000, 23);\n    lloptest(0xff, 0x1234);\n    b = 0x72345678 << 10;\n    lloptest(-3, b);\n    llshift(0x123, 5);\n    llshift(-23, 5);\n    b = 0x72345678LL << 10;\n    llshift(b, 47);\n\n    llfloat();\n#if 1\n    b = 0x12345678;\n    a = -1;\n    c = a + b;\n    printf(\"%Lx\\n\", c);\n#endif\n\n    /* long long reg spill test */\n    {\n          struct S a;\n\n          a.item = 3;\n          printf(\"%lld\\n\", value(&a));\n    }\n    lloptest(0x80000000, 0);\n\n    /* another long long spill test */\n    {\n        long long *p, v;\n        v = 1;\n        p = &v;\n        p[0]++;\n        printf(\"%lld\\n\", *p);\n    }\n\n    a = 68719476720LL;\n    b = 4294967295LL;\n    printf(\"%d %d %d %d\\n\", a > b, a < b, a >= b, a <= b);\n\n    printf(\"%Ld\\n\", 0x123456789LLU);\n}\n\nvoid manyarg_test(void)\n{\n    long double ld = 1234567891234LL;\n    printf(\"manyarg_test:\\n\");\n    printf(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\\n\",\n           1, 2, 3, 4, 5, 6, 7, 8,\n           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);\n    printf(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n           \"%Ld %Ld %f %f\\n\",\n           1, 2, 3, 4, 5, 6, 7, 8,\n           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n           1234567891234LL, 987654321986LL,\n           42.0, 43.0);\n    printf(\"%Lf %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n           \"%Ld %Ld %f %f\\n\",\n           ld, 1, 2, 3, 4, 5, 6, 7, 8,\n           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n           1234567891234LL, 987654321986LL,\n           42.0, 43.0);\n    /* XXX: known bug of x86-64 */\n#ifndef __x86_64__\n    printf(\"%d %d %d %d %d %d %d %d %Lf\\n\",\n           1, 2, 3, 4, 5, 6, 7, 8, ld);\n    printf(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n           \"%Ld %Ld %f %f %Lf\\n\",\n           1, 2, 3, 4, 5, 6, 7, 8,\n           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n           1234567891234LL, 987654321986LL,\n           42.0, 43.0, ld);\n    printf(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n           \"%Lf %Ld %Ld %f %f %Lf\\n\",\n           1, 2, 3, 4, 5, 6, 7, 8,\n           0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n           ld, 1234567891234LL, 987654321986LL,\n           42.0, 43.0, ld);\n#endif\n}\n\nvoid vprintf1(const char *fmt, ...)\n{\n    va_list ap, aq;\n    const char *p;\n    int c, i;\n    double d;\n    long long ll;\n    long double ld;\n\n    va_start(aq, fmt);\n    va_copy(ap, aq);\n    \n    p = fmt;\n    for(;;) {\n        c = *p;\n        if (c == '\\0')\n            break;\n        p++;\n        if (c == '%') {\n            c = *p;\n            switch(c) {\n            case '\\0':\n                goto the_end;\n            case 'd':\n                i = va_arg(ap, int);\n                printf(\"%d\", i);\n                break;\n            case 'f':\n                d = va_arg(ap, double);\n                printf(\"%f\", d);\n                break;\n            case 'l':\n                ll = va_arg(ap, long long);\n                printf(\"%Ld\", ll);\n                break;\n            case 'F':\n                ld = va_arg(ap, long double);\n                printf(\"%Lf\", ld);\n                break;\n            }\n            p++;\n        } else {\n            putchar(c);\n        }\n    }\n the_end:\n    va_end(aq);\n    va_end(ap);\n}\n\nstruct myspace {\n    short int profile;\n};\n\nvoid stdarg_for_struct(struct myspace bob, ...)\n{\n    struct myspace george, bill;\n    va_list ap;\n    short int validate;\n\n    va_start(ap, bob);\n    bill     = va_arg(ap, struct myspace);\n    george   = va_arg(ap, struct myspace);\n    validate = va_arg(ap, int);\n    printf(\"stdarg_for_struct: %d %d %d %d\\n\",\n           bob.profile, bill.profile, george.profile, validate);\n    va_end(ap);\n}\n\nvoid stdarg_test(void)\n{\n    long double ld = 1234567891234LL;\n    struct myspace bob;\n\n    vprintf1(\"%d %d %d\\n\", 1, 2, 3);\n    vprintf1(\"%f %d %f\\n\", 1.0, 2, 3.0);\n    vprintf1(\"%l %l %d %f\\n\", 1234567891234LL, 987654321986LL, 3, 1234.0);\n    vprintf1(\"%F %F %F\\n\", 1.2L, 2.3L, 3.4L);\n#ifdef __x86_64__\n    /* a bug of x86's TCC */\n    vprintf1(\"%d %f %l %F %d %f %l %F\\n\",\n             1, 1.2, 3L, 4.5L, 6, 7.8, 9L, 0.1L);\n#endif\n    vprintf1(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8);\n    vprintf1(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);\n    vprintf1(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n             \"%l %l %f %f\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n             1234567891234LL, 987654321986LL,\n             42.0, 43.0);\n    vprintf1(\"%F %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n             \"%l %l %f %f\\n\",\n             ld, 1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n             1234567891234LL, 987654321986LL,\n             42.0, 43.0);\n    vprintf1(\"%d %d %d %d %d %d %d %d %F\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8, ld);\n    vprintf1(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n             \"%l %l %f %f %F\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n             1234567891234LL, 987654321986LL,\n             42.0, 43.0, ld);\n    vprintf1(\"%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f \"\n             \"%F %l %l %f %f %F\\n\",\n             1, 2, 3, 4, 5, 6, 7, 8,\n             0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,\n             ld, 1234567891234LL, 987654321986LL,\n             42.0, 43.0, ld);\n\n    bob.profile = 42;\n    stdarg_for_struct(bob, bob, bob, bob.profile);\n}\n\nvoid whitespace_test(void)\n{\n    char *str;\n\n\f\u000b\r#if 1\n    pri\\\nntf(\"whitspace:\\n\");\f\u000b\r\n#endif\n    pf(\"N=%d\\n\", 2);\n\n#ifdef CORRECT_CR_HANDLING\n    pri\\\r\nntf(\"aaa=%d\\n\", 3);\n#endif\n\n    pri\\\n\\\nntf(\"min=%d\\n\", 4);\n\n#ifdef ACCEPT_CR_IN_STRINGS\n    printf(\"len1=%d\\n\", strlen(\"\n\"));\n#ifdef CORRECT_CR_HANDLING\n    str = \"\r\n\";\n    printf(\"len1=%d str[0]=%d\\n\", strlen(str), str[0]);\n#endif\n    printf(\"len1=%d\\n\", strlen(\"\ra\n\"));\n#endif /* ACCEPT_CR_IN_STRINGS */\n}\n\nint reltab[3] = { 1, 2, 3 };\n\nint *rel1 = &reltab[1];\nint *rel2 = &reltab[2];\n\nvoid relocation_test(void)\n{\n    printf(\"*rel1=%d\\n\", *rel1);\n    printf(\"*rel2=%d\\n\", *rel2);\n}\n\nvoid old_style_f(a,b,c)\n     int a, b;\n     double c;\n{\n    printf(\"a=%d b=%d b=%f\\n\", a, b, c);\n}\n\nvoid decl_func1(int cmpfn())\n{\n    printf(\"cmpfn=%lx\\n\", (long)cmpfn);\n}\n\nvoid decl_func2(cmpfn)\nint cmpfn();\n{\n    printf(\"cmpfn=%lx\\n\", (long)cmpfn);\n}\n\nvoid old_style_function(void)\n{\n    old_style_f((void *)1, 2, 3.0);\n    decl_func1(NULL);\n    decl_func2(NULL);\n}\n\nvoid alloca_test()\n{\n#if defined __i386__ || defined __x86_64__\n    char *p = alloca(16);\n    strcpy(p,\"123456789012345\");\n    printf(\"alloca: p is %s\\n\", p);\n    char *demo = \"This is only a test.\\n\";\n    /* Test alloca embedded in a larger expression */\n    printf(\"alloca: %s\\n\", strcpy(alloca(strlen(demo)+1),demo) );\n#endif\n}\n\nvoid *bounds_checking_is_enabled()\n{\n    char ca[10], *cp = ca-1;\n    return (ca != cp + 1) ? cp : NULL;\n}\n\ntypedef int constant_negative_array_size_as_compile_time_assertion_idiom[(1 ? 2 : 0) - 1];\n\nvoid c99_vla_test(int size1, int size2)\n{\n#if defined __i386__ || defined __x86_64__\n    int size = size1 * size2;\n    int tab1[size][2], tab2[10][2];\n    void *tab1_ptr, *tab2_ptr, *bad_ptr;\n\n    /* \"size\" should have been 'captured' at tab1 declaration, \n        so modifying it should have no effect on VLA behaviour. */\n    size = size-1;\n    \n    printf(\"Test C99 VLA 1 (sizeof): \");\n    printf(\"%s\\n\", (sizeof tab1 == size1 * size2 * 2 * sizeof(int)) ? \"PASSED\" : \"FAILED\");\n    tab1_ptr = tab1;\n    tab2_ptr = tab2;\n    printf(\"Test C99 VLA 2 (ptrs substract): \");\n    printf(\"%s\\n\", (tab2 - tab1 == (tab2_ptr - tab1_ptr) / (sizeof(int) * 2)) ? \"PASSED\" : \"FAILED\");\n    printf(\"Test C99 VLA 3 (ptr add): \");\n    printf(\"%s\\n\", &tab1[5][1] == (tab1_ptr + (5 * 2 + 1) * sizeof(int)) ? \"PASSED\" : \"FAILED\");\n    printf(\"Test C99 VLA 4 (ptr access): \");\n    tab1[size1][1] = 42;\n    printf(\"%s\\n\", (*((int *) (tab1_ptr + (size1 * 2 + 1) * sizeof(int))) == 42) ? \"PASSED\" : \"FAILED\");\n\n    printf(\"Test C99 VLA 5 (bounds checking (might be disabled)): \");\n    if (bad_ptr = bounds_checking_is_enabled()) {\n        int *t1 = &tab1[size1 * size2 - 1][3];\n        int *t2 = &tab2[9][3];\n        printf(\"%s \", bad_ptr == t1 ? \"PASSED\" : \"FAILED\");\n        printf(\"%s \", bad_ptr == t2 ? \"PASSED\" : \"FAILED\");\n\n        char*c1 = 1 + sizeof(tab1) + (char*)tab1;\n        char*c2 = 1 + sizeof(tab2) + (char*)tab2;\n        printf(\"%s \", bad_ptr == c1 ? \"PASSED\" : \"FAILED\");\n        printf(\"%s \", bad_ptr == c2 ? \"PASSED\" : \"FAILED\");\n\n        int *i1 = tab1[-1];\n        int *i2 = tab2[-1];\n        printf(\"%s \", bad_ptr == i1 ? \"PASSED\" : \"FAILED\");\n        printf(\"%s \", bad_ptr == i2 ? \"PASSED\" : \"FAILED\");\n\n        int *x1 = tab1[size1 * size2 + 1];\n        int *x2 = tab2[10 + 1];\n        printf(\"%s \", bad_ptr == x1 ? \"PASSED\" : \"FAILED\");\n        printf(\"%s \", bad_ptr == x2 ? \"PASSED\" : \"FAILED\");\n    } else {\n        printf(\"PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED \");\n    }\n    printf(\"\\n\");\n#endif\n}\n\ntypedef __SIZE_TYPE__ uintptr_t;\n\nvoid sizeof_test(void)\n{\n    int a;\n    int **ptr;\n\n    printf(\"sizeof(int) = %d\\n\", sizeof(int));\n    printf(\"sizeof(unsigned int) = %d\\n\", sizeof(unsigned int));\n    printf(\"sizeof(long) = %d\\n\", sizeof(long));\n    printf(\"sizeof(unsigned long) = %d\\n\", sizeof(unsigned long));\n    printf(\"sizeof(short) = %d\\n\", sizeof(short));\n    printf(\"sizeof(unsigned short) = %d\\n\", sizeof(unsigned short));\n    printf(\"sizeof(char) = %d\\n\", sizeof(char));\n    printf(\"sizeof(unsigned char) = %d\\n\", sizeof(unsigned char));\n    printf(\"sizeof(func) = %d\\n\", sizeof sizeof_test());\n    a = 1;\n    printf(\"sizeof(a++) = %d\\n\", sizeof a++);\n    printf(\"a=%d\\n\", a);\n    ptr = NULL;\n    printf(\"sizeof(**ptr) = %d\\n\", sizeof (**ptr));\n\n    /* The type of sizeof should be as large as a pointer, actually\n       it should be size_t.  */\n    printf(\"sizeof(sizeof(int) = %d\\n\", sizeof(sizeof(int)));\n    uintptr_t t = 1;\n    uintptr_t t2;\n    /* Effectively <<32, but defined also on 32bit machines.  */\n    t <<= 16;\n    t <<= 16;\n    t++;\n    /* This checks that sizeof really can be used to manipulate \n       uintptr_t objects, without truncation.  */\n    t2 = t & -sizeof(uintptr_t);\n    printf (\"%lu %lu\\n\", t, t2);\n\n    /* some alignof tests */\n    printf(\"__alignof__(int) = %d\\n\", __alignof__(int));\n    printf(\"__alignof__(unsigned int) = %d\\n\", __alignof__(unsigned int));\n    printf(\"__alignof__(short) = %d\\n\", __alignof__(short));\n    printf(\"__alignof__(unsigned short) = %d\\n\", __alignof__(unsigned short));\n    printf(\"__alignof__(char) = %d\\n\", __alignof__(char));\n    printf(\"__alignof__(unsigned char) = %d\\n\", __alignof__(unsigned char));\n    printf(\"__alignof__(func) = %d\\n\", __alignof__ sizeof_test());\n}\n\nvoid typeof_test(void)\n{\n    double a;\n    typeof(a) b;\n    typeof(float) c;\n\n    a = 1.5;\n    b = 2.5;\n    c = 3.5;\n    printf(\"a=%f b=%f c=%f\\n\", a, b, c);\n}\n\nvoid statement_expr_test(void)\n{\n    int a, i;\n\n    a = 0;\n    for(i=0;i<10;i++) {\n        a += 1 + \n            ( { int b, j; \n                b = 0; \n                for(j=0;j<5;j++) \n                    b += j; b; \n            } );\n    }\n    printf(\"a=%d\\n\", a);\n    \n}\n\nvoid local_label_test(void)\n{\n    int a;\n    goto l1;\n l2:\n    a = 1 + ({\n        __label__ l1, l2, l3, l4;\n        goto l1;\n    l4:\n        printf(\"aa1\\n\");\n        goto l3;\n    l2:\n        printf(\"aa3\\n\");\n        goto l4;\n    l1:\n        printf(\"aa2\\n\");\n        goto l2;\n    l3:;\n        1;\n    });\n    printf(\"a=%d\\n\", a);\n    return;\n l4:\n    printf(\"bb1\\n\");\n    goto l2;\n l1:\n    printf(\"bb2\\n\");\n    goto l4;\n}\n\n/* inline assembler test */\n#ifdef __i386__\n\n/* from linux kernel */\nstatic char * strncat1(char * dest,const char * src,size_t count)\n{\nint d0, d1, d2, d3;\n__asm__ __volatile__(\n\t\"repne\\n\\t\"\n\t\"scasb\\n\\t\"\n\t\"decl %1\\n\\t\"\n\t\"movl %8,%3\\n\"\n\t\"1:\\tdecl %3\\n\\t\"\n\t\"js 2f\\n\\t\"\n\t\"lodsb\\n\\t\"\n\t\"stosb\\n\\t\"\n\t\"testb %%al,%%al\\n\\t\"\n\t\"jne 1b\\n\"\n\t\"2:\\txorl %2,%2\\n\\t\"\n\t\"stosb\"\n\t: \"=&S\" (d0), \"=&D\" (d1), \"=&a\" (d2), \"=&c\" (d3)\n\t: \"0\" (src),\"1\" (dest),\"2\" (0),\"3\" (0xffffffff), \"g\" (count)\n\t: \"memory\");\nreturn dest;\n}\n\nstatic char * strncat2(char * dest,const char * src,size_t count)\n{\nint d0, d1, d2, d3;\n__asm__ __volatile__(\n\t\"repne scasb\\n\\t\" /* one-line repne prefix + string op */\n\t\"decl %1\\n\\t\"\n\t\"movl %8,%3\\n\"\n\t\"1:\\tdecl %3\\n\\t\"\n\t\"js 2f\\n\\t\"\n\t\"lodsb\\n\\t\"\n\t\"stosb\\n\\t\"\n\t\"testb %%al,%%al\\n\\t\"\n\t\"jne 1b\\n\"\n\t\"2:\\txorl %2,%2\\n\\t\"\n\t\"stosb\"\n\t: \"=&S\" (d0), \"=&D\" (d1), \"=&a\" (d2), \"=&c\" (d3)\n\t: \"0\" (src),\"1\" (dest),\"2\" (0),\"3\" (0xffffffff), \"g\" (count)\n\t: \"memory\");\nreturn dest;\n}\n\nstatic inline void * memcpy1(void * to, const void * from, size_t n)\n{\nint d0, d1, d2;\n__asm__ __volatile__(\n\t\"rep ; movsl\\n\\t\"\n\t\"testb $2,%b4\\n\\t\"\n\t\"je 1f\\n\\t\"\n\t\"movsw\\n\"\n\t\"1:\\ttestb $1,%b4\\n\\t\"\n\t\"je 2f\\n\\t\"\n\t\"movsb\\n\"\n\t\"2:\"\n\t: \"=&c\" (d0), \"=&D\" (d1), \"=&S\" (d2)\n\t:\"0\" (n/4), \"q\" (n),\"1\" ((long) to),\"2\" ((long) from)\n\t: \"memory\");\nreturn (to);\n}\n\nstatic inline void * memcpy2(void * to, const void * from, size_t n)\n{\nint d0, d1, d2;\n__asm__ __volatile__(\n\t\"rep movsl\\n\\t\"  /* one-line rep prefix + string op */\n\t\"testb $2,%b4\\n\\t\"\n\t\"je 1f\\n\\t\"\n\t\"movsw\\n\"\n\t\"1:\\ttestb $1,%b4\\n\\t\"\n\t\"je 2f\\n\\t\"\n\t\"movsb\\n\"\n\t\"2:\"\n\t: \"=&c\" (d0), \"=&D\" (d1), \"=&S\" (d2)\n\t:\"0\" (n/4), \"q\" (n),\"1\" ((long) to),\"2\" ((long) from)\n\t: \"memory\");\nreturn (to);\n}\n\nstatic __inline__ void sigaddset1(unsigned int *set, int _sig)\n{\n\t__asm__(\"btsl %1,%0\" : \"=m\"(*set) : \"Ir\"(_sig - 1) : \"cc\");\n}\n\nstatic __inline__ void sigdelset1(unsigned int *set, int _sig)\n{\n\tasm(\"btrl %1,%0\" : \"=m\"(*set) : \"Ir\"(_sig - 1) : \"cc\");\n}\n\nstatic __inline__ __const__ unsigned int swab32(unsigned int x)\n{\n\t__asm__(\"xchgb %b0,%h0\\n\\t\"\t/* swap lower bytes\t*/\n\t\t\"rorl $16,%0\\n\\t\"\t/* swap words\t\t*/\n\t\t\"xchgb %b0,%h0\"\t\t/* swap higher bytes\t*/\n\t\t:\"=q\" (x)\n\t\t: \"0\" (x));\n\treturn x;\n}\n\nstatic __inline__ unsigned long long mul64(unsigned int a, unsigned int b)\n{\n    unsigned long long res;\n    __asm__(\"mull %2\" : \"=A\" (res) : \"a\" (a), \"r\" (b));\n    return res;\n}\n\nstatic __inline__ unsigned long long inc64(unsigned long long a)\n{\n    unsigned long long res;\n    __asm__(\"addl $1, %%eax ; adcl $0, %%edx\" : \"=A\" (res) : \"A\" (a));\n    return res;\n}\n\nunsigned int set;\n\nvoid asm_test(void)\n{\n    char buf[128];\n    unsigned int val;\n\n    printf(\"inline asm:\\n\");\n    /* test the no operand case */\n    asm volatile (\"xorl %eax, %eax\");\n\n    memcpy1(buf, \"hello\", 6);\n    strncat1(buf, \" worldXXXXX\", 3);\n    printf(\"%s\\n\", buf);\n\n    memcpy2(buf, \"hello\", 6);\n    strncat2(buf, \" worldXXXXX\", 3);\n    printf(\"%s\\n\", buf);\n\n    /* 'A' constraint test */\n    printf(\"mul64=0x%Lx\\n\", mul64(0x12345678, 0xabcd1234));\n    printf(\"inc64=0x%Lx\\n\", inc64(0x12345678ffffffff));\n\n    set = 0xff;\n    sigdelset1(&set, 2);\n    sigaddset1(&set, 16);\n    /* NOTE: we test here if C labels are correctly restored after the\n       asm statement */\n    goto label1;\n label2:\n    __asm__(\"btsl %1,%0\" : \"=m\"(set) : \"Ir\"(20) : \"cc\");\n#ifdef __GNUC__ // works strange with GCC 4.3\n    set=0x1080fd;\n#endif\n    printf(\"set=0x%x\\n\", set);\n    val = 0x01020304;\n    printf(\"swab32(0x%08x) = 0x%0x\\n\", val, swab32(val));\n    return;\n label1:\n    goto label2;\n}\n\n#else\n\nvoid asm_test(void)\n{\n}\n\n#endif\n\n#define COMPAT_TYPE(type1, type2) \\\n{\\\n    printf(\"__builtin_types_compatible_p(%s, %s) = %d\\n\", #type1, #type2, \\\n           __builtin_types_compatible_p (type1, type2));\\\n}\n\nint constant_p_var;\n\nvoid builtin_test(void)\n{\n#if GCC_MAJOR >= 3\n    COMPAT_TYPE(int, int);\n    COMPAT_TYPE(int, unsigned int);\n    COMPAT_TYPE(int, char);\n    COMPAT_TYPE(int, const int);\n    COMPAT_TYPE(int, volatile int);\n    COMPAT_TYPE(int *, int *);\n    COMPAT_TYPE(int *, void *);\n    COMPAT_TYPE(int *, const int *);\n    COMPAT_TYPE(char *, unsigned char *);\n/* space is needed because tcc preprocessor introduces a space between each token */\n    COMPAT_TYPE(char * *, void *); \n#endif\n    printf(\"res = %d\\n\", __builtin_constant_p(1));\n    printf(\"res = %d\\n\", __builtin_constant_p(1 + 2));\n    printf(\"res = %d\\n\", __builtin_constant_p(&constant_p_var));\n    printf(\"res = %d\\n\", __builtin_constant_p(constant_p_var));\n}\n\n#ifndef _WIN32\nextern int __attribute__((weak)) weak_f1(void);\nextern int __attribute__((weak)) weak_f2(void);\nextern int                       weak_f3(void);\nextern int __attribute__((weak)) weak_v1;\nextern int __attribute__((weak)) weak_v2;\nextern int                       weak_v3;\n\nextern int                           (*weak_fpa)() __attribute__((weak));\nextern int __attribute__((weak))     (*weak_fpb)();\nextern     __attribute__((weak)) int (*weak_fpc)();\n\nextern int                     weak_asm_f1(void) asm(\"weak_asm_f1x\") __attribute((weak));\nextern int __attribute((weak)) weak_asm_f2(void) asm(\"weak_asm_f2x\")                    ;\nextern int __attribute((weak)) weak_asm_f3(void) asm(\"weak_asm_f3x\") __attribute((weak));\nextern int                     weak_asm_v1       asm(\"weak_asm_v1x\") __attribute((weak));\nextern int __attribute((weak)) weak_asm_v2       asm(\"weak_asm_v2x\")                    ;\nextern int __attribute((weak)) weak_asm_v3(void) asm(\"weak_asm_v3x\") __attribute((weak));\n\nstatic const size_t dummy = 0;\nextern __typeof(dummy) weak_dummy1 __attribute__((weak, alias(\"dummy\")));\nextern __typeof(dummy) __attribute__((weak, alias(\"dummy\"))) weak_dummy2;\nextern __attribute__((weak, alias(\"dummy\"))) __typeof(dummy) weak_dummy3;\n\nint some_lib_func(void);\nint dummy_impl_of_slf(void) { return 444; }\nint some_lib_func(void) __attribute__((weak, alias(\"dummy_impl_of_slf\")));\n\nint weak_toolate() __attribute__((weak));\nint weak_toolate() { return 0; }\n\nvoid __attribute__((weak)) weak_test(void)\n{\n\tprintf(\"weak_f1=%d\\n\", weak_f1 ? weak_f1() : 123);\n\tprintf(\"weak_f2=%d\\n\", weak_f2 ? weak_f2() : 123);\n\tprintf(\"weak_f3=%d\\n\", weak_f3 ? weak_f3() : 123);\n\tprintf(\"weak_v1=%d\\n\",&weak_v1 ? weak_v1   : 123);\n\tprintf(\"weak_v2=%d\\n\",&weak_v2 ? weak_v2   : 123);\n\tprintf(\"weak_v3=%d\\n\",&weak_v3 ? weak_v3   : 123);\n\n\tprintf(\"weak_fpa=%d\\n\",&weak_fpa ? weak_fpa() : 123);\n\tprintf(\"weak_fpb=%d\\n\",&weak_fpb ? weak_fpb() : 123);\n\tprintf(\"weak_fpc=%d\\n\",&weak_fpc ? weak_fpc() : 123);\n\t\n\tprintf(\"weak_asm_f1=%d\\n\", weak_asm_f1 != NULL);\n\tprintf(\"weak_asm_f2=%d\\n\", weak_asm_f2 != NULL);\n\tprintf(\"weak_asm_f3=%d\\n\", weak_asm_f3 != NULL);\n\tprintf(\"weak_asm_v1=%d\\n\",&weak_asm_v1 != NULL);\n\tprintf(\"weak_asm_v2=%d\\n\",&weak_asm_v2 != NULL);\n\tprintf(\"weak_asm_v3=%d\\n\",&weak_asm_v3 != NULL);\n}\n\nint __attribute__((weak)) weak_f2() { return 222; }\nint __attribute__((weak)) weak_f3() { return 333; }\nint __attribute__((weak)) weak_v2 = 222;\nint __attribute__((weak)) weak_v3 = 333;\n#endif\n\nvoid const_func(const int a)\n{\n}\n\nvoid const_warn_test(void)\n{\n    const_func(1);\n}\n\nstruct condstruct {\n  int i;\n};\n\nint getme (struct condstruct *s, int i)\n{\n  int i1 = (i == 0 ? 0 : s)->i;\n  int i2 = (i == 0 ? s : 0)->i;\n  int i3 = (i == 0 ? (void*)0 : s)->i;\n  int i4 = (i == 0 ? s : (void*)0)->i;\n  return i1 + i2 + i3 + i4;\n}\n\nstruct global_data\n{\n  int a[40];\n  int *b[40];\n};\n\nstruct global_data global_data;\n\nint global_data_getstuff (int *, int);\n\nvoid global_data_callit (int i)\n{\n  *global_data.b[i] = global_data_getstuff (global_data.b[i], 1);\n}\n\nint global_data_getstuff (int *p, int i)\n{\n  return *p + i;\n}\n\nvoid global_data_test (void)\n{\n  global_data.a[0] = 42;\n  global_data.b[0] = &global_data.a[0];\n  global_data_callit (0);\n  printf (\"%d\\n\", global_data.a[0]);\n}\n\nstruct cmpcmpS\n{\n  unsigned char fill : 3;\n  unsigned char b1 : 1;\n  unsigned char b2 : 1;\n  unsigned char fill2 : 3;\n};\n\nint glob1, glob2, glob3;\n\nvoid compare_comparisons (struct cmpcmpS *s)\n{\n  if (s->b1 != (glob1 == glob2)\n      || (s->b2 != (glob1 == glob3)))\n    printf (\"comparing comparisons broken\\n\");\n}\n\nvoid cmp_comparison_test(void)\n{\n  struct cmpcmpS s;\n  s.b1 = 1;\n  glob1 = 42; glob2 = 42;\n  s.b2 = 0;\n  glob3 = 43;\n  compare_comparisons (&s);\n}\n\nint fcompare (double a, double b, int code)\n{\n  switch (code) {\n    case 0: return a == b;\n    case 1: return a != b;\n    case 2: return a < b;\n    case 3: return a >= b;\n    case 4: return a > b;\n    case 5: return a <= b;\n  }\n}\n\nvoid math_cmp_test(void)\n{\n  double nan = 0.0/0.0;\n  double one = 1.0;\n  double two = 2.0;\n  int comp = 0;\n#define bug(a,b,op,iop,part) printf(\"Test broken: %s %s %s %s %d\\n\", #a, #b, #op, #iop, part)\n\n  /* This asserts that \"a op b\" is _not_ true, but \"a iop b\" is true.\n     And it does this in various ways so that all code generation paths\n     are checked (generating inverted tests, or non-inverted tests, or\n     producing a 0/1 value without jumps (that's done in the fcompare\n     function).  */\n#define FCMP(a,b,op,iop,code) \\\n  if (fcompare (a,b,code))    \\\n    bug (a,b,op,iop,1); \\\n  if (a op b) \\\n    bug (a,b,op,iop,2); \\\n  if (a iop b) \\\n    ; \\\n  else \\\n    bug (a,b,op,iop,3); \\\n  if ((a op b) || comp) \\\n    bug (a,b,op,iop,4); \\\n  if ((a iop b) || comp) \\\n    ; \\\n  else \\\n    bug (a,b,op,iop,5);\n\n  /* Equality tests.  */\n  FCMP(nan, nan, ==, !=, 0);\n  FCMP(one, two, ==, !=, 0);\n  FCMP(one, one, !=, ==, 1);\n  /* Non-equality is a bit special.  */\n  if (!fcompare (nan, nan, 1))\n    bug (nan, nan, !=, ==, 6);\n\n  /* Relational tests on numbers.  */\n  FCMP(two, one, <, >=, 2);\n  FCMP(one, two, >=, <, 3);\n  FCMP(one, two, >, <=, 4);\n  FCMP(two, one, <=, >, 5);\n\n  /* Relational tests on NaNs.  Note that the inverse op here is\n     always !=, there's no operator in C that is equivalent to !(a < b),\n     when NaNs are involved, same for the other relational ops.  */\n  FCMP(nan, nan, <, !=, 2);\n  FCMP(nan, nan, >=, !=, 3);\n  FCMP(nan, nan, >, !=, 4);\n  FCMP(nan, nan, <=, !=, 5);\n}\n\ndouble get100 () { return 100.0; }\n\nvoid callsave_test(void)\n{\n#if defined __i386__ || defined __x86_64__\n  int i, s; double *d; double t;\n  s = sizeof (double);\n  printf (\"callsavetest: %d\\n\", s);\n  d = alloca (sizeof(double));\n  d[0] = 10.0;\n  /* x86-64 had a bug were the next call to get100 would evict\n     the lvalue &d[0] as VT_LLOCAL, and the reload would be done\n     in int type, not pointer type.  When alloca returns a pointer\n     with the high 32 bit set (which is likely on x86-64) the access\n     generates a segfault.  */\n  i = d[0] > get100 ();\n  printf (\"%d\\n\", i);\n#endif\n}\n\n\nvoid bfa3(ptrdiff_t str_offset)\n{\n    printf(\"bfa3: %s\\n\", (char *)__builtin_frame_address(3) + str_offset);\n}\nvoid bfa2(ptrdiff_t str_offset)\n{\n    printf(\"bfa2: %s\\n\", (char *)__builtin_frame_address(2) + str_offset);\n    bfa3(str_offset);\n}\nvoid bfa1(ptrdiff_t str_offset)\n{\n    printf(\"bfa1: %s\\n\", (char *)__builtin_frame_address(1) + str_offset);\n#if defined(__arm__) && !defined(__GNUC__)\n    bfa2(str_offset);\n#endif\n}\n\nvoid builtin_frame_address_test(void)\n{\n    char str[] = \"__builtin_frame_address\";\n    char *fp0 = __builtin_frame_address(0);\n\n    printf(\"str: %s\\n\", str);\n    bfa1(str-fp0);\n}\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/test.out3",
    "content": "string:\nab3c\nABC:\nc=r\nwc=a 0x1234 c\nfoo1_string='bar\ntesta'\ntest\n!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\nfib=3524578\n262144\n524288\n1048576\n2097152\n4194304\n8388608\n16777216\n33554432\n67108864\n134217728\n268435456\n536870912\n1073741824\n1\n-1\n-31232132\n-7808033\n-13\n2\n5\n13\n1\n16\n22322\n22319\n6964152\n5580\n-5580\n1073736243\n1\n-1\n15\n0\n22326\n22329\n2790\n-2791\n536868121\n357136\n-22322\n-22321\n22321\n13\n10\n3744\n3\n12\n4\n11\n12\n3\n192\n-13\n-12\n12\n1 1 1 0\nmacro:\nN=1236\naaa=4\nmin=-1\ns1=hello\ns2=hello, world\ns3=\"c\"\ns4=a1\nB3=1\nonetwothree=123\nA defined\nA defined\nB not defined\nA defined\nB1 not defined\ntest true1\ntest trueA\ntest 2\n__LINE__ defined\n__LINE__=235 __FILE__=tcctest.c\n__LINE__=201 __FILE__=tcctest.c\n__LINE__=204 __FILE__=test\n__func__ = macro_test\nvaarg=1\nvaarg1\nvaarg1=2\nvaarg1=1 2\nfunc='macro_test'\nINT64_MIN=-9223372036854775808\na=2\na=8\nhi\ntralala\nhi\nqq=42\nqq1=1\n43\nfn tcctest.c, line 302, num 123\nfn tcctest.c, line 303, num 123\nfn tcctest.c, line 304, num 123\nrm_field = 0\nrm_field = 0\nrm_field = 0 0\nscope:\ng1=1\ng2=2\ng3=3\ng4=4\ng5=2\nforward:\nforward ok\nforward ok\nfuncptr:\n12345\n12345\n12346\nsizeof1 = 1\nsizeof2 = 1\nsizeof3 = 8\nsizeof4 = 8\n0123456789\n0123456789\n0123456789\ncount=1\ncount=2\ncount = 123\n12456\n12456\n012456789\naa2b4567ccccc1314\ngoto:\n0123456789\nlabel1\nlabel2\nlabel3\nenum:\n0 2 4 5 6 1000\nb1=1\ntypedef:\na=1234\nmytype2=2\nstruct:\nsizes: 20 8 4 4\nst1: 1 2 3\nunion1: 2\nunion2: 2\nst2: 3 2 1\nstr_addr=10\naligntest1 sizeof=10 alignof=1\naligntest2 sizeof=16 alignof=4\naligntest3 sizeof=16 alignof=8\naligntest4 sizeof=0 alignof=8\nsizeof(struct empty) = 0\nalignof(struct empty) = 1\narray:\nsizeof(a) = 16\nsizeof(\"a\") = 2\nsizeof(__func__) = 11\nsizeof tab 12\nsizeof tab2 24\n1 2 3\n   0   1  10  11  20  21\nsizeof(size_t)=8\nsizeof(ptrdiff_t)=8\nexpr_ptr:\ndiff=10\ninc=1\ndec=0\ninc=1\ndec=0\nadd=3\nadd=3\n0xfffffffffffffffc (nil) 1\n0 1 1 1 0 0\n0xfffffffffffffffc 0xffffffffc0000000 -268435455\n0 1 1 1 0 0\n0xfffffffffffffffc 0xb0000000 738197505\n0 1 1 1 0 0\n0xfffffffffffffffc 0x470000000 4764729345\n0 1 1 1 0 0\n42\n!s=1\na=1\na=0 1 1\na=0 0 1\na=1 0\na1\na2\na4\nb=6\na=400\nexp=1\nr=1\naspect=65535\naspect=65536\n34 -1\n60 31\nexpr2:\nres= 112 2\nconstant_expr:\n48\n3\n3\nconstant_expr:\n1\n0\n1\n1\n1\n1\n1\n1\n0\n0\n1\n0\n1\n0\nchar_short:\ns8=4 -4\nu8=4 252\ns16=772 -516\nu16=772 65020\ns32=16909060 -66052\nu32=16909060 -66052\nvar1=1020308\nvar1=1020809\nvar1=8090a0b\ninit_test:\nsinit1=2\nsinit2=3\nsinit3=12 1 2 3\nsinit6=12\nsinit7=12 1 2 3\nsinit8=hellotrala\nsinit9=1 2 3\nsinit10=1 2 3\nsinit11=1 2 3 10 11 12\n[0][0] = 1 1 1\n[0][1] = 2 2 2\n[1][0] = 3 3 3\n[1][1] = 4 4 4\n[2][0] = 5 5 5\n[2][1] = 6 6 6\nlinit1=2\nlinit2=3\nlinit6=12\nlinit8=11 hellotrala\nsinit12=hello world\nsinit13=24 test1 test2 test3\nsinit14=abc\n 1 2 0 0 0 0 0 0 0 0\n 1 2 0 4 0 0 0 3 0 0\n 97 98 99 0 0 0 0 0 0 0\n 2 3 0 0 0 0 4 0 0 0\n1 0 2 0\nlinit17=4\nsinit15=12\nsinit16=1 2\nsinit17=a1 4 a2 1\n0 0 14 14 14 14 2 0 a 0 \ncix: 2000 2001 2002 2003 2003 0 0\ncix2: 3003 4006\nsizeof cix20 4, cix21 4, sizeof cix22 4\ncompound_test:\n 1 2 3\n321\nq1=tralala1\nq2=tralala2\nq3=tralala2\nq4=tralala3\n 1 2 3\n1 2 4\n1 2 5\n1 2 6\nkr_test:\nfunc1=7\nfunc2=7\n1 2 3 4.500000\nbefore call: 1 2\nafter call: 5 -2\n1\ncast_test:\n-1 -1 255 65535\n-1 -1 255 65535\n-1 -1 255 65535\n-127\n1\nsizeof(c) = 1, sizeof((int)c) = 4\n((unsigned)(short)0x0000f000) = 0xfffff000\n((unsigned)(char)0x0000f0f0) = 0xfffffff0\n1 2\nsizeof(+(char)'a') = 4\nsizeof(-(char)'a') = 4\nsizeof(~(char)'a') = 4\n-66 -66 -123145302310978 -123145302310978 -123145302310978 -123145302310978\n0x1 0xf0f0 (nil) 0xfffffff0\nbitfield_test:sizeof(st1) = 8\n3 -1 15 -8 121\n121 121\nst1.f1 == -1\nst1.f2 == -1\n4886718345 4026531841 120\nbool_test:\nsizeof(_Bool) = 1\ncast: 1 0 1\nb = 1\nb = 1\nfloat_test:\nsizeof(float) = 4\nsizeof(double) = 8\nsizeof(long double) = 16\ntesting 'float'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600006 234.600006\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600098 -2334.600098\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123455\nlong double: 42.123455\nstrtof: 1.200000\ntesting 'double'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600000 234.600000\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600000 -2334.600000\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123457\nlong double: 42.123457\nstrtod: 1.200000\ntesting 'long double'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600000 234.600000\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600000 -2334.600000\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123457\nlong double: 42.123457\nstrtold: 1.200000\n1.200000 3.400000 -5.600000\n2.120000 0.500000 23000000000.000000\nda=123.000000\nfa=123.000000\nda = -294967296.000000\ndb = 4000000000.000000\nlonglong_test:\nsizeof(long long) = 8\n-1 4294967294\n1 -2 1 1234567812345679\n-6\narith: 1023 977 23000\narith1: 43 11\nbin: 0 1023 1023\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: 1001 24\narith2: 1001 24\narith2: 1001 24\narith2: 1001 24\nnot: 0 0 1 1\narith: 4915 -4405 1188300\narith1: 0 255\nbin: 52 4863 4811\ntest: 0 1 1 0 0 1\nutest: 0 1 1 0 0 1\narith2: 256 4661\narith2: 256 4661\narith2: 256 4661\narith2: 256 4661\nnot: 0 0 1 1\narith: -782639107 782639101 2347917312\narith1: 0 -3\nbin: -782639104 -3 782639101\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: -2 -782639103\narith2: -2 -782639103\narith2: -2 -782639103\narith2: -2 -782639103\nnot: 0 0 1 1\nshift: 9 9 9312\nshiftc: 36 36 2328\nshiftc: 0 0 9998683865088\nshift: 576460752303423487 -1 -736\nshiftc: 2305843009213693949 -3 -184\nshiftc: 536870911 -1 -790273982464\nshift: 0 0 -1152921504606846976\nshiftc: 245252176896 245252176896 15696139321344\nshiftc: 57 57 -8444530776296390656\nla=320255972942661 ula=16458594985017606144\nlltof: 320255981256704.000000 320255972942661.000000 320255972942661.000000\nftoll: 320255981256704 320255972942661 320255972942661\nulltof: 16458595053737082880.000000 16458594985017606144.000000 16458594985017606144.000000\nftoull: 16458595053737082880 16458594985017606144 16458594985017606144\n12345677\n3\narith: 2147483648 2147483648 0\nbin: 0 2147483648 2147483648\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: 2147483649 1\narith2: 2147483649 1\narith2: 2147483649 1\narith2: 2147483649 1\nnot: 0 0 1 1\n2\n1 0 1 0\n4886718345\nmanyarg_test:\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1234567891234.000000 1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1 2 3\n1.000000 2 3.000000\n1234567891234 987654321986 3 1234.000000\n1.200000 2.300000 3.400000\n1 1.200000 3 4.500000 6 7.800000 9 0.100000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1234567891234.000000 1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1 2 3 4 5 6 7 8 1234567891234.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000 1234567891234.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234.000000 1234567891234 987654321986 42.000000 43.000000 1234567891234.000000\nstdarg_for_struct: 42 42 42 42\nwhitspace:\nN=2\naaa=3\nmin=4\n*rel1=2\n*rel2=3\na=1 b=2 b=3.000000\ncmpfn=0\ncmpfn=0\nalloca: p is 123456789012345\nalloca: This is only a test.\n\nTest C99 VLA 1 (sizeof): PASSED\nTest C99 VLA 2 (ptrs substract): PASSED\nTest C99 VLA 3 (ptr add): PASSED\nTest C99 VLA 4 (ptr access): PASSED\nTest C99 VLA 5 (bounds checking (might be disabled)): PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED \nsizeof(int) = 4\nsizeof(unsigned int) = 4\nsizeof(long) = 8\nsizeof(unsigned long) = 8\nsizeof(short) = 2\nsizeof(unsigned short) = 2\nsizeof(char) = 1\nsizeof(unsigned char) = 1\nsizeof(func) = 1\nsizeof(a++) = 4\na=1\nsizeof(**ptr) = 4\nsizeof(sizeof(int) = 8\n4294967297 4294967296\n__alignof__(int) = 4\n__alignof__(unsigned int) = 4\n__alignof__(short) = 2\n__alignof__(unsigned short) = 2\n__alignof__(char) = 1\n__alignof__(unsigned char) = 1\n__alignof__(func) = 1\na=1.500000 b=2.500000 c=3.500000\na=110\nbb2\nbb1\naa2\naa3\naa1\na=2\n__builtin_types_compatible_p(int, int) = 1\n__builtin_types_compatible_p(int, unsigned int) = 0\n__builtin_types_compatible_p(int, char) = 0\n__builtin_types_compatible_p(int, const int) = 1\n__builtin_types_compatible_p(int, volatile int) = 1\n__builtin_types_compatible_p(int *, int *) = 1\n__builtin_types_compatible_p(int *, void *) = 0\n__builtin_types_compatible_p(int *, const int *) = 0\n__builtin_types_compatible_p(char *, unsigned char *) = 0\n__builtin_types_compatible_p(char * *, void *) = 0\nres = 1\nres = 1\nres = 0\nres = 0\nweak_f1=123\nweak_f2=222\nweak_f3=333\nweak_v1=123\nweak_v2=222\nweak_v3=333\nweak_fpa=123\nweak_fpb=123\nweak_fpc=123\nweak_asm_f1=0\nweak_asm_f2=0\nweak_asm_f3=0\nweak_asm_v1=0\nweak_asm_v2=0\nweak_asm_v3=0\n43\ncallsavetest: 8\n0\nstr: __builtin_frame_address\nbfa1: __builtin_frame_address\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/test.ref",
    "content": "string:\nab3c\nABC:\nc=r\nwc=a 0x1234 c\nfoo1_string='bar\ntesta'\ntest\n!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\nfib=3524578\n262144\n524288\n1048576\n2097152\n4194304\n8388608\n16777216\n33554432\n67108864\n134217728\n268435456\n536870912\n1073741824\n1\n-1\n-31232132\n-7808033\n-13\n2\n5\n13\n1\n16\n22322\n22319\n6964152\n5580\n-5580\n1073736243\n1\n-1\n15\n0\n22326\n22329\n2790\n-2791\n536868121\n357136\n-22322\n-22321\n22321\n13\n10\n3744\n3\n12\n4\n11\n12\n3\n192\n-13\n-12\n12\n1 1 1 0\nmacro:\nN=1236\naaa=4\nmin=-1\ns1=hello\ns2=hello, world\ns3=\"c\"\ns4=a1\nB3=1\nonetwothree=123\nA defined\nA defined\nB not defined\nA defined\nB1 not defined\ntest true1\ntest trueA\ntest 2\n__LINE__ defined\n__LINE__=235 __FILE__=tcctest.c\n__LINE__=201 __FILE__=tcctest.c\n__LINE__=204 __FILE__=test\n__func__ = macro_test\nvaarg=1\nvaarg1\nvaarg1=2\nvaarg1=1 2\nfunc='macro_test'\nINT64_MIN=-9223372036854775808\na=2\na=8\nhi\ntralala\nhi\nqq=42\nqq1=1\n43\nfn tcctest.c, line 302, num 123\nfn tcctest.c, line 303, num 123\nfn tcctest.c, line 304, num 123\nrm_field = 0\nrm_field = 0\nrm_field = 0 0\nscope:\ng1=1\ng2=2\ng3=3\ng4=4\ng5=2\nforward:\nforward ok\nforward ok\nfuncptr:\n12345\n12345\n12346\nsizeof1 = 1\nsizeof2 = 1\nsizeof3 = 8\nsizeof4 = 8\n0123456789\n0123456789\n0123456789\ncount=1\ncount=2\ncount = 123\n12456\n12456\n012456789\naa2b4567ccccc1314\ngoto:\n0123456789\nlabel1\nlabel2\nlabel3\nenum:\n0 2 4 5 6 1000\nb1=1\ntypedef:\na=1234\nmytype2=2\nstruct:\nsizes: 20 8 4 4\nst1: 1 2 3\nunion1: 2\nunion2: 2\nst2: 3 2 1\nstr_addr=10\naligntest1 sizeof=10 alignof=1\naligntest2 sizeof=16 alignof=4\naligntest3 sizeof=16 alignof=8\naligntest4 sizeof=0 alignof=8\nsizeof(struct empty) = 0\nalignof(struct empty) = 1\narray:\nsizeof(a) = 16\nsizeof(\"a\") = 2\nsizeof(__func__) = 11\nsizeof tab 12\nsizeof tab2 24\n1 2 3\n   0   1  10  11  20  21\nsizeof(size_t)=8\nsizeof(ptrdiff_t)=8\nexpr_ptr:\ndiff=10\ninc=1\ndec=0\ninc=1\ndec=0\nadd=3\nadd=3\n0xfffffffffffffffc (nil) 1\n0 1 1 1 0 0\n0xfffffffffffffffc 0xffffffffc0000000 -268435455\n0 1 1 1 0 0\n0xfffffffffffffffc 0xb0000000 738197505\n0 1 1 1 0 0\n0xfffffffffffffffc 0x470000000 4764729345\n0 1 1 1 0 0\n42\n!s=1\na=1\na=0 1 1\na=0 0 1\na=1 0\na1\na2\na4\nb=6\na=400\nexp=1\nr=1\naspect=65535\naspect=65536\n34 -1\n60 31\nexpr2:\nres= 112 2\nconstant_expr:\n48\n3\n3\nconstant_expr:\n1\n0\n1\n1\n1\n1\n1\n1\n0\n0\n1\n0\n1\n0\nchar_short:\ns8=4 -4\nu8=4 252\ns16=772 -516\nu16=772 65020\ns32=16909060 -66052\nu32=16909060 -66052\nvar1=1020308\nvar1=1020809\nvar1=8090a0b\ninit_test:\nsinit1=2\nsinit2=3\nsinit3=12 1 2 3\nsinit6=12\nsinit7=12 1 2 3\nsinit8=hellotrala\nsinit9=1 2 3\nsinit10=1 2 3\nsinit11=1 2 3 10 11 12\n[0][0] = 1 1 1\n[0][1] = 2 2 2\n[1][0] = 3 3 3\n[1][1] = 4 4 4\n[2][0] = 5 5 5\n[2][1] = 6 6 6\nlinit1=2\nlinit2=3\nlinit6=12\nlinit8=11 hellotrala\nsinit12=hello world\nsinit13=24 test1 test2 test3\nsinit14=abc\n 1 2 0 0 0 0 0 0 0 0\n 1 2 0 4 0 0 0 3 0 0\n 97 98 99 0 0 0 0 0 0 0\n 2 3 0 0 0 0 4 0 0 0\n1 0 2 0\nlinit17=4\nsinit15=12\nsinit16=1 2\nsinit17=a1 4 a2 1\n0 0 14 14 14 14 2 0 a 0 \ncix: 2000 2001 2002 2003 2003 0 0\ncix2: 3003 4006\nsizeof cix20 4, cix21 4, sizeof cix22 4\ncompound_test:\n 1 2 3\n321\nq1=tralala1\nq2=tralala2\nq3=tralala2\nq4=tralala3\n 1 2 3\n1 2 4\n1 2 5\n1 2 6\nkr_test:\nfunc1=7\nfunc2=7\n1 2 3 4.500000\nbefore call: 1 2\nafter call: 5 -2\n1\ncast_test:\n-1 -1 255 65535\n-1 -1 255 65535\n-1 -1 255 65535\n-127\n1\nsizeof(c) = 1, sizeof((int)c) = 4\n((unsigned)(short)0x0000f000) = 0xfffff000\n((unsigned)(char)0x0000f0f0) = 0xfffffff0\n1 2\nsizeof(+(char)'a') = 4\nsizeof(-(char)'a') = 4\nsizeof(~(char)'a') = 4\n-66 -66 -123145302310978 -123145302310978 -123145302310978 -123145302310978\n0x1 0xf0f0 (nil) 0xfffffff0\nbitfield_test:sizeof(st1) = 8\n3 -1 15 -8 121\n121 121\nst1.f1 == -1\nst1.f2 == -1\n4886718345 4026531841 120\nbool_test:\nsizeof(_Bool) = 1\ncast: 1 0 1\nb = 1\nb = 1\nfloat_test:\nsizeof(float) = 4\nsizeof(double) = 8\nsizeof(long double) = 16\ntesting 'float'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600006 234.600006\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600098 -2334.600098\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123455\nlong double: 42.123455\nstrtof: 1.200000\ntesting 'double'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600000 234.600000\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600000 -2334.600000\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123457\nlong double: 42.123457\nstrtod: 1.200000\ntesting 'long double'\n0 1 1 0 0 1\n1.000000 2.500000 3.500000 -1.500000 2.500000 0.400000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\n0 1 0 1 1 0\n2.000000 1.500000 3.500000 0.500000 3.000000 1.333333 -2.000000\n3.000000\n3.000000\n4.000000\n0 1\n1 0 0 0 1 1\n1.000000 1.000000 2.000000 0.000000 1.000000 1.000000 -1.000000\n2.000000\n2.000000\n3.000000\n0 1\nftof: 234.600006 234.600000 234.600000\nftoi: 234 234\nitof: -1234.000000\nutof: 2166572288.000000\nftof: -2334.600098 -2334.600000 -2334.600000\nftoi: -2334 4294964962\nitof: -1234.000000\nutof: 2166572288.000000\nfloat: 42.123455\ndouble: 42.123457\nlong double: 42.123457\nstrtold: 1.200000\n1.200000 3.400000 -5.600000\n2.120000 0.500000 23000000000.000000\nda=123.000000\nfa=123.000000\nda = -294967296.000000\ndb = 4000000000.000000\nlonglong_test:\nsizeof(long long) = 8\n-1 4294967294\n1 -2 1 1234567812345679\n-6\narith: 1023 977 23000\narith1: 43 11\nbin: 0 1023 1023\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: 1001 24\narith2: 1001 24\narith2: 1001 24\narith2: 1001 24\nnot: 0 0 1 1\narith: 4915 -4405 1188300\narith1: 0 255\nbin: 52 4863 4811\ntest: 0 1 1 0 0 1\nutest: 0 1 1 0 0 1\narith2: 256 4661\narith2: 256 4661\narith2: 256 4661\narith2: 256 4661\nnot: 0 0 1 1\narith: -782639107 782639101 2347917312\narith1: 0 -3\nbin: -782639104 -3 782639101\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: -2 -782639103\narith2: -2 -782639103\narith2: -2 -782639103\narith2: -2 -782639103\nnot: 0 0 1 1\nshift: 9 9 9312\nshiftc: 36 36 2328\nshiftc: 0 0 9998683865088\nshift: 576460752303423487 -1 -736\nshiftc: 2305843009213693949 -3 -184\nshiftc: 536870911 -1 -790273982464\nshift: 0 0 -1152921504606846976\nshiftc: 245252176896 245252176896 15696139321344\nshiftc: 57 57 -8444530776296390656\nla=320255972942661 ula=16458594985017606144\nlltof: 320255981256704.000000 320255972942661.000000 320255972942661.000000\nftoll: 320255981256704 320255972942661 320255972942661\nulltof: 16458595053737082880.000000 16458594985017606144.000000 16458594985017606144.000000\nftoull: 16458595053737082880 16458594985017606144 16458594985017606144\n12345677\n3\narith: 2147483648 2147483648 0\nbin: 0 2147483648 2147483648\ntest: 0 1 0 1 1 0\nutest: 0 1 0 1 1 0\narith2: 2147483649 1\narith2: 2147483649 1\narith2: 2147483649 1\narith2: 2147483649 1\nnot: 0 0 1 1\n2\n1 0 1 0\n4886718345\nmanyarg_test:\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1234567891234.000000 1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1 2 3\n1.000000 2 3.000000\n1234567891234 987654321986 3 1234.000000\n1.200000 2.300000 3.400000\n1 1.200000 3 4.500000 6 7.800000 9 0.100000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1234567891234.000000 1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000\n1 2 3 4 5 6 7 8 1234567891234.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234 987654321986 42.000000 43.000000 1234567891234.000000\n1 2 3 4 5 6 7 8 0.100000 1.200000 2.300000 3.400000 4.500000 5.600000 6.700000 7.800000 8.900000 9.000000 1234567891234.000000 1234567891234 987654321986 42.000000 43.000000 1234567891234.000000\nstdarg_for_struct: 42 42 42 42\nwhitspace:\nN=2\naaa=3\nmin=4\n*rel1=2\n*rel2=3\na=1 b=2 b=3.000000\ncmpfn=0\ncmpfn=0\nalloca: p is 123456789012345\nalloca: This is only a test.\n\nTest C99 VLA 1 (sizeof): PASSED\nTest C99 VLA 2 (ptrs substract): PASSED\nTest C99 VLA 3 (ptr add): PASSED\nTest C99 VLA 4 (ptr access): PASSED\nTest C99 VLA 5 (bounds checking (might be disabled)): PASSED PASSED PASSED PASSED PASSED PASSED PASSED PASSED \nsizeof(int) = 4\nsizeof(unsigned int) = 4\nsizeof(long) = 8\nsizeof(unsigned long) = 8\nsizeof(short) = 2\nsizeof(unsigned short) = 2\nsizeof(char) = 1\nsizeof(unsigned char) = 1\nsizeof(func) = 1\nsizeof(a++) = 4\na=1\nsizeof(**ptr) = 4\nsizeof(sizeof(int) = 8\n4294967297 4294967296\n__alignof__(int) = 4\n__alignof__(unsigned int) = 4\n__alignof__(short) = 2\n__alignof__(unsigned short) = 2\n__alignof__(char) = 1\n__alignof__(unsigned char) = 1\n__alignof__(func) = 1\na=1.500000 b=2.500000 c=3.500000\na=110\nbb2\nbb1\naa2\naa3\naa1\na=2\n__builtin_types_compatible_p(int, int) = 1\n__builtin_types_compatible_p(int, unsigned int) = 0\n__builtin_types_compatible_p(int, char) = 0\n__builtin_types_compatible_p(int, const int) = 1\n__builtin_types_compatible_p(int, volatile int) = 1\n__builtin_types_compatible_p(int *, int *) = 1\n__builtin_types_compatible_p(int *, void *) = 0\n__builtin_types_compatible_p(int *, const int *) = 0\n__builtin_types_compatible_p(char *, unsigned char *) = 0\n__builtin_types_compatible_p(char * *, void *) = 0\nres = 1\nres = 1\nres = 0\nres = 0\nweak_f1=123\nweak_f2=222\nweak_f3=333\nweak_v1=123\nweak_v2=222\nweak_v3=333\nweak_fpa=123\nweak_fpb=123\nweak_fpc=123\nweak_asm_f1=0\nweak_asm_f2=0\nweak_asm_f3=0\nweak_asm_v1=0\nweak_asm_v2=0\nweak_asm_v3=0\n43\ncallsavetest: 8\n0\nstr: __builtin_frame_address\nbfa1: __builtin_frame_address\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/00_assignment.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int a;\n   a = 42;\n   printf(\"%d\\n\", a);\n\n   int b = 64;\n   printf(\"%d\\n\", b);\n\n   int c = 12, d = 34;\n   printf(\"%d, %d\\n\", c, d);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/00_assignment.expect",
    "content": "42\n64\n12, 34\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/01_comment.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   printf(\"Hello\\n\");\n   printf(\"Hello\\n\"); /* this is a comment */ printf(\"Hello\\n\");\n   printf(\"Hello\\n\");\n   // this is also a comment sayhello();\n   printf(\"Hello\\n\");\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/01_comment.expect",
    "content": "Hello\nHello\nHello\nHello\nHello\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/02_printf.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   printf(\"Hello world\\n\");\n\n   int Count;\n   for (Count = -5; Count <= 5; Count++)\n      printf(\"Count = %d\\n\", Count);\n\n   printf(\"String 'hello', 'there' is '%s', '%s'\\n\", \"hello\", \"there\");\n   printf(\"Character 'A' is '%c'\\n\", 65);\n   printf(\"Character 'a' is '%c'\\n\", 'a');\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/02_printf.expect",
    "content": "Hello world\nCount = -5\nCount = -4\nCount = -3\nCount = -2\nCount = -1\nCount = 0\nCount = 1\nCount = 2\nCount = 3\nCount = 4\nCount = 5\nString 'hello', 'there' is 'hello', 'there'\nCharacter 'A' is 'A'\nCharacter 'a' is 'a'\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/03_struct.c",
    "content": "#include <stdio.h>\n\nstruct fred\n{\n   int boris;\n   int natasha;\n};\n\nvoid main() \n{\n   struct fred bloggs;\n\n   bloggs.boris = 12;\n   bloggs.natasha = 34;\n\n   printf(\"%d\\n\", bloggs.boris);\n   printf(\"%d\\n\", bloggs.natasha);\n\n   struct fred jones[2];\n   jones[0].boris = 12;\n   jones[0].natasha = 34;\n   jones[1].boris = 56;\n   jones[1].natasha = 78;\n\n   printf(\"%d\\n\", jones[0].boris);\n   printf(\"%d\\n\", jones[0].natasha);\n   printf(\"%d\\n\", jones[1].boris);\n   printf(\"%d\\n\", jones[1].natasha);\n\n   return 0;\n}\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/03_struct.expect",
    "content": "12\n34\n12\n34\n56\n78\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/04_for.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int Count;\n\n   for (Count = 1; Count <= 10; Count++)\n   {\n      printf(\"%d\\n\", Count);\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/04_for.expect",
    "content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/05_array.c",
    "content": "#include <stdio.h>\n\nint main() \n{\n   int Count;\n   int Array[10];\n\n   for (Count = 1; Count <= 10; Count++)\n   {\n      Array[Count-1] = Count * Count;\n   }\n\n   for (Count = 0; Count < 10; Count++)\n   {\n      printf(\"%d\\n\", Array[Count]);\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/05_array.expect",
    "content": "1\n4\n9\n16\n25\n36\n49\n64\n81\n100\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/06_case.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   for (Count = 0; Count < 4; Count++)\n   {\n      printf(\"%d\\n\", Count);\n      switch (Count)\n      {\n         case 1:\n            printf(\"%d\\n\", 1);\n            break;\n\n         case 2:\n            printf(\"%d\\n\", 2);\n            break;\n\n         default:\n            printf(\"%d\\n\", 0);\n            break;\n      }\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/06_case.expect",
    "content": "0\n0\n1\n1\n2\n2\n3\n0\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/07_function.c",
    "content": "#include <stdio.h>\n\nint myfunc(int x)\n{\n   return x * x;\n}\n\nvoid vfunc(int a)\n{\n   printf(\"a=%d\\n\", a);\n}\n\nvoid qfunc()\n{\n   printf(\"qfunc()\\n\");\n}\n\nint main()\n{\n   printf(\"%d\\n\", myfunc(3));\n   printf(\"%d\\n\", myfunc(4));\n\n   vfunc(1234);\n\n   qfunc();\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/07_function.expect",
    "content": "9\n16\na=1234\nqfunc()\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/08_while.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int p;\n   int t;\n\n   a = 1;\n   p = 0;\n   t = 0;\n\n   while (a < 100)\n   {\n      printf(\"%d\\n\", a);\n      t = a;\n      a = t + p;\n      p = t;\n   }\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/08_while.expect",
    "content": "1\n1\n2\n3\n5\n8\n13\n21\n34\n55\n89\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/09_do_while.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int p;\n   int t;\n\n   a = 1;\n   p = 0;\n   t = 0;\n\n   do\n   {\n      printf(\"%d\\n\", a);\n      t = a;\n      a = t + p;\n      p = t;\n   } while (a < 100);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/09_do_while.expect",
    "content": "1\n1\n2\n3\n5\n8\n13\n21\n34\n55\n89\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/10_pointer.c",
    "content": "#include <stdio.h>\n\nstruct ziggy\n{\n   int a;\n   int b;\n   int c;\n} bolshevic;\n\nint main()\n{\n   int a;\n   int *b;\n   int c;\n\n   a = 42;\n   b = &a;\n   printf(\"a = %d\\n\", *b);\n\n   bolshevic.a = 12;\n   bolshevic.b = 34;\n   bolshevic.c = 56;\n\n   printf(\"bolshevic.a = %d\\n\", bolshevic.a);\n   printf(\"bolshevic.b = %d\\n\", bolshevic.b);\n   printf(\"bolshevic.c = %d\\n\", bolshevic.c);\n\n   struct ziggy *tsar = &bolshevic;\n\n   printf(\"tsar->a = %d\\n\", tsar->a);\n   printf(\"tsar->b = %d\\n\", tsar->b);\n   printf(\"tsar->c = %d\\n\", tsar->c);\n\n   b = &(bolshevic.b);\n   printf(\"bolshevic.b = %d\\n\", *b);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/10_pointer.expect",
    "content": "a = 42\nbolshevic.a = 12\nbolshevic.b = 34\nbolshevic.c = 56\ntsar->a = 12\ntsar->b = 34\ntsar->c = 56\nbolshevic.b = 34\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/11_precedence.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int b;\n   int c;\n   int d;\n   int e;\n   int f;\n   int x;\n   int y;\n\n   a = 12;\n   b = 34;\n   c = 56;\n   d = 78;\n   e = 0;\n   f = 1;\n\n   printf(\"%d\\n\", c + d);\n   printf(\"%d\\n\", (y = c + d));\n   printf(\"%d\\n\", e || e && f);\n   printf(\"%d\\n\", e || f && f);\n   printf(\"%d\\n\", e && e || f);\n   printf(\"%d\\n\", e && f || f);\n   printf(\"%d\\n\", a && f | f);\n   printf(\"%d\\n\", a | b ^ c & d);\n   printf(\"%d, %d\\n\", a == a, a == b);\n   printf(\"%d, %d\\n\", a != a, a != b);\n   printf(\"%d\\n\", a != b && c != d);\n   printf(\"%d\\n\", a + b * c / f);\n   printf(\"%d\\n\", a + b * c / f);\n   printf(\"%d\\n\", (4 << 4));\n   printf(\"%d\\n\", (64 >> 4));\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/11_precedence.expect",
    "content": "134\n134\n0\n1\n1\n1\n1\n46\n1, 0\n0, 1\n1\n1916\n1916\n64\n4\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/12_hashdefine.c",
    "content": "#include <stdio.h>\n\n#define FRED 12\n#define BLOGGS(x) (12*(x))\n\nint main()\n{\n   printf(\"%d\\n\", FRED);\n   printf(\"%d, %d, %d\\n\", BLOGGS(1), BLOGGS(2), BLOGGS(3));\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/12_hashdefine.expect",
    "content": "12\n12, 24, 36\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/13_integer_literals.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a = 24680;\n   int b = 01234567;\n   int c = 0x2468ac;\n   int d = 0x2468AC;\n   int e = 0b010101010101;\n\n   printf(\"%d\\n\", a);\n   printf(\"%d\\n\", b);\n   printf(\"%d\\n\", c);\n   printf(\"%d\\n\", d);\n   printf(\"%d\\n\", e);\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/13_integer_literals.expect",
    "content": "24680\n342391\n2386092\n2386092\n1365\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/14_if.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a = 1;\n\n   if (a)\n      printf(\"a is true\\n\");\n   else\n      printf(\"a is false\\n\");\n\n   int b = 0;\n   if (b)\n      printf(\"b is true\\n\");\n   else\n      printf(\"b is false\\n\");\n\n   return 0;\n}\n\n// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/14_if.expect",
    "content": "a is true\nb is false\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/15_recursion.c",
    "content": "#include <stdio.h>\n\nint factorial(int i) \n{\n   if (i < 2)\n      return i;\n   else\n      return i * factorial(i - 1);\n}\n\nint main()\n{\n   int Count;\n\n   for (Count = 1; Count <= 10; Count++)\n      printf(\"%d\\n\", factorial(Count));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/15_recursion.expect",
    "content": "1\n2\n6\n24\n120\n720\n5040\n40320\n362880\n3628800\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/16_nesting.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int x, y, z;\n\n   for (x = 0; x < 2; x++)\n   {\n      for (y = 0; y < 3; y++)\n      {\n         for (z = 0; z < 3; z++)\n         {\n            printf(\"%d %d %d\\n\", x, y, z);\n         }\n      }\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/16_nesting.expect",
    "content": "0 0 0\n0 0 1\n0 0 2\n0 1 0\n0 1 1\n0 1 2\n0 2 0\n0 2 1\n0 2 2\n1 0 0\n1 0 1\n1 0 2\n1 1 0\n1 1 1\n1 1 2\n1 2 0\n1 2 1\n1 2 2\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/17_enum.c",
    "content": "#include <stdio.h>\n\nenum fred\n{\n   a,\n   b,\n   c,\n   d,\n   e = 54,\n   f = 73,\n   g,\n   h\n};\n\nint main()\n{\n   enum fred frod;\n\n   printf(\"%d %d %d %d %d %d %d %d\\n\", a, b, c, d, e, f, g, h);\n   /* printf(\"%d\\n\", frod); */\n   frod = 12;\n   printf(\"%d\\n\", frod);\n   frod = e;\n   printf(\"%d\\n\", frod);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/17_enum.expect",
    "content": "0 1 2 3 54 73 74 75\n12\n54\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/18_include.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"including\\n\");\n#include \"18_include.h\"\n   printf(\"done\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/18_include.expect",
    "content": "including\nincluded\ndone\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/18_include.h",
    "content": "printf(\"included\\n\");\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int *b;\n   int *c;\n\n   a = 42;\n   b = &a;\n   c = NULL;\n\n   printf(\"%d\\n\", *b);\n\n   if (b == NULL)\n      printf(\"b is NULL\\n\");\n   else\n      printf(\"b is not NULL\\n\");\n\n   if (c == NULL)\n      printf(\"c is NULL\\n\");\n   else\n      printf(\"c is not NULL\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/19_pointer_arithmetic.expect",
    "content": "42\nb is not NULL\nc is NULL\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/20_pointer_comparison.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   int b;\n   int *d;\n   int *e;\n   d = &a;\n   e = &b;\n   a = 12;\n   b = 34;\n   printf(\"%d\\n\", *d);\n   printf(\"%d\\n\", *e);\n   printf(\"%d\\n\", d == e);\n   printf(\"%d\\n\", d != e);\n   d = e;\n   printf(\"%d\\n\", d == e);\n   printf(\"%d\\n\", d != e);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/20_pointer_comparison.expect",
    "content": "12\n34\n0\n1\n1\n0\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/21_char_array.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int x = 'a';\n   char y = x;\n\n   char *a = \"hello\";\n\n   printf(\"%s\\n\", a);\n\n   int c;\n   c = *a;\n\n   char *b;\n   for (b = a; *b != 0; b++)\n      printf(\"%c: %d\\n\", *b, *b);\n\n   char destarray[10];\n   char *dest = &destarray[0];\n   char *src = a;\n\n   while (*src != 0)\n      *dest++ = *src++;\n\n   *dest = 0;\n\n   printf(\"copied string is %s\\n\", destarray);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/21_char_array.expect",
    "content": "hello\nh: 104\ne: 101\nl: 108\nl: 108\no: 111\ncopied string is hello\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/22_floating_point.c",
    "content": "#include <stdio.h>\n#include <math.h>\n\nint main()\n{\n   // variables\n   float a = 12.34 + 56.78;\n   printf(\"%f\\n\", a);\n\n   // infix operators\n   printf(\"%f\\n\", 12.34 + 56.78);\n   printf(\"%f\\n\", 12.34 - 56.78);\n   printf(\"%f\\n\", 12.34 * 56.78);\n   printf(\"%f\\n\", 12.34 / 56.78);\n\n   // comparison operators\n   printf(\"%d %d %d %d %d %d\\n\", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78);\n   printf(\"%d %d %d %d %d %d\\n\", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34);\n   printf(\"%d %d %d %d %d %d\\n\", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34);\n\n   // assignment operators\n   a = 12.34;\n   a += 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a -= 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a *= 56.78;\n   printf(\"%f\\n\", a);\n\n   a = 12.34;\n   a /= 56.78;\n   printf(\"%f\\n\", a);\n\n   // prefix operators\n   printf(\"%f\\n\", +12.34);\n   printf(\"%f\\n\", -12.34);\n\n   // type coercion\n   a = 2;\n   printf(\"%f\\n\", a);\n   printf(\"%f\\n\", sin(2));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/22_floating_point.expect",
    "content": "69.120003\n69.120000\n-44.440000\n700.665200\n0.217330\n1 1 0 0 0 1\n0 1 1 1 0 0\n0 0 0 1 1 1\n69.120003\n-44.439999\n700.665222\n0.217330\n12.340000\n-12.340000\n2.000000\n0.909297\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/23_type_coercion.c",
    "content": "#include <stdio.h>\n\nvoid charfunc(char a)\n{\n   printf(\"char: %c\\n\", a);\n}\n\nvoid intfunc(int a)\n{\n   printf(\"int: %d\\n\", a);\n}\n\nvoid floatfunc(float a)\n{\n   printf(\"float: %f\\n\", a);\n}\n\nint main()\n{\n   charfunc('a');\n   charfunc(98);\n   charfunc(99.0);\n\n   intfunc('a');\n   intfunc(98);\n   intfunc(99.0);\n\n   floatfunc('a');\n   floatfunc(98);\n   floatfunc(99.0);\n\n   /* printf(\"%c %d %f\\n\", 'a', 'b', 'c'); */\n   /* printf(\"%c %d %f\\n\", 97, 98, 99); */\n   /* printf(\"%c %d %f\\n\", 97.0, 98.0, 99.0); */\n\n   char b = 97;\n   char c = 97.0;\n\n   printf(\"%d %d\\n\", b, c);\n\n   int d = 'a';\n   int e = 97.0;\n\n   printf(\"%d %d\\n\", d, e);\n\n   float f = 'a';\n   float g = 97;\n\n   printf(\"%f %f\\n\", f, g);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/23_type_coercion.expect",
    "content": "char: a\nchar: b\nchar: c\nint: 97\nint: 98\nint: 99\nfloat: 97.000000\nfloat: 98.000000\nfloat: 99.000000\n97 97\n97 97\n97.000000 97.000000\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/24_math_library.c",
    "content": "#include <stdio.h>\n#include <math.h>\n\nint main()\n{\n   printf(\"%f\\n\", sin(0.12));\n   printf(\"%f\\n\", cos(0.12));\n   printf(\"%f\\n\", tan(0.12));\n   printf(\"%f\\n\", asin(0.12));\n   printf(\"%f\\n\", acos(0.12));\n   printf(\"%f\\n\", atan(0.12));\n   printf(\"%f\\n\", sinh(0.12));\n   printf(\"%f\\n\", cosh(0.12));\n   printf(\"%f\\n\", tanh(0.12));\n   printf(\"%f\\n\", exp(0.12));\n   printf(\"%f\\n\", fabs(-0.12));\n   printf(\"%f\\n\", log(0.12));\n   printf(\"%f\\n\", log10(0.12));\n   printf(\"%f\\n\", pow(0.12, 0.12));\n   printf(\"%f\\n\", sqrt(0.12));\n   printf(\"%f\\n\", round(12.34));\n   printf(\"%f\\n\", ceil(12.34));\n   printf(\"%f\\n\", floor(12.34));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/24_math_library.expect",
    "content": "0.119712\n0.992809\n0.120579\n0.120290\n1.450506\n0.119429\n0.120288\n1.007209\n0.119427\n1.127497\n0.120000\n-2.120264\n-0.920819\n0.775357\n0.346410\n12.000000\n13.000000\n12.000000\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/25_quicksort.c",
    "content": "#include <stdio.h>\n\nint array[16];\n\n//Swap integer values by array indexes\nvoid swap(int a, int b)\n{\n   int tmp  = array[a];\n   array[a] = array[b];\n   array[b] = tmp;\n}\n\n//Partition the array into two halves and return the\n//index about which the array is partitioned\nint partition(int left, int right)\n{\n   int pivotIndex = left;\n   int pivotValue = array[pivotIndex];\n   int index = left;\n   int i;\n\n   swap(pivotIndex, right);\n   for(i = left; i < right; i++)\n   {\n      if(array[i] < pivotValue)\n      {\n         swap(i, index);\n         index += 1;\n      }\n   }\n   swap(right, index);\n\n   return index;\n}\n\n//Quicksort the array\nvoid quicksort(int left, int right)\n{\n   if(left >= right)\n      return;\n\n   int index = partition(left, right);\n   quicksort(left, index - 1);\n   quicksort(index + 1, right);\n}\n\nint main()\n{\n   int i;\n\n   array[0] = 62;\n   array[1] = 83;\n   array[2] = 4;\n   array[3] = 89;\n   array[4] = 36;\n   array[5] = 21;\n   array[6] = 74;\n   array[7] = 37;\n   array[8] = 65;\n   array[9] = 33;\n   array[10] = 96;\n   array[11] = 38;\n   array[12] = 53;\n   array[13] = 16;\n   array[14] = 74;\n   array[15] = 55;\n\n   for (i = 0; i < 16; i++)\n      printf(\"%d \", array[i]);\n\n   printf(\"\\n\");\n\n   quicksort(0, 15);\n\n   for (i = 0; i < 16; i++)\n      printf(\"%d \", array[i]);\n\n   printf(\"\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/25_quicksort.expect",
    "content": "62 83 4 89 36 21 74 37 65 33 96 38 53 16 74 55 \n4 16 21 33 36 37 38 53 55 62 65 74 74 83 89 96 \n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/26_character_constants.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"%d\\n\", '\\1');\n   printf(\"%d\\n\", '\\10');\n   printf(\"%d\\n\", '\\100');\n   printf(\"%d\\n\", '\\x01');\n   printf(\"%d\\n\", '\\x0e');\n   printf(\"%d\\n\", '\\x10');\n   printf(\"%d\\n\", '\\x40');\n   printf(\"test \\x40\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/26_character_constants.expect",
    "content": "1\n8\n64\n1\n14\n16\n64\ntest @\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/27_sizeof.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char a;\n   int b;\n   double c;\n\n   printf(\"%d\\n\", sizeof(a));\n   printf(\"%d\\n\", sizeof(b));\n   printf(\"%d\\n\", sizeof(c));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/27_sizeof.expect",
    "content": "1\n4\n8\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/28_strings.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include <strings.h>\n\nint main()\n{\n   char a[10];\n\n   strcpy(a, \"hello\");\n   printf(\"%s\\n\", a);\n\n   strncpy(a, \"gosh\", 2);\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", strcmp(a, \"apple\") > 0);\n   printf(\"%d\\n\", strcmp(a, \"goere\") > 0);\n   printf(\"%d\\n\", strcmp(a, \"zebra\") < 0);\n\n   printf(\"%d\\n\", strlen(a));\n\n   strcat(a, \"!\");\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", strncmp(a, \"apple\", 2) > 0);\n   printf(\"%d\\n\", strncmp(a, \"goere\", 2) == 0);\n   printf(\"%d\\n\", strncmp(a, \"goerg\", 2) == 0);\n   printf(\"%d\\n\", strncmp(a, \"zebra\", 2) < 0);\n\n   printf(\"%s\\n\", index(a, 'o'));\n   printf(\"%s\\n\", rindex(a, 'l'));\n   printf(\"%d\\n\", rindex(a, 'x') == NULL);\n\n   memset(&a[1], 'r', 4);\n   printf(\"%s\\n\", a);\n\n   memcpy(&a[2], a, 2);\n   printf(\"%s\\n\", a);\n\n   printf(\"%d\\n\", memcmp(a, \"apple\", 4) > 0);\n   printf(\"%d\\n\", memcmp(a, \"grgr\", 4) == 0);\n   printf(\"%d\\n\", memcmp(a, \"zebra\", 4) < 0);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/28_strings.expect",
    "content": "hello\ngollo\n1\n1\n1\n5\ngollo!\n1\n1\n1\n1\nollo!\nlo!\n1\ngrrrr!\ngrgrr!\n1\n1\n1\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/29_array_address.c",
    "content": "#include <stdio.h>\n#include <string.h>\n\nint main()\n{\n   char a[10];\n   strcpy(a, \"abcdef\");\n   printf(\"%s\\n\", &a[1]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/29_array_address.expect",
    "content": "bcdef\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/30_hanoi.c",
    "content": "/* example from http://barnyard.syr.edu/quickies/hanoi.c */\n\n/* hanoi.c: solves the tower of hanoi problem. (Programming exercise.) */\n/* By Terry R. McConnell (12/2/97) */\n/* Compile: cc -o hanoi hanoi.c */\n\n/* This program does no error checking. But then, if it's right, \n   it's right ... right ? */\n\n\n/* The original towers of hanoi problem seems to have been originally posed\n   by one M. Claus in 1883. There is a popular legend that goes along with\n   it that has been often repeated and paraphrased. It goes something like this:\n   In the great temple at Benares there are 3 golden spikes. On one of them,\n   God placed 64 disks increasing in size from bottom to top, at the beginning\n   of time. Since then, and to this day, the priest on duty constantly transfers\n   disks, one at a time, in such a way that no larger disk is ever put on top\n   of a smaller one. When the disks have been transferred entirely to another\n   spike the Universe will come to an end in a large thunderclap.\n\n   This paraphrases the original legend due to DeParville, La Nature, Paris 1884,\n   Part I, 285-286. For this and further information see: Mathematical \n   Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967,\n   303-305.\n *\n *\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#define TRUE 1\n#define FALSE 0\n\n/* This is the number of \"disks\" on tower A initially. Taken to be 64 in the\n * legend. The number of moves required, in general, is 2^N - 1. For N = 64,\n * this is 18,446,744,073,709,551,615 */\n#define N 4\n\n/* These are the three towers. For example if the state of A is 0,1,3,4, that\n * means that there are three discs on A of sizes 1, 3, and 4. (Think of right\n * as being the \"down\" direction.) */\nint A[N], B[N], C[N]; \n\nvoid Hanoi(int,int*,int*,int*);\n\n/* Print the current configuration of A, B, and C to the screen */\nvoid PrintAll()\n{\n   int i;\n\n   printf(\"A: \");\n   for(i=0;i<N;i++)printf(\" %d \",A[i]);\n   printf(\"\\n\");\n\n   printf(\"B: \");\n   for(i=0;i<N;i++)printf(\" %d \",B[i]);\n   printf(\"\\n\");\n\n   printf(\"C: \");\n   for(i=0;i<N;i++)printf(\" %d \",C[i]);\n   printf(\"\\n\");\n   printf(\"------------------------------------------\\n\");\n   return;\n}\n\n/* Move the leftmost nonzero element of source to dest, leave behind 0. */\n/* Returns the value moved (not used.) */\nint Move(int *source, int *dest)\n{\n   int i,j;\n\n   while (i<N && (source[i])==0) i++;\n   while (j<N && (dest[j])==0) j++;\n\n   dest[j-1] = source[i];\n   source[i] = 0;\n   PrintAll();       /* Print configuration after each move. */\n   return dest[j-1];\n}\n\n\n/* Moves first n nonzero numbers from source to dest using the rules of Hanoi.\n   Calls itself recursively.\n   */\nvoid Hanoi(int n,int *source, int *dest, int *spare)\n{\n   int i;\n   if(n==1){\n      Move(source,dest);\n      return;\n   }\n\n   Hanoi(n-1,source,spare,dest);\n   Move(source,dest);\n   Hanoi(n-1,spare,dest,source);\t\n   return;\n}\n\nint main()\n{\n   int i;\n\n   /* initialize the towers */\n   for(i=0;i<N;i++)A[i]=i+1;\n   for(i=0;i<N;i++)B[i]=0;\n   for(i=0;i<N;i++)C[i]=0;\n\n   printf(\"Solution of Tower of Hanoi Problem with %d Disks\\n\\n\",N);\n\n   /* Print the starting state */\n   printf(\"Starting state:\\n\");\n   PrintAll();\n   printf(\"\\n\\nSubsequent states:\\n\\n\");\n\n   /* Do it! Use A = Source, B = Destination, C = Spare */\n   Hanoi(N,A,B,C);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/30_hanoi.expect",
    "content": "Solution of Tower of Hanoi Problem with 4 Disks\n\nStarting state:\nA:  1  2  3  4 \nB:  0  0  0  0 \nC:  0  0  0  0 \n------------------------------------------\n\n\nSubsequent states:\n\nA:  0  2  3  4 \nB:  0  0  0  0 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  3  4 \nB:  0  0  0  2 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  3  4 \nB:  0  0  1  2 \nC:  0  0  0  0 \n------------------------------------------\nA:  0  0  0  4 \nB:  0  0  1  2 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  4 \nB:  0  0  0  2 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  4 \nB:  0  0  0  0 \nC:  0  0  2  3 \n------------------------------------------\nA:  0  0  0  4 \nB:  0  0  0  0 \nC:  0  1  2  3 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  0  0  4 \nC:  0  1  2  3 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  0  1  4 \nC:  0  0  2  3 \n------------------------------------------\nA:  0  0  0  2 \nB:  0  0  1  4 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  2 \nB:  0  0  0  4 \nC:  0  0  0  3 \n------------------------------------------\nA:  0  0  1  2 \nB:  0  0  3  4 \nC:  0  0  0  0 \n------------------------------------------\nA:  0  0  0  2 \nB:  0  0  3  4 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  0  0 \nB:  0  2  3  4 \nC:  0  0  0  1 \n------------------------------------------\nA:  0  0  0  0 \nB:  1  2  3  4 \nC:  0  0  0  0 \n------------------------------------------\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/31_args.c",
    "content": "#include <stdio.h>\n\nint main(int argc, char **argv)\n{\n   int Count;\n\n   printf(\"hello world %d\\n\", argc);\n   for (Count = 0; Count < argc; Count++)\n      printf(\"arg %d: %s\\n\", Count, argv[Count]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/31_args.expect",
    "content": "hello world 6\narg 0: 31_args.c\narg 1: -\narg 2: arg1\narg 3: arg2\narg 4: arg3\narg 5: arg4\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/32_led.c",
    "content": "/* example from http://barnyard.syr.edu/quickies/led.c */\n\n/* led.c: print out number as if on 7 line led display. I.e., write integer\n   given on command line like this:  \n      _   _       _  \n   |  _|  _| |_| |_  \n   | |_   _|   |  _| etc.\n\n   We assume the terminal behaves like a classical teletype. So the top\n   lines of all digits have to be printed first, then the middle lines of\n   all digits, etc.\n\n   By Terry R. McConnell\n\ncompile: cc -o led led.c\n\nIf you just want to link in the subroutine print_led that does all the\nwork, compile with -DNO_MAIN, and declare the following in any source file\nthat uses the call:\n\nextern void print_led(unsigned long x, char *buf);\n\nBug: you cannot call repeatedly to print more than one number to a line.\nThat would require curses or some other terminal API that allows moving the\ncursor to a previous line.\n\n*/\n\n\n\n#include <stdlib.h>\n#include <stdio.h>\n\n#define MAX_DIGITS 32\n#define NO_MAIN\n\n\n/* Print the top line of the digit d into buffer. \n   Does not null terminate buffer. */\n\nvoid topline(int d, char *p){\n\n   *p++ = ' ';\n   switch(d){\n\n      /* all these have _ on top line */\n\n      case 0:\n      case 2:\n      case 3:\n      case 5:\n      case 7:\n      case 8:\n      case 9:\n         *p++ = '_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   *p++=' ';\n}\n\n/* Print the middle line of the digit d into the buffer. \n   Does not null terminate. */\n\nvoid midline(int d, char *p){\n\n   switch(d){\n\n      /* those that have leading | on middle line */\n\n      case 0:\n      case 4:\n      case 5:\n      case 6:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\t\n   }\n   switch(d){\n\n      /* those that have _ on middle line */\n\n      case 2:\n      case 3:\n      case 4:\n      case 5:\n      case 6:\n      case 8:\n      case 9:\n         *p++='_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   switch(d){\n\n      /* those that have closing | on middle line */\n\n      case 0:\n      case 1:\n      case 2:\n      case 3:\n      case 4:\n      case 7:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\n\n   }\n}\n\n/* Print the bottom line of the digit d. Does not null terminate. */\n\nvoid botline(int d, char *p){\n\n\n   switch(d){\n\n      /* those that have leading | on bottom line */\n\n      case 0:\n      case 2:\n      case 6:\n      case 8:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\t\n   }\n   switch(d){\n\n      /* those that have _ on bottom line */\n\n      case 0:\n      case 2:\n      case 3:\n      case 5:\n      case 6:\n      case 8:\n         *p++='_';\n         break;\n      default:\n         *p++=' ';\n\n   }\n   switch(d){\n\n      /* those that have closing | on bottom line */\n\n      case 0:\n      case 1:\n      case 3:\n      case 4:\n      case 5:\n      case 6:\n      case 7:\n      case 8:\n      case 9:\n         *p++='|';\n         break;\n      default:\n         *p++=' ';\n\n   }\n}\n\n/* Write the led representation of integer to string buffer. */\n\nvoid print_led(unsigned long x, char *buf)\n{\n\n   int i=0,n;\n   static int d[MAX_DIGITS];\n\n\n   /* extract digits from x */\n\n   n = ( x == 0L ? 1 : 0 );  /* 0 is a digit, hence a special case */\n\n   while(x){\n      d[n++] = (int)(x%10L);\n      if(n >= MAX_DIGITS)break;\n      x = x/10L;\n   }\n\n   /* print top lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      topline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n'; /* move teletype to next line */\n\n   /* print middle lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      midline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n';\n\n   /* print bottom lines of all digits */\n\n   for(i=n-1;i>=0;i--){\n      botline(d[i],buf);\n      buf += 3;\n      *buf++=' ';\n   }\n   *buf++='\\n';\n   *buf='\\0';\n}\n\nint main()\n{\n   char buf[5*MAX_DIGITS];\n   print_led(1234567, buf);\n   printf(\"%s\\n\",buf);\n\n   return 0;\n}\n\n#ifndef NO_MAIN\nint main(int argc, char **argv)\n{\n\n   int i=0,n;\n   long x;\n   static int d[MAX_DIGITS];\n   char buf[5*MAX_DIGITS];\n\n   if(argc != 2){\n      fprintf(stderr,\"led: usage: led integer\\n\");\n      return 1;\n   }\n\n   /* fetch argument from command line */\n\n   x = atol(argv[1]);\n\n   /* sanity check */\n\n   if(x<0){\n      fprintf(stderr,\"led: %d must be non-negative\\n\",x);\n      return 1;\n   }\n\n   print_led(x,buf);\n   printf(\"%s\\n\",buf);\n\n   return 0;\n\n}\n#endif\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/32_led.expect",
    "content": "     _   _       _       _  \n  |  _|  _| |_| |_  |_    | \n  | |_   _|   |  _| |_|   | \n\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/33_ternary_op.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   for (Count = 0; Count < 10; Count++)\n   {\n      printf(\"%d\\n\", (Count < 5) ? (Count*Count) : (Count * 3));\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/33_ternary_op.expect",
    "content": "0\n1\n4\n9\n16\n15\n18\n21\n24\n27\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/34_array_assignment.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a[4];\n\n   a[0] = 12;\n   a[1] = 23;\n   a[2] = 34;\n   a[3] = 45;\n\n   printf(\"%d %d %d %d\\n\", a[0], a[1], a[2], a[3]);\n\n   int b[4];\n\n   b = a;\n\n   printf(\"%d %d %d %d\\n\", b[0], b[1], b[2], b[3]);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/34_array_assignment.expect",
    "content": "12 23 34 45\n12 23 34 45\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/35_sizeof.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char a;\n   short b;\n\n   printf(\"%d %d\\n\", sizeof(char), sizeof(a));\n   printf(\"%d %d\\n\", sizeof(short), sizeof(b));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/35_sizeof.expect",
    "content": "1 1\n2 2\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/36_array_initialisers.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count;\n\n   int Array[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753 };\n\n   for (Count = 0; Count < 10; Count++)\n      printf(\"%d: %d\\n\", Count, Array[Count]);\n\n   int Array2[10] = { 12, 34, 56, 78, 90, 123, 456, 789, 8642, 9753, };\n\n   for (Count = 0; Count < 10; Count++)\n      printf(\"%d: %d\\n\", Count, Array2[Count]);\n\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/36_array_initialisers.expect",
    "content": "0: 12\n1: 34\n2: 56\n3: 78\n4: 90\n5: 123\n6: 456\n7: 789\n8: 8642\n9: 9753\n0: 12\n1: 34\n2: 56\n3: 78\n4: 90\n5: 123\n6: 456\n7: 789\n8: 8642\n9: 9753\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/37_sprintf.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   char Buf[100];\n   int Count;\n\n   for (Count = 1; Count <= 20; Count++)\n   {\n      sprintf(Buf, \"->%02d<-\\n\", Count);\n      printf(\"%s\", Buf);\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/37_sprintf.expect",
    "content": "->01<-\n->02<-\n->03<-\n->04<-\n->05<-\n->06<-\n->07<-\n->08<-\n->09<-\n->10<-\n->11<-\n->12<-\n->13<-\n->14<-\n->15<-\n->16<-\n->17<-\n->18<-\n->19<-\n->20<-\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/38_multiple_array_index.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a[4][4];\n   int b = 0;\n   int x;\n   int y;\n\n   for (x = 0; x < 4; x++)\n   {\n      for (y = 0; y < 4; y++)\n      {\n         b++;\n         a[x][y] = b;\n      }\n   }\n\n   for (x = 0; x < 4; x++)\n   {\n      printf(\"x=%d: \", x);\n      for (y = 0; y < 4; y++)\n      {\n         printf(\"%d \", a[x][y]);\n      }\n      printf(\"\\n\");\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/38_multiple_array_index.expect",
    "content": "x=0: 1 2 3 4\nx=1: 5 6 7 8\nx=2: 9 10 11 12\nx=3: 13 14 15 16 \n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/39_typedef.c",
    "content": "#include <stdio.h>\n\ntypedef int MyInt;\n\nstruct FunStruct\n{\n   int i;\n   int j;\n};\n\ntypedef struct FunStruct MyFunStruct;\n\ntypedef MyFunStruct *MoreFunThanEver;\n\nint main()\n{\n   MyInt a = 1;\n   printf(\"%d\\n\", a);\n\n   MyFunStruct b;\n   b.i = 12;\n   b.j = 34;\n   printf(\"%d,%d\\n\", b.i, b.j);\n\n   MoreFunThanEver c = &b;\n   printf(\"%d,%d\\n\", c->i, c->j);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/39_typedef.expect",
    "content": "1\n12,34\n12,34\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/40_stdio.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   FILE *f = fopen(\"fred.txt\", \"w\");\n   fwrite(\"hello\\nhello\\n\", 1, 12, f);\n   fclose(f);\n\n   char freddy[7];\n   f = fopen(\"fred.txt\", \"r\");\n   if (fread(freddy, 1, 6, f) != 6)\n      printf(\"couldn't read fred.txt\\n\");\n\n   freddy[6] = '\\0';\n   fclose(f);\n\n   printf(\"%s\", freddy);\n\n   int InChar;\n   char ShowChar;\n   f = fopen(\"fred.txt\", \"r\");\n   while ( (InChar = fgetc(f)) != EOF)\n   {\n      ShowChar = InChar;\n      if (ShowChar < ' ')\n         ShowChar = '.';\n\n      printf(\"ch: %d '%c'\\n\", InChar, ShowChar);\n   }\n   fclose(f);\n\n   f = fopen(\"fred.txt\", \"r\");\n   while ( (InChar = getc(f)) != EOF)\n   {\n      ShowChar = InChar;\n      if (ShowChar < ' ')\n         ShowChar = '.';\n\n      printf(\"ch: %d '%c'\\n\", InChar, ShowChar);\n   }\n   fclose(f);\n\n   f = fopen(\"fred.txt\", \"r\");\n   while (fgets(freddy, sizeof(freddy), f) != NULL)\n      printf(\"x: %s\", freddy);\n\n   fclose(f);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/40_stdio.expect",
    "content": "hello\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nch: 104 'h'\nch: 101 'e'\nch: 108 'l'\nch: 108 'l'\nch: 111 'o'\nch: 10 '.'\nx: hello\nx: hello\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/41_hashif.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   printf(\"#include test\\n\");\n\n#if 1\n#if 0\n   printf(\"a\\n\");\n#else\n   printf(\"b\\n\");\n#endif\n#else\n#if 0\n   printf(\"c\\n\");\n#else\n   printf(\"d\\n\");\n#endif\n#endif\n\n#if 0\n#if 1\n   printf(\"e\\n\");\n#else\n   printf(\"f\\n\");\n#endif\n#else\n#if 1\n   printf(\"g\\n\");\n#else\n   printf(\"h\\n\");\n#endif\n#endif\n\n#define DEF\n\n#ifdef DEF\n#ifdef DEF\n   printf(\"i\\n\");\n#else\n   printf(\"j\\n\");\n#endif\n#else\n#ifdef DEF\n   printf(\"k\\n\");\n#else\n   printf(\"l\\n\");\n#endif\n#endif\n\n#ifndef DEF\n#ifndef DEF\n   printf(\"m\\n\");\n#else\n   printf(\"n\\n\");\n#endif\n#else\n#ifndef DEF\n   printf(\"o\\n\");\n#else\n   printf(\"p\\n\");\n#endif\n#endif\n\n#define ONE 1\n#define ZERO 0\n\n#if ONE\n#if ZERO\n   printf(\"q\\n\");\n#else\n   printf(\"r\\n\");\n#endif\n#else\n#if ZERO\n   printf(\"s\\n\");\n#else\n   printf(\"t\\n\");\n#endif\n#endif\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/41_hashif.expect",
    "content": "#include test\nb\ng\ni\np\nr\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/42_function_pointer.c",
    "content": "#include <stdio.h>\n\nint fred(int p)\n{\n   printf(\"yo %d\\n\", p);\n   return 42;\n}\n\nint (*f)(int) = &fred;\n\nint main()\n{\n   printf(\"%d\\n\", (*f)(24));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/42_function_pointer.expect",
    "content": "yo 24\n42\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/43_void_param.c",
    "content": "#include <stdio.h>\n\nvoid fred(void)\n{\n   printf(\"yo\\n\");\n}\n\nint main()\n{\n   fred();\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/43_void_param.expect",
    "content": "yo\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/44_scoped_declarations.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n\n   for (a = 0; a < 2; a++)\n   {\n      int b = a;\n   }\n\n   printf(\"it's all good\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/44_scoped_declarations.expect",
    "content": "it's all good\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/45_empty_for.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int Count = 0;\n\n   for (;;)\n   {\n      Count++;\n      printf(\"%d\\n\", Count);\n      if (Count >= 10)\n         break;\n   }\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/45_empty_for.expect",
    "content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/46_grep.c",
    "content": "/*\n * The  information  in  this  document  is  subject  to  change\n * without  notice  and  should not be construed as a commitment\n * by Digital Equipment Corporation or by DECUS.\n *\n * Neither Digital Equipment Corporation, DECUS, nor the authors\n * assume any responsibility for the use or reliability of  this\n * document or the described software.\n *\n *      Copyright (C) 1980, DECUS\n *\n * General permission to copy or modify, but not for profit,  is\n * hereby  granted,  provided that the above copyright notice is\n * included and reference made to  the  fact  that  reproduction\n * privileges were granted by DECUS.\n */\n#include <stdio.h>\n\n/*\n * grep\n *\n * Runs on the Decus compiler or on vms, On vms, define as:\n *      grep :== \"$disk:[account]grep\"      (native)\n *      grep :== \"$disk:[account]grep grep\" (Decus)\n * See below for more information.\n */\n\n#if 0\nchar    *documentation[] = {\n   \"grep searches a file for a given pattern.  Execute by\",\n   \"   grep [flags] regular_expression file_list\\n\",\n   \"Flags are single characters preceeded by '-':\",\n   \"   -c      Only a count of matching lines is printed\",\n   \"   -f      Print file name for matching lines switch, see below\",\n   \"   -n      Each line is preceeded by its line number\",\n   \"   -v      Only print non-matching lines\\n\",\n   \"The file_list is a list of files (wildcards are acceptable on RSX modes).\",\n   \"\\nThe file name is normally printed if there is a file given.\",\n   \"The -f flag reverses this action (print name no file, not if more).\\n\",\n   0 };\n\nchar    *patdoc[] = {\n   \"The regular_expression defines the pattern to search for.  Upper- and\",\n   \"lower-case are always ignored.  Blank lines never match.  The expression\",\n   \"should be quoted to prevent file-name translation.\",\n   \"x      An ordinary character (not mentioned below) matches that character.\",\n   \"'\\\\'    The backslash quotes any character.  \\\"\\\\$\\\" matches a dollar-sign.\",\n   \"'^'    A circumflex at the beginning of an expression matches the\",\n   \"       beginning of a line.\",\n   \"'$'    A dollar-sign at the end of an expression matches the end of a line.\",\n   \"'.'    A period matches any character except \\\"new-line\\\".\",\n   \"':a'   A colon matches a class of characters described by the following\",\n   \"':d'     character.  \\\":a\\\" matches any alphabetic, \\\":d\\\" matches digits,\",\n   \"':n'     \\\":n\\\" matches alphanumerics, \\\": \\\" matches spaces, tabs, and\",\n   \"': '     other control characters, such as new-line.\",\n   \"'*'    An expression followed by an asterisk matches zero or more\",\n   \"       occurrances of that expression: \\\"fo*\\\" matches \\\"f\\\", \\\"fo\\\"\",\n   \"       \\\"foo\\\", etc.\",\n   \"'+'    An expression followed by a plus sign matches one or more\",\n   \"       occurrances of that expression: \\\"fo+\\\" matches \\\"fo\\\", etc.\",\n   \"'-'    An expression followed by a minus sign optionally matches\",\n   \"       the expression.\",\n   \"'[]'   A string enclosed in square brackets matches any character in\",\n   \"       that string, but no others.  If the first character in the\",\n   \"       string is a circumflex, the expression matches any character\",\n   \"       except \\\"new-line\\\" and the characters in the string.  For\",\n   \"       example, \\\"[xyz]\\\" matches \\\"xx\\\" and \\\"zyx\\\", while \\\"[^xyz]\\\"\",\n   \"       matches \\\"abc\\\" but not \\\"axb\\\".  A range of characters may be\",\n   \"       specified by two characters separated by \\\"-\\\".  Note that,\",\n   \"       [a-z] matches alphabetics, while [z-a] never matches.\",\n   \"The concatenation of regular expressions is a regular expression.\",\n   0};\n#endif\n\n#define LMAX    512\n#define PMAX    256\n\n#define CHAR    1\n#define BOL     2\n#define EOL     3\n#define ANY     4\n#define CLASS   5\n#define NCLASS  6\n#define STAR    7\n#define PLUS    8\n#define MINUS   9\n#define ALPHA   10\n#define DIGIT   11\n#define NALPHA  12\n#define PUNCT   13\n#define RANGE   14\n#define ENDPAT  15\n\nint cflag=0, fflag=0, nflag=0, vflag=0, nfile=0, debug=0;\n\nchar *pp, lbuf[LMAX], pbuf[PMAX];\n\nchar *cclass();\nchar *pmatch();\n\n\n/*** Display a file name *******************************/\nvoid file(char *s)\n{\n   printf(\"File %s:\\n\", s);\n}\n\n/*** Report unopenable file ****************************/\nvoid cant(char *s)\n{\n   fprintf(stderr, \"%s: cannot open\\n\", s);\n}\n\n/*** Give good help ************************************/\nvoid help(char **hp)\n{\n   char   **dp;\n\n   for (dp = hp; *dp; ++dp)\n      printf(\"%s\\n\", *dp);\n}\n\n/*** Display usage summary *****************************/\nvoid usage(char *s)\n{\n   fprintf(stderr, \"?GREP-E-%s\\n\", s);\n   fprintf(stderr,\n         \"Usage: grep [-cfnv] pattern [file ...].  grep ? for help\\n\");\n   exit(1);\n}\n\n/*** Compile the pattern into global pbuf[] ************/\nvoid compile(char *source)\n{\n   char  *s;         /* Source string pointer     */\n   char  *lp;        /* Last pattern pointer      */\n   int   c;          /* Current character         */\n   int            o;          /* Temp                      */\n   char           *spp;       /* Save beginning of pattern */\n\n   s = source;\n   if (debug)\n      printf(\"Pattern = \\\"%s\\\"\\n\", s);\n   pp = pbuf;\n   while (c = *s++) {\n      /*\n       * STAR, PLUS and MINUS are special.\n       */\n      if (c == '*' || c == '+' || c == '-') {\n         if (pp == pbuf ||\n               (o=pp[-1]) == BOL ||\n               o == EOL ||\n               o == STAR ||\n               o == PLUS ||\n               o == MINUS)\n            badpat(\"Illegal occurrance op.\", source, s);\n         store(ENDPAT);\n         store(ENDPAT);\n         spp = pp;               /* Save pattern end     */\n         while (--pp > lp)       /* Move pattern down    */\n            *pp = pp[-1];        /* one byte             */\n         *pp =   (c == '*') ? STAR :\n            (c == '-') ? MINUS : PLUS;\n         pp = spp;               /* Restore pattern end  */\n         continue;\n      }\n      /*\n       * All the rest.\n       */\n      lp = pp;         /* Remember start       */\n      switch(c) {\n\n         case '^':\n            store(BOL);\n            break;\n\n         case '$':\n            store(EOL);\n            break;\n\n         case '.':\n            store(ANY);\n            break;\n\n         case '[':\n            s = cclass(source, s);\n            break;\n\n         case ':':\n            if (*s) {\n               switch(tolower(c = *s++)) {\n\n                  case 'a':\n                  case 'A':\n                     store(ALPHA);\n                     break;\n\n                  case 'd':\n                  case 'D':\n                     store(DIGIT);\n                     break;\n\n                  case 'n':\n                  case 'N':\n                     store(NALPHA);\n                     break;\n\n                  case ' ':\n                     store(PUNCT);\n                     break;\n\n                  default:\n                     badpat(\"Unknown : type\", source, s);\n\n               }\n               break;\n            }\n            else    badpat(\"No : type\", source, s);\n\n         case '\\\\':\n            if (*s)\n               c = *s++;\n\n         default:\n            store(CHAR);\n            store(tolower(c));\n      }\n   }\n   store(ENDPAT);\n   store(0);                /* Terminate string     */\n   if (debug) {\n      for (lp = pbuf; lp < pp;) {\n         if ((c = (*lp++ & 0377)) < ' ')\n            printf(\"\\\\%o \", c);\n         else    printf(\"%c \", c);\n      }\n      printf(\"\\n\");\n   }\n}\n\n/*** Compile a class (within []) ***********************/\nchar *cclass(char *source, char *src)\n   /* char       *source;   // Pattern start -- for error msg. */\n   /* char       *src;      // Class start */\n{\n   char   *s;        /* Source pointer    */\n   char   *cp;       /* Pattern start     */\n   int    c;         /* Current character */\n   int             o;         /* Temp              */\n\n   s = src;\n   o = CLASS;\n   if (*s == '^') {\n      ++s;\n      o = NCLASS;\n   }\n   store(o);\n   cp = pp;\n   store(0);                          /* Byte count      */\n   while ((c = *s++) && c!=']') {\n      if (c == '\\\\') {                /* Store quoted char    */\n         if ((c = *s++) == '\\0')      /* Gotta get something  */\n            badpat(\"Class terminates badly\", source, s);\n         else    store(tolower(c));\n      }\n      else if (c == '-' &&\n            (pp - cp) > 1 && *s != ']' && *s != '\\0') {\n         c = pp[-1];             /* Range start     */\n         pp[-1] = RANGE;         /* Range signal    */\n         store(c);               /* Re-store start  */\n         c = *s++;               /* Get end char and*/\n         store(tolower(c));      /* Store it        */\n      }\n      else {\n         store(tolower(c));      /* Store normal char */\n      }\n   }\n   if (c != ']')\n      badpat(\"Unterminated class\", source, s);\n   if ((c = (pp - cp)) >= 256)\n      badpat(\"Class too large\", source, s);\n   if (c == 0)\n      badpat(\"Empty class\", source, s);\n   *cp = c;\n   return(s);\n}\n\n/*** Store an entry in the pattern buffer **************/\nvoid store(int op)\n{\n   if (pp >= &pbuf[PMAX])\n      error(\"Pattern too complex\\n\");\n   *pp++ = op;\n}\n\n/*** Report a bad pattern specification ****************/\nvoid badpat(char *message, char *source, char *stop)\n   /* char  *message;       // Error message */\n   /* char  *source;        // Pattern start */\n   /* char  *stop;          // Pattern end   */\n{\n   fprintf(stderr, \"-GREP-E-%s, pattern is\\\"%s\\\"\\n\", message, source);\n   fprintf(stderr, \"-GREP-E-Stopped at byte %d, '%c'\\n\",\n         stop-source, stop[-1]);\n   error(\"?GREP-E-Bad pattern\\n\");\n}\n\n/*** Scan the file for the pattern in pbuf[] ***********/\nvoid grep(FILE *fp, char *fn)\n   /* FILE       *fp;       // File to process            */\n   /* char       *fn;       // File name (for -f option)  */\n{\n   int lno, count, m;\n\n   lno = 0;\n   count = 0;\n   while (fgets(lbuf, LMAX, fp)) {\n      ++lno;\n      m = match();\n      if ((m && !vflag) || (!m && vflag)) {\n         ++count;\n         if (!cflag) {\n            if (fflag && fn) {\n               file(fn);\n               fn = 0;\n            }\n            if (nflag)\n               printf(\"%d\\t\", lno);\n            printf(\"%s\\n\", lbuf);\n         }\n      }\n   }\n   if (cflag) {\n      if (fflag && fn)\n         file(fn);\n      printf(\"%d\\n\", count);\n   }\n}\n\n/*** Match line (lbuf) with pattern (pbuf) return 1 if match ***/\nvoid match()\n{\n   char   *l;        /* Line pointer       */\n\n   for (l = lbuf; *l; ++l) {\n      if (pmatch(l, pbuf))\n         return(1);\n   }\n   return(0);\n}\n\n/*** Match partial line with pattern *******************/\nchar *pmatch(char *line, char *pattern)\n   /* char               *line;     // (partial) line to match      */\n   /* char               *pattern;  // (partial) pattern to match   */\n{\n   char   *l;        /* Current line pointer         */\n   char   *p;        /* Current pattern pointer      */\n   char   c;         /* Current character            */\n   char            *e;        /* End for STAR and PLUS match  */\n   int             op;        /* Pattern operation            */\n   int             n;         /* Class counter                */\n   char            *are;      /* Start of STAR match          */\n\n   l = line;\n   if (debug > 1)\n      printf(\"pmatch(\\\"%s\\\")\\n\", line);\n   p = pattern;\n   while ((op = *p++) != ENDPAT) {\n      if (debug > 1)\n         printf(\"byte[%d] = 0%o, '%c', op = 0%o\\n\",\n               l-line, *l, *l, op);\n      switch(op) {\n\n         case CHAR:\n            if (tolower(*l++) != *p++)\n               return(0);\n            break;\n\n         case BOL:\n            if (l != lbuf)\n               return(0);\n            break;\n\n         case EOL:\n            if (*l != '\\0')\n               return(0);\n            break;\n\n         case ANY:\n            if (*l++ == '\\0')\n               return(0);\n            break;\n\n         case DIGIT:\n            if ((c = *l++) < '0' || (c > '9'))\n               return(0);\n            break;\n\n         case ALPHA:\n            c = tolower(*l++);\n            if (c < 'a' || c > 'z')\n               return(0);\n            break;\n\n         case NALPHA:\n            c = tolower(*l++);\n            if (c >= 'a' && c <= 'z')\n               break;\n            else if (c < '0' || c > '9')\n               return(0);\n            break;\n\n         case PUNCT:\n            c = *l++;\n            if (c == 0 || c > ' ')\n               return(0);\n            break;\n\n         case CLASS:\n         case NCLASS:\n            c = tolower(*l++);\n            n = *p++ & 0377;\n            do {\n               if (*p == RANGE) {\n                  p += 3;\n                  n -= 2;\n                  if (c >= p[-2] && c <= p[-1])\n                     break;\n               }\n               else if (c == *p++)\n                  break;\n            } while (--n > 1);\n            if ((op == CLASS) == (n <= 1))\n               return(0);\n            if (op == CLASS)\n               p += n - 2;\n            break;\n\n         case MINUS:\n            e = pmatch(l, p);       /* Look for a match    */\n            while (*p++ != ENDPAT); /* Skip over pattern   */\n            if (e)                  /* Got a match?        */\n               l = e;               /* Yes, update string  */\n            break;                  /* Always succeeds     */\n\n         case PLUS:                 /* One or more ...     */\n            if ((l = pmatch(l, p)) == 0)\n               return(0);           /* Gotta have a match  */\n         case STAR:                 /* Zero or more ...    */\n            are = l;                /* Remember line start */\n            while (*l && (e = pmatch(l, p)))\n               l = e;               /* Get longest match   */\n            while (*p++ != ENDPAT); /* Skip over pattern   */\n            while (l >= are) {      /* Try to match rest   */\n               if (e = pmatch(l, p))\n                  return(e);\n               --l;                 /* Nope, try earlier   */\n            }\n            return(0);              /* Nothing else worked */\n\n         default:\n            printf(\"Bad op code %d\\n\", op);\n            error(\"Cannot happen -- match\\n\");\n      }\n   }\n   return(l);\n}\n\n/*** Report an error ***********************************/\nvoid error(char *s)\n{\n   fprintf(stderr, \"%s\", s);\n   exit(1);\n}\n\n/*** Main program - parse arguments & grep *************/\nint main(int argc, char **argv)\n{\n   char   *p;\n   int    c, i;\n   int             gotpattern;\n\n   FILE            *f;\n\n   if (argc <= 1)\n      usage(\"No arguments\");\n   if (argc == 2 && argv[1][0] == '?' && argv[1][1] == 0) {\n      help(documentation);\n      help(patdoc);\n      return 0;\n   }\n   nfile = argc-1;\n   gotpattern = 0;\n   for (i=1; i < argc; ++i) {\n      p = argv[i];\n      if (*p == '-') {\n         ++p;\n         while (c = *p++) {\n            switch(tolower(c)) {\n\n               case '?':\n                  help(documentation);\n                  break;\n\n               case 'C':\n               case 'c':\n                  ++cflag;\n                  break;\n\n               case 'D':\n               case 'd':\n                  ++debug;\n                  break;\n\n               case 'F':\n               case 'f':\n                  ++fflag;\n                  break;\n\n               case 'n':\n               case 'N':\n                  ++nflag;\n                  break;\n\n               case 'v':\n               case 'V':\n                  ++vflag;\n                  break;\n\n               default:\n                  usage(\"Unknown flag\");\n            }\n         }\n         argv[i] = 0;\n         --nfile;\n      } else if (!gotpattern) {\n         compile(p);\n         argv[i] = 0;\n         ++gotpattern;\n         --nfile;\n      }\n   }\n   if (!gotpattern)\n      usage(\"No pattern\");\n   if (nfile == 0)\n      grep(stdin, 0);\n   else {\n      fflag = fflag ^ (nfile > 0);\n      for (i=1; i < argc; ++i) {\n         if (p = argv[i]) {\n            if ((f=fopen(p, \"r\")) == NULL)\n               cant(p);\n            else {\n               grep(f, p);\n               fclose(f);\n            }\n         }\n      }\n   }\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/47_switch_return.c",
    "content": "#include <stdio.h>\n\nvoid fred(int x)\n{\n   switch (x)\n   {\n      case 1: printf(\"1\\n\"); return;\n      case 2: printf(\"2\\n\"); break;\n      case 3: printf(\"3\\n\"); return;\n   }\n\n   printf(\"out\\n\");\n}\n\nint main()\n{\n   fred(1);\n   fred(2);\n   fred(3);\n\n   return 0;\n}    \n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/47_switch_return.expect",
    "content": "1\n2\nout\n3\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/48_nested_break.c",
    "content": "#include <stdio.h>\n\nint main()\n{\n   int a;\n   char b;\n\n   a = 0;\n   while (a < 2)\n   {\n      printf(\"%d\", a++);\n      break;\n\n      b = 'A';\n      while (b < 'C')\n      {\n         printf(\"%c\", b++);\n      }\n      printf(\"e\");\n   }\n   printf(\"\\n\");\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/48_nested_break.expect",
    "content": "0\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/49_bracket_evaluation.c",
    "content": "#include <stdio.h>\n\nstruct point\n{\n   double x;\n   double y;\n};\n\nstruct point point_array[100];\n\nint main()\n{\n   int my_point = 10;\n\n   point_array[my_point].x = 12.34;\n   point_array[my_point].y = 56.78;\n\n   printf(\"%f, %f\\n\", point_array[my_point].x, point_array[my_point].y);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/49_bracket_evaluation.expect",
    "content": "12.340000, 56.780000\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/50_logical_second_arg.c",
    "content": "#include <stdio.h>\n\nint fred()\n{\n   printf(\"fred\\n\");\n   return 0;\n}\n\nint joe()\n{\n   printf(\"joe\\n\");\n   return 1;\n}\n\nint main()\n{\n   printf(\"%d\\n\", fred() && joe());\n   printf(\"%d\\n\", fred() || joe());\n   printf(\"%d\\n\", joe() && fred());\n   printf(\"%d\\n\", joe() || fred());\n   printf(\"%d\\n\", fred() && (1 + joe()));\n   printf(\"%d\\n\", fred() || (0 + joe()));\n   printf(\"%d\\n\", joe() && (0 + fred()));\n   printf(\"%d\\n\", joe() || (1 + fred()));\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/50_logical_second_arg.expect",
    "content": "fred\n0\nfred\njoe\n1\njoe\nfred\n0\njoe\n1\nfred\n0\nfred\njoe\n1\njoe\nfred\n0\njoe\n1\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/51_static.c",
    "content": "#include <stdio.h>\n\nstatic int fred = 1234;\nstatic int joe;\n\nvoid henry()\n{\n   static int fred = 4567;\n\n   printf(\"%d\\n\", fred);\n   fred++;\n}\n\nint main()\n{\n   printf(\"%d\\n\", fred);\n   henry();\n   henry();\n   henry();\n   henry();\n   printf(\"%d\\n\", fred);\n   fred = 8901;\n   joe = 2345;\n   printf(\"%d\\n\", fred);\n   printf(\"%d\\n\", joe);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/51_static.expect",
    "content": "1234\n4567\n4568\n4569\n4570\n1234\n8901\n2345\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/52_unnamed_enum.c",
    "content": "#include <stdio.h>\n\nenum fred { a, b, c };\n\nint main()\n{\n   printf(\"a=%d\\n\", a);\n   printf(\"b=%d\\n\", b);\n   printf(\"c=%d\\n\", c);\n\n   enum fred d;\n\n   typedef enum { e, f, g } h;\n   typedef enum { i, j, k } m;\n\n   printf(\"e=%d\\n\", e);\n   printf(\"f=%d\\n\", f);\n   printf(\"g=%d\\n\", g);\n\n   printf(\"i=%d\\n\", i);\n   printf(\"j=%d\\n\", j);\n   printf(\"k=%d\\n\", k);\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/52_unnamed_enum.expect",
    "content": "a=0\nb=1\nc=2\ne=0\nf=1\ng=2\ni=0\nj=1\nk=2\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/54_goto.c",
    "content": "#include <stdio.h>\n\nvoid fred()\n{\n   printf(\"In fred()\\n\");\n   goto done;\n   printf(\"In middle\\n\");\ndone:\n   printf(\"At end\\n\");\n}\n\nvoid joe()\n{\n   int b = 5678;\n\n   printf(\"In joe()\\n\");\n\n   {\n      int c = 1234;\n      printf(\"c = %d\\n\", c);\n      goto outer;\n      printf(\"uh-oh\\n\");\n   }\n\nouter:    \n\n   printf(\"done\\n\");\n}\n\nvoid henry()\n{\n   int a;\n\n   printf(\"In henry()\\n\");\n   goto inner;\n\n   {\n      int b;\ninner:    \n      b = 1234;\n      printf(\"b = %d\\n\", b);\n   }\n\n   printf(\"done\\n\");\n}\n\nint main()\n{\n   fred();\n   joe();\n   henry();\n\n   return 0;\n}\n\n/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/54_goto.expect",
    "content": "In fred()\nAt end\nIn joe()\nc = 1234\ndone\nIn henry()\nb = 1234\ndone\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/55_lshift_type.c",
    "content": "/* $Id: lshift-type.c 53089 2012-07-06 11:18:26Z vinc17/ypig $\n\nTests on left-shift type, written by Vincent Lefevre <vincent@vinc17.net>.\n\nISO C99 TC3 says: [6.5.7#3] \"The integer promotions are performed on\neach of the operands. The type of the result is that of the promoted\nleft operand.\"\n*/\n\n#include <stdio.h>\n\n#define PTYPE(M) ((M) < 0 || -(M) < 0 ? -1 : 1) * (int) sizeof((M)+0)\n#define CHECK(X,T) check(#X, PTYPE(X), PTYPE((X) << (T) 1))\n#define TEST1(X,T) do { CHECK(X,T); CHECK(X,unsigned T); } while (0)\n#define TEST2(X)                 \\\n  do                             \\\n    {                            \\\n      TEST1((X),short);          \\\n      TEST1((X),int);            \\\n      TEST1((X),long);           \\\n      TEST1((X),long long);      \\\n    }                            \\\n  while (0)\n#define TEST3(X,T) do { TEST2((T)(X)); TEST2((unsigned T)(X)); } while (0)\n#define TEST4(X)                 \\\n  do                             \\\n    {                            \\\n      TEST3((X),short);          \\\n      TEST3((X),int);            \\\n      TEST3((X),long);           \\\n      TEST3((X),long long);      \\\n    }                            \\\n while (0)\n\nstatic int debug, nfailed = 0;\n\nstatic void check (const char *s, int arg1, int shift)\n{\n  int failed = arg1 != shift;\n  if (debug || failed)\n    printf (\"%s %d %d\\n\", s, arg1, shift);\n  nfailed += failed;\n}\n\nint main (int argc, char **argv)\n{\n  debug = argc > 1;\n  TEST4(1);\n  TEST4(-1);\n  printf (\"%d test(s) failed\\n\", nfailed);\n  return nfailed != 0;\n}\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/55_lshift_type.expect",
    "content": "0 test(s) failed\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/LICENSE",
    "content": "The tests in this directory are either directly copied from the picoc project or\nare subsequently modified and added to for the purpose of TinyCC project. All\nthese modifications are licensed under the same terms as TinyCC as specified in\nthe file COPYING.\n\n=== picoc license ===\n\nCopyright (c) 2009-2011, Zik Saleeba\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without \nmodification, are permitted provided that the following conditions are \nmet:\n\n    * Redistributions of source code must retain the above copyright \n      notice, this list of conditions and the following disclaimer.\n      \n    * Redistributions in binary form must reproduce the above copyright \n      notice, this list of conditions and the following disclaimer in \n      the documentation and/or other materials provided with the \n      distribution.\n      \n    * Neither the name of the Zik Saleeba nor the names of its \n      contributors may be used to endorse or promote products derived \n      from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/Makefile",
    "content": "TOP = ../..\ninclude $(TOP)/Makefile\nVPATH = $(top_srcdir)/tests/tests2\n\nTCCFLAGS = -B$(TOP)\nifdef CONFIG_WIN32\n TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir)/include -L$(TOP)\nendif\n\nifeq ($(TARGETOS),Darwin)\n CFLAGS += -Wl,-flat_namespace,-undefined,warning\n TCCFLAGS += -D_ANSI_SOURCE\n export MACOSX_DEPLOYMENT_TARGET:=10.2\nendif\n\nTCC_RUN = $(TOP)/tcc $(TCCFLAGS) -run\n\nTESTS =\t\\\n 00_assignment.test \\\n 01_comment.test \\\n 02_printf.test \\\n 03_struct.test \\\n 04_for.test \\\n 05_array.test \\\n 06_case.test \\\n 07_function.test \\\n 08_while.test \\\n 09_do_while.test \\\n 10_pointer.test \\\n 11_precedence.test \\\n 12_hashdefine.test \\\n 13_integer_literals.test \\\n 14_if.test \\\n 15_recursion.test \\\n 16_nesting.test \\\n 17_enum.test \\\n 18_include.test \\\n 19_pointer_arithmetic.test \\\n 20_pointer_comparison.test \\\n 21_char_array.test \\\n 22_floating_point.test \\\n 23_type_coercion.test \\\n 24_math_library.test \\\n 25_quicksort.test \\\n 26_character_constants.test \\\n 27_sizeof.test \\\n 28_strings.test \\\n 29_array_address.test \\\n 31_args.test \\\n 32_led.test \\\n 33_ternary_op.test \\\n 35_sizeof.test \\\n 36_array_initialisers.test \\\n 37_sprintf.test \\\n 38_multiple_array_index.test \\\n 39_typedef.test \\\n 40_stdio.test \\\n 41_hashif.test \\\n 42_function_pointer.test \\\n 43_void_param.test \\\n 44_scoped_declarations.test \\\n 45_empty_for.test \\\n 47_switch_return.test \\\n 48_nested_break.test \\\n 49_bracket_evaluation.test \\\n 50_logical_second_arg.test \\\n 51_static.test \\\n 52_unnamed_enum.test \\\n 54_goto.test \\\n 55_lshift_type.test\n\n# 30_hanoi.test -- seg fault in the code, gcc as well\n# 34_array_assignment.test -- array assignment is not in C standard\n# 46_grep.test -- does not compile even with gcc\n\n# some tests do not pass on all platforms, remove them for now\nifeq ($(TARGETOS),Darwin)\n  TESTS := $(filter-out 40_stdio.test,$(TESTS))\nendif\nifdef CONFIG_WIN32\n  TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS))\nendif\n\n%.test: %.c %.expect\n\t@echo Test: $*...\n\t@if [ \"x`echo $* | grep args`\" != \"x\" ]; \\\n\tthen $(TCC_RUN) $< - arg1 arg2 arg3 arg4 >$*.output; \\\n\telse $(TCC_RUN) $< >$*.output; \\\n\tfi\n\t@if diff -bu $(<:.c=.expect) $*.output ; \\\n\tthen rm -f $*.output; \\\n\telse exit 1; \\\n\tfi\n\nall test: $(TESTS)\n\nclean:\n\trm -vf fred.txt *.output\n"
  },
  {
    "path": "v2/testdata/tcc-0.9.26/tests/tests2/fred.txt",
    "content": "hello\nhello\n"
  },
  {
    "path": "v2/trigraphs.go",
    "content": "// Code generated by golex. DO NOT EDIT.\n\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n\n// Implements translation phases 1 and 2 of [0], 5.1.1.2.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\npackage cc\n\nimport (\n\t\"fmt\"\n)\n\nconst (\n\t_ = iota\n\tscTRIGRAPHS\n)\n\nfunc (t *trigraphs) scan() (r int) {\n\tc := t.Enter()\n\nyystate0:\n\tyyrule := -1\n\t_ = yyrule\n\tc = t.Rule0()\n\n\tswitch yyt := t.sc; yyt {\n\tdefault:\n\t\tpanic(fmt.Errorf(`invalid start condition %d`, yyt))\n\tcase 0: // start condition: INITIAL\n\t\tgoto yystart1\n\tcase 1: // start condition: TRIGRAPHS\n\t\tgoto yystart5\n\t}\n\n\tgoto yystate0 // silence unused label error\n\tgoto yyAction // silence unused label error\nyyAction:\n\tswitch yyrule {\n\tcase 1:\n\t\tgoto yyrule1\n\tcase 2:\n\t\tgoto yyrule2\n\tcase 3:\n\t\tgoto yyrule3\n\tcase 4:\n\t\tgoto yyrule4\n\tcase 5:\n\t\tgoto yyrule5\n\tcase 6:\n\t\tgoto yyrule6\n\tcase 7:\n\t\tgoto yyrule7\n\tcase 8:\n\t\tgoto yyrule8\n\tcase 9:\n\t\tgoto yyrule9\n\tcase 10:\n\t\tgoto yyrule10\n\tcase 11:\n\t\tgoto yyrule11\n\t}\n\tgoto yystate1 // silence unused label error\nyystate1:\n\tc = t.Next()\nyystart1:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\\\':\n\t\tgoto yystate3\n\tcase c == '\\r':\n\t\tgoto yystate2\n\t}\n\nyystate2:\n\tc = t.Next()\n\tyyrule = 10\n\tt.Mark()\n\tgoto yyrule10\n\nyystate3:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate2\n\tcase c == '\\r':\n\t\tgoto yystate4\n\t}\n\nyystate4:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate2\n\t}\n\n\tgoto yystate5 // silence unused label error\nyystate5:\n\tc = t.Next()\nyystart5:\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '?':\n\t\tgoto yystate6\n\tcase c == '\\\\':\n\t\tgoto yystate3\n\tcase c == '\\r':\n\t\tgoto yystate2\n\t}\n\nyystate6:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '?':\n\t\tgoto yystate7\n\t}\n\nyystate7:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '!':\n\t\tgoto yystate8\n\tcase c == '(':\n\t\tgoto yystate10\n\tcase c == ')':\n\t\tgoto yystate11\n\tcase c == '-':\n\t\tgoto yystate12\n\tcase c == '/':\n\t\tgoto yystate13\n\tcase c == '<':\n\t\tgoto yystate16\n\tcase c == '=':\n\t\tgoto yystate17\n\tcase c == '>':\n\t\tgoto yystate18\n\tcase c == '\\'':\n\t\tgoto yystate9\n\t}\n\nyystate8:\n\tc = t.Next()\n\tyyrule = 1\n\tt.Mark()\n\tgoto yyrule1\n\nyystate9:\n\tc = t.Next()\n\tyyrule = 2\n\tt.Mark()\n\tgoto yyrule2\n\nyystate10:\n\tc = t.Next()\n\tyyrule = 3\n\tt.Mark()\n\tgoto yyrule3\n\nyystate11:\n\tc = t.Next()\n\tyyrule = 4\n\tt.Mark()\n\tgoto yyrule4\n\nyystate12:\n\tc = t.Next()\n\tyyrule = 5\n\tt.Mark()\n\tgoto yyrule5\n\nyystate13:\n\tc = t.Next()\n\tyyrule = 6\n\tt.Mark()\n\tswitch {\n\tdefault:\n\t\tgoto yyrule6\n\tcase c == '\\n':\n\t\tgoto yystate14\n\tcase c == '\\r':\n\t\tgoto yystate15\n\t}\n\nyystate14:\n\tc = t.Next()\n\tyyrule = 11\n\tt.Mark()\n\tgoto yyrule11\n\nyystate15:\n\tc = t.Next()\n\tswitch {\n\tdefault:\n\t\tgoto yyabort\n\tcase c == '\\n':\n\t\tgoto yystate14\n\t}\n\nyystate16:\n\tc = t.Next()\n\tyyrule = 7\n\tt.Mark()\n\tgoto yyrule7\n\nyystate17:\n\tc = t.Next()\n\tyyrule = 8\n\tt.Mark()\n\tgoto yyrule8\n\nyystate18:\n\tc = t.Next()\n\tyyrule = 9\n\tt.Mark()\n\tgoto yyrule9\n\nyyrule1: // \"??!\"\n\t{\n\t\treturn '|'\n\t}\nyyrule2: // \"??'\"\n\t{\n\t\treturn '^'\n\t}\nyyrule3: // \"??(\"\n\t{\n\t\treturn '['\n\t}\nyyrule4: // \"??)\"\n\t{\n\t\treturn ']'\n\t}\nyyrule5: // \"??-\"\n\t{\n\t\treturn '~'\n\t}\nyyrule6: // \"??/\"\n\t{\n\t\treturn '\\\\'\n\t}\nyyrule7: // \"??<\"\n\t{\n\t\treturn '{'\n\t}\nyyrule8: // \"??=\"\n\t{\n\t\treturn '#'\n\t}\nyyrule9: // \"??>\"\n\t{\n\t\treturn '}'\n\t}\nyyrule10: // \\\\\\r?\\n|\\r\nyyrule11: // \"??/\"\\r?\\n\n\n\tgoto yystate0\n\tpanic(\"unreachable\")\n\n\tgoto yyabort // silence unused label error\n\nyyabort: // no lexem recognized\n\tif c, ok := t.Abort(); ok {\n\t\treturn c\n\t}\n\n\tgoto yyAction\n}\n"
  },
  {
    "path": "v2/trigraphs.l",
    "content": "%{\n// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// Based on [0], 6.4.\n\n// Implements translation phases 1 and 2 of [0], 5.1.1.2.\n//\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n%}\n\n%yyc c\n%yyn c = t.Next()\n%yym t.Mark()\n%yyt t.sc\n\n%s TRIGRAPHS\n\n%{\npackage cc\n\nimport (\n        \"fmt\"\n)\n\nconst (\n        _ = iota\n        scTRIGRAPHS\n)\n\nfunc (t *trigraphs) scan() (r int) {\n        c := t.Enter()\n%}\n\n%%\n        c = t.Rule0()\n\n<TRIGRAPHS>\"??!\"        return '|'\n<TRIGRAPHS>\"??'\"        return '^'\n<TRIGRAPHS>\"??(\"        return '['\n<TRIGRAPHS>\"??)\"        return ']'\n<TRIGRAPHS>\"??-\"        return '~'\n<TRIGRAPHS>\"??/\"        return '\\\\'\n<TRIGRAPHS>\"??<\"        return '{'\n<TRIGRAPHS>\"??=\"        return '#'\n<TRIGRAPHS>\"??>\"        return '}'\n\n\\\\\\r?\\n|\\r |\n<TRIGRAPHS>\"??/\"\\r?\\n\n\n%%\n        if c, ok := t.Abort(); ok {\n                return c\n        }\n        \n        goto yyAction\n}\n"
  },
  {
    "path": "v2/type.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\npackage cc\n\n// [0]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\n\t\"github.com/cznic/ir\"\n)\n\nvar (\n\t_ Type = (*ArrayType)(nil)\n\t_ Type = (*EnumType)(nil)\n\t_ Type = (*FunctionType)(nil)\n\t_ Type = (*NamedType)(nil)\n\t_ Type = (*PointerType)(nil)\n\t_ Type = (*StructType)(nil)\n\t_ Type = (*TaggedStructType)(nil)\n\t_ Type = (*TaggedUnionType)(nil)\n\t_ Type = (*TaggedEnumType)(nil)\n\t_ Type = (*UnionType)(nil)\n\t_ Type = TypeKind(0)\n\n\t_ fieldFinder = (*StructType)(nil)\n\t_ fieldFinder = (*UnionType)(nil)\n)\n\ntype fieldFinder interface {\n\tfindField(int) *FieldProperties\n}\n\n// Type represents a C type.\ntype Type interface {\n\tEqual(Type) bool\n\tIsArithmeticType() bool\n\tIsCompatible(Type) bool // [0]6.2.7\n\tIsIntegerType() bool\n\tIsPointerType() bool\n\tIsScalarType() bool\n\tIsUnsigned() bool\n\tIsVoidPointerType() bool\n\tKind() TypeKind\n\tString() string\n\tassign(ctx *context, n Node, op Operand) Operand\n}\n\n// TypeKind represents a particular type kind.\ntype TypeKind int\n\n// TypeKind values.\nconst (\n\t_ TypeKind = iota\n\n\tBool\n\tChar\n\tInt\n\tLong\n\tLongLong\n\tSChar\n\tShort\n\tUChar\n\tUInt\n\tULong\n\tULongLong\n\tUShort\n\n\tFloat\n\tDouble\n\tLongDouble\n\n\tFloatComplex\n\tDoubleComplex\n\tLongDoubleComplex\n\n\tArray\n\tEnum\n\tEnumTag\n\tFunction\n\tPtr\n\tStruct\n\tStructTag\n\tTypedefName\n\tUnion\n\tUnionTag\n\tVoid\n\n\tmaxTypeKind\n)\n\n// IsUnsigned implements Type.\nfunc (t TypeKind) IsUnsigned() bool { return t.IsIntegerType() && !isSigned[t] }\n\n// Kind implements Type.\nfunc (t TypeKind) Kind() TypeKind { return t }\n\n// assign implements Type.\nfunc (t TypeKind) assign(ctx *context, n Node, op Operand) Operand {\n\t// [0]6.5.16.1\n\tswitch {\n\t// One of the following shall hold:\n\tcase\n\t\t// the left operand has qualified or unqualified arithmetic\n\t\t// type and the right has arithmetic type;\n\t\tt.IsArithmeticType() && op.Type.IsArithmeticType():\n\t\treturn op.ConvertTo(ctx.model, t)\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"%v: %v <- %v\", ctx.position(n), t, op))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t TypeKind) IsPointerType() bool {\n\tif t.IsArithmeticType() {\n\t\treturn false\n\t}\n\n\tswitch t {\n\tcase Void:\n\t\treturn false\n\tdefault:\n\t\tpanic(t)\n\t}\n}\n\n// IsIntegerType implements Type.\nfunc (t TypeKind) IsIntegerType() bool {\n\tswitch t {\n\tcase\n\t\tBool,\n\t\tChar,\n\t\tInt,\n\t\tLong,\n\t\tLongLong,\n\t\tSChar,\n\t\tShort,\n\t\tUChar,\n\t\tUInt,\n\t\tULong,\n\t\tULongLong,\n\t\tUShort:\n\n\t\treturn true\n\tcase\n\t\tDouble,\n\t\tDoubleComplex,\n\t\tFloat,\n\t\tFloatComplex,\n\t\tLongDouble,\n\t\tLongDoubleComplex,\n\t\tVoid:\n\n\t\treturn false\n\tdefault:\n\t\tpanic(t)\n\t}\n}\n\n// IsScalarType implements Type.\nfunc (t TypeKind) IsScalarType() bool {\n\tswitch t {\n\tcase\n\t\tChar,\n\t\tDouble,\n\t\tDoubleComplex,\n\t\tFloat,\n\t\tFloatComplex,\n\t\tInt,\n\t\tLong,\n\t\tLongDouble,\n\t\tLongDoubleComplex,\n\t\tLongLong,\n\t\tSChar,\n\t\tShort,\n\t\tUChar,\n\t\tUInt,\n\t\tULong,\n\t\tULongLong,\n\t\tUShort:\n\n\t\treturn true\n\tcase Void:\n\t\treturn false\n\tdefault:\n\t\tpanic(t)\n\t}\n}\n\n// IsVoidPointerType implements Type.\nfunc (t TypeKind) IsVoidPointerType() bool {\n\tif t != Ptr {\n\t\treturn false\n\t}\n\n\tpanic(t)\n}\n\n// IsArithmeticType implements Type.\nfunc (t TypeKind) IsArithmeticType() bool { return isArithmeticType[t] }\n\n// IsCompatible implements Type.\nfunc (t TypeKind) IsCompatible(u Type) bool {\n\tfor {\n\t\tswitch x := u.(type) {\n\t\tcase *PointerType:\n\t\t\tswitch t {\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tInt:\n\n\t\t\t\treturn false\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v %v\", t, x))\n\t\t\t}\n\t\tcase *NamedType:\n\t\t\tu = x.Type\n\t\tcase *EnumType:\n\t\t\tu = x.Enums[0].Operand.Type\n\t\tcase TypeKind:\n\t\t\tif t.IsIntegerType() && u.IsIntegerType() {\n\t\t\t\treturn intConvRank[t] == intConvRank[x] && isSigned[t] == isSigned[x]\n\t\t\t}\n\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tDouble,\n\t\t\t\tDoubleComplex,\n\t\t\t\tFloat,\n\t\t\t\tFloatComplex,\n\t\t\t\tLongDouble,\n\t\t\t\tLongDoubleComplex:\n\n\t\t\t\treturn t == x\n\t\t\tcase Void:\n\t\t\t\treturn t == x\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v\", x))\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v %T\", t, x))\n\t\t}\n\t}\n}\n\n// Equal implements Type.\nfunc (t TypeKind) Equal(u Type) bool {\n\tswitch x := u.(type) {\n\tcase\n\t\t*ArrayType,\n\t\t*EnumType,\n\t\t*FunctionType,\n\t\t*PointerType,\n\t\t*StructType,\n\t\t*TaggedEnumType,\n\t\t*TaggedStructType,\n\t\t*TaggedUnionType,\n\t\t*UnionType:\n\n\t\tif t.IsScalarType() || t == Void {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(t)\n\tcase *NamedType:\n\t\treturn t.Equal(x.Type)\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tBool,\n\t\t\tChar,\n\t\t\tDouble,\n\t\t\tDoubleComplex,\n\t\t\tFloat,\n\t\t\tFloatComplex,\n\t\t\tInt,\n\t\t\tLong,\n\t\t\tLongDouble,\n\t\t\tLongDoubleComplex,\n\t\t\tLongLong,\n\t\t\tSChar,\n\t\t\tShort,\n\t\t\tUChar,\n\t\t\tUInt,\n\t\t\tULong,\n\t\t\tULongLong,\n\t\t\tUShort,\n\t\t\tVoid:\n\n\t\t\treturn t == x\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\nfunc (t TypeKind) String() string {\n\tswitch t {\n\tcase Bool:\n\t\treturn \"bool\"\n\tcase Char:\n\t\treturn \"char\"\n\tcase Int:\n\t\treturn \"int\"\n\tcase Long:\n\t\treturn \"long\"\n\tcase LongLong:\n\t\treturn \"long long\"\n\tcase SChar:\n\t\treturn \"signed char\"\n\tcase Short:\n\t\treturn \"short\"\n\tcase UChar:\n\t\treturn \"unsigned char\"\n\tcase UInt:\n\t\treturn \"unsigned\"\n\tcase ULong:\n\t\treturn \"unsigned long\"\n\tcase ULongLong:\n\t\treturn \"unsigned long long\"\n\tcase UShort:\n\t\treturn \"unsigned short\"\n\tcase Float:\n\t\treturn \"float\"\n\tcase Double:\n\t\treturn \"double\"\n\tcase LongDouble:\n\t\treturn \"long double\"\n\tcase FloatComplex:\n\t\treturn \"float complex\"\n\tcase DoubleComplex:\n\t\treturn \"double complex\"\n\tcase LongDoubleComplex:\n\t\treturn \"long double complex\"\n\tcase Array:\n\t\treturn \"array\"\n\tcase Enum:\n\t\treturn \"enum\"\n\tcase EnumTag:\n\t\treturn \"enum tag\"\n\tcase Function:\n\t\treturn \"function\"\n\tcase Ptr:\n\t\treturn \"ptr\"\n\tcase Struct:\n\t\treturn \"struct\"\n\tcase StructTag:\n\t\treturn \"struct tag\"\n\tcase TypedefName:\n\t\treturn \"typedef name\"\n\tcase Union:\n\t\treturn \"union\"\n\tcase Void:\n\t\treturn \"void\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"TypeKind(%v)\", int(t))\n\t}\n}\n\n// ArrayType type represents an array type.\ntype ArrayType struct {\n\tItem           Type\n\tSize           Operand\n\tTypeQualifiers []*TypeQualifier // Eg. double a[restrict 3][5], see 6.7.5.3-21.\n}\n\n// IsUnsigned implements Type.\nfunc (t *ArrayType) IsUnsigned() bool { panic(\"TODO\") }\n\n// IsVoidPointerType implements Type.\nfunc (t *ArrayType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *ArrayType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *ArrayType) IsCompatible(u Type) bool {\n\t// [0]6.7.5.2\n\t//\n\t// 6. For two array types to be compatible, both shall have compatible\n\t// element types, and if both size specifiers are present, and are\n\t// integer constant expressions, then both size specifiers shall have\n\t// the same constant value. If the two array types are used in a\n\t// context which requires them to be compatible, it is undefined\n\t// behavior if the two size specifiers evaluate to unequal values.\n\tswitch x := u.(type) {\n\tcase *ArrayType:\n\t\tif !t.Item.IsCompatible(x.Item) {\n\t\t\treturn false\n\t\t}\n\n\t\tif t.Size.Type != nil && x.Size.Type != nil {\n\t\t\treturn t.Size.Value.(*ir.Int64Value).Value == x.Size.Value.(*ir.Int64Value).Value\n\t\t}\n\n\t\treturn true\n\tcase *NamedType:\n\t\treturn x.IsCompatible(t)\n\tcase *PointerType:\n\t\treturn t.Size.Type == nil && t.Item.IsCompatible(x.Item)\n\tcase TypeKind:\n\t\tif x.IsArithmeticType() {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%T\\n%v\\n%v\", x, t, u))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\\n%v\\n%v\", x, t, u))\n\t}\n}\n\n// Equal implements Type.\nfunc (t *ArrayType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase *ArrayType:\n\t\tif !t.Item.Equal(x.Item) {\n\t\t\treturn false\n\t\t}\n\n\t\tswitch {\n\t\tcase t.Size.Type != nil && x.Size.Type != nil:\n\t\t\treturn x.Size.Type != nil && t.Size.Value.(*ir.Int64Value).Value == x.Size.Value.(*ir.Int64Value).Value\n\t\tcase t.Size.Type == nil && x.Size.Type == nil:\n\t\t\treturn true\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v, %v\", t, u))\n\t\t}\n\tcase *NamedType:\n\t\treturn x.Type.Equal(t)\n\tcase\n\t\t*FunctionType,\n\t\t*PointerType,\n\t\t*StructType,\n\t\t*TaggedStructType:\n\n\t\treturn false\n\tcase TypeKind:\n\t\tif x.IsScalarType() || x == Void {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(x)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T %v\", x, x))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *ArrayType) Kind() TypeKind { return Array }\n\n// assign implements Type.\nfunc (t *ArrayType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch {\n\tcase t.Size.Value == nil:\n\t\treturn (&PointerType{Item: t.Item}).assign(ctx, n, op)\n\tdefault:\n\t\tpanic(\"TODO\")\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *ArrayType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *ArrayType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *ArrayType) IsScalarType() bool { return false }\n\nfunc (t *ArrayType) String() string {\n\tswitch {\n\tcase t.Size.Type != nil && t.Size.Value != nil:\n\t\treturn fmt.Sprintf(\"array of %v %v\", t.Size.Value, t.Item)\n\tdefault:\n\t\treturn fmt.Sprintf(\"array of %v\", t.Item)\n\t}\n}\n\n// EnumType represents an enum type.\ntype EnumType struct {\n\tTag   int\n\tEnums []*EnumerationConstant\n\tMin   int64\n\tMax   uint64\n}\n\nfunc (t *EnumType) find(nm int) *EnumerationConstant {\n\tfor _, v := range t.Enums {\n\t\tif v.Token.Val == nm {\n\t\t\treturn v\n\t\t}\n\t}\n\treturn nil\n}\n\n// IsUnsigned implements Type.\nfunc (t *EnumType) IsUnsigned() bool { return t.Enums[0].Operand.Type.IsUnsigned() }\n\n// IsVoidPointerType implements Type.\nfunc (t *EnumType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *EnumType) IsArithmeticType() bool { return true }\n\n// IsCompatible implements Type.\nfunc (t *EnumType) IsCompatible(u Type) bool {\n\tswitch x := underlyingType(u, true).(type) {\n\tcase *EnumType:\n\t\tif len(t.Enums) != len(x.Enums) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, v := range t.Enums {\n\t\t\tif !v.equal(x.Enums[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// Equal implements Type.\nfunc (t *EnumType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := UnderlyingType(u).(type) {\n\tcase *EnumType:\n\t\tif t.Tag != x.Tag || len(t.Enums) != len(x.Enums) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, v := range t.Enums {\n\t\t\tw := x.Enums[i]\n\t\t\tif !v.Operand.Type.Equal(w.Operand.Type) || v.Operand.Value.(*ir.Int64Value).Value != w.Operand.Value.(*ir.Int64Value).Value {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\tcase TypeKind:\n\t\tif x.IsScalarType() {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%v %T %v\", t, x, x))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v %T %v\", t, x, x))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *EnumType) Kind() TypeKind { return Enum }\n\n// assign implements Type.\nfunc (t *EnumType) assign(ctx *context, n Node, op Operand) Operand {\n\treturn op.ConvertTo(ctx.model, t)\n}\n\n// IsPointerType implements Type.\nfunc (t *EnumType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *EnumType) IsIntegerType() bool { return true }\n\n// IsScalarType implements Type.\nfunc (t *EnumType) IsScalarType() bool { return true }\n\nfunc (t *EnumType) String() string {\n\treturn fmt.Sprintf(\"%s enumeration %s\", t.Enums[0].Operand.Type.String(), dict.S(t.Tag))\n}\n\n// Field represents a struct/union field.\ntype Field struct {\n\tBits       int\n\tDeclarator *Declarator\n\tName       int\n\tPackedType Type // Bits != 0: underlaying struct field type\n\tType       Type\n\n\tAnonymous bool\n}\n\nfunc (f Field) equal(g Field) bool {\n\treturn f.Name == g.Name && f.Type.Equal(g.Type) && f.Bits == g.Bits\n}\n\nfunc (f Field) isCompatiblel(g Field) bool {\n\treturn f.Name == g.Name && f.Type.IsCompatible(g.Type) && f.Bits == g.Bits\n}\n\nfunc (f Field) String() string { return fmt.Sprintf(\"%s %v\", dict.S(f.Name), f.Type) }\n\n// FunctionType represents a function type.\ntype FunctionType struct {\n\tParams   []Type\n\tResult   Type\n\tVariadic bool\n\tparams   []int\n}\n\n// IsUnsigned implements Type.\nfunc (t *FunctionType) IsUnsigned() bool { panic(\"TODO\") }\n\n// IsVoidPointerType implements Type.\nfunc (t *FunctionType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *FunctionType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *FunctionType) IsCompatible(u Type) bool {\n\tswitch x := u.(type) {\n\tcase *FunctionType:\n\t\tif t.Variadic != x.Variadic || !t.Result.IsCompatible(x.Result) {\n\t\t\treturn false\n\t\t}\n\n\t\tif len(t.Params) != len(x.Params) {\n\t\t\tswitch {\n\t\t\tcase len(t.Params) == 1 && len(x.Params) == 0 && t.Params[0].Kind() == Void:\n\t\t\t\treturn true\n\t\t\tcase len(t.Params) == 0 && len(x.Params) == 1 && x.Params[0].Kind() == Void:\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, t := range t.Params {\n\t\t\tif !t.IsCompatible(x.Params[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tcase *NamedType:\n\t\treturn x.Type.IsCompatible(t)\n\tcase *PointerType:\n\t\treturn x.Item.IsCompatible(t)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// Equal implements Type.\nfunc (t *FunctionType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase *FunctionType:\n\t\tif len(t.Params) != len(x.Params) || t.Variadic != x.Variadic || !t.Result.Equal(x.Result) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, t := range t.Params {\n\t\t\tif !t.Equal(x.Params[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tcase\n\t\t*NamedType,\n\t\t*PointerType,\n\t\t*StructType:\n\n\t\treturn false\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tChar,\n\t\t\tInt,\n\t\t\tVoid:\n\n\t\t\treturn false\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *FunctionType) Kind() TypeKind { return Function }\n\n// assign implements Type.\nfunc (t *FunctionType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := UnderlyingType(op.Type).(type) {\n\tcase *PointerType:\n\t\tswitch y := UnderlyingType(x.Item).(type) {\n\t\tcase *FunctionType:\n\t\t\tif !t.Equal(y) {\n\t\t\t\tpanic(fmt.Errorf(\"%v: %v != %v\", ctx.position(n), t, y))\n\t\t\t}\n\n\t\t\treturn op\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), y))\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: %T\", ctx.position(n), x))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *FunctionType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *FunctionType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *FunctionType) IsScalarType() bool { return false }\n\nfunc (t *FunctionType) String() string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(\"function (\")\n\tswitch {\n\tcase len(t.Params) == 1 && t.Params[0].Kind() == Void:\n\t\t// nop\n\tdefault:\n\t\tfor i, v := range t.Params {\n\t\t\tif i != 0 {\n\t\t\t\tbuf.WriteString(\", \")\n\t\t\t}\n\t\t\tbuf.WriteString(v.String())\n\t\t}\n\t}\n\tfmt.Fprintf(&buf, \") returning %v\", t.Result)\n\treturn buf.String()\n}\n\n// NamedType represents a type described by a typedef name.\ntype NamedType struct {\n\tName int\n\tType Type // The type Name refers to.\n}\n\n// IsUnsigned implements Type.\nfunc (t *NamedType) IsUnsigned() bool { return t.Type.IsUnsigned() }\n\n// IsVoidPointerType implements Type.\nfunc (t *NamedType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *NamedType) IsArithmeticType() bool { return t.Type.IsArithmeticType() }\n\n// IsCompatible implements Type.\nfunc (t *NamedType) IsCompatible(u Type) (r bool) {\n\treturn UnderlyingType(t.Type).IsCompatible(UnderlyingType(u))\n}\n\n// Equal implements Type.\nfunc (t *NamedType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase *ArrayType:\n\t\treturn x.Equal(t.Type)\n\tcase *EnumType:\n\t\treturn x.Equal(t.Type)\n\tcase *NamedType:\n\t\treturn t.Name == x.Name && t.Type.Equal(x.Type)\n\tcase\n\t\t*FunctionType,\n\t\t*PointerType:\n\n\t\treturn x.Equal(t.Type)\n\tcase *StructType:\n\t\treturn t.Type.Equal(x)\n\tcase *TaggedEnumType:\n\t\tv := x.getType()\n\t\treturn v != x && t.Type.Equal(v)\n\tcase *TaggedStructType:\n\t\tv := x.getType()\n\t\treturn v != x && t.Type.Equal(v)\n\tcase *TaggedUnionType:\n\t\tv := x.getType()\n\t\treturn v != x && t.Type.Equal(v)\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tChar,\n\t\t\tDouble,\n\t\t\tFloat,\n\t\t\tInt,\n\t\t\tLong,\n\t\t\tLongDouble,\n\t\t\tLongLong,\n\t\t\tSChar,\n\t\t\tShort,\n\t\t\tUChar,\n\t\t\tUInt,\n\t\t\tULong,\n\t\t\tULongLong,\n\t\t\tUShort,\n\t\t\tVoid:\n\n\t\t\treturn x.Equal(t.Type)\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tcase *UnionType:\n\t\treturn t.Type.Equal(x)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T: %v, %v\", x, t.Type, u))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *NamedType) Kind() TypeKind { return t.Type.Kind() }\n\n// assign implements Type.\nfunc (t *NamedType) assign(ctx *context, n Node, op Operand) Operand { return t.Type.assign(ctx, n, op) }\n\n// IsPointerType implements Type.\nfunc (t *NamedType) IsPointerType() bool { return t.Type.IsPointerType() }\n\n// IsIntegerType implements Type.\nfunc (t *NamedType) IsIntegerType() bool { return t.Type.IsIntegerType() }\n\n// IsScalarType implements Type.\nfunc (t *NamedType) IsScalarType() bool { return t.Type.IsScalarType() }\n\nfunc (t *NamedType) String() string { return string(dict.S(t.Name)) }\n\n// PointerType represents a pointer type.\ntype PointerType struct {\n\tItem Type\n}\n\n// IsUnsigned implements Type.\nfunc (t *PointerType) IsUnsigned() bool { return true }\n\n// IsVoidPointerType implements Type.\nfunc (t *PointerType) IsVoidPointerType() bool { return UnderlyingType(t.Item) == Void }\n\n// IsArithmeticType implements Type.\nfunc (t *PointerType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *PointerType) IsCompatible(u Type) bool {\n\tif t.Equal(u) {\n\t\treturn true\n\t}\n\n\tvar ai Type\n\tswitch x := UnderlyingType(t.Item).(type) {\n\tcase *ArrayType:\n\t\tai = x.Item\n\t}\n\n\tswitch x := UnderlyingType(u).(type) {\n\tcase *ArrayType:\n\t\treturn t.Item.IsCompatible(x.Item)\n\tcase *NamedType:\n\t\treturn t.IsCompatible(x.Type)\n\tcase *FunctionType:\n\t\treturn x.IsCompatible(t)\n\tcase *PointerType:\n\t\t// [0]6.3.2.3\n\t\t//\n\t\t// 1. A pointer to void may be converted to or from a pointer to any\n\t\t// incomplete or object type. A pointer to any incomplete or object\n\t\t// type may be converted to a pointer to void and back again; the\n\t\t// result shall compare equal to the original pointer.\n\t\treturn t.Item == Void || x.Item == Void ||\n\t\t\tai != nil && ai.IsCompatible(x.Item) ||\n\t\t\tunderlyingType(t.Item, true).IsCompatible(underlyingType(x.Item, true)) ||\n\t\t\tUnsigned(t.Item) == Unsigned(x.Item)\n\tcase *StructType:\n\t\treturn false\n\tcase TypeKind:\n\t\tif u.IsArithmeticType() {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%T\\n%v\\n%v\", x, t, u))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\\n%v\\n%v\", x, t, u))\n\t}\n}\n\nfunc Unsigned(t Type) TypeKind {\n\tswitch k := underlyingType(t, false).Kind(); k {\n\tcase Char, SChar:\n\t\treturn UChar\n\tcase Short:\n\t\treturn UShort\n\tcase Int:\n\t\treturn UInt\n\tcase Long:\n\t\treturn ULong\n\tcase LongLong:\n\t\treturn ULongLong\n\tdefault:\n\t\treturn k\n\t}\n}\n\n// Equal implements Type.\nfunc (t *PointerType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase\n\t\t*ArrayType,\n\t\t*FunctionType,\n\t\t*StructType,\n\t\t*TaggedStructType,\n\t\t*UnionType:\n\n\t\treturn false\n\tcase *NamedType:\n\t\treturn t.Equal(x.Type)\n\tcase *PointerType:\n\t\treturn t.Item.Equal(x.Item)\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tChar,\n\t\t\tDouble,\n\t\t\tFloat,\n\t\t\tInt,\n\t\t\tLong,\n\t\t\tLongLong,\n\t\t\tShort,\n\t\t\tUChar,\n\t\t\tUInt,\n\t\t\tULong,\n\t\t\tULongLong,\n\t\t\tUShort,\n\t\t\tVoid:\n\n\t\t\treturn false\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *PointerType) Kind() TypeKind { return Ptr }\n\n// assign implements Type.\nfunc (t *PointerType) assign(ctx *context, n Node, op Operand) (r Operand) {\n\tu := UnderlyingType(t.Item)\n\tvar v Type\n\tif op.Type.IsPointerType() {\n\t\tv = UnderlyingType(UnderlyingType(op.Type).(*PointerType).Item)\n\t}\n\t// [0]6.5.16.1\n\tswitch {\n\t// One of the following shall hold:\n\tcase ctx.tweaks.EnablePointerCompatibility && op.Type.IsPointerType():\n\t\treturn op.ConvertTo(ctx.model, t)\n\tcase\n\t\t// both operands are pointers to qualified or unqualified\n\t\t// versions of compatible types, and the type pointed to by the\n\t\t// left has all the qualifiers of the type pointed to by the\n\t\t// right;\n\t\top.Type.IsPointerType() && t.IsCompatible(op.Type),\n\t\tu.IsIntegerType() && v != nil && v.IsIntegerType() && ctx.model.Sizeof(u) == ctx.model.Sizeof(v) && u.IsUnsigned() == v.IsUnsigned():\n\n\t\treturn op.ConvertTo(ctx.model, t)\n\tcase\n\t\t// one operand is a pointer to an object or incomplete type and\n\t\t// the other is a pointer to a qualified or unqualified version\n\t\t// of void, and the type pointed to by the left has all the\n\t\t// qualifiers of the type pointed to by the right;\n\t\tt.IsPointerType() && op.Type.IsVoidPointerType():\n\n\t\tpanic(\"TODO\")\n\tcase\n\t\t// the left operand is a pointer and the right is a null\n\t\t// pointer constant;\n\t\top.isNullPtrConst():\n\n\t\treturn Operand{Type: t, Value: Null}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: lhs type %v <- operand %v, op.IsPointerType %v op.IsCompatible %v\", ctx.position(n), t, op, op.Type.IsPointerType(), t.IsCompatible(op.Type)))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *PointerType) IsPointerType() bool { return true }\n\n// IsIntegerType implements Type.\nfunc (t *PointerType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *PointerType) IsScalarType() bool { return true }\n\nfunc (t *PointerType) String() string { return fmt.Sprintf(\"pointer to %v\", t.Item) }\n\ntype structBase struct {\n\tFields []Field\n\tTag    int\n\tscope  *Scope\n\tlayout []FieldProperties\n}\n\nfunc (s *structBase) findField(nm int) *FieldProperties {\n\tfps := s.layout\n\tif x, ok := s.scope.Idents[nm].(*Declarator); ok {\n\t\tr := fps[x.Field]\n\t\treturn &r\n\t}\n\n\tfor _, v := range fps {\n\t\tif v.Declarator != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tx, ok := v.Type.(fieldFinder)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tif fp := x.findField(nm); fp != nil {\n\t\t\tr := *fp\n\t\t\tr.Offset += v.Offset\n\t\t\treturn &r\n\t\t}\n\t}\n\treturn nil\n}\n\n// StructType represents a struct type.\ntype StructType struct{ structBase }\n\n// IsUnsigned implements Type.\nfunc (t *StructType) IsUnsigned() bool { panic(\"TODO\") }\n\n// Field returns the properties of field nm or nil if the field does not exist.\nfunc (t *StructType) Field(nm int) *FieldProperties {\n\treturn t.findField(nm)\n}\n\n// IsVoidPointerType implements Type.\nfunc (t *StructType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *StructType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *StructType) IsCompatible(u Type) bool {\n\tif t.Equal(u) {\n\t\treturn true\n\t}\n\n\t// [0]6.2.7.1\n\t//\n\t// Moreover, two structure, union, or enumerated types declared in\n\t// separate translation units are compatible if their tags and members\n\t// satisfy the following requirements: If one is declared with a tag,\n\t// the other shall be declared with the same tag. If both are complete\n\t// types, then the following additional requirements apply: there shall\n\t// be a one-to-one correspondence between their members such that each\n\t// pair of corresponding members are declared with compatible types,\n\t// and such that if one member of a corresponding pair is declared with\n\t// a name, the other member is declared with the same name. For two\n\t// structures, corresponding members shall be declared in the same\n\t// order. For two structures or unions, corresponding bit-fields shall\n\t// have the same widths.\n\tswitch x := UnderlyingType(u).(type) {\n\tcase *StructType:\n\t\t//TODO if len(t.Fields) != len(x.Fields) || t.Tag != x.Tag { // Fails in _sqlite/src/test_fs.c\n\t\tif len(t.Fields) != len(x.Fields) {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, v := range t.Fields {\n\t\t\tif !v.isCompatiblel(x.Fields[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// Equal implements Type.\nfunc (t *StructType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase *NamedType:\n\t\treturn t.Equal(x.Type)\n\tcase\n\t\t*ArrayType,\n\t\t*FunctionType,\n\t\t*PointerType:\n\n\t\treturn false\n\tcase *StructType:\n\t\tif len(t.Fields) != len(x.Fields) || t.Tag != x.Tag {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, v := range t.Fields {\n\t\t\tif !v.equal(x.Fields[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tcase *TaggedStructType:\n\t\tv := x.getType()\n\t\tif v == u {\n\t\t\treturn false\n\t\t}\n\n\t\treturn t.Equal(v)\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tChar,\n\t\t\tInt,\n\t\t\tLong,\n\t\t\tUChar,\n\t\t\tUInt,\n\t\t\tUShort,\n\t\t\tVoid:\n\n\t\t\treturn false\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// Kind implements Type.\nfunc (t *StructType) Kind() TypeKind { return Struct }\n\n// assign implements Type.\nfunc (t *StructType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := op.Type.(type) {\n\tcase *StructType:\n\t\tif !t.IsCompatible(x) {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn Operand{Type: t}\n\tcase *NamedType:\n\t\tif !t.IsCompatible(x.Type) {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn Operand{Type: t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: %T %v\", ctx.position(n), x, x))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *StructType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *StructType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *StructType) IsScalarType() bool { return false }\n\nfunc (t *StructType) String() string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(\"struct{\")\n\tfor i, v := range t.Fields {\n\t\tif i != 0 {\n\t\t\tbuf.WriteString(\"; \")\n\t\t}\n\t\tfmt.Fprintf(&buf, \"%s %s\", dict.S(v.Name), v.Type)\n\t\tif v.Bits != 0 {\n\t\t\tfmt.Fprintf(&buf, \".%d\", v.Bits)\n\t\t}\n\t}\n\tbuf.WriteByte('}')\n\treturn buf.String()\n}\n\n// TaggedEnumType represents an enum type described by a tag name.\ntype TaggedEnumType struct {\n\tTag   int\n\tType  Type\n\tscope *Scope\n}\n\n// IsUnsigned implements Type.\nfunc (t *TaggedEnumType) IsUnsigned() bool { return t.Type.IsUnsigned() }\n\n// Equal implements Type.\nfunc (t *TaggedEnumType) Equal(u Type) bool {\n\tswitch x := UnderlyingType(u).(type) {\n\tcase *EnumType:\n\t\tswitch y := t.getType(); {\n\t\tcase y == t:\n\t\t\tpanic(\"TODO\")\n\t\tdefault:\n\t\t\treturn y.Equal(u)\n\t\t}\n\tcase *TaggedEnumType:\n\t\tif t.Tag == x.Tag {\n\t\t\treturn true\n\t\t}\n\n\t\tpanic(\"TODO\")\n\tcase TypeKind:\n\t\tif x.IsScalarType() {\n\t\t\treturn false\n\t\t}\n\n\t\tpanic(fmt.Errorf(\"%v\", x))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// IsArithmeticType implements Type.\nfunc (t *TaggedEnumType) IsArithmeticType() bool { return true }\n\n// IsCompatible implements Type.\nfunc (t *TaggedEnumType) IsCompatible(u Type) bool {\n\tswitch x := t.getType(); {\n\tcase x == t:\n\t\tpanic(\"TODO\")\n\tdefault:\n\t\treturn underlyingType(x, true).IsCompatible(underlyingType(u, true))\n\t}\n}\n\n// IsIntegerType implements Type.\nfunc (t *TaggedEnumType) IsIntegerType() bool { return true }\n\n// IsPointerType implements Type.\nfunc (t *TaggedEnumType) IsPointerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *TaggedEnumType) IsScalarType() bool { return true }\n\n// IsVoidPointerType implements Type.\nfunc (t *TaggedEnumType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// Kind implements Type.\nfunc (t *TaggedEnumType) Kind() TypeKind { return Int }\n\nfunc (t *TaggedEnumType) String() string { return fmt.Sprintf(\"enum %s\", dict.S(t.Tag)) }\n\n// assign implements Type.\nfunc (t *TaggedEnumType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := UnderlyingType(op.Type).(type) {\n\tcase *EnumType:\n\t\t//TODO use IsCompatible\n\t\top.Type = t\n\t\treturn op\n\tcase TypeKind:\n\t\tif x.IsIntegerType() {\n\t\t\top.Type = t\n\t\t\treturn op\n\t\t}\n\n\t\tpanic(x)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\nfunc (t *TaggedEnumType) getType() Type {\n\tif t.Type != nil {\n\t\treturn t.Type\n\t}\n\n\ts := t.scope.lookupEnumTag(t.Tag)\n\tif s == nil {\n\t\treturn t\n\t}\n\n\tt.Type = s.typ\n\treturn t.Type\n}\n\n// TaggedStructType represents a struct type described by a tag name.\ntype TaggedStructType struct {\n\tTag   int\n\tType  Type\n\tscope *Scope\n}\n\n// IsUnsigned implements Type.\nfunc (t *TaggedStructType) IsUnsigned() bool { panic(\"TODO\") }\n\n// IsVoidPointerType implements Type.\nfunc (t *TaggedStructType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *TaggedStructType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *TaggedStructType) IsCompatible(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tif x, ok := u.(*TaggedStructType); ok && t.Tag == x.Tag {\n\t\treturn true\n\t}\n\n\ta := UnderlyingType(t)\n\tb := UnderlyingType(u)\n\treturn UnderlyingType(a).IsCompatible(UnderlyingType(b))\n}\n\n// Equal implements Type.\nfunc (t *TaggedStructType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tif x, ok := u.(*TaggedStructType); ok && t.Tag == x.Tag {\n\t\treturn true\n\t}\n\n\tswitch x := t.getType().(type) {\n\tcase *StructType:\n\t\treturn x.Equal(u)\n\tcase *TaggedStructType:\n\t\tif x == t {\n\t\t\tswitch y := u.(type) {\n\t\t\tcase *NamedType:\n\t\t\t\treturn t.Equal(y.Type)\n\t\t\tcase *StructType:\n\t\t\t\treturn false\n\t\t\tcase *TaggedStructType:\n\t\t\t\treturn t.Tag == y.Tag\n\t\t\tcase TypeKind:\n\t\t\t\tswitch y {\n\t\t\t\tcase Void:\n\t\t\t\t\treturn false\n\t\t\t\tdefault:\n\t\t\t\t\tpanic(y)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%T\", y))\n\t\t\t}\n\t\t}\n\n\t\tpanic(\"TODO\")\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\nfunc (t *TaggedStructType) getType() Type {\n\tif t.Type != nil {\n\t\treturn t.Type\n\t}\n\n\ts := t.scope.lookupStructTag(t.Tag)\n\tif s == nil {\n\t\treturn t\n\t}\n\n\tt.Type = s.typ\n\treturn t.Type\n}\n\n// Kind implements Type.\nfunc (t *TaggedStructType) Kind() TypeKind { return Struct }\n\n// assign implements Type.\nfunc (t *TaggedStructType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := op.Type.(type) {\n\tcase *NamedType:\n\t\top.Type = x.Type\n\t\treturn t.assign(ctx, n, op)\n\tcase *TaggedStructType:\n\t\tt2 := t.getType()\n\t\tu2 := x.getType()\n\t\tif t2 != t && u2 != x {\n\t\t\t// [0]6.5.16.1\n\t\t\t//\n\t\t\t// the left operand has a qualified or unqualified\n\t\t\t// version of a structure or union type compatible with\n\t\t\t// the type of the right;\n\t\t\tif t2.Equal(u2) {\n\t\t\t\treturn op\n\t\t\t}\n\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tpanic(\"TODO\")\n\tcase *StructType:\n\t\tt2 := t.getType()\n\t\tif t2.Equal(x) {\n\t\t\treturn op\n\t\t}\n\t\tpanic(fmt.Errorf(\"%v: %T %v, %T %v\", ctx.position(n), t2, t2, x, x))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *TaggedStructType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *TaggedStructType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *TaggedStructType) IsScalarType() bool { return false }\n\nfunc (t *TaggedStructType) String() string { return fmt.Sprintf(\"struct %s\", dict.S(t.Tag)) }\n\n// UnionType represents a union type.\ntype UnionType struct{ structBase }\n\n// Field returns the properties of field nm or nil if the field does not exist.\nfunc (t *UnionType) Field(nm int) *FieldProperties {\n\treturn t.findField(nm)\n}\n\n// IsUnsigned implements Type.\nfunc (t *UnionType) IsUnsigned() bool { panic(\"TODO\") }\n\n// TaggedUnionType represents a struct type described by a tag name.\ntype TaggedUnionType struct {\n\tTag   int\n\tType  Type\n\tscope *Scope\n}\n\n// IsUnsigned implements Type.\nfunc (t *TaggedUnionType) IsUnsigned() bool { panic(\"TODO\") }\n\n// IsVoidPointerType implements Type.\nfunc (t *TaggedUnionType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *TaggedUnionType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *TaggedUnionType) IsCompatible(u Type) bool { return t.Equal(u) }\n\n// Equal implements Type.\nfunc (t *TaggedUnionType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tif x, ok := u.(*TaggedUnionType); ok && t.Tag == x.Tag {\n\t\treturn true\n\t}\n\n\tswitch x := t.getType().(type) {\n\tcase *UnionType:\n\t\treturn x.Equal(u)\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\nfunc (t *TaggedUnionType) getType() Type {\n\tif t.Type != nil {\n\t\treturn t.Type\n\t}\n\n\ts := t.scope.lookupStructTag(t.Tag)\n\tif s == nil {\n\t\treturn t\n\t}\n\n\tt.Type = s.typ\n\treturn t.Type\n}\n\n// Kind implements Type.\nfunc (t *TaggedUnionType) Kind() TypeKind { return Union }\n\n// assign implements Type.\nfunc (t *TaggedUnionType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := op.Type.(type) {\n\tcase *TaggedUnionType:\n\t\tt2 := t.getType()\n\t\tu2 := x.getType()\n\t\tif t2 != t && u2 != x {\n\t\t\t// [0]6.5.16.1\n\t\t\t//\n\t\t\t// the left operand has a qualified or unqualified\n\t\t\t// version of a structure or union type compatible with\n\t\t\t// the type of the right;\n\t\t\tif t2.Equal(u2) {\n\t\t\t\treturn op\n\t\t\t}\n\n\t\t\tpanic(\"TODO\")\n\t\t}\n\t\tpanic(\"TODO\")\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%T\", x))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *TaggedUnionType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *TaggedUnionType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *TaggedUnionType) IsScalarType() bool { return false }\n\nfunc (t *TaggedUnionType) String() string { return fmt.Sprintf(\"union %s\", dict.S(t.Tag)) }\n\n// IsVoidPointerType implements Type.\nfunc (t *UnionType) IsVoidPointerType() bool { panic(\"TODO\") }\n\n// IsArithmeticType implements Type.\nfunc (t *UnionType) IsArithmeticType() bool { return false }\n\n// IsCompatible implements Type.\nfunc (t *UnionType) IsCompatible(u Type) bool {\n\tif t.Equal(u) {\n\t\treturn true\n\t}\n\n\tswitch x := UnderlyingType(u).(type) {\n\tcase TypeKind:\n\t\tif x.IsScalarType() {\n\t\t\treturn false\n\t\t}\n\t\tpanic(fmt.Errorf(\"%v %T %v\", t, x, x))\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v %T %v\", t, x, x))\n\t}\n}\n\n// Equal implements Type.\nfunc (t *UnionType) Equal(u Type) bool {\n\tif t == u {\n\t\treturn true\n\t}\n\n\tswitch x := u.(type) {\n\tcase *NamedType:\n\t\treturn t.Equal(x.Type)\n\tcase *PointerType:\n\t\treturn false\n\tcase *TaggedUnionType:\n\t\tv := x.Type\n\t\tif v == x {\n\t\t\tpanic(x)\n\t\t}\n\n\t\treturn t.Equal(v)\n\tcase TypeKind:\n\t\tswitch x {\n\t\tcase\n\t\t\tChar,\n\t\t\tInt,\n\t\t\tUInt,\n\t\t\tULongLong,\n\t\t\tVoid:\n\n\t\t\treturn false\n\t\tdefault:\n\t\t\tpanic(x)\n\t\t}\n\tcase *UnionType:\n\t\tif len(t.Fields) != len(x.Fields) || t.Tag != x.Tag {\n\t\t\treturn false\n\t\t}\n\n\t\tfor i, v := range t.Fields {\n\t\t\tif !v.equal(x.Fields[i]) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\treturn true\n\tdefault:\n\t\tpanic(x)\n\t}\n}\n\n// Kind implements Type.\nfunc (t *UnionType) Kind() TypeKind { return Union }\n\n// assign implements Type.\nfunc (t *UnionType) assign(ctx *context, n Node, op Operand) Operand {\n\tswitch x := op.Type.(type) {\n\tcase *NamedType:\n\t\tif !t.IsCompatible(x.Type) {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn Operand{Type: t}\n\tcase *UnionType:\n\t\tif !t.IsCompatible(x) {\n\t\t\tpanic(\"TODO\")\n\t\t}\n\n\t\treturn Operand{Type: t}\n\tdefault:\n\t\tpanic(fmt.Errorf(\"%v: %T %v\", ctx.position(n), x, x))\n\t}\n}\n\n// IsPointerType implements Type.\nfunc (t *UnionType) IsPointerType() bool { return false }\n\n// IsIntegerType implements Type.\nfunc (t *UnionType) IsIntegerType() bool { return false }\n\n// IsScalarType implements Type.\nfunc (t *UnionType) IsScalarType() bool { return false }\n\nfunc (t *UnionType) String() string {\n\tvar buf bytes.Buffer\n\tbuf.WriteString(\"union{\")\n\tfor i, v := range t.Fields {\n\t\tif i != 0 {\n\t\t\tbuf.WriteString(\"; \")\n\t\t}\n\t\tfmt.Fprintf(&buf, \"%s %s\", dict.S(v.Name), v.Type)\n\t\tif v.Bits != 0 {\n\t\t\tfmt.Fprintf(&buf, \".%d\", v.Bits)\n\t\t}\n\n\t}\n\tbuf.WriteByte('}')\n\treturn buf.String()\n}\n\n// AdjustedParameterType returns the type of an expression when used as an\n// argument of a function, see [0]6.9.1-10.\nfunc AdjustedParameterType(t Type) Type {\n\tu := t\n\tfor {\n\t\tswitch x := u.(type) {\n\t\tcase *ArrayType:\n\t\t\treturn &PointerType{t}\n\t\tcase *NamedType:\n\t\t\tif isVaList(x) {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\tu = x.Type\n\t\tcase\n\t\t\t*EnumType,\n\t\t\t*PointerType,\n\t\t\t*StructType,\n\t\t\t*TaggedEnumType,\n\t\t\t*TaggedStructType,\n\t\t\t*TaggedUnionType,\n\t\t\t*UnionType:\n\n\t\t\treturn t\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tChar,\n\t\t\t\tDouble,\n\t\t\t\tDoubleComplex,\n\t\t\t\tLongDouble,\n\t\t\t\tFloat,\n\t\t\t\tFloatComplex,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDoubleComplex,\n\t\t\t\tLongLong,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort:\n\n\t\t\t\treturn t\n\t\t\tdefault:\n\t\t\t\tpanic(x)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n}\n\n// UnderlyingType returns the concrete type of t, if posible.\nfunc UnderlyingType(t Type) Type { return underlyingType(t, false) }\n\nfunc underlyingType(t Type, enums bool) Type {\n\tfor {\n\t\tswitch x := t.(type) {\n\t\tcase\n\t\t\t*ArrayType,\n\t\t\t*FunctionType,\n\t\t\t*PointerType,\n\t\t\t*StructType,\n\t\t\t*UnionType:\n\n\t\t\treturn x\n\t\tcase *EnumType:\n\t\t\tif enums {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\treturn x.Enums[0].Operand.Type\n\t\tcase *NamedType:\n\t\t\tif x.Type == nil {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\tt = x.Type\n\t\tcase *TaggedEnumType:\n\t\t\tif x.Type == nil {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\tt = x.Type\n\t\tcase *TaggedStructType:\n\t\t\tif x.Type == nil {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\tt = x.Type\n\t\tcase *TaggedUnionType:\n\t\t\tif x.Type == nil {\n\t\t\t\treturn x\n\t\t\t}\n\n\t\t\tt = x.Type\n\t\tcase TypeKind:\n\t\t\tswitch x {\n\t\t\tcase\n\t\t\t\tBool,\n\t\t\t\tChar,\n\t\t\t\tDouble,\n\t\t\t\tDoubleComplex,\n\t\t\t\tFloat,\n\t\t\t\tFloatComplex,\n\t\t\t\tInt,\n\t\t\t\tLong,\n\t\t\t\tLongDouble,\n\t\t\t\tLongDoubleComplex,\n\t\t\t\tLongLong,\n\t\t\t\tPtr,\n\t\t\t\tSChar,\n\t\t\t\tShort,\n\t\t\t\tUChar,\n\t\t\t\tUInt,\n\t\t\t\tULong,\n\t\t\t\tULongLong,\n\t\t\t\tUShort,\n\t\t\t\tVoid:\n\n\t\t\t\treturn x\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Errorf(\"%v\", x))\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Errorf(\"%T\", x))\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "v2/ucn32.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build 386 arm armbe mips mipsle sparc\n\npackage cc\n\nvar ucnDigits = [...]uint32{\n\t0x33: 0x3ff,\n\t0x37: 0x3ff0000,\n\t0x4b: 0xffc0,\n\t0x4f: 0xffc0,\n\t0x53: 0xffc0,\n\t0x57: 0xffc0,\n\t0x5b: 0xffc0,\n\t0x5f: 0xff80,\n\t0x63: 0xffc0,\n\t0x67: 0xffc0,\n\t0x6b: 0xffc0,\n\t0x72: 0x3ff0000,\n\t0x76: 0x3ff0000,\n\t0x79: 0xfffff,\n}\n\nvar ucnNonDigits = [...]uint32{\n\t0x5: 0x4a00400, 0xff7fffff, 0xff7fffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xfc3fffff,\n\t0xffffff, 0x12: 0xffff0000, 0xffffffff,\n\t0xffffffff, 0xe9ff01ff, 0x30003, 0x1f,\n\t0x1b: 0x4000000,\n\t0xffffd740, 0xfffffffb, 0x547f7fff, 0xffffd,\n\t0xffffdffe, 0xffffffff, 0xdffeffff, 0xffffffff,\n\t0xffff0003, 0xffffffff, 0xffff199f, 0x33fcfff,\n\t0x29: 0xfffe0000, 0x27fffff, 0xfffffffe,\n\t0xff, 0x3ff0000, 0x2f: 0x70000,\n\t0x31: 0x7fffffe, 0x7ffff, 0xffff0000,\n\t0xffffffff, 0x7cffffff, 0x1fff7fff, 0x3de0,\n\t0x48: 0xffffffee, 0xe3ffffff, 0xff073fff, 0xf,\n\t0xfff99fee, 0xc3c5fdff, 0xb000399f, 0x3000f,\n\t0xfff987e4, 0xc36dfdff, 0x5e003987, 0x100000,\n\t0xfffbafee, 0xe3edfdff, 0x13bbf, 0x1,\n\t0xfff99fee, 0xe3cdfdff, 0xb000398f, 0x3,\n\t0xd63dc7ec, 0xc3bfc718, 0x3dc7,\n\t0x60: 0xfffddfee, 0xc3effdff, 0x3ddf, 0x3,\n\t0xfffddfec, 0xc3effdff, 0x40003ddf, 0x3,\n\t0xfffddfec, 0xc3fffdff, 0x3dcf, 0x3,\n\t0x70: 0xfffffffe, 0x7ffffff, 0xc00ffff,\n\t0x74: 0xfef02596, 0x3bff6cae, 0x30003f5f,\n\t0x78: 0x3000001, 0xc2a00000, 0xfffffeff, 0xfffe03ff,\n\t0xfebf0fdf, 0x2fe3fff,\n\t0x85: 0xffffffff, 0xffff003f, 0x7fffff,\n\t0xf0: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xfffffff, 0xffffffff, 0xffffffff, 0x3ffffff,\n\t0x3f3fffff, 0xffffffff, 0xaaff3f3f, 0x3fffffff,\n\t0xffffffff, 0x5fdfffff, 0xfcf1fdc, 0x1fdc1fff,\n\t0x101: 0x80000000, 0x1, 0x80000000,\n\t0x108: 0x3f2ffc84, 0x1fbfd50, 0x10b: 0xffffffff,\n\t0x7,\n\t0x180: 0xe0, 0x3fe, 0xfffffffe, 0xffffffff,\n\t0x180fffff, 0xfffffffe, 0xffffffff, 0x187fffff,\n\t0xffffffe0, 0x1fff,\n\t0x270: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0x3f,\n\t0x560: 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,\n\t0xffffffff, 0xf,\n}\n"
  },
  {
    "path": "v2/ucn64.go",
    "content": "// Copyright 2017 The CC Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n\n// +build amd64 amd64p32 arm64 arm64be ppc64 ppc64le mips64 mips64le mips64p32 mips64p32le sparc64\n\npackage cc\n\nvar ucnDigits = [...]uint64{\n\t0x19: 0x3ff00000000, 0x1b: 0x3ff000000000000,\n\t0x25: 0xffc000000000, 0x27: 0xffc000000000,\n\t0x29: 0xffc000000000, 0x2b: 0xffc000000000,\n\t0x2d: 0xffc000000000, 0x2f: 0xff8000000000,\n\t0x31: 0xffc000000000, 0x33: 0xffc000000000,\n\t0x35: 0xffc000000000,\n\t0x39: 0x3ff0000, 0x3b: 0x3ff0000,\n\t0xfffff00000000,\n}\n\nvar ucnNonDigits = [...]uint64{\n\t0x2: 0x4a0040000000000, 0xff7fffffff7fffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xfc3fffffffffffff,\n\t0xffffff, 0xffffffffffff0000, 0xe9ff01ffffffffff, 0x1f00030003,\n\t0xd: 0x400000000000000, 0xfffffffbffffd740, 0xffffd547f7fff,\n\t0xffffffffffffdffe, 0xffffffffdffeffff, 0xffffffffffff0003, 0x33fcfffffff199f,\n\t0xfffe000000000000, 0xfffffffe027fffff, 0x3ff0000000000ff, 0x7000000000000,\n\t0x7fffffe00000000, 0xffff00000007ffff, 0x7cffffffffffffff, 0x3de01fff7fff,\n\t0x24: 0xe3ffffffffffffee, 0xfff073fff, 0xc3c5fdfffff99fee, 0x3000fb000399f,\n\t0xc36dfdfffff987e4, 0x1000005e003987, 0xe3edfdfffffbafee, 0x100013bbf,\n\t0xe3cdfdfffff99fee, 0x3b000398f, 0xc3bfc718d63dc7ec, 0x3dc7,\n\t0xc3effdfffffddfee, 0x300003ddf, 0xc3effdfffffddfec, 0x340003ddf,\n\t0xc3fffdfffffddfec, 0x300003dcf,\n\t0x38: 0x7fffffffffffffe, 0xc00ffff, 0x3bff6caefef02596, 0x30003f5f,\n\t0xc2a0000003000001, 0xfffe03fffffffeff, 0x2fe3ffffebf0fdf,\n\t0x42: 0xffffffff00000000, 0x7fffffffff003f,\n\t0x78: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffff0fffffff, 0x3ffffffffffffff,\n\t0xffffffff3f3fffff, 0x3fffffffaaff3f3f, 0x5fdfffffffffffff, 0x1fdc1fff0fcf1fdc,\n\t0x8000000000000000, 0x8000000000000001,\n\t0x84: 0x1fbfd503f2ffc84, 0xffffffff00000000, 0x7,\n\t0xc0: 0x3fe000000e0, 0xfffffffffffffffe, 0xfffffffe180fffff, 0x187fffffffffffff,\n\t0x1fffffffffe0,\n\t0x138: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0x3fffffffff,\n\t0x2b0: 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff,\n\t0xffffffffffffffff, 0xffffffffffffffff, 0xfffffffff,\n}\n"
  },
  {
    "path": "xerrors",
    "content": "//TODO Revisit: PPIF PPOTHER '\\n' '\\n' \"unterminated #if\"\n\nCONSTANT_EXPRESSION \t|\nPREPROCESSING_FILE \t|\nTRANSLATION_UNIT \"unexpected EOF\"\n"
  }
]